From bc7951574e3922cf540120c38c12d5e01eff1d6a Mon Sep 17 00:00:00 2001 From: openset Date: Tue, 10 Dec 2019 14:05:31 +0800 Subject: [PATCH 001/145] Update: mysql schemas --- problems/exchange-seats/table_seat.sql | 43 -------------------------- 1 file changed, 43 deletions(-) delete mode 100644 problems/exchange-seats/table_seat.sql diff --git a/problems/exchange-seats/table_seat.sql b/problems/exchange-seats/table_seat.sql deleted file mode 100644 index 7f99fff91..000000000 --- a/problems/exchange-seats/table_seat.sql +++ /dev/null @@ -1,43 +0,0 @@ -/* - Navicat Premium Data Transfer - - Source Server : root@localhost - Source Server Type : MySQL - Source Server Version : 50724 - Source Host : localhost:3306 - Source Schema : leetcode - - Target Server Type : MySQL - Target Server Version : 50724 - File Encoding : 65001 - - Date: 14/02/2019 11:42:34 -*/ - -SET NAMES utf8mb4; -SET FOREIGN_KEY_CHECKS = 0; - --- ---------------------------- --- Table structure for seat --- ---------------------------- -DROP TABLE IF EXISTS `seat`; -CREATE TABLE `seat` ( - `id` int(11) DEFAULT NULL, - `student` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_unicode_ci; - --- ---------------------------- --- Records of seat --- ---------------------------- -BEGIN; -INSERT INTO `seat` VALUES (1, 'Abbot'); -INSERT INTO `seat` VALUES (2, 'Doris'); -INSERT INTO `seat` VALUES (3, 'Emerson'); -INSERT INTO `seat` VALUES (4, 'Green'); -INSERT INTO `seat` VALUES (5, 'Jeames'); -COMMIT; - -SET FOREIGN_KEY_CHECKS = 1; From baa78033139bf8e5c5891cb1451370c2dfdc773c Mon Sep 17 00:00:00 2001 From: openset Date: Tue, 10 Dec 2019 14:26:32 +0800 Subject: [PATCH 002/145] simplified --- tag/tags.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tag/tags.js b/tag/tags.js index 24e962533..f5c8f0b77 100644 --- a/tag/tags.js +++ b/tag/tags.js @@ -1,9 +1,9 @@ -tags = new Array(); +tags = []; document.querySelectorAll('#all-topic-tags>a').forEach(function (e) { tags.push({ "Name": e.title || e.firstElementChild.innerText.trim(), "Slug": /tag\/(\S+?)\//.exec(e.href)[1], - "TranslatedName": e.innerText.trim().replace(/\n/g, '') + "TranslatedName": e.innerText.trim().replace(/\n/g, ''), }); }); newWindow = window.open('', 'frame_name'); From 845e8687dd9686e814f717e8ae86d967582be570 Mon Sep 17 00:00:00 2001 From: openset Date: Wed, 11 Dec 2019 11:18:27 +0800 Subject: [PATCH 003/145] Add: Valid Perfect Square --- internal/leetcode/problems_status.go | 1 + .../valid_perfect_square.go | 7 ++++ .../valid_perfect_square_test.go | 38 +++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/internal/leetcode/problems_status.go b/internal/leetcode/problems_status.go index dd94a0ac4..9bf58a52b 100644 --- a/internal/leetcode/problems_status.go +++ b/internal/leetcode/problems_status.go @@ -100,6 +100,7 @@ var problemStatus = map[int]bool{ 344: true, 345: true, 350: true, + 367: true, 371: true, 383: true, 387: true, diff --git a/problems/valid-perfect-square/valid_perfect_square.go b/problems/valid-perfect-square/valid_perfect_square.go index 15910f848..7bb0af941 100644 --- a/problems/valid-perfect-square/valid_perfect_square.go +++ b/problems/valid-perfect-square/valid_perfect_square.go @@ -1 +1,8 @@ package problem367 + +func isPerfectSquare(num int) bool { + for i := 1; num > 0; i += 2 { + num -= i + } + return num == 0 +} diff --git a/problems/valid-perfect-square/valid_perfect_square_test.go b/problems/valid-perfect-square/valid_perfect_square_test.go index 15910f848..258f035eb 100644 --- a/problems/valid-perfect-square/valid_perfect_square_test.go +++ b/problems/valid-perfect-square/valid_perfect_square_test.go @@ -1 +1,39 @@ package problem367 + +import "testing" + +type testType struct { + in int + want bool +} + +func TestIsPerfectSquare(t *testing.T) { + tests := [...]testType{ + { + in: 16, + want: true, + }, + { + in: 14, + want: false, + }, + { + in: 0, + want: true, + }, + { + in: 1, + want: true, + }, + { + in: 3, + want: false, + }, + } + for _, tt := range tests { + got := isPerfectSquare(tt.in) + if got != tt.want { + t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want) + } + } +} From 2143f5cc5802a8d8f3738601f6b2b7e24edccaf7 Mon Sep 17 00:00:00 2001 From: openset Date: Thu, 12 Dec 2019 17:03:29 +0800 Subject: [PATCH 004/145] Add: Minimum Moves to Equal Array Elements --- .../minimum_moves_to_equal_array_elements.go | 11 ++++++++++ ...imum_moves_to_equal_array_elements_test.go | 22 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/problems/minimum-moves-to-equal-array-elements/minimum_moves_to_equal_array_elements.go b/problems/minimum-moves-to-equal-array-elements/minimum_moves_to_equal_array_elements.go index 74b359ae4..c8f837ede 100644 --- a/problems/minimum-moves-to-equal-array-elements/minimum_moves_to_equal_array_elements.go +++ b/problems/minimum-moves-to-equal-array-elements/minimum_moves_to_equal_array_elements.go @@ -1 +1,12 @@ package problem453 + +func minMoves(nums []int) int { + sum, min, n := 0, nums[0], len(nums) + for _, num := range nums { + sum += num + if min > num { + min = num + } + } + return sum - n*min +} diff --git a/problems/minimum-moves-to-equal-array-elements/minimum_moves_to_equal_array_elements_test.go b/problems/minimum-moves-to-equal-array-elements/minimum_moves_to_equal_array_elements_test.go index 74b359ae4..4427be7f1 100644 --- a/problems/minimum-moves-to-equal-array-elements/minimum_moves_to_equal_array_elements_test.go +++ b/problems/minimum-moves-to-equal-array-elements/minimum_moves_to_equal_array_elements_test.go @@ -1 +1,23 @@ package problem453 + +import "testing" + +type testType struct { + in []int + want int +} + +func TestMinMoves(t *testing.T) { + tests := [...]testType{ + { + in: []int{1, 2, 3}, + want: 3, + }, + } + for _, tt := range tests { + got := minMoves(tt.in) + if got != tt.want { + t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want) + } + } +} From 7828e29a07db878cf4bd8a560927bd757fe5fb5b Mon Sep 17 00:00:00 2001 From: openset Date: Thu, 12 Dec 2019 17:23:51 +0800 Subject: [PATCH 005/145] Add: Minimum Moves to Equal Array Elements --- README.md | 1 + internal/leetcode/problems_status.go | 1 + .../minimum_moves_to_equal_array_elements_test.go | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/README.md b/README.md index fe3f1906c..6fa4440dc 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1285 | [Find the Start and End Number of Continuous Ranges](https://leetcode.com/problems/find-the-start-and-end-number-of-continuous-ranges) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/find-the-start-and-end-number-of-continuous-ranges) | Medium | | 1284 | [Minimum Number of Flips to Convert Binary Matrix to Zero Matrix](https://leetcode.com/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix "转化为全零矩阵的最少反转次数") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | Hard | | 1283 | [Find the Smallest Divisor Given a Threshold](https://leetcode.com/problems/find-the-smallest-divisor-given-a-threshold "使结果不超过阈值的最小除数") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-the-smallest-divisor-given-a-threshold) | Medium | | 1282 | [Group the People Given the Group Size They Belong To](https://leetcode.com/problems/group-the-people-given-the-group-size-they-belong-to "用户分组") | [Go](https://github.com/openset/leetcode/tree/master/problems/group-the-people-given-the-group-size-they-belong-to) | Medium | diff --git a/internal/leetcode/problems_status.go b/internal/leetcode/problems_status.go index 9bf58a52b..806d419be 100644 --- a/internal/leetcode/problems_status.go +++ b/internal/leetcode/problems_status.go @@ -114,6 +114,7 @@ var problemStatus = map[int]bool{ 443: true, 445: true, 448: true, + 453: true, 455: true, 459: true, 461: true, diff --git a/problems/minimum-moves-to-equal-array-elements/minimum_moves_to_equal_array_elements_test.go b/problems/minimum-moves-to-equal-array-elements/minimum_moves_to_equal_array_elements_test.go index 4427be7f1..e98692c00 100644 --- a/problems/minimum-moves-to-equal-array-elements/minimum_moves_to_equal_array_elements_test.go +++ b/problems/minimum-moves-to-equal-array-elements/minimum_moves_to_equal_array_elements_test.go @@ -13,6 +13,10 @@ func TestMinMoves(t *testing.T) { in: []int{1, 2, 3}, want: 3, }, + { + in: []int{5, 3, 1}, + want: 6, + }, } for _, tt := range tests { got := minMoves(tt.in) From 5cd03632178111f0c5778d32976da9e672d473bf Mon Sep 17 00:00:00 2001 From: openset Date: Thu, 12 Dec 2019 17:25:09 +0800 Subject: [PATCH 006/145] Add: new --- .../README.md | 60 +++++++++++++++ .../mysql_schemas.sql | 8 ++ .../README.md | 74 +++++++++++++++---- .../README.md | 2 +- 4 files changed, 130 insertions(+), 14 deletions(-) create mode 100644 problems/find-the-start-and-end-number-of-continuous-ranges/README.md create mode 100644 problems/find-the-start-and-end-number-of-continuous-ranges/mysql_schemas.sql diff --git a/problems/find-the-start-and-end-number-of-continuous-ranges/README.md b/problems/find-the-start-and-end-number-of-continuous-ranges/README.md new file mode 100644 index 000000000..fbc0e7e9c --- /dev/null +++ b/problems/find-the-start-and-end-number-of-continuous-ranges/README.md @@ -0,0 +1,60 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix "Minimum Number of Flips to Convert Binary Matrix to Zero Matrix") +                 +Next > + +## [1285. Find the Start and End Number of Continuous Ranges (Medium)](https://leetcode.com/problems/find-the-start-and-end-number-of-continuous-ranges "") +`` +

Table: Logs

+
++---------------+---------+
+| Column Name   | Type    |
++---------------+---------+
+| log_id        | int     |
++---------------+---------+
+id is the primary key for this table.
+Each row of this table contains the ID in a log Table.
+
+ +Since some IDs have been removed from Logs. Write an SQL query to find the start and end number of continuous ranges in table Logs. + +Order the result table by start_id. + +The query result format is in the following example: +
+Logs table:
++------------+
+| log_id     |
++------------+
+| 1          |
+| 2          |
+| 3          |
+| 7          |
+| 8          |
+| 10         |
++------------+
+
+Result table:
++------------+--------------+
+| start_id   | end_id       |
++------------+--------------+
+| 1          | 3            |
+| 7          | 8            |
+| 10         | 10           |
++------------+--------------+
+The result table should contain all ranges in table Logs.
+From 1 to 3 is contained in the table.
+From 4 to 6 is missing in the table
+From 7 to 8 is contained in the table.
+Number 9 is missing in the table.
+Number 10 is contained in the table.
+
+ +### Similar Questions + 1. [Report Contiguous Dates](https://github.com/openset/leetcode/tree/master/problems/report-contiguous-dates) (Hard) diff --git a/problems/find-the-start-and-end-number-of-continuous-ranges/mysql_schemas.sql b/problems/find-the-start-and-end-number-of-continuous-ranges/mysql_schemas.sql new file mode 100644 index 000000000..3f578ff5a --- /dev/null +++ b/problems/find-the-start-and-end-number-of-continuous-ranges/mysql_schemas.sql @@ -0,0 +1,8 @@ +Create table If Not Exists Logs (log_id int); +Truncate table Logs; +insert into Logs (log_id) values ('1'); +insert into Logs (log_id) values ('2'); +insert into Logs (log_id) values ('3'); +insert into Logs (log_id) values ('7'); +insert into Logs (log_id) values ('8'); +insert into Logs (log_id) values ('10'); diff --git a/problems/flatten-a-multilevel-doubly-linked-list/README.md b/problems/flatten-a-multilevel-doubly-linked-list/README.md index 8049638b1..b43386a6a 100644 --- a/problems/flatten-a-multilevel-doubly-linked-list/README.md +++ b/problems/flatten-a-multilevel-doubly-linked-list/README.md @@ -16,36 +16,84 @@

Flatten the list so that all the nodes appear in a single-level, doubly linked list. You are given the head of the first level of the list.

 

+

Example 1:

-

Example:

+
+Input: head = [1,2,3,4,5,6,null,null,null,7,8,9,10,null,null,11,12]
+Output: [1,2,3,7,8,11,12,9,10,4,5,6]
+Explanation:
+
+The multilevel linked list in the input is as follows:
+
+
+
+After flattening the multilevel linked list it becomes:
+
+
+
+ +

Example 2:

+ +
+Input: head = [1,2,null,3]
+Output: [1,3,2]
+Explanation:
+
+The input multilevel linked list is as follows:
+
+  1---2---NULL
+  |
+  3---NULL
+
+ +

Example 3:

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

 

+ +

How multilevel linked list is represented in test case:

+ +

We use the multilevel linked list from Example 1 above:

-Input:
  1---2---3---4---5---6--NULL
          |
          7---8---9---10--NULL
              |
-             11--12--NULL
+             11--12--NULL
+ +

The serialization of each level is as follows:

-Output: -1-2-3-7-8-11-12-9-10-4-5-6-NULL +
+[1,2,3,4,5,6,null]
+[7,8,9,10,null]
+[11,12,null]
 
-

 

+

To serialize all levels together we will add nulls in each level to signify no node connects to the upper node of the previous level. The serialization becomes:

-

Explanation for the above example:

+
+[1,2,3,4,5,6,null]
+[null,null,7,8,9,10,null]
+[null,11,12,null]
+
-

Given the following multilevel doubly linked list:

+

Merging the serialization of each level and removing trailing nulls we obtain:

-
+[1,2,3,4,5,6,null,null,null,7,8,9,10,null,null,11,12]

 

+

Constraints:

-

We should return the following flattened doubly linked list:

- -
-
+
    +
  • Number of Nodes will not exceed 1000.
  • +
  • 1 <= Node.val <= 10^5
  • +
### Related Topics [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] diff --git a/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md b/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md index 9689d7591..1221df4e1 100644 --- a/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md +++ b/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md @@ -7,7 +7,7 @@ [< Previous](https://github.com/openset/leetcode/tree/master/problems/find-the-smallest-divisor-given-a-threshold "Find the Smallest Divisor Given a Threshold")                  -Next > +[Next >](https://github.com/openset/leetcode/tree/master/problems/find-the-start-and-end-number-of-continuous-ranges "Find the Start and End Number of Continuous Ranges") ## [1284. Minimum Number of Flips to Convert Binary Matrix to Zero Matrix (Hard)](https://leetcode.com/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix "转化为全零矩阵的最少反转次数") From 2f890ff5639e9cc1a1a1daabf58e4c1e10755897 Mon Sep 17 00:00:00 2001 From: openset Date: Thu, 12 Dec 2019 17:33:04 +0800 Subject: [PATCH 007/145] Add: desc --- .../README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/problems/find-the-start-and-end-number-of-continuous-ranges/README.md b/problems/find-the-start-and-end-number-of-continuous-ranges/README.md index fbc0e7e9c..928d4d8bd 100644 --- a/problems/find-the-start-and-end-number-of-continuous-ranges/README.md +++ b/problems/find-the-start-and-end-number-of-continuous-ranges/README.md @@ -10,7 +10,7 @@ Next > ## [1285. Find the Start and End Number of Continuous Ranges (Medium)](https://leetcode.com/problems/find-the-start-and-end-number-of-continuous-ranges "") -`` +

Table: Logs

 +---------------+---------+

From 0bccb04e0f208177f5142fca7f9d1919a4452571 Mon Sep 17 00:00:00 2001
From: openset 
Date: Thu, 12 Dec 2019 17:57:02 +0800
Subject: [PATCH 008/145] Add: Balanced Binary Tree

---
 .../balanced_binary_tree.go                   | 35 +++++++++----------
 .../balanced_binary_tree_test.go              | 30 ++++++++++++++++
 2 files changed, 47 insertions(+), 18 deletions(-)

diff --git a/problems/balanced-binary-tree/balanced_binary_tree.go b/problems/balanced-binary-tree/balanced_binary_tree.go
index ed9f4bfc4..83750f1b4 100644
--- a/problems/balanced-binary-tree/balanced_binary_tree.go
+++ b/problems/balanced-binary-tree/balanced_binary_tree.go
@@ -14,26 +14,25 @@ type TreeNode = kit.TreeNode
  * }
  */
 func isBalanced(root *TreeNode) bool {
-	_, isBalanced := recur(root)
-	return isBalanced
-}
-
-func recur(root *TreeNode) (int, bool) {
-	if root == nil {
-		return 0, true
-	}
-	leftDepth, leftIsBalanced := recur(root.Left)
-	rightDepth, rightIsBalanced := recur(root.Right)
-	if leftIsBalanced && rightIsBalanced &&
-		-1 <= leftDepth-rightDepth && leftDepth-rightDepth <= 1 {
-		return max(leftDepth, rightDepth) + 1, true
+	if root != nil {
+		left := depth(root.Left)
+		right := depth(root.Right)
+		if left > right+1 || left < right-1 {
+			return false
+		}
+		return isBalanced(root.Left) && isBalanced(root.Right)
 	}
-	return 0, false
+	return true
 }
 
-func max(a, b int) int {
-	if a > b {
-		return a
+func depth(root *TreeNode) int {
+	if root != nil {
+		left := depth(root.Left) + 1
+		right := depth(root.Right) + 1
+		if left > right {
+			return left
+		}
+		return right
 	}
-	return b
+	return 0
 }
diff --git a/problems/balanced-binary-tree/balanced_binary_tree_test.go b/problems/balanced-binary-tree/balanced_binary_tree_test.go
index e4fba9215..459dd6205 100644
--- a/problems/balanced-binary-tree/balanced_binary_tree_test.go
+++ b/problems/balanced-binary-tree/balanced_binary_tree_test.go
@@ -1 +1,31 @@
 package problem110
+
+import (
+	"testing"
+
+	"github.com/openset/leetcode/internal/kit"
+)
+
+type testType struct {
+	in   []int
+	want bool
+}
+
+func TestIsBalanced(t *testing.T) {
+	tests := [...]testType{
+		{
+			in:   []int{3, 9, 20, kit.NULL, kit.NULL, 15, 7},
+			want: true,
+		},
+		{
+			in:   []int{1, 2, 2, 3, 3, kit.NULL, kit.NULL, 4, 4},
+			want: false,
+		},
+	}
+	for _, tt := range tests {
+		got := isBalanced(kit.SliceInt2TreeNode(tt.in))
+		if got != tt.want {
+			t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want)
+		}
+	}
+}

From 294aef34bf683dbf3aecc6fd93fc4b2154d91dd4 Mon Sep 17 00:00:00 2001
From: openset 
Date: Fri, 13 Dec 2019 10:45:15 +0800
Subject: [PATCH 009/145] Add: Perfect Number

---
 problems/perfect-number/perfect_number.go     | 30 ++++++++++++
 .../perfect-number/perfect_number_test.go     | 46 +++++++++++++++++++
 2 files changed, 76 insertions(+)

diff --git a/problems/perfect-number/perfect_number.go b/problems/perfect-number/perfect_number.go
index 414ce1f4d..7a53b0d82 100644
--- a/problems/perfect-number/perfect_number.go
+++ b/problems/perfect-number/perfect_number.go
@@ -1 +1,31 @@
 package problem507
+
+// Solution 1
+func checkPerfectNumber(num int) bool {
+	if num < 6 {
+		return false
+	}
+	sum, mid := 1, num
+	for i := 2; i < mid; i++ {
+		if num%i == 0 {
+			n := num / i
+			sum += i + n
+			if mid > n {
+				mid = n
+			}
+		}
+	}
+	return sum == num
+}
+
+// Solution 2
+func checkPerfectNumber2(num int) bool {
+	m := map[int]bool{
+		6:        true,
+		28:       true,
+		496:      true,
+		8128:     true,
+		33550336: true,
+	}
+	return m[num]
+}
diff --git a/problems/perfect-number/perfect_number_test.go b/problems/perfect-number/perfect_number_test.go
index 414ce1f4d..fff1471b0 100644
--- a/problems/perfect-number/perfect_number_test.go
+++ b/problems/perfect-number/perfect_number_test.go
@@ -1 +1,47 @@
 package problem507
+
+import "testing"
+
+type testType struct {
+	in   int
+	want bool
+}
+
+func TestCheckPerfectNumber(t *testing.T) {
+	tests := [...]testType{
+		{
+			in:   28,
+			want: true,
+		},
+		{
+			in:   6,
+			want: true,
+		},
+		{
+			in:   24,
+			want: false,
+		},
+		{
+			in:   1,
+			want: false,
+		},
+		{
+			in:   33550336,
+			want: true,
+		},
+	}
+	// Solution 1
+	for _, tt := range tests {
+		got := checkPerfectNumber(tt.in)
+		if got != tt.want {
+			t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want)
+		}
+	}
+	// Solution 2
+	for _, tt := range tests {
+		got := checkPerfectNumber2(tt.in)
+		if got != tt.want {
+			t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want)
+		}
+	}
+}

From a937658152e4f14d6c20b416a19276f40c23581e Mon Sep 17 00:00:00 2001
From: openset 
Date: Mon, 16 Dec 2019 09:43:25 +0800
Subject: [PATCH 010/145] Add: new

---
 README.md                                     |  8 ++
 .../README.md                                 | 77 +++++++++++++++++++
 .../README.md                                 | 48 ++++++++++++
 .../README.md                                 |  5 +-
 problems/flip-game-ii/README.md               |  2 +-
 problems/iterator-for-combination/README.md   | 59 ++++++++++++++
 .../README.md                                 | 75 ++++++++++++++++++
 .../minimum-falling-path-sum-ii/README.md     | 57 ++++++++++++++
 problems/remove-covered-intervals/README.md   | 48 ++++++++++++
 problems/sequential-digits/README.md          | 45 +++++++++++
 .../README.md                                 | 76 ++++++++++++++++++
 tag/README.md                                 | 10 +--
 tag/array/README.md                           |  2 +
 tag/backtracking/README.md                    |  2 +
 tag/binary-search/README.md                   |  1 +
 tag/bit-manipulation/README.md                |  1 +
 tag/breadth-first-search/README.md            |  1 +
 tag/design/README.md                          |  1 +
 tag/dynamic-programming/README.md             |  1 +
 tag/line-sweep/README.md                      |  1 +
 tag/linked-list/README.md                     |  1 +
 tag/tags.json                                 | 20 ++---
 22 files changed, 521 insertions(+), 20 deletions(-)
 create mode 100644 problems/convert-binary-number-in-a-linked-list-to-integer/README.md
 create mode 100644 problems/element-appearing-more-than-25-in-sorted-array/README.md
 create mode 100644 problems/iterator-for-combination/README.md
 create mode 100644 problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md
 create mode 100644 problems/minimum-falling-path-sum-ii/README.md
 create mode 100644 problems/remove-covered-intervals/README.md
 create mode 100644 problems/sequential-digits/README.md
 create mode 100644 problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md

diff --git a/README.md b/README.md
index 6fa4440dc..967fab798 100644
--- a/README.md
+++ b/README.md
@@ -62,6 +62,14 @@ LeetCode Problems' Solutions
 
 | # | Title | Solution | Difficulty |
 | :-: | - | - | :-: |
+| 1293 | [Shortest Path in a Grid with Obstacles Elimination](https://leetcode.com/problems/shortest-path-in-a-grid-with-obstacles-elimination "网格中的最短路径") | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-path-in-a-grid-with-obstacles-elimination) | Hard |
+| 1292 | [Maximum Side Length of a Square with Sum Less than or Equal to Threshold](https://leetcode.com/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold "元素和小于等于阈值的正方形的最大边长") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | Medium |
+| 1291 | [Sequential Digits](https://leetcode.com/problems/sequential-digits "顺次数") | [Go](https://github.com/openset/leetcode/tree/master/problems/sequential-digits) | Medium |
+| 1290 | [Convert Binary Number in a Linked List to Integer](https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer "二进制链表转整数") | [Go](https://github.com/openset/leetcode/tree/master/problems/convert-binary-number-in-a-linked-list-to-integer) | Easy |
+| 1289 | [Minimum Falling Path Sum II](https://leetcode.com/problems/minimum-falling-path-sum-ii "下降路径最小和  II") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-falling-path-sum-ii) | Hard |
+| 1288 | [Remove Covered Intervals](https://leetcode.com/problems/remove-covered-intervals "删除被覆盖区间") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-covered-intervals) | Medium |
+| 1287 | [Element Appearing More Than 25% In Sorted Array](https://leetcode.com/problems/element-appearing-more-than-25-in-sorted-array "有序数组中出现次数超过25%的元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/element-appearing-more-than-25-in-sorted-array) | Easy |
+| 1286 | [Iterator for Combination](https://leetcode.com/problems/iterator-for-combination "字母组合迭代器") | [Go](https://github.com/openset/leetcode/tree/master/problems/iterator-for-combination) | Medium |
 | 1285 | [Find the Start and End Number of Continuous Ranges](https://leetcode.com/problems/find-the-start-and-end-number-of-continuous-ranges) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/find-the-start-and-end-number-of-continuous-ranges) | Medium |
 | 1284 | [Minimum Number of Flips to Convert Binary Matrix to Zero Matrix](https://leetcode.com/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix "转化为全零矩阵的最少反转次数") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | Hard |
 | 1283 | [Find the Smallest Divisor Given a Threshold](https://leetcode.com/problems/find-the-smallest-divisor-given-a-threshold "使结果不超过阈值的最小除数") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-the-smallest-divisor-given-a-threshold) | Medium |
diff --git a/problems/convert-binary-number-in-a-linked-list-to-integer/README.md b/problems/convert-binary-number-in-a-linked-list-to-integer/README.md
new file mode 100644
index 000000000..688a1ad50
--- /dev/null
+++ b/problems/convert-binary-number-in-a-linked-list-to-integer/README.md
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-falling-path-sum-ii "Minimum Falling Path Sum II")
+                
+[Next >](https://github.com/openset/leetcode/tree/master/problems/sequential-digits "Sequential Digits")
+
+## [1290. Convert Binary Number in a Linked List to Integer (Easy)](https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer "二进制链表转整数")
+
+

Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. The linked list holds the binary representation of a number.

+ +

Return the decimal value of the number in the linked list.

+ +

 

+

Example 1:

+ +
+Input: head = [1,0,1]
+Output: 5
+Explanation: (101) in base 2 = (5) in base 10
+
+ +

Example 2:

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

Example 3:

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

Example 4:

+ +
+Input: head = [1,0,0,1,0,0,1,1,1,0,0,0,0,0,0]
+Output: 18880
+
+ +

Example 5:

+ +
+Input: head = [0,0]
+Output: 0
+
+ +

 

+

Constraints:

+ +
    +
  • The Linked List is not empty.
  • +
  • Number of nodes will not exceed 30.
  • +
  • Each node's value is either 0 or 1.
  • +
+ +### Related Topics + [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] + [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + +### Hints +
+Hint 1 +Traverse the linked list and store all values in a string or array. convert the values obtained to decimal value. +
+ +
+Hint 2 +You can solve the problem in O(1) memory using bits operation. use shift left operation ( << ) and or operation ( | ) to get the decimal value in one operation. +
diff --git a/problems/element-appearing-more-than-25-in-sorted-array/README.md b/problems/element-appearing-more-than-25-in-sorted-array/README.md new file mode 100644 index 000000000..172d085de --- /dev/null +++ b/problems/element-appearing-more-than-25-in-sorted-array/README.md @@ -0,0 +1,48 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/iterator-for-combination "Iterator for Combination") +                 +[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-covered-intervals "Remove Covered Intervals") + +## [1287. Element Appearing More Than 25% In Sorted Array (Easy)](https://leetcode.com/problems/element-appearing-more-than-25-in-sorted-array "有序数组中出现次数超过25%的元素") + +

Given an integer array sorted in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time.

+ +

Return that integer.

+ +

 

+

Example 1:

+
Input: arr = [1,2,2,6,6,6,6,7,10]
+Output: 6
+
+

 

+

Constraints:

+ +
    +
  • 1 <= arr.length <= 10^4
  • +
  • 0 <= arr[i] <= 10^5
  • +
+ +### Related Topics + [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + +### Hints +
+Hint 1 +Divide the array in four parts [1 - 25%] [25 - 50 %] [50 - 75 %] [75% - 100%] +
+ +
+Hint 2 +The answer should be in one of the ends of the intervals. +
+ +
+Hint 3 +In order to check which is element is the answer we can count the frequency with binarySearch. +
diff --git a/problems/find-the-start-and-end-number-of-continuous-ranges/README.md b/problems/find-the-start-and-end-number-of-continuous-ranges/README.md index 928d4d8bd..5cc40e68f 100644 --- a/problems/find-the-start-and-end-number-of-continuous-ranges/README.md +++ b/problems/find-the-start-and-end-number-of-continuous-ranges/README.md @@ -7,7 +7,7 @@ [< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix "Minimum Number of Flips to Convert Binary Matrix to Zero Matrix")                  -Next > +[Next >](https://github.com/openset/leetcode/tree/master/problems/iterator-for-combination "Iterator for Combination") ## [1285. Find the Start and End Number of Continuous Ranges (Medium)](https://leetcode.com/problems/find-the-start-and-end-number-of-continuous-ranges "") @@ -55,6 +55,3 @@ From 7 to 8 is contained in the table. Number 9 is missing in the table. Number 10 is contained in the table.
- -### Similar Questions - 1. [Report Contiguous Dates](https://github.com/openset/leetcode/tree/master/problems/report-contiguous-dates) (Hard) diff --git a/problems/flip-game-ii/README.md b/problems/flip-game-ii/README.md index 3e06aca37..c710e0c82 100644 --- a/problems/flip-game-ii/README.md +++ b/problems/flip-game-ii/README.md @@ -27,8 +27,8 @@ Derive your algorithm's runtime complexity.

### Related Topics - [[Minimax](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Minimax](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] ### Similar Questions 1. [Nim Game](https://github.com/openset/leetcode/tree/master/problems/nim-game) (Easy) diff --git a/problems/iterator-for-combination/README.md b/problems/iterator-for-combination/README.md new file mode 100644 index 000000000..b4b1c9239 --- /dev/null +++ b/problems/iterator-for-combination/README.md @@ -0,0 +1,59 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-the-start-and-end-number-of-continuous-ranges "Find the Start and End Number of Continuous Ranges") +                 +[Next >](https://github.com/openset/leetcode/tree/master/problems/element-appearing-more-than-25-in-sorted-array "Element Appearing More Than 25% In Sorted Array") + +## [1286. Iterator for Combination (Medium)](https://leetcode.com/problems/iterator-for-combination "字母组合迭代器") + +

Design an Iterator class, which has:

+ +
    +
  • A constructor that takes a string characters of sorted distinct lowercase English letters and a number combinationLength as arguments.
  • +
  • A function next() that returns the next combination of length combinationLength in lexicographical order.
  • +
  • A function hasNext() that returns True if and only if there exists a next combination.
  • +
+ +

 

+ +

Example:

+ +
+CombinationIterator iterator = new CombinationIterator("abc", 2); // creates the iterator.
+
+iterator.next(); // returns "ab"
+iterator.hasNext(); // returns true
+iterator.next(); // returns "ac"
+iterator.hasNext(); // returns true
+iterator.next(); // returns "bc"
+iterator.hasNext(); // returns false
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= combinationLength <= characters.length <= 15
  • +
  • There will be at most 10^4 function calls per test.
  • +
  • It's guaranteed that all calls of the function next are valid.
  • +
+ +### Related Topics + [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + +### Hints +
+Hint 1 +Generate all combinations as a preprocessing. +
+ +
+Hint 2 +Use bit masking to generate all the combinations. +
diff --git a/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md b/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md new file mode 100644 index 000000000..ad3036b92 --- /dev/null +++ b/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/sequential-digits "Sequential Digits") +                 +[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-path-in-a-grid-with-obstacles-elimination "Shortest Path in a Grid with Obstacles Elimination") + +## [1292. Maximum Side Length of a Square with Sum Less than or Equal to Threshold (Medium)](https://leetcode.com/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold "元素和小于等于阈值的正方形的最大边长") + +

Given a m x n matrix mat and an integer threshold. Return the maximum side-length of a square with a sum less than or equal to threshold or return 0 if there is no such square.

+ +

 

+

Example 1:

+ +
+Input: mat = [[1,1,3,2,4,3,2],[1,1,3,2,4,3,2],[1,1,3,2,4,3,2]], threshold = 4
+Output: 2
+Explanation: The maximum side length of square with sum less than 4 is 2 as shown.
+
+ +

Example 2:

+ +
+Input: mat = [[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2]], threshold = 1
+Output: 0
+
+ +

Example 3:

+ +
+Input: mat = [[1,1,1,1],[1,0,0,0],[1,0,0,0],[1,0,0,0]], threshold = 6
+Output: 3
+
+ +

Example 4:

+ +
+Input: mat = [[18,70],[61,1],[25,85],[14,40],[11,96],[97,96],[63,45]], threshold = 40184
+Output: 2
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= m, n <= 300
  • +
  • m == mat.length
  • +
  • n == mat[i].length
  • +
  • 0 <= mat[i][j] <= 10000
  • +
  • 0 <= threshold <= 10^5
  • +
+ +### Related Topics + [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + +### Hints +
+Hint 1 +Store prefix sum of all grids in another 2D array. +
+ +
+Hint 2 +Try all possible solutions and if you cannot find one return -1. +
+ +
+Hint 3 +If x is a valid answer then any y < x is also valid answer. Use binary search to find answer. +
diff --git a/problems/minimum-falling-path-sum-ii/README.md b/problems/minimum-falling-path-sum-ii/README.md new file mode 100644 index 000000000..7a123ac89 --- /dev/null +++ b/problems/minimum-falling-path-sum-ii/README.md @@ -0,0 +1,57 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-covered-intervals "Remove Covered Intervals") +                 +[Next >](https://github.com/openset/leetcode/tree/master/problems/convert-binary-number-in-a-linked-list-to-integer "Convert Binary Number in a Linked List to Integer") + +## [1289. Minimum Falling Path Sum II (Hard)](https://leetcode.com/problems/minimum-falling-path-sum-ii "下降路径最小和 II") + +

Given a square grid of integers arr, a falling path with non-zero shifts is a choice of exactly one element from each row of arr, such that no two elements chosen in adjacent rows are in the same column.

+ +

Return the minimum sum of a falling path with non-zero shifts.

+ +

 

+

Example 1:

+ +
+Input: arr = [[1,2,3],[4,5,6],[7,8,9]]
+Output: 13
+Explanation: 
+The possible falling paths are:
+[1,5,9], [1,5,7], [1,6,7], [1,6,8],
+[2,4,8], [2,4,9], [2,6,7], [2,6,8],
+[3,4,8], [3,4,9], [3,5,7], [3,5,9]
+The falling path with the smallest sum is [1,5,7], so the answer is 13.
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= arr.length == arr[i].length <= 200
  • +
  • -99 <= arr[i][j] <= 99
  • +
+ +### Related Topics + [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + +### Hints +
+Hint 1 +Use dynamic programming. +
+ +
+Hint 2 +Let dp[i][j] be the answer for the first i rows such that column j is chosen from row i. +
+ +
+Hint 3 +Use the concept of cumulative array to optimize the complexity of the solution. +
diff --git a/problems/remove-covered-intervals/README.md b/problems/remove-covered-intervals/README.md new file mode 100644 index 000000000..450bb30ee --- /dev/null +++ b/problems/remove-covered-intervals/README.md @@ -0,0 +1,48 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/element-appearing-more-than-25-in-sorted-array "Element Appearing More Than 25% In Sorted Array") +                 +[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-falling-path-sum-ii "Minimum Falling Path Sum II") + +## [1288. Remove Covered Intervals (Medium)](https://leetcode.com/problems/remove-covered-intervals "删除被覆盖区间") + +

Given a list of intervals, remove all intervals that are covered by another interval in the list. Interval [a,b) is covered by interval [c,d) if and only if c <= a and b <= d.

+ +

After doing so, return the number of remaining intervals.

+ +

 

+

Example 1:

+ +
+Input: intervals = [[1,4],[3,6],[2,8]]
+Output: 2
+Explanation: Interval [3,6] is covered by [2,8], therefore it is removed.
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= intervals.length <= 1000
  • +
  • 0 <= intervals[i][0] < intervals[i][1] <= 10^5
  • +
  • intervals[i] != intervals[j] for all i != j
  • +
+ +### Related Topics + [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] + +### Hints +
+Hint 1 +How to check if an interval is covered by another? +
+ +
+Hint 2 +Compare each interval to all others and check if it is covered by any interval. +
diff --git a/problems/sequential-digits/README.md b/problems/sequential-digits/README.md new file mode 100644 index 000000000..4f355d37a --- /dev/null +++ b/problems/sequential-digits/README.md @@ -0,0 +1,45 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/convert-binary-number-in-a-linked-list-to-integer "Convert Binary Number in a Linked List to Integer") +                 +[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold "Maximum Side Length of a Square with Sum Less than or Equal to Threshold") + +## [1291. Sequential Digits (Medium)](https://leetcode.com/problems/sequential-digits "顺次数") + +

An integer has sequential digits if and only if each digit in the number is one more than the previous digit.

+ +

Return a sorted list of all the integers in the range [low, high] inclusive that have sequential digits.

+ +

 

+

Example 1:

+
Input: low = 100, high = 300
+Output: [123,234]
+

Example 2:

+
Input: low = 1000, high = 13000
+Output: [1234,2345,3456,4567,5678,6789,12345]
+
+

 

+

Constraints:

+ +
    +
  • 10 <= low <= high <= 10^9
  • +
+ +### Related Topics + [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + +### Hints +
+Hint 1 +Generate all numbers with sequential digits and check if they are in the given range. +
+ +
+Hint 2 +Fix the starting digit then do a recursion that tries to append all valid digits. +
diff --git a/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md b/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md new file mode 100644 index 000000000..81daf94db --- /dev/null +++ b/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold "Maximum Side Length of a Square with Sum Less than or Equal to Threshold") +                 +Next > + +## [1293. Shortest Path in a Grid with Obstacles Elimination (Hard)](https://leetcode.com/problems/shortest-path-in-a-grid-with-obstacles-elimination "网格中的最短路径") + +

Given a m * n grid, where each cell is either 0 (empty) or 1 (obstacle). In one step, you can move up, down, left or right from and to an empty cell.

+ +

Return the minimum number of steps to walk from the upper left corner (0, 0) to the lower right corner (m-1, n-1) given that you can eliminate at most k obstacles. If it is not possible to find such walk return -1.

+ +

 

+

Example 1:

+ +
+Input: 
+grid = 
+[[0,0,0],
+ [1,1,0],
+ [0,0,0],
+ [0,1,1],
+ [0,0,0]], 
+k = 1
+Output: 6
+Explanation: 
+The shortest path without eliminating any obstacle is 10. 
+The shortest path with one obstacle elimination at position (3,2) is 6. Such path is (0,0) -> (0,1) -> (0,2) -> (1,2) -> (2,2) -> (3,2) -> (4,2).
+
+ +

 

+ +

Example 2:

+ +
+Input: 
+grid = 
+[[0,1,1],
+ [1,1,1],
+ [1,0,0]], 
+k = 1
+Output: -1
+Explanation: 
+We need to eliminate at least two obstacles to find such a walk.
+
+ +

 

+

Constraints:

+ +
    +
  • grid.length == m
  • +
  • grid[0].length == n
  • +
  • 1 <= m, n <= 40
  • +
  • 1 <= k <= m*n
  • +
  • grid[i][j] == 0 or 1
  • +
  • grid[0][0] == grid[m-1][n-1] == 0
  • +
+ +### Related Topics + [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + +### Hints +
+Hint 1 +Use BFS. +
+ +
+Hint 2 +BFS on (x,y,r) x,y is coordinate, r is remain number of obstacles you can remove. +
diff --git a/tag/README.md b/tag/README.md index 179c9d563..e45f223ef 100644 --- a/tag/README.md +++ b/tag/README.md @@ -13,8 +13,8 @@ | 3 | [Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md) | [数学](https://openset.github.io/tags/math/) | | 4 | [String](https://github.com/openset/leetcode/tree/master/tag/string/README.md) | [字符串](https://openset.github.io/tags/string/) | | 5 | [Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md) | [树](https://openset.github.io/tags/tree/) | | 6 | [Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | | 7 | [Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md) | [深度优先搜索](https://openset.github.io/tags/depth-first-search/) | | 8 | [Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | -| 9 | [Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 10 | [Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | -| 11 | [Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | | 12 | [Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md) | [栈](https://openset.github.io/tags/stack/) | +| 9 | [Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 10 | [Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | +| 11 | [Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 12 | [Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md) | [栈](https://openset.github.io/tags/stack/) | | 13 | [Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md) | [设计](https://openset.github.io/tags/design/) | | 15 | [Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 16 | [Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 17 | [Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | @@ -23,9 +23,9 @@ | 23 | [Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | | 25 | [Segment Tree](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | | 27 | [Queue](https://github.com/openset/leetcode/tree/master/tag/queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Minimax](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | -| 29 | [Binary Indexed Tree](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 30 | [Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md) | [Random](https://openset.github.io/tags/random/) | -| 31 | [Topological Sort](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | | 32 | [Brainteaser](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | -| 33 | [Geometry](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | | 34 | [Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | +| 29 | [Binary Indexed Tree](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 30 | [Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | +| 31 | [Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md) | [Random](https://openset.github.io/tags/random/) | | 32 | [Topological Sort](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | +| 33 | [Brainteaser](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 34 | [Geometry](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | | 35 | [Binary Search Tree](https://github.com/openset/leetcode/tree/master/tag/binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [Rejection Sampling](https://github.com/openset/leetcode/tree/master/tag/rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | | 37 | [Reservoir Sampling](https://github.com/openset/leetcode/tree/master/tag/reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | | 38 | [Memoization](https://github.com/openset/leetcode/tree/master/tag/memoization/README.md) | [记忆化](https://openset.github.io/tags/memoization/) | | 39 | [Rolling Hash](https://github.com/openset/leetcode/tree/master/tag/rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | | 40 | [Suffix Array](https://github.com/openset/leetcode/tree/master/tag/suffix-array/README.md) | [Suffix Array](https://openset.github.io/tags/suffix-array/) | diff --git a/tag/array/README.md b/tag/array/README.md index 4273629b6..353bfe55d 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,8 @@ | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | +| 1292 | [元素和小于等于阈值的正方形的最大边长](https://github.com/openset/leetcode/tree/master/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | +| 1287 | [有序数组中出现次数超过25%的元素](https://github.com/openset/leetcode/tree/master/problems/element-appearing-more-than-25-in-sorted-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | | 1277 | [统计全为 1 的正方形子矩阵](https://github.com/openset/leetcode/tree/master/problems/count-square-submatrices-with-all-ones) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | | 1275 | [找出井字棋的获胜者](https://github.com/openset/leetcode/tree/master/problems/find-winner-on-a-tic-tac-toe-game) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | | 1267 | [统计参与通信的服务器](https://github.com/openset/leetcode/tree/master/problems/count-servers-that-communicate) | [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 04ac4d493..762689aa3 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,8 @@ | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | +| 1291 | [顺次数](https://github.com/openset/leetcode/tree/master/problems/sequential-digits) | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | +| 1286 | [字母组合迭代器](https://github.com/openset/leetcode/tree/master/problems/iterator-for-combination) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | | 1258 | [近义词句子](https://github.com/openset/leetcode/tree/master/problems/synonymous-sentences) 🔒 | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | | 1240 | [铺瓷砖](https://github.com/openset/leetcode/tree/master/problems/tiling-a-rectangle-with-the-fewest-squares) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | | 1239 | [串联字符串的最大长度](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index eb96f996e..d3e79bc2e 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,7 @@ | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | +| 1292 | [元素和小于等于阈值的正方形的最大边长](https://github.com/openset/leetcode/tree/master/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | | 1283 | [使结果不超过阈值的最小除数](https://github.com/openset/leetcode/tree/master/problems/find-the-smallest-divisor-given-a-threshold) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | | 1237 | [找出给定方程的正整数解](https://github.com/openset/leetcode/tree/master/problems/find-positive-integer-solution-for-a-given-equation) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | | 1235 | [规划兼职工作](https://github.com/openset/leetcode/tree/master/problems/maximum-profit-in-job-scheduling) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index c6c3c849c..a410fb011 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | +| 1290 | [二进制链表转整数](https://github.com/openset/leetcode/tree/master/problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Easy | | 1256 | [加密数字](https://github.com/openset/leetcode/tree/master/problems/encode-number) 🔒 | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | | 1255 | [得分最高的单词集合](https://github.com/openset/leetcode/tree/master/problems/maximum-score-words-formed-by-letters) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Hard | | 1239 | [串联字符串的最大长度](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index dea2a6a0d..5e76fd0c6 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | +| 1293 | [网格中的最短路径](https://github.com/openset/leetcode/tree/master/problems/shortest-path-in-a-grid-with-obstacles-elimination) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | | 1284 | [转化为全零矩阵的最少反转次数](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | | 1263 | [推箱子](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-move-a-box-to-their-target-location) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | | 1245 | [树的直径](https://github.com/openset/leetcode/tree/master/problems/tree-diameter) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index 3f1e6c40e..314e592c2 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | +| 1286 | [字母组合迭代器](https://github.com/openset/leetcode/tree/master/problems/iterator-for-combination) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | | 1244 | [力扣排行榜](https://github.com/openset/leetcode/tree/master/problems/design-a-leaderboard) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | | 1206 | [设计跳表](https://github.com/openset/leetcode/tree/master/problems/design-skiplist) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Hard | | 1172 | [餐盘栈](https://github.com/openset/leetcode/tree/master/problems/dinner-plate-stacks) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Hard | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index dffff9f47..95bbda0e4 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | +| 1289 | [下降路径最小和 II](https://github.com/openset/leetcode/tree/master/problems/minimum-falling-path-sum-ii) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | | 1278 | [分割回文串 III](https://github.com/openset/leetcode/tree/master/problems/palindrome-partitioning-iii) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | | 1277 | [统计全为 1 的正方形子矩阵](https://github.com/openset/leetcode/tree/master/problems/count-square-submatrices-with-all-ones) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | | 1273 | [删除树节点](https://github.com/openset/leetcode/tree/master/problems/delete-tree-nodes) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md index 750a31aab..d7e128c21 100644 --- a/tag/line-sweep/README.md +++ b/tag/line-sweep/README.md @@ -9,6 +9,7 @@ | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | +| 1288 | [删除被覆盖区间](https://github.com/openset/leetcode/tree/master/problems/remove-covered-intervals) | [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] | Medium | | 1272 | [删除区间](https://github.com/openset/leetcode/tree/master/problems/remove-interval) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] | Medium | | 1229 | [安排会议日程](https://github.com/openset/leetcode/tree/master/problems/meeting-scheduler) 🔒 | [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] | Medium | | 850 | [矩形面积 II](https://github.com/openset/leetcode/tree/master/problems/rectangle-area-ii) | [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] | Hard | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index 25c0c4903..1549bc29b 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -9,6 +9,7 @@ | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | +| 1290 | [二进制链表转整数](https://github.com/openset/leetcode/tree/master/problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Easy | | 1171 | [从链表中删去总和值为零的连续节点](https://github.com/openset/leetcode/tree/master/problems/remove-zero-sum-consecutive-nodes-from-linked-list) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | | 1019 | [链表中的下一个更大节点](https://github.com/openset/leetcode/tree/master/problems/next-greater-node-in-linked-list) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | | 876 | [链表的中间结点](https://github.com/openset/leetcode/tree/master/problems/middle-of-the-linked-list) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Easy | diff --git a/tag/tags.json b/tag/tags.json index 3862d19ad..57ef282a7 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -44,16 +44,16 @@ "Slug": "greedy", "TranslatedName": "贪心算法" }, - { - "Name": "Two Pointers", - "Slug": "two-pointers", - "TranslatedName": "双指针" - }, { "Name": "Breadth-first Search", "Slug": "breadth-first-search", "TranslatedName": "广度优先搜索" }, + { + "Name": "Two Pointers", + "Slug": "two-pointers", + "TranslatedName": "双指针" + }, { "Name": "Stack", "Slug": "stack", @@ -144,6 +144,11 @@ "Slug": "binary-indexed-tree", "TranslatedName": "树状数组" }, + { + "Name": "Line Sweep", + "Slug": "line-sweep", + "TranslatedName": "Line Sweep" + }, { "Name": "Random", "Slug": "random", @@ -164,11 +169,6 @@ "Slug": "geometry", "TranslatedName": "几何" }, - { - "Name": "Line Sweep", - "Slug": "line-sweep", - "TranslatedName": "Line Sweep" - }, { "Name": "Binary Search Tree", "Slug": "binary-search-tree", From 4191d079b6436451888b9ae5c09281466cf50364 Mon Sep 17 00:00:00 2001 From: openset Date: Tue, 17 Dec 2019 11:42:09 +0800 Subject: [PATCH 011/145] Add: Range Addition II --- .../range-addition-ii/range_addition_ii.go | 12 ++++++++ .../range_addition_ii_test.go | 29 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/problems/range-addition-ii/range_addition_ii.go b/problems/range-addition-ii/range_addition_ii.go index bc0ce4d61..6e802a816 100644 --- a/problems/range-addition-ii/range_addition_ii.go +++ b/problems/range-addition-ii/range_addition_ii.go @@ -1 +1,13 @@ package problem598 + +func maxCount(m int, n int, ops [][]int) int { + for _, op := range ops { + if m > op[0] { + m = op[0] + } + if n > op[1] { + n = op[1] + } + } + return m * n +} diff --git a/problems/range-addition-ii/range_addition_ii_test.go b/problems/range-addition-ii/range_addition_ii_test.go index bc0ce4d61..aff2a2d6e 100644 --- a/problems/range-addition-ii/range_addition_ii_test.go +++ b/problems/range-addition-ii/range_addition_ii_test.go @@ -1 +1,30 @@ package problem598 + +import "testing" + +type testType struct { + m int + n int + ops [][]int + want int +} + +func TestMaxCount(t *testing.T) { + tests := [...]testType{ + { + m: 3, + n: 3, + ops: [][]int{ + {2, 2}, + {3, 3}, + }, + want: 4, + }, + } + for _, tt := range tests { + got := maxCount(tt.m, tt.n, tt.ops) + if got != tt.want { + t.Fatalf("in: %v, got: %v, want: %v", tt.m, got, tt.want) + } + } +} From 01433e8f5be247ab03aa52ff263864abc6ce5039 Mon Sep 17 00:00:00 2001 From: openset Date: Wed, 18 Dec 2019 10:16:04 +0800 Subject: [PATCH 012/145] Update: relative path --- README.md | 786 +++++++++++++++--------------- internal/leetcode/problems_all.go | 10 +- internal/readme/readme.go | 4 +- readme/1-300.md | 600 +++++++++++------------ readme/301-600.md | 600 +++++++++++------------ readme/601-900.md | 600 +++++++++++------------ 6 files changed, 1302 insertions(+), 1298 deletions(-) diff --git a/README.md b/README.md index 967fab798..fade28112 100644 --- a/README.md +++ b/README.md @@ -62,396 +62,396 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | -| 1293 | [Shortest Path in a Grid with Obstacles Elimination](https://leetcode.com/problems/shortest-path-in-a-grid-with-obstacles-elimination "网格中的最短路径") | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-path-in-a-grid-with-obstacles-elimination) | Hard | -| 1292 | [Maximum Side Length of a Square with Sum Less than or Equal to Threshold](https://leetcode.com/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold "元素和小于等于阈值的正方形的最大边长") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | Medium | -| 1291 | [Sequential Digits](https://leetcode.com/problems/sequential-digits "顺次数") | [Go](https://github.com/openset/leetcode/tree/master/problems/sequential-digits) | Medium | -| 1290 | [Convert Binary Number in a Linked List to Integer](https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer "二进制链表转整数") | [Go](https://github.com/openset/leetcode/tree/master/problems/convert-binary-number-in-a-linked-list-to-integer) | Easy | -| 1289 | [Minimum Falling Path Sum II](https://leetcode.com/problems/minimum-falling-path-sum-ii "下降路径最小和 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-falling-path-sum-ii) | Hard | -| 1288 | [Remove Covered Intervals](https://leetcode.com/problems/remove-covered-intervals "删除被覆盖区间") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-covered-intervals) | Medium | -| 1287 | [Element Appearing More Than 25% In Sorted Array](https://leetcode.com/problems/element-appearing-more-than-25-in-sorted-array "有序数组中出现次数超过25%的元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/element-appearing-more-than-25-in-sorted-array) | Easy | -| 1286 | [Iterator for Combination](https://leetcode.com/problems/iterator-for-combination "字母组合迭代器") | [Go](https://github.com/openset/leetcode/tree/master/problems/iterator-for-combination) | Medium | -| 1285 | [Find the Start and End Number of Continuous Ranges](https://leetcode.com/problems/find-the-start-and-end-number-of-continuous-ranges) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/find-the-start-and-end-number-of-continuous-ranges) | Medium | -| 1284 | [Minimum Number of Flips to Convert Binary Matrix to Zero Matrix](https://leetcode.com/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix "转化为全零矩阵的最少反转次数") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | Hard | -| 1283 | [Find the Smallest Divisor Given a Threshold](https://leetcode.com/problems/find-the-smallest-divisor-given-a-threshold "使结果不超过阈值的最小除数") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-the-smallest-divisor-given-a-threshold) | Medium | -| 1282 | [Group the People Given the Group Size They Belong To](https://leetcode.com/problems/group-the-people-given-the-group-size-they-belong-to "用户分组") | [Go](https://github.com/openset/leetcode/tree/master/problems/group-the-people-given-the-group-size-they-belong-to) | Medium | -| 1281 | [Subtract the Product and Sum of Digits of an Integer](https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer "整数的各位积和之差") | [Go](https://github.com/openset/leetcode/tree/master/problems/subtract-the-product-and-sum-of-digits-of-an-integer) | Easy | -| 1280 | [Students and Examinations](https://leetcode.com/problems/students-and-examinations) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/students-and-examinations) | Easy | -| 1279 | [Traffic Light Controlled Intersection](https://leetcode.com/problems/traffic-light-controlled-intersection) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/traffic-light-controlled-intersection) | Easy | -| 1278 | [Palindrome Partitioning III](https://leetcode.com/problems/palindrome-partitioning-iii "分割回文串 III") | [Go](https://github.com/openset/leetcode/tree/master/problems/palindrome-partitioning-iii) | Hard | -| 1277 | [Count Square Submatrices with All Ones](https://leetcode.com/problems/count-square-submatrices-with-all-ones "统计全为 1 的正方形子矩阵") | [Go](https://github.com/openset/leetcode/tree/master/problems/count-square-submatrices-with-all-ones) | Medium | -| 1276 | [Number of Burgers with No Waste of Ingredients](https://leetcode.com/problems/number-of-burgers-with-no-waste-of-ingredients "不浪费原料的汉堡制作方案") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-burgers-with-no-waste-of-ingredients) | Medium | -| 1275 | [Find Winner on a Tic Tac Toe Game](https://leetcode.com/problems/find-winner-on-a-tic-tac-toe-game "找出井字棋的获胜者") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-winner-on-a-tic-tac-toe-game) | Easy | -| 1274 | [Number of Ships in a Rectangle](https://leetcode.com/problems/number-of-ships-in-a-rectangle "矩形内船只的数目") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-ships-in-a-rectangle) | Hard | -| 1273 | [Delete Tree Nodes](https://leetcode.com/problems/delete-tree-nodes "删除树节点") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/delete-tree-nodes) | Medium | -| 1272 | [Remove Interval](https://leetcode.com/problems/remove-interval "删除区间") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-interval) | Medium | -| 1271 | [Hexspeak](https://leetcode.com/problems/hexspeak "十六进制魔术数字") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/hexspeak) | Easy | -| 1270 | [All People Report to the Given Manager](https://leetcode.com/problems/all-people-report-to-the-given-manager) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/all-people-report-to-the-given-manager) | Medium | -| 1269 | [Number of Ways to Stay in the Same Place After Some Steps](https://leetcode.com/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps "停在原地的方案数") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps) | Hard | -| 1268 | [Search Suggestions System](https://leetcode.com/problems/search-suggestions-system "搜索推荐系统") | [Go](https://github.com/openset/leetcode/tree/master/problems/search-suggestions-system) | Medium | -| 1267 | [Count Servers that Communicate](https://leetcode.com/problems/count-servers-that-communicate "统计参与通信的服务器") | [Go](https://github.com/openset/leetcode/tree/master/problems/count-servers-that-communicate) | Medium | -| 1266 | [Minimum Time Visiting All Points](https://leetcode.com/problems/minimum-time-visiting-all-points "访问所有点的最小时间") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-time-visiting-all-points) | Easy | -| 1265 | [Print Immutable Linked List in Reverse](https://leetcode.com/problems/print-immutable-linked-list-in-reverse) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/print-immutable-linked-list-in-reverse) | Medium | -| 1264 | [Page Recommendations](https://leetcode.com/problems/page-recommendations) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/page-recommendations) | Medium | -| 1263 | [Minimum Moves to Move a Box to Their Target Location](https://leetcode.com/problems/minimum-moves-to-move-a-box-to-their-target-location "推箱子") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-move-a-box-to-their-target-location) | Hard | -| 1262 | [Greatest Sum Divisible by Three](https://leetcode.com/problems/greatest-sum-divisible-by-three "可被三整除的最大和") | [Go](https://github.com/openset/leetcode/tree/master/problems/greatest-sum-divisible-by-three) | Medium | -| 1261 | [Find Elements in a Contaminated Binary Tree](https://leetcode.com/problems/find-elements-in-a-contaminated-binary-tree "在受污染的二叉树中查找元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-elements-in-a-contaminated-binary-tree) | Medium | -| 1260 | [Shift 2D Grid](https://leetcode.com/problems/shift-2d-grid "二维网格迁移") | [Go](https://github.com/openset/leetcode/tree/master/problems/shift-2d-grid) | Easy | -| 1259 | [Handshakes That Don't Cross](https://leetcode.com/problems/handshakes-that-dont-cross "不相交的握手") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/handshakes-that-dont-cross) | Hard | -| 1258 | [Synonymous Sentences](https://leetcode.com/problems/synonymous-sentences "近义词句子") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/synonymous-sentences) | Medium | -| 1257 | [Smallest Common Region](https://leetcode.com/problems/smallest-common-region "最小公共区域") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-common-region) | Medium | -| 1256 | [Encode Number](https://leetcode.com/problems/encode-number "加密数字") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/encode-number) | Medium | -| 1255 | [Maximum Score Words Formed by Letters](https://leetcode.com/problems/maximum-score-words-formed-by-letters "得分最高的单词集合") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-score-words-formed-by-letters) | Hard | -| 1254 | [Number of Closed Islands](https://leetcode.com/problems/number-of-closed-islands "统计封闭岛屿的数目") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-closed-islands) | Medium | -| 1253 | [Reconstruct a 2-Row Binary Matrix](https://leetcode.com/problems/reconstruct-a-2-row-binary-matrix "重构 2 行二进制矩阵") | [Go](https://github.com/openset/leetcode/tree/master/problems/reconstruct-a-2-row-binary-matrix) | Medium | -| 1252 | [Cells with Odd Values in a Matrix](https://leetcode.com/problems/cells-with-odd-values-in-a-matrix "奇数值单元格的数目") | [Go](https://github.com/openset/leetcode/tree/master/problems/cells-with-odd-values-in-a-matrix) | Easy | -| 1251 | [Average Selling Price](https://leetcode.com/problems/average-selling-price) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/average-selling-price) | Easy | -| 1250 | [Check If It Is a Good Array](https://leetcode.com/problems/check-if-it-is-a-good-array "检查「好数组」") | [Go](https://github.com/openset/leetcode/tree/master/problems/check-if-it-is-a-good-array) | Hard | -| 1249 | [Minimum Remove to Make Valid Parentheses](https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses "移除无效的括号") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-remove-to-make-valid-parentheses) | Medium | -| 1248 | [Count Number of Nice Subarrays](https://leetcode.com/problems/count-number-of-nice-subarrays "统计「优美子数组」") | [Go](https://github.com/openset/leetcode/tree/master/problems/count-number-of-nice-subarrays) | Medium | -| 1247 | [Minimum Swaps to Make Strings Equal](https://leetcode.com/problems/minimum-swaps-to-make-strings-equal "交换字符使得字符串相同") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-swaps-to-make-strings-equal) | Medium | -| 1246 | [Palindrome Removal](https://leetcode.com/problems/palindrome-removal "删除回文子数组") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/palindrome-removal) | Hard | -| 1245 | [Tree Diameter](https://leetcode.com/problems/tree-diameter "树的直径") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/tree-diameter) | Medium | -| 1244 | [Design A Leaderboard](https://leetcode.com/problems/design-a-leaderboard "力扣排行榜") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-a-leaderboard) | Medium | -| 1243 | [Array Transformation](https://leetcode.com/problems/array-transformation "数组变换") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/array-transformation) | Easy | -| 1242 | [Web Crawler Multithreaded](https://leetcode.com/problems/web-crawler-multithreaded "多线程网页爬虫") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/web-crawler-multithreaded) | Medium | -| 1241 | [Number of Comments per Post](https://leetcode.com/problems/number-of-comments-per-post "每个帖子的评论数") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/number-of-comments-per-post) | Easy | -| 1240 | [Tiling a Rectangle with the Fewest Squares](https://leetcode.com/problems/tiling-a-rectangle-with-the-fewest-squares "铺瓷砖") | [Go](https://github.com/openset/leetcode/tree/master/problems/tiling-a-rectangle-with-the-fewest-squares) | Hard | -| 1239 | [Maximum Length of a Concatenated String with Unique Characters](https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters "串联字符串的最大长度") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-a-concatenated-string-with-unique-characters) | Medium | -| 1238 | [Circular Permutation in Binary Representation](https://leetcode.com/problems/circular-permutation-in-binary-representation "循环码排列") | [Go](https://github.com/openset/leetcode/tree/master/problems/circular-permutation-in-binary-representation) | Medium | -| 1237 | [Find Positive Integer Solution for a Given Equation](https://leetcode.com/problems/find-positive-integer-solution-for-a-given-equation "找出给定方程的正整数解") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-positive-integer-solution-for-a-given-equation) | Easy | -| 1236 | [Web Crawler](https://leetcode.com/problems/web-crawler) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/web-crawler) | Medium | -| 1235 | [Maximum Profit in Job Scheduling](https://leetcode.com/problems/maximum-profit-in-job-scheduling "规划兼职工作") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-profit-in-job-scheduling) | Hard | -| 1234 | [Replace the Substring for Balanced String](https://leetcode.com/problems/replace-the-substring-for-balanced-string "替换子串得到平衡字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/replace-the-substring-for-balanced-string) | Medium | -| 1233 | [Remove Sub-Folders from the Filesystem](https://leetcode.com/problems/remove-sub-folders-from-the-filesystem "删除子文件夹") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-sub-folders-from-the-filesystem) | Medium | -| 1232 | [Check If It Is a Straight Line](https://leetcode.com/problems/check-if-it-is-a-straight-line "缀点成线") | [Go](https://github.com/openset/leetcode/tree/master/problems/check-if-it-is-a-straight-line) | Easy | -| 1231 | [Divide Chocolate](https://leetcode.com/problems/divide-chocolate "分享巧克力") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/divide-chocolate) | Hard | -| 1230 | [Toss Strange Coins](https://leetcode.com/problems/toss-strange-coins "抛掷硬币") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/toss-strange-coins) | Medium | -| 1229 | [Meeting Scheduler](https://leetcode.com/problems/meeting-scheduler "安排会议日程") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/meeting-scheduler) | Medium | -| 1228 | [Missing Number In Arithmetic Progression](https://leetcode.com/problems/missing-number-in-arithmetic-progression "等差数列中缺失的数字") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/missing-number-in-arithmetic-progression) | Easy | -| 1227 | [Airplane Seat Assignment Probability](https://leetcode.com/problems/airplane-seat-assignment-probability "飞机座位分配概率") | [Go](https://github.com/openset/leetcode/tree/master/problems/airplane-seat-assignment-probability) | Medium | -| 1226 | [The Dining Philosophers](https://leetcode.com/problems/the-dining-philosophers "哲学家进餐") | [Go](https://github.com/openset/leetcode/tree/master/problems/the-dining-philosophers) | Medium | -| 1225 | [Report Contiguous Dates](https://leetcode.com/problems/report-contiguous-dates "报告系统状态的连续日期") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/report-contiguous-dates) | Hard | -| 1224 | [Maximum Equal Frequency](https://leetcode.com/problems/maximum-equal-frequency "最大相等频率") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-equal-frequency) | Hard | -| 1223 | [Dice Roll Simulation](https://leetcode.com/problems/dice-roll-simulation "掷骰子模拟") | [Go](https://github.com/openset/leetcode/tree/master/problems/dice-roll-simulation) | Medium | -| 1222 | [Queens That Can Attack the King](https://leetcode.com/problems/queens-that-can-attack-the-king "可以攻击国王的皇后") | [Go](https://github.com/openset/leetcode/tree/master/problems/queens-that-can-attack-the-king) | Medium | -| 1221 | [Split a String in Balanced Strings](https://leetcode.com/problems/split-a-string-in-balanced-strings "分割平衡字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/split-a-string-in-balanced-strings) | Easy | -| 1220 | [Count Vowels Permutation](https://leetcode.com/problems/count-vowels-permutation "统计元音字母序列的数目") | [Go](https://github.com/openset/leetcode/tree/master/problems/count-vowels-permutation) | Hard | -| 1219 | [Path with Maximum Gold](https://leetcode.com/problems/path-with-maximum-gold "黄金矿工") | [Go](https://github.com/openset/leetcode/tree/master/problems/path-with-maximum-gold) | Medium | -| 1218 | [Longest Arithmetic Subsequence of Given Difference](https://leetcode.com/problems/longest-arithmetic-subsequence-of-given-difference "最长定差子序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-arithmetic-subsequence-of-given-difference) | Medium | -| 1217 | [Play with Chips](https://leetcode.com/problems/play-with-chips "玩筹码") | [Go](https://github.com/openset/leetcode/tree/master/problems/play-with-chips) | Easy | -| 1216 | [Valid Palindrome III](https://leetcode.com/problems/valid-palindrome-iii "验证回文字符串 III") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome-iii) | Hard | -| 1215 | [Stepping Numbers](https://leetcode.com/problems/stepping-numbers "步进数") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/stepping-numbers) | Medium | -| 1214 | [Two Sum BSTs](https://leetcode.com/problems/two-sum-bsts "查找两棵二叉搜索树之和") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/two-sum-bsts) | Medium | -| 1213 | [Intersection of Three Sorted Arrays](https://leetcode.com/problems/intersection-of-three-sorted-arrays "三个有序数组的交集") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/intersection-of-three-sorted-arrays) | Easy | -| 1212 | [Team Scores in Football Tournament](https://leetcode.com/problems/team-scores-in-football-tournament) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/team-scores-in-football-tournament) | Medium | -| 1211 | [Queries Quality and Percentage](https://leetcode.com/problems/queries-quality-and-percentage) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/queries-quality-and-percentage) | Easy | -| 1210 | [Minimum Moves to Reach Target with Rotations](https://leetcode.com/problems/minimum-moves-to-reach-target-with-rotations "穿过迷宫的最少移动次数") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-reach-target-with-rotations) | Hard | -| 1209 | [Remove All Adjacent Duplicates in String II](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii "删除字符串中的所有相邻重复项 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-all-adjacent-duplicates-in-string-ii) | Medium | -| 1208 | [Get Equal Substrings Within Budget](https://leetcode.com/problems/get-equal-substrings-within-budget "尽可能使字符串相等") | [Go](https://github.com/openset/leetcode/tree/master/problems/get-equal-substrings-within-budget) | Medium | -| 1207 | [Unique Number of Occurrences](https://leetcode.com/problems/unique-number-of-occurrences "独一无二的出现次数") | [Go](https://github.com/openset/leetcode/tree/master/problems/unique-number-of-occurrences) | Easy | -| 1206 | [Design Skiplist](https://leetcode.com/problems/design-skiplist "设计跳表") | [Go](https://github.com/openset/leetcode/tree/master/problems/design-skiplist) | Hard | -| 1205 | [Monthly Transactions II](https://leetcode.com/problems/monthly-transactions-ii "每月交易II") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/monthly-transactions-ii) | Medium | -| 1204 | [Last Person to Fit in the Elevator](https://leetcode.com/problems/last-person-to-fit-in-the-elevator) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/last-person-to-fit-in-the-elevator) | Medium | -| 1203 | [Sort Items by Groups Respecting Dependencies](https://leetcode.com/problems/sort-items-by-groups-respecting-dependencies "项目管理") | [Go](https://github.com/openset/leetcode/tree/master/problems/sort-items-by-groups-respecting-dependencies) | Hard | -| 1202 | [Smallest String With Swaps](https://leetcode.com/problems/smallest-string-with-swaps "交换字符串中的元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-string-with-swaps) | Medium | -| 1201 | [Ugly Number III](https://leetcode.com/problems/ugly-number-iii "丑数 III") | [Go](https://github.com/openset/leetcode/tree/master/problems/ugly-number-iii) | Medium | -| 1200 | [Minimum Absolute Difference](https://leetcode.com/problems/minimum-absolute-difference "最小绝对差") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-absolute-difference) | Easy | -| 1199 | [Minimum Time to Build Blocks](https://leetcode.com/problems/minimum-time-to-build-blocks "建造街区的最短时间") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-time-to-build-blocks) | Hard | -| 1198 | [Find Smallest Common Element in All Rows](https://leetcode.com/problems/find-smallest-common-element-in-all-rows "找出所有行中最小公共元素") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/find-smallest-common-element-in-all-rows) | Medium | -| 1197 | [Minimum Knight Moves](https://leetcode.com/problems/minimum-knight-moves "进击的骑士") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-knight-moves) | Medium | -| 1196 | [How Many Apples Can You Put into the Basket](https://leetcode.com/problems/how-many-apples-can-you-put-into-the-basket "最多可以买到的苹果数量") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/how-many-apples-can-you-put-into-the-basket) | Easy | -| 1195 | [Fizz Buzz Multithreaded](https://leetcode.com/problems/fizz-buzz-multithreaded "交替打印字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/fizz-buzz-multithreaded) | Medium | -| 1194 | [Tournament Winners](https://leetcode.com/problems/tournament-winners "锦标赛优胜者") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/tournament-winners) | Hard | -| 1193 | [Monthly Transactions I](https://leetcode.com/problems/monthly-transactions-i "每月交易 I") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/monthly-transactions-i) | Medium | -| 1192 | [Critical Connections in a Network](https://leetcode.com/problems/critical-connections-in-a-network "查找集群内的「关键连接」") | [Go](https://github.com/openset/leetcode/tree/master/problems/critical-connections-in-a-network) | Hard | -| 1191 | [K-Concatenation Maximum Sum](https://leetcode.com/problems/k-concatenation-maximum-sum "K 次串联后最大子数组之和") | [Go](https://github.com/openset/leetcode/tree/master/problems/k-concatenation-maximum-sum) | Medium | -| 1190 | [Reverse Substrings Between Each Pair of Parentheses](https://leetcode.com/problems/reverse-substrings-between-each-pair-of-parentheses "反转每对括号间的子串") | [Go](https://github.com/openset/leetcode/tree/master/problems/reverse-substrings-between-each-pair-of-parentheses) | Medium | -| 1189 | [Maximum Number of Balloons](https://leetcode.com/problems/maximum-number-of-balloons "“气球” 的最大数量") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-number-of-balloons) | Easy | -| 1188 | [Design Bounded Blocking Queue](https://leetcode.com/problems/design-bounded-blocking-queue "设计有限阻塞队列") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-bounded-blocking-queue) | Medium | -| 1187 | [Make Array Strictly Increasing](https://leetcode.com/problems/make-array-strictly-increasing "使数组严格递增") | [Go](https://github.com/openset/leetcode/tree/master/problems/make-array-strictly-increasing) | Hard | -| 1186 | [Maximum Subarray Sum with One Deletion](https://leetcode.com/problems/maximum-subarray-sum-with-one-deletion "删除一次得到子数组最大和") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-subarray-sum-with-one-deletion) | Medium | -| 1185 | [Day of the Week](https://leetcode.com/problems/day-of-the-week "一周中的第几天") | [Go](https://github.com/openset/leetcode/tree/master/problems/day-of-the-week) | Easy | -| 1184 | [Distance Between Bus Stops](https://leetcode.com/problems/distance-between-bus-stops "公交站间的距离") | [Go](https://github.com/openset/leetcode/tree/master/problems/distance-between-bus-stops) | Easy | -| 1183 | [Maximum Number of Ones](https://leetcode.com/problems/maximum-number-of-ones "矩阵中 1 的最大数量") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-number-of-ones) | Hard | -| 1182 | [Shortest Distance to Target Color](https://leetcode.com/problems/shortest-distance-to-target-color "与目标颜色间的最短距离") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-to-target-color) | Medium | -| 1181 | [Before and After Puzzle](https://leetcode.com/problems/before-and-after-puzzle "前后拼接") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/before-and-after-puzzle) | Medium | -| 1180 | [Count Substrings with Only One Distinct Letter](https://leetcode.com/problems/count-substrings-with-only-one-distinct-letter "统计只含单一字母的子串") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/count-substrings-with-only-one-distinct-letter) | Easy | -| 1179 | [Reformat Department Table](https://leetcode.com/problems/reformat-department-table "重新格式化部门表") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/reformat-department-table) | Easy | -| 1178 | [Number of Valid Words for Each Puzzle](https://leetcode.com/problems/number-of-valid-words-for-each-puzzle "猜字谜") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-valid-words-for-each-puzzle) | Hard | -| 1177 | [Can Make Palindrome from Substring](https://leetcode.com/problems/can-make-palindrome-from-substring "构建回文串检测") | [Go](https://github.com/openset/leetcode/tree/master/problems/can-make-palindrome-from-substring) | Medium | -| 1176 | [Diet Plan Performance](https://leetcode.com/problems/diet-plan-performance "健身计划评估") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/diet-plan-performance) | Easy | -| 1175 | [Prime Arrangements](https://leetcode.com/problems/prime-arrangements "质数排列") | [Go](https://github.com/openset/leetcode/tree/master/problems/prime-arrangements) | Easy | -| 1174 | [Immediate Food Delivery II](https://leetcode.com/problems/immediate-food-delivery-ii) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/immediate-food-delivery-ii) | Medium | -| 1173 | [Immediate Food Delivery I](https://leetcode.com/problems/immediate-food-delivery-i) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/immediate-food-delivery-i) | Easy | -| 1172 | [Dinner Plate Stacks](https://leetcode.com/problems/dinner-plate-stacks "餐盘栈") | [Go](https://github.com/openset/leetcode/tree/master/problems/dinner-plate-stacks) | Hard | -| 1171 | [Remove Zero Sum Consecutive Nodes from Linked List](https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list "从链表中删去总和值为零的连续节点") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-zero-sum-consecutive-nodes-from-linked-list) | Medium | -| 1170 | [Compare Strings by Frequency of the Smallest Character](https://leetcode.com/problems/compare-strings-by-frequency-of-the-smallest-character "比较字符串最小字母出现频次") | [Go](https://github.com/openset/leetcode/tree/master/problems/compare-strings-by-frequency-of-the-smallest-character) | Easy | -| 1169 | [Invalid Transactions](https://leetcode.com/problems/invalid-transactions "查询无效交易") | [Go](https://github.com/openset/leetcode/tree/master/problems/invalid-transactions) | Medium | -| 1168 | [Optimize Water Distribution in a Village](https://leetcode.com/problems/optimize-water-distribution-in-a-village "水资源分配优化") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/optimize-water-distribution-in-a-village) | Hard | -| 1167 | [Minimum Cost to Connect Sticks](https://leetcode.com/problems/minimum-cost-to-connect-sticks "连接棒材的最低费用") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-to-connect-sticks) | Medium | -| 1166 | [Design File System](https://leetcode.com/problems/design-file-system "设计文件系统") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-file-system) | Medium | -| 1165 | [Single-Row Keyboard](https://leetcode.com/problems/single-row-keyboard "单行键盘") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/single-row-keyboard) | Easy | -| 1164 | [Product Price at a Given Date](https://leetcode.com/problems/product-price-at-a-given-date) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/product-price-at-a-given-date) | Medium | -| 1163 | [Last Substring in Lexicographical Order](https://leetcode.com/problems/last-substring-in-lexicographical-order "按字典序排在最后的子串") | [Go](https://github.com/openset/leetcode/tree/master/problems/last-substring-in-lexicographical-order) | Hard | -| 1162 | [As Far from Land as Possible](https://leetcode.com/problems/as-far-from-land-as-possible "地图分析") | [Go](https://github.com/openset/leetcode/tree/master/problems/as-far-from-land-as-possible) | Medium | -| 1161 | [Maximum Level Sum of a Binary Tree](https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree "最大层内元素和") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-level-sum-of-a-binary-tree) | Medium | -| 1160 | [Find Words That Can Be Formed by Characters](https://leetcode.com/problems/find-words-that-can-be-formed-by-characters "拼写单词") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-words-that-can-be-formed-by-characters) | Easy | -| 1159 | [Market Analysis II](https://leetcode.com/problems/market-analysis-ii) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/market-analysis-ii) | Hard | -| 1158 | [Market Analysis I](https://leetcode.com/problems/market-analysis-i) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/market-analysis-i) | Medium | -| 1157 | [Online Majority Element In Subarray](https://leetcode.com/problems/online-majority-element-in-subarray "子数组中占绝大多数的元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/online-majority-element-in-subarray) | Hard | -| 1156 | [Swap For Longest Repeated Character Substring](https://leetcode.com/problems/swap-for-longest-repeated-character-substring "单字符重复子串的最大长度") | [Go](https://github.com/openset/leetcode/tree/master/problems/swap-for-longest-repeated-character-substring) | Medium | -| 1155 | [Number of Dice Rolls With Target Sum](https://leetcode.com/problems/number-of-dice-rolls-with-target-sum "掷骰子的N种方法") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-dice-rolls-with-target-sum) | Medium | -| 1154 | [Day of the Year](https://leetcode.com/problems/day-of-the-year "一年中的第几天") | [Go](https://github.com/openset/leetcode/tree/master/problems/day-of-the-year) | Easy | -| 1153 | [String Transforms Into Another String](https://leetcode.com/problems/string-transforms-into-another-string "字符串转化") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/string-transforms-into-another-string) | Hard | -| 1152 | [Analyze User Website Visit Pattern](https://leetcode.com/problems/analyze-user-website-visit-pattern "用户网站访问行为分析") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/analyze-user-website-visit-pattern) | Medium | -| 1151 | [Minimum Swaps to Group All 1's Together](https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together "最少交换次数来组合所有的 1") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-swaps-to-group-all-1s-together) | Medium | -| 1150 | [Check If a Number Is Majority Element in a Sorted Array](https://leetcode.com/problems/check-if-a-number-is-majority-element-in-a-sorted-array "检查一个数是否在数组中占绝大多数") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/check-if-a-number-is-majority-element-in-a-sorted-array) | Easy | -| 1149 | [Article Views II](https://leetcode.com/problems/article-views-ii) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/article-views-ii) | Medium | -| 1148 | [Article Views I](https://leetcode.com/problems/article-views-i "文章浏览 I") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/article-views-i) | Easy | -| 1147 | [Longest Chunked Palindrome Decomposition](https://leetcode.com/problems/longest-chunked-palindrome-decomposition "段式回文") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-chunked-palindrome-decomposition) | Hard | -| 1146 | [Snapshot Array](https://leetcode.com/problems/snapshot-array "快照数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/snapshot-array) | Medium | -| 1145 | [Binary Tree Coloring Game](https://leetcode.com/problems/binary-tree-coloring-game "二叉树着色游戏") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-coloring-game) | Medium | -| 1144 | [Decrease Elements To Make Array Zigzag](https://leetcode.com/problems/decrease-elements-to-make-array-zigzag "递减元素使数组呈锯齿状") | [Go](https://github.com/openset/leetcode/tree/master/problems/decrease-elements-to-make-array-zigzag) | Medium | -| 1143 | [Longest Common Subsequence](https://leetcode.com/problems/longest-common-subsequence "最长公共子序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-common-subsequence) | Medium | -| 1142 | [User Activity for the Past 30 Days II](https://leetcode.com/problems/user-activity-for-the-past-30-days-ii "过去30天的用户活动 II") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/user-activity-for-the-past-30-days-ii) | Easy | -| 1141 | [User Activity for the Past 30 Days I](https://leetcode.com/problems/user-activity-for-the-past-30-days-i) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/user-activity-for-the-past-30-days-i) | Easy | -| 1140 | [Stone Game II](https://leetcode.com/problems/stone-game-ii "石子游戏 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/stone-game-ii) | Medium | -| 1139 | [Largest 1-Bordered Square](https://leetcode.com/problems/largest-1-bordered-square "最大的以 1 为边界的正方形") | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-1-bordered-square) | Medium | -| 1138 | [Alphabet Board Path](https://leetcode.com/problems/alphabet-board-path "字母板上的路径") | [Go](https://github.com/openset/leetcode/tree/master/problems/alphabet-board-path) | Medium | -| 1137 | [N-th Tribonacci Number](https://leetcode.com/problems/n-th-tribonacci-number "第 N 个泰波那契数") | [Go](https://github.com/openset/leetcode/tree/master/problems/n-th-tribonacci-number) | Easy | -| 1136 | [Parallel Courses](https://leetcode.com/problems/parallel-courses "平行课程") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/parallel-courses) | Hard | -| 1135 | [Connecting Cities With Minimum Cost](https://leetcode.com/problems/connecting-cities-with-minimum-cost "最低成本联通所有城市") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/connecting-cities-with-minimum-cost) | Medium | -| 1134 | [Armstrong Number](https://leetcode.com/problems/armstrong-number "阿姆斯特朗数") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/armstrong-number) | Easy | -| 1133 | [Largest Unique Number](https://leetcode.com/problems/largest-unique-number "最大唯一数") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-unique-number) | Easy | -| 1132 | [Reported Posts II](https://leetcode.com/problems/reported-posts-ii) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/reported-posts-ii) | Medium | -| 1131 | [Maximum of Absolute Value Expression](https://leetcode.com/problems/maximum-of-absolute-value-expression "绝对值表达式的最大值") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-of-absolute-value-expression) | Medium | -| 1130 | [Minimum Cost Tree From Leaf Values](https://leetcode.com/problems/minimum-cost-tree-from-leaf-values "叶值的最小代价生成树") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-tree-from-leaf-values) | Medium | -| 1129 | [Shortest Path with Alternating Colors](https://leetcode.com/problems/shortest-path-with-alternating-colors "颜色交替的最短路径") | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-path-with-alternating-colors) | Medium | -| 1128 | [Number of Equivalent Domino Pairs](https://leetcode.com/problems/number-of-equivalent-domino-pairs "等价多米诺骨牌对的数量") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-equivalent-domino-pairs) | Easy | -| 1127 | [User Purchase Platform](https://leetcode.com/problems/user-purchase-platform) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/user-purchase-platform) | Hard | -| 1126 | [Active Businesses](https://leetcode.com/problems/active-businesses) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/active-businesses) | Medium | -| 1125 | [Smallest Sufficient Team](https://leetcode.com/problems/smallest-sufficient-team "最小的必要团队") | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-sufficient-team) | Hard | -| 1124 | [Longest Well-Performing Interval](https://leetcode.com/problems/longest-well-performing-interval "表现良好的最长时间段") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-well-performing-interval) | Medium | -| 1123 | [Lowest Common Ancestor of Deepest Leaves](https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves "最深叶节点的最近公共祖先") | [Go](https://github.com/openset/leetcode/tree/master/problems/lowest-common-ancestor-of-deepest-leaves) | Medium | -| 1122 | [Relative Sort Array](https://leetcode.com/problems/relative-sort-array "数组的相对排序") | [Go](https://github.com/openset/leetcode/tree/master/problems/relative-sort-array) | Easy | -| 1121 | [Divide Array Into Increasing Sequences](https://leetcode.com/problems/divide-array-into-increasing-sequences "将数组分成几个递增序列") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/divide-array-into-increasing-sequences) | Hard | -| 1120 | [Maximum Average Subtree](https://leetcode.com/problems/maximum-average-subtree "子树的最大平均值") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-average-subtree) | Medium | -| 1119 | [Remove Vowels from a String](https://leetcode.com/problems/remove-vowels-from-a-string "删去字符串中的元音") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-vowels-from-a-string) | Easy | -| 1118 | [Number of Days in a Month](https://leetcode.com/problems/number-of-days-in-a-month "一月有多少天") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-days-in-a-month) | Easy | -| 1117 | [Building H2O](https://leetcode.com/problems/building-h2o "H2O 生成") | [Go](https://github.com/openset/leetcode/tree/master/problems/building-h2o) | Medium | -| 1116 | [Print Zero Even Odd](https://leetcode.com/problems/print-zero-even-odd "打印零与奇偶数") | [Go](https://github.com/openset/leetcode/tree/master/problems/print-zero-even-odd) | Medium | -| 1115 | [Print FooBar Alternately](https://leetcode.com/problems/print-foobar-alternately "交替打印FooBar") | [Go](https://github.com/openset/leetcode/tree/master/problems/print-foobar-alternately) | Medium | -| 1114 | [Print in Order](https://leetcode.com/problems/print-in-order "按序打印") | [Go](https://github.com/openset/leetcode/tree/master/problems/print-in-order) | Easy | -| 1113 | [Reported Posts](https://leetcode.com/problems/reported-posts) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/reported-posts) | Easy | -| 1112 | [Highest Grade For Each Student](https://leetcode.com/problems/highest-grade-for-each-student "每位学生的最高成绩") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/highest-grade-for-each-student) | Medium | -| 1111 | [Maximum Nesting Depth of Two Valid Parentheses Strings](https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings "有效括号的嵌套深度") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | Medium | -| 1110 | [Delete Nodes And Return Forest](https://leetcode.com/problems/delete-nodes-and-return-forest "删点成林") | [Go](https://github.com/openset/leetcode/tree/master/problems/delete-nodes-and-return-forest) | Medium | -| 1109 | [Corporate Flight Bookings](https://leetcode.com/problems/corporate-flight-bookings "航班预订统计") | [Go](https://github.com/openset/leetcode/tree/master/problems/corporate-flight-bookings) | Medium | -| 1108 | [Defanging an IP Address](https://leetcode.com/problems/defanging-an-ip-address "IP 地址无效化") | [Go](https://github.com/openset/leetcode/tree/master/problems/defanging-an-ip-address) | Easy | -| 1107 | [New Users Daily Count](https://leetcode.com/problems/new-users-daily-count "每日新用户统计") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/new-users-daily-count) | Medium | -| 1106 | [Parsing A Boolean Expression](https://leetcode.com/problems/parsing-a-boolean-expression "解析布尔表达式") | [Go](https://github.com/openset/leetcode/tree/master/problems/parsing-a-boolean-expression) | Hard | -| 1105 | [Filling Bookcase Shelves](https://leetcode.com/problems/filling-bookcase-shelves "填充书架") | [Go](https://github.com/openset/leetcode/tree/master/problems/filling-bookcase-shelves) | Medium | -| 1104 | [Path In Zigzag Labelled Binary Tree](https://leetcode.com/problems/path-in-zigzag-labelled-binary-tree "二叉树寻路") | [Go](https://github.com/openset/leetcode/tree/master/problems/path-in-zigzag-labelled-binary-tree) | Medium | -| 1103 | [Distribute Candies to People](https://leetcode.com/problems/distribute-candies-to-people "分糖果 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/distribute-candies-to-people) | Easy | -| 1102 | [Path With Maximum Minimum Value](https://leetcode.com/problems/path-with-maximum-minimum-value "得分最高的路径") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/path-with-maximum-minimum-value) | Medium | -| 1101 | [The Earliest Moment When Everyone Become Friends](https://leetcode.com/problems/the-earliest-moment-when-everyone-become-friends "彼此熟识的最早时间") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/the-earliest-moment-when-everyone-become-friends) | Medium | -| 1100 | [Find K-Length Substrings With No Repeated Characters](https://leetcode.com/problems/find-k-length-substrings-with-no-repeated-characters "长度为 K 的无重复字符子串") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/find-k-length-substrings-with-no-repeated-characters) | Medium | -| 1099 | [Two Sum Less Than K](https://leetcode.com/problems/two-sum-less-than-k "小于 K 的两数之和") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/two-sum-less-than-k) | Easy | -| 1098 | [Unpopular Books](https://leetcode.com/problems/unpopular-books "小众书籍") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/unpopular-books) | Medium | -| 1097 | [Game Play Analysis V](https://leetcode.com/problems/game-play-analysis-v "游戏玩法分析 V") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-v) | Hard | -| 1096 | [Brace Expansion II](https://leetcode.com/problems/brace-expansion-ii "花括号展开 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/brace-expansion-ii) | Hard | -| 1095 | [Find in Mountain Array](https://leetcode.com/problems/find-in-mountain-array "山脉数组中查找目标值") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-in-mountain-array) | Hard | -| 1094 | [Car Pooling](https://leetcode.com/problems/car-pooling "拼车") | [Go](https://github.com/openset/leetcode/tree/master/problems/car-pooling) | Medium | -| 1093 | [Statistics from a Large Sample](https://leetcode.com/problems/statistics-from-a-large-sample "大样本统计") | [Go](https://github.com/openset/leetcode/tree/master/problems/statistics-from-a-large-sample) | Medium | -| 1092 | [Shortest Common Supersequence](https://leetcode.com/problems/shortest-common-supersequence "最短公共超序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-common-supersequence) | Hard | -| 1091 | [Shortest Path in Binary Matrix](https://leetcode.com/problems/shortest-path-in-binary-matrix "二进制矩阵中的最短路径") | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-path-in-binary-matrix) | Medium | -| 1090 | [Largest Values From Labels](https://leetcode.com/problems/largest-values-from-labels "受标签影响的最大值") | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-values-from-labels) | Medium | -| 1089 | [Duplicate Zeros](https://leetcode.com/problems/duplicate-zeros "复写零") | [Go](https://github.com/openset/leetcode/tree/master/problems/duplicate-zeros) | Easy | -| 1088 | [Confusing Number II](https://leetcode.com/problems/confusing-number-ii "易混淆数 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/confusing-number-ii) | Hard | -| 1087 | [Brace Expansion](https://leetcode.com/problems/brace-expansion "字母切换") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/brace-expansion) | Medium | -| 1086 | [High Five](https://leetcode.com/problems/high-five "前五科的均分") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/high-five) | Easy | -| 1085 | [Sum of Digits in the Minimum Number](https://leetcode.com/problems/sum-of-digits-in-the-minimum-number "最小元素各数位之和") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/sum-of-digits-in-the-minimum-number) | Easy | -| 1084 | [Sales Analysis III](https://leetcode.com/problems/sales-analysis-iii "销售分析III") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/sales-analysis-iii) | Easy | -| 1083 | [Sales Analysis II](https://leetcode.com/problems/sales-analysis-ii "销售分析 II") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/sales-analysis-ii) | Easy | -| 1082 | [Sales Analysis I](https://leetcode.com/problems/sales-analysis-i "销售分析 I ") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/sales-analysis-i) | Easy | -| 1081 | [Smallest Subsequence of Distinct Characters](https://leetcode.com/problems/smallest-subsequence-of-distinct-characters "不同字符的最小子序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-subsequence-of-distinct-characters) | Medium | -| 1080 | [Insufficient Nodes in Root to Leaf Paths](https://leetcode.com/problems/insufficient-nodes-in-root-to-leaf-paths "根到叶路径上的不足节点") | [Go](https://github.com/openset/leetcode/tree/master/problems/insufficient-nodes-in-root-to-leaf-paths) | Medium | -| 1079 | [Letter Tile Possibilities](https://leetcode.com/problems/letter-tile-possibilities "活字印刷") | [Go](https://github.com/openset/leetcode/tree/master/problems/letter-tile-possibilities) | Medium | -| 1078 | [Occurrences After Bigram](https://leetcode.com/problems/occurrences-after-bigram "Bigram 分词") | [Go](https://github.com/openset/leetcode/tree/master/problems/occurrences-after-bigram) | Easy | -| 1077 | [Project Employees III](https://leetcode.com/problems/project-employees-iii "项目员工 III") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/project-employees-iii) | Medium | -| 1076 | [Project Employees II](https://leetcode.com/problems/project-employees-ii "项目员工II") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/project-employees-ii) | Easy | -| 1075 | [Project Employees I](https://leetcode.com/problems/project-employees-i "项目员工 I") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/project-employees-i) | Easy | -| 1074 | [Number of Submatrices That Sum to Target](https://leetcode.com/problems/number-of-submatrices-that-sum-to-target "元素和为目标值的子矩阵数量") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-submatrices-that-sum-to-target) | Hard | -| 1073 | [Adding Two Negabinary Numbers](https://leetcode.com/problems/adding-two-negabinary-numbers "负二进制数相加") | [Go](https://github.com/openset/leetcode/tree/master/problems/adding-two-negabinary-numbers) | Medium | -| 1072 | [Flip Columns For Maximum Number of Equal Rows](https://leetcode.com/problems/flip-columns-for-maximum-number-of-equal-rows "按列翻转得到最大值等行数") | [Go](https://github.com/openset/leetcode/tree/master/problems/flip-columns-for-maximum-number-of-equal-rows) | Medium | -| 1071 | [Greatest Common Divisor of Strings](https://leetcode.com/problems/greatest-common-divisor-of-strings "字符串的最大公因子") | [Go](https://github.com/openset/leetcode/tree/master/problems/greatest-common-divisor-of-strings) | Easy | -| 1070 | [Product Sales Analysis III](https://leetcode.com/problems/product-sales-analysis-iii "产品销售分析 III") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-iii) | Medium | -| 1069 | [Product Sales Analysis II](https://leetcode.com/problems/product-sales-analysis-ii "产品销售分析 II") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-ii) | Easy | -| 1068 | [Product Sales Analysis I](https://leetcode.com/problems/product-sales-analysis-i "产品销售分析 I") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-i) | Easy | -| 1067 | [Digit Count in Range](https://leetcode.com/problems/digit-count-in-range "范围内的数字计数") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/digit-count-in-range) | Hard | -| 1066 | [Campus Bikes II](https://leetcode.com/problems/campus-bikes-ii "校园自行车分配 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/campus-bikes-ii) | Medium | -| 1065 | [Index Pairs of a String](https://leetcode.com/problems/index-pairs-of-a-string "字符串的索引对") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/index-pairs-of-a-string) | Easy | -| 1064 | [Fixed Point](https://leetcode.com/problems/fixed-point "不动点") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/fixed-point) | Easy | -| 1063 | [Number of Valid Subarrays](https://leetcode.com/problems/number-of-valid-subarrays "有效子数组的数目") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-valid-subarrays) | Hard | -| 1062 | [Longest Repeating Substring](https://leetcode.com/problems/longest-repeating-substring "最长重复子串") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-repeating-substring) | Medium | -| 1061 | [Lexicographically Smallest Equivalent String](https://leetcode.com/problems/lexicographically-smallest-equivalent-string "按字典序排列最小的等效字符串") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/lexicographically-smallest-equivalent-string) | Medium | -| 1060 | [Missing Element in Sorted Array](https://leetcode.com/problems/missing-element-in-sorted-array "有序数组中的缺失元素") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/missing-element-in-sorted-array) | Medium | -| 1059 | [All Paths from Source Lead to Destination](https://leetcode.com/problems/all-paths-from-source-lead-to-destination "从始点到终点的所有路径") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/all-paths-from-source-lead-to-destination) | Medium | -| 1058 | [Minimize Rounding Error to Meet Target](https://leetcode.com/problems/minimize-rounding-error-to-meet-target "最小化舍入误差以满足目标") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/minimize-rounding-error-to-meet-target) | Medium | -| 1057 | [Campus Bikes](https://leetcode.com/problems/campus-bikes "校园自行车分配") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/campus-bikes) | Medium | -| 1056 | [Confusing Number](https://leetcode.com/problems/confusing-number "易混淆数") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/confusing-number) | Easy | -| 1055 | [Shortest Way to Form String](https://leetcode.com/problems/shortest-way-to-form-string "形成字符串的最短路径") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-way-to-form-string) | Medium | -| 1054 | [Distant Barcodes](https://leetcode.com/problems/distant-barcodes "距离相等的条形码") | [Go](https://github.com/openset/leetcode/tree/master/problems/distant-barcodes) | Medium | -| 1053 | [Previous Permutation With One Swap](https://leetcode.com/problems/previous-permutation-with-one-swap "交换一次的先前排列") | [Go](https://github.com/openset/leetcode/tree/master/problems/previous-permutation-with-one-swap) | Medium | -| 1052 | [Grumpy Bookstore Owner](https://leetcode.com/problems/grumpy-bookstore-owner "爱生气的书店老板") | [Go](https://github.com/openset/leetcode/tree/master/problems/grumpy-bookstore-owner) | Medium | -| 1051 | [Height Checker](https://leetcode.com/problems/height-checker "高度检查器") | [Go](https://github.com/openset/leetcode/tree/master/problems/height-checker) | Easy | -| 1050 | [Actors and Directors Who Cooperated At Least Three Times](https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times "合作过至少三次的演员和导演") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/actors-and-directors-who-cooperated-at-least-three-times) | Easy | -| 1049 | [Last Stone Weight II](https://leetcode.com/problems/last-stone-weight-ii "最后一块石头的重量 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/last-stone-weight-ii) | Medium | -| 1048 | [Longest String Chain](https://leetcode.com/problems/longest-string-chain "最长字符串链") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-string-chain) | Medium | -| 1047 | [Remove All Adjacent Duplicates In String](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string "删除字符串中的所有相邻重复项") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-all-adjacent-duplicates-in-string) | Easy | -| 1046 | [Last Stone Weight](https://leetcode.com/problems/last-stone-weight "最后一块石头的重量") | [Go](https://github.com/openset/leetcode/tree/master/problems/last-stone-weight) | Easy | -| 1045 | [Customers Who Bought All Products](https://leetcode.com/problems/customers-who-bought-all-products "买下所有产品的客户") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/customers-who-bought-all-products) | Medium | -| 1044 | [Longest Duplicate Substring](https://leetcode.com/problems/longest-duplicate-substring "最长重复子串") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-duplicate-substring) | Hard | -| 1043 | [Partition Array for Maximum Sum](https://leetcode.com/problems/partition-array-for-maximum-sum "分隔数组以得到最大和") | [Go](https://github.com/openset/leetcode/tree/master/problems/partition-array-for-maximum-sum) | Medium | -| 1042 | [Flower Planting With No Adjacent](https://leetcode.com/problems/flower-planting-with-no-adjacent "不邻接植花") | [Go](https://github.com/openset/leetcode/tree/master/problems/flower-planting-with-no-adjacent) | Easy | -| 1041 | [Robot Bounded In Circle](https://leetcode.com/problems/robot-bounded-in-circle "困于环中的机器人") | [Go](https://github.com/openset/leetcode/tree/master/problems/robot-bounded-in-circle) | Medium | -| 1040 | [Moving Stones Until Consecutive II](https://leetcode.com/problems/moving-stones-until-consecutive-ii "移动石子直到连续 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/moving-stones-until-consecutive-ii) | Medium | -| 1039 | [Minimum Score Triangulation of Polygon](https://leetcode.com/problems/minimum-score-triangulation-of-polygon "多边形三角剖分的最低得分") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-score-triangulation-of-polygon) | Medium | -| 1038 | [Binary Search Tree to Greater Sum Tree](https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree "从二叉搜索树到更大和树") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-search-tree-to-greater-sum-tree) | Medium | -| 1037 | [Valid Boomerang](https://leetcode.com/problems/valid-boomerang "有效的回旋镖") | [Go](https://github.com/openset/leetcode/tree/master/problems/valid-boomerang) | Easy | -| 1036 | [Escape a Large Maze](https://leetcode.com/problems/escape-a-large-maze "逃离大迷宫") | [Go](https://github.com/openset/leetcode/tree/master/problems/escape-a-large-maze) | Hard | -| 1035 | [Uncrossed Lines](https://leetcode.com/problems/uncrossed-lines "不相交的线") | [Go](https://github.com/openset/leetcode/tree/master/problems/uncrossed-lines) | Medium | -| 1034 | [Coloring A Border](https://leetcode.com/problems/coloring-a-border "边框着色") | [Go](https://github.com/openset/leetcode/tree/master/problems/coloring-a-border) | Medium | -| 1033 | [Moving Stones Until Consecutive](https://leetcode.com/problems/moving-stones-until-consecutive "移动石子直到连续") | [Go](https://github.com/openset/leetcode/tree/master/problems/moving-stones-until-consecutive) | Easy | -| 1032 | [Stream of Characters](https://leetcode.com/problems/stream-of-characters "字符流") | [Go](https://github.com/openset/leetcode/tree/master/problems/stream-of-characters) | Hard | -| 1031 | [Maximum Sum of Two Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays "两个非重叠子数组的最大和") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-sum-of-two-non-overlapping-subarrays) | Medium | -| 1030 | [Matrix Cells in Distance Order](https://leetcode.com/problems/matrix-cells-in-distance-order "距离顺序排列矩阵单元格") | [Go](https://github.com/openset/leetcode/tree/master/problems/matrix-cells-in-distance-order) | Easy | -| 1029 | [Two City Scheduling](https://leetcode.com/problems/two-city-scheduling "两地调度") | [Go](https://github.com/openset/leetcode/tree/master/problems/two-city-scheduling) | Easy | -| 1028 | [Recover a Tree From Preorder Traversal](https://leetcode.com/problems/recover-a-tree-from-preorder-traversal "从先序遍历还原二叉树") | [Go](https://github.com/openset/leetcode/tree/master/problems/recover-a-tree-from-preorder-traversal) | Hard | -| 1027 | [Longest Arithmetic Sequence](https://leetcode.com/problems/longest-arithmetic-sequence "最长等差数列") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-arithmetic-sequence) | Medium | -| 1026 | [Maximum Difference Between Node and Ancestor](https://leetcode.com/problems/maximum-difference-between-node-and-ancestor "节点与其祖先之间的最大差值") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-difference-between-node-and-ancestor) | Medium | -| 1025 | [Divisor Game](https://leetcode.com/problems/divisor-game "除数博弈") | [Go](https://github.com/openset/leetcode/tree/master/problems/divisor-game) | Easy | -| 1024 | [Video Stitching](https://leetcode.com/problems/video-stitching "视频拼接") | [Go](https://github.com/openset/leetcode/tree/master/problems/video-stitching) | Medium | -| 1023 | [Camelcase Matching](https://leetcode.com/problems/camelcase-matching "驼峰式匹配") | [Go](https://github.com/openset/leetcode/tree/master/problems/camelcase-matching) | Medium | -| 1022 | [Sum of Root To Leaf Binary Numbers](https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers "从根到叶的二进制数之和") | [Go](https://github.com/openset/leetcode/tree/master/problems/sum-of-root-to-leaf-binary-numbers) | Easy | -| 1021 | [Remove Outermost Parentheses](https://leetcode.com/problems/remove-outermost-parentheses "删除最外层的括号") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-outermost-parentheses) | Easy | -| 1020 | [Number of Enclaves](https://leetcode.com/problems/number-of-enclaves "飞地的数量") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-enclaves) | Medium | -| 1019 | [Next Greater Node In Linked List](https://leetcode.com/problems/next-greater-node-in-linked-list "链表中的下一个更大节点") | [Go](https://github.com/openset/leetcode/tree/master/problems/next-greater-node-in-linked-list) | Medium | -| 1018 | [Binary Prefix Divisible By 5](https://leetcode.com/problems/binary-prefix-divisible-by-5 "可被 5 整除的二进制前缀") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-prefix-divisible-by-5) | Easy | -| 1017 | [Convert to Base -2](https://leetcode.com/problems/convert-to-base-2 "负二进制转换") | [Go](https://github.com/openset/leetcode/tree/master/problems/convert-to-base-2) | Medium | -| 1016 | [Binary String With Substrings Representing 1 To N](https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n "子串能表示从 1 到 N 数字的二进制串") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-string-with-substrings-representing-1-to-n) | Medium | -| 1015 | [Smallest Integer Divisible by K](https://leetcode.com/problems/smallest-integer-divisible-by-k "可被 K 整除的最小整数") | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-integer-divisible-by-k) | Medium | -| 1014 | [Best Sightseeing Pair](https://leetcode.com/problems/best-sightseeing-pair "最佳观光组合") | [Go](https://github.com/openset/leetcode/tree/master/problems/best-sightseeing-pair) | Medium | -| 1013 | [Partition Array Into Three Parts With Equal Sum](https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum "将数组分成和相等的三个部分") | [Go](https://github.com/openset/leetcode/tree/master/problems/partition-array-into-three-parts-with-equal-sum) | Easy | -| 1012 | [Numbers With Repeated Digits](https://leetcode.com/problems/numbers-with-repeated-digits "至少有 1 位重复的数字") | [Go](https://github.com/openset/leetcode/tree/master/problems/numbers-with-repeated-digits) | Hard | -| 1011 | [Capacity To Ship Packages Within D Days](https://leetcode.com/problems/capacity-to-ship-packages-within-d-days "在 D 天内送达包裹的能力") | [Go](https://github.com/openset/leetcode/tree/master/problems/capacity-to-ship-packages-within-d-days) | Medium | -| 1010 | [Pairs of Songs With Total Durations Divisible by 60](https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60 "总持续时间可被 60 整除的歌曲") | [Go](https://github.com/openset/leetcode/tree/master/problems/pairs-of-songs-with-total-durations-divisible-by-60) | Easy | -| 1009 | [Complement of Base 10 Integer](https://leetcode.com/problems/complement-of-base-10-integer "十进制整数的反码") | [Go](https://github.com/openset/leetcode/tree/master/problems/complement-of-base-10-integer) | Easy | -| 1008 | [Construct Binary Search Tree from Preorder Traversal](https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal "先序遍历构造二叉树") | [Go](https://github.com/openset/leetcode/tree/master/problems/construct-binary-search-tree-from-preorder-traversal) | Medium | -| 1007 | [Minimum Domino Rotations For Equal Row](https://leetcode.com/problems/minimum-domino-rotations-for-equal-row "行相等的最少多米诺旋转") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-domino-rotations-for-equal-row) | Medium | -| 1006 | [Clumsy Factorial](https://leetcode.com/problems/clumsy-factorial "笨阶乘") | [Go](https://github.com/openset/leetcode/tree/master/problems/clumsy-factorial) | Medium | -| 1005 | [Maximize Sum Of Array After K Negations](https://leetcode.com/problems/maximize-sum-of-array-after-k-negations "K 次取反后最大化的数组和") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximize-sum-of-array-after-k-negations) | Easy | -| 1004 | [Max Consecutive Ones III](https://leetcode.com/problems/max-consecutive-ones-iii "最大连续1的个数 III") | [Go](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones-iii) | Medium | -| 1003 | [Check If Word Is Valid After Substitutions](https://leetcode.com/problems/check-if-word-is-valid-after-substitutions "检查替换后的词是否有效") | [Go](https://github.com/openset/leetcode/tree/master/problems/check-if-word-is-valid-after-substitutions) | Medium | -| 1002 | [Find Common Characters](https://leetcode.com/problems/find-common-characters "查找常用字符") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-common-characters) | Easy | -| 1001 | [Grid Illumination](https://leetcode.com/problems/grid-illumination "网格照明") | [Go](https://github.com/openset/leetcode/tree/master/problems/grid-illumination) | Hard | -| 1000 | [Minimum Cost to Merge Stones](https://leetcode.com/problems/minimum-cost-to-merge-stones "合并石头的最低成本") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-to-merge-stones) | Hard | -| 999 | [Available Captures for Rook](https://leetcode.com/problems/available-captures-for-rook "车的可用捕获量") | [Go](https://github.com/openset/leetcode/tree/master/problems/available-captures-for-rook) | Easy | -| 998 | [Maximum Binary Tree II](https://leetcode.com/problems/maximum-binary-tree-ii "最大二叉树 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-binary-tree-ii) | Medium | -| 997 | [Find the Town Judge](https://leetcode.com/problems/find-the-town-judge "找到小镇的法官") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-the-town-judge) | Easy | -| 996 | [Number of Squareful Arrays](https://leetcode.com/problems/number-of-squareful-arrays "正方形数组的数目") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-squareful-arrays) | Hard | -| 995 | [Minimum Number of K Consecutive Bit Flips](https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips "K 连续位的最小翻转次数") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-k-consecutive-bit-flips) | Hard | -| 994 | [Rotting Oranges](https://leetcode.com/problems/rotting-oranges "腐烂的橘子") | [Go](https://github.com/openset/leetcode/tree/master/problems/rotting-oranges) | Easy | -| 993 | [Cousins in Binary Tree](https://leetcode.com/problems/cousins-in-binary-tree "二叉树的堂兄弟节点") | [Go](https://github.com/openset/leetcode/tree/master/problems/cousins-in-binary-tree) | Easy | -| 992 | [Subarrays with K Different Integers](https://leetcode.com/problems/subarrays-with-k-different-integers "K 个不同整数的子数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/subarrays-with-k-different-integers) | Hard | -| 991 | [Broken Calculator](https://leetcode.com/problems/broken-calculator "坏了的计算器") | [Go](https://github.com/openset/leetcode/tree/master/problems/broken-calculator) | Medium | -| 990 | [Satisfiability of Equality Equations](https://leetcode.com/problems/satisfiability-of-equality-equations "等式方程的可满足性") | [Go](https://github.com/openset/leetcode/tree/master/problems/satisfiability-of-equality-equations) | Medium | -| 989 | [Add to Array-Form of Integer](https://leetcode.com/problems/add-to-array-form-of-integer "数组形式的整数加法") | [Go](https://github.com/openset/leetcode/tree/master/problems/add-to-array-form-of-integer) | Easy | -| 988 | [Smallest String Starting From Leaf](https://leetcode.com/problems/smallest-string-starting-from-leaf "从叶结点开始的最小字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-string-starting-from-leaf) | Medium | -| 987 | [Vertical Order Traversal of a Binary Tree](https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree "二叉树的垂序遍历") | [Go](https://github.com/openset/leetcode/tree/master/problems/vertical-order-traversal-of-a-binary-tree) | Medium | -| 986 | [Interval List Intersections](https://leetcode.com/problems/interval-list-intersections "区间列表的交集") | [Go](https://github.com/openset/leetcode/tree/master/problems/interval-list-intersections) | Medium | -| 985 | [Sum of Even Numbers After Queries](https://leetcode.com/problems/sum-of-even-numbers-after-queries "查询后的偶数和") | [Go](https://github.com/openset/leetcode/tree/master/problems/sum-of-even-numbers-after-queries) | Easy | -| 984 | [String Without AAA or BBB](https://leetcode.com/problems/string-without-aaa-or-bbb "不含 AAA 或 BBB 的字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/string-without-aaa-or-bbb) | Medium | -| 983 | [Minimum Cost For Tickets](https://leetcode.com/problems/minimum-cost-for-tickets "最低票价") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-for-tickets) | Medium | -| 982 | [Triples with Bitwise AND Equal To Zero](https://leetcode.com/problems/triples-with-bitwise-and-equal-to-zero "按位与为零的三元组") | [Go](https://github.com/openset/leetcode/tree/master/problems/triples-with-bitwise-and-equal-to-zero) | Hard | -| 981 | [Time Based Key-Value Store](https://leetcode.com/problems/time-based-key-value-store "基于时间的键值存储") | [Go](https://github.com/openset/leetcode/tree/master/problems/time-based-key-value-store) | Medium | -| 980 | [Unique Paths III](https://leetcode.com/problems/unique-paths-iii "不同路径 III") | [Go](https://github.com/openset/leetcode/tree/master/problems/unique-paths-iii) | Hard | -| 979 | [Distribute Coins in Binary Tree](https://leetcode.com/problems/distribute-coins-in-binary-tree "在二叉树中分配硬币") | [Go](https://github.com/openset/leetcode/tree/master/problems/distribute-coins-in-binary-tree) | Medium | -| 978 | [Longest Turbulent Subarray](https://leetcode.com/problems/longest-turbulent-subarray "最长湍流子数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-turbulent-subarray) | Medium | -| 977 | [Squares of a Sorted Array](https://leetcode.com/problems/squares-of-a-sorted-array "有序数组的平方") | [Go](https://github.com/openset/leetcode/tree/master/problems/squares-of-a-sorted-array) | Easy | -| 976 | [Largest Perimeter Triangle](https://leetcode.com/problems/largest-perimeter-triangle "三角形的最大周长") | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-perimeter-triangle) | Easy | -| 975 | [Odd Even Jump](https://leetcode.com/problems/odd-even-jump "奇偶跳") | [Go](https://github.com/openset/leetcode/tree/master/problems/odd-even-jump) | Hard | -| 974 | [Subarray Sums Divisible by K](https://leetcode.com/problems/subarray-sums-divisible-by-k "和可被 K 整除的子数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/subarray-sums-divisible-by-k) | Medium | -| 973 | [K Closest Points to Origin](https://leetcode.com/problems/k-closest-points-to-origin "最接近原点的 K 个点") | [Go](https://github.com/openset/leetcode/tree/master/problems/k-closest-points-to-origin) | Medium | -| 972 | [Equal Rational Numbers](https://leetcode.com/problems/equal-rational-numbers "相等的有理数") | [Go](https://github.com/openset/leetcode/tree/master/problems/equal-rational-numbers) | Hard | -| 971 | [Flip Binary Tree To Match Preorder Traversal](https://leetcode.com/problems/flip-binary-tree-to-match-preorder-traversal "翻转二叉树以匹配先序遍历") | [Go](https://github.com/openset/leetcode/tree/master/problems/flip-binary-tree-to-match-preorder-traversal) | Medium | -| 970 | [Powerful Integers](https://leetcode.com/problems/powerful-integers "强整数") | [Go](https://github.com/openset/leetcode/tree/master/problems/powerful-integers) | Easy | -| 969 | [Pancake Sorting](https://leetcode.com/problems/pancake-sorting "煎饼排序") | [Go](https://github.com/openset/leetcode/tree/master/problems/pancake-sorting) | Medium | -| 968 | [Binary Tree Cameras](https://leetcode.com/problems/binary-tree-cameras "监控二叉树") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-cameras) | Hard | -| 967 | [Numbers With Same Consecutive Differences](https://leetcode.com/problems/numbers-with-same-consecutive-differences "连续差相同的数字") | [Go](https://github.com/openset/leetcode/tree/master/problems/numbers-with-same-consecutive-differences) | Medium | -| 966 | [Vowel Spellchecker](https://leetcode.com/problems/vowel-spellchecker "元音拼写检查器") | [Go](https://github.com/openset/leetcode/tree/master/problems/vowel-spellchecker) | Medium | -| 965 | [Univalued Binary Tree](https://leetcode.com/problems/univalued-binary-tree "单值二叉树") | [Go](https://github.com/openset/leetcode/tree/master/problems/univalued-binary-tree) | Easy | -| 964 | [Least Operators to Express Number](https://leetcode.com/problems/least-operators-to-express-number "表示数字的最少运算符") | [Go](https://github.com/openset/leetcode/tree/master/problems/least-operators-to-express-number) | Hard | -| 963 | [Minimum Area Rectangle II](https://leetcode.com/problems/minimum-area-rectangle-ii "最小面积矩形 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-area-rectangle-ii) | Medium | -| 962 | [Maximum Width Ramp](https://leetcode.com/problems/maximum-width-ramp "最大宽度坡") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-width-ramp) | Medium | -| 961 | [N-Repeated Element in Size 2N Array](https://leetcode.com/problems/n-repeated-element-in-size-2n-array "重复 N 次的元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/n-repeated-element-in-size-2n-array) | Easy | -| 960 | [Delete Columns to Make Sorted III](https://leetcode.com/problems/delete-columns-to-make-sorted-iii "删列造序 III") | [Go](https://github.com/openset/leetcode/tree/master/problems/delete-columns-to-make-sorted-iii) | Hard | -| 959 | [Regions Cut By Slashes](https://leetcode.com/problems/regions-cut-by-slashes "由斜杠划分区域") | [Go](https://github.com/openset/leetcode/tree/master/problems/regions-cut-by-slashes) | Medium | -| 958 | [Check Completeness of a Binary Tree](https://leetcode.com/problems/check-completeness-of-a-binary-tree "二叉树的完全性检验") | [Go](https://github.com/openset/leetcode/tree/master/problems/check-completeness-of-a-binary-tree) | Medium | -| 957 | [Prison Cells After N Days](https://leetcode.com/problems/prison-cells-after-n-days "N 天后的牢房") | [Go](https://github.com/openset/leetcode/tree/master/problems/prison-cells-after-n-days) | Medium | -| 956 | [Tallest Billboard](https://leetcode.com/problems/tallest-billboard "最高的广告牌") | [Go](https://github.com/openset/leetcode/tree/master/problems/tallest-billboard) | Hard | -| 955 | [Delete Columns to Make Sorted II](https://leetcode.com/problems/delete-columns-to-make-sorted-ii "删列造序 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/delete-columns-to-make-sorted-ii) | Medium | -| 954 | [Array of Doubled Pairs](https://leetcode.com/problems/array-of-doubled-pairs "二倍数对数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/array-of-doubled-pairs) | Medium | -| 953 | [Verifying an Alien Dictionary](https://leetcode.com/problems/verifying-an-alien-dictionary "验证外星语词典") | [Go](https://github.com/openset/leetcode/tree/master/problems/verifying-an-alien-dictionary) | Easy | -| 952 | [Largest Component Size by Common Factor](https://leetcode.com/problems/largest-component-size-by-common-factor "按公因数计算最大组件大小") | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-component-size-by-common-factor) | Hard | -| 951 | [Flip Equivalent Binary Trees](https://leetcode.com/problems/flip-equivalent-binary-trees "翻转等价二叉树") | [Go](https://github.com/openset/leetcode/tree/master/problems/flip-equivalent-binary-trees) | Medium | -| 950 | [Reveal Cards In Increasing Order](https://leetcode.com/problems/reveal-cards-in-increasing-order "按递增顺序显示卡牌") | [Go](https://github.com/openset/leetcode/tree/master/problems/reveal-cards-in-increasing-order) | Medium | -| 949 | [Largest Time for Given Digits](https://leetcode.com/problems/largest-time-for-given-digits "给定数字能组成的最大时间") | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-time-for-given-digits) | Easy | -| 948 | [Bag of Tokens](https://leetcode.com/problems/bag-of-tokens "令牌放置") | [Go](https://github.com/openset/leetcode/tree/master/problems/bag-of-tokens) | Medium | -| 947 | [Most Stones Removed with Same Row or Column](https://leetcode.com/problems/most-stones-removed-with-same-row-or-column "移除最多的同行或同列石头") | [Go](https://github.com/openset/leetcode/tree/master/problems/most-stones-removed-with-same-row-or-column) | Medium | -| 946 | [Validate Stack Sequences](https://leetcode.com/problems/validate-stack-sequences "验证栈序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/validate-stack-sequences) | Medium | -| 945 | [Minimum Increment to Make Array Unique](https://leetcode.com/problems/minimum-increment-to-make-array-unique "使数组唯一的最小增量") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-increment-to-make-array-unique) | Medium | -| 944 | [Delete Columns to Make Sorted](https://leetcode.com/problems/delete-columns-to-make-sorted "删列造序") | [Go](https://github.com/openset/leetcode/tree/master/problems/delete-columns-to-make-sorted) | Easy | -| 943 | [Find the Shortest Superstring](https://leetcode.com/problems/find-the-shortest-superstring "最短超级串") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-the-shortest-superstring) | Hard | -| 942 | [DI String Match](https://leetcode.com/problems/di-string-match "增减字符串匹配") | [Go](https://github.com/openset/leetcode/tree/master/problems/di-string-match) | Easy | -| 941 | [Valid Mountain Array](https://leetcode.com/problems/valid-mountain-array "有效的山脉数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/valid-mountain-array) | Easy | -| 940 | [Distinct Subsequences II](https://leetcode.com/problems/distinct-subsequences-ii "不同的子序列 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/distinct-subsequences-ii) | Hard | -| 939 | [Minimum Area Rectangle](https://leetcode.com/problems/minimum-area-rectangle "最小面积矩形") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-area-rectangle) | Medium | -| 938 | [Range Sum of BST](https://leetcode.com/problems/range-sum-of-bst "二叉搜索树的范围和") | [Go](https://github.com/openset/leetcode/tree/master/problems/range-sum-of-bst) | Easy | -| 937 | [Reorder Data in Log Files](https://leetcode.com/problems/reorder-data-in-log-files "重新排列日志文件") | [Go](https://github.com/openset/leetcode/tree/master/problems/reorder-data-in-log-files) | Easy | -| 936 | [Stamping The Sequence](https://leetcode.com/problems/stamping-the-sequence "戳印序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/stamping-the-sequence) | Hard | -| 935 | [Knight Dialer](https://leetcode.com/problems/knight-dialer "骑士拨号器") | [Go](https://github.com/openset/leetcode/tree/master/problems/knight-dialer) | Medium | -| 934 | [Shortest Bridge](https://leetcode.com/problems/shortest-bridge "最短的桥") | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-bridge) | Medium | -| 933 | [Number of Recent Calls](https://leetcode.com/problems/number-of-recent-calls "最近的请求次数") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-recent-calls) | Easy | -| 932 | [Beautiful Array](https://leetcode.com/problems/beautiful-array "漂亮数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/beautiful-array) | Medium | -| 931 | [Minimum Falling Path Sum](https://leetcode.com/problems/minimum-falling-path-sum "下降路径最小和") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-falling-path-sum) | Medium | -| 930 | [Binary Subarrays With Sum](https://leetcode.com/problems/binary-subarrays-with-sum "和相同的二元子数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-subarrays-with-sum) | Medium | -| 929 | [Unique Email Addresses](https://leetcode.com/problems/unique-email-addresses "独特的电子邮件地址") | [Go](https://github.com/openset/leetcode/tree/master/problems/unique-email-addresses) | Easy | -| 928 | [Minimize Malware Spread II](https://leetcode.com/problems/minimize-malware-spread-ii "尽量减少恶意软件的传播 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimize-malware-spread-ii) | Hard | -| 927 | [Three Equal Parts](https://leetcode.com/problems/three-equal-parts "三等分") | [Go](https://github.com/openset/leetcode/tree/master/problems/three-equal-parts) | Hard | -| 926 | [Flip String to Monotone Increasing](https://leetcode.com/problems/flip-string-to-monotone-increasing "将字符串翻转到单调递增") | [Go](https://github.com/openset/leetcode/tree/master/problems/flip-string-to-monotone-increasing) | Medium | -| 925 | [Long Pressed Name](https://leetcode.com/problems/long-pressed-name "长按键入") | [Go](https://github.com/openset/leetcode/tree/master/problems/long-pressed-name) | Easy | -| 924 | [Minimize Malware Spread](https://leetcode.com/problems/minimize-malware-spread "尽量减少恶意软件的传播") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimize-malware-spread) | Hard | -| 923 | [3Sum With Multiplicity](https://leetcode.com/problems/3sum-with-multiplicity "三数之和的多种可能") | [Go](https://github.com/openset/leetcode/tree/master/problems/3sum-with-multiplicity) | Medium | -| 922 | [Sort Array By Parity II](https://leetcode.com/problems/sort-array-by-parity-ii "按奇偶排序数组 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/sort-array-by-parity-ii) | Easy | -| 921 | [Minimum Add to Make Parentheses Valid](https://leetcode.com/problems/minimum-add-to-make-parentheses-valid "使括号有效的最少添加") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-add-to-make-parentheses-valid) | Medium | -| 920 | [Number of Music Playlists](https://leetcode.com/problems/number-of-music-playlists "播放列表的数量") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-music-playlists) | Hard | -| 919 | [Complete Binary Tree Inserter](https://leetcode.com/problems/complete-binary-tree-inserter "完全二叉树插入器") | [Go](https://github.com/openset/leetcode/tree/master/problems/complete-binary-tree-inserter) | Medium | -| 918 | [Maximum Sum Circular Subarray](https://leetcode.com/problems/maximum-sum-circular-subarray "环形子数组的最大和") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-sum-circular-subarray) | Medium | -| 917 | [Reverse Only Letters](https://leetcode.com/problems/reverse-only-letters "仅仅反转字母") | [Go](https://github.com/openset/leetcode/tree/master/problems/reverse-only-letters) | Easy | -| 916 | [Word Subsets](https://leetcode.com/problems/word-subsets "单词子集") | [Go](https://github.com/openset/leetcode/tree/master/problems/word-subsets) | Medium | -| 915 | [Partition Array into Disjoint Intervals](https://leetcode.com/problems/partition-array-into-disjoint-intervals "分割数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/partition-array-into-disjoint-intervals) | Medium | -| 914 | [X of a Kind in a Deck of Cards](https://leetcode.com/problems/x-of-a-kind-in-a-deck-of-cards "卡牌分组") | [Go](https://github.com/openset/leetcode/tree/master/problems/x-of-a-kind-in-a-deck-of-cards) | Easy | -| 913 | [Cat and Mouse](https://leetcode.com/problems/cat-and-mouse "猫和老鼠") | [Go](https://github.com/openset/leetcode/tree/master/problems/cat-and-mouse) | Hard | -| 912 | [Sort an Array](https://leetcode.com/problems/sort-an-array "排序数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/sort-an-array) | Medium | -| 911 | [Online Election](https://leetcode.com/problems/online-election "在线选举") | [Go](https://github.com/openset/leetcode/tree/master/problems/online-election) | Medium | -| 910 | [Smallest Range II](https://leetcode.com/problems/smallest-range-ii "最小差值 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-range-ii) | Medium | -| 909 | [Snakes and Ladders](https://leetcode.com/problems/snakes-and-ladders "蛇梯棋") | [Go](https://github.com/openset/leetcode/tree/master/problems/snakes-and-ladders) | Medium | -| 908 | [Smallest Range I](https://leetcode.com/problems/smallest-range-i "最小差值 I") | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-range-i) | Easy | -| 907 | [Sum of Subarray Minimums](https://leetcode.com/problems/sum-of-subarray-minimums "子数组的最小值之和") | [Go](https://github.com/openset/leetcode/tree/master/problems/sum-of-subarray-minimums) | Medium | -| 906 | [Super Palindromes](https://leetcode.com/problems/super-palindromes "超级回文数") | [Go](https://github.com/openset/leetcode/tree/master/problems/super-palindromes) | Hard | -| 905 | [Sort Array By Parity](https://leetcode.com/problems/sort-array-by-parity "按奇偶排序数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/sort-array-by-parity) | Easy | -| 904 | [Fruit Into Baskets](https://leetcode.com/problems/fruit-into-baskets "水果成篮") | [Go](https://github.com/openset/leetcode/tree/master/problems/fruit-into-baskets) | Medium | -| 903 | [Valid Permutations for DI Sequence](https://leetcode.com/problems/valid-permutations-for-di-sequence "DI 序列的有效排列") | [Go](https://github.com/openset/leetcode/tree/master/problems/valid-permutations-for-di-sequence) | Hard | -| 902 | [Numbers At Most N Given Digit Set](https://leetcode.com/problems/numbers-at-most-n-given-digit-set "最大为 N 的数字组合") | [Go](https://github.com/openset/leetcode/tree/master/problems/numbers-at-most-n-given-digit-set) | Hard | -| 901 | [Online Stock Span](https://leetcode.com/problems/online-stock-span "股票价格跨度") | [Go](https://github.com/openset/leetcode/tree/master/problems/online-stock-span) | Medium | +| 1293 | [Shortest Path in a Grid with Obstacles Elimination](https://leetcode.com/problems/shortest-path-in-a-grid-with-obstacles-elimination "网格中的最短路径") | [Go](problems/shortest-path-in-a-grid-with-obstacles-elimination) | Hard | +| 1292 | [Maximum Side Length of a Square with Sum Less than or Equal to Threshold](https://leetcode.com/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold "元素和小于等于阈值的正方形的最大边长") | [Go](problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | Medium | +| 1291 | [Sequential Digits](https://leetcode.com/problems/sequential-digits "顺次数") | [Go](problems/sequential-digits) | Medium | +| 1290 | [Convert Binary Number in a Linked List to Integer](https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer "二进制链表转整数") | [Go](problems/convert-binary-number-in-a-linked-list-to-integer) | Easy | +| 1289 | [Minimum Falling Path Sum II](https://leetcode.com/problems/minimum-falling-path-sum-ii "下降路径最小和 II") | [Go](problems/minimum-falling-path-sum-ii) | Hard | +| 1288 | [Remove Covered Intervals](https://leetcode.com/problems/remove-covered-intervals "删除被覆盖区间") | [Go](problems/remove-covered-intervals) | Medium | +| 1287 | [Element Appearing More Than 25% In Sorted Array](https://leetcode.com/problems/element-appearing-more-than-25-in-sorted-array "有序数组中出现次数超过25%的元素") | [Go](problems/element-appearing-more-than-25-in-sorted-array) | Easy | +| 1286 | [Iterator for Combination](https://leetcode.com/problems/iterator-for-combination "字母组合迭代器") | [Go](problems/iterator-for-combination) | Medium | +| 1285 | [Find the Start and End Number of Continuous Ranges](https://leetcode.com/problems/find-the-start-and-end-number-of-continuous-ranges) 🔒 | [MySQL](problems/find-the-start-and-end-number-of-continuous-ranges) | Medium | +| 1284 | [Minimum Number of Flips to Convert Binary Matrix to Zero Matrix](https://leetcode.com/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix "转化为全零矩阵的最少反转次数") | [Go](problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | Hard | +| 1283 | [Find the Smallest Divisor Given a Threshold](https://leetcode.com/problems/find-the-smallest-divisor-given-a-threshold "使结果不超过阈值的最小除数") | [Go](problems/find-the-smallest-divisor-given-a-threshold) | Medium | +| 1282 | [Group the People Given the Group Size They Belong To](https://leetcode.com/problems/group-the-people-given-the-group-size-they-belong-to "用户分组") | [Go](problems/group-the-people-given-the-group-size-they-belong-to) | Medium | +| 1281 | [Subtract the Product and Sum of Digits of an Integer](https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer "整数的各位积和之差") | [Go](problems/subtract-the-product-and-sum-of-digits-of-an-integer) | Easy | +| 1280 | [Students and Examinations](https://leetcode.com/problems/students-and-examinations) 🔒 | [MySQL](problems/students-and-examinations) | Easy | +| 1279 | [Traffic Light Controlled Intersection](https://leetcode.com/problems/traffic-light-controlled-intersection) 🔒 | [Go](problems/traffic-light-controlled-intersection) | Easy | +| 1278 | [Palindrome Partitioning III](https://leetcode.com/problems/palindrome-partitioning-iii "分割回文串 III") | [Go](problems/palindrome-partitioning-iii) | Hard | +| 1277 | [Count Square Submatrices with All Ones](https://leetcode.com/problems/count-square-submatrices-with-all-ones "统计全为 1 的正方形子矩阵") | [Go](problems/count-square-submatrices-with-all-ones) | Medium | +| 1276 | [Number of Burgers with No Waste of Ingredients](https://leetcode.com/problems/number-of-burgers-with-no-waste-of-ingredients "不浪费原料的汉堡制作方案") | [Go](problems/number-of-burgers-with-no-waste-of-ingredients) | Medium | +| 1275 | [Find Winner on a Tic Tac Toe Game](https://leetcode.com/problems/find-winner-on-a-tic-tac-toe-game "找出井字棋的获胜者") | [Go](problems/find-winner-on-a-tic-tac-toe-game) | Easy | +| 1274 | [Number of Ships in a Rectangle](https://leetcode.com/problems/number-of-ships-in-a-rectangle "矩形内船只的数目") 🔒 | [Go](problems/number-of-ships-in-a-rectangle) | Hard | +| 1273 | [Delete Tree Nodes](https://leetcode.com/problems/delete-tree-nodes "删除树节点") 🔒 | [Go](problems/delete-tree-nodes) | Medium | +| 1272 | [Remove Interval](https://leetcode.com/problems/remove-interval "删除区间") 🔒 | [Go](problems/remove-interval) | Medium | +| 1271 | [Hexspeak](https://leetcode.com/problems/hexspeak "十六进制魔术数字") 🔒 | [Go](problems/hexspeak) | Easy | +| 1270 | [All People Report to the Given Manager](https://leetcode.com/problems/all-people-report-to-the-given-manager) 🔒 | [MySQL](problems/all-people-report-to-the-given-manager) | Medium | +| 1269 | [Number of Ways to Stay in the Same Place After Some Steps](https://leetcode.com/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps "停在原地的方案数") | [Go](problems/number-of-ways-to-stay-in-the-same-place-after-some-steps) | Hard | +| 1268 | [Search Suggestions System](https://leetcode.com/problems/search-suggestions-system "搜索推荐系统") | [Go](problems/search-suggestions-system) | Medium | +| 1267 | [Count Servers that Communicate](https://leetcode.com/problems/count-servers-that-communicate "统计参与通信的服务器") | [Go](problems/count-servers-that-communicate) | Medium | +| 1266 | [Minimum Time Visiting All Points](https://leetcode.com/problems/minimum-time-visiting-all-points "访问所有点的最小时间") | [Go](problems/minimum-time-visiting-all-points) | Easy | +| 1265 | [Print Immutable Linked List in Reverse](https://leetcode.com/problems/print-immutable-linked-list-in-reverse) 🔒 | [Go](problems/print-immutable-linked-list-in-reverse) | Medium | +| 1264 | [Page Recommendations](https://leetcode.com/problems/page-recommendations) 🔒 | [MySQL](problems/page-recommendations) | Medium | +| 1263 | [Minimum Moves to Move a Box to Their Target Location](https://leetcode.com/problems/minimum-moves-to-move-a-box-to-their-target-location "推箱子") | [Go](problems/minimum-moves-to-move-a-box-to-their-target-location) | Hard | +| 1262 | [Greatest Sum Divisible by Three](https://leetcode.com/problems/greatest-sum-divisible-by-three "可被三整除的最大和") | [Go](problems/greatest-sum-divisible-by-three) | Medium | +| 1261 | [Find Elements in a Contaminated Binary Tree](https://leetcode.com/problems/find-elements-in-a-contaminated-binary-tree "在受污染的二叉树中查找元素") | [Go](problems/find-elements-in-a-contaminated-binary-tree) | Medium | +| 1260 | [Shift 2D Grid](https://leetcode.com/problems/shift-2d-grid "二维网格迁移") | [Go](problems/shift-2d-grid) | Easy | +| 1259 | [Handshakes That Don't Cross](https://leetcode.com/problems/handshakes-that-dont-cross "不相交的握手") 🔒 | [Go](problems/handshakes-that-dont-cross) | Hard | +| 1258 | [Synonymous Sentences](https://leetcode.com/problems/synonymous-sentences "近义词句子") 🔒 | [Go](problems/synonymous-sentences) | Medium | +| 1257 | [Smallest Common Region](https://leetcode.com/problems/smallest-common-region "最小公共区域") 🔒 | [Go](problems/smallest-common-region) | Medium | +| 1256 | [Encode Number](https://leetcode.com/problems/encode-number "加密数字") 🔒 | [Go](problems/encode-number) | Medium | +| 1255 | [Maximum Score Words Formed by Letters](https://leetcode.com/problems/maximum-score-words-formed-by-letters "得分最高的单词集合") | [Go](problems/maximum-score-words-formed-by-letters) | Hard | +| 1254 | [Number of Closed Islands](https://leetcode.com/problems/number-of-closed-islands "统计封闭岛屿的数目") | [Go](problems/number-of-closed-islands) | Medium | +| 1253 | [Reconstruct a 2-Row Binary Matrix](https://leetcode.com/problems/reconstruct-a-2-row-binary-matrix "重构 2 行二进制矩阵") | [Go](problems/reconstruct-a-2-row-binary-matrix) | Medium | +| 1252 | [Cells with Odd Values in a Matrix](https://leetcode.com/problems/cells-with-odd-values-in-a-matrix "奇数值单元格的数目") | [Go](problems/cells-with-odd-values-in-a-matrix) | Easy | +| 1251 | [Average Selling Price](https://leetcode.com/problems/average-selling-price) 🔒 | [MySQL](problems/average-selling-price) | Easy | +| 1250 | [Check If It Is a Good Array](https://leetcode.com/problems/check-if-it-is-a-good-array "检查「好数组」") | [Go](problems/check-if-it-is-a-good-array) | Hard | +| 1249 | [Minimum Remove to Make Valid Parentheses](https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses "移除无效的括号") | [Go](problems/minimum-remove-to-make-valid-parentheses) | Medium | +| 1248 | [Count Number of Nice Subarrays](https://leetcode.com/problems/count-number-of-nice-subarrays "统计「优美子数组」") | [Go](problems/count-number-of-nice-subarrays) | Medium | +| 1247 | [Minimum Swaps to Make Strings Equal](https://leetcode.com/problems/minimum-swaps-to-make-strings-equal "交换字符使得字符串相同") | [Go](problems/minimum-swaps-to-make-strings-equal) | Medium | +| 1246 | [Palindrome Removal](https://leetcode.com/problems/palindrome-removal "删除回文子数组") 🔒 | [Go](problems/palindrome-removal) | Hard | +| 1245 | [Tree Diameter](https://leetcode.com/problems/tree-diameter "树的直径") 🔒 | [Go](problems/tree-diameter) | Medium | +| 1244 | [Design A Leaderboard](https://leetcode.com/problems/design-a-leaderboard "力扣排行榜") 🔒 | [Go](problems/design-a-leaderboard) | Medium | +| 1243 | [Array Transformation](https://leetcode.com/problems/array-transformation "数组变换") 🔒 | [Go](problems/array-transformation) | Easy | +| 1242 | [Web Crawler Multithreaded](https://leetcode.com/problems/web-crawler-multithreaded "多线程网页爬虫") 🔒 | [Go](problems/web-crawler-multithreaded) | Medium | +| 1241 | [Number of Comments per Post](https://leetcode.com/problems/number-of-comments-per-post "每个帖子的评论数") 🔒 | [MySQL](problems/number-of-comments-per-post) | Easy | +| 1240 | [Tiling a Rectangle with the Fewest Squares](https://leetcode.com/problems/tiling-a-rectangle-with-the-fewest-squares "铺瓷砖") | [Go](problems/tiling-a-rectangle-with-the-fewest-squares) | Hard | +| 1239 | [Maximum Length of a Concatenated String with Unique Characters](https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters "串联字符串的最大长度") | [Go](problems/maximum-length-of-a-concatenated-string-with-unique-characters) | Medium | +| 1238 | [Circular Permutation in Binary Representation](https://leetcode.com/problems/circular-permutation-in-binary-representation "循环码排列") | [Go](problems/circular-permutation-in-binary-representation) | Medium | +| 1237 | [Find Positive Integer Solution for a Given Equation](https://leetcode.com/problems/find-positive-integer-solution-for-a-given-equation "找出给定方程的正整数解") | [Go](problems/find-positive-integer-solution-for-a-given-equation) | Easy | +| 1236 | [Web Crawler](https://leetcode.com/problems/web-crawler) 🔒 | [Go](problems/web-crawler) | Medium | +| 1235 | [Maximum Profit in Job Scheduling](https://leetcode.com/problems/maximum-profit-in-job-scheduling "规划兼职工作") | [Go](problems/maximum-profit-in-job-scheduling) | Hard | +| 1234 | [Replace the Substring for Balanced String](https://leetcode.com/problems/replace-the-substring-for-balanced-string "替换子串得到平衡字符串") | [Go](problems/replace-the-substring-for-balanced-string) | Medium | +| 1233 | [Remove Sub-Folders from the Filesystem](https://leetcode.com/problems/remove-sub-folders-from-the-filesystem "删除子文件夹") | [Go](problems/remove-sub-folders-from-the-filesystem) | Medium | +| 1232 | [Check If It Is a Straight Line](https://leetcode.com/problems/check-if-it-is-a-straight-line "缀点成线") | [Go](problems/check-if-it-is-a-straight-line) | Easy | +| 1231 | [Divide Chocolate](https://leetcode.com/problems/divide-chocolate "分享巧克力") 🔒 | [Go](problems/divide-chocolate) | Hard | +| 1230 | [Toss Strange Coins](https://leetcode.com/problems/toss-strange-coins "抛掷硬币") 🔒 | [Go](problems/toss-strange-coins) | Medium | +| 1229 | [Meeting Scheduler](https://leetcode.com/problems/meeting-scheduler "安排会议日程") 🔒 | [Go](problems/meeting-scheduler) | Medium | +| 1228 | [Missing Number In Arithmetic Progression](https://leetcode.com/problems/missing-number-in-arithmetic-progression "等差数列中缺失的数字") 🔒 | [Go](problems/missing-number-in-arithmetic-progression) | Easy | +| 1227 | [Airplane Seat Assignment Probability](https://leetcode.com/problems/airplane-seat-assignment-probability "飞机座位分配概率") | [Go](problems/airplane-seat-assignment-probability) | Medium | +| 1226 | [The Dining Philosophers](https://leetcode.com/problems/the-dining-philosophers "哲学家进餐") | [Go](problems/the-dining-philosophers) | Medium | +| 1225 | [Report Contiguous Dates](https://leetcode.com/problems/report-contiguous-dates "报告系统状态的连续日期") 🔒 | [MySQL](problems/report-contiguous-dates) | Hard | +| 1224 | [Maximum Equal Frequency](https://leetcode.com/problems/maximum-equal-frequency "最大相等频率") | [Go](problems/maximum-equal-frequency) | Hard | +| 1223 | [Dice Roll Simulation](https://leetcode.com/problems/dice-roll-simulation "掷骰子模拟") | [Go](problems/dice-roll-simulation) | Medium | +| 1222 | [Queens That Can Attack the King](https://leetcode.com/problems/queens-that-can-attack-the-king "可以攻击国王的皇后") | [Go](problems/queens-that-can-attack-the-king) | Medium | +| 1221 | [Split a String in Balanced Strings](https://leetcode.com/problems/split-a-string-in-balanced-strings "分割平衡字符串") | [Go](problems/split-a-string-in-balanced-strings) | Easy | +| 1220 | [Count Vowels Permutation](https://leetcode.com/problems/count-vowels-permutation "统计元音字母序列的数目") | [Go](problems/count-vowels-permutation) | Hard | +| 1219 | [Path with Maximum Gold](https://leetcode.com/problems/path-with-maximum-gold "黄金矿工") | [Go](problems/path-with-maximum-gold) | Medium | +| 1218 | [Longest Arithmetic Subsequence of Given Difference](https://leetcode.com/problems/longest-arithmetic-subsequence-of-given-difference "最长定差子序列") | [Go](problems/longest-arithmetic-subsequence-of-given-difference) | Medium | +| 1217 | [Play with Chips](https://leetcode.com/problems/play-with-chips "玩筹码") | [Go](problems/play-with-chips) | Easy | +| 1216 | [Valid Palindrome III](https://leetcode.com/problems/valid-palindrome-iii "验证回文字符串 III") 🔒 | [Go](problems/valid-palindrome-iii) | Hard | +| 1215 | [Stepping Numbers](https://leetcode.com/problems/stepping-numbers "步进数") 🔒 | [Go](problems/stepping-numbers) | Medium | +| 1214 | [Two Sum BSTs](https://leetcode.com/problems/two-sum-bsts "查找两棵二叉搜索树之和") 🔒 | [Go](problems/two-sum-bsts) | Medium | +| 1213 | [Intersection of Three Sorted Arrays](https://leetcode.com/problems/intersection-of-three-sorted-arrays "三个有序数组的交集") 🔒 | [Go](problems/intersection-of-three-sorted-arrays) | Easy | +| 1212 | [Team Scores in Football Tournament](https://leetcode.com/problems/team-scores-in-football-tournament) 🔒 | [MySQL](problems/team-scores-in-football-tournament) | Medium | +| 1211 | [Queries Quality and Percentage](https://leetcode.com/problems/queries-quality-and-percentage) 🔒 | [MySQL](problems/queries-quality-and-percentage) | Easy | +| 1210 | [Minimum Moves to Reach Target with Rotations](https://leetcode.com/problems/minimum-moves-to-reach-target-with-rotations "穿过迷宫的最少移动次数") | [Go](problems/minimum-moves-to-reach-target-with-rotations) | Hard | +| 1209 | [Remove All Adjacent Duplicates in String II](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii "删除字符串中的所有相邻重复项 II") | [Go](problems/remove-all-adjacent-duplicates-in-string-ii) | Medium | +| 1208 | [Get Equal Substrings Within Budget](https://leetcode.com/problems/get-equal-substrings-within-budget "尽可能使字符串相等") | [Go](problems/get-equal-substrings-within-budget) | Medium | +| 1207 | [Unique Number of Occurrences](https://leetcode.com/problems/unique-number-of-occurrences "独一无二的出现次数") | [Go](problems/unique-number-of-occurrences) | Easy | +| 1206 | [Design Skiplist](https://leetcode.com/problems/design-skiplist "设计跳表") | [Go](problems/design-skiplist) | Hard | +| 1205 | [Monthly Transactions II](https://leetcode.com/problems/monthly-transactions-ii "每月交易II") 🔒 | [MySQL](problems/monthly-transactions-ii) | Medium | +| 1204 | [Last Person to Fit in the Elevator](https://leetcode.com/problems/last-person-to-fit-in-the-elevator) 🔒 | [MySQL](problems/last-person-to-fit-in-the-elevator) | Medium | +| 1203 | [Sort Items by Groups Respecting Dependencies](https://leetcode.com/problems/sort-items-by-groups-respecting-dependencies "项目管理") | [Go](problems/sort-items-by-groups-respecting-dependencies) | Hard | +| 1202 | [Smallest String With Swaps](https://leetcode.com/problems/smallest-string-with-swaps "交换字符串中的元素") | [Go](problems/smallest-string-with-swaps) | Medium | +| 1201 | [Ugly Number III](https://leetcode.com/problems/ugly-number-iii "丑数 III") | [Go](problems/ugly-number-iii) | Medium | +| 1200 | [Minimum Absolute Difference](https://leetcode.com/problems/minimum-absolute-difference "最小绝对差") | [Go](problems/minimum-absolute-difference) | Easy | +| 1199 | [Minimum Time to Build Blocks](https://leetcode.com/problems/minimum-time-to-build-blocks "建造街区的最短时间") 🔒 | [Go](problems/minimum-time-to-build-blocks) | Hard | +| 1198 | [Find Smallest Common Element in All Rows](https://leetcode.com/problems/find-smallest-common-element-in-all-rows "找出所有行中最小公共元素") 🔒 | [Go](problems/find-smallest-common-element-in-all-rows) | Medium | +| 1197 | [Minimum Knight Moves](https://leetcode.com/problems/minimum-knight-moves "进击的骑士") 🔒 | [Go](problems/minimum-knight-moves) | Medium | +| 1196 | [How Many Apples Can You Put into the Basket](https://leetcode.com/problems/how-many-apples-can-you-put-into-the-basket "最多可以买到的苹果数量") 🔒 | [Go](problems/how-many-apples-can-you-put-into-the-basket) | Easy | +| 1195 | [Fizz Buzz Multithreaded](https://leetcode.com/problems/fizz-buzz-multithreaded "交替打印字符串") | [Go](problems/fizz-buzz-multithreaded) | Medium | +| 1194 | [Tournament Winners](https://leetcode.com/problems/tournament-winners "锦标赛优胜者") 🔒 | [MySQL](problems/tournament-winners) | Hard | +| 1193 | [Monthly Transactions I](https://leetcode.com/problems/monthly-transactions-i "每月交易 I") 🔒 | [MySQL](problems/monthly-transactions-i) | Medium | +| 1192 | [Critical Connections in a Network](https://leetcode.com/problems/critical-connections-in-a-network "查找集群内的「关键连接」") | [Go](problems/critical-connections-in-a-network) | Hard | +| 1191 | [K-Concatenation Maximum Sum](https://leetcode.com/problems/k-concatenation-maximum-sum "K 次串联后最大子数组之和") | [Go](problems/k-concatenation-maximum-sum) | Medium | +| 1190 | [Reverse Substrings Between Each Pair of Parentheses](https://leetcode.com/problems/reverse-substrings-between-each-pair-of-parentheses "反转每对括号间的子串") | [Go](problems/reverse-substrings-between-each-pair-of-parentheses) | Medium | +| 1189 | [Maximum Number of Balloons](https://leetcode.com/problems/maximum-number-of-balloons "“气球” 的最大数量") | [Go](problems/maximum-number-of-balloons) | Easy | +| 1188 | [Design Bounded Blocking Queue](https://leetcode.com/problems/design-bounded-blocking-queue "设计有限阻塞队列") 🔒 | [Go](problems/design-bounded-blocking-queue) | Medium | +| 1187 | [Make Array Strictly Increasing](https://leetcode.com/problems/make-array-strictly-increasing "使数组严格递增") | [Go](problems/make-array-strictly-increasing) | Hard | +| 1186 | [Maximum Subarray Sum with One Deletion](https://leetcode.com/problems/maximum-subarray-sum-with-one-deletion "删除一次得到子数组最大和") | [Go](problems/maximum-subarray-sum-with-one-deletion) | Medium | +| 1185 | [Day of the Week](https://leetcode.com/problems/day-of-the-week "一周中的第几天") | [Go](problems/day-of-the-week) | Easy | +| 1184 | [Distance Between Bus Stops](https://leetcode.com/problems/distance-between-bus-stops "公交站间的距离") | [Go](problems/distance-between-bus-stops) | Easy | +| 1183 | [Maximum Number of Ones](https://leetcode.com/problems/maximum-number-of-ones "矩阵中 1 的最大数量") 🔒 | [Go](problems/maximum-number-of-ones) | Hard | +| 1182 | [Shortest Distance to Target Color](https://leetcode.com/problems/shortest-distance-to-target-color "与目标颜色间的最短距离") 🔒 | [Go](problems/shortest-distance-to-target-color) | Medium | +| 1181 | [Before and After Puzzle](https://leetcode.com/problems/before-and-after-puzzle "前后拼接") 🔒 | [Go](problems/before-and-after-puzzle) | Medium | +| 1180 | [Count Substrings with Only One Distinct Letter](https://leetcode.com/problems/count-substrings-with-only-one-distinct-letter "统计只含单一字母的子串") 🔒 | [Go](problems/count-substrings-with-only-one-distinct-letter) | Easy | +| 1179 | [Reformat Department Table](https://leetcode.com/problems/reformat-department-table "重新格式化部门表") | [MySQL](problems/reformat-department-table) | Easy | +| 1178 | [Number of Valid Words for Each Puzzle](https://leetcode.com/problems/number-of-valid-words-for-each-puzzle "猜字谜") | [Go](problems/number-of-valid-words-for-each-puzzle) | Hard | +| 1177 | [Can Make Palindrome from Substring](https://leetcode.com/problems/can-make-palindrome-from-substring "构建回文串检测") | [Go](problems/can-make-palindrome-from-substring) | Medium | +| 1176 | [Diet Plan Performance](https://leetcode.com/problems/diet-plan-performance "健身计划评估") 🔒 | [Go](problems/diet-plan-performance) | Easy | +| 1175 | [Prime Arrangements](https://leetcode.com/problems/prime-arrangements "质数排列") | [Go](problems/prime-arrangements) | Easy | +| 1174 | [Immediate Food Delivery II](https://leetcode.com/problems/immediate-food-delivery-ii) 🔒 | [MySQL](problems/immediate-food-delivery-ii) | Medium | +| 1173 | [Immediate Food Delivery I](https://leetcode.com/problems/immediate-food-delivery-i) 🔒 | [MySQL](problems/immediate-food-delivery-i) | Easy | +| 1172 | [Dinner Plate Stacks](https://leetcode.com/problems/dinner-plate-stacks "餐盘栈") | [Go](problems/dinner-plate-stacks) | Hard | +| 1171 | [Remove Zero Sum Consecutive Nodes from Linked List](https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list "从链表中删去总和值为零的连续节点") | [Go](problems/remove-zero-sum-consecutive-nodes-from-linked-list) | Medium | +| 1170 | [Compare Strings by Frequency of the Smallest Character](https://leetcode.com/problems/compare-strings-by-frequency-of-the-smallest-character "比较字符串最小字母出现频次") | [Go](problems/compare-strings-by-frequency-of-the-smallest-character) | Easy | +| 1169 | [Invalid Transactions](https://leetcode.com/problems/invalid-transactions "查询无效交易") | [Go](problems/invalid-transactions) | Medium | +| 1168 | [Optimize Water Distribution in a Village](https://leetcode.com/problems/optimize-water-distribution-in-a-village "水资源分配优化") 🔒 | [Go](problems/optimize-water-distribution-in-a-village) | Hard | +| 1167 | [Minimum Cost to Connect Sticks](https://leetcode.com/problems/minimum-cost-to-connect-sticks "连接棒材的最低费用") 🔒 | [Go](problems/minimum-cost-to-connect-sticks) | Medium | +| 1166 | [Design File System](https://leetcode.com/problems/design-file-system "设计文件系统") 🔒 | [Go](problems/design-file-system) | Medium | +| 1165 | [Single-Row Keyboard](https://leetcode.com/problems/single-row-keyboard "单行键盘") 🔒 | [Go](problems/single-row-keyboard) | Easy | +| 1164 | [Product Price at a Given Date](https://leetcode.com/problems/product-price-at-a-given-date) 🔒 | [MySQL](problems/product-price-at-a-given-date) | Medium | +| 1163 | [Last Substring in Lexicographical Order](https://leetcode.com/problems/last-substring-in-lexicographical-order "按字典序排在最后的子串") | [Go](problems/last-substring-in-lexicographical-order) | Hard | +| 1162 | [As Far from Land as Possible](https://leetcode.com/problems/as-far-from-land-as-possible "地图分析") | [Go](problems/as-far-from-land-as-possible) | Medium | +| 1161 | [Maximum Level Sum of a Binary Tree](https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree "最大层内元素和") | [Go](problems/maximum-level-sum-of-a-binary-tree) | Medium | +| 1160 | [Find Words That Can Be Formed by Characters](https://leetcode.com/problems/find-words-that-can-be-formed-by-characters "拼写单词") | [Go](problems/find-words-that-can-be-formed-by-characters) | Easy | +| 1159 | [Market Analysis II](https://leetcode.com/problems/market-analysis-ii) 🔒 | [MySQL](problems/market-analysis-ii) | Hard | +| 1158 | [Market Analysis I](https://leetcode.com/problems/market-analysis-i) 🔒 | [MySQL](problems/market-analysis-i) | Medium | +| 1157 | [Online Majority Element In Subarray](https://leetcode.com/problems/online-majority-element-in-subarray "子数组中占绝大多数的元素") | [Go](problems/online-majority-element-in-subarray) | Hard | +| 1156 | [Swap For Longest Repeated Character Substring](https://leetcode.com/problems/swap-for-longest-repeated-character-substring "单字符重复子串的最大长度") | [Go](problems/swap-for-longest-repeated-character-substring) | Medium | +| 1155 | [Number of Dice Rolls With Target Sum](https://leetcode.com/problems/number-of-dice-rolls-with-target-sum "掷骰子的N种方法") | [Go](problems/number-of-dice-rolls-with-target-sum) | Medium | +| 1154 | [Day of the Year](https://leetcode.com/problems/day-of-the-year "一年中的第几天") | [Go](problems/day-of-the-year) | Easy | +| 1153 | [String Transforms Into Another String](https://leetcode.com/problems/string-transforms-into-another-string "字符串转化") 🔒 | [Go](problems/string-transforms-into-another-string) | Hard | +| 1152 | [Analyze User Website Visit Pattern](https://leetcode.com/problems/analyze-user-website-visit-pattern "用户网站访问行为分析") 🔒 | [Go](problems/analyze-user-website-visit-pattern) | Medium | +| 1151 | [Minimum Swaps to Group All 1's Together](https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together "最少交换次数来组合所有的 1") 🔒 | [Go](problems/minimum-swaps-to-group-all-1s-together) | Medium | +| 1150 | [Check If a Number Is Majority Element in a Sorted Array](https://leetcode.com/problems/check-if-a-number-is-majority-element-in-a-sorted-array "检查一个数是否在数组中占绝大多数") 🔒 | [Go](problems/check-if-a-number-is-majority-element-in-a-sorted-array) | Easy | +| 1149 | [Article Views II](https://leetcode.com/problems/article-views-ii) 🔒 | [MySQL](problems/article-views-ii) | Medium | +| 1148 | [Article Views I](https://leetcode.com/problems/article-views-i "文章浏览 I") 🔒 | [MySQL](problems/article-views-i) | Easy | +| 1147 | [Longest Chunked Palindrome Decomposition](https://leetcode.com/problems/longest-chunked-palindrome-decomposition "段式回文") | [Go](problems/longest-chunked-palindrome-decomposition) | Hard | +| 1146 | [Snapshot Array](https://leetcode.com/problems/snapshot-array "快照数组") | [Go](problems/snapshot-array) | Medium | +| 1145 | [Binary Tree Coloring Game](https://leetcode.com/problems/binary-tree-coloring-game "二叉树着色游戏") | [Go](problems/binary-tree-coloring-game) | Medium | +| 1144 | [Decrease Elements To Make Array Zigzag](https://leetcode.com/problems/decrease-elements-to-make-array-zigzag "递减元素使数组呈锯齿状") | [Go](problems/decrease-elements-to-make-array-zigzag) | Medium | +| 1143 | [Longest Common Subsequence](https://leetcode.com/problems/longest-common-subsequence "最长公共子序列") | [Go](problems/longest-common-subsequence) | Medium | +| 1142 | [User Activity for the Past 30 Days II](https://leetcode.com/problems/user-activity-for-the-past-30-days-ii "过去30天的用户活动 II") 🔒 | [MySQL](problems/user-activity-for-the-past-30-days-ii) | Easy | +| 1141 | [User Activity for the Past 30 Days I](https://leetcode.com/problems/user-activity-for-the-past-30-days-i) 🔒 | [MySQL](problems/user-activity-for-the-past-30-days-i) | Easy | +| 1140 | [Stone Game II](https://leetcode.com/problems/stone-game-ii "石子游戏 II") | [Go](problems/stone-game-ii) | Medium | +| 1139 | [Largest 1-Bordered Square](https://leetcode.com/problems/largest-1-bordered-square "最大的以 1 为边界的正方形") | [Go](problems/largest-1-bordered-square) | Medium | +| 1138 | [Alphabet Board Path](https://leetcode.com/problems/alphabet-board-path "字母板上的路径") | [Go](problems/alphabet-board-path) | Medium | +| 1137 | [N-th Tribonacci Number](https://leetcode.com/problems/n-th-tribonacci-number "第 N 个泰波那契数") | [Go](problems/n-th-tribonacci-number) | Easy | +| 1136 | [Parallel Courses](https://leetcode.com/problems/parallel-courses "平行课程") 🔒 | [Go](problems/parallel-courses) | Hard | +| 1135 | [Connecting Cities With Minimum Cost](https://leetcode.com/problems/connecting-cities-with-minimum-cost "最低成本联通所有城市") 🔒 | [Go](problems/connecting-cities-with-minimum-cost) | Medium | +| 1134 | [Armstrong Number](https://leetcode.com/problems/armstrong-number "阿姆斯特朗数") 🔒 | [Go](problems/armstrong-number) | Easy | +| 1133 | [Largest Unique Number](https://leetcode.com/problems/largest-unique-number "最大唯一数") 🔒 | [Go](problems/largest-unique-number) | Easy | +| 1132 | [Reported Posts II](https://leetcode.com/problems/reported-posts-ii) 🔒 | [MySQL](problems/reported-posts-ii) | Medium | +| 1131 | [Maximum of Absolute Value Expression](https://leetcode.com/problems/maximum-of-absolute-value-expression "绝对值表达式的最大值") | [Go](problems/maximum-of-absolute-value-expression) | Medium | +| 1130 | [Minimum Cost Tree From Leaf Values](https://leetcode.com/problems/minimum-cost-tree-from-leaf-values "叶值的最小代价生成树") | [Go](problems/minimum-cost-tree-from-leaf-values) | Medium | +| 1129 | [Shortest Path with Alternating Colors](https://leetcode.com/problems/shortest-path-with-alternating-colors "颜色交替的最短路径") | [Go](problems/shortest-path-with-alternating-colors) | Medium | +| 1128 | [Number of Equivalent Domino Pairs](https://leetcode.com/problems/number-of-equivalent-domino-pairs "等价多米诺骨牌对的数量") | [Go](problems/number-of-equivalent-domino-pairs) | Easy | +| 1127 | [User Purchase Platform](https://leetcode.com/problems/user-purchase-platform) 🔒 | [MySQL](problems/user-purchase-platform) | Hard | +| 1126 | [Active Businesses](https://leetcode.com/problems/active-businesses) 🔒 | [MySQL](problems/active-businesses) | Medium | +| 1125 | [Smallest Sufficient Team](https://leetcode.com/problems/smallest-sufficient-team "最小的必要团队") | [Go](problems/smallest-sufficient-team) | Hard | +| 1124 | [Longest Well-Performing Interval](https://leetcode.com/problems/longest-well-performing-interval "表现良好的最长时间段") | [Go](problems/longest-well-performing-interval) | Medium | +| 1123 | [Lowest Common Ancestor of Deepest Leaves](https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves "最深叶节点的最近公共祖先") | [Go](problems/lowest-common-ancestor-of-deepest-leaves) | Medium | +| 1122 | [Relative Sort Array](https://leetcode.com/problems/relative-sort-array "数组的相对排序") | [Go](problems/relative-sort-array) | Easy | +| 1121 | [Divide Array Into Increasing Sequences](https://leetcode.com/problems/divide-array-into-increasing-sequences "将数组分成几个递增序列") 🔒 | [Go](problems/divide-array-into-increasing-sequences) | Hard | +| 1120 | [Maximum Average Subtree](https://leetcode.com/problems/maximum-average-subtree "子树的最大平均值") 🔒 | [Go](problems/maximum-average-subtree) | Medium | +| 1119 | [Remove Vowels from a String](https://leetcode.com/problems/remove-vowels-from-a-string "删去字符串中的元音") 🔒 | [Go](problems/remove-vowels-from-a-string) | Easy | +| 1118 | [Number of Days in a Month](https://leetcode.com/problems/number-of-days-in-a-month "一月有多少天") 🔒 | [Go](problems/number-of-days-in-a-month) | Easy | +| 1117 | [Building H2O](https://leetcode.com/problems/building-h2o "H2O 生成") | [Go](problems/building-h2o) | Medium | +| 1116 | [Print Zero Even Odd](https://leetcode.com/problems/print-zero-even-odd "打印零与奇偶数") | [Go](problems/print-zero-even-odd) | Medium | +| 1115 | [Print FooBar Alternately](https://leetcode.com/problems/print-foobar-alternately "交替打印FooBar") | [Go](problems/print-foobar-alternately) | Medium | +| 1114 | [Print in Order](https://leetcode.com/problems/print-in-order "按序打印") | [Go](problems/print-in-order) | Easy | +| 1113 | [Reported Posts](https://leetcode.com/problems/reported-posts) 🔒 | [MySQL](problems/reported-posts) | Easy | +| 1112 | [Highest Grade For Each Student](https://leetcode.com/problems/highest-grade-for-each-student "每位学生的最高成绩") 🔒 | [MySQL](problems/highest-grade-for-each-student) | Medium | +| 1111 | [Maximum Nesting Depth of Two Valid Parentheses Strings](https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings "有效括号的嵌套深度") | [Go](problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | Medium | +| 1110 | [Delete Nodes And Return Forest](https://leetcode.com/problems/delete-nodes-and-return-forest "删点成林") | [Go](problems/delete-nodes-and-return-forest) | Medium | +| 1109 | [Corporate Flight Bookings](https://leetcode.com/problems/corporate-flight-bookings "航班预订统计") | [Go](problems/corporate-flight-bookings) | Medium | +| 1108 | [Defanging an IP Address](https://leetcode.com/problems/defanging-an-ip-address "IP 地址无效化") | [Go](problems/defanging-an-ip-address) | Easy | +| 1107 | [New Users Daily Count](https://leetcode.com/problems/new-users-daily-count "每日新用户统计") 🔒 | [MySQL](problems/new-users-daily-count) | Medium | +| 1106 | [Parsing A Boolean Expression](https://leetcode.com/problems/parsing-a-boolean-expression "解析布尔表达式") | [Go](problems/parsing-a-boolean-expression) | Hard | +| 1105 | [Filling Bookcase Shelves](https://leetcode.com/problems/filling-bookcase-shelves "填充书架") | [Go](problems/filling-bookcase-shelves) | Medium | +| 1104 | [Path In Zigzag Labelled Binary Tree](https://leetcode.com/problems/path-in-zigzag-labelled-binary-tree "二叉树寻路") | [Go](problems/path-in-zigzag-labelled-binary-tree) | Medium | +| 1103 | [Distribute Candies to People](https://leetcode.com/problems/distribute-candies-to-people "分糖果 II") | [Go](problems/distribute-candies-to-people) | Easy | +| 1102 | [Path With Maximum Minimum Value](https://leetcode.com/problems/path-with-maximum-minimum-value "得分最高的路径") 🔒 | [Go](problems/path-with-maximum-minimum-value) | Medium | +| 1101 | [The Earliest Moment When Everyone Become Friends](https://leetcode.com/problems/the-earliest-moment-when-everyone-become-friends "彼此熟识的最早时间") 🔒 | [Go](problems/the-earliest-moment-when-everyone-become-friends) | Medium | +| 1100 | [Find K-Length Substrings With No Repeated Characters](https://leetcode.com/problems/find-k-length-substrings-with-no-repeated-characters "长度为 K 的无重复字符子串") 🔒 | [Go](problems/find-k-length-substrings-with-no-repeated-characters) | Medium | +| 1099 | [Two Sum Less Than K](https://leetcode.com/problems/two-sum-less-than-k "小于 K 的两数之和") 🔒 | [Go](problems/two-sum-less-than-k) | Easy | +| 1098 | [Unpopular Books](https://leetcode.com/problems/unpopular-books "小众书籍") 🔒 | [MySQL](problems/unpopular-books) | Medium | +| 1097 | [Game Play Analysis V](https://leetcode.com/problems/game-play-analysis-v "游戏玩法分析 V") 🔒 | [MySQL](problems/game-play-analysis-v) | Hard | +| 1096 | [Brace Expansion II](https://leetcode.com/problems/brace-expansion-ii "花括号展开 II") | [Go](problems/brace-expansion-ii) | Hard | +| 1095 | [Find in Mountain Array](https://leetcode.com/problems/find-in-mountain-array "山脉数组中查找目标值") | [Go](problems/find-in-mountain-array) | Hard | +| 1094 | [Car Pooling](https://leetcode.com/problems/car-pooling "拼车") | [Go](problems/car-pooling) | Medium | +| 1093 | [Statistics from a Large Sample](https://leetcode.com/problems/statistics-from-a-large-sample "大样本统计") | [Go](problems/statistics-from-a-large-sample) | Medium | +| 1092 | [Shortest Common Supersequence](https://leetcode.com/problems/shortest-common-supersequence "最短公共超序列") | [Go](problems/shortest-common-supersequence) | Hard | +| 1091 | [Shortest Path in Binary Matrix](https://leetcode.com/problems/shortest-path-in-binary-matrix "二进制矩阵中的最短路径") | [Go](problems/shortest-path-in-binary-matrix) | Medium | +| 1090 | [Largest Values From Labels](https://leetcode.com/problems/largest-values-from-labels "受标签影响的最大值") | [Go](problems/largest-values-from-labels) | Medium | +| 1089 | [Duplicate Zeros](https://leetcode.com/problems/duplicate-zeros "复写零") | [Go](problems/duplicate-zeros) | Easy | +| 1088 | [Confusing Number II](https://leetcode.com/problems/confusing-number-ii "易混淆数 II") 🔒 | [Go](problems/confusing-number-ii) | Hard | +| 1087 | [Brace Expansion](https://leetcode.com/problems/brace-expansion "字母切换") 🔒 | [Go](problems/brace-expansion) | Medium | +| 1086 | [High Five](https://leetcode.com/problems/high-five "前五科的均分") 🔒 | [Go](problems/high-five) | Easy | +| 1085 | [Sum of Digits in the Minimum Number](https://leetcode.com/problems/sum-of-digits-in-the-minimum-number "最小元素各数位之和") 🔒 | [Go](problems/sum-of-digits-in-the-minimum-number) | Easy | +| 1084 | [Sales Analysis III](https://leetcode.com/problems/sales-analysis-iii "销售分析III") 🔒 | [MySQL](problems/sales-analysis-iii) | Easy | +| 1083 | [Sales Analysis II](https://leetcode.com/problems/sales-analysis-ii "销售分析 II") 🔒 | [MySQL](problems/sales-analysis-ii) | Easy | +| 1082 | [Sales Analysis I](https://leetcode.com/problems/sales-analysis-i "销售分析 I ") 🔒 | [MySQL](problems/sales-analysis-i) | Easy | +| 1081 | [Smallest Subsequence of Distinct Characters](https://leetcode.com/problems/smallest-subsequence-of-distinct-characters "不同字符的最小子序列") | [Go](problems/smallest-subsequence-of-distinct-characters) | Medium | +| 1080 | [Insufficient Nodes in Root to Leaf Paths](https://leetcode.com/problems/insufficient-nodes-in-root-to-leaf-paths "根到叶路径上的不足节点") | [Go](problems/insufficient-nodes-in-root-to-leaf-paths) | Medium | +| 1079 | [Letter Tile Possibilities](https://leetcode.com/problems/letter-tile-possibilities "活字印刷") | [Go](problems/letter-tile-possibilities) | Medium | +| 1078 | [Occurrences After Bigram](https://leetcode.com/problems/occurrences-after-bigram "Bigram 分词") | [Go](problems/occurrences-after-bigram) | Easy | +| 1077 | [Project Employees III](https://leetcode.com/problems/project-employees-iii "项目员工 III") 🔒 | [MySQL](problems/project-employees-iii) | Medium | +| 1076 | [Project Employees II](https://leetcode.com/problems/project-employees-ii "项目员工II") 🔒 | [MySQL](problems/project-employees-ii) | Easy | +| 1075 | [Project Employees I](https://leetcode.com/problems/project-employees-i "项目员工 I") 🔒 | [MySQL](problems/project-employees-i) | Easy | +| 1074 | [Number of Submatrices That Sum to Target](https://leetcode.com/problems/number-of-submatrices-that-sum-to-target "元素和为目标值的子矩阵数量") | [Go](problems/number-of-submatrices-that-sum-to-target) | Hard | +| 1073 | [Adding Two Negabinary Numbers](https://leetcode.com/problems/adding-two-negabinary-numbers "负二进制数相加") | [Go](problems/adding-two-negabinary-numbers) | Medium | +| 1072 | [Flip Columns For Maximum Number of Equal Rows](https://leetcode.com/problems/flip-columns-for-maximum-number-of-equal-rows "按列翻转得到最大值等行数") | [Go](problems/flip-columns-for-maximum-number-of-equal-rows) | Medium | +| 1071 | [Greatest Common Divisor of Strings](https://leetcode.com/problems/greatest-common-divisor-of-strings "字符串的最大公因子") | [Go](problems/greatest-common-divisor-of-strings) | Easy | +| 1070 | [Product Sales Analysis III](https://leetcode.com/problems/product-sales-analysis-iii "产品销售分析 III") 🔒 | [MySQL](problems/product-sales-analysis-iii) | Medium | +| 1069 | [Product Sales Analysis II](https://leetcode.com/problems/product-sales-analysis-ii "产品销售分析 II") 🔒 | [MySQL](problems/product-sales-analysis-ii) | Easy | +| 1068 | [Product Sales Analysis I](https://leetcode.com/problems/product-sales-analysis-i "产品销售分析 I") 🔒 | [MySQL](problems/product-sales-analysis-i) | Easy | +| 1067 | [Digit Count in Range](https://leetcode.com/problems/digit-count-in-range "范围内的数字计数") 🔒 | [Go](problems/digit-count-in-range) | Hard | +| 1066 | [Campus Bikes II](https://leetcode.com/problems/campus-bikes-ii "校园自行车分配 II") 🔒 | [Go](problems/campus-bikes-ii) | Medium | +| 1065 | [Index Pairs of a String](https://leetcode.com/problems/index-pairs-of-a-string "字符串的索引对") 🔒 | [Go](problems/index-pairs-of-a-string) | Easy | +| 1064 | [Fixed Point](https://leetcode.com/problems/fixed-point "不动点") 🔒 | [Go](problems/fixed-point) | Easy | +| 1063 | [Number of Valid Subarrays](https://leetcode.com/problems/number-of-valid-subarrays "有效子数组的数目") 🔒 | [Go](problems/number-of-valid-subarrays) | Hard | +| 1062 | [Longest Repeating Substring](https://leetcode.com/problems/longest-repeating-substring "最长重复子串") 🔒 | [Go](problems/longest-repeating-substring) | Medium | +| 1061 | [Lexicographically Smallest Equivalent String](https://leetcode.com/problems/lexicographically-smallest-equivalent-string "按字典序排列最小的等效字符串") 🔒 | [Go](problems/lexicographically-smallest-equivalent-string) | Medium | +| 1060 | [Missing Element in Sorted Array](https://leetcode.com/problems/missing-element-in-sorted-array "有序数组中的缺失元素") 🔒 | [Go](problems/missing-element-in-sorted-array) | Medium | +| 1059 | [All Paths from Source Lead to Destination](https://leetcode.com/problems/all-paths-from-source-lead-to-destination "从始点到终点的所有路径") 🔒 | [Go](problems/all-paths-from-source-lead-to-destination) | Medium | +| 1058 | [Minimize Rounding Error to Meet Target](https://leetcode.com/problems/minimize-rounding-error-to-meet-target "最小化舍入误差以满足目标") 🔒 | [Go](problems/minimize-rounding-error-to-meet-target) | Medium | +| 1057 | [Campus Bikes](https://leetcode.com/problems/campus-bikes "校园自行车分配") 🔒 | [Go](problems/campus-bikes) | Medium | +| 1056 | [Confusing Number](https://leetcode.com/problems/confusing-number "易混淆数") 🔒 | [Go](problems/confusing-number) | Easy | +| 1055 | [Shortest Way to Form String](https://leetcode.com/problems/shortest-way-to-form-string "形成字符串的最短路径") 🔒 | [Go](problems/shortest-way-to-form-string) | Medium | +| 1054 | [Distant Barcodes](https://leetcode.com/problems/distant-barcodes "距离相等的条形码") | [Go](problems/distant-barcodes) | Medium | +| 1053 | [Previous Permutation With One Swap](https://leetcode.com/problems/previous-permutation-with-one-swap "交换一次的先前排列") | [Go](problems/previous-permutation-with-one-swap) | Medium | +| 1052 | [Grumpy Bookstore Owner](https://leetcode.com/problems/grumpy-bookstore-owner "爱生气的书店老板") | [Go](problems/grumpy-bookstore-owner) | Medium | +| 1051 | [Height Checker](https://leetcode.com/problems/height-checker "高度检查器") | [Go](problems/height-checker) | Easy | +| 1050 | [Actors and Directors Who Cooperated At Least Three Times](https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times "合作过至少三次的演员和导演") 🔒 | [MySQL](problems/actors-and-directors-who-cooperated-at-least-three-times) | Easy | +| 1049 | [Last Stone Weight II](https://leetcode.com/problems/last-stone-weight-ii "最后一块石头的重量 II") | [Go](problems/last-stone-weight-ii) | Medium | +| 1048 | [Longest String Chain](https://leetcode.com/problems/longest-string-chain "最长字符串链") | [Go](problems/longest-string-chain) | Medium | +| 1047 | [Remove All Adjacent Duplicates In String](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string "删除字符串中的所有相邻重复项") | [Go](problems/remove-all-adjacent-duplicates-in-string) | Easy | +| 1046 | [Last Stone Weight](https://leetcode.com/problems/last-stone-weight "最后一块石头的重量") | [Go](problems/last-stone-weight) | Easy | +| 1045 | [Customers Who Bought All Products](https://leetcode.com/problems/customers-who-bought-all-products "买下所有产品的客户") 🔒 | [MySQL](problems/customers-who-bought-all-products) | Medium | +| 1044 | [Longest Duplicate Substring](https://leetcode.com/problems/longest-duplicate-substring "最长重复子串") | [Go](problems/longest-duplicate-substring) | Hard | +| 1043 | [Partition Array for Maximum Sum](https://leetcode.com/problems/partition-array-for-maximum-sum "分隔数组以得到最大和") | [Go](problems/partition-array-for-maximum-sum) | Medium | +| 1042 | [Flower Planting With No Adjacent](https://leetcode.com/problems/flower-planting-with-no-adjacent "不邻接植花") | [Go](problems/flower-planting-with-no-adjacent) | Easy | +| 1041 | [Robot Bounded In Circle](https://leetcode.com/problems/robot-bounded-in-circle "困于环中的机器人") | [Go](problems/robot-bounded-in-circle) | Medium | +| 1040 | [Moving Stones Until Consecutive II](https://leetcode.com/problems/moving-stones-until-consecutive-ii "移动石子直到连续 II") | [Go](problems/moving-stones-until-consecutive-ii) | Medium | +| 1039 | [Minimum Score Triangulation of Polygon](https://leetcode.com/problems/minimum-score-triangulation-of-polygon "多边形三角剖分的最低得分") | [Go](problems/minimum-score-triangulation-of-polygon) | Medium | +| 1038 | [Binary Search Tree to Greater Sum Tree](https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree "从二叉搜索树到更大和树") | [Go](problems/binary-search-tree-to-greater-sum-tree) | Medium | +| 1037 | [Valid Boomerang](https://leetcode.com/problems/valid-boomerang "有效的回旋镖") | [Go](problems/valid-boomerang) | Easy | +| 1036 | [Escape a Large Maze](https://leetcode.com/problems/escape-a-large-maze "逃离大迷宫") | [Go](problems/escape-a-large-maze) | Hard | +| 1035 | [Uncrossed Lines](https://leetcode.com/problems/uncrossed-lines "不相交的线") | [Go](problems/uncrossed-lines) | Medium | +| 1034 | [Coloring A Border](https://leetcode.com/problems/coloring-a-border "边框着色") | [Go](problems/coloring-a-border) | Medium | +| 1033 | [Moving Stones Until Consecutive](https://leetcode.com/problems/moving-stones-until-consecutive "移动石子直到连续") | [Go](problems/moving-stones-until-consecutive) | Easy | +| 1032 | [Stream of Characters](https://leetcode.com/problems/stream-of-characters "字符流") | [Go](problems/stream-of-characters) | Hard | +| 1031 | [Maximum Sum of Two Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays "两个非重叠子数组的最大和") | [Go](problems/maximum-sum-of-two-non-overlapping-subarrays) | Medium | +| 1030 | [Matrix Cells in Distance Order](https://leetcode.com/problems/matrix-cells-in-distance-order "距离顺序排列矩阵单元格") | [Go](problems/matrix-cells-in-distance-order) | Easy | +| 1029 | [Two City Scheduling](https://leetcode.com/problems/two-city-scheduling "两地调度") | [Go](problems/two-city-scheduling) | Easy | +| 1028 | [Recover a Tree From Preorder Traversal](https://leetcode.com/problems/recover-a-tree-from-preorder-traversal "从先序遍历还原二叉树") | [Go](problems/recover-a-tree-from-preorder-traversal) | Hard | +| 1027 | [Longest Arithmetic Sequence](https://leetcode.com/problems/longest-arithmetic-sequence "最长等差数列") | [Go](problems/longest-arithmetic-sequence) | Medium | +| 1026 | [Maximum Difference Between Node and Ancestor](https://leetcode.com/problems/maximum-difference-between-node-and-ancestor "节点与其祖先之间的最大差值") | [Go](problems/maximum-difference-between-node-and-ancestor) | Medium | +| 1025 | [Divisor Game](https://leetcode.com/problems/divisor-game "除数博弈") | [Go](problems/divisor-game) | Easy | +| 1024 | [Video Stitching](https://leetcode.com/problems/video-stitching "视频拼接") | [Go](problems/video-stitching) | Medium | +| 1023 | [Camelcase Matching](https://leetcode.com/problems/camelcase-matching "驼峰式匹配") | [Go](problems/camelcase-matching) | Medium | +| 1022 | [Sum of Root To Leaf Binary Numbers](https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers "从根到叶的二进制数之和") | [Go](problems/sum-of-root-to-leaf-binary-numbers) | Easy | +| 1021 | [Remove Outermost Parentheses](https://leetcode.com/problems/remove-outermost-parentheses "删除最外层的括号") | [Go](problems/remove-outermost-parentheses) | Easy | +| 1020 | [Number of Enclaves](https://leetcode.com/problems/number-of-enclaves "飞地的数量") | [Go](problems/number-of-enclaves) | Medium | +| 1019 | [Next Greater Node In Linked List](https://leetcode.com/problems/next-greater-node-in-linked-list "链表中的下一个更大节点") | [Go](problems/next-greater-node-in-linked-list) | Medium | +| 1018 | [Binary Prefix Divisible By 5](https://leetcode.com/problems/binary-prefix-divisible-by-5 "可被 5 整除的二进制前缀") | [Go](problems/binary-prefix-divisible-by-5) | Easy | +| 1017 | [Convert to Base -2](https://leetcode.com/problems/convert-to-base-2 "负二进制转换") | [Go](problems/convert-to-base-2) | Medium | +| 1016 | [Binary String With Substrings Representing 1 To N](https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n "子串能表示从 1 到 N 数字的二进制串") | [Go](problems/binary-string-with-substrings-representing-1-to-n) | Medium | +| 1015 | [Smallest Integer Divisible by K](https://leetcode.com/problems/smallest-integer-divisible-by-k "可被 K 整除的最小整数") | [Go](problems/smallest-integer-divisible-by-k) | Medium | +| 1014 | [Best Sightseeing Pair](https://leetcode.com/problems/best-sightseeing-pair "最佳观光组合") | [Go](problems/best-sightseeing-pair) | Medium | +| 1013 | [Partition Array Into Three Parts With Equal Sum](https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum "将数组分成和相等的三个部分") | [Go](problems/partition-array-into-three-parts-with-equal-sum) | Easy | +| 1012 | [Numbers With Repeated Digits](https://leetcode.com/problems/numbers-with-repeated-digits "至少有 1 位重复的数字") | [Go](problems/numbers-with-repeated-digits) | Hard | +| 1011 | [Capacity To Ship Packages Within D Days](https://leetcode.com/problems/capacity-to-ship-packages-within-d-days "在 D 天内送达包裹的能力") | [Go](problems/capacity-to-ship-packages-within-d-days) | Medium | +| 1010 | [Pairs of Songs With Total Durations Divisible by 60](https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60 "总持续时间可被 60 整除的歌曲") | [Go](problems/pairs-of-songs-with-total-durations-divisible-by-60) | Easy | +| 1009 | [Complement of Base 10 Integer](https://leetcode.com/problems/complement-of-base-10-integer "十进制整数的反码") | [Go](problems/complement-of-base-10-integer) | Easy | +| 1008 | [Construct Binary Search Tree from Preorder Traversal](https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal "先序遍历构造二叉树") | [Go](problems/construct-binary-search-tree-from-preorder-traversal) | Medium | +| 1007 | [Minimum Domino Rotations For Equal Row](https://leetcode.com/problems/minimum-domino-rotations-for-equal-row "行相等的最少多米诺旋转") | [Go](problems/minimum-domino-rotations-for-equal-row) | Medium | +| 1006 | [Clumsy Factorial](https://leetcode.com/problems/clumsy-factorial "笨阶乘") | [Go](problems/clumsy-factorial) | Medium | +| 1005 | [Maximize Sum Of Array After K Negations](https://leetcode.com/problems/maximize-sum-of-array-after-k-negations "K 次取反后最大化的数组和") | [Go](problems/maximize-sum-of-array-after-k-negations) | Easy | +| 1004 | [Max Consecutive Ones III](https://leetcode.com/problems/max-consecutive-ones-iii "最大连续1的个数 III") | [Go](problems/max-consecutive-ones-iii) | Medium | +| 1003 | [Check If Word Is Valid After Substitutions](https://leetcode.com/problems/check-if-word-is-valid-after-substitutions "检查替换后的词是否有效") | [Go](problems/check-if-word-is-valid-after-substitutions) | Medium | +| 1002 | [Find Common Characters](https://leetcode.com/problems/find-common-characters "查找常用字符") | [Go](problems/find-common-characters) | Easy | +| 1001 | [Grid Illumination](https://leetcode.com/problems/grid-illumination "网格照明") | [Go](problems/grid-illumination) | Hard | +| 1000 | [Minimum Cost to Merge Stones](https://leetcode.com/problems/minimum-cost-to-merge-stones "合并石头的最低成本") | [Go](problems/minimum-cost-to-merge-stones) | Hard | +| 999 | [Available Captures for Rook](https://leetcode.com/problems/available-captures-for-rook "车的可用捕获量") | [Go](problems/available-captures-for-rook) | Easy | +| 998 | [Maximum Binary Tree II](https://leetcode.com/problems/maximum-binary-tree-ii "最大二叉树 II") | [Go](problems/maximum-binary-tree-ii) | Medium | +| 997 | [Find the Town Judge](https://leetcode.com/problems/find-the-town-judge "找到小镇的法官") | [Go](problems/find-the-town-judge) | Easy | +| 996 | [Number of Squareful Arrays](https://leetcode.com/problems/number-of-squareful-arrays "正方形数组的数目") | [Go](problems/number-of-squareful-arrays) | Hard | +| 995 | [Minimum Number of K Consecutive Bit Flips](https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips "K 连续位的最小翻转次数") | [Go](problems/minimum-number-of-k-consecutive-bit-flips) | Hard | +| 994 | [Rotting Oranges](https://leetcode.com/problems/rotting-oranges "腐烂的橘子") | [Go](problems/rotting-oranges) | Easy | +| 993 | [Cousins in Binary Tree](https://leetcode.com/problems/cousins-in-binary-tree "二叉树的堂兄弟节点") | [Go](problems/cousins-in-binary-tree) | Easy | +| 992 | [Subarrays with K Different Integers](https://leetcode.com/problems/subarrays-with-k-different-integers "K 个不同整数的子数组") | [Go](problems/subarrays-with-k-different-integers) | Hard | +| 991 | [Broken Calculator](https://leetcode.com/problems/broken-calculator "坏了的计算器") | [Go](problems/broken-calculator) | Medium | +| 990 | [Satisfiability of Equality Equations](https://leetcode.com/problems/satisfiability-of-equality-equations "等式方程的可满足性") | [Go](problems/satisfiability-of-equality-equations) | Medium | +| 989 | [Add to Array-Form of Integer](https://leetcode.com/problems/add-to-array-form-of-integer "数组形式的整数加法") | [Go](problems/add-to-array-form-of-integer) | Easy | +| 988 | [Smallest String Starting From Leaf](https://leetcode.com/problems/smallest-string-starting-from-leaf "从叶结点开始的最小字符串") | [Go](problems/smallest-string-starting-from-leaf) | Medium | +| 987 | [Vertical Order Traversal of a Binary Tree](https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree "二叉树的垂序遍历") | [Go](problems/vertical-order-traversal-of-a-binary-tree) | Medium | +| 986 | [Interval List Intersections](https://leetcode.com/problems/interval-list-intersections "区间列表的交集") | [Go](problems/interval-list-intersections) | Medium | +| 985 | [Sum of Even Numbers After Queries](https://leetcode.com/problems/sum-of-even-numbers-after-queries "查询后的偶数和") | [Go](problems/sum-of-even-numbers-after-queries) | Easy | +| 984 | [String Without AAA or BBB](https://leetcode.com/problems/string-without-aaa-or-bbb "不含 AAA 或 BBB 的字符串") | [Go](problems/string-without-aaa-or-bbb) | Medium | +| 983 | [Minimum Cost For Tickets](https://leetcode.com/problems/minimum-cost-for-tickets "最低票价") | [Go](problems/minimum-cost-for-tickets) | Medium | +| 982 | [Triples with Bitwise AND Equal To Zero](https://leetcode.com/problems/triples-with-bitwise-and-equal-to-zero "按位与为零的三元组") | [Go](problems/triples-with-bitwise-and-equal-to-zero) | Hard | +| 981 | [Time Based Key-Value Store](https://leetcode.com/problems/time-based-key-value-store "基于时间的键值存储") | [Go](problems/time-based-key-value-store) | Medium | +| 980 | [Unique Paths III](https://leetcode.com/problems/unique-paths-iii "不同路径 III") | [Go](problems/unique-paths-iii) | Hard | +| 979 | [Distribute Coins in Binary Tree](https://leetcode.com/problems/distribute-coins-in-binary-tree "在二叉树中分配硬币") | [Go](problems/distribute-coins-in-binary-tree) | Medium | +| 978 | [Longest Turbulent Subarray](https://leetcode.com/problems/longest-turbulent-subarray "最长湍流子数组") | [Go](problems/longest-turbulent-subarray) | Medium | +| 977 | [Squares of a Sorted Array](https://leetcode.com/problems/squares-of-a-sorted-array "有序数组的平方") | [Go](problems/squares-of-a-sorted-array) | Easy | +| 976 | [Largest Perimeter Triangle](https://leetcode.com/problems/largest-perimeter-triangle "三角形的最大周长") | [Go](problems/largest-perimeter-triangle) | Easy | +| 975 | [Odd Even Jump](https://leetcode.com/problems/odd-even-jump "奇偶跳") | [Go](problems/odd-even-jump) | Hard | +| 974 | [Subarray Sums Divisible by K](https://leetcode.com/problems/subarray-sums-divisible-by-k "和可被 K 整除的子数组") | [Go](problems/subarray-sums-divisible-by-k) | Medium | +| 973 | [K Closest Points to Origin](https://leetcode.com/problems/k-closest-points-to-origin "最接近原点的 K 个点") | [Go](problems/k-closest-points-to-origin) | Medium | +| 972 | [Equal Rational Numbers](https://leetcode.com/problems/equal-rational-numbers "相等的有理数") | [Go](problems/equal-rational-numbers) | Hard | +| 971 | [Flip Binary Tree To Match Preorder Traversal](https://leetcode.com/problems/flip-binary-tree-to-match-preorder-traversal "翻转二叉树以匹配先序遍历") | [Go](problems/flip-binary-tree-to-match-preorder-traversal) | Medium | +| 970 | [Powerful Integers](https://leetcode.com/problems/powerful-integers "强整数") | [Go](problems/powerful-integers) | Easy | +| 969 | [Pancake Sorting](https://leetcode.com/problems/pancake-sorting "煎饼排序") | [Go](problems/pancake-sorting) | Medium | +| 968 | [Binary Tree Cameras](https://leetcode.com/problems/binary-tree-cameras "监控二叉树") | [Go](problems/binary-tree-cameras) | Hard | +| 967 | [Numbers With Same Consecutive Differences](https://leetcode.com/problems/numbers-with-same-consecutive-differences "连续差相同的数字") | [Go](problems/numbers-with-same-consecutive-differences) | Medium | +| 966 | [Vowel Spellchecker](https://leetcode.com/problems/vowel-spellchecker "元音拼写检查器") | [Go](problems/vowel-spellchecker) | Medium | +| 965 | [Univalued Binary Tree](https://leetcode.com/problems/univalued-binary-tree "单值二叉树") | [Go](problems/univalued-binary-tree) | Easy | +| 964 | [Least Operators to Express Number](https://leetcode.com/problems/least-operators-to-express-number "表示数字的最少运算符") | [Go](problems/least-operators-to-express-number) | Hard | +| 963 | [Minimum Area Rectangle II](https://leetcode.com/problems/minimum-area-rectangle-ii "最小面积矩形 II") | [Go](problems/minimum-area-rectangle-ii) | Medium | +| 962 | [Maximum Width Ramp](https://leetcode.com/problems/maximum-width-ramp "最大宽度坡") | [Go](problems/maximum-width-ramp) | Medium | +| 961 | [N-Repeated Element in Size 2N Array](https://leetcode.com/problems/n-repeated-element-in-size-2n-array "重复 N 次的元素") | [Go](problems/n-repeated-element-in-size-2n-array) | Easy | +| 960 | [Delete Columns to Make Sorted III](https://leetcode.com/problems/delete-columns-to-make-sorted-iii "删列造序 III") | [Go](problems/delete-columns-to-make-sorted-iii) | Hard | +| 959 | [Regions Cut By Slashes](https://leetcode.com/problems/regions-cut-by-slashes "由斜杠划分区域") | [Go](problems/regions-cut-by-slashes) | Medium | +| 958 | [Check Completeness of a Binary Tree](https://leetcode.com/problems/check-completeness-of-a-binary-tree "二叉树的完全性检验") | [Go](problems/check-completeness-of-a-binary-tree) | Medium | +| 957 | [Prison Cells After N Days](https://leetcode.com/problems/prison-cells-after-n-days "N 天后的牢房") | [Go](problems/prison-cells-after-n-days) | Medium | +| 956 | [Tallest Billboard](https://leetcode.com/problems/tallest-billboard "最高的广告牌") | [Go](problems/tallest-billboard) | Hard | +| 955 | [Delete Columns to Make Sorted II](https://leetcode.com/problems/delete-columns-to-make-sorted-ii "删列造序 II") | [Go](problems/delete-columns-to-make-sorted-ii) | Medium | +| 954 | [Array of Doubled Pairs](https://leetcode.com/problems/array-of-doubled-pairs "二倍数对数组") | [Go](problems/array-of-doubled-pairs) | Medium | +| 953 | [Verifying an Alien Dictionary](https://leetcode.com/problems/verifying-an-alien-dictionary "验证外星语词典") | [Go](problems/verifying-an-alien-dictionary) | Easy | +| 952 | [Largest Component Size by Common Factor](https://leetcode.com/problems/largest-component-size-by-common-factor "按公因数计算最大组件大小") | [Go](problems/largest-component-size-by-common-factor) | Hard | +| 951 | [Flip Equivalent Binary Trees](https://leetcode.com/problems/flip-equivalent-binary-trees "翻转等价二叉树") | [Go](problems/flip-equivalent-binary-trees) | Medium | +| 950 | [Reveal Cards In Increasing Order](https://leetcode.com/problems/reveal-cards-in-increasing-order "按递增顺序显示卡牌") | [Go](problems/reveal-cards-in-increasing-order) | Medium | +| 949 | [Largest Time for Given Digits](https://leetcode.com/problems/largest-time-for-given-digits "给定数字能组成的最大时间") | [Go](problems/largest-time-for-given-digits) | Easy | +| 948 | [Bag of Tokens](https://leetcode.com/problems/bag-of-tokens "令牌放置") | [Go](problems/bag-of-tokens) | Medium | +| 947 | [Most Stones Removed with Same Row or Column](https://leetcode.com/problems/most-stones-removed-with-same-row-or-column "移除最多的同行或同列石头") | [Go](problems/most-stones-removed-with-same-row-or-column) | Medium | +| 946 | [Validate Stack Sequences](https://leetcode.com/problems/validate-stack-sequences "验证栈序列") | [Go](problems/validate-stack-sequences) | Medium | +| 945 | [Minimum Increment to Make Array Unique](https://leetcode.com/problems/minimum-increment-to-make-array-unique "使数组唯一的最小增量") | [Go](problems/minimum-increment-to-make-array-unique) | Medium | +| 944 | [Delete Columns to Make Sorted](https://leetcode.com/problems/delete-columns-to-make-sorted "删列造序") | [Go](problems/delete-columns-to-make-sorted) | Easy | +| 943 | [Find the Shortest Superstring](https://leetcode.com/problems/find-the-shortest-superstring "最短超级串") | [Go](problems/find-the-shortest-superstring) | Hard | +| 942 | [DI String Match](https://leetcode.com/problems/di-string-match "增减字符串匹配") | [Go](problems/di-string-match) | Easy | +| 941 | [Valid Mountain Array](https://leetcode.com/problems/valid-mountain-array "有效的山脉数组") | [Go](problems/valid-mountain-array) | Easy | +| 940 | [Distinct Subsequences II](https://leetcode.com/problems/distinct-subsequences-ii "不同的子序列 II") | [Go](problems/distinct-subsequences-ii) | Hard | +| 939 | [Minimum Area Rectangle](https://leetcode.com/problems/minimum-area-rectangle "最小面积矩形") | [Go](problems/minimum-area-rectangle) | Medium | +| 938 | [Range Sum of BST](https://leetcode.com/problems/range-sum-of-bst "二叉搜索树的范围和") | [Go](problems/range-sum-of-bst) | Easy | +| 937 | [Reorder Data in Log Files](https://leetcode.com/problems/reorder-data-in-log-files "重新排列日志文件") | [Go](problems/reorder-data-in-log-files) | Easy | +| 936 | [Stamping The Sequence](https://leetcode.com/problems/stamping-the-sequence "戳印序列") | [Go](problems/stamping-the-sequence) | Hard | +| 935 | [Knight Dialer](https://leetcode.com/problems/knight-dialer "骑士拨号器") | [Go](problems/knight-dialer) | Medium | +| 934 | [Shortest Bridge](https://leetcode.com/problems/shortest-bridge "最短的桥") | [Go](problems/shortest-bridge) | Medium | +| 933 | [Number of Recent Calls](https://leetcode.com/problems/number-of-recent-calls "最近的请求次数") | [Go](problems/number-of-recent-calls) | Easy | +| 932 | [Beautiful Array](https://leetcode.com/problems/beautiful-array "漂亮数组") | [Go](problems/beautiful-array) | Medium | +| 931 | [Minimum Falling Path Sum](https://leetcode.com/problems/minimum-falling-path-sum "下降路径最小和") | [Go](problems/minimum-falling-path-sum) | Medium | +| 930 | [Binary Subarrays With Sum](https://leetcode.com/problems/binary-subarrays-with-sum "和相同的二元子数组") | [Go](problems/binary-subarrays-with-sum) | Medium | +| 929 | [Unique Email Addresses](https://leetcode.com/problems/unique-email-addresses "独特的电子邮件地址") | [Go](problems/unique-email-addresses) | Easy | +| 928 | [Minimize Malware Spread II](https://leetcode.com/problems/minimize-malware-spread-ii "尽量减少恶意软件的传播 II") | [Go](problems/minimize-malware-spread-ii) | Hard | +| 927 | [Three Equal Parts](https://leetcode.com/problems/three-equal-parts "三等分") | [Go](problems/three-equal-parts) | Hard | +| 926 | [Flip String to Monotone Increasing](https://leetcode.com/problems/flip-string-to-monotone-increasing "将字符串翻转到单调递增") | [Go](problems/flip-string-to-monotone-increasing) | Medium | +| 925 | [Long Pressed Name](https://leetcode.com/problems/long-pressed-name "长按键入") | [Go](problems/long-pressed-name) | Easy | +| 924 | [Minimize Malware Spread](https://leetcode.com/problems/minimize-malware-spread "尽量减少恶意软件的传播") | [Go](problems/minimize-malware-spread) | Hard | +| 923 | [3Sum With Multiplicity](https://leetcode.com/problems/3sum-with-multiplicity "三数之和的多种可能") | [Go](problems/3sum-with-multiplicity) | Medium | +| 922 | [Sort Array By Parity II](https://leetcode.com/problems/sort-array-by-parity-ii "按奇偶排序数组 II") | [Go](problems/sort-array-by-parity-ii) | Easy | +| 921 | [Minimum Add to Make Parentheses Valid](https://leetcode.com/problems/minimum-add-to-make-parentheses-valid "使括号有效的最少添加") | [Go](problems/minimum-add-to-make-parentheses-valid) | Medium | +| 920 | [Number of Music Playlists](https://leetcode.com/problems/number-of-music-playlists "播放列表的数量") | [Go](problems/number-of-music-playlists) | Hard | +| 919 | [Complete Binary Tree Inserter](https://leetcode.com/problems/complete-binary-tree-inserter "完全二叉树插入器") | [Go](problems/complete-binary-tree-inserter) | Medium | +| 918 | [Maximum Sum Circular Subarray](https://leetcode.com/problems/maximum-sum-circular-subarray "环形子数组的最大和") | [Go](problems/maximum-sum-circular-subarray) | Medium | +| 917 | [Reverse Only Letters](https://leetcode.com/problems/reverse-only-letters "仅仅反转字母") | [Go](problems/reverse-only-letters) | Easy | +| 916 | [Word Subsets](https://leetcode.com/problems/word-subsets "单词子集") | [Go](problems/word-subsets) | Medium | +| 915 | [Partition Array into Disjoint Intervals](https://leetcode.com/problems/partition-array-into-disjoint-intervals "分割数组") | [Go](problems/partition-array-into-disjoint-intervals) | Medium | +| 914 | [X of a Kind in a Deck of Cards](https://leetcode.com/problems/x-of-a-kind-in-a-deck-of-cards "卡牌分组") | [Go](problems/x-of-a-kind-in-a-deck-of-cards) | Easy | +| 913 | [Cat and Mouse](https://leetcode.com/problems/cat-and-mouse "猫和老鼠") | [Go](problems/cat-and-mouse) | Hard | +| 912 | [Sort an Array](https://leetcode.com/problems/sort-an-array "排序数组") | [Go](problems/sort-an-array) | Medium | +| 911 | [Online Election](https://leetcode.com/problems/online-election "在线选举") | [Go](problems/online-election) | Medium | +| 910 | [Smallest Range II](https://leetcode.com/problems/smallest-range-ii "最小差值 II") | [Go](problems/smallest-range-ii) | Medium | +| 909 | [Snakes and Ladders](https://leetcode.com/problems/snakes-and-ladders "蛇梯棋") | [Go](problems/snakes-and-ladders) | Medium | +| 908 | [Smallest Range I](https://leetcode.com/problems/smallest-range-i "最小差值 I") | [Go](problems/smallest-range-i) | Easy | +| 907 | [Sum of Subarray Minimums](https://leetcode.com/problems/sum-of-subarray-minimums "子数组的最小值之和") | [Go](problems/sum-of-subarray-minimums) | Medium | +| 906 | [Super Palindromes](https://leetcode.com/problems/super-palindromes "超级回文数") | [Go](problems/super-palindromes) | Hard | +| 905 | [Sort Array By Parity](https://leetcode.com/problems/sort-array-by-parity "按奇偶排序数组") | [Go](problems/sort-array-by-parity) | Easy | +| 904 | [Fruit Into Baskets](https://leetcode.com/problems/fruit-into-baskets "水果成篮") | [Go](problems/fruit-into-baskets) | Medium | +| 903 | [Valid Permutations for DI Sequence](https://leetcode.com/problems/valid-permutations-for-di-sequence "DI 序列的有效排列") | [Go](problems/valid-permutations-for-di-sequence) | Hard | +| 902 | [Numbers At Most N Given Digit Set](https://leetcode.com/problems/numbers-at-most-n-given-digit-set "最大为 N 的数字组合") | [Go](problems/numbers-at-most-n-given-digit-set) | Hard | +| 901 | [Online Stock Span](https://leetcode.com/problems/online-stock-span "股票价格跨度") | [Go](problems/online-stock-span) | Medium | diff --git a/internal/leetcode/problems_all.go b/internal/leetcode/problems_all.go index bae3e1702..294baae0c 100644 --- a/internal/leetcode/problems_all.go +++ b/internal/leetcode/problems_all.go @@ -35,14 +35,18 @@ type StatStatusPairsType struct { } // WriteRow - leetcode.WriteRow -func (problem *StatStatusPairsType) WriteRow(buf *bytes.Buffer) { - format := "| %d | [%s](https://leetcode.com/problems/%s%s)%s | [%s](https://github.com/openset/leetcode/tree/master/problems/%s) | %s |\n" +func (problem *StatStatusPairsType) WriteRow(buf *bytes.Buffer, path string) { + format := "| %d | [%s](https://leetcode.com/problems/%s%s)%s | [%s](%s/%s) | %s |\n" id := problem.Stat.FrontendQuestionID stat := problem.Stat title := strings.TrimSpace(problem.Stat.QuestionTitle) titleSlug := stat.QuestionTitleSlug levelName := problem.Difficulty.LevelName() - buf.WriteString(fmt.Sprintf(format, id, id, title, titleSlug, stat.TranslationTitle(), problem.PaidOnly.Str(), stat.Lang(), titleSlug, levelName)) + buf.WriteString(fmt.Sprintf(format, id, id, + title, titleSlug, stat.TranslationTitle(), problem.PaidOnly.Str(), + stat.Lang(), path, titleSlug, + levelName, + )) } type statType struct { diff --git a/internal/readme/readme.go b/internal/readme/readme.go index c5c669445..621d30755 100644 --- a/internal/readme/readme.go +++ b/internal/readme/readme.go @@ -73,14 +73,14 @@ func writeProblems(buf *bytes.Buffer) { for i := 1; i < maxID/pageSize; i++ { for problems[count-1].Stat.FrontendQuestionID <= pageSize*i { count-- - problems[count].WriteRow(buf) + problems[count].WriteRow(buf, "../problems") } fileName := filepath.Join("readme", fmt.Sprintf("%d-%d.md", pageSize*(i-1)+1, pageSize*i)) base.FilePutContents(fileName, buf.Bytes()) buf.Truncate(n) } for _, problem := range problems[0:count] { - problem.WriteRow(buf) + problem.WriteRow(buf, "problems") } } } diff --git a/readme/1-300.md b/readme/1-300.md index 9ce3ea5c0..347bc028a 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -62,303 +62,303 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | -| 1 | [Two Sum](https://leetcode.com/problems/two-sum "两数之和") | [Go](https://github.com/openset/leetcode/tree/master/problems/two-sum) | Easy | -| 2 | [Add Two Numbers](https://leetcode.com/problems/add-two-numbers "两数相加") | [Go](https://github.com/openset/leetcode/tree/master/problems/add-two-numbers) | Medium | -| 3 | [Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters "无重复字符的最长子串") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-substring-without-repeating-characters) | Medium | -| 4 | [Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays "寻找两个有序数组的中位数") | [Go](https://github.com/openset/leetcode/tree/master/problems/median-of-two-sorted-arrays) | Hard | -| 5 | [Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring "最长回文子串") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-palindromic-substring) | Medium | -| 6 | [ZigZag Conversion](https://leetcode.com/problems/zigzag-conversion "Z 字形变换") | [Go](https://github.com/openset/leetcode/tree/master/problems/zigzag-conversion) | Medium | -| 7 | [Reverse Integer](https://leetcode.com/problems/reverse-integer "整数反转") | [Go](https://github.com/openset/leetcode/tree/master/problems/reverse-integer) | Easy | -| 8 | [String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-atoi "字符串转换整数 (atoi)") | [Go](https://github.com/openset/leetcode/tree/master/problems/string-to-integer-atoi) | Medium | -| 9 | [Palindrome Number](https://leetcode.com/problems/palindrome-number "回文数") | [Go](https://github.com/openset/leetcode/tree/master/problems/palindrome-number) | Easy | -| 10 | [Regular Expression Matching](https://leetcode.com/problems/regular-expression-matching "正则表达式匹配") | [Go](https://github.com/openset/leetcode/tree/master/problems/regular-expression-matching) | Hard | -| 11 | [Container With Most Water](https://leetcode.com/problems/container-with-most-water "盛最多水的容器") | [Go](https://github.com/openset/leetcode/tree/master/problems/container-with-most-water) | Medium | -| 12 | [Integer to Roman](https://leetcode.com/problems/integer-to-roman "整数转罗马数字") | [Go](https://github.com/openset/leetcode/tree/master/problems/integer-to-roman) | Medium | -| 13 | [Roman to Integer](https://leetcode.com/problems/roman-to-integer "罗马数字转整数") | [Go](https://github.com/openset/leetcode/tree/master/problems/roman-to-integer) | Easy | -| 14 | [Longest Common Prefix](https://leetcode.com/problems/longest-common-prefix "最长公共前缀") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-common-prefix) | Easy | -| 15 | [3Sum](https://leetcode.com/problems/3sum "三数之和") | [Go](https://github.com/openset/leetcode/tree/master/problems/3sum) | Medium | -| 16 | [3Sum Closest](https://leetcode.com/problems/3sum-closest "最接近的三数之和") | [Go](https://github.com/openset/leetcode/tree/master/problems/3sum-closest) | Medium | -| 17 | [Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number "电话号码的字母组合") | [Go](https://github.com/openset/leetcode/tree/master/problems/letter-combinations-of-a-phone-number) | Medium | -| 18 | [4Sum](https://leetcode.com/problems/4sum "四数之和") | [Go](https://github.com/openset/leetcode/tree/master/problems/4sum) | Medium | -| 19 | [Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list "删除链表的倒数第N个节点") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-nth-node-from-end-of-list) | Medium | -| 20 | [Valid Parentheses](https://leetcode.com/problems/valid-parentheses "有效的括号") | [Go](https://github.com/openset/leetcode/tree/master/problems/valid-parentheses) | Easy | -| 21 | [Merge Two Sorted Lists](https://leetcode.com/problems/merge-two-sorted-lists "合并两个有序链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/merge-two-sorted-lists) | Easy | -| 22 | [Generate Parentheses](https://leetcode.com/problems/generate-parentheses "括号生成") | [Go](https://github.com/openset/leetcode/tree/master/problems/generate-parentheses) | Medium | -| 23 | [Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists "合并K个排序链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/merge-k-sorted-lists) | Hard | -| 24 | [Swap Nodes in Pairs](https://leetcode.com/problems/swap-nodes-in-pairs "两两交换链表中的节点") | [Go](https://github.com/openset/leetcode/tree/master/problems/swap-nodes-in-pairs) | Medium | -| 25 | [Reverse Nodes in k-Group](https://leetcode.com/problems/reverse-nodes-in-k-group "K 个一组翻转链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/reverse-nodes-in-k-group) | Hard | -| 26 | [Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array "删除排序数组中的重复项") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-array) | Easy | -| 27 | [Remove Element](https://leetcode.com/problems/remove-element "移除元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-element) | Easy | -| 28 | [Implement strStr()](https://leetcode.com/problems/implement-strstr "实现 strStr()") | [Go](https://github.com/openset/leetcode/tree/master/problems/implement-strstr) | Easy | -| 29 | [Divide Two Integers](https://leetcode.com/problems/divide-two-integers "两数相除") | [Go](https://github.com/openset/leetcode/tree/master/problems/divide-two-integers) | Medium | -| 30 | [Substring with Concatenation of All Words](https://leetcode.com/problems/substring-with-concatenation-of-all-words "串联所有单词的子串") | [Go](https://github.com/openset/leetcode/tree/master/problems/substring-with-concatenation-of-all-words) | Hard | -| 31 | [Next Permutation](https://leetcode.com/problems/next-permutation "下一个排列") | [Go](https://github.com/openset/leetcode/tree/master/problems/next-permutation) | Medium | -| 32 | [Longest Valid Parentheses](https://leetcode.com/problems/longest-valid-parentheses "最长有效括号") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-valid-parentheses) | Hard | -| 33 | [Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array "搜索旋转排序数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/search-in-rotated-sorted-array) | Medium | -| 34 | [Find First and Last Position of Element in Sorted Array](https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array "在排序数组中查找元素的第一个和最后一个位置") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-first-and-last-position-of-element-in-sorted-array) | Medium | -| 35 | [Search Insert Position](https://leetcode.com/problems/search-insert-position "搜索插入位置") | [Go](https://github.com/openset/leetcode/tree/master/problems/search-insert-position) | Easy | -| 36 | [Valid Sudoku](https://leetcode.com/problems/valid-sudoku "有效的数独") | [Go](https://github.com/openset/leetcode/tree/master/problems/valid-sudoku) | Medium | -| 37 | [Sudoku Solver](https://leetcode.com/problems/sudoku-solver "解数独") | [Go](https://github.com/openset/leetcode/tree/master/problems/sudoku-solver) | Hard | -| 38 | [Count and Say](https://leetcode.com/problems/count-and-say "报数") | [Go](https://github.com/openset/leetcode/tree/master/problems/count-and-say) | Easy | -| 39 | [Combination Sum](https://leetcode.com/problems/combination-sum "组合总和") | [Go](https://github.com/openset/leetcode/tree/master/problems/combination-sum) | Medium | -| 40 | [Combination Sum II](https://leetcode.com/problems/combination-sum-ii "组合总和 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/combination-sum-ii) | Medium | -| 41 | [First Missing Positive](https://leetcode.com/problems/first-missing-positive "缺失的第一个正数") | [Go](https://github.com/openset/leetcode/tree/master/problems/first-missing-positive) | Hard | -| 42 | [Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water "接雨水") | [Go](https://github.com/openset/leetcode/tree/master/problems/trapping-rain-water) | Hard | -| 43 | [Multiply Strings](https://leetcode.com/problems/multiply-strings "字符串相乘") | [Go](https://github.com/openset/leetcode/tree/master/problems/multiply-strings) | Medium | -| 44 | [Wildcard Matching](https://leetcode.com/problems/wildcard-matching "通配符匹配") | [Go](https://github.com/openset/leetcode/tree/master/problems/wildcard-matching) | Hard | -| 45 | [Jump Game II](https://leetcode.com/problems/jump-game-ii "跳跃游戏 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/jump-game-ii) | Hard | -| 46 | [Permutations](https://leetcode.com/problems/permutations "全排列") | [Go](https://github.com/openset/leetcode/tree/master/problems/permutations) | Medium | -| 47 | [Permutations II](https://leetcode.com/problems/permutations-ii "全排列 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/permutations-ii) | Medium | -| 48 | [Rotate Image](https://leetcode.com/problems/rotate-image "旋转图像") | [Go](https://github.com/openset/leetcode/tree/master/problems/rotate-image) | Medium | -| 49 | [Group Anagrams](https://leetcode.com/problems/group-anagrams "字母异位词分组") | [Go](https://github.com/openset/leetcode/tree/master/problems/group-anagrams) | Medium | -| 50 | [Pow(x, n)](https://leetcode.com/problems/powx-n "Pow(x, n)") | [Go](https://github.com/openset/leetcode/tree/master/problems/powx-n) | Medium | -| 51 | [N-Queens](https://leetcode.com/problems/n-queens "N皇后") | [Go](https://github.com/openset/leetcode/tree/master/problems/n-queens) | Hard | -| 52 | [N-Queens II](https://leetcode.com/problems/n-queens-ii "N皇后 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/n-queens-ii) | Hard | -| 53 | [Maximum Subarray](https://leetcode.com/problems/maximum-subarray "最大子序和") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-subarray) | Easy | -| 54 | [Spiral Matrix](https://leetcode.com/problems/spiral-matrix "螺旋矩阵") | [Go](https://github.com/openset/leetcode/tree/master/problems/spiral-matrix) | Medium | -| 55 | [Jump Game](https://leetcode.com/problems/jump-game "跳跃游戏") | [Go](https://github.com/openset/leetcode/tree/master/problems/jump-game) | Medium | -| 56 | [Merge Intervals](https://leetcode.com/problems/merge-intervals "合并区间") | [Go](https://github.com/openset/leetcode/tree/master/problems/merge-intervals) | Medium | -| 57 | [Insert Interval](https://leetcode.com/problems/insert-interval "插入区间") | [Go](https://github.com/openset/leetcode/tree/master/problems/insert-interval) | Hard | -| 58 | [Length of Last Word](https://leetcode.com/problems/length-of-last-word "最后一个单词的长度") | [Go](https://github.com/openset/leetcode/tree/master/problems/length-of-last-word) | Easy | -| 59 | [Spiral Matrix II](https://leetcode.com/problems/spiral-matrix-ii "螺旋矩阵 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/spiral-matrix-ii) | Medium | -| 60 | [Permutation Sequence](https://leetcode.com/problems/permutation-sequence "第k个排列") | [Go](https://github.com/openset/leetcode/tree/master/problems/permutation-sequence) | Medium | -| 61 | [Rotate List](https://leetcode.com/problems/rotate-list "旋转链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/rotate-list) | Medium | -| 62 | [Unique Paths](https://leetcode.com/problems/unique-paths "不同路径") | [Go](https://github.com/openset/leetcode/tree/master/problems/unique-paths) | Medium | -| 63 | [Unique Paths II](https://leetcode.com/problems/unique-paths-ii "不同路径 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/unique-paths-ii) | Medium | -| 64 | [Minimum Path Sum](https://leetcode.com/problems/minimum-path-sum "最小路径和") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-path-sum) | Medium | -| 65 | [Valid Number](https://leetcode.com/problems/valid-number "有效数字") | [Go](https://github.com/openset/leetcode/tree/master/problems/valid-number) | Hard | -| 66 | [Plus One](https://leetcode.com/problems/plus-one "加一") | [Go](https://github.com/openset/leetcode/tree/master/problems/plus-one) | Easy | -| 67 | [Add Binary](https://leetcode.com/problems/add-binary "二进制求和") | [Go](https://github.com/openset/leetcode/tree/master/problems/add-binary) | Easy | -| 68 | [Text Justification](https://leetcode.com/problems/text-justification "文本左右对齐") | [Go](https://github.com/openset/leetcode/tree/master/problems/text-justification) | Hard | -| 69 | [Sqrt(x)](https://leetcode.com/problems/sqrtx "x 的平方根") | [Go](https://github.com/openset/leetcode/tree/master/problems/sqrtx) | Easy | -| 70 | [Climbing Stairs](https://leetcode.com/problems/climbing-stairs "爬楼梯") | [Go](https://github.com/openset/leetcode/tree/master/problems/climbing-stairs) | Easy | -| 71 | [Simplify Path](https://leetcode.com/problems/simplify-path "简化路径") | [Go](https://github.com/openset/leetcode/tree/master/problems/simplify-path) | Medium | -| 72 | [Edit Distance](https://leetcode.com/problems/edit-distance "编辑距离") | [Go](https://github.com/openset/leetcode/tree/master/problems/edit-distance) | Hard | -| 73 | [Set Matrix Zeroes](https://leetcode.com/problems/set-matrix-zeroes "矩阵置零") | [Go](https://github.com/openset/leetcode/tree/master/problems/set-matrix-zeroes) | Medium | -| 74 | [Search a 2D Matrix](https://leetcode.com/problems/search-a-2d-matrix "搜索二维矩阵") | [Go](https://github.com/openset/leetcode/tree/master/problems/search-a-2d-matrix) | Medium | -| 75 | [Sort Colors](https://leetcode.com/problems/sort-colors "颜色分类") | [Go](https://github.com/openset/leetcode/tree/master/problems/sort-colors) | Medium | -| 76 | [Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring "最小覆盖子串") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-window-substring) | Hard | -| 77 | [Combinations](https://leetcode.com/problems/combinations "组合") | [Go](https://github.com/openset/leetcode/tree/master/problems/combinations) | Medium | -| 78 | [Subsets](https://leetcode.com/problems/subsets "子集") | [Go](https://github.com/openset/leetcode/tree/master/problems/subsets) | Medium | -| 79 | [Word Search](https://leetcode.com/problems/word-search "单词搜索") | [Go](https://github.com/openset/leetcode/tree/master/problems/word-search) | Medium | -| 80 | [Remove Duplicates from Sorted Array II](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii "删除排序数组中的重复项 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-array-ii) | Medium | -| 81 | [Search in Rotated Sorted Array II](https://leetcode.com/problems/search-in-rotated-sorted-array-ii "搜索旋转排序数组 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/search-in-rotated-sorted-array-ii) | Medium | -| 82 | [Remove Duplicates from Sorted List II](https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii "删除排序链表中的重复元素 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-list-ii) | Medium | -| 83 | [Remove Duplicates from Sorted List](https://leetcode.com/problems/remove-duplicates-from-sorted-list "删除排序链表中的重复元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-list) | Easy | -| 84 | [Largest Rectangle in Histogram](https://leetcode.com/problems/largest-rectangle-in-histogram "柱状图中最大的矩形") | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-rectangle-in-histogram) | Hard | -| 85 | [Maximal Rectangle](https://leetcode.com/problems/maximal-rectangle "最大矩形") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximal-rectangle) | Hard | -| 86 | [Partition List](https://leetcode.com/problems/partition-list "分隔链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/partition-list) | Medium | -| 87 | [Scramble String](https://leetcode.com/problems/scramble-string "扰乱字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/scramble-string) | Hard | -| 88 | [Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array "合并两个有序数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/merge-sorted-array) | Easy | -| 89 | [Gray Code](https://leetcode.com/problems/gray-code "格雷编码") | [Go](https://github.com/openset/leetcode/tree/master/problems/gray-code) | Medium | -| 90 | [Subsets II](https://leetcode.com/problems/subsets-ii "子集 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/subsets-ii) | Medium | -| 91 | [Decode Ways](https://leetcode.com/problems/decode-ways "解码方法") | [Go](https://github.com/openset/leetcode/tree/master/problems/decode-ways) | Medium | -| 92 | [Reverse Linked List II](https://leetcode.com/problems/reverse-linked-list-ii "反转链表 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/reverse-linked-list-ii) | Medium | -| 93 | [Restore IP Addresses](https://leetcode.com/problems/restore-ip-addresses "复原IP地址") | [Go](https://github.com/openset/leetcode/tree/master/problems/restore-ip-addresses) | Medium | -| 94 | [Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal "二叉树的中序遍历") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-inorder-traversal) | Medium | -| 95 | [Unique Binary Search Trees II](https://leetcode.com/problems/unique-binary-search-trees-ii "不同的二叉搜索树 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/unique-binary-search-trees-ii) | Medium | -| 96 | [Unique Binary Search Trees](https://leetcode.com/problems/unique-binary-search-trees "不同的二叉搜索树") | [Go](https://github.com/openset/leetcode/tree/master/problems/unique-binary-search-trees) | Medium | -| 97 | [Interleaving String](https://leetcode.com/problems/interleaving-string "交错字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/interleaving-string) | Hard | -| 98 | [Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree "验证二叉搜索树") | [Go](https://github.com/openset/leetcode/tree/master/problems/validate-binary-search-tree) | Medium | -| 99 | [Recover Binary Search Tree](https://leetcode.com/problems/recover-binary-search-tree "恢复二叉搜索树") | [Go](https://github.com/openset/leetcode/tree/master/problems/recover-binary-search-tree) | Hard | -| 100 | [Same Tree](https://leetcode.com/problems/same-tree "相同的树") | [Go](https://github.com/openset/leetcode/tree/master/problems/same-tree) | Easy | -| 101 | [Symmetric Tree](https://leetcode.com/problems/symmetric-tree "对称二叉树") | [Go](https://github.com/openset/leetcode/tree/master/problems/symmetric-tree) | Easy | -| 102 | [Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal "二叉树的层次遍历") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal) | Medium | -| 103 | [Binary Tree Zigzag Level Order Traversal](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal "二叉树的锯齿形层次遍历") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-zigzag-level-order-traversal) | Medium | -| 104 | [Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree "二叉树的最大深度") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-depth-of-binary-tree) | Easy | -| 105 | [Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal "从前序与中序遍历序列构造二叉树") | [Go](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-preorder-and-inorder-traversal) | Medium | -| 106 | [Construct Binary Tree from Inorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal "从中序与后序遍历序列构造二叉树") | [Go](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-inorder-and-postorder-traversal) | Medium | -| 107 | [Binary Tree Level Order Traversal II](https://leetcode.com/problems/binary-tree-level-order-traversal-ii "二叉树的层次遍历 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal-ii) | Easy | -| 108 | [Convert Sorted Array to Binary Search Tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree "将有序数组转换为二叉搜索树") | [Go](https://github.com/openset/leetcode/tree/master/problems/convert-sorted-array-to-binary-search-tree) | Easy | -| 109 | [Convert Sorted List to Binary Search Tree](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree "有序链表转换二叉搜索树") | [Go](https://github.com/openset/leetcode/tree/master/problems/convert-sorted-list-to-binary-search-tree) | Medium | -| 110 | [Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree "平衡二叉树") | [Go](https://github.com/openset/leetcode/tree/master/problems/balanced-binary-tree) | Easy | -| 111 | [Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree "二叉树的最小深度") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-depth-of-binary-tree) | Easy | -| 112 | [Path Sum](https://leetcode.com/problems/path-sum "路径总和") | [Go](https://github.com/openset/leetcode/tree/master/problems/path-sum) | Easy | -| 113 | [Path Sum II](https://leetcode.com/problems/path-sum-ii "路径总和 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/path-sum-ii) | Medium | -| 114 | [Flatten Binary Tree to Linked List](https://leetcode.com/problems/flatten-binary-tree-to-linked-list "二叉树展开为链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/flatten-binary-tree-to-linked-list) | Medium | -| 115 | [Distinct Subsequences](https://leetcode.com/problems/distinct-subsequences "不同的子序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/distinct-subsequences) | Hard | -| 116 | [Populating Next Right Pointers in Each Node](https://leetcode.com/problems/populating-next-right-pointers-in-each-node "填充每个节点的下一个右侧节点指针") | [Go](https://github.com/openset/leetcode/tree/master/problems/populating-next-right-pointers-in-each-node) | Medium | -| 117 | [Populating Next Right Pointers in Each Node II](https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii "填充每个节点的下一个右侧节点指针 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/populating-next-right-pointers-in-each-node-ii) | Medium | -| 118 | [Pascal's Triangle](https://leetcode.com/problems/pascals-triangle "杨辉三角") | [Go](https://github.com/openset/leetcode/tree/master/problems/pascals-triangle) | Easy | -| 119 | [Pascal's Triangle II](https://leetcode.com/problems/pascals-triangle-ii "杨辉三角 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/pascals-triangle-ii) | Easy | -| 120 | [Triangle](https://leetcode.com/problems/triangle "三角形最小路径和") | [Go](https://github.com/openset/leetcode/tree/master/problems/triangle) | Medium | -| 121 | [Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock "买卖股票的最佳时机") | [Go](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock) | Easy | -| 122 | [Best Time to Buy and Sell Stock II](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii "买卖股票的最佳时机 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-ii) | Easy | -| 123 | [Best Time to Buy and Sell Stock III](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii "买卖股票的最佳时机 III") | [Go](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-iii) | Hard | -| 124 | [Binary Tree Maximum Path Sum](https://leetcode.com/problems/binary-tree-maximum-path-sum "二叉树中的最大路径和") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-maximum-path-sum) | Hard | -| 125 | [Valid Palindrome](https://leetcode.com/problems/valid-palindrome "验证回文串") | [Go](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome) | Easy | -| 126 | [Word Ladder II](https://leetcode.com/problems/word-ladder-ii "单词接龙 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/word-ladder-ii) | Hard | -| 127 | [Word Ladder](https://leetcode.com/problems/word-ladder "单词接龙") | [Go](https://github.com/openset/leetcode/tree/master/problems/word-ladder) | Medium | -| 128 | [Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence "最长连续序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-consecutive-sequence) | Hard | -| 129 | [Sum Root to Leaf Numbers](https://leetcode.com/problems/sum-root-to-leaf-numbers "求根到叶子节点数字之和") | [Go](https://github.com/openset/leetcode/tree/master/problems/sum-root-to-leaf-numbers) | Medium | -| 130 | [Surrounded Regions](https://leetcode.com/problems/surrounded-regions "被围绕的区域") | [Go](https://github.com/openset/leetcode/tree/master/problems/surrounded-regions) | Medium | -| 131 | [Palindrome Partitioning](https://leetcode.com/problems/palindrome-partitioning "分割回文串") | [Go](https://github.com/openset/leetcode/tree/master/problems/palindrome-partitioning) | Medium | -| 132 | [Palindrome Partitioning II](https://leetcode.com/problems/palindrome-partitioning-ii "分割回文串 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/palindrome-partitioning-ii) | Hard | -| 133 | [Clone Graph](https://leetcode.com/problems/clone-graph "克隆图") | [Go](https://github.com/openset/leetcode/tree/master/problems/clone-graph) | Medium | -| 134 | [Gas Station](https://leetcode.com/problems/gas-station "加油站") | [Go](https://github.com/openset/leetcode/tree/master/problems/gas-station) | Medium | -| 135 | [Candy](https://leetcode.com/problems/candy "分发糖果") | [Go](https://github.com/openset/leetcode/tree/master/problems/candy) | Hard | -| 136 | [Single Number](https://leetcode.com/problems/single-number "只出现一次的数字") | [Go](https://github.com/openset/leetcode/tree/master/problems/single-number) | Easy | -| 137 | [Single Number II](https://leetcode.com/problems/single-number-ii "只出现一次的数字 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/single-number-ii) | Medium | -| 138 | [Copy List with Random Pointer](https://leetcode.com/problems/copy-list-with-random-pointer "复制带随机指针的链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/copy-list-with-random-pointer) | Medium | -| 139 | [Word Break](https://leetcode.com/problems/word-break "单词拆分") | [Go](https://github.com/openset/leetcode/tree/master/problems/word-break) | Medium | -| 140 | [Word Break II](https://leetcode.com/problems/word-break-ii "单词拆分 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/word-break-ii) | Hard | -| 141 | [Linked List Cycle](https://leetcode.com/problems/linked-list-cycle "环形链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/linked-list-cycle) | Easy | -| 142 | [Linked List Cycle II](https://leetcode.com/problems/linked-list-cycle-ii "环形链表 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/linked-list-cycle-ii) | Medium | -| 143 | [Reorder List](https://leetcode.com/problems/reorder-list "重排链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/reorder-list) | Medium | -| 144 | [Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal "二叉树的前序遍历") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-preorder-traversal) | Medium | -| 145 | [Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-postorder-traversal) | Hard | -| 146 | [LRU Cache](https://leetcode.com/problems/lru-cache "LRU缓存机制") | [Go](https://github.com/openset/leetcode/tree/master/problems/lru-cache) | Medium | -| 147 | [Insertion Sort List](https://leetcode.com/problems/insertion-sort-list "对链表进行插入排序") | [Go](https://github.com/openset/leetcode/tree/master/problems/insertion-sort-list) | Medium | -| 148 | [Sort List](https://leetcode.com/problems/sort-list "排序链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/sort-list) | Medium | -| 149 | [Max Points on a Line](https://leetcode.com/problems/max-points-on-a-line "直线上最多的点数") | [Go](https://github.com/openset/leetcode/tree/master/problems/max-points-on-a-line) | Hard | -| 150 | [Evaluate Reverse Polish Notation](https://leetcode.com/problems/evaluate-reverse-polish-notation "逆波兰表达式求值") | [Go](https://github.com/openset/leetcode/tree/master/problems/evaluate-reverse-polish-notation) | Medium | -| 151 | [Reverse Words in a String](https://leetcode.com/problems/reverse-words-in-a-string "翻转字符串里的单词") | [Go](https://github.com/openset/leetcode/tree/master/problems/reverse-words-in-a-string) | Medium | -| 152 | [Maximum Product Subarray](https://leetcode.com/problems/maximum-product-subarray "乘积最大子序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-product-subarray) | Medium | -| 153 | [Find Minimum in Rotated Sorted Array](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array "寻找旋转排序数组中的最小值") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-minimum-in-rotated-sorted-array) | Medium | -| 154 | [Find Minimum in Rotated Sorted Array II](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii "寻找旋转排序数组中的最小值 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-minimum-in-rotated-sorted-array-ii) | Hard | -| 155 | [Min Stack](https://leetcode.com/problems/min-stack "最小栈") | [Go](https://github.com/openset/leetcode/tree/master/problems/min-stack) | Easy | -| 156 | [Binary Tree Upside Down](https://leetcode.com/problems/binary-tree-upside-down "上下翻转二叉树") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-upside-down) | Medium | -| 157 | [Read N Characters Given Read4](https://leetcode.com/problems/read-n-characters-given-read4 "用 Read4 读取 N 个字符") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/read-n-characters-given-read4) | Easy | -| 158 | [Read N Characters Given Read4 II - Call multiple times](https://leetcode.com/problems/read-n-characters-given-read4-ii-call-multiple-times "用 Read4 读取 N 个字符 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/read-n-characters-given-read4-ii-call-multiple-times) | Hard | -| 159 | [Longest Substring with At Most Two Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters "至多包含两个不同字符的最长子串") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters) | Medium | -| 160 | [Intersection of Two Linked Lists](https://leetcode.com/problems/intersection-of-two-linked-lists "相交链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-linked-lists) | Easy | -| 161 | [One Edit Distance](https://leetcode.com/problems/one-edit-distance "相隔为 1 的编辑距离") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/one-edit-distance) | Medium | -| 162 | [Find Peak Element](https://leetcode.com/problems/find-peak-element "寻找峰值") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-peak-element) | Medium | -| 163 | [Missing Ranges](https://leetcode.com/problems/missing-ranges "缺失的区间") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/missing-ranges) | Medium | -| 164 | [Maximum Gap](https://leetcode.com/problems/maximum-gap "最大间距") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-gap) | Hard | -| 165 | [Compare Version Numbers](https://leetcode.com/problems/compare-version-numbers "比较版本号") | [Go](https://github.com/openset/leetcode/tree/master/problems/compare-version-numbers) | Medium | -| 166 | [Fraction to Recurring Decimal](https://leetcode.com/problems/fraction-to-recurring-decimal "分数到小数") | [Go](https://github.com/openset/leetcode/tree/master/problems/fraction-to-recurring-decimal) | Medium | -| 167 | [Two Sum II - Input array is sorted](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted "两数之和 II - 输入有序数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/two-sum-ii-input-array-is-sorted) | Easy | -| 168 | [Excel Sheet Column Title](https://leetcode.com/problems/excel-sheet-column-title "Excel表列名称") | [Go](https://github.com/openset/leetcode/tree/master/problems/excel-sheet-column-title) | Easy | -| 169 | [Majority Element](https://leetcode.com/problems/majority-element "多数元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/majority-element) | Easy | -| 170 | [Two Sum III - Data structure design](https://leetcode.com/problems/two-sum-iii-data-structure-design "两数之和 III - 数据结构设计") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/two-sum-iii-data-structure-design) | Easy | -| 171 | [Excel Sheet Column Number](https://leetcode.com/problems/excel-sheet-column-number "Excel表列序号") | [Go](https://github.com/openset/leetcode/tree/master/problems/excel-sheet-column-number) | Easy | -| 172 | [Factorial Trailing Zeroes](https://leetcode.com/problems/factorial-trailing-zeroes "阶乘后的零") | [Go](https://github.com/openset/leetcode/tree/master/problems/factorial-trailing-zeroes) | Easy | -| 173 | [Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator "二叉搜索树迭代器") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-search-tree-iterator) | Medium | -| 174 | [Dungeon Game](https://leetcode.com/problems/dungeon-game "地下城游戏") | [Go](https://github.com/openset/leetcode/tree/master/problems/dungeon-game) | Hard | -| 175 | [Combine Two Tables](https://leetcode.com/problems/combine-two-tables "组合两个表") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/combine-two-tables) | Easy | -| 176 | [Second Highest Salary](https://leetcode.com/problems/second-highest-salary "第二高的薪水") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/second-highest-salary) | Easy | -| 177 | [Nth Highest Salary](https://leetcode.com/problems/nth-highest-salary "第N高的薪水") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/nth-highest-salary) | Medium | -| 178 | [Rank Scores](https://leetcode.com/problems/rank-scores "分数排名") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/rank-scores) | Medium | -| 179 | [Largest Number](https://leetcode.com/problems/largest-number "最大数") | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-number) | Medium | -| 180 | [Consecutive Numbers](https://leetcode.com/problems/consecutive-numbers "连续出现的数字") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/consecutive-numbers) | Medium | -| 181 | [Employees Earning More Than Their Managers](https://leetcode.com/problems/employees-earning-more-than-their-managers "超过经理收入的员工") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/employees-earning-more-than-their-managers) | Easy | -| 182 | [Duplicate Emails](https://leetcode.com/problems/duplicate-emails "查找重复的电子邮箱") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/duplicate-emails) | Easy | -| 183 | [Customers Who Never Order](https://leetcode.com/problems/customers-who-never-order "从不订购的客户") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/customers-who-never-order) | Easy | -| 184 | [Department Highest Salary](https://leetcode.com/problems/department-highest-salary "部门工资最高的员工") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/department-highest-salary) | Medium | -| 185 | [Department Top Three Salaries](https://leetcode.com/problems/department-top-three-salaries "部门工资前三高的所有员工") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/department-top-three-salaries) | Hard | -| 186 | [Reverse Words in a String II](https://leetcode.com/problems/reverse-words-in-a-string-ii "翻转字符串里的单词 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/reverse-words-in-a-string-ii) | Medium | -| 187 | [Repeated DNA Sequences](https://leetcode.com/problems/repeated-dna-sequences "重复的DNA序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/repeated-dna-sequences) | Medium | -| 188 | [Best Time to Buy and Sell Stock IV](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv "买卖股票的最佳时机 IV") | [Go](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-iv) | Hard | -| 189 | [Rotate Array](https://leetcode.com/problems/rotate-array "旋转数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/rotate-array) | Easy | -| 190 | [Reverse Bits](https://leetcode.com/problems/reverse-bits "颠倒二进制位") | [Go](https://github.com/openset/leetcode/tree/master/problems/reverse-bits) | Easy | -| 191 | [Number of 1 Bits](https://leetcode.com/problems/number-of-1-bits "位1的个数") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-1-bits) | Easy | -| 192 | [Word Frequency](https://leetcode.com/problems/word-frequency "统计词频") | [Bash](https://github.com/openset/leetcode/tree/master/problems/word-frequency) | Medium | -| 193 | [Valid Phone Numbers](https://leetcode.com/problems/valid-phone-numbers "有效电话号码") | [Bash](https://github.com/openset/leetcode/tree/master/problems/valid-phone-numbers) | Easy | -| 194 | [Transpose File](https://leetcode.com/problems/transpose-file "转置文件") | [Bash](https://github.com/openset/leetcode/tree/master/problems/transpose-file) | Medium | -| 195 | [Tenth Line](https://leetcode.com/problems/tenth-line "第十行") | [Bash](https://github.com/openset/leetcode/tree/master/problems/tenth-line) | Easy | -| 196 | [Delete Duplicate Emails](https://leetcode.com/problems/delete-duplicate-emails "删除重复的电子邮箱") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/delete-duplicate-emails) | Easy | -| 197 | [Rising Temperature](https://leetcode.com/problems/rising-temperature "上升的温度") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/rising-temperature) | Easy | -| 198 | [House Robber](https://leetcode.com/problems/house-robber "打家劫舍") | [Go](https://github.com/openset/leetcode/tree/master/problems/house-robber) | Easy | -| 199 | [Binary Tree Right Side View](https://leetcode.com/problems/binary-tree-right-side-view "二叉树的右视图") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-right-side-view) | Medium | -| 200 | [Number of Islands](https://leetcode.com/problems/number-of-islands "岛屿数量") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-islands) | Medium | -| 201 | [Bitwise AND of Numbers Range](https://leetcode.com/problems/bitwise-and-of-numbers-range "数字范围按位与") | [Go](https://github.com/openset/leetcode/tree/master/problems/bitwise-and-of-numbers-range) | Medium | -| 202 | [Happy Number](https://leetcode.com/problems/happy-number "快乐数") | [Go](https://github.com/openset/leetcode/tree/master/problems/happy-number) | Easy | -| 203 | [Remove Linked List Elements](https://leetcode.com/problems/remove-linked-list-elements "移除链表元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-linked-list-elements) | Easy | -| 204 | [Count Primes](https://leetcode.com/problems/count-primes "计数质数") | [Go](https://github.com/openset/leetcode/tree/master/problems/count-primes) | Easy | -| 205 | [Isomorphic Strings](https://leetcode.com/problems/isomorphic-strings "同构字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/isomorphic-strings) | Easy | -| 206 | [Reverse Linked List](https://leetcode.com/problems/reverse-linked-list "反转链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/reverse-linked-list) | Easy | -| 207 | [Course Schedule](https://leetcode.com/problems/course-schedule "课程表") | [Go](https://github.com/openset/leetcode/tree/master/problems/course-schedule) | Medium | -| 208 | [Implement Trie (Prefix Tree)](https://leetcode.com/problems/implement-trie-prefix-tree "实现 Trie (前缀树)") | [Go](https://github.com/openset/leetcode/tree/master/problems/implement-trie-prefix-tree) | Medium | -| 209 | [Minimum Size Subarray Sum](https://leetcode.com/problems/minimum-size-subarray-sum "长度最小的子数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-size-subarray-sum) | Medium | -| 210 | [Course Schedule II](https://leetcode.com/problems/course-schedule-ii "课程表 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/course-schedule-ii) | Medium | -| 211 | [Add and Search Word - Data structure design](https://leetcode.com/problems/add-and-search-word-data-structure-design "添加与搜索单词 - 数据结构设计") | [Go](https://github.com/openset/leetcode/tree/master/problems/add-and-search-word-data-structure-design) | Medium | -| 212 | [Word Search II](https://leetcode.com/problems/word-search-ii "单词搜索 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/word-search-ii) | Hard | -| 213 | [House Robber II](https://leetcode.com/problems/house-robber-ii "打家劫舍 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/house-robber-ii) | Medium | -| 214 | [Shortest Palindrome](https://leetcode.com/problems/shortest-palindrome "最短回文串") | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-palindrome) | Hard | -| 215 | [Kth Largest Element in an Array](https://leetcode.com/problems/kth-largest-element-in-an-array "数组中的第K个最大元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/kth-largest-element-in-an-array) | Medium | -| 216 | [Combination Sum III](https://leetcode.com/problems/combination-sum-iii "组合总和 III") | [Go](https://github.com/openset/leetcode/tree/master/problems/combination-sum-iii) | Medium | -| 217 | [Contains Duplicate](https://leetcode.com/problems/contains-duplicate "存在重复元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate) | Easy | -| 218 | [The Skyline Problem](https://leetcode.com/problems/the-skyline-problem "天际线问题") | [Go](https://github.com/openset/leetcode/tree/master/problems/the-skyline-problem) | Hard | -| 219 | [Contains Duplicate II](https://leetcode.com/problems/contains-duplicate-ii "存在重复元素 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate-ii) | Easy | -| 220 | [Contains Duplicate III](https://leetcode.com/problems/contains-duplicate-iii "存在重复元素 III") | [Go](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate-iii) | Medium | -| 221 | [Maximal Square](https://leetcode.com/problems/maximal-square "最大正方形") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximal-square) | Medium | -| 222 | [Count Complete Tree Nodes](https://leetcode.com/problems/count-complete-tree-nodes "完全二叉树的节点个数") | [Go](https://github.com/openset/leetcode/tree/master/problems/count-complete-tree-nodes) | Medium | -| 223 | [Rectangle Area](https://leetcode.com/problems/rectangle-area "矩形面积") | [Go](https://github.com/openset/leetcode/tree/master/problems/rectangle-area) | Medium | -| 224 | [Basic Calculator](https://leetcode.com/problems/basic-calculator "基本计算器") | [Go](https://github.com/openset/leetcode/tree/master/problems/basic-calculator) | Hard | -| 225 | [Implement Stack using Queues](https://leetcode.com/problems/implement-stack-using-queues "用队列实现栈") | [Go](https://github.com/openset/leetcode/tree/master/problems/implement-stack-using-queues) | Easy | -| 226 | [Invert Binary Tree](https://leetcode.com/problems/invert-binary-tree "翻转二叉树") | [Go](https://github.com/openset/leetcode/tree/master/problems/invert-binary-tree) | Easy | -| 227 | [Basic Calculator II](https://leetcode.com/problems/basic-calculator-ii "基本计算器 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-ii) | Medium | -| 228 | [Summary Ranges](https://leetcode.com/problems/summary-ranges "汇总区间") | [Go](https://github.com/openset/leetcode/tree/master/problems/summary-ranges) | Medium | -| 229 | [Majority Element II](https://leetcode.com/problems/majority-element-ii "求众数 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/majority-element-ii) | Medium | -| 230 | [Kth Smallest Element in a BST](https://leetcode.com/problems/kth-smallest-element-in-a-bst "二叉搜索树中第K小的元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-element-in-a-bst) | Medium | -| 231 | [Power of Two](https://leetcode.com/problems/power-of-two "2的幂") | [Go](https://github.com/openset/leetcode/tree/master/problems/power-of-two) | Easy | -| 232 | [Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks "用栈实现队列") | [Go](https://github.com/openset/leetcode/tree/master/problems/implement-queue-using-stacks) | Easy | -| 233 | [Number of Digit One](https://leetcode.com/problems/number-of-digit-one "数字 1 的个数") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-digit-one) | Hard | -| 234 | [Palindrome Linked List](https://leetcode.com/problems/palindrome-linked-list "回文链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/palindrome-linked-list) | Easy | -| 235 | [Lowest Common Ancestor of a Binary Search Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree "二叉搜索树的最近公共祖先") | [Go](https://github.com/openset/leetcode/tree/master/problems/lowest-common-ancestor-of-a-binary-search-tree) | Easy | -| 236 | [Lowest Common Ancestor of a Binary Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree "二叉树的最近公共祖先") | [Go](https://github.com/openset/leetcode/tree/master/problems/lowest-common-ancestor-of-a-binary-tree) | Medium | -| 237 | [Delete Node in a Linked List](https://leetcode.com/problems/delete-node-in-a-linked-list "删除链表中的节点") | [Go](https://github.com/openset/leetcode/tree/master/problems/delete-node-in-a-linked-list) | Easy | -| 238 | [Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self "除自身以外数组的乘积") | [Go](https://github.com/openset/leetcode/tree/master/problems/product-of-array-except-self) | Medium | -| 239 | [Sliding Window Maximum](https://leetcode.com/problems/sliding-window-maximum "滑动窗口最大值") | [Go](https://github.com/openset/leetcode/tree/master/problems/sliding-window-maximum) | Hard | -| 240 | [Search a 2D Matrix II](https://leetcode.com/problems/search-a-2d-matrix-ii "搜索二维矩阵 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/search-a-2d-matrix-ii) | Medium | -| 241 | [Different Ways to Add Parentheses](https://leetcode.com/problems/different-ways-to-add-parentheses "为运算表达式设计优先级") | [Go](https://github.com/openset/leetcode/tree/master/problems/different-ways-to-add-parentheses) | Medium | -| 242 | [Valid Anagram](https://leetcode.com/problems/valid-anagram "有效的字母异位词") | [Go](https://github.com/openset/leetcode/tree/master/problems/valid-anagram) | Easy | -| 243 | [Shortest Word Distance](https://leetcode.com/problems/shortest-word-distance "最短单词距离") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance) | Easy | -| 244 | [Shortest Word Distance II](https://leetcode.com/problems/shortest-word-distance-ii "最短单词距离 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance-ii) | Medium | -| 245 | [Shortest Word Distance III](https://leetcode.com/problems/shortest-word-distance-iii "最短单词距离 III") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance-iii) | Medium | -| 246 | [Strobogrammatic Number](https://leetcode.com/problems/strobogrammatic-number "中心对称数") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number) | Easy | -| 247 | [Strobogrammatic Number II](https://leetcode.com/problems/strobogrammatic-number-ii "中心对称数 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number-ii) | Medium | -| 248 | [Strobogrammatic Number III](https://leetcode.com/problems/strobogrammatic-number-iii "中心对称数 III") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number-iii) | Hard | -| 249 | [Group Shifted Strings](https://leetcode.com/problems/group-shifted-strings "移位字符串分组") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/group-shifted-strings) | Medium | -| 250 | [Count Univalue Subtrees](https://leetcode.com/problems/count-univalue-subtrees "统计同值子树") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/count-univalue-subtrees) | Medium | -| 251 | [Flatten 2D Vector](https://leetcode.com/problems/flatten-2d-vector "展开二维向量") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/flatten-2d-vector) | Medium | -| 252 | [Meeting Rooms](https://leetcode.com/problems/meeting-rooms "会议室") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/meeting-rooms) | Easy | -| 253 | [Meeting Rooms II](https://leetcode.com/problems/meeting-rooms-ii "会议室 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/meeting-rooms-ii) | Medium | -| 254 | [Factor Combinations](https://leetcode.com/problems/factor-combinations "因子的组合") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/factor-combinations) | Medium | -| 255 | [Verify Preorder Sequence in Binary Search Tree](https://leetcode.com/problems/verify-preorder-sequence-in-binary-search-tree "验证前序遍历序列二叉搜索树") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/verify-preorder-sequence-in-binary-search-tree) | Medium | -| 256 | [Paint House](https://leetcode.com/problems/paint-house "粉刷房子") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/paint-house) | Easy | -| 257 | [Binary Tree Paths](https://leetcode.com/problems/binary-tree-paths "二叉树的所有路径") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-paths) | Easy | -| 258 | [Add Digits](https://leetcode.com/problems/add-digits "各位相加") | [Go](https://github.com/openset/leetcode/tree/master/problems/add-digits) | Easy | -| 259 | [3Sum Smaller](https://leetcode.com/problems/3sum-smaller "较小的三数之和") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/3sum-smaller) | Medium | -| 260 | [Single Number III](https://leetcode.com/problems/single-number-iii "只出现一次的数字 III") | [Go](https://github.com/openset/leetcode/tree/master/problems/single-number-iii) | Medium | -| 261 | [Graph Valid Tree](https://leetcode.com/problems/graph-valid-tree "以图判树") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/graph-valid-tree) | Medium | -| 262 | [Trips and Users](https://leetcode.com/problems/trips-and-users "行程和用户") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/trips-and-users) | Hard | -| 263 | [Ugly Number](https://leetcode.com/problems/ugly-number "丑数") | [Go](https://github.com/openset/leetcode/tree/master/problems/ugly-number) | Easy | -| 264 | [Ugly Number II](https://leetcode.com/problems/ugly-number-ii "丑数 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/ugly-number-ii) | Medium | -| 265 | [Paint House II](https://leetcode.com/problems/paint-house-ii "粉刷房子 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/paint-house-ii) | Hard | -| 266 | [Palindrome Permutation](https://leetcode.com/problems/palindrome-permutation "回文排列") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/palindrome-permutation) | Easy | -| 267 | [Palindrome Permutation II](https://leetcode.com/problems/palindrome-permutation-ii "回文排列 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/palindrome-permutation-ii) | Medium | -| 268 | [Missing Number](https://leetcode.com/problems/missing-number "缺失数字") | [Go](https://github.com/openset/leetcode/tree/master/problems/missing-number) | Easy | -| 269 | [Alien Dictionary](https://leetcode.com/problems/alien-dictionary "火星词典") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/alien-dictionary) | Hard | -| 270 | [Closest Binary Search Tree Value](https://leetcode.com/problems/closest-binary-search-tree-value "最接近的二叉搜索树值") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/closest-binary-search-tree-value) | Easy | -| 271 | [Encode and Decode Strings](https://leetcode.com/problems/encode-and-decode-strings "字符串的编码与解码") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/encode-and-decode-strings) | Medium | -| 272 | [Closest Binary Search Tree Value II](https://leetcode.com/problems/closest-binary-search-tree-value-ii "最接近的二叉搜索树值 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/closest-binary-search-tree-value-ii) | Hard | -| 273 | [Integer to English Words](https://leetcode.com/problems/integer-to-english-words "整数转换英文表示") | [Go](https://github.com/openset/leetcode/tree/master/problems/integer-to-english-words) | Hard | -| 274 | [H-Index](https://leetcode.com/problems/h-index "H指数") | [Go](https://github.com/openset/leetcode/tree/master/problems/h-index) | Medium | -| 275 | [H-Index II](https://leetcode.com/problems/h-index-ii "H指数 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/h-index-ii) | Medium | -| 276 | [Paint Fence](https://leetcode.com/problems/paint-fence "栅栏涂色") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/paint-fence) | Easy | -| 277 | [Find the Celebrity](https://leetcode.com/problems/find-the-celebrity "搜寻名人") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/find-the-celebrity) | Medium | -| 278 | [First Bad Version](https://leetcode.com/problems/first-bad-version "第一个错误的版本") | [Go](https://github.com/openset/leetcode/tree/master/problems/first-bad-version) | Easy | -| 279 | [Perfect Squares](https://leetcode.com/problems/perfect-squares "完全平方数") | [Go](https://github.com/openset/leetcode/tree/master/problems/perfect-squares) | Medium | -| 280 | [Wiggle Sort](https://leetcode.com/problems/wiggle-sort "摆动排序") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/wiggle-sort) | Medium | -| 281 | [Zigzag Iterator](https://leetcode.com/problems/zigzag-iterator "锯齿迭代器") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/zigzag-iterator) | Medium | -| 282 | [Expression Add Operators](https://leetcode.com/problems/expression-add-operators "给表达式添加运算符") | [Go](https://github.com/openset/leetcode/tree/master/problems/expression-add-operators) | Hard | -| 283 | [Move Zeroes](https://leetcode.com/problems/move-zeroes "移动零") | [Go](https://github.com/openset/leetcode/tree/master/problems/move-zeroes) | Easy | -| 284 | [Peeking Iterator](https://leetcode.com/problems/peeking-iterator "顶端迭代器") | [Go](https://github.com/openset/leetcode/tree/master/problems/peeking-iterator) | Medium | -| 285 | [Inorder Successor in BST](https://leetcode.com/problems/inorder-successor-in-bst "二叉搜索树中的顺序后继") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/inorder-successor-in-bst) | Medium | -| 286 | [Walls and Gates](https://leetcode.com/problems/walls-and-gates "墙与门") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/walls-and-gates) | Medium | -| 287 | [Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number "寻找重复数") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-the-duplicate-number) | Medium | -| 288 | [Unique Word Abbreviation](https://leetcode.com/problems/unique-word-abbreviation "单词的唯一缩写") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/unique-word-abbreviation) | Medium | -| 289 | [Game of Life](https://leetcode.com/problems/game-of-life "生命游戏") | [Go](https://github.com/openset/leetcode/tree/master/problems/game-of-life) | Medium | -| 290 | [Word Pattern](https://leetcode.com/problems/word-pattern "单词规律") | [Go](https://github.com/openset/leetcode/tree/master/problems/word-pattern) | Easy | -| 291 | [Word Pattern II](https://leetcode.com/problems/word-pattern-ii "单词规律 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/word-pattern-ii) | Hard | -| 292 | [Nim Game](https://leetcode.com/problems/nim-game "Nim 游戏") | [Go](https://github.com/openset/leetcode/tree/master/problems/nim-game) | Easy | -| 293 | [Flip Game](https://leetcode.com/problems/flip-game "翻转游戏") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/flip-game) | Easy | -| 294 | [Flip Game II](https://leetcode.com/problems/flip-game-ii "翻转游戏 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/flip-game-ii) | Medium | -| 295 | [Find Median from Data Stream](https://leetcode.com/problems/find-median-from-data-stream "数据流的中位数") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-median-from-data-stream) | Hard | -| 296 | [Best Meeting Point](https://leetcode.com/problems/best-meeting-point "最佳的碰头地点") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/best-meeting-point) | Hard | -| 297 | [Serialize and Deserialize Binary Tree](https://leetcode.com/problems/serialize-and-deserialize-binary-tree "二叉树的序列化与反序列化") | [Go](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-binary-tree) | Hard | -| 298 | [Binary Tree Longest Consecutive Sequence](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence "二叉树最长连续序列") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-longest-consecutive-sequence) | Medium | -| 299 | [Bulls and Cows](https://leetcode.com/problems/bulls-and-cows "猜数字游戏") | [Go](https://github.com/openset/leetcode/tree/master/problems/bulls-and-cows) | Easy | -| 300 | [Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence "最长上升子序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-increasing-subsequence) | Medium | +| 1 | [Two Sum](https://leetcode.com/problems/two-sum "两数之和") | [Go](../problems/two-sum) | Easy | +| 2 | [Add Two Numbers](https://leetcode.com/problems/add-two-numbers "两数相加") | [Go](../problems/add-two-numbers) | Medium | +| 3 | [Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters "无重复字符的最长子串") | [Go](../problems/longest-substring-without-repeating-characters) | Medium | +| 4 | [Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays "寻找两个有序数组的中位数") | [Go](../problems/median-of-two-sorted-arrays) | Hard | +| 5 | [Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring "最长回文子串") | [Go](../problems/longest-palindromic-substring) | Medium | +| 6 | [ZigZag Conversion](https://leetcode.com/problems/zigzag-conversion "Z 字形变换") | [Go](../problems/zigzag-conversion) | Medium | +| 7 | [Reverse Integer](https://leetcode.com/problems/reverse-integer "整数反转") | [Go](../problems/reverse-integer) | Easy | +| 8 | [String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-atoi "字符串转换整数 (atoi)") | [Go](../problems/string-to-integer-atoi) | Medium | +| 9 | [Palindrome Number](https://leetcode.com/problems/palindrome-number "回文数") | [Go](../problems/palindrome-number) | Easy | +| 10 | [Regular Expression Matching](https://leetcode.com/problems/regular-expression-matching "正则表达式匹配") | [Go](../problems/regular-expression-matching) | Hard | +| 11 | [Container With Most Water](https://leetcode.com/problems/container-with-most-water "盛最多水的容器") | [Go](../problems/container-with-most-water) | Medium | +| 12 | [Integer to Roman](https://leetcode.com/problems/integer-to-roman "整数转罗马数字") | [Go](../problems/integer-to-roman) | Medium | +| 13 | [Roman to Integer](https://leetcode.com/problems/roman-to-integer "罗马数字转整数") | [Go](../problems/roman-to-integer) | Easy | +| 14 | [Longest Common Prefix](https://leetcode.com/problems/longest-common-prefix "最长公共前缀") | [Go](../problems/longest-common-prefix) | Easy | +| 15 | [3Sum](https://leetcode.com/problems/3sum "三数之和") | [Go](../problems/3sum) | Medium | +| 16 | [3Sum Closest](https://leetcode.com/problems/3sum-closest "最接近的三数之和") | [Go](../problems/3sum-closest) | Medium | +| 17 | [Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number "电话号码的字母组合") | [Go](../problems/letter-combinations-of-a-phone-number) | Medium | +| 18 | [4Sum](https://leetcode.com/problems/4sum "四数之和") | [Go](../problems/4sum) | Medium | +| 19 | [Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list "删除链表的倒数第N个节点") | [Go](../problems/remove-nth-node-from-end-of-list) | Medium | +| 20 | [Valid Parentheses](https://leetcode.com/problems/valid-parentheses "有效的括号") | [Go](../problems/valid-parentheses) | Easy | +| 21 | [Merge Two Sorted Lists](https://leetcode.com/problems/merge-two-sorted-lists "合并两个有序链表") | [Go](../problems/merge-two-sorted-lists) | Easy | +| 22 | [Generate Parentheses](https://leetcode.com/problems/generate-parentheses "括号生成") | [Go](../problems/generate-parentheses) | Medium | +| 23 | [Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists "合并K个排序链表") | [Go](../problems/merge-k-sorted-lists) | Hard | +| 24 | [Swap Nodes in Pairs](https://leetcode.com/problems/swap-nodes-in-pairs "两两交换链表中的节点") | [Go](../problems/swap-nodes-in-pairs) | Medium | +| 25 | [Reverse Nodes in k-Group](https://leetcode.com/problems/reverse-nodes-in-k-group "K 个一组翻转链表") | [Go](../problems/reverse-nodes-in-k-group) | Hard | +| 26 | [Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array "删除排序数组中的重复项") | [Go](../problems/remove-duplicates-from-sorted-array) | Easy | +| 27 | [Remove Element](https://leetcode.com/problems/remove-element "移除元素") | [Go](../problems/remove-element) | Easy | +| 28 | [Implement strStr()](https://leetcode.com/problems/implement-strstr "实现 strStr()") | [Go](../problems/implement-strstr) | Easy | +| 29 | [Divide Two Integers](https://leetcode.com/problems/divide-two-integers "两数相除") | [Go](../problems/divide-two-integers) | Medium | +| 30 | [Substring with Concatenation of All Words](https://leetcode.com/problems/substring-with-concatenation-of-all-words "串联所有单词的子串") | [Go](../problems/substring-with-concatenation-of-all-words) | Hard | +| 31 | [Next Permutation](https://leetcode.com/problems/next-permutation "下一个排列") | [Go](../problems/next-permutation) | Medium | +| 32 | [Longest Valid Parentheses](https://leetcode.com/problems/longest-valid-parentheses "最长有效括号") | [Go](../problems/longest-valid-parentheses) | Hard | +| 33 | [Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array "搜索旋转排序数组") | [Go](../problems/search-in-rotated-sorted-array) | Medium | +| 34 | [Find First and Last Position of Element in Sorted Array](https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array "在排序数组中查找元素的第一个和最后一个位置") | [Go](../problems/find-first-and-last-position-of-element-in-sorted-array) | Medium | +| 35 | [Search Insert Position](https://leetcode.com/problems/search-insert-position "搜索插入位置") | [Go](../problems/search-insert-position) | Easy | +| 36 | [Valid Sudoku](https://leetcode.com/problems/valid-sudoku "有效的数独") | [Go](../problems/valid-sudoku) | Medium | +| 37 | [Sudoku Solver](https://leetcode.com/problems/sudoku-solver "解数独") | [Go](../problems/sudoku-solver) | Hard | +| 38 | [Count and Say](https://leetcode.com/problems/count-and-say "报数") | [Go](../problems/count-and-say) | Easy | +| 39 | [Combination Sum](https://leetcode.com/problems/combination-sum "组合总和") | [Go](../problems/combination-sum) | Medium | +| 40 | [Combination Sum II](https://leetcode.com/problems/combination-sum-ii "组合总和 II") | [Go](../problems/combination-sum-ii) | Medium | +| 41 | [First Missing Positive](https://leetcode.com/problems/first-missing-positive "缺失的第一个正数") | [Go](../problems/first-missing-positive) | Hard | +| 42 | [Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water "接雨水") | [Go](../problems/trapping-rain-water) | Hard | +| 43 | [Multiply Strings](https://leetcode.com/problems/multiply-strings "字符串相乘") | [Go](../problems/multiply-strings) | Medium | +| 44 | [Wildcard Matching](https://leetcode.com/problems/wildcard-matching "通配符匹配") | [Go](../problems/wildcard-matching) | Hard | +| 45 | [Jump Game II](https://leetcode.com/problems/jump-game-ii "跳跃游戏 II") | [Go](../problems/jump-game-ii) | Hard | +| 46 | [Permutations](https://leetcode.com/problems/permutations "全排列") | [Go](../problems/permutations) | Medium | +| 47 | [Permutations II](https://leetcode.com/problems/permutations-ii "全排列 II") | [Go](../problems/permutations-ii) | Medium | +| 48 | [Rotate Image](https://leetcode.com/problems/rotate-image "旋转图像") | [Go](../problems/rotate-image) | Medium | +| 49 | [Group Anagrams](https://leetcode.com/problems/group-anagrams "字母异位词分组") | [Go](../problems/group-anagrams) | Medium | +| 50 | [Pow(x, n)](https://leetcode.com/problems/powx-n "Pow(x, n)") | [Go](../problems/powx-n) | Medium | +| 51 | [N-Queens](https://leetcode.com/problems/n-queens "N皇后") | [Go](../problems/n-queens) | Hard | +| 52 | [N-Queens II](https://leetcode.com/problems/n-queens-ii "N皇后 II") | [Go](../problems/n-queens-ii) | Hard | +| 53 | [Maximum Subarray](https://leetcode.com/problems/maximum-subarray "最大子序和") | [Go](../problems/maximum-subarray) | Easy | +| 54 | [Spiral Matrix](https://leetcode.com/problems/spiral-matrix "螺旋矩阵") | [Go](../problems/spiral-matrix) | Medium | +| 55 | [Jump Game](https://leetcode.com/problems/jump-game "跳跃游戏") | [Go](../problems/jump-game) | Medium | +| 56 | [Merge Intervals](https://leetcode.com/problems/merge-intervals "合并区间") | [Go](../problems/merge-intervals) | Medium | +| 57 | [Insert Interval](https://leetcode.com/problems/insert-interval "插入区间") | [Go](../problems/insert-interval) | Hard | +| 58 | [Length of Last Word](https://leetcode.com/problems/length-of-last-word "最后一个单词的长度") | [Go](../problems/length-of-last-word) | Easy | +| 59 | [Spiral Matrix II](https://leetcode.com/problems/spiral-matrix-ii "螺旋矩阵 II") | [Go](../problems/spiral-matrix-ii) | Medium | +| 60 | [Permutation Sequence](https://leetcode.com/problems/permutation-sequence "第k个排列") | [Go](../problems/permutation-sequence) | Medium | +| 61 | [Rotate List](https://leetcode.com/problems/rotate-list "旋转链表") | [Go](../problems/rotate-list) | Medium | +| 62 | [Unique Paths](https://leetcode.com/problems/unique-paths "不同路径") | [Go](../problems/unique-paths) | Medium | +| 63 | [Unique Paths II](https://leetcode.com/problems/unique-paths-ii "不同路径 II") | [Go](../problems/unique-paths-ii) | Medium | +| 64 | [Minimum Path Sum](https://leetcode.com/problems/minimum-path-sum "最小路径和") | [Go](../problems/minimum-path-sum) | Medium | +| 65 | [Valid Number](https://leetcode.com/problems/valid-number "有效数字") | [Go](../problems/valid-number) | Hard | +| 66 | [Plus One](https://leetcode.com/problems/plus-one "加一") | [Go](../problems/plus-one) | Easy | +| 67 | [Add Binary](https://leetcode.com/problems/add-binary "二进制求和") | [Go](../problems/add-binary) | Easy | +| 68 | [Text Justification](https://leetcode.com/problems/text-justification "文本左右对齐") | [Go](../problems/text-justification) | Hard | +| 69 | [Sqrt(x)](https://leetcode.com/problems/sqrtx "x 的平方根") | [Go](../problems/sqrtx) | Easy | +| 70 | [Climbing Stairs](https://leetcode.com/problems/climbing-stairs "爬楼梯") | [Go](../problems/climbing-stairs) | Easy | +| 71 | [Simplify Path](https://leetcode.com/problems/simplify-path "简化路径") | [Go](../problems/simplify-path) | Medium | +| 72 | [Edit Distance](https://leetcode.com/problems/edit-distance "编辑距离") | [Go](../problems/edit-distance) | Hard | +| 73 | [Set Matrix Zeroes](https://leetcode.com/problems/set-matrix-zeroes "矩阵置零") | [Go](../problems/set-matrix-zeroes) | Medium | +| 74 | [Search a 2D Matrix](https://leetcode.com/problems/search-a-2d-matrix "搜索二维矩阵") | [Go](../problems/search-a-2d-matrix) | Medium | +| 75 | [Sort Colors](https://leetcode.com/problems/sort-colors "颜色分类") | [Go](../problems/sort-colors) | Medium | +| 76 | [Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring "最小覆盖子串") | [Go](../problems/minimum-window-substring) | Hard | +| 77 | [Combinations](https://leetcode.com/problems/combinations "组合") | [Go](../problems/combinations) | Medium | +| 78 | [Subsets](https://leetcode.com/problems/subsets "子集") | [Go](../problems/subsets) | Medium | +| 79 | [Word Search](https://leetcode.com/problems/word-search "单词搜索") | [Go](../problems/word-search) | Medium | +| 80 | [Remove Duplicates from Sorted Array II](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii "删除排序数组中的重复项 II") | [Go](../problems/remove-duplicates-from-sorted-array-ii) | Medium | +| 81 | [Search in Rotated Sorted Array II](https://leetcode.com/problems/search-in-rotated-sorted-array-ii "搜索旋转排序数组 II") | [Go](../problems/search-in-rotated-sorted-array-ii) | Medium | +| 82 | [Remove Duplicates from Sorted List II](https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii "删除排序链表中的重复元素 II") | [Go](../problems/remove-duplicates-from-sorted-list-ii) | Medium | +| 83 | [Remove Duplicates from Sorted List](https://leetcode.com/problems/remove-duplicates-from-sorted-list "删除排序链表中的重复元素") | [Go](../problems/remove-duplicates-from-sorted-list) | Easy | +| 84 | [Largest Rectangle in Histogram](https://leetcode.com/problems/largest-rectangle-in-histogram "柱状图中最大的矩形") | [Go](../problems/largest-rectangle-in-histogram) | Hard | +| 85 | [Maximal Rectangle](https://leetcode.com/problems/maximal-rectangle "最大矩形") | [Go](../problems/maximal-rectangle) | Hard | +| 86 | [Partition List](https://leetcode.com/problems/partition-list "分隔链表") | [Go](../problems/partition-list) | Medium | +| 87 | [Scramble String](https://leetcode.com/problems/scramble-string "扰乱字符串") | [Go](../problems/scramble-string) | Hard | +| 88 | [Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array "合并两个有序数组") | [Go](../problems/merge-sorted-array) | Easy | +| 89 | [Gray Code](https://leetcode.com/problems/gray-code "格雷编码") | [Go](../problems/gray-code) | Medium | +| 90 | [Subsets II](https://leetcode.com/problems/subsets-ii "子集 II") | [Go](../problems/subsets-ii) | Medium | +| 91 | [Decode Ways](https://leetcode.com/problems/decode-ways "解码方法") | [Go](../problems/decode-ways) | Medium | +| 92 | [Reverse Linked List II](https://leetcode.com/problems/reverse-linked-list-ii "反转链表 II") | [Go](../problems/reverse-linked-list-ii) | Medium | +| 93 | [Restore IP Addresses](https://leetcode.com/problems/restore-ip-addresses "复原IP地址") | [Go](../problems/restore-ip-addresses) | Medium | +| 94 | [Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal "二叉树的中序遍历") | [Go](../problems/binary-tree-inorder-traversal) | Medium | +| 95 | [Unique Binary Search Trees II](https://leetcode.com/problems/unique-binary-search-trees-ii "不同的二叉搜索树 II") | [Go](../problems/unique-binary-search-trees-ii) | Medium | +| 96 | [Unique Binary Search Trees](https://leetcode.com/problems/unique-binary-search-trees "不同的二叉搜索树") | [Go](../problems/unique-binary-search-trees) | Medium | +| 97 | [Interleaving String](https://leetcode.com/problems/interleaving-string "交错字符串") | [Go](../problems/interleaving-string) | Hard | +| 98 | [Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree "验证二叉搜索树") | [Go](../problems/validate-binary-search-tree) | Medium | +| 99 | [Recover Binary Search Tree](https://leetcode.com/problems/recover-binary-search-tree "恢复二叉搜索树") | [Go](../problems/recover-binary-search-tree) | Hard | +| 100 | [Same Tree](https://leetcode.com/problems/same-tree "相同的树") | [Go](../problems/same-tree) | Easy | +| 101 | [Symmetric Tree](https://leetcode.com/problems/symmetric-tree "对称二叉树") | [Go](../problems/symmetric-tree) | Easy | +| 102 | [Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal "二叉树的层次遍历") | [Go](../problems/binary-tree-level-order-traversal) | Medium | +| 103 | [Binary Tree Zigzag Level Order Traversal](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal "二叉树的锯齿形层次遍历") | [Go](../problems/binary-tree-zigzag-level-order-traversal) | Medium | +| 104 | [Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree "二叉树的最大深度") | [Go](../problems/maximum-depth-of-binary-tree) | Easy | +| 105 | [Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal "从前序与中序遍历序列构造二叉树") | [Go](../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | Medium | +| 106 | [Construct Binary Tree from Inorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal "从中序与后序遍历序列构造二叉树") | [Go](../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | Medium | +| 107 | [Binary Tree Level Order Traversal II](https://leetcode.com/problems/binary-tree-level-order-traversal-ii "二叉树的层次遍历 II") | [Go](../problems/binary-tree-level-order-traversal-ii) | Easy | +| 108 | [Convert Sorted Array to Binary Search Tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree "将有序数组转换为二叉搜索树") | [Go](../problems/convert-sorted-array-to-binary-search-tree) | Easy | +| 109 | [Convert Sorted List to Binary Search Tree](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree "有序链表转换二叉搜索树") | [Go](../problems/convert-sorted-list-to-binary-search-tree) | Medium | +| 110 | [Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree "平衡二叉树") | [Go](../problems/balanced-binary-tree) | Easy | +| 111 | [Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree "二叉树的最小深度") | [Go](../problems/minimum-depth-of-binary-tree) | Easy | +| 112 | [Path Sum](https://leetcode.com/problems/path-sum "路径总和") | [Go](../problems/path-sum) | Easy | +| 113 | [Path Sum II](https://leetcode.com/problems/path-sum-ii "路径总和 II") | [Go](../problems/path-sum-ii) | Medium | +| 114 | [Flatten Binary Tree to Linked List](https://leetcode.com/problems/flatten-binary-tree-to-linked-list "二叉树展开为链表") | [Go](../problems/flatten-binary-tree-to-linked-list) | Medium | +| 115 | [Distinct Subsequences](https://leetcode.com/problems/distinct-subsequences "不同的子序列") | [Go](../problems/distinct-subsequences) | Hard | +| 116 | [Populating Next Right Pointers in Each Node](https://leetcode.com/problems/populating-next-right-pointers-in-each-node "填充每个节点的下一个右侧节点指针") | [Go](../problems/populating-next-right-pointers-in-each-node) | Medium | +| 117 | [Populating Next Right Pointers in Each Node II](https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii "填充每个节点的下一个右侧节点指针 II") | [Go](../problems/populating-next-right-pointers-in-each-node-ii) | Medium | +| 118 | [Pascal's Triangle](https://leetcode.com/problems/pascals-triangle "杨辉三角") | [Go](../problems/pascals-triangle) | Easy | +| 119 | [Pascal's Triangle II](https://leetcode.com/problems/pascals-triangle-ii "杨辉三角 II") | [Go](../problems/pascals-triangle-ii) | Easy | +| 120 | [Triangle](https://leetcode.com/problems/triangle "三角形最小路径和") | [Go](../problems/triangle) | Medium | +| 121 | [Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock "买卖股票的最佳时机") | [Go](../problems/best-time-to-buy-and-sell-stock) | Easy | +| 122 | [Best Time to Buy and Sell Stock II](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii "买卖股票的最佳时机 II") | [Go](../problems/best-time-to-buy-and-sell-stock-ii) | Easy | +| 123 | [Best Time to Buy and Sell Stock III](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii "买卖股票的最佳时机 III") | [Go](../problems/best-time-to-buy-and-sell-stock-iii) | Hard | +| 124 | [Binary Tree Maximum Path Sum](https://leetcode.com/problems/binary-tree-maximum-path-sum "二叉树中的最大路径和") | [Go](../problems/binary-tree-maximum-path-sum) | Hard | +| 125 | [Valid Palindrome](https://leetcode.com/problems/valid-palindrome "验证回文串") | [Go](../problems/valid-palindrome) | Easy | +| 126 | [Word Ladder II](https://leetcode.com/problems/word-ladder-ii "单词接龙 II") | [Go](../problems/word-ladder-ii) | Hard | +| 127 | [Word Ladder](https://leetcode.com/problems/word-ladder "单词接龙") | [Go](../problems/word-ladder) | Medium | +| 128 | [Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence "最长连续序列") | [Go](../problems/longest-consecutive-sequence) | Hard | +| 129 | [Sum Root to Leaf Numbers](https://leetcode.com/problems/sum-root-to-leaf-numbers "求根到叶子节点数字之和") | [Go](../problems/sum-root-to-leaf-numbers) | Medium | +| 130 | [Surrounded Regions](https://leetcode.com/problems/surrounded-regions "被围绕的区域") | [Go](../problems/surrounded-regions) | Medium | +| 131 | [Palindrome Partitioning](https://leetcode.com/problems/palindrome-partitioning "分割回文串") | [Go](../problems/palindrome-partitioning) | Medium | +| 132 | [Palindrome Partitioning II](https://leetcode.com/problems/palindrome-partitioning-ii "分割回文串 II") | [Go](../problems/palindrome-partitioning-ii) | Hard | +| 133 | [Clone Graph](https://leetcode.com/problems/clone-graph "克隆图") | [Go](../problems/clone-graph) | Medium | +| 134 | [Gas Station](https://leetcode.com/problems/gas-station "加油站") | [Go](../problems/gas-station) | Medium | +| 135 | [Candy](https://leetcode.com/problems/candy "分发糖果") | [Go](../problems/candy) | Hard | +| 136 | [Single Number](https://leetcode.com/problems/single-number "只出现一次的数字") | [Go](../problems/single-number) | Easy | +| 137 | [Single Number II](https://leetcode.com/problems/single-number-ii "只出现一次的数字 II") | [Go](../problems/single-number-ii) | Medium | +| 138 | [Copy List with Random Pointer](https://leetcode.com/problems/copy-list-with-random-pointer "复制带随机指针的链表") | [Go](../problems/copy-list-with-random-pointer) | Medium | +| 139 | [Word Break](https://leetcode.com/problems/word-break "单词拆分") | [Go](../problems/word-break) | Medium | +| 140 | [Word Break II](https://leetcode.com/problems/word-break-ii "单词拆分 II") | [Go](../problems/word-break-ii) | Hard | +| 141 | [Linked List Cycle](https://leetcode.com/problems/linked-list-cycle "环形链表") | [Go](../problems/linked-list-cycle) | Easy | +| 142 | [Linked List Cycle II](https://leetcode.com/problems/linked-list-cycle-ii "环形链表 II") | [Go](../problems/linked-list-cycle-ii) | Medium | +| 143 | [Reorder List](https://leetcode.com/problems/reorder-list "重排链表") | [Go](../problems/reorder-list) | Medium | +| 144 | [Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal "二叉树的前序遍历") | [Go](../problems/binary-tree-preorder-traversal) | Medium | +| 145 | [Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历") | [Go](../problems/binary-tree-postorder-traversal) | Hard | +| 146 | [LRU Cache](https://leetcode.com/problems/lru-cache "LRU缓存机制") | [Go](../problems/lru-cache) | Medium | +| 147 | [Insertion Sort List](https://leetcode.com/problems/insertion-sort-list "对链表进行插入排序") | [Go](../problems/insertion-sort-list) | Medium | +| 148 | [Sort List](https://leetcode.com/problems/sort-list "排序链表") | [Go](../problems/sort-list) | Medium | +| 149 | [Max Points on a Line](https://leetcode.com/problems/max-points-on-a-line "直线上最多的点数") | [Go](../problems/max-points-on-a-line) | Hard | +| 150 | [Evaluate Reverse Polish Notation](https://leetcode.com/problems/evaluate-reverse-polish-notation "逆波兰表达式求值") | [Go](../problems/evaluate-reverse-polish-notation) | Medium | +| 151 | [Reverse Words in a String](https://leetcode.com/problems/reverse-words-in-a-string "翻转字符串里的单词") | [Go](../problems/reverse-words-in-a-string) | Medium | +| 152 | [Maximum Product Subarray](https://leetcode.com/problems/maximum-product-subarray "乘积最大子序列") | [Go](../problems/maximum-product-subarray) | Medium | +| 153 | [Find Minimum in Rotated Sorted Array](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array "寻找旋转排序数组中的最小值") | [Go](../problems/find-minimum-in-rotated-sorted-array) | Medium | +| 154 | [Find Minimum in Rotated Sorted Array II](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii "寻找旋转排序数组中的最小值 II") | [Go](../problems/find-minimum-in-rotated-sorted-array-ii) | Hard | +| 155 | [Min Stack](https://leetcode.com/problems/min-stack "最小栈") | [Go](../problems/min-stack) | Easy | +| 156 | [Binary Tree Upside Down](https://leetcode.com/problems/binary-tree-upside-down "上下翻转二叉树") 🔒 | [Go](../problems/binary-tree-upside-down) | Medium | +| 157 | [Read N Characters Given Read4](https://leetcode.com/problems/read-n-characters-given-read4 "用 Read4 读取 N 个字符") 🔒 | [Go](../problems/read-n-characters-given-read4) | Easy | +| 158 | [Read N Characters Given Read4 II - Call multiple times](https://leetcode.com/problems/read-n-characters-given-read4-ii-call-multiple-times "用 Read4 读取 N 个字符 II") 🔒 | [Go](../problems/read-n-characters-given-read4-ii-call-multiple-times) | Hard | +| 159 | [Longest Substring with At Most Two Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters "至多包含两个不同字符的最长子串") 🔒 | [Go](../problems/longest-substring-with-at-most-two-distinct-characters) | Medium | +| 160 | [Intersection of Two Linked Lists](https://leetcode.com/problems/intersection-of-two-linked-lists "相交链表") | [Go](../problems/intersection-of-two-linked-lists) | Easy | +| 161 | [One Edit Distance](https://leetcode.com/problems/one-edit-distance "相隔为 1 的编辑距离") 🔒 | [Go](../problems/one-edit-distance) | Medium | +| 162 | [Find Peak Element](https://leetcode.com/problems/find-peak-element "寻找峰值") | [Go](../problems/find-peak-element) | Medium | +| 163 | [Missing Ranges](https://leetcode.com/problems/missing-ranges "缺失的区间") 🔒 | [Go](../problems/missing-ranges) | Medium | +| 164 | [Maximum Gap](https://leetcode.com/problems/maximum-gap "最大间距") | [Go](../problems/maximum-gap) | Hard | +| 165 | [Compare Version Numbers](https://leetcode.com/problems/compare-version-numbers "比较版本号") | [Go](../problems/compare-version-numbers) | Medium | +| 166 | [Fraction to Recurring Decimal](https://leetcode.com/problems/fraction-to-recurring-decimal "分数到小数") | [Go](../problems/fraction-to-recurring-decimal) | Medium | +| 167 | [Two Sum II - Input array is sorted](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted "两数之和 II - 输入有序数组") | [Go](../problems/two-sum-ii-input-array-is-sorted) | Easy | +| 168 | [Excel Sheet Column Title](https://leetcode.com/problems/excel-sheet-column-title "Excel表列名称") | [Go](../problems/excel-sheet-column-title) | Easy | +| 169 | [Majority Element](https://leetcode.com/problems/majority-element "多数元素") | [Go](../problems/majority-element) | Easy | +| 170 | [Two Sum III - Data structure design](https://leetcode.com/problems/two-sum-iii-data-structure-design "两数之和 III - 数据结构设计") 🔒 | [Go](../problems/two-sum-iii-data-structure-design) | Easy | +| 171 | [Excel Sheet Column Number](https://leetcode.com/problems/excel-sheet-column-number "Excel表列序号") | [Go](../problems/excel-sheet-column-number) | Easy | +| 172 | [Factorial Trailing Zeroes](https://leetcode.com/problems/factorial-trailing-zeroes "阶乘后的零") | [Go](../problems/factorial-trailing-zeroes) | Easy | +| 173 | [Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator "二叉搜索树迭代器") | [Go](../problems/binary-search-tree-iterator) | Medium | +| 174 | [Dungeon Game](https://leetcode.com/problems/dungeon-game "地下城游戏") | [Go](../problems/dungeon-game) | Hard | +| 175 | [Combine Two Tables](https://leetcode.com/problems/combine-two-tables "组合两个表") | [MySQL](../problems/combine-two-tables) | Easy | +| 176 | [Second Highest Salary](https://leetcode.com/problems/second-highest-salary "第二高的薪水") | [MySQL](../problems/second-highest-salary) | Easy | +| 177 | [Nth Highest Salary](https://leetcode.com/problems/nth-highest-salary "第N高的薪水") | [MySQL](../problems/nth-highest-salary) | Medium | +| 178 | [Rank Scores](https://leetcode.com/problems/rank-scores "分数排名") | [MySQL](../problems/rank-scores) | Medium | +| 179 | [Largest Number](https://leetcode.com/problems/largest-number "最大数") | [Go](../problems/largest-number) | Medium | +| 180 | [Consecutive Numbers](https://leetcode.com/problems/consecutive-numbers "连续出现的数字") | [MySQL](../problems/consecutive-numbers) | Medium | +| 181 | [Employees Earning More Than Their Managers](https://leetcode.com/problems/employees-earning-more-than-their-managers "超过经理收入的员工") | [MySQL](../problems/employees-earning-more-than-their-managers) | Easy | +| 182 | [Duplicate Emails](https://leetcode.com/problems/duplicate-emails "查找重复的电子邮箱") | [MySQL](../problems/duplicate-emails) | Easy | +| 183 | [Customers Who Never Order](https://leetcode.com/problems/customers-who-never-order "从不订购的客户") | [MySQL](../problems/customers-who-never-order) | Easy | +| 184 | [Department Highest Salary](https://leetcode.com/problems/department-highest-salary "部门工资最高的员工") | [MySQL](../problems/department-highest-salary) | Medium | +| 185 | [Department Top Three Salaries](https://leetcode.com/problems/department-top-three-salaries "部门工资前三高的所有员工") | [MySQL](../problems/department-top-three-salaries) | Hard | +| 186 | [Reverse Words in a String II](https://leetcode.com/problems/reverse-words-in-a-string-ii "翻转字符串里的单词 II") 🔒 | [Go](../problems/reverse-words-in-a-string-ii) | Medium | +| 187 | [Repeated DNA Sequences](https://leetcode.com/problems/repeated-dna-sequences "重复的DNA序列") | [Go](../problems/repeated-dna-sequences) | Medium | +| 188 | [Best Time to Buy and Sell Stock IV](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv "买卖股票的最佳时机 IV") | [Go](../problems/best-time-to-buy-and-sell-stock-iv) | Hard | +| 189 | [Rotate Array](https://leetcode.com/problems/rotate-array "旋转数组") | [Go](../problems/rotate-array) | Easy | +| 190 | [Reverse Bits](https://leetcode.com/problems/reverse-bits "颠倒二进制位") | [Go](../problems/reverse-bits) | Easy | +| 191 | [Number of 1 Bits](https://leetcode.com/problems/number-of-1-bits "位1的个数") | [Go](../problems/number-of-1-bits) | Easy | +| 192 | [Word Frequency](https://leetcode.com/problems/word-frequency "统计词频") | [Bash](../problems/word-frequency) | Medium | +| 193 | [Valid Phone Numbers](https://leetcode.com/problems/valid-phone-numbers "有效电话号码") | [Bash](../problems/valid-phone-numbers) | Easy | +| 194 | [Transpose File](https://leetcode.com/problems/transpose-file "转置文件") | [Bash](../problems/transpose-file) | Medium | +| 195 | [Tenth Line](https://leetcode.com/problems/tenth-line "第十行") | [Bash](../problems/tenth-line) | Easy | +| 196 | [Delete Duplicate Emails](https://leetcode.com/problems/delete-duplicate-emails "删除重复的电子邮箱") | [MySQL](../problems/delete-duplicate-emails) | Easy | +| 197 | [Rising Temperature](https://leetcode.com/problems/rising-temperature "上升的温度") | [MySQL](../problems/rising-temperature) | Easy | +| 198 | [House Robber](https://leetcode.com/problems/house-robber "打家劫舍") | [Go](../problems/house-robber) | Easy | +| 199 | [Binary Tree Right Side View](https://leetcode.com/problems/binary-tree-right-side-view "二叉树的右视图") | [Go](../problems/binary-tree-right-side-view) | Medium | +| 200 | [Number of Islands](https://leetcode.com/problems/number-of-islands "岛屿数量") | [Go](../problems/number-of-islands) | Medium | +| 201 | [Bitwise AND of Numbers Range](https://leetcode.com/problems/bitwise-and-of-numbers-range "数字范围按位与") | [Go](../problems/bitwise-and-of-numbers-range) | Medium | +| 202 | [Happy Number](https://leetcode.com/problems/happy-number "快乐数") | [Go](../problems/happy-number) | Easy | +| 203 | [Remove Linked List Elements](https://leetcode.com/problems/remove-linked-list-elements "移除链表元素") | [Go](../problems/remove-linked-list-elements) | Easy | +| 204 | [Count Primes](https://leetcode.com/problems/count-primes "计数质数") | [Go](../problems/count-primes) | Easy | +| 205 | [Isomorphic Strings](https://leetcode.com/problems/isomorphic-strings "同构字符串") | [Go](../problems/isomorphic-strings) | Easy | +| 206 | [Reverse Linked List](https://leetcode.com/problems/reverse-linked-list "反转链表") | [Go](../problems/reverse-linked-list) | Easy | +| 207 | [Course Schedule](https://leetcode.com/problems/course-schedule "课程表") | [Go](../problems/course-schedule) | Medium | +| 208 | [Implement Trie (Prefix Tree)](https://leetcode.com/problems/implement-trie-prefix-tree "实现 Trie (前缀树)") | [Go](../problems/implement-trie-prefix-tree) | Medium | +| 209 | [Minimum Size Subarray Sum](https://leetcode.com/problems/minimum-size-subarray-sum "长度最小的子数组") | [Go](../problems/minimum-size-subarray-sum) | Medium | +| 210 | [Course Schedule II](https://leetcode.com/problems/course-schedule-ii "课程表 II") | [Go](../problems/course-schedule-ii) | Medium | +| 211 | [Add and Search Word - Data structure design](https://leetcode.com/problems/add-and-search-word-data-structure-design "添加与搜索单词 - 数据结构设计") | [Go](../problems/add-and-search-word-data-structure-design) | Medium | +| 212 | [Word Search II](https://leetcode.com/problems/word-search-ii "单词搜索 II") | [Go](../problems/word-search-ii) | Hard | +| 213 | [House Robber II](https://leetcode.com/problems/house-robber-ii "打家劫舍 II") | [Go](../problems/house-robber-ii) | Medium | +| 214 | [Shortest Palindrome](https://leetcode.com/problems/shortest-palindrome "最短回文串") | [Go](../problems/shortest-palindrome) | Hard | +| 215 | [Kth Largest Element in an Array](https://leetcode.com/problems/kth-largest-element-in-an-array "数组中的第K个最大元素") | [Go](../problems/kth-largest-element-in-an-array) | Medium | +| 216 | [Combination Sum III](https://leetcode.com/problems/combination-sum-iii "组合总和 III") | [Go](../problems/combination-sum-iii) | Medium | +| 217 | [Contains Duplicate](https://leetcode.com/problems/contains-duplicate "存在重复元素") | [Go](../problems/contains-duplicate) | Easy | +| 218 | [The Skyline Problem](https://leetcode.com/problems/the-skyline-problem "天际线问题") | [Go](../problems/the-skyline-problem) | Hard | +| 219 | [Contains Duplicate II](https://leetcode.com/problems/contains-duplicate-ii "存在重复元素 II") | [Go](../problems/contains-duplicate-ii) | Easy | +| 220 | [Contains Duplicate III](https://leetcode.com/problems/contains-duplicate-iii "存在重复元素 III") | [Go](../problems/contains-duplicate-iii) | Medium | +| 221 | [Maximal Square](https://leetcode.com/problems/maximal-square "最大正方形") | [Go](../problems/maximal-square) | Medium | +| 222 | [Count Complete Tree Nodes](https://leetcode.com/problems/count-complete-tree-nodes "完全二叉树的节点个数") | [Go](../problems/count-complete-tree-nodes) | Medium | +| 223 | [Rectangle Area](https://leetcode.com/problems/rectangle-area "矩形面积") | [Go](../problems/rectangle-area) | Medium | +| 224 | [Basic Calculator](https://leetcode.com/problems/basic-calculator "基本计算器") | [Go](../problems/basic-calculator) | Hard | +| 225 | [Implement Stack using Queues](https://leetcode.com/problems/implement-stack-using-queues "用队列实现栈") | [Go](../problems/implement-stack-using-queues) | Easy | +| 226 | [Invert Binary Tree](https://leetcode.com/problems/invert-binary-tree "翻转二叉树") | [Go](../problems/invert-binary-tree) | Easy | +| 227 | [Basic Calculator II](https://leetcode.com/problems/basic-calculator-ii "基本计算器 II") | [Go](../problems/basic-calculator-ii) | Medium | +| 228 | [Summary Ranges](https://leetcode.com/problems/summary-ranges "汇总区间") | [Go](../problems/summary-ranges) | Medium | +| 229 | [Majority Element II](https://leetcode.com/problems/majority-element-ii "求众数 II") | [Go](../problems/majority-element-ii) | Medium | +| 230 | [Kth Smallest Element in a BST](https://leetcode.com/problems/kth-smallest-element-in-a-bst "二叉搜索树中第K小的元素") | [Go](../problems/kth-smallest-element-in-a-bst) | Medium | +| 231 | [Power of Two](https://leetcode.com/problems/power-of-two "2的幂") | [Go](../problems/power-of-two) | Easy | +| 232 | [Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks "用栈实现队列") | [Go](../problems/implement-queue-using-stacks) | Easy | +| 233 | [Number of Digit One](https://leetcode.com/problems/number-of-digit-one "数字 1 的个数") | [Go](../problems/number-of-digit-one) | Hard | +| 234 | [Palindrome Linked List](https://leetcode.com/problems/palindrome-linked-list "回文链表") | [Go](../problems/palindrome-linked-list) | Easy | +| 235 | [Lowest Common Ancestor of a Binary Search Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree "二叉搜索树的最近公共祖先") | [Go](../problems/lowest-common-ancestor-of-a-binary-search-tree) | Easy | +| 236 | [Lowest Common Ancestor of a Binary Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree "二叉树的最近公共祖先") | [Go](../problems/lowest-common-ancestor-of-a-binary-tree) | Medium | +| 237 | [Delete Node in a Linked List](https://leetcode.com/problems/delete-node-in-a-linked-list "删除链表中的节点") | [Go](../problems/delete-node-in-a-linked-list) | Easy | +| 238 | [Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self "除自身以外数组的乘积") | [Go](../problems/product-of-array-except-self) | Medium | +| 239 | [Sliding Window Maximum](https://leetcode.com/problems/sliding-window-maximum "滑动窗口最大值") | [Go](../problems/sliding-window-maximum) | Hard | +| 240 | [Search a 2D Matrix II](https://leetcode.com/problems/search-a-2d-matrix-ii "搜索二维矩阵 II") | [Go](../problems/search-a-2d-matrix-ii) | Medium | +| 241 | [Different Ways to Add Parentheses](https://leetcode.com/problems/different-ways-to-add-parentheses "为运算表达式设计优先级") | [Go](../problems/different-ways-to-add-parentheses) | Medium | +| 242 | [Valid Anagram](https://leetcode.com/problems/valid-anagram "有效的字母异位词") | [Go](../problems/valid-anagram) | Easy | +| 243 | [Shortest Word Distance](https://leetcode.com/problems/shortest-word-distance "最短单词距离") 🔒 | [Go](../problems/shortest-word-distance) | Easy | +| 244 | [Shortest Word Distance II](https://leetcode.com/problems/shortest-word-distance-ii "最短单词距离 II") 🔒 | [Go](../problems/shortest-word-distance-ii) | Medium | +| 245 | [Shortest Word Distance III](https://leetcode.com/problems/shortest-word-distance-iii "最短单词距离 III") 🔒 | [Go](../problems/shortest-word-distance-iii) | Medium | +| 246 | [Strobogrammatic Number](https://leetcode.com/problems/strobogrammatic-number "中心对称数") 🔒 | [Go](../problems/strobogrammatic-number) | Easy | +| 247 | [Strobogrammatic Number II](https://leetcode.com/problems/strobogrammatic-number-ii "中心对称数 II") 🔒 | [Go](../problems/strobogrammatic-number-ii) | Medium | +| 248 | [Strobogrammatic Number III](https://leetcode.com/problems/strobogrammatic-number-iii "中心对称数 III") 🔒 | [Go](../problems/strobogrammatic-number-iii) | Hard | +| 249 | [Group Shifted Strings](https://leetcode.com/problems/group-shifted-strings "移位字符串分组") 🔒 | [Go](../problems/group-shifted-strings) | Medium | +| 250 | [Count Univalue Subtrees](https://leetcode.com/problems/count-univalue-subtrees "统计同值子树") 🔒 | [Go](../problems/count-univalue-subtrees) | Medium | +| 251 | [Flatten 2D Vector](https://leetcode.com/problems/flatten-2d-vector "展开二维向量") 🔒 | [Go](../problems/flatten-2d-vector) | Medium | +| 252 | [Meeting Rooms](https://leetcode.com/problems/meeting-rooms "会议室") 🔒 | [Go](../problems/meeting-rooms) | Easy | +| 253 | [Meeting Rooms II](https://leetcode.com/problems/meeting-rooms-ii "会议室 II") 🔒 | [Go](../problems/meeting-rooms-ii) | Medium | +| 254 | [Factor Combinations](https://leetcode.com/problems/factor-combinations "因子的组合") 🔒 | [Go](../problems/factor-combinations) | Medium | +| 255 | [Verify Preorder Sequence in Binary Search Tree](https://leetcode.com/problems/verify-preorder-sequence-in-binary-search-tree "验证前序遍历序列二叉搜索树") 🔒 | [Go](../problems/verify-preorder-sequence-in-binary-search-tree) | Medium | +| 256 | [Paint House](https://leetcode.com/problems/paint-house "粉刷房子") 🔒 | [Go](../problems/paint-house) | Easy | +| 257 | [Binary Tree Paths](https://leetcode.com/problems/binary-tree-paths "二叉树的所有路径") | [Go](../problems/binary-tree-paths) | Easy | +| 258 | [Add Digits](https://leetcode.com/problems/add-digits "各位相加") | [Go](../problems/add-digits) | Easy | +| 259 | [3Sum Smaller](https://leetcode.com/problems/3sum-smaller "较小的三数之和") 🔒 | [Go](../problems/3sum-smaller) | Medium | +| 260 | [Single Number III](https://leetcode.com/problems/single-number-iii "只出现一次的数字 III") | [Go](../problems/single-number-iii) | Medium | +| 261 | [Graph Valid Tree](https://leetcode.com/problems/graph-valid-tree "以图判树") 🔒 | [Go](../problems/graph-valid-tree) | Medium | +| 262 | [Trips and Users](https://leetcode.com/problems/trips-and-users "行程和用户") | [MySQL](../problems/trips-and-users) | Hard | +| 263 | [Ugly Number](https://leetcode.com/problems/ugly-number "丑数") | [Go](../problems/ugly-number) | Easy | +| 264 | [Ugly Number II](https://leetcode.com/problems/ugly-number-ii "丑数 II") | [Go](../problems/ugly-number-ii) | Medium | +| 265 | [Paint House II](https://leetcode.com/problems/paint-house-ii "粉刷房子 II") 🔒 | [Go](../problems/paint-house-ii) | Hard | +| 266 | [Palindrome Permutation](https://leetcode.com/problems/palindrome-permutation "回文排列") 🔒 | [Go](../problems/palindrome-permutation) | Easy | +| 267 | [Palindrome Permutation II](https://leetcode.com/problems/palindrome-permutation-ii "回文排列 II") 🔒 | [Go](../problems/palindrome-permutation-ii) | Medium | +| 268 | [Missing Number](https://leetcode.com/problems/missing-number "缺失数字") | [Go](../problems/missing-number) | Easy | +| 269 | [Alien Dictionary](https://leetcode.com/problems/alien-dictionary "火星词典") 🔒 | [Go](../problems/alien-dictionary) | Hard | +| 270 | [Closest Binary Search Tree Value](https://leetcode.com/problems/closest-binary-search-tree-value "最接近的二叉搜索树值") 🔒 | [Go](../problems/closest-binary-search-tree-value) | Easy | +| 271 | [Encode and Decode Strings](https://leetcode.com/problems/encode-and-decode-strings "字符串的编码与解码") 🔒 | [Go](../problems/encode-and-decode-strings) | Medium | +| 272 | [Closest Binary Search Tree Value II](https://leetcode.com/problems/closest-binary-search-tree-value-ii "最接近的二叉搜索树值 II") 🔒 | [Go](../problems/closest-binary-search-tree-value-ii) | Hard | +| 273 | [Integer to English Words](https://leetcode.com/problems/integer-to-english-words "整数转换英文表示") | [Go](../problems/integer-to-english-words) | Hard | +| 274 | [H-Index](https://leetcode.com/problems/h-index "H指数") | [Go](../problems/h-index) | Medium | +| 275 | [H-Index II](https://leetcode.com/problems/h-index-ii "H指数 II") | [Go](../problems/h-index-ii) | Medium | +| 276 | [Paint Fence](https://leetcode.com/problems/paint-fence "栅栏涂色") 🔒 | [Go](../problems/paint-fence) | Easy | +| 277 | [Find the Celebrity](https://leetcode.com/problems/find-the-celebrity "搜寻名人") 🔒 | [Go](../problems/find-the-celebrity) | Medium | +| 278 | [First Bad Version](https://leetcode.com/problems/first-bad-version "第一个错误的版本") | [Go](../problems/first-bad-version) | Easy | +| 279 | [Perfect Squares](https://leetcode.com/problems/perfect-squares "完全平方数") | [Go](../problems/perfect-squares) | Medium | +| 280 | [Wiggle Sort](https://leetcode.com/problems/wiggle-sort "摆动排序") 🔒 | [Go](../problems/wiggle-sort) | Medium | +| 281 | [Zigzag Iterator](https://leetcode.com/problems/zigzag-iterator "锯齿迭代器") 🔒 | [Go](../problems/zigzag-iterator) | Medium | +| 282 | [Expression Add Operators](https://leetcode.com/problems/expression-add-operators "给表达式添加运算符") | [Go](../problems/expression-add-operators) | Hard | +| 283 | [Move Zeroes](https://leetcode.com/problems/move-zeroes "移动零") | [Go](../problems/move-zeroes) | Easy | +| 284 | [Peeking Iterator](https://leetcode.com/problems/peeking-iterator "顶端迭代器") | [Go](../problems/peeking-iterator) | Medium | +| 285 | [Inorder Successor in BST](https://leetcode.com/problems/inorder-successor-in-bst "二叉搜索树中的顺序后继") 🔒 | [Go](../problems/inorder-successor-in-bst) | Medium | +| 286 | [Walls and Gates](https://leetcode.com/problems/walls-and-gates "墙与门") 🔒 | [Go](../problems/walls-and-gates) | Medium | +| 287 | [Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number "寻找重复数") | [Go](../problems/find-the-duplicate-number) | Medium | +| 288 | [Unique Word Abbreviation](https://leetcode.com/problems/unique-word-abbreviation "单词的唯一缩写") 🔒 | [Go](../problems/unique-word-abbreviation) | Medium | +| 289 | [Game of Life](https://leetcode.com/problems/game-of-life "生命游戏") | [Go](../problems/game-of-life) | Medium | +| 290 | [Word Pattern](https://leetcode.com/problems/word-pattern "单词规律") | [Go](../problems/word-pattern) | Easy | +| 291 | [Word Pattern II](https://leetcode.com/problems/word-pattern-ii "单词规律 II") 🔒 | [Go](../problems/word-pattern-ii) | Hard | +| 292 | [Nim Game](https://leetcode.com/problems/nim-game "Nim 游戏") | [Go](../problems/nim-game) | Easy | +| 293 | [Flip Game](https://leetcode.com/problems/flip-game "翻转游戏") 🔒 | [Go](../problems/flip-game) | Easy | +| 294 | [Flip Game II](https://leetcode.com/problems/flip-game-ii "翻转游戏 II") 🔒 | [Go](../problems/flip-game-ii) | Medium | +| 295 | [Find Median from Data Stream](https://leetcode.com/problems/find-median-from-data-stream "数据流的中位数") | [Go](../problems/find-median-from-data-stream) | Hard | +| 296 | [Best Meeting Point](https://leetcode.com/problems/best-meeting-point "最佳的碰头地点") 🔒 | [Go](../problems/best-meeting-point) | Hard | +| 297 | [Serialize and Deserialize Binary Tree](https://leetcode.com/problems/serialize-and-deserialize-binary-tree "二叉树的序列化与反序列化") | [Go](../problems/serialize-and-deserialize-binary-tree) | Hard | +| 298 | [Binary Tree Longest Consecutive Sequence](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence "二叉树最长连续序列") 🔒 | [Go](../problems/binary-tree-longest-consecutive-sequence) | Medium | +| 299 | [Bulls and Cows](https://leetcode.com/problems/bulls-and-cows "猜数字游戏") | [Go](../problems/bulls-and-cows) | Easy | +| 300 | [Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence "最长上升子序列") | [Go](../problems/longest-increasing-subsequence) | Medium | diff --git a/readme/301-600.md b/readme/301-600.md index d36701d90..d85378bac 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -62,303 +62,303 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | -| 301 | [Remove Invalid Parentheses](https://leetcode.com/problems/remove-invalid-parentheses "删除无效的括号") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-invalid-parentheses) | Hard | -| 302 | [Smallest Rectangle Enclosing Black Pixels](https://leetcode.com/problems/smallest-rectangle-enclosing-black-pixels "包含全部黑色像素的最小矩形") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-rectangle-enclosing-black-pixels) | Hard | -| 303 | [Range Sum Query - Immutable](https://leetcode.com/problems/range-sum-query-immutable "区域和检索 - 数组不可变") | [Go](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-immutable) | Easy | -| 304 | [Range Sum Query 2D - Immutable](https://leetcode.com/problems/range-sum-query-2d-immutable "二维区域和检索 - 矩阵不可变") | [Go](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-2d-immutable) | Medium | -| 305 | [Number of Islands II](https://leetcode.com/problems/number-of-islands-ii "岛屿数量 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-islands-ii) | Hard | -| 306 | [Additive Number](https://leetcode.com/problems/additive-number "累加数") | [Go](https://github.com/openset/leetcode/tree/master/problems/additive-number) | Medium | -| 307 | [Range Sum Query - Mutable](https://leetcode.com/problems/range-sum-query-mutable "区域和检索 - 数组可修改") | [Go](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-mutable) | Medium | -| 308 | [Range Sum Query 2D - Mutable](https://leetcode.com/problems/range-sum-query-2d-mutable "二维区域和检索 - 可变") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-2d-mutable) | Hard | -| 309 | [Best Time to Buy and Sell Stock with Cooldown](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown "最佳买卖股票时机含冷冻期") | [Go](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-with-cooldown) | Medium | -| 310 | [Minimum Height Trees](https://leetcode.com/problems/minimum-height-trees "最小高度树") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-height-trees) | Medium | -| 311 | [Sparse Matrix Multiplication](https://leetcode.com/problems/sparse-matrix-multiplication "稀疏矩阵的乘法") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/sparse-matrix-multiplication) | Medium | -| 312 | [Burst Balloons](https://leetcode.com/problems/burst-balloons "戳气球") | [Go](https://github.com/openset/leetcode/tree/master/problems/burst-balloons) | Hard | -| 313 | [Super Ugly Number](https://leetcode.com/problems/super-ugly-number "超级丑数") | [Go](https://github.com/openset/leetcode/tree/master/problems/super-ugly-number) | Medium | -| 314 | [Binary Tree Vertical Order Traversal](https://leetcode.com/problems/binary-tree-vertical-order-traversal "二叉树的垂直遍历") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-vertical-order-traversal) | Medium | -| 315 | [Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self "计算右侧小于当前元素的个数") | [Go](https://github.com/openset/leetcode/tree/master/problems/count-of-smaller-numbers-after-self) | Hard | -| 316 | [Remove Duplicate Letters](https://leetcode.com/problems/remove-duplicate-letters "去除重复字母") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-duplicate-letters) | Hard | -| 317 | [Shortest Distance from All Buildings](https://leetcode.com/problems/shortest-distance-from-all-buildings "离建筑物最近的距离") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-from-all-buildings) | Hard | -| 318 | [Maximum Product of Word Lengths](https://leetcode.com/problems/maximum-product-of-word-lengths "最大单词长度乘积") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-product-of-word-lengths) | Medium | -| 319 | [Bulb Switcher](https://leetcode.com/problems/bulb-switcher "灯泡开关") | [Go](https://github.com/openset/leetcode/tree/master/problems/bulb-switcher) | Medium | -| 320 | [Generalized Abbreviation](https://leetcode.com/problems/generalized-abbreviation "列举单词的全部缩写") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/generalized-abbreviation) | Medium | -| 321 | [Create Maximum Number](https://leetcode.com/problems/create-maximum-number "拼接最大数") | [Go](https://github.com/openset/leetcode/tree/master/problems/create-maximum-number) | Hard | -| 322 | [Coin Change](https://leetcode.com/problems/coin-change "零钱兑换") | [Go](https://github.com/openset/leetcode/tree/master/problems/coin-change) | Medium | -| 323 | [Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph "无向图中连通分量的数目") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-connected-components-in-an-undirected-graph) | Medium | -| 324 | [Wiggle Sort II](https://leetcode.com/problems/wiggle-sort-ii "摆动排序 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/wiggle-sort-ii) | Medium | -| 325 | [Maximum Size Subarray Sum Equals k](https://leetcode.com/problems/maximum-size-subarray-sum-equals-k "和等于 k 的最长子数组长度") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-size-subarray-sum-equals-k) | Medium | -| 326 | [Power of Three](https://leetcode.com/problems/power-of-three "3的幂") | [Go](https://github.com/openset/leetcode/tree/master/problems/power-of-three) | Easy | -| 327 | [Count of Range Sum](https://leetcode.com/problems/count-of-range-sum "区间和的个数") | [Go](https://github.com/openset/leetcode/tree/master/problems/count-of-range-sum) | Hard | -| 328 | [Odd Even Linked List](https://leetcode.com/problems/odd-even-linked-list "奇偶链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/odd-even-linked-list) | Medium | -| 329 | [Longest Increasing Path in a Matrix](https://leetcode.com/problems/longest-increasing-path-in-a-matrix "矩阵中的最长递增路径") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-increasing-path-in-a-matrix) | Hard | -| 330 | [Patching Array](https://leetcode.com/problems/patching-array "按要求补齐数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/patching-array) | Hard | -| 331 | [Verify Preorder Serialization of a Binary Tree](https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree "验证二叉树的前序序列化") | [Go](https://github.com/openset/leetcode/tree/master/problems/verify-preorder-serialization-of-a-binary-tree) | Medium | -| 332 | [Reconstruct Itinerary](https://leetcode.com/problems/reconstruct-itinerary "重新安排行程") | [Go](https://github.com/openset/leetcode/tree/master/problems/reconstruct-itinerary) | Medium | -| 333 | [Largest BST Subtree](https://leetcode.com/problems/largest-bst-subtree "最大 BST 子树") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-bst-subtree) | Medium | -| 334 | [Increasing Triplet Subsequence](https://leetcode.com/problems/increasing-triplet-subsequence "递增的三元子序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/increasing-triplet-subsequence) | Medium | -| 335 | [Self Crossing](https://leetcode.com/problems/self-crossing "路径交叉") | [Go](https://github.com/openset/leetcode/tree/master/problems/self-crossing) | Hard | -| 336 | [Palindrome Pairs](https://leetcode.com/problems/palindrome-pairs "回文对") | [Go](https://github.com/openset/leetcode/tree/master/problems/palindrome-pairs) | Hard | -| 337 | [House Robber III](https://leetcode.com/problems/house-robber-iii "打家劫舍 III") | [Go](https://github.com/openset/leetcode/tree/master/problems/house-robber-iii) | Medium | -| 338 | [Counting Bits](https://leetcode.com/problems/counting-bits "比特位计数") | [Go](https://github.com/openset/leetcode/tree/master/problems/counting-bits) | Medium | -| 339 | [Nested List Weight Sum](https://leetcode.com/problems/nested-list-weight-sum "嵌套列表权重和") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/nested-list-weight-sum) | Easy | -| 340 | [Longest Substring with At Most K Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters "至多包含 K 个不同字符的最长子串") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-k-distinct-characters) | Hard | -| 341 | [Flatten Nested List Iterator](https://leetcode.com/problems/flatten-nested-list-iterator "扁平化嵌套列表迭代器") | [Go](https://github.com/openset/leetcode/tree/master/problems/flatten-nested-list-iterator) | Medium | -| 342 | [Power of Four](https://leetcode.com/problems/power-of-four "4的幂") | [Go](https://github.com/openset/leetcode/tree/master/problems/power-of-four) | Easy | -| 343 | [Integer Break](https://leetcode.com/problems/integer-break "整数拆分") | [Go](https://github.com/openset/leetcode/tree/master/problems/integer-break) | Medium | -| 344 | [Reverse String](https://leetcode.com/problems/reverse-string "反转字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/reverse-string) | Easy | -| 345 | [Reverse Vowels of a String](https://leetcode.com/problems/reverse-vowels-of-a-string "反转字符串中的元音字母") | [Go](https://github.com/openset/leetcode/tree/master/problems/reverse-vowels-of-a-string) | Easy | -| 346 | [Moving Average from Data Stream](https://leetcode.com/problems/moving-average-from-data-stream "数据流中的移动平均值") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/moving-average-from-data-stream) | Easy | -| 347 | [Top K Frequent Elements](https://leetcode.com/problems/top-k-frequent-elements "前 K 个高频元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-elements) | Medium | -| 348 | [Design Tic-Tac-Toe](https://leetcode.com/problems/design-tic-tac-toe "判定井字棋胜负") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-tic-tac-toe) | Medium | -| 349 | [Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays "两个数组的交集") | [Go](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays) | Easy | -| 350 | [Intersection of Two Arrays II](https://leetcode.com/problems/intersection-of-two-arrays-ii "两个数组的交集 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays-ii) | Easy | -| 351 | [Android Unlock Patterns](https://leetcode.com/problems/android-unlock-patterns "安卓系统手势解锁") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/android-unlock-patterns) | Medium | -| 352 | [Data Stream as Disjoint Intervals](https://leetcode.com/problems/data-stream-as-disjoint-intervals "将数据流变为多个不相交区间") | [Go](https://github.com/openset/leetcode/tree/master/problems/data-stream-as-disjoint-intervals) | Hard | -| 353 | [Design Snake Game](https://leetcode.com/problems/design-snake-game "贪吃蛇") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-snake-game) | Medium | -| 354 | [Russian Doll Envelopes](https://leetcode.com/problems/russian-doll-envelopes "俄罗斯套娃信封问题") | [Go](https://github.com/openset/leetcode/tree/master/problems/russian-doll-envelopes) | Hard | -| 355 | [Design Twitter](https://leetcode.com/problems/design-twitter "设计推特") | [Go](https://github.com/openset/leetcode/tree/master/problems/design-twitter) | Medium | -| 356 | [Line Reflection](https://leetcode.com/problems/line-reflection "直线镜像") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/line-reflection) | Medium | -| 357 | [Count Numbers with Unique Digits](https://leetcode.com/problems/count-numbers-with-unique-digits "计算各个位数不同的数字个数") | [Go](https://github.com/openset/leetcode/tree/master/problems/count-numbers-with-unique-digits) | Medium | -| 358 | [Rearrange String k Distance Apart](https://leetcode.com/problems/rearrange-string-k-distance-apart "K 距离间隔重排字符串") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/rearrange-string-k-distance-apart) | Hard | -| 359 | [Logger Rate Limiter](https://leetcode.com/problems/logger-rate-limiter "日志速率限制器") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/logger-rate-limiter) | Easy | -| 360 | [Sort Transformed Array](https://leetcode.com/problems/sort-transformed-array "有序转化数组") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/sort-transformed-array) | Medium | -| 361 | [Bomb Enemy](https://leetcode.com/problems/bomb-enemy "轰炸敌人") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/bomb-enemy) | Medium | -| 362 | [Design Hit Counter](https://leetcode.com/problems/design-hit-counter "敲击计数器") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-hit-counter) | Medium | -| 363 | [Max Sum of Rectangle No Larger Than K](https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k "矩形区域不超过 K 的最大数值和") | [Go](https://github.com/openset/leetcode/tree/master/problems/max-sum-of-rectangle-no-larger-than-k) | Hard | -| 364 | [Nested List Weight Sum II](https://leetcode.com/problems/nested-list-weight-sum-ii "加权嵌套序列和 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/nested-list-weight-sum-ii) | Medium | -| 365 | [Water and Jug Problem](https://leetcode.com/problems/water-and-jug-problem "水壶问题") | [Go](https://github.com/openset/leetcode/tree/master/problems/water-and-jug-problem) | Medium | -| 366 | [Find Leaves of Binary Tree](https://leetcode.com/problems/find-leaves-of-binary-tree "寻找完全二叉树的叶子节点") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/find-leaves-of-binary-tree) | Medium | -| 367 | [Valid Perfect Square](https://leetcode.com/problems/valid-perfect-square "有效的完全平方数") | [Go](https://github.com/openset/leetcode/tree/master/problems/valid-perfect-square) | Easy | -| 368 | [Largest Divisible Subset](https://leetcode.com/problems/largest-divisible-subset "最大整除子集") | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-divisible-subset) | Medium | -| 369 | [Plus One Linked List](https://leetcode.com/problems/plus-one-linked-list "给单链表加一") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/plus-one-linked-list) | Medium | -| 370 | [Range Addition](https://leetcode.com/problems/range-addition "区间加法") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/range-addition) | Medium | -| 371 | [Sum of Two Integers](https://leetcode.com/problems/sum-of-two-integers "两整数之和") | [Go](https://github.com/openset/leetcode/tree/master/problems/sum-of-two-integers) | Easy | -| 372 | [Super Pow](https://leetcode.com/problems/super-pow "超级次方") | [Go](https://github.com/openset/leetcode/tree/master/problems/super-pow) | Medium | -| 373 | [Find K Pairs with Smallest Sums](https://leetcode.com/problems/find-k-pairs-with-smallest-sums "查找和最小的K对数字") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-k-pairs-with-smallest-sums) | Medium | -| 374 | [Guess Number Higher or Lower](https://leetcode.com/problems/guess-number-higher-or-lower "猜数字大小") | [Go](https://github.com/openset/leetcode/tree/master/problems/guess-number-higher-or-lower) | Easy | -| 375 | [Guess Number Higher or Lower II](https://leetcode.com/problems/guess-number-higher-or-lower-ii "猜数字大小 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/guess-number-higher-or-lower-ii) | Medium | -| 376 | [Wiggle Subsequence](https://leetcode.com/problems/wiggle-subsequence "摆动序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/wiggle-subsequence) | Medium | -| 377 | [Combination Sum IV](https://leetcode.com/problems/combination-sum-iv "组合总和 Ⅳ") | [Go](https://github.com/openset/leetcode/tree/master/problems/combination-sum-iv) | Medium | -| 378 | [Kth Smallest Element in a Sorted Matrix](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix "有序矩阵中第K小的元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-element-in-a-sorted-matrix) | Medium | -| 379 | [Design Phone Directory](https://leetcode.com/problems/design-phone-directory "电话目录管理系统") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-phone-directory) | Medium | -| 380 | [Insert Delete GetRandom O(1)](https://leetcode.com/problems/insert-delete-getrandom-o1 "常数时间插入、删除和获取随机元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/insert-delete-getrandom-o1) | Medium | -| 381 | [Insert Delete GetRandom O(1) - Duplicates allowed](https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed "O(1) 时间插入、删除和获取随机元素 - 允许重复") | [Go](https://github.com/openset/leetcode/tree/master/problems/insert-delete-getrandom-o1-duplicates-allowed) | Hard | -| 382 | [Linked List Random Node](https://leetcode.com/problems/linked-list-random-node "链表随机节点") | [Go](https://github.com/openset/leetcode/tree/master/problems/linked-list-random-node) | Medium | -| 383 | [Ransom Note](https://leetcode.com/problems/ransom-note "赎金信") | [Go](https://github.com/openset/leetcode/tree/master/problems/ransom-note) | Easy | -| 384 | [Shuffle an Array](https://leetcode.com/problems/shuffle-an-array "打乱数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/shuffle-an-array) | Medium | -| 385 | [Mini Parser](https://leetcode.com/problems/mini-parser "迷你语法分析器") | [Go](https://github.com/openset/leetcode/tree/master/problems/mini-parser) | Medium | -| 386 | [Lexicographical Numbers](https://leetcode.com/problems/lexicographical-numbers "字典序排数") | [Go](https://github.com/openset/leetcode/tree/master/problems/lexicographical-numbers) | Medium | -| 387 | [First Unique Character in a String](https://leetcode.com/problems/first-unique-character-in-a-string "字符串中的第一个唯一字符") | [Go](https://github.com/openset/leetcode/tree/master/problems/first-unique-character-in-a-string) | Easy | -| 388 | [Longest Absolute File Path](https://leetcode.com/problems/longest-absolute-file-path "文件的最长绝对路径") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-absolute-file-path) | Medium | -| 389 | [Find the Difference](https://leetcode.com/problems/find-the-difference "找不同") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-the-difference) | Easy | -| 390 | [Elimination Game](https://leetcode.com/problems/elimination-game "消除游戏") | [Go](https://github.com/openset/leetcode/tree/master/problems/elimination-game) | Medium | -| 391 | [Perfect Rectangle](https://leetcode.com/problems/perfect-rectangle "完美矩形") | [Go](https://github.com/openset/leetcode/tree/master/problems/perfect-rectangle) | Hard | -| 392 | [Is Subsequence](https://leetcode.com/problems/is-subsequence "判断子序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/is-subsequence) | Easy | -| 393 | [UTF-8 Validation](https://leetcode.com/problems/utf-8-validation "UTF-8 编码验证") | [Go](https://github.com/openset/leetcode/tree/master/problems/utf-8-validation) | Medium | -| 394 | [Decode String](https://leetcode.com/problems/decode-string "字符串解码") | [Go](https://github.com/openset/leetcode/tree/master/problems/decode-string) | Medium | -| 395 | [Longest Substring with At Least K Repeating Characters](https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters "至少有K个重复字符的最长子串") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-least-k-repeating-characters) | Medium | -| 396 | [Rotate Function](https://leetcode.com/problems/rotate-function "旋转函数") | [Go](https://github.com/openset/leetcode/tree/master/problems/rotate-function) | Medium | -| 397 | [Integer Replacement](https://leetcode.com/problems/integer-replacement "整数替换") | [Go](https://github.com/openset/leetcode/tree/master/problems/integer-replacement) | Medium | -| 398 | [Random Pick Index](https://leetcode.com/problems/random-pick-index "随机数索引") | [Go](https://github.com/openset/leetcode/tree/master/problems/random-pick-index) | Medium | -| 399 | [Evaluate Division](https://leetcode.com/problems/evaluate-division "除法求值") | [Go](https://github.com/openset/leetcode/tree/master/problems/evaluate-division) | Medium | -| 400 | [Nth Digit](https://leetcode.com/problems/nth-digit "第N个数字") | [Go](https://github.com/openset/leetcode/tree/master/problems/nth-digit) | Medium | -| 401 | [Binary Watch](https://leetcode.com/problems/binary-watch "二进制手表") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-watch) | Easy | -| 402 | [Remove K Digits](https://leetcode.com/problems/remove-k-digits "移掉K位数字") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-k-digits) | Medium | -| 403 | [Frog Jump](https://leetcode.com/problems/frog-jump "青蛙过河") | [Go](https://github.com/openset/leetcode/tree/master/problems/frog-jump) | Hard | -| 404 | [Sum of Left Leaves](https://leetcode.com/problems/sum-of-left-leaves "左叶子之和") | [Go](https://github.com/openset/leetcode/tree/master/problems/sum-of-left-leaves) | Easy | -| 405 | [Convert a Number to Hexadecimal](https://leetcode.com/problems/convert-a-number-to-hexadecimal "数字转换为十六进制数") | [Go](https://github.com/openset/leetcode/tree/master/problems/convert-a-number-to-hexadecimal) | Easy | -| 406 | [Queue Reconstruction by Height](https://leetcode.com/problems/queue-reconstruction-by-height "根据身高重建队列") | [Go](https://github.com/openset/leetcode/tree/master/problems/queue-reconstruction-by-height) | Medium | -| 407 | [Trapping Rain Water II](https://leetcode.com/problems/trapping-rain-water-ii "接雨水 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/trapping-rain-water-ii) | Hard | -| 408 | [Valid Word Abbreviation](https://leetcode.com/problems/valid-word-abbreviation "有效单词缩写") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/valid-word-abbreviation) | Easy | -| 409 | [Longest Palindrome](https://leetcode.com/problems/longest-palindrome "最长回文串") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-palindrome) | Easy | -| 410 | [Split Array Largest Sum](https://leetcode.com/problems/split-array-largest-sum "分割数组的最大值") | [Go](https://github.com/openset/leetcode/tree/master/problems/split-array-largest-sum) | Hard | -| 411 | [Minimum Unique Word Abbreviation](https://leetcode.com/problems/minimum-unique-word-abbreviation "最短特异单词缩写") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-unique-word-abbreviation) | Hard | -| 412 | [Fizz Buzz](https://leetcode.com/problems/fizz-buzz "Fizz Buzz") | [Go](https://github.com/openset/leetcode/tree/master/problems/fizz-buzz) | Easy | -| 413 | [Arithmetic Slices](https://leetcode.com/problems/arithmetic-slices "等差数列划分") | [Go](https://github.com/openset/leetcode/tree/master/problems/arithmetic-slices) | Medium | -| 414 | [Third Maximum Number](https://leetcode.com/problems/third-maximum-number "第三大的数") | [Go](https://github.com/openset/leetcode/tree/master/problems/third-maximum-number) | Easy | -| 415 | [Add Strings](https://leetcode.com/problems/add-strings "字符串相加") | [Go](https://github.com/openset/leetcode/tree/master/problems/add-strings) | Easy | -| 416 | [Partition Equal Subset Sum](https://leetcode.com/problems/partition-equal-subset-sum "分割等和子集") | [Go](https://github.com/openset/leetcode/tree/master/problems/partition-equal-subset-sum) | Medium | -| 417 | [Pacific Atlantic Water Flow](https://leetcode.com/problems/pacific-atlantic-water-flow "太平洋大西洋水流问题") | [Go](https://github.com/openset/leetcode/tree/master/problems/pacific-atlantic-water-flow) | Medium | -| 418 | [Sentence Screen Fitting](https://leetcode.com/problems/sentence-screen-fitting "屏幕可显示句子的数量") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/sentence-screen-fitting) | Medium | -| 419 | [Battleships in a Board](https://leetcode.com/problems/battleships-in-a-board "甲板上的战舰") | [Go](https://github.com/openset/leetcode/tree/master/problems/battleships-in-a-board) | Medium | -| 420 | [Strong Password Checker](https://leetcode.com/problems/strong-password-checker "强密码检验器") | [Go](https://github.com/openset/leetcode/tree/master/problems/strong-password-checker) | Hard | -| 421 | [Maximum XOR of Two Numbers in an Array](https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array "数组中两个数的最大异或值") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-xor-of-two-numbers-in-an-array) | Medium | -| 422 | [Valid Word Square](https://leetcode.com/problems/valid-word-square "有效的单词方块") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/valid-word-square) | Easy | -| 423 | [Reconstruct Original Digits from English](https://leetcode.com/problems/reconstruct-original-digits-from-english "从英文中重建数字") | [Go](https://github.com/openset/leetcode/tree/master/problems/reconstruct-original-digits-from-english) | Medium | -| 424 | [Longest Repeating Character Replacement](https://leetcode.com/problems/longest-repeating-character-replacement "替换后的最长重复字符") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-repeating-character-replacement) | Medium | -| 425 | [Word Squares](https://leetcode.com/problems/word-squares "单词方块") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/word-squares) | Hard | -| 426 | [Convert Binary Search Tree to Sorted Doubly Linked List](https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list "将二叉搜索树转化为排序的双向链表") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/convert-binary-search-tree-to-sorted-doubly-linked-list) | Medium | -| 427 | [Construct Quad Tree](https://leetcode.com/problems/construct-quad-tree "建立四叉树") | [Go](https://github.com/openset/leetcode/tree/master/problems/construct-quad-tree) | Medium | -| 428 | [Serialize and Deserialize N-ary Tree](https://leetcode.com/problems/serialize-and-deserialize-n-ary-tree "序列化和反序列化 N 叉树") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-n-ary-tree) | Hard | -| 429 | [N-ary Tree Level Order Traversal](https://leetcode.com/problems/n-ary-tree-level-order-traversal "N叉树的层序遍历") | [Go](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-level-order-traversal) | Medium | -| 430 | [Flatten a Multilevel Doubly Linked List](https://leetcode.com/problems/flatten-a-multilevel-doubly-linked-list "扁平化多级双向链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/flatten-a-multilevel-doubly-linked-list) | Medium | -| 431 | [Encode N-ary Tree to Binary Tree](https://leetcode.com/problems/encode-n-ary-tree-to-binary-tree "将 N 叉树编码为二叉树") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/encode-n-ary-tree-to-binary-tree) | Hard | -| 432 | [All O`one Data Structure](https://leetcode.com/problems/all-oone-data-structure "全 O(1) 的数据结构") | [Go](https://github.com/openset/leetcode/tree/master/problems/all-oone-data-structure) | Hard | -| 433 | [Minimum Genetic Mutation](https://leetcode.com/problems/minimum-genetic-mutation "最小基因变化") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-genetic-mutation) | Medium | -| 434 | [Number of Segments in a String](https://leetcode.com/problems/number-of-segments-in-a-string "字符串中的单词数") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-segments-in-a-string) | Easy | -| 435 | [Non-overlapping Intervals](https://leetcode.com/problems/non-overlapping-intervals "无重叠区间") | [Go](https://github.com/openset/leetcode/tree/master/problems/non-overlapping-intervals) | Medium | -| 436 | [Find Right Interval](https://leetcode.com/problems/find-right-interval "寻找右区间") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-right-interval) | Medium | -| 437 | [Path Sum III](https://leetcode.com/problems/path-sum-iii "路径总和 III") | [Go](https://github.com/openset/leetcode/tree/master/problems/path-sum-iii) | Easy | -| 438 | [Find All Anagrams in a String](https://leetcode.com/problems/find-all-anagrams-in-a-string "找到字符串中所有字母异位词") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-all-anagrams-in-a-string) | Medium | -| 439 | [Ternary Expression Parser](https://leetcode.com/problems/ternary-expression-parser "三元表达式解析器") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/ternary-expression-parser) | Medium | -| 440 | [K-th Smallest in Lexicographical Order](https://leetcode.com/problems/k-th-smallest-in-lexicographical-order "字典序的第K小数字") | [Go](https://github.com/openset/leetcode/tree/master/problems/k-th-smallest-in-lexicographical-order) | Hard | -| 441 | [Arranging Coins](https://leetcode.com/problems/arranging-coins "排列硬币") | [Go](https://github.com/openset/leetcode/tree/master/problems/arranging-coins) | Easy | -| 442 | [Find All Duplicates in an Array](https://leetcode.com/problems/find-all-duplicates-in-an-array "数组中重复的数据") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-all-duplicates-in-an-array) | Medium | -| 443 | [String Compression](https://leetcode.com/problems/string-compression "压缩字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/string-compression) | Easy | -| 444 | [Sequence Reconstruction](https://leetcode.com/problems/sequence-reconstruction "序列重建") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/sequence-reconstruction) | Medium | -| 445 | [Add Two Numbers II](https://leetcode.com/problems/add-two-numbers-ii "两数相加 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/add-two-numbers-ii) | Medium | -| 446 | [Arithmetic Slices II - Subsequence](https://leetcode.com/problems/arithmetic-slices-ii-subsequence "等差数列划分 II - 子序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/arithmetic-slices-ii-subsequence) | Hard | -| 447 | [Number of Boomerangs](https://leetcode.com/problems/number-of-boomerangs "回旋镖的数量") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-boomerangs) | Easy | -| 448 | [Find All Numbers Disappeared in an Array](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array "找到所有数组中消失的数字") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-all-numbers-disappeared-in-an-array) | Easy | -| 449 | [Serialize and Deserialize BST](https://leetcode.com/problems/serialize-and-deserialize-bst "序列化和反序列化二叉搜索树") | [Go](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-bst) | Medium | -| 450 | [Delete Node in a BST](https://leetcode.com/problems/delete-node-in-a-bst "删除二叉搜索树中的节点") | [Go](https://github.com/openset/leetcode/tree/master/problems/delete-node-in-a-bst) | Medium | -| 451 | [Sort Characters By Frequency](https://leetcode.com/problems/sort-characters-by-frequency "根据字符出现频率排序") | [Go](https://github.com/openset/leetcode/tree/master/problems/sort-characters-by-frequency) | Medium | -| 452 | [Minimum Number of Arrows to Burst Balloons](https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons "用最少数量的箭引爆气球") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-arrows-to-burst-balloons) | Medium | -| 453 | [Minimum Moves to Equal Array Elements](https://leetcode.com/problems/minimum-moves-to-equal-array-elements "最小移动次数使数组元素相等") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-equal-array-elements) | Easy | -| 454 | [4Sum II](https://leetcode.com/problems/4sum-ii "四数相加 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/4sum-ii) | Medium | -| 455 | [Assign Cookies](https://leetcode.com/problems/assign-cookies "分发饼干") | [Go](https://github.com/openset/leetcode/tree/master/problems/assign-cookies) | Easy | -| 456 | [132 Pattern](https://leetcode.com/problems/132-pattern "132模式") | [Go](https://github.com/openset/leetcode/tree/master/problems/132-pattern) | Medium | -| 457 | [Circular Array Loop](https://leetcode.com/problems/circular-array-loop "环形数组循环") | [Go](https://github.com/openset/leetcode/tree/master/problems/circular-array-loop) | Medium | -| 458 | [Poor Pigs](https://leetcode.com/problems/poor-pigs "可怜的小猪") | [Go](https://github.com/openset/leetcode/tree/master/problems/poor-pigs) | Hard | -| 459 | [Repeated Substring Pattern](https://leetcode.com/problems/repeated-substring-pattern "重复的子字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/repeated-substring-pattern) | Easy | -| 460 | [LFU Cache](https://leetcode.com/problems/lfu-cache "LFU缓存") | [Go](https://github.com/openset/leetcode/tree/master/problems/lfu-cache) | Hard | -| 461 | [Hamming Distance](https://leetcode.com/problems/hamming-distance "汉明距离") | [Go](https://github.com/openset/leetcode/tree/master/problems/hamming-distance) | Easy | -| 462 | [Minimum Moves to Equal Array Elements II](https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii "最少移动次数使数组元素相等 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-equal-array-elements-ii) | Medium | -| 463 | [Island Perimeter](https://leetcode.com/problems/island-perimeter "岛屿的周长") | [Go](https://github.com/openset/leetcode/tree/master/problems/island-perimeter) | Easy | -| 464 | [Can I Win](https://leetcode.com/problems/can-i-win "我能赢吗") | [Go](https://github.com/openset/leetcode/tree/master/problems/can-i-win) | Medium | -| 465 | [Optimal Account Balancing](https://leetcode.com/problems/optimal-account-balancing "最优账单平衡") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/optimal-account-balancing) | Hard | -| 466 | [Count The Repetitions](https://leetcode.com/problems/count-the-repetitions "统计重复个数") | [Go](https://github.com/openset/leetcode/tree/master/problems/count-the-repetitions) | Hard | -| 467 | [Unique Substrings in Wraparound String](https://leetcode.com/problems/unique-substrings-in-wraparound-string "环绕字符串中唯一的子字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/unique-substrings-in-wraparound-string) | Medium | -| 468 | [Validate IP Address](https://leetcode.com/problems/validate-ip-address "验证IP地址") | [Go](https://github.com/openset/leetcode/tree/master/problems/validate-ip-address) | Medium | -| 469 | [Convex Polygon](https://leetcode.com/problems/convex-polygon "凸多边形") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/convex-polygon) | Medium | -| 470 | [Implement Rand10() Using Rand7()](https://leetcode.com/problems/implement-rand10-using-rand7 "用 Rand7() 实现 Rand10()") | [Go](https://github.com/openset/leetcode/tree/master/problems/implement-rand10-using-rand7) | Medium | -| 471 | [Encode String with Shortest Length](https://leetcode.com/problems/encode-string-with-shortest-length "编码最短长度的字符串") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/encode-string-with-shortest-length) | Hard | -| 472 | [Concatenated Words](https://leetcode.com/problems/concatenated-words "连接词") | [Go](https://github.com/openset/leetcode/tree/master/problems/concatenated-words) | Hard | -| 473 | [Matchsticks to Square](https://leetcode.com/problems/matchsticks-to-square "火柴拼正方形") | [Go](https://github.com/openset/leetcode/tree/master/problems/matchsticks-to-square) | Medium | -| 474 | [Ones and Zeroes](https://leetcode.com/problems/ones-and-zeroes "一和零") | [Go](https://github.com/openset/leetcode/tree/master/problems/ones-and-zeroes) | Medium | -| 475 | [Heaters](https://leetcode.com/problems/heaters "供暖器") | [Go](https://github.com/openset/leetcode/tree/master/problems/heaters) | Easy | -| 476 | [Number Complement](https://leetcode.com/problems/number-complement "数字的补数") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-complement) | Easy | -| 477 | [Total Hamming Distance](https://leetcode.com/problems/total-hamming-distance "汉明距离总和") | [Go](https://github.com/openset/leetcode/tree/master/problems/total-hamming-distance) | Medium | -| 478 | [Generate Random Point in a Circle](https://leetcode.com/problems/generate-random-point-in-a-circle "在圆内随机生成点") | [Go](https://github.com/openset/leetcode/tree/master/problems/generate-random-point-in-a-circle) | Medium | -| 479 | [Largest Palindrome Product](https://leetcode.com/problems/largest-palindrome-product "最大回文数乘积") | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-palindrome-product) | Hard | -| 480 | [Sliding Window Median](https://leetcode.com/problems/sliding-window-median "滑动窗口中位数") | [Go](https://github.com/openset/leetcode/tree/master/problems/sliding-window-median) | Hard | -| 481 | [Magical String](https://leetcode.com/problems/magical-string "神奇字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/magical-string) | Medium | -| 482 | [License Key Formatting](https://leetcode.com/problems/license-key-formatting "密钥格式化") | [Go](https://github.com/openset/leetcode/tree/master/problems/license-key-formatting) | Easy | -| 483 | [Smallest Good Base](https://leetcode.com/problems/smallest-good-base "最小好进制") | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-good-base) | Hard | -| 484 | [Find Permutation](https://leetcode.com/problems/find-permutation "寻找排列") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/find-permutation) | Medium | -| 485 | [Max Consecutive Ones](https://leetcode.com/problems/max-consecutive-ones "最大连续1的个数") | [Go](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones) | Easy | -| 486 | [Predict the Winner](https://leetcode.com/problems/predict-the-winner "预测赢家") | [Go](https://github.com/openset/leetcode/tree/master/problems/predict-the-winner) | Medium | -| 487 | [Max Consecutive Ones II](https://leetcode.com/problems/max-consecutive-ones-ii "最大连续1的个数 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones-ii) | Medium | -| 488 | [Zuma Game](https://leetcode.com/problems/zuma-game "祖玛游戏") | [Go](https://github.com/openset/leetcode/tree/master/problems/zuma-game) | Hard | -| 489 | [Robot Room Cleaner](https://leetcode.com/problems/robot-room-cleaner "扫地机器人") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/robot-room-cleaner) | Hard | -| 490 | [The Maze](https://leetcode.com/problems/the-maze "迷宫") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/the-maze) | Medium | -| 491 | [Increasing Subsequences](https://leetcode.com/problems/increasing-subsequences "递增子序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/increasing-subsequences) | Medium | -| 492 | [Construct the Rectangle](https://leetcode.com/problems/construct-the-rectangle "构造矩形") | [Go](https://github.com/openset/leetcode/tree/master/problems/construct-the-rectangle) | Easy | -| 493 | [Reverse Pairs](https://leetcode.com/problems/reverse-pairs "翻转对") | [Go](https://github.com/openset/leetcode/tree/master/problems/reverse-pairs) | Hard | -| 494 | [Target Sum](https://leetcode.com/problems/target-sum "目标和") | [Go](https://github.com/openset/leetcode/tree/master/problems/target-sum) | Medium | -| 495 | [Teemo Attacking](https://leetcode.com/problems/teemo-attacking "提莫攻击") | [Go](https://github.com/openset/leetcode/tree/master/problems/teemo-attacking) | Medium | -| 496 | [Next Greater Element I](https://leetcode.com/problems/next-greater-element-i "下一个更大元素 I") | [Go](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-i) | Easy | -| 497 | [Random Point in Non-overlapping Rectangles](https://leetcode.com/problems/random-point-in-non-overlapping-rectangles "非重叠矩形中的随机点") | [Go](https://github.com/openset/leetcode/tree/master/problems/random-point-in-non-overlapping-rectangles) | Medium | -| 498 | [Diagonal Traverse](https://leetcode.com/problems/diagonal-traverse "对角线遍历") | [Go](https://github.com/openset/leetcode/tree/master/problems/diagonal-traverse) | Medium | -| 499 | [The Maze III](https://leetcode.com/problems/the-maze-iii "迷宫 III") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/the-maze-iii) | Hard | -| 500 | [Keyboard Row](https://leetcode.com/problems/keyboard-row "键盘行") | [Go](https://github.com/openset/leetcode/tree/master/problems/keyboard-row) | Easy | -| 501 | [Find Mode in Binary Search Tree](https://leetcode.com/problems/find-mode-in-binary-search-tree "二叉搜索树中的众数") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-mode-in-binary-search-tree) | Easy | -| 502 | [IPO](https://leetcode.com/problems/ipo "IPO") | [Go](https://github.com/openset/leetcode/tree/master/problems/ipo) | Hard | -| 503 | [Next Greater Element II](https://leetcode.com/problems/next-greater-element-ii "下一个更大元素 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-ii) | Medium | -| 504 | [Base 7](https://leetcode.com/problems/base-7 "七进制数") | [Go](https://github.com/openset/leetcode/tree/master/problems/base-7) | Easy | -| 505 | [The Maze II](https://leetcode.com/problems/the-maze-ii "迷宫 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/the-maze-ii) | Medium | -| 506 | [Relative Ranks](https://leetcode.com/problems/relative-ranks "相对名次") | [Go](https://github.com/openset/leetcode/tree/master/problems/relative-ranks) | Easy | -| 507 | [Perfect Number](https://leetcode.com/problems/perfect-number "完美数") | [Go](https://github.com/openset/leetcode/tree/master/problems/perfect-number) | Easy | -| 508 | [Most Frequent Subtree Sum](https://leetcode.com/problems/most-frequent-subtree-sum "出现次数最多的子树元素和") | [Go](https://github.com/openset/leetcode/tree/master/problems/most-frequent-subtree-sum) | Medium | -| 509 | [Fibonacci Number](https://leetcode.com/problems/fibonacci-number "斐波那契数") | [Go](https://github.com/openset/leetcode/tree/master/problems/fibonacci-number) | Easy | -| 510 | [Inorder Successor in BST II](https://leetcode.com/problems/inorder-successor-in-bst-ii "二叉搜索树中的中序后继 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/inorder-successor-in-bst-ii) | Medium | -| 511 | [Game Play Analysis I](https://leetcode.com/problems/game-play-analysis-i "游戏玩法分析 I") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-i) | Easy | -| 512 | [Game Play Analysis II](https://leetcode.com/problems/game-play-analysis-ii "游戏玩法分析 II") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-ii) | Easy | -| 513 | [Find Bottom Left Tree Value](https://leetcode.com/problems/find-bottom-left-tree-value "找树左下角的值") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-bottom-left-tree-value) | Medium | -| 514 | [Freedom Trail](https://leetcode.com/problems/freedom-trail "自由之路") | [Go](https://github.com/openset/leetcode/tree/master/problems/freedom-trail) | Hard | -| 515 | [Find Largest Value in Each Tree Row](https://leetcode.com/problems/find-largest-value-in-each-tree-row "在每个树行中找最大值") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-largest-value-in-each-tree-row) | Medium | -| 516 | [Longest Palindromic Subsequence](https://leetcode.com/problems/longest-palindromic-subsequence "最长回文子序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-palindromic-subsequence) | Medium | -| 517 | [Super Washing Machines](https://leetcode.com/problems/super-washing-machines "超级洗衣机") | [Go](https://github.com/openset/leetcode/tree/master/problems/super-washing-machines) | Hard | -| 518 | [Coin Change 2](https://leetcode.com/problems/coin-change-2 "零钱兑换 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/coin-change-2) | Medium | -| 519 | [Random Flip Matrix](https://leetcode.com/problems/random-flip-matrix "随机翻转矩阵") | [Go](https://github.com/openset/leetcode/tree/master/problems/random-flip-matrix) | Medium | -| 520 | [Detect Capital](https://leetcode.com/problems/detect-capital "检测大写字母") | [Go](https://github.com/openset/leetcode/tree/master/problems/detect-capital) | Easy | -| 521 | [Longest Uncommon Subsequence I](https://leetcode.com/problems/longest-uncommon-subsequence-i "最长特殊序列 Ⅰ") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-uncommon-subsequence-i) | Easy | -| 522 | [Longest Uncommon Subsequence II](https://leetcode.com/problems/longest-uncommon-subsequence-ii "最长特殊序列 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-uncommon-subsequence-ii) | Medium | -| 523 | [Continuous Subarray Sum](https://leetcode.com/problems/continuous-subarray-sum "连续的子数组和") | [Go](https://github.com/openset/leetcode/tree/master/problems/continuous-subarray-sum) | Medium | -| 524 | [Longest Word in Dictionary through Deleting](https://leetcode.com/problems/longest-word-in-dictionary-through-deleting "通过删除字母匹配到字典里最长单词") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-word-in-dictionary-through-deleting) | Medium | -| 525 | [Contiguous Array](https://leetcode.com/problems/contiguous-array "连续数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/contiguous-array) | Medium | -| 526 | [Beautiful Arrangement](https://leetcode.com/problems/beautiful-arrangement "优美的排列") | [Go](https://github.com/openset/leetcode/tree/master/problems/beautiful-arrangement) | Medium | -| 527 | [Word Abbreviation](https://leetcode.com/problems/word-abbreviation "单词缩写") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/word-abbreviation) | Hard | -| 528 | [Random Pick with Weight](https://leetcode.com/problems/random-pick-with-weight "按权重随机选择") | [Go](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-weight) | Medium | -| 529 | [Minesweeper](https://leetcode.com/problems/minesweeper "扫雷游戏") | [Go](https://github.com/openset/leetcode/tree/master/problems/minesweeper) | Medium | -| 530 | [Minimum Absolute Difference in BST](https://leetcode.com/problems/minimum-absolute-difference-in-bst "二叉搜索树的最小绝对差") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-absolute-difference-in-bst) | Easy | -| 531 | [Lonely Pixel I](https://leetcode.com/problems/lonely-pixel-i "孤独像素 I") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/lonely-pixel-i) | Medium | -| 532 | [K-diff Pairs in an Array](https://leetcode.com/problems/k-diff-pairs-in-an-array "数组中的K-diff数对") | [Go](https://github.com/openset/leetcode/tree/master/problems/k-diff-pairs-in-an-array) | Easy | -| 533 | [Lonely Pixel II](https://leetcode.com/problems/lonely-pixel-ii "孤独像素 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/lonely-pixel-ii) | Medium | -| 534 | [Game Play Analysis III](https://leetcode.com/problems/game-play-analysis-iii "游戏玩法分析 III") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-iii) | Medium | -| 535 | [Encode and Decode TinyURL](https://leetcode.com/problems/encode-and-decode-tinyurl "TinyURL 的加密与解密") | [Go](https://github.com/openset/leetcode/tree/master/problems/encode-and-decode-tinyurl) | Medium | -| 536 | [Construct Binary Tree from String](https://leetcode.com/problems/construct-binary-tree-from-string "从字符串生成二叉树") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-string) | Medium | -| 537 | [Complex Number Multiplication](https://leetcode.com/problems/complex-number-multiplication "复数乘法") | [Go](https://github.com/openset/leetcode/tree/master/problems/complex-number-multiplication) | Medium | -| 538 | [Convert BST to Greater Tree](https://leetcode.com/problems/convert-bst-to-greater-tree "把二叉搜索树转换为累加树") | [Go](https://github.com/openset/leetcode/tree/master/problems/convert-bst-to-greater-tree) | Easy | -| 539 | [Minimum Time Difference](https://leetcode.com/problems/minimum-time-difference "最小时间差") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-time-difference) | Medium | -| 540 | [Single Element in a Sorted Array](https://leetcode.com/problems/single-element-in-a-sorted-array "有序数组中的单一元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/single-element-in-a-sorted-array) | Medium | -| 541 | [Reverse String II](https://leetcode.com/problems/reverse-string-ii "反转字符串 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/reverse-string-ii) | Easy | -| 542 | [01 Matrix](https://leetcode.com/problems/01-matrix "01 矩阵") | [Go](https://github.com/openset/leetcode/tree/master/problems/01-matrix) | Medium | -| 543 | [Diameter of Binary Tree](https://leetcode.com/problems/diameter-of-binary-tree "二叉树的直径") | [Go](https://github.com/openset/leetcode/tree/master/problems/diameter-of-binary-tree) | Easy | -| 544 | [Output Contest Matches](https://leetcode.com/problems/output-contest-matches "输出比赛匹配对") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/output-contest-matches) | Medium | -| 545 | [Boundary of Binary Tree](https://leetcode.com/problems/boundary-of-binary-tree "二叉树的边界") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/boundary-of-binary-tree) | Medium | -| 546 | [Remove Boxes](https://leetcode.com/problems/remove-boxes "移除盒子") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-boxes) | Hard | -| 547 | [Friend Circles](https://leetcode.com/problems/friend-circles "朋友圈") | [Go](https://github.com/openset/leetcode/tree/master/problems/friend-circles) | Medium | -| 548 | [Split Array with Equal Sum](https://leetcode.com/problems/split-array-with-equal-sum "将数组分割成和相等的子数组") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/split-array-with-equal-sum) | Medium | -| 549 | [Binary Tree Longest Consecutive Sequence II](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence-ii "二叉树中最长的连续序列") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-longest-consecutive-sequence-ii) | Medium | -| 550 | [Game Play Analysis IV](https://leetcode.com/problems/game-play-analysis-iv "游戏玩法分析 IV") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-iv) | Medium | -| 551 | [Student Attendance Record I](https://leetcode.com/problems/student-attendance-record-i "学生出勤记录 I") | [Go](https://github.com/openset/leetcode/tree/master/problems/student-attendance-record-i) | Easy | -| 552 | [Student Attendance Record II](https://leetcode.com/problems/student-attendance-record-ii "学生出勤记录 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/student-attendance-record-ii) | Hard | -| 553 | [Optimal Division](https://leetcode.com/problems/optimal-division "最优除法") | [Go](https://github.com/openset/leetcode/tree/master/problems/optimal-division) | Medium | -| 554 | [Brick Wall](https://leetcode.com/problems/brick-wall "砖墙") | [Go](https://github.com/openset/leetcode/tree/master/problems/brick-wall) | Medium | -| 555 | [Split Concatenated Strings](https://leetcode.com/problems/split-concatenated-strings "分割连接字符串") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/split-concatenated-strings) | Medium | -| 556 | [Next Greater Element III](https://leetcode.com/problems/next-greater-element-iii "下一个更大元素 III") | [Go](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-iii) | Medium | -| 557 | [Reverse Words in a String III](https://leetcode.com/problems/reverse-words-in-a-string-iii "反转字符串中的单词 III") | [Go](https://github.com/openset/leetcode/tree/master/problems/reverse-words-in-a-string-iii) | Easy | -| 558 | [Quad Tree Intersection](https://leetcode.com/problems/quad-tree-intersection "四叉树交集") | [Go](https://github.com/openset/leetcode/tree/master/problems/quad-tree-intersection) | Easy | -| 559 | [Maximum Depth of N-ary Tree](https://leetcode.com/problems/maximum-depth-of-n-ary-tree "N叉树的最大深度") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-depth-of-n-ary-tree) | Easy | -| 560 | [Subarray Sum Equals K](https://leetcode.com/problems/subarray-sum-equals-k "和为K的子数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/subarray-sum-equals-k) | Medium | -| 561 | [Array Partition I](https://leetcode.com/problems/array-partition-i "数组拆分 I") | [Go](https://github.com/openset/leetcode/tree/master/problems/array-partition-i) | Easy | -| 562 | [Longest Line of Consecutive One in Matrix](https://leetcode.com/problems/longest-line-of-consecutive-one-in-matrix "矩阵中最长的连续1线段") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-line-of-consecutive-one-in-matrix) | Medium | -| 563 | [Binary Tree Tilt](https://leetcode.com/problems/binary-tree-tilt "二叉树的坡度") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-tilt) | Easy | -| 564 | [Find the Closest Palindrome](https://leetcode.com/problems/find-the-closest-palindrome "寻找最近的回文数") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-the-closest-palindrome) | Hard | -| 565 | [Array Nesting](https://leetcode.com/problems/array-nesting "数组嵌套") | [Go](https://github.com/openset/leetcode/tree/master/problems/array-nesting) | Medium | -| 566 | [Reshape the Matrix](https://leetcode.com/problems/reshape-the-matrix "重塑矩阵") | [Go](https://github.com/openset/leetcode/tree/master/problems/reshape-the-matrix) | Easy | -| 567 | [Permutation in String](https://leetcode.com/problems/permutation-in-string "字符串的排列") | [Go](https://github.com/openset/leetcode/tree/master/problems/permutation-in-string) | Medium | -| 568 | [Maximum Vacation Days](https://leetcode.com/problems/maximum-vacation-days "最大休假天数") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-vacation-days) | Hard | -| 569 | [Median Employee Salary](https://leetcode.com/problems/median-employee-salary "员工薪水中位数") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/median-employee-salary) | Hard | -| 570 | [Managers with at Least 5 Direct Reports](https://leetcode.com/problems/managers-with-at-least-5-direct-reports "至少有5名直接下属的经理") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/managers-with-at-least-5-direct-reports) | Medium | -| 571 | [Find Median Given Frequency of Numbers](https://leetcode.com/problems/find-median-given-frequency-of-numbers "给定数字的频率查询中位数") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/find-median-given-frequency-of-numbers) | Hard | -| 572 | [Subtree of Another Tree](https://leetcode.com/problems/subtree-of-another-tree "另一个树的子树") | [Go](https://github.com/openset/leetcode/tree/master/problems/subtree-of-another-tree) | Easy | -| 573 | [Squirrel Simulation](https://leetcode.com/problems/squirrel-simulation "松鼠模拟") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/squirrel-simulation) | Medium | -| 574 | [Winning Candidate](https://leetcode.com/problems/winning-candidate "当选者") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/winning-candidate) | Medium | -| 575 | [Distribute Candies](https://leetcode.com/problems/distribute-candies "分糖果") | [Go](https://github.com/openset/leetcode/tree/master/problems/distribute-candies) | Easy | -| 576 | [Out of Boundary Paths](https://leetcode.com/problems/out-of-boundary-paths "出界的路径数") | [Go](https://github.com/openset/leetcode/tree/master/problems/out-of-boundary-paths) | Medium | -| 577 | [Employee Bonus](https://leetcode.com/problems/employee-bonus "员工奖金") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/employee-bonus) | Easy | -| 578 | [Get Highest Answer Rate Question](https://leetcode.com/problems/get-highest-answer-rate-question "查询回答率最高的问题") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/get-highest-answer-rate-question) | Medium | -| 579 | [Find Cumulative Salary of an Employee](https://leetcode.com/problems/find-cumulative-salary-of-an-employee "查询员工的累计薪水") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/find-cumulative-salary-of-an-employee) | Hard | -| 580 | [Count Student Number in Departments](https://leetcode.com/problems/count-student-number-in-departments "统计各专业学生人数") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/count-student-number-in-departments) | Medium | -| 581 | [Shortest Unsorted Continuous Subarray](https://leetcode.com/problems/shortest-unsorted-continuous-subarray "最短无序连续子数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-unsorted-continuous-subarray) | Easy | -| 582 | [Kill Process](https://leetcode.com/problems/kill-process "杀死进程") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/kill-process) | Medium | -| 583 | [Delete Operation for Two Strings](https://leetcode.com/problems/delete-operation-for-two-strings "两个字符串的删除操作") | [Go](https://github.com/openset/leetcode/tree/master/problems/delete-operation-for-two-strings) | Medium | -| 584 | [Find Customer Referee](https://leetcode.com/problems/find-customer-referee "寻找用户推荐人") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/find-customer-referee) | Easy | -| 585 | [Investments in 2016](https://leetcode.com/problems/investments-in-2016 "2016年的投资") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/investments-in-2016) | Medium | -| 586 | [Customer Placing the Largest Number of Orders](https://leetcode.com/problems/customer-placing-the-largest-number-of-orders "订单最多的客户") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/customer-placing-the-largest-number-of-orders) | Easy | -| 587 | [Erect the Fence](https://leetcode.com/problems/erect-the-fence "安装栅栏") | [Go](https://github.com/openset/leetcode/tree/master/problems/erect-the-fence) | Hard | -| 588 | [Design In-Memory File System](https://leetcode.com/problems/design-in-memory-file-system "设计内存文件系统") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-in-memory-file-system) | Hard | -| 589 | [N-ary Tree Preorder Traversal](https://leetcode.com/problems/n-ary-tree-preorder-traversal "N叉树的前序遍历") | [Go](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-preorder-traversal) | Easy | -| 590 | [N-ary Tree Postorder Traversal](https://leetcode.com/problems/n-ary-tree-postorder-traversal "N叉树的后序遍历") | [Go](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-postorder-traversal) | Easy | -| 591 | [Tag Validator](https://leetcode.com/problems/tag-validator "标签验证器") | [Go](https://github.com/openset/leetcode/tree/master/problems/tag-validator) | Hard | -| 592 | [Fraction Addition and Subtraction](https://leetcode.com/problems/fraction-addition-and-subtraction "分数加减运算") | [Go](https://github.com/openset/leetcode/tree/master/problems/fraction-addition-and-subtraction) | Medium | -| 593 | [Valid Square](https://leetcode.com/problems/valid-square "有效的正方形") | [Go](https://github.com/openset/leetcode/tree/master/problems/valid-square) | Medium | -| 594 | [Longest Harmonious Subsequence](https://leetcode.com/problems/longest-harmonious-subsequence "最长和谐子序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-harmonious-subsequence) | Easy | -| 595 | [Big Countries](https://leetcode.com/problems/big-countries "大的国家") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/big-countries) | Easy | -| 596 | [Classes More Than 5 Students](https://leetcode.com/problems/classes-more-than-5-students "超过5名学生的课") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/classes-more-than-5-students) | Easy | -| 597 | [Friend Requests I: Overall Acceptance Rate](https://leetcode.com/problems/friend-requests-i-overall-acceptance-rate "好友申请 I :总体通过率") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/friend-requests-i-overall-acceptance-rate) | Easy | -| 598 | [Range Addition II](https://leetcode.com/problems/range-addition-ii "范围求和 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/range-addition-ii) | Easy | -| 599 | [Minimum Index Sum of Two Lists](https://leetcode.com/problems/minimum-index-sum-of-two-lists "两个列表的最小索引总和") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-index-sum-of-two-lists) | Easy | -| 600 | [Non-negative Integers without Consecutive Ones](https://leetcode.com/problems/non-negative-integers-without-consecutive-ones "不含连续1的非负整数") | [Go](https://github.com/openset/leetcode/tree/master/problems/non-negative-integers-without-consecutive-ones) | Hard | +| 301 | [Remove Invalid Parentheses](https://leetcode.com/problems/remove-invalid-parentheses "删除无效的括号") | [Go](../problems/remove-invalid-parentheses) | Hard | +| 302 | [Smallest Rectangle Enclosing Black Pixels](https://leetcode.com/problems/smallest-rectangle-enclosing-black-pixels "包含全部黑色像素的最小矩形") 🔒 | [Go](../problems/smallest-rectangle-enclosing-black-pixels) | Hard | +| 303 | [Range Sum Query - Immutable](https://leetcode.com/problems/range-sum-query-immutable "区域和检索 - 数组不可变") | [Go](../problems/range-sum-query-immutable) | Easy | +| 304 | [Range Sum Query 2D - Immutable](https://leetcode.com/problems/range-sum-query-2d-immutable "二维区域和检索 - 矩阵不可变") | [Go](../problems/range-sum-query-2d-immutable) | Medium | +| 305 | [Number of Islands II](https://leetcode.com/problems/number-of-islands-ii "岛屿数量 II") 🔒 | [Go](../problems/number-of-islands-ii) | Hard | +| 306 | [Additive Number](https://leetcode.com/problems/additive-number "累加数") | [Go](../problems/additive-number) | Medium | +| 307 | [Range Sum Query - Mutable](https://leetcode.com/problems/range-sum-query-mutable "区域和检索 - 数组可修改") | [Go](../problems/range-sum-query-mutable) | Medium | +| 308 | [Range Sum Query 2D - Mutable](https://leetcode.com/problems/range-sum-query-2d-mutable "二维区域和检索 - 可变") 🔒 | [Go](../problems/range-sum-query-2d-mutable) | Hard | +| 309 | [Best Time to Buy and Sell Stock with Cooldown](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown "最佳买卖股票时机含冷冻期") | [Go](../problems/best-time-to-buy-and-sell-stock-with-cooldown) | Medium | +| 310 | [Minimum Height Trees](https://leetcode.com/problems/minimum-height-trees "最小高度树") | [Go](../problems/minimum-height-trees) | Medium | +| 311 | [Sparse Matrix Multiplication](https://leetcode.com/problems/sparse-matrix-multiplication "稀疏矩阵的乘法") 🔒 | [Go](../problems/sparse-matrix-multiplication) | Medium | +| 312 | [Burst Balloons](https://leetcode.com/problems/burst-balloons "戳气球") | [Go](../problems/burst-balloons) | Hard | +| 313 | [Super Ugly Number](https://leetcode.com/problems/super-ugly-number "超级丑数") | [Go](../problems/super-ugly-number) | Medium | +| 314 | [Binary Tree Vertical Order Traversal](https://leetcode.com/problems/binary-tree-vertical-order-traversal "二叉树的垂直遍历") 🔒 | [Go](../problems/binary-tree-vertical-order-traversal) | Medium | +| 315 | [Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self "计算右侧小于当前元素的个数") | [Go](../problems/count-of-smaller-numbers-after-self) | Hard | +| 316 | [Remove Duplicate Letters](https://leetcode.com/problems/remove-duplicate-letters "去除重复字母") | [Go](../problems/remove-duplicate-letters) | Hard | +| 317 | [Shortest Distance from All Buildings](https://leetcode.com/problems/shortest-distance-from-all-buildings "离建筑物最近的距离") 🔒 | [Go](../problems/shortest-distance-from-all-buildings) | Hard | +| 318 | [Maximum Product of Word Lengths](https://leetcode.com/problems/maximum-product-of-word-lengths "最大单词长度乘积") | [Go](../problems/maximum-product-of-word-lengths) | Medium | +| 319 | [Bulb Switcher](https://leetcode.com/problems/bulb-switcher "灯泡开关") | [Go](../problems/bulb-switcher) | Medium | +| 320 | [Generalized Abbreviation](https://leetcode.com/problems/generalized-abbreviation "列举单词的全部缩写") 🔒 | [Go](../problems/generalized-abbreviation) | Medium | +| 321 | [Create Maximum Number](https://leetcode.com/problems/create-maximum-number "拼接最大数") | [Go](../problems/create-maximum-number) | Hard | +| 322 | [Coin Change](https://leetcode.com/problems/coin-change "零钱兑换") | [Go](../problems/coin-change) | Medium | +| 323 | [Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph "无向图中连通分量的数目") 🔒 | [Go](../problems/number-of-connected-components-in-an-undirected-graph) | Medium | +| 324 | [Wiggle Sort II](https://leetcode.com/problems/wiggle-sort-ii "摆动排序 II") | [Go](../problems/wiggle-sort-ii) | Medium | +| 325 | [Maximum Size Subarray Sum Equals k](https://leetcode.com/problems/maximum-size-subarray-sum-equals-k "和等于 k 的最长子数组长度") 🔒 | [Go](../problems/maximum-size-subarray-sum-equals-k) | Medium | +| 326 | [Power of Three](https://leetcode.com/problems/power-of-three "3的幂") | [Go](../problems/power-of-three) | Easy | +| 327 | [Count of Range Sum](https://leetcode.com/problems/count-of-range-sum "区间和的个数") | [Go](../problems/count-of-range-sum) | Hard | +| 328 | [Odd Even Linked List](https://leetcode.com/problems/odd-even-linked-list "奇偶链表") | [Go](../problems/odd-even-linked-list) | Medium | +| 329 | [Longest Increasing Path in a Matrix](https://leetcode.com/problems/longest-increasing-path-in-a-matrix "矩阵中的最长递增路径") | [Go](../problems/longest-increasing-path-in-a-matrix) | Hard | +| 330 | [Patching Array](https://leetcode.com/problems/patching-array "按要求补齐数组") | [Go](../problems/patching-array) | Hard | +| 331 | [Verify Preorder Serialization of a Binary Tree](https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree "验证二叉树的前序序列化") | [Go](../problems/verify-preorder-serialization-of-a-binary-tree) | Medium | +| 332 | [Reconstruct Itinerary](https://leetcode.com/problems/reconstruct-itinerary "重新安排行程") | [Go](../problems/reconstruct-itinerary) | Medium | +| 333 | [Largest BST Subtree](https://leetcode.com/problems/largest-bst-subtree "最大 BST 子树") 🔒 | [Go](../problems/largest-bst-subtree) | Medium | +| 334 | [Increasing Triplet Subsequence](https://leetcode.com/problems/increasing-triplet-subsequence "递增的三元子序列") | [Go](../problems/increasing-triplet-subsequence) | Medium | +| 335 | [Self Crossing](https://leetcode.com/problems/self-crossing "路径交叉") | [Go](../problems/self-crossing) | Hard | +| 336 | [Palindrome Pairs](https://leetcode.com/problems/palindrome-pairs "回文对") | [Go](../problems/palindrome-pairs) | Hard | +| 337 | [House Robber III](https://leetcode.com/problems/house-robber-iii "打家劫舍 III") | [Go](../problems/house-robber-iii) | Medium | +| 338 | [Counting Bits](https://leetcode.com/problems/counting-bits "比特位计数") | [Go](../problems/counting-bits) | Medium | +| 339 | [Nested List Weight Sum](https://leetcode.com/problems/nested-list-weight-sum "嵌套列表权重和") 🔒 | [Go](../problems/nested-list-weight-sum) | Easy | +| 340 | [Longest Substring with At Most K Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters "至多包含 K 个不同字符的最长子串") 🔒 | [Go](../problems/longest-substring-with-at-most-k-distinct-characters) | Hard | +| 341 | [Flatten Nested List Iterator](https://leetcode.com/problems/flatten-nested-list-iterator "扁平化嵌套列表迭代器") | [Go](../problems/flatten-nested-list-iterator) | Medium | +| 342 | [Power of Four](https://leetcode.com/problems/power-of-four "4的幂") | [Go](../problems/power-of-four) | Easy | +| 343 | [Integer Break](https://leetcode.com/problems/integer-break "整数拆分") | [Go](../problems/integer-break) | Medium | +| 344 | [Reverse String](https://leetcode.com/problems/reverse-string "反转字符串") | [Go](../problems/reverse-string) | Easy | +| 345 | [Reverse Vowels of a String](https://leetcode.com/problems/reverse-vowels-of-a-string "反转字符串中的元音字母") | [Go](../problems/reverse-vowels-of-a-string) | Easy | +| 346 | [Moving Average from Data Stream](https://leetcode.com/problems/moving-average-from-data-stream "数据流中的移动平均值") 🔒 | [Go](../problems/moving-average-from-data-stream) | Easy | +| 347 | [Top K Frequent Elements](https://leetcode.com/problems/top-k-frequent-elements "前 K 个高频元素") | [Go](../problems/top-k-frequent-elements) | Medium | +| 348 | [Design Tic-Tac-Toe](https://leetcode.com/problems/design-tic-tac-toe "判定井字棋胜负") 🔒 | [Go](../problems/design-tic-tac-toe) | Medium | +| 349 | [Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays "两个数组的交集") | [Go](../problems/intersection-of-two-arrays) | Easy | +| 350 | [Intersection of Two Arrays II](https://leetcode.com/problems/intersection-of-two-arrays-ii "两个数组的交集 II") | [Go](../problems/intersection-of-two-arrays-ii) | Easy | +| 351 | [Android Unlock Patterns](https://leetcode.com/problems/android-unlock-patterns "安卓系统手势解锁") 🔒 | [Go](../problems/android-unlock-patterns) | Medium | +| 352 | [Data Stream as Disjoint Intervals](https://leetcode.com/problems/data-stream-as-disjoint-intervals "将数据流变为多个不相交区间") | [Go](../problems/data-stream-as-disjoint-intervals) | Hard | +| 353 | [Design Snake Game](https://leetcode.com/problems/design-snake-game "贪吃蛇") 🔒 | [Go](../problems/design-snake-game) | Medium | +| 354 | [Russian Doll Envelopes](https://leetcode.com/problems/russian-doll-envelopes "俄罗斯套娃信封问题") | [Go](../problems/russian-doll-envelopes) | Hard | +| 355 | [Design Twitter](https://leetcode.com/problems/design-twitter "设计推特") | [Go](../problems/design-twitter) | Medium | +| 356 | [Line Reflection](https://leetcode.com/problems/line-reflection "直线镜像") 🔒 | [Go](../problems/line-reflection) | Medium | +| 357 | [Count Numbers with Unique Digits](https://leetcode.com/problems/count-numbers-with-unique-digits "计算各个位数不同的数字个数") | [Go](../problems/count-numbers-with-unique-digits) | Medium | +| 358 | [Rearrange String k Distance Apart](https://leetcode.com/problems/rearrange-string-k-distance-apart "K 距离间隔重排字符串") 🔒 | [Go](../problems/rearrange-string-k-distance-apart) | Hard | +| 359 | [Logger Rate Limiter](https://leetcode.com/problems/logger-rate-limiter "日志速率限制器") 🔒 | [Go](../problems/logger-rate-limiter) | Easy | +| 360 | [Sort Transformed Array](https://leetcode.com/problems/sort-transformed-array "有序转化数组") 🔒 | [Go](../problems/sort-transformed-array) | Medium | +| 361 | [Bomb Enemy](https://leetcode.com/problems/bomb-enemy "轰炸敌人") 🔒 | [Go](../problems/bomb-enemy) | Medium | +| 362 | [Design Hit Counter](https://leetcode.com/problems/design-hit-counter "敲击计数器") 🔒 | [Go](../problems/design-hit-counter) | Medium | +| 363 | [Max Sum of Rectangle No Larger Than K](https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k "矩形区域不超过 K 的最大数值和") | [Go](../problems/max-sum-of-rectangle-no-larger-than-k) | Hard | +| 364 | [Nested List Weight Sum II](https://leetcode.com/problems/nested-list-weight-sum-ii "加权嵌套序列和 II") 🔒 | [Go](../problems/nested-list-weight-sum-ii) | Medium | +| 365 | [Water and Jug Problem](https://leetcode.com/problems/water-and-jug-problem "水壶问题") | [Go](../problems/water-and-jug-problem) | Medium | +| 366 | [Find Leaves of Binary Tree](https://leetcode.com/problems/find-leaves-of-binary-tree "寻找完全二叉树的叶子节点") 🔒 | [Go](../problems/find-leaves-of-binary-tree) | Medium | +| 367 | [Valid Perfect Square](https://leetcode.com/problems/valid-perfect-square "有效的完全平方数") | [Go](../problems/valid-perfect-square) | Easy | +| 368 | [Largest Divisible Subset](https://leetcode.com/problems/largest-divisible-subset "最大整除子集") | [Go](../problems/largest-divisible-subset) | Medium | +| 369 | [Plus One Linked List](https://leetcode.com/problems/plus-one-linked-list "给单链表加一") 🔒 | [Go](../problems/plus-one-linked-list) | Medium | +| 370 | [Range Addition](https://leetcode.com/problems/range-addition "区间加法") 🔒 | [Go](../problems/range-addition) | Medium | +| 371 | [Sum of Two Integers](https://leetcode.com/problems/sum-of-two-integers "两整数之和") | [Go](../problems/sum-of-two-integers) | Easy | +| 372 | [Super Pow](https://leetcode.com/problems/super-pow "超级次方") | [Go](../problems/super-pow) | Medium | +| 373 | [Find K Pairs with Smallest Sums](https://leetcode.com/problems/find-k-pairs-with-smallest-sums "查找和最小的K对数字") | [Go](../problems/find-k-pairs-with-smallest-sums) | Medium | +| 374 | [Guess Number Higher or Lower](https://leetcode.com/problems/guess-number-higher-or-lower "猜数字大小") | [Go](../problems/guess-number-higher-or-lower) | Easy | +| 375 | [Guess Number Higher or Lower II](https://leetcode.com/problems/guess-number-higher-or-lower-ii "猜数字大小 II") | [Go](../problems/guess-number-higher-or-lower-ii) | Medium | +| 376 | [Wiggle Subsequence](https://leetcode.com/problems/wiggle-subsequence "摆动序列") | [Go](../problems/wiggle-subsequence) | Medium | +| 377 | [Combination Sum IV](https://leetcode.com/problems/combination-sum-iv "组合总和 Ⅳ") | [Go](../problems/combination-sum-iv) | Medium | +| 378 | [Kth Smallest Element in a Sorted Matrix](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix "有序矩阵中第K小的元素") | [Go](../problems/kth-smallest-element-in-a-sorted-matrix) | Medium | +| 379 | [Design Phone Directory](https://leetcode.com/problems/design-phone-directory "电话目录管理系统") 🔒 | [Go](../problems/design-phone-directory) | Medium | +| 380 | [Insert Delete GetRandom O(1)](https://leetcode.com/problems/insert-delete-getrandom-o1 "常数时间插入、删除和获取随机元素") | [Go](../problems/insert-delete-getrandom-o1) | Medium | +| 381 | [Insert Delete GetRandom O(1) - Duplicates allowed](https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed "O(1) 时间插入、删除和获取随机元素 - 允许重复") | [Go](../problems/insert-delete-getrandom-o1-duplicates-allowed) | Hard | +| 382 | [Linked List Random Node](https://leetcode.com/problems/linked-list-random-node "链表随机节点") | [Go](../problems/linked-list-random-node) | Medium | +| 383 | [Ransom Note](https://leetcode.com/problems/ransom-note "赎金信") | [Go](../problems/ransom-note) | Easy | +| 384 | [Shuffle an Array](https://leetcode.com/problems/shuffle-an-array "打乱数组") | [Go](../problems/shuffle-an-array) | Medium | +| 385 | [Mini Parser](https://leetcode.com/problems/mini-parser "迷你语法分析器") | [Go](../problems/mini-parser) | Medium | +| 386 | [Lexicographical Numbers](https://leetcode.com/problems/lexicographical-numbers "字典序排数") | [Go](../problems/lexicographical-numbers) | Medium | +| 387 | [First Unique Character in a String](https://leetcode.com/problems/first-unique-character-in-a-string "字符串中的第一个唯一字符") | [Go](../problems/first-unique-character-in-a-string) | Easy | +| 388 | [Longest Absolute File Path](https://leetcode.com/problems/longest-absolute-file-path "文件的最长绝对路径") | [Go](../problems/longest-absolute-file-path) | Medium | +| 389 | [Find the Difference](https://leetcode.com/problems/find-the-difference "找不同") | [Go](../problems/find-the-difference) | Easy | +| 390 | [Elimination Game](https://leetcode.com/problems/elimination-game "消除游戏") | [Go](../problems/elimination-game) | Medium | +| 391 | [Perfect Rectangle](https://leetcode.com/problems/perfect-rectangle "完美矩形") | [Go](../problems/perfect-rectangle) | Hard | +| 392 | [Is Subsequence](https://leetcode.com/problems/is-subsequence "判断子序列") | [Go](../problems/is-subsequence) | Easy | +| 393 | [UTF-8 Validation](https://leetcode.com/problems/utf-8-validation "UTF-8 编码验证") | [Go](../problems/utf-8-validation) | Medium | +| 394 | [Decode String](https://leetcode.com/problems/decode-string "字符串解码") | [Go](../problems/decode-string) | Medium | +| 395 | [Longest Substring with At Least K Repeating Characters](https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters "至少有K个重复字符的最长子串") | [Go](../problems/longest-substring-with-at-least-k-repeating-characters) | Medium | +| 396 | [Rotate Function](https://leetcode.com/problems/rotate-function "旋转函数") | [Go](../problems/rotate-function) | Medium | +| 397 | [Integer Replacement](https://leetcode.com/problems/integer-replacement "整数替换") | [Go](../problems/integer-replacement) | Medium | +| 398 | [Random Pick Index](https://leetcode.com/problems/random-pick-index "随机数索引") | [Go](../problems/random-pick-index) | Medium | +| 399 | [Evaluate Division](https://leetcode.com/problems/evaluate-division "除法求值") | [Go](../problems/evaluate-division) | Medium | +| 400 | [Nth Digit](https://leetcode.com/problems/nth-digit "第N个数字") | [Go](../problems/nth-digit) | Medium | +| 401 | [Binary Watch](https://leetcode.com/problems/binary-watch "二进制手表") | [Go](../problems/binary-watch) | Easy | +| 402 | [Remove K Digits](https://leetcode.com/problems/remove-k-digits "移掉K位数字") | [Go](../problems/remove-k-digits) | Medium | +| 403 | [Frog Jump](https://leetcode.com/problems/frog-jump "青蛙过河") | [Go](../problems/frog-jump) | Hard | +| 404 | [Sum of Left Leaves](https://leetcode.com/problems/sum-of-left-leaves "左叶子之和") | [Go](../problems/sum-of-left-leaves) | Easy | +| 405 | [Convert a Number to Hexadecimal](https://leetcode.com/problems/convert-a-number-to-hexadecimal "数字转换为十六进制数") | [Go](../problems/convert-a-number-to-hexadecimal) | Easy | +| 406 | [Queue Reconstruction by Height](https://leetcode.com/problems/queue-reconstruction-by-height "根据身高重建队列") | [Go](../problems/queue-reconstruction-by-height) | Medium | +| 407 | [Trapping Rain Water II](https://leetcode.com/problems/trapping-rain-water-ii "接雨水 II") | [Go](../problems/trapping-rain-water-ii) | Hard | +| 408 | [Valid Word Abbreviation](https://leetcode.com/problems/valid-word-abbreviation "有效单词缩写") 🔒 | [Go](../problems/valid-word-abbreviation) | Easy | +| 409 | [Longest Palindrome](https://leetcode.com/problems/longest-palindrome "最长回文串") | [Go](../problems/longest-palindrome) | Easy | +| 410 | [Split Array Largest Sum](https://leetcode.com/problems/split-array-largest-sum "分割数组的最大值") | [Go](../problems/split-array-largest-sum) | Hard | +| 411 | [Minimum Unique Word Abbreviation](https://leetcode.com/problems/minimum-unique-word-abbreviation "最短特异单词缩写") 🔒 | [Go](../problems/minimum-unique-word-abbreviation) | Hard | +| 412 | [Fizz Buzz](https://leetcode.com/problems/fizz-buzz "Fizz Buzz") | [Go](../problems/fizz-buzz) | Easy | +| 413 | [Arithmetic Slices](https://leetcode.com/problems/arithmetic-slices "等差数列划分") | [Go](../problems/arithmetic-slices) | Medium | +| 414 | [Third Maximum Number](https://leetcode.com/problems/third-maximum-number "第三大的数") | [Go](../problems/third-maximum-number) | Easy | +| 415 | [Add Strings](https://leetcode.com/problems/add-strings "字符串相加") | [Go](../problems/add-strings) | Easy | +| 416 | [Partition Equal Subset Sum](https://leetcode.com/problems/partition-equal-subset-sum "分割等和子集") | [Go](../problems/partition-equal-subset-sum) | Medium | +| 417 | [Pacific Atlantic Water Flow](https://leetcode.com/problems/pacific-atlantic-water-flow "太平洋大西洋水流问题") | [Go](../problems/pacific-atlantic-water-flow) | Medium | +| 418 | [Sentence Screen Fitting](https://leetcode.com/problems/sentence-screen-fitting "屏幕可显示句子的数量") 🔒 | [Go](../problems/sentence-screen-fitting) | Medium | +| 419 | [Battleships in a Board](https://leetcode.com/problems/battleships-in-a-board "甲板上的战舰") | [Go](../problems/battleships-in-a-board) | Medium | +| 420 | [Strong Password Checker](https://leetcode.com/problems/strong-password-checker "强密码检验器") | [Go](../problems/strong-password-checker) | Hard | +| 421 | [Maximum XOR of Two Numbers in an Array](https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array "数组中两个数的最大异或值") | [Go](../problems/maximum-xor-of-two-numbers-in-an-array) | Medium | +| 422 | [Valid Word Square](https://leetcode.com/problems/valid-word-square "有效的单词方块") 🔒 | [Go](../problems/valid-word-square) | Easy | +| 423 | [Reconstruct Original Digits from English](https://leetcode.com/problems/reconstruct-original-digits-from-english "从英文中重建数字") | [Go](../problems/reconstruct-original-digits-from-english) | Medium | +| 424 | [Longest Repeating Character Replacement](https://leetcode.com/problems/longest-repeating-character-replacement "替换后的最长重复字符") | [Go](../problems/longest-repeating-character-replacement) | Medium | +| 425 | [Word Squares](https://leetcode.com/problems/word-squares "单词方块") 🔒 | [Go](../problems/word-squares) | Hard | +| 426 | [Convert Binary Search Tree to Sorted Doubly Linked List](https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list "将二叉搜索树转化为排序的双向链表") 🔒 | [Go](../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) | Medium | +| 427 | [Construct Quad Tree](https://leetcode.com/problems/construct-quad-tree "建立四叉树") | [Go](../problems/construct-quad-tree) | Medium | +| 428 | [Serialize and Deserialize N-ary Tree](https://leetcode.com/problems/serialize-and-deserialize-n-ary-tree "序列化和反序列化 N 叉树") 🔒 | [Go](../problems/serialize-and-deserialize-n-ary-tree) | Hard | +| 429 | [N-ary Tree Level Order Traversal](https://leetcode.com/problems/n-ary-tree-level-order-traversal "N叉树的层序遍历") | [Go](../problems/n-ary-tree-level-order-traversal) | Medium | +| 430 | [Flatten a Multilevel Doubly Linked List](https://leetcode.com/problems/flatten-a-multilevel-doubly-linked-list "扁平化多级双向链表") | [Go](../problems/flatten-a-multilevel-doubly-linked-list) | Medium | +| 431 | [Encode N-ary Tree to Binary Tree](https://leetcode.com/problems/encode-n-ary-tree-to-binary-tree "将 N 叉树编码为二叉树") 🔒 | [Go](../problems/encode-n-ary-tree-to-binary-tree) | Hard | +| 432 | [All O`one Data Structure](https://leetcode.com/problems/all-oone-data-structure "全 O(1) 的数据结构") | [Go](../problems/all-oone-data-structure) | Hard | +| 433 | [Minimum Genetic Mutation](https://leetcode.com/problems/minimum-genetic-mutation "最小基因变化") | [Go](../problems/minimum-genetic-mutation) | Medium | +| 434 | [Number of Segments in a String](https://leetcode.com/problems/number-of-segments-in-a-string "字符串中的单词数") | [Go](../problems/number-of-segments-in-a-string) | Easy | +| 435 | [Non-overlapping Intervals](https://leetcode.com/problems/non-overlapping-intervals "无重叠区间") | [Go](../problems/non-overlapping-intervals) | Medium | +| 436 | [Find Right Interval](https://leetcode.com/problems/find-right-interval "寻找右区间") | [Go](../problems/find-right-interval) | Medium | +| 437 | [Path Sum III](https://leetcode.com/problems/path-sum-iii "路径总和 III") | [Go](../problems/path-sum-iii) | Easy | +| 438 | [Find All Anagrams in a String](https://leetcode.com/problems/find-all-anagrams-in-a-string "找到字符串中所有字母异位词") | [Go](../problems/find-all-anagrams-in-a-string) | Medium | +| 439 | [Ternary Expression Parser](https://leetcode.com/problems/ternary-expression-parser "三元表达式解析器") 🔒 | [Go](../problems/ternary-expression-parser) | Medium | +| 440 | [K-th Smallest in Lexicographical Order](https://leetcode.com/problems/k-th-smallest-in-lexicographical-order "字典序的第K小数字") | [Go](../problems/k-th-smallest-in-lexicographical-order) | Hard | +| 441 | [Arranging Coins](https://leetcode.com/problems/arranging-coins "排列硬币") | [Go](../problems/arranging-coins) | Easy | +| 442 | [Find All Duplicates in an Array](https://leetcode.com/problems/find-all-duplicates-in-an-array "数组中重复的数据") | [Go](../problems/find-all-duplicates-in-an-array) | Medium | +| 443 | [String Compression](https://leetcode.com/problems/string-compression "压缩字符串") | [Go](../problems/string-compression) | Easy | +| 444 | [Sequence Reconstruction](https://leetcode.com/problems/sequence-reconstruction "序列重建") 🔒 | [Go](../problems/sequence-reconstruction) | Medium | +| 445 | [Add Two Numbers II](https://leetcode.com/problems/add-two-numbers-ii "两数相加 II") | [Go](../problems/add-two-numbers-ii) | Medium | +| 446 | [Arithmetic Slices II - Subsequence](https://leetcode.com/problems/arithmetic-slices-ii-subsequence "等差数列划分 II - 子序列") | [Go](../problems/arithmetic-slices-ii-subsequence) | Hard | +| 447 | [Number of Boomerangs](https://leetcode.com/problems/number-of-boomerangs "回旋镖的数量") | [Go](../problems/number-of-boomerangs) | Easy | +| 448 | [Find All Numbers Disappeared in an Array](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array "找到所有数组中消失的数字") | [Go](../problems/find-all-numbers-disappeared-in-an-array) | Easy | +| 449 | [Serialize and Deserialize BST](https://leetcode.com/problems/serialize-and-deserialize-bst "序列化和反序列化二叉搜索树") | [Go](../problems/serialize-and-deserialize-bst) | Medium | +| 450 | [Delete Node in a BST](https://leetcode.com/problems/delete-node-in-a-bst "删除二叉搜索树中的节点") | [Go](../problems/delete-node-in-a-bst) | Medium | +| 451 | [Sort Characters By Frequency](https://leetcode.com/problems/sort-characters-by-frequency "根据字符出现频率排序") | [Go](../problems/sort-characters-by-frequency) | Medium | +| 452 | [Minimum Number of Arrows to Burst Balloons](https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons "用最少数量的箭引爆气球") | [Go](../problems/minimum-number-of-arrows-to-burst-balloons) | Medium | +| 453 | [Minimum Moves to Equal Array Elements](https://leetcode.com/problems/minimum-moves-to-equal-array-elements "最小移动次数使数组元素相等") | [Go](../problems/minimum-moves-to-equal-array-elements) | Easy | +| 454 | [4Sum II](https://leetcode.com/problems/4sum-ii "四数相加 II") | [Go](../problems/4sum-ii) | Medium | +| 455 | [Assign Cookies](https://leetcode.com/problems/assign-cookies "分发饼干") | [Go](../problems/assign-cookies) | Easy | +| 456 | [132 Pattern](https://leetcode.com/problems/132-pattern "132模式") | [Go](../problems/132-pattern) | Medium | +| 457 | [Circular Array Loop](https://leetcode.com/problems/circular-array-loop "环形数组循环") | [Go](../problems/circular-array-loop) | Medium | +| 458 | [Poor Pigs](https://leetcode.com/problems/poor-pigs "可怜的小猪") | [Go](../problems/poor-pigs) | Hard | +| 459 | [Repeated Substring Pattern](https://leetcode.com/problems/repeated-substring-pattern "重复的子字符串") | [Go](../problems/repeated-substring-pattern) | Easy | +| 460 | [LFU Cache](https://leetcode.com/problems/lfu-cache "LFU缓存") | [Go](../problems/lfu-cache) | Hard | +| 461 | [Hamming Distance](https://leetcode.com/problems/hamming-distance "汉明距离") | [Go](../problems/hamming-distance) | Easy | +| 462 | [Minimum Moves to Equal Array Elements II](https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii "最少移动次数使数组元素相等 II") | [Go](../problems/minimum-moves-to-equal-array-elements-ii) | Medium | +| 463 | [Island Perimeter](https://leetcode.com/problems/island-perimeter "岛屿的周长") | [Go](../problems/island-perimeter) | Easy | +| 464 | [Can I Win](https://leetcode.com/problems/can-i-win "我能赢吗") | [Go](../problems/can-i-win) | Medium | +| 465 | [Optimal Account Balancing](https://leetcode.com/problems/optimal-account-balancing "最优账单平衡") 🔒 | [Go](../problems/optimal-account-balancing) | Hard | +| 466 | [Count The Repetitions](https://leetcode.com/problems/count-the-repetitions "统计重复个数") | [Go](../problems/count-the-repetitions) | Hard | +| 467 | [Unique Substrings in Wraparound String](https://leetcode.com/problems/unique-substrings-in-wraparound-string "环绕字符串中唯一的子字符串") | [Go](../problems/unique-substrings-in-wraparound-string) | Medium | +| 468 | [Validate IP Address](https://leetcode.com/problems/validate-ip-address "验证IP地址") | [Go](../problems/validate-ip-address) | Medium | +| 469 | [Convex Polygon](https://leetcode.com/problems/convex-polygon "凸多边形") 🔒 | [Go](../problems/convex-polygon) | Medium | +| 470 | [Implement Rand10() Using Rand7()](https://leetcode.com/problems/implement-rand10-using-rand7 "用 Rand7() 实现 Rand10()") | [Go](../problems/implement-rand10-using-rand7) | Medium | +| 471 | [Encode String with Shortest Length](https://leetcode.com/problems/encode-string-with-shortest-length "编码最短长度的字符串") 🔒 | [Go](../problems/encode-string-with-shortest-length) | Hard | +| 472 | [Concatenated Words](https://leetcode.com/problems/concatenated-words "连接词") | [Go](../problems/concatenated-words) | Hard | +| 473 | [Matchsticks to Square](https://leetcode.com/problems/matchsticks-to-square "火柴拼正方形") | [Go](../problems/matchsticks-to-square) | Medium | +| 474 | [Ones and Zeroes](https://leetcode.com/problems/ones-and-zeroes "一和零") | [Go](../problems/ones-and-zeroes) | Medium | +| 475 | [Heaters](https://leetcode.com/problems/heaters "供暖器") | [Go](../problems/heaters) | Easy | +| 476 | [Number Complement](https://leetcode.com/problems/number-complement "数字的补数") | [Go](../problems/number-complement) | Easy | +| 477 | [Total Hamming Distance](https://leetcode.com/problems/total-hamming-distance "汉明距离总和") | [Go](../problems/total-hamming-distance) | Medium | +| 478 | [Generate Random Point in a Circle](https://leetcode.com/problems/generate-random-point-in-a-circle "在圆内随机生成点") | [Go](../problems/generate-random-point-in-a-circle) | Medium | +| 479 | [Largest Palindrome Product](https://leetcode.com/problems/largest-palindrome-product "最大回文数乘积") | [Go](../problems/largest-palindrome-product) | Hard | +| 480 | [Sliding Window Median](https://leetcode.com/problems/sliding-window-median "滑动窗口中位数") | [Go](../problems/sliding-window-median) | Hard | +| 481 | [Magical String](https://leetcode.com/problems/magical-string "神奇字符串") | [Go](../problems/magical-string) | Medium | +| 482 | [License Key Formatting](https://leetcode.com/problems/license-key-formatting "密钥格式化") | [Go](../problems/license-key-formatting) | Easy | +| 483 | [Smallest Good Base](https://leetcode.com/problems/smallest-good-base "最小好进制") | [Go](../problems/smallest-good-base) | Hard | +| 484 | [Find Permutation](https://leetcode.com/problems/find-permutation "寻找排列") 🔒 | [Go](../problems/find-permutation) | Medium | +| 485 | [Max Consecutive Ones](https://leetcode.com/problems/max-consecutive-ones "最大连续1的个数") | [Go](../problems/max-consecutive-ones) | Easy | +| 486 | [Predict the Winner](https://leetcode.com/problems/predict-the-winner "预测赢家") | [Go](../problems/predict-the-winner) | Medium | +| 487 | [Max Consecutive Ones II](https://leetcode.com/problems/max-consecutive-ones-ii "最大连续1的个数 II") 🔒 | [Go](../problems/max-consecutive-ones-ii) | Medium | +| 488 | [Zuma Game](https://leetcode.com/problems/zuma-game "祖玛游戏") | [Go](../problems/zuma-game) | Hard | +| 489 | [Robot Room Cleaner](https://leetcode.com/problems/robot-room-cleaner "扫地机器人") 🔒 | [Go](../problems/robot-room-cleaner) | Hard | +| 490 | [The Maze](https://leetcode.com/problems/the-maze "迷宫") 🔒 | [Go](../problems/the-maze) | Medium | +| 491 | [Increasing Subsequences](https://leetcode.com/problems/increasing-subsequences "递增子序列") | [Go](../problems/increasing-subsequences) | Medium | +| 492 | [Construct the Rectangle](https://leetcode.com/problems/construct-the-rectangle "构造矩形") | [Go](../problems/construct-the-rectangle) | Easy | +| 493 | [Reverse Pairs](https://leetcode.com/problems/reverse-pairs "翻转对") | [Go](../problems/reverse-pairs) | Hard | +| 494 | [Target Sum](https://leetcode.com/problems/target-sum "目标和") | [Go](../problems/target-sum) | Medium | +| 495 | [Teemo Attacking](https://leetcode.com/problems/teemo-attacking "提莫攻击") | [Go](../problems/teemo-attacking) | Medium | +| 496 | [Next Greater Element I](https://leetcode.com/problems/next-greater-element-i "下一个更大元素 I") | [Go](../problems/next-greater-element-i) | Easy | +| 497 | [Random Point in Non-overlapping Rectangles](https://leetcode.com/problems/random-point-in-non-overlapping-rectangles "非重叠矩形中的随机点") | [Go](../problems/random-point-in-non-overlapping-rectangles) | Medium | +| 498 | [Diagonal Traverse](https://leetcode.com/problems/diagonal-traverse "对角线遍历") | [Go](../problems/diagonal-traverse) | Medium | +| 499 | [The Maze III](https://leetcode.com/problems/the-maze-iii "迷宫 III") 🔒 | [Go](../problems/the-maze-iii) | Hard | +| 500 | [Keyboard Row](https://leetcode.com/problems/keyboard-row "键盘行") | [Go](../problems/keyboard-row) | Easy | +| 501 | [Find Mode in Binary Search Tree](https://leetcode.com/problems/find-mode-in-binary-search-tree "二叉搜索树中的众数") | [Go](../problems/find-mode-in-binary-search-tree) | Easy | +| 502 | [IPO](https://leetcode.com/problems/ipo "IPO") | [Go](../problems/ipo) | Hard | +| 503 | [Next Greater Element II](https://leetcode.com/problems/next-greater-element-ii "下一个更大元素 II") | [Go](../problems/next-greater-element-ii) | Medium | +| 504 | [Base 7](https://leetcode.com/problems/base-7 "七进制数") | [Go](../problems/base-7) | Easy | +| 505 | [The Maze II](https://leetcode.com/problems/the-maze-ii "迷宫 II") 🔒 | [Go](../problems/the-maze-ii) | Medium | +| 506 | [Relative Ranks](https://leetcode.com/problems/relative-ranks "相对名次") | [Go](../problems/relative-ranks) | Easy | +| 507 | [Perfect Number](https://leetcode.com/problems/perfect-number "完美数") | [Go](../problems/perfect-number) | Easy | +| 508 | [Most Frequent Subtree Sum](https://leetcode.com/problems/most-frequent-subtree-sum "出现次数最多的子树元素和") | [Go](../problems/most-frequent-subtree-sum) | Medium | +| 509 | [Fibonacci Number](https://leetcode.com/problems/fibonacci-number "斐波那契数") | [Go](../problems/fibonacci-number) | Easy | +| 510 | [Inorder Successor in BST II](https://leetcode.com/problems/inorder-successor-in-bst-ii "二叉搜索树中的中序后继 II") 🔒 | [Go](../problems/inorder-successor-in-bst-ii) | Medium | +| 511 | [Game Play Analysis I](https://leetcode.com/problems/game-play-analysis-i "游戏玩法分析 I") 🔒 | [MySQL](../problems/game-play-analysis-i) | Easy | +| 512 | [Game Play Analysis II](https://leetcode.com/problems/game-play-analysis-ii "游戏玩法分析 II") 🔒 | [MySQL](../problems/game-play-analysis-ii) | Easy | +| 513 | [Find Bottom Left Tree Value](https://leetcode.com/problems/find-bottom-left-tree-value "找树左下角的值") | [Go](../problems/find-bottom-left-tree-value) | Medium | +| 514 | [Freedom Trail](https://leetcode.com/problems/freedom-trail "自由之路") | [Go](../problems/freedom-trail) | Hard | +| 515 | [Find Largest Value in Each Tree Row](https://leetcode.com/problems/find-largest-value-in-each-tree-row "在每个树行中找最大值") | [Go](../problems/find-largest-value-in-each-tree-row) | Medium | +| 516 | [Longest Palindromic Subsequence](https://leetcode.com/problems/longest-palindromic-subsequence "最长回文子序列") | [Go](../problems/longest-palindromic-subsequence) | Medium | +| 517 | [Super Washing Machines](https://leetcode.com/problems/super-washing-machines "超级洗衣机") | [Go](../problems/super-washing-machines) | Hard | +| 518 | [Coin Change 2](https://leetcode.com/problems/coin-change-2 "零钱兑换 II") | [Go](../problems/coin-change-2) | Medium | +| 519 | [Random Flip Matrix](https://leetcode.com/problems/random-flip-matrix "随机翻转矩阵") | [Go](../problems/random-flip-matrix) | Medium | +| 520 | [Detect Capital](https://leetcode.com/problems/detect-capital "检测大写字母") | [Go](../problems/detect-capital) | Easy | +| 521 | [Longest Uncommon Subsequence I](https://leetcode.com/problems/longest-uncommon-subsequence-i "最长特殊序列 Ⅰ") | [Go](../problems/longest-uncommon-subsequence-i) | Easy | +| 522 | [Longest Uncommon Subsequence II](https://leetcode.com/problems/longest-uncommon-subsequence-ii "最长特殊序列 II") | [Go](../problems/longest-uncommon-subsequence-ii) | Medium | +| 523 | [Continuous Subarray Sum](https://leetcode.com/problems/continuous-subarray-sum "连续的子数组和") | [Go](../problems/continuous-subarray-sum) | Medium | +| 524 | [Longest Word in Dictionary through Deleting](https://leetcode.com/problems/longest-word-in-dictionary-through-deleting "通过删除字母匹配到字典里最长单词") | [Go](../problems/longest-word-in-dictionary-through-deleting) | Medium | +| 525 | [Contiguous Array](https://leetcode.com/problems/contiguous-array "连续数组") | [Go](../problems/contiguous-array) | Medium | +| 526 | [Beautiful Arrangement](https://leetcode.com/problems/beautiful-arrangement "优美的排列") | [Go](../problems/beautiful-arrangement) | Medium | +| 527 | [Word Abbreviation](https://leetcode.com/problems/word-abbreviation "单词缩写") 🔒 | [Go](../problems/word-abbreviation) | Hard | +| 528 | [Random Pick with Weight](https://leetcode.com/problems/random-pick-with-weight "按权重随机选择") | [Go](../problems/random-pick-with-weight) | Medium | +| 529 | [Minesweeper](https://leetcode.com/problems/minesweeper "扫雷游戏") | [Go](../problems/minesweeper) | Medium | +| 530 | [Minimum Absolute Difference in BST](https://leetcode.com/problems/minimum-absolute-difference-in-bst "二叉搜索树的最小绝对差") | [Go](../problems/minimum-absolute-difference-in-bst) | Easy | +| 531 | [Lonely Pixel I](https://leetcode.com/problems/lonely-pixel-i "孤独像素 I") 🔒 | [Go](../problems/lonely-pixel-i) | Medium | +| 532 | [K-diff Pairs in an Array](https://leetcode.com/problems/k-diff-pairs-in-an-array "数组中的K-diff数对") | [Go](../problems/k-diff-pairs-in-an-array) | Easy | +| 533 | [Lonely Pixel II](https://leetcode.com/problems/lonely-pixel-ii "孤独像素 II") 🔒 | [Go](../problems/lonely-pixel-ii) | Medium | +| 534 | [Game Play Analysis III](https://leetcode.com/problems/game-play-analysis-iii "游戏玩法分析 III") 🔒 | [MySQL](../problems/game-play-analysis-iii) | Medium | +| 535 | [Encode and Decode TinyURL](https://leetcode.com/problems/encode-and-decode-tinyurl "TinyURL 的加密与解密") | [Go](../problems/encode-and-decode-tinyurl) | Medium | +| 536 | [Construct Binary Tree from String](https://leetcode.com/problems/construct-binary-tree-from-string "从字符串生成二叉树") 🔒 | [Go](../problems/construct-binary-tree-from-string) | Medium | +| 537 | [Complex Number Multiplication](https://leetcode.com/problems/complex-number-multiplication "复数乘法") | [Go](../problems/complex-number-multiplication) | Medium | +| 538 | [Convert BST to Greater Tree](https://leetcode.com/problems/convert-bst-to-greater-tree "把二叉搜索树转换为累加树") | [Go](../problems/convert-bst-to-greater-tree) | Easy | +| 539 | [Minimum Time Difference](https://leetcode.com/problems/minimum-time-difference "最小时间差") | [Go](../problems/minimum-time-difference) | Medium | +| 540 | [Single Element in a Sorted Array](https://leetcode.com/problems/single-element-in-a-sorted-array "有序数组中的单一元素") | [Go](../problems/single-element-in-a-sorted-array) | Medium | +| 541 | [Reverse String II](https://leetcode.com/problems/reverse-string-ii "反转字符串 II") | [Go](../problems/reverse-string-ii) | Easy | +| 542 | [01 Matrix](https://leetcode.com/problems/01-matrix "01 矩阵") | [Go](../problems/01-matrix) | Medium | +| 543 | [Diameter of Binary Tree](https://leetcode.com/problems/diameter-of-binary-tree "二叉树的直径") | [Go](../problems/diameter-of-binary-tree) | Easy | +| 544 | [Output Contest Matches](https://leetcode.com/problems/output-contest-matches "输出比赛匹配对") 🔒 | [Go](../problems/output-contest-matches) | Medium | +| 545 | [Boundary of Binary Tree](https://leetcode.com/problems/boundary-of-binary-tree "二叉树的边界") 🔒 | [Go](../problems/boundary-of-binary-tree) | Medium | +| 546 | [Remove Boxes](https://leetcode.com/problems/remove-boxes "移除盒子") | [Go](../problems/remove-boxes) | Hard | +| 547 | [Friend Circles](https://leetcode.com/problems/friend-circles "朋友圈") | [Go](../problems/friend-circles) | Medium | +| 548 | [Split Array with Equal Sum](https://leetcode.com/problems/split-array-with-equal-sum "将数组分割成和相等的子数组") 🔒 | [Go](../problems/split-array-with-equal-sum) | Medium | +| 549 | [Binary Tree Longest Consecutive Sequence II](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence-ii "二叉树中最长的连续序列") 🔒 | [Go](../problems/binary-tree-longest-consecutive-sequence-ii) | Medium | +| 550 | [Game Play Analysis IV](https://leetcode.com/problems/game-play-analysis-iv "游戏玩法分析 IV") 🔒 | [MySQL](../problems/game-play-analysis-iv) | Medium | +| 551 | [Student Attendance Record I](https://leetcode.com/problems/student-attendance-record-i "学生出勤记录 I") | [Go](../problems/student-attendance-record-i) | Easy | +| 552 | [Student Attendance Record II](https://leetcode.com/problems/student-attendance-record-ii "学生出勤记录 II") | [Go](../problems/student-attendance-record-ii) | Hard | +| 553 | [Optimal Division](https://leetcode.com/problems/optimal-division "最优除法") | [Go](../problems/optimal-division) | Medium | +| 554 | [Brick Wall](https://leetcode.com/problems/brick-wall "砖墙") | [Go](../problems/brick-wall) | Medium | +| 555 | [Split Concatenated Strings](https://leetcode.com/problems/split-concatenated-strings "分割连接字符串") 🔒 | [Go](../problems/split-concatenated-strings) | Medium | +| 556 | [Next Greater Element III](https://leetcode.com/problems/next-greater-element-iii "下一个更大元素 III") | [Go](../problems/next-greater-element-iii) | Medium | +| 557 | [Reverse Words in a String III](https://leetcode.com/problems/reverse-words-in-a-string-iii "反转字符串中的单词 III") | [Go](../problems/reverse-words-in-a-string-iii) | Easy | +| 558 | [Quad Tree Intersection](https://leetcode.com/problems/quad-tree-intersection "四叉树交集") | [Go](../problems/quad-tree-intersection) | Easy | +| 559 | [Maximum Depth of N-ary Tree](https://leetcode.com/problems/maximum-depth-of-n-ary-tree "N叉树的最大深度") | [Go](../problems/maximum-depth-of-n-ary-tree) | Easy | +| 560 | [Subarray Sum Equals K](https://leetcode.com/problems/subarray-sum-equals-k "和为K的子数组") | [Go](../problems/subarray-sum-equals-k) | Medium | +| 561 | [Array Partition I](https://leetcode.com/problems/array-partition-i "数组拆分 I") | [Go](../problems/array-partition-i) | Easy | +| 562 | [Longest Line of Consecutive One in Matrix](https://leetcode.com/problems/longest-line-of-consecutive-one-in-matrix "矩阵中最长的连续1线段") 🔒 | [Go](../problems/longest-line-of-consecutive-one-in-matrix) | Medium | +| 563 | [Binary Tree Tilt](https://leetcode.com/problems/binary-tree-tilt "二叉树的坡度") | [Go](../problems/binary-tree-tilt) | Easy | +| 564 | [Find the Closest Palindrome](https://leetcode.com/problems/find-the-closest-palindrome "寻找最近的回文数") | [Go](../problems/find-the-closest-palindrome) | Hard | +| 565 | [Array Nesting](https://leetcode.com/problems/array-nesting "数组嵌套") | [Go](../problems/array-nesting) | Medium | +| 566 | [Reshape the Matrix](https://leetcode.com/problems/reshape-the-matrix "重塑矩阵") | [Go](../problems/reshape-the-matrix) | Easy | +| 567 | [Permutation in String](https://leetcode.com/problems/permutation-in-string "字符串的排列") | [Go](../problems/permutation-in-string) | Medium | +| 568 | [Maximum Vacation Days](https://leetcode.com/problems/maximum-vacation-days "最大休假天数") 🔒 | [Go](../problems/maximum-vacation-days) | Hard | +| 569 | [Median Employee Salary](https://leetcode.com/problems/median-employee-salary "员工薪水中位数") 🔒 | [MySQL](../problems/median-employee-salary) | Hard | +| 570 | [Managers with at Least 5 Direct Reports](https://leetcode.com/problems/managers-with-at-least-5-direct-reports "至少有5名直接下属的经理") 🔒 | [MySQL](../problems/managers-with-at-least-5-direct-reports) | Medium | +| 571 | [Find Median Given Frequency of Numbers](https://leetcode.com/problems/find-median-given-frequency-of-numbers "给定数字的频率查询中位数") 🔒 | [MySQL](../problems/find-median-given-frequency-of-numbers) | Hard | +| 572 | [Subtree of Another Tree](https://leetcode.com/problems/subtree-of-another-tree "另一个树的子树") | [Go](../problems/subtree-of-another-tree) | Easy | +| 573 | [Squirrel Simulation](https://leetcode.com/problems/squirrel-simulation "松鼠模拟") 🔒 | [Go](../problems/squirrel-simulation) | Medium | +| 574 | [Winning Candidate](https://leetcode.com/problems/winning-candidate "当选者") 🔒 | [MySQL](../problems/winning-candidate) | Medium | +| 575 | [Distribute Candies](https://leetcode.com/problems/distribute-candies "分糖果") | [Go](../problems/distribute-candies) | Easy | +| 576 | [Out of Boundary Paths](https://leetcode.com/problems/out-of-boundary-paths "出界的路径数") | [Go](../problems/out-of-boundary-paths) | Medium | +| 577 | [Employee Bonus](https://leetcode.com/problems/employee-bonus "员工奖金") 🔒 | [MySQL](../problems/employee-bonus) | Easy | +| 578 | [Get Highest Answer Rate Question](https://leetcode.com/problems/get-highest-answer-rate-question "查询回答率最高的问题") 🔒 | [MySQL](../problems/get-highest-answer-rate-question) | Medium | +| 579 | [Find Cumulative Salary of an Employee](https://leetcode.com/problems/find-cumulative-salary-of-an-employee "查询员工的累计薪水") 🔒 | [MySQL](../problems/find-cumulative-salary-of-an-employee) | Hard | +| 580 | [Count Student Number in Departments](https://leetcode.com/problems/count-student-number-in-departments "统计各专业学生人数") 🔒 | [MySQL](../problems/count-student-number-in-departments) | Medium | +| 581 | [Shortest Unsorted Continuous Subarray](https://leetcode.com/problems/shortest-unsorted-continuous-subarray "最短无序连续子数组") | [Go](../problems/shortest-unsorted-continuous-subarray) | Easy | +| 582 | [Kill Process](https://leetcode.com/problems/kill-process "杀死进程") 🔒 | [Go](../problems/kill-process) | Medium | +| 583 | [Delete Operation for Two Strings](https://leetcode.com/problems/delete-operation-for-two-strings "两个字符串的删除操作") | [Go](../problems/delete-operation-for-two-strings) | Medium | +| 584 | [Find Customer Referee](https://leetcode.com/problems/find-customer-referee "寻找用户推荐人") 🔒 | [MySQL](../problems/find-customer-referee) | Easy | +| 585 | [Investments in 2016](https://leetcode.com/problems/investments-in-2016 "2016年的投资") 🔒 | [MySQL](../problems/investments-in-2016) | Medium | +| 586 | [Customer Placing the Largest Number of Orders](https://leetcode.com/problems/customer-placing-the-largest-number-of-orders "订单最多的客户") 🔒 | [MySQL](../problems/customer-placing-the-largest-number-of-orders) | Easy | +| 587 | [Erect the Fence](https://leetcode.com/problems/erect-the-fence "安装栅栏") | [Go](../problems/erect-the-fence) | Hard | +| 588 | [Design In-Memory File System](https://leetcode.com/problems/design-in-memory-file-system "设计内存文件系统") 🔒 | [Go](../problems/design-in-memory-file-system) | Hard | +| 589 | [N-ary Tree Preorder Traversal](https://leetcode.com/problems/n-ary-tree-preorder-traversal "N叉树的前序遍历") | [Go](../problems/n-ary-tree-preorder-traversal) | Easy | +| 590 | [N-ary Tree Postorder Traversal](https://leetcode.com/problems/n-ary-tree-postorder-traversal "N叉树的后序遍历") | [Go](../problems/n-ary-tree-postorder-traversal) | Easy | +| 591 | [Tag Validator](https://leetcode.com/problems/tag-validator "标签验证器") | [Go](../problems/tag-validator) | Hard | +| 592 | [Fraction Addition and Subtraction](https://leetcode.com/problems/fraction-addition-and-subtraction "分数加减运算") | [Go](../problems/fraction-addition-and-subtraction) | Medium | +| 593 | [Valid Square](https://leetcode.com/problems/valid-square "有效的正方形") | [Go](../problems/valid-square) | Medium | +| 594 | [Longest Harmonious Subsequence](https://leetcode.com/problems/longest-harmonious-subsequence "最长和谐子序列") | [Go](../problems/longest-harmonious-subsequence) | Easy | +| 595 | [Big Countries](https://leetcode.com/problems/big-countries "大的国家") | [MySQL](../problems/big-countries) | Easy | +| 596 | [Classes More Than 5 Students](https://leetcode.com/problems/classes-more-than-5-students "超过5名学生的课") | [MySQL](../problems/classes-more-than-5-students) | Easy | +| 597 | [Friend Requests I: Overall Acceptance Rate](https://leetcode.com/problems/friend-requests-i-overall-acceptance-rate "好友申请 I :总体通过率") 🔒 | [MySQL](../problems/friend-requests-i-overall-acceptance-rate) | Easy | +| 598 | [Range Addition II](https://leetcode.com/problems/range-addition-ii "范围求和 II") | [Go](../problems/range-addition-ii) | Easy | +| 599 | [Minimum Index Sum of Two Lists](https://leetcode.com/problems/minimum-index-sum-of-two-lists "两个列表的最小索引总和") | [Go](../problems/minimum-index-sum-of-two-lists) | Easy | +| 600 | [Non-negative Integers without Consecutive Ones](https://leetcode.com/problems/non-negative-integers-without-consecutive-ones "不含连续1的非负整数") | [Go](../problems/non-negative-integers-without-consecutive-ones) | Hard | diff --git a/readme/601-900.md b/readme/601-900.md index acfd38646..a80a422d9 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -62,303 +62,303 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | -| 601 | [Human Traffic of Stadium](https://leetcode.com/problems/human-traffic-of-stadium "体育馆的人流量") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/human-traffic-of-stadium) | Hard | -| 602 | [Friend Requests II: Who Has the Most Friends](https://leetcode.com/problems/friend-requests-ii-who-has-the-most-friends "好友申请 II :谁有最多的好友") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/friend-requests-ii-who-has-the-most-friends) | Medium | -| 603 | [Consecutive Available Seats](https://leetcode.com/problems/consecutive-available-seats "连续空余座位") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/consecutive-available-seats) | Easy | -| 604 | [Design Compressed String Iterator](https://leetcode.com/problems/design-compressed-string-iterator "迭代压缩字符串") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-compressed-string-iterator) | Easy | -| 605 | [Can Place Flowers](https://leetcode.com/problems/can-place-flowers "种花问题") | [Go](https://github.com/openset/leetcode/tree/master/problems/can-place-flowers) | Easy | -| 606 | [Construct String from Binary Tree](https://leetcode.com/problems/construct-string-from-binary-tree "根据二叉树创建字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/construct-string-from-binary-tree) | Easy | -| 607 | [Sales Person](https://leetcode.com/problems/sales-person "销售员") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/sales-person) | Easy | -| 608 | [Tree Node](https://leetcode.com/problems/tree-node "树节点") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/tree-node) | Medium | -| 609 | [Find Duplicate File in System](https://leetcode.com/problems/find-duplicate-file-in-system "在系统中查找重复文件") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-duplicate-file-in-system) | Medium | -| 610 | [Triangle Judgement](https://leetcode.com/problems/triangle-judgement "判断三角形") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/triangle-judgement) | Easy | -| 611 | [Valid Triangle Number](https://leetcode.com/problems/valid-triangle-number "有效三角形的个数") | [Go](https://github.com/openset/leetcode/tree/master/problems/valid-triangle-number) | Medium | -| 612 | [Shortest Distance in a Plane](https://leetcode.com/problems/shortest-distance-in-a-plane "平面上的最近距离") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-in-a-plane) | Medium | -| 613 | [Shortest Distance in a Line](https://leetcode.com/problems/shortest-distance-in-a-line "直线上的最近距离") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-in-a-line) | Easy | -| 614 | [Second Degree Follower](https://leetcode.com/problems/second-degree-follower "二级关注者") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/second-degree-follower) | Medium | -| 615 | [Average Salary: Departments VS Company](https://leetcode.com/problems/average-salary-departments-vs-company "平均工资:部门与公司比较") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/average-salary-departments-vs-company) | Hard | -| 616 | [Add Bold Tag in String](https://leetcode.com/problems/add-bold-tag-in-string "给字符串添加加粗标签") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/add-bold-tag-in-string) | Medium | -| 617 | [Merge Two Binary Trees](https://leetcode.com/problems/merge-two-binary-trees "合并二叉树") | [Go](https://github.com/openset/leetcode/tree/master/problems/merge-two-binary-trees) | Easy | -| 618 | [Students Report By Geography](https://leetcode.com/problems/students-report-by-geography "学生地理信息报告") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/students-report-by-geography) | Hard | -| 619 | [Biggest Single Number](https://leetcode.com/problems/biggest-single-number "只出现一次的最大数字") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/biggest-single-number) | Easy | -| 620 | [Not Boring Movies](https://leetcode.com/problems/not-boring-movies "有趣的电影") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/not-boring-movies) | Easy | -| 621 | [Task Scheduler](https://leetcode.com/problems/task-scheduler "任务调度器") | [Go](https://github.com/openset/leetcode/tree/master/problems/task-scheduler) | Medium | -| 622 | [Design Circular Queue](https://leetcode.com/problems/design-circular-queue "设计循环队列") | [Go](https://github.com/openset/leetcode/tree/master/problems/design-circular-queue) | Medium | -| 623 | [Add One Row to Tree](https://leetcode.com/problems/add-one-row-to-tree "在二叉树中增加一行") | [Go](https://github.com/openset/leetcode/tree/master/problems/add-one-row-to-tree) | Medium | -| 624 | [Maximum Distance in Arrays](https://leetcode.com/problems/maximum-distance-in-arrays "数组列表中的最大距离") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-distance-in-arrays) | Easy | -| 625 | [Minimum Factorization](https://leetcode.com/problems/minimum-factorization "最小因式分解") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-factorization) | Medium | -| 626 | [Exchange Seats](https://leetcode.com/problems/exchange-seats "换座位") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/exchange-seats) | Medium | -| 627 | [Swap Salary](https://leetcode.com/problems/swap-salary "交换工资") | [MySQL](https://github.com/openset/leetcode/tree/master/problems/swap-salary) | Easy | -| 628 | [Maximum Product of Three Numbers](https://leetcode.com/problems/maximum-product-of-three-numbers "三个数的最大乘积") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-product-of-three-numbers) | Easy | -| 629 | [K Inverse Pairs Array](https://leetcode.com/problems/k-inverse-pairs-array "K个逆序对数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/k-inverse-pairs-array) | Hard | -| 630 | [Course Schedule III](https://leetcode.com/problems/course-schedule-iii "课程表 III") | [Go](https://github.com/openset/leetcode/tree/master/problems/course-schedule-iii) | Hard | -| 631 | [Design Excel Sum Formula](https://leetcode.com/problems/design-excel-sum-formula "设计 Excel 求和公式") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-excel-sum-formula) | Hard | -| 632 | [Smallest Range Covering Elements from K Lists](https://leetcode.com/problems/smallest-range-covering-elements-from-k-lists "最小区间") | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-range-covering-elements-from-k-lists) | Hard | -| 633 | [Sum of Square Numbers](https://leetcode.com/problems/sum-of-square-numbers "平方数之和") | [Go](https://github.com/openset/leetcode/tree/master/problems/sum-of-square-numbers) | Easy | -| 634 | [Find the Derangement of An Array](https://leetcode.com/problems/find-the-derangement-of-an-array "寻找数组的错位排列") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/find-the-derangement-of-an-array) | Medium | -| 635 | [Design Log Storage System](https://leetcode.com/problems/design-log-storage-system "设计日志存储系统") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-log-storage-system) | Medium | -| 636 | [Exclusive Time of Functions](https://leetcode.com/problems/exclusive-time-of-functions "函数的独占时间") | [Go](https://github.com/openset/leetcode/tree/master/problems/exclusive-time-of-functions) | Medium | -| 637 | [Average of Levels in Binary Tree](https://leetcode.com/problems/average-of-levels-in-binary-tree "二叉树的层平均值") | [Go](https://github.com/openset/leetcode/tree/master/problems/average-of-levels-in-binary-tree) | Easy | -| 638 | [Shopping Offers](https://leetcode.com/problems/shopping-offers "大礼包") | [Go](https://github.com/openset/leetcode/tree/master/problems/shopping-offers) | Medium | -| 639 | [Decode Ways II](https://leetcode.com/problems/decode-ways-ii "解码方法 2") | [Go](https://github.com/openset/leetcode/tree/master/problems/decode-ways-ii) | Hard | -| 640 | [Solve the Equation](https://leetcode.com/problems/solve-the-equation "求解方程") | [Go](https://github.com/openset/leetcode/tree/master/problems/solve-the-equation) | Medium | -| 641 | [Design Circular Deque](https://leetcode.com/problems/design-circular-deque "设计循环双端队列") | [Go](https://github.com/openset/leetcode/tree/master/problems/design-circular-deque) | Medium | -| 642 | [Design Search Autocomplete System](https://leetcode.com/problems/design-search-autocomplete-system "设计搜索自动补全系统") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-search-autocomplete-system) | Hard | -| 643 | [Maximum Average Subarray I](https://leetcode.com/problems/maximum-average-subarray-i "子数组最大平均数 I") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-average-subarray-i) | Easy | -| 644 | [Maximum Average Subarray II](https://leetcode.com/problems/maximum-average-subarray-ii "最大平均子段和 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-average-subarray-ii) | Hard | -| 645 | [Set Mismatch](https://leetcode.com/problems/set-mismatch "错误的集合") | [Go](https://github.com/openset/leetcode/tree/master/problems/set-mismatch) | Easy | -| 646 | [Maximum Length of Pair Chain](https://leetcode.com/problems/maximum-length-of-pair-chain "最长数对链") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-pair-chain) | Medium | -| 647 | [Palindromic Substrings](https://leetcode.com/problems/palindromic-substrings "回文子串") | [Go](https://github.com/openset/leetcode/tree/master/problems/palindromic-substrings) | Medium | -| 648 | [Replace Words](https://leetcode.com/problems/replace-words "单词替换") | [Go](https://github.com/openset/leetcode/tree/master/problems/replace-words) | Medium | -| 649 | [Dota2 Senate](https://leetcode.com/problems/dota2-senate "Dota2 参议院") | [Go](https://github.com/openset/leetcode/tree/master/problems/dota2-senate) | Medium | -| 650 | [2 Keys Keyboard](https://leetcode.com/problems/2-keys-keyboard "只有两个键的键盘") | [Go](https://github.com/openset/leetcode/tree/master/problems/2-keys-keyboard) | Medium | -| 651 | [4 Keys Keyboard](https://leetcode.com/problems/4-keys-keyboard "4键键盘") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/4-keys-keyboard) | Medium | -| 652 | [Find Duplicate Subtrees](https://leetcode.com/problems/find-duplicate-subtrees "寻找重复的子树") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-duplicate-subtrees) | Medium | -| 653 | [Two Sum IV - Input is a BST](https://leetcode.com/problems/two-sum-iv-input-is-a-bst "两数之和 IV - 输入 BST") | [Go](https://github.com/openset/leetcode/tree/master/problems/two-sum-iv-input-is-a-bst) | Easy | -| 654 | [Maximum Binary Tree](https://leetcode.com/problems/maximum-binary-tree "最大二叉树") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-binary-tree) | Medium | -| 655 | [Print Binary Tree](https://leetcode.com/problems/print-binary-tree "输出二叉树") | [Go](https://github.com/openset/leetcode/tree/master/problems/print-binary-tree) | Medium | -| 656 | [Coin Path](https://leetcode.com/problems/coin-path "金币路径") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/coin-path) | Hard | -| 657 | [Robot Return to Origin](https://leetcode.com/problems/robot-return-to-origin "机器人能否返回原点") | [Go](https://github.com/openset/leetcode/tree/master/problems/robot-return-to-origin) | Easy | -| 658 | [Find K Closest Elements](https://leetcode.com/problems/find-k-closest-elements "找到 K 个最接近的元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-k-closest-elements) | Medium | -| 659 | [Split Array into Consecutive Subsequences](https://leetcode.com/problems/split-array-into-consecutive-subsequences "分割数组为连续子序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/split-array-into-consecutive-subsequences) | Medium | -| 660 | [Remove 9](https://leetcode.com/problems/remove-9 "移除 9") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-9) | Hard | -| 661 | [Image Smoother](https://leetcode.com/problems/image-smoother "图片平滑器") | [Go](https://github.com/openset/leetcode/tree/master/problems/image-smoother) | Easy | -| 662 | [Maximum Width of Binary Tree](https://leetcode.com/problems/maximum-width-of-binary-tree "二叉树最大宽度") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-width-of-binary-tree) | Medium | -| 663 | [Equal Tree Partition](https://leetcode.com/problems/equal-tree-partition "均匀树划分") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/equal-tree-partition) | Medium | -| 664 | [Strange Printer](https://leetcode.com/problems/strange-printer "奇怪的打印机") | [Go](https://github.com/openset/leetcode/tree/master/problems/strange-printer) | Hard | -| 665 | [Non-decreasing Array](https://leetcode.com/problems/non-decreasing-array "非递减数列") | [Go](https://github.com/openset/leetcode/tree/master/problems/non-decreasing-array) | Easy | -| 666 | [Path Sum IV](https://leetcode.com/problems/path-sum-iv "路径和 IV") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/path-sum-iv) | Medium | -| 667 | [Beautiful Arrangement II](https://leetcode.com/problems/beautiful-arrangement-ii "优美的排列 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/beautiful-arrangement-ii) | Medium | -| 668 | [Kth Smallest Number in Multiplication Table](https://leetcode.com/problems/kth-smallest-number-in-multiplication-table "乘法表中第k小的数") | [Go](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-number-in-multiplication-table) | Hard | -| 669 | [Trim a Binary Search Tree](https://leetcode.com/problems/trim-a-binary-search-tree "修剪二叉搜索树") | [Go](https://github.com/openset/leetcode/tree/master/problems/trim-a-binary-search-tree) | Easy | -| 670 | [Maximum Swap](https://leetcode.com/problems/maximum-swap "最大交换") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-swap) | Medium | -| 671 | [Second Minimum Node In a Binary Tree](https://leetcode.com/problems/second-minimum-node-in-a-binary-tree "二叉树中第二小的节点") | [Go](https://github.com/openset/leetcode/tree/master/problems/second-minimum-node-in-a-binary-tree) | Easy | -| 672 | [Bulb Switcher II](https://leetcode.com/problems/bulb-switcher-ii "灯泡开关 Ⅱ") | [Go](https://github.com/openset/leetcode/tree/master/problems/bulb-switcher-ii) | Medium | -| 673 | [Number of Longest Increasing Subsequence](https://leetcode.com/problems/number-of-longest-increasing-subsequence "最长递增子序列的个数") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-longest-increasing-subsequence) | Medium | -| 674 | [Longest Continuous Increasing Subsequence](https://leetcode.com/problems/longest-continuous-increasing-subsequence "最长连续递增序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-continuous-increasing-subsequence) | Easy | -| 675 | [Cut Off Trees for Golf Event](https://leetcode.com/problems/cut-off-trees-for-golf-event "为高尔夫比赛砍树") | [Go](https://github.com/openset/leetcode/tree/master/problems/cut-off-trees-for-golf-event) | Hard | -| 676 | [Implement Magic Dictionary](https://leetcode.com/problems/implement-magic-dictionary "实现一个魔法字典") | [Go](https://github.com/openset/leetcode/tree/master/problems/implement-magic-dictionary) | Medium | -| 677 | [Map Sum Pairs](https://leetcode.com/problems/map-sum-pairs "键值映射") | [Go](https://github.com/openset/leetcode/tree/master/problems/map-sum-pairs) | Medium | -| 678 | [Valid Parenthesis String](https://leetcode.com/problems/valid-parenthesis-string "有效的括号字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/valid-parenthesis-string) | Medium | -| 679 | [24 Game](https://leetcode.com/problems/24-game "24 点游戏") | [Go](https://github.com/openset/leetcode/tree/master/problems/24-game) | Hard | -| 680 | [Valid Palindrome II](https://leetcode.com/problems/valid-palindrome-ii "验证回文字符串 Ⅱ") | [Go](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome-ii) | Easy | -| 681 | [Next Closest Time](https://leetcode.com/problems/next-closest-time "最近时刻") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/next-closest-time) | Medium | -| 682 | [Baseball Game](https://leetcode.com/problems/baseball-game "棒球比赛") | [Go](https://github.com/openset/leetcode/tree/master/problems/baseball-game) | Easy | -| 683 | [K Empty Slots](https://leetcode.com/problems/k-empty-slots "K 个空花盆") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/k-empty-slots) | Hard | -| 684 | [Redundant Connection](https://leetcode.com/problems/redundant-connection "冗余连接") | [Go](https://github.com/openset/leetcode/tree/master/problems/redundant-connection) | Medium | -| 685 | [Redundant Connection II](https://leetcode.com/problems/redundant-connection-ii "冗余连接 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/redundant-connection-ii) | Hard | -| 686 | [Repeated String Match](https://leetcode.com/problems/repeated-string-match "重复叠加字符串匹配") | [Go](https://github.com/openset/leetcode/tree/master/problems/repeated-string-match) | Easy | -| 687 | [Longest Univalue Path](https://leetcode.com/problems/longest-univalue-path "最长同值路径") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-univalue-path) | Easy | -| 688 | [Knight Probability in Chessboard](https://leetcode.com/problems/knight-probability-in-chessboard "“马”在棋盘上的概率") | [Go](https://github.com/openset/leetcode/tree/master/problems/knight-probability-in-chessboard) | Medium | -| 689 | [Maximum Sum of 3 Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays "三个无重叠子数组的最大和") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-sum-of-3-non-overlapping-subarrays) | Hard | -| 690 | [Employee Importance](https://leetcode.com/problems/employee-importance "员工的重要性") | [Go](https://github.com/openset/leetcode/tree/master/problems/employee-importance) | Easy | -| 691 | [Stickers to Spell Word](https://leetcode.com/problems/stickers-to-spell-word "贴纸拼词") | [Go](https://github.com/openset/leetcode/tree/master/problems/stickers-to-spell-word) | Hard | -| 692 | [Top K Frequent Words](https://leetcode.com/problems/top-k-frequent-words "前K个高频单词") | [Go](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-words) | Medium | -| 693 | [Binary Number with Alternating Bits](https://leetcode.com/problems/binary-number-with-alternating-bits "交替位二进制数") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-number-with-alternating-bits) | Easy | -| 694 | [Number of Distinct Islands](https://leetcode.com/problems/number-of-distinct-islands "不同岛屿的数量") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-distinct-islands) | Medium | -| 695 | [Max Area of Island](https://leetcode.com/problems/max-area-of-island "岛屿的最大面积") | [Go](https://github.com/openset/leetcode/tree/master/problems/max-area-of-island) | Medium | -| 696 | [Count Binary Substrings](https://leetcode.com/problems/count-binary-substrings "计数二进制子串") | [Go](https://github.com/openset/leetcode/tree/master/problems/count-binary-substrings) | Easy | -| 697 | [Degree of an Array](https://leetcode.com/problems/degree-of-an-array "数组的度") | [Go](https://github.com/openset/leetcode/tree/master/problems/degree-of-an-array) | Easy | -| 698 | [Partition to K Equal Sum Subsets](https://leetcode.com/problems/partition-to-k-equal-sum-subsets "划分为k个相等的子集") | [Go](https://github.com/openset/leetcode/tree/master/problems/partition-to-k-equal-sum-subsets) | Medium | -| 699 | [Falling Squares](https://leetcode.com/problems/falling-squares "掉落的方块") | [Go](https://github.com/openset/leetcode/tree/master/problems/falling-squares) | Hard | -| 700 | [Search in a Binary Search Tree](https://leetcode.com/problems/search-in-a-binary-search-tree "二叉搜索树中的搜索") | [Go](https://github.com/openset/leetcode/tree/master/problems/search-in-a-binary-search-tree) | Easy | -| 701 | [Insert into a Binary Search Tree](https://leetcode.com/problems/insert-into-a-binary-search-tree "二叉搜索树中的插入操作") | [Go](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-binary-search-tree) | Medium | -| 702 | [Search in a Sorted Array of Unknown Size](https://leetcode.com/problems/search-in-a-sorted-array-of-unknown-size "搜索长度未知的有序数组") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/search-in-a-sorted-array-of-unknown-size) | Medium | -| 703 | [Kth Largest Element in a Stream](https://leetcode.com/problems/kth-largest-element-in-a-stream "数据流中的第K大元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/kth-largest-element-in-a-stream) | Easy | -| 704 | [Binary Search](https://leetcode.com/problems/binary-search "二分查找") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-search) | Easy | -| 705 | [Design HashSet](https://leetcode.com/problems/design-hashset "设计哈希集合") | [Go](https://github.com/openset/leetcode/tree/master/problems/design-hashset) | Easy | -| 706 | [Design HashMap](https://leetcode.com/problems/design-hashmap "设计哈希映射") | [Go](https://github.com/openset/leetcode/tree/master/problems/design-hashmap) | Easy | -| 707 | [Design Linked List](https://leetcode.com/problems/design-linked-list "设计链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/design-linked-list) | Medium | -| 708 | [Insert into a Sorted Circular Linked List](https://leetcode.com/problems/insert-into-a-sorted-circular-linked-list "循环有序列表的插入") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-sorted-circular-linked-list) | Medium | -| 709 | [To Lower Case](https://leetcode.com/problems/to-lower-case "转换成小写字母") | [Go](https://github.com/openset/leetcode/tree/master/problems/to-lower-case) | Easy | -| 710 | [Random Pick with Blacklist](https://leetcode.com/problems/random-pick-with-blacklist "黑名单中的随机数") | [Go](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-blacklist) | Hard | -| 711 | [Number of Distinct Islands II](https://leetcode.com/problems/number-of-distinct-islands-ii "不同岛屿的数量 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-distinct-islands-ii) | Hard | -| 712 | [Minimum ASCII Delete Sum for Two Strings](https://leetcode.com/problems/minimum-ascii-delete-sum-for-two-strings "两个字符串的最小ASCII删除和") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-ascii-delete-sum-for-two-strings) | Medium | -| 713 | [Subarray Product Less Than K](https://leetcode.com/problems/subarray-product-less-than-k "乘积小于K的子数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/subarray-product-less-than-k) | Medium | -| 714 | [Best Time to Buy and Sell Stock with Transaction Fee](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee "买卖股票的最佳时机含手续费") | [Go](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | Medium | -| 715 | [Range Module](https://leetcode.com/problems/range-module "Range 模块") | [Go](https://github.com/openset/leetcode/tree/master/problems/range-module) | Hard | -| 716 | [Max Stack](https://leetcode.com/problems/max-stack "最大栈") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/max-stack) | Easy | -| 717 | [1-bit and 2-bit Characters](https://leetcode.com/problems/1-bit-and-2-bit-characters "1比特与2比特字符") | [Go](https://github.com/openset/leetcode/tree/master/problems/1-bit-and-2-bit-characters) | Easy | -| 718 | [Maximum Length of Repeated Subarray](https://leetcode.com/problems/maximum-length-of-repeated-subarray "最长重复子数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-repeated-subarray) | Medium | -| 719 | [Find K-th Smallest Pair Distance](https://leetcode.com/problems/find-k-th-smallest-pair-distance "找出第 k 小的距离对") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-k-th-smallest-pair-distance) | Hard | -| 720 | [Longest Word in Dictionary](https://leetcode.com/problems/longest-word-in-dictionary "词典中最长的单词") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-word-in-dictionary) | Easy | -| 721 | [Accounts Merge](https://leetcode.com/problems/accounts-merge "账户合并") | [Go](https://github.com/openset/leetcode/tree/master/problems/accounts-merge) | Medium | -| 722 | [Remove Comments](https://leetcode.com/problems/remove-comments "删除注释") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-comments) | Medium | -| 723 | [Candy Crush](https://leetcode.com/problems/candy-crush "粉碎糖果") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/candy-crush) | Medium | -| 724 | [Find Pivot Index](https://leetcode.com/problems/find-pivot-index "寻找数组的中心索引") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-pivot-index) | Easy | -| 725 | [Split Linked List in Parts](https://leetcode.com/problems/split-linked-list-in-parts "分隔链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/split-linked-list-in-parts) | Medium | -| 726 | [Number of Atoms](https://leetcode.com/problems/number-of-atoms "原子的数量") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-atoms) | Hard | -| 727 | [Minimum Window Subsequence](https://leetcode.com/problems/minimum-window-subsequence "最小窗口子序列") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-window-subsequence) | Hard | -| 728 | [Self Dividing Numbers](https://leetcode.com/problems/self-dividing-numbers "自除数") | [Go](https://github.com/openset/leetcode/tree/master/problems/self-dividing-numbers) | Easy | -| 729 | [My Calendar I](https://leetcode.com/problems/my-calendar-i "我的日程安排表 I") | [Go](https://github.com/openset/leetcode/tree/master/problems/my-calendar-i) | Medium | -| 730 | [Count Different Palindromic Subsequences](https://leetcode.com/problems/count-different-palindromic-subsequences "统计不同回文子字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/count-different-palindromic-subsequences) | Hard | -| 731 | [My Calendar II](https://leetcode.com/problems/my-calendar-ii "我的日程安排表 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/my-calendar-ii) | Medium | -| 732 | [My Calendar III](https://leetcode.com/problems/my-calendar-iii "我的日程安排表 III") | [Go](https://github.com/openset/leetcode/tree/master/problems/my-calendar-iii) | Hard | -| 733 | [Flood Fill](https://leetcode.com/problems/flood-fill "图像渲染") | [Go](https://github.com/openset/leetcode/tree/master/problems/flood-fill) | Easy | -| 734 | [Sentence Similarity](https://leetcode.com/problems/sentence-similarity "句子相似性") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/sentence-similarity) | Easy | -| 735 | [Asteroid Collision](https://leetcode.com/problems/asteroid-collision "行星碰撞") | [Go](https://github.com/openset/leetcode/tree/master/problems/asteroid-collision) | Medium | -| 736 | [Parse Lisp Expression](https://leetcode.com/problems/parse-lisp-expression "Lisp 语法解析") | [Go](https://github.com/openset/leetcode/tree/master/problems/parse-lisp-expression) | Hard | -| 737 | [Sentence Similarity II](https://leetcode.com/problems/sentence-similarity-ii "句子相似性 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/sentence-similarity-ii) | Medium | -| 738 | [Monotone Increasing Digits](https://leetcode.com/problems/monotone-increasing-digits "单调递增的数字") | [Go](https://github.com/openset/leetcode/tree/master/problems/monotone-increasing-digits) | Medium | -| 739 | [Daily Temperatures](https://leetcode.com/problems/daily-temperatures "每日温度") | [Go](https://github.com/openset/leetcode/tree/master/problems/daily-temperatures) | Medium | -| 740 | [Delete and Earn](https://leetcode.com/problems/delete-and-earn "删除与获得点数") | [Go](https://github.com/openset/leetcode/tree/master/problems/delete-and-earn) | Medium | -| 741 | [Cherry Pickup](https://leetcode.com/problems/cherry-pickup "摘樱桃") | [Go](https://github.com/openset/leetcode/tree/master/problems/cherry-pickup) | Hard | -| 742 | [Closest Leaf in a Binary Tree](https://leetcode.com/problems/closest-leaf-in-a-binary-tree "二叉树最近的叶节点") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/closest-leaf-in-a-binary-tree) | Medium | -| 743 | [Network Delay Time](https://leetcode.com/problems/network-delay-time "网络延迟时间") | [Go](https://github.com/openset/leetcode/tree/master/problems/network-delay-time) | Medium | -| 744 | [Find Smallest Letter Greater Than Target](https://leetcode.com/problems/find-smallest-letter-greater-than-target "寻找比目标字母大的最小字母") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-smallest-letter-greater-than-target) | Easy | -| 745 | [Prefix and Suffix Search](https://leetcode.com/problems/prefix-and-suffix-search "前缀和后缀搜索") | [Go](https://github.com/openset/leetcode/tree/master/problems/prefix-and-suffix-search) | Hard | -| 746 | [Min Cost Climbing Stairs](https://leetcode.com/problems/min-cost-climbing-stairs "使用最小花费爬楼梯") | [Go](https://github.com/openset/leetcode/tree/master/problems/min-cost-climbing-stairs) | Easy | -| 747 | [Largest Number At Least Twice of Others](https://leetcode.com/problems/largest-number-at-least-twice-of-others "至少是其他数字两倍的最大数") | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-number-at-least-twice-of-others) | Easy | -| 748 | [Shortest Completing Word](https://leetcode.com/problems/shortest-completing-word "最短完整词") | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-completing-word) | Easy | -| 749 | [Contain Virus](https://leetcode.com/problems/contain-virus "隔离病毒") | [Go](https://github.com/openset/leetcode/tree/master/problems/contain-virus) | Hard | -| 750 | [Number Of Corner Rectangles](https://leetcode.com/problems/number-of-corner-rectangles "角矩形的数量") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-corner-rectangles) | Medium | -| 751 | [IP to CIDR](https://leetcode.com/problems/ip-to-cidr "IP 到 CIDR") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/ip-to-cidr) | Easy | -| 752 | [Open the Lock](https://leetcode.com/problems/open-the-lock "打开转盘锁") | [Go](https://github.com/openset/leetcode/tree/master/problems/open-the-lock) | Medium | -| 753 | [Cracking the Safe](https://leetcode.com/problems/cracking-the-safe "破解保险箱") | [Go](https://github.com/openset/leetcode/tree/master/problems/cracking-the-safe) | Hard | -| 754 | [Reach a Number](https://leetcode.com/problems/reach-a-number "到达终点数字") | [Go](https://github.com/openset/leetcode/tree/master/problems/reach-a-number) | Medium | -| 755 | [Pour Water](https://leetcode.com/problems/pour-water "倒水") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/pour-water) | Medium | -| 756 | [Pyramid Transition Matrix](https://leetcode.com/problems/pyramid-transition-matrix "金字塔转换矩阵") | [Go](https://github.com/openset/leetcode/tree/master/problems/pyramid-transition-matrix) | Medium | -| 757 | [Set Intersection Size At Least Two](https://leetcode.com/problems/set-intersection-size-at-least-two " 设置交集大小至少为2") | [Go](https://github.com/openset/leetcode/tree/master/problems/set-intersection-size-at-least-two) | Hard | -| 758 | [Bold Words in String](https://leetcode.com/problems/bold-words-in-string "字符串中的加粗单词") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/bold-words-in-string) | Easy | -| 759 | [Employee Free Time](https://leetcode.com/problems/employee-free-time "员工空闲时间") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/employee-free-time) | Hard | -| 760 | [Find Anagram Mappings](https://leetcode.com/problems/find-anagram-mappings "找出变位映射") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/find-anagram-mappings) | Easy | -| 761 | [Special Binary String](https://leetcode.com/problems/special-binary-string "特殊的二进制序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/special-binary-string) | Hard | -| 762 | [Prime Number of Set Bits in Binary Representation](https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation "二进制表示中质数个计算置位") | [Go](https://github.com/openset/leetcode/tree/master/problems/prime-number-of-set-bits-in-binary-representation) | Easy | -| 763 | [Partition Labels](https://leetcode.com/problems/partition-labels "划分字母区间") | [Go](https://github.com/openset/leetcode/tree/master/problems/partition-labels) | Medium | -| 764 | [Largest Plus Sign](https://leetcode.com/problems/largest-plus-sign "最大加号标志") | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-plus-sign) | Medium | -| 765 | [Couples Holding Hands](https://leetcode.com/problems/couples-holding-hands "情侣牵手") | [Go](https://github.com/openset/leetcode/tree/master/problems/couples-holding-hands) | Hard | -| 766 | [Toeplitz Matrix](https://leetcode.com/problems/toeplitz-matrix "托普利茨矩阵") | [Go](https://github.com/openset/leetcode/tree/master/problems/toeplitz-matrix) | Easy | -| 767 | [Reorganize String](https://leetcode.com/problems/reorganize-string "重构字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/reorganize-string) | Medium | -| 768 | [Max Chunks To Make Sorted II](https://leetcode.com/problems/max-chunks-to-make-sorted-ii "最多能完成排序的块 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/max-chunks-to-make-sorted-ii) | Hard | -| 769 | [Max Chunks To Make Sorted](https://leetcode.com/problems/max-chunks-to-make-sorted "最多能完成排序的块") | [Go](https://github.com/openset/leetcode/tree/master/problems/max-chunks-to-make-sorted) | Medium | -| 770 | [Basic Calculator IV](https://leetcode.com/problems/basic-calculator-iv "基本计算器 IV") | [Go](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iv) | Hard | -| 771 | [Jewels and Stones](https://leetcode.com/problems/jewels-and-stones "宝石与石头") | [Go](https://github.com/openset/leetcode/tree/master/problems/jewels-and-stones) | Easy | -| 772 | [Basic Calculator III](https://leetcode.com/problems/basic-calculator-iii "基本计算器 III") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iii) | Hard | -| 773 | [Sliding Puzzle](https://leetcode.com/problems/sliding-puzzle "滑动谜题") | [Go](https://github.com/openset/leetcode/tree/master/problems/sliding-puzzle) | Hard | -| 774 | [Minimize Max Distance to Gas Station](https://leetcode.com/problems/minimize-max-distance-to-gas-station "最小化去加油站的最大距离") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/minimize-max-distance-to-gas-station) | Hard | -| 775 | [Global and Local Inversions](https://leetcode.com/problems/global-and-local-inversions "全局倒置与局部倒置") | [Go](https://github.com/openset/leetcode/tree/master/problems/global-and-local-inversions) | Medium | -| 776 | [Split BST](https://leetcode.com/problems/split-bst "拆分二叉搜索树") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/split-bst) | Medium | -| 777 | [Swap Adjacent in LR String](https://leetcode.com/problems/swap-adjacent-in-lr-string "在LR字符串中交换相邻字符") | [Go](https://github.com/openset/leetcode/tree/master/problems/swap-adjacent-in-lr-string) | Medium | -| 778 | [Swim in Rising Water](https://leetcode.com/problems/swim-in-rising-water "水位上升的泳池中游泳") | [Go](https://github.com/openset/leetcode/tree/master/problems/swim-in-rising-water) | Hard | -| 779 | [K-th Symbol in Grammar](https://leetcode.com/problems/k-th-symbol-in-grammar "第K个语法符号") | [Go](https://github.com/openset/leetcode/tree/master/problems/k-th-symbol-in-grammar) | Medium | -| 780 | [Reaching Points](https://leetcode.com/problems/reaching-points "到达终点") | [Go](https://github.com/openset/leetcode/tree/master/problems/reaching-points) | Hard | -| 781 | [Rabbits in Forest](https://leetcode.com/problems/rabbits-in-forest "森林中的兔子") | [Go](https://github.com/openset/leetcode/tree/master/problems/rabbits-in-forest) | Medium | -| 782 | [Transform to Chessboard](https://leetcode.com/problems/transform-to-chessboard "变为棋盘") | [Go](https://github.com/openset/leetcode/tree/master/problems/transform-to-chessboard) | Hard | -| 783 | [Minimum Distance Between BST Nodes](https://leetcode.com/problems/minimum-distance-between-bst-nodes "二叉搜索树结点最小距离") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-distance-between-bst-nodes) | Easy | -| 784 | [Letter Case Permutation](https://leetcode.com/problems/letter-case-permutation "字母大小写全排列") | [Go](https://github.com/openset/leetcode/tree/master/problems/letter-case-permutation) | Easy | -| 785 | [Is Graph Bipartite?](https://leetcode.com/problems/is-graph-bipartite "判断二分图") | [Go](https://github.com/openset/leetcode/tree/master/problems/is-graph-bipartite) | Medium | -| 786 | [K-th Smallest Prime Fraction](https://leetcode.com/problems/k-th-smallest-prime-fraction "第 K 个最小的素数分数") | [Go](https://github.com/openset/leetcode/tree/master/problems/k-th-smallest-prime-fraction) | Hard | -| 787 | [Cheapest Flights Within K Stops](https://leetcode.com/problems/cheapest-flights-within-k-stops "K 站中转内最便宜的航班") | [Go](https://github.com/openset/leetcode/tree/master/problems/cheapest-flights-within-k-stops) | Medium | -| 788 | [Rotated Digits](https://leetcode.com/problems/rotated-digits "旋转数字") | [Go](https://github.com/openset/leetcode/tree/master/problems/rotated-digits) | Easy | -| 789 | [Escape The Ghosts](https://leetcode.com/problems/escape-the-ghosts "逃脱阻碍者") | [Go](https://github.com/openset/leetcode/tree/master/problems/escape-the-ghosts) | Medium | -| 790 | [Domino and Tromino Tiling](https://leetcode.com/problems/domino-and-tromino-tiling "多米诺和托米诺平铺") | [Go](https://github.com/openset/leetcode/tree/master/problems/domino-and-tromino-tiling) | Medium | -| 791 | [Custom Sort String](https://leetcode.com/problems/custom-sort-string "自定义字符串排序") | [Go](https://github.com/openset/leetcode/tree/master/problems/custom-sort-string) | Medium | -| 792 | [Number of Matching Subsequences](https://leetcode.com/problems/number-of-matching-subsequences "匹配子序列的单词数") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-matching-subsequences) | Medium | -| 793 | [Preimage Size of Factorial Zeroes Function](https://leetcode.com/problems/preimage-size-of-factorial-zeroes-function "阶乘函数后K个零") | [Go](https://github.com/openset/leetcode/tree/master/problems/preimage-size-of-factorial-zeroes-function) | Hard | -| 794 | [Valid Tic-Tac-Toe State](https://leetcode.com/problems/valid-tic-tac-toe-state "有效的井字游戏") | [Go](https://github.com/openset/leetcode/tree/master/problems/valid-tic-tac-toe-state) | Medium | -| 795 | [Number of Subarrays with Bounded Maximum](https://leetcode.com/problems/number-of-subarrays-with-bounded-maximum "区间子数组个数") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-subarrays-with-bounded-maximum) | Medium | -| 796 | [Rotate String](https://leetcode.com/problems/rotate-string "旋转字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/rotate-string) | Easy | -| 797 | [All Paths From Source to Target](https://leetcode.com/problems/all-paths-from-source-to-target "所有可能的路径") | [Go](https://github.com/openset/leetcode/tree/master/problems/all-paths-from-source-to-target) | Medium | -| 798 | [Smallest Rotation with Highest Score](https://leetcode.com/problems/smallest-rotation-with-highest-score "得分最高的最小轮调") | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-rotation-with-highest-score) | Hard | -| 799 | [Champagne Tower](https://leetcode.com/problems/champagne-tower "香槟塔") | [Go](https://github.com/openset/leetcode/tree/master/problems/champagne-tower) | Medium | -| 800 | [Similar RGB Color](https://leetcode.com/problems/similar-rgb-color "相似 RGB 颜色") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/similar-rgb-color) | Easy | -| 801 | [Minimum Swaps To Make Sequences Increasing](https://leetcode.com/problems/minimum-swaps-to-make-sequences-increasing "使序列递增的最小交换次数") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-swaps-to-make-sequences-increasing) | Medium | -| 802 | [Find Eventual Safe States](https://leetcode.com/problems/find-eventual-safe-states "找到最终的安全状态") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-eventual-safe-states) | Medium | -| 803 | [Bricks Falling When Hit](https://leetcode.com/problems/bricks-falling-when-hit "打砖块") | [Go](https://github.com/openset/leetcode/tree/master/problems/bricks-falling-when-hit) | Hard | -| 804 | [Unique Morse Code Words](https://leetcode.com/problems/unique-morse-code-words "唯一摩尔斯密码词") | [Go](https://github.com/openset/leetcode/tree/master/problems/unique-morse-code-words) | Easy | -| 805 | [Split Array With Same Average](https://leetcode.com/problems/split-array-with-same-average "数组的均值分割") | [Go](https://github.com/openset/leetcode/tree/master/problems/split-array-with-same-average) | Hard | -| 806 | [Number of Lines To Write String](https://leetcode.com/problems/number-of-lines-to-write-string "写字符串需要的行数") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-lines-to-write-string) | Easy | -| 807 | [Max Increase to Keep City Skyline](https://leetcode.com/problems/max-increase-to-keep-city-skyline "保持城市天际线") | [Go](https://github.com/openset/leetcode/tree/master/problems/max-increase-to-keep-city-skyline) | Medium | -| 808 | [Soup Servings](https://leetcode.com/problems/soup-servings "分汤") | [Go](https://github.com/openset/leetcode/tree/master/problems/soup-servings) | Medium | -| 809 | [Expressive Words](https://leetcode.com/problems/expressive-words "情感丰富的文字") | [Go](https://github.com/openset/leetcode/tree/master/problems/expressive-words) | Medium | -| 810 | [Chalkboard XOR Game](https://leetcode.com/problems/chalkboard-xor-game "黑板异或游戏") | [Go](https://github.com/openset/leetcode/tree/master/problems/chalkboard-xor-game) | Hard | -| 811 | [Subdomain Visit Count](https://leetcode.com/problems/subdomain-visit-count "子域名访问计数") | [Go](https://github.com/openset/leetcode/tree/master/problems/subdomain-visit-count) | Easy | -| 812 | [Largest Triangle Area](https://leetcode.com/problems/largest-triangle-area "最大三角形面积") | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-triangle-area) | Easy | -| 813 | [Largest Sum of Averages](https://leetcode.com/problems/largest-sum-of-averages "最大平均值和的分组") | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-sum-of-averages) | Medium | -| 814 | [Binary Tree Pruning](https://leetcode.com/problems/binary-tree-pruning "二叉树剪枝") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-pruning) | Medium | -| 815 | [Bus Routes](https://leetcode.com/problems/bus-routes "公交路线") | [Go](https://github.com/openset/leetcode/tree/master/problems/bus-routes) | Hard | -| 816 | [Ambiguous Coordinates](https://leetcode.com/problems/ambiguous-coordinates "模糊坐标") | [Go](https://github.com/openset/leetcode/tree/master/problems/ambiguous-coordinates) | Medium | -| 817 | [Linked List Components](https://leetcode.com/problems/linked-list-components "链表组件") | [Go](https://github.com/openset/leetcode/tree/master/problems/linked-list-components) | Medium | -| 818 | [Race Car](https://leetcode.com/problems/race-car "赛车") | [Go](https://github.com/openset/leetcode/tree/master/problems/race-car) | Hard | -| 819 | [Most Common Word](https://leetcode.com/problems/most-common-word "最常见的单词") | [Go](https://github.com/openset/leetcode/tree/master/problems/most-common-word) | Easy | -| 820 | [Short Encoding of Words](https://leetcode.com/problems/short-encoding-of-words "单词的压缩编码") | [Go](https://github.com/openset/leetcode/tree/master/problems/short-encoding-of-words) | Medium | -| 821 | [Shortest Distance to a Character](https://leetcode.com/problems/shortest-distance-to-a-character "字符的最短距离") | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-to-a-character) | Easy | -| 822 | [Card Flipping Game](https://leetcode.com/problems/card-flipping-game "翻转卡片游戏") | [Go](https://github.com/openset/leetcode/tree/master/problems/card-flipping-game) | Medium | -| 823 | [Binary Trees With Factors](https://leetcode.com/problems/binary-trees-with-factors "带因子的二叉树") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-trees-with-factors) | Medium | -| 824 | [Goat Latin](https://leetcode.com/problems/goat-latin "山羊拉丁文") | [Go](https://github.com/openset/leetcode/tree/master/problems/goat-latin) | Easy | -| 825 | [Friends Of Appropriate Ages](https://leetcode.com/problems/friends-of-appropriate-ages "适龄的朋友") | [Go](https://github.com/openset/leetcode/tree/master/problems/friends-of-appropriate-ages) | Medium | -| 826 | [Most Profit Assigning Work](https://leetcode.com/problems/most-profit-assigning-work "安排工作以达到最大收益") | [Go](https://github.com/openset/leetcode/tree/master/problems/most-profit-assigning-work) | Medium | -| 827 | [Making A Large Island](https://leetcode.com/problems/making-a-large-island "最大人工岛") | [Go](https://github.com/openset/leetcode/tree/master/problems/making-a-large-island) | Hard | -| 828 | [Unique Letter String](https://leetcode.com/problems/unique-letter-string "独特字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/unique-letter-string) | Hard | -| 829 | [Consecutive Numbers Sum](https://leetcode.com/problems/consecutive-numbers-sum "连续整数求和") | [Go](https://github.com/openset/leetcode/tree/master/problems/consecutive-numbers-sum) | Hard | -| 830 | [Positions of Large Groups](https://leetcode.com/problems/positions-of-large-groups "较大分组的位置") | [Go](https://github.com/openset/leetcode/tree/master/problems/positions-of-large-groups) | Easy | -| 831 | [Masking Personal Information](https://leetcode.com/problems/masking-personal-information "隐藏个人信息") | [Go](https://github.com/openset/leetcode/tree/master/problems/masking-personal-information) | Medium | -| 832 | [Flipping an Image](https://leetcode.com/problems/flipping-an-image "翻转图像") | [Go](https://github.com/openset/leetcode/tree/master/problems/flipping-an-image) | Easy | -| 833 | [Find And Replace in String](https://leetcode.com/problems/find-and-replace-in-string "字符串中的查找与替换") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-and-replace-in-string) | Medium | -| 834 | [Sum of Distances in Tree](https://leetcode.com/problems/sum-of-distances-in-tree "树中距离之和") | [Go](https://github.com/openset/leetcode/tree/master/problems/sum-of-distances-in-tree) | Hard | -| 835 | [Image Overlap](https://leetcode.com/problems/image-overlap "图像重叠") | [Go](https://github.com/openset/leetcode/tree/master/problems/image-overlap) | Medium | -| 836 | [Rectangle Overlap](https://leetcode.com/problems/rectangle-overlap "矩形重叠") | [Go](https://github.com/openset/leetcode/tree/master/problems/rectangle-overlap) | Easy | -| 837 | [New 21 Game](https://leetcode.com/problems/new-21-game "新21点") | [Go](https://github.com/openset/leetcode/tree/master/problems/new-21-game) | Medium | -| 838 | [Push Dominoes](https://leetcode.com/problems/push-dominoes "推多米诺") | [Go](https://github.com/openset/leetcode/tree/master/problems/push-dominoes) | Medium | -| 839 | [Similar String Groups](https://leetcode.com/problems/similar-string-groups "相似字符串组") | [Go](https://github.com/openset/leetcode/tree/master/problems/similar-string-groups) | Hard | -| 840 | [Magic Squares In Grid](https://leetcode.com/problems/magic-squares-in-grid "矩阵中的幻方") | [Go](https://github.com/openset/leetcode/tree/master/problems/magic-squares-in-grid) | Easy | -| 841 | [Keys and Rooms](https://leetcode.com/problems/keys-and-rooms "钥匙和房间") | [Go](https://github.com/openset/leetcode/tree/master/problems/keys-and-rooms) | Medium | -| 842 | [Split Array into Fibonacci Sequence](https://leetcode.com/problems/split-array-into-fibonacci-sequence "将数组拆分成斐波那契序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/split-array-into-fibonacci-sequence) | Medium | -| 843 | [Guess the Word](https://leetcode.com/problems/guess-the-word "猜猜这个单词") | [Go](https://github.com/openset/leetcode/tree/master/problems/guess-the-word) | Hard | -| 844 | [Backspace String Compare](https://leetcode.com/problems/backspace-string-compare "比较含退格的字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/backspace-string-compare) | Easy | -| 845 | [Longest Mountain in Array](https://leetcode.com/problems/longest-mountain-in-array "数组中的最长山脉") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-mountain-in-array) | Medium | -| 846 | [Hand of Straights](https://leetcode.com/problems/hand-of-straights "一手顺子") | [Go](https://github.com/openset/leetcode/tree/master/problems/hand-of-straights) | Medium | -| 847 | [Shortest Path Visiting All Nodes](https://leetcode.com/problems/shortest-path-visiting-all-nodes "访问所有节点的最短路径") | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-path-visiting-all-nodes) | Hard | -| 848 | [Shifting Letters](https://leetcode.com/problems/shifting-letters "字母移位") | [Go](https://github.com/openset/leetcode/tree/master/problems/shifting-letters) | Medium | -| 849 | [Maximize Distance to Closest Person](https://leetcode.com/problems/maximize-distance-to-closest-person "到最近的人的最大距离") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximize-distance-to-closest-person) | Easy | -| 850 | [Rectangle Area II](https://leetcode.com/problems/rectangle-area-ii "矩形面积 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/rectangle-area-ii) | Hard | -| 851 | [Loud and Rich](https://leetcode.com/problems/loud-and-rich "喧闹和富有") | [Go](https://github.com/openset/leetcode/tree/master/problems/loud-and-rich) | Medium | -| 852 | [Peak Index in a Mountain Array](https://leetcode.com/problems/peak-index-in-a-mountain-array "山脉数组的峰顶索引") | [Go](https://github.com/openset/leetcode/tree/master/problems/peak-index-in-a-mountain-array) | Easy | -| 853 | [Car Fleet](https://leetcode.com/problems/car-fleet "车队") | [Go](https://github.com/openset/leetcode/tree/master/problems/car-fleet) | Medium | -| 854 | [K-Similar Strings](https://leetcode.com/problems/k-similar-strings "相似度为 K 的字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/k-similar-strings) | Hard | -| 855 | [Exam Room](https://leetcode.com/problems/exam-room "考场就座") | [Go](https://github.com/openset/leetcode/tree/master/problems/exam-room) | Medium | -| 856 | [Score of Parentheses](https://leetcode.com/problems/score-of-parentheses "括号的分数") | [Go](https://github.com/openset/leetcode/tree/master/problems/score-of-parentheses) | Medium | -| 857 | [Minimum Cost to Hire K Workers](https://leetcode.com/problems/minimum-cost-to-hire-k-workers "雇佣 K 名工人的最低成本") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-to-hire-k-workers) | Hard | -| 858 | [Mirror Reflection](https://leetcode.com/problems/mirror-reflection "镜面反射") | [Go](https://github.com/openset/leetcode/tree/master/problems/mirror-reflection) | Medium | -| 859 | [Buddy Strings](https://leetcode.com/problems/buddy-strings "亲密字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/buddy-strings) | Easy | -| 860 | [Lemonade Change](https://leetcode.com/problems/lemonade-change "柠檬水找零") | [Go](https://github.com/openset/leetcode/tree/master/problems/lemonade-change) | Easy | -| 861 | [Score After Flipping Matrix](https://leetcode.com/problems/score-after-flipping-matrix "翻转矩阵后的得分") | [Go](https://github.com/openset/leetcode/tree/master/problems/score-after-flipping-matrix) | Medium | -| 862 | [Shortest Subarray with Sum at Least K](https://leetcode.com/problems/shortest-subarray-with-sum-at-least-k "和至少为 K 的最短子数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-subarray-with-sum-at-least-k) | Hard | -| 863 | [All Nodes Distance K in Binary Tree](https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree "二叉树中所有距离为 K 的结点") | [Go](https://github.com/openset/leetcode/tree/master/problems/all-nodes-distance-k-in-binary-tree) | Medium | -| 864 | [Shortest Path to Get All Keys](https://leetcode.com/problems/shortest-path-to-get-all-keys "获取所有钥匙的最短路径") | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-path-to-get-all-keys) | Hard | -| 865 | [Smallest Subtree with all the Deepest Nodes](https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes "具有所有最深结点的最小子树") | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-subtree-with-all-the-deepest-nodes) | Medium | -| 866 | [Prime Palindrome](https://leetcode.com/problems/prime-palindrome "回文素数") | [Go](https://github.com/openset/leetcode/tree/master/problems/prime-palindrome) | Medium | -| 867 | [Transpose Matrix](https://leetcode.com/problems/transpose-matrix "转置矩阵") | [Go](https://github.com/openset/leetcode/tree/master/problems/transpose-matrix) | Easy | -| 868 | [Binary Gap](https://leetcode.com/problems/binary-gap "二进制间距") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-gap) | Easy | -| 869 | [Reordered Power of 2](https://leetcode.com/problems/reordered-power-of-2 "重新排序得到 2 的幂") | [Go](https://github.com/openset/leetcode/tree/master/problems/reordered-power-of-2) | Medium | -| 870 | [Advantage Shuffle](https://leetcode.com/problems/advantage-shuffle "优势洗牌") | [Go](https://github.com/openset/leetcode/tree/master/problems/advantage-shuffle) | Medium | -| 871 | [Minimum Number of Refueling Stops](https://leetcode.com/problems/minimum-number-of-refueling-stops "最低加油次数") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-refueling-stops) | Hard | -| 872 | [Leaf-Similar Trees](https://leetcode.com/problems/leaf-similar-trees "叶子相似的树") | [Go](https://github.com/openset/leetcode/tree/master/problems/leaf-similar-trees) | Easy | -| 873 | [Length of Longest Fibonacci Subsequence](https://leetcode.com/problems/length-of-longest-fibonacci-subsequence "最长的斐波那契子序列的长度") | [Go](https://github.com/openset/leetcode/tree/master/problems/length-of-longest-fibonacci-subsequence) | Medium | -| 874 | [Walking Robot Simulation](https://leetcode.com/problems/walking-robot-simulation "模拟行走机器人") | [Go](https://github.com/openset/leetcode/tree/master/problems/walking-robot-simulation) | Easy | -| 875 | [Koko Eating Bananas](https://leetcode.com/problems/koko-eating-bananas "爱吃香蕉的珂珂") | [Go](https://github.com/openset/leetcode/tree/master/problems/koko-eating-bananas) | Medium | -| 876 | [Middle of the Linked List](https://leetcode.com/problems/middle-of-the-linked-list "链表的中间结点") | [Go](https://github.com/openset/leetcode/tree/master/problems/middle-of-the-linked-list) | Easy | -| 877 | [Stone Game](https://leetcode.com/problems/stone-game "石子游戏") | [Go](https://github.com/openset/leetcode/tree/master/problems/stone-game) | Medium | -| 878 | [Nth Magical Number](https://leetcode.com/problems/nth-magical-number "第 N 个神奇数字") | [Go](https://github.com/openset/leetcode/tree/master/problems/nth-magical-number) | Hard | -| 879 | [Profitable Schemes](https://leetcode.com/problems/profitable-schemes "盈利计划") | [Go](https://github.com/openset/leetcode/tree/master/problems/profitable-schemes) | Hard | -| 880 | [Decoded String at Index](https://leetcode.com/problems/decoded-string-at-index "索引处的解码字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/decoded-string-at-index) | Medium | -| 881 | [Boats to Save People](https://leetcode.com/problems/boats-to-save-people "救生艇") | [Go](https://github.com/openset/leetcode/tree/master/problems/boats-to-save-people) | Medium | -| 882 | [Reachable Nodes In Subdivided Graph](https://leetcode.com/problems/reachable-nodes-in-subdivided-graph "细分图中的可到达结点") | [Go](https://github.com/openset/leetcode/tree/master/problems/reachable-nodes-in-subdivided-graph) | Hard | -| 883 | [Projection Area of 3D Shapes](https://leetcode.com/problems/projection-area-of-3d-shapes "三维形体投影面积") | [Go](https://github.com/openset/leetcode/tree/master/problems/projection-area-of-3d-shapes) | Easy | -| 884 | [Uncommon Words from Two Sentences](https://leetcode.com/problems/uncommon-words-from-two-sentences "两句话中的不常见单词") | [Go](https://github.com/openset/leetcode/tree/master/problems/uncommon-words-from-two-sentences) | Easy | -| 885 | [Spiral Matrix III](https://leetcode.com/problems/spiral-matrix-iii "螺旋矩阵 III") | [Go](https://github.com/openset/leetcode/tree/master/problems/spiral-matrix-iii) | Medium | -| 886 | [Possible Bipartition](https://leetcode.com/problems/possible-bipartition "可能的二分法") | [Go](https://github.com/openset/leetcode/tree/master/problems/possible-bipartition) | Medium | -| 887 | [Super Egg Drop](https://leetcode.com/problems/super-egg-drop "鸡蛋掉落") | [Go](https://github.com/openset/leetcode/tree/master/problems/super-egg-drop) | Hard | -| 888 | [Fair Candy Swap](https://leetcode.com/problems/fair-candy-swap "公平的糖果交换") | [Go](https://github.com/openset/leetcode/tree/master/problems/fair-candy-swap) | Easy | -| 889 | [Construct Binary Tree from Preorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal "根据前序和后序遍历构造二叉树") | [Go](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-preorder-and-postorder-traversal) | Medium | -| 890 | [Find and Replace Pattern](https://leetcode.com/problems/find-and-replace-pattern "查找和替换模式") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-and-replace-pattern) | Medium | -| 891 | [Sum of Subsequence Widths](https://leetcode.com/problems/sum-of-subsequence-widths "子序列宽度之和") | [Go](https://github.com/openset/leetcode/tree/master/problems/sum-of-subsequence-widths) | Hard | -| 892 | [Surface Area of 3D Shapes](https://leetcode.com/problems/surface-area-of-3d-shapes "三维形体的表面积") | [Go](https://github.com/openset/leetcode/tree/master/problems/surface-area-of-3d-shapes) | Easy | -| 893 | [Groups of Special-Equivalent Strings](https://leetcode.com/problems/groups-of-special-equivalent-strings "特殊等价字符串组") | [Go](https://github.com/openset/leetcode/tree/master/problems/groups-of-special-equivalent-strings) | Easy | -| 894 | [All Possible Full Binary Trees](https://leetcode.com/problems/all-possible-full-binary-trees "所有可能的满二叉树") | [Go](https://github.com/openset/leetcode/tree/master/problems/all-possible-full-binary-trees) | Medium | -| 895 | [Maximum Frequency Stack](https://leetcode.com/problems/maximum-frequency-stack "最大频率栈") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-frequency-stack) | Hard | -| 896 | [Monotonic Array](https://leetcode.com/problems/monotonic-array "单调数列") | [Go](https://github.com/openset/leetcode/tree/master/problems/monotonic-array) | Easy | -| 897 | [Increasing Order Search Tree](https://leetcode.com/problems/increasing-order-search-tree "递增顺序查找树") | [Go](https://github.com/openset/leetcode/tree/master/problems/increasing-order-search-tree) | Easy | -| 898 | [Bitwise ORs of Subarrays](https://leetcode.com/problems/bitwise-ors-of-subarrays "子数组按位或操作") | [Go](https://github.com/openset/leetcode/tree/master/problems/bitwise-ors-of-subarrays) | Medium | -| 899 | [Orderly Queue](https://leetcode.com/problems/orderly-queue "有序队列") | [Go](https://github.com/openset/leetcode/tree/master/problems/orderly-queue) | Hard | -| 900 | [RLE Iterator](https://leetcode.com/problems/rle-iterator "RLE 迭代器") | [Go](https://github.com/openset/leetcode/tree/master/problems/rle-iterator) | Medium | +| 601 | [Human Traffic of Stadium](https://leetcode.com/problems/human-traffic-of-stadium "体育馆的人流量") | [MySQL](../problems/human-traffic-of-stadium) | Hard | +| 602 | [Friend Requests II: Who Has the Most Friends](https://leetcode.com/problems/friend-requests-ii-who-has-the-most-friends "好友申请 II :谁有最多的好友") 🔒 | [MySQL](../problems/friend-requests-ii-who-has-the-most-friends) | Medium | +| 603 | [Consecutive Available Seats](https://leetcode.com/problems/consecutive-available-seats "连续空余座位") 🔒 | [MySQL](../problems/consecutive-available-seats) | Easy | +| 604 | [Design Compressed String Iterator](https://leetcode.com/problems/design-compressed-string-iterator "迭代压缩字符串") 🔒 | [Go](../problems/design-compressed-string-iterator) | Easy | +| 605 | [Can Place Flowers](https://leetcode.com/problems/can-place-flowers "种花问题") | [Go](../problems/can-place-flowers) | Easy | +| 606 | [Construct String from Binary Tree](https://leetcode.com/problems/construct-string-from-binary-tree "根据二叉树创建字符串") | [Go](../problems/construct-string-from-binary-tree) | Easy | +| 607 | [Sales Person](https://leetcode.com/problems/sales-person "销售员") 🔒 | [MySQL](../problems/sales-person) | Easy | +| 608 | [Tree Node](https://leetcode.com/problems/tree-node "树节点") 🔒 | [MySQL](../problems/tree-node) | Medium | +| 609 | [Find Duplicate File in System](https://leetcode.com/problems/find-duplicate-file-in-system "在系统中查找重复文件") | [Go](../problems/find-duplicate-file-in-system) | Medium | +| 610 | [Triangle Judgement](https://leetcode.com/problems/triangle-judgement "判断三角形") 🔒 | [MySQL](../problems/triangle-judgement) | Easy | +| 611 | [Valid Triangle Number](https://leetcode.com/problems/valid-triangle-number "有效三角形的个数") | [Go](../problems/valid-triangle-number) | Medium | +| 612 | [Shortest Distance in a Plane](https://leetcode.com/problems/shortest-distance-in-a-plane "平面上的最近距离") 🔒 | [MySQL](../problems/shortest-distance-in-a-plane) | Medium | +| 613 | [Shortest Distance in a Line](https://leetcode.com/problems/shortest-distance-in-a-line "直线上的最近距离") 🔒 | [MySQL](../problems/shortest-distance-in-a-line) | Easy | +| 614 | [Second Degree Follower](https://leetcode.com/problems/second-degree-follower "二级关注者") 🔒 | [MySQL](../problems/second-degree-follower) | Medium | +| 615 | [Average Salary: Departments VS Company](https://leetcode.com/problems/average-salary-departments-vs-company "平均工资:部门与公司比较") 🔒 | [MySQL](../problems/average-salary-departments-vs-company) | Hard | +| 616 | [Add Bold Tag in String](https://leetcode.com/problems/add-bold-tag-in-string "给字符串添加加粗标签") 🔒 | [Go](../problems/add-bold-tag-in-string) | Medium | +| 617 | [Merge Two Binary Trees](https://leetcode.com/problems/merge-two-binary-trees "合并二叉树") | [Go](../problems/merge-two-binary-trees) | Easy | +| 618 | [Students Report By Geography](https://leetcode.com/problems/students-report-by-geography "学生地理信息报告") 🔒 | [MySQL](../problems/students-report-by-geography) | Hard | +| 619 | [Biggest Single Number](https://leetcode.com/problems/biggest-single-number "只出现一次的最大数字") 🔒 | [MySQL](../problems/biggest-single-number) | Easy | +| 620 | [Not Boring Movies](https://leetcode.com/problems/not-boring-movies "有趣的电影") | [MySQL](../problems/not-boring-movies) | Easy | +| 621 | [Task Scheduler](https://leetcode.com/problems/task-scheduler "任务调度器") | [Go](../problems/task-scheduler) | Medium | +| 622 | [Design Circular Queue](https://leetcode.com/problems/design-circular-queue "设计循环队列") | [Go](../problems/design-circular-queue) | Medium | +| 623 | [Add One Row to Tree](https://leetcode.com/problems/add-one-row-to-tree "在二叉树中增加一行") | [Go](../problems/add-one-row-to-tree) | Medium | +| 624 | [Maximum Distance in Arrays](https://leetcode.com/problems/maximum-distance-in-arrays "数组列表中的最大距离") 🔒 | [Go](../problems/maximum-distance-in-arrays) | Easy | +| 625 | [Minimum Factorization](https://leetcode.com/problems/minimum-factorization "最小因式分解") 🔒 | [Go](../problems/minimum-factorization) | Medium | +| 626 | [Exchange Seats](https://leetcode.com/problems/exchange-seats "换座位") | [MySQL](../problems/exchange-seats) | Medium | +| 627 | [Swap Salary](https://leetcode.com/problems/swap-salary "交换工资") | [MySQL](../problems/swap-salary) | Easy | +| 628 | [Maximum Product of Three Numbers](https://leetcode.com/problems/maximum-product-of-three-numbers "三个数的最大乘积") | [Go](../problems/maximum-product-of-three-numbers) | Easy | +| 629 | [K Inverse Pairs Array](https://leetcode.com/problems/k-inverse-pairs-array "K个逆序对数组") | [Go](../problems/k-inverse-pairs-array) | Hard | +| 630 | [Course Schedule III](https://leetcode.com/problems/course-schedule-iii "课程表 III") | [Go](../problems/course-schedule-iii) | Hard | +| 631 | [Design Excel Sum Formula](https://leetcode.com/problems/design-excel-sum-formula "设计 Excel 求和公式") 🔒 | [Go](../problems/design-excel-sum-formula) | Hard | +| 632 | [Smallest Range Covering Elements from K Lists](https://leetcode.com/problems/smallest-range-covering-elements-from-k-lists "最小区间") | [Go](../problems/smallest-range-covering-elements-from-k-lists) | Hard | +| 633 | [Sum of Square Numbers](https://leetcode.com/problems/sum-of-square-numbers "平方数之和") | [Go](../problems/sum-of-square-numbers) | Easy | +| 634 | [Find the Derangement of An Array](https://leetcode.com/problems/find-the-derangement-of-an-array "寻找数组的错位排列") 🔒 | [Go](../problems/find-the-derangement-of-an-array) | Medium | +| 635 | [Design Log Storage System](https://leetcode.com/problems/design-log-storage-system "设计日志存储系统") 🔒 | [Go](../problems/design-log-storage-system) | Medium | +| 636 | [Exclusive Time of Functions](https://leetcode.com/problems/exclusive-time-of-functions "函数的独占时间") | [Go](../problems/exclusive-time-of-functions) | Medium | +| 637 | [Average of Levels in Binary Tree](https://leetcode.com/problems/average-of-levels-in-binary-tree "二叉树的层平均值") | [Go](../problems/average-of-levels-in-binary-tree) | Easy | +| 638 | [Shopping Offers](https://leetcode.com/problems/shopping-offers "大礼包") | [Go](../problems/shopping-offers) | Medium | +| 639 | [Decode Ways II](https://leetcode.com/problems/decode-ways-ii "解码方法 2") | [Go](../problems/decode-ways-ii) | Hard | +| 640 | [Solve the Equation](https://leetcode.com/problems/solve-the-equation "求解方程") | [Go](../problems/solve-the-equation) | Medium | +| 641 | [Design Circular Deque](https://leetcode.com/problems/design-circular-deque "设计循环双端队列") | [Go](../problems/design-circular-deque) | Medium | +| 642 | [Design Search Autocomplete System](https://leetcode.com/problems/design-search-autocomplete-system "设计搜索自动补全系统") 🔒 | [Go](../problems/design-search-autocomplete-system) | Hard | +| 643 | [Maximum Average Subarray I](https://leetcode.com/problems/maximum-average-subarray-i "子数组最大平均数 I") | [Go](../problems/maximum-average-subarray-i) | Easy | +| 644 | [Maximum Average Subarray II](https://leetcode.com/problems/maximum-average-subarray-ii "最大平均子段和 II") 🔒 | [Go](../problems/maximum-average-subarray-ii) | Hard | +| 645 | [Set Mismatch](https://leetcode.com/problems/set-mismatch "错误的集合") | [Go](../problems/set-mismatch) | Easy | +| 646 | [Maximum Length of Pair Chain](https://leetcode.com/problems/maximum-length-of-pair-chain "最长数对链") | [Go](../problems/maximum-length-of-pair-chain) | Medium | +| 647 | [Palindromic Substrings](https://leetcode.com/problems/palindromic-substrings "回文子串") | [Go](../problems/palindromic-substrings) | Medium | +| 648 | [Replace Words](https://leetcode.com/problems/replace-words "单词替换") | [Go](../problems/replace-words) | Medium | +| 649 | [Dota2 Senate](https://leetcode.com/problems/dota2-senate "Dota2 参议院") | [Go](../problems/dota2-senate) | Medium | +| 650 | [2 Keys Keyboard](https://leetcode.com/problems/2-keys-keyboard "只有两个键的键盘") | [Go](../problems/2-keys-keyboard) | Medium | +| 651 | [4 Keys Keyboard](https://leetcode.com/problems/4-keys-keyboard "4键键盘") 🔒 | [Go](../problems/4-keys-keyboard) | Medium | +| 652 | [Find Duplicate Subtrees](https://leetcode.com/problems/find-duplicate-subtrees "寻找重复的子树") | [Go](../problems/find-duplicate-subtrees) | Medium | +| 653 | [Two Sum IV - Input is a BST](https://leetcode.com/problems/two-sum-iv-input-is-a-bst "两数之和 IV - 输入 BST") | [Go](../problems/two-sum-iv-input-is-a-bst) | Easy | +| 654 | [Maximum Binary Tree](https://leetcode.com/problems/maximum-binary-tree "最大二叉树") | [Go](../problems/maximum-binary-tree) | Medium | +| 655 | [Print Binary Tree](https://leetcode.com/problems/print-binary-tree "输出二叉树") | [Go](../problems/print-binary-tree) | Medium | +| 656 | [Coin Path](https://leetcode.com/problems/coin-path "金币路径") 🔒 | [Go](../problems/coin-path) | Hard | +| 657 | [Robot Return to Origin](https://leetcode.com/problems/robot-return-to-origin "机器人能否返回原点") | [Go](../problems/robot-return-to-origin) | Easy | +| 658 | [Find K Closest Elements](https://leetcode.com/problems/find-k-closest-elements "找到 K 个最接近的元素") | [Go](../problems/find-k-closest-elements) | Medium | +| 659 | [Split Array into Consecutive Subsequences](https://leetcode.com/problems/split-array-into-consecutive-subsequences "分割数组为连续子序列") | [Go](../problems/split-array-into-consecutive-subsequences) | Medium | +| 660 | [Remove 9](https://leetcode.com/problems/remove-9 "移除 9") 🔒 | [Go](../problems/remove-9) | Hard | +| 661 | [Image Smoother](https://leetcode.com/problems/image-smoother "图片平滑器") | [Go](../problems/image-smoother) | Easy | +| 662 | [Maximum Width of Binary Tree](https://leetcode.com/problems/maximum-width-of-binary-tree "二叉树最大宽度") | [Go](../problems/maximum-width-of-binary-tree) | Medium | +| 663 | [Equal Tree Partition](https://leetcode.com/problems/equal-tree-partition "均匀树划分") 🔒 | [Go](../problems/equal-tree-partition) | Medium | +| 664 | [Strange Printer](https://leetcode.com/problems/strange-printer "奇怪的打印机") | [Go](../problems/strange-printer) | Hard | +| 665 | [Non-decreasing Array](https://leetcode.com/problems/non-decreasing-array "非递减数列") | [Go](../problems/non-decreasing-array) | Easy | +| 666 | [Path Sum IV](https://leetcode.com/problems/path-sum-iv "路径和 IV") 🔒 | [Go](../problems/path-sum-iv) | Medium | +| 667 | [Beautiful Arrangement II](https://leetcode.com/problems/beautiful-arrangement-ii "优美的排列 II") | [Go](../problems/beautiful-arrangement-ii) | Medium | +| 668 | [Kth Smallest Number in Multiplication Table](https://leetcode.com/problems/kth-smallest-number-in-multiplication-table "乘法表中第k小的数") | [Go](../problems/kth-smallest-number-in-multiplication-table) | Hard | +| 669 | [Trim a Binary Search Tree](https://leetcode.com/problems/trim-a-binary-search-tree "修剪二叉搜索树") | [Go](../problems/trim-a-binary-search-tree) | Easy | +| 670 | [Maximum Swap](https://leetcode.com/problems/maximum-swap "最大交换") | [Go](../problems/maximum-swap) | Medium | +| 671 | [Second Minimum Node In a Binary Tree](https://leetcode.com/problems/second-minimum-node-in-a-binary-tree "二叉树中第二小的节点") | [Go](../problems/second-minimum-node-in-a-binary-tree) | Easy | +| 672 | [Bulb Switcher II](https://leetcode.com/problems/bulb-switcher-ii "灯泡开关 Ⅱ") | [Go](../problems/bulb-switcher-ii) | Medium | +| 673 | [Number of Longest Increasing Subsequence](https://leetcode.com/problems/number-of-longest-increasing-subsequence "最长递增子序列的个数") | [Go](../problems/number-of-longest-increasing-subsequence) | Medium | +| 674 | [Longest Continuous Increasing Subsequence](https://leetcode.com/problems/longest-continuous-increasing-subsequence "最长连续递增序列") | [Go](../problems/longest-continuous-increasing-subsequence) | Easy | +| 675 | [Cut Off Trees for Golf Event](https://leetcode.com/problems/cut-off-trees-for-golf-event "为高尔夫比赛砍树") | [Go](../problems/cut-off-trees-for-golf-event) | Hard | +| 676 | [Implement Magic Dictionary](https://leetcode.com/problems/implement-magic-dictionary "实现一个魔法字典") | [Go](../problems/implement-magic-dictionary) | Medium | +| 677 | [Map Sum Pairs](https://leetcode.com/problems/map-sum-pairs "键值映射") | [Go](../problems/map-sum-pairs) | Medium | +| 678 | [Valid Parenthesis String](https://leetcode.com/problems/valid-parenthesis-string "有效的括号字符串") | [Go](../problems/valid-parenthesis-string) | Medium | +| 679 | [24 Game](https://leetcode.com/problems/24-game "24 点游戏") | [Go](../problems/24-game) | Hard | +| 680 | [Valid Palindrome II](https://leetcode.com/problems/valid-palindrome-ii "验证回文字符串 Ⅱ") | [Go](../problems/valid-palindrome-ii) | Easy | +| 681 | [Next Closest Time](https://leetcode.com/problems/next-closest-time "最近时刻") 🔒 | [Go](../problems/next-closest-time) | Medium | +| 682 | [Baseball Game](https://leetcode.com/problems/baseball-game "棒球比赛") | [Go](../problems/baseball-game) | Easy | +| 683 | [K Empty Slots](https://leetcode.com/problems/k-empty-slots "K 个空花盆") 🔒 | [Go](../problems/k-empty-slots) | Hard | +| 684 | [Redundant Connection](https://leetcode.com/problems/redundant-connection "冗余连接") | [Go](../problems/redundant-connection) | Medium | +| 685 | [Redundant Connection II](https://leetcode.com/problems/redundant-connection-ii "冗余连接 II") | [Go](../problems/redundant-connection-ii) | Hard | +| 686 | [Repeated String Match](https://leetcode.com/problems/repeated-string-match "重复叠加字符串匹配") | [Go](../problems/repeated-string-match) | Easy | +| 687 | [Longest Univalue Path](https://leetcode.com/problems/longest-univalue-path "最长同值路径") | [Go](../problems/longest-univalue-path) | Easy | +| 688 | [Knight Probability in Chessboard](https://leetcode.com/problems/knight-probability-in-chessboard "“马”在棋盘上的概率") | [Go](../problems/knight-probability-in-chessboard) | Medium | +| 689 | [Maximum Sum of 3 Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays "三个无重叠子数组的最大和") | [Go](../problems/maximum-sum-of-3-non-overlapping-subarrays) | Hard | +| 690 | [Employee Importance](https://leetcode.com/problems/employee-importance "员工的重要性") | [Go](../problems/employee-importance) | Easy | +| 691 | [Stickers to Spell Word](https://leetcode.com/problems/stickers-to-spell-word "贴纸拼词") | [Go](../problems/stickers-to-spell-word) | Hard | +| 692 | [Top K Frequent Words](https://leetcode.com/problems/top-k-frequent-words "前K个高频单词") | [Go](../problems/top-k-frequent-words) | Medium | +| 693 | [Binary Number with Alternating Bits](https://leetcode.com/problems/binary-number-with-alternating-bits "交替位二进制数") | [Go](../problems/binary-number-with-alternating-bits) | Easy | +| 694 | [Number of Distinct Islands](https://leetcode.com/problems/number-of-distinct-islands "不同岛屿的数量") 🔒 | [Go](../problems/number-of-distinct-islands) | Medium | +| 695 | [Max Area of Island](https://leetcode.com/problems/max-area-of-island "岛屿的最大面积") | [Go](../problems/max-area-of-island) | Medium | +| 696 | [Count Binary Substrings](https://leetcode.com/problems/count-binary-substrings "计数二进制子串") | [Go](../problems/count-binary-substrings) | Easy | +| 697 | [Degree of an Array](https://leetcode.com/problems/degree-of-an-array "数组的度") | [Go](../problems/degree-of-an-array) | Easy | +| 698 | [Partition to K Equal Sum Subsets](https://leetcode.com/problems/partition-to-k-equal-sum-subsets "划分为k个相等的子集") | [Go](../problems/partition-to-k-equal-sum-subsets) | Medium | +| 699 | [Falling Squares](https://leetcode.com/problems/falling-squares "掉落的方块") | [Go](../problems/falling-squares) | Hard | +| 700 | [Search in a Binary Search Tree](https://leetcode.com/problems/search-in-a-binary-search-tree "二叉搜索树中的搜索") | [Go](../problems/search-in-a-binary-search-tree) | Easy | +| 701 | [Insert into a Binary Search Tree](https://leetcode.com/problems/insert-into-a-binary-search-tree "二叉搜索树中的插入操作") | [Go](../problems/insert-into-a-binary-search-tree) | Medium | +| 702 | [Search in a Sorted Array of Unknown Size](https://leetcode.com/problems/search-in-a-sorted-array-of-unknown-size "搜索长度未知的有序数组") 🔒 | [Go](../problems/search-in-a-sorted-array-of-unknown-size) | Medium | +| 703 | [Kth Largest Element in a Stream](https://leetcode.com/problems/kth-largest-element-in-a-stream "数据流中的第K大元素") | [Go](../problems/kth-largest-element-in-a-stream) | Easy | +| 704 | [Binary Search](https://leetcode.com/problems/binary-search "二分查找") | [Go](../problems/binary-search) | Easy | +| 705 | [Design HashSet](https://leetcode.com/problems/design-hashset "设计哈希集合") | [Go](../problems/design-hashset) | Easy | +| 706 | [Design HashMap](https://leetcode.com/problems/design-hashmap "设计哈希映射") | [Go](../problems/design-hashmap) | Easy | +| 707 | [Design Linked List](https://leetcode.com/problems/design-linked-list "设计链表") | [Go](../problems/design-linked-list) | Medium | +| 708 | [Insert into a Sorted Circular Linked List](https://leetcode.com/problems/insert-into-a-sorted-circular-linked-list "循环有序列表的插入") 🔒 | [Go](../problems/insert-into-a-sorted-circular-linked-list) | Medium | +| 709 | [To Lower Case](https://leetcode.com/problems/to-lower-case "转换成小写字母") | [Go](../problems/to-lower-case) | Easy | +| 710 | [Random Pick with Blacklist](https://leetcode.com/problems/random-pick-with-blacklist "黑名单中的随机数") | [Go](../problems/random-pick-with-blacklist) | Hard | +| 711 | [Number of Distinct Islands II](https://leetcode.com/problems/number-of-distinct-islands-ii "不同岛屿的数量 II") 🔒 | [Go](../problems/number-of-distinct-islands-ii) | Hard | +| 712 | [Minimum ASCII Delete Sum for Two Strings](https://leetcode.com/problems/minimum-ascii-delete-sum-for-two-strings "两个字符串的最小ASCII删除和") | [Go](../problems/minimum-ascii-delete-sum-for-two-strings) | Medium | +| 713 | [Subarray Product Less Than K](https://leetcode.com/problems/subarray-product-less-than-k "乘积小于K的子数组") | [Go](../problems/subarray-product-less-than-k) | Medium | +| 714 | [Best Time to Buy and Sell Stock with Transaction Fee](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee "买卖股票的最佳时机含手续费") | [Go](../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | Medium | +| 715 | [Range Module](https://leetcode.com/problems/range-module "Range 模块") | [Go](../problems/range-module) | Hard | +| 716 | [Max Stack](https://leetcode.com/problems/max-stack "最大栈") 🔒 | [Go](../problems/max-stack) | Easy | +| 717 | [1-bit and 2-bit Characters](https://leetcode.com/problems/1-bit-and-2-bit-characters "1比特与2比特字符") | [Go](../problems/1-bit-and-2-bit-characters) | Easy | +| 718 | [Maximum Length of Repeated Subarray](https://leetcode.com/problems/maximum-length-of-repeated-subarray "最长重复子数组") | [Go](../problems/maximum-length-of-repeated-subarray) | Medium | +| 719 | [Find K-th Smallest Pair Distance](https://leetcode.com/problems/find-k-th-smallest-pair-distance "找出第 k 小的距离对") | [Go](../problems/find-k-th-smallest-pair-distance) | Hard | +| 720 | [Longest Word in Dictionary](https://leetcode.com/problems/longest-word-in-dictionary "词典中最长的单词") | [Go](../problems/longest-word-in-dictionary) | Easy | +| 721 | [Accounts Merge](https://leetcode.com/problems/accounts-merge "账户合并") | [Go](../problems/accounts-merge) | Medium | +| 722 | [Remove Comments](https://leetcode.com/problems/remove-comments "删除注释") | [Go](../problems/remove-comments) | Medium | +| 723 | [Candy Crush](https://leetcode.com/problems/candy-crush "粉碎糖果") 🔒 | [Go](../problems/candy-crush) | Medium | +| 724 | [Find Pivot Index](https://leetcode.com/problems/find-pivot-index "寻找数组的中心索引") | [Go](../problems/find-pivot-index) | Easy | +| 725 | [Split Linked List in Parts](https://leetcode.com/problems/split-linked-list-in-parts "分隔链表") | [Go](../problems/split-linked-list-in-parts) | Medium | +| 726 | [Number of Atoms](https://leetcode.com/problems/number-of-atoms "原子的数量") | [Go](../problems/number-of-atoms) | Hard | +| 727 | [Minimum Window Subsequence](https://leetcode.com/problems/minimum-window-subsequence "最小窗口子序列") 🔒 | [Go](../problems/minimum-window-subsequence) | Hard | +| 728 | [Self Dividing Numbers](https://leetcode.com/problems/self-dividing-numbers "自除数") | [Go](../problems/self-dividing-numbers) | Easy | +| 729 | [My Calendar I](https://leetcode.com/problems/my-calendar-i "我的日程安排表 I") | [Go](../problems/my-calendar-i) | Medium | +| 730 | [Count Different Palindromic Subsequences](https://leetcode.com/problems/count-different-palindromic-subsequences "统计不同回文子字符串") | [Go](../problems/count-different-palindromic-subsequences) | Hard | +| 731 | [My Calendar II](https://leetcode.com/problems/my-calendar-ii "我的日程安排表 II") | [Go](../problems/my-calendar-ii) | Medium | +| 732 | [My Calendar III](https://leetcode.com/problems/my-calendar-iii "我的日程安排表 III") | [Go](../problems/my-calendar-iii) | Hard | +| 733 | [Flood Fill](https://leetcode.com/problems/flood-fill "图像渲染") | [Go](../problems/flood-fill) | Easy | +| 734 | [Sentence Similarity](https://leetcode.com/problems/sentence-similarity "句子相似性") 🔒 | [Go](../problems/sentence-similarity) | Easy | +| 735 | [Asteroid Collision](https://leetcode.com/problems/asteroid-collision "行星碰撞") | [Go](../problems/asteroid-collision) | Medium | +| 736 | [Parse Lisp Expression](https://leetcode.com/problems/parse-lisp-expression "Lisp 语法解析") | [Go](../problems/parse-lisp-expression) | Hard | +| 737 | [Sentence Similarity II](https://leetcode.com/problems/sentence-similarity-ii "句子相似性 II") 🔒 | [Go](../problems/sentence-similarity-ii) | Medium | +| 738 | [Monotone Increasing Digits](https://leetcode.com/problems/monotone-increasing-digits "单调递增的数字") | [Go](../problems/monotone-increasing-digits) | Medium | +| 739 | [Daily Temperatures](https://leetcode.com/problems/daily-temperatures "每日温度") | [Go](../problems/daily-temperatures) | Medium | +| 740 | [Delete and Earn](https://leetcode.com/problems/delete-and-earn "删除与获得点数") | [Go](../problems/delete-and-earn) | Medium | +| 741 | [Cherry Pickup](https://leetcode.com/problems/cherry-pickup "摘樱桃") | [Go](../problems/cherry-pickup) | Hard | +| 742 | [Closest Leaf in a Binary Tree](https://leetcode.com/problems/closest-leaf-in-a-binary-tree "二叉树最近的叶节点") 🔒 | [Go](../problems/closest-leaf-in-a-binary-tree) | Medium | +| 743 | [Network Delay Time](https://leetcode.com/problems/network-delay-time "网络延迟时间") | [Go](../problems/network-delay-time) | Medium | +| 744 | [Find Smallest Letter Greater Than Target](https://leetcode.com/problems/find-smallest-letter-greater-than-target "寻找比目标字母大的最小字母") | [Go](../problems/find-smallest-letter-greater-than-target) | Easy | +| 745 | [Prefix and Suffix Search](https://leetcode.com/problems/prefix-and-suffix-search "前缀和后缀搜索") | [Go](../problems/prefix-and-suffix-search) | Hard | +| 746 | [Min Cost Climbing Stairs](https://leetcode.com/problems/min-cost-climbing-stairs "使用最小花费爬楼梯") | [Go](../problems/min-cost-climbing-stairs) | Easy | +| 747 | [Largest Number At Least Twice of Others](https://leetcode.com/problems/largest-number-at-least-twice-of-others "至少是其他数字两倍的最大数") | [Go](../problems/largest-number-at-least-twice-of-others) | Easy | +| 748 | [Shortest Completing Word](https://leetcode.com/problems/shortest-completing-word "最短完整词") | [Go](../problems/shortest-completing-word) | Easy | +| 749 | [Contain Virus](https://leetcode.com/problems/contain-virus "隔离病毒") | [Go](../problems/contain-virus) | Hard | +| 750 | [Number Of Corner Rectangles](https://leetcode.com/problems/number-of-corner-rectangles "角矩形的数量") 🔒 | [Go](../problems/number-of-corner-rectangles) | Medium | +| 751 | [IP to CIDR](https://leetcode.com/problems/ip-to-cidr "IP 到 CIDR") 🔒 | [Go](../problems/ip-to-cidr) | Easy | +| 752 | [Open the Lock](https://leetcode.com/problems/open-the-lock "打开转盘锁") | [Go](../problems/open-the-lock) | Medium | +| 753 | [Cracking the Safe](https://leetcode.com/problems/cracking-the-safe "破解保险箱") | [Go](../problems/cracking-the-safe) | Hard | +| 754 | [Reach a Number](https://leetcode.com/problems/reach-a-number "到达终点数字") | [Go](../problems/reach-a-number) | Medium | +| 755 | [Pour Water](https://leetcode.com/problems/pour-water "倒水") 🔒 | [Go](../problems/pour-water) | Medium | +| 756 | [Pyramid Transition Matrix](https://leetcode.com/problems/pyramid-transition-matrix "金字塔转换矩阵") | [Go](../problems/pyramid-transition-matrix) | Medium | +| 757 | [Set Intersection Size At Least Two](https://leetcode.com/problems/set-intersection-size-at-least-two " 设置交集大小至少为2") | [Go](../problems/set-intersection-size-at-least-two) | Hard | +| 758 | [Bold Words in String](https://leetcode.com/problems/bold-words-in-string "字符串中的加粗单词") 🔒 | [Go](../problems/bold-words-in-string) | Easy | +| 759 | [Employee Free Time](https://leetcode.com/problems/employee-free-time "员工空闲时间") 🔒 | [Go](../problems/employee-free-time) | Hard | +| 760 | [Find Anagram Mappings](https://leetcode.com/problems/find-anagram-mappings "找出变位映射") 🔒 | [Go](../problems/find-anagram-mappings) | Easy | +| 761 | [Special Binary String](https://leetcode.com/problems/special-binary-string "特殊的二进制序列") | [Go](../problems/special-binary-string) | Hard | +| 762 | [Prime Number of Set Bits in Binary Representation](https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation "二进制表示中质数个计算置位") | [Go](../problems/prime-number-of-set-bits-in-binary-representation) | Easy | +| 763 | [Partition Labels](https://leetcode.com/problems/partition-labels "划分字母区间") | [Go](../problems/partition-labels) | Medium | +| 764 | [Largest Plus Sign](https://leetcode.com/problems/largest-plus-sign "最大加号标志") | [Go](../problems/largest-plus-sign) | Medium | +| 765 | [Couples Holding Hands](https://leetcode.com/problems/couples-holding-hands "情侣牵手") | [Go](../problems/couples-holding-hands) | Hard | +| 766 | [Toeplitz Matrix](https://leetcode.com/problems/toeplitz-matrix "托普利茨矩阵") | [Go](../problems/toeplitz-matrix) | Easy | +| 767 | [Reorganize String](https://leetcode.com/problems/reorganize-string "重构字符串") | [Go](../problems/reorganize-string) | Medium | +| 768 | [Max Chunks To Make Sorted II](https://leetcode.com/problems/max-chunks-to-make-sorted-ii "最多能完成排序的块 II") | [Go](../problems/max-chunks-to-make-sorted-ii) | Hard | +| 769 | [Max Chunks To Make Sorted](https://leetcode.com/problems/max-chunks-to-make-sorted "最多能完成排序的块") | [Go](../problems/max-chunks-to-make-sorted) | Medium | +| 770 | [Basic Calculator IV](https://leetcode.com/problems/basic-calculator-iv "基本计算器 IV") | [Go](../problems/basic-calculator-iv) | Hard | +| 771 | [Jewels and Stones](https://leetcode.com/problems/jewels-and-stones "宝石与石头") | [Go](../problems/jewels-and-stones) | Easy | +| 772 | [Basic Calculator III](https://leetcode.com/problems/basic-calculator-iii "基本计算器 III") 🔒 | [Go](../problems/basic-calculator-iii) | Hard | +| 773 | [Sliding Puzzle](https://leetcode.com/problems/sliding-puzzle "滑动谜题") | [Go](../problems/sliding-puzzle) | Hard | +| 774 | [Minimize Max Distance to Gas Station](https://leetcode.com/problems/minimize-max-distance-to-gas-station "最小化去加油站的最大距离") 🔒 | [Go](../problems/minimize-max-distance-to-gas-station) | Hard | +| 775 | [Global and Local Inversions](https://leetcode.com/problems/global-and-local-inversions "全局倒置与局部倒置") | [Go](../problems/global-and-local-inversions) | Medium | +| 776 | [Split BST](https://leetcode.com/problems/split-bst "拆分二叉搜索树") 🔒 | [Go](../problems/split-bst) | Medium | +| 777 | [Swap Adjacent in LR String](https://leetcode.com/problems/swap-adjacent-in-lr-string "在LR字符串中交换相邻字符") | [Go](../problems/swap-adjacent-in-lr-string) | Medium | +| 778 | [Swim in Rising Water](https://leetcode.com/problems/swim-in-rising-water "水位上升的泳池中游泳") | [Go](../problems/swim-in-rising-water) | Hard | +| 779 | [K-th Symbol in Grammar](https://leetcode.com/problems/k-th-symbol-in-grammar "第K个语法符号") | [Go](../problems/k-th-symbol-in-grammar) | Medium | +| 780 | [Reaching Points](https://leetcode.com/problems/reaching-points "到达终点") | [Go](../problems/reaching-points) | Hard | +| 781 | [Rabbits in Forest](https://leetcode.com/problems/rabbits-in-forest "森林中的兔子") | [Go](../problems/rabbits-in-forest) | Medium | +| 782 | [Transform to Chessboard](https://leetcode.com/problems/transform-to-chessboard "变为棋盘") | [Go](../problems/transform-to-chessboard) | Hard | +| 783 | [Minimum Distance Between BST Nodes](https://leetcode.com/problems/minimum-distance-between-bst-nodes "二叉搜索树结点最小距离") | [Go](../problems/minimum-distance-between-bst-nodes) | Easy | +| 784 | [Letter Case Permutation](https://leetcode.com/problems/letter-case-permutation "字母大小写全排列") | [Go](../problems/letter-case-permutation) | Easy | +| 785 | [Is Graph Bipartite?](https://leetcode.com/problems/is-graph-bipartite "判断二分图") | [Go](../problems/is-graph-bipartite) | Medium | +| 786 | [K-th Smallest Prime Fraction](https://leetcode.com/problems/k-th-smallest-prime-fraction "第 K 个最小的素数分数") | [Go](../problems/k-th-smallest-prime-fraction) | Hard | +| 787 | [Cheapest Flights Within K Stops](https://leetcode.com/problems/cheapest-flights-within-k-stops "K 站中转内最便宜的航班") | [Go](../problems/cheapest-flights-within-k-stops) | Medium | +| 788 | [Rotated Digits](https://leetcode.com/problems/rotated-digits "旋转数字") | [Go](../problems/rotated-digits) | Easy | +| 789 | [Escape The Ghosts](https://leetcode.com/problems/escape-the-ghosts "逃脱阻碍者") | [Go](../problems/escape-the-ghosts) | Medium | +| 790 | [Domino and Tromino Tiling](https://leetcode.com/problems/domino-and-tromino-tiling "多米诺和托米诺平铺") | [Go](../problems/domino-and-tromino-tiling) | Medium | +| 791 | [Custom Sort String](https://leetcode.com/problems/custom-sort-string "自定义字符串排序") | [Go](../problems/custom-sort-string) | Medium | +| 792 | [Number of Matching Subsequences](https://leetcode.com/problems/number-of-matching-subsequences "匹配子序列的单词数") | [Go](../problems/number-of-matching-subsequences) | Medium | +| 793 | [Preimage Size of Factorial Zeroes Function](https://leetcode.com/problems/preimage-size-of-factorial-zeroes-function "阶乘函数后K个零") | [Go](../problems/preimage-size-of-factorial-zeroes-function) | Hard | +| 794 | [Valid Tic-Tac-Toe State](https://leetcode.com/problems/valid-tic-tac-toe-state "有效的井字游戏") | [Go](../problems/valid-tic-tac-toe-state) | Medium | +| 795 | [Number of Subarrays with Bounded Maximum](https://leetcode.com/problems/number-of-subarrays-with-bounded-maximum "区间子数组个数") | [Go](../problems/number-of-subarrays-with-bounded-maximum) | Medium | +| 796 | [Rotate String](https://leetcode.com/problems/rotate-string "旋转字符串") | [Go](../problems/rotate-string) | Easy | +| 797 | [All Paths From Source to Target](https://leetcode.com/problems/all-paths-from-source-to-target "所有可能的路径") | [Go](../problems/all-paths-from-source-to-target) | Medium | +| 798 | [Smallest Rotation with Highest Score](https://leetcode.com/problems/smallest-rotation-with-highest-score "得分最高的最小轮调") | [Go](../problems/smallest-rotation-with-highest-score) | Hard | +| 799 | [Champagne Tower](https://leetcode.com/problems/champagne-tower "香槟塔") | [Go](../problems/champagne-tower) | Medium | +| 800 | [Similar RGB Color](https://leetcode.com/problems/similar-rgb-color "相似 RGB 颜色") 🔒 | [Go](../problems/similar-rgb-color) | Easy | +| 801 | [Minimum Swaps To Make Sequences Increasing](https://leetcode.com/problems/minimum-swaps-to-make-sequences-increasing "使序列递增的最小交换次数") | [Go](../problems/minimum-swaps-to-make-sequences-increasing) | Medium | +| 802 | [Find Eventual Safe States](https://leetcode.com/problems/find-eventual-safe-states "找到最终的安全状态") | [Go](../problems/find-eventual-safe-states) | Medium | +| 803 | [Bricks Falling When Hit](https://leetcode.com/problems/bricks-falling-when-hit "打砖块") | [Go](../problems/bricks-falling-when-hit) | Hard | +| 804 | [Unique Morse Code Words](https://leetcode.com/problems/unique-morse-code-words "唯一摩尔斯密码词") | [Go](../problems/unique-morse-code-words) | Easy | +| 805 | [Split Array With Same Average](https://leetcode.com/problems/split-array-with-same-average "数组的均值分割") | [Go](../problems/split-array-with-same-average) | Hard | +| 806 | [Number of Lines To Write String](https://leetcode.com/problems/number-of-lines-to-write-string "写字符串需要的行数") | [Go](../problems/number-of-lines-to-write-string) | Easy | +| 807 | [Max Increase to Keep City Skyline](https://leetcode.com/problems/max-increase-to-keep-city-skyline "保持城市天际线") | [Go](../problems/max-increase-to-keep-city-skyline) | Medium | +| 808 | [Soup Servings](https://leetcode.com/problems/soup-servings "分汤") | [Go](../problems/soup-servings) | Medium | +| 809 | [Expressive Words](https://leetcode.com/problems/expressive-words "情感丰富的文字") | [Go](../problems/expressive-words) | Medium | +| 810 | [Chalkboard XOR Game](https://leetcode.com/problems/chalkboard-xor-game "黑板异或游戏") | [Go](../problems/chalkboard-xor-game) | Hard | +| 811 | [Subdomain Visit Count](https://leetcode.com/problems/subdomain-visit-count "子域名访问计数") | [Go](../problems/subdomain-visit-count) | Easy | +| 812 | [Largest Triangle Area](https://leetcode.com/problems/largest-triangle-area "最大三角形面积") | [Go](../problems/largest-triangle-area) | Easy | +| 813 | [Largest Sum of Averages](https://leetcode.com/problems/largest-sum-of-averages "最大平均值和的分组") | [Go](../problems/largest-sum-of-averages) | Medium | +| 814 | [Binary Tree Pruning](https://leetcode.com/problems/binary-tree-pruning "二叉树剪枝") | [Go](../problems/binary-tree-pruning) | Medium | +| 815 | [Bus Routes](https://leetcode.com/problems/bus-routes "公交路线") | [Go](../problems/bus-routes) | Hard | +| 816 | [Ambiguous Coordinates](https://leetcode.com/problems/ambiguous-coordinates "模糊坐标") | [Go](../problems/ambiguous-coordinates) | Medium | +| 817 | [Linked List Components](https://leetcode.com/problems/linked-list-components "链表组件") | [Go](../problems/linked-list-components) | Medium | +| 818 | [Race Car](https://leetcode.com/problems/race-car "赛车") | [Go](../problems/race-car) | Hard | +| 819 | [Most Common Word](https://leetcode.com/problems/most-common-word "最常见的单词") | [Go](../problems/most-common-word) | Easy | +| 820 | [Short Encoding of Words](https://leetcode.com/problems/short-encoding-of-words "单词的压缩编码") | [Go](../problems/short-encoding-of-words) | Medium | +| 821 | [Shortest Distance to a Character](https://leetcode.com/problems/shortest-distance-to-a-character "字符的最短距离") | [Go](../problems/shortest-distance-to-a-character) | Easy | +| 822 | [Card Flipping Game](https://leetcode.com/problems/card-flipping-game "翻转卡片游戏") | [Go](../problems/card-flipping-game) | Medium | +| 823 | [Binary Trees With Factors](https://leetcode.com/problems/binary-trees-with-factors "带因子的二叉树") | [Go](../problems/binary-trees-with-factors) | Medium | +| 824 | [Goat Latin](https://leetcode.com/problems/goat-latin "山羊拉丁文") | [Go](../problems/goat-latin) | Easy | +| 825 | [Friends Of Appropriate Ages](https://leetcode.com/problems/friends-of-appropriate-ages "适龄的朋友") | [Go](../problems/friends-of-appropriate-ages) | Medium | +| 826 | [Most Profit Assigning Work](https://leetcode.com/problems/most-profit-assigning-work "安排工作以达到最大收益") | [Go](../problems/most-profit-assigning-work) | Medium | +| 827 | [Making A Large Island](https://leetcode.com/problems/making-a-large-island "最大人工岛") | [Go](../problems/making-a-large-island) | Hard | +| 828 | [Unique Letter String](https://leetcode.com/problems/unique-letter-string "独特字符串") | [Go](../problems/unique-letter-string) | Hard | +| 829 | [Consecutive Numbers Sum](https://leetcode.com/problems/consecutive-numbers-sum "连续整数求和") | [Go](../problems/consecutive-numbers-sum) | Hard | +| 830 | [Positions of Large Groups](https://leetcode.com/problems/positions-of-large-groups "较大分组的位置") | [Go](../problems/positions-of-large-groups) | Easy | +| 831 | [Masking Personal Information](https://leetcode.com/problems/masking-personal-information "隐藏个人信息") | [Go](../problems/masking-personal-information) | Medium | +| 832 | [Flipping an Image](https://leetcode.com/problems/flipping-an-image "翻转图像") | [Go](../problems/flipping-an-image) | Easy | +| 833 | [Find And Replace in String](https://leetcode.com/problems/find-and-replace-in-string "字符串中的查找与替换") | [Go](../problems/find-and-replace-in-string) | Medium | +| 834 | [Sum of Distances in Tree](https://leetcode.com/problems/sum-of-distances-in-tree "树中距离之和") | [Go](../problems/sum-of-distances-in-tree) | Hard | +| 835 | [Image Overlap](https://leetcode.com/problems/image-overlap "图像重叠") | [Go](../problems/image-overlap) | Medium | +| 836 | [Rectangle Overlap](https://leetcode.com/problems/rectangle-overlap "矩形重叠") | [Go](../problems/rectangle-overlap) | Easy | +| 837 | [New 21 Game](https://leetcode.com/problems/new-21-game "新21点") | [Go](../problems/new-21-game) | Medium | +| 838 | [Push Dominoes](https://leetcode.com/problems/push-dominoes "推多米诺") | [Go](../problems/push-dominoes) | Medium | +| 839 | [Similar String Groups](https://leetcode.com/problems/similar-string-groups "相似字符串组") | [Go](../problems/similar-string-groups) | Hard | +| 840 | [Magic Squares In Grid](https://leetcode.com/problems/magic-squares-in-grid "矩阵中的幻方") | [Go](../problems/magic-squares-in-grid) | Easy | +| 841 | [Keys and Rooms](https://leetcode.com/problems/keys-and-rooms "钥匙和房间") | [Go](../problems/keys-and-rooms) | Medium | +| 842 | [Split Array into Fibonacci Sequence](https://leetcode.com/problems/split-array-into-fibonacci-sequence "将数组拆分成斐波那契序列") | [Go](../problems/split-array-into-fibonacci-sequence) | Medium | +| 843 | [Guess the Word](https://leetcode.com/problems/guess-the-word "猜猜这个单词") | [Go](../problems/guess-the-word) | Hard | +| 844 | [Backspace String Compare](https://leetcode.com/problems/backspace-string-compare "比较含退格的字符串") | [Go](../problems/backspace-string-compare) | Easy | +| 845 | [Longest Mountain in Array](https://leetcode.com/problems/longest-mountain-in-array "数组中的最长山脉") | [Go](../problems/longest-mountain-in-array) | Medium | +| 846 | [Hand of Straights](https://leetcode.com/problems/hand-of-straights "一手顺子") | [Go](../problems/hand-of-straights) | Medium | +| 847 | [Shortest Path Visiting All Nodes](https://leetcode.com/problems/shortest-path-visiting-all-nodes "访问所有节点的最短路径") | [Go](../problems/shortest-path-visiting-all-nodes) | Hard | +| 848 | [Shifting Letters](https://leetcode.com/problems/shifting-letters "字母移位") | [Go](../problems/shifting-letters) | Medium | +| 849 | [Maximize Distance to Closest Person](https://leetcode.com/problems/maximize-distance-to-closest-person "到最近的人的最大距离") | [Go](../problems/maximize-distance-to-closest-person) | Easy | +| 850 | [Rectangle Area II](https://leetcode.com/problems/rectangle-area-ii "矩形面积 II") | [Go](../problems/rectangle-area-ii) | Hard | +| 851 | [Loud and Rich](https://leetcode.com/problems/loud-and-rich "喧闹和富有") | [Go](../problems/loud-and-rich) | Medium | +| 852 | [Peak Index in a Mountain Array](https://leetcode.com/problems/peak-index-in-a-mountain-array "山脉数组的峰顶索引") | [Go](../problems/peak-index-in-a-mountain-array) | Easy | +| 853 | [Car Fleet](https://leetcode.com/problems/car-fleet "车队") | [Go](../problems/car-fleet) | Medium | +| 854 | [K-Similar Strings](https://leetcode.com/problems/k-similar-strings "相似度为 K 的字符串") | [Go](../problems/k-similar-strings) | Hard | +| 855 | [Exam Room](https://leetcode.com/problems/exam-room "考场就座") | [Go](../problems/exam-room) | Medium | +| 856 | [Score of Parentheses](https://leetcode.com/problems/score-of-parentheses "括号的分数") | [Go](../problems/score-of-parentheses) | Medium | +| 857 | [Minimum Cost to Hire K Workers](https://leetcode.com/problems/minimum-cost-to-hire-k-workers "雇佣 K 名工人的最低成本") | [Go](../problems/minimum-cost-to-hire-k-workers) | Hard | +| 858 | [Mirror Reflection](https://leetcode.com/problems/mirror-reflection "镜面反射") | [Go](../problems/mirror-reflection) | Medium | +| 859 | [Buddy Strings](https://leetcode.com/problems/buddy-strings "亲密字符串") | [Go](../problems/buddy-strings) | Easy | +| 860 | [Lemonade Change](https://leetcode.com/problems/lemonade-change "柠檬水找零") | [Go](../problems/lemonade-change) | Easy | +| 861 | [Score After Flipping Matrix](https://leetcode.com/problems/score-after-flipping-matrix "翻转矩阵后的得分") | [Go](../problems/score-after-flipping-matrix) | Medium | +| 862 | [Shortest Subarray with Sum at Least K](https://leetcode.com/problems/shortest-subarray-with-sum-at-least-k "和至少为 K 的最短子数组") | [Go](../problems/shortest-subarray-with-sum-at-least-k) | Hard | +| 863 | [All Nodes Distance K in Binary Tree](https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree "二叉树中所有距离为 K 的结点") | [Go](../problems/all-nodes-distance-k-in-binary-tree) | Medium | +| 864 | [Shortest Path to Get All Keys](https://leetcode.com/problems/shortest-path-to-get-all-keys "获取所有钥匙的最短路径") | [Go](../problems/shortest-path-to-get-all-keys) | Hard | +| 865 | [Smallest Subtree with all the Deepest Nodes](https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes "具有所有最深结点的最小子树") | [Go](../problems/smallest-subtree-with-all-the-deepest-nodes) | Medium | +| 866 | [Prime Palindrome](https://leetcode.com/problems/prime-palindrome "回文素数") | [Go](../problems/prime-palindrome) | Medium | +| 867 | [Transpose Matrix](https://leetcode.com/problems/transpose-matrix "转置矩阵") | [Go](../problems/transpose-matrix) | Easy | +| 868 | [Binary Gap](https://leetcode.com/problems/binary-gap "二进制间距") | [Go](../problems/binary-gap) | Easy | +| 869 | [Reordered Power of 2](https://leetcode.com/problems/reordered-power-of-2 "重新排序得到 2 的幂") | [Go](../problems/reordered-power-of-2) | Medium | +| 870 | [Advantage Shuffle](https://leetcode.com/problems/advantage-shuffle "优势洗牌") | [Go](../problems/advantage-shuffle) | Medium | +| 871 | [Minimum Number of Refueling Stops](https://leetcode.com/problems/minimum-number-of-refueling-stops "最低加油次数") | [Go](../problems/minimum-number-of-refueling-stops) | Hard | +| 872 | [Leaf-Similar Trees](https://leetcode.com/problems/leaf-similar-trees "叶子相似的树") | [Go](../problems/leaf-similar-trees) | Easy | +| 873 | [Length of Longest Fibonacci Subsequence](https://leetcode.com/problems/length-of-longest-fibonacci-subsequence "最长的斐波那契子序列的长度") | [Go](../problems/length-of-longest-fibonacci-subsequence) | Medium | +| 874 | [Walking Robot Simulation](https://leetcode.com/problems/walking-robot-simulation "模拟行走机器人") | [Go](../problems/walking-robot-simulation) | Easy | +| 875 | [Koko Eating Bananas](https://leetcode.com/problems/koko-eating-bananas "爱吃香蕉的珂珂") | [Go](../problems/koko-eating-bananas) | Medium | +| 876 | [Middle of the Linked List](https://leetcode.com/problems/middle-of-the-linked-list "链表的中间结点") | [Go](../problems/middle-of-the-linked-list) | Easy | +| 877 | [Stone Game](https://leetcode.com/problems/stone-game "石子游戏") | [Go](../problems/stone-game) | Medium | +| 878 | [Nth Magical Number](https://leetcode.com/problems/nth-magical-number "第 N 个神奇数字") | [Go](../problems/nth-magical-number) | Hard | +| 879 | [Profitable Schemes](https://leetcode.com/problems/profitable-schemes "盈利计划") | [Go](../problems/profitable-schemes) | Hard | +| 880 | [Decoded String at Index](https://leetcode.com/problems/decoded-string-at-index "索引处的解码字符串") | [Go](../problems/decoded-string-at-index) | Medium | +| 881 | [Boats to Save People](https://leetcode.com/problems/boats-to-save-people "救生艇") | [Go](../problems/boats-to-save-people) | Medium | +| 882 | [Reachable Nodes In Subdivided Graph](https://leetcode.com/problems/reachable-nodes-in-subdivided-graph "细分图中的可到达结点") | [Go](../problems/reachable-nodes-in-subdivided-graph) | Hard | +| 883 | [Projection Area of 3D Shapes](https://leetcode.com/problems/projection-area-of-3d-shapes "三维形体投影面积") | [Go](../problems/projection-area-of-3d-shapes) | Easy | +| 884 | [Uncommon Words from Two Sentences](https://leetcode.com/problems/uncommon-words-from-two-sentences "两句话中的不常见单词") | [Go](../problems/uncommon-words-from-two-sentences) | Easy | +| 885 | [Spiral Matrix III](https://leetcode.com/problems/spiral-matrix-iii "螺旋矩阵 III") | [Go](../problems/spiral-matrix-iii) | Medium | +| 886 | [Possible Bipartition](https://leetcode.com/problems/possible-bipartition "可能的二分法") | [Go](../problems/possible-bipartition) | Medium | +| 887 | [Super Egg Drop](https://leetcode.com/problems/super-egg-drop "鸡蛋掉落") | [Go](../problems/super-egg-drop) | Hard | +| 888 | [Fair Candy Swap](https://leetcode.com/problems/fair-candy-swap "公平的糖果交换") | [Go](../problems/fair-candy-swap) | Easy | +| 889 | [Construct Binary Tree from Preorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal "根据前序和后序遍历构造二叉树") | [Go](../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | Medium | +| 890 | [Find and Replace Pattern](https://leetcode.com/problems/find-and-replace-pattern "查找和替换模式") | [Go](../problems/find-and-replace-pattern) | Medium | +| 891 | [Sum of Subsequence Widths](https://leetcode.com/problems/sum-of-subsequence-widths "子序列宽度之和") | [Go](../problems/sum-of-subsequence-widths) | Hard | +| 892 | [Surface Area of 3D Shapes](https://leetcode.com/problems/surface-area-of-3d-shapes "三维形体的表面积") | [Go](../problems/surface-area-of-3d-shapes) | Easy | +| 893 | [Groups of Special-Equivalent Strings](https://leetcode.com/problems/groups-of-special-equivalent-strings "特殊等价字符串组") | [Go](../problems/groups-of-special-equivalent-strings) | Easy | +| 894 | [All Possible Full Binary Trees](https://leetcode.com/problems/all-possible-full-binary-trees "所有可能的满二叉树") | [Go](../problems/all-possible-full-binary-trees) | Medium | +| 895 | [Maximum Frequency Stack](https://leetcode.com/problems/maximum-frequency-stack "最大频率栈") | [Go](../problems/maximum-frequency-stack) | Hard | +| 896 | [Monotonic Array](https://leetcode.com/problems/monotonic-array "单调数列") | [Go](../problems/monotonic-array) | Easy | +| 897 | [Increasing Order Search Tree](https://leetcode.com/problems/increasing-order-search-tree "递增顺序查找树") | [Go](../problems/increasing-order-search-tree) | Easy | +| 898 | [Bitwise ORs of Subarrays](https://leetcode.com/problems/bitwise-ors-of-subarrays "子数组按位或操作") | [Go](../problems/bitwise-ors-of-subarrays) | Medium | +| 899 | [Orderly Queue](https://leetcode.com/problems/orderly-queue "有序队列") | [Go](../problems/orderly-queue) | Hard | +| 900 | [RLE Iterator](https://leetcode.com/problems/rle-iterator "RLE 迭代器") | [Go](../problems/rle-iterator) | Medium | From 8cde692bbb805c0ae60d9d3908340e910a66ae0e Mon Sep 17 00:00:00 2001 From: openset Date: Wed, 18 Dec 2019 10:28:34 +0800 Subject: [PATCH 013/145] Update: linkStr --- internal/readme/readme.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/readme/readme.go b/internal/readme/readme.go index 621d30755..22a466b11 100644 --- a/internal/readme/readme.go +++ b/internal/readme/readme.go @@ -101,9 +101,7 @@ func writeNav(buf *bytes.Buffer) { func linkStr(num int) string { link := "https://github.com/openset/leetcode/blob/master/" if num > maxID-maxID%pageSize-pageSize { - link += fmt.Sprintf("README.md#%d", num) - } else { - link += fmt.Sprintf("readme/%d-%d.md#%d", (num-1)/pageSize*pageSize+1, ((num-1)/pageSize+1)*pageSize, num-step+1) + return fmt.Sprintf("%sREADME.md#%d", link, num) } - return link + return fmt.Sprintf("%sreadme/%d-%d.md#%d", link, (num-1)/pageSize*pageSize+1, ((num-1)/pageSize+1)*pageSize, num-step+1) } From cabf52031c6bcac17d04c67658f647c91a408c7b Mon Sep 17 00:00:00 2001 From: openset Date: Wed, 18 Dec 2019 11:17:10 +0800 Subject: [PATCH 014/145] Update: relative path --- README.md | 60 +-- internal/base/base.go | 5 +- internal/leetcode/question_data.go | 6 +- internal/leetcode/topic_tag.go | 6 +- internal/open/open.go | 3 +- internal/post/post.go | 6 +- internal/readme/readme.go | 5 +- internal/tag/tag.go | 2 +- problems/01-matrix/README.md | 8 +- problems/1-bit-and-2-bit-characters/README.md | 8 +- problems/132-pattern/README.md | 6 +- problems/2-keys-keyboard/README.md | 10 +- problems/24-game/README.md | 6 +- problems/3sum-closest/README.md | 12 +- problems/3sum-smaller/README.md | 16 +- problems/3sum-with-multiplicity/README.md | 6 +- problems/3sum/README.md | 16 +- problems/4-keys-keyboard/README.md | 12 +- problems/4sum-ii/README.md | 10 +- problems/4sum/README.md | 16 +- problems/accounts-merge/README.md | 14 +- problems/active-businesses/README.md | 4 +- .../README.md | 4 +- .../README.md | 14 +- problems/add-binary/README.md | 16 +- problems/add-bold-tag-in-string/README.md | 10 +- problems/add-digits/README.md | 10 +- problems/add-one-row-to-tree/README.md | 6 +- problems/add-strings/README.md | 12 +- .../add-to-array-form-of-integer/README.md | 14 +- problems/add-two-numbers-ii/README.md | 8 +- problems/add-two-numbers/README.md | 20 +- .../adding-two-negabinary-numbers/README.md | 6 +- problems/additive-number/README.md | 8 +- problems/advantage-shuffle/README.md | 8 +- .../README.md | 10 +- problems/alien-dictionary/README.md | 10 +- .../README.md | 10 +- problems/all-oone-data-structure/README.md | 6 +- .../README.md | 8 +- .../all-paths-from-source-to-target/README.md | 4 +- .../README.md | 4 +- .../all-possible-full-binary-trees/README.md | 8 +- problems/alphabet-board-path/README.md | 8 +- problems/ambiguous-coordinates/README.md | 6 +- .../README.md | 10 +- problems/android-unlock-patterns/README.md | 8 +- .../README.md | 8 +- problems/arithmetic-slices/README.md | 10 +- problems/armstrong-number/README.md | 6 +- problems/arranging-coins/README.md | 8 +- problems/array-nesting/README.md | 12 +- problems/array-of-doubled-pairs/README.md | 8 +- problems/array-partition-i/README.md | 6 +- problems/array-transformation/README.md | 6 +- problems/article-views-i/README.md | 4 +- problems/article-views-ii/README.md | 4 +- .../as-far-from-land-as-possible/README.md | 10 +- problems/assign-cookies/README.md | 6 +- problems/asteroid-collision/README.md | 8 +- .../available-captures-for-rook/README.md | 6 +- .../README.md | 10 +- .../README.md | 4 +- problems/average-selling-price/README.md | 4 +- problems/backspace-string-compare/README.md | 8 +- problems/bag-of-tokens/README.md | 6 +- problems/balanced-binary-tree/README.md | 10 +- problems/base-7/README.md | 4 +- problems/baseball-game/README.md | 6 +- problems/basic-calculator-ii/README.md | 12 +- problems/basic-calculator-iii/README.md | 14 +- problems/basic-calculator-iv/README.md | 14 +- problems/basic-calculator/README.md | 18 +- problems/battleships-in-a-board/README.md | 4 +- problems/beautiful-arrangement-ii/README.md | 8 +- problems/beautiful-arrangement/README.md | 8 +- problems/beautiful-array/README.md | 6 +- problems/before-and-after-puzzle/README.md | 6 +- problems/best-meeting-point/README.md | 12 +- problems/best-sightseeing-pair/README.md | 6 +- .../README.md | 18 +- .../README.md | 16 +- .../README.md | 12 +- .../README.md | 10 +- .../README.md | 12 +- .../best-time-to-buy-and-sell-stock/README.md | 18 +- problems/big-countries/README.md | 4 +- problems/biggest-single-number/README.md | 4 +- problems/binary-gap/README.md | 6 +- .../README.md | 8 +- .../binary-prefix-divisible-by-5/README.md | 6 +- .../binary-search-tree-iterator/README.md | 20 +- .../README.md | 6 +- problems/binary-search/README.md | 8 +- .../README.md | 6 +- problems/binary-subarrays-with-sum/README.md | 8 +- problems/binary-tree-cameras/README.md | 12 +- problems/binary-tree-coloring-game/README.md | 8 +- .../binary-tree-inorder-traversal/README.md | 28 +- .../README.md | 12 +- .../README.md | 22 +- .../README.md | 8 +- .../README.md | 10 +- .../binary-tree-maximum-path-sum/README.md | 16 +- problems/binary-tree-paths/README.md | 12 +- .../binary-tree-postorder-traversal/README.md | 12 +- .../binary-tree-preorder-traversal/README.md | 14 +- problems/binary-tree-pruning/README.md | 6 +- .../binary-tree-right-side-view/README.md | 14 +- problems/binary-tree-tilt/README.md | 6 +- problems/binary-tree-upside-down/README.md | 8 +- .../README.md | 8 +- .../README.md | 12 +- problems/binary-trees-with-factors/README.md | 4 +- problems/binary-watch/README.md | 12 +- .../bitwise-and-of-numbers-range/README.md | 6 +- problems/bitwise-ors-of-subarrays/README.md | 8 +- problems/boats-to-save-people/README.md | 8 +- problems/bold-words-in-string/README.md | 6 +- problems/bomb-enemy/README.md | 6 +- problems/boundary-of-binary-tree/README.md | 8 +- problems/brace-expansion-ii/README.md | 8 +- problems/brace-expansion/README.md | 12 +- problems/brick-wall/README.md | 6 +- problems/bricks-falling-when-hit/README.md | 6 +- problems/broken-calculator/README.md | 10 +- problems/buddy-strings/README.md | 6 +- problems/building-h2o/README.md | 4 +- problems/bulb-switcher-ii/README.md | 8 +- problems/bulb-switcher/README.md | 12 +- problems/bulls-and-cows/README.md | 6 +- problems/burst-balloons/README.md | 10 +- problems/bus-routes/README.md | 6 +- problems/camelcase-matching/README.md | 8 +- problems/campus-bikes-ii/README.md | 10 +- problems/campus-bikes/README.md | 10 +- problems/can-i-win/README.md | 14 +- .../README.md | 8 +- problems/can-place-flowers/README.md | 10 +- problems/candy-crush/README.md | 8 +- problems/candy/README.md | 6 +- .../README.md | 8 +- problems/car-fleet/README.md | 6 +- problems/car-pooling/README.md | 8 +- problems/card-flipping-game/README.md | 4 +- problems/cat-and-mouse/README.md | 8 +- .../README.md | 6 +- problems/chalkboard-xor-game/README.md | 6 +- problems/champagne-tower/README.md | 4 +- .../cheapest-flights-within-k-stops/README.md | 12 +- .../README.md | 6 +- .../README.md | 12 +- .../check-if-it-is-a-good-array/README.md | 6 +- .../check-if-it-is-a-straight-line/README.md | 10 +- .../README.md | 10 +- problems/cherry-pickup/README.md | 10 +- problems/circular-array-loop/README.md | 8 +- .../README.md | 6 +- .../classes-more-than-5-students/README.md | 4 +- problems/climbing-stairs/README.md | 12 +- problems/clone-graph/README.md | 12 +- .../README.md | 12 +- .../README.md | 14 +- .../closest-leaf-in-a-binary-tree/README.md | 6 +- problems/clumsy-factorial/README.md | 6 +- problems/coin-change-2/README.md | 4 +- problems/coin-change/README.md | 8 +- problems/coin-path/README.md | 10 +- problems/coloring-a-border/README.md | 8 +- problems/combination-sum-ii/README.md | 10 +- problems/combination-sum-iii/README.md | 10 +- problems/combination-sum-iv/README.md | 8 +- problems/combination-sum/README.md | 20 +- problems/combinations/README.md | 10 +- problems/combine-two-tables/README.md | 6 +- .../README.md | 8 +- problems/compare-version-numbers/README.md | 6 +- .../complement-of-base-10-integer/README.md | 6 +- .../complete-binary-tree-inserter/README.md | 6 +- .../complex-number-multiplication/README.md | 8 +- problems/concatenated-words/README.md | 12 +- problems/confusing-number-ii/README.md | 10 +- problems/confusing-number/README.md | 10 +- .../README.md | 8 +- .../consecutive-available-seats/README.md | 4 +- problems/consecutive-numbers-sum/README.md | 6 +- problems/consecutive-numbers/README.md | 4 +- .../README.md | 6 +- .../README.md | 12 +- .../README.md | 12 +- .../README.md | 6 +- .../README.md | 10 +- problems/construct-quad-tree/README.md | 4 +- .../README.md | 12 +- problems/construct-the-rectangle/README.md | 4 +- problems/contain-virus/README.md | 6 +- problems/container-with-most-water/README.md | 10 +- problems/contains-duplicate-ii/README.md | 12 +- problems/contains-duplicate-iii/README.md | 12 +- problems/contains-duplicate/README.md | 12 +- problems/contiguous-array/README.md | 8 +- problems/continuous-subarray-sum/README.md | 10 +- .../convert-a-number-to-hexadecimal/README.md | 6 +- .../README.md | 8 +- .../README.md | 12 +- .../convert-bst-to-greater-tree/README.md | 6 +- .../README.md | 10 +- .../README.md | 10 +- problems/convert-to-base-2/README.md | 8 +- problems/convex-polygon/README.md | 6 +- .../copy-list-with-random-pointer/README.md | 10 +- problems/corporate-flight-bookings/README.md | 8 +- problems/count-and-say/README.md | 10 +- problems/count-binary-substrings/README.md | 8 +- problems/count-complete-tree-nodes/README.md | 10 +- .../README.md | 10 +- .../count-number-of-nice-subarrays/README.md | 6 +- .../README.md | 10 +- problems/count-of-range-sum/README.md | 18 +- .../README.md | 20 +- problems/count-primes/README.md | 14 +- .../count-servers-that-communicate/README.md | 8 +- .../README.md | 8 +- .../README.md | 4 +- .../README.md | 8 +- problems/count-the-repetitions/README.md | 6 +- problems/count-univalue-subtrees/README.md | 10 +- problems/count-vowels-permutation/README.md | 6 +- problems/counting-bits/README.md | 10 +- problems/couples-holding-hands/README.md | 16 +- problems/course-schedule-ii/README.md | 22 +- problems/course-schedule-iii/README.md | 10 +- problems/course-schedule/README.md | 20 +- problems/cousins-in-binary-tree/README.md | 10 +- problems/cracking-the-safe/README.md | 8 +- problems/create-maximum-number/README.md | 12 +- .../README.md | 6 +- problems/custom-sort-string/README.md | 6 +- .../README.md | 4 +- .../README.md | 4 +- problems/customers-who-never-order/README.md | 4 +- .../cut-off-trees-for-golf-event/README.md | 6 +- problems/daily-temperatures/README.md | 10 +- .../README.md | 14 +- problems/day-of-the-week/README.md | 6 +- problems/day-of-the-year/README.md | 6 +- problems/decode-string/README.md | 14 +- problems/decode-ways-ii/README.md | 8 +- problems/decode-ways/README.md | 10 +- problems/decoded-string-at-index/README.md | 6 +- .../README.md | 6 +- problems/defanging-an-ip-address/README.md | 6 +- problems/degree-of-an-array/README.md | 8 +- problems/delete-and-earn/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../delete-columns-to-make-sorted/README.md | 6 +- problems/delete-duplicate-emails/README.md | 4 +- problems/delete-node-in-a-bst/README.md | 8 +- .../delete-node-in-a-linked-list/README.md | 8 +- .../delete-nodes-and-return-forest/README.md | 8 +- .../README.md | 10 +- problems/delete-tree-nodes/README.md | 8 +- problems/department-highest-salary/README.md | 4 +- .../department-top-three-salaries/README.md | 4 +- problems/design-a-leaderboard/README.md | 10 +- .../design-bounded-blocking-queue/README.md | 4 +- problems/design-circular-deque/README.md | 10 +- problems/design-circular-queue/README.md | 10 +- .../README.md | 10 +- problems/design-excel-sum-formula/README.md | 6 +- problems/design-file-system/README.md | 8 +- problems/design-hashmap/README.md | 10 +- problems/design-hashset/README.md | 10 +- problems/design-hit-counter/README.md | 8 +- .../design-in-memory-file-system/README.md | 12 +- problems/design-linked-list/README.md | 8 +- problems/design-log-storage-system/README.md | 10 +- problems/design-phone-directory/README.md | 8 +- .../README.md | 10 +- problems/design-skiplist/README.md | 6 +- problems/design-snake-game/README.md | 8 +- problems/design-tic-tac-toe/README.md | 8 +- problems/design-twitter/README.md | 10 +- problems/detect-capital/README.md | 6 +- problems/di-string-match/README.md | 6 +- problems/diagonal-traverse/README.md | 4 +- problems/diameter-of-binary-tree/README.md | 6 +- problems/dice-roll-simulation/README.md | 6 +- problems/diet-plan-performance/README.md | 8 +- .../README.md | 12 +- problems/digit-count-in-range/README.md | 10 +- problems/dinner-plate-stacks/README.md | 6 +- problems/distance-between-bus-stops/README.md | 6 +- problems/distant-barcodes/README.md | 8 +- problems/distinct-subsequences-ii/README.md | 6 +- problems/distinct-subsequences/README.md | 8 +- .../distribute-candies-to-people/README.md | 6 +- problems/distribute-candies/README.md | 6 +- .../distribute-coins-in-binary-tree/README.md | 12 +- .../README.md | 6 +- problems/divide-chocolate/README.md | 8 +- problems/divide-two-integers/README.md | 8 +- problems/divisor-game/README.md | 8 +- problems/domino-and-tromino-tiling/README.md | 6 +- problems/dota2-senate/README.md | 8 +- problems/dungeon-game/README.md | 14 +- problems/duplicate-emails/README.md | 4 +- problems/duplicate-zeros/README.md | 6 +- problems/edit-distance/README.md | 16 +- .../README.md | 6 +- problems/elimination-game/README.md | 4 +- problems/employee-bonus/README.md | 6 +- problems/employee-free-time/README.md | 12 +- problems/employee-importance/README.md | 12 +- .../README.md | 4 +- problems/encode-and-decode-strings/README.md | 14 +- problems/encode-and-decode-tinyurl/README.md | 8 +- .../README.md | 8 +- problems/encode-number/README.md | 10 +- .../README.md | 10 +- problems/equal-rational-numbers/README.md | 6 +- problems/equal-tree-partition/README.md | 6 +- problems/erect-the-fence/README.md | 6 +- problems/escape-a-large-maze/README.md | 6 +- problems/escape-the-ghosts/README.md | 6 +- problems/evaluate-division/README.md | 8 +- .../README.md | 10 +- problems/exam-room/README.md | 8 +- problems/excel-sheet-column-number/README.md | 8 +- problems/excel-sheet-column-title/README.md | 8 +- problems/exchange-seats/README.md | 4 +- .../exclusive-time-of-functions/README.md | 6 +- problems/expression-add-operators/README.md | 16 +- problems/expressive-words/README.md | 6 +- problems/factor-combinations/README.md | 8 +- problems/factorial-trailing-zeroes/README.md | 10 +- problems/fair-candy-swap/README.md | 6 +- problems/falling-squares/README.md | 10 +- problems/fibonacci-number/README.md | 12 +- problems/filling-bookcase-shelves/README.md | 6 +- .../find-all-anagrams-in-a-string/README.md | 10 +- .../find-all-duplicates-in-an-array/README.md | 8 +- .../README.md | 10 +- problems/find-anagram-mappings/README.md | 6 +- problems/find-and-replace-in-string/README.md | 6 +- problems/find-and-replace-pattern/README.md | 6 +- .../find-bottom-left-tree-value/README.md | 10 +- problems/find-common-characters/README.md | 10 +- .../README.md | 4 +- problems/find-customer-referee/README.md | 4 +- .../find-duplicate-file-in-system/README.md | 8 +- problems/find-duplicate-subtrees/README.md | 12 +- .../README.md | 8 +- problems/find-eventual-safe-states/README.md | 8 +- .../README.md | 10 +- problems/find-in-mountain-array/README.md | 6 +- problems/find-k-closest-elements/README.md | 12 +- .../README.md | 8 +- .../find-k-pairs-with-smallest-sums/README.md | 10 +- .../README.md | 20 +- .../README.md | 10 +- problems/find-leaves-of-binary-tree/README.md | 8 +- .../find-median-from-data-stream/README.md | 10 +- .../README.md | 6 +- .../README.md | 10 +- .../README.md | 12 +- .../find-mode-in-binary-search-tree/README.md | 8 +- problems/find-peak-element/README.md | 10 +- problems/find-permutation/README.md | 6 +- problems/find-pivot-index/README.md | 8 +- .../README.md | 8 +- problems/find-right-interval/README.md | 8 +- .../README.md | 8 +- .../README.md | 6 +- problems/find-the-celebrity/README.md | 8 +- .../find-the-closest-palindrome/README.md | 6 +- .../README.md | 6 +- problems/find-the-difference/README.md | 10 +- problems/find-the-duplicate-number/README.md | 20 +- .../find-the-shortest-superstring/README.md | 6 +- .../README.md | 6 +- .../README.md | 4 +- problems/find-the-town-judge/README.md | 8 +- .../README.md | 6 +- .../README.md | 8 +- problems/first-bad-version/README.md | 12 +- problems/first-missing-positive/README.md | 14 +- .../README.md | 10 +- problems/fixed-point/README.md | 8 +- problems/fizz-buzz-multithreaded/README.md | 4 +- problems/fizz-buzz/README.md | 4 +- problems/flatten-2d-vector/README.md | 14 +- .../README.md | 10 +- .../README.md | 10 +- .../flatten-nested-list-iterator/README.md | 16 +- .../README.md | 8 +- .../README.md | 6 +- .../flip-equivalent-binary-trees/README.md | 6 +- problems/flip-game-ii/README.md | 16 +- problems/flip-game/README.md | 8 +- .../README.md | 6 +- problems/flipping-an-image/README.md | 6 +- problems/flood-fill/README.md | 8 +- .../README.md | 6 +- .../README.md | 8 +- .../fraction-to-recurring-decimal/README.md | 8 +- problems/freedom-trail/README.md | 10 +- problems/friend-circles/README.md | 18 +- .../README.md | 4 +- .../README.md | 4 +- .../friends-of-appropriate-ages/README.md | 6 +- problems/frog-jump/README.md | 6 +- problems/fruit-into-baskets/README.md | 6 +- problems/game-of-life/README.md | 8 +- problems/game-play-analysis-i/README.md | 6 +- problems/game-play-analysis-ii/README.md | 8 +- problems/game-play-analysis-iii/README.md | 8 +- problems/game-play-analysis-iv/README.md | 8 +- problems/game-play-analysis-v/README.md | 6 +- problems/gas-station/README.md | 6 +- problems/generalized-abbreviation/README.md | 14 +- problems/generate-parentheses/README.md | 12 +- .../README.md | 12 +- .../README.md | 8 +- .../README.md | 4 +- .../global-and-local-inversions/README.md | 8 +- problems/goat-latin/README.md | 6 +- problems/graph-valid-tree/README.md | 16 +- problems/gray-code/README.md | 8 +- .../README.md | 6 +- .../greatest-sum-divisible-by-three/README.md | 6 +- problems/grid-illumination/README.md | 8 +- problems/group-anagrams/README.md | 12 +- problems/group-shifted-strings/README.md | 10 +- .../README.md | 6 +- .../README.md | 6 +- problems/grumpy-bookstore-owner/README.md | 8 +- .../guess-number-higher-or-lower-ii/README.md | 16 +- .../guess-number-higher-or-lower/README.md | 12 +- problems/guess-the-word/README.md | 6 +- problems/h-index-ii/README.md | 8 +- problems/h-index/README.md | 10 +- problems/hamming-distance/README.md | 10 +- problems/hand-of-straights/README.md | 6 +- problems/handshakes-that-dont-cross/README.md | 8 +- problems/happy-number/README.md | 14 +- problems/heaters/README.md | 6 +- problems/height-checker/README.md | 6 +- problems/hexspeak/README.md | 8 +- problems/high-five/README.md | 10 +- .../highest-grade-for-each-student/README.md | 4 +- problems/house-robber-ii/README.md | 18 +- problems/house-robber-iii/README.md | 12 +- problems/house-robber/README.md | 22 +- .../README.md | 6 +- problems/human-traffic-of-stadium/README.md | 4 +- problems/image-overlap/README.md | 6 +- problems/image-smoother/README.md | 6 +- problems/immediate-food-delivery-i/README.md | 4 +- problems/immediate-food-delivery-ii/README.md | 4 +- problems/implement-magic-dictionary/README.md | 12 +- .../implement-queue-using-stacks/README.md | 10 +- .../implement-rand10-using-rand7/README.md | 8 +- .../implement-stack-using-queues/README.md | 10 +- problems/implement-strstr/README.md | 12 +- problems/implement-trie-prefix-tree/README.md | 16 +- .../increasing-order-search-tree/README.md | 8 +- problems/increasing-subsequences/README.md | 8 +- .../increasing-triplet-subsequence/README.md | 6 +- problems/index-pairs-of-a-string/README.md | 8 +- .../inorder-successor-in-bst-ii/README.md | 8 +- problems/inorder-successor-in-bst/README.md | 12 +- .../README.md | 12 +- problems/insert-delete-getrandom-o1/README.md | 12 +- problems/insert-interval/README.md | 12 +- .../README.md | 8 +- .../README.md | 8 +- problems/insertion-sort-list/README.md | 12 +- .../README.md | 6 +- problems/integer-break/README.md | 8 +- problems/integer-replacement/README.md | 8 +- problems/integer-to-english-words/README.md | 10 +- problems/integer-to-roman/README.md | 12 +- problems/interleaving-string/README.md | 8 +- .../README.md | 10 +- .../intersection-of-two-arrays-ii/README.md | 16 +- problems/intersection-of-two-arrays/README.md | 16 +- .../README.md | 8 +- .../interval-list-intersections/README.md | 12 +- problems/invalid-transactions/README.md | 8 +- problems/invert-binary-tree/README.md | 6 +- problems/investments-in-2016/README.md | 4 +- problems/ip-to-cidr/README.md | 10 +- problems/ipo/README.md | 8 +- problems/is-graph-bipartite/README.md | 10 +- problems/is-subsequence/README.md | 14 +- problems/island-perimeter/README.md | 12 +- problems/isomorphic-strings/README.md | 8 +- problems/iterator-for-combination/README.md | 8 +- problems/jewels-and-stones/README.md | 6 +- problems/jump-game-ii/README.md | 10 +- problems/jump-game/README.md | 10 +- problems/k-closest-points-to-origin/README.md | 16 +- .../k-concatenation-maximum-sum/README.md | 6 +- problems/k-diff-pairs-in-an-array/README.md | 10 +- problems/k-empty-slots/README.md | 6 +- problems/k-inverse-pairs-array/README.md | 6 +- problems/k-similar-strings/README.md | 10 +- .../README.md | 4 +- .../k-th-smallest-prime-fraction/README.md | 14 +- problems/k-th-symbol-in-grammar/README.md | 6 +- problems/keyboard-row/README.md | 6 +- problems/keys-and-rooms/README.md | 8 +- problems/kill-process/README.md | 8 +- problems/knight-dialer/README.md | 6 +- .../README.md | 8 +- problems/koko-eating-bananas/README.md | 8 +- .../kth-largest-element-in-a-stream/README.md | 8 +- .../kth-largest-element-in-an-array/README.md | 18 +- .../kth-smallest-element-in-a-bst/README.md | 12 +- .../README.md | 16 +- .../README.md | 12 +- problems/largest-1-bordered-square/README.md | 6 +- problems/largest-bst-subtree/README.md | 6 +- .../README.md | 8 +- problems/largest-divisible-subset/README.md | 8 +- .../README.md | 6 +- problems/largest-number/README.md | 6 +- problems/largest-palindrome-product/README.md | 4 +- problems/largest-perimeter-triangle/README.md | 10 +- problems/largest-plus-sign/README.md | 8 +- .../largest-rectangle-in-histogram/README.md | 10 +- problems/largest-sum-of-averages/README.md | 6 +- .../largest-time-for-given-digits/README.md | 6 +- problems/largest-triangle-area/README.md | 8 +- problems/largest-unique-number/README.md | 8 +- problems/largest-values-from-labels/README.md | 8 +- .../README.md | 4 +- problems/last-stone-weight-ii/README.md | 6 +- problems/last-stone-weight/README.md | 8 +- .../README.md | 6 +- problems/leaf-similar-trees/README.md | 8 +- .../README.md | 8 +- problems/lemonade-change/README.md | 6 +- problems/length-of-last-word/README.md | 6 +- .../README.md | 10 +- problems/letter-case-permutation/README.md | 12 +- .../README.md | 14 +- problems/letter-tile-possibilities/README.md | 6 +- problems/lexicographical-numbers/README.md | 4 +- .../README.md | 8 +- problems/lfu-cache/README.md | 10 +- problems/license-key-formatting/README.md | 4 +- problems/line-reflection/README.md | 12 +- problems/linked-list-components/README.md | 6 +- problems/linked-list-cycle-ii/README.md | 12 +- problems/linked-list-cycle/README.md | 12 +- problems/linked-list-random-node/README.md | 8 +- problems/logger-rate-limiter/README.md | 10 +- problems/lonely-pixel-i/README.md | 10 +- problems/lonely-pixel-ii/README.md | 10 +- problems/long-pressed-name/README.md | 8 +- problems/longest-absolute-file-path/README.md | 4 +- .../longest-arithmetic-sequence/README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- problems/longest-common-prefix/README.md | 6 +- problems/longest-common-subsequence/README.md | 6 +- .../longest-consecutive-sequence/README.md | 10 +- .../README.md | 10 +- .../longest-duplicate-substring/README.md | 8 +- .../longest-harmonious-subsequence/README.md | 6 +- .../README.md | 10 +- .../longest-increasing-subsequence/README.md | 18 +- .../README.md | 6 +- problems/longest-mountain-in-array/README.md | 6 +- problems/longest-palindrome/README.md | 8 +- .../longest-palindromic-subsequence/README.md | 12 +- .../longest-palindromic-substring/README.md | 18 +- .../README.md | 12 +- .../longest-repeating-substring/README.md | 6 +- problems/longest-string-chain/README.md | 8 +- .../README.md | 4 +- .../README.md | 20 +- .../README.md | 20 +- .../README.md | 18 +- problems/longest-turbulent-subarray/README.md | 12 +- .../longest-uncommon-subsequence-i/README.md | 8 +- .../longest-uncommon-subsequence-ii/README.md | 8 +- problems/longest-univalue-path/README.md | 14 +- problems/longest-valid-parentheses/README.md | 10 +- .../README.md | 6 +- .../README.md | 10 +- problems/longest-word-in-dictionary/README.md | 12 +- problems/loud-and-rich/README.md | 6 +- .../README.md | 10 +- .../README.md | 10 +- .../README.md | 8 +- problems/lru-cache/README.md | 12 +- problems/magic-squares-in-grid/README.md | 6 +- problems/magical-string/README.md | 4 +- problems/majority-element-ii/README.md | 10 +- problems/majority-element/README.md | 14 +- .../make-array-strictly-increasing/README.md | 6 +- problems/making-a-large-island/README.md | 6 +- .../README.md | 4 +- problems/map-sum-pairs/README.md | 6 +- problems/market-analysis-i/README.md | 4 +- problems/market-analysis-ii/README.md | 4 +- .../masking-personal-information/README.md | 6 +- problems/matchsticks-to-square/README.md | 6 +- .../matrix-cells-in-distance-order/README.md | 6 +- problems/max-area-of-island/README.md | 12 +- .../max-chunks-to-make-sorted-ii/README.md | 8 +- problems/max-chunks-to-make-sorted/README.md | 8 +- problems/max-consecutive-ones-ii/README.md | 10 +- problems/max-consecutive-ones-iii/README.md | 16 +- problems/max-consecutive-ones/README.md | 10 +- .../README.md | 4 +- problems/max-points-on-a-line/README.md | 10 +- problems/max-stack/README.md | 8 +- .../README.md | 10 +- problems/maximal-rectangle/README.md | 16 +- problems/maximal-square/README.md | 10 +- .../README.md | 8 +- .../README.md | 6 +- problems/maximum-average-subarray-i/README.md | 8 +- .../maximum-average-subarray-ii/README.md | 10 +- problems/maximum-average-subtree/README.md | 6 +- problems/maximum-binary-tree-ii/README.md | 8 +- problems/maximum-binary-tree/README.md | 8 +- .../maximum-depth-of-binary-tree/README.md | 14 +- .../maximum-depth-of-n-ary-tree/README.md | 12 +- .../README.md | 8 +- problems/maximum-distance-in-arrays/README.md | 8 +- problems/maximum-equal-frequency/README.md | 6 +- problems/maximum-frequency-stack/README.md | 8 +- problems/maximum-gap/README.md | 6 +- .../README.md | 8 +- .../maximum-length-of-pair-chain/README.md | 10 +- .../README.md | 14 +- .../README.md | 6 +- .../README.md | 8 +- problems/maximum-number-of-balloons/README.md | 8 +- problems/maximum-number-of-ones/README.md | 8 +- .../README.md | 8 +- .../README.md | 10 +- .../maximum-product-of-word-lengths/README.md | 6 +- problems/maximum-product-subarray/README.md | 18 +- .../README.md | 10 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 14 +- .../README.md | 6 +- problems/maximum-subarray/README.md | 18 +- .../maximum-sum-circular-subarray/README.md | 6 +- .../README.md | 10 +- .../README.md | 6 +- problems/maximum-swap/README.md | 10 +- problems/maximum-vacation-days/README.md | 8 +- .../maximum-width-of-binary-tree/README.md | 6 +- problems/maximum-width-ramp/README.md | 6 +- .../README.md | 8 +- problems/median-employee-salary/README.md | 6 +- .../median-of-two-sorted-arrays/README.md | 10 +- problems/meeting-rooms-ii/README.md | 18 +- problems/meeting-rooms/README.md | 10 +- problems/meeting-scheduler/README.md | 6 +- problems/merge-intervals/README.md | 26 +- problems/merge-k-sorted-lists/README.md | 14 +- problems/merge-sorted-array/README.md | 14 +- problems/merge-two-binary-trees/README.md | 6 +- problems/merge-two-sorted-lists/README.md | 14 +- problems/middle-of-the-linked-list/README.md | 6 +- problems/min-cost-climbing-stairs/README.md | 10 +- problems/min-stack/README.md | 12 +- problems/minesweeper/README.md | 8 +- problems/mini-parser/README.md | 14 +- problems/minimize-malware-spread-ii/README.md | 10 +- problems/minimize-malware-spread/README.md | 8 +- .../README.md | 8 +- .../README.md | 10 +- .../README.md | 8 +- .../minimum-absolute-difference/README.md | 6 +- .../README.md | 8 +- problems/minimum-area-rectangle-ii/README.md | 8 +- problems/minimum-area-rectangle/README.md | 6 +- .../README.md | 12 +- problems/minimum-cost-for-tickets/README.md | 8 +- .../minimum-cost-to-connect-sticks/README.md | 8 +- .../minimum-cost-to-hire-k-workers/README.md | 6 +- .../minimum-cost-to-merge-stones/README.md | 10 +- .../README.md | 10 +- .../minimum-depth-of-binary-tree/README.md | 14 +- .../README.md | 10 +- .../README.md | 8 +- problems/minimum-factorization/README.md | 8 +- .../minimum-falling-path-sum-ii/README.md | 6 +- problems/minimum-falling-path-sum/README.md | 6 +- problems/minimum-genetic-mutation/README.md | 6 +- problems/minimum-height-trees/README.md | 12 +- .../README.md | 6 +- .../minimum-index-sum-of-two-lists/README.md | 8 +- problems/minimum-knight-moves/README.md | 6 +- .../README.md | 10 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 10 +- .../README.md | 6 +- .../README.md | 10 +- .../README.md | 8 +- problems/minimum-path-sum/README.md | 14 +- .../README.md | 8 +- .../README.md | 6 +- problems/minimum-size-subarray-sum/README.md | 16 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 8 +- problems/minimum-time-difference/README.md | 6 +- .../minimum-time-to-build-blocks/README.md | 8 +- .../README.md | 8 +- .../README.md | 14 +- problems/minimum-window-subsequence/README.md | 12 +- problems/minimum-window-substring/README.md | 22 +- problems/mirror-reflection/README.md | 6 +- .../missing-element-in-sorted-array/README.md | 6 +- .../README.md | 6 +- problems/missing-number/README.md | 18 +- problems/missing-ranges/README.md | 8 +- problems/monotone-increasing-digits/README.md | 8 +- problems/monotonic-array/README.md | 6 +- problems/monthly-transactions-i/README.md | 4 +- problems/monthly-transactions-ii/README.md | 4 +- problems/most-common-word/README.md | 6 +- problems/most-frequent-subtree-sum/README.md | 10 +- problems/most-profit-assigning-work/README.md | 6 +- .../README.md | 8 +- problems/move-zeroes/README.md | 10 +- .../moving-average-from-data-stream/README.md | 8 +- .../README.md | 8 +- .../moving-stones-until-consecutive/README.md | 6 +- problems/multiply-strings/README.md | 16 +- problems/my-calendar-i/README.md | 10 +- problems/my-calendar-ii/README.md | 10 +- problems/my-calendar-iii/README.md | 12 +- .../README.md | 14 +- .../n-ary-tree-postorder-traversal/README.md | 12 +- .../n-ary-tree-preorder-traversal/README.md | 12 +- problems/n-queens-ii/README.md | 8 +- problems/n-queens/README.md | 10 +- .../README.md | 6 +- problems/n-th-tribonacci-number/README.md | 8 +- problems/nested-list-weight-sum-ii/README.md | 10 +- problems/nested-list-weight-sum/README.md | 12 +- problems/network-delay-time/README.md | 12 +- problems/new-21-game/README.md | 6 +- problems/new-users-daily-count/README.md | 4 +- problems/next-closest-time/README.md | 6 +- problems/next-greater-element-i/README.md | 12 +- problems/next-greater-element-ii/README.md | 10 +- problems/next-greater-element-iii/README.md | 10 +- .../README.md | 8 +- problems/next-permutation/README.md | 14 +- problems/nim-game/README.md | 10 +- problems/non-decreasing-array/README.md | 6 +- .../README.md | 12 +- problems/non-overlapping-intervals/README.md | 8 +- problems/not-boring-movies/README.md | 4 +- problems/nth-digit/README.md | 6 +- problems/nth-highest-salary/README.md | 4 +- problems/nth-magical-number/README.md | 8 +- problems/number-complement/README.md | 6 +- problems/number-of-1-bits/README.md | 20 +- problems/number-of-atoms/README.md | 16 +- problems/number-of-boomerangs/README.md | 8 +- .../README.md | 8 +- problems/number-of-closed-islands/README.md | 6 +- .../number-of-comments-per-post/README.md | 4 +- .../README.md | 18 +- .../number-of-corner-rectangles/README.md | 6 +- problems/number-of-days-in-a-month/README.md | 4 +- .../README.md | 6 +- problems/number-of-digit-one/README.md | 10 +- .../number-of-distinct-islands-ii/README.md | 10 +- problems/number-of-distinct-islands/README.md | 12 +- problems/number-of-enclaves/README.md | 6 +- .../README.md | 6 +- problems/number-of-islands-ii/README.md | 8 +- problems/number-of-islands/README.md | 22 +- .../number-of-lines-to-write-string/README.md | 4 +- .../README.md | 10 +- .../number-of-matching-subsequences/README.md | 8 +- problems/number-of-music-playlists/README.md | 6 +- problems/number-of-recent-calls/README.md | 6 +- .../number-of-segments-in-a-string/README.md | 6 +- .../number-of-ships-in-a-rectangle/README.md | 6 +- problems/number-of-squareful-arrays/README.md | 12 +- .../README.md | 6 +- .../README.md | 10 +- problems/number-of-valid-subarrays/README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 8 +- .../numbers-with-repeated-digits/README.md | 8 +- .../README.md | 6 +- problems/occurrences-after-bigram/README.md | 6 +- problems/odd-even-jump/README.md | 10 +- problems/odd-even-linked-list/README.md | 8 +- problems/one-edit-distance/README.md | 8 +- problems/ones-and-zeroes/README.md | 8 +- problems/online-election/README.md | 6 +- .../README.md | 10 +- problems/online-stock-span/README.md | 6 +- problems/open-the-lock/README.md | 6 +- problems/optimal-account-balancing/README.md | 4 +- problems/optimal-division/README.md | 8 +- .../README.md | 8 +- problems/orderly-queue/README.md | 8 +- problems/out-of-boundary-paths/README.md | 10 +- problems/output-contest-matches/README.md | 8 +- .../pacific-atlantic-water-flow/README.md | 8 +- problems/page-recommendations/README.md | 4 +- problems/paint-fence/README.md | 14 +- problems/paint-house-ii/README.md | 14 +- problems/paint-house/README.md | 14 +- .../README.md | 6 +- problems/palindrome-linked-list/README.md | 14 +- problems/palindrome-number/README.md | 8 +- problems/palindrome-pairs/README.md | 14 +- problems/palindrome-partitioning-ii/README.md | 8 +- .../palindrome-partitioning-iii/README.md | 6 +- problems/palindrome-partitioning/README.md | 8 +- problems/palindrome-permutation-ii/README.md | 12 +- problems/palindrome-permutation/README.md | 14 +- problems/palindrome-removal/README.md | 6 +- problems/palindromic-substrings/README.md | 14 +- problems/pancake-sorting/README.md | 8 +- problems/parallel-courses/README.md | 10 +- problems/parse-lisp-expression/README.md | 12 +- .../parsing-a-boolean-expression/README.md | 6 +- .../partition-array-for-maximum-sum/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/partition-equal-subset-sum/README.md | 8 +- problems/partition-labels/README.md | 10 +- problems/partition-list/README.md | 8 +- .../README.md | 10 +- problems/pascals-triangle-ii/README.md | 8 +- problems/pascals-triangle/README.md | 8 +- problems/patching-array/README.md | 6 +- .../README.md | 8 +- problems/path-sum-ii/README.md | 16 +- problems/path-sum-iii/README.md | 14 +- problems/path-sum-iv/README.md | 14 +- problems/path-sum/README.md | 18 +- problems/path-with-maximum-gold/README.md | 6 +- .../path-with-maximum-minimum-value/README.md | 10 +- .../peak-index-in-a-mountain-array/README.md | 8 +- problems/peeking-iterator/README.md | 12 +- problems/perfect-number/README.md | 8 +- problems/perfect-rectangle/README.md | 6 +- problems/perfect-squares/README.md | 14 +- problems/permutation-in-string/README.md | 12 +- problems/permutation-sequence/README.md | 12 +- problems/permutations-ii/README.md | 14 +- problems/permutations/README.md | 14 +- problems/play-with-chips/README.md | 10 +- problems/plus-one-linked-list/README.md | 8 +- problems/plus-one/README.md | 14 +- problems/poor-pigs/README.md | 6 +- .../README.md | 10 +- .../README.md | 12 +- problems/positions-of-large-groups/README.md | 6 +- problems/possible-bipartition/README.md | 6 +- problems/pour-water/README.md | 8 +- problems/power-of-four/README.md | 10 +- problems/power-of-three/README.md | 10 +- problems/power-of-two/README.md | 14 +- problems/powerful-integers/README.md | 8 +- problems/powx-n/README.md | 12 +- problems/predict-the-winner/README.md | 10 +- problems/prefix-and-suffix-search/README.md | 8 +- .../README.md | 8 +- .../README.md | 8 +- problems/prime-arrangements/README.md | 6 +- .../README.md | 8 +- problems/prime-palindrome/README.md | 6 +- problems/print-binary-tree/README.md | 6 +- problems/print-foobar-alternately/README.md | 8 +- .../README.md | 4 +- problems/print-in-order/README.md | 6 +- problems/print-zero-even-odd/README.md | 6 +- problems/prison-cells-after-n-days/README.md | 6 +- .../product-of-array-except-self/README.md | 12 +- .../product-price-at-a-given-date/README.md | 4 +- problems/product-sales-analysis-i/README.md | 4 +- problems/product-sales-analysis-ii/README.md | 4 +- problems/product-sales-analysis-iii/README.md | 4 +- problems/profitable-schemes/README.md | 6 +- problems/project-employees-i/README.md | 4 +- problems/project-employees-ii/README.md | 4 +- problems/project-employees-iii/README.md | 4 +- .../projection-area-of-3d-shapes/README.md | 6 +- problems/push-dominoes/README.md | 8 +- problems/pyramid-transition-matrix/README.md | 8 +- problems/quad-tree-intersection/README.md | 4 +- .../queens-that-can-attack-the-king/README.md | 6 +- .../queries-quality-and-percentage/README.md | 4 +- .../queue-reconstruction-by-height/README.md | 8 +- problems/rabbits-in-forest/README.md | 8 +- problems/race-car/README.md | 8 +- problems/random-flip-matrix/README.md | 6 +- problems/random-pick-index/README.md | 12 +- problems/random-pick-with-blacklist/README.md | 16 +- problems/random-pick-with-weight/README.md | 14 +- .../README.md | 12 +- problems/range-addition-ii/README.md | 8 +- problems/range-addition/README.md | 8 +- problems/range-module/README.md | 14 +- problems/range-sum-of-bst/README.md | 8 +- .../range-sum-query-2d-immutable/README.md | 10 +- problems/range-sum-query-2d-mutable/README.md | 12 +- problems/range-sum-query-immutable/README.md | 12 +- problems/range-sum-query-mutable/README.md | 12 +- problems/rank-scores/README.md | 4 +- problems/ransom-note/README.md | 8 +- problems/reach-a-number/README.md | 6 +- .../README.md | 6 +- problems/reaching-points/README.md | 6 +- .../README.md | 8 +- .../read-n-characters-given-read4/README.md | 8 +- .../README.md | 14 +- .../README.md | 8 +- problems/reconstruct-itinerary/README.md | 8 +- .../README.md | 6 +- .../README.md | 8 +- problems/recover-binary-search-tree/README.md | 8 +- problems/rectangle-area-ii/README.md | 8 +- problems/rectangle-area/README.md | 8 +- problems/rectangle-overlap/README.md | 8 +- problems/redundant-connection-ii/README.md | 14 +- problems/redundant-connection/README.md | 14 +- problems/reformat-department-table/README.md | 4 +- problems/regions-cut-by-slashes/README.md | 10 +- .../regular-expression-matching/README.md | 12 +- problems/relative-ranks/README.md | 4 +- problems/relative-sort-array/README.md | 8 +- problems/remove-9/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/remove-boxes/README.md | 10 +- problems/remove-comments/README.md | 10 +- problems/remove-covered-intervals/README.md | 6 +- problems/remove-duplicate-letters/README.md | 8 +- .../README.md | 10 +- .../README.md | 12 +- .../README.md | 8 +- .../README.md | 8 +- problems/remove-element/README.md | 14 +- problems/remove-interval/README.md | 8 +- problems/remove-invalid-parentheses/README.md | 10 +- problems/remove-k-digits/README.md | 12 +- .../remove-linked-list-elements/README.md | 10 +- .../README.md | 8 +- .../remove-outermost-parentheses/README.md | 6 +- .../README.md | 8 +- .../remove-vowels-from-a-string/README.md | 8 +- .../README.md | 6 +- problems/reorder-data-in-log-files/README.md | 6 +- problems/reorder-list/README.md | 6 +- problems/reordered-power-of-2/README.md | 6 +- problems/reorganize-string/README.md | 16 +- problems/repeated-dna-sequences/README.md | 8 +- problems/repeated-string-match/README.md | 8 +- problems/repeated-substring-pattern/README.md | 10 +- .../README.md | 8 +- problems/replace-words/README.md | 10 +- problems/report-contiguous-dates/README.md | 4 +- problems/reported-posts-ii/README.md | 4 +- problems/reported-posts/README.md | 4 +- problems/reshape-the-matrix/README.md | 6 +- problems/restore-ip-addresses/README.md | 10 +- .../README.md | 6 +- problems/reverse-bits/README.md | 10 +- problems/reverse-integer/README.md | 10 +- problems/reverse-linked-list-ii/README.md | 8 +- problems/reverse-linked-list/README.md | 12 +- problems/reverse-nodes-in-k-group/README.md | 8 +- problems/reverse-only-letters/README.md | 6 +- problems/reverse-pairs/README.md | 18 +- problems/reverse-string-ii/README.md | 10 +- problems/reverse-string/README.md | 12 +- .../README.md | 6 +- problems/reverse-vowels-of-a-string/README.md | 12 +- .../reverse-words-in-a-string-ii/README.md | 10 +- .../reverse-words-in-a-string-iii/README.md | 8 +- problems/reverse-words-in-a-string/README.md | 8 +- problems/rising-temperature/README.md | 4 +- problems/rle-iterator/README.md | 6 +- problems/robot-bounded-in-circle/README.md | 6 +- problems/robot-return-to-origin/README.md | 8 +- problems/robot-room-cleaner/README.md | 8 +- problems/roman-to-integer/README.md | 10 +- problems/rotate-array/README.md | 10 +- problems/rotate-function/README.md | 6 +- problems/rotate-image/README.md | 6 +- problems/rotate-list/README.md | 12 +- problems/rotate-string/README.md | 4 +- problems/rotated-digits/README.md | 6 +- problems/rotting-oranges/README.md | 8 +- problems/russian-doll-envelopes/README.md | 10 +- problems/sales-analysis-i/README.md | 4 +- problems/sales-analysis-ii/README.md | 4 +- problems/sales-analysis-iii/README.md | 4 +- problems/sales-person/README.md | 4 +- problems/same-tree/README.md | 8 +- .../README.md | 8 +- .../score-after-flipping-matrix/README.md | 6 +- problems/score-of-parentheses/README.md | 8 +- problems/scramble-string/README.md | 8 +- problems/search-a-2d-matrix-ii/README.md | 10 +- problems/search-a-2d-matrix/README.md | 10 +- .../search-in-a-binary-search-tree/README.md | 10 +- .../README.md | 8 +- .../README.md | 10 +- .../search-in-rotated-sorted-array/README.md | 12 +- problems/search-insert-position/README.md | 10 +- problems/search-suggestions-system/README.md | 6 +- problems/second-degree-follower/README.md | 4 +- problems/second-highest-salary/README.md | 4 +- .../README.md | 8 +- problems/self-crossing/README.md | 6 +- problems/self-dividing-numbers/README.md | 8 +- problems/sentence-screen-fitting/README.md | 6 +- problems/sentence-similarity-ii/README.md | 14 +- problems/sentence-similarity/README.md | 12 +- problems/sequence-reconstruction/README.md | 10 +- problems/sequential-digits/README.md | 6 +- .../README.md | 16 +- .../serialize-and-deserialize-bst/README.md | 12 +- .../README.md | 12 +- .../README.md | 6 +- problems/set-matrix-zeroes/README.md | 8 +- problems/set-mismatch/README.md | 10 +- problems/shift-2d-grid/README.md | 6 +- problems/shifting-letters/README.md | 6 +- problems/shopping-offers/README.md | 8 +- problems/short-encoding-of-words/README.md | 4 +- problems/shortest-bridge/README.md | 8 +- .../shortest-common-supersequence/README.md | 6 +- problems/shortest-completing-word/README.md | 6 +- .../README.md | 12 +- .../shortest-distance-in-a-line/README.md | 4 +- .../shortest-distance-in-a-plane/README.md | 4 +- .../README.md | 4 +- .../README.md | 6 +- problems/shortest-palindrome/README.md | 12 +- .../README.md | 4 +- .../shortest-path-in-binary-matrix/README.md | 6 +- .../shortest-path-to-get-all-keys/README.md | 8 +- .../README.md | 8 +- .../README.md | 8 +- .../README.md | 8 +- .../README.md | 6 +- .../shortest-way-to-form-string/README.md | 10 +- problems/shortest-word-distance-ii/README.md | 14 +- problems/shortest-word-distance-iii/README.md | 10 +- problems/shortest-word-distance/README.md | 10 +- problems/shuffle-an-array/README.md | 4 +- problems/similar-rgb-color/README.md | 8 +- problems/similar-string-groups/README.md | 10 +- problems/simplify-path/README.md | 8 +- .../README.md | 4 +- problems/single-number-ii/README.md | 10 +- problems/single-number-iii/README.md | 10 +- problems/single-number/README.md | 18 +- problems/single-row-keyboard/README.md | 6 +- problems/sliding-puzzle/README.md | 6 +- problems/sliding-window-maximum/README.md | 16 +- problems/sliding-window-median/README.md | 8 +- problems/smallest-common-region/README.md | 10 +- problems/smallest-good-base/README.md | 8 +- .../smallest-integer-divisible-by-k/README.md | 6 +- .../README.md | 10 +- problems/smallest-range-i/README.md | 6 +- problems/smallest-range-ii/README.md | 8 +- .../README.md | 6 +- .../README.md | 4 +- .../README.md | 12 +- problems/smallest-string-with-swaps/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- problems/smallest-sufficient-team/README.md | 8 +- problems/snakes-and-ladders/README.md | 6 +- problems/snapshot-array/README.md | 6 +- problems/solve-the-equation/README.md | 8 +- problems/sort-an-array/README.md | 4 +- problems/sort-array-by-parity-ii/README.md | 8 +- problems/sort-array-by-parity/README.md | 6 +- .../sort-characters-by-frequency/README.md | 12 +- problems/sort-colors/README.md | 16 +- .../README.md | 10 +- problems/sort-list/README.md | 14 +- problems/sort-transformed-array/README.md | 10 +- problems/soup-servings/README.md | 6 +- .../sparse-matrix-multiplication/README.md | 6 +- problems/special-binary-string/README.md | 10 +- problems/spiral-matrix-ii/README.md | 8 +- problems/spiral-matrix-iii/README.md | 6 +- problems/spiral-matrix/README.md | 8 +- .../README.md | 8 +- .../README.md | 10 +- .../README.md | 14 +- problems/split-array-largest-sum/README.md | 8 +- problems/split-array-with-equal-sum/README.md | 6 +- .../split-array-with-same-average/README.md | 6 +- problems/split-bst/README.md | 10 +- problems/split-concatenated-strings/README.md | 6 +- problems/split-linked-list-in-parts/README.md | 10 +- problems/sqrtx/README.md | 12 +- problems/squares-of-a-sorted-array/README.md | 12 +- problems/squirrel-simulation/README.md | 6 +- problems/stamping-the-sequence/README.md | 8 +- .../statistics-from-a-large-sample/README.md | 8 +- problems/stepping-numbers/README.md | 6 +- problems/stickers-to-spell-word/README.md | 10 +- problems/stone-game-ii/README.md | 6 +- problems/stone-game/README.md | 10 +- problems/strange-printer/README.md | 10 +- problems/stream-of-characters/README.md | 6 +- problems/string-compression/README.md | 12 +- problems/string-to-integer-atoi/README.md | 12 +- .../README.md | 6 +- problems/string-without-aaa-or-bbb/README.md | 6 +- problems/strobogrammatic-number-ii/README.md | 12 +- problems/strobogrammatic-number-iii/README.md | 12 +- problems/strobogrammatic-number/README.md | 14 +- problems/strong-password-checker/README.md | 4 +- .../student-attendance-record-i/README.md | 8 +- .../student-attendance-record-ii/README.md | 8 +- problems/students-and-examinations/README.md | 4 +- .../students-report-by-geography/README.md | 4 +- .../subarray-product-less-than-k/README.md | 16 +- problems/subarray-sum-equals-k/README.md | 18 +- .../subarray-sums-divisible-by-k/README.md | 10 +- .../README.md | 16 +- problems/subdomain-visit-count/README.md | 6 +- problems/subsets-ii/README.md | 10 +- problems/subsets/README.md | 16 +- .../README.md | 12 +- .../README.md | 6 +- problems/subtree-of-another-tree/README.md | 10 +- problems/sudoku-solver/README.md | 12 +- .../README.md | 8 +- problems/sum-of-distances-in-tree/README.md | 10 +- .../README.md | 6 +- problems/sum-of-left-leaves/README.md | 6 +- .../README.md | 6 +- problems/sum-of-square-numbers/README.md | 8 +- problems/sum-of-subarray-minimums/README.md | 8 +- problems/sum-of-subsequence-widths/README.md | 8 +- problems/sum-of-two-integers/README.md | 8 +- problems/sum-root-to-leaf-numbers/README.md | 14 +- problems/summary-ranges/README.md | 10 +- problems/super-egg-drop/README.md | 10 +- problems/super-palindromes/README.md | 6 +- problems/super-pow/README.md | 8 +- problems/super-ugly-number/README.md | 10 +- problems/super-washing-machines/README.md | 8 +- problems/surface-area-of-3d-shapes/README.md | 8 +- problems/surrounded-regions/README.md | 14 +- problems/swap-adjacent-in-lr-string/README.md | 6 +- .../README.md | 6 +- problems/swap-nodes-in-pairs/README.md | 8 +- problems/swap-salary/README.md | 4 +- problems/swim-in-rising-water/README.md | 12 +- problems/symmetric-tree/README.md | 10 +- problems/synonymous-sentences/README.md | 6 +- problems/tag-validator/README.md | 10 +- problems/tallest-billboard/README.md | 6 +- problems/target-sum/README.md | 10 +- problems/task-scheduler/README.md | 14 +- .../README.md | 4 +- problems/teemo-attacking/README.md | 12 +- problems/tenth-line/README.md | 4 +- problems/ternary-expression-parser/README.md | 14 +- problems/text-justification/README.md | 6 +- problems/the-dining-philosophers/README.md | 4 +- .../README.md | 8 +- problems/the-maze-ii/README.md | 12 +- problems/the-maze-iii/README.md | 12 +- problems/the-maze/README.md | 12 +- problems/the-skyline-problem/README.md | 16 +- problems/third-maximum-number/README.md | 8 +- problems/three-equal-parts/README.md | 10 +- .../README.md | 8 +- problems/time-based-key-value-store/README.md | 8 +- problems/to-lower-case/README.md | 6 +- problems/toeplitz-matrix/README.md | 8 +- problems/top-k-frequent-elements/README.md | 20 +- problems/top-k-frequent-words/README.md | 14 +- problems/toss-strange-coins/README.md | 8 +- problems/total-hamming-distance/README.md | 8 +- problems/tournament-winners/README.md | 4 +- .../README.md | 4 +- problems/transform-to-chessboard/README.md | 8 +- problems/transpose-file/README.md | 4 +- problems/transpose-matrix/README.md | 6 +- problems/trapping-rain-water-ii/README.md | 10 +- problems/trapping-rain-water/README.md | 18 +- problems/tree-diameter/README.md | 10 +- problems/tree-node/README.md | 4 +- problems/triangle-judgement/README.md | 4 +- problems/triangle/README.md | 8 +- problems/trim-a-binary-search-tree/README.md | 6 +- .../README.md | 6 +- problems/trips-and-users/README.md | 4 +- problems/two-city-scheduling/README.md | 6 +- problems/two-sum-bsts/README.md | 8 +- .../README.md | 16 +- .../README.md | 14 +- problems/two-sum-iv-input-is-a-bst/README.md | 14 +- problems/two-sum-less-than-k/README.md | 14 +- problems/two-sum/README.md | 20 +- problems/ugly-number-ii/README.md | 20 +- problems/ugly-number-iii/README.md | 8 +- problems/ugly-number/README.md | 12 +- .../README.md | 6 +- problems/uncrossed-lines/README.md | 8 +- .../unique-binary-search-trees-ii/README.md | 12 +- problems/unique-binary-search-trees/README.md | 10 +- problems/unique-email-addresses/README.md | 6 +- problems/unique-letter-string/README.md | 6 +- problems/unique-morse-code-words/README.md | 6 +- .../unique-number-of-occurrences/README.md | 6 +- problems/unique-paths-ii/README.md | 12 +- problems/unique-paths-iii/README.md | 14 +- problems/unique-paths/README.md | 14 +- .../README.md | 6 +- problems/unique-word-abbreviation/README.md | 12 +- problems/univalued-binary-tree/README.md | 6 +- problems/unpopular-books/README.md | 4 +- .../README.md | 4 +- .../README.md | 4 +- problems/user-purchase-platform/README.md | 4 +- problems/utf-8-validation/README.md | 6 +- problems/valid-anagram/README.md | 14 +- problems/valid-boomerang/README.md | 6 +- problems/valid-mountain-array/README.md | 6 +- problems/valid-number/README.md | 10 +- problems/valid-palindrome-ii/README.md | 8 +- problems/valid-palindrome-iii/README.md | 8 +- problems/valid-palindrome/README.md | 12 +- problems/valid-parentheses/README.md | 16 +- problems/valid-parenthesis-string/README.md | 8 +- problems/valid-perfect-square/README.md | 12 +- .../README.md | 8 +- problems/valid-phone-numbers/README.md | 4 +- problems/valid-square/README.md | 6 +- problems/valid-sudoku/README.md | 8 +- problems/valid-tic-tac-toe-state/README.md | 10 +- problems/valid-triangle-number/README.md | 8 +- problems/valid-word-abbreviation/README.md | 10 +- problems/valid-word-square/README.md | 8 +- .../validate-binary-search-tree/README.md | 12 +- problems/validate-ip-address/README.md | 8 +- problems/validate-stack-sequences/README.md | 6 +- .../README.md | 10 +- .../README.md | 6 +- .../verifying-an-alien-dictionary/README.md | 6 +- .../README.md | 8 +- problems/video-stitching/README.md | 6 +- problems/vowel-spellchecker/README.md | 8 +- problems/walking-robot-simulation/README.md | 6 +- problems/walls-and-gates/README.md | 16 +- problems/water-and-jug-problem/README.md | 6 +- problems/web-crawler-multithreaded/README.md | 8 +- problems/web-crawler/README.md | 8 +- problems/wiggle-sort-ii/README.md | 12 +- problems/wiggle-sort/README.md | 12 +- problems/wiggle-subsequence/README.md | 8 +- problems/wildcard-matching/README.md | 14 +- problems/winning-candidate/README.md | 4 +- problems/word-abbreviation/README.md | 12 +- problems/word-break-ii/README.md | 12 +- problems/word-break/README.md | 8 +- problems/word-frequency/README.md | 6 +- problems/word-ladder-ii/README.md | 14 +- problems/word-ladder/README.md | 10 +- problems/word-pattern-ii/README.md | 8 +- problems/word-pattern/README.md | 10 +- problems/word-search-ii/README.md | 12 +- problems/word-search/README.md | 10 +- problems/word-squares/README.md | 10 +- problems/word-subsets/README.md | 6 +- .../x-of-a-kind-in-a-deck-of-cards/README.md | 8 +- problems/zigzag-conversion/README.md | 6 +- problems/zigzag-iterator/README.md | 14 +- problems/zuma-game/README.md | 6 +- readme/1-300.md | 60 +-- readme/301-600.md | 60 +-- readme/601-900.md | 60 +-- tag/README.md | 40 +- tag/array/README.md | 422 +++++++++--------- tag/backtracking/README.md | 106 ++--- tag/binary-indexed-tree/README.md | 14 +- tag/binary-search-tree/README.md | 6 +- tag/binary-search/README.md | 164 +++---- tag/bit-manipulation/README.md | 80 ++-- tag/brainteaser/README.md | 12 +- tag/breadth-first-search/README.md | 122 ++--- tag/depth-first-search/README.md | 230 +++++----- tag/design/README.md | 88 ++-- tag/divide-and-conquer/README.md | 40 +- tag/dynamic-programming/README.md | 350 +++++++-------- tag/geometry/README.md | 12 +- tag/graph/README.md | 76 ++-- tag/greedy/README.md | 138 +++--- tag/hash-table/README.md | 244 +++++----- tag/heap/README.md | 70 +-- tag/line-sweep/README.md | 14 +- tag/linked-list/README.md | 76 ++-- tag/math/README.md | 328 +++++++------- tag/memoization/README.md | 4 +- tag/minimax/README.md | 18 +- tag/ordered-map/README.md | 22 +- tag/queue/README.md | 20 +- tag/random/README.md | 14 +- tag/recursion/README.md | 32 +- tag/rejection-sampling/README.md | 6 +- tag/reservoir-sampling/README.md | 6 +- tag/rolling-hash/README.md | 2 +- tag/segment-tree/README.md | 24 +- tag/sliding-window/README.md | 42 +- tag/sort/README.md | 78 ++-- tag/stack/README.md | 110 ++--- tag/string/README.md | 302 ++++++------- tag/suffix-array/README.md | 2 +- tag/topological-sort/README.md | 14 +- tag/tree/README.md | 248 +++++----- tag/trie/README.md | 36 +- tag/two-pointers/README.md | 122 ++--- tag/union-find/README.md | 58 +-- 1345 files changed, 7701 insertions(+), 7698 deletions(-) diff --git a/README.md b/README.md index fade28112..4bce71657 100644 --- a/README.md +++ b/README.md @@ -19,44 +19,44 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + +
[1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
[301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
[601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
[901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
[1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
diff --git a/internal/base/base.go b/internal/base/base.go index 28168c8c5..38e622d8d 100644 --- a/internal/base/base.go +++ b/internal/base/base.go @@ -14,7 +14,10 @@ import ( ) // CmdName - base.CmdName -const CmdName = "leetcode" +const ( + CmdName = "leetcode" + URL = "https://github.com/openset/leetcode/tree/master" +) // base var var ( diff --git a/internal/leetcode/question_data.go b/internal/leetcode/question_data.go index 4bf230f02..a326f54cc 100644 --- a/internal/leetcode/question_data.go +++ b/internal/leetcode/question_data.go @@ -172,7 +172,7 @@ func (question *questionType) getNavigation() string { nav, pre, next := "\n%s\n%s\n%s\n", "< Previous", "Next >" problems := ProblemsAll().StatStatusPairs id := question.questionID() - format := `[%s](https://github.com/openset/leetcode/tree/master/problems/%s "%s")` + format := `[%s](../%s "%s")` for i, problem := range problems { if problem.Stat.QuestionID == id { if i < len(problems)-1 { @@ -193,7 +193,7 @@ func (question *questionType) getTopicTags() []byte { if len(tags) > 0 { buf.WriteString("\n### Related Topics\n") } - format := " [[%s](https://github.com/openset/leetcode/tree/master/tag/%s/README.md)]\n" + format := " [[%s](../../tag/%s/README.md)]\n" for _, tag := range tags { buf.WriteString(fmt.Sprintf(format, tag.Name, tag.Slug)) } @@ -249,7 +249,7 @@ func (question *questionType) getSimilarQuestion() []byte { if len(sq) > 0 { buf.WriteString("\n### Similar Questions\n") } - format := " 1. [%s](https://github.com/openset/leetcode/tree/master/problems/%s)%s\n" + format := " 1. [%s](../%s)%s\n" for _, q := range sq { buf.WriteString(fmt.Sprintf(format, q.Title, q.TitleSlug, q.Difficulty.Str())) } diff --git a/internal/leetcode/topic_tag.go b/internal/leetcode/topic_tag.go index 32243f173..c297cb3c9 100644 --- a/internal/leetcode/topic_tag.go +++ b/internal/leetcode/topic_tag.go @@ -34,10 +34,10 @@ func (tag *TagType) SaveContents() { }) var buf bytes.Buffer buf.WriteString(authInfo("tag")) - buf.WriteString(fmt.Sprintf("\n## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > %s\n\n", tag.name())) + buf.WriteString(fmt.Sprintf("\n## [话题分类](../README.md) > %s\n\n", tag.name())) buf.WriteString("| # | 题名 | 标签 | 难度 |\n") buf.WriteString("| :-: | - | - | :-: |\n") - format := "| %d | [%s](https://github.com/openset/leetcode/tree/master/problems/%s)%s | %s | %s |\n" + format := "| %d | [%s](../../problems/%s)%s | %s | %s |\n" for _, question := range questions { if question.TranslatedTitle == "" { question.TranslatedTitle = question.Title @@ -85,7 +85,7 @@ type ttQuestionType struct { func (question *ttQuestionType) TagsStr() string { var buf bytes.Buffer - format := "[[%s](https://github.com/openset/leetcode/tree/master/tag/%s/README.md)] " + format := "[[%s](../%s/README.md)] " for _, tag := range question.TopicTags { buf.WriteString(fmt.Sprintf(format, tag.name(), tag.Slug)) } diff --git a/internal/open/open.go b/internal/open/open.go index 287f0c31d..5e9d9280c 100644 --- a/internal/open/open.go +++ b/internal/open/open.go @@ -2,6 +2,7 @@ package open import ( + "fmt" "strconv" "github.com/openset/leetcode/internal/base" @@ -31,7 +32,7 @@ func runOpen(cmd *base.Command, args []string) { for _, problem := range problems.StatStatusPairs { if problem.Stat.FrontendQuestionID == id { titleSlug := problem.Stat.QuestionTitleSlug - browser.Open("https://github.com/openset/leetcode/tree/master/problems/" + titleSlug) + browser.Open(fmt.Sprintf("%s/problems/%s", base.URL, titleSlug)) break } } diff --git a/internal/post/post.go b/internal/post/post.go index d79209b1d..e10388367 100644 --- a/internal/post/post.go +++ b/internal/post/post.go @@ -52,7 +52,7 @@ func runPost(cmd *base.Command, args []string) { return } formatFilename := "%s-%s.md" - formatTopicTag := " [[%s](https://github.com/openset/leetcode/tree/master/tag/%s/README.md)]\n" + formatTopicTag := " [[%s](%s/tag/%s/README.md)]\n" formatSimilarQuestion := " 1. [%s](/problems/%s)%s\n" problems := leetcode.ProblemsAll() for _, problem := range problems.StatStatusPairs { @@ -71,7 +71,7 @@ func runPost(cmd *base.Command, args []string) { if tag.TranslatedName != "" { tag.Name = tag.TranslatedName } - tagsBuf.WriteString(fmt.Sprintf(formatTopicTag, tag.Name, tag.Slug)) + tagsBuf.WriteString(fmt.Sprintf(formatTopicTag, tag.Name, base.URL, tag.Slug)) } buf.WriteString(fmt.Sprintf(frontMatter, question.TranslatedTitle, @@ -104,7 +104,7 @@ func runPost(cmd *base.Command, args []string) { buf.WriteString(fmt.Sprintf(formatSimilarQuestion, q.Title, q.TitleSlug, q.Difficulty.Str())) } buf.WriteString("\n---\n") - buf.WriteString(fmt.Sprintf("\n## [解法](https://github.com/openset/leetcode/tree/master/problems/%s)\n", question.TitleSlug)) + buf.WriteString(fmt.Sprintf("\n## [解法](%s/problems/%s)\n", base.URL, question.TitleSlug)) filename := fmt.Sprintf(formatFilename, t.Format("2006-01-02"), question.TitleSlug) oldPath := filepath.Join(basePath, "leetcode", filename) newPath := filepath.Join(basePath, "_posts", filename) diff --git a/internal/readme/readme.go b/internal/readme/readme.go index 22a466b11..5bdb27a00 100644 --- a/internal/readme/readme.go +++ b/internal/readme/readme.go @@ -99,9 +99,8 @@ func writeNav(buf *bytes.Buffer) { } func linkStr(num int) string { - link := "https://github.com/openset/leetcode/blob/master/" if num > maxID-maxID%pageSize-pageSize { - return fmt.Sprintf("%sREADME.md#%d", link, num) + return fmt.Sprintf("%s/README.md#%d", base.URL, num) } - return fmt.Sprintf("%sreadme/%d-%d.md#%d", link, (num-1)/pageSize*pageSize+1, ((num-1)/pageSize+1)*pageSize, num-step+1) + return fmt.Sprintf("%s/readme/%d-%d.md#%d", base.URL, (num-1)/pageSize*pageSize+1, ((num-1)/pageSize+1)*pageSize, num-step+1) } diff --git a/internal/tag/tag.go b/internal/tag/tag.go index d5581f9c2..bb89fe516 100644 --- a/internal/tag/tag.go +++ b/internal/tag/tag.go @@ -31,7 +31,7 @@ func runTag(cmd *base.Command, args []string) { buf.WriteString("\n## 话题分类\n\n") buf.WriteString("| # | Title | 话题 | | # | Title | 话题 |\n") buf.WriteString("| :-: | - | :-: | - | :-: | - | :-: |\n") - format := "| %d | [%s](https://github.com/openset/leetcode/tree/master/tag/%s/README.md) | [%s](https://openset.github.io/tags/%s/) | " + format := "| %d | [%s](%s/README.md) | [%s](https://openset.github.io/tags/%s/) | " n := buf.Len() for times := 0; times < 2; times++ { buf.Truncate(n) diff --git a/problems/01-matrix/README.md b/problems/01-matrix/README.md index 0d8d304d5..c2ee184af 100644 --- a/problems/01-matrix/README.md +++ b/problems/01-matrix/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reverse-string-ii "Reverse String II") +[< Previous](../reverse-string-ii "Reverse String II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/diameter-of-binary-tree "Diameter of Binary Tree") +[Next >](../diameter-of-binary-tree "Diameter of Binary Tree") ## [542. 01 Matrix (Medium)](https://leetcode.com/problems/01-matrix "01 矩阵") @@ -56,5 +56,5 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/1-bit-and-2-bit-characters/README.md b/problems/1-bit-and-2-bit-characters/README.md index 4dd3a52e0..5c6032fa3 100644 --- a/problems/1-bit-and-2-bit-characters/README.md +++ b/problems/1-bit-and-2-bit-characters/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/max-stack "Max Stack") +[< Previous](../max-stack "Max Stack")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-repeated-subarray "Maximum Length of Repeated Subarray") +[Next >](../maximum-length-of-repeated-subarray "Maximum Length of Repeated Subarray") ## [717. 1-bit and 2-bit Characters (Easy)](https://leetcode.com/problems/1-bit-and-2-bit-characters "1比特与2比特字符") @@ -41,10 +41,10 @@ The only way to decode it is two-bit character and two-bit character. So the las

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Gray Code](https://github.com/openset/leetcode/tree/master/problems/gray-code) (Medium) + 1. [Gray Code](../gray-code) (Medium) ### Hints
diff --git a/problems/132-pattern/README.md b/problems/132-pattern/README.md index de23e63ec..862deef34 100644 --- a/problems/132-pattern/README.md +++ b/problems/132-pattern/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/assign-cookies "Assign Cookies") +[< Previous](../assign-cookies "Assign Cookies")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/circular-array-loop "Circular Array Loop") +[Next >](../circular-array-loop "Circular Array Loop") ## [456. 132 Pattern (Medium)](https://leetcode.com/problems/132-pattern "132模式") @@ -48,4 +48,4 @@ that i < j < k and ai < ak ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] + [[Stack](../../tag/stack/README.md)] diff --git a/problems/2-keys-keyboard/README.md b/problems/2-keys-keyboard/README.md index 7e0aba8ec..618540934 100644 --- a/problems/2-keys-keyboard/README.md +++ b/problems/2-keys-keyboard/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/dota2-senate "Dota2 Senate") +[< Previous](../dota2-senate "Dota2 Senate")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/4-keys-keyboard "4 Keys Keyboard") +[Next >](../4-keys-keyboard "4 Keys Keyboard") ## [650. 2 Keys Keyboard (Medium)](https://leetcode.com/problems/2-keys-keyboard "只有两个键的键盘") @@ -45,11 +45,11 @@ In step 3, we use Paste operation to get 'AAA'.

 

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [4 Keys Keyboard](https://github.com/openset/leetcode/tree/master/problems/4-keys-keyboard) (Medium) - 1. [Broken Calculator](https://github.com/openset/leetcode/tree/master/problems/broken-calculator) (Medium) + 1. [4 Keys Keyboard](../4-keys-keyboard) (Medium) + 1. [Broken Calculator](../broken-calculator) (Medium) ### Hints
diff --git a/problems/24-game/README.md b/problems/24-game/README.md index 8a3d10396..d5d1487e8 100644 --- a/problems/24-game/README.md +++ b/problems/24-game/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-parenthesis-string "Valid Parenthesis String") +[< Previous](../valid-parenthesis-string "Valid Parenthesis String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome-ii "Valid Palindrome II") +[Next >](../valid-palindrome-ii "Valid Palindrome II") ## [679. 24 Game (Hard)](https://leetcode.com/problems/24-game "24 点游戏") @@ -40,4 +40,4 @@ You have 4 cards each containing a number from 1 to 9. You need to judge whethe

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/3sum-closest/README.md b/problems/3sum-closest/README.md index 68daac163..e5a964119 100644 --- a/problems/3sum-closest/README.md +++ b/problems/3sum-closest/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/3sum "3Sum") +[< Previous](../3sum "3Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/letter-combinations-of-a-phone-number "Letter Combinations of a Phone Number") +[Next >](../letter-combinations-of-a-phone-number "Letter Combinations of a Phone Number") ## [16. 3Sum Closest (Medium)](https://leetcode.com/problems/3sum-closest "最接近的三数之和") @@ -22,9 +22,9 @@ The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [3Sum](https://github.com/openset/leetcode/tree/master/problems/3sum) (Medium) - 1. [3Sum Smaller](https://github.com/openset/leetcode/tree/master/problems/3sum-smaller) (Medium) + 1. [3Sum](../3sum) (Medium) + 1. [3Sum Smaller](../3sum-smaller) (Medium) diff --git a/problems/3sum-smaller/README.md b/problems/3sum-smaller/README.md index 2c7d76610..d9215a65f 100644 --- a/problems/3sum-smaller/README.md +++ b/problems/3sum-smaller/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/add-digits "Add Digits") +[< Previous](../add-digits "Add Digits")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/single-number-iii "Single Number III") +[Next >](../single-number-iii "Single Number III") ## [259. 3Sum Smaller (Medium)](https://leetcode.com/problems/3sum-smaller "较小的三数之和") @@ -26,11 +26,11 @@

Follow up: Could you solve it in O(n2) runtime?

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [3Sum](https://github.com/openset/leetcode/tree/master/problems/3sum) (Medium) - 1. [3Sum Closest](https://github.com/openset/leetcode/tree/master/problems/3sum-closest) (Medium) - 1. [Valid Triangle Number](https://github.com/openset/leetcode/tree/master/problems/valid-triangle-number) (Medium) - 1. [Two Sum Less Than K](https://github.com/openset/leetcode/tree/master/problems/two-sum-less-than-k) (Easy) + 1. [3Sum](../3sum) (Medium) + 1. [3Sum Closest](../3sum-closest) (Medium) + 1. [Valid Triangle Number](../valid-triangle-number) (Medium) + 1. [Two Sum Less Than K](../two-sum-less-than-k) (Easy) diff --git a/problems/3sum-with-multiplicity/README.md b/problems/3sum-with-multiplicity/README.md index 6f8e3dea5..d7d1d6276 100644 --- a/problems/3sum-with-multiplicity/README.md +++ b/problems/3sum-with-multiplicity/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sort-array-by-parity-ii "Sort Array By Parity II") +[< Previous](../sort-array-by-parity-ii "Sort Array By Parity II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimize-malware-spread "Minimize Malware Spread") +[Next >](../minimize-malware-spread "Minimize Malware Spread") ## [923. 3Sum With Multiplicity (Medium)](https://leetcode.com/problems/3sum-with-multiplicity "三数之和的多种可能") @@ -54,4 +54,4 @@ and two 2s from [2,2,2,2] in 6 ways. ### Related Topics - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/3sum/README.md b/problems/3sum/README.md index c69cd8b84..3bdb80943 100644 --- a/problems/3sum/README.md +++ b/problems/3sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-common-prefix "Longest Common Prefix") +[< Previous](../longest-common-prefix "Longest Common Prefix")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/3sum-closest "3Sum Closest") +[Next >](../3sum-closest "3Sum Closest") ## [15. 3Sum (Medium)](https://leetcode.com/problems/3sum "三数之和") @@ -30,11 +30,11 @@ A solution set is: ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Two Sum](https://github.com/openset/leetcode/tree/master/problems/two-sum) (Easy) - 1. [3Sum Closest](https://github.com/openset/leetcode/tree/master/problems/3sum-closest) (Medium) - 1. [4Sum](https://github.com/openset/leetcode/tree/master/problems/4sum) (Medium) - 1. [3Sum Smaller](https://github.com/openset/leetcode/tree/master/problems/3sum-smaller) (Medium) + 1. [Two Sum](../two-sum) (Easy) + 1. [3Sum Closest](../3sum-closest) (Medium) + 1. [4Sum](../4sum) (Medium) + 1. [3Sum Smaller](../3sum-smaller) (Medium) diff --git a/problems/4-keys-keyboard/README.md b/problems/4-keys-keyboard/README.md index 9e65b9e4a..c8aab92a6 100644 --- a/problems/4-keys-keyboard/README.md +++ b/problems/4-keys-keyboard/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/2-keys-keyboard "2 Keys Keyboard") +[< Previous](../2-keys-keyboard "2 Keys Keyboard")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-duplicate-subtrees "Find Duplicate Subtrees") +[Next >](../find-duplicate-subtrees "Find Duplicate Subtrees") ## [651. 4 Keys Keyboard (Medium)](https://leetcode.com/problems/4-keys-keyboard "4键键盘") @@ -48,9 +48,9 @@ A, A, A, Ctrl A, Ctrl C, Ctrl V, Ctrl V

### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [2 Keys Keyboard](https://github.com/openset/leetcode/tree/master/problems/2-keys-keyboard) (Medium) + 1. [2 Keys Keyboard](../2-keys-keyboard) (Medium) diff --git a/problems/4sum-ii/README.md b/problems/4sum-ii/README.md index e0141b64f..c250b1fe6 100644 --- a/problems/4sum-ii/README.md +++ b/problems/4sum-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-equal-array-elements "Minimum Moves to Equal Array Elements") +[< Previous](../minimum-moves-to-equal-array-elements "Minimum Moves to Equal Array Elements")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/assign-cookies "Assign Cookies") +[Next >](../assign-cookies "Assign Cookies") ## [454. 4Sum II (Medium)](https://leetcode.com/problems/4sum-ii "四数相加 II") @@ -36,8 +36,8 @@ The two tuples are:

 

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [4Sum](https://github.com/openset/leetcode/tree/master/problems/4sum) (Medium) + 1. [4Sum](../4sum) (Medium) diff --git a/problems/4sum/README.md b/problems/4sum/README.md index 5bd3b8a2e..c93f2aba1 100644 --- a/problems/4sum/README.md +++ b/problems/4sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/letter-combinations-of-a-phone-number "Letter Combinations of a Phone Number") +[< Previous](../letter-combinations-of-a-phone-number "Letter Combinations of a Phone Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-nth-node-from-end-of-list "Remove Nth Node From End of List") +[Next >](../remove-nth-node-from-end-of-list "Remove Nth Node From End of List") ## [18. 4Sum (Medium)](https://leetcode.com/problems/4sum "四数之和") @@ -31,11 +31,11 @@ A solution set is: ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Two Sum](https://github.com/openset/leetcode/tree/master/problems/two-sum) (Easy) - 1. [3Sum](https://github.com/openset/leetcode/tree/master/problems/3sum) (Medium) - 1. [4Sum II](https://github.com/openset/leetcode/tree/master/problems/4sum-ii) (Medium) + 1. [Two Sum](../two-sum) (Easy) + 1. [3Sum](../3sum) (Medium) + 1. [4Sum II](../4sum-ii) (Medium) diff --git a/problems/accounts-merge/README.md b/problems/accounts-merge/README.md index 6295efa83..90de80088 100644 --- a/problems/accounts-merge/README.md +++ b/problems/accounts-merge/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-word-in-dictionary "Longest Word in Dictionary") +[< Previous](../longest-word-in-dictionary "Longest Word in Dictionary")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-comments "Remove Comments") +[Next >](../remove-comments "Remove Comments") ## [721. Accounts Merge (Medium)](https://leetcode.com/problems/accounts-merge "账户合并") @@ -37,13 +37,13 @@ We could return these lists in any order, for example the answer [['Mary', 'mary

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] ### Similar Questions - 1. [Redundant Connection](https://github.com/openset/leetcode/tree/master/problems/redundant-connection) (Medium) - 1. [Sentence Similarity](https://github.com/openset/leetcode/tree/master/problems/sentence-similarity) (Easy) - 1. [Sentence Similarity II](https://github.com/openset/leetcode/tree/master/problems/sentence-similarity-ii) (Medium) + 1. [Redundant Connection](../redundant-connection) (Medium) + 1. [Sentence Similarity](../sentence-similarity) (Easy) + 1. [Sentence Similarity II](../sentence-similarity-ii) (Medium) ### Hints
diff --git a/problems/active-businesses/README.md b/problems/active-businesses/README.md index 8e9d065da..878048e5d 100644 --- a/problems/active-businesses/README.md +++ b/problems/active-businesses/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/smallest-sufficient-team "Smallest Sufficient Team") +[< Previous](../smallest-sufficient-team "Smallest Sufficient Team")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/user-purchase-platform "User Purchase Platform") +[Next >](../user-purchase-platform "User Purchase Platform") ## [1126. Active Businesses (Medium)](https://leetcode.com/problems/active-businesses "") diff --git a/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md b/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md index 89ca85513..ae617b27c 100644 --- a/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md +++ b/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/last-stone-weight-ii "Last Stone Weight II") +[< Previous](../last-stone-weight-ii "Last Stone Weight II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/height-checker "Height Checker") +[Next >](../height-checker "Height Checker") ## [1050. Actors and Directors Who Cooperated At Least Three Times (Easy)](https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times "合作过至少三次的演员和导演") diff --git a/problems/add-and-search-word-data-structure-design/README.md b/problems/add-and-search-word-data-structure-design/README.md index 16c4681b3..2376f5791 100644 --- a/problems/add-and-search-word-data-structure-design/README.md +++ b/problems/add-and-search-word-data-structure-design/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/course-schedule-ii "Course Schedule II") +[< Previous](../course-schedule-ii "Course Schedule II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/word-search-ii "Word Search II") +[Next >](../word-search-ii "Word Search II") ## [211. Add and Search Word - Data structure design (Medium)](https://leetcode.com/problems/add-and-search-word-data-structure-design "添加与搜索单词 - 数据结构设计") @@ -36,13 +36,13 @@ search("b..") -> true You may assume that all words are consist of lowercase letters a-z.

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Design](../../tag/design/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Implement Trie (Prefix Tree)](https://github.com/openset/leetcode/tree/master/problems/implement-trie-prefix-tree) (Medium) - 1. [Prefix and Suffix Search](https://github.com/openset/leetcode/tree/master/problems/prefix-and-suffix-search) (Hard) + 1. [Implement Trie (Prefix Tree)](../implement-trie-prefix-tree) (Medium) + 1. [Prefix and Suffix Search](../prefix-and-suffix-search) (Hard) ### Hints
diff --git a/problems/add-binary/README.md b/problems/add-binary/README.md index 5e28afa29..98b349191 100644 --- a/problems/add-binary/README.md +++ b/problems/add-binary/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/plus-one "Plus One") +[< Previous](../plus-one "Plus One")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/text-justification "Text Justification") +[Next >](../text-justification "Text Justification") ## [67. Add Binary (Easy)](https://leetcode.com/problems/add-binary "二进制求和") @@ -28,11 +28,11 @@ Output: "10101" ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Add Two Numbers](https://github.com/openset/leetcode/tree/master/problems/add-two-numbers) (Medium) - 1. [Multiply Strings](https://github.com/openset/leetcode/tree/master/problems/multiply-strings) (Medium) - 1. [Plus One](https://github.com/openset/leetcode/tree/master/problems/plus-one) (Easy) - 1. [Add to Array-Form of Integer](https://github.com/openset/leetcode/tree/master/problems/add-to-array-form-of-integer) (Easy) + 1. [Add Two Numbers](../add-two-numbers) (Medium) + 1. [Multiply Strings](../multiply-strings) (Medium) + 1. [Plus One](../plus-one) (Easy) + 1. [Add to Array-Form of Integer](../add-to-array-form-of-integer) (Easy) diff --git a/problems/add-bold-tag-in-string/README.md b/problems/add-bold-tag-in-string/README.md index 1eab22017..9ef927d3d 100644 --- a/problems/add-bold-tag-in-string/README.md +++ b/problems/add-bold-tag-in-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/average-salary-departments-vs-company "Average Salary: Departments VS Company") +[< Previous](../average-salary-departments-vs-company "Average Salary: Departments VS Company")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/merge-two-binary-trees "Merge Two Binary Trees") +[Next >](../merge-two-binary-trees "Merge Two Binary Trees") ## [616. Add Bold Tag in String (Medium)](https://leetcode.com/problems/add-bold-tag-in-string "给字符串添加加粗标签") @@ -41,8 +41,8 @@ dict = ["aaa","aab","bc"]

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Merge Intervals](https://github.com/openset/leetcode/tree/master/problems/merge-intervals) (Medium) - 1. [Tag Validator](https://github.com/openset/leetcode/tree/master/problems/tag-validator) (Hard) + 1. [Merge Intervals](../merge-intervals) (Medium) + 1. [Tag Validator](../tag-validator) (Hard) diff --git a/problems/add-digits/README.md b/problems/add-digits/README.md index c9fffa4c5..e9f8c53bd 100644 --- a/problems/add-digits/README.md +++ b/problems/add-digits/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-tree-paths "Binary Tree Paths") +[< Previous](../binary-tree-paths "Binary Tree Paths")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/3sum-smaller "3Sum Smaller") +[Next >](../3sum-smaller "3Sum Smaller") ## [258. Add Digits (Easy)](https://leetcode.com/problems/add-digits "各位相加") @@ -26,11 +26,11 @@ Could you do it without any loop/recursion in O(1) runtime?

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Happy Number](https://github.com/openset/leetcode/tree/master/problems/happy-number) (Easy) - 1. [Sum of Digits in the Minimum Number](https://github.com/openset/leetcode/tree/master/problems/sum-of-digits-in-the-minimum-number) (Easy) + 1. [Happy Number](../happy-number) (Easy) + 1. [Sum of Digits in the Minimum Number](../sum-of-digits-in-the-minimum-number) (Easy) ### Hints
diff --git a/problems/add-one-row-to-tree/README.md b/problems/add-one-row-to-tree/README.md index bd0c4e102..6f5c67cbf 100644 --- a/problems/add-one-row-to-tree/README.md +++ b/problems/add-one-row-to-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-circular-queue "Design Circular Queue") +[< Previous](../design-circular-queue "Design Circular Queue")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-distance-in-arrays "Maximum Distance in Arrays") +[Next >](../maximum-distance-in-arrays "Maximum Distance in Arrays") ## [623. Add One Row to Tree (Medium)](https://leetcode.com/problems/add-one-row-to-tree "在二叉树中增加一行") @@ -75,4 +75,4 @@ A binary tree as following:

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] diff --git a/problems/add-strings/README.md b/problems/add-strings/README.md index 8bc306acd..f6cabe247 100644 --- a/problems/add-strings/README.md +++ b/problems/add-strings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/third-maximum-number "Third Maximum Number") +[< Previous](../third-maximum-number "Third Maximum Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/partition-equal-subset-sum "Partition Equal Subset Sum") +[Next >](../partition-equal-subset-sum "Partition Equal Subset Sum") ## [415. Add Strings (Easy)](https://leetcode.com/problems/add-strings "字符串相加") @@ -23,9 +23,9 @@

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Add Two Numbers](https://github.com/openset/leetcode/tree/master/problems/add-two-numbers) (Medium) - 1. [Multiply Strings](https://github.com/openset/leetcode/tree/master/problems/multiply-strings) (Medium) - 1. [Add to Array-Form of Integer](https://github.com/openset/leetcode/tree/master/problems/add-to-array-form-of-integer) (Easy) + 1. [Add Two Numbers](../add-two-numbers) (Medium) + 1. [Multiply Strings](../multiply-strings) (Medium) + 1. [Add to Array-Form of Integer](../add-to-array-form-of-integer) (Easy) diff --git a/problems/add-to-array-form-of-integer/README.md b/problems/add-to-array-form-of-integer/README.md index f133d8fce..eba4e731c 100644 --- a/problems/add-to-array-form-of-integer/README.md +++ b/problems/add-to-array-form-of-integer/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/smallest-string-starting-from-leaf "Smallest String Starting From Leaf") +[< Previous](../smallest-string-starting-from-leaf "Smallest String Starting From Leaf")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/satisfiability-of-equality-equations "Satisfiability of Equality Equations") +[Next >](../satisfiability-of-equality-equations "Satisfiability of Equality Equations") ## [989. Add to Array-Form of Integer (Easy)](https://leetcode.com/problems/add-to-array-form-of-integer "数组形式的整数加法") @@ -72,10 +72,10 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Add Two Numbers](https://github.com/openset/leetcode/tree/master/problems/add-two-numbers) (Medium) - 1. [Plus One](https://github.com/openset/leetcode/tree/master/problems/plus-one) (Easy) - 1. [Add Binary](https://github.com/openset/leetcode/tree/master/problems/add-binary) (Easy) - 1. [Add Strings](https://github.com/openset/leetcode/tree/master/problems/add-strings) (Easy) + 1. [Add Two Numbers](../add-two-numbers) (Medium) + 1. [Plus One](../plus-one) (Easy) + 1. [Add Binary](../add-binary) (Easy) + 1. [Add Strings](../add-strings) (Easy) diff --git a/problems/add-two-numbers-ii/README.md b/problems/add-two-numbers-ii/README.md index 30d6b06e9..4ea219910 100644 --- a/problems/add-two-numbers-ii/README.md +++ b/problems/add-two-numbers-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sequence-reconstruction "Sequence Reconstruction") +[< Previous](../sequence-reconstruction "Sequence Reconstruction")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/arithmetic-slices-ii-subsequence "Arithmetic Slices II - Subsequence") +[Next >](../arithmetic-slices-ii-subsequence "Arithmetic Slices II - Subsequence") ## [445. Add Two Numbers II (Medium)](https://leetcode.com/problems/add-two-numbers-ii "两数相加 II") @@ -28,7 +28,7 @@ What if you cannot modify the input lists? In other words, reversing the lists i

### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Add Two Numbers](https://github.com/openset/leetcode/tree/master/problems/add-two-numbers) (Medium) + 1. [Add Two Numbers](../add-two-numbers) (Medium) diff --git a/problems/add-two-numbers/README.md b/problems/add-two-numbers/README.md index 1113d8ea6..f815a5b22 100644 --- a/problems/add-two-numbers/README.md +++ b/problems/add-two-numbers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/two-sum "Two Sum") +[< Previous](../two-sum "Two Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-substring-without-repeating-characters "Longest Substring Without Repeating Characters") +[Next >](../longest-substring-without-repeating-characters "Longest Substring Without Repeating Characters") ## [2. Add Two Numbers (Medium)](https://leetcode.com/problems/add-two-numbers "两数相加") @@ -24,13 +24,13 @@ ### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Multiply Strings](https://github.com/openset/leetcode/tree/master/problems/multiply-strings) (Medium) - 1. [Add Binary](https://github.com/openset/leetcode/tree/master/problems/add-binary) (Easy) - 1. [Sum of Two Integers](https://github.com/openset/leetcode/tree/master/problems/sum-of-two-integers) (Easy) - 1. [Add Strings](https://github.com/openset/leetcode/tree/master/problems/add-strings) (Easy) - 1. [Add Two Numbers II](https://github.com/openset/leetcode/tree/master/problems/add-two-numbers-ii) (Medium) - 1. [Add to Array-Form of Integer](https://github.com/openset/leetcode/tree/master/problems/add-to-array-form-of-integer) (Easy) + 1. [Multiply Strings](../multiply-strings) (Medium) + 1. [Add Binary](../add-binary) (Easy) + 1. [Sum of Two Integers](../sum-of-two-integers) (Easy) + 1. [Add Strings](../add-strings) (Easy) + 1. [Add Two Numbers II](../add-two-numbers-ii) (Medium) + 1. [Add to Array-Form of Integer](../add-to-array-form-of-integer) (Easy) diff --git a/problems/adding-two-negabinary-numbers/README.md b/problems/adding-two-negabinary-numbers/README.md index 41323503a..9f9dbeec8 100644 --- a/problems/adding-two-negabinary-numbers/README.md +++ b/problems/adding-two-negabinary-numbers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/flip-columns-for-maximum-number-of-equal-rows "Flip Columns For Maximum Number of Equal Rows") +[< Previous](../flip-columns-for-maximum-number-of-equal-rows "Flip Columns For Maximum Number of Equal Rows")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-submatrices-that-sum-to-target "Number of Submatrices That Sum to Target") +[Next >](../number-of-submatrices-that-sum-to-target "Number of Submatrices That Sum to Target") ## [1073. Adding Two Negabinary Numbers (Medium)](https://leetcode.com/problems/adding-two-negabinary-numbers "负二进制数相加") @@ -40,7 +40,7 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/additive-number/README.md b/problems/additive-number/README.md index 142fdc4a5..ae071b96f 100644 --- a/problems/additive-number/README.md +++ b/problems/additive-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-islands-ii "Number of Islands II") +[< Previous](../number-of-islands-ii "Number of Islands II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-mutable "Range Sum Query - Mutable") +[Next >](../range-sum-query-mutable "Range Sum Query - Mutable") ## [306. Additive Number (Medium)](https://leetcode.com/problems/additive-number "累加数") @@ -50,7 +50,7 @@ How would you handle overflow for very large input integers?

### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Split Array into Fibonacci Sequence](https://github.com/openset/leetcode/tree/master/problems/split-array-into-fibonacci-sequence) (Medium) + 1. [Split Array into Fibonacci Sequence](../split-array-into-fibonacci-sequence) (Medium) diff --git a/problems/advantage-shuffle/README.md b/problems/advantage-shuffle/README.md index a3ca3e455..4e521fc07 100644 --- a/problems/advantage-shuffle/README.md +++ b/problems/advantage-shuffle/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reordered-power-of-2 "Reordered Power of 2") +[< Previous](../reordered-power-of-2 "Reordered Power of 2")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-refueling-stops "Minimum Number of Refueling Stops") +[Next >](../minimum-number-of-refueling-stops "Minimum Number of Refueling Stops") ## [870. Advantage Shuffle (Medium)](https://leetcode.com/problems/advantage-shuffle "优势洗牌") @@ -46,5 +46,5 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/airplane-seat-assignment-probability/README.md b/problems/airplane-seat-assignment-probability/README.md index a60966ce1..9d9f33ae7 100644 --- a/problems/airplane-seat-assignment-probability/README.md +++ b/problems/airplane-seat-assignment-probability/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/the-dining-philosophers "The Dining Philosophers") +[< Previous](../the-dining-philosophers "The Dining Philosophers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/missing-number-in-arithmetic-progression "Missing Number In Arithmetic Progression") +[Next >](../missing-number-in-arithmetic-progression "Missing Number In Arithmetic Progression") ## [1227. Airplane Seat Assignment Probability (Medium)](https://leetcode.com/problems/airplane-seat-assignment-probability "飞机座位分配概率") @@ -44,9 +44,9 @@ ### Related Topics - [[Brainteaser](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Brainteaser](../../tag/brainteaser/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/alien-dictionary/README.md b/problems/alien-dictionary/README.md index bdc4613eb..e22b338d5 100644 --- a/problems/alien-dictionary/README.md +++ b/problems/alien-dictionary/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/missing-number "Missing Number") +[< Previous](../missing-number "Missing Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/closest-binary-search-tree-value "Closest Binary Search Tree Value") +[Next >](../closest-binary-search-tree-value "Closest Binary Search Tree Value") ## [269. Alien Dictionary (Hard)](https://leetcode.com/problems/alien-dictionary "火星词典") @@ -65,8 +65,8 @@ ### Related Topics - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] - [[Topological Sort](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] ### Similar Questions - 1. [Course Schedule II](https://github.com/openset/leetcode/tree/master/problems/course-schedule-ii) (Medium) + 1. [Course Schedule II](../course-schedule-ii) (Medium) diff --git a/problems/all-nodes-distance-k-in-binary-tree/README.md b/problems/all-nodes-distance-k-in-binary-tree/README.md index 05f76b748..6fd3d78fb 100644 --- a/problems/all-nodes-distance-k-in-binary-tree/README.md +++ b/problems/all-nodes-distance-k-in-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-subarray-with-sum-at-least-k "Shortest Subarray with Sum at Least K") +[< Previous](../shortest-subarray-with-sum-at-least-k "Shortest Subarray with Sum at Least K")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-path-to-get-all-keys "Shortest Path to Get All Keys") +[Next >](../shortest-path-to-get-all-keys "Shortest Path to Get All Keys") ## [863. All Nodes Distance K in Binary Tree (Medium)](https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree "二叉树中所有距离为 K 的结点") @@ -51,6 +51,6 @@ The descriptions of the inputs above are just serializations of these objects. ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/all-oone-data-structure/README.md b/problems/all-oone-data-structure/README.md index f52cb3bc1..ad1753225 100644 --- a/problems/all-oone-data-structure/README.md +++ b/problems/all-oone-data-structure/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/encode-n-ary-tree-to-binary-tree "Encode N-ary Tree to Binary Tree") +[< Previous](../encode-n-ary-tree-to-binary-tree "Encode N-ary Tree to Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-genetic-mutation "Minimum Genetic Mutation") +[Next >](../minimum-genetic-mutation "Minimum Genetic Mutation") ## [432. All O`one Data Structure (Hard)](https://leetcode.com/problems/all-oone-data-structure "全 O(1) 的数据结构") @@ -27,4 +27,4 @@ Challenge: Perform all these in O(1) time complexity.

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Design](../../tag/design/README.md)] diff --git a/problems/all-paths-from-source-lead-to-destination/README.md b/problems/all-paths-from-source-lead-to-destination/README.md index aa6b72a74..1d060ff6f 100644 --- a/problems/all-paths-from-source-lead-to-destination/README.md +++ b/problems/all-paths-from-source-lead-to-destination/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimize-rounding-error-to-meet-target "Minimize Rounding Error to Meet Target") +[< Previous](../minimize-rounding-error-to-meet-target "Minimize Rounding Error to Meet Target")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/missing-element-in-sorted-array "Missing Element in Sorted Array") +[Next >](../missing-element-in-sorted-array "Missing Element in Sorted Array") ## [1059. All Paths from Source Lead to Destination (Medium)](https://leetcode.com/problems/all-paths-from-source-lead-to-destination "从始点到终点的所有路径") @@ -87,8 +87,8 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] ### Hints
diff --git a/problems/all-paths-from-source-to-target/README.md b/problems/all-paths-from-source-to-target/README.md index 443fbc65d..eb3504a37 100644 --- a/problems/all-paths-from-source-to-target/README.md +++ b/problems/all-paths-from-source-to-target/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/rotate-string "Rotate String") +[< Previous](../rotate-string "Rotate String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/smallest-rotation-with-highest-score "Smallest Rotation with Highest Score") +[Next >](../smallest-rotation-with-highest-score "Smallest Rotation with Highest Score") ## [797. All Paths From Source to Target (Medium)](https://leetcode.com/problems/all-paths-from-source-to-target "所有可能的路径") diff --git a/problems/all-people-report-to-the-given-manager/README.md b/problems/all-people-report-to-the-given-manager/README.md index bdf841497..785024bfe 100644 --- a/problems/all-people-report-to-the-given-manager/README.md +++ b/problems/all-people-report-to-the-given-manager/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps "Number of Ways to Stay in the Same Place After Some Steps") +[< Previous](../number-of-ways-to-stay-in-the-same-place-after-some-steps "Number of Ways to Stay in the Same Place After Some Steps")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/hexspeak "Hexspeak") +[Next >](../hexspeak "Hexspeak") ## [1270. All People Report to the Given Manager (Medium)](https://leetcode.com/problems/all-people-report-to-the-given-manager "") diff --git a/problems/all-possible-full-binary-trees/README.md b/problems/all-possible-full-binary-trees/README.md index 474f5c885..168409c86 100644 --- a/problems/all-possible-full-binary-trees/README.md +++ b/problems/all-possible-full-binary-trees/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/groups-of-special-equivalent-strings "Groups of Special-Equivalent Strings") +[< Previous](../groups-of-special-equivalent-strings "Groups of Special-Equivalent Strings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-frequency-stack "Maximum Frequency Stack") +[Next >](../maximum-frequency-stack "Maximum Frequency Stack") ## [894. All Possible Full Binary Trees (Medium)](https://leetcode.com/problems/all-possible-full-binary-trees "所有可能的满二叉树") @@ -39,5 +39,5 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Recursion](../../tag/recursion/README.md)] diff --git a/problems/alphabet-board-path/README.md b/problems/alphabet-board-path/README.md index 61aa1efa8..c5062fab4 100644 --- a/problems/alphabet-board-path/README.md +++ b/problems/alphabet-board-path/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/n-th-tribonacci-number "N-th Tribonacci Number") +[< Previous](../n-th-tribonacci-number "N-th Tribonacci Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/largest-1-bordered-square "Largest 1-Bordered Square") +[Next >](../largest-1-bordered-square "Largest 1-Bordered Square") ## [1138. Alphabet Board Path (Medium)](https://leetcode.com/problems/alphabet-board-path "字母板上的路径") @@ -48,8 +48,8 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/ambiguous-coordinates/README.md b/problems/ambiguous-coordinates/README.md index 456d7ee44..a0f719e6e 100644 --- a/problems/ambiguous-coordinates/README.md +++ b/problems/ambiguous-coordinates/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/bus-routes "Bus Routes") +[< Previous](../bus-routes "Bus Routes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/linked-list-components "Linked List Components") +[Next >](../linked-list-components "Linked List Components") ## [816. Ambiguous Coordinates (Medium)](https://leetcode.com/problems/ambiguous-coordinates "模糊坐标") @@ -57,4 +57,4 @@

 

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/analyze-user-website-visit-pattern/README.md b/problems/analyze-user-website-visit-pattern/README.md index 7d6d64da4..3781f2f65 100644 --- a/problems/analyze-user-website-visit-pattern/README.md +++ b/problems/analyze-user-website-visit-pattern/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-swaps-to-group-all-1s-together "Minimum Swaps to Group All 1's Together") +[< Previous](../minimum-swaps-to-group-all-1s-together "Minimum Swaps to Group All 1's Together")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/string-transforms-into-another-string "String Transforms Into Another String") +[Next >](../string-transforms-into-another-string "String Transforms Into Another String") ## [1152. Analyze User Website Visit Pattern (Medium)](https://leetcode.com/problems/analyze-user-website-visit-pattern "用户网站访问行为分析") @@ -58,9 +58,9 @@ The 3-sequence ("cart", "maps", "home") was visite ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
diff --git a/problems/android-unlock-patterns/README.md b/problems/android-unlock-patterns/README.md index 78c379a38..9d96cd889 100644 --- a/problems/android-unlock-patterns/README.md +++ b/problems/android-unlock-patterns/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays-ii "Intersection of Two Arrays II") +[< Previous](../intersection-of-two-arrays-ii "Intersection of Two Arrays II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/data-stream-as-disjoint-intervals "Data Stream as Disjoint Intervals") +[Next >](../data-stream-as-disjoint-intervals "Data Stream as Disjoint Intervals") ## [351. Android Unlock Patterns (Medium)](https://leetcode.com/problems/android-unlock-patterns "安卓系统手势解锁") @@ -61,5 +61,5 @@ Line 1 - 9 is valid because it passes through key 5, which had been selected in ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/arithmetic-slices-ii-subsequence/README.md b/problems/arithmetic-slices-ii-subsequence/README.md index 98f442f54..ade7bc39a 100644 --- a/problems/arithmetic-slices-ii-subsequence/README.md +++ b/problems/arithmetic-slices-ii-subsequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/add-two-numbers-ii "Add Two Numbers II") +[< Previous](../add-two-numbers-ii "Add Two Numbers II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-boomerangs "Number of Boomerangs") +[Next >](../number-of-boomerangs "Number of Boomerangs") ## [446. Arithmetic Slices II - Subsequence (Hard)](https://leetcode.com/problems/arithmetic-slices-ii-subsequence "等差数列划分 II - 子序列") @@ -54,7 +54,7 @@ All arithmetic subsequence slices are: ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Arithmetic Slices](https://github.com/openset/leetcode/tree/master/problems/arithmetic-slices) (Medium) + 1. [Arithmetic Slices](../arithmetic-slices) (Medium) diff --git a/problems/arithmetic-slices/README.md b/problems/arithmetic-slices/README.md index 558f11dcb..b4a2e552f 100644 --- a/problems/arithmetic-slices/README.md +++ b/problems/arithmetic-slices/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/fizz-buzz "Fizz Buzz") +[< Previous](../fizz-buzz "Fizz Buzz")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/third-maximum-number "Third Maximum Number") +[Next >](../third-maximum-number "Third Maximum Number") ## [413. Arithmetic Slices (Medium)](https://leetcode.com/problems/arithmetic-slices "等差数列划分") @@ -37,8 +37,8 @@ return: 3, for 3 arithmetic slices in A: [1, 2, 3], [2, 3, 4] and [1, 2, 3, 4] i ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Arithmetic Slices II - Subsequence](https://github.com/openset/leetcode/tree/master/problems/arithmetic-slices-ii-subsequence) (Hard) + 1. [Arithmetic Slices II - Subsequence](../arithmetic-slices-ii-subsequence) (Hard) diff --git a/problems/armstrong-number/README.md b/problems/armstrong-number/README.md index 53a0fdd8a..2a5aef613 100644 --- a/problems/armstrong-number/README.md +++ b/problems/armstrong-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/largest-unique-number "Largest Unique Number") +[< Previous](../largest-unique-number "Largest Unique Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/connecting-cities-with-minimum-cost "Connecting Cities With Minimum Cost") +[Next >](../connecting-cities-with-minimum-cost "Connecting Cities With Minimum Cost") ## [1134. Armstrong Number (Easy)](https://leetcode.com/problems/armstrong-number "阿姆斯特朗数") @@ -44,7 +44,7 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/arranging-coins/README.md b/problems/arranging-coins/README.md index b36f01797..92d356733 100644 --- a/problems/arranging-coins/README.md +++ b/problems/arranging-coins/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/k-th-smallest-in-lexicographical-order "K-th Smallest in Lexicographical Order") +[< Previous](../k-th-smallest-in-lexicographical-order "K-th Smallest in Lexicographical Order")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-all-duplicates-in-an-array "Find All Duplicates in an Array") +[Next >](../find-all-duplicates-in-an-array "Find All Duplicates in an Array") ## [441. Arranging Coins (Easy)](https://leetcode.com/problems/arranging-coins "排列硬币") @@ -45,5 +45,5 @@ Because the 4th row is incomplete, we return 3.

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/array-nesting/README.md b/problems/array-nesting/README.md index bacb1b266..eb472d3dd 100644 --- a/problems/array-nesting/README.md +++ b/problems/array-nesting/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-the-closest-palindrome "Find the Closest Palindrome") +[< Previous](../find-the-closest-palindrome "Find the Closest Palindrome")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reshape-the-matrix "Reshape the Matrix") +[Next >](../reshape-the-matrix "Reshape the Matrix") ## [565. Array Nesting (Medium)](https://leetcode.com/problems/array-nesting "数组嵌套") @@ -40,9 +40,9 @@ S[0] = {A[0], A[5], A[6], A[2]} = {5, 6, 2, 0} ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Nested List Weight Sum](https://github.com/openset/leetcode/tree/master/problems/nested-list-weight-sum) (Easy) - 1. [Flatten Nested List Iterator](https://github.com/openset/leetcode/tree/master/problems/flatten-nested-list-iterator) (Medium) - 1. [Nested List Weight Sum II](https://github.com/openset/leetcode/tree/master/problems/nested-list-weight-sum-ii) (Medium) + 1. [Nested List Weight Sum](../nested-list-weight-sum) (Easy) + 1. [Flatten Nested List Iterator](../flatten-nested-list-iterator) (Medium) + 1. [Nested List Weight Sum II](../nested-list-weight-sum-ii) (Medium) diff --git a/problems/array-of-doubled-pairs/README.md b/problems/array-of-doubled-pairs/README.md index 57aa8de4f..dd4cc0d38 100644 --- a/problems/array-of-doubled-pairs/README.md +++ b/problems/array-of-doubled-pairs/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/verifying-an-alien-dictionary "Verifying an Alien Dictionary") +[< Previous](../verifying-an-alien-dictionary "Verifying an Alien Dictionary")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/delete-columns-to-make-sorted-ii "Delete Columns to Make Sorted II") +[Next >](../delete-columns-to-make-sorted-ii "Delete Columns to Make Sorted II") ## [954. Array of Doubled Pairs (Medium)](https://leetcode.com/problems/array-of-doubled-pairs "二倍数对数组") @@ -72,5 +72,5 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/array-partition-i/README.md b/problems/array-partition-i/README.md index 77ae9f4b1..87b67dbcc 100644 --- a/problems/array-partition-i/README.md +++ b/problems/array-partition-i/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/subarray-sum-equals-k "Subarray Sum Equals K") +[< Previous](../subarray-sum-equals-k "Subarray Sum Equals K")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-line-of-consecutive-one-in-matrix "Longest Line of Consecutive One in Matrix") +[Next >](../longest-line-of-consecutive-one-in-matrix "Longest Line of Consecutive One in Matrix") ## [561. Array Partition I (Easy)](https://leetcode.com/problems/array-partition-i "数组拆分 I") @@ -32,7 +32,7 @@ Given an array of 2n integers, your task is to group these integers into

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/array-transformation/README.md b/problems/array-transformation/README.md index 8f58ab5f8..4cccdf1d6 100644 --- a/problems/array-transformation/README.md +++ b/problems/array-transformation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/web-crawler-multithreaded "Web Crawler Multithreaded") +[< Previous](../web-crawler-multithreaded "Web Crawler Multithreaded")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-a-leaderboard "Design A Leaderboard") +[Next >](../design-a-leaderboard "Design A Leaderboard") ## [1243. Array Transformation (Easy)](https://leetcode.com/problems/array-transformation "数组变换") @@ -54,7 +54,7 @@ No more operations can be done to this array. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/article-views-i/README.md b/problems/article-views-i/README.md index 922b62dcb..2fe77f6d6 100644 --- a/problems/article-views-i/README.md +++ b/problems/article-views-i/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-chunked-palindrome-decomposition "Longest Chunked Palindrome Decomposition") +[< Previous](../longest-chunked-palindrome-decomposition "Longest Chunked Palindrome Decomposition")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/article-views-ii "Article Views II") +[Next >](../article-views-ii "Article Views II") ## [1148. Article Views I (Easy)](https://leetcode.com/problems/article-views-i "文章浏览 I") diff --git a/problems/article-views-ii/README.md b/problems/article-views-ii/README.md index f1e120c7e..f2d98b111 100644 --- a/problems/article-views-ii/README.md +++ b/problems/article-views-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/article-views-i "Article Views I") +[< Previous](../article-views-i "Article Views I")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/check-if-a-number-is-majority-element-in-a-sorted-array "Check If a Number Is Majority Element in a Sorted Array") +[Next >](../check-if-a-number-is-majority-element-in-a-sorted-array "Check If a Number Is Majority Element in a Sorted Array") ## [1149. Article Views II (Medium)](https://leetcode.com/problems/article-views-ii "") diff --git a/problems/as-far-from-land-as-possible/README.md b/problems/as-far-from-land-as-possible/README.md index 108a4ee86..827a3150a 100644 --- a/problems/as-far-from-land-as-possible/README.md +++ b/problems/as-far-from-land-as-possible/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-level-sum-of-a-binary-tree "Maximum Level Sum of a Binary Tree") +[< Previous](../maximum-level-sum-of-a-binary-tree "Maximum Level Sum of a Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/last-substring-in-lexicographical-order "Last Substring in Lexicographical Order") +[Next >](../last-substring-in-lexicographical-order "Last Substring in Lexicographical Order") ## [1162. As Far from Land as Possible (Medium)](https://leetcode.com/problems/as-far-from-land-as-possible "地图分析") @@ -51,11 +51,11 @@ The cell (2, 2) is as far as possible from all the land with distance 4. ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] ### Similar Questions - 1. [Shortest Distance from All Buildings](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-from-all-buildings) (Hard) + 1. [Shortest Distance from All Buildings](../shortest-distance-from-all-buildings) (Hard) ### Hints
diff --git a/problems/assign-cookies/README.md b/problems/assign-cookies/README.md index 4fd1ef220..c72fedcb4 100644 --- a/problems/assign-cookies/README.md +++ b/problems/assign-cookies/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/4sum-ii "4Sum II") +[< Previous](../4sum-ii "4Sum II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/132-pattern "132 Pattern") +[Next >](../132-pattern "132 Pattern") ## [455. Assign Cookies (Easy)](https://leetcode.com/problems/assign-cookies "分发饼干") @@ -45,4 +45,4 @@ You need to output 2.

### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/asteroid-collision/README.md b/problems/asteroid-collision/README.md index b8a2887d6..58ce6d9fd 100644 --- a/problems/asteroid-collision/README.md +++ b/problems/asteroid-collision/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sentence-similarity "Sentence Similarity") +[< Previous](../sentence-similarity "Sentence Similarity")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/parse-lisp-expression "Parse Lisp Expression") +[Next >](../parse-lisp-expression "Parse Lisp Expression") ## [735. Asteroid Collision (Medium)](https://leetcode.com/problems/asteroid-collision "行星碰撞") @@ -66,10 +66,10 @@ Asteroids moving the same direction never meet, so no asteroids will meet each o

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] + [[Stack](../../tag/stack/README.md)] ### Similar Questions - 1. [Can Place Flowers](https://github.com/openset/leetcode/tree/master/problems/can-place-flowers) (Easy) + 1. [Can Place Flowers](../can-place-flowers) (Easy) ### Hints
diff --git a/problems/available-captures-for-rook/README.md b/problems/available-captures-for-rook/README.md index 4efa68d81..77dac0fc4 100644 --- a/problems/available-captures-for-rook/README.md +++ b/problems/available-captures-for-rook/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-binary-tree-ii "Maximum Binary Tree II") +[< Previous](../maximum-binary-tree-ii "Maximum Binary Tree II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-to-merge-stones "Minimum Cost to Merge Stones") +[Next >](../minimum-cost-to-merge-stones "Minimum Cost to Merge Stones") ## [999. Available Captures for Rook (Easy)](https://leetcode.com/problems/available-captures-for-rook "车的可用捕获量") @@ -63,4 +63,4 @@ The rook can capture the pawns at positions b5, d6 and f5. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/average-of-levels-in-binary-tree/README.md b/problems/average-of-levels-in-binary-tree/README.md index 9d7ddcafb..14a2b4973 100644 --- a/problems/average-of-levels-in-binary-tree/README.md +++ b/problems/average-of-levels-in-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/exclusive-time-of-functions "Exclusive Time of Functions") +[< Previous](../exclusive-time-of-functions "Exclusive Time of Functions")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shopping-offers "Shopping Offers") +[Next >](../shopping-offers "Shopping Offers") ## [637. Average of Levels in Binary Tree (Easy)](https://leetcode.com/problems/average-of-levels-in-binary-tree "二叉树的层平均值") @@ -34,8 +34,8 @@ The average value of nodes on level 0 is 3, on level 1 is 14.5, and on level 2

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Binary Tree Level Order Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal) (Medium) - 1. [Binary Tree Level Order Traversal II](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal-ii) (Easy) + 1. [Binary Tree Level Order Traversal](../binary-tree-level-order-traversal) (Medium) + 1. [Binary Tree Level Order Traversal II](../binary-tree-level-order-traversal-ii) (Easy) diff --git a/problems/average-salary-departments-vs-company/README.md b/problems/average-salary-departments-vs-company/README.md index 3ca09ca73..6374e1e70 100644 --- a/problems/average-salary-departments-vs-company/README.md +++ b/problems/average-salary-departments-vs-company/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/second-degree-follower "Second Degree Follower") +[< Previous](../second-degree-follower "Second Degree Follower")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/add-bold-tag-in-string "Add Bold Tag in String") +[Next >](../add-bold-tag-in-string "Add Bold Tag in String") ## [615. Average Salary: Departments VS Company (Hard)](https://leetcode.com/problems/average-salary-departments-vs-company "平均工资:部门与公司比较") diff --git a/problems/average-selling-price/README.md b/problems/average-selling-price/README.md index 9b8663ded..db5550bb4 100644 --- a/problems/average-selling-price/README.md +++ b/problems/average-selling-price/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/check-if-it-is-a-good-array "Check If It Is a Good Array") +[< Previous](../check-if-it-is-a-good-array "Check If It Is a Good Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/cells-with-odd-values-in-a-matrix "Cells with Odd Values in a Matrix") +[Next >](../cells-with-odd-values-in-a-matrix "Cells with Odd Values in a Matrix") ## [1251. Average Selling Price (Easy)](https://leetcode.com/problems/average-selling-price "") diff --git a/problems/backspace-string-compare/README.md b/problems/backspace-string-compare/README.md index 74c1bec95..45441ffdd 100644 --- a/problems/backspace-string-compare/README.md +++ b/problems/backspace-string-compare/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/guess-the-word "Guess the Word") +[< Previous](../guess-the-word "Guess the Word")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-mountain-in-array "Longest Mountain in Array") +[Next >](../longest-mountain-in-array "Longest Mountain in Array") ## [844. Backspace String Compare (Easy)](https://leetcode.com/problems/backspace-string-compare "比较含退格的字符串") @@ -68,5 +68,5 @@ ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/bag-of-tokens/README.md b/problems/bag-of-tokens/README.md index cd950c911..d64b7f916 100644 --- a/problems/bag-of-tokens/README.md +++ b/problems/bag-of-tokens/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/most-stones-removed-with-same-row-or-column "Most Stones Removed with Same Row or Column") +[< Previous](../most-stones-removed-with-same-row-or-column "Most Stones Removed with Same Row or Column")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/largest-time-for-given-digits "Largest Time for Given Digits") +[Next >](../largest-time-for-given-digits "Largest Time for Given Digits") ## [948. Bag of Tokens (Medium)](https://leetcode.com/problems/bag-of-tokens "令牌放置") @@ -65,4 +65,4 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/balanced-binary-tree/README.md b/problems/balanced-binary-tree/README.md index 4a90626f4..5a8f78860 100644 --- a/problems/balanced-binary-tree/README.md +++ b/problems/balanced-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/convert-sorted-list-to-binary-search-tree "Convert Sorted List to Binary Search Tree") +[< Previous](../convert-sorted-list-to-binary-search-tree "Convert Sorted List to Binary Search Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-depth-of-binary-tree "Minimum Depth of Binary Tree") +[Next >](../minimum-depth-of-binary-tree "Minimum Depth of Binary Tree") ## [110. Balanced Binary Tree (Easy)](https://leetcode.com/problems/balanced-binary-tree "平衡二叉树") @@ -51,8 +51,8 @@

Return false.

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Maximum Depth of Binary Tree](https://github.com/openset/leetcode/tree/master/problems/maximum-depth-of-binary-tree) (Easy) + 1. [Maximum Depth of Binary Tree](../maximum-depth-of-binary-tree) (Easy) diff --git a/problems/base-7/README.md b/problems/base-7/README.md index 7d207887d..a3c89ea91 100644 --- a/problems/base-7/README.md +++ b/problems/base-7/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-ii "Next Greater Element II") +[< Previous](../next-greater-element-ii "Next Greater Element II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/the-maze-ii "The Maze II") +[Next >](../the-maze-ii "The Maze II") ## [504. Base 7 (Easy)](https://leetcode.com/problems/base-7 "七进制数") diff --git a/problems/baseball-game/README.md b/problems/baseball-game/README.md index 72c31eabf..c938d3158 100644 --- a/problems/baseball-game/README.md +++ b/problems/baseball-game/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/next-closest-time "Next Closest Time") +[< Previous](../next-closest-time "Next Closest Time")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/k-empty-slots "K Empty Slots") +[Next >](../k-empty-slots "K Empty Slots") ## [682. Baseball Game (Easy)](https://leetcode.com/problems/baseball-game "棒球比赛") @@ -68,4 +68,4 @@ Round 7: You could get 9 + 5 = 14 points. The sum is 27.

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] + [[Stack](../../tag/stack/README.md)] diff --git a/problems/basic-calculator-ii/README.md b/problems/basic-calculator-ii/README.md index 4c9974439..76950166f 100644 --- a/problems/basic-calculator-ii/README.md +++ b/problems/basic-calculator-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/invert-binary-tree "Invert Binary Tree") +[< Previous](../invert-binary-tree "Invert Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/summary-ranges "Summary Ranges") +[Next >](../summary-ranges "Summary Ranges") ## [227. Basic Calculator II (Medium)](https://leetcode.com/problems/basic-calculator-ii "基本计算器 II") @@ -43,9 +43,9 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Basic Calculator](https://github.com/openset/leetcode/tree/master/problems/basic-calculator) (Hard) - 1. [Expression Add Operators](https://github.com/openset/leetcode/tree/master/problems/expression-add-operators) (Hard) - 1. [Basic Calculator III](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iii) (Hard) + 1. [Basic Calculator](../basic-calculator) (Hard) + 1. [Expression Add Operators](../expression-add-operators) (Hard) + 1. [Basic Calculator III](../basic-calculator-iii) (Hard) diff --git a/problems/basic-calculator-iii/README.md b/problems/basic-calculator-iii/README.md index d3732386a..2cb1dd8ba 100644 --- a/problems/basic-calculator-iii/README.md +++ b/problems/basic-calculator-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/jewels-and-stones "Jewels and Stones") +[< Previous](../jewels-and-stones "Jewels and Stones")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sliding-puzzle "Sliding Puzzle") +[Next >](../sliding-puzzle "Sliding Puzzle") ## [772. Basic Calculator III (Hard)](https://leetcode.com/problems/basic-calculator-iii "基本计算器 III") @@ -33,10 +33,10 @@

Note: Do not use the eval built-in library function.

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Basic Calculator](https://github.com/openset/leetcode/tree/master/problems/basic-calculator) (Hard) - 1. [Basic Calculator II](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-ii) (Medium) - 1. [Basic Calculator IV](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iv) (Hard) + 1. [Basic Calculator](../basic-calculator) (Hard) + 1. [Basic Calculator II](../basic-calculator-ii) (Medium) + 1. [Basic Calculator IV](../basic-calculator-iv) (Hard) diff --git a/problems/basic-calculator-iv/README.md b/problems/basic-calculator-iv/README.md index 16b146ec8..e4b997d41 100644 --- a/problems/basic-calculator-iv/README.md +++ b/problems/basic-calculator-iv/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/max-chunks-to-make-sorted "Max Chunks To Make Sorted") +[< Previous](../max-chunks-to-make-sorted "Max Chunks To Make Sorted")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/jewels-and-stones "Jewels and Stones") +[Next >](../jewels-and-stones "Jewels and Stones") ## [770. Basic Calculator IV (Hard)](https://leetcode.com/problems/basic-calculator-iv "基本计算器 IV") @@ -63,13 +63,13 @@ evalvars = [], evalints = [] ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Parse Lisp Expression](https://github.com/openset/leetcode/tree/master/problems/parse-lisp-expression) (Hard) - 1. [Basic Calculator III](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iii) (Hard) + 1. [Parse Lisp Expression](../parse-lisp-expression) (Hard) + 1. [Basic Calculator III](../basic-calculator-iii) (Hard) ### Hints
diff --git a/problems/basic-calculator/README.md b/problems/basic-calculator/README.md index 552780bfe..ce4653dd8 100644 --- a/problems/basic-calculator/README.md +++ b/problems/basic-calculator/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/rectangle-area "Rectangle Area") +[< Previous](../rectangle-area "Rectangle Area")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/implement-stack-using-queues "Implement Stack using Queues") +[Next >](../implement-stack-using-queues "Implement Stack using Queues") ## [224. Basic Calculator (Hard)](https://leetcode.com/problems/basic-calculator "基本计算器") @@ -41,12 +41,12 @@ ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Evaluate Reverse Polish Notation](https://github.com/openset/leetcode/tree/master/problems/evaluate-reverse-polish-notation) (Medium) - 1. [Basic Calculator II](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-ii) (Medium) - 1. [Different Ways to Add Parentheses](https://github.com/openset/leetcode/tree/master/problems/different-ways-to-add-parentheses) (Medium) - 1. [Expression Add Operators](https://github.com/openset/leetcode/tree/master/problems/expression-add-operators) (Hard) - 1. [Basic Calculator III](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iii) (Hard) + 1. [Evaluate Reverse Polish Notation](../evaluate-reverse-polish-notation) (Medium) + 1. [Basic Calculator II](../basic-calculator-ii) (Medium) + 1. [Different Ways to Add Parentheses](../different-ways-to-add-parentheses) (Medium) + 1. [Expression Add Operators](../expression-add-operators) (Hard) + 1. [Basic Calculator III](../basic-calculator-iii) (Hard) diff --git a/problems/battleships-in-a-board/README.md b/problems/battleships-in-a-board/README.md index 7b49edcc7..1dc1ee558 100644 --- a/problems/battleships-in-a-board/README.md +++ b/problems/battleships-in-a-board/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sentence-screen-fitting "Sentence Screen Fitting") +[< Previous](../sentence-screen-fitting "Sentence Screen Fitting")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/strong-password-checker "Strong Password Checker") +[Next >](../strong-password-checker "Strong Password Checker") ## [419. Battleships in a Board (Medium)](https://leetcode.com/problems/battleships-in-a-board "甲板上的战舰") diff --git a/problems/beautiful-arrangement-ii/README.md b/problems/beautiful-arrangement-ii/README.md index 4050dc888..52657c08b 100644 --- a/problems/beautiful-arrangement-ii/README.md +++ b/problems/beautiful-arrangement-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/path-sum-iv "Path Sum IV") +[< Previous](../path-sum-iv "Path Sum IV")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-number-in-multiplication-table "Kth Smallest Number in Multiplication Table") +[Next >](../kth-smallest-number-in-multiplication-table "Kth Smallest Number in Multiplication Table") ## [667. Beautiful Arrangement II (Medium)](https://leetcode.com/problems/beautiful-arrangement-ii "优美的排列 II") @@ -44,7 +44,7 @@ If there are multiple answers, print any of them.

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Beautiful Arrangement](https://github.com/openset/leetcode/tree/master/problems/beautiful-arrangement) (Medium) + 1. [Beautiful Arrangement](../beautiful-arrangement) (Medium) diff --git a/problems/beautiful-arrangement/README.md b/problems/beautiful-arrangement/README.md index 7a772f6ae..e49690af1 100644 --- a/problems/beautiful-arrangement/README.md +++ b/problems/beautiful-arrangement/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/contiguous-array "Contiguous Array") +[< Previous](../contiguous-array "Contiguous Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/word-abbreviation "Word Abbreviation") +[Next >](../word-abbreviation "Word Abbreviation") ## [526. Beautiful Arrangement (Medium)](https://leetcode.com/problems/beautiful-arrangement "优美的排列") @@ -53,7 +53,7 @@ Number at the 2nd position (i=2) is 1, and i (i=2) is divisible by 1.

 

### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Beautiful Arrangement II](https://github.com/openset/leetcode/tree/master/problems/beautiful-arrangement-ii) (Medium) + 1. [Beautiful Arrangement II](../beautiful-arrangement-ii) (Medium) diff --git a/problems/beautiful-array/README.md b/problems/beautiful-array/README.md index e04ac68e7..3d8ca7a50 100644 --- a/problems/beautiful-array/README.md +++ b/problems/beautiful-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-falling-path-sum "Minimum Falling Path Sum") +[< Previous](../minimum-falling-path-sum "Minimum Falling Path Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-recent-calls "Number of Recent Calls") +[Next >](../number-of-recent-calls "Number of Recent Calls") ## [932. Beautiful Array (Medium)](https://leetcode.com/problems/beautiful-array "漂亮数组") @@ -47,4 +47,4 @@ ### Related Topics - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] diff --git a/problems/before-and-after-puzzle/README.md b/problems/before-and-after-puzzle/README.md index 0388bcaa9..d11a38180 100644 --- a/problems/before-and-after-puzzle/README.md +++ b/problems/before-and-after-puzzle/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/count-substrings-with-only-one-distinct-letter "Count Substrings with Only One Distinct Letter") +[< Previous](../count-substrings-with-only-one-distinct-letter "Count Substrings with Only One Distinct Letter")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-to-target-color "Shortest Distance to Target Color") +[Next >](../shortest-distance-to-target-color "Shortest Distance to Target Color") ## [1181. Before and After Puzzle (Medium)](https://leetcode.com/problems/before-and-after-puzzle "前后拼接") @@ -64,7 +64,7 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/best-meeting-point/README.md b/problems/best-meeting-point/README.md index 8f39648d6..bb2a41eb3 100644 --- a/problems/best-meeting-point/README.md +++ b/problems/best-meeting-point/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-median-from-data-stream "Find Median from Data Stream") +[< Previous](../find-median-from-data-stream "Find Median from Data Stream")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-binary-tree "Serialize and Deserialize Binary Tree") +[Next >](../serialize-and-deserialize-binary-tree "Serialize and Deserialize Binary Tree") ## [296. Best Meeting Point (Hard)](https://leetcode.com/problems/best-meeting-point "最佳的碰头地点") @@ -31,12 +31,12 @@ Explanation: Given three people living at (0,0), (0,   of 2+2+2=6 is minimal. So return 6. ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Shortest Distance from All Buildings](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-from-all-buildings) (Hard) - 1. [Minimum Moves to Equal Array Elements II](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-equal-array-elements-ii) (Medium) + 1. [Shortest Distance from All Buildings](../shortest-distance-from-all-buildings) (Hard) + 1. [Minimum Moves to Equal Array Elements II](../minimum-moves-to-equal-array-elements-ii) (Medium) ### Hints
diff --git a/problems/best-sightseeing-pair/README.md b/problems/best-sightseeing-pair/README.md index d7fcb6cb2..73535759b 100644 --- a/problems/best-sightseeing-pair/README.md +++ b/problems/best-sightseeing-pair/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/partition-array-into-three-parts-with-equal-sum "Partition Array Into Three Parts With Equal Sum") +[< Previous](../partition-array-into-three-parts-with-equal-sum "Partition Array Into Three Parts With Equal Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/smallest-integer-divisible-by-k "Smallest Integer Divisible by K") +[Next >](../smallest-integer-divisible-by-k "Smallest Integer Divisible by K") ## [1014. Best Sightseeing Pair (Medium)](https://leetcode.com/problems/best-sightseeing-pair "最佳观光组合") @@ -37,7 +37,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/best-time-to-buy-and-sell-stock-ii/README.md b/problems/best-time-to-buy-and-sell-stock-ii/README.md index 8cea3d897..48e05d027 100644 --- a/problems/best-time-to-buy-and-sell-stock-ii/README.md +++ b/problems/best-time-to-buy-and-sell-stock-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock "Best Time to Buy and Sell Stock") +[< Previous](../best-time-to-buy-and-sell-stock "Best Time to Buy and Sell Stock")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-iii "Best Time to Buy and Sell Stock III") +[Next >](../best-time-to-buy-and-sell-stock-iii "Best Time to Buy and Sell Stock III") ## [122. Best Time to Buy and Sell Stock II (Easy)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii "买卖股票的最佳时机 II") @@ -44,12 +44,12 @@ Explanation: In this case, no transaction is done, i.e. max profit = 0. ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Best Time to Buy and Sell Stock](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock) (Easy) - 1. [Best Time to Buy and Sell Stock III](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-iii) (Hard) - 1. [Best Time to Buy and Sell Stock IV](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-iv) (Hard) - 1. [Best Time to Buy and Sell Stock with Cooldown](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-with-cooldown) (Medium) - 1. [Best Time to Buy and Sell Stock with Transaction Fee](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-with-transaction-fee) (Medium) + 1. [Best Time to Buy and Sell Stock](../best-time-to-buy-and-sell-stock) (Easy) + 1. [Best Time to Buy and Sell Stock III](../best-time-to-buy-and-sell-stock-iii) (Hard) + 1. [Best Time to Buy and Sell Stock IV](../best-time-to-buy-and-sell-stock-iv) (Hard) + 1. [Best Time to Buy and Sell Stock with Cooldown](../best-time-to-buy-and-sell-stock-with-cooldown) (Medium) + 1. [Best Time to Buy and Sell Stock with Transaction Fee](../best-time-to-buy-and-sell-stock-with-transaction-fee) (Medium) diff --git a/problems/best-time-to-buy-and-sell-stock-iii/README.md b/problems/best-time-to-buy-and-sell-stock-iii/README.md index 765dde73b..43adc71d1 100644 --- a/problems/best-time-to-buy-and-sell-stock-iii/README.md +++ b/problems/best-time-to-buy-and-sell-stock-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-ii "Best Time to Buy and Sell Stock II") +[< Previous](../best-time-to-buy-and-sell-stock-ii "Best Time to Buy and Sell Stock II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-tree-maximum-path-sum "Binary Tree Maximum Path Sum") +[Next >](../binary-tree-maximum-path-sum "Binary Tree Maximum Path Sum") ## [123. Best Time to Buy and Sell Stock III (Hard)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii "买卖股票的最佳时机 III") @@ -43,11 +43,11 @@ Explanation: In this case, no transaction is done, i.e. max profit = 0. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Best Time to Buy and Sell Stock](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock) (Easy) - 1. [Best Time to Buy and Sell Stock II](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-ii) (Easy) - 1. [Best Time to Buy and Sell Stock IV](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-iv) (Hard) - 1. [Maximum Sum of 3 Non-Overlapping Subarrays](https://github.com/openset/leetcode/tree/master/problems/maximum-sum-of-3-non-overlapping-subarrays) (Hard) + 1. [Best Time to Buy and Sell Stock](../best-time-to-buy-and-sell-stock) (Easy) + 1. [Best Time to Buy and Sell Stock II](../best-time-to-buy-and-sell-stock-ii) (Easy) + 1. [Best Time to Buy and Sell Stock IV](../best-time-to-buy-and-sell-stock-iv) (Hard) + 1. [Maximum Sum of 3 Non-Overlapping Subarrays](../maximum-sum-of-3-non-overlapping-subarrays) (Hard) diff --git a/problems/best-time-to-buy-and-sell-stock-iv/README.md b/problems/best-time-to-buy-and-sell-stock-iv/README.md index 337decbbc..e0f6809f3 100644 --- a/problems/best-time-to-buy-and-sell-stock-iv/README.md +++ b/problems/best-time-to-buy-and-sell-stock-iv/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/repeated-dna-sequences "Repeated DNA Sequences") +[< Previous](../repeated-dna-sequences "Repeated DNA Sequences")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/rotate-array "Rotate Array") +[Next >](../rotate-array "Rotate Array") ## [188. Best Time to Buy and Sell Stock IV (Hard)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv "买卖股票的最佳时机 IV") @@ -36,9 +36,9 @@ You may not engage in multiple transactions at the same time (ie, you must sell ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Best Time to Buy and Sell Stock](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock) (Easy) - 1. [Best Time to Buy and Sell Stock II](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-ii) (Easy) - 1. [Best Time to Buy and Sell Stock III](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-iii) (Hard) + 1. [Best Time to Buy and Sell Stock](../best-time-to-buy-and-sell-stock) (Easy) + 1. [Best Time to Buy and Sell Stock II](../best-time-to-buy-and-sell-stock-ii) (Easy) + 1. [Best Time to Buy and Sell Stock III](../best-time-to-buy-and-sell-stock-iii) (Hard) diff --git a/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md b/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md index a677395f9..e57cb5155 100644 --- a/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md +++ b/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-2d-mutable "Range Sum Query 2D - Mutable") +[< Previous](../range-sum-query-2d-mutable "Range Sum Query 2D - Mutable")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-height-trees "Minimum Height Trees") +[Next >](../minimum-height-trees "Minimum Height Trees") ## [309. Best Time to Buy and Sell Stock with Cooldown (Medium)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown "最佳买卖股票时机含冷冻期") @@ -29,8 +29,8 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Best Time to Buy and Sell Stock](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock) (Easy) - 1. [Best Time to Buy and Sell Stock II](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-ii) (Easy) + 1. [Best Time to Buy and Sell Stock](../best-time-to-buy-and-sell-stock) (Easy) + 1. [Best Time to Buy and Sell Stock II](../best-time-to-buy-and-sell-stock-ii) (Easy) diff --git a/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md b/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md index 5ec74f3eb..b1ad894a5 100644 --- a/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md +++ b/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/subarray-product-less-than-k "Subarray Product Less Than K") +[< Previous](../subarray-product-less-than-k "Subarray Product Less Than K")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/range-module "Range Module") +[Next >](../range-module "Range Module") ## [714. Best Time to Buy and Sell Stock with Transaction Fee (Medium)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee "买卖股票的最佳时机含手续费") @@ -31,12 +31,12 @@

### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Best Time to Buy and Sell Stock II](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-ii) (Easy) + 1. [Best Time to Buy and Sell Stock II](../best-time-to-buy-and-sell-stock-ii) (Easy) ### Hints
diff --git a/problems/best-time-to-buy-and-sell-stock/README.md b/problems/best-time-to-buy-and-sell-stock/README.md index 1705d22ca..0c951ccd2 100644 --- a/problems/best-time-to-buy-and-sell-stock/README.md +++ b/problems/best-time-to-buy-and-sell-stock/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/triangle "Triangle") +[< Previous](../triangle "Triangle")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-ii "Best Time to Buy and Sell Stock II") +[Next >](../best-time-to-buy-and-sell-stock-ii "Best Time to Buy and Sell Stock II") ## [121. Best Time to Buy and Sell Stock (Easy)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock "买卖股票的最佳时机") @@ -35,12 +35,12 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Maximum Subarray](https://github.com/openset/leetcode/tree/master/problems/maximum-subarray) (Easy) - 1. [Best Time to Buy and Sell Stock II](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-ii) (Easy) - 1. [Best Time to Buy and Sell Stock III](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-iii) (Hard) - 1. [Best Time to Buy and Sell Stock IV](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-iv) (Hard) - 1. [Best Time to Buy and Sell Stock with Cooldown](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-with-cooldown) (Medium) + 1. [Maximum Subarray](../maximum-subarray) (Easy) + 1. [Best Time to Buy and Sell Stock II](../best-time-to-buy-and-sell-stock-ii) (Easy) + 1. [Best Time to Buy and Sell Stock III](../best-time-to-buy-and-sell-stock-iii) (Hard) + 1. [Best Time to Buy and Sell Stock IV](../best-time-to-buy-and-sell-stock-iv) (Hard) + 1. [Best Time to Buy and Sell Stock with Cooldown](../best-time-to-buy-and-sell-stock-with-cooldown) (Medium) diff --git a/problems/big-countries/README.md b/problems/big-countries/README.md index 789041a13..433c5c428 100644 --- a/problems/big-countries/README.md +++ b/problems/big-countries/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-harmonious-subsequence "Longest Harmonious Subsequence") +[< Previous](../longest-harmonious-subsequence "Longest Harmonious Subsequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/classes-more-than-5-students "Classes More Than 5 Students") +[Next >](../classes-more-than-5-students "Classes More Than 5 Students") ## [595. Big Countries (Easy)](https://leetcode.com/problems/big-countries "大的国家") diff --git a/problems/biggest-single-number/README.md b/problems/biggest-single-number/README.md index e95049561..71435f4ab 100644 --- a/problems/biggest-single-number/README.md +++ b/problems/biggest-single-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/students-report-by-geography "Students Report By Geography") +[< Previous](../students-report-by-geography "Students Report By Geography")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/not-boring-movies "Not Boring Movies") +[Next >](../not-boring-movies "Not Boring Movies") ## [619. Biggest Single Number (Easy)](https://leetcode.com/problems/biggest-single-number "只出现一次的最大数字") diff --git a/problems/binary-gap/README.md b/problems/binary-gap/README.md index 5930ec74a..02c250249 100644 --- a/problems/binary-gap/README.md +++ b/problems/binary-gap/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/transpose-matrix "Transpose Matrix") +[< Previous](../transpose-matrix "Transpose Matrix")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reordered-power-of-2 "Reordered Power of 2") +[Next >](../reordered-power-of-2 "Reordered Power of 2") ## [868. Binary Gap (Easy)](https://leetcode.com/problems/binary-gap "二进制间距") @@ -90,4 +90,4 @@ There aren't any consecutive pairs of 1's in the binary representation o ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/binary-number-with-alternating-bits/README.md b/problems/binary-number-with-alternating-bits/README.md index 750776eb3..f05d9ee99 100644 --- a/problems/binary-number-with-alternating-bits/README.md +++ b/problems/binary-number-with-alternating-bits/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-words "Top K Frequent Words") +[< Previous](../top-k-frequent-words "Top K Frequent Words")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-distinct-islands "Number of Distinct Islands") +[Next >](../number-of-distinct-islands "Number of Distinct Islands") ## [693. Binary Number with Alternating Bits (Easy)](https://leetcode.com/problems/binary-number-with-alternating-bits "交替位二进制数") @@ -50,7 +50,7 @@ The binary representation of 10 is: 1010.

### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions - 1. [Number of 1 Bits](https://github.com/openset/leetcode/tree/master/problems/number-of-1-bits) (Easy) + 1. [Number of 1 Bits](../number-of-1-bits) (Easy) diff --git a/problems/binary-prefix-divisible-by-5/README.md b/problems/binary-prefix-divisible-by-5/README.md index f1030d7fd..d1ee3b80a 100644 --- a/problems/binary-prefix-divisible-by-5/README.md +++ b/problems/binary-prefix-divisible-by-5/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/convert-to-base-2 "Convert to Base -2") +[< Previous](../convert-to-base-2 "Convert to Base -2")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/next-greater-node-in-linked-list "Next Greater Node In Linked List") +[Next >](../next-greater-node-in-linked-list "Next Greater Node In Linked List") ## [1018. Binary Prefix Divisible By 5 (Easy)](https://leetcode.com/problems/binary-prefix-divisible-by-5 "可被 5 整除的二进制前缀") @@ -55,7 +55,7 @@ The input numbers in binary are 0, 01, 011; which are 0, 1, and 3 in base-10. O ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/binary-search-tree-iterator/README.md b/problems/binary-search-tree-iterator/README.md index c1530afee..78b95f3d7 100644 --- a/problems/binary-search-tree-iterator/README.md +++ b/problems/binary-search-tree-iterator/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/factorial-trailing-zeroes "Factorial Trailing Zeroes") +[< Previous](../factorial-trailing-zeroes "Factorial Trailing Zeroes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/dungeon-game "Dungeon Game") +[Next >](../dungeon-game "Dungeon Game") ## [173. Binary Search Tree Iterator (Medium)](https://leetcode.com/problems/binary-search-tree-iterator "二叉搜索树迭代器") @@ -47,13 +47,13 @@ iterator.hasNext(); // return false ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions - 1. [Binary Tree Inorder Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-inorder-traversal) (Medium) - 1. [Flatten 2D Vector](https://github.com/openset/leetcode/tree/master/problems/flatten-2d-vector) (Medium) - 1. [Zigzag Iterator](https://github.com/openset/leetcode/tree/master/problems/zigzag-iterator) (Medium) - 1. [Peeking Iterator](https://github.com/openset/leetcode/tree/master/problems/peeking-iterator) (Medium) - 1. [Inorder Successor in BST](https://github.com/openset/leetcode/tree/master/problems/inorder-successor-in-bst) (Medium) + 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Medium) + 1. [Flatten 2D Vector](../flatten-2d-vector) (Medium) + 1. [Zigzag Iterator](../zigzag-iterator) (Medium) + 1. [Peeking Iterator](../peeking-iterator) (Medium) + 1. [Inorder Successor in BST](../inorder-successor-in-bst) (Medium) diff --git a/problems/binary-search-tree-to-greater-sum-tree/README.md b/problems/binary-search-tree-to-greater-sum-tree/README.md index bf74c778e..513955281 100644 --- a/problems/binary-search-tree-to-greater-sum-tree/README.md +++ b/problems/binary-search-tree-to-greater-sum-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-boomerang "Valid Boomerang") +[< Previous](../valid-boomerang "Valid Boomerang")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-score-triangulation-of-polygon "Minimum Score Triangulation of Polygon") +[Next >](../minimum-score-triangulation-of-polygon "Minimum Score Triangulation of Polygon") ## [1038. Binary Search Tree to Greater Sum Tree (Medium)](https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree "从二叉搜索树到更大和树") @@ -51,7 +51,7 @@ ### Related Topics - [[Binary Search Tree](https://github.com/openset/leetcode/tree/master/tag/binary-search-tree/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] ### Hints
diff --git a/problems/binary-search/README.md b/problems/binary-search/README.md index 072193658..34d2cf28e 100644 --- a/problems/binary-search/README.md +++ b/problems/binary-search/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/kth-largest-element-in-a-stream "Kth Largest Element in a Stream") +[< Previous](../kth-largest-element-in-a-stream "Kth Largest Element in a Stream")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-hashset "Design HashSet") +[Next >](../design-hashset "Design HashSet") ## [704. Binary Search (Easy)](https://leetcode.com/problems/binary-search "二分查找") @@ -42,7 +42,7 @@ ### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Search in a Sorted Array of Unknown Size](https://github.com/openset/leetcode/tree/master/problems/search-in-a-sorted-array-of-unknown-size) (Medium) + 1. [Search in a Sorted Array of Unknown Size](../search-in-a-sorted-array-of-unknown-size) (Medium) diff --git a/problems/binary-string-with-substrings-representing-1-to-n/README.md b/problems/binary-string-with-substrings-representing-1-to-n/README.md index 71e405ef9..ee354f5bf 100644 --- a/problems/binary-string-with-substrings-representing-1-to-n/README.md +++ b/problems/binary-string-with-substrings-representing-1-to-n/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/smallest-integer-divisible-by-k "Smallest Integer Divisible by K") +[< Previous](../smallest-integer-divisible-by-k "Smallest Integer Divisible by K")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/convert-to-base-2 "Convert to Base -2") +[Next >](../convert-to-base-2 "Convert to Base -2") ## [1016. Binary String With Substrings Representing 1 To N (Medium)](https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n "子串能表示从 1 到 N 数字的二进制串") @@ -39,7 +39,7 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/binary-subarrays-with-sum/README.md b/problems/binary-subarrays-with-sum/README.md index 9a30b8d6c..530b9e980 100644 --- a/problems/binary-subarrays-with-sum/README.md +++ b/problems/binary-subarrays-with-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/unique-email-addresses "Unique Email Addresses") +[< Previous](../unique-email-addresses "Unique Email Addresses")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-falling-path-sum "Minimum Falling Path Sum") +[Next >](../minimum-falling-path-sum "Minimum Falling Path Sum") ## [930. Binary Subarrays With Sum (Medium)](https://leetcode.com/problems/binary-subarrays-with-sum "和相同的二元子数组") @@ -39,5 +39,5 @@ The 4 subarrays are bolded below: ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/binary-tree-cameras/README.md b/problems/binary-tree-cameras/README.md index adec9afaa..dc265c0a0 100644 --- a/problems/binary-tree-cameras/README.md +++ b/problems/binary-tree-cameras/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/numbers-with-same-consecutive-differences "Numbers With Same Consecutive Differences") +[< Previous](../numbers-with-same-consecutive-differences "Numbers With Same Consecutive Differences")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/pancake-sorting "Pancake Sorting") +[Next >](../pancake-sorting "Pancake Sorting") ## [968. Binary Tree Cameras (Hard)](https://leetcode.com/problems/binary-tree-cameras "监控二叉树") @@ -48,9 +48,9 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Distribute Coins in Binary Tree](https://github.com/openset/leetcode/tree/master/problems/distribute-coins-in-binary-tree) (Medium) + 1. [Distribute Coins in Binary Tree](../distribute-coins-in-binary-tree) (Medium) diff --git a/problems/binary-tree-coloring-game/README.md b/problems/binary-tree-coloring-game/README.md index 6ce16d729..ee44c1142 100644 --- a/problems/binary-tree-coloring-game/README.md +++ b/problems/binary-tree-coloring-game/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/decrease-elements-to-make-array-zigzag "Decrease Elements To Make Array Zigzag") +[< Previous](../decrease-elements-to-make-array-zigzag "Decrease Elements To Make Array Zigzag")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/snapshot-array "Snapshot Array") +[Next >](../snapshot-array "Snapshot Array") ## [1145. Binary Tree Coloring Game (Medium)](https://leetcode.com/problems/binary-tree-coloring-game "二叉树着色游戏") @@ -40,8 +40,8 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Hints
diff --git a/problems/binary-tree-inorder-traversal/README.md b/problems/binary-tree-inorder-traversal/README.md index d88708f8a..541392d4b 100644 --- a/problems/binary-tree-inorder-traversal/README.md +++ b/problems/binary-tree-inorder-traversal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/restore-ip-addresses "Restore IP Addresses") +[< Previous](../restore-ip-addresses "Restore IP Addresses")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/unique-binary-search-trees-ii "Unique Binary Search Trees II") +[Next >](../unique-binary-search-trees-ii "Unique Binary Search Trees II") ## [94. Binary Tree Inorder Traversal (Medium)](https://leetcode.com/problems/binary-tree-inorder-traversal "二叉树的中序遍历") @@ -28,17 +28,17 @@

Follow up: Recursive solution is trivial, could you do it iteratively?

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Validate Binary Search Tree](https://github.com/openset/leetcode/tree/master/problems/validate-binary-search-tree) (Medium) - 1. [Binary Tree Preorder Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-preorder-traversal) (Medium) - 1. [Binary Tree Postorder Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-postorder-traversal) (Hard) - 1. [Binary Search Tree Iterator](https://github.com/openset/leetcode/tree/master/problems/binary-search-tree-iterator) (Medium) - 1. [Kth Smallest Element in a BST](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-element-in-a-bst) (Medium) - 1. [Closest Binary Search Tree Value II](https://github.com/openset/leetcode/tree/master/problems/closest-binary-search-tree-value-ii) (Hard) - 1. [Inorder Successor in BST](https://github.com/openset/leetcode/tree/master/problems/inorder-successor-in-bst) (Medium) - 1. [Convert Binary Search Tree to Sorted Doubly Linked List](https://github.com/openset/leetcode/tree/master/problems/convert-binary-search-tree-to-sorted-doubly-linked-list) (Medium) - 1. [Minimum Distance Between BST Nodes](https://github.com/openset/leetcode/tree/master/problems/minimum-distance-between-bst-nodes) (Easy) + 1. [Validate Binary Search Tree](../validate-binary-search-tree) (Medium) + 1. [Binary Tree Preorder Traversal](../binary-tree-preorder-traversal) (Medium) + 1. [Binary Tree Postorder Traversal](../binary-tree-postorder-traversal) (Hard) + 1. [Binary Search Tree Iterator](../binary-search-tree-iterator) (Medium) + 1. [Kth Smallest Element in a BST](../kth-smallest-element-in-a-bst) (Medium) + 1. [Closest Binary Search Tree Value II](../closest-binary-search-tree-value-ii) (Hard) + 1. [Inorder Successor in BST](../inorder-successor-in-bst) (Medium) + 1. [Convert Binary Search Tree to Sorted Doubly Linked List](../convert-binary-search-tree-to-sorted-doubly-linked-list) (Medium) + 1. [Minimum Distance Between BST Nodes](../minimum-distance-between-bst-nodes) (Easy) diff --git a/problems/binary-tree-level-order-traversal-ii/README.md b/problems/binary-tree-level-order-traversal-ii/README.md index eb3aa1978..d9e2f1472 100644 --- a/problems/binary-tree-level-order-traversal-ii/README.md +++ b/problems/binary-tree-level-order-traversal-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-inorder-and-postorder-traversal "Construct Binary Tree from Inorder and Postorder Traversal") +[< Previous](../construct-binary-tree-from-inorder-and-postorder-traversal "Construct Binary Tree from Inorder and Postorder Traversal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/convert-sorted-array-to-binary-search-tree "Convert Sorted Array to Binary Search Tree") +[Next >](../convert-sorted-array-to-binary-search-tree "Convert Sorted Array to Binary Search Tree") ## [107. Binary Tree Level Order Traversal II (Easy)](https://leetcode.com/problems/binary-tree-level-order-traversal-ii "二叉树的层次遍历 II") @@ -36,9 +36,9 @@ return its bottom-up level order traversal as:

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions - 1. [Binary Tree Level Order Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal) (Medium) - 1. [Average of Levels in Binary Tree](https://github.com/openset/leetcode/tree/master/problems/average-of-levels-in-binary-tree) (Easy) + 1. [Binary Tree Level Order Traversal](../binary-tree-level-order-traversal) (Medium) + 1. [Average of Levels in Binary Tree](../average-of-levels-in-binary-tree) (Easy) diff --git a/problems/binary-tree-level-order-traversal/README.md b/problems/binary-tree-level-order-traversal/README.md index ad8ce7547..d0e34e041 100644 --- a/problems/binary-tree-level-order-traversal/README.md +++ b/problems/binary-tree-level-order-traversal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/symmetric-tree "Symmetric Tree") +[< Previous](../symmetric-tree "Symmetric Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-tree-zigzag-level-order-traversal "Binary Tree Zigzag Level Order Traversal") +[Next >](../binary-tree-zigzag-level-order-traversal "Binary Tree Zigzag Level Order Traversal") ## [102. Binary Tree Level Order Traversal (Medium)](https://leetcode.com/problems/binary-tree-level-order-traversal "二叉树的层次遍历") @@ -36,14 +36,14 @@ return its level order traversal as:

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions - 1. [Binary Tree Zigzag Level Order Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-zigzag-level-order-traversal) (Medium) - 1. [Binary Tree Level Order Traversal II](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal-ii) (Easy) - 1. [Minimum Depth of Binary Tree](https://github.com/openset/leetcode/tree/master/problems/minimum-depth-of-binary-tree) (Easy) - 1. [Binary Tree Vertical Order Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-vertical-order-traversal) (Medium) - 1. [Average of Levels in Binary Tree](https://github.com/openset/leetcode/tree/master/problems/average-of-levels-in-binary-tree) (Easy) - 1. [N-ary Tree Level Order Traversal](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-level-order-traversal) (Medium) - 1. [Cousins in Binary Tree](https://github.com/openset/leetcode/tree/master/problems/cousins-in-binary-tree) (Easy) + 1. [Binary Tree Zigzag Level Order Traversal](../binary-tree-zigzag-level-order-traversal) (Medium) + 1. [Binary Tree Level Order Traversal II](../binary-tree-level-order-traversal-ii) (Easy) + 1. [Minimum Depth of Binary Tree](../minimum-depth-of-binary-tree) (Easy) + 1. [Binary Tree Vertical Order Traversal](../binary-tree-vertical-order-traversal) (Medium) + 1. [Average of Levels in Binary Tree](../average-of-levels-in-binary-tree) (Easy) + 1. [N-ary Tree Level Order Traversal](../n-ary-tree-level-order-traversal) (Medium) + 1. [Cousins in Binary Tree](../cousins-in-binary-tree) (Easy) diff --git a/problems/binary-tree-longest-consecutive-sequence-ii/README.md b/problems/binary-tree-longest-consecutive-sequence-ii/README.md index e923e4aa6..8347fe2f1 100644 --- a/problems/binary-tree-longest-consecutive-sequence-ii/README.md +++ b/problems/binary-tree-longest-consecutive-sequence-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/split-array-with-equal-sum "Split Array with Equal Sum") +[< Previous](../split-array-with-equal-sum "Split Array with Equal Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-iv "Game Play Analysis IV") +[Next >](../game-play-analysis-iv "Game Play Analysis IV") ## [549. Binary Tree Longest Consecutive Sequence II (Medium)](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence-ii "二叉树中最长的连续序列") @@ -44,7 +44,7 @@

Note: All the values of tree nodes are in the range of [-1e7, 1e7].

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Binary Tree Longest Consecutive Sequence](https://github.com/openset/leetcode/tree/master/problems/binary-tree-longest-consecutive-sequence) (Medium) + 1. [Binary Tree Longest Consecutive Sequence](../binary-tree-longest-consecutive-sequence) (Medium) diff --git a/problems/binary-tree-longest-consecutive-sequence/README.md b/problems/binary-tree-longest-consecutive-sequence/README.md index ce05cfd2a..1c6bfa49b 100644 --- a/problems/binary-tree-longest-consecutive-sequence/README.md +++ b/problems/binary-tree-longest-consecutive-sequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-binary-tree "Serialize and Deserialize Binary Tree") +[< Previous](../serialize-and-deserialize-binary-tree "Serialize and Deserialize Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/bulls-and-cows "Bulls and Cows") +[Next >](../bulls-and-cows "Bulls and Cows") ## [298. Binary Tree Longest Consecutive Sequence (Medium)](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence "二叉树最长连续序列") @@ -50,8 +50,8 @@ Explanation: Longest consecutive sequence path is 2-3, not 3-2-1, so return 2. ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Longest Consecutive Sequence](https://github.com/openset/leetcode/tree/master/problems/longest-consecutive-sequence) (Hard) - 1. [Binary Tree Longest Consecutive Sequence II](https://github.com/openset/leetcode/tree/master/problems/binary-tree-longest-consecutive-sequence-ii) (Medium) + 1. [Longest Consecutive Sequence](../longest-consecutive-sequence) (Hard) + 1. [Binary Tree Longest Consecutive Sequence II](../binary-tree-longest-consecutive-sequence-ii) (Medium) diff --git a/problems/binary-tree-maximum-path-sum/README.md b/problems/binary-tree-maximum-path-sum/README.md index 8bf8689e5..c6bba9c25 100644 --- a/problems/binary-tree-maximum-path-sum/README.md +++ b/problems/binary-tree-maximum-path-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-iii "Best Time to Buy and Sell Stock III") +[< Previous](../best-time-to-buy-and-sell-stock-iii "Best Time to Buy and Sell Stock III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome "Valid Palindrome") +[Next >](../valid-palindrome "Valid Palindrome") ## [124. Binary Tree Maximum Path Sum (Hard)](https://leetcode.com/problems/binary-tree-maximum-path-sum "二叉树中的最大路径和") @@ -42,11 +42,11 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Path Sum](https://github.com/openset/leetcode/tree/master/problems/path-sum) (Easy) - 1. [Sum Root to Leaf Numbers](https://github.com/openset/leetcode/tree/master/problems/sum-root-to-leaf-numbers) (Medium) - 1. [Path Sum IV](https://github.com/openset/leetcode/tree/master/problems/path-sum-iv) (Medium) - 1. [Longest Univalue Path](https://github.com/openset/leetcode/tree/master/problems/longest-univalue-path) (Easy) + 1. [Path Sum](../path-sum) (Easy) + 1. [Sum Root to Leaf Numbers](../sum-root-to-leaf-numbers) (Medium) + 1. [Path Sum IV](../path-sum-iv) (Medium) + 1. [Longest Univalue Path](../longest-univalue-path) (Easy) diff --git a/problems/binary-tree-paths/README.md b/problems/binary-tree-paths/README.md index 6df4189b2..236c890f6 100644 --- a/problems/binary-tree-paths/README.md +++ b/problems/binary-tree-paths/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/paint-house "Paint House") +[< Previous](../paint-house "Paint House")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/add-digits "Add Digits") +[Next >](../add-digits "Add Digits") ## [257. Binary Tree Paths (Easy)](https://leetcode.com/problems/binary-tree-paths "二叉树的所有路径") @@ -32,9 +32,9 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Path Sum II](https://github.com/openset/leetcode/tree/master/problems/path-sum-ii) (Medium) - 1. [Smallest String Starting From Leaf](https://github.com/openset/leetcode/tree/master/problems/smallest-string-starting-from-leaf) (Medium) + 1. [Path Sum II](../path-sum-ii) (Medium) + 1. [Smallest String Starting From Leaf](../smallest-string-starting-from-leaf) (Medium) diff --git a/problems/binary-tree-postorder-traversal/README.md b/problems/binary-tree-postorder-traversal/README.md index 926a0321e..3b6c1107b 100644 --- a/problems/binary-tree-postorder-traversal/README.md +++ b/problems/binary-tree-postorder-traversal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-tree-preorder-traversal "Binary Tree Preorder Traversal") +[< Previous](../binary-tree-preorder-traversal "Binary Tree Preorder Traversal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/lru-cache "LRU Cache") +[Next >](../lru-cache "LRU Cache") ## [145. Binary Tree Postorder Traversal (Hard)](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历") @@ -29,9 +29,9 @@

Follow up: Recursive solution is trivial, could you do it iteratively?

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Binary Tree Inorder Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-inorder-traversal) (Medium) - 1. [N-ary Tree Postorder Traversal](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-postorder-traversal) (Easy) + 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Medium) + 1. [N-ary Tree Postorder Traversal](../n-ary-tree-postorder-traversal) (Easy) diff --git a/problems/binary-tree-preorder-traversal/README.md b/problems/binary-tree-preorder-traversal/README.md index be1447b53..1d547ac24 100644 --- a/problems/binary-tree-preorder-traversal/README.md +++ b/problems/binary-tree-preorder-traversal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reorder-list "Reorder List") +[< Previous](../reorder-list "Reorder List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-tree-postorder-traversal "Binary Tree Postorder Traversal") +[Next >](../binary-tree-postorder-traversal "Binary Tree Postorder Traversal") ## [144. Binary Tree Preorder Traversal (Medium)](https://leetcode.com/problems/binary-tree-preorder-traversal "二叉树的前序遍历") @@ -29,10 +29,10 @@

Follow up: Recursive solution is trivial, could you do it iteratively?

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Binary Tree Inorder Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-inorder-traversal) (Medium) - 1. [Verify Preorder Sequence in Binary Search Tree](https://github.com/openset/leetcode/tree/master/problems/verify-preorder-sequence-in-binary-search-tree) (Medium) - 1. [N-ary Tree Preorder Traversal](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-preorder-traversal) (Easy) + 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Medium) + 1. [Verify Preorder Sequence in Binary Search Tree](../verify-preorder-sequence-in-binary-search-tree) (Medium) + 1. [N-ary Tree Preorder Traversal](../n-ary-tree-preorder-traversal) (Easy) diff --git a/problems/binary-tree-pruning/README.md b/problems/binary-tree-pruning/README.md index 703a73320..7fa911708 100644 --- a/problems/binary-tree-pruning/README.md +++ b/problems/binary-tree-pruning/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/largest-sum-of-averages "Largest Sum of Averages") +[< Previous](../largest-sum-of-averages "Largest Sum of Averages")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/bus-routes "Bus Routes") +[Next >](../bus-routes "Bus Routes") ## [814. Binary Tree Pruning (Medium)](https://leetcode.com/problems/binary-tree-pruning "二叉树剪枝") @@ -55,4 +55,4 @@ The diagram on the right represents the answer. ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] diff --git a/problems/binary-tree-right-side-view/README.md b/problems/binary-tree-right-side-view/README.md index 5ece4c4b9..c4c1c1725 100644 --- a/problems/binary-tree-right-side-view/README.md +++ b/problems/binary-tree-right-side-view/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/house-robber "House Robber") +[< Previous](../house-robber "House Robber")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-islands "Number of Islands") +[Next >](../number-of-islands "Number of Islands") ## [199. Binary Tree Right Side View (Medium)](https://leetcode.com/problems/binary-tree-right-side-view "二叉树的右视图") @@ -28,10 +28,10 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions - 1. [Populating Next Right Pointers in Each Node](https://github.com/openset/leetcode/tree/master/problems/populating-next-right-pointers-in-each-node) (Medium) - 1. [Boundary of Binary Tree](https://github.com/openset/leetcode/tree/master/problems/boundary-of-binary-tree) (Medium) + 1. [Populating Next Right Pointers in Each Node](../populating-next-right-pointers-in-each-node) (Medium) + 1. [Boundary of Binary Tree](../boundary-of-binary-tree) (Medium) diff --git a/problems/binary-tree-tilt/README.md b/problems/binary-tree-tilt/README.md index 88b2a8815..2f13835ec 100644 --- a/problems/binary-tree-tilt/README.md +++ b/problems/binary-tree-tilt/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-line-of-consecutive-one-in-matrix "Longest Line of Consecutive One in Matrix") +[< Previous](../longest-line-of-consecutive-one-in-matrix "Longest Line of Consecutive One in Matrix")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-the-closest-palindrome "Find the Closest Palindrome") +[Next >](../find-the-closest-palindrome "Find the Closest Palindrome") ## [563. Binary Tree Tilt (Easy)](https://leetcode.com/problems/binary-tree-tilt "二叉树的坡度") @@ -40,7 +40,7 @@ Tilt of binary tree : 0 + 0 + 1 = 1

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Hints
diff --git a/problems/binary-tree-upside-down/README.md b/problems/binary-tree-upside-down/README.md index 034d25b90..5a034ea82 100644 --- a/problems/binary-tree-upside-down/README.md +++ b/problems/binary-tree-upside-down/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/min-stack "Min Stack") +[< Previous](../min-stack "Min Stack")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/read-n-characters-given-read4 "Read N Characters Given Read4") +[Next >](../read-n-characters-given-read4 "Read N Characters Given Read4") ## [156. Binary Tree Upside Down (Medium)](https://leetcode.com/problems/binary-tree-upside-down "上下翻转二叉树") @@ -54,7 +54,7 @@

The above binary tree is serialized as [1,2,3,#,#,4,#,#,5].

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Reverse Linked List](https://github.com/openset/leetcode/tree/master/problems/reverse-linked-list) (Easy) + 1. [Reverse Linked List](../reverse-linked-list) (Easy) diff --git a/problems/binary-tree-vertical-order-traversal/README.md b/problems/binary-tree-vertical-order-traversal/README.md index ff7b3c5ba..0b3a26f4c 100644 --- a/problems/binary-tree-vertical-order-traversal/README.md +++ b/problems/binary-tree-vertical-order-traversal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/super-ugly-number "Super Ugly Number") +[< Previous](../super-ugly-number "Super Ugly Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/count-of-smaller-numbers-after-self "Count of Smaller Numbers After Self") +[Next >](../count-of-smaller-numbers-after-self "Count of Smaller Numbers After Self") ## [314. Binary Tree Vertical Order Traversal (Medium)](https://leetcode.com/problems/binary-tree-vertical-order-traversal "二叉树的垂直遍历") @@ -90,7 +90,7 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Binary Tree Level Order Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal) (Medium) + 1. [Binary Tree Level Order Traversal](../binary-tree-level-order-traversal) (Medium) diff --git a/problems/binary-tree-zigzag-level-order-traversal/README.md b/problems/binary-tree-zigzag-level-order-traversal/README.md index 72bf179c9..10e9b8169 100644 --- a/problems/binary-tree-zigzag-level-order-traversal/README.md +++ b/problems/binary-tree-zigzag-level-order-traversal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal "Binary Tree Level Order Traversal") +[< Previous](../binary-tree-level-order-traversal "Binary Tree Level Order Traversal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-depth-of-binary-tree "Maximum Depth of Binary Tree") +[Next >](../maximum-depth-of-binary-tree "Maximum Depth of Binary Tree") ## [103. Binary Tree Zigzag Level Order Traversal (Medium)](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal "二叉树的锯齿形层次遍历") @@ -36,9 +36,9 @@ return its zigzag level order traversal as:

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions - 1. [Binary Tree Level Order Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal) (Medium) + 1. [Binary Tree Level Order Traversal](../binary-tree-level-order-traversal) (Medium) diff --git a/problems/binary-trees-with-factors/README.md b/problems/binary-trees-with-factors/README.md index 393b0705d..acfc166b7 100644 --- a/problems/binary-trees-with-factors/README.md +++ b/problems/binary-trees-with-factors/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/card-flipping-game "Card Flipping Game") +[< Previous](../card-flipping-game "Card Flipping Game")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/goat-latin "Goat Latin") +[Next >](../goat-latin "Goat Latin") ## [823. Binary Trees With Factors (Medium)](https://leetcode.com/problems/binary-trees-with-factors "带因子的二叉树") diff --git a/problems/binary-watch/README.md b/problems/binary-watch/README.md index 8a6b895f3..09de949d2 100644 --- a/problems/binary-watch/README.md +++ b/problems/binary-watch/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/nth-digit "Nth Digit") +[< Previous](../nth-digit "Nth Digit")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-k-digits "Remove K Digits") +[Next >](../remove-k-digits "Remove K Digits") ## [401. Binary Watch (Easy)](https://leetcode.com/problems/binary-watch "二进制手表") @@ -31,12 +31,12 @@

### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Letter Combinations of a Phone Number](https://github.com/openset/leetcode/tree/master/problems/letter-combinations-of-a-phone-number) (Medium) - 1. [Number of 1 Bits](https://github.com/openset/leetcode/tree/master/problems/number-of-1-bits) (Easy) + 1. [Letter Combinations of a Phone Number](../letter-combinations-of-a-phone-number) (Medium) + 1. [Number of 1 Bits](../number-of-1-bits) (Easy) ### Hints
diff --git a/problems/bitwise-and-of-numbers-range/README.md b/problems/bitwise-and-of-numbers-range/README.md index b0738a994..cf9e4d9c7 100644 --- a/problems/bitwise-and-of-numbers-range/README.md +++ b/problems/bitwise-and-of-numbers-range/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-islands "Number of Islands") +[< Previous](../number-of-islands "Number of Islands")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/happy-number "Happy Number") +[Next >](../happy-number "Happy Number") ## [201. Bitwise AND of Numbers Range (Medium)](https://leetcode.com/problems/bitwise-and-of-numbers-range "数字范围按位与") @@ -27,4 +27,4 @@ Output: 0 ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/bitwise-ors-of-subarrays/README.md b/problems/bitwise-ors-of-subarrays/README.md index 1b9e160c2..56b41a488 100644 --- a/problems/bitwise-ors-of-subarrays/README.md +++ b/problems/bitwise-ors-of-subarrays/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/increasing-order-search-tree "Increasing Order Search Tree") +[< Previous](../increasing-order-search-tree "Increasing Order Search Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/orderly-queue "Orderly Queue") +[Next >](../orderly-queue "Orderly Queue") ## [898. Bitwise ORs of Subarrays (Medium)](https://leetcode.com/problems/bitwise-ors-of-subarrays "子数组按位或操作") @@ -64,5 +64,5 @@ The possible results are 1, 2, 3, 4, 6, and 7. ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/boats-to-save-people/README.md b/problems/boats-to-save-people/README.md index ce89022df..80af1ce36 100644 --- a/problems/boats-to-save-people/README.md +++ b/problems/boats-to-save-people/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/decoded-string-at-index "Decoded String at Index") +[< Previous](../decoded-string-at-index "Decoded String at Index")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reachable-nodes-in-subdivided-graph "Reachable Nodes In Subdivided Graph") +[Next >](../reachable-nodes-in-subdivided-graph "Reachable Nodes In Subdivided Graph") ## [881. Boats to Save People (Medium)](https://leetcode.com/problems/boats-to-save-people "救生艇") @@ -56,5 +56,5 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/bold-words-in-string/README.md b/problems/bold-words-in-string/README.md index 5c0eb70fe..bee582ca3 100644 --- a/problems/bold-words-in-string/README.md +++ b/problems/bold-words-in-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/set-intersection-size-at-least-two "Set Intersection Size At Least Two") +[< Previous](../set-intersection-size-at-least-two "Set Intersection Size At Least Two")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/employee-free-time "Employee Free Time") +[Next >](../employee-free-time "Employee Free Time") ## [758. Bold Words in String (Easy)](https://leetcode.com/problems/bold-words-in-string "字符串中的加粗单词") @@ -28,7 +28,7 @@ For example, given that words = ["ab", "bc"] and S = "aabcd"

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/bomb-enemy/README.md b/problems/bomb-enemy/README.md index ee3a3650a..635b337f8 100644 --- a/problems/bomb-enemy/README.md +++ b/problems/bomb-enemy/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sort-transformed-array "Sort Transformed Array") +[< Previous](../sort-transformed-array "Sort Transformed Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-hit-counter "Design Hit Counter") +[Next >](../design-hit-counter "Design Hit Counter") ## [361. Bomb Enemy (Medium)](https://leetcode.com/problems/bomb-enemy "轰炸敌人") @@ -31,4 +31,4 @@ Placing a bomb at (1,1) kills 3 enemies. ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/boundary-of-binary-tree/README.md b/problems/boundary-of-binary-tree/README.md index dd6d7a792..42239e8f7 100644 --- a/problems/boundary-of-binary-tree/README.md +++ b/problems/boundary-of-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/output-contest-matches "Output Contest Matches") +[< Previous](../output-contest-matches "Output Contest Matches")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-boxes "Remove Boxes") +[Next >](../remove-boxes "Remove Boxes") ## [545. Boundary of Binary Tree (Medium)](https://leetcode.com/problems/boundary-of-binary-tree "二叉树的边界") @@ -66,7 +66,7 @@ So order them in anti-clockwise without duplicate nodes we have [1,2,4,7,8,9,10,

 

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Binary Tree Right Side View](https://github.com/openset/leetcode/tree/master/problems/binary-tree-right-side-view) (Medium) + 1. [Binary Tree Right Side View](../binary-tree-right-side-view) (Medium) diff --git a/problems/brace-expansion-ii/README.md b/problems/brace-expansion-ii/README.md index e6cd3207b..e8691c186 100644 --- a/problems/brace-expansion-ii/README.md +++ b/problems/brace-expansion-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-in-mountain-array "Find in Mountain Array") +[< Previous](../find-in-mountain-array "Find in Mountain Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-v "Game Play Analysis V") +[Next >](../game-play-analysis-v "Game Play Analysis V") ## [1096. Brace Expansion II (Hard)](https://leetcode.com/problems/brace-expansion-ii "花括号展开 II") @@ -78,10 +78,10 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Brace Expansion](https://github.com/openset/leetcode/tree/master/problems/brace-expansion) (Medium) + 1. [Brace Expansion](../brace-expansion) (Medium) ### Hints
diff --git a/problems/brace-expansion/README.md b/problems/brace-expansion/README.md index 7491e97f8..937e39d7a 100644 --- a/problems/brace-expansion/README.md +++ b/problems/brace-expansion/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/high-five "High Five") +[< Previous](../high-five "High Five")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/confusing-number-ii "Confusing Number II") +[Next >](../confusing-number-ii "Confusing Number II") ## [1087. Brace Expansion (Medium)](https://leetcode.com/problems/brace-expansion "字母切换") @@ -46,12 +46,12 @@ ### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Decode String](https://github.com/openset/leetcode/tree/master/problems/decode-string) (Medium) - 1. [Letter Case Permutation](https://github.com/openset/leetcode/tree/master/problems/letter-case-permutation) (Easy) - 1. [Brace Expansion II](https://github.com/openset/leetcode/tree/master/problems/brace-expansion-ii) (Hard) + 1. [Decode String](../decode-string) (Medium) + 1. [Letter Case Permutation](../letter-case-permutation) (Easy) + 1. [Brace Expansion II](../brace-expansion-ii) (Hard) ### Hints
diff --git a/problems/brick-wall/README.md b/problems/brick-wall/README.md index 395abdbb9..5714cdb26 100644 --- a/problems/brick-wall/README.md +++ b/problems/brick-wall/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/optimal-division "Optimal Division") +[< Previous](../optimal-division "Optimal Division")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/split-concatenated-strings "Split Concatenated Strings") +[Next >](../split-concatenated-strings "Split Concatenated Strings") ## [554. Brick Wall (Medium)](https://leetcode.com/problems/brick-wall "砖墙") @@ -47,4 +47,4 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/bricks-falling-when-hit/README.md b/problems/bricks-falling-when-hit/README.md index a5df4460a..47c98e432 100644 --- a/problems/bricks-falling-when-hit/README.md +++ b/problems/bricks-falling-when-hit/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-eventual-safe-states "Find Eventual Safe States") +[< Previous](../find-eventual-safe-states "Find Eventual Safe States")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/unique-morse-code-words "Unique Morse Code Words") +[Next >](../unique-morse-code-words "Unique Morse Code Words") ## [803. Bricks Falling When Hit (Hard)](https://leetcode.com/problems/bricks-falling-when-hit "打砖块") @@ -47,4 +47,4 @@ When we erase the brick at (1, 0), the brick at (1, 1) has already disappeared d ### Related Topics - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] + [[Union Find](../../tag/union-find/README.md)] diff --git a/problems/broken-calculator/README.md b/problems/broken-calculator/README.md index 3344b03cf..a452afcbb 100644 --- a/problems/broken-calculator/README.md +++ b/problems/broken-calculator/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/satisfiability-of-equality-equations "Satisfiability of Equality Equations") +[< Previous](../satisfiability-of-equality-equations "Satisfiability of Equality Equations")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/subarrays-with-k-different-integers "Subarrays with K Different Integers") +[Next >](../subarrays-with-k-different-integers "Subarrays with K Different Integers") ## [991. Broken Calculator (Medium)](https://leetcode.com/problems/broken-calculator "坏了的计算器") @@ -66,8 +66,8 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [2 Keys Keyboard](https://github.com/openset/leetcode/tree/master/problems/2-keys-keyboard) (Medium) + 1. [2 Keys Keyboard](../2-keys-keyboard) (Medium) diff --git a/problems/buddy-strings/README.md b/problems/buddy-strings/README.md index 81a19007a..d2b799aeb 100644 --- a/problems/buddy-strings/README.md +++ b/problems/buddy-strings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/mirror-reflection "Mirror Reflection") +[< Previous](../mirror-reflection "Mirror Reflection")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/lemonade-change "Lemonade Change") +[Next >](../lemonade-change "Lemonade Change") ## [859. Buddy Strings (Easy)](https://leetcode.com/problems/buddy-strings "亲密字符串") @@ -71,4 +71,4 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/building-h2o/README.md b/problems/building-h2o/README.md index 1967f5aff..969d84da0 100644 --- a/problems/building-h2o/README.md +++ b/problems/building-h2o/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/print-zero-even-odd "Print Zero Even Odd") +[< Previous](../print-zero-even-odd "Print Zero Even Odd")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-days-in-a-month "Number of Days in a Month") +[Next >](../number-of-days-in-a-month "Number of Days in a Month") ## [1117. Building H2O (Medium)](https://leetcode.com/problems/building-h2o "H2O 生成") diff --git a/problems/bulb-switcher-ii/README.md b/problems/bulb-switcher-ii/README.md index 1e5994bda..2e641f981 100644 --- a/problems/bulb-switcher-ii/README.md +++ b/problems/bulb-switcher-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/second-minimum-node-in-a-binary-tree "Second Minimum Node In a Binary Tree") +[< Previous](../second-minimum-node-in-a-binary-tree "Second Minimum Node In a Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-longest-increasing-subsequence "Number of Longest Increasing Subsequence") +[Next >](../number-of-longest-increasing-subsequence "Number of Longest Increasing Subsequence") ## [672. Bulb Switcher II (Medium)](https://leetcode.com/problems/bulb-switcher-ii "灯泡开关 Ⅱ") @@ -57,7 +57,7 @@

Note: n and m both fit in range [0, 1000].

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Bulb Switcher](https://github.com/openset/leetcode/tree/master/problems/bulb-switcher) (Medium) + 1. [Bulb Switcher](../bulb-switcher) (Medium) diff --git a/problems/bulb-switcher/README.md b/problems/bulb-switcher/README.md index 9b83f3e02..b8cdb6bab 100644 --- a/problems/bulb-switcher/README.md +++ b/problems/bulb-switcher/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-product-of-word-lengths "Maximum Product of Word Lengths") +[< Previous](../maximum-product-of-word-lengths "Maximum Product of Word Lengths")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/generalized-abbreviation "Generalized Abbreviation") +[Next >](../generalized-abbreviation "Generalized Abbreviation") ## [319. Bulb Switcher (Medium)](https://leetcode.com/problems/bulb-switcher "灯泡开关") @@ -28,9 +28,9 @@ So you should return 1, because there is only one bulb is on. ### Related Topics - [[Brainteaser](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Brainteaser](../../tag/brainteaser/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Bulb Switcher II](https://github.com/openset/leetcode/tree/master/problems/bulb-switcher-ii) (Medium) - 1. [Minimum Number of K Consecutive Bit Flips](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-k-consecutive-bit-flips) (Hard) + 1. [Bulb Switcher II](../bulb-switcher-ii) (Medium) + 1. [Minimum Number of K Consecutive Bit Flips](../minimum-number-of-k-consecutive-bit-flips) (Hard) diff --git a/problems/bulls-and-cows/README.md b/problems/bulls-and-cows/README.md index 8986f0056..f2c9dbbc6 100644 --- a/problems/bulls-and-cows/README.md +++ b/problems/bulls-and-cows/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-tree-longest-consecutive-sequence "Binary Tree Longest Consecutive Sequence") +[< Previous](../binary-tree-longest-consecutive-sequence "Binary Tree Longest Consecutive Sequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-increasing-subsequence "Longest Increasing Subsequence") +[Next >](../longest-increasing-subsequence "Longest Increasing Subsequence") ## [299. Bulls and Cows (Easy)](https://leetcode.com/problems/bulls-and-cows "猜数字游戏") @@ -38,4 +38,4 @@

Note: You may assume that the secret number and your friend's guess only contain digits, and their lengths are always equal.

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/burst-balloons/README.md b/problems/burst-balloons/README.md index 61e267b4e..8dff26fd9 100644 --- a/problems/burst-balloons/README.md +++ b/problems/burst-balloons/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sparse-matrix-multiplication "Sparse Matrix Multiplication") +[< Previous](../sparse-matrix-multiplication "Sparse Matrix Multiplication")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/super-ugly-number "Super Ugly Number") +[Next >](../super-ugly-number "Super Ugly Number") ## [312. Burst Balloons (Hard)](https://leetcode.com/problems/burst-balloons "戳气球") @@ -32,8 +32,8 @@ ### Related Topics - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Minimum Cost to Merge Stones](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-to-merge-stones) (Hard) + 1. [Minimum Cost to Merge Stones](../minimum-cost-to-merge-stones) (Hard) diff --git a/problems/bus-routes/README.md b/problems/bus-routes/README.md index 9e114d32f..758dfeff8 100644 --- a/problems/bus-routes/README.md +++ b/problems/bus-routes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-tree-pruning "Binary Tree Pruning") +[< Previous](../binary-tree-pruning "Binary Tree Pruning")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/ambiguous-coordinates "Ambiguous Coordinates") +[Next >](../ambiguous-coordinates "Ambiguous Coordinates") ## [815. Bus Routes (Hard)](https://leetcode.com/problems/bus-routes "公交路线") @@ -35,4 +35,4 @@ The best strategy is take the first bus to the bus stop 7, then take the second ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/camelcase-matching/README.md b/problems/camelcase-matching/README.md index c3794292e..6144214e6 100644 --- a/problems/camelcase-matching/README.md +++ b/problems/camelcase-matching/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sum-of-root-to-leaf-binary-numbers "Sum of Root To Leaf Binary Numbers") +[< Previous](../sum-of-root-to-leaf-binary-numbers "Sum of Root To Leaf Binary Numbers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/video-stitching "Video Stitching") +[Next >](../video-stitching "Video Stitching") ## [1023. Camelcase Matching (Medium)](https://leetcode.com/problems/camelcase-matching "驼峰式匹配") @@ -58,8 +58,8 @@ ### Related Topics - [[Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Trie](../../tag/trie/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/campus-bikes-ii/README.md b/problems/campus-bikes-ii/README.md index 20930ca08..644d66f84 100644 --- a/problems/campus-bikes-ii/README.md +++ b/problems/campus-bikes-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/index-pairs-of-a-string "Index Pairs of a String") +[< Previous](../index-pairs-of-a-string "Index Pairs of a String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/digit-count-in-range "Digit Count in Range") +[Next >](../digit-count-in-range "Digit Count in Range") ## [1066. Campus Bikes II (Medium)](https://leetcode.com/problems/campus-bikes-ii "校园自行车分配 II") @@ -54,11 +54,11 @@ We first assign bike 0 to worker 0, then assign bike 1 to worker 1 or worker 2, ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Campus Bikes](https://github.com/openset/leetcode/tree/master/problems/campus-bikes) (Medium) + 1. [Campus Bikes](../campus-bikes) (Medium) ### Hints
diff --git a/problems/campus-bikes/README.md b/problems/campus-bikes/README.md index 8dd371be8..04a8de88c 100644 --- a/problems/campus-bikes/README.md +++ b/problems/campus-bikes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/confusing-number "Confusing Number") +[< Previous](../confusing-number "Confusing Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimize-rounding-error-to-meet-target "Minimize Rounding Error to Meet Target") +[Next >](../minimize-rounding-error-to-meet-target "Minimize Rounding Error to Meet Target") ## [1057. Campus Bikes (Medium)](https://leetcode.com/problems/campus-bikes "校园自行车分配") @@ -54,11 +54,11 @@ Worker 0 grabs Bike 0 at first. Worker 1 and Worker 2 share the same distance to ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Sort](../../tag/sort/README.md)] ### Similar Questions - 1. [Campus Bikes II](https://github.com/openset/leetcode/tree/master/problems/campus-bikes-ii) (Medium) + 1. [Campus Bikes II](../campus-bikes-ii) (Medium) ### Hints
diff --git a/problems/can-i-win/README.md b/problems/can-i-win/README.md index 2cd44020c..8a62abcae 100644 --- a/problems/can-i-win/README.md +++ b/problems/can-i-win/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/island-perimeter "Island Perimeter") +[< Previous](../island-perimeter "Island Perimeter")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/optimal-account-balancing "Optimal Account Balancing") +[Next >](../optimal-account-balancing "Optimal Account Balancing") ## [464. Can I Win (Medium)](https://leetcode.com/problems/can-i-win "我能赢吗") @@ -41,10 +41,10 @@ Same with other integers chosen by the first player, the second player will alwa

### Related Topics - [[Minimax](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Minimax](../../tag/minimax/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Flip Game II](https://github.com/openset/leetcode/tree/master/problems/flip-game-ii) (Medium) - 1. [Guess Number Higher or Lower II](https://github.com/openset/leetcode/tree/master/problems/guess-number-higher-or-lower-ii) (Medium) - 1. [Predict the Winner](https://github.com/openset/leetcode/tree/master/problems/predict-the-winner) (Medium) + 1. [Flip Game II](../flip-game-ii) (Medium) + 1. [Guess Number Higher or Lower II](../guess-number-higher-or-lower-ii) (Medium) + 1. [Predict the Winner](../predict-the-winner) (Medium) diff --git a/problems/can-make-palindrome-from-substring/README.md b/problems/can-make-palindrome-from-substring/README.md index 9103b7be1..d3949c81a 100644 --- a/problems/can-make-palindrome-from-substring/README.md +++ b/problems/can-make-palindrome-from-substring/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/diet-plan-performance "Diet Plan Performance") +[< Previous](../diet-plan-performance "Diet Plan Performance")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-valid-words-for-each-puzzle "Number of Valid Words for Each Puzzle") +[Next >](../number-of-valid-words-for-each-puzzle "Number of Valid Words for Each Puzzle") ## [1177. Can Make Palindrome from Substring (Medium)](https://leetcode.com/problems/can-make-palindrome-from-substring "构建回文串检测") @@ -46,8 +46,8 @@ queries[4] : substring = "abcda", could be changed to " ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/can-place-flowers/README.md b/problems/can-place-flowers/README.md index da20e1d21..18f55a282 100644 --- a/problems/can-place-flowers/README.md +++ b/problems/can-place-flowers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-compressed-string-iterator "Design Compressed String Iterator") +[< Previous](../design-compressed-string-iterator "Design Compressed String Iterator")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/construct-string-from-binary-tree "Construct String from Binary Tree") +[Next >](../construct-string-from-binary-tree "Construct String from Binary Tree") ## [605. Can Place Flowers (Easy)](https://leetcode.com/problems/can-place-flowers "种花问题") @@ -38,8 +38,8 @@

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Teemo Attacking](https://github.com/openset/leetcode/tree/master/problems/teemo-attacking) (Medium) - 1. [Asteroid Collision](https://github.com/openset/leetcode/tree/master/problems/asteroid-collision) (Medium) + 1. [Teemo Attacking](../teemo-attacking) (Medium) + 1. [Asteroid Collision](../asteroid-collision) (Medium) diff --git a/problems/candy-crush/README.md b/problems/candy-crush/README.md index ab4ed5f32..c5f04453d 100644 --- a/problems/candy-crush/README.md +++ b/problems/candy-crush/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-comments "Remove Comments") +[< Previous](../remove-comments "Remove Comments")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-pivot-index "Find Pivot Index") +[Next >](../find-pivot-index "Find Pivot Index") ## [723. Candy Crush (Medium)](https://leetcode.com/problems/candy-crush "粉碎糖果") @@ -51,8 +51,8 @@ board = ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Hints
diff --git a/problems/candy/README.md b/problems/candy/README.md index 03119f865..4254bd489 100644 --- a/problems/candy/README.md +++ b/problems/candy/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/gas-station "Gas Station") +[< Previous](../gas-station "Gas Station")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/single-number "Single Number") +[Next >](../single-number "Single Number") ## [135. Candy (Hard)](https://leetcode.com/problems/candy "分发糖果") @@ -40,4 +40,4 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/capacity-to-ship-packages-within-d-days/README.md b/problems/capacity-to-ship-packages-within-d-days/README.md index 725416682..82f7876f5 100644 --- a/problems/capacity-to-ship-packages-within-d-days/README.md +++ b/problems/capacity-to-ship-packages-within-d-days/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/pairs-of-songs-with-total-durations-divisible-by-60 "Pairs of Songs With Total Durations Divisible by 60") +[< Previous](../pairs-of-songs-with-total-durations-divisible-by-60 "Pairs of Songs With Total Durations Divisible by 60")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/numbers-with-repeated-digits "Numbers With Repeated Digits") +[Next >](../numbers-with-repeated-digits "Numbers With Repeated Digits") ## [1011. Capacity To Ship Packages Within D Days (Medium)](https://leetcode.com/problems/capacity-to-ship-packages-within-d-days "在 D 天内送达包裹的能力") @@ -69,8 +69,8 @@ A ship capacity of 6 is the minimum to ship all the packages in 3 days like this ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
diff --git a/problems/car-fleet/README.md b/problems/car-fleet/README.md index c6d0d419a..e507d9452 100644 --- a/problems/car-fleet/README.md +++ b/problems/car-fleet/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/peak-index-in-a-mountain-array "Peak Index in a Mountain Array") +[< Previous](../peak-index-in-a-mountain-array "Peak Index in a Mountain Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/k-similar-strings "K-Similar Strings") +[Next >](../k-similar-strings "K-Similar Strings") ## [853. Car Fleet (Medium)](https://leetcode.com/problems/car-fleet "车队") @@ -52,4 +52,4 @@ Note that no other cars meet these fleets before the destination, so the answer ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] + [[Sort](../../tag/sort/README.md)] diff --git a/problems/car-pooling/README.md b/problems/car-pooling/README.md index 3f5a4b143..c7788244d 100644 --- a/problems/car-pooling/README.md +++ b/problems/car-pooling/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/statistics-from-a-large-sample "Statistics from a Large Sample") +[< Previous](../statistics-from-a-large-sample "Statistics from a Large Sample")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-in-mountain-array "Find in Mountain Array") +[Next >](../find-in-mountain-array "Find in Mountain Array") ## [1094. Car Pooling (Medium)](https://leetcode.com/problems/car-pooling "拼车") @@ -73,10 +73,10 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions - 1. [Meeting Rooms II](https://github.com/openset/leetcode/tree/master/problems/meeting-rooms-ii) (Medium) + 1. [Meeting Rooms II](../meeting-rooms-ii) (Medium) ### Hints
diff --git a/problems/card-flipping-game/README.md b/problems/card-flipping-game/README.md index 004e49ed4..ab4b3a66b 100644 --- a/problems/card-flipping-game/README.md +++ b/problems/card-flipping-game/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-to-a-character "Shortest Distance to a Character") +[< Previous](../shortest-distance-to-a-character "Shortest Distance to a Character")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-trees-with-factors "Binary Trees With Factors") +[Next >](../binary-trees-with-factors "Binary Trees With Factors") ## [822. Card Flipping Game (Medium)](https://leetcode.com/problems/card-flipping-game "翻转卡片游戏") diff --git a/problems/cat-and-mouse/README.md b/problems/cat-and-mouse/README.md index f15258105..51ad3256e 100644 --- a/problems/cat-and-mouse/README.md +++ b/problems/cat-and-mouse/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sort-an-array "Sort an Array") +[< Previous](../sort-an-array "Sort an Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/x-of-a-kind-in-a-deck-of-cards "X of a Kind in a Deck of Cards") +[Next >](../x-of-a-kind-in-a-deck-of-cards "X of a Kind in a Deck of Cards") ## [913. Cat and Mouse (Hard)](https://leetcode.com/problems/cat-and-mouse "猫和老鼠") @@ -62,5 +62,5 @@ ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Minimax](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Minimax](../../tag/minimax/README.md)] diff --git a/problems/cells-with-odd-values-in-a-matrix/README.md b/problems/cells-with-odd-values-in-a-matrix/README.md index c64a42f33..6c2beb96f 100644 --- a/problems/cells-with-odd-values-in-a-matrix/README.md +++ b/problems/cells-with-odd-values-in-a-matrix/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/average-selling-price "Average Selling Price") +[< Previous](../average-selling-price "Average Selling Price")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reconstruct-a-2-row-binary-matrix "Reconstruct a 2-Row Binary Matrix") +[Next >](../reconstruct-a-2-row-binary-matrix "Reconstruct a 2-Row Binary Matrix") ## [1252. Cells with Odd Values in a Matrix (Easy)](https://leetcode.com/problems/cells-with-odd-values-in-a-matrix "奇数值单元格的数目") @@ -46,7 +46,7 @@ The final matrix will be [[1,3,1],[1,3,1]] which contains 6 odd numbers. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/chalkboard-xor-game/README.md b/problems/chalkboard-xor-game/README.md index 446f0f6db..26d614dcb 100644 --- a/problems/chalkboard-xor-game/README.md +++ b/problems/chalkboard-xor-game/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/expressive-words "Expressive Words") +[< Previous](../expressive-words "Expressive Words")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/subdomain-visit-count "Subdomain Visit Count") +[Next >](../subdomain-visit-count "Subdomain Visit Count") ## [810. Chalkboard XOR Game (Hard)](https://leetcode.com/problems/chalkboard-xor-game "黑板异或游戏") @@ -38,4 +38,4 @@ If Alice erases 2 first, now nums becomes [1, 1]. The bitwise XOR of all the ele

 

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/champagne-tower/README.md b/problems/champagne-tower/README.md index 33a68170e..005487ba5 100644 --- a/problems/champagne-tower/README.md +++ b/problems/champagne-tower/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/smallest-rotation-with-highest-score "Smallest Rotation with Highest Score") +[< Previous](../smallest-rotation-with-highest-score "Smallest Rotation with Highest Score")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/similar-rgb-color "Similar RGB Color") +[Next >](../similar-rgb-color "Similar RGB Color") ## [799. Champagne Tower (Medium)](https://leetcode.com/problems/champagne-tower "香槟塔") diff --git a/problems/cheapest-flights-within-k-stops/README.md b/problems/cheapest-flights-within-k-stops/README.md index 557ccb4bc..cba708f69 100644 --- a/problems/cheapest-flights-within-k-stops/README.md +++ b/problems/cheapest-flights-within-k-stops/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/k-th-smallest-prime-fraction "K-th Smallest Prime Fraction") +[< Previous](../k-th-smallest-prime-fraction "K-th Smallest Prime Fraction")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/rotated-digits "Rotated Digits") +[Next >](../rotated-digits "Rotated Digits") ## [787. Cheapest Flights Within K Stops (Medium)](https://leetcode.com/problems/cheapest-flights-within-k-stops "K 站中转内最便宜的航班") @@ -51,9 +51,9 @@ The cheapest price from city 0 to city 2 with at most ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Maximum Vacation Days](https://github.com/openset/leetcode/tree/master/problems/maximum-vacation-days) (Hard) + 1. [Maximum Vacation Days](../maximum-vacation-days) (Hard) diff --git a/problems/check-completeness-of-a-binary-tree/README.md b/problems/check-completeness-of-a-binary-tree/README.md index 7571bfc11..1640ba56e 100644 --- a/problems/check-completeness-of-a-binary-tree/README.md +++ b/problems/check-completeness-of-a-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/prison-cells-after-n-days "Prison Cells After N Days") +[< Previous](../prison-cells-after-n-days "Prison Cells After N Days")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/regions-cut-by-slashes "Regions Cut By Slashes") +[Next >](../regions-cut-by-slashes "Regions Cut By Slashes") ## [958. Check Completeness of a Binary Tree (Medium)](https://leetcode.com/problems/check-completeness-of-a-binary-tree "二叉树的完全性检验") @@ -49,4 +49,4 @@ In a complete binary tree every level, except possibly the last, is completely f ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] diff --git a/problems/check-if-a-number-is-majority-element-in-a-sorted-array/README.md b/problems/check-if-a-number-is-majority-element-in-a-sorted-array/README.md index 91e27e31f..ca9cb277e 100644 --- a/problems/check-if-a-number-is-majority-element-in-a-sorted-array/README.md +++ b/problems/check-if-a-number-is-majority-element-in-a-sorted-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/article-views-ii "Article Views II") +[< Previous](../article-views-ii "Article Views II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-swaps-to-group-all-1s-together "Minimum Swaps to Group All 1's Together") +[Next >](../minimum-swaps-to-group-all-1s-together "Minimum Swaps to Group All 1's Together") ## [1150. Check If a Number Is Majority Element in a Sorted Array (Easy)](https://leetcode.com/problems/check-if-a-number-is-majority-element-in-a-sorted-array "检查一个数是否在数组中占绝大多数") @@ -48,12 +48,12 @@ Thus, 101 is not a majority element because 2 > 4/2 is false. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Majority Element](https://github.com/openset/leetcode/tree/master/problems/majority-element) (Easy) - 1. [Majority Element II](https://github.com/openset/leetcode/tree/master/problems/majority-element-ii) (Medium) + 1. [Majority Element](../majority-element) (Easy) + 1. [Majority Element II](../majority-element-ii) (Medium) ### Hints
diff --git a/problems/check-if-it-is-a-good-array/README.md b/problems/check-if-it-is-a-good-array/README.md index fab812915..862b5b1c0 100644 --- a/problems/check-if-it-is-a-good-array/README.md +++ b/problems/check-if-it-is-a-good-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-remove-to-make-valid-parentheses "Minimum Remove to Make Valid Parentheses") +[< Previous](../minimum-remove-to-make-valid-parentheses "Minimum Remove to Make Valid Parentheses")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/average-selling-price "Average Selling Price") +[Next >](../average-selling-price "Average Selling Price") ## [1250. Check If It Is a Good Array (Hard)](https://leetcode.com/problems/check-if-it-is-a-good-array "检查「好数组」") @@ -50,7 +50,7 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/check-if-it-is-a-straight-line/README.md b/problems/check-if-it-is-a-straight-line/README.md index f1a384a10..f56c7a5e8 100644 --- a/problems/check-if-it-is-a-straight-line/README.md +++ b/problems/check-if-it-is-a-straight-line/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/divide-chocolate "Divide Chocolate") +[< Previous](../divide-chocolate "Divide Chocolate")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-sub-folders-from-the-filesystem "Remove Sub-Folders from the Filesystem") +[Next >](../remove-sub-folders-from-the-filesystem "Remove Sub-Folders from the Filesystem") ## [1232. Check If It Is a Straight Line (Easy)](https://leetcode.com/problems/check-if-it-is-a-straight-line "缀点成线") @@ -45,9 +45,9 @@ ### Related Topics - [[Geometry](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/check-if-word-is-valid-after-substitutions/README.md b/problems/check-if-word-is-valid-after-substitutions/README.md index a15f0994a..c52d7b9f1 100644 --- a/problems/check-if-word-is-valid-after-substitutions/README.md +++ b/problems/check-if-word-is-valid-after-substitutions/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-common-characters "Find Common Characters") +[< Previous](../find-common-characters "Find Common Characters")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones-iii "Max Consecutive Ones III") +[Next >](../max-consecutive-ones-iii "Max Consecutive Ones III") ## [1003. Check If Word Is Valid After Substitutions (Medium)](https://leetcode.com/problems/check-if-word-is-valid-after-substitutions "检查替换后的词是否有效") @@ -78,8 +78,8 @@ Then we can insert "abc" before the last letter, resulting in "ab ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Valid Parentheses](https://github.com/openset/leetcode/tree/master/problems/valid-parentheses) (Easy) + 1. [Valid Parentheses](../valid-parentheses) (Easy) diff --git a/problems/cherry-pickup/README.md b/problems/cherry-pickup/README.md index dc3c1ce97..d78c181cc 100644 --- a/problems/cherry-pickup/README.md +++ b/problems/cherry-pickup/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/delete-and-earn "Delete and Earn") +[< Previous](../delete-and-earn "Delete and Earn")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/closest-leaf-in-a-binary-tree "Closest Leaf in a Binary Tree") +[Next >](../closest-leaf-in-a-binary-tree "Closest Leaf in a Binary Tree") ## [741. Cherry Pickup (Hard)](https://leetcode.com/problems/cherry-pickup "摘樱桃") @@ -67,8 +67,8 @@ The total number of cherries picked up is 5, and this is the maximum possible. ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Minimum Path Sum](https://github.com/openset/leetcode/tree/master/problems/minimum-path-sum) (Medium) - 1. [Dungeon Game](https://github.com/openset/leetcode/tree/master/problems/dungeon-game) (Hard) + 1. [Minimum Path Sum](../minimum-path-sum) (Medium) + 1. [Dungeon Game](../dungeon-game) (Hard) diff --git a/problems/circular-array-loop/README.md b/problems/circular-array-loop/README.md index fdc034725..64aa6188a 100644 --- a/problems/circular-array-loop/README.md +++ b/problems/circular-array-loop/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/132-pattern "132 Pattern") +[< Previous](../132-pattern "132 Pattern")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/poor-pigs "Poor Pigs") +[Next >](../poor-pigs "Poor Pigs") ## [457. Circular Array Loop (Medium)](https://leetcode.com/problems/circular-array-loop "环形数组循环") @@ -57,5 +57,5 @@

Could you solve it in O(n) time complexity and O(1) extra space complexity?

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/circular-permutation-in-binary-representation/README.md b/problems/circular-permutation-in-binary-representation/README.md index 69ea0a51d..db853bdb9 100644 --- a/problems/circular-permutation-in-binary-representation/README.md +++ b/problems/circular-permutation-in-binary-representation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-positive-integer-solution-for-a-given-equation "Find Positive Integer Solution for a Given Equation") +[< Previous](../find-positive-integer-solution-for-a-given-equation "Find Positive Integer Solution for a Given Equation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-a-concatenated-string-with-unique-characters "Maximum Length of a Concatenated String with Unique Characters") +[Next >](../maximum-length-of-a-concatenated-string-with-unique-characters "Maximum Length of a Concatenated String with Unique Characters") ## [1238. Circular Permutation in Binary Representation (Medium)](https://leetcode.com/problems/circular-permutation-in-binary-representation "循环码排列") @@ -46,7 +46,7 @@ All the adjacent element differ by one bit. Another valid permutation is [3,1,0, ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/classes-more-than-5-students/README.md b/problems/classes-more-than-5-students/README.md index 9988db34b..caf9e3dd3 100644 --- a/problems/classes-more-than-5-students/README.md +++ b/problems/classes-more-than-5-students/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/big-countries "Big Countries") +[< Previous](../big-countries "Big Countries")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/friend-requests-i-overall-acceptance-rate "Friend Requests I: Overall Acceptance Rate") +[Next >](../friend-requests-i-overall-acceptance-rate "Friend Requests I: Overall Acceptance Rate") ## [596. Classes More Than 5 Students (Easy)](https://leetcode.com/problems/classes-more-than-5-students "超过5名学生的课") diff --git a/problems/climbing-stairs/README.md b/problems/climbing-stairs/README.md index cac4c346b..d75cf3aa3 100644 --- a/problems/climbing-stairs/README.md +++ b/problems/climbing-stairs/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sqrtx "Sqrt(x)") +[< Previous](../sqrtx "Sqrt(x)")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/simplify-path "Simplify Path") +[Next >](../simplify-path "Simplify Path") ## [70. Climbing Stairs (Easy)](https://leetcode.com/problems/climbing-stairs "爬楼梯") @@ -39,12 +39,12 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Min Cost Climbing Stairs](https://github.com/openset/leetcode/tree/master/problems/min-cost-climbing-stairs) (Easy) - 1. [Fibonacci Number](https://github.com/openset/leetcode/tree/master/problems/fibonacci-number) (Easy) - 1. [N-th Tribonacci Number](https://github.com/openset/leetcode/tree/master/problems/n-th-tribonacci-number) (Easy) + 1. [Min Cost Climbing Stairs](../min-cost-climbing-stairs) (Easy) + 1. [Fibonacci Number](../fibonacci-number) (Easy) + 1. [N-th Tribonacci Number](../n-th-tribonacci-number) (Easy) ### Hints
diff --git a/problems/clone-graph/README.md b/problems/clone-graph/README.md index 3a6b39079..83ddbe13a 100644 --- a/problems/clone-graph/README.md +++ b/problems/clone-graph/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/palindrome-partitioning-ii "Palindrome Partitioning II") +[< Previous](../palindrome-partitioning-ii "Palindrome Partitioning II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/gas-station "Gas Station") +[Next >](../gas-station "Gas Station") ## [133. Clone Graph (Medium)](https://leetcode.com/problems/clone-graph "克隆图") @@ -42,9 +42,9 @@ Node 4's value is 4, and it has two neighbors: Node 1 and 3. ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] ### Similar Questions - 1. [Copy List with Random Pointer](https://github.com/openset/leetcode/tree/master/problems/copy-list-with-random-pointer) (Medium) + 1. [Copy List with Random Pointer](../copy-list-with-random-pointer) (Medium) diff --git a/problems/closest-binary-search-tree-value-ii/README.md b/problems/closest-binary-search-tree-value-ii/README.md index 0262b09a4..b7fc0e007 100644 --- a/problems/closest-binary-search-tree-value-ii/README.md +++ b/problems/closest-binary-search-tree-value-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/encode-and-decode-strings "Encode and Decode Strings") +[< Previous](../encode-and-decode-strings "Encode and Decode Strings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/integer-to-english-words "Integer to English Words") +[Next >](../integer-to-english-words "Integer to English Words") ## [272. Closest Binary Search Tree Value II (Hard)](https://leetcode.com/problems/closest-binary-search-tree-value-ii "最接近的二叉搜索树值 II") @@ -38,12 +38,12 @@ Assume that the BST is balanced, could you solve it in less than O(n) runtime (where n = total nodes)?

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Binary Tree Inorder Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-inorder-traversal) (Medium) - 1. [Closest Binary Search Tree Value](https://github.com/openset/leetcode/tree/master/problems/closest-binary-search-tree-value) (Easy) + 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Medium) + 1. [Closest Binary Search Tree Value](../closest-binary-search-tree-value) (Easy) ### Hints
diff --git a/problems/closest-binary-search-tree-value/README.md b/problems/closest-binary-search-tree-value/README.md index 41f7790a7..8351a1bbd 100644 --- a/problems/closest-binary-search-tree-value/README.md +++ b/problems/closest-binary-search-tree-value/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/alien-dictionary "Alien Dictionary") +[< Previous](../alien-dictionary "Alien Dictionary")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/encode-and-decode-strings "Encode and Decode Strings") +[Next >](../encode-and-decode-strings "Encode and Decode Strings") ## [270. Closest Binary Search Tree Value (Easy)](https://leetcode.com/problems/closest-binary-search-tree-value "最接近的二叉搜索树值") @@ -35,10 +35,10 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Count Complete Tree Nodes](https://github.com/openset/leetcode/tree/master/problems/count-complete-tree-nodes) (Medium) - 1. [Closest Binary Search Tree Value II](https://github.com/openset/leetcode/tree/master/problems/closest-binary-search-tree-value-ii) (Hard) - 1. [Search in a Binary Search Tree](https://github.com/openset/leetcode/tree/master/problems/search-in-a-binary-search-tree) (Easy) + 1. [Count Complete Tree Nodes](../count-complete-tree-nodes) (Medium) + 1. [Closest Binary Search Tree Value II](../closest-binary-search-tree-value-ii) (Hard) + 1. [Search in a Binary Search Tree](../search-in-a-binary-search-tree) (Easy) diff --git a/problems/closest-leaf-in-a-binary-tree/README.md b/problems/closest-leaf-in-a-binary-tree/README.md index 234f6afd4..ae9ad07e2 100644 --- a/problems/closest-leaf-in-a-binary-tree/README.md +++ b/problems/closest-leaf-in-a-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/cherry-pickup "Cherry Pickup") +[< Previous](../cherry-pickup "Cherry Pickup")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/network-delay-time "Network Delay Time") +[Next >](../network-delay-time "Network Delay Time") ## [742. Closest Leaf in a Binary Tree (Medium)](https://leetcode.com/problems/closest-leaf-in-a-binary-tree "二叉树最近的叶节点") @@ -72,7 +72,7 @@ Diagram of binary tree:

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Hints
diff --git a/problems/clumsy-factorial/README.md b/problems/clumsy-factorial/README.md index 269eef531..dcd08ce1b 100644 --- a/problems/clumsy-factorial/README.md +++ b/problems/clumsy-factorial/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximize-sum-of-array-after-k-negations "Maximize Sum Of Array After K Negations") +[< Previous](../maximize-sum-of-array-after-k-negations "Maximize Sum Of Array After K Negations")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-domino-rotations-for-equal-row "Minimum Domino Rotations For Equal Row") +[Next >](../minimum-domino-rotations-for-equal-row "Minimum Domino Rotations For Equal Row") ## [1006. Clumsy Factorial (Medium)](https://leetcode.com/problems/clumsy-factorial "笨阶乘") @@ -49,4 +49,4 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/coin-change-2/README.md b/problems/coin-change-2/README.md index 66a73d957..8ab989868 100644 --- a/problems/coin-change-2/README.md +++ b/problems/coin-change-2/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/super-washing-machines "Super Washing Machines") +[< Previous](../super-washing-machines "Super Washing Machines")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/random-flip-matrix "Random Flip Matrix") +[Next >](../random-flip-matrix "Random Flip Matrix") ## [518. Coin Change 2 (Medium)](https://leetcode.com/problems/coin-change-2 "零钱兑换 II") diff --git a/problems/coin-change/README.md b/problems/coin-change/README.md index 080a65096..813ce28ba 100644 --- a/problems/coin-change/README.md +++ b/problems/coin-change/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/create-maximum-number "Create Maximum Number") +[< Previous](../create-maximum-number "Create Maximum Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-connected-components-in-an-undirected-graph "Number of Connected Components in an Undirected Graph") +[Next >](../number-of-connected-components-in-an-undirected-graph "Number of Connected Components in an Undirected Graph") ## [322. Coin Change (Medium)](https://leetcode.com/problems/coin-change "零钱兑换") @@ -31,7 +31,7 @@ You may assume that you have an infinite number of each kind of coin.

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Minimum Cost For Tickets](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-for-tickets) (Medium) + 1. [Minimum Cost For Tickets](../minimum-cost-for-tickets) (Medium) diff --git a/problems/coin-path/README.md b/problems/coin-path/README.md index d4412128b..d230d792b 100644 --- a/problems/coin-path/README.md +++ b/problems/coin-path/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/print-binary-tree "Print Binary Tree") +[< Previous](../print-binary-tree "Print Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/robot-return-to-origin "Robot Return to Origin") +[Next >](../robot-return-to-origin "Robot Return to Origin") ## [656. Coin Path (Hard)](https://leetcode.com/problems/coin-path "金币路径") @@ -49,8 +49,8 @@

 

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [House Robber](https://github.com/openset/leetcode/tree/master/problems/house-robber) (Easy) - 1. [House Robber II](https://github.com/openset/leetcode/tree/master/problems/house-robber-ii) (Medium) + 1. [House Robber](../house-robber) (Easy) + 1. [House Robber II](../house-robber-ii) (Medium) diff --git a/problems/coloring-a-border/README.md b/problems/coloring-a-border/README.md index b8d34c5df..21f04e19a 100644 --- a/problems/coloring-a-border/README.md +++ b/problems/coloring-a-border/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/moving-stones-until-consecutive "Moving Stones Until Consecutive") +[< Previous](../moving-stones-until-consecutive "Moving Stones Until Consecutive")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/uncrossed-lines "Uncrossed Lines") +[Next >](../uncrossed-lines "Uncrossed Lines") ## [1034. Coloring A Border (Medium)](https://leetcode.com/problems/coloring-a-border "边框着色") @@ -59,10 +59,10 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Island Perimeter](https://github.com/openset/leetcode/tree/master/problems/island-perimeter) (Easy) + 1. [Island Perimeter](../island-perimeter) (Easy) ### Hints
diff --git a/problems/combination-sum-ii/README.md b/problems/combination-sum-ii/README.md index d1bce0f92..765af270b 100644 --- a/problems/combination-sum-ii/README.md +++ b/problems/combination-sum-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/combination-sum "Combination Sum") +[< Previous](../combination-sum "Combination Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/first-missing-positive "First Missing Positive") +[Next >](../first-missing-positive "First Missing Positive") ## [40. Combination Sum II (Medium)](https://leetcode.com/problems/combination-sum-ii "组合总和 II") @@ -47,8 +47,8 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Array](../../tag/array/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Combination Sum](https://github.com/openset/leetcode/tree/master/problems/combination-sum) (Medium) + 1. [Combination Sum](../combination-sum) (Medium) diff --git a/problems/combination-sum-iii/README.md b/problems/combination-sum-iii/README.md index 6c010289a..806610e75 100644 --- a/problems/combination-sum-iii/README.md +++ b/problems/combination-sum-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/kth-largest-element-in-an-array "Kth Largest Element in an Array") +[< Previous](../kth-largest-element-in-an-array "Kth Largest Element in an Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate "Contains Duplicate") +[Next >](../contains-duplicate "Contains Duplicate") ## [216. Combination Sum III (Medium)](https://leetcode.com/problems/combination-sum-iii "组合总和 III") @@ -37,8 +37,8 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Array](../../tag/array/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Combination Sum](https://github.com/openset/leetcode/tree/master/problems/combination-sum) (Medium) + 1. [Combination Sum](../combination-sum) (Medium) diff --git a/problems/combination-sum-iv/README.md b/problems/combination-sum-iv/README.md index d0b6efb6f..5b6a981df 100644 --- a/problems/combination-sum-iv/README.md +++ b/problems/combination-sum-iv/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/wiggle-subsequence "Wiggle Subsequence") +[< Previous](../wiggle-subsequence "Wiggle Subsequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-element-in-a-sorted-matrix "Kth Smallest Element in a Sorted Matrix") +[Next >](../kth-smallest-element-in-a-sorted-matrix "Kth Smallest Element in a Sorted Matrix") ## [377. Combination Sum IV (Medium)](https://leetcode.com/problems/combination-sum-iv "组合总和 Ⅳ") @@ -44,7 +44,7 @@ What limitation we need to add to the question to allow negative numbers?

Special thanks to @pbrother for adding this problem and creating all test cases.

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Combination Sum](https://github.com/openset/leetcode/tree/master/problems/combination-sum) (Medium) + 1. [Combination Sum](../combination-sum) (Medium) diff --git a/problems/combination-sum/README.md b/problems/combination-sum/README.md index 18cff6162..3e9c9ac70 100644 --- a/problems/combination-sum/README.md +++ b/problems/combination-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/count-and-say "Count and Say") +[< Previous](../count-and-say "Count and Say")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/combination-sum-ii "Combination Sum II") +[Next >](../combination-sum-ii "Combination Sum II") ## [39. Combination Sum (Medium)](https://leetcode.com/problems/combination-sum "组合总和") @@ -46,13 +46,13 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Array](../../tag/array/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Letter Combinations of a Phone Number](https://github.com/openset/leetcode/tree/master/problems/letter-combinations-of-a-phone-number) (Medium) - 1. [Combination Sum II](https://github.com/openset/leetcode/tree/master/problems/combination-sum-ii) (Medium) - 1. [Combinations](https://github.com/openset/leetcode/tree/master/problems/combinations) (Medium) - 1. [Combination Sum III](https://github.com/openset/leetcode/tree/master/problems/combination-sum-iii) (Medium) - 1. [Factor Combinations](https://github.com/openset/leetcode/tree/master/problems/factor-combinations) (Medium) - 1. [Combination Sum IV](https://github.com/openset/leetcode/tree/master/problems/combination-sum-iv) (Medium) + 1. [Letter Combinations of a Phone Number](../letter-combinations-of-a-phone-number) (Medium) + 1. [Combination Sum II](../combination-sum-ii) (Medium) + 1. [Combinations](../combinations) (Medium) + 1. [Combination Sum III](../combination-sum-iii) (Medium) + 1. [Factor Combinations](../factor-combinations) (Medium) + 1. [Combination Sum IV](../combination-sum-iv) (Medium) diff --git a/problems/combinations/README.md b/problems/combinations/README.md index 66f22628c..196e8c701 100644 --- a/problems/combinations/README.md +++ b/problems/combinations/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-window-substring "Minimum Window Substring") +[< Previous](../minimum-window-substring "Minimum Window Substring")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/subsets "Subsets") +[Next >](../subsets "Subsets") ## [77. Combinations (Medium)](https://leetcode.com/problems/combinations "组合") @@ -29,8 +29,8 @@ ### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Combination Sum](https://github.com/openset/leetcode/tree/master/problems/combination-sum) (Medium) - 1. [Permutations](https://github.com/openset/leetcode/tree/master/problems/permutations) (Medium) + 1. [Combination Sum](../combination-sum) (Medium) + 1. [Permutations](../permutations) (Medium) diff --git a/problems/combine-two-tables/README.md b/problems/combine-two-tables/README.md index 45ff44fa0..c86061faa 100644 --- a/problems/combine-two-tables/README.md +++ b/problems/combine-two-tables/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/dungeon-game "Dungeon Game") +[< Previous](../dungeon-game "Dungeon Game")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/second-highest-salary "Second Highest Salary") +[Next >](../second-highest-salary "Second Highest Salary") ## [175. Combine Two Tables (Easy)](https://leetcode.com/problems/combine-two-tables "组合两个表") @@ -47,4 +47,4 @@ FirstName, LastName, City, State ### Similar Questions - 1. [Employee Bonus](https://github.com/openset/leetcode/tree/master/problems/employee-bonus) (Easy) + 1. [Employee Bonus](../employee-bonus) (Easy) diff --git a/problems/compare-strings-by-frequency-of-the-smallest-character/README.md b/problems/compare-strings-by-frequency-of-the-smallest-character/README.md index f964282e5..c17b913ac 100644 --- a/problems/compare-strings-by-frequency-of-the-smallest-character/README.md +++ b/problems/compare-strings-by-frequency-of-the-smallest-character/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/invalid-transactions "Invalid Transactions") +[< Previous](../invalid-transactions "Invalid Transactions")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-zero-sum-consecutive-nodes-from-linked-list "Remove Zero Sum Consecutive Nodes from Linked List") +[Next >](../remove-zero-sum-consecutive-nodes-from-linked-list "Remove Zero Sum Consecutive Nodes from Linked List") ## [1170. Compare Strings by Frequency of the Smallest Character (Easy)](https://leetcode.com/problems/compare-strings-by-frequency-of-the-smallest-character "比较字符串最小字母出现频次") @@ -43,8 +43,8 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/compare-version-numbers/README.md b/problems/compare-version-numbers/README.md index 178af1b2c..b1fe1be1b 100644 --- a/problems/compare-version-numbers/README.md +++ b/problems/compare-version-numbers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-gap "Maximum Gap") +[< Previous](../maximum-gap "Maximum Gap")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/fraction-to-recurring-decimal "Fraction to Recurring Decimal") +[Next >](../fraction-to-recurring-decimal "Fraction to Recurring Decimal") ## [165. Compare Version Numbers (Medium)](https://leetcode.com/problems/compare-version-numbers "比较版本号") @@ -57,4 +57,4 @@ If version1 > version2 return 1;& ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/complement-of-base-10-integer/README.md b/problems/complement-of-base-10-integer/README.md index b40f124c2..97dfeceb3 100644 --- a/problems/complement-of-base-10-integer/README.md +++ b/problems/complement-of-base-10-integer/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/construct-binary-search-tree-from-preorder-traversal "Construct Binary Search Tree from Preorder Traversal") +[< Previous](../construct-binary-search-tree-from-preorder-traversal "Construct Binary Search Tree from Preorder Traversal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/pairs-of-songs-with-total-durations-divisible-by-60 "Pairs of Songs With Total Durations Divisible by 60") +[Next >](../pairs-of-songs-with-total-durations-divisible-by-60 "Pairs of Songs With Total Durations Divisible by 60") ## [1009. Complement of Base 10 Integer (Easy)](https://leetcode.com/problems/complement-of-base-10-integer "十进制整数的反码") @@ -61,7 +61,7 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/complete-binary-tree-inserter/README.md b/problems/complete-binary-tree-inserter/README.md index 4b4dbea2c..3b690771a 100644 --- a/problems/complete-binary-tree-inserter/README.md +++ b/problems/complete-binary-tree-inserter/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-sum-circular-subarray "Maximum Sum Circular Subarray") +[< Previous](../maximum-sum-circular-subarray "Maximum Sum Circular Subarray")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-music-playlists "Number of Music Playlists") +[Next >](../number-of-music-playlists "Number of Music Playlists") ## [919. Complete Binary Tree Inserter (Medium)](https://leetcode.com/problems/complete-binary-tree-inserter "完全二叉树插入器") @@ -62,4 +62,4 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] diff --git a/problems/complex-number-multiplication/README.md b/problems/complex-number-multiplication/README.md index 02543cc9f..327b453c3 100644 --- a/problems/complex-number-multiplication/README.md +++ b/problems/complex-number-multiplication/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-string "Construct Binary Tree from String") +[< Previous](../construct-binary-tree-from-string "Construct Binary Tree from String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/convert-bst-to-greater-tree "Convert BST to Greater Tree") +[Next >](../convert-bst-to-greater-tree "Convert BST to Greater Tree") ## [537. Complex Number Multiplication (Medium)](https://leetcode.com/problems/complex-number-multiplication "复数乘法") @@ -42,5 +42,5 @@ You need to return a string representing their multiplication. Note i2 ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/concatenated-words/README.md b/problems/concatenated-words/README.md index c00ec694d..bb66dc160 100644 --- a/problems/concatenated-words/README.md +++ b/problems/concatenated-words/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/encode-string-with-shortest-length "Encode String with Shortest Length") +[< Previous](../encode-string-with-shortest-length "Encode String with Shortest Length")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/matchsticks-to-square "Matchsticks to Square") +[Next >](../matchsticks-to-square "Matchsticks to Square") ## [472. Concatenated Words (Hard)](https://leetcode.com/problems/concatenated-words "连接词") @@ -34,9 +34,9 @@ Given a list of words (without duplicates), please write a program that r

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Word Break II](https://github.com/openset/leetcode/tree/master/problems/word-break-ii) (Hard) + 1. [Word Break II](../word-break-ii) (Hard) diff --git a/problems/confusing-number-ii/README.md b/problems/confusing-number-ii/README.md index d2a3b2093..22064adde 100644 --- a/problems/confusing-number-ii/README.md +++ b/problems/confusing-number-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/brace-expansion "Brace Expansion") +[< Previous](../brace-expansion "Brace Expansion")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/duplicate-zeros "Duplicate Zeros") +[Next >](../duplicate-zeros "Duplicate Zeros") ## [1088. Confusing Number II (Hard)](https://leetcode.com/problems/confusing-number-ii "易混淆数 II") @@ -52,11 +52,11 @@ The confusing numbers are [6,9,10,16,18,19,60,61,66,68,80,81,86,89,90,91,98,99,1 ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Math](../../tag/math/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Confusing Number](https://github.com/openset/leetcode/tree/master/problems/confusing-number) (Easy) + 1. [Confusing Number](../confusing-number) (Easy) ### Hints
diff --git a/problems/confusing-number/README.md b/problems/confusing-number/README.md index 3619109cd..63070cfc9 100644 --- a/problems/confusing-number/README.md +++ b/problems/confusing-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-way-to-form-string "Shortest Way to Form String") +[< Previous](../shortest-way-to-form-string "Shortest Way to Form String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/campus-bikes "Campus Bikes") +[Next >](../campus-bikes "Campus Bikes") ## [1056. Confusing Number (Easy)](https://leetcode.com/problems/confusing-number "易混淆数") @@ -71,11 +71,11 @@ We get an invalid number after rotating 25. ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Strobogrammatic Number](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number) (Easy) - 1. [Confusing Number II](https://github.com/openset/leetcode/tree/master/problems/confusing-number-ii) (Hard) + 1. [Strobogrammatic Number](../strobogrammatic-number) (Easy) + 1. [Confusing Number II](../confusing-number-ii) (Hard) ### Hints
diff --git a/problems/connecting-cities-with-minimum-cost/README.md b/problems/connecting-cities-with-minimum-cost/README.md index 3b835adf4..8809b7075 100644 --- a/problems/connecting-cities-with-minimum-cost/README.md +++ b/problems/connecting-cities-with-minimum-cost/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/armstrong-number "Armstrong Number") +[< Previous](../armstrong-number "Armstrong Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/parallel-courses "Parallel Courses") +[Next >](../parallel-courses "Parallel Courses") ## [1135. Connecting Cities With Minimum Cost (Medium)](https://leetcode.com/problems/connecting-cities-with-minimum-cost "最低成本联通所有城市") @@ -54,8 +54,8 @@ There is no way to connect all cities even if all edges are used. ### Related Topics - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] ### Hints
diff --git a/problems/consecutive-available-seats/README.md b/problems/consecutive-available-seats/README.md index 1167c7c46..30ecfa1fb 100644 --- a/problems/consecutive-available-seats/README.md +++ b/problems/consecutive-available-seats/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/friend-requests-ii-who-has-the-most-friends "Friend Requests II: Who Has the Most Friends") +[< Previous](../friend-requests-ii-who-has-the-most-friends "Friend Requests II: Who Has the Most Friends")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-compressed-string-iterator "Design Compressed String Iterator") +[Next >](../design-compressed-string-iterator "Design Compressed String Iterator") ## [603. Consecutive Available Seats (Easy)](https://leetcode.com/problems/consecutive-available-seats "连续空余座位") diff --git a/problems/consecutive-numbers-sum/README.md b/problems/consecutive-numbers-sum/README.md index eafadca7d..d8a56e19e 100644 --- a/problems/consecutive-numbers-sum/README.md +++ b/problems/consecutive-numbers-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/unique-letter-string "Unique Letter String") +[< Previous](../unique-letter-string "Unique Letter String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/positions-of-large-groups "Positions of Large Groups") +[Next >](../positions-of-large-groups "Positions of Large Groups") ## [829. Consecutive Numbers Sum (Hard)](https://leetcode.com/problems/consecutive-numbers-sum "连续整数求和") @@ -37,4 +37,4 @@

Note: 1 <= N <= 10 ^ 9.

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/consecutive-numbers/README.md b/problems/consecutive-numbers/README.md index a84874f18..6a5efe60c 100644 --- a/problems/consecutive-numbers/README.md +++ b/problems/consecutive-numbers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/largest-number "Largest Number") +[< Previous](../largest-number "Largest Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/employees-earning-more-than-their-managers "Employees Earning More Than Their Managers") +[Next >](../employees-earning-more-than-their-managers "Employees Earning More Than Their Managers") ## [180. Consecutive Numbers (Medium)](https://leetcode.com/problems/consecutive-numbers "连续出现的数字") diff --git a/problems/construct-binary-search-tree-from-preorder-traversal/README.md b/problems/construct-binary-search-tree-from-preorder-traversal/README.md index fc00d9b00..982740fb7 100644 --- a/problems/construct-binary-search-tree-from-preorder-traversal/README.md +++ b/problems/construct-binary-search-tree-from-preorder-traversal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-domino-rotations-for-equal-row "Minimum Domino Rotations For Equal Row") +[< Previous](../minimum-domino-rotations-for-equal-row "Minimum Domino Rotations For Equal Row")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/complement-of-base-10-integer "Complement of Base 10 Integer") +[Next >](../complement-of-base-10-integer "Complement of Base 10 Integer") ## [1008. Construct Binary Search Tree from Preorder Traversal (Medium)](https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal "先序遍历构造二叉树") @@ -35,4 +35,4 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] diff --git a/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md b/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md index 3b827e726..6cab3faca 100644 --- a/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md +++ b/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-preorder-and-inorder-traversal "Construct Binary Tree from Preorder and Inorder Traversal") +[< Previous](../construct-binary-tree-from-preorder-and-inorder-traversal "Construct Binary Tree from Preorder and Inorder Traversal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal-ii "Binary Tree Level Order Traversal II") +[Next >](../binary-tree-level-order-traversal-ii "Binary Tree Level Order Traversal II") ## [106. Construct Binary Tree from Inorder and Postorder Traversal (Medium)](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal "从中序与后序遍历序列构造二叉树") @@ -33,9 +33,9 @@ postorder = [9,15,7,20,3] ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Construct Binary Tree from Preorder and Inorder Traversal](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-preorder-and-inorder-traversal) (Medium) + 1. [Construct Binary Tree from Preorder and Inorder Traversal](../construct-binary-tree-from-preorder-and-inorder-traversal) (Medium) diff --git a/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md b/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md index 45529a3aa..b90901203 100644 --- a/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md +++ b/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-depth-of-binary-tree "Maximum Depth of Binary Tree") +[< Previous](../maximum-depth-of-binary-tree "Maximum Depth of Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-inorder-and-postorder-traversal "Construct Binary Tree from Inorder and Postorder Traversal") +[Next >](../construct-binary-tree-from-inorder-and-postorder-traversal "Construct Binary Tree from Inorder and Postorder Traversal") ## [105. Construct Binary Tree from Preorder and Inorder Traversal (Medium)](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal "从前序与中序遍历序列构造二叉树") @@ -32,9 +32,9 @@ inorder = [9,3,15,20,7] 15 7 ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Construct Binary Tree from Inorder and Postorder Traversal](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-inorder-and-postorder-traversal) (Medium) + 1. [Construct Binary Tree from Inorder and Postorder Traversal](../construct-binary-tree-from-inorder-and-postorder-traversal) (Medium) diff --git a/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md b/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md index 07326909e..c73628d7f 100644 --- a/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md +++ b/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/fair-candy-swap "Fair Candy Swap") +[< Previous](../fair-candy-swap "Fair Candy Swap")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-and-replace-pattern "Find and Replace Pattern") +[Next >](../find-and-replace-pattern "Find and Replace Pattern") ## [889. Construct Binary Tree from Preorder and Postorder Traversal (Medium)](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal "根据前序和后序遍历构造二叉树") @@ -37,4 +37,4 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] diff --git a/problems/construct-binary-tree-from-string/README.md b/problems/construct-binary-tree-from-string/README.md index d0d37b6b6..36efbb74b 100644 --- a/problems/construct-binary-tree-from-string/README.md +++ b/problems/construct-binary-tree-from-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/encode-and-decode-tinyurl "Encode and Decode TinyURL") +[< Previous](../encode-and-decode-tinyurl "Encode and Decode TinyURL")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/complex-number-multiplication "Complex Number Multiplication") +[Next >](../complex-number-multiplication "Complex Number Multiplication") ## [536. Construct Binary Tree from String (Medium)](https://leetcode.com/problems/construct-binary-tree-from-string "从字符串生成二叉树") @@ -38,8 +38,8 @@

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Tree](../../tag/tree/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Construct String from Binary Tree](https://github.com/openset/leetcode/tree/master/problems/construct-string-from-binary-tree) (Easy) + 1. [Construct String from Binary Tree](../construct-string-from-binary-tree) (Easy) diff --git a/problems/construct-quad-tree/README.md b/problems/construct-quad-tree/README.md index 5f71237f2..85ea30cfc 100644 --- a/problems/construct-quad-tree/README.md +++ b/problems/construct-quad-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/convert-binary-search-tree-to-sorted-doubly-linked-list "Convert Binary Search Tree to Sorted Doubly Linked List") +[< Previous](../convert-binary-search-tree-to-sorted-doubly-linked-list "Convert Binary Search Tree to Sorted Doubly Linked List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-n-ary-tree "Serialize and Deserialize N-ary Tree") +[Next >](../serialize-and-deserialize-n-ary-tree "Serialize and Deserialize N-ary Tree") ## [427. Construct Quad Tree (Medium)](https://leetcode.com/problems/construct-quad-tree "建立四叉树") diff --git a/problems/construct-string-from-binary-tree/README.md b/problems/construct-string-from-binary-tree/README.md index f57de305e..c1eb73f7f 100644 --- a/problems/construct-string-from-binary-tree/README.md +++ b/problems/construct-string-from-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/can-place-flowers "Can Place Flowers") +[< Previous](../can-place-flowers "Can Place Flowers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sales-person "Sales Person") +[Next >](../sales-person "Sales Person") ## [606. Construct String from Binary Tree (Easy)](https://leetcode.com/problems/construct-string-from-binary-tree "根据二叉树创建字符串") @@ -44,9 +44,9 @@

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Tree](../../tag/tree/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Construct Binary Tree from String](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-string) (Medium) - 1. [Find Duplicate Subtrees](https://github.com/openset/leetcode/tree/master/problems/find-duplicate-subtrees) (Medium) + 1. [Construct Binary Tree from String](../construct-binary-tree-from-string) (Medium) + 1. [Find Duplicate Subtrees](../find-duplicate-subtrees) (Medium) diff --git a/problems/construct-the-rectangle/README.md b/problems/construct-the-rectangle/README.md index 10f3be612..a7dc0df8a 100644 --- a/problems/construct-the-rectangle/README.md +++ b/problems/construct-the-rectangle/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/increasing-subsequences "Increasing Subsequences") +[< Previous](../increasing-subsequences "Increasing Subsequences")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reverse-pairs "Reverse Pairs") +[Next >](../reverse-pairs "Reverse Pairs") ## [492. Construct the Rectangle (Easy)](https://leetcode.com/problems/construct-the-rectangle "构造矩形") diff --git a/problems/contain-virus/README.md b/problems/contain-virus/README.md index fd591e702..a296f5966 100644 --- a/problems/contain-virus/README.md +++ b/problems/contain-virus/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-completing-word "Shortest Completing Word") +[< Previous](../shortest-completing-word "Shortest Completing Word")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-corner-rectangles "Number Of Corner Rectangles") +[Next >](../number-of-corner-rectangles "Number Of Corner Rectangles") ## [749. Contain Virus (Hard)](https://leetcode.com/problems/contain-virus "隔离病毒") @@ -75,7 +75,7 @@ Notice that walls are only built on the shared boundary of two different cells.

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Hints
diff --git a/problems/container-with-most-water/README.md b/problems/container-with-most-water/README.md index 1572d657b..c56097f9e 100644 --- a/problems/container-with-most-water/README.md +++ b/problems/container-with-most-water/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/regular-expression-matching "Regular Expression Matching") +[< Previous](../regular-expression-matching "Regular Expression Matching")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/integer-to-roman "Integer to Roman") +[Next >](../integer-to-roman "Integer to Roman") ## [11. Container With Most Water (Medium)](https://leetcode.com/problems/container-with-most-water "盛最多水的容器") @@ -30,8 +30,8 @@ Output: 49 ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Trapping Rain Water](https://github.com/openset/leetcode/tree/master/problems/trapping-rain-water) (Hard) + 1. [Trapping Rain Water](../trapping-rain-water) (Hard) diff --git a/problems/contains-duplicate-ii/README.md b/problems/contains-duplicate-ii/README.md index ac23889f5..c90582922 100644 --- a/problems/contains-duplicate-ii/README.md +++ b/problems/contains-duplicate-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/the-skyline-problem "The Skyline Problem") +[< Previous](../the-skyline-problem "The Skyline Problem")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate-iii "Contains Duplicate III") +[Next >](../contains-duplicate-iii "Contains Duplicate III") ## [219. Contains Duplicate II (Easy)](https://leetcode.com/problems/contains-duplicate-ii "存在重复元素 II") @@ -41,9 +41,9 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Contains Duplicate](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate) (Easy) - 1. [Contains Duplicate III](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate-iii) (Medium) + 1. [Contains Duplicate](../contains-duplicate) (Easy) + 1. [Contains Duplicate III](../contains-duplicate-iii) (Medium) diff --git a/problems/contains-duplicate-iii/README.md b/problems/contains-duplicate-iii/README.md index 297a1946f..2e124d496 100644 --- a/problems/contains-duplicate-iii/README.md +++ b/problems/contains-duplicate-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate-ii "Contains Duplicate II") +[< Previous](../contains-duplicate-ii "Contains Duplicate II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximal-square "Maximal Square") +[Next >](../maximal-square "Maximal Square") ## [220. Contains Duplicate III (Medium)](https://leetcode.com/problems/contains-duplicate-iii "存在重复元素 III") @@ -41,12 +41,12 @@ ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Ordered Map](../../tag/ordered-map/README.md)] ### Similar Questions - 1. [Contains Duplicate](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate) (Easy) - 1. [Contains Duplicate II](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate-ii) (Easy) + 1. [Contains Duplicate](../contains-duplicate) (Easy) + 1. [Contains Duplicate II](../contains-duplicate-ii) (Easy) ### Hints
diff --git a/problems/contains-duplicate/README.md b/problems/contains-duplicate/README.md index 7f16f88db..1a922e7cf 100644 --- a/problems/contains-duplicate/README.md +++ b/problems/contains-duplicate/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/combination-sum-iii "Combination Sum III") +[< Previous](../combination-sum-iii "Combination Sum III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/the-skyline-problem "The Skyline Problem") +[Next >](../the-skyline-problem "The Skyline Problem") ## [217. Contains Duplicate (Easy)](https://leetcode.com/problems/contains-duplicate "存在重复元素") @@ -34,9 +34,9 @@ Output: true ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Contains Duplicate II](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate-ii) (Easy) - 1. [Contains Duplicate III](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate-iii) (Medium) + 1. [Contains Duplicate II](../contains-duplicate-ii) (Easy) + 1. [Contains Duplicate III](../contains-duplicate-iii) (Medium) diff --git a/problems/contiguous-array/README.md b/problems/contiguous-array/README.md index 632d9344a..8203bbcef 100644 --- a/problems/contiguous-array/README.md +++ b/problems/contiguous-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-word-in-dictionary-through-deleting "Longest Word in Dictionary through Deleting") +[< Previous](../longest-word-in-dictionary-through-deleting "Longest Word in Dictionary through Deleting")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/beautiful-arrangement "Beautiful Arrangement") +[Next >](../beautiful-arrangement "Beautiful Arrangement") ## [525. Contiguous Array (Medium)](https://leetcode.com/problems/contiguous-array "连续数组") @@ -35,7 +35,7 @@ The length of the given binary array will not exceed 50,000.

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Maximum Size Subarray Sum Equals k](https://github.com/openset/leetcode/tree/master/problems/maximum-size-subarray-sum-equals-k) (Medium) + 1. [Maximum Size Subarray Sum Equals k](../maximum-size-subarray-sum-equals-k) (Medium) diff --git a/problems/continuous-subarray-sum/README.md b/problems/continuous-subarray-sum/README.md index 72e50a225..5ef9ff35d 100644 --- a/problems/continuous-subarray-sum/README.md +++ b/problems/continuous-subarray-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-uncommon-subsequence-ii "Longest Uncommon Subsequence II") +[< Previous](../longest-uncommon-subsequence-ii "Longest Uncommon Subsequence II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-word-in-dictionary-through-deleting "Longest Word in Dictionary through Deleting") +[Next >](../longest-word-in-dictionary-through-deleting "Longest Word in Dictionary through Deleting") ## [523. Continuous Subarray Sum (Medium)](https://leetcode.com/problems/continuous-subarray-sum "连续的子数组和") @@ -41,8 +41,8 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Subarray Sum Equals K](https://github.com/openset/leetcode/tree/master/problems/subarray-sum-equals-k) (Medium) + 1. [Subarray Sum Equals K](../subarray-sum-equals-k) (Medium) diff --git a/problems/convert-a-number-to-hexadecimal/README.md b/problems/convert-a-number-to-hexadecimal/README.md index 16363d0d0..5e644bf73 100644 --- a/problems/convert-a-number-to-hexadecimal/README.md +++ b/problems/convert-a-number-to-hexadecimal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sum-of-left-leaves "Sum of Left Leaves") +[< Previous](../sum-of-left-leaves "Sum of Left Leaves")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/queue-reconstruction-by-height "Queue Reconstruction by Height") +[Next >](../queue-reconstruction-by-height "Queue Reconstruction by Height") ## [405. Convert a Number to Hexadecimal (Easy)](https://leetcode.com/problems/convert-a-number-to-hexadecimal "数字转换为十六进制数") @@ -45,4 +45,4 @@ Output:

### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/convert-binary-number-in-a-linked-list-to-integer/README.md b/problems/convert-binary-number-in-a-linked-list-to-integer/README.md index 688a1ad50..8d35ca70e 100644 --- a/problems/convert-binary-number-in-a-linked-list-to-integer/README.md +++ b/problems/convert-binary-number-in-a-linked-list-to-integer/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-falling-path-sum-ii "Minimum Falling Path Sum II") +[< Previous](../minimum-falling-path-sum-ii "Minimum Falling Path Sum II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sequential-digits "Sequential Digits") +[Next >](../sequential-digits "Sequential Digits") ## [1290. Convert Binary Number in a Linked List to Integer (Easy)](https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer "二进制链表转整数") @@ -62,8 +62,8 @@ ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Hints
diff --git a/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md b/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md index 280c149c2..9769c0b64 100644 --- a/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md +++ b/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/word-squares "Word Squares") +[< Previous](../word-squares "Word Squares")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/construct-quad-tree "Construct Quad Tree") +[Next >](../construct-quad-tree "Construct Quad Tree") ## [426. Convert Binary Search Tree to Sorted Doubly Linked List (Medium)](https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list "将二叉搜索树转化为排序的双向链表") @@ -35,9 +35,9 @@

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions - 1. [Binary Tree Inorder Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-inorder-traversal) (Medium) + 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Medium) diff --git a/problems/convert-bst-to-greater-tree/README.md b/problems/convert-bst-to-greater-tree/README.md index d1a6769aa..4fcf2c680 100644 --- a/problems/convert-bst-to-greater-tree/README.md +++ b/problems/convert-bst-to-greater-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/complex-number-multiplication "Complex Number Multiplication") +[< Previous](../complex-number-multiplication "Complex Number Multiplication")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-time-difference "Minimum Time Difference") +[Next >](../minimum-time-difference "Minimum Time Difference") ## [538. Convert BST to Greater Tree (Easy)](https://leetcode.com/problems/convert-bst-to-greater-tree "把二叉搜索树转换为累加树") @@ -29,4 +29,4 @@

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] diff --git a/problems/convert-sorted-array-to-binary-search-tree/README.md b/problems/convert-sorted-array-to-binary-search-tree/README.md index 24ec68cfc..7b9ec6396 100644 --- a/problems/convert-sorted-array-to-binary-search-tree/README.md +++ b/problems/convert-sorted-array-to-binary-search-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal-ii "Binary Tree Level Order Traversal II") +[< Previous](../binary-tree-level-order-traversal-ii "Binary Tree Level Order Traversal II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/convert-sorted-list-to-binary-search-tree "Convert Sorted List to Binary Search Tree") +[Next >](../convert-sorted-list-to-binary-search-tree "Convert Sorted List to Binary Search Tree") ## [108. Convert Sorted Array to Binary Search Tree (Easy)](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree "将有序数组转换为二叉搜索树") @@ -30,8 +30,8 @@ One possible answer is: [0,-3,9,-10,null,5], which represents the following heig ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Convert Sorted List to Binary Search Tree](https://github.com/openset/leetcode/tree/master/problems/convert-sorted-list-to-binary-search-tree) (Medium) + 1. [Convert Sorted List to Binary Search Tree](../convert-sorted-list-to-binary-search-tree) (Medium) diff --git a/problems/convert-sorted-list-to-binary-search-tree/README.md b/problems/convert-sorted-list-to-binary-search-tree/README.md index 14d09f85c..040b46dbd 100644 --- a/problems/convert-sorted-list-to-binary-search-tree/README.md +++ b/problems/convert-sorted-list-to-binary-search-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/convert-sorted-array-to-binary-search-tree "Convert Sorted Array to Binary Search Tree") +[< Previous](../convert-sorted-array-to-binary-search-tree "Convert Sorted Array to Binary Search Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/balanced-binary-tree "Balanced Binary Tree") +[Next >](../balanced-binary-tree "Balanced Binary Tree") ## [109. Convert Sorted List to Binary Search Tree (Medium)](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree "有序链表转换二叉搜索树") @@ -30,8 +30,8 @@ One possible answer is: [0,-3,9,-10,null,5], which represents the following heig ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Convert Sorted Array to Binary Search Tree](https://github.com/openset/leetcode/tree/master/problems/convert-sorted-array-to-binary-search-tree) (Easy) + 1. [Convert Sorted Array to Binary Search Tree](../convert-sorted-array-to-binary-search-tree) (Easy) diff --git a/problems/convert-to-base-2/README.md b/problems/convert-to-base-2/README.md index e1a921a8a..4efbc5543 100644 --- a/problems/convert-to-base-2/README.md +++ b/problems/convert-to-base-2/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-string-with-substrings-representing-1-to-n "Binary String With Substrings Representing 1 To N") +[< Previous](../binary-string-with-substrings-representing-1-to-n "Binary String With Substrings Representing 1 To N")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-prefix-divisible-by-5 "Binary Prefix Divisible By 5") +[Next >](../binary-prefix-divisible-by-5 "Binary Prefix Divisible By 5") ## [1017. Convert to Base -2 (Medium)](https://leetcode.com/problems/convert-to-base-2 "负二进制转换") @@ -56,10 +56,10 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Encode Number](https://github.com/openset/leetcode/tree/master/problems/encode-number) (Medium) + 1. [Encode Number](../encode-number) (Medium) ### Hints
diff --git a/problems/convex-polygon/README.md b/problems/convex-polygon/README.md index 175e1440a..f70b00492 100644 --- a/problems/convex-polygon/README.md +++ b/problems/convex-polygon/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/validate-ip-address "Validate IP Address") +[< Previous](../validate-ip-address "Validate IP Address")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/implement-rand10-using-rand7 "Implement Rand10() Using Rand7()") +[Next >](../implement-rand10-using-rand7 "Implement Rand10() Using Rand7()") ## [469. Convex Polygon (Medium)](https://leetcode.com/problems/convex-polygon "凸多边形") @@ -46,4 +46,4 @@ Explanation:](https://github.com/openset/leetcode/tree/master/problems/word-break "Word Break") +[Next >](../word-break "Word Break") ## [138. Copy List with Random Pointer (Medium)](https://leetcode.com/problems/copy-list-with-random-pointer "复制带随机指针的链表") @@ -39,11 +39,11 @@ Node 2's value is 2, its next pointer points to null and its random pointer ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Clone Graph](https://github.com/openset/leetcode/tree/master/problems/clone-graph) (Medium) + 1. [Clone Graph](../clone-graph) (Medium) ### Hints
diff --git a/problems/corporate-flight-bookings/README.md b/problems/corporate-flight-bookings/README.md index 876e2dcef..dac77489e 100644 --- a/problems/corporate-flight-bookings/README.md +++ b/problems/corporate-flight-bookings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/defanging-an-ip-address "Defanging an IP Address") +[< Previous](../defanging-an-ip-address "Defanging an IP Address")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/delete-nodes-and-return-forest "Delete Nodes And Return Forest") +[Next >](../delete-nodes-and-return-forest "Delete Nodes And Return Forest") ## [1109. Corporate Flight Bookings (Medium)](https://leetcode.com/problems/corporate-flight-bookings "航班预订统计") @@ -35,5 +35,5 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/count-and-say/README.md b/problems/count-and-say/README.md index 9cbe06b18..518a90528 100644 --- a/problems/count-and-say/README.md +++ b/problems/count-and-say/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sudoku-solver "Sudoku Solver") +[< Previous](../sudoku-solver "Sudoku Solver")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/combination-sum "Combination Sum") +[Next >](../combination-sum "Combination Sum") ## [38. Count and Say (Easy)](https://leetcode.com/problems/count-and-say "报数") @@ -45,11 +45,11 @@ Output: "1211" ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Encode and Decode Strings](https://github.com/openset/leetcode/tree/master/problems/encode-and-decode-strings) (Medium) - 1. [String Compression](https://github.com/openset/leetcode/tree/master/problems/string-compression) (Easy) + 1. [Encode and Decode Strings](../encode-and-decode-strings) (Medium) + 1. [String Compression](../string-compression) (Easy) ### Hints
diff --git a/problems/count-binary-substrings/README.md b/problems/count-binary-substrings/README.md index deddaa011..983f09f4d 100644 --- a/problems/count-binary-substrings/README.md +++ b/problems/count-binary-substrings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/max-area-of-island "Max Area of Island") +[< Previous](../max-area-of-island "Max Area of Island")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/degree-of-an-array "Degree of an Array") +[Next >](../degree-of-an-array "Degree of an Array") ## [696. Count Binary Substrings (Easy)](https://leetcode.com/problems/count-binary-substrings "计数二进制子串") @@ -39,10 +39,10 @@

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Encode and Decode Strings](https://github.com/openset/leetcode/tree/master/problems/encode-and-decode-strings) (Medium) + 1. [Encode and Decode Strings](../encode-and-decode-strings) (Medium) ### Hints
diff --git a/problems/count-complete-tree-nodes/README.md b/problems/count-complete-tree-nodes/README.md index 2b1afcb4c..bcc3eedbc 100644 --- a/problems/count-complete-tree-nodes/README.md +++ b/problems/count-complete-tree-nodes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximal-square "Maximal Square") +[< Previous](../maximal-square "Maximal Square")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/rectangle-area "Rectangle Area") +[Next >](../rectangle-area "Rectangle Area") ## [222. Count Complete Tree Nodes (Medium)](https://leetcode.com/problems/count-complete-tree-nodes "完全二叉树的节点个数") @@ -31,8 +31,8 @@ In a complete binary tree every level, except possibly the last, is completely f Output: 6 ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Closest Binary Search Tree Value](https://github.com/openset/leetcode/tree/master/problems/closest-binary-search-tree-value) (Easy) + 1. [Closest Binary Search Tree Value](../closest-binary-search-tree-value) (Easy) diff --git a/problems/count-different-palindromic-subsequences/README.md b/problems/count-different-palindromic-subsequences/README.md index 8da473279..b8d590c65 100644 --- a/problems/count-different-palindromic-subsequences/README.md +++ b/problems/count-different-palindromic-subsequences/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/my-calendar-i "My Calendar I") +[< Previous](../my-calendar-i "My Calendar I")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/my-calendar-ii "My Calendar II") +[Next >](../my-calendar-ii "My Calendar II") ## [730. Count Different Palindromic Subsequences (Hard)](https://leetcode.com/problems/count-different-palindromic-subsequences "统计不同回文子字符串") @@ -48,11 +48,11 @@ There are 3104860382 different non-empty palindromic subsequences, which is 1048

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Longest Palindromic Subsequence](https://github.com/openset/leetcode/tree/master/problems/longest-palindromic-subsequence) (Medium) + 1. [Longest Palindromic Subsequence](../longest-palindromic-subsequence) (Medium) ### Hints
diff --git a/problems/count-number-of-nice-subarrays/README.md b/problems/count-number-of-nice-subarrays/README.md index 2f527ab7a..dfdd0ad80 100644 --- a/problems/count-number-of-nice-subarrays/README.md +++ b/problems/count-number-of-nice-subarrays/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-swaps-to-make-strings-equal "Minimum Swaps to Make Strings Equal") +[< Previous](../minimum-swaps-to-make-strings-equal "Minimum Swaps to Make Strings Equal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-remove-to-make-valid-parentheses "Minimum Remove to Make Valid Parentheses") +[Next >](../minimum-remove-to-make-valid-parentheses "Minimum Remove to Make Valid Parentheses") ## [1248. Count Number of Nice Subarrays (Medium)](https://leetcode.com/problems/count-number-of-nice-subarrays "统计「优美子数组」") @@ -49,7 +49,7 @@ ### Related Topics - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Hints
diff --git a/problems/count-numbers-with-unique-digits/README.md b/problems/count-numbers-with-unique-digits/README.md index c6fd5053b..9aed98006 100644 --- a/problems/count-numbers-with-unique-digits/README.md +++ b/problems/count-numbers-with-unique-digits/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/line-reflection "Line Reflection") +[< Previous](../line-reflection "Line Reflection")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/rearrange-string-k-distance-apart "Rearrange String k Distance Apart") +[Next >](../rearrange-string-k-distance-apart "Rearrange String k Distance Apart") ## [357. Count Numbers with Unique Digits (Medium)](https://leetcode.com/problems/count-numbers-with-unique-digits "计算各个位数不同的数字个数") @@ -25,9 +25,9 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Hints
diff --git a/problems/count-of-range-sum/README.md b/problems/count-of-range-sum/README.md index 5daaa7bfc..ca49f61da 100644 --- a/problems/count-of-range-sum/README.md +++ b/problems/count-of-range-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/power-of-three "Power of Three") +[< Previous](../power-of-three "Power of Three")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/odd-even-linked-list "Odd Even Linked List") +[Next >](../odd-even-linked-list "Odd Even Linked List") ## [327. Count of Range Sum (Hard)](https://leetcode.com/problems/count-of-range-sum "区间和的个数") @@ -26,12 +26,12 @@ A naive algorithm of O(n2) is trivial. You MUST do bett ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Binary Indexed Tree](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] - [[Segment Tree](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions - 1. [Count of Smaller Numbers After Self](https://github.com/openset/leetcode/tree/master/problems/count-of-smaller-numbers-after-self) (Hard) - 1. [Reverse Pairs](https://github.com/openset/leetcode/tree/master/problems/reverse-pairs) (Hard) + 1. [Count of Smaller Numbers After Self](../count-of-smaller-numbers-after-self) (Hard) + 1. [Reverse Pairs](../reverse-pairs) (Hard) diff --git a/problems/count-of-smaller-numbers-after-self/README.md b/problems/count-of-smaller-numbers-after-self/README.md index e66a2d1f9..ceae78a02 100644 --- a/problems/count-of-smaller-numbers-after-self/README.md +++ b/problems/count-of-smaller-numbers-after-self/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-tree-vertical-order-traversal "Binary Tree Vertical Order Traversal") +[< Previous](../binary-tree-vertical-order-traversal "Binary Tree Vertical Order Traversal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-duplicate-letters "Remove Duplicate Letters") +[Next >](../remove-duplicate-letters "Remove Duplicate Letters") ## [315. Count of Smaller Numbers After Self (Hard)](https://leetcode.com/problems/count-of-smaller-numbers-after-self "计算右侧小于当前元素的个数") @@ -26,13 +26,13 @@ To the right of 1 there is 0 smaller element. ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Binary Indexed Tree](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] - [[Segment Tree](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions - 1. [Count of Range Sum](https://github.com/openset/leetcode/tree/master/problems/count-of-range-sum) (Hard) - 1. [Queue Reconstruction by Height](https://github.com/openset/leetcode/tree/master/problems/queue-reconstruction-by-height) (Medium) - 1. [Reverse Pairs](https://github.com/openset/leetcode/tree/master/problems/reverse-pairs) (Hard) + 1. [Count of Range Sum](../count-of-range-sum) (Hard) + 1. [Queue Reconstruction by Height](../queue-reconstruction-by-height) (Medium) + 1. [Reverse Pairs](../reverse-pairs) (Hard) diff --git a/problems/count-primes/README.md b/problems/count-primes/README.md index 6f297d81d..5ff81dc7f 100644 --- a/problems/count-primes/README.md +++ b/problems/count-primes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-linked-list-elements "Remove Linked List Elements") +[< Previous](../remove-linked-list-elements "Remove Linked List Elements")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/isomorphic-strings "Isomorphic Strings") +[Next >](../isomorphic-strings "Isomorphic Strings") ## [204. Count Primes (Easy)](https://leetcode.com/problems/count-primes "计数质数") @@ -22,13 +22,13 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Ugly Number](https://github.com/openset/leetcode/tree/master/problems/ugly-number) (Easy) - 1. [Ugly Number II](https://github.com/openset/leetcode/tree/master/problems/ugly-number-ii) (Medium) - 1. [Perfect Squares](https://github.com/openset/leetcode/tree/master/problems/perfect-squares) (Medium) + 1. [Ugly Number](../ugly-number) (Easy) + 1. [Ugly Number II](../ugly-number-ii) (Medium) + 1. [Perfect Squares](../perfect-squares) (Medium) ### Hints
diff --git a/problems/count-servers-that-communicate/README.md b/problems/count-servers-that-communicate/README.md index ff7cf62cb..4a6de5bd0 100644 --- a/problems/count-servers-that-communicate/README.md +++ b/problems/count-servers-that-communicate/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-time-visiting-all-points "Minimum Time Visiting All Points") +[< Previous](../minimum-time-visiting-all-points "Minimum Time Visiting All Points")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/search-suggestions-system "Search Suggestions System") +[Next >](../search-suggestions-system "Search Suggestions System") ## [1267. Count Servers that Communicate (Medium)](https://leetcode.com/problems/count-servers-that-communicate "统计参与通信的服务器") @@ -57,8 +57,8 @@ Return the number of servers that communicate with any other server.

### Related Topics - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/count-square-submatrices-with-all-ones/README.md b/problems/count-square-submatrices-with-all-ones/README.md index d29006e29..4ad175457 100644 --- a/problems/count-square-submatrices-with-all-ones/README.md +++ b/problems/count-square-submatrices-with-all-ones/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-burgers-with-no-waste-of-ingredients "Number of Burgers with No Waste of Ingredients") +[< Previous](../number-of-burgers-with-no-waste-of-ingredients "Number of Burgers with No Waste of Ingredients")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/palindrome-partitioning-iii "Palindrome Partitioning III") +[Next >](../palindrome-partitioning-iii "Palindrome Partitioning III") ## [1277. Count Square Submatrices with All Ones (Medium)](https://leetcode.com/problems/count-square-submatrices-with-all-ones "统计全为 1 的正方形子矩阵") @@ -57,8 +57,8 @@ Total number of squares = 6 + 1 = 7. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/count-student-number-in-departments/README.md b/problems/count-student-number-in-departments/README.md index c39b281dd..5291ffe31 100644 --- a/problems/count-student-number-in-departments/README.md +++ b/problems/count-student-number-in-departments/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-cumulative-salary-of-an-employee "Find Cumulative Salary of an Employee") +[< Previous](../find-cumulative-salary-of-an-employee "Find Cumulative Salary of an Employee")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-unsorted-continuous-subarray "Shortest Unsorted Continuous Subarray") +[Next >](../shortest-unsorted-continuous-subarray "Shortest Unsorted Continuous Subarray") ## [580. Count Student Number in Departments (Medium)](https://leetcode.com/problems/count-student-number-in-departments "统计各专业学生人数") diff --git a/problems/count-substrings-with-only-one-distinct-letter/README.md b/problems/count-substrings-with-only-one-distinct-letter/README.md index 17f5a7bd2..4636959fc 100644 --- a/problems/count-substrings-with-only-one-distinct-letter/README.md +++ b/problems/count-substrings-with-only-one-distinct-letter/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reformat-department-table "Reformat Department Table") +[< Previous](../reformat-department-table "Reformat Department Table")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/before-and-after-puzzle "Before and After Puzzle") +[Next >](../before-and-after-puzzle "Before and After Puzzle") ## [1180. Count Substrings with Only One Distinct Letter (Easy)](https://leetcode.com/problems/count-substrings-with-only-one-distinct-letter "统计只含单一字母的子串") @@ -43,8 +43,8 @@ So the answer is 1 + 2 + 4 + 1 = 8. ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/count-the-repetitions/README.md b/problems/count-the-repetitions/README.md index a41a96c6d..3d8983d52 100644 --- a/problems/count-the-repetitions/README.md +++ b/problems/count-the-repetitions/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/optimal-account-balancing "Optimal Account Balancing") +[< Previous](../optimal-account-balancing "Optimal Account Balancing")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/unique-substrings-in-wraparound-string "Unique Substrings in Wraparound String") +[Next >](../unique-substrings-in-wraparound-string "Unique Substrings in Wraparound String") ## [466. Count The Repetitions (Hard)](https://leetcode.com/problems/count-the-repetitions "统计重复个数") @@ -27,4 +27,4 @@ Return:

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/count-univalue-subtrees/README.md b/problems/count-univalue-subtrees/README.md index 3ff6de1b6..68d57a5be 100644 --- a/problems/count-univalue-subtrees/README.md +++ b/problems/count-univalue-subtrees/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/group-shifted-strings "Group Shifted Strings") +[< Previous](../group-shifted-strings "Group Shifted Strings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/flatten-2d-vector "Flatten 2D Vector") +[Next >](../flatten-2d-vector "Flatten 2D Vector") ## [250. Count Univalue Subtrees (Medium)](https://leetcode.com/problems/count-univalue-subtrees "统计同值子树") @@ -29,8 +29,8 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Subtree of Another Tree](https://github.com/openset/leetcode/tree/master/problems/subtree-of-another-tree) (Easy) - 1. [Longest Univalue Path](https://github.com/openset/leetcode/tree/master/problems/longest-univalue-path) (Easy) + 1. [Subtree of Another Tree](../subtree-of-another-tree) (Easy) + 1. [Longest Univalue Path](../longest-univalue-path) (Easy) diff --git a/problems/count-vowels-permutation/README.md b/problems/count-vowels-permutation/README.md index 6f3587629..31af29368 100644 --- a/problems/count-vowels-permutation/README.md +++ b/problems/count-vowels-permutation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/path-with-maximum-gold "Path with Maximum Gold") +[< Previous](../path-with-maximum-gold "Path with Maximum Gold")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/split-a-string-in-balanced-strings "Split a String in Balanced Strings") +[Next >](../split-a-string-in-balanced-strings "Split a String in Balanced Strings") ## [1220. Count Vowels Permutation (Hard)](https://leetcode.com/problems/count-vowels-permutation "统计元音字母序列的数目") @@ -55,7 +55,7 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/counting-bits/README.md b/problems/counting-bits/README.md index 9f17689de..e8d6a286b 100644 --- a/problems/counting-bits/README.md +++ b/problems/counting-bits/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/house-robber-iii "House Robber III") +[< Previous](../house-robber-iii "House Robber III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/nested-list-weight-sum "Nested List Weight Sum") +[Next >](../nested-list-weight-sum "Nested List Weight Sum") ## [338. Counting Bits (Medium)](https://leetcode.com/problems/counting-bits "比特位计数") @@ -35,11 +35,11 @@ ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Number of 1 Bits](https://github.com/openset/leetcode/tree/master/problems/number-of-1-bits) (Easy) + 1. [Number of 1 Bits](../number-of-1-bits) (Easy) ### Hints
diff --git a/problems/couples-holding-hands/README.md b/problems/couples-holding-hands/README.md index e9ffd922a..b86d0e446 100644 --- a/problems/couples-holding-hands/README.md +++ b/problems/couples-holding-hands/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/largest-plus-sign "Largest Plus Sign") +[< Previous](../largest-plus-sign "Largest Plus Sign")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/toeplitz-matrix "Toeplitz Matrix") +[Next >](../toeplitz-matrix "Toeplitz Matrix") ## [765. Couples Holding Hands (Hard)](https://leetcode.com/problems/couples-holding-hands "情侣牵手") @@ -38,14 +38,14 @@ The couples' initial seating is given by row[i] being the value of ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] ### Similar Questions - 1. [First Missing Positive](https://github.com/openset/leetcode/tree/master/problems/first-missing-positive) (Hard) - 1. [Missing Number](https://github.com/openset/leetcode/tree/master/problems/missing-number) (Easy) - 1. [K-Similar Strings](https://github.com/openset/leetcode/tree/master/problems/k-similar-strings) (Hard) + 1. [First Missing Positive](../first-missing-positive) (Hard) + 1. [Missing Number](../missing-number) (Easy) + 1. [K-Similar Strings](../k-similar-strings) (Hard) ### Hints
diff --git a/problems/course-schedule-ii/README.md b/problems/course-schedule-ii/README.md index a6c13e0ab..fa278ad52 100644 --- a/problems/course-schedule-ii/README.md +++ b/problems/course-schedule-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-size-subarray-sum "Minimum Size Subarray Sum") +[< Previous](../minimum-size-subarray-sum "Minimum Size Subarray Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/add-and-search-word-data-structure-design "Add and Search Word - Data structure design") +[Next >](../add-and-search-word-data-structure-design "Add and Search Word - Data structure design") ## [210. Course Schedule II (Medium)](https://leetcode.com/problems/course-schedule-ii "课程表 II") @@ -44,17 +44,17 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] - [[Topological Sort](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] ### Similar Questions - 1. [Course Schedule](https://github.com/openset/leetcode/tree/master/problems/course-schedule) (Medium) - 1. [Alien Dictionary](https://github.com/openset/leetcode/tree/master/problems/alien-dictionary) (Hard) - 1. [Minimum Height Trees](https://github.com/openset/leetcode/tree/master/problems/minimum-height-trees) (Medium) - 1. [Sequence Reconstruction](https://github.com/openset/leetcode/tree/master/problems/sequence-reconstruction) (Medium) - 1. [Course Schedule III](https://github.com/openset/leetcode/tree/master/problems/course-schedule-iii) (Hard) + 1. [Course Schedule](../course-schedule) (Medium) + 1. [Alien Dictionary](../alien-dictionary) (Hard) + 1. [Minimum Height Trees](../minimum-height-trees) (Medium) + 1. [Sequence Reconstruction](../sequence-reconstruction) (Medium) + 1. [Course Schedule III](../course-schedule-iii) (Hard) ### Hints
diff --git a/problems/course-schedule-iii/README.md b/problems/course-schedule-iii/README.md index c01f7c980..bf2960faf 100644 --- a/problems/course-schedule-iii/README.md +++ b/problems/course-schedule-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/k-inverse-pairs-array "K Inverse Pairs Array") +[< Previous](../k-inverse-pairs-array "K Inverse Pairs Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-excel-sum-formula "Design Excel Sum Formula") +[Next >](../design-excel-sum-formula "Design Excel Sum Formula") ## [630. Course Schedule III (Hard)](https://leetcode.com/problems/course-schedule-iii "课程表 III") @@ -40,11 +40,11 @@ The 4th course cannot be taken now, since you will finish it on the 3300th day,

 

### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions - 1. [Course Schedule](https://github.com/openset/leetcode/tree/master/problems/course-schedule) (Medium) - 1. [Course Schedule II](https://github.com/openset/leetcode/tree/master/problems/course-schedule-ii) (Medium) + 1. [Course Schedule](../course-schedule) (Medium) + 1. [Course Schedule II](../course-schedule-ii) (Medium) ### Hints
diff --git a/problems/course-schedule/README.md b/problems/course-schedule/README.md index e3854bc7b..1cea1585c 100644 --- a/problems/course-schedule/README.md +++ b/problems/course-schedule/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reverse-linked-list "Reverse Linked List") +[< Previous](../reverse-linked-list "Reverse Linked List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/implement-trie-prefix-tree "Implement Trie (Prefix Tree)") +[Next >](../implement-trie-prefix-tree "Implement Trie (Prefix Tree)") ## [207. Course Schedule (Medium)](https://leetcode.com/problems/course-schedule "课程表") @@ -43,16 +43,16 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] - [[Topological Sort](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] ### Similar Questions - 1. [Course Schedule II](https://github.com/openset/leetcode/tree/master/problems/course-schedule-ii) (Medium) - 1. [Graph Valid Tree](https://github.com/openset/leetcode/tree/master/problems/graph-valid-tree) (Medium) - 1. [Minimum Height Trees](https://github.com/openset/leetcode/tree/master/problems/minimum-height-trees) (Medium) - 1. [Course Schedule III](https://github.com/openset/leetcode/tree/master/problems/course-schedule-iii) (Hard) + 1. [Course Schedule II](../course-schedule-ii) (Medium) + 1. [Graph Valid Tree](../graph-valid-tree) (Medium) + 1. [Minimum Height Trees](../minimum-height-trees) (Medium) + 1. [Course Schedule III](../course-schedule-iii) (Hard) ### Hints
diff --git a/problems/cousins-in-binary-tree/README.md b/problems/cousins-in-binary-tree/README.md index 7415ee085..b56db424b 100644 --- a/problems/cousins-in-binary-tree/README.md +++ b/problems/cousins-in-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/subarrays-with-k-different-integers "Subarrays with K Different Integers") +[< Previous](../subarrays-with-k-different-integers "Subarrays with K Different Integers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/rotting-oranges "Rotting Oranges") +[Next >](../rotting-oranges "Rotting Oranges") ## [993. Cousins in Binary Tree (Easy)](https://leetcode.com/problems/cousins-in-binary-tree "二叉树的堂兄弟节点") @@ -65,8 +65,8 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions - 1. [Binary Tree Level Order Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal) (Medium) + 1. [Binary Tree Level Order Traversal](../binary-tree-level-order-traversal) (Medium) diff --git a/problems/cracking-the-safe/README.md b/problems/cracking-the-safe/README.md index 319f2e435..fc3957601 100644 --- a/problems/cracking-the-safe/README.md +++ b/problems/cracking-the-safe/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/open-the-lock "Open the Lock") +[< Previous](../open-the-lock "Open the Lock")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reach-a-number "Reach a Number") +[Next >](../reach-a-number "Reach a Number") ## [753. Cracking the Safe (Hard)](https://leetcode.com/problems/cracking-the-safe "破解保险箱") @@ -50,8 +50,8 @@

 

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/create-maximum-number/README.md b/problems/create-maximum-number/README.md index d57941c34..56b92324f 100644 --- a/problems/create-maximum-number/README.md +++ b/problems/create-maximum-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/generalized-abbreviation "Generalized Abbreviation") +[< Previous](../generalized-abbreviation "Generalized Abbreviation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/coin-change "Coin Change") +[Next >](../coin-change "Coin Change") ## [321. Create Maximum Number (Hard)](https://leetcode.com/problems/create-maximum-number "拼接最大数") @@ -47,9 +47,9 @@ k = 3 ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Remove K Digits](https://github.com/openset/leetcode/tree/master/problems/remove-k-digits) (Medium) - 1. [Maximum Swap](https://github.com/openset/leetcode/tree/master/problems/maximum-swap) (Medium) + 1. [Remove K Digits](../remove-k-digits) (Medium) + 1. [Maximum Swap](../maximum-swap) (Medium) diff --git a/problems/critical-connections-in-a-network/README.md b/problems/critical-connections-in-a-network/README.md index 6443eb367..ec7b89a84 100644 --- a/problems/critical-connections-in-a-network/README.md +++ b/problems/critical-connections-in-a-network/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/k-concatenation-maximum-sum "K-Concatenation Maximum Sum") +[< Previous](../k-concatenation-maximum-sum "K-Concatenation Maximum Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/monthly-transactions-i "Monthly Transactions I") +[Next >](../monthly-transactions-i "Monthly Transactions I") ## [1192. Critical Connections in a Network (Hard)](https://leetcode.com/problems/critical-connections-in-a-network "查找集群内的「关键连接」") @@ -39,7 +39,7 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Hints
diff --git a/problems/custom-sort-string/README.md b/problems/custom-sort-string/README.md index c6c50ca70..45c2502b9 100644 --- a/problems/custom-sort-string/README.md +++ b/problems/custom-sort-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/domino-and-tromino-tiling "Domino and Tromino Tiling") +[< Previous](../domino-and-tromino-tiling "Domino and Tromino Tiling")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-matching-subsequences "Number of Matching Subsequences") +[Next >](../number-of-matching-subsequences "Number of Matching Subsequences") ## [791. Custom Sort String (Medium)](https://leetcode.com/problems/custom-sort-string "自定义字符串排序") @@ -39,4 +39,4 @@ Since "d" does not appear in S, it can be at any position in T. " ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/customer-placing-the-largest-number-of-orders/README.md b/problems/customer-placing-the-largest-number-of-orders/README.md index 8451e4363..e4537c3f7 100644 --- a/problems/customer-placing-the-largest-number-of-orders/README.md +++ b/problems/customer-placing-the-largest-number-of-orders/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/investments-in-2016 "Investments in 2016") +[< Previous](../investments-in-2016 "Investments in 2016")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/erect-the-fence "Erect the Fence") +[Next >](../erect-the-fence "Erect the Fence") ## [586. Customer Placing the Largest Number of Orders (Easy)](https://leetcode.com/problems/customer-placing-the-largest-number-of-orders "订单最多的客户") diff --git a/problems/customers-who-bought-all-products/README.md b/problems/customers-who-bought-all-products/README.md index c0f39c74e..55613c05d 100644 --- a/problems/customers-who-bought-all-products/README.md +++ b/problems/customers-who-bought-all-products/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-duplicate-substring "Longest Duplicate Substring") +[< Previous](../longest-duplicate-substring "Longest Duplicate Substring")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/last-stone-weight "Last Stone Weight") +[Next >](../last-stone-weight "Last Stone Weight") ## [1045. Customers Who Bought All Products (Medium)](https://leetcode.com/problems/customers-who-bought-all-products "买下所有产品的客户") diff --git a/problems/customers-who-never-order/README.md b/problems/customers-who-never-order/README.md index 3bb83537f..abb7f3491 100644 --- a/problems/customers-who-never-order/README.md +++ b/problems/customers-who-never-order/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/duplicate-emails "Duplicate Emails") +[< Previous](../duplicate-emails "Duplicate Emails")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/department-highest-salary "Department Highest Salary") +[Next >](../department-highest-salary "Department Highest Salary") ## [183. Customers Who Never Order (Easy)](https://leetcode.com/problems/customers-who-never-order "从不订购的客户") diff --git a/problems/cut-off-trees-for-golf-event/README.md b/problems/cut-off-trees-for-golf-event/README.md index b250a1f77..cf0e863e8 100644 --- a/problems/cut-off-trees-for-golf-event/README.md +++ b/problems/cut-off-trees-for-golf-event/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-continuous-increasing-subsequence "Longest Continuous Increasing Subsequence") +[< Previous](../longest-continuous-increasing-subsequence "Longest Continuous Increasing Subsequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/implement-magic-dictionary "Implement Magic Dictionary") +[Next >](../implement-magic-dictionary "Implement Magic Dictionary") ## [675. Cut Off Trees for Golf Event (Hard)](https://leetcode.com/problems/cut-off-trees-for-golf-event "为高尔夫比赛砍树") @@ -73,4 +73,4 @@

Hint: size of the given matrix will not exceed 50x50.

### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/daily-temperatures/README.md b/problems/daily-temperatures/README.md index 9c0e7c3b7..2b44915b5 100644 --- a/problems/daily-temperatures/README.md +++ b/problems/daily-temperatures/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/monotone-increasing-digits "Monotone Increasing Digits") +[< Previous](../monotone-increasing-digits "Monotone Increasing Digits")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/delete-and-earn "Delete and Earn") +[Next >](../delete-and-earn "Delete and Earn") ## [739. Daily Temperatures (Medium)](https://leetcode.com/problems/daily-temperatures "每日温度") @@ -23,11 +23,11 @@ Each temperature will be an integer in the range [30, 100].

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Next Greater Element I](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-i) (Easy) + 1. [Next Greater Element I](../next-greater-element-i) (Easy) ### Hints
diff --git a/problems/data-stream-as-disjoint-intervals/README.md b/problems/data-stream-as-disjoint-intervals/README.md index d76f5d428..faacb90e7 100644 --- a/problems/data-stream-as-disjoint-intervals/README.md +++ b/problems/data-stream-as-disjoint-intervals/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/android-unlock-patterns "Android Unlock Patterns") +[< Previous](../android-unlock-patterns "Android Unlock Patterns")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-snake-game "Design Snake Game") +[Next >](../design-snake-game "Design Snake Game") ## [352. Data Stream as Disjoint Intervals (Hard)](https://leetcode.com/problems/data-stream-as-disjoint-intervals "将数据流变为多个不相交区间") @@ -30,10 +30,10 @@

What if there are lots of merges and the number of disjoint intervals are small compared to the data stream's size?

### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] - [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Ordered Map](../../tag/ordered-map/README.md)] ### Similar Questions - 1. [Summary Ranges](https://github.com/openset/leetcode/tree/master/problems/summary-ranges) (Medium) - 1. [Find Right Interval](https://github.com/openset/leetcode/tree/master/problems/find-right-interval) (Medium) - 1. [Range Module](https://github.com/openset/leetcode/tree/master/problems/range-module) (Hard) + 1. [Summary Ranges](../summary-ranges) (Medium) + 1. [Find Right Interval](../find-right-interval) (Medium) + 1. [Range Module](../range-module) (Hard) diff --git a/problems/day-of-the-week/README.md b/problems/day-of-the-week/README.md index bac1cd003..a5107132f 100644 --- a/problems/day-of-the-week/README.md +++ b/problems/day-of-the-week/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/distance-between-bus-stops "Distance Between Bus Stops") +[< Previous](../distance-between-bus-stops "Distance Between Bus Stops")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-subarray-sum-with-one-deletion "Maximum Subarray Sum with One Deletion") +[Next >](../maximum-subarray-sum-with-one-deletion "Maximum Subarray Sum with One Deletion") ## [1185. Day of the Week (Easy)](https://leetcode.com/problems/day-of-the-week "一周中的第几天") @@ -47,7 +47,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/day-of-the-year/README.md b/problems/day-of-the-year/README.md index 7c4e65130..d023c8209 100644 --- a/problems/day-of-the-year/README.md +++ b/problems/day-of-the-year/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/string-transforms-into-another-string "String Transforms Into Another String") +[< Previous](../string-transforms-into-another-string "String Transforms Into Another String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-dice-rolls-with-target-sum "Number of Dice Rolls With Target Sum") +[Next >](../number-of-dice-rolls-with-target-sum "Number of Dice Rolls With Target Sum") ## [1154. Day of the Year (Easy)](https://leetcode.com/problems/day-of-the-year "一年中的第几天") @@ -53,7 +53,7 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/decode-string/README.md b/problems/decode-string/README.md index 35004dff4..a8c64086a 100644 --- a/problems/decode-string/README.md +++ b/problems/decode-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/utf-8-validation "UTF-8 Validation") +[< Previous](../utf-8-validation "UTF-8 Validation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-least-k-repeating-characters "Longest Substring with At Least K Repeating Characters") +[Next >](../longest-substring-with-at-least-k-repeating-characters "Longest Substring with At Least K Repeating Characters") ## [394. Decode String (Medium)](https://leetcode.com/problems/decode-string "字符串解码") @@ -30,10 +30,10 @@ s = "2[abc]3[cd]ef", return "abcabccdcdcdef".

 

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Encode String with Shortest Length](https://github.com/openset/leetcode/tree/master/problems/encode-string-with-shortest-length) (Hard) - 1. [Number of Atoms](https://github.com/openset/leetcode/tree/master/problems/number-of-atoms) (Hard) - 1. [Brace Expansion](https://github.com/openset/leetcode/tree/master/problems/brace-expansion) (Medium) + 1. [Encode String with Shortest Length](../encode-string-with-shortest-length) (Hard) + 1. [Number of Atoms](../number-of-atoms) (Hard) + 1. [Brace Expansion](../brace-expansion) (Medium) diff --git a/problems/decode-ways-ii/README.md b/problems/decode-ways-ii/README.md index 53a80f86e..78a0e77f0 100644 --- a/problems/decode-ways-ii/README.md +++ b/problems/decode-ways-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shopping-offers "Shopping Offers") +[< Previous](../shopping-offers "Shopping Offers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/solve-the-equation "Solve the Equation") +[Next >](../solve-the-equation "Solve the Equation") ## [639. Decode Ways II (Hard)](https://leetcode.com/problems/decode-ways-ii "解码方法 2") @@ -58,7 +58,7 @@ Also, since the answer may be very large, you should return the output mod 10 ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Decode Ways](https://github.com/openset/leetcode/tree/master/problems/decode-ways) (Medium) + 1. [Decode Ways](../decode-ways) (Medium) diff --git a/problems/decode-ways/README.md b/problems/decode-ways/README.md index 3a2569d2f..933dcf927 100644 --- a/problems/decode-ways/README.md +++ b/problems/decode-ways/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/subsets-ii "Subsets II") +[< Previous](../subsets-ii "Subsets II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reverse-linked-list-ii "Reverse Linked List II") +[Next >](../reverse-linked-list-ii "Reverse Linked List II") ## [91. Decode Ways (Medium)](https://leetcode.com/problems/decode-ways "解码方法") @@ -38,8 +38,8 @@ Explanation: It could be decoded as "BZ" (2 26), "VF" (22 6), or "BBF" (2 2 6). ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Decode Ways II](https://github.com/openset/leetcode/tree/master/problems/decode-ways-ii) (Hard) + 1. [Decode Ways II](../decode-ways-ii) (Hard) diff --git a/problems/decoded-string-at-index/README.md b/problems/decoded-string-at-index/README.md index d27e7cfc7..08c90384a 100644 --- a/problems/decoded-string-at-index/README.md +++ b/problems/decoded-string-at-index/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/profitable-schemes "Profitable Schemes") +[< Previous](../profitable-schemes "Profitable Schemes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/boats-to-save-people "Boats to Save People") +[Next >](../boats-to-save-people "Boats to Save People") ## [880. Decoded String at Index (Medium)](https://leetcode.com/problems/decoded-string-at-index "索引处的解码字符串") @@ -69,4 +69,4 @@ The decoded string is "a" repeated 8301530446056247680 times. The 1st ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] + [[Stack](../../tag/stack/README.md)] diff --git a/problems/decrease-elements-to-make-array-zigzag/README.md b/problems/decrease-elements-to-make-array-zigzag/README.md index 89d266149..a03fae69f 100644 --- a/problems/decrease-elements-to-make-array-zigzag/README.md +++ b/problems/decrease-elements-to-make-array-zigzag/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-common-subsequence "Longest Common Subsequence") +[< Previous](../longest-common-subsequence "Longest Common Subsequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-tree-coloring-game "Binary Tree Coloring Game") +[Next >](../binary-tree-coloring-game "Binary Tree Coloring Game") ## [1144. Decrease Elements To Make Array Zigzag (Medium)](https://leetcode.com/problems/decrease-elements-to-make-array-zigzag "递减元素使数组呈锯齿状") @@ -47,7 +47,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/defanging-an-ip-address/README.md b/problems/defanging-an-ip-address/README.md index df01ada1a..916337166 100644 --- a/problems/defanging-an-ip-address/README.md +++ b/problems/defanging-an-ip-address/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/new-users-daily-count "New Users Daily Count") +[< Previous](../new-users-daily-count "New Users Daily Count")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/corporate-flight-bookings "Corporate Flight Bookings") +[Next >](../corporate-flight-bookings "Corporate Flight Bookings") ## [1108. Defanging an IP Address (Easy)](https://leetcode.com/problems/defanging-an-ip-address "IP 地址无效化") @@ -31,4 +31,4 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/degree-of-an-array/README.md b/problems/degree-of-an-array/README.md index 0046229ed..af0281478 100644 --- a/problems/degree-of-an-array/README.md +++ b/problems/degree-of-an-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/count-binary-substrings "Count Binary Substrings") +[< Previous](../count-binary-substrings "Count Binary Substrings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/partition-to-k-equal-sum-subsets "Partition to K Equal Sum Subsets") +[Next >](../partition-to-k-equal-sum-subsets "Partition to K Equal Sum Subsets") ## [697. Degree of an Array (Easy)](https://leetcode.com/problems/degree-of-an-array "数组的度") @@ -40,10 +40,10 @@ The shortest length is 2. So return 2.

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Maximum Subarray](https://github.com/openset/leetcode/tree/master/problems/maximum-subarray) (Easy) + 1. [Maximum Subarray](../maximum-subarray) (Easy) ### Hints
diff --git a/problems/delete-and-earn/README.md b/problems/delete-and-earn/README.md index ed871877f..517fcfb44 100644 --- a/problems/delete-and-earn/README.md +++ b/problems/delete-and-earn/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/daily-temperatures "Daily Temperatures") +[< Previous](../daily-temperatures "Daily Temperatures")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/cherry-pickup "Cherry Pickup") +[Next >](../cherry-pickup "Cherry Pickup") ## [740. Delete and Earn (Medium)](https://leetcode.com/problems/delete-and-earn "删除与获得点数") @@ -52,10 +52,10 @@ Then, delete 3 again to earn 3 points, and 3 again to earn 3 points.

 

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [House Robber](https://github.com/openset/leetcode/tree/master/problems/house-robber) (Easy) + 1. [House Robber](../house-robber) (Easy) ### Hints
diff --git a/problems/delete-columns-to-make-sorted-ii/README.md b/problems/delete-columns-to-make-sorted-ii/README.md index c09a89512..5e5583679 100644 --- a/problems/delete-columns-to-make-sorted-ii/README.md +++ b/problems/delete-columns-to-make-sorted-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/array-of-doubled-pairs "Array of Doubled Pairs") +[< Previous](../array-of-doubled-pairs "Array of Doubled Pairs")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/tallest-billboard "Tallest Billboard") +[Next >](../tallest-billboard "Tallest Billboard") ## [955. Delete Columns to Make Sorted II (Medium)](https://leetcode.com/problems/delete-columns-to-make-sorted-ii "删列造序 II") @@ -81,4 +81,4 @@ We have to delete every column. ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/delete-columns-to-make-sorted-iii/README.md b/problems/delete-columns-to-make-sorted-iii/README.md index 380e6d1d0..36088fa3b 100644 --- a/problems/delete-columns-to-make-sorted-iii/README.md +++ b/problems/delete-columns-to-make-sorted-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/regions-cut-by-slashes "Regions Cut By Slashes") +[< Previous](../regions-cut-by-slashes "Regions Cut By Slashes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/n-repeated-element-in-size-2n-array "N-Repeated Element in Size 2N Array") +[Next >](../n-repeated-element-in-size-2n-array "N-Repeated Element in Size 2N Array") ## [960. Delete Columns to Make Sorted III (Hard)](https://leetcode.com/problems/delete-columns-to-make-sorted-iii "删列造序 III") @@ -67,4 +67,4 @@ Note that A[0] > A[1] - the array A isn't necessarily in lexicographic or ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/delete-columns-to-make-sorted/README.md b/problems/delete-columns-to-make-sorted/README.md index 88f9e2efe..8c8aef867 100644 --- a/problems/delete-columns-to-make-sorted/README.md +++ b/problems/delete-columns-to-make-sorted/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-the-shortest-superstring "Find the Shortest Superstring") +[< Previous](../find-the-shortest-superstring "Find the Shortest Superstring")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-increment-to-make-array-unique "Minimum Increment to Make Array Unique") +[Next >](../minimum-increment-to-make-array-unique "Minimum Increment to Make Array Unique") ## [944. Delete Columns to Make Sorted (Easy)](https://leetcode.com/problems/delete-columns-to-make-sorted "删列造序") @@ -65,4 +65,4 @@ If we chose D = {}, then a column ["b","a","h"] wo ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/delete-duplicate-emails/README.md b/problems/delete-duplicate-emails/README.md index 514ecc93e..43a4a9fda 100644 --- a/problems/delete-duplicate-emails/README.md +++ b/problems/delete-duplicate-emails/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/tenth-line "Tenth Line") +[< Previous](../tenth-line "Tenth Line")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/rising-temperature "Rising Temperature") +[Next >](../rising-temperature "Rising Temperature") ## [196. Delete Duplicate Emails (Easy)](https://leetcode.com/problems/delete-duplicate-emails "删除重复的电子邮箱") diff --git a/problems/delete-node-in-a-bst/README.md b/problems/delete-node-in-a-bst/README.md index 6921e541f..0381b48dd 100644 --- a/problems/delete-node-in-a-bst/README.md +++ b/problems/delete-node-in-a-bst/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-bst "Serialize and Deserialize BST") +[< Previous](../serialize-and-deserialize-bst "Serialize and Deserialize BST")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sort-characters-by-frequency "Sort Characters By Frequency") +[Next >](../sort-characters-by-frequency "Sort Characters By Frequency") ## [450. Delete Node in a BST (Medium)](https://leetcode.com/problems/delete-node-in-a-bst "删除二叉搜索树中的节点") @@ -54,7 +54,7 @@ Another valid answer is [5,2,6,null,4,null,7].

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Split BST](https://github.com/openset/leetcode/tree/master/problems/split-bst) (Medium) + 1. [Split BST](../split-bst) (Medium) diff --git a/problems/delete-node-in-a-linked-list/README.md b/problems/delete-node-in-a-linked-list/README.md index 5df329c78..13e7acb62 100644 --- a/problems/delete-node-in-a-linked-list/README.md +++ b/problems/delete-node-in-a-linked-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/lowest-common-ancestor-of-a-binary-tree "Lowest Common Ancestor of a Binary Tree") +[< Previous](../lowest-common-ancestor-of-a-binary-tree "Lowest Common Ancestor of a Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/product-of-array-except-self "Product of Array Except Self") +[Next >](../product-of-array-except-self "Product of Array Except Self") ## [237. Delete Node in a Linked List (Easy)](https://leetcode.com/problems/delete-node-in-a-linked-list "删除链表中的节点") @@ -47,7 +47,7 @@ ### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Remove Linked List Elements](https://github.com/openset/leetcode/tree/master/problems/remove-linked-list-elements) (Easy) + 1. [Remove Linked List Elements](../remove-linked-list-elements) (Easy) diff --git a/problems/delete-nodes-and-return-forest/README.md b/problems/delete-nodes-and-return-forest/README.md index f6c02ef41..5f6290874 100644 --- a/problems/delete-nodes-and-return-forest/README.md +++ b/problems/delete-nodes-and-return-forest/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/corporate-flight-bookings "Corporate Flight Bookings") +[< Previous](../corporate-flight-bookings "Corporate Flight Bookings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-nesting-depth-of-two-valid-parentheses-strings "Maximum Nesting Depth of Two Valid Parentheses Strings") +[Next >](../maximum-nesting-depth-of-two-valid-parentheses-strings "Maximum Nesting Depth of Two Valid Parentheses Strings") ## [1110. Delete Nodes And Return Forest (Medium)](https://leetcode.com/problems/delete-nodes-and-return-forest "删点成林") @@ -38,5 +38,5 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/delete-operation-for-two-strings/README.md b/problems/delete-operation-for-two-strings/README.md index 87566b336..436c2977a 100644 --- a/problems/delete-operation-for-two-strings/README.md +++ b/problems/delete-operation-for-two-strings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/kill-process "Kill Process") +[< Previous](../kill-process "Kill Process")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-customer-referee "Find Customer Referee") +[Next >](../find-customer-referee "Find Customer Referee") ## [583. Delete Operation for Two Strings (Medium)](https://leetcode.com/problems/delete-operation-for-two-strings "两个字符串的删除操作") @@ -31,8 +31,8 @@ Given two words word1 and word2, find the minimum number of steps

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Edit Distance](https://github.com/openset/leetcode/tree/master/problems/edit-distance) (Hard) - 1. [Minimum ASCII Delete Sum for Two Strings](https://github.com/openset/leetcode/tree/master/problems/minimum-ascii-delete-sum-for-two-strings) (Medium) + 1. [Edit Distance](../edit-distance) (Hard) + 1. [Minimum ASCII Delete Sum for Two Strings](../minimum-ascii-delete-sum-for-two-strings) (Medium) diff --git a/problems/delete-tree-nodes/README.md b/problems/delete-tree-nodes/README.md index 4ad510520..010ab41e2 100644 --- a/problems/delete-tree-nodes/README.md +++ b/problems/delete-tree-nodes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-interval "Remove Interval") +[< Previous](../remove-interval "Remove Interval")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-ships-in-a-rectangle "Number of Ships in a Rectangle") +[Next >](../number-of-ships-in-a-rectangle "Number of Ships in a Rectangle") ## [1273. Delete Tree Nodes (Medium)](https://leetcode.com/problems/delete-tree-nodes "删除树节点") @@ -44,8 +44,8 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/department-highest-salary/README.md b/problems/department-highest-salary/README.md index 4e64bd78b..f96e6c0e6 100644 --- a/problems/department-highest-salary/README.md +++ b/problems/department-highest-salary/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/customers-who-never-order "Customers Who Never Order") +[< Previous](../customers-who-never-order "Customers Who Never Order")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/department-top-three-salaries "Department Top Three Salaries") +[Next >](../department-top-three-salaries "Department Top Three Salaries") ## [184. Department Highest Salary (Medium)](https://leetcode.com/problems/department-highest-salary "部门工资最高的员工") diff --git a/problems/department-top-three-salaries/README.md b/problems/department-top-three-salaries/README.md index 98fb00201..bf38afcb1 100644 --- a/problems/department-top-three-salaries/README.md +++ b/problems/department-top-three-salaries/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/department-highest-salary "Department Highest Salary") +[< Previous](../department-highest-salary "Department Highest Salary")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reverse-words-in-a-string-ii "Reverse Words in a String II") +[Next >](../reverse-words-in-a-string-ii "Reverse Words in a String II") ## [185. Department Top Three Salaries (Hard)](https://leetcode.com/problems/department-top-three-salaries "部门工资前三高的所有员工") diff --git a/problems/design-a-leaderboard/README.md b/problems/design-a-leaderboard/README.md index 528efa17b..d00c749ae 100644 --- a/problems/design-a-leaderboard/README.md +++ b/problems/design-a-leaderboard/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/array-transformation "Array Transformation") +[< Previous](../array-transformation "Array Transformation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/tree-diameter "Tree Diameter") +[Next >](../tree-diameter "Tree Diameter") ## [1244. Design A Leaderboard (Medium)](https://leetcode.com/problems/design-a-leaderboard "力扣排行榜") @@ -56,9 +56,9 @@ leaderboard.top(3); // returns 141 = 51 + 51 + 39; ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
diff --git a/problems/design-bounded-blocking-queue/README.md b/problems/design-bounded-blocking-queue/README.md index cd41fa0cd..8c53985e3 100644 --- a/problems/design-bounded-blocking-queue/README.md +++ b/problems/design-bounded-blocking-queue/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/make-array-strictly-increasing "Make Array Strictly Increasing") +[< Previous](../make-array-strictly-increasing "Make Array Strictly Increasing")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-number-of-balloons "Maximum Number of Balloons") +[Next >](../maximum-number-of-balloons "Maximum Number of Balloons") ## [1188. Design Bounded Blocking Queue (Medium)](https://leetcode.com/problems/design-bounded-blocking-queue "设计有限阻塞队列") diff --git a/problems/design-circular-deque/README.md b/problems/design-circular-deque/README.md index d35aa282f..82da33739 100644 --- a/problems/design-circular-deque/README.md +++ b/problems/design-circular-deque/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/solve-the-equation "Solve the Equation") +[< Previous](../solve-the-equation "Solve the Equation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-search-autocomplete-system "Design Search Autocomplete System") +[Next >](../design-search-autocomplete-system "Design Search Autocomplete System") ## [641. Design Circular Deque (Medium)](https://leetcode.com/problems/design-circular-deque "设计循环双端队列") @@ -55,8 +55,8 @@ circularDeque.getFront(); // return 4 ### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Queue](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] + [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] ### Similar Questions - 1. [Design Circular Queue](https://github.com/openset/leetcode/tree/master/problems/design-circular-queue) (Medium) + 1. [Design Circular Queue](../design-circular-queue) (Medium) diff --git a/problems/design-circular-queue/README.md b/problems/design-circular-queue/README.md index d87c12783..5d16b4293 100644 --- a/problems/design-circular-queue/README.md +++ b/problems/design-circular-queue/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/task-scheduler "Task Scheduler") +[< Previous](../task-scheduler "Task Scheduler")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/add-one-row-to-tree "Add One Row to Tree") +[Next >](../add-one-row-to-tree "Add One Row to Tree") ## [622. Design Circular Queue (Medium)](https://leetcode.com/problems/design-circular-queue "设计循环队列") @@ -54,8 +54,8 @@ circularQueue.Rear();  // return 4 ### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Queue](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] + [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] ### Similar Questions - 1. [Design Circular Deque](https://github.com/openset/leetcode/tree/master/problems/design-circular-deque) (Medium) + 1. [Design Circular Deque](../design-circular-deque) (Medium) diff --git a/problems/design-compressed-string-iterator/README.md b/problems/design-compressed-string-iterator/README.md index 03cb95090..c8278cf05 100644 --- a/problems/design-compressed-string-iterator/README.md +++ b/problems/design-compressed-string-iterator/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/consecutive-available-seats "Consecutive Available Seats") +[< Previous](../consecutive-available-seats "Consecutive Available Seats")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/can-place-flowers "Can Place Flowers") +[Next >](../can-place-flowers "Can Place Flowers") ## [604. Design Compressed String Iterator (Easy)](https://leetcode.com/problems/design-compressed-string-iterator "迭代压缩字符串") @@ -49,8 +49,8 @@ iterator.next(); // return ' '

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions - 1. [LRU Cache](https://github.com/openset/leetcode/tree/master/problems/lru-cache) (Medium) - 1. [String Compression](https://github.com/openset/leetcode/tree/master/problems/string-compression) (Easy) + 1. [LRU Cache](../lru-cache) (Medium) + 1. [String Compression](../string-compression) (Easy) diff --git a/problems/design-excel-sum-formula/README.md b/problems/design-excel-sum-formula/README.md index 0a8d8d7ab..e307a1d0a 100644 --- a/problems/design-excel-sum-formula/README.md +++ b/problems/design-excel-sum-formula/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/course-schedule-iii "Course Schedule III") +[< Previous](../course-schedule-iii "Course Schedule III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/smallest-range-covering-elements-from-k-lists "Smallest Range Covering Elements from K Lists") +[Next >](../smallest-range-covering-elements-from-k-lists "Smallest Range Covering Elements from K Lists") ## [631. Design Excel Sum Formula (Hard)](https://leetcode.com/problems/design-excel-sum-formula "设计 Excel 求和公式") @@ -70,4 +70,4 @@ Set(2, "B", 2);

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Design](../../tag/design/README.md)] diff --git a/problems/design-file-system/README.md b/problems/design-file-system/README.md index 171073d9b..7f00a7862 100644 --- a/problems/design-file-system/README.md +++ b/problems/design-file-system/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/single-row-keyboard "Single-Row Keyboard") +[< Previous](../single-row-keyboard "Single-Row Keyboard")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-to-connect-sticks "Minimum Cost to Connect Sticks") +[Next >](../minimum-cost-to-connect-sticks "Minimum Cost to Connect Sticks") ## [1166. Design File System (Medium)](https://leetcode.com/problems/design-file-system "设计文件系统") @@ -70,8 +70,8 @@ fileSystem.get("/c"); // return -1 because this path doesn't exist

NOTE: create method has been changed on August 29, 2019 to createPath. Please reset to default code definition to get new method signature.

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
diff --git a/problems/design-hashmap/README.md b/problems/design-hashmap/README.md index 6a547f5e4..1bcfdc4ac 100644 --- a/problems/design-hashmap/README.md +++ b/problems/design-hashmap/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-hashset "Design HashSet") +[< Previous](../design-hashset "Design HashSet")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-linked-list "Design Linked List") +[Next >](../design-linked-list "Design Linked List") ## [706. Design HashMap (Easy)](https://leetcode.com/problems/design-hashmap "设计哈希映射") @@ -46,8 +46,8 @@ hashMap.get(2);            // returns -1 (not foun ### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Design HashSet](https://github.com/openset/leetcode/tree/master/problems/design-hashset) (Easy) + 1. [Design HashSet](../design-hashset) (Easy) diff --git a/problems/design-hashset/README.md b/problems/design-hashset/README.md index f2167ee1a..4af6db33c 100644 --- a/problems/design-hashset/README.md +++ b/problems/design-hashset/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-search "Binary Search") +[< Previous](../binary-search "Binary Search")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-hashmap "Design HashMap") +[Next >](../design-hashmap "Design HashMap") ## [705. Design HashSet (Easy)](https://leetcode.com/problems/design-hashset "设计哈希集合") @@ -46,8 +46,8 @@ hashSet.contains(2);    // returns false (already removed) ### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Design HashMap](https://github.com/openset/leetcode/tree/master/problems/design-hashmap) (Easy) + 1. [Design HashMap](../design-hashmap) (Easy) diff --git a/problems/design-hit-counter/README.md b/problems/design-hit-counter/README.md index 72a77a44e..d7eff4a9f 100644 --- a/problems/design-hit-counter/README.md +++ b/problems/design-hit-counter/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/bomb-enemy "Bomb Enemy") +[< Previous](../bomb-enemy "Bomb Enemy")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/max-sum-of-rectangle-no-larger-than-k "Max Sum of Rectangle No Larger Than K") +[Next >](../max-sum-of-rectangle-no-larger-than-k "Max Sum of Rectangle No Larger Than K") ## [362. Design Hit Counter (Medium)](https://leetcode.com/problems/design-hit-counter "敲击计数器") @@ -48,7 +48,7 @@ counter.getHits(301); What if the number of hits per second could be very large? Does your design scale?

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions - 1. [Logger Rate Limiter](https://github.com/openset/leetcode/tree/master/problems/logger-rate-limiter) (Easy) + 1. [Logger Rate Limiter](../logger-rate-limiter) (Easy) diff --git a/problems/design-in-memory-file-system/README.md b/problems/design-in-memory-file-system/README.md index c4650d754..c9e5b7e6a 100644 --- a/problems/design-in-memory-file-system/README.md +++ b/problems/design-in-memory-file-system/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/erect-the-fence "Erect the Fence") +[< Previous](../erect-the-fence "Erect the Fence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-preorder-traversal "N-ary Tree Preorder Traversal") +[Next >](../n-ary-tree-preorder-traversal "N-ary Tree Preorder Traversal") ## [588. Design In-Memory File System (Hard)](https://leetcode.com/problems/design-in-memory-file-system "设计内存文件系统") @@ -47,9 +47,9 @@ ### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions - 1. [LRU Cache](https://github.com/openset/leetcode/tree/master/problems/lru-cache) (Medium) - 1. [LFU Cache](https://github.com/openset/leetcode/tree/master/problems/lfu-cache) (Hard) - 1. [Design Log Storage System](https://github.com/openset/leetcode/tree/master/problems/design-log-storage-system) (Medium) + 1. [LRU Cache](../lru-cache) (Medium) + 1. [LFU Cache](../lfu-cache) (Hard) + 1. [Design Log Storage System](../design-log-storage-system) (Medium) diff --git a/problems/design-linked-list/README.md b/problems/design-linked-list/README.md index 8bf14e22f..c4f46cc65 100644 --- a/problems/design-linked-list/README.md +++ b/problems/design-linked-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-hashmap "Design HashMap") +[< Previous](../design-hashmap "Design HashMap")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-sorted-circular-linked-list "Insert into a Sorted Circular Linked List") +[Next >](../insert-into-a-sorted-circular-linked-list "Insert into a Sorted Circular Linked List") ## [707. Design Linked List (Medium)](https://leetcode.com/problems/design-linked-list "设计链表") @@ -54,5 +54,5 @@ linkedList.get(1);    // returns 3 ### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Design](../../tag/design/README.md)] + [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/design-log-storage-system/README.md b/problems/design-log-storage-system/README.md index 3f4cf123c..811050b29 100644 --- a/problems/design-log-storage-system/README.md +++ b/problems/design-log-storage-system/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-the-derangement-of-an-array "Find the Derangement of An Array") +[< Previous](../find-the-derangement-of-an-array "Find the Derangement of An Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/exclusive-time-of-functions "Exclusive Time of Functions") +[Next >](../exclusive-time-of-functions "Exclusive Time of Functions") ## [635. Design Log Storage System (Medium)](https://leetcode.com/problems/design-log-storage-system "设计日志存储系统") @@ -38,8 +38,8 @@ retrieve("2016:01:01:01:01:01","2017:01:01:23:00:00","Hour"); // return [1,2], b

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Design](../../tag/design/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Design In-Memory File System](https://github.com/openset/leetcode/tree/master/problems/design-in-memory-file-system) (Hard) + 1. [Design In-Memory File System](../design-in-memory-file-system) (Hard) diff --git a/problems/design-phone-directory/README.md b/problems/design-phone-directory/README.md index 8bd0f632c..399850809 100644 --- a/problems/design-phone-directory/README.md +++ b/problems/design-phone-directory/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-element-in-a-sorted-matrix "Kth Smallest Element in a Sorted Matrix") +[< Previous](../kth-smallest-element-in-a-sorted-matrix "Kth Smallest Element in a Sorted Matrix")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/insert-delete-getrandom-o1 "Insert Delete GetRandom O(1)") +[Next >](../insert-delete-getrandom-o1 "Insert Delete GetRandom O(1)") ## [379. Design Phone Directory (Medium)](https://leetcode.com/problems/design-phone-directory "电话目录管理系统") @@ -50,5 +50,5 @@ directory.check(2);

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Design](../../tag/design/README.md)] + [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/design-search-autocomplete-system/README.md b/problems/design-search-autocomplete-system/README.md index 85cf6052a..d15189b63 100644 --- a/problems/design-search-autocomplete-system/README.md +++ b/problems/design-search-autocomplete-system/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-circular-deque "Design Circular Deque") +[< Previous](../design-circular-deque "Design Circular Deque")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-average-subarray-i "Maximum Average Subarray I") +[Next >](../maximum-average-subarray-i "Maximum Average Subarray I") ## [642. Design Search Autocomplete System (Hard)](https://leetcode.com/problems/design-search-autocomplete-system "设计搜索自动补全系统") @@ -73,8 +73,8 @@ The user finished the input, the sentence "i a" should be

 

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] + [[Design](../../tag/design/README.md)] + [[Trie](../../tag/trie/README.md)] ### Similar Questions - 1. [Implement Trie (Prefix Tree)](https://github.com/openset/leetcode/tree/master/problems/implement-trie-prefix-tree) (Medium) + 1. [Implement Trie (Prefix Tree)](../implement-trie-prefix-tree) (Medium) diff --git a/problems/design-skiplist/README.md b/problems/design-skiplist/README.md index be697f676..dc479dc8d 100644 --- a/problems/design-skiplist/README.md +++ b/problems/design-skiplist/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/monthly-transactions-ii "Monthly Transactions II") +[< Previous](../monthly-transactions-ii "Monthly Transactions II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/unique-number-of-occurrences "Unique Number of Occurrences") +[Next >](../unique-number-of-occurrences "Unique Number of Occurrences") ## [1206. Design Skiplist (Hard)](https://leetcode.com/problems/design-skiplist "设计跳表") @@ -60,4 +60,4 @@ skiplist.search(1); // return false, 1 has already been erased. ### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Design](../../tag/design/README.md)] diff --git a/problems/design-snake-game/README.md b/problems/design-snake-game/README.md index b55872a0f..521e549f0 100644 --- a/problems/design-snake-game/README.md +++ b/problems/design-snake-game/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/data-stream-as-disjoint-intervals "Data Stream as Disjoint Intervals") +[< Previous](../data-stream-as-disjoint-intervals "Data Stream as Disjoint Intervals")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/russian-doll-envelopes "Russian Doll Envelopes") +[Next >](../russian-doll-envelopes "Russian Doll Envelopes") ## [353. Design Snake Game (Medium)](https://leetcode.com/problems/design-snake-game "贪吃蛇") @@ -62,5 +62,5 @@ snake.move("U"); -> Returns -1 (Game over because snake collides wi ### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Queue](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] + [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] diff --git a/problems/design-tic-tac-toe/README.md b/problems/design-tic-tac-toe/README.md index 373fc1faf..46731adcc 100644 --- a/problems/design-tic-tac-toe/README.md +++ b/problems/design-tic-tac-toe/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-elements "Top K Frequent Elements") +[< Previous](../top-k-frequent-elements "Top K Frequent Elements")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays "Intersection of Two Arrays") +[Next >](../intersection-of-two-arrays "Intersection of Two Arrays") ## [348. Design Tic-Tac-Toe (Medium)](https://leetcode.com/problems/design-tic-tac-toe "判定井字棋胜负") @@ -70,10 +70,10 @@ Could you do better than O(n2) per move() operati

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions - 1. [Valid Tic-Tac-Toe State](https://github.com/openset/leetcode/tree/master/problems/valid-tic-tac-toe-state) (Medium) + 1. [Valid Tic-Tac-Toe State](../valid-tic-tac-toe-state) (Medium) ### Hints
diff --git a/problems/design-twitter/README.md b/problems/design-twitter/README.md index 3542ae84d..c1ad18065 100644 --- a/problems/design-twitter/README.md +++ b/problems/design-twitter/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/russian-doll-envelopes "Russian Doll Envelopes") +[< Previous](../russian-doll-envelopes "Russian Doll Envelopes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/line-reflection "Line Reflection") +[Next >](../line-reflection "Line Reflection") ## [355. Design Twitter (Medium)](https://leetcode.com/problems/design-twitter "设计推特") @@ -52,6 +52,6 @@ twitter.getNewsFeed(1);

### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/detect-capital/README.md b/problems/detect-capital/README.md index dcfa152ea..8a644ef49 100644 --- a/problems/detect-capital/README.md +++ b/problems/detect-capital/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/random-flip-matrix "Random Flip Matrix") +[< Previous](../random-flip-matrix "Random Flip Matrix")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-uncommon-subsequence-i "Longest Uncommon Subsequence I ") +[Next >](../longest-uncommon-subsequence-i "Longest Uncommon Subsequence I ") ## [520. Detect Capital (Easy)](https://leetcode.com/problems/detect-capital "检测大写字母") @@ -45,4 +45,4 @@ Otherwise, we define that this word doesn't use capitals in a right way.

Note: The input will be a non-empty word consisting of uppercase and lowercase latin letters.

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/di-string-match/README.md b/problems/di-string-match/README.md index 904142157..527e1f1d2 100644 --- a/problems/di-string-match/README.md +++ b/problems/di-string-match/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-mountain-array "Valid Mountain Array") +[< Previous](../valid-mountain-array "Valid Mountain Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-the-shortest-superstring "Find the Shortest Superstring") +[Next >](../find-the-shortest-superstring "Find the Shortest Superstring") ## [942. DI String Match (Easy)](https://leetcode.com/problems/di-string-match "增减字符串匹配") @@ -56,4 +56,4 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/diagonal-traverse/README.md b/problems/diagonal-traverse/README.md index 73dc3c5b7..85827a28b 100644 --- a/problems/diagonal-traverse/README.md +++ b/problems/diagonal-traverse/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/random-point-in-non-overlapping-rectangles "Random Point in Non-overlapping Rectangles") +[< Previous](../random-point-in-non-overlapping-rectangles "Random Point in Non-overlapping Rectangles")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/the-maze-iii "The Maze III") +[Next >](../the-maze-iii "The Maze III") ## [498. Diagonal Traverse (Medium)](https://leetcode.com/problems/diagonal-traverse "对角线遍历") diff --git a/problems/diameter-of-binary-tree/README.md b/problems/diameter-of-binary-tree/README.md index 43408cbaf..9a717ccc8 100644 --- a/problems/diameter-of-binary-tree/README.md +++ b/problems/diameter-of-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/01-matrix "01 Matrix") +[< Previous](../01-matrix "01 Matrix")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/output-contest-matches "Output Contest Matches") +[Next >](../output-contest-matches "Output Contest Matches") ## [543. Diameter of Binary Tree (Easy)](https://leetcode.com/problems/diameter-of-binary-tree "二叉树的直径") @@ -35,4 +35,4 @@ The length of path between two nodes is represented by the number of edges betwe

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] diff --git a/problems/dice-roll-simulation/README.md b/problems/dice-roll-simulation/README.md index 046ad67e1..f85ae8d84 100644 --- a/problems/dice-roll-simulation/README.md +++ b/problems/dice-roll-simulation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/queens-that-can-attack-the-king "Queens That Can Attack the King") +[< Previous](../queens-that-can-attack-the-king "Queens That Can Attack the King")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-equal-frequency "Maximum Equal Frequency") +[Next >](../maximum-equal-frequency "Maximum Equal Frequency") ## [1223. Dice Roll Simulation (Medium)](https://leetcode.com/problems/dice-roll-simulation "掷骰子模拟") @@ -50,7 +50,7 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/diet-plan-performance/README.md b/problems/diet-plan-performance/README.md index c6d6531de..e13b90c53 100644 --- a/problems/diet-plan-performance/README.md +++ b/problems/diet-plan-performance/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/prime-arrangements "Prime Arrangements") +[< Previous](../prime-arrangements "Prime Arrangements")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/can-make-palindrome-from-substring "Can Make Palindrome from Substring") +[Next >](../can-make-palindrome-from-substring "Can Make Palindrome from Substring") ## [1176. Diet Plan Performance (Easy)](https://leetcode.com/problems/diet-plan-performance "健身计划评估") @@ -57,8 +57,8 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Array](../../tag/array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
diff --git a/problems/different-ways-to-add-parentheses/README.md b/problems/different-ways-to-add-parentheses/README.md index 3fe8d055a..270723339 100644 --- a/problems/different-ways-to-add-parentheses/README.md +++ b/problems/different-ways-to-add-parentheses/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/search-a-2d-matrix-ii "Search a 2D Matrix II") +[< Previous](../search-a-2d-matrix-ii "Search a 2D Matrix II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-anagram "Valid Anagram") +[Next >](../valid-anagram "Valid Anagram") ## [241. Different Ways to Add Parentheses (Medium)](https://leetcode.com/problems/different-ways-to-add-parentheses "为运算表达式设计优先级") @@ -36,9 +36,9 @@ ### Related Topics - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions - 1. [Unique Binary Search Trees II](https://github.com/openset/leetcode/tree/master/problems/unique-binary-search-trees-ii) (Medium) - 1. [Basic Calculator](https://github.com/openset/leetcode/tree/master/problems/basic-calculator) (Hard) - 1. [Expression Add Operators](https://github.com/openset/leetcode/tree/master/problems/expression-add-operators) (Hard) + 1. [Unique Binary Search Trees II](../unique-binary-search-trees-ii) (Medium) + 1. [Basic Calculator](../basic-calculator) (Hard) + 1. [Expression Add Operators](../expression-add-operators) (Hard) diff --git a/problems/digit-count-in-range/README.md b/problems/digit-count-in-range/README.md index 0864f21b9..144467f1b 100644 --- a/problems/digit-count-in-range/README.md +++ b/problems/digit-count-in-range/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/campus-bikes-ii "Campus Bikes II") +[< Previous](../campus-bikes-ii "Campus Bikes II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-i "Product Sales Analysis I") +[Next >](../product-sales-analysis-i "Product Sales Analysis I") ## [1067. Digit Count in Range (Hard)](https://leetcode.com/problems/digit-count-in-range "范围内的数字计数") @@ -44,11 +44,11 @@ The digit d=3 occurs 35 times in 103,113,123,130 ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Number of Digit One](https://github.com/openset/leetcode/tree/master/problems/number-of-digit-one) (Hard) + 1. [Number of Digit One](../number-of-digit-one) (Hard) ### Hints
diff --git a/problems/dinner-plate-stacks/README.md b/problems/dinner-plate-stacks/README.md index 60f18c04f..8c1578558 100644 --- a/problems/dinner-plate-stacks/README.md +++ b/problems/dinner-plate-stacks/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-zero-sum-consecutive-nodes-from-linked-list "Remove Zero Sum Consecutive Nodes from Linked List") +[< Previous](../remove-zero-sum-consecutive-nodes-from-linked-list "Remove Zero Sum Consecutive Nodes from Linked List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/immediate-food-delivery-i "Immediate Food Delivery I") +[Next >](../immediate-food-delivery-i "Immediate Food Delivery I") ## [1172. Dinner Plate Stacks (Hard)](https://leetcode.com/problems/dinner-plate-stacks "餐盘栈") @@ -77,7 +77,7 @@ D.pop() // Returns -1. There are still no stacks. ### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Design](../../tag/design/README.md)] ### Hints
diff --git a/problems/distance-between-bus-stops/README.md b/problems/distance-between-bus-stops/README.md index 5cc1a7a56..1d919d552 100644 --- a/problems/distance-between-bus-stops/README.md +++ b/problems/distance-between-bus-stops/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-number-of-ones "Maximum Number of Ones") +[< Previous](../maximum-number-of-ones "Maximum Number of Ones")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/day-of-the-week "Day of the Week") +[Next >](../day-of-the-week "Day of the Week") ## [1184. Distance Between Bus Stops (Easy)](https://leetcode.com/problems/distance-between-bus-stops "公交站间的距离") @@ -62,7 +62,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/distant-barcodes/README.md b/problems/distant-barcodes/README.md index bc984cc96..b77e33d66 100644 --- a/problems/distant-barcodes/README.md +++ b/problems/distant-barcodes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/previous-permutation-with-one-swap "Previous Permutation With One Swap") +[< Previous](../previous-permutation-with-one-swap "Previous Permutation With One Swap")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-way-to-form-string "Shortest Way to Form String") +[Next >](../shortest-way-to-form-string "Shortest Way to Form String") ## [1054. Distant Barcodes (Medium)](https://leetcode.com/problems/distant-barcodes "距离相等的条形码") @@ -46,8 +46,8 @@ ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Sort](../../tag/sort/README.md)] ### Hints
diff --git a/problems/distinct-subsequences-ii/README.md b/problems/distinct-subsequences-ii/README.md index c72aa44f6..5ae9d2f70 100644 --- a/problems/distinct-subsequences-ii/README.md +++ b/problems/distinct-subsequences-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-area-rectangle "Minimum Area Rectangle") +[< Previous](../minimum-area-rectangle "Minimum Area Rectangle")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-mountain-array "Valid Mountain Array") +[Next >](../valid-mountain-array "Valid Mountain Array") ## [940. Distinct Subsequences II (Hard)](https://leetcode.com/problems/distinct-subsequences-ii "不同的子序列 II") @@ -65,4 +65,4 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/distinct-subsequences/README.md b/problems/distinct-subsequences/README.md index 9ba9a29ed..5a7804750 100644 --- a/problems/distinct-subsequences/README.md +++ b/problems/distinct-subsequences/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/flatten-binary-tree-to-linked-list "Flatten Binary Tree to Linked List") +[< Previous](../flatten-binary-tree-to-linked-list "Flatten Binary Tree to Linked List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/populating-next-right-pointers-in-each-node "Populating Next Right Pointers in Each Node") +[Next >](../populating-next-right-pointers-in-each-node "Populating Next Right Pointers in Each Node") ## [115. Distinct Subsequences (Hard)](https://leetcode.com/problems/distinct-subsequences "不同的子序列") @@ -56,5 +56,5 @@ As shown below, there are 5 ways you can generate "bag" from S. ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/distribute-candies-to-people/README.md b/problems/distribute-candies-to-people/README.md index a40be9024..7ee31f1d3 100644 --- a/problems/distribute-candies-to-people/README.md +++ b/problems/distribute-candies-to-people/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/path-with-maximum-minimum-value "Path With Maximum Minimum Value") +[< Previous](../path-with-maximum-minimum-value "Path With Maximum Minimum Value")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/path-in-zigzag-labelled-binary-tree "Path In Zigzag Labelled Binary Tree") +[Next >](../path-in-zigzag-labelled-binary-tree "Path In Zigzag Labelled Binary Tree") ## [1103. Distribute Candies to People (Easy)](https://leetcode.com/problems/distribute-candies-to-people "分糖果 II") @@ -55,7 +55,7 @@ On the fourth turn, ans[0] += 4, and the final array is [5,2,3]. ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/distribute-candies/README.md b/problems/distribute-candies/README.md index 7d5cb2f31..38dff1ca2 100644 --- a/problems/distribute-candies/README.md +++ b/problems/distribute-candies/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/winning-candidate "Winning Candidate") +[< Previous](../winning-candidate "Winning Candidate")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/out-of-boundary-paths "Out of Boundary Paths") +[Next >](../out-of-boundary-paths "Out of Boundary Paths") ## [575. Distribute Candies (Easy)](https://leetcode.com/problems/distribute-candies "分糖果") @@ -41,7 +41,7 @@ The sister has two different kinds of candies, the brother has only one kind of

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
diff --git a/problems/distribute-coins-in-binary-tree/README.md b/problems/distribute-coins-in-binary-tree/README.md index 677a8a1ec..5a8d2fecc 100644 --- a/problems/distribute-coins-in-binary-tree/README.md +++ b/problems/distribute-coins-in-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-turbulent-subarray "Longest Turbulent Subarray") +[< Previous](../longest-turbulent-subarray "Longest Turbulent Subarray")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/unique-paths-iii "Unique Paths III") +[Next >](../unique-paths-iii "Unique Paths III") ## [979. Distribute Coins in Binary Tree (Medium)](https://leetcode.com/problems/distribute-coins-in-binary-tree "在二叉树中分配硬币") @@ -75,9 +75,9 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Sum of Distances in Tree](https://github.com/openset/leetcode/tree/master/problems/sum-of-distances-in-tree) (Hard) - 1. [Binary Tree Cameras](https://github.com/openset/leetcode/tree/master/problems/binary-tree-cameras) (Hard) + 1. [Sum of Distances in Tree](../sum-of-distances-in-tree) (Hard) + 1. [Binary Tree Cameras](../binary-tree-cameras) (Hard) diff --git a/problems/divide-array-into-increasing-sequences/README.md b/problems/divide-array-into-increasing-sequences/README.md index 2713bcd7d..b8e16c7d3 100644 --- a/problems/divide-array-into-increasing-sequences/README.md +++ b/problems/divide-array-into-increasing-sequences/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-average-subtree "Maximum Average Subtree") +[< Previous](../maximum-average-subtree "Maximum Average Subtree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/relative-sort-array "Relative Sort Array") +[Next >](../relative-sort-array "Relative Sort Array") ## [1121. Divide Array Into Increasing Sequences (Hard)](https://leetcode.com/problems/divide-array-into-increasing-sequences "将数组分成几个递增序列") @@ -44,7 +44,7 @@ There is no way to divide the array using the conditions required. ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/divide-chocolate/README.md b/problems/divide-chocolate/README.md index a3f3daf1a..b60367c17 100644 --- a/problems/divide-chocolate/README.md +++ b/problems/divide-chocolate/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/toss-strange-coins "Toss Strange Coins") +[< Previous](../toss-strange-coins "Toss Strange Coins")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/check-if-it-is-a-straight-line "Check If It Is a Straight Line") +[Next >](../check-if-it-is-a-straight-line "Check If It Is a Straight Line") ## [1231. Divide Chocolate (Hard)](https://leetcode.com/problems/divide-chocolate "分享巧克力") @@ -53,8 +53,8 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
diff --git a/problems/divide-two-integers/README.md b/problems/divide-two-integers/README.md index 013767ec8..cc6d1c827 100644 --- a/problems/divide-two-integers/README.md +++ b/problems/divide-two-integers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/implement-strstr "Implement strStr()") +[< Previous](../implement-strstr "Implement strStr()")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/substring-with-concatenation-of-all-words "Substring with Concatenation of All Words") +[Next >](../substring-with-concatenation-of-all-words "Substring with Concatenation of All Words") ## [29. Divide Two Integers (Medium)](https://leetcode.com/problems/divide-two-integers "两数相除") @@ -38,5 +38,5 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/divisor-game/README.md b/problems/divisor-game/README.md index d39492181..6b74ac26b 100644 --- a/problems/divisor-game/README.md +++ b/problems/divisor-game/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/video-stitching "Video Stitching") +[< Previous](../video-stitching "Video Stitching")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-difference-between-node-and-ancestor "Maximum Difference Between Node and Ancestor") +[Next >](../maximum-difference-between-node-and-ancestor "Maximum Difference Between Node and Ancestor") ## [1025. Divisor Game (Easy)](https://leetcode.com/problems/divisor-game "除数博弈") @@ -58,8 +58,8 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/domino-and-tromino-tiling/README.md b/problems/domino-and-tromino-tiling/README.md index 67d8e276b..b469cb085 100644 --- a/problems/domino-and-tromino-tiling/README.md +++ b/problems/domino-and-tromino-tiling/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/escape-the-ghosts "Escape The Ghosts") +[< Previous](../escape-the-ghosts "Escape The Ghosts")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/custom-sort-string "Custom Sort String") +[Next >](../custom-sort-string "Custom Sort String") ## [790. Domino and Tromino Tiling (Medium)](https://leetcode.com/problems/domino-and-tromino-tiling "多米诺和托米诺平铺") @@ -43,4 +43,4 @@ XYZ YYZ XZZ XYY XXY

 

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/dota2-senate/README.md b/problems/dota2-senate/README.md index e0a6664fa..f0bf806cb 100644 --- a/problems/dota2-senate/README.md +++ b/problems/dota2-senate/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/replace-words "Replace Words") +[< Previous](../replace-words "Replace Words")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/2-keys-keyboard "2 Keys Keyboard") +[Next >](../2-keys-keyboard "2 Keys Keyboard") ## [649. Dota2 Senate (Medium)](https://leetcode.com/problems/dota2-senate "Dota2 参议院") @@ -65,7 +65,7 @@ And in the round 2, the third senator can just announce the victory since he is

 

### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions - 1. [Teemo Attacking](https://github.com/openset/leetcode/tree/master/problems/teemo-attacking) (Medium) + 1. [Teemo Attacking](../teemo-attacking) (Medium) diff --git a/problems/dungeon-game/README.md b/problems/dungeon-game/README.md index 97a9a1adb..24582265b 100644 --- a/problems/dungeon-game/README.md +++ b/problems/dungeon-game/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-search-tree-iterator "Binary Search Tree Iterator") +[< Previous](../binary-search-tree-iterator "Binary Search Tree Iterator")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/combine-two-tables "Combine Two Tables") +[Next >](../combine-two-tables "Combine Two Tables") ## [174. Dungeon Game (Hard)](https://leetcode.com/problems/dungeon-game "地下城游戏") @@ -55,10 +55,10 @@ ### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Unique Paths](https://github.com/openset/leetcode/tree/master/problems/unique-paths) (Medium) - 1. [Minimum Path Sum](https://github.com/openset/leetcode/tree/master/problems/minimum-path-sum) (Medium) - 1. [Cherry Pickup](https://github.com/openset/leetcode/tree/master/problems/cherry-pickup) (Hard) + 1. [Unique Paths](../unique-paths) (Medium) + 1. [Minimum Path Sum](../minimum-path-sum) (Medium) + 1. [Cherry Pickup](../cherry-pickup) (Hard) diff --git a/problems/duplicate-emails/README.md b/problems/duplicate-emails/README.md index 6c3c10853..3b3247fdc 100644 --- a/problems/duplicate-emails/README.md +++ b/problems/duplicate-emails/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/employees-earning-more-than-their-managers "Employees Earning More Than Their Managers") +[< Previous](../employees-earning-more-than-their-managers "Employees Earning More Than Their Managers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/customers-who-never-order "Customers Who Never Order") +[Next >](../customers-who-never-order "Customers Who Never Order") ## [182. Duplicate Emails (Easy)](https://leetcode.com/problems/duplicate-emails "查找重复的电子邮箱") diff --git a/problems/duplicate-zeros/README.md b/problems/duplicate-zeros/README.md index 9856d288b..4799ee5dd 100644 --- a/problems/duplicate-zeros/README.md +++ b/problems/duplicate-zeros/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/confusing-number-ii "Confusing Number II") +[< Previous](../confusing-number-ii "Confusing Number II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/largest-values-from-labels "Largest Values From Labels") +[Next >](../largest-values-from-labels "Largest Values From Labels") ## [1089. Duplicate Zeros (Easy)](https://leetcode.com/problems/duplicate-zeros "复写零") @@ -45,7 +45,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/edit-distance/README.md b/problems/edit-distance/README.md index adaa032a4..140d75e55 100644 --- a/problems/edit-distance/README.md +++ b/problems/edit-distance/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/simplify-path "Simplify Path") +[< Previous](../simplify-path "Simplify Path")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/set-matrix-zeroes "Set Matrix Zeroes") +[Next >](../set-matrix-zeroes "Set Matrix Zeroes") ## [72. Edit Distance (Hard)](https://leetcode.com/problems/edit-distance "编辑距离") @@ -46,11 +46,11 @@ exection -> execution (insert 'u') ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [One Edit Distance](https://github.com/openset/leetcode/tree/master/problems/one-edit-distance) (Medium) - 1. [Delete Operation for Two Strings](https://github.com/openset/leetcode/tree/master/problems/delete-operation-for-two-strings) (Medium) - 1. [Minimum ASCII Delete Sum for Two Strings](https://github.com/openset/leetcode/tree/master/problems/minimum-ascii-delete-sum-for-two-strings) (Medium) - 1. [Uncrossed Lines](https://github.com/openset/leetcode/tree/master/problems/uncrossed-lines) (Medium) + 1. [One Edit Distance](../one-edit-distance) (Medium) + 1. [Delete Operation for Two Strings](../delete-operation-for-two-strings) (Medium) + 1. [Minimum ASCII Delete Sum for Two Strings](../minimum-ascii-delete-sum-for-two-strings) (Medium) + 1. [Uncrossed Lines](../uncrossed-lines) (Medium) diff --git a/problems/element-appearing-more-than-25-in-sorted-array/README.md b/problems/element-appearing-more-than-25-in-sorted-array/README.md index 172d085de..52bdccd5e 100644 --- a/problems/element-appearing-more-than-25-in-sorted-array/README.md +++ b/problems/element-appearing-more-than-25-in-sorted-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/iterator-for-combination "Iterator for Combination") +[< Previous](../iterator-for-combination "Iterator for Combination")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-covered-intervals "Remove Covered Intervals") +[Next >](../remove-covered-intervals "Remove Covered Intervals") ## [1287. Element Appearing More Than 25% In Sorted Array (Easy)](https://leetcode.com/problems/element-appearing-more-than-25-in-sorted-array "有序数组中出现次数超过25%的元素") @@ -29,7 +29,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/elimination-game/README.md b/problems/elimination-game/README.md index ea1bc19a1..142b660d0 100644 --- a/problems/elimination-game/README.md +++ b/problems/elimination-game/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-the-difference "Find the Difference") +[< Previous](../find-the-difference "Find the Difference")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/perfect-rectangle "Perfect Rectangle") +[Next >](../perfect-rectangle "Perfect Rectangle") ## [390. Elimination Game (Medium)](https://leetcode.com/problems/elimination-game "消除游戏") diff --git a/problems/employee-bonus/README.md b/problems/employee-bonus/README.md index 5f390e4f5..da6fb333b 100644 --- a/problems/employee-bonus/README.md +++ b/problems/employee-bonus/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/out-of-boundary-paths "Out of Boundary Paths") +[< Previous](../out-of-boundary-paths "Out of Boundary Paths")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/get-highest-answer-rate-question "Get Highest Answer Rate Question") +[Next >](../get-highest-answer-rate-question "Get Highest Answer Rate Question") ## [577. Employee Bonus (Easy)](https://leetcode.com/problems/employee-bonus "员工奖金") @@ -52,7 +52,7 @@ empId is the primary key column for this table. ### Similar Questions - 1. [Combine Two Tables](https://github.com/openset/leetcode/tree/master/problems/combine-two-tables) (Easy) + 1. [Combine Two Tables](../combine-two-tables) (Easy) ### Hints
diff --git a/problems/employee-free-time/README.md b/problems/employee-free-time/README.md index 58aefdc02..8cb019ef3 100644 --- a/problems/employee-free-time/README.md +++ b/problems/employee-free-time/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/bold-words-in-string "Bold Words in String") +[< Previous](../bold-words-in-string "Bold Words in String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-anagram-mappings "Find Anagram Mappings") +[Next >](../find-anagram-mappings "Find Anagram Mappings") ## [759. Employee Free Time (Hard)](https://leetcode.com/problems/employee-free-time "员工空闲时间") @@ -55,12 +55,12 @@ We discard any intervals that contain inf as they aren't finite.

 

### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions - 1. [Merge Intervals](https://github.com/openset/leetcode/tree/master/problems/merge-intervals) (Medium) - 1. [Interval List Intersections](https://github.com/openset/leetcode/tree/master/problems/interval-list-intersections) (Medium) + 1. [Merge Intervals](../merge-intervals) (Medium) + 1. [Interval List Intersections](../interval-list-intersections) (Medium) ### Hints
diff --git a/problems/employee-importance/README.md b/problems/employee-importance/README.md index 17f9c8afa..16fda8047 100644 --- a/problems/employee-importance/README.md +++ b/problems/employee-importance/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-sum-of-3-non-overlapping-subarrays "Maximum Sum of 3 Non-Overlapping Subarrays") +[< Previous](../maximum-sum-of-3-non-overlapping-subarrays "Maximum Sum of 3 Non-Overlapping Subarrays")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/stickers-to-spell-word "Stickers to Spell Word") +[Next >](../stickers-to-spell-word "Stickers to Spell Word") ## [690. Employee Importance (Easy)](https://leetcode.com/problems/employee-importance "员工的重要性") @@ -38,9 +38,9 @@ Employee 1 has importance value 5, and he has two direct subordinates: employee

 

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Nested List Weight Sum](https://github.com/openset/leetcode/tree/master/problems/nested-list-weight-sum) (Easy) + 1. [Nested List Weight Sum](../nested-list-weight-sum) (Easy) diff --git a/problems/employees-earning-more-than-their-managers/README.md b/problems/employees-earning-more-than-their-managers/README.md index 4f6b0b684..d775a4709 100644 --- a/problems/employees-earning-more-than-their-managers/README.md +++ b/problems/employees-earning-more-than-their-managers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/consecutive-numbers "Consecutive Numbers") +[< Previous](../consecutive-numbers "Consecutive Numbers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/duplicate-emails "Duplicate Emails") +[Next >](../duplicate-emails "Duplicate Emails") ## [181. Employees Earning More Than Their Managers (Easy)](https://leetcode.com/problems/employees-earning-more-than-their-managers "超过经理收入的员工") diff --git a/problems/encode-and-decode-strings/README.md b/problems/encode-and-decode-strings/README.md index ab52b1dca..5674a6223 100644 --- a/problems/encode-and-decode-strings/README.md +++ b/problems/encode-and-decode-strings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/closest-binary-search-tree-value "Closest Binary Search Tree Value") +[< Previous](../closest-binary-search-tree-value "Closest Binary Search Tree Value")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/closest-binary-search-tree-value-ii "Closest Binary Search Tree Value II") +[Next >](../closest-binary-search-tree-value-ii "Closest Binary Search Tree Value II") ## [271. Encode and Decode Strings (Medium)](https://leetcode.com/problems/encode-and-decode-strings "字符串的编码与解码") @@ -56,10 +56,10 @@ vector<string> strs2 = decode(encoded_string); ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Count and Say](https://github.com/openset/leetcode/tree/master/problems/count-and-say) (Easy) - 1. [Serialize and Deserialize Binary Tree](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-binary-tree) (Hard) - 1. [String Compression](https://github.com/openset/leetcode/tree/master/problems/string-compression) (Easy) - 1. [Count Binary Substrings](https://github.com/openset/leetcode/tree/master/problems/count-binary-substrings) (Easy) + 1. [Count and Say](../count-and-say) (Easy) + 1. [Serialize and Deserialize Binary Tree](../serialize-and-deserialize-binary-tree) (Hard) + 1. [String Compression](../string-compression) (Easy) + 1. [Count Binary Substrings](../count-binary-substrings) (Easy) diff --git a/problems/encode-and-decode-tinyurl/README.md b/problems/encode-and-decode-tinyurl/README.md index d4ac836c6..209c602d6 100644 --- a/problems/encode-and-decode-tinyurl/README.md +++ b/problems/encode-and-decode-tinyurl/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-iii "Game Play Analysis III") +[< Previous](../game-play-analysis-iii "Game Play Analysis III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-string "Construct Binary Tree from String") +[Next >](../construct-binary-tree-from-string "Construct Binary Tree from String") ## [535. Encode and Decode TinyURL (Medium)](https://leetcode.com/problems/encode-and-decode-tinyurl "TinyURL 的加密与解密") @@ -18,5 +18,5 @@

Design the encode and decode methods for the TinyURL service. There is no restriction on how your encode/decode algorithm should work. You just need to ensure that a URL can be encoded to a tiny URL and the tiny URL can be decoded to the original URL.

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/encode-n-ary-tree-to-binary-tree/README.md b/problems/encode-n-ary-tree-to-binary-tree/README.md index d5cf469f7..e2895bbe5 100644 --- a/problems/encode-n-ary-tree-to-binary-tree/README.md +++ b/problems/encode-n-ary-tree-to-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/flatten-a-multilevel-doubly-linked-list "Flatten a Multilevel Doubly Linked List") +[< Previous](../flatten-a-multilevel-doubly-linked-list "Flatten a Multilevel Doubly Linked List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/all-oone-data-structure "All O`one Data Structure") +[Next >](../all-oone-data-structure "All O`one Data Structure") ## [431. Encode N-ary Tree to Binary Tree (Hard)](https://leetcode.com/problems/encode-n-ary-tree-to-binary-tree "将 N 叉树编码为二叉树") @@ -33,7 +33,7 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Serialize and Deserialize N-ary Tree](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-n-ary-tree) (Hard) + 1. [Serialize and Deserialize N-ary Tree](../serialize-and-deserialize-n-ary-tree) (Hard) diff --git a/problems/encode-number/README.md b/problems/encode-number/README.md index fa422dd2a..31691e5a7 100644 --- a/problems/encode-number/README.md +++ b/problems/encode-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-score-words-formed-by-letters "Maximum Score Words Formed by Letters") +[< Previous](../maximum-score-words-formed-by-letters "Maximum Score Words Formed by Letters")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/smallest-common-region "Smallest Common Region") +[Next >](../smallest-common-region "Smallest Common Region") ## [1256. Encode Number (Medium)](https://leetcode.com/problems/encode-number "加密数字") @@ -40,11 +40,11 @@ ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Convert to Base -2](https://github.com/openset/leetcode/tree/master/problems/convert-to-base-2) (Medium) + 1. [Convert to Base -2](../convert-to-base-2) (Medium) ### Hints
diff --git a/problems/encode-string-with-shortest-length/README.md b/problems/encode-string-with-shortest-length/README.md index 0f9cb0c75..f30975bf9 100644 --- a/problems/encode-string-with-shortest-length/README.md +++ b/problems/encode-string-with-shortest-length/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/implement-rand10-using-rand7 "Implement Rand10() Using Rand7()") +[< Previous](../implement-rand10-using-rand7 "Implement Rand10() Using Rand7()")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/concatenated-words "Concatenated Words") +[Next >](../concatenated-words "Concatenated Words") ## [471. Encode String with Shortest Length (Hard)](https://leetcode.com/problems/encode-string-with-shortest-length "编码最短长度的字符串") @@ -76,8 +76,8 @@ Explanation: "abbbabbbc" occurs twice, but "abbbabbbc" can a

 

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Decode String](https://github.com/openset/leetcode/tree/master/problems/decode-string) (Medium) - 1. [Number of Atoms](https://github.com/openset/leetcode/tree/master/problems/number-of-atoms) (Hard) + 1. [Decode String](../decode-string) (Medium) + 1. [Number of Atoms](../number-of-atoms) (Hard) diff --git a/problems/equal-rational-numbers/README.md b/problems/equal-rational-numbers/README.md index 7b30d8133..1f778ea6a 100644 --- a/problems/equal-rational-numbers/README.md +++ b/problems/equal-rational-numbers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/flip-binary-tree-to-match-preorder-traversal "Flip Binary Tree To Match Preorder Traversal") +[< Previous](../flip-binary-tree-to-match-preorder-traversal "Flip Binary Tree To Match Preorder Traversal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/k-closest-points-to-origin "K Closest Points to Origin") +[Next >](../k-closest-points-to-origin "K Closest Points to Origin") ## [972. Equal Rational Numbers (Hard)](https://leetcode.com/problems/equal-rational-numbers "相等的有理数") @@ -71,4 +71,4 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/equal-tree-partition/README.md b/problems/equal-tree-partition/README.md index 19e441893..c6edb8c86 100644 --- a/problems/equal-tree-partition/README.md +++ b/problems/equal-tree-partition/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-width-of-binary-tree "Maximum Width of Binary Tree") +[< Previous](../maximum-width-of-binary-tree "Maximum Width of Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/strange-printer "Strange Printer") +[Next >](../strange-printer "Strange Printer") ## [663. Equal Tree Partition (Medium)](https://leetcode.com/problems/equal-tree-partition "均匀树划分") @@ -61,4 +61,4 @@ Sum: 15

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] diff --git a/problems/erect-the-fence/README.md b/problems/erect-the-fence/README.md index 200ec6428..4ca2c2779 100644 --- a/problems/erect-the-fence/README.md +++ b/problems/erect-the-fence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/customer-placing-the-largest-number-of-orders "Customer Placing the Largest Number of Orders") +[< Previous](../customer-placing-the-largest-number-of-orders "Customer Placing the Largest Number of Orders")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-in-memory-file-system "Design In-Memory File System") +[Next >](../design-in-memory-file-system "Design In-Memory File System") ## [587. Erect the Fence (Hard)](https://leetcode.com/problems/erect-the-fence "安装栅栏") @@ -48,4 +48,4 @@ Even you only have trees in a line, you need to use rope to enclose them. ### Related Topics - [[Geometry](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md)] + [[Geometry](../../tag/geometry/README.md)] diff --git a/problems/escape-a-large-maze/README.md b/problems/escape-a-large-maze/README.md index b36b78f3b..7348bfdea 100644 --- a/problems/escape-a-large-maze/README.md +++ b/problems/escape-a-large-maze/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/uncrossed-lines "Uncrossed Lines") +[< Previous](../uncrossed-lines "Uncrossed Lines")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-boomerang "Valid Boomerang") +[Next >](../valid-boomerang "Valid Boomerang") ## [1036. Escape a Large Maze (Hard)](https://leetcode.com/problems/escape-a-large-maze "逃离大迷宫") @@ -51,7 +51,7 @@ Because there are no blocked cells, it's possible to reach the target square ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Hints
diff --git a/problems/escape-the-ghosts/README.md b/problems/escape-the-ghosts/README.md index b26beb934..a733cf3dc 100644 --- a/problems/escape-the-ghosts/README.md +++ b/problems/escape-the-ghosts/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/rotated-digits "Rotated Digits") +[< Previous](../rotated-digits "Rotated Digits")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/domino-and-tromino-tiling "Domino and Tromino Tiling") +[Next >](../domino-and-tromino-tiling "Domino and Tromino Tiling") ## [789. Escape The Ghosts (Medium)](https://leetcode.com/problems/escape-the-ghosts "逃脱阻碍者") @@ -57,4 +57,4 @@ The ghost can reach the target at the same time as you. ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/evaluate-division/README.md b/problems/evaluate-division/README.md index ba9219a90..da828384c 100644 --- a/problems/evaluate-division/README.md +++ b/problems/evaluate-division/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/random-pick-index "Random Pick Index") +[< Previous](../random-pick-index "Random Pick Index")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/nth-digit "Nth Digit") +[Next >](../nth-digit "Nth Digit") ## [399. Evaluate Division (Medium)](https://leetcode.com/problems/evaluate-division "除法求值") @@ -32,8 +32,8 @@ queries = [ ["a", "c"], ["b", "a"], [&qu

The input is always valid. You may assume that evaluating the queries will result in no division by zero and there is no contradiction.

### Related Topics - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] ### Hints
diff --git a/problems/evaluate-reverse-polish-notation/README.md b/problems/evaluate-reverse-polish-notation/README.md index e0e1ba1c9..8517d4438 100644 --- a/problems/evaluate-reverse-polish-notation/README.md +++ b/problems/evaluate-reverse-polish-notation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/max-points-on-a-line "Max Points on a Line") +[< Previous](../max-points-on-a-line "Max Points on a Line")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reverse-words-in-a-string "Reverse Words in a String") +[Next >](../reverse-words-in-a-string "Reverse Words in a String") ## [150. Evaluate Reverse Polish Notation (Medium)](https://leetcode.com/problems/evaluate-reverse-polish-notation "逆波兰表达式求值") @@ -54,8 +54,8 @@ ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] + [[Stack](../../tag/stack/README.md)] ### Similar Questions - 1. [Basic Calculator](https://github.com/openset/leetcode/tree/master/problems/basic-calculator) (Hard) - 1. [Expression Add Operators](https://github.com/openset/leetcode/tree/master/problems/expression-add-operators) (Hard) + 1. [Basic Calculator](../basic-calculator) (Hard) + 1. [Expression Add Operators](../expression-add-operators) (Hard) diff --git a/problems/exam-room/README.md b/problems/exam-room/README.md index 3e40ccb17..d69790d06 100644 --- a/problems/exam-room/README.md +++ b/problems/exam-room/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/k-similar-strings "K-Similar Strings") +[< Previous](../k-similar-strings "K-Similar Strings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/score-of-parentheses "Score of Parentheses") +[Next >](../score-of-parentheses "Score of Parentheses") ## [855. Exam Room (Medium)](https://leetcode.com/problems/exam-room "考场就座") @@ -45,7 +45,7 @@ seat() -> 5, the student sits at the last seat number 5. ### Related Topics - [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] + [[Ordered Map](../../tag/ordered-map/README.md)] ### Similar Questions - 1. [Maximize Distance to Closest Person](https://github.com/openset/leetcode/tree/master/problems/maximize-distance-to-closest-person) (Easy) + 1. [Maximize Distance to Closest Person](../maximize-distance-to-closest-person) (Easy) diff --git a/problems/excel-sheet-column-number/README.md b/problems/excel-sheet-column-number/README.md index 0a2fed74a..f89b0a019 100644 --- a/problems/excel-sheet-column-number/README.md +++ b/problems/excel-sheet-column-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/two-sum-iii-data-structure-design "Two Sum III - Data structure design") +[< Previous](../two-sum-iii-data-structure-design "Two Sum III - Data structure design")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/factorial-trailing-zeroes "Factorial Trailing Zeroes") +[Next >](../factorial-trailing-zeroes "Factorial Trailing Zeroes") ## [171. Excel Sheet Column Number (Easy)](https://leetcode.com/problems/excel-sheet-column-number "Excel表列序号") @@ -48,7 +48,7 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Excel Sheet Column Title](https://github.com/openset/leetcode/tree/master/problems/excel-sheet-column-title) (Easy) + 1. [Excel Sheet Column Title](../excel-sheet-column-title) (Easy) diff --git a/problems/excel-sheet-column-title/README.md b/problems/excel-sheet-column-title/README.md index ad0ca9fde..9992a826c 100644 --- a/problems/excel-sheet-column-title/README.md +++ b/problems/excel-sheet-column-title/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/two-sum-ii-input-array-is-sorted "Two Sum II - Input array is sorted") +[< Previous](../two-sum-ii-input-array-is-sorted "Two Sum II - Input array is sorted")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/majority-element "Majority Element") +[Next >](../majority-element "Majority Element") ## [168. Excel Sheet Column Title (Easy)](https://leetcode.com/problems/excel-sheet-column-title "Excel表列名称") @@ -48,7 +48,7 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Excel Sheet Column Number](https://github.com/openset/leetcode/tree/master/problems/excel-sheet-column-number) (Easy) + 1. [Excel Sheet Column Number](../excel-sheet-column-number) (Easy) diff --git a/problems/exchange-seats/README.md b/problems/exchange-seats/README.md index f433e5da1..b68568d1a 100644 --- a/problems/exchange-seats/README.md +++ b/problems/exchange-seats/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-factorization "Minimum Factorization") +[< Previous](../minimum-factorization "Minimum Factorization")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/swap-salary "Swap Salary") +[Next >](../swap-salary "Swap Salary") ## [626. Exchange Seats (Medium)](https://leetcode.com/problems/exchange-seats "换座位") diff --git a/problems/exclusive-time-of-functions/README.md b/problems/exclusive-time-of-functions/README.md index d7109cfcd..3eb9ebd75 100644 --- a/problems/exclusive-time-of-functions/README.md +++ b/problems/exclusive-time-of-functions/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-log-storage-system "Design Log Storage System") +[< Previous](../design-log-storage-system "Design Log Storage System")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/average-of-levels-in-binary-tree "Average of Levels in Binary Tree") +[Next >](../average-of-levels-in-binary-tree "Average of Levels in Binary Tree") ## [636. Exclusive Time of Functions (Medium)](https://leetcode.com/problems/exclusive-time-of-functions "函数的独占时间") @@ -54,4 +54,4 @@ So function 0 spends 2 + 1 = 3 units of total time executing, and function 1 spe

 

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] + [[Stack](../../tag/stack/README.md)] diff --git a/problems/expression-add-operators/README.md b/problems/expression-add-operators/README.md index 0705843ca..03eceb030 100644 --- a/problems/expression-add-operators/README.md +++ b/problems/expression-add-operators/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/zigzag-iterator "Zigzag Iterator") +[< Previous](../zigzag-iterator "Zigzag Iterator")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/move-zeroes "Move Zeroes") +[Next >](../move-zeroes "Move Zeroes") ## [282. Expression Add Operators (Hard)](https://leetcode.com/problems/expression-add-operators "给表达式添加运算符") @@ -47,14 +47,14 @@ ### Related Topics - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions - 1. [Evaluate Reverse Polish Notation](https://github.com/openset/leetcode/tree/master/problems/evaluate-reverse-polish-notation) (Medium) - 1. [Basic Calculator](https://github.com/openset/leetcode/tree/master/problems/basic-calculator) (Hard) - 1. [Basic Calculator II](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-ii) (Medium) - 1. [Different Ways to Add Parentheses](https://github.com/openset/leetcode/tree/master/problems/different-ways-to-add-parentheses) (Medium) - 1. [Target Sum](https://github.com/openset/leetcode/tree/master/problems/target-sum) (Medium) + 1. [Evaluate Reverse Polish Notation](../evaluate-reverse-polish-notation) (Medium) + 1. [Basic Calculator](../basic-calculator) (Hard) + 1. [Basic Calculator II](../basic-calculator-ii) (Medium) + 1. [Different Ways to Add Parentheses](../different-ways-to-add-parentheses) (Medium) + 1. [Target Sum](../target-sum) (Medium) ### Hints
diff --git a/problems/expressive-words/README.md b/problems/expressive-words/README.md index 580f18da8..6f0a59155 100644 --- a/problems/expressive-words/README.md +++ b/problems/expressive-words/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/soup-servings "Soup Servings") +[< Previous](../soup-servings "Soup Servings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/chalkboard-xor-game "Chalkboard XOR Game") +[Next >](../chalkboard-xor-game "Chalkboard XOR Game") ## [809. Expressive Words (Medium)](https://leetcode.com/problems/expressive-words "情感丰富的文字") @@ -46,4 +46,4 @@ We can't extend "helo" to get "heeellooo" because the gr

 

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/factor-combinations/README.md b/problems/factor-combinations/README.md index ef9157484..89ab53fba 100644 --- a/problems/factor-combinations/README.md +++ b/problems/factor-combinations/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/meeting-rooms-ii "Meeting Rooms II") +[< Previous](../meeting-rooms-ii "Meeting Rooms II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/verify-preorder-sequence-in-binary-search-tree "Verify Preorder Sequence in Binary Search Tree") +[Next >](../verify-preorder-sequence-in-binary-search-tree "Verify Preorder Sequence in Binary Search Tree") ## [254. Factor Combinations (Medium)](https://leetcode.com/problems/factor-combinations "因子的组合") @@ -67,7 +67,7 @@ ### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Combination Sum](https://github.com/openset/leetcode/tree/master/problems/combination-sum) (Medium) + 1. [Combination Sum](../combination-sum) (Medium) diff --git a/problems/factorial-trailing-zeroes/README.md b/problems/factorial-trailing-zeroes/README.md index 699e5d0a6..ad390a548 100644 --- a/problems/factorial-trailing-zeroes/README.md +++ b/problems/factorial-trailing-zeroes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/excel-sheet-column-number "Excel Sheet Column Number") +[< Previous](../excel-sheet-column-number "Excel Sheet Column Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-search-tree-iterator "Binary Search Tree Iterator") +[Next >](../binary-search-tree-iterator "Binary Search Tree Iterator") ## [172. Factorial Trailing Zeroes (Easy)](https://leetcode.com/problems/factorial-trailing-zeroes "阶乘后的零") @@ -30,8 +30,8 @@

Note: Your solution should be in logarithmic time complexity.

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Number of Digit One](https://github.com/openset/leetcode/tree/master/problems/number-of-digit-one) (Hard) - 1. [Preimage Size of Factorial Zeroes Function](https://github.com/openset/leetcode/tree/master/problems/preimage-size-of-factorial-zeroes-function) (Hard) + 1. [Number of Digit One](../number-of-digit-one) (Hard) + 1. [Preimage Size of Factorial Zeroes Function](../preimage-size-of-factorial-zeroes-function) (Hard) diff --git a/problems/fair-candy-swap/README.md b/problems/fair-candy-swap/README.md index 77ec6bc00..79fe3e629 100644 --- a/problems/fair-candy-swap/README.md +++ b/problems/fair-candy-swap/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/super-egg-drop "Super Egg Drop") +[< Previous](../super-egg-drop "Super Egg Drop")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-preorder-and-postorder-traversal "Construct Binary Tree from Preorder and Postorder Traversal") +[Next >](../construct-binary-tree-from-preorder-and-postorder-traversal "Construct Binary Tree from Preorder and Postorder Traversal") ## [888. Fair Candy Swap (Easy)](https://leetcode.com/problems/fair-candy-swap "公平的糖果交换") @@ -71,4 +71,4 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/falling-squares/README.md b/problems/falling-squares/README.md index 07f33153d..d9209d82b 100644 --- a/problems/falling-squares/README.md +++ b/problems/falling-squares/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/partition-to-k-equal-sum-subsets "Partition to K Equal Sum Subsets") +[< Previous](../partition-to-k-equal-sum-subsets "Partition to K Equal Sum Subsets")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/search-in-a-binary-search-tree "Search in a Binary Search Tree") +[Next >](../search-in-a-binary-search-tree "Search in a Binary Search Tree") ## [699. Falling Squares (Hard)](https://leetcode.com/problems/falling-squares "掉落的方块") @@ -60,11 +60,11 @@

 

### Related Topics - [[Segment Tree](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] - [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Ordered Map](../../tag/ordered-map/README.md)] ### Similar Questions - 1. [The Skyline Problem](https://github.com/openset/leetcode/tree/master/problems/the-skyline-problem) (Hard) + 1. [The Skyline Problem](../the-skyline-problem) (Hard) ### Hints
diff --git a/problems/fibonacci-number/README.md b/problems/fibonacci-number/README.md index fcb1407d4..c4047fe08 100644 --- a/problems/fibonacci-number/README.md +++ b/problems/fibonacci-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/most-frequent-subtree-sum "Most Frequent Subtree Sum") +[< Previous](../most-frequent-subtree-sum "Most Frequent Subtree Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/inorder-successor-in-bst-ii "Inorder Successor in BST II") +[Next >](../inorder-successor-in-bst-ii "Inorder Successor in BST II") ## [509. Fibonacci Number (Easy)](https://leetcode.com/problems/fibonacci-number "斐波那契数") @@ -53,9 +53,9 @@ F(N) = F(N - 1) + F(N - 2), for N > 1.

0 ≤ N ≤ 30.

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Climbing Stairs](https://github.com/openset/leetcode/tree/master/problems/climbing-stairs) (Easy) - 1. [Split Array into Fibonacci Sequence](https://github.com/openset/leetcode/tree/master/problems/split-array-into-fibonacci-sequence) (Medium) - 1. [Length of Longest Fibonacci Subsequence](https://github.com/openset/leetcode/tree/master/problems/length-of-longest-fibonacci-subsequence) (Medium) + 1. [Climbing Stairs](../climbing-stairs) (Easy) + 1. [Split Array into Fibonacci Sequence](../split-array-into-fibonacci-sequence) (Medium) + 1. [Length of Longest Fibonacci Subsequence](../length-of-longest-fibonacci-subsequence) (Medium) diff --git a/problems/filling-bookcase-shelves/README.md b/problems/filling-bookcase-shelves/README.md index 996594860..5d223c77d 100644 --- a/problems/filling-bookcase-shelves/README.md +++ b/problems/filling-bookcase-shelves/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/path-in-zigzag-labelled-binary-tree "Path In Zigzag Labelled Binary Tree") +[< Previous](../path-in-zigzag-labelled-binary-tree "Path In Zigzag Labelled Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/parsing-a-boolean-expression "Parsing A Boolean Expression") +[Next >](../parsing-a-boolean-expression "Parsing A Boolean Expression") ## [1105. Filling Bookcase Shelves (Medium)](https://leetcode.com/problems/filling-bookcase-shelves "填充书架") @@ -42,7 +42,7 @@ Notice that book number 2 does not have to be on the first shelf. ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/find-all-anagrams-in-a-string/README.md b/problems/find-all-anagrams-in-a-string/README.md index 06a8f41f8..bb7452d0b 100644 --- a/problems/find-all-anagrams-in-a-string/README.md +++ b/problems/find-all-anagrams-in-a-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/path-sum-iii "Path Sum III") +[< Previous](../path-sum-iii "Path Sum III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/ternary-expression-parser "Ternary Expression Parser") +[Next >](../ternary-expression-parser "Ternary Expression Parser") ## [438. Find All Anagrams in a String (Medium)](https://leetcode.com/problems/find-all-anagrams-in-a-string "找到字符串中所有字母异位词") @@ -47,8 +47,8 @@ The substring with start index = 2 is "ab", which is an anagram of "ab".

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Valid Anagram](https://github.com/openset/leetcode/tree/master/problems/valid-anagram) (Easy) - 1. [Permutation in String](https://github.com/openset/leetcode/tree/master/problems/permutation-in-string) (Medium) + 1. [Valid Anagram](../valid-anagram) (Easy) + 1. [Permutation in String](../permutation-in-string) (Medium) diff --git a/problems/find-all-duplicates-in-an-array/README.md b/problems/find-all-duplicates-in-an-array/README.md index b1068827c..9977ff59a 100644 --- a/problems/find-all-duplicates-in-an-array/README.md +++ b/problems/find-all-duplicates-in-an-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/arranging-coins "Arranging Coins") +[< Previous](../arranging-coins "Arranging Coins")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/string-compression "String Compression") +[Next >](../string-compression "String Compression") ## [442. Find All Duplicates in an Array (Medium)](https://leetcode.com/problems/find-all-duplicates-in-an-array "数组中重复的数据") @@ -27,7 +27,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Find All Numbers Disappeared in an Array](https://github.com/openset/leetcode/tree/master/problems/find-all-numbers-disappeared-in-an-array) (Easy) + 1. [Find All Numbers Disappeared in an Array](../find-all-numbers-disappeared-in-an-array) (Easy) diff --git a/problems/find-all-numbers-disappeared-in-an-array/README.md b/problems/find-all-numbers-disappeared-in-an-array/README.md index fc993b326..f1ce976b7 100644 --- a/problems/find-all-numbers-disappeared-in-an-array/README.md +++ b/problems/find-all-numbers-disappeared-in-an-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-boomerangs "Number of Boomerangs") +[< Previous](../number-of-boomerangs "Number of Boomerangs")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-bst "Serialize and Deserialize BST") +[Next >](../serialize-and-deserialize-bst "Serialize and Deserialize BST") ## [448. Find All Numbers Disappeared in an Array (Easy)](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array "找到所有数组中消失的数字") @@ -28,11 +28,11 @@

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [First Missing Positive](https://github.com/openset/leetcode/tree/master/problems/first-missing-positive) (Hard) - 1. [Find All Duplicates in an Array](https://github.com/openset/leetcode/tree/master/problems/find-all-duplicates-in-an-array) (Medium) + 1. [First Missing Positive](../first-missing-positive) (Hard) + 1. [Find All Duplicates in an Array](../find-all-duplicates-in-an-array) (Medium) ### Hints
diff --git a/problems/find-anagram-mappings/README.md b/problems/find-anagram-mappings/README.md index cf9da2489..c86ee417c 100644 --- a/problems/find-anagram-mappings/README.md +++ b/problems/find-anagram-mappings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/employee-free-time "Employee Free Time") +[< Previous](../employee-free-time "Employee Free Time")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/special-binary-string "Special Binary String") +[Next >](../special-binary-string "Special Binary String") ## [760. Find Anagram Mappings (Easy)](https://leetcode.com/problems/find-anagram-mappings "找出变位映射") @@ -41,7 +41,7 @@ and so on.

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
diff --git a/problems/find-and-replace-in-string/README.md b/problems/find-and-replace-in-string/README.md index 989beeab2..351f3f38d 100644 --- a/problems/find-and-replace-in-string/README.md +++ b/problems/find-and-replace-in-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/flipping-an-image "Flipping an Image") +[< Previous](../flipping-an-image "Flipping an Image")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sum-of-distances-in-tree "Sum of Distances in Tree") +[Next >](../sum-of-distances-in-tree "Sum of Distances in Tree") ## [833. Find And Replace in String (Medium)](https://leetcode.com/problems/find-and-replace-in-string "字符串中的查找与替换") @@ -50,4 +50,4 @@

 

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/find-and-replace-pattern/README.md b/problems/find-and-replace-pattern/README.md index c67de166b..3b4b4f1e6 100644 --- a/problems/find-and-replace-pattern/README.md +++ b/problems/find-and-replace-pattern/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-preorder-and-postorder-traversal "Construct Binary Tree from Preorder and Postorder Traversal") +[< Previous](../construct-binary-tree-from-preorder-and-postorder-traversal "Construct Binary Tree from Preorder and Postorder Traversal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sum-of-subsequence-widths "Sum of Subsequence Widths") +[Next >](../sum-of-subsequence-widths "Sum of Subsequence Widths") ## [890. Find and Replace Pattern (Medium)](https://leetcode.com/problems/find-and-replace-pattern "查找和替换模式") @@ -44,4 +44,4 @@ since a and b map to the same letter. ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/find-bottom-left-tree-value/README.md b/problems/find-bottom-left-tree-value/README.md index 811616711..fbca72dfd 100644 --- a/problems/find-bottom-left-tree-value/README.md +++ b/problems/find-bottom-left-tree-value/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-ii "Game Play Analysis II") +[< Previous](../game-play-analysis-ii "Game Play Analysis II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/freedom-trail "Freedom Trail") +[Next >](../freedom-trail "Freedom Trail") ## [513. Find Bottom Left Tree Value (Medium)](https://leetcode.com/problems/find-bottom-left-tree-value "找树左下角的值") @@ -50,6 +50,6 @@ You may assume the tree (i.e., the given root node) is not NULL.

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/find-common-characters/README.md b/problems/find-common-characters/README.md index 4da233435..6160447c6 100644 --- a/problems/find-common-characters/README.md +++ b/problems/find-common-characters/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/grid-illumination "Grid Illumination") +[< Previous](../grid-illumination "Grid Illumination")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/check-if-word-is-valid-after-substitutions "Check If Word Is Valid After Substitutions") +[Next >](../check-if-word-is-valid-after-substitutions "Check If Word Is Valid After Substitutions") ## [1002. Find Common Characters (Easy)](https://leetcode.com/problems/find-common-characters "查找常用字符") @@ -46,8 +46,8 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Intersection of Two Arrays II](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays-ii) (Easy) + 1. [Intersection of Two Arrays II](../intersection-of-two-arrays-ii) (Easy) diff --git a/problems/find-cumulative-salary-of-an-employee/README.md b/problems/find-cumulative-salary-of-an-employee/README.md index e2833723f..83a85c4ab 100644 --- a/problems/find-cumulative-salary-of-an-employee/README.md +++ b/problems/find-cumulative-salary-of-an-employee/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/get-highest-answer-rate-question "Get Highest Answer Rate Question") +[< Previous](../get-highest-answer-rate-question "Get Highest Answer Rate Question")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/count-student-number-in-departments "Count Student Number in Departments") +[Next >](../count-student-number-in-departments "Count Student Number in Departments") ## [579. Find Cumulative Salary of an Employee (Hard)](https://leetcode.com/problems/find-cumulative-salary-of-an-employee "查询员工的累计薪水") diff --git a/problems/find-customer-referee/README.md b/problems/find-customer-referee/README.md index 3c97763f6..5f0fe373a 100644 --- a/problems/find-customer-referee/README.md +++ b/problems/find-customer-referee/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/delete-operation-for-two-strings "Delete Operation for Two Strings") +[< Previous](../delete-operation-for-two-strings "Delete Operation for Two Strings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/investments-in-2016 "Investments in 2016") +[Next >](../investments-in-2016 "Investments in 2016") ## [584. Find Customer Referee (Easy)](https://leetcode.com/problems/find-customer-referee "寻找用户推荐人") diff --git a/problems/find-duplicate-file-in-system/README.md b/problems/find-duplicate-file-in-system/README.md index 0a3efdeb9..07fbeb275 100644 --- a/problems/find-duplicate-file-in-system/README.md +++ b/problems/find-duplicate-file-in-system/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/tree-node "Tree Node") +[< Previous](../tree-node "Tree Node")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/triangle-judgement "Triangle Judgement") +[Next >](../triangle-judgement "Triangle Judgement") ## [609. Find Duplicate File in System (Medium)](https://leetcode.com/problems/find-duplicate-file-in-system "在系统中查找重复文件") @@ -58,5 +58,5 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/find-duplicate-subtrees/README.md b/problems/find-duplicate-subtrees/README.md index f5fa2de52..649d1408c 100644 --- a/problems/find-duplicate-subtrees/README.md +++ b/problems/find-duplicate-subtrees/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/4-keys-keyboard "4 Keys Keyboard") +[< Previous](../4-keys-keyboard "4 Keys Keyboard")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/two-sum-iv-input-is-a-bst "Two Sum IV - Input is a BST") +[Next >](../two-sum-iv-input-is-a-bst "Two Sum IV - Input is a BST") ## [652. Find Duplicate Subtrees (Medium)](https://leetcode.com/problems/find-duplicate-subtrees "寻找重复的子树") @@ -43,9 +43,9 @@ Therefore, you need to return above trees' root in the form of a list. ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Serialize and Deserialize Binary Tree](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-binary-tree) (Hard) - 1. [Serialize and Deserialize BST](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-bst) (Medium) - 1. [Construct String from Binary Tree](https://github.com/openset/leetcode/tree/master/problems/construct-string-from-binary-tree) (Easy) + 1. [Serialize and Deserialize Binary Tree](../serialize-and-deserialize-binary-tree) (Hard) + 1. [Serialize and Deserialize BST](../serialize-and-deserialize-bst) (Medium) + 1. [Construct String from Binary Tree](../construct-string-from-binary-tree) (Easy) diff --git a/problems/find-elements-in-a-contaminated-binary-tree/README.md b/problems/find-elements-in-a-contaminated-binary-tree/README.md index b179e8dc6..a3a516d28 100644 --- a/problems/find-elements-in-a-contaminated-binary-tree/README.md +++ b/problems/find-elements-in-a-contaminated-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shift-2d-grid "Shift 2D Grid") +[< Previous](../shift-2d-grid "Shift 2D Grid")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/greatest-sum-divisible-by-three "Greatest Sum Divisible by Three") +[Next >](../greatest-sum-divisible-by-three "Greatest Sum Divisible by Three") ## [1261. Find Elements in a Contaminated Binary Tree (Medium)](https://leetcode.com/problems/find-elements-in-a-contaminated-binary-tree "在受污染的二叉树中查找元素") @@ -90,8 +90,8 @@ findElements.find(5); // return True ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
diff --git a/problems/find-eventual-safe-states/README.md b/problems/find-eventual-safe-states/README.md index 6a01cb5dc..86188cf43 100644 --- a/problems/find-eventual-safe-states/README.md +++ b/problems/find-eventual-safe-states/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-swaps-to-make-sequences-increasing "Minimum Swaps To Make Sequences Increasing") +[< Previous](../minimum-swaps-to-make-sequences-increasing "Minimum Swaps To Make Sequences Increasing")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/bricks-falling-when-hit "Bricks Falling When Hit") +[Next >](../bricks-falling-when-hit "Bricks Falling When Hit") ## [802. Find Eventual Safe States (Medium)](https://leetcode.com/problems/find-eventual-safe-states "找到最终的安全状态") @@ -38,5 +38,5 @@ Here is a diagram of the above graph. ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] diff --git a/problems/find-first-and-last-position-of-element-in-sorted-array/README.md b/problems/find-first-and-last-position-of-element-in-sorted-array/README.md index cd6946bc6..0ea7457d6 100644 --- a/problems/find-first-and-last-position-of-element-in-sorted-array/README.md +++ b/problems/find-first-and-last-position-of-element-in-sorted-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/search-in-rotated-sorted-array "Search in Rotated Sorted Array") +[< Previous](../search-in-rotated-sorted-array "Search in Rotated Sorted Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/search-insert-position "Search Insert Position") +[Next >](../search-insert-position "Search Insert Position") ## [34. Find First and Last Position of Element in Sorted Array (Medium)](https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array "在排序数组中查找元素的第一个和最后一个位置") @@ -30,8 +30,8 @@ Output: [-1,-1] ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [First Bad Version](https://github.com/openset/leetcode/tree/master/problems/first-bad-version) (Easy) + 1. [First Bad Version](../first-bad-version) (Easy) diff --git a/problems/find-in-mountain-array/README.md b/problems/find-in-mountain-array/README.md index e1953c42a..beb2a9ff2 100644 --- a/problems/find-in-mountain-array/README.md +++ b/problems/find-in-mountain-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/car-pooling "Car Pooling") +[< Previous](../car-pooling "Car Pooling")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/brace-expansion-ii "Brace Expansion II") +[Next >](../brace-expansion-ii "Brace Expansion II") ## [1095. Find in Mountain Array (Hard)](https://leetcode.com/problems/find-in-mountain-array "山脉数组中查找目标值") @@ -65,7 +65,7 @@ ### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
diff --git a/problems/find-k-closest-elements/README.md b/problems/find-k-closest-elements/README.md index 994312f97..0849ebd14 100644 --- a/problems/find-k-closest-elements/README.md +++ b/problems/find-k-closest-elements/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/robot-return-to-origin "Robot Return to Origin") +[< Previous](../robot-return-to-origin "Robot Return to Origin")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/split-array-into-consecutive-subsequences "Split Array into Consecutive Subsequences") +[Next >](../split-array-into-consecutive-subsequences "Split Array into Consecutive Subsequences") ## [658. Find K Closest Elements (Medium)](https://leetcode.com/problems/find-k-closest-elements "找到 K 个最接近的元素") @@ -47,9 +47,9 @@ The arr parameter had been changed to an array of integers (instea

### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Guess Number Higher or Lower](https://github.com/openset/leetcode/tree/master/problems/guess-number-higher-or-lower) (Easy) - 1. [Guess Number Higher or Lower II](https://github.com/openset/leetcode/tree/master/problems/guess-number-higher-or-lower-ii) (Medium) - 1. [Find K-th Smallest Pair Distance](https://github.com/openset/leetcode/tree/master/problems/find-k-th-smallest-pair-distance) (Hard) + 1. [Guess Number Higher or Lower](../guess-number-higher-or-lower) (Easy) + 1. [Guess Number Higher or Lower II](../guess-number-higher-or-lower-ii) (Medium) + 1. [Find K-th Smallest Pair Distance](../find-k-th-smallest-pair-distance) (Hard) diff --git a/problems/find-k-length-substrings-with-no-repeated-characters/README.md b/problems/find-k-length-substrings-with-no-repeated-characters/README.md index e9bb44c68..effcba5f7 100644 --- a/problems/find-k-length-substrings-with-no-repeated-characters/README.md +++ b/problems/find-k-length-substrings-with-no-repeated-characters/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/two-sum-less-than-k "Two Sum Less Than K") +[< Previous](../two-sum-less-than-k "Two Sum Less Than K")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/the-earliest-moment-when-everyone-become-friends "The Earliest Moment When Everyone Become Friends") +[Next >](../the-earliest-moment-when-everyone-become-friends "The Earliest Moment When Everyone Become Friends") ## [1100. Find K-Length Substrings With No Repeated Characters (Medium)](https://leetcode.com/problems/find-k-length-substrings-with-no-repeated-characters "长度为 K 的无重复字符子串") @@ -44,8 +44,8 @@ Notice K can be larger than the length of S. In this case is not possible to fin ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
diff --git a/problems/find-k-pairs-with-smallest-sums/README.md b/problems/find-k-pairs-with-smallest-sums/README.md index 07c6b6f11..df71879f7 100644 --- a/problems/find-k-pairs-with-smallest-sums/README.md +++ b/problems/find-k-pairs-with-smallest-sums/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/super-pow "Super Pow") +[< Previous](../super-pow "Super Pow")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/guess-number-higher-or-lower "Guess Number Higher or Lower") +[Next >](../guess-number-higher-or-lower "Guess Number Higher or Lower") ## [373. Find K Pairs with Smallest Sums (Medium)](https://leetcode.com/problems/find-k-pairs-with-smallest-sums "查找和最小的K对数字") @@ -42,8 +42,8 @@ ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] + [[Heap](../../tag/heap/README.md)] ### Similar Questions - 1. [Kth Smallest Element in a Sorted Matrix](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-element-in-a-sorted-matrix) (Medium) - 1. [Find K-th Smallest Pair Distance](https://github.com/openset/leetcode/tree/master/problems/find-k-th-smallest-pair-distance) (Hard) + 1. [Kth Smallest Element in a Sorted Matrix](../kth-smallest-element-in-a-sorted-matrix) (Medium) + 1. [Find K-th Smallest Pair Distance](../find-k-th-smallest-pair-distance) (Hard) diff --git a/problems/find-k-th-smallest-pair-distance/README.md b/problems/find-k-th-smallest-pair-distance/README.md index 7a8e6bd1d..b977ec166 100644 --- a/problems/find-k-th-smallest-pair-distance/README.md +++ b/problems/find-k-th-smallest-pair-distance/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-repeated-subarray "Maximum Length of Repeated Subarray") +[< Previous](../maximum-length-of-repeated-subarray "Maximum Length of Repeated Subarray")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-word-in-dictionary "Longest Word in Dictionary") +[Next >](../longest-word-in-dictionary "Longest Word in Dictionary") ## [719. Find K-th Smallest Pair Distance (Hard)](https://leetcode.com/problems/find-k-th-smallest-pair-distance "找出第 k 小的距离对") @@ -37,16 +37,16 @@ Then the 1st smallest distance pair is (1,1), and its distance is 0.

### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Find K Pairs with Smallest Sums](https://github.com/openset/leetcode/tree/master/problems/find-k-pairs-with-smallest-sums) (Medium) - 1. [Kth Smallest Element in a Sorted Matrix](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-element-in-a-sorted-matrix) (Medium) - 1. [Find K Closest Elements](https://github.com/openset/leetcode/tree/master/problems/find-k-closest-elements) (Medium) - 1. [Kth Smallest Number in Multiplication Table](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-number-in-multiplication-table) (Hard) - 1. [K-th Smallest Prime Fraction](https://github.com/openset/leetcode/tree/master/problems/k-th-smallest-prime-fraction) (Hard) + 1. [Find K Pairs with Smallest Sums](../find-k-pairs-with-smallest-sums) (Medium) + 1. [Kth Smallest Element in a Sorted Matrix](../kth-smallest-element-in-a-sorted-matrix) (Medium) + 1. [Find K Closest Elements](../find-k-closest-elements) (Medium) + 1. [Kth Smallest Number in Multiplication Table](../kth-smallest-number-in-multiplication-table) (Hard) + 1. [K-th Smallest Prime Fraction](../k-th-smallest-prime-fraction) (Hard) ### Hints
diff --git a/problems/find-largest-value-in-each-tree-row/README.md b/problems/find-largest-value-in-each-tree-row/README.md index de0ee2a27..e5c655338 100644 --- a/problems/find-largest-value-in-each-tree-row/README.md +++ b/problems/find-largest-value-in-each-tree-row/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/freedom-trail "Freedom Trail") +[< Previous](../freedom-trail "Freedom Trail")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-palindromic-subsequence "Longest Palindromic Subsequence") +[Next >](../longest-palindromic-subsequence "Longest Palindromic Subsequence") ## [515. Find Largest Value in Each Tree Row (Medium)](https://leetcode.com/problems/find-largest-value-in-each-tree-row "在每个树行中找最大值") @@ -28,6 +28,6 @@

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/find-leaves-of-binary-tree/README.md b/problems/find-leaves-of-binary-tree/README.md index cc7f1edc9..6c0bda5a5 100644 --- a/problems/find-leaves-of-binary-tree/README.md +++ b/problems/find-leaves-of-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/water-and-jug-problem "Water and Jug Problem") +[< Previous](../water-and-jug-problem "Water and Jug Problem")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-perfect-square "Valid Perfect Square") +[Next >](../valid-perfect-square "Valid Perfect Square") ## [366. Find Leaves of Binary Tree (Medium)](https://leetcode.com/problems/find-leaves-of-binary-tree "寻找完全二叉树的叶子节点") @@ -58,5 +58,5 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/find-median-from-data-stream/README.md b/problems/find-median-from-data-stream/README.md index dc926a24e..3416a3a92 100644 --- a/problems/find-median-from-data-stream/README.md +++ b/problems/find-median-from-data-stream/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/flip-game-ii "Flip Game II") +[< Previous](../flip-game-ii "Flip Game II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/best-meeting-point "Best Meeting Point") +[Next >](../best-meeting-point "Best Meeting Point") ## [295. Find Median from Data Stream (Hard)](https://leetcode.com/problems/find-median-from-data-stream "数据流的中位数") @@ -47,8 +47,8 @@ findMedian() -> 2 ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions - 1. [Sliding Window Median](https://github.com/openset/leetcode/tree/master/problems/sliding-window-median) (Hard) + 1. [Sliding Window Median](../sliding-window-median) (Hard) diff --git a/problems/find-median-given-frequency-of-numbers/README.md b/problems/find-median-given-frequency-of-numbers/README.md index bf32d16bb..85b17693e 100644 --- a/problems/find-median-given-frequency-of-numbers/README.md +++ b/problems/find-median-given-frequency-of-numbers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/managers-with-at-least-5-direct-reports "Managers with at Least 5 Direct Reports") +[< Previous](../managers-with-at-least-5-direct-reports "Managers with at Least 5 Direct Reports")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/subtree-of-another-tree "Subtree of Another Tree") +[Next >](../subtree-of-another-tree "Subtree of Another Tree") ## [571. Find Median Given Frequency of Numbers (Hard)](https://leetcode.com/problems/find-median-given-frequency-of-numbers "给定数字的频率查询中位数") @@ -37,4 +37,4 @@

Write a query to find the median of all numbers and name the result as median.

### Similar Questions - 1. [Median Employee Salary](https://github.com/openset/leetcode/tree/master/problems/median-employee-salary) (Hard) + 1. [Median Employee Salary](../median-employee-salary) (Hard) diff --git a/problems/find-minimum-in-rotated-sorted-array-ii/README.md b/problems/find-minimum-in-rotated-sorted-array-ii/README.md index c1b778710..322b4d2d7 100644 --- a/problems/find-minimum-in-rotated-sorted-array-ii/README.md +++ b/problems/find-minimum-in-rotated-sorted-array-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-minimum-in-rotated-sorted-array "Find Minimum in Rotated Sorted Array") +[< Previous](../find-minimum-in-rotated-sorted-array "Find Minimum in Rotated Sorted Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/min-stack "Min Stack") +[Next >](../min-stack "Min Stack") ## [154. Find Minimum in Rotated Sorted Array II (Hard)](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii "寻找旋转排序数组中的最小值 II") @@ -39,8 +39,8 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Find Minimum in Rotated Sorted Array](https://github.com/openset/leetcode/tree/master/problems/find-minimum-in-rotated-sorted-array) (Medium) + 1. [Find Minimum in Rotated Sorted Array](../find-minimum-in-rotated-sorted-array) (Medium) diff --git a/problems/find-minimum-in-rotated-sorted-array/README.md b/problems/find-minimum-in-rotated-sorted-array/README.md index 462253a0d..eccb58740 100644 --- a/problems/find-minimum-in-rotated-sorted-array/README.md +++ b/problems/find-minimum-in-rotated-sorted-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-product-subarray "Maximum Product Subarray") +[< Previous](../maximum-product-subarray "Maximum Product Subarray")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-minimum-in-rotated-sorted-array-ii "Find Minimum in Rotated Sorted Array II") +[Next >](../find-minimum-in-rotated-sorted-array-ii "Find Minimum in Rotated Sorted Array II") ## [153. Find Minimum in Rotated Sorted Array (Medium)](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array "寻找旋转排序数组中的最小值") @@ -34,12 +34,12 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Search in Rotated Sorted Array](https://github.com/openset/leetcode/tree/master/problems/search-in-rotated-sorted-array) (Medium) - 1. [Find Minimum in Rotated Sorted Array II](https://github.com/openset/leetcode/tree/master/problems/find-minimum-in-rotated-sorted-array-ii) (Hard) + 1. [Search in Rotated Sorted Array](../search-in-rotated-sorted-array) (Medium) + 1. [Find Minimum in Rotated Sorted Array II](../find-minimum-in-rotated-sorted-array-ii) (Hard) ### Hints
diff --git a/problems/find-mode-in-binary-search-tree/README.md b/problems/find-mode-in-binary-search-tree/README.md index a93834723..3c86f61c1 100644 --- a/problems/find-mode-in-binary-search-tree/README.md +++ b/problems/find-mode-in-binary-search-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/keyboard-row "Keyboard Row") +[< Previous](../keyboard-row "Keyboard Row")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/ipo "IPO") +[Next >](../ipo "IPO") ## [501. Find Mode in Binary Search Tree (Easy)](https://leetcode.com/problems/find-mode-in-binary-search-tree "二叉搜索树中的众数") @@ -43,7 +43,7 @@ Given BST [1,null,2,2],

Follow up: Could you do that without using any extra space? (Assume that the implicit stack space incurred due to recursion does not count).

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Validate Binary Search Tree](https://github.com/openset/leetcode/tree/master/problems/validate-binary-search-tree) (Medium) + 1. [Validate Binary Search Tree](../validate-binary-search-tree) (Medium) diff --git a/problems/find-peak-element/README.md b/problems/find-peak-element/README.md index 3f853163e..92bf14323 100644 --- a/problems/find-peak-element/README.md +++ b/problems/find-peak-element/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/one-edit-distance "One Edit Distance") +[< Previous](../one-edit-distance "One Edit Distance")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/missing-ranges "Missing Ranges") +[Next >](../missing-ranges "Missing Ranges") ## [162. Find Peak Element (Medium)](https://leetcode.com/problems/find-peak-element "寻找峰值") @@ -40,8 +40,8 @@

Your solution should be in logarithmic complexity.

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Peak Index in a Mountain Array](https://github.com/openset/leetcode/tree/master/problems/peak-index-in-a-mountain-array) (Easy) + 1. [Peak Index in a Mountain Array](../peak-index-in-a-mountain-array) (Easy) diff --git a/problems/find-permutation/README.md b/problems/find-permutation/README.md index 6b22df79e..bfa918ff8 100644 --- a/problems/find-permutation/README.md +++ b/problems/find-permutation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/smallest-good-base "Smallest Good Base") +[< Previous](../smallest-good-base "Smallest Good Base")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones "Max Consecutive Ones") +[Next >](../max-consecutive-ones "Max Consecutive Ones") ## [484. Find Permutation (Medium)](https://leetcode.com/problems/find-permutation "寻找排列") @@ -39,4 +39,4 @@ On the other hand, now your job is to find the lexicographically smallest permut

### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/find-pivot-index/README.md b/problems/find-pivot-index/README.md index 29ffd6664..7e653f866 100644 --- a/problems/find-pivot-index/README.md +++ b/problems/find-pivot-index/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/candy-crush "Candy Crush") +[< Previous](../candy-crush "Candy Crush")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/split-linked-list-in-parts "Split Linked List in Parts") +[Next >](../split-linked-list-in-parts "Split Linked List in Parts") ## [724. Find Pivot Index (Easy)](https://leetcode.com/problems/find-pivot-index "寻找数组的中心索引") @@ -52,10 +52,10 @@ There is no index that satisfies the conditions in the problem statement.

 

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Subarray Sum Equals K](https://github.com/openset/leetcode/tree/master/problems/subarray-sum-equals-k) (Medium) + 1. [Subarray Sum Equals K](../subarray-sum-equals-k) (Medium) ### Hints
diff --git a/problems/find-positive-integer-solution-for-a-given-equation/README.md b/problems/find-positive-integer-solution-for-a-given-equation/README.md index 5301d7de2..f70520803 100644 --- a/problems/find-positive-integer-solution-for-a-given-equation/README.md +++ b/problems/find-positive-integer-solution-for-a-given-equation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/web-crawler "Web Crawler") +[< Previous](../web-crawler "Web Crawler")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/circular-permutation-in-binary-representation "Circular Permutation in Binary Representation") +[Next >](../circular-permutation-in-binary-representation "Circular Permutation in Binary Representation") ## [1237. Find Positive Integer Solution for a Given Equation (Easy)](https://leetcode.com/problems/find-positive-integer-solution-for-a-given-equation "找出给定方程的正整数解") @@ -61,8 +61,8 @@ public: ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
diff --git a/problems/find-right-interval/README.md b/problems/find-right-interval/README.md index 52dc003d4..b49f70ba0 100644 --- a/problems/find-right-interval/README.md +++ b/problems/find-right-interval/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/non-overlapping-intervals "Non-overlapping Intervals") +[< Previous](../non-overlapping-intervals "Non-overlapping Intervals")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/path-sum-iii "Path Sum III") +[Next >](../path-sum-iii "Path Sum III") ## [436. Find Right Interval (Medium)](https://leetcode.com/problems/find-right-interval "寻找右区间") @@ -64,7 +64,7 @@ For [2,3], the interval [3,4] has minimum-"right" start point.

NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Data Stream as Disjoint Intervals](https://github.com/openset/leetcode/tree/master/problems/data-stream-as-disjoint-intervals) (Hard) + 1. [Data Stream as Disjoint Intervals](../data-stream-as-disjoint-intervals) (Hard) diff --git a/problems/find-smallest-common-element-in-all-rows/README.md b/problems/find-smallest-common-element-in-all-rows/README.md index ad9428e26..8bf0613d1 100644 --- a/problems/find-smallest-common-element-in-all-rows/README.md +++ b/problems/find-smallest-common-element-in-all-rows/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-knight-moves "Minimum Knight Moves") +[< Previous](../minimum-knight-moves "Minimum Knight Moves")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-time-to-build-blocks "Minimum Time to Build Blocks") +[Next >](../minimum-time-to-build-blocks "Minimum Time to Build Blocks") ## [1198. Find Smallest Common Element in All Rows (Medium)](https://leetcode.com/problems/find-smallest-common-element-in-all-rows "找出所有行中最小公共元素") @@ -31,8 +31,8 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
diff --git a/problems/find-smallest-letter-greater-than-target/README.md b/problems/find-smallest-letter-greater-than-target/README.md index 0de26a3ff..c308f8ce4 100644 --- a/problems/find-smallest-letter-greater-than-target/README.md +++ b/problems/find-smallest-letter-greater-than-target/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/network-delay-time "Network Delay Time") +[< Previous](../network-delay-time "Network Delay Time")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/prefix-and-suffix-search "Prefix and Suffix Search") +[Next >](../prefix-and-suffix-search "Prefix and Suffix Search") ## [744. Find Smallest Letter Greater Than Target (Easy)](https://leetcode.com/problems/find-smallest-letter-greater-than-target "寻找比目标字母大的最小字母") @@ -60,7 +60,7 @@ target = "k"

### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
diff --git a/problems/find-the-celebrity/README.md b/problems/find-the-celebrity/README.md index 95cd019c0..1cf1be1e1 100644 --- a/problems/find-the-celebrity/README.md +++ b/problems/find-the-celebrity/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/paint-fence "Paint Fence") +[< Previous](../paint-fence "Paint Fence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/first-bad-version "First Bad Version") +[Next >](../first-bad-version "First Bad Version") ## [277. Find the Celebrity (Medium)](https://leetcode.com/problems/find-the-celebrity "搜寻名人") @@ -53,10 +53,10 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Find the Town Judge](https://github.com/openset/leetcode/tree/master/problems/find-the-town-judge) (Easy) + 1. [Find the Town Judge](../find-the-town-judge) (Easy) ### Hints
diff --git a/problems/find-the-closest-palindrome/README.md b/problems/find-the-closest-palindrome/README.md index 7e935cd5f..8a6121526 100644 --- a/problems/find-the-closest-palindrome/README.md +++ b/problems/find-the-closest-palindrome/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-tree-tilt "Binary Tree Tilt") +[< Previous](../binary-tree-tilt "Binary Tree Tilt")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/array-nesting "Array Nesting") +[Next >](../array-nesting "Array Nesting") ## [564. Find the Closest Palindrome (Hard)](https://leetcode.com/problems/find-the-closest-palindrome "寻找最近的回文数") @@ -30,7 +30,7 @@

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/find-the-derangement-of-an-array/README.md b/problems/find-the-derangement-of-an-array/README.md index 75d4f16ed..4274d7cf9 100644 --- a/problems/find-the-derangement-of-an-array/README.md +++ b/problems/find-the-derangement-of-an-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sum-of-square-numbers "Sum of Square Numbers") +[< Previous](../sum-of-square-numbers "Sum of Square Numbers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-log-storage-system "Design Log Storage System") +[Next >](../design-log-storage-system "Design Log Storage System") ## [634. Find the Derangement of An Array (Medium)](https://leetcode.com/problems/find-the-derangement-of-an-array "寻找数组的错位排列") @@ -36,4 +36,4 @@ Also, since the answer may be very large, you should return the output mod 10 ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/find-the-difference/README.md b/problems/find-the-difference/README.md index 4acc0919f..4382ca887 100644 --- a/problems/find-the-difference/README.md +++ b/problems/find-the-difference/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-absolute-file-path "Longest Absolute File Path") +[< Previous](../longest-absolute-file-path "Longest Absolute File Path")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/elimination-game "Elimination Game") +[Next >](../elimination-game "Elimination Game") ## [389. Find the Difference (Easy)](https://leetcode.com/problems/find-the-difference "找不同") @@ -32,8 +32,8 @@ Explanation: ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Single Number](https://github.com/openset/leetcode/tree/master/problems/single-number) (Easy) + 1. [Single Number](../single-number) (Easy) diff --git a/problems/find-the-duplicate-number/README.md b/problems/find-the-duplicate-number/README.md index df3d0d69e..5ea4dd5c1 100644 --- a/problems/find-the-duplicate-number/README.md +++ b/problems/find-the-duplicate-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/walls-and-gates "Walls and Gates") +[< Previous](../walls-and-gates "Walls and Gates")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/unique-word-abbreviation "Unique Word Abbreviation") +[Next >](../unique-word-abbreviation "Unique Word Abbreviation") ## [287. Find the Duplicate Number (Medium)](https://leetcode.com/problems/find-the-duplicate-number "寻找重复数") @@ -36,13 +36,13 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [First Missing Positive](https://github.com/openset/leetcode/tree/master/problems/first-missing-positive) (Hard) - 1. [Single Number](https://github.com/openset/leetcode/tree/master/problems/single-number) (Easy) - 1. [Linked List Cycle II](https://github.com/openset/leetcode/tree/master/problems/linked-list-cycle-ii) (Medium) - 1. [Missing Number](https://github.com/openset/leetcode/tree/master/problems/missing-number) (Easy) - 1. [Set Mismatch](https://github.com/openset/leetcode/tree/master/problems/set-mismatch) (Easy) + 1. [First Missing Positive](../first-missing-positive) (Hard) + 1. [Single Number](../single-number) (Easy) + 1. [Linked List Cycle II](../linked-list-cycle-ii) (Medium) + 1. [Missing Number](../missing-number) (Easy) + 1. [Set Mismatch](../set-mismatch) (Easy) diff --git a/problems/find-the-shortest-superstring/README.md b/problems/find-the-shortest-superstring/README.md index aa5436013..b10ab5c72 100644 --- a/problems/find-the-shortest-superstring/README.md +++ b/problems/find-the-shortest-superstring/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/di-string-match "DI String Match") +[< Previous](../di-string-match "DI String Match")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/delete-columns-to-make-sorted "Delete Columns to Make Sorted") +[Next >](../delete-columns-to-make-sorted "Delete Columns to Make Sorted") ## [943. Find the Shortest Superstring (Hard)](https://leetcode.com/problems/find-the-shortest-superstring "最短超级串") @@ -49,4 +49,4 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/find-the-smallest-divisor-given-a-threshold/README.md b/problems/find-the-smallest-divisor-given-a-threshold/README.md index af86b2db7..2dec8542a 100644 --- a/problems/find-the-smallest-divisor-given-a-threshold/README.md +++ b/problems/find-the-smallest-divisor-given-a-threshold/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/group-the-people-given-the-group-size-they-belong-to "Group the People Given the Group Size They Belong To") +[< Previous](../group-the-people-given-the-group-size-they-belong-to "Group the People Given the Group Size They Belong To")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix "Minimum Number of Flips to Convert Binary Matrix to Zero Matrix") +[Next >](../minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix "Minimum Number of Flips to Convert Binary Matrix to Zero Matrix") ## [1283. Find the Smallest Divisor Given a Threshold (Medium)](https://leetcode.com/problems/find-the-smallest-divisor-given-a-threshold "使结果不超过阈值的最小除数") @@ -51,7 +51,7 @@ If the divisor is 4 we can get a sum to 7 (1+1+2+3) and if the divisor is 5 the ### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
diff --git a/problems/find-the-start-and-end-number-of-continuous-ranges/README.md b/problems/find-the-start-and-end-number-of-continuous-ranges/README.md index 5cc40e68f..cdc2150a3 100644 --- a/problems/find-the-start-and-end-number-of-continuous-ranges/README.md +++ b/problems/find-the-start-and-end-number-of-continuous-ranges/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix "Minimum Number of Flips to Convert Binary Matrix to Zero Matrix") +[< Previous](../minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix "Minimum Number of Flips to Convert Binary Matrix to Zero Matrix")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/iterator-for-combination "Iterator for Combination") +[Next >](../iterator-for-combination "Iterator for Combination") ## [1285. Find the Start and End Number of Continuous Ranges (Medium)](https://leetcode.com/problems/find-the-start-and-end-number-of-continuous-ranges "") diff --git a/problems/find-the-town-judge/README.md b/problems/find-the-town-judge/README.md index b4d33bf73..89542cda9 100644 --- a/problems/find-the-town-judge/README.md +++ b/problems/find-the-town-judge/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-squareful-arrays "Number of Squareful Arrays") +[< Previous](../number-of-squareful-arrays "Number of Squareful Arrays")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-binary-tree-ii "Maximum Binary Tree II") +[Next >](../maximum-binary-tree-ii "Maximum Binary Tree II") ## [997. Find the Town Judge (Easy)](https://leetcode.com/problems/find-the-town-judge "找到小镇的法官") @@ -82,7 +82,7 @@ ### Related Topics - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Graph](../../tag/graph/README.md)] ### Similar Questions - 1. [Find the Celebrity](https://github.com/openset/leetcode/tree/master/problems/find-the-celebrity) (Medium) + 1. [Find the Celebrity](../find-the-celebrity) (Medium) diff --git a/problems/find-winner-on-a-tic-tac-toe-game/README.md b/problems/find-winner-on-a-tic-tac-toe-game/README.md index 6779753e8..25d232e87 100644 --- a/problems/find-winner-on-a-tic-tac-toe-game/README.md +++ b/problems/find-winner-on-a-tic-tac-toe-game/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-ships-in-a-rectangle "Number of Ships in a Rectangle") +[< Previous](../number-of-ships-in-a-rectangle "Number of Ships in a Rectangle")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-burgers-with-no-waste-of-ingredients "Number of Burgers with No Waste of Ingredients") +[Next >](../number-of-burgers-with-no-waste-of-ingredients "Number of Burgers with No Waste of Ingredients") ## [1275. Find Winner on a Tic Tac Toe Game (Easy)](https://leetcode.com/problems/find-winner-on-a-tic-tac-toe-game "找出井字棋的获胜者") @@ -87,7 +87,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/find-words-that-can-be-formed-by-characters/README.md b/problems/find-words-that-can-be-formed-by-characters/README.md index 4099acf07..331d274a2 100644 --- a/problems/find-words-that-can-be-formed-by-characters/README.md +++ b/problems/find-words-that-can-be-formed-by-characters/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/market-analysis-ii "Market Analysis II") +[< Previous](../market-analysis-ii "Market Analysis II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-level-sum-of-a-binary-tree "Maximum Level Sum of a Binary Tree") +[Next >](../maximum-level-sum-of-a-binary-tree "Maximum Level Sum of a Binary Tree") ## [1160. Find Words That Can Be Formed by Characters (Easy)](https://leetcode.com/problems/find-words-that-can-be-formed-by-characters "拼写单词") @@ -48,8 +48,8 @@ The strings that can be formed are "hello" and "world" so th ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
diff --git a/problems/first-bad-version/README.md b/problems/first-bad-version/README.md index a276cc7ca..00755c011 100644 --- a/problems/first-bad-version/README.md +++ b/problems/first-bad-version/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-the-celebrity "Find the Celebrity") +[< Previous](../find-the-celebrity "Find the Celebrity")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/perfect-squares "Perfect Squares") +[Next >](../perfect-squares "Perfect Squares") ## [278. First Bad Version (Easy)](https://leetcode.com/problems/first-bad-version "第一个错误的版本") @@ -30,9 +30,9 @@ Then 4 is the first bad version.  ### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Find First and Last Position of Element in Sorted Array](https://github.com/openset/leetcode/tree/master/problems/find-first-and-last-position-of-element-in-sorted-array) (Medium) - 1. [Search Insert Position](https://github.com/openset/leetcode/tree/master/problems/search-insert-position) (Easy) - 1. [Guess Number Higher or Lower](https://github.com/openset/leetcode/tree/master/problems/guess-number-higher-or-lower) (Easy) + 1. [Find First and Last Position of Element in Sorted Array](../find-first-and-last-position-of-element-in-sorted-array) (Medium) + 1. [Search Insert Position](../search-insert-position) (Easy) + 1. [Guess Number Higher or Lower](../guess-number-higher-or-lower) (Easy) diff --git a/problems/first-missing-positive/README.md b/problems/first-missing-positive/README.md index 6a2455ba1..923cce8fa 100644 --- a/problems/first-missing-positive/README.md +++ b/problems/first-missing-positive/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/combination-sum-ii "Combination Sum II") +[< Previous](../combination-sum-ii "Combination Sum II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/trapping-rain-water "Trapping Rain Water") +[Next >](../trapping-rain-water "Trapping Rain Water") ## [41. First Missing Positive (Hard)](https://leetcode.com/problems/first-missing-positive "缺失的第一个正数") @@ -39,13 +39,13 @@ Output: 1

Your algorithm should run in O(n) time and uses constant extra space.

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Missing Number](https://github.com/openset/leetcode/tree/master/problems/missing-number) (Easy) - 1. [Find the Duplicate Number](https://github.com/openset/leetcode/tree/master/problems/find-the-duplicate-number) (Medium) - 1. [Find All Numbers Disappeared in an Array](https://github.com/openset/leetcode/tree/master/problems/find-all-numbers-disappeared-in-an-array) (Easy) - 1. [Couples Holding Hands](https://github.com/openset/leetcode/tree/master/problems/couples-holding-hands) (Hard) + 1. [Missing Number](../missing-number) (Easy) + 1. [Find the Duplicate Number](../find-the-duplicate-number) (Medium) + 1. [Find All Numbers Disappeared in an Array](../find-all-numbers-disappeared-in-an-array) (Easy) + 1. [Couples Holding Hands](../couples-holding-hands) (Hard) ### Hints
diff --git a/problems/first-unique-character-in-a-string/README.md b/problems/first-unique-character-in-a-string/README.md index 8653cc639..0256e95bc 100644 --- a/problems/first-unique-character-in-a-string/README.md +++ b/problems/first-unique-character-in-a-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/lexicographical-numbers "Lexicographical Numbers") +[< Previous](../lexicographical-numbers "Lexicographical Numbers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-absolute-file-path "Longest Absolute File Path") +[Next >](../longest-absolute-file-path "Longest Absolute File Path") ## [387. First Unique Character in a String (Easy)](https://leetcode.com/problems/first-unique-character-in-a-string "字符串中的第一个唯一字符") @@ -29,8 +29,8 @@ return 2.

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Sort Characters By Frequency](https://github.com/openset/leetcode/tree/master/problems/sort-characters-by-frequency) (Medium) + 1. [Sort Characters By Frequency](../sort-characters-by-frequency) (Medium) diff --git a/problems/fixed-point/README.md b/problems/fixed-point/README.md index 41d948be5..d3983ae1a 100644 --- a/problems/fixed-point/README.md +++ b/problems/fixed-point/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-valid-subarrays "Number of Valid Subarrays") +[< Previous](../number-of-valid-subarrays "Number of Valid Subarrays")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/index-pairs-of-a-string "Index Pairs of a String") +[Next >](../index-pairs-of-a-string "Index Pairs of a String") ## [1064. Fixed Point (Easy)](https://leetcode.com/problems/fixed-point "不动点") @@ -52,8 +52,8 @@ There is no such i that A[i] = i, thus the output is - ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
diff --git a/problems/fizz-buzz-multithreaded/README.md b/problems/fizz-buzz-multithreaded/README.md index f5a3f3eb7..0f3ef15ab 100644 --- a/problems/fizz-buzz-multithreaded/README.md +++ b/problems/fizz-buzz-multithreaded/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/tournament-winners "Tournament Winners") +[< Previous](../tournament-winners "Tournament Winners")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/how-many-apples-can-you-put-into-the-basket "How Many Apples Can You Put into the Basket") +[Next >](../how-many-apples-can-you-put-into-the-basket "How Many Apples Can You Put into the Basket") ## [1195. Fizz Buzz Multithreaded (Medium)](https://leetcode.com/problems/fizz-buzz-multithreaded "交替打印字符串") diff --git a/problems/fizz-buzz/README.md b/problems/fizz-buzz/README.md index d6844e7d2..cae237242 100644 --- a/problems/fizz-buzz/README.md +++ b/problems/fizz-buzz/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-unique-word-abbreviation "Minimum Unique Word Abbreviation") +[< Previous](../minimum-unique-word-abbreviation "Minimum Unique Word Abbreviation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/arithmetic-slices "Arithmetic Slices") +[Next >](../arithmetic-slices "Arithmetic Slices") ## [412. Fizz Buzz (Easy)](https://leetcode.com/problems/fizz-buzz "Fizz Buzz") diff --git a/problems/flatten-2d-vector/README.md b/problems/flatten-2d-vector/README.md index 4d0935174..7a8917757 100644 --- a/problems/flatten-2d-vector/README.md +++ b/problems/flatten-2d-vector/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/count-univalue-subtrees "Count Univalue Subtrees") +[< Previous](../count-univalue-subtrees "Count Univalue Subtrees")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/meeting-rooms "Meeting Rooms") +[Next >](../meeting-rooms "Meeting Rooms") ## [251. Flatten 2D Vector (Medium)](https://leetcode.com/problems/flatten-2d-vector "展开二维向量") @@ -45,13 +45,13 @@ iterator.hasNext(); // return false

As an added challenge, try to code it using only iterators in C++ or iterators in Java.

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions - 1. [Binary Search Tree Iterator](https://github.com/openset/leetcode/tree/master/problems/binary-search-tree-iterator) (Medium) - 1. [Zigzag Iterator](https://github.com/openset/leetcode/tree/master/problems/zigzag-iterator) (Medium) - 1. [Peeking Iterator](https://github.com/openset/leetcode/tree/master/problems/peeking-iterator) (Medium) - 1. [Flatten Nested List Iterator](https://github.com/openset/leetcode/tree/master/problems/flatten-nested-list-iterator) (Medium) + 1. [Binary Search Tree Iterator](../binary-search-tree-iterator) (Medium) + 1. [Zigzag Iterator](../zigzag-iterator) (Medium) + 1. [Peeking Iterator](../peeking-iterator) (Medium) + 1. [Flatten Nested List Iterator](../flatten-nested-list-iterator) (Medium) ### Hints
diff --git a/problems/flatten-a-multilevel-doubly-linked-list/README.md b/problems/flatten-a-multilevel-doubly-linked-list/README.md index b43386a6a..6a4366de6 100644 --- a/problems/flatten-a-multilevel-doubly-linked-list/README.md +++ b/problems/flatten-a-multilevel-doubly-linked-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-level-order-traversal "N-ary Tree Level Order Traversal") +[< Previous](../n-ary-tree-level-order-traversal "N-ary Tree Level Order Traversal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/encode-n-ary-tree-to-binary-tree "Encode N-ary Tree to Binary Tree") +[Next >](../encode-n-ary-tree-to-binary-tree "Encode N-ary Tree to Binary Tree") ## [430. Flatten a Multilevel Doubly Linked List (Medium)](https://leetcode.com/problems/flatten-a-multilevel-doubly-linked-list "扁平化多级双向链表") @@ -96,8 +96,8 @@ After flattening the multilevel linked list it becomes: ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Flatten Binary Tree to Linked List](https://github.com/openset/leetcode/tree/master/problems/flatten-binary-tree-to-linked-list) (Medium) + 1. [Flatten Binary Tree to Linked List](../flatten-binary-tree-to-linked-list) (Medium) diff --git a/problems/flatten-binary-tree-to-linked-list/README.md b/problems/flatten-binary-tree-to-linked-list/README.md index 19ce00839..52b53dbca 100644 --- a/problems/flatten-binary-tree-to-linked-list/README.md +++ b/problems/flatten-binary-tree-to-linked-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/path-sum-ii "Path Sum II") +[< Previous](../path-sum-ii "Path Sum II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/distinct-subsequences "Distinct Subsequences") +[Next >](../distinct-subsequences "Distinct Subsequences") ## [114. Flatten Binary Tree to Linked List (Medium)](https://leetcode.com/problems/flatten-binary-tree-to-linked-list "二叉树展开为链表") @@ -40,11 +40,11 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Flatten a Multilevel Doubly Linked List](https://github.com/openset/leetcode/tree/master/problems/flatten-a-multilevel-doubly-linked-list) (Medium) + 1. [Flatten a Multilevel Doubly Linked List](../flatten-a-multilevel-doubly-linked-list) (Medium) ### Hints
diff --git a/problems/flatten-nested-list-iterator/README.md b/problems/flatten-nested-list-iterator/README.md index ba6e79897..183c4401a 100644 --- a/problems/flatten-nested-list-iterator/README.md +++ b/problems/flatten-nested-list-iterator/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-k-distinct-characters "Longest Substring with At Most K Distinct Characters") +[< Previous](../longest-substring-with-at-most-k-distinct-characters "Longest Substring with At Most K Distinct Characters")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/power-of-four "Power of Four") +[Next >](../power-of-four "Power of Four") ## [341. Flatten Nested List Iterator (Medium)](https://leetcode.com/problems/flatten-nested-list-iterator "扁平化嵌套列表迭代器") @@ -37,11 +37,11 @@ ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions - 1. [Flatten 2D Vector](https://github.com/openset/leetcode/tree/master/problems/flatten-2d-vector) (Medium) - 1. [Zigzag Iterator](https://github.com/openset/leetcode/tree/master/problems/zigzag-iterator) (Medium) - 1. [Mini Parser](https://github.com/openset/leetcode/tree/master/problems/mini-parser) (Medium) - 1. [Array Nesting](https://github.com/openset/leetcode/tree/master/problems/array-nesting) (Medium) + 1. [Flatten 2D Vector](../flatten-2d-vector) (Medium) + 1. [Zigzag Iterator](../zigzag-iterator) (Medium) + 1. [Mini Parser](../mini-parser) (Medium) + 1. [Array Nesting](../array-nesting) (Medium) diff --git a/problems/flip-binary-tree-to-match-preorder-traversal/README.md b/problems/flip-binary-tree-to-match-preorder-traversal/README.md index ee0574964..00e9baf57 100644 --- a/problems/flip-binary-tree-to-match-preorder-traversal/README.md +++ b/problems/flip-binary-tree-to-match-preorder-traversal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/powerful-integers "Powerful Integers") +[< Previous](../powerful-integers "Powerful Integers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/equal-rational-numbers "Equal Rational Numbers") +[Next >](../equal-rational-numbers "Equal Rational Numbers") ## [971. Flip Binary Tree To Match Preorder Traversal (Medium)](https://leetcode.com/problems/flip-binary-tree-to-match-preorder-traversal "翻转二叉树以匹配先序遍历") @@ -69,5 +69,5 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/flip-columns-for-maximum-number-of-equal-rows/README.md b/problems/flip-columns-for-maximum-number-of-equal-rows/README.md index 3ef1408b7..eb25ef95a 100644 --- a/problems/flip-columns-for-maximum-number-of-equal-rows/README.md +++ b/problems/flip-columns-for-maximum-number-of-equal-rows/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/greatest-common-divisor-of-strings "Greatest Common Divisor of Strings") +[< Previous](../greatest-common-divisor-of-strings "Greatest Common Divisor of Strings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/adding-two-negabinary-numbers "Adding Two Negabinary Numbers") +[Next >](../adding-two-negabinary-numbers "Adding Two Negabinary Numbers") ## [1072. Flip Columns For Maximum Number of Equal Rows (Medium)](https://leetcode.com/problems/flip-columns-for-maximum-number-of-equal-rows "按列翻转得到最大值等行数") @@ -62,7 +62,7 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
diff --git a/problems/flip-equivalent-binary-trees/README.md b/problems/flip-equivalent-binary-trees/README.md index b13f1a5d1..32f6b6ba5 100644 --- a/problems/flip-equivalent-binary-trees/README.md +++ b/problems/flip-equivalent-binary-trees/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reveal-cards-in-increasing-order "Reveal Cards In Increasing Order") +[< Previous](../reveal-cards-in-increasing-order "Reveal Cards In Increasing Order")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/largest-component-size-by-common-factor "Largest Component Size by Common Factor") +[Next >](../largest-component-size-by-common-factor "Largest Component Size by Common Factor") ## [951. Flip Equivalent Binary Trees (Medium)](https://leetcode.com/problems/flip-equivalent-binary-trees "翻转等价二叉树") @@ -42,4 +42,4 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] diff --git a/problems/flip-game-ii/README.md b/problems/flip-game-ii/README.md index c710e0c82..2f1cb21a4 100644 --- a/problems/flip-game-ii/README.md +++ b/problems/flip-game-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/flip-game "Flip Game") +[< Previous](../flip-game "Flip Game")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-median-from-data-stream "Find Median from Data Stream") +[Next >](../find-median-from-data-stream "Find Median from Data Stream") ## [294. Flip Game II (Medium)](https://leetcode.com/problems/flip-game-ii "翻转游戏 II") @@ -27,11 +27,11 @@ Derive your algorithm's runtime complexity.

### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] - [[Minimax](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Minimax](../../tag/minimax/README.md)] ### Similar Questions - 1. [Nim Game](https://github.com/openset/leetcode/tree/master/problems/nim-game) (Easy) - 1. [Flip Game](https://github.com/openset/leetcode/tree/master/problems/flip-game) (Easy) - 1. [Guess Number Higher or Lower II](https://github.com/openset/leetcode/tree/master/problems/guess-number-higher-or-lower-ii) (Medium) - 1. [Can I Win](https://github.com/openset/leetcode/tree/master/problems/can-i-win) (Medium) + 1. [Nim Game](../nim-game) (Easy) + 1. [Flip Game](../flip-game) (Easy) + 1. [Guess Number Higher or Lower II](../guess-number-higher-or-lower-ii) (Medium) + 1. [Can I Win](../can-i-win) (Medium) diff --git a/problems/flip-game/README.md b/problems/flip-game/README.md index 728d42ce4..5a155f02b 100644 --- a/problems/flip-game/README.md +++ b/problems/flip-game/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/nim-game "Nim Game") +[< Previous](../nim-game "Nim Game")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/flip-game-ii "Flip Game II") +[Next >](../flip-game-ii "Flip Game II") ## [293. Flip Game (Easy)](https://leetcode.com/problems/flip-game "翻转游戏") @@ -30,7 +30,7 @@

Note: If there is no valid move, return an empty list [].

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Flip Game II](https://github.com/openset/leetcode/tree/master/problems/flip-game-ii) (Medium) + 1. [Flip Game II](../flip-game-ii) (Medium) diff --git a/problems/flip-string-to-monotone-increasing/README.md b/problems/flip-string-to-monotone-increasing/README.md index 84c4939a8..23cf18547 100644 --- a/problems/flip-string-to-monotone-increasing/README.md +++ b/problems/flip-string-to-monotone-increasing/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/long-pressed-name "Long Pressed Name") +[< Previous](../long-pressed-name "Long Pressed Name")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/three-equal-parts "Three Equal Parts") +[Next >](../three-equal-parts "Three Equal Parts") ## [926. Flip String to Monotone Increasing (Medium)](https://leetcode.com/problems/flip-string-to-monotone-increasing "将字符串翻转到单调递增") @@ -59,4 +59,4 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/flipping-an-image/README.md b/problems/flipping-an-image/README.md index b16f0ac6d..a15791ada 100644 --- a/problems/flipping-an-image/README.md +++ b/problems/flipping-an-image/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/masking-personal-information "Masking Personal Information") +[< Previous](../masking-personal-information "Masking Personal Information")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-and-replace-in-string "Find And Replace in String") +[Next >](../find-and-replace-in-string "Find And Replace in String") ## [832. Flipping an Image (Easy)](https://leetcode.com/problems/flipping-an-image "翻转图像") @@ -43,4 +43,4 @@ Then invert the image: [[1,1,0,0],[0,1,1,0],[0,0,0,1],[1,0,1,0]] ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/flood-fill/README.md b/problems/flood-fill/README.md index 82943c989..2b88dd868 100644 --- a/problems/flood-fill/README.md +++ b/problems/flood-fill/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/my-calendar-iii "My Calendar III") +[< Previous](../my-calendar-iii "My Calendar III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sentence-similarity "Sentence Similarity") +[Next >](../sentence-similarity "Sentence Similarity") ## [733. Flood Fill (Easy)](https://leetcode.com/problems/flood-fill "图像渲染") @@ -41,10 +41,10 @@ to the starting pixel.

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Island Perimeter](https://github.com/openset/leetcode/tree/master/problems/island-perimeter) (Easy) + 1. [Island Perimeter](../island-perimeter) (Easy) ### Hints
diff --git a/problems/flower-planting-with-no-adjacent/README.md b/problems/flower-planting-with-no-adjacent/README.md index f2af46149..d678c816f 100644 --- a/problems/flower-planting-with-no-adjacent/README.md +++ b/problems/flower-planting-with-no-adjacent/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/robot-bounded-in-circle "Robot Bounded In Circle") +[< Previous](../robot-bounded-in-circle "Robot Bounded In Circle")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/partition-array-for-maximum-sum "Partition Array for Maximum Sum") +[Next >](../partition-array-for-maximum-sum "Partition Array for Maximum Sum") ## [1042. Flower Planting With No Adjacent (Easy)](https://leetcode.com/problems/flower-planting-with-no-adjacent "不邻接植花") @@ -62,7 +62,7 @@ ### Related Topics - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Graph](../../tag/graph/README.md)] ### Hints
diff --git a/problems/fraction-addition-and-subtraction/README.md b/problems/fraction-addition-and-subtraction/README.md index 0abcb3900..1009fe831 100644 --- a/problems/fraction-addition-and-subtraction/README.md +++ b/problems/fraction-addition-and-subtraction/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/tag-validator "Tag Validator") +[< Previous](../tag-validator "Tag Validator")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-square "Valid Square") +[Next >](../valid-square "Valid Square") ## [592. Fraction Addition and Subtraction (Medium)](https://leetcode.com/problems/fraction-addition-and-subtraction "分数加减运算") @@ -52,7 +52,7 @@

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Solve the Equation](https://github.com/openset/leetcode/tree/master/problems/solve-the-equation) (Medium) + 1. [Solve the Equation](../solve-the-equation) (Medium) diff --git a/problems/fraction-to-recurring-decimal/README.md b/problems/fraction-to-recurring-decimal/README.md index 954f18ab8..24f9a239c 100644 --- a/problems/fraction-to-recurring-decimal/README.md +++ b/problems/fraction-to-recurring-decimal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/compare-version-numbers "Compare Version Numbers") +[< Previous](../compare-version-numbers "Compare Version Numbers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/two-sum-ii-input-array-is-sorted "Two Sum II - Input array is sorted") +[Next >](../two-sum-ii-input-array-is-sorted "Two Sum II - Input array is sorted") ## [166. Fraction to Recurring Decimal (Medium)](https://leetcode.com/problems/fraction-to-recurring-decimal "分数到小数") @@ -36,8 +36,8 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/freedom-trail/README.md b/problems/freedom-trail/README.md index a3fec895b..f565e1c45 100644 --- a/problems/freedom-trail/README.md +++ b/problems/freedom-trail/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-bottom-left-tree-value "Find Bottom Left Tree Value") +[< Previous](../find-bottom-left-tree-value "Find Bottom Left Tree Value")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-largest-value-in-each-tree-row "Find Largest Value in Each Tree Row") +[Next >](../find-largest-value-in-each-tree-row "Find Largest Value in Each Tree Row") ## [514. Freedom Trail (Hard)](https://leetcode.com/problems/freedom-trail "自由之路") @@ -48,6 +48,6 @@ So the final output is 4. ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/friend-circles/README.md b/problems/friend-circles/README.md index 6e05570a9..d8eb27439 100644 --- a/problems/friend-circles/README.md +++ b/problems/friend-circles/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-boxes "Remove Boxes") +[< Previous](../remove-boxes "Remove Boxes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/split-array-with-equal-sum "Split Array with Equal Sum") +[Next >](../split-array-with-equal-sum "Split Array with Equal Sum") ## [547. Friend Circles (Medium)](https://leetcode.com/problems/friend-circles "朋友圈") @@ -51,12 +51,12 @@ Given a N*N matrix M representing the friend relationship between

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] ### Similar Questions - 1. [Number of Connected Components in an Undirected Graph](https://github.com/openset/leetcode/tree/master/problems/number-of-connected-components-in-an-undirected-graph) (Medium) - 1. [Robot Return to Origin](https://github.com/openset/leetcode/tree/master/problems/robot-return-to-origin) (Easy) - 1. [Sentence Similarity](https://github.com/openset/leetcode/tree/master/problems/sentence-similarity) (Easy) - 1. [Sentence Similarity II](https://github.com/openset/leetcode/tree/master/problems/sentence-similarity-ii) (Medium) - 1. [The Earliest Moment When Everyone Become Friends](https://github.com/openset/leetcode/tree/master/problems/the-earliest-moment-when-everyone-become-friends) (Medium) + 1. [Number of Connected Components in an Undirected Graph](../number-of-connected-components-in-an-undirected-graph) (Medium) + 1. [Robot Return to Origin](../robot-return-to-origin) (Easy) + 1. [Sentence Similarity](../sentence-similarity) (Easy) + 1. [Sentence Similarity II](../sentence-similarity-ii) (Medium) + 1. [The Earliest Moment When Everyone Become Friends](../the-earliest-moment-when-everyone-become-friends) (Medium) diff --git a/problems/friend-requests-i-overall-acceptance-rate/README.md b/problems/friend-requests-i-overall-acceptance-rate/README.md index f9b2bc667..455c32bf6 100644 --- a/problems/friend-requests-i-overall-acceptance-rate/README.md +++ b/problems/friend-requests-i-overall-acceptance-rate/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/classes-more-than-5-students "Classes More Than 5 Students") +[< Previous](../classes-more-than-5-students "Classes More Than 5 Students")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/range-addition-ii "Range Addition II") +[Next >](../range-addition-ii "Range Addition II") ## [597. Friend Requests I: Overall Acceptance Rate (Easy)](https://leetcode.com/problems/friend-requests-i-overall-acceptance-rate "好友申请 I :总体通过率") diff --git a/problems/friend-requests-ii-who-has-the-most-friends/README.md b/problems/friend-requests-ii-who-has-the-most-friends/README.md index 9ee967544..64f9ceb5d 100644 --- a/problems/friend-requests-ii-who-has-the-most-friends/README.md +++ b/problems/friend-requests-ii-who-has-the-most-friends/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/human-traffic-of-stadium "Human Traffic of Stadium") +[< Previous](../human-traffic-of-stadium "Human Traffic of Stadium")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/consecutive-available-seats "Consecutive Available Seats") +[Next >](../consecutive-available-seats "Consecutive Available Seats") ## [602. Friend Requests II: Who Has the Most Friends (Medium)](https://leetcode.com/problems/friend-requests-ii-who-has-the-most-friends "好友申请 II :谁有最多的好友") diff --git a/problems/friends-of-appropriate-ages/README.md b/problems/friends-of-appropriate-ages/README.md index ff3ee28c5..bb701da97 100644 --- a/problems/friends-of-appropriate-ages/README.md +++ b/problems/friends-of-appropriate-ages/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/goat-latin "Goat Latin") +[< Previous](../goat-latin "Goat Latin")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/most-profit-assigning-work "Most Profit Assigning Work") +[Next >](../most-profit-assigning-work "Most Profit Assigning Work") ## [825. Friends Of Appropriate Ages (Medium)](https://leetcode.com/problems/friends-of-appropriate-ages "适龄的朋友") @@ -60,4 +60,4 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/frog-jump/README.md b/problems/frog-jump/README.md index 683d006d2..d53a1cc85 100644 --- a/problems/frog-jump/README.md +++ b/problems/frog-jump/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-k-digits "Remove K Digits") +[< Previous](../remove-k-digits "Remove K Digits")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sum-of-left-leaves "Sum of Left Leaves") +[Next >](../sum-of-left-leaves "Sum of Left Leaves") ## [403. Frog Jump (Hard)](https://leetcode.com/problems/frog-jump "青蛙过河") @@ -52,4 +52,4 @@ the gap between the 5th and 6th stone is too large.

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/fruit-into-baskets/README.md b/problems/fruit-into-baskets/README.md index 4277daa0b..a42a0ee11 100644 --- a/problems/fruit-into-baskets/README.md +++ b/problems/fruit-into-baskets/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-permutations-for-di-sequence "Valid Permutations for DI Sequence") +[< Previous](../valid-permutations-for-di-sequence "Valid Permutations for DI Sequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sort-array-by-parity "Sort Array By Parity") +[Next >](../sort-array-by-parity "Sort Array By Parity") ## [904. Fruit Into Baskets (Medium)](https://leetcode.com/problems/fruit-into-baskets "水果成篮") @@ -79,4 +79,4 @@ If we started at the first tree, we would only collect [0, 1]. ### Related Topics - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/game-of-life/README.md b/problems/game-of-life/README.md index 0689c2701..59dfaf890 100644 --- a/problems/game-of-life/README.md +++ b/problems/game-of-life/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/unique-word-abbreviation "Unique Word Abbreviation") +[< Previous](../unique-word-abbreviation "Unique Word Abbreviation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/word-pattern "Word Pattern") +[Next >](../word-pattern "Word Pattern") ## [289. Game of Life (Medium)](https://leetcode.com/problems/game-of-life "生命游戏") @@ -51,7 +51,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Set Matrix Zeroes](https://github.com/openset/leetcode/tree/master/problems/set-matrix-zeroes) (Medium) + 1. [Set Matrix Zeroes](../set-matrix-zeroes) (Medium) diff --git a/problems/game-play-analysis-i/README.md b/problems/game-play-analysis-i/README.md index 2520d5221..a736f72a2 100644 --- a/problems/game-play-analysis-i/README.md +++ b/problems/game-play-analysis-i/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/inorder-successor-in-bst-ii "Inorder Successor in BST II") +[< Previous](../inorder-successor-in-bst-ii "Inorder Successor in BST II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-ii "Game Play Analysis II") +[Next >](../game-play-analysis-ii "Game Play Analysis II") ## [511. Game Play Analysis I (Easy)](https://leetcode.com/problems/game-play-analysis-i "游戏玩法分析 I") @@ -56,4 +56,4 @@ Result table: ### Similar Questions - 1. [Game Play Analysis II](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-ii) (Easy) + 1. [Game Play Analysis II](../game-play-analysis-ii) (Easy) diff --git a/problems/game-play-analysis-ii/README.md b/problems/game-play-analysis-ii/README.md index 6775ba01d..7db8badb0 100644 --- a/problems/game-play-analysis-ii/README.md +++ b/problems/game-play-analysis-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-i "Game Play Analysis I") +[< Previous](../game-play-analysis-i "Game Play Analysis I")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-bottom-left-tree-value "Find Bottom Left Tree Value") +[Next >](../find-bottom-left-tree-value "Find Bottom Left Tree Value") ## [512. Game Play Analysis II (Easy)](https://leetcode.com/problems/game-play-analysis-ii "游戏玩法分析 II") @@ -55,5 +55,5 @@ Result table: +-----------+-----------+ ### Similar Questions - 1. [Game Play Analysis I](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-i) (Easy) - 1. [Game Play Analysis III](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-iii) (Medium) + 1. [Game Play Analysis I](../game-play-analysis-i) (Easy) + 1. [Game Play Analysis III](../game-play-analysis-iii) (Medium) diff --git a/problems/game-play-analysis-iii/README.md b/problems/game-play-analysis-iii/README.md index ebbdfc751..555eb3114 100644 --- a/problems/game-play-analysis-iii/README.md +++ b/problems/game-play-analysis-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/lonely-pixel-ii "Lonely Pixel II") +[< Previous](../lonely-pixel-ii "Lonely Pixel II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/encode-and-decode-tinyurl "Encode and Decode TinyURL") +[Next >](../encode-and-decode-tinyurl "Encode and Decode TinyURL") ## [534. Game Play Analysis III (Medium)](https://leetcode.com/problems/game-play-analysis-iii "游戏玩法分析 III") @@ -61,5 +61,5 @@ Note that for each player we only care about the days when the player logged in. ### Similar Questions - 1. [Game Play Analysis II](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-ii) (Easy) - 1. [Game Play Analysis IV](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-iv) (Medium) + 1. [Game Play Analysis II](../game-play-analysis-ii) (Easy) + 1. [Game Play Analysis IV](../game-play-analysis-iv) (Medium) diff --git a/problems/game-play-analysis-iv/README.md b/problems/game-play-analysis-iv/README.md index 00e6a5294..d77b91fa4 100644 --- a/problems/game-play-analysis-iv/README.md +++ b/problems/game-play-analysis-iv/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-tree-longest-consecutive-sequence-ii "Binary Tree Longest Consecutive Sequence II") +[< Previous](../binary-tree-longest-consecutive-sequence-ii "Binary Tree Longest Consecutive Sequence II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/student-attendance-record-i "Student Attendance Record I") +[Next >](../student-attendance-record-i "Student Attendance Record I") ## [550. Game Play Analysis IV (Medium)](https://leetcode.com/problems/game-play-analysis-iv "游戏玩法分析 IV") @@ -55,5 +55,5 @@ Only the player with id 1 logged back in after the first day he had logged in so ### Similar Questions - 1. [Game Play Analysis III](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-iii) (Medium) - 1. [Game Play Analysis V](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-v) (Hard) + 1. [Game Play Analysis III](../game-play-analysis-iii) (Medium) + 1. [Game Play Analysis V](../game-play-analysis-v) (Hard) diff --git a/problems/game-play-analysis-v/README.md b/problems/game-play-analysis-v/README.md index 1cddfdc34..956b97d1e 100644 --- a/problems/game-play-analysis-v/README.md +++ b/problems/game-play-analysis-v/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/brace-expansion-ii "Brace Expansion II") +[< Previous](../brace-expansion-ii "Brace Expansion II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/unpopular-books "Unpopular Books") +[Next >](../unpopular-books "Unpopular Books") ## [1097. Game Play Analysis V (Hard)](https://leetcode.com/problems/game-play-analysis-v "游戏玩法分析 V") @@ -61,4 +61,4 @@ Player 2 installed the game on 2017-06-25 but didn't log back in on 2017-06- ### Similar Questions - 1. [Game Play Analysis IV](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-iv) (Medium) + 1. [Game Play Analysis IV](../game-play-analysis-iv) (Medium) diff --git a/problems/gas-station/README.md b/problems/gas-station/README.md index f7d8de52d..2f7fb4a75 100644 --- a/problems/gas-station/README.md +++ b/problems/gas-station/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/clone-graph "Clone Graph") +[< Previous](../clone-graph "Clone Graph")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/candy "Candy") +[Next >](../candy "Candy") ## [134. Gas Station (Medium)](https://leetcode.com/problems/gas-station "加油站") @@ -63,4 +63,4 @@ Therefore, you can't travel around the circuit once no matter where you star ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/generalized-abbreviation/README.md b/problems/generalized-abbreviation/README.md index 77db54cad..2756ddefe 100644 --- a/problems/generalized-abbreviation/README.md +++ b/problems/generalized-abbreviation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/bulb-switcher "Bulb Switcher") +[< Previous](../bulb-switcher "Bulb Switcher")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/create-maximum-number "Create Maximum Number") +[Next >](../create-maximum-number "Create Maximum Number") ## [320. Generalized Abbreviation (Medium)](https://leetcode.com/problems/generalized-abbreviation "列举单词的全部缩写") @@ -26,10 +26,10 @@

 

### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Subsets](https://github.com/openset/leetcode/tree/master/problems/subsets) (Medium) - 1. [Unique Word Abbreviation](https://github.com/openset/leetcode/tree/master/problems/unique-word-abbreviation) (Medium) - 1. [Minimum Unique Word Abbreviation](https://github.com/openset/leetcode/tree/master/problems/minimum-unique-word-abbreviation) (Hard) + 1. [Subsets](../subsets) (Medium) + 1. [Unique Word Abbreviation](../unique-word-abbreviation) (Medium) + 1. [Minimum Unique Word Abbreviation](../minimum-unique-word-abbreviation) (Hard) diff --git a/problems/generate-parentheses/README.md b/problems/generate-parentheses/README.md index cc22abf0f..2a97c5fa7 100644 --- a/problems/generate-parentheses/README.md +++ b/problems/generate-parentheses/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/merge-two-sorted-lists "Merge Two Sorted Lists") +[< Previous](../merge-two-sorted-lists "Merge Two Sorted Lists")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/merge-k-sorted-lists "Merge k Sorted Lists") +[Next >](../merge-k-sorted-lists "Merge k Sorted Lists") ## [22. Generate Parentheses (Medium)](https://leetcode.com/problems/generate-parentheses "括号生成") @@ -29,9 +29,9 @@ For example, given n = 3, a solution set is: ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[String](../../tag/string/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Letter Combinations of a Phone Number](https://github.com/openset/leetcode/tree/master/problems/letter-combinations-of-a-phone-number) (Medium) - 1. [Valid Parentheses](https://github.com/openset/leetcode/tree/master/problems/valid-parentheses) (Easy) + 1. [Letter Combinations of a Phone Number](../letter-combinations-of-a-phone-number) (Medium) + 1. [Valid Parentheses](../valid-parentheses) (Easy) diff --git a/problems/generate-random-point-in-a-circle/README.md b/problems/generate-random-point-in-a-circle/README.md index 12f720905..fd63e7eab 100644 --- a/problems/generate-random-point-in-a-circle/README.md +++ b/problems/generate-random-point-in-a-circle/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/total-hamming-distance "Total Hamming Distance") +[< Previous](../total-hamming-distance "Total Hamming Distance")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/largest-palindrome-product "Largest Palindrome Product") +[Next >](../largest-palindrome-product "Largest Palindrome Product") ## [478. Generate Random Point in a Circle (Medium)](https://leetcode.com/problems/generate-random-point-in-a-circle "在圆内随机生成点") @@ -48,9 +48,9 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] - [[Rejection Sampling](https://github.com/openset/leetcode/tree/master/tag/rejection-sampling/README.md)] + [[Math](../../tag/math/README.md)] + [[Random](../../tag/random/README.md)] + [[Rejection Sampling](../../tag/rejection-sampling/README.md)] ### Similar Questions - 1. [Random Point in Non-overlapping Rectangles](https://github.com/openset/leetcode/tree/master/problems/random-point-in-non-overlapping-rectangles) (Medium) + 1. [Random Point in Non-overlapping Rectangles](../random-point-in-non-overlapping-rectangles) (Medium) diff --git a/problems/get-equal-substrings-within-budget/README.md b/problems/get-equal-substrings-within-budget/README.md index 9b88f63e4..d2cbf28f0 100644 --- a/problems/get-equal-substrings-within-budget/README.md +++ b/problems/get-equal-substrings-within-budget/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/unique-number-of-occurrences "Unique Number of Occurrences") +[< Previous](../unique-number-of-occurrences "Unique Number of Occurrences")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-all-adjacent-duplicates-in-string-ii "Remove All Adjacent Duplicates in String II") +[Next >](../remove-all-adjacent-duplicates-in-string-ii "Remove All Adjacent Duplicates in String II") ## [1208. Get Equal Substrings Within Budget (Medium)](https://leetcode.com/problems/get-equal-substrings-within-budget "尽可能使字符串相等") @@ -53,8 +53,8 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Array](../../tag/array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
diff --git a/problems/get-highest-answer-rate-question/README.md b/problems/get-highest-answer-rate-question/README.md index 4f9aac8eb..4683e1aa4 100644 --- a/problems/get-highest-answer-rate-question/README.md +++ b/problems/get-highest-answer-rate-question/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/employee-bonus "Employee Bonus") +[< Previous](../employee-bonus "Employee Bonus")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-cumulative-salary-of-an-employee "Find Cumulative Salary of an Employee") +[Next >](../find-cumulative-salary-of-an-employee "Find Cumulative Salary of an Employee") ## [578. Get Highest Answer Rate Question (Medium)](https://leetcode.com/problems/get-highest-answer-rate-question "查询回答率最高的问题") diff --git a/problems/global-and-local-inversions/README.md b/problems/global-and-local-inversions/README.md index ca5c69374..e30189aff 100644 --- a/problems/global-and-local-inversions/README.md +++ b/problems/global-and-local-inversions/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimize-max-distance-to-gas-station "Minimize Max Distance to Gas Station") +[< Previous](../minimize-max-distance-to-gas-station "Minimize Max Distance to Gas Station")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/split-bst "Split BST") +[Next >](../split-bst "Split BST") ## [775. Global and Local Inversions (Medium)](https://leetcode.com/problems/global-and-local-inversions "全局倒置与局部倒置") @@ -44,8 +44,8 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/goat-latin/README.md b/problems/goat-latin/README.md index 5725ac1db..2e54aee6b 100644 --- a/problems/goat-latin/README.md +++ b/problems/goat-latin/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-trees-with-factors "Binary Trees With Factors") +[< Previous](../binary-trees-with-factors "Binary Trees With Factors")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/friends-of-appropriate-ages "Friends Of Appropriate Ages") +[Next >](../friends-of-appropriate-ages "Friends Of Appropriate Ages") ## [824. Goat Latin (Easy)](https://leetcode.com/problems/goat-latin "山羊拉丁文") @@ -56,4 +56,4 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/graph-valid-tree/README.md b/problems/graph-valid-tree/README.md index e6d65ec73..fa7a72d39 100644 --- a/problems/graph-valid-tree/README.md +++ b/problems/graph-valid-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/single-number-iii "Single Number III") +[< Previous](../single-number-iii "Single Number III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/trips-and-users "Trips and Users") +[Next >](../trips-and-users "Trips and Users") ## [261. Graph Valid Tree (Medium)](https://leetcode.com/problems/graph-valid-tree "以图判树") @@ -28,14 +28,14 @@

Note: you can assume that no duplicate edges will appear in edges. Since all edges are undirected, [0,1] is the same as [1,0] and thus will not appear together in edges.

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] ### Similar Questions - 1. [Course Schedule](https://github.com/openset/leetcode/tree/master/problems/course-schedule) (Medium) - 1. [Number of Connected Components in an Undirected Graph](https://github.com/openset/leetcode/tree/master/problems/number-of-connected-components-in-an-undirected-graph) (Medium) + 1. [Course Schedule](../course-schedule) (Medium) + 1. [Number of Connected Components in an Undirected Graph](../number-of-connected-components-in-an-undirected-graph) (Medium) ### Hints
diff --git a/problems/gray-code/README.md b/problems/gray-code/README.md index e2cbe11f9..45b98b773 100644 --- a/problems/gray-code/README.md +++ b/problems/gray-code/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/merge-sorted-array "Merge Sorted Array") +[< Previous](../merge-sorted-array "Merge Sorted Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/subsets-ii "Subsets II") +[Next >](../subsets-ii "Subsets II") ## [89. Gray Code (Medium)](https://leetcode.com/problems/gray-code "格雷编码") @@ -46,7 +46,7 @@ For example, [0,2,3,1] is also a valid gray code sequence. ### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [1-bit and 2-bit Characters](https://github.com/openset/leetcode/tree/master/problems/1-bit-and-2-bit-characters) (Easy) + 1. [1-bit and 2-bit Characters](../1-bit-and-2-bit-characters) (Easy) diff --git a/problems/greatest-common-divisor-of-strings/README.md b/problems/greatest-common-divisor-of-strings/README.md index fe1cafc8e..1b3cb2011 100644 --- a/problems/greatest-common-divisor-of-strings/README.md +++ b/problems/greatest-common-divisor-of-strings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-iii "Product Sales Analysis III") +[< Previous](../product-sales-analysis-iii "Product Sales Analysis III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/flip-columns-for-maximum-number-of-equal-rows "Flip Columns For Maximum Number of Equal Rows") +[Next >](../flip-columns-for-maximum-number-of-equal-rows "Flip Columns For Maximum Number of Equal Rows") ## [1071. Greatest Common Divisor of Strings (Easy)](https://leetcode.com/problems/greatest-common-divisor-of-strings "字符串的最大公因子") @@ -49,7 +49,7 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/greatest-sum-divisible-by-three/README.md b/problems/greatest-sum-divisible-by-three/README.md index ee114840e..da02d3620 100644 --- a/problems/greatest-sum-divisible-by-three/README.md +++ b/problems/greatest-sum-divisible-by-three/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-elements-in-a-contaminated-binary-tree "Find Elements in a Contaminated Binary Tree") +[< Previous](../find-elements-in-a-contaminated-binary-tree "Find Elements in a Contaminated Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-move-a-box-to-their-target-location "Minimum Moves to Move a Box to Their Target Location") +[Next >](../minimum-moves-to-move-a-box-to-their-target-location "Minimum Moves to Move a Box to Their Target Location") ## [1262. Greatest Sum Divisible by Three (Medium)](https://leetcode.com/problems/greatest-sum-divisible-by-three "可被三整除的最大和") @@ -49,7 +49,7 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/grid-illumination/README.md b/problems/grid-illumination/README.md index cb727408e..818a21554 100644 --- a/problems/grid-illumination/README.md +++ b/problems/grid-illumination/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-to-merge-stones "Minimum Cost to Merge Stones") +[< Previous](../minimum-cost-to-merge-stones "Minimum Cost to Merge Stones")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-common-characters "Find Common Characters") +[Next >](../find-common-characters "Find Common Characters") ## [1001. Grid Illumination (Hard)](https://leetcode.com/problems/grid-illumination "网格照明") @@ -57,7 +57,7 @@ Before performing the second query we have only the lamp [4,4] on. Now the quer ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [N-Queens](https://github.com/openset/leetcode/tree/master/problems/n-queens) (Hard) + 1. [N-Queens](../n-queens) (Hard) diff --git a/problems/group-anagrams/README.md b/problems/group-anagrams/README.md index 1b3206ce6..3032aad0f 100644 --- a/problems/group-anagrams/README.md +++ b/problems/group-anagrams/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/rotate-image "Rotate Image") +[< Previous](../rotate-image "Rotate Image")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/powx-n "Pow(x, n)") +[Next >](../powx-n "Pow(x, n)") ## [49. Group Anagrams (Medium)](https://leetcode.com/problems/group-anagrams "字母异位词分组") @@ -32,9 +32,9 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Valid Anagram](https://github.com/openset/leetcode/tree/master/problems/valid-anagram) (Easy) - 1. [Group Shifted Strings](https://github.com/openset/leetcode/tree/master/problems/group-shifted-strings) (Medium) + 1. [Valid Anagram](../valid-anagram) (Easy) + 1. [Group Shifted Strings](../group-shifted-strings) (Medium) diff --git a/problems/group-shifted-strings/README.md b/problems/group-shifted-strings/README.md index 4074686f3..00b649435 100644 --- a/problems/group-shifted-strings/README.md +++ b/problems/group-shifted-strings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number-iii "Strobogrammatic Number III") +[< Previous](../strobogrammatic-number-iii "Strobogrammatic Number III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/count-univalue-subtrees "Count Univalue Subtrees") +[Next >](../count-univalue-subtrees "Count Univalue Subtrees") ## [249. Group Shifted Strings (Medium)](https://leetcode.com/problems/group-shifted-strings "移位字符串分组") @@ -32,8 +32,8 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Group Anagrams](https://github.com/openset/leetcode/tree/master/problems/group-anagrams) (Medium) + 1. [Group Anagrams](../group-anagrams) (Medium) diff --git a/problems/group-the-people-given-the-group-size-they-belong-to/README.md b/problems/group-the-people-given-the-group-size-they-belong-to/README.md index c9a4db1e7..cb02db933 100644 --- a/problems/group-the-people-given-the-group-size-they-belong-to/README.md +++ b/problems/group-the-people-given-the-group-size-they-belong-to/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/subtract-the-product-and-sum-of-digits-of-an-integer "Subtract the Product and Sum of Digits of an Integer") +[< Previous](../subtract-the-product-and-sum-of-digits-of-an-integer "Subtract the Product and Sum of Digits of an Integer")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-the-smallest-divisor-given-a-threshold "Find the Smallest Divisor Given a Threshold") +[Next >](../find-the-smallest-divisor-given-a-threshold "Find the Smallest Divisor Given a Threshold") ## [1282. Group the People Given the Group Size They Belong To (Medium)](https://leetcode.com/problems/group-the-people-given-the-group-size-they-belong-to "用户分组") @@ -42,7 +42,7 @@ Other possible solutions are [[2,1,6],[5],[0,4,3]] and [[5],[0,6,2],[4,3,1]]. ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
diff --git a/problems/groups-of-special-equivalent-strings/README.md b/problems/groups-of-special-equivalent-strings/README.md index 90e9e8a9b..c2a4c5ec0 100644 --- a/problems/groups-of-special-equivalent-strings/README.md +++ b/problems/groups-of-special-equivalent-strings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/surface-area-of-3d-shapes "Surface Area of 3D Shapes") +[< Previous](../surface-area-of-3d-shapes "Surface Area of 3D Shapes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/all-possible-full-binary-trees "All Possible Full Binary Trees") +[Next >](../all-possible-full-binary-trees "All Possible Full Binary Trees") ## [893. Groups of Special-Equivalent Strings (Easy)](https://leetcode.com/problems/groups-of-special-equivalent-strings "特殊等价字符串组") @@ -71,4 +71,4 @@ The other two groups are ["xyzz", "zzxy"] and ["zzyx&qu ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/grumpy-bookstore-owner/README.md b/problems/grumpy-bookstore-owner/README.md index d448161e1..0982db199 100644 --- a/problems/grumpy-bookstore-owner/README.md +++ b/problems/grumpy-bookstore-owner/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/height-checker "Height Checker") +[< Previous](../height-checker "Height Checker")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/previous-permutation-with-one-swap "Previous Permutation With One Swap") +[Next >](../previous-permutation-with-one-swap "Previous Permutation With One Swap") ## [1052. Grumpy Bookstore Owner (Medium)](https://leetcode.com/problems/grumpy-bookstore-owner "爱生气的书店老板") @@ -41,8 +41,8 @@ The maximum number of customers that can be satisfied = 1 + 1 + 1 + 1 + 7 + 5 = ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Array](../../tag/array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
diff --git a/problems/guess-number-higher-or-lower-ii/README.md b/problems/guess-number-higher-or-lower-ii/README.md index 1ba4686b3..f18636f96 100644 --- a/problems/guess-number-higher-or-lower-ii/README.md +++ b/problems/guess-number-higher-or-lower-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/guess-number-higher-or-lower "Guess Number Higher or Lower") +[< Previous](../guess-number-higher-or-lower "Guess Number Higher or Lower")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/wiggle-subsequence "Wiggle Subsequence") +[Next >](../wiggle-subsequence "Wiggle Subsequence") ## [375. Guess Number Higher or Lower II (Medium)](https://leetcode.com/problems/guess-number-higher-or-lower-ii "猜数字大小 II") @@ -36,14 +36,14 @@ You end up paying $5 + $7 + $9 = $21.

Given a particular n ≥ 1, find out how much money you need to have to guarantee a win.

### Related Topics - [[Minimax](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Minimax](../../tag/minimax/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Flip Game II](https://github.com/openset/leetcode/tree/master/problems/flip-game-ii) (Medium) - 1. [Guess Number Higher or Lower](https://github.com/openset/leetcode/tree/master/problems/guess-number-higher-or-lower) (Easy) - 1. [Can I Win](https://github.com/openset/leetcode/tree/master/problems/can-i-win) (Medium) - 1. [Find K Closest Elements](https://github.com/openset/leetcode/tree/master/problems/find-k-closest-elements) (Medium) + 1. [Flip Game II](../flip-game-ii) (Medium) + 1. [Guess Number Higher or Lower](../guess-number-higher-or-lower) (Easy) + 1. [Can I Win](../can-i-win) (Medium) + 1. [Find K Closest Elements](../find-k-closest-elements) (Medium) ### Hints
diff --git a/problems/guess-number-higher-or-lower/README.md b/problems/guess-number-higher-or-lower/README.md index 598ab18b4..22924c652 100644 --- a/problems/guess-number-higher-or-lower/README.md +++ b/problems/guess-number-higher-or-lower/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-k-pairs-with-smallest-sums "Find K Pairs with Smallest Sums") +[< Previous](../find-k-pairs-with-smallest-sums "Find K Pairs with Smallest Sums")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/guess-number-higher-or-lower-ii "Guess Number Higher or Lower II") +[Next >](../guess-number-higher-or-lower-ii "Guess Number Higher or Lower II") ## [374. Guess Number Higher or Lower (Easy)](https://leetcode.com/problems/guess-number-higher-or-lower "猜数字大小") @@ -35,9 +35,9 @@ ### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [First Bad Version](https://github.com/openset/leetcode/tree/master/problems/first-bad-version) (Easy) - 1. [Guess Number Higher or Lower II](https://github.com/openset/leetcode/tree/master/problems/guess-number-higher-or-lower-ii) (Medium) - 1. [Find K Closest Elements](https://github.com/openset/leetcode/tree/master/problems/find-k-closest-elements) (Medium) + 1. [First Bad Version](../first-bad-version) (Easy) + 1. [Guess Number Higher or Lower II](../guess-number-higher-or-lower-ii) (Medium) + 1. [Find K Closest Elements](../find-k-closest-elements) (Medium) diff --git a/problems/guess-the-word/README.md b/problems/guess-the-word/README.md index a5cb5b43f..8e640a233 100644 --- a/problems/guess-the-word/README.md +++ b/problems/guess-the-word/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/split-array-into-fibonacci-sequence "Split Array into Fibonacci Sequence") +[< Previous](../split-array-into-fibonacci-sequence "Split Array into Fibonacci Sequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/backspace-string-compare "Backspace String Compare") +[Next >](../backspace-string-compare "Backspace String Compare") ## [843. Guess the Word (Hard)](https://leetcode.com/problems/guess-the-word "猜猜这个单词") @@ -41,4 +41,4 @@ We made 5 calls to master.guess and one of them was the secret, so we pass

Note:  Any solutions that attempt to circumvent the judge will result in disqualification.

### Related Topics - [[Minimax](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] + [[Minimax](../../tag/minimax/README.md)] diff --git a/problems/h-index-ii/README.md b/problems/h-index-ii/README.md index 8d88f86ae..841f4c137 100644 --- a/problems/h-index-ii/README.md +++ b/problems/h-index-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/h-index "H-Index") +[< Previous](../h-index "H-Index")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/paint-fence "Paint Fence") +[Next >](../paint-fence "Paint Fence") ## [275. H-Index II (Medium)](https://leetcode.com/problems/h-index-ii "H指数 II") @@ -37,10 +37,10 @@ ### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [H-Index](https://github.com/openset/leetcode/tree/master/problems/h-index) (Medium) + 1. [H-Index](../h-index) (Medium) ### Hints
diff --git a/problems/h-index/README.md b/problems/h-index/README.md index 39476a408..0858d62f3 100644 --- a/problems/h-index/README.md +++ b/problems/h-index/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/integer-to-english-words "Integer to English Words") +[< Previous](../integer-to-english-words "Integer to English Words")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/h-index-ii "H-Index II") +[Next >](../h-index-ii "H-Index II") ## [274. H-Index (Medium)](https://leetcode.com/problems/h-index "H指数") @@ -28,11 +28,11 @@

Note: If there are several possible values for h, the maximum one is taken as the h-index.

### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [H-Index II](https://github.com/openset/leetcode/tree/master/problems/h-index-ii) (Medium) + 1. [H-Index II](../h-index-ii) (Medium) ### Hints
diff --git a/problems/hamming-distance/README.md b/problems/hamming-distance/README.md index 11d24a912..9c1800a39 100644 --- a/problems/hamming-distance/README.md +++ b/problems/hamming-distance/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/lfu-cache "LFU Cache") +[< Previous](../lfu-cache "LFU Cache")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-equal-array-elements-ii "Minimum Moves to Equal Array Elements II") +[Next >](../minimum-moves-to-equal-array-elements-ii "Minimum Moves to Equal Array Elements II") ## [461. Hamming Distance (Easy)](https://leetcode.com/problems/hamming-distance "汉明距离") @@ -35,8 +35,8 @@ The above arrows point to positions where the corresponding bits are different.

### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions - 1. [Number of 1 Bits](https://github.com/openset/leetcode/tree/master/problems/number-of-1-bits) (Easy) - 1. [Total Hamming Distance](https://github.com/openset/leetcode/tree/master/problems/total-hamming-distance) (Medium) + 1. [Number of 1 Bits](../number-of-1-bits) (Easy) + 1. [Total Hamming Distance](../total-hamming-distance) (Medium) diff --git a/problems/hand-of-straights/README.md b/problems/hand-of-straights/README.md index c2ad4a023..fe56a4df6 100644 --- a/problems/hand-of-straights/README.md +++ b/problems/hand-of-straights/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-mountain-in-array "Longest Mountain in Array") +[< Previous](../longest-mountain-in-array "Longest Mountain in Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-path-visiting-all-nodes "Shortest Path Visiting All Nodes") +[Next >](../shortest-path-visiting-all-nodes "Shortest Path Visiting All Nodes") ## [846. Hand of Straights (Medium)](https://leetcode.com/problems/hand-of-straights "一手顺子") @@ -47,4 +47,4 @@ ### Related Topics - [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] + [[Ordered Map](../../tag/ordered-map/README.md)] diff --git a/problems/handshakes-that-dont-cross/README.md b/problems/handshakes-that-dont-cross/README.md index 16bfdfafb..3817221f4 100644 --- a/problems/handshakes-that-dont-cross/README.md +++ b/problems/handshakes-that-dont-cross/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/synonymous-sentences "Synonymous Sentences") +[< Previous](../synonymous-sentences "Synonymous Sentences")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shift-2d-grid "Shift 2D Grid") +[Next >](../shift-2d-grid "Shift 2D Grid") ## [1259. Handshakes That Don't Cross (Hard)](https://leetcode.com/problems/handshakes-that-dont-cross "不相交的握手") @@ -60,8 +60,8 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/happy-number/README.md b/problems/happy-number/README.md index 6c4e98a6e..b1cf88483 100644 --- a/problems/happy-number/README.md +++ b/problems/happy-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/bitwise-and-of-numbers-range "Bitwise AND of Numbers Range") +[< Previous](../bitwise-and-of-numbers-range "Bitwise AND of Numbers Range")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-linked-list-elements "Remove Linked List Elements") +[Next >](../remove-linked-list-elements "Remove Linked List Elements") ## [202. Happy Number (Easy)](https://leetcode.com/problems/happy-number "快乐数") @@ -28,10 +28,10 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Linked List Cycle](https://github.com/openset/leetcode/tree/master/problems/linked-list-cycle) (Easy) - 1. [Add Digits](https://github.com/openset/leetcode/tree/master/problems/add-digits) (Easy) - 1. [Ugly Number](https://github.com/openset/leetcode/tree/master/problems/ugly-number) (Easy) + 1. [Linked List Cycle](../linked-list-cycle) (Easy) + 1. [Add Digits](../add-digits) (Easy) + 1. [Ugly Number](../ugly-number) (Easy) diff --git a/problems/heaters/README.md b/problems/heaters/README.md index e1d252034..db6bfe032 100644 --- a/problems/heaters/README.md +++ b/problems/heaters/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/ones-and-zeroes "Ones and Zeroes") +[< Previous](../ones-and-zeroes "Ones and Zeroes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-complement "Number Complement") +[Next >](../number-complement "Number Complement") ## [475. Heaters (Easy)](https://leetcode.com/problems/heaters "供暖器") @@ -49,4 +49,4 @@

 

### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/height-checker/README.md b/problems/height-checker/README.md index c540c1287..e35335df7 100644 --- a/problems/height-checker/README.md +++ b/problems/height-checker/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/actors-and-directors-who-cooperated-at-least-three-times "Actors and Directors Who Cooperated At Least Three Times") +[< Previous](../actors-and-directors-who-cooperated-at-least-three-times "Actors and Directors Who Cooperated At Least Three Times")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/grumpy-bookstore-owner "Grumpy Bookstore Owner") +[Next >](../grumpy-bookstore-owner "Grumpy Bookstore Owner") ## [1051. Height Checker (Easy)](https://leetcode.com/problems/height-checker "高度检查器") @@ -36,7 +36,7 @@ Students with heights 4, 3 and the last 1 are not standing in the right position ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/hexspeak/README.md b/problems/hexspeak/README.md index 05f0646e4..9813d663b 100644 --- a/problems/hexspeak/README.md +++ b/problems/hexspeak/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/all-people-report-to-the-given-manager "All People Report to the Given Manager") +[< Previous](../all-people-report-to-the-given-manager "All People Report to the Given Manager")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-interval "Remove Interval") +[Next >](../remove-interval "Remove Interval") ## [1271. Hexspeak (Easy)](https://leetcode.com/problems/hexspeak "十六进制魔术数字") @@ -41,8 +41,8 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/high-five/README.md b/problems/high-five/README.md index be848bcad..dfc3770d5 100644 --- a/problems/high-five/README.md +++ b/problems/high-five/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sum-of-digits-in-the-minimum-number "Sum of Digits in the Minimum Number") +[< Previous](../sum-of-digits-in-the-minimum-number "Sum of Digits in the Minimum Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/brace-expansion "Brace Expansion") +[Next >](../brace-expansion "Brace Expansion") ## [1086. High Five (Easy)](https://leetcode.com/problems/high-five "前五科的均分") @@ -40,9 +40,9 @@ The average of the student with id = 2 is 88.6. But with integer division their ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
diff --git a/problems/highest-grade-for-each-student/README.md b/problems/highest-grade-for-each-student/README.md index b70a600ae..509bc1cef 100644 --- a/problems/highest-grade-for-each-student/README.md +++ b/problems/highest-grade-for-each-student/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-nesting-depth-of-two-valid-parentheses-strings "Maximum Nesting Depth of Two Valid Parentheses Strings") +[< Previous](../maximum-nesting-depth-of-two-valid-parentheses-strings "Maximum Nesting Depth of Two Valid Parentheses Strings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reported-posts "Reported Posts") +[Next >](../reported-posts "Reported Posts") ## [1112. Highest Grade For Each Student (Medium)](https://leetcode.com/problems/highest-grade-for-each-student "每位学生的最高成绩") diff --git a/problems/house-robber-ii/README.md b/problems/house-robber-ii/README.md index f6edda3dd..feedaf417 100644 --- a/problems/house-robber-ii/README.md +++ b/problems/house-robber-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/word-search-ii "Word Search II") +[< Previous](../word-search-ii "Word Search II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-palindrome "Shortest Palindrome") +[Next >](../shortest-palindrome "Shortest Palindrome") ## [213. House Robber II (Medium)](https://leetcode.com/problems/house-robber-ii "打家劫舍 II") @@ -33,15 +33,15 @@   Total amount you can rob = 1 + 3 = 4. ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [House Robber](https://github.com/openset/leetcode/tree/master/problems/house-robber) (Easy) - 1. [Paint House](https://github.com/openset/leetcode/tree/master/problems/paint-house) (Easy) - 1. [Paint Fence](https://github.com/openset/leetcode/tree/master/problems/paint-fence) (Easy) - 1. [House Robber III](https://github.com/openset/leetcode/tree/master/problems/house-robber-iii) (Medium) - 1. [Non-negative Integers without Consecutive Ones](https://github.com/openset/leetcode/tree/master/problems/non-negative-integers-without-consecutive-ones) (Hard) - 1. [Coin Path](https://github.com/openset/leetcode/tree/master/problems/coin-path) (Hard) + 1. [House Robber](../house-robber) (Easy) + 1. [Paint House](../paint-house) (Easy) + 1. [Paint Fence](../paint-fence) (Easy) + 1. [House Robber III](../house-robber-iii) (Medium) + 1. [Non-negative Integers without Consecutive Ones](../non-negative-integers-without-consecutive-ones) (Hard) + 1. [Coin Path](../coin-path) (Hard) ### Hints
diff --git a/problems/house-robber-iii/README.md b/problems/house-robber-iii/README.md index 8b0537266..55f2fe6f3 100644 --- a/problems/house-robber-iii/README.md +++ b/problems/house-robber-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/palindrome-pairs "Palindrome Pairs") +[< Previous](../palindrome-pairs "Palindrome Pairs")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/counting-bits "Counting Bits") +[Next >](../counting-bits "Counting Bits") ## [337. House Robber III (Medium)](https://leetcode.com/problems/house-robber-iii "打家劫舍 III") @@ -45,9 +45,9 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [House Robber](https://github.com/openset/leetcode/tree/master/problems/house-robber) (Easy) - 1. [House Robber II](https://github.com/openset/leetcode/tree/master/problems/house-robber-ii) (Medium) + 1. [House Robber](../house-robber) (Easy) + 1. [House Robber II](../house-robber-ii) (Medium) diff --git a/problems/house-robber/README.md b/problems/house-robber/README.md index 0ef57af06..e6cf1754f 100644 --- a/problems/house-robber/README.md +++ b/problems/house-robber/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/rising-temperature "Rising Temperature") +[< Previous](../rising-temperature "Rising Temperature")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-tree-right-side-view "Binary Tree Right Side View") +[Next >](../binary-tree-right-side-view "Binary Tree Right Side View") ## [198. House Robber (Easy)](https://leetcode.com/problems/house-robber "打家劫舍") @@ -33,14 +33,14 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Maximum Product Subarray](https://github.com/openset/leetcode/tree/master/problems/maximum-product-subarray) (Medium) - 1. [House Robber II](https://github.com/openset/leetcode/tree/master/problems/house-robber-ii) (Medium) - 1. [Paint House](https://github.com/openset/leetcode/tree/master/problems/paint-house) (Easy) - 1. [Paint Fence](https://github.com/openset/leetcode/tree/master/problems/paint-fence) (Easy) - 1. [House Robber III](https://github.com/openset/leetcode/tree/master/problems/house-robber-iii) (Medium) - 1. [Non-negative Integers without Consecutive Ones](https://github.com/openset/leetcode/tree/master/problems/non-negative-integers-without-consecutive-ones) (Hard) - 1. [Coin Path](https://github.com/openset/leetcode/tree/master/problems/coin-path) (Hard) - 1. [Delete and Earn](https://github.com/openset/leetcode/tree/master/problems/delete-and-earn) (Medium) + 1. [Maximum Product Subarray](../maximum-product-subarray) (Medium) + 1. [House Robber II](../house-robber-ii) (Medium) + 1. [Paint House](../paint-house) (Easy) + 1. [Paint Fence](../paint-fence) (Easy) + 1. [House Robber III](../house-robber-iii) (Medium) + 1. [Non-negative Integers without Consecutive Ones](../non-negative-integers-without-consecutive-ones) (Hard) + 1. [Coin Path](../coin-path) (Hard) + 1. [Delete and Earn](../delete-and-earn) (Medium) diff --git a/problems/how-many-apples-can-you-put-into-the-basket/README.md b/problems/how-many-apples-can-you-put-into-the-basket/README.md index 862ac9644..db663b1de 100644 --- a/problems/how-many-apples-can-you-put-into-the-basket/README.md +++ b/problems/how-many-apples-can-you-put-into-the-basket/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/fizz-buzz-multithreaded "Fizz Buzz Multithreaded") +[< Previous](../fizz-buzz-multithreaded "Fizz Buzz Multithreaded")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-knight-moves "Minimum Knight Moves") +[Next >](../minimum-knight-moves "Minimum Knight Moves") ## [1196. How Many Apples Can You Put into the Basket (Easy)](https://leetcode.com/problems/how-many-apples-can-you-put-into-the-basket "最多可以买到的苹果数量") @@ -41,7 +41,7 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
diff --git a/problems/human-traffic-of-stadium/README.md b/problems/human-traffic-of-stadium/README.md index 7736d01d7..c7af7319b 100644 --- a/problems/human-traffic-of-stadium/README.md +++ b/problems/human-traffic-of-stadium/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/non-negative-integers-without-consecutive-ones "Non-negative Integers without Consecutive Ones") +[< Previous](../non-negative-integers-without-consecutive-ones "Non-negative Integers without Consecutive Ones")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/friend-requests-ii-who-has-the-most-friends "Friend Requests II: Who Has the Most Friends") +[Next >](../friend-requests-ii-who-has-the-most-friends "Friend Requests II: Who Has the Most Friends") ## [601. Human Traffic of Stadium (Hard)](https://leetcode.com/problems/human-traffic-of-stadium "体育馆的人流量") diff --git a/problems/image-overlap/README.md b/problems/image-overlap/README.md index e31ff5267..562c1f0a1 100644 --- a/problems/image-overlap/README.md +++ b/problems/image-overlap/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sum-of-distances-in-tree "Sum of Distances in Tree") +[< Previous](../sum-of-distances-in-tree "Sum of Distances in Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/rectangle-overlap "Rectangle Overlap") +[Next >](../rectangle-overlap "Rectangle Overlap") ## [835. Image Overlap (Medium)](https://leetcode.com/problems/image-overlap "图像重叠") @@ -39,4 +39,4 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/image-smoother/README.md b/problems/image-smoother/README.md index 1ebcce18f..cad378159 100644 --- a/problems/image-smoother/README.md +++ b/problems/image-smoother/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-9 "Remove 9") +[< Previous](../remove-9 "Remove 9")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-width-of-binary-tree "Maximum Width of Binary Tree") +[Next >](../maximum-width-of-binary-tree "Maximum Width of Binary Tree") ## [661. Image Smoother (Easy)](https://leetcode.com/problems/image-smoother "图片平滑器") @@ -38,4 +38,4 @@ For the point (1,1): floor(8/9) = floor(0.88888889) = 0

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/immediate-food-delivery-i/README.md b/problems/immediate-food-delivery-i/README.md index 383690478..2eb47ffb4 100644 --- a/problems/immediate-food-delivery-i/README.md +++ b/problems/immediate-food-delivery-i/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/dinner-plate-stacks "Dinner Plate Stacks") +[< Previous](../dinner-plate-stacks "Dinner Plate Stacks")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/immediate-food-delivery-ii "Immediate Food Delivery II") +[Next >](../immediate-food-delivery-ii "Immediate Food Delivery II") ## [1173. Immediate Food Delivery I (Easy)](https://leetcode.com/problems/immediate-food-delivery-i "") diff --git a/problems/immediate-food-delivery-ii/README.md b/problems/immediate-food-delivery-ii/README.md index 20ef3c2b9..f2fc1fc9d 100644 --- a/problems/immediate-food-delivery-ii/README.md +++ b/problems/immediate-food-delivery-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/immediate-food-delivery-i "Immediate Food Delivery I") +[< Previous](../immediate-food-delivery-i "Immediate Food Delivery I")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/prime-arrangements "Prime Arrangements") +[Next >](../prime-arrangements "Prime Arrangements") ## [1174. Immediate Food Delivery II (Medium)](https://leetcode.com/problems/immediate-food-delivery-ii "") diff --git a/problems/implement-magic-dictionary/README.md b/problems/implement-magic-dictionary/README.md index 971cd6a4b..5d5cef814 100644 --- a/problems/implement-magic-dictionary/README.md +++ b/problems/implement-magic-dictionary/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/cut-off-trees-for-golf-event "Cut Off Trees for Golf Event") +[< Previous](../cut-off-trees-for-golf-event "Cut Off Trees for Golf Event")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/map-sum-pairs "Map Sum Pairs") +[Next >](../map-sum-pairs "Map Sum Pairs") ## [676. Implement Magic Dictionary (Medium)](https://leetcode.com/problems/implement-magic-dictionary "实现一个魔法字典") @@ -42,9 +42,9 @@ Input: search("leetcoded"), Output: False

### Related Topics - [[Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Implement Trie (Prefix Tree)](https://github.com/openset/leetcode/tree/master/problems/implement-trie-prefix-tree) (Medium) - 1. [Longest Word in Dictionary](https://github.com/openset/leetcode/tree/master/problems/longest-word-in-dictionary) (Easy) + 1. [Implement Trie (Prefix Tree)](../implement-trie-prefix-tree) (Medium) + 1. [Longest Word in Dictionary](../longest-word-in-dictionary) (Easy) diff --git a/problems/implement-queue-using-stacks/README.md b/problems/implement-queue-using-stacks/README.md index 8d0069b46..09a021b43 100644 --- a/problems/implement-queue-using-stacks/README.md +++ b/problems/implement-queue-using-stacks/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/power-of-two "Power of Two") +[< Previous](../power-of-two "Power of Two")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-digit-one "Number of Digit One") +[Next >](../number-of-digit-one "Number of Digit One") ## [232. Implement Queue using Stacks (Easy)](https://leetcode.com/problems/implement-queue-using-stacks "用栈实现队列") @@ -40,8 +40,8 @@ queue.empty(); // returns false ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions - 1. [Implement Stack using Queues](https://github.com/openset/leetcode/tree/master/problems/implement-stack-using-queues) (Easy) + 1. [Implement Stack using Queues](../implement-stack-using-queues) (Easy) diff --git a/problems/implement-rand10-using-rand7/README.md b/problems/implement-rand10-using-rand7/README.md index d0cb8c918..321d10d26 100644 --- a/problems/implement-rand10-using-rand7/README.md +++ b/problems/implement-rand10-using-rand7/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/convex-polygon "Convex Polygon") +[< Previous](../convex-polygon "Convex Polygon")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/encode-string-with-shortest-length "Encode String with Shortest Length") +[Next >](../encode-string-with-shortest-length "Encode String with Shortest Length") ## [470. Implement Rand10() Using Rand7() (Medium)](https://leetcode.com/problems/implement-rand10-using-rand7 "用 Rand7() 实现 Rand10()") @@ -66,5 +66,5 @@ ### Related Topics - [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] - [[Rejection Sampling](https://github.com/openset/leetcode/tree/master/tag/rejection-sampling/README.md)] + [[Random](../../tag/random/README.md)] + [[Rejection Sampling](../../tag/rejection-sampling/README.md)] diff --git a/problems/implement-stack-using-queues/README.md b/problems/implement-stack-using-queues/README.md index 379c3968e..75c6c6563 100644 --- a/problems/implement-stack-using-queues/README.md +++ b/problems/implement-stack-using-queues/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/basic-calculator "Basic Calculator") +[< Previous](../basic-calculator "Basic Calculator")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/invert-binary-tree "Invert Binary Tree") +[Next >](../invert-binary-tree "Invert Binary Tree") ## [225. Implement Stack using Queues (Easy)](https://leetcode.com/problems/implement-stack-using-queues "用队列实现栈") @@ -40,8 +40,8 @@ stack.empty(); // returns false ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions - 1. [Implement Queue using Stacks](https://github.com/openset/leetcode/tree/master/problems/implement-queue-using-stacks) (Easy) + 1. [Implement Queue using Stacks](../implement-queue-using-stacks) (Easy) diff --git a/problems/implement-strstr/README.md b/problems/implement-strstr/README.md index 496f433f8..2c50a5f2d 100644 --- a/problems/implement-strstr/README.md +++ b/problems/implement-strstr/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-element "Remove Element") +[< Previous](../remove-element "Remove Element")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/divide-two-integers "Divide Two Integers") +[Next >](../divide-two-integers "Divide Two Integers") ## [28. Implement strStr() (Easy)](https://leetcode.com/problems/implement-strstr "实现 strStr()") @@ -36,9 +36,9 @@

For the purpose of this problem, we will return 0 when needle is an empty string. This is consistent to C's strstr() and Java's indexOf().

### Related Topics - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Shortest Palindrome](https://github.com/openset/leetcode/tree/master/problems/shortest-palindrome) (Hard) - 1. [Repeated Substring Pattern](https://github.com/openset/leetcode/tree/master/problems/repeated-substring-pattern) (Easy) + 1. [Shortest Palindrome](../shortest-palindrome) (Hard) + 1. [Repeated Substring Pattern](../repeated-substring-pattern) (Easy) diff --git a/problems/implement-trie-prefix-tree/README.md b/problems/implement-trie-prefix-tree/README.md index 2a4891a32..4435545a4 100644 --- a/problems/implement-trie-prefix-tree/README.md +++ b/problems/implement-trie-prefix-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/course-schedule "Course Schedule") +[< Previous](../course-schedule "Course Schedule")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-size-subarray-sum "Minimum Size Subarray Sum") +[Next >](../minimum-size-subarray-sum "Minimum Size Subarray Sum") ## [208. Implement Trie (Prefix Tree) (Medium)](https://leetcode.com/problems/implement-trie-prefix-tree "实现 Trie (前缀树)") @@ -34,11 +34,11 @@ trie.search("app"); // returns true ### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] + [[Design](../../tag/design/README.md)] + [[Trie](../../tag/trie/README.md)] ### Similar Questions - 1. [Add and Search Word - Data structure design](https://github.com/openset/leetcode/tree/master/problems/add-and-search-word-data-structure-design) (Medium) - 1. [Design Search Autocomplete System](https://github.com/openset/leetcode/tree/master/problems/design-search-autocomplete-system) (Hard) - 1. [Replace Words](https://github.com/openset/leetcode/tree/master/problems/replace-words) (Medium) - 1. [Implement Magic Dictionary](https://github.com/openset/leetcode/tree/master/problems/implement-magic-dictionary) (Medium) + 1. [Add and Search Word - Data structure design](../add-and-search-word-data-structure-design) (Medium) + 1. [Design Search Autocomplete System](../design-search-autocomplete-system) (Hard) + 1. [Replace Words](../replace-words) (Medium) + 1. [Implement Magic Dictionary](../implement-magic-dictionary) (Medium) diff --git a/problems/increasing-order-search-tree/README.md b/problems/increasing-order-search-tree/README.md index 54d7a14e3..1343dda37 100644 --- a/problems/increasing-order-search-tree/README.md +++ b/problems/increasing-order-search-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/monotonic-array "Monotonic Array") +[< Previous](../monotonic-array "Monotonic Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/bitwise-ors-of-subarrays "Bitwise ORs of Subarrays") +[Next >](../bitwise-ors-of-subarrays "Bitwise ORs of Subarrays") ## [897. Increasing Order Search Tree (Easy)](https://leetcode.com/problems/increasing-order-search-tree "递增顺序查找树") @@ -53,5 +53,5 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/increasing-subsequences/README.md b/problems/increasing-subsequences/README.md index dc241a1ce..64b6c3668 100644 --- a/problems/increasing-subsequences/README.md +++ b/problems/increasing-subsequences/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/the-maze "The Maze") +[< Previous](../the-maze "The Maze")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/construct-the-rectangle "Construct the Rectangle") +[Next >](../construct-the-rectangle "Construct the Rectangle") ## [491. Increasing Subsequences (Medium)](https://leetcode.com/problems/increasing-subsequences "递增子序列") @@ -33,7 +33,7 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Maximum Length of Pair Chain](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-pair-chain) (Medium) + 1. [Maximum Length of Pair Chain](../maximum-length-of-pair-chain) (Medium) diff --git a/problems/increasing-triplet-subsequence/README.md b/problems/increasing-triplet-subsequence/README.md index 9dd4ff799..257fbdbac 100644 --- a/problems/increasing-triplet-subsequence/README.md +++ b/problems/increasing-triplet-subsequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/largest-bst-subtree "Largest BST Subtree") +[< Previous](../largest-bst-subtree "Largest BST Subtree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/self-crossing "Self Crossing") +[Next >](../self-crossing "Self Crossing") ## [334. Increasing Triplet Subsequence (Medium)](https://leetcode.com/problems/increasing-triplet-subsequence "递增的三元子序列") @@ -39,4 +39,4 @@ such that arr[i] < arr[j] < arr[k] given 0 ≤ i< ### Similar Questions - 1. [Longest Increasing Subsequence](https://github.com/openset/leetcode/tree/master/problems/longest-increasing-subsequence) (Medium) + 1. [Longest Increasing Subsequence](../longest-increasing-subsequence) (Medium) diff --git a/problems/index-pairs-of-a-string/README.md b/problems/index-pairs-of-a-string/README.md index 5de15d158..0c71f38f4 100644 --- a/problems/index-pairs-of-a-string/README.md +++ b/problems/index-pairs-of-a-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/fixed-point "Fixed Point") +[< Previous](../fixed-point "Fixed Point")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/campus-bikes-ii "Campus Bikes II") +[Next >](../campus-bikes-ii "Campus Bikes II") ## [1065. Index Pairs of a String (Easy)](https://leetcode.com/problems/index-pairs-of-a-string "字符串的索引对") @@ -45,8 +45,8 @@ Notice that matches can overlap, see "aba" is found in [0,2] and [2,4] ### Related Topics - [[Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Trie](../../tag/trie/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/inorder-successor-in-bst-ii/README.md b/problems/inorder-successor-in-bst-ii/README.md index 6248aadad..a9fc233de 100644 --- a/problems/inorder-successor-in-bst-ii/README.md +++ b/problems/inorder-successor-in-bst-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/fibonacci-number "Fibonacci Number") +[< Previous](../fibonacci-number "Fibonacci Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-i "Game Play Analysis I") +[Next >](../game-play-analysis-i "Game Play Analysis I") ## [510. Inorder Successor in BST II (Medium)](https://leetcode.com/problems/inorder-successor-in-bst-ii "二叉搜索树中的中序后继 II") @@ -74,7 +74,7 @@ p = 13

Could you solve it without looking up any of the node's values?

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Inorder Successor in BST](https://github.com/openset/leetcode/tree/master/problems/inorder-successor-in-bst) (Medium) + 1. [Inorder Successor in BST](../inorder-successor-in-bst) (Medium) diff --git a/problems/inorder-successor-in-bst/README.md b/problems/inorder-successor-in-bst/README.md index 94f17f008..649abbec5 100644 --- a/problems/inorder-successor-in-bst/README.md +++ b/problems/inorder-successor-in-bst/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/peeking-iterator "Peeking Iterator") +[< Previous](../peeking-iterator "Peeking Iterator")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/walls-and-gates "Walls and Gates") +[Next >](../walls-and-gates "Walls and Gates") ## [285. Inorder Successor in BST (Medium)](https://leetcode.com/problems/inorder-successor-in-bst "二叉搜索树中的顺序后继") @@ -41,9 +41,9 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Binary Tree Inorder Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-inorder-traversal) (Medium) - 1. [Binary Search Tree Iterator](https://github.com/openset/leetcode/tree/master/problems/binary-search-tree-iterator) (Medium) - 1. [Inorder Successor in BST II](https://github.com/openset/leetcode/tree/master/problems/inorder-successor-in-bst-ii) (Medium) + 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Medium) + 1. [Binary Search Tree Iterator](../binary-search-tree-iterator) (Medium) + 1. [Inorder Successor in BST II](../inorder-successor-in-bst-ii) (Medium) diff --git a/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md b/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md index 9fbae1c04..2dff0654c 100644 --- a/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md +++ b/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/insert-delete-getrandom-o1 "Insert Delete GetRandom O(1)") +[< Previous](../insert-delete-getrandom-o1 "Insert Delete GetRandom O(1)")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/linked-list-random-node "Linked List Random Node") +[Next >](../linked-list-random-node "Linked List Random Node") ## [381. Insert Delete GetRandom O(1) - Duplicates allowed (Hard)](https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed "O(1) 时间插入、删除和获取随机元素 - 允许重复") @@ -47,9 +47,9 @@ collection.getRandom();

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Insert Delete GetRandom O(1)](https://github.com/openset/leetcode/tree/master/problems/insert-delete-getrandom-o1) (Medium) + 1. [Insert Delete GetRandom O(1)](../insert-delete-getrandom-o1) (Medium) diff --git a/problems/insert-delete-getrandom-o1/README.md b/problems/insert-delete-getrandom-o1/README.md index 48c55f95a..3ce5e63e9 100644 --- a/problems/insert-delete-getrandom-o1/README.md +++ b/problems/insert-delete-getrandom-o1/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-phone-directory "Design Phone Directory") +[< Previous](../design-phone-directory "Design Phone Directory")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/insert-delete-getrandom-o1-duplicates-allowed "Insert Delete GetRandom O(1) - Duplicates allowed") +[Next >](../insert-delete-getrandom-o1-duplicates-allowed "Insert Delete GetRandom O(1) - Duplicates allowed") ## [380. Insert Delete GetRandom O(1) (Medium)](https://leetcode.com/problems/insert-delete-getrandom-o1 "常数时间插入、删除和获取随机元素") @@ -50,9 +50,9 @@ randomSet.getRandom();

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Insert Delete GetRandom O(1) - Duplicates allowed](https://github.com/openset/leetcode/tree/master/problems/insert-delete-getrandom-o1-duplicates-allowed) (Hard) + 1. [Insert Delete GetRandom O(1) - Duplicates allowed](../insert-delete-getrandom-o1-duplicates-allowed) (Hard) diff --git a/problems/insert-interval/README.md b/problems/insert-interval/README.md index a2c0cfd5e..55aa7affc 100644 --- a/problems/insert-interval/README.md +++ b/problems/insert-interval/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/merge-intervals "Merge Intervals") +[< Previous](../merge-intervals "Merge Intervals")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/length-of-last-word "Length of Last Word") +[Next >](../length-of-last-word "Length of Last Word") ## [57. Insert Interval (Hard)](https://leetcode.com/problems/insert-interval "插入区间") @@ -32,9 +32,9 @@

NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Merge Intervals](https://github.com/openset/leetcode/tree/master/problems/merge-intervals) (Medium) - 1. [Range Module](https://github.com/openset/leetcode/tree/master/problems/range-module) (Hard) + 1. [Merge Intervals](../merge-intervals) (Medium) + 1. [Range Module](../range-module) (Hard) diff --git a/problems/insert-into-a-binary-search-tree/README.md b/problems/insert-into-a-binary-search-tree/README.md index d4b358b18..aadc7c3a0 100644 --- a/problems/insert-into-a-binary-search-tree/README.md +++ b/problems/insert-into-a-binary-search-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/search-in-a-binary-search-tree "Search in a Binary Search Tree") +[< Previous](../search-in-a-binary-search-tree "Search in a Binary Search Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/search-in-a-sorted-array-of-unknown-size "Search in a Sorted Array of Unknown Size") +[Next >](../search-in-a-sorted-array-of-unknown-size "Search in a Sorted Array of Unknown Size") ## [701. Insert into a Binary Search Tree (Medium)](https://leetcode.com/problems/insert-into-a-binary-search-tree "二叉搜索树中的插入操作") @@ -50,7 +50,7 @@ And the value to insert: 5 ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Search in a Binary Search Tree](https://github.com/openset/leetcode/tree/master/problems/search-in-a-binary-search-tree) (Easy) + 1. [Search in a Binary Search Tree](../search-in-a-binary-search-tree) (Easy) diff --git a/problems/insert-into-a-sorted-circular-linked-list/README.md b/problems/insert-into-a-sorted-circular-linked-list/README.md index 532e92ac7..d1c4bc30b 100644 --- a/problems/insert-into-a-sorted-circular-linked-list/README.md +++ b/problems/insert-into-a-sorted-circular-linked-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-linked-list "Design Linked List") +[< Previous](../design-linked-list "Design Linked List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/to-lower-case "To Lower Case") +[Next >](../to-lower-case "To Lower Case") ## [708. Insert into a Sorted Circular Linked List (Medium)](https://leetcode.com/problems/insert-into-a-sorted-circular-linked-list "循环有序列表的插入") @@ -32,7 +32,7 @@ The new node should insert between node 1 and node 3. After the insertion, the list should look like this, and we should still return node 3.

### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Insertion Sort List](https://github.com/openset/leetcode/tree/master/problems/insertion-sort-list) (Medium) + 1. [Insertion Sort List](../insertion-sort-list) (Medium) diff --git a/problems/insertion-sort-list/README.md b/problems/insertion-sort-list/README.md index c1c8776f0..e91075c57 100644 --- a/problems/insertion-sort-list/README.md +++ b/problems/insertion-sort-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/lru-cache "LRU Cache") +[< Previous](../lru-cache "LRU Cache")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sort-list "Sort List") +[Next >](../sort-list "Sort List") ## [147. Insertion Sort List (Medium)](https://leetcode.com/problems/insertion-sort-list "对链表进行插入排序") @@ -48,9 +48,9 @@ With each iteration one element (red) is removed from the input data and inserte ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Sort List](https://github.com/openset/leetcode/tree/master/problems/sort-list) (Medium) - 1. [Insert into a Sorted Circular Linked List](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-sorted-circular-linked-list) (Medium) + 1. [Sort List](../sort-list) (Medium) + 1. [Insert into a Sorted Circular Linked List](../insert-into-a-sorted-circular-linked-list) (Medium) diff --git a/problems/insufficient-nodes-in-root-to-leaf-paths/README.md b/problems/insufficient-nodes-in-root-to-leaf-paths/README.md index 8c31b30a4..5b7fe7400 100644 --- a/problems/insufficient-nodes-in-root-to-leaf-paths/README.md +++ b/problems/insufficient-nodes-in-root-to-leaf-paths/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/letter-tile-possibilities "Letter Tile Possibilities") +[< Previous](../letter-tile-possibilities "Letter Tile Possibilities")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/smallest-subsequence-of-distinct-characters "Smallest Subsequence of Distinct Characters") +[Next >](../smallest-subsequence-of-distinct-characters "Smallest Subsequence of Distinct Characters") ## [1080. Insufficient Nodes in Root to Leaf Paths (Medium)](https://leetcode.com/problems/insufficient-nodes-in-root-to-leaf-paths "根到叶路径上的不足节点") @@ -63,7 +63,7 @@ Output: [1,null,-3,4] ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Hints
diff --git a/problems/integer-break/README.md b/problems/integer-break/README.md index 7e8ca366f..5cf4dc96f 100644 --- a/problems/integer-break/README.md +++ b/problems/integer-break/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/power-of-four "Power of Four") +[< Previous](../power-of-four "Power of Four")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reverse-string "Reverse String") +[Next >](../reverse-string "Reverse String") ## [343. Integer Break (Medium)](https://leetcode.com/problems/integer-break "整数拆分") @@ -34,8 +34,8 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/integer-replacement/README.md b/problems/integer-replacement/README.md index 919ebe4c9..a34ff2c94 100644 --- a/problems/integer-replacement/README.md +++ b/problems/integer-replacement/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/rotate-function "Rotate Function") +[< Previous](../rotate-function "Rotate Function")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/random-pick-index "Random Pick Index") +[Next >](../random-pick-index "Random Pick Index") ## [397. Integer Replacement (Medium)](https://leetcode.com/problems/integer-replacement "整数替换") @@ -57,5 +57,5 @@ or

### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/integer-to-english-words/README.md b/problems/integer-to-english-words/README.md index 4d9d65718..d606efbdb 100644 --- a/problems/integer-to-english-words/README.md +++ b/problems/integer-to-english-words/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/closest-binary-search-tree-value-ii "Closest Binary Search Tree Value II") +[< Previous](../closest-binary-search-tree-value-ii "Closest Binary Search Tree Value II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/h-index "H-Index") +[Next >](../h-index "H-Index") ## [273. Integer to English Words (Hard)](https://leetcode.com/problems/integer-to-english-words "整数转换英文表示") @@ -41,11 +41,11 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Integer to Roman](https://github.com/openset/leetcode/tree/master/problems/integer-to-roman) (Medium) + 1. [Integer to Roman](../integer-to-roman) (Medium) ### Hints
diff --git a/problems/integer-to-roman/README.md b/problems/integer-to-roman/README.md index 517255a16..3797f58c5 100644 --- a/problems/integer-to-roman/README.md +++ b/problems/integer-to-roman/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/container-with-most-water "Container With Most Water") +[< Previous](../container-with-most-water "Container With Most Water")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/roman-to-integer "Roman to Integer") +[Next >](../roman-to-integer "Roman to Integer") ## [12. Integer to Roman (Medium)](https://leetcode.com/problems/integer-to-roman "整数转罗马数字") @@ -69,9 +69,9 @@ M 1000 Explanation: M = 1000, CM = 900, XC = 90 and IV = 4. ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Roman to Integer](https://github.com/openset/leetcode/tree/master/problems/roman-to-integer) (Easy) - 1. [Integer to English Words](https://github.com/openset/leetcode/tree/master/problems/integer-to-english-words) (Hard) + 1. [Roman to Integer](../roman-to-integer) (Easy) + 1. [Integer to English Words](../integer-to-english-words) (Hard) diff --git a/problems/interleaving-string/README.md b/problems/interleaving-string/README.md index 720d1ab49..54ef595ff 100644 --- a/problems/interleaving-string/README.md +++ b/problems/interleaving-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/unique-binary-search-trees "Unique Binary Search Trees") +[< Previous](../unique-binary-search-trees "Unique Binary Search Trees")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/validate-binary-search-tree "Validate Binary Search Tree") +[Next >](../validate-binary-search-tree "Validate Binary Search Tree") ## [97. Interleaving String (Hard)](https://leetcode.com/problems/interleaving-string "交错字符串") @@ -28,5 +28,5 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/intersection-of-three-sorted-arrays/README.md b/problems/intersection-of-three-sorted-arrays/README.md index 1047c1ba3..0b5787a5e 100644 --- a/problems/intersection-of-three-sorted-arrays/README.md +++ b/problems/intersection-of-three-sorted-arrays/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/team-scores-in-football-tournament "Team Scores in Football Tournament") +[< Previous](../team-scores-in-football-tournament "Team Scores in Football Tournament")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/two-sum-bsts "Two Sum BSTs") +[Next >](../two-sum-bsts "Two Sum BSTs") ## [1213. Intersection of Three Sorted Arrays (Easy)](https://leetcode.com/problems/intersection-of-three-sorted-arrays "三个有序数组的交集") @@ -31,11 +31,11 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Intersection of Two Arrays](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays) (Easy) + 1. [Intersection of Two Arrays](../intersection-of-two-arrays) (Easy) ### Hints
diff --git a/problems/intersection-of-two-arrays-ii/README.md b/problems/intersection-of-two-arrays-ii/README.md index de9020c26..4bc295a48 100644 --- a/problems/intersection-of-two-arrays-ii/README.md +++ b/problems/intersection-of-two-arrays-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays "Intersection of Two Arrays") +[< Previous](../intersection-of-two-arrays "Intersection of Two Arrays")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/android-unlock-patterns "Android Unlock Patterns") +[Next >](../android-unlock-patterns "Android Unlock Patterns") ## [350. Intersection of Two Arrays II (Easy)](https://leetcode.com/problems/intersection-of-two-arrays-ii "两个数组的交集 II") @@ -44,11 +44,11 @@ ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Intersection of Two Arrays](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays) (Easy) - 1. [Find Common Characters](https://github.com/openset/leetcode/tree/master/problems/find-common-characters) (Easy) + 1. [Intersection of Two Arrays](../intersection-of-two-arrays) (Easy) + 1. [Find Common Characters](../find-common-characters) (Easy) diff --git a/problems/intersection-of-two-arrays/README.md b/problems/intersection-of-two-arrays/README.md index 503266cff..09355375f 100644 --- a/problems/intersection-of-two-arrays/README.md +++ b/problems/intersection-of-two-arrays/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-tic-tac-toe "Design Tic-Tac-Toe") +[< Previous](../design-tic-tac-toe "Design Tic-Tac-Toe")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays-ii "Intersection of Two Arrays II") +[Next >](../intersection-of-two-arrays-ii "Intersection of Two Arrays II") ## [349. Intersection of Two Arrays (Easy)](https://leetcode.com/problems/intersection-of-two-arrays "两个数组的交集") @@ -38,11 +38,11 @@

 

### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Intersection of Two Arrays II](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays-ii) (Easy) - 1. [Intersection of Three Sorted Arrays](https://github.com/openset/leetcode/tree/master/problems/intersection-of-three-sorted-arrays) (Easy) + 1. [Intersection of Two Arrays II](../intersection-of-two-arrays-ii) (Easy) + 1. [Intersection of Three Sorted Arrays](../intersection-of-three-sorted-arrays) (Easy) diff --git a/problems/intersection-of-two-linked-lists/README.md b/problems/intersection-of-two-linked-lists/README.md index 5cf0c6857..0d9777df9 100644 --- a/problems/intersection-of-two-linked-lists/README.md +++ b/problems/intersection-of-two-linked-lists/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters "Longest Substring with At Most Two Distinct Characters") +[< Previous](../longest-substring-with-at-most-two-distinct-characters "Longest Substring with At Most Two Distinct Characters")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/one-edit-distance "One Edit Distance") +[Next >](../one-edit-distance "One Edit Distance") ## [160. Intersection of Two Linked Lists (Easy)](https://leetcode.com/problems/intersection-of-two-linked-lists "相交链表") @@ -63,7 +63,7 @@ ### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Minimum Index Sum of Two Lists](https://github.com/openset/leetcode/tree/master/problems/minimum-index-sum-of-two-lists) (Easy) + 1. [Minimum Index Sum of Two Lists](../minimum-index-sum-of-two-lists) (Easy) diff --git a/problems/interval-list-intersections/README.md b/problems/interval-list-intersections/README.md index f9effce18..5b31fbeca 100644 --- a/problems/interval-list-intersections/README.md +++ b/problems/interval-list-intersections/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sum-of-even-numbers-after-queries "Sum of Even Numbers After Queries") +[< Previous](../sum-of-even-numbers-after-queries "Sum of Even Numbers After Queries")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/vertical-order-traversal-of-a-binary-tree "Vertical Order Traversal of a Binary Tree") +[Next >](../vertical-order-traversal-of-a-binary-tree "Vertical Order Traversal of a Binary Tree") ## [986. Interval List Intersections (Medium)](https://leetcode.com/problems/interval-list-intersections "区间列表的交集") @@ -44,9 +44,9 @@ ### Related Topics - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Merge Intervals](https://github.com/openset/leetcode/tree/master/problems/merge-intervals) (Medium) - 1. [Merge Sorted Array](https://github.com/openset/leetcode/tree/master/problems/merge-sorted-array) (Easy) - 1. [Employee Free Time](https://github.com/openset/leetcode/tree/master/problems/employee-free-time) (Hard) + 1. [Merge Intervals](../merge-intervals) (Medium) + 1. [Merge Sorted Array](../merge-sorted-array) (Easy) + 1. [Employee Free Time](../employee-free-time) (Hard) diff --git a/problems/invalid-transactions/README.md b/problems/invalid-transactions/README.md index 8b4fb7a99..efdd20ee9 100644 --- a/problems/invalid-transactions/README.md +++ b/problems/invalid-transactions/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/optimize-water-distribution-in-a-village "Optimize Water Distribution in a Village") +[< Previous](../optimize-water-distribution-in-a-village "Optimize Water Distribution in a Village")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/compare-strings-by-frequency-of-the-smallest-character "Compare Strings by Frequency of the Smallest Character") +[Next >](../compare-strings-by-frequency-of-the-smallest-character "Compare Strings by Frequency of the Smallest Character") ## [1169. Invalid Transactions (Medium)](https://leetcode.com/problems/invalid-transactions "查询无效交易") @@ -56,8 +56,8 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/invert-binary-tree/README.md b/problems/invert-binary-tree/README.md index 3396784cb..10154674f 100644 --- a/problems/invert-binary-tree/README.md +++ b/problems/invert-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/implement-stack-using-queues "Implement Stack using Queues") +[< Previous](../implement-stack-using-queues "Implement Stack using Queues")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-ii "Basic Calculator II") +[Next >](../basic-calculator-ii "Basic Calculator II") ## [226. Invert Binary Tree (Easy)](https://leetcode.com/problems/invert-binary-tree "翻转二叉树") @@ -39,4 +39,4 @@ This problem was inspired by ](https://github.com/openset/leetcode/tree/master/problems/customer-placing-the-largest-number-of-orders "Customer Placing the Largest Number of Orders") +[Next >](../customer-placing-the-largest-number-of-orders "Customer Placing the Largest Number of Orders") ## [585. Investments in 2016 (Medium)](https://leetcode.com/problems/investments-in-2016 "2016年的投资") diff --git a/problems/ip-to-cidr/README.md b/problems/ip-to-cidr/README.md index c12274628..4d421dba8 100644 --- a/problems/ip-to-cidr/README.md +++ b/problems/ip-to-cidr/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-corner-rectangles "Number Of Corner Rectangles") +[< Previous](../number-of-corner-rectangles "Number Of Corner Rectangles")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/open-the-lock "Open the Lock") +[Next >](../open-the-lock "Open the Lock") ## [751. IP to CIDR (Easy)](https://leetcode.com/problems/ip-to-cidr "IP 到 CIDR") @@ -63,11 +63,11 @@ that are outside the specified range.

### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions - 1. [Restore IP Addresses](https://github.com/openset/leetcode/tree/master/problems/restore-ip-addresses) (Medium) - 1. [Validate IP Address](https://github.com/openset/leetcode/tree/master/problems/validate-ip-address) (Medium) + 1. [Restore IP Addresses](../restore-ip-addresses) (Medium) + 1. [Validate IP Address](../validate-ip-address) (Medium) ### Hints
diff --git a/problems/ipo/README.md b/problems/ipo/README.md index e8b474d5b..91afc78e3 100644 --- a/problems/ipo/README.md +++ b/problems/ipo/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-mode-in-binary-search-tree "Find Mode in Binary Search Tree") +[< Previous](../find-mode-in-binary-search-tree "Find Mode in Binary Search Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-ii "Next Greater Element II") +[Next >](../next-greater-element-ii "Next Greater Element II") ## [502. IPO (Hard)](https://leetcode.com/problems/ipo "IPO") @@ -46,5 +46,5 @@ To sum up, pick a list of at most k distinct projects from given projects

### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/is-graph-bipartite/README.md b/problems/is-graph-bipartite/README.md index 207186c72..f3f0bc575 100644 --- a/problems/is-graph-bipartite/README.md +++ b/problems/is-graph-bipartite/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/letter-case-permutation "Letter Case Permutation") +[< Previous](../letter-case-permutation "Letter Case Permutation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/k-th-smallest-prime-fraction "K-th Smallest Prime Fraction") +[Next >](../k-th-smallest-prime-fraction "K-th Smallest Prime Fraction") ## [785. Is Graph Bipartite? (Medium)](https://leetcode.com/problems/is-graph-bipartite "判断二分图") @@ -55,6 +55,6 @@ We cannot find a way to divide the set of nodes into two independent subsets. ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] diff --git a/problems/is-subsequence/README.md b/problems/is-subsequence/README.md index a143bde41..283334728 100644 --- a/problems/is-subsequence/README.md +++ b/problems/is-subsequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/perfect-rectangle "Perfect Rectangle") +[< Previous](../perfect-rectangle "Perfect Rectangle")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/utf-8-validation "UTF-8 Validation") +[Next >](../utf-8-validation "UTF-8 Validation") ## [392. Is Subsequence (Easy)](https://leetcode.com/problems/is-subsequence "判断子序列") @@ -43,10 +43,10 @@ If there are lots of incoming S, say S1, S2, ... , Sk where k >= 1B, and you wan

Credits:
Special thanks to
@pbrother for adding this problem and creating all test cases.

### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Number of Matching Subsequences](https://github.com/openset/leetcode/tree/master/problems/number-of-matching-subsequences) (Medium) - 1. [Shortest Way to Form String](https://github.com/openset/leetcode/tree/master/problems/shortest-way-to-form-string) (Medium) + 1. [Number of Matching Subsequences](../number-of-matching-subsequences) (Medium) + 1. [Shortest Way to Form String](../shortest-way-to-form-string) (Medium) diff --git a/problems/island-perimeter/README.md b/problems/island-perimeter/README.md index 3554e4726..8d27bd661 100644 --- a/problems/island-perimeter/README.md +++ b/problems/island-perimeter/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-equal-array-elements-ii "Minimum Moves to Equal Array Elements II") +[< Previous](../minimum-moves-to-equal-array-elements-ii "Minimum Moves to Equal Array Elements II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/can-i-win "Can I Win") +[Next >](../can-i-win "Can I Win") ## [463. Island Perimeter (Easy)](https://leetcode.com/problems/island-perimeter "岛屿的周长") @@ -36,9 +36,9 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Max Area of Island](https://github.com/openset/leetcode/tree/master/problems/max-area-of-island) (Medium) - 1. [Flood Fill](https://github.com/openset/leetcode/tree/master/problems/flood-fill) (Easy) - 1. [Coloring A Border](https://github.com/openset/leetcode/tree/master/problems/coloring-a-border) (Medium) + 1. [Max Area of Island](../max-area-of-island) (Medium) + 1. [Flood Fill](../flood-fill) (Easy) + 1. [Coloring A Border](../coloring-a-border) (Medium) diff --git a/problems/isomorphic-strings/README.md b/problems/isomorphic-strings/README.md index 592ffa1f0..1634e7f3d 100644 --- a/problems/isomorphic-strings/README.md +++ b/problems/isomorphic-strings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/count-primes "Count Primes") +[< Previous](../count-primes "Count Primes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reverse-linked-list "Reverse Linked List") +[Next >](../reverse-linked-list "Reverse Linked List") ## [205. Isomorphic Strings (Easy)](https://leetcode.com/problems/isomorphic-strings "同构字符串") @@ -40,7 +40,7 @@ You may assume both and have the same length.

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Word Pattern](https://github.com/openset/leetcode/tree/master/problems/word-pattern) (Easy) + 1. [Word Pattern](../word-pattern) (Easy) diff --git a/problems/iterator-for-combination/README.md b/problems/iterator-for-combination/README.md index b4b1c9239..f4afa69bc 100644 --- a/problems/iterator-for-combination/README.md +++ b/problems/iterator-for-combination/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-the-start-and-end-number-of-continuous-ranges "Find the Start and End Number of Continuous Ranges") +[< Previous](../find-the-start-and-end-number-of-continuous-ranges "Find the Start and End Number of Continuous Ranges")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/element-appearing-more-than-25-in-sorted-array "Element Appearing More Than 25% In Sorted Array") +[Next >](../element-appearing-more-than-25-in-sorted-array "Element Appearing More Than 25% In Sorted Array") ## [1286. Iterator for Combination (Medium)](https://leetcode.com/problems/iterator-for-combination "字母组合迭代器") @@ -44,8 +44,8 @@ iterator.hasNext(); // returns false ### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Design](../../tag/design/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Hints
diff --git a/problems/jewels-and-stones/README.md b/problems/jewels-and-stones/README.md index 5a026378d..62e973d48 100644 --- a/problems/jewels-and-stones/README.md +++ b/problems/jewels-and-stones/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iv "Basic Calculator IV") +[< Previous](../basic-calculator-iv "Basic Calculator IV")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iii "Basic Calculator III") +[Next >](../basic-calculator-iii "Basic Calculator III") ## [771. Jewels and Stones (Easy)](https://leetcode.com/problems/jewels-and-stones "宝石与石头") @@ -37,7 +37,7 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
diff --git a/problems/jump-game-ii/README.md b/problems/jump-game-ii/README.md index d6de691f2..9a57479a2 100644 --- a/problems/jump-game-ii/README.md +++ b/problems/jump-game-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/wildcard-matching "Wildcard Matching") +[< Previous](../wildcard-matching "Wildcard Matching")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/permutations "Permutations") +[Next >](../permutations "Permutations") ## [45. Jump Game II (Hard)](https://leetcode.com/problems/jump-game-ii "跳跃游戏 II") @@ -30,8 +30,8 @@

You can assume that you can always reach the last index.

### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Jump Game](https://github.com/openset/leetcode/tree/master/problems/jump-game) (Medium) + 1. [Jump Game](../jump-game) (Medium) diff --git a/problems/jump-game/README.md b/problems/jump-game/README.md index 953be26d3..73f8105a1 100644 --- a/problems/jump-game/README.md +++ b/problems/jump-game/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/spiral-matrix "Spiral Matrix") +[< Previous](../spiral-matrix "Spiral Matrix")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/merge-intervals "Merge Intervals") +[Next >](../merge-intervals "Merge Intervals") ## [55. Jump Game (Medium)](https://leetcode.com/problems/jump-game "跳跃游戏") @@ -35,8 +35,8 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Jump Game II](https://github.com/openset/leetcode/tree/master/problems/jump-game-ii) (Hard) + 1. [Jump Game II](../jump-game-ii) (Hard) diff --git a/problems/k-closest-points-to-origin/README.md b/problems/k-closest-points-to-origin/README.md index f406cbe11..4ae0f6d86 100644 --- a/problems/k-closest-points-to-origin/README.md +++ b/problems/k-closest-points-to-origin/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/equal-rational-numbers "Equal Rational Numbers") +[< Previous](../equal-rational-numbers "Equal Rational Numbers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/subarray-sums-divisible-by-k "Subarray Sums Divisible by K") +[Next >](../subarray-sums-divisible-by-k "Subarray Sums Divisible by K") ## [973. K Closest Points to Origin (Medium)](https://leetcode.com/problems/k-closest-points-to-origin "最接近原点的 K 个点") @@ -54,11 +54,11 @@ We only want the closest K = 1 points from the origin, so the answer is just [[- ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions - 1. [Kth Largest Element in an Array](https://github.com/openset/leetcode/tree/master/problems/kth-largest-element-in-an-array) (Medium) - 1. [Top K Frequent Elements](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-elements) (Medium) - 1. [Top K Frequent Words](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-words) (Medium) + 1. [Kth Largest Element in an Array](../kth-largest-element-in-an-array) (Medium) + 1. [Top K Frequent Elements](../top-k-frequent-elements) (Medium) + 1. [Top K Frequent Words](../top-k-frequent-words) (Medium) diff --git a/problems/k-concatenation-maximum-sum/README.md b/problems/k-concatenation-maximum-sum/README.md index a369f31d3..5e6b5ecb3 100644 --- a/problems/k-concatenation-maximum-sum/README.md +++ b/problems/k-concatenation-maximum-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reverse-substrings-between-each-pair-of-parentheses "Reverse Substrings Between Each Pair of Parentheses") +[< Previous](../reverse-substrings-between-each-pair-of-parentheses "Reverse Substrings Between Each Pair of Parentheses")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/critical-connections-in-a-network "Critical Connections in a Network") +[Next >](../critical-connections-in-a-network "Critical Connections in a Network") ## [1191. K-Concatenation Maximum Sum (Medium)](https://leetcode.com/problems/k-concatenation-maximum-sum "K 次串联后最大子数组之和") @@ -51,7 +51,7 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/k-diff-pairs-in-an-array/README.md b/problems/k-diff-pairs-in-an-array/README.md index 79fe9d09a..0a12fb1b7 100644 --- a/problems/k-diff-pairs-in-an-array/README.md +++ b/problems/k-diff-pairs-in-an-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/lonely-pixel-i "Lonely Pixel I") +[< Previous](../lonely-pixel-i "Lonely Pixel I")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/lonely-pixel-ii "Lonely Pixel II") +[Next >](../lonely-pixel-ii "Lonely Pixel II") ## [532. K-diff Pairs in an Array (Easy)](https://leetcode.com/problems/k-diff-pairs-in-an-array "数组中的K-diff数对") @@ -49,8 +49,8 @@ Given an array of integers and an integer k, you need to find the number

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Minimum Absolute Difference in BST](https://github.com/openset/leetcode/tree/master/problems/minimum-absolute-difference-in-bst) (Easy) + 1. [Minimum Absolute Difference in BST](../minimum-absolute-difference-in-bst) (Easy) diff --git a/problems/k-empty-slots/README.md b/problems/k-empty-slots/README.md index 0ef804aff..6057ff73a 100644 --- a/problems/k-empty-slots/README.md +++ b/problems/k-empty-slots/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/baseball-game "Baseball Game") +[< Previous](../baseball-game "Baseball Game")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/redundant-connection "Redundant Connection") +[Next >](../redundant-connection "Redundant Connection") ## [683. K Empty Slots (Hard)](https://leetcode.com/problems/k-empty-slots "K 个空花盆") @@ -56,4 +56,4 @@ K: 1 ### Related Topics - [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] + [[Ordered Map](../../tag/ordered-map/README.md)] diff --git a/problems/k-inverse-pairs-array/README.md b/problems/k-inverse-pairs-array/README.md index 992df9c84..e1c7a717d 100644 --- a/problems/k-inverse-pairs-array/README.md +++ b/problems/k-inverse-pairs-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-product-of-three-numbers "Maximum Product of Three Numbers") +[< Previous](../maximum-product-of-three-numbers "Maximum Product of Three Numbers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/course-schedule-iii "Course Schedule III") +[Next >](../course-schedule-iii "Course Schedule III") ## [629. K Inverse Pairs Array (Hard)](https://leetcode.com/problems/k-inverse-pairs-array "K个逆序对数组") @@ -48,4 +48,4 @@ The array [1,3,2] and [2,1,3] have exactly 1 inverse pair.

 

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/k-similar-strings/README.md b/problems/k-similar-strings/README.md index df0aea392..66df9c7bd 100644 --- a/problems/k-similar-strings/README.md +++ b/problems/k-similar-strings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/car-fleet "Car Fleet") +[< Previous](../car-fleet "Car Fleet")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/exam-room "Exam Room") +[Next >](../exam-room "Exam Room") ## [854. K-Similar Strings (Hard)](https://leetcode.com/problems/k-similar-strings "相似度为 K 的字符串") @@ -56,8 +56,8 @@ ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] ### Similar Questions - 1. [Couples Holding Hands](https://github.com/openset/leetcode/tree/master/problems/couples-holding-hands) (Hard) + 1. [Couples Holding Hands](../couples-holding-hands) (Hard) diff --git a/problems/k-th-smallest-in-lexicographical-order/README.md b/problems/k-th-smallest-in-lexicographical-order/README.md index 14c0b9193..23765647c 100644 --- a/problems/k-th-smallest-in-lexicographical-order/README.md +++ b/problems/k-th-smallest-in-lexicographical-order/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/ternary-expression-parser "Ternary Expression Parser") +[< Previous](../ternary-expression-parser "Ternary Expression Parser")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/arranging-coins "Arranging Coins") +[Next >](../arranging-coins "Arranging Coins") ## [440. K-th Smallest in Lexicographical Order (Hard)](https://leetcode.com/problems/k-th-smallest-in-lexicographical-order "字典序的第K小数字") diff --git a/problems/k-th-smallest-prime-fraction/README.md b/problems/k-th-smallest-prime-fraction/README.md index 9ef5aace3..e93afd957 100644 --- a/problems/k-th-smallest-prime-fraction/README.md +++ b/problems/k-th-smallest-prime-fraction/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/is-graph-bipartite "Is Graph Bipartite?") +[< Previous](../is-graph-bipartite "Is Graph Bipartite?")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/cheapest-flights-within-k-stops "Cheapest Flights Within K Stops") +[Next >](../cheapest-flights-within-k-stops "Cheapest Flights Within K Stops") ## [786. K-th Smallest Prime Fraction (Hard)](https://leetcode.com/problems/k-th-smallest-prime-fraction "第 K 个最小的素数分数") @@ -37,10 +37,10 @@ The third fraction is 2/5. ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Kth Smallest Element in a Sorted Matrix](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-element-in-a-sorted-matrix) (Medium) - 1. [Kth Smallest Number in Multiplication Table](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-number-in-multiplication-table) (Hard) - 1. [Find K-th Smallest Pair Distance](https://github.com/openset/leetcode/tree/master/problems/find-k-th-smallest-pair-distance) (Hard) + 1. [Kth Smallest Element in a Sorted Matrix](../kth-smallest-element-in-a-sorted-matrix) (Medium) + 1. [Kth Smallest Number in Multiplication Table](../kth-smallest-number-in-multiplication-table) (Hard) + 1. [Find K-th Smallest Pair Distance](../find-k-th-smallest-pair-distance) (Hard) diff --git a/problems/k-th-symbol-in-grammar/README.md b/problems/k-th-symbol-in-grammar/README.md index b876f07f3..d358592df 100644 --- a/problems/k-th-symbol-in-grammar/README.md +++ b/problems/k-th-symbol-in-grammar/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/swim-in-rising-water "Swim in Rising Water") +[< Previous](../swim-in-rising-water "Swim in Rising Water")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reaching-points "Reaching Points") +[Next >](../reaching-points "Reaching Points") ## [779. K-th Symbol in Grammar (Medium)](https://leetcode.com/problems/k-th-symbol-in-grammar "第K个语法符号") @@ -44,7 +44,7 @@ row 4: 01101001 ### Related Topics - [[Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Hints
diff --git a/problems/keyboard-row/README.md b/problems/keyboard-row/README.md index a233ceb2a..78137a474 100644 --- a/problems/keyboard-row/README.md +++ b/problems/keyboard-row/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/the-maze-iii "The Maze III") +[< Previous](../the-maze-iii "The Maze III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-mode-in-binary-search-tree "Find Mode in Binary Search Tree") +[Next >](../find-mode-in-binary-search-tree "Find Mode in Binary Search Tree") ## [500. Keyboard Row (Easy)](https://leetcode.com/problems/keyboard-row "键盘行") @@ -35,4 +35,4 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/keys-and-rooms/README.md b/problems/keys-and-rooms/README.md index 122a65ab9..b229c3f06 100644 --- a/problems/keys-and-rooms/README.md +++ b/problems/keys-and-rooms/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/magic-squares-in-grid "Magic Squares In Grid") +[< Previous](../magic-squares-in-grid "Magic Squares In Grid")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/split-array-into-fibonacci-sequence "Split Array into Fibonacci Sequence") +[Next >](../split-array-into-fibonacci-sequence "Split Array into Fibonacci Sequence") ## [841. Keys and Rooms (Medium)](https://leetcode.com/problems/keys-and-rooms "钥匙和房间") @@ -53,5 +53,5 @@ We then go to room 3. Since we were able to go to every room, we return true. ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] diff --git a/problems/kill-process/README.md b/problems/kill-process/README.md index 5b6be6ce7..3df553616 100644 --- a/problems/kill-process/README.md +++ b/problems/kill-process/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-unsorted-continuous-subarray "Shortest Unsorted Continuous Subarray") +[< Previous](../shortest-unsorted-continuous-subarray "Shortest Unsorted Continuous Subarray")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/delete-operation-for-two-strings "Delete Operation for Two Strings") +[Next >](../delete-operation-for-two-strings "Delete Operation for Two Strings") ## [582. Kill Process (Medium)](https://leetcode.com/problems/kill-process "杀死进程") @@ -43,5 +43,5 @@ Kill 5 will also kill 10.

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Queue](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Queue](../../tag/queue/README.md)] diff --git a/problems/knight-dialer/README.md b/problems/knight-dialer/README.md index f6deb9d5b..03fc04211 100644 --- a/problems/knight-dialer/README.md +++ b/problems/knight-dialer/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-bridge "Shortest Bridge") +[< Previous](../shortest-bridge "Shortest Bridge")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/stamping-the-sequence "Stamping The Sequence") +[Next >](../stamping-the-sequence "Stamping The Sequence") ## [935. Knight Dialer (Medium)](https://leetcode.com/problems/knight-dialer "骑士拨号器") @@ -66,4 +66,4 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/knight-probability-in-chessboard/README.md b/problems/knight-probability-in-chessboard/README.md index 107cb01d1..aa82f4b46 100644 --- a/problems/knight-probability-in-chessboard/README.md +++ b/problems/knight-probability-in-chessboard/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-univalue-path "Longest Univalue Path") +[< Previous](../longest-univalue-path "Longest Univalue Path")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-sum-of-3-non-overlapping-subarrays "Maximum Sum of 3 Non-Overlapping Subarrays") +[Next >](../maximum-sum-of-3-non-overlapping-subarrays "Maximum Sum of 3 Non-Overlapping Subarrays") ## [688. Knight Probability in Chessboard (Medium)](https://leetcode.com/problems/knight-probability-in-chessboard "“马”在棋盘上的概率") @@ -48,7 +48,7 @@ The total probability the knight stays on the board is 0.0625. ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Out of Boundary Paths](https://github.com/openset/leetcode/tree/master/problems/out-of-boundary-paths) (Medium) + 1. [Out of Boundary Paths](../out-of-boundary-paths) (Medium) diff --git a/problems/koko-eating-bananas/README.md b/problems/koko-eating-bananas/README.md index 1d6dba0f0..92d7f7133 100644 --- a/problems/koko-eating-bananas/README.md +++ b/problems/koko-eating-bananas/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/walking-robot-simulation "Walking Robot Simulation") +[< Previous](../walking-robot-simulation "Walking Robot Simulation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/middle-of-the-linked-list "Middle of the Linked List") +[Next >](../middle-of-the-linked-list "Middle of the Linked List") ## [875. Koko Eating Bananas (Medium)](https://leetcode.com/problems/koko-eating-bananas "爱吃香蕉的珂珂") @@ -62,7 +62,7 @@ ### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Minimize Max Distance to Gas Station](https://github.com/openset/leetcode/tree/master/problems/minimize-max-distance-to-gas-station) (Hard) + 1. [Minimize Max Distance to Gas Station](../minimize-max-distance-to-gas-station) (Hard) diff --git a/problems/kth-largest-element-in-a-stream/README.md b/problems/kth-largest-element-in-a-stream/README.md index 5aa77bc9c..8b25667eb 100644 --- a/problems/kth-largest-element-in-a-stream/README.md +++ b/problems/kth-largest-element-in-a-stream/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/search-in-a-sorted-array-of-unknown-size "Search in a Sorted Array of Unknown Size") +[< Previous](../search-in-a-sorted-array-of-unknown-size "Search in a Sorted Array of Unknown Size")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-search "Binary Search") +[Next >](../binary-search "Binary Search") ## [703. Kth Largest Element in a Stream (Easy)](https://leetcode.com/problems/kth-largest-element-in-a-stream "数据流中的第K大元素") @@ -32,7 +32,7 @@ kthLargest.add(4);   // returns 8 You may assume that nums' length ≥ k-1 and k ≥ 1.

### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] + [[Heap](../../tag/heap/README.md)] ### Similar Questions - 1. [Kth Largest Element in an Array](https://github.com/openset/leetcode/tree/master/problems/kth-largest-element-in-an-array) (Medium) + 1. [Kth Largest Element in an Array](../kth-largest-element-in-an-array) (Medium) diff --git a/problems/kth-largest-element-in-an-array/README.md b/problems/kth-largest-element-in-an-array/README.md index 301b0c4d3..e3227feed 100644 --- a/problems/kth-largest-element-in-an-array/README.md +++ b/problems/kth-largest-element-in-an-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-palindrome "Shortest Palindrome") +[< Previous](../shortest-palindrome "Shortest Palindrome")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/combination-sum-iii "Combination Sum III") +[Next >](../combination-sum-iii "Combination Sum III") ## [215. Kth Largest Element in an Array (Medium)](https://leetcode.com/problems/kth-largest-element-in-an-array "数组中的第K个最大元素") @@ -30,12 +30,12 @@ You may assume k is always valid, 1 ≤ k ≤ array's length.

### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions - 1. [Wiggle Sort II](https://github.com/openset/leetcode/tree/master/problems/wiggle-sort-ii) (Medium) - 1. [Top K Frequent Elements](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-elements) (Medium) - 1. [Third Maximum Number](https://github.com/openset/leetcode/tree/master/problems/third-maximum-number) (Easy) - 1. [Kth Largest Element in a Stream](https://github.com/openset/leetcode/tree/master/problems/kth-largest-element-in-a-stream) (Easy) - 1. [K Closest Points to Origin](https://github.com/openset/leetcode/tree/master/problems/k-closest-points-to-origin) (Medium) + 1. [Wiggle Sort II](../wiggle-sort-ii) (Medium) + 1. [Top K Frequent Elements](../top-k-frequent-elements) (Medium) + 1. [Third Maximum Number](../third-maximum-number) (Easy) + 1. [Kth Largest Element in a Stream](../kth-largest-element-in-a-stream) (Easy) + 1. [K Closest Points to Origin](../k-closest-points-to-origin) (Medium) diff --git a/problems/kth-smallest-element-in-a-bst/README.md b/problems/kth-smallest-element-in-a-bst/README.md index 9800e1247..a071458bd 100644 --- a/problems/kth-smallest-element-in-a-bst/README.md +++ b/problems/kth-smallest-element-in-a-bst/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/majority-element-ii "Majority Element II") +[< Previous](../majority-element-ii "Majority Element II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/power-of-two "Power of Two") +[Next >](../power-of-two "Power of Two") ## [230. Kth Smallest Element in a BST (Medium)](https://leetcode.com/problems/kth-smallest-element-in-a-bst "二叉搜索树中第K小的元素") @@ -45,12 +45,12 @@ You may assume k is always valid, 1 ≤ k ≤ BST's total elements.

What if the BST is modified (insert/delete operations) often and you need to find the kth smallest frequently? How would you optimize the kthSmallest routine?

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Binary Tree Inorder Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-inorder-traversal) (Medium) - 1. [Second Minimum Node In a Binary Tree](https://github.com/openset/leetcode/tree/master/problems/second-minimum-node-in-a-binary-tree) (Easy) + 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Medium) + 1. [Second Minimum Node In a Binary Tree](../second-minimum-node-in-a-binary-tree) (Easy) ### Hints
diff --git a/problems/kth-smallest-element-in-a-sorted-matrix/README.md b/problems/kth-smallest-element-in-a-sorted-matrix/README.md index 51d45f218..ae807bcb4 100644 --- a/problems/kth-smallest-element-in-a-sorted-matrix/README.md +++ b/problems/kth-smallest-element-in-a-sorted-matrix/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/combination-sum-iv "Combination Sum IV") +[< Previous](../combination-sum-iv "Combination Sum IV")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-phone-directory "Design Phone Directory") +[Next >](../design-phone-directory "Design Phone Directory") ## [378. Kth Smallest Element in a Sorted Matrix (Medium)](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix "有序矩阵中第K小的元素") @@ -34,11 +34,11 @@ return 13. You may assume k is always valid, 1 ≤ k ≤ n2.

### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Find K Pairs with Smallest Sums](https://github.com/openset/leetcode/tree/master/problems/find-k-pairs-with-smallest-sums) (Medium) - 1. [Kth Smallest Number in Multiplication Table](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-number-in-multiplication-table) (Hard) - 1. [Find K-th Smallest Pair Distance](https://github.com/openset/leetcode/tree/master/problems/find-k-th-smallest-pair-distance) (Hard) - 1. [K-th Smallest Prime Fraction](https://github.com/openset/leetcode/tree/master/problems/k-th-smallest-prime-fraction) (Hard) + 1. [Find K Pairs with Smallest Sums](../find-k-pairs-with-smallest-sums) (Medium) + 1. [Kth Smallest Number in Multiplication Table](../kth-smallest-number-in-multiplication-table) (Hard) + 1. [Find K-th Smallest Pair Distance](../find-k-th-smallest-pair-distance) (Hard) + 1. [K-th Smallest Prime Fraction](../k-th-smallest-prime-fraction) (Hard) diff --git a/problems/kth-smallest-number-in-multiplication-table/README.md b/problems/kth-smallest-number-in-multiplication-table/README.md index 6711926e3..c8243b0af 100644 --- a/problems/kth-smallest-number-in-multiplication-table/README.md +++ b/problems/kth-smallest-number-in-multiplication-table/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/beautiful-arrangement-ii "Beautiful Arrangement II") +[< Previous](../beautiful-arrangement-ii "Beautiful Arrangement II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/trim-a-binary-search-tree "Trim a Binary Search Tree") +[Next >](../trim-a-binary-search-tree "Trim a Binary Search Tree") ## [668. Kth Smallest Number in Multiplication Table (Hard)](https://leetcode.com/problems/kth-smallest-number-in-multiplication-table "乘法表中第k小的数") @@ -56,9 +56,9 @@ The 6-th smallest number is 6 (1, 2, 2, 3, 4, 6).

### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Kth Smallest Element in a Sorted Matrix](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-element-in-a-sorted-matrix) (Medium) - 1. [Find K-th Smallest Pair Distance](https://github.com/openset/leetcode/tree/master/problems/find-k-th-smallest-pair-distance) (Hard) - 1. [K-th Smallest Prime Fraction](https://github.com/openset/leetcode/tree/master/problems/k-th-smallest-prime-fraction) (Hard) + 1. [Kth Smallest Element in a Sorted Matrix](../kth-smallest-element-in-a-sorted-matrix) (Medium) + 1. [Find K-th Smallest Pair Distance](../find-k-th-smallest-pair-distance) (Hard) + 1. [K-th Smallest Prime Fraction](../k-th-smallest-prime-fraction) (Hard) diff --git a/problems/largest-1-bordered-square/README.md b/problems/largest-1-bordered-square/README.md index acb3d3a76..be8fb3820 100644 --- a/problems/largest-1-bordered-square/README.md +++ b/problems/largest-1-bordered-square/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/alphabet-board-path "Alphabet Board Path") +[< Previous](../alphabet-board-path "Alphabet Board Path")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/stone-game-ii "Stone Game II") +[Next >](../stone-game-ii "Stone Game II") ## [1139. Largest 1-Bordered Square (Medium)](https://leetcode.com/problems/largest-1-bordered-square "最大的以 1 为边界的正方形") @@ -38,7 +38,7 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/largest-bst-subtree/README.md b/problems/largest-bst-subtree/README.md index 3bc73859a..b2905ff2b 100644 --- a/problems/largest-bst-subtree/README.md +++ b/problems/largest-bst-subtree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reconstruct-itinerary "Reconstruct Itinerary") +[< Previous](../reconstruct-itinerary "Reconstruct Itinerary")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/increasing-triplet-subsequence "Increasing Triplet Subsequence") +[Next >](../increasing-triplet-subsequence "Increasing Triplet Subsequence") ## [333. Largest BST Subtree (Medium)](https://leetcode.com/problems/largest-bst-subtree "最大 BST 子树") @@ -36,7 +36,7 @@ A subtree must include all of its descendants.

Can you figure out ways to solve it with O(n) time complexity?

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Hints
diff --git a/problems/largest-component-size-by-common-factor/README.md b/problems/largest-component-size-by-common-factor/README.md index f30b527f9..b163c0f50 100644 --- a/problems/largest-component-size-by-common-factor/README.md +++ b/problems/largest-component-size-by-common-factor/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/flip-equivalent-binary-trees "Flip Equivalent Binary Trees") +[< Previous](../flip-equivalent-binary-trees "Flip Equivalent Binary Trees")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/verifying-an-alien-dictionary "Verifying an Alien Dictionary") +[Next >](../verifying-an-alien-dictionary "Verifying an Alien Dictionary") ## [952. Largest Component Size by Common Factor (Hard)](https://leetcode.com/problems/largest-component-size-by-common-factor "按公因数计算最大组件大小") @@ -63,5 +63,5 @@ ### Related Topics - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/largest-divisible-subset/README.md b/problems/largest-divisible-subset/README.md index 802b0b65e..50f2cf432 100644 --- a/problems/largest-divisible-subset/README.md +++ b/problems/largest-divisible-subset/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-perfect-square "Valid Perfect Square") +[< Previous](../valid-perfect-square "Valid Perfect Square")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/plus-one-linked-list "Plus One Linked List") +[Next >](../plus-one-linked-list "Plus One Linked List") ## [368. Largest Divisible Subset (Medium)](https://leetcode.com/problems/largest-divisible-subset "最大整除子集") @@ -36,5 +36,5 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/largest-number-at-least-twice-of-others/README.md b/problems/largest-number-at-least-twice-of-others/README.md index 661744bae..83800b4a8 100644 --- a/problems/largest-number-at-least-twice-of-others/README.md +++ b/problems/largest-number-at-least-twice-of-others/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/min-cost-climbing-stairs "Min Cost Climbing Stairs") +[< Previous](../min-cost-climbing-stairs "Min Cost Climbing Stairs")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-completing-word "Shortest Completing Word") +[Next >](../shortest-completing-word "Shortest Completing Word") ## [747. Largest Number At Least Twice of Others (Easy)](https://leetcode.com/problems/largest-number-at-least-twice-of-others "至少是其他数字两倍的最大数") @@ -48,7 +48,7 @@

 

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/largest-number/README.md b/problems/largest-number/README.md index ba5e7c7ac..a0f8e0e6a 100644 --- a/problems/largest-number/README.md +++ b/problems/largest-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/rank-scores "Rank Scores") +[< Previous](../rank-scores "Rank Scores")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/consecutive-numbers "Consecutive Numbers") +[Next >](../consecutive-numbers "Consecutive Numbers") ## [179. Largest Number (Medium)](https://leetcode.com/problems/largest-number "最大数") @@ -29,4 +29,4 @@

Note: The result may be very large, so you need to return a string instead of an integer.

### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] + [[Sort](../../tag/sort/README.md)] diff --git a/problems/largest-palindrome-product/README.md b/problems/largest-palindrome-product/README.md index 55aa3844c..c44be8ef6 100644 --- a/problems/largest-palindrome-product/README.md +++ b/problems/largest-palindrome-product/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/generate-random-point-in-a-circle "Generate Random Point in a Circle") +[< Previous](../generate-random-point-in-a-circle "Generate Random Point in a Circle")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sliding-window-median "Sliding Window Median") +[Next >](../sliding-window-median "Sliding Window Median") ## [479. Largest Palindrome Product (Hard)](https://leetcode.com/problems/largest-palindrome-product "最大回文数乘积") diff --git a/problems/largest-perimeter-triangle/README.md b/problems/largest-perimeter-triangle/README.md index f36682e64..843973455 100644 --- a/problems/largest-perimeter-triangle/README.md +++ b/problems/largest-perimeter-triangle/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/odd-even-jump "Odd Even Jump") +[< Previous](../odd-even-jump "Odd Even Jump")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/squares-of-a-sorted-array "Squares of a Sorted Array") +[Next >](../squares-of-a-sorted-array "Squares of a Sorted Array") ## [976. Largest Perimeter Triangle (Easy)](https://leetcode.com/problems/largest-perimeter-triangle "三角形的最大周长") @@ -66,8 +66,8 @@ ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Largest Triangle Area](https://github.com/openset/leetcode/tree/master/problems/largest-triangle-area) (Easy) + 1. [Largest Triangle Area](../largest-triangle-area) (Easy) diff --git a/problems/largest-plus-sign/README.md b/problems/largest-plus-sign/README.md index 65668f2f3..cdb692979 100644 --- a/problems/largest-plus-sign/README.md +++ b/problems/largest-plus-sign/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/partition-labels "Partition Labels") +[< Previous](../partition-labels "Partition Labels")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/couples-holding-hands "Couples Holding Hands") +[Next >](../couples-holding-hands "Couples Holding Hands") ## [764. Largest Plus Sign (Medium)](https://leetcode.com/problems/largest-plus-sign "最大加号标志") @@ -74,10 +74,10 @@ There is no plus sign, so return 0.

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Maximal Square](https://github.com/openset/leetcode/tree/master/problems/maximal-square) (Medium) + 1. [Maximal Square](../maximal-square) (Medium) ### Hints
diff --git a/problems/largest-rectangle-in-histogram/README.md b/problems/largest-rectangle-in-histogram/README.md index f9f7a7bf8..493e234d5 100644 --- a/problems/largest-rectangle-in-histogram/README.md +++ b/problems/largest-rectangle-in-histogram/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-list "Remove Duplicates from Sorted List") +[< Previous](../remove-duplicates-from-sorted-list "Remove Duplicates from Sorted List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximal-rectangle "Maximal Rectangle") +[Next >](../maximal-rectangle "Maximal Rectangle") ## [84. Largest Rectangle in Histogram (Hard)](https://leetcode.com/problems/largest-rectangle-in-histogram "柱状图中最大的矩形") @@ -33,8 +33,8 @@ ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Maximal Rectangle](https://github.com/openset/leetcode/tree/master/problems/maximal-rectangle) (Hard) + 1. [Maximal Rectangle](../maximal-rectangle) (Hard) diff --git a/problems/largest-sum-of-averages/README.md b/problems/largest-sum-of-averages/README.md index f2ca7d91f..8ce2f1d71 100644 --- a/problems/largest-sum-of-averages/README.md +++ b/problems/largest-sum-of-averages/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/largest-triangle-area "Largest Triangle Area") +[< Previous](../largest-triangle-area "Largest Triangle Area")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-tree-pruning "Binary Tree Pruning") +[Next >](../binary-tree-pruning "Binary Tree Pruning") ## [813. Largest Sum of Averages (Medium)](https://leetcode.com/problems/largest-sum-of-averages "最大平均值和的分组") @@ -39,4 +39,4 @@ That partition would lead to a score of 5 + 2 + 6 = 13, which is worse. ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/largest-time-for-given-digits/README.md b/problems/largest-time-for-given-digits/README.md index 3a799ce67..d364beb40 100644 --- a/problems/largest-time-for-given-digits/README.md +++ b/problems/largest-time-for-given-digits/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/bag-of-tokens "Bag of Tokens") +[< Previous](../bag-of-tokens "Bag of Tokens")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reveal-cards-in-increasing-order "Reveal Cards In Increasing Order") +[Next >](../reveal-cards-in-increasing-order "Reveal Cards In Increasing Order") ## [949. Largest Time for Given Digits (Easy)](https://leetcode.com/problems/largest-time-for-given-digits "给定数字能组成的最大时间") @@ -47,4 +47,4 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/largest-triangle-area/README.md b/problems/largest-triangle-area/README.md index b8158ebab..e03102598 100644 --- a/problems/largest-triangle-area/README.md +++ b/problems/largest-triangle-area/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/subdomain-visit-count "Subdomain Visit Count") +[< Previous](../subdomain-visit-count "Subdomain Visit Count")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/largest-sum-of-averages "Largest Sum of Averages") +[Next >](../largest-sum-of-averages "Largest Sum of Averages") ## [812. Largest Triangle Area (Easy)](https://leetcode.com/problems/largest-triangle-area "最大三角形面积") @@ -35,7 +35,7 @@ The five points are show in the figure below. The red triangle is the largest.

 

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Largest Perimeter Triangle](https://github.com/openset/leetcode/tree/master/problems/largest-perimeter-triangle) (Easy) + 1. [Largest Perimeter Triangle](../largest-perimeter-triangle) (Easy) diff --git a/problems/largest-unique-number/README.md b/problems/largest-unique-number/README.md index 00e9015f7..bef0cfe4d 100644 --- a/problems/largest-unique-number/README.md +++ b/problems/largest-unique-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reported-posts-ii "Reported Posts II") +[< Previous](../reported-posts-ii "Reported Posts II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/armstrong-number "Armstrong Number") +[Next >](../armstrong-number "Armstrong Number") ## [1133. Largest Unique Number (Easy)](https://leetcode.com/problems/largest-unique-number "最大唯一数") @@ -45,8 +45,8 @@ There is no number that occurs only once. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
diff --git a/problems/largest-values-from-labels/README.md b/problems/largest-values-from-labels/README.md index 756d02405..a71b155d7 100644 --- a/problems/largest-values-from-labels/README.md +++ b/problems/largest-values-from-labels/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/duplicate-zeros "Duplicate Zeros") +[< Previous](../duplicate-zeros "Duplicate Zeros")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-path-in-binary-matrix "Shortest Path in Binary Matrix") +[Next >](../shortest-path-in-binary-matrix "Shortest Path in Binary Matrix") ## [1090. Largest Values From Labels (Medium)](https://leetcode.com/problems/largest-values-from-labels "受标签影响的最大值") @@ -75,8 +75,8 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
diff --git a/problems/last-person-to-fit-in-the-elevator/README.md b/problems/last-person-to-fit-in-the-elevator/README.md index b02077c22..bb8211854 100644 --- a/problems/last-person-to-fit-in-the-elevator/README.md +++ b/problems/last-person-to-fit-in-the-elevator/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sort-items-by-groups-respecting-dependencies "Sort Items by Groups Respecting Dependencies") +[< Previous](../sort-items-by-groups-respecting-dependencies "Sort Items by Groups Respecting Dependencies")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/monthly-transactions-ii "Monthly Transactions II") +[Next >](../monthly-transactions-ii "Monthly Transactions II") ## [1204. Last Person to Fit in the Elevator (Medium)](https://leetcode.com/problems/last-person-to-fit-in-the-elevator "") diff --git a/problems/last-stone-weight-ii/README.md b/problems/last-stone-weight-ii/README.md index 2d1469310..0686f14ff 100644 --- a/problems/last-stone-weight-ii/README.md +++ b/problems/last-stone-weight-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-string-chain "Longest String Chain") +[< Previous](../longest-string-chain "Longest String Chain")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/actors-and-directors-who-cooperated-at-least-three-times "Actors and Directors Who Cooperated At Least Three Times") +[Next >](../actors-and-directors-who-cooperated-at-least-three-times "Actors and Directors Who Cooperated At Least Three Times") ## [1049. Last Stone Weight II (Medium)](https://leetcode.com/problems/last-stone-weight-ii "最后一块石头的重量 II") @@ -46,7 +46,7 @@ we can combine 1 and 1 to get 0 so the array converts to [1] then that's the ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/last-stone-weight/README.md b/problems/last-stone-weight/README.md index 0964d5b57..b45df5262 100644 --- a/problems/last-stone-weight/README.md +++ b/problems/last-stone-weight/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/customers-who-bought-all-products "Customers Who Bought All Products") +[< Previous](../customers-who-bought-all-products "Customers Who Bought All Products")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-all-adjacent-duplicates-in-string "Remove All Adjacent Duplicates In String") +[Next >](../remove-all-adjacent-duplicates-in-string "Remove All Adjacent Duplicates In String") ## [1046. Last Stone Weight (Easy)](https://leetcode.com/problems/last-stone-weight "最后一块石头的重量") @@ -45,8 +45,8 @@ we combine 1 and 1 to get 0 so the array converts to [1] then that's the val ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
diff --git a/problems/last-substring-in-lexicographical-order/README.md b/problems/last-substring-in-lexicographical-order/README.md index 799016eab..22c17fd2f 100644 --- a/problems/last-substring-in-lexicographical-order/README.md +++ b/problems/last-substring-in-lexicographical-order/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/as-far-from-land-as-possible "As Far from Land as Possible") +[< Previous](../as-far-from-land-as-possible "As Far from Land as Possible")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/product-price-at-a-given-date "Product Price at a Given Date") +[Next >](../product-price-at-a-given-date "Product Price at a Given Date") ## [1163. Last Substring in Lexicographical Order (Hard)](https://leetcode.com/problems/last-substring-in-lexicographical-order "按字典序排在最后的子串") @@ -40,7 +40,7 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/leaf-similar-trees/README.md b/problems/leaf-similar-trees/README.md index f19aeff35..c52ca03f0 100644 --- a/problems/leaf-similar-trees/README.md +++ b/problems/leaf-similar-trees/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-refueling-stops "Minimum Number of Refueling Stops") +[< Previous](../minimum-number-of-refueling-stops "Minimum Number of Refueling Stops")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/length-of-longest-fibonacci-subsequence "Length of Longest Fibonacci Subsequence") +[Next >](../length-of-longest-fibonacci-subsequence "Length of Longest Fibonacci Subsequence") ## [872. Leaf-Similar Trees (Easy)](https://leetcode.com/problems/leaf-similar-trees "叶子相似的树") @@ -30,5 +30,5 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/least-operators-to-express-number/README.md b/problems/least-operators-to-express-number/README.md index 29ca8ddc9..f50bba289 100644 --- a/problems/least-operators-to-express-number/README.md +++ b/problems/least-operators-to-express-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-area-rectangle-ii "Minimum Area Rectangle II") +[< Previous](../minimum-area-rectangle-ii "Minimum Area Rectangle II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/univalued-binary-tree "Univalued Binary Tree") +[Next >](../univalued-binary-tree "Univalued Binary Tree") ## [964. Least Operators to Express Number (Hard)](https://leetcode.com/problems/least-operators-to-express-number "表示数字的最少运算符") @@ -71,5 +71,5 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/lemonade-change/README.md b/problems/lemonade-change/README.md index 7f8959e1f..0abf8e839 100644 --- a/problems/lemonade-change/README.md +++ b/problems/lemonade-change/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/buddy-strings "Buddy Strings") +[< Previous](../buddy-strings "Buddy Strings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/score-after-flipping-matrix "Score After Flipping Matrix") +[Next >](../score-after-flipping-matrix "Score After Flipping Matrix") ## [860. Lemonade Change (Easy)](https://leetcode.com/problems/lemonade-change "柠檬水找零") @@ -79,4 +79,4 @@ Since not every customer received correct change, the answer is false. ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/length-of-last-word/README.md b/problems/length-of-last-word/README.md index 60594f868..3273ade81 100644 --- a/problems/length-of-last-word/README.md +++ b/problems/length-of-last-word/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/insert-interval "Insert Interval") +[< Previous](../insert-interval "Insert Interval")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/spiral-matrix-ii "Spiral Matrix II") +[Next >](../spiral-matrix-ii "Spiral Matrix II") ## [58. Length of Last Word (Easy)](https://leetcode.com/problems/length-of-last-word "最后一个单词的长度") @@ -27,4 +27,4 @@

 

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/length-of-longest-fibonacci-subsequence/README.md b/problems/length-of-longest-fibonacci-subsequence/README.md index bb1269950..9ee36d6ae 100644 --- a/problems/length-of-longest-fibonacci-subsequence/README.md +++ b/problems/length-of-longest-fibonacci-subsequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/leaf-similar-trees "Leaf-Similar Trees") +[< Previous](../leaf-similar-trees "Leaf-Similar Trees")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/walking-robot-simulation "Walking Robot Simulation") +[Next >](../walking-robot-simulation "Walking Robot Simulation") ## [873. Length of Longest Fibonacci Subsequence (Medium)](https://leetcode.com/problems/length-of-longest-fibonacci-subsequence "最长的斐波那契子序列的长度") @@ -57,8 +57,8 @@ The longest subsequence that is fibonacci-like: ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Fibonacci Number](https://github.com/openset/leetcode/tree/master/problems/fibonacci-number) (Easy) + 1. [Fibonacci Number](../fibonacci-number) (Easy) diff --git a/problems/letter-case-permutation/README.md b/problems/letter-case-permutation/README.md index 369445ac3..31b3fc159 100644 --- a/problems/letter-case-permutation/README.md +++ b/problems/letter-case-permutation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-distance-between-bst-nodes "Minimum Distance Between BST Nodes") +[< Previous](../minimum-distance-between-bst-nodes "Minimum Distance Between BST Nodes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/is-graph-bipartite "Is Graph Bipartite?") +[Next >](../is-graph-bipartite "Is Graph Bipartite?") ## [784. Letter Case Permutation (Easy)](https://leetcode.com/problems/letter-case-permutation "字母大小写全排列") @@ -33,9 +33,9 @@ ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Subsets](https://github.com/openset/leetcode/tree/master/problems/subsets) (Medium) - 1. [Brace Expansion](https://github.com/openset/leetcode/tree/master/problems/brace-expansion) (Medium) + 1. [Subsets](../subsets) (Medium) + 1. [Brace Expansion](../brace-expansion) (Medium) diff --git a/problems/letter-combinations-of-a-phone-number/README.md b/problems/letter-combinations-of-a-phone-number/README.md index 2263594d0..3ab05823e 100644 --- a/problems/letter-combinations-of-a-phone-number/README.md +++ b/problems/letter-combinations-of-a-phone-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/3sum-closest "3Sum Closest") +[< Previous](../3sum-closest "3Sum Closest")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/4sum "4Sum") +[Next >](../4sum "4Sum") ## [17. Letter Combinations of a Phone Number (Medium)](https://leetcode.com/problems/letter-combinations-of-a-phone-number "电话号码的字母组合") @@ -29,10 +29,10 @@

Although the above answer is in lexicographical order, your answer could be in any order you want.

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[String](../../tag/string/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Generate Parentheses](https://github.com/openset/leetcode/tree/master/problems/generate-parentheses) (Medium) - 1. [Combination Sum](https://github.com/openset/leetcode/tree/master/problems/combination-sum) (Medium) - 1. [Binary Watch](https://github.com/openset/leetcode/tree/master/problems/binary-watch) (Easy) + 1. [Generate Parentheses](../generate-parentheses) (Medium) + 1. [Combination Sum](../combination-sum) (Medium) + 1. [Binary Watch](../binary-watch) (Easy) diff --git a/problems/letter-tile-possibilities/README.md b/problems/letter-tile-possibilities/README.md index 5e6fbeed4..2823e0444 100644 --- a/problems/letter-tile-possibilities/README.md +++ b/problems/letter-tile-possibilities/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/occurrences-after-bigram "Occurrences After Bigram") +[< Previous](../occurrences-after-bigram "Occurrences After Bigram")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/insufficient-nodes-in-root-to-leaf-paths "Insufficient Nodes in Root to Leaf Paths") +[Next >](../insufficient-nodes-in-root-to-leaf-paths "Insufficient Nodes in Root to Leaf Paths") ## [1079. Letter Tile Possibilities (Medium)](https://leetcode.com/problems/letter-tile-possibilities "活字印刷") @@ -42,7 +42,7 @@ ### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Hints
diff --git a/problems/lexicographical-numbers/README.md b/problems/lexicographical-numbers/README.md index 33592c273..202709cbe 100644 --- a/problems/lexicographical-numbers/README.md +++ b/problems/lexicographical-numbers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/mini-parser "Mini Parser") +[< Previous](../mini-parser "Mini Parser")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/first-unique-character-in-a-string "First Unique Character in a String") +[Next >](../first-unique-character-in-a-string "First Unique Character in a String") ## [386. Lexicographical Numbers (Medium)](https://leetcode.com/problems/lexicographical-numbers "字典序排数") diff --git a/problems/lexicographically-smallest-equivalent-string/README.md b/problems/lexicographically-smallest-equivalent-string/README.md index dd6a66f52..273d83928 100644 --- a/problems/lexicographically-smallest-equivalent-string/README.md +++ b/problems/lexicographically-smallest-equivalent-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/missing-element-in-sorted-array "Missing Element in Sorted Array") +[< Previous](../missing-element-in-sorted-array "Missing Element in Sorted Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-repeating-substring "Longest Repeating Substring") +[Next >](../longest-repeating-substring "Longest Repeating Substring") ## [1061. Lexicographically Smallest Equivalent String (Medium)](https://leetcode.com/problems/lexicographically-smallest-equivalent-string "按字典序排列最小的等效字符串") @@ -62,8 +62,8 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] ### Hints
diff --git a/problems/lfu-cache/README.md b/problems/lfu-cache/README.md index d4952eff2..5f0d76269 100644 --- a/problems/lfu-cache/README.md +++ b/problems/lfu-cache/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/repeated-substring-pattern "Repeated Substring Pattern") +[< Previous](../repeated-substring-pattern "Repeated Substring Pattern")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/hamming-distance "Hamming Distance") +[Next >](../hamming-distance "Hamming Distance") ## [460. LFU Cache (Hard)](https://leetcode.com/problems/lfu-cache "LFU缓存") @@ -45,8 +45,8 @@ cache.get(4); // returns 4

 

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions - 1. [LRU Cache](https://github.com/openset/leetcode/tree/master/problems/lru-cache) (Medium) - 1. [Design In-Memory File System](https://github.com/openset/leetcode/tree/master/problems/design-in-memory-file-system) (Hard) + 1. [LRU Cache](../lru-cache) (Medium) + 1. [Design In-Memory File System](../design-in-memory-file-system) (Hard) diff --git a/problems/license-key-formatting/README.md b/problems/license-key-formatting/README.md index c079a5f43..aca195293 100644 --- a/problems/license-key-formatting/README.md +++ b/problems/license-key-formatting/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/magical-string "Magical String") +[< Previous](../magical-string "Magical String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/smallest-good-base "Smallest Good Base") +[Next >](../smallest-good-base "Smallest Good Base") ## [482. License Key Formatting (Easy)](https://leetcode.com/problems/license-key-formatting "密钥格式化") diff --git a/problems/line-reflection/README.md b/problems/line-reflection/README.md index 83c967b90..e08b9984f 100644 --- a/problems/line-reflection/README.md +++ b/problems/line-reflection/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-twitter "Design Twitter") +[< Previous](../design-twitter "Design Twitter")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/count-numbers-with-unique-digits "Count Numbers with Unique Digits") +[Next >](../count-numbers-with-unique-digits "Count Numbers with Unique Digits") ## [356. Line Reflection (Medium)](https://leetcode.com/problems/line-reflection "直线镜像") @@ -28,12 +28,12 @@ Output: false ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Max Points on a Line](https://github.com/openset/leetcode/tree/master/problems/max-points-on-a-line) (Hard) - 1. [Number of Boomerangs](https://github.com/openset/leetcode/tree/master/problems/number-of-boomerangs) (Easy) + 1. [Max Points on a Line](../max-points-on-a-line) (Hard) + 1. [Number of Boomerangs](../number-of-boomerangs) (Easy) ### Hints
diff --git a/problems/linked-list-components/README.md b/problems/linked-list-components/README.md index 84a14dde1..03075fdf2 100644 --- a/problems/linked-list-components/README.md +++ b/problems/linked-list-components/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/ambiguous-coordinates "Ambiguous Coordinates") +[< Previous](../ambiguous-coordinates "Ambiguous Coordinates")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/race-car "Race Car") +[Next >](../race-car "Race Car") ## [817. Linked List Components (Medium)](https://leetcode.com/problems/linked-list-components "链表组件") @@ -49,4 +49,4 @@ G = [0, 3, 1, 4] ### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/linked-list-cycle-ii/README.md b/problems/linked-list-cycle-ii/README.md index 03f237f05..beb38d797 100644 --- a/problems/linked-list-cycle-ii/README.md +++ b/problems/linked-list-cycle-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/linked-list-cycle "Linked List Cycle") +[< Previous](../linked-list-cycle "Linked List Cycle")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reorder-list "Reorder List") +[Next >](../reorder-list "Reorder List") ## [142. Linked List Cycle II (Medium)](https://leetcode.com/problems/linked-list-cycle-ii "环形链表 II") @@ -55,9 +55,9 @@ Can you solve it without using extra space?

### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Linked List Cycle](https://github.com/openset/leetcode/tree/master/problems/linked-list-cycle) (Easy) - 1. [Find the Duplicate Number](https://github.com/openset/leetcode/tree/master/problems/find-the-duplicate-number) (Medium) + 1. [Linked List Cycle](../linked-list-cycle) (Easy) + 1. [Find the Duplicate Number](../find-the-duplicate-number) (Medium) diff --git a/problems/linked-list-cycle/README.md b/problems/linked-list-cycle/README.md index 28f75ed36..056383919 100644 --- a/problems/linked-list-cycle/README.md +++ b/problems/linked-list-cycle/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/word-break-ii "Word Break II") +[< Previous](../word-break-ii "Word Break II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/linked-list-cycle-ii "Linked List Cycle II") +[Next >](../linked-list-cycle-ii "Linked List Cycle II") ## [141. Linked List Cycle (Easy)](https://leetcode.com/problems/linked-list-cycle "环形链表") @@ -60,9 +60,9 @@

Can you solve it using O(1) (i.e. constant) memory?

### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Linked List Cycle II](https://github.com/openset/leetcode/tree/master/problems/linked-list-cycle-ii) (Medium) - 1. [Happy Number](https://github.com/openset/leetcode/tree/master/problems/happy-number) (Easy) + 1. [Linked List Cycle II](../linked-list-cycle-ii) (Medium) + 1. [Happy Number](../happy-number) (Easy) diff --git a/problems/linked-list-random-node/README.md b/problems/linked-list-random-node/README.md index d07b720db..87e4bdd5e 100644 --- a/problems/linked-list-random-node/README.md +++ b/problems/linked-list-random-node/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/insert-delete-getrandom-o1-duplicates-allowed "Insert Delete GetRandom O(1) - Duplicates allowed") +[< Previous](../insert-delete-getrandom-o1-duplicates-allowed "Insert Delete GetRandom O(1) - Duplicates allowed")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/ransom-note "Ransom Note") +[Next >](../ransom-note "Ransom Note") ## [382. Linked List Random Node (Medium)](https://leetcode.com/problems/linked-list-random-node "链表随机节点") @@ -31,7 +31,7 @@ solution.getRandom();

### Related Topics - [[Reservoir Sampling](https://github.com/openset/leetcode/tree/master/tag/reservoir-sampling/README.md)] + [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] ### Similar Questions - 1. [Random Pick Index](https://github.com/openset/leetcode/tree/master/problems/random-pick-index) (Medium) + 1. [Random Pick Index](../random-pick-index) (Medium) diff --git a/problems/logger-rate-limiter/README.md b/problems/logger-rate-limiter/README.md index c4218c56c..20267a79e 100644 --- a/problems/logger-rate-limiter/README.md +++ b/problems/logger-rate-limiter/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/rearrange-string-k-distance-apart "Rearrange String k Distance Apart") +[< Previous](../rearrange-string-k-distance-apart "Rearrange String k Distance Apart")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sort-transformed-array "Sort Transformed Array") +[Next >](../sort-transformed-array "Sort Transformed Array") ## [359. Logger Rate Limiter (Easy)](https://leetcode.com/problems/logger-rate-limiter "日志速率限制器") @@ -42,8 +42,8 @@ logger.shouldPrintMessage(11,"foo"); returns true; ### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Design Hit Counter](https://github.com/openset/leetcode/tree/master/problems/design-hit-counter) (Medium) + 1. [Design Hit Counter](../design-hit-counter) (Medium) diff --git a/problems/lonely-pixel-i/README.md b/problems/lonely-pixel-i/README.md index 55cdaa3ff..8e95a9dd8 100644 --- a/problems/lonely-pixel-i/README.md +++ b/problems/lonely-pixel-i/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-absolute-difference-in-bst "Minimum Absolute Difference in BST") +[< Previous](../minimum-absolute-difference-in-bst "Minimum Absolute Difference in BST")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/k-diff-pairs-in-an-array "K-diff Pairs in an Array") +[Next >](../k-diff-pairs-in-an-array "K-diff Pairs in an Array") ## [531. Lonely Pixel I (Medium)](https://leetcode.com/problems/lonely-pixel-i "孤独像素 I") @@ -36,8 +36,8 @@

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Lonely Pixel II](https://github.com/openset/leetcode/tree/master/problems/lonely-pixel-ii) (Medium) + 1. [Lonely Pixel II](../lonely-pixel-ii) (Medium) diff --git a/problems/lonely-pixel-ii/README.md b/problems/lonely-pixel-ii/README.md index f24bb76d2..5d44bbe80 100644 --- a/problems/lonely-pixel-ii/README.md +++ b/problems/lonely-pixel-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/k-diff-pairs-in-an-array "K-diff Pairs in an Array") +[< Previous](../k-diff-pairs-in-an-array "K-diff Pairs in an Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-iii "Game Play Analysis III") +[Next >](../game-play-analysis-iii "Game Play Analysis III") ## [533. Lonely Pixel II (Medium)](https://leetcode.com/problems/lonely-pixel-ii "孤独像素 II") @@ -52,8 +52,8 @@ Rule 2, the rows have black pixel at column C = 1 are row 0, row 1 and row 2. Th

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Lonely Pixel I](https://github.com/openset/leetcode/tree/master/problems/lonely-pixel-i) (Medium) + 1. [Lonely Pixel I](../lonely-pixel-i) (Medium) diff --git a/problems/long-pressed-name/README.md b/problems/long-pressed-name/README.md index 0838ab7b2..835dcfa2e 100644 --- a/problems/long-pressed-name/README.md +++ b/problems/long-pressed-name/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimize-malware-spread "Minimize Malware Spread") +[< Previous](../minimize-malware-spread "Minimize Malware Spread")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/flip-string-to-monotone-increasing "Flip String to Monotone Increasing") +[Next >](../flip-string-to-monotone-increasing "Flip String to Monotone Increasing") ## [925. Long Pressed Name (Easy)](https://leetcode.com/problems/long-pressed-name "长按键入") @@ -75,5 +75,5 @@ ### Related Topics - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/longest-absolute-file-path/README.md b/problems/longest-absolute-file-path/README.md index c48e640c3..d1da1f8bd 100644 --- a/problems/longest-absolute-file-path/README.md +++ b/problems/longest-absolute-file-path/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/first-unique-character-in-a-string "First Unique Character in a String") +[< Previous](../first-unique-character-in-a-string "First Unique Character in a String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-the-difference "Find the Difference") +[Next >](../find-the-difference "Find the Difference") ## [388. Longest Absolute File Path (Medium)](https://leetcode.com/problems/longest-absolute-file-path "文件的最长绝对路径") diff --git a/problems/longest-arithmetic-sequence/README.md b/problems/longest-arithmetic-sequence/README.md index c3f2000bf..8703dfe66 100644 --- a/problems/longest-arithmetic-sequence/README.md +++ b/problems/longest-arithmetic-sequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-difference-between-node-and-ancestor "Maximum Difference Between Node and Ancestor") +[< Previous](../maximum-difference-between-node-and-ancestor "Maximum Difference Between Node and Ancestor")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/recover-a-tree-from-preorder-traversal "Recover a Tree From Preorder Traversal") +[Next >](../recover-a-tree-from-preorder-traversal "Recover a Tree From Preorder Traversal") ## [1027. Longest Arithmetic Sequence (Medium)](https://leetcode.com/problems/longest-arithmetic-sequence "最长等差数列") @@ -58,4 +58,4 @@ The longest arithmetic subsequence is [20,15,10,5]. ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/longest-arithmetic-subsequence-of-given-difference/README.md b/problems/longest-arithmetic-subsequence-of-given-difference/README.md index d1f167953..b56061b0a 100644 --- a/problems/longest-arithmetic-subsequence-of-given-difference/README.md +++ b/problems/longest-arithmetic-subsequence-of-given-difference/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/play-with-chips "Play with Chips") +[< Previous](../play-with-chips "Play with Chips")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/path-with-maximum-gold "Path with Maximum Gold") +[Next >](../path-with-maximum-gold "Path with Maximum Gold") ## [1218. Longest Arithmetic Subsequence of Given Difference (Medium)](https://leetcode.com/problems/longest-arithmetic-subsequence-of-given-difference "最长定差子序列") @@ -46,8 +46,8 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/longest-chunked-palindrome-decomposition/README.md b/problems/longest-chunked-palindrome-decomposition/README.md index 2c6b04c05..d2b9239a5 100644 --- a/problems/longest-chunked-palindrome-decomposition/README.md +++ b/problems/longest-chunked-palindrome-decomposition/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/snapshot-array "Snapshot Array") +[< Previous](../snapshot-array "Snapshot Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/article-views-i "Article Views I") +[Next >](../article-views-i "Article Views I") ## [1147. Longest Chunked Palindrome Decomposition (Hard)](https://leetcode.com/problems/longest-chunked-palindrome-decomposition "段式回文") @@ -61,7 +61,7 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/longest-common-prefix/README.md b/problems/longest-common-prefix/README.md index a967ff200..a5b6c63d3 100644 --- a/problems/longest-common-prefix/README.md +++ b/problems/longest-common-prefix/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/roman-to-integer "Roman to Integer") +[< Previous](../roman-to-integer "Roman to Integer")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/3sum "3Sum") +[Next >](../3sum "3Sum") ## [14. Longest Common Prefix (Easy)](https://leetcode.com/problems/longest-common-prefix "最长公共前缀") @@ -35,4 +35,4 @@

All given inputs are in lowercase letters a-z.

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/longest-common-subsequence/README.md b/problems/longest-common-subsequence/README.md index c16b43e6f..75d8cfed4 100644 --- a/problems/longest-common-subsequence/README.md +++ b/problems/longest-common-subsequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/user-activity-for-the-past-30-days-ii "User Activity for the Past 30 Days II") +[< Previous](../user-activity-for-the-past-30-days-ii "User Activity for the Past 30 Days II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/decrease-elements-to-make-array-zigzag "Decrease Elements To Make Array Zigzag") +[Next >](../decrease-elements-to-make-array-zigzag "Decrease Elements To Make Array Zigzag") ## [1143. Longest Common Subsequence (Medium)](https://leetcode.com/problems/longest-common-subsequence "最长公共子序列") @@ -54,7 +54,7 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/longest-consecutive-sequence/README.md b/problems/longest-consecutive-sequence/README.md index ca0a78204..b85a5bd21 100644 --- a/problems/longest-consecutive-sequence/README.md +++ b/problems/longest-consecutive-sequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/word-ladder "Word Ladder") +[< Previous](../word-ladder "Word Ladder")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sum-root-to-leaf-numbers "Sum Root to Leaf Numbers") +[Next >](../sum-root-to-leaf-numbers "Sum Root to Leaf Numbers") ## [128. Longest Consecutive Sequence (Hard)](https://leetcode.com/problems/longest-consecutive-sequence "最长连续序列") @@ -24,8 +24,8 @@ ### Related Topics - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Binary Tree Longest Consecutive Sequence](https://github.com/openset/leetcode/tree/master/problems/binary-tree-longest-consecutive-sequence) (Medium) + 1. [Binary Tree Longest Consecutive Sequence](../binary-tree-longest-consecutive-sequence) (Medium) diff --git a/problems/longest-continuous-increasing-subsequence/README.md b/problems/longest-continuous-increasing-subsequence/README.md index 959fa975d..b5b65a90a 100644 --- a/problems/longest-continuous-increasing-subsequence/README.md +++ b/problems/longest-continuous-increasing-subsequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-longest-increasing-subsequence "Number of Longest Increasing Subsequence") +[< Previous](../number-of-longest-increasing-subsequence "Number of Longest Increasing Subsequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/cut-off-trees-for-golf-event "Cut Off Trees for Golf Event") +[Next >](../cut-off-trees-for-golf-event "Cut Off Trees for Golf Event") ## [674. Longest Continuous Increasing Subsequence (Easy)](https://leetcode.com/problems/longest-continuous-increasing-subsequence "最长连续递增序列") @@ -37,8 +37,8 @@ Length of the array will not exceed 10,000.

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Number of Longest Increasing Subsequence](https://github.com/openset/leetcode/tree/master/problems/number-of-longest-increasing-subsequence) (Medium) - 1. [Minimum Window Subsequence](https://github.com/openset/leetcode/tree/master/problems/minimum-window-subsequence) (Hard) + 1. [Number of Longest Increasing Subsequence](../number-of-longest-increasing-subsequence) (Medium) + 1. [Minimum Window Subsequence](../minimum-window-subsequence) (Hard) diff --git a/problems/longest-duplicate-substring/README.md b/problems/longest-duplicate-substring/README.md index c457f590a..40e889317 100644 --- a/problems/longest-duplicate-substring/README.md +++ b/problems/longest-duplicate-substring/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/partition-array-for-maximum-sum "Partition Array for Maximum Sum") +[< Previous](../partition-array-for-maximum-sum "Partition Array for Maximum Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/customers-who-bought-all-products "Customers Who Bought All Products") +[Next >](../customers-who-bought-all-products "Customers Who Bought All Products") ## [1044. Longest Duplicate Substring (Hard)](https://leetcode.com/problems/longest-duplicate-substring "最长重复子串") @@ -41,8 +41,8 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
diff --git a/problems/longest-harmonious-subsequence/README.md b/problems/longest-harmonious-subsequence/README.md index d6083ff37..fb83eb1c5 100644 --- a/problems/longest-harmonious-subsequence/README.md +++ b/problems/longest-harmonious-subsequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-square "Valid Square") +[< Previous](../valid-square "Valid Square")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/big-countries "Big Countries") +[Next >](../big-countries "Big Countries") ## [594. Longest Harmonious Subsequence (Easy)](https://leetcode.com/problems/longest-harmonious-subsequence "最长和谐子序列") @@ -28,4 +28,4 @@

Note: The length of the input array will not exceed 20,000.

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/longest-increasing-path-in-a-matrix/README.md b/problems/longest-increasing-path-in-a-matrix/README.md index 578a4eaed..73f1cf63f 100644 --- a/problems/longest-increasing-path-in-a-matrix/README.md +++ b/problems/longest-increasing-path-in-a-matrix/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/odd-even-linked-list "Odd Even Linked List") +[< Previous](../odd-even-linked-list "Odd Even Linked List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/patching-array "Patching Array") +[Next >](../patching-array "Patching Array") ## [329. Longest Increasing Path in a Matrix (Hard)](https://leetcode.com/problems/longest-increasing-path-in-a-matrix "矩阵中的最长递增路径") @@ -42,6 +42,6 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Topological Sort](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] - [[Memoization](https://github.com/openset/leetcode/tree/master/tag/memoization/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] + [[Memoization](../../tag/memoization/README.md)] diff --git a/problems/longest-increasing-subsequence/README.md b/problems/longest-increasing-subsequence/README.md index 8b05a5d47..1f0fe7f8f 100644 --- a/problems/longest-increasing-subsequence/README.md +++ b/problems/longest-increasing-subsequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/bulls-and-cows "Bulls and Cows") +[< Previous](../bulls-and-cows "Bulls and Cows")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-invalid-parentheses "Remove Invalid Parentheses") +[Next >](../remove-invalid-parentheses "Remove Invalid Parentheses") ## [300. Longest Increasing Subsequence (Medium)](https://leetcode.com/problems/longest-increasing-subsequence "最长上升子序列") @@ -30,12 +30,12 @@

Follow up: Could you improve it to O(n log n) time complexity?

### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Increasing Triplet Subsequence](https://github.com/openset/leetcode/tree/master/problems/increasing-triplet-subsequence) (Medium) - 1. [Russian Doll Envelopes](https://github.com/openset/leetcode/tree/master/problems/russian-doll-envelopes) (Hard) - 1. [Maximum Length of Pair Chain](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-pair-chain) (Medium) - 1. [Number of Longest Increasing Subsequence](https://github.com/openset/leetcode/tree/master/problems/number-of-longest-increasing-subsequence) (Medium) - 1. [Minimum ASCII Delete Sum for Two Strings](https://github.com/openset/leetcode/tree/master/problems/minimum-ascii-delete-sum-for-two-strings) (Medium) + 1. [Increasing Triplet Subsequence](../increasing-triplet-subsequence) (Medium) + 1. [Russian Doll Envelopes](../russian-doll-envelopes) (Hard) + 1. [Maximum Length of Pair Chain](../maximum-length-of-pair-chain) (Medium) + 1. [Number of Longest Increasing Subsequence](../number-of-longest-increasing-subsequence) (Medium) + 1. [Minimum ASCII Delete Sum for Two Strings](../minimum-ascii-delete-sum-for-two-strings) (Medium) diff --git a/problems/longest-line-of-consecutive-one-in-matrix/README.md b/problems/longest-line-of-consecutive-one-in-matrix/README.md index 19a81e4a5..5698e26e0 100644 --- a/problems/longest-line-of-consecutive-one-in-matrix/README.md +++ b/problems/longest-line-of-consecutive-one-in-matrix/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/array-partition-i "Array Partition I") +[< Previous](../array-partition-i "Array Partition I")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-tree-tilt "Binary Tree Tilt") +[Next >](../binary-tree-tilt "Binary Tree Tilt") ## [562. Longest Line of Consecutive One in Matrix (Medium)](https://leetcode.com/problems/longest-line-of-consecutive-one-in-matrix "矩阵中最长的连续1线段") @@ -29,7 +29,7 @@ The number of elements in the given matrix will not exceed 10,000.

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/longest-mountain-in-array/README.md b/problems/longest-mountain-in-array/README.md index b7492086f..11c50003d 100644 --- a/problems/longest-mountain-in-array/README.md +++ b/problems/longest-mountain-in-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/backspace-string-compare "Backspace String Compare") +[< Previous](../backspace-string-compare "Backspace String Compare")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/hand-of-straights "Hand of Straights") +[Next >](../hand-of-straights "Hand of Straights") ## [845. Longest Mountain in Array (Medium)](https://leetcode.com/problems/longest-mountain-in-array "数组中的最长山脉") @@ -55,4 +55,4 @@ ### Related Topics - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/longest-palindrome/README.md b/problems/longest-palindrome/README.md index 8056e0379..61887ae96 100644 --- a/problems/longest-palindrome/README.md +++ b/problems/longest-palindrome/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-word-abbreviation "Valid Word Abbreviation") +[< Previous](../valid-word-abbreviation "Valid Word Abbreviation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/split-array-largest-sum "Split Array Largest Sum") +[Next >](../split-array-largest-sum "Split Array Largest Sum") ## [409. Longest Palindrome (Easy)](https://leetcode.com/problems/longest-palindrome "最长回文串") @@ -33,7 +33,7 @@ One longest palindrome that can be built is "dccaccd", whose length is 7.

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Palindrome Permutation](https://github.com/openset/leetcode/tree/master/problems/palindrome-permutation) (Easy) + 1. [Palindrome Permutation](../palindrome-permutation) (Easy) diff --git a/problems/longest-palindromic-subsequence/README.md b/problems/longest-palindromic-subsequence/README.md index 5f6f7f90c..9629d2933 100644 --- a/problems/longest-palindromic-subsequence/README.md +++ b/problems/longest-palindromic-subsequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-largest-value-in-each-tree-row "Find Largest Value in Each Tree Row") +[< Previous](../find-largest-value-in-each-tree-row "Find Largest Value in Each Tree Row")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/super-washing-machines "Super Washing Machines") +[Next >](../super-washing-machines "Super Washing Machines") ## [516. Longest Palindromic Subsequence (Medium)](https://leetcode.com/problems/longest-palindromic-subsequence "最长回文子序列") @@ -40,9 +40,9 @@ One possible longest palindromic subsequence is "bb".

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Longest Palindromic Substring](https://github.com/openset/leetcode/tree/master/problems/longest-palindromic-substring) (Medium) - 1. [Palindromic Substrings](https://github.com/openset/leetcode/tree/master/problems/palindromic-substrings) (Medium) - 1. [Count Different Palindromic Subsequences](https://github.com/openset/leetcode/tree/master/problems/count-different-palindromic-subsequences) (Hard) + 1. [Longest Palindromic Substring](../longest-palindromic-substring) (Medium) + 1. [Palindromic Substrings](../palindromic-substrings) (Medium) + 1. [Count Different Palindromic Subsequences](../count-different-palindromic-subsequences) (Hard) diff --git a/problems/longest-palindromic-substring/README.md b/problems/longest-palindromic-substring/README.md index d149237c7..427626ae3 100644 --- a/problems/longest-palindromic-substring/README.md +++ b/problems/longest-palindromic-substring/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/median-of-two-sorted-arrays "Median of Two Sorted Arrays") +[< Previous](../median-of-two-sorted-arrays "Median of Two Sorted Arrays")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/zigzag-conversion "ZigZag Conversion") +[Next >](../zigzag-conversion "ZigZag Conversion") ## [5. Longest Palindromic Substring (Medium)](https://leetcode.com/problems/longest-palindromic-substring "最长回文子串") @@ -29,15 +29,15 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Shortest Palindrome](https://github.com/openset/leetcode/tree/master/problems/shortest-palindrome) (Hard) - 1. [Palindrome Permutation](https://github.com/openset/leetcode/tree/master/problems/palindrome-permutation) (Easy) - 1. [Palindrome Pairs](https://github.com/openset/leetcode/tree/master/problems/palindrome-pairs) (Hard) - 1. [Longest Palindromic Subsequence](https://github.com/openset/leetcode/tree/master/problems/longest-palindromic-subsequence) (Medium) - 1. [Palindromic Substrings](https://github.com/openset/leetcode/tree/master/problems/palindromic-substrings) (Medium) + 1. [Shortest Palindrome](../shortest-palindrome) (Hard) + 1. [Palindrome Permutation](../palindrome-permutation) (Easy) + 1. [Palindrome Pairs](../palindrome-pairs) (Hard) + 1. [Longest Palindromic Subsequence](../longest-palindromic-subsequence) (Medium) + 1. [Palindromic Substrings](../palindromic-substrings) (Medium) ### Hints
diff --git a/problems/longest-repeating-character-replacement/README.md b/problems/longest-repeating-character-replacement/README.md index 287f5fb0c..4effd154d 100644 --- a/problems/longest-repeating-character-replacement/README.md +++ b/problems/longest-repeating-character-replacement/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reconstruct-original-digits-from-english "Reconstruct Original Digits from English") +[< Previous](../reconstruct-original-digits-from-english "Reconstruct Original Digits from English")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/word-squares "Word Squares") +[Next >](../word-squares "Word Squares") ## [424. Longest Repeating Character Replacement (Medium)](https://leetcode.com/problems/longest-repeating-character-replacement "替换后的最长重复字符") @@ -52,9 +52,9 @@ The substring "BBBB" has the longest repeating letters, which is 4.

 

### Related Topics - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions - 1. [Longest Substring with At Most K Distinct Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-k-distinct-characters) (Hard) - 1. [Max Consecutive Ones III](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones-iii) (Medium) + 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Hard) + 1. [Max Consecutive Ones III](../max-consecutive-ones-iii) (Medium) diff --git a/problems/longest-repeating-substring/README.md b/problems/longest-repeating-substring/README.md index 177fab4f7..74d0ab9e0 100644 --- a/problems/longest-repeating-substring/README.md +++ b/problems/longest-repeating-substring/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/lexicographically-smallest-equivalent-string "Lexicographically Smallest Equivalent String") +[< Previous](../lexicographically-smallest-equivalent-string "Lexicographically Smallest Equivalent String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-valid-subarrays "Number of Valid Subarrays") +[Next >](../number-of-valid-subarrays "Number of Valid Subarrays") ## [1062. Longest Repeating Substring (Medium)](https://leetcode.com/problems/longest-repeating-substring "最长重复子串") @@ -57,7 +57,7 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/longest-string-chain/README.md b/problems/longest-string-chain/README.md index f6339dad6..0a2b5f042 100644 --- a/problems/longest-string-chain/README.md +++ b/problems/longest-string-chain/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-all-adjacent-duplicates-in-string "Remove All Adjacent Duplicates In String") +[< Previous](../remove-all-adjacent-duplicates-in-string "Remove All Adjacent Duplicates In String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/last-stone-weight-ii "Last Stone Weight II") +[Next >](../last-stone-weight-ii "Last Stone Weight II") ## [1048. Longest String Chain (Medium)](https://leetcode.com/problems/longest-string-chain "最长字符串链") @@ -44,8 +44,8 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/longest-substring-with-at-least-k-repeating-characters/README.md b/problems/longest-substring-with-at-least-k-repeating-characters/README.md index cd701ca46..0043cf6de 100644 --- a/problems/longest-substring-with-at-least-k-repeating-characters/README.md +++ b/problems/longest-substring-with-at-least-k-repeating-characters/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/decode-string "Decode String") +[< Previous](../decode-string "Decode String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/rotate-function "Rotate Function") +[Next >](../rotate-function "Rotate Function") ## [395. Longest Substring with At Least K Repeating Characters (Medium)](https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters "至少有K个重复字符的最长子串") diff --git a/problems/longest-substring-with-at-most-k-distinct-characters/README.md b/problems/longest-substring-with-at-most-k-distinct-characters/README.md index 338beeb23..2ef66431a 100644 --- a/problems/longest-substring-with-at-most-k-distinct-characters/README.md +++ b/problems/longest-substring-with-at-most-k-distinct-characters/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/nested-list-weight-sum "Nested List Weight Sum") +[< Previous](../nested-list-weight-sum "Nested List Weight Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/flatten-nested-list-iterator "Flatten Nested List Iterator") +[Next >](../flatten-nested-list-iterator "Flatten Nested List Iterator") ## [340. Longest Substring with At Most K Distinct Characters (Hard)](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters "至多包含 K 个不同字符的最长子串") @@ -31,13 +31,13 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions - 1. [Longest Substring Without Repeating Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-without-repeating-characters) (Medium) - 1. [Longest Substring with At Most Two Distinct Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters) (Medium) - 1. [Longest Repeating Character Replacement](https://github.com/openset/leetcode/tree/master/problems/longest-repeating-character-replacement) (Medium) - 1. [Subarrays with K Different Integers](https://github.com/openset/leetcode/tree/master/problems/subarrays-with-k-different-integers) (Hard) - 1. [Max Consecutive Ones III](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones-iii) (Medium) + 1. [Longest Substring Without Repeating Characters](../longest-substring-without-repeating-characters) (Medium) + 1. [Longest Substring with At Most Two Distinct Characters](../longest-substring-with-at-most-two-distinct-characters) (Medium) + 1. [Longest Repeating Character Replacement](../longest-repeating-character-replacement) (Medium) + 1. [Subarrays with K Different Integers](../subarrays-with-k-different-integers) (Hard) + 1. [Max Consecutive Ones III](../max-consecutive-ones-iii) (Medium) diff --git a/problems/longest-substring-with-at-most-two-distinct-characters/README.md b/problems/longest-substring-with-at-most-two-distinct-characters/README.md index 5968b8604..a8177ceef 100644 --- a/problems/longest-substring-with-at-most-two-distinct-characters/README.md +++ b/problems/longest-substring-with-at-most-two-distinct-characters/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/read-n-characters-given-read4-ii-call-multiple-times "Read N Characters Given Read4 II - Call multiple times") +[< Previous](../read-n-characters-given-read4-ii-call-multiple-times "Read N Characters Given Read4 II - Call multiple times")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-linked-lists "Intersection of Two Linked Lists") +[Next >](../intersection-of-two-linked-lists "Intersection of Two Linked Lists") ## [159. Longest Substring with At Most Two Distinct Characters (Medium)](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters "至多包含两个不同字符的最长子串") @@ -28,13 +28,13 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions - 1. [Longest Substring Without Repeating Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-without-repeating-characters) (Medium) - 1. [Sliding Window Maximum](https://github.com/openset/leetcode/tree/master/problems/sliding-window-maximum) (Hard) - 1. [Longest Substring with At Most K Distinct Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-k-distinct-characters) (Hard) - 1. [Subarrays with K Different Integers](https://github.com/openset/leetcode/tree/master/problems/subarrays-with-k-different-integers) (Hard) + 1. [Longest Substring Without Repeating Characters](../longest-substring-without-repeating-characters) (Medium) + 1. [Sliding Window Maximum](../sliding-window-maximum) (Hard) + 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Hard) + 1. [Subarrays with K Different Integers](../subarrays-with-k-different-integers) (Hard) diff --git a/problems/longest-substring-without-repeating-characters/README.md b/problems/longest-substring-without-repeating-characters/README.md index 000b16105..584c5f845 100644 --- a/problems/longest-substring-without-repeating-characters/README.md +++ b/problems/longest-substring-without-repeating-characters/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/add-two-numbers "Add Two Numbers") +[< Previous](../add-two-numbers "Add Two Numbers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/median-of-two-sorted-arrays "Median of Two Sorted Arrays") +[Next >](../median-of-two-sorted-arrays "Median of Two Sorted Arrays") ## [3. Longest Substring Without Repeating Characters (Medium)](https://leetcode.com/problems/longest-substring-without-repeating-characters "无重复字符的最长子串") @@ -45,12 +45,12 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions - 1. [Longest Substring with At Most Two Distinct Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters) (Medium) - 1. [Longest Substring with At Most K Distinct Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-k-distinct-characters) (Hard) - 1. [Subarrays with K Different Integers](https://github.com/openset/leetcode/tree/master/problems/subarrays-with-k-different-integers) (Hard) + 1. [Longest Substring with At Most Two Distinct Characters](../longest-substring-with-at-most-two-distinct-characters) (Medium) + 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Hard) + 1. [Subarrays with K Different Integers](../subarrays-with-k-different-integers) (Hard) diff --git a/problems/longest-turbulent-subarray/README.md b/problems/longest-turbulent-subarray/README.md index 6999719c7..6883463ad 100644 --- a/problems/longest-turbulent-subarray/README.md +++ b/problems/longest-turbulent-subarray/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/squares-of-a-sorted-array "Squares of a Sorted Array") +[< Previous](../squares-of-a-sorted-array "Squares of a Sorted Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/distribute-coins-in-binary-tree "Distribute Coins in Binary Tree") +[Next >](../distribute-coins-in-binary-tree "Distribute Coins in Binary Tree") ## [978. Longest Turbulent Subarray (Medium)](https://leetcode.com/problems/longest-turbulent-subarray "最长湍流子数组") @@ -62,9 +62,9 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions - 1. [Maximum Subarray](https://github.com/openset/leetcode/tree/master/problems/maximum-subarray) (Easy) + 1. [Maximum Subarray](../maximum-subarray) (Easy) diff --git a/problems/longest-uncommon-subsequence-i/README.md b/problems/longest-uncommon-subsequence-i/README.md index c251c18ec..c4b156e8d 100644 --- a/problems/longest-uncommon-subsequence-i/README.md +++ b/problems/longest-uncommon-subsequence-i/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/detect-capital "Detect Capital") +[< Previous](../detect-capital "Detect Capital")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-uncommon-subsequence-ii "Longest Uncommon Subsequence II") +[Next >](../longest-uncommon-subsequence-ii "Longest Uncommon Subsequence II") ## [521. Longest Uncommon Subsequence I (Easy)](https://leetcode.com/problems/longest-uncommon-subsequence-i "最长特殊序列 Ⅰ") @@ -40,7 +40,7 @@ The input will be two strings, and the output needs to be the length of the long

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Longest Uncommon Subsequence II](https://github.com/openset/leetcode/tree/master/problems/longest-uncommon-subsequence-ii) (Medium) + 1. [Longest Uncommon Subsequence II](../longest-uncommon-subsequence-ii) (Medium) diff --git a/problems/longest-uncommon-subsequence-ii/README.md b/problems/longest-uncommon-subsequence-ii/README.md index bf2f523dc..996887d76 100644 --- a/problems/longest-uncommon-subsequence-ii/README.md +++ b/problems/longest-uncommon-subsequence-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-uncommon-subsequence-i "Longest Uncommon Subsequence I ") +[< Previous](../longest-uncommon-subsequence-i "Longest Uncommon Subsequence I ")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/continuous-subarray-sum "Continuous Subarray Sum") +[Next >](../continuous-subarray-sum "Continuous Subarray Sum") ## [522. Longest Uncommon Subsequence II (Medium)](https://leetcode.com/problems/longest-uncommon-subsequence-ii "最长特殊序列 II") @@ -38,7 +38,7 @@ The input will be a list of strings, and the output needs to be the length of th

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Longest Uncommon Subsequence I ](https://github.com/openset/leetcode/tree/master/problems/longest-uncommon-subsequence-i) (Easy) + 1. [Longest Uncommon Subsequence I ](../longest-uncommon-subsequence-i) (Easy) diff --git a/problems/longest-univalue-path/README.md b/problems/longest-univalue-path/README.md index c9e3b9d73..9fb322073 100644 --- a/problems/longest-univalue-path/README.md +++ b/problems/longest-univalue-path/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/repeated-string-match "Repeated String Match") +[< Previous](../repeated-string-match "Repeated String Match")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/knight-probability-in-chessboard "Knight Probability in Chessboard") +[Next >](../knight-probability-in-chessboard "Knight Probability in Chessboard") ## [687. Longest Univalue Path (Easy)](https://leetcode.com/problems/longest-univalue-path "最长同值路径") @@ -52,10 +52,10 @@

Note: The given binary tree has not more than 10000 nodes. The height of the tree is not more than 1000.

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions - 1. [Binary Tree Maximum Path Sum](https://github.com/openset/leetcode/tree/master/problems/binary-tree-maximum-path-sum) (Hard) - 1. [Count Univalue Subtrees](https://github.com/openset/leetcode/tree/master/problems/count-univalue-subtrees) (Medium) - 1. [Path Sum III](https://github.com/openset/leetcode/tree/master/problems/path-sum-iii) (Easy) + 1. [Binary Tree Maximum Path Sum](../binary-tree-maximum-path-sum) (Hard) + 1. [Count Univalue Subtrees](../count-univalue-subtrees) (Medium) + 1. [Path Sum III](../path-sum-iii) (Easy) diff --git a/problems/longest-valid-parentheses/README.md b/problems/longest-valid-parentheses/README.md index ace14c050..f459e20a3 100644 --- a/problems/longest-valid-parentheses/README.md +++ b/problems/longest-valid-parentheses/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/next-permutation "Next Permutation") +[< Previous](../next-permutation "Next Permutation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/search-in-rotated-sorted-array "Search in Rotated Sorted Array") +[Next >](../search-in-rotated-sorted-array "Search in Rotated Sorted Array") ## [32. Longest Valid Parentheses (Hard)](https://leetcode.com/problems/longest-valid-parentheses "最长有效括号") @@ -30,8 +30,8 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Valid Parentheses](https://github.com/openset/leetcode/tree/master/problems/valid-parentheses) (Easy) + 1. [Valid Parentheses](../valid-parentheses) (Easy) diff --git a/problems/longest-well-performing-interval/README.md b/problems/longest-well-performing-interval/README.md index 7c8cc3af6..f146b8769 100644 --- a/problems/longest-well-performing-interval/README.md +++ b/problems/longest-well-performing-interval/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/lowest-common-ancestor-of-deepest-leaves "Lowest Common Ancestor of Deepest Leaves") +[< Previous](../lowest-common-ancestor-of-deepest-leaves "Lowest Common Ancestor of Deepest Leaves")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/smallest-sufficient-team "Smallest Sufficient Team") +[Next >](../smallest-sufficient-team "Smallest Sufficient Team") ## [1124. Longest Well-Performing Interval (Medium)](https://leetcode.com/problems/longest-well-performing-interval "表现良好的最长时间段") @@ -37,7 +37,7 @@ ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] + [[Stack](../../tag/stack/README.md)] ### Hints
diff --git a/problems/longest-word-in-dictionary-through-deleting/README.md b/problems/longest-word-in-dictionary-through-deleting/README.md index 7cbef0140..6b9cecf28 100644 --- a/problems/longest-word-in-dictionary-through-deleting/README.md +++ b/problems/longest-word-in-dictionary-through-deleting/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/continuous-subarray-sum "Continuous Subarray Sum") +[< Previous](../continuous-subarray-sum "Continuous Subarray Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/contiguous-array "Contiguous Array") +[Next >](../contiguous-array "Contiguous Array") ## [524. Longest Word in Dictionary through Deleting (Medium)](https://leetcode.com/problems/longest-word-in-dictionary-through-deleting "通过删除字母匹配到字典里最长单词") @@ -44,8 +44,8 @@ s = "abpcplea", d = ["a","b","c"]

### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Longest Word in Dictionary](https://github.com/openset/leetcode/tree/master/problems/longest-word-in-dictionary) (Easy) + 1. [Longest Word in Dictionary](../longest-word-in-dictionary) (Easy) diff --git a/problems/longest-word-in-dictionary/README.md b/problems/longest-word-in-dictionary/README.md index de362edb5..13945cc3d 100644 --- a/problems/longest-word-in-dictionary/README.md +++ b/problems/longest-word-in-dictionary/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-k-th-smallest-pair-distance "Find K-th Smallest Pair Distance") +[< Previous](../find-k-th-smallest-pair-distance "Find K-th Smallest Pair Distance")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/accounts-merge "Accounts Merge") +[Next >](../accounts-merge "Accounts Merge") ## [720. Longest Word in Dictionary (Easy)](https://leetcode.com/problems/longest-word-in-dictionary "词典中最长的单词") @@ -40,12 +40,12 @@ Both "apply" and "apple" can be built from other words in the dictionary. Howeve

### Related Topics - [[Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Longest Word in Dictionary through Deleting](https://github.com/openset/leetcode/tree/master/problems/longest-word-in-dictionary-through-deleting) (Medium) - 1. [Implement Magic Dictionary](https://github.com/openset/leetcode/tree/master/problems/implement-magic-dictionary) (Medium) + 1. [Longest Word in Dictionary through Deleting](../longest-word-in-dictionary-through-deleting) (Medium) + 1. [Implement Magic Dictionary](../implement-magic-dictionary) (Medium) ### Hints
diff --git a/problems/loud-and-rich/README.md b/problems/loud-and-rich/README.md index 45015c10c..f10fc3568 100644 --- a/problems/loud-and-rich/README.md +++ b/problems/loud-and-rich/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/rectangle-area-ii "Rectangle Area II") +[< Previous](../rectangle-area-ii "Rectangle Area II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/peak-index-in-a-mountain-array "Peak Index in a Mountain Array") +[Next >](../peak-index-in-a-mountain-array "Peak Index in a Mountain Array") ## [851. Loud and Rich (Medium)](https://leetcode.com/problems/loud-and-rich "喧闹和富有") @@ -57,4 +57,4 @@ The other answers can be filled out with similar reasoning. ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md b/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md index 49e65f3cb..643c0884f 100644 --- a/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/palindrome-linked-list "Palindrome Linked List") +[< Previous](../palindrome-linked-list "Palindrome Linked List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/lowest-common-ancestor-of-a-binary-tree "Lowest Common Ancestor of a Binary Tree") +[Next >](../lowest-common-ancestor-of-a-binary-tree "Lowest Common Ancestor of a Binary Tree") ## [235. Lowest Common Ancestor of a Binary Search Tree (Easy)](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree "二叉搜索树的最近公共祖先") @@ -45,8 +45,8 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Lowest Common Ancestor of a Binary Tree](https://github.com/openset/leetcode/tree/master/problems/lowest-common-ancestor-of-a-binary-tree) (Medium) - 1. [Smallest Common Region](https://github.com/openset/leetcode/tree/master/problems/smallest-common-region) (Medium) + 1. [Lowest Common Ancestor of a Binary Tree](../lowest-common-ancestor-of-a-binary-tree) (Medium) + 1. [Smallest Common Region](../smallest-common-region) (Medium) diff --git a/problems/lowest-common-ancestor-of-a-binary-tree/README.md b/problems/lowest-common-ancestor-of-a-binary-tree/README.md index b7aea1b81..4224236f9 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/lowest-common-ancestor-of-a-binary-search-tree "Lowest Common Ancestor of a Binary Search Tree") +[< Previous](../lowest-common-ancestor-of-a-binary-search-tree "Lowest Common Ancestor of a Binary Search Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/delete-node-in-a-linked-list "Delete Node in a Linked List") +[Next >](../delete-node-in-a-linked-list "Delete Node in a Linked List") ## [236. Lowest Common Ancestor of a Binary Tree (Medium)](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree "二叉树的最近公共祖先") @@ -45,8 +45,8 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Lowest Common Ancestor of a Binary Search Tree](https://github.com/openset/leetcode/tree/master/problems/lowest-common-ancestor-of-a-binary-search-tree) (Easy) - 1. [Smallest Common Region](https://github.com/openset/leetcode/tree/master/problems/smallest-common-region) (Medium) + 1. [Lowest Common Ancestor of a Binary Search Tree](../lowest-common-ancestor-of-a-binary-search-tree) (Easy) + 1. [Smallest Common Region](../smallest-common-region) (Medium) diff --git a/problems/lowest-common-ancestor-of-deepest-leaves/README.md b/problems/lowest-common-ancestor-of-deepest-leaves/README.md index 1b1771fc5..134767ebe 100644 --- a/problems/lowest-common-ancestor-of-deepest-leaves/README.md +++ b/problems/lowest-common-ancestor-of-deepest-leaves/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/relative-sort-array "Relative Sort Array") +[< Previous](../relative-sort-array "Relative Sort Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-well-performing-interval "Longest Well-Performing Interval") +[Next >](../longest-well-performing-interval "Longest Well-Performing Interval") ## [1123. Lowest Common Ancestor of Deepest Leaves (Medium)](https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves "最深叶节点的最近公共祖先") @@ -56,8 +56,8 @@ The answer returned is a TreeNode object (not an array) with serialization " ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Hints
diff --git a/problems/lru-cache/README.md b/problems/lru-cache/README.md index d07901901..9fc8ceb01 100644 --- a/problems/lru-cache/README.md +++ b/problems/lru-cache/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-tree-postorder-traversal "Binary Tree Postorder Traversal") +[< Previous](../binary-tree-postorder-traversal "Binary Tree Postorder Traversal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/insertion-sort-list "Insertion Sort List") +[Next >](../insertion-sort-list "Insertion Sort List") ## [146. LRU Cache (Medium)](https://leetcode.com/problems/lru-cache "LRU缓存机制") @@ -40,9 +40,9 @@ cache.get(4); // returns 4

 

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions - 1. [LFU Cache](https://github.com/openset/leetcode/tree/master/problems/lfu-cache) (Hard) - 1. [Design In-Memory File System](https://github.com/openset/leetcode/tree/master/problems/design-in-memory-file-system) (Hard) - 1. [Design Compressed String Iterator](https://github.com/openset/leetcode/tree/master/problems/design-compressed-string-iterator) (Easy) + 1. [LFU Cache](../lfu-cache) (Hard) + 1. [Design In-Memory File System](../design-in-memory-file-system) (Hard) + 1. [Design Compressed String Iterator](../design-compressed-string-iterator) (Easy) diff --git a/problems/magic-squares-in-grid/README.md b/problems/magic-squares-in-grid/README.md index 97b317ee3..d7b2a0865 100644 --- a/problems/magic-squares-in-grid/README.md +++ b/problems/magic-squares-in-grid/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/similar-string-groups "Similar String Groups") +[< Previous](../similar-string-groups "Similar String Groups")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/keys-and-rooms "Keys and Rooms") +[Next >](../keys-and-rooms "Keys and Rooms") ## [840. Magic Squares In Grid (Easy)](https://leetcode.com/problems/magic-squares-in-grid "矩阵中的幻方") @@ -47,4 +47,4 @@ In total, there is only one magic square inside the given grid. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/magical-string/README.md b/problems/magical-string/README.md index 1cbf12567..5a1f060af 100644 --- a/problems/magical-string/README.md +++ b/problems/magical-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sliding-window-median "Sliding Window Median") +[< Previous](../sliding-window-median "Sliding Window Median")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/license-key-formatting "License Key Formatting") +[Next >](../license-key-formatting "License Key Formatting") ## [481. Magical String (Medium)](https://leetcode.com/problems/magical-string "神奇字符串") diff --git a/problems/majority-element-ii/README.md b/problems/majority-element-ii/README.md index 9a8c4e349..ba9295772 100644 --- a/problems/majority-element-ii/README.md +++ b/problems/majority-element-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/summary-ranges "Summary Ranges") +[< Previous](../summary-ranges "Summary Ranges")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-element-in-a-bst "Kth Smallest Element in a BST") +[Next >](../kth-smallest-element-in-a-bst "Kth Smallest Element in a BST") ## [229. Majority Element II (Medium)](https://leetcode.com/problems/majority-element-ii "求众数 II") @@ -28,11 +28,11 @@ Output: [1,2] ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Majority Element](https://github.com/openset/leetcode/tree/master/problems/majority-element) (Easy) - 1. [Check If a Number Is Majority Element in a Sorted Array](https://github.com/openset/leetcode/tree/master/problems/check-if-a-number-is-majority-element-in-a-sorted-array) (Easy) + 1. [Majority Element](../majority-element) (Easy) + 1. [Check If a Number Is Majority Element in a Sorted Array](../check-if-a-number-is-majority-element-in-a-sorted-array) (Easy) ### Hints
diff --git a/problems/majority-element/README.md b/problems/majority-element/README.md index 0c3be1c1f..146a0f308 100644 --- a/problems/majority-element/README.md +++ b/problems/majority-element/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/excel-sheet-column-title "Excel Sheet Column Title") +[< Previous](../excel-sheet-column-title "Excel Sheet Column Title")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/two-sum-iii-data-structure-design "Two Sum III - Data structure design") +[Next >](../two-sum-iii-data-structure-design "Two Sum III - Data structure design") ## [169. Majority Element (Easy)](https://leetcode.com/problems/majority-element "多数元素") @@ -29,10 +29,10 @@ ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions - 1. [Majority Element II](https://github.com/openset/leetcode/tree/master/problems/majority-element-ii) (Medium) - 1. [Check If a Number Is Majority Element in a Sorted Array](https://github.com/openset/leetcode/tree/master/problems/check-if-a-number-is-majority-element-in-a-sorted-array) (Easy) + 1. [Majority Element II](../majority-element-ii) (Medium) + 1. [Check If a Number Is Majority Element in a Sorted Array](../check-if-a-number-is-majority-element-in-a-sorted-array) (Easy) diff --git a/problems/make-array-strictly-increasing/README.md b/problems/make-array-strictly-increasing/README.md index 0bc4f461b..b8462c7ad 100644 --- a/problems/make-array-strictly-increasing/README.md +++ b/problems/make-array-strictly-increasing/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-subarray-sum-with-one-deletion "Maximum Subarray Sum with One Deletion") +[< Previous](../maximum-subarray-sum-with-one-deletion "Maximum Subarray Sum with One Deletion")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-bounded-blocking-queue "Design Bounded Blocking Queue") +[Next >](../design-bounded-blocking-queue "Design Bounded Blocking Queue") ## [1187. Make Array Strictly Increasing (Hard)](https://leetcode.com/problems/make-array-strictly-increasing "使数组严格递增") @@ -52,7 +52,7 @@

 

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/making-a-large-island/README.md b/problems/making-a-large-island/README.md index e06c2dd47..539b82767 100644 --- a/problems/making-a-large-island/README.md +++ b/problems/making-a-large-island/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/most-profit-assigning-work "Most Profit Assigning Work") +[< Previous](../most-profit-assigning-work "Most Profit Assigning Work")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/unique-letter-string "Unique Letter String") +[Next >](../unique-letter-string "Unique Letter String") ## [827. Making A Large Island (Hard)](https://leetcode.com/problems/making-a-large-island "最大人工岛") @@ -49,4 +49,4 @@

 

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/managers-with-at-least-5-direct-reports/README.md b/problems/managers-with-at-least-5-direct-reports/README.md index ea05e7977..f386177bb 100644 --- a/problems/managers-with-at-least-5-direct-reports/README.md +++ b/problems/managers-with-at-least-5-direct-reports/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/median-employee-salary "Median Employee Salary") +[< Previous](../median-employee-salary "Median Employee Salary")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-median-given-frequency-of-numbers "Find Median Given Frequency of Numbers") +[Next >](../find-median-given-frequency-of-numbers "Find Median Given Frequency of Numbers") ## [570. Managers with at Least 5 Direct Reports (Medium)](https://leetcode.com/problems/managers-with-at-least-5-direct-reports "至少有5名直接下属的经理") diff --git a/problems/map-sum-pairs/README.md b/problems/map-sum-pairs/README.md index 1e7f3763c..77155594d 100644 --- a/problems/map-sum-pairs/README.md +++ b/problems/map-sum-pairs/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/implement-magic-dictionary "Implement Magic Dictionary") +[< Previous](../implement-magic-dictionary "Implement Magic Dictionary")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-parenthesis-string "Valid Parenthesis String") +[Next >](../valid-parenthesis-string "Valid Parenthesis String") ## [677. Map Sum Pairs (Medium)](https://leetcode.com/problems/map-sum-pairs "键值映射") @@ -33,4 +33,4 @@ Input: sum("ap"), Output: 5

### Related Topics - [[Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] + [[Trie](../../tag/trie/README.md)] diff --git a/problems/market-analysis-i/README.md b/problems/market-analysis-i/README.md index a1a3c914a..076ba31a2 100644 --- a/problems/market-analysis-i/README.md +++ b/problems/market-analysis-i/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/online-majority-element-in-subarray "Online Majority Element In Subarray") +[< Previous](../online-majority-element-in-subarray "Online Majority Element In Subarray")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/market-analysis-ii "Market Analysis II") +[Next >](../market-analysis-ii "Market Analysis II") ## [1158. Market Analysis I (Medium)](https://leetcode.com/problems/market-analysis-i "") diff --git a/problems/market-analysis-ii/README.md b/problems/market-analysis-ii/README.md index 80d67976c..6638e8aa6 100644 --- a/problems/market-analysis-ii/README.md +++ b/problems/market-analysis-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/market-analysis-i "Market Analysis I") +[< Previous](../market-analysis-i "Market Analysis I")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-words-that-can-be-formed-by-characters "Find Words That Can Be Formed by Characters") +[Next >](../find-words-that-can-be-formed-by-characters "Find Words That Can Be Formed by Characters") ## [1159. Market Analysis II (Hard)](https://leetcode.com/problems/market-analysis-ii "") diff --git a/problems/masking-personal-information/README.md b/problems/masking-personal-information/README.md index f65e421de..0e1e348f6 100644 --- a/problems/masking-personal-information/README.md +++ b/problems/masking-personal-information/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/positions-of-large-groups "Positions of Large Groups") +[< Previous](../positions-of-large-groups "Positions of Large Groups")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/flipping-an-image "Flipping an Image") +[Next >](../flipping-an-image "Flipping an Image") ## [831. Masking Personal Information (Medium)](https://leetcode.com/problems/masking-personal-information "隐藏个人信息") @@ -89,4 +89,4 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/matchsticks-to-square/README.md b/problems/matchsticks-to-square/README.md index dd98cf31e..237257bd4 100644 --- a/problems/matchsticks-to-square/README.md +++ b/problems/matchsticks-to-square/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/concatenated-words "Concatenated Words") +[< Previous](../concatenated-words "Concatenated Words")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/ones-and-zeroes "Ones and Zeroes") +[Next >](../ones-and-zeroes "Ones and Zeroes") ## [473. Matchsticks to Square (Medium)](https://leetcode.com/problems/matchsticks-to-square "火柴拼正方形") @@ -41,7 +41,7 @@

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Hints
diff --git a/problems/matrix-cells-in-distance-order/README.md b/problems/matrix-cells-in-distance-order/README.md index 183665526..03b0443b0 100644 --- a/problems/matrix-cells-in-distance-order/README.md +++ b/problems/matrix-cells-in-distance-order/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/two-city-scheduling "Two City Scheduling") +[< Previous](../two-city-scheduling "Two City Scheduling")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-sum-of-two-non-overlapping-subarrays "Maximum Sum of Two Non-Overlapping Subarrays") +[Next >](../maximum-sum-of-two-non-overlapping-subarrays "Maximum Sum of Two Non-Overlapping Subarrays") ## [1030. Matrix Cells in Distance Order (Easy)](https://leetcode.com/problems/matrix-cells-in-distance-order "距离顺序排列矩阵单元格") @@ -63,4 +63,4 @@ There are other answers that would also be accepted as correct, such as [[1,2],[ ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] + [[Sort](../../tag/sort/README.md)] diff --git a/problems/max-area-of-island/README.md b/problems/max-area-of-island/README.md index 4cc679aaa..da1c96128 100644 --- a/problems/max-area-of-island/README.md +++ b/problems/max-area-of-island/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-distinct-islands "Number of Distinct Islands") +[< Previous](../number-of-distinct-islands "Number of Distinct Islands")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/count-binary-substrings "Count Binary Substrings") +[Next >](../count-binary-substrings "Count Binary Substrings") ## [695. Max Area of Island (Medium)](https://leetcode.com/problems/max-area-of-island "岛屿的最大面积") @@ -38,9 +38,9 @@ Given the above grid, return 0.

Note: The length of each dimension in the given grid does not exceed 50.

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Number of Islands](https://github.com/openset/leetcode/tree/master/problems/number-of-islands) (Medium) - 1. [Island Perimeter](https://github.com/openset/leetcode/tree/master/problems/island-perimeter) (Easy) + 1. [Number of Islands](../number-of-islands) (Medium) + 1. [Island Perimeter](../island-perimeter) (Easy) diff --git a/problems/max-chunks-to-make-sorted-ii/README.md b/problems/max-chunks-to-make-sorted-ii/README.md index 30c310ece..001a70daa 100644 --- a/problems/max-chunks-to-make-sorted-ii/README.md +++ b/problems/max-chunks-to-make-sorted-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reorganize-string "Reorganize String") +[< Previous](../reorganize-string "Reorganize String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/max-chunks-to-make-sorted "Max Chunks To Make Sorted") +[Next >](../max-chunks-to-make-sorted "Max Chunks To Make Sorted") ## [768. Max Chunks To Make Sorted II (Hard)](https://leetcode.com/problems/max-chunks-to-make-sorted-ii "最多能完成排序的块 II") @@ -49,10 +49,10 @@ However, splitting into [2, 1], [3], [4], [4] is the highest number of chunks po

 

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Max Chunks To Make Sorted](https://github.com/openset/leetcode/tree/master/problems/max-chunks-to-make-sorted) (Medium) + 1. [Max Chunks To Make Sorted](../max-chunks-to-make-sorted) (Medium) ### Hints
diff --git a/problems/max-chunks-to-make-sorted/README.md b/problems/max-chunks-to-make-sorted/README.md index cd0d3cdb5..646b94548 100644 --- a/problems/max-chunks-to-make-sorted/README.md +++ b/problems/max-chunks-to-make-sorted/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/max-chunks-to-make-sorted-ii "Max Chunks To Make Sorted II") +[< Previous](../max-chunks-to-make-sorted-ii "Max Chunks To Make Sorted II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iv "Basic Calculator IV") +[Next >](../basic-calculator-iv "Basic Calculator IV") ## [769. Max Chunks To Make Sorted (Medium)](https://leetcode.com/problems/max-chunks-to-make-sorted "最多能完成排序的块") @@ -45,10 +45,10 @@ However, splitting into [1, 0], [2], [3], [4] is the highest number of chunks po

 

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Max Chunks To Make Sorted II](https://github.com/openset/leetcode/tree/master/problems/max-chunks-to-make-sorted-ii) (Hard) + 1. [Max Chunks To Make Sorted II](../max-chunks-to-make-sorted-ii) (Hard) ### Hints
diff --git a/problems/max-consecutive-ones-ii/README.md b/problems/max-consecutive-ones-ii/README.md index d15435164..33099eacf 100644 --- a/problems/max-consecutive-ones-ii/README.md +++ b/problems/max-consecutive-ones-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/predict-the-winner "Predict the Winner") +[< Previous](../predict-the-winner "Predict the Winner")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/zuma-game "Zuma Game") +[Next >](../zuma-game "Zuma Game") ## [487. Max Consecutive Ones II (Medium)](https://leetcode.com/problems/max-consecutive-ones-ii "最大连续1的个数 II") @@ -36,8 +36,8 @@ What if the input numbers come in one by one as an infinite stream? In ot

### Related Topics - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Max Consecutive Ones](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones) (Easy) - 1. [Max Consecutive Ones III](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones-iii) (Medium) + 1. [Max Consecutive Ones](../max-consecutive-ones) (Easy) + 1. [Max Consecutive Ones III](../max-consecutive-ones-iii) (Medium) diff --git a/problems/max-consecutive-ones-iii/README.md b/problems/max-consecutive-ones-iii/README.md index d4661becf..508de2dfd 100644 --- a/problems/max-consecutive-ones-iii/README.md +++ b/problems/max-consecutive-ones-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/check-if-word-is-valid-after-substitutions "Check If Word Is Valid After Substitutions") +[< Previous](../check-if-word-is-valid-after-substitutions "Check If Word Is Valid After Substitutions")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximize-sum-of-array-after-k-negations "Maximize Sum Of Array After K Negations") +[Next >](../maximize-sum-of-array-after-k-negations "Maximize Sum Of Array After K Negations") ## [1004. Max Consecutive Ones III (Medium)](https://leetcode.com/problems/max-consecutive-ones-iii "最大连续1的个数 III") @@ -51,14 +51,14 @@ Bolded numbers were flipped from 0 to 1. The longest subarray is underlined. ### Related Topics - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions - 1. [Longest Substring with At Most K Distinct Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-k-distinct-characters) (Hard) - 1. [Longest Repeating Character Replacement](https://github.com/openset/leetcode/tree/master/problems/longest-repeating-character-replacement) (Medium) - 1. [Max Consecutive Ones](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones) (Easy) - 1. [Max Consecutive Ones II](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones-ii) (Medium) + 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Hard) + 1. [Longest Repeating Character Replacement](../longest-repeating-character-replacement) (Medium) + 1. [Max Consecutive Ones](../max-consecutive-ones) (Easy) + 1. [Max Consecutive Ones II](../max-consecutive-ones-ii) (Medium) ### Hints
diff --git a/problems/max-consecutive-ones/README.md b/problems/max-consecutive-ones/README.md index 4079de2d3..3b77bb078 100644 --- a/problems/max-consecutive-ones/README.md +++ b/problems/max-consecutive-ones/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-permutation "Find Permutation") +[< Previous](../find-permutation "Find Permutation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/predict-the-winner "Predict the Winner") +[Next >](../predict-the-winner "Predict the Winner") ## [485. Max Consecutive Ones (Easy)](https://leetcode.com/problems/max-consecutive-ones "最大连续1的个数") @@ -30,11 +30,11 @@

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Max Consecutive Ones II](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones-ii) (Medium) - 1. [Max Consecutive Ones III](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones-iii) (Medium) + 1. [Max Consecutive Ones II](../max-consecutive-ones-ii) (Medium) + 1. [Max Consecutive Ones III](../max-consecutive-ones-iii) (Medium) ### Hints
diff --git a/problems/max-increase-to-keep-city-skyline/README.md b/problems/max-increase-to-keep-city-skyline/README.md index db38fa6f5..74a6a85e5 100644 --- a/problems/max-increase-to-keep-city-skyline/README.md +++ b/problems/max-increase-to-keep-city-skyline/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-lines-to-write-string "Number of Lines To Write String") +[< Previous](../number-of-lines-to-write-string "Number of Lines To Write String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/soup-servings "Soup Servings") +[Next >](../soup-servings "Soup Servings") ## [807. Max Increase to Keep City Skyline (Medium)](https://leetcode.com/problems/max-increase-to-keep-city-skyline "保持城市天际线") diff --git a/problems/max-points-on-a-line/README.md b/problems/max-points-on-a-line/README.md index cb95fb3e8..316d5ef75 100644 --- a/problems/max-points-on-a-line/README.md +++ b/problems/max-points-on-a-line/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sort-list "Sort List") +[< Previous](../sort-list "Sort List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/evaluate-reverse-polish-notation "Evaluate Reverse Polish Notation") +[Next >](../evaluate-reverse-polish-notation "Evaluate Reverse Polish Notation") ## [149. Max Points on a Line (Hard)](https://leetcode.com/problems/max-points-on-a-line "直线上最多的点数") @@ -47,8 +47,8 @@

NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Line Reflection](https://github.com/openset/leetcode/tree/master/problems/line-reflection) (Medium) + 1. [Line Reflection](../line-reflection) (Medium) diff --git a/problems/max-stack/README.md b/problems/max-stack/README.md index 4f0e34aee..1f23c43b2 100644 --- a/problems/max-stack/README.md +++ b/problems/max-stack/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/range-module "Range Module") +[< Previous](../range-module "Range Module")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/1-bit-and-2-bit-characters "1-bit and 2-bit Characters") +[Next >](../1-bit-and-2-bit-characters "1-bit and 2-bit Characters") ## [716. Max Stack (Easy)](https://leetcode.com/problems/max-stack "最大栈") @@ -47,7 +47,7 @@ stack.top(); -> 5

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions - 1. [Min Stack](https://github.com/openset/leetcode/tree/master/problems/min-stack) (Easy) + 1. [Min Stack](../min-stack) (Easy) diff --git a/problems/max-sum-of-rectangle-no-larger-than-k/README.md b/problems/max-sum-of-rectangle-no-larger-than-k/README.md index fbbe76882..532527854 100644 --- a/problems/max-sum-of-rectangle-no-larger-than-k/README.md +++ b/problems/max-sum-of-rectangle-no-larger-than-k/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-hit-counter "Design Hit Counter") +[< Previous](../design-hit-counter "Design Hit Counter")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/nested-list-weight-sum-ii "Nested List Weight Sum II") +[Next >](../nested-list-weight-sum-ii "Nested List Weight Sum II") ## [363. Max Sum of Rectangle No Larger Than K (Hard)](https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k "矩形区域不超过 K 的最大数值和") @@ -29,6 +29,6 @@ ### Related Topics - [[Queue](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Queue](../../tag/queue/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/maximal-rectangle/README.md b/problems/maximal-rectangle/README.md index c727578e5..74cafe69a 100644 --- a/problems/maximal-rectangle/README.md +++ b/problems/maximal-rectangle/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/largest-rectangle-in-histogram "Largest Rectangle in Histogram") +[< Previous](../largest-rectangle-in-histogram "Largest Rectangle in Histogram")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/partition-list "Partition List") +[Next >](../partition-list "Partition List") ## [85. Maximal Rectangle (Hard)](https://leetcode.com/problems/maximal-rectangle "最大矩形") @@ -27,11 +27,11 @@ ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Largest Rectangle in Histogram](https://github.com/openset/leetcode/tree/master/problems/largest-rectangle-in-histogram) (Hard) - 1. [Maximal Square](https://github.com/openset/leetcode/tree/master/problems/maximal-square) (Medium) + 1. [Largest Rectangle in Histogram](../largest-rectangle-in-histogram) (Hard) + 1. [Maximal Square](../maximal-square) (Medium) diff --git a/problems/maximal-square/README.md b/problems/maximal-square/README.md index 9266e0698..07e1c6484 100644 --- a/problems/maximal-square/README.md +++ b/problems/maximal-square/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate-iii "Contains Duplicate III") +[< Previous](../contains-duplicate-iii "Contains Duplicate III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/count-complete-tree-nodes "Count Complete Tree Nodes") +[Next >](../count-complete-tree-nodes "Count Complete Tree Nodes") ## [221. Maximal Square (Medium)](https://leetcode.com/problems/maximal-square "最大正方形") @@ -27,8 +27,8 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Maximal Rectangle](https://github.com/openset/leetcode/tree/master/problems/maximal-rectangle) (Hard) - 1. [Largest Plus Sign](https://github.com/openset/leetcode/tree/master/problems/largest-plus-sign) (Medium) + 1. [Maximal Rectangle](../maximal-rectangle) (Hard) + 1. [Largest Plus Sign](../largest-plus-sign) (Medium) diff --git a/problems/maximize-distance-to-closest-person/README.md b/problems/maximize-distance-to-closest-person/README.md index 74cf86044..9f748c650 100644 --- a/problems/maximize-distance-to-closest-person/README.md +++ b/problems/maximize-distance-to-closest-person/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shifting-letters "Shifting Letters") +[< Previous](../shifting-letters "Shifting Letters")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/rectangle-area-ii "Rectangle Area II") +[Next >](../rectangle-area-ii "Rectangle Area II") ## [849. Maximize Distance to Closest Person (Easy)](https://leetcode.com/problems/maximize-distance-to-closest-person "到最近的人的最大距离") @@ -51,7 +51,7 @@ This is the maximum distance possible, so the answer is 3. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Exam Room](https://github.com/openset/leetcode/tree/master/problems/exam-room) (Medium) + 1. [Exam Room](../exam-room) (Medium) diff --git a/problems/maximize-sum-of-array-after-k-negations/README.md b/problems/maximize-sum-of-array-after-k-negations/README.md index af99ba214..59af8a1bf 100644 --- a/problems/maximize-sum-of-array-after-k-negations/README.md +++ b/problems/maximize-sum-of-array-after-k-negations/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones-iii "Max Consecutive Ones III") +[< Previous](../max-consecutive-ones-iii "Max Consecutive Ones III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/clumsy-factorial "Clumsy Factorial") +[Next >](../clumsy-factorial "Clumsy Factorial") ## [1005. Maximize Sum Of Array After K Negations (Easy)](https://leetcode.com/problems/maximize-sum-of-array-after-k-negations "K 次取反后最大化的数组和") @@ -56,4 +56,4 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/maximum-average-subarray-i/README.md b/problems/maximum-average-subarray-i/README.md index 81d9ac835..b44fcb666 100644 --- a/problems/maximum-average-subarray-i/README.md +++ b/problems/maximum-average-subarray-i/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-search-autocomplete-system "Design Search Autocomplete System") +[< Previous](../design-search-autocomplete-system "Design Search Autocomplete System")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-average-subarray-ii "Maximum Average Subarray II") +[Next >](../maximum-average-subarray-ii "Maximum Average Subarray II") ## [643. Maximum Average Subarray I (Easy)](https://leetcode.com/problems/maximum-average-subarray-i "子数组最大平均数 I") @@ -33,7 +33,7 @@

 

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Maximum Average Subarray II](https://github.com/openset/leetcode/tree/master/problems/maximum-average-subarray-ii) (Hard) + 1. [Maximum Average Subarray II](../maximum-average-subarray-ii) (Hard) diff --git a/problems/maximum-average-subarray-ii/README.md b/problems/maximum-average-subarray-ii/README.md index 305e7f7c3..d6203b0d6 100644 --- a/problems/maximum-average-subarray-ii/README.md +++ b/problems/maximum-average-subarray-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-average-subarray-i "Maximum Average Subarray I") +[< Previous](../maximum-average-subarray-i "Maximum Average Subarray I")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/set-mismatch "Set Mismatch") +[Next >](../set-mismatch "Set Mismatch") ## [644. Maximum Average Subarray II (Hard)](https://leetcode.com/problems/maximum-average-subarray-ii "最大平均子段和 II") @@ -37,8 +37,8 @@ Thus return 12.75.

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Maximum Average Subarray I](https://github.com/openset/leetcode/tree/master/problems/maximum-average-subarray-i) (Easy) + 1. [Maximum Average Subarray I](../maximum-average-subarray-i) (Easy) diff --git a/problems/maximum-average-subtree/README.md b/problems/maximum-average-subtree/README.md index 14ebff937..93cadd773 100644 --- a/problems/maximum-average-subtree/README.md +++ b/problems/maximum-average-subtree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-vowels-from-a-string "Remove Vowels from a String") +[< Previous](../remove-vowels-from-a-string "Remove Vowels from a String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/divide-array-into-increasing-sequences "Divide Array Into Increasing Sequences") +[Next >](../divide-array-into-increasing-sequences "Divide Array Into Increasing Sequences") ## [1120. Maximum Average Subtree (Medium)](https://leetcode.com/problems/maximum-average-subtree "子树的最大平均值") @@ -42,7 +42,7 @@ So the answer is 6 which is the maximum. ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Hints
diff --git a/problems/maximum-binary-tree-ii/README.md b/problems/maximum-binary-tree-ii/README.md index 9e09f6341..cccc87c6a 100644 --- a/problems/maximum-binary-tree-ii/README.md +++ b/problems/maximum-binary-tree-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-the-town-judge "Find the Town Judge") +[< Previous](../find-the-town-judge "Find the Town Judge")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/available-captures-for-rook "Available Captures for Rook") +[Next >](../available-captures-for-rook "Available Captures for Rook") ## [998. Maximum Binary Tree II (Medium)](https://leetcode.com/problems/maximum-binary-tree-ii "最大二叉树 II") @@ -72,7 +72,7 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Maximum Binary Tree](https://github.com/openset/leetcode/tree/master/problems/maximum-binary-tree) (Medium) + 1. [Maximum Binary Tree](../maximum-binary-tree) (Medium) diff --git a/problems/maximum-binary-tree/README.md b/problems/maximum-binary-tree/README.md index 736e9759e..0c572f88c 100644 --- a/problems/maximum-binary-tree/README.md +++ b/problems/maximum-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/two-sum-iv-input-is-a-bst "Two Sum IV - Input is a BST") +[< Previous](../two-sum-iv-input-is-a-bst "Two Sum IV - Input is a BST")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/print-binary-tree "Print Binary Tree") +[Next >](../print-binary-tree "Print Binary Tree") ## [654. Maximum Binary Tree (Medium)](https://leetcode.com/problems/maximum-binary-tree "最大二叉树") @@ -46,7 +46,7 @@ Construct the maximum tree by the given array and output the root node of this t

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Maximum Binary Tree II](https://github.com/openset/leetcode/tree/master/problems/maximum-binary-tree-ii) (Medium) + 1. [Maximum Binary Tree II](../maximum-binary-tree-ii) (Medium) diff --git a/problems/maximum-depth-of-binary-tree/README.md b/problems/maximum-depth-of-binary-tree/README.md index e16f6eb81..8b17749cf 100644 --- a/problems/maximum-depth-of-binary-tree/README.md +++ b/problems/maximum-depth-of-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-tree-zigzag-level-order-traversal "Binary Tree Zigzag Level Order Traversal") +[< Previous](../binary-tree-zigzag-level-order-traversal "Binary Tree Zigzag Level Order Traversal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-preorder-and-inorder-traversal "Construct Binary Tree from Preorder and Inorder Traversal") +[Next >](../construct-binary-tree-from-preorder-and-inorder-traversal "Construct Binary Tree from Preorder and Inorder Traversal") ## [104. Maximum Depth of Binary Tree (Easy)](https://leetcode.com/problems/maximum-depth-of-binary-tree "二叉树的最大深度") @@ -31,10 +31,10 @@

return its depth = 3.

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Balanced Binary Tree](https://github.com/openset/leetcode/tree/master/problems/balanced-binary-tree) (Easy) - 1. [Minimum Depth of Binary Tree](https://github.com/openset/leetcode/tree/master/problems/minimum-depth-of-binary-tree) (Easy) - 1. [Maximum Depth of N-ary Tree](https://github.com/openset/leetcode/tree/master/problems/maximum-depth-of-n-ary-tree) (Easy) + 1. [Balanced Binary Tree](../balanced-binary-tree) (Easy) + 1. [Minimum Depth of Binary Tree](../minimum-depth-of-binary-tree) (Easy) + 1. [Maximum Depth of N-ary Tree](../maximum-depth-of-n-ary-tree) (Easy) diff --git a/problems/maximum-depth-of-n-ary-tree/README.md b/problems/maximum-depth-of-n-ary-tree/README.md index 2ee83378d..3f997bd6d 100644 --- a/problems/maximum-depth-of-n-ary-tree/README.md +++ b/problems/maximum-depth-of-n-ary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/quad-tree-intersection "Quad Tree Intersection") +[< Previous](../quad-tree-intersection "Quad Tree Intersection")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/subarray-sum-equals-k "Subarray Sum Equals K") +[Next >](../subarray-sum-equals-k "Subarray Sum Equals K") ## [559. Maximum Depth of N-ary Tree (Easy)](https://leetcode.com/problems/maximum-depth-of-n-ary-tree "N叉树的最大深度") @@ -45,9 +45,9 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions - 1. [Maximum Depth of Binary Tree](https://github.com/openset/leetcode/tree/master/problems/maximum-depth-of-binary-tree) (Easy) + 1. [Maximum Depth of Binary Tree](../maximum-depth-of-binary-tree) (Easy) diff --git a/problems/maximum-difference-between-node-and-ancestor/README.md b/problems/maximum-difference-between-node-and-ancestor/README.md index 1ef8c0405..8b2246096 100644 --- a/problems/maximum-difference-between-node-and-ancestor/README.md +++ b/problems/maximum-difference-between-node-and-ancestor/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/divisor-game "Divisor Game") +[< Previous](../divisor-game "Divisor Game")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-arithmetic-sequence "Longest Arithmetic Sequence") +[Next >](../longest-arithmetic-sequence "Longest Arithmetic Sequence") ## [1026. Maximum Difference Between Node and Ancestor (Medium)](https://leetcode.com/problems/maximum-difference-between-node-and-ancestor "节点与其祖先之间的最大差值") @@ -43,8 +43,8 @@ Among all possible differences, the maximum value of 7 is obtained by |8 - 1| = ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Hints
diff --git a/problems/maximum-distance-in-arrays/README.md b/problems/maximum-distance-in-arrays/README.md index 5e3f5d8f4..04caa67f0 100644 --- a/problems/maximum-distance-in-arrays/README.md +++ b/problems/maximum-distance-in-arrays/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/add-one-row-to-tree "Add One Row to Tree") +[< Previous](../add-one-row-to-tree "Add One Row to Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-factorization "Minimum Factorization") +[Next >](../minimum-factorization "Minimum Factorization") ## [624. Maximum Distance in Arrays (Easy)](https://leetcode.com/problems/maximum-distance-in-arrays "数组列表中的最大距离") @@ -35,5 +35,5 @@ One way to reach the maximum distance 4 is to pick 1 in the first or third array

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/maximum-equal-frequency/README.md b/problems/maximum-equal-frequency/README.md index 00ac74daa..a8bbb691a 100644 --- a/problems/maximum-equal-frequency/README.md +++ b/problems/maximum-equal-frequency/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/dice-roll-simulation "Dice Roll Simulation") +[< Previous](../dice-roll-simulation "Dice Roll Simulation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/report-contiguous-dates "Report Contiguous Dates") +[Next >](../report-contiguous-dates "Report Contiguous Dates") ## [1224. Maximum Equal Frequency (Hard)](https://leetcode.com/problems/maximum-equal-frequency "最大相等频率") @@ -54,7 +54,7 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
diff --git a/problems/maximum-frequency-stack/README.md b/problems/maximum-frequency-stack/README.md index 26d80ee53..203c00854 100644 --- a/problems/maximum-frequency-stack/README.md +++ b/problems/maximum-frequency-stack/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/all-possible-full-binary-trees "All Possible Full Binary Trees") +[< Previous](../all-possible-full-binary-trees "All Possible Full Binary Trees")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/monotonic-array "Monotonic Array") +[Next >](../monotonic-array "Monotonic Array") ## [895. Maximum Frequency Stack (Hard)](https://leetcode.com/problems/maximum-frequency-stack "最大频率栈") @@ -66,5 +66,5 @@ The stack becomes [5,7]. ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/maximum-gap/README.md b/problems/maximum-gap/README.md index 15109a7a3..bc4492580 100644 --- a/problems/maximum-gap/README.md +++ b/problems/maximum-gap/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/missing-ranges "Missing Ranges") +[< Previous](../missing-ranges "Missing Ranges")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/compare-version-numbers "Compare Version Numbers") +[Next >](../compare-version-numbers "Compare Version Numbers") ## [164. Maximum Gap (Hard)](https://leetcode.com/problems/maximum-gap "最大间距") @@ -38,4 +38,4 @@ ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] + [[Sort](../../tag/sort/README.md)] diff --git a/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md b/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md index 309cc81be..95138ca76 100644 --- a/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md +++ b/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/circular-permutation-in-binary-representation "Circular Permutation in Binary Representation") +[< Previous](../circular-permutation-in-binary-representation "Circular Permutation in Binary Representation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/tiling-a-rectangle-with-the-fewest-squares "Tiling a Rectangle with the Fewest Squares") +[Next >](../tiling-a-rectangle-with-the-fewest-squares "Tiling a Rectangle with the Fewest Squares") ## [1239. Maximum Length of a Concatenated String with Unique Characters (Medium)](https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters "串联字符串的最大长度") @@ -50,8 +50,8 @@ Maximum length is 4. ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Hints
diff --git a/problems/maximum-length-of-pair-chain/README.md b/problems/maximum-length-of-pair-chain/README.md index 3666514ca..30e3a7061 100644 --- a/problems/maximum-length-of-pair-chain/README.md +++ b/problems/maximum-length-of-pair-chain/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/set-mismatch "Set Mismatch") +[< Previous](../set-mismatch "Set Mismatch")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/palindromic-substrings "Palindromic Substrings") +[Next >](../palindromic-substrings "Palindromic Substrings") ## [646. Maximum Length of Pair Chain (Medium)](https://leetcode.com/problems/maximum-length-of-pair-chain "最长数对链") @@ -39,8 +39,8 @@ Given a set of pairs, find the length longest chain which can be formed. You nee

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Longest Increasing Subsequence](https://github.com/openset/leetcode/tree/master/problems/longest-increasing-subsequence) (Medium) - 1. [Increasing Subsequences](https://github.com/openset/leetcode/tree/master/problems/increasing-subsequences) (Medium) + 1. [Longest Increasing Subsequence](../longest-increasing-subsequence) (Medium) + 1. [Increasing Subsequences](../increasing-subsequences) (Medium) diff --git a/problems/maximum-length-of-repeated-subarray/README.md b/problems/maximum-length-of-repeated-subarray/README.md index accfa83a0..efa97c82f 100644 --- a/problems/maximum-length-of-repeated-subarray/README.md +++ b/problems/maximum-length-of-repeated-subarray/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/1-bit-and-2-bit-characters "1-bit and 2-bit Characters") +[< Previous](../1-bit-and-2-bit-characters "1-bit and 2-bit Characters")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-k-th-smallest-pair-distance "Find K-th Smallest Pair Distance") +[Next >](../find-k-th-smallest-pair-distance "Find K-th Smallest Pair Distance") ## [718. Maximum Length of Repeated Subarray (Medium)](https://leetcode.com/problems/maximum-length-of-repeated-subarray "最长重复子数组") @@ -36,13 +36,13 @@ The repeated subarray with maximum length is [3, 2, 1].

 

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Minimum Size Subarray Sum](https://github.com/openset/leetcode/tree/master/problems/minimum-size-subarray-sum) (Medium) + 1. [Minimum Size Subarray Sum](../minimum-size-subarray-sum) (Medium) ### Hints
diff --git a/problems/maximum-level-sum-of-a-binary-tree/README.md b/problems/maximum-level-sum-of-a-binary-tree/README.md index 4fe1f0eef..4754b1d4f 100644 --- a/problems/maximum-level-sum-of-a-binary-tree/README.md +++ b/problems/maximum-level-sum-of-a-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-words-that-can-be-formed-by-characters "Find Words That Can Be Formed by Characters") +[< Previous](../find-words-that-can-be-formed-by-characters "Find Words That Can Be Formed by Characters")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/as-far-from-land-as-possible "As Far from Land as Possible") +[Next >](../as-far-from-land-as-possible "As Far from Land as Possible") ## [1161. Maximum Level Sum of a Binary Tree (Medium)](https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree "最大层内元素和") @@ -41,7 +41,7 @@ So we return the level with the maximum sum which is level 2. ### Related Topics - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Graph](../../tag/graph/README.md)] ### Hints
diff --git a/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/README.md b/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/README.md index dd2c49d0a..fcd02181e 100644 --- a/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/README.md +++ b/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/delete-nodes-and-return-forest "Delete Nodes And Return Forest") +[< Previous](../delete-nodes-and-return-forest "Delete Nodes And Return Forest")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/highest-grade-for-each-student "Highest Grade For Each Student") +[Next >](../highest-grade-for-each-student "Highest Grade For Each Student") ## [1111. Maximum Nesting Depth of Two Valid Parentheses Strings (Medium)](https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings "有效括号的嵌套深度") @@ -60,5 +60,5 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/maximum-number-of-balloons/README.md b/problems/maximum-number-of-balloons/README.md index 734eca84c..c8548021d 100644 --- a/problems/maximum-number-of-balloons/README.md +++ b/problems/maximum-number-of-balloons/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-bounded-blocking-queue "Design Bounded Blocking Queue") +[< Previous](../design-bounded-blocking-queue "Design Bounded Blocking Queue")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reverse-substrings-between-each-pair-of-parentheses "Reverse Substrings Between Each Pair of Parentheses") +[Next >](../reverse-substrings-between-each-pair-of-parentheses "Reverse Substrings Between Each Pair of Parentheses") ## [1189. Maximum Number of Balloons (Easy)](https://leetcode.com/problems/maximum-number-of-balloons "“气球” 的最大数量") @@ -50,8 +50,8 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/maximum-number-of-ones/README.md b/problems/maximum-number-of-ones/README.md index fffe911e4..5445b73ec 100644 --- a/problems/maximum-number-of-ones/README.md +++ b/problems/maximum-number-of-ones/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-to-target-color "Shortest Distance to Target Color") +[< Previous](../shortest-distance-to-target-color "Shortest Distance to Target Color")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/distance-between-bus-stops "Distance Between Bus Stops") +[Next >](../distance-between-bus-stops "Distance Between Bus Stops") ## [1183. Maximum Number of Ones (Hard)](https://leetcode.com/problems/maximum-number-of-ones "矩阵中 1 的最大数量") @@ -50,8 +50,8 @@ The best solution that has 4 ones is: ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/maximum-of-absolute-value-expression/README.md b/problems/maximum-of-absolute-value-expression/README.md index 06e03c1a5..80a75c955 100644 --- a/problems/maximum-of-absolute-value-expression/README.md +++ b/problems/maximum-of-absolute-value-expression/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-tree-from-leaf-values "Minimum Cost Tree From Leaf Values") +[< Previous](../minimum-cost-tree-from-leaf-values "Minimum Cost Tree From Leaf Values")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reported-posts-ii "Reported Posts II") +[Next >](../reported-posts-ii "Reported Posts II") ## [1131. Maximum of Absolute Value Expression (Medium)](https://leetcode.com/problems/maximum-of-absolute-value-expression "绝对值表达式的最大值") @@ -41,8 +41,8 @@ ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/maximum-product-of-three-numbers/README.md b/problems/maximum-product-of-three-numbers/README.md index e82527a72..eda024fee 100644 --- a/problems/maximum-product-of-three-numbers/README.md +++ b/problems/maximum-product-of-three-numbers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/swap-salary "Swap Salary") +[< Previous](../swap-salary "Swap Salary")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/k-inverse-pairs-array "K Inverse Pairs Array") +[Next >](../k-inverse-pairs-array "K Inverse Pairs Array") ## [628. Maximum Product of Three Numbers (Easy)](https://leetcode.com/problems/maximum-product-of-three-numbers "三个数的最大乘积") @@ -41,8 +41,8 @@

 

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Maximum Product Subarray](https://github.com/openset/leetcode/tree/master/problems/maximum-product-subarray) (Medium) + 1. [Maximum Product Subarray](../maximum-product-subarray) (Medium) diff --git a/problems/maximum-product-of-word-lengths/README.md b/problems/maximum-product-of-word-lengths/README.md index 470a1c12e..5b3597874 100644 --- a/problems/maximum-product-of-word-lengths/README.md +++ b/problems/maximum-product-of-word-lengths/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-from-all-buildings "Shortest Distance from All Buildings") +[< Previous](../shortest-distance-from-all-buildings "Shortest Distance from All Buildings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/bulb-switcher "Bulb Switcher") +[Next >](../bulb-switcher "Bulb Switcher") ## [318. Maximum Product of Word Lengths (Medium)](https://leetcode.com/problems/maximum-product-of-word-lengths "最大单词长度乘积") @@ -36,4 +36,4 @@ ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/maximum-product-subarray/README.md b/problems/maximum-product-subarray/README.md index 618124ffc..9b93e539b 100644 --- a/problems/maximum-product-subarray/README.md +++ b/problems/maximum-product-subarray/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reverse-words-in-a-string "Reverse Words in a String") +[< Previous](../reverse-words-in-a-string "Reverse Words in a String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-minimum-in-rotated-sorted-array "Find Minimum in Rotated Sorted Array") +[Next >](../find-minimum-in-rotated-sorted-array "Find Minimum in Rotated Sorted Array") ## [152. Maximum Product Subarray (Medium)](https://leetcode.com/problems/maximum-product-subarray "乘积最大子序列") @@ -29,12 +29,12 @@ Explanation: The result cannot be 2, because [-2,-1] is not a subarray. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Maximum Subarray](https://github.com/openset/leetcode/tree/master/problems/maximum-subarray) (Easy) - 1. [House Robber](https://github.com/openset/leetcode/tree/master/problems/house-robber) (Easy) - 1. [Product of Array Except Self](https://github.com/openset/leetcode/tree/master/problems/product-of-array-except-self) (Medium) - 1. [Maximum Product of Three Numbers](https://github.com/openset/leetcode/tree/master/problems/maximum-product-of-three-numbers) (Easy) - 1. [Subarray Product Less Than K](https://github.com/openset/leetcode/tree/master/problems/subarray-product-less-than-k) (Medium) + 1. [Maximum Subarray](../maximum-subarray) (Easy) + 1. [House Robber](../house-robber) (Easy) + 1. [Product of Array Except Self](../product-of-array-except-self) (Medium) + 1. [Maximum Product of Three Numbers](../maximum-product-of-three-numbers) (Easy) + 1. [Subarray Product Less Than K](../subarray-product-less-than-k) (Medium) diff --git a/problems/maximum-profit-in-job-scheduling/README.md b/problems/maximum-profit-in-job-scheduling/README.md index 2ec8b7d67..9201f646b 100644 --- a/problems/maximum-profit-in-job-scheduling/README.md +++ b/problems/maximum-profit-in-job-scheduling/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/replace-the-substring-for-balanced-string "Replace the Substring for Balanced String") +[< Previous](../replace-the-substring-for-balanced-string "Replace the Substring for Balanced String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/web-crawler "Web Crawler") +[Next >](../web-crawler "Web Crawler") ## [1235. Maximum Profit in Job Scheduling (Hard)](https://leetcode.com/problems/maximum-profit-in-job-scheduling "规划兼职工作") @@ -60,9 +60,9 @@ Profit obtained 150 = 20 + 70 + 60. ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/maximum-score-words-formed-by-letters/README.md b/problems/maximum-score-words-formed-by-letters/README.md index 91faabd61..1ca66233a 100644 --- a/problems/maximum-score-words-formed-by-letters/README.md +++ b/problems/maximum-score-words-formed-by-letters/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-closed-islands "Number of Closed Islands") +[< Previous](../number-of-closed-islands "Number of Closed Islands")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/encode-number "Encode Number") +[Next >](../encode-number "Encode Number") ## [1255. Maximum Score Words Formed by Letters (Hard)](https://leetcode.com/problems/maximum-score-words-formed-by-letters "得分最高的单词集合") @@ -60,7 +60,7 @@ Letter "e" can only be used once. ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
diff --git a/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md b/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md index ad3036b92..b989ac737 100644 --- a/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md +++ b/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sequential-digits "Sequential Digits") +[< Previous](../sequential-digits "Sequential Digits")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-path-in-a-grid-with-obstacles-elimination "Shortest Path in a Grid with Obstacles Elimination") +[Next >](../shortest-path-in-a-grid-with-obstacles-elimination "Shortest Path in a Grid with Obstacles Elimination") ## [1292. Maximum Side Length of a Square with Sum Less than or Equal to Threshold (Medium)](https://leetcode.com/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold "元素和小于等于阈值的正方形的最大边长") @@ -55,8 +55,8 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
diff --git a/problems/maximum-size-subarray-sum-equals-k/README.md b/problems/maximum-size-subarray-sum-equals-k/README.md index d46d32ffa..e963bfaec 100644 --- a/problems/maximum-size-subarray-sum-equals-k/README.md +++ b/problems/maximum-size-subarray-sum-equals-k/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/wiggle-sort-ii "Wiggle Sort II") +[< Previous](../wiggle-sort-ii "Wiggle Sort II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/power-of-three "Power of Three") +[Next >](../power-of-three "Power of Three") ## [325. Maximum Size Subarray Sum Equals k (Medium)](https://leetcode.com/problems/maximum-size-subarray-sum-equals-k "和等于 k 的最长子数组长度") @@ -35,13 +35,13 @@ Explanation: The subarray [-1, 2] sums to 1 and is the lon Can you do it in O(n) time?

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Minimum Size Subarray Sum](https://github.com/openset/leetcode/tree/master/problems/minimum-size-subarray-sum) (Medium) - 1. [Range Sum Query - Immutable](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-immutable) (Easy) - 1. [Contiguous Array](https://github.com/openset/leetcode/tree/master/problems/contiguous-array) (Medium) - 1. [Subarray Product Less Than K](https://github.com/openset/leetcode/tree/master/problems/subarray-product-less-than-k) (Medium) + 1. [Minimum Size Subarray Sum](../minimum-size-subarray-sum) (Medium) + 1. [Range Sum Query - Immutable](../range-sum-query-immutable) (Easy) + 1. [Contiguous Array](../contiguous-array) (Medium) + 1. [Subarray Product Less Than K](../subarray-product-less-than-k) (Medium) ### Hints
diff --git a/problems/maximum-subarray-sum-with-one-deletion/README.md b/problems/maximum-subarray-sum-with-one-deletion/README.md index 518b82fb3..86a0b4bc9 100644 --- a/problems/maximum-subarray-sum-with-one-deletion/README.md +++ b/problems/maximum-subarray-sum-with-one-deletion/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/day-of-the-week "Day of the Week") +[< Previous](../day-of-the-week "Day of the Week")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/make-array-strictly-increasing "Make Array Strictly Increasing") +[Next >](../make-array-strictly-increasing "Make Array Strictly Increasing") ## [1186. Maximum Subarray Sum with One Deletion (Medium)](https://leetcode.com/problems/maximum-subarray-sum-with-one-deletion "删除一次得到子数组最大和") @@ -48,7 +48,7 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/maximum-subarray/README.md b/problems/maximum-subarray/README.md index 0a5589864..a16dc4f22 100644 --- a/problems/maximum-subarray/README.md +++ b/problems/maximum-subarray/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/n-queens-ii "N-Queens II") +[< Previous](../n-queens-ii "N-Queens II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/spiral-matrix "Spiral Matrix") +[Next >](../spiral-matrix "Spiral Matrix") ## [53. Maximum Subarray (Easy)](https://leetcode.com/problems/maximum-subarray "最大子序和") @@ -26,12 +26,12 @@

If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle.

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Array](../../tag/array/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Best Time to Buy and Sell Stock](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock) (Easy) - 1. [Maximum Product Subarray](https://github.com/openset/leetcode/tree/master/problems/maximum-product-subarray) (Medium) - 1. [Degree of an Array](https://github.com/openset/leetcode/tree/master/problems/degree-of-an-array) (Easy) - 1. [Longest Turbulent Subarray](https://github.com/openset/leetcode/tree/master/problems/longest-turbulent-subarray) (Medium) + 1. [Best Time to Buy and Sell Stock](../best-time-to-buy-and-sell-stock) (Easy) + 1. [Maximum Product Subarray](../maximum-product-subarray) (Medium) + 1. [Degree of an Array](../degree-of-an-array) (Easy) + 1. [Longest Turbulent Subarray](../longest-turbulent-subarray) (Medium) diff --git a/problems/maximum-sum-circular-subarray/README.md b/problems/maximum-sum-circular-subarray/README.md index e0b7b364d..333658c86 100644 --- a/problems/maximum-sum-circular-subarray/README.md +++ b/problems/maximum-sum-circular-subarray/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reverse-only-letters "Reverse Only Letters") +[< Previous](../reverse-only-letters "Reverse Only Letters")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/complete-binary-tree-inserter "Complete Binary Tree Inserter") +[Next >](../complete-binary-tree-inserter "Complete Binary Tree Inserter") ## [918. Maximum Sum Circular Subarray (Medium)](https://leetcode.com/problems/maximum-sum-circular-subarray "环形子数组的最大和") @@ -77,7 +77,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md b/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md index 88c019729..1e23d04f4 100644 --- a/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md +++ b/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/knight-probability-in-chessboard "Knight Probability in Chessboard") +[< Previous](../knight-probability-in-chessboard "Knight Probability in Chessboard")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/employee-importance "Employee Importance") +[Next >](../employee-importance "Employee Importance") ## [689. Maximum Sum of 3 Non-Overlapping Subarrays (Hard)](https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays "三个无重叠子数组的最大和") @@ -39,8 +39,8 @@ We could have also taken [2, 1], but an answer of [1, 3, 5] would be lexicograph

 

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Best Time to Buy and Sell Stock III](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-iii) (Hard) + 1. [Best Time to Buy and Sell Stock III](../best-time-to-buy-and-sell-stock-iii) (Hard) diff --git a/problems/maximum-sum-of-two-non-overlapping-subarrays/README.md b/problems/maximum-sum-of-two-non-overlapping-subarrays/README.md index 8e30edbea..a21696936 100644 --- a/problems/maximum-sum-of-two-non-overlapping-subarrays/README.md +++ b/problems/maximum-sum-of-two-non-overlapping-subarrays/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/matrix-cells-in-distance-order "Matrix Cells in Distance Order") +[< Previous](../matrix-cells-in-distance-order "Matrix Cells in Distance Order")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/stream-of-characters "Stream of Characters") +[Next >](../stream-of-characters "Stream of Characters") ## [1031. Maximum Sum of Two Non-Overlapping Subarrays (Medium)](https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays "两个非重叠子数组的最大和") @@ -67,7 +67,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/maximum-swap/README.md b/problems/maximum-swap/README.md index 13094a7b4..4ad9961e3 100644 --- a/problems/maximum-swap/README.md +++ b/problems/maximum-swap/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/trim-a-binary-search-tree "Trim a Binary Search Tree") +[< Previous](../trim-a-binary-search-tree "Trim a Binary Search Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/second-minimum-node-in-a-binary-tree "Second Minimum Node In a Binary Tree") +[Next >](../second-minimum-node-in-a-binary-tree "Second Minimum Node In a Binary Tree") ## [670. Maximum Swap (Medium)](https://leetcode.com/problems/maximum-swap "最大交换") @@ -39,8 +39,8 @@ Given a non-negative integer, you could swap two digits at most once to g

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Create Maximum Number](https://github.com/openset/leetcode/tree/master/problems/create-maximum-number) (Hard) + 1. [Create Maximum Number](../create-maximum-number) (Hard) diff --git a/problems/maximum-vacation-days/README.md b/problems/maximum-vacation-days/README.md index 350f6dd4f..4868ce70c 100644 --- a/problems/maximum-vacation-days/README.md +++ b/problems/maximum-vacation-days/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/permutation-in-string "Permutation in String") +[< Previous](../permutation-in-string "Permutation in String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/median-employee-salary "Median Employee Salary") +[Next >](../median-employee-salary "Median Employee Salary") ## [568. Maximum Vacation Days (Hard)](https://leetcode.com/problems/maximum-vacation-days "最大休假天数") @@ -72,10 +72,10 @@ One of the best strategies is:

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Cheapest Flights Within K Stops](https://github.com/openset/leetcode/tree/master/problems/cheapest-flights-within-k-stops) (Medium) + 1. [Cheapest Flights Within K Stops](../cheapest-flights-within-k-stops) (Medium) ### Hints
diff --git a/problems/maximum-width-of-binary-tree/README.md b/problems/maximum-width-of-binary-tree/README.md index ebcfadf24..d94b75efe 100644 --- a/problems/maximum-width-of-binary-tree/README.md +++ b/problems/maximum-width-of-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/image-smoother "Image Smoother") +[< Previous](../image-smoother "Image Smoother")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/equal-tree-partition "Equal Tree Partition") +[Next >](../equal-tree-partition "Equal Tree Partition") ## [662. Maximum Width of Binary Tree (Medium)](https://leetcode.com/problems/maximum-width-of-binary-tree "二叉树最大宽度") @@ -81,4 +81,4 @@

Note: Answer will in the range of 32-bit signed integer.

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] diff --git a/problems/maximum-width-ramp/README.md b/problems/maximum-width-ramp/README.md index 5f81645fe..9710ac3e8 100644 --- a/problems/maximum-width-ramp/README.md +++ b/problems/maximum-width-ramp/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/n-repeated-element-in-size-2n-array "N-Repeated Element in Size 2N Array") +[< Previous](../n-repeated-element-in-size-2n-array "N-Repeated Element in Size 2N Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-area-rectangle-ii "Minimum Area Rectangle II") +[Next >](../minimum-area-rectangle-ii "Minimum Area Rectangle II") ## [962. Maximum Width Ramp (Medium)](https://leetcode.com/problems/maximum-width-ramp "最大宽度坡") @@ -55,4 +55,4 @@ The maximum width ramp is achieved at (i, j) = (2, 9): A[2] = 1 and A[9] = 1. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/maximum-xor-of-two-numbers-in-an-array/README.md b/problems/maximum-xor-of-two-numbers-in-an-array/README.md index 4763ec29d..f7b9891d7 100644 --- a/problems/maximum-xor-of-two-numbers-in-an-array/README.md +++ b/problems/maximum-xor-of-two-numbers-in-an-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/strong-password-checker "Strong Password Checker") +[< Previous](../strong-password-checker "Strong Password Checker")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-word-square "Valid Word Square") +[Next >](../valid-word-square "Valid Word Square") ## [421. Maximum XOR of Two Numbers in an Array (Medium)](https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array "数组中两个数的最大异或值") @@ -30,5 +30,5 @@

 

### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Trie](../../tag/trie/README.md)] diff --git a/problems/median-employee-salary/README.md b/problems/median-employee-salary/README.md index fedb6e968..67da590a3 100644 --- a/problems/median-employee-salary/README.md +++ b/problems/median-employee-salary/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-vacation-days "Maximum Vacation Days") +[< Previous](../maximum-vacation-days "Maximum Vacation Days")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/managers-with-at-least-5-direct-reports "Managers with at Least 5 Direct Reports") +[Next >](../managers-with-at-least-5-direct-reports "Managers with at Least 5 Direct Reports") ## [569. Median Employee Salary (Hard)](https://leetcode.com/problems/median-employee-salary "员工薪水中位数") @@ -52,7 +52,7 @@ ### Similar Questions - 1. [Find Median Given Frequency of Numbers](https://github.com/openset/leetcode/tree/master/problems/find-median-given-frequency-of-numbers) (Hard) + 1. [Find Median Given Frequency of Numbers](../find-median-given-frequency-of-numbers) (Hard) ### Hints
diff --git a/problems/median-of-two-sorted-arrays/README.md b/problems/median-of-two-sorted-arrays/README.md index 0adff0ffc..b840cf7e6 100644 --- a/problems/median-of-two-sorted-arrays/README.md +++ b/problems/median-of-two-sorted-arrays/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-substring-without-repeating-characters "Longest Substring Without Repeating Characters") +[< Previous](../longest-substring-without-repeating-characters "Longest Substring Without Repeating Characters")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-palindromic-substring "Longest Palindromic Substring") +[Next >](../longest-palindromic-substring "Longest Palindromic Substring") ## [4. Median of Two Sorted Arrays (Hard)](https://leetcode.com/problems/median-of-two-sorted-arrays "寻找两个有序数组的中位数") @@ -36,6 +36,6 @@ The median is (2 + 3)/2 = 2.5 ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] diff --git a/problems/meeting-rooms-ii/README.md b/problems/meeting-rooms-ii/README.md index 7ec49187b..4070e9afe 100644 --- a/problems/meeting-rooms-ii/README.md +++ b/problems/meeting-rooms-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/meeting-rooms "Meeting Rooms") +[< Previous](../meeting-rooms "Meeting Rooms")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/factor-combinations "Factor Combinations") +[Next >](../factor-combinations "Factor Combinations") ## [253. Meeting Rooms II (Medium)](https://leetcode.com/problems/meeting-rooms-ii "会议室 II") @@ -28,15 +28,15 @@

NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Sort](../../tag/sort/README.md)] ### Similar Questions - 1. [Merge Intervals](https://github.com/openset/leetcode/tree/master/problems/merge-intervals) (Medium) - 1. [Meeting Rooms](https://github.com/openset/leetcode/tree/master/problems/meeting-rooms) (Easy) - 1. [Minimum Number of Arrows to Burst Balloons](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-arrows-to-burst-balloons) (Medium) - 1. [Car Pooling](https://github.com/openset/leetcode/tree/master/problems/car-pooling) (Medium) + 1. [Merge Intervals](../merge-intervals) (Medium) + 1. [Meeting Rooms](../meeting-rooms) (Easy) + 1. [Minimum Number of Arrows to Burst Balloons](../minimum-number-of-arrows-to-burst-balloons) (Medium) + 1. [Car Pooling](../car-pooling) (Medium) ### Hints
diff --git a/problems/meeting-rooms/README.md b/problems/meeting-rooms/README.md index dea7c3edd..c6a566afe 100644 --- a/problems/meeting-rooms/README.md +++ b/problems/meeting-rooms/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/flatten-2d-vector "Flatten 2D Vector") +[< Previous](../flatten-2d-vector "Flatten 2D Vector")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/meeting-rooms-ii "Meeting Rooms II") +[Next >](../meeting-rooms-ii "Meeting Rooms II") ## [252. Meeting Rooms (Easy)](https://leetcode.com/problems/meeting-rooms "会议室") @@ -30,8 +30,8 @@

NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] + [[Sort](../../tag/sort/README.md)] ### Similar Questions - 1. [Merge Intervals](https://github.com/openset/leetcode/tree/master/problems/merge-intervals) (Medium) - 1. [Meeting Rooms II](https://github.com/openset/leetcode/tree/master/problems/meeting-rooms-ii) (Medium) + 1. [Merge Intervals](../merge-intervals) (Medium) + 1. [Meeting Rooms II](../meeting-rooms-ii) (Medium) diff --git a/problems/meeting-scheduler/README.md b/problems/meeting-scheduler/README.md index a12f38600..361377598 100644 --- a/problems/meeting-scheduler/README.md +++ b/problems/meeting-scheduler/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/missing-number-in-arithmetic-progression "Missing Number In Arithmetic Progression") +[< Previous](../missing-number-in-arithmetic-progression "Missing Number In Arithmetic Progression")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/toss-strange-coins "Toss Strange Coins") +[Next >](../toss-strange-coins "Toss Strange Coins") ## [1229. Meeting Scheduler (Medium)](https://leetcode.com/problems/meeting-scheduler "安排会议日程") @@ -47,7 +47,7 @@ ### Related Topics - [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] + [[Line Sweep](../../tag/line-sweep/README.md)] ### Hints
diff --git a/problems/merge-intervals/README.md b/problems/merge-intervals/README.md index 9d2bbc4a7..b1da7f102 100644 --- a/problems/merge-intervals/README.md +++ b/problems/merge-intervals/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/jump-game "Jump Game") +[< Previous](../jump-game "Jump Game")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/insert-interval "Insert Interval") +[Next >](../insert-interval "Insert Interval") ## [56. Merge Intervals (Medium)](https://leetcode.com/problems/merge-intervals "合并区间") @@ -31,16 +31,16 @@

NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Insert Interval](https://github.com/openset/leetcode/tree/master/problems/insert-interval) (Hard) - 1. [Meeting Rooms](https://github.com/openset/leetcode/tree/master/problems/meeting-rooms) (Easy) - 1. [Meeting Rooms II](https://github.com/openset/leetcode/tree/master/problems/meeting-rooms-ii) (Medium) - 1. [Teemo Attacking](https://github.com/openset/leetcode/tree/master/problems/teemo-attacking) (Medium) - 1. [Add Bold Tag in String](https://github.com/openset/leetcode/tree/master/problems/add-bold-tag-in-string) (Medium) - 1. [Range Module](https://github.com/openset/leetcode/tree/master/problems/range-module) (Hard) - 1. [Employee Free Time](https://github.com/openset/leetcode/tree/master/problems/employee-free-time) (Hard) - 1. [Partition Labels](https://github.com/openset/leetcode/tree/master/problems/partition-labels) (Medium) - 1. [Interval List Intersections](https://github.com/openset/leetcode/tree/master/problems/interval-list-intersections) (Medium) + 1. [Insert Interval](../insert-interval) (Hard) + 1. [Meeting Rooms](../meeting-rooms) (Easy) + 1. [Meeting Rooms II](../meeting-rooms-ii) (Medium) + 1. [Teemo Attacking](../teemo-attacking) (Medium) + 1. [Add Bold Tag in String](../add-bold-tag-in-string) (Medium) + 1. [Range Module](../range-module) (Hard) + 1. [Employee Free Time](../employee-free-time) (Hard) + 1. [Partition Labels](../partition-labels) (Medium) + 1. [Interval List Intersections](../interval-list-intersections) (Medium) diff --git a/problems/merge-k-sorted-lists/README.md b/problems/merge-k-sorted-lists/README.md index 849d58d26..28fc7a4fc 100644 --- a/problems/merge-k-sorted-lists/README.md +++ b/problems/merge-k-sorted-lists/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/generate-parentheses "Generate Parentheses") +[< Previous](../generate-parentheses "Generate Parentheses")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/swap-nodes-in-pairs "Swap Nodes in Pairs") +[Next >](../swap-nodes-in-pairs "Swap Nodes in Pairs") ## [23. Merge k Sorted Lists (Hard)](https://leetcode.com/problems/merge-k-sorted-lists "合并K个排序链表") @@ -26,10 +26,10 @@ ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions - 1. [Merge Two Sorted Lists](https://github.com/openset/leetcode/tree/master/problems/merge-two-sorted-lists) (Easy) - 1. [Ugly Number II](https://github.com/openset/leetcode/tree/master/problems/ugly-number-ii) (Medium) + 1. [Merge Two Sorted Lists](../merge-two-sorted-lists) (Easy) + 1. [Ugly Number II](../ugly-number-ii) (Medium) diff --git a/problems/merge-sorted-array/README.md b/problems/merge-sorted-array/README.md index e817c123c..9624f6514 100644 --- a/problems/merge-sorted-array/README.md +++ b/problems/merge-sorted-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/scramble-string "Scramble String") +[< Previous](../scramble-string "Scramble String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/gray-code "Gray Code") +[Next >](../gray-code "Gray Code") ## [88. Merge Sorted Array (Easy)](https://leetcode.com/problems/merge-sorted-array "合并两个有序数组") @@ -31,13 +31,13 @@ nums2 = [2,5,6], n = 3 ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Merge Two Sorted Lists](https://github.com/openset/leetcode/tree/master/problems/merge-two-sorted-lists) (Easy) - 1. [Squares of a Sorted Array](https://github.com/openset/leetcode/tree/master/problems/squares-of-a-sorted-array) (Easy) - 1. [Interval List Intersections](https://github.com/openset/leetcode/tree/master/problems/interval-list-intersections) (Medium) + 1. [Merge Two Sorted Lists](../merge-two-sorted-lists) (Easy) + 1. [Squares of a Sorted Array](../squares-of-a-sorted-array) (Easy) + 1. [Interval List Intersections](../interval-list-intersections) (Medium) ### Hints
diff --git a/problems/merge-two-binary-trees/README.md b/problems/merge-two-binary-trees/README.md index ec7caa749..36437c476 100644 --- a/problems/merge-two-binary-trees/README.md +++ b/problems/merge-two-binary-trees/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/add-bold-tag-in-string "Add Bold Tag in String") +[< Previous](../add-bold-tag-in-string "Add Bold Tag in String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/students-report-by-geography "Students Report By Geography") +[Next >](../students-report-by-geography "Students Report By Geography") ## [617. Merge Two Binary Trees (Easy)](https://leetcode.com/problems/merge-two-binary-trees "合并二叉树") @@ -39,4 +39,4 @@ Merged tree:

Note: The merging process must start from the root nodes of both trees.

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] diff --git a/problems/merge-two-sorted-lists/README.md b/problems/merge-two-sorted-lists/README.md index 54d3145d0..565a0b7e3 100644 --- a/problems/merge-two-sorted-lists/README.md +++ b/problems/merge-two-sorted-lists/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-parentheses "Valid Parentheses") +[< Previous](../valid-parentheses "Valid Parentheses")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/generate-parentheses "Generate Parentheses") +[Next >](../generate-parentheses "Generate Parentheses") ## [21. Merge Two Sorted Lists (Easy)](https://leetcode.com/problems/merge-two-sorted-lists "合并两个有序链表") @@ -21,10 +21,10 @@

### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Merge k Sorted Lists](https://github.com/openset/leetcode/tree/master/problems/merge-k-sorted-lists) (Hard) - 1. [Merge Sorted Array](https://github.com/openset/leetcode/tree/master/problems/merge-sorted-array) (Easy) - 1. [Sort List](https://github.com/openset/leetcode/tree/master/problems/sort-list) (Medium) - 1. [Shortest Word Distance II](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance-ii) (Medium) + 1. [Merge k Sorted Lists](../merge-k-sorted-lists) (Hard) + 1. [Merge Sorted Array](../merge-sorted-array) (Easy) + 1. [Sort List](../sort-list) (Medium) + 1. [Shortest Word Distance II](../shortest-word-distance-ii) (Medium) diff --git a/problems/middle-of-the-linked-list/README.md b/problems/middle-of-the-linked-list/README.md index 42914c432..6b2f44165 100644 --- a/problems/middle-of-the-linked-list/README.md +++ b/problems/middle-of-the-linked-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/koko-eating-bananas "Koko Eating Bananas") +[< Previous](../koko-eating-bananas "Koko Eating Bananas")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/stone-game "Stone Game") +[Next >](../stone-game "Stone Game") ## [876. Middle of the Linked List (Easy)](https://leetcode.com/problems/middle-of-the-linked-list "链表的中间结点") @@ -48,4 +48,4 @@ Since the list has two middle nodes with values 3 and 4, we return the second on ### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/min-cost-climbing-stairs/README.md b/problems/min-cost-climbing-stairs/README.md index a4afd7abe..1e99f1c43 100644 --- a/problems/min-cost-climbing-stairs/README.md +++ b/problems/min-cost-climbing-stairs/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/prefix-and-suffix-search "Prefix and Suffix Search") +[< Previous](../prefix-and-suffix-search "Prefix and Suffix Search")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/largest-number-at-least-twice-of-others "Largest Number At Least Twice of Others") +[Next >](../largest-number-at-least-twice-of-others "Largest Number At Least Twice of Others") ## [746. Min Cost Climbing Stairs (Easy)](https://leetcode.com/problems/min-cost-climbing-stairs "使用最小花费爬楼梯") @@ -41,11 +41,11 @@ Once you pay the cost, you can either climb one or two steps. You need to find m

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Climbing Stairs](https://github.com/openset/leetcode/tree/master/problems/climbing-stairs) (Easy) + 1. [Climbing Stairs](../climbing-stairs) (Easy) ### Hints
diff --git a/problems/min-stack/README.md b/problems/min-stack/README.md index 46c6f646c..769278c94 100644 --- a/problems/min-stack/README.md +++ b/problems/min-stack/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-minimum-in-rotated-sorted-array-ii "Find Minimum in Rotated Sorted Array II") +[< Previous](../find-minimum-in-rotated-sorted-array-ii "Find Minimum in Rotated Sorted Array II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-tree-upside-down "Binary Tree Upside Down") +[Next >](../binary-tree-upside-down "Binary Tree Upside Down") ## [155. Min Stack (Easy)](https://leetcode.com/problems/min-stack "最小栈") @@ -38,12 +38,12 @@ minStack.getMin(); --> Returns -2.

 

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions - 1. [Sliding Window Maximum](https://github.com/openset/leetcode/tree/master/problems/sliding-window-maximum) (Hard) - 1. [Max Stack](https://github.com/openset/leetcode/tree/master/problems/max-stack) (Easy) + 1. [Sliding Window Maximum](../sliding-window-maximum) (Hard) + 1. [Max Stack](../max-stack) (Easy) ### Hints
diff --git a/problems/minesweeper/README.md b/problems/minesweeper/README.md index 99123aaad..079809c35 100644 --- a/problems/minesweeper/README.md +++ b/problems/minesweeper/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-weight "Random Pick with Weight") +[< Previous](../random-pick-with-weight "Random Pick with Weight")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-absolute-difference-in-bst "Minimum Absolute Difference in BST") +[Next >](../minimum-absolute-difference-in-bst "Minimum Absolute Difference in BST") ## [529. Minesweeper (Medium)](https://leetcode.com/problems/minesweeper "扫雷游戏") @@ -84,5 +84,5 @@ Click : [1,2] ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/mini-parser/README.md b/problems/mini-parser/README.md index 031d480e6..8f3720ae7 100644 --- a/problems/mini-parser/README.md +++ b/problems/mini-parser/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shuffle-an-array "Shuffle an Array") +[< Previous](../shuffle-an-array "Shuffle an Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/lexicographical-numbers "Lexicographical Numbers") +[Next >](../lexicographical-numbers "Lexicographical Numbers") ## [385. Mini Parser (Medium)](https://leetcode.com/problems/mini-parser "迷你语法分析器") @@ -47,10 +47,10 @@ Return a NestedInteger object containing a nested list with 2 elements:

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Flatten Nested List Iterator](https://github.com/openset/leetcode/tree/master/problems/flatten-nested-list-iterator) (Medium) - 1. [Ternary Expression Parser](https://github.com/openset/leetcode/tree/master/problems/ternary-expression-parser) (Medium) - 1. [Remove Comments](https://github.com/openset/leetcode/tree/master/problems/remove-comments) (Medium) + 1. [Flatten Nested List Iterator](../flatten-nested-list-iterator) (Medium) + 1. [Ternary Expression Parser](../ternary-expression-parser) (Medium) + 1. [Remove Comments](../remove-comments) (Medium) diff --git a/problems/minimize-malware-spread-ii/README.md b/problems/minimize-malware-spread-ii/README.md index eed9861f8..7c8751027 100644 --- a/problems/minimize-malware-spread-ii/README.md +++ b/problems/minimize-malware-spread-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/three-equal-parts "Three Equal Parts") +[< Previous](../three-equal-parts "Three Equal Parts")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/unique-email-addresses "Unique Email Addresses") +[Next >](../unique-email-addresses "Unique Email Addresses") ## [928. Minimize Malware Spread II (Hard)](https://leetcode.com/problems/minimize-malware-spread-ii "尽量减少恶意软件的传播 II") @@ -66,6 +66,6 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] diff --git a/problems/minimize-malware-spread/README.md b/problems/minimize-malware-spread/README.md index e3d39401e..dcfc452ec 100644 --- a/problems/minimize-malware-spread/README.md +++ b/problems/minimize-malware-spread/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/3sum-with-multiplicity "3Sum With Multiplicity") +[< Previous](../3sum-with-multiplicity "3Sum With Multiplicity")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/long-pressed-name "Long Pressed Name") +[Next >](../long-pressed-name "Long Pressed Name") ## [924. Minimize Malware Spread (Hard)](https://leetcode.com/problems/minimize-malware-spread "尽量减少恶意软件的传播") @@ -60,5 +60,5 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] diff --git a/problems/minimize-max-distance-to-gas-station/README.md b/problems/minimize-max-distance-to-gas-station/README.md index 57d09d745..d2187464a 100644 --- a/problems/minimize-max-distance-to-gas-station/README.md +++ b/problems/minimize-max-distance-to-gas-station/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sliding-puzzle "Sliding Puzzle") +[< Previous](../sliding-puzzle "Sliding Puzzle")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/global-and-local-inversions "Global and Local Inversions") +[Next >](../global-and-local-inversions "Global and Local Inversions") ## [774. Minimize Max Distance to Gas Station (Hard)](https://leetcode.com/problems/minimize-max-distance-to-gas-station "最小化去加油站的最大距离") @@ -34,10 +34,10 @@ ### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Koko Eating Bananas](https://github.com/openset/leetcode/tree/master/problems/koko-eating-bananas) (Medium) + 1. [Koko Eating Bananas](../koko-eating-bananas) (Medium) ### Hints
diff --git a/problems/minimize-rounding-error-to-meet-target/README.md b/problems/minimize-rounding-error-to-meet-target/README.md index c35c22eca..1fa02d885 100644 --- a/problems/minimize-rounding-error-to-meet-target/README.md +++ b/problems/minimize-rounding-error-to-meet-target/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/campus-bikes "Campus Bikes") +[< Previous](../campus-bikes "Campus Bikes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/all-paths-from-source-lead-to-destination "All Paths from Source Lead to Destination") +[Next >](../all-paths-from-source-lead-to-destination "All Paths from Source Lead to Destination") ## [1058. Minimize Rounding Error to Meet Target (Medium)](https://leetcode.com/problems/minimize-rounding-error-to-meet-target "最小化舍入误差以满足目标") @@ -46,9 +46,9 @@ It is impossible to meet the target. ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/minimum-absolute-difference-in-bst/README.md b/problems/minimum-absolute-difference-in-bst/README.md index 2608ad08c..129639f52 100644 --- a/problems/minimum-absolute-difference-in-bst/README.md +++ b/problems/minimum-absolute-difference-in-bst/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minesweeper "Minesweeper") +[< Previous](../minesweeper "Minesweeper")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/lonely-pixel-i "Lonely Pixel I") +[Next >](../lonely-pixel-i "Lonely Pixel I") ## [530. Minimum Absolute Difference in BST (Easy)](https://leetcode.com/problems/minimum-absolute-difference-in-bst "二叉搜索树的最小绝对差") @@ -36,7 +36,7 @@ The minimum absolute difference is 1, which is the difference between 2 and 1 (o

Note: There are at least two nodes in this BST.

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [K-diff Pairs in an Array](https://github.com/openset/leetcode/tree/master/problems/k-diff-pairs-in-an-array) (Easy) + 1. [K-diff Pairs in an Array](../k-diff-pairs-in-an-array) (Easy) diff --git a/problems/minimum-absolute-difference/README.md b/problems/minimum-absolute-difference/README.md index cca15c21f..316cff22b 100644 --- a/problems/minimum-absolute-difference/README.md +++ b/problems/minimum-absolute-difference/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-time-to-build-blocks "Minimum Time to Build Blocks") +[< Previous](../minimum-time-to-build-blocks "Minimum Time to Build Blocks")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/ugly-number-iii "Ugly Number III") +[Next >](../ugly-number-iii "Ugly Number III") ## [1200. Minimum Absolute Difference (Easy)](https://leetcode.com/problems/minimum-absolute-difference "最小绝对差") @@ -52,7 +52,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/minimum-add-to-make-parentheses-valid/README.md b/problems/minimum-add-to-make-parentheses-valid/README.md index 77d338a41..986a5f5cb 100644 --- a/problems/minimum-add-to-make-parentheses-valid/README.md +++ b/problems/minimum-add-to-make-parentheses-valid/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-music-playlists "Number of Music Playlists") +[< Previous](../number-of-music-playlists "Number of Music Playlists")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sort-array-by-parity-ii "Sort Array By Parity II") +[Next >](../sort-array-by-parity-ii "Sort Array By Parity II") ## [921. Minimum Add to Make Parentheses Valid (Medium)](https://leetcode.com/problems/minimum-add-to-make-parentheses-valid "使括号有效的最少添加") @@ -76,5 +76,5 @@ ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/minimum-area-rectangle-ii/README.md b/problems/minimum-area-rectangle-ii/README.md index bd77cfbe7..add0abfb5 100644 --- a/problems/minimum-area-rectangle-ii/README.md +++ b/problems/minimum-area-rectangle-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-width-ramp "Maximum Width Ramp") +[< Previous](../maximum-width-ramp "Maximum Width Ramp")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/least-operators-to-express-number "Least Operators to Express Number") +[Next >](../least-operators-to-express-number "Least Operators to Express Number") ## [963. Minimum Area Rectangle II (Medium)](https://leetcode.com/problems/minimum-area-rectangle-ii "最小面积矩形 II") @@ -76,5 +76,5 @@ ### Related Topics - [[Geometry](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/minimum-area-rectangle/README.md b/problems/minimum-area-rectangle/README.md index 2f26e23a0..cba1ba034 100644 --- a/problems/minimum-area-rectangle/README.md +++ b/problems/minimum-area-rectangle/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/range-sum-of-bst "Range Sum of BST") +[< Previous](../range-sum-of-bst "Range Sum of BST")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/distinct-subsequences-ii "Distinct Subsequences II") +[Next >](../distinct-subsequences-ii "Distinct Subsequences II") ## [939. Minimum Area Rectangle (Medium)](https://leetcode.com/problems/minimum-area-rectangle "最小面积矩形") @@ -47,4 +47,4 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/minimum-ascii-delete-sum-for-two-strings/README.md b/problems/minimum-ascii-delete-sum-for-two-strings/README.md index 3bf34105c..3418ad60f 100644 --- a/problems/minimum-ascii-delete-sum-for-two-strings/README.md +++ b/problems/minimum-ascii-delete-sum-for-two-strings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-distinct-islands-ii "Number of Distinct Islands II") +[< Previous](../number-of-distinct-islands-ii "Number of Distinct Islands II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/subarray-product-less-than-k "Subarray Product Less Than K") +[Next >](../subarray-product-less-than-k "Subarray Product Less Than K") ## [712. Minimum ASCII Delete Sum for Two Strings (Medium)](https://leetcode.com/problems/minimum-ascii-delete-sum-for-two-strings "两个字符串的最小ASCII删除和") @@ -40,12 +40,12 @@ If instead we turned both strings into "lee" or "eet", we would get answers of 4

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Edit Distance](https://github.com/openset/leetcode/tree/master/problems/edit-distance) (Hard) - 1. [Longest Increasing Subsequence](https://github.com/openset/leetcode/tree/master/problems/longest-increasing-subsequence) (Medium) - 1. [Delete Operation for Two Strings](https://github.com/openset/leetcode/tree/master/problems/delete-operation-for-two-strings) (Medium) + 1. [Edit Distance](../edit-distance) (Hard) + 1. [Longest Increasing Subsequence](../longest-increasing-subsequence) (Medium) + 1. [Delete Operation for Two Strings](../delete-operation-for-two-strings) (Medium) ### Hints
diff --git a/problems/minimum-cost-for-tickets/README.md b/problems/minimum-cost-for-tickets/README.md index 35ac2e6a6..ef7d3fdc9 100644 --- a/problems/minimum-cost-for-tickets/README.md +++ b/problems/minimum-cost-for-tickets/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/triples-with-bitwise-and-equal-to-zero "Triples with Bitwise AND Equal To Zero") +[< Previous](../triples-with-bitwise-and-equal-to-zero "Triples with Bitwise AND Equal To Zero")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/string-without-aaa-or-bbb "String Without AAA or BBB") +[Next >](../string-without-aaa-or-bbb "String Without AAA or BBB") ## [983. Minimum Cost For Tickets (Medium)](https://leetcode.com/problems/minimum-cost-for-tickets "最低票价") @@ -67,7 +67,7 @@ In total you spent $17 and covered all the days of your travel. ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Coin Change](https://github.com/openset/leetcode/tree/master/problems/coin-change) (Medium) + 1. [Coin Change](../coin-change) (Medium) diff --git a/problems/minimum-cost-to-connect-sticks/README.md b/problems/minimum-cost-to-connect-sticks/README.md index d8f8984bc..eb1202625 100644 --- a/problems/minimum-cost-to-connect-sticks/README.md +++ b/problems/minimum-cost-to-connect-sticks/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-file-system "Design File System") +[< Previous](../design-file-system "Design File System")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/optimize-water-distribution-in-a-village "Optimize Water Distribution in a Village") +[Next >](../optimize-water-distribution-in-a-village "Optimize Water Distribution in a Village") ## [1167. Minimum Cost to Connect Sticks (Medium)](https://leetcode.com/problems/minimum-cost-to-connect-sticks "连接棒材的最低费用") @@ -34,10 +34,10 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions - 1. [Minimum Cost to Merge Stones](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-to-merge-stones) (Hard) + 1. [Minimum Cost to Merge Stones](../minimum-cost-to-merge-stones) (Hard) ### Hints
diff --git a/problems/minimum-cost-to-hire-k-workers/README.md b/problems/minimum-cost-to-hire-k-workers/README.md index e1febff1c..20dcf52f7 100644 --- a/problems/minimum-cost-to-hire-k-workers/README.md +++ b/problems/minimum-cost-to-hire-k-workers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/score-of-parentheses "Score of Parentheses") +[< Previous](../score-of-parentheses "Score of Parentheses")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/mirror-reflection "Mirror Reflection") +[Next >](../mirror-reflection "Mirror Reflection") ## [857. Minimum Cost to Hire K Workers (Hard)](https://leetcode.com/problems/minimum-cost-to-hire-k-workers "雇佣 K 名工人的最低成本") @@ -59,4 +59,4 @@ ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] + [[Heap](../../tag/heap/README.md)] diff --git a/problems/minimum-cost-to-merge-stones/README.md b/problems/minimum-cost-to-merge-stones/README.md index 719888d7f..f249cea94 100644 --- a/problems/minimum-cost-to-merge-stones/README.md +++ b/problems/minimum-cost-to-merge-stones/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/available-captures-for-rook "Available Captures for Rook") +[< Previous](../available-captures-for-rook "Available Captures for Rook")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/grid-illumination "Grid Illumination") +[Next >](../grid-illumination "Grid Illumination") ## [1000. Minimum Cost to Merge Stones (Hard)](https://leetcode.com/problems/minimum-cost-to-merge-stones "合并石头的最低成本") @@ -69,8 +69,8 @@ The total cost was 25, and this is the minimum possible. ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Burst Balloons](https://github.com/openset/leetcode/tree/master/problems/burst-balloons) (Hard) - 1. [Minimum Cost to Connect Sticks](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-to-connect-sticks) (Medium) + 1. [Burst Balloons](../burst-balloons) (Hard) + 1. [Minimum Cost to Connect Sticks](../minimum-cost-to-connect-sticks) (Medium) diff --git a/problems/minimum-cost-tree-from-leaf-values/README.md b/problems/minimum-cost-tree-from-leaf-values/README.md index ca8a26009..620805ee6 100644 --- a/problems/minimum-cost-tree-from-leaf-values/README.md +++ b/problems/minimum-cost-tree-from-leaf-values/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-path-with-alternating-colors "Shortest Path with Alternating Colors") +[< Previous](../shortest-path-with-alternating-colors "Shortest Path with Alternating Colors")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-of-absolute-value-expression "Maximum of Absolute Value Expression") +[Next >](../maximum-of-absolute-value-expression "Maximum of Absolute Value Expression") ## [1130. Minimum Cost Tree From Leaf Values (Medium)](https://leetcode.com/problems/minimum-cost-tree-from-leaf-values "叶值的最小代价生成树") @@ -47,9 +47,9 @@ There are two possible trees. The first has non-leaf node sum 36, and the secon ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/minimum-depth-of-binary-tree/README.md b/problems/minimum-depth-of-binary-tree/README.md index 0234cc0b0..9fc183496 100644 --- a/problems/minimum-depth-of-binary-tree/README.md +++ b/problems/minimum-depth-of-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/balanced-binary-tree "Balanced Binary Tree") +[< Previous](../balanced-binary-tree "Balanced Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/path-sum "Path Sum") +[Next >](../path-sum "Path Sum") ## [111. Minimum Depth of Binary Tree (Easy)](https://leetcode.com/problems/minimum-depth-of-binary-tree "二叉树的最小深度") @@ -31,10 +31,10 @@

return its minimum depth = 2.

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions - 1. [Binary Tree Level Order Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal) (Medium) - 1. [Maximum Depth of Binary Tree](https://github.com/openset/leetcode/tree/master/problems/maximum-depth-of-binary-tree) (Easy) + 1. [Binary Tree Level Order Traversal](../binary-tree-level-order-traversal) (Medium) + 1. [Maximum Depth of Binary Tree](../maximum-depth-of-binary-tree) (Easy) diff --git a/problems/minimum-distance-between-bst-nodes/README.md b/problems/minimum-distance-between-bst-nodes/README.md index 21bd2bd95..8f741919d 100644 --- a/problems/minimum-distance-between-bst-nodes/README.md +++ b/problems/minimum-distance-between-bst-nodes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/transform-to-chessboard "Transform to Chessboard") +[< Previous](../transform-to-chessboard "Transform to Chessboard")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/letter-case-permutation "Letter Case Permutation") +[Next >](../letter-case-permutation "Letter Case Permutation") ## [783. Minimum Distance Between BST Nodes (Easy)](https://leetcode.com/problems/minimum-distance-between-bst-nodes "二叉搜索树结点最小距离") @@ -40,8 +40,8 @@ while the minimum difference in this tree is 1, it occurs between node 1 and nod ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions - 1. [Binary Tree Inorder Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-inorder-traversal) (Medium) + 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Medium) diff --git a/problems/minimum-domino-rotations-for-equal-row/README.md b/problems/minimum-domino-rotations-for-equal-row/README.md index f0217fceb..a408778be 100644 --- a/problems/minimum-domino-rotations-for-equal-row/README.md +++ b/problems/minimum-domino-rotations-for-equal-row/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/clumsy-factorial "Clumsy Factorial") +[< Previous](../clumsy-factorial "Clumsy Factorial")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/construct-binary-search-tree-from-preorder-traversal "Construct Binary Search Tree from Preorder Traversal") +[Next >](../construct-binary-search-tree-from-preorder-traversal "Construct Binary Search Tree from Preorder Traversal") ## [1007. Minimum Domino Rotations For Equal Row (Medium)](https://leetcode.com/problems/minimum-domino-rotations-for-equal-row "行相等的最少多米诺旋转") @@ -52,5 +52,5 @@ In this case, it is not possible to rotate the dominoes to make one row of value ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/minimum-factorization/README.md b/problems/minimum-factorization/README.md index 202446a33..86bb32c98 100644 --- a/problems/minimum-factorization/README.md +++ b/problems/minimum-factorization/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-distance-in-arrays "Maximum Distance in Arrays") +[< Previous](../maximum-distance-in-arrays "Maximum Distance in Arrays")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/exchange-seats "Exchange Seats") +[Next >](../exchange-seats "Exchange Seats") ## [625. Minimum Factorization (Medium)](https://leetcode.com/problems/minimum-factorization "最小因式分解") @@ -34,5 +34,5 @@ Output:

### Related Topics - [[Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/minimum-falling-path-sum-ii/README.md b/problems/minimum-falling-path-sum-ii/README.md index 7a123ac89..8c006aab0 100644 --- a/problems/minimum-falling-path-sum-ii/README.md +++ b/problems/minimum-falling-path-sum-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-covered-intervals "Remove Covered Intervals") +[< Previous](../remove-covered-intervals "Remove Covered Intervals")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/convert-binary-number-in-a-linked-list-to-integer "Convert Binary Number in a Linked List to Integer") +[Next >](../convert-binary-number-in-a-linked-list-to-integer "Convert Binary Number in a Linked List to Integer") ## [1289. Minimum Falling Path Sum II (Hard)](https://leetcode.com/problems/minimum-falling-path-sum-ii "下降路径最小和 II") @@ -38,7 +38,7 @@ The falling path with the smallest sum is [1,5,7], so the answer is 13 ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/minimum-falling-path-sum/README.md b/problems/minimum-falling-path-sum/README.md index 59f722bd0..536824f88 100644 --- a/problems/minimum-falling-path-sum/README.md +++ b/problems/minimum-falling-path-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-subarrays-with-sum "Binary Subarrays With Sum") +[< Previous](../binary-subarrays-with-sum "Binary Subarrays With Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/beautiful-array "Beautiful Array") +[Next >](../beautiful-array "Beautiful Array") ## [931. Minimum Falling Path Sum (Medium)](https://leetcode.com/problems/minimum-falling-path-sum "下降路径最小和") @@ -44,4 +44,4 @@ The possible falling paths are: ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/minimum-genetic-mutation/README.md b/problems/minimum-genetic-mutation/README.md index d3451b97b..9ebb42a3c 100644 --- a/problems/minimum-genetic-mutation/README.md +++ b/problems/minimum-genetic-mutation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/all-oone-data-structure "All O`one Data Structure") +[< Previous](../all-oone-data-structure "All O`one Data Structure")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-segments-in-a-string "Number of Segments in a String") +[Next >](../number-of-segments-in-a-string "Number of Segments in a String") ## [433. Minimum Genetic Mutation (Medium)](https://leetcode.com/problems/minimum-genetic-mutation "最小基因变化") @@ -68,4 +68,4 @@ return: 3

 

### Similar Questions - 1. [Word Ladder](https://github.com/openset/leetcode/tree/master/problems/word-ladder) (Medium) + 1. [Word Ladder](../word-ladder) (Medium) diff --git a/problems/minimum-height-trees/README.md b/problems/minimum-height-trees/README.md index 3450ea3dd..6202f1d64 100644 --- a/problems/minimum-height-trees/README.md +++ b/problems/minimum-height-trees/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-with-cooldown "Best Time to Buy and Sell Stock with Cooldown") +[< Previous](../best-time-to-buy-and-sell-stock-with-cooldown "Best Time to Buy and Sell Stock with Cooldown")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sparse-matrix-multiplication "Sparse Matrix Multiplication") +[Next >](../sparse-matrix-multiplication "Sparse Matrix Multiplication") ## [310. Minimum Height Trees (Medium)](https://leetcode.com/problems/minimum-height-trees "最小高度树") @@ -55,12 +55,12 @@ The graph contains n nodes which are labeled from 0 to ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] ### Similar Questions - 1. [Course Schedule](https://github.com/openset/leetcode/tree/master/problems/course-schedule) (Medium) - 1. [Course Schedule II](https://github.com/openset/leetcode/tree/master/problems/course-schedule-ii) (Medium) + 1. [Course Schedule](../course-schedule) (Medium) + 1. [Course Schedule II](../course-schedule-ii) (Medium) ### Hints
diff --git a/problems/minimum-increment-to-make-array-unique/README.md b/problems/minimum-increment-to-make-array-unique/README.md index 2fc7fc30c..dbdd57096 100644 --- a/problems/minimum-increment-to-make-array-unique/README.md +++ b/problems/minimum-increment-to-make-array-unique/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/delete-columns-to-make-sorted "Delete Columns to Make Sorted") +[< Previous](../delete-columns-to-make-sorted "Delete Columns to Make Sorted")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/validate-stack-sequences "Validate Stack Sequences") +[Next >](../validate-stack-sequences "Validate Stack Sequences") ## [945. Minimum Increment to Make Array Unique (Medium)](https://leetcode.com/problems/minimum-increment-to-make-array-unique "使数组唯一的最小增量") @@ -50,4 +50,4 @@ It can be shown with 5 or less moves that it is impossible for the array to have ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/minimum-index-sum-of-two-lists/README.md b/problems/minimum-index-sum-of-two-lists/README.md index 25728b723..6b4ef8820 100644 --- a/problems/minimum-index-sum-of-two-lists/README.md +++ b/problems/minimum-index-sum-of-two-lists/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/range-addition-ii "Range Addition II") +[< Previous](../range-addition-ii "Range Addition II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/non-negative-integers-without-consecutive-ones "Non-negative Integers without Consecutive Ones") +[Next >](../non-negative-integers-without-consecutive-ones "Non-negative Integers without Consecutive Ones") ## [599. Minimum Index Sum of Two Lists (Easy)](https://leetcode.com/problems/minimum-index-sum-of-two-lists "两个列表的最小索引总和") @@ -50,7 +50,7 @@ You need to help them find out their common interest with the least li

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Intersection of Two Linked Lists](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-linked-lists) (Easy) + 1. [Intersection of Two Linked Lists](../intersection-of-two-linked-lists) (Easy) diff --git a/problems/minimum-knight-moves/README.md b/problems/minimum-knight-moves/README.md index 0a4623afd..0b43fe231 100644 --- a/problems/minimum-knight-moves/README.md +++ b/problems/minimum-knight-moves/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/how-many-apples-can-you-put-into-the-basket "How Many Apples Can You Put into the Basket") +[< Previous](../how-many-apples-can-you-put-into-the-basket "How Many Apples Can You Put into the Basket")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-smallest-common-element-in-all-rows "Find Smallest Common Element in All Rows") +[Next >](../find-smallest-common-element-in-all-rows "Find Smallest Common Element in All Rows") ## [1197. Minimum Knight Moves (Medium)](https://leetcode.com/problems/minimum-knight-moves "进击的骑士") @@ -44,7 +44,7 @@ ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Hints
diff --git a/problems/minimum-moves-to-equal-array-elements-ii/README.md b/problems/minimum-moves-to-equal-array-elements-ii/README.md index 6572a4bcf..47179a8ba 100644 --- a/problems/minimum-moves-to-equal-array-elements-ii/README.md +++ b/problems/minimum-moves-to-equal-array-elements-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/hamming-distance "Hamming Distance") +[< Previous](../hamming-distance "Hamming Distance")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/island-perimeter "Island Perimeter") +[Next >](../island-perimeter "Island Perimeter") ## [462. Minimum Moves to Equal Array Elements II (Medium)](https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii "最少移动次数使数组元素相等 II") @@ -31,8 +31,8 @@ Only two moves are needed (remember each move increments or decrements one eleme

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Best Meeting Point](https://github.com/openset/leetcode/tree/master/problems/best-meeting-point) (Hard) - 1. [Minimum Moves to Equal Array Elements](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-equal-array-elements) (Easy) + 1. [Best Meeting Point](../best-meeting-point) (Hard) + 1. [Minimum Moves to Equal Array Elements](../minimum-moves-to-equal-array-elements) (Easy) diff --git a/problems/minimum-moves-to-equal-array-elements/README.md b/problems/minimum-moves-to-equal-array-elements/README.md index a26167733..30e37eeb0 100644 --- a/problems/minimum-moves-to-equal-array-elements/README.md +++ b/problems/minimum-moves-to-equal-array-elements/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-arrows-to-burst-balloons "Minimum Number of Arrows to Burst Balloons") +[< Previous](../minimum-number-of-arrows-to-burst-balloons "Minimum Number of Arrows to Burst Balloons")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/4sum-ii "4Sum II") +[Next >](../4sum-ii "4Sum II") ## [453. Minimum Moves to Equal Array Elements (Easy)](https://leetcode.com/problems/minimum-moves-to-equal-array-elements "最小移动次数使数组元素相等") @@ -29,7 +29,7 @@ Only three moves are needed (remember each move increments two elements):

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Minimum Moves to Equal Array Elements II](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-equal-array-elements-ii) (Medium) + 1. [Minimum Moves to Equal Array Elements II](../minimum-moves-to-equal-array-elements-ii) (Medium) diff --git a/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md b/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md index 9aedc534b..0937eb1f3 100644 --- a/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md +++ b/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/greatest-sum-divisible-by-three "Greatest Sum Divisible by Three") +[< Previous](../greatest-sum-divisible-by-three "Greatest Sum Divisible by Three")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/page-recommendations "Page Recommendations") +[Next >](../page-recommendations "Page Recommendations") ## [1263. Minimum Moves to Move a Box to Their Target Location (Hard)](https://leetcode.com/problems/minimum-moves-to-move-a-box-to-their-target-location "推箱子") @@ -90,7 +90,7 @@ ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Hints
diff --git a/problems/minimum-moves-to-reach-target-with-rotations/README.md b/problems/minimum-moves-to-reach-target-with-rotations/README.md index 6ecbdc7b7..ca126f85c 100644 --- a/problems/minimum-moves-to-reach-target-with-rotations/README.md +++ b/problems/minimum-moves-to-reach-target-with-rotations/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-all-adjacent-duplicates-in-string-ii "Remove All Adjacent Duplicates in String II") +[< Previous](../remove-all-adjacent-duplicates-in-string-ii "Remove All Adjacent Duplicates in String II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/queries-quality-and-percentage "Queries Quality and Percentage") +[Next >](../queries-quality-and-percentage "Queries Quality and Percentage") ## [1210. Minimum Moves to Reach Target with Rotations (Hard)](https://leetcode.com/problems/minimum-moves-to-reach-target-with-rotations "穿过迷宫的最少移动次数") @@ -67,7 +67,7 @@ ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Hints
diff --git a/problems/minimum-number-of-arrows-to-burst-balloons/README.md b/problems/minimum-number-of-arrows-to-burst-balloons/README.md index 492f9f2fa..a42411d06 100644 --- a/problems/minimum-number-of-arrows-to-burst-balloons/README.md +++ b/problems/minimum-number-of-arrows-to-burst-balloons/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sort-characters-by-frequency "Sort Characters By Frequency") +[< Previous](../sort-characters-by-frequency "Sort Characters By Frequency")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-equal-array-elements "Minimum Moves to Equal Array Elements") +[Next >](../minimum-moves-to-equal-array-elements "Minimum Moves to Equal Array Elements") ## [452. Minimum Number of Arrows to Burst Balloons (Medium)](https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons "用最少数量的箭引爆气球") @@ -31,8 +31,8 @@ One way is to shoot one arrow for example at x = 6 (bursting the balloons [2,8]

 

### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions - 1. [Meeting Rooms II](https://github.com/openset/leetcode/tree/master/problems/meeting-rooms-ii) (Medium) - 1. [Non-overlapping Intervals](https://github.com/openset/leetcode/tree/master/problems/non-overlapping-intervals) (Medium) + 1. [Meeting Rooms II](../meeting-rooms-ii) (Medium) + 1. [Non-overlapping Intervals](../non-overlapping-intervals) (Medium) diff --git a/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md b/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md index 1221df4e1..f9be56862 100644 --- a/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md +++ b/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-the-smallest-divisor-given-a-threshold "Find the Smallest Divisor Given a Threshold") +[< Previous](../find-the-smallest-divisor-given-a-threshold "Find the Smallest Divisor Given a Threshold")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-the-start-and-end-number-of-continuous-ranges "Find the Start and End Number of Continuous Ranges") +[Next >](../find-the-start-and-end-number-of-continuous-ranges "Find the Start and End Number of Continuous Ranges") ## [1284. Minimum Number of Flips to Convert Binary Matrix to Zero Matrix (Hard)](https://leetcode.com/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix "转化为全零矩阵的最少反转次数") @@ -63,7 +63,7 @@ ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Hints
diff --git a/problems/minimum-number-of-k-consecutive-bit-flips/README.md b/problems/minimum-number-of-k-consecutive-bit-flips/README.md index ca7d138f4..3367943f7 100644 --- a/problems/minimum-number-of-k-consecutive-bit-flips/README.md +++ b/problems/minimum-number-of-k-consecutive-bit-flips/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/rotting-oranges "Rotting Oranges") +[< Previous](../rotting-oranges "Rotting Oranges")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-squareful-arrays "Number of Squareful Arrays") +[Next >](../number-of-squareful-arrays "Number of Squareful Arrays") ## [995. Minimum Number of K Consecutive Bit Flips (Hard)](https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips "K 连续位的最小翻转次数") @@ -58,8 +58,8 @@ Flip A[5],A[6],A[7]: A becomes [1,1,1,1,1,1,1,1] ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions - 1. [Bulb Switcher](https://github.com/openset/leetcode/tree/master/problems/bulb-switcher) (Medium) + 1. [Bulb Switcher](../bulb-switcher) (Medium) diff --git a/problems/minimum-number-of-refueling-stops/README.md b/problems/minimum-number-of-refueling-stops/README.md index 8ba37043f..fc29e86d9 100644 --- a/problems/minimum-number-of-refueling-stops/README.md +++ b/problems/minimum-number-of-refueling-stops/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/advantage-shuffle "Advantage Shuffle") +[< Previous](../advantage-shuffle "Advantage Shuffle")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/leaf-similar-trees "Leaf-Similar Trees") +[Next >](../leaf-similar-trees "Leaf-Similar Trees") ## [871. Minimum Number of Refueling Stops (Hard)](https://leetcode.com/problems/minimum-number-of-refueling-stops "最低加油次数") @@ -71,5 +71,5 @@ We made 2 refueling stops along the way, so we return 2. ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/minimum-path-sum/README.md b/problems/minimum-path-sum/README.md index 33ef4a067..43de41172 100644 --- a/problems/minimum-path-sum/README.md +++ b/problems/minimum-path-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/unique-paths-ii "Unique Paths II") +[< Previous](../unique-paths-ii "Unique Paths II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-number "Valid Number") +[Next >](../valid-number "Valid Number") ## [64. Minimum Path Sum (Medium)](https://leetcode.com/problems/minimum-path-sum "最小路径和") @@ -29,10 +29,10 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Unique Paths](https://github.com/openset/leetcode/tree/master/problems/unique-paths) (Medium) - 1. [Dungeon Game](https://github.com/openset/leetcode/tree/master/problems/dungeon-game) (Hard) - 1. [Cherry Pickup](https://github.com/openset/leetcode/tree/master/problems/cherry-pickup) (Hard) + 1. [Unique Paths](../unique-paths) (Medium) + 1. [Dungeon Game](../dungeon-game) (Hard) + 1. [Cherry Pickup](../cherry-pickup) (Hard) diff --git a/problems/minimum-remove-to-make-valid-parentheses/README.md b/problems/minimum-remove-to-make-valid-parentheses/README.md index 80f9dd68c..a8280751f 100644 --- a/problems/minimum-remove-to-make-valid-parentheses/README.md +++ b/problems/minimum-remove-to-make-valid-parentheses/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/count-number-of-nice-subarrays "Count Number of Nice Subarrays") +[< Previous](../count-number-of-nice-subarrays "Count Number of Nice Subarrays")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/check-if-it-is-a-good-array "Check If It Is a Good Array") +[Next >](../check-if-it-is-a-good-array "Check If It Is a Good Array") ## [1249. Minimum Remove to Make Valid Parentheses (Medium)](https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses "移除无效的括号") @@ -63,8 +63,8 @@ ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/minimum-score-triangulation-of-polygon/README.md b/problems/minimum-score-triangulation-of-polygon/README.md index df0e59edb..4ac0645ed 100644 --- a/problems/minimum-score-triangulation-of-polygon/README.md +++ b/problems/minimum-score-triangulation-of-polygon/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-search-tree-to-greater-sum-tree "Binary Search Tree to Greater Sum Tree") +[< Previous](../binary-search-tree-to-greater-sum-tree "Binary Search Tree to Greater Sum Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/moving-stones-until-consecutive-ii "Moving Stones Until Consecutive II") +[Next >](../moving-stones-until-consecutive-ii "Moving Stones Until Consecutive II") ## [1039. Minimum Score Triangulation of Polygon (Medium)](https://leetcode.com/problems/minimum-score-triangulation-of-polygon "多边形三角剖分的最低得分") @@ -64,7 +64,7 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/minimum-size-subarray-sum/README.md b/problems/minimum-size-subarray-sum/README.md index d6b8e034c..ea6678920 100644 --- a/problems/minimum-size-subarray-sum/README.md +++ b/problems/minimum-size-subarray-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/implement-trie-prefix-tree "Implement Trie (Prefix Tree)") +[< Previous](../implement-trie-prefix-tree "Implement Trie (Prefix Tree)")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/course-schedule-ii "Course Schedule II") +[Next >](../course-schedule-ii "Course Schedule II") ## [209. Minimum Size Subarray Sum (Medium)](https://leetcode.com/problems/minimum-size-subarray-sum "长度最小的子数组") @@ -25,11 +25,11 @@
If you have figured out the O(n) solution, try coding another solution of which the time complexity is O(n log n). 
### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Minimum Window Substring](https://github.com/openset/leetcode/tree/master/problems/minimum-window-substring) (Hard) - 1. [Maximum Size Subarray Sum Equals k](https://github.com/openset/leetcode/tree/master/problems/maximum-size-subarray-sum-equals-k) (Medium) - 1. [Maximum Length of Repeated Subarray](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-repeated-subarray) (Medium) + 1. [Minimum Window Substring](../minimum-window-substring) (Hard) + 1. [Maximum Size Subarray Sum Equals k](../maximum-size-subarray-sum-equals-k) (Medium) + 1. [Maximum Length of Repeated Subarray](../maximum-length-of-repeated-subarray) (Medium) diff --git a/problems/minimum-swaps-to-group-all-1s-together/README.md b/problems/minimum-swaps-to-group-all-1s-together/README.md index 3095e7ca8..4035377a3 100644 --- a/problems/minimum-swaps-to-group-all-1s-together/README.md +++ b/problems/minimum-swaps-to-group-all-1s-together/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/check-if-a-number-is-majority-element-in-a-sorted-array "Check If a Number Is Majority Element in a Sorted Array") +[< Previous](../check-if-a-number-is-majority-element-in-a-sorted-array "Check If a Number Is Majority Element in a Sorted Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/analyze-user-website-visit-pattern "Analyze User Website Visit Pattern") +[Next >](../analyze-user-website-visit-pattern "Analyze User Website Visit Pattern") ## [1151. Minimum Swaps to Group All 1's Together (Medium)](https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together "最少交换次数来组合所有的 1") @@ -56,8 +56,8 @@ One possible solution that uses 3 swaps is [0,0,0,0,0,1,1,1,1,1,1]. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Array](../../tag/array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
diff --git a/problems/minimum-swaps-to-make-sequences-increasing/README.md b/problems/minimum-swaps-to-make-sequences-increasing/README.md index a325cdd42..4f22e38ab 100644 --- a/problems/minimum-swaps-to-make-sequences-increasing/README.md +++ b/problems/minimum-swaps-to-make-sequences-increasing/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/similar-rgb-color "Similar RGB Color") +[< Previous](../similar-rgb-color "Similar RGB Color")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-eventual-safe-states "Find Eventual Safe States") +[Next >](../find-eventual-safe-states "Find Eventual Safe States") ## [801. Minimum Swaps To Make Sequences Increasing (Medium)](https://leetcode.com/problems/minimum-swaps-to-make-sequences-increasing "使序列递增的最小交换次数") @@ -37,4 +37,4 @@ which are both strictly increasing. ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/minimum-swaps-to-make-strings-equal/README.md b/problems/minimum-swaps-to-make-strings-equal/README.md index ec77e4cf2..420c6a2bd 100644 --- a/problems/minimum-swaps-to-make-strings-equal/README.md +++ b/problems/minimum-swaps-to-make-strings-equal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/palindrome-removal "Palindrome Removal") +[< Previous](../palindrome-removal "Palindrome Removal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/count-number-of-nice-subarrays "Count Number of Nice Subarrays") +[Next >](../count-number-of-nice-subarrays "Count Number of Nice Subarrays") ## [1247. Minimum Swaps to Make Strings Equal (Medium)](https://leetcode.com/problems/minimum-swaps-to-make-strings-equal "交换字符使得字符串相同") @@ -57,8 +57,8 @@ Note that you can't swap s1[0] and s1[1] to make s1 equal to "yx", ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/minimum-time-difference/README.md b/problems/minimum-time-difference/README.md index e57eba38c..6610069b1 100644 --- a/problems/minimum-time-difference/README.md +++ b/problems/minimum-time-difference/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/convert-bst-to-greater-tree "Convert BST to Greater Tree") +[< Previous](../convert-bst-to-greater-tree "Convert BST to Greater Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/single-element-in-a-sorted-array "Single Element in a Sorted Array") +[Next >](../single-element-in-a-sorted-array "Single Element in a Sorted Array") ## [539. Minimum Time Difference (Medium)](https://leetcode.com/problems/minimum-time-difference "最小时间差") @@ -28,4 +28,4 @@ Given a list of 24-hour clock time points in "Hour:Minutes" format, find the min

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/minimum-time-to-build-blocks/README.md b/problems/minimum-time-to-build-blocks/README.md index 3f1d304dd..b8c54d002 100644 --- a/problems/minimum-time-to-build-blocks/README.md +++ b/problems/minimum-time-to-build-blocks/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-smallest-common-element-in-all-rows "Find Smallest Common Element in All Rows") +[< Previous](../find-smallest-common-element-in-all-rows "Find Smallest Common Element in All Rows")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-absolute-difference "Minimum Absolute Difference") +[Next >](../minimum-absolute-difference "Minimum Absolute Difference") ## [1199. Minimum Time to Build Blocks (Hard)](https://leetcode.com/problems/minimum-time-to-build-blocks "建造街区的最短时间") @@ -58,8 +58,8 @@ The cost is 1 + max(3, 1 + max(1, 2)) = 4. ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/minimum-time-visiting-all-points/README.md b/problems/minimum-time-visiting-all-points/README.md index e8994e908..bd6d6dc5f 100644 --- a/problems/minimum-time-visiting-all-points/README.md +++ b/problems/minimum-time-visiting-all-points/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/print-immutable-linked-list-in-reverse "Print Immutable Linked List in Reverse") +[< Previous](../print-immutable-linked-list-in-reverse "Print Immutable Linked List in Reverse")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/count-servers-that-communicate "Count Servers that Communicate") +[Next >](../count-servers-that-communicate "Count Servers that Communicate") ## [1266. Minimum Time Visiting All Points (Easy)](https://leetcode.com/problems/minimum-time-visiting-all-points "访问所有点的最小时间") @@ -49,8 +49,8 @@ Total time = 7 seconds ### Related Topics - [[Geometry](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/minimum-unique-word-abbreviation/README.md b/problems/minimum-unique-word-abbreviation/README.md index 9a19da69c..26b1ecb05 100644 --- a/problems/minimum-unique-word-abbreviation/README.md +++ b/problems/minimum-unique-word-abbreviation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/split-array-largest-sum "Split Array Largest Sum") +[< Previous](../split-array-largest-sum "Split Array Largest Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/fizz-buzz "Fizz Buzz") +[Next >](../fizz-buzz "Fizz Buzz") ## [411. Minimum Unique Word Abbreviation (Hard)](https://leetcode.com/problems/minimum-unique-word-abbreviation "最短特异单词缩写") @@ -36,10 +36,10 @@

### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Generalized Abbreviation](https://github.com/openset/leetcode/tree/master/problems/generalized-abbreviation) (Medium) - 1. [Valid Word Abbreviation](https://github.com/openset/leetcode/tree/master/problems/valid-word-abbreviation) (Easy) - 1. [Word Abbreviation](https://github.com/openset/leetcode/tree/master/problems/word-abbreviation) (Hard) + 1. [Generalized Abbreviation](../generalized-abbreviation) (Medium) + 1. [Valid Word Abbreviation](../valid-word-abbreviation) (Easy) + 1. [Word Abbreviation](../word-abbreviation) (Hard) diff --git a/problems/minimum-window-subsequence/README.md b/problems/minimum-window-subsequence/README.md index d822f47b1..ce91c1346 100644 --- a/problems/minimum-window-subsequence/README.md +++ b/problems/minimum-window-subsequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-atoms "Number of Atoms") +[< Previous](../number-of-atoms "Number of Atoms")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/self-dividing-numbers "Self Dividing Numbers") +[Next >](../self-dividing-numbers "Self Dividing Numbers") ## [727. Minimum Window Subsequence (Hard)](https://leetcode.com/problems/minimum-window-subsequence "最小窗口子序列") @@ -39,12 +39,12 @@ S = "abcdebdde", T = "bde"

 

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions - 1. [Minimum Window Substring](https://github.com/openset/leetcode/tree/master/problems/minimum-window-substring) (Hard) - 1. [Longest Continuous Increasing Subsequence](https://github.com/openset/leetcode/tree/master/problems/longest-continuous-increasing-subsequence) (Easy) + 1. [Minimum Window Substring](../minimum-window-substring) (Hard) + 1. [Longest Continuous Increasing Subsequence](../longest-continuous-increasing-subsequence) (Easy) ### Hints
diff --git a/problems/minimum-window-substring/README.md b/problems/minimum-window-substring/README.md index 4f1d665f8..fd1081335 100644 --- a/problems/minimum-window-substring/README.md +++ b/problems/minimum-window-substring/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sort-colors "Sort Colors") +[< Previous](../sort-colors "Sort Colors")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/combinations "Combinations") +[Next >](../combinations "Combinations") ## [76. Minimum Window Substring (Hard)](https://leetcode.com/problems/minimum-window-substring "最小覆盖子串") @@ -28,17 +28,17 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions - 1. [Substring with Concatenation of All Words](https://github.com/openset/leetcode/tree/master/problems/substring-with-concatenation-of-all-words) (Hard) - 1. [Minimum Size Subarray Sum](https://github.com/openset/leetcode/tree/master/problems/minimum-size-subarray-sum) (Medium) - 1. [Sliding Window Maximum](https://github.com/openset/leetcode/tree/master/problems/sliding-window-maximum) (Hard) - 1. [Permutation in String](https://github.com/openset/leetcode/tree/master/problems/permutation-in-string) (Medium) - 1. [Minimum Window Subsequence](https://github.com/openset/leetcode/tree/master/problems/minimum-window-subsequence) (Hard) + 1. [Substring with Concatenation of All Words](../substring-with-concatenation-of-all-words) (Hard) + 1. [Minimum Size Subarray Sum](../minimum-size-subarray-sum) (Medium) + 1. [Sliding Window Maximum](../sliding-window-maximum) (Hard) + 1. [Permutation in String](../permutation-in-string) (Medium) + 1. [Minimum Window Subsequence](../minimum-window-subsequence) (Hard) ### Hints
diff --git a/problems/mirror-reflection/README.md b/problems/mirror-reflection/README.md index e8770f848..69343a8cb 100644 --- a/problems/mirror-reflection/README.md +++ b/problems/mirror-reflection/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-to-hire-k-workers "Minimum Cost to Hire K Workers") +[< Previous](../minimum-cost-to-hire-k-workers "Minimum Cost to Hire K Workers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/buddy-strings "Buddy Strings") +[Next >](../buddy-strings "Buddy Strings") ## [858. Mirror Reflection (Medium)](https://leetcode.com/problems/mirror-reflection "镜面反射") @@ -39,4 +39,4 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/missing-element-in-sorted-array/README.md b/problems/missing-element-in-sorted-array/README.md index 8f1e5714d..35b3c3c4b 100644 --- a/problems/missing-element-in-sorted-array/README.md +++ b/problems/missing-element-in-sorted-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/all-paths-from-source-lead-to-destination "All Paths from Source Lead to Destination") +[< Previous](../all-paths-from-source-lead-to-destination "All Paths from Source Lead to Destination")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/lexicographically-smallest-equivalent-string "Lexicographically Smallest Equivalent String") +[Next >](../lexicographically-smallest-equivalent-string "Lexicographically Smallest Equivalent String") ## [1060. Missing Element in Sorted Array (Medium)](https://leetcode.com/problems/missing-element-in-sorted-array "有序数组中的缺失元素") @@ -53,7 +53,7 @@ The missing numbers are [3,5,6,7,...], hence the third missing number is 6. ### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
diff --git a/problems/missing-number-in-arithmetic-progression/README.md b/problems/missing-number-in-arithmetic-progression/README.md index 08ae794a8..24b33ae4b 100644 --- a/problems/missing-number-in-arithmetic-progression/README.md +++ b/problems/missing-number-in-arithmetic-progression/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/airplane-seat-assignment-probability "Airplane Seat Assignment Probability") +[< Previous](../airplane-seat-assignment-probability "Airplane Seat Assignment Probability")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/meeting-scheduler "Meeting Scheduler") +[Next >](../meeting-scheduler "Meeting Scheduler") ## [1228. Missing Number In Arithmetic Progression (Easy)](https://leetcode.com/problems/missing-number-in-arithmetic-progression "等差数列中缺失的数字") @@ -42,7 +42,7 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/missing-number/README.md b/problems/missing-number/README.md index 9ce156104..5e0fa0135 100644 --- a/problems/missing-number/README.md +++ b/problems/missing-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/palindrome-permutation-ii "Palindrome Permutation II") +[< Previous](../palindrome-permutation-ii "Palindrome Permutation II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/alien-dictionary "Alien Dictionary") +[Next >](../alien-dictionary "Alien Dictionary") ## [268. Missing Number (Easy)](https://leetcode.com/problems/missing-number "缺失数字") @@ -31,12 +31,12 @@ Your algorithm should run in linear runtime complexity. Could you implement it using only constant extra space complexity?

### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [First Missing Positive](https://github.com/openset/leetcode/tree/master/problems/first-missing-positive) (Hard) - 1. [Single Number](https://github.com/openset/leetcode/tree/master/problems/single-number) (Easy) - 1. [Find the Duplicate Number](https://github.com/openset/leetcode/tree/master/problems/find-the-duplicate-number) (Medium) - 1. [Couples Holding Hands](https://github.com/openset/leetcode/tree/master/problems/couples-holding-hands) (Hard) + 1. [First Missing Positive](../first-missing-positive) (Hard) + 1. [Single Number](../single-number) (Easy) + 1. [Find the Duplicate Number](../find-the-duplicate-number) (Medium) + 1. [Couples Holding Hands](../couples-holding-hands) (Hard) diff --git a/problems/missing-ranges/README.md b/problems/missing-ranges/README.md index 02f3b9164..f99e5676f 100644 --- a/problems/missing-ranges/README.md +++ b/problems/missing-ranges/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-peak-element "Find Peak Element") +[< Previous](../find-peak-element "Find Peak Element")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-gap "Maximum Gap") +[Next >](../maximum-gap "Maximum Gap") ## [163. Missing Ranges (Medium)](https://leetcode.com/problems/missing-ranges "缺失的区间") @@ -21,7 +21,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Summary Ranges](https://github.com/openset/leetcode/tree/master/problems/summary-ranges) (Medium) + 1. [Summary Ranges](../summary-ranges) (Medium) diff --git a/problems/monotone-increasing-digits/README.md b/problems/monotone-increasing-digits/README.md index 43aac5455..6e9accb6d 100644 --- a/problems/monotone-increasing-digits/README.md +++ b/problems/monotone-increasing-digits/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sentence-similarity-ii "Sentence Similarity II") +[< Previous](../sentence-similarity-ii "Sentence Similarity II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/daily-temperatures "Daily Temperatures") +[Next >](../daily-temperatures "Daily Temperatures") ## [738. Monotone Increasing Digits (Medium)](https://leetcode.com/problems/monotone-increasing-digits "单调递增的数字") @@ -43,10 +43,10 @@ Given a non-negative integer N, find the largest number that is les

### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions - 1. [Remove K Digits](https://github.com/openset/leetcode/tree/master/problems/remove-k-digits) (Medium) + 1. [Remove K Digits](../remove-k-digits) (Medium) ### Hints
diff --git a/problems/monotonic-array/README.md b/problems/monotonic-array/README.md index d3dd108be..000420821 100644 --- a/problems/monotonic-array/README.md +++ b/problems/monotonic-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-frequency-stack "Maximum Frequency Stack") +[< Previous](../maximum-frequency-stack "Maximum Frequency Stack")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/increasing-order-search-tree "Increasing Order Search Tree") +[Next >](../increasing-order-search-tree "Increasing Order Search Tree") ## [896. Monotonic Array (Easy)](https://leetcode.com/problems/monotonic-array "单调数列") @@ -77,4 +77,4 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/monthly-transactions-i/README.md b/problems/monthly-transactions-i/README.md index 9f269e25a..d98080073 100644 --- a/problems/monthly-transactions-i/README.md +++ b/problems/monthly-transactions-i/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/critical-connections-in-a-network "Critical Connections in a Network") +[< Previous](../critical-connections-in-a-network "Critical Connections in a Network")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/tournament-winners "Tournament Winners") +[Next >](../tournament-winners "Tournament Winners") ## [1193. Monthly Transactions I (Medium)](https://leetcode.com/problems/monthly-transactions-i "每月交易 I") diff --git a/problems/monthly-transactions-ii/README.md b/problems/monthly-transactions-ii/README.md index ba8ed603e..a8c1b1b5c 100644 --- a/problems/monthly-transactions-ii/README.md +++ b/problems/monthly-transactions-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/last-person-to-fit-in-the-elevator "Last Person to Fit in the Elevator") +[< Previous](../last-person-to-fit-in-the-elevator "Last Person to Fit in the Elevator")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-skiplist "Design Skiplist") +[Next >](../design-skiplist "Design Skiplist") ## [1205. Monthly Transactions II (Medium)](https://leetcode.com/problems/monthly-transactions-ii "每月交易II") diff --git a/problems/most-common-word/README.md b/problems/most-common-word/README.md index ff2d8d755..f36586ff2 100644 --- a/problems/most-common-word/README.md +++ b/problems/most-common-word/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/race-car "Race Car") +[< Previous](../race-car "Race Car")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/short-encoding-of-words "Short Encoding of Words") +[Next >](../short-encoding-of-words "Short Encoding of Words") ## [819. Most Common Word (Easy)](https://leetcode.com/problems/most-common-word "最常见的单词") @@ -47,4 +47,4 @@ and that "hit" isn't the answer even though it occurs more because ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/most-frequent-subtree-sum/README.md b/problems/most-frequent-subtree-sum/README.md index 41294c4a6..7fd3f56ba 100644 --- a/problems/most-frequent-subtree-sum/README.md +++ b/problems/most-frequent-subtree-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/perfect-number "Perfect Number") +[< Previous](../perfect-number "Perfect Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/fibonacci-number "Fibonacci Number") +[Next >](../fibonacci-number "Fibonacci Number") ## [508. Most Frequent Subtree Sum (Medium)](https://leetcode.com/problems/most-frequent-subtree-sum "出现次数最多的子树元素和") @@ -40,8 +40,8 @@ You may assume the sum of values in any subtree is in the range of 32-bit signed

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Subtree of Another Tree](https://github.com/openset/leetcode/tree/master/problems/subtree-of-another-tree) (Easy) + 1. [Subtree of Another Tree](../subtree-of-another-tree) (Easy) diff --git a/problems/most-profit-assigning-work/README.md b/problems/most-profit-assigning-work/README.md index f40a5dbad..9f990e5aa 100644 --- a/problems/most-profit-assigning-work/README.md +++ b/problems/most-profit-assigning-work/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/friends-of-appropriate-ages "Friends Of Appropriate Ages") +[< Previous](../friends-of-appropriate-ages "Friends Of Appropriate Ages")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/making-a-large-island "Making A Large Island") +[Next >](../making-a-large-island "Making A Large Island") ## [826. Most Profit Assigning Work (Medium)](https://leetcode.com/problems/most-profit-assigning-work "安排工作以达到最大收益") @@ -37,4 +37,4 @@ ### Related Topics - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/most-stones-removed-with-same-row-or-column/README.md b/problems/most-stones-removed-with-same-row-or-column/README.md index 26a7a8e59..4be096fc6 100644 --- a/problems/most-stones-removed-with-same-row-or-column/README.md +++ b/problems/most-stones-removed-with-same-row-or-column/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/validate-stack-sequences "Validate Stack Sequences") +[< Previous](../validate-stack-sequences "Validate Stack Sequences")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/bag-of-tokens "Bag of Tokens") +[Next >](../bag-of-tokens "Bag of Tokens") ## [947. Most Stones Removed with Same Row or Column (Medium)](https://leetcode.com/problems/most-stones-removed-with-same-row-or-column "移除最多的同行或同列石头") @@ -56,5 +56,5 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] diff --git a/problems/move-zeroes/README.md b/problems/move-zeroes/README.md index f2ea21b89..855dd078e 100644 --- a/problems/move-zeroes/README.md +++ b/problems/move-zeroes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/expression-add-operators "Expression Add Operators") +[< Previous](../expression-add-operators "Expression Add Operators")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/peeking-iterator "Peeking Iterator") +[Next >](../peeking-iterator "Peeking Iterator") ## [283. Move Zeroes (Easy)](https://leetcode.com/problems/move-zeroes "移动零") @@ -27,11 +27,11 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Remove Element](https://github.com/openset/leetcode/tree/master/problems/remove-element) (Easy) + 1. [Remove Element](../remove-element) (Easy) ### Hints
diff --git a/problems/moving-average-from-data-stream/README.md b/problems/moving-average-from-data-stream/README.md index 42d99a260..36caea0c6 100644 --- a/problems/moving-average-from-data-stream/README.md +++ b/problems/moving-average-from-data-stream/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reverse-vowels-of-a-string "Reverse Vowels of a String") +[< Previous](../reverse-vowels-of-a-string "Reverse Vowels of a String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-elements "Top K Frequent Elements") +[Next >](../top-k-frequent-elements "Top K Frequent Elements") ## [346. Moving Average from Data Stream (Easy)](https://leetcode.com/problems/moving-average-from-data-stream "数据流中的移动平均值") @@ -26,5 +26,5 @@ m.next(5) = (10 + 3 + 5) / 3

 

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Queue](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] + [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] diff --git a/problems/moving-stones-until-consecutive-ii/README.md b/problems/moving-stones-until-consecutive-ii/README.md index 9c27bf2c5..28c71a038 100644 --- a/problems/moving-stones-until-consecutive-ii/README.md +++ b/problems/moving-stones-until-consecutive-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-score-triangulation-of-polygon "Minimum Score Triangulation of Polygon") +[< Previous](../minimum-score-triangulation-of-polygon "Minimum Score Triangulation of Polygon")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/robot-bounded-in-circle "Robot Bounded In Circle") +[Next >](../robot-bounded-in-circle "Robot Bounded In Circle") ## [1040. Moving Stones Until Consecutive II (Medium)](https://leetcode.com/problems/moving-stones-until-consecutive-ii "移动石子直到连续 II") @@ -70,8 +70,8 @@ Notice we cannot move 10 -> 2 to finish the game, because that would be an il ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Array](../../tag/array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
diff --git a/problems/moving-stones-until-consecutive/README.md b/problems/moving-stones-until-consecutive/README.md index 327286c92..9f8c452b1 100644 --- a/problems/moving-stones-until-consecutive/README.md +++ b/problems/moving-stones-until-consecutive/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/stream-of-characters "Stream of Characters") +[< Previous](../stream-of-characters "Stream of Characters")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/coloring-a-border "Coloring A Border") +[Next >](../coloring-a-border "Coloring A Border") ## [1033. Moving Stones Until Consecutive (Easy)](https://leetcode.com/problems/moving-stones-until-consecutive "移动石子直到连续") @@ -69,7 +69,7 @@ ### Related Topics - [[Brainteaser](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md)] + [[Brainteaser](../../tag/brainteaser/README.md)] ### Hints
diff --git a/problems/multiply-strings/README.md b/problems/multiply-strings/README.md index 424c34457..28290addf 100644 --- a/problems/multiply-strings/README.md +++ b/problems/multiply-strings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/trapping-rain-water "Trapping Rain Water") +[< Previous](../trapping-rain-water "Trapping Rain Water")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/wildcard-matching "Wildcard Matching") +[Next >](../wildcard-matching "Wildcard Matching") ## [43. Multiply Strings (Medium)](https://leetcode.com/problems/multiply-strings "字符串相乘") @@ -36,11 +36,11 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Add Two Numbers](https://github.com/openset/leetcode/tree/master/problems/add-two-numbers) (Medium) - 1. [Plus One](https://github.com/openset/leetcode/tree/master/problems/plus-one) (Easy) - 1. [Add Binary](https://github.com/openset/leetcode/tree/master/problems/add-binary) (Easy) - 1. [Add Strings](https://github.com/openset/leetcode/tree/master/problems/add-strings) (Easy) + 1. [Add Two Numbers](../add-two-numbers) (Medium) + 1. [Plus One](../plus-one) (Easy) + 1. [Add Binary](../add-binary) (Easy) + 1. [Add Strings](../add-strings) (Easy) diff --git a/problems/my-calendar-i/README.md b/problems/my-calendar-i/README.md index 1b4f18777..52c0248f7 100644 --- a/problems/my-calendar-i/README.md +++ b/problems/my-calendar-i/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/self-dividing-numbers "Self Dividing Numbers") +[< Previous](../self-dividing-numbers "Self Dividing Numbers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/count-different-palindromic-subsequences "Count Different Palindromic Subsequences") +[Next >](../count-different-palindromic-subsequences "Count Different Palindromic Subsequences") ## [729. My Calendar I (Medium)](https://leetcode.com/problems/my-calendar-i "我的日程安排表 I") @@ -44,11 +44,11 @@ The third event can be booked, as the first event takes every time less than 20,

 

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [My Calendar II](https://github.com/openset/leetcode/tree/master/problems/my-calendar-ii) (Medium) - 1. [My Calendar III](https://github.com/openset/leetcode/tree/master/problems/my-calendar-iii) (Hard) + 1. [My Calendar II](../my-calendar-ii) (Medium) + 1. [My Calendar III](../my-calendar-iii) (Hard) ### Hints
diff --git a/problems/my-calendar-ii/README.md b/problems/my-calendar-ii/README.md index 2337c03cb..e062b2ad1 100644 --- a/problems/my-calendar-ii/README.md +++ b/problems/my-calendar-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/count-different-palindromic-subsequences "Count Different Palindromic Subsequences") +[< Previous](../count-different-palindromic-subsequences "Count Different Palindromic Subsequences")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/my-calendar-iii "My Calendar III") +[Next >](../my-calendar-iii "My Calendar III") ## [731. My Calendar II (Medium)](https://leetcode.com/problems/my-calendar-ii "我的日程安排表 II") @@ -50,11 +50,11 @@ the time [40, 50) will be single booked, and the time [50, 55) will be double bo

 

### Related Topics - [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] + [[Ordered Map](../../tag/ordered-map/README.md)] ### Similar Questions - 1. [My Calendar I](https://github.com/openset/leetcode/tree/master/problems/my-calendar-i) (Medium) - 1. [My Calendar III](https://github.com/openset/leetcode/tree/master/problems/my-calendar-iii) (Hard) + 1. [My Calendar I](../my-calendar-i) (Medium) + 1. [My Calendar III](../my-calendar-iii) (Hard) ### Hints
diff --git a/problems/my-calendar-iii/README.md b/problems/my-calendar-iii/README.md index 655a9223d..14f448754 100644 --- a/problems/my-calendar-iii/README.md +++ b/problems/my-calendar-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/my-calendar-ii "My Calendar II") +[< Previous](../my-calendar-ii "My Calendar II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/flood-fill "Flood Fill") +[Next >](../flood-fill "Flood Fill") ## [732. My Calendar III (Hard)](https://leetcode.com/problems/my-calendar-iii "我的日程安排表 III") @@ -50,12 +50,12 @@ eg. [10, 20), [10, 40), and [5, 15) are still triple booked.

 

### Related Topics - [[Segment Tree](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] - [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Ordered Map](../../tag/ordered-map/README.md)] ### Similar Questions - 1. [My Calendar I](https://github.com/openset/leetcode/tree/master/problems/my-calendar-i) (Medium) - 1. [My Calendar II](https://github.com/openset/leetcode/tree/master/problems/my-calendar-ii) (Medium) + 1. [My Calendar I](../my-calendar-i) (Medium) + 1. [My Calendar II](../my-calendar-ii) (Medium) ### Hints
diff --git a/problems/n-ary-tree-level-order-traversal/README.md b/problems/n-ary-tree-level-order-traversal/README.md index 8eef2948c..97c8fc45d 100644 --- a/problems/n-ary-tree-level-order-traversal/README.md +++ b/problems/n-ary-tree-level-order-traversal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-n-ary-tree "Serialize and Deserialize N-ary Tree") +[< Previous](../serialize-and-deserialize-n-ary-tree "Serialize and Deserialize N-ary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/flatten-a-multilevel-doubly-linked-list "Flatten a Multilevel Doubly Linked List") +[Next >](../flatten-a-multilevel-doubly-linked-list "Flatten a Multilevel Doubly Linked List") ## [429. N-ary Tree Level Order Traversal (Medium)](https://leetcode.com/problems/n-ary-tree-level-order-traversal "N叉树的层序遍历") @@ -43,10 +43,10 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions - 1. [Binary Tree Level Order Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal) (Medium) - 1. [N-ary Tree Preorder Traversal](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-preorder-traversal) (Easy) - 1. [N-ary Tree Postorder Traversal](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-postorder-traversal) (Easy) + 1. [Binary Tree Level Order Traversal](../binary-tree-level-order-traversal) (Medium) + 1. [N-ary Tree Preorder Traversal](../n-ary-tree-preorder-traversal) (Easy) + 1. [N-ary Tree Postorder Traversal](../n-ary-tree-postorder-traversal) (Easy) diff --git a/problems/n-ary-tree-postorder-traversal/README.md b/problems/n-ary-tree-postorder-traversal/README.md index fb020b613..bab91f0cb 100644 --- a/problems/n-ary-tree-postorder-traversal/README.md +++ b/problems/n-ary-tree-postorder-traversal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-preorder-traversal "N-ary Tree Preorder Traversal") +[< Previous](../n-ary-tree-preorder-traversal "N-ary Tree Preorder Traversal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/tag-validator "Tag Validator") +[Next >](../tag-validator "Tag Validator") ## [590. N-ary Tree Postorder Traversal (Easy)](https://leetcode.com/problems/n-ary-tree-postorder-traversal "N叉树的后序遍历") @@ -49,9 +49,9 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Binary Tree Postorder Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-postorder-traversal) (Hard) - 1. [N-ary Tree Level Order Traversal](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-level-order-traversal) (Medium) - 1. [N-ary Tree Preorder Traversal](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-preorder-traversal) (Easy) + 1. [Binary Tree Postorder Traversal](../binary-tree-postorder-traversal) (Hard) + 1. [N-ary Tree Level Order Traversal](../n-ary-tree-level-order-traversal) (Medium) + 1. [N-ary Tree Preorder Traversal](../n-ary-tree-preorder-traversal) (Easy) diff --git a/problems/n-ary-tree-preorder-traversal/README.md b/problems/n-ary-tree-preorder-traversal/README.md index 55e926914..ec719eca8 100644 --- a/problems/n-ary-tree-preorder-traversal/README.md +++ b/problems/n-ary-tree-preorder-traversal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-in-memory-file-system "Design In-Memory File System") +[< Previous](../design-in-memory-file-system "Design In-Memory File System")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-postorder-traversal "N-ary Tree Postorder Traversal") +[Next >](../n-ary-tree-postorder-traversal "N-ary Tree Postorder Traversal") ## [589. N-ary Tree Preorder Traversal (Easy)](https://leetcode.com/problems/n-ary-tree-preorder-traversal "N叉树的前序遍历") @@ -49,9 +49,9 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Binary Tree Preorder Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-preorder-traversal) (Medium) - 1. [N-ary Tree Level Order Traversal](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-level-order-traversal) (Medium) - 1. [N-ary Tree Postorder Traversal](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-postorder-traversal) (Easy) + 1. [Binary Tree Preorder Traversal](../binary-tree-preorder-traversal) (Medium) + 1. [N-ary Tree Level Order Traversal](../n-ary-tree-level-order-traversal) (Medium) + 1. [N-ary Tree Postorder Traversal](../n-ary-tree-postorder-traversal) (Easy) diff --git a/problems/n-queens-ii/README.md b/problems/n-queens-ii/README.md index 8e3dcd20c..8aba5974f 100644 --- a/problems/n-queens-ii/README.md +++ b/problems/n-queens-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/n-queens "N-Queens") +[< Previous](../n-queens "N-Queens")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-subarray "Maximum Subarray") +[Next >](../maximum-subarray "Maximum Subarray") ## [52. N-Queens II (Hard)](https://leetcode.com/problems/n-queens-ii "N皇后 II") @@ -37,7 +37,7 @@ ### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [N-Queens](https://github.com/openset/leetcode/tree/master/problems/n-queens) (Hard) + 1. [N-Queens](../n-queens) (Hard) diff --git a/problems/n-queens/README.md b/problems/n-queens/README.md index 34e14423c..490a35e02 100644 --- a/problems/n-queens/README.md +++ b/problems/n-queens/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/powx-n "Pow(x, n)") +[< Previous](../powx-n "Pow(x, n)")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/n-queens-ii "N-Queens II") +[Next >](../n-queens-ii "N-Queens II") ## [51. N-Queens (Hard)](https://leetcode.com/problems/n-queens "N皇后") @@ -38,8 +38,8 @@ ### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [N-Queens II](https://github.com/openset/leetcode/tree/master/problems/n-queens-ii) (Hard) - 1. [Grid Illumination](https://github.com/openset/leetcode/tree/master/problems/grid-illumination) (Hard) + 1. [N-Queens II](../n-queens-ii) (Hard) + 1. [Grid Illumination](../grid-illumination) (Hard) diff --git a/problems/n-repeated-element-in-size-2n-array/README.md b/problems/n-repeated-element-in-size-2n-array/README.md index abc9a2414..45338a589 100644 --- a/problems/n-repeated-element-in-size-2n-array/README.md +++ b/problems/n-repeated-element-in-size-2n-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/delete-columns-to-make-sorted-iii "Delete Columns to Make Sorted III") +[< Previous](../delete-columns-to-make-sorted-iii "Delete Columns to Make Sorted III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-width-ramp "Maximum Width Ramp") +[Next >](../maximum-width-ramp "Maximum Width Ramp") ## [961. N-Repeated Element in Size 2N Array (Easy)](https://leetcode.com/problems/n-repeated-element-in-size-2n-array "重复 N 次的元素") @@ -58,4 +58,4 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/n-th-tribonacci-number/README.md b/problems/n-th-tribonacci-number/README.md index a6827838c..be7bd369e 100644 --- a/problems/n-th-tribonacci-number/README.md +++ b/problems/n-th-tribonacci-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/parallel-courses "Parallel Courses") +[< Previous](../parallel-courses "Parallel Courses")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/alphabet-board-path "Alphabet Board Path") +[Next >](../alphabet-board-path "Alphabet Board Path") ## [1137. N-th Tribonacci Number (Easy)](https://leetcode.com/problems/n-th-tribonacci-number "第 N 个泰波那契数") @@ -44,10 +44,10 @@ T_4 = 1 + 1 + 2 = 4 ### Related Topics - [[Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions - 1. [Climbing Stairs](https://github.com/openset/leetcode/tree/master/problems/climbing-stairs) (Easy) + 1. [Climbing Stairs](../climbing-stairs) (Easy) ### Hints
diff --git a/problems/nested-list-weight-sum-ii/README.md b/problems/nested-list-weight-sum-ii/README.md index 5a1322d87..7ebb10aa4 100644 --- a/problems/nested-list-weight-sum-ii/README.md +++ b/problems/nested-list-weight-sum-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/max-sum-of-rectangle-no-larger-than-k "Max Sum of Rectangle No Larger Than K") +[< Previous](../max-sum-of-rectangle-no-larger-than-k "Max Sum of Rectangle No Larger Than K")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/water-and-jug-problem "Water and Jug Problem") +[Next >](../water-and-jug-problem "Water and Jug Problem") ## [364. Nested List Weight Sum II (Medium)](https://leetcode.com/problems/nested-list-weight-sum-ii "加权嵌套序列和 II") @@ -36,8 +36,8 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Nested List Weight Sum](https://github.com/openset/leetcode/tree/master/problems/nested-list-weight-sum) (Easy) - 1. [Array Nesting](https://github.com/openset/leetcode/tree/master/problems/array-nesting) (Medium) + 1. [Nested List Weight Sum](../nested-list-weight-sum) (Easy) + 1. [Array Nesting](../array-nesting) (Medium) diff --git a/problems/nested-list-weight-sum/README.md b/problems/nested-list-weight-sum/README.md index c78b48f3a..18040d25a 100644 --- a/problems/nested-list-weight-sum/README.md +++ b/problems/nested-list-weight-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/counting-bits "Counting Bits") +[< Previous](../counting-bits "Counting Bits")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-k-distinct-characters "Longest Substring with At Most K Distinct Characters") +[Next >](../longest-substring-with-at-most-k-distinct-characters "Longest Substring with At Most K Distinct Characters") ## [339. Nested List Weight Sum (Easy)](https://leetcode.com/problems/nested-list-weight-sum "嵌套列表权重和") @@ -32,9 +32,9 @@ Explanation: One 1 at depth 1, one 4 at depth 2, and one 6 at depth 3; 1 + 4*2 + 6*3 = 27. ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Nested List Weight Sum II](https://github.com/openset/leetcode/tree/master/problems/nested-list-weight-sum-ii) (Medium) - 1. [Array Nesting](https://github.com/openset/leetcode/tree/master/problems/array-nesting) (Medium) - 1. [Employee Importance](https://github.com/openset/leetcode/tree/master/problems/employee-importance) (Easy) + 1. [Nested List Weight Sum II](../nested-list-weight-sum-ii) (Medium) + 1. [Array Nesting](../array-nesting) (Medium) + 1. [Employee Importance](../employee-importance) (Easy) diff --git a/problems/network-delay-time/README.md b/problems/network-delay-time/README.md index 97e5070fe..a5703b8f6 100644 --- a/problems/network-delay-time/README.md +++ b/problems/network-delay-time/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/closest-leaf-in-a-binary-tree "Closest Leaf in a Binary Tree") +[< Previous](../closest-leaf-in-a-binary-tree "Closest Leaf in a Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-smallest-letter-greater-than-target "Find Smallest Letter Greater Than Target") +[Next >](../find-smallest-letter-greater-than-target "Find Smallest Letter Greater Than Target") ## [743. Network Delay Time (Medium)](https://leetcode.com/problems/network-delay-time "网络延迟时间") @@ -40,10 +40,10 @@ ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] ### Hints
diff --git a/problems/new-21-game/README.md b/problems/new-21-game/README.md index 9ff2ad99e..e6b258219 100644 --- a/problems/new-21-game/README.md +++ b/problems/new-21-game/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/rectangle-overlap "Rectangle Overlap") +[< Previous](../rectangle-overlap "Rectangle Overlap")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/push-dominoes "Push Dominoes") +[Next >](../push-dominoes "Push Dominoes") ## [837. New 21 Game (Medium)](https://leetcode.com/problems/new-21-game "新21点") @@ -50,4 +50,4 @@ In 6 out of W = 10 possibilities, she is at or below N = 6 points. ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/new-users-daily-count/README.md b/problems/new-users-daily-count/README.md index 3a1482854..01c9e4357 100644 --- a/problems/new-users-daily-count/README.md +++ b/problems/new-users-daily-count/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/parsing-a-boolean-expression "Parsing A Boolean Expression") +[< Previous](../parsing-a-boolean-expression "Parsing A Boolean Expression")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/defanging-an-ip-address "Defanging an IP Address") +[Next >](../defanging-an-ip-address "Defanging an IP Address") ## [1107. New Users Daily Count (Medium)](https://leetcode.com/problems/new-users-daily-count "每日新用户统计") diff --git a/problems/next-closest-time/README.md b/problems/next-closest-time/README.md index 76439bcea..2971f096b 100644 --- a/problems/next-closest-time/README.md +++ b/problems/next-closest-time/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome-ii "Valid Palindrome II") +[< Previous](../valid-palindrome-ii "Valid Palindrome II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/baseball-game "Baseball Game") +[Next >](../baseball-game "Baseball Game") ## [681. Next Closest Time (Medium)](https://leetcode.com/problems/next-closest-time "最近时刻") @@ -32,4 +32,4 @@

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/next-greater-element-i/README.md b/problems/next-greater-element-i/README.md index 7872c7bc6..eacbe1de6 100644 --- a/problems/next-greater-element-i/README.md +++ b/problems/next-greater-element-i/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/teemo-attacking "Teemo Attacking") +[< Previous](../teemo-attacking "Teemo Attacking")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/random-point-in-non-overlapping-rectangles "Random Point in Non-overlapping Rectangles") +[Next >](../random-point-in-non-overlapping-rectangles "Random Point in Non-overlapping Rectangles") ## [496. Next Greater Element I (Easy)](https://leetcode.com/problems/next-greater-element-i "下一个更大元素 I") @@ -49,9 +49,9 @@ The Next Greater Number of a number x in nums1 is the first

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] + [[Stack](../../tag/stack/README.md)] ### Similar Questions - 1. [Next Greater Element II](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-ii) (Medium) - 1. [Next Greater Element III](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-iii) (Medium) - 1. [Daily Temperatures](https://github.com/openset/leetcode/tree/master/problems/daily-temperatures) (Medium) + 1. [Next Greater Element II](../next-greater-element-ii) (Medium) + 1. [Next Greater Element III](../next-greater-element-iii) (Medium) + 1. [Daily Temperatures](../daily-temperatures) (Medium) diff --git a/problems/next-greater-element-ii/README.md b/problems/next-greater-element-ii/README.md index 9319385f9..50f96bf30 100644 --- a/problems/next-greater-element-ii/README.md +++ b/problems/next-greater-element-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/ipo "IPO") +[< Previous](../ipo "IPO")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/base-7 "Base 7") +[Next >](../base-7 "Base 7") ## [503. Next Greater Element II (Medium)](https://leetcode.com/problems/next-greater-element-ii "下一个更大元素 II") @@ -28,8 +28,8 @@ The length of given array won't exceed 10000.

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] + [[Stack](../../tag/stack/README.md)] ### Similar Questions - 1. [Next Greater Element I](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-i) (Easy) - 1. [Next Greater Element III](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-iii) (Medium) + 1. [Next Greater Element I](../next-greater-element-i) (Easy) + 1. [Next Greater Element III](../next-greater-element-iii) (Medium) diff --git a/problems/next-greater-element-iii/README.md b/problems/next-greater-element-iii/README.md index e4142ef55..a3728a178 100644 --- a/problems/next-greater-element-iii/README.md +++ b/problems/next-greater-element-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/split-concatenated-strings "Split Concatenated Strings") +[< Previous](../split-concatenated-strings "Split Concatenated Strings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reverse-words-in-a-string-iii "Reverse Words in a String III") +[Next >](../reverse-words-in-a-string-iii "Reverse Words in a String III") ## [556. Next Greater Element III (Medium)](https://leetcode.com/problems/next-greater-element-iii "下一个更大元素 III") @@ -32,8 +32,8 @@

 

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Next Greater Element I](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-i) (Easy) - 1. [Next Greater Element II](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-ii) (Medium) + 1. [Next Greater Element I](../next-greater-element-i) (Easy) + 1. [Next Greater Element II](../next-greater-element-ii) (Medium) diff --git a/problems/next-greater-node-in-linked-list/README.md b/problems/next-greater-node-in-linked-list/README.md index f6d719a3e..0e9acc0b4 100644 --- a/problems/next-greater-node-in-linked-list/README.md +++ b/problems/next-greater-node-in-linked-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-prefix-divisible-by-5 "Binary Prefix Divisible By 5") +[< Previous](../binary-prefix-divisible-by-5 "Binary Prefix Divisible By 5")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-enclaves "Number of Enclaves") +[Next >](../number-of-enclaves "Number of Enclaves") ## [1019. Next Greater Node In Linked List (Medium)](https://leetcode.com/problems/next-greater-node-in-linked-list "链表中的下一个更大节点") @@ -58,8 +58,8 @@ ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Hints
diff --git a/problems/next-permutation/README.md b/problems/next-permutation/README.md index 01640d01a..f56c5cab4 100644 --- a/problems/next-permutation/README.md +++ b/problems/next-permutation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/substring-with-concatenation-of-all-words "Substring with Concatenation of All Words") +[< Previous](../substring-with-concatenation-of-all-words "Substring with Concatenation of All Words")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-valid-parentheses "Longest Valid Parentheses") +[Next >](../longest-valid-parentheses "Longest Valid Parentheses") ## [31. Next Permutation (Medium)](https://leetcode.com/problems/next-permutation "下一个排列") @@ -24,10 +24,10 @@ 1,1,51,5,1

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Permutations](https://github.com/openset/leetcode/tree/master/problems/permutations) (Medium) - 1. [Permutations II](https://github.com/openset/leetcode/tree/master/problems/permutations-ii) (Medium) - 1. [Permutation Sequence](https://github.com/openset/leetcode/tree/master/problems/permutation-sequence) (Medium) - 1. [Palindrome Permutation II](https://github.com/openset/leetcode/tree/master/problems/palindrome-permutation-ii) (Medium) + 1. [Permutations](../permutations) (Medium) + 1. [Permutations II](../permutations-ii) (Medium) + 1. [Permutation Sequence](../permutation-sequence) (Medium) + 1. [Palindrome Permutation II](../palindrome-permutation-ii) (Medium) diff --git a/problems/nim-game/README.md b/problems/nim-game/README.md index 97383164b..7e542acab 100644 --- a/problems/nim-game/README.md +++ b/problems/nim-game/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/word-pattern-ii "Word Pattern II") +[< Previous](../word-pattern-ii "Word Pattern II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/flip-game "Flip Game") +[Next >](../flip-game "Flip Game") ## [292. Nim Game (Easy)](https://leetcode.com/problems/nim-game "Nim 游戏") @@ -25,11 +25,11 @@   removed by your friend. ### Related Topics - [[Brainteaser](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md)] - [[Minimax](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] + [[Brainteaser](../../tag/brainteaser/README.md)] + [[Minimax](../../tag/minimax/README.md)] ### Similar Questions - 1. [Flip Game II](https://github.com/openset/leetcode/tree/master/problems/flip-game-ii) (Medium) + 1. [Flip Game II](../flip-game-ii) (Medium) ### Hints
diff --git a/problems/non-decreasing-array/README.md b/problems/non-decreasing-array/README.md index 749fe28f8..02506054e 100644 --- a/problems/non-decreasing-array/README.md +++ b/problems/non-decreasing-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/strange-printer "Strange Printer") +[< Previous](../strange-printer "Strange Printer")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/path-sum-iv "Path Sum IV") +[Next >](../path-sum-iv "Path Sum IV") ## [665. Non-decreasing Array (Easy)](https://leetcode.com/problems/non-decreasing-array "非递减数列") @@ -40,4 +40,4 @@ The n belongs to [1, 10,000].

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/non-negative-integers-without-consecutive-ones/README.md b/problems/non-negative-integers-without-consecutive-ones/README.md index 63ca0feba..a8a48a286 100644 --- a/problems/non-negative-integers-without-consecutive-ones/README.md +++ b/problems/non-negative-integers-without-consecutive-ones/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-index-sum-of-two-lists "Minimum Index Sum of Two Lists") +[< Previous](../minimum-index-sum-of-two-lists "Minimum Index Sum of Two Lists")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/human-traffic-of-stadium "Human Traffic of Stadium") +[Next >](../human-traffic-of-stadium "Human Traffic of Stadium") ## [600. Non-negative Integers without Consecutive Ones (Hard)](https://leetcode.com/problems/non-negative-integers-without-consecutive-ones "不含连续1的非负整数") @@ -34,9 +34,9 @@ Among them, only integer 3 disobeys the rule (two consecutive ones) and the othe

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [House Robber](https://github.com/openset/leetcode/tree/master/problems/house-robber) (Easy) - 1. [House Robber II](https://github.com/openset/leetcode/tree/master/problems/house-robber-ii) (Medium) - 1. [Ones and Zeroes](https://github.com/openset/leetcode/tree/master/problems/ones-and-zeroes) (Medium) + 1. [House Robber](../house-robber) (Easy) + 1. [House Robber II](../house-robber-ii) (Medium) + 1. [Ones and Zeroes](../ones-and-zeroes) (Medium) diff --git a/problems/non-overlapping-intervals/README.md b/problems/non-overlapping-intervals/README.md index 3c8d9bd33..c65355f63 100644 --- a/problems/non-overlapping-intervals/README.md +++ b/problems/non-overlapping-intervals/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-segments-in-a-string "Number of Segments in a String") +[< Previous](../number-of-segments-in-a-string "Number of Segments in a String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-right-interval "Find Right Interval") +[Next >](../find-right-interval "Find Right Interval") ## [435. Non-overlapping Intervals (Medium)](https://leetcode.com/problems/non-overlapping-intervals "无重叠区间") @@ -52,7 +52,7 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions - 1. [Minimum Number of Arrows to Burst Balloons](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-arrows-to-burst-balloons) (Medium) + 1. [Minimum Number of Arrows to Burst Balloons](../minimum-number-of-arrows-to-burst-balloons) (Medium) diff --git a/problems/not-boring-movies/README.md b/problems/not-boring-movies/README.md index 31351aa46..abdd6c9ba 100644 --- a/problems/not-boring-movies/README.md +++ b/problems/not-boring-movies/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/biggest-single-number "Biggest Single Number") +[< Previous](../biggest-single-number "Biggest Single Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/task-scheduler "Task Scheduler") +[Next >](../task-scheduler "Task Scheduler") ## [620. Not Boring Movies (Easy)](https://leetcode.com/problems/not-boring-movies "有趣的电影") diff --git a/problems/nth-digit/README.md b/problems/nth-digit/README.md index c608196b6..dc096e6ca 100644 --- a/problems/nth-digit/README.md +++ b/problems/nth-digit/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/evaluate-division "Evaluate Division") +[< Previous](../evaluate-division "Evaluate Division")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-watch "Binary Watch") +[Next >](../binary-watch "Binary Watch") ## [400. Nth Digit (Medium)](https://leetcode.com/problems/nth-digit "第N个数字") @@ -41,4 +41,4 @@ The 11th digit of the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... is a 0, wh

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/nth-highest-salary/README.md b/problems/nth-highest-salary/README.md index 1e339e539..98fac1c6c 100644 --- a/problems/nth-highest-salary/README.md +++ b/problems/nth-highest-salary/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/second-highest-salary "Second Highest Salary") +[< Previous](../second-highest-salary "Second Highest Salary")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/rank-scores "Rank Scores") +[Next >](../rank-scores "Rank Scores") ## [177. Nth Highest Salary (Medium)](https://leetcode.com/problems/nth-highest-salary "第N高的薪水") diff --git a/problems/nth-magical-number/README.md b/problems/nth-magical-number/README.md index 4a99f6b3f..88e9ae5b7 100644 --- a/problems/nth-magical-number/README.md +++ b/problems/nth-magical-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/stone-game "Stone Game") +[< Previous](../stone-game "Stone Game")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/profitable-schemes "Profitable Schemes") +[Next >](../profitable-schemes "Profitable Schemes") ## [878. Nth Magical Number (Hard)](https://leetcode.com/problems/nth-magical-number "第 N 个神奇数字") @@ -67,5 +67,5 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/number-complement/README.md b/problems/number-complement/README.md index 2c097e868..61f12dde8 100644 --- a/problems/number-complement/README.md +++ b/problems/number-complement/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/heaters "Heaters") +[< Previous](../heaters "Heaters")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/total-hamming-distance "Total Hamming Distance") +[Next >](../total-hamming-distance "Total Hamming Distance") ## [476. Number Complement (Easy)](https://leetcode.com/problems/number-complement "数字的补数") @@ -37,4 +37,4 @@

### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/number-of-1-bits/README.md b/problems/number-of-1-bits/README.md index 22b05d93e..5afa56ced 100644 --- a/problems/number-of-1-bits/README.md +++ b/problems/number-of-1-bits/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reverse-bits "Reverse Bits") +[< Previous](../reverse-bits "Reverse Bits")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/word-frequency "Word Frequency") +[Next >](../word-frequency "Word Frequency") ## [191. Number of 1 Bits (Easy)](https://leetcode.com/problems/number-of-1-bits "位1的个数") @@ -54,13 +54,13 @@

If this function is called many times, how would you optimize it?

### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions - 1. [Reverse Bits](https://github.com/openset/leetcode/tree/master/problems/reverse-bits) (Easy) - 1. [Power of Two](https://github.com/openset/leetcode/tree/master/problems/power-of-two) (Easy) - 1. [Counting Bits](https://github.com/openset/leetcode/tree/master/problems/counting-bits) (Medium) - 1. [Binary Watch](https://github.com/openset/leetcode/tree/master/problems/binary-watch) (Easy) - 1. [Hamming Distance](https://github.com/openset/leetcode/tree/master/problems/hamming-distance) (Easy) - 1. [Binary Number with Alternating Bits](https://github.com/openset/leetcode/tree/master/problems/binary-number-with-alternating-bits) (Easy) - 1. [Prime Number of Set Bits in Binary Representation](https://github.com/openset/leetcode/tree/master/problems/prime-number-of-set-bits-in-binary-representation) (Easy) + 1. [Reverse Bits](../reverse-bits) (Easy) + 1. [Power of Two](../power-of-two) (Easy) + 1. [Counting Bits](../counting-bits) (Medium) + 1. [Binary Watch](../binary-watch) (Easy) + 1. [Hamming Distance](../hamming-distance) (Easy) + 1. [Binary Number with Alternating Bits](../binary-number-with-alternating-bits) (Easy) + 1. [Prime Number of Set Bits in Binary Representation](../prime-number-of-set-bits-in-binary-representation) (Easy) diff --git a/problems/number-of-atoms/README.md b/problems/number-of-atoms/README.md index 5ff5aea5d..26381eb74 100644 --- a/problems/number-of-atoms/README.md +++ b/problems/number-of-atoms/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/split-linked-list-in-parts "Split Linked List in Parts") +[< Previous](../split-linked-list-in-parts "Split Linked List in Parts")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-window-subsequence "Minimum Window Subsequence") +[Next >](../minimum-window-subsequence "Minimum Window Subsequence") ## [726. Number of Atoms (Hard)](https://leetcode.com/problems/number-of-atoms "原子的数量") @@ -60,14 +60,14 @@ The count of elements are {'K': 4, 'N': 2, 'O': 14, 'S': 4}.

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Decode String](https://github.com/openset/leetcode/tree/master/problems/decode-string) (Medium) - 1. [Encode String with Shortest Length](https://github.com/openset/leetcode/tree/master/problems/encode-string-with-shortest-length) (Hard) - 1. [Parse Lisp Expression](https://github.com/openset/leetcode/tree/master/problems/parse-lisp-expression) (Hard) + 1. [Decode String](../decode-string) (Medium) + 1. [Encode String with Shortest Length](../encode-string-with-shortest-length) (Hard) + 1. [Parse Lisp Expression](../parse-lisp-expression) (Hard) ### Hints
diff --git a/problems/number-of-boomerangs/README.md b/problems/number-of-boomerangs/README.md index d34651dbb..607602129 100644 --- a/problems/number-of-boomerangs/README.md +++ b/problems/number-of-boomerangs/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/arithmetic-slices-ii-subsequence "Arithmetic Slices II - Subsequence") +[< Previous](../arithmetic-slices-ii-subsequence "Arithmetic Slices II - Subsequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-all-numbers-disappeared-in-an-array "Find All Numbers Disappeared in an Array") +[Next >](../find-all-numbers-disappeared-in-an-array "Find All Numbers Disappeared in an Array") ## [447. Number of Boomerangs (Easy)](https://leetcode.com/problems/number-of-boomerangs "回旋镖的数量") @@ -31,7 +31,7 @@ The two boomerangs are [[1,0],[0,0],[2,0]] and [[1,0],[2,0],[0,0]]

 

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Line Reflection](https://github.com/openset/leetcode/tree/master/problems/line-reflection) (Medium) + 1. [Line Reflection](../line-reflection) (Medium) diff --git a/problems/number-of-burgers-with-no-waste-of-ingredients/README.md b/problems/number-of-burgers-with-no-waste-of-ingredients/README.md index fb6b656c3..b2ab77f09 100644 --- a/problems/number-of-burgers-with-no-waste-of-ingredients/README.md +++ b/problems/number-of-burgers-with-no-waste-of-ingredients/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-winner-on-a-tic-tac-toe-game "Find Winner on a Tic Tac Toe Game") +[< Previous](../find-winner-on-a-tic-tac-toe-game "Find Winner on a Tic Tac Toe Game")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/count-square-submatrices-with-all-ones "Count Square Submatrices with All Ones") +[Next >](../count-square-submatrices-with-all-ones "Count Square Submatrices with All Ones") ## [1276. Number of Burgers with No Waste of Ingredients (Medium)](https://leetcode.com/problems/number-of-burgers-with-no-waste-of-ingredients "不浪费原料的汉堡制作方案") @@ -68,8 +68,8 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/number-of-closed-islands/README.md b/problems/number-of-closed-islands/README.md index e601c5275..f959a2ae7 100644 --- a/problems/number-of-closed-islands/README.md +++ b/problems/number-of-closed-islands/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reconstruct-a-2-row-binary-matrix "Reconstruct a 2-Row Binary Matrix") +[< Previous](../reconstruct-a-2-row-binary-matrix "Reconstruct a 2-Row Binary Matrix")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-score-words-formed-by-letters "Maximum Score Words Formed by Letters") +[Next >](../maximum-score-words-formed-by-letters "Maximum Score Words Formed by Letters") ## [1254. Number of Closed Islands (Medium)](https://leetcode.com/problems/number-of-closed-islands "统计封闭岛屿的数目") @@ -57,7 +57,7 @@ Islands in gray are closed because they are completely surrounded by water (grou ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Hints
diff --git a/problems/number-of-comments-per-post/README.md b/problems/number-of-comments-per-post/README.md index b2acd2df8..af1169aa8 100644 --- a/problems/number-of-comments-per-post/README.md +++ b/problems/number-of-comments-per-post/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/tiling-a-rectangle-with-the-fewest-squares "Tiling a Rectangle with the Fewest Squares") +[< Previous](../tiling-a-rectangle-with-the-fewest-squares "Tiling a Rectangle with the Fewest Squares")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/web-crawler-multithreaded "Web Crawler Multithreaded") +[Next >](../web-crawler-multithreaded "Web Crawler Multithreaded") ## [1241. Number of Comments per Post (Easy)](https://leetcode.com/problems/number-of-comments-per-post "每个帖子的评论数") diff --git a/problems/number-of-connected-components-in-an-undirected-graph/README.md b/problems/number-of-connected-components-in-an-undirected-graph/README.md index 8e01ebec0..2985f5ffb 100644 --- a/problems/number-of-connected-components-in-an-undirected-graph/README.md +++ b/problems/number-of-connected-components-in-an-undirected-graph/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/coin-change "Coin Change") +[< Previous](../coin-change "Coin Change")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/wiggle-sort-ii "Wiggle Sort II") +[Next >](../wiggle-sort-ii "Wiggle Sort II") ## [323. Number of Connected Components in an Undirected Graph (Medium)](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph "无向图中连通分量的数目") @@ -41,12 +41,12 @@ You can assume that no duplicate edges will appear in edges. Since all edges are undirected, [0, 1] is the same as [1, 0] and thus will not appear together in edges.

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] ### Similar Questions - 1. [Number of Islands](https://github.com/openset/leetcode/tree/master/problems/number-of-islands) (Medium) - 1. [Graph Valid Tree](https://github.com/openset/leetcode/tree/master/problems/graph-valid-tree) (Medium) - 1. [Friend Circles](https://github.com/openset/leetcode/tree/master/problems/friend-circles) (Medium) + 1. [Number of Islands](../number-of-islands) (Medium) + 1. [Graph Valid Tree](../graph-valid-tree) (Medium) + 1. [Friend Circles](../friend-circles) (Medium) diff --git a/problems/number-of-corner-rectangles/README.md b/problems/number-of-corner-rectangles/README.md index a0a672c3f..3daba39d4 100644 --- a/problems/number-of-corner-rectangles/README.md +++ b/problems/number-of-corner-rectangles/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/contain-virus "Contain Virus") +[< Previous](../contain-virus "Contain Virus")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/ip-to-cidr "IP to CIDR") +[Next >](../ip-to-cidr "IP to CIDR") ## [750. Number Of Corner Rectangles (Medium)](https://leetcode.com/problems/number-of-corner-rectangles "角矩形的数量") @@ -66,7 +66,7 @@

 

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/number-of-days-in-a-month/README.md b/problems/number-of-days-in-a-month/README.md index 91ba236ec..749631781 100644 --- a/problems/number-of-days-in-a-month/README.md +++ b/problems/number-of-days-in-a-month/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/building-h2o "Building H2O") +[< Previous](../building-h2o "Building H2O")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-vowels-from-a-string "Remove Vowels from a String") +[Next >](../remove-vowels-from-a-string "Remove Vowels from a String") ## [1118. Number of Days in a Month (Easy)](https://leetcode.com/problems/number-of-days-in-a-month "一月有多少天") diff --git a/problems/number-of-dice-rolls-with-target-sum/README.md b/problems/number-of-dice-rolls-with-target-sum/README.md index cab7bd01b..8f2e91845 100644 --- a/problems/number-of-dice-rolls-with-target-sum/README.md +++ b/problems/number-of-dice-rolls-with-target-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/day-of-the-year "Day of the Year") +[< Previous](../day-of-the-year "Day of the Year")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/swap-for-longest-repeated-character-substring "Swap For Longest Repeated Character Substring") +[Next >](../swap-for-longest-repeated-character-substring "Swap For Longest Repeated Character Substring") ## [1155. Number of Dice Rolls With Target Sum (Medium)](https://leetcode.com/problems/number-of-dice-rolls-with-target-sum "掷骰子的N种方法") @@ -71,7 +71,7 @@ The answer must be returned modulo 10^9 + 7. ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/number-of-digit-one/README.md b/problems/number-of-digit-one/README.md index a3856ae7b..787f8f7e0 100644 --- a/problems/number-of-digit-one/README.md +++ b/problems/number-of-digit-one/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/implement-queue-using-stacks "Implement Queue using Stacks") +[< Previous](../implement-queue-using-stacks "Implement Queue using Stacks")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/palindrome-linked-list "Palindrome Linked List") +[Next >](../palindrome-linked-list "Palindrome Linked List") ## [233. Number of Digit One (Hard)](https://leetcode.com/problems/number-of-digit-one "数字 1 的个数") @@ -22,11 +22,11 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Factorial Trailing Zeroes](https://github.com/openset/leetcode/tree/master/problems/factorial-trailing-zeroes) (Easy) - 1. [Digit Count in Range](https://github.com/openset/leetcode/tree/master/problems/digit-count-in-range) (Hard) + 1. [Factorial Trailing Zeroes](../factorial-trailing-zeroes) (Easy) + 1. [Digit Count in Range](../digit-count-in-range) (Hard) ### Hints
diff --git a/problems/number-of-distinct-islands-ii/README.md b/problems/number-of-distinct-islands-ii/README.md index d414a18eb..16b2f586f 100644 --- a/problems/number-of-distinct-islands-ii/README.md +++ b/problems/number-of-distinct-islands-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-blacklist "Random Pick with Blacklist") +[< Previous](../random-pick-with-blacklist "Random Pick with Blacklist")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-ascii-delete-sum-for-two-strings "Minimum ASCII Delete Sum for Two Strings") +[Next >](../minimum-ascii-delete-sum-for-two-strings "Minimum ASCII Delete Sum for Two Strings") ## [711. Number of Distinct Islands II (Hard)](https://leetcode.com/problems/number-of-distinct-islands-ii "不同岛屿的数量 II") @@ -74,8 +74,8 @@ The length of each dimension in the given grid does not exceed 50.

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Number of Distinct Islands](https://github.com/openset/leetcode/tree/master/problems/number-of-distinct-islands) (Medium) + 1. [Number of Distinct Islands](../number-of-distinct-islands) (Medium) diff --git a/problems/number-of-distinct-islands/README.md b/problems/number-of-distinct-islands/README.md index 425ffc39a..5148275d5 100644 --- a/problems/number-of-distinct-islands/README.md +++ b/problems/number-of-distinct-islands/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-number-with-alternating-bits "Binary Number with Alternating Bits") +[< Previous](../binary-number-with-alternating-bits "Binary Number with Alternating Bits")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/max-area-of-island "Max Area of Island") +[Next >](../max-area-of-island "Max Area of Island") ## [694. Number of Distinct Islands (Medium)](https://leetcode.com/problems/number-of-distinct-islands "不同岛屿的数量") @@ -49,9 +49,9 @@ The length of each dimension in the given grid does not exceed 50.

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Number of Islands](https://github.com/openset/leetcode/tree/master/problems/number-of-islands) (Medium) - 1. [Number of Distinct Islands II](https://github.com/openset/leetcode/tree/master/problems/number-of-distinct-islands-ii) (Hard) + 1. [Number of Islands](../number-of-islands) (Medium) + 1. [Number of Distinct Islands II](../number-of-distinct-islands-ii) (Hard) diff --git a/problems/number-of-enclaves/README.md b/problems/number-of-enclaves/README.md index 6f3695bc7..e578da4be 100644 --- a/problems/number-of-enclaves/README.md +++ b/problems/number-of-enclaves/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/next-greater-node-in-linked-list "Next Greater Node In Linked List") +[< Previous](../next-greater-node-in-linked-list "Next Greater Node In Linked List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-outermost-parentheses "Remove Outermost Parentheses") +[Next >](../remove-outermost-parentheses "Remove Outermost Parentheses") ## [1020. Number of Enclaves (Medium)](https://leetcode.com/problems/number-of-enclaves "飞地的数量") @@ -48,7 +48,7 @@ All 1s are either on the boundary or can reach the boundary. ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Hints
diff --git a/problems/number-of-equivalent-domino-pairs/README.md b/problems/number-of-equivalent-domino-pairs/README.md index 9f3bf8ac0..822b0b648 100644 --- a/problems/number-of-equivalent-domino-pairs/README.md +++ b/problems/number-of-equivalent-domino-pairs/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/user-purchase-platform "User Purchase Platform") +[< Previous](../user-purchase-platform "User Purchase Platform")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-path-with-alternating-colors "Shortest Path with Alternating Colors") +[Next >](../shortest-path-with-alternating-colors "Shortest Path with Alternating Colors") ## [1128. Number of Equivalent Domino Pairs (Easy)](https://leetcode.com/problems/number-of-equivalent-domino-pairs "等价多米诺骨牌对的数量") @@ -29,7 +29,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/number-of-islands-ii/README.md b/problems/number-of-islands-ii/README.md index c8cd4e6bb..3c9b2b9fd 100644 --- a/problems/number-of-islands-ii/README.md +++ b/problems/number-of-islands-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-2d-immutable "Range Sum Query 2D - Immutable") +[< Previous](../range-sum-query-2d-immutable "Range Sum Query 2D - Immutable")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/additive-number "Additive Number") +[Next >](../additive-number "Additive Number") ## [305. Number of Islands II (Hard)](https://leetcode.com/problems/number-of-islands-ii "岛屿数量 II") @@ -67,7 +67,7 @@

Can you do it in time complexity O(k log mn), where k is the length of the positions?

### Related Topics - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] + [[Union Find](../../tag/union-find/README.md)] ### Similar Questions - 1. [Number of Islands](https://github.com/openset/leetcode/tree/master/problems/number-of-islands) (Medium) + 1. [Number of Islands](../number-of-islands) (Medium) diff --git a/problems/number-of-islands/README.md b/problems/number-of-islands/README.md index b60f77966..bac05bb22 100644 --- a/problems/number-of-islands/README.md +++ b/problems/number-of-islands/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-tree-right-side-view "Binary Tree Right Side View") +[< Previous](../binary-tree-right-side-view "Binary Tree Right Side View")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/bitwise-and-of-numbers-range "Bitwise AND of Numbers Range") +[Next >](../bitwise-and-of-numbers-range "Bitwise AND of Numbers Range") ## [200. Number of Islands (Medium)](https://leetcode.com/problems/number-of-islands "岛屿数量") @@ -38,14 +38,14 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] ### Similar Questions - 1. [Surrounded Regions](https://github.com/openset/leetcode/tree/master/problems/surrounded-regions) (Medium) - 1. [Walls and Gates](https://github.com/openset/leetcode/tree/master/problems/walls-and-gates) (Medium) - 1. [Number of Islands II](https://github.com/openset/leetcode/tree/master/problems/number-of-islands-ii) (Hard) - 1. [Number of Connected Components in an Undirected Graph](https://github.com/openset/leetcode/tree/master/problems/number-of-connected-components-in-an-undirected-graph) (Medium) - 1. [Number of Distinct Islands](https://github.com/openset/leetcode/tree/master/problems/number-of-distinct-islands) (Medium) - 1. [Max Area of Island](https://github.com/openset/leetcode/tree/master/problems/max-area-of-island) (Medium) + 1. [Surrounded Regions](../surrounded-regions) (Medium) + 1. [Walls and Gates](../walls-and-gates) (Medium) + 1. [Number of Islands II](../number-of-islands-ii) (Hard) + 1. [Number of Connected Components in an Undirected Graph](../number-of-connected-components-in-an-undirected-graph) (Medium) + 1. [Number of Distinct Islands](../number-of-distinct-islands) (Medium) + 1. [Max Area of Island](../max-area-of-island) (Medium) diff --git a/problems/number-of-lines-to-write-string/README.md b/problems/number-of-lines-to-write-string/README.md index e6a3e521b..b4d78966f 100644 --- a/problems/number-of-lines-to-write-string/README.md +++ b/problems/number-of-lines-to-write-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/split-array-with-same-average "Split Array With Same Average") +[< Previous](../split-array-with-same-average "Split Array With Same Average")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/max-increase-to-keep-city-skyline "Max Increase to Keep City Skyline") +[Next >](../max-increase-to-keep-city-skyline "Max Increase to Keep City Skyline") ## [806. Number of Lines To Write String (Easy)](https://leetcode.com/problems/number-of-lines-to-write-string "写字符串需要的行数") diff --git a/problems/number-of-longest-increasing-subsequence/README.md b/problems/number-of-longest-increasing-subsequence/README.md index c900871b6..2f7a971ee 100644 --- a/problems/number-of-longest-increasing-subsequence/README.md +++ b/problems/number-of-longest-increasing-subsequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/bulb-switcher-ii "Bulb Switcher II") +[< Previous](../bulb-switcher-ii "Bulb Switcher II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-continuous-increasing-subsequence "Longest Continuous Increasing Subsequence") +[Next >](../longest-continuous-increasing-subsequence "Longest Continuous Increasing Subsequence") ## [673. Number of Longest Increasing Subsequence (Medium)](https://leetcode.com/problems/number-of-longest-increasing-subsequence "最长递增子序列的个数") @@ -36,8 +36,8 @@ Length of the given array will be not exceed 2000 and the answer is guaranteed t

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Longest Increasing Subsequence](https://github.com/openset/leetcode/tree/master/problems/longest-increasing-subsequence) (Medium) - 1. [Longest Continuous Increasing Subsequence](https://github.com/openset/leetcode/tree/master/problems/longest-continuous-increasing-subsequence) (Easy) + 1. [Longest Increasing Subsequence](../longest-increasing-subsequence) (Medium) + 1. [Longest Continuous Increasing Subsequence](../longest-continuous-increasing-subsequence) (Easy) diff --git a/problems/number-of-matching-subsequences/README.md b/problems/number-of-matching-subsequences/README.md index 1318a7084..a73b2dbec 100644 --- a/problems/number-of-matching-subsequences/README.md +++ b/problems/number-of-matching-subsequences/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/custom-sort-string "Custom Sort String") +[< Previous](../custom-sort-string "Custom Sort String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/preimage-size-of-factorial-zeroes-function "Preimage Size of Factorial Zeroes Function") +[Next >](../preimage-size-of-factorial-zeroes-function "Preimage Size of Factorial Zeroes Function") ## [792. Number of Matching Subsequences (Medium)](https://leetcode.com/problems/number-of-matching-subsequences "匹配子序列的单词数") @@ -32,7 +32,7 @@ words = ["a", "bb", "acd", "ace"] ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Is Subsequence](https://github.com/openset/leetcode/tree/master/problems/is-subsequence) (Easy) + 1. [Is Subsequence](../is-subsequence) (Easy) diff --git a/problems/number-of-music-playlists/README.md b/problems/number-of-music-playlists/README.md index 6bd851271..03d3874e3 100644 --- a/problems/number-of-music-playlists/README.md +++ b/problems/number-of-music-playlists/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/complete-binary-tree-inserter "Complete Binary Tree Inserter") +[< Previous](../complete-binary-tree-inserter "Complete Binary Tree Inserter")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-add-to-make-parentheses-valid "Minimum Add to Make Parentheses Valid") +[Next >](../minimum-add-to-make-parentheses-valid "Minimum Add to Make Parentheses Valid") ## [920. Number of Music Playlists (Hard)](https://leetcode.com/problems/number-of-music-playlists "播放列表的数量") @@ -65,4 +65,4 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/number-of-recent-calls/README.md b/problems/number-of-recent-calls/README.md index 6247df9d7..71a679ce1 100644 --- a/problems/number-of-recent-calls/README.md +++ b/problems/number-of-recent-calls/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/beautiful-array "Beautiful Array") +[< Previous](../beautiful-array "Beautiful Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-bridge "Shortest Bridge") +[Next >](../shortest-bridge "Shortest Bridge") ## [933. Number of Recent Calls (Easy)](https://leetcode.com/problems/number-of-recent-calls "最近的请求次数") @@ -44,4 +44,4 @@ ### Related Topics - [[Queue](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] + [[Queue](../../tag/queue/README.md)] diff --git a/problems/number-of-segments-in-a-string/README.md b/problems/number-of-segments-in-a-string/README.md index 3e0061558..099f18bfb 100644 --- a/problems/number-of-segments-in-a-string/README.md +++ b/problems/number-of-segments-in-a-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-genetic-mutation "Minimum Genetic Mutation") +[< Previous](../minimum-genetic-mutation "Minimum Genetic Mutation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/non-overlapping-intervals "Non-overlapping Intervals") +[Next >](../non-overlapping-intervals "Non-overlapping Intervals") ## [434. Number of Segments in a String (Easy)](https://leetcode.com/problems/number-of-segments-in-a-string "字符串中的单词数") @@ -23,4 +23,4 @@

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/number-of-ships-in-a-rectangle/README.md b/problems/number-of-ships-in-a-rectangle/README.md index 179de2fa2..3e3c6bf7a 100644 --- a/problems/number-of-ships-in-a-rectangle/README.md +++ b/problems/number-of-ships-in-a-rectangle/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/delete-tree-nodes "Delete Tree Nodes") +[< Previous](../delete-tree-nodes "Delete Tree Nodes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-winner-on-a-tic-tac-toe-game "Find Winner on a Tic Tac Toe Game") +[Next >](../find-winner-on-a-tic-tac-toe-game "Find Winner on a Tic Tac Toe Game") ## [1274. Number of Ships in a Rectangle (Hard)](https://leetcode.com/problems/number-of-ships-in-a-rectangle "矩形内船只的数目") @@ -43,7 +43,7 @@ ships = [[1,1],[2,2],[3,3],[5,5]], topRight = [4,4], bottomLeft = [0,0] ### Related Topics - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Hints
diff --git a/problems/number-of-squareful-arrays/README.md b/problems/number-of-squareful-arrays/README.md index 2bbd316fe..d405b7b41 100644 --- a/problems/number-of-squareful-arrays/README.md +++ b/problems/number-of-squareful-arrays/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-k-consecutive-bit-flips "Minimum Number of K Consecutive Bit Flips") +[< Previous](../minimum-number-of-k-consecutive-bit-flips "Minimum Number of K Consecutive Bit Flips")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-the-town-judge "Find the Town Judge") +[Next >](../find-the-town-judge "Find the Town Judge") ## [996. Number of Squareful Arrays (Hard)](https://leetcode.com/problems/number-of-squareful-arrays "正方形数组的数目") @@ -43,9 +43,9 @@ ### Related Topics - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Math](../../tag/math/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Permutations II](https://github.com/openset/leetcode/tree/master/problems/permutations-ii) (Medium) + 1. [Permutations II](../permutations-ii) (Medium) diff --git a/problems/number-of-subarrays-with-bounded-maximum/README.md b/problems/number-of-subarrays-with-bounded-maximum/README.md index d922e90b9..47f6125cd 100644 --- a/problems/number-of-subarrays-with-bounded-maximum/README.md +++ b/problems/number-of-subarrays-with-bounded-maximum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-tic-tac-toe-state "Valid Tic-Tac-Toe State") +[< Previous](../valid-tic-tac-toe-state "Valid Tic-Tac-Toe State")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/rotate-string "Rotate String") +[Next >](../rotate-string "Rotate String") ## [795. Number of Subarrays with Bounded Maximum (Medium)](https://leetcode.com/problems/number-of-subarrays-with-bounded-maximum "区间子数组个数") @@ -33,4 +33,4 @@ R = 3 ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/number-of-submatrices-that-sum-to-target/README.md b/problems/number-of-submatrices-that-sum-to-target/README.md index b496db698..64a0cf50b 100644 --- a/problems/number-of-submatrices-that-sum-to-target/README.md +++ b/problems/number-of-submatrices-that-sum-to-target/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/adding-two-negabinary-numbers "Adding Two Negabinary Numbers") +[< Previous](../adding-two-negabinary-numbers "Adding Two Negabinary Numbers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/project-employees-i "Project Employees I") +[Next >](../project-employees-i "Project Employees I") ## [1074. Number of Submatrices That Sum to Target (Hard)](https://leetcode.com/problems/number-of-submatrices-that-sum-to-target "元素和为目标值的子矩阵数量") @@ -49,9 +49,9 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
diff --git a/problems/number-of-valid-subarrays/README.md b/problems/number-of-valid-subarrays/README.md index d416e1775..3e0cb7181 100644 --- a/problems/number-of-valid-subarrays/README.md +++ b/problems/number-of-valid-subarrays/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-repeating-substring "Longest Repeating Substring") +[< Previous](../longest-repeating-substring "Longest Repeating Substring")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/fixed-point "Fixed Point") +[Next >](../fixed-point "Fixed Point") ## [1063. Number of Valid Subarrays (Hard)](https://leetcode.com/problems/number-of-valid-subarrays "有效子数组的数目") @@ -51,7 +51,7 @@ ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] + [[Stack](../../tag/stack/README.md)] ### Hints
diff --git a/problems/number-of-valid-words-for-each-puzzle/README.md b/problems/number-of-valid-words-for-each-puzzle/README.md index 3639bcb3d..e6a98be57 100644 --- a/problems/number-of-valid-words-for-each-puzzle/README.md +++ b/problems/number-of-valid-words-for-each-puzzle/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/can-make-palindrome-from-substring "Can Make Palindrome from Substring") +[< Previous](../can-make-palindrome-from-substring "Can Make Palindrome from Substring")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reformat-department-table "Reformat Department Table") +[Next >](../reformat-department-table "Reformat Department Table") ## [1178. Number of Valid Words for Each Puzzle (Hard)](https://leetcode.com/problems/number-of-valid-words-for-each-puzzle "猜字谜") @@ -48,8 +48,8 @@ There're no valid words for "gaswxyz" cause none of the ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
diff --git a/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/README.md b/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/README.md index 2bde286e7..0ab7b4892 100644 --- a/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/README.md +++ b/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/search-suggestions-system "Search Suggestions System") +[< Previous](../search-suggestions-system "Search Suggestions System")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/all-people-report-to-the-given-manager "All People Report to the Given Manager") +[Next >](../all-people-report-to-the-given-manager "All People Report to the Given Manager") ## [1269. Number of Ways to Stay in the Same Place After Some Steps (Hard)](https://leetcode.com/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps "停在原地的方案数") @@ -56,7 +56,7 @@ Stay, Stay ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/numbers-at-most-n-given-digit-set/README.md b/problems/numbers-at-most-n-given-digit-set/README.md index da7c4b88d..6f2a2ecc8 100644 --- a/problems/numbers-at-most-n-given-digit-set/README.md +++ b/problems/numbers-at-most-n-given-digit-set/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/online-stock-span "Online Stock Span") +[< Previous](../online-stock-span "Online Stock Span")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-permutations-for-di-sequence "Valid Permutations for DI Sequence") +[Next >](../valid-permutations-for-di-sequence "Valid Permutations for DI Sequence") ## [902. Numbers At Most N Given Digit Set (Hard)](https://leetcode.com/problems/numbers-at-most-n-given-digit-set "最大为 N 的数字组合") @@ -52,5 +52,5 @@ In total, this is 29523 integers that can be written using the digits of D. ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/numbers-with-repeated-digits/README.md b/problems/numbers-with-repeated-digits/README.md index eb00fb3bd..72bbbd957 100644 --- a/problems/numbers-with-repeated-digits/README.md +++ b/problems/numbers-with-repeated-digits/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/capacity-to-ship-packages-within-d-days "Capacity To Ship Packages Within D Days") +[< Previous](../capacity-to-ship-packages-within-d-days "Capacity To Ship Packages Within D Days")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/partition-array-into-three-parts-with-equal-sum "Partition Array Into Three Parts With Equal Sum") +[Next >](../partition-array-into-three-parts-with-equal-sum "Partition Array Into Three Parts With Equal Sum") ## [1012. Numbers With Repeated Digits (Hard)](https://leetcode.com/problems/numbers-with-repeated-digits "至少有 1 位重复的数字") @@ -53,8 +53,8 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/numbers-with-same-consecutive-differences/README.md b/problems/numbers-with-same-consecutive-differences/README.md index 74419a222..ca2e28dfb 100644 --- a/problems/numbers-with-same-consecutive-differences/README.md +++ b/problems/numbers-with-same-consecutive-differences/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/vowel-spellchecker "Vowel Spellchecker") +[< Previous](../vowel-spellchecker "Vowel Spellchecker")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-tree-cameras "Binary Tree Cameras") +[Next >](../binary-tree-cameras "Binary Tree Cameras") ## [967. Numbers With Same Consecutive Differences (Medium)](https://leetcode.com/problems/numbers-with-same-consecutive-differences "连续差相同的数字") @@ -45,4 +45,4 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/occurrences-after-bigram/README.md b/problems/occurrences-after-bigram/README.md index 3b766fd6c..71a72d9a5 100644 --- a/problems/occurrences-after-bigram/README.md +++ b/problems/occurrences-after-bigram/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/project-employees-iii "Project Employees III") +[< Previous](../project-employees-iii "Project Employees III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/letter-tile-possibilities "Letter Tile Possibilities") +[Next >](../letter-tile-possibilities "Letter Tile Possibilities") ## [1078. Occurrences After Bigram (Easy)](https://leetcode.com/problems/occurrences-after-bigram "Bigram 分词") @@ -45,7 +45,7 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
diff --git a/problems/odd-even-jump/README.md b/problems/odd-even-jump/README.md index 499efc796..6495a0e72 100644 --- a/problems/odd-even-jump/README.md +++ b/problems/odd-even-jump/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/subarray-sums-divisible-by-k "Subarray Sums Divisible by K") +[< Previous](../subarray-sums-divisible-by-k "Subarray Sums Divisible by K")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/largest-perimeter-triangle "Largest Perimeter Triangle") +[Next >](../largest-perimeter-triangle "Largest Perimeter Triangle") ## [975. Odd Even Jump (Hard)](https://leetcode.com/problems/odd-even-jump "奇偶跳") @@ -87,6 +87,6 @@ We can reach the end from starting indexes 1, 2, and 4. ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] - [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Ordered Map](../../tag/ordered-map/README.md)] diff --git a/problems/odd-even-linked-list/README.md b/problems/odd-even-linked-list/README.md index 809c5d64d..45f2449b2 100644 --- a/problems/odd-even-linked-list/README.md +++ b/problems/odd-even-linked-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/count-of-range-sum "Count of Range Sum") +[< Previous](../count-of-range-sum "Count of Range Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-increasing-path-in-a-matrix "Longest Increasing Path in a Matrix") +[Next >](../longest-increasing-path-in-a-matrix "Longest Increasing Path in a Matrix") ## [328. Odd Even Linked List (Medium)](https://leetcode.com/problems/odd-even-linked-list "奇偶链表") @@ -37,7 +37,7 @@ ### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Split Linked List in Parts](https://github.com/openset/leetcode/tree/master/problems/split-linked-list-in-parts) (Medium) + 1. [Split Linked List in Parts](../split-linked-list-in-parts) (Medium) diff --git a/problems/one-edit-distance/README.md b/problems/one-edit-distance/README.md index 80b022090..1237b5476 100644 --- a/problems/one-edit-distance/README.md +++ b/problems/one-edit-distance/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-linked-lists "Intersection of Two Linked Lists") +[< Previous](../intersection-of-two-linked-lists "Intersection of Two Linked Lists")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-peak-element "Find Peak Element") +[Next >](../find-peak-element "Find Peak Element") ## [161. One Edit Distance (Medium)](https://leetcode.com/problems/one-edit-distance "相隔为 1 的编辑距离") @@ -43,7 +43,7 @@ Explanation: We can replace '0' with '1' to get t. ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Edit Distance](https://github.com/openset/leetcode/tree/master/problems/edit-distance) (Hard) + 1. [Edit Distance](../edit-distance) (Hard) diff --git a/problems/ones-and-zeroes/README.md b/problems/ones-and-zeroes/README.md index 1f1dab26f..dbbe1cc58 100644 --- a/problems/ones-and-zeroes/README.md +++ b/problems/ones-and-zeroes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/matchsticks-to-square "Matchsticks to Square") +[< Previous](../matchsticks-to-square "Matchsticks to Square")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/heaters "Heaters") +[Next >](../heaters "Heaters") ## [474. Ones and Zeroes (Medium)](https://leetcode.com/problems/ones-and-zeroes "一和零") @@ -49,7 +49,7 @@

 

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Non-negative Integers without Consecutive Ones](https://github.com/openset/leetcode/tree/master/problems/non-negative-integers-without-consecutive-ones) (Hard) + 1. [Non-negative Integers without Consecutive Ones](../non-negative-integers-without-consecutive-ones) (Hard) diff --git a/problems/online-election/README.md b/problems/online-election/README.md index 095e48566..de4117996 100644 --- a/problems/online-election/README.md +++ b/problems/online-election/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/smallest-range-ii "Smallest Range II") +[< Previous](../smallest-range-ii "Smallest Range II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sort-an-array "Sort an Array") +[Next >](../sort-an-array "Sort an Array") ## [911. Online Election (Medium)](https://leetcode.com/problems/online-election "在线选举") @@ -46,4 +46,4 @@ This continues for 3 more queries at time 15, 24, and 8. ### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/online-majority-element-in-subarray/README.md b/problems/online-majority-element-in-subarray/README.md index 3bafa6159..550e63118 100644 --- a/problems/online-majority-element-in-subarray/README.md +++ b/problems/online-majority-element-in-subarray/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/swap-for-longest-repeated-character-substring "Swap For Longest Repeated Character Substring") +[< Previous](../swap-for-longest-repeated-character-substring "Swap For Longest Repeated Character Substring")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/market-analysis-i "Market Analysis I") +[Next >](../market-analysis-i "Market Analysis I") ## [1157. Online Majority Element In Subarray (Hard)](https://leetcode.com/problems/online-majority-element-in-subarray "子数组中占绝大多数的元素") @@ -48,9 +48,9 @@ majorityChecker.query(2,3,2); // returns 2 ### Related Topics - [[Segment Tree](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
diff --git a/problems/online-stock-span/README.md b/problems/online-stock-span/README.md index 22c885cf1..9a8c473ca 100644 --- a/problems/online-stock-span/README.md +++ b/problems/online-stock-span/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/rle-iterator "RLE Iterator") +[< Previous](../rle-iterator "RLE Iterator")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/numbers-at-most-n-given-digit-set "Numbers At Most N Given Digit Set") +[Next >](../numbers-at-most-n-given-digit-set "Numbers At Most N Given Digit Set") ## [901. Online Stock Span (Medium)](https://leetcode.com/problems/online-stock-span "股票价格跨度") @@ -52,4 +52,4 @@ Note that (for example) S.next(75) returned 4, because the last 4 prices ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] + [[Stack](../../tag/stack/README.md)] diff --git a/problems/open-the-lock/README.md b/problems/open-the-lock/README.md index ca151345b..94e887a81 100644 --- a/problems/open-the-lock/README.md +++ b/problems/open-the-lock/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/ip-to-cidr "IP to CIDR") +[< Previous](../ip-to-cidr "IP to CIDR")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/cracking-the-safe "Cracking the Safe") +[Next >](../cracking-the-safe "Cracking the Safe") ## [752. Open the Lock (Medium)](https://leetcode.com/problems/open-the-lock "打开转盘锁") @@ -66,7 +66,7 @@ We can't reach the target without getting stuck.

### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Hints
diff --git a/problems/optimal-account-balancing/README.md b/problems/optimal-account-balancing/README.md index e9d09522d..0bb3b3b4f 100644 --- a/problems/optimal-account-balancing/README.md +++ b/problems/optimal-account-balancing/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/can-i-win "Can I Win") +[< Previous](../can-i-win "Can I Win")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/count-the-repetitions "Count The Repetitions") +[Next >](../count-the-repetitions "Count The Repetitions") ## [465. Optimal Account Balancing (Hard)](https://leetcode.com/problems/optimal-account-balancing "最优账单平衡") diff --git a/problems/optimal-division/README.md b/problems/optimal-division/README.md index d72f3a290..3dd845203 100644 --- a/problems/optimal-division/README.md +++ b/problems/optimal-division/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/student-attendance-record-ii "Student Attendance Record II") +[< Previous](../student-attendance-record-ii "Student Attendance Record II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/brick-wall "Brick Wall") +[Next >](../brick-wall "Brick Wall") ## [553. Optimal Division (Medium)](https://leetcode.com/problems/optimal-division "最优除法") @@ -40,5 +40,5 @@ Other cases:

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/optimize-water-distribution-in-a-village/README.md b/problems/optimize-water-distribution-in-a-village/README.md index 2a3e4db94..2c9ea50d0 100644 --- a/problems/optimize-water-distribution-in-a-village/README.md +++ b/problems/optimize-water-distribution-in-a-village/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-to-connect-sticks "Minimum Cost to Connect Sticks") +[< Previous](../minimum-cost-to-connect-sticks "Minimum Cost to Connect Sticks")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/invalid-transactions "Invalid Transactions") +[Next >](../invalid-transactions "Invalid Transactions") ## [1168. Optimize Water Distribution in a Village (Hard)](https://leetcode.com/problems/optimize-water-distribution-in-a-village "水资源分配优化") @@ -44,8 +44,8 @@ The best strategy is to build a well in the first house with cost 1 and connect ### Related Topics - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] ### Hints
diff --git a/problems/orderly-queue/README.md b/problems/orderly-queue/README.md index c26709ec0..f245fb700 100644 --- a/problems/orderly-queue/README.md +++ b/problems/orderly-queue/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/bitwise-ors-of-subarrays "Bitwise ORs of Subarrays") +[< Previous](../bitwise-ors-of-subarrays "Bitwise ORs of Subarrays")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/rle-iterator "RLE Iterator") +[Next >](../rle-iterator "RLE Iterator") ## [899. Orderly Queue (Hard)](https://leetcode.com/problems/orderly-queue "有序队列") @@ -53,5 +53,5 @@ In the second move, we move the 3rd character ("c") to the end, obtain ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/out-of-boundary-paths/README.md b/problems/out-of-boundary-paths/README.md index a3719733d..31811361b 100644 --- a/problems/out-of-boundary-paths/README.md +++ b/problems/out-of-boundary-paths/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/distribute-candies "Distribute Candies") +[< Previous](../distribute-candies "Distribute Candies")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/employee-bonus "Employee Bonus") +[Next >](../employee-bonus "Employee Bonus") ## [576. Out of Boundary Paths (Medium)](https://leetcode.com/problems/out-of-boundary-paths "出界的路径数") @@ -44,11 +44,11 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Knight Probability in Chessboard](https://github.com/openset/leetcode/tree/master/problems/knight-probability-in-chessboard) (Medium) + 1. [Knight Probability in Chessboard](../knight-probability-in-chessboard) (Medium) ### Hints
diff --git a/problems/output-contest-matches/README.md b/problems/output-contest-matches/README.md index 5dd263202..784571272 100644 --- a/problems/output-contest-matches/README.md +++ b/problems/output-contest-matches/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/diameter-of-binary-tree "Diameter of Binary Tree") +[< Previous](../diameter-of-binary-tree "Diameter of Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/boundary-of-binary-tree "Boundary of Binary Tree") +[Next >](../boundary-of-binary-tree "Boundary of Binary Tree") ## [544. Output Contest Matches (Medium)](https://leetcode.com/problems/output-contest-matches "输出比赛匹配对") @@ -56,5 +56,5 @@ Since the third round will generate the final winner, you need to output the ans

### Related Topics - [[Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/pacific-atlantic-water-flow/README.md b/problems/pacific-atlantic-water-flow/README.md index ade44570b..0b253b797 100644 --- a/problems/pacific-atlantic-water-flow/README.md +++ b/problems/pacific-atlantic-water-flow/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/partition-equal-subset-sum "Partition Equal Subset Sum") +[< Previous](../partition-equal-subset-sum "Partition Equal Subset Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sentence-screen-fitting "Sentence Screen Fitting") +[Next >](../sentence-screen-fitting "Sentence Screen Fitting") ## [417. Pacific Atlantic Water Flow (Medium)](https://leetcode.com/problems/pacific-atlantic-water-flow "太平洋大西洋水流问题") @@ -47,5 +47,5 @@ Return:

 

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/page-recommendations/README.md b/problems/page-recommendations/README.md index ed8e615fa..e7a369734 100644 --- a/problems/page-recommendations/README.md +++ b/problems/page-recommendations/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-move-a-box-to-their-target-location "Minimum Moves to Move a Box to Their Target Location") +[< Previous](../minimum-moves-to-move-a-box-to-their-target-location "Minimum Moves to Move a Box to Their Target Location")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/print-immutable-linked-list-in-reverse "Print Immutable Linked List in Reverse") +[Next >](../print-immutable-linked-list-in-reverse "Print Immutable Linked List in Reverse") ## [1264. Page Recommendations (Medium)](https://leetcode.com/problems/page-recommendations "") diff --git a/problems/paint-fence/README.md b/problems/paint-fence/README.md index bc0e1e428..03eb7abea 100644 --- a/problems/paint-fence/README.md +++ b/problems/paint-fence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/h-index-ii "H-Index II") +[< Previous](../h-index-ii "H-Index II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-the-celebrity "Find the Celebrity") +[Next >](../find-the-celebrity "Find the Celebrity") ## [276. Paint Fence (Easy)](https://leetcode.com/problems/paint-fence "栅栏涂色") @@ -38,10 +38,10 @@ n and k are non-negative integers.

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [House Robber](https://github.com/openset/leetcode/tree/master/problems/house-robber) (Easy) - 1. [House Robber II](https://github.com/openset/leetcode/tree/master/problems/house-robber-ii) (Medium) - 1. [Paint House](https://github.com/openset/leetcode/tree/master/problems/paint-house) (Easy) - 1. [Paint House II](https://github.com/openset/leetcode/tree/master/problems/paint-house-ii) (Hard) + 1. [House Robber](../house-robber) (Easy) + 1. [House Robber II](../house-robber-ii) (Medium) + 1. [Paint House](../paint-house) (Easy) + 1. [Paint House II](../paint-house-ii) (Hard) diff --git a/problems/paint-house-ii/README.md b/problems/paint-house-ii/README.md index 6c67ad2d3..4cf6ca2a3 100644 --- a/problems/paint-house-ii/README.md +++ b/problems/paint-house-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/ugly-number-ii "Ugly Number II") +[< Previous](../ugly-number-ii "Ugly Number II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/palindrome-permutation "Palindrome Permutation") +[Next >](../palindrome-permutation "Palindrome Permutation") ## [265. Paint House II (Hard)](https://leetcode.com/problems/paint-house-ii "粉刷房子 II") @@ -31,10 +31,10 @@ All costs are positive integers.

Could you solve it in O(nk) runtime?

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Product of Array Except Self](https://github.com/openset/leetcode/tree/master/problems/product-of-array-except-self) (Medium) - 1. [Sliding Window Maximum](https://github.com/openset/leetcode/tree/master/problems/sliding-window-maximum) (Hard) - 1. [Paint House](https://github.com/openset/leetcode/tree/master/problems/paint-house) (Easy) - 1. [Paint Fence](https://github.com/openset/leetcode/tree/master/problems/paint-fence) (Easy) + 1. [Product of Array Except Self](../product-of-array-except-self) (Medium) + 1. [Sliding Window Maximum](../sliding-window-maximum) (Hard) + 1. [Paint House](../paint-house) (Easy) + 1. [Paint Fence](../paint-fence) (Easy) diff --git a/problems/paint-house/README.md b/problems/paint-house/README.md index d2a630ea7..ca0ca2513 100644 --- a/problems/paint-house/README.md +++ b/problems/paint-house/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/verify-preorder-sequence-in-binary-search-tree "Verify Preorder Sequence in Binary Search Tree") +[< Previous](../verify-preorder-sequence-in-binary-search-tree "Verify Preorder Sequence in Binary Search Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-tree-paths "Binary Tree Paths") +[Next >](../binary-tree-paths "Binary Tree Paths") ## [256. Paint House (Easy)](https://leetcode.com/problems/paint-house "粉刷房子") @@ -28,10 +28,10 @@ All costs are positive integers.

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [House Robber](https://github.com/openset/leetcode/tree/master/problems/house-robber) (Easy) - 1. [House Robber II](https://github.com/openset/leetcode/tree/master/problems/house-robber-ii) (Medium) - 1. [Paint House II](https://github.com/openset/leetcode/tree/master/problems/paint-house-ii) (Hard) - 1. [Paint Fence](https://github.com/openset/leetcode/tree/master/problems/paint-fence) (Easy) + 1. [House Robber](../house-robber) (Easy) + 1. [House Robber II](../house-robber-ii) (Medium) + 1. [Paint House II](../paint-house-ii) (Hard) + 1. [Paint Fence](../paint-fence) (Easy) diff --git a/problems/pairs-of-songs-with-total-durations-divisible-by-60/README.md b/problems/pairs-of-songs-with-total-durations-divisible-by-60/README.md index 34ecb218e..9e5ac8d38 100644 --- a/problems/pairs-of-songs-with-total-durations-divisible-by-60/README.md +++ b/problems/pairs-of-songs-with-total-durations-divisible-by-60/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/complement-of-base-10-integer "Complement of Base 10 Integer") +[< Previous](../complement-of-base-10-integer "Complement of Base 10 Integer")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/capacity-to-ship-packages-within-d-days "Capacity To Ship Packages Within D Days") +[Next >](../capacity-to-ship-packages-within-d-days "Capacity To Ship Packages Within D Days") ## [1010. Pairs of Songs With Total Durations Divisible by 60 (Easy)](https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60 "总持续时间可被 60 整除的歌曲") @@ -48,7 +48,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/palindrome-linked-list/README.md b/problems/palindrome-linked-list/README.md index a70f16f45..1bb515a82 100644 --- a/problems/palindrome-linked-list/README.md +++ b/problems/palindrome-linked-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-digit-one "Number of Digit One") +[< Previous](../number-of-digit-one "Number of Digit One")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/lowest-common-ancestor-of-a-binary-search-tree "Lowest Common Ancestor of a Binary Search Tree") +[Next >](../lowest-common-ancestor-of-a-binary-search-tree "Lowest Common Ancestor of a Binary Search Tree") ## [234. Palindrome Linked List (Easy)](https://leetcode.com/problems/palindrome-linked-list "回文链表") @@ -29,10 +29,10 @@ Could you do it in O(n) time and O(1) space?

### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Palindrome Number](https://github.com/openset/leetcode/tree/master/problems/palindrome-number) (Easy) - 1. [Valid Palindrome](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome) (Easy) - 1. [Reverse Linked List](https://github.com/openset/leetcode/tree/master/problems/reverse-linked-list) (Easy) + 1. [Palindrome Number](../palindrome-number) (Easy) + 1. [Valid Palindrome](../valid-palindrome) (Easy) + 1. [Reverse Linked List](../reverse-linked-list) (Easy) diff --git a/problems/palindrome-number/README.md b/problems/palindrome-number/README.md index bf22a0386..2fb012ce4 100644 --- a/problems/palindrome-number/README.md +++ b/problems/palindrome-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/string-to-integer-atoi "String to Integer (atoi)") +[< Previous](../string-to-integer-atoi "String to Integer (atoi)")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/regular-expression-matching "Regular Expression Matching") +[Next >](../regular-expression-matching "Regular Expression Matching") ## [9. Palindrome Number (Easy)](https://leetcode.com/problems/palindrome-number "回文数") @@ -41,10 +41,10 @@

Coud you solve it without converting the integer to a string?

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Palindrome Linked List](https://github.com/openset/leetcode/tree/master/problems/palindrome-linked-list) (Easy) + 1. [Palindrome Linked List](../palindrome-linked-list) (Easy) ### Hints
diff --git a/problems/palindrome-pairs/README.md b/problems/palindrome-pairs/README.md index 797712f1f..a1005a77d 100644 --- a/problems/palindrome-pairs/README.md +++ b/problems/palindrome-pairs/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/self-crossing "Self Crossing") +[< Previous](../self-crossing "Self Crossing")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/house-robber-iii "House Robber III") +[Next >](../house-robber-iii "House Robber III") ## [336. Palindrome Pairs (Hard)](https://leetcode.com/problems/palindrome-pairs "回文对") @@ -34,10 +34,10 @@ ### Related Topics - [[Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Longest Palindromic Substring](https://github.com/openset/leetcode/tree/master/problems/longest-palindromic-substring) (Medium) - 1. [Shortest Palindrome](https://github.com/openset/leetcode/tree/master/problems/shortest-palindrome) (Hard) + 1. [Longest Palindromic Substring](../longest-palindromic-substring) (Medium) + 1. [Shortest Palindrome](../shortest-palindrome) (Hard) diff --git a/problems/palindrome-partitioning-ii/README.md b/problems/palindrome-partitioning-ii/README.md index 7c5520f4d..f511bd3c9 100644 --- a/problems/palindrome-partitioning-ii/README.md +++ b/problems/palindrome-partitioning-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/palindrome-partitioning "Palindrome Partitioning") +[< Previous](../palindrome-partitioning "Palindrome Partitioning")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/clone-graph "Clone Graph") +[Next >](../clone-graph "Clone Graph") ## [132. Palindrome Partitioning II (Hard)](https://leetcode.com/problems/palindrome-partitioning-ii "分割回文串 II") @@ -24,7 +24,7 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Palindrome Partitioning](https://github.com/openset/leetcode/tree/master/problems/palindrome-partitioning) (Medium) + 1. [Palindrome Partitioning](../palindrome-partitioning) (Medium) diff --git a/problems/palindrome-partitioning-iii/README.md b/problems/palindrome-partitioning-iii/README.md index 756123c04..0dc5381f5 100644 --- a/problems/palindrome-partitioning-iii/README.md +++ b/problems/palindrome-partitioning-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/count-square-submatrices-with-all-ones "Count Square Submatrices with All Ones") +[< Previous](../count-square-submatrices-with-all-ones "Count Square Submatrices with All Ones")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/traffic-light-controlled-intersection "Traffic Light Controlled Intersection") +[Next >](../traffic-light-controlled-intersection "Traffic Light Controlled Intersection") ## [1278. Palindrome Partitioning III (Hard)](https://leetcode.com/problems/palindrome-partitioning-iii "分割回文串 III") @@ -52,7 +52,7 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/palindrome-partitioning/README.md b/problems/palindrome-partitioning/README.md index edfc550cf..8fefdf049 100644 --- a/problems/palindrome-partitioning/README.md +++ b/problems/palindrome-partitioning/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/surrounded-regions "Surrounded Regions") +[< Previous](../surrounded-regions "Surrounded Regions")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/palindrome-partitioning-ii "Palindrome Partitioning II") +[Next >](../palindrome-partitioning-ii "Palindrome Partitioning II") ## [131. Palindrome Partitioning (Medium)](https://leetcode.com/problems/palindrome-partitioning "分割回文串") @@ -27,7 +27,7 @@ ### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Palindrome Partitioning II](https://github.com/openset/leetcode/tree/master/problems/palindrome-partitioning-ii) (Hard) + 1. [Palindrome Partitioning II](../palindrome-partitioning-ii) (Hard) diff --git a/problems/palindrome-permutation-ii/README.md b/problems/palindrome-permutation-ii/README.md index ac5d96264..955fa468f 100644 --- a/problems/palindrome-permutation-ii/README.md +++ b/problems/palindrome-permutation-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/palindrome-permutation "Palindrome Permutation") +[< Previous](../palindrome-permutation "Palindrome Permutation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/missing-number "Missing Number") +[Next >](../missing-number "Missing Number") ## [267. Palindrome Permutation II (Medium)](https://leetcode.com/problems/palindrome-permutation-ii "回文排列 II") @@ -24,12 +24,12 @@ Output: [] ### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Next Permutation](https://github.com/openset/leetcode/tree/master/problems/next-permutation) (Medium) - 1. [Permutations II](https://github.com/openset/leetcode/tree/master/problems/permutations-ii) (Medium) - 1. [Palindrome Permutation](https://github.com/openset/leetcode/tree/master/problems/palindrome-permutation) (Easy) + 1. [Next Permutation](../next-permutation) (Medium) + 1. [Permutations II](../permutations-ii) (Medium) + 1. [Palindrome Permutation](../palindrome-permutation) (Easy) ### Hints
diff --git a/problems/palindrome-permutation/README.md b/problems/palindrome-permutation/README.md index 935bf732b..865215b59 100644 --- a/problems/palindrome-permutation/README.md +++ b/problems/palindrome-permutation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/paint-house-ii "Paint House II") +[< Previous](../paint-house-ii "Paint House II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/palindrome-permutation-ii "Palindrome Permutation II") +[Next >](../palindrome-permutation-ii "Palindrome Permutation II") ## [266. Palindrome Permutation (Easy)](https://leetcode.com/problems/palindrome-permutation "回文排列") @@ -29,13 +29,13 @@ Output: true ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Longest Palindromic Substring](https://github.com/openset/leetcode/tree/master/problems/longest-palindromic-substring) (Medium) - 1. [Valid Anagram](https://github.com/openset/leetcode/tree/master/problems/valid-anagram) (Easy) - 1. [Palindrome Permutation II](https://github.com/openset/leetcode/tree/master/problems/palindrome-permutation-ii) (Medium) - 1. [Longest Palindrome](https://github.com/openset/leetcode/tree/master/problems/longest-palindrome) (Easy) + 1. [Longest Palindromic Substring](../longest-palindromic-substring) (Medium) + 1. [Valid Anagram](../valid-anagram) (Easy) + 1. [Palindrome Permutation II](../palindrome-permutation-ii) (Medium) + 1. [Longest Palindrome](../longest-palindrome) (Easy) ### Hints
diff --git a/problems/palindrome-removal/README.md b/problems/palindrome-removal/README.md index 6705ece34..30cd1b25d 100644 --- a/problems/palindrome-removal/README.md +++ b/problems/palindrome-removal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/tree-diameter "Tree Diameter") +[< Previous](../tree-diameter "Tree Diameter")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-swaps-to-make-strings-equal "Minimum Swaps to Make Strings Equal") +[Next >](../minimum-swaps-to-make-strings-equal "Minimum Swaps to Make Strings Equal") ## [1246. Palindrome Removal (Hard)](https://leetcode.com/problems/palindrome-removal "删除回文子数组") @@ -40,7 +40,7 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/palindromic-substrings/README.md b/problems/palindromic-substrings/README.md index e197ee619..05e2e21f5 100644 --- a/problems/palindromic-substrings/README.md +++ b/problems/palindromic-substrings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-pair-chain "Maximum Length of Pair Chain") +[< Previous](../maximum-length-of-pair-chain "Maximum Length of Pair Chain")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/replace-words "Replace Words") +[Next >](../replace-words "Replace Words") ## [647. Palindromic Substrings (Medium)](https://leetcode.com/problems/palindromic-substrings "回文子串") @@ -44,13 +44,13 @@

 

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Longest Palindromic Substring](https://github.com/openset/leetcode/tree/master/problems/longest-palindromic-substring) (Medium) - 1. [Longest Palindromic Subsequence](https://github.com/openset/leetcode/tree/master/problems/longest-palindromic-subsequence) (Medium) - 1. [Palindromic Substrings](https://github.com/openset/leetcode/tree/master/problems/palindromic-substrings) (Medium) + 1. [Longest Palindromic Substring](../longest-palindromic-substring) (Medium) + 1. [Longest Palindromic Subsequence](../longest-palindromic-subsequence) (Medium) + 1. [Palindromic Substrings](../palindromic-substrings) (Medium) ### Hints
diff --git a/problems/pancake-sorting/README.md b/problems/pancake-sorting/README.md index 7befdf534..7c0d1e180 100644 --- a/problems/pancake-sorting/README.md +++ b/problems/pancake-sorting/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-tree-cameras "Binary Tree Cameras") +[< Previous](../binary-tree-cameras "Binary Tree Cameras")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/powerful-integers "Powerful Integers") +[Next >](../powerful-integers "Powerful Integers") ## [969. Pancake Sorting (Medium)](https://leetcode.com/problems/pancake-sorting "煎饼排序") @@ -52,5 +52,5 @@ Note that other answers, such as [3, 3], would also be accepted. ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/parallel-courses/README.md b/problems/parallel-courses/README.md index d0ba637d3..823516bf4 100644 --- a/problems/parallel-courses/README.md +++ b/problems/parallel-courses/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/connecting-cities-with-minimum-cost "Connecting Cities With Minimum Cost") +[< Previous](../connecting-cities-with-minimum-cost "Connecting Cities With Minimum Cost")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/n-th-tribonacci-number "N-th Tribonacci Number") +[Next >](../n-th-tribonacci-number "N-th Tribonacci Number") ## [1136. Parallel Courses (Hard)](https://leetcode.com/problems/parallel-courses "平行课程") @@ -55,9 +55,9 @@ No course can be studied because they depend on each other. ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/parse-lisp-expression/README.md b/problems/parse-lisp-expression/README.md index 8d240afae..a90237542 100644 --- a/problems/parse-lisp-expression/README.md +++ b/problems/parse-lisp-expression/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/asteroid-collision "Asteroid Collision") +[< Previous](../asteroid-collision "Asteroid Collision")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sentence-similarity-ii "Sentence Similarity II") +[Next >](../sentence-similarity-ii "Sentence Similarity II") ## [736. Parse Lisp Expression (Hard)](https://leetcode.com/problems/parse-lisp-expression "Lisp 语法解析") @@ -75,12 +75,12 @@ of the final x in the add-expression. That final x will equal 2.

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Ternary Expression Parser](https://github.com/openset/leetcode/tree/master/problems/ternary-expression-parser) (Medium) - 1. [Number of Atoms](https://github.com/openset/leetcode/tree/master/problems/number-of-atoms) (Hard) - 1. [Basic Calculator IV](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iv) (Hard) + 1. [Ternary Expression Parser](../ternary-expression-parser) (Medium) + 1. [Number of Atoms](../number-of-atoms) (Hard) + 1. [Basic Calculator IV](../basic-calculator-iv) (Hard) ### Hints
diff --git a/problems/parsing-a-boolean-expression/README.md b/problems/parsing-a-boolean-expression/README.md index 30029252d..227146bce 100644 --- a/problems/parsing-a-boolean-expression/README.md +++ b/problems/parsing-a-boolean-expression/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/filling-bookcase-shelves "Filling Bookcase Shelves") +[< Previous](../filling-bookcase-shelves "Filling Bookcase Shelves")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/new-users-daily-count "New Users Daily Count") +[Next >](../new-users-daily-count "New Users Daily Count") ## [1106. Parsing A Boolean Expression (Hard)](https://leetcode.com/problems/parsing-a-boolean-expression "解析布尔表达式") @@ -62,7 +62,7 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/partition-array-for-maximum-sum/README.md b/problems/partition-array-for-maximum-sum/README.md index 08ebc734e..0c2ac4cbc 100644 --- a/problems/partition-array-for-maximum-sum/README.md +++ b/problems/partition-array-for-maximum-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/flower-planting-with-no-adjacent "Flower Planting With No Adjacent") +[< Previous](../flower-planting-with-no-adjacent "Flower Planting With No Adjacent")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-duplicate-substring "Longest Duplicate Substring") +[Next >](../longest-duplicate-substring "Longest Duplicate Substring") ## [1043. Partition Array for Maximum Sum (Medium)](https://leetcode.com/problems/partition-array-for-maximum-sum "分隔数组以得到最大和") @@ -34,7 +34,7 @@ ### Related Topics - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Graph](../../tag/graph/README.md)] ### Hints
diff --git a/problems/partition-array-into-disjoint-intervals/README.md b/problems/partition-array-into-disjoint-intervals/README.md index e0f1e8953..28bb1ce3f 100644 --- a/problems/partition-array-into-disjoint-intervals/README.md +++ b/problems/partition-array-into-disjoint-intervals/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/x-of-a-kind-in-a-deck-of-cards "X of a Kind in a Deck of Cards") +[< Previous](../x-of-a-kind-in-a-deck-of-cards "X of a Kind in a Deck of Cards")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/word-subsets "Word Subsets") +[Next >](../word-subsets "Word Subsets") ## [915. Partition Array into Disjoint Intervals (Medium)](https://leetcode.com/problems/partition-array-into-disjoint-intervals "分割数组") @@ -56,4 +56,4 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/partition-array-into-three-parts-with-equal-sum/README.md b/problems/partition-array-into-three-parts-with-equal-sum/README.md index 617d531c1..17458db56 100644 --- a/problems/partition-array-into-three-parts-with-equal-sum/README.md +++ b/problems/partition-array-into-three-parts-with-equal-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/numbers-with-repeated-digits "Numbers With Repeated Digits") +[< Previous](../numbers-with-repeated-digits "Numbers With Repeated Digits")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/best-sightseeing-pair "Best Sightseeing Pair") +[Next >](../best-sightseeing-pair "Best Sightseeing Pair") ## [1013. Partition Array Into Three Parts With Equal Sum (Easy)](https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum "将数组分成和相等的三个部分") @@ -54,7 +54,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/partition-equal-subset-sum/README.md b/problems/partition-equal-subset-sum/README.md index de9e9da24..2a8918ccf 100644 --- a/problems/partition-equal-subset-sum/README.md +++ b/problems/partition-equal-subset-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/add-strings "Add Strings") +[< Previous](../add-strings "Add Strings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/pacific-atlantic-water-flow "Pacific Atlantic Water Flow") +[Next >](../pacific-atlantic-water-flow "Pacific Atlantic Water Flow") ## [416. Partition Equal Subset Sum (Medium)](https://leetcode.com/problems/partition-equal-subset-sum "分割等和子集") @@ -47,7 +47,7 @@ Explanation: The array cannot be partitioned into equal sum subsets.

 

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Partition to K Equal Sum Subsets](https://github.com/openset/leetcode/tree/master/problems/partition-to-k-equal-sum-subsets) (Medium) + 1. [Partition to K Equal Sum Subsets](../partition-to-k-equal-sum-subsets) (Medium) diff --git a/problems/partition-labels/README.md b/problems/partition-labels/README.md index a712e88e2..52a9a5fab 100644 --- a/problems/partition-labels/README.md +++ b/problems/partition-labels/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/prime-number-of-set-bits-in-binary-representation "Prime Number of Set Bits in Binary Representation") +[< Previous](../prime-number-of-set-bits-in-binary-representation "Prime Number of Set Bits in Binary Representation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/largest-plus-sign "Largest Plus Sign") +[Next >](../largest-plus-sign "Largest Plus Sign") ## [763. Partition Labels (Medium)](https://leetcode.com/problems/partition-labels "划分字母区间") @@ -32,11 +32,11 @@ A partition like "ababcbacadefegde", "hijhklij" is incorrect, because it splits

### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Merge Intervals](https://github.com/openset/leetcode/tree/master/problems/merge-intervals) (Medium) + 1. [Merge Intervals](../merge-intervals) (Medium) ### Hints
diff --git a/problems/partition-list/README.md b/problems/partition-list/README.md index 50f89c4d6..9d88e31d5 100644 --- a/problems/partition-list/README.md +++ b/problems/partition-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximal-rectangle "Maximal Rectangle") +[< Previous](../maximal-rectangle "Maximal Rectangle")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/scramble-string "Scramble String") +[Next >](../scramble-string "Scramble String") ## [86. Partition List (Medium)](https://leetcode.com/problems/partition-list "分隔链表") @@ -23,5 +23,5 @@ ### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/partition-to-k-equal-sum-subsets/README.md b/problems/partition-to-k-equal-sum-subsets/README.md index 8e6965555..9d06a68ed 100644 --- a/problems/partition-to-k-equal-sum-subsets/README.md +++ b/problems/partition-to-k-equal-sum-subsets/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/degree-of-an-array "Degree of an Array") +[< Previous](../degree-of-an-array "Degree of an Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/falling-squares "Falling Squares") +[Next >](../falling-squares "Falling Squares") ## [698. Partition to K Equal Sum Subsets (Medium)](https://leetcode.com/problems/partition-to-k-equal-sum-subsets "划分为k个相等的子集") @@ -33,11 +33,11 @@ ### Related Topics - [[Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Partition Equal Subset Sum](https://github.com/openset/leetcode/tree/master/problems/partition-equal-subset-sum) (Medium) + 1. [Partition Equal Subset Sum](../partition-equal-subset-sum) (Medium) ### Hints
diff --git a/problems/pascals-triangle-ii/README.md b/problems/pascals-triangle-ii/README.md index e8ae762da..1aba95a12 100644 --- a/problems/pascals-triangle-ii/README.md +++ b/problems/pascals-triangle-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/pascals-triangle "Pascal's Triangle") +[< Previous](../pascals-triangle "Pascal's Triangle")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/triangle "Triangle") +[Next >](../triangle "Triangle") ## [119. Pascal's Triangle II (Easy)](https://leetcode.com/problems/pascals-triangle-ii "杨辉三角 II") @@ -30,7 +30,7 @@

Could you optimize your algorithm to use only O(k) extra space?

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Pascal's Triangle](https://github.com/openset/leetcode/tree/master/problems/pascals-triangle) (Easy) + 1. [Pascal's Triangle](../pascals-triangle) (Easy) diff --git a/problems/pascals-triangle/README.md b/problems/pascals-triangle/README.md index 84634d9b5..2ef0d3e30 100644 --- a/problems/pascals-triangle/README.md +++ b/problems/pascals-triangle/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/populating-next-right-pointers-in-each-node-ii "Populating Next Right Pointers in Each Node II") +[< Previous](../populating-next-right-pointers-in-each-node-ii "Populating Next Right Pointers in Each Node II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/pascals-triangle-ii "Pascal's Triangle II") +[Next >](../pascals-triangle-ii "Pascal's Triangle II") ## [118. Pascal's Triangle (Easy)](https://leetcode.com/problems/pascals-triangle "杨辉三角") @@ -31,7 +31,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Pascal's Triangle II](https://github.com/openset/leetcode/tree/master/problems/pascals-triangle-ii) (Easy) + 1. [Pascal's Triangle II](../pascals-triangle-ii) (Easy) diff --git a/problems/patching-array/README.md b/problems/patching-array/README.md index 30f0a78d8..d89e2785c 100644 --- a/problems/patching-array/README.md +++ b/problems/patching-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-increasing-path-in-a-matrix "Longest Increasing Path in a Matrix") +[< Previous](../longest-increasing-path-in-a-matrix "Longest Increasing Path in a Matrix")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/verify-preorder-serialization-of-a-binary-tree "Verify Preorder Serialization of a Binary Tree") +[Next >](../verify-preorder-serialization-of-a-binary-tree "Verify Preorder Serialization of a Binary Tree") ## [330. Patching Array (Hard)](https://leetcode.com/problems/patching-array "按要求补齐数组") @@ -40,4 +40,4 @@ So we only need 1 patch. ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/path-in-zigzag-labelled-binary-tree/README.md b/problems/path-in-zigzag-labelled-binary-tree/README.md index ef8048b43..c32c25e76 100644 --- a/problems/path-in-zigzag-labelled-binary-tree/README.md +++ b/problems/path-in-zigzag-labelled-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/distribute-candies-to-people "Distribute Candies to People") +[< Previous](../distribute-candies-to-people "Distribute Candies to People")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/filling-bookcase-shelves "Filling Bookcase Shelves") +[Next >](../filling-bookcase-shelves "Filling Bookcase Shelves") ## [1104. Path In Zigzag Labelled Binary Tree (Medium)](https://leetcode.com/problems/path-in-zigzag-labelled-binary-tree "二叉树寻路") @@ -42,8 +42,8 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/path-sum-ii/README.md b/problems/path-sum-ii/README.md index c866b5769..06f289c5c 100644 --- a/problems/path-sum-ii/README.md +++ b/problems/path-sum-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/path-sum "Path Sum") +[< Previous](../path-sum "Path Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/flatten-binary-tree-to-linked-list "Flatten Binary Tree to Linked List") +[Next >](../flatten-binary-tree-to-linked-list "Flatten Binary Tree to Linked List") ## [113. Path Sum II (Medium)](https://leetcode.com/problems/path-sum-ii "路径总和 II") @@ -39,11 +39,11 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Path Sum](https://github.com/openset/leetcode/tree/master/problems/path-sum) (Easy) - 1. [Binary Tree Paths](https://github.com/openset/leetcode/tree/master/problems/binary-tree-paths) (Easy) - 1. [Path Sum III](https://github.com/openset/leetcode/tree/master/problems/path-sum-iii) (Easy) - 1. [Path Sum IV](https://github.com/openset/leetcode/tree/master/problems/path-sum-iv) (Medium) + 1. [Path Sum](../path-sum) (Easy) + 1. [Binary Tree Paths](../binary-tree-paths) (Easy) + 1. [Path Sum III](../path-sum-iii) (Easy) + 1. [Path Sum IV](../path-sum-iv) (Medium) diff --git a/problems/path-sum-iii/README.md b/problems/path-sum-iii/README.md index 6eb2edb78..5aefe3f75 100644 --- a/problems/path-sum-iii/README.md +++ b/problems/path-sum-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-right-interval "Find Right Interval") +[< Previous](../find-right-interval "Find Right Interval")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-all-anagrams-in-a-string "Find All Anagrams in a String") +[Next >](../find-all-anagrams-in-a-string "Find All Anagrams in a String") ## [437. Path Sum III (Easy)](https://leetcode.com/problems/path-sum-iii "路径总和 III") @@ -41,10 +41,10 @@ Return 3. The paths that sum to 8 are:

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Path Sum](https://github.com/openset/leetcode/tree/master/problems/path-sum) (Easy) - 1. [Path Sum II](https://github.com/openset/leetcode/tree/master/problems/path-sum-ii) (Medium) - 1. [Path Sum IV](https://github.com/openset/leetcode/tree/master/problems/path-sum-iv) (Medium) - 1. [Longest Univalue Path](https://github.com/openset/leetcode/tree/master/problems/longest-univalue-path) (Easy) + 1. [Path Sum](../path-sum) (Easy) + 1. [Path Sum II](../path-sum-ii) (Medium) + 1. [Path Sum IV](../path-sum-iv) (Medium) + 1. [Longest Univalue Path](../longest-univalue-path) (Easy) diff --git a/problems/path-sum-iv/README.md b/problems/path-sum-iv/README.md index b34a4feb6..c24266555 100644 --- a/problems/path-sum-iv/README.md +++ b/problems/path-sum-iv/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/non-decreasing-array "Non-decreasing Array") +[< Previous](../non-decreasing-array "Non-decreasing Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/beautiful-arrangement-ii "Beautiful Arrangement II") +[Next >](../beautiful-arrangement-ii "Beautiful Arrangement II") ## [666. Path Sum IV (Medium)](https://leetcode.com/problems/path-sum-iv "路径和 IV") @@ -56,10 +56,10 @@ The path sum is (3 + 1) = 4.

 

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Path Sum](https://github.com/openset/leetcode/tree/master/problems/path-sum) (Easy) - 1. [Path Sum II](https://github.com/openset/leetcode/tree/master/problems/path-sum-ii) (Medium) - 1. [Binary Tree Maximum Path Sum](https://github.com/openset/leetcode/tree/master/problems/binary-tree-maximum-path-sum) (Hard) - 1. [Path Sum III](https://github.com/openset/leetcode/tree/master/problems/path-sum-iii) (Easy) + 1. [Path Sum](../path-sum) (Easy) + 1. [Path Sum II](../path-sum-ii) (Medium) + 1. [Binary Tree Maximum Path Sum](../binary-tree-maximum-path-sum) (Hard) + 1. [Path Sum III](../path-sum-iii) (Easy) diff --git a/problems/path-sum/README.md b/problems/path-sum/README.md index a86e50a66..4938fdd45 100644 --- a/problems/path-sum/README.md +++ b/problems/path-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-depth-of-binary-tree "Minimum Depth of Binary Tree") +[< Previous](../minimum-depth-of-binary-tree "Minimum Depth of Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/path-sum-ii "Path Sum II") +[Next >](../path-sum-ii "Path Sum II") ## [112. Path Sum (Easy)](https://leetcode.com/problems/path-sum "路径总和") @@ -32,12 +32,12 @@

return true, as there exist a root-to-leaf path 5->4->11->2 which sum is 22.

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Path Sum II](https://github.com/openset/leetcode/tree/master/problems/path-sum-ii) (Medium) - 1. [Binary Tree Maximum Path Sum](https://github.com/openset/leetcode/tree/master/problems/binary-tree-maximum-path-sum) (Hard) - 1. [Sum Root to Leaf Numbers](https://github.com/openset/leetcode/tree/master/problems/sum-root-to-leaf-numbers) (Medium) - 1. [Path Sum III](https://github.com/openset/leetcode/tree/master/problems/path-sum-iii) (Easy) - 1. [Path Sum IV](https://github.com/openset/leetcode/tree/master/problems/path-sum-iv) (Medium) + 1. [Path Sum II](../path-sum-ii) (Medium) + 1. [Binary Tree Maximum Path Sum](../binary-tree-maximum-path-sum) (Hard) + 1. [Sum Root to Leaf Numbers](../sum-root-to-leaf-numbers) (Medium) + 1. [Path Sum III](../path-sum-iii) (Easy) + 1. [Path Sum IV](../path-sum-iv) (Medium) diff --git a/problems/path-with-maximum-gold/README.md b/problems/path-with-maximum-gold/README.md index 1d0dcf23a..451de7d4d 100644 --- a/problems/path-with-maximum-gold/README.md +++ b/problems/path-with-maximum-gold/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-arithmetic-subsequence-of-given-difference "Longest Arithmetic Subsequence of Given Difference") +[< Previous](../longest-arithmetic-subsequence-of-given-difference "Longest Arithmetic Subsequence of Given Difference")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/count-vowels-permutation "Count Vowels Permutation") +[Next >](../count-vowels-permutation "Count Vowels Permutation") ## [1219. Path with Maximum Gold (Medium)](https://leetcode.com/problems/path-with-maximum-gold "黄金矿工") @@ -60,7 +60,7 @@ Path to get the maximum gold, 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7. ### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Hints
diff --git a/problems/path-with-maximum-minimum-value/README.md b/problems/path-with-maximum-minimum-value/README.md index 2855bc72f..3a1a7ed12 100644 --- a/problems/path-with-maximum-minimum-value/README.md +++ b/problems/path-with-maximum-minimum-value/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/the-earliest-moment-when-everyone-become-friends "The Earliest Moment When Everyone Become Friends") +[< Previous](../the-earliest-moment-when-everyone-become-friends "The Earliest Moment When Everyone Become Friends")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/distribute-candies-to-people "Distribute Candies to People") +[Next >](../distribute-candies-to-people "Distribute Candies to People") ## [1102. Path With Maximum Minimum Value (Medium)](https://leetcode.com/problems/path-with-maximum-minimum-value "得分最高的路径") @@ -56,9 +56,9 @@ The path with the maximum score is highlighted in yellow. ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] ### Hints
diff --git a/problems/peak-index-in-a-mountain-array/README.md b/problems/peak-index-in-a-mountain-array/README.md index 71bdd1705..7d7bb7613 100644 --- a/problems/peak-index-in-a-mountain-array/README.md +++ b/problems/peak-index-in-a-mountain-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/loud-and-rich "Loud and Rich") +[< Previous](../loud-and-rich "Loud and Rich")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/car-fleet "Car Fleet") +[Next >](../car-fleet "Car Fleet") ## [852. Peak Index in a Mountain Array (Easy)](https://leetcode.com/problems/peak-index-in-a-mountain-array "山脉数组的峰顶索引") @@ -44,7 +44,7 @@ ### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Find Peak Element](https://github.com/openset/leetcode/tree/master/problems/find-peak-element) (Medium) + 1. [Find Peak Element](../find-peak-element) (Medium) diff --git a/problems/peeking-iterator/README.md b/problems/peeking-iterator/README.md index bafc60b67..62371eb61 100644 --- a/problems/peeking-iterator/README.md +++ b/problems/peeking-iterator/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/move-zeroes "Move Zeroes") +[< Previous](../move-zeroes "Move Zeroes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/inorder-successor-in-bst "Inorder Successor in BST") +[Next >](../inorder-successor-in-bst "Inorder Successor in BST") ## [284. Peeking Iterator (Medium)](https://leetcode.com/problems/peeking-iterator "顶端迭代器") @@ -27,12 +27,12 @@ Calling hasNext() after that should return Follow up: How would you extend your design to be generic and work with all types, not just integer?

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions - 1. [Binary Search Tree Iterator](https://github.com/openset/leetcode/tree/master/problems/binary-search-tree-iterator) (Medium) - 1. [Flatten 2D Vector](https://github.com/openset/leetcode/tree/master/problems/flatten-2d-vector) (Medium) - 1. [Zigzag Iterator](https://github.com/openset/leetcode/tree/master/problems/zigzag-iterator) (Medium) + 1. [Binary Search Tree Iterator](../binary-search-tree-iterator) (Medium) + 1. [Flatten 2D Vector](../flatten-2d-vector) (Medium) + 1. [Zigzag Iterator](../zigzag-iterator) (Medium) ### Hints
diff --git a/problems/perfect-number/README.md b/problems/perfect-number/README.md index 8a9994fcf..ad5382ff1 100644 --- a/problems/perfect-number/README.md +++ b/problems/perfect-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/relative-ranks "Relative Ranks") +[< Previous](../relative-ranks "Relative Ranks")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/most-frequent-subtree-sum "Most Frequent Subtree Sum") +[Next >](../most-frequent-subtree-sum "Most Frequent Subtree Sum") ## [507. Perfect Number (Easy)](https://leetcode.com/problems/perfect-number "完美数") @@ -29,7 +29,7 @@ The input number n will not exceed 100,000,000. (1e8)

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Self Dividing Numbers](https://github.com/openset/leetcode/tree/master/problems/self-dividing-numbers) (Easy) + 1. [Self Dividing Numbers](../self-dividing-numbers) (Easy) diff --git a/problems/perfect-rectangle/README.md b/problems/perfect-rectangle/README.md index c3dac2ecc..fdfef1386 100644 --- a/problems/perfect-rectangle/README.md +++ b/problems/perfect-rectangle/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/elimination-game "Elimination Game") +[< Previous](../elimination-game "Elimination Game")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/is-subsequence "Is Subsequence") +[Next >](../is-subsequence "Is Subsequence") ## [391. Perfect Rectangle (Hard)](https://leetcode.com/problems/perfect-rectangle "完美矩形") @@ -91,4 +91,4 @@ Return false. Because two of the rectangles overlap with each other.

 

### Related Topics - [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] + [[Line Sweep](../../tag/line-sweep/README.md)] diff --git a/problems/perfect-squares/README.md b/problems/perfect-squares/README.md index 4d091cd7d..71e721af9 100644 --- a/problems/perfect-squares/README.md +++ b/problems/perfect-squares/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/first-bad-version "First Bad Version") +[< Previous](../first-bad-version "First Bad Version")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/wiggle-sort "Wiggle Sort") +[Next >](../wiggle-sort "Wiggle Sort") ## [279. Perfect Squares (Medium)](https://leetcode.com/problems/perfect-squares "完全平方数") @@ -28,10 +28,10 @@ Explanation: 13 = 4 + 9. ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Count Primes](https://github.com/openset/leetcode/tree/master/problems/count-primes) (Easy) - 1. [Ugly Number II](https://github.com/openset/leetcode/tree/master/problems/ugly-number-ii) (Medium) + 1. [Count Primes](../count-primes) (Easy) + 1. [Ugly Number II](../ugly-number-ii) (Medium) diff --git a/problems/permutation-in-string/README.md b/problems/permutation-in-string/README.md index 9ece515a4..3c3b8fb52 100644 --- a/problems/permutation-in-string/README.md +++ b/problems/permutation-in-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reshape-the-matrix "Reshape the Matrix") +[< Previous](../reshape-the-matrix "Reshape the Matrix")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-vacation-days "Maximum Vacation Days") +[Next >](../maximum-vacation-days "Maximum Vacation Days") ## [567. Permutation in String (Medium)](https://leetcode.com/problems/permutation-in-string "字符串的排列") @@ -40,12 +40,12 @@ ### Related Topics - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions - 1. [Minimum Window Substring](https://github.com/openset/leetcode/tree/master/problems/minimum-window-substring) (Hard) - 1. [Find All Anagrams in a String](https://github.com/openset/leetcode/tree/master/problems/find-all-anagrams-in-a-string) (Medium) + 1. [Minimum Window Substring](../minimum-window-substring) (Hard) + 1. [Find All Anagrams in a String](../find-all-anagrams-in-a-string) (Medium) ### Hints
diff --git a/problems/permutation-sequence/README.md b/problems/permutation-sequence/README.md index 3b7a4b88e..4f57d9204 100644 --- a/problems/permutation-sequence/README.md +++ b/problems/permutation-sequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/spiral-matrix-ii "Spiral Matrix II") +[< Previous](../spiral-matrix-ii "Spiral Matrix II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/rotate-list "Rotate List") +[Next >](../rotate-list "Rotate List") ## [60. Permutation Sequence (Medium)](https://leetcode.com/problems/permutation-sequence "第k个排列") @@ -48,9 +48,9 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Math](../../tag/math/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Next Permutation](https://github.com/openset/leetcode/tree/master/problems/next-permutation) (Medium) - 1. [Permutations](https://github.com/openset/leetcode/tree/master/problems/permutations) (Medium) + 1. [Next Permutation](../next-permutation) (Medium) + 1. [Permutations](../permutations) (Medium) diff --git a/problems/permutations-ii/README.md b/problems/permutations-ii/README.md index 70cd26333..2aa447990 100644 --- a/problems/permutations-ii/README.md +++ b/problems/permutations-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/permutations "Permutations") +[< Previous](../permutations "Permutations")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/rotate-image "Rotate Image") +[Next >](../rotate-image "Rotate Image") ## [47. Permutations II (Medium)](https://leetcode.com/problems/permutations-ii "全排列 II") @@ -26,10 +26,10 @@ ### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Next Permutation](https://github.com/openset/leetcode/tree/master/problems/next-permutation) (Medium) - 1. [Permutations](https://github.com/openset/leetcode/tree/master/problems/permutations) (Medium) - 1. [Palindrome Permutation II](https://github.com/openset/leetcode/tree/master/problems/palindrome-permutation-ii) (Medium) - 1. [Number of Squareful Arrays](https://github.com/openset/leetcode/tree/master/problems/number-of-squareful-arrays) (Hard) + 1. [Next Permutation](../next-permutation) (Medium) + 1. [Permutations](../permutations) (Medium) + 1. [Palindrome Permutation II](../palindrome-permutation-ii) (Medium) + 1. [Number of Squareful Arrays](../number-of-squareful-arrays) (Hard) diff --git a/problems/permutations/README.md b/problems/permutations/README.md index 1dcb5d5fc..68fceb164 100644 --- a/problems/permutations/README.md +++ b/problems/permutations/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/jump-game-ii "Jump Game II") +[< Previous](../jump-game-ii "Jump Game II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/permutations-ii "Permutations II") +[Next >](../permutations-ii "Permutations II") ## [46. Permutations (Medium)](https://leetcode.com/problems/permutations "全排列") @@ -29,10 +29,10 @@ ### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Next Permutation](https://github.com/openset/leetcode/tree/master/problems/next-permutation) (Medium) - 1. [Permutations II](https://github.com/openset/leetcode/tree/master/problems/permutations-ii) (Medium) - 1. [Permutation Sequence](https://github.com/openset/leetcode/tree/master/problems/permutation-sequence) (Medium) - 1. [Combinations](https://github.com/openset/leetcode/tree/master/problems/combinations) (Medium) + 1. [Next Permutation](../next-permutation) (Medium) + 1. [Permutations II](../permutations-ii) (Medium) + 1. [Permutation Sequence](../permutation-sequence) (Medium) + 1. [Combinations](../combinations) (Medium) diff --git a/problems/play-with-chips/README.md b/problems/play-with-chips/README.md index 1431404cd..7c45594d3 100644 --- a/problems/play-with-chips/README.md +++ b/problems/play-with-chips/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome-iii "Valid Palindrome III") +[< Previous](../valid-palindrome-iii "Valid Palindrome III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-arithmetic-subsequence-of-given-difference "Longest Arithmetic Subsequence of Given Difference") +[Next >](../longest-arithmetic-subsequence-of-given-difference "Longest Arithmetic Subsequence of Given Difference") ## [1217. Play with Chips (Easy)](https://leetcode.com/problems/play-with-chips "玩筹码") @@ -50,9 +50,9 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/plus-one-linked-list/README.md b/problems/plus-one-linked-list/README.md index c047895c2..63596dd4e 100644 --- a/problems/plus-one-linked-list/README.md +++ b/problems/plus-one-linked-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/largest-divisible-subset "Largest Divisible Subset") +[< Previous](../largest-divisible-subset "Largest Divisible Subset")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/range-addition "Range Addition") +[Next >](../range-addition "Range Addition") ## [369. Plus One Linked List (Medium)](https://leetcode.com/problems/plus-one-linked-list "给单链表加一") @@ -26,7 +26,7 @@ ### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Plus One](https://github.com/openset/leetcode/tree/master/problems/plus-one) (Easy) + 1. [Plus One](../plus-one) (Easy) diff --git a/problems/plus-one/README.md b/problems/plus-one/README.md index 173a1578e..1d9485ad7 100644 --- a/problems/plus-one/README.md +++ b/problems/plus-one/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-number "Valid Number") +[< Previous](../valid-number "Valid Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/add-binary "Add Binary") +[Next >](../add-binary "Add Binary") ## [66. Plus One (Easy)](https://leetcode.com/problems/plus-one "加一") @@ -34,10 +34,10 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Multiply Strings](https://github.com/openset/leetcode/tree/master/problems/multiply-strings) (Medium) - 1. [Add Binary](https://github.com/openset/leetcode/tree/master/problems/add-binary) (Easy) - 1. [Plus One Linked List](https://github.com/openset/leetcode/tree/master/problems/plus-one-linked-list) (Medium) - 1. [Add to Array-Form of Integer](https://github.com/openset/leetcode/tree/master/problems/add-to-array-form-of-integer) (Easy) + 1. [Multiply Strings](../multiply-strings) (Medium) + 1. [Add Binary](../add-binary) (Easy) + 1. [Plus One Linked List](../plus-one-linked-list) (Medium) + 1. [Add to Array-Form of Integer](../add-to-array-form-of-integer) (Easy) diff --git a/problems/poor-pigs/README.md b/problems/poor-pigs/README.md index a72ee4e6e..fd4ed9099 100644 --- a/problems/poor-pigs/README.md +++ b/problems/poor-pigs/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/circular-array-loop "Circular Array Loop") +[< Previous](../circular-array-loop "Circular Array Loop")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/repeated-substring-pattern "Repeated Substring Pattern") +[Next >](../repeated-substring-pattern "Repeated Substring Pattern") ## [458. Poor Pigs (Hard)](https://leetcode.com/problems/poor-pigs "可怜的小猪") @@ -32,7 +32,7 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/populating-next-right-pointers-in-each-node-ii/README.md b/problems/populating-next-right-pointers-in-each-node-ii/README.md index 4f3ba254b..fa85e4142 100644 --- a/problems/populating-next-right-pointers-in-each-node-ii/README.md +++ b/problems/populating-next-right-pointers-in-each-node-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/populating-next-right-pointers-in-each-node "Populating Next Right Pointers in Each Node") +[< Previous](../populating-next-right-pointers-in-each-node "Populating Next Right Pointers in Each Node")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/pascals-triangle "Pascal's Triangle") +[Next >](../pascals-triangle "Pascal's Triangle") ## [117. Populating Next Right Pointers in Each Node II (Medium)](https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii "填充每个节点的下一个右侧节点指针 II") @@ -55,8 +55,8 @@ struct Node { ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Populating Next Right Pointers in Each Node](https://github.com/openset/leetcode/tree/master/problems/populating-next-right-pointers-in-each-node) (Medium) + 1. [Populating Next Right Pointers in Each Node](../populating-next-right-pointers-in-each-node) (Medium) diff --git a/problems/populating-next-right-pointers-in-each-node/README.md b/problems/populating-next-right-pointers-in-each-node/README.md index 3609677d7..06b846950 100644 --- a/problems/populating-next-right-pointers-in-each-node/README.md +++ b/problems/populating-next-right-pointers-in-each-node/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/distinct-subsequences "Distinct Subsequences") +[< Previous](../distinct-subsequences "Distinct Subsequences")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/populating-next-right-pointers-in-each-node-ii "Populating Next Right Pointers in Each Node II") +[Next >](../populating-next-right-pointers-in-each-node-ii "Populating Next Right Pointers in Each Node II") ## [116. Populating Next Right Pointers in Each Node (Medium)](https://leetcode.com/problems/populating-next-right-pointers-in-each-node "填充每个节点的下一个右侧节点指针") @@ -55,9 +55,9 @@ struct Node { ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Populating Next Right Pointers in Each Node II](https://github.com/openset/leetcode/tree/master/problems/populating-next-right-pointers-in-each-node-ii) (Medium) - 1. [Binary Tree Right Side View](https://github.com/openset/leetcode/tree/master/problems/binary-tree-right-side-view) (Medium) + 1. [Populating Next Right Pointers in Each Node II](../populating-next-right-pointers-in-each-node-ii) (Medium) + 1. [Binary Tree Right Side View](../binary-tree-right-side-view) (Medium) diff --git a/problems/positions-of-large-groups/README.md b/problems/positions-of-large-groups/README.md index b36d002f7..29f7789c5 100644 --- a/problems/positions-of-large-groups/README.md +++ b/problems/positions-of-large-groups/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/consecutive-numbers-sum "Consecutive Numbers Sum") +[< Previous](../consecutive-numbers-sum "Consecutive Numbers Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/masking-personal-information "Masking Personal Information") +[Next >](../masking-personal-information "Masking Personal Information") ## [830. Positions of Large Groups (Easy)](https://leetcode.com/problems/positions-of-large-groups "较大分组的位置") @@ -48,4 +48,4 @@

Note:  1 <= S.length <= 1000

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/possible-bipartition/README.md b/problems/possible-bipartition/README.md index 760353ff2..55fbc1546 100644 --- a/problems/possible-bipartition/README.md +++ b/problems/possible-bipartition/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/spiral-matrix-iii "Spiral Matrix III") +[< Previous](../spiral-matrix-iii "Spiral Matrix III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/super-egg-drop "Super Egg Drop") +[Next >](../super-egg-drop "Super Egg Drop") ## [886. Possible Bipartition (Medium)](https://leetcode.com/problems/possible-bipartition "可能的二分法") @@ -69,4 +69,4 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/pour-water/README.md b/problems/pour-water/README.md index 63711c7bb..cf4184a63 100644 --- a/problems/pour-water/README.md +++ b/problems/pour-water/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reach-a-number "Reach a Number") +[< Previous](../reach-a-number "Reach a Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/pyramid-transition-matrix "Pyramid Transition Matrix") +[Next >](../pyramid-transition-matrix "Pyramid Transition Matrix") ## [755. Pour Water (Medium)](https://leetcode.com/problems/pour-water "倒水") @@ -136,7 +136,7 @@ The last droplet settles at index 1, since moving further left would not cause i

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Trapping Rain Water](https://github.com/openset/leetcode/tree/master/problems/trapping-rain-water) (Hard) + 1. [Trapping Rain Water](../trapping-rain-water) (Hard) diff --git a/problems/power-of-four/README.md b/problems/power-of-four/README.md index 9b345c1c9..5b577262f 100644 --- a/problems/power-of-four/README.md +++ b/problems/power-of-four/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/flatten-nested-list-iterator "Flatten Nested List Iterator") +[< Previous](../flatten-nested-list-iterator "Flatten Nested List Iterator")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/integer-break "Integer Break") +[Next >](../integer-break "Integer Break") ## [342. Power of Four (Easy)](https://leetcode.com/problems/power-of-four "4的幂") @@ -31,8 +31,8 @@

Follow up: Could you solve it without loops/recursion?

### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions - 1. [Power of Two](https://github.com/openset/leetcode/tree/master/problems/power-of-two) (Easy) - 1. [Power of Three](https://github.com/openset/leetcode/tree/master/problems/power-of-three) (Easy) + 1. [Power of Two](../power-of-two) (Easy) + 1. [Power of Three](../power-of-three) (Easy) diff --git a/problems/power-of-three/README.md b/problems/power-of-three/README.md index 1d12a691c..5e4d3b688 100644 --- a/problems/power-of-three/README.md +++ b/problems/power-of-three/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-size-subarray-sum-equals-k "Maximum Size Subarray Sum Equals k") +[< Previous](../maximum-size-subarray-sum-equals-k "Maximum Size Subarray Sum Equals k")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/count-of-range-sum "Count of Range Sum") +[Next >](../count-of-range-sum "Count of Range Sum") ## [326. Power of Three (Easy)](https://leetcode.com/problems/power-of-three "3的幂") @@ -42,8 +42,8 @@ Could you do it without using any loop / recursion?

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Power of Two](https://github.com/openset/leetcode/tree/master/problems/power-of-two) (Easy) - 1. [Power of Four](https://github.com/openset/leetcode/tree/master/problems/power-of-four) (Easy) + 1. [Power of Two](../power-of-two) (Easy) + 1. [Power of Four](../power-of-four) (Easy) diff --git a/problems/power-of-two/README.md b/problems/power-of-two/README.md index b25cb49c4..4c9067ae3 100644 --- a/problems/power-of-two/README.md +++ b/problems/power-of-two/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-element-in-a-bst "Kth Smallest Element in a BST") +[< Previous](../kth-smallest-element-in-a-bst "Kth Smallest Element in a BST")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/implement-queue-using-stacks "Implement Queue using Stacks") +[Next >](../implement-queue-using-stacks "Implement Queue using Stacks") ## [231. Power of Two (Easy)](https://leetcode.com/problems/power-of-two "2的幂") @@ -35,10 +35,10 @@ Output: false ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Number of 1 Bits](https://github.com/openset/leetcode/tree/master/problems/number-of-1-bits) (Easy) - 1. [Power of Three](https://github.com/openset/leetcode/tree/master/problems/power-of-three) (Easy) - 1. [Power of Four](https://github.com/openset/leetcode/tree/master/problems/power-of-four) (Easy) + 1. [Number of 1 Bits](../number-of-1-bits) (Easy) + 1. [Power of Three](../power-of-three) (Easy) + 1. [Power of Four](../power-of-four) (Easy) diff --git a/problems/powerful-integers/README.md b/problems/powerful-integers/README.md index 73a76c2a0..23a348d75 100644 --- a/problems/powerful-integers/README.md +++ b/problems/powerful-integers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/pancake-sorting "Pancake Sorting") +[< Previous](../pancake-sorting "Pancake Sorting")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/flip-binary-tree-to-match-preorder-traversal "Flip Binary Tree To Match Preorder Traversal") +[Next >](../flip-binary-tree-to-match-preorder-traversal "Flip Binary Tree To Match Preorder Traversal") ## [970. Powerful Integers (Easy)](https://leetcode.com/problems/powerful-integers "强整数") @@ -56,5 +56,5 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/powx-n/README.md b/problems/powx-n/README.md index ce4e532e6..d3c41f6ff 100644 --- a/problems/powx-n/README.md +++ b/problems/powx-n/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/group-anagrams "Group Anagrams") +[< Previous](../group-anagrams "Group Anagrams")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/n-queens "N-Queens") +[Next >](../n-queens "N-Queens") ## [50. Pow(x, n) (Medium)](https://leetcode.com/problems/powx-n "Pow(x, n)") @@ -43,9 +43,9 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Sqrt(x)](https://github.com/openset/leetcode/tree/master/problems/sqrtx) (Easy) - 1. [Super Pow](https://github.com/openset/leetcode/tree/master/problems/super-pow) (Medium) + 1. [Sqrt(x)](../sqrtx) (Easy) + 1. [Super Pow](../super-pow) (Medium) diff --git a/problems/predict-the-winner/README.md b/problems/predict-the-winner/README.md index db3326063..af29a033d 100644 --- a/problems/predict-the-winner/README.md +++ b/problems/predict-the-winner/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones "Max Consecutive Ones") +[< Previous](../max-consecutive-ones "Max Consecutive Ones")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones-ii "Max Consecutive Ones II") +[Next >](../max-consecutive-ones-ii "Max Consecutive Ones II") ## [486. Predict the Winner (Medium)](https://leetcode.com/problems/predict-the-winner "预测赢家") @@ -40,8 +40,8 @@

### Related Topics - [[Minimax](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Minimax](../../tag/minimax/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Can I Win](https://github.com/openset/leetcode/tree/master/problems/can-i-win) (Medium) + 1. [Can I Win](../can-i-win) (Medium) diff --git a/problems/prefix-and-suffix-search/README.md b/problems/prefix-and-suffix-search/README.md index 7d38cfaae..f7fb85160 100644 --- a/problems/prefix-and-suffix-search/README.md +++ b/problems/prefix-and-suffix-search/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-smallest-letter-greater-than-target "Find Smallest Letter Greater Than Target") +[< Previous](../find-smallest-letter-greater-than-target "Find Smallest Letter Greater Than Target")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/min-cost-climbing-stairs "Min Cost Climbing Stairs") +[Next >](../min-cost-climbing-stairs "Min Cost Climbing Stairs") ## [745. Prefix and Suffix Search (Hard)](https://leetcode.com/problems/prefix-and-suffix-search "前缀和后缀搜索") @@ -39,10 +39,10 @@ WordFilter.f("b", "") // returns -1

 

### Related Topics - [[Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] + [[Trie](../../tag/trie/README.md)] ### Similar Questions - 1. [Add and Search Word - Data structure design](https://github.com/openset/leetcode/tree/master/problems/add-and-search-word-data-structure-design) (Medium) + 1. [Add and Search Word - Data structure design](../add-and-search-word-data-structure-design) (Medium) ### Hints
diff --git a/problems/preimage-size-of-factorial-zeroes-function/README.md b/problems/preimage-size-of-factorial-zeroes-function/README.md index 18caa7eaf..782d598d5 100644 --- a/problems/preimage-size-of-factorial-zeroes-function/README.md +++ b/problems/preimage-size-of-factorial-zeroes-function/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-matching-subsequences "Number of Matching Subsequences") +[< Previous](../number-of-matching-subsequences "Number of Matching Subsequences")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-tic-tac-toe-state "Valid Tic-Tac-Toe State") +[Next >](../valid-tic-tac-toe-state "Valid Tic-Tac-Toe State") ## [793. Preimage Size of Factorial Zeroes Function (Hard)](https://leetcode.com/problems/preimage-size-of-factorial-zeroes-function "阶乘函数后K个零") @@ -34,7 +34,7 @@ ### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Factorial Trailing Zeroes](https://github.com/openset/leetcode/tree/master/problems/factorial-trailing-zeroes) (Easy) + 1. [Factorial Trailing Zeroes](../factorial-trailing-zeroes) (Easy) diff --git a/problems/previous-permutation-with-one-swap/README.md b/problems/previous-permutation-with-one-swap/README.md index 83e650de7..dffedec5a 100644 --- a/problems/previous-permutation-with-one-swap/README.md +++ b/problems/previous-permutation-with-one-swap/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/grumpy-bookstore-owner "Grumpy Bookstore Owner") +[< Previous](../grumpy-bookstore-owner "Grumpy Bookstore Owner")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/distant-barcodes "Distant Barcodes") +[Next >](../distant-barcodes "Distant Barcodes") ## [1053. Previous Permutation With One Swap (Medium)](https://leetcode.com/problems/previous-permutation-with-one-swap "交换一次的先前排列") @@ -57,8 +57,8 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/prime-arrangements/README.md b/problems/prime-arrangements/README.md index 7eb23ed01..b85fa61f2 100644 --- a/problems/prime-arrangements/README.md +++ b/problems/prime-arrangements/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/immediate-food-delivery-ii "Immediate Food Delivery II") +[< Previous](../immediate-food-delivery-ii "Immediate Food Delivery II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/diet-plan-performance "Diet Plan Performance") +[Next >](../diet-plan-performance "Diet Plan Performance") ## [1175. Prime Arrangements (Easy)](https://leetcode.com/problems/prime-arrangements "质数排列") @@ -41,7 +41,7 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/prime-number-of-set-bits-in-binary-representation/README.md b/problems/prime-number-of-set-bits-in-binary-representation/README.md index c0eed9934..6baa890be 100644 --- a/problems/prime-number-of-set-bits-in-binary-representation/README.md +++ b/problems/prime-number-of-set-bits-in-binary-representation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/special-binary-string "Special Binary String") +[< Previous](../special-binary-string "Special Binary String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/partition-labels "Partition Labels") +[Next >](../partition-labels "Partition Labels") ## [762. Prime Number of Set Bits in Binary Representation (Easy)](https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation "二进制表示中质数个计算置位") @@ -45,10 +45,10 @@ Given two integers L and R, find the count of numbers

### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions - 1. [Number of 1 Bits](https://github.com/openset/leetcode/tree/master/problems/number-of-1-bits) (Easy) + 1. [Number of 1 Bits](../number-of-1-bits) (Easy) ### Hints
diff --git a/problems/prime-palindrome/README.md b/problems/prime-palindrome/README.md index 8a0c4f7d2..a5b7dfaa6 100644 --- a/problems/prime-palindrome/README.md +++ b/problems/prime-palindrome/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/smallest-subtree-with-all-the-deepest-nodes "Smallest Subtree with all the Deepest Nodes") +[< Previous](../smallest-subtree-with-all-the-deepest-nodes "Smallest Subtree with all the Deepest Nodes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/transpose-matrix "Transpose Matrix") +[Next >](../transpose-matrix "Transpose Matrix") ## [866. Prime Palindrome (Medium)](https://leetcode.com/problems/prime-palindrome "回文素数") @@ -59,4 +59,4 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/print-binary-tree/README.md b/problems/print-binary-tree/README.md index 2ed2a19f9..c313e3106 100644 --- a/problems/print-binary-tree/README.md +++ b/problems/print-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-binary-tree "Maximum Binary Tree") +[< Previous](../maximum-binary-tree "Maximum Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/coin-path "Coin Path") +[Next >](../coin-path "Coin Path") ## [655. Print Binary Tree (Medium)](https://leetcode.com/problems/print-binary-tree "输出二叉树") @@ -73,4 +73,4 @@ The height of binary tree is in the range of [1, 10].

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] diff --git a/problems/print-foobar-alternately/README.md b/problems/print-foobar-alternately/README.md index b447009b1..04d558ad2 100644 --- a/problems/print-foobar-alternately/README.md +++ b/problems/print-foobar-alternately/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/print-in-order "Print in Order") +[< Previous](../print-in-order "Print in Order")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/print-zero-even-odd "Print Zero Even Odd") +[Next >](../print-zero-even-odd "Print Zero Even Odd") ## [1115. Print FooBar Alternately (Medium)](https://leetcode.com/problems/print-foobar-alternately "交替打印FooBar") @@ -50,5 +50,5 @@ class FooBar { ### Similar Questions - 1. [Print in Order](https://github.com/openset/leetcode/tree/master/problems/print-in-order) (Easy) - 1. [Print Zero Even Odd](https://github.com/openset/leetcode/tree/master/problems/print-zero-even-odd) (Medium) + 1. [Print in Order](../print-in-order) (Easy) + 1. [Print Zero Even Odd](../print-zero-even-odd) (Medium) diff --git a/problems/print-immutable-linked-list-in-reverse/README.md b/problems/print-immutable-linked-list-in-reverse/README.md index ebf90bce2..61bb8638d 100644 --- a/problems/print-immutable-linked-list-in-reverse/README.md +++ b/problems/print-immutable-linked-list-in-reverse/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/page-recommendations "Page Recommendations") +[< Previous](../page-recommendations "Page Recommendations")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-time-visiting-all-points "Minimum Time Visiting All Points") +[Next >](../minimum-time-visiting-all-points "Minimum Time Visiting All Points") ## [1265. Print Immutable Linked List in Reverse (Medium)](https://leetcode.com/problems/print-immutable-linked-list-in-reverse "") diff --git a/problems/print-in-order/README.md b/problems/print-in-order/README.md index fa6fc8612..ee1d4c7e1 100644 --- a/problems/print-in-order/README.md +++ b/problems/print-in-order/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reported-posts "Reported Posts") +[< Previous](../reported-posts "Reported Posts")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/print-foobar-alternately "Print FooBar Alternately") +[Next >](../print-foobar-alternately "Print FooBar Alternately") ## [1114. Print in Order (Easy)](https://leetcode.com/problems/print-in-order "按序打印") @@ -47,4 +47,4 @@ public class Foo {

We do not know how the threads will be scheduled in the operating system, even though the numbers in the input seems to imply the ordering. The input format you see is mainly to ensure our tests' comprehensiveness.

### Similar Questions - 1. [Print FooBar Alternately](https://github.com/openset/leetcode/tree/master/problems/print-foobar-alternately) (Medium) + 1. [Print FooBar Alternately](../print-foobar-alternately) (Medium) diff --git a/problems/print-zero-even-odd/README.md b/problems/print-zero-even-odd/README.md index 9654abf57..7ab4b9e8b 100644 --- a/problems/print-zero-even-odd/README.md +++ b/problems/print-zero-even-odd/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/print-foobar-alternately "Print FooBar Alternately") +[< Previous](../print-foobar-alternately "Print FooBar Alternately")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/building-h2o "Building H2O") +[Next >](../building-h2o "Building H2O") ## [1116. Print Zero Even Odd (Medium)](https://leetcode.com/problems/print-zero-even-odd "打印零与奇偶数") @@ -50,4 +50,4 @@ class ZeroEvenOdd { ### Similar Questions - 1. [Print FooBar Alternately](https://github.com/openset/leetcode/tree/master/problems/print-foobar-alternately) (Medium) + 1. [Print FooBar Alternately](../print-foobar-alternately) (Medium) diff --git a/problems/prison-cells-after-n-days/README.md b/problems/prison-cells-after-n-days/README.md index 9202cde3a..e11dfd15f 100644 --- a/problems/prison-cells-after-n-days/README.md +++ b/problems/prison-cells-after-n-days/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/tallest-billboard "Tallest Billboard") +[< Previous](../tallest-billboard "Tallest Billboard")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/check-completeness-of-a-binary-tree "Check Completeness of a Binary Tree") +[Next >](../check-completeness-of-a-binary-tree "Check Completeness of a Binary Tree") ## [957. Prison Cells After N Days (Medium)](https://leetcode.com/problems/prison-cells-after-n-days "N 天后的牢房") @@ -73,4 +73,4 @@ Day 7: [0, 0, 1, 1, 0, 0, 0, 0] ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/product-of-array-except-self/README.md b/problems/product-of-array-except-self/README.md index b4a11bf7a..bdf68599c 100644 --- a/problems/product-of-array-except-self/README.md +++ b/problems/product-of-array-except-self/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/delete-node-in-a-linked-list "Delete Node in a Linked List") +[< Previous](../delete-node-in-a-linked-list "Delete Node in a Linked List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sliding-window-maximum "Sliding Window Maximum") +[Next >](../sliding-window-maximum "Sliding Window Maximum") ## [238. Product of Array Except Self (Medium)](https://leetcode.com/problems/product-of-array-except-self "除自身以外数组的乘积") @@ -26,9 +26,9 @@ Could you solve it with constant space complexity? (The output array does not count as extra space for the purpose of space complexity analysis.)

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Trapping Rain Water](https://github.com/openset/leetcode/tree/master/problems/trapping-rain-water) (Hard) - 1. [Maximum Product Subarray](https://github.com/openset/leetcode/tree/master/problems/maximum-product-subarray) (Medium) - 1. [Paint House II](https://github.com/openset/leetcode/tree/master/problems/paint-house-ii) (Hard) + 1. [Trapping Rain Water](../trapping-rain-water) (Hard) + 1. [Maximum Product Subarray](../maximum-product-subarray) (Medium) + 1. [Paint House II](../paint-house-ii) (Hard) diff --git a/problems/product-price-at-a-given-date/README.md b/problems/product-price-at-a-given-date/README.md index 2477fd617..e03c4c84c 100644 --- a/problems/product-price-at-a-given-date/README.md +++ b/problems/product-price-at-a-given-date/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/last-substring-in-lexicographical-order "Last Substring in Lexicographical Order") +[< Previous](../last-substring-in-lexicographical-order "Last Substring in Lexicographical Order")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/single-row-keyboard "Single-Row Keyboard") +[Next >](../single-row-keyboard "Single-Row Keyboard") ## [1164. Product Price at a Given Date (Medium)](https://leetcode.com/problems/product-price-at-a-given-date "") diff --git a/problems/product-sales-analysis-i/README.md b/problems/product-sales-analysis-i/README.md index 08fdc81f7..791ae7179 100644 --- a/problems/product-sales-analysis-i/README.md +++ b/problems/product-sales-analysis-i/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/digit-count-in-range "Digit Count in Range") +[< Previous](../digit-count-in-range "Digit Count in Range")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-ii "Product Sales Analysis II") +[Next >](../product-sales-analysis-ii "Product Sales Analysis II") ## [1068. Product Sales Analysis I (Easy)](https://leetcode.com/problems/product-sales-analysis-i "产品销售分析 I") diff --git a/problems/product-sales-analysis-ii/README.md b/problems/product-sales-analysis-ii/README.md index 08c193352..e0c5912a7 100644 --- a/problems/product-sales-analysis-ii/README.md +++ b/problems/product-sales-analysis-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-i "Product Sales Analysis I") +[< Previous](../product-sales-analysis-i "Product Sales Analysis I")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-iii "Product Sales Analysis III") +[Next >](../product-sales-analysis-iii "Product Sales Analysis III") ## [1069. Product Sales Analysis II (Easy)](https://leetcode.com/problems/product-sales-analysis-ii "产品销售分析 II") diff --git a/problems/product-sales-analysis-iii/README.md b/problems/product-sales-analysis-iii/README.md index 8ac139c1d..611a1157b 100644 --- a/problems/product-sales-analysis-iii/README.md +++ b/problems/product-sales-analysis-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-ii "Product Sales Analysis II") +[< Previous](../product-sales-analysis-ii "Product Sales Analysis II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/greatest-common-divisor-of-strings "Greatest Common Divisor of Strings") +[Next >](../greatest-common-divisor-of-strings "Greatest Common Divisor of Strings") ## [1070. Product Sales Analysis III (Medium)](https://leetcode.com/problems/product-sales-analysis-iii "产品销售分析 III") diff --git a/problems/profitable-schemes/README.md b/problems/profitable-schemes/README.md index 03e35b4b2..91e524a43 100644 --- a/problems/profitable-schemes/README.md +++ b/problems/profitable-schemes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/nth-magical-number "Nth Magical Number") +[< Previous](../nth-magical-number "Nth Magical Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/decoded-string-at-index "Decoded String at Index") +[Next >](../decoded-string-at-index "Decoded String at Index") ## [879. Profitable Schemes (Hard)](https://leetcode.com/problems/profitable-schemes "盈利计划") @@ -62,4 +62,4 @@ There are 7 possible schemes: (0), (1), (2), (0,1), (0,2), (1,2), and (0,1,2). ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/project-employees-i/README.md b/problems/project-employees-i/README.md index 3b3c50553..ddd837561 100644 --- a/problems/project-employees-i/README.md +++ b/problems/project-employees-i/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-submatrices-that-sum-to-target "Number of Submatrices That Sum to Target") +[< Previous](../number-of-submatrices-that-sum-to-target "Number of Submatrices That Sum to Target")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/project-employees-ii "Project Employees II") +[Next >](../project-employees-ii "Project Employees II") ## [1075. Project Employees I (Easy)](https://leetcode.com/problems/project-employees-i "项目员工 I") diff --git a/problems/project-employees-ii/README.md b/problems/project-employees-ii/README.md index d0c16a00d..d8f033adc 100644 --- a/problems/project-employees-ii/README.md +++ b/problems/project-employees-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/project-employees-i "Project Employees I") +[< Previous](../project-employees-i "Project Employees I")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/project-employees-iii "Project Employees III") +[Next >](../project-employees-iii "Project Employees III") ## [1076. Project Employees II (Easy)](https://leetcode.com/problems/project-employees-ii "项目员工II") diff --git a/problems/project-employees-iii/README.md b/problems/project-employees-iii/README.md index 675abc7d6..7e6f0c7bd 100644 --- a/problems/project-employees-iii/README.md +++ b/problems/project-employees-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/project-employees-ii "Project Employees II") +[< Previous](../project-employees-ii "Project Employees II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/occurrences-after-bigram "Occurrences After Bigram") +[Next >](../occurrences-after-bigram "Occurrences After Bigram") ## [1077. Project Employees III (Medium)](https://leetcode.com/problems/project-employees-iii "项目员工 III") diff --git a/problems/projection-area-of-3d-shapes/README.md b/problems/projection-area-of-3d-shapes/README.md index 491b51041..4b9df535e 100644 --- a/problems/projection-area-of-3d-shapes/README.md +++ b/problems/projection-area-of-3d-shapes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reachable-nodes-in-subdivided-graph "Reachable Nodes In Subdivided Graph") +[< Previous](../reachable-nodes-in-subdivided-graph "Reachable Nodes In Subdivided Graph")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/uncommon-words-from-two-sentences "Uncommon Words from Two Sentences") +[Next >](../uncommon-words-from-two-sentences "Uncommon Words from Two Sentences") ## [883. Projection Area of 3D Shapes (Easy)](https://leetcode.com/problems/projection-area-of-3d-shapes "三维形体投影面积") @@ -131,4 +131,4 @@ Here are the three projections ("shadows") of the shape made with each ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/push-dominoes/README.md b/problems/push-dominoes/README.md index f065ddbb1..b846d55ec 100644 --- a/problems/push-dominoes/README.md +++ b/problems/push-dominoes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/new-21-game "New 21 Game") +[< Previous](../new-21-game "New 21 Game")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/similar-string-groups "Similar String Groups") +[Next >](../similar-string-groups "Similar String Groups") ## [838. Push Dominoes (Medium)](https://leetcode.com/problems/push-dominoes "推多米诺") @@ -52,5 +52,5 @@ ### Related Topics - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/pyramid-transition-matrix/README.md b/problems/pyramid-transition-matrix/README.md index d7dc3cc24..4cdb08326 100644 --- a/problems/pyramid-transition-matrix/README.md +++ b/problems/pyramid-transition-matrix/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/pour-water "Pour Water") +[< Previous](../pour-water "Pour Water")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/set-intersection-size-at-least-two "Set Intersection Size At Least Two") +[Next >](../set-intersection-size-at-least-two "Set Intersection Size At Least Two") ## [756. Pyramid Transition Matrix (Medium)](https://leetcode.com/problems/pyramid-transition-matrix "金字塔转换矩阵") @@ -59,5 +59,5 @@ Note that there could be allowed triples (A, B, C) and (A, B, D) with C != D.

 

### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/quad-tree-intersection/README.md b/problems/quad-tree-intersection/README.md index 66d41f9e3..8eca3810f 100644 --- a/problems/quad-tree-intersection/README.md +++ b/problems/quad-tree-intersection/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reverse-words-in-a-string-iii "Reverse Words in a String III") +[< Previous](../reverse-words-in-a-string-iii "Reverse Words in a String III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-depth-of-n-ary-tree "Maximum Depth of N-ary Tree") +[Next >](../maximum-depth-of-n-ary-tree "Maximum Depth of N-ary Tree") ## [558. Quad Tree Intersection (Easy)](https://leetcode.com/problems/quad-tree-intersection "四叉树交集") diff --git a/problems/queens-that-can-attack-the-king/README.md b/problems/queens-that-can-attack-the-king/README.md index a69d5e1a3..53edb6653 100644 --- a/problems/queens-that-can-attack-the-king/README.md +++ b/problems/queens-that-can-attack-the-king/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/split-a-string-in-balanced-strings "Split a String in Balanced Strings") +[< Previous](../split-a-string-in-balanced-strings "Split a String in Balanced Strings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/dice-roll-simulation "Dice Roll Simulation") +[Next >](../dice-roll-simulation "Dice Roll Simulation") ## [1222. Queens That Can Attack the King (Medium)](https://leetcode.com/problems/queens-that-can-attack-the-king "可以攻击国王的皇后") @@ -63,7 +63,7 @@ The queen at [2,4] can't attack the king cause it's not in the same row/ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/queries-quality-and-percentage/README.md b/problems/queries-quality-and-percentage/README.md index bc31ace35..508c9449b 100644 --- a/problems/queries-quality-and-percentage/README.md +++ b/problems/queries-quality-and-percentage/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-reach-target-with-rotations "Minimum Moves to Reach Target with Rotations") +[< Previous](../minimum-moves-to-reach-target-with-rotations "Minimum Moves to Reach Target with Rotations")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/team-scores-in-football-tournament "Team Scores in Football Tournament") +[Next >](../team-scores-in-football-tournament "Team Scores in Football Tournament") ## [1211. Queries Quality and Percentage (Easy)](https://leetcode.com/problems/queries-quality-and-percentage "") diff --git a/problems/queue-reconstruction-by-height/README.md b/problems/queue-reconstruction-by-height/README.md index c8ac990e3..01a24bfa6 100644 --- a/problems/queue-reconstruction-by-height/README.md +++ b/problems/queue-reconstruction-by-height/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/convert-a-number-to-hexadecimal "Convert a Number to Hexadecimal") +[< Previous](../convert-a-number-to-hexadecimal "Convert a Number to Hexadecimal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/trapping-rain-water-ii "Trapping Rain Water II") +[Next >](../trapping-rain-water-ii "Trapping Rain Water II") ## [406. Queue Reconstruction by Height (Medium)](https://leetcode.com/problems/queue-reconstruction-by-height "根据身高重建队列") @@ -30,10 +30,10 @@ Output:

 

### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions - 1. [Count of Smaller Numbers After Self](https://github.com/openset/leetcode/tree/master/problems/count-of-smaller-numbers-after-self) (Hard) + 1. [Count of Smaller Numbers After Self](../count-of-smaller-numbers-after-self) (Hard) ### Hints
diff --git a/problems/rabbits-in-forest/README.md b/problems/rabbits-in-forest/README.md index 22639b128..1f8153873 100644 --- a/problems/rabbits-in-forest/README.md +++ b/problems/rabbits-in-forest/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reaching-points "Reaching Points") +[< Previous](../reaching-points "Reaching Points")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/transform-to-chessboard "Transform to Chessboard") +[Next >](../transform-to-chessboard "Transform to Chessboard") ## [781. Rabbits in Forest (Medium)](https://leetcode.com/problems/rabbits-in-forest "森林中的兔子") @@ -41,5 +41,5 @@ The smallest possible number of rabbits in the forest is therefore 5: 3 that ans ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/race-car/README.md b/problems/race-car/README.md index f2a79fc81..036b3d397 100644 --- a/problems/race-car/README.md +++ b/problems/race-car/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/linked-list-components "Linked List Components") +[< Previous](../linked-list-components "Linked List Components")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/most-common-word "Most Common Word") +[Next >](../most-common-word "Most Common Word") ## [818. Race Car (Hard)](https://leetcode.com/problems/race-car "赛车") @@ -52,5 +52,5 @@ Your position goes from 0->1->3->7->7->6. ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/random-flip-matrix/README.md b/problems/random-flip-matrix/README.md index a72b17742..7ab9fdd9b 100644 --- a/problems/random-flip-matrix/README.md +++ b/problems/random-flip-matrix/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/coin-change-2 "Coin Change 2") +[< Previous](../coin-change-2 "Coin Change 2")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/detect-capital "Detect Capital") +[Next >](../detect-capital "Detect Capital") ## [519. Random Flip Matrix (Medium)](https://leetcode.com/problems/random-flip-matrix "随机翻转矩阵") @@ -46,4 +46,4 @@

The input is two lists: the subroutines called and their arguments. Solution's constructor has two arguments, n_rows and n_colsflip and reset have no arguments. Arguments are always wrapped with a list, even if there aren't any.

### Related Topics - [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] + [[Random](../../tag/random/README.md)] diff --git a/problems/random-pick-index/README.md b/problems/random-pick-index/README.md index 071d06f1f..377cef862 100644 --- a/problems/random-pick-index/README.md +++ b/problems/random-pick-index/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/integer-replacement "Integer Replacement") +[< Previous](../integer-replacement "Integer Replacement")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/evaluate-division "Evaluate Division") +[Next >](../evaluate-division "Evaluate Division") ## [398. Random Pick Index (Medium)](https://leetcode.com/problems/random-pick-index "随机数索引") @@ -30,9 +30,9 @@ solution.pick(1); ### Related Topics - [[Reservoir Sampling](https://github.com/openset/leetcode/tree/master/tag/reservoir-sampling/README.md)] + [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] ### Similar Questions - 1. [Linked List Random Node](https://github.com/openset/leetcode/tree/master/problems/linked-list-random-node) (Medium) - 1. [Random Pick with Blacklist](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-blacklist) (Hard) - 1. [Random Pick with Weight](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-weight) (Medium) + 1. [Linked List Random Node](../linked-list-random-node) (Medium) + 1. [Random Pick with Blacklist](../random-pick-with-blacklist) (Hard) + 1. [Random Pick with Weight](../random-pick-with-weight) (Medium) diff --git a/problems/random-pick-with-blacklist/README.md b/problems/random-pick-with-blacklist/README.md index 3e58fc9f6..f1bbf992c 100644 --- a/problems/random-pick-with-blacklist/README.md +++ b/problems/random-pick-with-blacklist/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/to-lower-case "To Lower Case") +[< Previous](../to-lower-case "To Lower Case")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-distinct-islands-ii "Number of Distinct Islands II") +[Next >](../number-of-distinct-islands-ii "Number of Distinct Islands II") ## [710. Random Pick with Blacklist (Hard)](https://leetcode.com/problems/random-pick-with-blacklist "黑名单中的随机数") @@ -64,11 +64,11 @@

The input is two lists: the subroutines called and their arguments. Solution's constructor has two arguments, N and the blacklist B. pick has no arguments. Arguments are always wrapped with a list, even if there aren't any.

### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] - [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Random](../../tag/random/README.md)] ### Similar Questions - 1. [Random Pick Index](https://github.com/openset/leetcode/tree/master/problems/random-pick-index) (Medium) - 1. [Random Pick with Weight](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-weight) (Medium) + 1. [Random Pick Index](../random-pick-index) (Medium) + 1. [Random Pick with Weight](../random-pick-with-weight) (Medium) diff --git a/problems/random-pick-with-weight/README.md b/problems/random-pick-with-weight/README.md index bd51b9db2..0c9c0a786 100644 --- a/problems/random-pick-with-weight/README.md +++ b/problems/random-pick-with-weight/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/word-abbreviation "Word Abbreviation") +[< Previous](../word-abbreviation "Word Abbreviation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minesweeper "Minesweeper") +[Next >](../minesweeper "Minesweeper") ## [528. Random Pick with Weight (Medium)](https://leetcode.com/problems/random-pick-with-weight "按权重随机选择") @@ -45,10 +45,10 @@

The input is two lists: the subroutines called and their arguments. Solution's constructor has one argument, the array w. pickIndex has no arguments. Arguments are always wrapped with a list, even if there aren't any.

### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] - [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Random](../../tag/random/README.md)] ### Similar Questions - 1. [Random Pick Index](https://github.com/openset/leetcode/tree/master/problems/random-pick-index) (Medium) - 1. [Random Pick with Blacklist](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-blacklist) (Hard) - 1. [Random Point in Non-overlapping Rectangles](https://github.com/openset/leetcode/tree/master/problems/random-point-in-non-overlapping-rectangles) (Medium) + 1. [Random Pick Index](../random-pick-index) (Medium) + 1. [Random Pick with Blacklist](../random-pick-with-blacklist) (Hard) + 1. [Random Point in Non-overlapping Rectangles](../random-point-in-non-overlapping-rectangles) (Medium) diff --git a/problems/random-point-in-non-overlapping-rectangles/README.md b/problems/random-point-in-non-overlapping-rectangles/README.md index 2beed348c..9631b5baa 100644 --- a/problems/random-point-in-non-overlapping-rectangles/README.md +++ b/problems/random-point-in-non-overlapping-rectangles/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-i "Next Greater Element I") +[< Previous](../next-greater-element-i "Next Greater Element I")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/diagonal-traverse "Diagonal Traverse") +[Next >](../diagonal-traverse "Diagonal Traverse") ## [497. Random Point in Non-overlapping Rectangles (Medium)](https://leetcode.com/problems/random-point-in-non-overlapping-rectangles "非重叠矩形中的随机点") @@ -59,9 +59,9 @@ ### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] - [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Random](../../tag/random/README.md)] ### Similar Questions - 1. [Random Pick with Weight](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-weight) (Medium) - 1. [Generate Random Point in a Circle](https://github.com/openset/leetcode/tree/master/problems/generate-random-point-in-a-circle) (Medium) + 1. [Random Pick with Weight](../random-pick-with-weight) (Medium) + 1. [Generate Random Point in a Circle](../generate-random-point-in-a-circle) (Medium) diff --git a/problems/range-addition-ii/README.md b/problems/range-addition-ii/README.md index 8b233264b..50752f199 100644 --- a/problems/range-addition-ii/README.md +++ b/problems/range-addition-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/friend-requests-i-overall-acceptance-rate "Friend Requests I: Overall Acceptance Rate") +[< Previous](../friend-requests-i-overall-acceptance-rate "Friend Requests I: Overall Acceptance Rate")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-index-sum-of-two-lists "Minimum Index Sum of Two Lists") +[Next >](../minimum-index-sum-of-two-lists "Minimum Index Sum of Two Lists") ## [598. Range Addition II (Easy)](https://leetcode.com/problems/range-addition-ii "范围求和 II") @@ -50,7 +50,7 @@ So the maximum integer in M is 2, and there are four of it in M. So return 4.

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Range Addition](https://github.com/openset/leetcode/tree/master/problems/range-addition) (Medium) + 1. [Range Addition](../range-addition) (Medium) diff --git a/problems/range-addition/README.md b/problems/range-addition/README.md index 70d781b5c..f15faa682 100644 --- a/problems/range-addition/README.md +++ b/problems/range-addition/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/plus-one-linked-list "Plus One Linked List") +[< Previous](../plus-one-linked-list "Plus One Linked List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sum-of-two-integers "Sum of Two Integers") +[Next >](../sum-of-two-integers "Sum of Two Integers") ## [370. Range Addition (Medium)](https://leetcode.com/problems/range-addition "区间加法") @@ -41,10 +41,10 @@ After applying operation [0,2,-2]: ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Range Addition II](https://github.com/openset/leetcode/tree/master/problems/range-addition-ii) (Easy) + 1. [Range Addition II](../range-addition-ii) (Easy) ### Hints
diff --git a/problems/range-module/README.md b/problems/range-module/README.md index e84f60fb3..53f405c50 100644 --- a/problems/range-module/README.md +++ b/problems/range-module/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-with-transaction-fee "Best Time to Buy and Sell Stock with Transaction Fee") +[< Previous](../best-time-to-buy-and-sell-stock-with-transaction-fee "Best Time to Buy and Sell Stock with Transaction Fee")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/max-stack "Max Stack") +[Next >](../max-stack "Max Stack") ## [715. Range Module (Hard)](https://leetcode.com/problems/range-module "Range 模块") @@ -40,13 +40,13 @@

### Related Topics - [[Segment Tree](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] - [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Ordered Map](../../tag/ordered-map/README.md)] ### Similar Questions - 1. [Merge Intervals](https://github.com/openset/leetcode/tree/master/problems/merge-intervals) (Medium) - 1. [Insert Interval](https://github.com/openset/leetcode/tree/master/problems/insert-interval) (Hard) - 1. [Data Stream as Disjoint Intervals](https://github.com/openset/leetcode/tree/master/problems/data-stream-as-disjoint-intervals) (Hard) + 1. [Merge Intervals](../merge-intervals) (Medium) + 1. [Insert Interval](../insert-interval) (Hard) + 1. [Data Stream as Disjoint Intervals](../data-stream-as-disjoint-intervals) (Hard) ### Hints
diff --git a/problems/range-sum-of-bst/README.md b/problems/range-sum-of-bst/README.md index 356f00373..118d72922 100644 --- a/problems/range-sum-of-bst/README.md +++ b/problems/range-sum-of-bst/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reorder-data-in-log-files "Reorder Data in Log Files") +[< Previous](../reorder-data-in-log-files "Reorder Data in Log Files")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-area-rectangle "Minimum Area Rectangle") +[Next >](../minimum-area-rectangle "Minimum Area Rectangle") ## [938. Range Sum of BST (Easy)](https://leetcode.com/problems/range-sum-of-bst "二叉搜索树的范围和") @@ -45,5 +45,5 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Recursion](../../tag/recursion/README.md)] diff --git a/problems/range-sum-query-2d-immutable/README.md b/problems/range-sum-query-2d-immutable/README.md index 58ef930c4..0798fa03e 100644 --- a/problems/range-sum-query-2d-immutable/README.md +++ b/problems/range-sum-query-2d-immutable/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-immutable "Range Sum Query - Immutable") +[< Previous](../range-sum-query-immutable "Range Sum Query - Immutable")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-islands-ii "Number of Islands II") +[Next >](../number-of-islands-ii "Number of Islands II") ## [304. Range Sum Query 2D - Immutable (Medium)](https://leetcode.com/problems/range-sum-query-2d-immutable "二维区域和检索 - 矩阵不可变") @@ -43,8 +43,8 @@ sumRegion(1, 2, 2, 4) -> 12

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Range Sum Query - Immutable](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-immutable) (Easy) - 1. [Range Sum Query 2D - Mutable](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-2d-mutable) (Hard) + 1. [Range Sum Query - Immutable](../range-sum-query-immutable) (Easy) + 1. [Range Sum Query 2D - Mutable](../range-sum-query-2d-mutable) (Hard) diff --git a/problems/range-sum-query-2d-mutable/README.md b/problems/range-sum-query-2d-mutable/README.md index 57e92fd07..d52fb6950 100644 --- a/problems/range-sum-query-2d-mutable/README.md +++ b/problems/range-sum-query-2d-mutable/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-mutable "Range Sum Query - Mutable") +[< Previous](../range-sum-query-mutable "Range Sum Query - Mutable")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-with-cooldown "Best Time to Buy and Sell Stock with Cooldown") +[Next >](../best-time-to-buy-and-sell-stock-with-cooldown "Best Time to Buy and Sell Stock with Cooldown") ## [308. Range Sum Query 2D - Mutable (Hard)](https://leetcode.com/problems/range-sum-query-2d-mutable "二维区域和检索 - 可变") @@ -43,9 +43,9 @@ sumRegion(2, 1, 4, 3) -> 10

### Related Topics - [[Binary Indexed Tree](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] - [[Segment Tree](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] ### Similar Questions - 1. [Range Sum Query 2D - Immutable](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-2d-immutable) (Medium) - 1. [Range Sum Query - Mutable](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-mutable) (Medium) + 1. [Range Sum Query 2D - Immutable](../range-sum-query-2d-immutable) (Medium) + 1. [Range Sum Query - Mutable](../range-sum-query-mutable) (Medium) diff --git a/problems/range-sum-query-immutable/README.md b/problems/range-sum-query-immutable/README.md index fc3a0444e..e1baedfd5 100644 --- a/problems/range-sum-query-immutable/README.md +++ b/problems/range-sum-query-immutable/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/smallest-rectangle-enclosing-black-pixels "Smallest Rectangle Enclosing Black Pixels") +[< Previous](../smallest-rectangle-enclosing-black-pixels "Smallest Rectangle Enclosing Black Pixels")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-2d-immutable "Range Sum Query 2D - Immutable") +[Next >](../range-sum-query-2d-immutable "Range Sum Query 2D - Immutable") ## [303. Range Sum Query - Immutable (Easy)](https://leetcode.com/problems/range-sum-query-immutable "区域和检索 - 数组不可变") @@ -31,9 +31,9 @@ sumRange(0, 5) -> -3

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Range Sum Query 2D - Immutable](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-2d-immutable) (Medium) - 1. [Range Sum Query - Mutable](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-mutable) (Medium) - 1. [Maximum Size Subarray Sum Equals k](https://github.com/openset/leetcode/tree/master/problems/maximum-size-subarray-sum-equals-k) (Medium) + 1. [Range Sum Query 2D - Immutable](../range-sum-query-2d-immutable) (Medium) + 1. [Range Sum Query - Mutable](../range-sum-query-mutable) (Medium) + 1. [Maximum Size Subarray Sum Equals k](../maximum-size-subarray-sum-equals-k) (Medium) diff --git a/problems/range-sum-query-mutable/README.md b/problems/range-sum-query-mutable/README.md index 0922ceb77..2ab29effe 100644 --- a/problems/range-sum-query-mutable/README.md +++ b/problems/range-sum-query-mutable/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/additive-number "Additive Number") +[< Previous](../additive-number "Additive Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-2d-mutable "Range Sum Query 2D - Mutable") +[Next >](../range-sum-query-2d-mutable "Range Sum Query 2D - Mutable") ## [307. Range Sum Query - Mutable (Medium)](https://leetcode.com/problems/range-sum-query-mutable "区域和检索 - 数组可修改") @@ -33,9 +33,9 @@ sumRange(0, 2) -> 8 ### Related Topics - [[Binary Indexed Tree](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] - [[Segment Tree](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] ### Similar Questions - 1. [Range Sum Query - Immutable](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-immutable) (Easy) - 1. [Range Sum Query 2D - Mutable](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-2d-mutable) (Hard) + 1. [Range Sum Query - Immutable](../range-sum-query-immutable) (Easy) + 1. [Range Sum Query 2D - Mutable](../range-sum-query-2d-mutable) (Hard) diff --git a/problems/rank-scores/README.md b/problems/rank-scores/README.md index 98a80e882..348ec520c 100644 --- a/problems/rank-scores/README.md +++ b/problems/rank-scores/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/nth-highest-salary "Nth Highest Salary") +[< Previous](../nth-highest-salary "Nth Highest Salary")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/largest-number "Largest Number") +[Next >](../largest-number "Largest Number") ## [178. Rank Scores (Medium)](https://leetcode.com/problems/rank-scores "分数排名") diff --git a/problems/ransom-note/README.md b/problems/ransom-note/README.md index f3bc42a43..4b4f4adc0 100644 --- a/problems/ransom-note/README.md +++ b/problems/ransom-note/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/linked-list-random-node "Linked List Random Node") +[< Previous](../linked-list-random-node "Linked List Random Node")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shuffle-an-array "Shuffle an Array") +[Next >](../shuffle-an-array "Shuffle an Array") ## [383. Ransom Note (Easy)](https://leetcode.com/problems/ransom-note "赎金信") @@ -30,7 +30,7 @@ canConstruct("aa", "aab") -> true ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Stickers to Spell Word](https://github.com/openset/leetcode/tree/master/problems/stickers-to-spell-word) (Hard) + 1. [Stickers to Spell Word](../stickers-to-spell-word) (Hard) diff --git a/problems/reach-a-number/README.md b/problems/reach-a-number/README.md index 52f48248a..85e70c34a 100644 --- a/problems/reach-a-number/README.md +++ b/problems/reach-a-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/cracking-the-safe "Cracking the Safe") +[< Previous](../cracking-the-safe "Cracking the Safe")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/pour-water "Pour Water") +[Next >](../pour-water "Pour Water") ## [754. Reach a Number (Medium)](https://leetcode.com/problems/reach-a-number "到达终点数字") @@ -45,4 +45,4 @@ On the third move we step from -1 to 2.

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/reachable-nodes-in-subdivided-graph/README.md b/problems/reachable-nodes-in-subdivided-graph/README.md index 8cd936a5b..b33cd0903 100644 --- a/problems/reachable-nodes-in-subdivided-graph/README.md +++ b/problems/reachable-nodes-in-subdivided-graph/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/boats-to-save-people "Boats to Save People") +[< Previous](../boats-to-save-people "Boats to Save People")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/projection-area-of-3d-shapes "Projection Area of 3D Shapes") +[Next >](../projection-area-of-3d-shapes "Projection Area of 3D Shapes") ## [882. Reachable Nodes In Subdivided Graph (Hard)](https://leetcode.com/problems/reachable-nodes-in-subdivided-graph "细分图中的可到达结点") @@ -65,4 +65,4 @@ The nodes that are reachable in the final graph after M = 6 moves are indicated ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] + [[Heap](../../tag/heap/README.md)] diff --git a/problems/reaching-points/README.md b/problems/reaching-points/README.md index 383a2a695..989d99986 100644 --- a/problems/reaching-points/README.md +++ b/problems/reaching-points/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/k-th-symbol-in-grammar "K-th Symbol in Grammar") +[< Previous](../k-th-symbol-in-grammar "K-th Symbol in Grammar")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/rabbits-in-forest "Rabbits in Forest") +[Next >](../rabbits-in-forest "Rabbits in Forest") ## [780. Reaching Points (Hard)](https://leetcode.com/problems/reaching-points "到达终点") @@ -40,4 +40,4 @@ One series of moves that transforms the starting point to the target is: ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md b/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md index 3f4779cdc..366605e89 100644 --- a/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md +++ b/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/read-n-characters-given-read4 "Read N Characters Given Read4") +[< Previous](../read-n-characters-given-read4 "Read N Characters Given Read4")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters "Longest Substring with At Most Two Distinct Characters") +[Next >](../longest-substring-with-at-most-two-distinct-characters "Longest Substring with At Most Two Distinct Characters") ## [158. Read N Characters Given Read4 II - Call multiple times (Hard)](https://leetcode.com/problems/read-n-characters-given-read4-ii-call-multiple-times "用 Read4 读取 N 个字符 II") @@ -94,7 +94,7 @@ sol.read(buf, 1); // We have reached the end of file, no more characters can be ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Read N Characters Given Read4](https://github.com/openset/leetcode/tree/master/problems/read-n-characters-given-read4) (Easy) + 1. [Read N Characters Given Read4](../read-n-characters-given-read4) (Easy) diff --git a/problems/read-n-characters-given-read4/README.md b/problems/read-n-characters-given-read4/README.md index 7e777ec38..ec9cf5d10 100644 --- a/problems/read-n-characters-given-read4/README.md +++ b/problems/read-n-characters-given-read4/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-tree-upside-down "Binary Tree Upside Down") +[< Previous](../binary-tree-upside-down "Binary Tree Upside Down")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/read-n-characters-given-read4-ii-call-multiple-times "Read N Characters Given Read4 II - Call multiple times") +[Next >](../read-n-characters-given-read4-ii-call-multiple-times "Read N Characters Given Read4 II - Call multiple times") ## [157. Read N Characters Given Read4 (Easy)](https://leetcode.com/problems/read-n-characters-given-read4 "用 Read4 读取 N 个字符") @@ -104,7 +104,7 @@ Note: buf[] is destination not source, you will need to write the results to buf ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Read N Characters Given Read4 II - Call multiple times](https://github.com/openset/leetcode/tree/master/problems/read-n-characters-given-read4-ii-call-multiple-times) (Hard) + 1. [Read N Characters Given Read4 II - Call multiple times](../read-n-characters-given-read4-ii-call-multiple-times) (Hard) diff --git a/problems/rearrange-string-k-distance-apart/README.md b/problems/rearrange-string-k-distance-apart/README.md index c540b1737..8ab0f8b6e 100644 --- a/problems/rearrange-string-k-distance-apart/README.md +++ b/problems/rearrange-string-k-distance-apart/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/count-numbers-with-unique-digits "Count Numbers with Unique Digits") +[< Previous](../count-numbers-with-unique-digits "Count Numbers with Unique Digits")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/logger-rate-limiter "Logger Rate Limiter") +[Next >](../logger-rate-limiter "Logger Rate Limiter") ## [358. Rearrange String k Distance Apart (Hard)](https://leetcode.com/problems/rearrange-string-k-distance-apart "K 距离间隔重排字符串") @@ -43,10 +43,10 @@ ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Task Scheduler](https://github.com/openset/leetcode/tree/master/problems/task-scheduler) (Medium) - 1. [Reorganize String](https://github.com/openset/leetcode/tree/master/problems/reorganize-string) (Medium) + 1. [Task Scheduler](../task-scheduler) (Medium) + 1. [Reorganize String](../reorganize-string) (Medium) diff --git a/problems/reconstruct-a-2-row-binary-matrix/README.md b/problems/reconstruct-a-2-row-binary-matrix/README.md index e52c04fe5..05e21c189 100644 --- a/problems/reconstruct-a-2-row-binary-matrix/README.md +++ b/problems/reconstruct-a-2-row-binary-matrix/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/cells-with-odd-values-in-a-matrix "Cells with Odd Values in a Matrix") +[< Previous](../cells-with-odd-values-in-a-matrix "Cells with Odd Values in a Matrix")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-closed-islands "Number of Closed Islands") +[Next >](../number-of-closed-islands "Number of Closed Islands") ## [1253. Reconstruct a 2-Row Binary Matrix (Medium)](https://leetcode.com/problems/reconstruct-a-2-row-binary-matrix "重构 2 行二进制矩阵") @@ -61,8 +61,8 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/reconstruct-itinerary/README.md b/problems/reconstruct-itinerary/README.md index 09afa8ff3..b7cfcce7f 100644 --- a/problems/reconstruct-itinerary/README.md +++ b/problems/reconstruct-itinerary/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/verify-preorder-serialization-of-a-binary-tree "Verify Preorder Serialization of a Binary Tree") +[< Previous](../verify-preorder-serialization-of-a-binary-tree "Verify Preorder Serialization of a Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/largest-bst-subtree "Largest BST Subtree") +[Next >](../largest-bst-subtree "Largest BST Subtree") ## [332. Reconstruct Itinerary (Medium)](https://leetcode.com/problems/reconstruct-itinerary "重新安排行程") @@ -38,5 +38,5 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] diff --git a/problems/reconstruct-original-digits-from-english/README.md b/problems/reconstruct-original-digits-from-english/README.md index a3a9d6ed8..f4f520891 100644 --- a/problems/reconstruct-original-digits-from-english/README.md +++ b/problems/reconstruct-original-digits-from-english/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-word-square "Valid Word Square") +[< Previous](../valid-word-square "Valid Word Square")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-repeating-character-replacement "Longest Repeating Character Replacement") +[Next >](../longest-repeating-character-replacement "Longest Repeating Character Replacement") ## [423. Reconstruct Original Digits from English (Medium)](https://leetcode.com/problems/reconstruct-original-digits-from-english "从英文中重建数字") @@ -38,4 +38,4 @@ Output: "45"

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/recover-a-tree-from-preorder-traversal/README.md b/problems/recover-a-tree-from-preorder-traversal/README.md index 806ef8f48..f76b12e26 100644 --- a/problems/recover-a-tree-from-preorder-traversal/README.md +++ b/problems/recover-a-tree-from-preorder-traversal/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-arithmetic-sequence "Longest Arithmetic Sequence") +[< Previous](../longest-arithmetic-sequence "Longest Arithmetic Sequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/two-city-scheduling "Two City Scheduling") +[Next >](../two-city-scheduling "Two City Scheduling") ## [1028. Recover a Tree From Preorder Traversal (Hard)](https://leetcode.com/problems/recover-a-tree-from-preorder-traversal "从先序遍历还原二叉树") @@ -65,8 +65,8 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Hints
diff --git a/problems/recover-binary-search-tree/README.md b/problems/recover-binary-search-tree/README.md index 59bc3e33c..81af2a3a8 100644 --- a/problems/recover-binary-search-tree/README.md +++ b/problems/recover-binary-search-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/validate-binary-search-tree "Validate Binary Search Tree") +[< Previous](../validate-binary-search-tree "Validate Binary Search Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/same-tree "Same Tree") +[Next >](../same-tree "Same Tree") ## [99. Recover Binary Search Tree (Hard)](https://leetcode.com/problems/recover-binary-search-tree "恢复二叉搜索树") @@ -63,5 +63,5 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/rectangle-area-ii/README.md b/problems/rectangle-area-ii/README.md index 1fdb74c03..eac757cc8 100644 --- a/problems/rectangle-area-ii/README.md +++ b/problems/rectangle-area-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximize-distance-to-closest-person "Maximize Distance to Closest Person") +[< Previous](../maximize-distance-to-closest-person "Maximize Distance to Closest Person")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/loud-and-rich "Loud and Rich") +[Next >](../loud-and-rich "Loud and Rich") ## [850. Rectangle Area II (Hard)](https://leetcode.com/problems/rectangle-area-ii "矩形面积 II") @@ -43,5 +43,5 @@ ### Related Topics - [[Segment Tree](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] - [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Line Sweep](../../tag/line-sweep/README.md)] diff --git a/problems/rectangle-area/README.md b/problems/rectangle-area/README.md index 8cc6f2f84..a90cbf5dd 100644 --- a/problems/rectangle-area/README.md +++ b/problems/rectangle-area/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/count-complete-tree-nodes "Count Complete Tree Nodes") +[< Previous](../count-complete-tree-nodes "Count Complete Tree Nodes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/basic-calculator "Basic Calculator") +[Next >](../basic-calculator "Basic Calculator") ## [223. Rectangle Area (Medium)](https://leetcode.com/problems/rectangle-area "矩形面积") @@ -28,7 +28,7 @@

Assume that the total area is never beyond the maximum possible value of int.

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Rectangle Overlap](https://github.com/openset/leetcode/tree/master/problems/rectangle-overlap) (Easy) + 1. [Rectangle Overlap](../rectangle-overlap) (Easy) diff --git a/problems/rectangle-overlap/README.md b/problems/rectangle-overlap/README.md index ee40280ab..1665c47ed 100644 --- a/problems/rectangle-overlap/README.md +++ b/problems/rectangle-overlap/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/image-overlap "Image Overlap") +[< Previous](../image-overlap "Image Overlap")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/new-21-game "New 21 Game") +[Next >](../new-21-game "New 21 Game") ## [836. Rectangle Overlap (Easy)](https://leetcode.com/problems/rectangle-overlap "矩形重叠") @@ -39,7 +39,7 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Rectangle Area](https://github.com/openset/leetcode/tree/master/problems/rectangle-area) (Medium) + 1. [Rectangle Area](../rectangle-area) (Medium) diff --git a/problems/redundant-connection-ii/README.md b/problems/redundant-connection-ii/README.md index 7b6adc70d..32c267e4d 100644 --- a/problems/redundant-connection-ii/README.md +++ b/problems/redundant-connection-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/redundant-connection "Redundant Connection") +[< Previous](../redundant-connection "Redundant Connection")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/repeated-string-match "Repeated String Match") +[Next >](../repeated-string-match "Repeated String Match") ## [685. Redundant Connection II (Hard)](https://leetcode.com/problems/redundant-connection-ii "冗余连接 II") @@ -47,10 +47,10 @@ v v

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] ### Similar Questions - 1. [Redundant Connection](https://github.com/openset/leetcode/tree/master/problems/redundant-connection) (Medium) + 1. [Redundant Connection](../redundant-connection) (Medium) diff --git a/problems/redundant-connection/README.md b/problems/redundant-connection/README.md index 27cf22c9c..6d8db4840 100644 --- a/problems/redundant-connection/README.md +++ b/problems/redundant-connection/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/k-empty-slots "K Empty Slots") +[< Previous](../k-empty-slots "K Empty Slots")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/redundant-connection-ii "Redundant Connection II") +[Next >](../redundant-connection-ii "Redundant Connection II") ## [684. Redundant Connection (Medium)](https://leetcode.com/problems/redundant-connection "冗余连接") @@ -52,10 +52,10 @@ We have overhauled the problem description + test cases and specified clearly th

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] ### Similar Questions - 1. [Redundant Connection II](https://github.com/openset/leetcode/tree/master/problems/redundant-connection-ii) (Hard) - 1. [Accounts Merge](https://github.com/openset/leetcode/tree/master/problems/accounts-merge) (Medium) + 1. [Redundant Connection II](../redundant-connection-ii) (Hard) + 1. [Accounts Merge](../accounts-merge) (Medium) diff --git a/problems/reformat-department-table/README.md b/problems/reformat-department-table/README.md index 4ed39a47c..dbbf71b3a 100644 --- a/problems/reformat-department-table/README.md +++ b/problems/reformat-department-table/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-valid-words-for-each-puzzle "Number of Valid Words for Each Puzzle") +[< Previous](../number-of-valid-words-for-each-puzzle "Number of Valid Words for Each Puzzle")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/count-substrings-with-only-one-distinct-letter "Count Substrings with Only One Distinct Letter") +[Next >](../count-substrings-with-only-one-distinct-letter "Count Substrings with Only One Distinct Letter") ## [1179. Reformat Department Table (Easy)](https://leetcode.com/problems/reformat-department-table "重新格式化部门表") diff --git a/problems/regions-cut-by-slashes/README.md b/problems/regions-cut-by-slashes/README.md index b96d8c349..920a4ff39 100644 --- a/problems/regions-cut-by-slashes/README.md +++ b/problems/regions-cut-by-slashes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/check-completeness-of-a-binary-tree "Check Completeness of a Binary Tree") +[< Previous](../check-completeness-of-a-binary-tree "Check Completeness of a Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/delete-columns-to-make-sorted-iii "Delete Columns to Make Sorted III") +[Next >](../delete-columns-to-make-sorted-iii "Delete Columns to Make Sorted III") ## [959. Regions Cut By Slashes (Medium)](https://leetcode.com/problems/regions-cut-by-slashes "由斜杠划分区域") @@ -119,6 +119,6 @@ The 2x2 grid is as follows: ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] diff --git a/problems/regular-expression-matching/README.md b/problems/regular-expression-matching/README.md index 5e5d65f82..62ae6afc9 100644 --- a/problems/regular-expression-matching/README.md +++ b/problems/regular-expression-matching/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/palindrome-number "Palindrome Number") +[< Previous](../palindrome-number "Palindrome Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/container-with-most-water "Container With Most Water") +[Next >](../container-with-most-water "Container With Most Water") ## [10. Regular Expression Matching (Hard)](https://leetcode.com/problems/regular-expression-matching "正则表达式匹配") @@ -77,9 +77,9 @@ p = "mis*is*p*." ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Wildcard Matching](https://github.com/openset/leetcode/tree/master/problems/wildcard-matching) (Hard) + 1. [Wildcard Matching](../wildcard-matching) (Hard) diff --git a/problems/relative-ranks/README.md b/problems/relative-ranks/README.md index e8c796d4b..ab21ccd9a 100644 --- a/problems/relative-ranks/README.md +++ b/problems/relative-ranks/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/the-maze-ii "The Maze II") +[< Previous](../the-maze-ii "The Maze II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/perfect-number "Perfect Number") +[Next >](../perfect-number "Perfect Number") ## [506. Relative Ranks (Easy)](https://leetcode.com/problems/relative-ranks "相对名次") diff --git a/problems/relative-sort-array/README.md b/problems/relative-sort-array/README.md index 95a21fd99..b3de2b749 100644 --- a/problems/relative-sort-array/README.md +++ b/problems/relative-sort-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/divide-array-into-increasing-sequences "Divide Array Into Increasing Sequences") +[< Previous](../divide-array-into-increasing-sequences "Divide Array Into Increasing Sequences")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/lowest-common-ancestor-of-deepest-leaves "Lowest Common Ancestor of Deepest Leaves") +[Next >](../lowest-common-ancestor-of-deepest-leaves "Lowest Common Ancestor of Deepest Leaves") ## [1122. Relative Sort Array (Easy)](https://leetcode.com/problems/relative-sort-array "数组的相对排序") @@ -31,8 +31,8 @@ ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/remove-9/README.md b/problems/remove-9/README.md index 5a8abb0b8..c186217f6 100644 --- a/problems/remove-9/README.md +++ b/problems/remove-9/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/split-array-into-consecutive-subsequences "Split Array into Consecutive Subsequences") +[< Previous](../split-array-into-consecutive-subsequences "Split Array into Consecutive Subsequences")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/image-smoother "Image Smoother") +[Next >](../image-smoother "Image Smoother") ## [660. Remove 9 (Hard)](https://leetcode.com/problems/remove-9 "移除 9") @@ -28,4 +28,4 @@

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/remove-all-adjacent-duplicates-in-string-ii/README.md b/problems/remove-all-adjacent-duplicates-in-string-ii/README.md index 1343fa3b9..206bea2c3 100644 --- a/problems/remove-all-adjacent-duplicates-in-string-ii/README.md +++ b/problems/remove-all-adjacent-duplicates-in-string-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/get-equal-substrings-within-budget "Get Equal Substrings Within Budget") +[< Previous](../get-equal-substrings-within-budget "Get Equal Substrings Within Budget")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-reach-target-with-rotations "Minimum Moves to Reach Target with Rotations") +[Next >](../minimum-moves-to-reach-target-with-rotations "Minimum Moves to Reach Target with Rotations") ## [1209. Remove All Adjacent Duplicates in String II (Medium)](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii "删除字符串中的所有相邻重复项 II") @@ -54,7 +54,7 @@ Finally delete "ddd", get "aa" ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] + [[Stack](../../tag/stack/README.md)] ### Hints
diff --git a/problems/remove-all-adjacent-duplicates-in-string/README.md b/problems/remove-all-adjacent-duplicates-in-string/README.md index 12f0aa56c..2ec524ed2 100644 --- a/problems/remove-all-adjacent-duplicates-in-string/README.md +++ b/problems/remove-all-adjacent-duplicates-in-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/last-stone-weight "Last Stone Weight") +[< Previous](../last-stone-weight "Last Stone Weight")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-string-chain "Longest String Chain") +[Next >](../longest-string-chain "Longest String Chain") ## [1047. Remove All Adjacent Duplicates In String (Easy)](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string "删除字符串中的所有相邻重复项") @@ -38,7 +38,7 @@ For example, in "abbaca" we could remove "bb" since the lett ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] + [[Stack](../../tag/stack/README.md)] ### Hints
diff --git a/problems/remove-boxes/README.md b/problems/remove-boxes/README.md index 56bea8406..ff1ac85fb 100644 --- a/problems/remove-boxes/README.md +++ b/problems/remove-boxes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/boundary-of-binary-tree "Boundary of Binary Tree") +[< Previous](../boundary-of-binary-tree "Boundary of Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/friend-circles "Friend Circles") +[Next >](../friend-circles "Friend Circles") ## [546. Remove Boxes (Hard)](https://leetcode.com/problems/remove-boxes "移除盒子") @@ -40,8 +40,8 @@ The number of boxes n would not exceed 100.

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Strange Printer](https://github.com/openset/leetcode/tree/master/problems/strange-printer) (Hard) + 1. [Strange Printer](../strange-printer) (Hard) diff --git a/problems/remove-comments/README.md b/problems/remove-comments/README.md index 3a981fc79..08ced295f 100644 --- a/problems/remove-comments/README.md +++ b/problems/remove-comments/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/accounts-merge "Accounts Merge") +[< Previous](../accounts-merge "Accounts Merge")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/candy-crush "Candy Crush") +[Next >](../candy-crush "Candy Crush") ## [722. Remove Comments (Medium)](https://leetcode.com/problems/remove-comments "删除注释") @@ -82,11 +82,11 @@ source = ["a/*comment", "line", "more_comment*/b"]

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Mini Parser](https://github.com/openset/leetcode/tree/master/problems/mini-parser) (Medium) - 1. [Ternary Expression Parser](https://github.com/openset/leetcode/tree/master/problems/ternary-expression-parser) (Medium) + 1. [Mini Parser](../mini-parser) (Medium) + 1. [Ternary Expression Parser](../ternary-expression-parser) (Medium) ### Hints
diff --git a/problems/remove-covered-intervals/README.md b/problems/remove-covered-intervals/README.md index 450bb30ee..9afd3c7cf 100644 --- a/problems/remove-covered-intervals/README.md +++ b/problems/remove-covered-intervals/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/element-appearing-more-than-25-in-sorted-array "Element Appearing More Than 25% In Sorted Array") +[< Previous](../element-appearing-more-than-25-in-sorted-array "Element Appearing More Than 25% In Sorted Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-falling-path-sum-ii "Minimum Falling Path Sum II") +[Next >](../minimum-falling-path-sum-ii "Minimum Falling Path Sum II") ## [1288. Remove Covered Intervals (Medium)](https://leetcode.com/problems/remove-covered-intervals "删除被覆盖区间") @@ -34,7 +34,7 @@ ### Related Topics - [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] + [[Line Sweep](../../tag/line-sweep/README.md)] ### Hints
diff --git a/problems/remove-duplicate-letters/README.md b/problems/remove-duplicate-letters/README.md index f19bcb730..7de020501 100644 --- a/problems/remove-duplicate-letters/README.md +++ b/problems/remove-duplicate-letters/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/count-of-smaller-numbers-after-self "Count of Smaller Numbers After Self") +[< Previous](../count-of-smaller-numbers-after-self "Count of Smaller Numbers After Self")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-from-all-buildings "Shortest Distance from All Buildings") +[Next >](../shortest-distance-from-all-buildings "Shortest Distance from All Buildings") ## [316. Remove Duplicate Letters (Hard)](https://leetcode.com/problems/remove-duplicate-letters "去除重复字母") @@ -28,5 +28,5 @@ ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/remove-duplicates-from-sorted-array-ii/README.md b/problems/remove-duplicates-from-sorted-array-ii/README.md index 91362b9d8..e7bd74569 100644 --- a/problems/remove-duplicates-from-sorted-array-ii/README.md +++ b/problems/remove-duplicates-from-sorted-array-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/word-search "Word Search") +[< Previous](../word-search "Word Search")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/search-in-rotated-sorted-array-ii "Search in Rotated Sorted Array II") +[Next >](../search-in-rotated-sorted-array-ii "Search in Rotated Sorted Array II") ## [80. Remove Duplicates from Sorted Array II (Medium)](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii "删除排序数组中的重复项 II") @@ -54,8 +54,8 @@ for (int i = 0; i < len; i++) { ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Remove Duplicates from Sorted Array](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-array) (Easy) + 1. [Remove Duplicates from Sorted Array](../remove-duplicates-from-sorted-array) (Easy) diff --git a/problems/remove-duplicates-from-sorted-array/README.md b/problems/remove-duplicates-from-sorted-array/README.md index ea2a906a3..0dbb6aa76 100644 --- a/problems/remove-duplicates-from-sorted-array/README.md +++ b/problems/remove-duplicates-from-sorted-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reverse-nodes-in-k-group "Reverse Nodes in k-Group") +[< Previous](../reverse-nodes-in-k-group "Reverse Nodes in k-Group")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-element "Remove Element") +[Next >](../remove-element "Remove Element") ## [26. Remove Duplicates from Sorted Array (Easy)](https://leetcode.com/problems/remove-duplicates-from-sorted-array "删除排序数组中的重复项") @@ -53,9 +53,9 @@ for (int i = 0; i < len; i++) { } ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Remove Element](https://github.com/openset/leetcode/tree/master/problems/remove-element) (Easy) - 1. [Remove Duplicates from Sorted Array II](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-array-ii) (Medium) + 1. [Remove Element](../remove-element) (Easy) + 1. [Remove Duplicates from Sorted Array II](../remove-duplicates-from-sorted-array-ii) (Medium) diff --git a/problems/remove-duplicates-from-sorted-list-ii/README.md b/problems/remove-duplicates-from-sorted-list-ii/README.md index 53a8da13c..ec0ae0b3f 100644 --- a/problems/remove-duplicates-from-sorted-list-ii/README.md +++ b/problems/remove-duplicates-from-sorted-list-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/search-in-rotated-sorted-array-ii "Search in Rotated Sorted Array II") +[< Previous](../search-in-rotated-sorted-array-ii "Search in Rotated Sorted Array II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-list "Remove Duplicates from Sorted List") +[Next >](../remove-duplicates-from-sorted-list "Remove Duplicates from Sorted List") ## [82. Remove Duplicates from Sorted List II (Medium)](https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii "删除排序链表中的重复元素 II") @@ -28,7 +28,7 @@ ### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Remove Duplicates from Sorted List](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-list) (Easy) + 1. [Remove Duplicates from Sorted List](../remove-duplicates-from-sorted-list) (Easy) diff --git a/problems/remove-duplicates-from-sorted-list/README.md b/problems/remove-duplicates-from-sorted-list/README.md index 044ffdc16..bcf7db1ce 100644 --- a/problems/remove-duplicates-from-sorted-list/README.md +++ b/problems/remove-duplicates-from-sorted-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-list-ii "Remove Duplicates from Sorted List II") +[< Previous](../remove-duplicates-from-sorted-list-ii "Remove Duplicates from Sorted List II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/largest-rectangle-in-histogram "Largest Rectangle in Histogram") +[Next >](../largest-rectangle-in-histogram "Largest Rectangle in Histogram") ## [83. Remove Duplicates from Sorted List (Easy)](https://leetcode.com/problems/remove-duplicates-from-sorted-list "删除排序链表中的重复元素") @@ -28,7 +28,7 @@ ### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Remove Duplicates from Sorted List II](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-list-ii) (Medium) + 1. [Remove Duplicates from Sorted List II](../remove-duplicates-from-sorted-list-ii) (Medium) diff --git a/problems/remove-element/README.md b/problems/remove-element/README.md index 974109275..b82b30128 100644 --- a/problems/remove-element/README.md +++ b/problems/remove-element/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-array "Remove Duplicates from Sorted Array") +[< Previous](../remove-duplicates-from-sorted-array "Remove Duplicates from Sorted Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/implement-strstr "Implement strStr()") +[Next >](../implement-strstr "Implement strStr()") ## [27. Remove Element (Easy)](https://leetcode.com/problems/remove-element "移除元素") @@ -57,13 +57,13 @@ for (int i = 0; i < len; i++) { } ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Remove Duplicates from Sorted Array](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-array) (Easy) - 1. [Remove Linked List Elements](https://github.com/openset/leetcode/tree/master/problems/remove-linked-list-elements) (Easy) - 1. [Move Zeroes](https://github.com/openset/leetcode/tree/master/problems/move-zeroes) (Easy) + 1. [Remove Duplicates from Sorted Array](../remove-duplicates-from-sorted-array) (Easy) + 1. [Remove Linked List Elements](../remove-linked-list-elements) (Easy) + 1. [Move Zeroes](../move-zeroes) (Easy) ### Hints
diff --git a/problems/remove-interval/README.md b/problems/remove-interval/README.md index 693b9c100..437aef451 100644 --- a/problems/remove-interval/README.md +++ b/problems/remove-interval/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/hexspeak "Hexspeak") +[< Previous](../hexspeak "Hexspeak")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/delete-tree-nodes "Delete Tree Nodes") +[Next >](../delete-tree-nodes "Delete Tree Nodes") ## [1272. Remove Interval (Medium)](https://leetcode.com/problems/remove-interval "删除区间") @@ -34,8 +34,8 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] + [[Math](../../tag/math/README.md)] + [[Line Sweep](../../tag/line-sweep/README.md)] ### Hints
diff --git a/problems/remove-invalid-parentheses/README.md b/problems/remove-invalid-parentheses/README.md index 5230d2179..afa3e89a4 100644 --- a/problems/remove-invalid-parentheses/README.md +++ b/problems/remove-invalid-parentheses/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-increasing-subsequence "Longest Increasing Subsequence") +[< Previous](../longest-increasing-subsequence "Longest Increasing Subsequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/smallest-rectangle-enclosing-black-pixels "Smallest Rectangle Enclosing Black Pixels") +[Next >](../smallest-rectangle-enclosing-black-pixels "Smallest Rectangle Enclosing Black Pixels") ## [301. Remove Invalid Parentheses (Hard)](https://leetcode.com/problems/remove-invalid-parentheses "删除无效的括号") @@ -37,11 +37,11 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions - 1. [Valid Parentheses](https://github.com/openset/leetcode/tree/master/problems/valid-parentheses) (Easy) + 1. [Valid Parentheses](../valid-parentheses) (Easy) ### Hints
diff --git a/problems/remove-k-digits/README.md b/problems/remove-k-digits/README.md index c52c1a493..1444883ab 100644 --- a/problems/remove-k-digits/README.md +++ b/problems/remove-k-digits/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-watch "Binary Watch") +[< Previous](../binary-watch "Binary Watch")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/frog-jump "Frog Jump") +[Next >](../frog-jump "Frog Jump") ## [402. Remove K Digits (Medium)](https://leetcode.com/problems/remove-k-digits "移掉K位数字") @@ -47,9 +47,9 @@ Explanation: Remove all the digits from the number and it is left with nothing w

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions - 1. [Create Maximum Number](https://github.com/openset/leetcode/tree/master/problems/create-maximum-number) (Hard) - 1. [Monotone Increasing Digits](https://github.com/openset/leetcode/tree/master/problems/monotone-increasing-digits) (Medium) + 1. [Create Maximum Number](../create-maximum-number) (Hard) + 1. [Monotone Increasing Digits](../monotone-increasing-digits) (Medium) diff --git a/problems/remove-linked-list-elements/README.md b/problems/remove-linked-list-elements/README.md index 685fd493c..085bfd5c4 100644 --- a/problems/remove-linked-list-elements/README.md +++ b/problems/remove-linked-list-elements/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/happy-number "Happy Number") +[< Previous](../happy-number "Happy Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/count-primes "Count Primes") +[Next >](../count-primes "Count Primes") ## [203. Remove Linked List Elements (Easy)](https://leetcode.com/problems/remove-linked-list-elements "移除链表元素") @@ -21,8 +21,8 @@ ### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Remove Element](https://github.com/openset/leetcode/tree/master/problems/remove-element) (Easy) - 1. [Delete Node in a Linked List](https://github.com/openset/leetcode/tree/master/problems/delete-node-in-a-linked-list) (Easy) + 1. [Remove Element](../remove-element) (Easy) + 1. [Delete Node in a Linked List](../delete-node-in-a-linked-list) (Easy) diff --git a/problems/remove-nth-node-from-end-of-list/README.md b/problems/remove-nth-node-from-end-of-list/README.md index 51ff61a63..9ee4efe81 100644 --- a/problems/remove-nth-node-from-end-of-list/README.md +++ b/problems/remove-nth-node-from-end-of-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/4sum "4Sum") +[< Previous](../4sum "4Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-parentheses "Valid Parentheses") +[Next >](../valid-parentheses "Valid Parentheses") ## [19. Remove Nth Node From End of List (Medium)](https://leetcode.com/problems/remove-nth-node-from-end-of-list "删除链表的倒数第N个节点") @@ -30,8 +30,8 @@ After removing the second node from the end, the linked list becomes 1-&

Could you do this in one pass?

### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Hints
diff --git a/problems/remove-outermost-parentheses/README.md b/problems/remove-outermost-parentheses/README.md index 88c154ddb..c087df718 100644 --- a/problems/remove-outermost-parentheses/README.md +++ b/problems/remove-outermost-parentheses/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-enclaves "Number of Enclaves") +[< Previous](../number-of-enclaves "Number of Enclaves")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sum-of-root-to-leaf-binary-numbers "Sum of Root To Leaf Binary Numbers") +[Next >](../sum-of-root-to-leaf-binary-numbers "Sum of Root To Leaf Binary Numbers") ## [1021. Remove Outermost Parentheses (Easy)](https://leetcode.com/problems/remove-outermost-parentheses "删除最外层的括号") @@ -72,7 +72,7 @@ After removing outer parentheses of each part, this is "" + "&quo ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] + [[Stack](../../tag/stack/README.md)] ### Hints
diff --git a/problems/remove-sub-folders-from-the-filesystem/README.md b/problems/remove-sub-folders-from-the-filesystem/README.md index 77c766089..0a43455d8 100644 --- a/problems/remove-sub-folders-from-the-filesystem/README.md +++ b/problems/remove-sub-folders-from-the-filesystem/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/check-if-it-is-a-straight-line "Check If It Is a Straight Line") +[< Previous](../check-if-it-is-a-straight-line "Check If It Is a Straight Line")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/replace-the-substring-for-balanced-string "Replace the Substring for Balanced String") +[Next >](../replace-the-substring-for-balanced-string "Replace the Substring for Balanced String") ## [1233. Remove Sub-Folders from the Filesystem (Medium)](https://leetcode.com/problems/remove-sub-folders-from-the-filesystem "删除子文件夹") @@ -53,8 +53,8 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/remove-vowels-from-a-string/README.md b/problems/remove-vowels-from-a-string/README.md index a17b38422..ac8433ad8 100644 --- a/problems/remove-vowels-from-a-string/README.md +++ b/problems/remove-vowels-from-a-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-days-in-a-month "Number of Days in a Month") +[< Previous](../number-of-days-in-a-month "Number of Days in a Month")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-average-subtree "Maximum Average Subtree") +[Next >](../maximum-average-subtree "Maximum Average Subtree") ## [1119. Remove Vowels from a String (Easy)](https://leetcode.com/problems/remove-vowels-from-a-string "删去字符串中的元音") @@ -39,10 +39,10 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Reverse Vowels of a String](https://github.com/openset/leetcode/tree/master/problems/reverse-vowels-of-a-string) (Easy) + 1. [Reverse Vowels of a String](../reverse-vowels-of-a-string) (Easy) ### Hints
diff --git a/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md b/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md index b773d3eaf..dbab2e02f 100644 --- a/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md +++ b/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/compare-strings-by-frequency-of-the-smallest-character "Compare Strings by Frequency of the Smallest Character") +[< Previous](../compare-strings-by-frequency-of-the-smallest-character "Compare Strings by Frequency of the Smallest Character")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/dinner-plate-stacks "Dinner Plate Stacks") +[Next >](../dinner-plate-stacks "Dinner Plate Stacks") ## [1171. Remove Zero Sum Consecutive Nodes from Linked List (Medium)](https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list "从链表中删去总和值为零的连续节点") @@ -49,7 +49,7 @@ ### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Hints
diff --git a/problems/reorder-data-in-log-files/README.md b/problems/reorder-data-in-log-files/README.md index ca0522b02..6bfee801b 100644 --- a/problems/reorder-data-in-log-files/README.md +++ b/problems/reorder-data-in-log-files/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/stamping-the-sequence "Stamping The Sequence") +[< Previous](../stamping-the-sequence "Stamping The Sequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/range-sum-of-bst "Range Sum of BST") +[Next >](../range-sum-of-bst "Range Sum of BST") ## [937. Reorder Data in Log Files (Easy)](https://leetcode.com/problems/reorder-data-in-log-files "重新排列日志文件") @@ -41,4 +41,4 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/reorder-list/README.md b/problems/reorder-list/README.md index 300cd6bf9..a556af73d 100644 --- a/problems/reorder-list/README.md +++ b/problems/reorder-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/linked-list-cycle-ii "Linked List Cycle II") +[< Previous](../linked-list-cycle-ii "Linked List Cycle II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-tree-preorder-traversal "Binary Tree Preorder Traversal") +[Next >](../binary-tree-preorder-traversal "Binary Tree Preorder Traversal") ## [143. Reorder List (Medium)](https://leetcode.com/problems/reorder-list "重排链表") @@ -28,4 +28,4 @@ Given 1->2->3->4->5, reorder it to 1->5->2->4->3. ### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/reordered-power-of-2/README.md b/problems/reordered-power-of-2/README.md index 09805a4c7..b3ff34da4 100644 --- a/problems/reordered-power-of-2/README.md +++ b/problems/reordered-power-of-2/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-gap "Binary Gap") +[< Previous](../binary-gap "Binary Gap")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/advantage-shuffle "Advantage Shuffle") +[Next >](../advantage-shuffle "Advantage Shuffle") ## [869. Reordered Power of 2 (Medium)](https://leetcode.com/problems/reordered-power-of-2 "重新排序得到 2 的幂") @@ -74,4 +74,4 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/reorganize-string/README.md b/problems/reorganize-string/README.md index dfd251134..b5d3857ad 100644 --- a/problems/reorganize-string/README.md +++ b/problems/reorganize-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/toeplitz-matrix "Toeplitz Matrix") +[< Previous](../toeplitz-matrix "Toeplitz Matrix")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/max-chunks-to-make-sorted-ii "Max Chunks To Make Sorted II") +[Next >](../max-chunks-to-make-sorted-ii "Max Chunks To Make Sorted II") ## [767. Reorganize String (Medium)](https://leetcode.com/problems/reorganize-string "重构字符串") @@ -38,14 +38,14 @@

 

### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Sort](../../tag/sort/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Rearrange String k Distance Apart](https://github.com/openset/leetcode/tree/master/problems/rearrange-string-k-distance-apart) (Hard) - 1. [Task Scheduler](https://github.com/openset/leetcode/tree/master/problems/task-scheduler) (Medium) + 1. [Rearrange String k Distance Apart](../rearrange-string-k-distance-apart) (Hard) + 1. [Task Scheduler](../task-scheduler) (Medium) ### Hints
diff --git a/problems/repeated-dna-sequences/README.md b/problems/repeated-dna-sequences/README.md index ede09e699..596247e54 100644 --- a/problems/repeated-dna-sequences/README.md +++ b/problems/repeated-dna-sequences/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reverse-words-in-a-string-ii "Reverse Words in a String II") +[< Previous](../reverse-words-in-a-string-ii "Reverse Words in a String II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-iv "Best Time to Buy and Sell Stock IV") +[Next >](../best-time-to-buy-and-sell-stock-iv "Best Time to Buy and Sell Stock IV") ## [187. Repeated DNA Sequences (Medium)](https://leetcode.com/problems/repeated-dna-sequences "重复的DNA序列") @@ -24,5 +24,5 @@ ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/repeated-string-match/README.md b/problems/repeated-string-match/README.md index 5713cd4a0..3415e0f8b 100644 --- a/problems/repeated-string-match/README.md +++ b/problems/repeated-string-match/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/redundant-connection-ii "Redundant Connection II") +[< Previous](../redundant-connection-ii "Redundant Connection II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-univalue-path "Longest Univalue Path") +[Next >](../longest-univalue-path "Longest Univalue Path") ## [686. Repeated String Match (Easy)](https://leetcode.com/problems/repeated-string-match "重复叠加字符串匹配") @@ -21,7 +21,7 @@ The length of A and B will be between 1 and 10000.

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Repeated Substring Pattern](https://github.com/openset/leetcode/tree/master/problems/repeated-substring-pattern) (Easy) + 1. [Repeated Substring Pattern](../repeated-substring-pattern) (Easy) diff --git a/problems/repeated-substring-pattern/README.md b/problems/repeated-substring-pattern/README.md index 78acee6c6..2b436c0d0 100644 --- a/problems/repeated-substring-pattern/README.md +++ b/problems/repeated-substring-pattern/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/poor-pigs "Poor Pigs") +[< Previous](../poor-pigs "Poor Pigs")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/lfu-cache "LFU Cache") +[Next >](../lfu-cache "LFU Cache") ## [459. Repeated Substring Pattern (Easy)](https://leetcode.com/problems/repeated-substring-pattern "重复的子字符串") @@ -39,8 +39,8 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Implement strStr()](https://github.com/openset/leetcode/tree/master/problems/implement-strstr) (Easy) - 1. [Repeated String Match](https://github.com/openset/leetcode/tree/master/problems/repeated-string-match) (Easy) + 1. [Implement strStr()](../implement-strstr) (Easy) + 1. [Repeated String Match](../repeated-string-match) (Easy) diff --git a/problems/replace-the-substring-for-balanced-string/README.md b/problems/replace-the-substring-for-balanced-string/README.md index 49e1838fd..21ef59f4b 100644 --- a/problems/replace-the-substring-for-balanced-string/README.md +++ b/problems/replace-the-substring-for-balanced-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-sub-folders-from-the-filesystem "Remove Sub-Folders from the Filesystem") +[< Previous](../remove-sub-folders-from-the-filesystem "Remove Sub-Folders from the Filesystem")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-profit-in-job-scheduling "Maximum Profit in Job Scheduling") +[Next >](../maximum-profit-in-job-scheduling "Maximum Profit in Job Scheduling") ## [1234. Replace the Substring for Balanced String (Medium)](https://leetcode.com/problems/replace-the-substring-for-balanced-string "替换子串得到平衡字符串") @@ -61,8 +61,8 @@ ### Related Topics - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/replace-words/README.md b/problems/replace-words/README.md index 437a54593..7a3419aff 100644 --- a/problems/replace-words/README.md +++ b/problems/replace-words/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/palindromic-substrings "Palindromic Substrings") +[< Previous](../palindromic-substrings "Palindromic Substrings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/dota2-senate "Dota2 Senate") +[Next >](../dota2-senate "Dota2 Senate") ## [648. Replace Words (Medium)](https://leetcode.com/problems/replace-words "单词替换") @@ -40,8 +40,8 @@ sentence = "the cattle was rattled by the battery"

 

### Related Topics - [[Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Implement Trie (Prefix Tree)](https://github.com/openset/leetcode/tree/master/problems/implement-trie-prefix-tree) (Medium) + 1. [Implement Trie (Prefix Tree)](../implement-trie-prefix-tree) (Medium) diff --git a/problems/report-contiguous-dates/README.md b/problems/report-contiguous-dates/README.md index 2b96ebd67..11fe64ece 100644 --- a/problems/report-contiguous-dates/README.md +++ b/problems/report-contiguous-dates/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-equal-frequency "Maximum Equal Frequency") +[< Previous](../maximum-equal-frequency "Maximum Equal Frequency")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/the-dining-philosophers "The Dining Philosophers") +[Next >](../the-dining-philosophers "The Dining Philosophers") ## [1225. Report Contiguous Dates (Hard)](https://leetcode.com/problems/report-contiguous-dates "报告系统状态的连续日期") diff --git a/problems/reported-posts-ii/README.md b/problems/reported-posts-ii/README.md index 50c7bdbed..6c1b56bac 100644 --- a/problems/reported-posts-ii/README.md +++ b/problems/reported-posts-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-of-absolute-value-expression "Maximum of Absolute Value Expression") +[< Previous](../maximum-of-absolute-value-expression "Maximum of Absolute Value Expression")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/largest-unique-number "Largest Unique Number") +[Next >](../largest-unique-number "Largest Unique Number") ## [1132. Reported Posts II (Medium)](https://leetcode.com/problems/reported-posts-ii "") diff --git a/problems/reported-posts/README.md b/problems/reported-posts/README.md index ef60dbc00..28d60a6a0 100644 --- a/problems/reported-posts/README.md +++ b/problems/reported-posts/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/highest-grade-for-each-student "Highest Grade For Each Student") +[< Previous](../highest-grade-for-each-student "Highest Grade For Each Student")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/print-in-order "Print in Order") +[Next >](../print-in-order "Print in Order") ## [1113. Reported Posts (Easy)](https://leetcode.com/problems/reported-posts "") diff --git a/problems/reshape-the-matrix/README.md b/problems/reshape-the-matrix/README.md index 66969fde1..53b4b856d 100644 --- a/problems/reshape-the-matrix/README.md +++ b/problems/reshape-the-matrix/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/array-nesting "Array Nesting") +[< Previous](../array-nesting "Array Nesting")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/permutation-in-string "Permutation in String") +[Next >](../permutation-in-string "Permutation in String") ## [566. Reshape the Matrix (Easy)](https://leetcode.com/problems/reshape-the-matrix "重塑矩阵") @@ -59,7 +59,7 @@ r = 2, c = 4

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/restore-ip-addresses/README.md b/problems/restore-ip-addresses/README.md index d19d86b24..4c4d9ac8a 100644 --- a/problems/restore-ip-addresses/README.md +++ b/problems/restore-ip-addresses/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reverse-linked-list-ii "Reverse Linked List II") +[< Previous](../reverse-linked-list-ii "Reverse Linked List II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-tree-inorder-traversal "Binary Tree Inorder Traversal") +[Next >](../binary-tree-inorder-traversal "Binary Tree Inorder Traversal") ## [93. Restore IP Addresses (Medium)](https://leetcode.com/problems/restore-ip-addresses "复原IP地址") @@ -21,8 +21,8 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[String](../../tag/string/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [IP to CIDR](https://github.com/openset/leetcode/tree/master/problems/ip-to-cidr) (Easy) + 1. [IP to CIDR](../ip-to-cidr) (Easy) diff --git a/problems/reveal-cards-in-increasing-order/README.md b/problems/reveal-cards-in-increasing-order/README.md index 7d4c21d36..91b50b6a2 100644 --- a/problems/reveal-cards-in-increasing-order/README.md +++ b/problems/reveal-cards-in-increasing-order/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/largest-time-for-given-digits "Largest Time for Given Digits") +[< Previous](../largest-time-for-given-digits "Largest Time for Given Digits")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/flip-equivalent-binary-trees "Flip Equivalent Binary Trees") +[Next >](../flip-equivalent-binary-trees "Flip Equivalent Binary Trees") ## [950. Reveal Cards In Increasing Order (Medium)](https://leetcode.com/problems/reveal-cards-in-increasing-order "按递增顺序显示卡牌") @@ -62,4 +62,4 @@ Since all the cards revealed are in increasing order, the answer is correct. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/reverse-bits/README.md b/problems/reverse-bits/README.md index 3bc7fcb93..4dcbc9d08 100644 --- a/problems/reverse-bits/README.md +++ b/problems/reverse-bits/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/rotate-array "Rotate Array") +[< Previous](../rotate-array "Rotate Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-1-bits "Number of 1 Bits") +[Next >](../number-of-1-bits "Number of 1 Bits") ## [190. Reverse Bits (Easy)](https://leetcode.com/problems/reverse-bits "颠倒二进制位") @@ -46,8 +46,8 @@

If this function is called many times, how would you optimize it?

### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions - 1. [Reverse Integer](https://github.com/openset/leetcode/tree/master/problems/reverse-integer) (Easy) - 1. [Number of 1 Bits](https://github.com/openset/leetcode/tree/master/problems/number-of-1-bits) (Easy) + 1. [Reverse Integer](../reverse-integer) (Easy) + 1. [Number of 1 Bits](../number-of-1-bits) (Easy) diff --git a/problems/reverse-integer/README.md b/problems/reverse-integer/README.md index 354062cd9..610746349 100644 --- a/problems/reverse-integer/README.md +++ b/problems/reverse-integer/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/zigzag-conversion "ZigZag Conversion") +[< Previous](../zigzag-conversion "ZigZag Conversion")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/string-to-integer-atoi "String to Integer (atoi)") +[Next >](../string-to-integer-atoi "String to Integer (atoi)") ## [7. Reverse Integer (Easy)](https://leetcode.com/problems/reverse-integer "整数反转") @@ -38,8 +38,8 @@ Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [String to Integer (atoi)](https://github.com/openset/leetcode/tree/master/problems/string-to-integer-atoi) (Medium) - 1. [Reverse Bits](https://github.com/openset/leetcode/tree/master/problems/reverse-bits) (Easy) + 1. [String to Integer (atoi)](../string-to-integer-atoi) (Medium) + 1. [Reverse Bits](../reverse-bits) (Easy) diff --git a/problems/reverse-linked-list-ii/README.md b/problems/reverse-linked-list-ii/README.md index 1fb6872ce..9e99a57a2 100644 --- a/problems/reverse-linked-list-ii/README.md +++ b/problems/reverse-linked-list-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/decode-ways "Decode Ways") +[< Previous](../decode-ways "Decode Ways")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/restore-ip-addresses "Restore IP Addresses") +[Next >](../restore-ip-addresses "Restore IP Addresses") ## [92. Reverse Linked List II (Medium)](https://leetcode.com/problems/reverse-linked-list-ii "反转链表 II") @@ -23,7 +23,7 @@ ### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Reverse Linked List](https://github.com/openset/leetcode/tree/master/problems/reverse-linked-list) (Easy) + 1. [Reverse Linked List](../reverse-linked-list) (Easy) diff --git a/problems/reverse-linked-list/README.md b/problems/reverse-linked-list/README.md index 0ae9d3e1e..932df0fe5 100644 --- a/problems/reverse-linked-list/README.md +++ b/problems/reverse-linked-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/isomorphic-strings "Isomorphic Strings") +[< Previous](../isomorphic-strings "Isomorphic Strings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/course-schedule "Course Schedule") +[Next >](../course-schedule "Course Schedule") ## [206. Reverse Linked List (Easy)](https://leetcode.com/problems/reverse-linked-list "反转链表") @@ -25,9 +25,9 @@

A linked list can be reversed either iteratively or recursively. Could you implement both?

### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Reverse Linked List II](https://github.com/openset/leetcode/tree/master/problems/reverse-linked-list-ii) (Medium) - 1. [Binary Tree Upside Down](https://github.com/openset/leetcode/tree/master/problems/binary-tree-upside-down) (Medium) - 1. [Palindrome Linked List](https://github.com/openset/leetcode/tree/master/problems/palindrome-linked-list) (Easy) + 1. [Reverse Linked List II](../reverse-linked-list-ii) (Medium) + 1. [Binary Tree Upside Down](../binary-tree-upside-down) (Medium) + 1. [Palindrome Linked List](../palindrome-linked-list) (Easy) diff --git a/problems/reverse-nodes-in-k-group/README.md b/problems/reverse-nodes-in-k-group/README.md index 604789930..3bdf974b6 100644 --- a/problems/reverse-nodes-in-k-group/README.md +++ b/problems/reverse-nodes-in-k-group/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/swap-nodes-in-pairs "Swap Nodes in Pairs") +[< Previous](../swap-nodes-in-pairs "Swap Nodes in Pairs")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-array "Remove Duplicates from Sorted Array") +[Next >](../remove-duplicates-from-sorted-array "Remove Duplicates from Sorted Array") ## [25. Reverse Nodes in k-Group (Hard)](https://leetcode.com/problems/reverse-nodes-in-k-group "K 个一组翻转链表") @@ -34,7 +34,7 @@ ### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Swap Nodes in Pairs](https://github.com/openset/leetcode/tree/master/problems/swap-nodes-in-pairs) (Medium) + 1. [Swap Nodes in Pairs](../swap-nodes-in-pairs) (Medium) diff --git a/problems/reverse-only-letters/README.md b/problems/reverse-only-letters/README.md index 4fd63bcdb..466e3b271 100644 --- a/problems/reverse-only-letters/README.md +++ b/problems/reverse-only-letters/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/word-subsets "Word Subsets") +[< Previous](../word-subsets "Word Subsets")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-sum-circular-subarray "Maximum Sum Circular Subarray") +[Next >](../maximum-sum-circular-subarray "Maximum Sum Circular Subarray") ## [917. Reverse Only Letters (Easy)](https://leetcode.com/problems/reverse-only-letters "仅仅反转字母") @@ -64,7 +64,7 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/reverse-pairs/README.md b/problems/reverse-pairs/README.md index b5695a66d..11f7dd8a4 100644 --- a/problems/reverse-pairs/README.md +++ b/problems/reverse-pairs/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/construct-the-rectangle "Construct the Rectangle") +[< Previous](../construct-the-rectangle "Construct the Rectangle")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/target-sum "Target Sum") +[Next >](../target-sum "Target Sum") ## [493. Reverse Pairs (Hard)](https://leetcode.com/problems/reverse-pairs "翻转对") @@ -35,12 +35,12 @@

### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Binary Indexed Tree](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] - [[Segment Tree](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions - 1. [Count of Smaller Numbers After Self](https://github.com/openset/leetcode/tree/master/problems/count-of-smaller-numbers-after-self) (Hard) - 1. [Count of Range Sum](https://github.com/openset/leetcode/tree/master/problems/count-of-range-sum) (Hard) + 1. [Count of Smaller Numbers After Self](../count-of-smaller-numbers-after-self) (Hard) + 1. [Count of Range Sum](../count-of-range-sum) (Hard) diff --git a/problems/reverse-string-ii/README.md b/problems/reverse-string-ii/README.md index fbbd396b6..b968e041c 100644 --- a/problems/reverse-string-ii/README.md +++ b/problems/reverse-string-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/single-element-in-a-sorted-array "Single Element in a Sorted Array") +[< Previous](../single-element-in-a-sorted-array "Single Element in a Sorted Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/01-matrix "01 Matrix") +[Next >](../01-matrix "01 Matrix") ## [541. Reverse String II (Easy)](https://leetcode.com/problems/reverse-string-ii "反转字符串 II") @@ -29,8 +29,8 @@ Given a string and an integer k, you need to reverse the first k characters for ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Reverse String](https://github.com/openset/leetcode/tree/master/problems/reverse-string) (Easy) - 1. [Reverse Words in a String III](https://github.com/openset/leetcode/tree/master/problems/reverse-words-in-a-string-iii) (Easy) + 1. [Reverse String](../reverse-string) (Easy) + 1. [Reverse Words in a String III](../reverse-words-in-a-string-iii) (Easy) diff --git a/problems/reverse-string/README.md b/problems/reverse-string/README.md index db6b908fb..94874454e 100644 --- a/problems/reverse-string/README.md +++ b/problems/reverse-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/integer-break "Integer Break") +[< Previous](../integer-break "Integer Break")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reverse-vowels-of-a-string "Reverse Vowels of a String") +[Next >](../reverse-vowels-of-a-string "Reverse Vowels of a String") ## [344. Reverse String (Easy)](https://leetcode.com/problems/reverse-string "反转字符串") @@ -38,12 +38,12 @@ ### Related Topics - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Reverse Vowels of a String](https://github.com/openset/leetcode/tree/master/problems/reverse-vowels-of-a-string) (Easy) - 1. [Reverse String II](https://github.com/openset/leetcode/tree/master/problems/reverse-string-ii) (Easy) + 1. [Reverse Vowels of a String](../reverse-vowels-of-a-string) (Easy) + 1. [Reverse String II](../reverse-string-ii) (Easy) ### Hints
diff --git a/problems/reverse-substrings-between-each-pair-of-parentheses/README.md b/problems/reverse-substrings-between-each-pair-of-parentheses/README.md index 431d61983..d02500b91 100644 --- a/problems/reverse-substrings-between-each-pair-of-parentheses/README.md +++ b/problems/reverse-substrings-between-each-pair-of-parentheses/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-number-of-balloons "Maximum Number of Balloons") +[< Previous](../maximum-number-of-balloons "Maximum Number of Balloons")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/k-concatenation-maximum-sum "K-Concatenation Maximum Sum") +[Next >](../k-concatenation-maximum-sum "K-Concatenation Maximum Sum") ## [1190. Reverse Substrings Between Each Pair of Parentheses (Medium)](https://leetcode.com/problems/reverse-substrings-between-each-pair-of-parentheses "反转每对括号间的子串") @@ -58,7 +58,7 @@ ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] + [[Stack](../../tag/stack/README.md)] ### Hints
diff --git a/problems/reverse-vowels-of-a-string/README.md b/problems/reverse-vowels-of-a-string/README.md index 3b1c05b08..0c017d48e 100644 --- a/problems/reverse-vowels-of-a-string/README.md +++ b/problems/reverse-vowels-of-a-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reverse-string "Reverse String") +[< Previous](../reverse-string "Reverse String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/moving-average-from-data-stream "Moving Average from Data Stream") +[Next >](../moving-average-from-data-stream "Moving Average from Data Stream") ## [345. Reverse Vowels of a String (Easy)](https://leetcode.com/problems/reverse-vowels-of-a-string "反转字符串中的元音字母") @@ -34,9 +34,9 @@ The vowels does not include the letter "y".

 

### Related Topics - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Reverse String](https://github.com/openset/leetcode/tree/master/problems/reverse-string) (Easy) - 1. [Remove Vowels from a String](https://github.com/openset/leetcode/tree/master/problems/remove-vowels-from-a-string) (Easy) + 1. [Reverse String](../reverse-string) (Easy) + 1. [Remove Vowels from a String](../remove-vowels-from-a-string) (Easy) diff --git a/problems/reverse-words-in-a-string-ii/README.md b/problems/reverse-words-in-a-string-ii/README.md index f8fdc0bb8..9ddda9082 100644 --- a/problems/reverse-words-in-a-string-ii/README.md +++ b/problems/reverse-words-in-a-string-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/department-top-three-salaries "Department Top Three Salaries") +[< Previous](../department-top-three-salaries "Department Top Three Salaries")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/repeated-dna-sequences "Repeated DNA Sequences") +[Next >](../repeated-dna-sequences "Repeated DNA Sequences") ## [186. Reverse Words in a String II (Medium)](https://leetcode.com/problems/reverse-words-in-a-string-ii "翻转字符串里的单词 II") @@ -30,8 +30,8 @@

Follow up: Could you do it in-place without allocating extra space?

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Reverse Words in a String](https://github.com/openset/leetcode/tree/master/problems/reverse-words-in-a-string) (Medium) - 1. [Rotate Array](https://github.com/openset/leetcode/tree/master/problems/rotate-array) (Easy) + 1. [Reverse Words in a String](../reverse-words-in-a-string) (Medium) + 1. [Rotate Array](../rotate-array) (Easy) diff --git a/problems/reverse-words-in-a-string-iii/README.md b/problems/reverse-words-in-a-string-iii/README.md index 1186419ab..2060c20a6 100644 --- a/problems/reverse-words-in-a-string-iii/README.md +++ b/problems/reverse-words-in-a-string-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-iii "Next Greater Element III") +[< Previous](../next-greater-element-iii "Next Greater Element III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/quad-tree-intersection "Quad Tree Intersection") +[Next >](../quad-tree-intersection "Quad Tree Intersection") ## [557. Reverse Words in a String III (Easy)](https://leetcode.com/problems/reverse-words-in-a-string-iii "反转字符串中的单词 III") @@ -25,7 +25,7 @@ In the string, each word is separated by single space and there will not be any

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Reverse String II](https://github.com/openset/leetcode/tree/master/problems/reverse-string-ii) (Easy) + 1. [Reverse String II](../reverse-string-ii) (Easy) diff --git a/problems/reverse-words-in-a-string/README.md b/problems/reverse-words-in-a-string/README.md index 167067f44..a146c81f6 100644 --- a/problems/reverse-words-in-a-string/README.md +++ b/problems/reverse-words-in-a-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/evaluate-reverse-polish-notation "Evaluate Reverse Polish Notation") +[< Previous](../evaluate-reverse-polish-notation "Evaluate Reverse Polish Notation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-product-subarray "Maximum Product Subarray") +[Next >](../maximum-product-subarray "Maximum Product Subarray") ## [151. Reverse Words in a String (Medium)](https://leetcode.com/problems/reverse-words-in-a-string "翻转字符串里的单词") @@ -55,7 +55,7 @@

For C programmers, try to solve it in-place in O(1) extra space.

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Reverse Words in a String II](https://github.com/openset/leetcode/tree/master/problems/reverse-words-in-a-string-ii) (Medium) + 1. [Reverse Words in a String II](../reverse-words-in-a-string-ii) (Medium) diff --git a/problems/rising-temperature/README.md b/problems/rising-temperature/README.md index cc63c72db..64abfb622 100644 --- a/problems/rising-temperature/README.md +++ b/problems/rising-temperature/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/delete-duplicate-emails "Delete Duplicate Emails") +[< Previous](../delete-duplicate-emails "Delete Duplicate Emails")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/house-robber "House Robber") +[Next >](../house-robber "House Robber") ## [197. Rising Temperature (Easy)](https://leetcode.com/problems/rising-temperature "上升的温度") diff --git a/problems/rle-iterator/README.md b/problems/rle-iterator/README.md index 45275902a..a79cd7989 100644 --- a/problems/rle-iterator/README.md +++ b/problems/rle-iterator/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/orderly-queue "Orderly Queue") +[< Previous](../orderly-queue "Orderly Queue")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/online-stock-span "Online Stock Span") +[Next >](../online-stock-span "Online Stock Span") ## [900. RLE Iterator (Medium)](https://leetcode.com/problems/rle-iterator "RLE 迭代器") @@ -53,4 +53,4 @@ but the second term did not exist. Since the last term exhausted does not exist ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/robot-bounded-in-circle/README.md b/problems/robot-bounded-in-circle/README.md index 4a95b7a8e..ead8a72f6 100644 --- a/problems/robot-bounded-in-circle/README.md +++ b/problems/robot-bounded-in-circle/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/moving-stones-until-consecutive-ii "Moving Stones Until Consecutive II") +[< Previous](../moving-stones-until-consecutive-ii "Moving Stones Until Consecutive II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/flower-planting-with-no-adjacent "Flower Planting With No Adjacent") +[Next >](../flower-planting-with-no-adjacent "Flower Planting With No Adjacent") ## [1041. Robot Bounded In Circle (Medium)](https://leetcode.com/problems/robot-bounded-in-circle "困于环中的机器人") @@ -63,7 +63,7 @@ The robot moves from (0, 0) -> (0, 1) -> (-1, 1) -> (-1, 0) -> (0, 0 ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/robot-return-to-origin/README.md b/problems/robot-return-to-origin/README.md index 53af872b3..136450cd1 100644 --- a/problems/robot-return-to-origin/README.md +++ b/problems/robot-return-to-origin/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/coin-path "Coin Path") +[< Previous](../coin-path "Coin Path")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-k-closest-elements "Find K Closest Elements") +[Next >](../find-k-closest-elements "Find K Closest Elements") ## [657. Robot Return to Origin (Easy)](https://leetcode.com/problems/robot-return-to-origin "机器人能否返回原点") @@ -36,7 +36,7 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Friend Circles](https://github.com/openset/leetcode/tree/master/problems/friend-circles) (Medium) + 1. [Friend Circles](../friend-circles) (Medium) diff --git a/problems/robot-room-cleaner/README.md b/problems/robot-room-cleaner/README.md index e08f5efd5..4f9fd0399 100644 --- a/problems/robot-room-cleaner/README.md +++ b/problems/robot-room-cleaner/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/zuma-game "Zuma Game") +[< Previous](../zuma-game "Zuma Game")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/the-maze "The Maze") +[Next >](../the-maze "The Maze") ## [489. Robot Room Cleaner (Hard)](https://leetcode.com/problems/robot-room-cleaner "扫地机器人") @@ -68,7 +68,7 @@ From the top left corner, its position is one row below and three columns right. ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Walls and Gates](https://github.com/openset/leetcode/tree/master/problems/walls-and-gates) (Medium) + 1. [Walls and Gates](../walls-and-gates) (Medium) diff --git a/problems/roman-to-integer/README.md b/problems/roman-to-integer/README.md index b9219902f..41b7c6519 100644 --- a/problems/roman-to-integer/README.md +++ b/problems/roman-to-integer/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/integer-to-roman "Integer to Roman") +[< Previous](../integer-to-roman "Integer to Roman")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-common-prefix "Longest Common Prefix") +[Next >](../longest-common-prefix "Longest Common Prefix") ## [13. Roman to Integer (Easy)](https://leetcode.com/problems/roman-to-integer "罗马数字转整数") @@ -69,11 +69,11 @@ M 1000 Explanation: M = 1000, CM = 900, XC = 90 and IV = 4. ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Integer to Roman](https://github.com/openset/leetcode/tree/master/problems/integer-to-roman) (Medium) + 1. [Integer to Roman](../integer-to-roman) (Medium) ### Hints
diff --git a/problems/rotate-array/README.md b/problems/rotate-array/README.md index 72994b14e..0492b89a0 100644 --- a/problems/rotate-array/README.md +++ b/problems/rotate-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-iv "Best Time to Buy and Sell Stock IV") +[< Previous](../best-time-to-buy-and-sell-stock-iv "Best Time to Buy and Sell Stock IV")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reverse-bits "Reverse Bits") +[Next >](../reverse-bits "Reverse Bits") ## [189. Rotate Array (Easy)](https://leetcode.com/problems/rotate-array "旋转数组") @@ -42,11 +42,11 @@ rotate 2 steps to the right: [3,99,-1,-100] ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Rotate List](https://github.com/openset/leetcode/tree/master/problems/rotate-list) (Medium) - 1. [Reverse Words in a String II](https://github.com/openset/leetcode/tree/master/problems/reverse-words-in-a-string-ii) (Medium) + 1. [Rotate List](../rotate-list) (Medium) + 1. [Reverse Words in a String II](../reverse-words-in-a-string-ii) (Medium) ### Hints
diff --git a/problems/rotate-function/README.md b/problems/rotate-function/README.md index 849f8be48..e17bd15ca 100644 --- a/problems/rotate-function/README.md +++ b/problems/rotate-function/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-least-k-repeating-characters "Longest Substring with At Least K Repeating Characters") +[< Previous](../longest-substring-with-at-least-k-repeating-characters "Longest Substring with At Least K Repeating Characters")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/integer-replacement "Integer Replacement") +[Next >](../integer-replacement "Integer Replacement") ## [396. Rotate Function (Medium)](https://leetcode.com/problems/rotate-function "旋转函数") @@ -43,4 +43,4 @@ So the maximum value of F(0), F(1), F(2), F(3) is F(3) = 26.

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/rotate-image/README.md b/problems/rotate-image/README.md index ce9dd0479..49da7441d 100644 --- a/problems/rotate-image/README.md +++ b/problems/rotate-image/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/permutations-ii "Permutations II") +[< Previous](../permutations-ii "Permutations II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/group-anagrams "Group Anagrams") +[Next >](../group-anagrams "Group Anagrams") ## [48. Rotate Image (Medium)](https://leetcode.com/problems/rotate-image "旋转图像") @@ -58,4 +58,4 @@ rotate the input matrix in-place such that it becomes: ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/rotate-list/README.md b/problems/rotate-list/README.md index 0bd2abc1c..183cea056 100644 --- a/problems/rotate-list/README.md +++ b/problems/rotate-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/permutation-sequence "Permutation Sequence") +[< Previous](../permutation-sequence "Permutation Sequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/unique-paths "Unique Paths") +[Next >](../unique-paths "Unique Paths") ## [61. Rotate List (Medium)](https://leetcode.com/problems/rotate-list "旋转链表") @@ -35,9 +35,9 @@ rotate 3 steps to the right: 0->1->2->NULL rotate 4 steps to the right: 2->0->1->NULL ### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Rotate Array](https://github.com/openset/leetcode/tree/master/problems/rotate-array) (Easy) - 1. [Split Linked List in Parts](https://github.com/openset/leetcode/tree/master/problems/split-linked-list-in-parts) (Medium) + 1. [Rotate Array](../rotate-array) (Easy) + 1. [Split Linked List in Parts](../split-linked-list-in-parts) (Medium) diff --git a/problems/rotate-string/README.md b/problems/rotate-string/README.md index 65bdefc83..439e626a3 100644 --- a/problems/rotate-string/README.md +++ b/problems/rotate-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-subarrays-with-bounded-maximum "Number of Subarrays with Bounded Maximum") +[< Previous](../number-of-subarrays-with-bounded-maximum "Number of Subarrays with Bounded Maximum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/all-paths-from-source-to-target "All Paths From Source to Target") +[Next >](../all-paths-from-source-to-target "All Paths From Source to Target") ## [796. Rotate String (Easy)](https://leetcode.com/problems/rotate-string "旋转字符串") diff --git a/problems/rotated-digits/README.md b/problems/rotated-digits/README.md index a7767e7e4..9795ec22c 100644 --- a/problems/rotated-digits/README.md +++ b/problems/rotated-digits/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/cheapest-flights-within-k-stops "Cheapest Flights Within K Stops") +[< Previous](../cheapest-flights-within-k-stops "Cheapest Flights Within K Stops")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/escape-the-ghosts "Escape The Ghosts") +[Next >](../escape-the-ghosts "Escape The Ghosts") ## [788. Rotated Digits (Easy)](https://leetcode.com/problems/rotated-digits "旋转数字") @@ -33,4 +33,4 @@ Note that 1 and 10 are not good numbers, since they remain unchanged after rotat ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/rotting-oranges/README.md b/problems/rotting-oranges/README.md index 80037e6f9..29d01483d 100644 --- a/problems/rotting-oranges/README.md +++ b/problems/rotting-oranges/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/cousins-in-binary-tree "Cousins in Binary Tree") +[< Previous](../cousins-in-binary-tree "Cousins in Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-k-consecutive-bit-flips "Minimum Number of K Consecutive Bit Flips") +[Next >](../minimum-number-of-k-consecutive-bit-flips "Minimum Number of K Consecutive Bit Flips") ## [994. Rotting Oranges (Easy)](https://leetcode.com/problems/rotting-oranges "腐烂的橘子") @@ -67,7 +67,7 @@ ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions - 1. [Walls and Gates](https://github.com/openset/leetcode/tree/master/problems/walls-and-gates) (Medium) + 1. [Walls and Gates](../walls-and-gates) (Medium) diff --git a/problems/russian-doll-envelopes/README.md b/problems/russian-doll-envelopes/README.md index 3c94eabcd..69574adf1 100644 --- a/problems/russian-doll-envelopes/README.md +++ b/problems/russian-doll-envelopes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-snake-game "Design Snake Game") +[< Previous](../design-snake-game "Design Snake Game")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-twitter "Design Twitter") +[Next >](../design-twitter "Design Twitter") ## [354. Russian Doll Envelopes (Hard)](https://leetcode.com/problems/russian-doll-envelopes "俄罗斯套娃信封问题") @@ -29,8 +29,8 @@ Rotation is not allowed.

### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Longest Increasing Subsequence](https://github.com/openset/leetcode/tree/master/problems/longest-increasing-subsequence) (Medium) + 1. [Longest Increasing Subsequence](../longest-increasing-subsequence) (Medium) diff --git a/problems/sales-analysis-i/README.md b/problems/sales-analysis-i/README.md index 44575ec12..0a1194fca 100644 --- a/problems/sales-analysis-i/README.md +++ b/problems/sales-analysis-i/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/smallest-subsequence-of-distinct-characters "Smallest Subsequence of Distinct Characters") +[< Previous](../smallest-subsequence-of-distinct-characters "Smallest Subsequence of Distinct Characters")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sales-analysis-ii "Sales Analysis II") +[Next >](../sales-analysis-ii "Sales Analysis II") ## [1082. Sales Analysis I (Easy)](https://leetcode.com/problems/sales-analysis-i "销售分析 I ") diff --git a/problems/sales-analysis-ii/README.md b/problems/sales-analysis-ii/README.md index 2727dcd65..fc8aa1986 100644 --- a/problems/sales-analysis-ii/README.md +++ b/problems/sales-analysis-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sales-analysis-i "Sales Analysis I") +[< Previous](../sales-analysis-i "Sales Analysis I")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sales-analysis-iii "Sales Analysis III") +[Next >](../sales-analysis-iii "Sales Analysis III") ## [1083. Sales Analysis II (Easy)](https://leetcode.com/problems/sales-analysis-ii "销售分析 II") diff --git a/problems/sales-analysis-iii/README.md b/problems/sales-analysis-iii/README.md index 62e9bde75..dd4265cf4 100644 --- a/problems/sales-analysis-iii/README.md +++ b/problems/sales-analysis-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sales-analysis-ii "Sales Analysis II") +[< Previous](../sales-analysis-ii "Sales Analysis II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sum-of-digits-in-the-minimum-number "Sum of Digits in the Minimum Number") +[Next >](../sum-of-digits-in-the-minimum-number "Sum of Digits in the Minimum Number") ## [1084. Sales Analysis III (Easy)](https://leetcode.com/problems/sales-analysis-iii "销售分析III") diff --git a/problems/sales-person/README.md b/problems/sales-person/README.md index d0908a262..3cdb5eca4 100644 --- a/problems/sales-person/README.md +++ b/problems/sales-person/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/construct-string-from-binary-tree "Construct String from Binary Tree") +[< Previous](../construct-string-from-binary-tree "Construct String from Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/tree-node "Tree Node") +[Next >](../tree-node "Tree Node") ## [607. Sales Person (Easy)](https://leetcode.com/problems/sales-person "销售员") diff --git a/problems/same-tree/README.md b/problems/same-tree/README.md index d9a6e5cd2..162173b56 100644 --- a/problems/same-tree/README.md +++ b/problems/same-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/recover-binary-search-tree "Recover Binary Search Tree") +[< Previous](../recover-binary-search-tree "Recover Binary Search Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/symmetric-tree "Symmetric Tree") +[Next >](../symmetric-tree "Symmetric Tree") ## [100. Same Tree (Easy)](https://leetcode.com/problems/same-tree "相同的树") @@ -52,5 +52,5 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/satisfiability-of-equality-equations/README.md b/problems/satisfiability-of-equality-equations/README.md index 703b43d29..254462d3e 100644 --- a/problems/satisfiability-of-equality-equations/README.md +++ b/problems/satisfiability-of-equality-equations/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/add-to-array-form-of-integer "Add to Array-Form of Integer") +[< Previous](../add-to-array-form-of-integer "Add to Array-Form of Integer")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/broken-calculator "Broken Calculator") +[Next >](../broken-calculator "Broken Calculator") ## [990. Satisfiability of Equality Equations (Medium)](https://leetcode.com/problems/satisfiability-of-equality-equations "等式方程的可满足性") @@ -80,5 +80,5 @@ ### Related Topics - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] diff --git a/problems/score-after-flipping-matrix/README.md b/problems/score-after-flipping-matrix/README.md index 78058d317..12aa610f2 100644 --- a/problems/score-after-flipping-matrix/README.md +++ b/problems/score-after-flipping-matrix/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/lemonade-change "Lemonade Change") +[< Previous](../lemonade-change "Lemonade Change")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-subarray-with-sum-at-least-k "Shortest Subarray with Sum at Least K") +[Next >](../shortest-subarray-with-sum-at-least-k "Shortest Subarray with Sum at Least K") ## [861. Score After Flipping Matrix (Medium)](https://leetcode.com/problems/score-after-flipping-matrix "翻转矩阵后的得分") @@ -46,4 +46,4 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/score-of-parentheses/README.md b/problems/score-of-parentheses/README.md index dc86153a3..eea7cdcf7 100644 --- a/problems/score-of-parentheses/README.md +++ b/problems/score-of-parentheses/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/exam-room "Exam Room") +[< Previous](../exam-room "Exam Room")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-to-hire-k-workers "Minimum Cost to Hire K Workers") +[Next >](../minimum-cost-to-hire-k-workers "Minimum Cost to Hire K Workers") ## [856. Score of Parentheses (Medium)](https://leetcode.com/problems/score-of-parentheses "括号的分数") @@ -67,5 +67,5 @@ ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/scramble-string/README.md b/problems/scramble-string/README.md index fdfdfe68a..f28f7e09b 100644 --- a/problems/scramble-string/README.md +++ b/problems/scramble-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/partition-list "Partition List") +[< Previous](../partition-list "Partition List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/merge-sorted-array "Merge Sorted Array") +[Next >](../merge-sorted-array "Merge Sorted Array") ## [87. Scramble String (Hard)](https://leetcode.com/problems/scramble-string "扰乱字符串") @@ -71,5 +71,5 @@ r g ta e Output: false ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/search-a-2d-matrix-ii/README.md b/problems/search-a-2d-matrix-ii/README.md index 64030105e..af706d37e 100644 --- a/problems/search-a-2d-matrix-ii/README.md +++ b/problems/search-a-2d-matrix-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sliding-window-maximum "Sliding Window Maximum") +[< Previous](../sliding-window-maximum "Sliding Window Maximum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/different-ways-to-add-parentheses "Different Ways to Add Parentheses") +[Next >](../different-ways-to-add-parentheses "Different Ways to Add Parentheses") ## [240. Search a 2D Matrix II (Medium)](https://leetcode.com/problems/search-a-2d-matrix-ii "搜索二维矩阵 II") @@ -37,8 +37,8 @@

Given target = 20, return false.

### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions - 1. [Search a 2D Matrix](https://github.com/openset/leetcode/tree/master/problems/search-a-2d-matrix) (Medium) + 1. [Search a 2D Matrix](../search-a-2d-matrix) (Medium) diff --git a/problems/search-a-2d-matrix/README.md b/problems/search-a-2d-matrix/README.md index 2d46926c8..de3448811 100644 --- a/problems/search-a-2d-matrix/README.md +++ b/problems/search-a-2d-matrix/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/set-matrix-zeroes "Set Matrix Zeroes") +[< Previous](../set-matrix-zeroes "Set Matrix Zeroes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sort-colors "Sort Colors") +[Next >](../sort-colors "Sort Colors") ## [74. Search a 2D Matrix (Medium)](https://leetcode.com/problems/search-a-2d-matrix "搜索二维矩阵") @@ -44,8 +44,8 @@ target = 13 Output: false ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Search a 2D Matrix II](https://github.com/openset/leetcode/tree/master/problems/search-a-2d-matrix-ii) (Medium) + 1. [Search a 2D Matrix II](../search-a-2d-matrix-ii) (Medium) diff --git a/problems/search-in-a-binary-search-tree/README.md b/problems/search-in-a-binary-search-tree/README.md index e20122d20..24a5e7f02 100644 --- a/problems/search-in-a-binary-search-tree/README.md +++ b/problems/search-in-a-binary-search-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/falling-squares "Falling Squares") +[< Previous](../falling-squares "Falling Squares")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-binary-search-tree "Insert into a Binary Search Tree") +[Next >](../insert-into-a-binary-search-tree "Insert into a Binary Search Tree") ## [700. Search in a Binary Search Tree (Easy)](https://leetcode.com/problems/search-in-a-binary-search-tree "二叉搜索树中的搜索") @@ -39,8 +39,8 @@ And the value to search: 2

Note that an empty tree is represented by NULL, therefore you would see the expected output (serialized tree format) as [], not null.

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Closest Binary Search Tree Value](https://github.com/openset/leetcode/tree/master/problems/closest-binary-search-tree-value) (Easy) - 1. [Insert into a Binary Search Tree](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-binary-search-tree) (Medium) + 1. [Closest Binary Search Tree Value](../closest-binary-search-tree-value) (Easy) + 1. [Insert into a Binary Search Tree](../insert-into-a-binary-search-tree) (Medium) diff --git a/problems/search-in-a-sorted-array-of-unknown-size/README.md b/problems/search-in-a-sorted-array-of-unknown-size/README.md index 776283071..ae427a39c 100644 --- a/problems/search-in-a-sorted-array-of-unknown-size/README.md +++ b/problems/search-in-a-sorted-array-of-unknown-size/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-binary-search-tree "Insert into a Binary Search Tree") +[< Previous](../insert-into-a-binary-search-tree "Insert into a Binary Search Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/kth-largest-element-in-a-stream "Kth Largest Element in a Stream") +[Next >](../kth-largest-element-in-a-stream "Kth Largest Element in a Stream") ## [702. Search in a Sorted Array of Unknown Size (Medium)](https://leetcode.com/problems/search-in-a-sorted-array-of-unknown-size "搜索长度未知的有序数组") @@ -40,7 +40,7 @@ ### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Binary Search](https://github.com/openset/leetcode/tree/master/problems/binary-search) (Easy) + 1. [Binary Search](../binary-search) (Easy) diff --git a/problems/search-in-rotated-sorted-array-ii/README.md b/problems/search-in-rotated-sorted-array-ii/README.md index 8cf3d2d0d..6930dbd99 100644 --- a/problems/search-in-rotated-sorted-array-ii/README.md +++ b/problems/search-in-rotated-sorted-array-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-array-ii "Remove Duplicates from Sorted Array II") +[< Previous](../remove-duplicates-from-sorted-array-ii "Remove Duplicates from Sorted Array II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-list-ii "Remove Duplicates from Sorted List II") +[Next >](../remove-duplicates-from-sorted-list-ii "Remove Duplicates from Sorted List II") ## [81. Search in Rotated Sorted Array II (Medium)](https://leetcode.com/problems/search-in-rotated-sorted-array-ii "搜索旋转排序数组 II") @@ -38,8 +38,8 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Search in Rotated Sorted Array](https://github.com/openset/leetcode/tree/master/problems/search-in-rotated-sorted-array) (Medium) + 1. [Search in Rotated Sorted Array](../search-in-rotated-sorted-array) (Medium) diff --git a/problems/search-in-rotated-sorted-array/README.md b/problems/search-in-rotated-sorted-array/README.md index 4068e77b2..84e319757 100644 --- a/problems/search-in-rotated-sorted-array/README.md +++ b/problems/search-in-rotated-sorted-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-valid-parentheses "Longest Valid Parentheses") +[< Previous](../longest-valid-parentheses "Longest Valid Parentheses")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-first-and-last-position-of-element-in-sorted-array "Find First and Last Position of Element in Sorted Array") +[Next >](../find-first-and-last-position-of-element-in-sorted-array "Find First and Last Position of Element in Sorted Array") ## [33. Search in Rotated Sorted Array (Medium)](https://leetcode.com/problems/search-in-rotated-sorted-array "搜索旋转排序数组") @@ -35,9 +35,9 @@ Output: -1 ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Search in Rotated Sorted Array II](https://github.com/openset/leetcode/tree/master/problems/search-in-rotated-sorted-array-ii) (Medium) - 1. [Find Minimum in Rotated Sorted Array](https://github.com/openset/leetcode/tree/master/problems/find-minimum-in-rotated-sorted-array) (Medium) + 1. [Search in Rotated Sorted Array II](../search-in-rotated-sorted-array-ii) (Medium) + 1. [Find Minimum in Rotated Sorted Array](../find-minimum-in-rotated-sorted-array) (Medium) diff --git a/problems/search-insert-position/README.md b/problems/search-insert-position/README.md index 999e416f2..7526ec17d 100644 --- a/problems/search-insert-position/README.md +++ b/problems/search-insert-position/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-first-and-last-position-of-element-in-sorted-array "Find First and Last Position of Element in Sorted Array") +[< Previous](../find-first-and-last-position-of-element-in-sorted-array "Find First and Last Position of Element in Sorted Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-sudoku "Valid Sudoku") +[Next >](../valid-sudoku "Valid Sudoku") ## [35. Search Insert Position (Easy)](https://leetcode.com/problems/search-insert-position "搜索插入位置") @@ -44,8 +44,8 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [First Bad Version](https://github.com/openset/leetcode/tree/master/problems/first-bad-version) (Easy) + 1. [First Bad Version](../first-bad-version) (Easy) diff --git a/problems/search-suggestions-system/README.md b/problems/search-suggestions-system/README.md index 75f7f25a8..649512134 100644 --- a/problems/search-suggestions-system/README.md +++ b/problems/search-suggestions-system/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/count-servers-that-communicate "Count Servers that Communicate") +[< Previous](../count-servers-that-communicate "Count Servers that Communicate")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps "Number of Ways to Stay in the Same Place After Some Steps") +[Next >](../number-of-ways-to-stay-in-the-same-place-after-some-steps "Number of Ways to Stay in the Same Place After Some Steps") ## [1268. Search Suggestions System (Medium)](https://leetcode.com/problems/search-suggestions-system "搜索推荐系统") @@ -66,7 +66,7 @@ After typing mou, mous and mouse the system suggests ["mouse","mo ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/second-degree-follower/README.md b/problems/second-degree-follower/README.md index 70e0547c4..f8169a52a 100644 --- a/problems/second-degree-follower/README.md +++ b/problems/second-degree-follower/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-in-a-line "Shortest Distance in a Line") +[< Previous](../shortest-distance-in-a-line "Shortest Distance in a Line")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/average-salary-departments-vs-company "Average Salary: Departments VS Company") +[Next >](../average-salary-departments-vs-company "Average Salary: Departments VS Company") ## [614. Second Degree Follower (Medium)](https://leetcode.com/problems/second-degree-follower "二级关注者") diff --git a/problems/second-highest-salary/README.md b/problems/second-highest-salary/README.md index 392232b96..110115975 100644 --- a/problems/second-highest-salary/README.md +++ b/problems/second-highest-salary/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/combine-two-tables "Combine Two Tables") +[< Previous](../combine-two-tables "Combine Two Tables")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/nth-highest-salary "Nth Highest Salary") +[Next >](../nth-highest-salary "Nth Highest Salary") ## [176. Second Highest Salary (Easy)](https://leetcode.com/problems/second-highest-salary "第二高的薪水") diff --git a/problems/second-minimum-node-in-a-binary-tree/README.md b/problems/second-minimum-node-in-a-binary-tree/README.md index a2fb836a5..0affbf89b 100644 --- a/problems/second-minimum-node-in-a-binary-tree/README.md +++ b/problems/second-minimum-node-in-a-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-swap "Maximum Swap") +[< Previous](../maximum-swap "Maximum Swap")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/bulb-switcher-ii "Bulb Switcher II") +[Next >](../bulb-switcher-ii "Bulb Switcher II") ## [671. Second Minimum Node In a Binary Tree (Easy)](https://leetcode.com/problems/second-minimum-node-in-a-binary-tree "二叉树中第二小的节点") @@ -48,7 +48,7 @@

 

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Kth Smallest Element in a BST](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-element-in-a-bst) (Medium) + 1. [Kth Smallest Element in a BST](../kth-smallest-element-in-a-bst) (Medium) diff --git a/problems/self-crossing/README.md b/problems/self-crossing/README.md index cea72f512..5f302c012 100644 --- a/problems/self-crossing/README.md +++ b/problems/self-crossing/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/increasing-triplet-subsequence "Increasing Triplet Subsequence") +[< Previous](../increasing-triplet-subsequence "Increasing Triplet Subsequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/palindrome-pairs "Palindrome Pairs") +[Next >](../palindrome-pairs "Palindrome Pairs") ## [335. Self Crossing (Hard)](https://leetcode.com/problems/self-crossing "路径交叉") @@ -54,4 +54,4 @@ Input: [1,1,1,1] ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/self-dividing-numbers/README.md b/problems/self-dividing-numbers/README.md index 7b1e8948c..06a6d454a 100644 --- a/problems/self-dividing-numbers/README.md +++ b/problems/self-dividing-numbers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-window-subsequence "Minimum Window Subsequence") +[< Previous](../minimum-window-subsequence "Minimum Window Subsequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/my-calendar-i "My Calendar I") +[Next >](../my-calendar-i "My Calendar I") ## [728. Self Dividing Numbers (Easy)](https://leetcode.com/problems/self-dividing-numbers "自除数") @@ -33,10 +33,10 @@ left = 1, right = 22

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Perfect Number](https://github.com/openset/leetcode/tree/master/problems/perfect-number) (Easy) + 1. [Perfect Number](../perfect-number) (Easy) ### Hints
diff --git a/problems/sentence-screen-fitting/README.md b/problems/sentence-screen-fitting/README.md index 24d014d3e..e1f7c07d7 100644 --- a/problems/sentence-screen-fitting/README.md +++ b/problems/sentence-screen-fitting/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/pacific-atlantic-water-flow "Pacific Atlantic Water Flow") +[< Previous](../pacific-atlantic-water-flow "Pacific Atlantic Water Flow")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/battleships-in-a-board "Battleships in a Board") +[Next >](../battleships-in-a-board "Battleships in a Board") ## [418. Sentence Screen Fitting (Medium)](https://leetcode.com/problems/sentence-screen-fitting "屏幕可显示句子的数量") @@ -80,4 +80,4 @@ The character '-' signifies an empty space on the screen.

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/sentence-similarity-ii/README.md b/problems/sentence-similarity-ii/README.md index 402d0a3c5..d94e4d940 100644 --- a/problems/sentence-similarity-ii/README.md +++ b/problems/sentence-similarity-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/parse-lisp-expression "Parse Lisp Expression") +[< Previous](../parse-lisp-expression "Parse Lisp Expression")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/monotone-increasing-digits "Monotone Increasing Digits") +[Next >](../monotone-increasing-digits "Monotone Increasing Digits") ## [737. Sentence Similarity II (Medium)](https://leetcode.com/problems/sentence-similarity-ii "句子相似性 II") @@ -35,13 +35,13 @@

 

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] ### Similar Questions - 1. [Friend Circles](https://github.com/openset/leetcode/tree/master/problems/friend-circles) (Medium) - 1. [Accounts Merge](https://github.com/openset/leetcode/tree/master/problems/accounts-merge) (Medium) - 1. [Sentence Similarity](https://github.com/openset/leetcode/tree/master/problems/sentence-similarity) (Easy) + 1. [Friend Circles](../friend-circles) (Medium) + 1. [Accounts Merge](../accounts-merge) (Medium) + 1. [Sentence Similarity](../sentence-similarity) (Easy) ### Hints
diff --git a/problems/sentence-similarity/README.md b/problems/sentence-similarity/README.md index 63a6d8373..97d6a6713 100644 --- a/problems/sentence-similarity/README.md +++ b/problems/sentence-similarity/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/flood-fill "Flood Fill") +[< Previous](../flood-fill "Flood Fill")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/asteroid-collision "Asteroid Collision") +[Next >](../asteroid-collision "Asteroid Collision") ## [734. Sentence Similarity (Easy)](https://leetcode.com/problems/sentence-similarity "句子相似性") @@ -35,12 +35,12 @@

 

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Friend Circles](https://github.com/openset/leetcode/tree/master/problems/friend-circles) (Medium) - 1. [Accounts Merge](https://github.com/openset/leetcode/tree/master/problems/accounts-merge) (Medium) - 1. [Sentence Similarity II](https://github.com/openset/leetcode/tree/master/problems/sentence-similarity-ii) (Medium) + 1. [Friend Circles](../friend-circles) (Medium) + 1. [Accounts Merge](../accounts-merge) (Medium) + 1. [Sentence Similarity II](../sentence-similarity-ii) (Medium) ### Hints
diff --git a/problems/sequence-reconstruction/README.md b/problems/sequence-reconstruction/README.md index a457b302e..e7af72214 100644 --- a/problems/sequence-reconstruction/README.md +++ b/problems/sequence-reconstruction/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/string-compression "String Compression") +[< Previous](../string-compression "String Compression")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/add-two-numbers-ii "Add Two Numbers II") +[Next >](../add-two-numbers-ii "Add Two Numbers II") ## [444. Sequence Reconstruction (Medium)](https://leetcode.com/problems/sequence-reconstruction "序列重建") @@ -68,8 +68,8 @@ The seqs parameter had been changed to a list of list of strings (instead

### Related Topics - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] - [[Topological Sort](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] ### Similar Questions - 1. [Course Schedule II](https://github.com/openset/leetcode/tree/master/problems/course-schedule-ii) (Medium) + 1. [Course Schedule II](../course-schedule-ii) (Medium) diff --git a/problems/sequential-digits/README.md b/problems/sequential-digits/README.md index 4f355d37a..e3d92686a 100644 --- a/problems/sequential-digits/README.md +++ b/problems/sequential-digits/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/convert-binary-number-in-a-linked-list-to-integer "Convert Binary Number in a Linked List to Integer") +[< Previous](../convert-binary-number-in-a-linked-list-to-integer "Convert Binary Number in a Linked List to Integer")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold "Maximum Side Length of a Square with Sum Less than or Equal to Threshold") +[Next >](../maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold "Maximum Side Length of a Square with Sum Less than or Equal to Threshold") ## [1291. Sequential Digits (Medium)](https://leetcode.com/problems/sequential-digits "顺次数") @@ -31,7 +31,7 @@ ### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Hints
diff --git a/problems/serialize-and-deserialize-binary-tree/README.md b/problems/serialize-and-deserialize-binary-tree/README.md index 839b482f4..8a9db3e25 100644 --- a/problems/serialize-and-deserialize-binary-tree/README.md +++ b/problems/serialize-and-deserialize-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/best-meeting-point "Best Meeting Point") +[< Previous](../best-meeting-point "Best Meeting Point")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-tree-longest-consecutive-sequence "Binary Tree Longest Consecutive Sequence") +[Next >](../binary-tree-longest-consecutive-sequence "Binary Tree Longest Consecutive Sequence") ## [297. Serialize and Deserialize Binary Tree (Hard)](https://leetcode.com/problems/serialize-and-deserialize-binary-tree "二叉树的序列化与反序列化") @@ -34,11 +34,11 @@ as "[1,2,3,null,null,4,5]"

Note: Do not use class member/global/static variables to store states. Your serialize and deserialize algorithms should be stateless.

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions - 1. [Encode and Decode Strings](https://github.com/openset/leetcode/tree/master/problems/encode-and-decode-strings) (Medium) - 1. [Serialize and Deserialize BST](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-bst) (Medium) - 1. [Find Duplicate Subtrees](https://github.com/openset/leetcode/tree/master/problems/find-duplicate-subtrees) (Medium) - 1. [Serialize and Deserialize N-ary Tree](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-n-ary-tree) (Hard) + 1. [Encode and Decode Strings](../encode-and-decode-strings) (Medium) + 1. [Serialize and Deserialize BST](../serialize-and-deserialize-bst) (Medium) + 1. [Find Duplicate Subtrees](../find-duplicate-subtrees) (Medium) + 1. [Serialize and Deserialize N-ary Tree](../serialize-and-deserialize-n-ary-tree) (Hard) diff --git a/problems/serialize-and-deserialize-bst/README.md b/problems/serialize-and-deserialize-bst/README.md index 774273e13..254f98ab9 100644 --- a/problems/serialize-and-deserialize-bst/README.md +++ b/problems/serialize-and-deserialize-bst/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-all-numbers-disappeared-in-an-array "Find All Numbers Disappeared in an Array") +[< Previous](../find-all-numbers-disappeared-in-an-array "Find All Numbers Disappeared in an Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/delete-node-in-a-bst "Delete Node in a BST") +[Next >](../delete-node-in-a-bst "Delete Node in a BST") ## [449. Serialize and Deserialize BST (Medium)](https://leetcode.com/problems/serialize-and-deserialize-bst "序列化和反序列化二叉搜索树") @@ -20,9 +20,9 @@

Note: Do not use class member/global/static variables to store states. Your serialize and deserialize algorithms should be stateless.

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Serialize and Deserialize Binary Tree](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-binary-tree) (Hard) - 1. [Find Duplicate Subtrees](https://github.com/openset/leetcode/tree/master/problems/find-duplicate-subtrees) (Medium) - 1. [Serialize and Deserialize N-ary Tree](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-n-ary-tree) (Hard) + 1. [Serialize and Deserialize Binary Tree](../serialize-and-deserialize-binary-tree) (Hard) + 1. [Find Duplicate Subtrees](../find-duplicate-subtrees) (Medium) + 1. [Serialize and Deserialize N-ary Tree](../serialize-and-deserialize-n-ary-tree) (Hard) diff --git a/problems/serialize-and-deserialize-n-ary-tree/README.md b/problems/serialize-and-deserialize-n-ary-tree/README.md index 6fe49b453..cb66a80a8 100644 --- a/problems/serialize-and-deserialize-n-ary-tree/README.md +++ b/problems/serialize-and-deserialize-n-ary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/construct-quad-tree "Construct Quad Tree") +[< Previous](../construct-quad-tree "Construct Quad Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-level-order-traversal "N-ary Tree Level Order Traversal") +[Next >](../n-ary-tree-level-order-traversal "N-ary Tree Level Order Traversal") ## [428. Serialize and Deserialize N-ary Tree (Hard)](https://leetcode.com/problems/serialize-and-deserialize-n-ary-tree "序列化和反序列化 N 叉树") @@ -35,9 +35,9 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Serialize and Deserialize Binary Tree](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-binary-tree) (Hard) - 1. [Serialize and Deserialize BST](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-bst) (Medium) - 1. [Encode N-ary Tree to Binary Tree](https://github.com/openset/leetcode/tree/master/problems/encode-n-ary-tree-to-binary-tree) (Hard) + 1. [Serialize and Deserialize Binary Tree](../serialize-and-deserialize-binary-tree) (Hard) + 1. [Serialize and Deserialize BST](../serialize-and-deserialize-bst) (Medium) + 1. [Encode N-ary Tree to Binary Tree](../encode-n-ary-tree-to-binary-tree) (Hard) diff --git a/problems/set-intersection-size-at-least-two/README.md b/problems/set-intersection-size-at-least-two/README.md index 5e31e5660..1e96a4568 100644 --- a/problems/set-intersection-size-at-least-two/README.md +++ b/problems/set-intersection-size-at-least-two/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/pyramid-transition-matrix "Pyramid Transition Matrix") +[< Previous](../pyramid-transition-matrix "Pyramid Transition Matrix")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/bold-words-in-string "Bold Words in String") +[Next >](../bold-words-in-string "Bold Words in String") ## [757. Set Intersection Size At Least Two (Hard)](https://leetcode.com/problems/set-intersection-size-at-least-two " 设置交集大小至少为2") @@ -44,4 +44,4 @@ An example of a minimum sized set is {1, 2, 3, 4, 5}.

### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/set-matrix-zeroes/README.md b/problems/set-matrix-zeroes/README.md index 1b09a82e9..3ea8fd55c 100644 --- a/problems/set-matrix-zeroes/README.md +++ b/problems/set-matrix-zeroes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/edit-distance "Edit Distance") +[< Previous](../edit-distance "Edit Distance")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/search-a-2d-matrix "Search a 2D Matrix") +[Next >](../search-a-2d-matrix "Search a 2D Matrix") ## [73. Set Matrix Zeroes (Medium)](https://leetcode.com/problems/set-matrix-zeroes "矩阵置零") @@ -56,10 +56,10 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Game of Life](https://github.com/openset/leetcode/tree/master/problems/game-of-life) (Medium) + 1. [Game of Life](../game-of-life) (Medium) ### Hints
diff --git a/problems/set-mismatch/README.md b/problems/set-mismatch/README.md index 6b7304a8f..49bb9d549 100644 --- a/problems/set-mismatch/README.md +++ b/problems/set-mismatch/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-average-subarray-ii "Maximum Average Subarray II") +[< Previous](../maximum-average-subarray-ii "Maximum Average Subarray II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-pair-chain "Maximum Length of Pair Chain") +[Next >](../maximum-length-of-pair-chain "Maximum Length of Pair Chain") ## [645. Set Mismatch (Easy)](https://leetcode.com/problems/set-mismatch "错误的集合") @@ -35,8 +35,8 @@ Given an array nums representing the data status of this set after

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Find the Duplicate Number](https://github.com/openset/leetcode/tree/master/problems/find-the-duplicate-number) (Medium) + 1. [Find the Duplicate Number](../find-the-duplicate-number) (Medium) diff --git a/problems/shift-2d-grid/README.md b/problems/shift-2d-grid/README.md index 94bc194bc..e211a7e43 100644 --- a/problems/shift-2d-grid/README.md +++ b/problems/shift-2d-grid/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/handshakes-that-dont-cross "Handshakes That Don't Cross") +[< Previous](../handshakes-that-dont-cross "Handshakes That Don't Cross")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-elements-in-a-contaminated-binary-tree "Find Elements in a Contaminated Binary Tree") +[Next >](../find-elements-in-a-contaminated-binary-tree "Find Elements in a Contaminated Binary Tree") ## [1260. Shift 2D Grid (Easy)](https://leetcode.com/problems/shift-2d-grid "二维网格迁移") @@ -58,7 +58,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/shifting-letters/README.md b/problems/shifting-letters/README.md index ad1ce0a73..e33117192 100644 --- a/problems/shifting-letters/README.md +++ b/problems/shifting-letters/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-path-visiting-all-nodes "Shortest Path Visiting All Nodes") +[< Previous](../shortest-path-visiting-all-nodes "Shortest Path Visiting All Nodes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximize-distance-to-closest-person "Maximize Distance to Closest Person") +[Next >](../maximize-distance-to-closest-person "Maximize Distance to Closest Person") ## [848. Shifting Letters (Medium)](https://leetcode.com/problems/shifting-letters "字母移位") @@ -41,4 +41,4 @@ After shifting the first 3 letters of S by 9, we have "rpl", the answe ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/shopping-offers/README.md b/problems/shopping-offers/README.md index cc17dff08..029e7fe4e 100644 --- a/problems/shopping-offers/README.md +++ b/problems/shopping-offers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/average-of-levels-in-binary-tree "Average of Levels in Binary Tree") +[< Previous](../average-of-levels-in-binary-tree "Average of Levels in Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/decode-ways-ii "Decode Ways II") +[Next >](../decode-ways-ii "Decode Ways II") ## [638. Shopping Offers (Medium)](https://leetcode.com/problems/shopping-offers "大礼包") @@ -63,5 +63,5 @@ You cannot add more items, though only $9 for 2A ,2B and 1C.

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/short-encoding-of-words/README.md b/problems/short-encoding-of-words/README.md index ee2d7e0a5..a3c915941 100644 --- a/problems/short-encoding-of-words/README.md +++ b/problems/short-encoding-of-words/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/most-common-word "Most Common Word") +[< Previous](../most-common-word "Most Common Word")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-to-a-character "Shortest Distance to a Character") +[Next >](../shortest-distance-to-a-character "Shortest Distance to a Character") ## [820. Short Encoding of Words (Medium)](https://leetcode.com/problems/short-encoding-of-words "单词的压缩编码") diff --git a/problems/shortest-bridge/README.md b/problems/shortest-bridge/README.md index 260f0a91a..48adaccaa 100644 --- a/problems/shortest-bridge/README.md +++ b/problems/shortest-bridge/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-recent-calls "Number of Recent Calls") +[< Previous](../number-of-recent-calls "Number of Recent Calls")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/knight-dialer "Knight Dialer") +[Next >](../knight-dialer "Knight Dialer") ## [934. Shortest Bridge (Medium)](https://leetcode.com/problems/shortest-bridge "最短的桥") @@ -59,5 +59,5 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/shortest-common-supersequence/README.md b/problems/shortest-common-supersequence/README.md index 39c7ff71a..21f17617a 100644 --- a/problems/shortest-common-supersequence/README.md +++ b/problems/shortest-common-supersequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-path-in-binary-matrix "Shortest Path in Binary Matrix") +[< Previous](../shortest-path-in-binary-matrix "Shortest Path in Binary Matrix")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/statistics-from-a-large-sample "Statistics from a Large Sample") +[Next >](../statistics-from-a-large-sample "Statistics from a Large Sample") ## [1092. Shortest Common Supersequence (Hard)](https://leetcode.com/problems/shortest-common-supersequence "最短公共超序列") @@ -38,7 +38,7 @@ The answer provided is the shortest such string that satisfies these properties. ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/shortest-completing-word/README.md b/problems/shortest-completing-word/README.md index c77c4c671..045d2ae78 100644 --- a/problems/shortest-completing-word/README.md +++ b/problems/shortest-completing-word/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/largest-number-at-least-twice-of-others "Largest Number At Least Twice of Others") +[< Previous](../largest-number-at-least-twice-of-others "Largest Number At Least Twice of Others")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/contain-virus "Contain Virus") +[Next >](../contain-virus "Contain Virus") ## [748. Shortest Completing Word (Easy)](https://leetcode.com/problems/shortest-completing-word "最短完整词") @@ -50,7 +50,7 @@ We return the one that occurred first.

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
diff --git a/problems/shortest-distance-from-all-buildings/README.md b/problems/shortest-distance-from-all-buildings/README.md index 187eb8d10..fc39bd92a 100644 --- a/problems/shortest-distance-from-all-buildings/README.md +++ b/problems/shortest-distance-from-all-buildings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-duplicate-letters "Remove Duplicate Letters") +[< Previous](../remove-duplicate-letters "Remove Duplicate Letters")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-product-of-word-lengths "Maximum Product of Word Lengths") +[Next >](../maximum-product-of-word-lengths "Maximum Product of Word Lengths") ## [317. Shortest Distance from All Buildings (Hard)](https://leetcode.com/problems/shortest-distance-from-all-buildings "离建筑物最近的距离") @@ -40,9 +40,9 @@ There will be at least one building. If it is not possible to build such house according to the above rules, return -1.

### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions - 1. [Walls and Gates](https://github.com/openset/leetcode/tree/master/problems/walls-and-gates) (Medium) - 1. [Best Meeting Point](https://github.com/openset/leetcode/tree/master/problems/best-meeting-point) (Hard) - 1. [As Far from Land as Possible](https://github.com/openset/leetcode/tree/master/problems/as-far-from-land-as-possible) (Medium) + 1. [Walls and Gates](../walls-and-gates) (Medium) + 1. [Best Meeting Point](../best-meeting-point) (Hard) + 1. [As Far from Land as Possible](../as-far-from-land-as-possible) (Medium) diff --git a/problems/shortest-distance-in-a-line/README.md b/problems/shortest-distance-in-a-line/README.md index ce7c1d9d7..e81181f78 100644 --- a/problems/shortest-distance-in-a-line/README.md +++ b/problems/shortest-distance-in-a-line/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-in-a-plane "Shortest Distance in a Plane") +[< Previous](../shortest-distance-in-a-plane "Shortest Distance in a Plane")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/second-degree-follower "Second Degree Follower") +[Next >](../second-degree-follower "Second Degree Follower") ## [613. Shortest Distance in a Line (Easy)](https://leetcode.com/problems/shortest-distance-in-a-line "直线上的最近距离") diff --git a/problems/shortest-distance-in-a-plane/README.md b/problems/shortest-distance-in-a-plane/README.md index 46d62568c..aabfdb2ba 100644 --- a/problems/shortest-distance-in-a-plane/README.md +++ b/problems/shortest-distance-in-a-plane/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-triangle-number "Valid Triangle Number") +[< Previous](../valid-triangle-number "Valid Triangle Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-in-a-line "Shortest Distance in a Line") +[Next >](../shortest-distance-in-a-line "Shortest Distance in a Line") ## [612. Shortest Distance in a Plane (Medium)](https://leetcode.com/problems/shortest-distance-in-a-plane "平面上的最近距离") diff --git a/problems/shortest-distance-to-a-character/README.md b/problems/shortest-distance-to-a-character/README.md index 1c714fc50..c9fb378ac 100644 --- a/problems/shortest-distance-to-a-character/README.md +++ b/problems/shortest-distance-to-a-character/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/short-encoding-of-words "Short Encoding of Words") +[< Previous](../short-encoding-of-words "Short Encoding of Words")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/card-flipping-game "Card Flipping Game") +[Next >](../card-flipping-game "Card Flipping Game") ## [821. Shortest Distance to a Character (Easy)](https://leetcode.com/problems/shortest-distance-to-a-character "字符的最短距离") diff --git a/problems/shortest-distance-to-target-color/README.md b/problems/shortest-distance-to-target-color/README.md index 1c10cc5f0..dc9d88932 100644 --- a/problems/shortest-distance-to-target-color/README.md +++ b/problems/shortest-distance-to-target-color/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/before-and-after-puzzle "Before and After Puzzle") +[< Previous](../before-and-after-puzzle "Before and After Puzzle")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-number-of-ones "Maximum Number of Ones") +[Next >](../maximum-number-of-ones "Maximum Number of Ones") ## [1182. Shortest Distance to Target Color (Medium)](https://leetcode.com/problems/shortest-distance-to-target-color "与目标颜色间的最短距离") @@ -48,7 +48,7 @@ The nearest 1 from index 6 is at index 3 (3 steps away). ### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
diff --git a/problems/shortest-palindrome/README.md b/problems/shortest-palindrome/README.md index 4c169b39f..fc6cd92fc 100644 --- a/problems/shortest-palindrome/README.md +++ b/problems/shortest-palindrome/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/house-robber-ii "House Robber II") +[< Previous](../house-robber-ii "House Robber II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/kth-largest-element-in-an-array "Kth Largest Element in an Array") +[Next >](../kth-largest-element-in-an-array "Kth Largest Element in an Array") ## [214. Shortest Palindrome (Hard)](https://leetcode.com/problems/shortest-palindrome "最短回文串") @@ -27,9 +27,9 @@ Output: "dcbabcd" ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Longest Palindromic Substring](https://github.com/openset/leetcode/tree/master/problems/longest-palindromic-substring) (Medium) - 1. [Implement strStr()](https://github.com/openset/leetcode/tree/master/problems/implement-strstr) (Easy) - 1. [Palindrome Pairs](https://github.com/openset/leetcode/tree/master/problems/palindrome-pairs) (Hard) + 1. [Longest Palindromic Substring](../longest-palindromic-substring) (Medium) + 1. [Implement strStr()](../implement-strstr) (Easy) + 1. [Palindrome Pairs](../palindrome-pairs) (Hard) diff --git a/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md b/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md index 81daf94db..59f261ac0 100644 --- a/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md +++ b/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md @@ -5,7 +5,7 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold "Maximum Side Length of a Square with Sum Less than or Equal to Threshold") +[< Previous](../maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold "Maximum Side Length of a Square with Sum Less than or Equal to Threshold")                  Next > @@ -62,7 +62,7 @@ k = 1 ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Hints
diff --git a/problems/shortest-path-in-binary-matrix/README.md b/problems/shortest-path-in-binary-matrix/README.md index 3e805ecb2..aa9ac7b98 100644 --- a/problems/shortest-path-in-binary-matrix/README.md +++ b/problems/shortest-path-in-binary-matrix/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/largest-values-from-labels "Largest Values From Labels") +[< Previous](../largest-values-from-labels "Largest Values From Labels")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-common-supersequence "Shortest Common Supersequence ") +[Next >](../shortest-common-supersequence "Shortest Common Supersequence ") ## [1091. Shortest Path in Binary Matrix (Medium)](https://leetcode.com/problems/shortest-path-in-binary-matrix "二进制矩阵中的最短路径") @@ -58,7 +58,7 @@ ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Hints
diff --git a/problems/shortest-path-to-get-all-keys/README.md b/problems/shortest-path-to-get-all-keys/README.md index 5c3934946..cd6411533 100644 --- a/problems/shortest-path-to-get-all-keys/README.md +++ b/problems/shortest-path-to-get-all-keys/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/all-nodes-distance-k-in-binary-tree "All Nodes Distance K in Binary Tree") +[< Previous](../all-nodes-distance-k-in-binary-tree "All Nodes Distance K in Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/smallest-subtree-with-all-the-deepest-nodes "Smallest Subtree with all the Deepest Nodes") +[Next >](../smallest-subtree-with-all-the-deepest-nodes "Smallest Subtree with all the Deepest Nodes") ## [864. Shortest Path to Get All Keys (Hard)](https://leetcode.com/problems/shortest-path-to-get-all-keys "获取所有钥匙的最短路径") @@ -51,5 +51,5 @@ ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/shortest-path-visiting-all-nodes/README.md b/problems/shortest-path-visiting-all-nodes/README.md index 6bc36d4f8..9cbcc6800 100644 --- a/problems/shortest-path-visiting-all-nodes/README.md +++ b/problems/shortest-path-visiting-all-nodes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/hand-of-straights "Hand of Straights") +[< Previous](../hand-of-straights "Hand of Straights")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shifting-letters "Shifting Letters") +[Next >](../shifting-letters "Shifting Letters") ## [847. Shortest Path Visiting All Nodes (Hard)](https://leetcode.com/problems/shortest-path-visiting-all-nodes "访问所有节点的最短路径") @@ -47,5 +47,5 @@ ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/shortest-path-with-alternating-colors/README.md b/problems/shortest-path-with-alternating-colors/README.md index 3c5da4d1a..1d43b3d73 100644 --- a/problems/shortest-path-with-alternating-colors/README.md +++ b/problems/shortest-path-with-alternating-colors/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-equivalent-domino-pairs "Number of Equivalent Domino Pairs") +[< Previous](../number-of-equivalent-domino-pairs "Number of Equivalent Domino Pairs")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-tree-from-leaf-values "Minimum Cost Tree From Leaf Values") +[Next >](../minimum-cost-tree-from-leaf-values "Minimum Cost Tree From Leaf Values") ## [1129. Shortest Path with Alternating Colors (Medium)](https://leetcode.com/problems/shortest-path-with-alternating-colors "颜色交替的最短路径") @@ -46,8 +46,8 @@ ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] ### Hints
diff --git a/problems/shortest-subarray-with-sum-at-least-k/README.md b/problems/shortest-subarray-with-sum-at-least-k/README.md index 0f38bdfa5..8864d9c5d 100644 --- a/problems/shortest-subarray-with-sum-at-least-k/README.md +++ b/problems/shortest-subarray-with-sum-at-least-k/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/score-after-flipping-matrix "Score After Flipping Matrix") +[< Previous](../score-after-flipping-matrix "Score After Flipping Matrix")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/all-nodes-distance-k-in-binary-tree "All Nodes Distance K in Binary Tree") +[Next >](../all-nodes-distance-k-in-binary-tree "All Nodes Distance K in Binary Tree") ## [862. Shortest Subarray with Sum at Least K (Hard)](https://leetcode.com/problems/shortest-subarray-with-sum-at-least-k "和至少为 K 的最短子数组") @@ -58,5 +58,5 @@ ### Related Topics - [[Queue](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Queue](../../tag/queue/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/shortest-unsorted-continuous-subarray/README.md b/problems/shortest-unsorted-continuous-subarray/README.md index a29f202eb..fcdd6de27 100644 --- a/problems/shortest-unsorted-continuous-subarray/README.md +++ b/problems/shortest-unsorted-continuous-subarray/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/count-student-number-in-departments "Count Student Number in Departments") +[< Previous](../count-student-number-in-departments "Count Student Number in Departments")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/kill-process "Kill Process") +[Next >](../kill-process "Kill Process") ## [581. Shortest Unsorted Continuous Subarray (Easy)](https://leetcode.com/problems/shortest-unsorted-continuous-subarray "最短无序连续子数组") @@ -31,4 +31,4 @@

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/shortest-way-to-form-string/README.md b/problems/shortest-way-to-form-string/README.md index def04c26d..592d2ca7e 100644 --- a/problems/shortest-way-to-form-string/README.md +++ b/problems/shortest-way-to-form-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/distant-barcodes "Distant Barcodes") +[< Previous](../distant-barcodes "Distant Barcodes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/confusing-number "Confusing Number") +[Next >](../confusing-number "Confusing Number") ## [1055. Shortest Way to Form String (Medium)](https://leetcode.com/problems/shortest-way-to-form-string "形成字符串的最短路径") @@ -51,11 +51,11 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Is Subsequence](https://github.com/openset/leetcode/tree/master/problems/is-subsequence) (Easy) + 1. [Is Subsequence](../is-subsequence) (Easy) ### Hints
diff --git a/problems/shortest-word-distance-ii/README.md b/problems/shortest-word-distance-ii/README.md index 5394c03f5..ece760c67 100644 --- a/problems/shortest-word-distance-ii/README.md +++ b/problems/shortest-word-distance-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance "Shortest Word Distance") +[< Previous](../shortest-word-distance "Shortest Word Distance")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance-iii "Shortest Word Distance III") +[Next >](../shortest-word-distance-iii "Shortest Word Distance III") ## [244. Shortest Word Distance II (Medium)](https://leetcode.com/problems/shortest-word-distance-ii "最短单词距离 II") @@ -27,10 +27,10 @@ Assume that words = ["practice", "makes", "perfec You may assume that word1 does not equal to word2, and word1 and word2 are both in the list.

### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Merge Two Sorted Lists](https://github.com/openset/leetcode/tree/master/problems/merge-two-sorted-lists) (Easy) - 1. [Shortest Word Distance](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance) (Easy) - 1. [Shortest Word Distance III](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance-iii) (Medium) + 1. [Merge Two Sorted Lists](../merge-two-sorted-lists) (Easy) + 1. [Shortest Word Distance](../shortest-word-distance) (Easy) + 1. [Shortest Word Distance III](../shortest-word-distance-iii) (Medium) diff --git a/problems/shortest-word-distance-iii/README.md b/problems/shortest-word-distance-iii/README.md index 5516a4a63..de413094c 100644 --- a/problems/shortest-word-distance-iii/README.md +++ b/problems/shortest-word-distance-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance-ii "Shortest Word Distance II") +[< Previous](../shortest-word-distance-ii "Shortest Word Distance II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number "Strobogrammatic Number") +[Next >](../strobogrammatic-number "Strobogrammatic Number") ## [245. Shortest Word Distance III (Medium)](https://leetcode.com/problems/shortest-word-distance-iii "最短单词距离 III") @@ -32,8 +32,8 @@ Assume that words = ["practice", "makes", "perfec You may assume word1 and word2 are both in the list.

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Shortest Word Distance](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance) (Easy) - 1. [Shortest Word Distance II](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance-ii) (Medium) + 1. [Shortest Word Distance](../shortest-word-distance) (Easy) + 1. [Shortest Word Distance II](../shortest-word-distance-ii) (Medium) diff --git a/problems/shortest-word-distance/README.md b/problems/shortest-word-distance/README.md index a66b4ee8e..5523931ee 100644 --- a/problems/shortest-word-distance/README.md +++ b/problems/shortest-word-distance/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-anagram "Valid Anagram") +[< Previous](../valid-anagram "Valid Anagram")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance-ii "Shortest Word Distance II") +[Next >](../shortest-word-distance-ii "Shortest Word Distance II") ## [243. Shortest Word Distance (Easy)](https://leetcode.com/problems/shortest-word-distance "最短单词距离") @@ -30,8 +30,8 @@ Assume that words = ["practice", "makes", "perfec You may assume that word1 does not equal to word2, and word1 and word2 are both in the list.

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Shortest Word Distance II](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance-ii) (Medium) - 1. [Shortest Word Distance III](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance-iii) (Medium) + 1. [Shortest Word Distance II](../shortest-word-distance-ii) (Medium) + 1. [Shortest Word Distance III](../shortest-word-distance-iii) (Medium) diff --git a/problems/shuffle-an-array/README.md b/problems/shuffle-an-array/README.md index 4967f053e..0600b6030 100644 --- a/problems/shuffle-an-array/README.md +++ b/problems/shuffle-an-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/ransom-note "Ransom Note") +[< Previous](../ransom-note "Ransom Note")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/mini-parser "Mini Parser") +[Next >](../mini-parser "Mini Parser") ## [384. Shuffle an Array (Medium)](https://leetcode.com/problems/shuffle-an-array "打乱数组") diff --git a/problems/similar-rgb-color/README.md b/problems/similar-rgb-color/README.md index b5de81000..a70381508 100644 --- a/problems/similar-rgb-color/README.md +++ b/problems/similar-rgb-color/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/champagne-tower "Champagne Tower") +[< Previous](../champagne-tower "Champagne Tower")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-swaps-to-make-sequences-increasing "Minimum Swaps To Make Sequences Increasing") +[Next >](../minimum-swaps-to-make-sequences-increasing "Minimum Swaps To Make Sequences Increasing") ## [800. Similar RGB Color (Easy)](https://leetcode.com/problems/similar-rgb-color "相似 RGB 颜色") @@ -38,5 +38,5 @@ This is the highest among any shorthand color. ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/similar-string-groups/README.md b/problems/similar-string-groups/README.md index 485e93fcd..2823d4505 100644 --- a/problems/similar-string-groups/README.md +++ b/problems/similar-string-groups/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/push-dominoes "Push Dominoes") +[< Previous](../push-dominoes "Push Dominoes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/magic-squares-in-grid "Magic Squares In Grid") +[Next >](../magic-squares-in-grid "Magic Squares In Grid") ## [839. Similar String Groups (Hard)](https://leetcode.com/problems/similar-string-groups "相似字符串组") @@ -37,6 +37,6 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] diff --git a/problems/simplify-path/README.md b/problems/simplify-path/README.md index d2f043c69..d321a7840 100644 --- a/problems/simplify-path/README.md +++ b/problems/simplify-path/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/climbing-stairs "Climbing Stairs") +[< Previous](../climbing-stairs "Climbing Stairs")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/edit-distance "Edit Distance") +[Next >](../edit-distance "Edit Distance") ## [71. Simplify Path (Medium)](https://leetcode.com/problems/simplify-path "简化路径") @@ -65,5 +65,5 @@ ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/single-element-in-a-sorted-array/README.md b/problems/single-element-in-a-sorted-array/README.md index 4fb75deb3..72e0941e2 100644 --- a/problems/single-element-in-a-sorted-array/README.md +++ b/problems/single-element-in-a-sorted-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-time-difference "Minimum Time Difference") +[< Previous](../minimum-time-difference "Minimum Time Difference")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reverse-string-ii "Reverse String II") +[Next >](../reverse-string-ii "Reverse String II") ## [540. Single Element in a Sorted Array (Medium)](https://leetcode.com/problems/single-element-in-a-sorted-array "有序数组中的单一元素") diff --git a/problems/single-number-ii/README.md b/problems/single-number-ii/README.md index 02aad374a..cd578e54b 100644 --- a/problems/single-number-ii/README.md +++ b/problems/single-number-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/single-number "Single Number") +[< Previous](../single-number "Single Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/copy-list-with-random-pointer "Copy List with Random Pointer") +[Next >](../copy-list-with-random-pointer "Copy List with Random Pointer") ## [137. Single Number II (Medium)](https://leetcode.com/problems/single-number-ii "只出现一次的数字 II") @@ -31,8 +31,8 @@ Output: 99 ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions - 1. [Single Number](https://github.com/openset/leetcode/tree/master/problems/single-number) (Easy) - 1. [Single Number III](https://github.com/openset/leetcode/tree/master/problems/single-number-iii) (Medium) + 1. [Single Number](../single-number) (Easy) + 1. [Single Number III](../single-number-iii) (Medium) diff --git a/problems/single-number-iii/README.md b/problems/single-number-iii/README.md index e2e795866..005a7c376 100644 --- a/problems/single-number-iii/README.md +++ b/problems/single-number-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/3sum-smaller "3Sum Smaller") +[< Previous](../3sum-smaller "3Sum Smaller")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/graph-valid-tree "Graph Valid Tree") +[Next >](../graph-valid-tree "Graph Valid Tree") ## [260. Single Number III (Medium)](https://leetcode.com/problems/single-number-iii "只出现一次的数字 III") @@ -27,8 +27,8 @@ ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions - 1. [Single Number](https://github.com/openset/leetcode/tree/master/problems/single-number) (Easy) - 1. [Single Number II](https://github.com/openset/leetcode/tree/master/problems/single-number-ii) (Medium) + 1. [Single Number](../single-number) (Easy) + 1. [Single Number II](../single-number-ii) (Medium) diff --git a/problems/single-number/README.md b/problems/single-number/README.md index d9eaa60a0..b9e4ca162 100644 --- a/problems/single-number/README.md +++ b/problems/single-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/candy "Candy") +[< Previous](../candy "Candy")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/single-number-ii "Single Number II") +[Next >](../single-number-ii "Single Number II") ## [136. Single Number (Easy)](https://leetcode.com/problems/single-number "只出现一次的数字") @@ -32,12 +32,12 @@ ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Single Number II](https://github.com/openset/leetcode/tree/master/problems/single-number-ii) (Medium) - 1. [Single Number III](https://github.com/openset/leetcode/tree/master/problems/single-number-iii) (Medium) - 1. [Missing Number](https://github.com/openset/leetcode/tree/master/problems/missing-number) (Easy) - 1. [Find the Duplicate Number](https://github.com/openset/leetcode/tree/master/problems/find-the-duplicate-number) (Medium) - 1. [Find the Difference](https://github.com/openset/leetcode/tree/master/problems/find-the-difference) (Easy) + 1. [Single Number II](../single-number-ii) (Medium) + 1. [Single Number III](../single-number-iii) (Medium) + 1. [Missing Number](../missing-number) (Easy) + 1. [Find the Duplicate Number](../find-the-duplicate-number) (Medium) + 1. [Find the Difference](../find-the-difference) (Easy) diff --git a/problems/single-row-keyboard/README.md b/problems/single-row-keyboard/README.md index ff0e3c1f5..d54f02d4d 100644 --- a/problems/single-row-keyboard/README.md +++ b/problems/single-row-keyboard/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/product-price-at-a-given-date "Product Price at a Given Date") +[< Previous](../product-price-at-a-given-date "Product Price at a Given Date")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-file-system "Design File System") +[Next >](../design-file-system "Design File System") ## [1165. Single-Row Keyboard (Easy)](https://leetcode.com/problems/single-row-keyboard "单行键盘") @@ -45,7 +45,7 @@ Total time = 2 + 1 + 1 = 4. ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/sliding-puzzle/README.md b/problems/sliding-puzzle/README.md index b90bf71d6..f27971d81 100644 --- a/problems/sliding-puzzle/README.md +++ b/problems/sliding-puzzle/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iii "Basic Calculator III") +[< Previous](../basic-calculator-iii "Basic Calculator III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimize-max-distance-to-gas-station "Minimize Max Distance to Gas Station") +[Next >](../minimize-max-distance-to-gas-station "Minimize Max Distance to Gas Station") ## [773. Sliding Puzzle (Hard)](https://leetcode.com/problems/sliding-puzzle "滑动谜题") @@ -59,7 +59,7 @@ After move 5: [[1,2,3],[4,5,0]] ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Hints
diff --git a/problems/sliding-window-maximum/README.md b/problems/sliding-window-maximum/README.md index 0976d4e33..442c5496a 100644 --- a/problems/sliding-window-maximum/README.md +++ b/problems/sliding-window-maximum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/product-of-array-except-self "Product of Array Except Self") +[< Previous](../product-of-array-except-self "Product of Array Except Self")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/search-a-2d-matrix-ii "Search a 2D Matrix II") +[Next >](../search-a-2d-matrix-ii "Search a 2D Matrix II") ## [239. Sliding Window Maximum (Hard)](https://leetcode.com/problems/sliding-window-maximum "滑动窗口最大值") @@ -37,14 +37,14 @@ You may assume k is always valid, 1 ≤ k ≤ input array's size Could you solve it in linear time?

### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions - 1. [Minimum Window Substring](https://github.com/openset/leetcode/tree/master/problems/minimum-window-substring) (Hard) - 1. [Min Stack](https://github.com/openset/leetcode/tree/master/problems/min-stack) (Easy) - 1. [Longest Substring with At Most Two Distinct Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters) (Medium) - 1. [Paint House II](https://github.com/openset/leetcode/tree/master/problems/paint-house-ii) (Hard) + 1. [Minimum Window Substring](../minimum-window-substring) (Hard) + 1. [Min Stack](../min-stack) (Easy) + 1. [Longest Substring with At Most Two Distinct Characters](../longest-substring-with-at-most-two-distinct-characters) (Medium) + 1. [Paint House II](../paint-house-ii) (Hard) ### Hints
diff --git a/problems/sliding-window-median/README.md b/problems/sliding-window-median/README.md index b8223a8d9..6f6b6e780 100644 --- a/problems/sliding-window-median/README.md +++ b/problems/sliding-window-median/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/largest-palindrome-product "Largest Palindrome Product") +[< Previous](../largest-palindrome-product "Largest Palindrome Product")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/magical-string "Magical String") +[Next >](../magical-string "Magical String") ## [480. Sliding Window Median (Hard)](https://leetcode.com/problems/sliding-window-median "滑动窗口中位数") @@ -38,10 +38,10 @@ Window position Median You may assume k is always valid, ie: k is always smaller than input array's size for non-empty array.

### Related Topics - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions - 1. [Find Median from Data Stream](https://github.com/openset/leetcode/tree/master/problems/find-median-from-data-stream) (Hard) + 1. [Find Median from Data Stream](../find-median-from-data-stream) (Hard) ### Hints
diff --git a/problems/smallest-common-region/README.md b/problems/smallest-common-region/README.md index 282e69cbc..065a79db2 100644 --- a/problems/smallest-common-region/README.md +++ b/problems/smallest-common-region/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/encode-number "Encode Number") +[< Previous](../encode-number "Encode Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/synonymous-sentences "Synonymous Sentences") +[Next >](../synonymous-sentences "Synonymous Sentences") ## [1257. Smallest Common Region (Medium)](https://leetcode.com/problems/smallest-common-region "最小公共区域") @@ -46,11 +46,11 @@ region2 = "New York" ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Lowest Common Ancestor of a Binary Search Tree](https://github.com/openset/leetcode/tree/master/problems/lowest-common-ancestor-of-a-binary-search-tree) (Easy) - 1. [Lowest Common Ancestor of a Binary Tree](https://github.com/openset/leetcode/tree/master/problems/lowest-common-ancestor-of-a-binary-tree) (Medium) + 1. [Lowest Common Ancestor of a Binary Search Tree](../lowest-common-ancestor-of-a-binary-search-tree) (Easy) + 1. [Lowest Common Ancestor of a Binary Tree](../lowest-common-ancestor-of-a-binary-tree) (Medium) ### Hints
diff --git a/problems/smallest-good-base/README.md b/problems/smallest-good-base/README.md index 8cb829d8d..57031804d 100644 --- a/problems/smallest-good-base/README.md +++ b/problems/smallest-good-base/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/license-key-formatting "License Key Formatting") +[< Previous](../license-key-formatting "License Key Formatting")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-permutation "Find Permutation") +[Next >](../find-permutation "Find Permutation") ## [483. Smallest Good Base (Hard)](https://leetcode.com/problems/smallest-good-base "最小好进制") @@ -55,5 +55,5 @@

 

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/smallest-integer-divisible-by-k/README.md b/problems/smallest-integer-divisible-by-k/README.md index 4b56149a4..92ccb4cba 100644 --- a/problems/smallest-integer-divisible-by-k/README.md +++ b/problems/smallest-integer-divisible-by-k/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/best-sightseeing-pair "Best Sightseeing Pair") +[< Previous](../best-sightseeing-pair "Best Sightseeing Pair")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-string-with-substrings-representing-1-to-n "Binary String With Substrings Representing 1 To N") +[Next >](../binary-string-with-substrings-representing-1-to-n "Binary String With Substrings Representing 1 To N") ## [1015. Smallest Integer Divisible by K (Medium)](https://leetcode.com/problems/smallest-integer-divisible-by-k "可被 K 整除的最小整数") @@ -47,7 +47,7 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/smallest-range-covering-elements-from-k-lists/README.md b/problems/smallest-range-covering-elements-from-k-lists/README.md index b620a8a3f..ff1d523e8 100644 --- a/problems/smallest-range-covering-elements-from-k-lists/README.md +++ b/problems/smallest-range-covering-elements-from-k-lists/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-excel-sum-formula "Design Excel Sum Formula") +[< Previous](../design-excel-sum-formula "Design Excel Sum Formula")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sum-of-square-numbers "Sum of Square Numbers") +[Next >](../sum-of-square-numbers "Sum of Square Numbers") ## [632. Smallest Range Covering Elements from K Lists (Hard)](https://leetcode.com/problems/smallest-range-covering-elements-from-k-lists "最小区间") @@ -39,6 +39,6 @@ List 3: [5, 18, 22, 30], 22 is in range [20,24]. ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/smallest-range-i/README.md b/problems/smallest-range-i/README.md index e9786f635..410fbc31f 100644 --- a/problems/smallest-range-i/README.md +++ b/problems/smallest-range-i/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sum-of-subarray-minimums "Sum of Subarray Minimums") +[< Previous](../sum-of-subarray-minimums "Sum of Subarray Minimums")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/snakes-and-ladders "Snakes and Ladders") +[Next >](../snakes-and-ladders "Snakes and Ladders") ## [908. Smallest Range I (Easy)](https://leetcode.com/problems/smallest-range-i "最小差值 I") @@ -63,4 +63,4 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/smallest-range-ii/README.md b/problems/smallest-range-ii/README.md index feca0a126..cae7abe56 100644 --- a/problems/smallest-range-ii/README.md +++ b/problems/smallest-range-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/snakes-and-ladders "Snakes and Ladders") +[< Previous](../snakes-and-ladders "Snakes and Ladders")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/online-election "Online Election") +[Next >](../online-election "Online Election") ## [910. Smallest Range II (Medium)](https://leetcode.com/problems/smallest-range-ii "最小差值 II") @@ -63,5 +63,5 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/smallest-rectangle-enclosing-black-pixels/README.md b/problems/smallest-rectangle-enclosing-black-pixels/README.md index 52b347da5..14d52bda0 100644 --- a/problems/smallest-rectangle-enclosing-black-pixels/README.md +++ b/problems/smallest-rectangle-enclosing-black-pixels/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-invalid-parentheses "Remove Invalid Parentheses") +[< Previous](../remove-invalid-parentheses "Remove Invalid Parentheses")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-immutable "Range Sum Query - Immutable") +[Next >](../range-sum-query-immutable "Range Sum Query - Immutable") ## [302. Smallest Rectangle Enclosing Black Pixels (Hard)](https://leetcode.com/problems/smallest-rectangle-enclosing-black-pixels "包含全部黑色像素的最小矩形") @@ -28,4 +28,4 @@ and x = 0, ### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/smallest-rotation-with-highest-score/README.md b/problems/smallest-rotation-with-highest-score/README.md index b60d07f95..618c5dff0 100644 --- a/problems/smallest-rotation-with-highest-score/README.md +++ b/problems/smallest-rotation-with-highest-score/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/all-paths-from-source-to-target "All Paths From Source to Target") +[< Previous](../all-paths-from-source-to-target "All Paths From Source to Target")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/champagne-tower "Champagne Tower") +[Next >](../champagne-tower "Champagne Tower") ## [798. Smallest Rotation with Highest Score (Hard)](https://leetcode.com/problems/smallest-rotation-with-highest-score "得分最高的最小轮调") diff --git a/problems/smallest-string-starting-from-leaf/README.md b/problems/smallest-string-starting-from-leaf/README.md index 6298f709c..f50c6dcc5 100644 --- a/problems/smallest-string-starting-from-leaf/README.md +++ b/problems/smallest-string-starting-from-leaf/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/vertical-order-traversal-of-a-binary-tree "Vertical Order Traversal of a Binary Tree") +[< Previous](../vertical-order-traversal-of-a-binary-tree "Vertical Order Traversal of a Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/add-to-array-form-of-integer "Add to Array-Form of Integer") +[Next >](../add-to-array-form-of-integer "Add to Array-Form of Integer") ## [988. Smallest String Starting From Leaf (Medium)](https://leetcode.com/problems/smallest-string-starting-from-leaf "从叶结点开始的最小字符串") @@ -69,9 +69,9 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Sum Root to Leaf Numbers](https://github.com/openset/leetcode/tree/master/problems/sum-root-to-leaf-numbers) (Medium) - 1. [Binary Tree Paths](https://github.com/openset/leetcode/tree/master/problems/binary-tree-paths) (Easy) + 1. [Sum Root to Leaf Numbers](../sum-root-to-leaf-numbers) (Medium) + 1. [Binary Tree Paths](../binary-tree-paths) (Easy) diff --git a/problems/smallest-string-with-swaps/README.md b/problems/smallest-string-with-swaps/README.md index 70c035d95..b71a874f4 100644 --- a/problems/smallest-string-with-swaps/README.md +++ b/problems/smallest-string-with-swaps/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/ugly-number-iii "Ugly Number III") +[< Previous](../ugly-number-iii "Ugly Number III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sort-items-by-groups-respecting-dependencies "Sort Items by Groups Respecting Dependencies") +[Next >](../sort-items-by-groups-respecting-dependencies "Sort Items by Groups Respecting Dependencies") ## [1202. Smallest String With Swaps (Medium)](https://leetcode.com/problems/smallest-string-with-swaps "交换字符串中的元素") @@ -60,8 +60,8 @@ Swap s[0] and s[1], s = "abc" ### Related Topics - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/smallest-subsequence-of-distinct-characters/README.md b/problems/smallest-subsequence-of-distinct-characters/README.md index fa07b481b..c0a2b13e1 100644 --- a/problems/smallest-subsequence-of-distinct-characters/README.md +++ b/problems/smallest-subsequence-of-distinct-characters/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/insufficient-nodes-in-root-to-leaf-paths "Insufficient Nodes in Root to Leaf Paths") +[< Previous](../insufficient-nodes-in-root-to-leaf-paths "Insufficient Nodes in Root to Leaf Paths")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sales-analysis-i "Sales Analysis I") +[Next >](../sales-analysis-i "Sales Analysis I") ## [1081. Smallest Subsequence of Distinct Characters (Medium)](https://leetcode.com/problems/smallest-subsequence-of-distinct-characters "不同字符的最小子序列") @@ -61,7 +61,7 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md index f209498eb..3de6937a8 100644 --- a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md +++ b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-path-to-get-all-keys "Shortest Path to Get All Keys") +[< Previous](../shortest-path-to-get-all-keys "Shortest Path to Get All Keys")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/prime-palindrome "Prime Palindrome") +[Next >](../prime-palindrome "Prime Palindrome") ## [865. Smallest Subtree with all the Deepest Nodes (Medium)](https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes "具有所有最深结点的最小子树") @@ -47,4 +47,4 @@ Both the input and output have TreeNode type. ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] diff --git a/problems/smallest-sufficient-team/README.md b/problems/smallest-sufficient-team/README.md index 3b640da43..651b91afb 100644 --- a/problems/smallest-sufficient-team/README.md +++ b/problems/smallest-sufficient-team/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-well-performing-interval "Longest Well-Performing Interval") +[< Previous](../longest-well-performing-interval "Longest Well-Performing Interval")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/active-businesses "Active Businesses") +[Next >](../active-businesses "Active Businesses") ## [1125. Smallest Sufficient Team (Hard)](https://leetcode.com/problems/smallest-sufficient-team "最小的必要团队") @@ -41,8 +41,8 @@ ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/snakes-and-ladders/README.md b/problems/snakes-and-ladders/README.md index 5d1a70d9b..29051ae1d 100644 --- a/problems/snakes-and-ladders/README.md +++ b/problems/snakes-and-ladders/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/smallest-range-i "Smallest Range I") +[< Previous](../smallest-range-i "Smallest Range I")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/smallest-range-ii "Smallest Range II") +[Next >](../smallest-range-ii "Smallest Range II") ## [909. Snakes and Ladders (Medium)](https://leetcode.com/problems/snakes-and-ladders "蛇梯棋") @@ -64,4 +64,4 @@ It can be shown that you need at least 4 moves to reach the N*N-th square, so th ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/snapshot-array/README.md b/problems/snapshot-array/README.md index bde5c8649..1dce59d35 100644 --- a/problems/snapshot-array/README.md +++ b/problems/snapshot-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-tree-coloring-game "Binary Tree Coloring Game") +[< Previous](../binary-tree-coloring-game "Binary Tree Coloring Game")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-chunked-palindrome-decomposition "Longest Chunked Palindrome Decomposition") +[Next >](../longest-chunked-palindrome-decomposition "Longest Chunked Palindrome Decomposition") ## [1146. Snapshot Array (Medium)](https://leetcode.com/problems/snapshot-array "快照数组") @@ -46,7 +46,7 @@ snapshotArr.get(0,0); // Get the value of array[0] with snap_id = 0, return 5 ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/solve-the-equation/README.md b/problems/solve-the-equation/README.md index f4a02f8a6..e825bc691 100644 --- a/problems/solve-the-equation/README.md +++ b/problems/solve-the-equation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/decode-ways-ii "Decode Ways II") +[< Previous](../decode-ways-ii "Decode Ways II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-circular-deque "Design Circular Deque") +[Next >](../design-circular-deque "Design Circular Deque") ## [640. Solve the Equation (Medium)](https://leetcode.com/problems/solve-the-equation "求解方程") @@ -61,7 +61,7 @@ If there is exactly one solution for the equation, we ensure that the value of <

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Fraction Addition and Subtraction](https://github.com/openset/leetcode/tree/master/problems/fraction-addition-and-subtraction) (Medium) + 1. [Fraction Addition and Subtraction](../fraction-addition-and-subtraction) (Medium) diff --git a/problems/sort-an-array/README.md b/problems/sort-an-array/README.md index be77076e8..fb632ec4e 100644 --- a/problems/sort-an-array/README.md +++ b/problems/sort-an-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/online-election "Online Election") +[< Previous](../online-election "Online Election")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/cat-and-mouse "Cat and Mouse") +[Next >](../cat-and-mouse "Cat and Mouse") ## [912. Sort an Array (Medium)](https://leetcode.com/problems/sort-an-array "排序数组") diff --git a/problems/sort-array-by-parity-ii/README.md b/problems/sort-array-by-parity-ii/README.md index 199ffd2e9..6da52d820 100644 --- a/problems/sort-array-by-parity-ii/README.md +++ b/problems/sort-array-by-parity-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-add-to-make-parentheses-valid "Minimum Add to Make Parentheses Valid") +[< Previous](../minimum-add-to-make-parentheses-valid "Minimum Add to Make Parentheses Valid")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/3sum-with-multiplicity "3Sum With Multiplicity") +[Next >](../3sum-with-multiplicity "3Sum With Multiplicity") ## [922. Sort Array By Parity II (Easy)](https://leetcode.com/problems/sort-array-by-parity-ii "按奇偶排序数组 II") @@ -42,5 +42,5 @@ ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/sort-array-by-parity/README.md b/problems/sort-array-by-parity/README.md index 9956ea559..81a47709a 100644 --- a/problems/sort-array-by-parity/README.md +++ b/problems/sort-array-by-parity/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/fruit-into-baskets "Fruit Into Baskets") +[< Previous](../fruit-into-baskets "Fruit Into Baskets")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/super-palindromes "Super Palindromes") +[Next >](../super-palindromes "Super Palindromes") ## [905. Sort Array By Parity (Easy)](https://leetcode.com/problems/sort-array-by-parity "按奇偶排序数组") @@ -37,4 +37,4 @@ The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be accepted. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/sort-characters-by-frequency/README.md b/problems/sort-characters-by-frequency/README.md index 15636da50..41923ed44 100644 --- a/problems/sort-characters-by-frequency/README.md +++ b/problems/sort-characters-by-frequency/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/delete-node-in-a-bst "Delete Node in a BST") +[< Previous](../delete-node-in-a-bst "Delete Node in a BST")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-arrows-to-burst-balloons "Minimum Number of Arrows to Burst Balloons") +[Next >](../minimum-number-of-arrows-to-burst-balloons "Minimum Number of Arrows to Burst Balloons") ## [451. Sort Characters By Frequency (Medium)](https://leetcode.com/problems/sort-characters-by-frequency "根据字符出现频率排序") @@ -56,9 +56,9 @@ Note that 'A' and 'a' are treated as two different characters.

### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Top K Frequent Elements](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-elements) (Medium) - 1. [First Unique Character in a String](https://github.com/openset/leetcode/tree/master/problems/first-unique-character-in-a-string) (Easy) + 1. [Top K Frequent Elements](../top-k-frequent-elements) (Medium) + 1. [First Unique Character in a String](../first-unique-character-in-a-string) (Easy) diff --git a/problems/sort-colors/README.md b/problems/sort-colors/README.md index 19bdefc03..d68e399a4 100644 --- a/problems/sort-colors/README.md +++ b/problems/sort-colors/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/search-a-2d-matrix "Search a 2D Matrix") +[< Previous](../search-a-2d-matrix "Search a 2D Matrix")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-window-substring "Minimum Window Substring") +[Next >](../minimum-window-substring "Minimum Window Substring") ## [75. Sort Colors (Medium)](https://leetcode.com/problems/sort-colors "颜色分类") @@ -32,11 +32,11 @@ ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Sort List](https://github.com/openset/leetcode/tree/master/problems/sort-list) (Medium) - 1. [Wiggle Sort](https://github.com/openset/leetcode/tree/master/problems/wiggle-sort) (Medium) - 1. [Wiggle Sort II](https://github.com/openset/leetcode/tree/master/problems/wiggle-sort-ii) (Medium) + 1. [Sort List](../sort-list) (Medium) + 1. [Wiggle Sort](../wiggle-sort) (Medium) + 1. [Wiggle Sort II](../wiggle-sort-ii) (Medium) diff --git a/problems/sort-items-by-groups-respecting-dependencies/README.md b/problems/sort-items-by-groups-respecting-dependencies/README.md index 77143ac3d..ec7c51434 100644 --- a/problems/sort-items-by-groups-respecting-dependencies/README.md +++ b/problems/sort-items-by-groups-respecting-dependencies/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/smallest-string-with-swaps "Smallest String With Swaps") +[< Previous](../smallest-string-with-swaps "Smallest String With Swaps")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/last-person-to-fit-in-the-elevator "Last Person to Fit in the Elevator") +[Next >](../last-person-to-fit-in-the-elevator "Last Person to Fit in the Elevator") ## [1203. Sort Items by Groups Respecting Dependencies (Hard)](https://leetcode.com/problems/sort-items-by-groups-respecting-dependencies "项目管理") @@ -54,9 +54,9 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] - [[Topological Sort](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] ### Hints
diff --git a/problems/sort-list/README.md b/problems/sort-list/README.md index 1d555210d..9b662c369 100644 --- a/problems/sort-list/README.md +++ b/problems/sort-list/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/insertion-sort-list "Insertion Sort List") +[< Previous](../insertion-sort-list "Insertion Sort List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/max-points-on-a-line "Max Points on a Line") +[Next >](../max-points-on-a-line "Max Points on a Line") ## [148. Sort List (Medium)](https://leetcode.com/problems/sort-list "排序链表") @@ -27,10 +27,10 @@ Output: -1->0->3->4->5 ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Merge Two Sorted Lists](https://github.com/openset/leetcode/tree/master/problems/merge-two-sorted-lists) (Easy) - 1. [Sort Colors](https://github.com/openset/leetcode/tree/master/problems/sort-colors) (Medium) - 1. [Insertion Sort List](https://github.com/openset/leetcode/tree/master/problems/insertion-sort-list) (Medium) + 1. [Merge Two Sorted Lists](../merge-two-sorted-lists) (Easy) + 1. [Sort Colors](../sort-colors) (Medium) + 1. [Insertion Sort List](../insertion-sort-list) (Medium) diff --git a/problems/sort-transformed-array/README.md b/problems/sort-transformed-array/README.md index 546edf9f5..1d70cd120 100644 --- a/problems/sort-transformed-array/README.md +++ b/problems/sort-transformed-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/logger-rate-limiter "Logger Rate Limiter") +[< Previous](../logger-rate-limiter "Logger Rate Limiter")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/bomb-enemy "Bomb Enemy") +[Next >](../bomb-enemy "Bomb Enemy") ## [360. Sort Transformed Array (Medium)](https://leetcode.com/problems/sort-transformed-array "有序转化数组") @@ -34,11 +34,11 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Math](../../tag/math/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Squares of a Sorted Array](https://github.com/openset/leetcode/tree/master/problems/squares-of-a-sorted-array) (Easy) + 1. [Squares of a Sorted Array](../squares-of-a-sorted-array) (Easy) ### Hints
diff --git a/problems/soup-servings/README.md b/problems/soup-servings/README.md index 9dfdf605e..7a5dbb405 100644 --- a/problems/soup-servings/README.md +++ b/problems/soup-servings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/max-increase-to-keep-city-skyline "Max Increase to Keep City Skyline") +[< Previous](../max-increase-to-keep-city-skyline "Max Increase to Keep City Skyline")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/expressive-words "Expressive Words") +[Next >](../expressive-words "Expressive Words") ## [808. Soup Servings (Medium)](https://leetcode.com/problems/soup-servings "分汤") @@ -45,4 +45,4 @@ If we choose the first two operations, A will become empty first. For the third ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/sparse-matrix-multiplication/README.md b/problems/sparse-matrix-multiplication/README.md index b957bb1ce..1cb5568f1 100644 --- a/problems/sparse-matrix-multiplication/README.md +++ b/problems/sparse-matrix-multiplication/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-height-trees "Minimum Height Trees") +[< Previous](../minimum-height-trees "Minimum Height Trees")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/burst-balloons "Burst Balloons") +[Next >](../burst-balloons "Burst Balloons") ## [311. Sparse Matrix Multiplication (Medium)](https://leetcode.com/problems/sparse-matrix-multiplication "稀疏矩阵的乘法") @@ -39,4 +39,4 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/special-binary-string/README.md b/problems/special-binary-string/README.md index 5ab8b46ea..da6f20953 100644 --- a/problems/special-binary-string/README.md +++ b/problems/special-binary-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-anagram-mappings "Find Anagram Mappings") +[< Previous](../find-anagram-mappings "Find Anagram Mappings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/prime-number-of-set-bits-in-binary-representation "Prime Number of Set Bits in Binary Representation") +[Next >](../prime-number-of-set-bits-in-binary-representation "Prime Number of Set Bits in Binary Representation") ## [761. Special Binary String (Hard)](https://leetcode.com/problems/special-binary-string "特殊的二进制序列") @@ -38,11 +38,11 @@ This is the lexicographically largest string possible after some number of swaps

### Related Topics - [[Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Valid Parenthesis String](https://github.com/openset/leetcode/tree/master/problems/valid-parenthesis-string) (Medium) + 1. [Valid Parenthesis String](../valid-parenthesis-string) (Medium) ### Hints
diff --git a/problems/spiral-matrix-ii/README.md b/problems/spiral-matrix-ii/README.md index 29527da56..bddfb831a 100644 --- a/problems/spiral-matrix-ii/README.md +++ b/problems/spiral-matrix-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/length-of-last-word "Length of Last Word") +[< Previous](../length-of-last-word "Length of Last Word")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/permutation-sequence "Permutation Sequence") +[Next >](../permutation-sequence "Permutation Sequence") ## [59. Spiral Matrix II (Medium)](https://leetcode.com/problems/spiral-matrix-ii "螺旋矩阵 II") @@ -26,7 +26,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Spiral Matrix](https://github.com/openset/leetcode/tree/master/problems/spiral-matrix) (Medium) + 1. [Spiral Matrix](../spiral-matrix) (Medium) diff --git a/problems/spiral-matrix-iii/README.md b/problems/spiral-matrix-iii/README.md index d3abbd192..640c62380 100644 --- a/problems/spiral-matrix-iii/README.md +++ b/problems/spiral-matrix-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/uncommon-words-from-two-sentences "Uncommon Words from Two Sentences") +[< Previous](../uncommon-words-from-two-sentences "Uncommon Words from Two Sentences")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/possible-bipartition "Possible Bipartition") +[Next >](../possible-bipartition "Possible Bipartition") ## [885. Spiral Matrix III (Medium)](https://leetcode.com/problems/spiral-matrix-iii "螺旋矩阵 III") @@ -61,4 +61,4 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/spiral-matrix/README.md b/problems/spiral-matrix/README.md index 656c51760..f0139fd00 100644 --- a/problems/spiral-matrix/README.md +++ b/problems/spiral-matrix/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-subarray "Maximum Subarray") +[< Previous](../maximum-subarray "Maximum Subarray")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/jump-game "Jump Game") +[Next >](../jump-game "Jump Game") ## [54. Spiral Matrix (Medium)](https://leetcode.com/problems/spiral-matrix "螺旋矩阵") @@ -37,7 +37,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Spiral Matrix II](https://github.com/openset/leetcode/tree/master/problems/spiral-matrix-ii) (Medium) + 1. [Spiral Matrix II](../spiral-matrix-ii) (Medium) diff --git a/problems/split-a-string-in-balanced-strings/README.md b/problems/split-a-string-in-balanced-strings/README.md index b5db57d38..8d97a4325 100644 --- a/problems/split-a-string-in-balanced-strings/README.md +++ b/problems/split-a-string-in-balanced-strings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/count-vowels-permutation "Count Vowels Permutation") +[< Previous](../count-vowels-permutation "Count Vowels Permutation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/queens-that-can-attack-the-king "Queens That Can Attack the King") +[Next >](../queens-that-can-attack-the-king "Queens That Can Attack the King") ## [1221. Split a String in Balanced Strings (Easy)](https://leetcode.com/problems/split-a-string-in-balanced-strings "分割平衡字符串") @@ -59,8 +59,8 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/split-array-into-consecutive-subsequences/README.md b/problems/split-array-into-consecutive-subsequences/README.md index 2289bdc9e..9f60d7348 100644 --- a/problems/split-array-into-consecutive-subsequences/README.md +++ b/problems/split-array-into-consecutive-subsequences/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-k-closest-elements "Find K Closest Elements") +[< Previous](../find-k-closest-elements "Find K Closest Elements")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-9 "Remove 9") +[Next >](../remove-9 "Remove 9") ## [659. Split Array into Consecutive Subsequences (Medium)](https://leetcode.com/problems/split-array-into-consecutive-subsequences "分割数组为连续子序列") @@ -57,8 +57,8 @@ You can split them into two consecutive subsequences :

 

### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions - 1. [Top K Frequent Elements](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-elements) (Medium) + 1. [Top K Frequent Elements](../top-k-frequent-elements) (Medium) diff --git a/problems/split-array-into-fibonacci-sequence/README.md b/problems/split-array-into-fibonacci-sequence/README.md index f8894b2a4..81a7dc0f8 100644 --- a/problems/split-array-into-fibonacci-sequence/README.md +++ b/problems/split-array-into-fibonacci-sequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/keys-and-rooms "Keys and Rooms") +[< Previous](../keys-and-rooms "Keys and Rooms")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/guess-the-word "Guess the Word") +[Next >](../guess-the-word "Guess the Word") ## [842. Split Array into Fibonacci Sequence (Medium)](https://leetcode.com/problems/split-array-into-fibonacci-sequence "将数组拆分成斐波那契序列") @@ -71,10 +71,10 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Additive Number](https://github.com/openset/leetcode/tree/master/problems/additive-number) (Medium) - 1. [Fibonacci Number](https://github.com/openset/leetcode/tree/master/problems/fibonacci-number) (Easy) + 1. [Additive Number](../additive-number) (Medium) + 1. [Fibonacci Number](../fibonacci-number) (Easy) diff --git a/problems/split-array-largest-sum/README.md b/problems/split-array-largest-sum/README.md index 2eca5d0e9..923fd0683 100644 --- a/problems/split-array-largest-sum/README.md +++ b/problems/split-array-largest-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-palindrome "Longest Palindrome") +[< Previous](../longest-palindrome "Longest Palindrome")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-unique-word-abbreviation "Minimum Unique Word Abbreviation") +[Next >](../minimum-unique-word-abbreviation "Minimum Unique Word Abbreviation") ## [410. Split Array Largest Sum (Hard)](https://leetcode.com/problems/split-array-largest-sum "分割数组的最大值") @@ -39,5 +39,5 @@ where the largest sum among the two subarrays is only 18.

### Related Topics - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/split-array-with-equal-sum/README.md b/problems/split-array-with-equal-sum/README.md index 8c4afadbd..fac6e7e7d 100644 --- a/problems/split-array-with-equal-sum/README.md +++ b/problems/split-array-with-equal-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/friend-circles "Friend Circles") +[< Previous](../friend-circles "Friend Circles")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-tree-longest-consecutive-sequence-ii "Binary Tree Longest Consecutive Sequence II") +[Next >](../binary-tree-longest-consecutive-sequence-ii "Binary Tree Longest Consecutive Sequence II") ## [548. Split Array with Equal Sum (Medium)](https://leetcode.com/problems/split-array-with-equal-sum "将数组分割成和相等的子数组") @@ -40,4 +40,4 @@ sum(k + 1, n - 1) = sum(6, 6) = 1 ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/split-array-with-same-average/README.md b/problems/split-array-with-same-average/README.md index 14aa922d2..7a479df48 100644 --- a/problems/split-array-with-same-average/README.md +++ b/problems/split-array-with-same-average/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/unique-morse-code-words "Unique Morse Code Words") +[< Previous](../unique-morse-code-words "Unique Morse Code Words")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-lines-to-write-string "Number of Lines To Write String") +[Next >](../number-of-lines-to-write-string "Number of Lines To Write String") ## [805. Split Array With Same Average (Hard)](https://leetcode.com/problems/split-array-with-same-average "数组的均值分割") @@ -33,4 +33,4 @@

 

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/split-bst/README.md b/problems/split-bst/README.md index 7fb09710e..49e6a9ae1 100644 --- a/problems/split-bst/README.md +++ b/problems/split-bst/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/global-and-local-inversions "Global and Local Inversions") +[< Previous](../global-and-local-inversions "Global and Local Inversions")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/swap-adjacent-in-lr-string "Swap Adjacent in LR String") +[Next >](../swap-adjacent-in-lr-string "Swap Adjacent in LR String") ## [776. Split BST (Medium)](https://leetcode.com/problems/split-bst "拆分二叉搜索树") @@ -50,11 +50,11 @@ while the diagrams for the outputs are: ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions - 1. [Delete Node in a BST](https://github.com/openset/leetcode/tree/master/problems/delete-node-in-a-bst) (Medium) + 1. [Delete Node in a BST](../delete-node-in-a-bst) (Medium) ### Hints
diff --git a/problems/split-concatenated-strings/README.md b/problems/split-concatenated-strings/README.md index 7d4000e03..3121c5af8 100644 --- a/problems/split-concatenated-strings/README.md +++ b/problems/split-concatenated-strings/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/brick-wall "Brick Wall") +[< Previous](../brick-wall "Brick Wall")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-iii "Next Greater Element III") +[Next >](../next-greater-element-iii "Next Greater Element III") ## [555. Split Concatenated Strings (Medium)](https://leetcode.com/problems/split-concatenated-strings "分割连接字符串") @@ -39,4 +39,4 @@

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/split-linked-list-in-parts/README.md b/problems/split-linked-list-in-parts/README.md index f068af239..350cb53d9 100644 --- a/problems/split-linked-list-in-parts/README.md +++ b/problems/split-linked-list-in-parts/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-pivot-index "Find Pivot Index") +[< Previous](../find-pivot-index "Find Pivot Index")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-atoms "Number of Atoms") +[Next >](../number-of-atoms "Number of Atoms") ## [725. Split Linked List in Parts (Medium)](https://leetcode.com/problems/split-linked-list-in-parts "分隔链表") @@ -58,11 +58,11 @@ The input has been split into consecutive parts with size difference at most 1,

### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Rotate List](https://github.com/openset/leetcode/tree/master/problems/rotate-list) (Medium) - 1. [Odd Even Linked List](https://github.com/openset/leetcode/tree/master/problems/odd-even-linked-list) (Medium) + 1. [Rotate List](../rotate-list) (Medium) + 1. [Odd Even Linked List](../odd-even-linked-list) (Medium) ### Hints
diff --git a/problems/sqrtx/README.md b/problems/sqrtx/README.md index 678ff80fb..1462371e4 100644 --- a/problems/sqrtx/README.md +++ b/problems/sqrtx/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/text-justification "Text Justification") +[< Previous](../text-justification "Text Justification")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/climbing-stairs "Climbing Stairs") +[Next >](../climbing-stairs "Climbing Stairs") ## [69. Sqrt(x) (Easy)](https://leetcode.com/problems/sqrtx "x 的平方根") @@ -34,12 +34,12 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Pow(x, n)](https://github.com/openset/leetcode/tree/master/problems/powx-n) (Medium) - 1. [Valid Perfect Square](https://github.com/openset/leetcode/tree/master/problems/valid-perfect-square) (Easy) + 1. [Pow(x, n)](../powx-n) (Medium) + 1. [Valid Perfect Square](../valid-perfect-square) (Easy) ### Hints
diff --git a/problems/squares-of-a-sorted-array/README.md b/problems/squares-of-a-sorted-array/README.md index 2e3829a19..479f1d0ec 100644 --- a/problems/squares-of-a-sorted-array/README.md +++ b/problems/squares-of-a-sorted-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/largest-perimeter-triangle "Largest Perimeter Triangle") +[< Previous](../largest-perimeter-triangle "Largest Perimeter Triangle")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-turbulent-subarray "Longest Turbulent Subarray") +[Next >](../longest-turbulent-subarray "Longest Turbulent Subarray") ## [977. Squares of a Sorted Array (Easy)](https://leetcode.com/problems/squares-of-a-sorted-array "有序数组的平方") @@ -44,9 +44,9 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Merge Sorted Array](https://github.com/openset/leetcode/tree/master/problems/merge-sorted-array) (Easy) - 1. [Sort Transformed Array](https://github.com/openset/leetcode/tree/master/problems/sort-transformed-array) (Medium) + 1. [Merge Sorted Array](../merge-sorted-array) (Easy) + 1. [Sort Transformed Array](../sort-transformed-array) (Medium) diff --git a/problems/squirrel-simulation/README.md b/problems/squirrel-simulation/README.md index a42755dc8..5060c8f49 100644 --- a/problems/squirrel-simulation/README.md +++ b/problems/squirrel-simulation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/subtree-of-another-tree "Subtree of Another Tree") +[< Previous](../subtree-of-another-tree "Subtree of Another Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/winning-candidate "Winning Candidate") +[Next >](../winning-candidate "Winning Candidate") ## [573. Squirrel Simulation (Medium)](https://leetcode.com/problems/squirrel-simulation "松鼠模拟") @@ -36,7 +36,7 @@ Nuts : [[3,0], [2,5]] ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/stamping-the-sequence/README.md b/problems/stamping-the-sequence/README.md index 028e2a4ba..3217f2fab 100644 --- a/problems/stamping-the-sequence/README.md +++ b/problems/stamping-the-sequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/knight-dialer "Knight Dialer") +[< Previous](../knight-dialer "Knight Dialer")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reorder-data-in-log-files "Reorder Data in Log Files") +[Next >](../reorder-data-in-log-files "Reorder Data in Log Files") ## [936. Stamping The Sequence (Hard)](https://leetcode.com/problems/stamping-the-sequence "戳印序列") @@ -56,5 +56,5 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/statistics-from-a-large-sample/README.md b/problems/statistics-from-a-large-sample/README.md index 0b66d0a37..b59d03b09 100644 --- a/problems/statistics-from-a-large-sample/README.md +++ b/problems/statistics-from-a-large-sample/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-common-supersequence "Shortest Common Supersequence ") +[< Previous](../shortest-common-supersequence "Shortest Common Supersequence ")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/car-pooling "Car Pooling") +[Next >](../car-pooling "Car Pooling") ## [1093. Statistics from a Large Sample (Medium)](https://leetcode.com/problems/statistics-from-a-large-sample "大样本统计") @@ -41,8 +41,8 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Math](../../tag/math/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Hints
diff --git a/problems/stepping-numbers/README.md b/problems/stepping-numbers/README.md index e8bdd8bd6..c2b338c34 100644 --- a/problems/stepping-numbers/README.md +++ b/problems/stepping-numbers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/two-sum-bsts "Two Sum BSTs") +[< Previous](../two-sum-bsts "Two Sum BSTs")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome-iii "Valid Palindrome III") +[Next >](../valid-palindrome-iii "Valid Palindrome III") ## [1215. Stepping Numbers (Medium)](https://leetcode.com/problems/stepping-numbers "步进数") @@ -28,7 +28,7 @@ ### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Hints
diff --git a/problems/stickers-to-spell-word/README.md b/problems/stickers-to-spell-word/README.md index fd0239b72..70c307e12 100644 --- a/problems/stickers-to-spell-word/README.md +++ b/problems/stickers-to-spell-word/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/employee-importance "Employee Importance") +[< Previous](../employee-importance "Employee Importance")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-words "Top K Frequent Words") +[Next >](../top-k-frequent-words "Top K Frequent Words") ## [691. Stickers to Spell Word (Hard)](https://leetcode.com/problems/stickers-to-spell-word "贴纸拼词") @@ -58,11 +58,11 @@ We can't form the target "basicbasic" from cutting letters from the given sticke

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Ransom Note](https://github.com/openset/leetcode/tree/master/problems/ransom-note) (Easy) + 1. [Ransom Note](../ransom-note) (Easy) ### Hints
diff --git a/problems/stone-game-ii/README.md b/problems/stone-game-ii/README.md index 248756506..f609cb77c 100644 --- a/problems/stone-game-ii/README.md +++ b/problems/stone-game-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/largest-1-bordered-square "Largest 1-Bordered Square") +[< Previous](../largest-1-bordered-square "Largest 1-Bordered Square")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/user-activity-for-the-past-30-days-i "User Activity for the Past 30 Days I") +[Next >](../user-activity-for-the-past-30-days-i "User Activity for the Past 30 Days I") ## [1140. Stone Game II (Medium)](https://leetcode.com/problems/stone-game-ii "石子游戏 II") @@ -39,7 +39,7 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/stone-game/README.md b/problems/stone-game/README.md index 352076f20..b0760bc1b 100644 --- a/problems/stone-game/README.md +++ b/problems/stone-game/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/middle-of-the-linked-list "Middle of the Linked List") +[< Previous](../middle-of-the-linked-list "Middle of the Linked List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/nth-magical-number "Nth Magical Number") +[Next >](../nth-magical-number "Nth Magical Number") ## [877. Stone Game (Medium)](https://leetcode.com/problems/stone-game "石子游戏") @@ -46,6 +46,6 @@ This demonstrated that taking the first 5 was a winning move for Alex, so we ret ### Related Topics - [[Minimax](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Minimax](../../tag/minimax/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/strange-printer/README.md b/problems/strange-printer/README.md index e9a0aba61..06520e782 100644 --- a/problems/strange-printer/README.md +++ b/problems/strange-printer/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/equal-tree-partition "Equal Tree Partition") +[< Previous](../equal-tree-partition "Equal Tree Partition")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/non-decreasing-array "Non-decreasing Array") +[Next >](../non-decreasing-array "Non-decreasing Array") ## [664. Strange Printer (Hard)](https://leetcode.com/problems/strange-printer "奇怪的打印机") @@ -44,8 +44,8 @@ Given a string consists of lower English letters only, your job is to count the

Hint: Length of the given string will not exceed 100.

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Remove Boxes](https://github.com/openset/leetcode/tree/master/problems/remove-boxes) (Hard) + 1. [Remove Boxes](../remove-boxes) (Hard) diff --git a/problems/stream-of-characters/README.md b/problems/stream-of-characters/README.md index 6660187fc..bdc0b8a07 100644 --- a/problems/stream-of-characters/README.md +++ b/problems/stream-of-characters/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-sum-of-two-non-overlapping-subarrays "Maximum Sum of Two Non-Overlapping Subarrays") +[< Previous](../maximum-sum-of-two-non-overlapping-subarrays "Maximum Sum of Two Non-Overlapping Subarrays")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/moving-stones-until-consecutive "Moving Stones Until Consecutive") +[Next >](../moving-stones-until-consecutive "Moving Stones Until Consecutive") ## [1032. Stream of Characters (Hard)](https://leetcode.com/problems/stream-of-characters "字符流") @@ -51,7 +51,7 @@ streamChecker.query('l'); // return true, because 'kl' ### Related Topics - [[Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] + [[Trie](../../tag/trie/README.md)] ### Hints
diff --git a/problems/string-compression/README.md b/problems/string-compression/README.md index 3d56b5420..6196df087 100644 --- a/problems/string-compression/README.md +++ b/problems/string-compression/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-all-duplicates-in-an-array "Find All Duplicates in an Array") +[< Previous](../find-all-duplicates-in-an-array "Find All Duplicates in an Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sequence-reconstruction "Sequence Reconstruction") +[Next >](../sequence-reconstruction "Sequence Reconstruction") ## [443. String Compression (Easy)](https://leetcode.com/problems/string-compression "压缩字符串") @@ -78,12 +78,12 @@ Notice each digit has it's own entry in the array. ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Count and Say](https://github.com/openset/leetcode/tree/master/problems/count-and-say) (Easy) - 1. [Encode and Decode Strings](https://github.com/openset/leetcode/tree/master/problems/encode-and-decode-strings) (Medium) - 1. [Design Compressed String Iterator](https://github.com/openset/leetcode/tree/master/problems/design-compressed-string-iterator) (Easy) + 1. [Count and Say](../count-and-say) (Easy) + 1. [Encode and Decode Strings](../encode-and-decode-strings) (Medium) + 1. [Design Compressed String Iterator](../design-compressed-string-iterator) (Easy) ### Hints
diff --git a/problems/string-to-integer-atoi/README.md b/problems/string-to-integer-atoi/README.md index 1da386664..767154ac4 100644 --- a/problems/string-to-integer-atoi/README.md +++ b/problems/string-to-integer-atoi/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reverse-integer "Reverse Integer") +[< Previous](../reverse-integer "Reverse Integer")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/palindrome-number "Palindrome Number") +[Next >](../palindrome-number "Palindrome Number") ## [8. String to Integer (atoi) (Medium)](https://leetcode.com/problems/string-to-integer-atoi "字符串转换整数 (atoi)") @@ -69,9 +69,9 @@   Thefore INT_MIN (−231) is returned. ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Reverse Integer](https://github.com/openset/leetcode/tree/master/problems/reverse-integer) (Easy) - 1. [Valid Number](https://github.com/openset/leetcode/tree/master/problems/valid-number) (Hard) + 1. [Reverse Integer](../reverse-integer) (Easy) + 1. [Valid Number](../valid-number) (Hard) diff --git a/problems/string-transforms-into-another-string/README.md b/problems/string-transforms-into-another-string/README.md index 28ed4674b..dd1510145 100644 --- a/problems/string-transforms-into-another-string/README.md +++ b/problems/string-transforms-into-another-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/analyze-user-website-visit-pattern "Analyze User Website Visit Pattern") +[< Previous](../analyze-user-website-visit-pattern "Analyze User Website Visit Pattern")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/day-of-the-year "Day of the Year") +[Next >](../day-of-the-year "Day of the Year") ## [1153. String Transforms Into Another String (Hard)](https://leetcode.com/problems/string-transforms-into-another-string "字符串转化") @@ -45,7 +45,7 @@ ### Related Topics - [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] + [[Graph](../../tag/graph/README.md)] ### Hints
diff --git a/problems/string-without-aaa-or-bbb/README.md b/problems/string-without-aaa-or-bbb/README.md index dd3f88892..a252e92b6 100644 --- a/problems/string-without-aaa-or-bbb/README.md +++ b/problems/string-without-aaa-or-bbb/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-for-tickets "Minimum Cost For Tickets") +[< Previous](../minimum-cost-for-tickets "Minimum Cost For Tickets")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sum-of-even-numbers-after-queries "Sum of Even Numbers After Queries") +[Next >](../sum-of-even-numbers-after-queries "Sum of Even Numbers After Queries") ## [984. String Without AAA or BBB (Medium)](https://leetcode.com/problems/string-without-aaa-or-bbb "不含 AAA 或 BBB 的字符串") @@ -48,4 +48,4 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/strobogrammatic-number-ii/README.md b/problems/strobogrammatic-number-ii/README.md index da4bc8a7d..0cda2663c 100644 --- a/problems/strobogrammatic-number-ii/README.md +++ b/problems/strobogrammatic-number-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number "Strobogrammatic Number") +[< Previous](../strobogrammatic-number "Strobogrammatic Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number-iii "Strobogrammatic Number III") +[Next >](../strobogrammatic-number-iii "Strobogrammatic Number III") ## [247. Strobogrammatic Number II (Medium)](https://leetcode.com/problems/strobogrammatic-number-ii "中心对称数 II") @@ -23,12 +23,12 @@ ### Related Topics - [[Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Strobogrammatic Number](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number) (Easy) - 1. [Strobogrammatic Number III](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number-iii) (Hard) + 1. [Strobogrammatic Number](../strobogrammatic-number) (Easy) + 1. [Strobogrammatic Number III](../strobogrammatic-number-iii) (Hard) ### Hints
diff --git a/problems/strobogrammatic-number-iii/README.md b/problems/strobogrammatic-number-iii/README.md index daa31f714..2372b682c 100644 --- a/problems/strobogrammatic-number-iii/README.md +++ b/problems/strobogrammatic-number-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number-ii "Strobogrammatic Number II") +[< Previous](../strobogrammatic-number-ii "Strobogrammatic Number II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/group-shifted-strings "Group Shifted Strings") +[Next >](../group-shifted-strings "Group Shifted Strings") ## [248. Strobogrammatic Number III (Hard)](https://leetcode.com/problems/strobogrammatic-number-iii "中心对称数 III") @@ -26,9 +26,9 @@ Because the range might be a large number, the low and high numbers are represented as string.

### Related Topics - [[Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Strobogrammatic Number](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number) (Easy) - 1. [Strobogrammatic Number II](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number-ii) (Medium) + 1. [Strobogrammatic Number](../strobogrammatic-number) (Easy) + 1. [Strobogrammatic Number II](../strobogrammatic-number-ii) (Medium) diff --git a/problems/strobogrammatic-number/README.md b/problems/strobogrammatic-number/README.md index 907b40977..4784cec6a 100644 --- a/problems/strobogrammatic-number/README.md +++ b/problems/strobogrammatic-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance-iii "Shortest Word Distance III") +[< Previous](../shortest-word-distance-iii "Shortest Word Distance III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number-ii "Strobogrammatic Number II") +[Next >](../strobogrammatic-number-ii "Strobogrammatic Number II") ## [246. Strobogrammatic Number (Easy)](https://leetcode.com/problems/strobogrammatic-number "中心对称数") @@ -35,10 +35,10 @@ Output: false ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Strobogrammatic Number II](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number-ii) (Medium) - 1. [Strobogrammatic Number III](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number-iii) (Hard) - 1. [Confusing Number](https://github.com/openset/leetcode/tree/master/problems/confusing-number) (Easy) + 1. [Strobogrammatic Number II](../strobogrammatic-number-ii) (Medium) + 1. [Strobogrammatic Number III](../strobogrammatic-number-iii) (Hard) + 1. [Confusing Number](../confusing-number) (Easy) diff --git a/problems/strong-password-checker/README.md b/problems/strong-password-checker/README.md index 39223af92..ec53406d3 100644 --- a/problems/strong-password-checker/README.md +++ b/problems/strong-password-checker/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/battleships-in-a-board "Battleships in a Board") +[< Previous](../battleships-in-a-board "Battleships in a Board")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-xor-of-two-numbers-in-an-array "Maximum XOR of Two Numbers in an Array") +[Next >](../maximum-xor-of-two-numbers-in-an-array "Maximum XOR of Two Numbers in an Array") ## [420. Strong Password Checker (Hard)](https://leetcode.com/problems/strong-password-checker "强密码检验器") diff --git a/problems/student-attendance-record-i/README.md b/problems/student-attendance-record-i/README.md index 2f73371f1..4cc3b0c62 100644 --- a/problems/student-attendance-record-i/README.md +++ b/problems/student-attendance-record-i/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-iv "Game Play Analysis IV") +[< Previous](../game-play-analysis-iv "Game Play Analysis IV")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/student-attendance-record-ii "Student Attendance Record II") +[Next >](../student-attendance-record-ii "Student Attendance Record II") ## [551. Student Attendance Record I (Easy)](https://leetcode.com/problems/student-attendance-record-i "学生出勤记录 I") @@ -41,7 +41,7 @@ A student could be rewarded if his attendance record doesn't contain more tha

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Student Attendance Record II](https://github.com/openset/leetcode/tree/master/problems/student-attendance-record-ii) (Hard) + 1. [Student Attendance Record II](../student-attendance-record-ii) (Hard) diff --git a/problems/student-attendance-record-ii/README.md b/problems/student-attendance-record-ii/README.md index 648fcf229..10ad57c82 100644 --- a/problems/student-attendance-record-ii/README.md +++ b/problems/student-attendance-record-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/student-attendance-record-i "Student Attendance Record I") +[< Previous](../student-attendance-record-i "Student Attendance Record I")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/optimal-division "Optimal Division") +[Next >](../optimal-division "Optimal Division") ## [552. Student Attendance Record II (Hard)](https://leetcode.com/problems/student-attendance-record-ii "学生出勤记录 II") @@ -42,7 +42,7 @@ The value of n won't exceed 100,000.

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Student Attendance Record I](https://github.com/openset/leetcode/tree/master/problems/student-attendance-record-i) (Easy) + 1. [Student Attendance Record I](../student-attendance-record-i) (Easy) diff --git a/problems/students-and-examinations/README.md b/problems/students-and-examinations/README.md index 9e8f218e8..06b103b4d 100644 --- a/problems/students-and-examinations/README.md +++ b/problems/students-and-examinations/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/traffic-light-controlled-intersection "Traffic Light Controlled Intersection") +[< Previous](../traffic-light-controlled-intersection "Traffic Light Controlled Intersection")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/subtract-the-product-and-sum-of-digits-of-an-integer "Subtract the Product and Sum of Digits of an Integer") +[Next >](../subtract-the-product-and-sum-of-digits-of-an-integer "Subtract the Product and Sum of Digits of an Integer") ## [1280. Students and Examinations (Easy)](https://leetcode.com/problems/students-and-examinations "") diff --git a/problems/students-report-by-geography/README.md b/problems/students-report-by-geography/README.md index 43ca274d5..c7562dcd4 100644 --- a/problems/students-report-by-geography/README.md +++ b/problems/students-report-by-geography/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/merge-two-binary-trees "Merge Two Binary Trees") +[< Previous](../merge-two-binary-trees "Merge Two Binary Trees")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/biggest-single-number "Biggest Single Number") +[Next >](../biggest-single-number "Biggest Single Number") ## [618. Students Report By Geography (Hard)](https://leetcode.com/problems/students-report-by-geography "学生地理信息报告") diff --git a/problems/subarray-product-less-than-k/README.md b/problems/subarray-product-less-than-k/README.md index 08f96ac07..8c3cb96a0 100644 --- a/problems/subarray-product-less-than-k/README.md +++ b/problems/subarray-product-less-than-k/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-ascii-delete-sum-for-two-strings "Minimum ASCII Delete Sum for Two Strings") +[< Previous](../minimum-ascii-delete-sum-for-two-strings "Minimum ASCII Delete Sum for Two Strings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-with-transaction-fee "Best Time to Buy and Sell Stock with Transaction Fee") +[Next >](../best-time-to-buy-and-sell-stock-with-transaction-fee "Best Time to Buy and Sell Stock with Transaction Fee") ## [713. Subarray Product Less Than K (Medium)](https://leetcode.com/problems/subarray-product-less-than-k "乘积小于K的子数组") @@ -30,14 +30,14 @@ Note that [10, 5, 2] is not included as the product of 100 is not strictly less

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Maximum Product Subarray](https://github.com/openset/leetcode/tree/master/problems/maximum-product-subarray) (Medium) - 1. [Maximum Size Subarray Sum Equals k](https://github.com/openset/leetcode/tree/master/problems/maximum-size-subarray-sum-equals-k) (Medium) - 1. [Subarray Sum Equals K](https://github.com/openset/leetcode/tree/master/problems/subarray-sum-equals-k) (Medium) - 1. [Two Sum Less Than K](https://github.com/openset/leetcode/tree/master/problems/two-sum-less-than-k) (Easy) + 1. [Maximum Product Subarray](../maximum-product-subarray) (Medium) + 1. [Maximum Size Subarray Sum Equals k](../maximum-size-subarray-sum-equals-k) (Medium) + 1. [Subarray Sum Equals K](../subarray-sum-equals-k) (Medium) + 1. [Two Sum Less Than K](../two-sum-less-than-k) (Easy) ### Hints
diff --git a/problems/subarray-sum-equals-k/README.md b/problems/subarray-sum-equals-k/README.md index 230ad8813..ca30d116a 100644 --- a/problems/subarray-sum-equals-k/README.md +++ b/problems/subarray-sum-equals-k/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-depth-of-n-ary-tree "Maximum Depth of N-ary Tree") +[< Previous](../maximum-depth-of-n-ary-tree "Maximum Depth of N-ary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/array-partition-i "Array Partition I") +[Next >](../array-partition-i "Array Partition I") ## [560. Subarray Sum Equals K (Medium)](https://leetcode.com/problems/subarray-sum-equals-k "和为K的子数组") @@ -28,15 +28,15 @@

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Two Sum](https://github.com/openset/leetcode/tree/master/problems/two-sum) (Easy) - 1. [Continuous Subarray Sum](https://github.com/openset/leetcode/tree/master/problems/continuous-subarray-sum) (Medium) - 1. [Subarray Product Less Than K](https://github.com/openset/leetcode/tree/master/problems/subarray-product-less-than-k) (Medium) - 1. [Find Pivot Index](https://github.com/openset/leetcode/tree/master/problems/find-pivot-index) (Easy) - 1. [Subarray Sums Divisible by K](https://github.com/openset/leetcode/tree/master/problems/subarray-sums-divisible-by-k) (Medium) + 1. [Two Sum](../two-sum) (Easy) + 1. [Continuous Subarray Sum](../continuous-subarray-sum) (Medium) + 1. [Subarray Product Less Than K](../subarray-product-less-than-k) (Medium) + 1. [Find Pivot Index](../find-pivot-index) (Easy) + 1. [Subarray Sums Divisible by K](../subarray-sums-divisible-by-k) (Medium) ### Hints
diff --git a/problems/subarray-sums-divisible-by-k/README.md b/problems/subarray-sums-divisible-by-k/README.md index 52b1a9ca5..3e42f6a1c 100644 --- a/problems/subarray-sums-divisible-by-k/README.md +++ b/problems/subarray-sums-divisible-by-k/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/k-closest-points-to-origin "K Closest Points to Origin") +[< Previous](../k-closest-points-to-origin "K Closest Points to Origin")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/odd-even-jump "Odd Even Jump") +[Next >](../odd-even-jump "Odd Even Jump") ## [974. Subarray Sums Divisible by K (Medium)](https://leetcode.com/problems/subarray-sums-divisible-by-k "和可被 K 整除的子数组") @@ -37,8 +37,8 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Subarray Sum Equals K](https://github.com/openset/leetcode/tree/master/problems/subarray-sum-equals-k) (Medium) + 1. [Subarray Sum Equals K](../subarray-sum-equals-k) (Medium) diff --git a/problems/subarrays-with-k-different-integers/README.md b/problems/subarrays-with-k-different-integers/README.md index 1314603bd..0ca5646b9 100644 --- a/problems/subarrays-with-k-different-integers/README.md +++ b/problems/subarrays-with-k-different-integers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/broken-calculator "Broken Calculator") +[< Previous](../broken-calculator "Broken Calculator")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/cousins-in-binary-tree "Cousins in Binary Tree") +[Next >](../cousins-in-binary-tree "Cousins in Binary Tree") ## [992. Subarrays with K Different Integers (Hard)](https://leetcode.com/problems/subarrays-with-k-different-integers "K 个不同整数的子数组") @@ -46,11 +46,11 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions - 1. [Longest Substring Without Repeating Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-without-repeating-characters) (Medium) - 1. [Longest Substring with At Most Two Distinct Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters) (Medium) - 1. [Longest Substring with At Most K Distinct Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-k-distinct-characters) (Hard) + 1. [Longest Substring Without Repeating Characters](../longest-substring-without-repeating-characters) (Medium) + 1. [Longest Substring with At Most Two Distinct Characters](../longest-substring-with-at-most-two-distinct-characters) (Medium) + 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Hard) diff --git a/problems/subdomain-visit-count/README.md b/problems/subdomain-visit-count/README.md index 57737d611..171f9bd4f 100644 --- a/problems/subdomain-visit-count/README.md +++ b/problems/subdomain-visit-count/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/chalkboard-xor-game "Chalkboard XOR Game") +[< Previous](../chalkboard-xor-game "Chalkboard XOR Game")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/largest-triangle-area "Largest Triangle Area") +[Next >](../largest-triangle-area "Largest Triangle Area") ## [811. Subdomain Visit Count (Easy)](https://leetcode.com/problems/subdomain-visit-count "子域名访问计数") @@ -50,4 +50,4 @@ We will visit "google.mail.com" 900 times, "yahoo.com" 50 ti ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/subsets-ii/README.md b/problems/subsets-ii/README.md index c3618f956..42c17dd50 100644 --- a/problems/subsets-ii/README.md +++ b/problems/subsets-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/gray-code "Gray Code") +[< Previous](../gray-code "Gray Code")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/decode-ways "Decode Ways") +[Next >](../decode-ways "Decode Ways") ## [90. Subsets II (Medium)](https://leetcode.com/problems/subsets-ii "子集 II") @@ -31,8 +31,8 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Array](../../tag/array/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Subsets](https://github.com/openset/leetcode/tree/master/problems/subsets) (Medium) + 1. [Subsets](../subsets) (Medium) diff --git a/problems/subsets/README.md b/problems/subsets/README.md index ca45e5c79..de74d43be 100644 --- a/problems/subsets/README.md +++ b/problems/subsets/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/combinations "Combinations") +[< Previous](../combinations "Combinations")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/word-search "Word Search") +[Next >](../word-search "Word Search") ## [78. Subsets (Medium)](https://leetcode.com/problems/subsets "子集") @@ -32,11 +32,11 @@ ] ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Subsets II](https://github.com/openset/leetcode/tree/master/problems/subsets-ii) (Medium) - 1. [Generalized Abbreviation](https://github.com/openset/leetcode/tree/master/problems/generalized-abbreviation) (Medium) - 1. [Letter Case Permutation](https://github.com/openset/leetcode/tree/master/problems/letter-case-permutation) (Easy) + 1. [Subsets II](../subsets-ii) (Medium) + 1. [Generalized Abbreviation](../generalized-abbreviation) (Medium) + 1. [Letter Case Permutation](../letter-case-permutation) (Easy) diff --git a/problems/substring-with-concatenation-of-all-words/README.md b/problems/substring-with-concatenation-of-all-words/README.md index ecbe77f62..960c8ec8c 100644 --- a/problems/substring-with-concatenation-of-all-words/README.md +++ b/problems/substring-with-concatenation-of-all-words/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/divide-two-integers "Divide Two Integers") +[< Previous](../divide-two-integers "Divide Two Integers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/next-permutation "Next Permutation") +[Next >](../next-permutation "Next Permutation") ## [30. Substring with Concatenation of All Words (Hard)](https://leetcode.com/problems/substring-with-concatenation-of-all-words "串联所有单词的子串") @@ -34,9 +34,9 @@ The output order does not matter, returning [9,0] is fine too. ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Minimum Window Substring](https://github.com/openset/leetcode/tree/master/problems/minimum-window-substring) (Hard) + 1. [Minimum Window Substring](../minimum-window-substring) (Hard) diff --git a/problems/subtract-the-product-and-sum-of-digits-of-an-integer/README.md b/problems/subtract-the-product-and-sum-of-digits-of-an-integer/README.md index d39edd388..e4546b616 100644 --- a/problems/subtract-the-product-and-sum-of-digits-of-an-integer/README.md +++ b/problems/subtract-the-product-and-sum-of-digits-of-an-integer/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/students-and-examinations "Students and Examinations") +[< Previous](../students-and-examinations "Students and Examinations")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/group-the-people-given-the-group-size-they-belong-to "Group the People Given the Group Size They Belong To") +[Next >](../group-the-people-given-the-group-size-they-belong-to "Group the People Given the Group Size They Belong To") ## [1281. Subtract the Product and Sum of Digits of an Integer (Easy)](https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer "整数的各位积和之差") @@ -43,7 +43,7 @@ Result = 32 - 11 = 21 ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/subtree-of-another-tree/README.md b/problems/subtree-of-another-tree/README.md index 7132dfd0e..6135f27a0 100644 --- a/problems/subtree-of-another-tree/README.md +++ b/problems/subtree-of-another-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-median-given-frequency-of-numbers "Find Median Given Frequency of Numbers") +[< Previous](../find-median-given-frequency-of-numbers "Find Median Given Frequency of Numbers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/squirrel-simulation "Squirrel Simulation") +[Next >](../squirrel-simulation "Squirrel Simulation") ## [572. Subtree of Another Tree (Easy)](https://leetcode.com/problems/subtree-of-another-tree "另一个树的子树") @@ -56,11 +56,11 @@ Return false.

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Count Univalue Subtrees](https://github.com/openset/leetcode/tree/master/problems/count-univalue-subtrees) (Medium) - 1. [Most Frequent Subtree Sum](https://github.com/openset/leetcode/tree/master/problems/most-frequent-subtree-sum) (Medium) + 1. [Count Univalue Subtrees](../count-univalue-subtrees) (Medium) + 1. [Most Frequent Subtree Sum](../most-frequent-subtree-sum) (Medium) ### Hints
diff --git a/problems/sudoku-solver/README.md b/problems/sudoku-solver/README.md index 1f9f36c27..a1e6c8ae4 100644 --- a/problems/sudoku-solver/README.md +++ b/problems/sudoku-solver/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-sudoku "Valid Sudoku") +[< Previous](../valid-sudoku "Valid Sudoku")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/count-and-say "Count and Say") +[Next >](../count-and-say "Count and Say") ## [37. Sudoku Solver (Hard)](https://leetcode.com/problems/sudoku-solver "解数独") @@ -38,9 +38,9 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Valid Sudoku](https://github.com/openset/leetcode/tree/master/problems/valid-sudoku) (Medium) - 1. [Unique Paths III](https://github.com/openset/leetcode/tree/master/problems/unique-paths-iii) (Hard) + 1. [Valid Sudoku](../valid-sudoku) (Medium) + 1. [Unique Paths III](../unique-paths-iii) (Hard) diff --git a/problems/sum-of-digits-in-the-minimum-number/README.md b/problems/sum-of-digits-in-the-minimum-number/README.md index ea5acf8e3..3fd20a926 100644 --- a/problems/sum-of-digits-in-the-minimum-number/README.md +++ b/problems/sum-of-digits-in-the-minimum-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sales-analysis-iii "Sales Analysis III") +[< Previous](../sales-analysis-iii "Sales Analysis III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/high-five "High Five") +[Next >](../high-five "High Five") ## [1085. Sum of Digits in the Minimum Number (Easy)](https://leetcode.com/problems/sum-of-digits-in-the-minimum-number "最小元素各数位之和") @@ -45,10 +45,10 @@ The minimal element is 33, and the sum of those digits is S = 3 + 3 = 6 which is ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Add Digits](https://github.com/openset/leetcode/tree/master/problems/add-digits) (Easy) + 1. [Add Digits](../add-digits) (Easy) ### Hints
diff --git a/problems/sum-of-distances-in-tree/README.md b/problems/sum-of-distances-in-tree/README.md index 24003e64d..9798110da 100644 --- a/problems/sum-of-distances-in-tree/README.md +++ b/problems/sum-of-distances-in-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-and-replace-in-string "Find And Replace in String") +[< Previous](../find-and-replace-in-string "Find And Replace in String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/image-overlap "Image Overlap") +[Next >](../image-overlap "Image Overlap") ## [834. Sum of Distances in Tree (Hard)](https://leetcode.com/problems/sum-of-distances-in-tree "树中距离之和") @@ -36,8 +36,8 @@ equals 1 + 1 + 2 + 2 + 2 = 8. Hence, answer[0] = 8, and so on.

Note: 1 <= N <= 10000

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Distribute Coins in Binary Tree](https://github.com/openset/leetcode/tree/master/problems/distribute-coins-in-binary-tree) (Medium) + 1. [Distribute Coins in Binary Tree](../distribute-coins-in-binary-tree) (Medium) diff --git a/problems/sum-of-even-numbers-after-queries/README.md b/problems/sum-of-even-numbers-after-queries/README.md index 7928f30ff..ba86d4305 100644 --- a/problems/sum-of-even-numbers-after-queries/README.md +++ b/problems/sum-of-even-numbers-after-queries/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/string-without-aaa-or-bbb "String Without AAA or BBB") +[< Previous](../string-without-aaa-or-bbb "String Without AAA or BBB")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/interval-list-intersections "Interval List Intersections") +[Next >](../interval-list-intersections "Interval List Intersections") ## [985. Sum of Even Numbers After Queries (Easy)](https://leetcode.com/problems/sum-of-even-numbers-after-queries "查询后的偶数和") @@ -47,4 +47,4 @@ After adding 2 to A[3], the array is [-2,-1,3,6], and the sum of even values is ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/sum-of-left-leaves/README.md b/problems/sum-of-left-leaves/README.md index b9e08cc10..350540eef 100644 --- a/problems/sum-of-left-leaves/README.md +++ b/problems/sum-of-left-leaves/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/frog-jump "Frog Jump") +[< Previous](../frog-jump "Frog Jump")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/convert-a-number-to-hexadecimal "Convert a Number to Hexadecimal") +[Next >](../convert-a-number-to-hexadecimal "Convert a Number to Hexadecimal") ## [404. Sum of Left Leaves (Easy)](https://leetcode.com/problems/sum-of-left-leaves "左叶子之和") @@ -26,4 +26,4 @@ There are two left leaves in the binary tree, with values 9 and 15

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] diff --git a/problems/sum-of-root-to-leaf-binary-numbers/README.md b/problems/sum-of-root-to-leaf-binary-numbers/README.md index 5973095af..acca3d117 100644 --- a/problems/sum-of-root-to-leaf-binary-numbers/README.md +++ b/problems/sum-of-root-to-leaf-binary-numbers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-outermost-parentheses "Remove Outermost Parentheses") +[< Previous](../remove-outermost-parentheses "Remove Outermost Parentheses")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/camelcase-matching "Camelcase Matching") +[Next >](../camelcase-matching "Camelcase Matching") ## [1022. Sum of Root To Leaf Binary Numbers (Easy)](https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers "从根到叶的二进制数之和") @@ -40,7 +40,7 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Hints
diff --git a/problems/sum-of-square-numbers/README.md b/problems/sum-of-square-numbers/README.md index b15e6487f..92227ec87 100644 --- a/problems/sum-of-square-numbers/README.md +++ b/problems/sum-of-square-numbers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/smallest-range-covering-elements-from-k-lists "Smallest Range Covering Elements from K Lists") +[< Previous](../smallest-range-covering-elements-from-k-lists "Smallest Range Covering Elements from K Lists")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-the-derangement-of-an-array "Find the Derangement of An Array") +[Next >](../find-the-derangement-of-an-array "Find the Derangement of An Array") ## [633. Sum of Square Numbers (Easy)](https://leetcode.com/problems/sum-of-square-numbers "平方数之和") @@ -33,7 +33,7 @@

 

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Valid Perfect Square](https://github.com/openset/leetcode/tree/master/problems/valid-perfect-square) (Easy) + 1. [Valid Perfect Square](../valid-perfect-square) (Easy) diff --git a/problems/sum-of-subarray-minimums/README.md b/problems/sum-of-subarray-minimums/README.md index bd334bc5b..0809c6df5 100644 --- a/problems/sum-of-subarray-minimums/README.md +++ b/problems/sum-of-subarray-minimums/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/super-palindromes "Super Palindromes") +[< Previous](../super-palindromes "Super Palindromes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/smallest-range-i "Smallest Range I") +[Next >](../smallest-range-i "Smallest Range I") ## [907. Sum of Subarray Minimums (Medium)](https://leetcode.com/problems/sum-of-subarray-minimums "子数组的最小值之和") @@ -39,5 +39,5 @@ Minimums are 3, 1, 2, 4, 1, 1, 2, 1, 1, 1.  Sum is 17. ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/sum-of-subsequence-widths/README.md b/problems/sum-of-subsequence-widths/README.md index c09756beb..84cb22159 100644 --- a/problems/sum-of-subsequence-widths/README.md +++ b/problems/sum-of-subsequence-widths/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-and-replace-pattern "Find and Replace Pattern") +[< Previous](../find-and-replace-pattern "Find and Replace Pattern")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/surface-area-of-3d-shapes "Surface Area of 3D Shapes") +[Next >](../surface-area-of-3d-shapes "Surface Area of 3D Shapes") ## [891. Sum of Subsequence Widths (Hard)](https://leetcode.com/problems/sum-of-subsequence-widths "子序列宽度之和") @@ -44,5 +44,5 @@ The sum of these widths is 6. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/sum-of-two-integers/README.md b/problems/sum-of-two-integers/README.md index fb6f1af46..2246f3da4 100644 --- a/problems/sum-of-two-integers/README.md +++ b/problems/sum-of-two-integers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/range-addition "Range Addition") +[< Previous](../range-addition "Range Addition")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/super-pow "Super Pow") +[Next >](../super-pow "Super Pow") ## [371. Sum of Two Integers (Easy)](https://leetcode.com/problems/sum-of-two-integers "两整数之和") @@ -32,7 +32,7 @@ ### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions - 1. [Add Two Numbers](https://github.com/openset/leetcode/tree/master/problems/add-two-numbers) (Medium) + 1. [Add Two Numbers](../add-two-numbers) (Medium) diff --git a/problems/sum-root-to-leaf-numbers/README.md b/problems/sum-root-to-leaf-numbers/README.md index df87bd7a2..b6da1efa5 100644 --- a/problems/sum-root-to-leaf-numbers/README.md +++ b/problems/sum-root-to-leaf-numbers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-consecutive-sequence "Longest Consecutive Sequence") +[< Previous](../longest-consecutive-sequence "Longest Consecutive Sequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/surrounded-regions "Surrounded Regions") +[Next >](../surrounded-regions "Surrounded Regions") ## [129. Sum Root to Leaf Numbers (Medium)](https://leetcode.com/problems/sum-root-to-leaf-numbers "求根到叶子节点数字之和") @@ -49,10 +49,10 @@ The root-to-leaf path 4->0 represents the number 40. Therefore, sum = 495 + 491 + 40 = 1026. ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Path Sum](https://github.com/openset/leetcode/tree/master/problems/path-sum) (Easy) - 1. [Binary Tree Maximum Path Sum](https://github.com/openset/leetcode/tree/master/problems/binary-tree-maximum-path-sum) (Hard) - 1. [Smallest String Starting From Leaf](https://github.com/openset/leetcode/tree/master/problems/smallest-string-starting-from-leaf) (Medium) + 1. [Path Sum](../path-sum) (Easy) + 1. [Binary Tree Maximum Path Sum](../binary-tree-maximum-path-sum) (Hard) + 1. [Smallest String Starting From Leaf](../smallest-string-starting-from-leaf) (Medium) diff --git a/problems/summary-ranges/README.md b/problems/summary-ranges/README.md index df0940a9d..89f7fc379 100644 --- a/problems/summary-ranges/README.md +++ b/problems/summary-ranges/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-ii "Basic Calculator II") +[< Previous](../basic-calculator-ii "Basic Calculator II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/majority-element-ii "Majority Element II") +[Next >](../majority-element-ii "Majority Element II") ## [228. Summary Ranges (Medium)](https://leetcode.com/problems/summary-ranges "汇总区间") @@ -30,8 +30,8 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Missing Ranges](https://github.com/openset/leetcode/tree/master/problems/missing-ranges) (Medium) - 1. [Data Stream as Disjoint Intervals](https://github.com/openset/leetcode/tree/master/problems/data-stream-as-disjoint-intervals) (Hard) + 1. [Missing Ranges](../missing-ranges) (Medium) + 1. [Data Stream as Disjoint Intervals](../data-stream-as-disjoint-intervals) (Hard) diff --git a/problems/super-egg-drop/README.md b/problems/super-egg-drop/README.md index ba940f3ab..469a1468f 100644 --- a/problems/super-egg-drop/README.md +++ b/problems/super-egg-drop/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/possible-bipartition "Possible Bipartition") +[< Previous](../possible-bipartition "Possible Bipartition")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/fair-candy-swap "Fair Candy Swap") +[Next >](../fair-candy-swap "Fair Candy Swap") ## [887. Super Egg Drop (Hard)](https://leetcode.com/problems/super-egg-drop "鸡蛋掉落") @@ -70,6 +70,6 @@ Hence, we needed 2 moves in the worst case to know what F is with certainty. ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/super-palindromes/README.md b/problems/super-palindromes/README.md index 7c1955310..e472475a6 100644 --- a/problems/super-palindromes/README.md +++ b/problems/super-palindromes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sort-array-by-parity "Sort Array By Parity") +[< Previous](../sort-array-by-parity "Sort Array By Parity")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sum-of-subarray-minimums "Sum of Subarray Minimums") +[Next >](../sum-of-subarray-minimums "Sum of Subarray Minimums") ## [906. Super Palindromes (Hard)](https://leetcode.com/problems/super-palindromes "超级回文数") @@ -41,4 +41,4 @@ Note that 676 is not a superpalindrome: 26 * 26 = 676, but 26 is not a palindrom ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/super-pow/README.md b/problems/super-pow/README.md index dc1f69a72..1002c7117 100644 --- a/problems/super-pow/README.md +++ b/problems/super-pow/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sum-of-two-integers "Sum of Two Integers") +[< Previous](../sum-of-two-integers "Sum of Two Integers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-k-pairs-with-smallest-sums "Find K Pairs with Smallest Sums") +[Next >](../find-k-pairs-with-smallest-sums "Find K Pairs with Smallest Sums") ## [372. Super Pow (Medium)](https://leetcode.com/problems/super-pow "超级次方") @@ -32,7 +32,7 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Pow(x, n)](https://github.com/openset/leetcode/tree/master/problems/powx-n) (Medium) + 1. [Pow(x, n)](../powx-n) (Medium) diff --git a/problems/super-ugly-number/README.md b/problems/super-ugly-number/README.md index 2c926a6ea..df2add319 100644 --- a/problems/super-ugly-number/README.md +++ b/problems/super-ugly-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/burst-balloons "Burst Balloons") +[< Previous](../burst-balloons "Burst Balloons")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-tree-vertical-order-traversal "Binary Tree Vertical Order Traversal") +[Next >](../binary-tree-vertical-order-traversal "Binary Tree Vertical Order Traversal") ## [313. Super Ugly Number (Medium)](https://leetcode.com/problems/super-ugly-number "超级丑数") @@ -33,8 +33,8 @@ ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Ugly Number II](https://github.com/openset/leetcode/tree/master/problems/ugly-number-ii) (Medium) + 1. [Ugly Number II](../ugly-number-ii) (Medium) diff --git a/problems/super-washing-machines/README.md b/problems/super-washing-machines/README.md index 92179b0b7..c0a6b288b 100644 --- a/problems/super-washing-machines/README.md +++ b/problems/super-washing-machines/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-palindromic-subsequence "Longest Palindromic Subsequence") +[< Previous](../longest-palindromic-subsequence "Longest Palindromic Subsequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/coin-change-2 "Coin Change 2") +[Next >](../coin-change-2 "Coin Change 2") ## [517. Super Washing Machines (Hard)](https://leetcode.com/problems/super-washing-machines "超级洗衣机") @@ -61,5 +61,5 @@ It's impossible to make all the three washing machines have the same number of d

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/surface-area-of-3d-shapes/README.md b/problems/surface-area-of-3d-shapes/README.md index 333b38b12..ee4fe1698 100644 --- a/problems/surface-area-of-3d-shapes/README.md +++ b/problems/surface-area-of-3d-shapes/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sum-of-subsequence-widths "Sum of Subsequence Widths") +[< Previous](../sum-of-subsequence-widths "Sum of Subsequence Widths")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/groups-of-special-equivalent-strings "Groups of Special-Equivalent Strings") +[Next >](../groups-of-special-equivalent-strings "Groups of Special-Equivalent Strings") ## [892. Surface Area of 3D Shapes (Easy)](https://leetcode.com/problems/surface-area-of-3d-shapes "三维形体的表面积") @@ -83,5 +83,5 @@ ### Related Topics - [[Geometry](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/surrounded-regions/README.md b/problems/surrounded-regions/README.md index 34c2a83d0..0a565a22b 100644 --- a/problems/surrounded-regions/README.md +++ b/problems/surrounded-regions/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sum-root-to-leaf-numbers "Sum Root to Leaf Numbers") +[< Previous](../sum-root-to-leaf-numbers "Sum Root to Leaf Numbers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/palindrome-partitioning "Palindrome Partitioning") +[Next >](../palindrome-partitioning "Palindrome Partitioning") ## [130. Surrounded Regions (Medium)](https://leetcode.com/problems/surrounded-regions "被围绕的区域") @@ -38,10 +38,10 @@ X O X X

Surrounded regions shouldn’t be on the border, which means that any 'O' on the border of the board are not flipped to 'X'. Any 'O' that is not on the border and it is not connected to an 'O' on the border will be flipped to 'X'. Two cells are connected if they are adjacent cells connected horizontally or vertically.

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] ### Similar Questions - 1. [Number of Islands](https://github.com/openset/leetcode/tree/master/problems/number-of-islands) (Medium) - 1. [Walls and Gates](https://github.com/openset/leetcode/tree/master/problems/walls-and-gates) (Medium) + 1. [Number of Islands](../number-of-islands) (Medium) + 1. [Walls and Gates](../walls-and-gates) (Medium) diff --git a/problems/swap-adjacent-in-lr-string/README.md b/problems/swap-adjacent-in-lr-string/README.md index 1768b653c..4294ce3c1 100644 --- a/problems/swap-adjacent-in-lr-string/README.md +++ b/problems/swap-adjacent-in-lr-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/split-bst "Split BST") +[< Previous](../split-bst "Split BST")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/swim-in-rising-water "Swim in Rising Water") +[Next >](../swim-in-rising-water "Swim in Rising Water") ## [777. Swap Adjacent in LR String (Medium)](https://leetcode.com/problems/swap-adjacent-in-lr-string "在LR字符串中交换相邻字符") @@ -35,7 +35,7 @@ XRLXXRRLX ### Related Topics - [[Brainteaser](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md)] + [[Brainteaser](../../tag/brainteaser/README.md)] ### Hints
diff --git a/problems/swap-for-longest-repeated-character-substring/README.md b/problems/swap-for-longest-repeated-character-substring/README.md index f128f05f7..45c14c636 100644 --- a/problems/swap-for-longest-repeated-character-substring/README.md +++ b/problems/swap-for-longest-repeated-character-substring/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-dice-rolls-with-target-sum "Number of Dice Rolls With Target Sum") +[< Previous](../number-of-dice-rolls-with-target-sum "Number of Dice Rolls With Target Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/online-majority-element-in-subarray "Online Majority Element In Subarray") +[Next >](../online-majority-element-in-subarray "Online Majority Element In Subarray") ## [1156. Swap For Longest Repeated Character Substring (Medium)](https://leetcode.com/problems/swap-for-longest-repeated-character-substring "单字符重复子串的最大长度") @@ -61,7 +61,7 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/swap-nodes-in-pairs/README.md b/problems/swap-nodes-in-pairs/README.md index b578a5885..096ab636b 100644 --- a/problems/swap-nodes-in-pairs/README.md +++ b/problems/swap-nodes-in-pairs/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/merge-k-sorted-lists "Merge k Sorted Lists") +[< Previous](../merge-k-sorted-lists "Merge k Sorted Lists")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reverse-nodes-in-k-group "Reverse Nodes in k-Group") +[Next >](../reverse-nodes-in-k-group "Reverse Nodes in k-Group") ## [24. Swap Nodes in Pairs (Medium)](https://leetcode.com/problems/swap-nodes-in-pairs "两两交换链表中的节点") @@ -24,7 +24,7 @@ Given 1->2->3->4, you should return the list as 2-&g ### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions - 1. [Reverse Nodes in k-Group](https://github.com/openset/leetcode/tree/master/problems/reverse-nodes-in-k-group) (Hard) + 1. [Reverse Nodes in k-Group](../reverse-nodes-in-k-group) (Hard) diff --git a/problems/swap-salary/README.md b/problems/swap-salary/README.md index 9d3220c92..7b1d08c64 100644 --- a/problems/swap-salary/README.md +++ b/problems/swap-salary/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/exchange-seats "Exchange Seats") +[< Previous](../exchange-seats "Exchange Seats")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-product-of-three-numbers "Maximum Product of Three Numbers") +[Next >](../maximum-product-of-three-numbers "Maximum Product of Three Numbers") ## [627. Swap Salary (Easy)](https://leetcode.com/problems/swap-salary "交换工资") diff --git a/problems/swim-in-rising-water/README.md b/problems/swim-in-rising-water/README.md index 583325f02..cb0e65a99 100644 --- a/problems/swim-in-rising-water/README.md +++ b/problems/swim-in-rising-water/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/swap-adjacent-in-lr-string "Swap Adjacent in LR String") +[< Previous](../swap-adjacent-in-lr-string "Swap Adjacent in LR String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/k-th-symbol-in-grammar "K-th Symbol in Grammar") +[Next >](../k-th-symbol-in-grammar "K-th Symbol in Grammar") ## [778. Swim in Rising Water (Hard)](https://leetcode.com/problems/swim-in-rising-water "水位上升的泳池中游泳") @@ -54,10 +54,10 @@ We need to wait until time 16 so that (0, 0) and (4, 4) are connected. ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
diff --git a/problems/symmetric-tree/README.md b/problems/symmetric-tree/README.md index 98c856b9d..f3ddf815e 100644 --- a/problems/symmetric-tree/README.md +++ b/problems/symmetric-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/same-tree "Same Tree") +[< Previous](../same-tree "Same Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal "Binary Tree Level Order Traversal") +[Next >](../binary-tree-level-order-traversal "Binary Tree Level Order Traversal") ## [101. Symmetric Tree (Easy)](https://leetcode.com/problems/symmetric-tree "对称二叉树") @@ -41,6 +41,6 @@ Bonus points if you could solve it both recursively and iteratively.

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/synonymous-sentences/README.md b/problems/synonymous-sentences/README.md index 4c160667c..43d71fe59 100644 --- a/problems/synonymous-sentences/README.md +++ b/problems/synonymous-sentences/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/smallest-common-region "Smallest Common Region") +[< Previous](../smallest-common-region "Smallest Common Region")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/handshakes-that-dont-cross "Handshakes That Don't Cross") +[Next >](../handshakes-that-dont-cross "Handshakes That Don't Cross") ## [1258. Synonymous Sentences (Medium)](https://leetcode.com/problems/synonymous-sentences "近义词句子") @@ -40,7 +40,7 @@ text = "I am happy today but was sad yesterday" ### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Hints
diff --git a/problems/tag-validator/README.md b/problems/tag-validator/README.md index da97f1dd4..fba46fb64 100644 --- a/problems/tag-validator/README.md +++ b/problems/tag-validator/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-postorder-traversal "N-ary Tree Postorder Traversal") +[< Previous](../n-ary-tree-postorder-traversal "N-ary Tree Postorder Traversal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/fraction-addition-and-subtraction "Fraction Addition and Subtraction") +[Next >](../fraction-addition-and-subtraction "Fraction Addition and Subtraction") ## [591. Tag Validator (Hard)](https://leetcode.com/problems/tag-validator "标签验证器") @@ -79,8 +79,8 @@ The reason why cdata is NOT "<![CDATA[<div>]>]]>]]>" is because of

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Add Bold Tag in String](https://github.com/openset/leetcode/tree/master/problems/add-bold-tag-in-string) (Medium) + 1. [Add Bold Tag in String](../add-bold-tag-in-string) (Medium) diff --git a/problems/tallest-billboard/README.md b/problems/tallest-billboard/README.md index e2fe5b01b..b679a03ce 100644 --- a/problems/tallest-billboard/README.md +++ b/problems/tallest-billboard/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/delete-columns-to-make-sorted-ii "Delete Columns to Make Sorted II") +[< Previous](../delete-columns-to-make-sorted-ii "Delete Columns to Make Sorted II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/prison-cells-after-n-days "Prison Cells After N Days") +[Next >](../prison-cells-after-n-days "Prison Cells After N Days") ## [956. Tallest Billboard (Hard)](https://leetcode.com/problems/tallest-billboard "最高的广告牌") @@ -58,4 +58,4 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/target-sum/README.md b/problems/target-sum/README.md index 79e033662..05d61081c 100644 --- a/problems/target-sum/README.md +++ b/problems/target-sum/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/reverse-pairs "Reverse Pairs") +[< Previous](../reverse-pairs "Reverse Pairs")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/teemo-attacking "Teemo Attacking") +[Next >](../teemo-attacking "Teemo Attacking") ## [494. Target Sum (Medium)](https://leetcode.com/problems/target-sum "目标和") @@ -43,8 +43,8 @@ There are 5 ways to assign symbols to make the sum of nums be target 3.

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Expression Add Operators](https://github.com/openset/leetcode/tree/master/problems/expression-add-operators) (Hard) + 1. [Expression Add Operators](../expression-add-operators) (Hard) diff --git a/problems/task-scheduler/README.md b/problems/task-scheduler/README.md index 52f985e36..850176dde 100644 --- a/problems/task-scheduler/README.md +++ b/problems/task-scheduler/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/not-boring-movies "Not Boring Movies") +[< Previous](../not-boring-movies "Not Boring Movies")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-circular-queue "Design Circular Queue") +[Next >](../design-circular-queue "Design Circular Queue") ## [621. Task Scheduler (Medium)](https://leetcode.com/problems/task-scheduler "任务调度器") @@ -37,10 +37,10 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Queue](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Rearrange String k Distance Apart](https://github.com/openset/leetcode/tree/master/problems/rearrange-string-k-distance-apart) (Hard) - 1. [Reorganize String](https://github.com/openset/leetcode/tree/master/problems/reorganize-string) (Medium) + 1. [Rearrange String k Distance Apart](../rearrange-string-k-distance-apart) (Hard) + 1. [Reorganize String](../reorganize-string) (Medium) diff --git a/problems/team-scores-in-football-tournament/README.md b/problems/team-scores-in-football-tournament/README.md index d4152785d..b2540c4ef 100644 --- a/problems/team-scores-in-football-tournament/README.md +++ b/problems/team-scores-in-football-tournament/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/queries-quality-and-percentage "Queries Quality and Percentage") +[< Previous](../queries-quality-and-percentage "Queries Quality and Percentage")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/intersection-of-three-sorted-arrays "Intersection of Three Sorted Arrays") +[Next >](../intersection-of-three-sorted-arrays "Intersection of Three Sorted Arrays") ## [1212. Team Scores in Football Tournament (Medium)](https://leetcode.com/problems/team-scores-in-football-tournament "") diff --git a/problems/teemo-attacking/README.md b/problems/teemo-attacking/README.md index 2d69fc305..fbbd70e3e 100644 --- a/problems/teemo-attacking/README.md +++ b/problems/teemo-attacking/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/target-sum "Target Sum") +[< Previous](../target-sum "Target Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-i "Next Greater Element I") +[Next >](../next-greater-element-i "Next Greater Element I") ## [495. Teemo Attacking (Medium)](https://leetcode.com/problems/teemo-attacking "提莫攻击") @@ -52,9 +52,9 @@ So you finally need to output 3.

 

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Merge Intervals](https://github.com/openset/leetcode/tree/master/problems/merge-intervals) (Medium) - 1. [Can Place Flowers](https://github.com/openset/leetcode/tree/master/problems/can-place-flowers) (Easy) - 1. [Dota2 Senate](https://github.com/openset/leetcode/tree/master/problems/dota2-senate) (Medium) + 1. [Merge Intervals](../merge-intervals) (Medium) + 1. [Can Place Flowers](../can-place-flowers) (Easy) + 1. [Dota2 Senate](../dota2-senate) (Medium) diff --git a/problems/tenth-line/README.md b/problems/tenth-line/README.md index 8ead6d1f4..3b07a0e65 100644 --- a/problems/tenth-line/README.md +++ b/problems/tenth-line/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/transpose-file "Transpose File") +[< Previous](../transpose-file "Transpose File")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/delete-duplicate-emails "Delete Duplicate Emails") +[Next >](../delete-duplicate-emails "Delete Duplicate Emails") ## [195. Tenth Line (Easy)](https://leetcode.com/problems/tenth-line "第十行") diff --git a/problems/ternary-expression-parser/README.md b/problems/ternary-expression-parser/README.md index 6bb2facb1..2a4a1a0fd 100644 --- a/problems/ternary-expression-parser/README.md +++ b/problems/ternary-expression-parser/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-all-anagrams-in-a-string "Find All Anagrams in a String") +[< Previous](../find-all-anagrams-in-a-string "Find All Anagrams in a String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/k-th-smallest-in-lexicographical-order "K-th Smallest in Lexicographical Order") +[Next >](../k-th-smallest-in-lexicographical-order "K-th Smallest in Lexicographical Order") ## [439. Ternary Expression Parser (Medium)](https://leetcode.com/problems/ternary-expression-parser "三元表达式解析器") @@ -65,10 +65,10 @@

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Mini Parser](https://github.com/openset/leetcode/tree/master/problems/mini-parser) (Medium) - 1. [Remove Comments](https://github.com/openset/leetcode/tree/master/problems/remove-comments) (Medium) - 1. [Parse Lisp Expression](https://github.com/openset/leetcode/tree/master/problems/parse-lisp-expression) (Hard) + 1. [Mini Parser](../mini-parser) (Medium) + 1. [Remove Comments](../remove-comments) (Medium) + 1. [Parse Lisp Expression](../parse-lisp-expression) (Hard) diff --git a/problems/text-justification/README.md b/problems/text-justification/README.md index d767346df..d86a652d8 100644 --- a/problems/text-justification/README.md +++ b/problems/text-justification/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/add-binary "Add Binary") +[< Previous](../add-binary "Add Binary")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sqrtx "Sqrt(x)") +[Next >](../sqrtx "Sqrt(x)") ## [68. Text Justification (Hard)](https://leetcode.com/problems/text-justification "文本左右对齐") @@ -77,4 +77,4 @@ maxWidth = 20 ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/the-dining-philosophers/README.md b/problems/the-dining-philosophers/README.md index 69093ccf2..c3718c5ca 100644 --- a/problems/the-dining-philosophers/README.md +++ b/problems/the-dining-philosophers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/report-contiguous-dates "Report Contiguous Dates") +[< Previous](../report-contiguous-dates "Report Contiguous Dates")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/airplane-seat-assignment-probability "Airplane Seat Assignment Probability") +[Next >](../airplane-seat-assignment-probability "Airplane Seat Assignment Probability") ## [1226. The Dining Philosophers (Medium)](https://leetcode.com/problems/the-dining-philosophers "哲学家进餐") diff --git a/problems/the-earliest-moment-when-everyone-become-friends/README.md b/problems/the-earliest-moment-when-everyone-become-friends/README.md index ad6fc9f2f..555bde857 100644 --- a/problems/the-earliest-moment-when-everyone-become-friends/README.md +++ b/problems/the-earliest-moment-when-everyone-become-friends/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-k-length-substrings-with-no-repeated-characters "Find K-Length Substrings With No Repeated Characters") +[< Previous](../find-k-length-substrings-with-no-repeated-characters "Find K-Length Substrings With No Repeated Characters")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/path-with-maximum-minimum-value "Path With Maximum Minimum Value") +[Next >](../path-with-maximum-minimum-value "Path With Maximum Minimum Value") ## [1101. The Earliest Moment When Everyone Become Friends (Medium)](https://leetcode.com/problems/the-earliest-moment-when-everyone-become-friends "彼此熟识的最早时间") @@ -52,10 +52,10 @@ The sixth event occurs at timestamp = 20190301 and after 0 and 3 become friends ### Related Topics - [[Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] + [[Union Find](../../tag/union-find/README.md)] ### Similar Questions - 1. [Friend Circles](https://github.com/openset/leetcode/tree/master/problems/friend-circles) (Medium) + 1. [Friend Circles](../friend-circles) (Medium) ### Hints
diff --git a/problems/the-maze-ii/README.md b/problems/the-maze-ii/README.md index 51e8d2bd0..9f26c256a 100644 --- a/problems/the-maze-ii/README.md +++ b/problems/the-maze-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/base-7 "Base 7") +[< Previous](../base-7 "Base 7")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/relative-ranks "Relative Ranks") +[Next >](../relative-ranks "Relative Ranks") ## [505. The Maze II (Medium)](https://leetcode.com/problems/the-maze-ii "迷宫 II") @@ -70,9 +70,9 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions - 1. [The Maze](https://github.com/openset/leetcode/tree/master/problems/the-maze) (Medium) - 1. [The Maze III](https://github.com/openset/leetcode/tree/master/problems/the-maze-iii) (Hard) + 1. [The Maze](../the-maze) (Medium) + 1. [The Maze III](../the-maze-iii) (Hard) diff --git a/problems/the-maze-iii/README.md b/problems/the-maze-iii/README.md index 85c7c3cf1..7be1d3db1 100644 --- a/problems/the-maze-iii/README.md +++ b/problems/the-maze-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/diagonal-traverse "Diagonal Traverse") +[< Previous](../diagonal-traverse "Diagonal Traverse")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/keyboard-row "Keyboard Row") +[Next >](../keyboard-row "Keyboard Row") ## [499. The Maze III (Hard)](https://leetcode.com/problems/the-maze-iii "迷宫 III") @@ -74,9 +74,9 @@ Both ways have shortest distance 6, but the first way is lexicographically small ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions - 1. [The Maze](https://github.com/openset/leetcode/tree/master/problems/the-maze) (Medium) - 1. [The Maze II](https://github.com/openset/leetcode/tree/master/problems/the-maze-ii) (Medium) + 1. [The Maze](../the-maze) (Medium) + 1. [The Maze II](../the-maze-ii) (Medium) diff --git a/problems/the-maze/README.md b/problems/the-maze/README.md index 354fea1be..2086ae8c2 100644 --- a/problems/the-maze/README.md +++ b/problems/the-maze/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/robot-room-cleaner "Robot Room Cleaner") +[< Previous](../robot-room-cleaner "Robot Room Cleaner")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/increasing-subsequences "Increasing Subsequences") +[Next >](../increasing-subsequences "Increasing Subsequences") ## [490. The Maze (Medium)](https://leetcode.com/problems/the-maze "迷宫") @@ -69,9 +69,9 @@ ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions - 1. [The Maze III](https://github.com/openset/leetcode/tree/master/problems/the-maze-iii) (Hard) - 1. [The Maze II](https://github.com/openset/leetcode/tree/master/problems/the-maze-ii) (Medium) + 1. [The Maze III](../the-maze-iii) (Hard) + 1. [The Maze II](../the-maze-ii) (Medium) diff --git a/problems/the-skyline-problem/README.md b/problems/the-skyline-problem/README.md index 04395608d..93add4fcd 100644 --- a/problems/the-skyline-problem/README.md +++ b/problems/the-skyline-problem/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate "Contains Duplicate") +[< Previous](../contains-duplicate "Contains Duplicate")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate-ii "Contains Duplicate II") +[Next >](../contains-duplicate-ii "Contains Duplicate II") ## [218. The Skyline Problem (Hard)](https://leetcode.com/problems/the-skyline-problem "天际线问题") @@ -32,11 +32,11 @@ ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Binary Indexed Tree](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] - [[Segment Tree](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] - [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Line Sweep](../../tag/line-sweep/README.md)] ### Similar Questions - 1. [Falling Squares](https://github.com/openset/leetcode/tree/master/problems/falling-squares) (Hard) + 1. [Falling Squares](../falling-squares) (Hard) diff --git a/problems/third-maximum-number/README.md b/problems/third-maximum-number/README.md index 356f94be2..e9f44de98 100644 --- a/problems/third-maximum-number/README.md +++ b/problems/third-maximum-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/arithmetic-slices "Arithmetic Slices") +[< Previous](../arithmetic-slices "Arithmetic Slices")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/add-strings "Add Strings") +[Next >](../add-strings "Add Strings") ## [414. Third Maximum Number (Easy)](https://leetcode.com/problems/third-maximum-number "第三大的数") @@ -45,7 +45,7 @@ Both numbers with value 2 are both considered as second maximum.

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Kth Largest Element in an Array](https://github.com/openset/leetcode/tree/master/problems/kth-largest-element-in-an-array) (Medium) + 1. [Kth Largest Element in an Array](../kth-largest-element-in-an-array) (Medium) diff --git a/problems/three-equal-parts/README.md b/problems/three-equal-parts/README.md index 318af4cb7..1996c733e 100644 --- a/problems/three-equal-parts/README.md +++ b/problems/three-equal-parts/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/flip-string-to-monotone-increasing "Flip String to Monotone Increasing") +[< Previous](../flip-string-to-monotone-increasing "Flip String to Monotone Increasing")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimize-malware-spread-ii "Minimize Malware Spread II") +[Next >](../minimize-malware-spread-ii "Minimize Malware Spread II") ## [927. Three Equal Parts (Hard)](https://leetcode.com/problems/three-equal-parts "三等分") @@ -57,6 +57,6 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/tiling-a-rectangle-with-the-fewest-squares/README.md b/problems/tiling-a-rectangle-with-the-fewest-squares/README.md index bd4b0ae3b..2491a536b 100644 --- a/problems/tiling-a-rectangle-with-the-fewest-squares/README.md +++ b/problems/tiling-a-rectangle-with-the-fewest-squares/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-a-concatenated-string-with-unique-characters "Maximum Length of a Concatenated String with Unique Characters") +[< Previous](../maximum-length-of-a-concatenated-string-with-unique-characters "Maximum Length of a Concatenated String with Unique Characters")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-comments-per-post "Number of Comments per Post") +[Next >](../number-of-comments-per-post "Number of Comments per Post") ## [1240. Tiling a Rectangle with the Fewest Squares (Hard)](https://leetcode.com/problems/tiling-a-rectangle-with-the-fewest-squares "铺瓷砖") @@ -52,8 +52,8 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Hints
diff --git a/problems/time-based-key-value-store/README.md b/problems/time-based-key-value-store/README.md index fd44094a2..bb0d03f42 100644 --- a/problems/time-based-key-value-store/README.md +++ b/problems/time-based-key-value-store/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/unique-paths-iii "Unique Paths III") +[< Previous](../unique-paths-iii "Unique Paths III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/triples-with-bitwise-and-equal-to-zero "Triples with Bitwise AND Equal To Zero") +[Next >](../triples-with-bitwise-and-equal-to-zero "Triples with Bitwise AND Equal To Zero") ## [981. Time Based Key-Value Store (Medium)](https://leetcode.com/problems/time-based-key-value-store "基于时间的键值存储") @@ -69,5 +69,5 @@ kv.get("foo", 5); //output "bar2"   ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/to-lower-case/README.md b/problems/to-lower-case/README.md index 0cd4e359e..de7ab7125 100644 --- a/problems/to-lower-case/README.md +++ b/problems/to-lower-case/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-sorted-circular-linked-list "Insert into a Sorted Circular Linked List") +[< Previous](../insert-into-a-sorted-circular-linked-list "Insert into a Sorted Circular Linked List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-blacklist "Random Pick with Blacklist") +[Next >](../random-pick-with-blacklist "Random Pick with Blacklist") ## [709. To Lower Case (Easy)](https://leetcode.com/problems/to-lower-case "转换成小写字母") @@ -43,7 +43,7 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Hints
diff --git a/problems/toeplitz-matrix/README.md b/problems/toeplitz-matrix/README.md index 1d3efbdc2..a3f337771 100644 --- a/problems/toeplitz-matrix/README.md +++ b/problems/toeplitz-matrix/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/couples-holding-hands "Couples Holding Hands") +[< Previous](../couples-holding-hands "Couples Holding Hands")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reorganize-string "Reorganize String") +[Next >](../reorganize-string "Reorganize String") ## [766. Toeplitz Matrix (Easy)](https://leetcode.com/problems/toeplitz-matrix "托普利茨矩阵") @@ -63,10 +63,10 @@ The diagonal "[1, 2]" has different elements. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Valid Word Square](https://github.com/openset/leetcode/tree/master/problems/valid-word-square) (Easy) + 1. [Valid Word Square](../valid-word-square) (Easy) ### Hints
diff --git a/problems/top-k-frequent-elements/README.md b/problems/top-k-frequent-elements/README.md index c764fd708..50a0ec65b 100644 --- a/problems/top-k-frequent-elements/README.md +++ b/problems/top-k-frequent-elements/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/moving-average-from-data-stream "Moving Average from Data Stream") +[< Previous](../moving-average-from-data-stream "Moving Average from Data Stream")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/design-tic-tac-toe "Design Tic-Tac-Toe") +[Next >](../design-tic-tac-toe "Design Tic-Tac-Toe") ## [347. Top K Frequent Elements (Medium)](https://leetcode.com/problems/top-k-frequent-elements "前 K 个高频元素") @@ -36,13 +36,13 @@ ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Word Frequency](https://github.com/openset/leetcode/tree/master/problems/word-frequency) (Medium) - 1. [Kth Largest Element in an Array](https://github.com/openset/leetcode/tree/master/problems/kth-largest-element-in-an-array) (Medium) - 1. [Sort Characters By Frequency](https://github.com/openset/leetcode/tree/master/problems/sort-characters-by-frequency) (Medium) - 1. [Split Array into Consecutive Subsequences](https://github.com/openset/leetcode/tree/master/problems/split-array-into-consecutive-subsequences) (Medium) - 1. [Top K Frequent Words](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-words) (Medium) - 1. [K Closest Points to Origin](https://github.com/openset/leetcode/tree/master/problems/k-closest-points-to-origin) (Medium) + 1. [Word Frequency](../word-frequency) (Medium) + 1. [Kth Largest Element in an Array](../kth-largest-element-in-an-array) (Medium) + 1. [Sort Characters By Frequency](../sort-characters-by-frequency) (Medium) + 1. [Split Array into Consecutive Subsequences](../split-array-into-consecutive-subsequences) (Medium) + 1. [Top K Frequent Words](../top-k-frequent-words) (Medium) + 1. [K Closest Points to Origin](../k-closest-points-to-origin) (Medium) diff --git a/problems/top-k-frequent-words/README.md b/problems/top-k-frequent-words/README.md index 80d9e4b73..6cf53e341 100644 --- a/problems/top-k-frequent-words/README.md +++ b/problems/top-k-frequent-words/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/stickers-to-spell-word "Stickers to Spell Word") +[< Previous](../stickers-to-spell-word "Stickers to Spell Word")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-number-with-alternating-bits "Binary Number with Alternating Bits") +[Next >](../binary-number-with-alternating-bits "Binary Number with Alternating Bits") ## [692. Top K Frequent Words (Medium)](https://leetcode.com/problems/top-k-frequent-words "前K个高频单词") @@ -46,10 +46,10 @@

### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Top K Frequent Elements](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-elements) (Medium) - 1. [K Closest Points to Origin](https://github.com/openset/leetcode/tree/master/problems/k-closest-points-to-origin) (Medium) + 1. [Top K Frequent Elements](../top-k-frequent-elements) (Medium) + 1. [K Closest Points to Origin](../k-closest-points-to-origin) (Medium) diff --git a/problems/toss-strange-coins/README.md b/problems/toss-strange-coins/README.md index 1c1792940..2960a6347 100644 --- a/problems/toss-strange-coins/README.md +++ b/problems/toss-strange-coins/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/meeting-scheduler "Meeting Scheduler") +[< Previous](../meeting-scheduler "Meeting Scheduler")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/divide-chocolate "Divide Chocolate") +[Next >](../divide-chocolate "Divide Chocolate") ## [1230. Toss Strange Coins (Medium)](https://leetcode.com/problems/toss-strange-coins "抛掷硬币") @@ -34,8 +34,8 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/total-hamming-distance/README.md b/problems/total-hamming-distance/README.md index e7185bd0b..b233c8d30 100644 --- a/problems/total-hamming-distance/README.md +++ b/problems/total-hamming-distance/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-complement "Number Complement") +[< Previous](../number-complement "Number Complement")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/generate-random-point-in-a-circle "Generate Random Point in a Circle") +[Next >](../generate-random-point-in-a-circle "Generate Random Point in a Circle") ## [477. Total Hamming Distance (Medium)](https://leetcode.com/problems/total-hamming-distance "汉明距离总和") @@ -36,7 +36,7 @@ HammingDistance(4, 14) + HammingDistance(4, 2) + HammingDistance(14, 2) = 2 + 2

### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions - 1. [Hamming Distance](https://github.com/openset/leetcode/tree/master/problems/hamming-distance) (Easy) + 1. [Hamming Distance](../hamming-distance) (Easy) diff --git a/problems/tournament-winners/README.md b/problems/tournament-winners/README.md index b86a6b650..d7c5485cd 100644 --- a/problems/tournament-winners/README.md +++ b/problems/tournament-winners/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/monthly-transactions-i "Monthly Transactions I") +[< Previous](../monthly-transactions-i "Monthly Transactions I")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/fizz-buzz-multithreaded "Fizz Buzz Multithreaded") +[Next >](../fizz-buzz-multithreaded "Fizz Buzz Multithreaded") ## [1194. Tournament Winners (Hard)](https://leetcode.com/problems/tournament-winners "锦标赛优胜者") diff --git a/problems/traffic-light-controlled-intersection/README.md b/problems/traffic-light-controlled-intersection/README.md index 582b9ae3e..66e92e498 100644 --- a/problems/traffic-light-controlled-intersection/README.md +++ b/problems/traffic-light-controlled-intersection/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/palindrome-partitioning-iii "Palindrome Partitioning III") +[< Previous](../palindrome-partitioning-iii "Palindrome Partitioning III")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/students-and-examinations "Students and Examinations") +[Next >](../students-and-examinations "Students and Examinations") ## [1279. Traffic Light Controlled Intersection (Easy)](https://leetcode.com/problems/traffic-light-controlled-intersection "") diff --git a/problems/transform-to-chessboard/README.md b/problems/transform-to-chessboard/README.md index 933b175da..2b0a8f71b 100644 --- a/problems/transform-to-chessboard/README.md +++ b/problems/transform-to-chessboard/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/rabbits-in-forest "Rabbits in Forest") +[< Previous](../rabbits-in-forest "Rabbits in Forest")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-distance-between-bst-nodes "Minimum Distance Between BST Nodes") +[Next >](../minimum-distance-between-bst-nodes "Minimum Distance Between BST Nodes") ## [782. Transform to Chessboard (Hard)](https://leetcode.com/problems/transform-to-chessboard "变为棋盘") @@ -54,5 +54,5 @@ No matter what sequence of moves you make, you cannot end with a valid chessboar ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/transpose-file/README.md b/problems/transpose-file/README.md index 16a82b77f..ec2f0ca36 100644 --- a/problems/transpose-file/README.md +++ b/problems/transpose-file/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-phone-numbers "Valid Phone Numbers") +[< Previous](../valid-phone-numbers "Valid Phone Numbers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/tenth-line "Tenth Line") +[Next >](../tenth-line "Tenth Line") ## [194. Transpose File (Medium)](https://leetcode.com/problems/transpose-file "转置文件") diff --git a/problems/transpose-matrix/README.md b/problems/transpose-matrix/README.md index aec274fb9..aaf46fee7 100644 --- a/problems/transpose-matrix/README.md +++ b/problems/transpose-matrix/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/prime-palindrome "Prime Palindrome") +[< Previous](../prime-palindrome "Prime Palindrome")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-gap "Binary Gap") +[Next >](../binary-gap "Binary Gap") ## [867. Transpose Matrix (Easy)](https://leetcode.com/problems/transpose-matrix "转置矩阵") @@ -48,7 +48,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/trapping-rain-water-ii/README.md b/problems/trapping-rain-water-ii/README.md index e5c39c6c9..93c96ec7b 100644 --- a/problems/trapping-rain-water-ii/README.md +++ b/problems/trapping-rain-water-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/queue-reconstruction-by-height "Queue Reconstruction by Height") +[< Previous](../queue-reconstruction-by-height "Queue Reconstruction by Height")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-word-abbreviation "Valid Word Abbreviation") +[Next >](../valid-word-abbreviation "Valid Word Abbreviation") ## [407. Trapping Rain Water II (Hard)](https://leetcode.com/problems/trapping-rain-water-ii "接雨水 II") @@ -45,8 +45,8 @@ Return 4.

After the rain, water is trapped between the blocks. The total volume of water trapped is 4.

### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions - 1. [Trapping Rain Water](https://github.com/openset/leetcode/tree/master/problems/trapping-rain-water) (Hard) + 1. [Trapping Rain Water](../trapping-rain-water) (Hard) diff --git a/problems/trapping-rain-water/README.md b/problems/trapping-rain-water/README.md index d455b3852..b84d3a3d9 100644 --- a/problems/trapping-rain-water/README.md +++ b/problems/trapping-rain-water/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/first-missing-positive "First Missing Positive") +[< Previous](../first-missing-positive "First Missing Positive")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/multiply-strings "Multiply Strings") +[Next >](../multiply-strings "Multiply Strings") ## [42. Trapping Rain Water (Hard)](https://leetcode.com/problems/trapping-rain-water "接雨水") @@ -23,12 +23,12 @@ Output: 6 ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Container With Most Water](https://github.com/openset/leetcode/tree/master/problems/container-with-most-water) (Medium) - 1. [Product of Array Except Self](https://github.com/openset/leetcode/tree/master/problems/product-of-array-except-self) (Medium) - 1. [Trapping Rain Water II](https://github.com/openset/leetcode/tree/master/problems/trapping-rain-water-ii) (Hard) - 1. [Pour Water](https://github.com/openset/leetcode/tree/master/problems/pour-water) (Medium) + 1. [Container With Most Water](../container-with-most-water) (Medium) + 1. [Product of Array Except Self](../product-of-array-except-self) (Medium) + 1. [Trapping Rain Water II](../trapping-rain-water-ii) (Hard) + 1. [Pour Water](../pour-water) (Medium) diff --git a/problems/tree-diameter/README.md b/problems/tree-diameter/README.md index 8cacba3e3..d3956a758 100644 --- a/problems/tree-diameter/README.md +++ b/problems/tree-diameter/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-a-leaderboard "Design A Leaderboard") +[< Previous](../design-a-leaderboard "Design A Leaderboard")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/palindrome-removal "Palindrome Removal") +[Next >](../palindrome-removal "Palindrome Removal") ## [1245. Tree Diameter (Medium)](https://leetcode.com/problems/tree-diameter "树的直径") @@ -49,9 +49,9 @@ A longest path of the tree is the path 3 - 2 - 1 - 4 - 5. ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Hints
diff --git a/problems/tree-node/README.md b/problems/tree-node/README.md index 2558720cc..287a26c57 100644 --- a/problems/tree-node/README.md +++ b/problems/tree-node/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/sales-person "Sales Person") +[< Previous](../sales-person "Sales Person")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-duplicate-file-in-system "Find Duplicate File in System") +[Next >](../find-duplicate-file-in-system "Find Duplicate File in System") ## [608. Tree Node (Medium)](https://leetcode.com/problems/tree-node "树节点") diff --git a/problems/triangle-judgement/README.md b/problems/triangle-judgement/README.md index 3cf8df017..481277048 100644 --- a/problems/triangle-judgement/README.md +++ b/problems/triangle-judgement/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-duplicate-file-in-system "Find Duplicate File in System") +[< Previous](../find-duplicate-file-in-system "Find Duplicate File in System")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-triangle-number "Valid Triangle Number") +[Next >](../valid-triangle-number "Valid Triangle Number") ## [610. Triangle Judgement (Easy)](https://leetcode.com/problems/triangle-judgement "判断三角形") diff --git a/problems/triangle/README.md b/problems/triangle/README.md index d006de92d..eaf8a2655 100644 --- a/problems/triangle/README.md +++ b/problems/triangle/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/pascals-triangle-ii "Pascal's Triangle II") +[< Previous](../pascals-triangle-ii "Pascal's Triangle II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock "Best Time to Buy and Sell Stock") +[Next >](../best-time-to-buy-and-sell-stock "Best Time to Buy and Sell Stock") ## [120. Triangle (Medium)](https://leetcode.com/problems/triangle "三角形最小路径和") @@ -31,5 +31,5 @@

Bonus point if you are able to do this using only O(n) extra space, where n is the total number of rows in the triangle.

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/trim-a-binary-search-tree/README.md b/problems/trim-a-binary-search-tree/README.md index e460820ca..0e8890185 100644 --- a/problems/trim-a-binary-search-tree/README.md +++ b/problems/trim-a-binary-search-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-number-in-multiplication-table "Kth Smallest Number in Multiplication Table") +[< Previous](../kth-smallest-number-in-multiplication-table "Kth Smallest Number in Multiplication Table")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-swap "Maximum Swap") +[Next >](../maximum-swap "Maximum Swap") ## [669. Trim a Binary Search Tree (Easy)](https://leetcode.com/problems/trim-a-binary-search-tree "修剪二叉搜索树") @@ -56,4 +56,4 @@ Given a binary search tree and the lowest and highest boundaries as L ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] diff --git a/problems/triples-with-bitwise-and-equal-to-zero/README.md b/problems/triples-with-bitwise-and-equal-to-zero/README.md index baa0b75a8..062d98753 100644 --- a/problems/triples-with-bitwise-and-equal-to-zero/README.md +++ b/problems/triples-with-bitwise-and-equal-to-zero/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/time-based-key-value-store "Time Based Key-Value Store") +[< Previous](../time-based-key-value-store "Time Based Key-Value Store")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-for-tickets "Minimum Cost For Tickets") +[Next >](../minimum-cost-for-tickets "Minimum Cost For Tickets") ## [982. Triples with Bitwise AND Equal To Zero (Hard)](https://leetcode.com/problems/triples-with-bitwise-and-equal-to-zero "按位与为零的三元组") @@ -52,4 +52,4 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/trips-and-users/README.md b/problems/trips-and-users/README.md index e55410540..fba9141a1 100644 --- a/problems/trips-and-users/README.md +++ b/problems/trips-and-users/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/graph-valid-tree "Graph Valid Tree") +[< Previous](../graph-valid-tree "Graph Valid Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/ugly-number "Ugly Number") +[Next >](../ugly-number "Ugly Number") ## [262. Trips and Users (Hard)](https://leetcode.com/problems/trips-and-users "行程和用户") diff --git a/problems/two-city-scheduling/README.md b/problems/two-city-scheduling/README.md index 7f5e6c27d..91dab595a 100644 --- a/problems/two-city-scheduling/README.md +++ b/problems/two-city-scheduling/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/recover-a-tree-from-preorder-traversal "Recover a Tree From Preorder Traversal") +[< Previous](../recover-a-tree-from-preorder-traversal "Recover a Tree From Preorder Traversal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/matrix-cells-in-distance-order "Matrix Cells in Distance Order") +[Next >](../matrix-cells-in-distance-order "Matrix Cells in Distance Order") ## [1029. Two City Scheduling (Easy)](https://leetcode.com/problems/two-city-scheduling "两地调度") @@ -42,4 +42,4 @@ The total minimum cost is 10 + 30 + 50 + 20 = 110 to have half the people interv ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/two-sum-bsts/README.md b/problems/two-sum-bsts/README.md index 293ac5d8c..85389f582 100644 --- a/problems/two-sum-bsts/README.md +++ b/problems/two-sum-bsts/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/intersection-of-three-sorted-arrays "Intersection of Three Sorted Arrays") +[< Previous](../intersection-of-three-sorted-arrays "Intersection of Three Sorted Arrays")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/stepping-numbers "Stepping Numbers") +[Next >](../stepping-numbers "Stepping Numbers") ## [1214. Two Sum BSTs (Medium)](https://leetcode.com/problems/two-sum-bsts "查找两棵二叉搜索树之和") @@ -45,10 +45,10 @@ ### Related Topics - [[Binary Search Tree](https://github.com/openset/leetcode/tree/master/tag/binary-search-tree/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] ### Similar Questions - 1. [Two Sum IV - Input is a BST](https://github.com/openset/leetcode/tree/master/problems/two-sum-iv-input-is-a-bst) (Easy) + 1. [Two Sum IV - Input is a BST](../two-sum-iv-input-is-a-bst) (Easy) ### Hints
diff --git a/problems/two-sum-ii-input-array-is-sorted/README.md b/problems/two-sum-ii-input-array-is-sorted/README.md index f1bf17098..89af39b78 100644 --- a/problems/two-sum-ii-input-array-is-sorted/README.md +++ b/problems/two-sum-ii-input-array-is-sorted/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/fraction-to-recurring-decimal "Fraction to Recurring Decimal") +[< Previous](../fraction-to-recurring-decimal "Fraction to Recurring Decimal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/excel-sheet-column-title "Excel Sheet Column Title") +[Next >](../excel-sheet-column-title "Excel Sheet Column Title") ## [167. Two Sum II - Input array is sorted (Easy)](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted "两数之和 II - 输入有序数组") @@ -30,11 +30,11 @@ Explanation: The sum of 2 and 7 is 9. Therefore index1 = 1, index2 = 2. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Two Sum](https://github.com/openset/leetcode/tree/master/problems/two-sum) (Easy) - 1. [Two Sum IV - Input is a BST](https://github.com/openset/leetcode/tree/master/problems/two-sum-iv-input-is-a-bst) (Easy) - 1. [Two Sum Less Than K](https://github.com/openset/leetcode/tree/master/problems/two-sum-less-than-k) (Easy) + 1. [Two Sum](../two-sum) (Easy) + 1. [Two Sum IV - Input is a BST](../two-sum-iv-input-is-a-bst) (Easy) + 1. [Two Sum Less Than K](../two-sum-less-than-k) (Easy) diff --git a/problems/two-sum-iii-data-structure-design/README.md b/problems/two-sum-iii-data-structure-design/README.md index bcd04eaed..6f9ad83c8 100644 --- a/problems/two-sum-iii-data-structure-design/README.md +++ b/problems/two-sum-iii-data-structure-design/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/majority-element "Majority Element") +[< Previous](../majority-element "Majority Element")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/excel-sheet-column-number "Excel Sheet Column Number") +[Next >](../excel-sheet-column-number "Excel Sheet Column Number") ## [170. Two Sum III - Data structure design (Easy)](https://leetcode.com/problems/two-sum-iii-data-structure-design "两数之和 III - 数据结构设计") @@ -32,10 +32,10 @@ find(3) -> true find(6) -> false ### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Two Sum](https://github.com/openset/leetcode/tree/master/problems/two-sum) (Easy) - 1. [Unique Word Abbreviation](https://github.com/openset/leetcode/tree/master/problems/unique-word-abbreviation) (Medium) - 1. [Two Sum IV - Input is a BST](https://github.com/openset/leetcode/tree/master/problems/two-sum-iv-input-is-a-bst) (Easy) + 1. [Two Sum](../two-sum) (Easy) + 1. [Unique Word Abbreviation](../unique-word-abbreviation) (Medium) + 1. [Two Sum IV - Input is a BST](../two-sum-iv-input-is-a-bst) (Easy) diff --git a/problems/two-sum-iv-input-is-a-bst/README.md b/problems/two-sum-iv-input-is-a-bst/README.md index 081dd6153..17ca798cf 100644 --- a/problems/two-sum-iv-input-is-a-bst/README.md +++ b/problems/two-sum-iv-input-is-a-bst/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-duplicate-subtrees "Find Duplicate Subtrees") +[< Previous](../find-duplicate-subtrees "Find Duplicate Subtrees")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-binary-tree "Maximum Binary Tree") +[Next >](../maximum-binary-tree "Maximum Binary Tree") ## [653. Two Sum IV - Input is a BST (Easy)](https://leetcode.com/problems/two-sum-iv-input-is-a-bst "两数之和 IV - 输入 BST") @@ -48,10 +48,10 @@ Target = 28

 

### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Two Sum](https://github.com/openset/leetcode/tree/master/problems/two-sum) (Easy) - 1. [Two Sum II - Input array is sorted](https://github.com/openset/leetcode/tree/master/problems/two-sum-ii-input-array-is-sorted) (Easy) - 1. [Two Sum III - Data structure design](https://github.com/openset/leetcode/tree/master/problems/two-sum-iii-data-structure-design) (Easy) - 1. [Two Sum BSTs](https://github.com/openset/leetcode/tree/master/problems/two-sum-bsts) (Medium) + 1. [Two Sum](../two-sum) (Easy) + 1. [Two Sum II - Input array is sorted](../two-sum-ii-input-array-is-sorted) (Easy) + 1. [Two Sum III - Data structure design](../two-sum-iii-data-structure-design) (Easy) + 1. [Two Sum BSTs](../two-sum-bsts) (Medium) diff --git a/problems/two-sum-less-than-k/README.md b/problems/two-sum-less-than-k/README.md index 2dd7562ab..a45c44a84 100644 --- a/problems/two-sum-less-than-k/README.md +++ b/problems/two-sum-less-than-k/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/unpopular-books "Unpopular Books") +[< Previous](../unpopular-books "Unpopular Books")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-k-length-substrings-with-no-repeated-characters "Find K-Length Substrings With No Repeated Characters") +[Next >](../find-k-length-substrings-with-no-repeated-characters "Find K-Length Substrings With No Repeated Characters") ## [1099. Two Sum Less Than K (Easy)](https://leetcode.com/problems/two-sum-less-than-k "小于 K 的两数之和") @@ -44,13 +44,13 @@ In this case it's not possible to get a pair sum less that 15. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Two Sum](https://github.com/openset/leetcode/tree/master/problems/two-sum) (Easy) - 1. [Two Sum II - Input array is sorted](https://github.com/openset/leetcode/tree/master/problems/two-sum-ii-input-array-is-sorted) (Easy) - 1. [3Sum Smaller](https://github.com/openset/leetcode/tree/master/problems/3sum-smaller) (Medium) - 1. [Subarray Product Less Than K](https://github.com/openset/leetcode/tree/master/problems/subarray-product-less-than-k) (Medium) + 1. [Two Sum](../two-sum) (Easy) + 1. [Two Sum II - Input array is sorted](../two-sum-ii-input-array-is-sorted) (Easy) + 1. [3Sum Smaller](../3sum-smaller) (Medium) + 1. [Subarray Product Less Than K](../subarray-product-less-than-k) (Medium) ### Hints
diff --git a/problems/two-sum/README.md b/problems/two-sum/README.md index 3e2f47d42..3cf03d834 100644 --- a/problems/two-sum/README.md +++ b/problems/two-sum/README.md @@ -7,7 +7,7 @@ < Previous                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/add-two-numbers "Add Two Numbers") +[Next >](../add-two-numbers "Add Two Numbers") ## [1. Two Sum (Easy)](https://leetcode.com/problems/two-sum "两数之和") @@ -25,17 +25,17 @@ return [0, 1]. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [3Sum](https://github.com/openset/leetcode/tree/master/problems/3sum) (Medium) - 1. [4Sum](https://github.com/openset/leetcode/tree/master/problems/4sum) (Medium) - 1. [Two Sum II - Input array is sorted](https://github.com/openset/leetcode/tree/master/problems/two-sum-ii-input-array-is-sorted) (Easy) - 1. [Two Sum III - Data structure design](https://github.com/openset/leetcode/tree/master/problems/two-sum-iii-data-structure-design) (Easy) - 1. [Subarray Sum Equals K](https://github.com/openset/leetcode/tree/master/problems/subarray-sum-equals-k) (Medium) - 1. [Two Sum IV - Input is a BST](https://github.com/openset/leetcode/tree/master/problems/two-sum-iv-input-is-a-bst) (Easy) - 1. [Two Sum Less Than K](https://github.com/openset/leetcode/tree/master/problems/two-sum-less-than-k) (Easy) + 1. [3Sum](../3sum) (Medium) + 1. [4Sum](../4sum) (Medium) + 1. [Two Sum II - Input array is sorted](../two-sum-ii-input-array-is-sorted) (Easy) + 1. [Two Sum III - Data structure design](../two-sum-iii-data-structure-design) (Easy) + 1. [Subarray Sum Equals K](../subarray-sum-equals-k) (Medium) + 1. [Two Sum IV - Input is a BST](../two-sum-iv-input-is-a-bst) (Easy) + 1. [Two Sum Less Than K](../two-sum-less-than-k) (Easy) ### Hints
diff --git a/problems/ugly-number-ii/README.md b/problems/ugly-number-ii/README.md index 537291cb6..12bc00022 100644 --- a/problems/ugly-number-ii/README.md +++ b/problems/ugly-number-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/ugly-number "Ugly Number") +[< Previous](../ugly-number "Ugly Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/paint-house-ii "Paint House II") +[Next >](../paint-house-ii "Paint House II") ## [264. Ugly Number II (Medium)](https://leetcode.com/problems/ugly-number-ii "丑数 II") @@ -30,16 +30,16 @@ ### Related Topics - [[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Heap](../../tag/heap/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Merge k Sorted Lists](https://github.com/openset/leetcode/tree/master/problems/merge-k-sorted-lists) (Hard) - 1. [Count Primes](https://github.com/openset/leetcode/tree/master/problems/count-primes) (Easy) - 1. [Ugly Number](https://github.com/openset/leetcode/tree/master/problems/ugly-number) (Easy) - 1. [Perfect Squares](https://github.com/openset/leetcode/tree/master/problems/perfect-squares) (Medium) - 1. [Super Ugly Number](https://github.com/openset/leetcode/tree/master/problems/super-ugly-number) (Medium) + 1. [Merge k Sorted Lists](../merge-k-sorted-lists) (Hard) + 1. [Count Primes](../count-primes) (Easy) + 1. [Ugly Number](../ugly-number) (Easy) + 1. [Perfect Squares](../perfect-squares) (Medium) + 1. [Super Ugly Number](../super-ugly-number) (Medium) ### Hints
diff --git a/problems/ugly-number-iii/README.md b/problems/ugly-number-iii/README.md index fe85cdc98..5cd9b128f 100644 --- a/problems/ugly-number-iii/README.md +++ b/problems/ugly-number-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-absolute-difference "Minimum Absolute Difference") +[< Previous](../minimum-absolute-difference "Minimum Absolute Difference")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/smallest-string-with-swaps "Smallest String With Swaps") +[Next >](../smallest-string-with-swaps "Smallest String With Swaps") ## [1201. Ugly Number III (Medium)](https://leetcode.com/problems/ugly-number-iii "丑数 III") @@ -56,8 +56,8 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
diff --git a/problems/ugly-number/README.md b/problems/ugly-number/README.md index e252db0f6..47f61475e 100644 --- a/problems/ugly-number/README.md +++ b/problems/ugly-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/trips-and-users "Trips and Users") +[< Previous](../trips-and-users "Trips and Users")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/ugly-number-ii "Ugly Number II") +[Next >](../ugly-number-ii "Ugly Number II") ## [263. Ugly Number (Easy)](https://leetcode.com/problems/ugly-number "丑数") @@ -46,9 +46,9 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Happy Number](https://github.com/openset/leetcode/tree/master/problems/happy-number) (Easy) - 1. [Count Primes](https://github.com/openset/leetcode/tree/master/problems/count-primes) (Easy) - 1. [Ugly Number II](https://github.com/openset/leetcode/tree/master/problems/ugly-number-ii) (Medium) + 1. [Happy Number](../happy-number) (Easy) + 1. [Count Primes](../count-primes) (Easy) + 1. [Ugly Number II](../ugly-number-ii) (Medium) diff --git a/problems/uncommon-words-from-two-sentences/README.md b/problems/uncommon-words-from-two-sentences/README.md index edbf4e6c2..bfa063930 100644 --- a/problems/uncommon-words-from-two-sentences/README.md +++ b/problems/uncommon-words-from-two-sentences/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/projection-area-of-3d-shapes "Projection Area of 3D Shapes") +[< Previous](../projection-area-of-3d-shapes "Projection Area of 3D Shapes")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/spiral-matrix-iii "Spiral Matrix III") +[Next >](../spiral-matrix-iii "Spiral Matrix III") ## [884. Uncommon Words from Two Sentences (Easy)](https://leetcode.com/problems/uncommon-words-from-two-sentences "两句话中的不常见单词") @@ -53,4 +53,4 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/uncrossed-lines/README.md b/problems/uncrossed-lines/README.md index 89b39e475..8d9366fb0 100644 --- a/problems/uncrossed-lines/README.md +++ b/problems/uncrossed-lines/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/coloring-a-border "Coloring A Border") +[< Previous](../coloring-a-border "Coloring A Border")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/escape-a-large-maze "Escape a Large Maze") +[Next >](../escape-a-large-maze "Escape a Large Maze") ## [1035. Uncrossed Lines (Medium)](https://leetcode.com/problems/uncrossed-lines "不相交的线") @@ -63,10 +63,10 @@ We cannot draw 3 uncrossed lines, because the line from A[1]=4 to B[2]=4 will in ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Edit Distance](https://github.com/openset/leetcode/tree/master/problems/edit-distance) (Hard) + 1. [Edit Distance](../edit-distance) (Hard) ### Hints
diff --git a/problems/unique-binary-search-trees-ii/README.md b/problems/unique-binary-search-trees-ii/README.md index d652caec3..9fc43863d 100644 --- a/problems/unique-binary-search-trees-ii/README.md +++ b/problems/unique-binary-search-trees-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-tree-inorder-traversal "Binary Tree Inorder Traversal") +[< Previous](../binary-tree-inorder-traversal "Binary Tree Inorder Traversal")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/unique-binary-search-trees "Unique Binary Search Trees") +[Next >](../unique-binary-search-trees "Unique Binary Search Trees") ## [95. Unique Binary Search Trees II (Medium)](https://leetcode.com/problems/unique-binary-search-trees-ii "不同的二叉搜索树 II") @@ -36,9 +36,9 @@ The above output corresponds to the 5 unique BST's shown below: ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Unique Binary Search Trees](https://github.com/openset/leetcode/tree/master/problems/unique-binary-search-trees) (Medium) - 1. [Different Ways to Add Parentheses](https://github.com/openset/leetcode/tree/master/problems/different-ways-to-add-parentheses) (Medium) + 1. [Unique Binary Search Trees](../unique-binary-search-trees) (Medium) + 1. [Different Ways to Add Parentheses](../different-ways-to-add-parentheses) (Medium) diff --git a/problems/unique-binary-search-trees/README.md b/problems/unique-binary-search-trees/README.md index 421d50c20..18fe7f087 100644 --- a/problems/unique-binary-search-trees/README.md +++ b/problems/unique-binary-search-trees/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/unique-binary-search-trees-ii "Unique Binary Search Trees II") +[< Previous](../unique-binary-search-trees-ii "Unique Binary Search Trees II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/interleaving-string "Interleaving String") +[Next >](../interleaving-string "Interleaving String") ## [96. Unique Binary Search Trees (Medium)](https://leetcode.com/problems/unique-binary-search-trees "不同的二叉搜索树") @@ -29,8 +29,8 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Unique Binary Search Trees II](https://github.com/openset/leetcode/tree/master/problems/unique-binary-search-trees-ii) (Medium) + 1. [Unique Binary Search Trees II](../unique-binary-search-trees-ii) (Medium) diff --git a/problems/unique-email-addresses/README.md b/problems/unique-email-addresses/README.md index e4a5776ca..bd66b8fc8 100644 --- a/problems/unique-email-addresses/README.md +++ b/problems/unique-email-addresses/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimize-malware-spread-ii "Minimize Malware Spread II") +[< Previous](../minimize-malware-spread-ii "Minimize Malware Spread II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-subarrays-with-sum "Binary Subarrays With Sum") +[Next >](../binary-subarrays-with-sum "Binary Subarrays With Sum") ## [929. Unique Email Addresses (Easy)](https://leetcode.com/problems/unique-email-addresses "独特的电子邮件地址") @@ -50,4 +50,4 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/unique-letter-string/README.md b/problems/unique-letter-string/README.md index e58fefe9c..a6de633cd 100644 --- a/problems/unique-letter-string/README.md +++ b/problems/unique-letter-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/making-a-large-island "Making A Large Island") +[< Previous](../making-a-large-island "Making A Large Island")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/consecutive-numbers-sum "Consecutive Numbers Sum") +[Next >](../consecutive-numbers-sum "Consecutive Numbers Sum") ## [828. Unique Letter String (Hard)](https://leetcode.com/problems/unique-letter-string "独特字符串") @@ -49,4 +49,4 @@ Sum of lengths of all substring is 1 + 1 + 1 + 2 + 2 + 3 = 10

Note: 0 <= S.length <= 10000.

### Related Topics - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/unique-morse-code-words/README.md b/problems/unique-morse-code-words/README.md index d50ad65e8..7397e0522 100644 --- a/problems/unique-morse-code-words/README.md +++ b/problems/unique-morse-code-words/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/bricks-falling-when-hit "Bricks Falling When Hit") +[< Previous](../bricks-falling-when-hit "Bricks Falling When Hit")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/split-array-with-same-average "Split Array With Same Average") +[Next >](../split-array-with-same-average "Split Array With Same Average") ## [804. Unique Morse Code Words (Easy)](https://leetcode.com/problems/unique-morse-code-words "唯一摩尔斯密码词") @@ -45,4 +45,4 @@ There are 2 different transformations, "--...-." and "--...--.&qu ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/unique-number-of-occurrences/README.md b/problems/unique-number-of-occurrences/README.md index 0483c827b..76f5b3b37 100644 --- a/problems/unique-number-of-occurrences/README.md +++ b/problems/unique-number-of-occurrences/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-skiplist "Design Skiplist") +[< Previous](../design-skiplist "Design Skiplist")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/get-equal-substrings-within-budget "Get Equal Substrings Within Budget") +[Next >](../get-equal-substrings-within-budget "Get Equal Substrings Within Budget") ## [1207. Unique Number of Occurrences (Easy)](https://leetcode.com/problems/unique-number-of-occurrences "独一无二的出现次数") @@ -44,7 +44,7 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
diff --git a/problems/unique-paths-ii/README.md b/problems/unique-paths-ii/README.md index b5925b551..222f9a960 100644 --- a/problems/unique-paths-ii/README.md +++ b/problems/unique-paths-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/unique-paths "Unique Paths") +[< Previous](../unique-paths "Unique Paths")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-path-sum "Minimum Path Sum") +[Next >](../minimum-path-sum "Minimum Path Sum") ## [63. Unique Paths II (Medium)](https://leetcode.com/problems/unique-paths-ii "不同路径 II") @@ -41,12 +41,12 @@ There are two ways to reach the bottom-right corner: ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Unique Paths](https://github.com/openset/leetcode/tree/master/problems/unique-paths) (Medium) - 1. [Unique Paths III](https://github.com/openset/leetcode/tree/master/problems/unique-paths-iii) (Hard) + 1. [Unique Paths](../unique-paths) (Medium) + 1. [Unique Paths III](../unique-paths-iii) (Hard) ### Hints
diff --git a/problems/unique-paths-iii/README.md b/problems/unique-paths-iii/README.md index 7528df3a4..8b7cb2be0 100644 --- a/problems/unique-paths-iii/README.md +++ b/problems/unique-paths-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/distribute-coins-in-binary-tree "Distribute Coins in Binary Tree") +[< Previous](../distribute-coins-in-binary-tree "Distribute Coins in Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/time-based-key-value-store "Time Based Key-Value Store") +[Next >](../time-based-key-value-store "Time Based Key-Value Store") ## [980. Unique Paths III (Hard)](https://leetcode.com/problems/unique-paths-iii "不同路径 III") @@ -69,10 +69,10 @@ Note that the starting and ending square can be anywhere in the grid. ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Sudoku Solver](https://github.com/openset/leetcode/tree/master/problems/sudoku-solver) (Hard) - 1. [Unique Paths II](https://github.com/openset/leetcode/tree/master/problems/unique-paths-ii) (Medium) - 1. [Word Search II](https://github.com/openset/leetcode/tree/master/problems/word-search-ii) (Hard) + 1. [Sudoku Solver](../sudoku-solver) (Hard) + 1. [Unique Paths II](../unique-paths-ii) (Medium) + 1. [Word Search II](../word-search-ii) (Hard) diff --git a/problems/unique-paths/README.md b/problems/unique-paths/README.md index c5798d9e3..f9dbe3db5 100644 --- a/problems/unique-paths/README.md +++ b/problems/unique-paths/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/rotate-list "Rotate List") +[< Previous](../rotate-list "Rotate List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/unique-paths-ii "Unique Paths II") +[Next >](../unique-paths-ii "Unique Paths II") ## [62. Unique Paths (Medium)](https://leetcode.com/problems/unique-paths "不同路径") @@ -41,10 +41,10 @@ From the top-left corner, there are a total of 3 ways to reach the bottom-right Output: 28 ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Unique Paths II](https://github.com/openset/leetcode/tree/master/problems/unique-paths-ii) (Medium) - 1. [Minimum Path Sum](https://github.com/openset/leetcode/tree/master/problems/minimum-path-sum) (Medium) - 1. [Dungeon Game](https://github.com/openset/leetcode/tree/master/problems/dungeon-game) (Hard) + 1. [Unique Paths II](../unique-paths-ii) (Medium) + 1. [Minimum Path Sum](../minimum-path-sum) (Medium) + 1. [Dungeon Game](../dungeon-game) (Hard) diff --git a/problems/unique-substrings-in-wraparound-string/README.md b/problems/unique-substrings-in-wraparound-string/README.md index 094bfdb8e..2436acd6e 100644 --- a/problems/unique-substrings-in-wraparound-string/README.md +++ b/problems/unique-substrings-in-wraparound-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/count-the-repetitions "Count The Repetitions") +[< Previous](../count-the-repetitions "Count The Repetitions")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/validate-ip-address "Validate IP Address") +[Next >](../validate-ip-address "Validate IP Address") ## [467. Unique Substrings in Wraparound String (Medium)](https://leetcode.com/problems/unique-substrings-in-wraparound-string "环绕字符串中唯一的子字符串") @@ -43,7 +43,7 @@

### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/unique-word-abbreviation/README.md b/problems/unique-word-abbreviation/README.md index 4e693af61..1320ace22 100644 --- a/problems/unique-word-abbreviation/README.md +++ b/problems/unique-word-abbreviation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-the-duplicate-number "Find the Duplicate Number") +[< Previous](../find-the-duplicate-number "Find the Duplicate Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/game-of-life "Game of Life") +[Next >](../game-of-life "Game of Life") ## [288. Unique Word Abbreviation (Medium)](https://leetcode.com/problems/unique-word-abbreviation "单词的唯一缩写") @@ -45,9 +45,9 @@ isUnique("make") -> true ### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Two Sum III - Data structure design](https://github.com/openset/leetcode/tree/master/problems/two-sum-iii-data-structure-design) (Easy) - 1. [Generalized Abbreviation](https://github.com/openset/leetcode/tree/master/problems/generalized-abbreviation) (Medium) + 1. [Two Sum III - Data structure design](../two-sum-iii-data-structure-design) (Easy) + 1. [Generalized Abbreviation](../generalized-abbreviation) (Medium) diff --git a/problems/univalued-binary-tree/README.md b/problems/univalued-binary-tree/README.md index 2c40bdf11..4a371806e 100644 --- a/problems/univalued-binary-tree/README.md +++ b/problems/univalued-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/least-operators-to-express-number "Least Operators to Express Number") +[< Previous](../least-operators-to-express-number "Least Operators to Express Number")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/vowel-spellchecker "Vowel Spellchecker") +[Next >](../vowel-spellchecker "Vowel Spellchecker") ## [965. Univalued Binary Tree (Easy)](https://leetcode.com/problems/univalued-binary-tree "单值二叉树") @@ -43,4 +43,4 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Tree](../../tag/tree/README.md)] diff --git a/problems/unpopular-books/README.md b/problems/unpopular-books/README.md index e5243f362..afc51d30b 100644 --- a/problems/unpopular-books/README.md +++ b/problems/unpopular-books/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-v "Game Play Analysis V") +[< Previous](../game-play-analysis-v "Game Play Analysis V")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/two-sum-less-than-k "Two Sum Less Than K") +[Next >](../two-sum-less-than-k "Two Sum Less Than K") ## [1098. Unpopular Books (Medium)](https://leetcode.com/problems/unpopular-books "小众书籍") diff --git a/problems/user-activity-for-the-past-30-days-i/README.md b/problems/user-activity-for-the-past-30-days-i/README.md index d2f59c1fa..45bc8ab07 100644 --- a/problems/user-activity-for-the-past-30-days-i/README.md +++ b/problems/user-activity-for-the-past-30-days-i/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/stone-game-ii "Stone Game II") +[< Previous](../stone-game-ii "Stone Game II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/user-activity-for-the-past-30-days-ii "User Activity for the Past 30 Days II") +[Next >](../user-activity-for-the-past-30-days-ii "User Activity for the Past 30 Days II") ## [1141. User Activity for the Past 30 Days I (Easy)](https://leetcode.com/problems/user-activity-for-the-past-30-days-i "") diff --git a/problems/user-activity-for-the-past-30-days-ii/README.md b/problems/user-activity-for-the-past-30-days-ii/README.md index 0db1994a5..c24c48957 100644 --- a/problems/user-activity-for-the-past-30-days-ii/README.md +++ b/problems/user-activity-for-the-past-30-days-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/user-activity-for-the-past-30-days-i "User Activity for the Past 30 Days I") +[< Previous](../user-activity-for-the-past-30-days-i "User Activity for the Past 30 Days I")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-common-subsequence "Longest Common Subsequence") +[Next >](../longest-common-subsequence "Longest Common Subsequence") ## [1142. User Activity for the Past 30 Days II (Easy)](https://leetcode.com/problems/user-activity-for-the-past-30-days-ii "过去30天的用户活动 II") diff --git a/problems/user-purchase-platform/README.md b/problems/user-purchase-platform/README.md index df9bd2ac8..181aefec5 100644 --- a/problems/user-purchase-platform/README.md +++ b/problems/user-purchase-platform/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/active-businesses "Active Businesses") +[< Previous](../active-businesses "Active Businesses")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-equivalent-domino-pairs "Number of Equivalent Domino Pairs") +[Next >](../number-of-equivalent-domino-pairs "Number of Equivalent Domino Pairs") ## [1127. User Purchase Platform (Hard)](https://leetcode.com/problems/user-purchase-platform "") diff --git a/problems/utf-8-validation/README.md b/problems/utf-8-validation/README.md index 78e3f6165..d02dcde1e 100644 --- a/problems/utf-8-validation/README.md +++ b/problems/utf-8-validation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/is-subsequence "Is Subsequence") +[< Previous](../is-subsequence "Is Subsequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/decode-string "Decode String") +[Next >](../decode-string "Decode String") ## [393. UTF-8 Validation (Medium)](https://leetcode.com/problems/utf-8-validation "UTF-8 编码验证") @@ -57,7 +57,7 @@ But the second continuation byte does not start with 10, so it is invalid.

### Related Topics - [[Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
diff --git a/problems/valid-anagram/README.md b/problems/valid-anagram/README.md index a2f9e68c3..2c97538c5 100644 --- a/problems/valid-anagram/README.md +++ b/problems/valid-anagram/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/different-ways-to-add-parentheses "Different Ways to Add Parentheses") +[< Previous](../different-ways-to-add-parentheses "Different Ways to Add Parentheses")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance "Shortest Word Distance") +[Next >](../shortest-word-distance "Shortest Word Distance") ## [242. Valid Anagram (Easy)](https://leetcode.com/problems/valid-anagram "有效的字母异位词") @@ -34,10 +34,10 @@ You may assume the string contains only lowercase alphabets.

What if the inputs contain unicode characters? How would you adapt your solution to such case?

### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Group Anagrams](https://github.com/openset/leetcode/tree/master/problems/group-anagrams) (Medium) - 1. [Palindrome Permutation](https://github.com/openset/leetcode/tree/master/problems/palindrome-permutation) (Easy) - 1. [Find All Anagrams in a String](https://github.com/openset/leetcode/tree/master/problems/find-all-anagrams-in-a-string) (Medium) + 1. [Group Anagrams](../group-anagrams) (Medium) + 1. [Palindrome Permutation](../palindrome-permutation) (Easy) + 1. [Find All Anagrams in a String](../find-all-anagrams-in-a-string) (Medium) diff --git a/problems/valid-boomerang/README.md b/problems/valid-boomerang/README.md index e789f8a8a..4ae5826c4 100644 --- a/problems/valid-boomerang/README.md +++ b/problems/valid-boomerang/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/escape-a-large-maze "Escape a Large Maze") +[< Previous](../escape-a-large-maze "Escape a Large Maze")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-search-tree-to-greater-sum-tree "Binary Search Tree to Greater Sum Tree") +[Next >](../binary-search-tree-to-greater-sum-tree "Binary Search Tree to Greater Sum Tree") ## [1037. Valid Boomerang (Easy)](https://leetcode.com/problems/valid-boomerang "有效的回旋镖") @@ -47,7 +47,7 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
diff --git a/problems/valid-mountain-array/README.md b/problems/valid-mountain-array/README.md index db0606664..de6e3a005 100644 --- a/problems/valid-mountain-array/README.md +++ b/problems/valid-mountain-array/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/distinct-subsequences-ii "Distinct Subsequences II") +[< Previous](../distinct-subsequences-ii "Distinct Subsequences II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/di-string-match "DI String Match") +[Next >](../di-string-match "DI String Match") ## [941. Valid Mountain Array (Easy)](https://leetcode.com/problems/valid-mountain-array "有效的山脉数组") @@ -72,7 +72,7 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
diff --git a/problems/valid-number/README.md b/problems/valid-number/README.md index dfe197c93..ddee7b6ab 100644 --- a/problems/valid-number/README.md +++ b/problems/valid-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-path-sum "Minimum Path Sum") +[< Previous](../minimum-path-sum "Minimum Path Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/plus-one "Plus One") +[Next >](../plus-one "Plus One") ## [65. Valid Number (Hard)](https://leetcode.com/problems/valid-number "有效数字") @@ -44,8 +44,8 @@ The signature of the C++ function had been updated. If you still see your function signature accepts a const char * argument, please click the reload button to reset your code definition.

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [String to Integer (atoi)](https://github.com/openset/leetcode/tree/master/problems/string-to-integer-atoi) (Medium) + 1. [String to Integer (atoi)](../string-to-integer-atoi) (Medium) diff --git a/problems/valid-palindrome-ii/README.md b/problems/valid-palindrome-ii/README.md index db77d8cd9..2ec0816d3 100644 --- a/problems/valid-palindrome-ii/README.md +++ b/problems/valid-palindrome-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/24-game "24 Game") +[< Previous](../24-game "24 Game")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/next-closest-time "Next Closest Time") +[Next >](../next-closest-time "Next Closest Time") ## [680. Valid Palindrome II (Easy)](https://leetcode.com/problems/valid-palindrome-ii "验证回文字符串 Ⅱ") @@ -38,7 +38,7 @@ The maximum length of the string is 50000.

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Valid Palindrome](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome) (Easy) + 1. [Valid Palindrome](../valid-palindrome) (Easy) diff --git a/problems/valid-palindrome-iii/README.md b/problems/valid-palindrome-iii/README.md index 179cb388f..d6521343f 100644 --- a/problems/valid-palindrome-iii/README.md +++ b/problems/valid-palindrome-iii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/stepping-numbers "Stepping Numbers") +[< Previous](../stepping-numbers "Stepping Numbers")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/play-with-chips "Play with Chips") +[Next >](../play-with-chips "Play with Chips") ## [1216. Valid Palindrome III (Hard)](https://leetcode.com/problems/valid-palindrome-iii "验证回文字符串 III") @@ -34,8 +34,8 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/valid-palindrome/README.md b/problems/valid-palindrome/README.md index 88ffb9a5f..c8e45097b 100644 --- a/problems/valid-palindrome/README.md +++ b/problems/valid-palindrome/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/binary-tree-maximum-path-sum "Binary Tree Maximum Path Sum") +[< Previous](../binary-tree-maximum-path-sum "Binary Tree Maximum Path Sum")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/word-ladder-ii "Word Ladder II") +[Next >](../word-ladder-ii "Word Ladder II") ## [125. Valid Palindrome (Easy)](https://leetcode.com/problems/valid-palindrome "验证回文串") @@ -30,9 +30,9 @@ ### Related Topics - [[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Palindrome Linked List](https://github.com/openset/leetcode/tree/master/problems/palindrome-linked-list) (Easy) - 1. [Valid Palindrome II](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome-ii) (Easy) + 1. [Palindrome Linked List](../palindrome-linked-list) (Easy) + 1. [Valid Palindrome II](../valid-palindrome-ii) (Easy) diff --git a/problems/valid-parentheses/README.md b/problems/valid-parentheses/README.md index 7ad6dabb1..62a8bab5f 100644 --- a/problems/valid-parentheses/README.md +++ b/problems/valid-parentheses/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/remove-nth-node-from-end-of-list "Remove Nth Node From End of List") +[< Previous](../remove-nth-node-from-end-of-list "Remove Nth Node From End of List")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/merge-two-sorted-lists "Merge Two Sorted Lists") +[Next >](../merge-two-sorted-lists "Merge Two Sorted Lists") ## [20. Valid Parentheses (Easy)](https://leetcode.com/problems/valid-parentheses "有效的括号") @@ -58,14 +58,14 @@ ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Generate Parentheses](https://github.com/openset/leetcode/tree/master/problems/generate-parentheses) (Medium) - 1. [Longest Valid Parentheses](https://github.com/openset/leetcode/tree/master/problems/longest-valid-parentheses) (Hard) - 1. [Remove Invalid Parentheses](https://github.com/openset/leetcode/tree/master/problems/remove-invalid-parentheses) (Hard) - 1. [Check If Word Is Valid After Substitutions](https://github.com/openset/leetcode/tree/master/problems/check-if-word-is-valid-after-substitutions) (Medium) + 1. [Generate Parentheses](../generate-parentheses) (Medium) + 1. [Longest Valid Parentheses](../longest-valid-parentheses) (Hard) + 1. [Remove Invalid Parentheses](../remove-invalid-parentheses) (Hard) + 1. [Check If Word Is Valid After Substitutions](../check-if-word-is-valid-after-substitutions) (Medium) ### Hints
diff --git a/problems/valid-parenthesis-string/README.md b/problems/valid-parenthesis-string/README.md index 3ee494ec1..86f71797c 100644 --- a/problems/valid-parenthesis-string/README.md +++ b/problems/valid-parenthesis-string/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/map-sum-pairs "Map Sum Pairs") +[< Previous](../map-sum-pairs "Map Sum Pairs")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/24-game "24 Game") +[Next >](../24-game "24 Game") ## [678. Valid Parenthesis String (Medium)](https://leetcode.com/problems/valid-parenthesis-string "有效的括号字符串") @@ -50,7 +50,7 @@ Given a string containing only three types of characters: '(', ')' and '*', writ

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Special Binary String](https://github.com/openset/leetcode/tree/master/problems/special-binary-string) (Hard) + 1. [Special Binary String](../special-binary-string) (Hard) diff --git a/problems/valid-perfect-square/README.md b/problems/valid-perfect-square/README.md index 3f6ec1c3f..599552df1 100644 --- a/problems/valid-perfect-square/README.md +++ b/problems/valid-perfect-square/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-leaves-of-binary-tree "Find Leaves of Binary Tree") +[< Previous](../find-leaves-of-binary-tree "Find Leaves of Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/largest-divisible-subset "Largest Divisible Subset") +[Next >](../largest-divisible-subset "Largest Divisible Subset") ## [367. Valid Perfect Square (Easy)](https://leetcode.com/problems/valid-perfect-square "有效的完全平方数") @@ -34,9 +34,9 @@ ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] - [[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] + [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Sqrt(x)](https://github.com/openset/leetcode/tree/master/problems/sqrtx) (Easy) - 1. [Sum of Square Numbers](https://github.com/openset/leetcode/tree/master/problems/sum-of-square-numbers) (Easy) + 1. [Sqrt(x)](../sqrtx) (Easy) + 1. [Sum of Square Numbers](../sum-of-square-numbers) (Easy) diff --git a/problems/valid-permutations-for-di-sequence/README.md b/problems/valid-permutations-for-di-sequence/README.md index 19a96c7b1..60b5b26a1 100644 --- a/problems/valid-permutations-for-di-sequence/README.md +++ b/problems/valid-permutations-for-di-sequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/numbers-at-most-n-given-digit-set "Numbers At Most N Given Digit Set") +[< Previous](../numbers-at-most-n-given-digit-set "Numbers At Most N Given Digit Set")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/fruit-into-baskets "Fruit Into Baskets") +[Next >](../fruit-into-baskets "Fruit Into Baskets") ## [903. Valid Permutations for DI Sequence (Hard)](https://leetcode.com/problems/valid-permutations-for-di-sequence "DI 序列的有效排列") @@ -52,5 +52,5 @@ The 5 valid permutations of (0, 1, 2, 3) are: ### Related Topics - [[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/valid-phone-numbers/README.md b/problems/valid-phone-numbers/README.md index b3416caec..ff3a84800 100644 --- a/problems/valid-phone-numbers/README.md +++ b/problems/valid-phone-numbers/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/word-frequency "Word Frequency") +[< Previous](../word-frequency "Word Frequency")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/transpose-file "Transpose File") +[Next >](../transpose-file "Transpose File") ## [193. Valid Phone Numbers (Easy)](https://leetcode.com/problems/valid-phone-numbers "有效电话号码") diff --git a/problems/valid-square/README.md b/problems/valid-square/README.md index 77fddbde7..f10ffd466 100644 --- a/problems/valid-square/README.md +++ b/problems/valid-square/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/fraction-addition-and-subtraction "Fraction Addition and Subtraction") +[< Previous](../fraction-addition-and-subtraction "Fraction Addition and Subtraction")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-harmonious-subsequence "Longest Harmonious Subsequence") +[Next >](../longest-harmonious-subsequence "Longest Harmonious Subsequence") ## [593. Valid Square (Medium)](https://leetcode.com/problems/valid-square "有效的正方形") @@ -35,4 +35,4 @@

 

### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/valid-sudoku/README.md b/problems/valid-sudoku/README.md index b06125aca..653c6f0cd 100644 --- a/problems/valid-sudoku/README.md +++ b/problems/valid-sudoku/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/search-insert-position "Search Insert Position") +[< Previous](../search-insert-position "Search Insert Position")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/sudoku-solver "Sudoku Solver") +[Next >](../sudoku-solver "Sudoku Solver") ## [36. Valid Sudoku (Medium)](https://leetcode.com/problems/valid-sudoku "有效的数独") @@ -72,7 +72,7 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Sudoku Solver](https://github.com/openset/leetcode/tree/master/problems/sudoku-solver) (Hard) + 1. [Sudoku Solver](../sudoku-solver) (Hard) diff --git a/problems/valid-tic-tac-toe-state/README.md b/problems/valid-tic-tac-toe-state/README.md index 25541e46b..2a2676003 100644 --- a/problems/valid-tic-tac-toe-state/README.md +++ b/problems/valid-tic-tac-toe-state/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/preimage-size-of-factorial-zeroes-function "Preimage Size of Factorial Zeroes Function") +[< Previous](../preimage-size-of-factorial-zeroes-function "Preimage Size of Factorial Zeroes Function")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-subarrays-with-bounded-maximum "Number of Subarrays with Bounded Maximum") +[Next >](../number-of-subarrays-with-bounded-maximum "Number of Subarrays with Bounded Maximum") ## [794. Valid Tic-Tac-Toe State (Medium)](https://leetcode.com/problems/valid-tic-tac-toe-state "有效的井字游戏") @@ -54,8 +54,8 @@ ### Related Topics - [[Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions - 1. [Design Tic-Tac-Toe](https://github.com/openset/leetcode/tree/master/problems/design-tic-tac-toe) (Medium) + 1. [Design Tic-Tac-Toe](../design-tic-tac-toe) (Medium) diff --git a/problems/valid-triangle-number/README.md b/problems/valid-triangle-number/README.md index 3f83cd969..67ba0dc61 100644 --- a/problems/valid-triangle-number/README.md +++ b/problems/valid-triangle-number/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/triangle-judgement "Triangle Judgement") +[< Previous](../triangle-judgement "Triangle Judgement")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-in-a-plane "Shortest Distance in a Plane") +[Next >](../shortest-distance-in-a-plane "Shortest Distance in a Plane") ## [611. Valid Triangle Number (Medium)](https://leetcode.com/problems/valid-triangle-number "有效三角形的个数") @@ -33,7 +33,7 @@ Valid combinations are:

### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [3Sum Smaller](https://github.com/openset/leetcode/tree/master/problems/3sum-smaller) (Medium) + 1. [3Sum Smaller](../3sum-smaller) (Medium) diff --git a/problems/valid-word-abbreviation/README.md b/problems/valid-word-abbreviation/README.md index 5d704a6c1..b617cabb4 100644 --- a/problems/valid-word-abbreviation/README.md +++ b/problems/valid-word-abbreviation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/trapping-rain-water-ii "Trapping Rain Water II") +[< Previous](../trapping-rain-water-ii "Trapping Rain Water II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-palindrome "Longest Palindrome") +[Next >](../longest-palindrome "Longest Palindrome") ## [408. Valid Word Abbreviation (Easy)](https://leetcode.com/problems/valid-word-abbreviation "有效单词缩写") @@ -43,8 +43,8 @@ Return false.

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Minimum Unique Word Abbreviation](https://github.com/openset/leetcode/tree/master/problems/minimum-unique-word-abbreviation) (Hard) - 1. [Word Abbreviation](https://github.com/openset/leetcode/tree/master/problems/word-abbreviation) (Hard) + 1. [Minimum Unique Word Abbreviation](../minimum-unique-word-abbreviation) (Hard) + 1. [Word Abbreviation](../word-abbreviation) (Hard) diff --git a/problems/valid-word-square/README.md b/problems/valid-word-square/README.md index 016ac8cd2..66fd21971 100644 --- a/problems/valid-word-square/README.md +++ b/problems/valid-word-square/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-xor-of-two-numbers-in-an-array "Maximum XOR of Two Numbers in an Array") +[< Previous](../maximum-xor-of-two-numbers-in-an-array "Maximum XOR of Two Numbers in an Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reconstruct-original-digits-from-english "Reconstruct Original Digits from English") +[Next >](../reconstruct-original-digits-from-english "Reconstruct Original Digits from English") ## [422. Valid Word Square (Easy)](https://leetcode.com/problems/valid-word-square "有效的单词方块") @@ -90,5 +90,5 @@ Therefore, it is NOT a valid word square.

### Similar Questions - 1. [Word Squares](https://github.com/openset/leetcode/tree/master/problems/word-squares) (Hard) - 1. [Toeplitz Matrix](https://github.com/openset/leetcode/tree/master/problems/toeplitz-matrix) (Easy) + 1. [Word Squares](../word-squares) (Hard) + 1. [Toeplitz Matrix](../toeplitz-matrix) (Easy) diff --git a/problems/validate-binary-search-tree/README.md b/problems/validate-binary-search-tree/README.md index eb9852d93..87c7158ef 100644 --- a/problems/validate-binary-search-tree/README.md +++ b/problems/validate-binary-search-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/interleaving-string "Interleaving String") +[< Previous](../interleaving-string "Interleaving String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/recover-binary-search-tree "Recover Binary Search Tree") +[Next >](../recover-binary-search-tree "Recover Binary Search Tree") ## [98. Validate Binary Search Tree (Medium)](https://leetcode.com/problems/validate-binary-search-tree "验证二叉搜索树") @@ -49,9 +49,9 @@ ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Binary Tree Inorder Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-inorder-traversal) (Medium) - 1. [Find Mode in Binary Search Tree](https://github.com/openset/leetcode/tree/master/problems/find-mode-in-binary-search-tree) (Easy) + 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Medium) + 1. [Find Mode in Binary Search Tree](../find-mode-in-binary-search-tree) (Easy) diff --git a/problems/validate-ip-address/README.md b/problems/validate-ip-address/README.md index 5fa41af63..2018673ba 100644 --- a/problems/validate-ip-address/README.md +++ b/problems/validate-ip-address/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/unique-substrings-in-wraparound-string "Unique Substrings in Wraparound String") +[< Previous](../unique-substrings-in-wraparound-string "Unique Substrings in Wraparound String")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/convex-polygon "Convex Polygon") +[Next >](../convex-polygon "Convex Polygon") ## [468. Validate IP Address (Medium)](https://leetcode.com/problems/validate-ip-address "验证IP地址") @@ -73,7 +73,7 @@ You may assume there is no extra space or special characters in the input string

### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [IP to CIDR](https://github.com/openset/leetcode/tree/master/problems/ip-to-cidr) (Easy) + 1. [IP to CIDR](../ip-to-cidr) (Easy) diff --git a/problems/validate-stack-sequences/README.md b/problems/validate-stack-sequences/README.md index 702601231..33acc1474 100644 --- a/problems/validate-stack-sequences/README.md +++ b/problems/validate-stack-sequences/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-increment-to-make-array-unique "Minimum Increment to Make Array Unique") +[< Previous](../minimum-increment-to-make-array-unique "Minimum Increment to Make Array Unique")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/most-stones-removed-with-same-row-or-column "Most Stones Removed with Same Row or Column") +[Next >](../most-stones-removed-with-same-row-or-column "Most Stones Removed with Same Row or Column") ## [946. Validate Stack Sequences (Medium)](https://leetcode.com/problems/validate-stack-sequences "验证栈序列") @@ -49,4 +49,4 @@ push(5), pop() -> 5, pop() -> 3, pop() -> 2, pop() -> 1 ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] + [[Stack](../../tag/stack/README.md)] diff --git a/problems/verify-preorder-sequence-in-binary-search-tree/README.md b/problems/verify-preorder-sequence-in-binary-search-tree/README.md index 51ea3d09d..d9506fe3c 100644 --- a/problems/verify-preorder-sequence-in-binary-search-tree/README.md +++ b/problems/verify-preorder-sequence-in-binary-search-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/factor-combinations "Factor Combinations") +[< Previous](../factor-combinations "Factor Combinations")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/paint-house "Paint House") +[Next >](../paint-house "Paint House") ## [255. Verify Preorder Sequence in Binary Search Tree (Medium)](https://leetcode.com/problems/verify-preorder-sequence-in-binary-search-tree "验证前序遍历序列二叉搜索树") @@ -40,8 +40,8 @@ Could you do it using only constant space complexity?

### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Binary Tree Preorder Traversal](https://github.com/openset/leetcode/tree/master/problems/binary-tree-preorder-traversal) (Medium) + 1. [Binary Tree Preorder Traversal](../binary-tree-preorder-traversal) (Medium) diff --git a/problems/verify-preorder-serialization-of-a-binary-tree/README.md b/problems/verify-preorder-serialization-of-a-binary-tree/README.md index 673798d68..a8a6b2c3b 100644 --- a/problems/verify-preorder-serialization-of-a-binary-tree/README.md +++ b/problems/verify-preorder-serialization-of-a-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/patching-array "Patching Array") +[< Previous](../patching-array "Patching Array")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reconstruct-itinerary "Reconstruct Itinerary") +[Next >](../reconstruct-itinerary "Reconstruct Itinerary") ## [331. Verify Preorder Serialization of a Binary Tree (Medium)](https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree "验证二叉树的前序序列化") @@ -51,4 +51,4 @@ Output: false ### Related Topics - [[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] + [[Stack](../../tag/stack/README.md)] diff --git a/problems/verifying-an-alien-dictionary/README.md b/problems/verifying-an-alien-dictionary/README.md index 235591033..34c022512 100644 --- a/problems/verifying-an-alien-dictionary/README.md +++ b/problems/verifying-an-alien-dictionary/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/largest-component-size-by-common-factor "Largest Component Size by Common Factor") +[< Previous](../largest-component-size-by-common-factor "Largest Component Size by Common Factor")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/array-of-doubled-pairs "Array of Doubled Pairs") +[Next >](../array-of-doubled-pairs "Array of Doubled Pairs") ## [953. Verifying an Alien Dictionary (Easy)](https://leetcode.com/problems/verifying-an-alien-dictionary "验证外星语词典") @@ -50,4 +50,4 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/vertical-order-traversal-of-a-binary-tree/README.md b/problems/vertical-order-traversal-of-a-binary-tree/README.md index 6cbcefeae..ed7f0aecd 100644 --- a/problems/vertical-order-traversal-of-a-binary-tree/README.md +++ b/problems/vertical-order-traversal-of-a-binary-tree/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/interval-list-intersections "Interval List Intersections") +[< Previous](../interval-list-intersections "Interval List Intersections")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/smallest-string-starting-from-leaf "Smallest String Starting From Leaf") +[Next >](../smallest-string-starting-from-leaf "Smallest String Starting From Leaf") ## [987. Vertical Order Traversal of a Binary Tree (Medium)](https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree "二叉树的垂序遍历") @@ -68,5 +68,5 @@ However, in the report "[1,5,6]", the node value of 5 comes first sinc ### Related Topics - [[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/video-stitching/README.md b/problems/video-stitching/README.md index 826732ee8..e50de6a2e 100644 --- a/problems/video-stitching/README.md +++ b/problems/video-stitching/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/camelcase-matching "Camelcase Matching") +[< Previous](../camelcase-matching "Camelcase Matching")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/divisor-game "Divisor Game") +[Next >](../divisor-game "Divisor Game") ## [1024. Video Stitching (Medium)](https://leetcode.com/problems/video-stitching "视频拼接") @@ -69,7 +69,7 @@ Notice you can have extra video after the event ends. ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
diff --git a/problems/vowel-spellchecker/README.md b/problems/vowel-spellchecker/README.md index 99f363713..fd93b6fab 100644 --- a/problems/vowel-spellchecker/README.md +++ b/problems/vowel-spellchecker/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/univalued-binary-tree "Univalued Binary Tree") +[< Previous](../univalued-binary-tree "Univalued Binary Tree")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/numbers-with-same-consecutive-differences "Numbers With Same Consecutive Differences") +[Next >](../numbers-with-same-consecutive-differences "Numbers With Same Consecutive Differences") ## [966. Vowel Spellchecker (Medium)](https://leetcode.com/problems/vowel-spellchecker "元音拼写检查器") @@ -64,5 +64,5 @@ ### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/walking-robot-simulation/README.md b/problems/walking-robot-simulation/README.md index ae61d58be..94341741b 100644 --- a/problems/walking-robot-simulation/README.md +++ b/problems/walking-robot-simulation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/length-of-longest-fibonacci-subsequence "Length of Longest Fibonacci Subsequence") +[< Previous](../length-of-longest-fibonacci-subsequence "Length of Longest Fibonacci Subsequence")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/koko-eating-bananas "Koko Eating Bananas") +[Next >](../koko-eating-bananas "Koko Eating Bananas") ## [874. Walking Robot Simulation (Easy)](https://leetcode.com/problems/walking-robot-simulation "模拟行走机器人") @@ -60,4 +60,4 @@ ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/walls-and-gates/README.md b/problems/walls-and-gates/README.md index 643d71ae1..4afb430d3 100644 --- a/problems/walls-and-gates/README.md +++ b/problems/walls-and-gates/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/inorder-successor-in-bst "Inorder Successor in BST") +[< Previous](../inorder-successor-in-bst "Inorder Successor in BST")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-the-duplicate-number "Find the Duplicate Number") +[Next >](../find-the-duplicate-number "Find the Duplicate Number") ## [286. Walls and Gates (Medium)](https://leetcode.com/problems/walls-and-gates "墙与门") @@ -42,11 +42,11 @@ INF -1 INF -1 ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions - 1. [Surrounded Regions](https://github.com/openset/leetcode/tree/master/problems/surrounded-regions) (Medium) - 1. [Number of Islands](https://github.com/openset/leetcode/tree/master/problems/number-of-islands) (Medium) - 1. [Shortest Distance from All Buildings](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-from-all-buildings) (Hard) - 1. [Robot Room Cleaner](https://github.com/openset/leetcode/tree/master/problems/robot-room-cleaner) (Hard) - 1. [Rotting Oranges](https://github.com/openset/leetcode/tree/master/problems/rotting-oranges) (Easy) + 1. [Surrounded Regions](../surrounded-regions) (Medium) + 1. [Number of Islands](../number-of-islands) (Medium) + 1. [Shortest Distance from All Buildings](../shortest-distance-from-all-buildings) (Hard) + 1. [Robot Room Cleaner](../robot-room-cleaner) (Hard) + 1. [Rotting Oranges](../rotting-oranges) (Easy) diff --git a/problems/water-and-jug-problem/README.md b/problems/water-and-jug-problem/README.md index d8401d059..d073d0ba4 100644 --- a/problems/water-and-jug-problem/README.md +++ b/problems/water-and-jug-problem/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/nested-list-weight-sum-ii "Nested List Weight Sum II") +[< Previous](../nested-list-weight-sum-ii "Nested List Weight Sum II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-leaves-of-binary-tree "Find Leaves of Binary Tree") +[Next >](../find-leaves-of-binary-tree "Find Leaves of Binary Tree") ## [365. Water and Jug Problem (Medium)](https://leetcode.com/problems/water-and-jug-problem "水壶问题") @@ -38,4 +38,4 @@ Output: False ### Related Topics - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/web-crawler-multithreaded/README.md b/problems/web-crawler-multithreaded/README.md index a46795287..a0cf51d9b 100644 --- a/problems/web-crawler-multithreaded/README.md +++ b/problems/web-crawler-multithreaded/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-comments-per-post "Number of Comments per Post") +[< Previous](../number-of-comments-per-post "Number of Comments per Post")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/array-transformation "Array Transformation") +[Next >](../array-transformation "Array Transformation") ## [1242. Web Crawler Multithreaded (Medium)](https://leetcode.com/problems/web-crawler-multithreaded "多线程网页爬虫") @@ -106,5 +106,5 @@ startUrl = "http://news.google.com" ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/web-crawler/README.md b/problems/web-crawler/README.md index 537be0591..f242a7b83 100644 --- a/problems/web-crawler/README.md +++ b/problems/web-crawler/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-profit-in-job-scheduling "Maximum Profit in Job Scheduling") +[< Previous](../maximum-profit-in-job-scheduling "Maximum Profit in Job Scheduling")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/find-positive-integer-solution-for-a-given-equation "Find Positive Integer Solution for a Given Equation") +[Next >](../find-positive-integer-solution-for-a-given-equation "Find Positive Integer Solution for a Given Equation") ## [1236. Web Crawler (Medium)](https://leetcode.com/problems/web-crawler "") @@ -93,8 +93,8 @@ startUrl = "http://news.google.com" ### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Hints
diff --git a/problems/wiggle-sort-ii/README.md b/problems/wiggle-sort-ii/README.md index 31c8a3915..7843a9470 100644 --- a/problems/wiggle-sort-ii/README.md +++ b/problems/wiggle-sort-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-connected-components-in-an-undirected-graph "Number of Connected Components in an Undirected Graph") +[< Previous](../number-of-connected-components-in-an-undirected-graph "Number of Connected Components in an Undirected Graph")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-size-subarray-sum-equals-k "Maximum Size Subarray Sum Equals k") +[Next >](../maximum-size-subarray-sum-equals-k "Maximum Size Subarray Sum Equals k") ## [324. Wiggle Sort II (Medium)](https://leetcode.com/problems/wiggle-sort-ii "摆动排序 II") @@ -32,9 +32,9 @@ You may assume all input has valid answer.

Can you do it in O(n) time and/or in-place with O(1) extra space?

### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] + [[Sort](../../tag/sort/README.md)] ### Similar Questions - 1. [Sort Colors](https://github.com/openset/leetcode/tree/master/problems/sort-colors) (Medium) - 1. [Kth Largest Element in an Array](https://github.com/openset/leetcode/tree/master/problems/kth-largest-element-in-an-array) (Medium) - 1. [Wiggle Sort](https://github.com/openset/leetcode/tree/master/problems/wiggle-sort) (Medium) + 1. [Sort Colors](../sort-colors) (Medium) + 1. [Kth Largest Element in an Array](../kth-largest-element-in-an-array) (Medium) + 1. [Wiggle Sort](../wiggle-sort) (Medium) diff --git a/problems/wiggle-sort/README.md b/problems/wiggle-sort/README.md index 0d842d02e..847a6c2c5 100644 --- a/problems/wiggle-sort/README.md +++ b/problems/wiggle-sort/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/perfect-squares "Perfect Squares") +[< Previous](../perfect-squares "Perfect Squares")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/zigzag-iterator "Zigzag Iterator") +[Next >](../zigzag-iterator "Zigzag Iterator") ## [280. Wiggle Sort (Medium)](https://leetcode.com/problems/wiggle-sort "摆动排序") @@ -20,9 +20,9 @@ Output: One possible answer is [3,5,1,6,2,4] ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Sort Colors](https://github.com/openset/leetcode/tree/master/problems/sort-colors) (Medium) - 1. [Wiggle Sort II](https://github.com/openset/leetcode/tree/master/problems/wiggle-sort-ii) (Medium) + 1. [Sort Colors](../sort-colors) (Medium) + 1. [Wiggle Sort II](../wiggle-sort-ii) (Medium) diff --git a/problems/wiggle-subsequence/README.md b/problems/wiggle-subsequence/README.md index 4678c4ee4..546c59697 100644 --- a/problems/wiggle-subsequence/README.md +++ b/problems/wiggle-subsequence/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/guess-number-higher-or-lower-ii "Guess Number Higher or Lower II") +[< Previous](../guess-number-higher-or-lower-ii "Guess Number Higher or Lower II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/combination-sum-iv "Combination Sum IV") +[Next >](../combination-sum-iv "Combination Sum IV") ## [376. Wiggle Subsequence (Medium)](https://leetcode.com/problems/wiggle-subsequence "摆动序列") @@ -45,5 +45,5 @@ Can you do it in O(n) time?

### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/wildcard-matching/README.md b/problems/wildcard-matching/README.md index 850c1aaed..c4054c560 100644 --- a/problems/wildcard-matching/README.md +++ b/problems/wildcard-matching/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/multiply-strings "Multiply Strings") +[< Previous](../multiply-strings "Multiply Strings")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/jump-game-ii "Jump Game II") +[Next >](../jump-game-ii "Jump Game II") ## [44. Wildcard Matching (Hard)](https://leetcode.com/problems/wildcard-matching "通配符匹配") @@ -77,10 +77,10 @@ p = "a*c?b" ### Related Topics - [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Regular Expression Matching](https://github.com/openset/leetcode/tree/master/problems/regular-expression-matching) (Hard) + 1. [Regular Expression Matching](../regular-expression-matching) (Hard) diff --git a/problems/winning-candidate/README.md b/problems/winning-candidate/README.md index a6077e393..ccdb959c5 100644 --- a/problems/winning-candidate/README.md +++ b/problems/winning-candidate/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/squirrel-simulation "Squirrel Simulation") +[< Previous](../squirrel-simulation "Squirrel Simulation")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/distribute-candies "Distribute Candies") +[Next >](../distribute-candies "Distribute Candies") ## [574. Winning Candidate (Medium)](https://leetcode.com/problems/winning-candidate "当选者") diff --git a/problems/word-abbreviation/README.md b/problems/word-abbreviation/README.md index af9f1356a..c6ee708e0 100644 --- a/problems/word-abbreviation/README.md +++ b/problems/word-abbreviation/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/beautiful-arrangement "Beautiful Arrangement") +[< Previous](../beautiful-arrangement "Beautiful Arrangement")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-weight "Random Pick with Weight") +[Next >](../random-pick-with-weight "Random Pick with Weight") ## [527. Word Abbreviation (Hard)](https://leetcode.com/problems/word-abbreviation "单词缩写") @@ -36,9 +36,9 @@ ### Related Topics - [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[Sort](../../tag/sort/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Valid Word Abbreviation](https://github.com/openset/leetcode/tree/master/problems/valid-word-abbreviation) (Easy) - 1. [Minimum Unique Word Abbreviation](https://github.com/openset/leetcode/tree/master/problems/minimum-unique-word-abbreviation) (Hard) + 1. [Valid Word Abbreviation](../valid-word-abbreviation) (Easy) + 1. [Minimum Unique Word Abbreviation](../minimum-unique-word-abbreviation) (Hard) diff --git a/problems/word-break-ii/README.md b/problems/word-break-ii/README.md index 5f7c9ba21..5bfaa2a84 100644 --- a/problems/word-break-ii/README.md +++ b/problems/word-break-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/word-break "Word Break") +[< Previous](../word-break "Word Break")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/linked-list-cycle "Linked List Cycle") +[Next >](../linked-list-cycle "Linked List Cycle") ## [140. Word Break II (Hard)](https://leetcode.com/problems/word-break-ii "单词拆分 II") @@ -58,9 +58,9 @@ wordDict = ["cats", "dog", "sand", "and" [] ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Word Break](https://github.com/openset/leetcode/tree/master/problems/word-break) (Medium) - 1. [Concatenated Words](https://github.com/openset/leetcode/tree/master/problems/concatenated-words) (Hard) + 1. [Word Break](../word-break) (Medium) + 1. [Concatenated Words](../concatenated-words) (Hard) diff --git a/problems/word-break/README.md b/problems/word-break/README.md index 350da232d..b33b0291e 100644 --- a/problems/word-break/README.md +++ b/problems/word-break/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/copy-list-with-random-pointer "Copy List with Random Pointer") +[< Previous](../copy-list-with-random-pointer "Copy List with Random Pointer")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/word-break-ii "Word Break II") +[Next >](../word-break-ii "Word Break II") ## [139. Word Break (Medium)](https://leetcode.com/problems/word-break "单词拆分") @@ -45,7 +45,7 @@ ### Related Topics - [[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Word Break II](https://github.com/openset/leetcode/tree/master/problems/word-break-ii) (Hard) + 1. [Word Break II](../word-break-ii) (Hard) diff --git a/problems/word-frequency/README.md b/problems/word-frequency/README.md index 01de1d3bd..a8b0447ab 100644 --- a/problems/word-frequency/README.md +++ b/problems/word-frequency/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-1-bits "Number of 1 Bits") +[< Previous](../number-of-1-bits "Number of 1 Bits")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-phone-numbers "Valid Phone Numbers") +[Next >](../valid-phone-numbers "Valid Phone Numbers") ## [192. Word Frequency (Medium)](https://leetcode.com/problems/word-frequency "统计词频") @@ -47,4 +47,4 @@ day 1 ### Similar Questions - 1. [Top K Frequent Elements](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-elements) (Medium) + 1. [Top K Frequent Elements](../top-k-frequent-elements) (Medium) diff --git a/problems/word-ladder-ii/README.md b/problems/word-ladder-ii/README.md index e1f44be7e..89166942d 100644 --- a/problems/word-ladder-ii/README.md +++ b/problems/word-ladder-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome "Valid Palindrome") +[< Previous](../valid-palindrome "Valid Palindrome")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/word-ladder "Word Ladder") +[Next >](../word-ladder "Word Ladder") ## [126. Word Ladder II (Hard)](https://leetcode.com/problems/word-ladder-ii "单词接龙 II") @@ -60,10 +60,10 @@ wordList = ["hot","dot","dog","lot",&quo ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Word Ladder](https://github.com/openset/leetcode/tree/master/problems/word-ladder) (Medium) + 1. [Word Ladder](../word-ladder) (Medium) diff --git a/problems/word-ladder/README.md b/problems/word-ladder/README.md index 84a7f94f2..6e83286d9 100644 --- a/problems/word-ladder/README.md +++ b/problems/word-ladder/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/word-ladder-ii "Word Ladder II") +[< Previous](../word-ladder-ii "Word Ladder II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-consecutive-sequence "Longest Consecutive Sequence") +[Next >](../longest-consecutive-sequence "Longest Consecutive Sequence") ## [127. Word Ladder (Medium)](https://leetcode.com/problems/word-ladder "单词接龙") @@ -59,8 +59,8 @@ wordList = ["hot","dot","dog","lot",&quo ### Related Topics - [[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions - 1. [Word Ladder II](https://github.com/openset/leetcode/tree/master/problems/word-ladder-ii) (Hard) - 1. [Minimum Genetic Mutation](https://github.com/openset/leetcode/tree/master/problems/minimum-genetic-mutation) (Medium) + 1. [Word Ladder II](../word-ladder-ii) (Hard) + 1. [Minimum Genetic Mutation](../minimum-genetic-mutation) (Medium) diff --git a/problems/word-pattern-ii/README.md b/problems/word-pattern-ii/README.md index 9033c3830..4bb45671f 100644 --- a/problems/word-pattern-ii/README.md +++ b/problems/word-pattern-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/word-pattern "Word Pattern") +[< Previous](../word-pattern "Word Pattern")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/nim-game "Nim Game") +[Next >](../nim-game "Nim Game") ## [291. Word Pattern II (Hard)](https://leetcode.com/problems/word-pattern-ii "单词规律 II") @@ -38,7 +38,7 @@ You may assume both pattern and str contains only lowercase letters.

### Related Topics - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Word Pattern](https://github.com/openset/leetcode/tree/master/problems/word-pattern) (Easy) + 1. [Word Pattern](../word-pattern) (Easy) diff --git a/problems/word-pattern/README.md b/problems/word-pattern/README.md index 9fff9caf9..afa958726 100644 --- a/problems/word-pattern/README.md +++ b/problems/word-pattern/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/game-of-life "Game of Life") +[< Previous](../game-of-life "Game of Life")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/word-pattern-ii "Word Pattern II") +[Next >](../word-pattern-ii "Word Pattern II") ## [290. Word Pattern (Easy)](https://leetcode.com/problems/word-pattern "单词规律") @@ -43,8 +43,8 @@ You may assume pattern contains only lowercase letters, and str contains lowercase letters that may be separated by a single space.

### Related Topics - [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Isomorphic Strings](https://github.com/openset/leetcode/tree/master/problems/isomorphic-strings) (Easy) - 1. [Word Pattern II](https://github.com/openset/leetcode/tree/master/problems/word-pattern-ii) (Hard) + 1. [Isomorphic Strings](../isomorphic-strings) (Easy) + 1. [Word Pattern II](../word-pattern-ii) (Hard) diff --git a/problems/word-search-ii/README.md b/problems/word-search-ii/README.md index 73dabb714..0a51d3e59 100644 --- a/problems/word-search-ii/README.md +++ b/problems/word-search-ii/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/add-and-search-word-data-structure-design "Add and Search Word - Data structure design") +[< Previous](../add-and-search-word-data-structure-design "Add and Search Word - Data structure design")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/house-robber-ii "House Robber II") +[Next >](../house-robber-ii "House Robber II") ## [212. Word Search II (Hard)](https://leetcode.com/problems/word-search-ii "单词搜索 II") @@ -42,12 +42,12 @@ ### Related Topics - [[Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Word Search](https://github.com/openset/leetcode/tree/master/problems/word-search) (Medium) - 1. [Unique Paths III](https://github.com/openset/leetcode/tree/master/problems/unique-paths-iii) (Hard) + 1. [Word Search](../word-search) (Medium) + 1. [Unique Paths III](../unique-paths-iii) (Hard) ### Hints
diff --git a/problems/word-search/README.md b/problems/word-search/README.md index 5f5b4bb13..a6c9d25c5 100644 --- a/problems/word-search/README.md +++ b/problems/word-search/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/subsets "Subsets") +[< Previous](../subsets "Subsets")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-array-ii "Remove Duplicates from Sorted Array II") +[Next >](../remove-duplicates-from-sorted-array-ii "Remove Duplicates from Sorted Array II") ## [79. Word Search (Medium)](https://leetcode.com/problems/word-search "单词搜索") @@ -31,8 +31,8 @@ Given word = "ABCB", return false. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Array](../../tag/array/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Word Search II](https://github.com/openset/leetcode/tree/master/problems/word-search-ii) (Hard) + 1. [Word Search II](../word-search-ii) (Hard) diff --git a/problems/word-squares/README.md b/problems/word-squares/README.md index e8f2a7639..c5a53380b 100644 --- a/problems/word-squares/README.md +++ b/problems/word-squares/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-repeating-character-replacement "Longest Repeating Character Replacement") +[< Previous](../longest-repeating-character-replacement "Longest Repeating Character Replacement")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/convert-binary-search-tree-to-sorted-doubly-linked-list "Convert Binary Search Tree to Sorted Doubly Linked List") +[Next >](../convert-binary-search-tree-to-sorted-doubly-linked-list "Convert Binary Search Tree to Sorted Doubly Linked List") ## [425. Word Squares (Hard)](https://leetcode.com/problems/word-squares "单词方块") @@ -82,8 +82,8 @@ The output consists of two word squares. The order of output does not matter (ju

### Related Topics - [[Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] - [[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Valid Word Square](https://github.com/openset/leetcode/tree/master/problems/valid-word-square) (Easy) + 1. [Valid Word Square](../valid-word-square) (Easy) diff --git a/problems/word-subsets/README.md b/problems/word-subsets/README.md index e3b35bbf2..9a557652d 100644 --- a/problems/word-subsets/README.md +++ b/problems/word-subsets/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/partition-array-into-disjoint-intervals "Partition Array into Disjoint Intervals") +[< Previous](../partition-array-into-disjoint-intervals "Partition Array into Disjoint Intervals")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reverse-only-letters "Reverse Only Letters") +[Next >](../reverse-only-letters "Reverse Only Letters") ## [916. Word Subsets (Medium)](https://leetcode.com/problems/word-subsets "单词子集") @@ -81,4 +81,4 @@ ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/x-of-a-kind-in-a-deck-of-cards/README.md b/problems/x-of-a-kind-in-a-deck-of-cards/README.md index 1a4c97be7..5ae7dfdea 100644 --- a/problems/x-of-a-kind-in-a-deck-of-cards/README.md +++ b/problems/x-of-a-kind-in-a-deck-of-cards/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/cat-and-mouse "Cat and Mouse") +[< Previous](../cat-and-mouse "Cat and Mouse")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/partition-array-into-disjoint-intervals "Partition Array into Disjoint Intervals") +[Next >](../partition-array-into-disjoint-intervals "Partition Array into Disjoint Intervals") ## [914. X of a Kind in a Deck of Cards (Easy)](https://leetcode.com/problems/x-of-a-kind-in-a-deck-of-cards "卡牌分组") @@ -89,5 +89,5 @@ ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] - [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/zigzag-conversion/README.md b/problems/zigzag-conversion/README.md index be8e65df8..e0b4c7f6a 100644 --- a/problems/zigzag-conversion/README.md +++ b/problems/zigzag-conversion/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-palindromic-substring "Longest Palindromic Substring") +[< Previous](../longest-palindromic-substring "Longest Palindromic Substring")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/reverse-integer "Reverse Integer") +[Next >](../reverse-integer "Reverse Integer") ## [6. ZigZag Conversion (Medium)](https://leetcode.com/problems/zigzag-conversion "Z 字形变换") @@ -46,4 +46,4 @@ Y A H R P I ### Related Topics - [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/zigzag-iterator/README.md b/problems/zigzag-iterator/README.md index e73a2dd42..7c86e928a 100644 --- a/problems/zigzag-iterator/README.md +++ b/problems/zigzag-iterator/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/wiggle-sort "Wiggle Sort") +[< Previous](../wiggle-sort "Wiggle Sort")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/expression-add-operators "Expression Add Operators") +[Next >](../expression-add-operators "Expression Add Operators") ## [281. Zigzag Iterator (Medium)](https://leetcode.com/problems/zigzag-iterator "锯齿迭代器") @@ -40,10 +40,10 @@ The "Zigzag" order is not clearly defined and is ambiguous for k ### Related Topics - [[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions - 1. [Binary Search Tree Iterator](https://github.com/openset/leetcode/tree/master/problems/binary-search-tree-iterator) (Medium) - 1. [Flatten 2D Vector](https://github.com/openset/leetcode/tree/master/problems/flatten-2d-vector) (Medium) - 1. [Peeking Iterator](https://github.com/openset/leetcode/tree/master/problems/peeking-iterator) (Medium) - 1. [Flatten Nested List Iterator](https://github.com/openset/leetcode/tree/master/problems/flatten-nested-list-iterator) (Medium) + 1. [Binary Search Tree Iterator](../binary-search-tree-iterator) (Medium) + 1. [Flatten 2D Vector](../flatten-2d-vector) (Medium) + 1. [Peeking Iterator](../peeking-iterator) (Medium) + 1. [Flatten Nested List Iterator](../flatten-nested-list-iterator) (Medium) diff --git a/problems/zuma-game/README.md b/problems/zuma-game/README.md index 37123e60d..a8d9b5b65 100644 --- a/problems/zuma-game/README.md +++ b/problems/zuma-game/README.md @@ -5,9 +5,9 @@ -[< Previous](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones-ii "Max Consecutive Ones II") +[< Previous](../max-consecutive-ones-ii "Max Consecutive Ones II")                  -[Next >](https://github.com/openset/leetcode/tree/master/problems/robot-room-cleaner "Robot Room Cleaner") +[Next >](../robot-room-cleaner "Robot Room Cleaner") ## [488. Zuma Game (Hard)](https://leetcode.com/problems/zuma-game "祖玛游戏") @@ -47,4 +47,4 @@ Find the minimal balls you have to insert to remove all the balls on the table.

### Related Topics - [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/readme/1-300.md b/readme/1-300.md index 347bc028a..15fc094b0 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -19,44 +19,44 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + +
[1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
[301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
[601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
[901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
[1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
diff --git a/readme/301-600.md b/readme/301-600.md index d85378bac..0baddcda9 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -19,44 +19,44 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + +
[1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
[301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
[601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
[901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
[1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
diff --git a/readme/601-900.md b/readme/601-900.md index a80a422d9..b9e0660fa 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -19,44 +19,44 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + +
[1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
[301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
[601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
[901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
[1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
diff --git a/tag/README.md b/tag/README.md index e45f223ef..ce49fdea5 100644 --- a/tag/README.md +++ b/tag/README.md @@ -9,23 +9,23 @@ | # | Title | 话题 | | # | Title | 话题 | | :-: | - | :-: | - | :-: | - | :-: | -| 1 | [Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md) | [数组](https://openset.github.io/tags/array/) | | 2 | [Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md) | [动态规划](https://openset.github.io/tags/dynamic-programming/) | -| 3 | [Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md) | [数学](https://openset.github.io/tags/math/) | | 4 | [String](https://github.com/openset/leetcode/tree/master/tag/string/README.md) | [字符串](https://openset.github.io/tags/string/) | -| 5 | [Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md) | [树](https://openset.github.io/tags/tree/) | | 6 | [Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | -| 7 | [Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md) | [深度优先搜索](https://openset.github.io/tags/depth-first-search/) | | 8 | [Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | -| 9 | [Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 10 | [Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | -| 11 | [Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 12 | [Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md) | [栈](https://openset.github.io/tags/stack/) | -| 13 | [Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md) | [设计](https://openset.github.io/tags/design/) | -| 15 | [Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 16 | [Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md) | [排序](https://openset.github.io/tags/sort/) | -| 17 | [Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | -| 19 | [Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 20 | [Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | -| 21 | [Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | | 22 | [Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | -| 23 | [Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | -| 25 | [Segment Tree](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | -| 27 | [Queue](https://github.com/openset/leetcode/tree/master/tag/queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Minimax](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | -| 29 | [Binary Indexed Tree](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 30 | [Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | -| 31 | [Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md) | [Random](https://openset.github.io/tags/random/) | | 32 | [Topological Sort](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | -| 33 | [Brainteaser](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 34 | [Geometry](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | -| 35 | [Binary Search Tree](https://github.com/openset/leetcode/tree/master/tag/binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [Rejection Sampling](https://github.com/openset/leetcode/tree/master/tag/rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | -| 37 | [Reservoir Sampling](https://github.com/openset/leetcode/tree/master/tag/reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | | 38 | [Memoization](https://github.com/openset/leetcode/tree/master/tag/memoization/README.md) | [记忆化](https://openset.github.io/tags/memoization/) | -| 39 | [Rolling Hash](https://github.com/openset/leetcode/tree/master/tag/rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | | 40 | [Suffix Array](https://github.com/openset/leetcode/tree/master/tag/suffix-array/README.md) | [Suffix Array](https://openset.github.io/tags/suffix-array/) | +| 1 | [Array](array/README.md) | [数组](https://openset.github.io/tags/array/) | | 2 | [Dynamic Programming](dynamic-programming/README.md) | [动态规划](https://openset.github.io/tags/dynamic-programming/) | +| 3 | [Math](math/README.md) | [数学](https://openset.github.io/tags/math/) | | 4 | [String](string/README.md) | [字符串](https://openset.github.io/tags/string/) | +| 5 | [Tree](tree/README.md) | [树](https://openset.github.io/tags/tree/) | | 6 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | +| 7 | [Depth-first Search](depth-first-search/README.md) | [深度优先搜索](https://openset.github.io/tags/depth-first-search/) | | 8 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | +| 9 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | +| 11 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 12 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | +| 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | +| 15 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 16 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | +| 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | +| 19 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 20 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | +| 21 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | | 22 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | +| 23 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | +| 25 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | +| 27 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | +| 29 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 30 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | +| 31 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 32 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | +| 33 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 34 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | +| 35 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | +| 37 | [Reservoir Sampling](reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | | 38 | [Memoization](memoization/README.md) | [记忆化](https://openset.github.io/tags/memoization/) | +| 39 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | | 40 | [Suffix Array](suffix-array/README.md) | [Suffix Array](https://openset.github.io/tags/suffix-array/) | diff --git a/tag/array/README.md b/tag/array/README.md index 353bfe55d..65b453837 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -5,217 +5,217 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 数组 +## [话题分类](../README.md) > 数组 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1292 | [元素和小于等于阈值的正方形的最大边长](https://github.com/openset/leetcode/tree/master/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 1287 | [有序数组中出现次数超过25%的元素](https://github.com/openset/leetcode/tree/master/problems/element-appearing-more-than-25-in-sorted-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1277 | [统计全为 1 的正方形子矩阵](https://github.com/openset/leetcode/tree/master/problems/count-square-submatrices-with-all-ones) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1275 | [找出井字棋的获胜者](https://github.com/openset/leetcode/tree/master/problems/find-winner-on-a-tic-tac-toe-game) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1267 | [统计参与通信的服务器](https://github.com/openset/leetcode/tree/master/problems/count-servers-that-communicate) | [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 1266 | [访问所有点的最小时间](https://github.com/openset/leetcode/tree/master/problems/minimum-time-visiting-all-points) | [[几何](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1260 | [二维网格迁移](https://github.com/openset/leetcode/tree/master/problems/shift-2d-grid) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1252 | [奇数值单元格的数目](https://github.com/openset/leetcode/tree/master/problems/cells-with-odd-values-in-a-matrix) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1243 | [数组变换](https://github.com/openset/leetcode/tree/master/problems/array-transformation) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1233 | [删除子文件夹](https://github.com/openset/leetcode/tree/master/problems/remove-sub-folders-from-the-filesystem) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1232 | [缀点成线](https://github.com/openset/leetcode/tree/master/problems/check-if-it-is-a-straight-line) | [[几何](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 1222 | [可以攻击国王的皇后](https://github.com/openset/leetcode/tree/master/problems/queens-that-can-attack-the-king) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 1217 | [玩筹码](https://github.com/openset/leetcode/tree/master/problems/play-with-chips) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 1208 | [尽可能使字符串相等](https://github.com/openset/leetcode/tree/master/problems/get-equal-substrings-within-budget) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 1202 | [交换字符串中的元素](https://github.com/openset/leetcode/tree/master/problems/smallest-string-with-swaps) | [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 1200 | [最小绝对差](https://github.com/openset/leetcode/tree/master/problems/minimum-absolute-difference) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1185 | [一周中的第几天](https://github.com/openset/leetcode/tree/master/problems/day-of-the-week) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1184 | [公交站间的距离](https://github.com/openset/leetcode/tree/master/problems/distance-between-bus-stops) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1177 | [构建回文串检测](https://github.com/openset/leetcode/tree/master/problems/can-make-palindrome-from-substring) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1176 | [健身计划评估](https://github.com/openset/leetcode/tree/master/problems/diet-plan-performance) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Easy | -| 1170 | [比较字符串最小字母出现频次](https://github.com/openset/leetcode/tree/master/problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 1169 | [查询无效交易](https://github.com/openset/leetcode/tree/master/problems/invalid-transactions) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1160 | [拼写单词](https://github.com/openset/leetcode/tree/master/problems/find-words-that-can-be-formed-by-characters) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 1157 | [子数组中占绝大多数的元素](https://github.com/openset/leetcode/tree/master/problems/online-majority-element-in-subarray) | [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 1152 | [用户网站访问行为分析](https://github.com/openset/leetcode/tree/master/problems/analyze-user-website-visit-pattern) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 1151 | [最少交换次数来组合所有的 1](https://github.com/openset/leetcode/tree/master/problems/minimum-swaps-to-group-all-1s-together) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 1150 | [检查一个数是否在数组中占绝大多数](https://github.com/openset/leetcode/tree/master/problems/check-if-a-number-is-majority-element-in-a-sorted-array) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 1146 | [快照数组](https://github.com/openset/leetcode/tree/master/problems/snapshot-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 1144 | [递减元素使数组呈锯齿状](https://github.com/openset/leetcode/tree/master/problems/decrease-elements-to-make-array-zigzag) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 1133 | [最大唯一数](https://github.com/openset/leetcode/tree/master/problems/largest-unique-number) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 1128 | [等价多米诺骨牌对的数量](https://github.com/openset/leetcode/tree/master/problems/number-of-equivalent-domino-pairs) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1122 | [数组的相对排序](https://github.com/openset/leetcode/tree/master/problems/relative-sort-array) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1109 | [航班预订统计](https://github.com/openset/leetcode/tree/master/problems/corporate-flight-bookings) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 1099 | [小于 K 的两数之和](https://github.com/openset/leetcode/tree/master/problems/two-sum-less-than-k) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1089 | [复写零](https://github.com/openset/leetcode/tree/master/problems/duplicate-zeros) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1086 | [前五科的均分](https://github.com/openset/leetcode/tree/master/problems/high-five) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 1085 | [最小元素各数位之和](https://github.com/openset/leetcode/tree/master/problems/sum-of-digits-in-the-minimum-number) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1074 | [元素和为目标值的子矩阵数量](https://github.com/openset/leetcode/tree/master/problems/number-of-submatrices-that-sum-to-target) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 1064 | [不动点](https://github.com/openset/leetcode/tree/master/problems/fixed-point) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 1053 | [交换一次的先前排列](https://github.com/openset/leetcode/tree/master/problems/previous-permutation-with-one-swap) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 1052 | [爱生气的书店老板](https://github.com/openset/leetcode/tree/master/problems/grumpy-bookstore-owner) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 1051 | [高度检查器](https://github.com/openset/leetcode/tree/master/problems/height-checker) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1040 | [移动石子直到连续 II](https://github.com/openset/leetcode/tree/master/problems/moving-stones-until-consecutive-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 1035 | [不相交的线](https://github.com/openset/leetcode/tree/master/problems/uncrossed-lines) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 1031 | [两个非重叠子数组的最大和](https://github.com/openset/leetcode/tree/master/problems/maximum-sum-of-two-non-overlapping-subarrays) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 1018 | [可被 5 整除的二进制前缀](https://github.com/openset/leetcode/tree/master/problems/binary-prefix-divisible-by-5) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1014 | [最佳观光组合](https://github.com/openset/leetcode/tree/master/problems/best-sightseeing-pair) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 1013 | [将数组分成和相等的三个部分](https://github.com/openset/leetcode/tree/master/problems/partition-array-into-three-parts-with-equal-sum) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1011 | [在 D 天内送达包裹的能力](https://github.com/openset/leetcode/tree/master/problems/capacity-to-ship-packages-within-d-days) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 1010 | [总持续时间可被 60 整除的歌曲](https://github.com/openset/leetcode/tree/master/problems/pairs-of-songs-with-total-durations-divisible-by-60) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1007 | [行相等的最少多米诺旋转](https://github.com/openset/leetcode/tree/master/problems/minimum-domino-rotations-for-equal-row) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 1002 | [查找常用字符](https://github.com/openset/leetcode/tree/master/problems/find-common-characters) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 999 | [车的可用捕获量](https://github.com/openset/leetcode/tree/master/problems/available-captures-for-rook) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 989 | [数组形式的整数加法](https://github.com/openset/leetcode/tree/master/problems/add-to-array-form-of-integer) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 985 | [查询后的偶数和](https://github.com/openset/leetcode/tree/master/problems/sum-of-even-numbers-after-queries) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 978 | [最长湍流子数组](https://github.com/openset/leetcode/tree/master/problems/longest-turbulent-subarray) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 977 | [有序数组的平方](https://github.com/openset/leetcode/tree/master/problems/squares-of-a-sorted-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 974 | [和可被 K 整除的子数组](https://github.com/openset/leetcode/tree/master/problems/subarray-sums-divisible-by-k) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 969 | [煎饼排序](https://github.com/openset/leetcode/tree/master/problems/pancake-sorting) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 962 | [最大宽度坡](https://github.com/openset/leetcode/tree/master/problems/maximum-width-ramp) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 954 | [二倍数对数组](https://github.com/openset/leetcode/tree/master/problems/array-of-doubled-pairs) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 950 | [按递增顺序显示卡牌](https://github.com/openset/leetcode/tree/master/problems/reveal-cards-in-increasing-order) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 945 | [使数组唯一的最小增量](https://github.com/openset/leetcode/tree/master/problems/minimum-increment-to-make-array-unique) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 941 | [有效的山脉数组](https://github.com/openset/leetcode/tree/master/problems/valid-mountain-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 926 | [将字符串翻转到单调递增](https://github.com/openset/leetcode/tree/master/problems/flip-string-to-monotone-increasing) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 922 | [按奇偶排序数组 II](https://github.com/openset/leetcode/tree/master/problems/sort-array-by-parity-ii) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 918 | [环形子数组的最大和](https://github.com/openset/leetcode/tree/master/problems/maximum-sum-circular-subarray) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 915 | [分割数组](https://github.com/openset/leetcode/tree/master/problems/partition-array-into-disjoint-intervals) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 914 | [卡牌分组](https://github.com/openset/leetcode/tree/master/problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 907 | [子数组的最小值之和](https://github.com/openset/leetcode/tree/master/problems/sum-of-subarray-minimums) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 905 | [按奇偶排序数组](https://github.com/openset/leetcode/tree/master/problems/sort-array-by-parity) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 900 | [RLE 迭代器](https://github.com/openset/leetcode/tree/master/problems/rle-iterator) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 896 | [单调数列](https://github.com/openset/leetcode/tree/master/problems/monotonic-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 891 | [子序列宽度之和](https://github.com/openset/leetcode/tree/master/problems/sum-of-subsequence-widths) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 888 | [公平的糖果交换](https://github.com/openset/leetcode/tree/master/problems/fair-candy-swap) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 873 | [最长的斐波那契子序列的长度](https://github.com/openset/leetcode/tree/master/problems/length-of-longest-fibonacci-subsequence) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 870 | [优势洗牌](https://github.com/openset/leetcode/tree/master/problems/advantage-shuffle) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 867 | [转置矩阵](https://github.com/openset/leetcode/tree/master/problems/transpose-matrix) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 849 | [到最近的人的最大距离](https://github.com/openset/leetcode/tree/master/problems/maximize-distance-to-closest-person) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 840 | [矩阵中的幻方](https://github.com/openset/leetcode/tree/master/problems/magic-squares-in-grid) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 835 | [图像重叠](https://github.com/openset/leetcode/tree/master/problems/image-overlap) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 832 | [翻转图像](https://github.com/openset/leetcode/tree/master/problems/flipping-an-image) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 830 | [较大分组的位置](https://github.com/openset/leetcode/tree/master/problems/positions-of-large-groups) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 825 | [适龄的朋友](https://github.com/openset/leetcode/tree/master/problems/friends-of-appropriate-ages) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 795 | [区间子数组个数](https://github.com/openset/leetcode/tree/master/problems/number-of-subarrays-with-bounded-maximum) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 792 | [匹配子序列的单词数](https://github.com/openset/leetcode/tree/master/problems/number-of-matching-subsequences) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 782 | [变为棋盘](https://github.com/openset/leetcode/tree/master/problems/transform-to-chessboard) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 775 | [全局倒置与局部倒置](https://github.com/openset/leetcode/tree/master/problems/global-and-local-inversions) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 769 | [最多能完成排序的块](https://github.com/openset/leetcode/tree/master/problems/max-chunks-to-make-sorted) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 768 | [最多能完成排序的块 II](https://github.com/openset/leetcode/tree/master/problems/max-chunks-to-make-sorted-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Hard | -| 766 | [托普利茨矩阵](https://github.com/openset/leetcode/tree/master/problems/toeplitz-matrix) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 755 | [倒水](https://github.com/openset/leetcode/tree/master/problems/pour-water) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 747 | [至少是其他数字两倍的最大数](https://github.com/openset/leetcode/tree/master/problems/largest-number-at-least-twice-of-others) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 746 | [使用最小花费爬楼梯](https://github.com/openset/leetcode/tree/master/problems/min-cost-climbing-stairs) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Easy | -| 729 | [我的日程安排表 I](https://github.com/openset/leetcode/tree/master/problems/my-calendar-i) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 724 | [寻找数组的中心索引](https://github.com/openset/leetcode/tree/master/problems/find-pivot-index) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 723 | [粉碎糖果](https://github.com/openset/leetcode/tree/master/problems/candy-crush) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 719 | [找出第 k 小的距离对](https://github.com/openset/leetcode/tree/master/problems/find-k-th-smallest-pair-distance) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 718 | [最长重复子数组](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-repeated-subarray) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 717 | [1比特与2比特字符](https://github.com/openset/leetcode/tree/master/problems/1-bit-and-2-bit-characters) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 714 | [买卖股票的最佳时机含手续费](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 713 | [乘积小于K的子数组](https://github.com/openset/leetcode/tree/master/problems/subarray-product-less-than-k) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 697 | [数组的度](https://github.com/openset/leetcode/tree/master/problems/degree-of-an-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 695 | [岛屿的最大面积](https://github.com/openset/leetcode/tree/master/problems/max-area-of-island) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 689 | [三个无重叠子数组的最大和](https://github.com/openset/leetcode/tree/master/problems/maximum-sum-of-3-non-overlapping-subarrays) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 674 | [最长连续递增序列](https://github.com/openset/leetcode/tree/master/problems/longest-continuous-increasing-subsequence) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 670 | [最大交换](https://github.com/openset/leetcode/tree/master/problems/maximum-swap) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 667 | [优美的排列 II](https://github.com/openset/leetcode/tree/master/problems/beautiful-arrangement-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 665 | [非递减数列](https://github.com/openset/leetcode/tree/master/problems/non-decreasing-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 661 | [图片平滑器](https://github.com/openset/leetcode/tree/master/problems/image-smoother) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 644 | [最大平均子段和 II](https://github.com/openset/leetcode/tree/master/problems/maximum-average-subarray-ii) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 643 | [子数组最大平均数 I](https://github.com/openset/leetcode/tree/master/problems/maximum-average-subarray-i) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 628 | [三个数的最大乘积](https://github.com/openset/leetcode/tree/master/problems/maximum-product-of-three-numbers) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 624 | [数组列表中的最大距离](https://github.com/openset/leetcode/tree/master/problems/maximum-distance-in-arrays) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 621 | [任务调度器](https://github.com/openset/leetcode/tree/master/problems/task-scheduler) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 611 | [有效三角形的个数](https://github.com/openset/leetcode/tree/master/problems/valid-triangle-number) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 605 | [种花问题](https://github.com/openset/leetcode/tree/master/problems/can-place-flowers) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 581 | [最短无序连续子数组](https://github.com/openset/leetcode/tree/master/problems/shortest-unsorted-continuous-subarray) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 566 | [重塑矩阵](https://github.com/openset/leetcode/tree/master/problems/reshape-the-matrix) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 565 | [数组嵌套](https://github.com/openset/leetcode/tree/master/problems/array-nesting) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 562 | [矩阵中最长的连续1线段](https://github.com/openset/leetcode/tree/master/problems/longest-line-of-consecutive-one-in-matrix) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 561 | [数组拆分 I](https://github.com/openset/leetcode/tree/master/problems/array-partition-i) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 560 | [和为K的子数组](https://github.com/openset/leetcode/tree/master/problems/subarray-sum-equals-k) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 548 | [将数组分割成和相等的子数组](https://github.com/openset/leetcode/tree/master/problems/split-array-with-equal-sum) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 533 | [孤独像素 II](https://github.com/openset/leetcode/tree/master/problems/lonely-pixel-ii) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 532 | [数组中的K-diff数对](https://github.com/openset/leetcode/tree/master/problems/k-diff-pairs-in-an-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 531 | [孤独像素 I](https://github.com/openset/leetcode/tree/master/problems/lonely-pixel-i) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 509 | [斐波那契数](https://github.com/openset/leetcode/tree/master/problems/fibonacci-number) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 495 | [提莫攻击](https://github.com/openset/leetcode/tree/master/problems/teemo-attacking) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 485 | [最大连续1的个数](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 457 | [环形数组循环](https://github.com/openset/leetcode/tree/master/problems/circular-array-loop) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 448 | [找到所有数组中消失的数字](https://github.com/openset/leetcode/tree/master/problems/find-all-numbers-disappeared-in-an-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 442 | [数组中重复的数据](https://github.com/openset/leetcode/tree/master/problems/find-all-duplicates-in-an-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 414 | [第三大的数](https://github.com/openset/leetcode/tree/master/problems/third-maximum-number) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](https://github.com/openset/leetcode/tree/master/problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Hard | -| 380 | [常数时间插入、删除和获取随机元素](https://github.com/openset/leetcode/tree/master/problems/insert-delete-getrandom-o1) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 370 | [区间加法](https://github.com/openset/leetcode/tree/master/problems/range-addition) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 289 | [生命游戏](https://github.com/openset/leetcode/tree/master/problems/game-of-life) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 287 | [寻找重复数](https://github.com/openset/leetcode/tree/master/problems/find-the-duplicate-number) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 283 | [移动零](https://github.com/openset/leetcode/tree/master/problems/move-zeroes) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 280 | [摆动排序](https://github.com/openset/leetcode/tree/master/problems/wiggle-sort) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 277 | [搜寻名人](https://github.com/openset/leetcode/tree/master/problems/find-the-celebrity) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 268 | [缺失数字](https://github.com/openset/leetcode/tree/master/problems/missing-number) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 259 | [较小的三数之和](https://github.com/openset/leetcode/tree/master/problems/3sum-smaller) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 245 | [最短单词距离 III](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance-iii) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 243 | [最短单词距离](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 238 | [除自身以外数组的乘积](https://github.com/openset/leetcode/tree/master/problems/product-of-array-except-self) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 229 | [求众数 II](https://github.com/openset/leetcode/tree/master/problems/majority-element-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 228 | [汇总区间](https://github.com/openset/leetcode/tree/master/problems/summary-ranges) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 219 | [存在重复元素 II](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 217 | [存在重复元素](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 216 | [组合总和 III](https://github.com/openset/leetcode/tree/master/problems/combination-sum-iii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 209 | [长度最小的子数组](https://github.com/openset/leetcode/tree/master/problems/minimum-size-subarray-sum) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 189 | [旋转数组](https://github.com/openset/leetcode/tree/master/problems/rotate-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 169 | [多数元素](https://github.com/openset/leetcode/tree/master/problems/majority-element) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Easy | -| 167 | [两数之和 II - 输入有序数组](https://github.com/openset/leetcode/tree/master/problems/two-sum-ii-input-array-is-sorted) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 163 | [缺失的区间](https://github.com/openset/leetcode/tree/master/problems/missing-ranges) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 162 | [寻找峰值](https://github.com/openset/leetcode/tree/master/problems/find-peak-element) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 154 | [寻找旋转排序数组中的最小值 II](https://github.com/openset/leetcode/tree/master/problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 153 | [寻找旋转排序数组中的最小值](https://github.com/openset/leetcode/tree/master/problems/find-minimum-in-rotated-sorted-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 152 | [乘积最大子序列](https://github.com/openset/leetcode/tree/master/problems/maximum-product-subarray) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 128 | [最长连续序列](https://github.com/openset/leetcode/tree/master/problems/longest-consecutive-sequence) | [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Hard | -| 126 | [单词接龙 II](https://github.com/openset/leetcode/tree/master/problems/word-ladder-ii) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 123 | [买卖股票的最佳时机 III](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-iii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 122 | [买卖股票的最佳时机 II](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-ii) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 121 | [买卖股票的最佳时机](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Easy | -| 120 | [三角形最小路径和](https://github.com/openset/leetcode/tree/master/problems/triangle) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 119 | [杨辉三角 II](https://github.com/openset/leetcode/tree/master/problems/pascals-triangle-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 118 | [杨辉三角](https://github.com/openset/leetcode/tree/master/problems/pascals-triangle) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 106 | [从中序与后序遍历序列构造二叉树](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 105 | [从前序与中序遍历序列构造二叉树](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 90 | [子集 II](https://github.com/openset/leetcode/tree/master/problems/subsets-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 88 | [合并两个有序数组](https://github.com/openset/leetcode/tree/master/problems/merge-sorted-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 85 | [最大矩形](https://github.com/openset/leetcode/tree/master/problems/maximal-rectangle) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 84 | [柱状图中最大的矩形](https://github.com/openset/leetcode/tree/master/problems/largest-rectangle-in-histogram) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Hard | -| 81 | [搜索旋转排序数组 II](https://github.com/openset/leetcode/tree/master/problems/search-in-rotated-sorted-array-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 80 | [删除排序数组中的重复项 II](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-array-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 79 | [单词搜索](https://github.com/openset/leetcode/tree/master/problems/word-search) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 78 | [子集](https://github.com/openset/leetcode/tree/master/problems/subsets) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 75 | [颜色分类](https://github.com/openset/leetcode/tree/master/problems/sort-colors) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 74 | [搜索二维矩阵](https://github.com/openset/leetcode/tree/master/problems/search-a-2d-matrix) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 73 | [矩阵置零](https://github.com/openset/leetcode/tree/master/problems/set-matrix-zeroes) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 66 | [加一](https://github.com/openset/leetcode/tree/master/problems/plus-one) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 64 | [最小路径和](https://github.com/openset/leetcode/tree/master/problems/minimum-path-sum) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 63 | [不同路径 II](https://github.com/openset/leetcode/tree/master/problems/unique-paths-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 62 | [不同路径](https://github.com/openset/leetcode/tree/master/problems/unique-paths) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 59 | [螺旋矩阵 II](https://github.com/openset/leetcode/tree/master/problems/spiral-matrix-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 57 | [插入区间](https://github.com/openset/leetcode/tree/master/problems/insert-interval) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Hard | -| 56 | [合并区间](https://github.com/openset/leetcode/tree/master/problems/merge-intervals) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 55 | [跳跃游戏](https://github.com/openset/leetcode/tree/master/problems/jump-game) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 54 | [螺旋矩阵](https://github.com/openset/leetcode/tree/master/problems/spiral-matrix) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 53 | [最大子序和](https://github.com/openset/leetcode/tree/master/problems/maximum-subarray) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Easy | -| 48 | [旋转图像](https://github.com/openset/leetcode/tree/master/problems/rotate-image) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 45 | [跳跃游戏 II](https://github.com/openset/leetcode/tree/master/problems/jump-game-ii) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Hard | -| 42 | [接雨水](https://github.com/openset/leetcode/tree/master/problems/trapping-rain-water) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Hard | -| 41 | [缺失的第一个正数](https://github.com/openset/leetcode/tree/master/problems/first-missing-positive) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Hard | -| 40 | [组合总和 II](https://github.com/openset/leetcode/tree/master/problems/combination-sum-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 39 | [组合总和](https://github.com/openset/leetcode/tree/master/problems/combination-sum) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 35 | [搜索插入位置](https://github.com/openset/leetcode/tree/master/problems/search-insert-position) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 34 | [在排序数组中查找元素的第一个和最后一个位置](https://github.com/openset/leetcode/tree/master/problems/find-first-and-last-position-of-element-in-sorted-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 33 | [搜索旋转排序数组](https://github.com/openset/leetcode/tree/master/problems/search-in-rotated-sorted-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 31 | [下一个排列](https://github.com/openset/leetcode/tree/master/problems/next-permutation) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 27 | [移除元素](https://github.com/openset/leetcode/tree/master/problems/remove-element) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 26 | [删除排序数组中的重复项](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 18 | [四数之和](https://github.com/openset/leetcode/tree/master/problems/4sum) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 16 | [最接近的三数之和](https://github.com/openset/leetcode/tree/master/problems/3sum-closest) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 15 | [三数之和](https://github.com/openset/leetcode/tree/master/problems/3sum) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 11 | [盛最多水的容器](https://github.com/openset/leetcode/tree/master/problems/container-with-most-water) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 4 | [寻找两个有序数组的中位数](https://github.com/openset/leetcode/tree/master/problems/median-of-two-sorted-arrays) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 1 | [两数之和](https://github.com/openset/leetcode/tree/master/problems/two-sum) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | +| 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1287 | [有序数组中出现次数超过25%的元素](../../problems/element-appearing-more-than-25-in-sorted-array) | [[数组](../array/README.md)] | Easy | +| 1277 | [统计全为 1 的正方形子矩阵](../../problems/count-square-submatrices-with-all-ones) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1275 | [找出井字棋的获胜者](../../problems/find-winner-on-a-tic-tac-toe-game) | [[数组](../array/README.md)] | Easy | +| 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | +| 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] | Easy | +| 1260 | [二维网格迁移](../../problems/shift-2d-grid) | [[数组](../array/README.md)] | Easy | +| 1252 | [奇数值单元格的数目](../../problems/cells-with-odd-values-in-a-matrix) | [[数组](../array/README.md)] | Easy | +| 1243 | [数组变换](../../problems/array-transformation) 🔒 | [[数组](../array/README.md)] | Easy | +| 1233 | [删除子文件夹](../../problems/remove-sub-folders-from-the-filesystem) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1222 | [可以攻击国王的皇后](../../problems/queens-that-can-attack-the-king) | [[数组](../array/README.md)] | Medium | +| 1217 | [玩筹码](../../problems/play-with-chips) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | +| 1200 | [最小绝对差](../../problems/minimum-absolute-difference) | [[数组](../array/README.md)] | Easy | +| 1185 | [一周中的第几天](../../problems/day-of-the-week) | [[数组](../array/README.md)] | Easy | +| 1184 | [公交站间的距离](../../problems/distance-between-bus-stops) | [[数组](../array/README.md)] | Easy | +| 1177 | [构建回文串检测](../../problems/can-make-palindrome-from-substring) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1176 | [健身计划评估](../../problems/diet-plan-performance) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Easy | +| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1169 | [查询无效交易](../../problems/invalid-transactions) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1160 | [拼写单词](../../problems/find-words-that-can-be-formed-by-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1151 | [最少交换次数来组合所有的 1](../../problems/minimum-swaps-to-group-all-1s-together) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1150 | [检查一个数是否在数组中占绝大多数](../../problems/check-if-a-number-is-majority-element-in-a-sorted-array) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1146 | [快照数组](../../problems/snapshot-array) | [[数组](../array/README.md)] | Medium | +| 1144 | [递减元素使数组呈锯齿状](../../problems/decrease-elements-to-make-array-zigzag) | [[数组](../array/README.md)] | Medium | +| 1133 | [最大唯一数](../../problems/largest-unique-number) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1128 | [等价多米诺骨牌对的数量](../../problems/number-of-equivalent-domino-pairs) | [[数组](../array/README.md)] | Easy | +| 1122 | [数组的相对排序](../../problems/relative-sort-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 1109 | [航班预订统计](../../problems/corporate-flight-bookings) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[数组](../array/README.md)] | Easy | +| 1089 | [复写零](../../problems/duplicate-zeros) | [[数组](../array/README.md)] | Easy | +| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1085 | [最小元素各数位之和](../../problems/sum-of-digits-in-the-minimum-number) 🔒 | [[数组](../array/README.md)] | Easy | +| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 1064 | [不动点](../../problems/fixed-point) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1053 | [交换一次的先前排列](../../problems/previous-permutation-with-one-swap) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1052 | [爱生气的书店老板](../../problems/grumpy-bookstore-owner) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1051 | [高度检查器](../../problems/height-checker) | [[数组](../array/README.md)] | Easy | +| 1040 | [移动石子直到连续 II](../../problems/moving-stones-until-consecutive-ii) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1035 | [不相交的线](../../problems/uncrossed-lines) | [[数组](../array/README.md)] | Medium | +| 1031 | [两个非重叠子数组的最大和](../../problems/maximum-sum-of-two-non-overlapping-subarrays) | [[数组](../array/README.md)] | Medium | +| 1018 | [可被 5 整除的二进制前缀](../../problems/binary-prefix-divisible-by-5) | [[数组](../array/README.md)] | Easy | +| 1014 | [最佳观光组合](../../problems/best-sightseeing-pair) | [[数组](../array/README.md)] | Medium | +| 1013 | [将数组分成和相等的三个部分](../../problems/partition-array-into-three-parts-with-equal-sum) | [[数组](../array/README.md)] | Easy | +| 1011 | [在 D 天内送达包裹的能力](../../problems/capacity-to-ship-packages-within-d-days) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1010 | [总持续时间可被 60 整除的歌曲](../../problems/pairs-of-songs-with-total-durations-divisible-by-60) | [[数组](../array/README.md)] | Easy | +| 1007 | [行相等的最少多米诺旋转](../../problems/minimum-domino-rotations-for-equal-row) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 999 | [车的可用捕获量](../../problems/available-captures-for-rook) | [[数组](../array/README.md)] | Easy | +| 989 | [数组形式的整数加法](../../problems/add-to-array-form-of-integer) | [[数组](../array/README.md)] | Easy | +| 985 | [查询后的偶数和](../../problems/sum-of-even-numbers-after-queries) | [[数组](../array/README.md)] | Easy | +| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 977 | [有序数组的平方](../../problems/squares-of-a-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 974 | [和可被 K 整除的子数组](../../problems/subarray-sums-divisible-by-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 969 | [煎饼排序](../../problems/pancake-sorting) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 962 | [最大宽度坡](../../problems/maximum-width-ramp) | [[数组](../array/README.md)] | Medium | +| 954 | [二倍数对数组](../../problems/array-of-doubled-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 950 | [按递增顺序显示卡牌](../../problems/reveal-cards-in-increasing-order) | [[数组](../array/README.md)] | Medium | +| 945 | [使数组唯一的最小增量](../../problems/minimum-increment-to-make-array-unique) | [[数组](../array/README.md)] | Medium | +| 941 | [有效的山脉数组](../../problems/valid-mountain-array) | [[数组](../array/README.md)] | Easy | +| 926 | [将字符串翻转到单调递增](../../problems/flip-string-to-monotone-increasing) | [[数组](../array/README.md)] | Medium | +| 922 | [按奇偶排序数组 II](../../problems/sort-array-by-parity-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 918 | [环形子数组的最大和](../../problems/maximum-sum-circular-subarray) | [[数组](../array/README.md)] | Medium | +| 915 | [分割数组](../../problems/partition-array-into-disjoint-intervals) | [[数组](../array/README.md)] | Medium | +| 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 907 | [子数组的最小值之和](../../problems/sum-of-subarray-minimums) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Medium | +| 905 | [按奇偶排序数组](../../problems/sort-array-by-parity) | [[数组](../array/README.md)] | Easy | +| 900 | [RLE 迭代器](../../problems/rle-iterator) | [[数组](../array/README.md)] | Medium | +| 896 | [单调数列](../../problems/monotonic-array) | [[数组](../array/README.md)] | Easy | +| 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 888 | [公平的糖果交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] | Easy | +| 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 867 | [转置矩阵](../../problems/transpose-matrix) | [[数组](../array/README.md)] | Easy | +| 849 | [到最近的人的最大距离](../../problems/maximize-distance-to-closest-person) | [[数组](../array/README.md)] | Easy | +| 840 | [矩阵中的幻方](../../problems/magic-squares-in-grid) | [[数组](../array/README.md)] | Easy | +| 835 | [图像重叠](../../problems/image-overlap) | [[数组](../array/README.md)] | Medium | +| 832 | [翻转图像](../../problems/flipping-an-image) | [[数组](../array/README.md)] | Easy | +| 830 | [较大分组的位置](../../problems/positions-of-large-groups) | [[数组](../array/README.md)] | Easy | +| 825 | [适龄的朋友](../../problems/friends-of-appropriate-ages) | [[数组](../array/README.md)] | Medium | +| 795 | [区间子数组个数](../../problems/number-of-subarrays-with-bounded-maximum) | [[数组](../array/README.md)] | Medium | +| 792 | [匹配子序列的单词数](../../problems/number-of-matching-subsequences) | [[数组](../array/README.md)] | Medium | +| 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 775 | [全局倒置与局部倒置](../../problems/global-and-local-inversions) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 769 | [最多能完成排序的块](../../problems/max-chunks-to-make-sorted) | [[数组](../array/README.md)] | Medium | +| 768 | [最多能完成排序的块 II](../../problems/max-chunks-to-make-sorted-ii) | [[数组](../array/README.md)] | Hard | +| 766 | [托普利茨矩阵](../../problems/toeplitz-matrix) | [[数组](../array/README.md)] | Easy | +| 755 | [倒水](../../problems/pour-water) 🔒 | [[数组](../array/README.md)] | Medium | +| 747 | [至少是其他数字两倍的最大数](../../problems/largest-number-at-least-twice-of-others) | [[数组](../array/README.md)] | Easy | +| 746 | [使用最小花费爬楼梯](../../problems/min-cost-climbing-stairs) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 729 | [我的日程安排表 I](../../problems/my-calendar-i) | [[数组](../array/README.md)] | Medium | +| 724 | [寻找数组的中心索引](../../problems/find-pivot-index) | [[数组](../array/README.md)] | Easy | +| 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 717 | [1比特与2比特字符](../../problems/1-bit-and-2-bit-characters) | [[数组](../array/README.md)] | Easy | +| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 697 | [数组的度](../../problems/degree-of-an-array) | [[数组](../array/README.md)] | Easy | +| 695 | [岛屿的最大面积](../../problems/max-area-of-island) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 689 | [三个无重叠子数组的最大和](../../problems/maximum-sum-of-3-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 674 | [最长连续递增序列](../../problems/longest-continuous-increasing-subsequence) | [[数组](../array/README.md)] | Easy | +| 670 | [最大交换](../../problems/maximum-swap) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 667 | [优美的排列 II](../../problems/beautiful-arrangement-ii) | [[数组](../array/README.md)] | Medium | +| 665 | [非递减数列](../../problems/non-decreasing-array) | [[数组](../array/README.md)] | Easy | +| 661 | [图片平滑器](../../problems/image-smoother) | [[数组](../array/README.md)] | Easy | +| 644 | [最大平均子段和 II](../../problems/maximum-average-subarray-ii) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 643 | [子数组最大平均数 I](../../problems/maximum-average-subarray-i) | [[数组](../array/README.md)] | Easy | +| 628 | [三个数的最大乘积](../../problems/maximum-product-of-three-numbers) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | +| 611 | [有效三角形的个数](../../problems/valid-triangle-number) | [[数组](../array/README.md)] | Medium | +| 605 | [种花问题](../../problems/can-place-flowers) | [[数组](../array/README.md)] | Easy | +| 581 | [最短无序连续子数组](../../problems/shortest-unsorted-continuous-subarray) | [[数组](../array/README.md)] | Easy | +| 566 | [重塑矩阵](../../problems/reshape-the-matrix) | [[数组](../array/README.md)] | Easy | +| 565 | [数组嵌套](../../problems/array-nesting) | [[数组](../array/README.md)] | Medium | +| 562 | [矩阵中最长的连续1线段](../../problems/longest-line-of-consecutive-one-in-matrix) 🔒 | [[数组](../array/README.md)] | Medium | +| 561 | [数组拆分 I](../../problems/array-partition-i) | [[数组](../array/README.md)] | Easy | +| 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 548 | [将数组分割成和相等的子数组](../../problems/split-array-with-equal-sum) 🔒 | [[数组](../array/README.md)] | Medium | +| 533 | [孤独像素 II](../../problems/lonely-pixel-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 532 | [数组中的K-diff数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 531 | [孤独像素 I](../../problems/lonely-pixel-i) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 509 | [斐波那契数](../../problems/fibonacci-number) | [[数组](../array/README.md)] | Easy | +| 495 | [提莫攻击](../../problems/teemo-attacking) | [[数组](../array/README.md)] | Medium | +| 485 | [最大连续1的个数](../../problems/max-consecutive-ones) | [[数组](../array/README.md)] | Easy | +| 457 | [环形数组循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 448 | [找到所有数组中消失的数字](../../problems/find-all-numbers-disappeared-in-an-array) | [[数组](../array/README.md)] | Easy | +| 442 | [数组中重复的数据](../../problems/find-all-duplicates-in-an-array) | [[数组](../array/README.md)] | Medium | +| 414 | [第三大的数](../../problems/third-maximum-number) | [[数组](../array/README.md)] | Easy | +| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 370 | [区间加法](../../problems/range-addition) 🔒 | [[数组](../array/README.md)] | Medium | +| 289 | [生命游戏](../../problems/game-of-life) | [[数组](../array/README.md)] | Medium | +| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 277 | [搜寻名人](../../problems/find-the-celebrity) 🔒 | [[数组](../array/README.md)] | Medium | +| 268 | [缺失数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 245 | [最短单词距离 III](../../problems/shortest-word-distance-iii) 🔒 | [[数组](../array/README.md)] | Medium | +| 243 | [最短单词距离](../../problems/shortest-word-distance) 🔒 | [[数组](../array/README.md)] | Easy | +| 238 | [除自身以外数组的乘积](../../problems/product-of-array-except-self) | [[数组](../array/README.md)] | Medium | +| 229 | [求众数 II](../../problems/majority-element-ii) | [[数组](../array/README.md)] | Medium | +| 228 | [汇总区间](../../problems/summary-ranges) | [[数组](../array/README.md)] | Medium | +| 219 | [存在重复元素 II](../../problems/contains-duplicate-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 217 | [存在重复元素](../../problems/contains-duplicate) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 189 | [旋转数组](../../problems/rotate-array) | [[数组](../array/README.md)] | Easy | +| 169 | [多数元素](../../problems/majority-element) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Easy | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 163 | [缺失的区间](../../problems/missing-ranges) 🔒 | [[数组](../array/README.md)] | Medium | +| 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 154 | [寻找旋转排序数组中的最小值 II](../../problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 152 | [乘积最大子序列](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 128 | [最长连续序列](../../problems/longest-consecutive-sequence) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Hard | +| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 123 | [买卖股票的最佳时机 III](../../problems/best-time-to-buy-and-sell-stock-iii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 121 | [买卖股票的最佳时机](../../problems/best-time-to-buy-and-sell-stock) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 120 | [三角形最小路径和](../../problems/triangle) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 119 | [杨辉三角 II](../../problems/pascals-triangle-ii) | [[数组](../array/README.md)] | Easy | +| 118 | [杨辉三角](../../problems/pascals-triangle) | [[数组](../array/README.md)] | Easy | +| 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 90 | [子集 II](../../problems/subsets-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 88 | [合并两个有序数组](../../problems/merge-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 84 | [柱状图中最大的矩形](../../problems/largest-rectangle-in-histogram) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Hard | +| 81 | [搜索旋转排序数组 II](../../problems/search-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 80 | [删除排序数组中的重复项 II](../../problems/remove-duplicates-from-sorted-array-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 79 | [单词搜索](../../problems/word-search) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 74 | [搜索二维矩阵](../../problems/search-a-2d-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 73 | [矩阵置零](../../problems/set-matrix-zeroes) | [[数组](../array/README.md)] | Medium | +| 66 | [加一](../../problems/plus-one) | [[数组](../array/README.md)] | Easy | +| 64 | [最小路径和](../../problems/minimum-path-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 63 | [不同路径 II](../../problems/unique-paths-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 62 | [不同路径](../../problems/unique-paths) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 59 | [螺旋矩阵 II](../../problems/spiral-matrix-ii) | [[数组](../array/README.md)] | Medium | +| 57 | [插入区间](../../problems/insert-interval) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Hard | +| 56 | [合并区间](../../problems/merge-intervals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 55 | [跳跃游戏](../../problems/jump-game) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 54 | [螺旋矩阵](../../problems/spiral-matrix) | [[数组](../array/README.md)] | Medium | +| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 48 | [旋转图像](../../problems/rotate-image) | [[数组](../array/README.md)] | Medium | +| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Hard | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Hard | +| 41 | [缺失的第一个正数](../../problems/first-missing-positive) | [[数组](../array/README.md)] | Hard | +| 40 | [组合总和 II](../../problems/combination-sum-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 39 | [组合总和](../../problems/combination-sum) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 35 | [搜索插入位置](../../problems/search-insert-position) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 34 | [在排序数组中查找元素的第一个和最后一个位置](../../problems/find-first-and-last-position-of-element-in-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 33 | [搜索旋转排序数组](../../problems/search-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 31 | [下一个排列](../../problems/next-permutation) | [[数组](../array/README.md)] | Medium | +| 27 | [移除元素](../../problems/remove-element) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 26 | [删除排序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 11 | [盛最多水的容器](../../problems/container-with-most-water) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 4 | [寻找两个有序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 1 | [两数之和](../../problems/two-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 762689aa3..27e81cf48 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -5,59 +5,59 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 回溯算法 +## [话题分类](../README.md) > 回溯算法 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1291 | [顺次数](https://github.com/openset/leetcode/tree/master/problems/sequential-digits) | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 1286 | [字母组合迭代器](https://github.com/openset/leetcode/tree/master/problems/iterator-for-combination) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 1258 | [近义词句子](https://github.com/openset/leetcode/tree/master/problems/synonymous-sentences) 🔒 | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 1240 | [铺瓷砖](https://github.com/openset/leetcode/tree/master/problems/tiling-a-rectangle-with-the-fewest-squares) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 1239 | [串联字符串的最大长度](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 1219 | [黄金矿工](https://github.com/openset/leetcode/tree/master/problems/path-with-maximum-gold) | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 1215 | [步进数](https://github.com/openset/leetcode/tree/master/problems/stepping-numbers) 🔒 | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 1088 | [易混淆数 II](https://github.com/openset/leetcode/tree/master/problems/confusing-number-ii) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 1087 | [字母切换](https://github.com/openset/leetcode/tree/master/problems/brace-expansion) 🔒 | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 1079 | [活字印刷](https://github.com/openset/leetcode/tree/master/problems/letter-tile-possibilities) | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 1066 | [校园自行车分配 II](https://github.com/openset/leetcode/tree/master/problems/campus-bikes-ii) 🔒 | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 996 | [正方形数组的数目](https://github.com/openset/leetcode/tree/master/problems/number-of-squareful-arrays) | [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 980 | [不同路径 III](https://github.com/openset/leetcode/tree/master/problems/unique-paths-iii) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 842 | [将数组拆分成斐波那契序列](https://github.com/openset/leetcode/tree/master/problems/split-array-into-fibonacci-sequence) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 784 | [字母大小写全排列](https://github.com/openset/leetcode/tree/master/problems/letter-case-permutation) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Easy | -| 691 | [贴纸拼词](https://github.com/openset/leetcode/tree/master/problems/stickers-to-spell-word) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 526 | [优美的排列](https://github.com/openset/leetcode/tree/master/problems/beautiful-arrangement) | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 425 | [单词方块](https://github.com/openset/leetcode/tree/master/problems/word-squares) 🔒 | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 411 | [最短特异单词缩写](https://github.com/openset/leetcode/tree/master/problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 401 | [二进制手表](https://github.com/openset/leetcode/tree/master/problems/binary-watch) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Easy | -| 357 | [计算各个位数不同的数字个数](https://github.com/openset/leetcode/tree/master/problems/count-numbers-with-unique-digits) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 351 | [安卓系统手势解锁](https://github.com/openset/leetcode/tree/master/problems/android-unlock-patterns) 🔒 | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 320 | [列举单词的全部缩写](https://github.com/openset/leetcode/tree/master/problems/generalized-abbreviation) 🔒 | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 306 | [累加数](https://github.com/openset/leetcode/tree/master/problems/additive-number) | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 294 | [翻转游戏 II](https://github.com/openset/leetcode/tree/master/problems/flip-game-ii) 🔒 | [[极小化极大](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 291 | [单词规律 II](https://github.com/openset/leetcode/tree/master/problems/word-pattern-ii) 🔒 | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 267 | [回文排列 II](https://github.com/openset/leetcode/tree/master/problems/palindrome-permutation-ii) 🔒 | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 254 | [因子的组合](https://github.com/openset/leetcode/tree/master/problems/factor-combinations) 🔒 | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 216 | [组合总和 III](https://github.com/openset/leetcode/tree/master/problems/combination-sum-iii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 212 | [单词搜索 II](https://github.com/openset/leetcode/tree/master/problems/word-search-ii) | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 211 | [添加与搜索单词 - 数据结构设计](https://github.com/openset/leetcode/tree/master/problems/add-and-search-word-data-structure-design) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 140 | [单词拆分 II](https://github.com/openset/leetcode/tree/master/problems/word-break-ii) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 131 | [分割回文串](https://github.com/openset/leetcode/tree/master/problems/palindrome-partitioning) | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 126 | [单词接龙 II](https://github.com/openset/leetcode/tree/master/problems/word-ladder-ii) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 93 | [复原IP地址](https://github.com/openset/leetcode/tree/master/problems/restore-ip-addresses) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 90 | [子集 II](https://github.com/openset/leetcode/tree/master/problems/subsets-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 89 | [格雷编码](https://github.com/openset/leetcode/tree/master/problems/gray-code) | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 79 | [单词搜索](https://github.com/openset/leetcode/tree/master/problems/word-search) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 78 | [子集](https://github.com/openset/leetcode/tree/master/problems/subsets) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 77 | [组合](https://github.com/openset/leetcode/tree/master/problems/combinations) | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 60 | [第k个排列](https://github.com/openset/leetcode/tree/master/problems/permutation-sequence) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 52 | [N皇后 II](https://github.com/openset/leetcode/tree/master/problems/n-queens-ii) | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 51 | [N皇后](https://github.com/openset/leetcode/tree/master/problems/n-queens) | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 47 | [全排列 II](https://github.com/openset/leetcode/tree/master/problems/permutations-ii) | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 46 | [全排列](https://github.com/openset/leetcode/tree/master/problems/permutations) | [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 44 | [通配符匹配](https://github.com/openset/leetcode/tree/master/problems/wildcard-matching) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 40 | [组合总和 II](https://github.com/openset/leetcode/tree/master/problems/combination-sum-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 39 | [组合总和](https://github.com/openset/leetcode/tree/master/problems/combination-sum) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 37 | [解数独](https://github.com/openset/leetcode/tree/master/problems/sudoku-solver) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 22 | [括号生成](https://github.com/openset/leetcode/tree/master/problems/generate-parentheses) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 17 | [电话号码的字母组合](https://github.com/openset/leetcode/tree/master/problems/letter-combinations-of-a-phone-number) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 10 | [正则表达式匹配](https://github.com/openset/leetcode/tree/master/problems/regular-expression-matching) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | +| 1291 | [顺次数](../../problems/sequential-digits) | [[回溯算法](../backtracking/README.md)] | Medium | +| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1258 | [近义词句子](../../problems/synonymous-sentences) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | +| 1240 | [铺瓷砖](../../problems/tiling-a-rectangle-with-the-fewest-squares) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1239 | [串联字符串的最大长度](../../problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1219 | [黄金矿工](../../problems/path-with-maximum-gold) | [[回溯算法](../backtracking/README.md)] | Medium | +| 1215 | [步进数](../../problems/stepping-numbers) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | +| 1088 | [易混淆数 II](../../problems/confusing-number-ii) 🔒 | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1087 | [字母切换](../../problems/brace-expansion) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | +| 1079 | [活字印刷](../../problems/letter-tile-possibilities) | [[回溯算法](../backtracking/README.md)] | Medium | +| 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 980 | [不同路径 III](../../problems/unique-paths-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | +| 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 526 | [优美的排列](../../problems/beautiful-arrangement) | [[回溯算法](../backtracking/README.md)] | Medium | +| 425 | [单词方块](../../problems/word-squares) 🔒 | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 411 | [最短特异单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 401 | [二进制手表](../../problems/binary-watch) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | +| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 351 | [安卓系统手势解锁](../../problems/android-unlock-patterns) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 306 | [累加数](../../problems/additive-number) | [[回溯算法](../backtracking/README.md)] | Medium | +| 294 | [翻转游戏 II](../../problems/flip-game-ii) 🔒 | [[极小化极大](../minimax/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 291 | [单词规律 II](../../problems/word-pattern-ii) 🔒 | [[回溯算法](../backtracking/README.md)] | Hard | +| 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | +| 254 | [因子的组合](../../problems/factor-combinations) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | +| 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/add-and-search-word-data-structure-design) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 140 | [单词拆分 II](../../problems/word-break-ii) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[回溯算法](../backtracking/README.md)] | Medium | +| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 93 | [复原IP地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 90 | [子集 II](../../problems/subsets-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 89 | [格雷编码](../../problems/gray-code) | [[回溯算法](../backtracking/README.md)] | Medium | +| 79 | [单词搜索](../../problems/word-search) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 77 | [组合](../../problems/combinations) | [[回溯算法](../backtracking/README.md)] | Medium | +| 60 | [第k个排列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 52 | [N皇后 II](../../problems/n-queens-ii) | [[回溯算法](../backtracking/README.md)] | Hard | +| 51 | [N皇后](../../problems/n-queens) | [[回溯算法](../backtracking/README.md)] | Hard | +| 47 | [全排列 II](../../problems/permutations-ii) | [[回溯算法](../backtracking/README.md)] | Medium | +| 46 | [全排列](../../problems/permutations) | [[回溯算法](../backtracking/README.md)] | Medium | +| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 40 | [组合总和 II](../../problems/combination-sum-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 39 | [组合总和](../../problems/combination-sum) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 37 | [解数独](../../problems/sudoku-solver) | [[哈希表](../hash-table/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/binary-indexed-tree/README.md b/tag/binary-indexed-tree/README.md index ad7125ff0..0038749bc 100644 --- a/tag/binary-indexed-tree/README.md +++ b/tag/binary-indexed-tree/README.md @@ -5,13 +5,13 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 树状数组 +## [话题分类](../README.md) > 树状数组 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 493 | [翻转对](https://github.com/openset/leetcode/tree/master/problems/reverse-pairs) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 327 | [区间和的个数](https://github.com/openset/leetcode/tree/master/problems/count-of-range-sum) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 315 | [计算右侧小于当前元素的个数](https://github.com/openset/leetcode/tree/master/problems/count-of-smaller-numbers-after-self) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 308 | [二维区域和检索 - 可变](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-2d-mutable) 🔒 | [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] | Hard | -| 307 | [区域和检索 - 数组可修改](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-mutable) | [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] | Medium | -| 218 | [天际线问题](https://github.com/openset/leetcode/tree/master/problems/the-skyline-problem) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] | Hard | +| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 308 | [二维区域和检索 - 可变](../../problems/range-sum-query-2d-mutable) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Hard | +| 307 | [区域和检索 - 数组可修改](../../problems/range-sum-query-mutable) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Medium | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/binary-search-tree/README.md b/tag/binary-search-tree/README.md index 5a01d10b4..42efd4da5 100644 --- a/tag/binary-search-tree/README.md +++ b/tag/binary-search-tree/README.md @@ -5,9 +5,9 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 二叉搜索树 +## [话题分类](../README.md) > 二叉搜索树 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1214 | [查找两棵二叉搜索树之和](https://github.com/openset/leetcode/tree/master/problems/two-sum-bsts) 🔒 | [[二叉搜索树](https://github.com/openset/leetcode/tree/master/tag/binary-search-tree/README.md)] | Medium | -| 1038 | [从二叉搜索树到更大和树](https://github.com/openset/leetcode/tree/master/problems/binary-search-tree-to-greater-sum-tree) | [[二叉搜索树](https://github.com/openset/leetcode/tree/master/tag/binary-search-tree/README.md)] | Medium | +| 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | +| 1038 | [从二叉搜索树到更大和树](../../problems/binary-search-tree-to-greater-sum-tree) | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index d3e79bc2e..e713cbd38 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -5,88 +5,88 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 二分查找 +## [话题分类](../README.md) > 二分查找 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1292 | [元素和小于等于阈值的正方形的最大边长](https://github.com/openset/leetcode/tree/master/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 1283 | [使结果不超过阈值的最小除数](https://github.com/openset/leetcode/tree/master/problems/find-the-smallest-divisor-given-a-threshold) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 1237 | [找出给定方程的正整数解](https://github.com/openset/leetcode/tree/master/problems/find-positive-integer-solution-for-a-given-equation) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 1235 | [规划兼职工作](https://github.com/openset/leetcode/tree/master/problems/maximum-profit-in-job-scheduling) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1231 | [分享巧克力](https://github.com/openset/leetcode/tree/master/problems/divide-chocolate) 🔒 | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 1201 | [丑数 III](https://github.com/openset/leetcode/tree/master/problems/ugly-number-iii) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 1198 | [找出所有行中最小公共元素](https://github.com/openset/leetcode/tree/master/problems/find-smallest-common-element-in-all-rows) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 1182 | [与目标颜色间的最短距离](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-to-target-color) 🔒 | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 1157 | [子数组中占绝大多数的元素](https://github.com/openset/leetcode/tree/master/problems/online-majority-element-in-subarray) | [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 1150 | [检查一个数是否在数组中占绝大多数](https://github.com/openset/leetcode/tree/master/problems/check-if-a-number-is-majority-element-in-a-sorted-array) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 1111 | [有效括号的嵌套深度](https://github.com/openset/leetcode/tree/master/problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 1095 | [山脉数组中查找目标值](https://github.com/openset/leetcode/tree/master/problems/find-in-mountain-array) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 1064 | [不动点](https://github.com/openset/leetcode/tree/master/problems/fixed-point) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 1060 | [有序数组中的缺失元素](https://github.com/openset/leetcode/tree/master/problems/missing-element-in-sorted-array) 🔒 | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 1044 | [最长重复子串](https://github.com/openset/leetcode/tree/master/problems/longest-duplicate-substring) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 1011 | [在 D 天内送达包裹的能力](https://github.com/openset/leetcode/tree/master/problems/capacity-to-ship-packages-within-d-days) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 981 | [基于时间的键值存储](https://github.com/openset/leetcode/tree/master/problems/time-based-key-value-store) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 927 | [三等分](https://github.com/openset/leetcode/tree/master/problems/three-equal-parts) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 911 | [在线选举](https://github.com/openset/leetcode/tree/master/problems/online-election) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 887 | [鸡蛋掉落](https://github.com/openset/leetcode/tree/master/problems/super-egg-drop) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 878 | [第 N 个神奇数字](https://github.com/openset/leetcode/tree/master/problems/nth-magical-number) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 875 | [爱吃香蕉的珂珂](https://github.com/openset/leetcode/tree/master/problems/koko-eating-bananas) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 862 | [和至少为 K 的最短子数组](https://github.com/openset/leetcode/tree/master/problems/shortest-subarray-with-sum-at-least-k) | [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 852 | [山脉数组的峰顶索引](https://github.com/openset/leetcode/tree/master/problems/peak-index-in-a-mountain-array) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 793 | [阶乘函数后K个零](https://github.com/openset/leetcode/tree/master/problems/preimage-size-of-factorial-zeroes-function) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 786 | [第 K 个最小的素数分数](https://github.com/openset/leetcode/tree/master/problems/k-th-smallest-prime-fraction) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 778 | [水位上升的泳池中游泳](https://github.com/openset/leetcode/tree/master/problems/swim-in-rising-water) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 774 | [最小化去加油站的最大距离](https://github.com/openset/leetcode/tree/master/problems/minimize-max-distance-to-gas-station) 🔒 | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 744 | [寻找比目标字母大的最小字母](https://github.com/openset/leetcode/tree/master/problems/find-smallest-letter-greater-than-target) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 719 | [找出第 k 小的距离对](https://github.com/openset/leetcode/tree/master/problems/find-k-th-smallest-pair-distance) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 718 | [最长重复子数组](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-repeated-subarray) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 710 | [黑名单中的随机数](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-blacklist) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] | Hard | -| 704 | [二分查找](https://github.com/openset/leetcode/tree/master/problems/binary-search) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 702 | [搜索长度未知的有序数组](https://github.com/openset/leetcode/tree/master/problems/search-in-a-sorted-array-of-unknown-size) 🔒 | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 668 | [乘法表中第k小的数](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-number-in-multiplication-table) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 658 | [找到 K 个最接近的元素](https://github.com/openset/leetcode/tree/master/problems/find-k-closest-elements) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 644 | [最大平均子段和 II](https://github.com/openset/leetcode/tree/master/problems/maximum-average-subarray-ii) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 528 | [按权重随机选择](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-weight) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] | Medium | -| 497 | [非重叠矩形中的随机点](https://github.com/openset/leetcode/tree/master/problems/random-point-in-non-overlapping-rectangles) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] | Medium | -| 493 | [翻转对](https://github.com/openset/leetcode/tree/master/problems/reverse-pairs) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 483 | [最小好进制](https://github.com/openset/leetcode/tree/master/problems/smallest-good-base) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 475 | [供暖器](https://github.com/openset/leetcode/tree/master/problems/heaters) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 454 | [四数相加 II](https://github.com/openset/leetcode/tree/master/problems/4sum-ii) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 441 | [排列硬币](https://github.com/openset/leetcode/tree/master/problems/arranging-coins) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 436 | [寻找右区间](https://github.com/openset/leetcode/tree/master/problems/find-right-interval) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 410 | [分割数组的最大值](https://github.com/openset/leetcode/tree/master/problems/split-array-largest-sum) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 392 | [判断子序列](https://github.com/openset/leetcode/tree/master/problems/is-subsequence) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Easy | -| 378 | [有序矩阵中第K小的元素](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-element-in-a-sorted-matrix) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 374 | [猜数字大小](https://github.com/openset/leetcode/tree/master/problems/guess-number-higher-or-lower) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 367 | [有效的完全平方数](https://github.com/openset/leetcode/tree/master/problems/valid-perfect-square) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 363 | [矩形区域不超过 K 的最大数值和](https://github.com/openset/leetcode/tree/master/problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 354 | [俄罗斯套娃信封问题](https://github.com/openset/leetcode/tree/master/problems/russian-doll-envelopes) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 352 | [将数据流变为多个不相交区间](https://github.com/openset/leetcode/tree/master/problems/data-stream-as-disjoint-intervals) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] | Hard | -| 350 | [两个数组的交集 II](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays-ii) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 327 | [区间和的个数](https://github.com/openset/leetcode/tree/master/problems/count-of-range-sum) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 315 | [计算右侧小于当前元素的个数](https://github.com/openset/leetcode/tree/master/problems/count-of-smaller-numbers-after-self) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 302 | [包含全部黑色像素的最小矩形](https://github.com/openset/leetcode/tree/master/problems/smallest-rectangle-enclosing-black-pixels) 🔒 | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 300 | [最长上升子序列](https://github.com/openset/leetcode/tree/master/problems/longest-increasing-subsequence) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 287 | [寻找重复数](https://github.com/openset/leetcode/tree/master/problems/find-the-duplicate-number) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 278 | [第一个错误的版本](https://github.com/openset/leetcode/tree/master/problems/first-bad-version) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 275 | [H指数 II](https://github.com/openset/leetcode/tree/master/problems/h-index-ii) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 270 | [最接近的二叉搜索树值](https://github.com/openset/leetcode/tree/master/problems/closest-binary-search-tree-value) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 240 | [搜索二维矩阵 II](https://github.com/openset/leetcode/tree/master/problems/search-a-2d-matrix-ii) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Medium | -| 230 | [二叉搜索树中第K小的元素](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-element-in-a-bst) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 222 | [完全二叉树的节点个数](https://github.com/openset/leetcode/tree/master/problems/count-complete-tree-nodes) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 209 | [长度最小的子数组](https://github.com/openset/leetcode/tree/master/problems/minimum-size-subarray-sum) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 174 | [地下城游戏](https://github.com/openset/leetcode/tree/master/problems/dungeon-game) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 167 | [两数之和 II - 输入有序数组](https://github.com/openset/leetcode/tree/master/problems/two-sum-ii-input-array-is-sorted) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 162 | [寻找峰值](https://github.com/openset/leetcode/tree/master/problems/find-peak-element) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 154 | [寻找旋转排序数组中的最小值 II](https://github.com/openset/leetcode/tree/master/problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 153 | [寻找旋转排序数组中的最小值](https://github.com/openset/leetcode/tree/master/problems/find-minimum-in-rotated-sorted-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 81 | [搜索旋转排序数组 II](https://github.com/openset/leetcode/tree/master/problems/search-in-rotated-sorted-array-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 74 | [搜索二维矩阵](https://github.com/openset/leetcode/tree/master/problems/search-a-2d-matrix) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 69 | [x 的平方根](https://github.com/openset/leetcode/tree/master/problems/sqrtx) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 50 | [Pow(x, n)](https://github.com/openset/leetcode/tree/master/problems/powx-n) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 35 | [搜索插入位置](https://github.com/openset/leetcode/tree/master/problems/search-insert-position) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 34 | [在排序数组中查找元素的第一个和最后一个位置](https://github.com/openset/leetcode/tree/master/problems/find-first-and-last-position-of-element-in-sorted-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 33 | [搜索旋转排序数组](https://github.com/openset/leetcode/tree/master/problems/search-in-rotated-sorted-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 29 | [两数相除](https://github.com/openset/leetcode/tree/master/problems/divide-two-integers) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 4 | [寻找两个有序数组的中位数](https://github.com/openset/leetcode/tree/master/problems/median-of-two-sorted-arrays) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | +| 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1283 | [使结果不超过阈值的最小除数](../../problems/find-the-smallest-divisor-given-a-threshold) | [[二分查找](../binary-search/README.md)] | Medium | +| 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1231 | [分享巧克力](../../problems/divide-chocolate) 🔒 | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1182 | [与目标颜色间的最短距离](../../problems/shortest-distance-to-target-color) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | +| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1150 | [检查一个数是否在数组中占绝大多数](../../problems/check-if-a-number-is-majority-element-in-a-sorted-array) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1111 | [有效括号的嵌套深度](../../problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1095 | [山脉数组中查找目标值](../../problems/find-in-mountain-array) | [[二分查找](../binary-search/README.md)] | Hard | +| 1064 | [不动点](../../problems/fixed-point) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1060 | [有序数组中的缺失元素](../../problems/missing-element-in-sorted-array) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | +| 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1011 | [在 D 天内送达包裹的能力](../../problems/capacity-to-ship-packages-within-d-days) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 911 | [在线选举](../../problems/online-election) | [[二分查找](../binary-search/README.md)] | Medium | +| 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 878 | [第 N 个神奇数字](../../problems/nth-magical-number) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 875 | [爱吃香蕉的珂珂](../../problems/koko-eating-bananas) | [[二分查找](../binary-search/README.md)] | Medium | +| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 852 | [山脉数组的峰顶索引](../../problems/peak-index-in-a-mountain-array) | [[二分查找](../binary-search/README.md)] | Easy | +| 793 | [阶乘函数后K个零](../../problems/preimage-size-of-factorial-zeroes-function) | [[二分查找](../binary-search/README.md)] | Hard | +| 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 774 | [最小化去加油站的最大距离](../../problems/minimize-max-distance-to-gas-station) 🔒 | [[二分查找](../binary-search/README.md)] | Hard | +| 744 | [寻找比目标字母大的最小字母](../../problems/find-smallest-letter-greater-than-target) | [[二分查找](../binary-search/README.md)] | Easy | +| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | +| 704 | [二分查找](../../problems/binary-search) | [[二分查找](../binary-search/README.md)] | Easy | +| 702 | [搜索长度未知的有序数组](../../problems/search-in-a-sorted-array-of-unknown-size) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | +| 668 | [乘法表中第k小的数](../../problems/kth-smallest-number-in-multiplication-table) | [[二分查找](../binary-search/README.md)] | Hard | +| 658 | [找到 K 个最接近的元素](../../problems/find-k-closest-elements) | [[二分查找](../binary-search/README.md)] | Medium | +| 644 | [最大平均子段和 II](../../problems/maximum-average-subarray-ii) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | +| 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | +| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 483 | [最小好进制](../../problems/smallest-good-base) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 475 | [供暖器](../../problems/heaters) | [[二分查找](../binary-search/README.md)] | Easy | +| 454 | [四数相加 II](../../problems/4sum-ii) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 441 | [排列硬币](../../problems/arranging-coins) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 436 | [寻找右区间](../../problems/find-right-interval) | [[二分查找](../binary-search/README.md)] | Medium | +| 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 378 | [有序矩阵中第K小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 374 | [猜数字大小](../../problems/guess-number-higher-or-lower) | [[二分查找](../binary-search/README.md)] | Easy | +| 367 | [有效的完全平方数](../../problems/valid-perfect-square) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 354 | [俄罗斯套娃信封问题](../../problems/russian-doll-envelopes) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 302 | [包含全部黑色像素的最小矩形](../../problems/smallest-rectangle-enclosing-black-pixels) 🔒 | [[二分查找](../binary-search/README.md)] | Hard | +| 300 | [最长上升子序列](../../problems/longest-increasing-subsequence) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 278 | [第一个错误的版本](../../problems/first-bad-version) | [[二分查找](../binary-search/README.md)] | Easy | +| 275 | [H指数 II](../../problems/h-index-ii) | [[二分查找](../binary-search/README.md)] | Medium | +| 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 230 | [二叉搜索树中第K小的元素](../../problems/kth-smallest-element-in-a-bst) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 174 | [地下城游戏](../../problems/dungeon-game) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 154 | [寻找旋转排序数组中的最小值 II](../../problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 81 | [搜索旋转排序数组 II](../../problems/search-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 74 | [搜索二维矩阵](../../problems/search-a-2d-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 69 | [x 的平方根](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 50 | [Pow(x, n)](../../problems/powx-n) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 35 | [搜索插入位置](../../problems/search-insert-position) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 34 | [在排序数组中查找元素的第一个和最后一个位置](../../problems/find-first-and-last-position-of-element-in-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 33 | [搜索旋转排序数组](../../problems/search-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 29 | [两数相除](../../problems/divide-two-integers) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 4 | [寻找两个有序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index a410fb011..b33bb8c94 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -5,46 +5,46 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 位运算 +## [话题分类](../README.md) > 位运算 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1290 | [二进制链表转整数](https://github.com/openset/leetcode/tree/master/problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Easy | -| 1256 | [加密数字](https://github.com/openset/leetcode/tree/master/problems/encode-number) 🔒 | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 1255 | [得分最高的单词集合](https://github.com/openset/leetcode/tree/master/problems/maximum-score-words-formed-by-letters) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Hard | -| 1239 | [串联字符串的最大长度](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 1178 | [猜字谜](https://github.com/openset/leetcode/tree/master/problems/number-of-valid-words-for-each-puzzle) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Hard | -| 1131 | [绝对值表达式的最大值](https://github.com/openset/leetcode/tree/master/problems/maximum-of-absolute-value-expression) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 1125 | [最小的必要团队](https://github.com/openset/leetcode/tree/master/problems/smallest-sufficient-team) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 898 | [子数组按位或操作](https://github.com/openset/leetcode/tree/master/problems/bitwise-ors-of-subarrays) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 784 | [字母大小写全排列](https://github.com/openset/leetcode/tree/master/problems/letter-case-permutation) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Easy | -| 762 | [二进制表示中质数个计算置位](https://github.com/openset/leetcode/tree/master/problems/prime-number-of-set-bits-in-binary-representation) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Easy | -| 756 | [金字塔转换矩阵](https://github.com/openset/leetcode/tree/master/problems/pyramid-transition-matrix) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 751 | [IP 到 CIDR](https://github.com/openset/leetcode/tree/master/problems/ip-to-cidr) 🔒 | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Easy | -| 693 | [交替位二进制数](https://github.com/openset/leetcode/tree/master/problems/binary-number-with-alternating-bits) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Easy | -| 477 | [汉明距离总和](https://github.com/openset/leetcode/tree/master/problems/total-hamming-distance) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Medium | -| 476 | [数字的补数](https://github.com/openset/leetcode/tree/master/problems/number-complement) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Easy | -| 461 | [汉明距离](https://github.com/openset/leetcode/tree/master/problems/hamming-distance) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Easy | -| 421 | [数组中两个数的最大异或值](https://github.com/openset/leetcode/tree/master/problems/maximum-xor-of-two-numbers-in-an-array) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] | Medium | -| 411 | [最短特异单词缩写](https://github.com/openset/leetcode/tree/master/problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 405 | [数字转换为十六进制数](https://github.com/openset/leetcode/tree/master/problems/convert-a-number-to-hexadecimal) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Easy | -| 401 | [二进制手表](https://github.com/openset/leetcode/tree/master/problems/binary-watch) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Easy | -| 397 | [整数替换](https://github.com/openset/leetcode/tree/master/problems/integer-replacement) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 393 | [UTF-8 编码验证](https://github.com/openset/leetcode/tree/master/problems/utf-8-validation) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Medium | -| 389 | [找不同](https://github.com/openset/leetcode/tree/master/problems/find-the-difference) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 371 | [两整数之和](https://github.com/openset/leetcode/tree/master/problems/sum-of-two-integers) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Easy | -| 342 | [4的幂](https://github.com/openset/leetcode/tree/master/problems/power-of-four) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Easy | -| 338 | [比特位计数](https://github.com/openset/leetcode/tree/master/problems/counting-bits) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 320 | [列举单词的全部缩写](https://github.com/openset/leetcode/tree/master/problems/generalized-abbreviation) 🔒 | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 318 | [最大单词长度乘积](https://github.com/openset/leetcode/tree/master/problems/maximum-product-of-word-lengths) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Medium | -| 268 | [缺失数字](https://github.com/openset/leetcode/tree/master/problems/missing-number) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 260 | [只出现一次的数字 III](https://github.com/openset/leetcode/tree/master/problems/single-number-iii) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Medium | -| 231 | [2的幂](https://github.com/openset/leetcode/tree/master/problems/power-of-two) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 201 | [数字范围按位与](https://github.com/openset/leetcode/tree/master/problems/bitwise-and-of-numbers-range) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Medium | -| 191 | [位1的个数](https://github.com/openset/leetcode/tree/master/problems/number-of-1-bits) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Easy | -| 190 | [颠倒二进制位](https://github.com/openset/leetcode/tree/master/problems/reverse-bits) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Easy | -| 187 | [重复的DNA序列](https://github.com/openset/leetcode/tree/master/problems/repeated-dna-sequences) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 169 | [多数元素](https://github.com/openset/leetcode/tree/master/problems/majority-element) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Easy | -| 137 | [只出现一次的数字 II](https://github.com/openset/leetcode/tree/master/problems/single-number-ii) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Medium | -| 136 | [只出现一次的数字](https://github.com/openset/leetcode/tree/master/problems/single-number) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 78 | [子集](https://github.com/openset/leetcode/tree/master/problems/subsets) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | +| 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)] | Easy | +| 1256 | [加密数字](../../problems/encode-number) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | +| 1255 | [得分最高的单词集合](../../problems/maximum-score-words-formed-by-letters) | [[位运算](../bit-manipulation/README.md)] | Hard | +| 1239 | [串联字符串的最大长度](../../problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1178 | [猜字谜](../../problems/number-of-valid-words-for-each-puzzle) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 1131 | [绝对值表达式的最大值](../../problems/maximum-of-absolute-value-expression) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | +| 1125 | [最小的必要团队](../../problems/smallest-sufficient-team) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 898 | [子数组按位或操作](../../problems/bitwise-ors-of-subarrays) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | +| 762 | [二进制表示中质数个计算置位](../../problems/prime-number-of-set-bits-in-binary-representation) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 756 | [金字塔转换矩阵](../../problems/pyramid-transition-matrix) | [[位运算](../bit-manipulation/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 751 | [IP 到 CIDR](../../problems/ip-to-cidr) 🔒 | [[位运算](../bit-manipulation/README.md)] | Easy | +| 693 | [交替位二进制数](../../problems/binary-number-with-alternating-bits) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 477 | [汉明距离总和](../../problems/total-hamming-distance) | [[位运算](../bit-manipulation/README.md)] | Medium | +| 476 | [数字的补数](../../problems/number-complement) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 461 | [汉明距离](../../problems/hamming-distance) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 421 | [数组中两个数的最大异或值](../../problems/maximum-xor-of-two-numbers-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Medium | +| 411 | [最短特异单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 405 | [数字转换为十六进制数](../../problems/convert-a-number-to-hexadecimal) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 401 | [二进制手表](../../problems/binary-watch) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | +| 397 | [整数替换](../../problems/integer-replacement) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | +| 393 | [UTF-8 编码验证](../../problems/utf-8-validation) | [[位运算](../bit-manipulation/README.md)] | Medium | +| 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 371 | [两整数之和](../../problems/sum-of-two-integers) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 342 | [4的幂](../../problems/power-of-four) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 318 | [最大单词长度乘积](../../problems/maximum-product-of-word-lengths) | [[位运算](../bit-manipulation/README.md)] | Medium | +| 268 | [缺失数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 260 | [只出现一次的数字 III](../../problems/single-number-iii) | [[位运算](../bit-manipulation/README.md)] | Medium | +| 231 | [2的幂](../../problems/power-of-two) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | +| 201 | [数字范围按位与](../../problems/bitwise-and-of-numbers-range) | [[位运算](../bit-manipulation/README.md)] | Medium | +| 191 | [位1的个数](../../problems/number-of-1-bits) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 190 | [颠倒二进制位](../../problems/reverse-bits) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 187 | [重复的DNA序列](../../problems/repeated-dna-sequences) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 169 | [多数元素](../../problems/majority-element) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Easy | +| 137 | [只出现一次的数字 II](../../problems/single-number-ii) | [[位运算](../bit-manipulation/README.md)] | Medium | +| 136 | [只出现一次的数字](../../problems/single-number) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/brainteaser/README.md b/tag/brainteaser/README.md index 279f180a2..9ca15357a 100644 --- a/tag/brainteaser/README.md +++ b/tag/brainteaser/README.md @@ -5,12 +5,12 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 脑筋急转弯 +## [话题分类](../README.md) > 脑筋急转弯 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1227 | [飞机座位分配概率](https://github.com/openset/leetcode/tree/master/problems/airplane-seat-assignment-probability) | [[脑筋急转弯](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1033 | [移动石子直到连续](https://github.com/openset/leetcode/tree/master/problems/moving-stones-until-consecutive) | [[脑筋急转弯](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md)] | Easy | -| 777 | [在LR字符串中交换相邻字符](https://github.com/openset/leetcode/tree/master/problems/swap-adjacent-in-lr-string) | [[脑筋急转弯](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md)] | Medium | -| 319 | [灯泡开关](https://github.com/openset/leetcode/tree/master/problems/bulb-switcher) | [[脑筋急转弯](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 292 | [Nim 游戏](https://github.com/openset/leetcode/tree/master/problems/nim-game) | [[脑筋急转弯](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md)] [[极小化极大](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] | Easy | +| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1033 | [移动石子直到连续](../../problems/moving-stones-until-consecutive) | [[脑筋急转弯](../brainteaser/README.md)] | Easy | +| 777 | [在LR字符串中交换相邻字符](../../problems/swap-adjacent-in-lr-string) | [[脑筋急转弯](../brainteaser/README.md)] | Medium | +| 319 | [灯泡开关](../../problems/bulb-switcher) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Medium | +| 292 | [Nim 游戏](../../problems/nim-game) | [[脑筋急转弯](../brainteaser/README.md)] [[极小化极大](../minimax/README.md)] | Easy | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 5e76fd0c6..cc761a19f 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -5,67 +5,67 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 广度优先搜索 +## [话题分类](../README.md) > 广度优先搜索 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1293 | [网格中的最短路径](https://github.com/openset/leetcode/tree/master/problems/shortest-path-in-a-grid-with-obstacles-elimination) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | -| 1284 | [转化为全零矩阵的最少反转次数](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | -| 1263 | [推箱子](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-move-a-box-to-their-target-location) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | -| 1245 | [树的直径](https://github.com/openset/leetcode/tree/master/problems/tree-diameter) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 1242 | [多线程网页爬虫](https://github.com/openset/leetcode/tree/master/problems/web-crawler-multithreaded) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 1236 | [Web Crawler](https://github.com/openset/leetcode/tree/master/problems/web-crawler) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 1210 | [穿过迷宫的最少移动次数](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-reach-target-with-rotations) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | -| 1197 | [进击的骑士](https://github.com/openset/leetcode/tree/master/problems/minimum-knight-moves) 🔒 | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 1162 | [地图分析](https://github.com/openset/leetcode/tree/master/problems/as-far-from-land-as-possible) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 1129 | [颜色交替的最短路径](https://github.com/openset/leetcode/tree/master/problems/shortest-path-with-alternating-colors) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 1091 | [二进制矩阵中的最短路径](https://github.com/openset/leetcode/tree/master/problems/shortest-path-in-binary-matrix) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 1036 | [逃离大迷宫](https://github.com/openset/leetcode/tree/master/problems/escape-a-large-maze) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | -| 994 | [腐烂的橘子](https://github.com/openset/leetcode/tree/master/problems/rotting-oranges) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Easy | -| 993 | [二叉树的堂兄弟节点](https://github.com/openset/leetcode/tree/master/problems/cousins-in-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Easy | -| 934 | [最短的桥](https://github.com/openset/leetcode/tree/master/problems/shortest-bridge) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 913 | [猫和老鼠](https://github.com/openset/leetcode/tree/master/problems/cat-and-mouse) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[极小化极大](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] | Hard | -| 909 | [蛇梯棋](https://github.com/openset/leetcode/tree/master/problems/snakes-and-ladders) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 864 | [获取所有钥匙的最短路径](https://github.com/openset/leetcode/tree/master/problems/shortest-path-to-get-all-keys) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | -| 863 | [二叉树中所有距离为 K 的结点](https://github.com/openset/leetcode/tree/master/problems/all-nodes-distance-k-in-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 854 | [相似度为 K 的字符串](https://github.com/openset/leetcode/tree/master/problems/k-similar-strings) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Hard | -| 847 | [访问所有节点的最短路径](https://github.com/openset/leetcode/tree/master/problems/shortest-path-visiting-all-nodes) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 815 | [公交路线](https://github.com/openset/leetcode/tree/master/problems/bus-routes) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | -| 787 | [K 站中转内最便宜的航班](https://github.com/openset/leetcode/tree/master/problems/cheapest-flights-within-k-stops) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 785 | [判断二分图](https://github.com/openset/leetcode/tree/master/problems/is-graph-bipartite) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 773 | [滑动谜题](https://github.com/openset/leetcode/tree/master/problems/sliding-puzzle) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | -| 752 | [打开转盘锁](https://github.com/openset/leetcode/tree/master/problems/open-the-lock) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 743 | [网络延迟时间](https://github.com/openset/leetcode/tree/master/problems/network-delay-time) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 690 | [员工的重要性](https://github.com/openset/leetcode/tree/master/problems/employee-importance) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 675 | [为高尔夫比赛砍树](https://github.com/openset/leetcode/tree/master/problems/cut-off-trees-for-golf-event) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | -| 559 | [N叉树的最大深度](https://github.com/openset/leetcode/tree/master/problems/maximum-depth-of-n-ary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Easy | -| 542 | [01 矩阵](https://github.com/openset/leetcode/tree/master/problems/01-matrix) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 529 | [扫雷游戏](https://github.com/openset/leetcode/tree/master/problems/minesweeper) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 515 | [在每个树行中找最大值](https://github.com/openset/leetcode/tree/master/problems/find-largest-value-in-each-tree-row) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 513 | [找树左下角的值](https://github.com/openset/leetcode/tree/master/problems/find-bottom-left-tree-value) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 505 | [迷宫 II](https://github.com/openset/leetcode/tree/master/problems/the-maze-ii) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 499 | [迷宫 III](https://github.com/openset/leetcode/tree/master/problems/the-maze-iii) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | -| 490 | [迷宫](https://github.com/openset/leetcode/tree/master/problems/the-maze) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 429 | [N叉树的层序遍历](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-level-order-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 417 | [太平洋大西洋水流问题](https://github.com/openset/leetcode/tree/master/problems/pacific-atlantic-water-flow) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 407 | [接雨水 II](https://github.com/openset/leetcode/tree/master/problems/trapping-rain-water-ii) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | -| 323 | [无向图中连通分量的数目](https://github.com/openset/leetcode/tree/master/problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 317 | [离建筑物最近的距离](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-from-all-buildings) 🔒 | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | -| 310 | [最小高度树](https://github.com/openset/leetcode/tree/master/problems/minimum-height-trees) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 301 | [删除无效的括号](https://github.com/openset/leetcode/tree/master/problems/remove-invalid-parentheses) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | -| 286 | [墙与门](https://github.com/openset/leetcode/tree/master/problems/walls-and-gates) 🔒 | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 279 | [完全平方数](https://github.com/openset/leetcode/tree/master/problems/perfect-squares) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 261 | [以图判树](https://github.com/openset/leetcode/tree/master/problems/graph-valid-tree) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 210 | [课程表 II](https://github.com/openset/leetcode/tree/master/problems/course-schedule-ii) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] | Medium | -| 207 | [课程表](https://github.com/openset/leetcode/tree/master/problems/course-schedule) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] | Medium | -| 200 | [岛屿数量](https://github.com/openset/leetcode/tree/master/problems/number-of-islands) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Medium | -| 199 | [二叉树的右视图](https://github.com/openset/leetcode/tree/master/problems/binary-tree-right-side-view) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 133 | [克隆图](https://github.com/openset/leetcode/tree/master/problems/clone-graph) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 130 | [被围绕的区域](https://github.com/openset/leetcode/tree/master/problems/surrounded-regions) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Medium | -| 127 | [单词接龙](https://github.com/openset/leetcode/tree/master/problems/word-ladder) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 126 | [单词接龙 II](https://github.com/openset/leetcode/tree/master/problems/word-ladder-ii) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 111 | [二叉树的最小深度](https://github.com/openset/leetcode/tree/master/problems/minimum-depth-of-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Easy | -| 107 | [二叉树的层次遍历 II](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal-ii) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Easy | -| 103 | [二叉树的锯齿形层次遍历](https://github.com/openset/leetcode/tree/master/problems/binary-tree-zigzag-level-order-traversal) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 102 | [二叉树的层次遍历](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 101 | [对称二叉树](https://github.com/openset/leetcode/tree/master/problems/symmetric-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Easy | +| 1293 | [网格中的最短路径](../../problems/shortest-path-in-a-grid-with-obstacles-elimination) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1284 | [转化为全零矩阵的最少反转次数](../../problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1263 | [推箱子](../../problems/minimum-moves-to-move-a-box-to-their-target-location) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1242 | [多线程网页爬虫](../../problems/web-crawler-multithreaded) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1236 | [Web Crawler](../../problems/web-crawler) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1210 | [穿过迷宫的最少移动次数](../../problems/minimum-moves-to-reach-target-with-rotations) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1197 | [进击的骑士](../../problems/minimum-knight-moves) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1091 | [二进制矩阵中的最短路径](../../problems/shortest-path-in-binary-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 994 | [腐烂的橘子](../../problems/rotting-oranges) | [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[极小化极大](../minimax/README.md)] | Hard | +| 909 | [蛇梯棋](../../problems/snakes-and-ladders) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 864 | [获取所有钥匙的最短路径](../../problems/shortest-path-to-get-all-keys) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 854 | [相似度为 K 的字符串](../../problems/k-similar-strings) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Hard | +| 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 773 | [滑动谜题](../../problems/sliding-puzzle) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 675 | [为高尔夫比赛砍树](../../problems/cut-off-trees-for-golf-event) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 559 | [N叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 542 | [01 矩阵](../../problems/01-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 529 | [扫雷游戏](../../problems/minesweeper) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 505 | [迷宫 II](../../problems/the-maze-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 499 | [迷宫 III](../../problems/the-maze-iii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 490 | [迷宫](../../problems/the-maze) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 429 | [N叉树的层序遍历](../../problems/n-ary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 417 | [太平洋大西洋水流问题](../../problems/pacific-atlantic-water-flow) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 317 | [离建筑物最近的距离](../../problems/shortest-distance-from-all-buildings) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 310 | [最小高度树](../../problems/minimum-height-trees) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 301 | [删除无效的括号](../../problems/remove-invalid-parentheses) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 286 | [墙与门](../../problems/walls-and-gates) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 127 | [单词接龙](../../problems/word-ladder) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 107 | [二叉树的层次遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 103 | [二叉树的锯齿形层次遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 102 | [二叉树的层次遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index c2ea6715c..f48d651a0 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -5,121 +5,121 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 深度优先搜索 +## [话题分类](../README.md) > 深度优先搜索 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1273 | [删除树节点](https://github.com/openset/leetcode/tree/master/problems/delete-tree-nodes) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1254 | [统计封闭岛屿的数目](https://github.com/openset/leetcode/tree/master/problems/number-of-closed-islands) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 1245 | [树的直径](https://github.com/openset/leetcode/tree/master/problems/tree-diameter) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 1242 | [多线程网页爬虫](https://github.com/openset/leetcode/tree/master/problems/web-crawler-multithreaded) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 1236 | [Web Crawler](https://github.com/openset/leetcode/tree/master/problems/web-crawler) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 1203 | [项目管理](https://github.com/openset/leetcode/tree/master/problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] | Hard | -| 1192 | [查找集群内的「关键连接」](https://github.com/openset/leetcode/tree/master/problems/critical-connections-in-a-network) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Hard | -| 1145 | [二叉树着色游戏](https://github.com/openset/leetcode/tree/master/problems/binary-tree-coloring-game) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 1136 | [平行课程](https://github.com/openset/leetcode/tree/master/problems/parallel-courses) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1123 | [最深叶节点的最近公共祖先](https://github.com/openset/leetcode/tree/master/problems/lowest-common-ancestor-of-deepest-leaves) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 1110 | [删点成林](https://github.com/openset/leetcode/tree/master/problems/delete-nodes-and-return-forest) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 1102 | [得分最高的路径](https://github.com/openset/leetcode/tree/master/problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 1080 | [根到叶路径上的不足节点](https://github.com/openset/leetcode/tree/master/problems/insufficient-nodes-in-root-to-leaf-paths) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 1061 | [按字典序排列最小的等效字符串](https://github.com/openset/leetcode/tree/master/problems/lexicographically-smallest-equivalent-string) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Medium | -| 1059 | [从始点到终点的所有路径](https://github.com/openset/leetcode/tree/master/problems/all-paths-from-source-lead-to-destination) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 1034 | [边框着色](https://github.com/openset/leetcode/tree/master/problems/coloring-a-border) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 1028 | [从先序遍历还原二叉树](https://github.com/openset/leetcode/tree/master/problems/recover-a-tree-from-preorder-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Hard | -| 1026 | [节点与其祖先之间的最大差值](https://github.com/openset/leetcode/tree/master/problems/maximum-difference-between-node-and-ancestor) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 1020 | [飞地的数量](https://github.com/openset/leetcode/tree/master/problems/number-of-enclaves) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 988 | [从叶结点开始的最小字符串](https://github.com/openset/leetcode/tree/master/problems/smallest-string-starting-from-leaf) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 980 | [不同路径 III](https://github.com/openset/leetcode/tree/master/problems/unique-paths-iii) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 979 | [在二叉树中分配硬币](https://github.com/openset/leetcode/tree/master/problems/distribute-coins-in-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 971 | [翻转二叉树以匹配先序遍历](https://github.com/openset/leetcode/tree/master/problems/flip-binary-tree-to-match-preorder-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 968 | [监控二叉树](https://github.com/openset/leetcode/tree/master/problems/binary-tree-cameras) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 959 | [由斜杠划分区域](https://github.com/openset/leetcode/tree/master/problems/regions-cut-by-slashes) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 947 | [移除最多的同行或同列石头](https://github.com/openset/leetcode/tree/master/problems/most-stones-removed-with-same-row-or-column) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Medium | -| 934 | [最短的桥](https://github.com/openset/leetcode/tree/master/problems/shortest-bridge) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 928 | [尽量减少恶意软件的传播 II](https://github.com/openset/leetcode/tree/master/problems/minimize-malware-spread-ii) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Hard | -| 924 | [尽量减少恶意软件的传播](https://github.com/openset/leetcode/tree/master/problems/minimize-malware-spread) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Hard | -| 897 | [递增顺序查找树](https://github.com/openset/leetcode/tree/master/problems/increasing-order-search-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Easy | -| 886 | [可能的二分法](https://github.com/openset/leetcode/tree/master/problems/possible-bipartition) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 872 | [叶子相似的树](https://github.com/openset/leetcode/tree/master/problems/leaf-similar-trees) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Easy | -| 863 | [二叉树中所有距离为 K 的结点](https://github.com/openset/leetcode/tree/master/problems/all-nodes-distance-k-in-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 851 | [喧闹和富有](https://github.com/openset/leetcode/tree/master/problems/loud-and-rich) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 841 | [钥匙和房间](https://github.com/openset/leetcode/tree/master/problems/keys-and-rooms) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 839 | [相似字符串组](https://github.com/openset/leetcode/tree/master/problems/similar-string-groups) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Hard | -| 834 | [树中距离之和](https://github.com/openset/leetcode/tree/master/problems/sum-of-distances-in-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Hard | -| 827 | [最大人工岛](https://github.com/openset/leetcode/tree/master/problems/making-a-large-island) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Hard | -| 802 | [找到最终的安全状态](https://github.com/openset/leetcode/tree/master/problems/find-eventual-safe-states) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 785 | [判断二分图](https://github.com/openset/leetcode/tree/master/problems/is-graph-bipartite) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 778 | [水位上升的泳池中游泳](https://github.com/openset/leetcode/tree/master/problems/swim-in-rising-water) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 756 | [金字塔转换矩阵](https://github.com/openset/leetcode/tree/master/problems/pyramid-transition-matrix) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 753 | [破解保险箱](https://github.com/openset/leetcode/tree/master/problems/cracking-the-safe) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 749 | [隔离病毒](https://github.com/openset/leetcode/tree/master/problems/contain-virus) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Hard | -| 743 | [网络延迟时间](https://github.com/openset/leetcode/tree/master/problems/network-delay-time) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 737 | [句子相似性 II](https://github.com/openset/leetcode/tree/master/problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Medium | -| 733 | [图像渲染](https://github.com/openset/leetcode/tree/master/problems/flood-fill) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Easy | -| 721 | [账户合并](https://github.com/openset/leetcode/tree/master/problems/accounts-merge) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Medium | -| 711 | [不同岛屿的数量 II](https://github.com/openset/leetcode/tree/master/problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Hard | -| 695 | [岛屿的最大面积](https://github.com/openset/leetcode/tree/master/problems/max-area-of-island) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 694 | [不同岛屿的数量](https://github.com/openset/leetcode/tree/master/problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 690 | [员工的重要性](https://github.com/openset/leetcode/tree/master/problems/employee-importance) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 685 | [冗余连接 II](https://github.com/openset/leetcode/tree/master/problems/redundant-connection-ii) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Hard | -| 679 | [24 点游戏](https://github.com/openset/leetcode/tree/master/problems/24-game) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Hard | -| 664 | [奇怪的打印机](https://github.com/openset/leetcode/tree/master/problems/strange-printer) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 638 | [大礼包](https://github.com/openset/leetcode/tree/master/problems/shopping-offers) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 576 | [出界的路径数](https://github.com/openset/leetcode/tree/master/problems/out-of-boundary-paths) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 559 | [N叉树的最大深度](https://github.com/openset/leetcode/tree/master/problems/maximum-depth-of-n-ary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Easy | -| 547 | [朋友圈](https://github.com/openset/leetcode/tree/master/problems/friend-circles) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Medium | -| 546 | [移除盒子](https://github.com/openset/leetcode/tree/master/problems/remove-boxes) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 542 | [01 矩阵](https://github.com/openset/leetcode/tree/master/problems/01-matrix) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 533 | [孤独像素 II](https://github.com/openset/leetcode/tree/master/problems/lonely-pixel-ii) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 531 | [孤独像素 I](https://github.com/openset/leetcode/tree/master/problems/lonely-pixel-i) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 529 | [扫雷游戏](https://github.com/openset/leetcode/tree/master/problems/minesweeper) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 515 | [在每个树行中找最大值](https://github.com/openset/leetcode/tree/master/problems/find-largest-value-in-each-tree-row) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 514 | [自由之路](https://github.com/openset/leetcode/tree/master/problems/freedom-trail) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 513 | [找树左下角的值](https://github.com/openset/leetcode/tree/master/problems/find-bottom-left-tree-value) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 505 | [迷宫 II](https://github.com/openset/leetcode/tree/master/problems/the-maze-ii) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 499 | [迷宫 III](https://github.com/openset/leetcode/tree/master/problems/the-maze-iii) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | -| 494 | [目标和](https://github.com/openset/leetcode/tree/master/problems/target-sum) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 491 | [递增子序列](https://github.com/openset/leetcode/tree/master/problems/increasing-subsequences) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 490 | [迷宫](https://github.com/openset/leetcode/tree/master/problems/the-maze) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 489 | [扫地机器人](https://github.com/openset/leetcode/tree/master/problems/robot-room-cleaner) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Hard | -| 488 | [祖玛游戏](https://github.com/openset/leetcode/tree/master/problems/zuma-game) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Hard | -| 473 | [火柴拼正方形](https://github.com/openset/leetcode/tree/master/problems/matchsticks-to-square) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 472 | [连接词](https://github.com/openset/leetcode/tree/master/problems/concatenated-words) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 439 | [三元表达式解析器](https://github.com/openset/leetcode/tree/master/problems/ternary-expression-parser) 🔒 | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 430 | [扁平化多级双向链表](https://github.com/openset/leetcode/tree/master/problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 417 | [太平洋大西洋水流问题](https://github.com/openset/leetcode/tree/master/problems/pacific-atlantic-water-flow) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 394 | [字符串解码](https://github.com/openset/leetcode/tree/master/problems/decode-string) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 366 | [寻找完全二叉树的叶子节点](https://github.com/openset/leetcode/tree/master/problems/find-leaves-of-binary-tree) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 364 | [加权嵌套序列和 II](https://github.com/openset/leetcode/tree/master/problems/nested-list-weight-sum-ii) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 339 | [嵌套列表权重和](https://github.com/openset/leetcode/tree/master/problems/nested-list-weight-sum) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Easy | -| 337 | [打家劫舍 III](https://github.com/openset/leetcode/tree/master/problems/house-robber-iii) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 332 | [重新安排行程](https://github.com/openset/leetcode/tree/master/problems/reconstruct-itinerary) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 329 | [矩阵中的最长递增路径](https://github.com/openset/leetcode/tree/master/problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] [[记忆化](https://github.com/openset/leetcode/tree/master/tag/memoization/README.md)] | Hard | -| 323 | [无向图中连通分量的数目](https://github.com/openset/leetcode/tree/master/problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 301 | [删除无效的括号](https://github.com/openset/leetcode/tree/master/problems/remove-invalid-parentheses) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | -| 261 | [以图判树](https://github.com/openset/leetcode/tree/master/problems/graph-valid-tree) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 257 | [二叉树的所有路径](https://github.com/openset/leetcode/tree/master/problems/binary-tree-paths) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Easy | -| 210 | [课程表 II](https://github.com/openset/leetcode/tree/master/problems/course-schedule-ii) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] | Medium | -| 207 | [课程表](https://github.com/openset/leetcode/tree/master/problems/course-schedule) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] | Medium | -| 200 | [岛屿数量](https://github.com/openset/leetcode/tree/master/problems/number-of-islands) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Medium | -| 199 | [二叉树的右视图](https://github.com/openset/leetcode/tree/master/problems/binary-tree-right-side-view) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 133 | [克隆图](https://github.com/openset/leetcode/tree/master/problems/clone-graph) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 130 | [被围绕的区域](https://github.com/openset/leetcode/tree/master/problems/surrounded-regions) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Medium | -| 129 | [求根到叶子节点数字之和](https://github.com/openset/leetcode/tree/master/problems/sum-root-to-leaf-numbers) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 124 | [二叉树中的最大路径和](https://github.com/openset/leetcode/tree/master/problems/binary-tree-maximum-path-sum) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](https://github.com/openset/leetcode/tree/master/problems/populating-next-right-pointers-in-each-node-ii) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](https://github.com/openset/leetcode/tree/master/problems/populating-next-right-pointers-in-each-node) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 114 | [二叉树展开为链表](https://github.com/openset/leetcode/tree/master/problems/flatten-binary-tree-to-linked-list) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 113 | [路径总和 II](https://github.com/openset/leetcode/tree/master/problems/path-sum-ii) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 112 | [路径总和](https://github.com/openset/leetcode/tree/master/problems/path-sum) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Easy | -| 111 | [二叉树的最小深度](https://github.com/openset/leetcode/tree/master/problems/minimum-depth-of-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Easy | -| 110 | [平衡二叉树](https://github.com/openset/leetcode/tree/master/problems/balanced-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Easy | -| 109 | [有序链表转换二叉搜索树](https://github.com/openset/leetcode/tree/master/problems/convert-sorted-list-to-binary-search-tree) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 108 | [将有序数组转换为二叉搜索树](https://github.com/openset/leetcode/tree/master/problems/convert-sorted-array-to-binary-search-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Easy | -| 106 | [从中序与后序遍历序列构造二叉树](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 105 | [从前序与中序遍历序列构造二叉树](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 104 | [二叉树的最大深度](https://github.com/openset/leetcode/tree/master/problems/maximum-depth-of-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Easy | -| 101 | [对称二叉树](https://github.com/openset/leetcode/tree/master/problems/symmetric-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Easy | -| 100 | [相同的树](https://github.com/openset/leetcode/tree/master/problems/same-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Easy | -| 99 | [恢复二叉搜索树](https://github.com/openset/leetcode/tree/master/problems/recover-binary-search-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Hard | -| 98 | [验证二叉搜索树](https://github.com/openset/leetcode/tree/master/problems/validate-binary-search-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | +| 1273 | [删除树节点](../../problems/delete-tree-nodes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1254 | [统计封闭岛屿的数目](../../problems/number-of-closed-islands) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1242 | [多线程网页爬虫](../../problems/web-crawler-multithreaded) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1236 | [Web Crawler](../../problems/web-crawler) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 1192 | [查找集群内的「关键连接」](../../problems/critical-connections-in-a-network) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1110 | [删点成林](../../problems/delete-nodes-and-return-forest) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 1080 | [根到叶路径上的不足节点](../../problems/insufficient-nodes-in-root-to-leaf-paths) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1061 | [按字典序排列最小的等效字符串](../../problems/lexicographically-smallest-equivalent-string) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 1059 | [从始点到终点的所有路径](../../problems/all-paths-from-source-lead-to-destination) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 1026 | [节点与其祖先之间的最大差值](../../problems/maximum-difference-between-node-and-ancestor) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1020 | [飞地的数量](../../problems/number-of-enclaves) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 988 | [从叶结点开始的最小字符串](../../problems/smallest-string-starting-from-leaf) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 980 | [不同路径 III](../../problems/unique-paths-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 979 | [在二叉树中分配硬币](../../problems/distribute-coins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 971 | [翻转二叉树以匹配先序遍历](../../problems/flip-binary-tree-to-match-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 947 | [移除最多的同行或同列石头](../../problems/most-stones-removed-with-same-row-or-column) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 924 | [尽量减少恶意软件的传播](../../problems/minimize-malware-spread) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | +| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 851 | [喧闹和富有](../../problems/loud-and-rich) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 841 | [钥匙和房间](../../problems/keys-and-rooms) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 827 | [最大人工岛](../../problems/making-a-large-island) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 802 | [找到最终的安全状态](../../problems/find-eventual-safe-states) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 756 | [金字塔转换矩阵](../../problems/pyramid-transition-matrix) | [[位运算](../bit-manipulation/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 753 | [破解保险箱](../../problems/cracking-the-safe) | [[深度优先搜索](../depth-first-search/README.md)] [[数学](../math/README.md)] | Hard | +| 749 | [隔离病毒](../../problems/contain-virus) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 733 | [图像渲染](../../problems/flood-fill) | [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 721 | [账户合并](../../problems/accounts-merge) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 695 | [岛屿的最大面积](../../problems/max-area-of-island) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 679 | [24 点游戏](../../problems/24-game) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 664 | [奇怪的打印机](../../problems/strange-printer) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 638 | [大礼包](../../problems/shopping-offers) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 576 | [出界的路径数](../../problems/out-of-boundary-paths) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 559 | [N叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 547 | [朋友圈](../../problems/friend-circles) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 546 | [移除盒子](../../problems/remove-boxes) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 542 | [01 矩阵](../../problems/01-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 533 | [孤独像素 II](../../problems/lonely-pixel-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 531 | [孤独像素 I](../../problems/lonely-pixel-i) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 529 | [扫雷游戏](../../problems/minesweeper) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 505 | [迷宫 II](../../problems/the-maze-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 499 | [迷宫 III](../../problems/the-maze-iii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 494 | [目标和](../../problems/target-sum) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 491 | [递增子序列](../../problems/increasing-subsequences) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 490 | [迷宫](../../problems/the-maze) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 489 | [扫地机器人](../../problems/robot-room-cleaner) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 488 | [祖玛游戏](../../problems/zuma-game) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 473 | [火柴拼正方形](../../problems/matchsticks-to-square) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 439 | [三元表达式解析器](../../problems/ternary-expression-parser) 🔒 | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 430 | [扁平化多级双向链表](../../problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 417 | [太平洋大西洋水流问题](../../problems/pacific-atlantic-water-flow) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 366 | [寻找完全二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 364 | [加权嵌套序列和 II](../../problems/nested-list-weight-sum-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 339 | [嵌套列表权重和](../../problems/nested-list-weight-sum) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | +| 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 301 | [删除无效的括号](../../problems/remove-invalid-parentheses) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 129 | [求根到叶子节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 100 | [相同的树](../../problems/same-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 99 | [恢复二叉搜索树](../../problems/recover-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index 314e592c2..d96b9f132 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -5,50 +5,50 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 设计 +## [话题分类](../README.md) > 设计 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1286 | [字母组合迭代器](https://github.com/openset/leetcode/tree/master/problems/iterator-for-combination) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 1244 | [力扣排行榜](https://github.com/openset/leetcode/tree/master/problems/design-a-leaderboard) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 1206 | [设计跳表](https://github.com/openset/leetcode/tree/master/problems/design-skiplist) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Hard | -| 1172 | [餐盘栈](https://github.com/openset/leetcode/tree/master/problems/dinner-plate-stacks) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Hard | -| 1166 | [设计文件系统](https://github.com/openset/leetcode/tree/master/problems/design-file-system) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 716 | [最大栈](https://github.com/openset/leetcode/tree/master/problems/max-stack) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Easy | -| 707 | [设计链表](https://github.com/openset/leetcode/tree/master/problems/design-linked-list) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 706 | [设计哈希映射](https://github.com/openset/leetcode/tree/master/problems/design-hashmap) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 705 | [设计哈希集合](https://github.com/openset/leetcode/tree/master/problems/design-hashset) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 642 | [设计搜索自动补全系统](https://github.com/openset/leetcode/tree/master/problems/design-search-autocomplete-system) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] | Hard | -| 641 | [设计循环双端队列](https://github.com/openset/leetcode/tree/master/problems/design-circular-deque) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] | Medium | -| 635 | [设计日志存储系统](https://github.com/openset/leetcode/tree/master/problems/design-log-storage-system) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 631 | [设计 Excel 求和公式](https://github.com/openset/leetcode/tree/master/problems/design-excel-sum-formula) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Hard | -| 622 | [设计循环队列](https://github.com/openset/leetcode/tree/master/problems/design-circular-queue) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] | Medium | -| 604 | [迭代压缩字符串](https://github.com/openset/leetcode/tree/master/problems/design-compressed-string-iterator) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Easy | -| 588 | [设计内存文件系统](https://github.com/openset/leetcode/tree/master/problems/design-in-memory-file-system) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Hard | -| 460 | [LFU缓存](https://github.com/openset/leetcode/tree/master/problems/lfu-cache) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Hard | -| 432 | [全 O(1) 的数据结构](https://github.com/openset/leetcode/tree/master/problems/all-oone-data-structure) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Hard | -| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](https://github.com/openset/leetcode/tree/master/problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Hard | -| 380 | [常数时间插入、删除和获取随机元素](https://github.com/openset/leetcode/tree/master/problems/insert-delete-getrandom-o1) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 379 | [电话目录管理系统](https://github.com/openset/leetcode/tree/master/problems/design-phone-directory) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 362 | [敲击计数器](https://github.com/openset/leetcode/tree/master/problems/design-hit-counter) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Medium | -| 359 | [日志速率限制器](https://github.com/openset/leetcode/tree/master/problems/logger-rate-limiter) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 355 | [设计推特](https://github.com/openset/leetcode/tree/master/problems/design-twitter) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 353 | [贪吃蛇](https://github.com/openset/leetcode/tree/master/problems/design-snake-game) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] | Medium | -| 348 | [判定井字棋胜负](https://github.com/openset/leetcode/tree/master/problems/design-tic-tac-toe) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Medium | -| 346 | [数据流中的移动平均值](https://github.com/openset/leetcode/tree/master/problems/moving-average-from-data-stream) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] | Easy | -| 341 | [扁平化嵌套列表迭代器](https://github.com/openset/leetcode/tree/master/problems/flatten-nested-list-iterator) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Medium | -| 297 | [二叉树的序列化与反序列化](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Hard | -| 295 | [数据流的中位数](https://github.com/openset/leetcode/tree/master/problems/find-median-from-data-stream) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Hard | -| 288 | [单词的唯一缩写](https://github.com/openset/leetcode/tree/master/problems/unique-word-abbreviation) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 284 | [顶端迭代器](https://github.com/openset/leetcode/tree/master/problems/peeking-iterator) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Medium | -| 281 | [锯齿迭代器](https://github.com/openset/leetcode/tree/master/problems/zigzag-iterator) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Medium | -| 251 | [展开二维向量](https://github.com/openset/leetcode/tree/master/problems/flatten-2d-vector) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Medium | -| 244 | [最短单词距离 II](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance-ii) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 232 | [用栈实现队列](https://github.com/openset/leetcode/tree/master/problems/implement-queue-using-stacks) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Easy | -| 225 | [用队列实现栈](https://github.com/openset/leetcode/tree/master/problems/implement-stack-using-queues) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Easy | -| 211 | [添加与搜索单词 - 数据结构设计](https://github.com/openset/leetcode/tree/master/problems/add-and-search-word-data-structure-design) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 208 | [实现 Trie (前缀树)](https://github.com/openset/leetcode/tree/master/problems/implement-trie-prefix-tree) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] | Medium | -| 173 | [二叉搜索树迭代器](https://github.com/openset/leetcode/tree/master/problems/binary-search-tree-iterator) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Medium | -| 170 | [两数之和 III - 数据结构设计](https://github.com/openset/leetcode/tree/master/problems/two-sum-iii-data-structure-design) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 155 | [最小栈](https://github.com/openset/leetcode/tree/master/problems/min-stack) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Easy | -| 146 | [LRU缓存机制](https://github.com/openset/leetcode/tree/master/problems/lru-cache) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Medium | +| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1206 | [设计跳表](../../problems/design-skiplist) | [[设计](../design/README.md)] | Hard | +| 1172 | [餐盘栈](../../problems/dinner-plate-stacks) | [[设计](../design/README.md)] | Hard | +| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 716 | [最大栈](../../problems/max-stack) 🔒 | [[设计](../design/README.md)] | Easy | +| 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Hard | +| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | +| 631 | [设计 Excel 求和公式](../../problems/design-excel-sum-formula) 🔒 | [[设计](../design/README.md)] | Hard | +| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] | Easy | +| 588 | [设计内存文件系统](../../problems/design-in-memory-file-system) 🔒 | [[设计](../design/README.md)] | Hard | +| 460 | [LFU缓存](../../problems/lfu-cache) | [[设计](../design/README.md)] | Hard | +| 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] | Hard | +| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 362 | [敲击计数器](../../problems/design-hit-counter) 🔒 | [[设计](../design/README.md)] | Medium | +| 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 348 | [判定井字棋胜负](../../problems/design-tic-tac-toe) 🔒 | [[设计](../design/README.md)] | Medium | +| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | +| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | +| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard | +| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard | +| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] | Medium | +| 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] | Medium | +| 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] | Medium | +| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/add-and-search-word-data-structure-design) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium | +| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 146 | [LRU缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] | Medium | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index aee63daf9..63807f675 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -5,26 +5,26 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 分治算法 +## [话题分类](../README.md) > 分治算法 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1274 | [矩形内船只的数目](https://github.com/openset/leetcode/tree/master/problems/number-of-ships-in-a-rectangle) 🔒 | [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 973 | [最接近原点的 K 个点](https://github.com/openset/leetcode/tree/master/problems/k-closest-points-to-origin) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Medium | -| 932 | [漂亮数组](https://github.com/openset/leetcode/tree/master/problems/beautiful-array) | [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Medium | -| 903 | [DI 序列的有效排列](https://github.com/openset/leetcode/tree/master/problems/valid-permutations-for-di-sequence) | [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 514 | [自由之路](https://github.com/openset/leetcode/tree/master/problems/freedom-trail) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 493 | [翻转对](https://github.com/openset/leetcode/tree/master/problems/reverse-pairs) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 426 | [将二叉搜索树转化为排序的双向链表](https://github.com/openset/leetcode/tree/master/problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Medium | -| 327 | [区间和的个数](https://github.com/openset/leetcode/tree/master/problems/count-of-range-sum) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 315 | [计算右侧小于当前元素的个数](https://github.com/openset/leetcode/tree/master/problems/count-of-smaller-numbers-after-self) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 312 | [戳气球](https://github.com/openset/leetcode/tree/master/problems/burst-balloons) | [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 282 | [给表达式添加运算符](https://github.com/openset/leetcode/tree/master/problems/expression-add-operators) | [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 241 | [为运算表达式设计优先级](https://github.com/openset/leetcode/tree/master/problems/different-ways-to-add-parentheses) | [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Medium | -| 240 | [搜索二维矩阵 II](https://github.com/openset/leetcode/tree/master/problems/search-a-2d-matrix-ii) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Medium | -| 218 | [天际线问题](https://github.com/openset/leetcode/tree/master/problems/the-skyline-problem) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] | Hard | -| 215 | [数组中的第K个最大元素](https://github.com/openset/leetcode/tree/master/problems/kth-largest-element-in-an-array) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Medium | -| 169 | [多数元素](https://github.com/openset/leetcode/tree/master/problems/majority-element) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Easy | -| 53 | [最大子序和](https://github.com/openset/leetcode/tree/master/problems/maximum-subarray) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Easy | -| 23 | [合并K个排序链表](https://github.com/openset/leetcode/tree/master/problems/merge-k-sorted-lists) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 4 | [寻找两个有序数组的中位数](https://github.com/openset/leetcode/tree/master/problems/median-of-two-sorted-arrays) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | +| 1274 | [矩形内船只的数目](../../problems/number-of-ships-in-a-rectangle) 🔒 | [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 932 | [漂亮数组](../../problems/beautiful-array) | [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 903 | [DI 序列的有效排列](../../problems/valid-permutations-for-di-sequence) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 312 | [戳气球](../../problems/burst-balloons) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 282 | [给表达式添加运算符](../../problems/expression-add-operators) | [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 241 | [为运算表达式设计优先级](../../problems/different-ways-to-add-parentheses) | [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | +| 215 | [数组中的第K个最大元素](../../problems/kth-largest-element-in-an-array) | [[堆](../heap/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 169 | [多数元素](../../problems/majority-element) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Easy | +| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 23 | [合并K个排序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 4 | [寻找两个有序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 95bbda0e4..c69b90d2f 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -5,181 +5,181 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 动态规划 +## [话题分类](../README.md) > 动态规划 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1289 | [下降路径最小和 II](https://github.com/openset/leetcode/tree/master/problems/minimum-falling-path-sum-ii) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1278 | [分割回文串 III](https://github.com/openset/leetcode/tree/master/problems/palindrome-partitioning-iii) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1277 | [统计全为 1 的正方形子矩阵](https://github.com/openset/leetcode/tree/master/problems/count-square-submatrices-with-all-ones) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1273 | [删除树节点](https://github.com/openset/leetcode/tree/master/problems/delete-tree-nodes) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1269 | [停在原地的方案数](https://github.com/openset/leetcode/tree/master/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1262 | [可被三整除的最大和](https://github.com/openset/leetcode/tree/master/problems/greatest-sum-divisible-by-three) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1259 | [不相交的握手](https://github.com/openset/leetcode/tree/master/problems/handshakes-that-dont-cross) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1246 | [删除回文子数组](https://github.com/openset/leetcode/tree/master/problems/palindrome-removal) 🔒 | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1240 | [铺瓷砖](https://github.com/openset/leetcode/tree/master/problems/tiling-a-rectangle-with-the-fewest-squares) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 1235 | [规划兼职工作](https://github.com/openset/leetcode/tree/master/problems/maximum-profit-in-job-scheduling) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1230 | [抛掷硬币](https://github.com/openset/leetcode/tree/master/problems/toss-strange-coins) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1227 | [飞机座位分配概率](https://github.com/openset/leetcode/tree/master/problems/airplane-seat-assignment-probability) | [[脑筋急转弯](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1223 | [掷骰子模拟](https://github.com/openset/leetcode/tree/master/problems/dice-roll-simulation) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1220 | [统计元音字母序列的数目](https://github.com/openset/leetcode/tree/master/problems/count-vowels-permutation) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1218 | [最长定差子序列](https://github.com/openset/leetcode/tree/master/problems/longest-arithmetic-subsequence-of-given-difference) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1216 | [验证回文字符串 III](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome-iii) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1199 | [建造街区的最短时间](https://github.com/openset/leetcode/tree/master/problems/minimum-time-to-build-blocks) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1191 | [K 次串联后最大子数组之和](https://github.com/openset/leetcode/tree/master/problems/k-concatenation-maximum-sum) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1187 | [使数组严格递增](https://github.com/openset/leetcode/tree/master/problems/make-array-strictly-increasing) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1186 | [删除一次得到子数组最大和](https://github.com/openset/leetcode/tree/master/problems/maximum-subarray-sum-with-one-deletion) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1155 | [掷骰子的N种方法](https://github.com/openset/leetcode/tree/master/problems/number-of-dice-rolls-with-target-sum) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1147 | [段式回文](https://github.com/openset/leetcode/tree/master/problems/longest-chunked-palindrome-decomposition) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1143 | [最长公共子序列](https://github.com/openset/leetcode/tree/master/problems/longest-common-subsequence) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1140 | [石子游戏 II](https://github.com/openset/leetcode/tree/master/problems/stone-game-ii) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1139 | [最大的以 1 为边界的正方形](https://github.com/openset/leetcode/tree/master/problems/largest-1-bordered-square) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1136 | [平行课程](https://github.com/openset/leetcode/tree/master/problems/parallel-courses) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1130 | [叶值的最小代价生成树](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-tree-from-leaf-values) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1125 | [最小的必要团队](https://github.com/openset/leetcode/tree/master/problems/smallest-sufficient-team) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1105 | [填充书架](https://github.com/openset/leetcode/tree/master/problems/filling-bookcase-shelves) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1092 | [最短公共超序列](https://github.com/openset/leetcode/tree/master/problems/shortest-common-supersequence) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1074 | [元素和为目标值的子矩阵数量](https://github.com/openset/leetcode/tree/master/problems/number-of-submatrices-that-sum-to-target) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 1067 | [范围内的数字计数](https://github.com/openset/leetcode/tree/master/problems/digit-count-in-range) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1066 | [校园自行车分配 II](https://github.com/openset/leetcode/tree/master/problems/campus-bikes-ii) 🔒 | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 1058 | [最小化舍入误差以满足目标](https://github.com/openset/leetcode/tree/master/problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1055 | [形成字符串的最短路径](https://github.com/openset/leetcode/tree/master/problems/shortest-way-to-form-string) 🔒 | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1049 | [最后一块石头的重量 II](https://github.com/openset/leetcode/tree/master/problems/last-stone-weight-ii) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1048 | [最长字符串链](https://github.com/openset/leetcode/tree/master/problems/longest-string-chain) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1039 | [多边形三角剖分的最低得分](https://github.com/openset/leetcode/tree/master/problems/minimum-score-triangulation-of-polygon) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1027 | [最长等差数列](https://github.com/openset/leetcode/tree/master/problems/longest-arithmetic-sequence) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1025 | [除数博弈](https://github.com/openset/leetcode/tree/master/problems/divisor-game) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Easy | -| 1024 | [视频拼接](https://github.com/openset/leetcode/tree/master/problems/video-stitching) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1012 | [至少有 1 位重复的数字](https://github.com/openset/leetcode/tree/master/problems/numbers-with-repeated-digits) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1000 | [合并石头的最低成本](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-to-merge-stones) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 983 | [最低票价](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-for-tickets) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 982 | [按位与为零的三元组](https://github.com/openset/leetcode/tree/master/problems/triples-with-bitwise-and-equal-to-zero) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 978 | [最长湍流子数组](https://github.com/openset/leetcode/tree/master/problems/longest-turbulent-subarray) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 975 | [奇偶跳](https://github.com/openset/leetcode/tree/master/problems/odd-even-jump) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] | Hard | -| 968 | [监控二叉树](https://github.com/openset/leetcode/tree/master/problems/binary-tree-cameras) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 967 | [连续差相同的数字](https://github.com/openset/leetcode/tree/master/problems/numbers-with-same-consecutive-differences) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 964 | [表示数字的最少运算符](https://github.com/openset/leetcode/tree/master/problems/least-operators-to-express-number) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 960 | [删列造序 III](https://github.com/openset/leetcode/tree/master/problems/delete-columns-to-make-sorted-iii) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 956 | [最高的广告牌](https://github.com/openset/leetcode/tree/master/problems/tallest-billboard) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 943 | [最短超级串](https://github.com/openset/leetcode/tree/master/problems/find-the-shortest-superstring) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 940 | [不同的子序列 II](https://github.com/openset/leetcode/tree/master/problems/distinct-subsequences-ii) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 935 | [骑士拨号器](https://github.com/openset/leetcode/tree/master/problems/knight-dialer) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 931 | [下降路径最小和](https://github.com/openset/leetcode/tree/master/problems/minimum-falling-path-sum) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 920 | [播放列表的数量](https://github.com/openset/leetcode/tree/master/problems/number-of-music-playlists) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 903 | [DI 序列的有效排列](https://github.com/openset/leetcode/tree/master/problems/valid-permutations-for-di-sequence) | [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 902 | [最大为 N 的数字组合](https://github.com/openset/leetcode/tree/master/problems/numbers-at-most-n-given-digit-set) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 898 | [子数组按位或操作](https://github.com/openset/leetcode/tree/master/problems/bitwise-ors-of-subarrays) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 887 | [鸡蛋掉落](https://github.com/openset/leetcode/tree/master/problems/super-egg-drop) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 879 | [盈利计划](https://github.com/openset/leetcode/tree/master/problems/profitable-schemes) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 877 | [石子游戏](https://github.com/openset/leetcode/tree/master/problems/stone-game) | [[极小化极大](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 873 | [最长的斐波那契子序列的长度](https://github.com/openset/leetcode/tree/master/problems/length-of-longest-fibonacci-subsequence) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 871 | [最低加油次数](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-refueling-stops) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 847 | [访问所有节点的最短路径](https://github.com/openset/leetcode/tree/master/problems/shortest-path-visiting-all-nodes) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 838 | [推多米诺](https://github.com/openset/leetcode/tree/master/problems/push-dominoes) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 837 | [新21点](https://github.com/openset/leetcode/tree/master/problems/new-21-game) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 818 | [赛车](https://github.com/openset/leetcode/tree/master/problems/race-car) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 813 | [最大平均值和的分组](https://github.com/openset/leetcode/tree/master/problems/largest-sum-of-averages) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 808 | [分汤](https://github.com/openset/leetcode/tree/master/problems/soup-servings) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 801 | [使序列递增的最小交换次数](https://github.com/openset/leetcode/tree/master/problems/minimum-swaps-to-make-sequences-increasing) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 790 | [多米诺和托米诺平铺](https://github.com/openset/leetcode/tree/master/problems/domino-and-tromino-tiling) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 787 | [K 站中转内最便宜的航班](https://github.com/openset/leetcode/tree/master/problems/cheapest-flights-within-k-stops) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 764 | [最大加号标志](https://github.com/openset/leetcode/tree/master/problems/largest-plus-sign) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 750 | [角矩形的数量](https://github.com/openset/leetcode/tree/master/problems/number-of-corner-rectangles) 🔒 | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 746 | [使用最小花费爬楼梯](https://github.com/openset/leetcode/tree/master/problems/min-cost-climbing-stairs) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Easy | -| 741 | [摘樱桃](https://github.com/openset/leetcode/tree/master/problems/cherry-pickup) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 740 | [删除与获得点数](https://github.com/openset/leetcode/tree/master/problems/delete-and-earn) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 730 | [统计不同回文子字符串](https://github.com/openset/leetcode/tree/master/problems/count-different-palindromic-subsequences) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 727 | [最小窗口子序列](https://github.com/openset/leetcode/tree/master/problems/minimum-window-subsequence) 🔒 | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 718 | [最长重复子数组](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-repeated-subarray) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 714 | [买卖股票的最佳时机含手续费](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 712 | [两个字符串的最小ASCII删除和](https://github.com/openset/leetcode/tree/master/problems/minimum-ascii-delete-sum-for-two-strings) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 698 | [划分为k个相等的子集](https://github.com/openset/leetcode/tree/master/problems/partition-to-k-equal-sum-subsets) | [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 691 | [贴纸拼词](https://github.com/openset/leetcode/tree/master/problems/stickers-to-spell-word) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 689 | [三个无重叠子数组的最大和](https://github.com/openset/leetcode/tree/master/problems/maximum-sum-of-3-non-overlapping-subarrays) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 688 | [“马”在棋盘上的概率](https://github.com/openset/leetcode/tree/master/problems/knight-probability-in-chessboard) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 673 | [最长递增子序列的个数](https://github.com/openset/leetcode/tree/master/problems/number-of-longest-increasing-subsequence) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 664 | [奇怪的打印机](https://github.com/openset/leetcode/tree/master/problems/strange-printer) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 656 | [金币路径](https://github.com/openset/leetcode/tree/master/problems/coin-path) 🔒 | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 651 | [4键键盘](https://github.com/openset/leetcode/tree/master/problems/4-keys-keyboard) 🔒 | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 650 | [只有两个键的键盘](https://github.com/openset/leetcode/tree/master/problems/2-keys-keyboard) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 647 | [回文子串](https://github.com/openset/leetcode/tree/master/problems/palindromic-substrings) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 646 | [最长数对链](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-pair-chain) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 639 | [解码方法 2](https://github.com/openset/leetcode/tree/master/problems/decode-ways-ii) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 638 | [大礼包](https://github.com/openset/leetcode/tree/master/problems/shopping-offers) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 629 | [K个逆序对数组](https://github.com/openset/leetcode/tree/master/problems/k-inverse-pairs-array) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 600 | [不含连续1的非负整数](https://github.com/openset/leetcode/tree/master/problems/non-negative-integers-without-consecutive-ones) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 576 | [出界的路径数](https://github.com/openset/leetcode/tree/master/problems/out-of-boundary-paths) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 568 | [最大休假天数](https://github.com/openset/leetcode/tree/master/problems/maximum-vacation-days) 🔒 | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 552 | [学生出勤记录 II](https://github.com/openset/leetcode/tree/master/problems/student-attendance-record-ii) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 546 | [移除盒子](https://github.com/openset/leetcode/tree/master/problems/remove-boxes) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 523 | [连续的子数组和](https://github.com/openset/leetcode/tree/master/problems/continuous-subarray-sum) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 517 | [超级洗衣机](https://github.com/openset/leetcode/tree/master/problems/super-washing-machines) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 516 | [最长回文子序列](https://github.com/openset/leetcode/tree/master/problems/longest-palindromic-subsequence) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 514 | [自由之路](https://github.com/openset/leetcode/tree/master/problems/freedom-trail) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 494 | [目标和](https://github.com/openset/leetcode/tree/master/problems/target-sum) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 486 | [预测赢家](https://github.com/openset/leetcode/tree/master/problems/predict-the-winner) | [[极小化极大](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 474 | [一和零](https://github.com/openset/leetcode/tree/master/problems/ones-and-zeroes) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 472 | [连接词](https://github.com/openset/leetcode/tree/master/problems/concatenated-words) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 471 | [编码最短长度的字符串](https://github.com/openset/leetcode/tree/master/problems/encode-string-with-shortest-length) 🔒 | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 467 | [环绕字符串中唯一的子字符串](https://github.com/openset/leetcode/tree/master/problems/unique-substrings-in-wraparound-string) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 466 | [统计重复个数](https://github.com/openset/leetcode/tree/master/problems/count-the-repetitions) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 464 | [我能赢吗](https://github.com/openset/leetcode/tree/master/problems/can-i-win) | [[极小化极大](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 446 | [等差数列划分 II - 子序列](https://github.com/openset/leetcode/tree/master/problems/arithmetic-slices-ii-subsequence) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 418 | [屏幕可显示句子的数量](https://github.com/openset/leetcode/tree/master/problems/sentence-screen-fitting) 🔒 | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 416 | [分割等和子集](https://github.com/openset/leetcode/tree/master/problems/partition-equal-subset-sum) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 413 | [等差数列划分](https://github.com/openset/leetcode/tree/master/problems/arithmetic-slices) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 410 | [分割数组的最大值](https://github.com/openset/leetcode/tree/master/problems/split-array-largest-sum) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 403 | [青蛙过河](https://github.com/openset/leetcode/tree/master/problems/frog-jump) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 392 | [判断子序列](https://github.com/openset/leetcode/tree/master/problems/is-subsequence) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Easy | -| 377 | [组合总和 Ⅳ](https://github.com/openset/leetcode/tree/master/problems/combination-sum-iv) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 376 | [摆动序列](https://github.com/openset/leetcode/tree/master/problems/wiggle-subsequence) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 375 | [猜数字大小 II](https://github.com/openset/leetcode/tree/master/problems/guess-number-higher-or-lower-ii) | [[极小化极大](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 368 | [最大整除子集](https://github.com/openset/leetcode/tree/master/problems/largest-divisible-subset) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 363 | [矩形区域不超过 K 的最大数值和](https://github.com/openset/leetcode/tree/master/problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 361 | [轰炸敌人](https://github.com/openset/leetcode/tree/master/problems/bomb-enemy) 🔒 | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 357 | [计算各个位数不同的数字个数](https://github.com/openset/leetcode/tree/master/problems/count-numbers-with-unique-digits) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 354 | [俄罗斯套娃信封问题](https://github.com/openset/leetcode/tree/master/problems/russian-doll-envelopes) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 351 | [安卓系统手势解锁](https://github.com/openset/leetcode/tree/master/problems/android-unlock-patterns) 🔒 | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 343 | [整数拆分](https://github.com/openset/leetcode/tree/master/problems/integer-break) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 338 | [比特位计数](https://github.com/openset/leetcode/tree/master/problems/counting-bits) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 322 | [零钱兑换](https://github.com/openset/leetcode/tree/master/problems/coin-change) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 321 | [拼接最大数](https://github.com/openset/leetcode/tree/master/problems/create-maximum-number) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 312 | [戳气球](https://github.com/openset/leetcode/tree/master/problems/burst-balloons) | [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 309 | [最佳买卖股票时机含冷冻期](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-with-cooldown) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 304 | [二维区域和检索 - 矩阵不可变](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-2d-immutable) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 303 | [区域和检索 - 数组不可变](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-immutable) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Easy | -| 300 | [最长上升子序列](https://github.com/openset/leetcode/tree/master/problems/longest-increasing-subsequence) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 279 | [完全平方数](https://github.com/openset/leetcode/tree/master/problems/perfect-squares) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 276 | [栅栏涂色](https://github.com/openset/leetcode/tree/master/problems/paint-fence) 🔒 | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Easy | -| 265 | [粉刷房子 II](https://github.com/openset/leetcode/tree/master/problems/paint-house-ii) 🔒 | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 264 | [丑数 II](https://github.com/openset/leetcode/tree/master/problems/ugly-number-ii) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 256 | [粉刷房子](https://github.com/openset/leetcode/tree/master/problems/paint-house) 🔒 | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Easy | -| 221 | [最大正方形](https://github.com/openset/leetcode/tree/master/problems/maximal-square) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 213 | [打家劫舍 II](https://github.com/openset/leetcode/tree/master/problems/house-robber-ii) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 198 | [打家劫舍](https://github.com/openset/leetcode/tree/master/problems/house-robber) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Easy | -| 188 | [买卖股票的最佳时机 IV](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-iv) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 174 | [地下城游戏](https://github.com/openset/leetcode/tree/master/problems/dungeon-game) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 152 | [乘积最大子序列](https://github.com/openset/leetcode/tree/master/problems/maximum-product-subarray) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 140 | [单词拆分 II](https://github.com/openset/leetcode/tree/master/problems/word-break-ii) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 139 | [单词拆分](https://github.com/openset/leetcode/tree/master/problems/word-break) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 132 | [分割回文串 II](https://github.com/openset/leetcode/tree/master/problems/palindrome-partitioning-ii) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 123 | [买卖股票的最佳时机 III](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-iii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 121 | [买卖股票的最佳时机](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Easy | -| 120 | [三角形最小路径和](https://github.com/openset/leetcode/tree/master/problems/triangle) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 115 | [不同的子序列](https://github.com/openset/leetcode/tree/master/problems/distinct-subsequences) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 97 | [交错字符串](https://github.com/openset/leetcode/tree/master/problems/interleaving-string) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 96 | [不同的二叉搜索树](https://github.com/openset/leetcode/tree/master/problems/unique-binary-search-trees) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 95 | [不同的二叉搜索树 II](https://github.com/openset/leetcode/tree/master/problems/unique-binary-search-trees-ii) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 91 | [解码方法](https://github.com/openset/leetcode/tree/master/problems/decode-ways) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 87 | [扰乱字符串](https://github.com/openset/leetcode/tree/master/problems/scramble-string) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 85 | [最大矩形](https://github.com/openset/leetcode/tree/master/problems/maximal-rectangle) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 72 | [编辑距离](https://github.com/openset/leetcode/tree/master/problems/edit-distance) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 70 | [爬楼梯](https://github.com/openset/leetcode/tree/master/problems/climbing-stairs) | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Easy | -| 64 | [最小路径和](https://github.com/openset/leetcode/tree/master/problems/minimum-path-sum) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 63 | [不同路径 II](https://github.com/openset/leetcode/tree/master/problems/unique-paths-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 62 | [不同路径](https://github.com/openset/leetcode/tree/master/problems/unique-paths) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 53 | [最大子序和](https://github.com/openset/leetcode/tree/master/problems/maximum-subarray) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Easy | -| 44 | [通配符匹配](https://github.com/openset/leetcode/tree/master/problems/wildcard-matching) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 32 | [最长有效括号](https://github.com/openset/leetcode/tree/master/problems/longest-valid-parentheses) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 10 | [正则表达式匹配](https://github.com/openset/leetcode/tree/master/problems/regular-expression-matching) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 5 | [最长回文子串](https://github.com/openset/leetcode/tree/master/problems/longest-palindromic-substring) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | +| 1289 | [下降路径最小和 II](../../problems/minimum-falling-path-sum-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1278 | [分割回文串 III](../../problems/palindrome-partitioning-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1277 | [统计全为 1 的正方形子矩阵](../../problems/count-square-submatrices-with-all-ones) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1273 | [删除树节点](../../problems/delete-tree-nodes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1269 | [停在原地的方案数](../../problems/number-of-ways-to-stay-in-the-same-place-after-some-steps) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1262 | [可被三整除的最大和](../../problems/greatest-sum-divisible-by-three) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1259 | [不相交的握手](../../problems/handshakes-that-dont-cross) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1246 | [删除回文子数组](../../problems/palindrome-removal) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1240 | [铺瓷砖](../../problems/tiling-a-rectangle-with-the-fewest-squares) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1230 | [抛掷硬币](../../problems/toss-strange-coins) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1223 | [掷骰子模拟](../../problems/dice-roll-simulation) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1220 | [统计元音字母序列的数目](../../problems/count-vowels-permutation) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1216 | [验证回文字符串 III](../../problems/valid-palindrome-iii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1199 | [建造街区的最短时间](../../problems/minimum-time-to-build-blocks) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1191 | [K 次串联后最大子数组之和](../../problems/k-concatenation-maximum-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1187 | [使数组严格递增](../../problems/make-array-strictly-increasing) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1186 | [删除一次得到子数组最大和](../../problems/maximum-subarray-sum-with-one-deletion) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1155 | [掷骰子的N种方法](../../problems/number-of-dice-rolls-with-target-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1147 | [段式回文](../../problems/longest-chunked-palindrome-decomposition) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1143 | [最长公共子序列](../../problems/longest-common-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1140 | [石子游戏 II](../../problems/stone-game-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1139 | [最大的以 1 为边界的正方形](../../problems/largest-1-bordered-square) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1125 | [最小的必要团队](../../problems/smallest-sufficient-team) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1105 | [填充书架](../../problems/filling-bookcase-shelves) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1092 | [最短公共超序列](../../problems/shortest-common-supersequence) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 1067 | [范围内的数字计数](../../problems/digit-count-in-range) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1055 | [形成字符串的最短路径](../../problems/shortest-way-to-form-string) 🔒 | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1049 | [最后一块石头的重量 II](../../problems/last-stone-weight-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1048 | [最长字符串链](../../problems/longest-string-chain) | [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1039 | [多边形三角剖分的最低得分](../../problems/minimum-score-triangulation-of-polygon) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1027 | [最长等差数列](../../problems/longest-arithmetic-sequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1025 | [除数博弈](../../problems/divisor-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 1024 | [视频拼接](../../problems/video-stitching) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1012 | [至少有 1 位重复的数字](../../problems/numbers-with-repeated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1000 | [合并石头的最低成本](../../problems/minimum-cost-to-merge-stones) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 983 | [最低票价](../../problems/minimum-cost-for-tickets) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 982 | [按位与为零的三元组](../../problems/triples-with-bitwise-and-equal-to-zero) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 964 | [表示数字的最少运算符](../../problems/least-operators-to-express-number) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 960 | [删列造序 III](../../problems/delete-columns-to-make-sorted-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 956 | [最高的广告牌](../../problems/tallest-billboard) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 943 | [最短超级串](../../problems/find-the-shortest-superstring) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 940 | [不同的子序列 II](../../problems/distinct-subsequences-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 935 | [骑士拨号器](../../problems/knight-dialer) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 931 | [下降路径最小和](../../problems/minimum-falling-path-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 920 | [播放列表的数量](../../problems/number-of-music-playlists) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 903 | [DI 序列的有效排列](../../problems/valid-permutations-for-di-sequence) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 902 | [最大为 N 的数字组合](../../problems/numbers-at-most-n-given-digit-set) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 898 | [子数组按位或操作](../../problems/bitwise-ors-of-subarrays) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 879 | [盈利计划](../../problems/profitable-schemes) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 877 | [石子游戏](../../problems/stone-game) | [[极小化极大](../minimax/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 871 | [最低加油次数](../../problems/minimum-number-of-refueling-stops) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 837 | [新21点](../../problems/new-21-game) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 818 | [赛车](../../problems/race-car) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 813 | [最大平均值和的分组](../../problems/largest-sum-of-averages) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 808 | [分汤](../../problems/soup-servings) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 801 | [使序列递增的最小交换次数](../../problems/minimum-swaps-to-make-sequences-increasing) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 790 | [多米诺和托米诺平铺](../../problems/domino-and-tromino-tiling) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 764 | [最大加号标志](../../problems/largest-plus-sign) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 750 | [角矩形的数量](../../problems/number-of-corner-rectangles) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 746 | [使用最小花费爬楼梯](../../problems/min-cost-climbing-stairs) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 741 | [摘樱桃](../../problems/cherry-pickup) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 740 | [删除与获得点数](../../problems/delete-and-earn) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 730 | [统计不同回文子字符串](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 712 | [两个字符串的最小ASCII删除和](../../problems/minimum-ascii-delete-sum-for-two-strings) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 689 | [三个无重叠子数组的最大和](../../problems/maximum-sum-of-3-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 688 | [“马”在棋盘上的概率](../../problems/knight-probability-in-chessboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 673 | [最长递增子序列的个数](../../problems/number-of-longest-increasing-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 664 | [奇怪的打印机](../../problems/strange-printer) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 656 | [金币路径](../../problems/coin-path) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 651 | [4键键盘](../../problems/4-keys-keyboard) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 650 | [只有两个键的键盘](../../problems/2-keys-keyboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 647 | [回文子串](../../problems/palindromic-substrings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 646 | [最长数对链](../../problems/maximum-length-of-pair-chain) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 639 | [解码方法 2](../../problems/decode-ways-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 638 | [大礼包](../../problems/shopping-offers) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 629 | [K个逆序对数组](../../problems/k-inverse-pairs-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 600 | [不含连续1的非负整数](../../problems/non-negative-integers-without-consecutive-ones) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 576 | [出界的路径数](../../problems/out-of-boundary-paths) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 568 | [最大休假天数](../../problems/maximum-vacation-days) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 552 | [学生出勤记录 II](../../problems/student-attendance-record-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 546 | [移除盒子](../../problems/remove-boxes) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 523 | [连续的子数组和](../../problems/continuous-subarray-sum) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 517 | [超级洗衣机](../../problems/super-washing-machines) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 516 | [最长回文子序列](../../problems/longest-palindromic-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 494 | [目标和](../../problems/target-sum) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 486 | [预测赢家](../../problems/predict-the-winner) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 474 | [一和零](../../problems/ones-and-zeroes) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 471 | [编码最短长度的字符串](../../problems/encode-string-with-shortest-length) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 467 | [环绕字符串中唯一的子字符串](../../problems/unique-substrings-in-wraparound-string) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 466 | [统计重复个数](../../problems/count-the-repetitions) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 464 | [我能赢吗](../../problems/can-i-win) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 446 | [等差数列划分 II - 子序列](../../problems/arithmetic-slices-ii-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 416 | [分割等和子集](../../problems/partition-equal-subset-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 403 | [青蛙过河](../../problems/frog-jump) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 377 | [组合总和 Ⅳ](../../problems/combination-sum-iv) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 375 | [猜数字大小 II](../../problems/guess-number-higher-or-lower-ii) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 361 | [轰炸敌人](../../problems/bomb-enemy) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 354 | [俄罗斯套娃信封问题](../../problems/russian-doll-envelopes) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 351 | [安卓系统手势解锁](../../problems/android-unlock-patterns) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 343 | [整数拆分](../../problems/integer-break) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 322 | [零钱兑换](../../problems/coin-change) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 321 | [拼接最大数](../../problems/create-maximum-number) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 312 | [戳气球](../../problems/burst-balloons) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 309 | [最佳买卖股票时机含冷冻期](../../problems/best-time-to-buy-and-sell-stock-with-cooldown) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 304 | [二维区域和检索 - 矩阵不可变](../../problems/range-sum-query-2d-immutable) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 303 | [区域和检索 - 数组不可变](../../problems/range-sum-query-immutable) | [[动态规划](../dynamic-programming/README.md)] | Easy | +| 300 | [最长上升子序列](../../problems/longest-increasing-subsequence) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 276 | [栅栏涂色](../../problems/paint-fence) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Easy | +| 265 | [粉刷房子 II](../../problems/paint-house-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 256 | [粉刷房子](../../problems/paint-house) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Easy | +| 221 | [最大正方形](../../problems/maximal-square) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 213 | [打家劫舍 II](../../problems/house-robber-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 198 | [打家劫舍](../../problems/house-robber) | [[动态规划](../dynamic-programming/README.md)] | Easy | +| 188 | [买卖股票的最佳时机 IV](../../problems/best-time-to-buy-and-sell-stock-iv) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 174 | [地下城游戏](../../problems/dungeon-game) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 152 | [乘积最大子序列](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 140 | [单词拆分 II](../../problems/word-break-ii) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 139 | [单词拆分](../../problems/word-break) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 132 | [分割回文串 II](../../problems/palindrome-partitioning-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 123 | [买卖股票的最佳时机 III](../../problems/best-time-to-buy-and-sell-stock-iii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 121 | [买卖股票的最佳时机](../../problems/best-time-to-buy-and-sell-stock) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 120 | [三角形最小路径和](../../problems/triangle) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 115 | [不同的子序列](../../problems/distinct-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 91 | [解码方法](../../problems/decode-ways) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 87 | [扰乱字符串](../../problems/scramble-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 72 | [编辑距离](../../problems/edit-distance) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 70 | [爬楼梯](../../problems/climbing-stairs) | [[动态规划](../dynamic-programming/README.md)] | Easy | +| 64 | [最小路径和](../../problems/minimum-path-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 63 | [不同路径 II](../../problems/unique-paths-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 62 | [不同路径](../../problems/unique-paths) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 5 | [最长回文子串](../../problems/longest-palindromic-substring) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index 275a6eb17..91db869fc 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -5,12 +5,12 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 几何 +## [话题分类](../README.md) > 几何 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1266 | [访问所有点的最小时间](https://github.com/openset/leetcode/tree/master/problems/minimum-time-visiting-all-points) | [[几何](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1232 | [缀点成线](https://github.com/openset/leetcode/tree/master/problems/check-if-it-is-a-straight-line) | [[几何](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 963 | [最小面积矩形 II](https://github.com/openset/leetcode/tree/master/problems/minimum-area-rectangle-ii) | [[几何](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 892 | [三维形体的表面积](https://github.com/openset/leetcode/tree/master/problems/surface-area-of-3d-shapes) | [[几何](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 587 | [安装栅栏](https://github.com/openset/leetcode/tree/master/problems/erect-the-fence) | [[几何](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md)] | Hard | +| 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] | Easy | +| 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | +| 892 | [三维形体的表面积](../../problems/surface-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | +| 587 | [安装栅栏](../../problems/erect-the-fence) | [[几何](../geometry/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index 095c3a33a..7b4877e3f 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -5,44 +5,44 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 图 +## [话题分类](../README.md) > 图 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1267 | [统计参与通信的服务器](https://github.com/openset/leetcode/tree/master/problems/count-servers-that-communicate) | [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 1203 | [项目管理](https://github.com/openset/leetcode/tree/master/problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] | Hard | -| 1168 | [水资源分配优化](https://github.com/openset/leetcode/tree/master/problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Hard | -| 1162 | [地图分析](https://github.com/openset/leetcode/tree/master/problems/as-far-from-land-as-possible) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 1161 | [最大层内元素和](https://github.com/openset/leetcode/tree/master/problems/maximum-level-sum-of-a-binary-tree) | [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 1153 | [字符串转化](https://github.com/openset/leetcode/tree/master/problems/string-transforms-into-another-string) 🔒 | [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Hard | -| 1136 | [平行课程](https://github.com/openset/leetcode/tree/master/problems/parallel-courses) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1135 | [最低成本联通所有城市](https://github.com/openset/leetcode/tree/master/problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 1129 | [颜色交替的最短路径](https://github.com/openset/leetcode/tree/master/problems/shortest-path-with-alternating-colors) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 1102 | [得分最高的路径](https://github.com/openset/leetcode/tree/master/problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 1059 | [从始点到终点的所有路径](https://github.com/openset/leetcode/tree/master/problems/all-paths-from-source-lead-to-destination) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 1043 | [分隔数组以得到最大和](https://github.com/openset/leetcode/tree/master/problems/partition-array-for-maximum-sum) | [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 1042 | [不邻接植花](https://github.com/openset/leetcode/tree/master/problems/flower-planting-with-no-adjacent) | [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Easy | -| 997 | [找到小镇的法官](https://github.com/openset/leetcode/tree/master/problems/find-the-town-judge) | [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Easy | -| 996 | [正方形数组的数目](https://github.com/openset/leetcode/tree/master/problems/number-of-squareful-arrays) | [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 990 | [等式方程的可满足性](https://github.com/openset/leetcode/tree/master/problems/satisfiability-of-equality-equations) | [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 959 | [由斜杠划分区域](https://github.com/openset/leetcode/tree/master/problems/regions-cut-by-slashes) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 928 | [尽量减少恶意软件的传播 II](https://github.com/openset/leetcode/tree/master/problems/minimize-malware-spread-ii) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Hard | -| 854 | [相似度为 K 的字符串](https://github.com/openset/leetcode/tree/master/problems/k-similar-strings) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Hard | -| 841 | [钥匙和房间](https://github.com/openset/leetcode/tree/master/problems/keys-and-rooms) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 839 | [相似字符串组](https://github.com/openset/leetcode/tree/master/problems/similar-string-groups) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Hard | -| 802 | [找到最终的安全状态](https://github.com/openset/leetcode/tree/master/problems/find-eventual-safe-states) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 785 | [判断二分图](https://github.com/openset/leetcode/tree/master/problems/is-graph-bipartite) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 765 | [情侣牵手](https://github.com/openset/leetcode/tree/master/problems/couples-holding-hands) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Hard | -| 743 | [网络延迟时间](https://github.com/openset/leetcode/tree/master/problems/network-delay-time) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 685 | [冗余连接 II](https://github.com/openset/leetcode/tree/master/problems/redundant-connection-ii) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Hard | -| 684 | [冗余连接](https://github.com/openset/leetcode/tree/master/problems/redundant-connection) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 444 | [序列重建](https://github.com/openset/leetcode/tree/master/problems/sequence-reconstruction) 🔒 | [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] | Medium | -| 399 | [除法求值](https://github.com/openset/leetcode/tree/master/problems/evaluate-division) | [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 332 | [重新安排行程](https://github.com/openset/leetcode/tree/master/problems/reconstruct-itinerary) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 323 | [无向图中连通分量的数目](https://github.com/openset/leetcode/tree/master/problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 310 | [最小高度树](https://github.com/openset/leetcode/tree/master/problems/minimum-height-trees) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 269 | [火星词典](https://github.com/openset/leetcode/tree/master/problems/alien-dictionary) 🔒 | [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] | Hard | -| 261 | [以图判树](https://github.com/openset/leetcode/tree/master/problems/graph-valid-tree) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 210 | [课程表 II](https://github.com/openset/leetcode/tree/master/problems/course-schedule-ii) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] | Medium | -| 207 | [课程表](https://github.com/openset/leetcode/tree/master/problems/course-schedule) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] | Medium | -| 133 | [克隆图](https://github.com/openset/leetcode/tree/master/problems/clone-graph) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | +| 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | +| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[图](../graph/README.md)] | Medium | +| 1153 | [字符串转化](../../problems/string-transforms-into-another-string) 🔒 | [[图](../graph/README.md)] | Hard | +| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1135 | [最低成本联通所有城市](../../problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 1059 | [从始点到终点的所有路径](../../problems/all-paths-from-source-lead-to-destination) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1043 | [分隔数组以得到最大和](../../problems/partition-array-for-maximum-sum) | [[图](../graph/README.md)] | Medium | +| 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[图](../graph/README.md)] | Easy | +| 997 | [找到小镇的法官](../../problems/find-the-town-judge) | [[图](../graph/README.md)] | Easy | +| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 990 | [等式方程的可满足性](../../problems/satisfiability-of-equality-equations) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 854 | [相似度为 K 的字符串](../../problems/k-similar-strings) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Hard | +| 841 | [钥匙和房间](../../problems/keys-and-rooms) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 802 | [找到最终的安全状态](../../problems/find-eventual-safe-states) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 684 | [冗余连接](../../problems/redundant-connection) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 444 | [序列重建](../../problems/sequence-reconstruction) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 399 | [除法求值](../../problems/evaluate-division) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 310 | [最小高度树](../../problems/minimum-height-trees) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 212b7ddc1..7c819aa53 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -5,75 +5,75 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 贪心算法 +## [话题分类](../README.md) > 贪心算法 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1282 | [用户分组](https://github.com/openset/leetcode/tree/master/problems/group-the-people-given-the-group-size-they-belong-to) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 1276 | [不浪费原料的汉堡制作方案](https://github.com/openset/leetcode/tree/master/problems/number-of-burgers-with-no-waste-of-ingredients) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 1253 | [重构 2 行二进制矩阵](https://github.com/openset/leetcode/tree/master/problems/reconstruct-a-2-row-binary-matrix) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 1247 | [交换字符使得字符串相同](https://github.com/openset/leetcode/tree/master/problems/minimum-swaps-to-make-strings-equal) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1231 | [分享巧克力](https://github.com/openset/leetcode/tree/master/problems/divide-chocolate) 🔒 | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 1221 | [分割平衡字符串](https://github.com/openset/leetcode/tree/master/problems/split-a-string-in-balanced-strings) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 1217 | [玩筹码](https://github.com/openset/leetcode/tree/master/problems/play-with-chips) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 1196 | [最多可以买到的苹果数量](https://github.com/openset/leetcode/tree/master/problems/how-many-apples-can-you-put-into-the-basket) 🔒 | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Easy | -| 1167 | [连接棒材的最低费用](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-to-connect-sticks) 🔒 | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 1111 | [有效括号的嵌套深度](https://github.com/openset/leetcode/tree/master/problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 1094 | [拼车](https://github.com/openset/leetcode/tree/master/problems/car-pooling) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 1090 | [受标签影响的最大值](https://github.com/openset/leetcode/tree/master/problems/largest-values-from-labels) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 1058 | [最小化舍入误差以满足目标](https://github.com/openset/leetcode/tree/master/problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1057 | [校园自行车分配](https://github.com/openset/leetcode/tree/master/problems/campus-bikes) 🔒 | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] | Medium | -| 1055 | [形成字符串的最短路径](https://github.com/openset/leetcode/tree/master/problems/shortest-way-to-form-string) 🔒 | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1053 | [交换一次的先前排列](https://github.com/openset/leetcode/tree/master/problems/previous-permutation-with-one-swap) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 1046 | [最后一块石头的重量](https://github.com/openset/leetcode/tree/master/problems/last-stone-weight) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Easy | -| 1029 | [两地调度](https://github.com/openset/leetcode/tree/master/problems/two-city-scheduling) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Easy | -| 1007 | [行相等的最少多米诺旋转](https://github.com/openset/leetcode/tree/master/problems/minimum-domino-rotations-for-equal-row) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 1005 | [K 次取反后最大化的数组和](https://github.com/openset/leetcode/tree/master/problems/maximize-sum-of-array-after-k-negations) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Easy | -| 995 | [K 连续位的最小翻转次数](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-k-consecutive-bit-flips) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 991 | [坏了的计算器](https://github.com/openset/leetcode/tree/master/problems/broken-calculator) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 984 | [不含 AAA 或 BBB 的字符串](https://github.com/openset/leetcode/tree/master/problems/string-without-aaa-or-bbb) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 955 | [删列造序 II](https://github.com/openset/leetcode/tree/master/problems/delete-columns-to-make-sorted-ii) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 948 | [令牌放置](https://github.com/openset/leetcode/tree/master/problems/bag-of-tokens) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 944 | [删列造序](https://github.com/openset/leetcode/tree/master/problems/delete-columns-to-make-sorted) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Easy | -| 936 | [戳印序列](https://github.com/openset/leetcode/tree/master/problems/stamping-the-sequence) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 927 | [三等分](https://github.com/openset/leetcode/tree/master/problems/three-equal-parts) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 921 | [使括号有效的最少添加](https://github.com/openset/leetcode/tree/master/problems/minimum-add-to-make-parentheses-valid) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 910 | [最小差值 II](https://github.com/openset/leetcode/tree/master/problems/smallest-range-ii) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 881 | [救生艇](https://github.com/openset/leetcode/tree/master/problems/boats-to-save-people) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 874 | [模拟行走机器人](https://github.com/openset/leetcode/tree/master/problems/walking-robot-simulation) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Easy | -| 870 | [优势洗牌](https://github.com/openset/leetcode/tree/master/problems/advantage-shuffle) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 861 | [翻转矩阵后的得分](https://github.com/openset/leetcode/tree/master/problems/score-after-flipping-matrix) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 860 | [柠檬水找零](https://github.com/openset/leetcode/tree/master/problems/lemonade-change) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Easy | -| 842 | [将数组拆分成斐波那契序列](https://github.com/openset/leetcode/tree/master/problems/split-array-into-fibonacci-sequence) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 767 | [重构字符串](https://github.com/openset/leetcode/tree/master/problems/reorganize-string) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 765 | [情侣牵手](https://github.com/openset/leetcode/tree/master/problems/couples-holding-hands) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Hard | -| 763 | [划分字母区间](https://github.com/openset/leetcode/tree/master/problems/partition-labels) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 759 | [员工空闲时间](https://github.com/openset/leetcode/tree/master/problems/employee-free-time) 🔒 | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Hard | -| 757 | [ 设置交集大小至少为2](https://github.com/openset/leetcode/tree/master/problems/set-intersection-size-at-least-two) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Hard | -| 738 | [单调递增的数字](https://github.com/openset/leetcode/tree/master/problems/monotone-increasing-digits) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 714 | [买卖股票的最佳时机含手续费](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 659 | [分割数组为连续子序列](https://github.com/openset/leetcode/tree/master/problems/split-array-into-consecutive-subsequences) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 651 | [4键键盘](https://github.com/openset/leetcode/tree/master/problems/4-keys-keyboard) 🔒 | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 649 | [Dota2 参议院](https://github.com/openset/leetcode/tree/master/problems/dota2-senate) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 630 | [课程表 III](https://github.com/openset/leetcode/tree/master/problems/course-schedule-iii) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Hard | -| 621 | [任务调度器](https://github.com/openset/leetcode/tree/master/problems/task-scheduler) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 502 | [IPO](https://github.com/openset/leetcode/tree/master/problems/ipo) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Hard | -| 484 | [寻找排列](https://github.com/openset/leetcode/tree/master/problems/find-permutation) 🔒 | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 455 | [分发饼干](https://github.com/openset/leetcode/tree/master/problems/assign-cookies) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Easy | -| 452 | [用最少数量的箭引爆气球](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 435 | [无重叠区间](https://github.com/openset/leetcode/tree/master/problems/non-overlapping-intervals) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 406 | [根据身高重建队列](https://github.com/openset/leetcode/tree/master/problems/queue-reconstruction-by-height) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 402 | [移掉K位数字](https://github.com/openset/leetcode/tree/master/problems/remove-k-digits) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 392 | [判断子序列](https://github.com/openset/leetcode/tree/master/problems/is-subsequence) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Easy | -| 376 | [摆动序列](https://github.com/openset/leetcode/tree/master/problems/wiggle-subsequence) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 358 | [K 距离间隔重排字符串](https://github.com/openset/leetcode/tree/master/problems/rearrange-string-k-distance-apart) 🔒 | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Hard | -| 330 | [按要求补齐数组](https://github.com/openset/leetcode/tree/master/problems/patching-array) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Hard | -| 321 | [拼接最大数](https://github.com/openset/leetcode/tree/master/problems/create-maximum-number) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 316 | [去除重复字母](https://github.com/openset/leetcode/tree/master/problems/remove-duplicate-letters) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Hard | -| 253 | [会议室 II](https://github.com/openset/leetcode/tree/master/problems/meeting-rooms-ii) 🔒 | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] | Medium | -| 135 | [分发糖果](https://github.com/openset/leetcode/tree/master/problems/candy) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Hard | -| 134 | [加油站](https://github.com/openset/leetcode/tree/master/problems/gas-station) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 122 | [买卖股票的最佳时机 II](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock-ii) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 55 | [跳跃游戏](https://github.com/openset/leetcode/tree/master/problems/jump-game) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 45 | [跳跃游戏 II](https://github.com/openset/leetcode/tree/master/problems/jump-game-ii) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Hard | -| 44 | [通配符匹配](https://github.com/openset/leetcode/tree/master/problems/wildcard-matching) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | +| 1282 | [用户分组](../../problems/group-the-people-given-the-group-size-they-belong-to) | [[贪心算法](../greedy/README.md)] | Medium | +| 1276 | [不浪费原料的汉堡制作方案](../../problems/number-of-burgers-with-no-waste-of-ingredients) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 1253 | [重构 2 行二进制矩阵](../../problems/reconstruct-a-2-row-binary-matrix) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 1247 | [交换字符使得字符串相同](../../problems/minimum-swaps-to-make-strings-equal) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1231 | [分享巧克力](../../problems/divide-chocolate) 🔒 | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1221 | [分割平衡字符串](../../problems/split-a-string-in-balanced-strings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | +| 1217 | [玩筹码](../../problems/play-with-chips) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1196 | [最多可以买到的苹果数量](../../problems/how-many-apples-can-you-put-into-the-basket) 🔒 | [[贪心算法](../greedy/README.md)] | Easy | +| 1167 | [连接棒材的最低费用](../../problems/minimum-cost-to-connect-sticks) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | +| 1111 | [有效括号的嵌套深度](../../problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1094 | [拼车](../../problems/car-pooling) | [[贪心算法](../greedy/README.md)] | Medium | +| 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1057 | [校园自行车分配](../../problems/campus-bikes) 🔒 | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 1055 | [形成字符串的最短路径](../../problems/shortest-way-to-form-string) 🔒 | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1053 | [交换一次的先前排列](../../problems/previous-permutation-with-one-swap) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1046 | [最后一块石头的重量](../../problems/last-stone-weight) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Easy | +| 1029 | [两地调度](../../problems/two-city-scheduling) | [[贪心算法](../greedy/README.md)] | Easy | +| 1007 | [行相等的最少多米诺旋转](../../problems/minimum-domino-rotations-for-equal-row) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1005 | [K 次取反后最大化的数组和](../../problems/maximize-sum-of-array-after-k-negations) | [[贪心算法](../greedy/README.md)] | Easy | +| 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[贪心算法](../greedy/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 991 | [坏了的计算器](../../problems/broken-calculator) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 984 | [不含 AAA 或 BBB 的字符串](../../problems/string-without-aaa-or-bbb) | [[贪心算法](../greedy/README.md)] | Medium | +| 955 | [删列造序 II](../../problems/delete-columns-to-make-sorted-ii) | [[贪心算法](../greedy/README.md)] | Medium | +| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心算法](../greedy/README.md)] | Medium | +| 944 | [删列造序](../../problems/delete-columns-to-make-sorted) | [[贪心算法](../greedy/README.md)] | Easy | +| 936 | [戳印序列](../../problems/stamping-the-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | +| 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 921 | [使括号有效的最少添加](../../problems/minimum-add-to-make-parentheses-valid) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 910 | [最小差值 II](../../problems/smallest-range-ii) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 874 | [模拟行走机器人](../../problems/walking-robot-simulation) | [[贪心算法](../greedy/README.md)] | Easy | +| 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 861 | [翻转矩阵后的得分](../../problems/score-after-flipping-matrix) | [[贪心算法](../greedy/README.md)] | Medium | +| 860 | [柠檬水找零](../../problems/lemonade-change) | [[贪心算法](../greedy/README.md)] | Easy | +| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | +| 757 | [ 设置交集大小至少为2](../../problems/set-intersection-size-at-least-two) | [[贪心算法](../greedy/README.md)] | Hard | +| 738 | [单调递增的数字](../../problems/monotone-increasing-digits) | [[贪心算法](../greedy/README.md)] | Medium | +| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 651 | [4键键盘](../../problems/4-keys-keyboard) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 649 | [Dota2 参议院](../../problems/dota2-senate) | [[贪心算法](../greedy/README.md)] | Medium | +| 630 | [课程表 III](../../problems/course-schedule-iii) | [[贪心算法](../greedy/README.md)] | Hard | +| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | +| 502 | [IPO](../../problems/ipo) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | +| 484 | [寻找排列](../../problems/find-permutation) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | +| 455 | [分发饼干](../../problems/assign-cookies) | [[贪心算法](../greedy/README.md)] | Easy | +| 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心算法](../greedy/README.md)] | Medium | +| 435 | [无重叠区间](../../problems/non-overlapping-intervals) | [[贪心算法](../greedy/README.md)] | Medium | +| 406 | [根据身高重建队列](../../problems/queue-reconstruction-by-height) | [[贪心算法](../greedy/README.md)] | Medium | +| 402 | [移掉K位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 330 | [按要求补齐数组](../../problems/patching-array) | [[贪心算法](../greedy/README.md)] | Hard | +| 321 | [拼接最大数](../../problems/create-maximum-number) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Hard | +| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 135 | [分发糖果](../../problems/candy) | [[贪心算法](../greedy/README.md)] | Hard | +| 134 | [加油站](../../problems/gas-station) | [[贪心算法](../greedy/README.md)] | Medium | +| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 55 | [跳跃游戏](../../problems/jump-game) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Hard | +| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 4a94414ad..4d9098833 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -5,128 +5,128 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 哈希表 +## [话题分类](../README.md) > 哈希表 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1261 | [在受污染的二叉树中查找元素](https://github.com/openset/leetcode/tree/master/problems/find-elements-in-a-contaminated-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 1244 | [力扣排行榜](https://github.com/openset/leetcode/tree/master/problems/design-a-leaderboard) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 1224 | [最大相等频率](https://github.com/openset/leetcode/tree/master/problems/maximum-equal-frequency) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Hard | -| 1213 | [三个有序数组的交集](https://github.com/openset/leetcode/tree/master/problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 1207 | [独一无二的出现次数](https://github.com/openset/leetcode/tree/master/problems/unique-number-of-occurrences) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 1198 | [找出所有行中最小公共元素](https://github.com/openset/leetcode/tree/master/problems/find-smallest-common-element-in-all-rows) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 1189 | [“气球” 的最大数量](https://github.com/openset/leetcode/tree/master/problems/maximum-number-of-balloons) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 1178 | [猜字谜](https://github.com/openset/leetcode/tree/master/problems/number-of-valid-words-for-each-puzzle) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Hard | -| 1166 | [设计文件系统](https://github.com/openset/leetcode/tree/master/problems/design-file-system) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 1160 | [拼写单词](https://github.com/openset/leetcode/tree/master/problems/find-words-that-can-be-formed-by-characters) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 1152 | [用户网站访问行为分析](https://github.com/openset/leetcode/tree/master/problems/analyze-user-website-visit-pattern) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 1138 | [字母板上的路径](https://github.com/openset/leetcode/tree/master/problems/alphabet-board-path) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1133 | [最大唯一数](https://github.com/openset/leetcode/tree/master/problems/largest-unique-number) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 1090 | [受标签影响的最大值](https://github.com/openset/leetcode/tree/master/problems/largest-values-from-labels) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 1086 | [前五科的均分](https://github.com/openset/leetcode/tree/master/problems/high-five) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 1078 | [Bigram 分词](https://github.com/openset/leetcode/tree/master/problems/occurrences-after-bigram) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 1072 | [按列翻转得到最大值等行数](https://github.com/openset/leetcode/tree/master/problems/flip-columns-for-maximum-number-of-equal-rows) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 1048 | [最长字符串链](https://github.com/openset/leetcode/tree/master/problems/longest-string-chain) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1044 | [最长重复子串](https://github.com/openset/leetcode/tree/master/problems/longest-duplicate-substring) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 1002 | [查找常用字符](https://github.com/openset/leetcode/tree/master/problems/find-common-characters) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 1001 | [网格照明](https://github.com/openset/leetcode/tree/master/problems/grid-illumination) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Hard | -| 992 | [K 个不同整数的子数组](https://github.com/openset/leetcode/tree/master/problems/subarrays-with-k-different-integers) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 987 | [二叉树的垂序遍历](https://github.com/openset/leetcode/tree/master/problems/vertical-order-traversal-of-a-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 981 | [基于时间的键值存储](https://github.com/openset/leetcode/tree/master/problems/time-based-key-value-store) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 974 | [和可被 K 整除的子数组](https://github.com/openset/leetcode/tree/master/problems/subarray-sums-divisible-by-k) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 970 | [强整数](https://github.com/openset/leetcode/tree/master/problems/powerful-integers) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 966 | [元音拼写检查器](https://github.com/openset/leetcode/tree/master/problems/vowel-spellchecker) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 961 | [重复 N 次的元素](https://github.com/openset/leetcode/tree/master/problems/n-repeated-element-in-size-2n-array) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 957 | [N 天后的牢房](https://github.com/openset/leetcode/tree/master/problems/prison-cells-after-n-days) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 954 | [二倍数对数组](https://github.com/openset/leetcode/tree/master/problems/array-of-doubled-pairs) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 953 | [验证外星语词典](https://github.com/openset/leetcode/tree/master/problems/verifying-an-alien-dictionary) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 939 | [最小面积矩形](https://github.com/openset/leetcode/tree/master/problems/minimum-area-rectangle) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 930 | [和相同的二元子数组](https://github.com/openset/leetcode/tree/master/problems/binary-subarrays-with-sum) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 895 | [最大频率栈](https://github.com/openset/leetcode/tree/master/problems/maximum-frequency-stack) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Hard | -| 884 | [两句话中的不常见单词](https://github.com/openset/leetcode/tree/master/problems/uncommon-words-from-two-sentences) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 811 | [子域名访问计数](https://github.com/openset/leetcode/tree/master/problems/subdomain-visit-count) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 781 | [森林中的兔子](https://github.com/openset/leetcode/tree/master/problems/rabbits-in-forest) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 771 | [宝石与石头](https://github.com/openset/leetcode/tree/master/problems/jewels-and-stones) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 770 | [基本计算器 IV](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iv) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 760 | [找出变位映射](https://github.com/openset/leetcode/tree/master/problems/find-anagram-mappings) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 748 | [最短完整词](https://github.com/openset/leetcode/tree/master/problems/shortest-completing-word) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 739 | [每日温度](https://github.com/openset/leetcode/tree/master/problems/daily-temperatures) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 734 | [句子相似性](https://github.com/openset/leetcode/tree/master/problems/sentence-similarity) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 726 | [原子的数量](https://github.com/openset/leetcode/tree/master/problems/number-of-atoms) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Hard | -| 720 | [词典中最长的单词](https://github.com/openset/leetcode/tree/master/problems/longest-word-in-dictionary) | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 718 | [最长重复子数组](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-repeated-subarray) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 711 | [不同岛屿的数量 II](https://github.com/openset/leetcode/tree/master/problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Hard | -| 710 | [黑名单中的随机数](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-blacklist) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] | Hard | -| 706 | [设计哈希映射](https://github.com/openset/leetcode/tree/master/problems/design-hashmap) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 705 | [设计哈希集合](https://github.com/openset/leetcode/tree/master/problems/design-hashset) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 694 | [不同岛屿的数量](https://github.com/openset/leetcode/tree/master/problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 692 | [前K个高频单词](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-words) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 690 | [员工的重要性](https://github.com/openset/leetcode/tree/master/problems/employee-importance) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 676 | [实现一个魔法字典](https://github.com/openset/leetcode/tree/master/problems/implement-magic-dictionary) | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 648 | [单词替换](https://github.com/openset/leetcode/tree/master/problems/replace-words) | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 645 | [错误的集合](https://github.com/openset/leetcode/tree/master/problems/set-mismatch) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 632 | [最小区间](https://github.com/openset/leetcode/tree/master/problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 624 | [数组列表中的最大距离](https://github.com/openset/leetcode/tree/master/problems/maximum-distance-in-arrays) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 609 | [在系统中查找重复文件](https://github.com/openset/leetcode/tree/master/problems/find-duplicate-file-in-system) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 599 | [两个列表的最小索引总和](https://github.com/openset/leetcode/tree/master/problems/minimum-index-sum-of-two-lists) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 594 | [最长和谐子序列](https://github.com/openset/leetcode/tree/master/problems/longest-harmonious-subsequence) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 575 | [分糖果](https://github.com/openset/leetcode/tree/master/problems/distribute-candies) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 560 | [和为K的子数组](https://github.com/openset/leetcode/tree/master/problems/subarray-sum-equals-k) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 554 | [砖墙](https://github.com/openset/leetcode/tree/master/problems/brick-wall) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 535 | [TinyURL 的加密与解密](https://github.com/openset/leetcode/tree/master/problems/encode-and-decode-tinyurl) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 525 | [连续数组](https://github.com/openset/leetcode/tree/master/problems/contiguous-array) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 508 | [出现次数最多的子树元素和](https://github.com/openset/leetcode/tree/master/problems/most-frequent-subtree-sum) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 500 | [键盘行](https://github.com/openset/leetcode/tree/master/problems/keyboard-row) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 463 | [岛屿的周长](https://github.com/openset/leetcode/tree/master/problems/island-perimeter) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 454 | [四数相加 II](https://github.com/openset/leetcode/tree/master/problems/4sum-ii) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 451 | [根据字符出现频率排序](https://github.com/openset/leetcode/tree/master/problems/sort-characters-by-frequency) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 447 | [回旋镖的数量](https://github.com/openset/leetcode/tree/master/problems/number-of-boomerangs) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 438 | [找到字符串中所有字母异位词](https://github.com/openset/leetcode/tree/master/problems/find-all-anagrams-in-a-string) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 409 | [最长回文串](https://github.com/openset/leetcode/tree/master/problems/longest-palindrome) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 389 | [找不同](https://github.com/openset/leetcode/tree/master/problems/find-the-difference) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 387 | [字符串中的第一个唯一字符](https://github.com/openset/leetcode/tree/master/problems/first-unique-character-in-a-string) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](https://github.com/openset/leetcode/tree/master/problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Hard | -| 380 | [常数时间插入、删除和获取随机元素](https://github.com/openset/leetcode/tree/master/problems/insert-delete-getrandom-o1) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 359 | [日志速率限制器](https://github.com/openset/leetcode/tree/master/problems/logger-rate-limiter) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 358 | [K 距离间隔重排字符串](https://github.com/openset/leetcode/tree/master/problems/rearrange-string-k-distance-apart) 🔒 | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Hard | -| 356 | [直线镜像](https://github.com/openset/leetcode/tree/master/problems/line-reflection) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 355 | [设计推特](https://github.com/openset/leetcode/tree/master/problems/design-twitter) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 350 | [两个数组的交集 II](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays-ii) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 347 | [前 K 个高频元素](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-elements) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 340 | [至多包含 K 个不同字符的最长子串](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 336 | [回文对](https://github.com/openset/leetcode/tree/master/problems/palindrome-pairs) | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 325 | [和等于 k 的最长子数组长度](https://github.com/openset/leetcode/tree/master/problems/maximum-size-subarray-sum-equals-k) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 314 | [二叉树的垂直遍历](https://github.com/openset/leetcode/tree/master/problems/binary-tree-vertical-order-traversal) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 311 | [稀疏矩阵的乘法](https://github.com/openset/leetcode/tree/master/problems/sparse-matrix-multiplication) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 299 | [猜数字游戏](https://github.com/openset/leetcode/tree/master/problems/bulls-and-cows) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 290 | [单词规律](https://github.com/openset/leetcode/tree/master/problems/word-pattern) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 288 | [单词的唯一缩写](https://github.com/openset/leetcode/tree/master/problems/unique-word-abbreviation) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 274 | [H指数](https://github.com/openset/leetcode/tree/master/problems/h-index) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 266 | [回文排列](https://github.com/openset/leetcode/tree/master/problems/palindrome-permutation) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 249 | [移位字符串分组](https://github.com/openset/leetcode/tree/master/problems/group-shifted-strings) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 246 | [中心对称数](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 244 | [最短单词距离 II](https://github.com/openset/leetcode/tree/master/problems/shortest-word-distance-ii) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 242 | [有效的字母异位词](https://github.com/openset/leetcode/tree/master/problems/valid-anagram) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 219 | [存在重复元素 II](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 217 | [存在重复元素](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 205 | [同构字符串](https://github.com/openset/leetcode/tree/master/problems/isomorphic-strings) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 204 | [计数质数](https://github.com/openset/leetcode/tree/master/problems/count-primes) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 202 | [快乐数](https://github.com/openset/leetcode/tree/master/problems/happy-number) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 187 | [重复的DNA序列](https://github.com/openset/leetcode/tree/master/problems/repeated-dna-sequences) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 170 | [两数之和 III - 数据结构设计](https://github.com/openset/leetcode/tree/master/problems/two-sum-iii-data-structure-design) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 166 | [分数到小数](https://github.com/openset/leetcode/tree/master/problems/fraction-to-recurring-decimal) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 159 | [至多包含两个不同字符的最长子串](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 149 | [直线上最多的点数](https://github.com/openset/leetcode/tree/master/problems/max-points-on-a-line) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 138 | [复制带随机指针的链表](https://github.com/openset/leetcode/tree/master/problems/copy-list-with-random-pointer) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 136 | [只出现一次的数字](https://github.com/openset/leetcode/tree/master/problems/single-number) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 94 | [二叉树的中序遍历](https://github.com/openset/leetcode/tree/master/problems/binary-tree-inorder-traversal) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 85 | [最大矩形](https://github.com/openset/leetcode/tree/master/problems/maximal-rectangle) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 76 | [最小覆盖子串](https://github.com/openset/leetcode/tree/master/problems/minimum-window-substring) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 49 | [字母异位词分组](https://github.com/openset/leetcode/tree/master/problems/group-anagrams) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 37 | [解数独](https://github.com/openset/leetcode/tree/master/problems/sudoku-solver) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 36 | [有效的数独](https://github.com/openset/leetcode/tree/master/problems/valid-sudoku) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 30 | [串联所有单词的子串](https://github.com/openset/leetcode/tree/master/problems/substring-with-concatenation-of-all-words) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 18 | [四数之和](https://github.com/openset/leetcode/tree/master/problems/4sum) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 3 | [无重复字符的最长子串](https://github.com/openset/leetcode/tree/master/problems/longest-substring-without-repeating-characters) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 1 | [两数之和](https://github.com/openset/leetcode/tree/master/problems/two-sum) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | +| 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1224 | [最大相等频率](../../problems/maximum-equal-frequency) | [[哈希表](../hash-table/README.md)] | Hard | +| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1207 | [独一无二的出现次数](../../problems/unique-number-of-occurrences) | [[哈希表](../hash-table/README.md)] | Easy | +| 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1189 | [“气球” 的最大数量](../../problems/maximum-number-of-balloons) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1178 | [猜字谜](../../problems/number-of-valid-words-for-each-puzzle) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1160 | [拼写单词](../../problems/find-words-that-can-be-formed-by-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1138 | [字母板上的路径](../../problems/alphabet-board-path) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1133 | [最大唯一数](../../problems/largest-unique-number) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1078 | [Bigram 分词](../../problems/occurrences-after-bigram) | [[哈希表](../hash-table/README.md)] | Easy | +| 1072 | [按列翻转得到最大值等行数](../../problems/flip-columns-for-maximum-number-of-equal-rows) | [[哈希表](../hash-table/README.md)] | Medium | +| 1048 | [最长字符串链](../../problems/longest-string-chain) | [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1001 | [网格照明](../../problems/grid-illumination) | [[哈希表](../hash-table/README.md)] | Hard | +| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 974 | [和可被 K 整除的子数组](../../problems/subarray-sums-divisible-by-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 970 | [强整数](../../problems/powerful-integers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 961 | [重复 N 次的元素](../../problems/n-repeated-element-in-size-2n-array) | [[哈希表](../hash-table/README.md)] | Easy | +| 957 | [N 天后的牢房](../../problems/prison-cells-after-n-days) | [[哈希表](../hash-table/README.md)] | Medium | +| 954 | [二倍数对数组](../../problems/array-of-doubled-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 953 | [验证外星语词典](../../problems/verifying-an-alien-dictionary) | [[哈希表](../hash-table/README.md)] | Easy | +| 939 | [最小面积矩形](../../problems/minimum-area-rectangle) | [[哈希表](../hash-table/README.md)] | Medium | +| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 884 | [两句话中的不常见单词](../../problems/uncommon-words-from-two-sentences) | [[哈希表](../hash-table/README.md)] | Easy | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[哈希表](../hash-table/README.md)] | Easy | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 771 | [宝石与石头](../../problems/jewels-and-stones) | [[哈希表](../hash-table/README.md)] | Easy | +| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 760 | [找出变位映射](../../problems/find-anagram-mappings) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | +| 748 | [最短完整词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] | Easy | +| 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | +| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[堆](../heap/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 676 | [实现一个魔法字典](../../problems/implement-magic-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 648 | [单词替换](../../problems/replace-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 645 | [错误的集合](../../problems/set-mismatch) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 599 | [两个列表的最小索引总和](../../problems/minimum-index-sum-of-two-lists) | [[哈希表](../hash-table/README.md)] | Easy | +| 594 | [最长和谐子序列](../../problems/longest-harmonious-subsequence) | [[哈希表](../hash-table/README.md)] | Easy | +| 575 | [分糖果](../../problems/distribute-candies) | [[哈希表](../hash-table/README.md)] | Easy | +| 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 554 | [砖墙](../../problems/brick-wall) | [[哈希表](../hash-table/README.md)] | Medium | +| 535 | [TinyURL 的加密与解密](../../problems/encode-and-decode-tinyurl) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 525 | [连续数组](../../problems/contiguous-array) | [[哈希表](../hash-table/README.md)] | Medium | +| 508 | [出现次数最多的子树元素和](../../problems/most-frequent-subtree-sum) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 500 | [键盘行](../../problems/keyboard-row) | [[哈希表](../hash-table/README.md)] | Easy | +| 463 | [岛屿的周长](../../problems/island-perimeter) | [[哈希表](../hash-table/README.md)] | Easy | +| 454 | [四数相加 II](../../problems/4sum-ii) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 447 | [回旋镖的数量](../../problems/number-of-boomerangs) | [[哈希表](../hash-table/README.md)] | Easy | +| 438 | [找到字符串中所有字母异位词](../../problems/find-all-anagrams-in-a-string) | [[哈希表](../hash-table/README.md)] | Medium | +| 409 | [最长回文串](../../problems/longest-palindrome) | [[哈希表](../hash-table/README.md)] | Easy | +| 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 356 | [直线镜像](../../problems/line-reflection) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 325 | [和等于 k 的最长子数组长度](../../problems/maximum-size-subarray-sum-equals-k) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | +| 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | +| 311 | [稀疏矩阵的乘法](../../problems/sparse-matrix-multiplication) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | +| 299 | [猜数字游戏](../../problems/bulls-and-cows) | [[哈希表](../hash-table/README.md)] | Easy | +| 290 | [单词规律](../../problems/word-pattern) | [[哈希表](../hash-table/README.md)] | Easy | +| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 274 | [H指数](../../problems/h-index) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 266 | [回文排列](../../problems/palindrome-permutation) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | +| 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 246 | [中心对称数](../../problems/strobogrammatic-number) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 242 | [有效的字母异位词](../../problems/valid-anagram) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 219 | [存在重复元素 II](../../problems/contains-duplicate-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 217 | [存在重复元素](../../problems/contains-duplicate) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 205 | [同构字符串](../../problems/isomorphic-strings) | [[哈希表](../hash-table/README.md)] | Easy | +| 204 | [计数质数](../../problems/count-primes) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 202 | [快乐数](../../problems/happy-number) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 187 | [重复的DNA序列](../../problems/repeated-dna-sequences) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 138 | [复制带随机指针的链表](../../problems/copy-list-with-random-pointer) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 136 | [只出现一次的数字](../../problems/single-number) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 37 | [解数独](../../problems/sudoku-solver) | [[哈希表](../hash-table/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 36 | [有效的数独](../../problems/valid-sudoku) | [[哈希表](../hash-table/README.md)] | Medium | +| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1 | [两数之和](../../problems/two-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/heap/README.md b/tag/heap/README.md index fc75ef978..bb21437a3 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -5,41 +5,41 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 堆 +## [话题分类](../README.md) > 堆 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1054 | [距离相等的条形码](https://github.com/openset/leetcode/tree/master/problems/distant-barcodes) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] | Medium | -| 1046 | [最后一块石头的重量](https://github.com/openset/leetcode/tree/master/problems/last-stone-weight) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Easy | -| 973 | [最接近原点的 K 个点](https://github.com/openset/leetcode/tree/master/problems/k-closest-points-to-origin) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Medium | -| 882 | [细分图中的可到达结点](https://github.com/openset/leetcode/tree/master/problems/reachable-nodes-in-subdivided-graph) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] | Hard | -| 871 | [最低加油次数](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-refueling-stops) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 864 | [获取所有钥匙的最短路径](https://github.com/openset/leetcode/tree/master/problems/shortest-path-to-get-all-keys) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | -| 857 | [雇佣 K 名工人的最低成本](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-to-hire-k-workers) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] | Hard | -| 818 | [赛车](https://github.com/openset/leetcode/tree/master/problems/race-car) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 787 | [K 站中转内最便宜的航班](https://github.com/openset/leetcode/tree/master/problems/cheapest-flights-within-k-stops) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 786 | [第 K 个最小的素数分数](https://github.com/openset/leetcode/tree/master/problems/k-th-smallest-prime-fraction) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 778 | [水位上升的泳池中游泳](https://github.com/openset/leetcode/tree/master/problems/swim-in-rising-water) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 767 | [重构字符串](https://github.com/openset/leetcode/tree/master/problems/reorganize-string) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 759 | [员工空闲时间](https://github.com/openset/leetcode/tree/master/problems/employee-free-time) 🔒 | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Hard | -| 743 | [网络延迟时间](https://github.com/openset/leetcode/tree/master/problems/network-delay-time) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 719 | [找出第 k 小的距离对](https://github.com/openset/leetcode/tree/master/problems/find-k-th-smallest-pair-distance) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 703 | [数据流中的第K大元素](https://github.com/openset/leetcode/tree/master/problems/kth-largest-element-in-a-stream) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] | Easy | -| 692 | [前K个高频单词](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-words) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 659 | [分割数组为连续子序列](https://github.com/openset/leetcode/tree/master/problems/split-array-into-consecutive-subsequences) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 502 | [IPO](https://github.com/openset/leetcode/tree/master/problems/ipo) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Hard | -| 451 | [根据字符出现频率排序](https://github.com/openset/leetcode/tree/master/problems/sort-characters-by-frequency) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 407 | [接雨水 II](https://github.com/openset/leetcode/tree/master/problems/trapping-rain-water-ii) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Hard | -| 378 | [有序矩阵中第K小的元素](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-element-in-a-sorted-matrix) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 373 | [查找和最小的K对数字](https://github.com/openset/leetcode/tree/master/problems/find-k-pairs-with-smallest-sums) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] | Medium | -| 358 | [K 距离间隔重排字符串](https://github.com/openset/leetcode/tree/master/problems/rearrange-string-k-distance-apart) 🔒 | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Hard | -| 355 | [设计推特](https://github.com/openset/leetcode/tree/master/problems/design-twitter) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 347 | [前 K 个高频元素](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-elements) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 313 | [超级丑数](https://github.com/openset/leetcode/tree/master/problems/super-ugly-number) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 295 | [数据流的中位数](https://github.com/openset/leetcode/tree/master/problems/find-median-from-data-stream) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Hard | -| 264 | [丑数 II](https://github.com/openset/leetcode/tree/master/problems/ugly-number-ii) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 253 | [会议室 II](https://github.com/openset/leetcode/tree/master/problems/meeting-rooms-ii) 🔒 | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] | Medium | -| 239 | [滑动窗口最大值](https://github.com/openset/leetcode/tree/master/problems/sliding-window-maximum) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 218 | [天际线问题](https://github.com/openset/leetcode/tree/master/problems/the-skyline-problem) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] | Hard | -| 215 | [数组中的第K个最大元素](https://github.com/openset/leetcode/tree/master/problems/kth-largest-element-in-an-array) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Medium | -| 23 | [合并K个排序链表](https://github.com/openset/leetcode/tree/master/problems/merge-k-sorted-lists) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | +| 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] | Medium | +| 1046 | [最后一块石头的重量](../../problems/last-stone-weight) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Easy | +| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 882 | [细分图中的可到达结点](../../problems/reachable-nodes-in-subdivided-graph) | [[堆](../heap/README.md)] | Hard | +| 871 | [最低加油次数](../../problems/minimum-number-of-refueling-stops) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 864 | [获取所有钥匙的最短路径](../../problems/shortest-path-to-get-all-keys) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[堆](../heap/README.md)] | Hard | +| 818 | [赛车](../../problems/race-car) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | +| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 703 | [数据流中的第K大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] | Easy | +| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[堆](../heap/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 502 | [IPO](../../problems/ipo) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | +| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 378 | [有序矩阵中第K小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 373 | [查找和最小的K对数字](../../problems/find-k-pairs-with-smallest-sums) | [[堆](../heap/README.md)] | Medium | +| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 313 | [超级丑数](../../problems/super-ugly-number) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | +| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard | +| 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | +| 215 | [数组中的第K个最大元素](../../problems/kth-largest-element-in-an-array) | [[堆](../heap/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 23 | [合并K个排序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md index d7e128c21..b72c19577 100644 --- a/tag/line-sweep/README.md +++ b/tag/line-sweep/README.md @@ -5,13 +5,13 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > Line Sweep +## [话题分类](../README.md) > Line Sweep | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1288 | [删除被覆盖区间](https://github.com/openset/leetcode/tree/master/problems/remove-covered-intervals) | [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] | Medium | -| 1272 | [删除区间](https://github.com/openset/leetcode/tree/master/problems/remove-interval) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] | Medium | -| 1229 | [安排会议日程](https://github.com/openset/leetcode/tree/master/problems/meeting-scheduler) 🔒 | [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] | Medium | -| 850 | [矩形面积 II](https://github.com/openset/leetcode/tree/master/problems/rectangle-area-ii) | [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] | Hard | -| 391 | [完美矩形](https://github.com/openset/leetcode/tree/master/problems/perfect-rectangle) | [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] | Hard | -| 218 | [天际线问题](https://github.com/openset/leetcode/tree/master/problems/the-skyline-problem) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] | Hard | +| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[Line Sweep](../line-sweep/README.md)] | Medium | +| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | +| 391 | [完美矩形](../../problems/perfect-rectangle) | [[Line Sweep](../line-sweep/README.md)] | Hard | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index 1549bc29b..20c3c937c 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -5,44 +5,44 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 链表 +## [话题分类](../README.md) > 链表 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1290 | [二进制链表转整数](https://github.com/openset/leetcode/tree/master/problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Easy | -| 1171 | [从链表中删去总和值为零的连续节点](https://github.com/openset/leetcode/tree/master/problems/remove-zero-sum-consecutive-nodes-from-linked-list) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 1019 | [链表中的下一个更大节点](https://github.com/openset/leetcode/tree/master/problems/next-greater-node-in-linked-list) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 876 | [链表的中间结点](https://github.com/openset/leetcode/tree/master/problems/middle-of-the-linked-list) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Easy | -| 817 | [链表组件](https://github.com/openset/leetcode/tree/master/problems/linked-list-components) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 725 | [分隔链表](https://github.com/openset/leetcode/tree/master/problems/split-linked-list-in-parts) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 708 | [循环有序列表的插入](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-sorted-circular-linked-list) 🔒 | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 707 | [设计链表](https://github.com/openset/leetcode/tree/master/problems/design-linked-list) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 445 | [两数相加 II](https://github.com/openset/leetcode/tree/master/problems/add-two-numbers-ii) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 430 | [扁平化多级双向链表](https://github.com/openset/leetcode/tree/master/problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 426 | [将二叉搜索树转化为排序的双向链表](https://github.com/openset/leetcode/tree/master/problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Medium | -| 379 | [电话目录管理系统](https://github.com/openset/leetcode/tree/master/problems/design-phone-directory) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 369 | [给单链表加一](https://github.com/openset/leetcode/tree/master/problems/plus-one-linked-list) 🔒 | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 328 | [奇偶链表](https://github.com/openset/leetcode/tree/master/problems/odd-even-linked-list) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 237 | [删除链表中的节点](https://github.com/openset/leetcode/tree/master/problems/delete-node-in-a-linked-list) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Easy | -| 234 | [回文链表](https://github.com/openset/leetcode/tree/master/problems/palindrome-linked-list) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 206 | [反转链表](https://github.com/openset/leetcode/tree/master/problems/reverse-linked-list) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Easy | -| 203 | [移除链表元素](https://github.com/openset/leetcode/tree/master/problems/remove-linked-list-elements) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Easy | -| 160 | [相交链表](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-linked-lists) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Easy | -| 148 | [排序链表](https://github.com/openset/leetcode/tree/master/problems/sort-list) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 147 | [对链表进行插入排序](https://github.com/openset/leetcode/tree/master/problems/insertion-sort-list) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 143 | [重排链表](https://github.com/openset/leetcode/tree/master/problems/reorder-list) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 142 | [环形链表 II](https://github.com/openset/leetcode/tree/master/problems/linked-list-cycle-ii) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 141 | [环形链表](https://github.com/openset/leetcode/tree/master/problems/linked-list-cycle) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 138 | [复制带随机指针的链表](https://github.com/openset/leetcode/tree/master/problems/copy-list-with-random-pointer) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 109 | [有序链表转换二叉搜索树](https://github.com/openset/leetcode/tree/master/problems/convert-sorted-list-to-binary-search-tree) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 92 | [反转链表 II](https://github.com/openset/leetcode/tree/master/problems/reverse-linked-list-ii) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 86 | [分隔链表](https://github.com/openset/leetcode/tree/master/problems/partition-list) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 83 | [删除排序链表中的重复元素](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-list) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Easy | -| 82 | [删除排序链表中的重复元素 II](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-list-ii) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 61 | [旋转链表](https://github.com/openset/leetcode/tree/master/problems/rotate-list) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 25 | [K 个一组翻转链表](https://github.com/openset/leetcode/tree/master/problems/reverse-nodes-in-k-group) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Hard | -| 24 | [两两交换链表中的节点](https://github.com/openset/leetcode/tree/master/problems/swap-nodes-in-pairs) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 23 | [合并K个排序链表](https://github.com/openset/leetcode/tree/master/problems/merge-k-sorted-lists) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 21 | [合并两个有序链表](https://github.com/openset/leetcode/tree/master/problems/merge-two-sorted-lists) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Easy | -| 19 | [删除链表的倒数第N个节点](https://github.com/openset/leetcode/tree/master/problems/remove-nth-node-from-end-of-list) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 2 | [两数相加](https://github.com/openset/leetcode/tree/master/problems/add-two-numbers) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | +| 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)] | Easy | +| 1171 | [从链表中删去总和值为零的连续节点](../../problems/remove-zero-sum-consecutive-nodes-from-linked-list) | [[链表](../linked-list/README.md)] | Medium | +| 1019 | [链表中的下一个更大节点](../../problems/next-greater-node-in-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 876 | [链表的中间结点](../../problems/middle-of-the-linked-list) | [[链表](../linked-list/README.md)] | Easy | +| 817 | [链表组件](../../problems/linked-list-components) | [[链表](../linked-list/README.md)] | Medium | +| 725 | [分隔链表](../../problems/split-linked-list-in-parts) | [[链表](../linked-list/README.md)] | Medium | +| 708 | [循环有序列表的插入](../../problems/insert-into-a-sorted-circular-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Medium | +| 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 445 | [两数相加 II](../../problems/add-two-numbers-ii) | [[链表](../linked-list/README.md)] | Medium | +| 430 | [扁平化多级双向链表](../../problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Medium | +| 328 | [奇偶链表](../../problems/odd-even-linked-list) | [[链表](../linked-list/README.md)] | Medium | +| 237 | [删除链表中的节点](../../problems/delete-node-in-a-linked-list) | [[链表](../linked-list/README.md)] | Easy | +| 234 | [回文链表](../../problems/palindrome-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 206 | [反转链表](../../problems/reverse-linked-list) | [[链表](../linked-list/README.md)] | Easy | +| 203 | [移除链表元素](../../problems/remove-linked-list-elements) | [[链表](../linked-list/README.md)] | Easy | +| 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[链表](../linked-list/README.md)] | Easy | +| 148 | [排序链表](../../problems/sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 143 | [重排链表](../../problems/reorder-list) | [[链表](../linked-list/README.md)] | Medium | +| 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 141 | [环形链表](../../problems/linked-list-cycle) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 138 | [复制带随机指针的链表](../../problems/copy-list-with-random-pointer) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 92 | [反转链表 II](../../problems/reverse-linked-list-ii) | [[链表](../linked-list/README.md)] | Medium | +| 86 | [分隔链表](../../problems/partition-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 83 | [删除排序链表中的重复元素](../../problems/remove-duplicates-from-sorted-list) | [[链表](../linked-list/README.md)] | Easy | +| 82 | [删除排序链表中的重复元素 II](../../problems/remove-duplicates-from-sorted-list-ii) | [[链表](../linked-list/README.md)] | Medium | +| 61 | [旋转链表](../../problems/rotate-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 25 | [K 个一组翻转链表](../../problems/reverse-nodes-in-k-group) | [[链表](../linked-list/README.md)] | Hard | +| 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[链表](../linked-list/README.md)] | Medium | +| 23 | [合并K个排序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[链表](../linked-list/README.md)] | Easy | +| 19 | [删除链表的倒数第N个节点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2 | [两数相加](../../problems/add-two-numbers) | [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index eedbb5392..2ca06bfff 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -5,170 +5,170 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 数学 +## [话题分类](../README.md) > 数学 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1281 | [整数的各位积和之差](https://github.com/openset/leetcode/tree/master/problems/subtract-the-product-and-sum-of-digits-of-an-integer) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 1276 | [不浪费原料的汉堡制作方案](https://github.com/openset/leetcode/tree/master/problems/number-of-burgers-with-no-waste-of-ingredients) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 1272 | [删除区间](https://github.com/openset/leetcode/tree/master/problems/remove-interval) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] | Medium | -| 1271 | [十六进制魔术数字](https://github.com/openset/leetcode/tree/master/problems/hexspeak) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 1259 | [不相交的握手](https://github.com/openset/leetcode/tree/master/problems/handshakes-that-dont-cross) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1256 | [加密数字](https://github.com/openset/leetcode/tree/master/problems/encode-number) 🔒 | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 1253 | [重构 2 行二进制矩阵](https://github.com/openset/leetcode/tree/master/problems/reconstruct-a-2-row-binary-matrix) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 1250 | [检查「好数组」](https://github.com/openset/leetcode/tree/master/problems/check-if-it-is-a-good-array) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 1238 | [循环码排列](https://github.com/openset/leetcode/tree/master/problems/circular-permutation-in-binary-representation) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 1237 | [找出给定方程的正整数解](https://github.com/openset/leetcode/tree/master/problems/find-positive-integer-solution-for-a-given-equation) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 1232 | [缀点成线](https://github.com/openset/leetcode/tree/master/problems/check-if-it-is-a-straight-line) | [[几何](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 1230 | [抛掷硬币](https://github.com/openset/leetcode/tree/master/problems/toss-strange-coins) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1228 | [等差数列中缺失的数字](https://github.com/openset/leetcode/tree/master/problems/missing-number-in-arithmetic-progression) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 1227 | [飞机座位分配概率](https://github.com/openset/leetcode/tree/master/problems/airplane-seat-assignment-probability) | [[脑筋急转弯](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1218 | [最长定差子序列](https://github.com/openset/leetcode/tree/master/problems/longest-arithmetic-subsequence-of-given-difference) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1217 | [玩筹码](https://github.com/openset/leetcode/tree/master/problems/play-with-chips) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 1201 | [丑数 III](https://github.com/openset/leetcode/tree/master/problems/ugly-number-iii) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 1199 | [建造街区的最短时间](https://github.com/openset/leetcode/tree/master/problems/minimum-time-to-build-blocks) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1183 | [矩阵中 1 的最大数量](https://github.com/openset/leetcode/tree/master/problems/maximum-number-of-ones) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 1180 | [统计只含单一字母的子串](https://github.com/openset/leetcode/tree/master/problems/count-substrings-with-only-one-distinct-letter) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 1175 | [质数排列](https://github.com/openset/leetcode/tree/master/problems/prime-arrangements) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 1154 | [一年中的第几天](https://github.com/openset/leetcode/tree/master/problems/day-of-the-year) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 1134 | [阿姆斯特朗数](https://github.com/openset/leetcode/tree/master/problems/armstrong-number) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 1131 | [绝对值表达式的最大值](https://github.com/openset/leetcode/tree/master/problems/maximum-of-absolute-value-expression) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 1121 | [将数组分成几个递增序列](https://github.com/openset/leetcode/tree/master/problems/divide-array-into-increasing-sequences) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 1109 | [航班预订统计](https://github.com/openset/leetcode/tree/master/problems/corporate-flight-bookings) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 1104 | [二叉树寻路](https://github.com/openset/leetcode/tree/master/problems/path-in-zigzag-labelled-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 1103 | [分糖果 II](https://github.com/openset/leetcode/tree/master/problems/distribute-candies-to-people) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 1093 | [大样本统计](https://github.com/openset/leetcode/tree/master/problems/statistics-from-a-large-sample) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 1088 | [易混淆数 II](https://github.com/openset/leetcode/tree/master/problems/confusing-number-ii) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 1073 | [负二进制数相加](https://github.com/openset/leetcode/tree/master/problems/adding-two-negabinary-numbers) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 1067 | [范围内的数字计数](https://github.com/openset/leetcode/tree/master/problems/digit-count-in-range) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1058 | [最小化舍入误差以满足目标](https://github.com/openset/leetcode/tree/master/problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1056 | [易混淆数](https://github.com/openset/leetcode/tree/master/problems/confusing-number) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 1041 | [困于环中的机器人](https://github.com/openset/leetcode/tree/master/problems/robot-bounded-in-circle) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 1037 | [有效的回旋镖](https://github.com/openset/leetcode/tree/master/problems/valid-boomerang) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 1025 | [除数博弈](https://github.com/openset/leetcode/tree/master/problems/divisor-game) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Easy | -| 1017 | [负二进制转换](https://github.com/openset/leetcode/tree/master/problems/convert-to-base-2) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 1015 | [可被 K 整除的最小整数](https://github.com/openset/leetcode/tree/master/problems/smallest-integer-divisible-by-k) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 1012 | [至少有 1 位重复的数字](https://github.com/openset/leetcode/tree/master/problems/numbers-with-repeated-digits) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1009 | [十进制整数的反码](https://github.com/openset/leetcode/tree/master/problems/complement-of-base-10-integer) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 1006 | [笨阶乘](https://github.com/openset/leetcode/tree/master/problems/clumsy-factorial) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 996 | [正方形数组的数目](https://github.com/openset/leetcode/tree/master/problems/number-of-squareful-arrays) | [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 991 | [坏了的计算器](https://github.com/openset/leetcode/tree/master/problems/broken-calculator) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 976 | [三角形的最大周长](https://github.com/openset/leetcode/tree/master/problems/largest-perimeter-triangle) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 972 | [相等的有理数](https://github.com/openset/leetcode/tree/master/problems/equal-rational-numbers) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 970 | [强整数](https://github.com/openset/leetcode/tree/master/problems/powerful-integers) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 964 | [表示数字的最少运算符](https://github.com/openset/leetcode/tree/master/problems/least-operators-to-express-number) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 963 | [最小面积矩形 II](https://github.com/openset/leetcode/tree/master/problems/minimum-area-rectangle-ii) | [[几何](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 952 | [按公因数计算最大组件大小](https://github.com/openset/leetcode/tree/master/problems/largest-component-size-by-common-factor) | [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 949 | [给定数字能组成的最大时间](https://github.com/openset/leetcode/tree/master/problems/largest-time-for-given-digits) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 942 | [增减字符串匹配](https://github.com/openset/leetcode/tree/master/problems/di-string-match) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 927 | [三等分](https://github.com/openset/leetcode/tree/master/problems/three-equal-parts) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 914 | [卡牌分组](https://github.com/openset/leetcode/tree/master/problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 910 | [最小差值 II](https://github.com/openset/leetcode/tree/master/problems/smallest-range-ii) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 908 | [最小差值 I](https://github.com/openset/leetcode/tree/master/problems/smallest-range-i) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 906 | [超级回文数](https://github.com/openset/leetcode/tree/master/problems/super-palindromes) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 902 | [最大为 N 的数字组合](https://github.com/openset/leetcode/tree/master/problems/numbers-at-most-n-given-digit-set) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 899 | [有序队列](https://github.com/openset/leetcode/tree/master/problems/orderly-queue) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 892 | [三维形体的表面积](https://github.com/openset/leetcode/tree/master/problems/surface-area-of-3d-shapes) | [[几何](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 891 | [子序列宽度之和](https://github.com/openset/leetcode/tree/master/problems/sum-of-subsequence-widths) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 887 | [鸡蛋掉落](https://github.com/openset/leetcode/tree/master/problems/super-egg-drop) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 885 | [螺旋矩阵 III](https://github.com/openset/leetcode/tree/master/problems/spiral-matrix-iii) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 883 | [三维形体投影面积](https://github.com/openset/leetcode/tree/master/problems/projection-area-of-3d-shapes) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 878 | [第 N 个神奇数字](https://github.com/openset/leetcode/tree/master/problems/nth-magical-number) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 877 | [石子游戏](https://github.com/openset/leetcode/tree/master/problems/stone-game) | [[极小化极大](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 869 | [重新排序得到 2 的幂](https://github.com/openset/leetcode/tree/master/problems/reordered-power-of-2) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 868 | [二进制间距](https://github.com/openset/leetcode/tree/master/problems/binary-gap) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 866 | [回文素数](https://github.com/openset/leetcode/tree/master/problems/prime-palindrome) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 858 | [镜面反射](https://github.com/openset/leetcode/tree/master/problems/mirror-reflection) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 836 | [矩形重叠](https://github.com/openset/leetcode/tree/master/problems/rectangle-overlap) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 829 | [连续整数求和](https://github.com/openset/leetcode/tree/master/problems/consecutive-numbers-sum) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 812 | [最大三角形面积](https://github.com/openset/leetcode/tree/master/problems/largest-triangle-area) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 810 | [黑板异或游戏](https://github.com/openset/leetcode/tree/master/problems/chalkboard-xor-game) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 805 | [数组的均值分割](https://github.com/openset/leetcode/tree/master/problems/split-array-with-same-average) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 800 | [相似 RGB 颜色](https://github.com/openset/leetcode/tree/master/problems/similar-rgb-color) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 794 | [有效的井字游戏](https://github.com/openset/leetcode/tree/master/problems/valid-tic-tac-toe-state) | [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 789 | [逃脱阻碍者](https://github.com/openset/leetcode/tree/master/problems/escape-the-ghosts) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 782 | [变为棋盘](https://github.com/openset/leetcode/tree/master/problems/transform-to-chessboard) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 781 | [森林中的兔子](https://github.com/openset/leetcode/tree/master/problems/rabbits-in-forest) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 780 | [到达终点](https://github.com/openset/leetcode/tree/master/problems/reaching-points) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 775 | [全局倒置与局部倒置](https://github.com/openset/leetcode/tree/master/problems/global-and-local-inversions) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 754 | [到达终点数字](https://github.com/openset/leetcode/tree/master/problems/reach-a-number) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 753 | [破解保险箱](https://github.com/openset/leetcode/tree/master/problems/cracking-the-safe) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 728 | [自除数](https://github.com/openset/leetcode/tree/master/problems/self-dividing-numbers) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 672 | [灯泡开关 Ⅱ](https://github.com/openset/leetcode/tree/master/problems/bulb-switcher-ii) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 670 | [最大交换](https://github.com/openset/leetcode/tree/master/problems/maximum-swap) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 660 | [移除 9](https://github.com/openset/leetcode/tree/master/problems/remove-9) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 651 | [4键键盘](https://github.com/openset/leetcode/tree/master/problems/4-keys-keyboard) 🔒 | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 645 | [错误的集合](https://github.com/openset/leetcode/tree/master/problems/set-mismatch) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 640 | [求解方程](https://github.com/openset/leetcode/tree/master/problems/solve-the-equation) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 634 | [寻找数组的错位排列](https://github.com/openset/leetcode/tree/master/problems/find-the-derangement-of-an-array) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 633 | [平方数之和](https://github.com/openset/leetcode/tree/master/problems/sum-of-square-numbers) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 628 | [三个数的最大乘积](https://github.com/openset/leetcode/tree/master/problems/maximum-product-of-three-numbers) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 625 | [最小因式分解](https://github.com/openset/leetcode/tree/master/problems/minimum-factorization) 🔒 | [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 598 | [范围求和 II](https://github.com/openset/leetcode/tree/master/problems/range-addition-ii) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 593 | [有效的正方形](https://github.com/openset/leetcode/tree/master/problems/valid-square) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 592 | [分数加减运算](https://github.com/openset/leetcode/tree/master/problems/fraction-addition-and-subtraction) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 573 | [松鼠模拟](https://github.com/openset/leetcode/tree/master/problems/squirrel-simulation) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 553 | [最优除法](https://github.com/openset/leetcode/tree/master/problems/optimal-division) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 537 | [复数乘法](https://github.com/openset/leetcode/tree/master/problems/complex-number-multiplication) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 535 | [TinyURL 的加密与解密](https://github.com/openset/leetcode/tree/master/problems/encode-and-decode-tinyurl) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 523 | [连续的子数组和](https://github.com/openset/leetcode/tree/master/problems/continuous-subarray-sum) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 517 | [超级洗衣机](https://github.com/openset/leetcode/tree/master/problems/super-washing-machines) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 507 | [完美数](https://github.com/openset/leetcode/tree/master/problems/perfect-number) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 483 | [最小好进制](https://github.com/openset/leetcode/tree/master/problems/smallest-good-base) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 478 | [在圆内随机生成点](https://github.com/openset/leetcode/tree/master/problems/generate-random-point-in-a-circle) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] [[Rejection Sampling](https://github.com/openset/leetcode/tree/master/tag/rejection-sampling/README.md)] | Medium | -| 469 | [凸多边形](https://github.com/openset/leetcode/tree/master/problems/convex-polygon) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 462 | [最少移动次数使数组元素相等 II](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-equal-array-elements-ii) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 458 | [可怜的小猪](https://github.com/openset/leetcode/tree/master/problems/poor-pigs) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 453 | [最小移动次数使数组元素相等](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-equal-array-elements) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 441 | [排列硬币](https://github.com/openset/leetcode/tree/master/problems/arranging-coins) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 423 | [从英文中重建数字](https://github.com/openset/leetcode/tree/master/problems/reconstruct-original-digits-from-english) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 413 | [等差数列划分](https://github.com/openset/leetcode/tree/master/problems/arithmetic-slices) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 400 | [第N个数字](https://github.com/openset/leetcode/tree/master/problems/nth-digit) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 397 | [整数替换](https://github.com/openset/leetcode/tree/master/problems/integer-replacement) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 396 | [旋转函数](https://github.com/openset/leetcode/tree/master/problems/rotate-function) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 372 | [超级次方](https://github.com/openset/leetcode/tree/master/problems/super-pow) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 368 | [最大整除子集](https://github.com/openset/leetcode/tree/master/problems/largest-divisible-subset) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 367 | [有效的完全平方数](https://github.com/openset/leetcode/tree/master/problems/valid-perfect-square) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 365 | [水壶问题](https://github.com/openset/leetcode/tree/master/problems/water-and-jug-problem) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 360 | [有序转化数组](https://github.com/openset/leetcode/tree/master/problems/sort-transformed-array) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 357 | [计算各个位数不同的数字个数](https://github.com/openset/leetcode/tree/master/problems/count-numbers-with-unique-digits) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 356 | [直线镜像](https://github.com/openset/leetcode/tree/master/problems/line-reflection) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 343 | [整数拆分](https://github.com/openset/leetcode/tree/master/problems/integer-break) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 335 | [路径交叉](https://github.com/openset/leetcode/tree/master/problems/self-crossing) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 326 | [3的幂](https://github.com/openset/leetcode/tree/master/problems/power-of-three) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 319 | [灯泡开关](https://github.com/openset/leetcode/tree/master/problems/bulb-switcher) | [[脑筋急转弯](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 313 | [超级丑数](https://github.com/openset/leetcode/tree/master/problems/super-ugly-number) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 296 | [最佳的碰头地点](https://github.com/openset/leetcode/tree/master/problems/best-meeting-point) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 279 | [完全平方数](https://github.com/openset/leetcode/tree/master/problems/perfect-squares) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 273 | [整数转换英文表示](https://github.com/openset/leetcode/tree/master/problems/integer-to-english-words) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 268 | [缺失数字](https://github.com/openset/leetcode/tree/master/problems/missing-number) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 264 | [丑数 II](https://github.com/openset/leetcode/tree/master/problems/ugly-number-ii) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 263 | [丑数](https://github.com/openset/leetcode/tree/master/problems/ugly-number) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 258 | [各位相加](https://github.com/openset/leetcode/tree/master/problems/add-digits) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 248 | [中心对称数 III](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number-iii) 🔒 | [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 247 | [中心对称数 II](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number-ii) 🔒 | [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 246 | [中心对称数](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 233 | [数字 1 的个数](https://github.com/openset/leetcode/tree/master/problems/number-of-digit-one) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 231 | [2的幂](https://github.com/openset/leetcode/tree/master/problems/power-of-two) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 224 | [基本计算器](https://github.com/openset/leetcode/tree/master/problems/basic-calculator) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 223 | [矩形面积](https://github.com/openset/leetcode/tree/master/problems/rectangle-area) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 204 | [计数质数](https://github.com/openset/leetcode/tree/master/problems/count-primes) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 202 | [快乐数](https://github.com/openset/leetcode/tree/master/problems/happy-number) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 172 | [阶乘后的零](https://github.com/openset/leetcode/tree/master/problems/factorial-trailing-zeroes) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 171 | [Excel表列序号](https://github.com/openset/leetcode/tree/master/problems/excel-sheet-column-number) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 168 | [Excel表列名称](https://github.com/openset/leetcode/tree/master/problems/excel-sheet-column-title) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 166 | [分数到小数](https://github.com/openset/leetcode/tree/master/problems/fraction-to-recurring-decimal) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 149 | [直线上最多的点数](https://github.com/openset/leetcode/tree/master/problems/max-points-on-a-line) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 69 | [x 的平方根](https://github.com/openset/leetcode/tree/master/problems/sqrtx) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 67 | [二进制求和](https://github.com/openset/leetcode/tree/master/problems/add-binary) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 65 | [有效数字](https://github.com/openset/leetcode/tree/master/problems/valid-number) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 60 | [第k个排列](https://github.com/openset/leetcode/tree/master/problems/permutation-sequence) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 50 | [Pow(x, n)](https://github.com/openset/leetcode/tree/master/problems/powx-n) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 43 | [字符串相乘](https://github.com/openset/leetcode/tree/master/problems/multiply-strings) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 29 | [两数相除](https://github.com/openset/leetcode/tree/master/problems/divide-two-integers) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 13 | [罗马数字转整数](https://github.com/openset/leetcode/tree/master/problems/roman-to-integer) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 12 | [整数转罗马数字](https://github.com/openset/leetcode/tree/master/problems/integer-to-roman) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 9 | [回文数](https://github.com/openset/leetcode/tree/master/problems/palindrome-number) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 8 | [字符串转换整数 (atoi)](https://github.com/openset/leetcode/tree/master/problems/string-to-integer-atoi) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 7 | [整数反转](https://github.com/openset/leetcode/tree/master/problems/reverse-integer) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 2 | [两数相加](https://github.com/openset/leetcode/tree/master/problems/add-two-numbers) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | +| 1281 | [整数的各位积和之差](../../problems/subtract-the-product-and-sum-of-digits-of-an-integer) | [[数学](../math/README.md)] | Easy | +| 1276 | [不浪费原料的汉堡制作方案](../../problems/number-of-burgers-with-no-waste-of-ingredients) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1271 | [十六进制魔术数字](../../problems/hexspeak) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1259 | [不相交的握手](../../problems/handshakes-that-dont-cross) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1256 | [加密数字](../../problems/encode-number) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | +| 1253 | [重构 2 行二进制矩阵](../../problems/reconstruct-a-2-row-binary-matrix) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 1250 | [检查「好数组」](../../problems/check-if-it-is-a-good-array) | [[数学](../math/README.md)] | Hard | +| 1238 | [循环码排列](../../problems/circular-permutation-in-binary-representation) | [[数学](../math/README.md)] | Medium | +| 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1230 | [抛掷硬币](../../problems/toss-strange-coins) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1228 | [等差数列中缺失的数字](../../problems/missing-number-in-arithmetic-progression) 🔒 | [[数学](../math/README.md)] | Easy | +| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1217 | [玩筹码](../../problems/play-with-chips) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1199 | [建造街区的最短时间](../../problems/minimum-time-to-build-blocks) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1183 | [矩阵中 1 的最大数量](../../problems/maximum-number-of-ones) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | +| 1180 | [统计只含单一字母的子串](../../problems/count-substrings-with-only-one-distinct-letter) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1175 | [质数排列](../../problems/prime-arrangements) | [[数学](../math/README.md)] | Easy | +| 1154 | [一年中的第几天](../../problems/day-of-the-year) | [[数学](../math/README.md)] | Easy | +| 1134 | [阿姆斯特朗数](../../problems/armstrong-number) 🔒 | [[数学](../math/README.md)] | Easy | +| 1131 | [绝对值表达式的最大值](../../problems/maximum-of-absolute-value-expression) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | +| 1121 | [将数组分成几个递增序列](../../problems/divide-array-into-increasing-sequences) 🔒 | [[数学](../math/README.md)] | Hard | +| 1109 | [航班预订统计](../../problems/corporate-flight-bookings) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1104 | [二叉树寻路](../../problems/path-in-zigzag-labelled-binary-tree) | [[树](../tree/README.md)] [[数学](../math/README.md)] | Medium | +| 1103 | [分糖果 II](../../problems/distribute-candies-to-people) | [[数学](../math/README.md)] | Easy | +| 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1088 | [易混淆数 II](../../problems/confusing-number-ii) 🔒 | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1073 | [负二进制数相加](../../problems/adding-two-negabinary-numbers) | [[数学](../math/README.md)] | Medium | +| 1067 | [范围内的数字计数](../../problems/digit-count-in-range) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1056 | [易混淆数](../../problems/confusing-number) 🔒 | [[数学](../math/README.md)] | Easy | +| 1041 | [困于环中的机器人](../../problems/robot-bounded-in-circle) | [[数学](../math/README.md)] | Medium | +| 1037 | [有效的回旋镖](../../problems/valid-boomerang) | [[数学](../math/README.md)] | Easy | +| 1025 | [除数博弈](../../problems/divisor-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 1017 | [负二进制转换](../../problems/convert-to-base-2) | [[数学](../math/README.md)] | Medium | +| 1015 | [可被 K 整除的最小整数](../../problems/smallest-integer-divisible-by-k) | [[数学](../math/README.md)] | Medium | +| 1012 | [至少有 1 位重复的数字](../../problems/numbers-with-repeated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1009 | [十进制整数的反码](../../problems/complement-of-base-10-integer) | [[数学](../math/README.md)] | Easy | +| 1006 | [笨阶乘](../../problems/clumsy-factorial) | [[数学](../math/README.md)] | Medium | +| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 991 | [坏了的计算器](../../problems/broken-calculator) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 976 | [三角形的最大周长](../../problems/largest-perimeter-triangle) | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Easy | +| 972 | [相等的有理数](../../problems/equal-rational-numbers) | [[数学](../math/README.md)] | Hard | +| 970 | [强整数](../../problems/powerful-integers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 964 | [表示数字的最少运算符](../../problems/least-operators-to-express-number) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | +| 952 | [按公因数计算最大组件大小](../../problems/largest-component-size-by-common-factor) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | +| 949 | [给定数字能组成的最大时间](../../problems/largest-time-for-given-digits) | [[数学](../math/README.md)] | Easy | +| 942 | [增减字符串匹配](../../problems/di-string-match) | [[数学](../math/README.md)] | Easy | +| 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 910 | [最小差值 II](../../problems/smallest-range-ii) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 908 | [最小差值 I](../../problems/smallest-range-i) | [[数学](../math/README.md)] | Easy | +| 906 | [超级回文数](../../problems/super-palindromes) | [[数学](../math/README.md)] | Hard | +| 902 | [最大为 N 的数字组合](../../problems/numbers-at-most-n-given-digit-set) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 892 | [三维形体的表面积](../../problems/surface-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | +| 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 885 | [螺旋矩阵 III](../../problems/spiral-matrix-iii) | [[数学](../math/README.md)] | Medium | +| 883 | [三维形体投影面积](../../problems/projection-area-of-3d-shapes) | [[数学](../math/README.md)] | Easy | +| 878 | [第 N 个神奇数字](../../problems/nth-magical-number) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 877 | [石子游戏](../../problems/stone-game) | [[极小化极大](../minimax/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 869 | [重新排序得到 2 的幂](../../problems/reordered-power-of-2) | [[数学](../math/README.md)] | Medium | +| 868 | [二进制间距](../../problems/binary-gap) | [[数学](../math/README.md)] | Easy | +| 866 | [回文素数](../../problems/prime-palindrome) | [[数学](../math/README.md)] | Medium | +| 858 | [镜面反射](../../problems/mirror-reflection) | [[数学](../math/README.md)] | Medium | +| 836 | [矩形重叠](../../problems/rectangle-overlap) | [[数学](../math/README.md)] | Easy | +| 829 | [连续整数求和](../../problems/consecutive-numbers-sum) | [[数学](../math/README.md)] | Hard | +| 812 | [最大三角形面积](../../problems/largest-triangle-area) | [[数学](../math/README.md)] | Easy | +| 810 | [黑板异或游戏](../../problems/chalkboard-xor-game) | [[数学](../math/README.md)] | Hard | +| 805 | [数组的均值分割](../../problems/split-array-with-same-average) | [[数学](../math/README.md)] | Hard | +| 800 | [相似 RGB 颜色](../../problems/similar-rgb-color) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 789 | [逃脱阻碍者](../../problems/escape-the-ghosts) | [[数学](../math/README.md)] | Medium | +| 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 780 | [到达终点](../../problems/reaching-points) | [[数学](../math/README.md)] | Hard | +| 775 | [全局倒置与局部倒置](../../problems/global-and-local-inversions) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 754 | [到达终点数字](../../problems/reach-a-number) | [[数学](../math/README.md)] | Medium | +| 753 | [破解保险箱](../../problems/cracking-the-safe) | [[深度优先搜索](../depth-first-search/README.md)] [[数学](../math/README.md)] | Hard | +| 728 | [自除数](../../problems/self-dividing-numbers) | [[数学](../math/README.md)] | Easy | +| 672 | [灯泡开关 Ⅱ](../../problems/bulb-switcher-ii) | [[数学](../math/README.md)] | Medium | +| 670 | [最大交换](../../problems/maximum-swap) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 660 | [移除 9](../../problems/remove-9) 🔒 | [[数学](../math/README.md)] | Hard | +| 651 | [4键键盘](../../problems/4-keys-keyboard) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 645 | [错误的集合](../../problems/set-mismatch) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 640 | [求解方程](../../problems/solve-the-equation) | [[数学](../math/README.md)] | Medium | +| 634 | [寻找数组的错位排列](../../problems/find-the-derangement-of-an-array) 🔒 | [[数学](../math/README.md)] | Medium | +| 633 | [平方数之和](../../problems/sum-of-square-numbers) | [[数学](../math/README.md)] | Easy | +| 628 | [三个数的最大乘积](../../problems/maximum-product-of-three-numbers) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 598 | [范围求和 II](../../problems/range-addition-ii) | [[数学](../math/README.md)] | Easy | +| 593 | [有效的正方形](../../problems/valid-square) | [[数学](../math/README.md)] | Medium | +| 592 | [分数加减运算](../../problems/fraction-addition-and-subtraction) | [[数学](../math/README.md)] | Medium | +| 573 | [松鼠模拟](../../problems/squirrel-simulation) 🔒 | [[数学](../math/README.md)] | Medium | +| 553 | [最优除法](../../problems/optimal-division) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 535 | [TinyURL 的加密与解密](../../problems/encode-and-decode-tinyurl) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 523 | [连续的子数组和](../../problems/continuous-subarray-sum) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 517 | [超级洗衣机](../../problems/super-washing-machines) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 507 | [完美数](../../problems/perfect-number) | [[数学](../math/README.md)] | Easy | +| 483 | [最小好进制](../../problems/smallest-good-base) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | +| 469 | [凸多边形](../../problems/convex-polygon) 🔒 | [[数学](../math/README.md)] | Medium | +| 462 | [最少移动次数使数组元素相等 II](../../problems/minimum-moves-to-equal-array-elements-ii) | [[数学](../math/README.md)] | Medium | +| 458 | [可怜的小猪](../../problems/poor-pigs) | [[数学](../math/README.md)] | Hard | +| 453 | [最小移动次数使数组元素相等](../../problems/minimum-moves-to-equal-array-elements) | [[数学](../math/README.md)] | Easy | +| 441 | [排列硬币](../../problems/arranging-coins) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 423 | [从英文中重建数字](../../problems/reconstruct-original-digits-from-english) | [[数学](../math/README.md)] | Medium | +| 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 400 | [第N个数字](../../problems/nth-digit) | [[数学](../math/README.md)] | Medium | +| 397 | [整数替换](../../problems/integer-replacement) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | +| 396 | [旋转函数](../../problems/rotate-function) | [[数学](../math/README.md)] | Medium | +| 372 | [超级次方](../../problems/super-pow) | [[数学](../math/README.md)] | Medium | +| 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 367 | [有效的完全平方数](../../problems/valid-perfect-square) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 365 | [水壶问题](../../problems/water-and-jug-problem) | [[数学](../math/README.md)] | Medium | +| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 356 | [直线镜像](../../problems/line-reflection) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 343 | [整数拆分](../../problems/integer-break) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 335 | [路径交叉](../../problems/self-crossing) | [[数学](../math/README.md)] | Hard | +| 326 | [3的幂](../../problems/power-of-three) | [[数学](../math/README.md)] | Easy | +| 319 | [灯泡开关](../../problems/bulb-switcher) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Medium | +| 313 | [超级丑数](../../problems/super-ugly-number) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | +| 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | +| 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 268 | [缺失数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 263 | [丑数](../../problems/ugly-number) | [[数学](../math/README.md)] | Easy | +| 258 | [各位相加](../../problems/add-digits) | [[数学](../math/README.md)] | Easy | +| 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | +| 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 246 | [中心对称数](../../problems/strobogrammatic-number) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 233 | [数字 1 的个数](../../problems/number-of-digit-one) | [[数学](../math/README.md)] | Hard | +| 231 | [2的幂](../../problems/power-of-two) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | +| 224 | [基本计算器](../../problems/basic-calculator) | [[栈](../stack/README.md)] [[数学](../math/README.md)] | Hard | +| 223 | [矩形面积](../../problems/rectangle-area) | [[数学](../math/README.md)] | Medium | +| 204 | [计数质数](../../problems/count-primes) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 202 | [快乐数](../../problems/happy-number) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 172 | [阶乘后的零](../../problems/factorial-trailing-zeroes) | [[数学](../math/README.md)] | Easy | +| 171 | [Excel表列序号](../../problems/excel-sheet-column-number) | [[数学](../math/README.md)] | Easy | +| 168 | [Excel表列名称](../../problems/excel-sheet-column-title) | [[数学](../math/README.md)] | Easy | +| 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 69 | [x 的平方根](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 67 | [二进制求和](../../problems/add-binary) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 65 | [有效数字](../../problems/valid-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 60 | [第k个排列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 50 | [Pow(x, n)](../../problems/powx-n) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 29 | [两数相除](../../problems/divide-two-integers) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 9 | [回文数](../../problems/palindrome-number) | [[数学](../math/README.md)] | Easy | +| 8 | [字符串转换整数 (atoi)](../../problems/string-to-integer-atoi) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 7 | [整数反转](../../problems/reverse-integer) | [[数学](../math/README.md)] | Easy | +| 2 | [两数相加](../../problems/add-two-numbers) | [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/memoization/README.md b/tag/memoization/README.md index 1e9282f91..8b57a4940 100644 --- a/tag/memoization/README.md +++ b/tag/memoization/README.md @@ -5,8 +5,8 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 记忆化 +## [话题分类](../README.md) > 记忆化 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 329 | [矩阵中的最长递增路径](https://github.com/openset/leetcode/tree/master/problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] [[记忆化](https://github.com/openset/leetcode/tree/master/tag/memoization/README.md)] | Hard | +| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | diff --git a/tag/minimax/README.md b/tag/minimax/README.md index b1f2f7b2d..bfd9897a4 100644 --- a/tag/minimax/README.md +++ b/tag/minimax/README.md @@ -5,15 +5,15 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 极小化极大 +## [话题分类](../README.md) > 极小化极大 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 913 | [猫和老鼠](https://github.com/openset/leetcode/tree/master/problems/cat-and-mouse) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[极小化极大](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] | Hard | -| 877 | [石子游戏](https://github.com/openset/leetcode/tree/master/problems/stone-game) | [[极小化极大](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 843 | [猜猜这个单词](https://github.com/openset/leetcode/tree/master/problems/guess-the-word) | [[极小化极大](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] | Hard | -| 486 | [预测赢家](https://github.com/openset/leetcode/tree/master/problems/predict-the-winner) | [[极小化极大](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 464 | [我能赢吗](https://github.com/openset/leetcode/tree/master/problems/can-i-win) | [[极小化极大](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 375 | [猜数字大小 II](https://github.com/openset/leetcode/tree/master/problems/guess-number-higher-or-lower-ii) | [[极小化极大](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 294 | [翻转游戏 II](https://github.com/openset/leetcode/tree/master/problems/flip-game-ii) 🔒 | [[极小化极大](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 292 | [Nim 游戏](https://github.com/openset/leetcode/tree/master/problems/nim-game) | [[脑筋急转弯](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md)] [[极小化极大](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md)] | Easy | +| 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[极小化极大](../minimax/README.md)] | Hard | +| 877 | [石子游戏](../../problems/stone-game) | [[极小化极大](../minimax/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 843 | [猜猜这个单词](../../problems/guess-the-word) | [[极小化极大](../minimax/README.md)] | Hard | +| 486 | [预测赢家](../../problems/predict-the-winner) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 464 | [我能赢吗](../../problems/can-i-win) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 375 | [猜数字大小 II](../../problems/guess-number-higher-or-lower-ii) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 294 | [翻转游戏 II](../../problems/flip-game-ii) 🔒 | [[极小化极大](../minimax/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 292 | [Nim 游戏](../../problems/nim-game) | [[脑筋急转弯](../brainteaser/README.md)] [[极小化极大](../minimax/README.md)] | Easy | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index 90f73139e..19a1d5a98 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -5,17 +5,17 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > Ordered Map +## [话题分类](../README.md) > Ordered Map | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 975 | [奇偶跳](https://github.com/openset/leetcode/tree/master/problems/odd-even-jump) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] | Hard | -| 855 | [考场就座](https://github.com/openset/leetcode/tree/master/problems/exam-room) | [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] | Medium | -| 846 | [一手顺子](https://github.com/openset/leetcode/tree/master/problems/hand-of-straights) | [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] | Medium | -| 732 | [我的日程安排表 III](https://github.com/openset/leetcode/tree/master/problems/my-calendar-iii) | [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] | Hard | -| 731 | [我的日程安排表 II](https://github.com/openset/leetcode/tree/master/problems/my-calendar-ii) | [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] | Medium | -| 715 | [Range 模块](https://github.com/openset/leetcode/tree/master/problems/range-module) | [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] | Hard | -| 699 | [掉落的方块](https://github.com/openset/leetcode/tree/master/problems/falling-squares) | [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] | Hard | -| 683 | [K 个空花盆](https://github.com/openset/leetcode/tree/master/problems/k-empty-slots) 🔒 | [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] | Hard | -| 352 | [将数据流变为多个不相交区间](https://github.com/openset/leetcode/tree/master/problems/data-stream-as-disjoint-intervals) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] | Hard | -| 220 | [存在重复元素 III](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate-iii) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] | Medium | +| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 855 | [考场就座](../../problems/exam-room) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 846 | [一手顺子](../../problems/hand-of-straights) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 731 | [我的日程安排表 II](../../problems/my-calendar-ii) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 683 | [K 个空花盆](../../problems/k-empty-slots) 🔒 | [[Ordered Map](../ordered-map/README.md)] | Hard | +| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index 334b8bc4f..f83d54bcb 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -5,16 +5,16 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 队列 +## [话题分类](../README.md) > 队列 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 933 | [最近的请求次数](https://github.com/openset/leetcode/tree/master/problems/number-of-recent-calls) | [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] | Easy | -| 862 | [和至少为 K 的最短子数组](https://github.com/openset/leetcode/tree/master/problems/shortest-subarray-with-sum-at-least-k) | [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 641 | [设计循环双端队列](https://github.com/openset/leetcode/tree/master/problems/design-circular-deque) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] | Medium | -| 622 | [设计循环队列](https://github.com/openset/leetcode/tree/master/problems/design-circular-queue) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] | Medium | -| 621 | [任务调度器](https://github.com/openset/leetcode/tree/master/problems/task-scheduler) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 582 | [杀死进程](https://github.com/openset/leetcode/tree/master/problems/kill-process) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] | Medium | -| 363 | [矩形区域不超过 K 的最大数值和](https://github.com/openset/leetcode/tree/master/problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 353 | [贪吃蛇](https://github.com/openset/leetcode/tree/master/problems/design-snake-game) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] | Medium | -| 346 | [数据流中的移动平均值](https://github.com/openset/leetcode/tree/master/problems/moving-average-from-data-stream) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] | Easy | +| 933 | [最近的请求次数](../../problems/number-of-recent-calls) | [[队列](../queue/README.md)] | Easy | +| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | +| 582 | [杀死进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | +| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | diff --git a/tag/random/README.md b/tag/random/README.md index 7b6c82e1b..53eac31f1 100644 --- a/tag/random/README.md +++ b/tag/random/README.md @@ -5,13 +5,13 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > Random +## [话题分类](../README.md) > Random | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 710 | [黑名单中的随机数](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-blacklist) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] | Hard | -| 528 | [按权重随机选择](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-weight) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] | Medium | -| 519 | [随机翻转矩阵](https://github.com/openset/leetcode/tree/master/problems/random-flip-matrix) | [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] | Medium | -| 497 | [非重叠矩形中的随机点](https://github.com/openset/leetcode/tree/master/problems/random-point-in-non-overlapping-rectangles) | [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] | Medium | -| 478 | [在圆内随机生成点](https://github.com/openset/leetcode/tree/master/problems/generate-random-point-in-a-circle) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] [[Rejection Sampling](https://github.com/openset/leetcode/tree/master/tag/rejection-sampling/README.md)] | Medium | -| 470 | [用 Rand7() 实现 Rand10()](https://github.com/openset/leetcode/tree/master/problems/implement-rand10-using-rand7) | [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] [[Rejection Sampling](https://github.com/openset/leetcode/tree/master/tag/rejection-sampling/README.md)] | Medium | +| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | +| 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | +| 519 | [随机翻转矩阵](../../problems/random-flip-matrix) | [[Random](../random/README.md)] | Medium | +| 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | +| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | +| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 8e30e1029..2e9d297ae 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -5,22 +5,22 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 递归 +## [话题分类](../README.md) > 递归 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1137 | [第 N 个泰波那契数](https://github.com/openset/leetcode/tree/master/problems/n-th-tribonacci-number) | [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] | Easy | -| 938 | [二叉搜索树的范围和](https://github.com/openset/leetcode/tree/master/problems/range-sum-of-bst) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] | Easy | -| 894 | [所有可能的满二叉树](https://github.com/openset/leetcode/tree/master/problems/all-possible-full-binary-trees) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] | Medium | -| 794 | [有效的井字游戏](https://github.com/openset/leetcode/tree/master/problems/valid-tic-tac-toe-state) | [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 783 | [二叉搜索树结点最小距离](https://github.com/openset/leetcode/tree/master/problems/minimum-distance-between-bst-nodes) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] | Easy | -| 779 | [第K个语法符号](https://github.com/openset/leetcode/tree/master/problems/k-th-symbol-in-grammar) | [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] | Medium | -| 776 | [拆分二叉搜索树](https://github.com/openset/leetcode/tree/master/problems/split-bst) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] | Medium | -| 761 | [特殊的二进制序列](https://github.com/openset/leetcode/tree/master/problems/special-binary-string) | [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 726 | [原子的数量](https://github.com/openset/leetcode/tree/master/problems/number-of-atoms) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Hard | -| 698 | [划分为k个相等的子集](https://github.com/openset/leetcode/tree/master/problems/partition-to-k-equal-sum-subsets) | [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 687 | [最长同值路径](https://github.com/openset/leetcode/tree/master/problems/longest-univalue-path) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] | Easy | -| 625 | [最小因式分解](https://github.com/openset/leetcode/tree/master/problems/minimum-factorization) 🔒 | [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 544 | [输出比赛匹配对](https://github.com/openset/leetcode/tree/master/problems/output-contest-matches) 🔒 | [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 248 | [中心对称数 III](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number-iii) 🔒 | [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 247 | [中心对称数 II](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number-ii) 🔒 | [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | +| 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[递归](../recursion/README.md)] | Easy | +| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | +| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 783 | [二叉搜索树结点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | +| 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[递归](../recursion/README.md)] | Medium | +| 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | +| 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | +| 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | +| 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/rejection-sampling/README.md b/tag/rejection-sampling/README.md index 2e5258a04..510709f4d 100644 --- a/tag/rejection-sampling/README.md +++ b/tag/rejection-sampling/README.md @@ -5,9 +5,9 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > Rejection Sampling +## [话题分类](../README.md) > Rejection Sampling | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 478 | [在圆内随机生成点](https://github.com/openset/leetcode/tree/master/problems/generate-random-point-in-a-circle) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] [[Rejection Sampling](https://github.com/openset/leetcode/tree/master/tag/rejection-sampling/README.md)] | Medium | -| 470 | [用 Rand7() 实现 Rand10()](https://github.com/openset/leetcode/tree/master/problems/implement-rand10-using-rand7) | [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] [[Rejection Sampling](https://github.com/openset/leetcode/tree/master/tag/rejection-sampling/README.md)] | Medium | +| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | +| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | diff --git a/tag/reservoir-sampling/README.md b/tag/reservoir-sampling/README.md index f816564af..4d9d5b6b8 100644 --- a/tag/reservoir-sampling/README.md +++ b/tag/reservoir-sampling/README.md @@ -5,9 +5,9 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 蓄水池抽样 +## [话题分类](../README.md) > 蓄水池抽样 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 398 | [随机数索引](https://github.com/openset/leetcode/tree/master/problems/random-pick-index) | [[蓄水池抽样](https://github.com/openset/leetcode/tree/master/tag/reservoir-sampling/README.md)] | Medium | -| 382 | [链表随机节点](https://github.com/openset/leetcode/tree/master/problems/linked-list-random-node) | [[蓄水池抽样](https://github.com/openset/leetcode/tree/master/tag/reservoir-sampling/README.md)] | Medium | +| 398 | [随机数索引](../../problems/random-pick-index) | [[蓄水池抽样](../reservoir-sampling/README.md)] | Medium | +| 382 | [链表随机节点](../../problems/linked-list-random-node) | [[蓄水池抽样](../reservoir-sampling/README.md)] | Medium | diff --git a/tag/rolling-hash/README.md b/tag/rolling-hash/README.md index 3ed09eb4f..4584c71c6 100644 --- a/tag/rolling-hash/README.md +++ b/tag/rolling-hash/README.md @@ -5,7 +5,7 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > Rolling Hash +## [话题分类](../README.md) > Rolling Hash | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index 600969c34..221b8b50c 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -5,18 +5,18 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 线段树 +## [话题分类](../README.md) > 线段树 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1157 | [子数组中占绝大多数的元素](https://github.com/openset/leetcode/tree/master/problems/online-majority-element-in-subarray) | [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 850 | [矩形面积 II](https://github.com/openset/leetcode/tree/master/problems/rectangle-area-ii) | [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] | Hard | -| 732 | [我的日程安排表 III](https://github.com/openset/leetcode/tree/master/problems/my-calendar-iii) | [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] | Hard | -| 715 | [Range 模块](https://github.com/openset/leetcode/tree/master/problems/range-module) | [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] | Hard | -| 699 | [掉落的方块](https://github.com/openset/leetcode/tree/master/problems/falling-squares) | [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] | Hard | -| 493 | [翻转对](https://github.com/openset/leetcode/tree/master/problems/reverse-pairs) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 327 | [区间和的个数](https://github.com/openset/leetcode/tree/master/problems/count-of-range-sum) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 315 | [计算右侧小于当前元素的个数](https://github.com/openset/leetcode/tree/master/problems/count-of-smaller-numbers-after-self) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 308 | [二维区域和检索 - 可变](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-2d-mutable) 🔒 | [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] | Hard | -| 307 | [区域和检索 - 数组可修改](https://github.com/openset/leetcode/tree/master/problems/range-sum-query-mutable) | [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] | Medium | -| 218 | [天际线问题](https://github.com/openset/leetcode/tree/master/problems/the-skyline-problem) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] [[Line Sweep](https://github.com/openset/leetcode/tree/master/tag/line-sweep/README.md)] | Hard | +| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | +| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 308 | [二维区域和检索 - 可变](../../problems/range-sum-query-2d-mutable) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Hard | +| 307 | [区域和检索 - 数组可修改](../../problems/range-sum-query-mutable) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Medium | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index 9943e5b44..840ed4c1d 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -5,27 +5,27 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > Sliding Window +## [话题分类](../README.md) > Sliding Window | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1208 | [尽可能使字符串相等](https://github.com/openset/leetcode/tree/master/problems/get-equal-substrings-within-budget) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 1176 | [健身计划评估](https://github.com/openset/leetcode/tree/master/problems/diet-plan-performance) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Easy | -| 1151 | [最少交换次数来组合所有的 1](https://github.com/openset/leetcode/tree/master/problems/minimum-swaps-to-group-all-1s-together) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 1100 | [长度为 K 的无重复字符子串](https://github.com/openset/leetcode/tree/master/problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 1074 | [元素和为目标值的子矩阵数量](https://github.com/openset/leetcode/tree/master/problems/number-of-submatrices-that-sum-to-target) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 1052 | [爱生气的书店老板](https://github.com/openset/leetcode/tree/master/problems/grumpy-bookstore-owner) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 1040 | [移动石子直到连续 II](https://github.com/openset/leetcode/tree/master/problems/moving-stones-until-consecutive-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 1004 | [最大连续1的个数 III](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones-iii) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 995 | [K 连续位的最小翻转次数](https://github.com/openset/leetcode/tree/master/problems/minimum-number-of-k-consecutive-bit-flips) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 992 | [K 个不同整数的子数组](https://github.com/openset/leetcode/tree/master/problems/subarrays-with-k-different-integers) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 978 | [最长湍流子数组](https://github.com/openset/leetcode/tree/master/problems/longest-turbulent-subarray) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 727 | [最小窗口子序列](https://github.com/openset/leetcode/tree/master/problems/minimum-window-subsequence) 🔒 | [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 567 | [字符串的排列](https://github.com/openset/leetcode/tree/master/problems/permutation-in-string) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 480 | [滑动窗口中位数](https://github.com/openset/leetcode/tree/master/problems/sliding-window-median) | [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 424 | [替换后的最长重复字符](https://github.com/openset/leetcode/tree/master/problems/longest-repeating-character-replacement) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 340 | [至多包含 K 个不同字符的最长子串](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 239 | [滑动窗口最大值](https://github.com/openset/leetcode/tree/master/problems/sliding-window-maximum) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 159 | [至多包含两个不同字符的最长子串](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 76 | [最小覆盖子串](https://github.com/openset/leetcode/tree/master/problems/minimum-window-substring) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 3 | [无重复字符的最长子串](https://github.com/openset/leetcode/tree/master/problems/longest-substring-without-repeating-characters) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | +| 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1176 | [健身计划评估](../../problems/diet-plan-performance) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Easy | +| 1151 | [最少交换次数来组合所有的 1](../../problems/minimum-swaps-to-group-all-1s-together) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 1052 | [爱生气的书店老板](../../problems/grumpy-bookstore-owner) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1040 | [移动石子直到连续 II](../../problems/moving-stones-until-consecutive-ii) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[贪心算法](../greedy/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 480 | [滑动窗口中位数](../../problems/sliding-window-median) | [[Sliding Window](../sliding-window/README.md)] | Hard | +| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index 25022b6c9..fa76fdf87 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -5,45 +5,45 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 排序 +## [话题分类](../README.md) > 排序 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1244 | [力扣排行榜](https://github.com/openset/leetcode/tree/master/problems/design-a-leaderboard) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 1235 | [规划兼职工作](https://github.com/openset/leetcode/tree/master/problems/maximum-profit-in-job-scheduling) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1183 | [矩阵中 1 的最大数量](https://github.com/openset/leetcode/tree/master/problems/maximum-number-of-ones) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 1152 | [用户网站访问行为分析](https://github.com/openset/leetcode/tree/master/problems/analyze-user-website-visit-pattern) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 1122 | [数组的相对排序](https://github.com/openset/leetcode/tree/master/problems/relative-sort-array) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 1086 | [前五科的均分](https://github.com/openset/leetcode/tree/master/problems/high-five) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 1057 | [校园自行车分配](https://github.com/openset/leetcode/tree/master/problems/campus-bikes) 🔒 | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] | Medium | -| 1054 | [距离相等的条形码](https://github.com/openset/leetcode/tree/master/problems/distant-barcodes) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] | Medium | -| 1030 | [距离顺序排列矩阵单元格](https://github.com/openset/leetcode/tree/master/problems/matrix-cells-in-distance-order) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] | Easy | -| 976 | [三角形的最大周长](https://github.com/openset/leetcode/tree/master/problems/largest-perimeter-triangle) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Easy | -| 973 | [最接近原点的 K 个点](https://github.com/openset/leetcode/tree/master/problems/k-closest-points-to-origin) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Medium | -| 969 | [煎饼排序](https://github.com/openset/leetcode/tree/master/problems/pancake-sorting) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 922 | [按奇偶排序数组 II](https://github.com/openset/leetcode/tree/master/problems/sort-array-by-parity-ii) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy | -| 853 | [车队](https://github.com/openset/leetcode/tree/master/problems/car-fleet) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] | Medium | -| 767 | [重构字符串](https://github.com/openset/leetcode/tree/master/problems/reorganize-string) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 710 | [黑名单中的随机数](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-blacklist) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md)] | Hard | -| 527 | [单词缩写](https://github.com/openset/leetcode/tree/master/problems/word-abbreviation) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 524 | [通过删除字母匹配到字典里最长单词](https://github.com/openset/leetcode/tree/master/problems/longest-word-in-dictionary-through-deleting) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 493 | [翻转对](https://github.com/openset/leetcode/tree/master/problems/reverse-pairs) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 350 | [两个数组的交集 II](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays-ii) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 327 | [区间和的个数](https://github.com/openset/leetcode/tree/master/problems/count-of-range-sum) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 324 | [摆动排序 II](https://github.com/openset/leetcode/tree/master/problems/wiggle-sort-ii) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] | Medium | -| 315 | [计算右侧小于当前元素的个数](https://github.com/openset/leetcode/tree/master/problems/count-of-smaller-numbers-after-self) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md)] [[线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Hard | -| 296 | [最佳的碰头地点](https://github.com/openset/leetcode/tree/master/problems/best-meeting-point) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 280 | [摆动排序](https://github.com/openset/leetcode/tree/master/problems/wiggle-sort) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 274 | [H指数](https://github.com/openset/leetcode/tree/master/problems/h-index) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 253 | [会议室 II](https://github.com/openset/leetcode/tree/master/problems/meeting-rooms-ii) 🔒 | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] | Medium | -| 252 | [会议室](https://github.com/openset/leetcode/tree/master/problems/meeting-rooms) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] | Easy | -| 242 | [有效的字母异位词](https://github.com/openset/leetcode/tree/master/problems/valid-anagram) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 220 | [存在重复元素 III](https://github.com/openset/leetcode/tree/master/problems/contains-duplicate-iii) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] | Medium | -| 179 | [最大数](https://github.com/openset/leetcode/tree/master/problems/largest-number) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] | Medium | -| 164 | [最大间距](https://github.com/openset/leetcode/tree/master/problems/maximum-gap) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] | Hard | -| 148 | [排序链表](https://github.com/openset/leetcode/tree/master/problems/sort-list) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 147 | [对链表进行插入排序](https://github.com/openset/leetcode/tree/master/problems/insertion-sort-list) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 75 | [颜色分类](https://github.com/openset/leetcode/tree/master/problems/sort-colors) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 57 | [插入区间](https://github.com/openset/leetcode/tree/master/problems/insert-interval) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Hard | -| 56 | [合并区间](https://github.com/openset/leetcode/tree/master/problems/merge-intervals) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | +| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1183 | [矩阵中 1 的最大数量](../../problems/maximum-number-of-ones) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | +| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1122 | [数组的相对排序](../../problems/relative-sort-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1057 | [校园自行车分配](../../problems/campus-bikes) 🔒 | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] | Medium | +| 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[排序](../sort/README.md)] | Easy | +| 976 | [三角形的最大周长](../../problems/largest-perimeter-triangle) | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Easy | +| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 969 | [煎饼排序](../../problems/pancake-sorting) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 922 | [按奇偶排序数组 II](../../problems/sort-array-by-parity-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 853 | [车队](../../problems/car-fleet) | [[排序](../sort/README.md)] | Medium | +| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | +| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Hard | +| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 324 | [摆动排序 II](../../problems/wiggle-sort-ii) | [[排序](../sort/README.md)] | Medium | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | +| 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 274 | [H指数](../../problems/h-index) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 252 | [会议室](../../problems/meeting-rooms) 🔒 | [[排序](../sort/README.md)] | Easy | +| 242 | [有效的字母异位词](../../problems/valid-anagram) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | +| 179 | [最大数](../../problems/largest-number) | [[排序](../sort/README.md)] | Medium | +| 164 | [最大间距](../../problems/maximum-gap) | [[排序](../sort/README.md)] | Hard | +| 148 | [排序链表](../../problems/sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 57 | [插入区间](../../problems/insert-interval) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Hard | +| 56 | [合并区间](../../problems/merge-intervals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/stack/README.md b/tag/stack/README.md index d280a120e..a67c9392d 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -5,61 +5,61 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 栈 +## [话题分类](../README.md) > 栈 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1249 | [移除无效的括号](https://github.com/openset/leetcode/tree/master/problems/minimum-remove-to-make-valid-parentheses) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1209 | [删除字符串中的所有相邻重复项 II](https://github.com/openset/leetcode/tree/master/problems/remove-all-adjacent-duplicates-in-string-ii) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] | Medium | -| 1190 | [反转每对括号间的子串](https://github.com/openset/leetcode/tree/master/problems/reverse-substrings-between-each-pair-of-parentheses) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] | Medium | -| 1130 | [叶值的最小代价生成树](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-tree-from-leaf-values) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1124 | [表现良好的最长时间段](https://github.com/openset/leetcode/tree/master/problems/longest-well-performing-interval) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] | Medium | -| 1063 | [有效子数组的数目](https://github.com/openset/leetcode/tree/master/problems/number-of-valid-subarrays) 🔒 | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] | Hard | -| 1047 | [删除字符串中的所有相邻重复项](https://github.com/openset/leetcode/tree/master/problems/remove-all-adjacent-duplicates-in-string) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] | Easy | -| 1021 | [删除最外层的括号](https://github.com/openset/leetcode/tree/master/problems/remove-outermost-parentheses) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] | Easy | -| 1019 | [链表中的下一个更大节点](https://github.com/openset/leetcode/tree/master/problems/next-greater-node-in-linked-list) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium | -| 1003 | [检查替换后的词是否有效](https://github.com/openset/leetcode/tree/master/problems/check-if-word-is-valid-after-substitutions) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 975 | [奇偶跳](https://github.com/openset/leetcode/tree/master/problems/odd-even-jump) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)] | Hard | -| 946 | [验证栈序列](https://github.com/openset/leetcode/tree/master/problems/validate-stack-sequences) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] | Medium | -| 921 | [使括号有效的最少添加](https://github.com/openset/leetcode/tree/master/problems/minimum-add-to-make-parentheses-valid) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 907 | [子数组的最小值之和](https://github.com/openset/leetcode/tree/master/problems/sum-of-subarray-minimums) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 901 | [股票价格跨度](https://github.com/openset/leetcode/tree/master/problems/online-stock-span) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] | Medium | -| 895 | [最大频率栈](https://github.com/openset/leetcode/tree/master/problems/maximum-frequency-stack) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Hard | -| 880 | [索引处的解码字符串](https://github.com/openset/leetcode/tree/master/problems/decoded-string-at-index) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] | Medium | -| 856 | [括号的分数](https://github.com/openset/leetcode/tree/master/problems/score-of-parentheses) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 844 | [比较含退格的字符串](https://github.com/openset/leetcode/tree/master/problems/backspace-string-compare) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 772 | [基本计算器 III](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iii) 🔒 | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 770 | [基本计算器 IV](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iv) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 739 | [每日温度](https://github.com/openset/leetcode/tree/master/problems/daily-temperatures) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 735 | [行星碰撞](https://github.com/openset/leetcode/tree/master/problems/asteroid-collision) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] | Medium | -| 726 | [原子的数量](https://github.com/openset/leetcode/tree/master/problems/number-of-atoms) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Hard | -| 682 | [棒球比赛](https://github.com/openset/leetcode/tree/master/problems/baseball-game) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] | Easy | -| 636 | [函数的独占时间](https://github.com/openset/leetcode/tree/master/problems/exclusive-time-of-functions) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] | Medium | -| 591 | [标签验证器](https://github.com/openset/leetcode/tree/master/problems/tag-validator) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 503 | [下一个更大元素 II](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-ii) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] | Medium | -| 496 | [下一个更大元素 I](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-i) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] | Easy | -| 456 | [132模式](https://github.com/openset/leetcode/tree/master/problems/132-pattern) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] | Medium | -| 439 | [三元表达式解析器](https://github.com/openset/leetcode/tree/master/problems/ternary-expression-parser) 🔒 | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 402 | [移掉K位数字](https://github.com/openset/leetcode/tree/master/problems/remove-k-digits) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Medium | -| 394 | [字符串解码](https://github.com/openset/leetcode/tree/master/problems/decode-string) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 385 | [迷你语法分析器](https://github.com/openset/leetcode/tree/master/problems/mini-parser) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 341 | [扁平化嵌套列表迭代器](https://github.com/openset/leetcode/tree/master/problems/flatten-nested-list-iterator) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Medium | -| 331 | [验证二叉树的前序序列化](https://github.com/openset/leetcode/tree/master/problems/verify-preorder-serialization-of-a-binary-tree) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] | Medium | -| 316 | [去除重复字母](https://github.com/openset/leetcode/tree/master/problems/remove-duplicate-letters) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] | Hard | -| 272 | [最接近的二叉搜索树值 II](https://github.com/openset/leetcode/tree/master/problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Hard | -| 255 | [验证前序遍历序列二叉搜索树](https://github.com/openset/leetcode/tree/master/problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 232 | [用栈实现队列](https://github.com/openset/leetcode/tree/master/problems/implement-queue-using-stacks) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Easy | -| 225 | [用队列实现栈](https://github.com/openset/leetcode/tree/master/problems/implement-stack-using-queues) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Easy | -| 224 | [基本计算器](https://github.com/openset/leetcode/tree/master/problems/basic-calculator) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 173 | [二叉搜索树迭代器](https://github.com/openset/leetcode/tree/master/problems/binary-search-tree-iterator) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Medium | -| 155 | [最小栈](https://github.com/openset/leetcode/tree/master/problems/min-stack) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Easy | -| 150 | [逆波兰表达式求值](https://github.com/openset/leetcode/tree/master/problems/evaluate-reverse-polish-notation) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] | Medium | -| 145 | [二叉树的后序遍历](https://github.com/openset/leetcode/tree/master/problems/binary-tree-postorder-traversal) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Hard | -| 144 | [二叉树的前序遍历](https://github.com/openset/leetcode/tree/master/problems/binary-tree-preorder-traversal) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 103 | [二叉树的锯齿形层次遍历](https://github.com/openset/leetcode/tree/master/problems/binary-tree-zigzag-level-order-traversal) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 94 | [二叉树的中序遍历](https://github.com/openset/leetcode/tree/master/problems/binary-tree-inorder-traversal) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 85 | [最大矩形](https://github.com/openset/leetcode/tree/master/problems/maximal-rectangle) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 84 | [柱状图中最大的矩形](https://github.com/openset/leetcode/tree/master/problems/largest-rectangle-in-histogram) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Hard | -| 71 | [简化路径](https://github.com/openset/leetcode/tree/master/problems/simplify-path) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 42 | [接雨水](https://github.com/openset/leetcode/tree/master/problems/trapping-rain-water) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Hard | -| 20 | [有效的括号](https://github.com/openset/leetcode/tree/master/problems/valid-parentheses) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | +| 1249 | [移除无效的括号](../../problems/minimum-remove-to-make-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1209 | [删除字符串中的所有相邻重复项 II](../../problems/remove-all-adjacent-duplicates-in-string-ii) | [[栈](../stack/README.md)] | Medium | +| 1190 | [反转每对括号间的子串](../../problems/reverse-substrings-between-each-pair-of-parentheses) | [[栈](../stack/README.md)] | Medium | +| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1124 | [表现良好的最长时间段](../../problems/longest-well-performing-interval) | [[栈](../stack/README.md)] | Medium | +| 1063 | [有效子数组的数目](../../problems/number-of-valid-subarrays) 🔒 | [[栈](../stack/README.md)] | Hard | +| 1047 | [删除字符串中的所有相邻重复项](../../problems/remove-all-adjacent-duplicates-in-string) | [[栈](../stack/README.md)] | Easy | +| 1021 | [删除最外层的括号](../../problems/remove-outermost-parentheses) | [[栈](../stack/README.md)] | Easy | +| 1019 | [链表中的下一个更大节点](../../problems/next-greater-node-in-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 1003 | [检查替换后的词是否有效](../../problems/check-if-word-is-valid-after-substitutions) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 946 | [验证栈序列](../../problems/validate-stack-sequences) | [[栈](../stack/README.md)] | Medium | +| 921 | [使括号有效的最少添加](../../problems/minimum-add-to-make-parentheses-valid) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 907 | [子数组的最小值之和](../../problems/sum-of-subarray-minimums) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Medium | +| 901 | [股票价格跨度](../../problems/online-stock-span) | [[栈](../stack/README.md)] | Medium | +| 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 880 | [索引处的解码字符串](../../problems/decoded-string-at-index) | [[栈](../stack/README.md)] | Medium | +| 856 | [括号的分数](../../problems/score-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | +| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 735 | [行星碰撞](../../problems/asteroid-collision) | [[栈](../stack/README.md)] | Medium | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 682 | [棒球比赛](../../problems/baseball-game) | [[栈](../stack/README.md)] | Easy | +| 636 | [函数的独占时间](../../problems/exclusive-time-of-functions) | [[栈](../stack/README.md)] | Medium | +| 591 | [标签验证器](../../problems/tag-validator) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | +| 503 | [下一个更大元素 II](../../problems/next-greater-element-ii) | [[栈](../stack/README.md)] | Medium | +| 496 | [下一个更大元素 I](../../problems/next-greater-element-i) | [[栈](../stack/README.md)] | Easy | +| 456 | [132模式](../../problems/132-pattern) | [[栈](../stack/README.md)] | Medium | +| 439 | [三元表达式解析器](../../problems/ternary-expression-parser) 🔒 | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 402 | [移掉K位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 385 | [迷你语法分析器](../../problems/mini-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | +| 331 | [验证二叉树的前序序列化](../../problems/verify-preorder-serialization-of-a-binary-tree) | [[栈](../stack/README.md)] | Medium | +| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Hard | +| 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Hard | +| 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | +| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 224 | [基本计算器](../../problems/basic-calculator) | [[栈](../stack/README.md)] [[数学](../math/README.md)] | Hard | +| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] | Medium | +| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Hard | +| 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | +| 103 | [二叉树的锯齿形层次遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 84 | [柱状图中最大的矩形](../../problems/largest-rectangle-in-histogram) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Hard | +| 71 | [简化路径](../../problems/simplify-path) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Hard | +| 20 | [有效的括号](../../problems/valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | diff --git a/tag/string/README.md b/tag/string/README.md index 3db7038fb..82fa26b3c 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -5,157 +5,157 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 字符串 +## [话题分类](../README.md) > 字符串 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1271 | [十六进制魔术数字](https://github.com/openset/leetcode/tree/master/problems/hexspeak) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 1268 | [搜索推荐系统](https://github.com/openset/leetcode/tree/master/problems/search-suggestions-system) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1249 | [移除无效的括号](https://github.com/openset/leetcode/tree/master/problems/minimum-remove-to-make-valid-parentheses) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1247 | [交换字符使得字符串相同](https://github.com/openset/leetcode/tree/master/problems/minimum-swaps-to-make-strings-equal) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1234 | [替换子串得到平衡字符串](https://github.com/openset/leetcode/tree/master/problems/replace-the-substring-for-balanced-string) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1233 | [删除子文件夹](https://github.com/openset/leetcode/tree/master/problems/remove-sub-folders-from-the-filesystem) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1221 | [分割平衡字符串](https://github.com/openset/leetcode/tree/master/problems/split-a-string-in-balanced-strings) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 1216 | [验证回文字符串 III](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome-iii) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 1189 | [“气球” 的最大数量](https://github.com/openset/leetcode/tree/master/problems/maximum-number-of-balloons) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 1181 | [前后拼接](https://github.com/openset/leetcode/tree/master/problems/before-and-after-puzzle) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1180 | [统计只含单一字母的子串](https://github.com/openset/leetcode/tree/master/problems/count-substrings-with-only-one-distinct-letter) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 1177 | [构建回文串检测](https://github.com/openset/leetcode/tree/master/problems/can-make-palindrome-from-substring) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1170 | [比较字符串最小字母出现频次](https://github.com/openset/leetcode/tree/master/problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 1169 | [查询无效交易](https://github.com/openset/leetcode/tree/master/problems/invalid-transactions) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1165 | [单行键盘](https://github.com/openset/leetcode/tree/master/problems/single-row-keyboard) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 1163 | [按字典序排在最后的子串](https://github.com/openset/leetcode/tree/master/problems/last-substring-in-lexicographical-order) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 1156 | [单字符重复子串的最大长度](https://github.com/openset/leetcode/tree/master/problems/swap-for-longest-repeated-character-substring) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1138 | [字母板上的路径](https://github.com/openset/leetcode/tree/master/problems/alphabet-board-path) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1119 | [删去字符串中的元音](https://github.com/openset/leetcode/tree/master/problems/remove-vowels-from-a-string) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 1108 | [IP 地址无效化](https://github.com/openset/leetcode/tree/master/problems/defanging-an-ip-address) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 1106 | [解析布尔表达式](https://github.com/openset/leetcode/tree/master/problems/parsing-a-boolean-expression) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 1100 | [长度为 K 的无重复字符子串](https://github.com/openset/leetcode/tree/master/problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 1096 | [花括号展开 II](https://github.com/openset/leetcode/tree/master/problems/brace-expansion-ii) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 1081 | [不同字符的最小子序列](https://github.com/openset/leetcode/tree/master/problems/smallest-subsequence-of-distinct-characters) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1071 | [字符串的最大公因子](https://github.com/openset/leetcode/tree/master/problems/greatest-common-divisor-of-strings) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 1065 | [字符串的索引对](https://github.com/openset/leetcode/tree/master/problems/index-pairs-of-a-string) 🔒 | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 1062 | [最长重复子串](https://github.com/openset/leetcode/tree/master/problems/longest-repeating-substring) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1023 | [驼峰式匹配](https://github.com/openset/leetcode/tree/master/problems/camelcase-matching) | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1016 | [子串能表示从 1 到 N 数字的二进制串](https://github.com/openset/leetcode/tree/master/problems/binary-string-with-substrings-representing-1-to-n) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1003 | [检查替换后的词是否有效](https://github.com/openset/leetcode/tree/master/problems/check-if-word-is-valid-after-substitutions) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 966 | [元音拼写检查器](https://github.com/openset/leetcode/tree/master/problems/vowel-spellchecker) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 937 | [重新排列日志文件](https://github.com/openset/leetcode/tree/master/problems/reorder-data-in-log-files) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 936 | [戳印序列](https://github.com/openset/leetcode/tree/master/problems/stamping-the-sequence) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 929 | [独特的电子邮件地址](https://github.com/openset/leetcode/tree/master/problems/unique-email-addresses) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 925 | [长按键入](https://github.com/openset/leetcode/tree/master/problems/long-pressed-name) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 917 | [仅仅反转字母](https://github.com/openset/leetcode/tree/master/problems/reverse-only-letters) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 916 | [单词子集](https://github.com/openset/leetcode/tree/master/problems/word-subsets) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 899 | [有序队列](https://github.com/openset/leetcode/tree/master/problems/orderly-queue) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 893 | [特殊等价字符串组](https://github.com/openset/leetcode/tree/master/problems/groups-of-special-equivalent-strings) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 890 | [查找和替换模式](https://github.com/openset/leetcode/tree/master/problems/find-and-replace-pattern) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 859 | [亲密字符串](https://github.com/openset/leetcode/tree/master/problems/buddy-strings) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 856 | [括号的分数](https://github.com/openset/leetcode/tree/master/problems/score-of-parentheses) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 848 | [字母移位](https://github.com/openset/leetcode/tree/master/problems/shifting-letters) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 842 | [将数组拆分成斐波那契序列](https://github.com/openset/leetcode/tree/master/problems/split-array-into-fibonacci-sequence) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 833 | [字符串中的查找与替换](https://github.com/openset/leetcode/tree/master/problems/find-and-replace-in-string) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 831 | [隐藏个人信息](https://github.com/openset/leetcode/tree/master/problems/masking-personal-information) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 824 | [山羊拉丁文](https://github.com/openset/leetcode/tree/master/problems/goat-latin) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 819 | [最常见的单词](https://github.com/openset/leetcode/tree/master/problems/most-common-word) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 816 | [模糊坐标](https://github.com/openset/leetcode/tree/master/problems/ambiguous-coordinates) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 809 | [情感丰富的文字](https://github.com/openset/leetcode/tree/master/problems/expressive-words) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 804 | [唯一摩尔斯密码词](https://github.com/openset/leetcode/tree/master/problems/unique-morse-code-words) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 800 | [相似 RGB 颜色](https://github.com/openset/leetcode/tree/master/problems/similar-rgb-color) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 791 | [自定义字符串排序](https://github.com/openset/leetcode/tree/master/problems/custom-sort-string) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 788 | [旋转数字](https://github.com/openset/leetcode/tree/master/problems/rotated-digits) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 772 | [基本计算器 III](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iii) 🔒 | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 770 | [基本计算器 IV](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-iv) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 767 | [重构字符串](https://github.com/openset/leetcode/tree/master/problems/reorganize-string) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 761 | [特殊的二进制序列](https://github.com/openset/leetcode/tree/master/problems/special-binary-string) | [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 758 | [字符串中的加粗单词](https://github.com/openset/leetcode/tree/master/problems/bold-words-in-string) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 736 | [Lisp 语法解析](https://github.com/openset/leetcode/tree/master/problems/parse-lisp-expression) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 730 | [统计不同回文子字符串](https://github.com/openset/leetcode/tree/master/problems/count-different-palindromic-subsequences) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 722 | [删除注释](https://github.com/openset/leetcode/tree/master/problems/remove-comments) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 709 | [转换成小写字母](https://github.com/openset/leetcode/tree/master/problems/to-lower-case) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 696 | [计数二进制子串](https://github.com/openset/leetcode/tree/master/problems/count-binary-substrings) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 686 | [重复叠加字符串匹配](https://github.com/openset/leetcode/tree/master/problems/repeated-string-match) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 681 | [最近时刻](https://github.com/openset/leetcode/tree/master/problems/next-closest-time) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 680 | [验证回文字符串 Ⅱ](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome-ii) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 678 | [有效的括号字符串](https://github.com/openset/leetcode/tree/master/problems/valid-parenthesis-string) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 657 | [机器人能否返回原点](https://github.com/openset/leetcode/tree/master/problems/robot-return-to-origin) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 647 | [回文子串](https://github.com/openset/leetcode/tree/master/problems/palindromic-substrings) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 635 | [设计日志存储系统](https://github.com/openset/leetcode/tree/master/problems/design-log-storage-system) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 632 | [最小区间](https://github.com/openset/leetcode/tree/master/problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 616 | [给字符串添加加粗标签](https://github.com/openset/leetcode/tree/master/problems/add-bold-tag-in-string) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 609 | [在系统中查找重复文件](https://github.com/openset/leetcode/tree/master/problems/find-duplicate-file-in-system) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 606 | [根据二叉树创建字符串](https://github.com/openset/leetcode/tree/master/problems/construct-string-from-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 591 | [标签验证器](https://github.com/openset/leetcode/tree/master/problems/tag-validator) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 583 | [两个字符串的删除操作](https://github.com/openset/leetcode/tree/master/problems/delete-operation-for-two-strings) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 564 | [寻找最近的回文数](https://github.com/openset/leetcode/tree/master/problems/find-the-closest-palindrome) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 557 | [反转字符串中的单词 III](https://github.com/openset/leetcode/tree/master/problems/reverse-words-in-a-string-iii) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 556 | [下一个更大元素 III](https://github.com/openset/leetcode/tree/master/problems/next-greater-element-iii) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 555 | [分割连接字符串](https://github.com/openset/leetcode/tree/master/problems/split-concatenated-strings) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 553 | [最优除法](https://github.com/openset/leetcode/tree/master/problems/optimal-division) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 551 | [学生出勤记录 I](https://github.com/openset/leetcode/tree/master/problems/student-attendance-record-i) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 544 | [输出比赛匹配对](https://github.com/openset/leetcode/tree/master/problems/output-contest-matches) 🔒 | [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 541 | [反转字符串 II](https://github.com/openset/leetcode/tree/master/problems/reverse-string-ii) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 539 | [最小时间差](https://github.com/openset/leetcode/tree/master/problems/minimum-time-difference) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 537 | [复数乘法](https://github.com/openset/leetcode/tree/master/problems/complex-number-multiplication) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 536 | [从字符串生成二叉树](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-string) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 527 | [单词缩写](https://github.com/openset/leetcode/tree/master/problems/word-abbreviation) 🔒 | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 522 | [最长特殊序列 II](https://github.com/openset/leetcode/tree/master/problems/longest-uncommon-subsequence-ii) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 521 | [最长特殊序列 Ⅰ](https://github.com/openset/leetcode/tree/master/problems/longest-uncommon-subsequence-i) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 520 | [检测大写字母](https://github.com/openset/leetcode/tree/master/problems/detect-capital) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 468 | [验证IP地址](https://github.com/openset/leetcode/tree/master/problems/validate-ip-address) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 459 | [重复的子字符串](https://github.com/openset/leetcode/tree/master/problems/repeated-substring-pattern) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 443 | [压缩字符串](https://github.com/openset/leetcode/tree/master/problems/string-compression) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 434 | [字符串中的单词数](https://github.com/openset/leetcode/tree/master/problems/number-of-segments-in-a-string) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 415 | [字符串相加](https://github.com/openset/leetcode/tree/master/problems/add-strings) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 408 | [有效单词缩写](https://github.com/openset/leetcode/tree/master/problems/valid-word-abbreviation) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 387 | [字符串中的第一个唯一字符](https://github.com/openset/leetcode/tree/master/problems/first-unique-character-in-a-string) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 385 | [迷你语法分析器](https://github.com/openset/leetcode/tree/master/problems/mini-parser) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 383 | [赎金信](https://github.com/openset/leetcode/tree/master/problems/ransom-note) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 345 | [反转字符串中的元音字母](https://github.com/openset/leetcode/tree/master/problems/reverse-vowels-of-a-string) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 344 | [反转字符串](https://github.com/openset/leetcode/tree/master/problems/reverse-string) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 340 | [至多包含 K 个不同字符的最长子串](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 336 | [回文对](https://github.com/openset/leetcode/tree/master/problems/palindrome-pairs) | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 293 | [翻转游戏](https://github.com/openset/leetcode/tree/master/problems/flip-game) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 273 | [整数转换英文表示](https://github.com/openset/leetcode/tree/master/problems/integer-to-english-words) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 271 | [字符串的编码与解码](https://github.com/openset/leetcode/tree/master/problems/encode-and-decode-strings) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 249 | [移位字符串分组](https://github.com/openset/leetcode/tree/master/problems/group-shifted-strings) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 227 | [基本计算器 II](https://github.com/openset/leetcode/tree/master/problems/basic-calculator-ii) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 214 | [最短回文串](https://github.com/openset/leetcode/tree/master/problems/shortest-palindrome) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 186 | [翻转字符串里的单词 II](https://github.com/openset/leetcode/tree/master/problems/reverse-words-in-a-string-ii) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 165 | [比较版本号](https://github.com/openset/leetcode/tree/master/problems/compare-version-numbers) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 161 | [相隔为 1 的编辑距离](https://github.com/openset/leetcode/tree/master/problems/one-edit-distance) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 159 | [至多包含两个不同字符的最长子串](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 158 | [用 Read4 读取 N 个字符 II](https://github.com/openset/leetcode/tree/master/problems/read-n-characters-given-read4-ii-call-multiple-times) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 157 | [用 Read4 读取 N 个字符](https://github.com/openset/leetcode/tree/master/problems/read-n-characters-given-read4) 🔒 | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 151 | [翻转字符串里的单词](https://github.com/openset/leetcode/tree/master/problems/reverse-words-in-a-string) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 126 | [单词接龙 II](https://github.com/openset/leetcode/tree/master/problems/word-ladder-ii) | [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 125 | [验证回文串](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 115 | [不同的子序列](https://github.com/openset/leetcode/tree/master/problems/distinct-subsequences) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 97 | [交错字符串](https://github.com/openset/leetcode/tree/master/problems/interleaving-string) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 93 | [复原IP地址](https://github.com/openset/leetcode/tree/master/problems/restore-ip-addresses) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 91 | [解码方法](https://github.com/openset/leetcode/tree/master/problems/decode-ways) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 87 | [扰乱字符串](https://github.com/openset/leetcode/tree/master/problems/scramble-string) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 76 | [最小覆盖子串](https://github.com/openset/leetcode/tree/master/problems/minimum-window-substring) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 72 | [编辑距离](https://github.com/openset/leetcode/tree/master/problems/edit-distance) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 71 | [简化路径](https://github.com/openset/leetcode/tree/master/problems/simplify-path) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 68 | [文本左右对齐](https://github.com/openset/leetcode/tree/master/problems/text-justification) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 67 | [二进制求和](https://github.com/openset/leetcode/tree/master/problems/add-binary) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 65 | [有效数字](https://github.com/openset/leetcode/tree/master/problems/valid-number) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 58 | [最后一个单词的长度](https://github.com/openset/leetcode/tree/master/problems/length-of-last-word) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 49 | [字母异位词分组](https://github.com/openset/leetcode/tree/master/problems/group-anagrams) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 44 | [通配符匹配](https://github.com/openset/leetcode/tree/master/problems/wildcard-matching) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 43 | [字符串相乘](https://github.com/openset/leetcode/tree/master/problems/multiply-strings) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 38 | [报数](https://github.com/openset/leetcode/tree/master/problems/count-and-say) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 32 | [最长有效括号](https://github.com/openset/leetcode/tree/master/problems/longest-valid-parentheses) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 30 | [串联所有单词的子串](https://github.com/openset/leetcode/tree/master/problems/substring-with-concatenation-of-all-words) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 28 | [实现 strStr()](https://github.com/openset/leetcode/tree/master/problems/implement-strstr) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 22 | [括号生成](https://github.com/openset/leetcode/tree/master/problems/generate-parentheses) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 20 | [有效的括号](https://github.com/openset/leetcode/tree/master/problems/valid-parentheses) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 17 | [电话号码的字母组合](https://github.com/openset/leetcode/tree/master/problems/letter-combinations-of-a-phone-number) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 14 | [最长公共前缀](https://github.com/openset/leetcode/tree/master/problems/longest-common-prefix) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 13 | [罗马数字转整数](https://github.com/openset/leetcode/tree/master/problems/roman-to-integer) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 12 | [整数转罗马数字](https://github.com/openset/leetcode/tree/master/problems/integer-to-roman) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 10 | [正则表达式匹配](https://github.com/openset/leetcode/tree/master/problems/regular-expression-matching) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 8 | [字符串转换整数 (atoi)](https://github.com/openset/leetcode/tree/master/problems/string-to-integer-atoi) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 6 | [Z 字形变换](https://github.com/openset/leetcode/tree/master/problems/zigzag-conversion) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 5 | [最长回文子串](https://github.com/openset/leetcode/tree/master/problems/longest-palindromic-substring) | [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 3 | [无重复字符的最长子串](https://github.com/openset/leetcode/tree/master/problems/longest-substring-without-repeating-characters) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | +| 1271 | [十六进制魔术数字](../../problems/hexspeak) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1268 | [搜索推荐系统](../../problems/search-suggestions-system) | [[字符串](../string/README.md)] | Medium | +| 1249 | [移除无效的括号](../../problems/minimum-remove-to-make-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1247 | [交换字符使得字符串相同](../../problems/minimum-swaps-to-make-strings-equal) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1233 | [删除子文件夹](../../problems/remove-sub-folders-from-the-filesystem) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1221 | [分割平衡字符串](../../problems/split-a-string-in-balanced-strings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | +| 1216 | [验证回文字符串 III](../../problems/valid-palindrome-iii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1189 | [“气球” 的最大数量](../../problems/maximum-number-of-balloons) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1181 | [前后拼接](../../problems/before-and-after-puzzle) 🔒 | [[字符串](../string/README.md)] | Medium | +| 1180 | [统计只含单一字母的子串](../../problems/count-substrings-with-only-one-distinct-letter) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1177 | [构建回文串检测](../../problems/can-make-palindrome-from-substring) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1169 | [查询无效交易](../../problems/invalid-transactions) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1165 | [单行键盘](../../problems/single-row-keyboard) 🔒 | [[字符串](../string/README.md)] | Easy | +| 1163 | [按字典序排在最后的子串](../../problems/last-substring-in-lexicographical-order) | [[字符串](../string/README.md)] | Hard | +| 1156 | [单字符重复子串的最大长度](../../problems/swap-for-longest-repeated-character-substring) | [[字符串](../string/README.md)] | Medium | +| 1138 | [字母板上的路径](../../problems/alphabet-board-path) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1119 | [删去字符串中的元音](../../problems/remove-vowels-from-a-string) 🔒 | [[字符串](../string/README.md)] | Easy | +| 1108 | [IP 地址无效化](../../problems/defanging-an-ip-address) | [[字符串](../string/README.md)] | Easy | +| 1106 | [解析布尔表达式](../../problems/parsing-a-boolean-expression) | [[字符串](../string/README.md)] | Hard | +| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1096 | [花括号展开 II](../../problems/brace-expansion-ii) | [[字符串](../string/README.md)] | Hard | +| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[字符串](../string/README.md)] | Medium | +| 1071 | [字符串的最大公因子](../../problems/greatest-common-divisor-of-strings) | [[字符串](../string/README.md)] | Easy | +| 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Easy | +| 1062 | [最长重复子串](../../problems/longest-repeating-substring) 🔒 | [[字符串](../string/README.md)] | Medium | +| 1023 | [驼峰式匹配](../../problems/camelcase-matching) | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | +| 1016 | [子串能表示从 1 到 N 数字的二进制串](../../problems/binary-string-with-substrings-representing-1-to-n) | [[字符串](../string/README.md)] | Medium | +| 1003 | [检查替换后的词是否有效](../../problems/check-if-word-is-valid-after-substitutions) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 937 | [重新排列日志文件](../../problems/reorder-data-in-log-files) | [[字符串](../string/README.md)] | Easy | +| 936 | [戳印序列](../../problems/stamping-the-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | +| 929 | [独特的电子邮件地址](../../problems/unique-email-addresses) | [[字符串](../string/README.md)] | Easy | +| 925 | [长按键入](../../problems/long-pressed-name) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 917 | [仅仅反转字母](../../problems/reverse-only-letters) | [[字符串](../string/README.md)] | Easy | +| 916 | [单词子集](../../problems/word-subsets) | [[字符串](../string/README.md)] | Medium | +| 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[字符串](../string/README.md)] | Easy | +| 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[字符串](../string/README.md)] | Medium | +| 859 | [亲密字符串](../../problems/buddy-strings) | [[字符串](../string/README.md)] | Easy | +| 856 | [括号的分数](../../problems/score-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 848 | [字母移位](../../problems/shifting-letters) | [[字符串](../string/README.md)] | Medium | +| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 833 | [字符串中的查找与替换](../../problems/find-and-replace-in-string) | [[字符串](../string/README.md)] | Medium | +| 831 | [隐藏个人信息](../../problems/masking-personal-information) | [[字符串](../string/README.md)] | Medium | +| 824 | [山羊拉丁文](../../problems/goat-latin) | [[字符串](../string/README.md)] | Easy | +| 819 | [最常见的单词](../../problems/most-common-word) | [[字符串](../string/README.md)] | Easy | +| 816 | [模糊坐标](../../problems/ambiguous-coordinates) | [[字符串](../string/README.md)] | Medium | +| 809 | [情感丰富的文字](../../problems/expressive-words) | [[字符串](../string/README.md)] | Medium | +| 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[字符串](../string/README.md)] | Easy | +| 800 | [相似 RGB 颜色](../../problems/similar-rgb-color) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 791 | [自定义字符串排序](../../problems/custom-sort-string) | [[字符串](../string/README.md)] | Medium | +| 788 | [旋转数字](../../problems/rotated-digits) | [[字符串](../string/README.md)] | Easy | +| 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | +| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | +| 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字符串](../string/README.md)] | Easy | +| 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[字符串](../string/README.md)] | Hard | +| 730 | [统计不同回文子字符串](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 722 | [删除注释](../../problems/remove-comments) | [[字符串](../string/README.md)] | Medium | +| 709 | [转换成小写字母](../../problems/to-lower-case) | [[字符串](../string/README.md)] | Easy | +| 696 | [计数二进制子串](../../problems/count-binary-substrings) | [[字符串](../string/README.md)] | Easy | +| 686 | [重复叠加字符串匹配](../../problems/repeated-string-match) | [[字符串](../string/README.md)] | Easy | +| 681 | [最近时刻](../../problems/next-closest-time) 🔒 | [[字符串](../string/README.md)] | Medium | +| 680 | [验证回文字符串 Ⅱ](../../problems/valid-palindrome-ii) | [[字符串](../string/README.md)] | Easy | +| 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[字符串](../string/README.md)] | Medium | +| 657 | [机器人能否返回原点](../../problems/robot-return-to-origin) | [[字符串](../string/README.md)] | Easy | +| 647 | [回文子串](../../problems/palindromic-substrings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | +| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 616 | [给字符串添加加粗标签](../../problems/add-bold-tag-in-string) 🔒 | [[字符串](../string/README.md)] | Medium | +| 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 606 | [根据二叉树创建字符串](../../problems/construct-string-from-binary-tree) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Easy | +| 591 | [标签验证器](../../problems/tag-validator) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | +| 583 | [两个字符串的删除操作](../../problems/delete-operation-for-two-strings) | [[字符串](../string/README.md)] | Medium | +| 564 | [寻找最近的回文数](../../problems/find-the-closest-palindrome) | [[字符串](../string/README.md)] | Hard | +| 557 | [反转字符串中的单词 III](../../problems/reverse-words-in-a-string-iii) | [[字符串](../string/README.md)] | Easy | +| 556 | [下一个更大元素 III](../../problems/next-greater-element-iii) | [[字符串](../string/README.md)] | Medium | +| 555 | [分割连接字符串](../../problems/split-concatenated-strings) 🔒 | [[字符串](../string/README.md)] | Medium | +| 553 | [最优除法](../../problems/optimal-division) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 551 | [学生出勤记录 I](../../problems/student-attendance-record-i) | [[字符串](../string/README.md)] | Easy | +| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | +| 541 | [反转字符串 II](../../problems/reverse-string-ii) | [[字符串](../string/README.md)] | Easy | +| 539 | [最小时间差](../../problems/minimum-time-difference) | [[字符串](../string/README.md)] | Medium | +| 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | +| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Hard | +| 522 | [最长特殊序列 II](../../problems/longest-uncommon-subsequence-ii) | [[字符串](../string/README.md)] | Medium | +| 521 | [最长特殊序列 Ⅰ](../../problems/longest-uncommon-subsequence-i) | [[字符串](../string/README.md)] | Easy | +| 520 | [检测大写字母](../../problems/detect-capital) | [[字符串](../string/README.md)] | Easy | +| 468 | [验证IP地址](../../problems/validate-ip-address) | [[字符串](../string/README.md)] | Medium | +| 459 | [重复的子字符串](../../problems/repeated-substring-pattern) | [[字符串](../string/README.md)] | Easy | +| 443 | [压缩字符串](../../problems/string-compression) | [[字符串](../string/README.md)] | Easy | +| 434 | [字符串中的单词数](../../problems/number-of-segments-in-a-string) | [[字符串](../string/README.md)] | Easy | +| 415 | [字符串相加](../../problems/add-strings) | [[字符串](../string/README.md)] | Easy | +| 408 | [有效单词缩写](../../problems/valid-word-abbreviation) 🔒 | [[字符串](../string/README.md)] | Easy | +| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 385 | [迷你语法分析器](../../problems/mini-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 383 | [赎金信](../../problems/ransom-note) | [[字符串](../string/README.md)] | Easy | +| 345 | [反转字符串中的元音字母](../../problems/reverse-vowels-of-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 344 | [反转字符串](../../problems/reverse-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 293 | [翻转游戏](../../problems/flip-game) 🔒 | [[字符串](../string/README.md)] | Easy | +| 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 271 | [字符串的编码与解码](../../problems/encode-and-decode-strings) 🔒 | [[字符串](../string/README.md)] | Medium | +| 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[字符串](../string/README.md)] | Medium | +| 214 | [最短回文串](../../problems/shortest-palindrome) | [[字符串](../string/README.md)] | Hard | +| 186 | [翻转字符串里的单词 II](../../problems/reverse-words-in-a-string-ii) 🔒 | [[字符串](../string/README.md)] | Medium | +| 165 | [比较版本号](../../problems/compare-version-numbers) | [[字符串](../string/README.md)] | Medium | +| 161 | [相隔为 1 的编辑距离](../../problems/one-edit-distance) 🔒 | [[字符串](../string/README.md)] | Medium | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 158 | [用 Read4 读取 N 个字符 II](../../problems/read-n-characters-given-read4-ii-call-multiple-times) 🔒 | [[字符串](../string/README.md)] | Hard | +| 157 | [用 Read4 读取 N 个字符](../../problems/read-n-characters-given-read4) 🔒 | [[字符串](../string/README.md)] | Easy | +| 151 | [翻转字符串里的单词](../../problems/reverse-words-in-a-string) | [[字符串](../string/README.md)] | Medium | +| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 125 | [验证回文串](../../problems/valid-palindrome) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 115 | [不同的子序列](../../problems/distinct-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 93 | [复原IP地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 91 | [解码方法](../../problems/decode-ways) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 87 | [扰乱字符串](../../problems/scramble-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 72 | [编辑距离](../../problems/edit-distance) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 71 | [简化路径](../../problems/simplify-path) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 68 | [文本左右对齐](../../problems/text-justification) | [[字符串](../string/README.md)] | Hard | +| 67 | [二进制求和](../../problems/add-binary) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 65 | [有效数字](../../problems/valid-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 58 | [最后一个单词的长度](../../problems/length-of-last-word) | [[字符串](../string/README.md)] | Easy | +| 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 38 | [报数](../../problems/count-and-say) | [[字符串](../string/README.md)] | Easy | +| 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 20 | [有效的括号](../../problems/valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | +| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 14 | [最长公共前缀](../../problems/longest-common-prefix) | [[字符串](../string/README.md)] | Easy | +| 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 8 | [字符串转换整数 (atoi)](../../problems/string-to-integer-atoi) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 6 | [Z 字形变换](../../problems/zigzag-conversion) | [[字符串](../string/README.md)] | Medium | +| 5 | [最长回文子串](../../problems/longest-palindromic-substring) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/suffix-array/README.md b/tag/suffix-array/README.md index 51a0cc1aa..b419d4047 100644 --- a/tag/suffix-array/README.md +++ b/tag/suffix-array/README.md @@ -5,7 +5,7 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > Suffix Array +## [话题分类](../README.md) > Suffix Array | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | diff --git a/tag/topological-sort/README.md b/tag/topological-sort/README.md index 1fd7cff97..7231dfe39 100644 --- a/tag/topological-sort/README.md +++ b/tag/topological-sort/README.md @@ -5,13 +5,13 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 拓扑排序 +## [话题分类](../README.md) > 拓扑排序 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1203 | [项目管理](https://github.com/openset/leetcode/tree/master/problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] | Hard | -| 444 | [序列重建](https://github.com/openset/leetcode/tree/master/problems/sequence-reconstruction) 🔒 | [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] | Medium | -| 329 | [矩阵中的最长递增路径](https://github.com/openset/leetcode/tree/master/problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] [[记忆化](https://github.com/openset/leetcode/tree/master/tag/memoization/README.md)] | Hard | -| 269 | [火星词典](https://github.com/openset/leetcode/tree/master/problems/alien-dictionary) 🔒 | [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] | Hard | -| 210 | [课程表 II](https://github.com/openset/leetcode/tree/master/problems/course-schedule-ii) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] | Medium | -| 207 | [课程表](https://github.com/openset/leetcode/tree/master/problems/course-schedule) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] [[拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md)] | Medium | +| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 444 | [序列重建](../../problems/sequence-reconstruction) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | +| 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | diff --git a/tag/tree/README.md b/tag/tree/README.md index 7a19ae58c..97fd5f73a 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -5,130 +5,130 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 树 +## [话题分类](../README.md) > 树 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1261 | [在受污染的二叉树中查找元素](https://github.com/openset/leetcode/tree/master/problems/find-elements-in-a-contaminated-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 1257 | [最小公共区域](https://github.com/openset/leetcode/tree/master/problems/smallest-common-region) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 1245 | [树的直径](https://github.com/openset/leetcode/tree/master/problems/tree-diameter) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 1145 | [二叉树着色游戏](https://github.com/openset/leetcode/tree/master/problems/binary-tree-coloring-game) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 1130 | [叶值的最小代价生成树](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-tree-from-leaf-values) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 1123 | [最深叶节点的最近公共祖先](https://github.com/openset/leetcode/tree/master/problems/lowest-common-ancestor-of-deepest-leaves) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 1120 | [子树的最大平均值](https://github.com/openset/leetcode/tree/master/problems/maximum-average-subtree) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 1110 | [删点成林](https://github.com/openset/leetcode/tree/master/problems/delete-nodes-and-return-forest) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 1104 | [二叉树寻路](https://github.com/openset/leetcode/tree/master/problems/path-in-zigzag-labelled-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Medium | -| 1028 | [从先序遍历还原二叉树](https://github.com/openset/leetcode/tree/master/problems/recover-a-tree-from-preorder-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Hard | -| 1026 | [节点与其祖先之间的最大差值](https://github.com/openset/leetcode/tree/master/problems/maximum-difference-between-node-and-ancestor) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 1022 | [从根到叶的二进制数之和](https://github.com/openset/leetcode/tree/master/problems/sum-of-root-to-leaf-binary-numbers) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 1008 | [先序遍历构造二叉树](https://github.com/openset/leetcode/tree/master/problems/construct-binary-search-tree-from-preorder-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 998 | [最大二叉树 II](https://github.com/openset/leetcode/tree/master/problems/maximum-binary-tree-ii) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 993 | [二叉树的堂兄弟节点](https://github.com/openset/leetcode/tree/master/problems/cousins-in-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Easy | -| 988 | [从叶结点开始的最小字符串](https://github.com/openset/leetcode/tree/master/problems/smallest-string-starting-from-leaf) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 987 | [二叉树的垂序遍历](https://github.com/openset/leetcode/tree/master/problems/vertical-order-traversal-of-a-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 979 | [在二叉树中分配硬币](https://github.com/openset/leetcode/tree/master/problems/distribute-coins-in-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 971 | [翻转二叉树以匹配先序遍历](https://github.com/openset/leetcode/tree/master/problems/flip-binary-tree-to-match-preorder-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 968 | [监控二叉树](https://github.com/openset/leetcode/tree/master/problems/binary-tree-cameras) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 965 | [单值二叉树](https://github.com/openset/leetcode/tree/master/problems/univalued-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 958 | [二叉树的完全性检验](https://github.com/openset/leetcode/tree/master/problems/check-completeness-of-a-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 951 | [翻转等价二叉树](https://github.com/openset/leetcode/tree/master/problems/flip-equivalent-binary-trees) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 938 | [二叉搜索树的范围和](https://github.com/openset/leetcode/tree/master/problems/range-sum-of-bst) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] | Easy | -| 919 | [完全二叉树插入器](https://github.com/openset/leetcode/tree/master/problems/complete-binary-tree-inserter) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 897 | [递增顺序查找树](https://github.com/openset/leetcode/tree/master/problems/increasing-order-search-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Easy | -| 894 | [所有可能的满二叉树](https://github.com/openset/leetcode/tree/master/problems/all-possible-full-binary-trees) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] | Medium | -| 889 | [根据前序和后序遍历构造二叉树](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 872 | [叶子相似的树](https://github.com/openset/leetcode/tree/master/problems/leaf-similar-trees) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Easy | -| 865 | [具有所有最深结点的最小子树](https://github.com/openset/leetcode/tree/master/problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 863 | [二叉树中所有距离为 K 的结点](https://github.com/openset/leetcode/tree/master/problems/all-nodes-distance-k-in-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 834 | [树中距离之和](https://github.com/openset/leetcode/tree/master/problems/sum-of-distances-in-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Hard | -| 814 | [二叉树剪枝](https://github.com/openset/leetcode/tree/master/problems/binary-tree-pruning) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 783 | [二叉搜索树结点最小距离](https://github.com/openset/leetcode/tree/master/problems/minimum-distance-between-bst-nodes) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] | Easy | -| 776 | [拆分二叉搜索树](https://github.com/openset/leetcode/tree/master/problems/split-bst) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] | Medium | -| 742 | [二叉树最近的叶节点](https://github.com/openset/leetcode/tree/master/problems/closest-leaf-in-a-binary-tree) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 701 | [二叉搜索树中的插入操作](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-binary-search-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 700 | [二叉搜索树中的搜索](https://github.com/openset/leetcode/tree/master/problems/search-in-a-binary-search-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 687 | [最长同值路径](https://github.com/openset/leetcode/tree/master/problems/longest-univalue-path) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md)] | Easy | -| 685 | [冗余连接 II](https://github.com/openset/leetcode/tree/master/problems/redundant-connection-ii) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Hard | -| 684 | [冗余连接](https://github.com/openset/leetcode/tree/master/problems/redundant-connection) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 671 | [二叉树中第二小的节点](https://github.com/openset/leetcode/tree/master/problems/second-minimum-node-in-a-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 669 | [修剪二叉搜索树](https://github.com/openset/leetcode/tree/master/problems/trim-a-binary-search-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 666 | [路径和 IV](https://github.com/openset/leetcode/tree/master/problems/path-sum-iv) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 663 | [均匀树划分](https://github.com/openset/leetcode/tree/master/problems/equal-tree-partition) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 662 | [二叉树最大宽度](https://github.com/openset/leetcode/tree/master/problems/maximum-width-of-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 655 | [输出二叉树](https://github.com/openset/leetcode/tree/master/problems/print-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 654 | [最大二叉树](https://github.com/openset/leetcode/tree/master/problems/maximum-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 653 | [两数之和 IV - 输入 BST](https://github.com/openset/leetcode/tree/master/problems/two-sum-iv-input-is-a-bst) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 652 | [寻找重复的子树](https://github.com/openset/leetcode/tree/master/problems/find-duplicate-subtrees) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 637 | [二叉树的层平均值](https://github.com/openset/leetcode/tree/master/problems/average-of-levels-in-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 623 | [在二叉树中增加一行](https://github.com/openset/leetcode/tree/master/problems/add-one-row-to-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 617 | [合并二叉树](https://github.com/openset/leetcode/tree/master/problems/merge-two-binary-trees) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 606 | [根据二叉树创建字符串](https://github.com/openset/leetcode/tree/master/problems/construct-string-from-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 590 | [N叉树的后序遍历](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-postorder-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 589 | [N叉树的前序遍历](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-preorder-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 582 | [杀死进程](https://github.com/openset/leetcode/tree/master/problems/kill-process) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md)] | Medium | -| 572 | [另一个树的子树](https://github.com/openset/leetcode/tree/master/problems/subtree-of-another-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 563 | [二叉树的坡度](https://github.com/openset/leetcode/tree/master/problems/binary-tree-tilt) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 559 | [N叉树的最大深度](https://github.com/openset/leetcode/tree/master/problems/maximum-depth-of-n-ary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Easy | -| 549 | [二叉树中最长的连续序列](https://github.com/openset/leetcode/tree/master/problems/binary-tree-longest-consecutive-sequence-ii) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 545 | [二叉树的边界](https://github.com/openset/leetcode/tree/master/problems/boundary-of-binary-tree) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 543 | [二叉树的直径](https://github.com/openset/leetcode/tree/master/problems/diameter-of-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 538 | [把二叉搜索树转换为累加树](https://github.com/openset/leetcode/tree/master/problems/convert-bst-to-greater-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 536 | [从字符串生成二叉树](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-string) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 530 | [二叉搜索树的最小绝对差](https://github.com/openset/leetcode/tree/master/problems/minimum-absolute-difference-in-bst) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 515 | [在每个树行中找最大值](https://github.com/openset/leetcode/tree/master/problems/find-largest-value-in-each-tree-row) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 513 | [找树左下角的值](https://github.com/openset/leetcode/tree/master/problems/find-bottom-left-tree-value) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 510 | [二叉搜索树中的中序后继 II](https://github.com/openset/leetcode/tree/master/problems/inorder-successor-in-bst-ii) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 508 | [出现次数最多的子树元素和](https://github.com/openset/leetcode/tree/master/problems/most-frequent-subtree-sum) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 501 | [二叉搜索树中的众数](https://github.com/openset/leetcode/tree/master/problems/find-mode-in-binary-search-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 450 | [删除二叉搜索树中的节点](https://github.com/openset/leetcode/tree/master/problems/delete-node-in-a-bst) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 449 | [序列化和反序列化二叉搜索树](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-bst) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 437 | [路径总和 III](https://github.com/openset/leetcode/tree/master/problems/path-sum-iii) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 431 | [将 N 叉树编码为二叉树](https://github.com/openset/leetcode/tree/master/problems/encode-n-ary-tree-to-binary-tree) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Hard | -| 429 | [N叉树的层序遍历](https://github.com/openset/leetcode/tree/master/problems/n-ary-tree-level-order-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 428 | [序列化和反序列化 N 叉树](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-n-ary-tree) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Hard | -| 426 | [将二叉搜索树转化为排序的双向链表](https://github.com/openset/leetcode/tree/master/problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Medium | -| 404 | [左叶子之和](https://github.com/openset/leetcode/tree/master/problems/sum-of-left-leaves) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 366 | [寻找完全二叉树的叶子节点](https://github.com/openset/leetcode/tree/master/problems/find-leaves-of-binary-tree) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 337 | [打家劫舍 III](https://github.com/openset/leetcode/tree/master/problems/house-robber-iii) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 333 | [最大 BST 子树](https://github.com/openset/leetcode/tree/master/problems/largest-bst-subtree) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 298 | [二叉树最长连续序列](https://github.com/openset/leetcode/tree/master/problems/binary-tree-longest-consecutive-sequence) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 297 | [二叉树的序列化与反序列化](https://github.com/openset/leetcode/tree/master/problems/serialize-and-deserialize-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Hard | -| 285 | [二叉搜索树中的顺序后继](https://github.com/openset/leetcode/tree/master/problems/inorder-successor-in-bst) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 272 | [最接近的二叉搜索树值 II](https://github.com/openset/leetcode/tree/master/problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Hard | -| 270 | [最接近的二叉搜索树值](https://github.com/openset/leetcode/tree/master/problems/closest-binary-search-tree-value) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 257 | [二叉树的所有路径](https://github.com/openset/leetcode/tree/master/problems/binary-tree-paths) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Easy | -| 255 | [验证前序遍历序列二叉搜索树](https://github.com/openset/leetcode/tree/master/problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 250 | [统计同值子树](https://github.com/openset/leetcode/tree/master/problems/count-univalue-subtrees) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 236 | [二叉树的最近公共祖先](https://github.com/openset/leetcode/tree/master/problems/lowest-common-ancestor-of-a-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 235 | [二叉搜索树的最近公共祖先](https://github.com/openset/leetcode/tree/master/problems/lowest-common-ancestor-of-a-binary-search-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 230 | [二叉搜索树中第K小的元素](https://github.com/openset/leetcode/tree/master/problems/kth-smallest-element-in-a-bst) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 226 | [翻转二叉树](https://github.com/openset/leetcode/tree/master/problems/invert-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Easy | -| 222 | [完全二叉树的节点个数](https://github.com/openset/leetcode/tree/master/problems/count-complete-tree-nodes) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 199 | [二叉树的右视图](https://github.com/openset/leetcode/tree/master/problems/binary-tree-right-side-view) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 173 | [二叉搜索树迭代器](https://github.com/openset/leetcode/tree/master/problems/binary-search-tree-iterator) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Medium | -| 156 | [上下翻转二叉树](https://github.com/openset/leetcode/tree/master/problems/binary-tree-upside-down) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 145 | [二叉树的后序遍历](https://github.com/openset/leetcode/tree/master/problems/binary-tree-postorder-traversal) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Hard | -| 144 | [二叉树的前序遍历](https://github.com/openset/leetcode/tree/master/problems/binary-tree-preorder-traversal) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] | Medium | -| 129 | [求根到叶子节点数字之和](https://github.com/openset/leetcode/tree/master/problems/sum-root-to-leaf-numbers) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 124 | [二叉树中的最大路径和](https://github.com/openset/leetcode/tree/master/problems/binary-tree-maximum-path-sum) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](https://github.com/openset/leetcode/tree/master/problems/populating-next-right-pointers-in-each-node-ii) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](https://github.com/openset/leetcode/tree/master/problems/populating-next-right-pointers-in-each-node) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 114 | [二叉树展开为链表](https://github.com/openset/leetcode/tree/master/problems/flatten-binary-tree-to-linked-list) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 113 | [路径总和 II](https://github.com/openset/leetcode/tree/master/problems/path-sum-ii) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 112 | [路径总和](https://github.com/openset/leetcode/tree/master/problems/path-sum) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Easy | -| 111 | [二叉树的最小深度](https://github.com/openset/leetcode/tree/master/problems/minimum-depth-of-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Easy | -| 110 | [平衡二叉树](https://github.com/openset/leetcode/tree/master/problems/balanced-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Easy | -| 108 | [将有序数组转换为二叉搜索树](https://github.com/openset/leetcode/tree/master/problems/convert-sorted-array-to-binary-search-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Easy | -| 107 | [二叉树的层次遍历 II](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal-ii) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Easy | -| 106 | [从中序与后序遍历序列构造二叉树](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 105 | [从前序与中序遍历序列构造二叉树](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 104 | [二叉树的最大深度](https://github.com/openset/leetcode/tree/master/problems/maximum-depth-of-binary-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Easy | -| 103 | [二叉树的锯齿形层次遍历](https://github.com/openset/leetcode/tree/master/problems/binary-tree-zigzag-level-order-traversal) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 102 | [二叉树的层次遍历](https://github.com/openset/leetcode/tree/master/problems/binary-tree-level-order-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Medium | -| 101 | [对称二叉树](https://github.com/openset/leetcode/tree/master/problems/symmetric-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] | Easy | -| 100 | [相同的树](https://github.com/openset/leetcode/tree/master/problems/same-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Easy | -| 99 | [恢复二叉搜索树](https://github.com/openset/leetcode/tree/master/problems/recover-binary-search-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Hard | -| 98 | [验证二叉搜索树](https://github.com/openset/leetcode/tree/master/problems/validate-binary-search-tree) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium | -| 96 | [不同的二叉搜索树](https://github.com/openset/leetcode/tree/master/problems/unique-binary-search-trees) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 95 | [不同的二叉搜索树 II](https://github.com/openset/leetcode/tree/master/problems/unique-binary-search-trees-ii) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 94 | [二叉树的中序遍历](https://github.com/openset/leetcode/tree/master/problems/binary-tree-inorder-traversal) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | +| 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1257 | [最小公共区域](../../problems/smallest-common-region) 🔒 | [[树](../tree/README.md)] | Medium | +| 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] | Medium | +| 1110 | [删点成林](../../problems/delete-nodes-and-return-forest) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1104 | [二叉树寻路](../../problems/path-in-zigzag-labelled-binary-tree) | [[树](../tree/README.md)] [[数学](../math/README.md)] | Medium | +| 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 1026 | [节点与其祖先之间的最大差值](../../problems/maximum-difference-between-node-and-ancestor) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1022 | [从根到叶的二进制数之和](../../problems/sum-of-root-to-leaf-binary-numbers) | [[树](../tree/README.md)] | Easy | +| 1008 | [先序遍历构造二叉树](../../problems/construct-binary-search-tree-from-preorder-traversal) | [[树](../tree/README.md)] | Medium | +| 998 | [最大二叉树 II](../../problems/maximum-binary-tree-ii) | [[树](../tree/README.md)] | Medium | +| 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 988 | [从叶结点开始的最小字符串](../../problems/smallest-string-starting-from-leaf) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 979 | [在二叉树中分配硬币](../../problems/distribute-coins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 971 | [翻转二叉树以匹配先序遍历](../../problems/flip-binary-tree-to-match-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 965 | [单值二叉树](../../problems/univalued-binary-tree) | [[树](../tree/README.md)] | Easy | +| 958 | [二叉树的完全性检验](../../problems/check-completeness-of-a-binary-tree) | [[树](../tree/README.md)] | Medium | +| 951 | [翻转等价二叉树](../../problems/flip-equivalent-binary-trees) | [[树](../tree/README.md)] | Medium | +| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | +| 919 | [完全二叉树插入器](../../problems/complete-binary-tree-inserter) | [[树](../tree/README.md)] | Medium | +| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] | Medium | +| 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 865 | [具有所有最深结点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] | Medium | +| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 814 | [二叉树剪枝](../../problems/binary-tree-pruning) | [[树](../tree/README.md)] | Medium | +| 783 | [二叉搜索树结点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | +| 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 742 | [二叉树最近的叶节点](../../problems/closest-leaf-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | +| 701 | [二叉搜索树中的插入操作](../../problems/insert-into-a-binary-search-tree) | [[树](../tree/README.md)] | Medium | +| 700 | [二叉搜索树中的搜索](../../problems/search-in-a-binary-search-tree) | [[树](../tree/README.md)] | Easy | +| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | +| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 684 | [冗余连接](../../problems/redundant-connection) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 671 | [二叉树中第二小的节点](../../problems/second-minimum-node-in-a-binary-tree) | [[树](../tree/README.md)] | Easy | +| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] | Easy | +| 666 | [路径和 IV](../../problems/path-sum-iv) 🔒 | [[树](../tree/README.md)] | Medium | +| 663 | [均匀树划分](../../problems/equal-tree-partition) 🔒 | [[树](../tree/README.md)] | Medium | +| 662 | [二叉树最大宽度](../../problems/maximum-width-of-binary-tree) | [[树](../tree/README.md)] | Medium | +| 655 | [输出二叉树](../../problems/print-binary-tree) | [[树](../tree/README.md)] | Medium | +| 654 | [最大二叉树](../../problems/maximum-binary-tree) | [[树](../tree/README.md)] | Medium | +| 653 | [两数之和 IV - 输入 BST](../../problems/two-sum-iv-input-is-a-bst) | [[树](../tree/README.md)] | Easy | +| 652 | [寻找重复的子树](../../problems/find-duplicate-subtrees) | [[树](../tree/README.md)] | Medium | +| 637 | [二叉树的层平均值](../../problems/average-of-levels-in-binary-tree) | [[树](../tree/README.md)] | Easy | +| 623 | [在二叉树中增加一行](../../problems/add-one-row-to-tree) | [[树](../tree/README.md)] | Medium | +| 617 | [合并二叉树](../../problems/merge-two-binary-trees) | [[树](../tree/README.md)] | Easy | +| 606 | [根据二叉树创建字符串](../../problems/construct-string-from-binary-tree) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Easy | +| 590 | [N叉树的后序遍历](../../problems/n-ary-tree-postorder-traversal) | [[树](../tree/README.md)] | Easy | +| 589 | [N叉树的前序遍历](../../problems/n-ary-tree-preorder-traversal) | [[树](../tree/README.md)] | Easy | +| 582 | [杀死进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | +| 572 | [另一个树的子树](../../problems/subtree-of-another-tree) | [[树](../tree/README.md)] | Easy | +| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] | Easy | +| 559 | [N叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 549 | [二叉树中最长的连续序列](../../problems/binary-tree-longest-consecutive-sequence-ii) 🔒 | [[树](../tree/README.md)] | Medium | +| 545 | [二叉树的边界](../../problems/boundary-of-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | +| 543 | [二叉树的直径](../../problems/diameter-of-binary-tree) | [[树](../tree/README.md)] | Easy | +| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] | Easy | +| 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | +| 530 | [二叉搜索树的最小绝对差](../../problems/minimum-absolute-difference-in-bst) | [[树](../tree/README.md)] | Easy | +| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 510 | [二叉搜索树中的中序后继 II](../../problems/inorder-successor-in-bst-ii) 🔒 | [[树](../tree/README.md)] | Medium | +| 508 | [出现次数最多的子树元素和](../../problems/most-frequent-subtree-sum) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 501 | [二叉搜索树中的众数](../../problems/find-mode-in-binary-search-tree) | [[树](../tree/README.md)] | Easy | +| 450 | [删除二叉搜索树中的节点](../../problems/delete-node-in-a-bst) | [[树](../tree/README.md)] | Medium | +| 449 | [序列化和反序列化二叉搜索树](../../problems/serialize-and-deserialize-bst) | [[树](../tree/README.md)] | Medium | +| 437 | [路径总和 III](../../problems/path-sum-iii) | [[树](../tree/README.md)] | Easy | +| 431 | [将 N 叉树编码为二叉树](../../problems/encode-n-ary-tree-to-binary-tree) 🔒 | [[树](../tree/README.md)] | Hard | +| 429 | [N叉树的层序遍历](../../problems/n-ary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 428 | [序列化和反序列化 N 叉树](../../problems/serialize-and-deserialize-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard | +| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 404 | [左叶子之和](../../problems/sum-of-left-leaves) | [[树](../tree/README.md)] | Easy | +| 366 | [寻找完全二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 333 | [最大 BST 子树](../../problems/largest-bst-subtree) 🔒 | [[树](../tree/README.md)] | Medium | +| 298 | [二叉树最长连续序列](../../problems/binary-tree-longest-consecutive-sequence) 🔒 | [[树](../tree/README.md)] | Medium | +| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard | +| 285 | [二叉搜索树中的顺序后继](../../problems/inorder-successor-in-bst) 🔒 | [[树](../tree/README.md)] | Medium | +| 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Hard | +| 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | +| 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] | Medium | +| 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] | Medium | +| 235 | [二叉搜索树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-search-tree) | [[树](../tree/README.md)] | Easy | +| 230 | [二叉搜索树中第K小的元素](../../problems/kth-smallest-element-in-a-bst) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 226 | [翻转二叉树](../../problems/invert-binary-tree) | [[树](../tree/README.md)] | Easy | +| 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 156 | [上下翻转二叉树](../../problems/binary-tree-upside-down) 🔒 | [[树](../tree/README.md)] | Medium | +| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Hard | +| 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | +| 129 | [求根到叶子节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 107 | [二叉树的层次遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 103 | [二叉树的锯齿形层次遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 102 | [二叉树的层次遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 100 | [相同的树](../../problems/same-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 99 | [恢复二叉搜索树](../../problems/recover-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/trie/README.md b/tag/trie/README.md index 133d06798..593289190 100644 --- a/tag/trie/README.md +++ b/tag/trie/README.md @@ -5,24 +5,24 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 字典树 +## [话题分类](../README.md) > 字典树 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1065 | [字符串的索引对](https://github.com/openset/leetcode/tree/master/problems/index-pairs-of-a-string) 🔒 | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 1032 | [字符流](https://github.com/openset/leetcode/tree/master/problems/stream-of-characters) | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] | Hard | -| 1023 | [驼峰式匹配](https://github.com/openset/leetcode/tree/master/problems/camelcase-matching) | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 745 | [前缀和后缀搜索](https://github.com/openset/leetcode/tree/master/problems/prefix-and-suffix-search) | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] | Hard | -| 720 | [词典中最长的单词](https://github.com/openset/leetcode/tree/master/problems/longest-word-in-dictionary) | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy | -| 692 | [前K个高频单词](https://github.com/openset/leetcode/tree/master/problems/top-k-frequent-words) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 677 | [键值映射](https://github.com/openset/leetcode/tree/master/problems/map-sum-pairs) | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] | Medium | -| 676 | [实现一个魔法字典](https://github.com/openset/leetcode/tree/master/problems/implement-magic-dictionary) | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 648 | [单词替换](https://github.com/openset/leetcode/tree/master/problems/replace-words) | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium | -| 642 | [设计搜索自动补全系统](https://github.com/openset/leetcode/tree/master/problems/design-search-autocomplete-system) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] | Hard | -| 472 | [连接词](https://github.com/openset/leetcode/tree/master/problems/concatenated-words) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Hard | -| 425 | [单词方块](https://github.com/openset/leetcode/tree/master/problems/word-squares) 🔒 | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 421 | [数组中两个数的最大异或值](https://github.com/openset/leetcode/tree/master/problems/maximum-xor-of-two-numbers-in-an-array) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] | Medium | -| 336 | [回文对](https://github.com/openset/leetcode/tree/master/problems/palindrome-pairs) | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 212 | [单词搜索 II](https://github.com/openset/leetcode/tree/master/problems/word-search-ii) | [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Hard | -| 211 | [添加与搜索单词 - 数据结构设计](https://github.com/openset/leetcode/tree/master/problems/add-and-search-word-data-structure-design) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium | -| 208 | [实现 Trie (前缀树)](https://github.com/openset/leetcode/tree/master/problems/implement-trie-prefix-tree) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] | Medium | +| 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Easy | +| 1032 | [字符流](../../problems/stream-of-characters) | [[字典树](../trie/README.md)] | Hard | +| 1023 | [驼峰式匹配](../../problems/camelcase-matching) | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | +| 745 | [前缀和后缀搜索](../../problems/prefix-and-suffix-search) | [[字典树](../trie/README.md)] | Hard | +| 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[堆](../heap/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 677 | [键值映射](../../problems/map-sum-pairs) | [[字典树](../trie/README.md)] | Medium | +| 676 | [实现一个魔法字典](../../problems/implement-magic-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 648 | [单词替换](../../problems/replace-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Hard | +| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 425 | [单词方块](../../problems/word-squares) 🔒 | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 421 | [数组中两个数的最大异或值](../../problems/maximum-xor-of-two-numbers-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Medium | +| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/add-and-search-word-data-structure-design) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 8e1982275..73027ba12 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -5,67 +5,67 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 双指针 +## [话题分类](../README.md) > 双指针 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1248 | [统计「优美子数组」](https://github.com/openset/leetcode/tree/master/problems/count-number-of-nice-subarrays) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 1234 | [替换子串得到平衡字符串](https://github.com/openset/leetcode/tree/master/problems/replace-the-substring-for-balanced-string) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Medium | -| 1213 | [三个有序数组的交集](https://github.com/openset/leetcode/tree/master/problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 1093 | [大样本统计](https://github.com/openset/leetcode/tree/master/problems/statistics-from-a-large-sample) | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 1004 | [最大连续1的个数 III](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones-iii) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 992 | [K 个不同整数的子数组](https://github.com/openset/leetcode/tree/master/problems/subarrays-with-k-different-integers) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 986 | [区间列表的交集](https://github.com/openset/leetcode/tree/master/problems/interval-list-intersections) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 977 | [有序数组的平方](https://github.com/openset/leetcode/tree/master/problems/squares-of-a-sorted-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 930 | [和相同的二元子数组](https://github.com/openset/leetcode/tree/master/problems/binary-subarrays-with-sum) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 925 | [长按键入](https://github.com/openset/leetcode/tree/master/problems/long-pressed-name) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 923 | [三数之和的多种可能](https://github.com/openset/leetcode/tree/master/problems/3sum-with-multiplicity) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 904 | [水果成篮](https://github.com/openset/leetcode/tree/master/problems/fruit-into-baskets) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 881 | [救生艇](https://github.com/openset/leetcode/tree/master/problems/boats-to-save-people) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 845 | [数组中的最长山脉](https://github.com/openset/leetcode/tree/master/problems/longest-mountain-in-array) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 844 | [比较含退格的字符串](https://github.com/openset/leetcode/tree/master/problems/backspace-string-compare) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 838 | [推多米诺](https://github.com/openset/leetcode/tree/master/problems/push-dominoes) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[动态规划](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)] | Medium | -| 828 | [独特字符串](https://github.com/openset/leetcode/tree/master/problems/unique-letter-string) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Hard | -| 826 | [安排工作以达到最大收益](https://github.com/openset/leetcode/tree/master/problems/most-profit-assigning-work) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 763 | [划分字母区间](https://github.com/openset/leetcode/tree/master/problems/partition-labels) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 723 | [粉碎糖果](https://github.com/openset/leetcode/tree/master/problems/candy-crush) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 713 | [乘积小于K的子数组](https://github.com/openset/leetcode/tree/master/problems/subarray-product-less-than-k) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 632 | [最小区间](https://github.com/openset/leetcode/tree/master/problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 567 | [字符串的排列](https://github.com/openset/leetcode/tree/master/problems/permutation-in-string) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 532 | [数组中的K-diff数对](https://github.com/openset/leetcode/tree/master/problems/k-diff-pairs-in-an-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 524 | [通过删除字母匹配到字典里最长单词](https://github.com/openset/leetcode/tree/master/problems/longest-word-in-dictionary-through-deleting) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 487 | [最大连续1的个数 II](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones-ii) 🔒 | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 457 | [环形数组循环](https://github.com/openset/leetcode/tree/master/problems/circular-array-loop) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 424 | [替换后的最长重复字符](https://github.com/openset/leetcode/tree/master/problems/longest-repeating-character-replacement) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 360 | [有序转化数组](https://github.com/openset/leetcode/tree/master/problems/sort-transformed-array) 🔒 | [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 350 | [两个数组的交集 II](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays-ii) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-arrays) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 345 | [反转字符串中的元音字母](https://github.com/openset/leetcode/tree/master/problems/reverse-vowels-of-a-string) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 344 | [反转字符串](https://github.com/openset/leetcode/tree/master/problems/reverse-string) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 287 | [寻找重复数](https://github.com/openset/leetcode/tree/master/problems/find-the-duplicate-number) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 283 | [移动零](https://github.com/openset/leetcode/tree/master/problems/move-zeroes) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 259 | [较小的三数之和](https://github.com/openset/leetcode/tree/master/problems/3sum-smaller) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 234 | [回文链表](https://github.com/openset/leetcode/tree/master/problems/palindrome-linked-list) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 209 | [长度最小的子数组](https://github.com/openset/leetcode/tree/master/problems/minimum-size-subarray-sum) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium | -| 167 | [两数之和 II - 输入有序数组](https://github.com/openset/leetcode/tree/master/problems/two-sum-ii-input-array-is-sorted) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy | -| 159 | [至多包含两个不同字符的最长子串](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | -| 142 | [环形链表 II](https://github.com/openset/leetcode/tree/master/problems/linked-list-cycle-ii) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 141 | [环形链表](https://github.com/openset/leetcode/tree/master/problems/linked-list-cycle) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 125 | [验证回文串](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 88 | [合并两个有序数组](https://github.com/openset/leetcode/tree/master/problems/merge-sorted-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 86 | [分隔链表](https://github.com/openset/leetcode/tree/master/problems/partition-list) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 80 | [删除排序数组中的重复项 II](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-array-ii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 76 | [最小覆盖子串](https://github.com/openset/leetcode/tree/master/problems/minimum-window-substring) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Hard | -| 75 | [颜色分类](https://github.com/openset/leetcode/tree/master/problems/sort-colors) | [[排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 61 | [旋转链表](https://github.com/openset/leetcode/tree/master/problems/rotate-list) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 42 | [接雨水](https://github.com/openset/leetcode/tree/master/problems/trapping-rain-water) | [[栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Hard | -| 30 | [串联所有单词的子串](https://github.com/openset/leetcode/tree/master/problems/substring-with-concatenation-of-all-words) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Hard | -| 28 | [实现 strStr()](https://github.com/openset/leetcode/tree/master/problems/implement-strstr) | [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] | Easy | -| 27 | [移除元素](https://github.com/openset/leetcode/tree/master/problems/remove-element) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 26 | [删除排序数组中的重复项](https://github.com/openset/leetcode/tree/master/problems/remove-duplicates-from-sorted-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Easy | -| 19 | [删除链表的倒数第N个节点](https://github.com/openset/leetcode/tree/master/problems/remove-nth-node-from-end-of-list) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 18 | [四数之和](https://github.com/openset/leetcode/tree/master/problems/4sum) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 16 | [最接近的三数之和](https://github.com/openset/leetcode/tree/master/problems/3sum-closest) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 15 | [三数之和](https://github.com/openset/leetcode/tree/master/problems/3sum) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 11 | [盛最多水的容器](https://github.com/openset/leetcode/tree/master/problems/container-with-most-water) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] | Medium | -| 3 | [无重复字符的最长子串](https://github.com/openset/leetcode/tree/master/problems/longest-substring-without-repeating-characters) | [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[字符串](https://github.com/openset/leetcode/tree/master/tag/string/README.md)] [[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)] | Medium | +| 1248 | [统计「优美子数组」](../../problems/count-number-of-nice-subarrays) | [[双指针](../two-pointers/README.md)] | Medium | +| 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 986 | [区间列表的交集](../../problems/interval-list-intersections) | [[双指针](../two-pointers/README.md)] | Medium | +| 977 | [有序数组的平方](../../problems/squares-of-a-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 925 | [长按键入](../../problems/long-pressed-name) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 923 | [三数之和的多种可能](../../problems/3sum-with-multiplicity) | [[双指针](../two-pointers/README.md)] | Medium | +| 904 | [水果成篮](../../problems/fruit-into-baskets) | [[双指针](../two-pointers/README.md)] | Medium | +| 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 845 | [数组中的最长山脉](../../problems/longest-mountain-in-array) | [[双指针](../two-pointers/README.md)] | Medium | +| 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 828 | [独特字符串](../../problems/unique-letter-string) | [[双指针](../two-pointers/README.md)] | Hard | +| 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[双指针](../two-pointers/README.md)] | Medium | +| 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 532 | [数组中的K-diff数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 487 | [最大连续1的个数 II](../../problems/max-consecutive-ones-ii) 🔒 | [[双指针](../two-pointers/README.md)] | Medium | +| 457 | [环形数组循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 345 | [反转字符串中的元音字母](../../problems/reverse-vowels-of-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 344 | [反转字符串](../../problems/reverse-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 234 | [回文链表](../../problems/palindrome-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 141 | [环形链表](../../problems/linked-list-cycle) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 125 | [验证回文串](../../problems/valid-palindrome) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 88 | [合并两个有序数组](../../problems/merge-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 86 | [分隔链表](../../problems/partition-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 80 | [删除排序数组中的重复项 II](../../problems/remove-duplicates-from-sorted-array-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 61 | [旋转链表](../../problems/rotate-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Hard | +| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 27 | [移除元素](../../problems/remove-element) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 26 | [删除排序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 19 | [删除链表的倒数第N个节点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 11 | [盛最多水的容器](../../problems/container-with-most-water) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index 835928141..22c143e20 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -5,35 +5,35 @@ -## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > 并查集 +## [话题分类](../README.md) > 并查集 | # | 题名 | 标签 | 难度 | | :-: | - | - | :-: | -| 1202 | [交换字符串中的元素](https://github.com/openset/leetcode/tree/master/problems/smallest-string-with-swaps) | [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium | -| 1168 | [水资源分配优化](https://github.com/openset/leetcode/tree/master/problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Hard | -| 1135 | [最低成本联通所有城市](https://github.com/openset/leetcode/tree/master/problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 1102 | [得分最高的路径](https://github.com/openset/leetcode/tree/master/problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 1101 | [彼此熟识的最早时间](https://github.com/openset/leetcode/tree/master/problems/the-earliest-moment-when-everyone-become-friends) 🔒 | [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Medium | -| 1061 | [按字典序排列最小的等效字符串](https://github.com/openset/leetcode/tree/master/problems/lexicographically-smallest-equivalent-string) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Medium | -| 990 | [等式方程的可满足性](https://github.com/openset/leetcode/tree/master/problems/satisfiability-of-equality-equations) | [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 959 | [由斜杠划分区域](https://github.com/openset/leetcode/tree/master/problems/regions-cut-by-slashes) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 952 | [按公因数计算最大组件大小](https://github.com/openset/leetcode/tree/master/problems/largest-component-size-by-common-factor) | [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[数学](https://github.com/openset/leetcode/tree/master/tag/math/README.md)] | Hard | -| 947 | [移除最多的同行或同列石头](https://github.com/openset/leetcode/tree/master/problems/most-stones-removed-with-same-row-or-column) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Medium | -| 928 | [尽量减少恶意软件的传播 II](https://github.com/openset/leetcode/tree/master/problems/minimize-malware-spread-ii) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Hard | -| 924 | [尽量减少恶意软件的传播](https://github.com/openset/leetcode/tree/master/problems/minimize-malware-spread) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Hard | -| 839 | [相似字符串组](https://github.com/openset/leetcode/tree/master/problems/similar-string-groups) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Hard | -| 803 | [打砖块](https://github.com/openset/leetcode/tree/master/problems/bricks-falling-when-hit) | [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Hard | -| 778 | [水位上升的泳池中游泳](https://github.com/openset/leetcode/tree/master/problems/swim-in-rising-water) | [[堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Hard | -| 765 | [情侣牵手](https://github.com/openset/leetcode/tree/master/problems/couples-holding-hands) | [[贪心算法](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Hard | -| 737 | [句子相似性 II](https://github.com/openset/leetcode/tree/master/problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Medium | -| 721 | [账户合并](https://github.com/openset/leetcode/tree/master/problems/accounts-merge) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Medium | -| 685 | [冗余连接 II](https://github.com/openset/leetcode/tree/master/problems/redundant-connection-ii) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Hard | -| 684 | [冗余连接](https://github.com/openset/leetcode/tree/master/problems/redundant-connection) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 547 | [朋友圈](https://github.com/openset/leetcode/tree/master/problems/friend-circles) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Medium | -| 399 | [除法求值](https://github.com/openset/leetcode/tree/master/problems/evaluate-division) | [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 323 | [无向图中连通分量的数目](https://github.com/openset/leetcode/tree/master/problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 305 | [岛屿数量 II](https://github.com/openset/leetcode/tree/master/problems/number-of-islands-ii) 🔒 | [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Hard | -| 261 | [以图判树](https://github.com/openset/leetcode/tree/master/problems/graph-valid-tree) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)] | Medium | -| 200 | [岛屿数量](https://github.com/openset/leetcode/tree/master/problems/number-of-islands) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Medium | -| 130 | [被围绕的区域](https://github.com/openset/leetcode/tree/master/problems/surrounded-regions) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Medium | -| 128 | [最长连续序列](https://github.com/openset/leetcode/tree/master/problems/longest-consecutive-sequence) | [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Hard | +| 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | +| 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 1135 | [最低成本联通所有城市](../../problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 1101 | [彼此熟识的最早时间](../../problems/the-earliest-moment-when-everyone-become-friends) 🔒 | [[并查集](../union-find/README.md)] | Medium | +| 1061 | [按字典序排列最小的等效字符串](../../problems/lexicographically-smallest-equivalent-string) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 990 | [等式方程的可满足性](../../problems/satisfiability-of-equality-equations) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 952 | [按公因数计算最大组件大小](../../problems/largest-component-size-by-common-factor) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | +| 947 | [移除最多的同行或同列石头](../../problems/most-stones-removed-with-same-row-or-column) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 924 | [尽量减少恶意软件的传播](../../problems/minimize-malware-spread) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | +| 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 803 | [打砖块](../../problems/bricks-falling-when-hit) | [[并查集](../union-find/README.md)] | Hard | +| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 721 | [账户合并](../../problems/accounts-merge) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 684 | [冗余连接](../../problems/redundant-connection) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 547 | [朋友圈](../../problems/friend-circles) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 399 | [除法求值](../../problems/evaluate-division) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 305 | [岛屿数量 II](../../problems/number-of-islands-ii) 🔒 | [[并查集](../union-find/README.md)] | Hard | +| 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 128 | [最长连续序列](../../problems/longest-consecutive-sequence) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Hard | From ec525e92e08c2b00fb1d80ec506bab3e716157cd Mon Sep 17 00:00:00 2001 From: openset Date: Wed, 18 Dec 2019 16:59:31 +0800 Subject: [PATCH 015/145] Add: Integer Break --- internal/leetcode/problems_status.go | 1 + problems/integer-break/integer_break.go | 12 +++++++ problems/integer-break/integer_break_test.go | 38 ++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/internal/leetcode/problems_status.go b/internal/leetcode/problems_status.go index 806d419be..22f685cd6 100644 --- a/internal/leetcode/problems_status.go +++ b/internal/leetcode/problems_status.go @@ -97,6 +97,7 @@ var problemStatus = map[int]bool{ 319: true, 326: true, 342: true, + 343: true, 344: true, 345: true, 350: true, diff --git a/problems/integer-break/integer_break.go b/problems/integer-break/integer_break.go index befef58b1..eb9c835a6 100644 --- a/problems/integer-break/integer_break.go +++ b/problems/integer-break/integer_break.go @@ -1 +1,13 @@ package problem343 + +func integerBreak(n int) int { + if n <= 3 { + return n - 1 + } + ans := 1 + for n > 4 { + n -= 3 + ans *= 3 + } + return ans * n +} diff --git a/problems/integer-break/integer_break_test.go b/problems/integer-break/integer_break_test.go index befef58b1..2d58ab424 100644 --- a/problems/integer-break/integer_break_test.go +++ b/problems/integer-break/integer_break_test.go @@ -1 +1,39 @@ package problem343 + +import "testing" + +type testType struct { + in int + want int +} + +func TestIntegerBreak(t *testing.T) { + tests := [...]testType{ + { + in: 2, + want: 1, + }, + { + in: 10, + want: 36, + }, + { + in: 3, + want: 2, + }, + { + in: 7, + want: 12, + }, + { + in: 17, + want: 486, + }, + } + for _, tt := range tests { + got := integerBreak(tt.in) + if got != tt.want { + t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want) + } + } +} From 3b37d75984bc1443e592e751e17f9be5dd9aeec5 Mon Sep 17 00:00:00 2001 From: openset Date: Mon, 23 Dec 2019 09:39:58 +0800 Subject: [PATCH 016/145] Add: new --- README.md | 9 +- internal/leetcode/topic_tag.go | 4 +- problems/best-meeting-point/README.md | 2 +- .../copy-list-with-random-pointer/README.md | 51 +++++++--- .../README.md | 76 +++++++++++++++ .../README.md | 59 ++++++++++++ problems/flip-game-ii/README.md | 2 +- problems/immediate-food-delivery-i/README.md | 2 +- .../README.md | 93 +++++++++++++++++++ .../README.md | 81 ++++++++++++++++ .../README.md | 2 +- problems/students-and-examinations/README.md | 2 +- .../weather-type-in-each-country/README.md | 14 +++ .../mysql_schemas.sql | 27 ++++++ tag/array/README.md | 2 + tag/bit-manipulation/README.md | 1 + tag/breadth-first-search/README.md | 1 + tag/greedy/README.md | 1 + tag/string/README.md | 1 + 19 files changed, 409 insertions(+), 21 deletions(-) create mode 100644 problems/divide-array-in-sets-of-k-consecutive-numbers/README.md create mode 100644 problems/find-numbers-with-even-number-of-digits/README.md create mode 100644 problems/maximum-candies-you-can-get-from-boxes/README.md create mode 100644 problems/maximum-number-of-occurrences-of-a-substring/README.md create mode 100644 problems/weather-type-in-each-country/README.md create mode 100644 problems/weather-type-in-each-country/mysql_schemas.sql diff --git a/README.md b/README.md index 4bce71657..53e640787 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,11 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1298 | [Maximum Candies You Can Get from Boxes](https://leetcode.com/problems/maximum-candies-you-can-get-from-boxes "你能从盒子里获得的最大糖果数") | [Go](problems/maximum-candies-you-can-get-from-boxes) | Hard | +| 1297 | [Maximum Number of Occurrences of a Substring](https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring "子串的最大出现次数") | [Go](problems/maximum-number-of-occurrences-of-a-substring) | Medium | +| 1296 | [Divide Array in Sets of K Consecutive Numbers](https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers "划分数组为连续数字的集合") | [Go](problems/divide-array-in-sets-of-k-consecutive-numbers) | Medium | +| 1295 | [Find Numbers with Even Number of Digits](https://leetcode.com/problems/find-numbers-with-even-number-of-digits "统计位数为偶数的数字") | [Go](problems/find-numbers-with-even-number-of-digits) | Easy | +| 1294 | [Weather Type in Each Country](https://leetcode.com/problems/weather-type-in-each-country) 🔒 | [MySQL](problems/weather-type-in-each-country) | Easy | | 1293 | [Shortest Path in a Grid with Obstacles Elimination](https://leetcode.com/problems/shortest-path-in-a-grid-with-obstacles-elimination "网格中的最短路径") | [Go](problems/shortest-path-in-a-grid-with-obstacles-elimination) | Hard | | 1292 | [Maximum Side Length of a Square with Sum Less than or Equal to Threshold](https://leetcode.com/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold "元素和小于等于阈值的正方形的最大边长") | [Go](problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | Medium | | 1291 | [Sequential Digits](https://leetcode.com/problems/sequential-digits "顺次数") | [Go](problems/sequential-digits) | Medium | @@ -75,7 +80,7 @@ LeetCode Problems' Solutions | 1283 | [Find the Smallest Divisor Given a Threshold](https://leetcode.com/problems/find-the-smallest-divisor-given-a-threshold "使结果不超过阈值的最小除数") | [Go](problems/find-the-smallest-divisor-given-a-threshold) | Medium | | 1282 | [Group the People Given the Group Size They Belong To](https://leetcode.com/problems/group-the-people-given-the-group-size-they-belong-to "用户分组") | [Go](problems/group-the-people-given-the-group-size-they-belong-to) | Medium | | 1281 | [Subtract the Product and Sum of Digits of an Integer](https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer "整数的各位积和之差") | [Go](problems/subtract-the-product-and-sum-of-digits-of-an-integer) | Easy | -| 1280 | [Students and Examinations](https://leetcode.com/problems/students-and-examinations) 🔒 | [MySQL](problems/students-and-examinations) | Easy | +| 1280 | [Students and Examinations](https://leetcode.com/problems/students-and-examinations "学生们参加各科测试的次数") 🔒 | [MySQL](problems/students-and-examinations) | Easy | | 1279 | [Traffic Light Controlled Intersection](https://leetcode.com/problems/traffic-light-controlled-intersection) 🔒 | [Go](problems/traffic-light-controlled-intersection) | Easy | | 1278 | [Palindrome Partitioning III](https://leetcode.com/problems/palindrome-partitioning-iii "分割回文串 III") | [Go](problems/palindrome-partitioning-iii) | Hard | | 1277 | [Count Square Submatrices with All Ones](https://leetcode.com/problems/count-square-submatrices-with-all-ones "统计全为 1 的正方形子矩阵") | [Go](problems/count-square-submatrices-with-all-ones) | Medium | @@ -182,7 +187,7 @@ LeetCode Problems' Solutions | 1176 | [Diet Plan Performance](https://leetcode.com/problems/diet-plan-performance "健身计划评估") 🔒 | [Go](problems/diet-plan-performance) | Easy | | 1175 | [Prime Arrangements](https://leetcode.com/problems/prime-arrangements "质数排列") | [Go](problems/prime-arrangements) | Easy | | 1174 | [Immediate Food Delivery II](https://leetcode.com/problems/immediate-food-delivery-ii) 🔒 | [MySQL](problems/immediate-food-delivery-ii) | Medium | -| 1173 | [Immediate Food Delivery I](https://leetcode.com/problems/immediate-food-delivery-i) 🔒 | [MySQL](problems/immediate-food-delivery-i) | Easy | +| 1173 | [Immediate Food Delivery I](https://leetcode.com/problems/immediate-food-delivery-i "即时食物配送 I") 🔒 | [MySQL](problems/immediate-food-delivery-i) | Easy | | 1172 | [Dinner Plate Stacks](https://leetcode.com/problems/dinner-plate-stacks "餐盘栈") | [Go](problems/dinner-plate-stacks) | Hard | | 1171 | [Remove Zero Sum Consecutive Nodes from Linked List](https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list "从链表中删去总和值为零的连续节点") | [Go](problems/remove-zero-sum-consecutive-nodes-from-linked-list) | Medium | | 1170 | [Compare Strings by Frequency of the Smallest Character](https://leetcode.com/problems/compare-strings-by-frequency-of-the-smallest-character "比较字符串最小字母出现频次") | [Go](problems/compare-strings-by-frequency-of-the-smallest-character) | Easy | diff --git a/internal/leetcode/topic_tag.go b/internal/leetcode/topic_tag.go index c297cb3c9..17ae396d8 100644 --- a/internal/leetcode/topic_tag.go +++ b/internal/leetcode/topic_tag.go @@ -42,7 +42,9 @@ func (tag *TagType) SaveContents() { if question.TranslatedTitle == "" { question.TranslatedTitle = question.Title } - buf.WriteString(fmt.Sprintf(format, question.frontendID(), question.TranslatedTitle, question.TitleSlug, question.IsPaidOnly.Str(), question.TagsStr(), question.Difficulty)) + if question.frontendID() > 0 { + buf.WriteString(fmt.Sprintf(format, question.frontendID(), question.TranslatedTitle, question.TitleSlug, question.IsPaidOnly.Str(), question.TagsStr(), question.Difficulty)) + } } filename := filepath.Join("tag", tag.Slug, "README.md") filePutContents(filename, buf.Bytes()) diff --git a/problems/best-meeting-point/README.md b/problems/best-meeting-point/README.md index bb2a41eb3..297450d60 100644 --- a/problems/best-meeting-point/README.md +++ b/problems/best-meeting-point/README.md @@ -31,8 +31,8 @@ Explanation: Given three people living at (0,0), (0,   of 2+2+2=6 is minimal. So return 6. ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Math](../../tag/math/README.md)] + [[Sort](../../tag/sort/README.md)] ### Similar Questions 1. [Shortest Distance from All Buildings](../shortest-distance-from-all-buildings) (Hard) diff --git a/problems/copy-list-with-random-pointer/README.md b/problems/copy-list-with-random-pointer/README.md index ba40520ee..d09f36026 100644 --- a/problems/copy-list-with-random-pointer/README.md +++ b/problems/copy-list-with-random-pointer/README.md @@ -15,28 +15,53 @@

Return a deep copy of the list.

-

 

+

The Linked List is represented in the input/output as a list of n nodes. Each node is represented as a pair of [val, random_index] where:

+ +
    +
  • val: an integer representing Node.val
  • +
  • random_index: the index of the node (range from 0 to n-1) where random pointer points to, or null if it does not point to any node.
  • +
+

 

Example 1:

+ +
+Input: head = [[7,null],[13,0],[11,4],[10,2],[1,0]]
+Output: [[7,null],[13,0],[11,4],[10,2],[1,0]]
+
+ +

Example 2:

+ +
+Input: head = [[1,1],[2,1]]
+Output: [[1,1],[2,1]]
+
+ +

Example 3:

-

+

-Input:
-{"$id":"1","next":{"$id":"2","next":null,"random":{"$ref":"2"},"val":2},"random":{"$ref":"2"},"val":1}
-
-Explanation:
-Node 1's value is 1, both of its next and random pointer points to Node 2.
-Node 2's value is 2, its next pointer points to null and its random pointer points to itself.
+Input: head = [[3,null],[3,0],[3,null]]
+Output: [[3,null],[3,0],[3,null]]
 
-

 

+

Example 4:

-

Note:

+
+Input: head = []
+Output: []
+Explanation: Given linked list is empty (null pointer), so return null.
+
+ +

 

+

Constraints:

-
    -
  1. You must return the copy of the given head as a reference to the cloned list.
  2. -
+
    +
  • -10000 <= Node.val <= 10000
  • +
  • Node.random is null or pointing to a node in the linked list.
  • +
  • Number of Nodes will not exceed 1000.
  • +
### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md b/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md new file mode 100644 index 000000000..a0d5c312b --- /dev/null +++ b/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](../find-numbers-with-even-number-of-digits "Find Numbers with Even Number of Digits") +                 +[Next >](../maximum-number-of-occurrences-of-a-substring "Maximum Number of Occurrences of a Substring") + +## [1296. Divide Array in Sets of K Consecutive Numbers (Medium)](https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers "划分数组为连续数字的集合") + +

Given an array of integers nums and a positive integer k, find whether it's possible to divide this array into sets of k consecutive numbers
+Return True if its possible otherwise return False.

+ +

 

+

Example 1:

+ +
+Input: nums = [1,2,3,3,4,4,5,6], k = 4
+Output: true
+Explanation: Array can be divided into [1,2,3,4] and [3,4,5,6].
+
+ +

Example 2:

+ +
+Input: nums = [3,2,1,2,3,4,3,4,5,9,10,11], k = 3
+Output: true
+Explanation: Array can be divided into [1,2,3] , [2,3,4] , [3,4,5] and [9,10,11].
+
+ +

Example 3:

+ +
+Input: nums = [3,3,2,2,1,1], k = 3
+Output: true
+
+ +

Example 4:

+ +
+Input: nums = [1,2,3,4], k = 3
+Output: false
+Explanation: Each array should be divided in subarrays of size 3.
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= nums.length <= 10^5
  • +
  • 1 <= nums[i] <= 10^9
  • +
  • 1 <= k <= nums.length
  • +
+ +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
+Hint 1 +If the smallest number in the possible-to-split array is V, then numbers V+1, V+2, ... V+k-1 must contain there as well. +
+ +
+Hint 2 +You can iteratively find k sets and remove them from array until it becomes empty. +
+ +
+Hint 3 +Failure to do so would mean that array is unsplittable. +
diff --git a/problems/find-numbers-with-even-number-of-digits/README.md b/problems/find-numbers-with-even-number-of-digits/README.md new file mode 100644 index 000000000..fc610d517 --- /dev/null +++ b/problems/find-numbers-with-even-number-of-digits/README.md @@ -0,0 +1,59 @@ + + + + + + + +[< Previous](../weather-type-in-each-country "Weather Type in Each Country") +                 +[Next >](../divide-array-in-sets-of-k-consecutive-numbers "Divide Array in Sets of K Consecutive Numbers") + +## [1295. Find Numbers with Even Number of Digits (Easy)](https://leetcode.com/problems/find-numbers-with-even-number-of-digits "统计位数为偶数的数字") + +Given an array nums of integers, return how many of them contain an even number of digits. +

 

+

Example 1:

+ +
+Input: nums = [12,345,2,6,7896]
+Output: 2
+Explanation: 
+12 contains 2 digits (even number of digits). 
+345 contains 3 digits (odd number of digits). 
+2 contains 1 digit (odd number of digits). 
+6 contains 1 digit (odd number of digits). 
+7896 contains 4 digits (even number of digits). 
+Therefore only 12 and 7896 contain an even number of digits.
+
+ +

Example 2:

+ +
+Input: nums = [555,901,482,1771]
+Output: 1 
+Explanation: 
+Only 1771 contains an even number of digits.
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= nums.length <= 500
  • +
  • 1 <= nums[i] <= 10^5
  • +
+ +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
+Hint 1 +How to compute the number of digits of a number ? +
+ +
+Hint 2 +Divide the number by 10 again and again to get the number of digits. +
diff --git a/problems/flip-game-ii/README.md b/problems/flip-game-ii/README.md index 2f1cb21a4..b35d2be9a 100644 --- a/problems/flip-game-ii/README.md +++ b/problems/flip-game-ii/README.md @@ -27,8 +27,8 @@ Derive your algorithm's runtime complexity.

### Related Topics - [[Backtracking](../../tag/backtracking/README.md)] [[Minimax](../../tag/minimax/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions 1. [Nim Game](../nim-game) (Easy) diff --git a/problems/immediate-food-delivery-i/README.md b/problems/immediate-food-delivery-i/README.md index 2eb47ffb4..39a2a918a 100644 --- a/problems/immediate-food-delivery-i/README.md +++ b/problems/immediate-food-delivery-i/README.md @@ -9,7 +9,7 @@                  [Next >](../immediate-food-delivery-ii "Immediate Food Delivery II") -## [1173. Immediate Food Delivery I (Easy)](https://leetcode.com/problems/immediate-food-delivery-i "") +## [1173. Immediate Food Delivery I (Easy)](https://leetcode.com/problems/immediate-food-delivery-i "即时食物配送 I")

Table: Delivery

diff --git a/problems/maximum-candies-you-can-get-from-boxes/README.md b/problems/maximum-candies-you-can-get-from-boxes/README.md new file mode 100644 index 000000000..584b72f91 --- /dev/null +++ b/problems/maximum-candies-you-can-get-from-boxes/README.md @@ -0,0 +1,93 @@ + + + + + + + +[< Previous](../maximum-number-of-occurrences-of-a-substring "Maximum Number of Occurrences of a Substring") +                 +Next > + +## [1298. Maximum Candies You Can Get from Boxes (Hard)](https://leetcode.com/problems/maximum-candies-you-can-get-from-boxes "你能从盒子里获得的最大糖果数") + +

Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:

+ +
    +
  • status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
  • +
  • candies[i]: an integer representing the number of candies in box[i].
  • +
  • keys[i]: an array contains the indices of the boxes you can open with the key in box[i].
  • +
  • containedBoxes[i]: an array contains the indices of the boxes found in box[i].
  • +
+ +

You will start with some boxes given in initialBoxes array. You can take all the candies in any open box and you can use the keys in it to open new boxes and you also can use the boxes you find in it.

+ +

Return the maximum number of candies you can get following the rules above.

+ +

 

+

Example 1:

+ +
+Input: status = [1,0,1,0], candies = [7,5,4,100], keys = [[],[],[1],[]], containedBoxes = [[1,2],[3],[],[]], initialBoxes = [0]
+Output: 16
+Explanation: You will be initially given box 0. You will find 7 candies in it and boxes 1 and 2. Box 1 is closed and you don't have a key for it so you will open box 2. You will find 4 candies and a key to box 1 in box 2.
+In box 1, you will find 5 candies and box 3 but you will not find a key to box 3 so box 3 will remain closed.
+Total number of candies collected = 7 + 4 + 5 = 16 candy.
+
+ +

Example 2:

+ +
+Input: status = [1,0,0,0,0,0], candies = [1,1,1,1,1,1], keys = [[1,2,3,4,5],[],[],[],[],[]], containedBoxes = [[1,2,3,4,5],[],[],[],[],[]], initialBoxes = [0]
+Output: 6
+Explanation: You have initially box 0. Opening it you can find boxes 1,2,3,4 and 5 and their keys. The total number of candies will be 6.
+
+ +

Example 3:

+ +
+Input: status = [1,1,1], candies = [100,1,100], keys = [[],[0,2],[]], containedBoxes = [[],[],[]], initialBoxes = [1]
+Output: 1
+
+ +

Example 4:

+ +
+Input: status = [1], candies = [100], keys = [[]], containedBoxes = [[]], initialBoxes = []
+Output: 0
+
+ +

Example 5:

+ +
+Input: status = [1,1,1], candies = [2,3,2], keys = [[],[],[]], containedBoxes = [[],[],[]], initialBoxes = [2,1,0]
+Output: 7
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= status.length <= 1000
  • +
  • status.length == candies.length == keys.length == containedBoxes.length == n
  • +
  • status[i] is 0 or 1.
  • +
  • 1 <= candies[i] <= 1000
  • +
  • 0 <= keys[i].length <= status.length
  • +
  • 0 <= keys[i][j] < status.length
  • +
  • All values in keys[i] are unique.
  • +
  • 0 <= containedBoxes[i].length <= status.length
  • +
  • 0 <= containedBoxes[i][j] < status.length
  • +
  • All values in containedBoxes[i] are unique.
  • +
  • Each box is contained in one box at most.
  • +
  • 0 <= initialBoxes.length <= status.length
  • +
  • 0 <= initialBoxes[i] < status.length
  • +
+ +### Related Topics + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + +### Hints +
+Hint 1 +Use Breadth First Search (BFS) to traverse all possible boxes you can open. Only push to the queue the boxes the you have with their keys. +
diff --git a/problems/maximum-number-of-occurrences-of-a-substring/README.md b/problems/maximum-number-of-occurrences-of-a-substring/README.md new file mode 100644 index 000000000..2716510ab --- /dev/null +++ b/problems/maximum-number-of-occurrences-of-a-substring/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../divide-array-in-sets-of-k-consecutive-numbers "Divide Array in Sets of K Consecutive Numbers") +                 +[Next >](../maximum-candies-you-can-get-from-boxes "Maximum Candies You Can Get from Boxes") + +## [1297. Maximum Number of Occurrences of a Substring (Medium)](https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring "子串的最大出现次数") + +

Given a string s, return the maximum number of ocurrences of any substring under the following rules:

+ +
    +
  • The number of unique characters in the substring must be less than or equal to maxLetters.
  • +
  • The substring size must be between minSize and maxSize inclusive.
  • +
+ +

 

+

Example 1:

+ +
+Input: s = "aababcaab", maxLetters = 2, minSize = 3, maxSize = 4
+Output: 2
+Explanation: Substring "aab" has 2 ocurrences in the original string.
+It satisfies the conditions, 2 unique letters and size 3 (between minSize and maxSize).
+
+ +

Example 2:

+ +
+Input: s = "aaaa", maxLetters = 1, minSize = 3, maxSize = 3
+Output: 2
+Explanation: Substring "aaa" occur 2 times in the string. It can overlap.
+
+ +

Example 3:

+ +
+Input: s = "aabcabcab", maxLetters = 2, minSize = 2, maxSize = 3
+Output: 3
+
+ +

Example 4:

+ +
+Input: s = "abcde", maxLetters = 2, minSize = 3, maxSize = 3
+Output: 0
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= s.length <= 10^5
  • +
  • 1 <= maxLetters <= 26
  • +
  • 1 <= minSize <= maxSize <= min(26, s.length)
  • +
  • s only contains lowercase English letters.
  • +
+ +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
+Hint 1 +Check out the constraints, (maxSize <=26). +
+ +
+Hint 2 +This means you can explore all substrings in O(n * 26). +
+ +
+Hint 3 +Find the Maximum Number of Occurrences of a Substring with bruteforce. +
diff --git a/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md b/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md index 59f261ac0..8b4f60995 100644 --- a/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md +++ b/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md @@ -7,7 +7,7 @@ [< Previous](../maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold "Maximum Side Length of a Square with Sum Less than or Equal to Threshold")                  -Next > +[Next >](../weather-type-in-each-country "Weather Type in Each Country") ## [1293. Shortest Path in a Grid with Obstacles Elimination (Hard)](https://leetcode.com/problems/shortest-path-in-a-grid-with-obstacles-elimination "网格中的最短路径") diff --git a/problems/students-and-examinations/README.md b/problems/students-and-examinations/README.md index 06b103b4d..bb99c2475 100644 --- a/problems/students-and-examinations/README.md +++ b/problems/students-and-examinations/README.md @@ -9,7 +9,7 @@                  [Next >](../subtract-the-product-and-sum-of-digits-of-an-integer "Subtract the Product and Sum of Digits of an Integer") -## [1280. Students and Examinations (Easy)](https://leetcode.com/problems/students-and-examinations "") +## [1280. Students and Examinations (Easy)](https://leetcode.com/problems/students-and-examinations "学生们参加各科测试的次数")

Table: Students

diff --git a/problems/weather-type-in-each-country/README.md b/problems/weather-type-in-each-country/README.md
new file mode 100644
index 000000000..4f3e18a09
--- /dev/null
+++ b/problems/weather-type-in-each-country/README.md
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+[< Previous](../shortest-path-in-a-grid-with-obstacles-elimination "Shortest Path in a Grid with Obstacles Elimination")
+                
+[Next >](../find-numbers-with-even-number-of-digits "Find Numbers with Even Number of Digits")
+
+## [1294. Weather Type in Each Country (Easy)](https://leetcode.com/problems/weather-type-in-each-country "")
+
+
diff --git a/problems/weather-type-in-each-country/mysql_schemas.sql b/problems/weather-type-in-each-country/mysql_schemas.sql
new file mode 100644
index 000000000..047159d79
--- /dev/null
+++ b/problems/weather-type-in-each-country/mysql_schemas.sql
@@ -0,0 +1,27 @@
+Create table If Not Exists Countries (country_id int, country_name varchar(20));
+Create table If Not Exists Weather (country_id int, weather_state int, day date);
+Truncate table Countries;
+insert into Countries (country_id, country_name) values ('2', 'USA');
+insert into Countries (country_id, country_name) values ('3', 'Australia');
+insert into Countries (country_id, country_name) values ('7', 'Peru');
+insert into Countries (country_id, country_name) values ('5', 'China');
+insert into Countries (country_id, country_name) values ('8', 'Morocco');
+insert into Countries (country_id, country_name) values ('9', 'Spain');
+Truncate table Weather;
+insert into Weather (country_id, weather_state, day) values ('2', '15', '2019-11-01');
+insert into Weather (country_id, weather_state, day) values ('2', '12', '2019-10-28');
+insert into Weather (country_id, weather_state, day) values ('2', '12', '2019-10-27');
+insert into Weather (country_id, weather_state, day) values ('3', '-2', '2019-11-10');
+insert into Weather (country_id, weather_state, day) values ('3', '0', '2019-11-11');
+insert into Weather (country_id, weather_state, day) values ('3', '3', '2019-11-12');
+insert into Weather (country_id, weather_state, day) values ('5', '16', '2019-11-07');
+insert into Weather (country_id, weather_state, day) values ('5', '18', '2019-11-09');
+insert into Weather (country_id, weather_state, day) values ('5', '21', '2019-11-23');
+insert into Weather (country_id, weather_state, day) values ('7', '25', '2019-11-28');
+insert into Weather (country_id, weather_state, day) values ('7', '22', '2019-12-01');
+insert into Weather (country_id, weather_state, day) values ('7', '20', '2019-12-02');
+insert into Weather (country_id, weather_state, day) values ('8', '25', '2019-11-05');
+insert into Weather (country_id, weather_state, day) values ('8', '27', '2019-11-15');
+insert into Weather (country_id, weather_state, day) values ('8', '31', '2019-11-25');
+insert into Weather (country_id, weather_state, day) values ('9', '7', '2019-10-23');
+insert into Weather (country_id, weather_state, day) values ('9', '3', '2019-12-23');
diff --git a/tag/array/README.md b/tag/array/README.md
index 65b453837..c27081e6a 100644
--- a/tag/array/README.md
+++ b/tag/array/README.md
@@ -9,6 +9,8 @@
 
 | # | 题名 | 标签 | 难度 |
 | :-: | - | - | :-: |
+| 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)]  | Medium |
+| 1295 | [统计位数为偶数的数字](../../problems/find-numbers-with-even-number-of-digits) | [[数组](../array/README.md)]  | Easy |
 | 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)]  | Medium |
 | 1287 | [有序数组中出现次数超过25%的元素](../../problems/element-appearing-more-than-25-in-sorted-array) | [[数组](../array/README.md)]  | Easy |
 | 1277 | [统计全为 1 的正方形子矩阵](../../problems/count-square-submatrices-with-all-ones) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)]  | Medium |
diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md
index b33bb8c94..c7a0a6025 100644
--- a/tag/bit-manipulation/README.md
+++ b/tag/bit-manipulation/README.md
@@ -9,6 +9,7 @@
 
 | # | 题名 | 标签 | 难度 |
 | :-: | - | - | :-: |
+| 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)]  | Medium |
 | 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)]  | Easy |
 | 1256 | [加密数字](../../problems/encode-number) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)]  | Medium |
 | 1255 | [得分最高的单词集合](../../problems/maximum-score-words-formed-by-letters) | [[位运算](../bit-manipulation/README.md)]  | Hard |
diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md
index cc761a19f..e59be563c 100644
--- a/tag/breadth-first-search/README.md
+++ b/tag/breadth-first-search/README.md
@@ -9,6 +9,7 @@
 
 | # | 题名 | 标签 | 难度 |
 | :-: | - | - | :-: |
+| 1298 | [你能从盒子里获得的最大糖果数](../../problems/maximum-candies-you-can-get-from-boxes) | [[广度优先搜索](../breadth-first-search/README.md)]  | Hard |
 | 1293 | [网格中的最短路径](../../problems/shortest-path-in-a-grid-with-obstacles-elimination) | [[广度优先搜索](../breadth-first-search/README.md)]  | Hard |
 | 1284 | [转化为全零矩阵的最少反转次数](../../problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | [[广度优先搜索](../breadth-first-search/README.md)]  | Hard |
 | 1263 | [推箱子](../../problems/minimum-moves-to-move-a-box-to-their-target-location) | [[广度优先搜索](../breadth-first-search/README.md)]  | Hard |
diff --git a/tag/greedy/README.md b/tag/greedy/README.md
index 7c819aa53..f5e2fd318 100644
--- a/tag/greedy/README.md
+++ b/tag/greedy/README.md
@@ -9,6 +9,7 @@
 
 | # | 题名 | 标签 | 难度 |
 | :-: | - | - | :-: |
+| 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)]  | Medium |
 | 1282 | [用户分组](../../problems/group-the-people-given-the-group-size-they-belong-to) | [[贪心算法](../greedy/README.md)]  | Medium |
 | 1276 | [不浪费原料的汉堡制作方案](../../problems/number-of-burgers-with-no-waste-of-ingredients) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)]  | Medium |
 | 1253 | [重构 2 行二进制矩阵](../../problems/reconstruct-a-2-row-binary-matrix) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)]  | Medium |
diff --git a/tag/string/README.md b/tag/string/README.md
index 82fa26b3c..db4c81d85 100644
--- a/tag/string/README.md
+++ b/tag/string/README.md
@@ -9,6 +9,7 @@
 
 | # | 题名 | 标签 | 难度 |
 | :-: | - | - | :-: |
+| 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)]  | Medium |
 | 1271 | [十六进制魔术数字](../../problems/hexspeak) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)]  | Easy |
 | 1268 | [搜索推荐系统](../../problems/search-suggestions-system) | [[字符串](../string/README.md)]  | Medium |
 | 1249 | [移除无效的括号](../../problems/minimum-remove-to-make-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)]  | Medium |

From d40e31a380b3de555290af6955b3a090f4bc4d25 Mon Sep 17 00:00:00 2001
From: openset 
Date: Mon, 23 Dec 2019 10:21:52 +0800
Subject: [PATCH 017/145] Add: Weather Type in Each Country

---
 .../weather-type-in-each-country/README.md    | 82 +++++++++++++++++++
 .../weather_type_in_each_country.sql          | 11 +++
 2 files changed, 93 insertions(+)
 create mode 100644 problems/weather-type-in-each-country/weather_type_in_each_country.sql

diff --git a/problems/weather-type-in-each-country/README.md b/problems/weather-type-in-each-country/README.md
index 4f3e18a09..b9bbc9ae6 100644
--- a/problems/weather-type-in-each-country/README.md
+++ b/problems/weather-type-in-each-country/README.md
@@ -11,4 +11,86 @@
 
 ## [1294. Weather Type in Each Country (Easy)](https://leetcode.com/problems/weather-type-in-each-country "")
 
+

Table: Countries

+
++---------------+---------+
+| Column Name   | Type    |
++---------------+---------+
+| country_id    | int     |
+| country_name  | varchar |
++---------------+---------+
+country_id is the primary key for this table.
+Each row of this table contains the ID and the name of one country.
+
+ +

Table: Weather

+
++---------------+---------+
+| Column Name   | Type    |
++---------------+---------+
+| country_id    | int     |
+| weather_state | varchar |
+| day           | date    |
++---------------+---------+
+(country_id, day) is the primary key for this table.
+Each row of this table indicates the weather state in a country for one day.
+
+ +Write an SQL query to find the type of weather in each country for November 2019. +The type of weather is Cold if the average weather_state is less than or equal 15, Hot if the average weather_state is greater than or equal 25 and Warm otherwise. + +Return result table in any order. + +The query result format is in the following example: +
+Countries table:
++------------+--------------+
+| country_id | country_name |
++------------+--------------+
+| 2          | USA          |
+| 3          | Australia    |
+| 7          | Peru         |
+| 5          | China        |
+| 8          | Morocco      |
+| 9          | Spain        |
++------------+--------------+
+Weather table:
++------------+---------------+------------+
+| country_id | weather_state | day        |
++------------+---------------+------------+
+| 2          | 15            | 2019-11-01 |
+| 2          | 12            | 2019-10-28 |
+| 2          | 12            | 2019-10-27 |
+| 3          | -2            | 2019-11-10 |
+| 3          | 0             | 2019-11-11 |
+| 3          | 3             | 2019-11-12 |
+| 5          | 16            | 2019-11-07 |
+| 5          | 18            | 2019-11-09 |
+| 5          | 21            | 2019-11-23 |
+| 7          | 25            | 2019-11-28 |
+| 7          | 22            | 2019-12-01 |
+| 7          | 20            | 2019-12-02 |
+| 8          | 25            | 2019-11-05 |
+| 8          | 27            | 2019-11-15 |
+| 8          | 31            | 2019-11-25 |
+| 9          | 7             | 2019-10-23 |
+| 9          | 3             | 2019-12-23 |
++------------+---------------+------------+
+Result table:
++--------------+--------------+
+| country_name | weather_type |
++--------------+--------------+
+| USA          | Cold         |
+| Austraila    | Cold         |
+| Peru         | Hot          |
+| China        | Warm         |
+| Morocco      | Hot          |
++--------------+--------------+
+Average weather_state in USA in November is (15) / 1 = 15 so weather type is Cold.
+Average weather_state in Austraila in November is (-2 + 0 + 3) / 3 = 0.333 so weather type is Cold.
+Average weather_state in Peru in November is (25) / 1 = 25 so weather type is Hot.
+Average weather_state in China in November is (16 + 18 + 21) / 3 = 18.333 so weather type is Warm.
+Average weather_state in Morocco in November is (25 + 27 + 31) / 3 = 27.667 so weather type is Hot.
+We know nothing about average weather_state in Spain in November so we don't include it in the result table. 
+
diff --git a/problems/weather-type-in-each-country/weather_type_in_each_country.sql b/problems/weather-type-in-each-country/weather_type_in_each_country.sql new file mode 100644 index 000000000..01fa68ac9 --- /dev/null +++ b/problems/weather-type-in-each-country/weather_type_in_each_country.sql @@ -0,0 +1,11 @@ +# Write your MySQL query statement below + +SELECT country_name, + CASE + WHEN avg(weather_state) <= 15 THEN "Cold" + WHEN avg(weather_state) >= 25 THEN "Hot" + ELSE "Warm" END AS weather_type +FROM Countries + INNER JOIN Weather ON Countries.country_id = Weather.country_id +WHERE LEFT(DAY, 7) = '2019-11' +GROUP BY country_name From 037fda789284632a8334af988d14aeefa591ca6d Mon Sep 17 00:00:00 2001 From: openset Date: Tue, 24 Dec 2019 11:01:03 +0800 Subject: [PATCH 018/145] Add: v1.5.3 --- internal/leetcode/topic_tag.go | 2 +- internal/tag/tag.go | 2 +- internal/version/version.go | 2 +- tag/README.md | 2 +- tag/array/README.md | 2 +- tag/backtracking/README.md | 2 +- tag/binary-indexed-tree/README.md | 2 +- tag/binary-search-tree/README.md | 2 +- tag/binary-search/README.md | 2 +- tag/bit-manipulation/README.md | 2 +- tag/brainteaser/README.md | 2 +- tag/breadth-first-search/README.md | 2 +- tag/depth-first-search/README.md | 2 +- tag/design/README.md | 2 +- tag/divide-and-conquer/README.md | 2 +- tag/dynamic-programming/README.md | 2 +- tag/geometry/README.md | 2 +- tag/graph/README.md | 2 +- tag/greedy/README.md | 2 +- tag/hash-table/README.md | 2 +- tag/heap/README.md | 2 +- tag/line-sweep/README.md | 2 +- tag/linked-list/README.md | 2 +- tag/math/README.md | 2 +- tag/memoization/README.md | 2 +- tag/minimax/README.md | 2 +- tag/ordered-map/README.md | 2 +- tag/queue/README.md | 2 +- tag/random/README.md | 2 +- tag/recursion/README.md | 2 +- tag/rejection-sampling/README.md | 2 +- tag/reservoir-sampling/README.md | 2 +- tag/rolling-hash/README.md | 2 +- tag/segment-tree/README.md | 2 +- tag/sliding-window/README.md | 2 +- tag/sort/README.md | 2 +- tag/stack/README.md | 2 +- tag/string/README.md | 2 +- tag/suffix-array/README.md | 2 +- tag/topological-sort/README.md | 2 +- tag/tree/README.md | 2 +- tag/trie/README.md | 2 +- tag/two-pointers/README.md | 2 +- tag/union-find/README.md | 2 +- 44 files changed, 44 insertions(+), 44 deletions(-) diff --git a/internal/leetcode/topic_tag.go b/internal/leetcode/topic_tag.go index 17ae396d8..355980140 100644 --- a/internal/leetcode/topic_tag.go +++ b/internal/leetcode/topic_tag.go @@ -35,7 +35,7 @@ func (tag *TagType) SaveContents() { var buf bytes.Buffer buf.WriteString(authInfo("tag")) buf.WriteString(fmt.Sprintf("\n## [话题分类](../README.md) > %s\n\n", tag.name())) - buf.WriteString("| # | 题名 | 标签 | 难度 |\n") + buf.WriteString("| # | 题目 | 标签 | 难度 |\n") buf.WriteString("| :-: | - | - | :-: |\n") format := "| %d | [%s](../../problems/%s)%s | %s | %s |\n" for _, question := range questions { diff --git a/internal/tag/tag.go b/internal/tag/tag.go index bb89fe516..2ca146756 100644 --- a/internal/tag/tag.go +++ b/internal/tag/tag.go @@ -29,7 +29,7 @@ func runTag(cmd *base.Command, args []string) { var buf bytes.Buffer buf.WriteString(base.AuthInfo("tag")) buf.WriteString("\n## 话题分类\n\n") - buf.WriteString("| # | Title | 话题 | | # | Title | 话题 |\n") + buf.WriteString("| # | Topic | 话题 | | # | Topic | 话题 |\n") buf.WriteString("| :-: | - | :-: | - | :-: | - | :-: |\n") format := "| %d | [%s](%s/README.md) | [%s](https://openset.github.io/tags/%s/) | " n := buf.Len() diff --git a/internal/version/version.go b/internal/version/version.go index 8c17f7e2e..15f7bb386 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -8,7 +8,7 @@ import ( "github.com/openset/leetcode/internal/base" ) -const version = "1.5.2" +const version = "1.5.3" // CmdVersion - version.CmdVersion var CmdVersion = &base.Command{ diff --git a/tag/README.md b/tag/README.md index ce49fdea5..f30727ce6 100644 --- a/tag/README.md +++ b/tag/README.md @@ -7,7 +7,7 @@ ## 话题分类 -| # | Title | 话题 | | # | Title | 话题 | +| # | Topic | 话题 | | # | Topic | 话题 | | :-: | - | :-: | - | :-: | - | :-: | | 1 | [Array](array/README.md) | [数组](https://openset.github.io/tags/array/) | | 2 | [Dynamic Programming](dynamic-programming/README.md) | [动态规划](https://openset.github.io/tags/dynamic-programming/) | | 3 | [Math](math/README.md) | [数学](https://openset.github.io/tags/math/) | | 4 | [String](string/README.md) | [字符串](https://openset.github.io/tags/string/) | diff --git a/tag/array/README.md b/tag/array/README.md index c27081e6a..eb7f1220c 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 数组 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1295 | [统计位数为偶数的数字](../../problems/find-numbers-with-even-number-of-digits) | [[数组](../array/README.md)] | Easy | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 27e81cf48..baea11d43 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 回溯算法 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1291 | [顺次数](../../problems/sequential-digits) | [[回溯算法](../backtracking/README.md)] | Medium | | 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/binary-indexed-tree/README.md b/tag/binary-indexed-tree/README.md index 0038749bc..3e21d1daf 100644 --- a/tag/binary-indexed-tree/README.md +++ b/tag/binary-indexed-tree/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 树状数组 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/binary-search-tree/README.md b/tag/binary-search-tree/README.md index 42efd4da5..523255055 100644 --- a/tag/binary-search-tree/README.md +++ b/tag/binary-search-tree/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 二叉搜索树 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | | 1038 | [从二叉搜索树到更大和树](../../problems/binary-search-tree-to-greater-sum-tree) | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index e713cbd38..5ae879e4a 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 二分查找 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1283 | [使结果不超过阈值的最小除数](../../problems/find-the-smallest-divisor-given-a-threshold) | [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index c7a0a6025..2a046f6b3 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 位运算 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)] | Easy | diff --git a/tag/brainteaser/README.md b/tag/brainteaser/README.md index 9ca15357a..e6f0d0760 100644 --- a/tag/brainteaser/README.md +++ b/tag/brainteaser/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 脑筋急转弯 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1033 | [移动石子直到连续](../../problems/moving-stones-until-consecutive) | [[脑筋急转弯](../brainteaser/README.md)] | Easy | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index e59be563c..4e01f935c 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 广度优先搜索 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1298 | [你能从盒子里获得的最大糖果数](../../problems/maximum-candies-you-can-get-from-boxes) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 1293 | [网格中的最短路径](../../problems/shortest-path-in-a-grid-with-obstacles-elimination) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index f48d651a0..e54942a30 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 深度优先搜索 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1273 | [删除树节点](../../problems/delete-tree-nodes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1254 | [统计封闭岛屿的数目](../../problems/number-of-closed-islands) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index d96b9f132..18652a73b 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 设计 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index 63807f675..e761314cd 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 分治算法 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1274 | [矩形内船只的数目](../../problems/number-of-ships-in-a-rectangle) 🔒 | [[分治算法](../divide-and-conquer/README.md)] | Hard | | 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index c69b90d2f..26653f21d 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 动态规划 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1289 | [下降路径最小和 II](../../problems/minimum-falling-path-sum-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1278 | [分割回文串 III](../../problems/palindrome-partitioning-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index 91db869fc..444a2be36 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 几何 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] | Easy | | 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | diff --git a/tag/graph/README.md b/tag/graph/README.md index 7b4877e3f..2d5869f88 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 图 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index f5e2fd318..1874d4171 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 贪心算法 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1282 | [用户分组](../../problems/group-the-people-given-the-group-size-they-belong-to) | [[贪心算法](../greedy/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 4d9098833..32d850461 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 哈希表 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/heap/README.md b/tag/heap/README.md index bb21437a3..4c04d66bd 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 堆 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] | Medium | | 1046 | [最后一块石头的重量](../../problems/last-stone-weight) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Easy | diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md index b72c19577..8dc62c6a6 100644 --- a/tag/line-sweep/README.md +++ b/tag/line-sweep/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > Line Sweep -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[Line Sweep](../line-sweep/README.md)] | Medium | | 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index 20c3c937c..d186d7105 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 链表 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)] | Easy | | 1171 | [从链表中删去总和值为零的连续节点](../../problems/remove-zero-sum-consecutive-nodes-from-linked-list) | [[链表](../linked-list/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 2ca06bfff..be547e322 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 数学 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1281 | [整数的各位积和之差](../../problems/subtract-the-product-and-sum-of-digits-of-an-integer) | [[数学](../math/README.md)] | Easy | | 1276 | [不浪费原料的汉堡制作方案](../../problems/number-of-burgers-with-no-waste-of-ingredients) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/memoization/README.md b/tag/memoization/README.md index 8b57a4940..2c6a5dffd 100644 --- a/tag/memoization/README.md +++ b/tag/memoization/README.md @@ -7,6 +7,6 @@ ## [话题分类](../README.md) > 记忆化 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | diff --git a/tag/minimax/README.md b/tag/minimax/README.md index bfd9897a4..0cf0739a7 100644 --- a/tag/minimax/README.md +++ b/tag/minimax/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 极小化极大 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[极小化极大](../minimax/README.md)] | Hard | | 877 | [石子游戏](../../problems/stone-game) | [[极小化极大](../minimax/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index 19a1d5a98..d8c9d70c3 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > Ordered Map -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | | 855 | [考场就座](../../problems/exam-room) | [[Ordered Map](../ordered-map/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index f83d54bcb..16db88027 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 队列 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 933 | [最近的请求次数](../../problems/number-of-recent-calls) | [[队列](../queue/README.md)] | Easy | | 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | diff --git a/tag/random/README.md b/tag/random/README.md index 53eac31f1..25144cd0a 100644 --- a/tag/random/README.md +++ b/tag/random/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > Random -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | | 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 2e9d297ae..d2c3bb17d 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 递归 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[递归](../recursion/README.md)] | Easy | | 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | diff --git a/tag/rejection-sampling/README.md b/tag/rejection-sampling/README.md index 510709f4d..fc2d396f2 100644 --- a/tag/rejection-sampling/README.md +++ b/tag/rejection-sampling/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > Rejection Sampling -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | | 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | diff --git a/tag/reservoir-sampling/README.md b/tag/reservoir-sampling/README.md index 4d9d5b6b8..1fc516eb3 100644 --- a/tag/reservoir-sampling/README.md +++ b/tag/reservoir-sampling/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 蓄水池抽样 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 398 | [随机数索引](../../problems/random-pick-index) | [[蓄水池抽样](../reservoir-sampling/README.md)] | Medium | | 382 | [链表随机节点](../../problems/linked-list-random-node) | [[蓄水池抽样](../reservoir-sampling/README.md)] | Medium | diff --git a/tag/rolling-hash/README.md b/tag/rolling-hash/README.md index 4584c71c6..70152bf02 100644 --- a/tag/rolling-hash/README.md +++ b/tag/rolling-hash/README.md @@ -7,5 +7,5 @@ ## [话题分类](../README.md) > Rolling Hash -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index 221b8b50c..4fb79b397 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 线段树 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index 840ed4c1d..dc035894e 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > Sliding Window -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1176 | [健身计划评估](../../problems/diet-plan-performance) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Easy | diff --git a/tag/sort/README.md b/tag/sort/README.md index fa76fdf87..98d0301ff 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 排序 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/stack/README.md b/tag/stack/README.md index a67c9392d..865595eda 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 栈 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1249 | [移除无效的括号](../../problems/minimum-remove-to-make-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | | 1209 | [删除字符串中的所有相邻重复项 II](../../problems/remove-all-adjacent-duplicates-in-string-ii) | [[栈](../stack/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index db4c81d85..20203a6eb 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 字符串 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1271 | [十六进制魔术数字](../../problems/hexspeak) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | diff --git a/tag/suffix-array/README.md b/tag/suffix-array/README.md index b419d4047..f01d0740f 100644 --- a/tag/suffix-array/README.md +++ b/tag/suffix-array/README.md @@ -7,5 +7,5 @@ ## [话题分类](../README.md) > Suffix Array -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | diff --git a/tag/topological-sort/README.md b/tag/topological-sort/README.md index 7231dfe39..5a051c022 100644 --- a/tag/topological-sort/README.md +++ b/tag/topological-sort/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 拓扑排序 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | | 444 | [序列重建](../../problems/sequence-reconstruction) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | diff --git a/tag/tree/README.md b/tag/tree/README.md index 97fd5f73a..dd5ec3c5e 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 树 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1257 | [最小公共区域](../../problems/smallest-common-region) 🔒 | [[树](../tree/README.md)] | Medium | diff --git a/tag/trie/README.md b/tag/trie/README.md index 593289190..3bd66dc15 100644 --- a/tag/trie/README.md +++ b/tag/trie/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 字典树 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Easy | | 1032 | [字符流](../../problems/stream-of-characters) | [[字典树](../trie/README.md)] | Hard | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 73027ba12..99b86e534 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 双指针 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1248 | [统计「优美子数组」](../../problems/count-number-of-nice-subarrays) | [[双指针](../two-pointers/README.md)] | Medium | | 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index 22c143e20..71691b39d 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -7,7 +7,7 @@ ## [话题分类](../README.md) > 并查集 -| # | 题名 | 标签 | 难度 | +| # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | | 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | From 6676eab8839ac3ea7244f1fd651af0e034c32c64 Mon Sep 17 00:00:00 2001 From: openset Date: Mon, 30 Dec 2019 09:43:44 +0800 Subject: [PATCH 019/145] Add: new --- README.md | 9 +++ .../README.md | 75 +++++++++++++++++ problems/best-meeting-point/README.md | 2 +- problems/deepest-leaves-sum/README.md | 46 +++++++++++ .../README.md | 58 +++++++++++++ problems/find-the-team-size/README.md | 14 ++++ problems/find-the-team-size/mysql_schemas.sql | 8 ++ problems/jump-game-iii/README.md | 70 ++++++++++++++++ .../README.md | 2 +- .../number-of-paths-with-max-score/README.md | 52 ++++++++++++ .../README.md | 43 ++++++++++ .../README.md | 69 ++++++++++++++++ problems/verbal-arithmetic-puzzle/README.md | 81 +++++++++++++++++++ tag/array/README.md | 3 + tag/backtracking/README.md | 1 + tag/binary-search/README.md | 1 + tag/breadth-first-search/README.md | 1 + tag/depth-first-search/README.md | 1 + tag/dynamic-programming/README.md | 1 + tag/graph/README.md | 1 + tag/math/README.md | 1 + tag/sort/README.md | 1 + tag/tree/README.md | 2 + 23 files changed, 540 insertions(+), 2 deletions(-) create mode 100644 problems/all-elements-in-two-binary-search-trees/README.md create mode 100644 problems/deepest-leaves-sum/README.md create mode 100644 problems/find-n-unique-integers-sum-up-to-zero/README.md create mode 100644 problems/find-the-team-size/README.md create mode 100644 problems/find-the-team-size/mysql_schemas.sql create mode 100644 problems/jump-game-iii/README.md create mode 100644 problems/number-of-paths-with-max-score/README.md create mode 100644 problems/replace-elements-with-greatest-element-on-right-side/README.md create mode 100644 problems/sum-of-mutated-array-closest-to-target/README.md create mode 100644 problems/verbal-arithmetic-puzzle/README.md diff --git a/README.md b/README.md index 53e640787..8f6b96da4 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,15 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1307 | [Verbal Arithmetic Puzzle](https://leetcode.com/problems/verbal-arithmetic-puzzle "口算难题") | [Go](problems/verbal-arithmetic-puzzle) | Hard | +| 1306 | [Jump Game III](https://leetcode.com/problems/jump-game-iii "跳跃游戏 III") | [Go](problems/jump-game-iii) | Medium | +| 1305 | [All Elements in Two Binary Search Trees](https://leetcode.com/problems/all-elements-in-two-binary-search-trees "两棵二叉搜索树中的所有元素") | [Go](problems/all-elements-in-two-binary-search-trees) | Medium | +| 1304 | [Find N Unique Integers Sum up to Zero](https://leetcode.com/problems/find-n-unique-integers-sum-up-to-zero "和为零的N个唯一整数") | [Go](problems/find-n-unique-integers-sum-up-to-zero) | Easy | +| 1303 | [Find the Team Size](https://leetcode.com/problems/find-the-team-size) 🔒 | [MySQL](problems/find-the-team-size) | Easy | +| 1302 | [Deepest Leaves Sum](https://leetcode.com/problems/deepest-leaves-sum "层数最深叶子节点的和") | [Go](problems/deepest-leaves-sum) | Medium | +| 1301 | [Number of Paths with Max Score](https://leetcode.com/problems/number-of-paths-with-max-score "最大得分的路径数目") | [Go](problems/number-of-paths-with-max-score) | Hard | +| 1300 | [Sum of Mutated Array Closest to Target](https://leetcode.com/problems/sum-of-mutated-array-closest-to-target "转变数组后最接近目标值的数组和") | [Go](problems/sum-of-mutated-array-closest-to-target) | Medium | +| 1299 | [Replace Elements with Greatest Element on Right Side](https://leetcode.com/problems/replace-elements-with-greatest-element-on-right-side "将每个元素替换为右侧最大元素") | [Go](problems/replace-elements-with-greatest-element-on-right-side) | Easy | | 1298 | [Maximum Candies You Can Get from Boxes](https://leetcode.com/problems/maximum-candies-you-can-get-from-boxes "你能从盒子里获得的最大糖果数") | [Go](problems/maximum-candies-you-can-get-from-boxes) | Hard | | 1297 | [Maximum Number of Occurrences of a Substring](https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring "子串的最大出现次数") | [Go](problems/maximum-number-of-occurrences-of-a-substring) | Medium | | 1296 | [Divide Array in Sets of K Consecutive Numbers](https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers "划分数组为连续数字的集合") | [Go](problems/divide-array-in-sets-of-k-consecutive-numbers) | Medium | diff --git a/problems/all-elements-in-two-binary-search-trees/README.md b/problems/all-elements-in-two-binary-search-trees/README.md new file mode 100644 index 000000000..af291ed84 --- /dev/null +++ b/problems/all-elements-in-two-binary-search-trees/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../find-n-unique-integers-sum-up-to-zero "Find N Unique Integers Sum up to Zero") +                 +[Next >](../jump-game-iii "Jump Game III") + +## [1305. All Elements in Two Binary Search Trees (Medium)](https://leetcode.com/problems/all-elements-in-two-binary-search-trees "两棵二叉搜索树中的所有元素") + +

Given two binary search trees root1 and root2.

+ +

Return a list containing all the integers from both trees sorted in ascending order.

+ +

 

+

Example 1:

+ +
+Input: root1 = [2,1,4], root2 = [1,0,3]
+Output: [0,1,1,2,3,4]
+
+ +

Example 2:

+ +
+Input: root1 = [0,-10,10], root2 = [5,1,7,0,2]
+Output: [-10,0,0,1,2,5,7,10]
+
+ +

Example 3:

+ +
+Input: root1 = [], root2 = [5,1,7,0,2]
+Output: [0,1,2,5,7]
+
+ +

Example 4:

+ +
+Input: root1 = [0,-10,10], root2 = []
+Output: [-10,0,10]
+
+ +

Example 5:

+ +
+Input: root1 = [1,null,8], root2 = [8,1]
+Output: [1,1,8,8]
+
+ +

 

+

Constraints:

+ +
    +
  • Each tree has at most 5000 nodes.
  • +
  • Each node's value is between [-10^5, 10^5].
  • +
+ +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Tree](../../tag/tree/README.md)] + +### Hints +
+Hint 1 +Traverse the first tree in list1 and the second tree in list2. +
+ +
+Hint 2 +Merge the two trees in one list and sort it. +
diff --git a/problems/best-meeting-point/README.md b/problems/best-meeting-point/README.md index 297450d60..bb2a41eb3 100644 --- a/problems/best-meeting-point/README.md +++ b/problems/best-meeting-point/README.md @@ -31,8 +31,8 @@ Explanation: Given three people living at (0,0), (0,   of 2+2+2=6 is minimal. So return 6.
### Related Topics - [[Math](../../tag/math/README.md)] [[Sort](../../tag/sort/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Shortest Distance from All Buildings](../shortest-distance-from-all-buildings) (Hard) diff --git a/problems/deepest-leaves-sum/README.md b/problems/deepest-leaves-sum/README.md new file mode 100644 index 000000000..eebaa5614 --- /dev/null +++ b/problems/deepest-leaves-sum/README.md @@ -0,0 +1,46 @@ + + + + + + + +[< Previous](../number-of-paths-with-max-score "Number of Paths with Max Score") +                 +[Next >](../find-the-team-size "Find the Team Size") + +## [1302. Deepest Leaves Sum (Medium)](https://leetcode.com/problems/deepest-leaves-sum "层数最深叶子节点的和") + +Given a binary tree, return the sum of values of its deepest leaves. +

 

+

Example 1:

+ +

+ +
+Input: root = [1,2,3,4,5,null,6,7,null,null,null,null,8]
+Output: 15
+
+ +

 

+

Constraints:

+ +
    +
  • The number of nodes in the tree is between 1 and 10^4.
  • +
  • The value of nodes is between 1 and 100.
  • +
+ +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + +### Hints +
+Hint 1 +Traverse the tree to find the max depth. +
+ +
+Hint 2 +Traverse the tree again to compute the sum required. +
diff --git a/problems/find-n-unique-integers-sum-up-to-zero/README.md b/problems/find-n-unique-integers-sum-up-to-zero/README.md new file mode 100644 index 000000000..a4cb10af2 --- /dev/null +++ b/problems/find-n-unique-integers-sum-up-to-zero/README.md @@ -0,0 +1,58 @@ + + + + + + + +[< Previous](../find-the-team-size "Find the Team Size") +                 +[Next >](../all-elements-in-two-binary-search-trees "All Elements in Two Binary Search Trees") + +## [1304. Find N Unique Integers Sum up to Zero (Easy)](https://leetcode.com/problems/find-n-unique-integers-sum-up-to-zero "和为零的N个唯一整数") + +

Given an integer n, return any array containing n unique integers such that they add up to 0.

+ +

 

+

Example 1:

+ +
+Input: n = 5
+Output: [-7,-1,1,3,4]
+Explanation: These arrays also are accepted [-5,-1,1,2,3] , [-3,-1,2,-2,4].
+
+ +

Example 2:

+ +
+Input: n = 3
+Output: [-1,0,1]
+
+ +

Example 3:

+ +
+Input: n = 1
+Output: [0]
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= n <= 1000
  • +
+ +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
+Hint 1 +Return an array where the values are symmetric. (+x , -x). +
+ +
+Hint 2 +If n is odd, append value 0 in your returned array. +
diff --git a/problems/find-the-team-size/README.md b/problems/find-the-team-size/README.md new file mode 100644 index 000000000..6f2178d99 --- /dev/null +++ b/problems/find-the-team-size/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../deepest-leaves-sum "Deepest Leaves Sum") +                 +[Next >](../find-n-unique-integers-sum-up-to-zero "Find N Unique Integers Sum up to Zero") + +## [1303. Find the Team Size (Easy)](https://leetcode.com/problems/find-the-team-size "") + + diff --git a/problems/find-the-team-size/mysql_schemas.sql b/problems/find-the-team-size/mysql_schemas.sql new file mode 100644 index 000000000..bd2dc77d2 --- /dev/null +++ b/problems/find-the-team-size/mysql_schemas.sql @@ -0,0 +1,8 @@ +Create table If Not Exists Employee (employee_id int, team_id int); +Truncate table Employee; +insert into Employee (employee_id, team_id) values ('1', '8'); +insert into Employee (employee_id, team_id) values ('2', '8'); +insert into Employee (employee_id, team_id) values ('3', '8'); +insert into Employee (employee_id, team_id) values ('4', '7'); +insert into Employee (employee_id, team_id) values ('5', '9'); +insert into Employee (employee_id, team_id) values ('6', '9'); diff --git a/problems/jump-game-iii/README.md b/problems/jump-game-iii/README.md new file mode 100644 index 000000000..ad2a1e1c5 --- /dev/null +++ b/problems/jump-game-iii/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../all-elements-in-two-binary-search-trees "All Elements in Two Binary Search Trees") +                 +[Next >](../verbal-arithmetic-puzzle "Verbal Arithmetic Puzzle") + +## [1306. Jump Game III (Medium)](https://leetcode.com/problems/jump-game-iii "跳跃游戏 III") + +

Given an array of non-negative integers arr, you are initially positioned at start index of the array. When you are at index i, you can jump to i + arr[i] or i - arr[i], check if you can reach to any index with value 0.

+ +

Notice that you can not jump outside of the array at any time.

+ +

 

+

Example 1:

+ +
+Input: arr = [4,2,3,0,3,1,2], start = 5
+Output: true
+Explanation: 
+All possible ways to reach at index 3 with value 0 are: 
+index 5 -> index 4 -> index 1 -> index 3 
+index 5 -> index 6 -> index 4 -> index 1 -> index 3 
+
+ +

Example 2:

+ +
+Input: arr = [4,2,3,0,3,1,2], start = 0
+Output: true 
+Explanation: 
+One possible way to reach at index 3 with value 0 is: 
+index 0 -> index 4 -> index 1 -> index 3
+
+ +

Example 3:

+ +
+Input: arr = [3,0,2,1,2], start = 2
+Output: false
+Explanation: There is no way to reach at index 1 with value 0.
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= arr.length <= 5 * 10^4
  • +
  • 0 <= arr[i] < arr.length
  • +
  • 0 <= start < arr.length
  • +
+ +### Related Topics + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + +### Hints +
+Hint 1 +Think of BFS to solve the problem. +
+ +
+Hint 2 +When you reach a position with a value = 0 then return true. +
diff --git a/problems/maximum-candies-you-can-get-from-boxes/README.md b/problems/maximum-candies-you-can-get-from-boxes/README.md index 584b72f91..fec63de89 100644 --- a/problems/maximum-candies-you-can-get-from-boxes/README.md +++ b/problems/maximum-candies-you-can-get-from-boxes/README.md @@ -7,7 +7,7 @@ [< Previous](../maximum-number-of-occurrences-of-a-substring "Maximum Number of Occurrences of a Substring")                  -Next > +[Next >](../replace-elements-with-greatest-element-on-right-side "Replace Elements with Greatest Element on Right Side") ## [1298. Maximum Candies You Can Get from Boxes (Hard)](https://leetcode.com/problems/maximum-candies-you-can-get-from-boxes "你能从盒子里获得的最大糖果数") diff --git a/problems/number-of-paths-with-max-score/README.md b/problems/number-of-paths-with-max-score/README.md new file mode 100644 index 000000000..b6d1d5790 --- /dev/null +++ b/problems/number-of-paths-with-max-score/README.md @@ -0,0 +1,52 @@ + + + + + + + +[< Previous](../sum-of-mutated-array-closest-to-target "Sum of Mutated Array Closest to Target") +                 +[Next >](../deepest-leaves-sum "Deepest Leaves Sum") + +## [1301. Number of Paths with Max Score (Hard)](https://leetcode.com/problems/number-of-paths-with-max-score "最大得分的路径数目") + +

You are given a square board of characters. You can move on the board starting at the bottom right square marked with the character 'S'.

+ +

You need to reach the top left square marked with the character 'E'. The rest of the squares are labeled either with a numeric character 1, 2, ..., 9 or with an obstacle 'X'. In one move you can go up, left or up-left (diagonally) only if there is no obstacle there.

+ +

Return a list of two integers: the first integer is the maximum sum of numeric characters you can collect, and the second is the number of such paths that you can take to get that maximum sum, taken modulo 10^9 + 7.

+ +

In case there is no path, return [0, 0].

+ +

 

+

Example 1:

+
Input: board = ["E23","2X2","12S"]
+Output: [7,1]
+

Example 2:

+
Input: board = ["E12","1X1","21S"]
+Output: [4,2]
+

Example 3:

+
Input: board = ["E11","XXX","11S"]
+Output: [0,0]
+
+

 

+

Constraints:

+ +
    +
  • 2 <= board.length == board[i].length <= 100
  • +
+ +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
+Hint 1 +Use dynamic programming to find the path with the max score. +
+ +
+Hint 2 +Use another dynamic programming array to count the number of paths with max score. +
diff --git a/problems/replace-elements-with-greatest-element-on-right-side/README.md b/problems/replace-elements-with-greatest-element-on-right-side/README.md new file mode 100644 index 000000000..3ea525177 --- /dev/null +++ b/problems/replace-elements-with-greatest-element-on-right-side/README.md @@ -0,0 +1,43 @@ + + + + + + + +[< Previous](../maximum-candies-you-can-get-from-boxes "Maximum Candies You Can Get from Boxes") +                 +[Next >](../sum-of-mutated-array-closest-to-target "Sum of Mutated Array Closest to Target") + +## [1299. Replace Elements with Greatest Element on Right Side (Easy)](https://leetcode.com/problems/replace-elements-with-greatest-element-on-right-side "将每个元素替换为右侧最大元素") + +

Given an array arr, replace every element in that array with the greatest element among the elements to its right, and replace the last element with -1.

+ +

After doing so, return the array.

+ +

 

+

Example 1:

+
Input: arr = [17,18,5,4,6,1]
+Output: [18,6,6,6,1,-1]
+
+

 

+

Constraints:

+ +
    +
  • 1 <= arr.length <= 10^4
  • +
  • 1 <= arr[i] <= 10^5
  • +
+ +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
+Hint 1 +Loop through the array starting from the end. +
+ +
+Hint 2 +Keep the maximum value seen so far. +
diff --git a/problems/sum-of-mutated-array-closest-to-target/README.md b/problems/sum-of-mutated-array-closest-to-target/README.md new file mode 100644 index 000000000..f7ef1d2f2 --- /dev/null +++ b/problems/sum-of-mutated-array-closest-to-target/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../replace-elements-with-greatest-element-on-right-side "Replace Elements with Greatest Element on Right Side") +                 +[Next >](../number-of-paths-with-max-score "Number of Paths with Max Score") + +## [1300. Sum of Mutated Array Closest to Target (Medium)](https://leetcode.com/problems/sum-of-mutated-array-closest-to-target "转变数组后最接近目标值的数组和") + +

Given an integer array arr and a target value target, return the integer value such that when we change all the integers larger than value in the given array to be equal to value, the sum of the array gets as close as possible (in absolute difference) to target.

+ +

In case of a tie, return the minimum such integer.

+ +

Notice that the answer is not neccesarilly a number from arr.

+ +

 

+

Example 1:

+ +
+Input: arr = [4,9,3], target = 10
+Output: 3
+Explanation: When using 3 arr converts to [3, 3, 3] which sums 9 and that's the optimal answer.
+
+ +

Example 2:

+ +
+Input: arr = [2,3,5], target = 10
+Output: 5
+
+ +

Example 3:

+ +
+Input: arr = [60864,25176,27249,21296,20204], target = 56803
+Output: 11361
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= arr.length <= 10^4
  • +
  • 1 <= arr[i], target <= 10^5
  • +
+ +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
+Hint 1 +If you draw a graph with the value on one axis and the absolute difference between the target and the array sum, what will you get? +
+ +
+Hint 2 +That graph is uni-modal. +
+ +
+Hint 3 +Use ternary search on that graph to find the best value. +
diff --git a/problems/verbal-arithmetic-puzzle/README.md b/problems/verbal-arithmetic-puzzle/README.md new file mode 100644 index 000000000..5ded4692a --- /dev/null +++ b/problems/verbal-arithmetic-puzzle/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../jump-game-iii "Jump Game III") +                 +Next > + +## [1307. Verbal Arithmetic Puzzle (Hard)](https://leetcode.com/problems/verbal-arithmetic-puzzle "口算难题") + +

Given an equation, represented by words on left side and the result on right side.

+ +

You need to check if the equation is solvable under the following rules:

+ +
    +
  • Each character is decoded as one digit (0 - 9).
  • +
  • Every pair of different characters they must map to different digits.
  • +
  • Each words[i] and result are decoded as one number without leading zeros.
  • +
  • Sum of numbers on left side (words) will equal to the number on right side (result). 
  • +
+ +

Return True if the equation is solvable otherwise return False.

+ +

 

+

Example 1:

+ +
+Input: words = ["SEND","MORE"], result = "MONEY"
+Output: true
+Explanation: Map 'S'-> 9, 'E'->5, 'N'->6, 'D'->7, 'M'->1, 'O'->0, 'R'->8, 'Y'->'2'
+Such that: "SEND" + "MORE" = "MONEY" ,  9567 + 1085 = 10652
+ +

Example 2:

+ +
+Input: words = ["SIX","SEVEN","SEVEN"], result = "TWENTY"
+Output: true
+Explanation: Map 'S'-> 6, 'I'->5, 'X'->0, 'E'->8, 'V'->7, 'N'->2, 'T'->1, 'W'->'3', 'Y'->4
+Such that: "SIX" + "SEVEN" + "SEVEN" = "TWENTY" ,  650 + 68782 + 68782 = 138214
+ +

Example 3:

+ +
+Input: words = ["THIS","IS","TOO"], result = "FUNNY"
+Output: true
+
+ +

Example 4:

+ +
+Input: words = ["LEET","CODE"], result = "POINT"
+Output: false
+
+ +

 

+

Constraints:

+ +
    +
  • 2 <= words.length <= 5
  • +
  • 1 <= words[i].length, results.length <= 7
  • +
  • words[i], result contains only upper case English letters.
  • +
  • Number of different characters used on the expression is at most 10.
  • +
+ +### Related Topics + [[Math](../../tag/math/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
+Hint 1 +Use Backtracking and pruning to solve this problem. +
+ +
+Hint 2 +If you set the values of some digits (from right to left), the other digits will be constrained. +
diff --git a/tag/array/README.md b/tag/array/README.md index eb7f1220c..8ad504fec 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1304 | [和为零的N个唯一整数](../../problems/find-n-unique-integers-sum-up-to-zero) | [[数组](../array/README.md)] | Easy | +| 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1299 | [将每个元素替换为右侧最大元素](../../problems/replace-elements-with-greatest-element-on-right-side) | [[数组](../array/README.md)] | Easy | | 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1295 | [统计位数为偶数的数字](../../problems/find-numbers-with-even-number-of-digits) | [[数组](../array/README.md)] | Easy | | 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index baea11d43..919333086 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1291 | [顺次数](../../problems/sequential-digits) | [[回溯算法](../backtracking/README.md)] | Medium | | 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1258 | [近义词句子](../../problems/synonymous-sentences) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 5ae879e4a..13f7da3be 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1283 | [使结果不超过阈值的最小除数](../../problems/find-the-smallest-divisor-given-a-threshold) | [[二分查找](../binary-search/README.md)] | Medium | | 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 4e01f935c..2c1d516ea 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1298 | [你能从盒子里获得的最大糖果数](../../problems/maximum-candies-you-can-get-from-boxes) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 1293 | [网格中的最短路径](../../problems/shortest-path-in-a-grid-with-obstacles-elimination) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 1284 | [转化为全零矩阵的最少反转次数](../../problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index e54942a30..6851a2a5e 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1273 | [删除树节点](../../problems/delete-tree-nodes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1254 | [统计封闭岛屿的数目](../../problems/number-of-closed-islands) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 26653f21d..8c99435cf 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1301 | [最大得分的路径数目](../../problems/number-of-paths-with-max-score) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1289 | [下降路径最小和 II](../../problems/minimum-falling-path-sum-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1278 | [分割回文串 III](../../problems/palindrome-partitioning-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1277 | [统计全为 1 的正方形子矩阵](../../problems/count-square-submatrices-with-all-ones) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/graph/README.md b/tag/graph/README.md index 2d5869f88..29f1f46a0 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | | 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | diff --git a/tag/math/README.md b/tag/math/README.md index be547e322..b35d02202 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1281 | [整数的各位积和之差](../../problems/subtract-the-product-and-sum-of-digits-of-an-integer) | [[数学](../math/README.md)] | Easy | | 1276 | [不浪费原料的汉堡制作方案](../../problems/number-of-burgers-with-no-waste-of-ingredients) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | | 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index 98d0301ff..66714adb4 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[排序](../sort/README.md)] [[树](../tree/README.md)] | Medium | | 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1183 | [矩阵中 1 的最大数量](../../problems/maximum-number-of-ones) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/tree/README.md b/tag/tree/README.md index dd5ec3c5e..85e15669c 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[排序](../sort/README.md)] [[树](../tree/README.md)] | Medium | +| 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1257 | [最小公共区域](../../problems/smallest-common-region) 🔒 | [[树](../tree/README.md)] | Medium | | 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | From 2c31b2a96ff028a8426d04b8fdae48cd40f8781d Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 31 Dec 2019 17:07:53 +0800 Subject: [PATCH 020/145] Update: dayOfYear --- problems/day-of-the-year/day_of_the_year.go | 31 ++------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/problems/day-of-the-year/day_of_the_year.go b/problems/day-of-the-year/day_of_the_year.go index 2dbf77102..18df7e443 100644 --- a/problems/day-of-the-year/day_of_the_year.go +++ b/problems/day-of-the-year/day_of_the_year.go @@ -1,33 +1,8 @@ package problem1154 -import "strconv" - -var daysBefore = [...]int{ - 0, - 31, - 31 + 28, - 31 + 28 + 31, - 31 + 28 + 31 + 30, - 31 + 28 + 31 + 30 + 31, - 31 + 28 + 31 + 30 + 31 + 30, - 31 + 28 + 31 + 30 + 31 + 30 + 31, - 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31, - 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30, - 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31, - 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30, -} +import "time" func dayOfYear(date string) int { - year, _ := strconv.Atoi(date[:4]) - month, _ := strconv.Atoi(date[5:7]) - day, _ := strconv.Atoi(date[8:]) - day += daysBefore[month-1] - if month > 2 && isLeap(year) { - day++ - } - return day -} - -func isLeap(year int) bool { - return year%4 == 0 && (year%100 != 0 || year%400 == 0) + t, _ := time.Parse("2006-01-02", date) + return t.YearDay() } From 43d9b4b6884e4011cae9276edb699f8866c2d2ce Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 2 Jan 2020 11:23:35 +0800 Subject: [PATCH 021/145] Add: new --- README.md | 11 ++++++----- problems/count-and-say/README.md | 2 +- .../README.md | 2 +- .../mysql_schemas.sql | 10 +++++----- problems/immediate-food-delivery-ii/README.md | 2 +- .../README.md | 2 +- problems/reported-posts/README.md | 2 +- .../README.md | 17 +++++++++++++++++ .../mysql_schemas.sql | 11 +++++++++++ problems/verbal-arithmetic-puzzle/README.md | 2 +- problems/weather-type-in-each-country/README.md | 2 +- readme/1-300.md | 2 +- tag/string/README.md | 2 +- 13 files changed, 48 insertions(+), 19 deletions(-) create mode 100644 problems/running-total-for-different-genders/README.md create mode 100644 problems/running-total-for-different-genders/mysql_schemas.sql diff --git a/README.md b/README.md index 8f6b96da4..4bd1b7abc 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1308 | [Running Total for Different Genders](https://leetcode.com/problems/running-total-for-different-genders) 🔒 | [MySQL](problems/running-total-for-different-genders) | Medium | | 1307 | [Verbal Arithmetic Puzzle](https://leetcode.com/problems/verbal-arithmetic-puzzle "口算难题") | [Go](problems/verbal-arithmetic-puzzle) | Hard | | 1306 | [Jump Game III](https://leetcode.com/problems/jump-game-iii "跳跃游戏 III") | [Go](problems/jump-game-iii) | Medium | | 1305 | [All Elements in Two Binary Search Trees](https://leetcode.com/problems/all-elements-in-two-binary-search-trees "两棵二叉搜索树中的所有元素") | [Go](problems/all-elements-in-two-binary-search-trees) | Medium | @@ -75,7 +76,7 @@ LeetCode Problems' Solutions | 1297 | [Maximum Number of Occurrences of a Substring](https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring "子串的最大出现次数") | [Go](problems/maximum-number-of-occurrences-of-a-substring) | Medium | | 1296 | [Divide Array in Sets of K Consecutive Numbers](https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers "划分数组为连续数字的集合") | [Go](problems/divide-array-in-sets-of-k-consecutive-numbers) | Medium | | 1295 | [Find Numbers with Even Number of Digits](https://leetcode.com/problems/find-numbers-with-even-number-of-digits "统计位数为偶数的数字") | [Go](problems/find-numbers-with-even-number-of-digits) | Easy | -| 1294 | [Weather Type in Each Country](https://leetcode.com/problems/weather-type-in-each-country) 🔒 | [MySQL](problems/weather-type-in-each-country) | Easy | +| 1294 | [Weather Type in Each Country](https://leetcode.com/problems/weather-type-in-each-country "不同国家的天气类型") 🔒 | [MySQL](problems/weather-type-in-each-country) | Easy | | 1293 | [Shortest Path in a Grid with Obstacles Elimination](https://leetcode.com/problems/shortest-path-in-a-grid-with-obstacles-elimination "网格中的最短路径") | [Go](problems/shortest-path-in-a-grid-with-obstacles-elimination) | Hard | | 1292 | [Maximum Side Length of a Square with Sum Less than or Equal to Threshold](https://leetcode.com/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold "元素和小于等于阈值的正方形的最大边长") | [Go](problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | Medium | | 1291 | [Sequential Digits](https://leetcode.com/problems/sequential-digits "顺次数") | [Go](problems/sequential-digits) | Medium | @@ -84,7 +85,7 @@ LeetCode Problems' Solutions | 1288 | [Remove Covered Intervals](https://leetcode.com/problems/remove-covered-intervals "删除被覆盖区间") | [Go](problems/remove-covered-intervals) | Medium | | 1287 | [Element Appearing More Than 25% In Sorted Array](https://leetcode.com/problems/element-appearing-more-than-25-in-sorted-array "有序数组中出现次数超过25%的元素") | [Go](problems/element-appearing-more-than-25-in-sorted-array) | Easy | | 1286 | [Iterator for Combination](https://leetcode.com/problems/iterator-for-combination "字母组合迭代器") | [Go](problems/iterator-for-combination) | Medium | -| 1285 | [Find the Start and End Number of Continuous Ranges](https://leetcode.com/problems/find-the-start-and-end-number-of-continuous-ranges) 🔒 | [MySQL](problems/find-the-start-and-end-number-of-continuous-ranges) | Medium | +| 1285 | [Find the Start and End Number of Continuous Ranges](https://leetcode.com/problems/find-the-start-and-end-number-of-continuous-ranges "找到连续区间的开始和结束数字") 🔒 | [MySQL](problems/find-the-start-and-end-number-of-continuous-ranges) | Medium | | 1284 | [Minimum Number of Flips to Convert Binary Matrix to Zero Matrix](https://leetcode.com/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix "转化为全零矩阵的最少反转次数") | [Go](problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | Hard | | 1283 | [Find the Smallest Divisor Given a Threshold](https://leetcode.com/problems/find-the-smallest-divisor-given-a-threshold "使结果不超过阈值的最小除数") | [Go](problems/find-the-smallest-divisor-given-a-threshold) | Medium | | 1282 | [Group the People Given the Group Size They Belong To](https://leetcode.com/problems/group-the-people-given-the-group-size-they-belong-to "用户分组") | [Go](problems/group-the-people-given-the-group-size-they-belong-to) | Medium | @@ -104,7 +105,7 @@ LeetCode Problems' Solutions | 1268 | [Search Suggestions System](https://leetcode.com/problems/search-suggestions-system "搜索推荐系统") | [Go](problems/search-suggestions-system) | Medium | | 1267 | [Count Servers that Communicate](https://leetcode.com/problems/count-servers-that-communicate "统计参与通信的服务器") | [Go](problems/count-servers-that-communicate) | Medium | | 1266 | [Minimum Time Visiting All Points](https://leetcode.com/problems/minimum-time-visiting-all-points "访问所有点的最小时间") | [Go](problems/minimum-time-visiting-all-points) | Easy | -| 1265 | [Print Immutable Linked List in Reverse](https://leetcode.com/problems/print-immutable-linked-list-in-reverse) 🔒 | [Go](problems/print-immutable-linked-list-in-reverse) | Medium | +| 1265 | [Print Immutable Linked List in Reverse](https://leetcode.com/problems/print-immutable-linked-list-in-reverse "逆序打印不可变链表") 🔒 | [Go](problems/print-immutable-linked-list-in-reverse) | Medium | | 1264 | [Page Recommendations](https://leetcode.com/problems/page-recommendations) 🔒 | [MySQL](problems/page-recommendations) | Medium | | 1263 | [Minimum Moves to Move a Box to Their Target Location](https://leetcode.com/problems/minimum-moves-to-move-a-box-to-their-target-location "推箱子") | [Go](problems/minimum-moves-to-move-a-box-to-their-target-location) | Hard | | 1262 | [Greatest Sum Divisible by Three](https://leetcode.com/problems/greatest-sum-divisible-by-three "可被三整除的最大和") | [Go](problems/greatest-sum-divisible-by-three) | Medium | @@ -195,7 +196,7 @@ LeetCode Problems' Solutions | 1177 | [Can Make Palindrome from Substring](https://leetcode.com/problems/can-make-palindrome-from-substring "构建回文串检测") | [Go](problems/can-make-palindrome-from-substring) | Medium | | 1176 | [Diet Plan Performance](https://leetcode.com/problems/diet-plan-performance "健身计划评估") 🔒 | [Go](problems/diet-plan-performance) | Easy | | 1175 | [Prime Arrangements](https://leetcode.com/problems/prime-arrangements "质数排列") | [Go](problems/prime-arrangements) | Easy | -| 1174 | [Immediate Food Delivery II](https://leetcode.com/problems/immediate-food-delivery-ii) 🔒 | [MySQL](problems/immediate-food-delivery-ii) | Medium | +| 1174 | [Immediate Food Delivery II](https://leetcode.com/problems/immediate-food-delivery-ii "即时食物配送 II") 🔒 | [MySQL](problems/immediate-food-delivery-ii) | Medium | | 1173 | [Immediate Food Delivery I](https://leetcode.com/problems/immediate-food-delivery-i "即时食物配送 I") 🔒 | [MySQL](problems/immediate-food-delivery-i) | Easy | | 1172 | [Dinner Plate Stacks](https://leetcode.com/problems/dinner-plate-stacks "餐盘栈") | [Go](problems/dinner-plate-stacks) | Hard | | 1171 | [Remove Zero Sum Consecutive Nodes from Linked List](https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list "从链表中删去总和值为零的连续节点") | [Go](problems/remove-zero-sum-consecutive-nodes-from-linked-list) | Medium | @@ -256,7 +257,7 @@ LeetCode Problems' Solutions | 1116 | [Print Zero Even Odd](https://leetcode.com/problems/print-zero-even-odd "打印零与奇偶数") | [Go](problems/print-zero-even-odd) | Medium | | 1115 | [Print FooBar Alternately](https://leetcode.com/problems/print-foobar-alternately "交替打印FooBar") | [Go](problems/print-foobar-alternately) | Medium | | 1114 | [Print in Order](https://leetcode.com/problems/print-in-order "按序打印") | [Go](problems/print-in-order) | Easy | -| 1113 | [Reported Posts](https://leetcode.com/problems/reported-posts) 🔒 | [MySQL](problems/reported-posts) | Easy | +| 1113 | [Reported Posts](https://leetcode.com/problems/reported-posts "报告的记录") 🔒 | [MySQL](problems/reported-posts) | Easy | | 1112 | [Highest Grade For Each Student](https://leetcode.com/problems/highest-grade-for-each-student "每位学生的最高成绩") 🔒 | [MySQL](problems/highest-grade-for-each-student) | Medium | | 1111 | [Maximum Nesting Depth of Two Valid Parentheses Strings](https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings "有效括号的嵌套深度") | [Go](problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | Medium | | 1110 | [Delete Nodes And Return Forest](https://leetcode.com/problems/delete-nodes-and-return-forest "删点成林") | [Go](problems/delete-nodes-and-return-forest) | Medium | diff --git a/problems/count-and-say/README.md b/problems/count-and-say/README.md index 518a90528..9d287b488 100644 --- a/problems/count-and-say/README.md +++ b/problems/count-and-say/README.md @@ -9,7 +9,7 @@                  [Next >](../combination-sum "Combination Sum") -## [38. Count and Say (Easy)](https://leetcode.com/problems/count-and-say "报数") +## [38. Count and Say (Easy)](https://leetcode.com/problems/count-and-say "外观数列")

The count-and-say sequence is the sequence of integers with the first five terms as following:

diff --git a/problems/find-the-start-and-end-number-of-continuous-ranges/README.md b/problems/find-the-start-and-end-number-of-continuous-ranges/README.md index cdc2150a3..cc874b923 100644 --- a/problems/find-the-start-and-end-number-of-continuous-ranges/README.md +++ b/problems/find-the-start-and-end-number-of-continuous-ranges/README.md @@ -9,7 +9,7 @@                  [Next >](../iterator-for-combination "Iterator for Combination") -## [1285. Find the Start and End Number of Continuous Ranges (Medium)](https://leetcode.com/problems/find-the-start-and-end-number-of-continuous-ranges "") +## [1285. Find the Start and End Number of Continuous Ranges (Medium)](https://leetcode.com/problems/find-the-start-and-end-number-of-continuous-ranges "找到连续区间的开始和结束数字")

Table: Logs

diff --git a/problems/get-highest-answer-rate-question/mysql_schemas.sql b/problems/get-highest-answer-rate-question/mysql_schemas.sql
index 4e5af2a5d..ce07f2d2a 100644
--- a/problems/get-highest-answer-rate-question/mysql_schemas.sql
+++ b/problems/get-highest-answer-rate-question/mysql_schemas.sql
@@ -1,6 +1,6 @@
-Create table If Not Exists survey_log (uid int, action varchar(255), question_id int, answer_id int, q_num int, timestamp int);
+Create table If Not Exists survey_log (id int, action varchar(255), question_id int, answer_id int, q_num int, timestamp int);
 Truncate table survey_log;
-insert into survey_log (uid, action, question_id, answer_id, q_num, timestamp) values ('5', 'show', '285', 'None', '1', '123');
-insert into survey_log (uid, action, question_id, answer_id, q_num, timestamp) values ('5', 'answer', '285', '124124', '1', '124');
-insert into survey_log (uid, action, question_id, answer_id, q_num, timestamp) values ('5', 'show', '369', 'None', '2', '125');
-insert into survey_log (uid, action, question_id, answer_id, q_num, timestamp) values ('5', 'skip', '369', 'None', '2', '126');
+insert into survey_log (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'show', '285', 'None', '1', '123');
+insert into survey_log (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'answer', '285', '124124', '1', '124');
+insert into survey_log (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'show', '369', 'None', '2', '125');
+insert into survey_log (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'skip', '369', 'None', '2', '126');
diff --git a/problems/immediate-food-delivery-ii/README.md b/problems/immediate-food-delivery-ii/README.md
index f2fc1fc9d..a860cff02 100644
--- a/problems/immediate-food-delivery-ii/README.md
+++ b/problems/immediate-food-delivery-ii/README.md
@@ -9,7 +9,7 @@
                 
 [Next >](../prime-arrangements "Prime Arrangements")
 
-## [1174. Immediate Food Delivery II (Medium)](https://leetcode.com/problems/immediate-food-delivery-ii "")
+## [1174. Immediate Food Delivery II (Medium)](https://leetcode.com/problems/immediate-food-delivery-ii "即时食物配送 II")
 
 

Table: Delivery

diff --git a/problems/print-immutable-linked-list-in-reverse/README.md b/problems/print-immutable-linked-list-in-reverse/README.md index 61bb8638d..74fabefa4 100644 --- a/problems/print-immutable-linked-list-in-reverse/README.md +++ b/problems/print-immutable-linked-list-in-reverse/README.md @@ -9,7 +9,7 @@                  [Next >](../minimum-time-visiting-all-points "Minimum Time Visiting All Points") -## [1265. Print Immutable Linked List in Reverse (Medium)](https://leetcode.com/problems/print-immutable-linked-list-in-reverse "") +## [1265. Print Immutable Linked List in Reverse (Medium)](https://leetcode.com/problems/print-immutable-linked-list-in-reverse "逆序打印不可变链表") You are given an immutable linked list, print out all values of each node in reverse with the help of the following interface: diff --git a/problems/reported-posts/README.md b/problems/reported-posts/README.md index 28d60a6a0..029c248ed 100644 --- a/problems/reported-posts/README.md +++ b/problems/reported-posts/README.md @@ -9,7 +9,7 @@                  [Next >](../print-in-order "Print in Order") -## [1113. Reported Posts (Easy)](https://leetcode.com/problems/reported-posts "") +## [1113. Reported Posts (Easy)](https://leetcode.com/problems/reported-posts "报告的记录")

Table: Actions

diff --git a/problems/running-total-for-different-genders/README.md b/problems/running-total-for-different-genders/README.md new file mode 100644 index 000000000..3e33c9da3 --- /dev/null +++ b/problems/running-total-for-different-genders/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../verbal-arithmetic-puzzle "Verbal Arithmetic Puzzle") +                 +Next > + +## [1308. Running Total for Different Genders (Medium)](https://leetcode.com/problems/running-total-for-different-genders "") + + + +### Similar Questions + 1. [Last Person to Fit in the Elevator](../last-person-to-fit-in-the-elevator) (Medium) diff --git a/problems/running-total-for-different-genders/mysql_schemas.sql b/problems/running-total-for-different-genders/mysql_schemas.sql new file mode 100644 index 000000000..365fc0407 --- /dev/null +++ b/problems/running-total-for-different-genders/mysql_schemas.sql @@ -0,0 +1,11 @@ +Create table If Not Exists Scores (player_name varchar(20), gender varchar(1), day date, score_points int); +Truncate table Scores; +insert into Scores (player_name, gender, day, score_points) values ('Aron', 'F', '2020-01-01', '17'); +insert into Scores (player_name, gender, day, score_points) values ('Alice', 'F', '2020-01-07', '23'); +insert into Scores (player_name, gender, day, score_points) values ('Bajrang', 'M', '2020-01-07', '7'); +insert into Scores (player_name, gender, day, score_points) values ('Khali', 'M', '2019-12-25', '11'); +insert into Scores (player_name, gender, day, score_points) values ('Slaman', 'M', '2019-12-30', '13'); +insert into Scores (player_name, gender, day, score_points) values ('Joe', 'M', '2019-12-31', '3'); +insert into Scores (player_name, gender, day, score_points) values ('Jose', 'M', '2019-12-18', '2'); +insert into Scores (player_name, gender, day, score_points) values ('Priya', 'F', '2019-12-31', '23'); +insert into Scores (player_name, gender, day, score_points) values ('Priyanka', 'F', '2019-12-30', '17'); diff --git a/problems/verbal-arithmetic-puzzle/README.md b/problems/verbal-arithmetic-puzzle/README.md index 5ded4692a..eaf4fc394 100644 --- a/problems/verbal-arithmetic-puzzle/README.md +++ b/problems/verbal-arithmetic-puzzle/README.md @@ -7,7 +7,7 @@ [< Previous](../jump-game-iii "Jump Game III")                  -Next > +[Next >](../running-total-for-different-genders "Running Total for Different Genders") ## [1307. Verbal Arithmetic Puzzle (Hard)](https://leetcode.com/problems/verbal-arithmetic-puzzle "口算难题") diff --git a/problems/weather-type-in-each-country/README.md b/problems/weather-type-in-each-country/README.md index b9bbc9ae6..5af755cf5 100644 --- a/problems/weather-type-in-each-country/README.md +++ b/problems/weather-type-in-each-country/README.md @@ -9,7 +9,7 @@                  [Next >](../find-numbers-with-even-number-of-digits "Find Numbers with Even Number of Digits") -## [1294. Weather Type in Each Country (Easy)](https://leetcode.com/problems/weather-type-in-each-country "") +## [1294. Weather Type in Each Country (Easy)](https://leetcode.com/problems/weather-type-in-each-country "不同国家的天气类型")

Table: Countries

diff --git a/readme/1-300.md b/readme/1-300.md
index 15fc094b0..bd56c5321 100644
--- a/readme/1-300.md
+++ b/readme/1-300.md
@@ -99,7 +99,7 @@ LeetCode Problems' Solutions
 | 35 | [Search Insert Position](https://leetcode.com/problems/search-insert-position "搜索插入位置") | [Go](../problems/search-insert-position) | Easy |
 | 36 | [Valid Sudoku](https://leetcode.com/problems/valid-sudoku "有效的数独") | [Go](../problems/valid-sudoku) | Medium |
 | 37 | [Sudoku Solver](https://leetcode.com/problems/sudoku-solver "解数独") | [Go](../problems/sudoku-solver) | Hard |
-| 38 | [Count and Say](https://leetcode.com/problems/count-and-say "报数") | [Go](../problems/count-and-say) | Easy |
+| 38 | [Count and Say](https://leetcode.com/problems/count-and-say "外观数列") | [Go](../problems/count-and-say) | Easy |
 | 39 | [Combination Sum](https://leetcode.com/problems/combination-sum "组合总和") | [Go](../problems/combination-sum) | Medium |
 | 40 | [Combination Sum II](https://leetcode.com/problems/combination-sum-ii "组合总和 II") | [Go](../problems/combination-sum-ii) | Medium |
 | 41 | [First Missing Positive](https://leetcode.com/problems/first-missing-positive "缺失的第一个正数") | [Go](../problems/first-missing-positive) | Hard |
diff --git a/tag/string/README.md b/tag/string/README.md
index 20203a6eb..9389598b0 100644
--- a/tag/string/README.md
+++ b/tag/string/README.md
@@ -145,7 +145,7 @@
 | 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)]  | Medium |
 | 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)]  | Hard |
 | 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)]  | Medium |
-| 38 | [报数](../../problems/count-and-say) | [[字符串](../string/README.md)]  | Easy |
+| 38 | [外观数列](../../problems/count-and-say) | [[字符串](../string/README.md)]  | Easy |
 | 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)]  | Hard |
 | 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)]  | Hard |
 | 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)]  | Easy |

From 6aab5be4c93e3651ab90a78f0777ca52474262ea Mon Sep 17 00:00:00 2001
From: Shuo 
Date: Mon, 6 Jan 2020 09:52:58 +0800
Subject: [PATCH 022/145] Add: new

---
 README.md                                     | 14 ++--
 problems/active-businesses/README.md          |  2 +-
 .../README.md                                 |  2 +-
 .../README.md                                 | 71 +++++++++++++++++
 problems/find-the-team-size/README.md         |  2 +-
 .../README.md                                 | 75 ++++++++++++++++++
 .../README.md                                 | 79 +++++++++++++++++++
 .../README.md                                 |  2 +-
 .../README.md                                 |  2 +-
 problems/verbal-arithmetic-puzzle/README.md   |  2 +-
 problems/web-crawler/README.md                |  2 +-
 problems/xor-queries-of-a-subarray/README.md  | 69 ++++++++++++++++
 tag/bit-manipulation/README.md                |  1 +
 tag/breadth-first-search/README.md            |  3 +-
 tag/depth-first-search/README.md              |  2 +-
 tag/dynamic-programming/README.md             |  1 +
 tag/hash-table/README.md                      |  1 +
 tag/string/README.md                          |  2 +
 18 files changed, 318 insertions(+), 14 deletions(-)
 create mode 100644 problems/decrypt-string-from-alphabet-to-integer-mapping/README.md
 create mode 100644 problems/get-watched-videos-by-your-friends/README.md
 create mode 100644 problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md
 create mode 100644 problems/xor-queries-of-a-subarray/README.md

diff --git a/README.md b/README.md
index 4bd1b7abc..b5c3e769d 100644
--- a/README.md
+++ b/README.md
@@ -62,12 +62,16 @@ LeetCode Problems' Solutions
 
 | # | Title | Solution | Difficulty |
 | :-: | - | - | :-: |
+| 1312 | [Minimum Insertion Steps to Make a String Palindrome](https://leetcode.com/problems/minimum-insertion-steps-to-make-a-string-palindrome "让字符串成为回文串的最少插入次数") | [Go](problems/minimum-insertion-steps-to-make-a-string-palindrome) | Hard |
+| 1311 | [Get Watched Videos by Your Friends](https://leetcode.com/problems/get-watched-videos-by-your-friends "获取你好友已观看的视频") | [Go](problems/get-watched-videos-by-your-friends) | Medium |
+| 1310 | [XOR Queries of a Subarray](https://leetcode.com/problems/xor-queries-of-a-subarray "子数组异或查询") | [Go](problems/xor-queries-of-a-subarray) | Medium |
+| 1309 | [Decrypt String from Alphabet to Integer Mapping](https://leetcode.com/problems/decrypt-string-from-alphabet-to-integer-mapping "解码字母到整数映射") | [Go](problems/decrypt-string-from-alphabet-to-integer-mapping) | Easy |
 | 1308 | [Running Total for Different Genders](https://leetcode.com/problems/running-total-for-different-genders) 🔒 | [MySQL](problems/running-total-for-different-genders) | Medium |
 | 1307 | [Verbal Arithmetic Puzzle](https://leetcode.com/problems/verbal-arithmetic-puzzle "口算难题") | [Go](problems/verbal-arithmetic-puzzle) | Hard |
 | 1306 | [Jump Game III](https://leetcode.com/problems/jump-game-iii "跳跃游戏 III") | [Go](problems/jump-game-iii) | Medium |
 | 1305 | [All Elements in Two Binary Search Trees](https://leetcode.com/problems/all-elements-in-two-binary-search-trees "两棵二叉搜索树中的所有元素") | [Go](problems/all-elements-in-two-binary-search-trees) | Medium |
 | 1304 | [Find N Unique Integers Sum up to Zero](https://leetcode.com/problems/find-n-unique-integers-sum-up-to-zero "和为零的N个唯一整数") | [Go](problems/find-n-unique-integers-sum-up-to-zero) | Easy |
-| 1303 | [Find the Team Size](https://leetcode.com/problems/find-the-team-size) 🔒 | [MySQL](problems/find-the-team-size) | Easy |
+| 1303 | [Find the Team Size](https://leetcode.com/problems/find-the-team-size "求团队人数") 🔒 | [MySQL](problems/find-the-team-size) | Easy |
 | 1302 | [Deepest Leaves Sum](https://leetcode.com/problems/deepest-leaves-sum "层数最深叶子节点的和") | [Go](problems/deepest-leaves-sum) | Medium |
 | 1301 | [Number of Paths with Max Score](https://leetcode.com/problems/number-of-paths-with-max-score "最大得分的路径数目") | [Go](problems/number-of-paths-with-max-score) | Hard |
 | 1300 | [Sum of Mutated Array Closest to Target](https://leetcode.com/problems/sum-of-mutated-array-closest-to-target "转变数组后最接近目标值的数组和") | [Go](problems/sum-of-mutated-array-closest-to-target) | Medium |
@@ -100,7 +104,7 @@ LeetCode Problems' Solutions
 | 1273 | [Delete Tree Nodes](https://leetcode.com/problems/delete-tree-nodes "删除树节点") 🔒 | [Go](problems/delete-tree-nodes) | Medium |
 | 1272 | [Remove Interval](https://leetcode.com/problems/remove-interval "删除区间") 🔒 | [Go](problems/remove-interval) | Medium |
 | 1271 | [Hexspeak](https://leetcode.com/problems/hexspeak "十六进制魔术数字") 🔒 | [Go](problems/hexspeak) | Easy |
-| 1270 | [All People Report to the Given Manager](https://leetcode.com/problems/all-people-report-to-the-given-manager) 🔒 | [MySQL](problems/all-people-report-to-the-given-manager) | Medium |
+| 1270 | [All People Report to the Given Manager](https://leetcode.com/problems/all-people-report-to-the-given-manager "向公司CEO汇报工作的所有人") 🔒 | [MySQL](problems/all-people-report-to-the-given-manager) | Medium |
 | 1269 | [Number of Ways to Stay in the Same Place After Some Steps](https://leetcode.com/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps "停在原地的方案数") | [Go](problems/number-of-ways-to-stay-in-the-same-place-after-some-steps) | Hard |
 | 1268 | [Search Suggestions System](https://leetcode.com/problems/search-suggestions-system "搜索推荐系统") | [Go](problems/search-suggestions-system) | Medium |
 | 1267 | [Count Servers that Communicate](https://leetcode.com/problems/count-servers-that-communicate "统计参与通信的服务器") | [Go](problems/count-servers-that-communicate) | Medium |
@@ -134,7 +138,7 @@ LeetCode Problems' Solutions
 | 1239 | [Maximum Length of a Concatenated String with Unique Characters](https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters "串联字符串的最大长度") | [Go](problems/maximum-length-of-a-concatenated-string-with-unique-characters) | Medium |
 | 1238 | [Circular Permutation in Binary Representation](https://leetcode.com/problems/circular-permutation-in-binary-representation "循环码排列") | [Go](problems/circular-permutation-in-binary-representation) | Medium |
 | 1237 | [Find Positive Integer Solution for a Given Equation](https://leetcode.com/problems/find-positive-integer-solution-for-a-given-equation "找出给定方程的正整数解") | [Go](problems/find-positive-integer-solution-for-a-given-equation) | Easy |
-| 1236 | [Web Crawler](https://leetcode.com/problems/web-crawler) 🔒 | [Go](problems/web-crawler) | Medium |
+| 1236 | [Web Crawler](https://leetcode.com/problems/web-crawler "网络爬虫") 🔒 | [Go](problems/web-crawler) | Medium |
 | 1235 | [Maximum Profit in Job Scheduling](https://leetcode.com/problems/maximum-profit-in-job-scheduling "规划兼职工作") | [Go](problems/maximum-profit-in-job-scheduling) | Hard |
 | 1234 | [Replace the Substring for Balanced String](https://leetcode.com/problems/replace-the-substring-for-balanced-string "替换子串得到平衡字符串") | [Go](problems/replace-the-substring-for-balanced-string) | Medium |
 | 1233 | [Remove Sub-Folders from the Filesystem](https://leetcode.com/problems/remove-sub-folders-from-the-filesystem "删除子文件夹") | [Go](problems/remove-sub-folders-from-the-filesystem) | Medium |
@@ -229,7 +233,7 @@ LeetCode Problems' Solutions
 | 1144 | [Decrease Elements To Make Array Zigzag](https://leetcode.com/problems/decrease-elements-to-make-array-zigzag "递减元素使数组呈锯齿状") | [Go](problems/decrease-elements-to-make-array-zigzag) | Medium |
 | 1143 | [Longest Common Subsequence](https://leetcode.com/problems/longest-common-subsequence "最长公共子序列") | [Go](problems/longest-common-subsequence) | Medium |
 | 1142 | [User Activity for the Past 30 Days II](https://leetcode.com/problems/user-activity-for-the-past-30-days-ii "过去30天的用户活动 II") 🔒 | [MySQL](problems/user-activity-for-the-past-30-days-ii) | Easy |
-| 1141 | [User Activity for the Past 30 Days I](https://leetcode.com/problems/user-activity-for-the-past-30-days-i) 🔒 | [MySQL](problems/user-activity-for-the-past-30-days-i) | Easy |
+| 1141 | [User Activity for the Past 30 Days I](https://leetcode.com/problems/user-activity-for-the-past-30-days-i "查询近30天活跃用户数") 🔒 | [MySQL](problems/user-activity-for-the-past-30-days-i) | Easy |
 | 1140 | [Stone Game II](https://leetcode.com/problems/stone-game-ii "石子游戏 II") | [Go](problems/stone-game-ii) | Medium |
 | 1139 | [Largest 1-Bordered Square](https://leetcode.com/problems/largest-1-bordered-square "最大的以 1 为边界的正方形") | [Go](problems/largest-1-bordered-square) | Medium |
 | 1138 | [Alphabet Board Path](https://leetcode.com/problems/alphabet-board-path "字母板上的路径") | [Go](problems/alphabet-board-path) | Medium |
@@ -244,7 +248,7 @@ LeetCode Problems' Solutions
 | 1129 | [Shortest Path with Alternating Colors](https://leetcode.com/problems/shortest-path-with-alternating-colors "颜色交替的最短路径") | [Go](problems/shortest-path-with-alternating-colors) | Medium |
 | 1128 | [Number of Equivalent Domino Pairs](https://leetcode.com/problems/number-of-equivalent-domino-pairs "等价多米诺骨牌对的数量") | [Go](problems/number-of-equivalent-domino-pairs) | Easy |
 | 1127 | [User Purchase Platform](https://leetcode.com/problems/user-purchase-platform) 🔒 | [MySQL](problems/user-purchase-platform) | Hard |
-| 1126 | [Active Businesses](https://leetcode.com/problems/active-businesses) 🔒 | [MySQL](problems/active-businesses) | Medium |
+| 1126 | [Active Businesses](https://leetcode.com/problems/active-businesses "查询活跃业务") 🔒 | [MySQL](problems/active-businesses) | Medium |
 | 1125 | [Smallest Sufficient Team](https://leetcode.com/problems/smallest-sufficient-team "最小的必要团队") | [Go](problems/smallest-sufficient-team) | Hard |
 | 1124 | [Longest Well-Performing Interval](https://leetcode.com/problems/longest-well-performing-interval "表现良好的最长时间段") | [Go](problems/longest-well-performing-interval) | Medium |
 | 1123 | [Lowest Common Ancestor of Deepest Leaves](https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves "最深叶节点的最近公共祖先") | [Go](problems/lowest-common-ancestor-of-deepest-leaves) | Medium |
diff --git a/problems/active-businesses/README.md b/problems/active-businesses/README.md
index 878048e5d..e5f157e4d 100644
--- a/problems/active-businesses/README.md
+++ b/problems/active-businesses/README.md
@@ -9,7 +9,7 @@
                 
 [Next >](../user-purchase-platform "User Purchase Platform")
 
-## [1126. Active Businesses (Medium)](https://leetcode.com/problems/active-businesses "")
+## [1126. Active Businesses (Medium)](https://leetcode.com/problems/active-businesses "查询活跃业务")
 
 

Table: Events

diff --git a/problems/all-people-report-to-the-given-manager/README.md b/problems/all-people-report-to-the-given-manager/README.md index 785024bfe..ccad4e619 100644 --- a/problems/all-people-report-to-the-given-manager/README.md +++ b/problems/all-people-report-to-the-given-manager/README.md @@ -9,7 +9,7 @@                  [Next >](../hexspeak "Hexspeak") -## [1270. All People Report to the Given Manager (Medium)](https://leetcode.com/problems/all-people-report-to-the-given-manager "") +## [1270. All People Report to the Given Manager (Medium)](https://leetcode.com/problems/all-people-report-to-the-given-manager "向公司CEO汇报工作的所有人")

Table: Employees

diff --git a/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md b/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md
new file mode 100644
index 000000000..ebfe6aaa5
--- /dev/null
+++ b/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+[< Previous](../running-total-for-different-genders "Running Total for Different Genders")
+                
+[Next >](../xor-queries-of-a-subarray "XOR Queries of a Subarray")
+
+## [1309. Decrypt String from Alphabet to Integer Mapping (Easy)](https://leetcode.com/problems/decrypt-string-from-alphabet-to-integer-mapping "解码字母到整数映射")
+
+

Given a string s formed by digits ('0' - '9') and '#' . We want to map s to English lowercase characters as follows:

+ +
    +
  • Characters ('a' to 'i') are represented by ('1' to '9') respectively.
  • +
  • Characters ('j' to 'z') are represented by ('10#' to '26#') respectively. 
  • +
+ +

Return the string formed after mapping.

+ +

It's guaranteed that a unique mapping will always exist.

+ +

 

+

Example 1:

+ +
+Input: s = "10#11#12"
+Output: "jkab"
+Explanation: "j" -> "10#" , "k" -> "11#" , "a" -> "1" , "b" -> "2".
+
+ +

Example 2:

+ +
+Input: s = "1326#"
+Output: "acz"
+
+ +

Example 3:

+ +
+Input: s = "25#"
+Output: "y"
+
+ +

Example 4:

+ +
+Input: s = "12345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#"
+Output: "abcdefghijklmnopqrstuvwxyz"
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= s.length <= 1000
  • +
  • s[i] only contains digits letters ('0'-'9') and '#' letter.
  • +
  • s will be valid string such that mapping is always possible.
  • +
+ +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
+Hint 1 +Scan from right to left, in each step of the scanning check whether there is a trailing "#" 2 indexes away. +
diff --git a/problems/find-the-team-size/README.md b/problems/find-the-team-size/README.md index 6f2178d99..02ee15626 100644 --- a/problems/find-the-team-size/README.md +++ b/problems/find-the-team-size/README.md @@ -9,6 +9,6 @@                  [Next >](../find-n-unique-integers-sum-up-to-zero "Find N Unique Integers Sum up to Zero") -## [1303. Find the Team Size (Easy)](https://leetcode.com/problems/find-the-team-size "") +## [1303. Find the Team Size (Easy)](https://leetcode.com/problems/find-the-team-size "求团队人数") diff --git a/problems/get-watched-videos-by-your-friends/README.md b/problems/get-watched-videos-by-your-friends/README.md new file mode 100644 index 000000000..d3e1a3f97 --- /dev/null +++ b/problems/get-watched-videos-by-your-friends/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../xor-queries-of-a-subarray "XOR Queries of a Subarray") +                 +[Next >](../minimum-insertion-steps-to-make-a-string-palindrome "Minimum Insertion Steps to Make a String Palindrome") + +## [1311. Get Watched Videos by Your Friends (Medium)](https://leetcode.com/problems/get-watched-videos-by-your-friends "获取你好友已观看的视频") + +

There are n people, each person has a unique id between 0 and n-1. Given the arrays watchedVideos and friends, where watchedVideos[i] and friends[i] contain the list of watched videos and the list of friends respectively for the person with id = i.

+ +

Level 1 of videos are all watched videos by your friends, level 2 of videos are all watched videos by the friends of your friends and so on. In general, the level k of videos are all watched videos by people with the shortest path equal to k with you. Given your id and the level of videos, return the list of videos ordered by their frequencies (increasing). For videos with the same frequency order them alphabetically from least to greatest. 

+ +

 

+

Example 1:

+ +

+ +
+Input: watchedVideos = [["A","B"],["C"],["B","C"],["D"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 1
+Output: ["B","C"] 
+Explanation: 
+You have id = 0 (green color in the figure) and your friends are (yellow color in the figure):
+Person with id = 1 -> watchedVideos = ["C"] 
+Person with id = 2 -> watchedVideos = ["B","C"] 
+The frequencies of watchedVideos by your friends are: 
+B -> 1 
+C -> 2
+
+ +

Example 2:

+ +

+ +
+Input: watchedVideos = [["A","B"],["C"],["B","C"],["D"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 2
+Output: ["D"]
+Explanation: 
+You have id = 0 (green color in the figure) and the only friend of your friends is the person with id = 3 (yellow color in the figure).
+
+ +

 

+

Constraints:

+ +
    +
  • n == watchedVideos.length == friends.length
  • +
  • 2 <= n <= 100
  • +
  • 1 <= watchedVideos[i].length <= 100
  • +
  • 1 <= watchedVideos[i][j].length <= 8
  • +
  • 0 <= friends[i].length < n
  • +
  • 0 <= friends[i][j] < n
  • +
  • 0 <= id < n
  • +
  • 1 <= level < n
  • +
  • if friends[i] contains j, then friends[j] contains i
  • +
+ +### Related Topics + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
+Hint 1 +Do BFS to find the kth level friends. +
+ +
+Hint 2 +Then collect movies saw by kth level friends and sort them accordingly. +
diff --git a/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md b/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md new file mode 100644 index 000000000..6d4b720ef --- /dev/null +++ b/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../get-watched-videos-by-your-friends "Get Watched Videos by Your Friends") +                 +Next > + +## [1312. Minimum Insertion Steps to Make a String Palindrome (Hard)](https://leetcode.com/problems/minimum-insertion-steps-to-make-a-string-palindrome "让字符串成为回文串的最少插入次数") + +

Given a string s. In one step you can insert any character at any index of the string.

+ +

Return the minimum number of steps to make s palindrome.

+ +

Palindrome String is one that reads the same backward as well as forward.

+ +

 

+

Example 1:

+ +
+Input: s = "zzazz"
+Output: 0
+Explanation: The string "zzazz" is already palindrome we don't need any insertions.
+
+ +

Example 2:

+ +
+Input: s = "mbadm"
+Output: 2
+Explanation: String can be "mbdadbm" or "mdbabdm".
+
+ +

Example 3:

+ +
+Input: s = "leetcode"
+Output: 5
+Explanation: Inserting 5 characters the string becomes "leetcodocteel".
+
+ +

Example 4:

+ +
+Input: s = "g"
+Output: 0
+
+ +

Example 5:

+ +
+Input: s = "no"
+Output: 1
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= s.length <= 500
  • +
  • All characters of s are lower case English letters.
  • +
+ +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
+Hint 1 +Is dynamic programming suitable for this problem ? +
+ +
+Hint 2 +If we know the longest palindromic sub-sequence is x and the length of the string is n then, what is the answer to this problem? It is n - x as we need n - x insertions to make the remaining characters also palindrome. +
diff --git a/problems/running-total-for-different-genders/README.md b/problems/running-total-for-different-genders/README.md index 3e33c9da3..493be1006 100644 --- a/problems/running-total-for-different-genders/README.md +++ b/problems/running-total-for-different-genders/README.md @@ -7,7 +7,7 @@ [< Previous](../verbal-arithmetic-puzzle "Verbal Arithmetic Puzzle")                  -Next > +[Next >](../decrypt-string-from-alphabet-to-integer-mapping "Decrypt String from Alphabet to Integer Mapping") ## [1308. Running Total for Different Genders (Medium)](https://leetcode.com/problems/running-total-for-different-genders "") diff --git a/problems/user-activity-for-the-past-30-days-i/README.md b/problems/user-activity-for-the-past-30-days-i/README.md index 45bc8ab07..083444f4f 100644 --- a/problems/user-activity-for-the-past-30-days-i/README.md +++ b/problems/user-activity-for-the-past-30-days-i/README.md @@ -9,7 +9,7 @@                  [Next >](../user-activity-for-the-past-30-days-ii "User Activity for the Past 30 Days II") -## [1141. User Activity for the Past 30 Days I (Easy)](https://leetcode.com/problems/user-activity-for-the-past-30-days-i "") +## [1141. User Activity for the Past 30 Days I (Easy)](https://leetcode.com/problems/user-activity-for-the-past-30-days-i "查询近30天活跃用户数")

Table: Activity

diff --git a/problems/verbal-arithmetic-puzzle/README.md b/problems/verbal-arithmetic-puzzle/README.md index eaf4fc394..0724fe028 100644 --- a/problems/verbal-arithmetic-puzzle/README.md +++ b/problems/verbal-arithmetic-puzzle/README.md @@ -60,7 +60,7 @@ Such that: "SIX" + "SEVEN" + "SEVEN" = "TWENT
  • 2 <= words.length <= 5
  • -
  • 1 <= words[i].length, results.length <= 7
  • +
  • 1 <= words[i].length, result.length <= 7
  • words[i], result contains only upper case English letters.
  • Number of different characters used on the expression is at most 10.
diff --git a/problems/web-crawler/README.md b/problems/web-crawler/README.md index f242a7b83..bbec735a2 100644 --- a/problems/web-crawler/README.md +++ b/problems/web-crawler/README.md @@ -9,7 +9,7 @@                  [Next >](../find-positive-integer-solution-for-a-given-equation "Find Positive Integer Solution for a Given Equation") -## [1236. Web Crawler (Medium)](https://leetcode.com/problems/web-crawler "") +## [1236. Web Crawler (Medium)](https://leetcode.com/problems/web-crawler "网络爬虫")

Given a url startUrl and an interface HtmlParser, implement a web crawler to crawl all links that are under the same hostname as startUrl

diff --git a/problems/xor-queries-of-a-subarray/README.md b/problems/xor-queries-of-a-subarray/README.md new file mode 100644 index 000000000..cad1478f7 --- /dev/null +++ b/problems/xor-queries-of-a-subarray/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../decrypt-string-from-alphabet-to-integer-mapping "Decrypt String from Alphabet to Integer Mapping") +                 +[Next >](../get-watched-videos-by-your-friends "Get Watched Videos by Your Friends") + +## [1310. XOR Queries of a Subarray (Medium)](https://leetcode.com/problems/xor-queries-of-a-subarray "子数组异或查询") + +Given the array arr of positive integers and the array queries where queries[i] = [Li, Ri], for each query i compute the XOR of elements from Li to Ri (that is, arr[Li] xor arr[Li+1] xor ... xor arr[Ri] ). Return an array containing the result for the given queries. +

 

+

Example 1:

+ +
+Input: arr = [1,3,4,8], queries = [[0,1],[1,2],[0,3],[3,3]]
+Output: [2,7,14,8] 
+Explanation: 
+The binary representation of the elements in the array are:
+1 = 0001 
+3 = 0011 
+4 = 0100 
+8 = 1000 
+The XOR values for queries are:
+[0,1] = 1 xor 3 = 2 
+[1,2] = 3 xor 4 = 7 
+[0,3] = 1 xor 3 xor 4 xor 8 = 14 
+[3,3] = 8
+
+ +

Example 2:

+ +
+Input: arr = [4,8,2,10], queries = [[2,3],[1,3],[0,0],[0,3]]
+Output: [8,0,4,4]
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= arr.length <= 3 * 10^4
  • +
  • 1 <= arr[i] <= 10^9
  • +
  • 1 <= queries.length <= 3 * 10^4
  • +
  • queries[i].length == 2
  • +
  • 0 <= queries[i][0] <= queries[i][1] < arr.length
  • +
+ +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + +### Hints +
+Hint 1 +What is the result of x ^ y ^ x ? +
+ +
+Hint 2 +Compute the prefix sum for XOR. +
+ +
+Hint 3 +Process the queries with the prefix sum values. +
diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 2a046f6b3..637201e0d 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1310 | [子数组异或查询](../../problems/xor-queries-of-a-subarray) | [[位运算](../bit-manipulation/README.md)] | Medium | | 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)] | Easy | | 1256 | [加密数字](../../problems/encode-number) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 2c1d516ea..aaef8bbae 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1298 | [你能从盒子里获得的最大糖果数](../../problems/maximum-candies-you-can-get-from-boxes) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 1293 | [网格中的最短路径](../../problems/shortest-path-in-a-grid-with-obstacles-elimination) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | @@ -16,7 +17,7 @@ | 1263 | [推箱子](../../problems/minimum-moves-to-move-a-box-to-their-target-location) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1242 | [多线程网页爬虫](../../problems/web-crawler-multithreaded) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1236 | [Web Crawler](../../problems/web-crawler) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1236 | [网络爬虫](../../problems/web-crawler) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1210 | [穿过迷宫的最少移动次数](../../problems/minimum-moves-to-reach-target-with-rotations) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 1197 | [进击的骑士](../../problems/minimum-knight-moves) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 6851a2a5e..a9a13bd81 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -14,7 +14,7 @@ | 1254 | [统计封闭岛屿的数目](../../problems/number-of-closed-islands) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1242 | [多线程网页爬虫](../../problems/web-crawler-multithreaded) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1236 | [Web Crawler](../../problems/web-crawler) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1236 | [网络爬虫](../../problems/web-crawler) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | | 1192 | [查找集群内的「关键连接」](../../problems/critical-connections-in-a-network) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | | 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 8c99435cf..28ab71a2c 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1312 | [让字符串成为回文串的最少插入次数](../../problems/minimum-insertion-steps-to-make-a-string-palindrome) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1301 | [最大得分的路径数目](../../problems/number-of-paths-with-max-score) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1289 | [下降路径最小和 II](../../problems/minimum-falling-path-sum-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1278 | [分割回文串 III](../../problems/palindrome-partitioning-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 32d850461..6aa1733f9 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1224 | [最大相等频率](../../problems/maximum-equal-frequency) | [[哈希表](../hash-table/README.md)] | Hard | diff --git a/tag/string/README.md b/tag/string/README.md index 9389598b0..976e47a4c 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1309 | [解码字母到整数映射](../../problems/decrypt-string-from-alphabet-to-integer-mapping) | [[字符串](../string/README.md)] | Easy | | 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1271 | [十六进制魔术数字](../../problems/hexspeak) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 1268 | [搜索推荐系统](../../problems/search-suggestions-system) | [[字符串](../string/README.md)] | Medium | From a07c5ac810b2ef783a9f32d9b406af763143e3f6 Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 8 Jan 2020 11:36:52 +0800 Subject: [PATCH 023/145] Add: Decrypt String from Alphabet to Integer Mapping --- ...string_from_alphabet_to_integer_mapping.go | 16 ++++++++++ ...g_from_alphabet_to_integer_mapping_test.go | 31 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 problems/decrypt-string-from-alphabet-to-integer-mapping/decrypt_string_from_alphabet_to_integer_mapping.go create mode 100644 problems/decrypt-string-from-alphabet-to-integer-mapping/decrypt_string_from_alphabet_to_integer_mapping_test.go diff --git a/problems/decrypt-string-from-alphabet-to-integer-mapping/decrypt_string_from_alphabet_to_integer_mapping.go b/problems/decrypt-string-from-alphabet-to-integer-mapping/decrypt_string_from_alphabet_to_integer_mapping.go new file mode 100644 index 000000000..e6bdc5079 --- /dev/null +++ b/problems/decrypt-string-from-alphabet-to-integer-mapping/decrypt_string_from_alphabet_to_integer_mapping.go @@ -0,0 +1,16 @@ +package problem1309 + +func freqAlphabets(s string) string { + l := len(s) + ans, head := make([]byte, l), l-1 + for i := l - 1; i >= 0; i-- { + if s[i] == '#' { + ans[head] = 'a' + (s[i-1] - '1') + (s[i-2]-'0')*10 + i -= 2 + } else { + ans[head] = 'a' + (s[i] - '1') + } + head-- + } + return string(ans[head+1:]) +} diff --git a/problems/decrypt-string-from-alphabet-to-integer-mapping/decrypt_string_from_alphabet_to_integer_mapping_test.go b/problems/decrypt-string-from-alphabet-to-integer-mapping/decrypt_string_from_alphabet_to_integer_mapping_test.go new file mode 100644 index 000000000..1fadf7105 --- /dev/null +++ b/problems/decrypt-string-from-alphabet-to-integer-mapping/decrypt_string_from_alphabet_to_integer_mapping_test.go @@ -0,0 +1,31 @@ +package problem1309 + +import "testing" + +type testType struct { + in string + want string +} + +func TestFreqAlphabets(t *testing.T) { + tests := [...]testType{ + { + in: "10#11#12", + want: "jkab", + }, + { + in: "1326#", + want: "acz", + }, + { + in: "12345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#", + want: "abcdefghijklmnopqrstuvwxyz", + }, + } + for _, tt := range tests { + got := freqAlphabets(tt.in) + if got != tt.want { + t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want) + } + } +} From af5e6780a319c25b90f1911a87009cc4c7416b6f Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 9 Jan 2020 10:14:29 +0800 Subject: [PATCH 024/145] Add: Combine Two Tables --- problems/combine-two-tables/combine_two_tables.sql | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/problems/combine-two-tables/combine_two_tables.sql b/problems/combine-two-tables/combine_two_tables.sql index bae62cf19..eb8813415 100644 --- a/problems/combine-two-tables/combine_two_tables.sql +++ b/problems/combine-two-tables/combine_two_tables.sql @@ -1 +1,10 @@ # Write your MySQL query statement below + +SELECT + Person.FirstName, + Person.LastName, + Address.City, + Address.State +FROM + Person +LEFT JOIN Address ON Person.PersonId = Address.PersonId; From 04c80dd37da6693cc79b239ab3506b3eeaa8afa7 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 13 Jan 2020 11:15:49 +0800 Subject: [PATCH 025/145] Add: new --- README.md | 22 +++-- problems/average-selling-price/README.md | 2 +- .../README.md | 81 +++++++++++++++++ .../README.md | 41 +++++++++ problems/distinct-echo-substrings/README.md | 58 +++++++++++++ problems/market-analysis-i/README.md | 2 +- problems/matrix-block-sum/README.md | 57 ++++++++++++ .../README.md | 86 +++++++++++++++++++ .../README.md | 57 ++++++++++++ .../README.md | 2 +- .../README.md | 80 +++++++++++++++++ problems/page-recommendations/README.md | 2 +- .../product-price-at-a-given-date/README.md | 2 +- problems/shift-2d-grid/README.md | 6 +- problems/similar-string-groups/README.md | 2 +- .../README.md | 50 +++++++++++ .../README.md | 2 +- .../README.md | 2 +- problems/user-purchase-platform/README.md | 2 +- tag/README.md | 4 +- tag/array/README.md | 1 + tag/bit-manipulation/README.md | 1 + tag/breadth-first-search/README.md | 1 + tag/depth-first-search/README.md | 2 + tag/dynamic-programming/README.md | 2 + tag/math/README.md | 1 + tag/string/README.md | 1 + tag/tags.json | 10 +-- tag/tree/README.md | 1 + tag/union-find/README.md | 1 + 30 files changed, 555 insertions(+), 26 deletions(-) create mode 100644 problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md create mode 100644 problems/decompress-run-length-encoded-list/README.md create mode 100644 problems/distinct-echo-substrings/README.md create mode 100644 problems/matrix-block-sum/README.md create mode 100644 problems/minimum-distance-to-type-a-word-using-two-fingers/README.md create mode 100644 problems/minimum-flips-to-make-a-or-b-equal-to-c/README.md create mode 100644 problems/number-of-operations-to-make-network-connected/README.md create mode 100644 problems/sum-of-nodes-with-even-valued-grandparent/README.md diff --git a/README.md b/README.md index b5c3e769d..ef96d64d4 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,14 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1320 | [Minimum Distance to Type a Word Using Two Fingers](https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers "二指输入的的最小距离") | [Go](problems/minimum-distance-to-type-a-word-using-two-fingers) | Hard | +| 1319 | [Number of Operations to Make Network Connected](https://leetcode.com/problems/number-of-operations-to-make-network-connected "连通网络的操作次数") | [Go](problems/number-of-operations-to-make-network-connected) | Medium | +| 1318 | [Minimum Flips to Make a OR b Equal to c](https://leetcode.com/problems/minimum-flips-to-make-a-or-b-equal-to-c "或运算的最小翻转次数") | [Go](problems/minimum-flips-to-make-a-or-b-equal-to-c) | Medium | +| 1317 | [Convert Integer to the Sum of Two No-Zero Integers](https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers "将整数转换为两个无零整数的和") | [Go](problems/convert-integer-to-the-sum-of-two-no-zero-integers) | Easy | +| 1316 | [Distinct Echo Substrings](https://leetcode.com/problems/distinct-echo-substrings "不同的循环子字符串") | [Go](problems/distinct-echo-substrings) | Hard | +| 1315 | [Sum of Nodes with Even-Valued Grandparent](https://leetcode.com/problems/sum-of-nodes-with-even-valued-grandparent "祖父节点值为偶数的节点和") | [Go](problems/sum-of-nodes-with-even-valued-grandparent) | Medium | +| 1314 | [Matrix Block Sum](https://leetcode.com/problems/matrix-block-sum "矩阵区域和") | [Go](problems/matrix-block-sum) | Medium | +| 1313 | [Decompress Run-Length Encoded List](https://leetcode.com/problems/decompress-run-length-encoded-list "解压缩编码列表") | [Go](problems/decompress-run-length-encoded-list) | Easy | | 1312 | [Minimum Insertion Steps to Make a String Palindrome](https://leetcode.com/problems/minimum-insertion-steps-to-make-a-string-palindrome "让字符串成为回文串的最少插入次数") | [Go](problems/minimum-insertion-steps-to-make-a-string-palindrome) | Hard | | 1311 | [Get Watched Videos by Your Friends](https://leetcode.com/problems/get-watched-videos-by-your-friends "获取你好友已观看的视频") | [Go](problems/get-watched-videos-by-your-friends) | Medium | | 1310 | [XOR Queries of a Subarray](https://leetcode.com/problems/xor-queries-of-a-subarray "子数组异或查询") | [Go](problems/xor-queries-of-a-subarray) | Medium | @@ -95,7 +103,7 @@ LeetCode Problems' Solutions | 1282 | [Group the People Given the Group Size They Belong To](https://leetcode.com/problems/group-the-people-given-the-group-size-they-belong-to "用户分组") | [Go](problems/group-the-people-given-the-group-size-they-belong-to) | Medium | | 1281 | [Subtract the Product and Sum of Digits of an Integer](https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer "整数的各位积和之差") | [Go](problems/subtract-the-product-and-sum-of-digits-of-an-integer) | Easy | | 1280 | [Students and Examinations](https://leetcode.com/problems/students-and-examinations "学生们参加各科测试的次数") 🔒 | [MySQL](problems/students-and-examinations) | Easy | -| 1279 | [Traffic Light Controlled Intersection](https://leetcode.com/problems/traffic-light-controlled-intersection) 🔒 | [Go](problems/traffic-light-controlled-intersection) | Easy | +| 1279 | [Traffic Light Controlled Intersection](https://leetcode.com/problems/traffic-light-controlled-intersection "红绿灯路口") 🔒 | [Go](problems/traffic-light-controlled-intersection) | Easy | | 1278 | [Palindrome Partitioning III](https://leetcode.com/problems/palindrome-partitioning-iii "分割回文串 III") | [Go](problems/palindrome-partitioning-iii) | Hard | | 1277 | [Count Square Submatrices with All Ones](https://leetcode.com/problems/count-square-submatrices-with-all-ones "统计全为 1 的正方形子矩阵") | [Go](problems/count-square-submatrices-with-all-ones) | Medium | | 1276 | [Number of Burgers with No Waste of Ingredients](https://leetcode.com/problems/number-of-burgers-with-no-waste-of-ingredients "不浪费原料的汉堡制作方案") | [Go](problems/number-of-burgers-with-no-waste-of-ingredients) | Medium | @@ -110,7 +118,7 @@ LeetCode Problems' Solutions | 1267 | [Count Servers that Communicate](https://leetcode.com/problems/count-servers-that-communicate "统计参与通信的服务器") | [Go](problems/count-servers-that-communicate) | Medium | | 1266 | [Minimum Time Visiting All Points](https://leetcode.com/problems/minimum-time-visiting-all-points "访问所有点的最小时间") | [Go](problems/minimum-time-visiting-all-points) | Easy | | 1265 | [Print Immutable Linked List in Reverse](https://leetcode.com/problems/print-immutable-linked-list-in-reverse "逆序打印不可变链表") 🔒 | [Go](problems/print-immutable-linked-list-in-reverse) | Medium | -| 1264 | [Page Recommendations](https://leetcode.com/problems/page-recommendations) 🔒 | [MySQL](problems/page-recommendations) | Medium | +| 1264 | [Page Recommendations](https://leetcode.com/problems/page-recommendations "页面推荐") 🔒 | [MySQL](problems/page-recommendations) | Medium | | 1263 | [Minimum Moves to Move a Box to Their Target Location](https://leetcode.com/problems/minimum-moves-to-move-a-box-to-their-target-location "推箱子") | [Go](problems/minimum-moves-to-move-a-box-to-their-target-location) | Hard | | 1262 | [Greatest Sum Divisible by Three](https://leetcode.com/problems/greatest-sum-divisible-by-three "可被三整除的最大和") | [Go](problems/greatest-sum-divisible-by-three) | Medium | | 1261 | [Find Elements in a Contaminated Binary Tree](https://leetcode.com/problems/find-elements-in-a-contaminated-binary-tree "在受污染的二叉树中查找元素") | [Go](problems/find-elements-in-a-contaminated-binary-tree) | Medium | @@ -123,7 +131,7 @@ LeetCode Problems' Solutions | 1254 | [Number of Closed Islands](https://leetcode.com/problems/number-of-closed-islands "统计封闭岛屿的数目") | [Go](problems/number-of-closed-islands) | Medium | | 1253 | [Reconstruct a 2-Row Binary Matrix](https://leetcode.com/problems/reconstruct-a-2-row-binary-matrix "重构 2 行二进制矩阵") | [Go](problems/reconstruct-a-2-row-binary-matrix) | Medium | | 1252 | [Cells with Odd Values in a Matrix](https://leetcode.com/problems/cells-with-odd-values-in-a-matrix "奇数值单元格的数目") | [Go](problems/cells-with-odd-values-in-a-matrix) | Easy | -| 1251 | [Average Selling Price](https://leetcode.com/problems/average-selling-price) 🔒 | [MySQL](problems/average-selling-price) | Easy | +| 1251 | [Average Selling Price](https://leetcode.com/problems/average-selling-price "平均售价") 🔒 | [MySQL](problems/average-selling-price) | Easy | | 1250 | [Check If It Is a Good Array](https://leetcode.com/problems/check-if-it-is-a-good-array "检查「好数组」") | [Go](problems/check-if-it-is-a-good-array) | Hard | | 1249 | [Minimum Remove to Make Valid Parentheses](https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses "移除无效的括号") | [Go](problems/minimum-remove-to-make-valid-parentheses) | Medium | | 1248 | [Count Number of Nice Subarrays](https://leetcode.com/problems/count-number-of-nice-subarrays "统计「优美子数组」") | [Go](problems/count-number-of-nice-subarrays) | Medium | @@ -162,7 +170,7 @@ LeetCode Problems' Solutions | 1215 | [Stepping Numbers](https://leetcode.com/problems/stepping-numbers "步进数") 🔒 | [Go](problems/stepping-numbers) | Medium | | 1214 | [Two Sum BSTs](https://leetcode.com/problems/two-sum-bsts "查找两棵二叉搜索树之和") 🔒 | [Go](problems/two-sum-bsts) | Medium | | 1213 | [Intersection of Three Sorted Arrays](https://leetcode.com/problems/intersection-of-three-sorted-arrays "三个有序数组的交集") 🔒 | [Go](problems/intersection-of-three-sorted-arrays) | Easy | -| 1212 | [Team Scores in Football Tournament](https://leetcode.com/problems/team-scores-in-football-tournament) 🔒 | [MySQL](problems/team-scores-in-football-tournament) | Medium | +| 1212 | [Team Scores in Football Tournament](https://leetcode.com/problems/team-scores-in-football-tournament "查询球队积分") 🔒 | [MySQL](problems/team-scores-in-football-tournament) | Medium | | 1211 | [Queries Quality and Percentage](https://leetcode.com/problems/queries-quality-and-percentage) 🔒 | [MySQL](problems/queries-quality-and-percentage) | Easy | | 1210 | [Minimum Moves to Reach Target with Rotations](https://leetcode.com/problems/minimum-moves-to-reach-target-with-rotations "穿过迷宫的最少移动次数") | [Go](problems/minimum-moves-to-reach-target-with-rotations) | Hard | | 1209 | [Remove All Adjacent Duplicates in String II](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii "删除字符串中的所有相邻重复项 II") | [Go](problems/remove-all-adjacent-duplicates-in-string-ii) | Medium | @@ -210,13 +218,13 @@ LeetCode Problems' Solutions | 1167 | [Minimum Cost to Connect Sticks](https://leetcode.com/problems/minimum-cost-to-connect-sticks "连接棒材的最低费用") 🔒 | [Go](problems/minimum-cost-to-connect-sticks) | Medium | | 1166 | [Design File System](https://leetcode.com/problems/design-file-system "设计文件系统") 🔒 | [Go](problems/design-file-system) | Medium | | 1165 | [Single-Row Keyboard](https://leetcode.com/problems/single-row-keyboard "单行键盘") 🔒 | [Go](problems/single-row-keyboard) | Easy | -| 1164 | [Product Price at a Given Date](https://leetcode.com/problems/product-price-at-a-given-date) 🔒 | [MySQL](problems/product-price-at-a-given-date) | Medium | +| 1164 | [Product Price at a Given Date](https://leetcode.com/problems/product-price-at-a-given-date "指定日期的产品价格") 🔒 | [MySQL](problems/product-price-at-a-given-date) | Medium | | 1163 | [Last Substring in Lexicographical Order](https://leetcode.com/problems/last-substring-in-lexicographical-order "按字典序排在最后的子串") | [Go](problems/last-substring-in-lexicographical-order) | Hard | | 1162 | [As Far from Land as Possible](https://leetcode.com/problems/as-far-from-land-as-possible "地图分析") | [Go](problems/as-far-from-land-as-possible) | Medium | | 1161 | [Maximum Level Sum of a Binary Tree](https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree "最大层内元素和") | [Go](problems/maximum-level-sum-of-a-binary-tree) | Medium | | 1160 | [Find Words That Can Be Formed by Characters](https://leetcode.com/problems/find-words-that-can-be-formed-by-characters "拼写单词") | [Go](problems/find-words-that-can-be-formed-by-characters) | Easy | | 1159 | [Market Analysis II](https://leetcode.com/problems/market-analysis-ii) 🔒 | [MySQL](problems/market-analysis-ii) | Hard | -| 1158 | [Market Analysis I](https://leetcode.com/problems/market-analysis-i) 🔒 | [MySQL](problems/market-analysis-i) | Medium | +| 1158 | [Market Analysis I](https://leetcode.com/problems/market-analysis-i "市场分析 I") 🔒 | [MySQL](problems/market-analysis-i) | Medium | | 1157 | [Online Majority Element In Subarray](https://leetcode.com/problems/online-majority-element-in-subarray "子数组中占绝大多数的元素") | [Go](problems/online-majority-element-in-subarray) | Hard | | 1156 | [Swap For Longest Repeated Character Substring](https://leetcode.com/problems/swap-for-longest-repeated-character-substring "单字符重复子串的最大长度") | [Go](problems/swap-for-longest-repeated-character-substring) | Medium | | 1155 | [Number of Dice Rolls With Target Sum](https://leetcode.com/problems/number-of-dice-rolls-with-target-sum "掷骰子的N种方法") | [Go](problems/number-of-dice-rolls-with-target-sum) | Medium | @@ -247,7 +255,7 @@ LeetCode Problems' Solutions | 1130 | [Minimum Cost Tree From Leaf Values](https://leetcode.com/problems/minimum-cost-tree-from-leaf-values "叶值的最小代价生成树") | [Go](problems/minimum-cost-tree-from-leaf-values) | Medium | | 1129 | [Shortest Path with Alternating Colors](https://leetcode.com/problems/shortest-path-with-alternating-colors "颜色交替的最短路径") | [Go](problems/shortest-path-with-alternating-colors) | Medium | | 1128 | [Number of Equivalent Domino Pairs](https://leetcode.com/problems/number-of-equivalent-domino-pairs "等价多米诺骨牌对的数量") | [Go](problems/number-of-equivalent-domino-pairs) | Easy | -| 1127 | [User Purchase Platform](https://leetcode.com/problems/user-purchase-platform) 🔒 | [MySQL](problems/user-purchase-platform) | Hard | +| 1127 | [User Purchase Platform](https://leetcode.com/problems/user-purchase-platform "用户购买平台") 🔒 | [MySQL](problems/user-purchase-platform) | Hard | | 1126 | [Active Businesses](https://leetcode.com/problems/active-businesses "查询活跃业务") 🔒 | [MySQL](problems/active-businesses) | Medium | | 1125 | [Smallest Sufficient Team](https://leetcode.com/problems/smallest-sufficient-team "最小的必要团队") | [Go](problems/smallest-sufficient-team) | Hard | | 1124 | [Longest Well-Performing Interval](https://leetcode.com/problems/longest-well-performing-interval "表现良好的最长时间段") | [Go](problems/longest-well-performing-interval) | Medium | diff --git a/problems/average-selling-price/README.md b/problems/average-selling-price/README.md index db5550bb4..8eee2ff1e 100644 --- a/problems/average-selling-price/README.md +++ b/problems/average-selling-price/README.md @@ -9,7 +9,7 @@                  [Next >](../cells-with-odd-values-in-a-matrix "Cells with Odd Values in a Matrix") -## [1251. Average Selling Price (Easy)](https://leetcode.com/problems/average-selling-price "") +## [1251. Average Selling Price (Easy)](https://leetcode.com/problems/average-selling-price "平均售价")

Table: Prices

diff --git a/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md b/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md new file mode 100644 index 000000000..1d4bf848c --- /dev/null +++ b/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../distinct-echo-substrings "Distinct Echo Substrings") +                 +[Next >](../minimum-flips-to-make-a-or-b-equal-to-c "Minimum Flips to Make a OR b Equal to c") + +## [1317. Convert Integer to the Sum of Two No-Zero Integers (Easy)](https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers "将整数转换为两个无零整数的和") + +

Given an integer n. No-Zero integer is a positive integer which doesn't contain any 0 in its decimal representation.

+ +

Return a list of two integers [A, B] where:

+ +
    +
  • A and B are No-Zero integers.
  • +
  • A + B = n
  • +
+ +

It's guarateed that there is at least one valid solution. If there are many valid solutions you can return any of them.

+ +

 

+

Example 1:

+ +
+Input: n = 2
+Output: [1,1]
+Explanation: A = 1, B = 1. A + B = n and both A and B don't contain any 0 in their decimal representation.
+
+ +

Example 2:

+ +
+Input: n = 11
+Output: [2,9]
+
+ +

Example 3:

+ +
+Input: n = 10000
+Output: [1,9999]
+
+ +

Example 4:

+ +
+Input: n = 69
+Output: [1,68]
+
+ +

Example 5:

+ +
+Input: n = 1010
+Output: [11,999]
+
+ +

 

+

Constraints:

+ +
    +
  • 2 <= n <= 10^4
  • +
+ +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
+Hint 1 +Loop through all elements from 1 to n. +
+ +
+Hint 2 +Choose A = i and B = n - i then check if A and B are both No-Zero integers. +
diff --git a/problems/decompress-run-length-encoded-list/README.md b/problems/decompress-run-length-encoded-list/README.md new file mode 100644 index 000000000..e6d524263 --- /dev/null +++ b/problems/decompress-run-length-encoded-list/README.md @@ -0,0 +1,41 @@ + + + + + + + +[< Previous](../minimum-insertion-steps-to-make-a-string-palindrome "Minimum Insertion Steps to Make a String Palindrome") +                 +[Next >](../matrix-block-sum "Matrix Block Sum") + +## [1313. Decompress Run-Length Encoded List (Easy)](https://leetcode.com/problems/decompress-run-length-encoded-list "解压缩编码列表") + +

We are given a list nums of integers representing a list compressed with run-length encoding.

+ +

Consider each adjacent pair of elements [a, b] = [nums[2*i], nums[2*i+1]] (with i >= 0).  For each such pair, there are a elements with value b in the decompressed list.

+ +

Return the decompressed list.

+ +

 

+

Example 1:

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

 

+

Constraints:

+ +
    +
  • 2 <= nums.length <= 100
  • +
  • nums.length % 2 == 0
  • +
  • 1 <= nums[i] <= 100
  • +
+ +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
+Hint 1 +Decompress the given array by repeating nums[2*i+1] a number of times equal to nums[2*i]. +
diff --git a/problems/distinct-echo-substrings/README.md b/problems/distinct-echo-substrings/README.md new file mode 100644 index 000000000..58a16978f --- /dev/null +++ b/problems/distinct-echo-substrings/README.md @@ -0,0 +1,58 @@ + + + + + + + +[< Previous](../sum-of-nodes-with-even-valued-grandparent "Sum of Nodes with Even-Valued Grandparent") +                 +[Next >](../convert-integer-to-the-sum-of-two-no-zero-integers "Convert Integer to the Sum of Two No-Zero Integers") + +## [1316. Distinct Echo Substrings (Hard)](https://leetcode.com/problems/distinct-echo-substrings "不同的循环子字符串") + +

Return the number of distinct non-empty substrings of text that can be written as the concatenation of some string with itself.

+ +

 

+

Example 1:

+ +
+Input: text = "abcabcabc"
+Output: 3
+Explanation: The 3 substrings are "abcabc", "bcabca" and "cabcab".
+
+ +

Example 2:

+ +
+Input: text = "leetcodeleetcode"
+Output: 2
+Explanation: The 2 substrings are "ee" and "leetcodeleetcode".
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= text.length <= 2000
  • +
  • text has only lowercase English letters.
  • +
+ +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
+Hint 1 +Given a substring of the text, how to check if it can be written as the concatenation of a string with itself ? +
+ +
+Hint 2 +We can do that in linear time, a faster way is to use hashing. +
+ +
+Hint 3 +Try all substrings and use hashing to check them. +
diff --git a/problems/market-analysis-i/README.md b/problems/market-analysis-i/README.md index 076ba31a2..16d679b4c 100644 --- a/problems/market-analysis-i/README.md +++ b/problems/market-analysis-i/README.md @@ -9,7 +9,7 @@                  [Next >](../market-analysis-ii "Market Analysis II") -## [1158. Market Analysis I (Medium)](https://leetcode.com/problems/market-analysis-i "") +## [1158. Market Analysis I (Medium)](https://leetcode.com/problems/market-analysis-i "市场分析 I")

Table: Users

diff --git a/problems/matrix-block-sum/README.md b/problems/matrix-block-sum/README.md new file mode 100644 index 000000000..177fee58e --- /dev/null +++ b/problems/matrix-block-sum/README.md @@ -0,0 +1,57 @@ + + + + + + + +[< Previous](../decompress-run-length-encoded-list "Decompress Run-Length Encoded List") +                 +[Next >](../sum-of-nodes-with-even-valued-grandparent "Sum of Nodes with Even-Valued Grandparent") + +## [1314. Matrix Block Sum (Medium)](https://leetcode.com/problems/matrix-block-sum "矩阵区域和") + +Given a m * n matrix mat and an integer K, return a matrix answer where each answer[i][j] is the sum of all elements mat[r][c] for i - K <= r <= i + K, j - K <= c <= j + K, and (r, c) is a valid position in the matrix. +

 

+

Example 1:

+ +
+Input: mat = [[1,2,3],[4,5,6],[7,8,9]], K = 1
+Output: [[12,21,16],[27,45,33],[24,39,28]]
+
+ +

Example 2:

+ +
+Input: mat = [[1,2,3],[4,5,6],[7,8,9]], K = 2
+Output: [[45,45,45],[45,45,45],[45,45,45]]
+
+ +

 

+

Constraints:

+ +
    +
  • m == mat.length
  • +
  • n == mat[i].length
  • +
  • 1 <= m, n, K <= 100
  • +
  • 1 <= mat[i][j] <= 100
  • +
+ +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
+Hint 1 +How to calculate the required sum for a cell (i,j) fast ? +
+ +
+Hint 2 +Use the concept of cumulative sum array. +
+ +
+Hint 3 +Create a cumulative sum matrix where dp[i][j] is the sum of all cells in the rectangle from (0,0) to (i,j), use inclusion-exclusion idea. +
diff --git a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md new file mode 100644 index 000000000..bd82d9adc --- /dev/null +++ b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../number-of-operations-to-make-network-connected "Number of Operations to Make Network Connected") +                 +Next > + +## [1320. Minimum Distance to Type a Word Using Two Fingers (Hard)](https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers "二指输入的的最小距离") + +

+ +

You have a keyboard layout as shown above in the XY plane, where each English uppercase letter is located at some coordinate, for example, the letter A is located at coordinate (0,0), the letter B is located at coordinate (0,1), the letter P is located at coordinate (2,3) and the letter Z is located at coordinate (4,1).

+ +

Given the string word, return the minimum total distance to type such string using only two fingers. The distance between coordinates (x1,y1) and (x2,y2) is |x1 - x2| + |y1 - y2|

+ +

Note that the initial positions of your two fingers are considered free so don't count towards your total distance, also your two fingers do not have to start at the first letter or the first two letters.

+ +

 

+

Example 1:

+ +
+Input: word = "CAKE"
+Output: 3
+Explanation: 
+Using two fingers, one optimal way to type "CAKE" is: 
+Finger 1 on letter 'C' -> cost = 0 
+Finger 1 on letter 'A' -> cost = Distance from letter 'C' to letter 'A' = 2 
+Finger 2 on letter 'K' -> cost = 0 
+Finger 2 on letter 'E' -> cost = Distance from letter 'K' to letter 'E' = 1 
+Total distance = 3
+
+ +

Example 2:

+ +
+Input: word = "HAPPY"
+Output: 6
+Explanation: 
+Using two fingers, one optimal way to type "HAPPY" is:
+Finger 1 on letter 'H' -> cost = 0
+Finger 1 on letter 'A' -> cost = Distance from letter 'H' to letter 'A' = 2
+Finger 2 on letter 'P' -> cost = 0
+Finger 2 on letter 'P' -> cost = Distance from letter 'P' to letter 'P' = 0
+Finger 1 on letter 'Y' -> cost = Distance from letter 'A' to letter 'Y' = 4
+Total distance = 6
+
+ +

Example 3:

+ +
+Input: word = "NEW"
+Output: 3
+
+ +

Example 4:

+ +
+Input: word = "YEAR"
+Output: 7
+
+ +

 

+

Constraints:

+ +
    +
  • 2 <= word.length <= 300
  • +
  • Each word[i] is an English uppercase letter.
  • +
+ +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
+Hint 1 +Use dynamic programming. +
+ +
+Hint 2 +dp[i][j][k]: smallest movements when you have one finger on i-th char and the other one on j-th char already having written k first characters from word. +
diff --git a/problems/minimum-flips-to-make-a-or-b-equal-to-c/README.md b/problems/minimum-flips-to-make-a-or-b-equal-to-c/README.md new file mode 100644 index 000000000..e9644a5ae --- /dev/null +++ b/problems/minimum-flips-to-make-a-or-b-equal-to-c/README.md @@ -0,0 +1,57 @@ + + + + + + + +[< Previous](../convert-integer-to-the-sum-of-two-no-zero-integers "Convert Integer to the Sum of Two No-Zero Integers") +                 +[Next >](../number-of-operations-to-make-network-connected "Number of Operations to Make Network Connected") + +## [1318. Minimum Flips to Make a OR b Equal to c (Medium)](https://leetcode.com/problems/minimum-flips-to-make-a-or-b-equal-to-c "或运算的最小翻转次数") + +

Given 3 positives numbers a, b and c. Return the minimum flips required in some bits of a and b to make ( a OR b == c ). (bitwise OR operation).
+Flip operation consists of change any single bit 1 to 0 or change the bit 0 to 1 in their binary representation.

+ +

 

+

Example 1:

+ +

+ +
+Input: a = 2, b = 6, c = 5
+Output: 3
+Explanation: After flips a = 1 , b = 4 , c = 5 such that (a OR b == c)
+ +

Example 2:

+ +
+Input: a = 4, b = 2, c = 7
+Output: 1
+
+ +

Example 3:

+ +
+Input: a = 1, b = 2, c = 3
+Output: 0
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= a <= 10^9
  • +
  • 1 <= b <= 10^9
  • +
  • 1 <= c <= 10^9
  • +
+ +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + +### Hints +
+Hint 1 +Check the bits one by one whether they need to be flipped. +
diff --git a/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md b/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md index 6d4b720ef..2dfd15089 100644 --- a/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md +++ b/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md @@ -7,7 +7,7 @@ [< Previous](../get-watched-videos-by-your-friends "Get Watched Videos by Your Friends")                  -Next > +[Next >](../decompress-run-length-encoded-list "Decompress Run-Length Encoded List") ## [1312. Minimum Insertion Steps to Make a String Palindrome (Hard)](https://leetcode.com/problems/minimum-insertion-steps-to-make-a-string-palindrome "让字符串成为回文串的最少插入次数") diff --git a/problems/number-of-operations-to-make-network-connected/README.md b/problems/number-of-operations-to-make-network-connected/README.md new file mode 100644 index 000000000..b7c2144ba --- /dev/null +++ b/problems/number-of-operations-to-make-network-connected/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../minimum-flips-to-make-a-or-b-equal-to-c "Minimum Flips to Make a OR b Equal to c") +                 +[Next >](../minimum-distance-to-type-a-word-using-two-fingers "Minimum Distance to Type a Word Using Two Fingers") + +## [1319. Number of Operations to Make Network Connected (Medium)](https://leetcode.com/problems/number-of-operations-to-make-network-connected "连通网络的操作次数") + +

There are n computers numbered from 0 to n-1 connected by ethernet cables connections forming a network where connections[i] = [a, b] represents a connection between computers a and b. Any computer can reach any other computer directly or indirectly through the network.

+ +

Given an initial computer network connections. You can extract certain cables between two directly connected computers, and place them between any pair of disconnected computers to make them directly connected. Return the minimum number of times you need to do this in order to make all the computers connected. If it's not possible, return -1. 

+ +

 

+

Example 1:

+ +

+ +
+Input: n = 4, connections = [[0,1],[0,2],[1,2]]
+Output: 1
+Explanation: Remove cable between computer 1 and 2 and place between computers 1 and 3.
+
+ +

Example 2:

+ +

+ +
+Input: n = 6, connections = [[0,1],[0,2],[0,3],[1,2],[1,3]]
+Output: 2
+
+ +

Example 3:

+ +
+Input: n = 6, connections = [[0,1],[0,2],[0,3],[1,2]]
+Output: -1
+Explanation: There are not enough cables.
+
+ +

Example 4:

+ +
+Input: n = 5, connections = [[0,1],[0,2],[3,4],[2,3]]
+Output: 0
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= n <= 10^5
  • +
  • 1 <= connections.length <= min(n*(n-1)/2, 10^5)
  • +
  • connections[i].length == 2
  • +
  • 0 <= connections[i][0], connections[i][1] < n
  • +
  • connections[i][0] != connections[i][1]
  • +
  • There are no repeated connections.
  • +
  • No two computers are connected by more than one cable.
  • +
+ +### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + +### Hints +
+Hint 1 +As long as there are at least (n - 1) connections, there is definitely a way to connect all computers. +
+ +
+Hint 2 +Use DFS to determine the number of isolated computer clusters. +
diff --git a/problems/page-recommendations/README.md b/problems/page-recommendations/README.md index e7a369734..e90b60e6c 100644 --- a/problems/page-recommendations/README.md +++ b/problems/page-recommendations/README.md @@ -9,7 +9,7 @@                  [Next >](../print-immutable-linked-list-in-reverse "Print Immutable Linked List in Reverse") -## [1264. Page Recommendations (Medium)](https://leetcode.com/problems/page-recommendations "") +## [1264. Page Recommendations (Medium)](https://leetcode.com/problems/page-recommendations "页面推荐")

Table: Friendship

diff --git a/problems/product-price-at-a-given-date/README.md b/problems/product-price-at-a-given-date/README.md
index e03c4c84c..f1a5121e4 100644
--- a/problems/product-price-at-a-given-date/README.md
+++ b/problems/product-price-at-a-given-date/README.md
@@ -9,7 +9,7 @@
                 
 [Next >](../single-row-keyboard "Single-Row Keyboard")
 
-## [1164. Product Price at a Given Date (Medium)](https://leetcode.com/problems/product-price-at-a-given-date "")
+## [1164. Product Price at a Given Date (Medium)](https://leetcode.com/problems/product-price-at-a-given-date "指定日期的产品价格")
 
 

Table: Products

diff --git a/problems/shift-2d-grid/README.md b/problems/shift-2d-grid/README.md index e211a7e43..5d3f2674d 100644 --- a/problems/shift-2d-grid/README.md +++ b/problems/shift-2d-grid/README.md @@ -16,9 +16,9 @@

In one shift operation:

    -
  • Element at grid[i][j] becomes at grid[i][j + 1].
  • -
  • Element at grid[i][n - 1] becomes at grid[i + 1][0].
  • -
  • Element at grid[n - 1][n - 1] becomes at grid[0][0].
  • +
  • Element at grid[i][j] moves to grid[i][j + 1].
  • +
  • Element at grid[i][n - 1] moves to grid[i + 1][0].
  • +
  • Element at grid[m - 1][n - 1] moves to grid[0][0].

Return the 2D grid after applying shift operation k times.

diff --git a/problems/similar-string-groups/README.md b/problems/similar-string-groups/README.md index 2823d4505..1f01cae1a 100644 --- a/problems/similar-string-groups/README.md +++ b/problems/similar-string-groups/README.md @@ -11,7 +11,7 @@ ## [839. Similar String Groups (Hard)](https://leetcode.com/problems/similar-string-groups "相似字符串组") -

Two strings X and Y are similar if we can swap two letters (in different positions) of X, so that it equals Y.

+

Two strings X and Y are similar if we can swap two letters (in different positions) of X, so that it equals Y. Also two strings X and Y are similar if they are equal.

For example, "tars" and "rats" are similar (swapping at positions 0 and 2), and "rats" and "arts" are similar, but "star" is not similar to "tars", "rats", or "arts".

diff --git a/problems/sum-of-nodes-with-even-valued-grandparent/README.md b/problems/sum-of-nodes-with-even-valued-grandparent/README.md new file mode 100644 index 000000000..758aa7a6b --- /dev/null +++ b/problems/sum-of-nodes-with-even-valued-grandparent/README.md @@ -0,0 +1,50 @@ + + + + + + + +[< Previous](../matrix-block-sum "Matrix Block Sum") +                 +[Next >](../distinct-echo-substrings "Distinct Echo Substrings") + +## [1315. Sum of Nodes with Even-Valued Grandparent (Medium)](https://leetcode.com/problems/sum-of-nodes-with-even-valued-grandparent "祖父节点值为偶数的节点和") + +

Given a binary tree, return the sum of values of nodes with even-valued grandparent.  (A grandparent of a node is the parent of its parent, if it exists.)

+ +

If there are no nodes with an even-valued grandparent, return 0.

+ +

 

+

Example 1:

+ +

+ +
+Input: root = [6,7,8,2,7,1,3,9,null,1,4,null,null,null,5]
+Output: 18
+Explanation: The red nodes are the nodes with even-value grandparent while the blue nodes are the even-value grandparents.
+
+ +

 

+

Constraints:

+ +
    +
  • The number of nodes in the tree is between 1 and 10^4.
  • +
  • The value of nodes is between 1 and 100.
  • +
+ +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + +### Hints +
+Hint 1 +Traverse the tree keeping the parent and the grandparent. +
+ +
+Hint 2 +If the grandparent of the current node is even-valued, add the value of this node to the answer. +
diff --git a/problems/team-scores-in-football-tournament/README.md b/problems/team-scores-in-football-tournament/README.md index b2540c4ef..003c3bc81 100644 --- a/problems/team-scores-in-football-tournament/README.md +++ b/problems/team-scores-in-football-tournament/README.md @@ -9,7 +9,7 @@                  [Next >](../intersection-of-three-sorted-arrays "Intersection of Three Sorted Arrays") -## [1212. Team Scores in Football Tournament (Medium)](https://leetcode.com/problems/team-scores-in-football-tournament "") +## [1212. Team Scores in Football Tournament (Medium)](https://leetcode.com/problems/team-scores-in-football-tournament "查询球队积分")

Table: Teams

diff --git a/problems/traffic-light-controlled-intersection/README.md b/problems/traffic-light-controlled-intersection/README.md index 66e92e498..e27e50ea7 100644 --- a/problems/traffic-light-controlled-intersection/README.md +++ b/problems/traffic-light-controlled-intersection/README.md @@ -9,7 +9,7 @@                  [Next >](../students-and-examinations "Students and Examinations") -## [1279. Traffic Light Controlled Intersection (Easy)](https://leetcode.com/problems/traffic-light-controlled-intersection "") +## [1279. Traffic Light Controlled Intersection (Easy)](https://leetcode.com/problems/traffic-light-controlled-intersection "红绿灯路口") There is an intersection of two roads. First road is road A where cars travel from North to South in direction 1 and from South to North in direction 2. Second road is road B where cars travel from West to East in direction 3 and from East to West in direction 4. diff --git a/problems/user-purchase-platform/README.md b/problems/user-purchase-platform/README.md index 181aefec5..74e191305 100644 --- a/problems/user-purchase-platform/README.md +++ b/problems/user-purchase-platform/README.md @@ -9,7 +9,7 @@                  [Next >](../number-of-equivalent-domino-pairs "Number of Equivalent Domino Pairs") -## [1127. User Purchase Platform (Hard)](https://leetcode.com/problems/user-purchase-platform "") +## [1127. User Purchase Platform (Hard)](https://leetcode.com/problems/user-purchase-platform "用户购买平台")

Table: Spending

diff --git a/tag/README.md b/tag/README.md index f30727ce6..02b484368 100644 --- a/tag/README.md +++ b/tag/README.md @@ -27,5 +27,5 @@ | 31 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 32 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | | 33 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 34 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | | 35 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | -| 37 | [Reservoir Sampling](reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | | 38 | [Memoization](memoization/README.md) | [记忆化](https://openset.github.io/tags/memoization/) | -| 39 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | | 40 | [Suffix Array](suffix-array/README.md) | [Suffix Array](https://openset.github.io/tags/suffix-array/) | +| 37 | [Reservoir Sampling](reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | | 38 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | +| 39 | [Memoization](memoization/README.md) | [记忆化](https://openset.github.io/tags/memoization/) | | 40 | [Suffix Array](suffix-array/README.md) | [Suffix Array](https://openset.github.io/tags/suffix-array/) | diff --git a/tag/array/README.md b/tag/array/README.md index 8ad504fec..5e864adc6 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1313 | [解压缩编码列表](../../problems/decompress-run-length-encoded-list) | [[数组](../array/README.md)] | Easy | | 1304 | [和为零的N个唯一整数](../../problems/find-n-unique-integers-sum-up-to-zero) | [[数组](../array/README.md)] | Easy | | 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1299 | [将每个元素替换为右侧最大元素](../../problems/replace-elements-with-greatest-element-on-right-side) | [[数组](../array/README.md)] | Easy | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 637201e0d..560688625 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1318 | [或运算的最小翻转次数](../../problems/minimum-flips-to-make-a-or-b-equal-to-c) | [[位运算](../bit-manipulation/README.md)] | Medium | | 1310 | [子数组异或查询](../../problems/xor-queries-of-a-subarray) | [[位运算](../bit-manipulation/README.md)] | Medium | | 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)] | Easy | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index aaef8bbae..cfd690bd3 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1298 | [你能从盒子里获得的最大糖果数](../../problems/maximum-candies-you-can-get-from-boxes) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index a9a13bd81..ccbe74420 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 1315 | [祖父节点值为偶数的节点和](../../problems/sum-of-nodes-with-even-valued-grandparent) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1273 | [删除树节点](../../problems/delete-tree-nodes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1254 | [统计封闭岛屿的数目](../../problems/number-of-closed-islands) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 28ab71a2c..84453c782 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1320 | [二指输入的的最小距离](../../problems/minimum-distance-to-type-a-word-using-two-fingers) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1314 | [矩阵区域和](../../problems/matrix-block-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1312 | [让字符串成为回文串的最少插入次数](../../problems/minimum-insertion-steps-to-make-a-string-palindrome) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1301 | [最大得分的路径数目](../../problems/number-of-paths-with-max-score) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1289 | [下降路径最小和 II](../../problems/minimum-falling-path-sum-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/math/README.md b/tag/math/README.md index b35d02202..7cc0c2a34 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1317 | [将整数转换为两个无零整数的和](../../problems/convert-integer-to-the-sum-of-two-no-zero-integers) | [[数学](../math/README.md)] | Easy | | 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1281 | [整数的各位积和之差](../../problems/subtract-the-product-and-sum-of-digits-of-an-integer) | [[数学](../math/README.md)] | Easy | | 1276 | [不浪费原料的汉堡制作方案](../../problems/number-of-burgers-with-no-waste-of-ingredients) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index 976e47a4c..fb2e0f732 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1316 | [不同的循环子字符串](../../problems/distinct-echo-substrings) | [[字符串](../string/README.md)] | Hard | | 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1309 | [解码字母到整数映射](../../problems/decrypt-string-from-alphabet-to-integer-mapping) | [[字符串](../string/README.md)] | Easy | | 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/tags.json b/tag/tags.json index 57ef282a7..07bcfd4a6 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -184,16 +184,16 @@ "Slug": "reservoir-sampling", "TranslatedName": "蓄水池抽样" }, - { - "Name": "Memoization", - "Slug": "memoization", - "TranslatedName": "记忆化" - }, { "Name": "Rolling Hash", "Slug": "rolling-hash", "TranslatedName": "Rolling Hash" }, + { + "Name": "Memoization", + "Slug": "memoization", + "TranslatedName": "记忆化" + }, { "Name": "Suffix Array", "Slug": "suffix-array", diff --git a/tag/tree/README.md b/tag/tree/README.md index 85e15669c..8a85b87d4 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1315 | [祖父节点值为偶数的节点和](../../problems/sum-of-nodes-with-even-valued-grandparent) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[排序](../sort/README.md)] [[树](../tree/README.md)] | Medium | | 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index 71691b39d..638ca37b7 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | | 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 1135 | [最低成本联通所有城市](../../problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | From ad4abce9f66ff86383a3f71b12b261f6b90e1e53 Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 15 Jan 2020 16:34:16 +0800 Subject: [PATCH 026/145] Add: Minimum Depth of Binary Tree --- problems/3sum/README.md | 16 +++++++++ problems/bulb-switcher/README.md | 2 +- problems/container-with-most-water/README.md | 23 +++++++++++++ problems/count-and-say/README.md | 7 ++-- .../README.md | 4 +-- problems/create-maximum-number/README.md | 2 +- problems/generalized-abbreviation/README.md | 2 +- problems/length-of-last-word/README.md | 4 +-- problems/merge-sorted-array/README.md | 7 +++- .../minimum_depth_of_binary_tree.go | 28 +++++++++++++++ .../minimum_depth_of_binary_tree_test.go | 34 +++++++++++++++++++ .../README.md | 19 +++++++++++ problems/remove-element/README.md | 7 ++-- .../README.md | 4 ++- 14 files changed, 145 insertions(+), 14 deletions(-) diff --git a/problems/3sum/README.md b/problems/3sum/README.md index 3bdb80943..f9061e54a 100644 --- a/problems/3sum/README.md +++ b/problems/3sum/README.md @@ -38,3 +38,19 @@ A solution set is: 1. [3Sum Closest](../3sum-closest) (Medium) 1. [4Sum](../4sum) (Medium) 1. [3Sum Smaller](../3sum-smaller) (Medium) + +### Hints +
+Hint 1 +So, we essentially need to find three numbers x, y, and z such that they add up to the given value. If we fix one of the numbers say x, we are left with the two-sum problem at hand! +
+ +
+Hint 2 +For the two-sum problem, if we fix one of the numbers, say
x
, we have to scan the entire array to find the next number
y
which is
value - x
where value is the input parameter. Can we change our array somehow so that this search becomes faster? +
+ +
+Hint 3 +The second train of thought for two-sum is, without changing the array, can we use additional space somehow? Like maybe a hash map to speed up the search? +
diff --git a/problems/bulb-switcher/README.md b/problems/bulb-switcher/README.md index b8cdb6bab..51dd1e362 100644 --- a/problems/bulb-switcher/README.md +++ b/problems/bulb-switcher/README.md @@ -28,8 +28,8 @@ So you should return 1, because there is only one bulb is on.
### Related Topics - [[Brainteaser](../../tag/brainteaser/README.md)] [[Math](../../tag/math/README.md)] + [[Brainteaser](../../tag/brainteaser/README.md)] ### Similar Questions 1. [Bulb Switcher II](../bulb-switcher-ii) (Medium) diff --git a/problems/container-with-most-water/README.md b/problems/container-with-most-water/README.md index c56097f9e..6a5accfe4 100644 --- a/problems/container-with-most-water/README.md +++ b/problems/container-with-most-water/README.md @@ -35,3 +35,26 @@ ### Similar Questions 1. [Trapping Rain Water](../trapping-rain-water) (Hard) + +### Hints +
+Hint 1 +The aim is to maximize the area formed between the vertical lines. The area of any container is calculated using the shorter line as length and the distance between the lines as the width of the rectangle. + +
+Area = length of shorter vertical line * distance between lines
+
+ +We can definitely get the maximum width container as the outermost lines have the maximum distance between them. However, this container might not be the maximum in size as one of the vertical lines of this container could be really short. + +
+ + +
+ +
+ +
+Hint 2 +Start with the maximum width container and go to a shorter width container if there is a vertical line longer than the current containers shorter line. This way we are compromising on the width but we are looking forward to a longer length container. +
diff --git a/problems/count-and-say/README.md b/problems/count-and-say/README.md index 9d287b488..ff64e1143 100644 --- a/problems/count-and-say/README.md +++ b/problems/count-and-say/README.md @@ -25,7 +25,7 @@ 11 is read off as "two 1s" or 21.
21 is read off as "one 2, then one 1" or 1211.

-

Given an integer n where 1 ≤ n ≤ 30, generate the nth term of the count-and-say sequence.

+

Given an integer n where 1 ≤ n ≤ 30, generate the nth term of the count-and-say sequence. You can do so recursively, in other words from the previous member read off the digits, counting the number of digits in groups of the same digit.

Note: Each term of the sequence of integers will be represented as a string.

@@ -36,13 +36,16 @@
 Input: 1
 Output: "1"
+Explanation: This is the base case.
 

Example 2:

 Input: 4
-Output: "1211"
+Output: "1211" +Explanation: For n = 3 the term was "21" in which we have two groups "2" and "1", "2" can be read as "12" which means frequency = 1 and value = 2, the same way "1" is read as "11", so the answer is the concatenation of "12" and "11" which is "1211". +
### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/count-of-smaller-numbers-after-self/README.md b/problems/count-of-smaller-numbers-after-self/README.md index ceae78a02..a298f932d 100644 --- a/problems/count-of-smaller-numbers-after-self/README.md +++ b/problems/count-of-smaller-numbers-after-self/README.md @@ -26,11 +26,11 @@ To the right of 1 there is 0 smaller element.
### Related Topics + [[Binary Search](../../tag/binary-search/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Sort](../../tag/sort/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] - [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions 1. [Count of Range Sum](../count-of-range-sum) (Hard) diff --git a/problems/create-maximum-number/README.md b/problems/create-maximum-number/README.md index 56b92324f..44e118849 100644 --- a/problems/create-maximum-number/README.md +++ b/problems/create-maximum-number/README.md @@ -47,8 +47,8 @@ k = 3
### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions 1. [Remove K Digits](../remove-k-digits) (Medium) diff --git a/problems/generalized-abbreviation/README.md b/problems/generalized-abbreviation/README.md index 2756ddefe..be8286812 100644 --- a/problems/generalized-abbreviation/README.md +++ b/problems/generalized-abbreviation/README.md @@ -26,8 +26,8 @@

 

### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Subsets](../subsets) (Medium) diff --git a/problems/length-of-last-word/README.md b/problems/length-of-last-word/README.md index 3273ade81..3ac31cbac 100644 --- a/problems/length-of-last-word/README.md +++ b/problems/length-of-last-word/README.md @@ -11,11 +11,11 @@ ## [58. Length of Last Word (Easy)](https://leetcode.com/problems/length-of-last-word "最后一个单词的长度") -

Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.

+

Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word (last word means the last appearing word if we loop from left to right) in the string.

If the last word does not exist, return 0.

-

Note: A word is defined as a character sequence consists of non-space characters only.

+

Note: A word is defined as a maximal substring consisting of non-space characters only.

Example:

diff --git a/problems/merge-sorted-array/README.md b/problems/merge-sorted-array/README.md index 9624f6514..3acd0e9bf 100644 --- a/problems/merge-sorted-array/README.md +++ b/problems/merge-sorted-array/README.md @@ -42,5 +42,10 @@ nums2 = [2,5,6], n = 3 ### Hints
Hint 1 -What if you fill the longer array from the end instead of start ? +You can easily solve this problem if you simply think about two elements at a time rather than two arrays. We know that each of the individual arrays is sorted. What we don't know is how they will intertwine. Can we take a local decision and arrive at an optimal solution? +
+ +
+Hint 2 +If you simply consider one element each at a time from the two arrays and make a decision and proceed accordingly, you will arrive at the optimal solution.
diff --git a/problems/minimum-depth-of-binary-tree/minimum_depth_of_binary_tree.go b/problems/minimum-depth-of-binary-tree/minimum_depth_of_binary_tree.go index 1afb002f3..cb1c6f5f7 100644 --- a/problems/minimum-depth-of-binary-tree/minimum_depth_of_binary_tree.go +++ b/problems/minimum-depth-of-binary-tree/minimum_depth_of_binary_tree.go @@ -1 +1,29 @@ package problem111 + +import "github.com/openset/leetcode/internal/kit" + +// TreeNode - Definition for a binary tree node. +type TreeNode = kit.TreeNode + +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func minDepth(root *TreeNode) int { + if root == nil { + return 0 + } + l := minDepth(root.Left) + r := minDepth(root.Right) + if l == 0 || r == 0 { + return l + r + 1 + } + if l < r { + return l + 1 + } + return r + 1 +} diff --git a/problems/minimum-depth-of-binary-tree/minimum_depth_of_binary_tree_test.go b/problems/minimum-depth-of-binary-tree/minimum_depth_of_binary_tree_test.go index 1afb002f3..87367c423 100644 --- a/problems/minimum-depth-of-binary-tree/minimum_depth_of_binary_tree_test.go +++ b/problems/minimum-depth-of-binary-tree/minimum_depth_of_binary_tree_test.go @@ -1 +1,35 @@ package problem111 + +import ( + "testing" + + "github.com/openset/leetcode/internal/kit" +) + +type testType struct { + in []int + want int +} + +func TestMinDepth(t *testing.T) { + tests := [...]testType{ + { + in: []int{3, 9, 20, kit.NULL, kit.NULL, 15, 7}, + want: 2, + }, + { + in: []int{1, 2}, + want: 2, + }, + { + in: nil, + want: 0, + }, + } + for _, tt := range tests { + got := minDepth(kit.SliceInt2TreeNode(tt.in)) + if got != tt.want { + t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want) + } + } +} diff --git a/problems/remove-duplicates-from-sorted-array/README.md b/problems/remove-duplicates-from-sorted-array/README.md index 0dbb6aa76..24e64268b 100644 --- a/problems/remove-duplicates-from-sorted-array/README.md +++ b/problems/remove-duplicates-from-sorted-array/README.md @@ -59,3 +59,22 @@ for (int i = 0; i < len; i++) { ### Similar Questions 1. [Remove Element](../remove-element) (Easy) 1. [Remove Duplicates from Sorted Array II](../remove-duplicates-from-sorted-array-ii) (Medium) + +### Hints +
+Hint 1 +In this problem, the key point to focus on is the input array being sorted. As far as duplicate elements are concerned, what is their positioning in the array when the given array is sorted? Look at the image above for the answer. If we know the position of one of the elements, do we also know the positioning of all the duplicate elements? + +
+ +
+ +
+Hint 2 +We need to modify the array in-place and the size of the final array would potentially be smaller than the size of the input array. So, we ought to use a two-pointer approach here. One, that would keep track of the current element in the original array and another one for just the unique elements. +
+ +
+Hint 3 +Essentially, once an element is encountered, you simply need to bypass its duplicates and move on to the next unique element. +
diff --git a/problems/remove-element/README.md b/problems/remove-element/README.md index b82b30128..3efd8e8fc 100644 --- a/problems/remove-element/README.md +++ b/problems/remove-element/README.md @@ -68,15 +68,16 @@ for (int i = 0; i < len; i++) { ### Hints
Hint 1 -Try two pointers. +The problem statement clearly asks us to modify the array in-place and it also says that the element beyond the new length of the array can be anything. Given an element, we need to remove all the occurrences of it from the array. We don't technically need to remove that element per-say, right?
Hint 2 -Did you use the property of "the order of elements can be changed"? +We can move all the occurrences of this element to the end of the array. Use two pointers! +
Hint 3 -What happens when the elements to remove are rare? +Yet another direction of thought is to consider the elements to be removed as non-existent. In a single pass, if we keep copying the visible elements in-place, that should also solve this problem for us.
diff --git a/problems/substring-with-concatenation-of-all-words/README.md b/problems/substring-with-concatenation-of-all-words/README.md index 960c8ec8c..717be3254 100644 --- a/problems/substring-with-concatenation-of-all-words/README.md +++ b/problems/substring-with-concatenation-of-all-words/README.md @@ -13,6 +13,8 @@

You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any intervening characters.

+

 

+

Example 1:

@@ -20,7 +22,7 @@
   s = "barfoothefoobarman",
   words = ["foo","bar"]
 Output: [0,9]
-Explanation: Substrings starting at index 0 and 9 are "barfoor" and "foobar" respectively.
+Explanation: Substrings starting at index 0 and 9 are "barfoo" and "foobar" respectively.
 The output order does not matter, returning [9,0] is fine too.
 
From 95129aaad345ac4322e9c67121ff46b544796a36 Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 16 Jan 2020 10:45:29 +0800 Subject: [PATCH 027/145] Add: Remove Nth Node From End of List --- .../remove_nth_node_from_end_of_list.go | 27 +++++++++++++ .../remove_nth_node_from_end_of_list_test.go | 39 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list.go b/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list.go index 30d5ec65d..c23d7d1c0 100644 --- a/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list.go +++ b/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list.go @@ -1 +1,28 @@ package problem19 + +import "github.com/openset/leetcode/internal/kit" + +// ListNode - Definition for singly-linked list. +type ListNode = kit.ListNode + +/** + * Definition for singly-linked list. + * type ListNode struct { + * Val int + * Next *ListNode + * } + */ +func removeNthFromEnd(head *ListNode, n int) *ListNode { + q := []*ListNode{head} + for head.Next != nil { + q = append(q, head.Next) + head = head.Next + } + i := len(q) - n + if i > 0 { + q[i-1].Next = q[i].Next + } else { + q[0] = q[i].Next + } + return q[0] +} diff --git a/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list_test.go b/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list_test.go index 30d5ec65d..3407d4d1a 100644 --- a/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list_test.go +++ b/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list_test.go @@ -1 +1,40 @@ package problem19 + +import ( + "reflect" + "testing" + + "github.com/openset/leetcode/internal/kit" +) + +type testType struct { + in []int + n int + want []int +} + +func TestRemoveNthFromEnd(t *testing.T) { + tests := [...]testType{ + { + in: []int{1, 2, 3, 4, 5}, + n: 2, + want: []int{1, 2, 3, 5}, + }, + { + in: []int{1, 2, 3, 4, 5}, + n: 5, + want: []int{2, 3, 4, 5}, + }, + { + in: []int{1, 2, 3, 4, 5}, + n: 1, + want: []int{1, 2, 3, 4}, + }, + } + for _, tt := range tests { + got := removeNthFromEnd(kit.SliceInt2ListNode(tt.in), tt.n) + if !reflect.DeepEqual(kit.ListNode2SliceInt(got), tt.want) { + t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want) + } + } +} From 207daaa987386a034ed96be3744c3629698c1a5f Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 16 Jan 2020 12:03:55 +0800 Subject: [PATCH 028/145] Add: Remove Nth Node From End of List --- .../remove_nth_node_from_end_of_list.go | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list.go b/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list.go index c23d7d1c0..360761d09 100644 --- a/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list.go +++ b/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list.go @@ -13,16 +13,16 @@ type ListNode = kit.ListNode * } */ func removeNthFromEnd(head *ListNode, n int) *ListNode { - q := []*ListNode{head} - for head.Next != nil { - q = append(q, head.Next) + ans := &ListNode{Next: head} + pos := ans + for head != nil { head = head.Next + if n > 0 { + n-- + } else { + pos = pos.Next + } } - i := len(q) - n - if i > 0 { - q[i-1].Next = q[i].Next - } else { - q[0] = q[i].Next - } - return q[0] + pos.Next = pos.Next.Next + return ans.Next } From a37d8c8035df2d662cf646508cae3bd3f85319d8 Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 16 Jan 2020 12:07:13 +0800 Subject: [PATCH 029/145] Add: 19 --- internal/leetcode/problems_status.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/leetcode/problems_status.go b/internal/leetcode/problems_status.go index 22f685cd6..bd5148f6e 100644 --- a/internal/leetcode/problems_status.go +++ b/internal/leetcode/problems_status.go @@ -19,6 +19,7 @@ var problemStatus = map[int]bool{ 16: true, 17: true, 18: true, + 19: true, 20: true, 21: true, 22: true, From 549e00856b33c72695e556d1d7d02116446febe5 Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 16 Jan 2020 12:26:30 +0800 Subject: [PATCH 030/145] Add: new --- README.md | 5 +- problems/article-views-ii/README.md | 2 +- problems/bulb-switcher/README.md | 2 +- problems/clone-graph/README.md | 78 ++++++++++++++----- .../README.md | 4 +- problems/create-maximum-number/README.md | 2 +- .../README.md | 8 +- problems/distinct-echo-substrings/README.md | 2 +- problems/find-the-team-size/README.md | 43 ++++++++++ problems/generalized-abbreviation/README.md | 2 +- problems/height-checker/README.md | 19 ++--- .../README.md | 2 +- problems/reported-posts-ii/README.md | 2 +- problems/restaurant-growth/README.md | 72 +++++++++++++++++ problems/restaurant-growth/mysql_schemas.sql | 13 ++++ .../README.md | 62 ++++++++++++++- 16 files changed, 272 insertions(+), 46 deletions(-) create mode 100644 problems/restaurant-growth/README.md create mode 100644 problems/restaurant-growth/mysql_schemas.sql diff --git a/README.md b/README.md index ef96d64d4..9b15a1ee4 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1321 | [Restaurant Growth](https://leetcode.com/problems/restaurant-growth) 🔒 | [MySQL](problems/restaurant-growth) | Medium | | 1320 | [Minimum Distance to Type a Word Using Two Fingers](https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers "二指输入的的最小距离") | [Go](problems/minimum-distance-to-type-a-word-using-two-fingers) | Hard | | 1319 | [Number of Operations to Make Network Connected](https://leetcode.com/problems/number-of-operations-to-make-network-connected "连通网络的操作次数") | [Go](problems/number-of-operations-to-make-network-connected) | Medium | | 1318 | [Minimum Flips to Make a OR b Equal to c](https://leetcode.com/problems/minimum-flips-to-make-a-or-b-equal-to-c "或运算的最小翻转次数") | [Go](problems/minimum-flips-to-make-a-or-b-equal-to-c) | Medium | @@ -233,7 +234,7 @@ LeetCode Problems' Solutions | 1152 | [Analyze User Website Visit Pattern](https://leetcode.com/problems/analyze-user-website-visit-pattern "用户网站访问行为分析") 🔒 | [Go](problems/analyze-user-website-visit-pattern) | Medium | | 1151 | [Minimum Swaps to Group All 1's Together](https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together "最少交换次数来组合所有的 1") 🔒 | [Go](problems/minimum-swaps-to-group-all-1s-together) | Medium | | 1150 | [Check If a Number Is Majority Element in a Sorted Array](https://leetcode.com/problems/check-if-a-number-is-majority-element-in-a-sorted-array "检查一个数是否在数组中占绝大多数") 🔒 | [Go](problems/check-if-a-number-is-majority-element-in-a-sorted-array) | Easy | -| 1149 | [Article Views II](https://leetcode.com/problems/article-views-ii) 🔒 | [MySQL](problems/article-views-ii) | Medium | +| 1149 | [Article Views II](https://leetcode.com/problems/article-views-ii "文章浏览 II") 🔒 | [MySQL](problems/article-views-ii) | Medium | | 1148 | [Article Views I](https://leetcode.com/problems/article-views-i "文章浏览 I") 🔒 | [MySQL](problems/article-views-i) | Easy | | 1147 | [Longest Chunked Palindrome Decomposition](https://leetcode.com/problems/longest-chunked-palindrome-decomposition "段式回文") | [Go](problems/longest-chunked-palindrome-decomposition) | Hard | | 1146 | [Snapshot Array](https://leetcode.com/problems/snapshot-array "快照数组") | [Go](problems/snapshot-array) | Medium | @@ -250,7 +251,7 @@ LeetCode Problems' Solutions | 1135 | [Connecting Cities With Minimum Cost](https://leetcode.com/problems/connecting-cities-with-minimum-cost "最低成本联通所有城市") 🔒 | [Go](problems/connecting-cities-with-minimum-cost) | Medium | | 1134 | [Armstrong Number](https://leetcode.com/problems/armstrong-number "阿姆斯特朗数") 🔒 | [Go](problems/armstrong-number) | Easy | | 1133 | [Largest Unique Number](https://leetcode.com/problems/largest-unique-number "最大唯一数") 🔒 | [Go](problems/largest-unique-number) | Easy | -| 1132 | [Reported Posts II](https://leetcode.com/problems/reported-posts-ii) 🔒 | [MySQL](problems/reported-posts-ii) | Medium | +| 1132 | [Reported Posts II](https://leetcode.com/problems/reported-posts-ii "报告的记录 II") 🔒 | [MySQL](problems/reported-posts-ii) | Medium | | 1131 | [Maximum of Absolute Value Expression](https://leetcode.com/problems/maximum-of-absolute-value-expression "绝对值表达式的最大值") | [Go](problems/maximum-of-absolute-value-expression) | Medium | | 1130 | [Minimum Cost Tree From Leaf Values](https://leetcode.com/problems/minimum-cost-tree-from-leaf-values "叶值的最小代价生成树") | [Go](problems/minimum-cost-tree-from-leaf-values) | Medium | | 1129 | [Shortest Path with Alternating Colors](https://leetcode.com/problems/shortest-path-with-alternating-colors "颜色交替的最短路径") | [Go](problems/shortest-path-with-alternating-colors) | Medium | diff --git a/problems/article-views-ii/README.md b/problems/article-views-ii/README.md index f2d98b111..d10a5bd6f 100644 --- a/problems/article-views-ii/README.md +++ b/problems/article-views-ii/README.md @@ -9,7 +9,7 @@                  [Next >](../check-if-a-number-is-majority-element-in-a-sorted-array "Check If a Number Is Majority Element in a Sorted Array") -## [1149. Article Views II (Medium)](https://leetcode.com/problems/article-views-ii "") +## [1149. Article Views II (Medium)](https://leetcode.com/problems/article-views-ii "文章浏览 II")

Table: Views

diff --git a/problems/bulb-switcher/README.md b/problems/bulb-switcher/README.md index 51dd1e362..b8cdb6bab 100644 --- a/problems/bulb-switcher/README.md +++ b/problems/bulb-switcher/README.md @@ -28,8 +28,8 @@ So you should return 1, because there is only one bulb is on. ### Related Topics - [[Math](../../tag/math/README.md)] [[Brainteaser](../../tag/brainteaser/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Bulb Switcher II](../bulb-switcher-ii) (Medium) diff --git a/problems/clone-graph/README.md b/problems/clone-graph/README.md index 83ddbe13a..e80992258 100644 --- a/problems/clone-graph/README.md +++ b/problems/clone-graph/README.md @@ -11,35 +11,75 @@ ## [133. Clone Graph (Medium)](https://leetcode.com/problems/clone-graph "克隆图") -

Given a reference of a node in a connected undirected graph, return a deep copy (clone) of the graph. Each node in the graph contains a val (int) and a list (List[Node]) of its neighbors.

+

Given a reference of a node in a connected undirected graph.

+ +

Return a deep copy (clone) of the graph.

+ +

Each node in the graph contains a val (int) and a list (List[Node]) of its neighbors.

+ +
+class Node {
+    public int val;
+    public List<Node> neighbors;
+}
+

 

-

Example:

+

Test case format:

-

+

For simplicity sake, each node's value is the same as the node's index (1-indexed). For example, the first node with val = 1, the second node with val = 2, and so on. The graph is represented in the test case using an adjacency list.

+

Adjacency list is a collection of unordered lists used to represent a finite graph. Each list describes the set of neighbors of a node in the graph.

+ +

The given node will always be the first node with val = 1. You must return the copy of the given node as a reference to the cloned graph.

+ +

 

+

Example 1:

+
-Input:
-{"$id":"1","neighbors":[{"$id":"2","neighbors":[{"$ref":"1"},{"$id":"3","neighbors":[{"$ref":"2"},{"$id":"4","neighbors":[{"$ref":"3"},{"$ref":"1"}],"val":4}],"val":3}],"val":2},{"$ref":"4"}],"val":1}
-
-Explanation:
-Node 1's value is 1, and it has two neighbors: Node 2 and 4.
-Node 2's value is 2, and it has two neighbors: Node 1 and 3.
-Node 3's value is 3, and it has two neighbors: Node 2 and 4.
-Node 4's value is 4, and it has two neighbors: Node 1 and 3.
+Input: adjList = [[2,4],[1,3],[2,4],[1,3]]
+Output: [[2,4],[1,3],[2,4],[1,3]]
+Explanation: There are 4 nodes in the graph.
+1st node (val = 1)'s neighbors are 2nd node (val = 2) and 4th node (val = 4).
+2nd node (val = 2)'s neighbors are 1st node (val = 1) and 3rd node (val = 3).
+3rd node (val = 3)'s neighbors are 2nd node (val = 2) and 4th node (val = 4).
+4th node (val = 4)'s neighbors are 1st node (val = 1) and 3rd node (val = 3).
 
-

 

+

Example 2:

+ +
+Input: adjList = [[]]
+Output: [[]]
+Explanation: Note that the input contains one empty list. The graph consists of only one node with val = 1 and it does not have any neighbors.
+
+ +

Example 3:

+ +
+Input: adjList = []
+Output: []
+Explanation: This an empty graph, it does not have any nodes.
+
-

Note:

+

Example 4:

+ +
+Input: adjList = [[2],[1]]
+Output: [[2],[1]]
+
+ +

 

+

Constraints:

-
    -
  1. The number of nodes will be between 1 and 100.
  2. -
  3. The undirected graph is a simple graph, which means no repeated edges and no self-loops in the graph.
  4. -
  5. Since the graph is undirected, if node p has node q as neighbor, then node q must have node p as neighbor too.
  6. -
  7. You must return the copy of the given node as a reference to the cloned graph.
  8. -
+
    +
  • 1 <= Node.val <= 100
  • +
  • Node.val is unique for each node.
  • +
  • Number of Nodes will not exceed 100.
  • +
  • There is no repeated edges and no self-loops in the graph.
  • +
  • The Graph is connected and all nodes can be visited starting from the given node.
  • +
### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/count-of-smaller-numbers-after-self/README.md b/problems/count-of-smaller-numbers-after-self/README.md index a298f932d..ceae78a02 100644 --- a/problems/count-of-smaller-numbers-after-self/README.md +++ b/problems/count-of-smaller-numbers-after-self/README.md @@ -26,11 +26,11 @@ To the right of 1 there is 0 smaller element. ### Related Topics - [[Binary Search](../../tag/binary-search/README.md)] - [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Sort](../../tag/sort/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions 1. [Count of Range Sum](../count-of-range-sum) (Hard) diff --git a/problems/create-maximum-number/README.md b/problems/create-maximum-number/README.md index 44e118849..56b92324f 100644 --- a/problems/create-maximum-number/README.md +++ b/problems/create-maximum-number/README.md @@ -47,8 +47,8 @@ k = 3 ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Remove K Digits](../remove-k-digits) (Medium) diff --git a/problems/decompress-run-length-encoded-list/README.md b/problems/decompress-run-length-encoded-list/README.md index e6d524263..36b9dd8a3 100644 --- a/problems/decompress-run-length-encoded-list/README.md +++ b/problems/decompress-run-length-encoded-list/README.md @@ -19,9 +19,15 @@

 

Example 1:

-
Input: nums = [1,2,3,4]
+
+
+Input: nums = [1,2,3,4]
 Output: [2,4,4,4]
+Explanation: The first pair [1,2] means we have freq = 1 and val = 2 so we generate the array [2].
+The second pair [3,4] means we have freq = 3 and val = 4 so we generate [4,4,4].
+At the end the concatenation [2] + [4,4,4,4] is [2,4,4,4].
 
+

 

Constraints:

diff --git a/problems/distinct-echo-substrings/README.md b/problems/distinct-echo-substrings/README.md index 58a16978f..2d3d3f53a 100644 --- a/problems/distinct-echo-substrings/README.md +++ b/problems/distinct-echo-substrings/README.md @@ -11,7 +11,7 @@ ## [1316. Distinct Echo Substrings (Hard)](https://leetcode.com/problems/distinct-echo-substrings "不同的循环子字符串") -

Return the number of distinct non-empty substrings of text that can be written as the concatenation of some string with itself.

+

Return the number of distinct non-empty substrings of text that can be written as the concatenation of some string with itself (i.e. it can be written as a + a where a is some string).

 

Example 1:

diff --git a/problems/find-the-team-size/README.md b/problems/find-the-team-size/README.md index 02ee15626..8c56cf681 100644 --- a/problems/find-the-team-size/README.md +++ b/problems/find-the-team-size/README.md @@ -11,4 +11,47 @@ ## [1303. Find the Team Size (Easy)](https://leetcode.com/problems/find-the-team-size "求团队人数") +

Table: Employee

+
++---------------+---------+
+| Column Name   | Type    |
++---------------+---------+
+| employee_id   | int     |
+| team_id       | int     |
++---------------+---------+
+employee_id is the primary key for this table.
+Each row of this table contains the ID of each employee and their respective team.
+
+Write an SQL query to find the team size of each of the employees. + +Return result table in any order. + +The query result format is in the following example: +
+Employee Table:
++-------------+------------+
+| employee_id | team_id    |
++-------------+------------+
+|     1       |     8      |
+|     2       |     8      |
+|     3       |     8      |
+|     4       |     7      |
+|     5       |     9      |
+|     6       |     9      |
++-------------+------------+
+Result table:
++-------------+------------+
+| employee_id | team_size  |
++-------------+------------+
+|     1       |     3      |
+|     2       |     3      |
+|     3       |     3      |
+|     4       |     1      |
+|     5       |     2      |
+|     6       |     2      |
++-------------+------------+
+Employees with Id 1,2,3 are part of a team with team_id = 8.
+Employees with Id 4 is part of a team with team_id = 7.
+Employees with Id 5,6 are part of a team with team_id = 9.
+
diff --git a/problems/generalized-abbreviation/README.md b/problems/generalized-abbreviation/README.md index be8286812..2756ddefe 100644 --- a/problems/generalized-abbreviation/README.md +++ b/problems/generalized-abbreviation/README.md @@ -26,8 +26,8 @@

 

### Related Topics - [[Backtracking](../../tag/backtracking/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions 1. [Subsets](../subsets) (Medium) diff --git a/problems/height-checker/README.md b/problems/height-checker/README.md index e35335df7..440eb14b1 100644 --- a/problems/height-checker/README.md +++ b/problems/height-checker/README.md @@ -13,27 +13,20 @@

Students are asked to stand in non-decreasing order of heights for an annual photo.

-

Return the minimum number of students not standing in the right positions.  (This is the number of students that must move in order for all students to be standing in non-decreasing order of height.)

+

Return the minimum number of students that must move in order for all students to be standing in non-decreasing order of height.

 

-

Example 1:

- -
-Input: [1,1,4,2,1,3]
-Output: 3
-Explanation: 
-Students with heights 4, 3 and the last 1 are not standing in the right positions.
+
Input: heights = [1,1,4,2,1,3]
+Output: 3
 
-

 

+

Constraints:

-

Note:

- -
    +
    • 1 <= heights.length <= 100
    • 1 <= heights[i] <= 100
    • -
+ ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md index bd82d9adc..eb6bc852e 100644 --- a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md +++ b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md @@ -7,7 +7,7 @@ [< Previous](../number-of-operations-to-make-network-connected "Number of Operations to Make Network Connected")                  -Next > +[Next >](../restaurant-growth "Restaurant Growth") ## [1320. Minimum Distance to Type a Word Using Two Fingers (Hard)](https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers "二指输入的的最小距离") diff --git a/problems/reported-posts-ii/README.md b/problems/reported-posts-ii/README.md index 6c1b56bac..164ef4413 100644 --- a/problems/reported-posts-ii/README.md +++ b/problems/reported-posts-ii/README.md @@ -9,7 +9,7 @@                  [Next >](../largest-unique-number "Largest Unique Number") -## [1132. Reported Posts II (Medium)](https://leetcode.com/problems/reported-posts-ii "") +## [1132. Reported Posts II (Medium)](https://leetcode.com/problems/reported-posts-ii "报告的记录 II")

Table: Actions

diff --git a/problems/restaurant-growth/README.md b/problems/restaurant-growth/README.md new file mode 100644 index 000000000..a13c18fff --- /dev/null +++ b/problems/restaurant-growth/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../minimum-distance-to-type-a-word-using-two-fingers "Minimum Distance to Type a Word Using Two Fingers") +                 +Next > + +## [1321. Restaurant Growth (Medium)](https://leetcode.com/problems/restaurant-growth "") + +

Table: Customer

+
++---------------+---------+
+| Column Name   | Type    |
++---------------+---------+
+| customer_id   | int     |
+| name          | varchar |
+| visited_on    | date    |
+| amount        | int     |
++---------------+---------+
+(customer_id, visited_on) is the primary key for this table.
+This table contains data about customer transactions in a restaurant.
+visited_on is the date on which the customer with ID (customer_id) have visited the restaurant.
+amount is the total paid by a customer.
+
+ +You are the restaurant owner and you want to analyze a possible expansion (there will be at least one customer every day). + +Write an SQL query to compute moving average of how much customer paid in a 7 days window (current day + 6 days before) . + +The query result format is in the following example: + +Return result table ordered by visited_on. + +average_amount should be rounded to 2 decimal places, all dates are in the format ('YYYY-MM-DD'). + +
+Customer table:
++-------------+--------------+--------------+-------------+
+| customer_id | name         | visited_on   | amount      |
++-------------+--------------+--------------+-------------+
+| 1           | Jhon         | 2019-01-01   | 100         |
+| 2           | Daniel       | 2019-01-02   | 110         |
+| 3           | Jade         | 2019-01-03   | 120         |
+| 4           | Khaled       | 2019-01-04   | 130         |
+| 5           | Winston      | 2019-01-05   | 110         | 
+| 6           | Elvis        | 2019-01-06   | 140         | 
+| 7           | Anna         | 2019-01-07   | 150         |
+| 8           | Maria        | 2019-01-08   | 80          |
+| 9           | Jaze         | 2019-01-09   | 110         | 
+| 1           | Jhon         | 2019-01-10   | 130         | 
+| 3           | Jade         | 2019-01-10   | 150         | 
++-------------+--------------+--------------+-------------+
+
+Result table:
++--------------+--------------+----------------+
+| visited_on   | amount       | average_amount |
++--------------+--------------+----------------+
+| 2019-01-07   | 860          | 122.86         |
+| 2019-01-08   | 840          | 120            |
+| 2019-01-09   | 840          | 120            |
+| 2019-01-10   | 1000         | 142.86         |
++--------------+--------------+----------------+
+
+1st moving average from 2019-01-01 to 2019-01-07 has an average_amount of (100 + 110 + 120 + 130 + 110 + 140 + 150)/7 = 122.86
+2nd moving average from 2019-01-02 to 2019-01-08 has an average_amount of (110 + 120 + 130 + 110 + 140 + 150 + 80)/7 = 120
+3rd moving average from 2019-01-03 to 2019-01-09 has an average_amount of (120 + 130 + 110 + 140 + 150 + 80 + 110)/7 = 120
+4th moving average from 2019-01-04 to 2019-01-10 has an average_amount of (130 + 110 + 140 + 150 + 80 + 110 + 130 + 150)/7 = 142.86
+
diff --git a/problems/restaurant-growth/mysql_schemas.sql b/problems/restaurant-growth/mysql_schemas.sql new file mode 100644 index 000000000..41462f500 --- /dev/null +++ b/problems/restaurant-growth/mysql_schemas.sql @@ -0,0 +1,13 @@ +Create table If Not Exists Customer (customer_id int, name varchar(20), visited_on date, amount int); +Truncate table Customer; +insert into Customer (customer_id, name, visited_on, amount) values ('1', 'Jhon', '2019-01-01', '100'); +insert into Customer (customer_id, name, visited_on, amount) values ('2', 'Daniel', '2019-01-02', '110'); +insert into Customer (customer_id, name, visited_on, amount) values ('3', 'Jade', '2019-01-03', '120'); +insert into Customer (customer_id, name, visited_on, amount) values ('4', 'Khaled', '2019-01-04', '130'); +insert into Customer (customer_id, name, visited_on, amount) values ('5', 'Winston', '2019-01-05', '110'); +insert into Customer (customer_id, name, visited_on, amount) values ('6', 'Elvis', '2019-01-06', '140'); +insert into Customer (customer_id, name, visited_on, amount) values ('7', 'Anna', '2019-01-07', '150'); +insert into Customer (customer_id, name, visited_on, amount) values ('8', 'Maria', '2019-01-08', '80'); +insert into Customer (customer_id, name, visited_on, amount) values ('9', 'Jaze', '2019-01-09', '110'); +insert into Customer (customer_id, name, visited_on, amount) values ('1', 'Jhon', '2019-01-10', '130'); +insert into Customer (customer_id, name, visited_on, amount) values ('3', 'Jade', '2019-01-10', '150'); diff --git a/problems/running-total-for-different-genders/README.md b/problems/running-total-for-different-genders/README.md index 493be1006..3c975341e 100644 --- a/problems/running-total-for-different-genders/README.md +++ b/problems/running-total-for-different-genders/README.md @@ -11,7 +11,65 @@ ## [1308. Running Total for Different Genders (Medium)](https://leetcode.com/problems/running-total-for-different-genders "") +

Table: Scores

+
++---------------+---------+
+| Column Name   | Type    |
++---------------+---------+
+| player_name   | varchar |
+| gender        | varchar |
+| day           | date    |
+| score_points  | int     |
++---------------+---------+
+(gender, day) is the primary key for this table.
+A competition is held between females team and males team.
+Each row of this table indicates that a player_name and with gender has scored score_point in someday.
+Gender is 'F' if the player is in females team and 'M' if the player is in males team.
+ 
+Write an SQL query to find the total score for each gender at each day. -### Similar Questions - 1. [Last Person to Fit in the Elevator](../last-person-to-fit-in-the-elevator) (Medium) +Order the result table by gender and day + +The query result format is in the following example: +
+Scores table:
++-------------+--------+------------+--------------+
+| player_name | gender | day        | score_points |
++-------------+--------+------------+--------------+
+| Aron        | F      | 2020-01-01 | 17           |
+| Alice       | F      | 2020-01-07 | 23           |
+| Bajrang     | M      | 2020-01-07 | 7            |
+| Khali       | M      | 2019-12-25 | 11           |
+| Slaman      | M      | 2019-12-30 | 13           |
+| Joe         | M      | 2019-12-31 | 3            |
+| Jose        | M      | 2019-12-18 | 2            |
+| Priya       | F      | 2019-12-31 | 23           |
+| Priyanka    | F      | 2019-12-30 | 17           |
++-------------+--------+------------+--------------+
+Result table:
++--------+------------+-------+
+| gender | day        | total |
++--------+------------+-------+
+| F      | 2019-12-30 | 17    |
+| F      | 2019-12-31 | 40    |
+| F      | 2020-01-01 | 57    |
+| F      | 2020-01-07 | 80    |
+| M      | 2019-12-18 | 2     |
+| M      | 2019-12-25 | 13    |
+| M      | 2019-12-30 | 26    |
+| M      | 2019-12-31 | 29    |
+| M      | 2020-01-07 | 36    |
++--------+------------+-------+
+For females team:
+First day is 2019-12-30, Priyanka scored 17 points and the total score for the team is 17.
+Second day is 2019-12-31, Priya scored 23 points and the total score for the team is 40.
+Third day is 2020-01-01, Aron scored 17 points and the total score for the team is 57.
+Fourth day is 2020-01-07, Alice scored 23 points and the total score for the team is 80.
+For males team:
+First day is 2019-12-18, Jose scored 2 points and the total score for the team is 2.
+Second day is 2019-12-25, Khali scored 11 points and the total score for the team is 13.
+Third day is 2019-12-30, Slaman scored 13 points and the total score for the team is 26.
+Fourth day is 2019-12-31, Joe scored 3 points and the total score for the team is 29.
+Fifth day is 2020-01-07, Bajrang scored 7 points and the total score for the team is 36.
+
From a69f341ffc71d8f9b65acc4f7a7476fc4e63693a Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 4 Feb 2020 17:15:17 +0800 Subject: [PATCH 031/145] Add: new --- README.md | 19 ++++ problems/ads-performance/README.md | 14 +++ problems/ads-performance/mysql_schemas.sql | 12 +++ problems/break-a-palindrome/README.md | 63 +++++++++++++ .../README.md | 79 ++++++++++++++++ .../README.md | 71 ++++++++++++++ .../README.md | 78 ++++++++++++++++ .../README.md | 2 +- problems/jump-game-v/README.md | 89 ++++++++++++++++++ .../README.md | 14 +++ .../mysql_schemas.sql | 21 +++++ problems/maximum-69-number/README.md | 66 +++++++++++++ .../README.md | 69 ++++++++++++++ .../README.md | 84 +++++++++++++++++ .../README.md | 93 +++++++++++++++++++ .../README.md | 14 +++ .../mysql_schemas.sql | 22 +++++ problems/print-words-vertically/README.md | 64 +++++++++++++ problems/rank-transform-of-an-array/README.md | 67 +++++++++++++ .../reduce-array-size-to-the-half/README.md | 85 +++++++++++++++++ .../remove-palindromic-subsequences/README.md | 76 +++++++++++++++ problems/restaurant-growth/README.md | 2 +- .../README.md | 72 ++++++++++++++ problems/sliding-window-median/README.md | 13 ++- problems/sort-the-matrix-diagonally/README.md | 52 +++++++++++ problems/spiral-matrix/README.md | 17 ++++ .../the-k-weakest-rows-in-a-matrix/README.md | 78 ++++++++++++++++ problems/zuma-game/README.md | 76 ++++++++------- tag/array/README.md | 6 ++ tag/binary-search/README.md | 1 + tag/dynamic-programming/README.md | 4 + tag/graph/README.md | 1 + tag/greedy/README.md | 2 + tag/math/README.md | 2 + tag/sort/README.md | 2 + tag/string/README.md | 3 + tag/tree/README.md | 2 + 37 files changed, 1397 insertions(+), 38 deletions(-) create mode 100644 problems/ads-performance/README.md create mode 100644 problems/ads-performance/mysql_schemas.sql create mode 100644 problems/break-a-palindrome/README.md create mode 100644 problems/delete-leaves-with-a-given-value/README.md create mode 100644 problems/filter-restaurants-by-vegan-friendly-price-and-distance/README.md create mode 100644 problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md create mode 100644 problems/jump-game-v/README.md create mode 100644 problems/list-the-products-ordered-in-a-period/README.md create mode 100644 problems/list-the-products-ordered-in-a-period/mysql_schemas.sql create mode 100644 problems/maximum-69-number/README.md create mode 100644 problems/maximum-product-of-splitted-binary-tree/README.md create mode 100644 problems/minimum-difficulty-of-a-job-schedule/README.md create mode 100644 problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md create mode 100644 problems/number-of-transactions-per-visit/README.md create mode 100644 problems/number-of-transactions-per-visit/mysql_schemas.sql create mode 100644 problems/print-words-vertically/README.md create mode 100644 problems/rank-transform-of-an-array/README.md create mode 100644 problems/reduce-array-size-to-the-half/README.md create mode 100644 problems/remove-palindromic-subsequences/README.md create mode 100644 problems/reverse-subarray-to-maximize-array-value/README.md create mode 100644 problems/sort-the-matrix-diagonally/README.md create mode 100644 problems/the-k-weakest-rows-in-a-matrix/README.md diff --git a/README.md b/README.md index 9b15a1ee4..02d19b0a3 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,25 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1340 | [Jump Game V](https://leetcode.com/problems/jump-game-v "跳跃游戏 V") | [Go](problems/jump-game-v) | Hard | +| 1339 | [Maximum Product of Splitted Binary Tree](https://leetcode.com/problems/maximum-product-of-splitted-binary-tree "分裂二叉树的最大乘积") | [Go](problems/maximum-product-of-splitted-binary-tree) | Medium | +| 1338 | [Reduce Array Size to The Half](https://leetcode.com/problems/reduce-array-size-to-the-half "数组大小减半") | [Go](problems/reduce-array-size-to-the-half) | Medium | +| 1337 | [The K Weakest Rows in a Matrix](https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix "方阵中战斗力最弱的 K 行") | [Go](problems/the-k-weakest-rows-in-a-matrix) | Easy | +| 1336 | [Number of Transactions per Visit](https://leetcode.com/problems/number-of-transactions-per-visit) 🔒 | [MySQL](problems/number-of-transactions-per-visit) | Medium | +| 1335 | [Minimum Difficulty of a Job Schedule](https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule "工作计划的最低难度") | [Go](problems/minimum-difficulty-of-a-job-schedule) | Hard | +| 1334 | [Find the City With the Smallest Number of Neighbors at a Threshold Distance](https://leetcode.com/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance "阈值距离内邻居最少的城市") | [Go](problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | Medium | +| 1333 | [Filter Restaurants by Vegan-Friendly, Price and Distance](https://leetcode.com/problems/filter-restaurants-by-vegan-friendly-price-and-distance "餐厅过滤器") | [Go](problems/filter-restaurants-by-vegan-friendly-price-and-distance) | Medium | +| 1332 | [Remove Palindromic Subsequences](https://leetcode.com/problems/remove-palindromic-subsequences "删除回文子序列") | [Go](problems/remove-palindromic-subsequences) | Easy | +| 1331 | [Rank Transform of an Array](https://leetcode.com/problems/rank-transform-of-an-array "数组序号转换") | [Go](problems/rank-transform-of-an-array) | Easy | +| 1330 | [Reverse Subarray To Maximize Array Value](https://leetcode.com/problems/reverse-subarray-to-maximize-array-value "翻转子数组得到最大的数组值") | [Go](problems/reverse-subarray-to-maximize-array-value) | Hard | +| 1329 | [Sort the Matrix Diagonally](https://leetcode.com/problems/sort-the-matrix-diagonally "将矩阵按对角线排序") | [Go](problems/sort-the-matrix-diagonally) | Medium | +| 1328 | [Break a Palindrome](https://leetcode.com/problems/break-a-palindrome "破坏回文串") | [Go](problems/break-a-palindrome) | Medium | +| 1327 | [List the Products Ordered in a Period](https://leetcode.com/problems/list-the-products-ordered-in-a-period) 🔒 | [MySQL](problems/list-the-products-ordered-in-a-period) | Easy | +| 1326 | [Minimum Number of Taps to Open to Water a Garden](https://leetcode.com/problems/minimum-number-of-taps-to-open-to-water-a-garden "灌溉花园的最少水龙头数目") | [Go](problems/minimum-number-of-taps-to-open-to-water-a-garden) | Hard | +| 1325 | [Delete Leaves With a Given Value](https://leetcode.com/problems/delete-leaves-with-a-given-value "删除给定值的叶子节点") | [Go](problems/delete-leaves-with-a-given-value) | Medium | +| 1324 | [Print Words Vertically](https://leetcode.com/problems/print-words-vertically "竖直打印单词") | [Go](problems/print-words-vertically) | Medium | +| 1323 | [Maximum 69 Number](https://leetcode.com/problems/maximum-69-number "6 和 9 组成的最大数字") | [Go](problems/maximum-69-number) | Easy | +| 1322 | [Ads Performance](https://leetcode.com/problems/ads-performance) 🔒 | [MySQL](problems/ads-performance) | Easy | | 1321 | [Restaurant Growth](https://leetcode.com/problems/restaurant-growth) 🔒 | [MySQL](problems/restaurant-growth) | Medium | | 1320 | [Minimum Distance to Type a Word Using Two Fingers](https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers "二指输入的的最小距离") | [Go](problems/minimum-distance-to-type-a-word-using-two-fingers) | Hard | | 1319 | [Number of Operations to Make Network Connected](https://leetcode.com/problems/number-of-operations-to-make-network-connected "连通网络的操作次数") | [Go](problems/number-of-operations-to-make-network-connected) | Medium | diff --git a/problems/ads-performance/README.md b/problems/ads-performance/README.md new file mode 100644 index 000000000..17c8661d2 --- /dev/null +++ b/problems/ads-performance/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../restaurant-growth "Restaurant Growth") +                 +[Next >](../maximum-69-number "Maximum 69 Number") + +## [1322. Ads Performance (Easy)](https://leetcode.com/problems/ads-performance "") + + diff --git a/problems/ads-performance/mysql_schemas.sql b/problems/ads-performance/mysql_schemas.sql new file mode 100644 index 000000000..0ccce8bb5 --- /dev/null +++ b/problems/ads-performance/mysql_schemas.sql @@ -0,0 +1,12 @@ +Create table If Not Exists Ads (ad_id int, user_id int, action ENUM('Clicked', 'Viewed', 'Ignored')); +Truncate table Ads; +insert into Ads (ad_id, user_id, action) values ('1', '1', 'Clicked'); +insert into Ads (ad_id, user_id, action) values ('2', '2', 'Clicked'); +insert into Ads (ad_id, user_id, action) values ('3', '3', 'Viewed'); +insert into Ads (ad_id, user_id, action) values ('5', '5', 'Ignored'); +insert into Ads (ad_id, user_id, action) values ('1', '7', 'Ignored'); +insert into Ads (ad_id, user_id, action) values ('2', '7', 'Viewed'); +insert into Ads (ad_id, user_id, action) values ('3', '5', 'Clicked'); +insert into Ads (ad_id, user_id, action) values ('1', '4', 'Viewed'); +insert into Ads (ad_id, user_id, action) values ('2', '11', 'Viewed'); +insert into Ads (ad_id, user_id, action) values ('1', '2', 'Clicked'); diff --git a/problems/break-a-palindrome/README.md b/problems/break-a-palindrome/README.md new file mode 100644 index 000000000..b64bba2c8 --- /dev/null +++ b/problems/break-a-palindrome/README.md @@ -0,0 +1,63 @@ + + + + + + + +[< Previous](../list-the-products-ordered-in-a-period "List the Products Ordered in a Period") +                 +[Next >](../sort-the-matrix-diagonally "Sort the Matrix Diagonally") + +## [1328. Break a Palindrome (Medium)](https://leetcode.com/problems/break-a-palindrome "破坏回文串") + +

Given a palindromic string palindrome, replace exactly one character by any lowercase English letter so that the string becomes the lexicographically smallest possible string that isn't a palindrome.

+ +

After doing so, return the final string.  If there is no way to do so, return the empty string.

+ +

 

+

Example 1:

+ +
+Input: palindrome = "abccba"
+Output: "aaccba"
+
+ +

Example 2:

+ +
+Input: palindrome = "a"
+Output: ""
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= palindrome.length <= 1000
  • +
  • palindrome consists of only lowercase English letters.
  • +
+ +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
+Hint 1 +How to detect if there is impossible to perform the replacement? Only when the length = 1. +
+ +
+Hint 2 +Change the first non 'a' character to 'a'. +
+ +
+Hint 3 +What if the string has only 'a'? +
+ +
+Hint 4 +Change the last character to 'b'. +
diff --git a/problems/delete-leaves-with-a-given-value/README.md b/problems/delete-leaves-with-a-given-value/README.md new file mode 100644 index 000000000..65abf060f --- /dev/null +++ b/problems/delete-leaves-with-a-given-value/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../print-words-vertically "Print Words Vertically") +                 +[Next >](../minimum-number-of-taps-to-open-to-water-a-garden "Minimum Number of Taps to Open to Water a Garden") + +## [1325. Delete Leaves With a Given Value (Medium)](https://leetcode.com/problems/delete-leaves-with-a-given-value "删除给定值的叶子节点") + +

Given a binary tree root and an integer target, delete all the leaf nodes with value target.

+ +

Note that once you delete a leaf node with value targetif it's parent node becomes a leaf node and has the value target, it should also be deleted (you need to continue doing that until you can't).

+ +

 

+

Example 1:

+ +

+ +
+Input: root = [1,2,3,2,null,2,4], target = 2
+Output: [1,null,3,null,4]
+Explanation: Leaf nodes in green with value (target = 2) are removed (Picture in left). 
+After removing, new nodes become leaf nodes with value (target = 2) (Picture in center).
+
+ +

Example 2:

+ +

+ +
+Input: root = [1,3,3,3,2], target = 3
+Output: [1,3,null,null,2]
+
+ +

Example 3:

+ +

+ +
+Input: root = [1,2,null,2,null,2], target = 2
+Output: [1]
+Explanation: Leaf nodes in green with value (target = 2) are removed at each step.
+
+ +

Example 4:

+ +
+Input: root = [1,1,1], target = 1
+Output: []
+
+ +

Example 5:

+ +
+Input: root = [1,2,3], target = 1
+Output: [1,2,3]
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= target <= 1000
  • +
  • Each tree has at most 3000 nodes.
  • +
  • Each node's value is between [1, 1000].
  • +
+ +### Related Topics + [[Tree](../../tag/tree/README.md)] + +### Hints +
+Hint 1 +Use the DFS to reconstruct the tree such that no leaf node is equal to the target. If the leaf node is equal to the target, return an empty object instead. +
diff --git a/problems/filter-restaurants-by-vegan-friendly-price-and-distance/README.md b/problems/filter-restaurants-by-vegan-friendly-price-and-distance/README.md new file mode 100644 index 000000000..9ae2a5248 --- /dev/null +++ b/problems/filter-restaurants-by-vegan-friendly-price-and-distance/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../remove-palindromic-subsequences "Remove Palindromic Subsequences") +                 +[Next >](../find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance "Find the City With the Smallest Number of Neighbors at a Threshold Distance") + +## [1333. Filter Restaurants by Vegan-Friendly, Price and Distance (Medium)](https://leetcode.com/problems/filter-restaurants-by-vegan-friendly-price-and-distance "餐厅过滤器") + +

Given the array restaurants where  restaurants[i] = [idi, ratingi, veganFriendlyi, pricei, distancei]. You have to filter the restaurants using three filters.

+ +

The veganFriendly filter will be either true (meaning you should only include restaurants with veganFriendlyi set to true) or false (meaning you can include any restaurant). In addition, you have the filters maxPrice and maxDistance which are the maximum value for price and distance of restaurants you should consider respectively.

+ +

Return the array of restaurant IDs after filtering, ordered by rating from highest to lowest. For restaurants with the same rating, order them by id from highest to lowest. For simplicity veganFriendlyi and veganFriendly take value 1 when it is true, and 0 when it is false.

+ +

 

+

Example 1:

+ +
+Input: restaurants = [[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]], veganFriendly = 1, maxPrice = 50, maxDistance = 10
+Output: [3,1,5] 
+Explanation: 
+The restaurants are:
+Restaurant 1 [id=1, rating=4, veganFriendly=1, price=40, distance=10]
+Restaurant 2 [id=2, rating=8, veganFriendly=0, price=50, distance=5]
+Restaurant 3 [id=3, rating=8, veganFriendly=1, price=30, distance=4]
+Restaurant 4 [id=4, rating=10, veganFriendly=0, price=10, distance=3]
+Restaurant 5 [id=5, rating=1, veganFriendly=1, price=15, distance=1] 
+After filter restaurants with veganFriendly = 1, maxPrice = 50 and maxDistance = 10 we have restaurant 3, restaurant 1 and restaurant 5 (ordered by rating from highest to lowest). 
+
+ +

Example 2:

+ +
+Input: restaurants = [[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]], veganFriendly = 0, maxPrice = 50, maxDistance = 10
+Output: [4,3,2,1,5]
+Explanation: The restaurants are the same as in example 1, but in this case the filter veganFriendly = 0, therefore all restaurants are considered.
+
+ +

Example 3:

+ +
+Input: restaurants = [[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]], veganFriendly = 0, maxPrice = 30, maxDistance = 3
+Output: [4,5]
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= restaurants.length <= 10^4
  • +
  • restaurants[i].length == 5
  • +
  • 1 <= idi, ratingi, pricei, distancei <= 10^5
  • +
  • 1 <= maxPrice, maxDistance <= 10^5
  • +
  • veganFriendlyi and veganFriendly are 0 or 1.
  • +
  • All idi are distinct.
  • +
+ +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
+Hint 1 +Do the filtering and sort as said. Note that the id may not be the index in the array. +
diff --git a/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md b/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md new file mode 100644 index 000000000..d0ddb9996 --- /dev/null +++ b/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../filter-restaurants-by-vegan-friendly-price-and-distance "Filter Restaurants by Vegan-Friendly, Price and Distance") +                 +[Next >](../minimum-difficulty-of-a-job-schedule "Minimum Difficulty of a Job Schedule") + +## [1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance (Medium)](https://leetcode.com/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance "阈值距离内邻居最少的城市") + +

There are n cities numbered from 0 to n-1. Given the array edges where edges[i] = [fromi, toi, weighti] represents a bidirectional and weighted edge between cities fromi and toi, and given the integer distanceThreshold.

+ +

Return the city with the smallest number of cities that are reachable through some path and whose distance is at most distanceThreshold, If there are multiple such cities, return the city with the greatest number.

+ +

Notice that the distance of a path connecting cities i and j is equal to the sum of the edges' weights along that path.

+ +

 

+

Example 1:

+ +

+ +
+Input: n = 4, edges = [[0,1,3],[1,2,1],[1,3,4],[2,3,1]], distanceThreshold = 4
+Output: 3
+Explanation: The figure above describes the graph. 
+The neighboring cities at a distanceThreshold = 4 for each city are:
+City 0 -> [City 1, City 2] 
+City 1 -> [City 0, City 2, City 3] 
+City 2 -> [City 0, City 1, City 3] 
+City 3 -> [City 1, City 2] 
+Cities 0 and 3 have 2 neighboring cities at a distanceThreshold = 4, but we have to return city 3 since it has the greatest number.
+
+ +

Example 2:

+ +

+ +
+Input: n = 5, edges = [[0,1,2],[0,4,8],[1,2,3],[1,4,2],[2,3,1],[3,4,1]], distanceThreshold = 2
+Output: 0
+Explanation: The figure above describes the graph. 
+The neighboring cities at a distanceThreshold = 2 for each city are:
+City 0 -> [City 1] 
+City 1 -> [City 0, City 4] 
+City 2 -> [City 3, City 4] 
+City 3 -> [City 2, City 4]
+City 4 -> [City 1, City 2, City 3] 
+The city 0 has 1 neighboring city at a distanceThreshold = 2.
+
+ +

 

+

Constraints:

+ +
    +
  • 2 <= n <= 100
  • +
  • 1 <= edges.length <= n * (n - 1) / 2
  • +
  • edges[i].length == 3
  • +
  • 0 <= fromi < toi < n
  • +
  • 1 <= weighti, distanceThreshold <= 10^4
  • +
  • All pairs (fromi, toi) are distinct.
  • +
+ +### Related Topics + [[Graph](../../tag/graph/README.md)] + +### Hints +
+Hint 1 +Use Floyd-Warshall's algorithm to compute any-point to any-point distances. (Or can also do Dijkstra from every node due to the weights are non-negative). +
+ +
+Hint 2 +For each city calculate the number of reachable cities within the threshold, then search for the optimal city. +
diff --git a/problems/get-watched-videos-by-your-friends/README.md b/problems/get-watched-videos-by-your-friends/README.md index d3e1a3f97..fbaddab8c 100644 --- a/problems/get-watched-videos-by-your-friends/README.md +++ b/problems/get-watched-videos-by-your-friends/README.md @@ -13,7 +13,7 @@

There are n people, each person has a unique id between 0 and n-1. Given the arrays watchedVideos and friends, where watchedVideos[i] and friends[i] contain the list of watched videos and the list of friends respectively for the person with id = i.

-

Level 1 of videos are all watched videos by your friends, level 2 of videos are all watched videos by the friends of your friends and so on. In general, the level k of videos are all watched videos by people with the shortest path equal to k with you. Given your id and the level of videos, return the list of videos ordered by their frequencies (increasing). For videos with the same frequency order them alphabetically from least to greatest. 

+

Level 1 of videos are all watched videos by your friends, level 2 of videos are all watched videos by the friends of your friends and so on. In general, the level k of videos are all watched videos by people with the shortest path exactly equal to k with you. Given your id and the level of videos, return the list of videos ordered by their frequencies (increasing). For videos with the same frequency order them alphabetically from least to greatest. 

 

Example 1:

diff --git a/problems/jump-game-v/README.md b/problems/jump-game-v/README.md new file mode 100644 index 000000000..b30bfe79c --- /dev/null +++ b/problems/jump-game-v/README.md @@ -0,0 +1,89 @@ + + + + + + + +[< Previous](../maximum-product-of-splitted-binary-tree "Maximum Product of Splitted Binary Tree") +                 +Next > + +## [1340. Jump Game V (Hard)](https://leetcode.com/problems/jump-game-v "跳跃游戏 V") + +

Given an array of integers arr and an integer d. In one step you can jump from index i to index:

+ +
    +
  • i + x where: i + x < arr.length and 0 < x <= d.
  • +
  • i - x where: i - x >= 0 and 0 < x <= d.
  • +
+ +

In addition, you can only jump from index i to index j if arr[i] > arr[j] and arr[i] > arr[k] for all indices k between i and j (More formally min(i, j) < k < max(i, j)).

+ +

You can choose any index of the array and start jumping. Return the maximum number of indices you can visit.

+ +

Notice that you can not jump outside of the array at any time.

+ +

 

+

Example 1:

+ +
+Input: arr = [6,4,14,6,8,13,9,7,10,6,12], d = 2
+Output: 4
+Explanation: You can start at index 10. You can jump 10 --> 8 --> 6 --> 7 as shown.
+Note that if you start at index 6 you can only jump to index 7. You cannot jump to index 5 because 13 > 9. You cannot jump to index 4 because index 5 is between index 4 and 6 and 13 > 9.
+Similarly You cannot jump from index 3 to index 2 or index 1.
+
+ +

Example 2:

+ +
+Input: arr = [3,3,3,3,3], d = 3
+Output: 1
+Explanation: You can start at any index. You always cannot jump to any index.
+
+ +

Example 3:

+ +
+Input: arr = [7,6,5,4,3,2,1], d = 1
+Output: 7
+Explanation: Start at index 0. You can visit all the indicies. 
+
+ +

Example 4:

+ +
+Input: arr = [7,1,7,1,7,1], d = 2
+Output: 2
+
+ +

Example 5:

+ +
+Input: arr = [66], d = 1
+Output: 1
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= arr.length <= 1000
  • +
  • 1 <= arr[i] <= 10^5
  • +
  • 1 <= d <= arr.length
  • +
+ +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
+Hint 1 +Use dynamic programming. dp[i] is max jumps you can do starting from index i. Answer is max(dp[i]). +
+ +
+Hint 2 +dp[i] = 1 + max (dp[j]) where j is all indices you can reach from i. +
diff --git a/problems/list-the-products-ordered-in-a-period/README.md b/problems/list-the-products-ordered-in-a-period/README.md new file mode 100644 index 000000000..e33dfda4b --- /dev/null +++ b/problems/list-the-products-ordered-in-a-period/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../minimum-number-of-taps-to-open-to-water-a-garden "Minimum Number of Taps to Open to Water a Garden") +                 +[Next >](../break-a-palindrome "Break a Palindrome") + +## [1327. List the Products Ordered in a Period (Easy)](https://leetcode.com/problems/list-the-products-ordered-in-a-period "") + + diff --git a/problems/list-the-products-ordered-in-a-period/mysql_schemas.sql b/problems/list-the-products-ordered-in-a-period/mysql_schemas.sql new file mode 100644 index 000000000..a69778f8f --- /dev/null +++ b/problems/list-the-products-ordered-in-a-period/mysql_schemas.sql @@ -0,0 +1,21 @@ +Create table If Not Exists Products (product_id int, product_name varchar(40), product_category varchar(40)); +Create table If Not Exists Orders (product_id int, order_date date, unit int); +Truncate table Products; +insert into Products (product_id, product_name, product_category) values ('1', 'Leetcode Solutions', 'Book'); +insert into Products (product_id, product_name, product_category) values ('2', 'Jewels of Stringology', 'Book'); +insert into Products (product_id, product_name, product_category) values ('3', 'HP', 'Laptop'); +insert into Products (product_id, product_name, product_category) values ('4', 'Lenovo', 'Laptop'); +insert into Products (product_id, product_name, product_category) values ('5', 'Leetcode Kit', 'T-shirt'); +Truncate table Orders; +insert into Orders (product_id, order_date, unit) values ('1', '2020-02-05', '60'); +insert into Orders (product_id, order_date, unit) values ('1', '2020-02-10', '70'); +insert into Orders (product_id, order_date, unit) values ('2', '2020-01-18', '30'); +insert into Orders (product_id, order_date, unit) values ('2', '2020-02-11', '80'); +insert into Orders (product_id, order_date, unit) values ('3', '2020-02-17', '2'); +insert into Orders (product_id, order_date, unit) values ('3', '2020-02-24', '3'); +insert into Orders (product_id, order_date, unit) values ('4', '2020-03-01', '20'); +insert into Orders (product_id, order_date, unit) values ('4', '2020-03-04', '30'); +insert into Orders (product_id, order_date, unit) values ('4', '2020-03-04', '60'); +insert into Orders (product_id, order_date, unit) values ('5', '2020-02-25', '50'); +insert into Orders (product_id, order_date, unit) values ('5', '2020-02-27', '50'); +insert into Orders (product_id, order_date, unit) values ('5', '2020-03-01', '50'); diff --git a/problems/maximum-69-number/README.md b/problems/maximum-69-number/README.md new file mode 100644 index 000000000..002a3340a --- /dev/null +++ b/problems/maximum-69-number/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../ads-performance "Ads Performance") +                 +[Next >](../print-words-vertically "Print Words Vertically") + +## [1323. Maximum 69 Number (Easy)](https://leetcode.com/problems/maximum-69-number "6 和 9 组成的最大数字") + +

Given a positive integer num consisting only of digits 6 and 9.

+ +

Return the maximum number you can get by changing at most one digit (6 becomes 9, and 9 becomes 6).

+ +

 

+

Example 1:

+ +
+Input: num = 9669
+Output: 9969
+Explanation: 
+Changing the first digit results in 6669.
+Changing the second digit results in 9969.
+Changing the third digit results in 9699.
+Changing the fourth digit results in 9666. 
+The maximum number is 9969.
+
+ +

Example 2:

+ +
+Input: num = 9996
+Output: 9999
+Explanation: Changing the last digit 6 to 9 results in the maximum number.
+ +

Example 3:

+ +
+Input: num = 9999
+Output: 9999
+Explanation: It is better not to apply any change.
+ +

 

+

Constraints:

+ +
    +
  • 1 <= num <= 10^4
  • +
  • num's digits are 6 or 9.
  • +
+ +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
+Hint 1 +Convert the number in an array of its digits. +
+ +
+Hint 2 +Brute force on every digit to get the maximum number. +
diff --git a/problems/maximum-product-of-splitted-binary-tree/README.md b/problems/maximum-product-of-splitted-binary-tree/README.md new file mode 100644 index 000000000..fbe9b425e --- /dev/null +++ b/problems/maximum-product-of-splitted-binary-tree/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../reduce-array-size-to-the-half "Reduce Array Size to The Half") +                 +[Next >](../jump-game-v "Jump Game V") + +## [1339. Maximum Product of Splitted Binary Tree (Medium)](https://leetcode.com/problems/maximum-product-of-splitted-binary-tree "分裂二叉树的最大乘积") + +

Given a binary tree root. Split the binary tree into two subtrees by removing 1 edge such that the product of the sums of the subtrees are maximized.

+ +

Since the answer may be too large, return it modulo 10^9 + 7.

+ +

 

+

Example 1:

+ +

+ +
+Input: root = [1,2,3,4,5,6]
+Output: 110
+Explanation: Remove the red edge and get 2 binary trees with sum 11 and 10. Their product is 110 (11*10)
+
+ +

Example 2:

+ +

+ +
+Input: root = [1,null,2,3,4,null,null,5,6]
+Output: 90
+Explanation:  Remove the red edge and get 2 binary trees with sum 15 and 6.Their product is 90 (15*6)
+
+ +

Example 3:

+ +
+Input: root = [2,3,9,10,7,8,6,5,4,11,1]
+Output: 1025
+
+ +

Example 4:

+ +
+Input: root = [1,1]
+Output: 1
+
+ +

 

+

Constraints:

+ +
    +
  • Each tree has at most 50000 nodes and at least 2 nodes.
  • +
  • Each node's value is between [1, 10000].
  • +
+ +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
+Hint 1 +If we know the sum of a subtree, the answer is max( (total_sum - subtree_sum) * subtree_sum) in each node. +
diff --git a/problems/minimum-difficulty-of-a-job-schedule/README.md b/problems/minimum-difficulty-of-a-job-schedule/README.md new file mode 100644 index 000000000..d45e64349 --- /dev/null +++ b/problems/minimum-difficulty-of-a-job-schedule/README.md @@ -0,0 +1,84 @@ + + + + + + + +[< Previous](../find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance "Find the City With the Smallest Number of Neighbors at a Threshold Distance") +                 +[Next >](../number-of-transactions-per-visit "Number of Transactions per Visit") + +## [1335. Minimum Difficulty of a Job Schedule (Hard)](https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule "工作计划的最低难度") + +

You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the i-th job, you have to finish all the jobs j where 0 <= j < i).

+ +

You have to finish at least one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the d days. The difficulty of a day is the maximum difficulty of a job done in that day.

+ +

Given an array of integers jobDifficulty and an integer d. The difficulty of the i-th job is jobDifficulty[i].

+ +

Return the minimum difficulty of a job schedule. If you cannot find a schedule for the jobs return -1.

+ +

 

+

Example 1:

+ +
+Input: jobDifficulty = [6,5,4,3,2,1], d = 2
+Output: 7
+Explanation: First day you can finish the first 5 jobs, total difficulty = 6.
+Second day you can finish the last job, total difficulty = 1.
+The difficulty of the schedule = 6 + 1 = 7 
+
+ +

Example 2:

+ +
+Input: jobDifficulty = [9,9,9], d = 4
+Output: -1
+Explanation: If you finish a job per day you will still have a free day. you cannot find a schedule for the given jobs.
+
+ +

Example 3:

+ +
+Input: jobDifficulty = [1,1,1], d = 3
+Output: 3
+Explanation: The schedule is one job per day. total difficulty will be 3.
+
+ +

Example 4:

+ +
+Input: jobDifficulty = [7,1,7,1,7,1], d = 3
+Output: 15
+
+ +

Example 5:

+ +
+Input: jobDifficulty = [11,111,22,222,33,333,44,444], d = 6
+Output: 843
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= jobDifficulty.length <= 300
  • +
  • 0 <= jobDifficulty[i] <= 1000
  • +
  • 1 <= d <= 10
  • +
+ +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
+Hint 1 +Use DP. Try to cut the array into d non-empty sub-arrays. Try all possible cuts for the array. +
+ +
+Hint 2 +Use dp[i][j] where DP states are i the index of the last cut and j the number of remaining cuts. Complexity is O(n * n * d). +
diff --git a/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md b/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md new file mode 100644 index 000000000..b3fbccb97 --- /dev/null +++ b/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md @@ -0,0 +1,93 @@ + + + + + + + +[< Previous](../delete-leaves-with-a-given-value "Delete Leaves With a Given Value") +                 +[Next >](../list-the-products-ordered-in-a-period "List the Products Ordered in a Period") + +## [1326. Minimum Number of Taps to Open to Water a Garden (Hard)](https://leetcode.com/problems/minimum-number-of-taps-to-open-to-water-a-garden "灌溉花园的最少水龙头数目") + +

There is a one-dimensional garden on the x-axis. The garden starts at the point 0 and ends at the point n. (i.e The length of the garden is n).

+ +

There are n + 1 taps located at points [0, 1, ..., n] in the garden.

+ +

Given an integer n and an integer array ranges of length n + 1 where ranges[i] (0-indexed) means the i-th tap can water the area [i - ranges[i], i + ranges[i]] if it was open.

+ +

Return the minimum number of taps that should be open to water the whole garden, If the garden cannot be watered return -1.

+ +

 

+

Example 1:

+ +
+Input: n = 5, ranges = [3,4,1,1,0,0]
+Output: 1
+Explanation: The tap at point 0 can cover the interval [-3,3]
+The tap at point 1 can cover the interval [-3,5]
+The tap at point 2 can cover the interval [1,3]
+The tap at point 3 can cover the interval [2,4]
+The tap at point 4 can cover the interval [4,4]
+The tap at point 5 can cover the interval [5,5]
+Opening Only the second tap will water the whole garden [0,5]
+
+ +

Example 2:

+ +
+Input: n = 3, ranges = [0,0,0,0]
+Output: -1
+Explanation: Even if you activate all the four taps you cannot water the whole garden.
+
+ +

Example 3:

+ +
+Input: n = 7, ranges = [1,2,1,0,2,1,0,1]
+Output: 3
+
+ +

Example 4:

+ +
+Input: n = 8, ranges = [4,0,0,0,0,0,0,0,4]
+Output: 2
+
+ +

Example 5:

+ +
+Input: n = 8, ranges = [4,0,0,0,4,0,0,0,4]
+Output: 1
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= n <= 10^4
  • +
  • ranges.length == n + 1
  • +
  • 0 <= ranges[i] <= 100
  • +
+ +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
+Hint 1 +Create intervals of the area covered by each tap, sort intervals by the left end. +
+ +
+Hint 2 +We need to cover the interval [0, n]. we can start with the first interval and out of all intervals that intersect with it we choose the one that covers the farthest point to the right. +
+ +
+Hint 3 +What if there is a gap between intervals that is not covered ? we should stop and return -1 as there is some interval that cannot be covered. +
diff --git a/problems/number-of-transactions-per-visit/README.md b/problems/number-of-transactions-per-visit/README.md new file mode 100644 index 000000000..21309d506 --- /dev/null +++ b/problems/number-of-transactions-per-visit/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../minimum-difficulty-of-a-job-schedule "Minimum Difficulty of a Job Schedule") +                 +[Next >](../the-k-weakest-rows-in-a-matrix "The K Weakest Rows in a Matrix") + +## [1336. Number of Transactions per Visit (Medium)](https://leetcode.com/problems/number-of-transactions-per-visit "") + + diff --git a/problems/number-of-transactions-per-visit/mysql_schemas.sql b/problems/number-of-transactions-per-visit/mysql_schemas.sql new file mode 100644 index 000000000..0c16a9c57 --- /dev/null +++ b/problems/number-of-transactions-per-visit/mysql_schemas.sql @@ -0,0 +1,22 @@ +Create table If Not Exists Visits (user_id int, visit_date date); +Create table If Not Exists Transactions (user_id int, transaction_date date, amount int); +Truncate table Visits; +insert into Visits (user_id, visit_date) values ('1', '2020-01-01'); +insert into Visits (user_id, visit_date) values ('2', '2020-01-02'); +insert into Visits (user_id, visit_date) values ('12', '2020-01-01'); +insert into Visits (user_id, visit_date) values ('19', '2020-01-03'); +insert into Visits (user_id, visit_date) values ('1', '2020-01-02'); +insert into Visits (user_id, visit_date) values ('2', '2020-01-03'); +insert into Visits (user_id, visit_date) values ('1', '2020-01-04'); +insert into Visits (user_id, visit_date) values ('7', '2020-01-11'); +insert into Visits (user_id, visit_date) values ('9', '2020-01-25'); +insert into Visits (user_id, visit_date) values ('8', '2020-01-28'); +Truncate table Transactions; +insert into Transactions (user_id, transaction_date, amount) values ('1', '2020-01-02', '120'); +insert into Transactions (user_id, transaction_date, amount) values ('2', '2020-01-03', '22'); +insert into Transactions (user_id, transaction_date, amount) values ('7', '2020-01-11', '232'); +insert into Transactions (user_id, transaction_date, amount) values ('1', '2020-01-04', '7'); +insert into Transactions (user_id, transaction_date, amount) values ('9', '2020-01-25', '33'); +insert into Transactions (user_id, transaction_date, amount) values ('9', '2020-01-25', '66'); +insert into Transactions (user_id, transaction_date, amount) values ('8', '2020-01-28', '1'); +insert into Transactions (user_id, transaction_date, amount) values ('9', '2020-01-25', '99'); diff --git a/problems/print-words-vertically/README.md b/problems/print-words-vertically/README.md new file mode 100644 index 000000000..ca42eb973 --- /dev/null +++ b/problems/print-words-vertically/README.md @@ -0,0 +1,64 @@ + + + + + + + +[< Previous](../maximum-69-number "Maximum 69 Number") +                 +[Next >](../delete-leaves-with-a-given-value "Delete Leaves With a Given Value") + +## [1324. Print Words Vertically (Medium)](https://leetcode.com/problems/print-words-vertically "竖直打印单词") + +

Given a string s. Return all the words vertically in the same order in which they appear in s.
+Words are returned as a list of strings, complete with spaces when is necessary. (Trailing spaces are not allowed).
+Each word would be put on only one column and that in one column there will be only one word.

+ +

 

+

Example 1:

+ +
+Input: s = "HOW ARE YOU"
+Output: ["HAY","ORO","WEU"]
+Explanation: Each word is printed vertically. 
+ "HAY"
+ "ORO"
+ "WEU"
+
+ +

Example 2:

+ +
+Input: s = "TO BE OR NOT TO BE"
+Output: ["TBONTB","OEROOE","   T"]
+Explanation: Trailing spaces is not allowed. 
+"TBONTB"
+"OEROOE"
+"   T"
+
+ +

Example 3:

+ +
+Input: s = "CONTEST IS COMING"
+Output: ["CIC","OSO","N M","T I","E N","S G","T"]
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= s.length <= 200
  • +
  • s contains only upper case English letters.
  • +
  • It's guaranteed that there is only one space between 2 words.
  • +
+ +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
+Hint 1 +Use the maximum length of words to determine the length of the returned answer. However, don't forget to remove trailing spaces. +
diff --git a/problems/rank-transform-of-an-array/README.md b/problems/rank-transform-of-an-array/README.md new file mode 100644 index 000000000..0d8e92a8f --- /dev/null +++ b/problems/rank-transform-of-an-array/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../reverse-subarray-to-maximize-array-value "Reverse Subarray To Maximize Array Value") +                 +[Next >](../remove-palindromic-subsequences "Remove Palindromic Subsequences") + +## [1331. Rank Transform of an Array (Easy)](https://leetcode.com/problems/rank-transform-of-an-array "数组序号转换") + +

Given an array of integers arr, replace each element with its rank.

+ +

The rank represents how large the element is. The rank has the following rules:

+ +
    +
  • Rank is an integer starting from 1.
  • +
  • The larger the element, the larger the rank. If two elements are equal, their rank must be the same.
  • +
  • Rank should be as small as possible.
  • +
+ +

 

+

Example 1:

+ +
+Input: arr = [40,10,20,30]
+Output: [4,1,2,3]
+Explanation: 40 is the largest element. 10 is the smallest. 20 is the second smallest. 30 is the third smallest.
+ +

Example 2:

+ +
+Input: arr = [100,100,100]
+Output: [1,1,1]
+Explanation: Same elements share the same rank.
+
+ +

Example 3:

+ +
+Input: arr = [37,12,28,9,100,56,80,5,12]
+Output: [5,3,4,2,8,6,7,1,3]
+
+ +

 

+

Constraints:

+ +
    +
  • 0 <= arr.length <= 105
  • +
  • -109 <= arr[i] <= 109
  • +
+ +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
+Hint 1 +Use a temporary array to copy the array and sort it. +
+ +
+Hint 2 +The rank of each element is the number of elements smaller than it in the sorted array plus one. +
diff --git a/problems/reduce-array-size-to-the-half/README.md b/problems/reduce-array-size-to-the-half/README.md new file mode 100644 index 000000000..954a94437 --- /dev/null +++ b/problems/reduce-array-size-to-the-half/README.md @@ -0,0 +1,85 @@ + + + + + + + +[< Previous](../the-k-weakest-rows-in-a-matrix "The K Weakest Rows in a Matrix") +                 +[Next >](../maximum-product-of-splitted-binary-tree "Maximum Product of Splitted Binary Tree") + +## [1338. Reduce Array Size to The Half (Medium)](https://leetcode.com/problems/reduce-array-size-to-the-half "数组大小减半") + +

Given an array arr.  You can choose a set of integers and remove all the occurrences of these integers in the array.

+ +

Return the minimum size of the set so that at least half of the integers of the array are removed.

+ +

 

+

Example 1:

+ +
+Input: arr = [3,3,3,3,5,5,5,2,2,7]
+Output: 2
+Explanation: Choosing {3,7} will make the new array [5,5,5,2,2] which has size 5 (i.e equal to half of the size of the old array).
+Possible sets of size 2 are {3,5},{3,2},{5,2}.
+Choosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] which has size greater than half of the size of the old array.
+
+ +

Example 2:

+ +
+Input: arr = [7,7,7,7,7,7]
+Output: 1
+Explanation: The only possible set you can choose is {7}. This will make the new array empty.
+
+ +

Example 3:

+ +
+Input: arr = [1,9]
+Output: 1
+
+ +

Example 4:

+ +
+Input: arr = [1000,1000,3,7]
+Output: 1
+
+ +

Example 5:

+ +
+Input: arr = [1,2,3,4,5,6,7,8,9,10]
+Output: 5
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= arr.length <= 10^5
  • +
  • arr.length is even.
  • +
  • 1 <= arr[i] <= 10^5
  • +
+ +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
+Hint 1 +Count the frequency of each integer in the array. +
+ +
+Hint 2 +Start with an empty set, add to the set the integer with the maximum frequency. +
+ +
+Hint 3 +Keep Adding the integer with the max frequency until you remove at least half of the integers. +
diff --git a/problems/remove-palindromic-subsequences/README.md b/problems/remove-palindromic-subsequences/README.md new file mode 100644 index 000000000..4380f54d4 --- /dev/null +++ b/problems/remove-palindromic-subsequences/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](../rank-transform-of-an-array "Rank Transform of an Array") +                 +[Next >](../filter-restaurants-by-vegan-friendly-price-and-distance "Filter Restaurants by Vegan-Friendly, Price and Distance") + +## [1332. Remove Palindromic Subsequences (Easy)](https://leetcode.com/problems/remove-palindromic-subsequences "删除回文子序列") + +

Given a string s consisting only of letters 'a' and 'b'. In a single step you can remove one palindromic subsequence from s.

+ +

Return the minimum number of steps to make the given string empty.

+ +

A string is a subsequence of a given string, if it is generated by deleting some characters of a given string without changing its order.

+ +

A string is called palindrome if is one that reads the same backward as well as forward.

+ +

 

+

Example 1:

+ +
+Input: s = "ababa"
+Output: 1
+Explanation: String is already palindrome
+
+ +

Example 2:

+ +
+Input: s = "abb"
+Output: 2
+Explanation: "abb" -> "bb" -> "". 
+Remove palindromic subsequence "a" then "bb".
+
+ +

Example 3:

+ +
+Input: s = "baabb"
+Output: 2
+Explanation: "baabb" -> "b" -> "". 
+Remove palindromic subsequence "baab" then "b".
+
+ +

Example 4:

+ +
+Input: s = ""
+Output: 0
+
+ +

 

+

Constraints:

+ +
    +
  • 0 <= s.length <= 1000
  • +
  • s only consists of letters 'a' and 'b'
  • +
+ +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
+Hint 1 +Use the fact that string contains only 2 characters. +
+ +
+Hint 2 +Are subsequences composed of only one type of letter always palindrome strings ? +
diff --git a/problems/restaurant-growth/README.md b/problems/restaurant-growth/README.md index a13c18fff..71b2ba3fb 100644 --- a/problems/restaurant-growth/README.md +++ b/problems/restaurant-growth/README.md @@ -7,7 +7,7 @@ [< Previous](../minimum-distance-to-type-a-word-using-two-fingers "Minimum Distance to Type a Word Using Two Fingers")                  -Next > +[Next >](../ads-performance "Ads Performance") ## [1321. Restaurant Growth (Medium)](https://leetcode.com/problems/restaurant-growth "") diff --git a/problems/reverse-subarray-to-maximize-array-value/README.md b/problems/reverse-subarray-to-maximize-array-value/README.md new file mode 100644 index 000000000..697eb0f3c --- /dev/null +++ b/problems/reverse-subarray-to-maximize-array-value/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../sort-the-matrix-diagonally "Sort the Matrix Diagonally") +                 +[Next >](../rank-transform-of-an-array "Rank Transform of an Array") + +## [1330. Reverse Subarray To Maximize Array Value (Hard)](https://leetcode.com/problems/reverse-subarray-to-maximize-array-value "翻转子数组得到最大的数组值") + +

You are given an integer array nums. The value of this array is defined as the sum of |nums[i]-nums[i+1]| for all 0 <= i < nums.length-1.

+ +

You are allowed to select any subarray of the given array and reverse it. You can perform this operation only once.

+ +

Find maximum possible value of the final array.

+ +

 

+

Example 1:

+ +
+Input: nums = [2,3,1,5,4]
+Output: 10
+Explanation: By reversing the subarray [3,1,5] the array becomes [2,5,1,3,4] whose value is 10.
+
+ +

Example 2:

+ +
+Input: nums = [2,4,9,24,2,1,10]
+Output: 68
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= nums.length <= 3*10^4
  • +
  • -10^5 <= nums[i] <= 10^5
  • +
+ +### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
+Hint 1 +What's the score after reversing a sub-array [L, R] ? +
+ +
+Hint 2 +It's the score without reversing it + abs(a[R] - a[L-1]) + abs(a[L] - a[R+1]) - abs(a[L] - a[L-1]) - abs(a[R] - a[R+1]) +
+ +
+Hint 3 +How to maximize that formula given that abs(x - y) = max(x - y, y - x) ? +
+ +
+Hint 4 +This can be written as max(max(a[R] - a[L - 1], a[L - 1] - a[R]) + max(a[R + 1] - a[L], a[L] - a[R + 1]) - value(L) - value(R + 1)) over all L < R where value(i) = abs(a[i] - a[i-1]) +
+ +
+Hint 5 +This can be divided into 4 cases. +
diff --git a/problems/sliding-window-median/README.md b/problems/sliding-window-median/README.md index 6f6b6e780..86deb00fb 100644 --- a/problems/sliding-window-median/README.md +++ b/problems/sliding-window-median/README.md @@ -12,13 +12,15 @@ ## [480. Sliding Window Median (Hard)](https://leetcode.com/problems/sliding-window-median "滑动窗口中位数")

Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.

-Examples:
+Examples: +

[2,3,4] , the median is 3

-

[2,3], the median is (2 + 3) / 2 = 2.5

+ +

[2,3], the median is (2 + 3) / 2 = 2.5

Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Your job is to output the median array for each window in the original array.

-

For example,
+

For example,
Given nums = [1,3,-1,-3,5,3,6,7], and k = 3.

@@ -34,8 +36,9 @@ Window position                Median
 
 

Therefore, return the median sliding window as [1,-1,-1,3,5,6].

-

Note:
-You may assume k is always valid, ie: k is always smaller than input array's size for non-empty array.

+

Note:
+You may assume k is always valid, ie: k is always smaller than input array's size for non-empty array.
+Answers within 10^-5 of the actual value will be accepted as correct.

### Related Topics [[Sliding Window](../../tag/sliding-window/README.md)] diff --git a/problems/sort-the-matrix-diagonally/README.md b/problems/sort-the-matrix-diagonally/README.md new file mode 100644 index 000000000..d99b12887 --- /dev/null +++ b/problems/sort-the-matrix-diagonally/README.md @@ -0,0 +1,52 @@ + + + + + + + +[< Previous](../break-a-palindrome "Break a Palindrome") +                 +[Next >](../reverse-subarray-to-maximize-array-value "Reverse Subarray To Maximize Array Value") + +## [1329. Sort the Matrix Diagonally (Medium)](https://leetcode.com/problems/sort-the-matrix-diagonally "将矩阵按对角线排序") + +

Given a m * n matrix mat of integers, sort it diagonally in ascending order from the top-left to the bottom-right then return the sorted array.

+ +

 

+

Example 1:

+ +
+Input: mat = [[3,3,1,1],[2,2,1,2],[1,1,1,2]]
+Output: [[1,1,1,1],[1,2,2,2],[1,2,3,3]]
+
+ +

 

+

Constraints:

+ +
    +
  • m == mat.length
  • +
  • n == mat[i].length
  • +
  • 1 <= m, n <= 100
  • +
  • 1 <= mat[i][j] <= 100
  • +
+ +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
+Hint 1 +Use a data structure to store all values of each diagonal. +
+ +
+Hint 2 +How to index the data structure with the id of the diagonal? +
+ +
+Hint 3 +All cells in the same diagonal (i,j) have the same difference so we can get the diagonal of a cell using the difference i-j. +
diff --git a/problems/spiral-matrix/README.md b/problems/spiral-matrix/README.md index f0139fd00..428ad14cb 100644 --- a/problems/spiral-matrix/README.md +++ b/problems/spiral-matrix/README.md @@ -41,3 +41,20 @@ ### Similar Questions 1. [Spiral Matrix II](../spiral-matrix-ii) (Medium) + +### Hints +
+Hint 1 +Well for some problems, the best way really is to come up with some algorithms for simulation. Basically, you need to simulate what the problem asks us to do. +
+ +
+Hint 2 +We go boundary by boundary and move inwards. That is the essential operation. First row, last column, last row, first column and then we move inwards by 1 and then repeat. That's all, that is all the simulation that we need. +
+ +
+Hint 3 +Think about when you want to switch the progress on one of the indexes. If you progress on
i
out of
[i, j]
, you'd be shifting in the same column. Similarly, by changing values for
j
, you'd be shifting in the same row. +Also, keep track of the end of a boundary so that you can move inwards and then keep repeating. It's always best to run the simulation on edge cases like a single column or a single row to see if anything breaks or not. +
diff --git a/problems/the-k-weakest-rows-in-a-matrix/README.md b/problems/the-k-weakest-rows-in-a-matrix/README.md new file mode 100644 index 000000000..411515b6c --- /dev/null +++ b/problems/the-k-weakest-rows-in-a-matrix/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../number-of-transactions-per-visit "Number of Transactions per Visit") +                 +[Next >](../reduce-array-size-to-the-half "Reduce Array Size to The Half") + +## [1337. The K Weakest Rows in a Matrix (Easy)](https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix "方阵中战斗力最弱的 K 行") + +

Given a m * n matrix mat of ones (representing soldiers) and zeros (representing civilians), return the indexes of the k weakest rows in the matrix ordered from the weakest to the strongest.

+ +

A row i is weaker than row j, if the number of soldiers in row i is less than the number of soldiers in row j, or they have the same number of soldiers but i is less than j. Soldiers are always stand in the frontier of a row, that is, always ones may appear first and then zeros.

+ +

 

+

Example 1:

+ +
+Input: mat = 
+[[1,1,0,0,0],
+ [1,1,1,1,0],
+ [1,0,0,0,0],
+ [1,1,0,0,0],
+ [1,1,1,1,1]], 
+k = 3
+Output: [2,0,3]
+Explanation: 
+The number of soldiers for each row is: 
+row 0 -> 2 
+row 1 -> 4 
+row 2 -> 1 
+row 3 -> 2 
+row 4 -> 5 
+Rows ordered from the weakest to the strongest are [2,0,3,1,4]
+
+ +

Example 2:

+ +
+Input: mat = 
+[[1,0,0,0],
+ [1,1,1,1],
+ [1,0,0,0],
+ [1,0,0,0]], 
+k = 2
+Output: [0,2]
+Explanation: 
+The number of soldiers for each row is: 
+row 0 -> 1 
+row 1 -> 4 
+row 2 -> 1 
+row 3 -> 1 
+Rows ordered from the weakest to the strongest are [0,2,3,1]
+
+ +

 

+

Constraints:

+ +
    +
  • m == mat.length
  • +
  • n == mat[i].length
  • +
  • 2 <= n, m <= 100
  • +
  • 1 <= k <= m
  • +
  • matrix[i][j] is either 0 or 1.
  • +
+ +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
+Hint 1 +Sort the matrix row indexes by the number of soldiers and then row indexes. +
diff --git a/problems/zuma-game/README.md b/problems/zuma-game/README.md index a8d9b5b65..03e93ae42 100644 --- a/problems/zuma-game/README.md +++ b/problems/zuma-game/README.md @@ -12,39 +12,53 @@ ## [488. Zuma Game (Hard)](https://leetcode.com/problems/zuma-game "祖玛游戏")

Think about Zuma Game. You have a row of balls on the table, colored red(R), yellow(Y), blue(B), green(G), and white(W). You also have several balls in your hand.

-

-Each time, you may choose a ball in your hand, and insert it into the row (including the leftmost place and rightmost place). Then, if there is a group of 3 or more balls in the same color touching, remove these balls. Keep doing this until no more balls can be removed.

-

-Find the minimal balls you have to insert to remove all the balls on the table. If you cannot remove all the balls, output -1. -

+ +

Each time, you may choose a ball in your hand, and insert it into the row (including the leftmost place and rightmost place). Then, if there is a group of 3 or more balls in the same color touching, remove these balls. Keep doing this until no more balls can be removed.

+ +

Find the minimal balls you have to insert to remove all the balls on the table. If you cannot remove all the balls, output -1.

+ +

 

+

Example 1:

+ +
+Input: board = "WRRBBW", hand = "RB"
+Output: -1
+Explanation: WRRBBW -> WRR[R]BBW -> WBBW -> WBB[B]W -> WW
+
+ +

Example 2:

+ +
+Input: board = "WWRRBBWW", hand = "WRBRW"
+Output: 2
+Explanation: WWRRBBWW -> WWRR[R]BBWW -> WWBBWW -> WWBB[B]WW -> WWWW -> empty
+
+ +

Example 3:

+
-

Examples:
-Input: "WRRBBW", "RB" -Output: -1 -Explanation: WRRBBW -> WRR[R]BBW -> WBBW -> WBB[B]W -> WW - -Input: "WWRRBBWW", "WRBRW" -Output: 2 -Explanation: WWRRBBWW -> WWRR[R]BBWW -> WWBBWW -> WWBB[B]WW -> WWWW -> empty - -Input:"G", "GGGGG" -Output: 2 -Explanation: G -> G[G] -> GG[G] -> empty - -Input: "RBYYBBRRB", "YRBGB" -Output: 3 -Explanation: RBYYBBRRB -> RBYY[Y]BBRRB -> RBBBRRB -> RRRB -> B -> B[B] -> BB[B] -> empty +Input: board = "G", hand = "GGGGG" +Output: 2 +Explanation: G -> G[G] -> GG[G] -> empty

-

- -

Note:
-

    -
  1. You may assume that the initial row of balls on the table won’t have any 3 or more consecutive balls with the same color.
  2. -
  3. The number of balls on the table won't exceed 20, and the string represents these balls is called "board" in the input.
  4. -
  5. The number of balls in your hand won't exceed 5, and the string represents these balls is called "hand" in the input.
  6. -
  7. Both input strings will be non-empty and only contain characters 'R','Y','B','G','W'.
  8. -
-

+ +

Example 4:

+ +
+Input: board = "RBYYBBRRB", hand = "YRBGB"
+Output: 3
+Explanation: RBYYBBRRB -> RBYY[Y]BBRRB -> RBBBRRB -> RRRB -> B -> B[B] -> BB[B] -> empty 
+
+ +

 

+

Constraints:

+ +
    +
  • You may assume that the initial row of balls on the table won’t have any 3 or more consecutive balls with the same color.
  • +
  • The number of balls on the table won't exceed 16, and the string represents these balls is called "board" in the input.
  • +
  • The number of balls in your hand won't exceed 5, and the string represents these balls is called "hand" in the input.
  • +
  • Both input strings will be non-empty and only contain characters 'R','Y','B','G','W'.
  • +
### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/tag/array/README.md b/tag/array/README.md index 5e864adc6..a5f55a21f 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1337 | [方阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1333 | [餐厅过滤器](../../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1331 | [数组序号转换](../../problems/rank-transform-of-an-array) | [[数组](../array/README.md)] | Easy | +| 1330 | [翻转子数组得到最大的数组值](../../problems/reverse-subarray-to-maximize-array-value) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1329 | [将矩阵按对角线排序](../../problems/sort-the-matrix-diagonally) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1313 | [解压缩编码列表](../../problems/decompress-run-length-encoded-list) | [[数组](../array/README.md)] | Easy | | 1304 | [和为零的N个唯一整数](../../problems/find-n-unique-integers-sum-up-to-zero) | [[数组](../array/README.md)] | Easy | | 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 13f7da3be..f2d86062a 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1337 | [方阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1283 | [使结果不超过阈值的最小除数](../../problems/find-the-smallest-divisor-given-a-threshold) | [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 84453c782..ef7346fa4 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1340 | [跳跃游戏 V](../../problems/jump-game-v) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1335 | [工作计划的最低难度](../../problems/minimum-difficulty-of-a-job-schedule) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1326 | [灌溉花园的最少水龙头数目](../../problems/minimum-number-of-taps-to-open-to-water-a-garden) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1320 | [二指输入的的最小距离](../../problems/minimum-distance-to-type-a-word-using-two-fingers) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1314 | [矩阵区域和](../../problems/matrix-block-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1312 | [让字符串成为回文串的最少插入次数](../../problems/minimum-insertion-steps-to-make-a-string-palindrome) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index 29f1f46a0..46ae8c5ba 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1334 | [阈值距离内邻居最少的城市](../../problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | [[图](../graph/README.md)] | Medium | | 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 1874d4171..2e8dc11ce 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1326 | [灌溉花园的最少水龙头数目](../../problems/minimum-number-of-taps-to-open-to-water-a-garden) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1282 | [用户分组](../../problems/group-the-people-given-the-group-size-they-belong-to) | [[贪心算法](../greedy/README.md)] | Medium | | 1276 | [不浪费原料的汉堡制作方案](../../problems/number-of-burgers-with-no-waste-of-ingredients) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 7cc0c2a34..bf444c7fc 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1330 | [翻转子数组得到最大的数组值](../../problems/reverse-subarray-to-maximize-array-value) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1323 | [6 和 9 组成的最大数字](../../problems/maximum-69-number) | [[数学](../math/README.md)] | Easy | | 1317 | [将整数转换为两个无零整数的和](../../problems/convert-integer-to-the-sum-of-two-no-zero-integers) | [[数学](../math/README.md)] | Easy | | 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1281 | [整数的各位积和之差](../../problems/subtract-the-product-and-sum-of-digits-of-an-integer) | [[数学](../math/README.md)] | Easy | diff --git a/tag/sort/README.md b/tag/sort/README.md index 66714adb4..8bd489283 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1333 | [餐厅过滤器](../../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1329 | [将矩阵按对角线排序](../../problems/sort-the-matrix-diagonally) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[排序](../sort/README.md)] [[树](../tree/README.md)] | Medium | | 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/string/README.md b/tag/string/README.md index fb2e0f732..56d5bf36b 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1332 | [删除回文子序列](../../problems/remove-palindromic-subsequences) | [[字符串](../string/README.md)] | Easy | +| 1328 | [破坏回文串](../../problems/break-a-palindrome) | [[字符串](../string/README.md)] | Medium | +| 1324 | [竖直打印单词](../../problems/print-words-vertically) | [[字符串](../string/README.md)] | Medium | | 1316 | [不同的循环子字符串](../../problems/distinct-echo-substrings) | [[字符串](../string/README.md)] | Hard | | 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1309 | [解码字母到整数映射](../../problems/decrypt-string-from-alphabet-to-integer-mapping) | [[字符串](../string/README.md)] | Easy | diff --git a/tag/tree/README.md b/tag/tree/README.md index 8a85b87d4..78d48cd39 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1325 | [删除给定值的叶子节点](../../problems/delete-leaves-with-a-given-value) | [[树](../tree/README.md)] | Medium | | 1315 | [祖父节点值为偶数的节点和](../../problems/sum-of-nodes-with-even-valued-grandparent) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[排序](../sort/README.md)] [[树](../tree/README.md)] | Medium | | 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | From 6117b666391b4dc58bbbc971ebbd9ec599a07e9c Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 4 Feb 2020 17:34:56 +0800 Subject: [PATCH 032/145] Add: desc --- problems/ads-performance/README.md | 56 +++++++++++++ .../README.md | 76 ++++++++++++++++++ .../README.md | 80 +++++++++++++++++++ 3 files changed, 212 insertions(+) diff --git a/problems/ads-performance/README.md b/problems/ads-performance/README.md index 17c8661d2..713d3a9a8 100644 --- a/problems/ads-performance/README.md +++ b/problems/ads-performance/README.md @@ -11,4 +11,60 @@ ## [1322. Ads Performance (Easy)](https://leetcode.com/problems/ads-performance "") +

Table: Ads

+
++---------------+---------+
+| Column Name   | Type    |
++---------------+---------+
+| ad_id         | int     |
+| user_id       | int     |
+| action        | enum    |
++---------------+---------+
+(ad_id, user_id) is the primary key for this table.
+Each row of this table contains the ID of an Ad, the ID of a user and the action taken by this user regarding this Ad.
+The action column is an ENUM type of ('Clicked', 'Viewed', 'Ignored').
+
+ +A company is running Ads and wants to calculate the performance of each Ad. +Performance of the Ad is measured using Click-Through Rate (CTR) where: + +[[image-blog:Leetcode: Ads Performance][https://raw.githubusercontent.com/dennyzhang/code.dennyzhang.com/master/problems/ads-performance/ctrformula.png]] + +Write an SQL query to find the ctr of each Ad. + +Round ctr to 2 decimal points. Order the result table by ctr in descending order and by ad_id in ascending order in case of a tie. + +The query result format is in the following example: +
+Ads table:
++-------+---------+---------+
+| ad_id | user_id | action  |
++-------+---------+---------+
+| 1     | 1       | Clicked |
+| 2     | 2       | Clicked |
+| 3     | 3       | Viewed  |
+| 5     | 5       | Ignored |
+| 1     | 7       | Ignored |
+| 2     | 7       | Viewed  |
+| 3     | 5       | Clicked |
+| 1     | 4       | Viewed  |
+| 2     | 11      | Viewed  |
+| 1     | 2       | Clicked |
++-------+---------+---------+
+Result table:
++-------+-------+
+| ad_id | ctr   |
++-------+-------+
+| 1     | 66.67 |
+| 3     | 50.00 |
+| 2     | 33.33 |
+| 5     | 0.00  |
++-------+-------+
+for ad_id = 1, ctr = (2/(2+1)) * 100 = 66.67
+for ad_id = 2, ctr = (1/(1+2)) * 100 = 33.33
+for ad_id = 3, ctr = (1/(1+1)) * 100 = 50.00
+for ad_id = 5, ctr = 0.00, Note that ad_id has no clicks or views.
+Note that we don't care about Ignored Ads.
+Result table is ordered by the ctr. in case of a tie we order them by ad_id
+
diff --git a/problems/list-the-products-ordered-in-a-period/README.md b/problems/list-the-products-ordered-in-a-period/README.md index e33dfda4b..acfd83aae 100644 --- a/problems/list-the-products-ordered-in-a-period/README.md +++ b/problems/list-the-products-ordered-in-a-period/README.md @@ -11,4 +11,80 @@ ## [1327. List the Products Ordered in a Period (Easy)](https://leetcode.com/problems/list-the-products-ordered-in-a-period "") +SQL Schema +

Table: Products

+
++------------------+---------+
+| Column Name      | Type    |
++------------------+---------+
+| product_id       | int     |
+| product_name     | varchar |
+| product_category | varchar |
++------------------+---------+
+product_id is the primary key for this table.
+This table contains data about the company's products.
+
+

Table: Orders

+
++---------------+---------+
+| Column Name   | Type    |
++---------------+---------+
+| product_id    | int     |
+| order_date    | date    |
+| unit          | int     |
++---------------+---------+
+There is no primary key for this table. It may have duplicate rows.
+product_id is a foreign key to Products table.
+unit is the number of products ordered in order_date.
+
+ +Write an SQL query to get the names of products with greater than or equal to 100 units ordered in February 2020 and their amount. + +Return result table in any order. + +The query result format is in the following example: +
+Products table:
++-------------+-----------------------+------------------+
+| product_id  | product_name          | product_category |
++-------------+-----------------------+------------------+
+| 1           | Leetcode Solutions    | Book             |
+| 2           | Jewels of Stringology | Book             |
+| 3           | HP                    | Laptop           |
+| 4           | Lenovo                | Laptop           |
+| 5           | Leetcode Kit          | T-shirt          |
++-------------+-----------------------+------------------+
+
+Orders table:
++--------------+--------------+----------+
+| product_id   | order_date   | unit     |
++--------------+--------------+----------+
+| 1            | 2020-02-05   | 60       |
+| 1            | 2020-02-10   | 70       |
+| 2            | 2020-01-18   | 30       |
+| 2            | 2020-02-11   | 80       |
+| 3            | 2020-02-17   | 2        |
+| 3            | 2020-02-24   | 3        |
+| 4            | 2020-03-01   | 20       |
+| 4            | 2020-03-04   | 30       |
+| 4            | 2020-03-04   | 60       |
+| 5            | 2020-02-25   | 50       |
+| 5            | 2020-02-27   | 50       |
+| 5            | 2020-03-01   | 50       |
++--------------+--------------+----------+
+
+Result table:
++--------------------+---------+
+| product_name       | unit    |
++--------------------+---------+
+| Leetcode Solutions | 130     |
+| Leetcode Kit       | 100     |
++--------------------+---------+
+
+Products with product_id = 1 is ordered in February a total of (60 + 70) = 130.
+Products with product_id = 2 is ordered in February a total of 80.
+Products with product_id = 3 is ordered in February a total of (2 + 3) = 5.
+Products with product_id = 4 was not ordered in February 2020.
+Products with product_id = 5 is ordered in February a total of (50 + 50) = 100.
+
diff --git a/problems/number-of-transactions-per-visit/README.md b/problems/number-of-transactions-per-visit/README.md index 21309d506..f730c2508 100644 --- a/problems/number-of-transactions-per-visit/README.md +++ b/problems/number-of-transactions-per-visit/README.md @@ -11,4 +11,84 @@ ## [1336. Number of Transactions per Visit (Medium)](https://leetcode.com/problems/number-of-transactions-per-visit "") +

Table: Visits

+
++---------------+---------+
+| Column Name   | Type    |
++---------------+---------+
+| user_id       | int     |
+| visit_date    | date    |
++---------------+---------+
+(user_id, visit_date) is the primary key for this table.
+Each row of this table indicates that user_id has visited the bank in visit_date.
+
+

Table: Transactions

+
++------------------+---------+
+| Column Name      | Type    |
++------------------+---------+
+| user_id          | int     |
+| transaction_date | date    |
+| amount           | int     |
++------------------+---------+
+There is no primary key for this table, it may contain duplicates.
+Each row of this table indicates that user_id has done a transaction of amount in transaction_date.
+It is guaranteed that the user has visited the bank in the transaction_date.(i.e The Visits table contains (user_id, transaction_date) in one row)
+
+ +Write an SQL query to find how many users visited the bank and didn't do any transactions, how many visited the bank and did one transaction and so on. + +The result table will contain two columns transactions_count which is the number of transactions done in one visit and visits_count which is the corresponding number of users who did transactions_count in one visit to the bank. transactions_count should take all values from 0 to max(transactions_count) done by one or more users. + +Order the result table by transactions_count. + +The query result format is in the following example: + +
+Visits table:
++---------+------------+
+| user_id | visit_date |
++---------+------------+
+| 1       | 2020-01-01 |
+| 2       | 2020-01-02 |
+| 12      | 2020-01-01 |
+| 19      | 2020-01-03 |
+| 1       | 2020-01-02 |
+| 2       | 2020-01-03 |
+| 1       | 2020-01-04 |
+| 7       | 2020-01-11 |
+| 9       | 2020-01-25 |
+| 8       | 2020-01-28 |
++---------+------------+
+Transactions table:
++---------+------------------+--------+
+| user_id | transaction_date | amount |
++---------+------------------+--------+
+| 1       | 2020-01-02       | 120    |
+| 2       | 2020-01-03       | 22     |
+| 7       | 2020-01-11       | 232    |
+| 1       | 2020-01-04       | 7      |
+| 9       | 2020-01-25       | 33     |
+| 9       | 2020-01-25       | 66     |
+| 8       | 2020-01-28       | 1      |
+| 9       | 2020-01-25       | 99     |
++---------+------------------+--------+
+Result table:
++--------------------+--------------+
+| transactions_count | visits_count |
++--------------------+--------------+
+| 0                  | 4            |
+| 1                  | 5            |
+| 2                  | 0            |
+| 3                  | 1            |
++--------------------+--------------+
+Users 1, 2, 12 and 19 visited the bank in 2020-01-01, 2020-01-02, 2020-01-01 and 2020-01-03 respectively, and didn't do any transactions.
+So we have visits_count = 4 for transactions_count = 0.
+Users 2, 7 and 8 visited the bank in 2020-01-03, 2020-01-11 and 2020-01-28 respectively, and did one transaction.
+User 1 Also visited the bank in 2020-01-02 and 2020-01-04 and did one transaction each day.
+So we have total visits_count = 5 for transactions_count = 1.
+For transactions_count = 2 we don't have any users who visited the bank and did two transactions.
+For transactions_count = 3 we have user 9 who visited the bank in 2020-01-25 and did three transactions.
+Note that we stopped at transactions_count = 3 as this is the maximum number of transactions done by one user in one visit to the bank.
+
From 6d11c3aaa0b7ab68ccbe319cf30f631079dac72e Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 13 Feb 2020 09:51:36 +0800 Subject: [PATCH 033/145] Add: new --- README.md | 15 +++- .../angle-between-hands-of-a-clock/README.md | 79 +++++++++++++++++ .../check-if-n-and-its-double-exist/README.md | 69 +++++++++++++++ problems/counting-bits/README.md | 2 +- problems/intersection-of-two-arrays/README.md | 2 +- problems/jump-game-iv/README.md | 87 +++++++++++++++++++ problems/jump-game-v/README.md | 2 +- .../README.md | 2 +- .../maximum-students-taking-exam/README.md | 79 +++++++++++++++++ .../README.md | 80 +++++++++++++++++ problems/movie-rating/README.md | 14 +++ problems/movie-rating/mysql_schemas.sql | 22 +++++ .../README.md | 64 ++++++++++++++ .../README.md | 78 +++++++++++++++++ .../README.md | 2 +- .../queries-quality-and-percentage/README.md | 2 +- problems/tweet-counts-per-frequency/README.md | 62 +++++++++++++ .../x-of-a-kind-in-a-deck-of-cards/README.md | 65 +++++--------- tag/array/README.md | 2 + tag/bit-manipulation/README.md | 1 + tag/breadth-first-search/README.md | 1 + tag/design/README.md | 1 + tag/dynamic-programming/README.md | 1 + tag/math/README.md | 1 + tag/string/README.md | 1 + 25 files changed, 683 insertions(+), 51 deletions(-) create mode 100644 problems/angle-between-hands-of-a-clock/README.md create mode 100644 problems/check-if-n-and-its-double-exist/README.md create mode 100644 problems/jump-game-iv/README.md create mode 100644 problems/maximum-students-taking-exam/README.md create mode 100644 problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md create mode 100644 problems/movie-rating/README.md create mode 100644 problems/movie-rating/mysql_schemas.sql create mode 100644 problems/number-of-steps-to-reduce-a-number-to-zero/README.md create mode 100644 problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md create mode 100644 problems/tweet-counts-per-frequency/README.md diff --git a/README.md b/README.md index 02d19b0a3..5f49225c2 100644 --- a/README.md +++ b/README.md @@ -62,11 +62,20 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1349 | [Maximum Students Taking Exam](https://leetcode.com/problems/maximum-students-taking-exam "参加考试的最大学生数") | [Go](problems/maximum-students-taking-exam) | Hard | +| 1348 | [Tweet Counts Per Frequency](https://leetcode.com/problems/tweet-counts-per-frequency "推文计数") | [Go](problems/tweet-counts-per-frequency) | Medium | +| 1347 | [Minimum Number of Steps to Make Two Strings Anagram](https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram "制造字母异位词的最小步骤数") | [Go](problems/minimum-number-of-steps-to-make-two-strings-anagram) | Medium | +| 1346 | [Check If N and Its Double Exist](https://leetcode.com/problems/check-if-n-and-its-double-exist "检查整数及其两倍数是否存在") | [Go](problems/check-if-n-and-its-double-exist) | Easy | +| 1345 | [Jump Game IV](https://leetcode.com/problems/jump-game-iv "跳跃游戏 IV") | [Go](problems/jump-game-iv) | Hard | +| 1344 | [Angle Between Hands of a Clock](https://leetcode.com/problems/angle-between-hands-of-a-clock "时钟指针的夹角") | [Go](problems/angle-between-hands-of-a-clock) | Medium | +| 1343 | [Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold](https://leetcode.com/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold "大小为 K 且平均值大于等于阈值的子数组数目") | [Go](problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold) | Medium | +| 1342 | [Number of Steps to Reduce a Number to Zero](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero "将数字变成 0 的操作次数") | [Go](problems/number-of-steps-to-reduce-a-number-to-zero) | Easy | +| 1341 | [Movie Rating](https://leetcode.com/problems/movie-rating "电影评分") 🔒 | [MySQL](problems/movie-rating) | Medium | | 1340 | [Jump Game V](https://leetcode.com/problems/jump-game-v "跳跃游戏 V") | [Go](problems/jump-game-v) | Hard | | 1339 | [Maximum Product of Splitted Binary Tree](https://leetcode.com/problems/maximum-product-of-splitted-binary-tree "分裂二叉树的最大乘积") | [Go](problems/maximum-product-of-splitted-binary-tree) | Medium | | 1338 | [Reduce Array Size to The Half](https://leetcode.com/problems/reduce-array-size-to-the-half "数组大小减半") | [Go](problems/reduce-array-size-to-the-half) | Medium | | 1337 | [The K Weakest Rows in a Matrix](https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix "方阵中战斗力最弱的 K 行") | [Go](problems/the-k-weakest-rows-in-a-matrix) | Easy | -| 1336 | [Number of Transactions per Visit](https://leetcode.com/problems/number-of-transactions-per-visit) 🔒 | [MySQL](problems/number-of-transactions-per-visit) | Medium | +| 1336 | [Number of Transactions per Visit](https://leetcode.com/problems/number-of-transactions-per-visit) 🔒 | [MySQL](problems/number-of-transactions-per-visit) | Hard | | 1335 | [Minimum Difficulty of a Job Schedule](https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule "工作计划的最低难度") | [Go](problems/minimum-difficulty-of-a-job-schedule) | Hard | | 1334 | [Find the City With the Smallest Number of Neighbors at a Threshold Distance](https://leetcode.com/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance "阈值距离内邻居最少的城市") | [Go](problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | Medium | | 1333 | [Filter Restaurants by Vegan-Friendly, Price and Distance](https://leetcode.com/problems/filter-restaurants-by-vegan-friendly-price-and-distance "餐厅过滤器") | [Go](problems/filter-restaurants-by-vegan-friendly-price-and-distance) | Medium | @@ -191,14 +200,14 @@ LeetCode Problems' Solutions | 1214 | [Two Sum BSTs](https://leetcode.com/problems/two-sum-bsts "查找两棵二叉搜索树之和") 🔒 | [Go](problems/two-sum-bsts) | Medium | | 1213 | [Intersection of Three Sorted Arrays](https://leetcode.com/problems/intersection-of-three-sorted-arrays "三个有序数组的交集") 🔒 | [Go](problems/intersection-of-three-sorted-arrays) | Easy | | 1212 | [Team Scores in Football Tournament](https://leetcode.com/problems/team-scores-in-football-tournament "查询球队积分") 🔒 | [MySQL](problems/team-scores-in-football-tournament) | Medium | -| 1211 | [Queries Quality and Percentage](https://leetcode.com/problems/queries-quality-and-percentage) 🔒 | [MySQL](problems/queries-quality-and-percentage) | Easy | +| 1211 | [Queries Quality and Percentage](https://leetcode.com/problems/queries-quality-and-percentage "查询结果的质量和占比") 🔒 | [MySQL](problems/queries-quality-and-percentage) | Easy | | 1210 | [Minimum Moves to Reach Target with Rotations](https://leetcode.com/problems/minimum-moves-to-reach-target-with-rotations "穿过迷宫的最少移动次数") | [Go](problems/minimum-moves-to-reach-target-with-rotations) | Hard | | 1209 | [Remove All Adjacent Duplicates in String II](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii "删除字符串中的所有相邻重复项 II") | [Go](problems/remove-all-adjacent-duplicates-in-string-ii) | Medium | | 1208 | [Get Equal Substrings Within Budget](https://leetcode.com/problems/get-equal-substrings-within-budget "尽可能使字符串相等") | [Go](problems/get-equal-substrings-within-budget) | Medium | | 1207 | [Unique Number of Occurrences](https://leetcode.com/problems/unique-number-of-occurrences "独一无二的出现次数") | [Go](problems/unique-number-of-occurrences) | Easy | | 1206 | [Design Skiplist](https://leetcode.com/problems/design-skiplist "设计跳表") | [Go](problems/design-skiplist) | Hard | | 1205 | [Monthly Transactions II](https://leetcode.com/problems/monthly-transactions-ii "每月交易II") 🔒 | [MySQL](problems/monthly-transactions-ii) | Medium | -| 1204 | [Last Person to Fit in the Elevator](https://leetcode.com/problems/last-person-to-fit-in-the-elevator) 🔒 | [MySQL](problems/last-person-to-fit-in-the-elevator) | Medium | +| 1204 | [Last Person to Fit in the Elevator](https://leetcode.com/problems/last-person-to-fit-in-the-elevator "最后一个能进入电梯的人") 🔒 | [MySQL](problems/last-person-to-fit-in-the-elevator) | Medium | | 1203 | [Sort Items by Groups Respecting Dependencies](https://leetcode.com/problems/sort-items-by-groups-respecting-dependencies "项目管理") | [Go](problems/sort-items-by-groups-respecting-dependencies) | Hard | | 1202 | [Smallest String With Swaps](https://leetcode.com/problems/smallest-string-with-swaps "交换字符串中的元素") | [Go](problems/smallest-string-with-swaps) | Medium | | 1201 | [Ugly Number III](https://leetcode.com/problems/ugly-number-iii "丑数 III") | [Go](problems/ugly-number-iii) | Medium | diff --git a/problems/angle-between-hands-of-a-clock/README.md b/problems/angle-between-hands-of-a-clock/README.md new file mode 100644 index 000000000..b78b0d9d9 --- /dev/null +++ b/problems/angle-between-hands-of-a-clock/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold "Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold") +                 +[Next >](../jump-game-iv "Jump Game IV") + +## [1344. Angle Between Hands of a Clock (Medium)](https://leetcode.com/problems/angle-between-hands-of-a-clock "时钟指针的夹角") + +

Given two numbers, hour and minutes. Return the smaller angle (in sexagesimal units) formed between the hour and the minute hand.

+ +

 

+

Example 1:

+ +

+ +
+Input: hour = 12, minutes = 30
+Output: 165
+
+ +

Example 2:

+ +

+ +
+Input: hour = 3, minutes = 30
+Output: 75
+
+ +

Example 3:

+ +

+ +
+Input: hour = 3, minutes = 15
+Output: 7.5
+
+ +

Example 4:

+ +
+Input: hour = 4, minutes = 50
+Output: 155
+
+ +

Example 5:

+ +
+Input: hour = 12, minutes = 0
+Output: 0
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= hour <= 12
  • +
  • 0 <= minutes <= 59
  • +
  • Answers within 10^-5 of the actual value will be accepted as correct.
  • +
+ +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
+Hint 1 +The tricky part is determining how the minute hand affects the position of the hour hand. +
+ +
+Hint 2 +Calculate the angles separately then find the difference. +
diff --git a/problems/check-if-n-and-its-double-exist/README.md b/problems/check-if-n-and-its-double-exist/README.md new file mode 100644 index 000000000..f0125d228 --- /dev/null +++ b/problems/check-if-n-and-its-double-exist/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../jump-game-iv "Jump Game IV") +                 +[Next >](../minimum-number-of-steps-to-make-two-strings-anagram "Minimum Number of Steps to Make Two Strings Anagram") + +## [1346. Check If N and Its Double Exist (Easy)](https://leetcode.com/problems/check-if-n-and-its-double-exist "检查整数及其两倍数是否存在") + +

Given an array arr of integers, check if there exists two integers N and M such that N is the double of M ( i.e. N = 2 * M).

+ +

More formally check if there exists two indices i and j such that :

+ +
    +
  • i != j
  • +
  • 0 <= i, j < arr.length
  • +
  • arr[i] == 2 * arr[j]
  • +
+ +

 

+

Example 1:

+ +
+Input: arr = [10,2,5,3]
+Output: true
+Explanation: N = 10 is the double of M = 5,that is, 10 = 2 * 5.
+
+ +

Example 2:

+ +
+Input: arr = [7,1,14,11]
+Output: true
+Explanation: N = 14 is the double of M = 7,that is, 14 = 2 * 7.
+
+ +

Example 3:

+ +
+Input: arr = [3,1,7,11]
+Output: false
+Explanation: In this case does not exist N and M, such that N = 2 * M.
+
+ +

 

+

Constraints:

+ +
    +
  • 2 <= arr.length <= 500
  • +
  • -10^3 <= arr[i] <= 10^3
  • +
+ +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
+Hint 1 +Loop from i = 0 to arr.length, maintaining in a hashTable the array elements from [0, i - 1]. +
+ +
+Hint 2 +On each step of the loop check if we have seen the element 2 * arr[i] so far or arr[i] / 2 was seen if arr[i] % 2 == 0. +
diff --git a/problems/counting-bits/README.md b/problems/counting-bits/README.md index e8d6a286b..9169d1a68 100644 --- a/problems/counting-bits/README.md +++ b/problems/counting-bits/README.md @@ -35,8 +35,8 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Number of 1 Bits](../number-of-1-bits) (Easy) diff --git a/problems/intersection-of-two-arrays/README.md b/problems/intersection-of-two-arrays/README.md index 09355375f..26f036111 100644 --- a/problems/intersection-of-two-arrays/README.md +++ b/problems/intersection-of-two-arrays/README.md @@ -38,10 +38,10 @@

 

### Related Topics - [[Sort](../../tag/sort/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Sort](../../tag/sort/README.md)] ### Similar Questions 1. [Intersection of Two Arrays II](../intersection-of-two-arrays-ii) (Easy) diff --git a/problems/jump-game-iv/README.md b/problems/jump-game-iv/README.md new file mode 100644 index 000000000..1e5d81d6d --- /dev/null +++ b/problems/jump-game-iv/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../angle-between-hands-of-a-clock "Angle Between Hands of a Clock") +                 +[Next >](../check-if-n-and-its-double-exist "Check If N and Its Double Exist") + +## [1345. Jump Game IV (Hard)](https://leetcode.com/problems/jump-game-iv "跳跃游戏 IV") + +

Given an array of integers arr, you are initially positioned at the first index of the array.

+ +

In one step you can jump from index i to index:

+ +
    +
  • i + 1 where: i + 1 < arr.length.
  • +
  • i - 1 where: i - 1 >= 0.
  • +
  • j where: arr[i] == arr[j] and i != j.
  • +
+ +

Return the minimum number of steps to reach the last index of the array.

+ +

Notice that you can not jump outside of the array at any time.

+ +

 

+

Example 1:

+ +
+Input: arr = [100,-23,-23,404,100,23,23,23,3,404]
+Output: 3
+Explanation: You need three jumps from index 0 --> 4 --> 3 --> 9. Note that index 9 is the last index of the array.
+
+ +

Example 2:

+ +
+Input: arr = [7]
+Output: 0
+Explanation: Start index is the last index. You don't need to jump.
+
+ +

Example 3:

+ +
+Input: arr = [7,6,9,6,9,6,9,7]
+Output: 1
+Explanation: You can jump directly from index 0 to index 7 which is last index of the array.
+
+ +

Example 4:

+ +
+Input: arr = [6,1,9]
+Output: 2
+
+ +

Example 5:

+ +
+Input: arr = [11,22,7,7,7,7,7,7,7,22,13]
+Output: 3
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= arr.length <= 5 * 10^4
  • +
  • -10^8 <= arr[i] <= 10^8
  • +
+ +### Related Topics + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + +### Hints +
+Hint 1 +Build a graph of n nodes where nodes are the indices of the array and edges for node i are nodes i+1, i-1, j where arr[i] == arr[j]. +
+ +
+Hint 2 +Start bfs from node 0 and keep distance, answer is the distance when you reach onode n-1. +
diff --git a/problems/jump-game-v/README.md b/problems/jump-game-v/README.md index b30bfe79c..177bf0404 100644 --- a/problems/jump-game-v/README.md +++ b/problems/jump-game-v/README.md @@ -7,7 +7,7 @@ [< Previous](../maximum-product-of-splitted-binary-tree "Maximum Product of Splitted Binary Tree")                  -Next > +[Next >](../movie-rating "Movie Rating") ## [1340. Jump Game V (Hard)](https://leetcode.com/problems/jump-game-v "跳跃游戏 V") diff --git a/problems/last-person-to-fit-in-the-elevator/README.md b/problems/last-person-to-fit-in-the-elevator/README.md index bb8211854..0d8f8558c 100644 --- a/problems/last-person-to-fit-in-the-elevator/README.md +++ b/problems/last-person-to-fit-in-the-elevator/README.md @@ -9,7 +9,7 @@                  [Next >](../monthly-transactions-ii "Monthly Transactions II") -## [1204. Last Person to Fit in the Elevator (Medium)](https://leetcode.com/problems/last-person-to-fit-in-the-elevator "") +## [1204. Last Person to Fit in the Elevator (Medium)](https://leetcode.com/problems/last-person-to-fit-in-the-elevator "最后一个能进入电梯的人")

Table: Queue

diff --git a/problems/maximum-students-taking-exam/README.md b/problems/maximum-students-taking-exam/README.md new file mode 100644 index 000000000..42528f4fb --- /dev/null +++ b/problems/maximum-students-taking-exam/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../tweet-counts-per-frequency "Tweet Counts Per Frequency") +                 +Next > + +## [1349. Maximum Students Taking Exam (Hard)](https://leetcode.com/problems/maximum-students-taking-exam "参加考试的最大学生数") + +

Given a m * n matrix seats  that represent seats distributions in a classroom. If a seat is broken, it is denoted by '#' character otherwise it is denoted by a '.' character.

+ +

Students can see the answers of those sitting next to the left, right, upper left and upper right, but he cannot see the answers of the student sitting directly in front or behind him. Return the maximum number of students that can take the exam together without any cheating being possible..

+ +

Students must be placed in seats in good condition.

+ +

 

+

Example 1:

+ +
+Input: seats = [["#",".","#","#",".","#"],
+                [".","#","#","#","#","."],
+                ["#",".","#","#",".","#"]]
+Output: 4
+Explanation: Teacher can place 4 students in available seats so they don't cheat on the exam. 
+
+ +

Example 2:

+ +
+Input: seats = [[".","#"],
+                ["#","#"],
+                ["#","."],
+                ["#","#"],
+                [".","#"]]
+Output: 3
+Explanation: Place all students in available seats. 
+
+
+ +

Example 3:

+ +
+Input: seats = [["#",".",".",".","#"],
+                [".","#",".","#","."],
+                [".",".","#",".","."],
+                [".","#",".","#","."],
+                ["#",".",".",".","#"]]
+Output: 10
+Explanation: Place students in available seats in column 1, 3 and 5.
+
+ +

 

+

Constraints:

+ +
    +
  • seats contains only characters '.' and'#'.
  • +
  • m == seats.length
  • +
  • n == seats[i].length
  • +
  • 1 <= m <= 8
  • +
  • 1 <= n <= 8
  • +
+ +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
+Hint 1 +Students in row i only can see exams in row i+1. +
+ +
+Hint 2 +Use Dynamic programming to compute the result given a (current row, bitmask people seated in previous row). +
diff --git a/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md b/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md new file mode 100644 index 000000000..6923d359f --- /dev/null +++ b/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../check-if-n-and-its-double-exist "Check If N and Its Double Exist") +                 +[Next >](../tweet-counts-per-frequency "Tweet Counts Per Frequency") + +## [1347. Minimum Number of Steps to Make Two Strings Anagram (Medium)](https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram "制造字母异位词的最小步骤数") + +

Given two equal-size strings s and t. In one step you can choose any character of t and replace it with another character.

+ +

Return the minimum number of steps to make t an anagram of s.

+ +

An Anagram of a string is a string that contains the same characters with a different (or the same) ordering.

+ +

 

+

Example 1:

+ +
+Input: s = "bab", t = "aba"
+Output: 1
+Explanation: Replace the first 'a' in t with b, t = "bba" which is anagram of s.
+
+ +

Example 2:

+ +
+Input: s = "leetcode", t = "practice"
+Output: 5
+Explanation: Replace 'p', 'r', 'a', 'i' and 'c' from t with proper characters to make t anagram of s.
+
+ +

Example 3:

+ +
+Input: s = "anagram", t = "mangaar"
+Output: 0
+Explanation: "anagram" and "mangaar" are anagrams. 
+
+ +

Example 4:

+ +
+Input: s = "xxyyzz", t = "xxyyzz"
+Output: 0
+
+ +

Example 5:

+ +
+Input: s = "friend", t = "family"
+Output: 4
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= s.length <= 50000
  • +
  • s.length == t.length
  • +
  • s and t contain lower-case English letters only.
  • +
+ +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
+Hint 1 +Count the frequency of characters of each string. +
+ +
+Hint 2 +Loop over all characters if the frequency of a character in t is less than the frequency of the same character in s then add the difference between the frequencies to the answer. +
diff --git a/problems/movie-rating/README.md b/problems/movie-rating/README.md new file mode 100644 index 000000000..7d825c727 --- /dev/null +++ b/problems/movie-rating/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../jump-game-v "Jump Game V") +                 +[Next >](../number-of-steps-to-reduce-a-number-to-zero "Number of Steps to Reduce a Number to Zero") + +## [1341. Movie Rating (Medium)](https://leetcode.com/problems/movie-rating "电影评分") + + diff --git a/problems/movie-rating/mysql_schemas.sql b/problems/movie-rating/mysql_schemas.sql new file mode 100644 index 000000000..03c2afee1 --- /dev/null +++ b/problems/movie-rating/mysql_schemas.sql @@ -0,0 +1,22 @@ +Create table If Not Exists Movies (movie_id int, title varchar(30)); +Create table If Not Exists Users (user_id int, name varchar(30)); +Create table If Not Exists Movie_Rating (movie_id int, user_id int, rating int, created_at date); +Truncate table Movies; +insert into Movies (movie_id, title) values ('1', 'Avengers'); +insert into Movies (movie_id, title) values ('2', 'Frozen 2'); +insert into Movies (movie_id, title) values ('3', 'Joker'); +Truncate table Users; +insert into Users (user_id, name) values ('1', 'Daniel'); +insert into Users (user_id, name) values ('2', 'Monica'); +insert into Users (user_id, name) values ('3', 'Maria'); +insert into Users (user_id, name) values ('4', 'James'); +Truncate table Movie_Rating; +insert into Movie_Rating (movie_id, user_id, rating, created_at) values ('1', '1', '3', '2020-01-12'); +insert into Movie_Rating (movie_id, user_id, rating, created_at) values ('1', '2', '4', '2020-02-11'); +insert into Movie_Rating (movie_id, user_id, rating, created_at) values ('1', '3', '2', '2020-02-12'); +insert into Movie_Rating (movie_id, user_id, rating, created_at) values ('1', '4', '1', '2020-01-01'); +insert into Movie_Rating (movie_id, user_id, rating, created_at) values ('2', '1', '5', '2020-02-17'); +insert into Movie_Rating (movie_id, user_id, rating, created_at) values ('2', '2', '2', '2020-02-01'); +insert into Movie_Rating (movie_id, user_id, rating, created_at) values ('2', '3', '2', '2020-03-01'); +insert into Movie_Rating (movie_id, user_id, rating, created_at) values ('3', '1', '3', '2020-02-22'); +insert into Movie_Rating (movie_id, user_id, rating, created_at) values ('3', '2', '4', '2020-02-25'); diff --git a/problems/number-of-steps-to-reduce-a-number-to-zero/README.md b/problems/number-of-steps-to-reduce-a-number-to-zero/README.md new file mode 100644 index 000000000..e32d8d282 --- /dev/null +++ b/problems/number-of-steps-to-reduce-a-number-to-zero/README.md @@ -0,0 +1,64 @@ + + + + + + + +[< Previous](../movie-rating "Movie Rating") +                 +[Next >](../number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold "Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold") + +## [1342. Number of Steps to Reduce a Number to Zero (Easy)](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero "将数字变成 0 的操作次数") + +

Given a non-negative integer num, return the number of steps to reduce it to zero. If the current number is even, you have to divide it by 2, otherwise, you have to subtract 1 from it.

+ +

 

+

Example 1:

+ +
+Input: num = 14
+Output: 6
+Explanation: 
+Step 1) 14 is even; divide by 2 and obtain 7. 
+Step 2) 7 is odd; subtract 1 and obtain 6.
+Step 3) 6 is even; divide by 2 and obtain 3. 
+Step 4) 3 is odd; subtract 1 and obtain 2. 
+Step 5) 2 is even; divide by 2 and obtain 1. 
+Step 6) 1 is odd; subtract 1 and obtain 0.
+
+ +

Example 2:

+ +
+Input: num = 8
+Output: 4
+Explanation: 
+Step 1) 8 is even; divide by 2 and obtain 4. 
+Step 2) 4 is even; divide by 2 and obtain 2. 
+Step 3) 2 is even; divide by 2 and obtain 1. 
+Step 4) 1 is odd; subtract 1 and obtain 0.
+
+ +

Example 3:

+ +
+Input: num = 123
+Output: 12
+
+ +

 

+

Constraints:

+ +
    +
  • 0 <= num <= 10^6
  • +
+ +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + +### Hints +
+Hint 1 +Simulate the process to get the final answer. +
diff --git a/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md b/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md new file mode 100644 index 000000000..8049a016c --- /dev/null +++ b/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../number-of-steps-to-reduce-a-number-to-zero "Number of Steps to Reduce a Number to Zero") +                 +[Next >](../angle-between-hands-of-a-clock "Angle Between Hands of a Clock") + +## [1343. Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold (Medium)](https://leetcode.com/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold "大小为 K 且平均值大于等于阈值的子数组数目") + +

Given an array of integers arr and two integers k and threshold.

+ +

Return the number of sub-arrays of size k and average greater than or equal to threshold.

+ +

 

+

Example 1:

+ +
+Input: arr = [2,2,2,2,5,5,5,8], k = 3, threshold = 4
+Output: 3
+Explanation: Sub-arrays [2,5,5],[5,5,5] and [5,5,8] have averages 4, 5 and 6 respectively. All other sub-arrays of size 3 have averages less than 4 (the threshold).
+
+ +

Example 2:

+ +
+Input: arr = [1,1,1,1,1], k = 1, threshold = 0
+Output: 5
+
+ +

Example 3:

+ +
+Input: arr = [11,13,17,23,29,31,7,5,2,3], k = 3, threshold = 5
+Output: 6
+Explanation: The first 6 sub-arrays of size 3 have averages greater than 5. Note that averages are not integers.
+
+ +

Example 4:

+ +
+Input: arr = [7,7,7,7,7,7,7], k = 7, threshold = 7
+Output: 1
+
+ +

Example 5:

+ +
+Input: arr = [4,4,4,4], k = 4, threshold = 1
+Output: 1
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= arr.length <= 10^5
  • +
  • 1 <= arr[i] <= 10^4
  • +
  • 1 <= k <= arr.length
  • +
  • 0 <= threshold <= 10^4
  • +
+ +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
+Hint 1 +Start with a window of size K and test its average against the threshold. +
+ +
+Hint 2 +Keep moving the window by one element maintaining its size k until you cover the whole array. count number of windows that satisfy that its average is greater than the threshold. +
diff --git a/problems/number-of-transactions-per-visit/README.md b/problems/number-of-transactions-per-visit/README.md index f730c2508..fce4ce6f3 100644 --- a/problems/number-of-transactions-per-visit/README.md +++ b/problems/number-of-transactions-per-visit/README.md @@ -9,7 +9,7 @@                  [Next >](../the-k-weakest-rows-in-a-matrix "The K Weakest Rows in a Matrix") -## [1336. Number of Transactions per Visit (Medium)](https://leetcode.com/problems/number-of-transactions-per-visit "") +## [1336. Number of Transactions per Visit (Hard)](https://leetcode.com/problems/number-of-transactions-per-visit "")

Table: Visits

diff --git a/problems/queries-quality-and-percentage/README.md b/problems/queries-quality-and-percentage/README.md
index 508c9449b..8d7f56944 100644
--- a/problems/queries-quality-and-percentage/README.md
+++ b/problems/queries-quality-and-percentage/README.md
@@ -9,7 +9,7 @@
                 
 [Next >](../team-scores-in-football-tournament "Team Scores in Football Tournament")
 
-## [1211. Queries Quality and Percentage (Easy)](https://leetcode.com/problems/queries-quality-and-percentage "")
+## [1211. Queries Quality and Percentage (Easy)](https://leetcode.com/problems/queries-quality-and-percentage "查询结果的质量和占比")
 
 

Table: Queries

diff --git a/problems/tweet-counts-per-frequency/README.md b/problems/tweet-counts-per-frequency/README.md new file mode 100644 index 000000000..5c1992a42 --- /dev/null +++ b/problems/tweet-counts-per-frequency/README.md @@ -0,0 +1,62 @@ + + + + + + + +[< Previous](../minimum-number-of-steps-to-make-two-strings-anagram "Minimum Number of Steps to Make Two Strings Anagram") +                 +[Next >](../maximum-students-taking-exam "Maximum Students Taking Exam") + +## [1348. Tweet Counts Per Frequency (Medium)](https://leetcode.com/problems/tweet-counts-per-frequency "推文计数") + +

Implement the class TweetCounts that supports two methods:

+ +

1. recordTweet(string tweetName, int time)

+ +
    +
  • Stores the tweetName at the recorded time (in seconds).
  • +
+ +

2. getTweetCountsPerFrequency(string freq, string tweetName, int startTime, int endTime)

+ +
    +
  • Returns the total number of occurrences for the given tweetName per minute, hour, or day (depending on freq) starting from the startTime (in seconds) and ending at the endTime (in seconds).
  • +
  • freq is always minute, hour or day, representing the time interval to get the total number of occurrences for the given tweetName.
  • +
  • The first time interval always starts from the startTime, so the time intervals are [startTime, startTime + delta*1>,  [startTime + delta*1, startTime + delta*2>, [startTime + delta*2, startTime + delta*3>, ... , [startTime + delta*i, min(startTime + delta*(i+1), endTime + 1)> for some non-negative number i and delta (which depends on freq).  
  • +
+ +

 

+

Example:

+ +
+Input
+["TweetCounts","recordTweet","recordTweet","recordTweet","getTweetCountsPerFrequency","getTweetCountsPerFrequency","recordTweet","getTweetCountsPerFrequency"]
+[[],["tweet3",0],["tweet3",60],["tweet3",10],["minute","tweet3",0,59],["minute","tweet3",0,60],["tweet3",120],["hour","tweet3",0,210]]
+
+Output
+[null,null,null,null,[2],[2,1],null,[4]]
+
+Explanation
+TweetCounts tweetCounts = new TweetCounts();
+tweetCounts.recordTweet("tweet3", 0);
+tweetCounts.recordTweet("tweet3", 60);
+tweetCounts.recordTweet("tweet3", 10);                             // All tweets correspond to "tweet3" with recorded times at 0, 10 and 60.
+tweetCounts.getTweetCountsPerFrequency("minute", "tweet3", 0, 59); // return [2]. The frequency is per minute (60 seconds), so there is one interval of time: 1) [0, 60> - > 2 tweets.
+tweetCounts.getTweetCountsPerFrequency("minute", "tweet3", 0, 60); // return [2, 1]. The frequency is per minute (60 seconds), so there are two intervals of time: 1) [0, 60> - > 2 tweets, and 2) [60,61> - > 1 tweet.
+tweetCounts.recordTweet("tweet3", 120);                            // All tweets correspond to "tweet3" with recorded times at 0, 10, 60 and 120.
+tweetCounts.getTweetCountsPerFrequency("hour", "tweet3", 0, 210);  // return [4]. The frequency is per hour (3600 seconds), so there is one interval of time: 1) [0, 211> - > 4 tweets.
+
+ +

 

+

Constraints:

+ +
    +
  • There will be at most 10000 operations considering both recordTweet and getTweetCountsPerFrequency.
  • +
  • 0 <= time, startTime, endTime <= 10^9
  • +
  • 0 <= endTime - startTime <= 10^4
  • +
+ +### Related Topics + [[Design](../../tag/design/README.md)] diff --git a/problems/x-of-a-kind-in-a-deck-of-cards/README.md b/problems/x-of-a-kind-in-a-deck-of-cards/README.md index 5ae7dfdea..2cb334781 100644 --- a/problems/x-of-a-kind-in-a-deck-of-cards/README.md +++ b/problems/x-of-a-kind-in-a-deck-of-cards/README.md @@ -21,72 +21,53 @@

 

-

Example 1:

-Input: [1,2,3,4,4,3,2,1]
-Output: true
-Explanation: Possible partition [1,1],[2,2],[3,3],[4,4]
+Input: deck = [1,2,3,4,4,3,2,1]
+Output: true
+Explanation: Possible partition [1,1],[2,2],[3,3],[4,4].
 
-

Example 2:

-Input: [1,1,1,2,2,2,3,3]
-Output: false
-Explanation: No possible partition.
+Input: deck = [1,1,1,2,2,2,3,3]
+Output: false´
+Explanation: No possible partition.
 
-

Example 3:

-Input: [1]
-Output: false
-Explanation: No possible partition.
+Input: deck = [1]
+Output: false
+Explanation: No possible partition.
 
-

Example 4:

-Input: [1,1]
-Output: true
-Explanation: Possible partition [1,1]
+Input: deck = [1,1]
+Output: true
+Explanation: Possible partition [1,1].
 
-

Example 5:

-Input: [1,1,2,2,2,2]
-Output: true
-Explanation: Possible partition [1,1],[2,2],[2,2]
+Input: deck = [1,1,2,2,2,2]
+Output: true
+Explanation: Possible partition [1,1],[2,2],[2,2].
 
-
-
-
-
- -


-Note:

- -
    -
  1. 1 <= deck.length <= 10000
  2. -
  3. 0 <= deck[i] < 10000
  4. -
- -
-
-
-
-
 
-
-
-
-
+ +

 

+

Constraints:

+ +
    +
  • 1 <= deck.length <= 10^4
  • +
  • 0 <= deck[i] < 10^4
  • +
### Related Topics [[Array](../../tag/array/README.md)] diff --git a/tag/array/README.md b/tag/array/README.md index a5f55a21f..9db12f938 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1346 | [检查整数及其两倍数是否存在](../../problems/check-if-n-and-its-double-exist) | [[数组](../array/README.md)] | Easy | +| 1343 | [大小为 K 且平均值大于等于阈值的子数组数目](../../problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold) | [[数组](../array/README.md)] | Medium | | 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1337 | [方阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 1333 | [餐厅过滤器](../../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 560688625..9b9b4004c 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1342 | [将数字变成 0 的操作次数](../../problems/number-of-steps-to-reduce-a-number-to-zero) | [[位运算](../bit-manipulation/README.md)] | Easy | | 1318 | [或运算的最小翻转次数](../../problems/minimum-flips-to-make-a-or-b-equal-to-c) | [[位运算](../bit-manipulation/README.md)] | Medium | | 1310 | [子数组异或查询](../../problems/xor-queries-of-a-subarray) | [[位运算](../bit-manipulation/README.md)] | Medium | | 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index cfd690bd3..3b09315e2 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1345 | [跳跃游戏 IV](../../problems/jump-game-iv) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index 18652a73b..05840b149 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] | Medium | | 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1206 | [设计跳表](../../problems/design-skiplist) | [[设计](../design/README.md)] | Hard | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index ef7346fa4..da437ed7f 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1349 | [参加考试的最大学生数](../../problems/maximum-students-taking-exam) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1340 | [跳跃游戏 V](../../problems/jump-game-v) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1335 | [工作计划的最低难度](../../problems/minimum-difficulty-of-a-job-schedule) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/math/README.md b/tag/math/README.md index bf444c7fc..980532490 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1344 | [时钟指针的夹角](../../problems/angle-between-hands-of-a-clock) | [[数学](../math/README.md)] | Medium | | 1330 | [翻转子数组得到最大的数组值](../../problems/reverse-subarray-to-maximize-array-value) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1323 | [6 和 9 组成的最大数字](../../problems/maximum-69-number) | [[数学](../math/README.md)] | Easy | | 1317 | [将整数转换为两个无零整数的和](../../problems/convert-integer-to-the-sum-of-two-no-zero-integers) | [[数学](../math/README.md)] | Easy | diff --git a/tag/string/README.md b/tag/string/README.md index 56d5bf36b..a50d6891a 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1347 | [制造字母异位词的最小步骤数](../../problems/minimum-number-of-steps-to-make-two-strings-anagram) | [[字符串](../string/README.md)] | Medium | | 1332 | [删除回文子序列](../../problems/remove-palindromic-subsequences) | [[字符串](../string/README.md)] | Easy | | 1328 | [破坏回文串](../../problems/break-a-palindrome) | [[字符串](../string/README.md)] | Medium | | 1324 | [竖直打印单词](../../problems/print-words-vertically) | [[字符串](../string/README.md)] | Medium | From 1d64e8139b2ba528a2f9c31faefb3b1f192a057c Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 17 Feb 2020 10:23:08 +0800 Subject: [PATCH 034/145] Add: new --- README.md | 5 ++ .../README.md | 73 ++++++++++++++++ .../README.md | 66 +++++++++++++++ problems/counting-bits/README.md | 2 +- problems/intersection-of-two-arrays/README.md | 2 +- .../README.md | 84 +++++++++++++++++++ .../maximum-students-taking-exam/README.md | 2 +- .../product-of-the-last-k-numbers/README.md | 78 +++++++++++++++++ .../README.md | 14 ++++ .../mysql_schemas.sql | 17 ++++ tag/array/README.md | 2 + tag/binary-search/README.md | 1 + tag/design/README.md | 1 + tag/greedy/README.md | 2 + tag/segment-tree/README.md | 1 + tag/sort/README.md | 1 + 16 files changed, 348 insertions(+), 3 deletions(-) create mode 100644 problems/construct-target-array-with-multiple-sums/README.md create mode 100644 problems/count-negative-numbers-in-a-sorted-matrix/README.md create mode 100644 problems/maximum-number-of-events-that-can-be-attended/README.md create mode 100644 problems/product-of-the-last-k-numbers/README.md create mode 100644 problems/students-with-invalid-departments/README.md create mode 100644 problems/students-with-invalid-departments/mysql_schemas.sql diff --git a/README.md b/README.md index 5f49225c2..c849b280b 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,11 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1354 | [Construct Target Array With Multiple Sums](https://leetcode.com/problems/construct-target-array-with-multiple-sums "多次求和构造目标数组") | [Go](problems/construct-target-array-with-multiple-sums) | Hard | +| 1353 | [Maximum Number of Events That Can Be Attended](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended "最多可以参加的会议数目") | [Go](problems/maximum-number-of-events-that-can-be-attended) | Medium | +| 1352 | [Product of the Last K Numbers](https://leetcode.com/problems/product-of-the-last-k-numbers "最后 K 个数的乘积") | [Go](problems/product-of-the-last-k-numbers) | Medium | +| 1351 | [Count Negative Numbers in a Sorted Matrix](https://leetcode.com/problems/count-negative-numbers-in-a-sorted-matrix "统计有序矩阵中的负数") | [Go](problems/count-negative-numbers-in-a-sorted-matrix) | Easy | +| 1350 | [Students With Invalid Departments](https://leetcode.com/problems/students-with-invalid-departments) 🔒 | [MySQL](problems/students-with-invalid-departments) | Easy | | 1349 | [Maximum Students Taking Exam](https://leetcode.com/problems/maximum-students-taking-exam "参加考试的最大学生数") | [Go](problems/maximum-students-taking-exam) | Hard | | 1348 | [Tweet Counts Per Frequency](https://leetcode.com/problems/tweet-counts-per-frequency "推文计数") | [Go](problems/tweet-counts-per-frequency) | Medium | | 1347 | [Minimum Number of Steps to Make Two Strings Anagram](https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram "制造字母异位词的最小步骤数") | [Go](problems/minimum-number-of-steps-to-make-two-strings-anagram) | Medium | diff --git a/problems/construct-target-array-with-multiple-sums/README.md b/problems/construct-target-array-with-multiple-sums/README.md new file mode 100644 index 000000000..2367ddbea --- /dev/null +++ b/problems/construct-target-array-with-multiple-sums/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../maximum-number-of-events-that-can-be-attended "Maximum Number of Events That Can Be Attended") +                 +Next > + +## [1354. Construct Target Array With Multiple Sums (Hard)](https://leetcode.com/problems/construct-target-array-with-multiple-sums "多次求和构造目标数组") + +

Given an array of integers target. From a starting array, A consisting of all 1's, you may perform the following procedure :

+ +
    +
  • let x be the sum of all elements currently in your array.
  • +
  • choose index i, such that 0 <= i < target.size and set the value of A at index i to x.
  • +
  • You may repeat this procedure as many times as needed.
  • +
+ +

Return True if it is possible to construct the target array from A otherwise return False.

+ +

 

+

Example 1:

+ +
+Input: target = [9,3,5]
+Output: true
+Explanation: Start with [1, 1, 1] 
+[1, 1, 1], sum = 3 choose index 1
+[1, 3, 1], sum = 5 choose index 2
+[1, 3, 5], sum = 9 choose index 0
+[9, 3, 5] Done
+
+ +

Example 2:

+ +
+Input: target = [1,1,1,2]
+Output: false
+Explanation: Impossible to create target array from [1,1,1,1].
+
+ +

Example 3:

+ +
+Input: target = [8,5]
+Output: true
+
+ +

 

+

Constraints:

+ +
    +
  • N == target.length
  • +
  • 1 <= target.length <= 5 * 10^4
  • +
  • 1 <= target[i] <= 10^9
  • +
+ +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
+Hint 1 +Given that the sum is strictly increasing, the largest element in the target must be formed in the last step by adding the total sum in the previous step. Thus, we can simulate the process in a reversed way. +
+ +
+Hint 2 +Subtract the largest with the rest of the array, and put the new element into the array. Repeat until all elements become one +
diff --git a/problems/count-negative-numbers-in-a-sorted-matrix/README.md b/problems/count-negative-numbers-in-a-sorted-matrix/README.md new file mode 100644 index 000000000..075589a10 --- /dev/null +++ b/problems/count-negative-numbers-in-a-sorted-matrix/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../students-with-invalid-departments "Students With Invalid Departments") +                 +[Next >](../product-of-the-last-k-numbers "Product of the Last K Numbers") + +## [1351. Count Negative Numbers in a Sorted Matrix (Easy)](https://leetcode.com/problems/count-negative-numbers-in-a-sorted-matrix "统计有序矩阵中的负数") + +

Given a m * n matrix grid which is sorted in non-increasing order both row-wise and column-wise. 

+ +

Return the number of negative numbers in grid.

+ +

 

+

Example 1:

+ +
+Input: grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]]
+Output: 8
+Explanation: There are 8 negatives number in the matrix.
+
+ +

Example 2:

+ +
+Input: grid = [[3,2],[1,0]]
+Output: 0
+
+ +

Example 3:

+ +
+Input: grid = [[1,-1],[-1,-1]]
+Output: 3
+
+ +

Example 4:

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

 

+

Constraints:

+ +
    +
  • m == grid.length
  • +
  • n == grid[i].length
  • +
  • 1 <= m, n <= 100
  • +
  • -100 <= grid[i][j] <= 100
  • +
+ +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
+Hint 1 +Use binary search for optimization or simply brute force. +
diff --git a/problems/counting-bits/README.md b/problems/counting-bits/README.md index 9169d1a68..e8d6a286b 100644 --- a/problems/counting-bits/README.md +++ b/problems/counting-bits/README.md @@ -35,8 +35,8 @@ ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Number of 1 Bits](../number-of-1-bits) (Easy) diff --git a/problems/intersection-of-two-arrays/README.md b/problems/intersection-of-two-arrays/README.md index 26f036111..09355375f 100644 --- a/problems/intersection-of-two-arrays/README.md +++ b/problems/intersection-of-two-arrays/README.md @@ -38,10 +38,10 @@

 

### Related Topics + [[Sort](../../tag/sort/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Sort](../../tag/sort/README.md)] ### Similar Questions 1. [Intersection of Two Arrays II](../intersection-of-two-arrays-ii) (Easy) diff --git a/problems/maximum-number-of-events-that-can-be-attended/README.md b/problems/maximum-number-of-events-that-can-be-attended/README.md new file mode 100644 index 000000000..abbb0b36a --- /dev/null +++ b/problems/maximum-number-of-events-that-can-be-attended/README.md @@ -0,0 +1,84 @@ + + + + + + + +[< Previous](../product-of-the-last-k-numbers "Product of the Last K Numbers") +                 +[Next >](../construct-target-array-with-multiple-sums "Construct Target Array With Multiple Sums") + +## [1353. Maximum Number of Events That Can Be Attended (Medium)](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended "最多可以参加的会议数目") + +

Given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi.

+ +

You can attend an event i at any day d where startTimei <= d <= endTimei. Notice that you can only attend one event at any time d.

+ +

Return the maximum number of events you can attend.

+ +

 

+

Example 1:

+ +
+Input: events = [[1,2],[2,3],[3,4]]
+Output: 3
+Explanation: You can attend all the three events.
+One way to attend them all is as shown.
+Attend the first event on day 1.
+Attend the second event on day 2.
+Attend the third event on day 3.
+
+ +

Example 2:

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

Example 3:

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

Example 4:

+ +
+Input: events = [[1,100000]]
+Output: 1
+
+ +

Example 5:

+ +
+Input: events = [[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7]]
+Output: 7
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= events.length <= 10^5
  • +
  • events[i].length == 2
  • +
  • 1 <= events[i][0] <= events[i][1] <= 10^5
  • +
+ +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + +### Hints +
+Hint 1 +Sort the events by the start time and in case of tie by the end time in ascending order. +
+ +
+Hint 2 +Loop over the sorted events. Attend as much as you can and keep the last day occupied. When you try to attend new event keep in mind the first day you can attend a new event in. +
diff --git a/problems/maximum-students-taking-exam/README.md b/problems/maximum-students-taking-exam/README.md index 42528f4fb..6776e572c 100644 --- a/problems/maximum-students-taking-exam/README.md +++ b/problems/maximum-students-taking-exam/README.md @@ -7,7 +7,7 @@ [< Previous](../tweet-counts-per-frequency "Tweet Counts Per Frequency")                  -Next > +[Next >](../students-with-invalid-departments "Students With Invalid Departments") ## [1349. Maximum Students Taking Exam (Hard)](https://leetcode.com/problems/maximum-students-taking-exam "参加考试的最大学生数") diff --git a/problems/product-of-the-last-k-numbers/README.md b/problems/product-of-the-last-k-numbers/README.md new file mode 100644 index 000000000..799a75cc8 --- /dev/null +++ b/problems/product-of-the-last-k-numbers/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../count-negative-numbers-in-a-sorted-matrix "Count Negative Numbers in a Sorted Matrix") +                 +[Next >](../maximum-number-of-events-that-can-be-attended "Maximum Number of Events That Can Be Attended") + +## [1352. Product of the Last K Numbers (Medium)](https://leetcode.com/problems/product-of-the-last-k-numbers "最后 K 个数的乘积") + +

Implement the class ProductOfNumbers that supports two methods:

+ +

1. add(int num)

+ +
    +
  • Adds the number num to the back of the current list of numbers.
  • +
+ +

2. getProduct(int k)

+ +
    +
  • Returns the product of the last k numbers in the current list.
  • +
  • You can assume that always the current list has at least k numbers.
  • +
+ +

At any time, the product of any contiguous sequence of numbers will fit into a single 32-bit integer without overflowing.

+ +

 

+

Example:

+ +
+Input
+["ProductOfNumbers","add","add","add","add","add","getProduct","getProduct","getProduct","add","getProduct"]
+[[],[3],[0],[2],[5],[4],[2],[3],[4],[8],[2]]
+
+Output
+[null,null,null,null,null,null,20,40,0,null,32]
+
+Explanation
+ProductOfNumbers productOfNumbers = new ProductOfNumbers();
+productOfNumbers.add(3);        // [3]
+productOfNumbers.add(0);        // [3,0]
+productOfNumbers.add(2);        // [3,0,2]
+productOfNumbers.add(5);        // [3,0,2,5]
+productOfNumbers.add(4);        // [3,0,2,5,4]
+productOfNumbers.getProduct(2); // return 20. The product of the last 2 numbers is 5 * 4 = 20
+productOfNumbers.getProduct(3); // return 40. The product of the last 3 numbers is 2 * 5 * 4 = 40
+productOfNumbers.getProduct(4); // return 0. The product of the last 4 numbers is 0 * 2 * 5 * 4 = 0
+productOfNumbers.add(8);        // [3,0,2,5,4,8]
+productOfNumbers.getProduct(2); // return 32. The product of the last 2 numbers is 4 * 8 = 32 
+
+ +

 

+

Constraints:

+ +
    +
  • There will be at most 40000 operations considering both add and getProduct.
  • +
  • 0 <= num <= 100
  • +
  • 1 <= k <= 40000
  • +
+ +### Related Topics + [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
+Hint 1 +Keep all prefix products of numbers in an array, then calculate the product of last K elements in O(1) complexity. +
+ +
+Hint 2 +When a zero number is added, clean the array of prefix products. +
diff --git a/problems/students-with-invalid-departments/README.md b/problems/students-with-invalid-departments/README.md new file mode 100644 index 000000000..2a1b9c1ec --- /dev/null +++ b/problems/students-with-invalid-departments/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../maximum-students-taking-exam "Maximum Students Taking Exam") +                 +[Next >](../count-negative-numbers-in-a-sorted-matrix "Count Negative Numbers in a Sorted Matrix") + +## [1350. Students With Invalid Departments (Easy)](https://leetcode.com/problems/students-with-invalid-departments "") + + diff --git a/problems/students-with-invalid-departments/mysql_schemas.sql b/problems/students-with-invalid-departments/mysql_schemas.sql new file mode 100644 index 000000000..3f3e4af12 --- /dev/null +++ b/problems/students-with-invalid-departments/mysql_schemas.sql @@ -0,0 +1,17 @@ +Create table If Not Exists Departments (id int, name varchar(30)); +Create table If Not Exists Students (id int, name varchar(30), department_id int); +Truncate table Departments; +insert into Departments (id, name) values ('1', 'Electrical Engineering'); +insert into Departments (id, name) values ('7', 'Computer Engineering'); +insert into Departments (id, name) values ('13', 'Bussiness Administration'); +Truncate table Students; +insert into Students (id, name, department_id) values ('23', 'Alice', '1'); +insert into Students (id, name, department_id) values ('1', 'Bob', '7'); +insert into Students (id, name, department_id) values ('5', 'Jennifer', '13'); +insert into Students (id, name, department_id) values ('2', 'John', '14'); +insert into Students (id, name, department_id) values ('4', 'Jasmine', '77'); +insert into Students (id, name, department_id) values ('3', 'Steve', '74'); +insert into Students (id, name, department_id) values ('6', 'Luis', '1'); +insert into Students (id, name, department_id) values ('8', 'Jonathan', '7'); +insert into Students (id, name, department_id) values ('7', 'Daiana', '33'); +insert into Students (id, name, department_id) values ('11', 'Madelynn', '1'); diff --git a/tag/array/README.md b/tag/array/README.md index 9db12f938..ba5742da3 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 1346 | [检查整数及其两倍数是否存在](../../problems/check-if-n-and-its-double-exist) | [[数组](../array/README.md)] | Easy | | 1343 | [大小为 K 且平均值大于等于阈值的子数组数目](../../problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold) | [[数组](../array/README.md)] | Medium | | 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index f2d86062a..fd809ab4a 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 1337 | [方阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index 05840b149..91b34835c 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] | Medium | | 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 2e8dc11ce..ca7efdb77 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1354 | [多次求和构造目标数组](../../problems/construct-target-array-with-multiple-sums) | [[贪心算法](../greedy/README.md)] | Hard | +| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | | 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1326 | [灌溉花园的最少水龙头数目](../../problems/minimum-number-of-taps-to-open-to-water-a-garden) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index 4fb79b397..d17f4d302 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | | 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | | 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | diff --git a/tag/sort/README.md b/tag/sort/README.md index 8bd489283..1948cedb1 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | | 1333 | [餐厅过滤器](../../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1329 | [将矩阵按对角线排序](../../problems/sort-the-matrix-diagonally) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[排序](../sort/README.md)] [[树](../tree/README.md)] | Medium | From 7569133ebc851220bfa21818098eb527b91e8ec1 Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 25 Feb 2020 11:04:47 +0800 Subject: [PATCH 035/145] Add: new --- README.md | 9 ++ problems/activity-participants/README.md | 14 +++ .../activity-participants/mysql_schemas.sql | 13 +++ .../apply-discount-every-n-orders/README.md | 77 ++++++++++++ .../cheapest-flights-within-k-stops/README.md | 2 +- problems/closest-divisors/README.md | 60 ++++++++++ problems/consecutive-numbers-sum/README.md | 2 +- problems/construct-quad-tree/README.md | 96 ++++++++++++--- .../README.md | 2 +- .../README.md | 61 ++++++++++ .../README.md | 55 +++++++++ .../README.md | 2 +- problems/largest-multiple-of-three/README.md | 81 +++++++++++++ .../README.md | 110 ++++++++++++++++++ problems/making-a-large-island/README.md | 2 +- .../maximum-depth-of-n-ary-tree/README.md | 2 +- .../README.md | 52 +++++++++ .../README.md | 62 ++++++++++ .../README.md | 2 +- .../reverse-words-in-a-string-iii/README.md | 2 +- .../README.md | 81 +++++++++++++ problems/validate-binary-tree-nodes/README.md | 78 +++++++++++++ readme/301-600.md | 2 +- readme/601-900.md | 2 +- tag/bit-manipulation/README.md | 1 + tag/design/README.md | 1 + tag/dynamic-programming/README.md | 2 + tag/graph/README.md | 1 + tag/math/README.md | 3 + tag/sort/README.md | 1 + tag/string/README.md | 1 + tag/two-pointers/README.md | 2 +- 32 files changed, 855 insertions(+), 26 deletions(-) create mode 100644 problems/activity-participants/README.md create mode 100644 problems/activity-participants/mysql_schemas.sql create mode 100644 problems/apply-discount-every-n-orders/README.md create mode 100644 problems/closest-divisors/README.md create mode 100644 problems/count-all-valid-pickup-and-delivery-options/README.md create mode 100644 problems/count-unique-characters-of-all-substrings-of-a-given-string/README.md create mode 100644 problems/largest-multiple-of-three/README.md create mode 100644 problems/logical-or-of-two-binary-grids-represented-as-quad-trees/README.md create mode 100644 problems/number-of-days-between-two-dates/README.md create mode 100644 problems/number-of-substrings-containing-all-three-characters/README.md create mode 100644 problems/sort-integers-by-the-number-of-1-bits/README.md create mode 100644 problems/validate-binary-tree-nodes/README.md diff --git a/README.md b/README.md index c849b280b..ee918bcdc 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,15 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1363 | [Largest Multiple of Three](https://leetcode.com/problems/largest-multiple-of-three "形成三的最大倍数") | [Go](problems/largest-multiple-of-three) | Hard | +| 1362 | [Closest Divisors](https://leetcode.com/problems/closest-divisors "最接近的因数") | [Go](problems/closest-divisors) | Medium | +| 1361 | [Validate Binary Tree Nodes](https://leetcode.com/problems/validate-binary-tree-nodes "验证二叉树") | [Go](problems/validate-binary-tree-nodes) | Medium | +| 1360 | [Number of Days Between Two Dates](https://leetcode.com/problems/number-of-days-between-two-dates "日期之间隔几天") | [Go](problems/number-of-days-between-two-dates) | Easy | +| 1359 | [Count All Valid Pickup and Delivery Options](https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options "有效的快递序列数目") | [Go](problems/count-all-valid-pickup-and-delivery-options) | Hard | +| 1358 | [Number of Substrings Containing All Three Characters](https://leetcode.com/problems/number-of-substrings-containing-all-three-characters "包含所有三种字符的子字符串数目") | [Go](problems/number-of-substrings-containing-all-three-characters) | Medium | +| 1357 | [Apply Discount Every n Orders](https://leetcode.com/problems/apply-discount-every-n-orders "每隔 n 个顾客打折") | [Go](problems/apply-discount-every-n-orders) | Medium | +| 1356 | [Sort Integers by The Number of 1 Bits](https://leetcode.com/problems/sort-integers-by-the-number-of-1-bits "根据数字二进制下 1 的数目排序") | [Go](problems/sort-integers-by-the-number-of-1-bits) | Easy | +| 1355 | [Activity Participants](https://leetcode.com/problems/activity-participants) 🔒 | [MySQL](problems/activity-participants) | Medium | | 1354 | [Construct Target Array With Multiple Sums](https://leetcode.com/problems/construct-target-array-with-multiple-sums "多次求和构造目标数组") | [Go](problems/construct-target-array-with-multiple-sums) | Hard | | 1353 | [Maximum Number of Events That Can Be Attended](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended "最多可以参加的会议数目") | [Go](problems/maximum-number-of-events-that-can-be-attended) | Medium | | 1352 | [Product of the Last K Numbers](https://leetcode.com/problems/product-of-the-last-k-numbers "最后 K 个数的乘积") | [Go](problems/product-of-the-last-k-numbers) | Medium | diff --git a/problems/activity-participants/README.md b/problems/activity-participants/README.md new file mode 100644 index 000000000..47c6a14fb --- /dev/null +++ b/problems/activity-participants/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../construct-target-array-with-multiple-sums "Construct Target Array With Multiple Sums") +                 +[Next >](../sort-integers-by-the-number-of-1-bits "Sort Integers by The Number of 1 Bits") + +## [1355. Activity Participants (Medium)](https://leetcode.com/problems/activity-participants "") + + diff --git a/problems/activity-participants/mysql_schemas.sql b/problems/activity-participants/mysql_schemas.sql new file mode 100644 index 000000000..161ef2e28 --- /dev/null +++ b/problems/activity-participants/mysql_schemas.sql @@ -0,0 +1,13 @@ +Create table If Not Exists Friends (id int, name varchar(30), activity varchar(30)); +Create table If Not Exists Activities (id int, name varchar(30)); +Truncate table Friends; +insert into Friends (id, name, activity) values ('1', 'Jonathan D.', 'Eating'); +insert into Friends (id, name, activity) values ('2', 'Jade W.', 'Singing'); +insert into Friends (id, name, activity) values ('3', 'Victor J.', 'Singing'); +insert into Friends (id, name, activity) values ('4', 'Elvis Q.', 'Eating'); +insert into Friends (id, name, activity) values ('5', 'Daniel A.', 'Eating'); +insert into Friends (id, name, activity) values ('6', 'Bob B.', 'Horse Riding'); +Truncate table Activities; +insert into Activities (id, name) values ('1', 'Eating'); +insert into Activities (id, name) values ('2', 'Singing'); +insert into Activities (id, name) values ('3', 'Horse Riding'); diff --git a/problems/apply-discount-every-n-orders/README.md b/problems/apply-discount-every-n-orders/README.md new file mode 100644 index 000000000..44802160d --- /dev/null +++ b/problems/apply-discount-every-n-orders/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../sort-integers-by-the-number-of-1-bits "Sort Integers by The Number of 1 Bits") +                 +[Next >](../number-of-substrings-containing-all-three-characters "Number of Substrings Containing All Three Characters") + +## [1357. Apply Discount Every n Orders (Medium)](https://leetcode.com/problems/apply-discount-every-n-orders "每隔 n 个顾客打折") + +

There is a sale in a supermarket, there will be a discount every n customer.
+There are some products in the supermarket where the id of the i-th product is products[i] and the price per unit of this product is prices[i].
+The system will count the number of customers and when the n-th customer arrive he/she will have a discount on the bill. (i.e if the cost is x the new cost is x - (discount * x) / 100). Then the system will start counting customers again.
+The customer orders a certain amount of each product where product[i] is the id of the i-th product the customer ordered and amount[i] is the number of units the customer ordered of that product.

+ +

Implement the Cashier class:

+ +
    +
  • Cashier(int n, int discount, int[] products, int[] prices) Initializes the object with n, the discount, the products and their prices.
  • +
  • double getBill(int[] product, int[] amount) returns the value of the bill and apply the discount if needed. Answers within 10^-5 of the actual value will be accepted as correct.
  • +
+ +

 

+

Example 1:

+ +
+Input
+["Cashier","getBill","getBill","getBill","getBill","getBill","getBill","getBill"]
+[[3,50,[1,2,3,4,5,6,7],[100,200,300,400,300,200,100]],[[1,2],[1,2]],[[3,7],[10,10]],[[1,2,3,4,5,6,7],[1,1,1,1,1,1,1]],[[4],[10]],[[7,3],[10,10]],[[7,5,3,1,6,4,2],[10,10,10,9,9,9,7]],[[2,3,5],[5,3,2]]]
+Output
+[null,500.0,4000.0,800.0,4000.0,4000.0,7350.0,2500.0]
+Explanation
+Cashier cashier = new Cashier(3,50,[1,2,3,4,5,6,7],[100,200,300,400,300,200,100]);
+cashier.getBill([1,2],[1,2]);                        // return 500.0, bill = 1 * 100 + 2 * 200 = 500.
+cashier.getBill([3,7],[10,10]);                      // return 4000.0
+cashier.getBill([1,2,3,4,5,6,7],[1,1,1,1,1,1,1]);    // return 800.0, The bill was 1600.0 but as this is the third customer, he has a discount of 50% which means his bill is only 1600 - 1600 * (50 / 100) = 800.
+cashier.getBill([4],[10]);                           // return 4000.0
+cashier.getBill([7,3],[10,10]);                      // return 4000.0
+cashier.getBill([7,5,3,1,6,4,2],[10,10,10,9,9,9,7]); // return 7350.0, Bill was 14700.0 but as the system counted three more customers, he will have a 50% discount and the bill becomes 7350.0
+cashier.getBill([2,3,5],[5,3,2]);                    // return 2500.0
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= n <= 10^4
  • +
  • 0 <= discount <= 100
  • +
  • 1 <= products.length <= 200
  • +
  • 1 <= products[i] <= 200
  • +
  • There are not repeated elements in the array products.
  • +
  • prices.length == products.length
  • +
  • 1 <= prices[i] <= 1000
  • +
  • 1 <= product.length <= products.length
  • +
  • product[i] exists in products.
  • +
  • amount.length == product.length
  • +
  • 1 <= amount[i] <= 1000
  • +
  • At most 1000 calls will be made to getBill.
  • +
  • Answers within 10^-5 of the actual value will be accepted as correct.
  • +
+ +### Related Topics + [[Design](../../tag/design/README.md)] + +### Hints +
+Hint 1 +Keep track of the count of the customers. +
+ +
+Hint 2 +Check if the count of the customers is divisible by n then apply the discount formula. +
diff --git a/problems/cheapest-flights-within-k-stops/README.md b/problems/cheapest-flights-within-k-stops/README.md index cba708f69..8d003d2d7 100644 --- a/problems/cheapest-flights-within-k-stops/README.md +++ b/problems/cheapest-flights-within-k-stops/README.md @@ -11,7 +11,7 @@ ## [787. Cheapest Flights Within K Stops (Medium)](https://leetcode.com/problems/cheapest-flights-within-k-stops "K 站中转内最便宜的航班") -

There are n cities connected by m flights. Each fight starts from city u and arrives at v with a price w.

+

There are n cities connected by m flights. Each flight starts from city u and arrives at v with a price w.

Now given all the cities and flights, together with starting city src and the destination dst, your task is to find the cheapest price from src to dst with up to k stops. If there is no such route, output -1.

diff --git a/problems/closest-divisors/README.md b/problems/closest-divisors/README.md new file mode 100644 index 000000000..85e11e737 --- /dev/null +++ b/problems/closest-divisors/README.md @@ -0,0 +1,60 @@ + + + + + + + +[< Previous](../validate-binary-tree-nodes "Validate Binary Tree Nodes") +                 +[Next >](../largest-multiple-of-three "Largest Multiple of Three") + +## [1362. Closest Divisors (Medium)](https://leetcode.com/problems/closest-divisors "最接近的因数") + +

Given an integer num, find the closest two integers in absolute difference whose product equals num + 1 or num + 2.

+ +

Return the two integers in any order.

+ +

 

+

Example 1:

+ +
+Input: num = 8
+Output: [3,3]
+Explanation: For num + 1 = 9, the closest divisors are 3 & 3, for num + 2 = 10, the closest divisors are 2 & 5, hence 3 & 3 is chosen.
+
+ +

Example 2:

+ +
+Input: num = 123
+Output: [5,25]
+
+ +

Example 3:

+ +
+Input: num = 999
+Output: [40,25]
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= num <= 10^9
  • +
+ +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
+Hint 1 +Find the divisors of n+1 and n+2. +
+ +
+Hint 2 +To find the divisors of a number, you only need to iterate to the square root of that number. +
diff --git a/problems/consecutive-numbers-sum/README.md b/problems/consecutive-numbers-sum/README.md index d8a56e19e..919abaae0 100644 --- a/problems/consecutive-numbers-sum/README.md +++ b/problems/consecutive-numbers-sum/README.md @@ -5,7 +5,7 @@ -[< Previous](../unique-letter-string "Unique Letter String") +[< Previous](../count-unique-characters-of-all-substrings-of-a-given-string "Count Unique Characters of All Substrings of a Given String")                  [Next >](../positions-of-large-groups "Positions of Large Groups") diff --git a/problems/construct-quad-tree/README.md b/problems/construct-quad-tree/README.md index 85ea30cfc..9384b2ea8 100644 --- a/problems/construct-quad-tree/README.md +++ b/problems/construct-quad-tree/README.md @@ -11,31 +11,97 @@ ## [427. Construct Quad Tree (Medium)](https://leetcode.com/problems/construct-quad-tree "建立四叉树") -

We want to use quad trees to store an N x N boolean grid. Each cell in the grid can only be true or false. The root node represents the whole grid. For each node, it will be subdivided into four children nodes until the values in the region it represents are all the same.

+

Given a n * n matrix grid of 0's and 1's only. We want to represent the grid with a Quad-Tree.

-

Each node has another two boolean attributes : isLeaf and val. isLeaf is true if and only if the node is a leaf node. The val attribute for a leaf node contains the value of the region it represents.

+

Return the root of the Quad-Tree representing the grid.

-

Your task is to use a quad tree to represent a given grid. The following example may help you understand the problem better:

+

Notice that you can assign the value of a node to True or False when isLeaf is False, and both are accepted in the answer.

-

Given the 8 x 8 grid below, we want to construct the corresponding quad tree:

+

A Quad-Tree is a tree data structure in which each internal node has exactly four children. Besides, each node has two attributes:

-

+
    +
  • val: True if the node represents a grid of 1's or False if the node represents a grid of 0's. 
  • +
  • isLeaf: True if the node is leaf node on the tree or False if the node has the four children.
  • +
-

It can be divided according to the definition above:

+
+class Node {
+    public boolean val;
+    public boolean isLeaf;
+    public Node topLeft;
+    public Node topRight;
+    public Node bottomLeft;
+    public Node bottomRight;
+}
-

+

We can construct a Quad-Tree from a two-dimensional area using the following steps:

+ +
    +
  1. If the current grid has the same value (i.e all 1's or all 0's) set isLeaf True and set val to the value of the grid and set the four children to Null and stop.
  2. +
  3. If the current grid has different values, set isLeaf to False and set val to any value and divide the current grid into four sub-grids as shown in the photo.
  4. +
  5. Recurse for each of the children with the proper sub-grid.
  6. +
+ +

If you want to know more about the Quad-Tree, you can refer to the wiki.

+ +

Quad-Tree format:

+ +

The output represents the serialized format of a Quad-Tree using level order traversal, where null signifies a path terminator where no node exists below.

+ +

It is very similar to the serialization of the binary tree. The only difference is that the node is represented as a list [isLeaf, val].

+ +

If the value of isLeaf or val is True we represent it as 1 in the list [isLeaf, val] and if the value of isLeaf or val is False we represent it as 0.

 

+

Example 1:

+ +
+Input: grid = [[0,1],[1,0]]
+Output: [[0,1],[1,0],[1,1],[1,1],[1,0]]
+Explanation: The explanation of this example is shown below:
+Notice that 0 represnts False and 1 represents True in the photo representing the Quad-Tree.
+
+
-

The corresponding quad tree should be as following, where each node is represented as a (isLeaf, val) pair.

+

Example 2:

-

For the non-leaf nodes, val can be arbitrary, so it is represented as *.

+

-

+
+Input: grid = [[1,1,1,1,0,0,0,0],[1,1,1,1,0,0,0,0],[1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1],[1,1,1,1,0,0,0,0],[1,1,1,1,0,0,0,0],[1,1,1,1,0,0,0,0],[1,1,1,1,0,0,0,0]]
+Output: [[0,1],[1,1],[0,1],[1,1],[1,0],null,null,null,null,[1,0],[1,0],[1,1],[1,1]]
+Explanation: All values in the grid are not the same. We divide the grid into four sub-grids.
+The topLeft, bottomLeft and bottomRight each has the same value.
+The topRight have different values so we divide it into 4 sub-grids where each has the same value.
+Explanation is shown in the photo below:
+
+
-

Note:

+

Example 3:

-
    -
  1. N is less than 1000 and guaranteened to be a power of 2.
  2. -
  3. If you want to know more about the quad tree, you can refer to its wiki.
  4. -
+
+Input: grid = [[1,1],[1,1]]
+Output: [[1,1]]
+
+ +

Example 4:

+ +
+Input: grid = [[0]]
+Output: [[1,0]]
+
+ +

Example 5:

+ +
+Input: grid = [[1,1,0,0],[1,1,0,0],[0,0,1,1],[0,0,1,1]]
+Output: [[0,1],[1,1],[1,0],[1,0],[1,1]]
+
+ +

 

+

Constraints:

+ +
    +
  • n == grid.length == grid[i].length
  • +
  • n == 2^x where 0 <= x <= 6
  • +
diff --git a/problems/construct-target-array-with-multiple-sums/README.md b/problems/construct-target-array-with-multiple-sums/README.md index 2367ddbea..08f6155d4 100644 --- a/problems/construct-target-array-with-multiple-sums/README.md +++ b/problems/construct-target-array-with-multiple-sums/README.md @@ -7,7 +7,7 @@ [< Previous](../maximum-number-of-events-that-can-be-attended "Maximum Number of Events That Can Be Attended")                  -Next > +[Next >](../activity-participants "Activity Participants") ## [1354. Construct Target Array With Multiple Sums (Hard)](https://leetcode.com/problems/construct-target-array-with-multiple-sums "多次求和构造目标数组") diff --git a/problems/count-all-valid-pickup-and-delivery-options/README.md b/problems/count-all-valid-pickup-and-delivery-options/README.md new file mode 100644 index 000000000..664cb1b10 --- /dev/null +++ b/problems/count-all-valid-pickup-and-delivery-options/README.md @@ -0,0 +1,61 @@ + + + + + + + +[< Previous](../number-of-substrings-containing-all-three-characters "Number of Substrings Containing All Three Characters") +                 +[Next >](../number-of-days-between-two-dates "Number of Days Between Two Dates") + +## [1359. Count All Valid Pickup and Delivery Options (Hard)](https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options "有效的快递序列数目") + +

Given n orders, each order consist in pickup and delivery services. 

+ +

Count all valid pickup/delivery possible sequences such that delivery(i) is always after of pickup(i). 

+ +

Since the answer may be too large, return it modulo 10^9 + 7.

+ +

 

+

Example 1:

+ +
+Input: n = 1
+Output: 1
+Explanation: Unique order (P1, D1), Delivery 1 always is after of Pickup 1.
+
+ +

Example 2:

+ +
+Input: n = 2
+Output: 6
+Explanation: All possible orders: 
+(P1,P2,D1,D2), (P1,P2,D2,D1), (P1,D1,P2,D2), (P2,P1,D1,D2), (P2,P1,D2,D1) and (P2,D2,P1,D1).
+This is an invalid order (P1,D2,P2,D1) because Pickup 2 is after of Delivery 2.
+
+ +

Example 3:

+ +
+Input: n = 3
+Output: 90
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= n <= 500
  • +
+ +### Related Topics + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
+Hint 1 +Use the permutation and combination theory to add one (P, D) pair each time until n pairs. +
diff --git a/problems/count-unique-characters-of-all-substrings-of-a-given-string/README.md b/problems/count-unique-characters-of-all-substrings-of-a-given-string/README.md new file mode 100644 index 000000000..99c7db690 --- /dev/null +++ b/problems/count-unique-characters-of-all-substrings-of-a-given-string/README.md @@ -0,0 +1,55 @@ + + + + + + + +[< Previous](../making-a-large-island "Making A Large Island") +                 +[Next >](../consecutive-numbers-sum "Consecutive Numbers Sum") + +## [828. Count Unique Characters of All Substrings of a Given String (Hard)](https://leetcode.com/problems/count-unique-characters-of-all-substrings-of-a-given-string "独特字符串") + +

Let's define a function countUniqueChars(s) that returns the number of unique characters on s, for example if s = "LEETCODE" then "L", "T","C","O","D" are the unique characters since they appear only once in s, therefore countUniqueChars(s) = 5.
+
+On this problem given a string s we need to return the sum of countUniqueChars(t) where t is a substring of s. Notice that some substrings can be repeated so on this case you have to count the repeated ones too.

+ +

Since the answer can be very large, return the answer modulo 10 ^ 9 + 7.

+ +

 

+

Example 1:

+ +
+Input: s = "ABC"
+Output: 10
+Explanation: All possible substrings are: "A","B","C","AB","BC" and "ABC".
+Evey substring is composed with only unique letters.
+Sum of lengths of all substring is 1 + 1 + 1 + 2 + 2 + 3 = 10
+
+ +

Example 2:

+ +
+Input: s = "ABA"
+Output: 8
+Explanation: The same as example 1, except countUniqueChars("ABA") = 1.
+
+ +

Example 3:

+ +
+Input: s = "LEETCODE"
+Output: 92
+
+ +

 

+

Constraints:

+ +
    +
  • 0 <= s.length <= 10^4
  • +
  • s contain upper-case English letters only.
  • +
+ +### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/decompress-run-length-encoded-list/README.md b/problems/decompress-run-length-encoded-list/README.md index 36b9dd8a3..4040e2fcb 100644 --- a/problems/decompress-run-length-encoded-list/README.md +++ b/problems/decompress-run-length-encoded-list/README.md @@ -25,7 +25,7 @@ Output: [2,4,4,4] Explanation: The first pair [1,2] means we have freq = 1 and val = 2 so we generate the array [2]. The second pair [3,4] means we have freq = 3 and val = 4 so we generate [4,4,4]. -At the end the concatenation [2] + [4,4,4,4] is [2,4,4,4]. +At the end the concatenation [2] + [4,4,4] is [2,4,4,4].

 

diff --git a/problems/largest-multiple-of-three/README.md b/problems/largest-multiple-of-three/README.md new file mode 100644 index 000000000..c32499e8f --- /dev/null +++ b/problems/largest-multiple-of-three/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../closest-divisors "Closest Divisors") +                 +Next > + +## [1363. Largest Multiple of Three (Hard)](https://leetcode.com/problems/largest-multiple-of-three "形成三的最大倍数") + +

Given an integer array of digits, return the largest multiple of three that can be formed by concatenating some of the given digits in any order.

+ +

Since the answer may not fit in an integer data type, return the answer as a string.

+ +

If there is no answer return an empty string.

+ +

 

+

Example 1:

+ +
+Input: digits = [8,1,9]
+Output: "981"
+
+ +

Example 2:

+ +
+Input: digits = [8,6,7,1,0]
+Output: "8760"
+
+ +

Example 3:

+ +
+Input: digits = [1]
+Output: ""
+
+ +

Example 4:

+ +
+Input: digits = [0,0,0,0,0,0]
+Output: "0"
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= digits.length <= 10^4
  • +
  • 0 <= digits[i] <= 9
  • +
  • The returning answer must not contain unnecessary leading zeros.
  • +
+ +### Related Topics + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
+Hint 1 +A number is a multiple of three if and only if its sum of digits is a multiple of three. +
+ +
+Hint 2 +Use dynamic programming. +
+ +
+Hint 3 +To find the maximum number, try to maximize the number of digits of the number. +
+ +
+Hint 4 +Sort the digits in descending order to find the maximum number. +
diff --git a/problems/logical-or-of-two-binary-grids-represented-as-quad-trees/README.md b/problems/logical-or-of-two-binary-grids-represented-as-quad-trees/README.md new file mode 100644 index 000000000..b1e9e6126 --- /dev/null +++ b/problems/logical-or-of-two-binary-grids-represented-as-quad-trees/README.md @@ -0,0 +1,110 @@ + + + + + + + +[< Previous](../reverse-words-in-a-string-iii "Reverse Words in a String III") +                 +[Next >](../maximum-depth-of-n-ary-tree "Maximum Depth of N-ary Tree") + +## [558. Logical OR of Two Binary Grids Represented as Quad-Trees (Medium)](https://leetcode.com/problems/logical-or-of-two-binary-grids-represented-as-quad-trees "四叉树交集") + +

A Binary Matrix is a matrix in which all the elements are either 0 or 1.

+ +

Given quadTree1 and quadTree2. quadTree1 represents a n * n binary matrix and quadTree2 represents another n * n binary matrix. 

+ +

Return a Quad-Tree representing the n * n binary matrix which is the result of logical bitwise OR of the two binary matrixes represented by quadTree1 and quadTree2.

+ +

Notice that you can assign the value of a node to True or False when isLeaf is False, and both are accepted in the answer.

+ +

A Quad-Tree is a tree data structure in which each internal node has exactly four children. Besides, each node has two attributes:

+ +
    +
  • val: True if the node represents a grid of 1's or False if the node represents a grid of 0's. 
  • +
  • isLeaf: True if the node is leaf node on the tree or False if the node has the four children.
  • +
+ +
+class Node {
+    public boolean val;
+    public boolean isLeaf;
+    public Node topLeft;
+    public Node topRight;
+    public Node bottomLeft;
+    public Node bottomRight;
+}
+ +

We can construct a Quad-Tree from a two-dimensional area using the following steps:

+ +
    +
  1. If the current grid has the same value (i.e all 1's or all 0's) set isLeaf True and set val to the value of the grid and set the four children to Null and stop.
  2. +
  3. If the current grid has different values, set isLeaf to False and set val to any value and divide the current grid into four sub-grids as shown in the photo.
  4. +
  5. Recurse for each of the children with the proper sub-grid.
  6. +
+ +

If you want to know more about the Quad-Tree, you can refer to the wiki.

+ +

Quad-Tree format:

+ +

The input/output represents the serialized format of a Quad-Tree using level order traversal, where null signifies a path terminator where no node exists below.

+ +

It is very similar to the serialization of the binary tree. The only difference is that the node is represented as a list [isLeaf, val].

+ +

If the value of isLeaf or val is True we represent it as 1 in the list [isLeaf, val] and if the value of isLeaf or val is False we represent it as 0.

+ +

 

+

Example 1:

+ +
+Input: quadTree1 = [[0,1],[1,1],[1,1],[1,0],[1,0]]
+, quadTree2 = [[0,1],[1,1],[0,1],[1,1],[1,0],null,null,null,null,[1,0],[1,0],[1,1],[1,1]]
+Output: [[0,0],[1,1],[1,1],[1,1],[1,0]]
+Explanation: quadTree1 and quadTree2 are shown above. You can see the binary matrix which is represented by each Quad-Tree.
+If we apply logical bitwise OR on the two binary matrices we get the binary matrix below which is represented by the result Quad-Tree.
+Notice that the binary matrices shown are only for illustration, you don't have to construct the binary matrix to get the result tree.
+
+
+ +

Example 2:

+ +
+Input: quadTree1 = [[1,0]]
+, quadTree2 = [[1,0]]
+Output: [[1,0]]
+Explanation: Each tree represents a binary matrix of size 1*1. Each matrix contains only zero.
+The resulting matrix is of size 1*1 with also zero.
+
+ +

Example 3:

+ +
+Input: quadTree1 = [[0,0],[1,0],[1,0],[1,1],[1,1]]
+, quadTree2 = [[0,0],[1,1],[1,1],[1,0],[1,1]]
+Output: [[1,1]]
+
+ +

Example 4:

+ +
+Input: quadTree1 = [[0,0],[1,1],[1,0],[1,1],[1,1]]
+, quadTree2 = [[0,0],[1,1],[0,1],[1,1],[1,1],null,null,null,null,[1,1],[1,0],[1,0],[1,1]]
+Output: [[0,0],[1,1],[0,1],[1,1],[1,1],null,null,null,null,[1,1],[1,0],[1,0],[1,1]]
+
+ +

Example 5:

+ +
+Input: quadTree1 = [[0,1],[1,0],[0,1],[1,1],[1,0],null,null,null,null,[1,0],[1,0],[1,1],[1,1]]
+, quadTree2 = [[0,1],[0,1],[1,0],[1,1],[1,0],[1,0],[1,0],[1,1],[1,1]]
+Output: [[0,0],[0,1],[0,1],[1,1],[1,0],[1,0],[1,0],[1,1],[1,1],[1,0],[1,0],[1,1],[1,1]]
+
+ +

 

+

Constraints:

+ +
    +
  • quadTree1 and quadTree2 are both valid Quad-Trees each representing a n * n grid.
  • +
  • n == 2^x where 0 <= x <= 9.
  • +
diff --git a/problems/making-a-large-island/README.md b/problems/making-a-large-island/README.md index 539b82767..927a173d4 100644 --- a/problems/making-a-large-island/README.md +++ b/problems/making-a-large-island/README.md @@ -7,7 +7,7 @@ [< Previous](../most-profit-assigning-work "Most Profit Assigning Work")                  -[Next >](../unique-letter-string "Unique Letter String") +[Next >](../count-unique-characters-of-all-substrings-of-a-given-string "Count Unique Characters of All Substrings of a Given String") ## [827. Making A Large Island (Hard)](https://leetcode.com/problems/making-a-large-island "最大人工岛") diff --git a/problems/maximum-depth-of-n-ary-tree/README.md b/problems/maximum-depth-of-n-ary-tree/README.md index 3f997bd6d..676d323a5 100644 --- a/problems/maximum-depth-of-n-ary-tree/README.md +++ b/problems/maximum-depth-of-n-ary-tree/README.md @@ -5,7 +5,7 @@ -[< Previous](../quad-tree-intersection "Quad Tree Intersection") +[< Previous](../logical-or-of-two-binary-grids-represented-as-quad-trees "Logical OR of Two Binary Grids Represented as Quad-Trees")                  [Next >](../subarray-sum-equals-k "Subarray Sum Equals K") diff --git a/problems/number-of-days-between-two-dates/README.md b/problems/number-of-days-between-two-dates/README.md new file mode 100644 index 000000000..ebc0d0775 --- /dev/null +++ b/problems/number-of-days-between-two-dates/README.md @@ -0,0 +1,52 @@ + + + + + + + +[< Previous](../count-all-valid-pickup-and-delivery-options "Count All Valid Pickup and Delivery Options") +                 +[Next >](../validate-binary-tree-nodes "Validate Binary Tree Nodes") + +## [1360. Number of Days Between Two Dates (Easy)](https://leetcode.com/problems/number-of-days-between-two-dates "日期之间隔几天") + +

Write a program to count the number of days between two dates.

+ +

The two dates are given as strings, their format is YYYY-MM-DD as shown in the examples.

+ +

 

+

Example 1:

+
Input: date1 = "2019-06-29", date2 = "2019-06-30"
+Output: 1
+

Example 2:

+
Input: date1 = "2020-01-15", date2 = "2019-12-31"
+Output: 15
+
+

 

+

Constraints:

+ +
    +
  • The given dates are valid dates between the years 1971 and 2100.
  • +
+ +### Hints +
+Hint 1 +Create a function f(date) that counts the number of days from 1900-01-01 to date. How can we calculate the answer ? +
+ +
+Hint 2 +The answer is just |f(date1) - f(date2)|. +
+ +
+Hint 3 +How to construct f(date) ? +
+ +
+Hint 4 +For each year from 1900 to year - 1 sum up 365 or 366 in case of leap years. Then sum up for each month the number of days, consider the case when the current year is leap, finally sum up the days. +
diff --git a/problems/number-of-substrings-containing-all-three-characters/README.md b/problems/number-of-substrings-containing-all-three-characters/README.md new file mode 100644 index 000000000..2dffce2c5 --- /dev/null +++ b/problems/number-of-substrings-containing-all-three-characters/README.md @@ -0,0 +1,62 @@ + + + + + + + +[< Previous](../apply-discount-every-n-orders "Apply Discount Every n Orders") +                 +[Next >](../count-all-valid-pickup-and-delivery-options "Count All Valid Pickup and Delivery Options") + +## [1358. Number of Substrings Containing All Three Characters (Medium)](https://leetcode.com/problems/number-of-substrings-containing-all-three-characters "包含所有三种字符的子字符串数目") + +

Given a string s consisting only of characters a, b and c.

+ +

Return the number of substrings containing at least one occurrence of all these characters a, b and c.

+ +

 

+

Example 1:

+ +
+Input: s = "abcabc"
+Output: 10
+Explanation: The substrings containing at least one occurrence of the characters ab and c are "abc", "abca", "abcab", "abcabc", "bca", "bcab", "bcabc", "cab", "cabc" and "abc" (again). 
+
+ +

Example 2:

+ +
+Input: s = "aaacb"
+Output: 3
+Explanation: The substrings containing at least one occurrence of the characters ab and c are "aaacb", "aacb" and "acb". 
+
+ +

Example 3:

+ +
+Input: s = "abc"
+Output: 1
+
+ +

 

+

Constraints:

+ +
    +
  • 3 <= s.length <= 5 x 10^4
  • +
  • s only consists of a, b or characters.
  • +
+ +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
+Hint 1 +For each position we simply need to find the first occurrence of a/b/c on or after this position. +
+ +
+Hint 2 +So we can pre-compute three link-list of indices of each a, b, and c. +
diff --git a/problems/rearrange-string-k-distance-apart/README.md b/problems/rearrange-string-k-distance-apart/README.md index 8ab0f8b6e..210352a9b 100644 --- a/problems/rearrange-string-k-distance-apart/README.md +++ b/problems/rearrange-string-k-distance-apart/README.md @@ -43,9 +43,9 @@
### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Heap](../../tag/heap/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions 1. [Task Scheduler](../task-scheduler) (Medium) diff --git a/problems/reverse-words-in-a-string-iii/README.md b/problems/reverse-words-in-a-string-iii/README.md index 2060c20a6..8076b5b6d 100644 --- a/problems/reverse-words-in-a-string-iii/README.md +++ b/problems/reverse-words-in-a-string-iii/README.md @@ -7,7 +7,7 @@ [< Previous](../next-greater-element-iii "Next Greater Element III")                  -[Next >](../quad-tree-intersection "Quad Tree Intersection") +[Next >](../logical-or-of-two-binary-grids-represented-as-quad-trees "Logical OR of Two Binary Grids Represented as Quad-Trees") ## [557. Reverse Words in a String III (Easy)](https://leetcode.com/problems/reverse-words-in-a-string-iii "反转字符串中的单词 III") diff --git a/problems/sort-integers-by-the-number-of-1-bits/README.md b/problems/sort-integers-by-the-number-of-1-bits/README.md new file mode 100644 index 000000000..b53b087bb --- /dev/null +++ b/problems/sort-integers-by-the-number-of-1-bits/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../activity-participants "Activity Participants") +                 +[Next >](../apply-discount-every-n-orders "Apply Discount Every n Orders") + +## [1356. Sort Integers by The Number of 1 Bits (Easy)](https://leetcode.com/problems/sort-integers-by-the-number-of-1-bits "根据数字二进制下 1 的数目排序") + +

Given an integer array arr. You have to sort the integers in the array in ascending order by the number of 1's in their binary representation and in case of two or more integers have the same number of 1's you have to sort them in ascending order.

+ +

Return the sorted array.

+ +

 

+

Example 1:

+ +
+Input: arr = [0,1,2,3,4,5,6,7,8]
+Output: [0,1,2,4,8,3,5,6,7]
+Explantion: [0] is the only integer with 0 bits.
+[1,2,4,8] all have 1 bit.
+[3,5,6] have 2 bits.
+[7] has 3 bits.
+The sorted array by bits is [0,1,2,4,8,3,5,6,7]
+
+ +

Example 2:

+ +
+Input: arr = [1024,512,256,128,64,32,16,8,4,2,1]
+Output: [1,2,4,8,16,32,64,128,256,512,1024]
+Explantion: All integers have 1 bit in the binary representation, you should just sort them in ascending order.
+
+ +

Example 3:

+ +
+Input: arr = [10000,10000]
+Output: [10000,10000]
+
+ +

Example 4:

+ +
+Input: arr = [2,3,5,7,11,13,17,19]
+Output: [2,3,5,17,7,11,13,19]
+
+ +

Example 5:

+ +
+Input: arr = [10,100,1000,10000]
+Output: [10,100,10000,1000]
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= arr.length <= 500
  • +
  • 0 <= arr[i] <= 10^4
  • +
+ +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + +### Hints +
+Hint 1 +Simulate the problem. Count the number of 1's in the binary representation of each integer. +
+ +
+Hint 2 +Sort by the number of 1's ascending and by the value in case of tie. +
diff --git a/problems/validate-binary-tree-nodes/README.md b/problems/validate-binary-tree-nodes/README.md new file mode 100644 index 000000000..fe4ac2367 --- /dev/null +++ b/problems/validate-binary-tree-nodes/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../number-of-days-between-two-dates "Number of Days Between Two Dates") +                 +[Next >](../closest-divisors "Closest Divisors") + +## [1361. Validate Binary Tree Nodes (Medium)](https://leetcode.com/problems/validate-binary-tree-nodes "验证二叉树") + +

You have n binary tree nodes numbered from 0 to n - 1 where node i has two children leftChild[i] and rightChild[i], return true if and only if all the given nodes form exactly one valid binary tree.

+ +

If node i has no left child then leftChild[i] will equal -1, similarly for the right child.

+ +

Note that the nodes have no values and that we only use the node numbers in this problem.

+ +

 

+

Example 1:

+ +

+ +
+Input: n = 4, leftChild = [1,-1,3,-1], rightChild = [2,-1,-1,-1]
+Output: true
+
+ +

Example 2:

+ +

+ +
+Input: n = 4, leftChild = [1,-1,3,-1], rightChild = [2,3,-1,-1]
+Output: false
+
+ +

Example 3:

+ +

+ +
+Input: n = 2, leftChild = [1,0], rightChild = [-1,-1]
+Output: false
+
+ +

Example 4:

+ +

+ +
+Input: n = 6, leftChild = [1,-1,-1,4,-1,-1], rightChild = [2,-1,-1,5,-1,-1]
+Output: false
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= n <= 10^4
  • +
  • leftChild.length == rightChild.length == n
  • +
  • -1 <= leftChild[i], rightChild[i] <= n - 1
  • +
+ +### Related Topics + [[Graph](../../tag/graph/README.md)] + +### Hints +
+Hint 1 +Find the parent of each node. +
+ +
+Hint 2 +A valid tree must have nodes with only one parent and exactly one node with no parent. +
diff --git a/readme/301-600.md b/readme/301-600.md index 0baddcda9..114f9523c 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -319,7 +319,7 @@ LeetCode Problems' Solutions | 555 | [Split Concatenated Strings](https://leetcode.com/problems/split-concatenated-strings "分割连接字符串") 🔒 | [Go](../problems/split-concatenated-strings) | Medium | | 556 | [Next Greater Element III](https://leetcode.com/problems/next-greater-element-iii "下一个更大元素 III") | [Go](../problems/next-greater-element-iii) | Medium | | 557 | [Reverse Words in a String III](https://leetcode.com/problems/reverse-words-in-a-string-iii "反转字符串中的单词 III") | [Go](../problems/reverse-words-in-a-string-iii) | Easy | -| 558 | [Quad Tree Intersection](https://leetcode.com/problems/quad-tree-intersection "四叉树交集") | [Go](../problems/quad-tree-intersection) | Easy | +| 558 | [Logical OR of Two Binary Grids Represented as Quad-Trees](https://leetcode.com/problems/logical-or-of-two-binary-grids-represented-as-quad-trees "四叉树交集") | [Go](../problems/logical-or-of-two-binary-grids-represented-as-quad-trees) | Medium | | 559 | [Maximum Depth of N-ary Tree](https://leetcode.com/problems/maximum-depth-of-n-ary-tree "N叉树的最大深度") | [Go](../problems/maximum-depth-of-n-ary-tree) | Easy | | 560 | [Subarray Sum Equals K](https://leetcode.com/problems/subarray-sum-equals-k "和为K的子数组") | [Go](../problems/subarray-sum-equals-k) | Medium | | 561 | [Array Partition I](https://leetcode.com/problems/array-partition-i "数组拆分 I") | [Go](../problems/array-partition-i) | Easy | diff --git a/readme/601-900.md b/readme/601-900.md index b9e0660fa..78115c110 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -289,7 +289,7 @@ LeetCode Problems' Solutions | 825 | [Friends Of Appropriate Ages](https://leetcode.com/problems/friends-of-appropriate-ages "适龄的朋友") | [Go](../problems/friends-of-appropriate-ages) | Medium | | 826 | [Most Profit Assigning Work](https://leetcode.com/problems/most-profit-assigning-work "安排工作以达到最大收益") | [Go](../problems/most-profit-assigning-work) | Medium | | 827 | [Making A Large Island](https://leetcode.com/problems/making-a-large-island "最大人工岛") | [Go](../problems/making-a-large-island) | Hard | -| 828 | [Unique Letter String](https://leetcode.com/problems/unique-letter-string "独特字符串") | [Go](../problems/unique-letter-string) | Hard | +| 828 | [Count Unique Characters of All Substrings of a Given String](https://leetcode.com/problems/count-unique-characters-of-all-substrings-of-a-given-string "独特字符串") | [Go](../problems/count-unique-characters-of-all-substrings-of-a-given-string) | Hard | | 829 | [Consecutive Numbers Sum](https://leetcode.com/problems/consecutive-numbers-sum "连续整数求和") | [Go](../problems/consecutive-numbers-sum) | Hard | | 830 | [Positions of Large Groups](https://leetcode.com/problems/positions-of-large-groups "较大分组的位置") | [Go](../problems/positions-of-large-groups) | Easy | | 831 | [Masking Personal Information](https://leetcode.com/problems/masking-personal-information "隐藏个人信息") | [Go](../problems/masking-personal-information) | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 9b9b4004c..1c8caef90 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[排序](../sort/README.md)] [[位运算](../bit-manipulation/README.md)] | Easy | | 1342 | [将数字变成 0 的操作次数](../../problems/number-of-steps-to-reduce-a-number-to-zero) | [[位运算](../bit-manipulation/README.md)] | Easy | | 1318 | [或运算的最小翻转次数](../../problems/minimum-flips-to-make-a-or-b-equal-to-c) | [[位运算](../bit-manipulation/README.md)] | Medium | | 1310 | [子数组异或查询](../../problems/xor-queries-of-a-subarray) | [[位运算](../bit-manipulation/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index 91b34835c..fc0019638 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] | Medium | | 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] | Medium | | 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index da437ed7f..e9291e5a1 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1359 | [有效的快递序列数目](../../problems/count-all-valid-pickup-and-delivery-options) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1349 | [参加考试的最大学生数](../../problems/maximum-students-taking-exam) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1340 | [跳跃游戏 V](../../problems/jump-game-v) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/graph/README.md b/tag/graph/README.md index 46ae8c5ba..906283e0a 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1361 | [验证二叉树](../../problems/validate-binary-tree-nodes) | [[图](../graph/README.md)] | Medium | | 1334 | [阈值距离内邻居最少的城市](../../problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | [[图](../graph/README.md)] | Medium | | 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 980532490..99ef5fd37 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1362 | [最接近的因数](../../problems/closest-divisors) | [[数学](../math/README.md)] | Medium | +| 1359 | [有效的快递序列数目](../../problems/count-all-valid-pickup-and-delivery-options) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1344 | [时钟指针的夹角](../../problems/angle-between-hands-of-a-clock) | [[数学](../math/README.md)] | Medium | | 1330 | [翻转子数组得到最大的数组值](../../problems/reverse-subarray-to-maximize-array-value) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1323 | [6 和 9 组成的最大数字](../../problems/maximum-69-number) | [[数学](../math/README.md)] | Easy | diff --git a/tag/sort/README.md b/tag/sort/README.md index 1948cedb1..6880ce48e 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[排序](../sort/README.md)] [[位运算](../bit-manipulation/README.md)] | Easy | | 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | | 1333 | [餐厅过滤器](../../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1329 | [将矩阵按对角线排序](../../problems/sort-the-matrix-diagonally) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index a50d6891a..42e39f2bd 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1358 | [包含所有三种字符的子字符串数目](../../problems/number-of-substrings-containing-all-three-characters) | [[字符串](../string/README.md)] | Medium | | 1347 | [制造字母异位词的最小步骤数](../../problems/minimum-number-of-steps-to-make-two-strings-anagram) | [[字符串](../string/README.md)] | Medium | | 1332 | [删除回文子序列](../../problems/remove-palindromic-subsequences) | [[字符串](../string/README.md)] | Easy | | 1328 | [破坏回文串](../../problems/break-a-palindrome) | [[字符串](../string/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 99b86e534..dcd4ad618 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -25,7 +25,7 @@ | 845 | [数组中的最长山脉](../../problems/longest-mountain-in-array) | [[双指针](../two-pointers/README.md)] | Medium | | 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 828 | [独特字符串](../../problems/unique-letter-string) | [[双指针](../two-pointers/README.md)] | Hard | +| 828 | [独特字符串](../../problems/count-unique-characters-of-all-substrings-of-a-given-string) | [[双指针](../two-pointers/README.md)] | Hard | | 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[双指针](../two-pointers/README.md)] | Medium | | 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | From 01e0aa5c7787d154bc545cbe5dc5c4c6ad8a13ce Mon Sep 17 00:00:00 2001 From: Shuo Date: Fri, 6 Mar 2020 09:30:17 +0800 Subject: [PATCH 036/145] Add: new --- README.md | 20 ++-- problems/ads-performance/README.md | 2 +- .../README.md | 4 +- .../convert-bst-to-greater-tree/README.md | 7 +- problems/find-leaves-of-binary-tree/README.md | 2 +- .../README.md | 14 +++ .../mysql_schemas.sql | 6 ++ problems/height-checker/README.md | 25 ++++- .../README.md | 67 +++++++++++++ problems/largest-multiple-of-three/README.md | 2 +- problems/linked-list-in-binary-tree/README.md | 66 +++++++++++++ .../README.md | 2 +- problems/market-analysis-ii/README.md | 2 +- .../README.md | 91 ++++++++++++++++++ .../README.md | 2 +- .../README.md | 14 +++ .../mysql_schemas.sql | 22 +++++ .../product-of-array-except-self/README.md | 2 + problems/rank-teams-by-votes/README.md | 95 +++++++++++++++++++ .../README.md | 2 +- problems/remove-duplicate-letters/README.md | 2 + .../README.md | 2 + problems/restaurant-growth/README.md | 2 +- .../README.md | 2 +- .../README.md | 6 +- .../README.md | 2 +- problems/the-dining-philosophers/README.md | 6 +- readme/301-600.md | 2 +- tag/array/README.md | 2 + tag/breadth-first-search/README.md | 1 + tag/depth-first-search/README.md | 2 +- tag/dynamic-programming/README.md | 1 + tag/hash-table/README.md | 1 + tag/linked-list/README.md | 1 + tag/sort/README.md | 1 + tag/tree/README.md | 3 +- 36 files changed, 450 insertions(+), 33 deletions(-) create mode 100644 problems/get-the-second-most-recent-activity/README.md create mode 100644 problems/get-the-second-most-recent-activity/mysql_schemas.sql create mode 100644 problems/how-many-numbers-are-smaller-than-the-current-number/README.md create mode 100644 problems/linked-list-in-binary-tree/README.md create mode 100644 problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/README.md create mode 100644 problems/number-of-trusted-contacts-of-a-customer/README.md create mode 100644 problems/number-of-trusted-contacts-of-a-customer/mysql_schemas.sql create mode 100644 problems/rank-teams-by-votes/README.md diff --git a/README.md b/README.md index ee918bcdc..a0092daee 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,12 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1369 | [Get the Second Most Recent Activity](https://leetcode.com/problems/get-the-second-most-recent-activity) 🔒 | [MySQL](problems/get-the-second-most-recent-activity) | Hard | +| 1368 | [Minimum Cost to Make at Least One Valid Path in a Grid](https://leetcode.com/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid "使网格图至少有一条有效路径的最小代价") | [Go](problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | Hard | +| 1367 | [Linked List in Binary Tree](https://leetcode.com/problems/linked-list-in-binary-tree "二叉树中的列表") | [Go](problems/linked-list-in-binary-tree) | Medium | +| 1366 | [Rank Teams by Votes](https://leetcode.com/problems/rank-teams-by-votes "通过投票对团队排名") | [Go](problems/rank-teams-by-votes) | Medium | +| 1365 | [How Many Numbers Are Smaller Than the Current Number](https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number "有多少小于当前数字的数字") | [Go](problems/how-many-numbers-are-smaller-than-the-current-number) | Easy | +| 1364 | [Number of Trusted Contacts of a Customer](https://leetcode.com/problems/number-of-trusted-contacts-of-a-customer "顾客的可信联系人数量") 🔒 | [MySQL](problems/number-of-trusted-contacts-of-a-customer) | Medium | | 1363 | [Largest Multiple of Three](https://leetcode.com/problems/largest-multiple-of-three "形成三的最大倍数") | [Go](problems/largest-multiple-of-three) | Hard | | 1362 | [Closest Divisors](https://leetcode.com/problems/closest-divisors "最接近的因数") | [Go](problems/closest-divisors) | Medium | | 1361 | [Validate Binary Tree Nodes](https://leetcode.com/problems/validate-binary-tree-nodes "验证二叉树") | [Go](problems/validate-binary-tree-nodes) | Medium | @@ -75,7 +81,7 @@ LeetCode Problems' Solutions | 1353 | [Maximum Number of Events That Can Be Attended](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended "最多可以参加的会议数目") | [Go](problems/maximum-number-of-events-that-can-be-attended) | Medium | | 1352 | [Product of the Last K Numbers](https://leetcode.com/problems/product-of-the-last-k-numbers "最后 K 个数的乘积") | [Go](problems/product-of-the-last-k-numbers) | Medium | | 1351 | [Count Negative Numbers in a Sorted Matrix](https://leetcode.com/problems/count-negative-numbers-in-a-sorted-matrix "统计有序矩阵中的负数") | [Go](problems/count-negative-numbers-in-a-sorted-matrix) | Easy | -| 1350 | [Students With Invalid Departments](https://leetcode.com/problems/students-with-invalid-departments) 🔒 | [MySQL](problems/students-with-invalid-departments) | Easy | +| 1350 | [Students With Invalid Departments](https://leetcode.com/problems/students-with-invalid-departments "院系无效的学生") 🔒 | [MySQL](problems/students-with-invalid-departments) | Easy | | 1349 | [Maximum Students Taking Exam](https://leetcode.com/problems/maximum-students-taking-exam "参加考试的最大学生数") | [Go](problems/maximum-students-taking-exam) | Hard | | 1348 | [Tweet Counts Per Frequency](https://leetcode.com/problems/tweet-counts-per-frequency "推文计数") | [Go](problems/tweet-counts-per-frequency) | Medium | | 1347 | [Minimum Number of Steps to Make Two Strings Anagram](https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram "制造字母异位词的最小步骤数") | [Go](problems/minimum-number-of-steps-to-make-two-strings-anagram) | Medium | @@ -89,7 +95,7 @@ LeetCode Problems' Solutions | 1339 | [Maximum Product of Splitted Binary Tree](https://leetcode.com/problems/maximum-product-of-splitted-binary-tree "分裂二叉树的最大乘积") | [Go](problems/maximum-product-of-splitted-binary-tree) | Medium | | 1338 | [Reduce Array Size to The Half](https://leetcode.com/problems/reduce-array-size-to-the-half "数组大小减半") | [Go](problems/reduce-array-size-to-the-half) | Medium | | 1337 | [The K Weakest Rows in a Matrix](https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix "方阵中战斗力最弱的 K 行") | [Go](problems/the-k-weakest-rows-in-a-matrix) | Easy | -| 1336 | [Number of Transactions per Visit](https://leetcode.com/problems/number-of-transactions-per-visit) 🔒 | [MySQL](problems/number-of-transactions-per-visit) | Hard | +| 1336 | [Number of Transactions per Visit](https://leetcode.com/problems/number-of-transactions-per-visit "每次访问的交易次数") 🔒 | [MySQL](problems/number-of-transactions-per-visit) | Hard | | 1335 | [Minimum Difficulty of a Job Schedule](https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule "工作计划的最低难度") | [Go](problems/minimum-difficulty-of-a-job-schedule) | Hard | | 1334 | [Find the City With the Smallest Number of Neighbors at a Threshold Distance](https://leetcode.com/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance "阈值距离内邻居最少的城市") | [Go](problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | Medium | | 1333 | [Filter Restaurants by Vegan-Friendly, Price and Distance](https://leetcode.com/problems/filter-restaurants-by-vegan-friendly-price-and-distance "餐厅过滤器") | [Go](problems/filter-restaurants-by-vegan-friendly-price-and-distance) | Medium | @@ -98,13 +104,13 @@ LeetCode Problems' Solutions | 1330 | [Reverse Subarray To Maximize Array Value](https://leetcode.com/problems/reverse-subarray-to-maximize-array-value "翻转子数组得到最大的数组值") | [Go](problems/reverse-subarray-to-maximize-array-value) | Hard | | 1329 | [Sort the Matrix Diagonally](https://leetcode.com/problems/sort-the-matrix-diagonally "将矩阵按对角线排序") | [Go](problems/sort-the-matrix-diagonally) | Medium | | 1328 | [Break a Palindrome](https://leetcode.com/problems/break-a-palindrome "破坏回文串") | [Go](problems/break-a-palindrome) | Medium | -| 1327 | [List the Products Ordered in a Period](https://leetcode.com/problems/list-the-products-ordered-in-a-period) 🔒 | [MySQL](problems/list-the-products-ordered-in-a-period) | Easy | +| 1327 | [List the Products Ordered in a Period](https://leetcode.com/problems/list-the-products-ordered-in-a-period "列出指定时间段内所有的下单产品") 🔒 | [MySQL](problems/list-the-products-ordered-in-a-period) | Easy | | 1326 | [Minimum Number of Taps to Open to Water a Garden](https://leetcode.com/problems/minimum-number-of-taps-to-open-to-water-a-garden "灌溉花园的最少水龙头数目") | [Go](problems/minimum-number-of-taps-to-open-to-water-a-garden) | Hard | | 1325 | [Delete Leaves With a Given Value](https://leetcode.com/problems/delete-leaves-with-a-given-value "删除给定值的叶子节点") | [Go](problems/delete-leaves-with-a-given-value) | Medium | | 1324 | [Print Words Vertically](https://leetcode.com/problems/print-words-vertically "竖直打印单词") | [Go](problems/print-words-vertically) | Medium | | 1323 | [Maximum 69 Number](https://leetcode.com/problems/maximum-69-number "6 和 9 组成的最大数字") | [Go](problems/maximum-69-number) | Easy | -| 1322 | [Ads Performance](https://leetcode.com/problems/ads-performance) 🔒 | [MySQL](problems/ads-performance) | Easy | -| 1321 | [Restaurant Growth](https://leetcode.com/problems/restaurant-growth) 🔒 | [MySQL](problems/restaurant-growth) | Medium | +| 1322 | [Ads Performance](https://leetcode.com/problems/ads-performance "广告效果") 🔒 | [MySQL](problems/ads-performance) | Easy | +| 1321 | [Restaurant Growth](https://leetcode.com/problems/restaurant-growth "餐馆营业额变化增长") 🔒 | [MySQL](problems/restaurant-growth) | Medium | | 1320 | [Minimum Distance to Type a Word Using Two Fingers](https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers "二指输入的的最小距离") | [Go](problems/minimum-distance-to-type-a-word-using-two-fingers) | Hard | | 1319 | [Number of Operations to Make Network Connected](https://leetcode.com/problems/number-of-operations-to-make-network-connected "连通网络的操作次数") | [Go](problems/number-of-operations-to-make-network-connected) | Medium | | 1318 | [Minimum Flips to Make a OR b Equal to c](https://leetcode.com/problems/minimum-flips-to-make-a-or-b-equal-to-c "或运算的最小翻转次数") | [Go](problems/minimum-flips-to-make-a-or-b-equal-to-c) | Medium | @@ -117,7 +123,7 @@ LeetCode Problems' Solutions | 1311 | [Get Watched Videos by Your Friends](https://leetcode.com/problems/get-watched-videos-by-your-friends "获取你好友已观看的视频") | [Go](problems/get-watched-videos-by-your-friends) | Medium | | 1310 | [XOR Queries of a Subarray](https://leetcode.com/problems/xor-queries-of-a-subarray "子数组异或查询") | [Go](problems/xor-queries-of-a-subarray) | Medium | | 1309 | [Decrypt String from Alphabet to Integer Mapping](https://leetcode.com/problems/decrypt-string-from-alphabet-to-integer-mapping "解码字母到整数映射") | [Go](problems/decrypt-string-from-alphabet-to-integer-mapping) | Easy | -| 1308 | [Running Total for Different Genders](https://leetcode.com/problems/running-total-for-different-genders) 🔒 | [MySQL](problems/running-total-for-different-genders) | Medium | +| 1308 | [Running Total for Different Genders](https://leetcode.com/problems/running-total-for-different-genders "不同性别每日分数总计") 🔒 | [MySQL](problems/running-total-for-different-genders) | Medium | | 1307 | [Verbal Arithmetic Puzzle](https://leetcode.com/problems/verbal-arithmetic-puzzle "口算难题") | [Go](problems/verbal-arithmetic-puzzle) | Hard | | 1306 | [Jump Game III](https://leetcode.com/problems/jump-game-iii "跳跃游戏 III") | [Go](problems/jump-game-iii) | Medium | | 1305 | [All Elements in Two Binary Search Trees](https://leetcode.com/problems/all-elements-in-two-binary-search-trees "两棵二叉搜索树中的所有元素") | [Go](problems/all-elements-in-two-binary-search-trees) | Medium | @@ -266,7 +272,7 @@ LeetCode Problems' Solutions | 1162 | [As Far from Land as Possible](https://leetcode.com/problems/as-far-from-land-as-possible "地图分析") | [Go](problems/as-far-from-land-as-possible) | Medium | | 1161 | [Maximum Level Sum of a Binary Tree](https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree "最大层内元素和") | [Go](problems/maximum-level-sum-of-a-binary-tree) | Medium | | 1160 | [Find Words That Can Be Formed by Characters](https://leetcode.com/problems/find-words-that-can-be-formed-by-characters "拼写单词") | [Go](problems/find-words-that-can-be-formed-by-characters) | Easy | -| 1159 | [Market Analysis II](https://leetcode.com/problems/market-analysis-ii) 🔒 | [MySQL](problems/market-analysis-ii) | Hard | +| 1159 | [Market Analysis II](https://leetcode.com/problems/market-analysis-ii "市场分析 II") 🔒 | [MySQL](problems/market-analysis-ii) | Hard | | 1158 | [Market Analysis I](https://leetcode.com/problems/market-analysis-i "市场分析 I") 🔒 | [MySQL](problems/market-analysis-i) | Medium | | 1157 | [Online Majority Element In Subarray](https://leetcode.com/problems/online-majority-element-in-subarray "子数组中占绝大多数的元素") | [Go](problems/online-majority-element-in-subarray) | Hard | | 1156 | [Swap For Longest Repeated Character Substring](https://leetcode.com/problems/swap-for-longest-repeated-character-substring "单字符重复子串的最大长度") | [Go](problems/swap-for-longest-repeated-character-substring) | Medium | diff --git a/problems/ads-performance/README.md b/problems/ads-performance/README.md index 713d3a9a8..91befe0f6 100644 --- a/problems/ads-performance/README.md +++ b/problems/ads-performance/README.md @@ -9,7 +9,7 @@                  [Next >](../maximum-69-number "Maximum 69 Number") -## [1322. Ads Performance (Easy)](https://leetcode.com/problems/ads-performance "") +## [1322. Ads Performance (Easy)](https://leetcode.com/problems/ads-performance "广告效果")

Table: Ads

diff --git a/problems/binary-search-tree-to-greater-sum-tree/README.md b/problems/binary-search-tree-to-greater-sum-tree/README.md
index 513955281..873ca95a4 100644
--- a/problems/binary-search-tree-to-greater-sum-tree/README.md
+++ b/problems/binary-search-tree-to-greater-sum-tree/README.md
@@ -36,7 +36,7 @@
 

 

-

Note:

+

Constraints:

  1. The number of nodes in the tree is between 1 and 100.
  2. @@ -46,7 +46,7 @@
    -
     
    +
    Note: This question is the same as 538: https://leetcode.com/problems/convert-bst-to-greater-tree/
    diff --git a/problems/convert-bst-to-greater-tree/README.md b/problems/convert-bst-to-greater-tree/README.md index 4fcf2c680..29a9af0b8 100644 --- a/problems/convert-bst-to-greater-tree/README.md +++ b/problems/convert-bst-to-greater-tree/README.md @@ -13,8 +13,8 @@

    Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.

    -

    -Example: +

    Example:

    +
     Input: The root of a Binary Search Tree like this:
                   5
    @@ -26,7 +26,8 @@
                 /   \
               20     13
     
    -

    + +

    Note: This question is the same as 1038: https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree/

    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/find-leaves-of-binary-tree/README.md b/problems/find-leaves-of-binary-tree/README.md index 6c0bda5a5..a60428896 100644 --- a/problems/find-leaves-of-binary-tree/README.md +++ b/problems/find-leaves-of-binary-tree/README.md @@ -9,7 +9,7 @@                  [Next >](../valid-perfect-square "Valid Perfect Square") -## [366. Find Leaves of Binary Tree (Medium)](https://leetcode.com/problems/find-leaves-of-binary-tree "寻找完全二叉树的叶子节点") +## [366. Find Leaves of Binary Tree (Medium)](https://leetcode.com/problems/find-leaves-of-binary-tree "寻找二叉树的叶子节点")

    Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all leaves, repeat until the tree is empty.

    diff --git a/problems/get-the-second-most-recent-activity/README.md b/problems/get-the-second-most-recent-activity/README.md new file mode 100644 index 000000000..4953f59b4 --- /dev/null +++ b/problems/get-the-second-most-recent-activity/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../minimum-cost-to-make-at-least-one-valid-path-in-a-grid "Minimum Cost to Make at Least One Valid Path in a Grid") +                 +Next > + +## [1369. Get the Second Most Recent Activity (Hard)](https://leetcode.com/problems/get-the-second-most-recent-activity "") + + diff --git a/problems/get-the-second-most-recent-activity/mysql_schemas.sql b/problems/get-the-second-most-recent-activity/mysql_schemas.sql new file mode 100644 index 000000000..880eded3e --- /dev/null +++ b/problems/get-the-second-most-recent-activity/mysql_schemas.sql @@ -0,0 +1,6 @@ +Create table If Not Exists UserActivity (username varchar(30), activity varchar(30), startDate date, endDate date); +Truncate table UserActivity; +insert into UserActivity (username, activity, startDate, endDate) values ('Alice', 'Travel', '2020-02-12', '2020-02-20'); +insert into UserActivity (username, activity, startDate, endDate) values ('Alice', 'Dancing', '2020-02-21', '2020-02-23'); +insert into UserActivity (username, activity, startDate, endDate) values ('Alice', 'Travel', '2020-02-24', '2020-02-28'); +insert into UserActivity (username, activity, startDate, endDate) values ('Bob', 'Travel', '2020-02-11', '2020-02-18'); diff --git a/problems/height-checker/README.md b/problems/height-checker/README.md index 440eb14b1..13b28d7d4 100644 --- a/problems/height-checker/README.md +++ b/problems/height-checker/README.md @@ -17,9 +17,32 @@

     

    Example 1:

    -
    Input: heights = [1,1,4,2,1,3]
    +
    +
    +Input: heights = [1,1,4,2,1,3]
     Output: 3
    +Explanation: 
    +Current array : [1,1,4,2,1,3]
    +Target array  : [1,1,1,2,3,4]
    +On index 2 (0-based) we have 4 vs 1 so we have to move this student.
    +On index 4 (0-based) we have 1 vs 3 so we have to move this student.
    +On index 5 (0-based) we have 3 vs 4 so we have to move this student.
    +
    + +

    Example 2:

    + +
    +Input: heights = [5,1,2,3,4]
    +Output: 5
     
    + +

    Example 3:

    + +
    +Input: heights = [1,2,3,4,5]
    +Output: 0
    +
    +

     

    Constraints:

    diff --git a/problems/how-many-numbers-are-smaller-than-the-current-number/README.md b/problems/how-many-numbers-are-smaller-than-the-current-number/README.md new file mode 100644 index 000000000..9f8056258 --- /dev/null +++ b/problems/how-many-numbers-are-smaller-than-the-current-number/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../number-of-trusted-contacts-of-a-customer "Number of Trusted Contacts of a Customer") +                 +[Next >](../rank-teams-by-votes "Rank Teams by Votes") + +## [1365. How Many Numbers Are Smaller Than the Current Number (Easy)](https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number "有多少小于当前数字的数字") + +

    Given the array nums, for each nums[i] find out how many numbers in the array are smaller than it. That is, for each nums[i] you have to count the number of valid j's such that j != i and nums[j] < nums[i].

    + +

    Return the answer in an array.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [8,1,2,2,3]
    +Output: [4,0,1,1,3]
    +Explanation: 
    +For nums[0]=8 there exist four smaller numbers than it (1, 2, 2 and 3). 
    +For nums[1]=1 does not exist any smaller number than it.
    +For nums[2]=2 there exist one smaller number than it (1). 
    +For nums[3]=2 there exist one smaller number than it (1). 
    +For nums[4]=3 there exist three smaller numbers than it (1, 2 and 2).
    +
    + +

    Example 2:

    + +
    +Input: nums = [6,5,4,8]
    +Output: [2,1,0,3]
    +
    + +

    Example 3:

    + +
    +Input: nums = [7,7,7,7]
    +Output: [0,0,0,0]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= nums.length <= 500
    • +
    • 0 <= nums[i] <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +Brute force for each array element. +
    + +
    +Hint 2 +In order to improve the time complexity, we can sort the array and get the answer for each array element. +
    diff --git a/problems/largest-multiple-of-three/README.md b/problems/largest-multiple-of-three/README.md index c32499e8f..72e8b52e2 100644 --- a/problems/largest-multiple-of-three/README.md +++ b/problems/largest-multiple-of-three/README.md @@ -7,7 +7,7 @@ [< Previous](../closest-divisors "Closest Divisors")                  -Next > +[Next >](../number-of-trusted-contacts-of-a-customer "Number of Trusted Contacts of a Customer") ## [1363. Largest Multiple of Three (Hard)](https://leetcode.com/problems/largest-multiple-of-three "形成三的最大倍数") diff --git a/problems/linked-list-in-binary-tree/README.md b/problems/linked-list-in-binary-tree/README.md new file mode 100644 index 000000000..55de122a8 --- /dev/null +++ b/problems/linked-list-in-binary-tree/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../rank-teams-by-votes "Rank Teams by Votes") +                 +[Next >](../minimum-cost-to-make-at-least-one-valid-path-in-a-grid "Minimum Cost to Make at Least One Valid Path in a Grid") + +## [1367. Linked List in Binary Tree (Medium)](https://leetcode.com/problems/linked-list-in-binary-tree "二叉树中的列表") + +

    Given a binary tree root and a linked list with head as the first node. 

    + +

    Return True if all the elements in the linked list starting from the head correspond to some downward path connected in the binary tree otherwise return False.

    + +

    In this context downward path means a path that starts at some node and goes downwards.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: head = [4,2,8], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3]
    +Output: true
    +Explanation: Nodes in blue form a subpath in the binary Tree.  
    +
    + +

    Example 2:

    + +

    + +
    +Input: head = [1,4,2,6], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3]
    +Output: true
    +
    + +

    Example 3:

    + +
    +Input: head = [1,4,2,6,8], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3]
    +Output: false
    +Explanation: There is no path in the binary tree that contains all the elements of the linked list from head.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= node.val <= 100 for each node in the linked list and binary tree.
    • +
    • The given linked list will contain between 1 and 100 nodes.
    • +
    • The given binary tree will contain between 1 and 2500 nodes.
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Create recursive function, given a pointer in a Linked List and any node in the Binary Tree. Check if all the elements in the linked list starting from the head correspond to some downward path in the binary tree. +
    diff --git a/problems/list-the-products-ordered-in-a-period/README.md b/problems/list-the-products-ordered-in-a-period/README.md index acfd83aae..26471f8b5 100644 --- a/problems/list-the-products-ordered-in-a-period/README.md +++ b/problems/list-the-products-ordered-in-a-period/README.md @@ -9,7 +9,7 @@                  [Next >](../break-a-palindrome "Break a Palindrome") -## [1327. List the Products Ordered in a Period (Easy)](https://leetcode.com/problems/list-the-products-ordered-in-a-period "") +## [1327. List the Products Ordered in a Period (Easy)](https://leetcode.com/problems/list-the-products-ordered-in-a-period "列出指定时间段内所有的下单产品") SQL Schema

    Table: Products

    diff --git a/problems/market-analysis-ii/README.md b/problems/market-analysis-ii/README.md index 6638e8aa6..84e817704 100644 --- a/problems/market-analysis-ii/README.md +++ b/problems/market-analysis-ii/README.md @@ -9,7 +9,7 @@                  [Next >](../find-words-that-can-be-formed-by-characters "Find Words That Can Be Formed by Characters") -## [1159. Market Analysis II (Hard)](https://leetcode.com/problems/market-analysis-ii "") +## [1159. Market Analysis II (Hard)](https://leetcode.com/problems/market-analysis-ii "市场分析 II")

    Table: Users

    diff --git a/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/README.md b/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/README.md new file mode 100644 index 000000000..86f4c2a97 --- /dev/null +++ b/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/README.md @@ -0,0 +1,91 @@ + + + + + + + +[< Previous](../linked-list-in-binary-tree "Linked List in Binary Tree") +                 +[Next >](../get-the-second-most-recent-activity "Get the Second Most Recent Activity") + +## [1368. Minimum Cost to Make at Least One Valid Path in a Grid (Hard)](https://leetcode.com/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid "使网格图至少有一条有效路径的最小代价") + +Given a m x n grid. Each cell of the grid has a sign pointing to the next cell you should visit if you are currently in this cell. The sign of grid[i][j] can be: +
      +
    • 1 which means go to the cell to the right. (i.e go from grid[i][j] to grid[i][j + 1])
    • +
    • 2 which means go to the cell to the left. (i.e go from grid[i][j] to grid[i][j - 1])
    • +
    • 3 which means go to the lower cell. (i.e go from grid[i][j] to grid[i + 1][j])
    • +
    • 4 which means go to the upper cell. (i.e go from grid[i][j] to grid[i - 1][j])
    • +
    + +

    Notice that there could be some invalid signs on the cells of the grid which points outside the grid.

    + +

    You will initially start at the upper left cell (0,0). A valid path in the grid is a path which starts from the upper left cell (0,0) and ends at the bottom-right cell (m - 1, n - 1) following the signs on the grid. The valid path doesn't have to be the shortest.

    + +

    You can modify the sign on a cell with cost = 1. You can modify the sign on a cell one time only.

    + +

    Return the minimum cost to make the grid have at least one valid path.

    + +

     

    +

    Example 1:

    + +
    +Input: grid = [[1,1,1,1],[2,2,2,2],[1,1,1,1],[2,2,2,2]]
    +Output: 3
    +Explanation: You will start at point (0, 0).
    +The path to (3, 3) is as follows. (0, 0) --> (0, 1) --> (0, 2) --> (0, 3) change the arrow to down with cost = 1 --> (1, 3) --> (1, 2) --> (1, 1) --> (1, 0) change the arrow to down with cost = 1 --> (2, 0) --> (2, 1) --> (2, 2) --> (2, 3) change the arrow to down with cost = 1 --> (3, 3)
    +The total cost = 3.
    +
    + +

    Example 2:

    + +
    +Input: grid = [[1,1,3],[3,2,2],[1,1,4]]
    +Output: 0
    +Explanation: You can follow the path from (0, 0) to (2, 2).
    +
    + +

    Example 3:

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

    Example 4:

    + +
    +Input: grid = [[2,2,2],[2,2,2]]
    +Output: 3
    +
    + +

    Example 5:

    + +
    +Input: grid = [[4]]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 100
    • +
    + +### Related Topics + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + +### Hints +
    +Hint 1 +Build a graph where grid[i][j] is connected to all the four side-adjacent cells with weighted edge. the weight is 0 if the sign is pointing to the adjacent cell or 1 otherwise. +
    + +
    +Hint 2 +Do BFS from (0, 0) visit all edges with weight = 0 first. the answer is the distance to (m -1, n - 1). +
    diff --git a/problems/number-of-transactions-per-visit/README.md b/problems/number-of-transactions-per-visit/README.md index fce4ce6f3..61e8f63b9 100644 --- a/problems/number-of-transactions-per-visit/README.md +++ b/problems/number-of-transactions-per-visit/README.md @@ -9,7 +9,7 @@                  [Next >](../the-k-weakest-rows-in-a-matrix "The K Weakest Rows in a Matrix") -## [1336. Number of Transactions per Visit (Hard)](https://leetcode.com/problems/number-of-transactions-per-visit "") +## [1336. Number of Transactions per Visit (Hard)](https://leetcode.com/problems/number-of-transactions-per-visit "每次访问的交易次数")

    Table: Visits

    diff --git a/problems/number-of-trusted-contacts-of-a-customer/README.md b/problems/number-of-trusted-contacts-of-a-customer/README.md
    new file mode 100644
    index 000000000..1408b9119
    --- /dev/null
    +++ b/problems/number-of-trusted-contacts-of-a-customer/README.md
    @@ -0,0 +1,14 @@
    +
    +
    +
    +
    +
    +
    +
    +[< Previous](../largest-multiple-of-three "Largest Multiple of Three")
    +                
    +[Next >](../how-many-numbers-are-smaller-than-the-current-number "How Many Numbers Are Smaller Than the Current Number")
    +
    +## [1364. Number of Trusted Contacts of a Customer (Medium)](https://leetcode.com/problems/number-of-trusted-contacts-of-a-customer "顾客的可信联系人数量")
    +
    +
    diff --git a/problems/number-of-trusted-contacts-of-a-customer/mysql_schemas.sql b/problems/number-of-trusted-contacts-of-a-customer/mysql_schemas.sql
    new file mode 100644
    index 000000000..608197d7b
    --- /dev/null
    +++ b/problems/number-of-trusted-contacts-of-a-customer/mysql_schemas.sql
    @@ -0,0 +1,22 @@
    +Create table If Not Exists Customers (customer_id int, customer_name varchar(20), email varchar(30));
    +Create table If Not Exists Contacts (user_id int, contact_name varchar(20), contact_email varchar(30));
    +Create table If Not Exists Invoices (invoice_id int, price int, user_id int);
    +Truncate table Customers;
    +insert into Customers (customer_id, customer_name, email) values ('1', 'Alice', 'alice@leetcode.com');
    +insert into Customers (customer_id, customer_name, email) values ('2', 'Bob', 'bob@leetcode.com');
    +insert into Customers (customer_id, customer_name, email) values ('13', 'John', 'john@leetcode.com');
    +insert into Customers (customer_id, customer_name, email) values ('6', 'Alex', 'alex@leetcode.com');
    +Truncate table Contacts;
    +insert into Contacts (user_id, contact_name, contact_email) values ('1', 'Bob', 'bob@leetcode.com');
    +insert into Contacts (user_id, contact_name, contact_email) values ('1', 'John', 'john@leetcode.com');
    +insert into Contacts (user_id, contact_name, contact_email) values ('1', 'Jal', 'jal@leetcode.com');
    +insert into Contacts (user_id, contact_name, contact_email) values ('2', 'Omar', 'omar@leetcode.com');
    +insert into Contacts (user_id, contact_name, contact_email) values ('2', 'Meir', 'meir@leetcode.com');
    +insert into Contacts (user_id, contact_name, contact_email) values ('6', 'Alice', 'alice@leetcode.com');
    +Truncate table Invoices;
    +insert into Invoices (invoice_id, price, user_id) values ('77', '100', '1');
    +insert into Invoices (invoice_id, price, user_id) values ('88', '200', '1');
    +insert into Invoices (invoice_id, price, user_id) values ('99', '300', '2');
    +insert into Invoices (invoice_id, price, user_id) values ('66', '400', '2');
    +insert into Invoices (invoice_id, price, user_id) values ('55', '500', '13');
    +insert into Invoices (invoice_id, price, user_id) values ('44', '60', '6');
    diff --git a/problems/product-of-array-except-self/README.md b/problems/product-of-array-except-self/README.md
    index bdf68599c..b542b1fec 100644
    --- a/problems/product-of-array-except-self/README.md
    +++ b/problems/product-of-array-except-self/README.md
    @@ -20,6 +20,8 @@
     Output: [24,12,8,6]
     
    +

    Constraint: It's guaranteed that the product of the elements of any preffix or suffix of the array (including the whole array) fits in a 32 bit integer.

    +

    Note: Please solve it without division and in O(n).

    Follow up:
    diff --git a/problems/rank-teams-by-votes/README.md b/problems/rank-teams-by-votes/README.md new file mode 100644 index 000000000..f041f7c56 --- /dev/null +++ b/problems/rank-teams-by-votes/README.md @@ -0,0 +1,95 @@ + + + + + + + +[< Previous](../how-many-numbers-are-smaller-than-the-current-number "How Many Numbers Are Smaller Than the Current Number") +                 +[Next >](../linked-list-in-binary-tree "Linked List in Binary Tree") + +## [1366. Rank Teams by Votes (Medium)](https://leetcode.com/problems/rank-teams-by-votes "通过投票对团队排名") + +

    In a special ranking system, each voter gives a rank from highest to lowest to all teams participated in the competition.

    + +

    The ordering of teams is decided by who received the most position-one votes. If two or more teams tie in the first position, we consider the second position to resolve the conflict, if they tie again, we continue this process until the ties are resolved. If two or more teams are still tied after considering all positions, we rank them alphabetically based on their team letter.

    + +

    Given an array of strings votes which is the votes of all voters in the ranking systems. Sort all teams according to the ranking system described above.

    + +

    Return a string of all teams sorted by the ranking system.

    + +

     

    +

    Example 1:

    + +
    +Input: votes = ["ABC","ACB","ABC","ACB","ACB"]
    +Output: "ACB"
    +Explanation: Team A was ranked first place by 5 voters. No other team was voted as first place so team A is the first team.
    +Team B was ranked second by 2 voters and was ranked third by 3 voters.
    +Team C was ranked second by 3 voters and was ranked third by 2 voters.
    +As most of the voters ranked C second, team C is the second team and team B is the third.
    +
    + +

    Example 2:

    + +
    +Input: votes = ["WXYZ","XYZW"]
    +Output: "XWYZ"
    +Explanation: X is the winner due to tie-breaking rule. X has same votes as W for the first position but X has one vote as second position while W doesn't have any votes as second position. 
    +
    + +

    Example 3:

    + +
    +Input: votes = ["ZMNAGUEDSJYLBOPHRQICWFXTVK"]
    +Output: "ZMNAGUEDSJYLBOPHRQICWFXTVK"
    +Explanation: Only one voter so his votes are used for the ranking.
    +
    + +

    Example 4:

    + +
    +Input: votes = ["BCA","CAB","CBA","ABC","ACB","BAC"]
    +Output: "ABC"
    +Explanation: 
    +Team A was ranked first by 2 voters, second by 2 voters and third by 2 voters.
    +Team B was ranked first by 2 voters, second by 2 voters and third by 2 voters.
    +Team C was ranked first by 2 voters, second by 2 voters and third by 2 voters.
    +There is a tie and we rank teams ascending by their IDs.
    +
    + +

    Example 5:

    + +
    +Input: votes = ["M","M","M","M"]
    +Output: "M"
    +Explanation: Only team M in the competition so it has the first rank.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= votes.length <= 1000
    • +
    • 1 <= votes[i].length <= 26
    • +
    • votes[i].length == votes[j].length for 0 <= i, j < votes.length.
    • +
    • votes[i][j] is an English upper-case letter.
    • +
    • All characters of votes[i] are unique.
    • +
    • All the characters that occur in votes[0] also occur in votes[j] where 1 <= j < votes.length.
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Build array rank where rank[i][j] is the number of votes for team i to be the j-th rank. +
    + +
    +Hint 2 +Sort the trams by rank array. if rank array is the same for two or more teams, sort them by the ID in ascending order. +
    diff --git a/problems/rearrange-string-k-distance-apart/README.md b/problems/rearrange-string-k-distance-apart/README.md index 210352a9b..8ab0f8b6e 100644 --- a/problems/rearrange-string-k-distance-apart/README.md +++ b/problems/rearrange-string-k-distance-apart/README.md @@ -43,9 +43,9 @@
    ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] [[Heap](../../tag/heap/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions 1. [Task Scheduler](../task-scheduler) (Medium) diff --git a/problems/remove-duplicate-letters/README.md b/problems/remove-duplicate-letters/README.md index 7de020501..996d871f6 100644 --- a/problems/remove-duplicate-letters/README.md +++ b/problems/remove-duplicate-letters/README.md @@ -27,6 +27,8 @@ Output: "acdb"
+

Note: This question is the same as 1081: https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/

+ ### Related Topics [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/remove-duplicates-from-sorted-list-ii/README.md b/problems/remove-duplicates-from-sorted-list-ii/README.md index ec0ae0b3f..a59209fb5 100644 --- a/problems/remove-duplicates-from-sorted-list-ii/README.md +++ b/problems/remove-duplicates-from-sorted-list-ii/README.md @@ -13,6 +13,8 @@

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.

+

Return the linked list sorted as well.

+

Example 1:

diff --git a/problems/restaurant-growth/README.md b/problems/restaurant-growth/README.md
index 71b2ba3fb..4f767373e 100644
--- a/problems/restaurant-growth/README.md
+++ b/problems/restaurant-growth/README.md
@@ -9,7 +9,7 @@
                 
 [Next >](../ads-performance "Ads Performance")
 
-## [1321. Restaurant Growth (Medium)](https://leetcode.com/problems/restaurant-growth "")
+## [1321. Restaurant Growth (Medium)](https://leetcode.com/problems/restaurant-growth "餐馆营业额变化增长")
 
 

Table: Customer

diff --git a/problems/running-total-for-different-genders/README.md b/problems/running-total-for-different-genders/README.md
index 3c975341e..9d0db8e7d 100644
--- a/problems/running-total-for-different-genders/README.md
+++ b/problems/running-total-for-different-genders/README.md
@@ -9,7 +9,7 @@
                 
 [Next >](../decrypt-string-from-alphabet-to-integer-mapping "Decrypt String from Alphabet to Integer Mapping")
 
-## [1308. Running Total for Different Genders (Medium)](https://leetcode.com/problems/running-total-for-different-genders "")
+## [1308. Running Total for Different Genders (Medium)](https://leetcode.com/problems/running-total-for-different-genders "不同性别每日分数总计")
 
 

Table: Scores

diff --git a/problems/smallest-subsequence-of-distinct-characters/README.md b/problems/smallest-subsequence-of-distinct-characters/README.md
index c0a2b13e1..51438c964 100644
--- a/problems/smallest-subsequence-of-distinct-characters/README.md
+++ b/problems/smallest-subsequence-of-distinct-characters/README.md
@@ -13,8 +13,6 @@
 
 

Return the lexicographically smallest subsequence of text that contains all the distinct characters of text exactly once.

-

 

-

Example 1:

@@ -48,14 +46,14 @@
 
 

 

-

Note:

+

Constraints:

  1. 1 <= text.length <= 1000
  2. text consists of lowercase English letters.
-

 

+

Note: This question is the same as 316: https://leetcode.com/problems/remove-duplicate-letters/

diff --git a/problems/students-with-invalid-departments/README.md b/problems/students-with-invalid-departments/README.md index 2a1b9c1ec..1810f84f6 100644 --- a/problems/students-with-invalid-departments/README.md +++ b/problems/students-with-invalid-departments/README.md @@ -9,6 +9,6 @@                  [Next >](../count-negative-numbers-in-a-sorted-matrix "Count Negative Numbers in a Sorted Matrix") -## [1350. Students With Invalid Departments (Easy)](https://leetcode.com/problems/students-with-invalid-departments "") +## [1350. Students With Invalid Departments (Easy)](https://leetcode.com/problems/students-with-invalid-departments "院系无效的学生") diff --git a/problems/the-dining-philosophers/README.md b/problems/the-dining-philosophers/README.md index c3718c5ca..297fcfa94 100644 --- a/problems/the-dining-philosophers/README.md +++ b/problems/the-dining-philosophers/README.md @@ -17,7 +17,7 @@

Eating is not limited by the remaining amounts of spaghetti or stomach space; an infinite supply and an infinite demand are assumed.

-

Design a discipline of behavior (a concurrent algorithm) such that no philosopher will starve; i.e., each can forever continue to alternate between eating and thinking, assuming that no philosopher can know when others may want to eat or think.

+

Design a discipline of behaviour (a concurrent algorithm) such that no philosopher will starve; i.e., each can forever continue to alternate between eating and thinking, assuming that no philosopher can know when others may want to eat or think.

@@ -31,11 +31,11 @@
  • philosopher is the id of the philosopher who wants to eat.
  • pickLeftFork and pickRightFork are functions you can call to pick the corresponding forks of that philosopher.
  • eat is a function you can call to let the philosopher eat once he has picked both forks.
  • -
  • putLeftFork and pickRightFork are functions you can call to put down the corresponding forks of that philosopher.
  • +
  • putLeftFork and putRightFork are functions you can call to put down the corresponding forks of that philosopher.
  • The philosophers are assumed to be thinking as long as they are not asking to eat (the function is not being called with their number).
  • -

    Five threads, each representing a philosopher, will simultaneously use one object of your class to simulate the process. It is possible that the function will be called for the same philosopher more than once, even before the last call ends.

    +

    Five threads, each representing a philosopher, will simultaneously use one object of your class to simulate the process. The function may be called for the same philosopher more than once, even before the last call ends.

     

    Example 1:

    diff --git a/readme/301-600.md b/readme/301-600.md index 114f9523c..5d37d4931 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -127,7 +127,7 @@ LeetCode Problems' Solutions | 363 | [Max Sum of Rectangle No Larger Than K](https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k "矩形区域不超过 K 的最大数值和") | [Go](../problems/max-sum-of-rectangle-no-larger-than-k) | Hard | | 364 | [Nested List Weight Sum II](https://leetcode.com/problems/nested-list-weight-sum-ii "加权嵌套序列和 II") 🔒 | [Go](../problems/nested-list-weight-sum-ii) | Medium | | 365 | [Water and Jug Problem](https://leetcode.com/problems/water-and-jug-problem "水壶问题") | [Go](../problems/water-and-jug-problem) | Medium | -| 366 | [Find Leaves of Binary Tree](https://leetcode.com/problems/find-leaves-of-binary-tree "寻找完全二叉树的叶子节点") 🔒 | [Go](../problems/find-leaves-of-binary-tree) | Medium | +| 366 | [Find Leaves of Binary Tree](https://leetcode.com/problems/find-leaves-of-binary-tree "寻找二叉树的叶子节点") 🔒 | [Go](../problems/find-leaves-of-binary-tree) | Medium | | 367 | [Valid Perfect Square](https://leetcode.com/problems/valid-perfect-square "有效的完全平方数") | [Go](../problems/valid-perfect-square) | Easy | | 368 | [Largest Divisible Subset](https://leetcode.com/problems/largest-divisible-subset "最大整除子集") | [Go](../problems/largest-divisible-subset) | Medium | | 369 | [Plus One Linked List](https://leetcode.com/problems/plus-one-linked-list "给单链表加一") 🔒 | [Go](../problems/plus-one-linked-list) | Medium | diff --git a/tag/array/README.md b/tag/array/README.md index ba5742da3..286f15cb6 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 1346 | [检查整数及其两倍数是否存在](../../problems/check-if-n-and-its-double-exist) | [[数组](../array/README.md)] | Easy | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 3b09315e2..90f4defa8 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 1345 | [跳跃游戏 IV](../../problems/jump-game-iv) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index ccbe74420..c694a5c87 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -92,7 +92,7 @@ | 430 | [扁平化多级双向链表](../../problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | | 417 | [太平洋大西洋水流问题](../../problems/pacific-atlantic-water-flow) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 366 | [寻找完全二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 366 | [寻找二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 364 | [加权嵌套序列和 II](../../problems/nested-list-weight-sum-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 339 | [嵌套列表权重和](../../problems/nested-list-weight-sum) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index e9291e5a1..117dc00e3 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1359 | [有效的快递序列数目](../../problems/count-all-valid-pickup-and-delivery-options) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1349 | [参加考试的最大学生数](../../problems/maximum-students-taking-exam) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 6aa1733f9..f64eb2adf 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index d186d7105..2d5a361ce 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)] | Easy | | 1171 | [从链表中删去总和值为零的连续节点](../../problems/remove-zero-sum-consecutive-nodes-from-linked-list) | [[链表](../linked-list/README.md)] | Medium | | 1019 | [链表中的下一个更大节点](../../problems/next-greater-node-in-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index 6880ce48e..247a8caef 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[排序](../sort/README.md)] [[位运算](../bit-manipulation/README.md)] | Easy | | 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | | 1333 | [餐厅过滤器](../../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/tree/README.md b/tag/tree/README.md index 78d48cd39..a7053ac1d 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1325 | [删除给定值的叶子节点](../../problems/delete-leaves-with-a-given-value) | [[树](../tree/README.md)] | Medium | | 1315 | [祖父节点值为偶数的节点和](../../problems/sum-of-nodes-with-even-valued-grandparent) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | @@ -93,7 +94,7 @@ | 428 | [序列化和反序列化 N 叉树](../../problems/serialize-and-deserialize-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard | | 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | | 404 | [左叶子之和](../../problems/sum-of-left-leaves) | [[树](../tree/README.md)] | Easy | -| 366 | [寻找完全二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 366 | [寻找二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 333 | [最大 BST 子树](../../problems/largest-bst-subtree) 🔒 | [[树](../tree/README.md)] | Medium | | 298 | [二叉树最长连续序列](../../problems/binary-tree-longest-consecutive-sequence) 🔒 | [[树](../tree/README.md)] | Medium | From 23e5bc8abe3888d4b56d12a98a310c217620c50c Mon Sep 17 00:00:00 2001 From: Shuo Date: Fri, 6 Mar 2020 09:37:51 +0800 Subject: [PATCH 037/145] Add: desc --- problems/activity-participants/README.md | 64 +++++++++++++ problems/movie-rating/README.md | 92 +++++++++++++++++++ .../README.md | 67 ++++++++++++++ 3 files changed, 223 insertions(+) diff --git a/problems/activity-participants/README.md b/problems/activity-participants/README.md index 47c6a14fb..3531f2acc 100644 --- a/problems/activity-participants/README.md +++ b/problems/activity-participants/README.md @@ -11,4 +11,68 @@ ## [1355. Activity Participants (Medium)](https://leetcode.com/problems/activity-participants "") +

    Table: Friends

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| id            | int     |
    +| name          | varchar |
    +| activity      | varchar |
    ++---------------+---------+
    +id is the id of the friend and primary key for this table.
    +name is the name of the friend.
    +activity is the name of the activity which the friend takes part in.
    +
    +

    Table: Activities

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| id            | int     |
    +| name          | varchar |
    ++---------------+---------+
    +id is the primary key for this table.
    +name is the name of the activity.
    +
    + +Write an SQL query to find the names of all the activities with neither maximum, nor minimum number of participants. + +Return the result table in any order. Each activity in table Activities is performed by any person in the table Friends. + +The query result format is in the following example: + +Friends table: +
    ++------+--------------+---------------+
    +| id   | name         | activity      |
    ++------+--------------+---------------+
    +| 1    | Jonathan D.  | Eating        |
    +| 2    | Jade W.      | Singing       |
    +| 3    | Victor J.    | Singing       |
    +| 4    | Elvis Q.     | Eating        |
    +| 5    | Daniel A.    | Eating        |
    +| 6    | Bob B.       | Horse Riding  |
    ++------+--------------+---------------+
    +
    +Activities table:
    ++------+--------------+
    +| id   | name         |
    ++------+--------------+
    +| 1    | Eating       |
    +| 2    | Singing      |
    +| 3    | Horse Riding |
    ++------+--------------+
    +
    +Result table:
    ++--------------+
    +| results      |
    ++--------------+
    +| Singing      |
    ++--------------+
    +
    +Eating activity is performed by 3 friends, maximum number of participants, (Jonathan D. , Elvis Q. and Daniel A.)
    +Horse Riding activity is performed by 1 friend, minimum number of participants, (Bob B.)
    +Singing is performed by 2 friends (Victor J. and Jade W.)
    +
    diff --git a/problems/movie-rating/README.md b/problems/movie-rating/README.md index 7d825c727..6f65cba68 100644 --- a/problems/movie-rating/README.md +++ b/problems/movie-rating/README.md @@ -11,4 +11,96 @@ ## [1341. Movie Rating (Medium)](https://leetcode.com/problems/movie-rating "电影评分") +

    Table: Movies

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| movie_id      | int     |
    +| title         | varchar |
    ++---------------+---------+
    +movie_id is the primary key for this table.
    +title is the name of the movie.
    +
    +

    Table: Users

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| user_id       | int     |
    +| name          | varchar |
    ++---------------+---------+
    +user_id is the primary key for this table.
    +
    + +

    Table: Movie_Rating

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| movie_id      | int     |
    +| user_id       | int     |
    +| rating        | int     |
    +| created_at    | date    |
    ++---------------+---------+
    +(movie_id, user_id) is the primary key for this table.
    +This table contains the rating of a movie by a user in their review.
    +created_at is the user's review date. 
    +
    + +Write the following SQL query: + +- Find the name of the user who has rated the greatest number of the movies. + In case of a tie, return lexicographically smaller user name. + +- Find the movie name with the highest average rating as of Feb 2020. + In case of a tie, return lexicographically smaller movie name.. + +Query is returned in 2 rows, the query result format is in the folowing example: +
    +Movie table:
    ++-------------+--------------+
    +| movie_id    |  title       |
    ++-------------+--------------+
    +| 1           | Avengers     |
    +| 2           | Frozen 2     |
    +| 3           | Joker        |
    ++-------------+--------------+
    +
    +Users table:
    ++-------------+--------------+
    +| user_id     |  name        |
    ++-------------+--------------+
    +| 1           | Daniel       |
    +| 2           | Monica       |
    +| 3           | Maria        |
    +| 4           | James        |
    ++-------------+--------------+
    +
    +Movie_Rating table:
    ++-------------+--------------+--------------+-------------+
    +| movie_id    | user_id      | rating       | created_at  |
    ++-------------+--------------+--------------+-------------+
    +| 1           | 1            | 3            | 2020-01-12  |
    +| 1           | 2            | 4            | 2020-02-11  |
    +| 1           | 3            | 2            | 2020-02-12  |
    +| 1           | 4            | 1            | 2020-01-01  |
    +| 2           | 1            | 5            | 2020-02-17  | 
    +| 2           | 2            | 2            | 2020-02-01  | 
    +| 2           | 3            | 2            | 2020-03-01  |
    +| 3           | 1            | 3            | 2020-02-22  | 
    +| 3           | 2            | 4            | 2020-02-25  | 
    ++-------------+--------------+--------------+-------------+
    +
    +Result table:
    ++--------------+
    +| results      |
    ++--------------+
    +| Daniel       |
    +| Frozen 2     |
    ++--------------+
    +
    +Daniel and Maria have rated 3 movies ("Avengers", "Frozen 2" and "Joker") but Daniel is smaller lexicographically.
    +Frozen 2 and Joker have a rating average of 3.5 in February but Frozen 2 is smaller lexicographically.
    +
    diff --git a/problems/students-with-invalid-departments/README.md b/problems/students-with-invalid-departments/README.md index 1810f84f6..b696a87a5 100644 --- a/problems/students-with-invalid-departments/README.md +++ b/problems/students-with-invalid-departments/README.md @@ -11,4 +11,71 @@ ## [1350. Students With Invalid Departments (Easy)](https://leetcode.com/problems/students-with-invalid-departments "院系无效的学生") +

    Table: Departments

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| id            | int     |
    +| name          | varchar |
    ++---------------+---------+
    +id is the primary key of this table.
    +The table has information about the id of each department of a university.
    +
    + +

    Table: Students

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| id            | int     |
    +| name          | varchar |
    +| department_id | int     |
    ++---------------+---------+
    +id is the primary key of this table.
    +The table has information about the id of each student at a university and the id of the department he/she studies at.
    +
    + +Write an SQL query to find the id and the name of all students who are enrolled in departments that no longer exists. +Return the result table in any order. + +The query result format is in the following example: +
    +Departments table:
    ++------+--------------------------+
    +| id   | name                     |
    ++------+--------------------------+
    +| 1    | Electrical Engineering   |
    +| 7    | Computer Engineering     |
    +| 13   | Bussiness Administration |
    ++------+--------------------------+
    +
    +Students table:
    ++------+----------+---------------+
    +| id   | name     | department_id |
    ++------+----------+---------------+
    +| 23   | Alice    | 1             |
    +| 1    | Bob      | 7             |
    +| 5    | Jennifer | 13            |
    +| 2    | John     | 14            |
    +| 4    | Jasmine  | 77            |
    +| 3    | Steve    | 74            |
    +| 6    | Luis     | 1             |
    +| 8    | Jonathan | 7             |
    +| 7    | Daiana   | 33            |
    +| 11   | Madelynn | 1             |
    ++------+----------+---------------+
    +
    +Result table:
    ++------+----------+
    +| id   | name     |
    ++------+----------+
    +| 2    | John     |
    +| 7    | Daiana   |
    +| 4    | Jasmine  |
    +| 3    | Steve    |
    ++------+----------+
    +
    +John, Daiana, Steve and Jasmine are enrolled in departments 14, 33, 74 and 77 respectively. department 14, 33, 74 and 77 doesn't exist in the Departments table.
    +
    From 545dd88037b9875931c68cd3f3d7ff5b90b4e49f Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 9 Mar 2020 09:21:44 +0800 Subject: [PATCH 038/145] Add: new --- README.md | 12 +- problems/activity-participants/README.md | 2 +- problems/bulb-switcher-iii/README.md | 78 +++++++++++++ .../complement-of-base-10-integer/README.md | 1 + .../README.md | 2 +- .../README.md | 9 +- .../README.md | 61 ++++++++++ .../frog-position-after-t-seconds/README.md | 73 ++++++++++++ .../README.md | 56 ++++++++++ .../README.md | 4 +- .../guess-number-higher-or-lower-ii/README.md | 2 +- problems/height-checker/README.md | 2 + .../increasing-decreasing-string/README.md | 98 ++++++++++++++++ .../README.md | 71 ++++++++++++ .../maximum-sum-bst-in-binary-tree/README.md | 88 +++++++++++++++ .../README.md | 7 +- .../README.md | 1 + problems/number-complement/README.md | 27 +++-- .../README.md | 97 ++++++++++++++++ .../product-of-array-except-self/README.md | 2 +- .../README.md | 105 ++++++++++++++++++ problems/unique-paths/README.md | 14 ++- readme/601-900.md | 2 +- tag/README.md | 2 +- tag/array/README.md | 1 + tag/binary-search-tree/README.md | 1 + tag/depth-first-search/README.md | 2 + tag/dynamic-programming/README.md | 2 + tag/sort/README.md | 1 + tag/string/README.md | 3 + tag/tags.json | 10 +- tag/tree/README.md | 1 + tag/two-pointers/README.md | 2 +- 33 files changed, 808 insertions(+), 31 deletions(-) create mode 100644 problems/bulb-switcher-iii/README.md create mode 100644 problems/find-the-longest-substring-containing-vowels-in-even-counts/README.md create mode 100644 problems/frog-position-after-t-seconds/README.md create mode 100644 problems/generate-a-string-with-characters-that-have-odd-counts/README.md create mode 100644 problems/increasing-decreasing-string/README.md create mode 100644 problems/longest-zigzag-path-in-a-binary-tree/README.md create mode 100644 problems/maximum-sum-bst-in-binary-tree/README.md create mode 100644 problems/time-needed-to-inform-all-employees/README.md diff --git a/README.md b/README.md index a0092daee..1569fd4b0 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,15 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | -| 1369 | [Get the Second Most Recent Activity](https://leetcode.com/problems/get-the-second-most-recent-activity) 🔒 | [MySQL](problems/get-the-second-most-recent-activity) | Hard | +| 1377 | [Frog Position After T Seconds](https://leetcode.com/problems/frog-position-after-t-seconds "T 秒后青蛙的位置") | [Go](problems/frog-position-after-t-seconds) | Hard | +| 1376 | [Time Needed to Inform All Employees](https://leetcode.com/problems/time-needed-to-inform-all-employees "通知所有员工所需的时间") | [Go](problems/time-needed-to-inform-all-employees) | Medium | +| 1375 | [Bulb Switcher III](https://leetcode.com/problems/bulb-switcher-iii "灯泡开关 III") | [Go](problems/bulb-switcher-iii) | Medium | +| 1374 | [Generate a String With Characters That Have Odd Counts](https://leetcode.com/problems/generate-a-string-with-characters-that-have-odd-counts "生成每种字符都是奇数个的字符串") | [Go](problems/generate-a-string-with-characters-that-have-odd-counts) | Easy | +| 1373 | [Maximum Sum BST in Binary Tree](https://leetcode.com/problems/maximum-sum-bst-in-binary-tree "二叉搜索子树的最大键值和") | [Go](problems/maximum-sum-bst-in-binary-tree) | Hard | +| 1372 | [Longest ZigZag Path in a Binary Tree](https://leetcode.com/problems/longest-zigzag-path-in-a-binary-tree "二叉树中的最长交错路径") | [Go](problems/longest-zigzag-path-in-a-binary-tree) | Medium | +| 1371 | [Find the Longest Substring Containing Vowels in Even Counts](https://leetcode.com/problems/find-the-longest-substring-containing-vowels-in-even-counts "每个元音包含偶数次的最长子字符串") | [Go](problems/find-the-longest-substring-containing-vowels-in-even-counts) | Medium | +| 1370 | [Increasing Decreasing String](https://leetcode.com/problems/increasing-decreasing-string "上升下降字符串") | [Go](problems/increasing-decreasing-string) | Easy | +| 1369 | [Get the Second Most Recent Activity](https://leetcode.com/problems/get-the-second-most-recent-activity "获取最近第二次的活动") 🔒 | [MySQL](problems/get-the-second-most-recent-activity) | Hard | | 1368 | [Minimum Cost to Make at Least One Valid Path in a Grid](https://leetcode.com/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid "使网格图至少有一条有效路径的最小代价") | [Go](problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | Hard | | 1367 | [Linked List in Binary Tree](https://leetcode.com/problems/linked-list-in-binary-tree "二叉树中的列表") | [Go](problems/linked-list-in-binary-tree) | Medium | | 1366 | [Rank Teams by Votes](https://leetcode.com/problems/rank-teams-by-votes "通过投票对团队排名") | [Go](problems/rank-teams-by-votes) | Medium | @@ -76,7 +84,7 @@ LeetCode Problems' Solutions | 1358 | [Number of Substrings Containing All Three Characters](https://leetcode.com/problems/number-of-substrings-containing-all-three-characters "包含所有三种字符的子字符串数目") | [Go](problems/number-of-substrings-containing-all-three-characters) | Medium | | 1357 | [Apply Discount Every n Orders](https://leetcode.com/problems/apply-discount-every-n-orders "每隔 n 个顾客打折") | [Go](problems/apply-discount-every-n-orders) | Medium | | 1356 | [Sort Integers by The Number of 1 Bits](https://leetcode.com/problems/sort-integers-by-the-number-of-1-bits "根据数字二进制下 1 的数目排序") | [Go](problems/sort-integers-by-the-number-of-1-bits) | Easy | -| 1355 | [Activity Participants](https://leetcode.com/problems/activity-participants) 🔒 | [MySQL](problems/activity-participants) | Medium | +| 1355 | [Activity Participants](https://leetcode.com/problems/activity-participants "活动参与者") 🔒 | [MySQL](problems/activity-participants) | Medium | | 1354 | [Construct Target Array With Multiple Sums](https://leetcode.com/problems/construct-target-array-with-multiple-sums "多次求和构造目标数组") | [Go](problems/construct-target-array-with-multiple-sums) | Hard | | 1353 | [Maximum Number of Events That Can Be Attended](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended "最多可以参加的会议数目") | [Go](problems/maximum-number-of-events-that-can-be-attended) | Medium | | 1352 | [Product of the Last K Numbers](https://leetcode.com/problems/product-of-the-last-k-numbers "最后 K 个数的乘积") | [Go](problems/product-of-the-last-k-numbers) | Medium | diff --git a/problems/activity-participants/README.md b/problems/activity-participants/README.md index 3531f2acc..59e05000d 100644 --- a/problems/activity-participants/README.md +++ b/problems/activity-participants/README.md @@ -9,7 +9,7 @@                  [Next >](../sort-integers-by-the-number-of-1-bits "Sort Integers by The Number of 1 Bits") -## [1355. Activity Participants (Medium)](https://leetcode.com/problems/activity-participants "") +## [1355. Activity Participants (Medium)](https://leetcode.com/problems/activity-participants "活动参与者")

    Table: Friends

    diff --git a/problems/bulb-switcher-iii/README.md b/problems/bulb-switcher-iii/README.md
    new file mode 100644
    index 000000000..49ff0d736
    --- /dev/null
    +++ b/problems/bulb-switcher-iii/README.md
    @@ -0,0 +1,78 @@
    +
    +
    +
    +
    +
    +
    +
    +[< Previous](../generate-a-string-with-characters-that-have-odd-counts "Generate a String With Characters That Have Odd Counts")
    +                
    +[Next >](../time-needed-to-inform-all-employees "Time Needed to Inform All Employees")
    +
    +## [1375. Bulb Switcher III (Medium)](https://leetcode.com/problems/bulb-switcher-iii "灯泡开关 III")
    +
    +

    There is a room with n bulbs, numbered from 1 to n, arranged in a row from left to right. Initially, all the bulbs are turned off.

    + +

    At moment k (for k from 0 to n - 1), we turn on the light[k] bulb. A bulb change color to blue only if it is on and all the previous bulbs (to the left) are turned on too.

    + +

    Return the number of moments in which all turned on bulbs are blue.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: light = [2,1,3,5,4]
    +Output: 3
    +Explanation: All bulbs turned on, are blue at the moment 1, 2 and 4.
    +
    + +

    Example 2:

    + +
    +Input: light = [3,2,4,1,5]
    +Output: 2
    +Explanation: All bulbs turned on, are blue at the moment 3, and 4 (index-0).
    +
    + +

    Example 3:

    + +
    +Input: light = [4,1,2,3]
    +Output: 1
    +Explanation: All bulbs turned on, are blue at the moment 3 (index-0).
    +Bulb 4th changes to blue at the moment 3.
    +
    + +

    Example 4:

    + +
    +Input: light = [2,1,4,3,6,5]
    +Output: 3
    +
    + +

    Example 5:

    + +
    +Input: light = [1,2,3,4,5,6]
    +Output: 6
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == light.length
    • +
    • 1 <= n <= 5 * 10^4
    • +
    • light is a permutation of  [1, 2, ..., n]
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +If in the step x all bulb shines then bulbs 1,2,3,..,x should shines too. +
    diff --git a/problems/complement-of-base-10-integer/README.md b/problems/complement-of-base-10-integer/README.md index 97dfeceb3..910c3dc2a 100644 --- a/problems/complement-of-base-10-integer/README.md +++ b/problems/complement-of-base-10-integer/README.md @@ -55,6 +55,7 @@
    1. 0 <= N < 10^9
    2. +
    3. This question is the same as 476: https://leetcode.com/problems/number-complement/
    diff --git a/problems/count-unique-characters-of-all-substrings-of-a-given-string/README.md b/problems/count-unique-characters-of-all-substrings-of-a-given-string/README.md index 99c7db690..26680d401 100644 --- a/problems/count-unique-characters-of-all-substrings-of-a-given-string/README.md +++ b/problems/count-unique-characters-of-all-substrings-of-a-given-string/README.md @@ -9,7 +9,7 @@                  [Next >](../consecutive-numbers-sum "Consecutive Numbers Sum") -## [828. Count Unique Characters of All Substrings of a Given String (Hard)](https://leetcode.com/problems/count-unique-characters-of-all-substrings-of-a-given-string "独特字符串") +## [828. Count Unique Characters of All Substrings of a Given String (Hard)](https://leetcode.com/problems/count-unique-characters-of-all-substrings-of-a-given-string "统计子串中的唯一字符")

    Let's define a function countUniqueChars(s) that returns the number of unique characters on s, for example if s = "LEETCODE" then "L", "T","C","O","D" are the unique characters since they appear only once in s, therefore countUniqueChars(s) = 5.

    diff --git a/problems/decompress-run-length-encoded-list/README.md b/problems/decompress-run-length-encoded-list/README.md index 4040e2fcb..9d28d4d54 100644 --- a/problems/decompress-run-length-encoded-list/README.md +++ b/problems/decompress-run-length-encoded-list/README.md @@ -13,7 +13,7 @@

    We are given a list nums of integers representing a list compressed with run-length encoding.

    -

    Consider each adjacent pair of elements [a, b] = [nums[2*i], nums[2*i+1]] (with i >= 0).  For each such pair, there are a elements with value b in the decompressed list.

    +

    Consider each adjacent pair of elements [freq, val] = [nums[2*i], nums[2*i+1]] (with i >= 0).  For each such pair, there are freq elements with value val concatenated in a sublist. Concatenate all the sublists from left to right to generate the decompressed list.

    Return the decompressed list.

    @@ -28,6 +28,13 @@ The second pair [3,4] means we have freq = 3 and val = 4 so we generate [4,4,4]. At the end the concatenation [2] + [4,4,4] is [2,4,4,4].
    +

    Example 2:

    + +
    +Input: nums = [1,1,2,3]
    +Output: [1,3,3]
    +
    +

     

    Constraints:

    diff --git a/problems/find-the-longest-substring-containing-vowels-in-even-counts/README.md b/problems/find-the-longest-substring-containing-vowels-in-even-counts/README.md new file mode 100644 index 000000000..d0832f0a3 --- /dev/null +++ b/problems/find-the-longest-substring-containing-vowels-in-even-counts/README.md @@ -0,0 +1,61 @@ + + + + + + + +[< Previous](../increasing-decreasing-string "Increasing Decreasing String") +                 +[Next >](../longest-zigzag-path-in-a-binary-tree "Longest ZigZag Path in a Binary Tree") + +## [1371. Find the Longest Substring Containing Vowels in Even Counts (Medium)](https://leetcode.com/problems/find-the-longest-substring-containing-vowels-in-even-counts "每个元音包含偶数次的最长子字符串") + +

    Given the string s, return the size of the longest substring containing each vowel an even number of times. That is, 'a', 'e', 'i', 'o', and 'u' must appear an even number of times.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "eleetminicoworoep"
    +Output: 13
    +Explanation: The longest substring is "leetminicowor" which contains two each of the vowels: e, i and o and zero of the vowels: a and u.
    +
    + +

    Example 2:

    + +
    +Input: s = "leetcodeisgreat"
    +Output: 5
    +Explanation: The longest substring is "leetc" which contains two e's.
    +
    + +

    Example 3:

    + +
    +Input: s = "bcbcbc"
    +Output: 6
    +Explanation: In this case, the given string "bcbcbc" is the longest because all vowels: a, e, i, o and u appear zero times.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 5 x 10^5
    • +
    • s contains only lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Represent the counts (odd or even) of vowels with a bitmask. +
    + +
    +Hint 2 +Precompute the prefix xor for the bitmask of vowels and then get the longest valid substring. +
    diff --git a/problems/frog-position-after-t-seconds/README.md b/problems/frog-position-after-t-seconds/README.md new file mode 100644 index 000000000..fe86f23d2 --- /dev/null +++ b/problems/frog-position-after-t-seconds/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../time-needed-to-inform-all-employees "Time Needed to Inform All Employees") +                 +Next > + +## [1377. Frog Position After T Seconds (Hard)](https://leetcode.com/problems/frog-position-after-t-seconds "T 秒后青蛙的位置") + +

    Given an undirected tree consisting of n vertices numbered from 1 to n. A frog starts jumping from the vertex 1. In one second, the frog jumps from its current vertex to another unvisited vertex if they are directly connected. The frog can not jump back to a visited vertex. In case the frog can jump to several vertices it jumps randomly to one of them with the same probability, otherwise, when the frog can not jump to any unvisited vertex it jumps forever on the same vertex. 

    + +

    The edges of the undirected tree are given in the array edges, where edges[i] = [fromi, toi] means that exists an edge connecting directly the vertices fromi and toi.

    + +

    Return the probability that after t seconds the frog is on the vertex target.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 2, target = 4
    +Output: 0.16666666666666666 
    +Explanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 probability to the vertex 2 after second 1 and then jumping with 1/2 probability to vertex 4 after second 2. Thus the probability for the frog is on the vertex 4 after 2 seconds is 1/3 * 1/2 = 1/6 = 0.16666666666666666. 
    +
    + +

    Example 2:

    + +

    + +
    +Input: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 1, target = 7
    +Output: 0.3333333333333333
    +Explanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 = 0.3333333333333333 probability to the vertex 7 after second 1. 
    +
    + +

    Example 3:

    + +
    +Input: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 20, target = 6
    +Output: 0.16666666666666666
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 100
    • +
    • edges.length == n-1
    • +
    • edges[i].length == 2
    • +
    • 1 <= edges[i][0], edges[i][1] <= n
    • +
    • 1 <= t <= 50
    • +
    • 1 <= target <= n
    • +
    • Answers within 10^-5 of the actual value will be accepted as correct.
    • +
    + +### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] + +### Hints +
    +Hint 1 +Use a variation of DFS with parameters 'curent_vertex' and 'current_time'. +
    + +
    +Hint 2 +Update the probability considering to jump to one of the children vertices. +
    diff --git a/problems/generate-a-string-with-characters-that-have-odd-counts/README.md b/problems/generate-a-string-with-characters-that-have-odd-counts/README.md new file mode 100644 index 000000000..a8034e1a7 --- /dev/null +++ b/problems/generate-a-string-with-characters-that-have-odd-counts/README.md @@ -0,0 +1,56 @@ + + + + + + + +[< Previous](../maximum-sum-bst-in-binary-tree "Maximum Sum BST in Binary Tree") +                 +[Next >](../bulb-switcher-iii "Bulb Switcher III") + +## [1374. Generate a String With Characters That Have Odd Counts (Easy)](https://leetcode.com/problems/generate-a-string-with-characters-that-have-odd-counts "生成每种字符都是奇数个的字符串") + +

    Given an integer n, return a string with n characters such that each character in such string occurs an odd number of times.

    + +

    The returned string must contain only lowercase English letters. If there are multiples valid strings, return any of them.  

    + +

     

    +

    Example 1:

    + +
    +Input: n = 4
    +Output: "pppz"
    +Explanation: "pppz" is a valid string since the character 'p' occurs three times and the character 'z' occurs once. Note that there are many other valid strings such as "ohhh" and "love".
    +
    + +

    Example 2:

    + +
    +Input: n = 2
    +Output: "xy"
    +Explanation: "xy" is a valid string since the characters 'x' and 'y' occur once. Note that there are many other valid strings such as "ag" and "ur".
    +
    + +

    Example 3:

    + +
    +Input: n = 7
    +Output: "holasss"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 500
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +If n is odd, return a string of size n formed only by 'a', else return string formed with n-1 'a' and 1 'b''. +
    diff --git a/problems/get-the-second-most-recent-activity/README.md b/problems/get-the-second-most-recent-activity/README.md index 4953f59b4..572594895 100644 --- a/problems/get-the-second-most-recent-activity/README.md +++ b/problems/get-the-second-most-recent-activity/README.md @@ -7,8 +7,8 @@ [< Previous](../minimum-cost-to-make-at-least-one-valid-path-in-a-grid "Minimum Cost to Make at Least One Valid Path in a Grid")                  -Next > +[Next >](../increasing-decreasing-string "Increasing Decreasing String") -## [1369. Get the Second Most Recent Activity (Hard)](https://leetcode.com/problems/get-the-second-most-recent-activity "") +## [1369. Get the Second Most Recent Activity (Hard)](https://leetcode.com/problems/get-the-second-most-recent-activity "获取最近第二次的活动") diff --git a/problems/guess-number-higher-or-lower-ii/README.md b/problems/guess-number-higher-or-lower-ii/README.md index f18636f96..6a17d0b12 100644 --- a/problems/guess-number-higher-or-lower-ii/README.md +++ b/problems/guess-number-higher-or-lower-ii/README.md @@ -36,8 +36,8 @@ You end up paying $5 + $7 + $9 = $21.

    Given a particular n ≥ 1, find out how much money you need to have to guarantee a win.

    ### Related Topics - [[Minimax](../../tag/minimax/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Minimax](../../tag/minimax/README.md)] ### Similar Questions 1. [Flip Game II](../flip-game-ii) (Medium) diff --git a/problems/height-checker/README.md b/problems/height-checker/README.md index 13b28d7d4..bb3d22b7b 100644 --- a/problems/height-checker/README.md +++ b/problems/height-checker/README.md @@ -15,6 +15,8 @@

    Return the minimum number of students that must move in order for all students to be standing in non-decreasing order of height.

    +

    Notice that when a group of students is selected they can reorder in any possible way between themselves and the non selected students remain on their seats.

    +

     

    Example 1:

    diff --git a/problems/increasing-decreasing-string/README.md b/problems/increasing-decreasing-string/README.md new file mode 100644 index 000000000..98d45e933 --- /dev/null +++ b/problems/increasing-decreasing-string/README.md @@ -0,0 +1,98 @@ + + + + + + + +[< Previous](../get-the-second-most-recent-activity "Get the Second Most Recent Activity") +                 +[Next >](../find-the-longest-substring-containing-vowels-in-even-counts "Find the Longest Substring Containing Vowels in Even Counts") + +## [1370. Increasing Decreasing String (Easy)](https://leetcode.com/problems/increasing-decreasing-string "上升下降字符串") + +

    Given a string s. You should re-order the string using the following algorithm:

    + +
      +
    1. Pick the smallest character from s and append it to the result.
    2. +
    3. Pick the smallest character from s which is greater than the last appended character to the result and append it.
    4. +
    5. Repeat step 2 until you cannot pick more characters.
    6. +
    7. Pick the largest character from s and append it to the result.
    8. +
    9. Pick the largest character from s which is smaller than the last appended character to the result and append it.
    10. +
    11. Repeat step 5 until you cannot pick more characters.
    12. +
    13. Repeat the steps from 1 to 6 until you pick all characters from s.
    14. +
    + +

    In each step, If the smallest or the largest character appears more than once you can choose any occurrence and append it to the result.

    + +

    Return the result string after sorting s with this algorithm.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "aaaabbbbcccc"
    +Output: "abccbaabccba"
    +Explanation: After steps 1, 2 and 3 of the first iteration, result = "abc"
    +After steps 4, 5 and 6 of the first iteration, result = "abccba"
    +First iteration is done. Now s = "aabbcc" and we go back to step 1
    +After steps 1, 2 and 3 of the second iteration, result = "abccbaabc"
    +After steps 4, 5 and 6 of the second iteration, result = "abccbaabccba"
    +
    + +

    Example 2:

    + +
    +Input: s = "rat"
    +Output: "art"
    +Explanation: The word "rat" becomes "art" after re-ordering it with the mentioned algorithm.
    +
    + +

    Example 3:

    + +
    +Input: s = "leetcode"
    +Output: "cdelotee"
    +
    + +

    Example 4:

    + +
    +Input: s = "ggggggg"
    +Output: "ggggggg"
    +
    + +

    Example 5:

    + +
    +Input: s = "spo"
    +Output: "ops"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 500
    • +
    • s contains only lower-case English letters.
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Count the frequency of each character. +
    + +
    +Hint 2 +Loop over all character from 'a' to 'z' and append the character if it exists and decrease frequency by 1. Do the same from 'z' to 'a'. +
    + +
    +Hint 3 +Keep repeating until the frequency of all characters is zero. +
    diff --git a/problems/longest-zigzag-path-in-a-binary-tree/README.md b/problems/longest-zigzag-path-in-a-binary-tree/README.md new file mode 100644 index 000000000..24109eba2 --- /dev/null +++ b/problems/longest-zigzag-path-in-a-binary-tree/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../find-the-longest-substring-containing-vowels-in-even-counts "Find the Longest Substring Containing Vowels in Even Counts") +                 +[Next >](../maximum-sum-bst-in-binary-tree "Maximum Sum BST in Binary Tree") + +## [1372. Longest ZigZag Path in a Binary Tree (Medium)](https://leetcode.com/problems/longest-zigzag-path-in-a-binary-tree "二叉树中的最长交错路径") + +

    Given a binary tree root, a ZigZag path for a binary tree is defined as follow:

    + +
      +
    • Choose any node in the binary tree and a direction (right or left).
    • +
    • If the current direction is right then move to the right child of the current node otherwise move to the left child.
    • +
    • Change the direction from right to left or right to left.
    • +
    • Repeat the second and third step until you can't move in the tree.
    • +
    + +

    Zigzag length is defined as the number of nodes visited - 1. (A single node has a length of 0).

    + +

    Return the longest ZigZag path contained in that tree.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: root = [1,null,1,1,1,null,null,1,1,null,1,null,null,null,1,null,1]
    +Output: 3
    +Explanation: Longest ZigZag path in blue nodes (right -> left -> right).
    +
    + +

    Example 2:

    + +

    + +
    +Input: root = [1,1,1,null,1,null,null,1,1,null,1]
    +Output: 4
    +Explanation: Longest ZigZag path in blue nodes (left -> right -> left -> right).
    +
    + +

    Example 3:

    + +
    +Input: root = [1]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • Each tree has at most 50000 nodes..
    • +
    • Each node's value is between [1, 100].
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Create this function maxZigZag(node, direction) maximum zigzag given a node and direction (right or left). +
    diff --git a/problems/maximum-sum-bst-in-binary-tree/README.md b/problems/maximum-sum-bst-in-binary-tree/README.md new file mode 100644 index 000000000..bd1da9df9 --- /dev/null +++ b/problems/maximum-sum-bst-in-binary-tree/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../longest-zigzag-path-in-a-binary-tree "Longest ZigZag Path in a Binary Tree") +                 +[Next >](../generate-a-string-with-characters-that-have-odd-counts "Generate a String With Characters That Have Odd Counts") + +## [1373. Maximum Sum BST in Binary Tree (Hard)](https://leetcode.com/problems/maximum-sum-bst-in-binary-tree "二叉搜索子树的最大键值和") + +

    Given a binary tree root, the task is to return the maximum sum of all keys of any sub-tree which is also a Binary Search Tree (BST).

    + +

    Assume a BST is defined as follows:

    + +
      +
    • The left subtree of a node contains only nodes with keys less than the node's key.
    • +
    • The right subtree of a node contains only nodes with keys greater than the node's key.
    • +
    • Both the left and right subtrees must also be binary search trees.
    • +
    + +

     

    +

    Example 1:

    + +

    + +
    +Input: root = [1,4,3,2,4,2,5,null,null,null,null,null,null,4,6]
    +Output: 20
    +Explanation: Maximum sum in a valid Binary search tree is obtained in root node with key equal to 3.
    +
    + +

    Example 2:

    + +

    + +
    +Input: root = [4,3,null,1,2]
    +Output: 2
    +Explanation: Maximum sum in a valid Binary search tree is obtained in a single root node with key equal to 2.
    +
    + +

    Example 3:

    + +
    +Input: root = [-4,-2,-5]
    +Output: 0
    +Explanation: All values are negatives. Return an empty BST.
    +
    + +

    Example 4:

    + +
    +Input: root = [2,1,3]
    +Output: 6
    +
    + +

    Example 5:

    + +
    +Input: root = [5,4,8,3,null,6,3]
    +Output: 7
    +
    + +

     

    +

    Constraints:

    + +
      +
    • Each tree has at most 40000 nodes..
    • +
    • Each node's value is between [-4 * 10^4 , 4 * 10^4].
    • +
    + +### Related Topics + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Create a datastructure with 4 parameters: (sum, isBST, maxLeft, minLeft). +
    + +
    +Hint 2 +In each node compute theses parameters, following the conditions of a Binary Search Tree. +
    diff --git a/problems/minimum-absolute-difference-in-bst/README.md b/problems/minimum-absolute-difference-in-bst/README.md index 129639f52..4341fc091 100644 --- a/problems/minimum-absolute-difference-in-bst/README.md +++ b/problems/minimum-absolute-difference-in-bst/README.md @@ -33,7 +33,12 @@ The minimum absolute difference is 1, which is the difference between 2 and 1 (o

     

    -

    Note: There are at least two nodes in this BST.

    +

    Note:

    + + ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/minimum-distance-between-bst-nodes/README.md b/problems/minimum-distance-between-bst-nodes/README.md index 8f741919d..04bba7d41 100644 --- a/problems/minimum-distance-between-bst-nodes/README.md +++ b/problems/minimum-distance-between-bst-nodes/README.md @@ -37,6 +37,7 @@ while the minimum difference in this tree is 1, it occurs between node 1 and nod
    1. The size of the BST will be between 2 and 100.
    2. The BST is always valid, each node's value is an integer, and each node's value is different.
    3. +
    4. This question is the same as 530: https://leetcode.com/problems/minimum-absolute-difference-in-bst/
    ### Related Topics diff --git a/problems/number-complement/README.md b/problems/number-complement/README.md index 61f12dde8..522c757ad 100644 --- a/problems/number-complement/README.md +++ b/problems/number-complement/README.md @@ -13,28 +13,35 @@

    Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.

    -

    Note:
    -

      -
    1. The given integer is guaranteed to fit within the range of a 32-bit signed integer.
    2. -
    3. You could assume no leading zero bit in the integer’s binary representation.
    4. -
    -

    +

     

    + +

    Example 1:

    -

    Example 1:

     Input: 5
     Output: 2
     Explanation: The binary representation of 5 is 101 (no leading zero bits), and its complement is 010. So you need to output 2.
     
    -

    -

    Example 2:
    +

     

    + +

    Example 2:

    +
     Input: 1
     Output: 0
     Explanation: The binary representation of 1 is 1 (no leading zero bits), and its complement is 0. So you need to output 0.
     
    -

    + +

     

    + +

    Note:

    + +
      +
    1. The given integer is guaranteed to fit within the range of a 32-bit signed integer.
    2. +
    3. You could assume no leading zero bit in the integer’s binary representation.
    4. +
    5. This question is the same as 1009: https://leetcode.com/problems/complement-of-base-10-integer/
    6. +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/number-of-trusted-contacts-of-a-customer/README.md b/problems/number-of-trusted-contacts-of-a-customer/README.md index 1408b9119..4a8e8df5d 100644 --- a/problems/number-of-trusted-contacts-of-a-customer/README.md +++ b/problems/number-of-trusted-contacts-of-a-customer/README.md @@ -11,4 +11,101 @@ ## [1364. Number of Trusted Contacts of a Customer (Medium)](https://leetcode.com/problems/number-of-trusted-contacts-of-a-customer "顾客的可信联系人数量") +

    Table: Customers

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| customer_id   | int     |
    +| customer_name | varchar |
    +| email         | varchar |
    ++---------------+---------+
    +customer_id is the primary key for this table.
    +Each row of this table contains the name and the email of a customer of an online shop.
    +
    + +

    Table: Contacts

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| user_id       | id      |
    +| contact_name  | varchar |
    +| contact_email | varchar |
    ++---------------+---------+
    +(user_id, contact_email) is the primary key for this table.
    +Each row of this table contains the name and email of one contact of customer with user_id.
    +This table contains information about people each customer trust. The contact may or may not exist in the Customers table.
    +
    +

    Table: Invoices

    +
    ++--------------+---------+
    +| Column Name  | Type    |
    ++--------------+---------+
    +| invoice_id   | int     |
    +| price        | int     |
    +| user_id      | int     |
    ++--------------+---------+
    +invoice_id is the primary key for this table.
    +Each row of this table indicates that user_id has an invoice with invoice_id and a price.
    +
    + +Write an SQL query to find the following for each invoice_id: + +- customer_name: The name of the customer the invoice is related to. +- price: The price of the invoice. +- contacts_cnt: The number of contacts related to the customer. +- trusted_contacts_cnt: The number of contacts related to the customer and at the same time they are customers to the shop. (i.e His/Her email exists in the Customers table.) + +Order the result table by invoice_id. + +The query result format is in the following example: +
    +Customers table:
    ++-------------+---------------+--------------------+
    +| customer_id | customer_name | email              |
    ++-------------+---------------+--------------------+
    +| 1           | Alice         | alice@leetcode.com |
    +| 2           | Bob           | bob@leetcode.com   |
    +| 13          | John          | john@leetcode.com  |
    +| 6           | Alex          | alex@leetcode.com  |
    ++-------------+---------------+--------------------+
    +Contacts table:
    ++-------------+--------------+--------------------+
    +| user_id     | contact_name | contact_email      |
    ++-------------+--------------+--------------------+
    +| 1           | Bob          | bob@leetcode.com   |
    +| 1           | John         | john@leetcode.com  |
    +| 1           | Jal          | jal@leetcode.com   |
    +| 2           | Omar         | omar@leetcode.com  |
    +| 2           | Meir         | meir@leetcode.com  |
    +| 6           | Alice        | alice@leetcode.com |
    ++-------------+--------------+--------------------+
    +Invoices table:
    ++------------+-------+---------+
    +| invoice_id | price | user_id |
    ++------------+-------+---------+
    +| 77         | 100   | 1       |
    +| 88         | 200   | 1       |
    +| 99         | 300   | 2       |
    +| 66         | 400   | 2       |
    +| 55         | 500   | 13      |
    +| 44         | 60    | 6       |
    ++------------+-------+---------+
    +Result table:
    ++------------+---------------+-------+--------------+----------------------+
    +| invoice_id | customer_name | price | contacts_cnt | trusted_contacts_cnt |
    ++------------+---------------+-------+--------------+----------------------+
    +| 44         | Alex          | 60    | 1            | 1                    |
    +| 55         | John          | 500   | 0            | 0                    |
    +| 66         | Bob           | 400   | 2            | 0                    |
    +| 77         | Alice         | 100   | 3            | 2                    |
    +| 88         | Alice         | 200   | 3            | 2                    |
    +| 99         | Bob           | 300   | 2            | 0                    |
    ++------------+---------------+-------+--------------+----------------------+
    +Alice has three contacts, two of them are trusted contacts (Bob and John).
    +Bob has two contacts, none of them is a trusted contact.
    +Alex has one contact and it is a trusted contact (Alice).
    +John doesn't have any contacts.
    +
    diff --git a/problems/product-of-array-except-self/README.md b/problems/product-of-array-except-self/README.md index b542b1fec..1fad35bc7 100644 --- a/problems/product-of-array-except-self/README.md +++ b/problems/product-of-array-except-self/README.md @@ -20,7 +20,7 @@ Output: [24,12,8,6]
    -

    Constraint: It's guaranteed that the product of the elements of any preffix or suffix of the array (including the whole array) fits in a 32 bit integer.

    +

    Constraint: It's guaranteed that the product of the elements of any prefix or suffix of the array (including the whole array) fits in a 32 bit integer.

    Note: Please solve it without division and in O(n).

    diff --git a/problems/time-needed-to-inform-all-employees/README.md b/problems/time-needed-to-inform-all-employees/README.md new file mode 100644 index 000000000..aa0893d59 --- /dev/null +++ b/problems/time-needed-to-inform-all-employees/README.md @@ -0,0 +1,105 @@ + + + + + + + +[< Previous](../bulb-switcher-iii "Bulb Switcher III") +                 +[Next >](../frog-position-after-t-seconds "Frog Position After T Seconds") + +## [1376. Time Needed to Inform All Employees (Medium)](https://leetcode.com/problems/time-needed-to-inform-all-employees "通知所有员工所需的时间") + +

    A company has n employees with a unique ID for each employee from 0 to n - 1. The head of the company has is the one with headID.

    + +

    Each employee has one direct manager given in the manager array where manager[i] is the direct manager of the i-th employee, manager[headID] = -1. Also it's guaranteed that the subordination relationships have a tree structure.

    + +

    The head of the company wants to inform all the employees of the company of an urgent piece of news. He will inform his direct subordinates and they will inform their subordinates and so on until all employees know about the urgent news.

    + +

    The i-th employee needs informTime[i] minutes to inform all of his direct subordinates (i.e After informTime[i] minutes, all his direct subordinates can start spreading the news).

    + +

    Return the number of minutes needed to inform all the employees about the urgent news.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 1, headID = 0, manager = [-1], informTime = [0]
    +Output: 0
    +Explanation: The head of the company is the only employee in the company.
    +
    + +

    Example 2:

    + +
    +Input: n = 6, headID = 2, manager = [2,2,-1,2,2,2], informTime = [0,0,1,0,0,0]
    +Output: 1
    +Explanation: The head of the company with id = 2 is the direct manager of all the employees in the company and needs 1 minute to inform them all.
    +The tree structure of the employees in the company is shown.
    +
    + +

    Example 3:

    + +
    +Input: n = 7, headID = 6, manager = [1,2,3,4,5,6,-1], informTime = [0,6,5,4,3,2,1]
    +Output: 21
    +Explanation: The head has id = 6. He will inform employee with id = 5 in 1 minute.
    +The employee with id = 5 will inform the employee with id = 4 in 2 minutes.
    +The employee with id = 4 will inform the employee with id = 3 in 3 minutes.
    +The employee with id = 3 will inform the employee with id = 2 in 4 minutes.
    +The employee with id = 2 will inform the employee with id = 1 in 5 minutes.
    +The employee with id = 1 will inform the employee with id = 0 in 6 minutes.
    +Needed time = 1 + 2 + 3 + 4 + 5 + 6 = 21.
    +
    + +

    Example 4:

    + +
    +Input: n = 15, headID = 0, manager = [-1,0,0,1,1,2,2,3,3,4,4,5,5,6,6], informTime = [1,1,1,1,1,1,1,0,0,0,0,0,0,0,0]
    +Output: 3
    +Explanation: The first minute the head will inform employees 1 and 2.
    +The second minute they will inform employees 3, 4, 5 and 6.
    +The third minute they will inform the rest of employees.
    +
    + +

    Example 5:

    + +
    +Input: n = 4, headID = 2, manager = [3,3,-1,2], informTime = [0,0,162,914]
    +Output: 1076
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 10^5
    • +
    • 0 <= headID < n
    • +
    • manager.length == n
    • +
    • 0 <= manager[i] < n
    • +
    • manager[headID] == -1
    • +
    • informTime.length == n
    • +
    • 0 <= informTime[i] <= 1000
    • +
    • informTime[i] == 0 if employee i has no subordinates.
    • +
    • It is guaranteed that all the employees can be informed.
    • +
    + +### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] + +### Hints +
    +Hint 1 +The company can be represented as a tree, headID is always the root. +
    + +
    +Hint 2 +Store for each node the time needed to be informed of the news. +
    + +
    +Hint 3 +Answer is the max time a leaf node needs to be informed. +
    diff --git a/problems/unique-paths/README.md b/problems/unique-paths/README.md index f9dbe3db5..8f8017a78 100644 --- a/problems/unique-paths/README.md +++ b/problems/unique-paths/README.md @@ -20,8 +20,7 @@


    Above is a 7 x 3 grid. How many possible unique paths are there?

    -

    Note: m and n will be at most 100.

    - +

     

    Example 1:

    @@ -38,7 +37,16 @@ From the top-left corner, there are a total of 3 ways to reach the bottom-right
     
     
     Input: m = 7, n = 3
    -Output: 28
    +Output: 28 +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= m, n <= 100
    • +
    • It's guaranteed that the answer will be less than or equal to 2 * 10 ^ 9.
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/readme/601-900.md b/readme/601-900.md index 78115c110..3c770adcd 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -289,7 +289,7 @@ LeetCode Problems' Solutions | 825 | [Friends Of Appropriate Ages](https://leetcode.com/problems/friends-of-appropriate-ages "适龄的朋友") | [Go](../problems/friends-of-appropriate-ages) | Medium | | 826 | [Most Profit Assigning Work](https://leetcode.com/problems/most-profit-assigning-work "安排工作以达到最大收益") | [Go](../problems/most-profit-assigning-work) | Medium | | 827 | [Making A Large Island](https://leetcode.com/problems/making-a-large-island "最大人工岛") | [Go](../problems/making-a-large-island) | Hard | -| 828 | [Count Unique Characters of All Substrings of a Given String](https://leetcode.com/problems/count-unique-characters-of-all-substrings-of-a-given-string "独特字符串") | [Go](../problems/count-unique-characters-of-all-substrings-of-a-given-string) | Hard | +| 828 | [Count Unique Characters of All Substrings of a Given String](https://leetcode.com/problems/count-unique-characters-of-all-substrings-of-a-given-string "统计子串中的唯一字符") | [Go](../problems/count-unique-characters-of-all-substrings-of-a-given-string) | Hard | | 829 | [Consecutive Numbers Sum](https://leetcode.com/problems/consecutive-numbers-sum "连续整数求和") | [Go](../problems/consecutive-numbers-sum) | Hard | | 830 | [Positions of Large Groups](https://leetcode.com/problems/positions-of-large-groups "较大分组的位置") | [Go](../problems/positions-of-large-groups) | Easy | | 831 | [Masking Personal Information](https://leetcode.com/problems/masking-personal-information "隐藏个人信息") | [Go](../problems/masking-personal-information) | Medium | diff --git a/tag/README.md b/tag/README.md index 02b484368..61fdd8818 100644 --- a/tag/README.md +++ b/tag/README.md @@ -16,7 +16,7 @@ | 9 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | | 11 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 12 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | | 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | -| 15 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 16 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | +| 15 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | | 19 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 20 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | | 21 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | | 22 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | diff --git a/tag/array/README.md b/tag/array/README.md index 286f15cb6..6c69108ce 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1375 | [灯泡开关 III](../../problems/bulb-switcher-iii) | [[数组](../array/README.md)] | Medium | | 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/binary-search-tree/README.md b/tag/binary-search-tree/README.md index 523255055..4153b282b 100644 --- a/tag/binary-search-tree/README.md +++ b/tag/binary-search-tree/README.md @@ -9,5 +9,6 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | | 1038 | [从二叉搜索树到更大和树](../../problems/binary-search-tree-to-greater-sum-tree) | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index c694a5c87..8bcbdcdda 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1377 | [T 秒后青蛙的位置](../../problems/frog-position-after-t-seconds) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 1376 | [通知所有员工所需的时间](../../problems/time-needed-to-inform-all-employees) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 1315 | [祖父节点值为偶数的节点和](../../problems/sum-of-nodes-with-even-valued-grandparent) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 117dc00e3..d4bc236da 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1359 | [有效的快递序列数目](../../problems/count-all-valid-pickup-and-delivery-options) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/sort/README.md b/tag/sort/README.md index 247a8caef..73570ab7f 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | | 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[排序](../sort/README.md)] [[位运算](../bit-manipulation/README.md)] | Easy | | 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index 42e39f2bd..362397eda 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1374 | [生成每种字符都是奇数个的字符串](../../problems/generate-a-string-with-characters-that-have-odd-counts) | [[字符串](../string/README.md)] | Easy | +| 1371 | [每个元音包含偶数次的最长子字符串](../../problems/find-the-longest-substring-containing-vowels-in-even-counts) | [[字符串](../string/README.md)] | Medium | +| 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | | 1358 | [包含所有三种字符的子字符串数目](../../problems/number-of-substrings-containing-all-three-characters) | [[字符串](../string/README.md)] | Medium | | 1347 | [制造字母异位词的最小步骤数](../../problems/minimum-number-of-steps-to-make-two-strings-anagram) | [[字符串](../string/README.md)] | Medium | | 1332 | [删除回文子序列](../../problems/remove-palindromic-subsequences) | [[字符串](../string/README.md)] | Easy | diff --git a/tag/tags.json b/tag/tags.json index 07bcfd4a6..a6f7edc10 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -69,16 +69,16 @@ "Slug": "design", "TranslatedName": "设计" }, - { - "Name": "Bit Manipulation", - "Slug": "bit-manipulation", - "TranslatedName": "位运算" - }, { "Name": "Sort", "Slug": "sort", "TranslatedName": "排序" }, + { + "Name": "Bit Manipulation", + "Slug": "bit-manipulation", + "TranslatedName": "位运算" + }, { "Name": "Graph", "Slug": "graph", diff --git a/tag/tree/README.md b/tag/tree/README.md index a7053ac1d..0ebe052e9 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1325 | [删除给定值的叶子节点](../../problems/delete-leaves-with-a-given-value) | [[树](../tree/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index dcd4ad618..a749ae488 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -25,7 +25,7 @@ | 845 | [数组中的最长山脉](../../problems/longest-mountain-in-array) | [[双指针](../two-pointers/README.md)] | Medium | | 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 828 | [独特字符串](../../problems/count-unique-characters-of-all-substrings-of-a-given-string) | [[双指针](../two-pointers/README.md)] | Hard | +| 828 | [统计子串中的唯一字符](../../problems/count-unique-characters-of-all-substrings-of-a-given-string) | [[双指针](../two-pointers/README.md)] | Hard | | 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[双指针](../two-pointers/README.md)] | Medium | | 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | From 70a6508619826d39725740508cc7285ffb259340 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 16 Mar 2020 14:51:03 +0800 Subject: [PATCH 039/145] Add: new --- README.md | 6 ++ .../balance-a-binary-search-tree/README.md | 51 +++++++++++++ problems/course-schedule/README.md | 22 +++--- .../cut-off-trees-for-golf-event/README.md | 9 ++- .../README.md | 74 +++++++++++++++++++ problems/divide-two-integers/README.md | 12 ++- .../README.md | 71 ++++++++++++++++++ .../frog-position-after-t-seconds/README.md | 2 +- .../guess-number-higher-or-lower-ii/README.md | 2 +- .../increasing-order-search-tree/README.md | 12 +-- .../README.md | 2 +- problems/insert-delete-getrandom-o1/README.md | 2 +- problems/lucky-numbers-in-a-matrix/README.md | 65 ++++++++++++++++ .../maximum-performance-of-a-team/README.md | 69 +++++++++++++++++ .../README.md | 30 +++----- .../README.md | 14 ++++ .../mysql_schemas.sql | 12 +++ problems/trapping-rain-water-ii/README.md | 16 ++-- problems/word-search/README.md | 10 +++ tag/array/README.md | 1 + tag/binary-search-tree/README.md | 1 + tag/design/README.md | 1 + tag/greedy/README.md | 1 + tag/sort/README.md | 1 + tag/stack/README.md | 1 + tag/tree/README.md | 1 + 26 files changed, 437 insertions(+), 51 deletions(-) create mode 100644 problems/balance-a-binary-search-tree/README.md create mode 100644 problems/design-a-stack-with-increment-operation/README.md create mode 100644 problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md create mode 100644 problems/lucky-numbers-in-a-matrix/README.md create mode 100644 problems/maximum-performance-of-a-team/README.md create mode 100644 problems/replace-employee-id-with-the-unique-identifier/README.md create mode 100644 problems/replace-employee-id-with-the-unique-identifier/mysql_schemas.sql diff --git a/README.md b/README.md index 1569fd4b0..80f1b3d43 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,12 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1383 | [Maximum Performance of a Team](https://leetcode.com/problems/maximum-performance-of-a-team "最大的团队表现值") | [Go](problems/maximum-performance-of-a-team) | Hard | +| 1382 | [Balance a Binary Search Tree](https://leetcode.com/problems/balance-a-binary-search-tree "将二叉搜索树变平衡") | [Go](problems/balance-a-binary-search-tree) | Medium | +| 1381 | [Design a Stack With Increment Operation](https://leetcode.com/problems/design-a-stack-with-increment-operation "设计一个支持增量操作的栈") | [Go](problems/design-a-stack-with-increment-operation) | Medium | +| 1380 | [Lucky Numbers in a Matrix](https://leetcode.com/problems/lucky-numbers-in-a-matrix "矩阵中的幸运数") | [Go](problems/lucky-numbers-in-a-matrix) | Easy | +| 1379 | [Find a Corresponding Node of a Binary Tree in a Clone of That Tree](https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree "找出克隆二叉树中的相同节点") | [Go](problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | Medium | +| 1378 | [Replace Employee ID With The Unique Identifier](https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier "使用唯一标识码替换员工ID") 🔒 | [MySQL](problems/replace-employee-id-with-the-unique-identifier) | Easy | | 1377 | [Frog Position After T Seconds](https://leetcode.com/problems/frog-position-after-t-seconds "T 秒后青蛙的位置") | [Go](problems/frog-position-after-t-seconds) | Hard | | 1376 | [Time Needed to Inform All Employees](https://leetcode.com/problems/time-needed-to-inform-all-employees "通知所有员工所需的时间") | [Go](problems/time-needed-to-inform-all-employees) | Medium | | 1375 | [Bulb Switcher III](https://leetcode.com/problems/bulb-switcher-iii "灯泡开关 III") | [Go](problems/bulb-switcher-iii) | Medium | diff --git a/problems/balance-a-binary-search-tree/README.md b/problems/balance-a-binary-search-tree/README.md new file mode 100644 index 000000000..4820ce264 --- /dev/null +++ b/problems/balance-a-binary-search-tree/README.md @@ -0,0 +1,51 @@ + + + + + + + +[< Previous](../design-a-stack-with-increment-operation "Design a Stack With Increment Operation") +                 +[Next >](../maximum-performance-of-a-team "Maximum Performance of a Team") + +## [1382. Balance a Binary Search Tree (Medium)](https://leetcode.com/problems/balance-a-binary-search-tree "将二叉搜索树变平衡") + +

    Given a binary search tree, return a balanced binary search tree with the same node values.

    + +

    A binary search tree is balanced if and only if the depth of the two subtrees of every node never differ by more than 1.

    + +

    If there is more than one answer, return any of them.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: root = [1,null,2,null,3,null,4,null,null]
    +Output: [2,1,3,null,null,null,4]
    +Explanation: This is not the only correct answer, [3,1,4,null,2,null,null] is also correct.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is between 1 and 10^4.
    • +
    • The tree nodes will have distinct values between 1 and 10^5.
    • +
    + +### Related Topics + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + +### Hints +
    +Hint 1 +Convert the tree to a sorted array using an in-order traversal. +
    + +
    +Hint 2 +Construct a new balanced tree from the sorted array recursively. +
    diff --git a/problems/course-schedule/README.md b/problems/course-schedule/README.md index 1cea1585c..02808f090 100644 --- a/problems/course-schedule/README.md +++ b/problems/course-schedule/README.md @@ -11,36 +11,40 @@ ## [207. Course Schedule (Medium)](https://leetcode.com/problems/course-schedule "课程表") -

    There are a total of n courses you have to take, labeled from 0 to n-1.

    +

    There are a total of numCourses courses you have to take, labeled from 0 to numCourses-1.

    Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1]

    Given the total number of courses and a list of prerequisite pairs, is it possible for you to finish all courses?

    +

     

    Example 1:

    -Input: 2, [[1,0]] 
    -Output: true
    +Input: numCourses = 2, prerequisites = [[1,0]]
    +Output: true
     Explanation: There are a total of 2 courses to take. 
    -             To take course 1 you should have finished course 0. So it is possible.
    +  To take course 1 you should have finished course 0. So it is possible. +

    Example 2:

    -Input: 2, [[1,0],[0,1]]
    -Output: false
    +Input: numCourses = 2, prerequisites = [[1,0],[0,1]]
    +Output: false
     Explanation: There are a total of 2 courses to take. 
                  To take course 1 you should have finished course 0, and to take course 0 you should
                  also have finished course 1. So it is impossible.
     
    -

    Note:

    +

     

    +

    Constraints:

    -
      +
      • The input prerequisites is a graph represented by a list of edges, not adjacency matrices. Read more about how a graph is represented.
      • You may assume that there are no duplicate edges in the input prerequisites.
      • -
    +
  • 1 <= numCourses <= 10^5
  • + ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/cut-off-trees-for-golf-event/README.md b/problems/cut-off-trees-for-golf-event/README.md index cf0e863e8..d00dda833 100644 --- a/problems/cut-off-trees-for-golf-event/README.md +++ b/problems/cut-off-trees-for-golf-event/README.md @@ -19,7 +19,7 @@
  • The place with number bigger than 1 represents a tree can be walked through, and this positive number represents the tree's height.
  • -

     

    +

    In one step you can walk in any of the four directions top, bottom, left and right also when standing in a point which is a tree you can decide whether or not to cut off the tree.

    You are asked to cut off all the trees in this forest in the order of tree's height - always cut off the tree with lowest height first. And after cutting, the original place has the tree will become a grass (value 1).

    @@ -69,8 +69,13 @@

     

    +

    Constraints:

    -

    Hint: size of the given matrix will not exceed 50x50.

    +
      +
    • 1 <= forest.length <= 50
    • +
    • 1 <= forest[i].length <= 50
    • +
    • 0 <= forest[i][j] <= 10^9
    • +
    ### Related Topics [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/design-a-stack-with-increment-operation/README.md b/problems/design-a-stack-with-increment-operation/README.md new file mode 100644 index 000000000..0328198d4 --- /dev/null +++ b/problems/design-a-stack-with-increment-operation/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../lucky-numbers-in-a-matrix "Lucky Numbers in a Matrix") +                 +[Next >](../balance-a-binary-search-tree "Balance a Binary Search Tree") + +## [1381. Design a Stack With Increment Operation (Medium)](https://leetcode.com/problems/design-a-stack-with-increment-operation "设计一个支持增量操作的栈") + +

    Design a stack which supports the following operations.

    + +

    Implement the CustomStack class:

    + +
      +
    • CustomStack(int maxSize) Initializes the object with maxSize which is the maximum number of elements in the stack or do nothing if the stack reached the maxSize.
    • +
    • void push(int x) Adds x to the top of the stack if the stack hasn't reached the maxSize.
    • +
    • int pop() Pops and returns the top of stack or -1 if the stack is empty.
    • +
    • void inc(int k, int val) Increments the bottom k elements of the stack by val. If there are less than k elements in the stack, just increment all the elements in the stack.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input
    +["CustomStack","push","push","pop","push","push","push","increment","increment","pop","pop","pop","pop"]
    +[[3],[1],[2],[],[2],[3],[4],[5,100],[2,100],[],[],[],[]]
    +Output
    +[null,null,null,2,null,null,null,null,null,103,202,201,-1]
    +Explanation
    +CustomStack customStack = new CustomStack(3); // Stack is Empty []
    +customStack.push(1);                          // stack becomes [1]
    +customStack.push(2);                          // stack becomes [1, 2]
    +customStack.pop();                            // return 2 --> Return top of the stack 2, stack becomes [1]
    +customStack.push(2);                          // stack becomes [1, 2]
    +customStack.push(3);                          // stack becomes [1, 2, 3]
    +customStack.push(4);                          // stack still [1, 2, 3], Don't add another elements as size is 4
    +customStack.increment(5, 100);                // stack becomes [101, 102, 103]
    +customStack.increment(2, 100);                // stack becomes [201, 202, 103]
    +customStack.pop();                            // return 103 --> Return top of the stack 103, stack becomes [201, 202]
    +customStack.pop();                            // return 202 --> Return top of the stack 102, stack becomes [201]
    +customStack.pop();                            // return 201 --> Return top of the stack 101, stack becomes []
    +customStack.pop();                            // return -1 --> Stack is empty return -1.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= maxSize <= 1000
    • +
    • 1 <= x <= 1000
    • +
    • 1 <= k <= 1000
    • +
    • 0 <= val <= 100
    • +
    • At most 1000 calls will be made to each method of increment, push and pop each separately.
    • +
    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Design](../../tag/design/README.md)] + +### Hints +
    +Hint 1 +Use an array to represent the stack. Push will add new integer to the array. Pop removes the last element in the array and increment will add val to the first k elements of the array. +
    + +
    +Hint 2 +This solution run in O(1) per push and pop and O(k) per increment. +
    diff --git a/problems/divide-two-integers/README.md b/problems/divide-two-integers/README.md index cc6d1c827..5e7ecca08 100644 --- a/problems/divide-two-integers/README.md +++ b/problems/divide-two-integers/README.md @@ -15,26 +15,30 @@

    Return the quotient after dividing dividend by divisor.

    -

    The integer division should truncate toward zero.

    +

    The integer division should truncate toward zero, which means losing its fractional part. For example, truncate(8.345) = 8 and truncate(-2.7335) = -2.

    Example 1:

     Input: dividend = 10, divisor = 3
    -Output: 3
    +Output: 3 +Explanation: 10/3 = truncate(3.33333..) = truncate(3) = 3. +

    Example 2:

     Input: dividend = 7, divisor = -3
    -Output: -2
    +Output: -2 +Explanation: 7/-3 = truncate(-2.33333..) = truncate(-2) = 3. +

    Note:

    • Both dividend and divisor will be 32-bit signed integers.
    • The divisor will never be 0.
    • -
    • Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. For the purpose of this problem, assume that your function returns 231 − 1 when the division result overflows.
    • +
    • Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. For the purpose of this problem, assume that your function returns 231 − 1 when the division result overflows.
    ### Related Topics diff --git a/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md b/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md new file mode 100644 index 000000000..0f47e5ccb --- /dev/null +++ b/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../replace-employee-id-with-the-unique-identifier "Replace Employee ID With The Unique Identifier") +                 +[Next >](../lucky-numbers-in-a-matrix "Lucky Numbers in a Matrix") + +## [1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree (Medium)](https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree "找出克隆二叉树中的相同节点") + +

    Given two binary trees original and cloned and given a reference to a node target in the original tree.

    + +

    The cloned tree is a copy of the original tree.

    + +

    Return a reference to the same node in the cloned tree.

    + +

    Note that you are not allowed to change any of the two trees or the target node and the answer must be a reference to a node in the cloned tree.

    + +

    Follow up: Solve the problem if repeated values on the tree are allowed.

    + +

     

    +

    Example 1:

    + +
    +Input: tree = [7,4,3,null,null,6,19], target = 3
    +Output: 3
    +Explanation: In all examples the original and cloned trees are shown. The target node is a green node from the original tree. The answer is the yellow node from the cloned tree.
    +
    + +

    Example 2:

    + +
    +Input: tree = [7], target =  7
    +Output: 7
    +
    + +

    Example 3:

    + +
    +Input: tree = [8,null,6,null,5,null,4,null,3,null,2,null,1], target = 4
    +Output: 4
    +
    + +

    Example 4:

    + +
    +Input: tree = [1,2,3,4,5,6,7,8,9,10], target = 5
    +Output: 5
    +
    + +

    Example 5:

    + +
    +Input: tree = [1,2,null,3], target = 2
    +Output: 2
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [1, 10^4].
    • +
    • The values of the nodes of the tree are unique.
    • +
    • target node is a node from the original tree and is not null.
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] diff --git a/problems/frog-position-after-t-seconds/README.md b/problems/frog-position-after-t-seconds/README.md index fe86f23d2..b54d2c14a 100644 --- a/problems/frog-position-after-t-seconds/README.md +++ b/problems/frog-position-after-t-seconds/README.md @@ -7,7 +7,7 @@ [< Previous](../time-needed-to-inform-all-employees "Time Needed to Inform All Employees")                  -Next > +[Next >](../replace-employee-id-with-the-unique-identifier "Replace Employee ID With The Unique Identifier") ## [1377. Frog Position After T Seconds (Hard)](https://leetcode.com/problems/frog-position-after-t-seconds "T 秒后青蛙的位置") diff --git a/problems/guess-number-higher-or-lower-ii/README.md b/problems/guess-number-higher-or-lower-ii/README.md index 6a17d0b12..f18636f96 100644 --- a/problems/guess-number-higher-or-lower-ii/README.md +++ b/problems/guess-number-higher-or-lower-ii/README.md @@ -36,8 +36,8 @@ You end up paying $5 + $7 + $9 = $21.

    Given a particular n ≥ 1, find out how much money you need to have to guarantee a win.

    ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Minimax](../../tag/minimax/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Flip Game II](../flip-game-ii) (Medium) diff --git a/problems/increasing-order-search-tree/README.md b/problems/increasing-order-search-tree/README.md index 1343dda37..6bd71fc00 100644 --- a/problems/increasing-order-search-tree/README.md +++ b/problems/increasing-order-search-tree/README.md @@ -44,13 +44,13 @@   8   \ 9
    +

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. The number of nodes in the given tree will be between 1 and 100.
    2. -
    3. Each node will have a unique integer value from 0 to 1000.
    4. -
    +
      +
    • The number of nodes in the given tree will be between 1 and 100.
    • +
    • Each node will have a unique integer value from 0 to 1000.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md b/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md index 2dff0654c..7ea75746d 100644 --- a/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md +++ b/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md @@ -47,9 +47,9 @@ collection.getRandom();

    ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions 1. [Insert Delete GetRandom O(1)](../insert-delete-getrandom-o1) (Medium) diff --git a/problems/insert-delete-getrandom-o1/README.md b/problems/insert-delete-getrandom-o1/README.md index 3ce5e63e9..319374469 100644 --- a/problems/insert-delete-getrandom-o1/README.md +++ b/problems/insert-delete-getrandom-o1/README.md @@ -50,9 +50,9 @@ randomSet.getRandom();

    ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions 1. [Insert Delete GetRandom O(1) - Duplicates allowed](../insert-delete-getrandom-o1-duplicates-allowed) (Hard) diff --git a/problems/lucky-numbers-in-a-matrix/README.md b/problems/lucky-numbers-in-a-matrix/README.md new file mode 100644 index 000000000..f5d7023e8 --- /dev/null +++ b/problems/lucky-numbers-in-a-matrix/README.md @@ -0,0 +1,65 @@ + + + + + + + +[< Previous](../find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree "Find a Corresponding Node of a Binary Tree in a Clone of That Tree") +                 +[Next >](../design-a-stack-with-increment-operation "Design a Stack With Increment Operation") + +## [1380. Lucky Numbers in a Matrix (Easy)](https://leetcode.com/problems/lucky-numbers-in-a-matrix "矩阵中的幸运数") + +

    Given a m * n matrix of distinct numbers, return all lucky numbers in the matrix in any order.

    + +

    A lucky number is an element of the matrix such that it is the minimum element in its row and maximum in its column.

    + +

     

    +

    Example 1:

    + +
    +Input: matrix = [[3,7,8],[9,11,13],[15,16,17]]
    +Output: [15]
    +Explanation: 15 is the only lucky number since it is the minimum in its row and the maximum in its column
    +
    + +

    Example 2:

    + +
    +Input: matrix = [[1,10,4,2],[9,3,8,7],[15,16,17,12]]
    +Output: [12]
    +Explanation: 12 is the only lucky number since it is the minimum in its row and the maximum in its column.
    +
    + +

    Example 3:

    + +
    +Input: matrix = [[7,8],[1,2]]
    +Output: [7]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == mat.length
    • +
    • n == mat[i].length
    • +
    • 1 <= n, m <= 50
    • +
    • 1 <= matrix[i][j] <= 10^5.
    • +
    • All elements in the matrix are distinct.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Find out and save the minimum of each row and maximum of each column in two lists. +
    + +
    +Hint 2 +Then scan through the whole matrix to identify the elements that satisfy the criteria. +
    diff --git a/problems/maximum-performance-of-a-team/README.md b/problems/maximum-performance-of-a-team/README.md new file mode 100644 index 000000000..7bf1e3dc3 --- /dev/null +++ b/problems/maximum-performance-of-a-team/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../balance-a-binary-search-tree "Balance a Binary Search Tree") +                 +Next > + +## [1383. Maximum Performance of a Team (Hard)](https://leetcode.com/problems/maximum-performance-of-a-team "最大的团队表现值") + +

    There are n engineers numbered from 1 to n and two arrays: speed and efficiency, where speed[i] and efficiency[i] represent the speed and efficiency for the i-th engineer respectively. Return the maximum performance of a team composed of at most k engineers, since the answer can be a huge number, return this modulo 10^9 + 7.

    + +

    The performance of a team is the sum of their engineers' speeds multiplied by the minimum efficiency among their engineers. 

    + +

     

    +

    Example 1:

    + +
    +Input: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 2
    +Output: 60
    +Explanation: 
    +We have the maximum performance of the team by selecting engineer 2 (with speed=10 and efficiency=4) and engineer 5 (with speed=5 and efficiency=7). That is, performance = (10 + 5) * min(4, 7) = 60.
    +
    + +

    Example 2:

    + +
    +Input: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 3
    +Output: 68
    +Explanation:
    +This is the same example as the first but k = 3. We can select engineer 1, engineer 2 and engineer 5 to get the maximum performance of the team. That is, performance = (2 + 10 + 5) * min(5, 4, 7) = 68.
    +
    + +

    Example 3:

    + +
    +Input: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 4
    +Output: 72
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 10^5
    • +
    • speed.length == n
    • +
    • efficiency.length == n
    • +
    • 1 <= speed[i] <= 10^5
    • +
    • 1 <= efficiency[i] <= 10^8
    • +
    • 1 <= k <= n
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Sort](../../tag/sort/README.md)] + +### Hints +
    +Hint 1 +Keep track of the engineers by their efficiency in decreasing order. +
    + +
    +Hint 2 +For each engineer's efficiency take the K highest speeds among the engineers previously tracked. +
    diff --git a/problems/partition-array-into-three-parts-with-equal-sum/README.md b/problems/partition-array-into-three-parts-with-equal-sum/README.md index 17458db56..0d9a74fe5 100644 --- a/problems/partition-array-into-three-parts-with-equal-sum/README.md +++ b/problems/partition-array-into-three-parts-with-equal-sum/README.md @@ -16,42 +16,36 @@

    Formally, we can partition the array if we can find indexes i+1 < j with (A[0] + A[1] + ... + A[i] == A[i+1] + A[i+2] + ... + A[j-1] == A[j] + A[j-1] + ... + A[A.length - 1])

     

    -

    Example 1:

    -Input: [0,2,1,-6,6,-7,9,1,2,0,1]
    -Output: true
    -Explanation: 0 + 2 + 1 = -6 + 6 - 7 + 9 + 1 = 2 + 0 + 1
    +Input: A = [0,2,1,-6,6,-7,9,1,2,0,1]
    +Output: true
    +Explanation: 0 + 2 + 1 = -6 + 6 - 7 + 9 + 1 = 2 + 0 + 1
     
    -

    Example 2:

    -Input: [0,2,1,-6,6,7,9,-1,2,0,1]
    -Output: false
    +Input: A = [0,2,1,-6,6,7,9,-1,2,0,1]
    +Output: false
     
    -

    Example 3:

    -Input: [3,3,6,5,-2,2,5,1,-9,4]
    -Output: true
    -Explanation: 3 + 3 = 6 = 5 - 2 + 2 + 5 + 1 - 9 + 4
    +Input: A = [3,3,6,5,-2,2,5,1,-9,4]
    +Output: true
    +Explanation: 3 + 3 = 6 = 5 - 2 + 2 + 5 + 1 - 9 + 4
     
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 3 <= A.length <= 50000
      • -
      • -10000 <= A[i] <= 10000
      • -
    +
  • -10^4 <= A[i] <= 10^4
  • + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/replace-employee-id-with-the-unique-identifier/README.md b/problems/replace-employee-id-with-the-unique-identifier/README.md new file mode 100644 index 000000000..2ab2945a0 --- /dev/null +++ b/problems/replace-employee-id-with-the-unique-identifier/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../frog-position-after-t-seconds "Frog Position After T Seconds") +                 +[Next >](../find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree "Find a Corresponding Node of a Binary Tree in a Clone of That Tree") + +## [1378. Replace Employee ID With The Unique Identifier (Easy)](https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier "使用唯一标识码替换员工ID") + + diff --git a/problems/replace-employee-id-with-the-unique-identifier/mysql_schemas.sql b/problems/replace-employee-id-with-the-unique-identifier/mysql_schemas.sql new file mode 100644 index 000000000..93fb4473d --- /dev/null +++ b/problems/replace-employee-id-with-the-unique-identifier/mysql_schemas.sql @@ -0,0 +1,12 @@ +Create table If Not Exists Employees (id int, name varchar(20)); +Create table If Not Exists EmployeeUNI (id int, unique_id int); +Truncate table Employees; +insert into Employees (id, name) values ('1', 'Alice'); +insert into Employees (id, name) values ('7', 'Bob'); +insert into Employees (id, name) values ('11', 'Meir'); +insert into Employees (id, name) values ('90', 'Winston'); +insert into Employees (id, name) values ('3', 'Jonathan'); +Truncate table EmployeeUNI; +insert into EmployeeUNI (id, unique_id) values ('3', '1'); +insert into EmployeeUNI (id, unique_id) values ('11', '2'); +insert into EmployeeUNI (id, unique_id) values ('90', '3'); diff --git a/problems/trapping-rain-water-ii/README.md b/problems/trapping-rain-water-ii/README.md index 93c96ec7b..50abc3d39 100644 --- a/problems/trapping-rain-water-ii/README.md +++ b/problems/trapping-rain-water-ii/README.md @@ -13,14 +13,6 @@

    Given an m x n matrix of positive integers representing the height of each unit cell in a 2D elevation map, compute the volume of water it is able to trap after raining.

    -

     

    - -

    Note:

    - -

    Both m and n are less than 110. The height of each unit cell is greater than 0 and is less than 20,000.

    - -

     

    -

    Example:

    @@ -44,6 +36,14 @@ Return 4.
     
     

    After the rain, water is trapped between the blocks. The total volume of water trapped is 4.

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= m, n <= 110
    • +
    • 0 <= heightMap[i][j] <= 20000
    • +
    + ### Related Topics [[Heap](../../tag/heap/README.md)] [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/word-search/README.md b/problems/word-search/README.md index a6c9d25c5..be3a29f22 100644 --- a/problems/word-search/README.md +++ b/problems/word-search/README.md @@ -30,6 +30,16 @@ Given word = "SEE", return true. Given word = "ABCB", return false.
    +

     

    +

    Constraints:

    + +
      +
    • board and word consists only of lowercase and uppercase English letters.
    • +
    • 1 <= board.length <= 200
    • +
    • 1 <= board[i].length <= 200
    • +
    • 1 <= word.length <= 10^3
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] diff --git a/tag/array/README.md b/tag/array/README.md index 6c69108ce..6c40ac120 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1380 | [矩阵中的幸运数](../../problems/lucky-numbers-in-a-matrix) | [[数组](../array/README.md)] | Easy | | 1375 | [灯泡开关 III](../../problems/bulb-switcher-iii) | [[数组](../array/README.md)] | Medium | | 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/binary-search-tree/README.md b/tag/binary-search-tree/README.md index 4153b282b..d5e801079 100644 --- a/tag/binary-search-tree/README.md +++ b/tag/binary-search-tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1382 | [将二叉搜索树变平衡](../../problems/balance-a-binary-search-tree) | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | | 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | | 1038 | [从二叉搜索树到更大和树](../../problems/binary-search-tree-to-greater-sum-tree) | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index fc0019638..310b06a0b 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | | 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] | Medium | | 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index ca7efdb77..91d8b86b7 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Hard | | 1354 | [多次求和构造目标数组](../../problems/construct-target-array-with-multiple-sums) | [[贪心算法](../greedy/README.md)] | Hard | | 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | | 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index 73570ab7f..7b84b8318 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Hard | | 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | | 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[排序](../sort/README.md)] [[位运算](../bit-manipulation/README.md)] | Easy | diff --git a/tag/stack/README.md b/tag/stack/README.md index 865595eda..32a4c502e 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | | 1249 | [移除无效的括号](../../problems/minimum-remove-to-make-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | | 1209 | [删除字符串中的所有相邻重复项 II](../../problems/remove-all-adjacent-duplicates-in-string-ii) | [[栈](../stack/README.md)] | Medium | | 1190 | [反转每对括号间的子串](../../problems/reverse-substrings-between-each-pair-of-parentheses) | [[栈](../stack/README.md)] | Medium | diff --git a/tag/tree/README.md b/tag/tree/README.md index 0ebe052e9..7ae7fed66 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] | Medium | | 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | From f643c91721c900dd9bbf3ac65d03ea4c0da97fcf Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 24 Mar 2020 09:40:38 +0800 Subject: [PATCH 040/145] Add: new --- README.md | 9 ++ .../README.md | 94 ++++++++++++++++++ problems/cinema-seat-allocation/README.md | 77 +++++++++++++++ .../README.md | 79 +++++++++++++++ problems/divide-two-integers/README.md | 4 +- .../README.md | 72 ++++++++++++++ problems/four-divisors/README.md | 51 ++++++++++ .../README.md | 2 +- problems/insert-delete-getrandom-o1/README.md | 2 +- problems/is-subsequence/README.md | 2 +- problems/leaf-similar-trees/README.md | 6 +- problems/longest-happy-prefix/README.md | 66 +++++++++++++ .../maximum-performance-of-a-team/README.md | 2 +- problems/non-decreasing-array/README.md | 39 ++++---- problems/pizza-with-3n-slices/README.md | 83 ++++++++++++++++ problems/rotated-digits/README.md | 2 +- .../README.md | 95 +++++++++++++++++++ problems/task-scheduler/README.md | 11 +-- problems/total-sales-amount-by-year/README.md | 14 +++ .../mysql_schemas.sql | 10 ++ tag/array/README.md | 3 + tag/breadth-first-search/README.md | 1 + tag/depth-first-search/README.md | 1 + tag/dynamic-programming/README.md | 1 + tag/graph/README.md | 1 + tag/greedy/README.md | 1 + tag/math/README.md | 1 + tag/sort/README.md | 1 + tag/string/README.md | 1 + 29 files changed, 696 insertions(+), 35 deletions(-) create mode 100644 problems/check-if-there-is-a-valid-path-in-a-grid/README.md create mode 100644 problems/cinema-seat-allocation/README.md create mode 100644 problems/create-target-array-in-the-given-order/README.md create mode 100644 problems/find-the-distance-value-between-two-arrays/README.md create mode 100644 problems/four-divisors/README.md create mode 100644 problems/longest-happy-prefix/README.md create mode 100644 problems/pizza-with-3n-slices/README.md create mode 100644 problems/sort-integers-by-the-power-value/README.md create mode 100644 problems/total-sales-amount-by-year/README.md create mode 100644 problems/total-sales-amount-by-year/mysql_schemas.sql diff --git a/README.md b/README.md index 80f1b3d43..62e6317df 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,15 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1392 | [Longest Happy Prefix](https://leetcode.com/problems/longest-happy-prefix "最长快乐前缀") | [Go](problems/longest-happy-prefix) | Hard | +| 1391 | [Check if There is a Valid Path in a Grid](https://leetcode.com/problems/check-if-there-is-a-valid-path-in-a-grid "检查网格中是否存在有效路径") | [Go](problems/check-if-there-is-a-valid-path-in-a-grid) | Medium | +| 1390 | [Four Divisors](https://leetcode.com/problems/four-divisors "四因数") | [Go](problems/four-divisors) | Medium | +| 1389 | [Create Target Array in the Given Order](https://leetcode.com/problems/create-target-array-in-the-given-order "按既定顺序创建目标数组") | [Go](problems/create-target-array-in-the-given-order) | Easy | +| 1388 | [Pizza With 3n Slices](https://leetcode.com/problems/pizza-with-3n-slices "3n 块披萨") | [Go](problems/pizza-with-3n-slices) | Hard | +| 1387 | [Sort Integers by The Power Value](https://leetcode.com/problems/sort-integers-by-the-power-value "将整数按权重排序") | [Go](problems/sort-integers-by-the-power-value) | Medium | +| 1386 | [Cinema Seat Allocation](https://leetcode.com/problems/cinema-seat-allocation "安排电影院座位") | [Go](problems/cinema-seat-allocation) | Medium | +| 1385 | [Find the Distance Value Between Two Arrays](https://leetcode.com/problems/find-the-distance-value-between-two-arrays "两个数组间的距离值") | [Go](problems/find-the-distance-value-between-two-arrays) | Easy | +| 1384 | [Total Sales Amount by Year](https://leetcode.com/problems/total-sales-amount-by-year "按年度列出销售总额") 🔒 | [MySQL](problems/total-sales-amount-by-year) | Hard | | 1383 | [Maximum Performance of a Team](https://leetcode.com/problems/maximum-performance-of-a-team "最大的团队表现值") | [Go](problems/maximum-performance-of-a-team) | Hard | | 1382 | [Balance a Binary Search Tree](https://leetcode.com/problems/balance-a-binary-search-tree "将二叉搜索树变平衡") | [Go](problems/balance-a-binary-search-tree) | Medium | | 1381 | [Design a Stack With Increment Operation](https://leetcode.com/problems/design-a-stack-with-increment-operation "设计一个支持增量操作的栈") | [Go](problems/design-a-stack-with-increment-operation) | Medium | diff --git a/problems/check-if-there-is-a-valid-path-in-a-grid/README.md b/problems/check-if-there-is-a-valid-path-in-a-grid/README.md new file mode 100644 index 000000000..a6ccd766b --- /dev/null +++ b/problems/check-if-there-is-a-valid-path-in-a-grid/README.md @@ -0,0 +1,94 @@ + + + + + + + +[< Previous](../four-divisors "Four Divisors") +                 +[Next >](../longest-happy-prefix "Longest Happy Prefix") + +## [1391. Check if There is a Valid Path in a Grid (Medium)](https://leetcode.com/problems/check-if-there-is-a-valid-path-in-a-grid "检查网格中是否存在有效路径") + +Given a m x n grid. Each cell of the grid represents a street. The street of grid[i][j] can be: +
      +
    • 1 which means a street connecting the left cell and the right cell.
    • +
    • 2 which means a street connecting the upper cell and the lower cell.
    • +
    • 3 which means a street connecting the left cell and the lower cell.
    • +
    • 4 which means a street connecting the right cell and the lower cell.
    • +
    • 5 which means a street connecting the left cell and the upper cell.
    • +
    • 6 which means a street connecting the right cell and the upper cell.
    • +
    + +

    + +

    You will initially start at the street of the upper-left cell (0,0). A valid path in the grid is a path which starts from the upper left cell (0,0) and ends at the bottom-right cell (m - 1, n - 1). The path should only follow the streets.

    + +

    Notice that you are not allowed to change any street.

    + +

    Return true if there is a valid path in the grid or false otherwise.

    + +

     

    +

    Example 1:

    + +
    +Input: grid = [[2,4,3],[6,5,2]]
    +Output: true
    +Explanation: As shown you can start at cell (0, 0) and visit all the cells of the grid to reach (m - 1, n - 1).
    +
    + +

    Example 2:

    + +
    +Input: grid = [[1,2,1],[1,2,1]]
    +Output: false
    +Explanation: As shown you the street at cell (0, 0) is not connected with any street of any other cell and you will get stuck at cell (0, 0)
    +
    + +

    Example 3:

    + +
    +Input: grid = [[1,1,2]]
    +Output: false
    +Explanation: You will get stuck at cell (0, 1) and you cannot reach cell (0, 2).
    +
    + +

    Example 4:

    + +
    +Input: grid = [[1,1,1,1,1,1,3]]
    +Output: true
    +
    + +

    Example 5:

    + +
    +Input: grid = [[2],[2],[2],[2],[2],[2],[6]]
    +Output: true
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 300
    • +
    • 1 <= grid[i][j] <= 6
    • +
    + +### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + +### Hints +
    +Hint 1 +Start DFS from the node (0, 0) and follow the path till you stop. +
    + +
    +Hint 2 +When you reach a cell and cannot move anymore check that this cell is (m - 1, n - 1) or not. +
    diff --git a/problems/cinema-seat-allocation/README.md b/problems/cinema-seat-allocation/README.md new file mode 100644 index 000000000..1825bddea --- /dev/null +++ b/problems/cinema-seat-allocation/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../find-the-distance-value-between-two-arrays "Find the Distance Value Between Two Arrays") +                 +[Next >](../sort-integers-by-the-power-value "Sort Integers by The Power Value") + +## [1386. Cinema Seat Allocation (Medium)](https://leetcode.com/problems/cinema-seat-allocation "安排电影院座位") + +

    + +

    A cinema has n rows of seats, numbered from 1 to n and there are ten seats in each row, labelled from 1 to 10 as shown in the figure above.

    + +

    Given the array reservedSeats containing the numbers of seats already reserved, for example, reservedSeats[i]=[3,8] means the seat located in row 3 and labelled with 8 is already reserved. 

    + +

    Return the maximum number of four-person families you can allocate on the cinema seats. A four-person family occupies fours seats in one row, that are next to each other. Seats across an aisle (such as [3,3] and [3,4]) are not considered to be next to each other, however, It is permissible for the four-person family to be separated by an aisle, but in that case, exactly two people have to sit on each side of the aisle.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: n = 3, reservedSeats = [[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]
    +Output: 4
    +Explanation: The figure above shows the optimal allocation for four families, where seats mark with blue are already reserved and contiguous seats mark with orange are for one family. 
    +
    + +

    Example 2:

    + +
    +Input: n = 2, reservedSeats = [[2,1],[1,8],[2,6]]
    +Output: 2
    +
    + +

    Example 3:

    + +
    +Input: n = 4, reservedSeats = [[4,3],[1,4],[4,6],[1,7]]
    +Output: 4
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 10^9
    • +
    • 1 <= reservedSeats.length <= min(10*n, 10^4)
    • +
    • reservedSeats[i].length == 2
    • +
    • 1 <= reservedSeats[i][0] <= n
    • +
    • 1 <= reservedSeats[i][1] <= 10
    • +
    • All reservedSeats[i] are distinct.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Note you can allocate at most two families in one row. +
    + +
    +Hint 2 +Greedily check if you can allocate seats for two families, one family or none. +
    + +
    +Hint 3 +Process only rows that appear in the input, for other rows you can always allocate seats for two families. +
    diff --git a/problems/create-target-array-in-the-given-order/README.md b/problems/create-target-array-in-the-given-order/README.md new file mode 100644 index 000000000..0e4cdc0d9 --- /dev/null +++ b/problems/create-target-array-in-the-given-order/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../pizza-with-3n-slices "Pizza With 3n Slices") +                 +[Next >](../four-divisors "Four Divisors") + +## [1389. Create Target Array in the Given Order (Easy)](https://leetcode.com/problems/create-target-array-in-the-given-order "按既定顺序创建目标数组") + +

    Given two arrays of integers nums and index. Your task is to create target array under the following rules:

    + +
      +
    • Initially target array is empty.
    • +
    • From left to right read nums[i] and index[i], insert at index index[i] the value nums[i] in target array.
    • +
    • Repeat the previous step until there are no elements to read in nums and index.
    • +
    + +

    Return the target array.

    + +

    It is guaranteed that the insertion operations will be valid.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [0,1,2,3,4], index = [0,1,2,2,1]
    +Output: [0,4,1,3,2]
    +Explanation:
    +nums       index     target
    +0            0        [0]
    +1            1        [0,1]
    +2            2        [0,1,2]
    +3            2        [0,1,3,2]
    +4            1        [0,4,1,3,2]
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,2,3,4,0], index = [0,1,2,3,0]
    +Output: [0,1,2,3,4]
    +Explanation:
    +nums       index     target
    +1            0        [1]
    +2            1        [1,2]
    +3            2        [1,2,3]
    +4            3        [1,2,3,4]
    +0            0        [0,1,2,3,4]
    +
    + +

    Example 3:

    + +
    +Input: nums = [1], index = [0]
    +Output: [1]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length, index.length <= 100
    • +
    • nums.length == index.length
    • +
    • 0 <= nums[i] <= 100
    • +
    • 0 <= index[i] <= i
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Simulate the process and fill corresponding numbers in the designated spots. +
    diff --git a/problems/divide-two-integers/README.md b/problems/divide-two-integers/README.md index 5e7ecca08..0d0667fd8 100644 --- a/problems/divide-two-integers/README.md +++ b/problems/divide-two-integers/README.md @@ -22,7 +22,7 @@
     Input: dividend = 10, divisor = 3
     Output: 3
    -Explanation: 10/3 = truncate(3.33333..) = truncate(3) = 3.
    +Explanation: 10/3 = truncate(3.33333..) = 3.
     

    Example 2:

    @@ -30,7 +30,7 @@
     Input: dividend = 7, divisor = -3
     Output: -2
    -Explanation: 7/-3 = truncate(-2.33333..) = truncate(-2) = 3.
    +Explanation: 7/-3 = truncate(-2.33333..) = -2.
     

    Note:

    diff --git a/problems/find-the-distance-value-between-two-arrays/README.md b/problems/find-the-distance-value-between-two-arrays/README.md new file mode 100644 index 000000000..b1ec13c0d --- /dev/null +++ b/problems/find-the-distance-value-between-two-arrays/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../total-sales-amount-by-year "Total Sales Amount by Year") +                 +[Next >](../cinema-seat-allocation "Cinema Seat Allocation") + +## [1385. Find the Distance Value Between Two Arrays (Easy)](https://leetcode.com/problems/find-the-distance-value-between-two-arrays "两个数组间的距离值") + +

    Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays.

    + +

    The distance value is defined as the number of elements arr1[i] such that there is not any element arr2[j] where |arr1[i]-arr2[j]| <= d.

    + +

     

    +

    Example 1:

    + +
    +Input: arr1 = [4,5,8], arr2 = [10,9,1,8], d = 2
    +Output: 2
    +Explanation: 
    +For arr1[0]=4 we have: 
    +|4-10|=6 > d=2 
    +|4-9|=5 > d=2 
    +|4-1|=3 > d=2 
    +|4-8|=4 > d=2 
    +For arr1[1]=5 we have: 
    +|5-10|=5 > d=2 
    +|5-9|=4 > d=2 
    +|5-1|=4 > d=2 
    +|5-8|=3 > d=2
    +For arr1[2]=8 we have:
    +|8-10|=2 <= d=2
    +|8-9|=1 <= d=2
    +|8-1|=7 > d=2
    +|8-8|=0 <= d=2
    +
    + +

    Example 2:

    + +
    +Input: arr1 = [1,4,2,3], arr2 = [-4,-3,6,10,20,30], d = 3
    +Output: 2
    +
    + +

    Example 3:

    + +
    +Input: arr1 = [2,1,100,3], arr2 = [-5,-2,10,-3,7], d = 6
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr1.length, arr2.length <= 500
    • +
    • -10^3 <= arr1[i], arr2[j] <= 10^3
    • +
    • 0 <= d <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Sort 'arr2' and use binary search to get the closest element for each 'arr1[i]', it gives a time complexity of O(nlogn). +
    diff --git a/problems/four-divisors/README.md b/problems/four-divisors/README.md new file mode 100644 index 000000000..72d2bfa49 --- /dev/null +++ b/problems/four-divisors/README.md @@ -0,0 +1,51 @@ + + + + + + + +[< Previous](../create-target-array-in-the-given-order "Create Target Array in the Given Order") +                 +[Next >](../check-if-there-is-a-valid-path-in-a-grid "Check if There is a Valid Path in a Grid") + +## [1390. Four Divisors (Medium)](https://leetcode.com/problems/four-divisors "四因数") + +

    Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors.

    + +

    If there is no such integer in the array, return 0.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [21,4,7]
    +Output: 32
    +Explanation:
    +21 has 4 divisors: 1, 3, 7, 21
    +4 has 3 divisors: 1, 2, 4
    +7 has 2 divisors: 1, 7
    +The answer is the sum of divisors of 21 only.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 10^4
    • +
    • 1 <= nums[i] <= 10^5
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Find the divisors of each element in the array. +
    + +
    +Hint 2 +You only need to loop to the square root of a number to find its divisors. +
    diff --git a/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md b/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md index 7ea75746d..2dff0654c 100644 --- a/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md +++ b/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md @@ -47,9 +47,9 @@ collection.getRandom();

    ### Related Topics + [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Design](../../tag/design/README.md)] ### Similar Questions 1. [Insert Delete GetRandom O(1)](../insert-delete-getrandom-o1) (Medium) diff --git a/problems/insert-delete-getrandom-o1/README.md b/problems/insert-delete-getrandom-o1/README.md index 319374469..3ce5e63e9 100644 --- a/problems/insert-delete-getrandom-o1/README.md +++ b/problems/insert-delete-getrandom-o1/README.md @@ -50,9 +50,9 @@ randomSet.getRandom();

    ### Related Topics + [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Design](../../tag/design/README.md)] ### Similar Questions 1. [Insert Delete GetRandom O(1) - Duplicates allowed](../insert-delete-getrandom-o1-duplicates-allowed) (Hard) diff --git a/problems/is-subsequence/README.md b/problems/is-subsequence/README.md index 283334728..673cecd91 100644 --- a/problems/is-subsequence/README.md +++ b/problems/is-subsequence/README.md @@ -43,9 +43,9 @@ If there are lots of incoming S, say S1, S2, ... , Sk where k >= 1B, and you wan

    Credits:
    Special thanks to @pbrother for adding this problem and creating all test cases.

    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions 1. [Number of Matching Subsequences](../number-of-matching-subsequences) (Medium) diff --git a/problems/leaf-similar-trees/README.md b/problems/leaf-similar-trees/README.md index c52ca03f0..ec9028c6e 100644 --- a/problems/leaf-similar-trees/README.md +++ b/problems/leaf-similar-trees/README.md @@ -22,11 +22,11 @@

    Return true if and only if the two given trees with head nodes root1 and root2 are leaf-similar.

     

    - -

    Note:

    +

    Constraints:

      -
    • Both of the given trees will have between 1 and 100 nodes.
    • +
    • Both of the given trees will have between 1 and 200 nodes.
    • +
    • Both of the given trees will have values between 0 and 200
    ### Related Topics diff --git a/problems/longest-happy-prefix/README.md b/problems/longest-happy-prefix/README.md new file mode 100644 index 000000000..8ce5b431e --- /dev/null +++ b/problems/longest-happy-prefix/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../check-if-there-is-a-valid-path-in-a-grid "Check if There is a Valid Path in a Grid") +                 +Next > + +## [1392. Longest Happy Prefix (Hard)](https://leetcode.com/problems/longest-happy-prefix "最长快乐前缀") + +

    A string is called a happy prefix if is a non-empty prefix which is also a suffix (excluding itself).

    + +

    Given a string s. Return the longest happy prefix of s .

    + +

    Return an empty string if no such prefix exists.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "level"
    +Output: "l"
    +Explanation: s contains 4 prefix excluding itself ("l", "le", "lev", "leve"), and suffix ("l", "el", "vel", "evel"). The largest prefix which is also suffix is given by "l".
    +
    + +

    Example 2:

    + +
    +Input: s = "ababab"
    +Output: "abab"
    +Explanation: "abab" is the largest prefix which is also suffix. They can overlap in the original string.
    +
    + +

    Example 3:

    + +
    +Input: s = "leetcodeleet"
    +Output: "leet"
    +
    + +

    Example 4:

    + +
    +Input: s = "a"
    +Output: ""
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 10^5
    • +
    • s contains only lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Use Longest Prefix Suffix (KMP-table) or String Hashing. +
    diff --git a/problems/maximum-performance-of-a-team/README.md b/problems/maximum-performance-of-a-team/README.md index 7bf1e3dc3..4743fd9b7 100644 --- a/problems/maximum-performance-of-a-team/README.md +++ b/problems/maximum-performance-of-a-team/README.md @@ -7,7 +7,7 @@ [< Previous](../balance-a-binary-search-tree "Balance a Binary Search Tree")                  -Next > +[Next >](../total-sales-amount-by-year "Total Sales Amount by Year") ## [1383. Maximum Performance of a Team (Hard)](https://leetcode.com/problems/maximum-performance-of-a-team "最大的团队表现值") diff --git a/problems/non-decreasing-array/README.md b/problems/non-decreasing-array/README.md index 02506054e..bf06ba4f0 100644 --- a/problems/non-decreasing-array/README.md +++ b/problems/non-decreasing-array/README.md @@ -11,33 +11,34 @@ ## [665. Non-decreasing Array (Easy)](https://leetcode.com/problems/non-decreasing-array "非递减数列") -

    -Given an array with n integers, your task is to check if it could become non-decreasing by modifying at most 1 element. -

    +

    Given an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most 1 element.

    -

    -We define an array is non-decreasing if array[i] <= array[i + 1] holds for every i (1 <= i < n). -

    +

    We define an array is non-decreasing if nums[i] <= nums[i + 1] holds for every i (0-based) such that (0 <= i <= n - 2).

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: [4,2,3]
    -Output: True
    -Explanation: You could modify the first 4 to 1 to get a non-decreasing array.
    +Input: nums = [4,2,3]
    +Output: true
    +Explanation: You could modify the first 4 to 1 to get a non-decreasing array.
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: [4,2,1]
    -Output: False
    -Explanation: You can't get a non-decreasing array by modify at most one element.
    +Input: nums = [4,2,1]
    +Output: false
    +Explanation: You can't get a non-decreasing array by modify at most one element.
     
    -

    -

    Note: -The n belongs to [1, 10,000]. -

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 10 ^ 4
    • +
    • - 10 ^ 5 <= nums[i] <= 10 ^ 5
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/pizza-with-3n-slices/README.md b/problems/pizza-with-3n-slices/README.md new file mode 100644 index 000000000..ead6248cd --- /dev/null +++ b/problems/pizza-with-3n-slices/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../sort-integers-by-the-power-value "Sort Integers by The Power Value") +                 +[Next >](../create-target-array-in-the-given-order "Create Target Array in the Given Order") + +## [1388. Pizza With 3n Slices (Hard)](https://leetcode.com/problems/pizza-with-3n-slices "3n 块披萨") + +

    There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:

    + +
      +
    • You will pick any pizza slice.
    • +
    • Your friend Alice will pick next slice in anti clockwise direction of your pick. 
    • +
    • Your friend Bob will pick next slice in clockwise direction of your pick.
    • +
    • Repeat until there are no more slices of pizzas.
    • +
    + +

    Sizes of Pizza slices is represented by circular array slices in clockwise direction.

    + +

    Return the maximum possible sum of slice sizes which you can have.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: slices = [1,2,3,4,5,6]
    +Output: 10
    +Explanation: Pick pizza slice of size 4, Alice and Bob will pick slices with size 3 and 5 respectively. Then Pick slices with size 6, finally Alice and Bob will pick slice of size 2 and 1 respectively. Total = 4 + 6.
    +
    + +

    Example 2:

    + +

    + +
    +Input: slices = [8,9,8,6,1,1]
    +Output: 16
    +Output: Pick pizza slice of size 8 in each turn. If you pick slice with size 9 your partners will pick slices of size 8.
    +
    + +

    Example 3:

    + +
    +Input: slices = [4,1,2,5,8,3,1,9,7]
    +Output: 21
    +
    + +

    Example 4:

    + +
    +Input: slices = [3,1,2]
    +Output: 3
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= slices.length <= 500
    • +
    • slices.length % 3 == 0
    • +
    • 1 <= slices[i] <= 1000
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +By studying the pattern of the operations, we can find out that the problem is equivalent to: Given an integer array with size 3N, select N integers with maximum sum and any selected integers are not next to each other in the array. +
    + +
    +Hint 2 +The first one in the array is considered next to the last one in the array. Use Dynamic Programming to solve it. +
    diff --git a/problems/rotated-digits/README.md b/problems/rotated-digits/README.md index 9795ec22c..de4d05002 100644 --- a/problems/rotated-digits/README.md +++ b/problems/rotated-digits/README.md @@ -13,7 +13,7 @@

    X is a good number if after rotating each digit individually by 180 degrees, we get a valid number that is different from X.  Each digit must be rotated - we cannot choose to leave it alone.

    -

    A number is valid if each digit remains a digit after rotation. 0, 1, and 8 rotate to themselves; 2 and 5 rotate to each other; 6 and 9 rotate to each other, and the rest of the numbers do not rotate to any other number and become invalid.

    +

    A number is valid if each digit remains a digit after rotation. 0, 1, and 8 rotate to themselves; 2 and 5 rotate to each other (on this case they are rotated in a different direction, in other words 2 or 5 gets mirrored); 6 and 9 rotate to each other, and the rest of the numbers do not rotate to any other number and become invalid.

    Now given a positive number N, how many numbers X from 1 to N are good?

    diff --git a/problems/sort-integers-by-the-power-value/README.md b/problems/sort-integers-by-the-power-value/README.md new file mode 100644 index 000000000..2ef8484e8 --- /dev/null +++ b/problems/sort-integers-by-the-power-value/README.md @@ -0,0 +1,95 @@ + + + + + + + +[< Previous](../cinema-seat-allocation "Cinema Seat Allocation") +                 +[Next >](../pizza-with-3n-slices "Pizza With 3n Slices") + +## [1387. Sort Integers by The Power Value (Medium)](https://leetcode.com/problems/sort-integers-by-the-power-value "将整数按权重排序") + +

    The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps:

    + +
      +
    • if x is even then x = x / 2
    • +
    • if x is odd then x = 3 * x + 1
    • +
    + +

    For example, the power of x = 3 is 7 because 3 needs 7 steps to become 1 (3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1).

    + +

    Given three integers lo, hi and k. The task is to sort all integers in the interval [lo, hi] by the power value in ascending order, if two or more integers have the same power value sort them by ascending order.

    + +

    Return the k-th integer in the range [lo, hi] sorted by the power value.

    + +

    Notice that for any integer x (lo <= x <= hi) it is guaranteed that x will transform into 1 using these steps and that the power of x is will fit in 32 bit signed integer.

    + +

     

    +

    Example 1:

    + +
    +Input: lo = 12, hi = 15, k = 2
    +Output: 13
    +Explanation: The power of 12 is 9 (12 --> 6 --> 3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1)
    +The power of 13 is 9
    +The power of 14 is 17
    +The power of 15 is 17
    +The interval sorted by the power value [12,13,14,15]. For k = 2 answer is the second element which is 13.
    +Notice that 12 and 13 have the same power value and we sorted them in ascending order. Same for 14 and 15.
    +
    + +

    Example 2:

    + +
    +Input: lo = 1, hi = 1, k = 1
    +Output: 1
    +
    + +

    Example 3:

    + +
    +Input: lo = 7, hi = 11, k = 4
    +Output: 7
    +Explanation: The power array corresponding to the interval [7, 8, 9, 10, 11] is [16, 3, 19, 6, 14].
    +The interval sorted by power is [8, 10, 11, 7, 9].
    +The fourth number in the sorted array is 7.
    +
    + +

    Example 4:

    + +
    +Input: lo = 10, hi = 20, k = 5
    +Output: 13
    +
    + +

    Example 5:

    + +
    +Input: lo = 1, hi = 1000, k = 777
    +Output: 570
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= lo <= hi <= 1000
    • +
    • 1 <= k <= hi - lo + 1
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Graph](../../tag/graph/README.md)] + +### Hints +
    +Hint 1 +Use dynamic programming to get the power of each integer of the intervals. +
    + +
    +Hint 2 +Sort all the integers of the interval by the power value and return the k-th in the sorted list. +
    diff --git a/problems/task-scheduler/README.md b/problems/task-scheduler/README.md index 850176dde..4cfe52574 100644 --- a/problems/task-scheduler/README.md +++ b/problems/task-scheduler/README.md @@ -28,13 +28,12 @@

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. The number of tasks is in the range [1, 10000].
    2. -
    3. The integer n is in the range [0, 100].
    4. -
    +
      +
    • The number of tasks is in the range [1, 10000].
    • +
    • The integer n is in the range [0, 100].
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/total-sales-amount-by-year/README.md b/problems/total-sales-amount-by-year/README.md new file mode 100644 index 000000000..415c11781 --- /dev/null +++ b/problems/total-sales-amount-by-year/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../maximum-performance-of-a-team "Maximum Performance of a Team") +                 +[Next >](../find-the-distance-value-between-two-arrays "Find the Distance Value Between Two Arrays") + +## [1384. Total Sales Amount by Year (Hard)](https://leetcode.com/problems/total-sales-amount-by-year "按年度列出销售总额") + + diff --git a/problems/total-sales-amount-by-year/mysql_schemas.sql b/problems/total-sales-amount-by-year/mysql_schemas.sql new file mode 100644 index 000000000..28c6d0ba1 --- /dev/null +++ b/problems/total-sales-amount-by-year/mysql_schemas.sql @@ -0,0 +1,10 @@ +Create table If Not Exists Product (product_id int, product_name varchar(30)); +Create table If Not Exists Sales (product_id varchar(30), period_start date, period_end date, average_daily_sales int); +Truncate table Product; +insert into Product (product_id, product_name) values ('1', 'LC Phone '); +insert into Product (product_id, product_name) values ('2', 'LC T-Shirt'); +insert into Product (product_id, product_name) values ('3', 'LC Keychain'); +Truncate table Sales; +insert into Sales (product_id, period_start, period_end, average_daily_sales) values ('1', '2019-01-25', '2019-02-28', '100'); +insert into Sales (product_id, period_start, period_end, average_daily_sales) values ('2', '2018-12-01', '2020-01-01', '10'); +insert into Sales (product_id, period_start, period_end, average_daily_sales) values ('3', '2019-12-01', '2020-01-31', '1'); diff --git a/tag/array/README.md b/tag/array/README.md index 6c40ac120..cb37b2f45 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1389 | [按既定顺序创建目标数组](../../problems/create-target-array-in-the-given-order) | [[数组](../array/README.md)] | Easy | +| 1386 | [安排电影院座位](../../problems/cinema-seat-allocation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1385 | [两个数组间的距离值](../../problems/find-the-distance-value-between-two-arrays) | [[数组](../array/README.md)] | Easy | | 1380 | [矩阵中的幸运数](../../problems/lucky-numbers-in-a-matrix) | [[数组](../array/README.md)] | Easy | | 1375 | [灯泡开关 III](../../problems/bulb-switcher-iii) | [[数组](../array/README.md)] | Medium | | 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 90f4defa8..c7632435f 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 1345 | [跳跃游戏 IV](../../problems/jump-game-iv) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 8bcbdcdda..94c7ef128 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1377 | [T 秒后青蛙的位置](../../problems/frog-position-after-t-seconds) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | | 1376 | [通知所有员工所需的时间](../../problems/time-needed-to-inform-all-employees) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index d4bc236da..fc02277e4 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1388 | [3n 块披萨](../../problems/pizza-with-3n-slices) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/graph/README.md b/tag/graph/README.md index 906283e0a..0dc91bb4e 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | | 1361 | [验证二叉树](../../problems/validate-binary-tree-nodes) | [[图](../graph/README.md)] | Medium | | 1334 | [阈值距离内邻居最少的城市](../../problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | [[图](../graph/README.md)] | Medium | | 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 91d8b86b7..9f10119ea 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1386 | [安排电影院座位](../../problems/cinema-seat-allocation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Hard | | 1354 | [多次求和构造目标数组](../../problems/construct-target-array-with-multiple-sums) | [[贪心算法](../greedy/README.md)] | Hard | | 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 99ef5fd37..ada7dc38e 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1390 | [四因数](../../problems/four-divisors) | [[数学](../math/README.md)] | Medium | | 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1362 | [最接近的因数](../../problems/closest-divisors) | [[数学](../math/README.md)] | Medium | | 1359 | [有效的快递序列数目](../../problems/count-all-valid-pickup-and-delivery-options) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/sort/README.md b/tag/sort/README.md index 7b84b8318..00a686712 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | | 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Hard | | 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | | 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index 362397eda..200174778 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1392 | [最长快乐前缀](../../problems/longest-happy-prefix) | [[字符串](../string/README.md)] | Hard | | 1374 | [生成每种字符都是奇数个的字符串](../../problems/generate-a-string-with-characters-that-have-odd-counts) | [[字符串](../string/README.md)] | Easy | | 1371 | [每个元音包含偶数次的最长子字符串](../../problems/find-the-longest-substring-containing-vowels-in-even-counts) | [[字符串](../string/README.md)] | Medium | | 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | From ad29f32e3d70c305681b4eb084ba04baaba30ee7 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 30 Mar 2020 09:54:19 +0800 Subject: [PATCH 041/145] Add: new --- README.md | 7 +- .../available-captures-for-rook/README.md | 2 +- problems/bus-routes/README.md | 5 +- problems/capital-gainloss/README.md | 14 ++++ problems/capital-gainloss/mysql_schemas.sql | 12 +++ problems/count-number-of-teams/README.md | 65 +++++++++++++++ problems/design-underground-system/README.md | 83 +++++++++++++++++++ problems/find-all-good-strings/README.md | 65 +++++++++++++++ .../find-lucky-integer-in-an-array/README.md | 77 +++++++++++++++++ problems/is-subsequence/README.md | 2 +- problems/longest-happy-prefix/README.md | 2 +- problems/maximum-product-subarray/README.md | 2 +- problems/minimize-malware-spread/README.md | 8 +- problems/simplify-path/README.md | 2 +- problems/sliding-window-maximum/README.md | 14 +++- readme/1-300.md | 2 +- tag/array/README.md | 6 +- tag/design/README.md | 1 + tag/dynamic-programming/README.md | 3 +- 19 files changed, 352 insertions(+), 20 deletions(-) create mode 100644 problems/capital-gainloss/README.md create mode 100644 problems/capital-gainloss/mysql_schemas.sql create mode 100644 problems/count-number-of-teams/README.md create mode 100644 problems/design-underground-system/README.md create mode 100644 problems/find-all-good-strings/README.md create mode 100644 problems/find-lucky-integer-in-an-array/README.md diff --git a/README.md b/README.md index 62e6317df..19f651c0e 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,11 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1397 | [Find All Good Strings](https://leetcode.com/problems/find-all-good-strings "找到所有好字符串") | [Go](problems/find-all-good-strings) | Hard | +| 1396 | [Design Underground System](https://leetcode.com/problems/design-underground-system "设计地铁系统") | [Go](problems/design-underground-system) | Medium | +| 1395 | [Count Number of Teams](https://leetcode.com/problems/count-number-of-teams "统计作战单位数") | [Go](problems/count-number-of-teams) | Medium | +| 1394 | [Find Lucky Integer in an Array](https://leetcode.com/problems/find-lucky-integer-in-an-array "找出数组中的幸运数") | [Go](problems/find-lucky-integer-in-an-array) | Easy | +| 1393 | [Capital Gain/Loss](https://leetcode.com/problems/capital-gainloss) 🔒 | [MySQL](problems/capital-gainloss) | Medium | | 1392 | [Longest Happy Prefix](https://leetcode.com/problems/longest-happy-prefix "最长快乐前缀") | [Go](problems/longest-happy-prefix) | Hard | | 1391 | [Check if There is a Valid Path in a Grid](https://leetcode.com/problems/check-if-there-is-a-valid-path-in-a-grid "检查网格中是否存在有效路径") | [Go](problems/check-if-there-is-a-valid-path-in-a-grid) | Medium | | 1390 | [Four Divisors](https://leetcode.com/problems/four-divisors "四因数") | [Go](problems/four-divisors) | Medium | @@ -455,7 +460,7 @@ LeetCode Problems' Solutions | 1002 | [Find Common Characters](https://leetcode.com/problems/find-common-characters "查找常用字符") | [Go](problems/find-common-characters) | Easy | | 1001 | [Grid Illumination](https://leetcode.com/problems/grid-illumination "网格照明") | [Go](problems/grid-illumination) | Hard | | 1000 | [Minimum Cost to Merge Stones](https://leetcode.com/problems/minimum-cost-to-merge-stones "合并石头的最低成本") | [Go](problems/minimum-cost-to-merge-stones) | Hard | -| 999 | [Available Captures for Rook](https://leetcode.com/problems/available-captures-for-rook "车的可用捕获量") | [Go](problems/available-captures-for-rook) | Easy | +| 999 | [Available Captures for Rook](https://leetcode.com/problems/available-captures-for-rook "可以被一步捕获的棋子数") | [Go](problems/available-captures-for-rook) | Easy | | 998 | [Maximum Binary Tree II](https://leetcode.com/problems/maximum-binary-tree-ii "最大二叉树 II") | [Go](problems/maximum-binary-tree-ii) | Medium | | 997 | [Find the Town Judge](https://leetcode.com/problems/find-the-town-judge "找到小镇的法官") | [Go](problems/find-the-town-judge) | Easy | | 996 | [Number of Squareful Arrays](https://leetcode.com/problems/number-of-squareful-arrays "正方形数组的数目") | [Go](problems/number-of-squareful-arrays) | Hard | diff --git a/problems/available-captures-for-rook/README.md b/problems/available-captures-for-rook/README.md index 77dac0fc4..4ccfa4383 100644 --- a/problems/available-captures-for-rook/README.md +++ b/problems/available-captures-for-rook/README.md @@ -9,7 +9,7 @@                  [Next >](../minimum-cost-to-merge-stones "Minimum Cost to Merge Stones") -## [999. Available Captures for Rook (Easy)](https://leetcode.com/problems/available-captures-for-rook "车的可用捕获量") +## [999. Available Captures for Rook (Easy)](https://leetcode.com/problems/available-captures-for-rook "可以被一步捕获的棋子数")

    On an 8 x 8 chessboard, there is one white rook.  There also may be empty squares, white bishops, and black pawns.  These are given as characters 'R', '.', 'B', and 'p' respectively. Uppercase characters represent white pieces, and lowercase characters represent black pieces.

    diff --git a/problems/bus-routes/README.md b/problems/bus-routes/README.md index 758dfeff8..58e43ac65 100644 --- a/problems/bus-routes/README.md +++ b/problems/bus-routes/README.md @@ -26,11 +26,12 @@ T = 6 The best strategy is take the first bus to the bus stop 7, then take the second bus to the bus stop 6. -

    Note:

    +

     

    +

    Constraints:

    • 1 <= routes.length <= 500.
    • -
    • 1 <= routes[i].length <= 500.
    • +
    • 1 <= routes[i].length <= 10^5.
    • 0 <= routes[i][j] < 10 ^ 6.
    diff --git a/problems/capital-gainloss/README.md b/problems/capital-gainloss/README.md new file mode 100644 index 000000000..bffd10d17 --- /dev/null +++ b/problems/capital-gainloss/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../longest-happy-prefix "Longest Happy Prefix") +                 +[Next >](../find-lucky-integer-in-an-array "Find Lucky Integer in an Array") + +## [1393. Capital Gain/Loss (Medium)](https://leetcode.com/problems/capital-gainloss "") + + diff --git a/problems/capital-gainloss/mysql_schemas.sql b/problems/capital-gainloss/mysql_schemas.sql new file mode 100644 index 000000000..8b782e9d7 --- /dev/null +++ b/problems/capital-gainloss/mysql_schemas.sql @@ -0,0 +1,12 @@ +Create Table If Not Exists Stocks (stock_name varchar(15), operation ENUM('Sell', 'Buy'), operation_day int, price int); +Truncate table Stocks; +insert into Stocks (stock_name, operation, operation_day, price) values ('Leetcode', 'Buy', '1', '1000'); +insert into Stocks (stock_name, operation, operation_day, price) values ('Corona Masks', 'Buy', '2', '10'); +insert into Stocks (stock_name, operation, operation_day, price) values ('Leetcode', 'Sell', '5', '9000'); +insert into Stocks (stock_name, operation, operation_day, price) values ('Handbags', 'Buy', '17', '30000'); +insert into Stocks (stock_name, operation, operation_day, price) values ('Corona Masks', 'Sell', '3', '1010'); +insert into Stocks (stock_name, operation, operation_day, price) values ('Corona Masks', 'Buy', '4', '1000'); +insert into Stocks (stock_name, operation, operation_day, price) values ('Corona Masks', 'Sell', '5', '500'); +insert into Stocks (stock_name, operation, operation_day, price) values ('Corona Masks', 'Buy', '6', '1000'); +insert into Stocks (stock_name, operation, operation_day, price) values ('Handbags', 'Sell', '29', '7000'); +insert into Stocks (stock_name, operation, operation_day, price) values ('Corona Masks', 'Sell', '10', '10000'); diff --git a/problems/count-number-of-teams/README.md b/problems/count-number-of-teams/README.md new file mode 100644 index 000000000..6f7670f95 --- /dev/null +++ b/problems/count-number-of-teams/README.md @@ -0,0 +1,65 @@ + + + + + + + +[< Previous](../find-lucky-integer-in-an-array "Find Lucky Integer in an Array") +                 +[Next >](../design-underground-system "Design Underground System") + +## [1395. Count Number of Teams (Medium)](https://leetcode.com/problems/count-number-of-teams "统计作战单位数") + +

    There are n soldiers standing in a line. Each soldier is assigned a unique rating value.

    + +

    You have to form a team of 3 soldiers amongst them under the following rules:

    + +
      +
    • Choose 3 soldiers with index (i, j, k) with rating (rating[i], rating[j], rating[k]).
    • +
    • A team is valid if:  (rating[i] < rating[j] < rating[k]) or (rating[i] > rating[j] > rating[k]) where (0 <= i < j < k < n).
    • +
    + +

    Return the number of teams you can form given the conditions. (soldiers can be part of multiple teams).

    + +

     

    +

    Example 1:

    + +
    +Input: rating = [2,5,3,4,1]
    +Output: 3
    +Explanation: We can form three teams given the conditions. (2,3,4), (5,4,1), (5,3,1). 
    +
    + +

    Example 2:

    + +
    +Input: rating = [2,1,3]
    +Output: 0
    +Explanation: We can't form any team given the conditions.
    +
    + +

    Example 3:

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

     

    +

    Constraints:

    + +
      +
    • n == rating.length
    • +
    • 1 <= n <= 200
    • +
    • 1 <= rating[i] <= 10^5
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +BruteForce, check all possibilities. +
    diff --git a/problems/design-underground-system/README.md b/problems/design-underground-system/README.md new file mode 100644 index 000000000..e95e2a2d0 --- /dev/null +++ b/problems/design-underground-system/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../count-number-of-teams "Count Number of Teams") +                 +[Next >](../find-all-good-strings "Find All Good Strings") + +## [1396. Design Underground System (Medium)](https://leetcode.com/problems/design-underground-system "设计地铁系统") + +

    Implement the class UndergroundSystem that supports three methods:

    + +

    1. checkIn(int id, string stationName, int t)

    + +
      +
    • A customer with id card equal to id, gets in the station stationName at time t.
    • +
    • A customer can only be checked into one place at a time.
    • +
    + +

    2. checkOut(int id, string stationName, int t)

    + +
      +
    • A customer with id card equal to id, gets out from the station stationName at time t.
    • +
    + +

    3. getAverageTime(string startStation, string endStation) 

    + +
      +
    • Returns the average time to travel between the startStation and the endStation.
    • +
    • The average time is computed from all the previous traveling from startStation to endStation that happened directly.
    • +
    • Call to getAverageTime is always valid.
    • +
    + +

    You can assume all calls to checkIn and checkOut methods are consistent. That is, if a customer gets in at time t1 at some station, then it gets out at time t2 with t2 > t1. All events happen in chronological order.

    + +

     

    +

    Example 1:

    + +
    +Input
    +["UndergroundSystem","checkIn","checkIn","checkIn","checkOut","checkOut","checkOut","getAverageTime","getAverageTime","checkIn","getAverageTime","checkOut","getAverageTime"]
    +[[],[45,"Leyton",3],[32,"Paradise",8],[27,"Leyton",10],[45,"Waterloo",15],[27,"Waterloo",20],[32,"Cambridge",22],["Paradise","Cambridge"],["Leyton","Waterloo"],[10,"Leyton",24],["Leyton","Waterloo"],[10,"Waterloo",38],["Leyton","Waterloo"]]
    +
    +Output
    +[null,null,null,null,null,null,null,14.0,11.0,null,11.0,null,12.0]
    +
    +Explanation
    +UndergroundSystem undergroundSystem = new UndergroundSystem();
    +undergroundSystem.checkIn(45, "Leyton", 3);
    +undergroundSystem.checkIn(32, "Paradise", 8);
    +undergroundSystem.checkIn(27, "Leyton", 10);
    +undergroundSystem.checkOut(45, "Waterloo", 15);
    +undergroundSystem.checkOut(27, "Waterloo", 20);
    +undergroundSystem.checkOut(32, "Cambridge", 22);
    +undergroundSystem.getAverageTime("Paradise", "Cambridge");       // return 14.0. There was only one travel from "Paradise" (at time 8) to "Cambridge" (at time 22)
    +undergroundSystem.getAverageTime("Leyton", "Waterloo");          // return 11.0. There were two travels from "Leyton" to "Waterloo", a customer with id=45 from time=3 to time=15 and a customer with id=27 from time=10 to time=20. So the average time is ( (15-3) + (20-10) ) / 2 = 11.0
    +undergroundSystem.checkIn(10, "Leyton", 24);
    +undergroundSystem.getAverageTime("Leyton", "Waterloo");          // return 11.0
    +undergroundSystem.checkOut(10, "Waterloo", 38);
    +undergroundSystem.getAverageTime("Leyton", "Waterloo");          // return 12.0
    + +

     

    +

    Constraints:

    + +
      +
    • There will be at most 20000 operations.
    • +
    • 1 <= id, t <= 10^6
    • +
    • All strings consist of uppercase, lowercase English letters and digits.
    • +
    • 1 <= stationName.length <= 10
    • +
    • Answers within 10^-5 of the actual value will be accepted as correct.
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + +### Hints +
    +Hint 1 +Use two hash tables. The first to save the check-in time for a customer and the second to update the total time between two stations. +
    diff --git a/problems/find-all-good-strings/README.md b/problems/find-all-good-strings/README.md new file mode 100644 index 000000000..e36911120 --- /dev/null +++ b/problems/find-all-good-strings/README.md @@ -0,0 +1,65 @@ + + + + + + + +[< Previous](../design-underground-system "Design Underground System") +                 +Next > + +## [1397. Find All Good Strings (Hard)](https://leetcode.com/problems/find-all-good-strings "找到所有好字符串") + +

    Given the strings s1 and s2 of size n, and the string evil. Return the number of good strings.

    + +

    A good string has size n, it is alphabetically greater than or equal to s1, it is alphabetically smaller than or equal to s2, and it does not contain the string evil as a substring. Since the answer can be a huge number, return this modulo 10^9 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 2, s1 = "aa", s2 = "da", evil = "b"
    +Output: 51 
    +Explanation: There are 25 good strings starting with 'a': "aa","ac","ad",...,"az". Then there are 25 good strings starting with 'c': "ca","cc","cd",...,"cz" and finally there is one good string starting with 'd': "da". 
    +
    + +

    Example 2:

    + +
    +Input: n = 8, s1 = "leetcode", s2 = "leetgoes", evil = "leet"
    +Output: 0 
    +Explanation: All strings greater than or equal to s1 and smaller than or equal to s2 start with the prefix "leet", therefore, there is not any good string.
    +
    + +

    Example 3:

    + +
    +Input: n = 2, s1 = "gx", s2 = "gz", evil = "x"
    +Output: 2
    +
    + +

     

    +

    Constraints:

    + +
      +
    • s1.length == n
    • +
    • s2.length == n
    • +
    • 1 <= n <= 500
    • +
    • 1 <= evil.length <= 50
    • +
    • All strings consist of lowercase English letters.
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Use DP with 4 states (pos: Int, posEvil: Int, equalToS1: Bool, equalToS2: Bool) which compute the number of valid strings of size "pos" where the maximum common suffix with string "evil" has size "posEvil". When "equalToS1" is "true", the current valid string is equal to "S1" otherwise it is greater. In a similar way when equalToS2 is "true" the current valid string is equal to "S2" otherwise it is smaller. +
    + +
    +Hint 2 +To update the maximum common suffix with string "evil" use KMP preprocessing. +
    diff --git a/problems/find-lucky-integer-in-an-array/README.md b/problems/find-lucky-integer-in-an-array/README.md new file mode 100644 index 000000000..099a8ba85 --- /dev/null +++ b/problems/find-lucky-integer-in-an-array/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../capital-gainloss "Capital Gain/Loss") +                 +[Next >](../count-number-of-teams "Count Number of Teams") + +## [1394. Find Lucky Integer in an Array (Easy)](https://leetcode.com/problems/find-lucky-integer-in-an-array "找出数组中的幸运数") + +

    Given an array of integers arr, a lucky integer is an integer which has a frequency in the array equal to its value.

    + +

    Return a lucky integer in the array. If there are multiple lucky integers return the largest of them. If there is no lucky integer return -1.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [2,2,3,4]
    +Output: 2
    +Explanation: The only lucky number in the array is 2 because frequency[2] == 2.
    +
    + +

    Example 2:

    + +
    +Input: arr = [1,2,2,3,3,3]
    +Output: 3
    +Explanation: 1, 2 and 3 are all lucky numbers, return the largest of them.
    +
    + +

    Example 3:

    + +
    +Input: arr = [2,2,2,3,3]
    +Output: -1
    +Explanation: There are no lucky numbers in the array.
    +
    + +

    Example 4:

    + +
    +Input: arr = [5]
    +Output: -1
    +
    + +

    Example 5:

    + +
    +Input: arr = [7,7,7,7,7,7,7]
    +Output: 7
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 500
    • +
    • 1 <= arr[i] <= 500
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Count the frequency of each integer in the array. +
    + +
    +Hint 2 +Get all lucky numbers and return the largest of them. +
    diff --git a/problems/is-subsequence/README.md b/problems/is-subsequence/README.md index 673cecd91..283334728 100644 --- a/problems/is-subsequence/README.md +++ b/problems/is-subsequence/README.md @@ -43,9 +43,9 @@ If there are lots of incoming S, say S1, S2, ... , Sk where k >= 1B, and you wan

    Credits:
    Special thanks to @pbrother for adding this problem and creating all test cases.

    ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### Similar Questions 1. [Number of Matching Subsequences](../number-of-matching-subsequences) (Medium) diff --git a/problems/longest-happy-prefix/README.md b/problems/longest-happy-prefix/README.md index 8ce5b431e..dcfffa076 100644 --- a/problems/longest-happy-prefix/README.md +++ b/problems/longest-happy-prefix/README.md @@ -7,7 +7,7 @@ [< Previous](../check-if-there-is-a-valid-path-in-a-grid "Check if There is a Valid Path in a Grid")                  -Next > +[Next >](../capital-gainloss "Capital Gain/Loss") ## [1392. Longest Happy Prefix (Hard)](https://leetcode.com/problems/longest-happy-prefix "最长快乐前缀") diff --git a/problems/maximum-product-subarray/README.md b/problems/maximum-product-subarray/README.md index 9b93e539b..f2ebe7fbf 100644 --- a/problems/maximum-product-subarray/README.md +++ b/problems/maximum-product-subarray/README.md @@ -9,7 +9,7 @@                  [Next >](../find-minimum-in-rotated-sorted-array "Find Minimum in Rotated Sorted Array") -## [152. Maximum Product Subarray (Medium)](https://leetcode.com/problems/maximum-product-subarray "乘积最大子序列") +## [152. Maximum Product Subarray (Medium)](https://leetcode.com/problems/maximum-product-subarray "乘积最大子数组")

    Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.

    diff --git a/problems/minimize-malware-spread/README.md b/problems/minimize-malware-spread/README.md index dcfc452ec..fc61aba51 100644 --- a/problems/minimize-malware-spread/README.md +++ b/problems/minimize-malware-spread/README.md @@ -51,13 +51,13 @@

    Note:

    -
      +
      • 1 < graph.length = graph[0].length <= 300
      • 0 <= graph[i][j] == graph[j][i] <= 1
      • -
      • graph[i][i] = 1
      • -
      • 1 <= initial.length < graph.length
      • +
      • graph[i][i] == 1
      • +
      • 1 <= initial.length <= graph.length
      • 0 <= initial[i] < graph.length
      • -
    + ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/simplify-path/README.md b/problems/simplify-path/README.md index d321a7840..cb9780bdb 100644 --- a/problems/simplify-path/README.md +++ b/problems/simplify-path/README.md @@ -13,7 +13,7 @@

    Given an absolute path for a file (Unix-style), simplify it. Or in other words, convert it to the canonical path.

    -

    In a UNIX-style file system, a period . refers to the current directory. Furthermore, a double period .. moves the directory up a level. For more information, see: Absolute path vs relative path in Linux/Unix

    +

    In a UNIX-style file system, a period . refers to the current directory. Furthermore, a double period .. moves the directory up a level.

    Note that the returned canonical path must always begin with a slash /, and there must be only a single slash / between two directory names. The last directory name (if it exists) must not end with a trailing /. Also, the canonical path must be the shortest string representing the absolute path.

    diff --git a/problems/sliding-window-maximum/README.md b/problems/sliding-window-maximum/README.md index 442c5496a..144dad840 100644 --- a/problems/sliding-window-maximum/README.md +++ b/problems/sliding-window-maximum/README.md @@ -13,6 +13,9 @@

    Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the max sliding window.

    +

    Follow up:
    +Could you solve it in linear time?

    +

    Example:

    @@ -30,11 +33,14 @@ Window position                Max
      1  3  -1  -3  5 [3  6  7]      7
     
    -

    Note:
    -You may assume k is always valid, 1 ≤ k ≤ input array's size for non-empty array.

    +

     

    +

    Constraints:

    -

    Follow up:
    -Could you solve it in linear time?

    +
      +
    • 1 <= nums.length <= 10^5
    • +
    • -10^4 <= nums[i] <= 10^4
    • +
    • 1 <= k <= nums.length
    • +
    ### Related Topics [[Heap](../../tag/heap/README.md)] diff --git a/readme/1-300.md b/readme/1-300.md index bd56c5321..ace0725b6 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -213,7 +213,7 @@ LeetCode Problems' Solutions | 149 | [Max Points on a Line](https://leetcode.com/problems/max-points-on-a-line "直线上最多的点数") | [Go](../problems/max-points-on-a-line) | Hard | | 150 | [Evaluate Reverse Polish Notation](https://leetcode.com/problems/evaluate-reverse-polish-notation "逆波兰表达式求值") | [Go](../problems/evaluate-reverse-polish-notation) | Medium | | 151 | [Reverse Words in a String](https://leetcode.com/problems/reverse-words-in-a-string "翻转字符串里的单词") | [Go](../problems/reverse-words-in-a-string) | Medium | -| 152 | [Maximum Product Subarray](https://leetcode.com/problems/maximum-product-subarray "乘积最大子序列") | [Go](../problems/maximum-product-subarray) | Medium | +| 152 | [Maximum Product Subarray](https://leetcode.com/problems/maximum-product-subarray "乘积最大子数组") | [Go](../problems/maximum-product-subarray) | Medium | | 153 | [Find Minimum in Rotated Sorted Array](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array "寻找旋转排序数组中的最小值") | [Go](../problems/find-minimum-in-rotated-sorted-array) | Medium | | 154 | [Find Minimum in Rotated Sorted Array II](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii "寻找旋转排序数组中的最小值 II") | [Go](../problems/find-minimum-in-rotated-sorted-array-ii) | Hard | | 155 | [Min Stack](https://leetcode.com/problems/min-stack "最小栈") | [Go](../problems/min-stack) | Easy | diff --git a/tag/array/README.md b/tag/array/README.md index cb37b2f45..5023dc46d 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1395 | [统计作战单位数](../../problems/count-number-of-teams) | [[数组](../array/README.md)] | Medium | +| 1394 | [找出数组中的幸运数](../../problems/find-lucky-integer-in-an-array) | [[数组](../array/README.md)] | Easy | | 1389 | [按既定顺序创建目标数组](../../problems/create-target-array-in-the-given-order) | [[数组](../array/README.md)] | Easy | | 1386 | [安排电影院座位](../../problems/cinema-seat-allocation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1385 | [两个数组间的距离值](../../problems/find-the-distance-value-between-two-arrays) | [[数组](../array/README.md)] | Easy | @@ -84,7 +86,7 @@ | 1010 | [总持续时间可被 60 整除的歌曲](../../problems/pairs-of-songs-with-total-durations-divisible-by-60) | [[数组](../array/README.md)] | Easy | | 1007 | [行相等的最少多米诺旋转](../../problems/minimum-domino-rotations-for-equal-row) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 999 | [车的可用捕获量](../../problems/available-captures-for-rook) | [[数组](../array/README.md)] | Easy | +| 999 | [可以被一步捕获的棋子数](../../problems/available-captures-for-rook) | [[数组](../array/README.md)] | Easy | | 989 | [数组形式的整数加法](../../problems/add-to-array-form-of-integer) | [[数组](../array/README.md)] | Easy | | 985 | [查询后的偶数和](../../problems/sum-of-even-numbers-after-queries) | [[数组](../array/README.md)] | Easy | | 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | @@ -192,7 +194,7 @@ | 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 154 | [寻找旋转排序数组中的最小值 II](../../problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 152 | [乘积最大子序列](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 152 | [乘积最大子数组](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 128 | [最长连续序列](../../problems/longest-consecutive-sequence) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Hard | | 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 123 | [买卖股票的最佳时机 III](../../problems/best-time-to-buy-and-sell-stock-iii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/design/README.md b/tag/design/README.md index 310b06a0b..0f442f13a 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] | Medium | | 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | | 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] | Medium | | 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index fc02277e4..5827ea901 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1397 | [找到所有好字符串](../../problems/find-all-good-strings) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1388 | [3n 块披萨](../../problems/pizza-with-3n-slices) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -174,7 +175,7 @@ | 198 | [打家劫舍](../../problems/house-robber) | [[动态规划](../dynamic-programming/README.md)] | Easy | | 188 | [买卖股票的最佳时机 IV](../../problems/best-time-to-buy-and-sell-stock-iv) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 174 | [地下城游戏](../../problems/dungeon-game) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 152 | [乘积最大子序列](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 152 | [乘积最大子数组](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 140 | [单词拆分 II](../../problems/word-break-ii) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 139 | [单词拆分](../../problems/word-break) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 132 | [分割回文串 II](../../problems/palindrome-partitioning-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | From 9baaaf5d97acd0e8bcb2692425468de44293ed1f Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 2 Apr 2020 10:06:12 +0800 Subject: [PATCH 042/145] Add: Generate a String With Characters That Have Odd Counts --- ...ng_with_characters_that_have_odd_counts.go | 12 +++++++ ...th_characters_that_have_odd_counts_test.go | 35 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 problems/generate-a-string-with-characters-that-have-odd-counts/generate_a_string_with_characters_that_have_odd_counts.go create mode 100644 problems/generate-a-string-with-characters-that-have-odd-counts/generate_a_string_with_characters_that_have_odd_counts_test.go diff --git a/problems/generate-a-string-with-characters-that-have-odd-counts/generate_a_string_with_characters_that_have_odd_counts.go b/problems/generate-a-string-with-characters-that-have-odd-counts/generate_a_string_with_characters_that_have_odd_counts.go new file mode 100644 index 000000000..707bfb46d --- /dev/null +++ b/problems/generate-a-string-with-characters-that-have-odd-counts/generate_a_string_with_characters_that_have_odd_counts.go @@ -0,0 +1,12 @@ +package problem1374 + +func generateTheString(n int) string { + b := make([]byte, n) + for i := 0; i < n; i++ { + b[i] = 'x' + } + if n%2 == 0 { + b[n-1] = 'y' + } + return string(b) +} diff --git a/problems/generate-a-string-with-characters-that-have-odd-counts/generate_a_string_with_characters_that_have_odd_counts_test.go b/problems/generate-a-string-with-characters-that-have-odd-counts/generate_a_string_with_characters_that_have_odd_counts_test.go new file mode 100644 index 000000000..3c121cfee --- /dev/null +++ b/problems/generate-a-string-with-characters-that-have-odd-counts/generate_a_string_with_characters_that_have_odd_counts_test.go @@ -0,0 +1,35 @@ +package problem1374 + +import "testing" + +type testType struct { + in int + want string +} + +func TestGenerateTheString(t *testing.T) { + tests := [...]testType{ + { + in: 4, + want: "xxxy", + }, + { + in: 2, + want: "xy", + }, + { + in: 7, + want: "xxxxxxx", + }, + { + in: 30, + want: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxy", + }, + } + for _, tt := range tests { + got := generateTheString(tt.in) + if got != tt.want { + t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want) + } + } +} From f7ea9e8c23e1442edc5a54fd6a40977b8cdd7f54 Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 2 Apr 2020 10:52:08 +0800 Subject: [PATCH 043/145] U: tidy --- .../angle-between-hands-of-a-clock/README.md | 2 +- .../README.md | 2 +- problems/find-all-good-strings/README.md | 1 + problems/h-index/README.md | 2 +- problems/integer-replacement/README.md | 2 +- problems/quad-tree-intersection/README.md | 80 ------------------- .../quad_tree_intersection.go | 1 - .../quad_tree_intersection.py | 16 ---- .../quad_tree_intersection_test.go | 1 - problems/swap-adjacent-in-lr-string/README.md | 9 ++- problems/unique-letter-string/README.md | 52 ------------ .../unique_letter_string.go | 1 - .../unique_letter_string_test.go | 1 - readme/1-300.md | 4 +- tag/breadth-first-search/README.md | 2 +- tag/hash-table/README.md | 2 +- tag/sort/README.md | 2 +- tag/tree/README.md | 2 +- 18 files changed, 16 insertions(+), 166 deletions(-) delete mode 100644 problems/quad-tree-intersection/README.md delete mode 100644 problems/quad-tree-intersection/quad_tree_intersection.go delete mode 100755 problems/quad-tree-intersection/quad_tree_intersection.py delete mode 100644 problems/quad-tree-intersection/quad_tree_intersection_test.go delete mode 100644 problems/unique-letter-string/README.md delete mode 100644 problems/unique-letter-string/unique_letter_string.go delete mode 100644 problems/unique-letter-string/unique_letter_string_test.go diff --git a/problems/angle-between-hands-of-a-clock/README.md b/problems/angle-between-hands-of-a-clock/README.md index b78b0d9d9..96ac413ee 100644 --- a/problems/angle-between-hands-of-a-clock/README.md +++ b/problems/angle-between-hands-of-a-clock/README.md @@ -11,7 +11,7 @@ ## [1344. Angle Between Hands of a Clock (Medium)](https://leetcode.com/problems/angle-between-hands-of-a-clock "时钟指针的夹角") -

    Given two numbers, hour and minutes. Return the smaller angle (in sexagesimal units) formed between the hour and the minute hand.

    +

    Given two numbers, hour and minutes. Return the smaller angle (in degrees) formed between the hour and the minute hand.

     

    Example 1:

    diff --git a/problems/binary-tree-level-order-traversal/README.md b/problems/binary-tree-level-order-traversal/README.md index d0e34e041..31c4ec7a1 100644 --- a/problems/binary-tree-level-order-traversal/README.md +++ b/problems/binary-tree-level-order-traversal/README.md @@ -9,7 +9,7 @@                  [Next >](../binary-tree-zigzag-level-order-traversal "Binary Tree Zigzag Level Order Traversal") -## [102. Binary Tree Level Order Traversal (Medium)](https://leetcode.com/problems/binary-tree-level-order-traversal "二叉树的层次遍历") +## [102. Binary Tree Level Order Traversal (Medium)](https://leetcode.com/problems/binary-tree-level-order-traversal "二叉树的层序遍历")

    Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).

    diff --git a/problems/find-all-good-strings/README.md b/problems/find-all-good-strings/README.md index e36911120..a81a4cfc5 100644 --- a/problems/find-all-good-strings/README.md +++ b/problems/find-all-good-strings/README.md @@ -45,6 +45,7 @@ Next >
    • s1.length == n
    • s2.length == n
    • +
    • s1 <= s2
    • 1 <= n <= 500
    • 1 <= evil.length <= 50
    • All strings consist of lowercase English letters.
    • diff --git a/problems/h-index/README.md b/problems/h-index/README.md index 0858d62f3..734b667b4 100644 --- a/problems/h-index/README.md +++ b/problems/h-index/README.md @@ -9,7 +9,7 @@                  [Next >](../h-index-ii "H-Index II") -## [274. H-Index (Medium)](https://leetcode.com/problems/h-index "H指数") +## [274. H-Index (Medium)](https://leetcode.com/problems/h-index "H 指数")

      Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.

      diff --git a/problems/integer-replacement/README.md b/problems/integer-replacement/README.md index a34ff2c94..db19d0243 100644 --- a/problems/integer-replacement/README.md +++ b/problems/integer-replacement/README.md @@ -57,5 +57,5 @@ or

      ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/quad-tree-intersection/README.md b/problems/quad-tree-intersection/README.md deleted file mode 100644 index 8eca3810f..000000000 --- a/problems/quad-tree-intersection/README.md +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - -[< Previous](../reverse-words-in-a-string-iii "Reverse Words in a String III") -                 -[Next >](../maximum-depth-of-n-ary-tree "Maximum Depth of N-ary Tree") - -## [558. Quad Tree Intersection (Easy)](https://leetcode.com/problems/quad-tree-intersection "四叉树交集") - -

      A quadtree is a tree data in which each internal node has exactly four children: topLeft, topRight, bottomLeft and bottomRight. Quad trees are often used to partition a two-dimensional space by recursively subdividing it into four quadrants or regions.

      - -

      We want to store True/False information in our quad tree. The quad tree is used to represent a N * N boolean grid. For each node, it will be subdivided into four children nodes until the values in the region it represents are all the same. Each node has another two boolean attributes : isLeaf and val. isLeaf is true if and only if the node is a leaf node. The val attribute for a leaf node contains the value of the region it represents.

      - -

      For example, below are two quad trees A and B:

      - -
      -A:
      -+-------+-------+   T: true
      -|       |       |   F: false
      -|   T   |   T   |
      -|       |       |
      -+-------+-------+
      -|       |       |
      -|   F   |   F   |
      -|       |       |
      -+-------+-------+
      -topLeft: T
      -topRight: T
      -bottomLeft: F
      -bottomRight: F
      -
      -B:               
      -+-------+---+---+
      -|       | F | F |
      -|   T   +---+---+
      -|       | T | T |
      -+-------+---+---+
      -|       |       |
      -|   T   |   F   |
      -|       |       |
      -+-------+-------+
      -topLeft: T
      -topRight:
      -     topLeft: F
      -     topRight: F
      -     bottomLeft: T
      -     bottomRight: T
      -bottomLeft: T
      -bottomRight: F
      -
      - -

       

      - -

      Your task is to implement a function that will take two quadtrees and return a quadtree that represents the logical OR (or union) of the two trees.

      - -
      -A:                 B:                 C (A or B):
      -+-------+-------+  +-------+---+---+  +-------+-------+
      -|       |       |  |       | F | F |  |       |       |
      -|   T   |   T   |  |   T   +---+---+  |   T   |   T   |
      -|       |       |  |       | T | T |  |       |       |
      -+-------+-------+  +-------+---+---+  +-------+-------+
      -|       |       |  |       |       |  |       |       |
      -|   F   |   F   |  |   T   |   F   |  |   T   |   F   |
      -|       |       |  |       |       |  |       |       |
      -+-------+-------+  +-------+-------+  +-------+-------+
      -
      - -

      Note:

      - -
        -
      1. Both A and B represent grids of size N * N.
      2. -
      3. N is guaranteed to be a power of 2.
      4. -
      5. If you want to know more about the quad tree, you can refer to its wiki.
      6. -
      7. The logic OR operation is defined as this: "A or B" is true if A is true, or if B is true, or if both A and B are true.
      8. -
      diff --git a/problems/quad-tree-intersection/quad_tree_intersection.go b/problems/quad-tree-intersection/quad_tree_intersection.go deleted file mode 100644 index 73dbfbda2..000000000 --- a/problems/quad-tree-intersection/quad_tree_intersection.go +++ /dev/null @@ -1 +0,0 @@ -package problem558 diff --git a/problems/quad-tree-intersection/quad_tree_intersection.py b/problems/quad-tree-intersection/quad_tree_intersection.py deleted file mode 100755 index 67b733294..000000000 --- a/problems/quad-tree-intersection/quad_tree_intersection.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env python - -""" -# Definition for a QuadTree node. -class Node: - def __init__(self, val, isLeaf, topLeft, topRight, bottomLeft, bottomRight): - self.val = val - self.isLeaf = isLeaf - self.topLeft = topLeft - self.topRight = topRight - self.bottomLeft = bottomLeft - self.bottomRight = bottomRight -""" -class Solution: - def intersect(self, quadTree1: 'Node', quadTree2: 'Node') -> 'Node': - \ No newline at end of file diff --git a/problems/quad-tree-intersection/quad_tree_intersection_test.go b/problems/quad-tree-intersection/quad_tree_intersection_test.go deleted file mode 100644 index 73dbfbda2..000000000 --- a/problems/quad-tree-intersection/quad_tree_intersection_test.go +++ /dev/null @@ -1 +0,0 @@ -package problem558 diff --git a/problems/swap-adjacent-in-lr-string/README.md b/problems/swap-adjacent-in-lr-string/README.md index 4294ce3c1..dbd7efcc0 100644 --- a/problems/swap-adjacent-in-lr-string/README.md +++ b/problems/swap-adjacent-in-lr-string/README.md @@ -27,12 +27,13 @@ XRLXXRRXL -> XRLXXRRLX -

      Note:

      +

       

      +

      Constraints:

      -
        -
      1. 1 <= len(start) = len(end) <= 10000.
      2. +
          +
        • 1 <= len(start) == len(end) <= 10000.
        • Both start and end will only consist of characters in {'L', 'R', 'X'}.
        • -
      +
    ### Related Topics [[Brainteaser](../../tag/brainteaser/README.md)] diff --git a/problems/unique-letter-string/README.md b/problems/unique-letter-string/README.md deleted file mode 100644 index a6de633cd..000000000 --- a/problems/unique-letter-string/README.md +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - -[< Previous](../making-a-large-island "Making A Large Island") -                 -[Next >](../consecutive-numbers-sum "Consecutive Numbers Sum") - -## [828. Unique Letter String (Hard)](https://leetcode.com/problems/unique-letter-string "独特字符串") - -

    A character is unique in string S if it occurs exactly once in it.

    - -

    For example, in string S = "LETTER", the only unique characters are "L" and "R".

    - -

    Let's define UNIQ(S) as the number of unique characters in string S.

    - -

    For example, UNIQ("LETTER") =  2.

    - -

    Given a string S with only uppercases, calculate the sum of UNIQ(substring) over all non-empty substrings of S.

    - -

    If there are two or more equal substrings at different positions in S, we consider them different.

    - -

    Since the answer can be very large, return the answer modulo 10 ^ 9 + 7.

    - -

     

    - -

    Example 1:

    - -
    -Input: "ABC"
    -Output: 10
    -Explanation: All possible substrings are: "A","B","C","AB","BC" and "ABC".
    -Evey substring is composed with only unique letters.
    -Sum of lengths of all substring is 1 + 1 + 1 + 2 + 2 + 3 = 10
    - -

    Example 2:

    - -
    -Input: "ABA"
    -Output: 8
    -Explanation: The same as example 1, except uni("ABA") = 1.
    -
    - -

     

    - -

    Note: 0 <= S.length <= 10000.

    - -### Related Topics - [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/unique-letter-string/unique_letter_string.go b/problems/unique-letter-string/unique_letter_string.go deleted file mode 100644 index 66a63083f..000000000 --- a/problems/unique-letter-string/unique_letter_string.go +++ /dev/null @@ -1 +0,0 @@ -package problem828 diff --git a/problems/unique-letter-string/unique_letter_string_test.go b/problems/unique-letter-string/unique_letter_string_test.go deleted file mode 100644 index 66a63083f..000000000 --- a/problems/unique-letter-string/unique_letter_string_test.go +++ /dev/null @@ -1 +0,0 @@ -package problem828 diff --git a/readme/1-300.md b/readme/1-300.md index ace0725b6..a9af4d825 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -163,7 +163,7 @@ LeetCode Problems' Solutions | 99 | [Recover Binary Search Tree](https://leetcode.com/problems/recover-binary-search-tree "恢复二叉搜索树") | [Go](../problems/recover-binary-search-tree) | Hard | | 100 | [Same Tree](https://leetcode.com/problems/same-tree "相同的树") | [Go](../problems/same-tree) | Easy | | 101 | [Symmetric Tree](https://leetcode.com/problems/symmetric-tree "对称二叉树") | [Go](../problems/symmetric-tree) | Easy | -| 102 | [Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal "二叉树的层次遍历") | [Go](../problems/binary-tree-level-order-traversal) | Medium | +| 102 | [Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal "二叉树的层序遍历") | [Go](../problems/binary-tree-level-order-traversal) | Medium | | 103 | [Binary Tree Zigzag Level Order Traversal](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal "二叉树的锯齿形层次遍历") | [Go](../problems/binary-tree-zigzag-level-order-traversal) | Medium | | 104 | [Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree "二叉树的最大深度") | [Go](../problems/maximum-depth-of-binary-tree) | Easy | | 105 | [Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal "从前序与中序遍历序列构造二叉树") | [Go](../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | Medium | @@ -335,7 +335,7 @@ LeetCode Problems' Solutions | 271 | [Encode and Decode Strings](https://leetcode.com/problems/encode-and-decode-strings "字符串的编码与解码") 🔒 | [Go](../problems/encode-and-decode-strings) | Medium | | 272 | [Closest Binary Search Tree Value II](https://leetcode.com/problems/closest-binary-search-tree-value-ii "最接近的二叉搜索树值 II") 🔒 | [Go](../problems/closest-binary-search-tree-value-ii) | Hard | | 273 | [Integer to English Words](https://leetcode.com/problems/integer-to-english-words "整数转换英文表示") | [Go](../problems/integer-to-english-words) | Hard | -| 274 | [H-Index](https://leetcode.com/problems/h-index "H指数") | [Go](../problems/h-index) | Medium | +| 274 | [H-Index](https://leetcode.com/problems/h-index "H 指数") | [Go](../problems/h-index) | Medium | | 275 | [H-Index II](https://leetcode.com/problems/h-index-ii "H指数 II") | [Go](../problems/h-index-ii) | Medium | | 276 | [Paint Fence](https://leetcode.com/problems/paint-fence "栅栏涂色") 🔒 | [Go](../problems/paint-fence) | Easy | | 277 | [Find the Celebrity](https://leetcode.com/problems/find-the-celebrity "搜寻名人") 🔒 | [Go](../problems/find-the-celebrity) | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index c7632435f..5a541ddc1 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -74,5 +74,5 @@ | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 107 | [二叉树的层次遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 103 | [二叉树的锯齿形层次遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 102 | [二叉树的层次遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 102 | [二叉树的层序遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index f64eb2adf..048244161 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -104,7 +104,7 @@ | 299 | [猜数字游戏](../../problems/bulls-and-cows) | [[哈希表](../hash-table/README.md)] | Easy | | 290 | [单词规律](../../problems/word-pattern) | [[哈希表](../hash-table/README.md)] | Easy | | 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 274 | [H指数](../../problems/h-index) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 274 | [H 指数](../../problems/h-index) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 266 | [回文排列](../../problems/palindrome-permutation) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | | 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 246 | [中心对称数](../../problems/strobogrammatic-number) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | diff --git a/tag/sort/README.md b/tag/sort/README.md index 00a686712..02d67afd8 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -44,7 +44,7 @@ | 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | | 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 274 | [H指数](../../problems/h-index) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 274 | [H 指数](../../problems/h-index) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | | 252 | [会议室](../../problems/meeting-rooms) 🔒 | [[排序](../sort/README.md)] | Easy | | 242 | [有效的字母异位词](../../problems/valid-anagram) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/tree/README.md b/tag/tree/README.md index 7ae7fed66..8e5a8ad97 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -132,7 +132,7 @@ | 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 103 | [二叉树的锯齿形层次遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 102 | [二叉树的层次遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 102 | [二叉树的层序遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 100 | [相同的树](../../problems/same-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 99 | [恢复二叉搜索树](../../problems/recover-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | From 53f0c962b2676f3bf9b80cd464839bf1f283ecff Mon Sep 17 00:00:00 2001 From: Shuo Date: Fri, 3 Apr 2020 10:03:08 +0800 Subject: [PATCH 044/145] A: Increasing Decreasing String --- .../increasing_decreasing_string.go | 26 +++++++++++++ .../increasing_decreasing_string_test.go | 39 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 problems/increasing-decreasing-string/increasing_decreasing_string.go create mode 100644 problems/increasing-decreasing-string/increasing_decreasing_string_test.go diff --git a/problems/increasing-decreasing-string/increasing_decreasing_string.go b/problems/increasing-decreasing-string/increasing_decreasing_string.go new file mode 100644 index 000000000..9d939beb1 --- /dev/null +++ b/problems/increasing-decreasing-string/increasing_decreasing_string.go @@ -0,0 +1,26 @@ +package problem1370 + +func sortString(s string) string { + var m [26]int + for _, c := range s { + m[c-'a']++ + } + l := len(s) + ans := make([]byte, 0, l) + appendChar := func(c int) { + if m[c] > 0 { + m[c]-- + l-- + ans = append(ans, byte(c+'a')) + } + } + for l > 0 { + for i := 0; i <= 25; i++ { + appendChar(i) + } + for i := 25; i >= 0; i-- { + appendChar(i) + } + } + return string(ans) +} diff --git a/problems/increasing-decreasing-string/increasing_decreasing_string_test.go b/problems/increasing-decreasing-string/increasing_decreasing_string_test.go new file mode 100644 index 000000000..562fd3e14 --- /dev/null +++ b/problems/increasing-decreasing-string/increasing_decreasing_string_test.go @@ -0,0 +1,39 @@ +package problem1370 + +import "testing" + +type testType struct { + in string + want string +} + +func TestSortString(t *testing.T) { + tests := [...]testType{ + { + in: "aaaabbbbcccc", + want: "abccbaabccba", + }, + { + in: "rat", + want: "art", + }, + { + in: "leetcode", + want: "cdelotee", + }, + { + in: "ggggggg", + want: "ggggggg", + }, + { + in: "spo", + want: "ops", + }, + } + for _, tt := range tests { + got := sortString(tt.in) + if got != tt.want { + t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want) + } + } +} From 487b0d50c229e4bd2934c02eb7f3df094dcd03b8 Mon Sep 17 00:00:00 2001 From: Shuo Date: Sat, 4 Apr 2020 10:37:39 +0800 Subject: [PATCH 045/145] A: Remove Palindromic Subsequences --- .../remove_palindromic_subsequences.go | 13 +++++++ .../remove_palindromic_subsequences_test.go | 39 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 problems/remove-palindromic-subsequences/remove_palindromic_subsequences.go create mode 100644 problems/remove-palindromic-subsequences/remove_palindromic_subsequences_test.go diff --git a/problems/remove-palindromic-subsequences/remove_palindromic_subsequences.go b/problems/remove-palindromic-subsequences/remove_palindromic_subsequences.go new file mode 100644 index 000000000..4b96049a9 --- /dev/null +++ b/problems/remove-palindromic-subsequences/remove_palindromic_subsequences.go @@ -0,0 +1,13 @@ +package problem1332 + +func removePalindromeSub(s string) int { + if s == "" { + return 0 + } + for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 { + if s[i] != s[j] { + return 2 + } + } + return 1 +} diff --git a/problems/remove-palindromic-subsequences/remove_palindromic_subsequences_test.go b/problems/remove-palindromic-subsequences/remove_palindromic_subsequences_test.go new file mode 100644 index 000000000..d91a2bfff --- /dev/null +++ b/problems/remove-palindromic-subsequences/remove_palindromic_subsequences_test.go @@ -0,0 +1,39 @@ +package problem1332 + +import "testing" + +type testType struct { + in string + want int +} + +func TestRemovePalindromeSub(t *testing.T) { + tests := [...]testType{ + { + in: "ababa", + want: 1, + }, + { + in: "abb", + want: 2, + }, + { + in: "baabb", + want: 2, + }, + { + in: "", + want: 0, + }, + { + in: "aaabbbaaabbb", + want: 2, + }, + } + for _, tt := range tests { + got := removePalindromeSub(tt.in) + if got != tt.want { + t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want) + } + } +} From 5c3b4dd92d87ed8c320b5ded098376e462920b9c Mon Sep 17 00:00:00 2001 From: Shuo Date: Sat, 4 Apr 2020 10:57:06 +0800 Subject: [PATCH 046/145] Create go.yml --- .github/workflows/go.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 000000000..b66c0d719 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,34 @@ +name: Go + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Get dependencies + run: | + go get -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure + fi + + - name: Build + run: go build -v . From 7af862d7daf848b4cbe0aca37fa1a8ddb918f225 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 6 Apr 2020 16:50:29 +0800 Subject: [PATCH 047/145] A: new --- README.md | 11 ++- problems/add-binary/README.md | 9 ++ problems/capital-gainloss/README.md | 2 +- .../README.md | 73 +++++++++++++++ .../construct-k-palindrome-strings/README.md | 86 ++++++++++++++++++ problems/count-largest-group/README.md | 64 ++++++++++++++ .../README.md | 14 +++ .../mysql_schemas.sql | 17 ++++ problems/design-underground-system/README.md | 36 ++++++-- problems/find-all-good-strings/README.md | 2 +- problems/find-in-mountain-array/README.md | 4 +- problems/integer-replacement/README.md | 2 +- problems/longest-happy-string/README.md | 71 +++++++++++++++ .../README.md | 60 +++++++++++++ .../README.md | 80 +++++++++++++++++ problems/reducing-dishes/README.md | 74 ++++++++++++++++ problems/stone-game-iii/README.md | 88 +++++++++++++++++++ tag/README.md | 6 +- tag/array/README.md | 1 + tag/bit-manipulation/README.md | 1 + tag/dynamic-programming/README.md | 3 + tag/geometry/README.md | 1 + tag/greedy/README.md | 3 + tag/sort/README.md | 1 + tag/string/README.md | 1 + tag/tags.json | 10 +-- 26 files changed, 700 insertions(+), 20 deletions(-) create mode 100644 problems/circle-and-rectangle-overlapping/README.md create mode 100644 problems/construct-k-palindrome-strings/README.md create mode 100644 problems/count-largest-group/README.md create mode 100644 problems/customers-who-bought-products-a-and-b-but-not-c/README.md create mode 100644 problems/customers-who-bought-products-a-and-b-but-not-c/mysql_schemas.sql create mode 100644 problems/longest-happy-string/README.md create mode 100644 problems/minimum-subsequence-in-non-increasing-order/README.md create mode 100644 problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md create mode 100644 problems/reducing-dishes/README.md create mode 100644 problems/stone-game-iii/README.md diff --git a/README.md b/README.md index 19f651c0e..e863a47f5 100644 --- a/README.md +++ b/README.md @@ -62,11 +62,20 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1406 | [Stone Game III](https://leetcode.com/problems/stone-game-iii "石子游戏 III") | [Go](problems/stone-game-iii) | Hard | +| 1405 | [Longest Happy String](https://leetcode.com/problems/longest-happy-string "最长快乐字符串") | [Go](problems/longest-happy-string) | Medium | +| 1404 | [Number of Steps to Reduce a Number in Binary Representation to One](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one "将二进制表示减到 1 的步骤数") | [Go](problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | Medium | +| 1403 | [Minimum Subsequence in Non-Increasing Order](https://leetcode.com/problems/minimum-subsequence-in-non-increasing-order "非递增顺序的最小子序列") | [Go](problems/minimum-subsequence-in-non-increasing-order) | Easy | +| 1402 | [Reducing Dishes](https://leetcode.com/problems/reducing-dishes "做菜顺序") | [Go](problems/reducing-dishes) | Hard | +| 1401 | [Circle and Rectangle Overlapping](https://leetcode.com/problems/circle-and-rectangle-overlapping "圆和矩形是否有重叠") | [Go](problems/circle-and-rectangle-overlapping) | Medium | +| 1400 | [Construct K Palindrome Strings](https://leetcode.com/problems/construct-k-palindrome-strings "构造 K 个回文字符串") | [Go](problems/construct-k-palindrome-strings) | Medium | +| 1399 | [Count Largest Group](https://leetcode.com/problems/count-largest-group "统计最大组的数目") | [Go](problems/count-largest-group) | Easy | +| 1398 | [Customers Who Bought Products A and B but Not C](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c) 🔒 | [MySQL](problems/customers-who-bought-products-a-and-b-but-not-c) | Medium | | 1397 | [Find All Good Strings](https://leetcode.com/problems/find-all-good-strings "找到所有好字符串") | [Go](problems/find-all-good-strings) | Hard | | 1396 | [Design Underground System](https://leetcode.com/problems/design-underground-system "设计地铁系统") | [Go](problems/design-underground-system) | Medium | | 1395 | [Count Number of Teams](https://leetcode.com/problems/count-number-of-teams "统计作战单位数") | [Go](problems/count-number-of-teams) | Medium | | 1394 | [Find Lucky Integer in an Array](https://leetcode.com/problems/find-lucky-integer-in-an-array "找出数组中的幸运数") | [Go](problems/find-lucky-integer-in-an-array) | Easy | -| 1393 | [Capital Gain/Loss](https://leetcode.com/problems/capital-gainloss) 🔒 | [MySQL](problems/capital-gainloss) | Medium | +| 1393 | [Capital Gain/Loss](https://leetcode.com/problems/capital-gainloss "股票的资本损益") 🔒 | [MySQL](problems/capital-gainloss) | Medium | | 1392 | [Longest Happy Prefix](https://leetcode.com/problems/longest-happy-prefix "最长快乐前缀") | [Go](problems/longest-happy-prefix) | Hard | | 1391 | [Check if There is a Valid Path in a Grid](https://leetcode.com/problems/check-if-there-is-a-valid-path-in-a-grid "检查网格中是否存在有效路径") | [Go](problems/check-if-there-is-a-valid-path-in-a-grid) | Medium | | 1390 | [Four Divisors](https://leetcode.com/problems/four-divisors "四因数") | [Go](problems/four-divisors) | Medium | diff --git a/problems/add-binary/README.md b/problems/add-binary/README.md index 98b349191..072f50da0 100644 --- a/problems/add-binary/README.md +++ b/problems/add-binary/README.md @@ -27,6 +27,15 @@ Input: a = "1010", b = "1011" Output: "10101" +

     

    +

    Constraints:

    + +
      +
    • Each string consists only of '0' or '1' characters.
    • +
    • 1 <= a.length, b.length <= 10^4
    • +
    • Each string is either "0" or doesn't contain any leading zero.
    • +
    + ### Related Topics [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/capital-gainloss/README.md b/problems/capital-gainloss/README.md index bffd10d17..cd4960a2b 100644 --- a/problems/capital-gainloss/README.md +++ b/problems/capital-gainloss/README.md @@ -9,6 +9,6 @@                  [Next >](../find-lucky-integer-in-an-array "Find Lucky Integer in an Array") -## [1393. Capital Gain/Loss (Medium)](https://leetcode.com/problems/capital-gainloss "") +## [1393. Capital Gain/Loss (Medium)](https://leetcode.com/problems/capital-gainloss "股票的资本损益") diff --git a/problems/circle-and-rectangle-overlapping/README.md b/problems/circle-and-rectangle-overlapping/README.md new file mode 100644 index 000000000..405cf2a7e --- /dev/null +++ b/problems/circle-and-rectangle-overlapping/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../construct-k-palindrome-strings "Construct K Palindrome Strings") +                 +[Next >](../reducing-dishes "Reducing Dishes") + +## [1401. Circle and Rectangle Overlapping (Medium)](https://leetcode.com/problems/circle-and-rectangle-overlapping "圆和矩形是否有重叠") + +

    Given a circle represented as (radius, x_center, y_center) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the rectangle.

    + +

    Return True if the circle and rectangle are overlapped otherwise return False.

    + +

    In other words, check if there are any point (xi, yi) such that belongs to the circle and the rectangle at the same time.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: radius = 1, x_center = 0, y_center = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1
    +Output: true
    +Explanation: Circle and rectangle share the point (1,0) 
    +
    + +

    Example 2:

    + +

    + +
    +Input: radius = 1, x_center = 0, y_center = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1
    +Output: true
    +
    + +

    Example 3:

    + +

    + +
    +Input: radius = 1, x_center = 1, y_center = 1, x1 = -3, y1 = -3, x2 = 3, y2 = 3
    +Output: true
    +
    + +

    Example 4:

    + +
    +Input: radius = 1, x_center = 1, y_center = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1
    +Output: false
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= radius <= 2000
    • +
    • -10^4 <= x_center, y_center, x1, y1, x2, y2 <= 10^4
    • +
    • x1 < x2
    • +
    • y1 < y2
    • +
    + +### Related Topics + [[Geometry](../../tag/geometry/README.md)] + +### Hints +
    +Hint 1 +Locate the closest point of the square to the circle, you can then find the distance from this point to the center of the circle and check if this is less than or equal to the radius. +
    diff --git a/problems/construct-k-palindrome-strings/README.md b/problems/construct-k-palindrome-strings/README.md new file mode 100644 index 000000000..da1e88f7c --- /dev/null +++ b/problems/construct-k-palindrome-strings/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../count-largest-group "Count Largest Group") +                 +[Next >](../circle-and-rectangle-overlapping "Circle and Rectangle Overlapping") + +## [1400. Construct K Palindrome Strings (Medium)](https://leetcode.com/problems/construct-k-palindrome-strings "构造 K 个回文字符串") + +

    Given a string s and an integer k. You should construct k non-empty palindrome strings using all the characters in s.

    + +

    Return True if you can use all the characters in s to construct k palindrome strings or False otherwise.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "annabelle", k = 2
    +Output: true
    +Explanation: You can construct two palindromes using all characters in s.
    +Some possible constructions "anna" + "elble", "anbna" + "elle", "anellena" + "b"
    +
    + +

    Example 2:

    + +
    +Input: s = "leetcode", k = 3
    +Output: false
    +Explanation: It is impossible to construct 3 palindromes using all the characters of s.
    +
    + +

    Example 3:

    + +
    +Input: s = "true", k = 4
    +Output: true
    +Explanation: The only possible solution is to put each character in a separate string.
    +
    + +

    Example 4:

    + +
    +Input: s = "yzyzyzyzyzyzyzy", k = 2
    +Output: true
    +Explanation: Simply you can put all z's in one string and all y's in the other string. Both strings will be palindrome.
    +
    + +

    Example 5:

    + +
    +Input: s = "cr", k = 7
    +Output: false
    +Explanation: We don't have enough characters in s to construct 7 palindromes.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 10^5
    • +
    • All characters in s are lower-case English letters.
    • +
    • 1 <= k <= 10^5
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +If the s.length < k we cannot construct k strings from s and answer is false. +
    + +
    +Hint 2 +If the number of characters that have odd counts is > k then the minimum number of palindrome strings we can construct is > k and answer is false. +
    + +
    +Hint 3 +Otherwise you can construct exactly k palindrome strings and answer is true (why ?). +
    diff --git a/problems/count-largest-group/README.md b/problems/count-largest-group/README.md new file mode 100644 index 000000000..9035e595d --- /dev/null +++ b/problems/count-largest-group/README.md @@ -0,0 +1,64 @@ + + + + + + + +[< Previous](../customers-who-bought-products-a-and-b-but-not-c "Customers Who Bought Products A and B but Not C") +                 +[Next >](../construct-k-palindrome-strings "Construct K Palindrome Strings") + +## [1399. Count Largest Group (Easy)](https://leetcode.com/problems/count-largest-group "统计最大组的数目") + +

    Given an integer n. Each number from 1 to n is grouped according to the sum of its digits. 

    + +

    Return how many groups have the largest size.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 13
    +Output: 4
    +Explanation: There are 9 groups in total, they are grouped according sum of its digits of numbers from 1 to 13:
    +[1,10], [2,11], [3,12], [4,13], [5], [6], [7], [8], [9]. There are 4 groups with largest size.
    +
    + +

    Example 2:

    + +
    +Input: n = 2
    +Output: 2
    +Explanation: There are 2 groups [1], [2] of size 1.
    +
    + +

    Example 3:

    + +
    +Input: n = 15
    +Output: 6
    +
    + +

    Example 4:

    + +
    +Input: n = 24
    +Output: 5
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 10^4
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Count the digit sum for each integer in the range and find out the largest groups. +
    diff --git a/problems/customers-who-bought-products-a-and-b-but-not-c/README.md b/problems/customers-who-bought-products-a-and-b-but-not-c/README.md new file mode 100644 index 000000000..e434966cd --- /dev/null +++ b/problems/customers-who-bought-products-a-and-b-but-not-c/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../find-all-good-strings "Find All Good Strings") +                 +[Next >](../count-largest-group "Count Largest Group") + +## [1398. Customers Who Bought Products A and B but Not C (Medium)](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c "") + + diff --git a/problems/customers-who-bought-products-a-and-b-but-not-c/mysql_schemas.sql b/problems/customers-who-bought-products-a-and-b-but-not-c/mysql_schemas.sql new file mode 100644 index 000000000..a69fad8cb --- /dev/null +++ b/problems/customers-who-bought-products-a-and-b-but-not-c/mysql_schemas.sql @@ -0,0 +1,17 @@ +Create table If Not Exists Customers (customer_id int, customer_name varchar(30)); +Create table If Not Exists Orders (order_id int, customer_id int, product_name varchar(30)); +Truncate table Customers; +insert into Customers (customer_id, customer_name) values ('1', 'Daniel'); +insert into Customers (customer_id, customer_name) values ('2', 'Diana'); +insert into Customers (customer_id, customer_name) values ('3', 'Elizabeth'); +insert into Customers (customer_id, customer_name) values ('4', 'Jhon'); +Truncate table Orders; +insert into Orders (order_id, customer_id, product_name) values ('10', '1', 'A'); +insert into Orders (order_id, customer_id, product_name) values ('20', '1', 'B'); +insert into Orders (order_id, customer_id, product_name) values ('30', '1', 'D'); +insert into Orders (order_id, customer_id, product_name) values ('40', '1', 'C'); +insert into Orders (order_id, customer_id, product_name) values ('50', '2', 'A'); +insert into Orders (order_id, customer_id, product_name) values ('60', '3', 'A'); +insert into Orders (order_id, customer_id, product_name) values ('70', '3', 'B'); +insert into Orders (order_id, customer_id, product_name) values ('80', '3', 'D'); +insert into Orders (order_id, customer_id, product_name) values ('90', '4', 'C'); diff --git a/problems/design-underground-system/README.md b/problems/design-underground-system/README.md index e95e2a2d0..f834f1cad 100644 --- a/problems/design-underground-system/README.md +++ b/problems/design-underground-system/README.md @@ -38,14 +38,14 @@

     

    Example 1:

    +Input
    -Input
     ["UndergroundSystem","checkIn","checkIn","checkIn","checkOut","checkOut","checkOut","getAverageTime","getAverageTime","checkIn","getAverageTime","checkOut","getAverageTime"]
     [[],[45,"Leyton",3],[32,"Paradise",8],[27,"Leyton",10],[45,"Waterloo",15],[27,"Waterloo",20],[32,"Cambridge",22],["Paradise","Cambridge"],["Leyton","Waterloo"],[10,"Leyton",24],["Leyton","Waterloo"],[10,"Waterloo",38],["Leyton","Waterloo"]]
     
     Output
    -[null,null,null,null,null,null,null,14.0,11.0,null,11.0,null,12.0]
    +[null,null,null,null,null,null,null,14.00000,11.00000,null,11.00000,null,12.00000]
     
     Explanation
     UndergroundSystem undergroundSystem = new UndergroundSystem();
    @@ -55,12 +55,36 @@ undergroundSystem.checkIn(27, "Leyton", 10);
     undergroundSystem.checkOut(45, "Waterloo", 15);
     undergroundSystem.checkOut(27, "Waterloo", 20);
     undergroundSystem.checkOut(32, "Cambridge", 22);
    -undergroundSystem.getAverageTime("Paradise", "Cambridge");       // return 14.0. There was only one travel from "Paradise" (at time 8) to "Cambridge" (at time 22)
    -undergroundSystem.getAverageTime("Leyton", "Waterloo");          // return 11.0. There were two travels from "Leyton" to "Waterloo", a customer with id=45 from time=3 to time=15 and a customer with id=27 from time=10 to time=20. So the average time is ( (15-3) + (20-10) ) / 2 = 11.0
    +undergroundSystem.getAverageTime("Paradise", "Cambridge");       // return 14.00000. There was only one travel from "Paradise" (at time 8) to "Cambridge" (at time 22)
    +undergroundSystem.getAverageTime("Leyton", "Waterloo");          // return 11.00000. There were two travels from "Leyton" to "Waterloo", a customer with id=45 from time=3 to time=15 and a customer with id=27 from time=10 to time=20. So the average time is ( (15-3) + (20-10) ) / 2 = 11.00000
     undergroundSystem.checkIn(10, "Leyton", 24);
    -undergroundSystem.getAverageTime("Leyton", "Waterloo");          // return 11.0
    +undergroundSystem.getAverageTime("Leyton", "Waterloo");          // return 11.00000
     undergroundSystem.checkOut(10, "Waterloo", 38);
    -undergroundSystem.getAverageTime("Leyton", "Waterloo");          // return 12.0
    +undergroundSystem.getAverageTime("Leyton", "Waterloo");          // return 12.00000 + + +

    Example 2:

    +Input + +
    +["UndergroundSystem","checkIn","checkOut","getAverageTime","checkIn","checkOut","getAverageTime","checkIn","checkOut","getAverageTime"]
    +[[],[10,"Leyton",3],[10,"Paradise",8],["Leyton","Paradise"],[5,"Leyton",10],[5,"Paradise",16],["Leyton","Paradise"],[2,"Leyton",21],[2,"Paradise",30],["Leyton","Paradise"]]
    +
    +Output
    +[null,null,null,5.00000,null,null,5.50000,null,null,6.66667]
    +
    +Explanation
    +UndergroundSystem undergroundSystem = new UndergroundSystem();
    +undergroundSystem.checkIn(10, "Leyton", 3);
    +undergroundSystem.checkOut(10, "Paradise", 8);
    +undergroundSystem.getAverageTime("Leyton", "Paradise"); // return 5.00000
    +undergroundSystem.checkIn(5, "Leyton", 10);
    +undergroundSystem.checkOut(5, "Paradise", 16);
    +undergroundSystem.getAverageTime("Leyton", "Paradise"); // return 5.50000
    +undergroundSystem.checkIn(2, "Leyton", 21);
    +undergroundSystem.checkOut(2, "Paradise", 30);
    +undergroundSystem.getAverageTime("Leyton", "Paradise"); // return 6.66667
    +

     

    Constraints:

    diff --git a/problems/find-all-good-strings/README.md b/problems/find-all-good-strings/README.md index a81a4cfc5..d1f1b7e4b 100644 --- a/problems/find-all-good-strings/README.md +++ b/problems/find-all-good-strings/README.md @@ -7,7 +7,7 @@ [< Previous](../design-underground-system "Design Underground System")                  -Next > +[Next >](../customers-who-bought-products-a-and-b-but-not-c "Customers Who Bought Products A and B but Not C") ## [1397. Find All Good Strings (Hard)](https://leetcode.com/problems/find-all-good-strings "找到所有好字符串") diff --git a/problems/find-in-mountain-array/README.md b/problems/find-in-mountain-array/README.md index beb2a9ff2..9d531ae4d 100644 --- a/problems/find-in-mountain-array/README.md +++ b/problems/find-in-mountain-array/README.md @@ -58,11 +58,11 @@

     

    Constraints:

    -
      +
      • 3 <= mountain_arr.length() <= 10000
      • 0 <= target <= 10^9
      • 0 <= mountain_arr.get(index) <= 10^9
      • -
    + ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/integer-replacement/README.md b/problems/integer-replacement/README.md index db19d0243..a34ff2c94 100644 --- a/problems/integer-replacement/README.md +++ b/problems/integer-replacement/README.md @@ -57,5 +57,5 @@ or

    ### Related Topics - [[Math](../../tag/math/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/longest-happy-string/README.md b/problems/longest-happy-string/README.md new file mode 100644 index 000000000..6d94a5f68 --- /dev/null +++ b/problems/longest-happy-string/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../number-of-steps-to-reduce-a-number-in-binary-representation-to-one "Number of Steps to Reduce a Number in Binary Representation to One") +                 +[Next >](../stone-game-iii "Stone Game III") + +## [1405. Longest Happy String (Medium)](https://leetcode.com/problems/longest-happy-string "最长快乐字符串") + +

    A string is called happy if it does not have any of the strings 'aaa', 'bbb' or 'ccc' as a substring.

    + +

    Given three integers a, b and c, return any string s, which satisfies following conditions:

    + +
      +
    • s is happy and longest possible.
    • +
    • s contains at most a occurrences of the letter 'a', at most b occurrences of the letter 'b' and at most c occurrences of the letter 'c'.
    • +
    • will only contain 'a', 'b' and 'c' letters.
    • +
    + +

    If there is no such string s return the empty string "".

    + +

     

    +

    Example 1:

    + +
    +Input: a = 1, b = 1, c = 7
    +Output: "ccaccbcc"
    +Explanation: "ccbccacc" would also be a correct answer.
    +
    + +

    Example 2:

    + +
    +Input: a = 2, b = 2, c = 1
    +Output: "aabbc"
    +
    + +

    Example 3:

    + +
    +Input: a = 7, b = 1, c = 0
    +Output: "aabaa"
    +Explanation: It's the only correct answer in this case.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= a, b, c <= 100
    • +
    • a + b + c > 0
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Use a greedy approach. +
    + +
    +Hint 2 +Use the letter with the maximum current limit that can be added without breaking the condition. +
    diff --git a/problems/minimum-subsequence-in-non-increasing-order/README.md b/problems/minimum-subsequence-in-non-increasing-order/README.md new file mode 100644 index 000000000..93bfcbbba --- /dev/null +++ b/problems/minimum-subsequence-in-non-increasing-order/README.md @@ -0,0 +1,60 @@ + + + + + + + +[< Previous](../reducing-dishes "Reducing Dishes") +                 +[Next >](../number-of-steps-to-reduce-a-number-in-binary-representation-to-one "Number of Steps to Reduce a Number in Binary Representation to One") + +## [1403. Minimum Subsequence in Non-Increasing Order (Easy)](https://leetcode.com/problems/minimum-subsequence-in-non-increasing-order "非递增顺序的最小子序列") + +

    Given the array nums, obtain a subsequence of the array whose sum of elements is strictly greater than the sum of the non included elements in such subsequence. 

    + +

    If there are multiple solutions, return the subsequence with minimum size and if there still exist multiple solutions, return the subsequence with the maximum total sum of all its elements. A subsequence of an array can be obtained by erasing some (possibly zero) elements from the array. 

    + +

    Note that the solution with the given constraints is guaranteed to be unique. Also return the answer sorted in non-increasing order.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [4,3,10,9,8]
    +Output: [10,9] 
    +Explanation: The subsequences [10,9] and [10,8] are minimal such that the sum of their elements is strictly greater than the sum of elements not included, however, the subsequence [10,9] has the maximum total sum of its elements. 
    +
    + +

    Example 2:

    + +
    +Input: nums = [4,4,7,6,7]
    +Output: [7,7,6] 
    +Explanation: The subsequence [7,7] has the sum of its elements equal to 14 which is not strictly greater than the sum of elements not included (14 = 4 + 4 + 6). Therefore, the subsequence [7,6,7] is the minimal satisfying the conditions. Note the subsequence has to returned in non-decreasing order.  
    +
    + +

    Example 3:

    + +
    +Input: nums = [6]
    +Output: [6]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 500
    • +
    • 1 <= nums[i] <= 100
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Sort](../../tag/sort/README.md)] + +### Hints +
    +Hint 1 +Sort elements and take each element from the largest until accomplish the conditions. +
    diff --git a/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md b/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md new file mode 100644 index 000000000..287f5d23f --- /dev/null +++ b/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../minimum-subsequence-in-non-increasing-order "Minimum Subsequence in Non-Increasing Order") +                 +[Next >](../longest-happy-string "Longest Happy String") + +## [1404. Number of Steps to Reduce a Number in Binary Representation to One (Medium)](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one "将二进制表示减到 1 的步骤数") + +

    Given a number s in their binary representation. Return the number of steps to reduce it to 1 under the following rules:

    + +
      +
    • +

      If the current number is even, you have to divide it by 2.

      +
    • +
    • +

      If the current number is odd, you have to add 1 to it.

      +
    • +
    + +

    It's guaranteed that you can always reach to one for all testcases.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "1101"
    +Output: 6
    +Explanation: "1101" corressponds to number 13 in their decimal representation.
    +Step 1) 13 is odd, add 1 and obtain 14. 
    +Step 2) 14 is even, divide by 2 and obtain 7.
    +Step 3) 7 is odd, add 1 and obtain 8.
    +Step 4) 8 is even, divide by 2 and obtain 4.  
    +Step 5) 4 is even, divide by 2 and obtain 2. 
    +Step 6) 2 is even, divide by 2 and obtain 1.  
    +
    + +

    Example 2:

    + +
    +Input: s = "10"
    +Output: 1
    +Explanation: "10" corressponds to number 2 in their decimal representation.
    +Step 1) 2 is even, divide by 2 and obtain 1.  
    +
    + +

    Example 3:

    + +
    +Input: s = "1"
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 500
    • +
    • s consists of characters '0' or '1'
    • +
    • s[0] == '1'
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Read the string from right to left, if the string ends in '0' then the number is even otherwise it is odd. +
    + +
    +Hint 2 +Simulate the steps described in the binary string. +
    diff --git a/problems/reducing-dishes/README.md b/problems/reducing-dishes/README.md new file mode 100644 index 000000000..318b14ce1 --- /dev/null +++ b/problems/reducing-dishes/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../circle-and-rectangle-overlapping "Circle and Rectangle Overlapping") +                 +[Next >](../minimum-subsequence-in-non-increasing-order "Minimum Subsequence in Non-Increasing Order") + +## [1402. Reducing Dishes (Hard)](https://leetcode.com/problems/reducing-dishes "做菜顺序") + +

    A chef has collected data on the satisfaction level of his n dishes. Chef can cook any dish in 1 unit of time.

    + +

    Like-time coefficient of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its satisfaction level  i.e.  time[i]*satisfaction[i]

    + +

    Return the maximum sum of Like-time coefficient that the chef can obtain after dishes preparation.

    + +

    Dishes can be prepared in any order and the chef can discard some dishes to get this maximum value.

    + +

     

    +

    Example 1:

    + +
    +Input: satisfaction = [-1,-8,0,5,-9]
    +Output: 14
    +Explanation: After Removing the second and last dish, the maximum total Like-time coefficient will be equal to (-1*1 + 0*2 + 5*3 = 14). Each dish is prepared in one unit of time.
    + +

    Example 2:

    + +
    +Input: satisfaction = [4,3,2]
    +Output: 20
    +Explanation: Dishes can be prepared in any order, (2*1 + 3*2 + 4*3 = 20)
    +
    + +

    Example 3:

    + +
    +Input: satisfaction = [-1,-4,-5]
    +Output: 0
    +Explanation: People don't like the dishes. No dish is prepared.
    +
    + +

    Example 4:

    + +
    +Input: satisfaction = [-2,5,-1,0,3,-3]
    +Output: 35
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == satisfaction.length
    • +
    • 1 <= n <= 500
    • +
    • -10^3 <= satisfaction[i] <= 10^3
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Use dynamic programming to find the optimal solution by saving the previous best like-time coefficient and its corresponding element sum. +
    + +
    +Hint 2 +If adding the current element to the previous best like-time coefficient and its corresponding element sum would increase the best like-time coefficient, then go ahead and add it. Otherwise, keep the previous best like-time coefficient. +
    diff --git a/problems/stone-game-iii/README.md b/problems/stone-game-iii/README.md new file mode 100644 index 000000000..fcb7afd2a --- /dev/null +++ b/problems/stone-game-iii/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../longest-happy-string "Longest Happy String") +                 +Next > + +## [1406. Stone Game III (Hard)](https://leetcode.com/problems/stone-game-iii "石子游戏 III") + +

    Alice and Bob continue their games with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.

    + +

    Alice and Bob take turns, with Alice starting first. On each player's turn, that player can take 1, 2 or 3 stones from the first remaining stones in the row.

    + +

    The score of each player is the sum of values of the stones taken. The score of each player is 0 initially.

    + +

    The objective of the game is to end with the highest score, and the winner is the player with the highest score and there could be a tie. The game continues until all the stones have been taken.

    + +

    Assume Alice and Bob play optimally.

    + +

    Return "Alice" if Alice will win, "Bob" if Bob will win or "Tie" if they end the game with the same score.

    + +

     

    +

    Example 1:

    + +
    +Input: values = [1,2,3,7]
    +Output: "Bob"
    +Explanation: Alice will always lose. Her best move will be to take three piles and the score become 6. Now the score of Bob is 7 and Bob wins.
    +
    + +

    Example 2:

    + +
    +Input: values = [1,2,3,-9]
    +Output: "Alice"
    +Explanation: Alice must choose all the three piles at the first move to win and leave Bob with negative score.
    +If Alice chooses one pile her score will be 1 and the next move Bob's score becomes 5. The next move Alice will take the pile with value = -9 and lose.
    +If Alice chooses two piles her score will be 3 and the next move Bob's score becomes 3. The next move Alice will take the pile with value = -9 and also lose.
    +Remember that both play optimally so here Alice will choose the scenario that makes her win.
    +
    + +

    Example 3:

    + +
    +Input: values = [1,2,3,6]
    +Output: "Tie"
    +Explanation: Alice cannot win this game. She can end the game in a draw if she decided to choose all the first three piles, otherwise she will lose.
    +
    + +

    Example 4:

    + +
    +Input: values = [1,2,3,-1,-2,-3,7]
    +Output: "Alice"
    +
    + +

    Example 5:

    + +
    +Input: values = [-1,-2,-3]
    +Output: "Tie"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= values.length <= 50000
    • +
    • -1000 <= values[i] <= 1000
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +The game can be mapped to minmax game. Alex tries to maximize the total score and Lee tries to minimize it. +
    + +
    +Hint 2 +Use dynamic programming to simulate the game. If the total score was 0 the game is "Tie", and if it has positive value then "Alex" wins, otherwise "Lee" wins. +
    diff --git a/tag/README.md b/tag/README.md index 61fdd8818..854b8235f 100644 --- a/tag/README.md +++ b/tag/README.md @@ -23,9 +23,9 @@ | 23 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | | 25 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | | 27 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | -| 29 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 30 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | -| 31 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 32 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | -| 33 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 34 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | +| 29 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 30 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | +| 31 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | | 32 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | +| 33 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | | 34 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 35 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | | 37 | [Reservoir Sampling](reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | | 38 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | | 39 | [Memoization](memoization/README.md) | [记忆化](https://openset.github.io/tags/memoization/) | | 40 | [Suffix Array](suffix-array/README.md) | [Suffix Array](https://openset.github.io/tags/suffix-array/) | diff --git a/tag/array/README.md b/tag/array/README.md index 5023dc46d..6a3ad09e4 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1399 | [统计最大组的数目](../../problems/count-largest-group) | [[数组](../array/README.md)] | Easy | | 1395 | [统计作战单位数](../../problems/count-number-of-teams) | [[数组](../array/README.md)] | Medium | | 1394 | [找出数组中的幸运数](../../problems/find-lucky-integer-in-an-array) | [[数组](../array/README.md)] | Easy | | 1389 | [按既定顺序创建目标数组](../../problems/create-target-array-in-the-given-order) | [[数组](../array/README.md)] | Easy | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 1c8caef90..666decd3d 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1404 | [将二进制表示减到 1 的步骤数](../../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[排序](../sort/README.md)] [[位运算](../bit-manipulation/README.md)] | Easy | | 1342 | [将数字变成 0 的操作次数](../../problems/number-of-steps-to-reduce-a-number-to-zero) | [[位运算](../bit-manipulation/README.md)] | Easy | | 1318 | [或运算的最小翻转次数](../../problems/minimum-flips-to-make-a-or-b-equal-to-c) | [[位运算](../bit-manipulation/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 5827ea901..4ea035f8e 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1406 | [石子游戏 III](../../problems/stone-game-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1402 | [做菜顺序](../../problems/reducing-dishes) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1397 | [找到所有好字符串](../../problems/find-all-good-strings) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1388 | [3n 块披萨](../../problems/pizza-with-3n-slices) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index 444a2be36..1a0038d3e 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1401 | [圆和矩形是否有重叠](../../problems/circle-and-rectangle-overlapping) | [[几何](../geometry/README.md)] | Medium | | 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] | Easy | | 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 9f10119ea..4e436672e 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | +| 1400 | [构造 K 个回文字符串](../../problems/construct-k-palindrome-strings) | [[贪心算法](../greedy/README.md)] | Medium | | 1386 | [安排电影院座位](../../problems/cinema-seat-allocation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Hard | | 1354 | [多次求和构造目标数组](../../problems/construct-target-array-with-multiple-sums) | [[贪心算法](../greedy/README.md)] | Hard | diff --git a/tag/sort/README.md b/tag/sort/README.md index 02d67afd8..5b346163f 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | | 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | | 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Hard | | 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | diff --git a/tag/string/README.md b/tag/string/README.md index 200174778..c03bb0b56 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1404 | [将二进制表示减到 1 的步骤数](../../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1392 | [最长快乐前缀](../../problems/longest-happy-prefix) | [[字符串](../string/README.md)] | Hard | | 1374 | [生成每种字符都是奇数个的字符串](../../problems/generate-a-string-with-characters-that-have-odd-counts) | [[字符串](../string/README.md)] | Easy | | 1371 | [每个元音包含偶数次的最长子字符串](../../problems/find-the-longest-substring-containing-vowels-in-even-counts) | [[字符串](../string/README.md)] | Medium | diff --git a/tag/tags.json b/tag/tags.json index a6f7edc10..1f0b44a86 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -144,6 +144,11 @@ "Slug": "binary-indexed-tree", "TranslatedName": "树状数组" }, + { + "Name": "Geometry", + "Slug": "geometry", + "TranslatedName": "几何" + }, { "Name": "Line Sweep", "Slug": "line-sweep", @@ -164,11 +169,6 @@ "Slug": "brainteaser", "TranslatedName": "脑筋急转弯" }, - { - "Name": "Geometry", - "Slug": "geometry", - "TranslatedName": "几何" - }, { "Name": "Binary Search Tree", "Slug": "binary-search-tree", From 82be7a1186558a2278eb5c279951ce3c683a418a Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 6 Apr 2020 17:44:35 +0800 Subject: [PATCH 048/145] A: Count Largest Group --- .../count_largest_group.go | 21 +++++++++++ .../count_largest_group_test.go | 35 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 problems/count-largest-group/count_largest_group.go create mode 100644 problems/count-largest-group/count_largest_group_test.go diff --git a/problems/count-largest-group/count_largest_group.go b/problems/count-largest-group/count_largest_group.go new file mode 100644 index 000000000..ae012a3f8 --- /dev/null +++ b/problems/count-largest-group/count_largest_group.go @@ -0,0 +1,21 @@ +package problem1399 + +func countLargestGroup(n int) int { + group := make(map[int]int) + for i := 1; i <= n; i++ { + s := 0 + for x := i; x > 0; x /= 10 { + s += x % 10 + } + group[s]++ + } + ans, max := 0, 0 + for _, v := range group { + if v == max { + ans++ + } else if v > max { + ans, max = 1, v + } + } + return ans +} diff --git a/problems/count-largest-group/count_largest_group_test.go b/problems/count-largest-group/count_largest_group_test.go new file mode 100644 index 000000000..56bb1705c --- /dev/null +++ b/problems/count-largest-group/count_largest_group_test.go @@ -0,0 +1,35 @@ +package problem1399 + +import "testing" + +type testType struct { + in int + want int +} + +func TestCountLargestGroup(t *testing.T) { + tests := [...]testType{ + { + in: 13, + want: 4, + }, + { + in: 2, + want: 2, + }, + { + in: 15, + want: 6, + }, + { + in: 24, + want: 5, + }, + } + for _, tt := range tests { + got := countLargestGroup(tt.in) + if got != tt.want { + t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want) + } + } +} From f73081084c57f9e7df3bb25d389ade666d5eed29 Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 7 Apr 2020 12:53:53 +0800 Subject: [PATCH 049/145] A: Find Lucky Integer in an Array --- .../find_lucky_integer_in_an_array.go | 15 +++++++ .../find_lucky_integer_in_an_array_test.go | 39 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 problems/find-lucky-integer-in-an-array/find_lucky_integer_in_an_array.go create mode 100644 problems/find-lucky-integer-in-an-array/find_lucky_integer_in_an_array_test.go diff --git a/problems/find-lucky-integer-in-an-array/find_lucky_integer_in_an_array.go b/problems/find-lucky-integer-in-an-array/find_lucky_integer_in_an_array.go new file mode 100644 index 000000000..26e83d6dd --- /dev/null +++ b/problems/find-lucky-integer-in-an-array/find_lucky_integer_in_an_array.go @@ -0,0 +1,15 @@ +package problem1394 + +func findLucky(arr []int) int { + m := make(map[int]int) + for _, v := range arr { + m[v]++ + } + ans, max := -1, 0 + for k, v := range m { + if k > max && k == v { + ans, max = k, v + } + } + return ans +} diff --git a/problems/find-lucky-integer-in-an-array/find_lucky_integer_in_an_array_test.go b/problems/find-lucky-integer-in-an-array/find_lucky_integer_in_an_array_test.go new file mode 100644 index 000000000..bf75d1b17 --- /dev/null +++ b/problems/find-lucky-integer-in-an-array/find_lucky_integer_in_an_array_test.go @@ -0,0 +1,39 @@ +package problem1394 + +import "testing" + +type testType struct { + in []int + want int +} + +func TestFindLucky(t *testing.T) { + tests := [...]testType{ + { + in: []int{2, 2, 3, 4}, + want: 2, + }, + { + in: []int{1, 2, 2, 3, 3, 3}, + want: 3, + }, + { + in: []int{2, 2, 2, 3, 3}, + want: -1, + }, + { + in: []int{5}, + want: -1, + }, + { + in: []int{7, 7, 7, 7, 7, 7, 7}, + want: 7, + }, + } + for _, tt := range tests { + got := findLucky(tt.in) + if got != tt.want { + t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want) + } + } +} From 32d904c9eaf4e32e7c78b21e9515161506248767 Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 8 Apr 2020 10:00:15 +0800 Subject: [PATCH 050/145] A: Create Target Array in the Given Order --- .../create_target_array_in_the_given_order.go | 10 +++++ ...te_target_array_in_the_given_order_test.go | 38 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 problems/create-target-array-in-the-given-order/create_target_array_in_the_given_order.go create mode 100644 problems/create-target-array-in-the-given-order/create_target_array_in_the_given_order_test.go diff --git a/problems/create-target-array-in-the-given-order/create_target_array_in_the_given_order.go b/problems/create-target-array-in-the-given-order/create_target_array_in_the_given_order.go new file mode 100644 index 000000000..cf70a3f4a --- /dev/null +++ b/problems/create-target-array-in-the-given-order/create_target_array_in_the_given_order.go @@ -0,0 +1,10 @@ +package problem1389 + +func createTargetArray(nums []int, index []int) []int { + ans := make([]int, len(nums)) + for i, idx := range index { + copy(ans[idx+1:], ans[idx:]) + ans[idx] = nums[i] + } + return ans +} diff --git a/problems/create-target-array-in-the-given-order/create_target_array_in_the_given_order_test.go b/problems/create-target-array-in-the-given-order/create_target_array_in_the_given_order_test.go new file mode 100644 index 000000000..8fa361251 --- /dev/null +++ b/problems/create-target-array-in-the-given-order/create_target_array_in_the_given_order_test.go @@ -0,0 +1,38 @@ +package problem1389 + +import ( + "reflect" + "testing" +) + +type testType struct { + in []int + index []int + want []int +} + +func TestCreateTargetArray(t *testing.T) { + tests := [...]testType{ + { + in: []int{0, 1, 2, 3, 4}, + index: []int{0, 1, 2, 2, 1}, + want: []int{0, 4, 1, 3, 2}, + }, + { + in: []int{1, 2, 3, 4, 0}, + index: []int{0, 1, 2, 3, 0}, + want: []int{0, 1, 2, 3, 4}, + }, + { + in: []int{1}, + index: []int{0}, + want: []int{1}, + }, + } + for _, tt := range tests { + got := createTargetArray(tt.in, tt.index) + if !reflect.DeepEqual(got, tt.want) { + t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want) + } + } +} From 4c914e90eef1aee8a66c9452f4aa5748c02f9c37 Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 8 Apr 2020 14:10:32 +0800 Subject: [PATCH 051/145] A: Merge k Sorted Lists --- problems/merge-k-sorted-lists/README.md | 2 +- .../merge_k_sorted_lists.go | 33 ++++++++++++ .../merge_k_sorted_lists_test.go | 50 +++++++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) diff --git a/problems/merge-k-sorted-lists/README.md b/problems/merge-k-sorted-lists/README.md index 28fc7a4fc..2f4e64b81 100644 --- a/problems/merge-k-sorted-lists/README.md +++ b/problems/merge-k-sorted-lists/README.md @@ -26,9 +26,9 @@ ### Related Topics - [[Heap](../../tag/heap/README.md)] [[Linked List](../../tag/linked-list/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Heap](../../tag/heap/README.md)] ### Similar Questions 1. [Merge Two Sorted Lists](../merge-two-sorted-lists) (Easy) diff --git a/problems/merge-k-sorted-lists/merge_k_sorted_lists.go b/problems/merge-k-sorted-lists/merge_k_sorted_lists.go index c69fad2c0..25d1dc230 100644 --- a/problems/merge-k-sorted-lists/merge_k_sorted_lists.go +++ b/problems/merge-k-sorted-lists/merge_k_sorted_lists.go @@ -1 +1,34 @@ package problem23 + +import "github.com/openset/leetcode/internal/kit" + +// ListNode - Definition for singly-linked list. +type ListNode = kit.ListNode + +/** + * Definition for singly-linked list. + * type ListNode struct { + * Val int + * Next *ListNode + * } + */ +func mergeKLists(lists []*ListNode) *ListNode { + var ans *ListNode + for _, l := range lists { + ans = mergeTwoLists(ans, l) + } + return ans +} + +func mergeTwoLists(l1 *ListNode, l2 *ListNode) *ListNode { + if l1 == nil { + return l2 + } else if l2 == nil { + return l1 + } + if l1.Val > l2.Val { + l1, l2 = l2, l1 + } + l1.Next = mergeTwoLists(l1.Next, l2) + return l1 +} diff --git a/problems/merge-k-sorted-lists/merge_k_sorted_lists_test.go b/problems/merge-k-sorted-lists/merge_k_sorted_lists_test.go index c69fad2c0..47f574d2b 100644 --- a/problems/merge-k-sorted-lists/merge_k_sorted_lists_test.go +++ b/problems/merge-k-sorted-lists/merge_k_sorted_lists_test.go @@ -1 +1,51 @@ package problem23 + +import ( + "reflect" + "testing" + + "github.com/openset/leetcode/internal/kit" +) + +type testType struct { + in [][]int + want []int +} + +func TestMergeKLists(t *testing.T) { + tests := [...]testType{ + { + in: [][]int{ + {1, 4, 5}, + {1, 3, 4}, + {2, 6}, + }, + want: []int{1, 1, 2, 3, 4, 4, 5, 6}, + }, + { + in: [][]int{ + {2}, + {}, + {-1}, + }, + want: []int{-1, 2}, + }, + { + in: [][]int{ + {}, + {}, + }, + want: nil, + }, + } + for _, tt := range tests { + lists := make([]*ListNode, len(tt.in)) + for i, v := range tt.in { + lists[i] = kit.SliceInt2ListNode(v) + } + got := kit.ListNode2SliceInt(mergeKLists(lists)) + if !reflect.DeepEqual(got, tt.want) { + t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want) + } + } +} From 4bcee43a6542c2cd003232acce8e86a8b29fee28 Mon Sep 17 00:00:00 2001 From: Shuo Date: Sun, 12 Apr 2020 18:11:42 +0800 Subject: [PATCH 052/145] A: new --- README.md | 9 +- .../README.md | 10 ++- .../README.md | 2 +- problems/fizz-buzz/README.md | 3 + problems/happy-number/README.md | 6 +- problems/html-entity-parser/README.md | 89 +++++++++++++++++++ problems/last-stone-weight/README.md | 4 +- problems/merge-k-sorted-lists/README.md | 2 +- .../README.md | 79 ++++++++++++++++ .../README.md | 72 +++++++++++++++ problems/rotting-oranges/README.md | 2 +- problems/stone-game-iii/README.md | 2 +- .../string-matching-in-an-array/README.md | 60 +++++++++++++ problems/symmetric-tree/README.md | 3 +- problems/top-travellers/README.md | 14 +++ problems/top-travellers/mysql_schemas.sql | 20 +++++ problems/walls-and-gates/README.md | 2 +- tag/array/README.md | 1 + tag/binary-search/README.md | 85 ++++++++++++++++++ tag/breadth-first-search/README.md | 2 +- tag/design/README.md | 37 ++++++++ tag/dynamic-programming/README.md | 1 + tag/stack/README.md | 1 + tag/string/README.md | 2 + tag/two-pointers/README.md | 60 +++++++++++++ 25 files changed, 553 insertions(+), 15 deletions(-) create mode 100644 problems/html-entity-parser/README.md create mode 100644 problems/number-of-ways-to-paint-n-3-grid/README.md create mode 100644 problems/queries-on-a-permutation-with-key/README.md create mode 100644 problems/string-matching-in-an-array/README.md create mode 100644 problems/top-travellers/README.md create mode 100644 problems/top-travellers/mysql_schemas.sql diff --git a/README.md b/README.md index e863a47f5..6f051c931 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,11 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1411 | [Number of Ways to Paint N × 3 Grid](https://leetcode.com/problems/number-of-ways-to-paint-n-3-grid "给 N x 3 网格图涂色的方案数") | [Go](problems/number-of-ways-to-paint-n-3-grid) | Hard | +| 1410 | [HTML Entity Parser](https://leetcode.com/problems/html-entity-parser "HTML 实体解析器") | [Go](problems/html-entity-parser) | Medium | +| 1409 | [Queries on a Permutation With Key](https://leetcode.com/problems/queries-on-a-permutation-with-key "查询带键的排列") | [Go](problems/queries-on-a-permutation-with-key) | Medium | +| 1408 | [String Matching in an Array](https://leetcode.com/problems/string-matching-in-an-array "数组中的字符串匹配") | [Go](problems/string-matching-in-an-array) | Easy | +| 1407 | [Top Travellers](https://leetcode.com/problems/top-travellers) 🔒 | [MySQL](problems/top-travellers) | Easy | | 1406 | [Stone Game III](https://leetcode.com/problems/stone-game-iii "石子游戏 III") | [Go](problems/stone-game-iii) | Hard | | 1405 | [Longest Happy String](https://leetcode.com/problems/longest-happy-string "最长快乐字符串") | [Go](problems/longest-happy-string) | Medium | | 1404 | [Number of Steps to Reduce a Number in Binary Representation to One](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one "将二进制表示减到 1 的步骤数") | [Go](problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | Medium | @@ -70,7 +75,7 @@ LeetCode Problems' Solutions | 1401 | [Circle and Rectangle Overlapping](https://leetcode.com/problems/circle-and-rectangle-overlapping "圆和矩形是否有重叠") | [Go](problems/circle-and-rectangle-overlapping) | Medium | | 1400 | [Construct K Palindrome Strings](https://leetcode.com/problems/construct-k-palindrome-strings "构造 K 个回文字符串") | [Go](problems/construct-k-palindrome-strings) | Medium | | 1399 | [Count Largest Group](https://leetcode.com/problems/count-largest-group "统计最大组的数目") | [Go](problems/count-largest-group) | Easy | -| 1398 | [Customers Who Bought Products A and B but Not C](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c) 🔒 | [MySQL](problems/customers-who-bought-products-a-and-b-but-not-c) | Medium | +| 1398 | [Customers Who Bought Products A and B but Not C](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c "购买了产品A和产品B却没有购买产品C的顾客") 🔒 | [MySQL](problems/customers-who-bought-products-a-and-b-but-not-c) | Medium | | 1397 | [Find All Good Strings](https://leetcode.com/problems/find-all-good-strings "找到所有好字符串") | [Go](problems/find-all-good-strings) | Hard | | 1396 | [Design Underground System](https://leetcode.com/problems/design-underground-system "设计地铁系统") | [Go](problems/design-underground-system) | Medium | | 1395 | [Count Number of Teams](https://leetcode.com/problems/count-number-of-teams "统计作战单位数") | [Go](problems/count-number-of-teams) | Medium | @@ -474,7 +479,7 @@ LeetCode Problems' Solutions | 997 | [Find the Town Judge](https://leetcode.com/problems/find-the-town-judge "找到小镇的法官") | [Go](problems/find-the-town-judge) | Easy | | 996 | [Number of Squareful Arrays](https://leetcode.com/problems/number-of-squareful-arrays "正方形数组的数目") | [Go](problems/number-of-squareful-arrays) | Hard | | 995 | [Minimum Number of K Consecutive Bit Flips](https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips "K 连续位的最小翻转次数") | [Go](problems/minimum-number-of-k-consecutive-bit-flips) | Hard | -| 994 | [Rotting Oranges](https://leetcode.com/problems/rotting-oranges "腐烂的橘子") | [Go](problems/rotting-oranges) | Easy | +| 994 | [Rotting Oranges](https://leetcode.com/problems/rotting-oranges "腐烂的橘子") | [Go](problems/rotting-oranges) | Medium | | 993 | [Cousins in Binary Tree](https://leetcode.com/problems/cousins-in-binary-tree "二叉树的堂兄弟节点") | [Go](problems/cousins-in-binary-tree) | Easy | | 992 | [Subarrays with K Different Integers](https://leetcode.com/problems/subarrays-with-k-different-integers "K 个不同整数的子数组") | [Go](problems/subarrays-with-k-different-integers) | Hard | | 991 | [Broken Calculator](https://leetcode.com/problems/broken-calculator "坏了的计算器") | [Go](problems/broken-calculator) | Medium | diff --git a/problems/best-time-to-buy-and-sell-stock-ii/README.md b/problems/best-time-to-buy-and-sell-stock-ii/README.md index 48e05d027..ab394120d 100644 --- a/problems/best-time-to-buy-and-sell-stock-ii/README.md +++ b/problems/best-time-to-buy-and-sell-stock-ii/README.md @@ -11,7 +11,7 @@ ## [122. Best Time to Buy and Sell Stock II (Easy)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii "买卖股票的最佳时机 II") -

    Say you have an array for which the ith element is the price of a given stock on day i.

    +

    Say you have an array prices for which the ith element is the price of a given stock on day i.

    Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times).

    @@ -43,6 +43,14 @@ Output: 0 Explanation: In this case, no transaction is done, i.e. max profit = 0. +

     

    +

    Constraints:

    + +
      +
    • 1 <= prices.length <= 3 * 10 ^ 4
    • +
    • 0 <= prices[i] <= 10 ^ 4
    • +
    + ### Related Topics [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] diff --git a/problems/customers-who-bought-products-a-and-b-but-not-c/README.md b/problems/customers-who-bought-products-a-and-b-but-not-c/README.md index e434966cd..cf518607c 100644 --- a/problems/customers-who-bought-products-a-and-b-but-not-c/README.md +++ b/problems/customers-who-bought-products-a-and-b-but-not-c/README.md @@ -9,6 +9,6 @@                  [Next >](../count-largest-group "Count Largest Group") -## [1398. Customers Who Bought Products A and B but Not C (Medium)](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c "") +## [1398. Customers Who Bought Products A and B but Not C (Medium)](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c "购买了产品A和产品B却没有购买产品C的顾客") diff --git a/problems/fizz-buzz/README.md b/problems/fizz-buzz/README.md index cae237242..89105359b 100644 --- a/problems/fizz-buzz/README.md +++ b/problems/fizz-buzz/README.md @@ -39,3 +39,6 @@ Return: ]

    + +### Similar Questions + 1. [Fizz Buzz Multithreaded](../fizz-buzz-multithreaded) (Medium) diff --git a/problems/happy-number/README.md b/problems/happy-number/README.md index b1cf88483..5c6fe7fc3 100644 --- a/problems/happy-number/README.md +++ b/problems/happy-number/README.md @@ -11,9 +11,11 @@ ## [202. Happy Number (Easy)](https://leetcode.com/problems/happy-number "快乐数") -

    Write an algorithm to determine if a number is "happy".

    +

    Write an algorithm to determine if a number n is "happy".

    -

    A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers.

    +

    A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers.

    + +

    Return True if n is a happy number, and False if not.

    Example: 

    diff --git a/problems/html-entity-parser/README.md b/problems/html-entity-parser/README.md new file mode 100644 index 000000000..580a68168 --- /dev/null +++ b/problems/html-entity-parser/README.md @@ -0,0 +1,89 @@ + + + + + + + +[< Previous](../queries-on-a-permutation-with-key "Queries on a Permutation With Key") +                 +[Next >](../number-of-ways-to-paint-n-3-grid "Number of Ways to Paint N × 3 Grid") + +## [1410. HTML Entity Parser (Medium)](https://leetcode.com/problems/html-entity-parser "HTML 实体解析器") + +

    HTML entity parser is the parser that takes HTML code as input and replace all the entities of the special characters by the characters itself.

    + +

    The special characters and their entities for HTML are:

    + +
      +
    • Quotation Mark: the entity is &quot; and symbol character is ".
    • +
    • Single Quote Mark: the entity is &apos; and symbol character is '.
    • +
    • Ampersand: the entity is &amp; and symbol character is &.
    • +
    • Greater Than Sign: the entity is &gt; and symbol character is >.
    • +
    • Less Than Sign: the entity is &lt; and symbol character is <.
    • +
    • Slash: the entity is &frasl; and symbol character is /.
    • +
    + +

    Given the input text string to the HTML parser, you have to implement the entity parser.

    + +

    Return the text after replacing the entities by the special characters.

    + +

     

    +

    Example 1:

    + +
    +Input: text = "&amp; is an HTML entity but &ambassador; is not."
    +Output: "& is an HTML entity but &ambassador; is not."
    +Explanation: The parser will replace the &amp; entity by &
    +
    + +

    Example 2:

    + +
    +Input: text = "and I quote: &quot;...&quot;"
    +Output: "and I quote: \"...\""
    +
    + +

    Example 3:

    + +
    +Input: text = "Stay home! Practice on Leetcode :)"
    +Output: "Stay home! Practice on Leetcode :)"
    +
    + +

    Example 4:

    + +
    +Input: text = "x &gt; y &amp;&amp; x &lt; y is always false"
    +Output: "x > y && x < y is always false"
    +
    + +

    Example 5:

    + +
    +Input: text = "leetcode.com&frasl;problemset&frasl;all"
    +Output: "leetcode.com/problemset/all"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= text.length <= 10^5
    • +
    • The string may contain any possible characters out of all the 256 ASCII characters.
    • +
    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Search the string for all the occurrences of the character '&'. +
    + +
    +Hint 2 +For every '&' check if it matches an HTML entity by checking the ';' character and if entity found replace it in the answer. +
    diff --git a/problems/last-stone-weight/README.md b/problems/last-stone-weight/README.md index b45df5262..06263254a 100644 --- a/problems/last-stone-weight/README.md +++ b/problems/last-stone-weight/README.md @@ -11,9 +11,9 @@ ## [1046. Last Stone Weight (Easy)](https://leetcode.com/problems/last-stone-weight "最后一块石头的重量") -

    We have a collection of rocks, each rock has a positive integer weight.

    +

    We have a collection of stones, each stone has a positive integer weight.

    -

    Each turn, we choose the two heaviest rocks and smash them together.  Suppose the stones have weights x and y with x <= y.  The result of this smash is:

    +

    Each turn, we choose the two heaviest stones and smash them together.  Suppose the stones have weights x and y with x <= y.  The result of this smash is:

    • If x == y, both stones are totally destroyed;
    • diff --git a/problems/merge-k-sorted-lists/README.md b/problems/merge-k-sorted-lists/README.md index 2f4e64b81..28fc7a4fc 100644 --- a/problems/merge-k-sorted-lists/README.md +++ b/problems/merge-k-sorted-lists/README.md @@ -26,9 +26,9 @@ ### Related Topics + [[Heap](../../tag/heap/README.md)] [[Linked List](../../tag/linked-list/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] - [[Heap](../../tag/heap/README.md)] ### Similar Questions 1. [Merge Two Sorted Lists](../merge-two-sorted-lists) (Easy) diff --git a/problems/number-of-ways-to-paint-n-3-grid/README.md b/problems/number-of-ways-to-paint-n-3-grid/README.md new file mode 100644 index 000000000..c04492978 --- /dev/null +++ b/problems/number-of-ways-to-paint-n-3-grid/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../html-entity-parser "HTML Entity Parser") +                 +Next > + +## [1411. Number of Ways to Paint N × 3 Grid (Hard)](https://leetcode.com/problems/number-of-ways-to-paint-n-3-grid "给 N x 3 网格图涂色的方案数") + +

      You have a grid of size n x 3 and you want to paint each cell of the grid with exactly one of the three colours: Red, Yellow or Green while making sure that no two adjacent cells have the same colour (i.e no two cells that share vertical or horizontal sides have the same colour).

      + +

      You are given n the number of rows of the grid.

      + +

      Return the number of ways you can paint this grid. As the answer may grow large, the answer must be computed modulo 10^9 + 7.

      + +

       

      +

      Example 1:

      + +
      +Input: n = 1
      +Output: 12
      +Explanation: There are 12 possible way to paint the grid as shown:
      +
      +
      + +

      Example 2:

      + +
      +Input: n = 2
      +Output: 54
      +
      + +

      Example 3:

      + +
      +Input: n = 3
      +Output: 246
      +
      + +

      Example 4:

      + +
      +Input: n = 7
      +Output: 106494
      +
      + +

      Example 5:

      + +
      +Input: n = 5000
      +Output: 30228214
      +
      + +

       

      +

      Constraints:

      + +
        +
      • n == grid.length
      • +
      • grid[i].length == 3
      • +
      • 1 <= n <= 5000
      • +
      + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
      +Hint 1 +We will use Dynamic programming approach. we will try all possible configuration. +
      + +
      +Hint 2 +Let dp[idx][prev1col][prev2col][prev3col] be the number of ways to color the rows of the grid from idx to n-1 keeping in mind that the previous row (idx - 1) has colors prev1col, prev2col and prev3col. Build the dp array to get the answer. +
      diff --git a/problems/queries-on-a-permutation-with-key/README.md b/problems/queries-on-a-permutation-with-key/README.md new file mode 100644 index 000000000..7db1e71a3 --- /dev/null +++ b/problems/queries-on-a-permutation-with-key/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../string-matching-in-an-array "String Matching in an Array") +                 +[Next >](../html-entity-parser "HTML Entity Parser") + +## [1409. Queries on a Permutation With Key (Medium)](https://leetcode.com/problems/queries-on-a-permutation-with-key "查询带键的排列") + +

      Given the array queries of positive integers between 1 and m, you have to process all queries[i] (from i=0 to i=queries.length-1) according to the following rules:

      + +
        +
      • In the beginning, you have the permutation P=[1,2,3,...,m].
      • +
      • For the current i, find the position of queries[i] in the permutation P (indexing from 0) and then move this at the beginning of the permutation P. Notice that the position of queries[i] in P is the result for queries[i].
      • +
      + +

      Return an array containing the result for the given queries.

      + +

       

      +

      Example 1:

      + +
      +Input: queries = [3,1,2,1], m = 5
      +Output: [2,1,2,1] 
      +Explanation: The queries are processed as follow: 
      +For i=0: queries[i]=3, P=[1,2,3,4,5], position of 3 in P is 2, then we move 3 to the beginning of P resulting in P=[3,1,2,4,5]. 
      +For i=1: queries[i]=1, P=[3,1,2,4,5], position of 1 in P is 1, then we move 1 to the beginning of P resulting in P=[1,3,2,4,5]. 
      +For i=2: queries[i]=2, P=[1,3,2,4,5], position of 2 in P is 2, then we move 2 to the beginning of P resulting in P=[2,1,3,4,5]. 
      +For i=3: queries[i]=1, P=[2,1,3,4,5], position of 1 in P is 1, then we move 1 to the beginning of P resulting in P=[1,2,3,4,5]. 
      +Therefore, the array containing the result is [2,1,2,1].  
      +
      + +

      Example 2:

      + +
      +Input: queries = [4,1,2,2], m = 4
      +Output: [3,1,2,0]
      +
      + +

      Example 3:

      + +
      +Input: queries = [7,5,5,8,3], m = 8
      +Output: [6,5,0,7,5]
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= m <= 10^3
      • +
      • 1 <= queries.length <= m
      • +
      • 1 <= queries[i] <= m
      • +
      + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
      +Hint 1 +Create the permutation P=[1,2,...,m], it could be a list for example. +
      + +
      +Hint 2 +For each i, find the position of queries[i] with a simple scan over P and then move this to the beginning. +
      diff --git a/problems/rotting-oranges/README.md b/problems/rotting-oranges/README.md index 29d01483d..2713cf07f 100644 --- a/problems/rotting-oranges/README.md +++ b/problems/rotting-oranges/README.md @@ -9,7 +9,7 @@                  [Next >](../minimum-number-of-k-consecutive-bit-flips "Minimum Number of K Consecutive Bit Flips") -## [994. Rotting Oranges (Easy)](https://leetcode.com/problems/rotting-oranges "腐烂的橘子") +## [994. Rotting Oranges (Medium)](https://leetcode.com/problems/rotting-oranges "腐烂的橘子")

      In a given grid, each cell can have one of three values:

      diff --git a/problems/stone-game-iii/README.md b/problems/stone-game-iii/README.md index fcb7afd2a..f57b22440 100644 --- a/problems/stone-game-iii/README.md +++ b/problems/stone-game-iii/README.md @@ -7,7 +7,7 @@ [< Previous](../longest-happy-string "Longest Happy String")                  -Next > +[Next >](../top-travellers "Top Travellers") ## [1406. Stone Game III (Hard)](https://leetcode.com/problems/stone-game-iii "石子游戏 III") diff --git a/problems/string-matching-in-an-array/README.md b/problems/string-matching-in-an-array/README.md new file mode 100644 index 000000000..5f341db53 --- /dev/null +++ b/problems/string-matching-in-an-array/README.md @@ -0,0 +1,60 @@ + + + + + + + +[< Previous](../top-travellers "Top Travellers") +                 +[Next >](../queries-on-a-permutation-with-key "Queries on a Permutation With Key") + +## [1408. String Matching in an Array (Easy)](https://leetcode.com/problems/string-matching-in-an-array "数组中的字符串匹配") + +

      Given an array of string words. Return all strings in words which is substring of another word in any order. 

      + +

      String words[i] is substring of words[j], if can be obtained removing some characters to left and/or right side of words[j].

      + +

       

      +

      Example 1:

      + +
      +Input: words = ["mass","as","hero","superhero"]
      +Output: ["as","hero"]
      +Explanation: "as" is substring of "mass" and "hero" is substring of "superhero".
      +["hero","as"] is also a valid answer.
      +
      + +

      Example 2:

      + +
      +Input: words = ["leetcode","et","code"]
      +Output: ["et","code"]
      +Explanation: "et", "code" are substring of "leetcode".
      +
      + +

      Example 3:

      + +
      +Input: words = ["blue","green","bu"]
      +Output: []
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= words.length <= 100
      • +
      • 1 <= words[i].length <= 30
      • +
      • words[i] contains only lowercase English letters.
      • +
      • It's guaranteed that words[i] will be unique.
      • +
      + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
      +Hint 1 +Bruteforce to find if one string is substring of another or use KMP algorithm. +
      diff --git a/problems/symmetric-tree/README.md b/problems/symmetric-tree/README.md index f3ddf815e..31daa7e32 100644 --- a/problems/symmetric-tree/README.md +++ b/problems/symmetric-tree/README.md @@ -37,8 +37,7 @@

       

      -

      Note:
      -Bonus points if you could solve it both recursively and iteratively.

      +

      Follow up: Solve it both recursively and iteratively.

      ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/top-travellers/README.md b/problems/top-travellers/README.md new file mode 100644 index 000000000..57fc5d75e --- /dev/null +++ b/problems/top-travellers/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../stone-game-iii "Stone Game III") +                 +[Next >](../string-matching-in-an-array "String Matching in an Array") + +## [1407. Top Travellers (Easy)](https://leetcode.com/problems/top-travellers "") + + diff --git a/problems/top-travellers/mysql_schemas.sql b/problems/top-travellers/mysql_schemas.sql new file mode 100644 index 000000000..4d1dbe7da --- /dev/null +++ b/problems/top-travellers/mysql_schemas.sql @@ -0,0 +1,20 @@ +Create Table If Not Exists Users (id int, name varchar(30)); +Create Table If Not Exists Rides (id int, user_id int, distance int); +Truncate table Users; +insert into Users (id, name) values ('1', 'Alice'); +insert into Users (id, name) values ('2', 'Bob'); +insert into Users (id, name) values ('3', 'Alex'); +insert into Users (id, name) values ('4', 'Donald'); +insert into Users (id, name) values ('7', 'Lee'); +insert into Users (id, name) values ('13', 'Jonathan'); +insert into Users (id, name) values ('19', 'Elvis'); +Truncate table Rides; +insert into Rides (id, user_id, distance) values ('1', '1', '120'); +insert into Rides (id, user_id, distance) values ('2', '2', '317'); +insert into Rides (id, user_id, distance) values ('3', '3', '222'); +insert into Rides (id, user_id, distance) values ('4', '7', '100'); +insert into Rides (id, user_id, distance) values ('5', '13', '312'); +insert into Rides (id, user_id, distance) values ('6', '19', '50'); +insert into Rides (id, user_id, distance) values ('7', '7', '120'); +insert into Rides (id, user_id, distance) values ('8', '19', '400'); +insert into Rides (id, user_id, distance) values ('9', '7', '230'); diff --git a/problems/walls-and-gates/README.md b/problems/walls-and-gates/README.md index 4afb430d3..3cdb5f5cd 100644 --- a/problems/walls-and-gates/README.md +++ b/problems/walls-and-gates/README.md @@ -49,4 +49,4 @@ INF -1 INF -1 1. [Number of Islands](../number-of-islands) (Medium) 1. [Shortest Distance from All Buildings](../shortest-distance-from-all-buildings) (Hard) 1. [Robot Room Cleaner](../robot-room-cleaner) (Hard) - 1. [Rotting Oranges](../rotting-oranges) (Easy) + 1. [Rotting Oranges](../rotting-oranges) (Medium) diff --git a/tag/array/README.md b/tag/array/README.md index 6a3ad09e4..b8cb5b418 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1409 | [查询带键的排列](../../problems/queries-on-a-permutation-with-key) | [[数组](../array/README.md)] | Medium | | 1399 | [统计最大组的数目](../../problems/count-largest-group) | [[数组](../array/README.md)] | Easy | | 1395 | [统计作战单位数](../../problems/count-number-of-teams) | [[数组](../array/README.md)] | Medium | | 1394 | [找出数组中的幸运数](../../problems/find-lucky-integer-in-an-array) | [[数组](../array/README.md)] | Easy | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index fd809ab4a..4e2cb4d67 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -10,86 +10,171 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1337 | [方阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 1337 | [方阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1283 | [使结果不超过阈值的最小除数](../../problems/find-the-smallest-divisor-given-a-threshold) | [[二分查找](../binary-search/README.md)] | Medium | | 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1231 | [分享巧克力](../../problems/divide-chocolate) 🔒 | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1231 | [分享巧克力](../../problems/divide-chocolate) 🔒 | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1182 | [与目标颜色间的最短距离](../../problems/shortest-distance-to-target-color) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | | 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1150 | [检查一个数是否在数组中占绝大多数](../../problems/check-if-a-number-is-majority-element-in-a-sorted-array) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1150 | [检查一个数是否在数组中占绝大多数](../../problems/check-if-a-number-is-majority-element-in-a-sorted-array) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1111 | [有效括号的嵌套深度](../../problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1111 | [有效括号的嵌套深度](../../problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1095 | [山脉数组中查找目标值](../../problems/find-in-mountain-array) | [[二分查找](../binary-search/README.md)] | Hard | | 1064 | [不动点](../../problems/fixed-point) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1064 | [不动点](../../problems/fixed-point) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 1060 | [有序数组中的缺失元素](../../problems/missing-element-in-sorted-array) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | | 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1011 | [在 D 天内送达包裹的能力](../../problems/capacity-to-ship-packages-within-d-days) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1011 | [在 D 天内送达包裹的能力](../../problems/capacity-to-ship-packages-within-d-days) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 911 | [在线选举](../../problems/online-election) | [[二分查找](../binary-search/README.md)] | Medium | | 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 878 | [第 N 个神奇数字](../../problems/nth-magical-number) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 878 | [第 N 个神奇数字](../../problems/nth-magical-number) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 875 | [爱吃香蕉的珂珂](../../problems/koko-eating-bananas) | [[二分查找](../binary-search/README.md)] | Medium | | 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 852 | [山脉数组的峰顶索引](../../problems/peak-index-in-a-mountain-array) | [[二分查找](../binary-search/README.md)] | Easy | | 793 | [阶乘函数后K个零](../../problems/preimage-size-of-factorial-zeroes-function) | [[二分查找](../binary-search/README.md)] | Hard | | 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 774 | [最小化去加油站的最大距离](../../problems/minimize-max-distance-to-gas-station) 🔒 | [[二分查找](../binary-search/README.md)] | Hard | | 744 | [寻找比目标字母大的最小字母](../../problems/find-smallest-letter-greater-than-target) | [[二分查找](../binary-search/README.md)] | Easy | | 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | +| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | +| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | | 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | | 704 | [二分查找](../../problems/binary-search) | [[二分查找](../binary-search/README.md)] | Easy | | 702 | [搜索长度未知的有序数组](../../problems/search-in-a-sorted-array-of-unknown-size) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | | 668 | [乘法表中第k小的数](../../problems/kth-smallest-number-in-multiplication-table) | [[二分查找](../binary-search/README.md)] | Hard | | 658 | [找到 K 个最接近的元素](../../problems/find-k-closest-elements) | [[二分查找](../binary-search/README.md)] | Medium | | 644 | [最大平均子段和 II](../../problems/maximum-average-subarray-ii) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 644 | [最大平均子段和 II](../../problems/maximum-average-subarray-ii) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | | 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | | 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | +| 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | +| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 483 | [最小好进制](../../problems/smallest-good-base) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 483 | [最小好进制](../../problems/smallest-good-base) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 475 | [供暖器](../../problems/heaters) | [[二分查找](../binary-search/README.md)] | Easy | | 454 | [四数相加 II](../../problems/4sum-ii) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 454 | [四数相加 II](../../problems/4sum-ii) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 441 | [排列硬币](../../problems/arranging-coins) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 441 | [排列硬币](../../problems/arranging-coins) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 436 | [寻找右区间](../../problems/find-right-interval) | [[二分查找](../binary-search/README.md)] | Medium | | 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 378 | [有序矩阵中第K小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 378 | [有序矩阵中第K小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 374 | [猜数字大小](../../problems/guess-number-higher-or-lower) | [[二分查找](../binary-search/README.md)] | Easy | | 367 | [有效的完全平方数](../../problems/valid-perfect-square) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 367 | [有效的完全平方数](../../problems/valid-perfect-square) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 354 | [俄罗斯套娃信封问题](../../problems/russian-doll-envelopes) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 302 | [包含全部黑色像素的最小矩形](../../problems/smallest-rectangle-enclosing-black-pixels) 🔒 | [[二分查找](../binary-search/README.md)] | Hard | | 300 | [最长上升子序列](../../problems/longest-increasing-subsequence) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 278 | [第一个错误的版本](../../problems/first-bad-version) | [[二分查找](../binary-search/README.md)] | Easy | | 275 | [H指数 II](../../problems/h-index-ii) | [[二分查找](../binary-search/README.md)] | Medium | | 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | | 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | | 230 | [二叉搜索树中第K小的元素](../../problems/kth-smallest-element-in-a-bst) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 230 | [二叉搜索树中第K小的元素](../../problems/kth-smallest-element-in-a-bst) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 174 | [地下城游戏](../../problems/dungeon-game) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 154 | [寻找旋转排序数组中的最小值 II](../../problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 154 | [寻找旋转排序数组中的最小值 II](../../problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 81 | [搜索旋转排序数组 II](../../problems/search-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 81 | [搜索旋转排序数组 II](../../problems/search-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 74 | [搜索二维矩阵](../../problems/search-a-2d-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 74 | [搜索二维矩阵](../../problems/search-a-2d-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 69 | [x 的平方根](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 69 | [x 的平方根](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 50 | [Pow(x, n)](../../problems/powx-n) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 50 | [Pow(x, n)](../../problems/powx-n) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 35 | [搜索插入位置](../../problems/search-insert-position) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 35 | [搜索插入位置](../../problems/search-insert-position) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 34 | [在排序数组中查找元素的第一个和最后一个位置](../../problems/find-first-and-last-position-of-element-in-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 34 | [在排序数组中查找元素的第一个和最后一个位置](../../problems/find-first-and-last-position-of-element-in-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 33 | [搜索旋转排序数组](../../problems/search-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 33 | [搜索旋转排序数组](../../problems/search-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 29 | [两数相除](../../problems/divide-two-integers) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 29 | [两数相除](../../problems/divide-two-integers) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 4 | [寻找两个有序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 4 | [寻找两个有序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 4 | [寻找两个有序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 5a541ddc1..5e5fc4b65 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -28,7 +28,7 @@ | 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1091 | [二进制矩阵中的最短路径](../../problems/shortest-path-in-binary-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 994 | [腐烂的橘子](../../problems/rotting-oranges) | [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 994 | [腐烂的橘子](../../problems/rotting-oranges) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[极小化极大](../minimax/README.md)] | Hard | diff --git a/tag/design/README.md b/tag/design/README.md index 0f442f13a..c65c5a1b5 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -11,49 +11,86 @@ | :-: | - | - | :-: | | 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] | Medium | | 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | +| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | | 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] | Medium | | 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] | Medium | | 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1206 | [设计跳表](../../problems/design-skiplist) | [[设计](../design/README.md)] | Hard | | 1172 | [餐盘栈](../../problems/dinner-plate-stacks) | [[设计](../design/README.md)] | Hard | | 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 716 | [最大栈](../../problems/max-stack) 🔒 | [[设计](../design/README.md)] | Easy | | 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Hard | | 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Hard | | 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | | 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | | 631 | [设计 Excel 求和公式](../../problems/design-excel-sum-formula) 🔒 | [[设计](../design/README.md)] | Hard | | 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | | 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] | Easy | | 588 | [设计内存文件系统](../../problems/design-in-memory-file-system) 🔒 | [[设计](../design/README.md)] | Hard | | 460 | [LFU缓存](../../problems/lfu-cache) | [[设计](../design/README.md)] | Hard | | 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] | Hard | | 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | | 362 | [敲击计数器](../../problems/design-hit-counter) 🔒 | [[设计](../design/README.md)] | Medium | | 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | | 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | | 348 | [判定井字棋胜负](../../problems/design-tic-tac-toe) 🔒 | [[设计](../design/README.md)] | Medium | | 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | +| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | +| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | | 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | | 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard | +| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard | +| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard | | 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard | | 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] | Medium | | 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] | Medium | | 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] | Medium | | 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | | 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | | 211 | [添加与搜索单词 - 数据结构设计](../../problems/add-and-search-word-data-structure-design) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/add-and-search-word-data-structure-design) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/add-and-search-word-data-structure-design) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium | | 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium | | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | | 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | | 146 | [LRU缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 4ea035f8e..6e9b17ce7 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 5383 | [给 N x 3 网格图涂色的方案数](../../problems/number-of-ways-to-paint-n-x-3-grid) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1406 | [石子游戏 III](../../problems/stone-game-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1402 | [做菜顺序](../../problems/reducing-dishes) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/stack/README.md b/tag/stack/README.md index 32a4c502e..d274a91de 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | | 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | | 1249 | [移除无效的括号](../../problems/minimum-remove-to-make-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | | 1209 | [删除字符串中的所有相邻重复项 II](../../problems/remove-all-adjacent-duplicates-in-string-ii) | [[栈](../stack/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index c03bb0b56..280fc9add 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1408 | [数组中的字符串匹配](../../problems/string-matching-in-an-array) | [[字符串](../string/README.md)] | Easy | | 1404 | [将二进制表示减到 1 的步骤数](../../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1392 | [最长快乐前缀](../../problems/longest-happy-prefix) | [[字符串](../string/README.md)] | Hard | | 1374 | [生成每种字符都是奇数个的字符串](../../problems/generate-a-string-with-characters-that-have-odd-counts) | [[字符串](../string/README.md)] | Easy | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index a749ae488..21c3005e0 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -12,60 +12,120 @@ | 1248 | [统计「优美子数组」](../../problems/count-number-of-nice-subarrays) | [[双指针](../two-pointers/README.md)] | Medium | | 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 986 | [区间列表的交集](../../problems/interval-list-intersections) | [[双指针](../two-pointers/README.md)] | Medium | | 977 | [有序数组的平方](../../problems/squares-of-a-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 977 | [有序数组的平方](../../problems/squares-of-a-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 925 | [长按键入](../../problems/long-pressed-name) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 923 | [三数之和的多种可能](../../problems/3sum-with-multiplicity) | [[双指针](../two-pointers/README.md)] | Medium | | 904 | [水果成篮](../../problems/fruit-into-baskets) | [[双指针](../two-pointers/README.md)] | Medium | | 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 845 | [数组中的最长山脉](../../problems/longest-mountain-in-array) | [[双指针](../two-pointers/README.md)] | Medium | | 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 828 | [统计子串中的唯一字符](../../problems/count-unique-characters-of-all-substrings-of-a-given-string) | [[双指针](../two-pointers/README.md)] | Hard | | 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[双指针](../two-pointers/README.md)] | Medium | | 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | | 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | | 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 532 | [数组中的K-diff数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 532 | [数组中的K-diff数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 487 | [最大连续1的个数 II](../../problems/max-consecutive-ones-ii) 🔒 | [[双指针](../two-pointers/README.md)] | Medium | | 457 | [环形数组循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 457 | [环形数组循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 345 | [反转字符串中的元音字母](../../problems/reverse-vowels-of-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 344 | [反转字符串](../../problems/reverse-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 234 | [回文链表](../../problems/palindrome-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 234 | [回文链表](../../problems/palindrome-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 141 | [环形链表](../../problems/linked-list-cycle) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 141 | [环形链表](../../problems/linked-list-cycle) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 125 | [验证回文串](../../problems/valid-palindrome) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 88 | [合并两个有序数组](../../problems/merge-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 88 | [合并两个有序数组](../../problems/merge-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 86 | [分隔链表](../../problems/partition-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 86 | [分隔链表](../../problems/partition-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 80 | [删除排序数组中的重复项 II](../../problems/remove-duplicates-from-sorted-array-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 80 | [删除排序数组中的重复项 II](../../problems/remove-duplicates-from-sorted-array-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 61 | [旋转链表](../../problems/rotate-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 61 | [旋转链表](../../problems/rotate-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Hard | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Hard | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Hard | +| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | | 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | | 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 27 | [移除元素](../../problems/remove-element) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 27 | [移除元素](../../problems/remove-element) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 26 | [删除排序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 26 | [删除排序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 19 | [删除链表的倒数第N个节点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 19 | [删除链表的倒数第N个节点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 11 | [盛最多水的容器](../../problems/container-with-most-water) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 11 | [盛最多水的容器](../../problems/container-with-most-water) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | From 9c963b5c602a29926504fcc8f66e46ccc70c2789 Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 16 Apr 2020 18:34:45 +0800 Subject: [PATCH 053/145] A: v1.6.0 --- internal/leetcode/topic_tag.go | 4 +- internal/version/version.go | 2 +- problems/backspace-string-compare/README.md | 6 +- problems/capital-gainloss/README.md | 52 ++++++++++++ .../README.md | 64 ++++++++++++++ .../delete-columns-to-make-sorted/README.md | 28 +++--- problems/distinct-subsequences/README.md | 8 +- .../README.md | 44 ++++++++++ .../longest-uncommon-subsequence-i/README.md | 56 +++++++----- .../README.md | 6 +- .../README.md | 65 ++++++++++++++ problems/top-travellers/README.md | 74 ++++++++++++++++ problems/total-sales-amount-by-year/README.md | 66 ++++++++++++++ problems/word-ladder/README.md | 2 +- tag/binary-search/README.md | 85 ------------------- tag/design/README.md | 37 -------- tag/dynamic-programming/README.md | 2 +- tag/two-pointers/README.md | 60 ------------- 18 files changed, 426 insertions(+), 235 deletions(-) diff --git a/internal/leetcode/topic_tag.go b/internal/leetcode/topic_tag.go index 355980140..c6e9d4cc9 100644 --- a/internal/leetcode/topic_tag.go +++ b/internal/leetcode/topic_tag.go @@ -38,11 +38,13 @@ func (tag *TagType) SaveContents() { buf.WriteString("| # | 题目 | 标签 | 难度 |\n") buf.WriteString("| :-: | - | - | :-: |\n") format := "| %d | [%s](../../problems/%s)%s | %s | %s |\n" + preID := 0 for _, question := range questions { if question.TranslatedTitle == "" { question.TranslatedTitle = question.Title } - if question.frontendID() > 0 { + if question.frontendID() > 0 && question.frontendID() != preID { + preID = question.frontendID() buf.WriteString(fmt.Sprintf(format, question.frontendID(), question.TranslatedTitle, question.TitleSlug, question.IsPaidOnly.Str(), question.TagsStr(), question.Difficulty)) } } diff --git a/internal/version/version.go b/internal/version/version.go index 15f7bb386..6886a1b9d 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -8,7 +8,7 @@ import ( "github.com/openset/leetcode/internal/base" ) -const version = "1.5.3" +const version = "1.6.0" // CmdVersion - version.CmdVersion var CmdVersion = &base.Command{ diff --git a/problems/backspace-string-compare/README.md b/problems/backspace-string-compare/README.md index 45441ffdd..6e263c3aa 100644 --- a/problems/backspace-string-compare/README.md +++ b/problems/backspace-string-compare/README.md @@ -13,6 +13,8 @@

      Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character.

      +

      Note that after backspacing an empty text, the text will continue empty.

      +

      Example 1:

      @@ -51,11 +53,11 @@

      Note:

      -
        +
        • 1 <= S.length <= 200
        • 1 <= T.length <= 200
        • S and T only contain lowercase letters and '#' characters.
        • -
      +

    Follow up:

    diff --git a/problems/capital-gainloss/README.md b/problems/capital-gainloss/README.md index cd4960a2b..990cd2437 100644 --- a/problems/capital-gainloss/README.md +++ b/problems/capital-gainloss/README.md @@ -11,4 +11,56 @@ ## [1393. Capital Gain/Loss (Medium)](https://leetcode.com/problems/capital-gainloss "股票的资本损益") +

    Table: Stocks

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| stock_name    | varchar |
    +| operation     | enum    |
    +| operation_day | int     |
    +| price         | int     |
    ++---------------+---------+
    +(stock_name, day) is the primary key for this table.
    +The operation column is an ENUM of type ('Sell', 'Buy')
    +Each row of this table indicates that the stock which has stock_name had an operation on the day operation_day with the price.
    +It is guaranteed that each 'Sell' operation for a stock has a corresponding 'Buy' operation in a previous day.
    +
    + +Write an SQL query to report the Capital gain/loss for each stock. +The capital gain/loss of a stock is total gain or loss after buying and selling the stock one or many times. + +Return the result table in any order. + +The query result format is in the following example: + +
    +Stocks table:
    ++---------------+-----------+---------------+--------+
    +| stock_name    | operation | operation_day | price  |
    ++---------------+-----------+---------------+--------+
    +| Leetcode      | Buy       | 1             | 1000   |
    +| Corona Masks  | Buy       | 2             | 10     |
    +| Leetcode      | Sell      | 5             | 9000   |
    +| Handbags      | Buy       | 17            | 30000  |
    +| Corona Masks  | Sell      | 3             | 1010   |
    +| Corona Masks  | Buy       | 4             | 1000   |
    +| Corona Masks  | Sell      | 5             | 500    |
    +| Corona Masks  | Buy       | 6             | 1000   |
    +| Handbags      | Sell      | 29            | 7000   |
    +| Corona Masks  | Sell      | 10            | 10000  |
    ++---------------+-----------+---------------+--------+
    +
    +Result table:
    ++---------------+-------------------+
    +| stock_name    | capital_gain_loss |
    ++---------------+-------------------+
    +| Corona Masks  | 9500              |
    +| Leetcode      | 8000              |
    +| Handbags      | -23000            |
    ++---------------+-------------------+
    +Leetcode stock was bought at day 1 for 1000$ and was sold at day 5 for 9000$. Capital gain = 9000 - 1000 = 8000$.
    +Handbags stock was bought at day 17 for 30000$ and was sold at day 29 for 7000$. Capital loss = 7000 - 30000 = -23000$.
    +Corona Masks stock was bought at day 1 for 10$ and was sold at day 3 for 1010$. It was bought again at day 4 for 1000$ and was sold at day 5 for 500$. At last, it was bought at day 6 for 1000$ and was sold at day 10 for 10000$. Capital gain/loss is the sum of capital gains/losses for each ('Buy' --> 'Sell') operation = (1010 - 10) + (500 - 1000) + (10000 - 1000) = 1000 - 500 + 9000 = 9500$.
    +
    diff --git a/problems/customers-who-bought-products-a-and-b-but-not-c/README.md b/problems/customers-who-bought-products-a-and-b-but-not-c/README.md index cf518607c..07a9674a7 100644 --- a/problems/customers-who-bought-products-a-and-b-but-not-c/README.md +++ b/problems/customers-who-bought-products-a-and-b-but-not-c/README.md @@ -11,4 +11,68 @@ ## [1398. Customers Who Bought Products A and B but Not C (Medium)](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c "购买了产品A和产品B却没有购买产品C的顾客") +

    Table: Customers

    +
    ++---------------------+---------+
    +| Column Name         | Type    |
    ++---------------------+---------+
    +| customer_id         | int     |
    +| customer_name       | varchar |
    ++---------------------+---------+
    +customer_id is the primary key for this table.
    +customer_name is the name of the customer.
    +
    + +

    Table: Orders

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| order_id      | int     |
    +| customer_id   | int     |
    +| product_name  | varchar |
    ++---------------+---------+
    +order_id is the primary key for this table.
    +customer_id is the id of the customer who bought the product "product_name".
    +
    + +Write an SQL query to report the customer_id and customer_name of customers who bought products "A", "B" but did not buy the product "C" since we want to recommend them buy this product. +Return the result table ordered by customer_id. + +The query result format is in the following example. + +
    +Customers table:
    ++-------------+---------------+
    +| customer_id | customer_name |
    ++-------------+---------------+
    +| 1           | Daniel        |
    +| 2           | Diana         |
    +| 3           | Elizabeth     |
    +| 4           | Jhon          |
    ++-------------+---------------+
    +
    +Orders table:
    ++------------+--------------+---------------+
    +| order_id   | customer_id  | product_name  |
    ++------------+--------------+---------------+
    +| 10         |     1        |     A         |
    +| 20         |     1        |     B         |
    +| 30         |     1        |     D         |
    +| 40         |     1        |     C         |
    +| 50         |     2        |     A         |
    +| 60         |     3        |     A         |
    +| 70         |     3        |     B         |
    +| 80         |     3        |     D         |
    +| 90         |     4        |     C         |
    ++------------+--------------+---------------+
    +
    +Result table:
    ++-------------+---------------+
    +| customer_id | customer_name |
    ++-------------+---------------+
    +| 3           | Elizabeth     |
    ++-------------+---------------+
    +Only the customer_id with id 3 bought the product A and B but not the product C.
    +
    diff --git a/problems/delete-columns-to-make-sorted/README.md b/problems/delete-columns-to-make-sorted/README.md index 8c8aef867..82afaae3d 100644 --- a/problems/delete-columns-to-make-sorted/README.md +++ b/problems/delete-columns-to-make-sorted/README.md @@ -15,54 +15,46 @@

    Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices.

    -

    For example, if we have an array A = ["abcdef","uvwxyz"] and deletion indices {0, 2, 3}, then the final array after deletions is ["bef", "vyz"], and the remaining columns of A are ["b","v"], ["e","y"], and ["f","z"].  (Formally, the c-th column is [A[0][c], A[1][c], ..., A[A.length-1][c]].)

    +

    For example, if we have an array A = ["abcdef","uvwxyz"] and deletion indices {0, 2, 3}, then the final array after deletions is ["bef", "vyz"], and the remaining columns of A are ["b","v"], ["e","y"], and ["f","z"].  (Formally, the c-th column is [A[0][c], A[1][c], ..., A[A.length-1][c]]).

    Suppose we chose a set of deletion indices D such that after deletions, each remaining column in A is in non-decreasing sorted order.

    Return the minimum possible value of D.length.

     

    - -

    Example 1:

    -Input: ["cba","daf","ghi"]
    -Output: 1
    +Input: A = ["cba","daf","ghi"]
    +Output: 1
     Explanation: 
     After choosing D = {1}, each column ["c","d","g"] and ["a","f","i"] are in non-decreasing sorted order.
     If we chose D = {}, then a column ["b","a","h"] would not be in non-decreasing sorted order.
     
    -

    Example 2:

    -Input: ["a","b"]
    -Output: 0
    +Input: A = ["a","b"]
    +Output: 0
     Explanation: D = {}
     
    -

    Example 3:

    -Input: ["zyx","wvu","tsr"]
    -Output: 3
    +Input: A = ["zyx","wvu","tsr"]
    +Output: 3
     Explanation: D = {0, 1, 2}
     

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= A.length <= 100
      • 1 <= A[i].length <= 1000
      • -
    -
    -
    -
    + ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/distinct-subsequences/README.md b/problems/distinct-subsequences/README.md index 5a7804750..75c52d122 100644 --- a/problems/distinct-subsequences/README.md +++ b/problems/distinct-subsequences/README.md @@ -15,13 +15,14 @@

    A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, "ACE" is a subsequence of "ABCDE" while "AEC" is not).

    +

    It's guaranteed the answer fits on a 32-bit signed integer.

    +

    Example 1:

     Input: S = "rabbbit", T = "rabbit"
     Output: 3
    -Explanation:
    -
    +Explanation:
     As shown below, there are 3 ways you can generate "rabbit" from S.
     (The caret symbol ^ means the chosen letters)
     
    @@ -38,8 +39,7 @@ As shown below, there are 3 ways you can generate "rabbit" from S.
     
     Input: S = "babgbag", T = "bag"
     Output: 5
    -Explanation:
    -
    +Explanation:
     As shown below, there are 5 ways you can generate "bag" from S.
     (The caret symbol ^ means the chosen letters)
     
    diff --git a/problems/get-the-second-most-recent-activity/README.md b/problems/get-the-second-most-recent-activity/README.md
    index 572594895..a98a5e3d4 100644
    --- a/problems/get-the-second-most-recent-activity/README.md
    +++ b/problems/get-the-second-most-recent-activity/README.md
    @@ -11,4 +11,48 @@
     
     ## [1369. Get the Second Most Recent Activity (Hard)](https://leetcode.com/problems/get-the-second-most-recent-activity "获取最近第二次的活动")
     
    +SQL Schema
    +

    Table: UserActivity

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| username      | varchar |
    +| activity      | varchar |
    +| startDate     | Date    |
    +| endDate       | Date    |
    ++---------------+---------+
    +This table does not contain primary key.
    +This table contain information about the activity performed of each user in a period of time.
    +A person with username performed a activity from startDate to endDate.
    +
    +Write an SQL query to show the second most recent activity of each user. + +If the user only has one activity, return that one. + +A user can't perform more than one activity at the same time. Return the result table in any order. + +The query result format is in the following example: +
    +UserActivity table:
    ++------------+--------------+-------------+-------------+
    +| username   | activity     | startDate   | endDate     |
    ++------------+--------------+-------------+-------------+
    +| Alice      | Travel       | 2020-02-12  | 2020-02-20  |
    +| Alice      | Dancing      | 2020-02-21  | 2020-02-23  |
    +| Alice      | Travel       | 2020-02-24  | 2020-02-28  |
    +| Bob        | Travel       | 2020-02-11  | 2020-02-18  |
    ++------------+--------------+-------------+-------------+
    +
    +Result table:
    ++------------+--------------+-------------+-------------+
    +| username   | activity     | startDate   | endDate     |
    ++------------+--------------+-------------+-------------+
    +| Alice      | Dancing      | 2020-02-21  | 2020-02-23  |
    +| Bob        | Travel       | 2020-02-11  | 2020-02-18  |
    ++------------+--------------+-------------+-------------+
    +
    +The most recent activity of Alice is Travel from 2020-02-24 to 2020-02-28, before that she was dancing from 2020-02-21 to 2020-02-23.
    +Bob only has one record, we just take that one.
    +
    diff --git a/problems/longest-uncommon-subsequence-i/README.md b/problems/longest-uncommon-subsequence-i/README.md index c4b156e8d..3f3f4d2ed 100644 --- a/problems/longest-uncommon-subsequence-i/README.md +++ b/problems/longest-uncommon-subsequence-i/README.md @@ -11,33 +11,45 @@ ## [521. Longest Uncommon Subsequence I (Easy)](https://leetcode.com/problems/longest-uncommon-subsequence-i "最长特殊序列 Ⅰ") -

    -Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. -The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequence should not be any subsequence of the other strings. -

    +

    Given two strings, you need to find the longest uncommon subsequence of this two strings. The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequence should not be any subsequence of the other string.

    -

    -A subsequence is a sequence that can be derived from one sequence by deleting some characters without changing the order of the remaining elements. Trivially, any string is a subsequence of itself and an empty string is a subsequence of any string. -

    +

    A subsequence is a sequence that can be derived from one sequence by deleting some characters without changing the order of the remaining elements. Trivially, any string is a subsequence of itself and an empty string is a subsequence of any string.

    -

    -The input will be two strings, and the output needs to be the length of the longest uncommon subsequence. If the longest uncommon subsequence doesn't exist, return -1. -

    +

    The input will be two strings, and the output needs to be the length of the longest uncommon subsequence. If the longest uncommon subsequence doesn't exist, return -1.

    + +

     

    +

    Example 1:

    + +
    +Input: a = "aba", b = "cdc"
    +Output: 3
    +Explanation: The longest uncommon subsequence is "aba", 
    +because "aba" is a subsequence of "aba", 
    +but not a subsequence of the other string "cdc".
    +Note that "cdc" can be also a longest uncommon subsequence.
    +
    + +

    Example 2:

    -

    Example 1:

    -Input: "aba", "cdc"
    -Output: 3
    -Explanation: The longest uncommon subsequence is "aba" (or "cdc"), 
    because "aba" is a subsequence of "aba",
    but not a subsequence of any other strings in the group of two strings. +Input: a = "aaa", b = "bbb" +Output: 3
    -

    - -

    Note: -

      -
    1. Both strings' lengths will not exceed 100.
    2. -
    3. Only letters from a ~ z will appear in input strings.
    4. -
    -

    + +

    Example 3:

    + +
    +Input: a = "aaa", b = "aaa"
    +Output: -1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • Both strings' lengths will be between [1 - 100].
    • +
    • Only letters from a ~ z will appear in input strings.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/pairs-of-songs-with-total-durations-divisible-by-60/README.md b/problems/pairs-of-songs-with-total-durations-divisible-by-60/README.md index 9e5ac8d38..9a03fc86c 100644 --- a/problems/pairs-of-songs-with-total-durations-divisible-by-60/README.md +++ b/problems/pairs-of-songs-with-total-durations-divisible-by-60/README.md @@ -13,7 +13,7 @@

    In a list of songs, the i-th song has a duration of time[i] seconds. 

    -

    Return the number of pairs of songs for which their total duration in seconds is divisible by 60.  Formally, we want the number of indices i < j with (time[i] + time[j]) % 60 == 0.

    +

    Return the number of pairs of songs for which their total duration in seconds is divisible by 60.  Formally, we want the number of indices i, j such that i < j with (time[i] + time[j]) % 60 == 0.

     

    @@ -42,10 +42,10 @@

    Note:

    -
      +
      • 1 <= time.length <= 60000
      • 1 <= time[i] <= 500
      • -
    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/replace-employee-id-with-the-unique-identifier/README.md b/problems/replace-employee-id-with-the-unique-identifier/README.md index 2ab2945a0..ae92f57d0 100644 --- a/problems/replace-employee-id-with-the-unique-identifier/README.md +++ b/problems/replace-employee-id-with-the-unique-identifier/README.md @@ -11,4 +11,69 @@ ## [1378. Replace Employee ID With The Unique Identifier (Easy)](https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier "使用唯一标识码替换员工ID") +

    Table: Employees

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| id            | int     |
    +| name          | varchar |
    ++---------------+---------+
    +id is the primary key for this table.
    +Each row of this table contains the id and the name of an employee in a company.
    +
    + +

    Table: EmployeeUNI

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| id            | int     |
    +| unique_id     | int     |
    ++---------------+---------+
    +(id, unique_id) is the primary key for this table.
    +Each row of this table contains the id and the corresponding unique id of an employee in the company.
    +
    + +Write an SQL query to show the unique ID of each user, If a user doesn't have a unique ID replace just show null. +Return the result table in any order. + +The query result format is in the following example: +
    +Employees table:
    ++----+----------+
    +| id | name     |
    ++----+----------+
    +| 1  | Alice    |
    +| 7  | Bob      |
    +| 11 | Meir     |
    +| 90 | Winston  |
    +| 3  | Jonathan |
    ++----+----------+
    +
    +EmployeeUNI table:
    ++----+-----------+
    +| id | unique_id |
    ++----+-----------+
    +| 3  | 1         |
    +| 11 | 2         |
    +| 90 | 3         |
    ++----+-----------+
    +
    +EmployeeUNI table:
    ++-----------+----------+
    +| unique_id | name     |
    ++-----------+----------+
    +| null      | Alice    |
    +| null      | Bob      |
    +| 2         | Meir     |
    +| 3         | Winston  |
    +| 1         | Jonathan |
    ++-----------+----------+
    +
    +Alice and Bob don't have a unique ID, We will show null instead.
    +The unique ID of Meir is 2.
    +The unique ID of Winston is 3.
    +The unique ID of Jonathan is 1.
    +
    diff --git a/problems/top-travellers/README.md b/problems/top-travellers/README.md index 57fc5d75e..d35e3c7f6 100644 --- a/problems/top-travellers/README.md +++ b/problems/top-travellers/README.md @@ -11,4 +11,78 @@ ## [1407. Top Travellers (Easy)](https://leetcode.com/problems/top-travellers "") +

    Table: Users

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| id            | int     |
    +| name          | varchar |
    ++---------------+---------+
    +id is the primary key for this table.
    +name is the name of the user.
    +
    + +

    Table: Rides

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| id            | int     |
    +| user_id       | int     |
    +| distance      | int     |
    ++---------------+---------+
    +id is the primary key for this table.
    +city_id is the id of the city who bought the product "product_name".
    +
    + +Write an SQL query to report the distance travelled by each user. +Return the result table ordered by travelled_distance in descending order, if two or more users travelled the same distance, order them by their name in ascending order. + +The query result format is in the following example. +
    +Users table:
    ++------+-----------+
    +| id   | name      |
    ++------+-----------+
    +| 1    | Alice     |
    +| 2    | Bob       |
    +| 3    | Alex      |
    +| 4    | Donald    |
    +| 7    | Lee       |
    +| 13   | Jonathan  |
    +| 19   | Elvis     |
    ++------+-----------+
    +
    +Rides table:
    ++------+----------+----------+
    +| id   | user_id  | distance |
    ++------+----------+----------+
    +| 1    | 1        | 120      |
    +| 2    | 2        | 317      |
    +| 3    | 3        | 222      |
    +| 4    | 7        | 100      |
    +| 5    | 13       | 312      |
    +| 6    | 19       | 50       |
    +| 7    | 7        | 120      |
    +| 8    | 19       | 400      |
    +| 9    | 7        | 230      |
    ++------+----------+----------+
    +
    +Result table:
    ++----------+--------------------+
    +| name     | travelled_distance |
    ++----------+--------------------+
    +| Elvis    | 450                |
    +| Lee      | 450                |
    +| Bob      | 317                |
    +| Jonathan | 312                |
    +| Alex     | 222                |
    +| Alice    | 120                |
    +| Donald   | 0                  |
    ++----------+--------------------+
    +Elvis and Lee travelled 450 miles, Elvis is the top traveller as his name is alphabetically smaller than Lee.
    +Bob, Jonathan, Alex and Alice have only one ride and we just order them by the total distances of the ride.
    +Donald didn't have any rides, the distance travelled by him is 0.
    +
    diff --git a/problems/total-sales-amount-by-year/README.md b/problems/total-sales-amount-by-year/README.md index 415c11781..87ed722ca 100644 --- a/problems/total-sales-amount-by-year/README.md +++ b/problems/total-sales-amount-by-year/README.md @@ -11,4 +11,70 @@ ## [1384. Total Sales Amount by Year (Hard)](https://leetcode.com/problems/total-sales-amount-by-year "按年度列出销售总额") +

    Table: Product

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| product_id    | int     |
    +| product_name  | varchar |
    ++---------------+---------+
    +product_id is the primary key for this table.
    +product_name is the name of the product.
    +
    + +

    Table: Sales

    +
    ++---------------------+---------+
    +| Column Name         | Type    |
    ++---------------------+---------+
    +| product_id          | int     |
    +| period_start        | varchar |
    +| period_end          | date    |
    +| average_daily_sales | int     |
    ++---------------------+---------+
    +product_id is the primary key for this table. 
    +period_start and period_end indicates the start and end date for sales period, both dates are inclusive.
    +The average_daily_sales column holds the average daily sales amount of the items for the period.
    +
    +Write an SQL query to report the Total sales amount of each item for each year, with corresponding product name, product_id, product_name and report_year. + +Dates of the sales years are between 2018 to 2020. Return the result table ordered by product_id and report_year. + +The query result format is in the following example: + +
    +Product table:
    ++------------+--------------+
    +| product_id | product_name |
    ++------------+--------------+
    +| 1          | LC Phone     |
    +| 2          | LC T-Shirt   |
    +| 3          | LC Keychain  |
    ++------------+--------------+
    +
    +Sales table:
    ++------------+--------------+-------------+---------------------+
    +| product_id | period_start | period_end  | average_daily_sales |
    ++------------+--------------+-------------+---------------------+
    +| 1          | 2019-01-25   | 2019-02-28  | 100                 |
    +| 2          | 2018-12-01   | 2020-01-01  | 10                  |
    +| 3          | 2019-12-01   | 2020-01-31  | 1                   |
    ++------------+--------------+-------------+---------------------+
    +
    +Result table:
    ++------------+--------------+-------------+--------------+
    +| product_id | product_name | report_year | total_amount |
    ++------------+--------------+-------------+--------------+
    +| 1          | LC Phone     |    2019     | 3500         |
    +| 2          | LC T-Shirt   |    2018     | 310          |
    +| 2          | LC T-Shirt   |    2019     | 3650         |
    +| 2          | LC T-Shirt   |    2020     | 10           |
    +| 3          | LC Keychain  |    2019     | 31           |
    +| 3          | LC Keychain  |    2020     | 31           |
    ++------------+--------------+-------------+--------------+
    +LC Phone was sold for the period of 2019-01-25 to 2019-02-28, and there are 35 days for this period. Total amount 35*100 = 3500. 
    +LC T-shirt was sold for the period of 2018-12-01 to 2020-01-01, and there are 31, 365, 1 days for years 2018, 2019 and 2020 respectively.
    +LC Keychain was sold for the period of 2019-12-01 to 2020-01-31, and there are 31, 31 days for years 2019 and 2020 respectively.
    +
    diff --git a/problems/word-ladder/README.md b/problems/word-ladder/README.md index 6e83286d9..008dce79f 100644 --- a/problems/word-ladder/README.md +++ b/problems/word-ladder/README.md @@ -15,7 +15,7 @@
    1. Only one letter can be changed at a time.
    2. -
    3. Each transformed word must exist in the word list. Note that beginWord is not a transformed word.
    4. +
    5. Each transformed word must exist in the word list.

    Note:

    diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 4e2cb4d67..fd809ab4a 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -10,171 +10,86 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1337 | [方阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 1337 | [方阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1283 | [使结果不超过阈值的最小除数](../../problems/find-the-smallest-divisor-given-a-threshold) | [[二分查找](../binary-search/README.md)] | Medium | | 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1231 | [分享巧克力](../../problems/divide-chocolate) 🔒 | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1231 | [分享巧克力](../../problems/divide-chocolate) 🔒 | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1182 | [与目标颜色间的最短距离](../../problems/shortest-distance-to-target-color) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | | 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1150 | [检查一个数是否在数组中占绝大多数](../../problems/check-if-a-number-is-majority-element-in-a-sorted-array) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1150 | [检查一个数是否在数组中占绝大多数](../../problems/check-if-a-number-is-majority-element-in-a-sorted-array) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1111 | [有效括号的嵌套深度](../../problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1111 | [有效括号的嵌套深度](../../problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1095 | [山脉数组中查找目标值](../../problems/find-in-mountain-array) | [[二分查找](../binary-search/README.md)] | Hard | | 1064 | [不动点](../../problems/fixed-point) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1064 | [不动点](../../problems/fixed-point) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 1060 | [有序数组中的缺失元素](../../problems/missing-element-in-sorted-array) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | | 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1011 | [在 D 天内送达包裹的能力](../../problems/capacity-to-ship-packages-within-d-days) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1011 | [在 D 天内送达包裹的能力](../../problems/capacity-to-ship-packages-within-d-days) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 911 | [在线选举](../../problems/online-election) | [[二分查找](../binary-search/README.md)] | Medium | | 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 878 | [第 N 个神奇数字](../../problems/nth-magical-number) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 878 | [第 N 个神奇数字](../../problems/nth-magical-number) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 875 | [爱吃香蕉的珂珂](../../problems/koko-eating-bananas) | [[二分查找](../binary-search/README.md)] | Medium | | 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 852 | [山脉数组的峰顶索引](../../problems/peak-index-in-a-mountain-array) | [[二分查找](../binary-search/README.md)] | Easy | | 793 | [阶乘函数后K个零](../../problems/preimage-size-of-factorial-zeroes-function) | [[二分查找](../binary-search/README.md)] | Hard | | 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 774 | [最小化去加油站的最大距离](../../problems/minimize-max-distance-to-gas-station) 🔒 | [[二分查找](../binary-search/README.md)] | Hard | | 744 | [寻找比目标字母大的最小字母](../../problems/find-smallest-letter-greater-than-target) | [[二分查找](../binary-search/README.md)] | Easy | | 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | -| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | -| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | | 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | | 704 | [二分查找](../../problems/binary-search) | [[二分查找](../binary-search/README.md)] | Easy | | 702 | [搜索长度未知的有序数组](../../problems/search-in-a-sorted-array-of-unknown-size) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | | 668 | [乘法表中第k小的数](../../problems/kth-smallest-number-in-multiplication-table) | [[二分查找](../binary-search/README.md)] | Hard | | 658 | [找到 K 个最接近的元素](../../problems/find-k-closest-elements) | [[二分查找](../binary-search/README.md)] | Medium | | 644 | [最大平均子段和 II](../../problems/maximum-average-subarray-ii) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 644 | [最大平均子段和 II](../../problems/maximum-average-subarray-ii) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | | 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | | 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | -| 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | -| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 483 | [最小好进制](../../problems/smallest-good-base) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 483 | [最小好进制](../../problems/smallest-good-base) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 475 | [供暖器](../../problems/heaters) | [[二分查找](../binary-search/README.md)] | Easy | | 454 | [四数相加 II](../../problems/4sum-ii) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 454 | [四数相加 II](../../problems/4sum-ii) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 441 | [排列硬币](../../problems/arranging-coins) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 441 | [排列硬币](../../problems/arranging-coins) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 436 | [寻找右区间](../../problems/find-right-interval) | [[二分查找](../binary-search/README.md)] | Medium | | 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 378 | [有序矩阵中第K小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 378 | [有序矩阵中第K小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 374 | [猜数字大小](../../problems/guess-number-higher-or-lower) | [[二分查找](../binary-search/README.md)] | Easy | | 367 | [有效的完全平方数](../../problems/valid-perfect-square) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 367 | [有效的完全平方数](../../problems/valid-perfect-square) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 354 | [俄罗斯套娃信封问题](../../problems/russian-doll-envelopes) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 302 | [包含全部黑色像素的最小矩形](../../problems/smallest-rectangle-enclosing-black-pixels) 🔒 | [[二分查找](../binary-search/README.md)] | Hard | | 300 | [最长上升子序列](../../problems/longest-increasing-subsequence) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 278 | [第一个错误的版本](../../problems/first-bad-version) | [[二分查找](../binary-search/README.md)] | Easy | | 275 | [H指数 II](../../problems/h-index-ii) | [[二分查找](../binary-search/README.md)] | Medium | | 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | | 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | | 230 | [二叉搜索树中第K小的元素](../../problems/kth-smallest-element-in-a-bst) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 230 | [二叉搜索树中第K小的元素](../../problems/kth-smallest-element-in-a-bst) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 174 | [地下城游戏](../../problems/dungeon-game) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 154 | [寻找旋转排序数组中的最小值 II](../../problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 154 | [寻找旋转排序数组中的最小值 II](../../problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 81 | [搜索旋转排序数组 II](../../problems/search-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 81 | [搜索旋转排序数组 II](../../problems/search-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 74 | [搜索二维矩阵](../../problems/search-a-2d-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 74 | [搜索二维矩阵](../../problems/search-a-2d-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 69 | [x 的平方根](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 69 | [x 的平方根](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 50 | [Pow(x, n)](../../problems/powx-n) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 50 | [Pow(x, n)](../../problems/powx-n) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 35 | [搜索插入位置](../../problems/search-insert-position) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 35 | [搜索插入位置](../../problems/search-insert-position) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 34 | [在排序数组中查找元素的第一个和最后一个位置](../../problems/find-first-and-last-position-of-element-in-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 34 | [在排序数组中查找元素的第一个和最后一个位置](../../problems/find-first-and-last-position-of-element-in-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 33 | [搜索旋转排序数组](../../problems/search-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 33 | [搜索旋转排序数组](../../problems/search-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 29 | [两数相除](../../problems/divide-two-integers) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 29 | [两数相除](../../problems/divide-two-integers) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 4 | [寻找两个有序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 4 | [寻找两个有序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 4 | [寻找两个有序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/design/README.md b/tag/design/README.md index c65c5a1b5..0f442f13a 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -11,86 +11,49 @@ | :-: | - | - | :-: | | 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] | Medium | | 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | -| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | | 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] | Medium | | 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | -| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] | Medium | | 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1206 | [设计跳表](../../problems/design-skiplist) | [[设计](../design/README.md)] | Hard | | 1172 | [餐盘栈](../../problems/dinner-plate-stacks) | [[设计](../design/README.md)] | Hard | | 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 716 | [最大栈](../../problems/max-stack) 🔒 | [[设计](../design/README.md)] | Easy | | 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Hard | | 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Hard | | 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | | 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | | 631 | [设计 Excel 求和公式](../../problems/design-excel-sum-formula) 🔒 | [[设计](../design/README.md)] | Hard | | 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | | 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] | Easy | | 588 | [设计内存文件系统](../../problems/design-in-memory-file-system) 🔒 | [[设计](../design/README.md)] | Hard | | 460 | [LFU缓存](../../problems/lfu-cache) | [[设计](../design/README.md)] | Hard | | 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] | Hard | | 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | | 362 | [敲击计数器](../../problems/design-hit-counter) 🔒 | [[设计](../design/README.md)] | Medium | | 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | | 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | | 348 | [判定井字棋胜负](../../problems/design-tic-tac-toe) 🔒 | [[设计](../design/README.md)] | Medium | | 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | -| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | -| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | | 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | | 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard | -| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard | -| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard | | 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard | | 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] | Medium | | 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] | Medium | | 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] | Medium | | 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | | 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | | 211 | [添加与搜索单词 - 数据结构设计](../../problems/add-and-search-word-data-structure-design) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 211 | [添加与搜索单词 - 数据结构设计](../../problems/add-and-search-word-data-structure-design) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 211 | [添加与搜索单词 - 数据结构设计](../../problems/add-and-search-word-data-structure-design) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium | | 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium | | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | | 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | | 146 | [LRU缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 6e9b17ce7..213efd277 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 5383 | [给 N x 3 网格图涂色的方案数](../../problems/number-of-ways-to-paint-n-x-3-grid) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1411 | [给 N x 3 网格图涂色的方案数](../../problems/number-of-ways-to-paint-n-x-3-grid) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1406 | [石子游戏 III](../../problems/stone-game-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1402 | [做菜顺序](../../problems/reducing-dishes) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 21c3005e0..a749ae488 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -12,120 +12,60 @@ | 1248 | [统计「优美子数组」](../../problems/count-number-of-nice-subarrays) | [[双指针](../two-pointers/README.md)] | Medium | | 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 986 | [区间列表的交集](../../problems/interval-list-intersections) | [[双指针](../two-pointers/README.md)] | Medium | | 977 | [有序数组的平方](../../problems/squares-of-a-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 977 | [有序数组的平方](../../problems/squares-of-a-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 925 | [长按键入](../../problems/long-pressed-name) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 923 | [三数之和的多种可能](../../problems/3sum-with-multiplicity) | [[双指针](../two-pointers/README.md)] | Medium | | 904 | [水果成篮](../../problems/fruit-into-baskets) | [[双指针](../two-pointers/README.md)] | Medium | | 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 845 | [数组中的最长山脉](../../problems/longest-mountain-in-array) | [[双指针](../two-pointers/README.md)] | Medium | | 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 828 | [统计子串中的唯一字符](../../problems/count-unique-characters-of-all-substrings-of-a-given-string) | [[双指针](../two-pointers/README.md)] | Hard | | 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[双指针](../two-pointers/README.md)] | Medium | | 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | | 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | | 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 532 | [数组中的K-diff数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 532 | [数组中的K-diff数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 487 | [最大连续1的个数 II](../../problems/max-consecutive-ones-ii) 🔒 | [[双指针](../two-pointers/README.md)] | Medium | | 457 | [环形数组循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 457 | [环形数组循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 345 | [反转字符串中的元音字母](../../problems/reverse-vowels-of-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 344 | [反转字符串](../../problems/reverse-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 234 | [回文链表](../../problems/palindrome-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 234 | [回文链表](../../problems/palindrome-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 141 | [环形链表](../../problems/linked-list-cycle) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 141 | [环形链表](../../problems/linked-list-cycle) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 125 | [验证回文串](../../problems/valid-palindrome) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 88 | [合并两个有序数组](../../problems/merge-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 88 | [合并两个有序数组](../../problems/merge-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 86 | [分隔链表](../../problems/partition-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 86 | [分隔链表](../../problems/partition-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 80 | [删除排序数组中的重复项 II](../../problems/remove-duplicates-from-sorted-array-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 80 | [删除排序数组中的重复项 II](../../problems/remove-duplicates-from-sorted-array-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 61 | [旋转链表](../../problems/rotate-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 61 | [旋转链表](../../problems/rotate-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Hard | -| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Hard | -| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Hard | -| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | | 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | | 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 27 | [移除元素](../../problems/remove-element) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 27 | [移除元素](../../problems/remove-element) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 26 | [删除排序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 26 | [删除排序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 19 | [删除链表的倒数第N个节点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 19 | [删除链表的倒数第N个节点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 11 | [盛最多水的容器](../../problems/container-with-most-water) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 11 | [盛最多水的容器](../../problems/container-with-most-water) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | From 8eb508fdb48b7a9ed11a576f0f99256bc307330c Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 20 Apr 2020 08:22:23 +0800 Subject: [PATCH 054/145] A: new --- README.md | 11 ++- .../README.md | 87 ++++++++++++++++++ .../README.md | 75 ++++++++++++++++ .../README.md | 69 +++++++++++++++ .../README.md | 14 +++ .../mysql_schemas.sql | 19 ++++ problems/fizz-buzz/README.md | 3 - .../README.md | 72 +++++++++++++++ .../README.md | 66 ++++++++++++++ .../README.md | 2 +- problems/reformat-the-string/README.md | 79 +++++++++++++++++ problems/restore-the-array/README.md | 83 +++++++++++++++++ .../README.md | 88 +++++++++++++++++++ problems/top-travellers/README.md | 2 +- tag/array/README.md | 2 + tag/backtracking/README.md | 1 + tag/dynamic-programming/README.md | 2 + tag/greedy/README.md | 1 + tag/hash-table/README.md | 1 + tag/string/README.md | 2 + 20 files changed, 673 insertions(+), 6 deletions(-) create mode 100644 problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/README.md create mode 100644 problems/display-table-of-food-orders-in-a-restaurant/README.md create mode 100644 problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md create mode 100644 problems/find-the-quiet-students-in-all-exams/README.md create mode 100644 problems/find-the-quiet-students-in-all-exams/mysql_schemas.sql create mode 100644 problems/minimum-number-of-frogs-croaking/README.md create mode 100644 problems/minimum-value-to-get-positive-step-by-step-sum/README.md create mode 100644 problems/reformat-the-string/README.md create mode 100644 problems/restore-the-array/README.md create mode 100644 problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/README.md diff --git a/README.md b/README.md index 6f051c931..504588346 100644 --- a/README.md +++ b/README.md @@ -62,11 +62,20 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1420 | [Build Array Where You Can Find The Maximum Exactly K Comparisons](https://leetcode.com/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons "生成数组") | [Go](problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons) | Hard | +| 1419 | [Minimum Number of Frogs Croaking](https://leetcode.com/problems/minimum-number-of-frogs-croaking "数青蛙") | [Go](problems/minimum-number-of-frogs-croaking) | Medium | +| 1418 | [Display Table of Food Orders in a Restaurant](https://leetcode.com/problems/display-table-of-food-orders-in-a-restaurant "点菜展示表") | [Go](problems/display-table-of-food-orders-in-a-restaurant) | Medium | +| 1417 | [Reformat The String](https://leetcode.com/problems/reformat-the-string "重新格式化字符串") | [Go](problems/reformat-the-string) | Easy | +| 1416 | [Restore The Array](https://leetcode.com/problems/restore-the-array "恢复数组") | [Go](problems/restore-the-array) | Hard | +| 1415 | [The k-th Lexicographical String of All Happy Strings of Length n](https://leetcode.com/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n "长度为 n 的开心字符串中字典序第 k 小的字符串") | [Go](problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | Medium | +| 1414 | [Find the Minimum Number of Fibonacci Numbers Whose Sum Is K](https://leetcode.com/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k "和为 K 的最少斐波那契数字数目") | [Go](problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | Medium | +| 1413 | [Minimum Value to Get Positive Step by Step Sum](https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum "逐步求和得到正数的最小值") | [Go](problems/minimum-value-to-get-positive-step-by-step-sum) | Easy | +| 1412 | [Find the Quiet Students in All Exams](https://leetcode.com/problems/find-the-quiet-students-in-all-exams) 🔒 | [MySQL](problems/find-the-quiet-students-in-all-exams) | Hard | | 1411 | [Number of Ways to Paint N × 3 Grid](https://leetcode.com/problems/number-of-ways-to-paint-n-3-grid "给 N x 3 网格图涂色的方案数") | [Go](problems/number-of-ways-to-paint-n-3-grid) | Hard | | 1410 | [HTML Entity Parser](https://leetcode.com/problems/html-entity-parser "HTML 实体解析器") | [Go](problems/html-entity-parser) | Medium | | 1409 | [Queries on a Permutation With Key](https://leetcode.com/problems/queries-on-a-permutation-with-key "查询带键的排列") | [Go](problems/queries-on-a-permutation-with-key) | Medium | | 1408 | [String Matching in an Array](https://leetcode.com/problems/string-matching-in-an-array "数组中的字符串匹配") | [Go](problems/string-matching-in-an-array) | Easy | -| 1407 | [Top Travellers](https://leetcode.com/problems/top-travellers) 🔒 | [MySQL](problems/top-travellers) | Easy | +| 1407 | [Top Travellers](https://leetcode.com/problems/top-travellers "排名靠前的旅行者") 🔒 | [MySQL](problems/top-travellers) | Easy | | 1406 | [Stone Game III](https://leetcode.com/problems/stone-game-iii "石子游戏 III") | [Go](problems/stone-game-iii) | Hard | | 1405 | [Longest Happy String](https://leetcode.com/problems/longest-happy-string "最长快乐字符串") | [Go](problems/longest-happy-string) | Medium | | 1404 | [Number of Steps to Reduce a Number in Binary Representation to One](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one "将二进制表示减到 1 的步骤数") | [Go](problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | Medium | diff --git a/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/README.md b/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/README.md new file mode 100644 index 000000000..588219043 --- /dev/null +++ b/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../minimum-number-of-frogs-croaking "Minimum Number of Frogs Croaking") +                 +Next > + +## [1420. Build Array Where You Can Find The Maximum Exactly K Comparisons (Hard)](https://leetcode.com/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons "生成数组") + +

    Given three integers n, m and k. Consider the following algorithm to find the maximum element of an array of positive integers:

    + +

    You should build the array arr which has the following properties:

    + +
      +
    • arr has exactly n integers.
    • +
    • 1 <= arr[i] <= m where (0 <= i < n).
    • +
    • After applying the mentioned algorithm to arr, the value search_cost is equal to k.
    • +
    + +

    Return the number of ways to build the array arr under the mentioned conditions. As the answer may grow large, the answer must be computed modulo 10^9 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 2, m = 3, k = 1
    +Output: 6
    +Explanation: The possible arrays are [1, 1], [2, 1], [2, 2], [3, 1], [3, 2] [3, 3]
    +
    + +

    Example 2:

    + +
    +Input: n = 5, m = 2, k = 3
    +Output: 0
    +Explanation: There are no possible arrays that satisify the mentioned conditions.
    +
    + +

    Example 3:

    + +
    +Input: n = 9, m = 1, k = 1
    +Output: 1
    +Explanation: The only possible array is [1, 1, 1, 1, 1, 1, 1, 1, 1]
    +
    + +

    Example 4:

    + +
    +Input: n = 50, m = 100, k = 25
    +Output: 34549172
    +Explanation: Don't forget to compute the answer modulo 1000000007
    +
    + +

    Example 5:

    + +
    +Input: n = 37, m = 17, k = 7
    +Output: 418930126
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 50
    • +
    • 1 <= m <= 100
    • +
    • 0 <= k <= n
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Use dynamic programming approach. Build dp table where dp[a][b][c] is the number of ways you can start building the array starting from index a where the search_cost = c and the maximum used integer was b. +
    + +
    +Hint 2 +Recursively, solve the small sub-problems first. Optimize your answer by stopping the search if you exceeded k changes. +
    diff --git a/problems/display-table-of-food-orders-in-a-restaurant/README.md b/problems/display-table-of-food-orders-in-a-restaurant/README.md new file mode 100644 index 000000000..31295dfe2 --- /dev/null +++ b/problems/display-table-of-food-orders-in-a-restaurant/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../reformat-the-string "Reformat The String") +                 +[Next >](../minimum-number-of-frogs-croaking "Minimum Number of Frogs Croaking") + +## [1418. Display Table of Food Orders in a Restaurant (Medium)](https://leetcode.com/problems/display-table-of-food-orders-in-a-restaurant "点菜展示表") + +

    Given the array orders, which represents the orders that customers have done in a restaurant. More specifically orders[i]=[customerNamei,tableNumberi,foodItemi] where customerNamei is the name of the customer, tableNumberi is the table customer sit at, and foodItemi is the item customer orders.

    + +

    Return the restaurant's “display table. The “display table” is a table whose row entries denote how many of each food item each table ordered. The first column is the table number and the remaining columns correspond to each food item in alphabetical order. The first row should be a header whose first column is “Table”, followed by the names of the food items. Note that the customer names are not part of the table. Additionally, the rows should be sorted in numerically increasing order.

    + +

     

    +

    Example 1:

    + +
    +Input: orders = [["David","3","Ceviche"],["Corina","10","Beef Burrito"],["David","3","Fried Chicken"],["Carla","5","Water"],["Carla","5","Ceviche"],["Rous","3","Ceviche"]]
    +Output: [["Table","Beef Burrito","Ceviche","Fried Chicken","Water"],["3","0","2","1","0"],["5","0","1","0","1"],["10","1","0","0","0"]] 
    +Explanation:
    +The displaying table looks like:
    +Table,Beef Burrito,Ceviche,Fried Chicken,Water
    +3    ,0           ,2      ,1            ,0
    +5    ,0           ,1      ,0            ,1
    +10   ,1           ,0      ,0            ,0
    +For the table 3: David orders "Ceviche" and "Fried Chicken", and Rous orders "Ceviche".
    +For the table 5: Carla orders "Water" and "Ceviche".
    +For the table 10: Corina orders "Beef Burrito". 
    +
    + +

    Example 2:

    + +
    +Input: orders = [["James","12","Fried Chicken"],["Ratesh","12","Fried Chicken"],["Amadeus","12","Fried Chicken"],["Adam","1","Canadian Waffles"],["Brianna","1","Canadian Waffles"]]
    +Output: [["Table","Canadian Waffles","Fried Chicken"],["1","2","0"],["12","0","3"]] 
    +Explanation: 
    +For the table 1: Adam and Brianna order "Canadian Waffles".
    +For the table 12: James, Ratesh and Amadeus order "Fried Chicken".
    +
    + +

    Example 3:

    + +
    +Input: orders = [["Laura","2","Bean Burrito"],["Jhon","2","Beef Burrito"],["Melissa","2","Soda"]]
    +Output: [["Table","Bean Burrito","Beef Burrito","Soda"],["2","1","1","1"]]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= orders.length <= 5 * 10^4
    • +
    • orders[i].length == 3
    • +
    • 1 <= customerNamei.length, foodItemi.length <= 20
    • +
    • customerNamei and foodItemi consist of lowercase and uppercase English letters and the space character.
    • +
    • tableNumberi is a valid integer between 1 and 500.
    • +
    + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +Keep the frequency of all pairs (tableNumber, foodItem) using a hashmap. +
    + +
    +Hint 2 +Sort rows by tableNumber and columns by foodItem, then process the resulted table. +
    diff --git a/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md b/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md new file mode 100644 index 000000000..5b96f49e9 --- /dev/null +++ b/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../minimum-value-to-get-positive-step-by-step-sum "Minimum Value to Get Positive Step by Step Sum") +                 +[Next >](../the-k-th-lexicographical-string-of-all-happy-strings-of-length-n "The k-th Lexicographical String of All Happy Strings of Length n") + +## [1414. Find the Minimum Number of Fibonacci Numbers Whose Sum Is K (Medium)](https://leetcode.com/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k "和为 K 的最少斐波那契数字数目") + +

    Given the number k, return the minimum number of Fibonacci numbers whose sum is equal to k, whether a Fibonacci number could be used multiple times.

    + +

    The Fibonacci numbers are defined as:

    + +
      +
    • F1 = 1
    • +
    • F2 = 1
    • +
    • Fn = Fn-1 + Fn-2 , for n > 2.
    • +
    +It is guaranteed that for the given constraints we can always find such fibonacci numbers that sum k. +

     

    +

    Example 1:

    + +
    +Input: k = 7
    +Output: 2 
    +Explanation: The Fibonacci numbers are: 1, 1, 2, 3, 5, 8, 13, ... 
    +For k = 7 we can use 2 + 5 = 7.
    + +

    Example 2:

    + +
    +Input: k = 10
    +Output: 2 
    +Explanation: For k = 10 we can use 2 + 8 = 10.
    +
    + +

    Example 3:

    + +
    +Input: k = 19
    +Output: 3 
    +Explanation: For k = 19 we can use 1 + 5 + 13 = 19.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= 10^9
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Generate all Fibonacci numbers up to the limit (they are few). +
    + +
    +Hint 2 +Use greedy solution, taking at every time the greatest Fibonacci number which is smaller than or equal to the current number. Subtract this Fibonacci number from the current number and repeat again the process. +
    diff --git a/problems/find-the-quiet-students-in-all-exams/README.md b/problems/find-the-quiet-students-in-all-exams/README.md new file mode 100644 index 000000000..c6be9f9ec --- /dev/null +++ b/problems/find-the-quiet-students-in-all-exams/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../number-of-ways-to-paint-n-3-grid "Number of Ways to Paint N × 3 Grid") +                 +[Next >](../minimum-value-to-get-positive-step-by-step-sum "Minimum Value to Get Positive Step by Step Sum") + +## [1412. Find the Quiet Students in All Exams (Hard)](https://leetcode.com/problems/find-the-quiet-students-in-all-exams "") + + diff --git a/problems/find-the-quiet-students-in-all-exams/mysql_schemas.sql b/problems/find-the-quiet-students-in-all-exams/mysql_schemas.sql new file mode 100644 index 000000000..66fe906ec --- /dev/null +++ b/problems/find-the-quiet-students-in-all-exams/mysql_schemas.sql @@ -0,0 +1,19 @@ +Create table If Not Exists Student (student_id int, student_name varchar(30)); +Create table If Not Exists Exam (exam_id int, student_id int, score int); +Truncate table Student; +insert into Student (student_id, student_name) values ('1', 'Daniel'); +insert into Student (student_id, student_name) values ('2', 'Jade'); +insert into Student (student_id, student_name) values ('3', 'Stella'); +insert into Student (student_id, student_name) values ('4', 'Jonathan'); +insert into Student (student_id, student_name) values ('5', 'Will'); +Truncate table Exam; +insert into Exam (exam_id, student_id, score) values ('10', '1', '70'); +insert into Exam (exam_id, student_id, score) values ('10', '2', '80'); +insert into Exam (exam_id, student_id, score) values ('10', '3', '90'); +insert into Exam (exam_id, student_id, score) values ('20', '1', '80'); +insert into Exam (exam_id, student_id, score) values ('30', '1', '70'); +insert into Exam (exam_id, student_id, score) values ('30', '3', '80'); +insert into Exam (exam_id, student_id, score) values ('30', '4', '90'); +insert into Exam (exam_id, student_id, score) values ('40', '1', '60'); +insert into Exam (exam_id, student_id, score) values ('40', '2', '70'); +insert into Exam (exam_id, student_id, score) values ('40', '4', '80'); diff --git a/problems/fizz-buzz/README.md b/problems/fizz-buzz/README.md index 89105359b..cae237242 100644 --- a/problems/fizz-buzz/README.md +++ b/problems/fizz-buzz/README.md @@ -39,6 +39,3 @@ Return: ]

    - -### Similar Questions - 1. [Fizz Buzz Multithreaded](../fizz-buzz-multithreaded) (Medium) diff --git a/problems/minimum-number-of-frogs-croaking/README.md b/problems/minimum-number-of-frogs-croaking/README.md new file mode 100644 index 000000000..94050c6c7 --- /dev/null +++ b/problems/minimum-number-of-frogs-croaking/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../display-table-of-food-orders-in-a-restaurant "Display Table of Food Orders in a Restaurant") +                 +[Next >](../build-array-where-you-can-find-the-maximum-exactly-k-comparisons "Build Array Where You Can Find The Maximum Exactly K Comparisons") + +## [1419. Minimum Number of Frogs Croaking (Medium)](https://leetcode.com/problems/minimum-number-of-frogs-croaking "数青蛙") + +

    Given the string croakOfFrogs, which represents a combination of the string "croak" from different frogs, that is, multiple frogs can croak at the same time, so multiple “croak” are mixed. Return the minimum number of different frogs to finish all the croak in the given string.

    + +

    A valid "croak" means a frog is printing 5 letters ‘c’, ’r’, ’o’, ’a’, ’k’ sequentially. The frogs have to print all five letters to finish a croak. If the given string is not a combination of valid "croak" return -1.

    + +

     

    +

    Example 1:

    + +
    +Input: croakOfFrogs = "croakcroak"
    +Output: 1 
    +Explanation: One frog yelling "croak" twice.
    +
    + +

    Example 2:

    + +
    +Input: croakOfFrogs = "crcoakroak"
    +Output: 2 
    +Explanation: The minimum number of frogs is two. 
    +The first frog could yell "crcoakroak".
    +The second frog could yell later "crcoakroak".
    +
    + +

    Example 3:

    + +
    +Input: croakOfFrogs = "croakcrook"
    +Output: -1
    +Explanation: The given string is an invalid combination of "croak" from different frogs.
    +
    + +

    Example 4:

    + +
    +Input: croakOfFrogs = "croakcroa"
    +Output: -1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= croakOfFrogs.length <= 10^5
    • +
    • All characters in the string are: 'c', 'r', 'o', 'a' or 'k'.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +keep the frequency of all characters from "croak" using a hashmap. +
    + +
    +Hint 2 +For each character in the given string, greedily match it to a possible "croak". +
    diff --git a/problems/minimum-value-to-get-positive-step-by-step-sum/README.md b/problems/minimum-value-to-get-positive-step-by-step-sum/README.md new file mode 100644 index 000000000..e4b21a71e --- /dev/null +++ b/problems/minimum-value-to-get-positive-step-by-step-sum/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../find-the-quiet-students-in-all-exams "Find the Quiet Students in All Exams") +                 +[Next >](../find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k "Find the Minimum Number of Fibonacci Numbers Whose Sum Is K") + +## [1413. Minimum Value to Get Positive Step by Step Sum (Easy)](https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum "逐步求和得到正数的最小值") + +

    Given an array of integers nums, you start with an initial positive value startValue.

    + +

    In each iteration, you calculate the step by step sum of startValue plus elements in nums (from left to right).

    + +

    Return the minimum positive value of startValue such that the step by step sum is never less than 1.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [-3,2,-3,4,2]
    +Output: 5
    +Explanation: If you choose startValue = 4, in the third iteration your step by step sum is less than 1.
    +                step by step sum
    +                startValue = 4 | startValue = 5 | nums
    +                  (4 -3 ) = 1  | (5 -3 ) = 2    |  -3
    +                  (1 +2 ) = 3  | (2 +2 ) = 4    |   2
    +                  (3 -3 ) = 0  | (4 -3 ) = 1    |  -3
    +                  (0 +4 ) = 4  | (1 +4 ) = 5    |   4
    +                  (4 +2 ) = 6  | (5 +2 ) = 7    |   2
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,2]
    +Output: 1
    +Explanation: Minimum start value should be positive. 
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,-2,-3]
    +Output: 5
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • -100 <= nums[i] <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Find the minimum prefix sum. +
    diff --git a/problems/number-of-ways-to-paint-n-3-grid/README.md b/problems/number-of-ways-to-paint-n-3-grid/README.md index c04492978..52b5ea05a 100644 --- a/problems/number-of-ways-to-paint-n-3-grid/README.md +++ b/problems/number-of-ways-to-paint-n-3-grid/README.md @@ -7,7 +7,7 @@ [< Previous](../html-entity-parser "HTML Entity Parser")                  -Next > +[Next >](../find-the-quiet-students-in-all-exams "Find the Quiet Students in All Exams") ## [1411. Number of Ways to Paint N × 3 Grid (Hard)](https://leetcode.com/problems/number-of-ways-to-paint-n-3-grid "给 N x 3 网格图涂色的方案数") diff --git a/problems/reformat-the-string/README.md b/problems/reformat-the-string/README.md new file mode 100644 index 000000000..77165ed14 --- /dev/null +++ b/problems/reformat-the-string/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../restore-the-array "Restore The Array") +                 +[Next >](../display-table-of-food-orders-in-a-restaurant "Display Table of Food Orders in a Restaurant") + +## [1417. Reformat The String (Easy)](https://leetcode.com/problems/reformat-the-string "重新格式化字符串") + +

    Given alphanumeric string s. (Alphanumeric string is a string consisting of lowercase English letters and digits).

    + +

    You have to find a permutation of the string where no letter is followed by another letter and no digit is followed by another digit. That is, no two adjacent characters have the same type.

    + +

    Return the reformatted string or return an empty string if it is impossible to reformat the string.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "a0b1c2"
    +Output: "0a1b2c"
    +Explanation: "0a1b2c" doesn't have any letter followed by digit or any digit followed by character. "a0b1c2", "0a1b2c", "0c2a1b" are also valid permutations.
    +
    + +

    Example 2:

    + +
    +Input: s = "leetcode"
    +Output: ""
    +Explanation: "leetcode" has only characters so we cannot separate them by digits.
    +
    + +

    Example 3:

    + +
    +Input: s = "1229857369"
    +Output: ""
    +Explanation: "1229857369" has only digits so we cannot separate them by characters.
    +
    + +

    Example 4:

    + +
    +Input: s = "covid2019"
    +Output: "c2o0v1i9d"
    +
    + +

    Example 5:

    + +
    +Input: s = "ab123"
    +Output: "1a2b3"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 500
    • +
    • s consists of only lowercase English letters and/or digits.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Count the number of letters and digits in the string. if cntLetters - cntDigits has any of the values [-1, 0, 1] we have an answer, otherwise we don't have any answer. +
    + +
    +Hint 2 +Build the string anyway as you wish. Keep in mind that you need to start with the type that have more characters if cntLetters ≠ cntDigits. +
    diff --git a/problems/restore-the-array/README.md b/problems/restore-the-array/README.md new file mode 100644 index 000000000..3276f9838 --- /dev/null +++ b/problems/restore-the-array/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../the-k-th-lexicographical-string-of-all-happy-strings-of-length-n "The k-th Lexicographical String of All Happy Strings of Length n") +                 +[Next >](../reformat-the-string "Reformat The String") + +## [1416. Restore The Array (Hard)](https://leetcode.com/problems/restore-the-array "恢复数组") + +

    A program was supposed to print an array of integers. The program forgot to print whitespaces and the array is printed as a string of digits and all we know is that all integers in the array were in the range [1, k] and there are no leading zeros in the array.

    + +

    Given the string s and the integer k. There can be multiple ways to restore the array.

    + +

    Return the number of possible array that can be printed as a string s using the mentioned program.

    + +

    The number of ways could be very large so return it modulo 10^9 + 7

    + +

     

    +

    Example 1:

    + +
    +Input: s = "1000", k = 10000
    +Output: 1
    +Explanation: The only possible array is [1000]
    +
    + +

    Example 2:

    + +
    +Input: s = "1000", k = 10
    +Output: 0
    +Explanation: There cannot be an array that was printed this way and has all integer >= 1 and <= 10.
    +
    + +

    Example 3:

    + +
    +Input: s = "1317", k = 2000
    +Output: 8
    +Explanation: Possible arrays are [1317],[131,7],[13,17],[1,317],[13,1,7],[1,31,7],[1,3,17],[1,3,1,7]
    +
    + +

    Example 4:

    + +
    +Input: s = "2020", k = 30
    +Output: 1
    +Explanation: The only possible array is [20,20]. [2020] is invalid because 2020 > 30. [2,020] is ivalid because 020 contains leading zeros.
    +
    + +

    Example 5:

    + +
    +Input: s = "1234567890", k = 90
    +Output: 34
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 10^5.
    • +
    • s consists of only digits and doesn't contain leading zeros.
    • +
    • 1 <= k <= 10^9.
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Use dynamic programming. Build an array dp where dp[i] is the number of ways you can divide the string starting from index i to the end. +
    + +
    +Hint 2 +Keep in mind that the answer is modulo 10^9 + 7 and take the mod for each operation. +
    diff --git a/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/README.md b/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/README.md new file mode 100644 index 000000000..391b6fcfd --- /dev/null +++ b/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k "Find the Minimum Number of Fibonacci Numbers Whose Sum Is K") +                 +[Next >](../restore-the-array "Restore The Array") + +## [1415. The k-th Lexicographical String of All Happy Strings of Length n (Medium)](https://leetcode.com/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n "长度为 n 的开心字符串中字典序第 k 小的字符串") + +

    A happy string is a string that:

    + +
      +
    • consists only of letters of the set ['a', 'b', 'c'].
    • +
    • s[i] != s[i + 1] for all values of i from 1 to s.length - 1 (string is 1-indexed).
    • +
    + +

    For example, strings "abc", "ac", "b" and "abcbabcbcb" are all happy strings and strings "aa", "baa" and "ababbc" are not happy strings.

    + +

    Given two integers n and k, consider a list of all happy strings of length n sorted in lexicographical order.

    + +

    Return the kth string of this list or return an empty string if there are less than k happy strings of length n.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 1, k = 3
    +Output: "c"
    +Explanation: The list ["a", "b", "c"] contains all happy strings of length 1. The third string is "c".
    +
    + +

    Example 2:

    + +
    +Input: n = 1, k = 4
    +Output: ""
    +Explanation: There are only 3 happy strings of length 1.
    +
    + +

    Example 3:

    + +
    +Input: n = 3, k = 9
    +Output: "cab"
    +Explanation: There are 12 different happy string of length 3 ["aba", "abc", "aca", "acb", "bab", "bac", "bca", "bcb", "cab", "cac", "cba", "cbc"]. You will find the 9th string = "cab"
    +
    + +

    Example 4:

    + +
    +Input: n = 2, k = 7
    +Output: ""
    +
    + +

    Example 5:

    + +
    +Input: n = 10, k = 100
    +Output: "abacbabacb"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 10
    • +
    • 1 <= k <= 100
    • +
    + +
     
    + +### Related Topics + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
    +Hint 1 +Generate recursively all the happy strings of length n. +
    + +
    +Hint 2 +Sort them in lexicographical order and return the kth string if it exists. +
    diff --git a/problems/top-travellers/README.md b/problems/top-travellers/README.md index d35e3c7f6..f5041022a 100644 --- a/problems/top-travellers/README.md +++ b/problems/top-travellers/README.md @@ -9,7 +9,7 @@                  [Next >](../string-matching-in-an-array "String Matching in an Array") -## [1407. Top Travellers (Easy)](https://leetcode.com/problems/top-travellers "") +## [1407. Top Travellers (Easy)](https://leetcode.com/problems/top-travellers "排名靠前的旅行者")

    Table: Users

    diff --git a/tag/array/README.md b/tag/array/README.md
    index b8cb5b418..9c3a0f06e 100644
    --- a/tag/array/README.md
    +++ b/tag/array/README.md
    @@ -9,6 +9,8 @@
     
     | # | 题目 | 标签 | 难度 |
     | :-: | - | - | :-: |
    +| 1414 | [和为 K 的最少斐波那契数字数目](../../problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)]  | Medium |
    +| 1413 | [逐步求和得到正数的最小值](../../problems/minimum-value-to-get-positive-step-by-step-sum) | [[数组](../array/README.md)]  | Easy |
     | 1409 | [查询带键的排列](../../problems/queries-on-a-permutation-with-key) | [[数组](../array/README.md)]  | Medium |
     | 1399 | [统计最大组的数目](../../problems/count-largest-group) | [[数组](../array/README.md)]  | Easy |
     | 1395 | [统计作战单位数](../../problems/count-number-of-teams) | [[数组](../array/README.md)]  | Medium |
    diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md
    index 919333086..86c2e7d88 100644
    --- a/tag/backtracking/README.md
    +++ b/tag/backtracking/README.md
    @@ -9,6 +9,7 @@
     
     | # | 题目 | 标签 | 难度 |
     | :-: | - | - | :-: |
    +| 1415 | [长度为 n 的开心字符串中字典序第 k 小的字符串](../../problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | [[回溯算法](../backtracking/README.md)]  | Medium |
     | 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)]  | Hard |
     | 1291 | [顺次数](../../problems/sequential-digits) | [[回溯算法](../backtracking/README.md)]  | Medium |
     | 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)]  | Medium |
    diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md
    index 213efd277..a0fd30ca1 100644
    --- a/tag/dynamic-programming/README.md
    +++ b/tag/dynamic-programming/README.md
    @@ -9,6 +9,8 @@
     
     | # | 题目 | 标签 | 难度 |
     | :-: | - | - | :-: |
    +| 1420 | [生成数组](../../problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons) | [[动态规划](../dynamic-programming/README.md)]  | Hard |
    +| 1416 | [恢复数组](../../problems/restore-the-array) | [[动态规划](../dynamic-programming/README.md)]  | Hard |
     | 1411 | [给 N x 3 网格图涂色的方案数](../../problems/number-of-ways-to-paint-n-x-3-grid) | [[动态规划](../dynamic-programming/README.md)]  | Hard |
     | 1406 | [石子游戏 III](../../problems/stone-game-iii) | [[动态规划](../dynamic-programming/README.md)]  | Hard |
     | 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)]  | Medium |
    diff --git a/tag/greedy/README.md b/tag/greedy/README.md
    index 4e436672e..548d29949 100644
    --- a/tag/greedy/README.md
    +++ b/tag/greedy/README.md
    @@ -9,6 +9,7 @@
     
     | # | 题目 | 标签 | 难度 |
     | :-: | - | - | :-: |
    +| 1414 | [和为 K 的最少斐波那契数字数目](../../problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)]  | Medium |
     | 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)]  | Medium |
     | 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)]  | Easy |
     | 1400 | [构造 K 个回文字符串](../../problems/construct-k-palindrome-strings) | [[贪心算法](../greedy/README.md)]  | Medium |
    diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md
    index 048244161..81fe5ca3a 100644
    --- a/tag/hash-table/README.md
    +++ b/tag/hash-table/README.md
    @@ -9,6 +9,7 @@
     
     | # | 题目 | 标签 | 难度 |
     | :-: | - | - | :-: |
    +| 1418 | [点菜展示表](../../problems/display-table-of-food-orders-in-a-restaurant) | [[哈希表](../hash-table/README.md)]  | Medium |
     | 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)]  | Easy |
     | 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)]  | Medium |
     | 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)]  | Medium |
    diff --git a/tag/string/README.md b/tag/string/README.md
    index 280fc9add..4e53dd7eb 100644
    --- a/tag/string/README.md
    +++ b/tag/string/README.md
    @@ -9,6 +9,8 @@
     
     | # | 题目 | 标签 | 难度 |
     | :-: | - | - | :-: |
    +| 1419 | [数青蛙](../../problems/minimum-number-of-frogs-croaking) | [[字符串](../string/README.md)]  | Medium |
    +| 1417 | [重新格式化字符串](../../problems/reformat-the-string) | [[字符串](../string/README.md)]  | Easy |
     | 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)]  | Medium |
     | 1408 | [数组中的字符串匹配](../../problems/string-matching-in-an-array) | [[字符串](../string/README.md)]  | Easy |
     | 1404 | [将二进制表示减到 1 的步骤数](../../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)]  | Medium |
    
    From c5e8b6b4b14d4ecacf8012fe0d8de095c739cd48 Mon Sep 17 00:00:00 2001
    From: Shuo 
    Date: Mon, 20 Apr 2020 16:19:51 +0800
    Subject: [PATCH 055/145] A: Longest Valid Parentheses
    
    ---
     internal/leetcode/problems_status.go          |  1 +
     .../longest_valid_parentheses.go              | 25 ++++++++++++++
     .../longest_valid_parentheses_test.go         | 34 +++++++++++++++++++
     3 files changed, 60 insertions(+)
    
    diff --git a/internal/leetcode/problems_status.go b/internal/leetcode/problems_status.go
    index bd5148f6e..fcf416ccd 100644
    --- a/internal/leetcode/problems_status.go
    +++ b/internal/leetcode/problems_status.go
    @@ -27,6 +27,7 @@ var problemStatus = map[int]bool{
     	26:   true,
     	27:   true,
     	28:   true,
    +	32:   true,
     	35:   true,
     	36:   true,
     	38:   true,
    diff --git a/problems/longest-valid-parentheses/longest_valid_parentheses.go b/problems/longest-valid-parentheses/longest_valid_parentheses.go
    index ab2725f32..304b1db42 100644
    --- a/problems/longest-valid-parentheses/longest_valid_parentheses.go
    +++ b/problems/longest-valid-parentheses/longest_valid_parentheses.go
    @@ -1 +1,26 @@
     package problem32
    +
    +func longestValidParentheses(s string) int {
    +	ans, l := 0, len(s)
    +	dp := make([]int, l)
    +	for i, c := range s {
    +		if i == 0 || c == '(' {
    +			continue
    +		}
    +		if s[i-1] == '(' {
    +			dp[i] = 2
    +			if i > 1 {
    +				dp[i] = dp[i-2] + 2
    +			}
    +		} else if i > dp[i-1] && s[i-1-dp[i-1]] == '(' {
    +			dp[i] = dp[i-1] + 2
    +			if i-1 > dp[i-1] {
    +				dp[i] += dp[i-2-dp[i-1]]
    +			}
    +		}
    +		if dp[i] > ans {
    +			ans = dp[i]
    +		}
    +	}
    +	return ans
    +}
    diff --git a/problems/longest-valid-parentheses/longest_valid_parentheses_test.go b/problems/longest-valid-parentheses/longest_valid_parentheses_test.go
    index ab2725f32..d77b2d465 100644
    --- a/problems/longest-valid-parentheses/longest_valid_parentheses_test.go
    +++ b/problems/longest-valid-parentheses/longest_valid_parentheses_test.go
    @@ -1 +1,35 @@
     package problem32
    +
    +import "testing"
    +
    +type testType struct {
    +	in   string
    +	want int
    +}
    +
    +func TestLongestValidParentheses(t *testing.T) {
    +	tests := [...]testType{
    +		{
    +			in:   "(()",
    +			want: 2,
    +		},
    +		{
    +			in:   ")()())",
    +			want: 4,
    +		},
    +		{
    +			in:   ")()())(())()(",
    +			want: 6,
    +		},
    +		{
    +			in:   "()(())",
    +			want: 6,
    +		},
    +	}
    +	for _, tt := range tests {
    +		got := longestValidParentheses(tt.in)
    +		if got != tt.want {
    +			t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want)
    +		}
    +	}
    +}
    
    From df037eb7faa8047295f9f7091f03e4be5b0a46b7 Mon Sep 17 00:00:00 2001
    From: Shuo 
    Date: Mon, 20 Apr 2020 16:22:22 +0800
    Subject: [PATCH 056/145] A: Longest Valid Parentheses
    
    ---
     problems/longest-valid-parentheses/longest_valid_parentheses.go | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/problems/longest-valid-parentheses/longest_valid_parentheses.go b/problems/longest-valid-parentheses/longest_valid_parentheses.go
    index 304b1db42..138fca601 100644
    --- a/problems/longest-valid-parentheses/longest_valid_parentheses.go
    +++ b/problems/longest-valid-parentheses/longest_valid_parentheses.go
    @@ -10,7 +10,7 @@ func longestValidParentheses(s string) int {
     		if s[i-1] == '(' {
     			dp[i] = 2
     			if i > 1 {
    -				dp[i] = dp[i-2] + 2
    +				dp[i] += dp[i-2]
     			}
     		} else if i > dp[i-1] && s[i-1-dp[i-1]] == '(' {
     			dp[i] = dp[i-1] + 2
    
    From ed1b98cefe00060391ed7d4712f88e19e4928561 Mon Sep 17 00:00:00 2001
    From: Shuo 
    Date: Wed, 22 Apr 2020 09:53:23 +0800
    Subject: [PATCH 057/145] A: Path Sum III
    
    ---
     internal/leetcode/problems_status.go       |  1 +
     problems/path-sum-iii/path_sum_iii.go      | 32 ++++++++++++++++++++++
     problems/path-sum-iii/path_sum_iii_test.go | 29 ++++++++++++++++++++
     3 files changed, 62 insertions(+)
    
    diff --git a/internal/leetcode/problems_status.go b/internal/leetcode/problems_status.go
    index fcf416ccd..edd5b8c49 100644
    --- a/internal/leetcode/problems_status.go
    +++ b/internal/leetcode/problems_status.go
    @@ -113,6 +113,7 @@ var problemStatus = map[int]bool{
     	414:  true,
     	415:  true,
     	434:  true,
    +	437:  true,
     	441:  true,
     	443:  true,
     	445:  true,
    diff --git a/problems/path-sum-iii/path_sum_iii.go b/problems/path-sum-iii/path_sum_iii.go
    index 8efa1554a..cdc1542d6 100644
    --- a/problems/path-sum-iii/path_sum_iii.go
    +++ b/problems/path-sum-iii/path_sum_iii.go
    @@ -1 +1,33 @@
     package problem437
    +
    +import "github.com/openset/leetcode/internal/kit"
    +
    +// TreeNode - Definition for a binary tree node.
    +type TreeNode = kit.TreeNode
    +
    +/**
    + * Definition for a binary tree node.
    + * type TreeNode struct {
    + *     Val int
    + *     Left *TreeNode
    + *     Right *TreeNode
    + * }
    + */
    +func pathSum(root *TreeNode, sum int) int {
    +	if root == nil {
    +		return 0
    +	}
    +	return findPath(root, sum) + pathSum(root.Left, sum) + pathSum(root.Right, sum)
    +}
    +
    +func findPath(root *TreeNode, sum int) int {
    +	r := 0
    +	if root == nil {
    +		return 0
    +	} else if root.Val == sum {
    +		r++
    +	}
    +	r += findPath(root.Left, sum-root.Val)
    +	r += findPath(root.Right, sum-root.Val)
    +	return r
    +}
    diff --git a/problems/path-sum-iii/path_sum_iii_test.go b/problems/path-sum-iii/path_sum_iii_test.go
    index 8efa1554a..6a28bf338 100644
    --- a/problems/path-sum-iii/path_sum_iii_test.go
    +++ b/problems/path-sum-iii/path_sum_iii_test.go
    @@ -1 +1,30 @@
     package problem437
    +
    +import (
    +	"testing"
    +
    +	"github.com/openset/leetcode/internal/kit"
    +)
    +
    +type testType struct {
    +	in   []int
    +	sum  int
    +	want int
    +}
    +
    +func TestPathSum(t *testing.T) {
    +	tests := [...]testType{
    +		{
    +			in:   []int{10, 5, -3, 3, 2, kit.NULL, 11, 3, -2, kit.NULL, 1},
    +			sum:  8,
    +			want: 3,
    +		},
    +	}
    +	for _, tt := range tests {
    +		root := kit.SliceInt2TreeNode(tt.in)
    +		got := pathSum(root, tt.sum)
    +		if got != tt.want {
    +			t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want)
    +		}
    +	}
    +}
    
    From d814bd98835ed10c2a8fec5546e332d6d4435b49 Mon Sep 17 00:00:00 2001
    From: Shuo 
    Date: Mon, 27 Apr 2020 09:06:14 +0800
    Subject: [PATCH 058/145] A: Path Sum III
    
    ---
     README.md                                     |  5 ++
     .../README.md                                 |  3 +-
     .../README.md                                 |  2 +-
     problems/constrained-subset-sum/README.md     | 73 ++++++++++++++++
     problems/design-underground-system/README.md  |  4 +-
     problems/diagonal-traverse-ii/README.md       | 71 ++++++++++++++++
     problems/long-pressed-name/README.md          | 50 ++++-------
     .../README.md                                 | 85 +++++++++++++++++++
     .../README.md                                 | 68 +++++++++++++++
     problems/min-stack/README.md                  | 22 +++--
     .../README.md                                 |  2 +-
     problems/npv-queries/README.md                | 14 +++
     problems/npv-queries/mysql_schemas.sql        | 19 +++++
     problems/reformat-the-string/README.md        |  2 +-
     problems/replace-words/README.md              | 21 ++---
     problems/restore-ip-addresses/README.md       |  2 +
     problems/top-k-frequent-elements/README.md    |  2 +
     readme/601-900.md                             |  2 +-
     tag/breadth-first-search/README.md            |  1 +
     tag/depth-first-search/README.md              |  1 +
     tag/hash-table/README.md                      |  1 -
     tag/recursion/README.md                       |  2 +-
     tag/tree/README.md                            |  2 +-
     23 files changed, 393 insertions(+), 61 deletions(-)
     create mode 100644 problems/constrained-subset-sum/README.md
     create mode 100644 problems/diagonal-traverse-ii/README.md
     create mode 100644 problems/maximum-points-you-can-obtain-from-cards/README.md
     create mode 100644 problems/maximum-score-after-splitting-a-string/README.md
     create mode 100644 problems/npv-queries/README.md
     create mode 100644 problems/npv-queries/mysql_schemas.sql
    
    diff --git a/README.md b/README.md
    index 504588346..b651a20e8 100644
    --- a/README.md
    +++ b/README.md
    @@ -62,6 +62,11 @@ LeetCode Problems' Solutions
     
     | # | Title | Solution | Difficulty |
     | :-: | - | - | :-: |
    +| 1425 | [Constrained Subset Sum](https://leetcode.com/problems/constrained-subset-sum "带限制的子序列和") | [Go](problems/constrained-subset-sum) | Hard |
    +| 1424 | [Diagonal Traverse II](https://leetcode.com/problems/diagonal-traverse-ii "对角线遍历 II") | [Go](problems/diagonal-traverse-ii) | Medium |
    +| 1423 | [Maximum Points You Can Obtain from Cards](https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards "可获得的最大点数") | [Go](problems/maximum-points-you-can-obtain-from-cards) | Medium |
    +| 1422 | [Maximum Score After Splitting a String](https://leetcode.com/problems/maximum-score-after-splitting-a-string "分割字符串的最大得分") | [Go](problems/maximum-score-after-splitting-a-string) | Easy |
    +| 1421 | [NPV Queries](https://leetcode.com/problems/npv-queries) 🔒 | [MySQL](problems/npv-queries) | Medium |
     | 1420 | [Build Array Where You Can Find The Maximum Exactly K Comparisons](https://leetcode.com/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons "生成数组") | [Go](problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons) | Hard |
     | 1419 | [Minimum Number of Frogs Croaking](https://leetcode.com/problems/minimum-number-of-frogs-croaking "数青蛙") | [Go](problems/minimum-number-of-frogs-croaking) | Medium |
     | 1418 | [Display Table of Food Orders in a Restaurant](https://leetcode.com/problems/display-table-of-food-orders-in-a-restaurant "点菜展示表") | [Go](problems/display-table-of-food-orders-in-a-restaurant) | Medium |
    diff --git a/problems/binary-tree-vertical-order-traversal/README.md b/problems/binary-tree-vertical-order-traversal/README.md
    index 0b3a26f4c..90197094e 100644
    --- a/problems/binary-tree-vertical-order-traversal/README.md
    +++ b/problems/binary-tree-vertical-order-traversal/README.md
    @@ -90,7 +90,8 @@
     
    ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions 1. [Binary Tree Level Order Traversal](../binary-tree-level-order-traversal) (Medium) diff --git a/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/README.md b/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/README.md index 588219043..9b129e918 100644 --- a/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/README.md +++ b/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/README.md @@ -7,7 +7,7 @@ [< Previous](../minimum-number-of-frogs-croaking "Minimum Number of Frogs Croaking")                  -Next > +[Next >](../npv-queries "NPV Queries") ## [1420. Build Array Where You Can Find The Maximum Exactly K Comparisons (Hard)](https://leetcode.com/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons "生成数组") diff --git a/problems/constrained-subset-sum/README.md b/problems/constrained-subset-sum/README.md new file mode 100644 index 000000000..3a5366d9a --- /dev/null +++ b/problems/constrained-subset-sum/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../diagonal-traverse-ii "Diagonal Traverse II") +                 +Next > + +## [1425. Constrained Subset Sum (Hard)](https://leetcode.com/problems/constrained-subset-sum "带限制的子序列和") + +

    Given an integer array nums and an integer k, return the maximum sum of a non-empty subset of that array such that for every two consecutive integers in the subset, nums[i] and nums[j], where i < j, the condition j - i <= k is satisfied.

    + +

    subset of an array is obtained by deleting some number of elements (can be zero) from the array, leaving the remaining elements in their original order.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [10,2,-10,5,20], k = 2
    +Output: 37
    +Explanation: The subset is [10, 2, 5, 20].
    +
    + +

    Example 2:

    + +
    +Input: nums = [-1,-2,-3], k = 1
    +Output: -1
    +Explanation: The subset must be non-empty, so we choose the largest number.
    +
    + +

    Example 3:

    + +
    +Input: nums = [10,-2,-10,-5,20], k = 2
    +Output: 23
    +Explanation: The subset is [10, -2, -5, 20].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= nums.length <= 10^5
    • +
    • -10^4 <= nums[i] <= 10^4
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Use dynamic programming. +
    + +
    +Hint 2 +Let dp[i] be the solution for the prefix of the array that ends at index i, if the element at index i is in the subset. +
    + +
    +Hint 3 +dp[i] = nums[i] + max(0, dp[i-k], dp[i-k+1], ..., dp[i-1]) +
    + +
    +Hint 4 +Use a heap with the sliding window technique to optimize the dp. +
    diff --git a/problems/design-underground-system/README.md b/problems/design-underground-system/README.md index f834f1cad..18ab2eb5a 100644 --- a/problems/design-underground-system/README.md +++ b/problems/design-underground-system/README.md @@ -38,9 +38,9 @@

     

    Example 1:

    -Input
    +Input
     ["UndergroundSystem","checkIn","checkIn","checkIn","checkOut","checkOut","checkOut","getAverageTime","getAverageTime","checkIn","getAverageTime","checkOut","getAverageTime"]
     [[],[45,"Leyton",3],[32,"Paradise",8],[27,"Leyton",10],[45,"Waterloo",15],[27,"Waterloo",20],[32,"Cambridge",22],["Paradise","Cambridge"],["Leyton","Waterloo"],[10,"Leyton",24],["Leyton","Waterloo"],[10,"Waterloo",38],["Leyton","Waterloo"]]
     
    @@ -64,9 +64,9 @@ undergroundSystem.getAverageTime("Leyton", "Waterloo"); &nbs
     

    Example 2:

    -Input
    +Input
     ["UndergroundSystem","checkIn","checkOut","getAverageTime","checkIn","checkOut","getAverageTime","checkIn","checkOut","getAverageTime"]
     [[],[10,"Leyton",3],[10,"Paradise",8],["Leyton","Paradise"],[5,"Leyton",10],[5,"Paradise",16],["Leyton","Paradise"],[2,"Leyton",21],[2,"Paradise",30],["Leyton","Paradise"]]
     
    diff --git a/problems/diagonal-traverse-ii/README.md b/problems/diagonal-traverse-ii/README.md
    new file mode 100644
    index 000000000..d856f64d7
    --- /dev/null
    +++ b/problems/diagonal-traverse-ii/README.md
    @@ -0,0 +1,71 @@
    +
    +
    +
    +
    +
    +
    +
    +[< Previous](../maximum-points-you-can-obtain-from-cards "Maximum Points You Can Obtain from Cards")
    +                
    +[Next >](../constrained-subset-sum "Constrained Subset Sum")
    +
    +## [1424. Diagonal Traverse II (Medium)](https://leetcode.com/problems/diagonal-traverse-ii "对角线遍历 II")
    +
    +Given a list of lists of integers, nums, return all elements of nums in diagonal order as shown in the below images.
    +

     

    +

    Example 1:

    + +

    + +
    +Input: nums = [[1,2,3],[4,5,6],[7,8,9]]
    +Output: [1,4,2,7,5,3,8,6,9]
    +
    + +

    Example 2:

    + +

    + +
    +Input: nums = [[1,2,3,4,5],[6,7],[8],[9,10,11],[12,13,14,15,16]]
    +Output: [1,6,2,8,7,3,9,4,12,10,5,13,11,14,15,16]
    +
    + +

    Example 3:

    + +
    +Input: nums = [[1,2,3],[4],[5,6,7],[8],[9,10,11]]
    +Output: [1,4,2,5,3,8,6,9,7,10,11]
    +
    + +

    Example 4:

    + +
    +Input: nums = [[1,2,3,4,5,6]]
    +Output: [1,2,3,4,5,6]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 10^5
    • +
    • 1 <= nums[i].length <= 10^5
    • +
    • 1 <= nums[i][j] <= 10^9
    • +
    • There at most 10^5 elements in nums.
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Notice that numbers with equal sums of row and column indexes belong to the same diagonal. +
    + +
    +Hint 2 +Store them in tuples (sum, row, val), sort them, and then regroup the answer. +
    diff --git a/problems/long-pressed-name/README.md b/problems/long-pressed-name/README.md index 835dcfa2e..41ab868d8 100644 --- a/problems/long-pressed-name/README.md +++ b/problems/long-pressed-name/README.md @@ -16,63 +16,45 @@

    You examine the typed characters of the keyboard.  Return True if it is possible that it was your friends name, with some characters (possibly none) being long pressed.

     

    -

    Example 1:

    -Input: name = "alex", typed = "aaleex"
    -Output: true
    -Explanation: 'a' and 'e' in 'alex' were long pressed.
    +Input: name = "alex", typed = "aaleex"
    +Output: true
    +Explanation: 'a' and 'e' in 'alex' were long pressed.
     
    -

    Example 2:

    -Input: name = "saeed", typed = "ssaaedd"
    -Output: false
    -Explanation: 'e' must have been pressed twice, but it wasn't in the typed output.
    +Input: name = "saeed", typed = "ssaaedd"
    +Output: false
    +Explanation: 'e' must have been pressed twice, but it wasn't in the typed output.
     
    -

    Example 3:

    -Input: name = "leelee", typed = "lleeelee"
    -Output: true
    +Input: name = "leelee", typed = "lleeelee"
    +Output: true
     
    -

    Example 4:

    -Input: name = "laiden", typed = "laiden"
    -Output: true
    -Explanation: It's not necessary to long press any character.
    +Input: name = "laiden", typed = "laiden"
    +Output: true
    +Explanation: It's not necessary to long press any character.
     

     

    -
    -
    -
    - -

    Note:

    +

    Constraints:

    -
      -
    1. name.length <= 1000
    2. -
    3. typed.length <= 1000
    4. +
        +
      • 1 <= name.length <= 1000
      • +
      • 1 <= typed.length <= 1000
      • The characters of name and typed are lowercase letters.
      • -
    - -
    -

     

    - -
    -
    -
     
    -
    -
    -
    + ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/maximum-points-you-can-obtain-from-cards/README.md b/problems/maximum-points-you-can-obtain-from-cards/README.md new file mode 100644 index 000000000..586217ad0 --- /dev/null +++ b/problems/maximum-points-you-can-obtain-from-cards/README.md @@ -0,0 +1,85 @@ + + + + + + + +[< Previous](../maximum-score-after-splitting-a-string "Maximum Score After Splitting a String") +                 +[Next >](../diagonal-traverse-ii "Diagonal Traverse II") + +## [1423. Maximum Points You Can Obtain from Cards (Medium)](https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards "可获得的最大点数") + +

    There are several cards arranged in a row, and each card has an associated number of points The points are given in the integer array cardPoints.

    + +

    In one step, you can take one card from the beginning or from the end of the row. You have to take exactly k cards.

    + +

    Your score is the sum of the points of the cards you have taken.

    + +

    Given the integer array cardPoints and the integer k, return the maximum score you can obtain.

    + +

     

    +

    Example 1:

    + +
    +Input: cardPoints = [1,2,3,4,5,6,1], k = 3
    +Output: 12
    +Explanation: After the first step, your score will always be 1. However, choosing the rightmost card first will maximize your total score. The optimal strategy is to take the three cards on the right, giving a final score of 1 + 6 + 5 = 12.
    +
    + +

    Example 2:

    + +
    +Input: cardPoints = [2,2,2], k = 2
    +Output: 4
    +Explanation: Regardless of which two cards you take, your score will always be 4.
    +
    + +

    Example 3:

    + +
    +Input: cardPoints = [9,7,7,9,7,7,9], k = 7
    +Output: 55
    +Explanation: You have to take all the cards. Your score is the sum of points of all cards.
    +
    + +

    Example 4:

    + +
    +Input: cardPoints = [1,1000,1], k = 1
    +Output: 1
    +Explanation: You cannot take the card in the middle. Your best score is 1. 
    +
    + +

    Example 5:

    + +
    +Input: cardPoints = [1,79,80,1,1,1,200,1], k = 3
    +Output: 202
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= cardPoints.length <= 10^5
    • +
    • 1 <= cardPoints[i] <= 10^4
    • +
    • 1 <= k <= cardPoints.length
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
    +Hint 1 +Let the sum of all points be total_pts. You need to remove a sub-array from cardPoints with length n - k. +
    + +
    +Hint 2 +Keep a window of size n - k over the array. The answer is max(answer, total_pts - sumOfCurrentWindow) +
    diff --git a/problems/maximum-score-after-splitting-a-string/README.md b/problems/maximum-score-after-splitting-a-string/README.md new file mode 100644 index 000000000..3fd031b1f --- /dev/null +++ b/problems/maximum-score-after-splitting-a-string/README.md @@ -0,0 +1,68 @@ + + + + + + + +[< Previous](../npv-queries "NPV Queries") +                 +[Next >](../maximum-points-you-can-obtain-from-cards "Maximum Points You Can Obtain from Cards") + +## [1422. Maximum Score After Splitting a String (Easy)](https://leetcode.com/problems/maximum-score-after-splitting-a-string "分割字符串的最大得分") + +

    Given a string s of zeros and ones, return the maximum score after splitting the string into two non-empty substrings (i.e. left substring and right substring).

    + +

    The score after splitting a string is the number of zeros in the left substring plus the number of ones in the right substring.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "011101"
    +Output: 5 
    +Explanation: 
    +All possible ways of splitting s into two non-empty substrings are:
    +left = "0" and right = "11101", score = 1 + 4 = 5 
    +left = "01" and right = "1101", score = 1 + 3 = 4 
    +left = "011" and right = "101", score = 1 + 2 = 3 
    +left = "0111" and right = "01", score = 1 + 1 = 2 
    +left = "01110" and right = "1", score = 2 + 1 = 3
    +
    + +

    Example 2:

    + +
    +Input: s = "00111"
    +Output: 5
    +Explanation: When left = "00" and right = "111", we get the maximum score = 2 + 3 = 5
    +
    + +

    Example 3:

    + +
    +Input: s = "1111"
    +Output: 3
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= s.length <= 500
    • +
    • The string s consists of characters '0' and '1' only.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Precompute a prefix sum of ones ('1'). +
    + +
    +Hint 2 +Iterate from left to right counting the number of zeros ('0'), then use the precomputed prefix sum for counting ones ('1'). Update the answer. +
    diff --git a/problems/min-stack/README.md b/problems/min-stack/README.md index 769278c94..337b2bb83 100644 --- a/problems/min-stack/README.md +++ b/problems/min-stack/README.md @@ -21,21 +21,33 @@

     

    - -

    Example:

    +

    Example 1:

    +Input
    +["MinStack","push","push","push","getMin","pop","top","getMin"]
    +[[],[-2],[0],[-3],[],[],[],[]]
    +
    +Output
    +[null,null,null,null,-3,null,0,-2]
    +
    +Explanation
     MinStack minStack = new MinStack();
     minStack.push(-2);
     minStack.push(0);
     minStack.push(-3);
    -minStack.getMin();   --> Returns -3.
    +minStack.getMin(); // return -3
     minStack.pop();
    -minStack.top();      --> Returns 0.
    -minStack.getMin();   --> Returns -2.
    +minStack.top();    // return 0
    +minStack.getMin(); // return -2
     

     

    +

    Constraints:

    + +
      +
    • Methods pop, top and getMin operations will always be called on non-empty stacks.
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/minimum-distance-between-bst-nodes/README.md b/problems/minimum-distance-between-bst-nodes/README.md index 04bba7d41..be7bc9ceb 100644 --- a/problems/minimum-distance-between-bst-nodes/README.md +++ b/problems/minimum-distance-between-bst-nodes/README.md @@ -9,7 +9,7 @@                  [Next >](../letter-case-permutation "Letter Case Permutation") -## [783. Minimum Distance Between BST Nodes (Easy)](https://leetcode.com/problems/minimum-distance-between-bst-nodes "二叉搜索树结点最小距离") +## [783. Minimum Distance Between BST Nodes (Easy)](https://leetcode.com/problems/minimum-distance-between-bst-nodes "二叉搜索树节点最小距离")

    Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the values of any two different nodes in the tree.

    diff --git a/problems/npv-queries/README.md b/problems/npv-queries/README.md new file mode 100644 index 000000000..add374f2c --- /dev/null +++ b/problems/npv-queries/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../build-array-where-you-can-find-the-maximum-exactly-k-comparisons "Build Array Where You Can Find The Maximum Exactly K Comparisons") +                 +[Next >](../maximum-score-after-splitting-a-string "Maximum Score After Splitting a String") + +## [1421. NPV Queries (Medium)](https://leetcode.com/problems/npv-queries "") + + diff --git a/problems/npv-queries/mysql_schemas.sql b/problems/npv-queries/mysql_schemas.sql new file mode 100644 index 000000000..0ad1de8aa --- /dev/null +++ b/problems/npv-queries/mysql_schemas.sql @@ -0,0 +1,19 @@ +Create Table If Not Exists NPV (id int, year int, npv int); +Create Table If Not Exists Queries (id int, year int); +Truncate table NPV; +insert into NPV (id, year, npv) values ('1', '2018', '100'); +insert into NPV (id, year, npv) values ('7', '2020', '30'); +insert into NPV (id, year, npv) values ('13', '2019', '40'); +insert into NPV (id, year, npv) values ('1', '2019', '113'); +insert into NPV (id, year, npv) values ('2', '2008', '121'); +insert into NPV (id, year, npv) values ('3', '2009', '21'); +insert into NPV (id, year, npv) values ('11', '2020', '99'); +insert into NPV (id, year, npv) values ('7', '2019', '0'); +Truncate table Queries; +insert into Queries (id, year) values ('1', '2019'); +insert into Queries (id, year) values ('2', '2008'); +insert into Queries (id, year) values ('3', '2009'); +insert into Queries (id, year) values ('7', '2018'); +insert into Queries (id, year) values ('7', '2019'); +insert into Queries (id, year) values ('7', '2020'); +insert into Queries (id, year) values ('13', '2019'); diff --git a/problems/reformat-the-string/README.md b/problems/reformat-the-string/README.md index 77165ed14..9b928f238 100644 --- a/problems/reformat-the-string/README.md +++ b/problems/reformat-the-string/README.md @@ -23,7 +23,7 @@
     Input: s = "a0b1c2"
     Output: "0a1b2c"
    -Explanation: "0a1b2c" doesn't have any letter followed by digit or any digit followed by character. "a0b1c2", "0a1b2c", "0c2a1b" are also valid permutations.
    +Explanation: No two adjacent characters have the same type in "0a1b2c". "a0b1c2", "0a1b2c", "0c2a1b" are also valid permutations.
     

    Example 2:

    diff --git a/problems/replace-words/README.md b/problems/replace-words/README.md index 7a3419aff..28c1950e0 100644 --- a/problems/replace-words/README.md +++ b/problems/replace-words/README.md @@ -17,27 +17,24 @@

    You need to output the sentence after the replacement.

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input: dict = ["cat", "bat", "rat"]
    -sentence = "the cattle was rattled by the battery"
    -Output: "the cat was rat by the bat"
    +Input: dict = ["cat","bat","rat"], sentence = "the cattle was rattled by the battery"
    +Output: "the cat was rat by the bat"
     

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • The input will only have lower-case letters.
      • -
      • 1 <= dict words number <= 1000
      • +
      • 1 <= dict.length <= 1000
      • +
      • 1 <= dict[i].length <= 100
      • 1 <= sentence words number <= 1000
      • -
      • 1 <= root length <= 100
      • 1 <= sentence words length <= 1000
      • -
    - -

     

    + ### Related Topics [[Trie](../../tag/trie/README.md)] diff --git a/problems/restore-ip-addresses/README.md b/problems/restore-ip-addresses/README.md index 4c4d9ac8a..7f44a6fd7 100644 --- a/problems/restore-ip-addresses/README.md +++ b/problems/restore-ip-addresses/README.md @@ -13,6 +13,8 @@

    Given a string containing only digits, restore it by returning all possible valid IP address combinations.

    +

    A valid IP address consists of exactly four integers (each integer is between 0 and 255) separated by single points.

    +

    Example:

    diff --git a/problems/top-k-frequent-elements/README.md b/problems/top-k-frequent-elements/README.md
    index 50a0ec65b..0ad927e36 100644
    --- a/problems/top-k-frequent-elements/README.md
    +++ b/problems/top-k-frequent-elements/README.md
    @@ -33,6 +33,8 @@
     
    • You may assume k is always valid, 1 ≤ k ≤ number of unique elements.
    • Your algorithm's time complexity must be better than O(n log n), where n is the array's size.
    • +
    • It's guaranteed that the answer is unique, in other words the set of the top k frequent elements is unique.
    • +
    • You can return the answer in any order.
    ### Related Topics diff --git a/readme/601-900.md b/readme/601-900.md index 3c770adcd..fbce6aef4 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -244,7 +244,7 @@ LeetCode Problems' Solutions | 780 | [Reaching Points](https://leetcode.com/problems/reaching-points "到达终点") | [Go](../problems/reaching-points) | Hard | | 781 | [Rabbits in Forest](https://leetcode.com/problems/rabbits-in-forest "森林中的兔子") | [Go](../problems/rabbits-in-forest) | Medium | | 782 | [Transform to Chessboard](https://leetcode.com/problems/transform-to-chessboard "变为棋盘") | [Go](../problems/transform-to-chessboard) | Hard | -| 783 | [Minimum Distance Between BST Nodes](https://leetcode.com/problems/minimum-distance-between-bst-nodes "二叉搜索树结点最小距离") | [Go](../problems/minimum-distance-between-bst-nodes) | Easy | +| 783 | [Minimum Distance Between BST Nodes](https://leetcode.com/problems/minimum-distance-between-bst-nodes "二叉搜索树节点最小距离") | [Go](../problems/minimum-distance-between-bst-nodes) | Easy | | 784 | [Letter Case Permutation](https://leetcode.com/problems/letter-case-permutation "字母大小写全排列") | [Go](../problems/letter-case-permutation) | Easy | | 785 | [Is Graph Bipartite?](https://leetcode.com/problems/is-graph-bipartite "判断二分图") | [Go](../problems/is-graph-bipartite) | Medium | | 786 | [K-th Smallest Prime Fraction](https://leetcode.com/problems/k-th-smallest-prime-fraction "第 K 个最小的素数分数") | [Go](../problems/k-th-smallest-prime-fraction) | Hard | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 5e5fc4b65..2202bebdf 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -58,6 +58,7 @@ | 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 317 | [离建筑物最近的距离](../../problems/shortest-distance-from-all-buildings) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 310 | [最小高度树](../../problems/minimum-height-trees) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 301 | [删除无效的括号](../../problems/remove-invalid-parentheses) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 286 | [墙与门](../../problems/walls-and-gates) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 94c7ef128..c58017106 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -102,6 +102,7 @@ | 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | | 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 301 | [删除无效的括号](../../problems/remove-invalid-parentheses) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 81fe5ca3a..2a1714f20 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -100,7 +100,6 @@ | 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 325 | [和等于 k 的最长子数组长度](../../problems/maximum-size-subarray-sum-equals-k) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | -| 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | | 311 | [稀疏矩阵的乘法](../../problems/sparse-matrix-multiplication) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | | 299 | [猜数字游戏](../../problems/bulls-and-cows) | [[哈希表](../hash-table/README.md)] | Easy | | 290 | [单词规律](../../problems/word-pattern) | [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index d2c3bb17d..542c1e35b 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -13,7 +13,7 @@ | 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | | 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 783 | [二叉搜索树结点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | +| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | | 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[递归](../recursion/README.md)] | Medium | | 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | diff --git a/tag/tree/README.md b/tag/tree/README.md index 8e5a8ad97..af1c23a9e 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -50,7 +50,7 @@ | 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | | 814 | [二叉树剪枝](../../problems/binary-tree-pruning) | [[树](../tree/README.md)] | Medium | -| 783 | [二叉搜索树结点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | +| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | | 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 742 | [二叉树最近的叶节点](../../problems/closest-leaf-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | | 701 | [二叉搜索树中的插入操作](../../problems/insert-into-a-binary-search-tree) | [[树](../tree/README.md)] | Medium | From 66970cade3643b6d4f9bc79b53ccf0a699123c62 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 27 Apr 2020 09:29:53 +0800 Subject: [PATCH 059/145] U: Mkdir --- internal/base/base.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/base/base.go b/internal/base/base.go index 38e622d8d..79657f50e 100644 --- a/internal/base/base.go +++ b/internal/base/base.go @@ -114,9 +114,8 @@ func AuthInfo(cmd string) string { func getFilePath(filename string) string { if dir := filepath.Dir(filename); dir != "" { - if err := os.MkdirAll(dir, 0755); err != nil { - CheckErr(err) - } + err := os.MkdirAll(dir, 0755) + CheckErr(err) } return filename } From 4ceac4287daf9a8ce9facdc79dcbccb50059a9a4 Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 6 May 2020 09:16:51 +0800 Subject: [PATCH 060/145] A: new --- README.md | 16 +++- .../README.md | 60 +++++++++++++ .../README.md | 28 ++++++ .../README.md | 66 ++++++++++++++ .../constrained-subsequence-sum/README.md | 73 +++++++++++++++ .../README.md | 10 +-- problems/counting-elements/README.md | 28 ++++++ problems/create-a-session-bar-chart/README.md | 14 +++ .../mysql_schemas.sql | 7 ++ problems/destination-city/README.md | 70 +++++++++++++++ problems/diagonal-traverse-ii/README.md | 2 +- .../README.md | 69 +++++++++++++++ problems/first-unique-number/README.md | 34 +++++++ problems/jump-game/README.md | 16 +++- .../README.md | 63 +++++++++++++ .../README.md | 28 ++++++ .../README.md | 75 ++++++++++++++++ .../README.md | 88 +++++++++++++++++++ .../README.md | 80 +++++++++++++++++ problems/ones-and-zeroes/README.md | 38 ++++---- problems/perform-string-shifts/README.md | 29 ++++++ problems/remove-boxes/README.md | 42 +++++---- problems/rotate-array/README.md | 28 ++++-- tag/array/README.md | 8 ++ tag/bit-manipulation/README.md | 1 + tag/design/README.md | 1 + tag/dynamic-programming/README.md | 3 + tag/greedy/README.md | 1 + tag/hash-table/README.md | 1 + tag/heap/README.md | 1 + tag/math/README.md | 1 + tag/sliding-window/README.md | 2 + tag/sort/README.md | 1 + tag/string/README.md | 4 + tag/tree/README.md | 1 + 35 files changed, 925 insertions(+), 64 deletions(-) create mode 100644 problems/check-if-a-string-can-break-another-string/README.md create mode 100644 problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/README.md create mode 100644 problems/check-if-all-1s-are-at-least-length-k-places-away/README.md create mode 100644 problems/constrained-subsequence-sum/README.md create mode 100644 problems/counting-elements/README.md create mode 100644 problems/create-a-session-bar-chart/README.md create mode 100644 problems/create-a-session-bar-chart/mysql_schemas.sql create mode 100644 problems/destination-city/README.md create mode 100644 problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md create mode 100644 problems/first-unique-number/README.md create mode 100644 problems/kids-with-the-greatest-number-of-candies/README.md create mode 100644 problems/leftmost-column-with-at-least-a-one/README.md create mode 100644 problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md create mode 100644 problems/max-difference-you-can-get-from-changing-an-integer/README.md create mode 100644 problems/number-of-ways-to-wear-different-hats-to-each-other/README.md create mode 100644 problems/perform-string-shifts/README.md diff --git a/README.md b/README.md index b651a20e8..caac8d57b 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,21 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | -| 1425 | [Constrained Subset Sum](https://leetcode.com/problems/constrained-subset-sum "带限制的子序列和") | [Go](problems/constrained-subset-sum) | Hard | +| 1439 | [Find the Kth Smallest Sum of a Matrix With Sorted Rows](https://leetcode.com/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows "有序矩阵中的第 k 个最小数组和") | [Go](problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | Hard | +| 1438 | [Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit](https://leetcode.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "绝对差不超过限制的最长连续子数组") | [Go](problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | Medium | +| 1437 | [Check If All 1's Are at Least Length K Places Away](https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away "是否所有 1 都至少相隔 k 个元素") | [Go](problems/check-if-all-1s-are-at-least-length-k-places-away) | Medium | +| 1436 | [Destination City](https://leetcode.com/problems/destination-city "旅行终点站") | [Go](problems/destination-city) | Easy | +| 1435 | [Create a Session Bar Chart](https://leetcode.com/problems/create-a-session-bar-chart) 🔒 | [MySQL](problems/create-a-session-bar-chart) | Easy | +| 1434 | [Number of Ways to Wear Different Hats to Each Other](https://leetcode.com/problems/number-of-ways-to-wear-different-hats-to-each-other "每个人戴不同帽子的方案数") | [Go](problems/number-of-ways-to-wear-different-hats-to-each-other) | Hard | +| 1433 | [Check If a String Can Break Another String](https://leetcode.com/problems/check-if-a-string-can-break-another-string "检查一个字符串是否可以打破另一个字符串") | [Go](problems/check-if-a-string-can-break-another-string) | Medium | +| 1432 | [Max Difference You Can Get From Changing an Integer](https://leetcode.com/problems/max-difference-you-can-get-from-changing-an-integer "改变一个整数能得到的最大差值") | [Go](problems/max-difference-you-can-get-from-changing-an-integer) | Medium | +| 1431 | [Kids With the Greatest Number of Candies](https://leetcode.com/problems/kids-with-the-greatest-number-of-candies "拥有最多糖果的孩子") | [Go](problems/kids-with-the-greatest-number-of-candies) | Easy | +| 1430 | [Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree](https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [Go](problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) | Medium | +| 1429 | [First Unique Number](https://leetcode.com/problems/first-unique-number) 🔒 | [Go](problems/first-unique-number) | Medium | +| 1428 | [Leftmost Column with at Least a One](https://leetcode.com/problems/leftmost-column-with-at-least-a-one) 🔒 | [Go](problems/leftmost-column-with-at-least-a-one) | Medium | +| 1427 | [Perform String Shifts](https://leetcode.com/problems/perform-string-shifts) 🔒 | [Go](problems/perform-string-shifts) | Easy | +| 1426 | [Counting Elements](https://leetcode.com/problems/counting-elements "数元素") 🔒 | [Go](problems/counting-elements) | Easy | +| 1425 | [Constrained Subsequence Sum](https://leetcode.com/problems/constrained-subsequence-sum "带限制的子序列和") | [Go](problems/constrained-subsequence-sum) | Hard | | 1424 | [Diagonal Traverse II](https://leetcode.com/problems/diagonal-traverse-ii "对角线遍历 II") | [Go](problems/diagonal-traverse-ii) | Medium | | 1423 | [Maximum Points You Can Obtain from Cards](https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards "可获得的最大点数") | [Go](problems/maximum-points-you-can-obtain-from-cards) | Medium | | 1422 | [Maximum Score After Splitting a String](https://leetcode.com/problems/maximum-score-after-splitting-a-string "分割字符串的最大得分") | [Go](problems/maximum-score-after-splitting-a-string) | Easy | diff --git a/problems/check-if-a-string-can-break-another-string/README.md b/problems/check-if-a-string-can-break-another-string/README.md new file mode 100644 index 000000000..8216e3e01 --- /dev/null +++ b/problems/check-if-a-string-can-break-another-string/README.md @@ -0,0 +1,60 @@ + + + + + + + +[< Previous](../max-difference-you-can-get-from-changing-an-integer "Max Difference You Can Get From Changing an Integer") +                 +[Next >](../number-of-ways-to-wear-different-hats-to-each-other "Number of Ways to Wear Different Hats to Each Other") + +## [1433. Check If a String Can Break Another String (Medium)](https://leetcode.com/problems/check-if-a-string-can-break-another-string "检查一个字符串是否可以打破另一个字符串") + +

    Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).

    + +

    A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.

    + +

     

    +

    Example 1:

    + +
    +Input: s1 = "abc", s2 = "xya"
    +Output: true
    +Explanation: "ayx" is a permutation of s2="xya" which can break to string "abc" which is a permutation of s1="abc".
    +
    + +

    Example 2:

    + +
    +Input: s1 = "abe", s2 = "acd"
    +Output: false 
    +Explanation: All permutations for s1="abe" are: "abe", "aeb", "bae", "bea", "eab" and "eba" and all permutation for s2="acd" are: "acd", "adc", "cad", "cda", "dac" and "dca". However, there is not any permutation from s1 which can break some permutation from s2 and vice-versa.
    +
    + +

    Example 3:

    + +
    +Input: s1 = "leetcodee", s2 = "interview"
    +Output: true
    +
    + +

     

    +

    Constraints:

    + +
      +
    • s1.length == n
    • +
    • s2.length == n
    • +
    • 1 <= n <= 10^5
    • +
    • All strings consist of lowercase English letters.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Sort both strings and then check if one of them can break the other. +
    diff --git a/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/README.md b/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/README.md new file mode 100644 index 000000000..324291e90 --- /dev/null +++ b/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../first-unique-number "First Unique Number") +                 +[Next >](../kids-with-the-greatest-number-of-candies "Kids With the Greatest Number of Candies") + +## [1430. Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree (Medium)](https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree "") + + + +### Related Topics + [[Tree](../../tag/tree/README.md)] + +### Hints +
    +Hint 1 +Depth-first search (DFS) with the parameters: current node in the binary tree and current position in the array of integers. +
    + +
    +Hint 2 +When reaching at final position check if it is a leaf node. +
    diff --git a/problems/check-if-all-1s-are-at-least-length-k-places-away/README.md b/problems/check-if-all-1s-are-at-least-length-k-places-away/README.md new file mode 100644 index 000000000..b285ea86e --- /dev/null +++ b/problems/check-if-all-1s-are-at-least-length-k-places-away/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../destination-city "Destination City") +                 +[Next >](../longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit") + +## [1437. Check If All 1's Are at Least Length K Places Away (Medium)](https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away "是否所有 1 都至少相隔 k 个元素") + +

    Given an array nums of 0s and 1s and an integer k, return True if all 1's are at least k places away from each other, otherwise return False.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: nums = [1,0,0,0,1,0,0,1], k = 2
    +Output: true
    +Explanation: Each of the 1s are at least 2 places away from each other.
    +
    + +

    Example 2:

    + +

    + +
    +Input: nums = [1,0,0,1,0,1], k = 2
    +Output: false
    +Explanation: The second 1 and third 1 are only one apart from each other.
    + +

    Example 3:

    + +
    +Input: nums = [1,1,1,1,1], k = 0
    +Output: true
    +
    + +

    Example 4:

    + +
    +Input: nums = [0,1,0,1], k = 1
    +Output: true
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 10^5
    • +
    • 0 <= k <= nums.length
    • +
    • nums[i] is 0 or 1
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Each time you find a number 1, check whether or not it is K or more places away from the next one. If it's not, return false. +
    diff --git a/problems/constrained-subsequence-sum/README.md b/problems/constrained-subsequence-sum/README.md new file mode 100644 index 000000000..7c76eaa23 --- /dev/null +++ b/problems/constrained-subsequence-sum/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../diagonal-traverse-ii "Diagonal Traverse II") +                 +[Next >](../counting-elements "Counting Elements") + +## [1425. Constrained Subsequence Sum (Hard)](https://leetcode.com/problems/constrained-subsequence-sum "带限制的子序列和") + +

    Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence, nums[i] and nums[j], where i < j, the condition j - i <= k is satisfied.

    + +

    subsequence of an array is obtained by deleting some number of elements (can be zero) from the array, leaving the remaining elements in their original order.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [10,2,-10,5,20], k = 2
    +Output: 37
    +Explanation: The subsequence is [10, 2, 5, 20].
    +
    + +

    Example 2:

    + +
    +Input: nums = [-1,-2,-3], k = 1
    +Output: -1
    +Explanation: The subsequence must be non-empty, so we choose the largest number.
    +
    + +

    Example 3:

    + +
    +Input: nums = [10,-2,-10,-5,20], k = 2
    +Output: 23
    +Explanation: The subsequence is [10, -2, -5, 20].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= nums.length <= 10^5
    • +
    • -10^4 <= nums[i] <= 10^4
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Use dynamic programming. +
    + +
    +Hint 2 +Let dp[i] be the solution for the prefix of the array that ends at index i, if the element at index i is in the subsequence. +
    + +
    +Hint 3 +dp[i] = nums[i] + max(0, dp[i-k], dp[i-k+1], ..., dp[i-1]) +
    + +
    +Hint 4 +Use a heap with the sliding window technique to optimize the dp. +
    diff --git a/problems/construct-binary-search-tree-from-preorder-traversal/README.md b/problems/construct-binary-search-tree-from-preorder-traversal/README.md index 982740fb7..f0f85cc8b 100644 --- a/problems/construct-binary-search-tree-from-preorder-traversal/README.md +++ b/problems/construct-binary-search-tree-from-preorder-traversal/README.md @@ -15,7 +15,7 @@

    (Recall that a binary search tree is a binary tree where for every node, any descendant of node.left has a value < node.val, and any descendant of node.right has a value > node.val.  Also recall that a preorder traversal displays the value of the node first, then traverses node.left, then traverses node.right.)

    -

     

    +

    It's guaranteed that for the given test cases there is always possible to find a binary search tree with the given requirements.

    Example 1:

    @@ -26,13 +26,13 @@

     

    +

    Constraints:

    -

    Note: 

    - -
      +
      • 1 <= preorder.length <= 100
      • +
      • 1 <= preorder[i] <= 10^8
      • The values of preorder are distinct.
      • -
    + ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/counting-elements/README.md b/problems/counting-elements/README.md new file mode 100644 index 000000000..ee43f6c68 --- /dev/null +++ b/problems/counting-elements/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../constrained-subsequence-sum "Constrained Subsequence Sum") +                 +[Next >](../perform-string-shifts "Perform String Shifts") + +## [1426. Counting Elements (Easy)](https://leetcode.com/problems/counting-elements "数元素") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Use hashset to store all elements. +
    + +
    +Hint 2 +Loop again to count all valid elements. +
    diff --git a/problems/create-a-session-bar-chart/README.md b/problems/create-a-session-bar-chart/README.md new file mode 100644 index 000000000..5f135a792 --- /dev/null +++ b/problems/create-a-session-bar-chart/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../number-of-ways-to-wear-different-hats-to-each-other "Number of Ways to Wear Different Hats to Each Other") +                 +[Next >](../destination-city "Destination City") + +## [1435. Create a Session Bar Chart (Easy)](https://leetcode.com/problems/create-a-session-bar-chart "") + + diff --git a/problems/create-a-session-bar-chart/mysql_schemas.sql b/problems/create-a-session-bar-chart/mysql_schemas.sql new file mode 100644 index 000000000..6041cffa5 --- /dev/null +++ b/problems/create-a-session-bar-chart/mysql_schemas.sql @@ -0,0 +1,7 @@ +Create table If Not Exists Sessions (session_id int, duration int); +Truncate table Sessions; +insert into Sessions (session_id, duration) values ('1', '30'); +insert into Sessions (session_id, duration) values ('2', '199'); +insert into Sessions (session_id, duration) values ('3', '299'); +insert into Sessions (session_id, duration) values ('4', '580'); +insert into Sessions (session_id, duration) values ('5', '1000'); diff --git a/problems/destination-city/README.md b/problems/destination-city/README.md new file mode 100644 index 000000000..76d0c3b81 --- /dev/null +++ b/problems/destination-city/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../create-a-session-bar-chart "Create a Session Bar Chart") +                 +[Next >](../check-if-all-1s-are-at-least-length-k-places-away "Check If All 1's Are at Least Length K Places Away") + +## [1436. Destination City (Easy)](https://leetcode.com/problems/destination-city "旅行终点站") + +

    You are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi. Return the destination city, that is, the city without any path outgoing to another city.

    + +

    It is guaranteed that the graph of paths forms a line without any loop, therefore, there will be exactly one destination city.

    + +

     

    +

    Example 1:

    + +
    +Input: paths = [["London","New York"],["New York","Lima"],["Lima","Sao Paulo"]]
    +Output: "Sao Paulo" 
    +Explanation: Starting at "London" city you will reach "Sao Paulo" city which is the destination city. Your trip consist of: "London" -> "New York" -> "Lima" -> "Sao Paulo".
    +
    + +

    Example 2:

    + +
    +Input: paths = [["B","C"],["D","B"],["C","A"]]
    +Output: "A"
    +Explanation: All possible trips are: 
    +"D" -> "B" -> "C" -> "A". 
    +"B" -> "C" -> "A". 
    +"C" -> "A". 
    +"A". 
    +Clearly the destination city is "A".
    +
    + +

    Example 3:

    + +
    +Input: paths = [["A","Z"]]
    +Output: "Z"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= paths.length <= 100
    • +
    • paths[i].length == 2
    • +
    • 1 <= cityAi.length, cityBi.length <= 10
    • +
    • cityA!= cityBi
    • +
    • All strings consist of lowercase and uppercase English letters and the space character.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Start in any city and use the path to move to the next city. +
    + +
    +Hint 2 +Eventually, you will reach a city with no path outgoing, this is the destination city. +
    diff --git a/problems/diagonal-traverse-ii/README.md b/problems/diagonal-traverse-ii/README.md index d856f64d7..74b730804 100644 --- a/problems/diagonal-traverse-ii/README.md +++ b/problems/diagonal-traverse-ii/README.md @@ -7,7 +7,7 @@ [< Previous](../maximum-points-you-can-obtain-from-cards "Maximum Points You Can Obtain from Cards")                  -[Next >](../constrained-subset-sum "Constrained Subset Sum") +[Next >](../constrained-subsequence-sum "Constrained Subsequence Sum") ## [1424. Diagonal Traverse II (Medium)](https://leetcode.com/problems/diagonal-traverse-ii "对角线遍历 II") diff --git a/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md new file mode 100644 index 000000000..a821a5a06 --- /dev/null +++ b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit") +                 +Next > + +## [1439. Find the Kth Smallest Sum of a Matrix With Sorted Rows (Hard)](https://leetcode.com/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows "有序矩阵中的第 k 个最小数组和") + +

    You are given an m * n matrix, mat, and an integer k, which has its rows sorted in non-decreasing order.

    + +

    You are allowed to choose exactly 1 element from each row to form an array. Return the Kth smallest array sum among all possible arrays.

    + +

     

    +

    Example 1:

    + +
    +Input: mat = [[1,3,11],[2,4,6]], k = 5
    +Output: 7
    +Explanation: Choosing one element from each row, the first k smallest sum are:
    +[1,2], [1,4], [3,2], [3,4], [1,6]. Where the 5th sum is 7.  
    + +

    Example 2:

    + +
    +Input: mat = [[1,3,11],[2,4,6]], k = 9
    +Output: 17
    +
    + +

    Example 3:

    + +
    +Input: mat = [[1,10,10],[1,4,5],[2,3,6]], k = 7
    +Output: 9
    +Explanation: Choosing one element from each row, the first k smallest sum are:
    +[1,1,2], [1,1,3], [1,4,2], [1,4,3], [1,1,6], [1,5,2], [1,5,3]. Where the 7th sum is 9.  
    +
    + +

    Example 4:

    + +
    +Input: mat = [[1,1,10],[2,2,9]], k = 7
    +Output: 12
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == mat.length
    • +
    • n == mat.length[i]
    • +
    • 1 <= m, n <= 40
    • +
    • 1 <= k <= min(200, n ^ m)
    • +
    • 1 <= mat[i][j] <= 5000
    • +
    • mat[i] is a non decreasing array.
    • +
    + +### Related Topics + [[Heap](../../tag/heap/README.md)] + +### Hints +
    +Hint 1 +Save all visited sums and corresponding indexes in a priority queue. Then, once you pop the smallest sum so far, you can quickly identify the next m candidates for smallest sum by incrementing each row index by 1. +
    diff --git a/problems/first-unique-number/README.md b/problems/first-unique-number/README.md new file mode 100644 index 000000000..e41636f56 --- /dev/null +++ b/problems/first-unique-number/README.md @@ -0,0 +1,34 @@ + + + + + + + +[< Previous](../leftmost-column-with-at-least-a-one "Leftmost Column with at Least a One") +                 +[Next >](../check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree "Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree") + +## [1429. First Unique Number (Medium)](https://leetcode.com/problems/first-unique-number "") + + + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +Use doubly Linked list with hashmap of pointers to linked list nodes. add unique number to the linked list. When add is called check if the added number is unique then it have to be added to the linked list and if it is repeated remove it from the linked list if exists. When showFirstUnique is called retrieve the head of the linked list. +
    + +
    +Hint 2 +Use queue and check that first element of the queue is always unique. +
    + +
    +Hint 3 +Use set or heap to make running time of each function O(logn). +
    diff --git a/problems/jump-game/README.md b/problems/jump-game/README.md index 73f8105a1..566f54531 100644 --- a/problems/jump-game/README.md +++ b/problems/jump-game/README.md @@ -17,10 +17,11 @@

    Determine if you are able to reach the last index.

    +

     

    Example 1:

    -Input: [2,3,1,1,4]
    +Input: nums = [2,3,1,1,4]
     Output: true
     Explanation: Jump 1 step from index 0 to 1, then 3 steps to the last index.
     
    @@ -28,12 +29,19 @@

    Example 2:

    -Input: [3,2,1,0,4]
    +Input: nums = [3,2,1,0,4]
     Output: false
    -Explanation: You will always arrive at index 3 no matter what. Its maximum
    -             jump length is 0, which makes it impossible to reach the last index.
    +Explanation: You will always arrive at index 3 no matter what. Its maximum jump length is 0, which makes it impossible to reach the last index.
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 3 * 10^4
    • +
    • 0 <= nums[i][j] <= 10^5
    • +
    + ### Related Topics [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] diff --git a/problems/kids-with-the-greatest-number-of-candies/README.md b/problems/kids-with-the-greatest-number-of-candies/README.md new file mode 100644 index 000000000..df7073b98 --- /dev/null +++ b/problems/kids-with-the-greatest-number-of-candies/README.md @@ -0,0 +1,63 @@ + + + + + + + +[< Previous](../check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree "Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree") +                 +[Next >](../max-difference-you-can-get-from-changing-an-integer "Max Difference You Can Get From Changing an Integer") + +## [1431. Kids With the Greatest Number of Candies (Easy)](https://leetcode.com/problems/kids-with-the-greatest-number-of-candies "拥有最多糖果的孩子") + +

    Given the array candies and the integer extraCandies, where candies[i] represents the number of candies that the ith kid has.

    + +

    For each kid check if there is a way to distribute extraCandies among the kids such that he or she can have the greatest number of candies among them. Notice that multiple kids can have the greatest number of candies.

    + +

     

    +

    Example 1:

    + +
    +Input: candies = [2,3,5,1,3], extraCandies = 3
    +Output: [true,true,true,false,true] 
    +Explanation: 
    +Kid 1 has 2 candies and if he or she receives all extra candies (3) will have 5 candies --- the greatest number of candies among the kids. 
    +Kid 2 has 3 candies and if he or she receives at least 2 extra candies will have the greatest number of candies among the kids. 
    +Kid 3 has 5 candies and this is already the greatest number of candies among the kids. 
    +Kid 4 has 1 candy and even if he or she receives all extra candies will only have 4 candies. 
    +Kid 5 has 3 candies and if he or she receives at least 2 extra candies will have the greatest number of candies among the kids. 
    +
    + +

    Example 2:

    + +
    +Input: candies = [4,2,1,1,2], extraCandies = 1
    +Output: [true,false,false,false,false] 
    +Explanation: There is only 1 extra candy, therefore only kid 1 will have the greatest number of candies among the kids regardless of who takes the extra candy.
    +
    + +

    Example 3:

    + +
    +Input: candies = [12,1,12], extraCandies = 10
    +Output: [true,false,true]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= candies.length <= 100
    • +
    • 1 <= candies[i] <= 100
    • +
    • 1 <= extraCandies <= 50
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Use greedy approach. For each kid check if candies[i] + extraCandies ≥ maximum in Candies[i]. +
    diff --git a/problems/leftmost-column-with-at-least-a-one/README.md b/problems/leftmost-column-with-at-least-a-one/README.md new file mode 100644 index 000000000..bcf077e40 --- /dev/null +++ b/problems/leftmost-column-with-at-least-a-one/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../perform-string-shifts "Perform String Shifts") +                 +[Next >](../first-unique-number "First Unique Number") + +## [1428. Leftmost Column with at Least a One (Medium)](https://leetcode.com/problems/leftmost-column-with-at-least-a-one "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +1. (Binary Search) For each row do a binary search to find the leftmost one on that row and update the answer. +
    + +
    +Hint 2 +2. (Optimal Approach) Imagine there is a pointer p(x, y) starting from top right corner. p can only move left or down. If the value at p is 0, move down. If the value at p is 1, move left. Try to figure out the correctness and time complexity of this algorithm. +
    diff --git a/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md new file mode 100644 index 000000000..a2239cd27 --- /dev/null +++ b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../check-if-all-1s-are-at-least-length-k-places-away "Check If All 1's Are at Least Length K Places Away") +                 +[Next >](../find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows "Find the Kth Smallest Sum of a Matrix With Sorted Rows") + +## [1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit (Medium)](https://leetcode.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "绝对差不超过限制的最长连续子数组") + +

    Given an array of integers nums and an integer limit, return the size of the longest continuous subarray such that the absolute difference between any two elements is less than or equal to limit.

    + +

    In case there is no subarray satisfying the given condition return 0.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [8,2,4,7], limit = 4
    +Output: 2 
    +Explanation: All subarrays are: 
    +[8] with maximum absolute diff |8-8| = 0 <= 4.
    +[8,2] with maximum absolute diff |8-2| = 6 > 4. 
    +[8,2,4] with maximum absolute diff |8-2| = 6 > 4.
    +[8,2,4,7] with maximum absolute diff |8-2| = 6 > 4.
    +[2] with maximum absolute diff |2-2| = 0 <= 4.
    +[2,4] with maximum absolute diff |2-4| = 2 <= 4.
    +[2,4,7] with maximum absolute diff |2-7| = 5 > 4.
    +[4] with maximum absolute diff |4-4| = 0 <= 4.
    +[4,7] with maximum absolute diff |4-7| = 3 <= 4.
    +[7] with maximum absolute diff |7-7| = 0 <= 4. 
    +Therefore, the size of the longest subarray is 2.
    +
    + +

    Example 2:

    + +
    +Input: nums = [10,1,2,4,7,2], limit = 5
    +Output: 4 
    +Explanation: The subarray [2,4,7,2] is the longest since the maximum absolute diff is |2-7| = 5 <= 5.
    +
    + +

    Example 3:

    + +
    +Input: nums = [4,2,2,2,4,4,2,2], limit = 0
    +Output: 3
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 10^5
    • +
    • 1 <= nums[i] <= 10^9
    • +
    • 0 <= limit <= 10^9
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
    +Hint 1 +Use a sliding window approach keeping the maximum and minimum value using a data structure like a multiset from STL in C++. +
    + +
    +Hint 2 +More specifically, use the two pointer technique, moving the right pointer as far as possible to the right until the subarray is not valid (maxValue - minValue > limit), then moving the left pointer until the subarray is valid again (maxValue - minValue <= limit). Keep repeating this process. +
    diff --git a/problems/max-difference-you-can-get-from-changing-an-integer/README.md b/problems/max-difference-you-can-get-from-changing-an-integer/README.md new file mode 100644 index 000000000..3c1901b55 --- /dev/null +++ b/problems/max-difference-you-can-get-from-changing-an-integer/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../kids-with-the-greatest-number-of-candies "Kids With the Greatest Number of Candies") +                 +[Next >](../check-if-a-string-can-break-another-string "Check If a String Can Break Another String") + +## [1432. Max Difference You Can Get From Changing an Integer (Medium)](https://leetcode.com/problems/max-difference-you-can-get-from-changing-an-integer "改变一个整数能得到的最大差值") + +

    You are given an integer num. You will apply the following steps exactly two times:

    + +
      +
    • Pick a digit x (0 <= x <= 9).
    • +
    • Pick another digit y (0 <= y <= 9). The digit y can be equal to x.
    • +
    • Replace all the occurrences of x in the decimal representation of num by y.
    • +
    • The new integer cannot have any leading zeros, also the new integer cannot be 0.
    • +
    + +

    Let a and b be the results of applying the operations to num the first and second times, respectively.

    + +

    Return the max difference between a and b.

    + +

     

    +

    Example 1:

    + +
    +Input: num = 555
    +Output: 888
    +Explanation: The first time pick x = 5 and y = 9 and store the new integer in a.
    +The second time pick x = 5 and y = 1 and store the new integer in b.
    +We have now a = 999 and b = 111 and max difference = 888
    +
    + +

    Example 2:

    + +
    +Input: num = 9
    +Output: 8
    +Explanation: The first time pick x = 9 and y = 9 and store the new integer in a.
    +The second time pick x = 9 and y = 1 and store the new integer in b.
    +We have now a = 9 and b = 1 and max difference = 8
    +
    + +

    Example 3:

    + +
    +Input: num = 123456
    +Output: 820000
    +
    + +

    Example 4:

    + +
    +Input: num = 10000
    +Output: 80000
    +
    + +

    Example 5:

    + +
    +Input: num = 9288
    +Output: 8700
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= num <= 10^8
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +We need to get the max and min value after changing num and the answer is max - min. +
    + +
    +Hint 2 +Use brute force, try all possible changes and keep the minimum and maximum values. +
    diff --git a/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md b/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md new file mode 100644 index 000000000..802f61ba6 --- /dev/null +++ b/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../check-if-a-string-can-break-another-string "Check If a String Can Break Another String") +                 +[Next >](../create-a-session-bar-chart "Create a Session Bar Chart") + +## [1434. Number of Ways to Wear Different Hats to Each Other (Hard)](https://leetcode.com/problems/number-of-ways-to-wear-different-hats-to-each-other "每个人戴不同帽子的方案数") + +

    There are n people and 40 types of hats labeled from 1 to 40.

    + +

    Given a list of list of integers hats, where hats[i] is a list of all hats preferred by the i-th person.

    + +

    Return the number of ways that the n people wear different hats to each other.

    + +

    Since the answer may be too large, return it modulo 10^9 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: hats = [[3,4],[4,5],[5]]
    +Output: 1
    +Explanation: There is only one way to choose hats given the conditions. 
    +First person choose hat 3, Second person choose hat 4 and last one hat 5.
    + +

    Example 2:

    + +
    +Input: hats = [[3,5,1],[3,5]]
    +Output: 4
    +Explanation: There are 4 ways to choose hats
    +(3,5), (5,3), (1,3) and (1,5)
    +
    + +

    Example 3:

    + +
    +Input: hats = [[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]]
    +Output: 24
    +Explanation: Each person can choose hats labeled from 1 to 4.
    +Number of Permutations of (1,2,3,4) = 24.
    +
    + +

    Example 4:

    + +
    +Input: hats = [[1,2,3],[2,3,5,6],[1,3,7,9],[1,8,9],[2,5,7]]
    +Output: 111
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == hats.length
    • +
    • 1 <= n <= 10
    • +
    • 1 <= hats[i].length <= 40
    • +
    • 1 <= hats[i][j] <= 40
    • +
    • hats[i] contains a list of unique integers.
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Dynamic programming + bitmask. +
    + +
    +Hint 2 +dp(peopleMask, idHat) number of ways to wear different hats given a bitmask (people visited) and used hats from 1 to idHat-1. +
    diff --git a/problems/ones-and-zeroes/README.md b/problems/ones-and-zeroes/README.md index dbbe1cc58..de0279e7a 100644 --- a/problems/ones-and-zeroes/README.md +++ b/problems/ones-and-zeroes/README.md @@ -11,42 +11,36 @@ ## [474. Ones and Zeroes (Medium)](https://leetcode.com/problems/ones-and-zeroes "一和零") -

    In the computer world, use restricted resource you have to generate maximum benefit is what we always want to pursue.

    - -

    For now, suppose you are a dominator of m 0s and n 1s respectively. On the other hand, there is an array with strings consisting of only 0s and 1s.

    +

    Given an array, strs, with strings consisting of only 0s and 1s. Also two integers m and n.

    Now your task is to find the maximum number of strings that you can form with given m 0s and n 1s. Each 0 and 1 can be used at most once.

    -

    Note:

    - -
      -
    1. The given numbers of 0s and 1s will both not exceed 100
    2. -
    3. The size of given string array won't exceed 600.
    4. -
    -

     

    - -

    Example 1:

    +

    Example 1:

    -Input: Array = {"10", "0001", "111001", "1", "0"}, m = 5, n = 3
    -Output: 4
    -
    -Explanation: This are totally 4 strings can be formed by the using of 5 0s and 3 1s, which are “10,”0001”,”1”,”0”
    +Input: strs = ["10","0001","111001","1","0"], m = 5, n = 3
    +Output: 4
    +Explanation: This are totally 4 strings can be formed by the using of 5 0s and 3 1s, which are "10","0001","1","0".
     
    -

     

    - -

    Example 2:

    +

    Example 2:

    -Input: Array = {"10", "0", "1"}, m = 1, n = 1
    -Output: 2
    -
    +Input: strs = ["10","0","1"], m = 1, n = 1
    +Output: 2
     Explanation: You could form "10", but then you'd have nothing left. Better form "0" and "1".
     

     

    +

    Constraints:

    + +
      +
    • 1 <= strs.length <= 600
    • +
    • 1 <= strs[i].length <= 100
    • +
    • strs[i] consists only of digits '0' and '1'.
    • +
    • 1 <= m, n <= 100
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/perform-string-shifts/README.md b/problems/perform-string-shifts/README.md new file mode 100644 index 000000000..3c25d222a --- /dev/null +++ b/problems/perform-string-shifts/README.md @@ -0,0 +1,29 @@ + + + + + + + +[< Previous](../counting-elements "Counting Elements") +                 +[Next >](../leftmost-column-with-at-least-a-one "Leftmost Column with at Least a One") + +## [1427. Perform String Shifts (Easy)](https://leetcode.com/problems/perform-string-shifts "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Intuitively performing all shift operations is acceptable due to the constraints. +
    + +
    +Hint 2 +You may notice that left shift cancels the right shift, so count the total left shift times (may be negative if the final result is right shift), and perform it once. +
    diff --git a/problems/remove-boxes/README.md b/problems/remove-boxes/README.md index ff1ac85fb..553648a4d 100644 --- a/problems/remove-boxes/README.md +++ b/problems/remove-boxes/README.md @@ -11,33 +11,31 @@ ## [546. Remove Boxes (Hard)](https://leetcode.com/problems/remove-boxes "移除盒子") -

    Given several boxes with different colors represented by different positive numbers.
    -You may experience several rounds to remove boxes until there is no box left. Each time you can choose some continuous boxes with the same color (composed of k boxes, k >= 1), remove them and get k*k points.
    -Find the maximum points you can get. -

    +

    Given several boxes with different colors represented by different positive numbers.
    +You may experience several rounds to remove boxes until there is no box left. Each time you can choose some continuous boxes with the same color (composed of k boxes, k >= 1), remove them and get k*k points.
    +Find the maximum points you can get.

    + +

     

    +

    Example 1:

    -

    Example 1:
    -Input: -

    -[1, 3, 2, 2, 2, 3, 4, 3, 1]
    -
    -Output: -
    -23
    -
    -Explanation:
    +Input: boxes = [1,3,2,2,2,3,4,3,1]
    +Output: 23
    +Explanation:
     [1, 3, 2, 2, 2, 3, 4, 3, 1] 
    -----> [1, 3, 3, 4, 3, 1] (3*3=9 points) 
    -----> [1, 3, 3, 3, 1] (1*1=1 points) 
    -----> [1, 1] (3*3=9 points) 
    -----> [] (2*2=4 points)
    +----> [1, 3, 3, 4, 3, 1] (3*3=9 points) 
    +----> [1, 3, 3, 3, 1] (1*1=1 points) 
    +----> [1, 1] (3*3=9 points) 
    +----> [] (2*2=4 points)
     
    -

    -

    Note: -The number of boxes n would not exceed 100. -

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= boxes.length <= 100
    • +
    • 1 <= boxes[i] <= 100
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/rotate-array/README.md b/problems/rotate-array/README.md index 0492b89a0..af79af5b7 100644 --- a/problems/rotate-array/README.md +++ b/problems/rotate-array/README.md @@ -13,32 +13,42 @@

    Given an array, rotate the array to the right by k steps, where k is non-negative.

    +

    Follow up:

    + +
      +
    • Try to come up as many solutions as you can, there are at least 3 different ways to solve this problem.
    • +
    • Could you do it in-place with O(1) extra space?
    • +
    + +

     

    Example 1:

    -Input: [1,2,3,4,5,6,7] and k = 3
    -Output: [5,6,7,1,2,3,4]
    +Input: nums = [1,2,3,4,5,6,7], k = 3
    +Output: [5,6,7,1,2,3,4]
     Explanation:
    -rotate 1 steps to the right: [7,1,2,3,4,5,6]
    -rotate 2 steps to the right: [6,7,1,2,3,4,5]
    -rotate 3 steps to the right: [5,6,7,1,2,3,4]
    +rotate 1 steps to the right: [7,1,2,3,4,5,6]
    +rotate 2 steps to the right: [6,7,1,2,3,4,5]
    +rotate 3 steps to the right: [5,6,7,1,2,3,4]
     

    Example 2:

    -Input: [-1,-100,3,99] and k = 2
    +Input: nums = [-1,-100,3,99], k = 2
     Output: [3,99,-1,-100]
     Explanation: 
     rotate 1 steps to the right: [99,-1,-100,3]
     rotate 2 steps to the right: [3,99,-1,-100]
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • Try to come up as many solutions as you can, there are at least 3 different ways to solve this problem.
    • -
    • Could you do it in-place with O(1) extra space?
    • +
    • 1 <= nums.length <= 2 * 10^4
    • +
    • It's guaranteed that nums[i] fits in a 32 bit-signed integer.
    • +
    • k >= 0
    ### Related Topics diff --git a/tag/array/README.md b/tag/array/README.md index 9c3a0f06e..78bfe62c8 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,14 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1437 | [是否所有 1 都至少相隔 k 个元素](../../problems/check-if-all-1s-are-at-least-length-k-places-away) | [[数组](../array/README.md)] | Medium | +| 1431 | [拥有最多糖果的孩子](../../problems/kids-with-the-greatest-number-of-candies) | [[数组](../array/README.md)] | Easy | +| 1428 | [Leftmost Column with at Least a One](../../problems/leftmost-column-with-at-least-a-one) 🔒 | [[数组](../array/README.md)] | Medium | +| 1427 | [Perform String Shifts](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1426 | [数元素](../../problems/counting-elements) 🔒 | [[数组](../array/README.md)] | Easy | +| 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1414 | [和为 K 的最少斐波那契数字数目](../../problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1413 | [逐步求和得到正数的最小值](../../problems/minimum-value-to-get-positive-step-by-step-sum) | [[数组](../array/README.md)] | Easy | | 1409 | [查询带键的排列](../../problems/queries-on-a-permutation-with-key) | [[数组](../array/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 666decd3d..f3b48ab7c 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1404 | [将二进制表示减到 1 的步骤数](../../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[排序](../sort/README.md)] [[位运算](../bit-manipulation/README.md)] | Easy | | 1342 | [将数字变成 0 的操作次数](../../problems/number-of-steps-to-reduce-a-number-to-zero) | [[位运算](../bit-manipulation/README.md)] | Easy | diff --git a/tag/design/README.md b/tag/design/README.md index 0f442f13a..546da5322 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1429 | [First Unique Number](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] | Medium | | 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | | 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index a0fd30ca1..322c4233d 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1425 | [带限制的子序列和](../../problems/constrained-subsequence-sum) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1420 | [生成数组](../../problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1416 | [恢复数组](../../problems/restore-the-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1411 | [给 N x 3 网格图涂色的方案数](../../problems/number-of-ways-to-paint-n-x-3-grid) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 548d29949..8be0add8c 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1414 | [和为 K 的最少斐波那契数字数目](../../problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 2a1714f20..7065347c2 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1429 | [First Unique Number](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1418 | [点菜展示表](../../problems/display-table-of-food-orders-in-a-restaurant) | [[哈希表](../hash-table/README.md)] | Medium | | 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/heap/README.md b/tag/heap/README.md index 4c04d66bd..b815bcaee 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1439 | [有序矩阵中的第 k 个最小数组和](../../problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | [[堆](../heap/README.md)] | Hard | | 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] | Medium | | 1046 | [最后一块石头的重量](../../problems/last-stone-weight) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Easy | | 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index ada7dc38e..9d25bf985 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1427 | [Perform String Shifts](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1390 | [四因数](../../problems/four-divisors) | [[数学](../math/README.md)] | Medium | | 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1362 | [最接近的因数](../../problems/closest-divisors) | [[数学](../math/README.md)] | Medium | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index dc035894e..5ad662cb4 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1176 | [健身计划评估](../../problems/diet-plan-performance) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Easy | | 1151 | [最少交换次数来组合所有的 1](../../problems/minimum-swaps-to-group-all-1s-together) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index 5b346163f..bc64cd5ac 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | | 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | | 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Hard | diff --git a/tag/string/README.md b/tag/string/README.md index 4e53dd7eb..50dcda9dc 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1436 | [旅行终点站](../../problems/destination-city) | [[字符串](../string/README.md)] | Easy | +| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1432 | [改变一个整数能得到的最大差值](../../problems/max-difference-you-can-get-from-changing-an-integer) | [[字符串](../string/README.md)] | Medium | +| 1422 | [分割字符串的最大得分](../../problems/maximum-score-after-splitting-a-string) | [[字符串](../string/README.md)] | Easy | | 1419 | [数青蛙](../../problems/minimum-number-of-frogs-croaking) | [[字符串](../string/README.md)] | Medium | | 1417 | [重新格式化字符串](../../problems/reformat-the-string) | [[字符串](../string/README.md)] | Easy | | 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/tree/README.md b/tag/tree/README.md index af1c23a9e..537be7ad1 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1430 | [Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree](../../problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | | 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] | Medium | | 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | From fdac83e3250cf9effda6f7e8252a6c9c44d965bd Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 11 May 2020 13:00:30 +0800 Subject: [PATCH 061/145] A: new --- README.md | 5 ++ .../README.md | 81 +++++++++++++++++ .../README.md | 88 +++++++++++++++++++ .../evaluate-boolean-expression/README.md | 14 +++ .../mysql_schemas.sql | 12 +++ problems/find-k-closest-elements/README.md | 50 ++++------- .../README.md | 2 +- .../README.md | 10 +++ .../median-of-two-sorted-arrays/README.md | 2 +- .../README.md | 71 +++++++++++++++ problems/number-complement/README.md | 31 +++---- .../README.md | 78 ++++++++++++++++ problems/ransom-note/README.md | 36 ++++---- problems/subarray-sum-equals-k/README.md | 19 ++-- problems/subtree-of-another-tree/README.md | 20 +++-- readme/1-300.md | 2 +- tag/array/README.md | 3 +- tag/binary-search/README.md | 2 +- tag/bit-manipulation/README.md | 1 + tag/depth-first-search/README.md | 1 + tag/divide-and-conquer/README.md | 2 +- tag/dynamic-programming/README.md | 1 + tag/math/README.md | 1 + tag/stack/README.md | 1 + tag/tree/README.md | 1 + 25 files changed, 444 insertions(+), 90 deletions(-) create mode 100644 problems/build-an-array-with-stack-operations/README.md create mode 100644 problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md create mode 100644 problems/evaluate-boolean-expression/README.md create mode 100644 problems/evaluate-boolean-expression/mysql_schemas.sql create mode 100644 problems/minimum-time-to-collect-all-apples-in-a-tree/README.md create mode 100644 problems/number-of-ways-of-cutting-a-pizza/README.md diff --git a/README.md b/README.md index caac8d57b..6a142e8f8 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,11 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1444 | [Number of Ways of Cutting a Pizza](https://leetcode.com/problems/number-of-ways-of-cutting-a-pizza "切披萨的方案数") | [Go](problems/number-of-ways-of-cutting-a-pizza) | Hard | +| 1443 | [Minimum Time to Collect All Apples in a Tree](https://leetcode.com/problems/minimum-time-to-collect-all-apples-in-a-tree "收集树上所有苹果的最少时间") | [Go](problems/minimum-time-to-collect-all-apples-in-a-tree) | Medium | +| 1442 | [Count Triplets That Can Form Two Arrays of Equal XOR](https://leetcode.com/problems/count-triplets-that-can-form-two-arrays-of-equal-xor "形成两个异或相等数组的三元组数目") | [Go](problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | Medium | +| 1441 | [Build an Array With Stack Operations](https://leetcode.com/problems/build-an-array-with-stack-operations "用栈操作构建数组") | [Go](problems/build-an-array-with-stack-operations) | Easy | +| 1440 | [Evaluate Boolean Expression](https://leetcode.com/problems/evaluate-boolean-expression) 🔒 | [MySQL](problems/evaluate-boolean-expression) | Medium | | 1439 | [Find the Kth Smallest Sum of a Matrix With Sorted Rows](https://leetcode.com/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows "有序矩阵中的第 k 个最小数组和") | [Go](problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | Hard | | 1438 | [Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit](https://leetcode.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "绝对差不超过限制的最长连续子数组") | [Go](problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | Medium | | 1437 | [Check If All 1's Are at Least Length K Places Away](https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away "是否所有 1 都至少相隔 k 个元素") | [Go](problems/check-if-all-1s-are-at-least-length-k-places-away) | Medium | diff --git a/problems/build-an-array-with-stack-operations/README.md b/problems/build-an-array-with-stack-operations/README.md new file mode 100644 index 000000000..0f11e7d05 --- /dev/null +++ b/problems/build-an-array-with-stack-operations/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../evaluate-boolean-expression "Evaluate Boolean Expression") +                 +[Next >](../count-triplets-that-can-form-two-arrays-of-equal-xor "Count Triplets That Can Form Two Arrays of Equal XOR") + +## [1441. Build an Array With Stack Operations (Easy)](https://leetcode.com/problems/build-an-array-with-stack-operations "用栈操作构建数组") + +

    Given an array target and an integer n. In each iteration, you will read a number from  list = {1,2,3..., n}.

    + +

    Build the target array using the following operations:

    + +
      +
    • Push: Read a new element from the beginning list, and push it in the array.
    • +
    • Pop: delete the last element of the array.
    • +
    • If the target array is already built, stop reading more elements.
    • +
    + +

    You are guaranteed that the target array is strictly increasing, only containing numbers between 1 to n inclusive.

    + +

    Return the operations to build the target array.

    + +

    You are guaranteed that the answer is unique.

    + +

     

    +

    Example 1:

    + +
    +Input: target = [1,3], n = 3
    +Output: ["Push","Push","Pop","Push"]
    +Explanation: 
    +Read number 1 and automatically push in the array -> [1]
    +Read number 2 and automatically push in the array then Pop it -> [1]
    +Read number 3 and automatically push in the array -> [1,3]
    +
    + +

    Example 2:

    + +
    +Input: target = [1,2,3], n = 3
    +Output: ["Push","Push","Push"]
    +
    + +

    Example 3:

    + +
    +Input: target = [1,2], n = 4
    +Output: ["Push","Push"]
    +Explanation: You only need to read the first 2 numbers and stop.
    +
    + +

    Example 4:

    + +
    +Input: target = [2,3,4], n = 4
    +Output: ["Push","Pop","Push","Push","Push"]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= target.length <= 100
    • +
    • 1 <= target[i] <= 100
    • +
    • 1 <= n <= 100
    • +
    • target is strictly increasing.
    • +
    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + +### Hints +
    +Hint 1 +Use “Push” for numbers to be kept in target array and [“Push”, “Pop”] for numbers to be discarded. +
    diff --git a/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md b/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md new file mode 100644 index 000000000..f73d02316 --- /dev/null +++ b/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../build-an-array-with-stack-operations "Build an Array With Stack Operations") +                 +[Next >](../minimum-time-to-collect-all-apples-in-a-tree "Minimum Time to Collect All Apples in a Tree") + +## [1442. Count Triplets That Can Form Two Arrays of Equal XOR (Medium)](https://leetcode.com/problems/count-triplets-that-can-form-two-arrays-of-equal-xor "形成两个异或相等数组的三元组数目") + +

    Given an array of integers arr.

    + +

    We want to select three indices i, j and k where (0 <= i < j <= k < arr.length).

    + +

    Let's define a and b as follows:

    + +
      +
    • a = arr[i] ^ arr[i + 1] ^ ... ^ arr[j - 1]
    • +
    • b = arr[j] ^ arr[j + 1] ^ ... ^ arr[k]
    • +
    + +

    Note that ^ denotes the bitwise-xor operation.

    + +

    Return the number of triplets (i, j and k) Where a == b.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [2,3,1,6,7]
    +Output: 4
    +Explanation: The triplets are (0,1,2), (0,2,2), (2,3,4) and (2,4,4)
    +
    + +

    Example 2:

    + +
    +Input: arr = [1,1,1,1,1]
    +Output: 10
    +
    + +

    Example 3:

    + +
    +Input: arr = [2,3]
    +Output: 0
    +
    + +

    Example 4:

    + +
    +Input: arr = [1,3,5,7,9]
    +Output: 3
    +
    + +

    Example 5:

    + +
    +Input: arr = [7,11,12,9,5,2,7,17,22]
    +Output: 8
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 300
    • +
    • 1 <= arr[i] <= 10^8
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +We are searching for sub-array of length ≥ 2 and we need to split it to 2 non-empty arrays so that the xor of the first array is equal to the xor of the second array. This is equivalent to searching for sub-array with xor = 0. +
    + +
    +Hint 2 +Keep the prefix xor of arr in another array, check the xor of all sub-arrays in O(n^2), if the xor of sub-array of length x is 0 add x-1 to the answer. +
    diff --git a/problems/evaluate-boolean-expression/README.md b/problems/evaluate-boolean-expression/README.md new file mode 100644 index 000000000..b3ccf69e9 --- /dev/null +++ b/problems/evaluate-boolean-expression/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows "Find the Kth Smallest Sum of a Matrix With Sorted Rows") +                 +[Next >](../build-an-array-with-stack-operations "Build an Array With Stack Operations") + +## [1440. Evaluate Boolean Expression (Medium)](https://leetcode.com/problems/evaluate-boolean-expression "") + + diff --git a/problems/evaluate-boolean-expression/mysql_schemas.sql b/problems/evaluate-boolean-expression/mysql_schemas.sql new file mode 100644 index 000000000..1b0c6f56c --- /dev/null +++ b/problems/evaluate-boolean-expression/mysql_schemas.sql @@ -0,0 +1,12 @@ +Create Table If Not Exists Variables (name varchar(3), value int); +Create Table If Not Exists Expressions (left_operand varchar(3), operator ENUM('>', '<', '='), right_operand varchar(3)); +Truncate table Variables; +insert into Variables (name, value) values ('x', '66'); +insert into Variables (name, value) values ('y', '77'); +Truncate table Expressions; +insert into Expressions (left_operand, operator, right_operand) values ('x', '>', 'y'); +insert into Expressions (left_operand, operator, right_operand) values ('x', '<', 'y'); +insert into Expressions (left_operand, operator, right_operand) values ('x', '=', 'y'); +insert into Expressions (left_operand, operator, right_operand) values ('y', '>', 'x'); +insert into Expressions (left_operand, operator, right_operand) values ('y', '<', 'x'); +insert into Expressions (left_operand, operator, right_operand) values ('x', '=', 'x'); diff --git a/problems/find-k-closest-elements/README.md b/problems/find-k-closest-elements/README.md index 0849ebd14..eadcf4ad5 100644 --- a/problems/find-k-closest-elements/README.md +++ b/problems/find-k-closest-elements/README.md @@ -11,40 +11,24 @@ ## [658. Find K Closest Elements (Medium)](https://leetcode.com/problems/find-k-closest-elements "找到 K 个最接近的元素") -

    -Given a sorted array, two integers k and x, find the k closest elements to x in the array. The result should also be sorted in ascending order. -If there is a tie, the smaller elements are always preferred. -

    - -

    Example 1:
    -

    -Input: [1,2,3,4,5], k=4, x=3
    -Output: [1,2,3,4]
    -
    -

    - - -

    Example 2:
    -

    -Input: [1,2,3,4,5], k=4, x=-1
    -Output: [1,2,3,4]
    +

    Given a sorted array arr, two integers k and x, find the k closest elements to x in the array. The result should also be sorted in ascending order. If there is a tie, the smaller elements are always preferred.

    + +

     

    +

    Example 1:

    +
    Input: arr = [1,2,3,4,5], k = 4, x = 3
    +Output: [1,2,3,4]
    +

    Example 2:

    +
    Input: arr = [1,2,3,4,5], k = 4, x = -1
    +Output: [1,2,3,4]
     
    -

    - -

    Note:
    -

      -
    1. The value k is positive and will always be smaller than the length of the sorted array.
    2. -
    3. Length of the given array is positive and will not exceed 104
    4. -
    5. Absolute value of elements in the array and x will not exceed 104
    6. -
    -

    - -
    - -

    -UPDATE (2017/9/19):
    -The arr parameter had been changed to an array of integers (instead of a list of integers). Please reload the code definition to get the latest changes. -

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= arr.length
    • +
    • 1 <= arr.length <= 10^4
    • +
    • Absolute value of elements in the array and x will not exceed 104
    • +
    ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md index a821a5a06..0b694d57e 100644 --- a/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md +++ b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md @@ -7,7 +7,7 @@ [< Previous](../longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit")                  -Next > +[Next >](../evaluate-boolean-expression "Evaluate Boolean Expression") ## [1439. Find the Kth Smallest Sum of a Matrix With Sorted Rows (Hard)](https://leetcode.com/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows "有序矩阵中的第 k 个最小数组和") diff --git a/problems/insert-into-a-binary-search-tree/README.md b/problems/insert-into-a-binary-search-tree/README.md index aadc7c3a0..11807618d 100644 --- a/problems/insert-into-a-binary-search-tree/README.md +++ b/problems/insert-into-a-binary-search-tree/README.md @@ -49,6 +49,16 @@ And the value to insert: 5 4
    +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the given tree will be between 0 and 10^4.
    • +
    • Each node will have a unique integer value from 0 to -10^8, inclusive.
    • +
    • -10^8 <= val <= 10^8
    • +
    • It's guaranteed that val does not exist in the original BST.
    • +
    + ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/median-of-two-sorted-arrays/README.md b/problems/median-of-two-sorted-arrays/README.md index b840cf7e6..c49c2fa3c 100644 --- a/problems/median-of-two-sorted-arrays/README.md +++ b/problems/median-of-two-sorted-arrays/README.md @@ -9,7 +9,7 @@                  [Next >](../longest-palindromic-substring "Longest Palindromic Substring") -## [4. Median of Two Sorted Arrays (Hard)](https://leetcode.com/problems/median-of-two-sorted-arrays "寻找两个有序数组的中位数") +## [4. Median of Two Sorted Arrays (Hard)](https://leetcode.com/problems/median-of-two-sorted-arrays "寻找两个正序数组的中位数")

    There are two sorted arrays nums1 and nums2 of size m and n respectively.

    diff --git a/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md b/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md new file mode 100644 index 000000000..0a303646b --- /dev/null +++ b/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../count-triplets-that-can-form-two-arrays-of-equal-xor "Count Triplets That Can Form Two Arrays of Equal XOR") +                 +[Next >](../number-of-ways-of-cutting-a-pizza "Number of Ways of Cutting a Pizza") + +## [1443. Minimum Time to Collect All Apples in a Tree (Medium)](https://leetcode.com/problems/minimum-time-to-collect-all-apples-in-a-tree "收集树上所有苹果的最少时间") + +

    Given an undirected tree consisting of n vertices numbered from 0 to n-1, which has some apples in their vertices. You spend 1 second to walk over one edge of the tree. Return the minimum time in seconds you have to spend in order to collect all apples in the tree starting at vertex 0 and coming back to this vertex.

    + +

    The edges of the undirected tree are given in the array edges, where edges[i] = [fromi, toi] means that exists an edge connecting the vertices fromi and toi. Additionally, there is a boolean array hasApple, where hasApple[i] = true means that vertex i has an apple, otherwise, it does not have any apple.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], hasApple = [false,false,true,false,true,true,false]
    +Output: 8 
    +Explanation: The figure above represents the given tree where red vertices have an apple. One optimal path to collect all apples is shown by the green arrows.  
    +
    + +

    Example 2:

    + +

    + +
    +Input: n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], hasApple = [false,false,true,false,false,true,false]
    +Output: 6
    +Explanation: The figure above represents the given tree where red vertices have an apple. One optimal path to collect all apples is shown by the green arrows.  
    +
    + +

    Example 3:

    + +
    +Input: n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], hasApple = [false,false,false,false,false,false,false]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 10^5
    • +
    • edges.length == n-1
    • +
    • edges[i].length == 2
    • +
    • 0 <= fromi, toi <= n-1
    • +
    • fromi < toi
    • +
    • hasApple.length == n
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + +### Hints +
    +Hint 1 +Note that if a node u contains an apple then all edges in the path from the root to the node u have to be used forward and backward (2 times). +
    + +
    +Hint 2 +Therefore use a depth-first search (DFS) to check if an edge will be used or not. +
    diff --git a/problems/number-complement/README.md b/problems/number-complement/README.md index 522c757ad..10d005f24 100644 --- a/problems/number-complement/README.md +++ b/problems/number-complement/README.md @@ -11,37 +11,34 @@ ## [476. Number Complement (Easy)](https://leetcode.com/problems/number-complement "数字的补数") -

    Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.

    +

    Given a positive integer num, output its complement number. The complement strategy is to flip the bits of its binary representation.

     

    - -

    Example 1:

    +

    Example 1:

    -Input: 5
    -Output: 2
    -Explanation: The binary representation of 5 is 101 (no leading zero bits), and its complement is 010. So you need to output 2.
    +Input: num = 5
    +Output: 2
    +Explanation: The binary representation of 5 is 101 (no leading zero bits), and its complement is 010. So you need to output 2.
     
    -

     

    - -

    Example 2:

    +

    Example 2:

    -Input: 1
    -Output: 0
    -Explanation: The binary representation of 1 is 1 (no leading zero bits), and its complement is 0. So you need to output 0.
    +Input: num = 1
    +Output: 0
    +Explanation: The binary representation of 1 is 1 (no leading zero bits), and its complement is 0. So you need to output 0.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. The given integer is guaranteed to fit within the range of a 32-bit signed integer.
    2. +
    + ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/number-of-ways-of-cutting-a-pizza/README.md b/problems/number-of-ways-of-cutting-a-pizza/README.md new file mode 100644 index 000000000..cb88c5e62 --- /dev/null +++ b/problems/number-of-ways-of-cutting-a-pizza/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../minimum-time-to-collect-all-apples-in-a-tree "Minimum Time to Collect All Apples in a Tree") +                 +Next > + +## [1444. Number of Ways of Cutting a Pizza (Hard)](https://leetcode.com/problems/number-of-ways-of-cutting-a-pizza "切披萨的方案数") + +

    Given a rectangular pizza represented as a rows x cols matrix containing the following characters: 'A' (an apple) and '.' (empty cell) and given the integer k. You have to cut the pizza into k pieces using k-1 cuts. 

    + +

    For each cut you choose the direction: vertical or horizontal, then you choose a cut position at the cell boundary and cut the pizza into two pieces. If you cut the pizza vertically, give the left part of the pizza to a person. If you cut the pizza horizontally, give the upper part of the pizza to a person. Give the last piece of pizza to the last person.

    + +

    Return the number of ways of cutting the pizza such that each piece contains at least one apple. Since the answer can be a huge number, return this modulo 10^9 + 7.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: pizza = ["A..","AAA","..."], k = 3
    +Output: 3 
    +Explanation: The figure above shows the three ways to cut the pizza. Note that pieces must contain at least one apple.
    +
    + +

    Example 2:

    + +
    +Input: pizza = ["A..","AA.","..."], k = 3
    +Output: 1
    +
    + +

    Example 3:

    + +
    +Input: pizza = ["A..","A..","..."], k = 1
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= rows, cols <= 50
    • +
    • rows == pizza.length
    • +
    • cols == pizza[i].length
    • +
    • 1 <= k <= 10
    • +
    • pizza consists of characters 'A' and '.' only.
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Note that after each cut the remaining piece of pizza always has the lower right coordinate at (rows-1,cols-1). +
    + +
    +Hint 2 +Use dynamic programming approach with states (row1, col1, c) which computes the number of ways of cutting the pizza using "c" cuts where the current piece of pizza has upper left coordinate at (row1,col1) and lower right coordinate at (rows-1,cols-1). +
    + +
    +Hint 3 +For the transitions try all vertical and horizontal cuts such that the piece of pizza you have to give a person must contain at least one apple. The base case is when c=k-1. +
    + +
    +Hint 4 +Additionally use a 2D dynamic programming to respond in O(1) if a piece of pizza contains at least one apple. +
    diff --git a/problems/ransom-note/README.md b/problems/ransom-note/README.md index 4b4f4adc0..d6a177735 100644 --- a/problems/ransom-note/README.md +++ b/problems/ransom-note/README.md @@ -11,23 +11,27 @@ ## [383. Ransom Note (Easy)](https://leetcode.com/problems/ransom-note "赎金信") -

    -Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom -note can be constructed from the magazines ; otherwise, it will return false. -

    -

    -Each letter in the magazine string can only be used once in your ransom note. -

    - -

    Note:
    -You may assume that both strings contain only lowercase letters. -

    - -
    -canConstruct("a", "b") -> false
    -canConstruct("aa", "ab") -> false
    -canConstruct("aa", "aab") -> true
    +

    Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; otherwise, it will return false.

    + +

    Each letter in the magazine string can only be used once in your ransom note.

    + +

     

    +

    Example 1:

    +
    Input: ransomNote = "a", magazine = "b"
    +Output: false
    +

    Example 2:

    +
    Input: ransomNote = "aa", magazine = "ab"
    +Output: false
    +

    Example 3:

    +
    Input: ransomNote = "aa", magazine = "aab"
    +Output: true
     
    +

     

    +

    Constraints:

    + +
      +
    • You may assume that both strings contain only lowercase letters.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/subarray-sum-equals-k/README.md b/problems/subarray-sum-equals-k/README.md index ca30d116a..40472369f 100644 --- a/problems/subarray-sum-equals-k/README.md +++ b/problems/subarray-sum-equals-k/README.md @@ -13,19 +13,20 @@

    Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.

    -

    Example 1:
    +

    Example 1:

    +
     Input:nums = [1,1,1], k = 2
     Output: 2
     
    -

    - -

    Note:
    -

      -
    1. The length of the array is in range [1, 20,000].
    2. -
    3. The range of numbers in the array is [-1000, 1000] and the range of the integer k is [-1e7, 1e7].
    4. -
    -

    + +

     

    +

    Constraints:

    + +
      +
    • The length of the array is in range [1, 20,000].
    • +
    • The range of numbers in the array is [-1000, 1000] and the range of the integer k is [-1e7, 1e7].
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/subtree-of-another-tree/README.md b/problems/subtree-of-another-tree/README.md index 6135f27a0..de3ec8219 100644 --- a/problems/subtree-of-another-tree/README.md +++ b/problems/subtree-of-another-tree/README.md @@ -11,13 +11,11 @@ ## [572. Subtree of Another Tree (Easy)](https://leetcode.com/problems/subtree-of-another-tree "另一个树的子树") -

    -Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree consists of a node in s and all of this node's descendants. The tree s could also be considered as a subtree of itself. -

    +

    Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree consists of a node in s and all of this node's descendants. The tree s could also be considered as a subtree of itself.

    -

    Example 1:
    +

    Example 1:
    +Given tree s:

    -Given tree s:
          3
         / \
    @@ -26,17 +24,19 @@ Given tree s:
      1   2
     
    Given tree t: +
        4 
       / \
      1   2
     
    Return true, because t has the same structure and node values with a subtree of s. -

    -

    Example 2:
    +

     

    + +

    Example 2:
    +Given tree s:

    -Given tree s:
          3
         / \
    @@ -47,13 +47,15 @@ Given tree s:
        0
     
    Given tree t: +
        4
       / \
      1   2
     
    Return false. -

    + +

     

    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/readme/1-300.md b/readme/1-300.md index a9af4d825..afacbba39 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -65,7 +65,7 @@ LeetCode Problems' Solutions | 1 | [Two Sum](https://leetcode.com/problems/two-sum "两数之和") | [Go](../problems/two-sum) | Easy | | 2 | [Add Two Numbers](https://leetcode.com/problems/add-two-numbers "两数相加") | [Go](../problems/add-two-numbers) | Medium | | 3 | [Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters "无重复字符的最长子串") | [Go](../problems/longest-substring-without-repeating-characters) | Medium | -| 4 | [Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays "寻找两个有序数组的中位数") | [Go](../problems/median-of-two-sorted-arrays) | Hard | +| 4 | [Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays "寻找两个正序数组的中位数") | [Go](../problems/median-of-two-sorted-arrays) | Hard | | 5 | [Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring "最长回文子串") | [Go](../problems/longest-palindromic-substring) | Medium | | 6 | [ZigZag Conversion](https://leetcode.com/problems/zigzag-conversion "Z 字形变换") | [Go](../problems/zigzag-conversion) | Medium | | 7 | [Reverse Integer](https://leetcode.com/problems/reverse-integer "整数反转") | [Go](../problems/reverse-integer) | Easy | diff --git a/tag/array/README.md b/tag/array/README.md index 78bfe62c8..17127a0a3 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1437 | [是否所有 1 都至少相隔 k 个元素](../../problems/check-if-all-1s-are-at-least-length-k-places-away) | [[数组](../array/README.md)] | Medium | | 1431 | [拥有最多糖果的孩子](../../problems/kids-with-the-greatest-number-of-candies) | [[数组](../array/README.md)] | Easy | @@ -254,5 +255,5 @@ | 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 11 | [盛最多水的容器](../../problems/container-with-most-water) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 4 | [寻找两个有序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 4 | [寻找两个正序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 1 | [两数之和](../../problems/two-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index fd809ab4a..d94a9fe77 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -92,4 +92,4 @@ | 34 | [在排序数组中查找元素的第一个和最后一个位置](../../problems/find-first-and-last-position-of-element-in-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 33 | [搜索旋转排序数组](../../problems/search-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 29 | [两数相除](../../problems/divide-two-integers) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 4 | [寻找两个有序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 4 | [寻找两个正序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index f3b48ab7c..31bd7b3f2 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1404 | [将二进制表示减到 1 的步骤数](../../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[排序](../sort/README.md)] [[位运算](../bit-manipulation/README.md)] | Easy | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index c58017106..ff73b6891 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1377 | [T 秒后青蛙的位置](../../problems/frog-position-after-t-seconds) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | | 1376 | [通知所有员工所需的时间](../../problems/time-needed-to-inform-all-employees) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index e761314cd..b0960f7f8 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -27,4 +27,4 @@ | 169 | [多数元素](../../problems/majority-element) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Easy | | 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 23 | [合并K个排序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 4 | [寻找两个有序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 4 | [寻找两个正序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 322c4233d..89963f0ca 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1444 | [切披萨的方案数](../../problems/number-of-ways-of-cutting-a-pizza) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1425 | [带限制的子序列和](../../problems/constrained-subsequence-sum) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 9d25bf985..8e62d08dc 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1427 | [Perform String Shifts](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1390 | [四因数](../../problems/four-divisors) | [[数学](../math/README.md)] | Medium | | 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/stack/README.md b/tag/stack/README.md index d274a91de..bbfe948a8 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1441 | [用栈操作构建数组](../../problems/build-an-array-with-stack-operations) | [[栈](../stack/README.md)] | Easy | | 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | | 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | | 1249 | [移除无效的括号](../../problems/minimum-remove-to-make-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/tree/README.md b/tag/tree/README.md index 537be7ad1..ec6576c36 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1430 | [Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree](../../problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | | 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] | Medium | | 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | From d45a97b0a5ad75056510d53c1c28862489d3b7ab Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 11 May 2020 13:02:42 +0800 Subject: [PATCH 062/145] A: tidy --- problems/constrained-subset-sum/README.md | 73 ----------------------- 1 file changed, 73 deletions(-) delete mode 100644 problems/constrained-subset-sum/README.md diff --git a/problems/constrained-subset-sum/README.md b/problems/constrained-subset-sum/README.md deleted file mode 100644 index 3a5366d9a..000000000 --- a/problems/constrained-subset-sum/README.md +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - -[< Previous](../diagonal-traverse-ii "Diagonal Traverse II") -                 -Next > - -## [1425. Constrained Subset Sum (Hard)](https://leetcode.com/problems/constrained-subset-sum "带限制的子序列和") - -

    Given an integer array nums and an integer k, return the maximum sum of a non-empty subset of that array such that for every two consecutive integers in the subset, nums[i] and nums[j], where i < j, the condition j - i <= k is satisfied.

    - -

    subset of an array is obtained by deleting some number of elements (can be zero) from the array, leaving the remaining elements in their original order.

    - -

     

    -

    Example 1:

    - -
    -Input: nums = [10,2,-10,5,20], k = 2
    -Output: 37
    -Explanation: The subset is [10, 2, 5, 20].
    -
    - -

    Example 2:

    - -
    -Input: nums = [-1,-2,-3], k = 1
    -Output: -1
    -Explanation: The subset must be non-empty, so we choose the largest number.
    -
    - -

    Example 3:

    - -
    -Input: nums = [10,-2,-10,-5,20], k = 2
    -Output: 23
    -Explanation: The subset is [10, -2, -5, 20].
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= k <= nums.length <= 10^5
    • -
    • -10^4 <= nums[i] <= 10^4
    • -
    - -### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - -### Hints -
    -Hint 1 -Use dynamic programming. -
    - -
    -Hint 2 -Let dp[i] be the solution for the prefix of the array that ends at index i, if the element at index i is in the subset. -
    - -
    -Hint 3 -dp[i] = nums[i] + max(0, dp[i-k], dp[i-k+1], ..., dp[i-1]) -
    - -
    -Hint 4 -Use a heap with the sliding window technique to optimize the dp. -
    From d2f3c6389efecf3fdf612178c03a708d61dc1d7c Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 18 May 2020 09:30:16 +0800 Subject: [PATCH 063/145] A: tidy --- README.md | 13 ++- problems/apples-oranges/README.md | 14 +++ problems/apples-oranges/mysql_schemas.sql | 10 +++ problems/consecutive-characters/README.md | 76 ++++++++++++++++ .../count-good-nodes-in-binary-tree/README.md | 64 +++++++++++++ problems/cousins-in-binary-tree/README.md | 18 ++-- .../README.md | 2 +- problems/find-the-town-judge/README.md | 65 ++++---------- .../README.md | 90 +++++++++++++++++++ problems/is-subsequence/README.md | 52 +++++------ .../README.md | 80 +++++++++++++++++ problems/npv-queries/README.md | 2 +- .../README.md | 83 +++++++++++++++++ .../README.md | 2 +- .../README.md | 70 +++++++++++++++ .../rearrange-words-in-a-sentence/README.md | 71 +++++++++++++++ problems/shortest-bridge/README.md | 46 +++------- problems/simplified-fractions/README.md | 64 +++++++++++++ .../README.md | 28 +++--- problems/valid-perfect-square/README.md | 29 +++--- problems/zuma-game/README.md | 4 +- tag/README.md | 12 +-- tag/array/README.md | 1 + tag/depth-first-search/README.md | 1 + tag/dynamic-programming/README.md | 1 + tag/geometry/README.md | 1 + tag/math/README.md | 1 + tag/sort/README.md | 2 + tag/string/README.md | 4 + tag/tags.json | 40 ++++----- tag/tree/README.md | 1 + 31 files changed, 763 insertions(+), 184 deletions(-) create mode 100644 problems/apples-oranges/README.md create mode 100644 problems/apples-oranges/mysql_schemas.sql create mode 100644 problems/consecutive-characters/README.md create mode 100644 problems/count-good-nodes-in-binary-tree/README.md create mode 100644 problems/form-largest-integer-with-digits-that-add-up-to-target/README.md create mode 100644 problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md create mode 100644 problems/number-of-students-doing-homework-at-a-given-time/README.md create mode 100644 problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md create mode 100644 problems/rearrange-words-in-a-sentence/README.md create mode 100644 problems/simplified-fractions/README.md diff --git a/README.md b/README.md index 6a142e8f8..02b82d890 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,15 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1453 | [Maximum Number of Darts Inside of a Circular Dartboard](https://leetcode.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard "圆形靶内的最大飞镖数量") | [Go](problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | Hard | +| 1452 | [People Whose List of Favorite Companies Is Not a Subset of Another List](https://leetcode.com/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list "收藏清单") | [Go](problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | Medium | +| 1451 | [Rearrange Words in a Sentence](https://leetcode.com/problems/rearrange-words-in-a-sentence "重新排列句子中的单词") | [Go](problems/rearrange-words-in-a-sentence) | Medium | +| 1450 | [Number of Students Doing Homework at a Given Time](https://leetcode.com/problems/number-of-students-doing-homework-at-a-given-time "在既定时间做作业的学生人数") | [Go](problems/number-of-students-doing-homework-at-a-given-time) | Easy | +| 1449 | [Form Largest Integer With Digits That Add up to Target](https://leetcode.com/problems/form-largest-integer-with-digits-that-add-up-to-target "数位成本和为目标值的最大数字") | [Go](problems/form-largest-integer-with-digits-that-add-up-to-target) | Hard | +| 1448 | [Count Good Nodes in Binary Tree](https://leetcode.com/problems/count-good-nodes-in-binary-tree "统计二叉树中好节点的数目") | [Go](problems/count-good-nodes-in-binary-tree) | Medium | +| 1447 | [Simplified Fractions](https://leetcode.com/problems/simplified-fractions "最简分数") | [Go](problems/simplified-fractions) | Medium | +| 1446 | [Consecutive Characters](https://leetcode.com/problems/consecutive-characters "连续字符") | [Go](problems/consecutive-characters) | Easy | +| 1445 | [Apples & Oranges](https://leetcode.com/problems/apples-oranges) 🔒 | [MySQL](problems/apples-oranges) | Medium | | 1444 | [Number of Ways of Cutting a Pizza](https://leetcode.com/problems/number-of-ways-of-cutting-a-pizza "切披萨的方案数") | [Go](problems/number-of-ways-of-cutting-a-pizza) | Hard | | 1443 | [Minimum Time to Collect All Apples in a Tree](https://leetcode.com/problems/minimum-time-to-collect-all-apples-in-a-tree "收集树上所有苹果的最少时间") | [Go](problems/minimum-time-to-collect-all-apples-in-a-tree) | Medium | | 1442 | [Count Triplets That Can Form Two Arrays of Equal XOR](https://leetcode.com/problems/count-triplets-that-can-form-two-arrays-of-equal-xor "形成两个异或相等数组的三元组数目") | [Go](problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | Medium | @@ -85,7 +94,7 @@ LeetCode Problems' Solutions | 1424 | [Diagonal Traverse II](https://leetcode.com/problems/diagonal-traverse-ii "对角线遍历 II") | [Go](problems/diagonal-traverse-ii) | Medium | | 1423 | [Maximum Points You Can Obtain from Cards](https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards "可获得的最大点数") | [Go](problems/maximum-points-you-can-obtain-from-cards) | Medium | | 1422 | [Maximum Score After Splitting a String](https://leetcode.com/problems/maximum-score-after-splitting-a-string "分割字符串的最大得分") | [Go](problems/maximum-score-after-splitting-a-string) | Easy | -| 1421 | [NPV Queries](https://leetcode.com/problems/npv-queries) 🔒 | [MySQL](problems/npv-queries) | Medium | +| 1421 | [NPV Queries](https://leetcode.com/problems/npv-queries "净现值查询") 🔒 | [MySQL](problems/npv-queries) | Medium | | 1420 | [Build Array Where You Can Find The Maximum Exactly K Comparisons](https://leetcode.com/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons "生成数组") | [Go](problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons) | Hard | | 1419 | [Minimum Number of Frogs Croaking](https://leetcode.com/problems/minimum-number-of-frogs-croaking "数青蛙") | [Go](problems/minimum-number-of-frogs-croaking) | Medium | | 1418 | [Display Table of Food Orders in a Restaurant](https://leetcode.com/problems/display-table-of-food-orders-in-a-restaurant "点菜展示表") | [Go](problems/display-table-of-food-orders-in-a-restaurant) | Medium | @@ -94,7 +103,7 @@ LeetCode Problems' Solutions | 1415 | [The k-th Lexicographical String of All Happy Strings of Length n](https://leetcode.com/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n "长度为 n 的开心字符串中字典序第 k 小的字符串") | [Go](problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | Medium | | 1414 | [Find the Minimum Number of Fibonacci Numbers Whose Sum Is K](https://leetcode.com/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k "和为 K 的最少斐波那契数字数目") | [Go](problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | Medium | | 1413 | [Minimum Value to Get Positive Step by Step Sum](https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum "逐步求和得到正数的最小值") | [Go](problems/minimum-value-to-get-positive-step-by-step-sum) | Easy | -| 1412 | [Find the Quiet Students in All Exams](https://leetcode.com/problems/find-the-quiet-students-in-all-exams) 🔒 | [MySQL](problems/find-the-quiet-students-in-all-exams) | Hard | +| 1412 | [Find the Quiet Students in All Exams](https://leetcode.com/problems/find-the-quiet-students-in-all-exams "查找成绩处于中游的的学生") 🔒 | [MySQL](problems/find-the-quiet-students-in-all-exams) | Hard | | 1411 | [Number of Ways to Paint N × 3 Grid](https://leetcode.com/problems/number-of-ways-to-paint-n-3-grid "给 N x 3 网格图涂色的方案数") | [Go](problems/number-of-ways-to-paint-n-3-grid) | Hard | | 1410 | [HTML Entity Parser](https://leetcode.com/problems/html-entity-parser "HTML 实体解析器") | [Go](problems/html-entity-parser) | Medium | | 1409 | [Queries on a Permutation With Key](https://leetcode.com/problems/queries-on-a-permutation-with-key "查询带键的排列") | [Go](problems/queries-on-a-permutation-with-key) | Medium | diff --git a/problems/apples-oranges/README.md b/problems/apples-oranges/README.md new file mode 100644 index 000000000..b9963c64d --- /dev/null +++ b/problems/apples-oranges/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../number-of-ways-of-cutting-a-pizza "Number of Ways of Cutting a Pizza") +                 +[Next >](../consecutive-characters "Consecutive Characters") + +## [1445. Apples & Oranges (Medium)](https://leetcode.com/problems/apples-oranges "") + + diff --git a/problems/apples-oranges/mysql_schemas.sql b/problems/apples-oranges/mysql_schemas.sql new file mode 100644 index 000000000..426703feb --- /dev/null +++ b/problems/apples-oranges/mysql_schemas.sql @@ -0,0 +1,10 @@ +Create table If Not Exists Sales (sale_date date, fruit ENUM('apples', 'oranges'), sold_num int); +Truncate table Sales; +insert into Sales (sale_date, fruit, sold_num) values ('2020-05-01', 'apples', '10'); +insert into Sales (sale_date, fruit, sold_num) values ('2020-05-01', 'oranges', '8'); +insert into Sales (sale_date, fruit, sold_num) values ('2020-05-02', 'apples', '15'); +insert into Sales (sale_date, fruit, sold_num) values ('2020-05-02', 'oranges', '15'); +insert into Sales (sale_date, fruit, sold_num) values ('2020-05-03', 'apples', '20'); +insert into Sales (sale_date, fruit, sold_num) values ('2020-05-03', 'oranges', '0'); +insert into Sales (sale_date, fruit, sold_num) values ('2020-05-04', 'apples', '15'); +insert into Sales (sale_date, fruit, sold_num) values ('2020-05-04', 'oranges', '16'); diff --git a/problems/consecutive-characters/README.md b/problems/consecutive-characters/README.md new file mode 100644 index 000000000..4dc643039 --- /dev/null +++ b/problems/consecutive-characters/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](../apples-oranges "Apples & Oranges") +                 +[Next >](../simplified-fractions "Simplified Fractions") + +## [1446. Consecutive Characters (Easy)](https://leetcode.com/problems/consecutive-characters "连续字符") + +

    Given a string s, the power of the string is the maximum length of a non-empty substring that contains only one unique character.

    + +

    Return the power of the string.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "leetcode"
    +Output: 2
    +Explanation: The substring "ee" is of length 2 with the character 'e' only.
    +
    + +

    Example 2:

    + +
    +Input: s = "abbcccddddeeeeedcba"
    +Output: 5
    +Explanation: The substring "eeeee" is of length 5 with the character 'e' only.
    +
    + +

    Example 3:

    + +
    +Input: s = "triplepillooooow"
    +Output: 5
    +
    + +

    Example 4:

    + +
    +Input: s = "hooraaaaaaaaaaay"
    +Output: 11
    +
    + +

    Example 5:

    + +
    +Input: s = "tourist"
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 500
    • +
    • s contains only lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Keep an array power where power[i] is the maximum power of the i-th character. +
    + +
    +Hint 2 +The answer is max(power[i]). +
    diff --git a/problems/count-good-nodes-in-binary-tree/README.md b/problems/count-good-nodes-in-binary-tree/README.md new file mode 100644 index 000000000..29231eb0b --- /dev/null +++ b/problems/count-good-nodes-in-binary-tree/README.md @@ -0,0 +1,64 @@ + + + + + + + +[< Previous](../simplified-fractions "Simplified Fractions") +                 +[Next >](../form-largest-integer-with-digits-that-add-up-to-target "Form Largest Integer With Digits That Add up to Target") + +## [1448. Count Good Nodes in Binary Tree (Medium)](https://leetcode.com/problems/count-good-nodes-in-binary-tree "统计二叉树中好节点的数目") + +

    Given a binary tree root, a node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X.

    + +

    Return the number of good nodes in the binary tree.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: root = [3,1,4,3,null,1,5]
    +Output: 4
    +Explanation: Nodes in blue are good.
    +Root Node (3) is always a good node.
    +Node 4 -> (3,4) is the maximum value in the path starting from the root.
    +Node 5 -> (3,4,5) is the maximum value in the path
    +Node 3 -> (3,1,3) is the maximum value in the path.
    + +

    Example 2:

    + +

    + +
    +Input: root = [3,3,null,4,2]
    +Output: 3
    +Explanation: Node 2 -> (3, 3, 2) is not good, because "3" is higher than it.
    + +

    Example 3:

    + +
    +Input: root = [1]
    +Output: 1
    +Explanation: Root is considered as good.
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the binary tree is in the range [1, 10^5].
    • +
    • Each node's value is between [-10^4, 10^4].
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + +### Hints +
    +Hint 1 +Use DFS (Depth First Search) to traverse the tree, and constantly keep track of the current path maximum. +
    diff --git a/problems/cousins-in-binary-tree/README.md b/problems/cousins-in-binary-tree/README.md index b56db424b..47666787e 100644 --- a/problems/cousins-in-binary-tree/README.md +++ b/problems/cousins-in-binary-tree/README.md @@ -45,24 +45,18 @@
     Input: root = [1,2,3,null,4], x = 2, y = 3
    -Output: false
    - -

     

    +Output: false +
    -

    Note:

    +

     

    +

    Constraints:

    -
      +
      • The number of nodes in the tree will be between 2 and 100.
      • Each node has a unique integer value from 1 to 100.
      • -
    - -
    -
    -
     
    -
    -
    + ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/find-the-quiet-students-in-all-exams/README.md b/problems/find-the-quiet-students-in-all-exams/README.md index c6be9f9ec..1bf21ead1 100644 --- a/problems/find-the-quiet-students-in-all-exams/README.md +++ b/problems/find-the-quiet-students-in-all-exams/README.md @@ -9,6 +9,6 @@                  [Next >](../minimum-value-to-get-positive-step-by-step-sum "Minimum Value to Get Positive Step by Step Sum") -## [1412. Find the Quiet Students in All Exams (Hard)](https://leetcode.com/problems/find-the-quiet-students-in-all-exams "") +## [1412. Find the Quiet Students in All Exams (Hard)](https://leetcode.com/problems/find-the-quiet-students-in-all-exams "查找成绩处于中游的的学生") diff --git a/problems/find-the-town-judge/README.md b/problems/find-the-town-judge/README.md index 89542cda9..a49a80b9f 100644 --- a/problems/find-the-town-judge/README.md +++ b/problems/find-the-town-judge/README.md @@ -26,60 +26,33 @@

    If the town judge exists and can be identified, return the label of the town judge.  Otherwise, return -1.

     

    -

    Example 1:

    - -
    -Input: N = 2, trust = [[1,2]]
    -Output: 2
    -
    - -
    -

    Example 2:

    - -
    -Input: N = 3, trust = [[1,3],[2,3]]
    -Output: 3
    +
    Input: N = 2, trust = [[1,2]]
    +Output: 2
    +

    Example 2:

    +
    Input: N = 3, trust = [[1,3],[2,3]]
    +Output: 3
    +

    Example 3:

    +
    Input: N = 3, trust = [[1,3],[2,3],[3,1]]
    +Output: -1
    +

    Example 4:

    +
    Input: N = 3, trust = [[1,2],[2,3]]
    +Output: -1
    +

    Example 5:

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

    Example 3:

    - -
    -Input: N = 3, trust = [[1,3],[2,3],[3,1]]
    -Output: -1
    -
    - -
    -

    Example 4:

    - -
    -Input: N = 3, trust = [[1,2],[2,3]]
    -Output: -1
    -
    - -
    -

    Example 5:

    - -
    -Input: N = 4, trust = [[1,3],[1,4],[2,3],[2,4],[4,3]]
    -Output: 3
    -

     

    -
    -
    -
    -
    - -

    Note:

    +

    Constraints:

    -
      +
      • 1 <= N <= 1000
      • -
      • trust.length <= 10000
      • +
      • 0 <= trust.length <= 10^4
      • +
      • trust[i].length == 2
      • trust[i] are all different
      • trust[i][0] != trust[i][1]
      • 1 <= trust[i][0], trust[i][1] <= N
      • -
    + ### Related Topics [[Graph](../../tag/graph/README.md)] diff --git a/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md b/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md new file mode 100644 index 000000000..448b78012 --- /dev/null +++ b/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md @@ -0,0 +1,90 @@ + + + + + + + +[< Previous](../count-good-nodes-in-binary-tree "Count Good Nodes in Binary Tree") +                 +[Next >](../number-of-students-doing-homework-at-a-given-time "Number of Students Doing Homework at a Given Time") + +## [1449. Form Largest Integer With Digits That Add up to Target (Hard)](https://leetcode.com/problems/form-largest-integer-with-digits-that-add-up-to-target "数位成本和为目标值的最大数字") + +

    Given an array of integers cost and an integer target. Return the maximum integer you can paint under the following rules:

    + +
      +
    • The cost of painting a digit (i+1) is given by cost[i] (0 indexed).
    • +
    • The total cost used must be equal to target.
    • +
    • Integer does not have digits 0.
    • +
    + +

    Since the answer may be too large, return it as string.

    + +

    If there is no way to paint any integer given the condition, return "0".

    + +

     

    +

    Example 1:

    + +
    +Input: cost = [4,3,2,5,6,7,2,5,5], target = 9
    +Output: "7772"
    +Explanation:  The cost to paint the digit '7' is 2, and the digit '2' is 3. Then cost("7772") = 2*3+ 3*1 = 9. You could also paint "997", but "7772" is the largest number.
    +Digit    cost
    +  1  ->   4
    +  2  ->   3
    +  3  ->   2
    +  4  ->   5
    +  5  ->   6
    +  6  ->   7
    +  7  ->   2
    +  8  ->   5
    +  9  ->   5
    +
    + +

    Example 2:

    + +
    +Input: cost = [7,6,5,5,5,6,8,7,8], target = 12
    +Output: "85"
    +Explanation: The cost to paint the digit '8' is 7, and the digit '5' is 5. Then cost("85") = 7 + 5 = 12.
    +
    + +

    Example 3:

    + +
    +Input: cost = [2,4,6,2,4,6,4,4,4], target = 5
    +Output: "0"
    +Explanation: It's not possible to paint any integer with total cost equal to target.
    +
    + +

    Example 4:

    + +
    +Input: cost = [6,10,15,40,40,40,40,40,40], target = 47
    +Output: "32211"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • cost.length == 9
    • +
    • 1 <= cost[i] <= 5000
    • +
    • 1 <= target <= 5000
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Use dynamic programming to find the maximum digits to paint given a total cost. +
    + +
    +Hint 2 +Build the largest number possible using this DP table. +
    diff --git a/problems/is-subsequence/README.md b/problems/is-subsequence/README.md index 283334728..0155e185f 100644 --- a/problems/is-subsequence/README.md +++ b/problems/is-subsequence/README.md @@ -11,36 +11,32 @@ ## [392. Is Subsequence (Easy)](https://leetcode.com/problems/is-subsequence "判断子序列") -

    -Given a string s and a string t, check if s is subsequence of t. -

    - -

    -You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) string, and s is a short string (<=100). -

    - -

    -A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, "ace" is a subsequence of "abcde" while "aec" is not). -

    - -

    Example 1:
    -s = "abc", t = "ahbgdc" -

    -

    -Return true. -

    - -

    Example 2:
    -s = "axc", t = "ahbgdc" -

    -

    -Return false. -

    +

    Given a string s and a string t, check if s is subsequence of t.

    -

    Follow up:
    -If there are lots of incoming S, say S1, S2, ... , Sk where k >= 1B, and you want to check one by one to see if T has its subsequence. In this scenario, how would you change your code?

    +

    A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, "ace" is a subsequence of "abcde" while "aec" is not).

    -

    Credits:
    Special thanks to @pbrother for adding this problem and creating all test cases.

    +

    Follow up:
    +If there are lots of incoming S, say S1, S2, ... , Sk where k >= 1B, and you want to check one by one to see if T has its subsequence. In this scenario, how would you change your code?

    + +

    Credits:
    +Special thanks to @pbrother for adding this problem and creating all test cases.

    + +

     

    +

    Example 1:

    +
    Input: s = "abc", t = "ahbgdc"
    +Output: true
    +

    Example 2:

    +
    Input: s = "axc", t = "ahbgdc"
    +Output: false
    +
    +

     

    +

    Constraints:

    + +
      +
    • 0 <= s.length <= 100
    • +
    • 0 <= t.length <= 10^4
    • +
    • Both strings consists only of lowercase characters.
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md b/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md new file mode 100644 index 000000000..a6bd74524 --- /dev/null +++ b/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list "People Whose List of Favorite Companies Is Not a Subset of Another List") +                 +Next > + +## [1453. Maximum Number of Darts Inside of a Circular Dartboard (Hard)](https://leetcode.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard "圆形靶内的最大飞镖数量") + +

    You have a very large square wall and a circular dartboard placed on the wall. You have been challenged to throw darts into the board blindfolded. Darts thrown at the wall are represented as an array of points on a 2D plane. 

    + +

    Return the maximum number of points that are within or lie on any circular dartboard of radius r.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: points = [[-2,0],[2,0],[0,2],[0,-2]], r = 2
    +Output: 4
    +Explanation: Circle dartboard with center in (0,0) and radius = 2 contain all points.
    +
    + +

    Example 2:

    + +

    + +
    +Input: points = [[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]], r = 5
    +Output: 5
    +Explanation: Circle dartboard with center in (0,4) and radius = 5 contain all points except the point (7,8).
    +
    + +

    Example 3:

    + +
    +Input: points = [[-2,0],[2,0],[0,2],[0,-2]], r = 1
    +Output: 1
    +
    + +

    Example 4:

    + +
    +Input: points = [[1,2],[3,5],[1,-1],[2,3],[4,1],[1,3]], r = 2
    +Output: 4
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= points.length <= 100
    • +
    • points[i].length == 2
    • +
    • -10^4 <= points[i][0], points[i][1] <= 10^4
    • +
    • 1 <= r <= 5000
    • +
    + +### Related Topics + [[Geometry](../../tag/geometry/README.md)] + +### Hints +
    +Hint 1 +If there is an optimal solution, you can always move the circle so that two points lie on the boundary of the circle. +
    + +
    +Hint 2 +When the radius is fixed, you can find either 0 or 1 or 2 circles that pass two given points at the same time. +
    + +
    +Hint 3 +Loop for each pair of points and find the center of the circle, after that count the number of points inside the circle. +
    diff --git a/problems/npv-queries/README.md b/problems/npv-queries/README.md index add374f2c..91c34c7b9 100644 --- a/problems/npv-queries/README.md +++ b/problems/npv-queries/README.md @@ -9,6 +9,6 @@                  [Next >](../maximum-score-after-splitting-a-string "Maximum Score After Splitting a String") -## [1421. NPV Queries (Medium)](https://leetcode.com/problems/npv-queries "") +## [1421. NPV Queries (Medium)](https://leetcode.com/problems/npv-queries "净现值查询") diff --git a/problems/number-of-students-doing-homework-at-a-given-time/README.md b/problems/number-of-students-doing-homework-at-a-given-time/README.md new file mode 100644 index 000000000..549a039e0 --- /dev/null +++ b/problems/number-of-students-doing-homework-at-a-given-time/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../form-largest-integer-with-digits-that-add-up-to-target "Form Largest Integer With Digits That Add up to Target") +                 +[Next >](../rearrange-words-in-a-sentence "Rearrange Words in a Sentence") + +## [1450. Number of Students Doing Homework at a Given Time (Easy)](https://leetcode.com/problems/number-of-students-doing-homework-at-a-given-time "在既定时间做作业的学生人数") + +

    Given two integer arrays startTime and endTime and given an integer queryTime.

    + +

    The ith student started doing their homework at the time startTime[i] and finished it at time endTime[i].

    + +

    Return the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime lays in the interval [startTime[i], endTime[i]] inclusive.

    + +

     

    +

    Example 1:

    + +
    +Input: startTime = [1,2,3], endTime = [3,2,7], queryTime = 4
    +Output: 1
    +Explanation: We have 3 students where:
    +The first student started doing homework at time 1 and finished at time 3 and wasn't doing anything at time 4.
    +The second student started doing homework at time 2 and finished at time 2 and also wasn't doing anything at time 4.
    +The third student started doing homework at time 3 and finished at time 7 and was the only student doing homework at time 4.
    +
    + +

    Example 2:

    + +
    +Input: startTime = [4], endTime = [4], queryTime = 4
    +Output: 1
    +Explanation: The only student was doing their homework at the queryTime.
    +
    + +

    Example 3:

    + +
    +Input: startTime = [4], endTime = [4], queryTime = 5
    +Output: 0
    +
    + +

    Example 4:

    + +
    +Input: startTime = [1,1,1,1], endTime = [1,3,2,4], queryTime = 7
    +Output: 0
    +
    + +

    Example 5:

    + +
    +Input: startTime = [9,8,7,6,5,4,3,2,1], endTime = [10,10,10,10,10,10,10,10,10], queryTime = 5
    +Output: 5
    +
    + +

     

    +

    Constraints:

    + +
      +
    • startTime.length == endTime.length
    • +
    • 1 <= startTime.length <= 100
    • +
    • 1 <= startTime[i] <= endTime[i] <= 1000
    • +
    • 1 <= queryTime <= 1000
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Imagine that startTime[i] and endTime[i] form an interval (i.e. [startTime[i], endTime[i]]). +
    + +
    +Hint 2 +The answer is how many times the queryTime laid in those mentioned intervals. +
    diff --git a/problems/number-of-ways-of-cutting-a-pizza/README.md b/problems/number-of-ways-of-cutting-a-pizza/README.md index cb88c5e62..0d831de8c 100644 --- a/problems/number-of-ways-of-cutting-a-pizza/README.md +++ b/problems/number-of-ways-of-cutting-a-pizza/README.md @@ -7,7 +7,7 @@ [< Previous](../minimum-time-to-collect-all-apples-in-a-tree "Minimum Time to Collect All Apples in a Tree")                  -Next > +[Next >](../apples-oranges "Apples & Oranges") ## [1444. Number of Ways of Cutting a Pizza (Hard)](https://leetcode.com/problems/number-of-ways-of-cutting-a-pizza "切披萨的方案数") diff --git a/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md b/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md new file mode 100644 index 000000000..9e3302460 --- /dev/null +++ b/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../rearrange-words-in-a-sentence "Rearrange Words in a Sentence") +                 +[Next >](../maximum-number-of-darts-inside-of-a-circular-dartboard "Maximum Number of Darts Inside of a Circular Dartboard") + +## [1452. People Whose List of Favorite Companies Is Not a Subset of Another List (Medium)](https://leetcode.com/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list "收藏清单") + +

    Given the array favoriteCompanies where favoriteCompanies[i] is the list of favorites companies for the ith person (indexed from 0).

    + +

    Return the indices of people whose list of favorite companies is not a subset of any other list of favorites companies. You must return the indices in increasing order.

    + +

     

    +

    Example 1:

    + +
    +Input: favoriteCompanies = [["leetcode","google","facebook"],["google","microsoft"],["google","facebook"],["google"],["amazon"]]
    +Output: [0,1,4] 
    +Explanation: 
    +Person with index=2 has favoriteCompanies[2]=["google","facebook"] which is a subset of favoriteCompanies[0]=["leetcode","google","facebook"] corresponding to the person with index 0. 
    +Person with index=3 has favoriteCompanies[3]=["google"] which is a subset of favoriteCompanies[0]=["leetcode","google","facebook"] and favoriteCompanies[1]=["google","microsoft"]. 
    +Other lists of favorite companies are not a subset of another list, therefore, the answer is [0,1,4].
    +
    + +

    Example 2:

    + +
    +Input: favoriteCompanies = [["leetcode","google","facebook"],["leetcode","amazon"],["facebook","google"]]
    +Output: [0,1] 
    +Explanation: In this case favoriteCompanies[2]=["facebook","google"] is a subset of favoriteCompanies[0]=["leetcode","google","facebook"], therefore, the answer is [0,1].
    +
    + +

    Example 3:

    + +
    +Input: favoriteCompanies = [["leetcode"],["google"],["facebook"],["amazon"]]
    +Output: [0,1,2,3]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= favoriteCompanies.length <= 100
    • +
    • 1 <= favoriteCompanies[i].length <= 500
    • +
    • 1 <= favoriteCompanies[i][j].length <= 20
    • +
    • All strings in favoriteCompanies[i] are distinct.
    • +
    • All lists of favorite companies are distinct, that is, If we sort alphabetically each list then favoriteCompanies[i] != favoriteCompanies[j].
    • +
    • All strings consist of lowercase English letters only.
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Use hashing to convert company names in numbers and then for each list check if this is a subset of any other list. +
    + +
    +Hint 2 +In order to check if a list is a subset of another list, use two pointers technique to get a linear solution for this task. The total complexity will be O(n^2 * m) where n is the number of lists and m is the maximum number of elements in a list. +
    diff --git a/problems/rearrange-words-in-a-sentence/README.md b/problems/rearrange-words-in-a-sentence/README.md new file mode 100644 index 000000000..2abdf219e --- /dev/null +++ b/problems/rearrange-words-in-a-sentence/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../number-of-students-doing-homework-at-a-given-time "Number of Students Doing Homework at a Given Time") +                 +[Next >](../people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list "People Whose List of Favorite Companies Is Not a Subset of Another List") + +## [1451. Rearrange Words in a Sentence (Medium)](https://leetcode.com/problems/rearrange-words-in-a-sentence "重新排列句子中的单词") + +

    Given a sentence text (A sentence is a string of space-separated words) in the following format:

    + +
      +
    • First letter is in upper case.
    • +
    • Each word in text are separated by a single space.
    • +
    + +

    Your task is to rearrange the words in text such that all words are rearranged in an increasing order of their lengths. If two words have the same length, arrange them in their original order.

    + +

    Return the new text following the format shown above.

    + +

     

    +

    Example 1:

    + +
    +Input: text = "Leetcode is cool"
    +Output: "Is cool leetcode"
    +Explanation: There are 3 words, "Leetcode" of length 8, "is" of length 2 and "cool" of length 4.
    +Output is ordered by length and the new first word starts with capital letter.
    +
    + +

    Example 2:

    + +
    +Input: text = "Keep calm and code on"
    +Output: "On and keep calm code"
    +Explanation: Output is ordered as follows:
    +"On" 2 letters.
    +"and" 3 letters.
    +"keep" 4 letters in case of tie order by position in original text.
    +"calm" 4 letters.
    +"code" 4 letters.
    +
    + +

    Example 3:

    + +
    +Input: text = "To be or not to be"
    +Output: "To be or to be not"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • text begins with a capital letter and then contains lowercase letters and single space between words.
    • +
    • 1 <= text.length <= 10^5
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Store each word and their relative position. Then, sort them by length of words in case of tie by their original order. +
    diff --git a/problems/shortest-bridge/README.md b/problems/shortest-bridge/README.md index 48adaccaa..9c4479453 100644 --- a/problems/shortest-bridge/README.md +++ b/problems/shortest-bridge/README.md @@ -18,45 +18,23 @@

    Return the smallest number of 0s that must be flipped.  (It is guaranteed that the answer is at least 1.)

     

    -

    Example 1:

    - -
    -Input: [[0,1],[1,0]]
    -Output: 1
    -
    - -
    -

    Example 2:

    - -
    -Input: [[0,1,0],[0,0,0],[0,0,1]]
    -Output: 2
    +
    Input: A = [[0,1],[1,0]]
    +Output: 1
    +

    Example 2:

    +
    Input: A = [[0,1,0],[0,0,0],[0,0,1]]
    +Output: 2
    +

    Example 3:

    +
    Input: A = [[1,1,1,1,1],[1,0,0,0,1],[1,0,1,0,1],[1,0,0,0,1],[1,1,1,1,1]]
    +Output: 1
     
    - -
    -

    Example 3:

    - -
    -Input: [[1,1,1,1,1],[1,0,0,0,1],[1,0,1,0,1],[1,0,0,0,1],[1,1,1,1,1]]
    -Output: 1
    -

     

    -
    -
    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= A.length = A[0].length <= 100
    2. +
        +
      • 2 <= A.length == A[0].length <= 100
      • A[i][j] == 0 or A[i][j] == 1
      • -
    - -
    -
    -
     
    -
    -
    + ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/simplified-fractions/README.md b/problems/simplified-fractions/README.md new file mode 100644 index 000000000..eb7856621 --- /dev/null +++ b/problems/simplified-fractions/README.md @@ -0,0 +1,64 @@ + + + + + + + +[< Previous](../consecutive-characters "Consecutive Characters") +                 +[Next >](../count-good-nodes-in-binary-tree "Count Good Nodes in Binary Tree") + +## [1447. Simplified Fractions (Medium)](https://leetcode.com/problems/simplified-fractions "最简分数") + +

    Given an integer n, return a list of all simplified fractions between 0 and 1 (exclusive) such that the denominator is less-than-or-equal-to n. The fractions can be in any order.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 2
    +Output: ["1/2"]
    +Explanation: "1/2" is the only unique fraction with a denominator less-than-or-equal-to 2.
    + +

    Example 2:

    + +
    +Input: n = 3
    +Output: ["1/2","1/3","2/3"]
    +
    + +

    Example 3:

    + +
    +Input: n = 4
    +Output: ["1/2","1/3","1/4","2/3","3/4"]
    +Explanation: "2/4" is not a simplified fraction because it can be simplified to "1/2".
    + +

    Example 4:

    + +
    +Input: n = 1
    +Output: []
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 100
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +A fraction is fully simplified if there is no integer that divides cleanly into the numerator and denominator. +
    + +
    +Hint 2 +In other words the greatest common divisor of the numerator and the denominator of a simplified fraction is 1. +
    diff --git a/problems/single-element-in-a-sorted-array/README.md b/problems/single-element-in-a-sorted-array/README.md index 72e0941e2..b76ff4d35 100644 --- a/problems/single-element-in-a-sorted-array/README.md +++ b/problems/single-element-in-a-sorted-array/README.md @@ -13,22 +13,20 @@

    You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Find this single element that appears only once.

    -

     

    - -

    Example 1:

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

    Follow up: Your solution should run in O(log n) time and O(1) space.

    -

    Example 2:

    - -
    -Input: [3,3,7,7,10,11,11]
    -Output: 10
    +

     

    +

    Example 1:

    +
    Input: nums = [1,1,2,3,3,4,4,8,8]
    +Output: 2
    +

    Example 2:

    +
    Input: nums = [3,3,7,7,10,11,11]
    +Output: 10
     
    -

     

    +

    Constraints:

    -

    Note: Your solution should run in O(log n) time and O(1) space.

    +
      +
    • 1 <= nums.length <= 10^5
    • +
    • 0 <= nums[i] <= 10^5
    • +
    diff --git a/problems/valid-perfect-square/README.md b/problems/valid-perfect-square/README.md index 599552df1..0ba60992e 100644 --- a/problems/valid-perfect-square/README.md +++ b/problems/valid-perfect-square/README.md @@ -11,27 +11,24 @@ ## [367. Valid Perfect Square (Easy)](https://leetcode.com/problems/valid-perfect-square "有效的完全平方数") -

    Given a positive integer num, write a function which returns True if num is a perfect square else False.

    +

    Given a positive integer num, write a function which returns True if num is a perfect square else False.

    -

    Note: Do not use any built-in library function such as sqrt.

    +

    Follow up: Do not use any built-in library function such as sqrt.

    +

     

    Example 1:

    - -
    -
    -Input: 16
    -Output: true
    +
    Input: num = 16
    +Output: true
    +

    Example 2:

    +
    Input: num = 14
    +Output: false
     
    +

     

    +

    Constraints:

    -
    -

    Example 2:

    - -
    -Input: 14
    -Output: false
    -
    -
    -
    +
      +
    • 1 <= num <= 2^31 - 1
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/zuma-game/README.md b/problems/zuma-game/README.md index 03e93ae42..1508f7e9c 100644 --- a/problems/zuma-game/README.md +++ b/problems/zuma-game/README.md @@ -55,8 +55,8 @@
    • You may assume that the initial row of balls on the table won’t have any 3 or more consecutive balls with the same color.
    • -
    • The number of balls on the table won't exceed 16, and the string represents these balls is called "board" in the input.
    • -
    • The number of balls in your hand won't exceed 5, and the string represents these balls is called "hand" in the input.
    • +
    • 1 <= board.length <= 16
    • +
    • 1 <= hand.length <= 5
    • Both input strings will be non-empty and only contain characters 'R','Y','B','G','W'.
    diff --git a/tag/README.md b/tag/README.md index 854b8235f..3653effbd 100644 --- a/tag/README.md +++ b/tag/README.md @@ -10,20 +10,20 @@ | # | Topic | 话题 | | # | Topic | 话题 | | :-: | - | :-: | - | :-: | - | :-: | | 1 | [Array](array/README.md) | [数组](https://openset.github.io/tags/array/) | | 2 | [Dynamic Programming](dynamic-programming/README.md) | [动态规划](https://openset.github.io/tags/dynamic-programming/) | -| 3 | [Math](math/README.md) | [数学](https://openset.github.io/tags/math/) | | 4 | [String](string/README.md) | [字符串](https://openset.github.io/tags/string/) | -| 5 | [Tree](tree/README.md) | [树](https://openset.github.io/tags/tree/) | | 6 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | -| 7 | [Depth-first Search](depth-first-search/README.md) | [深度优先搜索](https://openset.github.io/tags/depth-first-search/) | | 8 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | +| 3 | [String](string/README.md) | [字符串](https://openset.github.io/tags/string/) | | 4 | [Math](math/README.md) | [数学](https://openset.github.io/tags/math/) | +| 5 | [Tree](tree/README.md) | [树](https://openset.github.io/tags/tree/) | | 6 | [Depth-first Search](depth-first-search/README.md) | [深度优先搜索](https://openset.github.io/tags/depth-first-search/) | +| 7 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | | 8 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 9 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | | 11 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 12 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | -| 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | -| 15 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | +| 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | +| 15 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | | 19 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 20 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | | 21 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | | 22 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | | 23 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | | 25 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | | 27 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | -| 29 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 30 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | +| 29 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 31 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | | 32 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 33 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | | 34 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 35 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | diff --git a/tag/array/README.md b/tag/array/README.md index 17127a0a3..b311be9fb 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1450 | [在既定时间做作业的学生人数](../../problems/number-of-students-doing-homework-at-a-given-time) | [[数组](../array/README.md)] | Easy | | 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1437 | [是否所有 1 都至少相隔 k 个元素](../../problems/check-if-all-1s-are-at-least-length-k-places-away) | [[数组](../array/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index ff73b6891..e025264a9 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1377 | [T 秒后青蛙的位置](../../problems/frog-position-after-t-seconds) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 89963f0ca..db2bd32a3 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1444 | [切披萨的方案数](../../problems/number-of-ways-of-cutting-a-pizza) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1425 | [带限制的子序列和](../../problems/constrained-subsequence-sum) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index 1a0038d3e..6cdb8d902 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1453 | [圆形靶内的最大飞镖数量](../../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | [[几何](../geometry/README.md)] | Hard | | 1401 | [圆和矩形是否有重叠](../../problems/circle-and-rectangle-overlapping) | [[几何](../geometry/README.md)] | Medium | | 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] | Easy | | 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | diff --git a/tag/math/README.md b/tag/math/README.md index 8e62d08dc..b8042189d 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] | Medium | | 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1427 | [Perform String Shifts](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1390 | [四因数](../../problems/four-divisors) | [[数学](../math/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index bc64cd5ac..ffdc26b64 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | | 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | | 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index 50dcda9dc..04c8d34cd 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1446 | [连续字符](../../problems/consecutive-characters) | [[字符串](../string/README.md)] | Easy | | 1436 | [旅行终点站](../../problems/destination-city) | [[字符串](../string/README.md)] | Easy | | 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1432 | [改变一个整数能得到的最大差值](../../problems/max-difference-you-can-get-from-changing-an-integer) | [[字符串](../string/README.md)] | Medium | diff --git a/tag/tags.json b/tag/tags.json index 1f0b44a86..8981e1c12 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -9,31 +9,31 @@ "Slug": "dynamic-programming", "TranslatedName": "动态规划" }, - { - "Name": "Math", - "Slug": "math", - "TranslatedName": "数学" - }, { "Name": "String", "Slug": "string", "TranslatedName": "字符串" }, + { + "Name": "Math", + "Slug": "math", + "TranslatedName": "数学" + }, { "Name": "Tree", "Slug": "tree", "TranslatedName": "树" }, - { - "Name": "Hash Table", - "Slug": "hash-table", - "TranslatedName": "哈希表" - }, { "Name": "Depth-first Search", "Slug": "depth-first-search", "TranslatedName": "深度优先搜索" }, + { + "Name": "Hash Table", + "Slug": "hash-table", + "TranslatedName": "哈希表" + }, { "Name": "Binary Search", "Slug": "binary-search", @@ -64,16 +64,16 @@ "Slug": "backtracking", "TranslatedName": "回溯算法" }, - { - "Name": "Design", - "Slug": "design", - "TranslatedName": "设计" - }, { "Name": "Sort", "Slug": "sort", "TranslatedName": "排序" }, + { + "Name": "Design", + "Slug": "design", + "TranslatedName": "设计" + }, { "Name": "Bit Manipulation", "Slug": "bit-manipulation", @@ -139,16 +139,16 @@ "Slug": "minimax", "TranslatedName": "极小化极大" }, - { - "Name": "Binary Indexed Tree", - "Slug": "binary-indexed-tree", - "TranslatedName": "树状数组" - }, { "Name": "Geometry", "Slug": "geometry", "TranslatedName": "几何" }, + { + "Name": "Binary Indexed Tree", + "Slug": "binary-indexed-tree", + "TranslatedName": "树状数组" + }, { "Name": "Line Sweep", "Slug": "line-sweep", diff --git a/tag/tree/README.md b/tag/tree/README.md index ec6576c36..ee49bf21c 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1430 | [Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree](../../problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | | 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] | Medium | From f9b69bc9f2671cae9236d81cee106cbda02e998a Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 26 May 2020 13:05:06 +0800 Subject: [PATCH 064/145] A: new --- README.md | 9 +- problems/active-users/README.md | 14 +++ problems/active-users/mysql_schemas.sql | 15 ++++ problems/apples-oranges/README.md | 2 +- .../README.md | 90 +++++++++++++++++++ .../README.md | 2 +- problems/find-peak-element/README.md | 4 +- problems/find-pivot-index/README.md | 28 +++--- .../README.md | 2 +- .../kth-smallest-element-in-a-bst/README.md | 11 ++- .../README.md | 2 +- .../README.md | 60 +++++++++++++ .../README.md | 2 +- .../README.md | 82 +++++++++++++++++ problems/mini-parser/README.md | 29 +++--- problems/odd-even-linked-list/README.md | 4 +- problems/permutation-in-string/README.md | 7 +- .../README.md | 68 ++++++++++++++ readme/601-900.md | 2 +- tag/array/README.md | 2 +- tag/bit-manipulation/README.md | 1 + tag/depth-first-search/README.md | 1 + tag/dynamic-programming/README.md | 3 +- tag/sliding-window/README.md | 1 + tag/string/README.md | 4 +- tag/tree/README.md | 1 + 26 files changed, 396 insertions(+), 50 deletions(-) create mode 100644 problems/active-users/README.md create mode 100644 problems/active-users/mysql_schemas.sql create mode 100644 problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md create mode 100644 problems/max-dot-product-of-two-subsequences/README.md create mode 100644 problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md create mode 100644 problems/pseudo-palindromic-paths-in-a-binary-tree/README.md diff --git a/README.md b/README.md index 02b82d890..ccbc2ec36 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,11 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1458 | [Max Dot Product of Two Subsequences](https://leetcode.com/problems/max-dot-product-of-two-subsequences "两个子序列的最大点积") | [Go](problems/max-dot-product-of-two-subsequences) | Hard | +| 1457 | [Pseudo-Palindromic Paths in a Binary Tree](https://leetcode.com/problems/pseudo-palindromic-paths-in-a-binary-tree "二叉树中的伪回文路径") | [Go](problems/pseudo-palindromic-paths-in-a-binary-tree) | Medium | +| 1456 | [Maximum Number of Vowels in a Substring of Given Length](https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length "定长子串中元音的最大数目") | [Go](problems/maximum-number-of-vowels-in-a-substring-of-given-length) | Medium | +| 1455 | [Check If a Word Occurs As a Prefix of Any Word in a Sentence](https://leetcode.com/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence "检查单词是否为句中其他单词的前缀") | [Go](problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | Easy | +| 1454 | [Active Users](https://leetcode.com/problems/active-users) 🔒 | [MySQL](problems/active-users) | Medium | | 1453 | [Maximum Number of Darts Inside of a Circular Dartboard](https://leetcode.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard "圆形靶内的最大飞镖数量") | [Go](problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | Hard | | 1452 | [People Whose List of Favorite Companies Is Not a Subset of Another List](https://leetcode.com/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list "收藏清单") | [Go](problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | Medium | | 1451 | [Rearrange Words in a Sentence](https://leetcode.com/problems/rearrange-words-in-a-sentence "重新排列句子中的单词") | [Go](problems/rearrange-words-in-a-sentence) | Medium | @@ -70,7 +75,7 @@ LeetCode Problems' Solutions | 1448 | [Count Good Nodes in Binary Tree](https://leetcode.com/problems/count-good-nodes-in-binary-tree "统计二叉树中好节点的数目") | [Go](problems/count-good-nodes-in-binary-tree) | Medium | | 1447 | [Simplified Fractions](https://leetcode.com/problems/simplified-fractions "最简分数") | [Go](problems/simplified-fractions) | Medium | | 1446 | [Consecutive Characters](https://leetcode.com/problems/consecutive-characters "连续字符") | [Go](problems/consecutive-characters) | Easy | -| 1445 | [Apples & Oranges](https://leetcode.com/problems/apples-oranges) 🔒 | [MySQL](problems/apples-oranges) | Medium | +| 1445 | [Apples & Oranges](https://leetcode.com/problems/apples-oranges "苹果和桔子") 🔒 | [MySQL](problems/apples-oranges) | Medium | | 1444 | [Number of Ways of Cutting a Pizza](https://leetcode.com/problems/number-of-ways-of-cutting-a-pizza "切披萨的方案数") | [Go](problems/number-of-ways-of-cutting-a-pizza) | Hard | | 1443 | [Minimum Time to Collect All Apples in a Tree](https://leetcode.com/problems/minimum-time-to-collect-all-apples-in-a-tree "收集树上所有苹果的最少时间") | [Go](problems/minimum-time-to-collect-all-apples-in-a-tree) | Medium | | 1442 | [Count Triplets That Can Form Two Arrays of Equal XOR](https://leetcode.com/problems/count-triplets-that-can-form-two-arrays-of-equal-xor "形成两个异或相等数组的三元组数目") | [Go](problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | Medium | @@ -87,7 +92,7 @@ LeetCode Problems' Solutions | 1431 | [Kids With the Greatest Number of Candies](https://leetcode.com/problems/kids-with-the-greatest-number-of-candies "拥有最多糖果的孩子") | [Go](problems/kids-with-the-greatest-number-of-candies) | Easy | | 1430 | [Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree](https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [Go](problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) | Medium | | 1429 | [First Unique Number](https://leetcode.com/problems/first-unique-number) 🔒 | [Go](problems/first-unique-number) | Medium | -| 1428 | [Leftmost Column with at Least a One](https://leetcode.com/problems/leftmost-column-with-at-least-a-one) 🔒 | [Go](problems/leftmost-column-with-at-least-a-one) | Medium | +| 1428 | [Leftmost Column with at Least a One](https://leetcode.com/problems/leftmost-column-with-at-least-a-one "至少有一个 1 的最左端列") 🔒 | [Go](problems/leftmost-column-with-at-least-a-one) | Medium | | 1427 | [Perform String Shifts](https://leetcode.com/problems/perform-string-shifts) 🔒 | [Go](problems/perform-string-shifts) | Easy | | 1426 | [Counting Elements](https://leetcode.com/problems/counting-elements "数元素") 🔒 | [Go](problems/counting-elements) | Easy | | 1425 | [Constrained Subsequence Sum](https://leetcode.com/problems/constrained-subsequence-sum "带限制的子序列和") | [Go](problems/constrained-subsequence-sum) | Hard | diff --git a/problems/active-users/README.md b/problems/active-users/README.md new file mode 100644 index 000000000..05d3c0032 --- /dev/null +++ b/problems/active-users/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../maximum-number-of-darts-inside-of-a-circular-dartboard "Maximum Number of Darts Inside of a Circular Dartboard") +                 +[Next >](../check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence "Check If a Word Occurs As a Prefix of Any Word in a Sentence") + +## [1454. Active Users (Medium)](https://leetcode.com/problems/active-users "") + + diff --git a/problems/active-users/mysql_schemas.sql b/problems/active-users/mysql_schemas.sql new file mode 100644 index 000000000..256bf8be8 --- /dev/null +++ b/problems/active-users/mysql_schemas.sql @@ -0,0 +1,15 @@ +Create table If Not Exists Accounts (id int, name varchar(10)); +Create table If Not Exists Logins (id int, login_date date); +Truncate table Accounts; +insert into Accounts (id, name) values ('1', 'Winston'); +insert into Accounts (id, name) values ('7', 'Jonathan'); +Truncate table Logins; +insert into Logins (id, login_date) values ('7', '2020-05-30'); +insert into Logins (id, login_date) values ('1', '2020-05-30'); +insert into Logins (id, login_date) values ('7', '2020-05-31'); +insert into Logins (id, login_date) values ('7', '2020-06-01'); +insert into Logins (id, login_date) values ('7', '2020-06-02'); +insert into Logins (id, login_date) values ('7', '2020-06-02'); +insert into Logins (id, login_date) values ('7', '2020-06-03'); +insert into Logins (id, login_date) values ('1', '2020-06-07'); +insert into Logins (id, login_date) values ('7', '2020-06-10'); diff --git a/problems/apples-oranges/README.md b/problems/apples-oranges/README.md index b9963c64d..6d592e273 100644 --- a/problems/apples-oranges/README.md +++ b/problems/apples-oranges/README.md @@ -9,6 +9,6 @@                  [Next >](../consecutive-characters "Consecutive Characters") -## [1445. Apples & Oranges (Medium)](https://leetcode.com/problems/apples-oranges "") +## [1445. Apples & Oranges (Medium)](https://leetcode.com/problems/apples-oranges "苹果和桔子") diff --git a/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md b/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md new file mode 100644 index 000000000..9d216a1e5 --- /dev/null +++ b/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md @@ -0,0 +1,90 @@ + + + + + + + +[< Previous](../active-users "Active Users") +                 +[Next >](../maximum-number-of-vowels-in-a-substring-of-given-length "Maximum Number of Vowels in a Substring of Given Length") + +## [1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence (Easy)](https://leetcode.com/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence "检查单词是否为句中其他单词的前缀") + +

    Given a sentence that consists of some words separated by a single space, and a searchWord.

    + +

    You have to check if searchWord is a prefix of any word in sentence.

    + +

    Return the index of the word in sentence where searchWord is a prefix of this word (1-indexed).

    + +

    If searchWord is a prefix of more than one word, return the index of the first word (minimum index). If there is no such word return -1.

    + +

    A prefix of a string S is any leading contiguous substring of S.

    + +

     

    +

    Example 1:

    + +
    +Input: sentence = "i love eating burger", searchWord = "burg"
    +Output: 4
    +Explanation: "burg" is prefix of "burger" which is the 4th word in the sentence.
    +
    + +

    Example 2:

    + +
    +Input: sentence = "this problem is an easy problem", searchWord = "pro"
    +Output: 2
    +Explanation: "pro" is prefix of "problem" which is the 2nd and the 6th word in the sentence, but we return 2 as it's the minimal index.
    +
    + +

    Example 3:

    + +
    +Input: sentence = "i am tired", searchWord = "you"
    +Output: -1
    +Explanation: "you" is not a prefix of any word in the sentence.
    +
    + +

    Example 4:

    + +
    +Input: sentence = "i use triple pillow", searchWord = "pill"
    +Output: 4
    +
    + +

    Example 5:

    + +
    +Input: sentence = "hello from the other side", searchWord = "they"
    +Output: -1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= sentence.length <= 100
    • +
    • 1 <= searchWord.length <= 10
    • +
    • sentence consists of lowercase English letters and spaces.
    • +
    • searchWord consists of lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +First extract the words of the sentence. +
    + +
    +Hint 2 +Check for each word if searchWord occurs at index 0, if so return the index of this word (1-indexed) +
    + +
    +Hint 3 +If searchWord doesn't exist as a prefix of any word return the default value (-1). +
    diff --git a/problems/count-different-palindromic-subsequences/README.md b/problems/count-different-palindromic-subsequences/README.md index b8d590c65..4ca9e550b 100644 --- a/problems/count-different-palindromic-subsequences/README.md +++ b/problems/count-different-palindromic-subsequences/README.md @@ -9,7 +9,7 @@                  [Next >](../my-calendar-ii "My Calendar II") -## [730. Count Different Palindromic Subsequences (Hard)](https://leetcode.com/problems/count-different-palindromic-subsequences "统计不同回文子字符串") +## [730. Count Different Palindromic Subsequences (Hard)](https://leetcode.com/problems/count-different-palindromic-subsequences "统计不同回文子序列")

    Given a string S, find the number of different non-empty palindromic subsequences in S, and return that number modulo 10^9 + 7. diff --git a/problems/find-peak-element/README.md b/problems/find-peak-element/README.md index 92bf14323..0e6e3069d 100644 --- a/problems/find-peak-element/README.md +++ b/problems/find-peak-element/README.md @@ -35,9 +35,7 @@   or index number 5 where the peak element is 6.

    -

    Note:

    - -

    Your solution should be in logarithmic complexity.

    +

    Follow up: Your solution should be in logarithmic complexity.

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/find-pivot-index/README.md b/problems/find-pivot-index/README.md index 7e653f866..03aa0c5b9 100644 --- a/problems/find-pivot-index/README.md +++ b/problems/find-pivot-index/README.md @@ -13,44 +13,38 @@

    Given an array of integers nums, write a method that returns the "pivot" index of this array.

    -

    We define the pivot index as the index where the sum of the numbers to the left of the index is equal to the sum of the numbers to the right of the index.

    +

    We define the pivot index as the index where the sum of all the numbers to the left of the index is equal to the sum of all the numbers to the right of the index.

    If no such index exists, we should return -1. If there are multiple pivot indexes, you should return the left-most pivot index.

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input: 
    -nums = [1, 7, 3, 6, 5, 6]
    -Output: 3
    -Explanation: 
    +Input: nums = [1,7,3,6,5,6]
    +Output: 3
    +Explanation:
     The sum of the numbers to the left of index 3 (nums[3] = 6) is equal to the sum of numbers to the right of index 3.
     Also, 3 is the first index where this occurs.
     
    -

     

    - -

    Example 2:

    +

    Example 2:

    -Input: 
    -nums = [1, 2, 3]
    -Output: -1
    -Explanation: 
    +Input: nums = [1,2,3]
    +Output: -1
    +Explanation:
     There is no index that satisfies the conditions in the problem statement.
     

     

    - -

    Note:

    +

    Constraints:

    • The length of nums will be in the range [0, 10000].
    • Each element nums[i] will be an integer in the range [-1000, 1000].
    -

     

    - ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md b/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md index 448b78012..957fe3cef 100644 --- a/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md +++ b/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md @@ -29,7 +29,7 @@
     Input: cost = [4,3,2,5,6,7,2,5,5], target = 9
     Output: "7772"
    -Explanation:  The cost to paint the digit '7' is 2, and the digit '2' is 3. Then cost("7772") = 2*3+ 3*1 = 9. You could also paint "997", but "7772" is the largest number.
    +Explanation:  The cost to paint the digit '7' is 2, and the digit '2' is 3. Then cost("7772") = 2*3+ 3*1 = 9. You could also paint "977", but "7772" is the largest number.
     Digit    cost
       1  ->   4
       2  ->   3
    diff --git a/problems/kth-smallest-element-in-a-bst/README.md b/problems/kth-smallest-element-in-a-bst/README.md
    index a071458bd..ccb774a3b 100644
    --- a/problems/kth-smallest-element-in-a-bst/README.md
    +++ b/problems/kth-smallest-element-in-a-bst/README.md
    @@ -13,8 +13,7 @@
     
     

    Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.

    -

    Note:
    -You may assume k is always valid, 1 ≤ k ≤ BST's total elements.

    +

     

    Example 1:

    @@ -44,6 +43,14 @@ You may assume k is always valid, 1 ≤ k ≤ BST's total elements.

    Follow up:
    What if the BST is modified (insert/delete operations) often and you need to find the kth smallest frequently? How would you optimize the kthSmallest routine?

    +

     

    +

    Constraints:

    + +
      +
    • The number of elements of the BST is between 1 to 10^4.
    • +
    • You may assume k is always valid, 1 ≤ k ≤ BST's total elements.
    • +
    + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/leftmost-column-with-at-least-a-one/README.md b/problems/leftmost-column-with-at-least-a-one/README.md index bcf077e40..75c48d336 100644 --- a/problems/leftmost-column-with-at-least-a-one/README.md +++ b/problems/leftmost-column-with-at-least-a-one/README.md @@ -9,7 +9,7 @@                  [Next >](../first-unique-number "First Unique Number") -## [1428. Leftmost Column with at Least a One (Medium)](https://leetcode.com/problems/leftmost-column-with-at-least-a-one "") +## [1428. Leftmost Column with at Least a One (Medium)](https://leetcode.com/problems/leftmost-column-with-at-least-a-one "至少有一个 1 的最左端列") diff --git a/problems/max-dot-product-of-two-subsequences/README.md b/problems/max-dot-product-of-two-subsequences/README.md new file mode 100644 index 000000000..ee6d8c975 --- /dev/null +++ b/problems/max-dot-product-of-two-subsequences/README.md @@ -0,0 +1,60 @@ + + + + + + + +[< Previous](../pseudo-palindromic-paths-in-a-binary-tree "Pseudo-Palindromic Paths in a Binary Tree") +                 +Next > + +## [1458. Max Dot Product of Two Subsequences (Hard)](https://leetcode.com/problems/max-dot-product-of-two-subsequences "两个子序列的最大点积") + +

    Given two arrays nums1 and nums2.

    + +

    Return the maximum dot product between non-empty subsequences of nums1 and nums2 with the same length.

    + +

    A subsequence of a array is a new array which is formed from the original array by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, [2,3,5] is a subsequence of [1,2,3,4,5] while [1,5,3] is not).

    + +

     

    +

    Example 1:

    + +
    +Input: nums1 = [2,1,-2,5], nums2 = [3,0,-6]
    +Output: 18
    +Explanation: Take subsequence [2,-2] from nums1 and subsequence [3,-6] from nums2.
    +Their dot product is (2*3 + (-2)*(-6)) = 18.
    + +

    Example 2:

    + +
    +Input: nums1 = [3,-2], nums2 = [2,-6,7]
    +Output: 21
    +Explanation: Take subsequence [3] from nums1 and subsequence [7] from nums2.
    +Their dot product is (3*7) = 21.
    + +

    Example 3:

    + +
    +Input: nums1 = [-1,-1], nums2 = [1,1]
    +Output: -1
    +Explanation: Take subsequence [-1] from nums1 and subsequence [1] from nums2.
    +Their dot product is -1.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums1.length, nums2.length <= 500
    • +
    • -1000 <= nums1[i], nums2[i] <= 1000
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Use dynamic programming, define DP[i][j] as the maximum dot product of two subsequences starting in the position i of nums1 and position j of nums2. +
    diff --git a/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md b/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md index a6bd74524..972f9f534 100644 --- a/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md +++ b/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md @@ -7,7 +7,7 @@ [< Previous](../people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list "People Whose List of Favorite Companies Is Not a Subset of Another List")                  -Next > +[Next >](../active-users "Active Users") ## [1453. Maximum Number of Darts Inside of a Circular Dartboard (Hard)](https://leetcode.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard "圆形靶内的最大飞镖数量") diff --git a/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md b/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md new file mode 100644 index 000000000..ff2dbd569 --- /dev/null +++ b/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence "Check If a Word Occurs As a Prefix of Any Word in a Sentence") +                 +[Next >](../pseudo-palindromic-paths-in-a-binary-tree "Pseudo-Palindromic Paths in a Binary Tree") + +## [1456. Maximum Number of Vowels in a Substring of Given Length (Medium)](https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length "定长子串中元音的最大数目") + +

    Given a string s and an integer k.

    + +

    Return the maximum number of vowel letters in any substring of s with length k.

    + +

    Vowel letters in English are (a, e, i, o, u).

    + +

     

    +

    Example 1:

    + +
    +Input: s = "abciiidef", k = 3
    +Output: 3
    +Explanation: The substring "iii" contains 3 vowel letters.
    +
    + +

    Example 2:

    + +
    +Input: s = "aeiou", k = 2
    +Output: 2
    +Explanation: Any substring of length 2 contains 2 vowels.
    +
    + +

    Example 3:

    + +
    +Input: s = "leetcode", k = 3
    +Output: 2
    +Explanation: "lee", "eet" and "ode" contain 2 vowels.
    +
    + +

    Example 4:

    + +
    +Input: s = "rhythms", k = 4
    +Output: 0
    +Explanation: We can see that s doesn't have any vowel letters.
    +
    + +

    Example 5:

    + +
    +Input: s = "tryhard", k = 4
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 10^5
    • +
    • s consists of lowercase English letters.
    • +
    • 1 <= k <= s.length
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
    +Hint 1 +Keep a window of size k and maintain the number of vowels in it. +
    + +
    +Hint 2 +Keep moving the window and update the number of vowels while moving. Answer is max number of vowels of any window. +
    diff --git a/problems/mini-parser/README.md b/problems/mini-parser/README.md index 8f3720ae7..711e765b7 100644 --- a/problems/mini-parser/README.md +++ b/problems/mini-parser/README.md @@ -15,26 +15,30 @@

    Each element is either an integer, or a list -- whose elements may also be integers or other lists.

    -

    Note: -You may assume that the string is well-formed: +

    Note: You may assume that the string is well-formed:

    +
      -
    • String is non-empty.
    • -
    • String does not contain white spaces.
    • -
    • String contains only digits 0-9, [, - ,, ].
    • +
    • String is non-empty.
    • +
    • String does not contain white spaces.
    • +
    • String contains only digits 0-9, [, - ,, ].
    -

    -

    Example 1: +

     

    + +

    Example 1:

    +
    -Given s = "324",
    +Given s = "324",
     
     You should return a NestedInteger object which contains a single integer 324.
     
    -

    -

    Example 2: +

     

    + +

    Example 2:

    +
    -Given s = "[123,[456,[789]]]",
    +Given s = "[123,[456,[789]]]",
     
     Return a NestedInteger object containing a nested list with 2 elements:
     
    @@ -44,7 +48,8 @@ Return a NestedInteger object containing a nested list with 2 elements:
         ii. A nested list with one element:
              a. An integer containing value 789.
     
    -

    + +

     

    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/odd-even-linked-list/README.md b/problems/odd-even-linked-list/README.md index 45f2449b2..4abbe37ec 100644 --- a/problems/odd-even-linked-list/README.md +++ b/problems/odd-even-linked-list/README.md @@ -29,11 +29,13 @@ Output: 2->3->6->7->1->5->4->NULL
    -

    Note:

    +

     

    +

    Constraints:

    • The relative order inside both the even and odd groups should remain as it was in the input.
    • The first node is considered odd, the second node even and so on ...
    • +
    • The length of the linked list is between [0, 10^4].
    ### Related Topics diff --git a/problems/permutation-in-string/README.md b/problems/permutation-in-string/README.md index 3c3b8fb52..59878437b 100644 --- a/problems/permutation-in-string/README.md +++ b/problems/permutation-in-string/README.md @@ -31,13 +31,12 @@

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • The input strings only contain lower case letters.
      • The length of both given strings is in range [1, 10,000].
      • -
    + ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md b/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md new file mode 100644 index 000000000..b673de543 --- /dev/null +++ b/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md @@ -0,0 +1,68 @@ + + + + + + + +[< Previous](../maximum-number-of-vowels-in-a-substring-of-given-length "Maximum Number of Vowels in a Substring of Given Length") +                 +[Next >](../max-dot-product-of-two-subsequences "Max Dot Product of Two Subsequences") + +## [1457. Pseudo-Palindromic Paths in a Binary Tree (Medium)](https://leetcode.com/problems/pseudo-palindromic-paths-in-a-binary-tree "二叉树中的伪回文路径") + +

    Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be pseudo-palindromic if at least one permutation of the node values in the path is a palindrome.

    + +

    Return the number of pseudo-palindromic paths going from the root node to leaf nodes.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: root = [2,3,1,3,1,null,1]
    +Output: 2 
    +Explanation: The figure above represents the given binary tree. There are three paths going from the root node to leaf nodes: the red path [2,3,3], the green path [2,1,1], and the path [2,3,1]. Among these paths only red path and green path are pseudo-palindromic paths since the red path [2,3,3] can be rearranged in [3,2,3] (palindrome) and the green path [2,1,1] can be rearranged in [1,2,1] (palindrome).
    +
    + +

    Example 2:

    + +

    + +
    +Input: root = [2,1,1,1,3,null,null,null,null,null,1]
    +Output: 1 
    +Explanation: The figure above represents the given binary tree. There are three paths going from the root node to leaf nodes: the green path [2,1,1], the path [2,1,3,1], and the path [2,1]. Among these paths only the green path is pseudo-palindromic since [2,1,1] can be rearranged in [1,2,1] (palindrome).
    +
    + +

    Example 3:

    + +
    +Input: root = [9]
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The given binary tree will have between 1 and 10^5 nodes.
    • +
    • Node values are digits from 1 to 9.
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + +### Hints +
    +Hint 1 +Note that the node values of a path form a palindrome if at most one digit has an odd frequency (parity). +
    + +
    +Hint 2 +Use a Depth First Search (DFS) keeping the frequency (parity) of the digits. Once you are in a leaf node check if at most one digit has an odd frequency (parity). +
    diff --git a/readme/601-900.md b/readme/601-900.md index fbce6aef4..8e761e7fb 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -191,7 +191,7 @@ LeetCode Problems' Solutions | 727 | [Minimum Window Subsequence](https://leetcode.com/problems/minimum-window-subsequence "最小窗口子序列") 🔒 | [Go](../problems/minimum-window-subsequence) | Hard | | 728 | [Self Dividing Numbers](https://leetcode.com/problems/self-dividing-numbers "自除数") | [Go](../problems/self-dividing-numbers) | Easy | | 729 | [My Calendar I](https://leetcode.com/problems/my-calendar-i "我的日程安排表 I") | [Go](../problems/my-calendar-i) | Medium | -| 730 | [Count Different Palindromic Subsequences](https://leetcode.com/problems/count-different-palindromic-subsequences "统计不同回文子字符串") | [Go](../problems/count-different-palindromic-subsequences) | Hard | +| 730 | [Count Different Palindromic Subsequences](https://leetcode.com/problems/count-different-palindromic-subsequences "统计不同回文子序列") | [Go](../problems/count-different-palindromic-subsequences) | Hard | | 731 | [My Calendar II](https://leetcode.com/problems/my-calendar-ii "我的日程安排表 II") | [Go](../problems/my-calendar-ii) | Medium | | 732 | [My Calendar III](https://leetcode.com/problems/my-calendar-iii "我的日程安排表 III") | [Go](../problems/my-calendar-iii) | Hard | | 733 | [Flood Fill](https://leetcode.com/problems/flood-fill "图像渲染") | [Go](../problems/flood-fill) | Easy | diff --git a/tag/array/README.md b/tag/array/README.md index b311be9fb..ed9e02fc0 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -14,7 +14,7 @@ | 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1437 | [是否所有 1 都至少相隔 k 个元素](../../problems/check-if-all-1s-are-at-least-length-k-places-away) | [[数组](../array/README.md)] | Medium | | 1431 | [拥有最多糖果的孩子](../../problems/kids-with-the-greatest-number-of-candies) | [[数组](../array/README.md)] | Easy | -| 1428 | [Leftmost Column with at Least a One](../../problems/leftmost-column-with-at-least-a-one) 🔒 | [[数组](../array/README.md)] | Medium | +| 1428 | [至少有一个 1 的最左端列](../../problems/leftmost-column-with-at-least-a-one) 🔒 | [[数组](../array/README.md)] | Medium | | 1427 | [Perform String Shifts](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1426 | [数元素](../../problems/counting-elements) 🔒 | [[数组](../array/README.md)] | Easy | | 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 31bd7b3f2..108b7ff40 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1404 | [将二进制表示减到 1 的步骤数](../../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index e025264a9..936794801 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index db2bd32a3..7f5c30011 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1458 | [两个子序列的最大点积](../../problems/max-dot-product-of-two-subsequences) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1444 | [切披萨的方案数](../../problems/number-of-ways-of-cutting-a-pizza) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -115,7 +116,7 @@ | 746 | [使用最小花费爬楼梯](../../problems/min-cost-climbing-stairs) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 741 | [摘樱桃](../../problems/cherry-pickup) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 740 | [删除与获得点数](../../problems/delete-and-earn) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 730 | [统计不同回文子字符串](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index 5ad662cb4..a602f91fc 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index 04c8d34cd..23117a1b0 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1455 | [检查单词是否为句中其他单词的前缀](../../problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | [[字符串](../string/README.md)] | Easy | | 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | | 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | | 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -95,7 +97,7 @@ | 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | | 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字符串](../string/README.md)] | Easy | | 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[字符串](../string/README.md)] | Hard | -| 730 | [统计不同回文子字符串](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 722 | [删除注释](../../problems/remove-comments) | [[字符串](../string/README.md)] | Medium | | 709 | [转换成小写字母](../../problems/to-lower-case) | [[字符串](../string/README.md)] | Easy | | 696 | [计数二进制子串](../../problems/count-binary-substrings) | [[字符串](../string/README.md)] | Easy | diff --git a/tag/tree/README.md b/tag/tree/README.md index ee49bf21c..99f713b4e 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1430 | [Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree](../../problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | From 0e370425bd9d918a845a1ccec4aa936f9f440b65 Mon Sep 17 00:00:00 2001 From: Shuo Date: Sat, 30 May 2020 19:15:12 +0800 Subject: [PATCH 065/145] A: v1.6.1 --- internal/base/base.go | 8 ++------ internal/leetcode/topic_tag.go | 7 ++++--- internal/version/version.go | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/internal/base/base.go b/internal/base/base.go index 79657f50e..37cd115b0 100644 --- a/internal/base/base.go +++ b/internal/base/base.go @@ -10,7 +10,6 @@ import ( "os" "path/filepath" "strings" - "sync" ) // CmdName - base.CmdName @@ -19,11 +18,8 @@ const ( URL = "https://github.com/openset/leetcode/tree/master" ) -// base var -var ( - Commands []*Command - Mutex sync.Mutex -) +// Commands - base.Commands +var Commands []*Command // Command - base.Command type Command struct { diff --git a/internal/leetcode/topic_tag.go b/internal/leetcode/topic_tag.go index c6e9d4cc9..cf127e472 100644 --- a/internal/leetcode/topic_tag.go +++ b/internal/leetcode/topic_tag.go @@ -9,12 +9,13 @@ import ( "regexp" "sort" "strconv" + "sync" - "github.com/openset/leetcode/internal/base" "github.com/openset/leetcode/internal/client" ) var ( + mu sync.Mutex initTags []TagType tagsFile = filepath.Join("tag", "tags.json") ) @@ -135,10 +136,10 @@ func GetTopicTag(slug string) (tt TopicTagType) { } func saveTags(tags []TagType) { - base.Mutex.Lock() + mu.Lock() + defer mu.Unlock() tags = append(GetTags(), tags...) filePutContents(tagsFile, jsonEncode(tagsUnique(tags))) - base.Mutex.Unlock() } func tagsUnique(tags []TagType) []TagType { diff --git a/internal/version/version.go b/internal/version/version.go index 6886a1b9d..79daf648c 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -8,7 +8,7 @@ import ( "github.com/openset/leetcode/internal/base" ) -const version = "1.6.0" +const version = "1.6.1" // CmdVersion - version.CmdVersion var CmdVersion = &base.Command{ From c9460fbcca7320dbbb1f0adca04e704bbe8dbf16 Mon Sep 17 00:00:00 2001 From: Shuo Date: Sat, 30 May 2020 19:57:47 +0800 Subject: [PATCH 066/145] A: v1.6.2 --- internal/base/base.go | 41 ++++----------------------------------- internal/base/cmd.go | 45 +++++++++++++++++++++++++++++++++++++++++++ internal/base/run.go | 25 ++++++++++++++++++++++++ main.go | 29 ++++------------------------ 4 files changed, 78 insertions(+), 62 deletions(-) create mode 100644 internal/base/cmd.go create mode 100644 internal/base/run.go diff --git a/internal/base/base.go b/internal/base/base.go index 37cd115b0..43bec5f6a 100644 --- a/internal/base/base.go +++ b/internal/base/base.go @@ -12,44 +12,11 @@ import ( "strings" ) -// CmdName - base.CmdName -const ( - CmdName = "leetcode" - URL = "https://github.com/openset/leetcode/tree/master" -) +// URL - base.URL +const URL = "https://github.com/openset/leetcode/tree/master" -// Commands - base.Commands -var Commands []*Command - -// Command - base.Command -type Command struct { - Run func(cmd *Command, args []string) - UsageLine string - Short string - Long string - Hidden bool -} - -// Name - base.Name -func (c *Command) Name() string { - name := c.UsageLine - if i := strings.Index(name, " "); i > 0 { - name = name[0:i] - } - return name -} - -// Usage - base.Usage -func (c *Command) Usage() { - fmt.Printf("usage: %s %s\n\n", CmdName, c.UsageLine) - fmt.Printf("Run '%s help %s' for details.\n", CmdName, c.Name()) -} - -// UsageHelp - base.UsageHelp -func (c *Command) UsageHelp() { - fmt.Printf("usage: %s %s\n\n", CmdName, c.UsageLine) - fmt.Println(c.Long) -} +// CmdName - base.CmdName +var CmdName = filepath.Base(os.Args[0]) // Usage - base.Usage func Usage() { diff --git a/internal/base/cmd.go b/internal/base/cmd.go new file mode 100644 index 000000000..5678bb9ff --- /dev/null +++ b/internal/base/cmd.go @@ -0,0 +1,45 @@ +// Package base provides base support. +package base + +import ( + "fmt" + "strings" +) + +// Commands - base.Commands +var Commands []*Command + +// Command - base.Command +type Command struct { + Run func(cmd *Command, args []string) + UsageLine string + Short string + Long string + Hidden bool +} + +// Name - base.Command.Name +func (c *Command) Name() string { + name := c.UsageLine + if i := strings.Index(name, " "); i > 0 { + name = name[0:i] + } + return name +} + +// Usage - base.Command.Usage +func (c *Command) Usage() { + fmt.Printf("usage: %s %s\n\n", CmdName, c.UsageLine) + fmt.Printf("Run '%s help %s' for details.\n", CmdName, c.Name()) +} + +// UsageHelp - base.Command.UsageHelp +func (c *Command) UsageHelp() { + fmt.Printf("usage: %s %s\n\n", CmdName, c.UsageLine) + fmt.Println(c.Long) +} + +// Register - base.Register +func Register(cmds ...*Command) { + Commands = append(Commands, cmds...) +} diff --git a/internal/base/run.go b/internal/base/run.go new file mode 100644 index 000000000..f53173354 --- /dev/null +++ b/internal/base/run.go @@ -0,0 +1,25 @@ +package base + +import ( + "flag" + "fmt" +) + +func Run() { + flag.Usage = Usage + flag.Parse() + if flag.NArg() < 1 { + flag.Usage() + return + } + args := flag.Args() + cmdName := flag.Arg(0) + for _, cmd := range Commands { + if cmd.Name() == cmdName { + cmd.Run(cmd, args[1:]) + return + } + } + fmt.Printf("%s %s: unknown command\n\n", CmdName, cmdName) + fmt.Printf("Run '%s help' for usage.\n", CmdName) +} diff --git a/main.go b/main.go index 2724d739f..1b7032cec 100644 --- a/main.go +++ b/main.go @@ -2,9 +2,6 @@ package main import ( - "flag" - "fmt" - "github.com/openset/leetcode/internal/base" "github.com/openset/leetcode/internal/build" "github.com/openset/leetcode/internal/clean" @@ -22,8 +19,8 @@ import ( "github.com/openset/leetcode/internal/version" ) -func init() { - base.Commands = []*base.Command{ +func main() { + base.Register( readme.CmdReadme, page.CmdPage, tag.CmdTag, @@ -38,24 +35,6 @@ func init() { version.CmdVersion, help.CmdHelp, post.CmdPost, - } -} - -func main() { - flag.Usage = base.Usage - flag.Parse() - if flag.NArg() < 1 { - flag.Usage() - return - } - args := flag.Args() - cmdName := flag.Arg(0) - for _, cmd := range base.Commands { - if cmd.Name() == cmdName { - cmd.Run(cmd, args[1:]) - return - } - } - fmt.Printf("%s %s: unknown command\n\n", base.CmdName, cmdName) - fmt.Printf("Run '%s help' for usage.\n", base.CmdName) + ) + base.Run() } From 40ca651a71d224f010b2a08d7c5e7044bbc1e81d Mon Sep 17 00:00:00 2001 From: Shuo Date: Sat, 30 May 2020 20:18:58 +0800 Subject: [PATCH 067/145] A: v1.6.3 --- internal/base/cmd.go | 1 - internal/base/run.go | 1 + internal/version/version.go | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/base/cmd.go b/internal/base/cmd.go index 5678bb9ff..fb8dcdc37 100644 --- a/internal/base/cmd.go +++ b/internal/base/cmd.go @@ -1,4 +1,3 @@ -// Package base provides base support. package base import ( diff --git a/internal/base/run.go b/internal/base/run.go index f53173354..f62a66982 100644 --- a/internal/base/run.go +++ b/internal/base/run.go @@ -5,6 +5,7 @@ import ( "fmt" ) +// Run - base.Run func Run() { flag.Usage = Usage flag.Parse() diff --git a/internal/version/version.go b/internal/version/version.go index 79daf648c..52e8aa506 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -8,7 +8,7 @@ import ( "github.com/openset/leetcode/internal/base" ) -const version = "1.6.1" +const version = "1.6.3" // CmdVersion - version.CmdVersion var CmdVersion = &base.Command{ From aad78465f3c789e998f3afe1a065f57708d56aff Mon Sep 17 00:00:00 2001 From: Shuo Date: Sun, 31 May 2020 18:45:38 +0800 Subject: [PATCH 068/145] A: new --- README.md | 11 +- problems/3sum-closest/README.md | 18 ++- .../README.md | 79 +++++++++++++ problems/cherry-pickup-ii/README.md | 86 ++++++++++++++ problems/cinema-seat-allocation/README.md | 6 +- problems/course-schedule-iv/README.md | 95 ++++++++++++++++ .../README.md | 1 + .../evaluate-boolean-expression/README.md | 2 +- problems/hand-of-straights/README.md | 11 +- .../interval-list-intersections/README.md | 3 - .../README.md | 85 ++++++++++++++ .../README.md | 2 +- .../README.md | 71 ++++++++++++ .../README.md | 54 +++++++++ problems/merge-two-sorted-lists/README.md | 10 +- problems/possible-bipartition/README.md | 14 +-- .../README.md | 105 ++++++++++++++++++ problems/pyramid-transition-matrix/README.md | 9 +- problems/rectangles-area/README.md | 14 +++ problems/rectangles-area/mysql_schemas.sql | 5 + .../README.md | 69 ++++++++++++ .../unique-binary-search-trees-ii/README.md | 9 +- problems/video-stitching/README.md | 9 +- 23 files changed, 726 insertions(+), 42 deletions(-) create mode 100644 problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md create mode 100644 problems/cherry-pickup-ii/README.md create mode 100644 problems/course-schedule-iv/README.md create mode 100644 problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md create mode 100644 problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md create mode 100644 problems/maximum-product-of-two-elements-in-an-array/README.md create mode 100644 problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md create mode 100644 problems/rectangles-area/README.md create mode 100644 problems/rectangles-area/mysql_schemas.sql create mode 100644 problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md diff --git a/README.md b/README.md index ccbc2ec36..c2fb3cf65 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,15 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1467 | [Probability of a Two Boxes Having The Same Number of Distinct Balls](https://leetcode.com/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "两个盒子中不同颜色的球数量相同的概率") | [Go](problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | Hard | +| 1466 | [Reorder Routes to Make All Paths Lead to the City Zero](https://leetcode.com/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero "重新规划路线") | [Go](problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | Medium | +| 1465 | [Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts](https://leetcode.com/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts "切割后面积最大的蛋糕") | [Go](problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts) | Medium | +| 1464 | [Maximum Product of Two Elements in an Array](https://leetcode.com/problems/maximum-product-of-two-elements-in-an-array "数组中两元素的最大乘积") | [Go](problems/maximum-product-of-two-elements-in-an-array) | Easy | +| 1463 | [Cherry Pickup II](https://leetcode.com/problems/cherry-pickup-ii "摘樱桃 II") | [Go](problems/cherry-pickup-ii) | Hard | +| 1462 | [Course Schedule IV](https://leetcode.com/problems/course-schedule-iv "课程安排 IV") | [Go](problems/course-schedule-iv) | Medium | +| 1461 | [Check If a String Contains All Binary Codes of Size K](https://leetcode.com/problems/check-if-a-string-contains-all-binary-codes-of-size-k "检查一个字符串是否包含所有大小为 K 的二进制子串") | [Go](problems/check-if-a-string-contains-all-binary-codes-of-size-k) | Medium | +| 1460 | [Make Two Arrays Equal by Reversing Sub-arrays](https://leetcode.com/problems/make-two-arrays-equal-by-reversing-sub-arrays "通过翻转子数组使两个数组相等") | [Go](problems/make-two-arrays-equal-by-reversing-sub-arrays) | Easy | +| 1459 | [Rectangles Area](https://leetcode.com/problems/rectangles-area) 🔒 | [MySQL](problems/rectangles-area) | Medium | | 1458 | [Max Dot Product of Two Subsequences](https://leetcode.com/problems/max-dot-product-of-two-subsequences "两个子序列的最大点积") | [Go](problems/max-dot-product-of-two-subsequences) | Hard | | 1457 | [Pseudo-Palindromic Paths in a Binary Tree](https://leetcode.com/problems/pseudo-palindromic-paths-in-a-binary-tree "二叉树中的伪回文路径") | [Go](problems/pseudo-palindromic-paths-in-a-binary-tree) | Medium | | 1456 | [Maximum Number of Vowels in a Substring of Given Length](https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length "定长子串中元音的最大数目") | [Go](problems/maximum-number-of-vowels-in-a-substring-of-given-length) | Medium | @@ -80,7 +89,7 @@ LeetCode Problems' Solutions | 1443 | [Minimum Time to Collect All Apples in a Tree](https://leetcode.com/problems/minimum-time-to-collect-all-apples-in-a-tree "收集树上所有苹果的最少时间") | [Go](problems/minimum-time-to-collect-all-apples-in-a-tree) | Medium | | 1442 | [Count Triplets That Can Form Two Arrays of Equal XOR](https://leetcode.com/problems/count-triplets-that-can-form-two-arrays-of-equal-xor "形成两个异或相等数组的三元组数目") | [Go](problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | Medium | | 1441 | [Build an Array With Stack Operations](https://leetcode.com/problems/build-an-array-with-stack-operations "用栈操作构建数组") | [Go](problems/build-an-array-with-stack-operations) | Easy | -| 1440 | [Evaluate Boolean Expression](https://leetcode.com/problems/evaluate-boolean-expression) 🔒 | [MySQL](problems/evaluate-boolean-expression) | Medium | +| 1440 | [Evaluate Boolean Expression](https://leetcode.com/problems/evaluate-boolean-expression "计算布尔表达式的值") 🔒 | [MySQL](problems/evaluate-boolean-expression) | Medium | | 1439 | [Find the Kth Smallest Sum of a Matrix With Sorted Rows](https://leetcode.com/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows "有序矩阵中的第 k 个最小数组和") | [Go](problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | Hard | | 1438 | [Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit](https://leetcode.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "绝对差不超过限制的最长连续子数组") | [Go](problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | Medium | | 1437 | [Check If All 1's Are at Least Length K Places Away](https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away "是否所有 1 都至少相隔 k 个元素") | [Go](problems/check-if-all-1s-are-at-least-length-k-places-away) | Medium | diff --git a/problems/3sum-closest/README.md b/problems/3sum-closest/README.md index e5a964119..d73441b68 100644 --- a/problems/3sum-closest/README.md +++ b/problems/3sum-closest/README.md @@ -13,14 +13,24 @@

    Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution.

    -

    Example:

    +

     

    +

    Example 1:

    -Given array nums = [-1, 2, 1, -4], and target = 1.
    -
    -The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).
    +Input: nums = [-1,2,1,-4], target = 1
    +Output: 2
    +Explanation: The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).
     
    +

     

    +

    Constraints:

    + +
      +
    • 3 <= nums.length <= 10^3
    • +
    • -10^3 <= nums[i] <= 10^3
    • +
    • -10^4 <= target <= 10^4
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md b/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md new file mode 100644 index 000000000..d50ff2544 --- /dev/null +++ b/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../make-two-arrays-equal-by-reversing-sub-arrays "Make Two Arrays Equal by Reversing Sub-arrays") +                 +[Next >](../course-schedule-iv "Course Schedule IV") + +## [1461. Check If a String Contains All Binary Codes of Size K (Medium)](https://leetcode.com/problems/check-if-a-string-contains-all-binary-codes-of-size-k "检查一个字符串是否包含所有长度为 K 的二进制子串") + +

    Given a binary string s and an integer k.

    + +

    Return True if all binary codes of length k is a substring of s. Otherwise, return False.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "00110110", k = 2
    +Output: true
    +Explanation: The binary codes of length 2 are "00", "01", "10" and "11". They can be all found as substrings at indicies 0, 1, 3 and 2 respectively.
    +
    + +

    Example 2:

    + +
    +Input: s = "00110", k = 2
    +Output: true
    +
    + +

    Example 3:

    + +
    +Input: s = "0110", k = 1
    +Output: true
    +Explanation: The binary codes of length 1 are "0" and "1", it is clear that both exist as a substring. 
    +
    + +

    Example 4:

    + +
    +Input: s = "0110", k = 2
    +Output: false
    +Explanation: The binary code "00" is of length 2 and doesn't exist in the array.
    +
    + +

    Example 5:

    + +
    +Input: s = "0000000001011100", k = 4
    +Output: false
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 5 * 10^5
    • +
    • s consists of 0's and 1's only.
    • +
    • 1 <= k <= 20
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +We need only to check all sub-strings of length k. +
    + +
    +Hint 2 +The number of distinct sub-strings should be exactly 2^k. +
    diff --git a/problems/cherry-pickup-ii/README.md b/problems/cherry-pickup-ii/README.md new file mode 100644 index 000000000..d3eb098d8 --- /dev/null +++ b/problems/cherry-pickup-ii/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../course-schedule-iv "Course Schedule IV") +                 +[Next >](../maximum-product-of-two-elements-in-an-array "Maximum Product of Two Elements in an Array") + +## [1463. Cherry Pickup II (Hard)](https://leetcode.com/problems/cherry-pickup-ii "摘樱桃 II") + +

    Given a rows x cols matrix grid representing a field of cherries. Each cell in grid represents the number of cherries that you can collect.

    + +

    You have two robots that can collect cherries for you, Robot #1 is located at the top-left corner (0,0) , and Robot #2 is located at the top-right corner (0, cols-1) of the grid.

    + +

    Return the maximum number of cherries collection using both robots  by following the rules below:

    + +
      +
    • From a cell (i,j), robots can move to cell (i+1, j-1) , (i+1, j) or (i+1, j+1).
    • +
    • When any robot is passing through a cell, It picks it up all cherries, and the cell becomes an empty cell (0).
    • +
    • When both robots stay on the same cell, only one of them takes the cherries.
    • +
    • Both robots cannot move outside of the grid at any moment.
    • +
    • Both robots should reach the bottom row in the grid.
    • +
    + +

     

    +

    Example 1:

    + +

    + +
    +Input: grid = [[3,1,1],[2,5,1],[1,5,5],[2,1,1]]
    +Output: 24
    +Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
    +Cherries taken by Robot #1, (3 + 2 + 5 + 2) = 12.
    +Cherries taken by Robot #2, (1 + 5 + 5 + 1) = 12.
    +Total of cherries: 12 + 12 = 24.
    +
    + +

    Example 2:

    + +

    + +
    +Input: grid = [[1,0,0,0,0,0,1],[2,0,0,0,0,3,0],[2,0,9,0,0,0,0],[0,3,0,5,4,0,0],[1,0,2,3,0,0,6]]
    +Output: 28
    +Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
    +Cherries taken by Robot #1, (1 + 9 + 5 + 2) = 17.
    +Cherries taken by Robot #2, (1 + 3 + 4 + 3) = 11.
    +Total of cherries: 17 + 11 = 28.
    +
    + +

    Example 3:

    + +
    +Input: grid = [[1,0,0,3],[0,0,0,3],[0,0,3,3],[9,0,3,3]]
    +Output: 22
    +
    + +

    Example 4:

    + +
    +Input: grid = [[1,1],[1,1]]
    +Output: 4
    +
    + +

     

    +

    Constraints:

    + +
      +
    • rows == grid.length
    • +
    • cols == grid[i].length
    • +
    • 2 <= rows, cols <= 70
    • +
    • 0 <= grid[i][j] <= 100 
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Use dynammic programming, define DP[i][j][k]: The maximum cherries that both robots can take starting on the ith row, and column j and k of Robot 1 and 2 respectively. +
    diff --git a/problems/cinema-seat-allocation/README.md b/problems/cinema-seat-allocation/README.md index 1825bddea..b3cfc5d7a 100644 --- a/problems/cinema-seat-allocation/README.md +++ b/problems/cinema-seat-allocation/README.md @@ -15,9 +15,9 @@

    A cinema has n rows of seats, numbered from 1 to n and there are ten seats in each row, labelled from 1 to 10 as shown in the figure above.

    -

    Given the array reservedSeats containing the numbers of seats already reserved, for example, reservedSeats[i]=[3,8] means the seat located in row 3 and labelled with 8 is already reserved. 

    +

    Given the array reservedSeats containing the numbers of seats already reserved, for example, reservedSeats[i] = [3,8] means the seat located in row 3 and labelled with 8 is already reserved.

    -

    Return the maximum number of four-person families you can allocate on the cinema seats. A four-person family occupies fours seats in one row, that are next to each other. Seats across an aisle (such as [3,3] and [3,4]) are not considered to be next to each other, however, It is permissible for the four-person family to be separated by an aisle, but in that case, exactly two people have to sit on each side of the aisle.

    +

    Return the maximum number of four-person groups you can assign on the cinema seats. A four-person group occupies four adjacent seats in one single row. Seats across an aisle (such as [3,3] and [3,4]) are not considered to be adjacent, but there is an exceptional case on which an aisle split a four-person group, in that case, the aisle split a four-person group in the middle, which means to have two people on each side.

     

    Example 1:

    @@ -27,7 +27,7 @@
     Input: n = 3, reservedSeats = [[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]
     Output: 4
    -Explanation: The figure above shows the optimal allocation for four families, where seats mark with blue are already reserved and contiguous seats mark with orange are for one family. 
    +Explanation: The figure above shows the optimal allocation for four groups, where seats mark with blue are already reserved and contiguous seats mark with orange are for one group.
     

    Example 2:

    diff --git a/problems/course-schedule-iv/README.md b/problems/course-schedule-iv/README.md new file mode 100644 index 000000000..75eee50ff --- /dev/null +++ b/problems/course-schedule-iv/README.md @@ -0,0 +1,95 @@ + + + + + + + +[< Previous](../check-if-a-string-contains-all-binary-codes-of-size-k "Check If a String Contains All Binary Codes of Size K") +                 +[Next >](../cherry-pickup-ii "Cherry Pickup II") + +## [1462. Course Schedule IV (Medium)](https://leetcode.com/problems/course-schedule-iv "课程安排 IV") + +

    There are a total of n courses you have to take, labeled from 0 to n-1.

    + +

    Some courses may have direct prerequisites, for example, to take course 0 you have first to take course 1, which is expressed as a pair: [1,0]

    + +

    Given the total number of courses n, a list of direct prerequisite pairs and a list of queries pairs.

    + +

    You should answer for each queries[i] whether the course queries[i][0] is a prerequisite of the course queries[i][1] or not.

    + +

    Return a list of boolean, the answers to the given queries.

    + +

    Please note that if course a is a prerequisite of course b and course b is a prerequisite of course c, then, course a is a prerequisite of course c.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 2, prerequisites = [[1,0]], queries = [[0,1],[1,0]]
    +Output: [false,true]
    +Explanation: course 0 is not a prerequisite of course 1 but the opposite is true.
    +
    + +

    Example 2:

    + +
    +Input: n = 2, prerequisites = [], queries = [[1,0],[0,1]]
    +Output: [false,false]
    +Explanation: There are no prerequisites and each course is independent.
    +
    + +

    Example 3:

    + +
    +Input: n = 3, prerequisites = [[1,2],[1,0],[2,0]], queries = [[1,0],[1,2]]
    +Output: [true,true]
    +
    + +

    Example 4:

    + +
    +Input: n = 3, prerequisites = [[1,0],[2,0]], queries = [[0,1],[2,0]]
    +Output: [false,true]
    +
    + +

    Example 5:

    + +
    +Input: n = 5, prerequisites = [[0,1],[1,2],[2,3],[3,4]], queries = [[0,4],[4,0],[1,3],[3,0]]
    +Output: [true,false,true,false]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 100
    • +
    • 0 <= prerequisite.length <= (n * (n - 1) / 2)
    • +
    • 0 <= prerequisite[i][0], prerequisite[i][1] < n
    • +
    • prerequisite[i][0] != prerequisite[i][1]
    • +
    • The prerequisites graph has no cycles.
    • +
    • The prerequisites graph has no repeated edges.
    • +
    • 1 <= queries.length <= 10^4
    • +
    • queries[i][0] != queries[i][1]
    • +
    + +### Related Topics + [[Graph](../../tag/graph/README.md)] + +### Hints +
    +Hint 1 +Imagine if the courses are nodes of a graph. We need to build an array isReachable[i][j]. +
    + +
    +Hint 2 +Start a bfs from each course i and assign for each course j you visit isReachable[i][j] = True. +
    + +
    +Hint 3 +Answer the queries from the isReachable array. +
    diff --git a/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md b/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md index a0d5c312b..b5867e953 100644 --- a/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md +++ b/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md @@ -54,6 +54,7 @@ Return True if its possible otherwi
  • 1 <= nums[i] <= 10^9
  • 1 <= k <= nums.length
  • +Note: This question is the same as 846: https://leetcode.com/problems/hand-of-straights/ ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/evaluate-boolean-expression/README.md b/problems/evaluate-boolean-expression/README.md index b3ccf69e9..c2f7c6614 100644 --- a/problems/evaluate-boolean-expression/README.md +++ b/problems/evaluate-boolean-expression/README.md @@ -9,6 +9,6 @@                  [Next >](../build-an-array-with-stack-operations "Build an Array With Stack Operations") -## [1440. Evaluate Boolean Expression (Medium)](https://leetcode.com/problems/evaluate-boolean-expression "") +## [1440. Evaluate Boolean Expression (Medium)](https://leetcode.com/problems/evaluate-boolean-expression "计算布尔表达式的值") diff --git a/problems/hand-of-straights/README.md b/problems/hand-of-straights/README.md index fe56a4df6..f3999aa27 100644 --- a/problems/hand-of-straights/README.md +++ b/problems/hand-of-straights/README.md @@ -34,17 +34,18 @@
     Input: hand = [1,2,3,4,5], W = 4
     Output: false
    -Explanation: Alice's hand can't be rearranged into groups of 4.
    +Explanation: Alice's hand can't be rearranged into groups of 4. +

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= hand.length <= 10000
      • 0 <= hand[i] <= 10^9
      • 1 <= W <= hand.length
      • -
    + +Note: This question is the same as 1296: https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/ ### Related Topics [[Ordered Map](../../tag/ordered-map/README.md)] diff --git a/problems/interval-list-intersections/README.md b/problems/interval-list-intersections/README.md index 5b31fbeca..b394cb21e 100644 --- a/problems/interval-list-intersections/README.md +++ b/problems/interval-list-intersections/README.md @@ -27,7 +27,6 @@
     Input: A = [[0,2],[5,10],[13,23],[24,25]], B = [[1,5],[8,12],[15,24],[25,26]]
     Output: [[1,2],[5,5],[8,10],[15,23],[24,24],[25,25]]
    -Reminder: The inputs and the desired output are lists of Interval objects, and not arrays or lists.
     

     

    @@ -39,8 +38,6 @@
  • 0 <= B.length < 1000
  • 0 <= A[i].start, A[i].end, B[i].start, B[i].end < 10^9
  • - -

    NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

    ### Related Topics diff --git a/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md b/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md new file mode 100644 index 000000000..2ec259377 --- /dev/null +++ b/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md @@ -0,0 +1,85 @@ + + + + + + + +[< Previous](../rectangles-area "Rectangles Area") +                 +[Next >](../check-if-a-string-contains-all-binary-codes-of-size-k "Check If a String Contains All Binary Codes of Size K") + +## [1460. Make Two Arrays Equal by Reversing Sub-arrays (Easy)](https://leetcode.com/problems/make-two-arrays-equal-by-reversing-sub-arrays "通过翻转子数组使两个数组相等") + +

    Given two integer arrays of equal length target and arr.

    + +

    In one step, you can select any non-empty sub-array of arr and reverse it. You are allowed to make any number of steps.

    + +

    Return True if you can make arr equal to target, or False otherwise.

    + +

     

    +

    Example 1:

    + +
    +Input: target = [1,2,3,4], arr = [2,4,1,3]
    +Output: true
    +Explanation: You can follow the next steps to convert arr to target:
    +1- Reverse sub-array [2,4,1], arr becomes [1,4,2,3]
    +2- Reverse sub-array [4,2], arr becomes [1,2,4,3]
    +3- Reverse sub-array [4,3], arr becomes [1,2,3,4]
    +There are multiple ways to convert arr to target, this is not the only way to do so.
    +
    + +

    Example 2:

    + +
    +Input: target = [7], arr = [7]
    +Output: true
    +Explanation: arr is equal to target without any reverses.
    +
    + +

    Example 3:

    + +
    +Input: target = [1,12], arr = [12,1]
    +Output: true
    +
    + +

    Example 4:

    + +
    +Input: target = [3,7,9], arr = [3,7,11]
    +Output: false
    +Explanation: arr doesn't have value 9 and it can never be converted to target.
    +
    + +

    Example 5:

    + +
    +Input: target = [1,1,1,1,1], arr = [1,1,1,1,1]
    +Output: true
    +
    + +

     

    +

    Constraints:

    + +
      +
    • target.length == arr.length
    • +
    • 1 <= target.length <= 1000
    • +
    • 1 <= target[i] <= 1000
    • +
    • 1 <= arr[i] <= 1000
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Each element of target should have a corresponding element in arr, and if it doesn't have a corresponding element, return false. +
    + +
    +Hint 2 +To solve it easiely you can sort the two arrays and check if they are equal. +
    diff --git a/problems/max-dot-product-of-two-subsequences/README.md b/problems/max-dot-product-of-two-subsequences/README.md index ee6d8c975..a756469e9 100644 --- a/problems/max-dot-product-of-two-subsequences/README.md +++ b/problems/max-dot-product-of-two-subsequences/README.md @@ -7,7 +7,7 @@ [< Previous](../pseudo-palindromic-paths-in-a-binary-tree "Pseudo-Palindromic Paths in a Binary Tree")                  -Next > +[Next >](../rectangles-area "Rectangles Area") ## [1458. Max Dot Product of Two Subsequences (Hard)](https://leetcode.com/problems/max-dot-product-of-two-subsequences "两个子序列的最大点积") diff --git a/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md b/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md new file mode 100644 index 000000000..188966c7f --- /dev/null +++ b/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../maximum-product-of-two-elements-in-an-array "Maximum Product of Two Elements in an Array") +                 +[Next >](../reorder-routes-to-make-all-paths-lead-to-the-city-zero "Reorder Routes to Make All Paths Lead to the City Zero") + +## [1465. Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts (Medium)](https://leetcode.com/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts "切割后面积最大的蛋糕") + +

    Given a rectangular cake with height h and width w, and two arrays of integers horizontalCuts and verticalCuts where horizontalCuts[i] is the distance from the top of the rectangular cake to the ith horizontal cut and similarly, verticalCuts[j] is the distance from the left of the rectangular cake to the jth vertical cut.

    + +

    Return the maximum area of a piece of cake after you cut at each horizontal and vertical position provided in the arrays horizontalCuts and verticalCutsSince the answer can be a huge number, return this modulo 10^9 + 7.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: h = 5, w = 4, horizontalCuts = [1,2,4], verticalCuts = [1,3]
    +Output: 4 
    +Explanation: The figure above represents the given rectangular cake. Red lines are the horizontal and vertical cuts. After you cut the cake, the green piece of cake has the maximum area.
    +
    + +

    Example 2:

    + +

    + +
    +Input: h = 5, w = 4, horizontalCuts = [3,1], verticalCuts = [1]
    +Output: 6
    +Explanation: The figure above represents the given rectangular cake. Red lines are the horizontal and vertical cuts. After you cut the cake, the green and yellow pieces of cake have the maximum area.
    +
    + +

    Example 3:

    + +
    +Input: h = 5, w = 4, horizontalCuts = [3], verticalCuts = [3]
    +Output: 9
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= h, w <= 10^9
    • +
    • 1 <= horizontalCuts.length < min(h, 10^5)
    • +
    • 1 <= verticalCuts.length < min(w, 10^5)
    • +
    • 1 <= horizontalCuts[i] < h
    • +
    • 1 <= verticalCuts[i] < w
    • +
    • It is guaranteed that all elements in horizontalCuts are distinct.
    • +
    • It is guaranteed that all elements in verticalCuts are distinct.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Sort the arrays, then compute the maximum difference between two consecutive elements for horizontal cuts and vertical cuts. +
    + +
    +Hint 2 +The answer is the product of these maximum values in horizontal cuts and vertical cuts. +
    diff --git a/problems/maximum-product-of-two-elements-in-an-array/README.md b/problems/maximum-product-of-two-elements-in-an-array/README.md new file mode 100644 index 000000000..f343dba97 --- /dev/null +++ b/problems/maximum-product-of-two-elements-in-an-array/README.md @@ -0,0 +1,54 @@ + + + + + + + +[< Previous](../cherry-pickup-ii "Cherry Pickup II") +                 +[Next >](../maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts "Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts") + +## [1464. Maximum Product of Two Elements in an Array (Easy)](https://leetcode.com/problems/maximum-product-of-two-elements-in-an-array "数组中两元素的最大乘积") + +Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1). +

     

    +

    Example 1:

    + +
    +Input: nums = [3,4,5,2]
    +Output: 12 
    +Explanation: If you choose the indices i=1 and j=2 (indexed from 0), you will get the maximum value, that is, (nums[1]-1)*(nums[2]-1) = (4-1)*(5-1) = 3*4 = 12. 
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,5,4,5]
    +Output: 16
    +Explanation: Choosing the indices i=1 and j=3 (indexed from 0), you will get the maximum value of (5-1)*(5-1) = 16.
    +
    + +

    Example 3:

    + +
    +Input: nums = [3,7]
    +Output: 12
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= nums.length <= 500
    • +
    • 1 <= nums[i] <= 10^3
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Use brute force: two loops to select i and j, then select the maximum value of (nums[i]-1)*(nums[j]-1). +
    diff --git a/problems/merge-two-sorted-lists/README.md b/problems/merge-two-sorted-lists/README.md index 565a0b7e3..c60d75e2a 100644 --- a/problems/merge-two-sorted-lists/README.md +++ b/problems/merge-two-sorted-lists/README.md @@ -11,14 +11,14 @@ ## [21. Merge Two Sorted Lists (Easy)](https://leetcode.com/problems/merge-two-sorted-lists "合并两个有序链表") -

    Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.

    +

    Merge two sorted linked lists and return it as a new sorted list. The new list should be made by splicing together the nodes of the first two lists.

    + +

    Example:

    -

    Example:

    -Input: 1->2->4, 1->3->4
    -Output: 1->1->2->3->4->4
    +Input: 1->2->4, 1->3->4
    +Output: 1->1->2->3->4->4
     
    -

    ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/possible-bipartition/README.md b/problems/possible-bipartition/README.md index 55fbc1546..251cd5219 100644 --- a/problems/possible-bipartition/README.md +++ b/problems/possible-bipartition/README.md @@ -52,21 +52,21 @@ Input: N = 5, dislikes = [[1,2],[2,3],[3,4],[4,5],[1,5]] Output: false + + +

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= N <= 2000
      • 0 <= dislikes.length <= 10000
      • +
      • dislikes[i].length == 2
      • 1 <= dislikes[i][j] <= N
      • dislikes[i][0] < dislikes[i][1]
      • There does not exist i != j for which dislikes[i] == dislikes[j].
      • -
    - - - + ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md b/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md new file mode 100644 index 000000000..ec4a207df --- /dev/null +++ b/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md @@ -0,0 +1,105 @@ + + + + + + + +[< Previous](../reorder-routes-to-make-all-paths-lead-to-the-city-zero "Reorder Routes to Make All Paths Lead to the City Zero") +                 +Next > + +## [1467. Probability of a Two Boxes Having The Same Number of Distinct Balls (Hard)](https://leetcode.com/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "两个盒子中球的颜色数相同的概率") + +

    Given 2n balls of k distinct colors. You will be given an integer array balls of size k where balls[i] is the number of balls of color i

    + +

    All the balls will be shuffled uniformly at random, then we will distribute the first n balls to the first box and the remaining n balls to the other box (Please read the explanation of the second example carefully).

    + +

    Please note that the two boxes are considered different. For example, if we have two balls of colors a and b, and two boxes [] and (), then the distribution [a] (b) is considered different than the distribution [b] (a) (Please read the explanation of the first example carefully).

    + +

    We want to calculate the probability that the two boxes have the same number of distinct balls.

    + +

     

    +

    Example 1:

    + +
    +Input: balls = [1,1]
    +Output: 1.00000
    +Explanation: Only 2 ways to divide the balls equally:
    +- A ball of color 1 to box 1 and a ball of color 2 to box 2
    +- A ball of color 2 to box 1 and a ball of color 1 to box 2
    +In both ways, the number of distinct colors in each box is equal. The probability is 2/2 = 1
    +
    + +

    Example 2:

    + +
    +Input: balls = [2,1,1]
    +Output: 0.66667
    +Explanation: We have the set of balls [1, 1, 2, 3]
    +This set of balls will be shuffled randomly and we may have one of the 12 distinct shuffles with equale probability (i.e. 1/12):
    +[1,1 / 2,3], [1,1 / 3,2], [1,2 / 1,3], [1,2 / 3,1], [1,3 / 1,2], [1,3 / 2,1], [2,1 / 1,3], [2,1 / 3,1], [2,3 / 1,1], [3,1 / 1,2], [3,1 / 2,1], [3,2 / 1,1]
    +After that we add the first two balls to the first box and the second two balls to the second box.
    +We can see that 8 of these 12 possible random distributions have the same number of distinct colors of balls in each box.
    +Probability is 8/12 = 0.66667
    +
    + +

    Example 3:

    + +
    +Input: balls = [1,2,1,2]
    +Output: 0.60000
    +Explanation: The set of balls is [1, 2, 2, 3, 4, 4]. It is hard to display all the 180 possible random shuffles of this set but it is easy to check that 108 of them will have the same number of distinct colors in each box.
    +Probability = 108 / 180 = 0.6
    +
    + +

    Example 4:

    + +
    +Input: balls = [3,2,1]
    +Output: 0.30000
    +Explanation: The set of balls is [1, 1, 1, 2, 2, 3]. It is hard to display all the 60 possible random shuffles of this set but it is easy to check that 18 of them will have the same number of distinct colors in each box.
    +Probability = 18 / 60 = 0.3
    +
    + +

    Example 5:

    + +
    +Input: balls = [6,6,6,6,6,6]
    +Output: 0.90327
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= balls.length <= 8
    • +
    • 1 <= balls[i] <= 6
    • +
    • sum(balls) is even.
    • +
    • Answers within 10^-5 of the actual value will be accepted as correct.
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
    +Hint 1 +Check how many ways you can distribute the balls between the boxes. +
    + +
    +Hint 2 +Consider that one way you will use (x1, x2, x3, ..., xk) where xi is the number of balls from colour i. The probability of achieving this way randomly is ( (ball1 C x1) * (ball2 C x2) * (ball3 C x3) * ... * (ballk C xk)) / (2n C n). +
    + +
    +Hint 3 +The probability of a draw is the sigma of probabilities of different ways to achieve draw. +
    + +
    +Hint 4 +Can you use Dynamic programming to solve this problem in a better complexity ? +
    diff --git a/problems/pyramid-transition-matrix/README.md b/problems/pyramid-transition-matrix/README.md index 4cdb08326..d09d7af8c 100644 --- a/problems/pyramid-transition-matrix/README.md +++ b/problems/pyramid-transition-matrix/README.md @@ -47,16 +47,13 @@ Note that there could be allowed triples (A, B, C) and (A, B, D) with C != D.

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • bottom will be a string with length in range [2, 8].
      • allowed will have length in range [0, 200].
      • Letters in all strings will be chosen from the set {'A', 'B', 'C', 'D', 'E', 'F', 'G'}.
      • -
    - -

     

    + ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/rectangles-area/README.md b/problems/rectangles-area/README.md new file mode 100644 index 000000000..cd9a93e2e --- /dev/null +++ b/problems/rectangles-area/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../max-dot-product-of-two-subsequences "Max Dot Product of Two Subsequences") +                 +[Next >](../make-two-arrays-equal-by-reversing-sub-arrays "Make Two Arrays Equal by Reversing Sub-arrays") + +## [1459. Rectangles Area (Medium)](https://leetcode.com/problems/rectangles-area "") + + diff --git a/problems/rectangles-area/mysql_schemas.sql b/problems/rectangles-area/mysql_schemas.sql new file mode 100644 index 000000000..75f4fb6f3 --- /dev/null +++ b/problems/rectangles-area/mysql_schemas.sql @@ -0,0 +1,5 @@ +Create table If Not Exists Points (id int, x_value int, y_value int); +Truncate table Points; +insert into Points (id, x_value, y_value) values ('1', '2', '8'); +insert into Points (id, x_value, y_value) values ('2', '4', '7'); +insert into Points (id, x_value, y_value) values ('3', '2', '10'); diff --git a/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md b/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md new file mode 100644 index 000000000..8740e846e --- /dev/null +++ b/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts "Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts") +                 +[Next >](../probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "Probability of a Two Boxes Having The Same Number of Distinct Balls") + +## [1466. Reorder Routes to Make All Paths Lead to the City Zero (Medium)](https://leetcode.com/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero "重新规划路线") + +

    There are n cities numbered from 0 to n-1 and n-1 roads such that there is only one way to travel between two different cities (this network form a tree). Last year, The ministry of transport decided to orient the roads in one direction because they are too narrow.

    + +

    Roads are represented by connections where connections[i] = [a, b] represents a road from city a to b.

    + +

    This year, there will be a big event in the capital (city 0), and many people want to travel to this city.

    + +

    Your task consists of reorienting some roads such that each city can visit the city 0. Return the minimum number of edges changed.

    + +

    It's guaranteed that each city can reach the city 0 after reorder.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: n = 6, connections = [[0,1],[1,3],[2,3],[4,0],[4,5]]
    +Output: 3
    +Explanation: Change the direction of edges show in red such that each node can reach the node 0 (capital).
    + +

    Example 2:

    + +

    + +
    +Input: n = 5, connections = [[1,0],[1,2],[3,2],[3,4]]
    +Output: 2
    +Explanation: Change the direction of edges show in red such that each node can reach the node 0 (capital).
    + +

    Example 3:

    + +
    +Input: n = 3, connections = [[1,0],[2,0]]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 5 * 10^4
    • +
    • connections.length == n-1
    • +
    • connections[i].length == 2
    • +
    • 0 <= connections[i][0], connections[i][1] <= n-1
    • +
    • connections[i][0] != connections[i][1]
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + +### Hints +
    +Hint 1 +Treat the graph as undirected. Start a dfs from the root, if you come across an edge in the forward direction, you need to reverse the edge. +
    diff --git a/problems/unique-binary-search-trees-ii/README.md b/problems/unique-binary-search-trees-ii/README.md index 9fc43863d..482638ce5 100644 --- a/problems/unique-binary-search-trees-ii/README.md +++ b/problems/unique-binary-search-trees-ii/README.md @@ -11,7 +11,7 @@ ## [95. Unique Binary Search Trees II (Medium)](https://leetcode.com/problems/unique-binary-search-trees-ii "不同的二叉搜索树 II") -

    Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1 ... n.

    +

    Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1 ... n.

    Example:

    @@ -35,6 +35,13 @@ The above output corresponds to the 5 unique BST's shown below: 2 1 2 3 +

     

    +

    Constraints:

    + +
      +
    • 0 <= n <= 8
    • +
    + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/video-stitching/README.md b/problems/video-stitching/README.md index e50de6a2e..18472b3d0 100644 --- a/problems/video-stitching/README.md +++ b/problems/video-stitching/README.md @@ -59,14 +59,13 @@ Notice you can have extra video after the event ends.

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= clips.length <= 100
      • -
      • 0 <= clips[i][0], clips[i][1] <= 100
      • +
      • 0 <= clips[i][0] <= clips[i][1] <= 100
      • 0 <= T <= 100
      • -
    + ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] From 38b080d855c8d5bcf10fbad4e029075ff4e72c96 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 8 Jun 2020 09:01:52 +0800 Subject: [PATCH 069/145] A: new --- README.md | 14 ++- problems/active-users/README.md | 2 +- problems/calculate-salaries/README.md | 14 +++ problems/calculate-salaries/mysql_schemas.sql | 12 +++ .../cheapest-flights-within-k-stops/README.md | 8 +- problems/continuous-subarray-sum/README.md | 7 +- problems/decode-string/README.md | 21 +++-- .../README.md | 2 +- problems/design-browser-history/README.md | 72 +++++++++++++++ problems/find-all-the-lonely-nodes/README.md | 29 ++++++ .../README.md | 19 ++-- problems/house-robber/README.md | 16 +++- .../README.md | 4 +- .../README.md | 13 +-- .../maximum-sum-bst-in-binary-tree/README.md | 2 +- problems/paint-house-iii/README.md | 88 ++++++++++++++++++ .../README.md | 2 +- problems/rank-scores/README.md | 22 +++-- problems/rectangles-area/README.md | 2 +- problems/shuffle-the-array/README.md | 57 ++++++++++++ .../README.md | 91 +++++++++++++++++++ tag/array/README.md | 5 + tag/backtracking/README.md | 1 + tag/bit-manipulation/README.md | 1 + tag/depth-first-search/README.md | 2 + tag/design/README.md | 1 + tag/dynamic-programming/README.md | 2 + tag/graph/README.md | 1 + tag/math/README.md | 1 + tag/sort/README.md | 1 + tag/string/README.md | 1 + tag/tree/README.md | 2 + 32 files changed, 459 insertions(+), 56 deletions(-) create mode 100644 problems/calculate-salaries/README.md create mode 100644 problems/calculate-salaries/mysql_schemas.sql create mode 100644 problems/design-browser-history/README.md create mode 100644 problems/find-all-the-lonely-nodes/README.md create mode 100644 problems/paint-house-iii/README.md create mode 100644 problems/shuffle-the-array/README.md create mode 100644 problems/the-k-strongest-values-in-an-array/README.md diff --git a/README.md b/README.md index c2fb3cf65..d1cdd45c4 100644 --- a/README.md +++ b/README.md @@ -62,20 +62,26 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | -| 1467 | [Probability of a Two Boxes Having The Same Number of Distinct Balls](https://leetcode.com/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "两个盒子中不同颜色的球数量相同的概率") | [Go](problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | Hard | +| 1473 | [Paint House III](https://leetcode.com/problems/paint-house-iii "给房子涂色 III") | [Go](problems/paint-house-iii) | Hard | +| 1472 | [Design Browser History](https://leetcode.com/problems/design-browser-history "设计浏览器历史记录") | [Go](problems/design-browser-history) | Medium | +| 1471 | [The k Strongest Values in an Array](https://leetcode.com/problems/the-k-strongest-values-in-an-array "数组中的 k 个最强值") | [Go](problems/the-k-strongest-values-in-an-array) | Medium | +| 1470 | [Shuffle the Array](https://leetcode.com/problems/shuffle-the-array "重新排列数组") | [Go](problems/shuffle-the-array) | Easy | +| 1469 | [Find All The Lonely Nodes](https://leetcode.com/problems/find-all-the-lonely-nodes) 🔒 | [Go](problems/find-all-the-lonely-nodes) | Easy | +| 1468 | [Calculate Salaries](https://leetcode.com/problems/calculate-salaries) 🔒 | [MySQL](problems/calculate-salaries) | Medium | +| 1467 | [Probability of a Two Boxes Having The Same Number of Distinct Balls](https://leetcode.com/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "两个盒子中球的颜色数相同的概率") | [Go](problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | Hard | | 1466 | [Reorder Routes to Make All Paths Lead to the City Zero](https://leetcode.com/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero "重新规划路线") | [Go](problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | Medium | | 1465 | [Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts](https://leetcode.com/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts "切割后面积最大的蛋糕") | [Go](problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts) | Medium | | 1464 | [Maximum Product of Two Elements in an Array](https://leetcode.com/problems/maximum-product-of-two-elements-in-an-array "数组中两元素的最大乘积") | [Go](problems/maximum-product-of-two-elements-in-an-array) | Easy | | 1463 | [Cherry Pickup II](https://leetcode.com/problems/cherry-pickup-ii "摘樱桃 II") | [Go](problems/cherry-pickup-ii) | Hard | | 1462 | [Course Schedule IV](https://leetcode.com/problems/course-schedule-iv "课程安排 IV") | [Go](problems/course-schedule-iv) | Medium | -| 1461 | [Check If a String Contains All Binary Codes of Size K](https://leetcode.com/problems/check-if-a-string-contains-all-binary-codes-of-size-k "检查一个字符串是否包含所有大小为 K 的二进制子串") | [Go](problems/check-if-a-string-contains-all-binary-codes-of-size-k) | Medium | +| 1461 | [Check If a String Contains All Binary Codes of Size K](https://leetcode.com/problems/check-if-a-string-contains-all-binary-codes-of-size-k "检查一个字符串是否包含所有长度为 K 的二进制子串") | [Go](problems/check-if-a-string-contains-all-binary-codes-of-size-k) | Medium | | 1460 | [Make Two Arrays Equal by Reversing Sub-arrays](https://leetcode.com/problems/make-two-arrays-equal-by-reversing-sub-arrays "通过翻转子数组使两个数组相等") | [Go](problems/make-two-arrays-equal-by-reversing-sub-arrays) | Easy | -| 1459 | [Rectangles Area](https://leetcode.com/problems/rectangles-area) 🔒 | [MySQL](problems/rectangles-area) | Medium | +| 1459 | [Rectangles Area](https://leetcode.com/problems/rectangles-area "矩形面积") 🔒 | [MySQL](problems/rectangles-area) | Medium | | 1458 | [Max Dot Product of Two Subsequences](https://leetcode.com/problems/max-dot-product-of-two-subsequences "两个子序列的最大点积") | [Go](problems/max-dot-product-of-two-subsequences) | Hard | | 1457 | [Pseudo-Palindromic Paths in a Binary Tree](https://leetcode.com/problems/pseudo-palindromic-paths-in-a-binary-tree "二叉树中的伪回文路径") | [Go](problems/pseudo-palindromic-paths-in-a-binary-tree) | Medium | | 1456 | [Maximum Number of Vowels in a Substring of Given Length](https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length "定长子串中元音的最大数目") | [Go](problems/maximum-number-of-vowels-in-a-substring-of-given-length) | Medium | | 1455 | [Check If a Word Occurs As a Prefix of Any Word in a Sentence](https://leetcode.com/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence "检查单词是否为句中其他单词的前缀") | [Go](problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | Easy | -| 1454 | [Active Users](https://leetcode.com/problems/active-users) 🔒 | [MySQL](problems/active-users) | Medium | +| 1454 | [Active Users](https://leetcode.com/problems/active-users " 活跃用户") 🔒 | [MySQL](problems/active-users) | Medium | | 1453 | [Maximum Number of Darts Inside of a Circular Dartboard](https://leetcode.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard "圆形靶内的最大飞镖数量") | [Go](problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | Hard | | 1452 | [People Whose List of Favorite Companies Is Not a Subset of Another List](https://leetcode.com/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list "收藏清单") | [Go](problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | Medium | | 1451 | [Rearrange Words in a Sentence](https://leetcode.com/problems/rearrange-words-in-a-sentence "重新排列句子中的单词") | [Go](problems/rearrange-words-in-a-sentence) | Medium | diff --git a/problems/active-users/README.md b/problems/active-users/README.md index 05d3c0032..cccaaa1df 100644 --- a/problems/active-users/README.md +++ b/problems/active-users/README.md @@ -9,6 +9,6 @@                  [Next >](../check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence "Check If a Word Occurs As a Prefix of Any Word in a Sentence") -## [1454. Active Users (Medium)](https://leetcode.com/problems/active-users "") +## [1454. Active Users (Medium)](https://leetcode.com/problems/active-users " 活跃用户") diff --git a/problems/calculate-salaries/README.md b/problems/calculate-salaries/README.md new file mode 100644 index 000000000..753e9f946 --- /dev/null +++ b/problems/calculate-salaries/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "Probability of a Two Boxes Having The Same Number of Distinct Balls") +                 +[Next >](../find-all-the-lonely-nodes "Find All The Lonely Nodes") + +## [1468. Calculate Salaries (Medium)](https://leetcode.com/problems/calculate-salaries "") + + diff --git a/problems/calculate-salaries/mysql_schemas.sql b/problems/calculate-salaries/mysql_schemas.sql new file mode 100644 index 000000000..a60a565aa --- /dev/null +++ b/problems/calculate-salaries/mysql_schemas.sql @@ -0,0 +1,12 @@ +Create table If Not Exists Salaries (company_id int, employee_id int, employee_name varchar(13), salary int); +Truncate table Salaries; +insert into Salaries (company_id, employee_id, employee_name, salary) values ('1', '1', 'Tony', '2000'); +insert into Salaries (company_id, employee_id, employee_name, salary) values ('1', '2', 'Pronub', '21300'); +insert into Salaries (company_id, employee_id, employee_name, salary) values ('1', '3', 'Tyrrox', '10800'); +insert into Salaries (company_id, employee_id, employee_name, salary) values ('2', '1', 'Pam', '300'); +insert into Salaries (company_id, employee_id, employee_name, salary) values ('2', '7', 'Bassem', '450'); +insert into Salaries (company_id, employee_id, employee_name, salary) values ('2', '9', 'Hermione', '700'); +insert into Salaries (company_id, employee_id, employee_name, salary) values ('3', '7', 'Bocaben', '100'); +insert into Salaries (company_id, employee_id, employee_name, salary) values ('3', '2', 'Ognjen', '2200'); +insert into Salaries (company_id, employee_id, employee_name, salary) values ('3', '13', 'Nyancat', '3300'); +insert into Salaries (company_id, employee_id, employee_name, salary) values ('3', '15', 'Morninngcat', '7777'); diff --git a/problems/cheapest-flights-within-k-stops/README.md b/problems/cheapest-flights-within-k-stops/README.md index 8d003d2d7..a0bb47ed5 100644 --- a/problems/cheapest-flights-within-k-stops/README.md +++ b/problems/cheapest-flights-within-k-stops/README.md @@ -11,7 +11,7 @@ ## [787. Cheapest Flights Within K Stops (Medium)](https://leetcode.com/problems/cheapest-flights-within-k-stops "K 站中转内最便宜的航班") -

    There are n cities connected by m flights. Each flight starts from city u and arrives at v with a price w.

    +

    There are n cities connected by m flights. Each flight starts from city u and arrives at v with a price w.

    Now given all the cities and flights, together with starting city src and the destination dst, your task is to find the cheapest price from src to dst with up to k stops. If there is no such route, output -1.

    @@ -37,9 +37,11 @@ src = 0, dst = 2, k = 0 The graph looks like this: -The cheapest price from city 0 to city 2 with at most 0 stop costs 500, as marked blue in the picture. +The cheapest price from city 0 to city 2 with at most 0 stop costs 500, as marked blue in the picture. + -

    Note:

    +

     

    +

    Constraints:

    • The number of nodes n will be in range [1, 100], with nodes labeled from 0 to n - 1.
    • diff --git a/problems/continuous-subarray-sum/README.md b/problems/continuous-subarray-sum/README.md index 5ef9ff35d..55c6d5344 100644 --- a/problems/continuous-subarray-sum/README.md +++ b/problems/continuous-subarray-sum/README.md @@ -32,13 +32,12 @@

       

      +

      Constraints:

      -

      Note:

      - -
        +
        • The length of the array won't exceed 10,000.
        • You may assume the sum of all the numbers is in the range of a signed 32-bit integer.
        • -
      +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/decode-string/README.md b/problems/decode-string/README.md index a8c64086a..cc017aceb 100644 --- a/problems/decode-string/README.md +++ b/problems/decode-string/README.md @@ -19,15 +19,20 @@

    Furthermore, you may assume that the original data does not contain any digits and that digits are only for those repeat numbers, k. For example, there won't be input like 3a or 2[4].

    -

    Examples:

    - -
    -s = "3[a]2[bc]", return "aaabcbc".
    -s = "3[a2[c]]", return "accaccacc".
    -s = "2[abc]3[cd]ef", return "abcabccdcdcdef".
    -
    -

     

    +

    Example 1:

    +
    Input: s = "3[a]2[bc]"
    +Output: "aaabcbc"
    +

    Example 2:

    +
    Input: s = "3[a2[c]]"
    +Output: "accaccacc"
    +

    Example 3:

    +
    Input: s = "2[abc]3[cd]ef"
    +Output: "abcabccdcdcdef"
    +

    Example 4:

    +
    Input: s = "abc3[cd]xyz"
    +Output: "abccdcdcdxyz"
    +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/delete-leaves-with-a-given-value/README.md b/problems/delete-leaves-with-a-given-value/README.md index 65abf060f..12c7fb813 100644 --- a/problems/delete-leaves-with-a-given-value/README.md +++ b/problems/delete-leaves-with-a-given-value/README.md @@ -65,7 +65,7 @@ After removing, new nodes become leaf nodes with value (target = 2) (Picture in
    • 1 <= target <= 1000
    • -
    • Each tree has at most 3000 nodes.
    • +
    • The given binary tree will have between 1 and 3000 nodes.
    • Each node's value is between [1, 1000].
    diff --git a/problems/design-browser-history/README.md b/problems/design-browser-history/README.md new file mode 100644 index 000000000..a068bfe7c --- /dev/null +++ b/problems/design-browser-history/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../the-k-strongest-values-in-an-array "The k Strongest Values in an Array") +                 +[Next >](../paint-house-iii "Paint House III") + +## [1472. Design Browser History (Medium)](https://leetcode.com/problems/design-browser-history "设计浏览器历史记录") + +

    You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps.

    + +

    Implement the BrowserHistory class:

    + +
      +
    • BrowserHistory(string homepage) Initializes the object with the homepage of the browser.
    • +
    • void visit(string url) visits url from the current page. It clears up all the forward history.
    • +
    • string back(int steps) Move steps back in history. If you can only return x steps in the history and steps > x, you will return only x steps. Return the current url after moving back in history at most steps.
    • +
    • string forward(int steps) Move steps forward in history. If you can only forward x steps in the history and steps > x, you will forward only x steps. Return the current url after forwarding in history at most steps.
    • +
    + +

     

    +

    Example:

    + +
    +Input:
    +["BrowserHistory","visit","visit","visit","back","back","forward","visit","forward","back","back"]
    +[["leetcode.com"],["google.com"],["facebook.com"],["youtube.com"],[1],[1],[1],["linkedin.com"],[2],[2],[7]]
    +Output:
    +[null,null,null,null,"facebook.com","google.com","facebook.com",null,"linkedin.com","google.com","leetcode.com"]
    +
    +Explanation:
    +BrowserHistory browserHistory = new BrowserHistory("leetcode.com");
    +browserHistory.visit("google.com");       // You are in "leetcode.com". Visit "google.com"
    +browserHistory.visit("facebook.com");     // You are in "google.com". Visit "facebook.com"
    +browserHistory.visit("youtube.com");      // You are in "facebook.com". Visit "youtube.com"
    +browserHistory.back(1);                   // You are in "youtube.com", move back to "facebook.com" return "facebook.com"
    +browserHistory.back(1);                   // You are in "facebook.com", move back to "google.com" return "google.com"
    +browserHistory.forward(1);                // You are in "google.com", move forward to "facebook.com" return "facebook.com"
    +browserHistory.visit("linkedin.com");     // You are in "facebook.com". Visit "linkedin.com"
    +browserHistory.forward(2);                // You are in "linkedin.com", you cannot move forward any steps.
    +browserHistory.back(2);                   // You are in "linkedin.com", move back two steps to "facebook.com" then to "google.com". return "google.com"
    +browserHistory.back(7);                   // You are in "google.com", you can move back only one step to "leetcode.com". return "leetcode.com"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= homepage.length <= 20
    • +
    • 1 <= url.length <= 20
    • +
    • 1 <= steps <= 100
    • +
    • homepage and url consist of  '.' or lower case English letters.
    • +
    • At most 5000 calls will be made to visit, back, and forward.
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + +### Hints +
    +Hint 1 +Use two stack one for back history and one for forward history and simulate the functions. +
    + +
    +Hint 2 +Can you do faster by using different data structure ? +
    diff --git a/problems/find-all-the-lonely-nodes/README.md b/problems/find-all-the-lonely-nodes/README.md new file mode 100644 index 000000000..a19d1ff54 --- /dev/null +++ b/problems/find-all-the-lonely-nodes/README.md @@ -0,0 +1,29 @@ + + + + + + + +[< Previous](../calculate-salaries "Calculate Salaries") +                 +[Next >](../shuffle-the-array "Shuffle the Array") + +## [1469. Find All The Lonely Nodes (Easy)](https://leetcode.com/problems/find-all-the-lonely-nodes "") + + + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + +### Hints +
    +Hint 1 +Do a simple tree traversal, try to check if the current node is lonely or not. +
    + +
    +Hint 2 +Node is lonely if at least one of the left/right pointers is null. +
    diff --git a/problems/first-unique-character-in-a-string/README.md b/problems/first-unique-character-in-a-string/README.md index 0256e95bc..da979307d 100644 --- a/problems/first-unique-character-in-a-string/README.md +++ b/problems/first-unique-character-in-a-string/README.md @@ -11,22 +11,21 @@ ## [387. First Unique Character in a String (Easy)](https://leetcode.com/problems/first-unique-character-in-a-string "字符串中的第一个唯一字符") -

    -Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. -

    -

    Examples: +

    Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.

    + +

    Examples:

    +
    -s = "leetcode"
    +s = "leetcode"
     return 0.
     
    -s = "loveleetcode",
    +s = "loveleetcode",
     return 2.
     
    -

    -

    -Note: You may assume the string contain only lowercase letters. -

    +

     

    + +

    Note: You may assume the string contain only lowercase English letters.

    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/house-robber/README.md b/problems/house-robber/README.md index e6cf1754f..7430cf8d5 100644 --- a/problems/house-robber/README.md +++ b/problems/house-robber/README.md @@ -15,23 +15,33 @@

    Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police.

    +

     

    Example 1:

    -Input: [1,2,3,1]
    +Input: nums = [1,2,3,1]
     Output: 4
     Explanation: Rob house 1 (money = 1) and then rob house 3 (money = 3).
    -             Total amount you can rob = 1 + 3 = 4.
    +  Total amount you can rob = 1 + 3 = 4. +

    Example 2:

    -Input: [2,7,9,3,1]
    +Input: nums = [2,7,9,3,1]
     Output: 12
     Explanation: Rob house 1 (money = 2), rob house 3 (money = 9) and rob house 5 (money = 1).
                  Total amount you can rob = 2 + 9 + 1 = 12.
     
    +

     

    +

    Constraints:

    + +
      +
    • 0 <= nums.length <= 100
    • +
    • 0 <= nums[i] <= 400
    • +
    + ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md index a2239cd27..f51d9833c 100644 --- a/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md +++ b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md @@ -11,9 +11,7 @@ ## [1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit (Medium)](https://leetcode.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "绝对差不超过限制的最长连续子数组") -

    Given an array of integers nums and an integer limit, return the size of the longest continuous subarray such that the absolute difference between any two elements is less than or equal to limit.

    - -

    In case there is no subarray satisfying the given condition return 0.

    +

    Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference between any two elements of this subarray is less than or equal to limit.

     

    Example 1:

    diff --git a/problems/maximize-distance-to-closest-person/README.md b/problems/maximize-distance-to-closest-person/README.md index 9f748c650..bcf8f806d 100644 --- a/problems/maximize-distance-to-closest-person/README.md +++ b/problems/maximize-distance-to-closest-person/README.md @@ -40,15 +40,16 @@ Thus, the maximum distance to the closest person is 2. If Alex sits in the last seat, the closest person is 3 seats away. This is the maximum distance possible, so the answer is 3. + + -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. 1 <= seats.length <= 20000
    2. +
        +
      • 2 <= seats.length <= 20000
      • seats contains only 0s or 1s, at least one 0, and at least one 1.
      • -
    - - + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/maximum-sum-bst-in-binary-tree/README.md b/problems/maximum-sum-bst-in-binary-tree/README.md index bd1da9df9..fe33f295a 100644 --- a/problems/maximum-sum-bst-in-binary-tree/README.md +++ b/problems/maximum-sum-bst-in-binary-tree/README.md @@ -68,7 +68,7 @@

    Constraints:

      -
    • Each tree has at most 40000 nodes..
    • +
    • The given binary tree will have between 1 and 40000 nodes.
    • Each node's value is between [-4 * 10^4 , 4 * 10^4].
    diff --git a/problems/paint-house-iii/README.md b/problems/paint-house-iii/README.md new file mode 100644 index 000000000..62d7469f9 --- /dev/null +++ b/problems/paint-house-iii/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../design-browser-history "Design Browser History") +                 +Next > + +## [1473. Paint House III (Hard)](https://leetcode.com/problems/paint-house-iii "给房子涂色 III") + +

    There is a row of m houses in a small city, each house must be painted with one of the n colors (labeled from 1 to n), some houses that has been painted last summer should not be painted again.

    + +

    A neighborhood is a maximal group of continuous houses that are painted with the same color. (For example: houses = [1,2,2,3,3,2,1,1] contains 5 neighborhoods  [{1}, {2,2}, {3,3}, {2}, {1,1}]).

    + +

    Given an array houses, an m * n matrix cost and an integer target where:

    + +
      +
    • houses[i]: is the color of the house i, 0 if the house is not painted yet.
    • +
    • cost[i][j]: is the cost of paint the house i with the color j+1.
    • +
    + +

    Return the minimum cost of painting all the remaining houses in such a way that there are exactly target neighborhoods, if not possible return -1.

    + +

     

    +

    Example 1:

    + +
    +Input: houses = [0,0,0,0,0], cost = [[1,10],[10,1],[10,1],[1,10],[5,1]], m = 5, n = 2, target = 3
    +Output: 9
    +Explanation: Paint houses of this way [1,2,2,1,1]
    +This array contains target = 3 neighborhoods, [{1}, {2,2}, {1,1}].
    +Cost of paint all houses (1 + 1 + 1 + 1 + 5) = 9.
    +
    + +

    Example 2:

    + +
    +Input: houses = [0,2,1,2,0], cost = [[1,10],[10,1],[10,1],[1,10],[5,1]], m = 5, n = 2, target = 3
    +Output: 11
    +Explanation: Some houses are already painted, Paint the houses of this way [2,2,1,2,2]
    +This array contains target = 3 neighborhoods, [{2,2}, {1}, {2,2}]. 
    +Cost of paint the first and last house (10 + 1) = 11.
    +
    + +

    Example 3:

    + +
    +Input: houses = [0,0,0,0,0], cost = [[1,10],[10,1],[1,10],[10,1],[1,10]], m = 5, n = 2, target = 5
    +Output: 5
    +
    + +

    Example 4:

    + +
    +Input: houses = [3,1,2,3], cost = [[1,1,1],[1,1,1],[1,1,1],[1,1,1]], m = 4, n = 3, target = 3
    +Output: -1
    +Explanation: Houses are already painted with a total of 4 neighborhoods [{3},{1},{2},{3}] different of target = 3.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == houses.length == cost.length
    • +
    • n == cost[i].length
    • +
    • 1 <= m <= 100
    • +
    • 1 <= n <= 20
    • +
    • 1 <= target <= m
    • +
    • 0 <= houses[i] <= n
    • +
    • 1 <= cost[i][j] <= 10^4
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Use Dynamic programming. +
    + +
    +Hint 2 +Define dp[i][j][k] as the minimum cost where we have k neighborhoods in the first i houses and the i-th house is painted with the color j. +
    diff --git a/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md b/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md index ec4a207df..b51e1e54b 100644 --- a/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md +++ b/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md @@ -7,7 +7,7 @@ [< Previous](../reorder-routes-to-make-all-paths-lead-to-the-city-zero "Reorder Routes to Make All Paths Lead to the City Zero")                  -Next > +[Next >](../calculate-salaries "Calculate Salaries") ## [1467. Probability of a Two Boxes Having The Same Number of Distinct Balls (Hard)](https://leetcode.com/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "两个盒子中球的颜色数相同的概率") diff --git a/problems/rank-scores/README.md b/problems/rank-scores/README.md index 348ec520c..7f9cd7f57 100644 --- a/problems/rank-scores/README.md +++ b/problems/rank-scores/README.md @@ -29,14 +29,16 @@

    For example, given the above Scores table, your query should generate the following report (order by highest score):

    -+-------+------+
    -| Score | Rank |
    -+-------+------+
    -| 4.00  | 1    |
    -| 4.00  | 1    |
    -| 3.85  | 2    |
    -| 3.65  | 3    |
    -| 3.65  | 3    |
    -| 3.50  | 4    |
    -+-------+------+
    ++-------+---------+
    +| score | Rank    |
    ++-------+---------+
    +| 4.00  | 1       |
    +| 4.00  | 1       |
    +| 3.85  | 2       |
    +| 3.65  | 3       |
    +| 3.65  | 3       |
    +| 3.50  | 4       |
    ++-------+---------+
     
    + +

    Important Note: For MySQL solutions, to escape reserved words used as column names, you can use an apostrophe before and after the keyword. For example `Rank`.

    diff --git a/problems/rectangles-area/README.md b/problems/rectangles-area/README.md index cd9a93e2e..f2a2e02b6 100644 --- a/problems/rectangles-area/README.md +++ b/problems/rectangles-area/README.md @@ -9,6 +9,6 @@                  [Next >](../make-two-arrays-equal-by-reversing-sub-arrays "Make Two Arrays Equal by Reversing Sub-arrays") -## [1459. Rectangles Area (Medium)](https://leetcode.com/problems/rectangles-area "") +## [1459. Rectangles Area (Medium)](https://leetcode.com/problems/rectangles-area "矩形面积") diff --git a/problems/shuffle-the-array/README.md b/problems/shuffle-the-array/README.md new file mode 100644 index 000000000..43679a3af --- /dev/null +++ b/problems/shuffle-the-array/README.md @@ -0,0 +1,57 @@ + + + + + + + +[< Previous](../find-all-the-lonely-nodes "Find All The Lonely Nodes") +                 +[Next >](../the-k-strongest-values-in-an-array "The k Strongest Values in an Array") + +## [1470. Shuffle the Array (Easy)](https://leetcode.com/problems/shuffle-the-array "重新排列数组") + +

    Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn].

    + +

    Return the array in the form [x1,y1,x2,y2,...,xn,yn].

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [2,5,1,3,4,7], n = 3
    +Output: [2,3,5,4,1,7] 
    +Explanation: Since x1=2, x2=5, x3=1, y1=3, y2=4, y3=7 then the answer is [2,3,5,4,1,7].
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,2,3,4,4,3,2,1], n = 4
    +Output: [1,4,2,3,3,2,4,1]
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,1,2,2], n = 2
    +Output: [1,2,1,2]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 500
    • +
    • nums.length == 2n
    • +
    • 1 <= nums[i] <= 10^3
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Use two pointers to create the new array of 2n elements. The first starting at the beginning and the other starting at (n+1)th position. Alternate between them and create the new array. +
    diff --git a/problems/the-k-strongest-values-in-an-array/README.md b/problems/the-k-strongest-values-in-an-array/README.md new file mode 100644 index 000000000..8ff4ad6ae --- /dev/null +++ b/problems/the-k-strongest-values-in-an-array/README.md @@ -0,0 +1,91 @@ + + + + + + + +[< Previous](../shuffle-the-array "Shuffle the Array") +                 +[Next >](../design-browser-history "Design Browser History") + +## [1471. The k Strongest Values in an Array (Medium)](https://leetcode.com/problems/the-k-strongest-values-in-an-array "数组中的 k 个最强值") + +

    Given an array of integers arr and an integer k.

    + +

    A value arr[i] is said to be stronger than a value arr[j] if |arr[i] - m| > |arr[j] - m| where m is the median of the array.
    +If |arr[i] - m| == |arr[j] - m|, then arr[i] is said to be stronger than arr[j] if arr[i] > arr[j].

    + +

    Return a list of the strongest k values in the array. return the answer in any arbitrary order.

    + +

    Median is the middle value in an ordered integer list. More formally, if the length of the list is n, the median is the element in position ((n - 1) / 2) in the sorted list (0-indexed).

    + +
      +
    • For arr = [6, -3, 7, 2, 11]n = 5 and the median is obtained by sorting the array arr = [-3, 2, 6, 7, 11] and the median is arr[m] where m = ((5 - 1) / 2) = 2. The median is 6.
    • +
    • For arr = [-7, 22, 17, 3]n = 4 and the median is obtained by sorting the array arr = [-7, 3, 17, 22] and the median is arr[m] where m = ((4 - 1) / 2) = 1. The median is 3.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: arr = [1,2,3,4,5], k = 2
    +Output: [5,1]
    +Explanation: Median is 3, the elements of the array sorted by the strongest are [5,1,4,2,3]. The strongest 2 elements are [5, 1]. [1, 5] is also accepted answer.
    +Please note that although |5 - 3| == |1 - 3| but 5 is stronger than 1 because 5 > 1.
    +
    + +

    Example 2:

    + +
    +Input: arr = [1,1,3,5,5], k = 2
    +Output: [5,5]
    +Explanation: Median is 3, the elements of the array sorted by the strongest are [5,5,1,1,3]. The strongest 2 elements are [5, 5].
    +
    + +

    Example 3:

    + +
    +Input: arr = [6,7,11,7,6,8], k = 5
    +Output: [11,8,6,6,7]
    +Explanation: Median is 7, the elements of the array sorted by the strongest are [11,8,6,6,7,7].
    +Any permutation of [11,8,6,6,7] is accepted.
    +
    + +

    Example 4:

    + +
    +Input: arr = [6,-3,7,2,11], k = 3
    +Output: [-3,11,2]
    +
    + +

    Example 5:

    + +
    +Input: arr = [-7,22,17,3], k = 2
    +Output: [22,17]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 10^5
    • +
    • -10^5 <= arr[i] <= 10^5
    • +
    • 1 <= k <= arr.length
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Calculate the median of the array as defined in the statement. +
    + +
    +Hint 2 +Use custom sort function to sort values (Strongest first), then slice the first k. +
    diff --git a/tag/array/README.md b/tag/array/README.md index ed9e02fc0..9d8b5316e 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1471 | [数组中的 k 个最强值](../../problems/the-k-strongest-values-in-an-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1470 | [重新排列数组](../../problems/shuffle-the-array) | [[数组](../array/README.md)] | Easy | +| 1465 | [切割后面积最大的蛋糕](../../problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts) | [[数组](../array/README.md)] | Medium | +| 1464 | [数组中两元素的最大乘积](../../problems/maximum-product-of-two-elements-in-an-array) | [[数组](../array/README.md)] | Easy | +| 1460 | [通过翻转子数组使两个数组相等](../../problems/make-two-arrays-equal-by-reversing-sub-arrays) | [[数组](../array/README.md)] | Easy | | 1450 | [在既定时间做作业的学生人数](../../problems/number-of-students-doing-homework-at-a-given-time) | [[数组](../array/README.md)] | Easy | | 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 86c2e7d88..62615e280 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1415 | [长度为 n 的开心字符串中字典序第 k 小的字符串](../../problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | [[回溯算法](../backtracking/README.md)] | Medium | | 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1291 | [顺次数](../../problems/sequential-digits) | [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 108b7ff40..88c883798 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 936794801..9abe22563 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1469 | [Find All The Lonely Nodes](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 1466 | [重新规划路线](../../problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index 546da5322..8f7969f23 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[设计](../design/README.md)] | Medium | | 1429 | [First Unique Number](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] | Medium | | 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 7f5c30011..391ee6bb5 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1473 | [给房子涂色 III](../../problems/paint-house-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1463 | [摘樱桃 II](../../problems/cherry-pickup-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1458 | [两个子序列的最大点积](../../problems/max-dot-product-of-two-subsequences) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1444 | [切披萨的方案数](../../problems/number-of-ways-of-cutting-a-pizza) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index 0dc91bb4e..cef03e5f3 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1462 | [课程安排 IV](../../problems/course-schedule-iv) | [[图](../graph/README.md)] | Medium | | 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | | 1361 | [验证二叉树](../../problems/validate-binary-tree-nodes) | [[图](../graph/README.md)] | Medium | | 1334 | [阈值距离内邻居最少的城市](../../problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | [[图](../graph/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index b8042189d..9d967e5de 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] | Medium | | 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1427 | [Perform String Shifts](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | diff --git a/tag/sort/README.md b/tag/sort/README.md index ffdc26b64..a5094a7e1 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1471 | [数组中的 k 个最强值](../../problems/the-k-strongest-values-in-an-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | | 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | | 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index 23117a1b0..50c3ffe5c 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1455 | [检查单词是否为句中其他单词的前缀](../../problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | [[字符串](../string/README.md)] | Easy | | 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/tree/README.md b/tag/tree/README.md index 99f713b4e..01ce441c7 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1469 | [Find All The Lonely Nodes](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 1466 | [重新规划路线](../../problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | From 574a257f0181f9623fba499f5ca5f4838023bb0e Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 22 Jun 2020 09:32:51 +0800 Subject: [PATCH 070/145] A: new --- README.md | 20 +++- problems/allocate-mailboxes/README.md | 81 +++++++++++++ problems/avoid-flood-in-the-city/README.md | 113 ++++++++++++++++++ problems/calculate-salaries/README.md | 2 +- .../README.md | 7 +- .../README.md | 2 +- .../README.md | 29 +++++ .../README.md | 17 +++ problems/expression-add-operators/README.md | 8 ++ .../README.md | 61 ++++++++++ .../README.md | 80 +++++++++++++ .../README.md | 87 ++++++++++++++ .../group-sold-products-by-the-date/README.md | 14 +++ .../mysql_schemas.sql | 9 ++ problems/increasing-subsequences/README.md | 7 +- problems/koko-eating-bananas/README.md | 40 ++----- .../kth-ancestor-of-a-tree-node/README.md | 65 ++++++++++ .../README.md | 56 +++++++++ .../longest-palindromic-subsequence/README.md | 37 +++--- problems/making-file-names-unique/README.md | 96 +++++++++++++++ problems/maximum-binary-tree-ii/README.md | 10 +- problems/minimum-falling-path-sum/README.md | 7 +- .../README.md | 95 +++++++++++++++ problems/paint-house-iii/README.md | 2 +- problems/partition-labels/README.md | 30 +++-- problems/perform-string-shifts/README.md | 2 +- problems/random-pick-with-weight/README.md | 62 ++++++---- problems/reconstruct-itinerary/README.md | 1 + problems/running-sum-of-1d-array/README.md | 55 +++++++++ problems/sales-by-day-of-the-week/README.md | 14 +++ .../mysql_schemas.sql | 19 +++ problems/subrectangle-queries/README.md | 103 ++++++++++++++++ problems/target-sum/README.md | 28 ++--- problems/task-scheduler/README.md | 35 ++++-- problems/validate-ip-address/README.md | 69 ++++------- problems/xor-operation-in-an-array/README.md | 68 +++++++++++ tag/README.md | 2 +- tag/array/README.md | 9 +- tag/binary-search/README.md | 1 + tag/bit-manipulation/README.md | 1 + tag/depth-first-search/README.md | 2 + tag/dynamic-programming/README.md | 3 + tag/hash-table/README.md | 2 + tag/linked-list/README.md | 1 + tag/math/README.md | 3 +- tag/sort/README.md | 1 + tag/string/README.md | 1 + tag/tags.json | 10 +- tag/tree/README.md | 1 + tag/union-find/README.md | 1 + 50 files changed, 1295 insertions(+), 174 deletions(-) create mode 100644 problems/allocate-mailboxes/README.md create mode 100644 problems/avoid-flood-in-the-city/README.md create mode 100644 problems/clone-binary-tree-with-random-pointer/README.md create mode 100644 problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md create mode 100644 problems/final-prices-with-a-special-discount-in-a-shop/README.md create mode 100644 problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md create mode 100644 problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md create mode 100644 problems/group-sold-products-by-the-date/README.md create mode 100644 problems/group-sold-products-by-the-date/mysql_schemas.sql create mode 100644 problems/kth-ancestor-of-a-tree-node/README.md create mode 100644 problems/least-number-of-unique-integers-after-k-removals/README.md create mode 100644 problems/making-file-names-unique/README.md create mode 100644 problems/minimum-number-of-days-to-make-m-bouquets/README.md create mode 100644 problems/running-sum-of-1d-array/README.md create mode 100644 problems/sales-by-day-of-the-week/README.md create mode 100644 problems/sales-by-day-of-the-week/mysql_schemas.sql create mode 100644 problems/subrectangle-queries/README.md create mode 100644 problems/xor-operation-in-an-array/README.md diff --git a/README.md b/README.md index d1cdd45c4..6e9fddc93 100644 --- a/README.md +++ b/README.md @@ -62,12 +62,28 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1489 | [Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree](https://leetcode.com/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree "找到最小生成树里的关键边和伪关键边") | [Go](problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | Hard | +| 1488 | [Avoid Flood in The City](https://leetcode.com/problems/avoid-flood-in-the-city "避免洪水泛滥") | [Go](problems/avoid-flood-in-the-city) | Medium | +| 1487 | [Making File Names Unique](https://leetcode.com/problems/making-file-names-unique "保证文件名唯一") | [Go](problems/making-file-names-unique) | Medium | +| 1486 | [XOR Operation in an Array](https://leetcode.com/problems/xor-operation-in-an-array "数组异或操作") | [Go](problems/xor-operation-in-an-array) | Easy | +| 1485 | [Clone Binary Tree With Random Pointer](https://leetcode.com/problems/clone-binary-tree-with-random-pointer "克隆含随机指针的二叉树") 🔒 | [Go](problems/clone-binary-tree-with-random-pointer) | Medium | +| 1484 | [Group Sold Products By The Date](https://leetcode.com/problems/group-sold-products-by-the-date) 🔒 | [MySQL](problems/group-sold-products-by-the-date) | Easy | +| 1483 | [Kth Ancestor of a Tree Node](https://leetcode.com/problems/kth-ancestor-of-a-tree-node "树节点的第 K 个祖先") | [Go](problems/kth-ancestor-of-a-tree-node) | Hard | +| 1482 | [Minimum Number of Days to Make m Bouquets](https://leetcode.com/problems/minimum-number-of-days-to-make-m-bouquets "制作 m 束花所需的最少天数") | [Go](problems/minimum-number-of-days-to-make-m-bouquets) | Medium | +| 1481 | [Least Number of Unique Integers after K Removals](https://leetcode.com/problems/least-number-of-unique-integers-after-k-removals "不同整数的最少数目") | [Go](problems/least-number-of-unique-integers-after-k-removals) | Medium | +| 1480 | [Running Sum of 1d Array](https://leetcode.com/problems/running-sum-of-1d-array "一维数组的动态和") | [Go](problems/running-sum-of-1d-array) | Easy | +| 1479 | [Sales by Day of the Week](https://leetcode.com/problems/sales-by-day-of-the-week) 🔒 | [MySQL](problems/sales-by-day-of-the-week) | Hard | +| 1478 | [Allocate Mailboxes](https://leetcode.com/problems/allocate-mailboxes "安排邮筒") | [Go](problems/allocate-mailboxes) | Hard | +| 1477 | [Find Two Non-overlapping Sub-arrays Each With Target Sum](https://leetcode.com/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum "找两个和为目标值且不重叠的子数组") | [Go](problems/find-two-non-overlapping-sub-arrays-each-with-target-sum) | Medium | +| 1476 | [Subrectangle Queries](https://leetcode.com/problems/subrectangle-queries "子矩形查询") | [Go](problems/subrectangle-queries) | Medium | +| 1475 | [Final Prices With a Special Discount in a Shop](https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop "商品折扣后的最终价格") | [Go](problems/final-prices-with-a-special-discount-in-a-shop) | Easy | +| 1474 | [Delete N Nodes After M Nodes of a Linked List](https://leetcode.com/problems/delete-n-nodes-after-m-nodes-of-a-linked-list "删除链表 M 个节点之后的 N 个节点") 🔒 | [Go](problems/delete-n-nodes-after-m-nodes-of-a-linked-list) | Easy | | 1473 | [Paint House III](https://leetcode.com/problems/paint-house-iii "给房子涂色 III") | [Go](problems/paint-house-iii) | Hard | | 1472 | [Design Browser History](https://leetcode.com/problems/design-browser-history "设计浏览器历史记录") | [Go](problems/design-browser-history) | Medium | | 1471 | [The k Strongest Values in an Array](https://leetcode.com/problems/the-k-strongest-values-in-an-array "数组中的 k 个最强值") | [Go](problems/the-k-strongest-values-in-an-array) | Medium | | 1470 | [Shuffle the Array](https://leetcode.com/problems/shuffle-the-array "重新排列数组") | [Go](problems/shuffle-the-array) | Easy | | 1469 | [Find All The Lonely Nodes](https://leetcode.com/problems/find-all-the-lonely-nodes) 🔒 | [Go](problems/find-all-the-lonely-nodes) | Easy | -| 1468 | [Calculate Salaries](https://leetcode.com/problems/calculate-salaries) 🔒 | [MySQL](problems/calculate-salaries) | Medium | +| 1468 | [Calculate Salaries](https://leetcode.com/problems/calculate-salaries "计算税后工资") 🔒 | [MySQL](problems/calculate-salaries) | Medium | | 1467 | [Probability of a Two Boxes Having The Same Number of Distinct Balls](https://leetcode.com/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "两个盒子中球的颜色数相同的概率") | [Go](problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | Hard | | 1466 | [Reorder Routes to Make All Paths Lead to the City Zero](https://leetcode.com/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero "重新规划路线") | [Go](problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | Medium | | 1465 | [Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts](https://leetcode.com/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts "切割后面积最大的蛋糕") | [Go](problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts) | Medium | @@ -108,7 +124,7 @@ LeetCode Problems' Solutions | 1430 | [Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree](https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [Go](problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) | Medium | | 1429 | [First Unique Number](https://leetcode.com/problems/first-unique-number) 🔒 | [Go](problems/first-unique-number) | Medium | | 1428 | [Leftmost Column with at Least a One](https://leetcode.com/problems/leftmost-column-with-at-least-a-one "至少有一个 1 的最左端列") 🔒 | [Go](problems/leftmost-column-with-at-least-a-one) | Medium | -| 1427 | [Perform String Shifts](https://leetcode.com/problems/perform-string-shifts) 🔒 | [Go](problems/perform-string-shifts) | Easy | +| 1427 | [Perform String Shifts](https://leetcode.com/problems/perform-string-shifts "字符串的左右移") 🔒 | [Go](problems/perform-string-shifts) | Easy | | 1426 | [Counting Elements](https://leetcode.com/problems/counting-elements "数元素") 🔒 | [Go](problems/counting-elements) | Easy | | 1425 | [Constrained Subsequence Sum](https://leetcode.com/problems/constrained-subsequence-sum "带限制的子序列和") | [Go](problems/constrained-subsequence-sum) | Hard | | 1424 | [Diagonal Traverse II](https://leetcode.com/problems/diagonal-traverse-ii "对角线遍历 II") | [Go](problems/diagonal-traverse-ii) | Medium | diff --git a/problems/allocate-mailboxes/README.md b/problems/allocate-mailboxes/README.md new file mode 100644 index 000000000..f8b3ac88b --- /dev/null +++ b/problems/allocate-mailboxes/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../find-two-non-overlapping-sub-arrays-each-with-target-sum "Find Two Non-overlapping Sub-arrays Each With Target Sum") +                 +[Next >](../sales-by-day-of-the-week "Sales by Day of the Week") + +## [1478. Allocate Mailboxes (Hard)](https://leetcode.com/problems/allocate-mailboxes "安排邮筒") + +

    Given the array houses and an integer k. where houses[i] is the location of the ith house along a street, your task is to allocate k mailboxes in the street.

    + +

    Return the minimum total distance between each house and its nearest mailbox.

    + +

    The answer is guaranteed to fit in a 32-bit signed integer.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: houses = [1,4,8,10,20], k = 3
    +Output: 5
    +Explanation: Allocate mailboxes in position 3, 9 and 20.
    +Minimum total distance from each houses to nearest mailboxes is |3-1| + |4-3| + |9-8| + |10-9| + |20-20| = 5 
    +
    + +

    Example 2:

    + +

    + +
    +Input: houses = [2,3,5,12,18], k = 2
    +Output: 9
    +Explanation: Allocate mailboxes in position 3 and 14.
    +Minimum total distance from each houses to nearest mailboxes is |2-3| + |3-3| + |5-3| + |12-14| + |18-14| = 9.
    +
    + +

    Example 3:

    + +
    +Input: houses = [7,4,6,1], k = 1
    +Output: 8
    +
    + +

    Example 4:

    + +
    +Input: houses = [3,6,14,10], k = 4
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == houses.length
    • +
    • 1 <= n <= 100
    • +
    • 1 <= houses[i] <= 10^4
    • +
    • 1 <= k <= n
    • +
    • Array houses contain unique integers.
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +If k =1, the minimum distance is obtained allocating the mailbox in the median of the array houses. +
    + +
    +Hint 2 +Generalize this idea, using dynamic programming allocating k mailboxes. +
    diff --git a/problems/avoid-flood-in-the-city/README.md b/problems/avoid-flood-in-the-city/README.md new file mode 100644 index 000000000..fade8b947 --- /dev/null +++ b/problems/avoid-flood-in-the-city/README.md @@ -0,0 +1,113 @@ + + + + + + + +[< Previous](../making-file-names-unique "Making File Names Unique") +                 +[Next >](../find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree "Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree") + +## [1488. Avoid Flood in The City (Medium)](https://leetcode.com/problems/avoid-flood-in-the-city "避免洪水泛滥") + +

    Your country has an infinite number of lakes. Initially, all the lakes are empty, but when it rains over the nth lake, the nth lake becomes full of water. If it rains over a lake which is full of water, there will be a flood. Your goal is to avoid the flood in any lake.

    + +

    Given an integer array rains where:

    + +
      +
    • rains[i] > 0 means there will be rains over the rains[i] lake.
    • +
    • rains[i] == 0 means there are no rains this day and you can choose one lake this day and dry it.
    • +
    + +

    Return an array ans where:

    + +
      +
    • ans.length == rains.length
    • +
    • ans[i] == -1 if rains[i] > 0.
    • +
    • ans[i] is the lake you choose to dry in the ith day if rains[i] == 0.
    • +
    + +

    If there are multiple valid answers return any of them. If it is impossible to avoid flood return an empty array.

    + +

    Notice that if you chose to dry a full lake, it becomes empty, but if you chose to dry an empty lake, nothing changes. (see example 4)

    + +

     

    +

    Example 1:

    + +
    +Input: rains = [1,2,3,4]
    +Output: [-1,-1,-1,-1]
    +Explanation: After the first day full lakes are [1]
    +After the second day full lakes are [1,2]
    +After the third day full lakes are [1,2,3]
    +After the fourth day full lakes are [1,2,3,4]
    +There's no day to dry any lake and there is no flood in any lake.
    +
    + +

    Example 2:

    + +
    +Input: rains = [1,2,0,0,2,1]
    +Output: [-1,-1,2,1,-1,-1]
    +Explanation: After the first day full lakes are [1]
    +After the second day full lakes are [1,2]
    +After the third day, we dry lake 2. Full lakes are [1]
    +After the fourth day, we dry lake 1. There is no full lakes.
    +After the fifth day, full lakes are [2].
    +After the sixth day, full lakes are [1,2].
    +It is easy that this scenario is flood-free. [-1,-1,1,2,-1,-1] is another acceptable scenario.
    +
    + +

    Example 3:

    + +
    +Input: rains = [1,2,0,1,2]
    +Output: []
    +Explanation: After the second day, full lakes are  [1,2]. We have to dry one lake in the third day.
    +After that, it will rain over lakes [1,2]. It's easy to prove that no matter which lake you choose to dry in the 3rd day, the other one will flood.
    +
    + +

    Example 4:

    + +
    +Input: rains = [69,0,0,0,69]
    +Output: [-1,69,1,1,-1]
    +Explanation: Any solution on one of the forms [-1,69,x,y,-1], [-1,x,69,y,-1] or [-1,x,y,69,-1] is acceptable where 1 <= x,y <= 10^9
    +
    + +

    Example 5:

    + +
    +Input: rains = [10,20,20]
    +Output: []
    +Explanation: It will rain over lake 20 two consecutive days. There is no chance to dry any lake.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= rains.length <= 10^5
    • +
    • 0 <= rains[i] <= 10^9
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +Keep An array of the last day there was rains over each city. +
    + +
    +Hint 2 +Keep an array of the days you can dry a lake when you face one. +
    + +
    +Hint 3 +When it rains over a lake, check the first possible day you can dry this lake and assign this day to this lake. +
    diff --git a/problems/calculate-salaries/README.md b/problems/calculate-salaries/README.md index 753e9f946..23877d36e 100644 --- a/problems/calculate-salaries/README.md +++ b/problems/calculate-salaries/README.md @@ -9,6 +9,6 @@                  [Next >](../find-all-the-lonely-nodes "Find All The Lonely Nodes") -## [1468. Calculate Salaries (Medium)](https://leetcode.com/problems/calculate-salaries "") +## [1468. Calculate Salaries (Medium)](https://leetcode.com/problems/calculate-salaries "计算税后工资") diff --git a/problems/capacity-to-ship-packages-within-d-days/README.md b/problems/capacity-to-ship-packages-within-d-days/README.md index 82f7876f5..e311fa320 100644 --- a/problems/capacity-to-ship-packages-within-d-days/README.md +++ b/problems/capacity-to-ship-packages-within-d-days/README.md @@ -60,13 +60,12 @@ A ship capacity of 6 is the minimum to ship all the packages in 3 days like this

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= D <= weights.length <= 50000
      • 1 <= weights[i] <= 500
      • -
    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md b/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md index d50ff2544..ccb31ff31 100644 --- a/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md +++ b/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md @@ -13,7 +13,7 @@

    Given a binary string s and an integer k.

    -

    Return True if all binary codes of length k is a substring of s. Otherwise, return False.

    +

    Return True if every binary code of length k is a substring of s. Otherwise, return False.

     

    Example 1:

    diff --git a/problems/clone-binary-tree-with-random-pointer/README.md b/problems/clone-binary-tree-with-random-pointer/README.md new file mode 100644 index 000000000..13690a8cd --- /dev/null +++ b/problems/clone-binary-tree-with-random-pointer/README.md @@ -0,0 +1,29 @@ + + + + + + + +[< Previous](../group-sold-products-by-the-date "Group Sold Products By The Date") +                 +[Next >](../xor-operation-in-an-array "XOR Operation in an Array") + +## [1485. Clone Binary Tree With Random Pointer (Medium)](https://leetcode.com/problems/clone-binary-tree-with-random-pointer "克隆含随机指针的二叉树") + + + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + +### Hints +
    +Hint 1 +Create an equivalent node for each node in the original tree. +
    + +
    +Hint 2 +Start traversing the original tree and connect the left, right and random pointers in the cloned tree the same way as the original tree. +
    diff --git a/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md b/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md new file mode 100644 index 000000000..2260751eb --- /dev/null +++ b/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../paint-house-iii "Paint House III") +                 +[Next >](../final-prices-with-a-special-discount-in-a-shop "Final Prices With a Special Discount in a Shop") + +## [1474. Delete N Nodes After M Nodes of a Linked List (Easy)](https://leetcode.com/problems/delete-n-nodes-after-m-nodes-of-a-linked-list "删除链表 M 个节点之后的 N 个节点") + + + +### Related Topics + [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/expression-add-operators/README.md b/problems/expression-add-operators/README.md index 03eceb030..67e43041c 100644 --- a/problems/expression-add-operators/README.md +++ b/problems/expression-add-operators/README.md @@ -46,6 +46,14 @@ Output: [] +

     

    +

    Constraints:

    + +
      +
    • 0 <= num.length <= 10
    • +
    • num only contain digits.
    • +
    + ### Related Topics [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] diff --git a/problems/final-prices-with-a-special-discount-in-a-shop/README.md b/problems/final-prices-with-a-special-discount-in-a-shop/README.md new file mode 100644 index 000000000..845ca88e6 --- /dev/null +++ b/problems/final-prices-with-a-special-discount-in-a-shop/README.md @@ -0,0 +1,61 @@ + + + + + + + +[< Previous](../delete-n-nodes-after-m-nodes-of-a-linked-list "Delete N Nodes After M Nodes of a Linked List") +                 +[Next >](../subrectangle-queries "Subrectangle Queries") + +## [1475. Final Prices With a Special Discount in a Shop (Easy)](https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop "商品折扣后的最终价格") + +

    Given the array prices where prices[i] is the price of the ith item in a shop. There is a special discount for items in the shop, if you buy the ith item, then you will receive a discount equivalent to prices[j] where j is the minimum index such that j > i and prices[j] <= prices[i], otherwise, you will not receive any discount at all.

    + +

    Return an array where the ith element is the final price you will pay for the ith item of the shop considering the special discount.

    + +

     

    +

    Example 1:

    + +
    +Input: prices = [8,4,6,2,3]
    +Output: [4,2,4,2,3]
    +Explanation: 
    +For item 0 with price[0]=8 you will receive a discount equivalent to prices[1]=4, therefore, the final price you will pay is 8 - 4 = 4. 
    +For item 1 with price[1]=4 you will receive a discount equivalent to prices[3]=2, therefore, the final price you will pay is 4 - 2 = 2. 
    +For item 2 with price[2]=6 you will receive a discount equivalent to prices[3]=2, therefore, the final price you will pay is 6 - 2 = 4. 
    +For items 3 and 4 you will not receive any discount at all.
    +
    + +

    Example 2:

    + +
    +Input: prices = [1,2,3,4,5]
    +Output: [1,2,3,4,5]
    +Explanation: In this case, for all items, you will not receive any discount at all.
    +
    + +

    Example 3:

    + +
    +Input: prices = [10,1,1,6]
    +Output: [9,0,1,6]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= prices.length <= 500
    • +
    • 1 <= prices[i] <= 10^3
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Use brute force: For the ith item in the shop with a loop find the first position j satisfying the conditions and apply the discount, otherwise, the discount is 0. +
    diff --git a/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md b/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md new file mode 100644 index 000000000..8c377e5f0 --- /dev/null +++ b/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../avoid-flood-in-the-city "Avoid Flood in The City") +                 +Next > + +## [1489. Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree (Hard)](https://leetcode.com/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree "找到最小生成树里的关键边和伪关键边") + +

    Given a weighted undirected connected graph with n vertices numbered from 0 to n-1, and an array edges where edges[i] = [fromi, toi, weighti] represents a bidirectional and weighted edge between nodes fromi and toi. A minimum spanning tree (MST) is a subset of the edges of the graph that connects all vertices without cycles and with the minimum possible total edge weight.

    + +

    Find all the critical and pseudo-critical edges in the minimum spanning tree (MST) of the given graph. An MST edge whose deletion from the graph would cause the MST weight to increase is called a critical edge. A pseudo-critical edge, on the other hand, is that which can appear in some MSTs but not all.

    + +

    Note that you can return the indices of the edges in any order.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: n = 5, edges = [[0,1,1],[1,2,1],[2,3,2],[0,3,2],[0,4,3],[3,4,3],[1,4,6]]
    +Output: [[0,1],[2,3,4,5]]
    +Explanation: The figure above describes the graph.
    +The following figure shows all the possible MSTs:
    +
    +Notice that the two edges 0 and 1 appear in all MSTs, therefore they are critical edges, so we return them in the first list of the output.
    +The edges 2, 3, 4, and 5 are only part of some MSTs, therefore they are considered pseudo-critical edges. We add them to the second list of the output.
    +
    + +

    Example 2:

    + +

    + +
    +Input: n = 4, edges = [[0,1,1],[1,2,1],[2,3,1],[0,3,1]]
    +Output: [[],[0,1,2,3]]
    +Explanation: We can observe that since all 4 edges have equal weight, choosing any 3 edges from the given 4 will yield an MST. Therefore all 4 edges are pseudo-critical.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 100
    • +
    • 1 <= edges.length <= min(200, n * (n - 1) / 2)
    • +
    • edges[i].length == 3
    • +
    • 0 <= fromi < toi < n
    • +
    • 1 <= weighti <= 1000
    • +
    • All pairs (fromi, toi) are distinct.
    • +
    + +### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + +### Hints +
    +Hint 1 +Use the Kruskal algorithm to find the minimum spanning tree by sorting the edges and picking edges from ones with smaller weights. +
    + +
    +Hint 2 +Use a disjoint set to avoid adding redundant edges that result in a cycle. +
    + +
    +Hint 3 +To find if one edge is critical, delete that edge and re-run the MST algorithm and see if the weight of the new MST increases. +
    + +
    +Hint 4 +To find if one edge is non-critical (in any MST), include that edge to the accepted edge list and continue the MST algorithm, then see if the resulting MST has the same weight of the initial MST of the entire graph. +
    diff --git a/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md b/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md new file mode 100644 index 000000000..b750a78c1 --- /dev/null +++ b/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../subrectangle-queries "Subrectangle Queries") +                 +[Next >](../allocate-mailboxes "Allocate Mailboxes") + +## [1477. Find Two Non-overlapping Sub-arrays Each With Target Sum (Medium)](https://leetcode.com/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum "找两个和为目标值且不重叠的子数组") + +

    Given an array of integers arr and an integer target.

    + +

    You have to find two non-overlapping sub-arrays of arr each with sum equal target. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is minimum.

    + +

    Return the minimum sum of the lengths of the two required sub-arrays, or return -1 if you cannot find such two sub-arrays.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [3,2,2,4,3], target = 3
    +Output: 2
    +Explanation: Only two sub-arrays have sum = 3 ([3] and [3]). The sum of their lengths is 2.
    +
    + +

    Example 2:

    + +
    +Input: arr = [7,3,4,7], target = 7
    +Output: 2
    +Explanation: Although we have three non-overlapping sub-arrays of sum = 7 ([7], [3,4] and [7]), but we will choose the first and third sub-arrays as the sum of their lengths is 2.
    +
    + +

    Example 3:

    + +
    +Input: arr = [4,3,2,6,2,3,4], target = 6
    +Output: -1
    +Explanation: We have only one sub-array of sum = 6.
    +
    + +

    Example 4:

    + +
    +Input: arr = [5,5,4,4,5], target = 3
    +Output: -1
    +Explanation: We cannot find a sub-array of sum = 3.
    +
    + +

    Example 5:

    + +
    +Input: arr = [3,1,1,1,5,1,2,1], target = 3
    +Output: 3
    +Explanation: Note that sub-arrays [1,2] and [2,1] cannot be an answer because they overlap.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 10^5
    • +
    • 1 <= arr[i] <= 1000
    • +
    • 1 <= target <= 10^8
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Let's create two arrays prefix and suffix where prefix[i] is the minimum length of sub-array ends before i and has sum = k, suffix[i] is the minimum length of sub-array starting at or after i and has sum = k. +
    + +
    +Hint 2 +The answer we are searching for is min(prefix[i] + suffix[i]) for all values of i from 0 to n-1 where n == arr.length. +
    + +
    +Hint 3 +If you are still stuck with how to build prefix and suffix, you can store for each index i the length of the sub-array starts at i and has sum = k or infinity otherwise, and you can use it to build both prefix and suffix. +
    diff --git a/problems/group-sold-products-by-the-date/README.md b/problems/group-sold-products-by-the-date/README.md new file mode 100644 index 000000000..356c986c4 --- /dev/null +++ b/problems/group-sold-products-by-the-date/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../kth-ancestor-of-a-tree-node "Kth Ancestor of a Tree Node") +                 +[Next >](../clone-binary-tree-with-random-pointer "Clone Binary Tree With Random Pointer") + +## [1484. Group Sold Products By The Date (Easy)](https://leetcode.com/problems/group-sold-products-by-the-date "") + + diff --git a/problems/group-sold-products-by-the-date/mysql_schemas.sql b/problems/group-sold-products-by-the-date/mysql_schemas.sql new file mode 100644 index 000000000..bf1f0a1b3 --- /dev/null +++ b/problems/group-sold-products-by-the-date/mysql_schemas.sql @@ -0,0 +1,9 @@ +Create table If Not Exists Activities (sell_date date, product varchar(20)); +Truncate table Activities; +insert into Activities (sell_date, product) values ('2020-05-30', 'Headphone'); +insert into Activities (sell_date, product) values ('2020-06-01', 'Pencil'); +insert into Activities (sell_date, product) values ('2020-06-02', 'Mask'); +insert into Activities (sell_date, product) values ('2020-05-30', 'Basketball'); +insert into Activities (sell_date, product) values ('2020-06-01', 'Bible'); +insert into Activities (sell_date, product) values ('2020-06-02', 'Mask'); +insert into Activities (sell_date, product) values ('2020-05-30', 'T-Shirt'); diff --git a/problems/increasing-subsequences/README.md b/problems/increasing-subsequences/README.md index 64b6c3668..37e0adff8 100644 --- a/problems/increasing-subsequences/README.md +++ b/problems/increasing-subsequences/README.md @@ -23,14 +23,13 @@

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • The length of the given array will not exceed 15.
      • The range of integer in the given array is [-100,100].
      • The given array may contain duplicates, and two equal integers should also be considered as a special case of increasing sequence.
      • -
    + ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/koko-eating-bananas/README.md b/problems/koko-eating-bananas/README.md index 92d7f7133..dcef83a39 100644 --- a/problems/koko-eating-bananas/README.md +++ b/problems/koko-eating-bananas/README.md @@ -20,46 +20,24 @@

    Return the minimum integer K such that she can eat all the bananas within H hours.

     

    - -
      -
    - -

    Example 1:

    - -
    -Input: piles = [3,6,7,11], H = 8
    -Output: 4
    +
    Input: piles = [3,6,7,11], H = 8
    +Output: 4
    +

    Example 2:

    +
    Input: piles = [30,11,23,4,20], H = 5
    +Output: 30
    +

    Example 3:

    +
    Input: piles = [30,11,23,4,20], H = 6
    +Output: 23
     
    - -
    -

    Example 2:

    - -
    -Input: piles = [30,11,23,4,20], H = 5
    -Output: 30
    -
    - -
    -

    Example 3:

    - -
    -Input: piles = [30,11,23,4,20], H = 6
    -Output: 23
    -
    -

     

    - -

    Note:

    +

    Constraints:

    • 1 <= piles.length <= 10^4
    • piles.length <= H <= 10^9
    • 1 <= piles[i] <= 10^9
    -
    -
    -
    ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/kth-ancestor-of-a-tree-node/README.md b/problems/kth-ancestor-of-a-tree-node/README.md new file mode 100644 index 000000000..5981636cb --- /dev/null +++ b/problems/kth-ancestor-of-a-tree-node/README.md @@ -0,0 +1,65 @@ + + + + + + + +[< Previous](../minimum-number-of-days-to-make-m-bouquets "Minimum Number of Days to Make m Bouquets") +                 +[Next >](../group-sold-products-by-the-date "Group Sold Products By The Date") + +## [1483. Kth Ancestor of a Tree Node (Hard)](https://leetcode.com/problems/kth-ancestor-of-a-tree-node "树节点的第 K 个祖先") + +

    You are given a tree with n nodes numbered from 0 to n-1 in the form of a parent array where parent[i] is the parent of node i. The root of the tree is node 0.

    + +

    Implement the function getKthAncestor(int node, int k) to return the k-th ancestor of the given node. If there is no such ancestor, return -1.

    + +

    The k-th ancestor of a tree node is the k-th node in the path from that node to the root.

    + +

     

    + +

    Example:

    + +

    + +
    +Input:
    +["TreeAncestor","getKthAncestor","getKthAncestor","getKthAncestor"]
    +[[7,[-1,0,0,1,1,2,2]],[3,1],[5,2],[6,3]]
    +
    +Output:
    +[null,1,0,-1]
    +
    +Explanation:
    +TreeAncestor treeAncestor = new TreeAncestor(7, [-1, 0, 0, 1, 1, 2, 2]);
    +
    +treeAncestor.getKthAncestor(3, 1);  // returns 1 which is the parent of 3
    +treeAncestor.getKthAncestor(5, 2);  // returns 0 which is the grandparent of 5
    +treeAncestor.getKthAncestor(6, 3);  // returns -1 because there is no such ancestor
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= n <= 5*10^4
    • +
    • parent[0] == -1 indicating that 0 is the root node.
    • +
    • 0 <= parent[i] < n for all 0 < i < n
    • +
    • 0 <= node < n
    • +
    • There will be at most 5*10^4 queries.
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +The queries must be answered efficiently to avoid time limit exceeded verdict. +
    + +
    +Hint 2 +Use sparse table (dynamic programming application) to travel the tree upwards in a fast way. +
    diff --git a/problems/least-number-of-unique-integers-after-k-removals/README.md b/problems/least-number-of-unique-integers-after-k-removals/README.md new file mode 100644 index 000000000..9a244fddf --- /dev/null +++ b/problems/least-number-of-unique-integers-after-k-removals/README.md @@ -0,0 +1,56 @@ + + + + + + + +[< Previous](../running-sum-of-1d-array "Running Sum of 1d Array") +                 +[Next >](../minimum-number-of-days-to-make-m-bouquets "Minimum Number of Days to Make m Bouquets") + +## [1481. Least Number of Unique Integers after K Removals (Medium)](https://leetcode.com/problems/least-number-of-unique-integers-after-k-removals "不同整数的最少数目") + +

    Given an array of integers arr and an integer k. Find the least number of unique integers after removing exactly k elements.

    + +
      +
    + +

     

    +

    Example 1:

    + +
    +Input: arr = [5,5,4], k = 1
    +Output: 1
    +Explanation: Remove the single 4, only 5 is left.
    +
    +Example 2: + +
    +Input: arr = [4,3,1,1,3,3,2], k = 3
    +Output: 2
    +Explanation: Remove 4, 2 and either one of the two 1s or three 3s. 1 and 3 will be left.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 10^5
    • +
    • 1 <= arr[i] <= 10^9
    • +
    • 0 <= k <= arr.length
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Use a map to count the frequencies of the numbers in the array. +
    + +
    +Hint 2 +An optimal strategy is to remove the numbers with the smallest count first. +
    diff --git a/problems/longest-palindromic-subsequence/README.md b/problems/longest-palindromic-subsequence/README.md index 9629d2933..267d342b3 100644 --- a/problems/longest-palindromic-subsequence/README.md +++ b/problems/longest-palindromic-subsequence/README.md @@ -11,33 +11,42 @@ ## [516. Longest Palindromic Subsequence (Medium)](https://leetcode.com/problems/longest-palindromic-subsequence "最长回文子序列") -

    -Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000. -

    +

    Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000.

    + +

    Example 1:
    +Input:

    -

    Example 1:
    -Input:

    -"bbbab"
    +"bbbab"
     
    -Output: +Output: +
     4
     
    -One possible longest palindromic subsequence is "bbbb". -

    +One possible longest palindromic subsequence is "bbbb". + +

     

    + +

    Example 2:
    +Input:

    -

    Example 2:
    -Input:

    -"cbbd"
    +"cbbd"
     
    Output: +
     2
     
    -One possible longest palindromic subsequence is "bb". -

    +One possible longest palindromic subsequence is "bb". +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 1000
    • +
    • s consists only of lowercase English letters.
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/making-file-names-unique/README.md b/problems/making-file-names-unique/README.md new file mode 100644 index 000000000..2e0f911f5 --- /dev/null +++ b/problems/making-file-names-unique/README.md @@ -0,0 +1,96 @@ + + + + + + + +[< Previous](../xor-operation-in-an-array "XOR Operation in an Array") +                 +[Next >](../avoid-flood-in-the-city "Avoid Flood in The City") + +## [1487. Making File Names Unique (Medium)](https://leetcode.com/problems/making-file-names-unique "保证文件名唯一") + +

    Given an array of strings names of size n. You will create n folders in your file system such that, at the ith minute, you will create a folder with the name names[i].

    + +

    Since two files cannot have the same name, if you enter a folder name which is previously used, the system will have a suffix addition to its name in the form of (k), where, k is the smallest positive integer such that the obtained name remains unique.

    + +

    Return an array of strings of length n where ans[i] is the actual name the system will assign to the ith folder when you create it.

    + +

     

    +

    Example 1:

    + +
    +Input: names = ["pes","fifa","gta","pes(2019)"]
    +Output: ["pes","fifa","gta","pes(2019)"]
    +Explanation: Let's see how the file system creates folder names:
    +"pes" --> not assigned before, remains "pes"
    +"fifa" --> not assigned before, remains "fifa"
    +"gta" --> not assigned before, remains "gta"
    +"pes(2019)" --> not assigned before, remains "pes(2019)"
    +
    + +

    Example 2:

    + +
    +Input: names = ["gta","gta(1)","gta","avalon"]
    +Output: ["gta","gta(1)","gta(2)","avalon"]
    +Explanation: Let's see how the file system creates folder names:
    +"gta" --> not assigned before, remains "gta"
    +"gta(1)" --> not assigned before, remains "gta(1)"
    +"gta" --> the name is reserved, system adds (k), since "gta(1)" is also reserved, systems put k = 2. it becomes "gta(2)"
    +"avalon" --> not assigned before, remains "avalon"
    +
    + +

    Example 3:

    + +
    +Input: names = ["onepiece","onepiece(1)","onepiece(2)","onepiece(3)","onepiece"]
    +Output: ["onepiece","onepiece(1)","onepiece(2)","onepiece(3)","onepiece(4)"]
    +Explanation: When the last folder is created, the smallest positive valid k is 4, and it becomes "onepiece(4)".
    +
    + +

    Example 4:

    + +
    +Input: names = ["wano","wano","wano","wano"]
    +Output: ["wano","wano(1)","wano(2)","wano(3)"]
    +Explanation: Just increase the value of k each time you create folder "wano".
    +
    + +

    Example 5:

    + +
    +Input: names = ["kaido","kaido(1)","kaido","kaido(1)"]
    +Output: ["kaido","kaido(1)","kaido(2)","kaido(1)(1)"]
    +Explanation: Please note that system adds the suffix (k) to current name even it contained the same suffix before.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= names.length <= 5 * 10^4
    • +
    • 1 <= names[i].length <= 20
    • +
    • names[i] consists of lower case English letters, digits and/or round brackets.
    • +
    + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Keep a map of each name and the smallest valid integer that can be appended as a suffix to it. +
    + +
    +Hint 2 +If the name is not present in the map, you can use it without adding any suffixes. +
    + +
    +Hint 3 +If the name is present in the map, append the smallest proper suffix, and add the new name to the map. +
    diff --git a/problems/maximum-binary-tree-ii/README.md b/problems/maximum-binary-tree-ii/README.md index cccc87c6a..66d804d37 100644 --- a/problems/maximum-binary-tree-ii/README.md +++ b/problems/maximum-binary-tree-ii/README.md @@ -30,7 +30,6 @@

    Return Construct(B).

     

    -

    Example 1:

    @@ -60,16 +59,15 @@ Output: [5,2,4,null,1,3] Explanation: A = [2,1,5,3], B = [2,1,5,3,4] - -

     

    -

    Note:

    +

     

    +

    Constraints:

    -
      +
      • 1 <= B.length <= 100
      • -
    + ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/minimum-falling-path-sum/README.md b/problems/minimum-falling-path-sum/README.md index 536824f88..2d1e6e612 100644 --- a/problems/minimum-falling-path-sum/README.md +++ b/problems/minimum-falling-path-sum/README.md @@ -35,13 +35,12 @@ The possible falling paths are:

    The falling path with the smallest sum is [1,4,7], so the answer is 12.

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= A.length == A[0].length <= 100
      • -100 <= A[i][j] <= 100
      • -
    + ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/minimum-number-of-days-to-make-m-bouquets/README.md b/problems/minimum-number-of-days-to-make-m-bouquets/README.md new file mode 100644 index 000000000..b1ebbe7e0 --- /dev/null +++ b/problems/minimum-number-of-days-to-make-m-bouquets/README.md @@ -0,0 +1,95 @@ + + + + + + + +[< Previous](../least-number-of-unique-integers-after-k-removals "Least Number of Unique Integers after K Removals") +                 +[Next >](../kth-ancestor-of-a-tree-node "Kth Ancestor of a Tree Node") + +## [1482. Minimum Number of Days to Make m Bouquets (Medium)](https://leetcode.com/problems/minimum-number-of-days-to-make-m-bouquets "制作 m 束花所需的最少天数") + +

    Given an integer array bloomDay, an integer m and an integer k.

    + +

    We need to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden.

    + +

    The garden consists of n flowers, the ith flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet.

    + +

    Return the minimum number of days you need to wait to be able to make m bouquets from the garden. If it is impossible to make m bouquets return -1.

    + +

     

    +

    Example 1:

    + +
    +Input: bloomDay = [1,10,3,10,2], m = 3, k = 1
    +Output: 3
    +Explanation: Let's see what happened in the first three days. x means flower bloomed and _ means flower didn't bloom in the garden.
    +We need 3 bouquets each should contain 1 flower.
    +After day 1: [x, _, _, _, _]   // we can only make one bouquet.
    +After day 2: [x, _, _, _, x]   // we can only make two bouquets.
    +After day 3: [x, _, x, _, x]   // we can make 3 bouquets. The answer is 3.
    +
    + +

    Example 2:

    + +
    +Input: bloomDay = [1,10,3,10,2], m = 3, k = 2
    +Output: -1
    +Explanation: We need 3 bouquets each has 2 flowers, that means we need 6 flowers. We only have 5 flowers so it is impossible to get the needed bouquets and we return -1.
    +
    + +

    Example 3:

    + +
    +Input: bloomDay = [7,7,7,7,12,7,7], m = 2, k = 3
    +Output: 12
    +Explanation: We need 2 bouquets each should have 3 flowers.
    +Here's the garden after the 7 and 12 days:
    +After day 7: [x, x, x, x, _, x, x]
    +We can make one bouquet of the first three flowers that bloomed. We cannot make another bouquet from the last three flowers that bloomed because they are not adjacent.
    +After day 12: [x, x, x, x, x, x, x]
    +It is obvious that we can make two bouquets in different ways.
    +
    + +

    Example 4:

    + +
    +Input: bloomDay = [1000000000,1000000000], m = 1, k = 1
    +Output: 1000000000
    +Explanation: You need to wait 1000000000 days to have a flower ready for a bouquet.
    +
    + +

    Example 5:

    + +
    +Input: bloomDay = [1,10,2,9,3,8,4,7,5,6], m = 4, k = 2
    +Output: 9
    +
    + +

     

    +

    Constraints:

    + +
      +
    • bloomDay.length == n
    • +
    • 1 <= n <= 10^5
    • +
    • 1 <= bloomDay[i] <= 10^9
    • +
    • 1 <= m <= 10^6
    • +
    • 1 <= k <= n
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +If we can make m or more bouquets at day x, then we can still make m or more bouquets at any day y > x. +
    + +
    +Hint 2 +We can check easily if we can make enough bouquets at day x if we can get group adjacent flowers at day x. +
    diff --git a/problems/paint-house-iii/README.md b/problems/paint-house-iii/README.md index 62d7469f9..6bc7167c3 100644 --- a/problems/paint-house-iii/README.md +++ b/problems/paint-house-iii/README.md @@ -7,7 +7,7 @@ [< Previous](../design-browser-history "Design Browser History")                  -Next > +[Next >](../delete-n-nodes-after-m-nodes-of-a-linked-list "Delete N Nodes After M Nodes of a Linked List") ## [1473. Paint House III (Hard)](https://leetcode.com/problems/paint-house-iii "给房子涂色 III") diff --git a/problems/partition-labels/README.md b/problems/partition-labels/README.md index 52a9a5fab..b635ead5e 100644 --- a/problems/partition-labels/README.md +++ b/problems/partition-labels/README.md @@ -11,25 +11,31 @@ ## [763. Partition Labels (Medium)](https://leetcode.com/problems/partition-labels "划分字母区间") -

    -A string S of lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing the size of these parts. -

    +

    A string S of lowercase English letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing the size of these parts.

    + +

     

    + +

    Example 1:

    -

    Example 1:

    -Input: S = "ababcbacadefegdehijhklij"
    +Input: S = "ababcbacadefegdehijhklij"
     Output: [9,7,8]
     Explanation:
    -The partition is "ababcbaca", "defegde", "hijhklij".
    +The partition is "ababcbaca", "defegde", "hijhklij".
     This is a partition so that each letter appears in at most one part.
    -A partition like "ababcbacadefegde", "hijhklij" is incorrect, because it splits S into less parts.
    +A partition like "ababcbacadefegde", "hijhklij" is incorrect, because it splits S into less parts.
     
    -

    -

    Note:

      -
    1. S will have length in range [1, 500].
    2. -
    3. S will consist of lowercase letters ('a' to 'z') only.
    4. -

    +

     

    + +

    Note:

    + +
      +
    • S will have length in range [1, 500].
    • +
    • S will consist of lowercase English letters ('a' to 'z') only.
    • +
    + +

     

    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/perform-string-shifts/README.md b/problems/perform-string-shifts/README.md index 3c25d222a..46b6ad61d 100644 --- a/problems/perform-string-shifts/README.md +++ b/problems/perform-string-shifts/README.md @@ -9,7 +9,7 @@                  [Next >](../leftmost-column-with-at-least-a-one "Leftmost Column with at Least a One") -## [1427. Perform String Shifts (Easy)](https://leetcode.com/problems/perform-string-shifts "") +## [1427. Perform String Shifts (Easy)](https://leetcode.com/problems/perform-string-shifts "字符串的左右移") diff --git a/problems/random-pick-with-weight/README.md b/problems/random-pick-with-weight/README.md index 0c9c0a786..79ff5c5bf 100644 --- a/problems/random-pick-with-weight/README.md +++ b/problems/random-pick-with-weight/README.md @@ -11,38 +11,60 @@ ## [528. Random Pick with Weight (Medium)](https://leetcode.com/problems/random-pick-with-weight "按权重随机选择") -

    Given an array w of positive integers, where w[i] describes the weight of index i, write a function pickIndex which randomly picks an index in proportion to its weight.

    +

    Given an array w of positive integers, where w[i] describes the weight of index i(0-indexed), write a function pickIndex which randomly picks an index in proportion to its weight.

    -

    Note:

    - -
      -
    1. 1 <= w.length <= 10000
    2. -
    3. 1 <= w[i] <= 10^5
    4. -
    5. pickIndex will be called at most 10000 times.
    6. -
    +

    For example, given an input list of values w = [2, 8], when we pick up a number out of it, the chance is that 8 times out of 10 we should pick the number 1 as the answer since it's the second element of the array (w[1] = 8).

    +

     

    Example 1:

    -Input: 
    -["Solution","pickIndex"]
    -[[[1]],[]]
    -Output: [null,0]
    +Input
    +["Solution","pickIndex"]
    +[[[1]],[]]
    +Output
    +[null,0]
    +
    +Explanation
    +Solution solution = new Solution([1]);
    +solution.pickIndex(); // return 0. Since there is only one single element on the array the only option is to return the first element.
     
    -

    Example 2:

    -Input: 
    -["Solution","pickIndex","pickIndex","pickIndex","pickIndex","pickIndex"]
    -[[[1,3]],[],[],[],[],[]]
    -Output: [null,0,1,1,1,0]
    -
    +Input +["Solution","pickIndex","pickIndex","pickIndex","pickIndex","pickIndex"] +[[[1,3]],[],[],[],[],[]] +Output +[null,1,1,1,1,0] -

    Explanation of Input Syntax:

    +Explanation +Solution solution = new Solution([1, 3]); +solution.pickIndex(); // return 1. It's returning the second element (index = 1) that has probability of 3/4. +solution.pickIndex(); // return 1 +solution.pickIndex(); // return 1 +solution.pickIndex(); // return 1 +solution.pickIndex(); // return 0. It's returning the first element (index = 0) that has probability of 1/4. -

    The input is two lists: the subroutines called and their arguments. Solution's constructor has one argument, the array w. pickIndex has no arguments. Arguments are always wrapped with a list, even if there aren't any.

    +Since this is a randomization problem, multiple answers are allowed so the following outputs can be considered correct : +[null,1,1,1,1,0] +[null,1,1,1,1,1] +[null,1,1,1,0,0] +[null,1,1,1,0,1] +[null,1,0,1,0,0] +...... +and so on. + + +

     

    +

    Constraints:

    + +
      +
    • 1 <= w.length <= 10000
    • +
    • 1 <= w[i] <= 10^5
    • +
    • pickIndex will be called at most 10000 times.
    • +
    ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/reconstruct-itinerary/README.md b/problems/reconstruct-itinerary/README.md index b7cfcce7f..5038676bc 100644 --- a/problems/reconstruct-itinerary/README.md +++ b/problems/reconstruct-itinerary/README.md @@ -19,6 +19,7 @@
  • If there are multiple valid itineraries, you should return the itinerary that has the smallest lexical order when read as a single string. For example, the itinerary ["JFK", "LGA"] has a smaller lexical order than ["JFK", "LGB"].
  • All airports are represented by three capital letters (IATA code).
  • You may assume all tickets form at least one valid itinerary.
  • +
  • One must use all the tickets once and only once.
  • Example 1:

    diff --git a/problems/running-sum-of-1d-array/README.md b/problems/running-sum-of-1d-array/README.md new file mode 100644 index 000000000..a0699df2a --- /dev/null +++ b/problems/running-sum-of-1d-array/README.md @@ -0,0 +1,55 @@ + + + + + + + +[< Previous](../sales-by-day-of-the-week "Sales by Day of the Week") +                 +[Next >](../least-number-of-unique-integers-after-k-removals "Least Number of Unique Integers after K Removals") + +## [1480. Running Sum of 1d Array (Easy)](https://leetcode.com/problems/running-sum-of-1d-array "一维数组的动态和") + +

    Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]).

    + +

    Return the running sum of nums.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3,4]
    +Output: [1,3,6,10]
    +Explanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4].
    + +

    Example 2:

    + +
    +Input: nums = [1,1,1,1,1]
    +Output: [1,2,3,4,5]
    +Explanation: Running sum is obtained as follows: [1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1].
    + +

    Example 3:

    + +
    +Input: nums = [3,1,2,10,1]
    +Output: [3,4,6,16,17]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • -10^6 <= nums[i] <= 10^6
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Think about how we can calculate the i-th number in the running sum from the (i-1)-th number. +
    diff --git a/problems/sales-by-day-of-the-week/README.md b/problems/sales-by-day-of-the-week/README.md new file mode 100644 index 000000000..6ee35a001 --- /dev/null +++ b/problems/sales-by-day-of-the-week/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../allocate-mailboxes "Allocate Mailboxes") +                 +[Next >](../running-sum-of-1d-array "Running Sum of 1d Array") + +## [1479. Sales by Day of the Week (Hard)](https://leetcode.com/problems/sales-by-day-of-the-week "") + + diff --git a/problems/sales-by-day-of-the-week/mysql_schemas.sql b/problems/sales-by-day-of-the-week/mysql_schemas.sql new file mode 100644 index 000000000..24328670f --- /dev/null +++ b/problems/sales-by-day-of-the-week/mysql_schemas.sql @@ -0,0 +1,19 @@ +Create table If Not Exists Orders (order_id int, customer_id int, order_date date, item_id varchar(30), quantity int); +Create table If Not Exists Items (item_id varchar(30), item_name varchar(30), item_category varchar(30)); +Truncate table Orders; +insert into Orders (order_id, customer_id, order_date, item_id, quantity) values ('1', '1', '2020-06-01', '1', '10'); +insert into Orders (order_id, customer_id, order_date, item_id, quantity) values ('2', '1', '2020-06-08', '2', '10'); +insert into Orders (order_id, customer_id, order_date, item_id, quantity) values ('3', '2', '2020-06-02', '1', '5'); +insert into Orders (order_id, customer_id, order_date, item_id, quantity) values ('4', '3', '2020-06-03', '3', '5'); +insert into Orders (order_id, customer_id, order_date, item_id, quantity) values ('5', '4', '2020-06-04', '4', '1'); +insert into Orders (order_id, customer_id, order_date, item_id, quantity) values ('6', '4', '2020-06-05', '5', '5'); +insert into Orders (order_id, customer_id, order_date, item_id, quantity) values ('7', '5', '2020-06-05', '1', '10'); +insert into Orders (order_id, customer_id, order_date, item_id, quantity) values ('8', '5', '2020-06-14', '4', '5'); +insert into Orders (order_id, customer_id, order_date, item_id, quantity) values ('9', '5', '2020-06-21', '3', '5'); +Truncate table Items; +insert into Items (item_id, item_name, item_category) values ('1', 'LC Alg. Book', 'Book'); +insert into Items (item_id, item_name, item_category) values ('2', 'LC DB. Book', 'Book'); +insert into Items (item_id, item_name, item_category) values ('3', 'LC SmarthPhone', 'Phone'); +insert into Items (item_id, item_name, item_category) values ('4', 'LC Phone 2020', 'Phone'); +insert into Items (item_id, item_name, item_category) values ('5', 'LC SmartGlass', 'Glasses'); +insert into Items (item_id, item_name, item_category) values ('6', 'LC T-Shirt XL', 'T-shirt'); diff --git a/problems/subrectangle-queries/README.md b/problems/subrectangle-queries/README.md new file mode 100644 index 000000000..0fcd080a7 --- /dev/null +++ b/problems/subrectangle-queries/README.md @@ -0,0 +1,103 @@ + + + + + + + +[< Previous](../final-prices-with-a-special-discount-in-a-shop "Final Prices With a Special Discount in a Shop") +                 +[Next >](../find-two-non-overlapping-sub-arrays-each-with-target-sum "Find Two Non-overlapping Sub-arrays Each With Target Sum") + +## [1476. Subrectangle Queries (Medium)](https://leetcode.com/problems/subrectangle-queries "子矩形查询") + +

    Implement the class SubrectangleQueries which receives a rows x cols rectangle as a matrix of integers in the constructor and supports two methods:

    + +

    1. updateSubrectangle(int row1, int col1, int row2, int col2, int newValue)

    + +
      +
    • Updates all values with newValue in the subrectangle whose upper left coordinate is (row1,col1) and bottom right coordinate is (row2,col2).
    • +
    + +

    2. getValue(int row, int col)

    + +
      +
    • Returns the current value of the coordinate (row,col) from the rectangle.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input
    +["SubrectangleQueries","getValue","updateSubrectangle","getValue","getValue","updateSubrectangle","getValue","getValue"]
    +[[[[1,2,1],[4,3,4],[3,2,1],[1,1,1]]],[0,2],[0,0,3,2,5],[0,2],[3,1],[3,0,3,2,10],[3,1],[0,2]]
    +Output
    +[null,1,null,5,5,null,10,5]
    +Explanation
    +SubrectangleQueries subrectangleQueries = new SubrectangleQueries([[1,2,1],[4,3,4],[3,2,1],[1,1,1]]);  
    +// The initial rectangle (4x3) looks like:
    +// 1 2 1
    +// 4 3 4
    +// 3 2 1
    +// 1 1 1
    +subrectangleQueries.getValue(0, 2); // return 1
    +subrectangleQueries.updateSubrectangle(0, 0, 3, 2, 5);
    +// After this update the rectangle looks like:
    +// 5 5 5
    +// 5 5 5
    +// 5 5 5
    +// 5 5 5 
    +subrectangleQueries.getValue(0, 2); // return 5
    +subrectangleQueries.getValue(3, 1); // return 5
    +subrectangleQueries.updateSubrectangle(3, 0, 3, 2, 10);
    +// After this update the rectangle looks like:
    +// 5   5   5
    +// 5   5   5
    +// 5   5   5
    +// 10  10  10 
    +subrectangleQueries.getValue(3, 1); // return 10
    +subrectangleQueries.getValue(0, 2); // return 5
    +
    + +

    Example 2:

    + +
    +Input
    +["SubrectangleQueries","getValue","updateSubrectangle","getValue","getValue","updateSubrectangle","getValue"]
    +[[[[1,1,1],[2,2,2],[3,3,3]]],[0,0],[0,0,2,2,100],[0,0],[2,2],[1,1,2,2,20],[2,2]]
    +Output
    +[null,1,null,100,100,null,20]
    +Explanation
    +SubrectangleQueries subrectangleQueries = new SubrectangleQueries([[1,1,1],[2,2,2],[3,3,3]]);
    +subrectangleQueries.getValue(0, 0); // return 1
    +subrectangleQueries.updateSubrectangle(0, 0, 2, 2, 100);
    +subrectangleQueries.getValue(0, 0); // return 100
    +subrectangleQueries.getValue(2, 2); // return 100
    +subrectangleQueries.updateSubrectangle(1, 1, 2, 2, 20);
    +subrectangleQueries.getValue(2, 2); // return 20
    +
    + +

     

    +

    Constraints:

    + +
      +
    • There will be at most 500 operations considering both methods: updateSubrectangle and getValue.
    • +
    • 1 <= rows, cols <= 100
    • +
    • rows == rectangle.length
    • +
    • cols == rectangle[i].length
    • +
    • 0 <= row1 <= row2 < rows
    • +
    • 0 <= col1 <= col2 < cols
    • +
    • 1 <= newValue, rectangle[i][j] <= 10^9
    • +
    • 0 <= row < rows
    • +
    • 0 <= col < cols
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Use brute force to update a rectangle and, response to the queries in O(1). +
    diff --git a/problems/target-sum/README.md b/problems/target-sum/README.md index 05d61081c..4f5398666 100644 --- a/problems/target-sum/README.md +++ b/problems/target-sum/README.md @@ -11,14 +11,12 @@ ## [494. Target Sum (Medium)](https://leetcode.com/problems/target-sum "目标和") -

    -You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol. -

    +

    You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol.

    -

    Find out how many ways to assign symbols to make sum of integers equal to target S. -

    +

    Find out how many ways to assign symbols to make sum of integers equal to target S.

    + +

    Example 1:

    -

    Example 1:

     Input: nums is [1, 1, 1, 1, 1], S is 3. 
     Output: 5
    @@ -32,15 +30,15 @@ You are given a list of non-negative integers, a1, a2, ..., an, and a target, S.
     
     There are 5 ways to assign symbols to make the sum of nums be target 3.
     
    -

    - -

    Note:
    -

      -
    1. The length of the given array is positive and will not exceed 20.
    2. -
    3. The sum of elements in the given array will not exceed 1000.
    4. -
    5. Your output answer is guaranteed to be fitted in a 32-bit integer.
    6. -
    -

    + +

     

    +

    Constraints:

    + +
      +
    • The length of the given array is positive and will not exceed 20.
    • +
    • The sum of elements in the given array will not exceed 1000.
    • +
    • Your output answer is guaranteed to be fitted in a 32-bit integer.
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/task-scheduler/README.md b/problems/task-scheduler/README.md index 4cfe52574..76579da8f 100644 --- a/problems/task-scheduler/README.md +++ b/problems/task-scheduler/README.md @@ -11,20 +11,41 @@ ## [621. Task Scheduler (Medium)](https://leetcode.com/problems/task-scheduler "任务调度器") -

    Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks. Tasks could be done without original order. Each task could be done in one interval. For each interval, CPU could finish one task or just be idle.

    +

    You are given a char array representing tasks CPU need to do. It contains capital letters A to Z where each letter represents a different task. Tasks could be done without the original order of the array. Each task is done in one unit of time. For each unit of time, the CPU could complete either one task or just be idle.

    -

    However, there is a non-negative cooling interval n that means between two same tasks, there must be at least n intervals that CPU are doing different tasks or just be idle.

    +

    However, there is a non-negative integer n that represents the cooldown period between two same tasks (the same letter in the array), that is that there must be at least n units of time between any two same tasks.

    -

    You need to return the least number of intervals the CPU will take to finish all the given tasks.

    +

    You need to return the least number of units of times that the CPU will take to finish all the given tasks.

     

    +

    Example 1:

    -

    Example:

    +
    +Input: tasks = ["A","A","A","B","B","B"], n = 2
    +Output: 8
    +Explanation: 
    +A -> B -> idle -> A -> B -> idle -> A -> B
    +There is at least 2 units of time between any two same tasks.
    +
    + +

    Example 2:

    + +
    +Input: tasks = ["A","A","A","B","B","B"], n = 0
    +Output: 6
    +Explanation: On this case any permutation of size 6 would work since n = 0.
    +["A","A","A","B","B","B"]
    +["A","B","A","B","A","B"]
    +["B","B","B","A","A","A"]
    +...
    +And so on.
    +
    + +

    Example 3:

    -Input: tasks = ["A","A","A","B","B","B"], n = 2
    -Output: 8
    -Explanation: A -> B -> idle -> A -> B -> idle -> A -> B.
    +Input: tasks = ["A","B","C","D","E","A","B","C","D","E"], n = 4
    +Output: 10
     

     

    diff --git a/problems/validate-ip-address/README.md b/problems/validate-ip-address/README.md index 2018673ba..109142b53 100644 --- a/problems/validate-ip-address/README.md +++ b/problems/validate-ip-address/README.md @@ -11,66 +11,49 @@ ## [468. Validate IP Address (Medium)](https://leetcode.com/problems/validate-ip-address "验证IP地址") -

    -Write a function to check whether an input string is a valid IPv4 address or IPv6 address or neither. -

    +

    Write a function to check whether an input string is a valid IPv4 address or IPv6 address or neither.

    -

    -IPv4 addresses are canonically represented in dot-decimal notation, which consists of four decimal numbers, each ranging from 0 to 255, separated by dots ("."), e.g.,172.16.254.1; -

    +

    IPv4 addresses are canonically represented in dot-decimal notation, which consists of four decimal numbers, each ranging from 0 to 255, separated by dots ("."), e.g.,172.16.254.1;

    -

    -Besides, leading zeros in the IPv4 is invalid. For example, the address 172.16.254.01 is invalid. -

    +

    Besides, leading zeros in the IPv4 is invalid. For example, the address 172.16.254.01 is invalid.

    -

    -IPv6 addresses are represented as eight groups of four hexadecimal digits, each group representing 16 bits. The groups are separated by colons (":"). For example, the address 2001:0db8:85a3:0000:0000:8a2e:0370:7334 is a valid one. Also, we could omit some leading zeros among four hexadecimal digits and some low-case characters in the address to upper-case ones, so 2001:db8:85a3:0:0:8A2E:0370:7334 is also a valid IPv6 address(Omit leading zeros and using upper cases). -

    +

    IPv6 addresses are represented as eight groups of four hexadecimal digits, each group representing 16 bits. The groups are separated by colons (":"). For example, the address 2001:0db8:85a3:0000:0000:8a2e:0370:7334 is a valid one. Also, we could omit some leading zeros among four hexadecimal digits and some low-case characters in the address to upper-case ones, so 2001:db8:85a3:0:0:8A2E:0370:7334 is also a valid IPv6 address(Omit leading zeros and using upper cases).

    +

    However, we don't replace a consecutive group of zero value with a single empty group using two consecutive colons (::) to pursue simplicity. For example, 2001:0db8:85a3::8A2E:0370:7334 is an invalid IPv6 address.

    -

    -However, we don't replace a consecutive group of zero value with a single empty group using two consecutive colons (::) to pursue simplicity. For example, 2001:0db8:85a3::8A2E:0370:7334 is an invalid IPv6 address. -

    +

    Besides, extra leading zeros in the IPv6 is also invalid. For example, the address 02001:0db8:85a3:0000:0000:8a2e:0370:7334 is invalid.

    -

    -Besides, extra leading zeros in the IPv6 is also invalid. For example, the address 02001:0db8:85a3:0000:0000:8a2e:0370:7334 is invalid. -

    +

     

    +

    Example 1:

    - -

    Note: -You may assume there is no extra space or special characters in the input string. -

    - -

    Example 1:

    -Input: "172.16.254.1"
    -
    -Output: "IPv4"
    -
    -Explanation: This is a valid IPv4 address, return "IPv4".
    +Input: IP = "172.16.254.1"
    +Output: "IPv4"
    +Explanation: This is a valid IPv4 address, return "IPv4".
     
    -

    +

    Example 2:

    -

    Example 2:

    -Input: "2001:0db8:85a3:0:0:8A2E:0370:7334"
    -
    -Output: "IPv6"
    -
    -Explanation: This is a valid IPv6 address, return "IPv6".
    +Input: IP = "2001:0db8:85a3:0:0:8A2E:0370:7334"
    +Output: "IPv6"
    +Explanation: This is a valid IPv6 address, return "IPv6".
     
    -

    -

    Example 3:
    +

    Example 3:

    +
    -Input: "256.256.256.256"
    +Input: IP = "256.256.256.256"
    +Output: "Neither"
    +Explanation: This is neither a IPv4 address nor a IPv6 address.
    +
    -Output: "Neither" +

     

    +

    Constraints:

    -Explanation: This is neither a IPv4 address nor a IPv6 address. - -

    +
      +
    • IP consists only of English letters, digits and the characters "." and ":".
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/xor-operation-in-an-array/README.md b/problems/xor-operation-in-an-array/README.md new file mode 100644 index 000000000..2385c4411 --- /dev/null +++ b/problems/xor-operation-in-an-array/README.md @@ -0,0 +1,68 @@ + + + + + + + +[< Previous](../clone-binary-tree-with-random-pointer "Clone Binary Tree With Random Pointer") +                 +[Next >](../making-file-names-unique "Making File Names Unique") + +## [1486. XOR Operation in an Array (Easy)](https://leetcode.com/problems/xor-operation-in-an-array "数组异或操作") + +

    Given an integer n and an integer start.

    + +

    Define an array nums where nums[i] = start + 2*i (0-indexed) and n == nums.length.

    + +

    Return the bitwise XOR of all elements of nums.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 5, start = 0
    +Output: 8
    +Explanation: Array nums is equal to [0, 2, 4, 6, 8] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8.
    +Where "^" corresponds to bitwise XOR operator.
    +
    + +

    Example 2:

    + +
    +Input: n = 4, start = 3
    +Output: 8
    +Explanation: Array nums is equal to [3, 5, 7, 9] where (3 ^ 5 ^ 7 ^ 9) = 8.
    + +

    Example 3:

    + +
    +Input: n = 1, start = 7
    +Output: 7
    +
    + +

    Example 4:

    + +
    +Input: n = 10, start = 5
    +Output: 2
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 1000
    • +
    • 0 <= start <= 1000
    • +
    • n == nums.length
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Simulate the process, create an array nums and return the Bitwise XOR of all elements of it. +
    diff --git a/tag/README.md b/tag/README.md index 3653effbd..3108a4597 100644 --- a/tag/README.md +++ b/tag/README.md @@ -16,7 +16,7 @@ | 9 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | | 11 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 12 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | | 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | -| 15 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | +| 15 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 16 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | | 19 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 20 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | | 21 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | | 22 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | diff --git a/tag/array/README.md b/tag/array/README.md index 9d8b5316e..be4e977b3 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,13 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1486 | [数组异或操作](../../problems/xor-operation-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | +| 1482 | [制作 m 束花所需的最少天数](../../problems/minimum-number-of-days-to-make-m-bouquets) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1481 | [不同整数的最少数目](../../problems/least-number-of-unique-integers-after-k-removals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1480 | [一维数组的动态和](../../problems/running-sum-of-1d-array) | [[数组](../array/README.md)] | Easy | +| 1476 | [子矩形查询](../../problems/subrectangle-queries) | [[数组](../array/README.md)] | Medium | +| 1475 | [商品折扣后的最终价格](../../problems/final-prices-with-a-special-discount-in-a-shop) | [[数组](../array/README.md)] | Easy | | 1471 | [数组中的 k 个最强值](../../problems/the-k-strongest-values-in-an-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1470 | [重新排列数组](../../problems/shuffle-the-array) | [[数组](../array/README.md)] | Easy | | 1465 | [切割后面积最大的蛋糕](../../problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts) | [[数组](../array/README.md)] | Medium | @@ -20,7 +27,7 @@ | 1437 | [是否所有 1 都至少相隔 k 个元素](../../problems/check-if-all-1s-are-at-least-length-k-places-away) | [[数组](../array/README.md)] | Medium | | 1431 | [拥有最多糖果的孩子](../../problems/kids-with-the-greatest-number-of-candies) | [[数组](../array/README.md)] | Easy | | 1428 | [至少有一个 1 的最左端列](../../problems/leftmost-column-with-at-least-a-one) 🔒 | [[数组](../array/README.md)] | Medium | -| 1427 | [Perform String Shifts](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1427 | [字符串的左右移](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1426 | [数元素](../../problems/counting-elements) 🔒 | [[数组](../array/README.md)] | Easy | | 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index d94a9fe77..507321fb8 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1482 | [制作 m 束花所需的最少天数](../../problems/minimum-number-of-days-to-make-m-bouquets) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 1337 | [方阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 88c883798..fece1bc71 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1486 | [数组异或操作](../../problems/xor-operation-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | | 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 9abe22563..40d0dbf04 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | +| 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1469 | [Find All The Lonely Nodes](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 1466 | [重新规划路线](../../problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 391ee6bb5..d87b39ed8 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1483 | [树节点的第 K 个祖先](../../problems/kth-ancestor-of-a-tree-node) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1477 | [找两个和为目标值且不重叠的子数组](../../problems/find-two-non-overlapping-sub-arrays-each-with-target-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1473 | [给房子涂色 III](../../problems/paint-house-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1463 | [摘樱桃 II](../../problems/cherry-pickup-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1458 | [两个子序列的最大点积](../../problems/max-dot-product-of-two-subsequences) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 7065347c2..692e1e2ef 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1429 | [First Unique Number](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1418 | [点菜展示表](../../problems/display-table-of-food-orders-in-a-restaurant) | [[哈希表](../hash-table/README.md)] | Medium | | 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index 2d5a361ce..f51d0b0c6 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1474 | [删除链表 M 个节点之后的 N 个节点](../../problems/delete-n-nodes-after-m-nodes-of-a-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Easy | | 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)] | Easy | | 1171 | [从链表中删去总和值为零的连续节点](../../problems/remove-zero-sum-consecutive-nodes-from-linked-list) | [[链表](../linked-list/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 9d967e5de..92f01a558 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,10 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] | Medium | | 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1427 | [Perform String Shifts](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1427 | [字符串的左右移](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1390 | [四因数](../../problems/four-divisors) | [[数学](../math/README.md)] | Medium | | 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1362 | [最接近的因数](../../problems/closest-divisors) | [[数学](../math/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index a5094a7e1..e462e2ee9 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1481 | [不同整数的最少数目](../../problems/least-number-of-unique-integers-after-k-removals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1471 | [数组中的 k 个最强值](../../problems/the-k-strongest-values-in-an-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | | 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index 50c3ffe5c..c7b01260a 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1455 | [检查单词是否为句中其他单词的前缀](../../problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | [[字符串](../string/README.md)] | Easy | diff --git a/tag/tags.json b/tag/tags.json index 8981e1c12..1f059d765 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -69,16 +69,16 @@ "Slug": "sort", "TranslatedName": "排序" }, - { - "Name": "Design", - "Slug": "design", - "TranslatedName": "设计" - }, { "Name": "Bit Manipulation", "Slug": "bit-manipulation", "TranslatedName": "位运算" }, + { + "Name": "Design", + "Slug": "design", + "TranslatedName": "设计" + }, { "Name": "Graph", "Slug": "graph", diff --git a/tag/tree/README.md b/tag/tree/README.md index 01ce441c7..63b06cfbc 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1469 | [Find All The Lonely Nodes](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 1466 | [重新规划路线](../../problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index 638ca37b7..abac1e797 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | | 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | | 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | From 1e18819c580ab07be5eebb8572199df1ff72a7d6 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 22 Jun 2020 10:14:45 +0800 Subject: [PATCH 071/145] U: go.yml --- .github/workflows/go.yml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index b66c0d719..94a0b682c 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -13,22 +13,21 @@ jobs: runs-on: ubuntu-latest steps: - - name: Set up Go 1.13 - uses: actions/setup-go@v1 - with: - go-version: 1.13 - id: go + - name: Setup Go environment + uses: actions/setup-go@v2 + run: go version - name: Check out code into the Go module directory uses: actions/checkout@v2 - name: Get dependencies - run: | - go get -v -t -d ./... - if [ -f Gopkg.toml ]; then - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh - dep ensure - fi + run: go get -v -t -d ./... - name: Build run: go build -v . + + - name: Test + run: go test -race -coverprofile=coverage.txt -covermode=atomic ./... + + - name: Codecov + uses: codecov/codecov-action@v1.0.7 From c601e956dc7e26d597f5046a9209bbd9ee8afa85 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 22 Jun 2020 10:18:18 +0800 Subject: [PATCH 072/145] U: go.yml --- .github/workflows/go.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 94a0b682c..342564bb2 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -15,6 +15,8 @@ jobs: - name: Setup Go environment uses: actions/setup-go@v2 + + - name: Go version run: go version - name: Check out code into the Go module directory From 8158269d5037282fb3ea6fa15ee42ee5b66b6752 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 22 Jun 2020 10:34:51 +0800 Subject: [PATCH 073/145] A: v1.6.4 --- README.md | 2 +- internal/readme/readme.go | 2 +- internal/version/version.go | 2 +- readme/1-300.md | 2 +- readme/301-600.md | 2 +- readme/601-900.md | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6e9fddc93..d08ccf641 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ LeetCode Problems' Solutions [[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] -[![Build Status](https://travis-ci.org/openset/leetcode.svg?branch=master)](https://travis-ci.org/openset/leetcode) +[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) [![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) [![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) [![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) diff --git a/internal/readme/readme.go b/internal/readme/readme.go index 5bdb27a00..477ff952f 100644 --- a/internal/readme/readme.go +++ b/internal/readme/readme.go @@ -15,7 +15,7 @@ const defaultStr = ` LeetCode Problems' Solutions [[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] -[![Build Status](https://travis-ci.org/openset/leetcode.svg?branch=master)](https://travis-ci.org/openset/leetcode) +[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) [![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) [![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) [![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) diff --git a/internal/version/version.go b/internal/version/version.go index 52e8aa506..4d6bf5511 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -8,7 +8,7 @@ import ( "github.com/openset/leetcode/internal/base" ) -const version = "1.6.3" +const version = "1.6.4" // CmdVersion - version.CmdVersion var CmdVersion = &base.Command{ diff --git a/readme/1-300.md b/readme/1-300.md index afacbba39..c989ede88 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -9,7 +9,7 @@ LeetCode Problems' Solutions [[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] -[![Build Status](https://travis-ci.org/openset/leetcode.svg?branch=master)](https://travis-ci.org/openset/leetcode) +[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) [![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) [![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) [![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) diff --git a/readme/301-600.md b/readme/301-600.md index 5d37d4931..af4578e6e 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -9,7 +9,7 @@ LeetCode Problems' Solutions [[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] -[![Build Status](https://travis-ci.org/openset/leetcode.svg?branch=master)](https://travis-ci.org/openset/leetcode) +[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) [![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) [![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) [![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) diff --git a/readme/601-900.md b/readme/601-900.md index 8e761e7fb..f36362a21 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -9,7 +9,7 @@ LeetCode Problems' Solutions [[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] -[![Build Status](https://travis-ci.org/openset/leetcode.svg?branch=master)](https://travis-ci.org/openset/leetcode) +[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) [![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) [![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) [![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) From 1518485d73ec4a25df106844278ff844bd53b868 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 22 Jun 2020 10:35:51 +0800 Subject: [PATCH 074/145] Update go.yml --- .github/workflows/go.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 342564bb2..202ee7bcf 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -16,9 +16,6 @@ jobs: - name: Setup Go environment uses: actions/setup-go@v2 - - name: Go version - run: go version - - name: Check out code into the Go module directory uses: actions/checkout@v2 @@ -32,4 +29,4 @@ jobs: run: go test -race -coverprofile=coverage.txt -covermode=atomic ./... - name: Codecov - uses: codecov/codecov-action@v1.0.7 + uses: codecov/codecov-action@v1 From 11d26c31f18be090b86ce3b2d5cf239a1046cf7f Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 22 Jun 2020 10:42:24 +0800 Subject: [PATCH 075/145] D: travis.yml --- .travis.yml | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 94bd3ad27..000000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: go - -go: - - "1.13.x" - -env: - - GO111MODULE=on - -before_install: - - go get -v ./... - -script: - - go test -race -coverprofile=coverage.txt -covermode=atomic ./... - -after_success: - - bash <(curl -s https://codecov.io/bash) From 2e9116761dc659df08a0687ac65873446529ea3b Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 24 Jun 2020 13:51:05 +0800 Subject: [PATCH 076/145] A: Check If a Word Occurs As a Prefix of Any Word in a Sentence --- ...s_as_a_prefix_of_any_word_in_a_sentence.go | 13 ++++++ ...a_prefix_of_any_word_in_a_sentence_test.go | 45 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/check_if_a_word_occurs_as_a_prefix_of_any_word_in_a_sentence.go create mode 100644 problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/check_if_a_word_occurs_as_a_prefix_of_any_word_in_a_sentence_test.go diff --git a/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/check_if_a_word_occurs_as_a_prefix_of_any_word_in_a_sentence.go b/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/check_if_a_word_occurs_as_a_prefix_of_any_word_in_a_sentence.go new file mode 100644 index 000000000..703b7c628 --- /dev/null +++ b/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/check_if_a_word_occurs_as_a_prefix_of_any_word_in_a_sentence.go @@ -0,0 +1,13 @@ +package problem1455 + +import "strings" + +func isPrefixOfWord(sentence string, searchWord string) int { + items := strings.Fields(sentence) + for i, item := range items { + if strings.HasPrefix(item, searchWord) { + return i + 1 + } + } + return -1 +} diff --git a/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/check_if_a_word_occurs_as_a_prefix_of_any_word_in_a_sentence_test.go b/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/check_if_a_word_occurs_as_a_prefix_of_any_word_in_a_sentence_test.go new file mode 100644 index 000000000..30813227d --- /dev/null +++ b/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/check_if_a_word_occurs_as_a_prefix_of_any_word_in_a_sentence_test.go @@ -0,0 +1,45 @@ +package problem1455 + +import "testing" + +type testType struct { + sentence string + searchWord string + want int +} + +func TestIsPrefixOfWord(t *testing.T) { + tests := [...]testType{ + { + sentence: "i love eating burger", + searchWord: "burg", + want: 4, + }, + { + sentence: "this problem is an easy problem", + searchWord: "pro", + want: 2, + }, + { + sentence: "i am tired", + searchWord: "you", + want: -1, + }, + { + sentence: "i use triple pillow", + searchWord: "pill", + want: 4, + }, + { + sentence: "hello from the other side", + searchWord: "they", + want: -1, + }, + } + for _, tt := range tests { + got := isPrefixOfWord(tt.sentence, tt.searchWord) + if got != tt.want { + t.Fatalf("in: %v, got: %v, want: %v", tt.sentence, got, tt.want) + } + } +} From 2e7c3c9a992123896067b2d753fb557a713268e5 Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 24 Jun 2020 14:32:25 +0800 Subject: [PATCH 077/145] A: cache --- .github/workflows/go.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 202ee7bcf..5401b72df 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -19,6 +19,8 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v2 + - uses: actions/cache@v2 + - name: Get dependencies run: go get -v -t -d ./... From a1c466f62b469e8e1ea2df06a88ab2ae58fd4466 Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 24 Jun 2020 14:37:19 +0800 Subject: [PATCH 078/145] A: Cache --- .github/workflows/go.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 5401b72df..22795bfc0 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -19,7 +19,11 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v2 - - uses: actions/cache@v2 + - name: Cache + uses: actions/cache@v2 + with: + path: ~/*/*/go-build/ + key: ${{ runner.os }}-go-build - name: Get dependencies run: go get -v -t -d ./... From 4fa9e0eb9e328660e54b393824f3e721a8c17a78 Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 24 Jun 2020 15:18:47 +0800 Subject: [PATCH 079/145] U: cache --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 22795bfc0..04594529b 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -22,7 +22,7 @@ jobs: - name: Cache uses: actions/cache@v2 with: - path: ~/*/*/go-build/ + path: ~/.cache/go-build/ key: ${{ runner.os }}-go-build - name: Get dependencies From 281b8fd6fe32604b5183bcd2b9c248a436c0ce39 Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 24 Jun 2020 16:40:44 +0800 Subject: [PATCH 080/145] D: Cache --- .github/workflows/go.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 04594529b..77fe0b084 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -19,18 +19,6 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v2 - - name: Cache - uses: actions/cache@v2 - with: - path: ~/.cache/go-build/ - key: ${{ runner.os }}-go-build - - - name: Get dependencies - run: go get -v -t -d ./... - - - name: Build - run: go build -v . - - name: Test run: go test -race -coverprofile=coverage.txt -covermode=atomic ./... From a0dbe9aed976e8a58c5f63b46decaf1d03fb7db0 Mon Sep 17 00:00:00 2001 From: Shuo Date: Sun, 28 Jun 2020 09:22:16 +0800 Subject: [PATCH 081/145] A: new --- README.md | 18 +++-- .../README.md | 69 ++++++++++++++++ problems/buddy-strings/README.md | 17 ++-- .../README.md | 2 +- problems/climbing-stairs/README.md | 9 ++- problems/clone-n-ary-tree/README.md | 31 +++++++ problems/create-a-session-bar-chart/README.md | 2 +- problems/excel-sheet-column-number/README.md | 8 ++ problems/find-all-the-lonely-nodes/README.md | 2 +- .../README.md | 2 +- .../README.md | 10 +++ .../README.md | 6 +- problems/first-unique-number/README.md | 2 +- .../README.md | 14 ++++ .../mysql_schemas.sql | 15 ++++ .../friends-of-appropriate-ages/README.md | 2 +- .../group-sold-products-by-the-date/README.md | 2 +- problems/insert-delete-getrandom-o1/README.md | 16 ++-- .../README.md | 2 +- .../README.md | 71 ++++++++++++++++ problems/maximum-binary-tree-ii/README.md | 14 ++-- problems/merge-sorted-array/README.md | 7 ++ problems/mirror-reflection/README.md | 3 +- problems/parallel-courses-ii/README.md | 74 +++++++++++++++++ problems/sales-by-day-of-the-week/README.md | 2 +- problems/task-scheduler/README.md | 7 +- problems/the-kth-factor-of-n/README.md | 80 +++++++++++++++++++ problems/valid-palindrome/README.md | 7 ++ tag/array/README.md | 2 + tag/breadth-first-search/README.md | 1 + tag/depth-first-search/README.md | 3 +- tag/design/README.md | 2 +- tag/graph/README.md | 1 + tag/hash-table/README.md | 3 +- tag/math/README.md | 1 + tag/sort/README.md | 1 + tag/tree/README.md | 5 +- 37 files changed, 460 insertions(+), 53 deletions(-) create mode 100644 problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md create mode 100644 problems/clone-n-ary-tree/README.md create mode 100644 problems/friendly-movies-streamed-last-month/README.md create mode 100644 problems/friendly-movies-streamed-last-month/mysql_schemas.sql create mode 100644 problems/longest-subarray-of-1s-after-deleting-one-element/README.md create mode 100644 problems/parallel-courses-ii/README.md create mode 100644 problems/the-kth-factor-of-n/README.md diff --git a/README.md b/README.md index d08ccf641..cf947c8b8 100644 --- a/README.md +++ b/README.md @@ -62,17 +62,23 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1495 | [Friendly Movies Streamed Last Month](https://leetcode.com/problems/friendly-movies-streamed-last-month) 🔒 | [MySQL](problems/friendly-movies-streamed-last-month) | Easy | +| 1494 | [Parallel Courses II](https://leetcode.com/problems/parallel-courses-ii "并行课程 II") | [Go](problems/parallel-courses-ii) | Hard | +| 1493 | [Longest Subarray of 1's After Deleting One Element](https://leetcode.com/problems/longest-subarray-of-1s-after-deleting-one-element "删掉一个元素以后全为 1 的最长子数组") | [Go](problems/longest-subarray-of-1s-after-deleting-one-element) | Medium | +| 1492 | [The kth Factor of n](https://leetcode.com/problems/the-kth-factor-of-n "n 的第 k 个因子") | [Go](problems/the-kth-factor-of-n) | Medium | +| 1491 | [Average Salary Excluding the Minimum and Maximum Salary](https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary "去掉最低工资和最高工资后的工资平均值") | [Go](problems/average-salary-excluding-the-minimum-and-maximum-salary) | Easy | +| 1490 | [Clone N-ary Tree](https://leetcode.com/problems/clone-n-ary-tree "克隆 N 叉树") 🔒 | [Go](problems/clone-n-ary-tree) | Medium | | 1489 | [Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree](https://leetcode.com/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree "找到最小生成树里的关键边和伪关键边") | [Go](problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | Hard | | 1488 | [Avoid Flood in The City](https://leetcode.com/problems/avoid-flood-in-the-city "避免洪水泛滥") | [Go](problems/avoid-flood-in-the-city) | Medium | | 1487 | [Making File Names Unique](https://leetcode.com/problems/making-file-names-unique "保证文件名唯一") | [Go](problems/making-file-names-unique) | Medium | | 1486 | [XOR Operation in an Array](https://leetcode.com/problems/xor-operation-in-an-array "数组异或操作") | [Go](problems/xor-operation-in-an-array) | Easy | | 1485 | [Clone Binary Tree With Random Pointer](https://leetcode.com/problems/clone-binary-tree-with-random-pointer "克隆含随机指针的二叉树") 🔒 | [Go](problems/clone-binary-tree-with-random-pointer) | Medium | -| 1484 | [Group Sold Products By The Date](https://leetcode.com/problems/group-sold-products-by-the-date) 🔒 | [MySQL](problems/group-sold-products-by-the-date) | Easy | +| 1484 | [Group Sold Products By The Date](https://leetcode.com/problems/group-sold-products-by-the-date "按日期分组销售产品") 🔒 | [MySQL](problems/group-sold-products-by-the-date) | Easy | | 1483 | [Kth Ancestor of a Tree Node](https://leetcode.com/problems/kth-ancestor-of-a-tree-node "树节点的第 K 个祖先") | [Go](problems/kth-ancestor-of-a-tree-node) | Hard | | 1482 | [Minimum Number of Days to Make m Bouquets](https://leetcode.com/problems/minimum-number-of-days-to-make-m-bouquets "制作 m 束花所需的最少天数") | [Go](problems/minimum-number-of-days-to-make-m-bouquets) | Medium | | 1481 | [Least Number of Unique Integers after K Removals](https://leetcode.com/problems/least-number-of-unique-integers-after-k-removals "不同整数的最少数目") | [Go](problems/least-number-of-unique-integers-after-k-removals) | Medium | | 1480 | [Running Sum of 1d Array](https://leetcode.com/problems/running-sum-of-1d-array "一维数组的动态和") | [Go](problems/running-sum-of-1d-array) | Easy | -| 1479 | [Sales by Day of the Week](https://leetcode.com/problems/sales-by-day-of-the-week) 🔒 | [MySQL](problems/sales-by-day-of-the-week) | Hard | +| 1479 | [Sales by Day of the Week](https://leetcode.com/problems/sales-by-day-of-the-week "周内每天的销售情况") 🔒 | [MySQL](problems/sales-by-day-of-the-week) | Hard | | 1478 | [Allocate Mailboxes](https://leetcode.com/problems/allocate-mailboxes "安排邮筒") | [Go](problems/allocate-mailboxes) | Hard | | 1477 | [Find Two Non-overlapping Sub-arrays Each With Target Sum](https://leetcode.com/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum "找两个和为目标值且不重叠的子数组") | [Go](problems/find-two-non-overlapping-sub-arrays-each-with-target-sum) | Medium | | 1476 | [Subrectangle Queries](https://leetcode.com/problems/subrectangle-queries "子矩形查询") | [Go](problems/subrectangle-queries) | Medium | @@ -82,7 +88,7 @@ LeetCode Problems' Solutions | 1472 | [Design Browser History](https://leetcode.com/problems/design-browser-history "设计浏览器历史记录") | [Go](problems/design-browser-history) | Medium | | 1471 | [The k Strongest Values in an Array](https://leetcode.com/problems/the-k-strongest-values-in-an-array "数组中的 k 个最强值") | [Go](problems/the-k-strongest-values-in-an-array) | Medium | | 1470 | [Shuffle the Array](https://leetcode.com/problems/shuffle-the-array "重新排列数组") | [Go](problems/shuffle-the-array) | Easy | -| 1469 | [Find All The Lonely Nodes](https://leetcode.com/problems/find-all-the-lonely-nodes) 🔒 | [Go](problems/find-all-the-lonely-nodes) | Easy | +| 1469 | [Find All The Lonely Nodes](https://leetcode.com/problems/find-all-the-lonely-nodes "寻找所有的独生节点") 🔒 | [Go](problems/find-all-the-lonely-nodes) | Easy | | 1468 | [Calculate Salaries](https://leetcode.com/problems/calculate-salaries "计算税后工资") 🔒 | [MySQL](problems/calculate-salaries) | Medium | | 1467 | [Probability of a Two Boxes Having The Same Number of Distinct Balls](https://leetcode.com/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "两个盒子中球的颜色数相同的概率") | [Go](problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | Hard | | 1466 | [Reorder Routes to Make All Paths Lead to the City Zero](https://leetcode.com/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero "重新规划路线") | [Go](problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | Medium | @@ -116,13 +122,13 @@ LeetCode Problems' Solutions | 1438 | [Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit](https://leetcode.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "绝对差不超过限制的最长连续子数组") | [Go](problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | Medium | | 1437 | [Check If All 1's Are at Least Length K Places Away](https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away "是否所有 1 都至少相隔 k 个元素") | [Go](problems/check-if-all-1s-are-at-least-length-k-places-away) | Medium | | 1436 | [Destination City](https://leetcode.com/problems/destination-city "旅行终点站") | [Go](problems/destination-city) | Easy | -| 1435 | [Create a Session Bar Chart](https://leetcode.com/problems/create-a-session-bar-chart) 🔒 | [MySQL](problems/create-a-session-bar-chart) | Easy | +| 1435 | [Create a Session Bar Chart](https://leetcode.com/problems/create-a-session-bar-chart "制作会话柱状图") 🔒 | [MySQL](problems/create-a-session-bar-chart) | Easy | | 1434 | [Number of Ways to Wear Different Hats to Each Other](https://leetcode.com/problems/number-of-ways-to-wear-different-hats-to-each-other "每个人戴不同帽子的方案数") | [Go](problems/number-of-ways-to-wear-different-hats-to-each-other) | Hard | | 1433 | [Check If a String Can Break Another String](https://leetcode.com/problems/check-if-a-string-can-break-another-string "检查一个字符串是否可以打破另一个字符串") | [Go](problems/check-if-a-string-can-break-another-string) | Medium | | 1432 | [Max Difference You Can Get From Changing an Integer](https://leetcode.com/problems/max-difference-you-can-get-from-changing-an-integer "改变一个整数能得到的最大差值") | [Go](problems/max-difference-you-can-get-from-changing-an-integer) | Medium | | 1431 | [Kids With the Greatest Number of Candies](https://leetcode.com/problems/kids-with-the-greatest-number-of-candies "拥有最多糖果的孩子") | [Go](problems/kids-with-the-greatest-number-of-candies) | Easy | -| 1430 | [Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree](https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [Go](problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) | Medium | -| 1429 | [First Unique Number](https://leetcode.com/problems/first-unique-number) 🔒 | [Go](problems/first-unique-number) | Medium | +| 1430 | [Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree](https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree "判断给定的序列是否是二叉树从根到叶的路径") 🔒 | [Go](problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) | Medium | +| 1429 | [First Unique Number](https://leetcode.com/problems/first-unique-number "第一个唯一数字") 🔒 | [Go](problems/first-unique-number) | Medium | | 1428 | [Leftmost Column with at Least a One](https://leetcode.com/problems/leftmost-column-with-at-least-a-one "至少有一个 1 的最左端列") 🔒 | [Go](problems/leftmost-column-with-at-least-a-one) | Medium | | 1427 | [Perform String Shifts](https://leetcode.com/problems/perform-string-shifts "字符串的左右移") 🔒 | [Go](problems/perform-string-shifts) | Easy | | 1426 | [Counting Elements](https://leetcode.com/problems/counting-elements "数元素") 🔒 | [Go](problems/counting-elements) | Easy | diff --git a/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md b/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md new file mode 100644 index 000000000..7315b3fe6 --- /dev/null +++ b/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../clone-n-ary-tree "Clone N-ary Tree") +                 +[Next >](../the-kth-factor-of-n "The kth Factor of n") + +## [1491. Average Salary Excluding the Minimum and Maximum Salary (Easy)](https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary "去掉最低工资和最高工资后的工资平均值") + +

    Given an array of unique integers salary where salary[i] is the salary of the employee i.

    + +

    Return the average salary of employees excluding the minimum and maximum salary.

    + +

     

    +

    Example 1:

    + +
    +Input: salary = [4000,3000,1000,2000]
    +Output: 2500.00000
    +Explanation: Minimum salary and maximum salary are 1000 and 4000 respectively.
    +Average salary excluding minimum and maximum salary is (2000+3000)/2= 2500
    +
    + +

    Example 2:

    + +
    +Input: salary = [1000,2000,3000]
    +Output: 2000.00000
    +Explanation: Minimum salary and maximum salary are 1000 and 3000 respectively.
    +Average salary excluding minimum and maximum salary is (2000)/1= 2000
    +
    + +

    Example 3:

    + +
    +Input: salary = [6000,5000,4000,3000,2000,1000]
    +Output: 3500.00000
    +
    + +

    Example 4:

    + +
    +Input: salary = [8000,9000,2000,3000,6000,1000]
    +Output: 4750.00000
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= salary.length <= 100
    • +
    • 10^3 <= salary[i] <= 10^6
    • +
    • salary[i] is unique.
    • +
    • Answers within 10^-5 of the actual value will be accepted as correct.
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Get the total sum and subtract the minimum and maximum value in the array. Finally divide the result by n - 2. +
    diff --git a/problems/buddy-strings/README.md b/problems/buddy-strings/README.md index d2b799aeb..1318d2968 100644 --- a/problems/buddy-strings/README.md +++ b/problems/buddy-strings/README.md @@ -54,21 +54,20 @@ Input: A = "", B = "aa" Output: false + + + + +

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 0 <= A.length <= 20000
      • 0 <= B.length <= 20000
      • A and B consist only of lowercase letters.
      • -
    - - - - - + ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/README.md b/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/README.md index 324291e90..68a6243c9 100644 --- a/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/README.md +++ b/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/README.md @@ -9,7 +9,7 @@                  [Next >](../kids-with-the-greatest-number-of-candies "Kids With the Greatest Number of Candies") -## [1430. Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree (Medium)](https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree "") +## [1430. Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree (Medium)](https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree "判断给定的序列是否是二叉树从根到叶的路径") diff --git a/problems/climbing-stairs/README.md b/problems/climbing-stairs/README.md index d75cf3aa3..1058f7503 100644 --- a/problems/climbing-stairs/README.md +++ b/problems/climbing-stairs/README.md @@ -15,8 +15,6 @@

    Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?

    -

    Note: Given n will be a positive integer.

    -

    Example 1:

    @@ -38,6 +36,13 @@
     3. 2 steps + 1 step
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 45
    • +
    + ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/clone-n-ary-tree/README.md b/problems/clone-n-ary-tree/README.md new file mode 100644 index 000000000..35df14008 --- /dev/null +++ b/problems/clone-n-ary-tree/README.md @@ -0,0 +1,31 @@ + + + + + + + +[< Previous](../find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree "Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree") +                 +[Next >](../average-salary-excluding-the-minimum-and-maximum-salary "Average Salary Excluding the Minimum and Maximum Salary") + +## [1490. Clone N-ary Tree (Medium)](https://leetcode.com/problems/clone-n-ary-tree "克隆 N 叉树") + + + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +Traverse the tree, keep a hashtable with you and create a clone node for each node in the tree. +
    + +
    +Hint 2 +Start traversing the original tree again and connect each child pointer in the cloned tree the same way as the original tree with the help of the hashtable. +
    diff --git a/problems/create-a-session-bar-chart/README.md b/problems/create-a-session-bar-chart/README.md index 5f135a792..c47d9fbcd 100644 --- a/problems/create-a-session-bar-chart/README.md +++ b/problems/create-a-session-bar-chart/README.md @@ -9,6 +9,6 @@                  [Next >](../destination-city "Destination City") -## [1435. Create a Session Bar Chart (Easy)](https://leetcode.com/problems/create-a-session-bar-chart "") +## [1435. Create a Session Bar Chart (Easy)](https://leetcode.com/problems/create-a-session-bar-chart "制作会话柱状图") diff --git a/problems/excel-sheet-column-number/README.md b/problems/excel-sheet-column-number/README.md index f89b0a019..cc8d7ae28 100644 --- a/problems/excel-sheet-column-number/README.md +++ b/problems/excel-sheet-column-number/README.md @@ -46,6 +46,14 @@ Input: "ZY" Output: 701 +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 7
    • +
    • s consists only of uppercase English letters.
    • +
    • s is between "A" and "FXSHRXW".
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/find-all-the-lonely-nodes/README.md b/problems/find-all-the-lonely-nodes/README.md index a19d1ff54..5739fd8b6 100644 --- a/problems/find-all-the-lonely-nodes/README.md +++ b/problems/find-all-the-lonely-nodes/README.md @@ -9,7 +9,7 @@                  [Next >](../shuffle-the-array "Shuffle the Array") -## [1469. Find All The Lonely Nodes (Easy)](https://leetcode.com/problems/find-all-the-lonely-nodes "") +## [1469. Find All The Lonely Nodes (Easy)](https://leetcode.com/problems/find-all-the-lonely-nodes "寻找所有的独生节点") diff --git a/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md b/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md index 8c377e5f0..3d12015d3 100644 --- a/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md +++ b/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md @@ -7,7 +7,7 @@ [< Previous](../avoid-flood-in-the-city "Avoid Flood in The City")                  -Next > +[Next >](../clone-n-ary-tree "Clone N-ary Tree") ## [1489. Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree (Hard)](https://leetcode.com/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree "找到最小生成树里的关键边和伪关键边") diff --git a/problems/find-first-and-last-position-of-element-in-sorted-array/README.md b/problems/find-first-and-last-position-of-element-in-sorted-array/README.md index 0ea7457d6..5e959983d 100644 --- a/problems/find-first-and-last-position-of-element-in-sorted-array/README.md +++ b/problems/find-first-and-last-position-of-element-in-sorted-array/README.md @@ -29,6 +29,16 @@ Input: nums = [5,7,7,8,8,10], target = 6 Output: [-1,-1] +

     

    +

    Constraints:

    + +
      +
    • 0 <= nums.length <= 10^5
    • +
    • -10^9 <= nums[i] <= 10^9
    • +
    • nums is a non decreasing array.
    • +
    • -10^9 <= target <= 10^9
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/first-unique-character-in-a-string/README.md b/problems/first-unique-character-in-a-string/README.md index da979307d..8d1f01059 100644 --- a/problems/first-unique-character-in-a-string/README.md +++ b/problems/first-unique-character-in-a-string/README.md @@ -11,7 +11,7 @@ ## [387. First Unique Character in a String (Easy)](https://leetcode.com/problems/first-unique-character-in-a-string "字符串中的第一个唯一字符") -

    Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.

    +

    Given a string, find the first non-repeating character in it and return its index. If it doesn't exist, return -1.

    Examples:

    @@ -19,13 +19,13 @@ s = "leetcode" return 0. -s = "loveleetcode", +s = "loveleetcode" return 2.

     

    -

    Note: You may assume the string contain only lowercase English letters.

    +

    Note: You may assume the string contains only lowercase English letters.

    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/first-unique-number/README.md b/problems/first-unique-number/README.md index e41636f56..2f0e27ccc 100644 --- a/problems/first-unique-number/README.md +++ b/problems/first-unique-number/README.md @@ -9,7 +9,7 @@                  [Next >](../check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree "Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree") -## [1429. First Unique Number (Medium)](https://leetcode.com/problems/first-unique-number "") +## [1429. First Unique Number (Medium)](https://leetcode.com/problems/first-unique-number "第一个唯一数字") diff --git a/problems/friendly-movies-streamed-last-month/README.md b/problems/friendly-movies-streamed-last-month/README.md new file mode 100644 index 000000000..e1910169c --- /dev/null +++ b/problems/friendly-movies-streamed-last-month/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../parallel-courses-ii "Parallel Courses II") +                 +Next > + +## [1495. Friendly Movies Streamed Last Month (Easy)](https://leetcode.com/problems/friendly-movies-streamed-last-month "") + + diff --git a/problems/friendly-movies-streamed-last-month/mysql_schemas.sql b/problems/friendly-movies-streamed-last-month/mysql_schemas.sql new file mode 100644 index 000000000..44becd868 --- /dev/null +++ b/problems/friendly-movies-streamed-last-month/mysql_schemas.sql @@ -0,0 +1,15 @@ +Create table If Not Exists TVProgram (program_date date, content_id int, channel varchar(30)); +Create table If Not Exists Content (content_id varchar(30), title varchar(30), Kids_content ENUM('Y', 'N'), content_type varchar(30)); +Truncate table TVProgram; +insert into TVProgram (program_date, content_id, channel) values ('2020-06-10 08:00', '1', 'LC-Channel'); +insert into TVProgram (program_date, content_id, channel) values ('2020-05-11 12:00', '2', 'LC-Channel'); +insert into TVProgram (program_date, content_id, channel) values ('2020-05-12 12:00', '3', 'LC-Channel'); +insert into TVProgram (program_date, content_id, channel) values ('2020-05-13 14:00', '4', 'Disney Ch'); +insert into TVProgram (program_date, content_id, channel) values ('2020-06-18 14:00', '4', 'Disney Ch'); +insert into TVProgram (program_date, content_id, channel) values ('2020-07-15 16:00', '5', 'Disney Ch'); +Truncate table Content; +insert into Content (content_id, title, Kids_content, content_type) values ('1', 'Leetcode Movie', 'N', 'Movies'); +insert into Content (content_id, title, Kids_content, content_type) values ('2', 'Alg. for Kids', 'Y', 'Series'); +insert into Content (content_id, title, Kids_content, content_type) values ('3', 'Database Sols', 'N', 'Series'); +insert into Content (content_id, title, Kids_content, content_type) values ('4', 'Aladdin', 'Y', 'Movies'); +insert into Content (content_id, title, Kids_content, content_type) values ('5', 'Cinderella', 'Y', 'Movies'); diff --git a/problems/friends-of-appropriate-ages/README.md b/problems/friends-of-appropriate-ages/README.md index bb701da97..477679d99 100644 --- a/problems/friends-of-appropriate-ages/README.md +++ b/problems/friends-of-appropriate-ages/README.md @@ -46,7 +46,7 @@
     Input: [20,30,100,110,120]
    -Output: 
    +Output: 3
     Explanation: Friend requests are made 110 -> 100, 120 -> 110, 120 -> 100.
     
    diff --git a/problems/group-sold-products-by-the-date/README.md b/problems/group-sold-products-by-the-date/README.md index 356c986c4..27d8ca750 100644 --- a/problems/group-sold-products-by-the-date/README.md +++ b/problems/group-sold-products-by-the-date/README.md @@ -9,6 +9,6 @@                  [Next >](../clone-binary-tree-with-random-pointer "Clone Binary Tree With Random Pointer") -## [1484. Group Sold Products By The Date (Easy)](https://leetcode.com/problems/group-sold-products-by-the-date "") +## [1484. Group Sold Products By The Date (Easy)](https://leetcode.com/problems/group-sold-products-by-the-date "按日期分组销售产品") diff --git a/problems/insert-delete-getrandom-o1/README.md b/problems/insert-delete-getrandom-o1/README.md index 3ce5e63e9..5013ff5f9 100644 --- a/problems/insert-delete-getrandom-o1/README.md +++ b/problems/insert-delete-getrandom-o1/README.md @@ -13,15 +13,18 @@

    Design a data structure that supports all following operations in average O(1) time.

    -

    +

     

    +
      -
    1. insert(val): Inserts an item val to the set if not already present.
    2. -
    3. remove(val): Removes an item val from the set if present.
    4. -
    5. getRandom: Returns a random element from current set of elements. Each element must have the same probability of being returned.
    6. +
    7. insert(val): Inserts an item val to the set if not already present.
    8. +
    9. remove(val): Removes an item val from the set if present.
    10. +
    11. getRandom: Returns a random element from current set of elements (it's guaranteed that at least one element exists when this method is called). Each element must have the same probability of being returned.
    -

    -

    Example: +

     

    + +

    Example:

    +
     // Init an empty set.
     RandomizedSet randomSet = new RandomizedSet();
    @@ -47,7 +50,6 @@ randomSet.insert(2);
     // Since 2 is the only number in the set, getRandom always return 2.
     randomSet.getRandom();
     
    -

    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/letter-combinations-of-a-phone-number/README.md b/problems/letter-combinations-of-a-phone-number/README.md index 3ab05823e..91aa19186 100644 --- a/problems/letter-combinations-of-a-phone-number/README.md +++ b/problems/letter-combinations-of-a-phone-number/README.md @@ -15,7 +15,7 @@

    A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.

    -

    +

    Example:

    diff --git a/problems/longest-subarray-of-1s-after-deleting-one-element/README.md b/problems/longest-subarray-of-1s-after-deleting-one-element/README.md new file mode 100644 index 000000000..ea9f442f5 --- /dev/null +++ b/problems/longest-subarray-of-1s-after-deleting-one-element/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../the-kth-factor-of-n "The kth Factor of n") +                 +[Next >](../parallel-courses-ii "Parallel Courses II") + +## [1493. Longest Subarray of 1's After Deleting One Element (Medium)](https://leetcode.com/problems/longest-subarray-of-1s-after-deleting-one-element "删掉一个元素以后全为 1 的最长子数组") + +

    Given a binary array nums, you should delete one element from it.

    + +

    Return the size of the longest non-empty subarray containing only 1's in the resulting array.

    + +

    Return 0 if there is no such subarray.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,1,0,1]
    +Output: 3
    +Explanation: After deleting the number in position 2, [1,1,1] contains 3 numbers with value of 1's.
    + +

    Example 2:

    + +
    +Input: nums = [0,1,1,1,0,1,1,0,1]
    +Output: 5
    +Explanation: After deleting the number in position 4, [0,1,1,1,1,1,0,1] longest subarray with value of 1's is [1,1,1,1,1].
    + +

    Example 3:

    + +
    +Input: nums = [1,1,1]
    +Output: 2
    +Explanation: You must delete one element.
    + +

    Example 4:

    + +
    +Input: nums = [1,1,0,0,1,1,1,0,1]
    +Output: 4
    +
    + +

    Example 5:

    + +
    +Input: nums = [0,0,0]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 10^5
    • +
    • nums[i] is either 0 or 1.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Maintain a sliding window where there is at most one zero on it. +
    diff --git a/problems/maximum-binary-tree-ii/README.md b/problems/maximum-binary-tree-ii/README.md index 66d804d37..0f0d7833d 100644 --- a/problems/maximum-binary-tree-ii/README.md +++ b/problems/maximum-binary-tree-ii/README.md @@ -40,9 +40,9 @@ Explanation: A = [1,4,2,3], B = [1,4,2,3,5] -
    -

    Example 2:
    -

    +

    Example 2:

    + +

     Input: root = [5,2,4,null,1], val = 3
    @@ -50,17 +50,15 @@
     Explanation: A = [2,1,5,4], B = [2,1,5,4,3]
     
    -
    -

    Example 3:
    -

    +

    Example 3:

    + +

     Input: root = [5,2,3,null,1], val = 4
     Output: [5,2,4,null,1,3]
     Explanation: A = [2,1,5,3], B = [2,1,5,3,4]
     
    -
    -

     

    Constraints:

    diff --git a/problems/merge-sorted-array/README.md b/problems/merge-sorted-array/README.md index 3acd0e9bf..1f8a02bb0 100644 --- a/problems/merge-sorted-array/README.md +++ b/problems/merge-sorted-array/README.md @@ -30,6 +30,13 @@ nums2 = [2,5,6], n = 3 Output: [1,2,2,3,5,6] +

     

    +

    Constraints:

    + +
      +
    • -10^9 <= nums1[i], nums2[i] <= 10^9
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/mirror-reflection/README.md b/problems/mirror-reflection/README.md index 69343a8cb..25adeb8d7 100644 --- a/problems/mirror-reflection/README.md +++ b/problems/mirror-reflection/README.md @@ -26,10 +26,9 @@ Input: p = 2, q = 1 Output: 2 Explanation: The ray meets receptor 2 the first time it gets reflected back to the left wall. -

    + -

    Note:

      diff --git a/problems/parallel-courses-ii/README.md b/problems/parallel-courses-ii/README.md new file mode 100644 index 000000000..1bb3fea26 --- /dev/null +++ b/problems/parallel-courses-ii/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../longest-subarray-of-1s-after-deleting-one-element "Longest Subarray of 1's After Deleting One Element") +                 +[Next >](../friendly-movies-streamed-last-month "Friendly Movies Streamed Last Month") + +## [1494. Parallel Courses II (Hard)](https://leetcode.com/problems/parallel-courses-ii "并行课程 II") + +

      Given the integer n representing the number of courses at some university labeled from 1 to n, and the array dependencies where dependencies[i] = [xi, yi]  represents a prerequisite relationship, that is, the course xi must be taken before the course yi.  Also, you are given the integer k.

      + +

      In one semester you can take at most k courses as long as you have taken all the prerequisites for the courses you are taking.

      + +

      Return the minimum number of semesters to take all courses. It is guaranteed that you can take all courses in some way.

      + +

       

      +

      Example 1:

      + +

      + +
      +Input: n = 4, dependencies = [[2,1],[3,1],[1,4]], k = 2
      +Output: 3 
      +Explanation: The figure above represents the given graph. In this case we can take courses 2 and 3 in the first semester, then take course 1 in the second semester and finally take course 4 in the third semester.
      +
      + +

      Example 2:

      + +

      + +
      +Input: n = 5, dependencies = [[2,1],[3,1],[4,1],[1,5]], k = 2
      +Output: 4 
      +Explanation: The figure above represents the given graph. In this case one optimal way to take all courses is: take courses 2 and 3 in the first semester and take course 4 in the second semester, then take course 1 in the third semester and finally take course 5 in the fourth semester.
      +
      + +

      Example 3:

      + +
      +Input: n = 11, dependencies = [], k = 2
      +Output: 6
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= n <= 15
      • +
      • 1 <= k <= n
      • +
      • 0 <= dependencies.length <= n * (n-1) / 2
      • +
      • dependencies[i].length == 2
      • +
      • 1 <= xi, yi <= n
      • +
      • xi != yi
      • +
      • All prerequisite relationships are distinct, that is, dependencies[i] != dependencies[j].
      • +
      • The given graph is a directed acyclic graph.
      • +
      + +### Related Topics + [[Graph](../../tag/graph/README.md)] + +### Hints +
      +Hint 1 +Use backtracking with states (bitmask, degrees) where bitmask represents the set of courses, if the ith bit is 1 then the ith course was taken, otherwise, you can take the ith course. Degrees represent the degree for each course (nodes in the graph). +
      + +
      +Hint 2 +Note that you can only take nodes (courses) with degree = 0 and it is optimal at every step in the backtracking take the maximum number of courses limited by k. +
      diff --git a/problems/sales-by-day-of-the-week/README.md b/problems/sales-by-day-of-the-week/README.md index 6ee35a001..28d94b922 100644 --- a/problems/sales-by-day-of-the-week/README.md +++ b/problems/sales-by-day-of-the-week/README.md @@ -9,6 +9,6 @@                  [Next >](../running-sum-of-1d-array "Running Sum of 1d Array") -## [1479. Sales by Day of the Week (Hard)](https://leetcode.com/problems/sales-by-day-of-the-week "") +## [1479. Sales by Day of the Week (Hard)](https://leetcode.com/problems/sales-by-day-of-the-week "周内每天的销售情况") diff --git a/problems/task-scheduler/README.md b/problems/task-scheduler/README.md index 76579da8f..e2dff6082 100644 --- a/problems/task-scheduler/README.md +++ b/problems/task-scheduler/README.md @@ -44,8 +44,11 @@ And so on.

      Example 3:

      -Input: tasks = ["A","B","C","D","E","A","B","C","D","E"], n = 4
      -Output: 10
      +Input: tasks = ["A","A","A","A","A","A","B","C","D","E","F","G"], n = 2
      +Output: 16
      +Explanation: 
      +One possible solution is
      +A -> B -> C -> A -> D -> E -> A -> F -> G -> A -> idle -> idle -> A -> idle -> idle -> A
       

       

      diff --git a/problems/the-kth-factor-of-n/README.md b/problems/the-kth-factor-of-n/README.md new file mode 100644 index 000000000..a375f78b4 --- /dev/null +++ b/problems/the-kth-factor-of-n/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../average-salary-excluding-the-minimum-and-maximum-salary "Average Salary Excluding the Minimum and Maximum Salary") +                 +[Next >](../longest-subarray-of-1s-after-deleting-one-element "Longest Subarray of 1's After Deleting One Element") + +## [1492. The kth Factor of n (Medium)](https://leetcode.com/problems/the-kth-factor-of-n "n 的第 k 个因子") + +

      Given two positive integers n and k.

      + +

      A factor of an integer n is defined as an integer i where n % i == 0.

      + +

      Consider a list of all factors of n sorted in ascending order, return the kth factor in this list or return -1 if n has less than k factors.

      + +

       

      +

      Example 1:

      + +
      +Input: n = 12, k = 3
      +Output: 3
      +Explanation: Factors list is [1, 2, 3, 4, 6, 12], the 3rd factor is 3.
      +
      + +

      Example 2:

      + +
      +Input: n = 7, k = 2
      +Output: 7
      +Explanation: Factors list is [1, 7], the 2nd factor is 7.
      +
      + +

      Example 3:

      + +
      +Input: n = 4, k = 4
      +Output: -1
      +Explanation: Factors list is [1, 2, 4], there is only 3 factors. We should return -1.
      +
      + +

      Example 4:

      + +
      +Input: n = 1, k = 1
      +Output: 1
      +Explanation: Factors list is [1], the 1st factor is 1.
      +
      + +

      Example 5:

      + +
      +Input: n = 1000, k = 3
      +Output: 4
      +Explanation: Factors list is [1, 2, 4, 5, 8, 10, 20, 25, 40, 50, 100, 125, 200, 250, 500, 1000].
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= k <= n <= 1000
      • +
      + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
      +Hint 1 +The factors of n will be always in the range [1, n]. +
      + +
      +Hint 2 +Keep a list of all factors sorted. Loop i from 1 to n and add i if n % i == 0. Return the kth factor if it exist in this list. +
      diff --git a/problems/valid-palindrome/README.md b/problems/valid-palindrome/README.md index c8e45097b..46d89f104 100644 --- a/problems/valid-palindrome/README.md +++ b/problems/valid-palindrome/README.md @@ -29,6 +29,13 @@ Output: false +

       

      +

      Constraints:

      + +
        +
      • s consists only of printable ASCII characters.
      • +
      + ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] diff --git a/tag/array/README.md b/tag/array/README.md index be4e977b3..b42149b3d 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1493 | [删掉一个元素以后全为 1 的最长子数组](../../problems/longest-subarray-of-1s-after-deleting-one-element) | [[数组](../array/README.md)] | Medium | +| 1491 | [去掉最低工资和最高工资后的工资平均值](../../problems/average-salary-excluding-the-minimum-and-maximum-salary) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | | 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1486 | [数组异或操作](../../problems/xor-operation-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | | 1482 | [制作 m 束花所需的最少天数](../../problems/minimum-number-of-days-to-make-m-bouquets) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 2202bebdf..91218fbbe 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 1345 | [跳跃游戏 IV](../../problems/jump-game-iv) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 40d0dbf04..b14efd835 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,9 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | | 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1469 | [Find All The Lonely Nodes](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 1469 | [寻找所有的独生节点](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 1466 | [重新规划路线](../../problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index 8f7969f23..aabe94b12 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -10,7 +10,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[设计](../design/README.md)] | Medium | -| 1429 | [First Unique Number](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] | Medium | | 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | | 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] | Medium | diff --git a/tag/graph/README.md b/tag/graph/README.md index cef03e5f3..140532a8e 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1494 | [并行课程 II](../../problems/parallel-courses-ii) | [[图](../graph/README.md)] | Hard | | 1462 | [课程安排 IV](../../problems/course-schedule-iv) | [[图](../graph/README.md)] | Medium | | 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | | 1361 | [验证二叉树](../../problems/validate-binary-tree-nodes) | [[图](../graph/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 692e1e2ef..e70601db4 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,9 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1429 | [First Unique Number](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1418 | [点菜展示表](../../problems/display-table-of-food-orders-in-a-restaurant) | [[哈希表](../hash-table/README.md)] | Medium | | 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 92f01a558..398bb69f9 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1492 | [n 的第 k 个因子](../../problems/the-kth-factor-of-n) | [[数学](../math/README.md)] | Medium | | 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index e462e2ee9..588bbaae0 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1491 | [去掉最低工资和最高工资后的工资平均值](../../problems/average-salary-excluding-the-minimum-and-maximum-salary) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | | 1481 | [不同整数的最少数目](../../problems/least-number-of-unique-integers-after-k-removals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1471 | [数组中的 k 个最强值](../../problems/the-k-strongest-values-in-an-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/tree/README.md b/tag/tree/README.md index 63b06cfbc..f5c592079 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,13 +9,14 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1469 | [Find All The Lonely Nodes](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 1469 | [寻找所有的独生节点](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 1466 | [重新规划路线](../../problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1430 | [Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree](../../problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | +| 1430 | [判断给定的序列是否是二叉树从根到叶的路径](../../problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | | 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] | Medium | | 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | From 4b2ab79684657108ddcf00ef2ae93c2874b92bef Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 2 Jul 2020 13:56:58 +0800 Subject: [PATCH 082/145] A: new --- README.md | 4 + problems/arithmetic-slices/README.md | 28 +++--- .../README.md | 89 +++++++++++++++++++ problems/expressive-words/README.md | 5 +- .../README.md | 2 +- .../README.md | 13 +-- problems/max-value-of-equation/README.md | 65 ++++++++++++++ .../README.md | 2 +- problems/merge-sorted-array/README.md | 4 +- .../README.md | 6 +- .../README.md | 84 +++++++++++++++++ problems/path-crossing/README.md | 58 ++++++++++++ tag/array/README.md | 3 + tag/greedy/README.md | 1 + tag/math/README.md | 1 + tag/sliding-window/README.md | 2 + tag/sort/README.md | 1 + tag/string/README.md | 1 + 18 files changed, 342 insertions(+), 27 deletions(-) create mode 100644 problems/check-if-array-pairs-are-divisible-by-k/README.md create mode 100644 problems/max-value-of-equation/README.md create mode 100644 problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md create mode 100644 problems/path-crossing/README.md diff --git a/README.md b/README.md index cf947c8b8..82583c798 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,10 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1499 | [Max Value of Equation](https://leetcode.com/problems/max-value-of-equation "满足不等式的最大值") | [Go](problems/max-value-of-equation) | Hard | +| 1498 | [Number of Subsequences That Satisfy the Given Sum Condition](https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition "满足条件的子序列数目") | [Go](problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | Medium | +| 1497 | [Check If Array Pairs Are Divisible by k](https://leetcode.com/problems/check-if-array-pairs-are-divisible-by-k "检查数组对是否可以被 k 整除") | [Go](problems/check-if-array-pairs-are-divisible-by-k) | Medium | +| 1496 | [Path Crossing](https://leetcode.com/problems/path-crossing "判断路径是否相交") | [Go](problems/path-crossing) | Easy | | 1495 | [Friendly Movies Streamed Last Month](https://leetcode.com/problems/friendly-movies-streamed-last-month) 🔒 | [MySQL](problems/friendly-movies-streamed-last-month) | Easy | | 1494 | [Parallel Courses II](https://leetcode.com/problems/parallel-courses-ii "并行课程 II") | [Go](problems/parallel-courses-ii) | Hard | | 1493 | [Longest Subarray of 1's After Deleting One Element](https://leetcode.com/problems/longest-subarray-of-1s-after-deleting-one-element "删掉一个元素以后全为 1 的最长子数组") | [Go](problems/longest-subarray-of-1s-after-deleting-one-element) | Medium | diff --git a/problems/arithmetic-slices/README.md b/problems/arithmetic-slices/README.md index b4a2e552f..220578503 100644 --- a/problems/arithmetic-slices/README.md +++ b/problems/arithmetic-slices/README.md @@ -11,25 +11,31 @@ ## [413. Arithmetic Slices (Medium)](https://leetcode.com/problems/arithmetic-slices "等差数列划分") -

      A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.

      +

      A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.

      -

      For example, these are arithmetic sequence:

      -
      1, 3, 5, 7, 9
      +

      For example, these are arithmetic sequences:

      + +
      +1, 3, 5, 7, 9
       7, 7, 7, 7
       3, -1, -5, -9
      -

      The following sequence is not arithmetic.

      1, 1, 2, 5, 7
      -
      +

      The following sequence is not arithmetic.

      + +
      +1, 1, 2, 5, 7
      +  + +

      A zero-indexed array A consisting of N numbers is given. A slice of that array is any pair of integers (P, Q) such that 0 <= P < Q < N.

      -

      A zero-indexed array A consisting of N numbers is given. A slice of that array is any pair of integers (P, Q) such that 0 <= P < Q < N.

      +

      A slice (P, Q) of the array A is called arithmetic if the sequence:
      +A[P], A[P + 1], ..., A[Q - 1], A[Q] is arithmetic. In particular, this means that P + 1 < Q.

      -

      A slice (P, Q) of array A is called arithmetic if the sequence:
      - A[P], A[p + 1], ..., A[Q - 1], A[Q] is arithmetic. In particular, this means that P + 1 < Q.

      +

      The function should return the number of arithmetic slices in the array A.

      +  -

      The function should return the number of arithmetic slices in the array A.

      -
      +

      Example:

      -

      Example:

       A = [1, 2, 3, 4]
       
      diff --git a/problems/check-if-array-pairs-are-divisible-by-k/README.md b/problems/check-if-array-pairs-are-divisible-by-k/README.md
      new file mode 100644
      index 000000000..d023b74de
      --- /dev/null
      +++ b/problems/check-if-array-pairs-are-divisible-by-k/README.md
      @@ -0,0 +1,89 @@
      +
      +
      +
      +
      +
      +
      +
      +[< Previous](../path-crossing "Path Crossing")
      +                
      +[Next >](../number-of-subsequences-that-satisfy-the-given-sum-condition "Number of Subsequences That Satisfy the Given Sum Condition")
      +
      +## [1497. Check If Array Pairs Are Divisible by k (Medium)](https://leetcode.com/problems/check-if-array-pairs-are-divisible-by-k "检查数组对是否可以被 k 整除")
      +
      +

      Given an array of integers arr of even length n and an integer k.

      + +

      We want to divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k.

      + +

      Return True If you can find a way to do that or False otherwise.

      + +

       

      +

      Example 1:

      + +
      +Input: arr = [1,2,3,4,5,10,6,7,8,9], k = 5
      +Output: true
      +Explanation: Pairs are (1,9),(2,8),(3,7),(4,6) and (5,10).
      +
      + +

      Example 2:

      + +
      +Input: arr = [1,2,3,4,5,6], k = 7
      +Output: true
      +Explanation: Pairs are (1,6),(2,5) and(3,4).
      +
      + +

      Example 3:

      + +
      +Input: arr = [1,2,3,4,5,6], k = 10
      +Output: false
      +Explanation: You can try all possible pairs to see that there is no way to divide arr into 3 pairs each with sum divisible by 10.
      +
      + +

      Example 4:

      + +
      +Input: arr = [-10,10], k = 2
      +Output: true
      +
      + +

      Example 5:

      + +
      +Input: arr = [-1,1,-2,2,-3,3,-4,4], k = 3
      +Output: true
      +
      + +

       

      +

      Constraints:

      + +
        +
      • arr.length == n
      • +
      • 1 <= n <= 10^5
      • +
      • n is even.
      • +
      • -10^9 <= arr[i] <= 10^9
      • +
      • 1 <= k <= 10^5
      • +
      + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
      +Hint 1 +Keep an array of the frequencies of ((x % k) + k) % k for each x in arr. +
      + +
      +Hint 2 +for each i in [0, k - 1] we need to check if freq[k] == freq[k - i] +
      + +
      +Hint 3 +Take care of the case when i == k - i and when i == 0 +
      diff --git a/problems/expressive-words/README.md b/problems/expressive-words/README.md index 6f0a59155..1a7716570 100644 --- a/problems/expressive-words/README.md +++ b/problems/expressive-words/README.md @@ -33,8 +33,7 @@ We can't extend "helo" to get "heeellooo" because the gr

       

      - -

      Notes:

      +

      Constraints:

      • 0 <= len(S) <= 100.
      • @@ -43,7 +42,5 @@ We can't extend "helo" to get "heeellooo" because the gr
      • S and all words in words consist only of lowercase letters
      -

       

      - ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/friendly-movies-streamed-last-month/README.md b/problems/friendly-movies-streamed-last-month/README.md index e1910169c..1fa758c44 100644 --- a/problems/friendly-movies-streamed-last-month/README.md +++ b/problems/friendly-movies-streamed-last-month/README.md @@ -7,7 +7,7 @@ [< Previous](../parallel-courses-ii "Parallel Courses II")                  -Next > +[Next >](../path-crossing "Path Crossing") ## [1495. Friendly Movies Streamed Last Month (Easy)](https://leetcode.com/problems/friendly-movies-streamed-last-month "") diff --git a/problems/intersection-of-two-linked-lists/README.md b/problems/intersection-of-two-linked-lists/README.md index 0d9777df9..3e7090f99 100644 --- a/problems/intersection-of-two-linked-lists/README.md +++ b/problems/intersection-of-two-linked-lists/README.md @@ -21,22 +21,22 @@

       

      Example 1:

      - +
      -Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,0,1,8,4,5], skipA = 2, skipB = 3
      +Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,6,1,8,4,5], skipA = 2, skipB = 3
       Output: Reference of the node with value = 8
      -Input Explanation: The intersected node's value is 8 (note that this must not be 0 if the two lists intersect). From the head of A, it reads as [4,1,8,4,5]. From the head of B, it reads as [5,0,1,8,4,5]. There are 2 nodes before the intersected node in A; There are 3 nodes before the intersected node in B.
      +Input Explanation: The intersected node's value is 8 (note that this must not be 0 if the two lists intersect). From the head of A, it reads as [4,1,8,4,5]. From the head of B, it reads as [5,6,1,8,4,5]. There are 2 nodes before the intersected node in A; There are 3 nodes before the intersected node in B.

       

      Example 2:

      - +
      -Input: intersectVal = 2, listA = [0,9,1,2,4], listB = [3,2,4], skipA = 3, skipB = 1
      +Input: intersectVal = 2, listA = [1,9,1,2,4], listB = [3,2,4], skipA = 3, skipB = 1
       Output: Reference of the node with value = 2
      -Input Explanation: The intersected node's value is 2 (note that this must not be 0 if the two lists intersect). From the head of A, it reads as [0,9,1,2,4]. From the head of B, it reads as [3,2,4]. There are 3 nodes before the intersected node in A; There are 1 node before the intersected node in B.
      +Input Explanation: The intersected node's value is 2 (note that this must not be 0 if the two lists intersect). From the head of A, it reads as [1,9,1,2,4]. From the head of B, it reads as [3,2,4]. There are 3 nodes before the intersected node in A; There are 1 node before the intersected node in B.
       

       

      @@ -59,6 +59,7 @@
    1. If the two linked lists have no intersection at all, return null.
    2. The linked lists must retain their original structure after the function returns.
    3. You may assume there are no cycles anywhere in the entire linked structure.
    4. +
    5. Each value on each linked list is in the range [1, 10^9].
    6. Your code should preferably run in O(n) time and use only O(1) memory.
    7. diff --git a/problems/max-value-of-equation/README.md b/problems/max-value-of-equation/README.md new file mode 100644 index 000000000..4b4d4cbeb --- /dev/null +++ b/problems/max-value-of-equation/README.md @@ -0,0 +1,65 @@ + + + + + + + +[< Previous](../number-of-subsequences-that-satisfy-the-given-sum-condition "Number of Subsequences That Satisfy the Given Sum Condition") +                 +Next > + +## [1499. Max Value of Equation (Hard)](https://leetcode.com/problems/max-value-of-equation "满足不等式的最大值") + +

      Given an array points containing the coordinates of points on a 2D plane, sorted by the x-values, where points[i] = [xi, yi] such that xi < xj for all 1 <= i < j <= points.length. You are also given an integer k.

      + +

      Find the maximum value of the equation yi + yj + |xi - xj| where |xi - xj| <= k and 1 <= i < j <= points.length. It is guaranteed that there exists at least one pair of points that satisfy the constraint |xi - xj| <= k.

      + +

       

      +

      Example 1:

      + +
      +Input: points = [[1,3],[2,0],[5,10],[6,-10]], k = 1
      +Output: 4
      +Explanation: The first two points satisfy the condition |xi - xj| <= 1 and if we calculate the equation we get 3 + 0 + |1 - 2| = 4. Third and fourth points also satisfy the condition and give a value of 10 + -10 + |5 - 6| = 1.
      +No other pairs satisfy the condition, so we return the max of 4 and 1.
      + +

      Example 2:

      + +
      +Input: points = [[0,0],[3,0],[9,2]], k = 3
      +Output: 3
      +Explanation: Only the first two points have an absolute difference of 3 or less in the x-values, and give the value of 0 + 0 + |0 - 3| = 3.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 2 <= points.length <= 10^5
      • +
      • points[i].length == 2
      • +
      • -10^8 <= points[i][0], points[i][1] <= 10^8
      • +
      • 0 <= k <= 2 * 10^8
      • +
      • points[i][0] < points[j][0] for all 1 <= i < j <= points.length
      • +
      • xi form a strictly increasing sequence.
      • +
      + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
      +Hint 1 +Use a priority queue to store for each point i, the tuple [yi-xi, xi] +
      + +
      +Hint 2 +Loop through the array and pop elements from the heap if the condition xj - xi > k, where j is the current index and i is the point on top the queue. +
      + +
      +Hint 3 +After popping elements from the queue. If the queue is not empty, calculate the equation with the current point and the point on top of the queue and maximize the answer. +
      diff --git a/problems/maximum-length-of-repeated-subarray/README.md b/problems/maximum-length-of-repeated-subarray/README.md index efa97c82f..3d4201a94 100644 --- a/problems/maximum-length-of-repeated-subarray/README.md +++ b/problems/maximum-length-of-repeated-subarray/README.md @@ -47,5 +47,5 @@ The repeated subarray with maximum length is [3, 2, 1]. ### Hints
      Hint 1 -Use dynamic programming. dp[i][j] will be the answer for inputs A[i:], B[j:]. +运用动态规划的方法,dp[i][j] 就是是输入中 A [i:], B[j:] 所对应的答案。
      diff --git a/problems/merge-sorted-array/README.md b/problems/merge-sorted-array/README.md index 1f8a02bb0..d8f1548ce 100644 --- a/problems/merge-sorted-array/README.md +++ b/problems/merge-sorted-array/README.md @@ -17,7 +17,7 @@
      • The number of elements initialized in nums1 and nums2 are m and n respectively.
      • -
      • You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from nums2.
      • +
      • You may assume that nums1 has enough space (size that is equal to m + n) to hold additional elements from nums2.

      Example:

      @@ -35,6 +35,8 @@ nums2 = [2,5,6], n = 3
      • -10^9 <= nums1[i], nums2[i] <= 10^9
      • +
      • nums1.length == m + n
      • +
      • nums2.length == n
      ### Related Topics diff --git a/problems/n-repeated-element-in-size-2n-array/README.md b/problems/n-repeated-element-in-size-2n-array/README.md index 45338a589..ed9d656f3 100644 --- a/problems/n-repeated-element-in-size-2n-array/README.md +++ b/problems/n-repeated-element-in-size-2n-array/README.md @@ -11,7 +11,7 @@ ## [961. N-Repeated Element in Size 2N Array (Easy)](https://leetcode.com/problems/n-repeated-element-in-size-2n-array "重复 N 次的元素") -

      In a array A of size 2N, there are N+1 unique elements, and exactly one of these elements is repeated N times.

      +

      In a array A of size 2N, there are N+1 unique elements, and exactly one of these elements is repeated N times.

      Return the element repeated N times.

      @@ -48,11 +48,11 @@

      Note:

      -
        +
        • 4 <= A.length <= 10000
        • 0 <= A[i] < 10000
        • A.length is even
        • -
      + diff --git a/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md b/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md new file mode 100644 index 000000000..04b4533ab --- /dev/null +++ b/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md @@ -0,0 +1,84 @@ + + + + + + + +[< Previous](../check-if-array-pairs-are-divisible-by-k "Check If Array Pairs Are Divisible by k") +                 +[Next >](../max-value-of-equation "Max Value of Equation") + +## [1498. Number of Subsequences That Satisfy the Given Sum Condition (Medium)](https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition "满足条件的子序列数目") + +

      Given an array of integers nums and an integer target.

      + +

      Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal than target.

      + +

      Since the answer may be too large, return it modulo 10^9 + 7.

      + +

       

      +

      Example 1:

      + +
      +Input: nums = [3,5,6,7], target = 9
      +Output: 4
      +Explanation: There are 4 subsequences that satisfy the condition.
      +[3] -> Min value + max value <= target (3 + 3 <= 9)
      +[3,5] -> (3 + 5 <= 9)
      +[3,5,6] -> (3 + 6 <= 9)
      +[3,6] -> (3 + 6 <= 9)
      +
      + +

      Example 2:

      + +
      +Input: nums = [3,3,6,8], target = 10
      +Output: 6
      +Explanation: There are 6 subsequences that satisfy the condition. (nums can have repeated numbers).
      +[3] , [3] , [3,3], [3,6] , [3,6] , [3,3,6]
      + +

      Example 3:

      + +
      +Input: nums = [2,3,3,4,6,7], target = 12
      +Output: 61
      +Explanation: There are 63 non-empty subsequences, two of them don't satisfy the condition ([6,7], [7]).
      +Number of valid subsequences (63 - 2 = 61).
      +
      + +

      Example 4:

      + +
      +Input: nums = [5,2,4,1,7,6,8], target = 16
      +Output: 127
      +Explanation: All non-empty subset satisfy the condition (2^7 - 1) = 127
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= nums.length <= 10^5
      • +
      • 1 <= nums[i] <= 10^6
      • +
      • 1 <= target <= 10^6
      • +
      + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
      +Hint 1 +Sort the array nums. +
      + +
      +Hint 2 +Use two pointers approach: Given an index i (choose it as the minimum in a subsequence) find the maximum j where j ≥ i and nums[i] +nums[j] ≤ target. +
      + +
      +Hint 3 +Count the number of subsequences. +
      diff --git a/problems/path-crossing/README.md b/problems/path-crossing/README.md new file mode 100644 index 000000000..8899d515d --- /dev/null +++ b/problems/path-crossing/README.md @@ -0,0 +1,58 @@ + + + + + + + +[< Previous](../friendly-movies-streamed-last-month "Friendly Movies Streamed Last Month") +                 +[Next >](../check-if-array-pairs-are-divisible-by-k "Check If Array Pairs Are Divisible by k") + +## [1496. Path Crossing (Easy)](https://leetcode.com/problems/path-crossing "判断路径是否相交") + +

      Given a string path, where path[i] = 'N', 'S', 'E' or 'W', each representing moving one unit north, south, east, or west, respectively. You start at the origin (0, 0) on a 2D plane and walk on the path specified by path.

      + +

      Return True if the path crosses itself at any point, that is, if at any time you are on a location you've previously visited. Return False otherwise.

      + +

       

      +

      Example 1:

      + +

      + +
      +Input: path = "NES"
      +Output: false 
      +Explanation: Notice that the path doesn't cross any point more than once.
      +
      + +

      Example 2:

      + +

      + +
      +Input: path = "NESWW"
      +Output: true
      +Explanation: Notice that the path visits the origin twice.
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= path.length <= 10^4
      • +
      • path will only consist of characters in {'N', 'S', 'E', 'W}
      • +
      + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
      +Hint 1 +Simulate the process while keeping track of visited points. +
      + +
      +Hint 2 +Use a set to store previously visited points. +
      diff --git a/tag/array/README.md b/tag/array/README.md index b42149b3d..8c22d9bc1 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1500 | [Design a File Sharing System](../../problems/design-a-file-sharing-system) 🔒 | [[数组](../array/README.md)] | Medium | +| 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1493 | [删掉一个元素以后全为 1 的最长子数组](../../problems/longest-subarray-of-1s-after-deleting-one-element) | [[数组](../array/README.md)] | Medium | | 1491 | [去掉最低工资和最高工资后的工资平均值](../../problems/average-salary-excluding-the-minimum-and-maximum-salary) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | | 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 8be0add8c..0e8d15254 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1414 | [和为 K 的最少斐波那契数字数目](../../problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 398bb69f9..268d31824 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1492 | [n 的第 k 个因子](../../problems/the-kth-factor-of-n) | [[数学](../math/README.md)] | Medium | | 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index a602f91fc..674b421a7 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[排序](../sort/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index 588bbaae0..ee397f312 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[排序](../sort/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1491 | [去掉最低工资和最高工资后的工资平均值](../../problems/average-salary-excluding-the-minimum-and-maximum-salary) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | | 1481 | [不同整数的最少数目](../../problems/least-number-of-unique-integers-after-k-removals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1471 | [数组中的 k 个最强值](../../problems/the-k-strongest-values-in-an-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index c7b01260a..49cb5540b 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1496 | [判断路径是否相交](../../problems/path-crossing) | [[字符串](../string/README.md)] | Easy | | 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | From b540efae66f02d54f79bfbbec806f12317a2e14a Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 2 Jul 2020 14:30:06 +0800 Subject: [PATCH 083/145] A: String Matching in an Array --- .../string_matching_in_an_array.go | 21 ++++++++++++ .../string_matching_in_an_array_test.go | 34 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 problems/string-matching-in-an-array/string_matching_in_an_array.go create mode 100644 problems/string-matching-in-an-array/string_matching_in_an_array_test.go diff --git a/problems/string-matching-in-an-array/string_matching_in_an_array.go b/problems/string-matching-in-an-array/string_matching_in_an_array.go new file mode 100644 index 000000000..6979793f8 --- /dev/null +++ b/problems/string-matching-in-an-array/string_matching_in_an_array.go @@ -0,0 +1,21 @@ +package problem1408 + +import "strings" + +func stringMatching(words []string) []string { + var ans []string + ok := func(str string) bool { + for _, word := range words { + if word != str && strings.Contains(word, str) { + return true + } + } + return false + } + for _, word := range words { + if ok(word) { + ans = append(ans, word) + } + } + return ans +} diff --git a/problems/string-matching-in-an-array/string_matching_in_an_array_test.go b/problems/string-matching-in-an-array/string_matching_in_an_array_test.go new file mode 100644 index 000000000..00659ab4a --- /dev/null +++ b/problems/string-matching-in-an-array/string_matching_in_an_array_test.go @@ -0,0 +1,34 @@ +package problem1408 + +import ( + "reflect" + "testing" +) + +type testType struct { + in []string + want []string +} + +func TestStringMatching(t *testing.T) { + tests := [...]testType{ + { + in: []string{"mass", "as", "hero", "superhero"}, + want: []string{"as", "hero"}, + }, + { + in: []string{"leetcode", "et", "code"}, + want: []string{"et", "code"}, + }, + { + in: []string{"blue", "green", "bu"}, + want: nil, + }, + } + for _, tt := range tests { + got := stringMatching(tt.in) + if !reflect.DeepEqual(got, tt.want) { + t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want) + } + } +} From 76b5ee769c83701af60b64ee5290a35a1be8d90c Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 2 Jul 2020 14:33:13 +0800 Subject: [PATCH 084/145] A: String Matching in an Array --- .../string_matching_in_an_array.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/problems/string-matching-in-an-array/string_matching_in_an_array.go b/problems/string-matching-in-an-array/string_matching_in_an_array.go index 6979793f8..c39f42ee7 100644 --- a/problems/string-matching-in-an-array/string_matching_in_an_array.go +++ b/problems/string-matching-in-an-array/string_matching_in_an_array.go @@ -4,17 +4,12 @@ import "strings" func stringMatching(words []string) []string { var ans []string - ok := func(str string) bool { - for _, word := range words { - if word != str && strings.Contains(word, str) { - return true - } - } - return false - } for _, word := range words { - if ok(word) { - ans = append(ans, word) + for _, val := range words { + if val != word && strings.Contains(val, word) { + ans = append(ans, word) + break + } } } return ans From 697f63dd8f3dad4bfe46debfb628e1de33bb41f2 Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 2 Jul 2020 17:51:04 +0800 Subject: [PATCH 085/145] A: Reformat The String --- .../reformat_the_string.go | 26 ++++++++ .../reformat_the_string_test.go | 63 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 problems/reformat-the-string/reformat_the_string.go create mode 100644 problems/reformat-the-string/reformat_the_string_test.go diff --git a/problems/reformat-the-string/reformat_the_string.go b/problems/reformat-the-string/reformat_the_string.go new file mode 100644 index 000000000..840d70c1d --- /dev/null +++ b/problems/reformat-the-string/reformat_the_string.go @@ -0,0 +1,26 @@ +package problem1417 + +func reformat(s string) string { + i, j, l := 0, 1, len(s) + str := make([]byte, l+1) + for _, c := range s { + if '0' <= c && c <= '9' { + if i > l { + return "" + } + str[i], i = byte(c), i+2 + } else if j > l { + return "" + } else { + str[j], j = byte(c), j+2 + } + } + if i == l || j == l { + return string(str[:l]) + } + if i == l-1 { + str[i] = str[0] + return string(str[1 : l+1]) + } + return "" +} diff --git a/problems/reformat-the-string/reformat_the_string_test.go b/problems/reformat-the-string/reformat_the_string_test.go new file mode 100644 index 000000000..691a6f023 --- /dev/null +++ b/problems/reformat-the-string/reformat_the_string_test.go @@ -0,0 +1,63 @@ +package problem1417 + +import "testing" + +type testType struct { + in string + want string +} + +func TestReformat(t *testing.T) { + tests := [...]testType{ + { + in: "a0b1c2", + want: "0a1b2c", + }, + { + in: "leetcode", + want: "", + }, + { + in: "1229857369", + want: "", + }, + { + in: "covid2019", + want: "c0o1v9i2d", + }, + { + in: "ab123", + want: "1a2b3", + }, + { + in: "ec", + want: "", + }, + { + in: "abcd12345", + want: "1a2b3c4d5", + }, + { + in: "12345abcd", + want: "1a2b3c4d5", + }, + { + in: "77", + want: "", + }, + { + in: "1", + want: "1", + }, + { + in: "a", + want: "a", + }, + } + for _, tt := range tests { + got := reformat(tt.in) + if got != tt.want { + t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want) + } + } +} From cb477f3948615811dc1873e0934a8a6f26644668 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 6 Jul 2020 16:12:31 +0800 Subject: [PATCH 086/145] A: new --- README.md | 326 +-------------- .../README.md | 56 +++ .../README.md | 6 + .../count-submatrices-with-all-ones/README.md | 86 ++++ .../README.md | 14 + .../mysql_schemas.sql | 27 ++ .../design-a-file-sharing-system/README.md | 28 ++ problems/employee-importance/README.md | 6 +- .../README.md | 93 +++++ .../README.md | 3 +- problems/max-value-of-equation/README.md | 2 +- .../README.md | 2 +- .../README.md | 80 ++++ problems/most-frequent-subtree-sum/README.md | 2 +- problems/unique-morse-code-words/README.md | 2 +- readme/1-300.md | 20 +- readme/301-600.md | 20 +- readme/601-900.md | 20 +- readme/901-1200.md | 372 ++++++++++++++++++ tag/README.md | 6 +- tag/array/README.md | 2 + tag/brainteaser/README.md | 1 + tag/dynamic-programming/README.md | 1 + tag/greedy/README.md | 1 + tag/sort/README.md | 1 + tag/tags.json | 20 +- 26 files changed, 850 insertions(+), 347 deletions(-) create mode 100644 problems/can-make-arithmetic-progression-from-sequence/README.md create mode 100644 problems/count-submatrices-with-all-ones/README.md create mode 100644 problems/countries-you-can-safely-invest-in/README.md create mode 100644 problems/countries-you-can-safely-invest-in/mysql_schemas.sql create mode 100644 problems/design-a-file-sharing-system/README.md create mode 100644 problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md create mode 100644 problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md create mode 100644 readme/901-1200.md diff --git a/README.md b/README.md index 82583c798..ca5551603 100644 --- a/README.md +++ b/README.md @@ -43,12 +43,12 @@ LeetCode Problems' Solutions [851-900] - [901-950] - [951-1000] - [1001-1050] - [1051-1100] - [1101-1150] - [1151-1200] + [901-950] + [951-1000] + [1001-1050] + [1051-1100] + [1101-1150] + [1151-1200] [1201-1250] @@ -58,10 +58,24 @@ LeetCode Problems' Solutions [1401-1450] [1451-1500] + + [1501-1550] + [1551-1600] + [1601-1650] + [1651-1700] + [1701-1750] + [1751-1800] + | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1505 | [Minimum Possible Integer After at Most K Adjacent Swaps On Digits](https://leetcode.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "最多 K 次交换相邻数位后得到的最小整数") | [Go](problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | Hard | +| 1504 | [Count Submatrices With All Ones](https://leetcode.com/problems/count-submatrices-with-all-ones "统计全 1 子矩形") | [Go](problems/count-submatrices-with-all-ones) | Medium | +| 1503 | [Last Moment Before All Ants Fall Out of a Plank](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank "所有蚂蚁掉下来前的最后一刻") | [Go](problems/last-moment-before-all-ants-fall-out-of-a-plank) | Medium | +| 1502 | [Can Make Arithmetic Progression From Sequence](https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence "判断能否形成等差数列") | [Go](problems/can-make-arithmetic-progression-from-sequence) | Easy | +| 1501 | [Countries You Can Safely Invest In](https://leetcode.com/problems/countries-you-can-safely-invest-in) 🔒 | [MySQL](problems/countries-you-can-safely-invest-in) | Medium | +| 1500 | [Design a File Sharing System](https://leetcode.com/problems/design-a-file-sharing-system) 🔒 | [Go](problems/design-a-file-sharing-system) | Medium | | 1499 | [Max Value of Equation](https://leetcode.com/problems/max-value-of-equation "满足不等式的最大值") | [Go](problems/max-value-of-equation) | Hard | | 1498 | [Number of Subsequences That Satisfy the Given Sum Condition](https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition "满足条件的子序列数目") | [Go](problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | Medium | | 1497 | [Check If Array Pairs Are Divisible by k](https://leetcode.com/problems/check-if-array-pairs-are-divisible-by-k "检查数组对是否可以被 k 整除") | [Go](problems/check-if-array-pairs-are-divisible-by-k) | Medium | @@ -361,303 +375,3 @@ LeetCode Problems' Solutions | 1203 | [Sort Items by Groups Respecting Dependencies](https://leetcode.com/problems/sort-items-by-groups-respecting-dependencies "项目管理") | [Go](problems/sort-items-by-groups-respecting-dependencies) | Hard | | 1202 | [Smallest String With Swaps](https://leetcode.com/problems/smallest-string-with-swaps "交换字符串中的元素") | [Go](problems/smallest-string-with-swaps) | Medium | | 1201 | [Ugly Number III](https://leetcode.com/problems/ugly-number-iii "丑数 III") | [Go](problems/ugly-number-iii) | Medium | -| 1200 | [Minimum Absolute Difference](https://leetcode.com/problems/minimum-absolute-difference "最小绝对差") | [Go](problems/minimum-absolute-difference) | Easy | -| 1199 | [Minimum Time to Build Blocks](https://leetcode.com/problems/minimum-time-to-build-blocks "建造街区的最短时间") 🔒 | [Go](problems/minimum-time-to-build-blocks) | Hard | -| 1198 | [Find Smallest Common Element in All Rows](https://leetcode.com/problems/find-smallest-common-element-in-all-rows "找出所有行中最小公共元素") 🔒 | [Go](problems/find-smallest-common-element-in-all-rows) | Medium | -| 1197 | [Minimum Knight Moves](https://leetcode.com/problems/minimum-knight-moves "进击的骑士") 🔒 | [Go](problems/minimum-knight-moves) | Medium | -| 1196 | [How Many Apples Can You Put into the Basket](https://leetcode.com/problems/how-many-apples-can-you-put-into-the-basket "最多可以买到的苹果数量") 🔒 | [Go](problems/how-many-apples-can-you-put-into-the-basket) | Easy | -| 1195 | [Fizz Buzz Multithreaded](https://leetcode.com/problems/fizz-buzz-multithreaded "交替打印字符串") | [Go](problems/fizz-buzz-multithreaded) | Medium | -| 1194 | [Tournament Winners](https://leetcode.com/problems/tournament-winners "锦标赛优胜者") 🔒 | [MySQL](problems/tournament-winners) | Hard | -| 1193 | [Monthly Transactions I](https://leetcode.com/problems/monthly-transactions-i "每月交易 I") 🔒 | [MySQL](problems/monthly-transactions-i) | Medium | -| 1192 | [Critical Connections in a Network](https://leetcode.com/problems/critical-connections-in-a-network "查找集群内的「关键连接」") | [Go](problems/critical-connections-in-a-network) | Hard | -| 1191 | [K-Concatenation Maximum Sum](https://leetcode.com/problems/k-concatenation-maximum-sum "K 次串联后最大子数组之和") | [Go](problems/k-concatenation-maximum-sum) | Medium | -| 1190 | [Reverse Substrings Between Each Pair of Parentheses](https://leetcode.com/problems/reverse-substrings-between-each-pair-of-parentheses "反转每对括号间的子串") | [Go](problems/reverse-substrings-between-each-pair-of-parentheses) | Medium | -| 1189 | [Maximum Number of Balloons](https://leetcode.com/problems/maximum-number-of-balloons "“气球” 的最大数量") | [Go](problems/maximum-number-of-balloons) | Easy | -| 1188 | [Design Bounded Blocking Queue](https://leetcode.com/problems/design-bounded-blocking-queue "设计有限阻塞队列") 🔒 | [Go](problems/design-bounded-blocking-queue) | Medium | -| 1187 | [Make Array Strictly Increasing](https://leetcode.com/problems/make-array-strictly-increasing "使数组严格递增") | [Go](problems/make-array-strictly-increasing) | Hard | -| 1186 | [Maximum Subarray Sum with One Deletion](https://leetcode.com/problems/maximum-subarray-sum-with-one-deletion "删除一次得到子数组最大和") | [Go](problems/maximum-subarray-sum-with-one-deletion) | Medium | -| 1185 | [Day of the Week](https://leetcode.com/problems/day-of-the-week "一周中的第几天") | [Go](problems/day-of-the-week) | Easy | -| 1184 | [Distance Between Bus Stops](https://leetcode.com/problems/distance-between-bus-stops "公交站间的距离") | [Go](problems/distance-between-bus-stops) | Easy | -| 1183 | [Maximum Number of Ones](https://leetcode.com/problems/maximum-number-of-ones "矩阵中 1 的最大数量") 🔒 | [Go](problems/maximum-number-of-ones) | Hard | -| 1182 | [Shortest Distance to Target Color](https://leetcode.com/problems/shortest-distance-to-target-color "与目标颜色间的最短距离") 🔒 | [Go](problems/shortest-distance-to-target-color) | Medium | -| 1181 | [Before and After Puzzle](https://leetcode.com/problems/before-and-after-puzzle "前后拼接") 🔒 | [Go](problems/before-and-after-puzzle) | Medium | -| 1180 | [Count Substrings with Only One Distinct Letter](https://leetcode.com/problems/count-substrings-with-only-one-distinct-letter "统计只含单一字母的子串") 🔒 | [Go](problems/count-substrings-with-only-one-distinct-letter) | Easy | -| 1179 | [Reformat Department Table](https://leetcode.com/problems/reformat-department-table "重新格式化部门表") | [MySQL](problems/reformat-department-table) | Easy | -| 1178 | [Number of Valid Words for Each Puzzle](https://leetcode.com/problems/number-of-valid-words-for-each-puzzle "猜字谜") | [Go](problems/number-of-valid-words-for-each-puzzle) | Hard | -| 1177 | [Can Make Palindrome from Substring](https://leetcode.com/problems/can-make-palindrome-from-substring "构建回文串检测") | [Go](problems/can-make-palindrome-from-substring) | Medium | -| 1176 | [Diet Plan Performance](https://leetcode.com/problems/diet-plan-performance "健身计划评估") 🔒 | [Go](problems/diet-plan-performance) | Easy | -| 1175 | [Prime Arrangements](https://leetcode.com/problems/prime-arrangements "质数排列") | [Go](problems/prime-arrangements) | Easy | -| 1174 | [Immediate Food Delivery II](https://leetcode.com/problems/immediate-food-delivery-ii "即时食物配送 II") 🔒 | [MySQL](problems/immediate-food-delivery-ii) | Medium | -| 1173 | [Immediate Food Delivery I](https://leetcode.com/problems/immediate-food-delivery-i "即时食物配送 I") 🔒 | [MySQL](problems/immediate-food-delivery-i) | Easy | -| 1172 | [Dinner Plate Stacks](https://leetcode.com/problems/dinner-plate-stacks "餐盘栈") | [Go](problems/dinner-plate-stacks) | Hard | -| 1171 | [Remove Zero Sum Consecutive Nodes from Linked List](https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list "从链表中删去总和值为零的连续节点") | [Go](problems/remove-zero-sum-consecutive-nodes-from-linked-list) | Medium | -| 1170 | [Compare Strings by Frequency of the Smallest Character](https://leetcode.com/problems/compare-strings-by-frequency-of-the-smallest-character "比较字符串最小字母出现频次") | [Go](problems/compare-strings-by-frequency-of-the-smallest-character) | Easy | -| 1169 | [Invalid Transactions](https://leetcode.com/problems/invalid-transactions "查询无效交易") | [Go](problems/invalid-transactions) | Medium | -| 1168 | [Optimize Water Distribution in a Village](https://leetcode.com/problems/optimize-water-distribution-in-a-village "水资源分配优化") 🔒 | [Go](problems/optimize-water-distribution-in-a-village) | Hard | -| 1167 | [Minimum Cost to Connect Sticks](https://leetcode.com/problems/minimum-cost-to-connect-sticks "连接棒材的最低费用") 🔒 | [Go](problems/minimum-cost-to-connect-sticks) | Medium | -| 1166 | [Design File System](https://leetcode.com/problems/design-file-system "设计文件系统") 🔒 | [Go](problems/design-file-system) | Medium | -| 1165 | [Single-Row Keyboard](https://leetcode.com/problems/single-row-keyboard "单行键盘") 🔒 | [Go](problems/single-row-keyboard) | Easy | -| 1164 | [Product Price at a Given Date](https://leetcode.com/problems/product-price-at-a-given-date "指定日期的产品价格") 🔒 | [MySQL](problems/product-price-at-a-given-date) | Medium | -| 1163 | [Last Substring in Lexicographical Order](https://leetcode.com/problems/last-substring-in-lexicographical-order "按字典序排在最后的子串") | [Go](problems/last-substring-in-lexicographical-order) | Hard | -| 1162 | [As Far from Land as Possible](https://leetcode.com/problems/as-far-from-land-as-possible "地图分析") | [Go](problems/as-far-from-land-as-possible) | Medium | -| 1161 | [Maximum Level Sum of a Binary Tree](https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree "最大层内元素和") | [Go](problems/maximum-level-sum-of-a-binary-tree) | Medium | -| 1160 | [Find Words That Can Be Formed by Characters](https://leetcode.com/problems/find-words-that-can-be-formed-by-characters "拼写单词") | [Go](problems/find-words-that-can-be-formed-by-characters) | Easy | -| 1159 | [Market Analysis II](https://leetcode.com/problems/market-analysis-ii "市场分析 II") 🔒 | [MySQL](problems/market-analysis-ii) | Hard | -| 1158 | [Market Analysis I](https://leetcode.com/problems/market-analysis-i "市场分析 I") 🔒 | [MySQL](problems/market-analysis-i) | Medium | -| 1157 | [Online Majority Element In Subarray](https://leetcode.com/problems/online-majority-element-in-subarray "子数组中占绝大多数的元素") | [Go](problems/online-majority-element-in-subarray) | Hard | -| 1156 | [Swap For Longest Repeated Character Substring](https://leetcode.com/problems/swap-for-longest-repeated-character-substring "单字符重复子串的最大长度") | [Go](problems/swap-for-longest-repeated-character-substring) | Medium | -| 1155 | [Number of Dice Rolls With Target Sum](https://leetcode.com/problems/number-of-dice-rolls-with-target-sum "掷骰子的N种方法") | [Go](problems/number-of-dice-rolls-with-target-sum) | Medium | -| 1154 | [Day of the Year](https://leetcode.com/problems/day-of-the-year "一年中的第几天") | [Go](problems/day-of-the-year) | Easy | -| 1153 | [String Transforms Into Another String](https://leetcode.com/problems/string-transforms-into-another-string "字符串转化") 🔒 | [Go](problems/string-transforms-into-another-string) | Hard | -| 1152 | [Analyze User Website Visit Pattern](https://leetcode.com/problems/analyze-user-website-visit-pattern "用户网站访问行为分析") 🔒 | [Go](problems/analyze-user-website-visit-pattern) | Medium | -| 1151 | [Minimum Swaps to Group All 1's Together](https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together "最少交换次数来组合所有的 1") 🔒 | [Go](problems/minimum-swaps-to-group-all-1s-together) | Medium | -| 1150 | [Check If a Number Is Majority Element in a Sorted Array](https://leetcode.com/problems/check-if-a-number-is-majority-element-in-a-sorted-array "检查一个数是否在数组中占绝大多数") 🔒 | [Go](problems/check-if-a-number-is-majority-element-in-a-sorted-array) | Easy | -| 1149 | [Article Views II](https://leetcode.com/problems/article-views-ii "文章浏览 II") 🔒 | [MySQL](problems/article-views-ii) | Medium | -| 1148 | [Article Views I](https://leetcode.com/problems/article-views-i "文章浏览 I") 🔒 | [MySQL](problems/article-views-i) | Easy | -| 1147 | [Longest Chunked Palindrome Decomposition](https://leetcode.com/problems/longest-chunked-palindrome-decomposition "段式回文") | [Go](problems/longest-chunked-palindrome-decomposition) | Hard | -| 1146 | [Snapshot Array](https://leetcode.com/problems/snapshot-array "快照数组") | [Go](problems/snapshot-array) | Medium | -| 1145 | [Binary Tree Coloring Game](https://leetcode.com/problems/binary-tree-coloring-game "二叉树着色游戏") | [Go](problems/binary-tree-coloring-game) | Medium | -| 1144 | [Decrease Elements To Make Array Zigzag](https://leetcode.com/problems/decrease-elements-to-make-array-zigzag "递减元素使数组呈锯齿状") | [Go](problems/decrease-elements-to-make-array-zigzag) | Medium | -| 1143 | [Longest Common Subsequence](https://leetcode.com/problems/longest-common-subsequence "最长公共子序列") | [Go](problems/longest-common-subsequence) | Medium | -| 1142 | [User Activity for the Past 30 Days II](https://leetcode.com/problems/user-activity-for-the-past-30-days-ii "过去30天的用户活动 II") 🔒 | [MySQL](problems/user-activity-for-the-past-30-days-ii) | Easy | -| 1141 | [User Activity for the Past 30 Days I](https://leetcode.com/problems/user-activity-for-the-past-30-days-i "查询近30天活跃用户数") 🔒 | [MySQL](problems/user-activity-for-the-past-30-days-i) | Easy | -| 1140 | [Stone Game II](https://leetcode.com/problems/stone-game-ii "石子游戏 II") | [Go](problems/stone-game-ii) | Medium | -| 1139 | [Largest 1-Bordered Square](https://leetcode.com/problems/largest-1-bordered-square "最大的以 1 为边界的正方形") | [Go](problems/largest-1-bordered-square) | Medium | -| 1138 | [Alphabet Board Path](https://leetcode.com/problems/alphabet-board-path "字母板上的路径") | [Go](problems/alphabet-board-path) | Medium | -| 1137 | [N-th Tribonacci Number](https://leetcode.com/problems/n-th-tribonacci-number "第 N 个泰波那契数") | [Go](problems/n-th-tribonacci-number) | Easy | -| 1136 | [Parallel Courses](https://leetcode.com/problems/parallel-courses "平行课程") 🔒 | [Go](problems/parallel-courses) | Hard | -| 1135 | [Connecting Cities With Minimum Cost](https://leetcode.com/problems/connecting-cities-with-minimum-cost "最低成本联通所有城市") 🔒 | [Go](problems/connecting-cities-with-minimum-cost) | Medium | -| 1134 | [Armstrong Number](https://leetcode.com/problems/armstrong-number "阿姆斯特朗数") 🔒 | [Go](problems/armstrong-number) | Easy | -| 1133 | [Largest Unique Number](https://leetcode.com/problems/largest-unique-number "最大唯一数") 🔒 | [Go](problems/largest-unique-number) | Easy | -| 1132 | [Reported Posts II](https://leetcode.com/problems/reported-posts-ii "报告的记录 II") 🔒 | [MySQL](problems/reported-posts-ii) | Medium | -| 1131 | [Maximum of Absolute Value Expression](https://leetcode.com/problems/maximum-of-absolute-value-expression "绝对值表达式的最大值") | [Go](problems/maximum-of-absolute-value-expression) | Medium | -| 1130 | [Minimum Cost Tree From Leaf Values](https://leetcode.com/problems/minimum-cost-tree-from-leaf-values "叶值的最小代价生成树") | [Go](problems/minimum-cost-tree-from-leaf-values) | Medium | -| 1129 | [Shortest Path with Alternating Colors](https://leetcode.com/problems/shortest-path-with-alternating-colors "颜色交替的最短路径") | [Go](problems/shortest-path-with-alternating-colors) | Medium | -| 1128 | [Number of Equivalent Domino Pairs](https://leetcode.com/problems/number-of-equivalent-domino-pairs "等价多米诺骨牌对的数量") | [Go](problems/number-of-equivalent-domino-pairs) | Easy | -| 1127 | [User Purchase Platform](https://leetcode.com/problems/user-purchase-platform "用户购买平台") 🔒 | [MySQL](problems/user-purchase-platform) | Hard | -| 1126 | [Active Businesses](https://leetcode.com/problems/active-businesses "查询活跃业务") 🔒 | [MySQL](problems/active-businesses) | Medium | -| 1125 | [Smallest Sufficient Team](https://leetcode.com/problems/smallest-sufficient-team "最小的必要团队") | [Go](problems/smallest-sufficient-team) | Hard | -| 1124 | [Longest Well-Performing Interval](https://leetcode.com/problems/longest-well-performing-interval "表现良好的最长时间段") | [Go](problems/longest-well-performing-interval) | Medium | -| 1123 | [Lowest Common Ancestor of Deepest Leaves](https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves "最深叶节点的最近公共祖先") | [Go](problems/lowest-common-ancestor-of-deepest-leaves) | Medium | -| 1122 | [Relative Sort Array](https://leetcode.com/problems/relative-sort-array "数组的相对排序") | [Go](problems/relative-sort-array) | Easy | -| 1121 | [Divide Array Into Increasing Sequences](https://leetcode.com/problems/divide-array-into-increasing-sequences "将数组分成几个递增序列") 🔒 | [Go](problems/divide-array-into-increasing-sequences) | Hard | -| 1120 | [Maximum Average Subtree](https://leetcode.com/problems/maximum-average-subtree "子树的最大平均值") 🔒 | [Go](problems/maximum-average-subtree) | Medium | -| 1119 | [Remove Vowels from a String](https://leetcode.com/problems/remove-vowels-from-a-string "删去字符串中的元音") 🔒 | [Go](problems/remove-vowels-from-a-string) | Easy | -| 1118 | [Number of Days in a Month](https://leetcode.com/problems/number-of-days-in-a-month "一月有多少天") 🔒 | [Go](problems/number-of-days-in-a-month) | Easy | -| 1117 | [Building H2O](https://leetcode.com/problems/building-h2o "H2O 生成") | [Go](problems/building-h2o) | Medium | -| 1116 | [Print Zero Even Odd](https://leetcode.com/problems/print-zero-even-odd "打印零与奇偶数") | [Go](problems/print-zero-even-odd) | Medium | -| 1115 | [Print FooBar Alternately](https://leetcode.com/problems/print-foobar-alternately "交替打印FooBar") | [Go](problems/print-foobar-alternately) | Medium | -| 1114 | [Print in Order](https://leetcode.com/problems/print-in-order "按序打印") | [Go](problems/print-in-order) | Easy | -| 1113 | [Reported Posts](https://leetcode.com/problems/reported-posts "报告的记录") 🔒 | [MySQL](problems/reported-posts) | Easy | -| 1112 | [Highest Grade For Each Student](https://leetcode.com/problems/highest-grade-for-each-student "每位学生的最高成绩") 🔒 | [MySQL](problems/highest-grade-for-each-student) | Medium | -| 1111 | [Maximum Nesting Depth of Two Valid Parentheses Strings](https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings "有效括号的嵌套深度") | [Go](problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | Medium | -| 1110 | [Delete Nodes And Return Forest](https://leetcode.com/problems/delete-nodes-and-return-forest "删点成林") | [Go](problems/delete-nodes-and-return-forest) | Medium | -| 1109 | [Corporate Flight Bookings](https://leetcode.com/problems/corporate-flight-bookings "航班预订统计") | [Go](problems/corporate-flight-bookings) | Medium | -| 1108 | [Defanging an IP Address](https://leetcode.com/problems/defanging-an-ip-address "IP 地址无效化") | [Go](problems/defanging-an-ip-address) | Easy | -| 1107 | [New Users Daily Count](https://leetcode.com/problems/new-users-daily-count "每日新用户统计") 🔒 | [MySQL](problems/new-users-daily-count) | Medium | -| 1106 | [Parsing A Boolean Expression](https://leetcode.com/problems/parsing-a-boolean-expression "解析布尔表达式") | [Go](problems/parsing-a-boolean-expression) | Hard | -| 1105 | [Filling Bookcase Shelves](https://leetcode.com/problems/filling-bookcase-shelves "填充书架") | [Go](problems/filling-bookcase-shelves) | Medium | -| 1104 | [Path In Zigzag Labelled Binary Tree](https://leetcode.com/problems/path-in-zigzag-labelled-binary-tree "二叉树寻路") | [Go](problems/path-in-zigzag-labelled-binary-tree) | Medium | -| 1103 | [Distribute Candies to People](https://leetcode.com/problems/distribute-candies-to-people "分糖果 II") | [Go](problems/distribute-candies-to-people) | Easy | -| 1102 | [Path With Maximum Minimum Value](https://leetcode.com/problems/path-with-maximum-minimum-value "得分最高的路径") 🔒 | [Go](problems/path-with-maximum-minimum-value) | Medium | -| 1101 | [The Earliest Moment When Everyone Become Friends](https://leetcode.com/problems/the-earliest-moment-when-everyone-become-friends "彼此熟识的最早时间") 🔒 | [Go](problems/the-earliest-moment-when-everyone-become-friends) | Medium | -| 1100 | [Find K-Length Substrings With No Repeated Characters](https://leetcode.com/problems/find-k-length-substrings-with-no-repeated-characters "长度为 K 的无重复字符子串") 🔒 | [Go](problems/find-k-length-substrings-with-no-repeated-characters) | Medium | -| 1099 | [Two Sum Less Than K](https://leetcode.com/problems/two-sum-less-than-k "小于 K 的两数之和") 🔒 | [Go](problems/two-sum-less-than-k) | Easy | -| 1098 | [Unpopular Books](https://leetcode.com/problems/unpopular-books "小众书籍") 🔒 | [MySQL](problems/unpopular-books) | Medium | -| 1097 | [Game Play Analysis V](https://leetcode.com/problems/game-play-analysis-v "游戏玩法分析 V") 🔒 | [MySQL](problems/game-play-analysis-v) | Hard | -| 1096 | [Brace Expansion II](https://leetcode.com/problems/brace-expansion-ii "花括号展开 II") | [Go](problems/brace-expansion-ii) | Hard | -| 1095 | [Find in Mountain Array](https://leetcode.com/problems/find-in-mountain-array "山脉数组中查找目标值") | [Go](problems/find-in-mountain-array) | Hard | -| 1094 | [Car Pooling](https://leetcode.com/problems/car-pooling "拼车") | [Go](problems/car-pooling) | Medium | -| 1093 | [Statistics from a Large Sample](https://leetcode.com/problems/statistics-from-a-large-sample "大样本统计") | [Go](problems/statistics-from-a-large-sample) | Medium | -| 1092 | [Shortest Common Supersequence](https://leetcode.com/problems/shortest-common-supersequence "最短公共超序列") | [Go](problems/shortest-common-supersequence) | Hard | -| 1091 | [Shortest Path in Binary Matrix](https://leetcode.com/problems/shortest-path-in-binary-matrix "二进制矩阵中的最短路径") | [Go](problems/shortest-path-in-binary-matrix) | Medium | -| 1090 | [Largest Values From Labels](https://leetcode.com/problems/largest-values-from-labels "受标签影响的最大值") | [Go](problems/largest-values-from-labels) | Medium | -| 1089 | [Duplicate Zeros](https://leetcode.com/problems/duplicate-zeros "复写零") | [Go](problems/duplicate-zeros) | Easy | -| 1088 | [Confusing Number II](https://leetcode.com/problems/confusing-number-ii "易混淆数 II") 🔒 | [Go](problems/confusing-number-ii) | Hard | -| 1087 | [Brace Expansion](https://leetcode.com/problems/brace-expansion "字母切换") 🔒 | [Go](problems/brace-expansion) | Medium | -| 1086 | [High Five](https://leetcode.com/problems/high-five "前五科的均分") 🔒 | [Go](problems/high-five) | Easy | -| 1085 | [Sum of Digits in the Minimum Number](https://leetcode.com/problems/sum-of-digits-in-the-minimum-number "最小元素各数位之和") 🔒 | [Go](problems/sum-of-digits-in-the-minimum-number) | Easy | -| 1084 | [Sales Analysis III](https://leetcode.com/problems/sales-analysis-iii "销售分析III") 🔒 | [MySQL](problems/sales-analysis-iii) | Easy | -| 1083 | [Sales Analysis II](https://leetcode.com/problems/sales-analysis-ii "销售分析 II") 🔒 | [MySQL](problems/sales-analysis-ii) | Easy | -| 1082 | [Sales Analysis I](https://leetcode.com/problems/sales-analysis-i "销售分析 I ") 🔒 | [MySQL](problems/sales-analysis-i) | Easy | -| 1081 | [Smallest Subsequence of Distinct Characters](https://leetcode.com/problems/smallest-subsequence-of-distinct-characters "不同字符的最小子序列") | [Go](problems/smallest-subsequence-of-distinct-characters) | Medium | -| 1080 | [Insufficient Nodes in Root to Leaf Paths](https://leetcode.com/problems/insufficient-nodes-in-root-to-leaf-paths "根到叶路径上的不足节点") | [Go](problems/insufficient-nodes-in-root-to-leaf-paths) | Medium | -| 1079 | [Letter Tile Possibilities](https://leetcode.com/problems/letter-tile-possibilities "活字印刷") | [Go](problems/letter-tile-possibilities) | Medium | -| 1078 | [Occurrences After Bigram](https://leetcode.com/problems/occurrences-after-bigram "Bigram 分词") | [Go](problems/occurrences-after-bigram) | Easy | -| 1077 | [Project Employees III](https://leetcode.com/problems/project-employees-iii "项目员工 III") 🔒 | [MySQL](problems/project-employees-iii) | Medium | -| 1076 | [Project Employees II](https://leetcode.com/problems/project-employees-ii "项目员工II") 🔒 | [MySQL](problems/project-employees-ii) | Easy | -| 1075 | [Project Employees I](https://leetcode.com/problems/project-employees-i "项目员工 I") 🔒 | [MySQL](problems/project-employees-i) | Easy | -| 1074 | [Number of Submatrices That Sum to Target](https://leetcode.com/problems/number-of-submatrices-that-sum-to-target "元素和为目标值的子矩阵数量") | [Go](problems/number-of-submatrices-that-sum-to-target) | Hard | -| 1073 | [Adding Two Negabinary Numbers](https://leetcode.com/problems/adding-two-negabinary-numbers "负二进制数相加") | [Go](problems/adding-two-negabinary-numbers) | Medium | -| 1072 | [Flip Columns For Maximum Number of Equal Rows](https://leetcode.com/problems/flip-columns-for-maximum-number-of-equal-rows "按列翻转得到最大值等行数") | [Go](problems/flip-columns-for-maximum-number-of-equal-rows) | Medium | -| 1071 | [Greatest Common Divisor of Strings](https://leetcode.com/problems/greatest-common-divisor-of-strings "字符串的最大公因子") | [Go](problems/greatest-common-divisor-of-strings) | Easy | -| 1070 | [Product Sales Analysis III](https://leetcode.com/problems/product-sales-analysis-iii "产品销售分析 III") 🔒 | [MySQL](problems/product-sales-analysis-iii) | Medium | -| 1069 | [Product Sales Analysis II](https://leetcode.com/problems/product-sales-analysis-ii "产品销售分析 II") 🔒 | [MySQL](problems/product-sales-analysis-ii) | Easy | -| 1068 | [Product Sales Analysis I](https://leetcode.com/problems/product-sales-analysis-i "产品销售分析 I") 🔒 | [MySQL](problems/product-sales-analysis-i) | Easy | -| 1067 | [Digit Count in Range](https://leetcode.com/problems/digit-count-in-range "范围内的数字计数") 🔒 | [Go](problems/digit-count-in-range) | Hard | -| 1066 | [Campus Bikes II](https://leetcode.com/problems/campus-bikes-ii "校园自行车分配 II") 🔒 | [Go](problems/campus-bikes-ii) | Medium | -| 1065 | [Index Pairs of a String](https://leetcode.com/problems/index-pairs-of-a-string "字符串的索引对") 🔒 | [Go](problems/index-pairs-of-a-string) | Easy | -| 1064 | [Fixed Point](https://leetcode.com/problems/fixed-point "不动点") 🔒 | [Go](problems/fixed-point) | Easy | -| 1063 | [Number of Valid Subarrays](https://leetcode.com/problems/number-of-valid-subarrays "有效子数组的数目") 🔒 | [Go](problems/number-of-valid-subarrays) | Hard | -| 1062 | [Longest Repeating Substring](https://leetcode.com/problems/longest-repeating-substring "最长重复子串") 🔒 | [Go](problems/longest-repeating-substring) | Medium | -| 1061 | [Lexicographically Smallest Equivalent String](https://leetcode.com/problems/lexicographically-smallest-equivalent-string "按字典序排列最小的等效字符串") 🔒 | [Go](problems/lexicographically-smallest-equivalent-string) | Medium | -| 1060 | [Missing Element in Sorted Array](https://leetcode.com/problems/missing-element-in-sorted-array "有序数组中的缺失元素") 🔒 | [Go](problems/missing-element-in-sorted-array) | Medium | -| 1059 | [All Paths from Source Lead to Destination](https://leetcode.com/problems/all-paths-from-source-lead-to-destination "从始点到终点的所有路径") 🔒 | [Go](problems/all-paths-from-source-lead-to-destination) | Medium | -| 1058 | [Minimize Rounding Error to Meet Target](https://leetcode.com/problems/minimize-rounding-error-to-meet-target "最小化舍入误差以满足目标") 🔒 | [Go](problems/minimize-rounding-error-to-meet-target) | Medium | -| 1057 | [Campus Bikes](https://leetcode.com/problems/campus-bikes "校园自行车分配") 🔒 | [Go](problems/campus-bikes) | Medium | -| 1056 | [Confusing Number](https://leetcode.com/problems/confusing-number "易混淆数") 🔒 | [Go](problems/confusing-number) | Easy | -| 1055 | [Shortest Way to Form String](https://leetcode.com/problems/shortest-way-to-form-string "形成字符串的最短路径") 🔒 | [Go](problems/shortest-way-to-form-string) | Medium | -| 1054 | [Distant Barcodes](https://leetcode.com/problems/distant-barcodes "距离相等的条形码") | [Go](problems/distant-barcodes) | Medium | -| 1053 | [Previous Permutation With One Swap](https://leetcode.com/problems/previous-permutation-with-one-swap "交换一次的先前排列") | [Go](problems/previous-permutation-with-one-swap) | Medium | -| 1052 | [Grumpy Bookstore Owner](https://leetcode.com/problems/grumpy-bookstore-owner "爱生气的书店老板") | [Go](problems/grumpy-bookstore-owner) | Medium | -| 1051 | [Height Checker](https://leetcode.com/problems/height-checker "高度检查器") | [Go](problems/height-checker) | Easy | -| 1050 | [Actors and Directors Who Cooperated At Least Three Times](https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times "合作过至少三次的演员和导演") 🔒 | [MySQL](problems/actors-and-directors-who-cooperated-at-least-three-times) | Easy | -| 1049 | [Last Stone Weight II](https://leetcode.com/problems/last-stone-weight-ii "最后一块石头的重量 II") | [Go](problems/last-stone-weight-ii) | Medium | -| 1048 | [Longest String Chain](https://leetcode.com/problems/longest-string-chain "最长字符串链") | [Go](problems/longest-string-chain) | Medium | -| 1047 | [Remove All Adjacent Duplicates In String](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string "删除字符串中的所有相邻重复项") | [Go](problems/remove-all-adjacent-duplicates-in-string) | Easy | -| 1046 | [Last Stone Weight](https://leetcode.com/problems/last-stone-weight "最后一块石头的重量") | [Go](problems/last-stone-weight) | Easy | -| 1045 | [Customers Who Bought All Products](https://leetcode.com/problems/customers-who-bought-all-products "买下所有产品的客户") 🔒 | [MySQL](problems/customers-who-bought-all-products) | Medium | -| 1044 | [Longest Duplicate Substring](https://leetcode.com/problems/longest-duplicate-substring "最长重复子串") | [Go](problems/longest-duplicate-substring) | Hard | -| 1043 | [Partition Array for Maximum Sum](https://leetcode.com/problems/partition-array-for-maximum-sum "分隔数组以得到最大和") | [Go](problems/partition-array-for-maximum-sum) | Medium | -| 1042 | [Flower Planting With No Adjacent](https://leetcode.com/problems/flower-planting-with-no-adjacent "不邻接植花") | [Go](problems/flower-planting-with-no-adjacent) | Easy | -| 1041 | [Robot Bounded In Circle](https://leetcode.com/problems/robot-bounded-in-circle "困于环中的机器人") | [Go](problems/robot-bounded-in-circle) | Medium | -| 1040 | [Moving Stones Until Consecutive II](https://leetcode.com/problems/moving-stones-until-consecutive-ii "移动石子直到连续 II") | [Go](problems/moving-stones-until-consecutive-ii) | Medium | -| 1039 | [Minimum Score Triangulation of Polygon](https://leetcode.com/problems/minimum-score-triangulation-of-polygon "多边形三角剖分的最低得分") | [Go](problems/minimum-score-triangulation-of-polygon) | Medium | -| 1038 | [Binary Search Tree to Greater Sum Tree](https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree "从二叉搜索树到更大和树") | [Go](problems/binary-search-tree-to-greater-sum-tree) | Medium | -| 1037 | [Valid Boomerang](https://leetcode.com/problems/valid-boomerang "有效的回旋镖") | [Go](problems/valid-boomerang) | Easy | -| 1036 | [Escape a Large Maze](https://leetcode.com/problems/escape-a-large-maze "逃离大迷宫") | [Go](problems/escape-a-large-maze) | Hard | -| 1035 | [Uncrossed Lines](https://leetcode.com/problems/uncrossed-lines "不相交的线") | [Go](problems/uncrossed-lines) | Medium | -| 1034 | [Coloring A Border](https://leetcode.com/problems/coloring-a-border "边框着色") | [Go](problems/coloring-a-border) | Medium | -| 1033 | [Moving Stones Until Consecutive](https://leetcode.com/problems/moving-stones-until-consecutive "移动石子直到连续") | [Go](problems/moving-stones-until-consecutive) | Easy | -| 1032 | [Stream of Characters](https://leetcode.com/problems/stream-of-characters "字符流") | [Go](problems/stream-of-characters) | Hard | -| 1031 | [Maximum Sum of Two Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays "两个非重叠子数组的最大和") | [Go](problems/maximum-sum-of-two-non-overlapping-subarrays) | Medium | -| 1030 | [Matrix Cells in Distance Order](https://leetcode.com/problems/matrix-cells-in-distance-order "距离顺序排列矩阵单元格") | [Go](problems/matrix-cells-in-distance-order) | Easy | -| 1029 | [Two City Scheduling](https://leetcode.com/problems/two-city-scheduling "两地调度") | [Go](problems/two-city-scheduling) | Easy | -| 1028 | [Recover a Tree From Preorder Traversal](https://leetcode.com/problems/recover-a-tree-from-preorder-traversal "从先序遍历还原二叉树") | [Go](problems/recover-a-tree-from-preorder-traversal) | Hard | -| 1027 | [Longest Arithmetic Sequence](https://leetcode.com/problems/longest-arithmetic-sequence "最长等差数列") | [Go](problems/longest-arithmetic-sequence) | Medium | -| 1026 | [Maximum Difference Between Node and Ancestor](https://leetcode.com/problems/maximum-difference-between-node-and-ancestor "节点与其祖先之间的最大差值") | [Go](problems/maximum-difference-between-node-and-ancestor) | Medium | -| 1025 | [Divisor Game](https://leetcode.com/problems/divisor-game "除数博弈") | [Go](problems/divisor-game) | Easy | -| 1024 | [Video Stitching](https://leetcode.com/problems/video-stitching "视频拼接") | [Go](problems/video-stitching) | Medium | -| 1023 | [Camelcase Matching](https://leetcode.com/problems/camelcase-matching "驼峰式匹配") | [Go](problems/camelcase-matching) | Medium | -| 1022 | [Sum of Root To Leaf Binary Numbers](https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers "从根到叶的二进制数之和") | [Go](problems/sum-of-root-to-leaf-binary-numbers) | Easy | -| 1021 | [Remove Outermost Parentheses](https://leetcode.com/problems/remove-outermost-parentheses "删除最外层的括号") | [Go](problems/remove-outermost-parentheses) | Easy | -| 1020 | [Number of Enclaves](https://leetcode.com/problems/number-of-enclaves "飞地的数量") | [Go](problems/number-of-enclaves) | Medium | -| 1019 | [Next Greater Node In Linked List](https://leetcode.com/problems/next-greater-node-in-linked-list "链表中的下一个更大节点") | [Go](problems/next-greater-node-in-linked-list) | Medium | -| 1018 | [Binary Prefix Divisible By 5](https://leetcode.com/problems/binary-prefix-divisible-by-5 "可被 5 整除的二进制前缀") | [Go](problems/binary-prefix-divisible-by-5) | Easy | -| 1017 | [Convert to Base -2](https://leetcode.com/problems/convert-to-base-2 "负二进制转换") | [Go](problems/convert-to-base-2) | Medium | -| 1016 | [Binary String With Substrings Representing 1 To N](https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n "子串能表示从 1 到 N 数字的二进制串") | [Go](problems/binary-string-with-substrings-representing-1-to-n) | Medium | -| 1015 | [Smallest Integer Divisible by K](https://leetcode.com/problems/smallest-integer-divisible-by-k "可被 K 整除的最小整数") | [Go](problems/smallest-integer-divisible-by-k) | Medium | -| 1014 | [Best Sightseeing Pair](https://leetcode.com/problems/best-sightseeing-pair "最佳观光组合") | [Go](problems/best-sightseeing-pair) | Medium | -| 1013 | [Partition Array Into Three Parts With Equal Sum](https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum "将数组分成和相等的三个部分") | [Go](problems/partition-array-into-three-parts-with-equal-sum) | Easy | -| 1012 | [Numbers With Repeated Digits](https://leetcode.com/problems/numbers-with-repeated-digits "至少有 1 位重复的数字") | [Go](problems/numbers-with-repeated-digits) | Hard | -| 1011 | [Capacity To Ship Packages Within D Days](https://leetcode.com/problems/capacity-to-ship-packages-within-d-days "在 D 天内送达包裹的能力") | [Go](problems/capacity-to-ship-packages-within-d-days) | Medium | -| 1010 | [Pairs of Songs With Total Durations Divisible by 60](https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60 "总持续时间可被 60 整除的歌曲") | [Go](problems/pairs-of-songs-with-total-durations-divisible-by-60) | Easy | -| 1009 | [Complement of Base 10 Integer](https://leetcode.com/problems/complement-of-base-10-integer "十进制整数的反码") | [Go](problems/complement-of-base-10-integer) | Easy | -| 1008 | [Construct Binary Search Tree from Preorder Traversal](https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal "先序遍历构造二叉树") | [Go](problems/construct-binary-search-tree-from-preorder-traversal) | Medium | -| 1007 | [Minimum Domino Rotations For Equal Row](https://leetcode.com/problems/minimum-domino-rotations-for-equal-row "行相等的最少多米诺旋转") | [Go](problems/minimum-domino-rotations-for-equal-row) | Medium | -| 1006 | [Clumsy Factorial](https://leetcode.com/problems/clumsy-factorial "笨阶乘") | [Go](problems/clumsy-factorial) | Medium | -| 1005 | [Maximize Sum Of Array After K Negations](https://leetcode.com/problems/maximize-sum-of-array-after-k-negations "K 次取反后最大化的数组和") | [Go](problems/maximize-sum-of-array-after-k-negations) | Easy | -| 1004 | [Max Consecutive Ones III](https://leetcode.com/problems/max-consecutive-ones-iii "最大连续1的个数 III") | [Go](problems/max-consecutive-ones-iii) | Medium | -| 1003 | [Check If Word Is Valid After Substitutions](https://leetcode.com/problems/check-if-word-is-valid-after-substitutions "检查替换后的词是否有效") | [Go](problems/check-if-word-is-valid-after-substitutions) | Medium | -| 1002 | [Find Common Characters](https://leetcode.com/problems/find-common-characters "查找常用字符") | [Go](problems/find-common-characters) | Easy | -| 1001 | [Grid Illumination](https://leetcode.com/problems/grid-illumination "网格照明") | [Go](problems/grid-illumination) | Hard | -| 1000 | [Minimum Cost to Merge Stones](https://leetcode.com/problems/minimum-cost-to-merge-stones "合并石头的最低成本") | [Go](problems/minimum-cost-to-merge-stones) | Hard | -| 999 | [Available Captures for Rook](https://leetcode.com/problems/available-captures-for-rook "可以被一步捕获的棋子数") | [Go](problems/available-captures-for-rook) | Easy | -| 998 | [Maximum Binary Tree II](https://leetcode.com/problems/maximum-binary-tree-ii "最大二叉树 II") | [Go](problems/maximum-binary-tree-ii) | Medium | -| 997 | [Find the Town Judge](https://leetcode.com/problems/find-the-town-judge "找到小镇的法官") | [Go](problems/find-the-town-judge) | Easy | -| 996 | [Number of Squareful Arrays](https://leetcode.com/problems/number-of-squareful-arrays "正方形数组的数目") | [Go](problems/number-of-squareful-arrays) | Hard | -| 995 | [Minimum Number of K Consecutive Bit Flips](https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips "K 连续位的最小翻转次数") | [Go](problems/minimum-number-of-k-consecutive-bit-flips) | Hard | -| 994 | [Rotting Oranges](https://leetcode.com/problems/rotting-oranges "腐烂的橘子") | [Go](problems/rotting-oranges) | Medium | -| 993 | [Cousins in Binary Tree](https://leetcode.com/problems/cousins-in-binary-tree "二叉树的堂兄弟节点") | [Go](problems/cousins-in-binary-tree) | Easy | -| 992 | [Subarrays with K Different Integers](https://leetcode.com/problems/subarrays-with-k-different-integers "K 个不同整数的子数组") | [Go](problems/subarrays-with-k-different-integers) | Hard | -| 991 | [Broken Calculator](https://leetcode.com/problems/broken-calculator "坏了的计算器") | [Go](problems/broken-calculator) | Medium | -| 990 | [Satisfiability of Equality Equations](https://leetcode.com/problems/satisfiability-of-equality-equations "等式方程的可满足性") | [Go](problems/satisfiability-of-equality-equations) | Medium | -| 989 | [Add to Array-Form of Integer](https://leetcode.com/problems/add-to-array-form-of-integer "数组形式的整数加法") | [Go](problems/add-to-array-form-of-integer) | Easy | -| 988 | [Smallest String Starting From Leaf](https://leetcode.com/problems/smallest-string-starting-from-leaf "从叶结点开始的最小字符串") | [Go](problems/smallest-string-starting-from-leaf) | Medium | -| 987 | [Vertical Order Traversal of a Binary Tree](https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree "二叉树的垂序遍历") | [Go](problems/vertical-order-traversal-of-a-binary-tree) | Medium | -| 986 | [Interval List Intersections](https://leetcode.com/problems/interval-list-intersections "区间列表的交集") | [Go](problems/interval-list-intersections) | Medium | -| 985 | [Sum of Even Numbers After Queries](https://leetcode.com/problems/sum-of-even-numbers-after-queries "查询后的偶数和") | [Go](problems/sum-of-even-numbers-after-queries) | Easy | -| 984 | [String Without AAA or BBB](https://leetcode.com/problems/string-without-aaa-or-bbb "不含 AAA 或 BBB 的字符串") | [Go](problems/string-without-aaa-or-bbb) | Medium | -| 983 | [Minimum Cost For Tickets](https://leetcode.com/problems/minimum-cost-for-tickets "最低票价") | [Go](problems/minimum-cost-for-tickets) | Medium | -| 982 | [Triples with Bitwise AND Equal To Zero](https://leetcode.com/problems/triples-with-bitwise-and-equal-to-zero "按位与为零的三元组") | [Go](problems/triples-with-bitwise-and-equal-to-zero) | Hard | -| 981 | [Time Based Key-Value Store](https://leetcode.com/problems/time-based-key-value-store "基于时间的键值存储") | [Go](problems/time-based-key-value-store) | Medium | -| 980 | [Unique Paths III](https://leetcode.com/problems/unique-paths-iii "不同路径 III") | [Go](problems/unique-paths-iii) | Hard | -| 979 | [Distribute Coins in Binary Tree](https://leetcode.com/problems/distribute-coins-in-binary-tree "在二叉树中分配硬币") | [Go](problems/distribute-coins-in-binary-tree) | Medium | -| 978 | [Longest Turbulent Subarray](https://leetcode.com/problems/longest-turbulent-subarray "最长湍流子数组") | [Go](problems/longest-turbulent-subarray) | Medium | -| 977 | [Squares of a Sorted Array](https://leetcode.com/problems/squares-of-a-sorted-array "有序数组的平方") | [Go](problems/squares-of-a-sorted-array) | Easy | -| 976 | [Largest Perimeter Triangle](https://leetcode.com/problems/largest-perimeter-triangle "三角形的最大周长") | [Go](problems/largest-perimeter-triangle) | Easy | -| 975 | [Odd Even Jump](https://leetcode.com/problems/odd-even-jump "奇偶跳") | [Go](problems/odd-even-jump) | Hard | -| 974 | [Subarray Sums Divisible by K](https://leetcode.com/problems/subarray-sums-divisible-by-k "和可被 K 整除的子数组") | [Go](problems/subarray-sums-divisible-by-k) | Medium | -| 973 | [K Closest Points to Origin](https://leetcode.com/problems/k-closest-points-to-origin "最接近原点的 K 个点") | [Go](problems/k-closest-points-to-origin) | Medium | -| 972 | [Equal Rational Numbers](https://leetcode.com/problems/equal-rational-numbers "相等的有理数") | [Go](problems/equal-rational-numbers) | Hard | -| 971 | [Flip Binary Tree To Match Preorder Traversal](https://leetcode.com/problems/flip-binary-tree-to-match-preorder-traversal "翻转二叉树以匹配先序遍历") | [Go](problems/flip-binary-tree-to-match-preorder-traversal) | Medium | -| 970 | [Powerful Integers](https://leetcode.com/problems/powerful-integers "强整数") | [Go](problems/powerful-integers) | Easy | -| 969 | [Pancake Sorting](https://leetcode.com/problems/pancake-sorting "煎饼排序") | [Go](problems/pancake-sorting) | Medium | -| 968 | [Binary Tree Cameras](https://leetcode.com/problems/binary-tree-cameras "监控二叉树") | [Go](problems/binary-tree-cameras) | Hard | -| 967 | [Numbers With Same Consecutive Differences](https://leetcode.com/problems/numbers-with-same-consecutive-differences "连续差相同的数字") | [Go](problems/numbers-with-same-consecutive-differences) | Medium | -| 966 | [Vowel Spellchecker](https://leetcode.com/problems/vowel-spellchecker "元音拼写检查器") | [Go](problems/vowel-spellchecker) | Medium | -| 965 | [Univalued Binary Tree](https://leetcode.com/problems/univalued-binary-tree "单值二叉树") | [Go](problems/univalued-binary-tree) | Easy | -| 964 | [Least Operators to Express Number](https://leetcode.com/problems/least-operators-to-express-number "表示数字的最少运算符") | [Go](problems/least-operators-to-express-number) | Hard | -| 963 | [Minimum Area Rectangle II](https://leetcode.com/problems/minimum-area-rectangle-ii "最小面积矩形 II") | [Go](problems/minimum-area-rectangle-ii) | Medium | -| 962 | [Maximum Width Ramp](https://leetcode.com/problems/maximum-width-ramp "最大宽度坡") | [Go](problems/maximum-width-ramp) | Medium | -| 961 | [N-Repeated Element in Size 2N Array](https://leetcode.com/problems/n-repeated-element-in-size-2n-array "重复 N 次的元素") | [Go](problems/n-repeated-element-in-size-2n-array) | Easy | -| 960 | [Delete Columns to Make Sorted III](https://leetcode.com/problems/delete-columns-to-make-sorted-iii "删列造序 III") | [Go](problems/delete-columns-to-make-sorted-iii) | Hard | -| 959 | [Regions Cut By Slashes](https://leetcode.com/problems/regions-cut-by-slashes "由斜杠划分区域") | [Go](problems/regions-cut-by-slashes) | Medium | -| 958 | [Check Completeness of a Binary Tree](https://leetcode.com/problems/check-completeness-of-a-binary-tree "二叉树的完全性检验") | [Go](problems/check-completeness-of-a-binary-tree) | Medium | -| 957 | [Prison Cells After N Days](https://leetcode.com/problems/prison-cells-after-n-days "N 天后的牢房") | [Go](problems/prison-cells-after-n-days) | Medium | -| 956 | [Tallest Billboard](https://leetcode.com/problems/tallest-billboard "最高的广告牌") | [Go](problems/tallest-billboard) | Hard | -| 955 | [Delete Columns to Make Sorted II](https://leetcode.com/problems/delete-columns-to-make-sorted-ii "删列造序 II") | [Go](problems/delete-columns-to-make-sorted-ii) | Medium | -| 954 | [Array of Doubled Pairs](https://leetcode.com/problems/array-of-doubled-pairs "二倍数对数组") | [Go](problems/array-of-doubled-pairs) | Medium | -| 953 | [Verifying an Alien Dictionary](https://leetcode.com/problems/verifying-an-alien-dictionary "验证外星语词典") | [Go](problems/verifying-an-alien-dictionary) | Easy | -| 952 | [Largest Component Size by Common Factor](https://leetcode.com/problems/largest-component-size-by-common-factor "按公因数计算最大组件大小") | [Go](problems/largest-component-size-by-common-factor) | Hard | -| 951 | [Flip Equivalent Binary Trees](https://leetcode.com/problems/flip-equivalent-binary-trees "翻转等价二叉树") | [Go](problems/flip-equivalent-binary-trees) | Medium | -| 950 | [Reveal Cards In Increasing Order](https://leetcode.com/problems/reveal-cards-in-increasing-order "按递增顺序显示卡牌") | [Go](problems/reveal-cards-in-increasing-order) | Medium | -| 949 | [Largest Time for Given Digits](https://leetcode.com/problems/largest-time-for-given-digits "给定数字能组成的最大时间") | [Go](problems/largest-time-for-given-digits) | Easy | -| 948 | [Bag of Tokens](https://leetcode.com/problems/bag-of-tokens "令牌放置") | [Go](problems/bag-of-tokens) | Medium | -| 947 | [Most Stones Removed with Same Row or Column](https://leetcode.com/problems/most-stones-removed-with-same-row-or-column "移除最多的同行或同列石头") | [Go](problems/most-stones-removed-with-same-row-or-column) | Medium | -| 946 | [Validate Stack Sequences](https://leetcode.com/problems/validate-stack-sequences "验证栈序列") | [Go](problems/validate-stack-sequences) | Medium | -| 945 | [Minimum Increment to Make Array Unique](https://leetcode.com/problems/minimum-increment-to-make-array-unique "使数组唯一的最小增量") | [Go](problems/minimum-increment-to-make-array-unique) | Medium | -| 944 | [Delete Columns to Make Sorted](https://leetcode.com/problems/delete-columns-to-make-sorted "删列造序") | [Go](problems/delete-columns-to-make-sorted) | Easy | -| 943 | [Find the Shortest Superstring](https://leetcode.com/problems/find-the-shortest-superstring "最短超级串") | [Go](problems/find-the-shortest-superstring) | Hard | -| 942 | [DI String Match](https://leetcode.com/problems/di-string-match "增减字符串匹配") | [Go](problems/di-string-match) | Easy | -| 941 | [Valid Mountain Array](https://leetcode.com/problems/valid-mountain-array "有效的山脉数组") | [Go](problems/valid-mountain-array) | Easy | -| 940 | [Distinct Subsequences II](https://leetcode.com/problems/distinct-subsequences-ii "不同的子序列 II") | [Go](problems/distinct-subsequences-ii) | Hard | -| 939 | [Minimum Area Rectangle](https://leetcode.com/problems/minimum-area-rectangle "最小面积矩形") | [Go](problems/minimum-area-rectangle) | Medium | -| 938 | [Range Sum of BST](https://leetcode.com/problems/range-sum-of-bst "二叉搜索树的范围和") | [Go](problems/range-sum-of-bst) | Easy | -| 937 | [Reorder Data in Log Files](https://leetcode.com/problems/reorder-data-in-log-files "重新排列日志文件") | [Go](problems/reorder-data-in-log-files) | Easy | -| 936 | [Stamping The Sequence](https://leetcode.com/problems/stamping-the-sequence "戳印序列") | [Go](problems/stamping-the-sequence) | Hard | -| 935 | [Knight Dialer](https://leetcode.com/problems/knight-dialer "骑士拨号器") | [Go](problems/knight-dialer) | Medium | -| 934 | [Shortest Bridge](https://leetcode.com/problems/shortest-bridge "最短的桥") | [Go](problems/shortest-bridge) | Medium | -| 933 | [Number of Recent Calls](https://leetcode.com/problems/number-of-recent-calls "最近的请求次数") | [Go](problems/number-of-recent-calls) | Easy | -| 932 | [Beautiful Array](https://leetcode.com/problems/beautiful-array "漂亮数组") | [Go](problems/beautiful-array) | Medium | -| 931 | [Minimum Falling Path Sum](https://leetcode.com/problems/minimum-falling-path-sum "下降路径最小和") | [Go](problems/minimum-falling-path-sum) | Medium | -| 930 | [Binary Subarrays With Sum](https://leetcode.com/problems/binary-subarrays-with-sum "和相同的二元子数组") | [Go](problems/binary-subarrays-with-sum) | Medium | -| 929 | [Unique Email Addresses](https://leetcode.com/problems/unique-email-addresses "独特的电子邮件地址") | [Go](problems/unique-email-addresses) | Easy | -| 928 | [Minimize Malware Spread II](https://leetcode.com/problems/minimize-malware-spread-ii "尽量减少恶意软件的传播 II") | [Go](problems/minimize-malware-spread-ii) | Hard | -| 927 | [Three Equal Parts](https://leetcode.com/problems/three-equal-parts "三等分") | [Go](problems/three-equal-parts) | Hard | -| 926 | [Flip String to Monotone Increasing](https://leetcode.com/problems/flip-string-to-monotone-increasing "将字符串翻转到单调递增") | [Go](problems/flip-string-to-monotone-increasing) | Medium | -| 925 | [Long Pressed Name](https://leetcode.com/problems/long-pressed-name "长按键入") | [Go](problems/long-pressed-name) | Easy | -| 924 | [Minimize Malware Spread](https://leetcode.com/problems/minimize-malware-spread "尽量减少恶意软件的传播") | [Go](problems/minimize-malware-spread) | Hard | -| 923 | [3Sum With Multiplicity](https://leetcode.com/problems/3sum-with-multiplicity "三数之和的多种可能") | [Go](problems/3sum-with-multiplicity) | Medium | -| 922 | [Sort Array By Parity II](https://leetcode.com/problems/sort-array-by-parity-ii "按奇偶排序数组 II") | [Go](problems/sort-array-by-parity-ii) | Easy | -| 921 | [Minimum Add to Make Parentheses Valid](https://leetcode.com/problems/minimum-add-to-make-parentheses-valid "使括号有效的最少添加") | [Go](problems/minimum-add-to-make-parentheses-valid) | Medium | -| 920 | [Number of Music Playlists](https://leetcode.com/problems/number-of-music-playlists "播放列表的数量") | [Go](problems/number-of-music-playlists) | Hard | -| 919 | [Complete Binary Tree Inserter](https://leetcode.com/problems/complete-binary-tree-inserter "完全二叉树插入器") | [Go](problems/complete-binary-tree-inserter) | Medium | -| 918 | [Maximum Sum Circular Subarray](https://leetcode.com/problems/maximum-sum-circular-subarray "环形子数组的最大和") | [Go](problems/maximum-sum-circular-subarray) | Medium | -| 917 | [Reverse Only Letters](https://leetcode.com/problems/reverse-only-letters "仅仅反转字母") | [Go](problems/reverse-only-letters) | Easy | -| 916 | [Word Subsets](https://leetcode.com/problems/word-subsets "单词子集") | [Go](problems/word-subsets) | Medium | -| 915 | [Partition Array into Disjoint Intervals](https://leetcode.com/problems/partition-array-into-disjoint-intervals "分割数组") | [Go](problems/partition-array-into-disjoint-intervals) | Medium | -| 914 | [X of a Kind in a Deck of Cards](https://leetcode.com/problems/x-of-a-kind-in-a-deck-of-cards "卡牌分组") | [Go](problems/x-of-a-kind-in-a-deck-of-cards) | Easy | -| 913 | [Cat and Mouse](https://leetcode.com/problems/cat-and-mouse "猫和老鼠") | [Go](problems/cat-and-mouse) | Hard | -| 912 | [Sort an Array](https://leetcode.com/problems/sort-an-array "排序数组") | [Go](problems/sort-an-array) | Medium | -| 911 | [Online Election](https://leetcode.com/problems/online-election "在线选举") | [Go](problems/online-election) | Medium | -| 910 | [Smallest Range II](https://leetcode.com/problems/smallest-range-ii "最小差值 II") | [Go](problems/smallest-range-ii) | Medium | -| 909 | [Snakes and Ladders](https://leetcode.com/problems/snakes-and-ladders "蛇梯棋") | [Go](problems/snakes-and-ladders) | Medium | -| 908 | [Smallest Range I](https://leetcode.com/problems/smallest-range-i "最小差值 I") | [Go](problems/smallest-range-i) | Easy | -| 907 | [Sum of Subarray Minimums](https://leetcode.com/problems/sum-of-subarray-minimums "子数组的最小值之和") | [Go](problems/sum-of-subarray-minimums) | Medium | -| 906 | [Super Palindromes](https://leetcode.com/problems/super-palindromes "超级回文数") | [Go](problems/super-palindromes) | Hard | -| 905 | [Sort Array By Parity](https://leetcode.com/problems/sort-array-by-parity "按奇偶排序数组") | [Go](problems/sort-array-by-parity) | Easy | -| 904 | [Fruit Into Baskets](https://leetcode.com/problems/fruit-into-baskets "水果成篮") | [Go](problems/fruit-into-baskets) | Medium | -| 903 | [Valid Permutations for DI Sequence](https://leetcode.com/problems/valid-permutations-for-di-sequence "DI 序列的有效排列") | [Go](problems/valid-permutations-for-di-sequence) | Hard | -| 902 | [Numbers At Most N Given Digit Set](https://leetcode.com/problems/numbers-at-most-n-given-digit-set "最大为 N 的数字组合") | [Go](problems/numbers-at-most-n-given-digit-set) | Hard | -| 901 | [Online Stock Span](https://leetcode.com/problems/online-stock-span "股票价格跨度") | [Go](problems/online-stock-span) | Medium | diff --git a/problems/can-make-arithmetic-progression-from-sequence/README.md b/problems/can-make-arithmetic-progression-from-sequence/README.md new file mode 100644 index 000000000..345961092 --- /dev/null +++ b/problems/can-make-arithmetic-progression-from-sequence/README.md @@ -0,0 +1,56 @@ + + + + + + + +[< Previous](../countries-you-can-safely-invest-in "Countries You Can Safely Invest In") +                 +[Next >](../last-moment-before-all-ants-fall-out-of-a-plank "Last Moment Before All Ants Fall Out of a Plank") + +## [1502. Can Make Arithmetic Progression From Sequence (Easy)](https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence "判断能否形成等差数列") + +

      Given an array of numbers arr. A sequence of numbers is called an arithmetic progression if the difference between any two consecutive elements is the same.

      + +

      Return true if the array can be rearranged to form an arithmetic progression, otherwise, return false.

      + +

       

      +

      Example 1:

      + +
      +Input: arr = [3,5,1]
      +Output: true
      +Explanation: We can reorder the elements as [1,3,5] or [5,3,1] with differences 2 and -2 respectively, between each consecutive elements.
      +
      + +

      Example 2:

      + +
      +Input: arr = [1,2,4]
      +Output: false
      +Explanation: There is no way to reorder the elements to obtain an arithmetic progression.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 2 <= arr.length <= 1000
      • +
      • -10^6 <= arr[i] <= 10^6
      • +
      + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
      +Hint 1 +Consider that any valid arithmetic progression will be in sorted order. +
      + +
      +Hint 2 +Sort the array, then check if the differences of all consecutive elements are equal. +
      diff --git a/problems/count-numbers-with-unique-digits/README.md b/problems/count-numbers-with-unique-digits/README.md index 9aed98006..42e4f0f8f 100644 --- a/problems/count-numbers-with-unique-digits/README.md +++ b/problems/count-numbers-with-unique-digits/README.md @@ -23,6 +23,12 @@   excluding 11,22,33,44,55,66,77,88,99 +

       

      +

      Constraints:

      + +
        +
      • 0 <= n <= 8
      • +
      ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/count-submatrices-with-all-ones/README.md b/problems/count-submatrices-with-all-ones/README.md new file mode 100644 index 000000000..a6a872b36 --- /dev/null +++ b/problems/count-submatrices-with-all-ones/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../last-moment-before-all-ants-fall-out-of-a-plank "Last Moment Before All Ants Fall Out of a Plank") +                 +[Next >](../minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "Minimum Possible Integer After at Most K Adjacent Swaps On Digits") + +## [1504. Count Submatrices With All Ones (Medium)](https://leetcode.com/problems/count-submatrices-with-all-ones "统计全 1 子矩形") + +

      Given a rows * columns matrix mat of ones and zeros, return how many submatrices have all ones.

      + +

       

      +

      Example 1:

      + +
      +Input: mat = [[1,0,1],
      +              [1,1,0],
      +              [1,1,0]]
      +Output: 13
      +Explanation:
      +There are 6 rectangles of side 1x1.
      +There are 2 rectangles of side 1x2.
      +There are 3 rectangles of side 2x1.
      +There is 1 rectangle of side 2x2. 
      +There is 1 rectangle of side 3x1.
      +Total number of rectangles = 6 + 2 + 3 + 1 + 1 = 13.
      +
      + +

      Example 2:

      + +
      +Input: mat = [[0,1,1,0],
      +              [0,1,1,1],
      +              [1,1,1,0]]
      +Output: 24
      +Explanation:
      +There are 8 rectangles of side 1x1.
      +There are 5 rectangles of side 1x2.
      +There are 2 rectangles of side 1x3. 
      +There are 4 rectangles of side 2x1.
      +There are 2 rectangles of side 2x2. 
      +There are 2 rectangles of side 3x1. 
      +There is 1 rectangle of side 3x2. 
      +Total number of rectangles = 8 + 5 + 2 + 4 + 2 + 2 + 1 = 24.
      +
      + +

      Example 3:

      + +
      +Input: mat = [[1,1,1,1,1,1]]
      +Output: 21
      +
      + +

      Example 4:

      + +
      +Input: mat = [[1,0,1],[0,1,0],[1,0,1]]
      +Output: 5
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= rows <= 150
      • +
      • 1 <= columns <= 150
      • +
      • 0 <= mat[i][j] <= 1
      • +
      + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
      +Hint 1 +For each row i, create an array nums where: if mat[i][j] == 0 then nums[j] = 0 else nums[j] = nums[j-1] +1. +
      + +
      +Hint 2 +In the row i, number of rectangles between column j and k(inclusive) and ends in row i, is equal to SUM(min(nums[j, .. idx])) where idx go from j to k. Expected solution is O(n^3). +
      diff --git a/problems/countries-you-can-safely-invest-in/README.md b/problems/countries-you-can-safely-invest-in/README.md new file mode 100644 index 000000000..2d037428f --- /dev/null +++ b/problems/countries-you-can-safely-invest-in/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../design-a-file-sharing-system "Design a File Sharing System") +                 +[Next >](../can-make-arithmetic-progression-from-sequence "Can Make Arithmetic Progression From Sequence") + +## [1501. Countries You Can Safely Invest In (Medium)](https://leetcode.com/problems/countries-you-can-safely-invest-in "") + + diff --git a/problems/countries-you-can-safely-invest-in/mysql_schemas.sql b/problems/countries-you-can-safely-invest-in/mysql_schemas.sql new file mode 100644 index 000000000..ca07cd0eb --- /dev/null +++ b/problems/countries-you-can-safely-invest-in/mysql_schemas.sql @@ -0,0 +1,27 @@ +Create table If Not Exists Person (id int, name varchar(15), phone_number varchar(11)); +Create table If Not Exists Country (name varchar(15), country_code varchar(3)); +Create table If Not Exists Calls (caller_id int, callee_id int, duration int); +Truncate table Person; +insert into Person (id, name, phone_number) values ('3', 'Jonathan', '051-1234567'); +insert into Person (id, name, phone_number) values ('12', 'Elvis', '051-7654321'); +insert into Person (id, name, phone_number) values ('1', 'Moncef', '212-1234567'); +insert into Person (id, name, phone_number) values ('2', 'Maroua', '212-6523651'); +insert into Person (id, name, phone_number) values ('7', 'Meir', '972-1234567'); +insert into Person (id, name, phone_number) values ('9', 'Rachel', '972-0011100'); +Truncate table Country; +insert into Country (name, country_code) values ('Peru', '051'); +insert into Country (name, country_code) values ('Israel', '972'); +insert into Country (name, country_code) values ('Morocco', '212'); +insert into Country (name, country_code) values ('Germany', '049'); +insert into Country (name, country_code) values ('Ethiopia', '251'); +Truncate table Calls; +insert into Calls (caller_id, callee_id, duration) values ('1', '9', '33'); +insert into Calls (caller_id, callee_id, duration) values ('2', '9', '4'); +insert into Calls (caller_id, callee_id, duration) values ('1', '2', '59'); +insert into Calls (caller_id, callee_id, duration) values ('3', '12', '102'); +insert into Calls (caller_id, callee_id, duration) values ('3', '12', '330'); +insert into Calls (caller_id, callee_id, duration) values ('12', '3', '5'); +insert into Calls (caller_id, callee_id, duration) values ('7', '9', '13'); +insert into Calls (caller_id, callee_id, duration) values ('7', '1', '3'); +insert into Calls (caller_id, callee_id, duration) values ('9', '7', '1'); +insert into Calls (caller_id, callee_id, duration) values ('1', '7', '7'); diff --git a/problems/design-a-file-sharing-system/README.md b/problems/design-a-file-sharing-system/README.md new file mode 100644 index 000000000..62a3064ae --- /dev/null +++ b/problems/design-a-file-sharing-system/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../max-value-of-equation "Max Value of Equation") +                 +[Next >](../countries-you-can-safely-invest-in "Countries You Can Safely Invest In") + +## [1500. Design a File Sharing System (Medium)](https://leetcode.com/problems/design-a-file-sharing-system "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
      +Hint 1 +Try to solve it by keeping for each file chunk, the users who have this chunk. +
      + +
      +Hint 2 +Try to solve it by keeping all the users in the system with their owned chunks, and when you request a chunk, check all users for it. +
      diff --git a/problems/employee-importance/README.md b/problems/employee-importance/README.md index 16fda8047..4ff109f56 100644 --- a/problems/employee-importance/README.md +++ b/problems/employee-importance/README.md @@ -11,11 +11,11 @@ ## [690. Employee Importance (Easy)](https://leetcode.com/problems/employee-importance "员工的重要性") -

      You are given a data structure of employee information, which includes the employee's unique id, his importance value and his direct subordinates' id.

      +

      You are given a data structure of employee information, which includes the employee's unique id, their importance value and their direct subordinates' id.

      For example, employee 1 is the leader of employee 2, and employee 2 is the leader of employee 3. They have importance value 15, 10 and 5, respectively. Then employee 1 has a data structure like [1, 15, [2]], and employee 2 has [2, 10, [3]], and employee 3 has [3, 5, []]. Note that although employee 3 is also a subordinate of employee 1, the relationship is not direct.

      -

      Now given the employee information of a company, and an employee id, you need to return the total importance value of this employee and all his subordinates.

      +

      Now given the employee information of a company, and an employee id, you need to return the total importance value of this employee and all their subordinates.

      Example 1:

      @@ -35,8 +35,6 @@ Employee 1 has importance value 5, and he has two direct subordinates: employee
    8. The maximum number of employees won't exceed 2000.
    -

     

    - ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md b/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md new file mode 100644 index 000000000..e1b5c38bb --- /dev/null +++ b/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md @@ -0,0 +1,93 @@ + + + + + + + +[< Previous](../can-make-arithmetic-progression-from-sequence "Can Make Arithmetic Progression From Sequence") +                 +[Next >](../count-submatrices-with-all-ones "Count Submatrices With All Ones") + +## [1503. Last Moment Before All Ants Fall Out of a Plank (Medium)](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank "所有蚂蚁掉下来前的最后一刻") + +

    We have a wooden plank of the length n units. Some ants are walking on the plank, each ant moves with speed 1 unit per second. Some of the ants move to the left, the other move to the right.

    + +

    When two ants moving in two different directions meet at some point, they change their directions and continue moving again. Assume changing directions doesn't take any additional time.

    + +

    When an ant reaches one end of the plank at a time t, it falls out of the plank imediately.

    + +

    Given an integer n and two integer arrays left and right, the positions of the ants moving to the left and the right. Return the moment when the last ant(s) fall out of the plank.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 4, left = [4,3], right = [0,1]
    +Output: 4
    +Explanation: In the image above:
    +-The ant at index 0 is named A and going to the right.
    +-The ant at index 1 is named B and going to the right.
    +-The ant at index 3 is named C and going to the left.
    +-The ant at index 4 is named D and going to the left.
    +Note that the last moment when an ant was on the plank is t = 4 second, after that it falls imediately out of the plank. (i.e. We can say that at t = 4.0000000001, there is no ants on the plank).
    +
    + +

    Example 2:

    + +
    +Input: n = 7, left = [], right = [0,1,2,3,4,5,6,7]
    +Output: 7
    +Explanation: All ants are going to the right, the ant at index 0 needs 7 seconds to fall.
    +
    + +

    Example 3:

    + +
    +Input: n = 7, left = [0,1,2,3,4,5,6,7], right = []
    +Output: 7
    +Explanation: All ants are going to the left, the ant at index 7 needs 7 seconds to fall.
    +
    + +

    Example 4:

    + +
    +Input: n = 9, left = [5], right = [4]
    +Output: 5
    +Explanation: At t = 1 second, both ants will be at the same intial position but with different direction.
    +
    + +

    Example 5:

    + +
    +Input: n = 6, left = [6], right = [0]
    +Output: 6
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 10^4
    • +
    • 0 <= left.length <= n + 1
    • +
    • 0 <= left[i] <= n
    • +
    • 0 <= right.length <= n + 1
    • +
    • 0 <= right[i] <= n
    • +
    • 1 <= left.length + right.length <= n + 1
    • +
    • All values of left and right are unique, and each value can appear only in one of the two arrays.
    • +
    + +### Related Topics + [[Brainteaser](../../tag/brainteaser/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +The ants change their way when they meet is equivalent to continue moving without changing their direction. +
    + +
    +Hint 2 +Answer is the max distance for one ant to reach the end of the plank in the facing direction. +
    diff --git a/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md b/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md index 643c0884f..a675ce477 100644 --- a/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md @@ -36,8 +36,7 @@

     

    - -

    Note:

    +

    Constraints:

    • All of the nodes' values will be unique.
    • diff --git a/problems/max-value-of-equation/README.md b/problems/max-value-of-equation/README.md index 4b4d4cbeb..09b036ff5 100644 --- a/problems/max-value-of-equation/README.md +++ b/problems/max-value-of-equation/README.md @@ -7,7 +7,7 @@ [< Previous](../number-of-subsequences-that-satisfy-the-given-sum-condition "Number of Subsequences That Satisfy the Given Sum Condition")                  -Next > +[Next >](../design-a-file-sharing-system "Design a File Sharing System") ## [1499. Max Value of Equation (Hard)](https://leetcode.com/problems/max-value-of-equation "满足不等式的最大值") diff --git a/problems/maximum-length-of-repeated-subarray/README.md b/problems/maximum-length-of-repeated-subarray/README.md index 3d4201a94..efa97c82f 100644 --- a/problems/maximum-length-of-repeated-subarray/README.md +++ b/problems/maximum-length-of-repeated-subarray/README.md @@ -47,5 +47,5 @@ The repeated subarray with maximum length is [3, 2, 1]. ### Hints
      Hint 1 -运用动态规划的方法,dp[i][j] 就是是输入中 A [i:], B[j:] 所对应的答案。 +Use dynamic programming. dp[i][j] will be the answer for inputs A[i:], B[j:].
      diff --git a/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md b/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md new file mode 100644 index 000000000..833a7c88c --- /dev/null +++ b/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../count-submatrices-with-all-ones "Count Submatrices With All Ones") +                 +Next > + +## [1505. Minimum Possible Integer After at Most K Adjacent Swaps On Digits (Hard)](https://leetcode.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "最多 K 次交换相邻数位后得到的最小整数") + +

      Given a string num representing the digits of a very large integer and an integer k.

      + +

      You are allowed to swap any two adjacent digits of the integer at most k times.

      + +

      Return the minimum integer you can obtain also as a string.

      + +

       

      +

      Example 1:

      + +
      +Input: num = "4321", k = 4
      +Output: "1342"
      +Explanation: The steps to obtain the minimum integer from 4321 with 4 adjacent swaps are shown.
      +
      + +

      Example 2:

      + +
      +Input: num = "100", k = 1
      +Output: "010"
      +Explanation: It's ok for the output to have leading zeros, but the input is guaranteed not to have any leading zeros.
      +
      + +

      Example 3:

      + +
      +Input: num = "36789", k = 1000
      +Output: "36789"
      +Explanation: We can keep the number without any swaps.
      +
      + +

      Example 4:

      + +
      +Input: num = "22", k = 22
      +Output: "22"
      +
      + +

      Example 5:

      + +
      +Input: num = "9438957234785635408", k = 23
      +Output: "0345989723478563548"
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= num.length <= 30000
      • +
      • num contains digits only and doesn't have leading zeros.
      • +
      • 1 <= k <= 10^9
      • +
      + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
      +Hint 1 +We want to make the smaller digits the most significant digits in the number. +
      + +
      +Hint 2 +For each index i, check the smallest digit in a window of size k and append it to the answer. Update the indices of all digits in this range accordingly. +
      diff --git a/problems/most-frequent-subtree-sum/README.md b/problems/most-frequent-subtree-sum/README.md index 7fd3f56ba..49dbb76bf 100644 --- a/problems/most-frequent-subtree-sum/README.md +++ b/problems/most-frequent-subtree-sum/README.md @@ -40,8 +40,8 @@ You may assume the sum of values in any subtree is in the range of 32-bit signed

      ### Related Topics - [[Tree](../../tag/tree/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Tree](../../tag/tree/README.md)] ### Similar Questions 1. [Subtree of Another Tree](../subtree-of-another-tree) (Easy) diff --git a/problems/unique-morse-code-words/README.md b/problems/unique-morse-code-words/README.md index 7397e0522..8e1e415dc 100644 --- a/problems/unique-morse-code-words/README.md +++ b/problems/unique-morse-code-words/README.md @@ -18,7 +18,7 @@
       [".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."]
      -

      Now, given a list of words, each word can be written as a concatenation of the Morse code of each letter. For example, "cba" can be written as "-.-..--...", (which is the concatenation "-.-." + "-..." + ".-"). We'll call such a concatenation, the transformation of a word.

      +

      Now, given a list of words, each word can be written as a concatenation of the Morse code of each letter. For example, "cab" can be written as "-.-..--...", (which is the concatenation "-.-." + ".-" + "-..."). We'll call such a concatenation, the transformation of a word.

      Return the number of different transformations among all words we have.

      diff --git a/readme/1-300.md b/readme/1-300.md index c989ede88..ba989f2be 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -43,12 +43,12 @@ LeetCode Problems' Solutions [851-900] - [901-950] - [951-1000] - [1001-1050] - [1051-1100] - [1101-1150] - [1151-1200] + [901-950] + [951-1000] + [1001-1050] + [1051-1100] + [1101-1150] + [1151-1200] [1201-1250] @@ -58,6 +58,14 @@ LeetCode Problems' Solutions [1401-1450] [1451-1500] + + [1501-1550] + [1551-1600] + [1601-1650] + [1651-1700] + [1701-1750] + [1751-1800] + | # | Title | Solution | Difficulty | diff --git a/readme/301-600.md b/readme/301-600.md index af4578e6e..1bd40461b 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -43,12 +43,12 @@ LeetCode Problems' Solutions [851-900] - [901-950] - [951-1000] - [1001-1050] - [1051-1100] - [1101-1150] - [1151-1200] + [901-950] + [951-1000] + [1001-1050] + [1051-1100] + [1101-1150] + [1151-1200] [1201-1250] @@ -58,6 +58,14 @@ LeetCode Problems' Solutions [1401-1450] [1451-1500] + + [1501-1550] + [1551-1600] + [1601-1650] + [1651-1700] + [1701-1750] + [1751-1800] + | # | Title | Solution | Difficulty | diff --git a/readme/601-900.md b/readme/601-900.md index f36362a21..182a98ded 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -43,12 +43,12 @@ LeetCode Problems' Solutions [851-900] - [901-950] - [951-1000] - [1001-1050] - [1051-1100] - [1101-1150] - [1151-1200] + [901-950] + [951-1000] + [1001-1050] + [1051-1100] + [1101-1150] + [1151-1200] [1201-1250] @@ -58,6 +58,14 @@ LeetCode Problems' Solutions [1401-1450] [1451-1500] + + [1501-1550] + [1551-1600] + [1601-1650] + [1651-1700] + [1701-1750] + [1751-1800] + | # | Title | Solution | Difficulty | diff --git a/readme/901-1200.md b/readme/901-1200.md new file mode 100644 index 000000000..dfddde6e8 --- /dev/null +++ b/readme/901-1200.md @@ -0,0 +1,372 @@ + + + + + + + +# [LeetCode](https://openset.github.io/leetcode) +LeetCode Problems' Solutions +[[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] + +[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) +[![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) +[![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) +[![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) +[![license](https://img.shields.io/github/license/openset/leetcode.svg)](https://github.com/openset/leetcode/blob/master/LICENSE) +[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fopenset%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fopenset%2Fleetcode?ref=badge_shield) +[![Join the chat](https://badges.gitter.im/openset/leetcode.svg)](https://gitter.im/openset/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      [1-50][51-100][101-150][151-200][201-250][251-300]
      [301-350][351-400][401-450][451-500][501-550][551-600]
      [601-650][651-700][701-750][751-800][801-850][851-900]
      [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
      [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
      [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
      + +| # | Title | Solution | Difficulty | +| :-: | - | - | :-: | +| 901 | [Online Stock Span](https://leetcode.com/problems/online-stock-span "股票价格跨度") | [Go](../problems/online-stock-span) | Medium | +| 902 | [Numbers At Most N Given Digit Set](https://leetcode.com/problems/numbers-at-most-n-given-digit-set "最大为 N 的数字组合") | [Go](../problems/numbers-at-most-n-given-digit-set) | Hard | +| 903 | [Valid Permutations for DI Sequence](https://leetcode.com/problems/valid-permutations-for-di-sequence "DI 序列的有效排列") | [Go](../problems/valid-permutations-for-di-sequence) | Hard | +| 904 | [Fruit Into Baskets](https://leetcode.com/problems/fruit-into-baskets "水果成篮") | [Go](../problems/fruit-into-baskets) | Medium | +| 905 | [Sort Array By Parity](https://leetcode.com/problems/sort-array-by-parity "按奇偶排序数组") | [Go](../problems/sort-array-by-parity) | Easy | +| 906 | [Super Palindromes](https://leetcode.com/problems/super-palindromes "超级回文数") | [Go](../problems/super-palindromes) | Hard | +| 907 | [Sum of Subarray Minimums](https://leetcode.com/problems/sum-of-subarray-minimums "子数组的最小值之和") | [Go](../problems/sum-of-subarray-minimums) | Medium | +| 908 | [Smallest Range I](https://leetcode.com/problems/smallest-range-i "最小差值 I") | [Go](../problems/smallest-range-i) | Easy | +| 909 | [Snakes and Ladders](https://leetcode.com/problems/snakes-and-ladders "蛇梯棋") | [Go](../problems/snakes-and-ladders) | Medium | +| 910 | [Smallest Range II](https://leetcode.com/problems/smallest-range-ii "最小差值 II") | [Go](../problems/smallest-range-ii) | Medium | +| 911 | [Online Election](https://leetcode.com/problems/online-election "在线选举") | [Go](../problems/online-election) | Medium | +| 912 | [Sort an Array](https://leetcode.com/problems/sort-an-array "排序数组") | [Go](../problems/sort-an-array) | Medium | +| 913 | [Cat and Mouse](https://leetcode.com/problems/cat-and-mouse "猫和老鼠") | [Go](../problems/cat-and-mouse) | Hard | +| 914 | [X of a Kind in a Deck of Cards](https://leetcode.com/problems/x-of-a-kind-in-a-deck-of-cards "卡牌分组") | [Go](../problems/x-of-a-kind-in-a-deck-of-cards) | Easy | +| 915 | [Partition Array into Disjoint Intervals](https://leetcode.com/problems/partition-array-into-disjoint-intervals "分割数组") | [Go](../problems/partition-array-into-disjoint-intervals) | Medium | +| 916 | [Word Subsets](https://leetcode.com/problems/word-subsets "单词子集") | [Go](../problems/word-subsets) | Medium | +| 917 | [Reverse Only Letters](https://leetcode.com/problems/reverse-only-letters "仅仅反转字母") | [Go](../problems/reverse-only-letters) | Easy | +| 918 | [Maximum Sum Circular Subarray](https://leetcode.com/problems/maximum-sum-circular-subarray "环形子数组的最大和") | [Go](../problems/maximum-sum-circular-subarray) | Medium | +| 919 | [Complete Binary Tree Inserter](https://leetcode.com/problems/complete-binary-tree-inserter "完全二叉树插入器") | [Go](../problems/complete-binary-tree-inserter) | Medium | +| 920 | [Number of Music Playlists](https://leetcode.com/problems/number-of-music-playlists "播放列表的数量") | [Go](../problems/number-of-music-playlists) | Hard | +| 921 | [Minimum Add to Make Parentheses Valid](https://leetcode.com/problems/minimum-add-to-make-parentheses-valid "使括号有效的最少添加") | [Go](../problems/minimum-add-to-make-parentheses-valid) | Medium | +| 922 | [Sort Array By Parity II](https://leetcode.com/problems/sort-array-by-parity-ii "按奇偶排序数组 II") | [Go](../problems/sort-array-by-parity-ii) | Easy | +| 923 | [3Sum With Multiplicity](https://leetcode.com/problems/3sum-with-multiplicity "三数之和的多种可能") | [Go](../problems/3sum-with-multiplicity) | Medium | +| 924 | [Minimize Malware Spread](https://leetcode.com/problems/minimize-malware-spread "尽量减少恶意软件的传播") | [Go](../problems/minimize-malware-spread) | Hard | +| 925 | [Long Pressed Name](https://leetcode.com/problems/long-pressed-name "长按键入") | [Go](../problems/long-pressed-name) | Easy | +| 926 | [Flip String to Monotone Increasing](https://leetcode.com/problems/flip-string-to-monotone-increasing "将字符串翻转到单调递增") | [Go](../problems/flip-string-to-monotone-increasing) | Medium | +| 927 | [Three Equal Parts](https://leetcode.com/problems/three-equal-parts "三等分") | [Go](../problems/three-equal-parts) | Hard | +| 928 | [Minimize Malware Spread II](https://leetcode.com/problems/minimize-malware-spread-ii "尽量减少恶意软件的传播 II") | [Go](../problems/minimize-malware-spread-ii) | Hard | +| 929 | [Unique Email Addresses](https://leetcode.com/problems/unique-email-addresses "独特的电子邮件地址") | [Go](../problems/unique-email-addresses) | Easy | +| 930 | [Binary Subarrays With Sum](https://leetcode.com/problems/binary-subarrays-with-sum "和相同的二元子数组") | [Go](../problems/binary-subarrays-with-sum) | Medium | +| 931 | [Minimum Falling Path Sum](https://leetcode.com/problems/minimum-falling-path-sum "下降路径最小和") | [Go](../problems/minimum-falling-path-sum) | Medium | +| 932 | [Beautiful Array](https://leetcode.com/problems/beautiful-array "漂亮数组") | [Go](../problems/beautiful-array) | Medium | +| 933 | [Number of Recent Calls](https://leetcode.com/problems/number-of-recent-calls "最近的请求次数") | [Go](../problems/number-of-recent-calls) | Easy | +| 934 | [Shortest Bridge](https://leetcode.com/problems/shortest-bridge "最短的桥") | [Go](../problems/shortest-bridge) | Medium | +| 935 | [Knight Dialer](https://leetcode.com/problems/knight-dialer "骑士拨号器") | [Go](../problems/knight-dialer) | Medium | +| 936 | [Stamping The Sequence](https://leetcode.com/problems/stamping-the-sequence "戳印序列") | [Go](../problems/stamping-the-sequence) | Hard | +| 937 | [Reorder Data in Log Files](https://leetcode.com/problems/reorder-data-in-log-files "重新排列日志文件") | [Go](../problems/reorder-data-in-log-files) | Easy | +| 938 | [Range Sum of BST](https://leetcode.com/problems/range-sum-of-bst "二叉搜索树的范围和") | [Go](../problems/range-sum-of-bst) | Easy | +| 939 | [Minimum Area Rectangle](https://leetcode.com/problems/minimum-area-rectangle "最小面积矩形") | [Go](../problems/minimum-area-rectangle) | Medium | +| 940 | [Distinct Subsequences II](https://leetcode.com/problems/distinct-subsequences-ii "不同的子序列 II") | [Go](../problems/distinct-subsequences-ii) | Hard | +| 941 | [Valid Mountain Array](https://leetcode.com/problems/valid-mountain-array "有效的山脉数组") | [Go](../problems/valid-mountain-array) | Easy | +| 942 | [DI String Match](https://leetcode.com/problems/di-string-match "增减字符串匹配") | [Go](../problems/di-string-match) | Easy | +| 943 | [Find the Shortest Superstring](https://leetcode.com/problems/find-the-shortest-superstring "最短超级串") | [Go](../problems/find-the-shortest-superstring) | Hard | +| 944 | [Delete Columns to Make Sorted](https://leetcode.com/problems/delete-columns-to-make-sorted "删列造序") | [Go](../problems/delete-columns-to-make-sorted) | Easy | +| 945 | [Minimum Increment to Make Array Unique](https://leetcode.com/problems/minimum-increment-to-make-array-unique "使数组唯一的最小增量") | [Go](../problems/minimum-increment-to-make-array-unique) | Medium | +| 946 | [Validate Stack Sequences](https://leetcode.com/problems/validate-stack-sequences "验证栈序列") | [Go](../problems/validate-stack-sequences) | Medium | +| 947 | [Most Stones Removed with Same Row or Column](https://leetcode.com/problems/most-stones-removed-with-same-row-or-column "移除最多的同行或同列石头") | [Go](../problems/most-stones-removed-with-same-row-or-column) | Medium | +| 948 | [Bag of Tokens](https://leetcode.com/problems/bag-of-tokens "令牌放置") | [Go](../problems/bag-of-tokens) | Medium | +| 949 | [Largest Time for Given Digits](https://leetcode.com/problems/largest-time-for-given-digits "给定数字能组成的最大时间") | [Go](../problems/largest-time-for-given-digits) | Easy | +| 950 | [Reveal Cards In Increasing Order](https://leetcode.com/problems/reveal-cards-in-increasing-order "按递增顺序显示卡牌") | [Go](../problems/reveal-cards-in-increasing-order) | Medium | +| 951 | [Flip Equivalent Binary Trees](https://leetcode.com/problems/flip-equivalent-binary-trees "翻转等价二叉树") | [Go](../problems/flip-equivalent-binary-trees) | Medium | +| 952 | [Largest Component Size by Common Factor](https://leetcode.com/problems/largest-component-size-by-common-factor "按公因数计算最大组件大小") | [Go](../problems/largest-component-size-by-common-factor) | Hard | +| 953 | [Verifying an Alien Dictionary](https://leetcode.com/problems/verifying-an-alien-dictionary "验证外星语词典") | [Go](../problems/verifying-an-alien-dictionary) | Easy | +| 954 | [Array of Doubled Pairs](https://leetcode.com/problems/array-of-doubled-pairs "二倍数对数组") | [Go](../problems/array-of-doubled-pairs) | Medium | +| 955 | [Delete Columns to Make Sorted II](https://leetcode.com/problems/delete-columns-to-make-sorted-ii "删列造序 II") | [Go](../problems/delete-columns-to-make-sorted-ii) | Medium | +| 956 | [Tallest Billboard](https://leetcode.com/problems/tallest-billboard "最高的广告牌") | [Go](../problems/tallest-billboard) | Hard | +| 957 | [Prison Cells After N Days](https://leetcode.com/problems/prison-cells-after-n-days "N 天后的牢房") | [Go](../problems/prison-cells-after-n-days) | Medium | +| 958 | [Check Completeness of a Binary Tree](https://leetcode.com/problems/check-completeness-of-a-binary-tree "二叉树的完全性检验") | [Go](../problems/check-completeness-of-a-binary-tree) | Medium | +| 959 | [Regions Cut By Slashes](https://leetcode.com/problems/regions-cut-by-slashes "由斜杠划分区域") | [Go](../problems/regions-cut-by-slashes) | Medium | +| 960 | [Delete Columns to Make Sorted III](https://leetcode.com/problems/delete-columns-to-make-sorted-iii "删列造序 III") | [Go](../problems/delete-columns-to-make-sorted-iii) | Hard | +| 961 | [N-Repeated Element in Size 2N Array](https://leetcode.com/problems/n-repeated-element-in-size-2n-array "重复 N 次的元素") | [Go](../problems/n-repeated-element-in-size-2n-array) | Easy | +| 962 | [Maximum Width Ramp](https://leetcode.com/problems/maximum-width-ramp "最大宽度坡") | [Go](../problems/maximum-width-ramp) | Medium | +| 963 | [Minimum Area Rectangle II](https://leetcode.com/problems/minimum-area-rectangle-ii "最小面积矩形 II") | [Go](../problems/minimum-area-rectangle-ii) | Medium | +| 964 | [Least Operators to Express Number](https://leetcode.com/problems/least-operators-to-express-number "表示数字的最少运算符") | [Go](../problems/least-operators-to-express-number) | Hard | +| 965 | [Univalued Binary Tree](https://leetcode.com/problems/univalued-binary-tree "单值二叉树") | [Go](../problems/univalued-binary-tree) | Easy | +| 966 | [Vowel Spellchecker](https://leetcode.com/problems/vowel-spellchecker "元音拼写检查器") | [Go](../problems/vowel-spellchecker) | Medium | +| 967 | [Numbers With Same Consecutive Differences](https://leetcode.com/problems/numbers-with-same-consecutive-differences "连续差相同的数字") | [Go](../problems/numbers-with-same-consecutive-differences) | Medium | +| 968 | [Binary Tree Cameras](https://leetcode.com/problems/binary-tree-cameras "监控二叉树") | [Go](../problems/binary-tree-cameras) | Hard | +| 969 | [Pancake Sorting](https://leetcode.com/problems/pancake-sorting "煎饼排序") | [Go](../problems/pancake-sorting) | Medium | +| 970 | [Powerful Integers](https://leetcode.com/problems/powerful-integers "强整数") | [Go](../problems/powerful-integers) | Easy | +| 971 | [Flip Binary Tree To Match Preorder Traversal](https://leetcode.com/problems/flip-binary-tree-to-match-preorder-traversal "翻转二叉树以匹配先序遍历") | [Go](../problems/flip-binary-tree-to-match-preorder-traversal) | Medium | +| 972 | [Equal Rational Numbers](https://leetcode.com/problems/equal-rational-numbers "相等的有理数") | [Go](../problems/equal-rational-numbers) | Hard | +| 973 | [K Closest Points to Origin](https://leetcode.com/problems/k-closest-points-to-origin "最接近原点的 K 个点") | [Go](../problems/k-closest-points-to-origin) | Medium | +| 974 | [Subarray Sums Divisible by K](https://leetcode.com/problems/subarray-sums-divisible-by-k "和可被 K 整除的子数组") | [Go](../problems/subarray-sums-divisible-by-k) | Medium | +| 975 | [Odd Even Jump](https://leetcode.com/problems/odd-even-jump "奇偶跳") | [Go](../problems/odd-even-jump) | Hard | +| 976 | [Largest Perimeter Triangle](https://leetcode.com/problems/largest-perimeter-triangle "三角形的最大周长") | [Go](../problems/largest-perimeter-triangle) | Easy | +| 977 | [Squares of a Sorted Array](https://leetcode.com/problems/squares-of-a-sorted-array "有序数组的平方") | [Go](../problems/squares-of-a-sorted-array) | Easy | +| 978 | [Longest Turbulent Subarray](https://leetcode.com/problems/longest-turbulent-subarray "最长湍流子数组") | [Go](../problems/longest-turbulent-subarray) | Medium | +| 979 | [Distribute Coins in Binary Tree](https://leetcode.com/problems/distribute-coins-in-binary-tree "在二叉树中分配硬币") | [Go](../problems/distribute-coins-in-binary-tree) | Medium | +| 980 | [Unique Paths III](https://leetcode.com/problems/unique-paths-iii "不同路径 III") | [Go](../problems/unique-paths-iii) | Hard | +| 981 | [Time Based Key-Value Store](https://leetcode.com/problems/time-based-key-value-store "基于时间的键值存储") | [Go](../problems/time-based-key-value-store) | Medium | +| 982 | [Triples with Bitwise AND Equal To Zero](https://leetcode.com/problems/triples-with-bitwise-and-equal-to-zero "按位与为零的三元组") | [Go](../problems/triples-with-bitwise-and-equal-to-zero) | Hard | +| 983 | [Minimum Cost For Tickets](https://leetcode.com/problems/minimum-cost-for-tickets "最低票价") | [Go](../problems/minimum-cost-for-tickets) | Medium | +| 984 | [String Without AAA or BBB](https://leetcode.com/problems/string-without-aaa-or-bbb "不含 AAA 或 BBB 的字符串") | [Go](../problems/string-without-aaa-or-bbb) | Medium | +| 985 | [Sum of Even Numbers After Queries](https://leetcode.com/problems/sum-of-even-numbers-after-queries "查询后的偶数和") | [Go](../problems/sum-of-even-numbers-after-queries) | Easy | +| 986 | [Interval List Intersections](https://leetcode.com/problems/interval-list-intersections "区间列表的交集") | [Go](../problems/interval-list-intersections) | Medium | +| 987 | [Vertical Order Traversal of a Binary Tree](https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree "二叉树的垂序遍历") | [Go](../problems/vertical-order-traversal-of-a-binary-tree) | Medium | +| 988 | [Smallest String Starting From Leaf](https://leetcode.com/problems/smallest-string-starting-from-leaf "从叶结点开始的最小字符串") | [Go](../problems/smallest-string-starting-from-leaf) | Medium | +| 989 | [Add to Array-Form of Integer](https://leetcode.com/problems/add-to-array-form-of-integer "数组形式的整数加法") | [Go](../problems/add-to-array-form-of-integer) | Easy | +| 990 | [Satisfiability of Equality Equations](https://leetcode.com/problems/satisfiability-of-equality-equations "等式方程的可满足性") | [Go](../problems/satisfiability-of-equality-equations) | Medium | +| 991 | [Broken Calculator](https://leetcode.com/problems/broken-calculator "坏了的计算器") | [Go](../problems/broken-calculator) | Medium | +| 992 | [Subarrays with K Different Integers](https://leetcode.com/problems/subarrays-with-k-different-integers "K 个不同整数的子数组") | [Go](../problems/subarrays-with-k-different-integers) | Hard | +| 993 | [Cousins in Binary Tree](https://leetcode.com/problems/cousins-in-binary-tree "二叉树的堂兄弟节点") | [Go](../problems/cousins-in-binary-tree) | Easy | +| 994 | [Rotting Oranges](https://leetcode.com/problems/rotting-oranges "腐烂的橘子") | [Go](../problems/rotting-oranges) | Medium | +| 995 | [Minimum Number of K Consecutive Bit Flips](https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips "K 连续位的最小翻转次数") | [Go](../problems/minimum-number-of-k-consecutive-bit-flips) | Hard | +| 996 | [Number of Squareful Arrays](https://leetcode.com/problems/number-of-squareful-arrays "正方形数组的数目") | [Go](../problems/number-of-squareful-arrays) | Hard | +| 997 | [Find the Town Judge](https://leetcode.com/problems/find-the-town-judge "找到小镇的法官") | [Go](../problems/find-the-town-judge) | Easy | +| 998 | [Maximum Binary Tree II](https://leetcode.com/problems/maximum-binary-tree-ii "最大二叉树 II") | [Go](../problems/maximum-binary-tree-ii) | Medium | +| 999 | [Available Captures for Rook](https://leetcode.com/problems/available-captures-for-rook "可以被一步捕获的棋子数") | [Go](../problems/available-captures-for-rook) | Easy | +| 1000 | [Minimum Cost to Merge Stones](https://leetcode.com/problems/minimum-cost-to-merge-stones "合并石头的最低成本") | [Go](../problems/minimum-cost-to-merge-stones) | Hard | +| 1001 | [Grid Illumination](https://leetcode.com/problems/grid-illumination "网格照明") | [Go](../problems/grid-illumination) | Hard | +| 1002 | [Find Common Characters](https://leetcode.com/problems/find-common-characters "查找常用字符") | [Go](../problems/find-common-characters) | Easy | +| 1003 | [Check If Word Is Valid After Substitutions](https://leetcode.com/problems/check-if-word-is-valid-after-substitutions "检查替换后的词是否有效") | [Go](../problems/check-if-word-is-valid-after-substitutions) | Medium | +| 1004 | [Max Consecutive Ones III](https://leetcode.com/problems/max-consecutive-ones-iii "最大连续1的个数 III") | [Go](../problems/max-consecutive-ones-iii) | Medium | +| 1005 | [Maximize Sum Of Array After K Negations](https://leetcode.com/problems/maximize-sum-of-array-after-k-negations "K 次取反后最大化的数组和") | [Go](../problems/maximize-sum-of-array-after-k-negations) | Easy | +| 1006 | [Clumsy Factorial](https://leetcode.com/problems/clumsy-factorial "笨阶乘") | [Go](../problems/clumsy-factorial) | Medium | +| 1007 | [Minimum Domino Rotations For Equal Row](https://leetcode.com/problems/minimum-domino-rotations-for-equal-row "行相等的最少多米诺旋转") | [Go](../problems/minimum-domino-rotations-for-equal-row) | Medium | +| 1008 | [Construct Binary Search Tree from Preorder Traversal](https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal "先序遍历构造二叉树") | [Go](../problems/construct-binary-search-tree-from-preorder-traversal) | Medium | +| 1009 | [Complement of Base 10 Integer](https://leetcode.com/problems/complement-of-base-10-integer "十进制整数的反码") | [Go](../problems/complement-of-base-10-integer) | Easy | +| 1010 | [Pairs of Songs With Total Durations Divisible by 60](https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60 "总持续时间可被 60 整除的歌曲") | [Go](../problems/pairs-of-songs-with-total-durations-divisible-by-60) | Easy | +| 1011 | [Capacity To Ship Packages Within D Days](https://leetcode.com/problems/capacity-to-ship-packages-within-d-days "在 D 天内送达包裹的能力") | [Go](../problems/capacity-to-ship-packages-within-d-days) | Medium | +| 1012 | [Numbers With Repeated Digits](https://leetcode.com/problems/numbers-with-repeated-digits "至少有 1 位重复的数字") | [Go](../problems/numbers-with-repeated-digits) | Hard | +| 1013 | [Partition Array Into Three Parts With Equal Sum](https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum "将数组分成和相等的三个部分") | [Go](../problems/partition-array-into-three-parts-with-equal-sum) | Easy | +| 1014 | [Best Sightseeing Pair](https://leetcode.com/problems/best-sightseeing-pair "最佳观光组合") | [Go](../problems/best-sightseeing-pair) | Medium | +| 1015 | [Smallest Integer Divisible by K](https://leetcode.com/problems/smallest-integer-divisible-by-k "可被 K 整除的最小整数") | [Go](../problems/smallest-integer-divisible-by-k) | Medium | +| 1016 | [Binary String With Substrings Representing 1 To N](https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n "子串能表示从 1 到 N 数字的二进制串") | [Go](../problems/binary-string-with-substrings-representing-1-to-n) | Medium | +| 1017 | [Convert to Base -2](https://leetcode.com/problems/convert-to-base-2 "负二进制转换") | [Go](../problems/convert-to-base-2) | Medium | +| 1018 | [Binary Prefix Divisible By 5](https://leetcode.com/problems/binary-prefix-divisible-by-5 "可被 5 整除的二进制前缀") | [Go](../problems/binary-prefix-divisible-by-5) | Easy | +| 1019 | [Next Greater Node In Linked List](https://leetcode.com/problems/next-greater-node-in-linked-list "链表中的下一个更大节点") | [Go](../problems/next-greater-node-in-linked-list) | Medium | +| 1020 | [Number of Enclaves](https://leetcode.com/problems/number-of-enclaves "飞地的数量") | [Go](../problems/number-of-enclaves) | Medium | +| 1021 | [Remove Outermost Parentheses](https://leetcode.com/problems/remove-outermost-parentheses "删除最外层的括号") | [Go](../problems/remove-outermost-parentheses) | Easy | +| 1022 | [Sum of Root To Leaf Binary Numbers](https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers "从根到叶的二进制数之和") | [Go](../problems/sum-of-root-to-leaf-binary-numbers) | Easy | +| 1023 | [Camelcase Matching](https://leetcode.com/problems/camelcase-matching "驼峰式匹配") | [Go](../problems/camelcase-matching) | Medium | +| 1024 | [Video Stitching](https://leetcode.com/problems/video-stitching "视频拼接") | [Go](../problems/video-stitching) | Medium | +| 1025 | [Divisor Game](https://leetcode.com/problems/divisor-game "除数博弈") | [Go](../problems/divisor-game) | Easy | +| 1026 | [Maximum Difference Between Node and Ancestor](https://leetcode.com/problems/maximum-difference-between-node-and-ancestor "节点与其祖先之间的最大差值") | [Go](../problems/maximum-difference-between-node-and-ancestor) | Medium | +| 1027 | [Longest Arithmetic Sequence](https://leetcode.com/problems/longest-arithmetic-sequence "最长等差数列") | [Go](../problems/longest-arithmetic-sequence) | Medium | +| 1028 | [Recover a Tree From Preorder Traversal](https://leetcode.com/problems/recover-a-tree-from-preorder-traversal "从先序遍历还原二叉树") | [Go](../problems/recover-a-tree-from-preorder-traversal) | Hard | +| 1029 | [Two City Scheduling](https://leetcode.com/problems/two-city-scheduling "两地调度") | [Go](../problems/two-city-scheduling) | Easy | +| 1030 | [Matrix Cells in Distance Order](https://leetcode.com/problems/matrix-cells-in-distance-order "距离顺序排列矩阵单元格") | [Go](../problems/matrix-cells-in-distance-order) | Easy | +| 1031 | [Maximum Sum of Two Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays "两个非重叠子数组的最大和") | [Go](../problems/maximum-sum-of-two-non-overlapping-subarrays) | Medium | +| 1032 | [Stream of Characters](https://leetcode.com/problems/stream-of-characters "字符流") | [Go](../problems/stream-of-characters) | Hard | +| 1033 | [Moving Stones Until Consecutive](https://leetcode.com/problems/moving-stones-until-consecutive "移动石子直到连续") | [Go](../problems/moving-stones-until-consecutive) | Easy | +| 1034 | [Coloring A Border](https://leetcode.com/problems/coloring-a-border "边框着色") | [Go](../problems/coloring-a-border) | Medium | +| 1035 | [Uncrossed Lines](https://leetcode.com/problems/uncrossed-lines "不相交的线") | [Go](../problems/uncrossed-lines) | Medium | +| 1036 | [Escape a Large Maze](https://leetcode.com/problems/escape-a-large-maze "逃离大迷宫") | [Go](../problems/escape-a-large-maze) | Hard | +| 1037 | [Valid Boomerang](https://leetcode.com/problems/valid-boomerang "有效的回旋镖") | [Go](../problems/valid-boomerang) | Easy | +| 1038 | [Binary Search Tree to Greater Sum Tree](https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree "从二叉搜索树到更大和树") | [Go](../problems/binary-search-tree-to-greater-sum-tree) | Medium | +| 1039 | [Minimum Score Triangulation of Polygon](https://leetcode.com/problems/minimum-score-triangulation-of-polygon "多边形三角剖分的最低得分") | [Go](../problems/minimum-score-triangulation-of-polygon) | Medium | +| 1040 | [Moving Stones Until Consecutive II](https://leetcode.com/problems/moving-stones-until-consecutive-ii "移动石子直到连续 II") | [Go](../problems/moving-stones-until-consecutive-ii) | Medium | +| 1041 | [Robot Bounded In Circle](https://leetcode.com/problems/robot-bounded-in-circle "困于环中的机器人") | [Go](../problems/robot-bounded-in-circle) | Medium | +| 1042 | [Flower Planting With No Adjacent](https://leetcode.com/problems/flower-planting-with-no-adjacent "不邻接植花") | [Go](../problems/flower-planting-with-no-adjacent) | Easy | +| 1043 | [Partition Array for Maximum Sum](https://leetcode.com/problems/partition-array-for-maximum-sum "分隔数组以得到最大和") | [Go](../problems/partition-array-for-maximum-sum) | Medium | +| 1044 | [Longest Duplicate Substring](https://leetcode.com/problems/longest-duplicate-substring "最长重复子串") | [Go](../problems/longest-duplicate-substring) | Hard | +| 1045 | [Customers Who Bought All Products](https://leetcode.com/problems/customers-who-bought-all-products "买下所有产品的客户") 🔒 | [MySQL](../problems/customers-who-bought-all-products) | Medium | +| 1046 | [Last Stone Weight](https://leetcode.com/problems/last-stone-weight "最后一块石头的重量") | [Go](../problems/last-stone-weight) | Easy | +| 1047 | [Remove All Adjacent Duplicates In String](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string "删除字符串中的所有相邻重复项") | [Go](../problems/remove-all-adjacent-duplicates-in-string) | Easy | +| 1048 | [Longest String Chain](https://leetcode.com/problems/longest-string-chain "最长字符串链") | [Go](../problems/longest-string-chain) | Medium | +| 1049 | [Last Stone Weight II](https://leetcode.com/problems/last-stone-weight-ii "最后一块石头的重量 II") | [Go](../problems/last-stone-weight-ii) | Medium | +| 1050 | [Actors and Directors Who Cooperated At Least Three Times](https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times "合作过至少三次的演员和导演") 🔒 | [MySQL](../problems/actors-and-directors-who-cooperated-at-least-three-times) | Easy | +| 1051 | [Height Checker](https://leetcode.com/problems/height-checker "高度检查器") | [Go](../problems/height-checker) | Easy | +| 1052 | [Grumpy Bookstore Owner](https://leetcode.com/problems/grumpy-bookstore-owner "爱生气的书店老板") | [Go](../problems/grumpy-bookstore-owner) | Medium | +| 1053 | [Previous Permutation With One Swap](https://leetcode.com/problems/previous-permutation-with-one-swap "交换一次的先前排列") | [Go](../problems/previous-permutation-with-one-swap) | Medium | +| 1054 | [Distant Barcodes](https://leetcode.com/problems/distant-barcodes "距离相等的条形码") | [Go](../problems/distant-barcodes) | Medium | +| 1055 | [Shortest Way to Form String](https://leetcode.com/problems/shortest-way-to-form-string "形成字符串的最短路径") 🔒 | [Go](../problems/shortest-way-to-form-string) | Medium | +| 1056 | [Confusing Number](https://leetcode.com/problems/confusing-number "易混淆数") 🔒 | [Go](../problems/confusing-number) | Easy | +| 1057 | [Campus Bikes](https://leetcode.com/problems/campus-bikes "校园自行车分配") 🔒 | [Go](../problems/campus-bikes) | Medium | +| 1058 | [Minimize Rounding Error to Meet Target](https://leetcode.com/problems/minimize-rounding-error-to-meet-target "最小化舍入误差以满足目标") 🔒 | [Go](../problems/minimize-rounding-error-to-meet-target) | Medium | +| 1059 | [All Paths from Source Lead to Destination](https://leetcode.com/problems/all-paths-from-source-lead-to-destination "从始点到终点的所有路径") 🔒 | [Go](../problems/all-paths-from-source-lead-to-destination) | Medium | +| 1060 | [Missing Element in Sorted Array](https://leetcode.com/problems/missing-element-in-sorted-array "有序数组中的缺失元素") 🔒 | [Go](../problems/missing-element-in-sorted-array) | Medium | +| 1061 | [Lexicographically Smallest Equivalent String](https://leetcode.com/problems/lexicographically-smallest-equivalent-string "按字典序排列最小的等效字符串") 🔒 | [Go](../problems/lexicographically-smallest-equivalent-string) | Medium | +| 1062 | [Longest Repeating Substring](https://leetcode.com/problems/longest-repeating-substring "最长重复子串") 🔒 | [Go](../problems/longest-repeating-substring) | Medium | +| 1063 | [Number of Valid Subarrays](https://leetcode.com/problems/number-of-valid-subarrays "有效子数组的数目") 🔒 | [Go](../problems/number-of-valid-subarrays) | Hard | +| 1064 | [Fixed Point](https://leetcode.com/problems/fixed-point "不动点") 🔒 | [Go](../problems/fixed-point) | Easy | +| 1065 | [Index Pairs of a String](https://leetcode.com/problems/index-pairs-of-a-string "字符串的索引对") 🔒 | [Go](../problems/index-pairs-of-a-string) | Easy | +| 1066 | [Campus Bikes II](https://leetcode.com/problems/campus-bikes-ii "校园自行车分配 II") 🔒 | [Go](../problems/campus-bikes-ii) | Medium | +| 1067 | [Digit Count in Range](https://leetcode.com/problems/digit-count-in-range "范围内的数字计数") 🔒 | [Go](../problems/digit-count-in-range) | Hard | +| 1068 | [Product Sales Analysis I](https://leetcode.com/problems/product-sales-analysis-i "产品销售分析 I") 🔒 | [MySQL](../problems/product-sales-analysis-i) | Easy | +| 1069 | [Product Sales Analysis II](https://leetcode.com/problems/product-sales-analysis-ii "产品销售分析 II") 🔒 | [MySQL](../problems/product-sales-analysis-ii) | Easy | +| 1070 | [Product Sales Analysis III](https://leetcode.com/problems/product-sales-analysis-iii "产品销售分析 III") 🔒 | [MySQL](../problems/product-sales-analysis-iii) | Medium | +| 1071 | [Greatest Common Divisor of Strings](https://leetcode.com/problems/greatest-common-divisor-of-strings "字符串的最大公因子") | [Go](../problems/greatest-common-divisor-of-strings) | Easy | +| 1072 | [Flip Columns For Maximum Number of Equal Rows](https://leetcode.com/problems/flip-columns-for-maximum-number-of-equal-rows "按列翻转得到最大值等行数") | [Go](../problems/flip-columns-for-maximum-number-of-equal-rows) | Medium | +| 1073 | [Adding Two Negabinary Numbers](https://leetcode.com/problems/adding-two-negabinary-numbers "负二进制数相加") | [Go](../problems/adding-two-negabinary-numbers) | Medium | +| 1074 | [Number of Submatrices That Sum to Target](https://leetcode.com/problems/number-of-submatrices-that-sum-to-target "元素和为目标值的子矩阵数量") | [Go](../problems/number-of-submatrices-that-sum-to-target) | Hard | +| 1075 | [Project Employees I](https://leetcode.com/problems/project-employees-i "项目员工 I") 🔒 | [MySQL](../problems/project-employees-i) | Easy | +| 1076 | [Project Employees II](https://leetcode.com/problems/project-employees-ii "项目员工II") 🔒 | [MySQL](../problems/project-employees-ii) | Easy | +| 1077 | [Project Employees III](https://leetcode.com/problems/project-employees-iii "项目员工 III") 🔒 | [MySQL](../problems/project-employees-iii) | Medium | +| 1078 | [Occurrences After Bigram](https://leetcode.com/problems/occurrences-after-bigram "Bigram 分词") | [Go](../problems/occurrences-after-bigram) | Easy | +| 1079 | [Letter Tile Possibilities](https://leetcode.com/problems/letter-tile-possibilities "活字印刷") | [Go](../problems/letter-tile-possibilities) | Medium | +| 1080 | [Insufficient Nodes in Root to Leaf Paths](https://leetcode.com/problems/insufficient-nodes-in-root-to-leaf-paths "根到叶路径上的不足节点") | [Go](../problems/insufficient-nodes-in-root-to-leaf-paths) | Medium | +| 1081 | [Smallest Subsequence of Distinct Characters](https://leetcode.com/problems/smallest-subsequence-of-distinct-characters "不同字符的最小子序列") | [Go](../problems/smallest-subsequence-of-distinct-characters) | Medium | +| 1082 | [Sales Analysis I](https://leetcode.com/problems/sales-analysis-i "销售分析 I ") 🔒 | [MySQL](../problems/sales-analysis-i) | Easy | +| 1083 | [Sales Analysis II](https://leetcode.com/problems/sales-analysis-ii "销售分析 II") 🔒 | [MySQL](../problems/sales-analysis-ii) | Easy | +| 1084 | [Sales Analysis III](https://leetcode.com/problems/sales-analysis-iii "销售分析III") 🔒 | [MySQL](../problems/sales-analysis-iii) | Easy | +| 1085 | [Sum of Digits in the Minimum Number](https://leetcode.com/problems/sum-of-digits-in-the-minimum-number "最小元素各数位之和") 🔒 | [Go](../problems/sum-of-digits-in-the-minimum-number) | Easy | +| 1086 | [High Five](https://leetcode.com/problems/high-five "前五科的均分") 🔒 | [Go](../problems/high-five) | Easy | +| 1087 | [Brace Expansion](https://leetcode.com/problems/brace-expansion "字母切换") 🔒 | [Go](../problems/brace-expansion) | Medium | +| 1088 | [Confusing Number II](https://leetcode.com/problems/confusing-number-ii "易混淆数 II") 🔒 | [Go](../problems/confusing-number-ii) | Hard | +| 1089 | [Duplicate Zeros](https://leetcode.com/problems/duplicate-zeros "复写零") | [Go](../problems/duplicate-zeros) | Easy | +| 1090 | [Largest Values From Labels](https://leetcode.com/problems/largest-values-from-labels "受标签影响的最大值") | [Go](../problems/largest-values-from-labels) | Medium | +| 1091 | [Shortest Path in Binary Matrix](https://leetcode.com/problems/shortest-path-in-binary-matrix "二进制矩阵中的最短路径") | [Go](../problems/shortest-path-in-binary-matrix) | Medium | +| 1092 | [Shortest Common Supersequence](https://leetcode.com/problems/shortest-common-supersequence "最短公共超序列") | [Go](../problems/shortest-common-supersequence) | Hard | +| 1093 | [Statistics from a Large Sample](https://leetcode.com/problems/statistics-from-a-large-sample "大样本统计") | [Go](../problems/statistics-from-a-large-sample) | Medium | +| 1094 | [Car Pooling](https://leetcode.com/problems/car-pooling "拼车") | [Go](../problems/car-pooling) | Medium | +| 1095 | [Find in Mountain Array](https://leetcode.com/problems/find-in-mountain-array "山脉数组中查找目标值") | [Go](../problems/find-in-mountain-array) | Hard | +| 1096 | [Brace Expansion II](https://leetcode.com/problems/brace-expansion-ii "花括号展开 II") | [Go](../problems/brace-expansion-ii) | Hard | +| 1097 | [Game Play Analysis V](https://leetcode.com/problems/game-play-analysis-v "游戏玩法分析 V") 🔒 | [MySQL](../problems/game-play-analysis-v) | Hard | +| 1098 | [Unpopular Books](https://leetcode.com/problems/unpopular-books "小众书籍") 🔒 | [MySQL](../problems/unpopular-books) | Medium | +| 1099 | [Two Sum Less Than K](https://leetcode.com/problems/two-sum-less-than-k "小于 K 的两数之和") 🔒 | [Go](../problems/two-sum-less-than-k) | Easy | +| 1100 | [Find K-Length Substrings With No Repeated Characters](https://leetcode.com/problems/find-k-length-substrings-with-no-repeated-characters "长度为 K 的无重复字符子串") 🔒 | [Go](../problems/find-k-length-substrings-with-no-repeated-characters) | Medium | +| 1101 | [The Earliest Moment When Everyone Become Friends](https://leetcode.com/problems/the-earliest-moment-when-everyone-become-friends "彼此熟识的最早时间") 🔒 | [Go](../problems/the-earliest-moment-when-everyone-become-friends) | Medium | +| 1102 | [Path With Maximum Minimum Value](https://leetcode.com/problems/path-with-maximum-minimum-value "得分最高的路径") 🔒 | [Go](../problems/path-with-maximum-minimum-value) | Medium | +| 1103 | [Distribute Candies to People](https://leetcode.com/problems/distribute-candies-to-people "分糖果 II") | [Go](../problems/distribute-candies-to-people) | Easy | +| 1104 | [Path In Zigzag Labelled Binary Tree](https://leetcode.com/problems/path-in-zigzag-labelled-binary-tree "二叉树寻路") | [Go](../problems/path-in-zigzag-labelled-binary-tree) | Medium | +| 1105 | [Filling Bookcase Shelves](https://leetcode.com/problems/filling-bookcase-shelves "填充书架") | [Go](../problems/filling-bookcase-shelves) | Medium | +| 1106 | [Parsing A Boolean Expression](https://leetcode.com/problems/parsing-a-boolean-expression "解析布尔表达式") | [Go](../problems/parsing-a-boolean-expression) | Hard | +| 1107 | [New Users Daily Count](https://leetcode.com/problems/new-users-daily-count "每日新用户统计") 🔒 | [MySQL](../problems/new-users-daily-count) | Medium | +| 1108 | [Defanging an IP Address](https://leetcode.com/problems/defanging-an-ip-address "IP 地址无效化") | [Go](../problems/defanging-an-ip-address) | Easy | +| 1109 | [Corporate Flight Bookings](https://leetcode.com/problems/corporate-flight-bookings "航班预订统计") | [Go](../problems/corporate-flight-bookings) | Medium | +| 1110 | [Delete Nodes And Return Forest](https://leetcode.com/problems/delete-nodes-and-return-forest "删点成林") | [Go](../problems/delete-nodes-and-return-forest) | Medium | +| 1111 | [Maximum Nesting Depth of Two Valid Parentheses Strings](https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings "有效括号的嵌套深度") | [Go](../problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | Medium | +| 1112 | [Highest Grade For Each Student](https://leetcode.com/problems/highest-grade-for-each-student "每位学生的最高成绩") 🔒 | [MySQL](../problems/highest-grade-for-each-student) | Medium | +| 1113 | [Reported Posts](https://leetcode.com/problems/reported-posts "报告的记录") 🔒 | [MySQL](../problems/reported-posts) | Easy | +| 1114 | [Print in Order](https://leetcode.com/problems/print-in-order "按序打印") | [Go](../problems/print-in-order) | Easy | +| 1115 | [Print FooBar Alternately](https://leetcode.com/problems/print-foobar-alternately "交替打印FooBar") | [Go](../problems/print-foobar-alternately) | Medium | +| 1116 | [Print Zero Even Odd](https://leetcode.com/problems/print-zero-even-odd "打印零与奇偶数") | [Go](../problems/print-zero-even-odd) | Medium | +| 1117 | [Building H2O](https://leetcode.com/problems/building-h2o "H2O 生成") | [Go](../problems/building-h2o) | Medium | +| 1118 | [Number of Days in a Month](https://leetcode.com/problems/number-of-days-in-a-month "一月有多少天") 🔒 | [Go](../problems/number-of-days-in-a-month) | Easy | +| 1119 | [Remove Vowels from a String](https://leetcode.com/problems/remove-vowels-from-a-string "删去字符串中的元音") 🔒 | [Go](../problems/remove-vowels-from-a-string) | Easy | +| 1120 | [Maximum Average Subtree](https://leetcode.com/problems/maximum-average-subtree "子树的最大平均值") 🔒 | [Go](../problems/maximum-average-subtree) | Medium | +| 1121 | [Divide Array Into Increasing Sequences](https://leetcode.com/problems/divide-array-into-increasing-sequences "将数组分成几个递增序列") 🔒 | [Go](../problems/divide-array-into-increasing-sequences) | Hard | +| 1122 | [Relative Sort Array](https://leetcode.com/problems/relative-sort-array "数组的相对排序") | [Go](../problems/relative-sort-array) | Easy | +| 1123 | [Lowest Common Ancestor of Deepest Leaves](https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves "最深叶节点的最近公共祖先") | [Go](../problems/lowest-common-ancestor-of-deepest-leaves) | Medium | +| 1124 | [Longest Well-Performing Interval](https://leetcode.com/problems/longest-well-performing-interval "表现良好的最长时间段") | [Go](../problems/longest-well-performing-interval) | Medium | +| 1125 | [Smallest Sufficient Team](https://leetcode.com/problems/smallest-sufficient-team "最小的必要团队") | [Go](../problems/smallest-sufficient-team) | Hard | +| 1126 | [Active Businesses](https://leetcode.com/problems/active-businesses "查询活跃业务") 🔒 | [MySQL](../problems/active-businesses) | Medium | +| 1127 | [User Purchase Platform](https://leetcode.com/problems/user-purchase-platform "用户购买平台") 🔒 | [MySQL](../problems/user-purchase-platform) | Hard | +| 1128 | [Number of Equivalent Domino Pairs](https://leetcode.com/problems/number-of-equivalent-domino-pairs "等价多米诺骨牌对的数量") | [Go](../problems/number-of-equivalent-domino-pairs) | Easy | +| 1129 | [Shortest Path with Alternating Colors](https://leetcode.com/problems/shortest-path-with-alternating-colors "颜色交替的最短路径") | [Go](../problems/shortest-path-with-alternating-colors) | Medium | +| 1130 | [Minimum Cost Tree From Leaf Values](https://leetcode.com/problems/minimum-cost-tree-from-leaf-values "叶值的最小代价生成树") | [Go](../problems/minimum-cost-tree-from-leaf-values) | Medium | +| 1131 | [Maximum of Absolute Value Expression](https://leetcode.com/problems/maximum-of-absolute-value-expression "绝对值表达式的最大值") | [Go](../problems/maximum-of-absolute-value-expression) | Medium | +| 1132 | [Reported Posts II](https://leetcode.com/problems/reported-posts-ii "报告的记录 II") 🔒 | [MySQL](../problems/reported-posts-ii) | Medium | +| 1133 | [Largest Unique Number](https://leetcode.com/problems/largest-unique-number "最大唯一数") 🔒 | [Go](../problems/largest-unique-number) | Easy | +| 1134 | [Armstrong Number](https://leetcode.com/problems/armstrong-number "阿姆斯特朗数") 🔒 | [Go](../problems/armstrong-number) | Easy | +| 1135 | [Connecting Cities With Minimum Cost](https://leetcode.com/problems/connecting-cities-with-minimum-cost "最低成本联通所有城市") 🔒 | [Go](../problems/connecting-cities-with-minimum-cost) | Medium | +| 1136 | [Parallel Courses](https://leetcode.com/problems/parallel-courses "平行课程") 🔒 | [Go](../problems/parallel-courses) | Hard | +| 1137 | [N-th Tribonacci Number](https://leetcode.com/problems/n-th-tribonacci-number "第 N 个泰波那契数") | [Go](../problems/n-th-tribonacci-number) | Easy | +| 1138 | [Alphabet Board Path](https://leetcode.com/problems/alphabet-board-path "字母板上的路径") | [Go](../problems/alphabet-board-path) | Medium | +| 1139 | [Largest 1-Bordered Square](https://leetcode.com/problems/largest-1-bordered-square "最大的以 1 为边界的正方形") | [Go](../problems/largest-1-bordered-square) | Medium | +| 1140 | [Stone Game II](https://leetcode.com/problems/stone-game-ii "石子游戏 II") | [Go](../problems/stone-game-ii) | Medium | +| 1141 | [User Activity for the Past 30 Days I](https://leetcode.com/problems/user-activity-for-the-past-30-days-i "查询近30天活跃用户数") 🔒 | [MySQL](../problems/user-activity-for-the-past-30-days-i) | Easy | +| 1142 | [User Activity for the Past 30 Days II](https://leetcode.com/problems/user-activity-for-the-past-30-days-ii "过去30天的用户活动 II") 🔒 | [MySQL](../problems/user-activity-for-the-past-30-days-ii) | Easy | +| 1143 | [Longest Common Subsequence](https://leetcode.com/problems/longest-common-subsequence "最长公共子序列") | [Go](../problems/longest-common-subsequence) | Medium | +| 1144 | [Decrease Elements To Make Array Zigzag](https://leetcode.com/problems/decrease-elements-to-make-array-zigzag "递减元素使数组呈锯齿状") | [Go](../problems/decrease-elements-to-make-array-zigzag) | Medium | +| 1145 | [Binary Tree Coloring Game](https://leetcode.com/problems/binary-tree-coloring-game "二叉树着色游戏") | [Go](../problems/binary-tree-coloring-game) | Medium | +| 1146 | [Snapshot Array](https://leetcode.com/problems/snapshot-array "快照数组") | [Go](../problems/snapshot-array) | Medium | +| 1147 | [Longest Chunked Palindrome Decomposition](https://leetcode.com/problems/longest-chunked-palindrome-decomposition "段式回文") | [Go](../problems/longest-chunked-palindrome-decomposition) | Hard | +| 1148 | [Article Views I](https://leetcode.com/problems/article-views-i "文章浏览 I") 🔒 | [MySQL](../problems/article-views-i) | Easy | +| 1149 | [Article Views II](https://leetcode.com/problems/article-views-ii "文章浏览 II") 🔒 | [MySQL](../problems/article-views-ii) | Medium | +| 1150 | [Check If a Number Is Majority Element in a Sorted Array](https://leetcode.com/problems/check-if-a-number-is-majority-element-in-a-sorted-array "检查一个数是否在数组中占绝大多数") 🔒 | [Go](../problems/check-if-a-number-is-majority-element-in-a-sorted-array) | Easy | +| 1151 | [Minimum Swaps to Group All 1's Together](https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together "最少交换次数来组合所有的 1") 🔒 | [Go](../problems/minimum-swaps-to-group-all-1s-together) | Medium | +| 1152 | [Analyze User Website Visit Pattern](https://leetcode.com/problems/analyze-user-website-visit-pattern "用户网站访问行为分析") 🔒 | [Go](../problems/analyze-user-website-visit-pattern) | Medium | +| 1153 | [String Transforms Into Another String](https://leetcode.com/problems/string-transforms-into-another-string "字符串转化") 🔒 | [Go](../problems/string-transforms-into-another-string) | Hard | +| 1154 | [Day of the Year](https://leetcode.com/problems/day-of-the-year "一年中的第几天") | [Go](../problems/day-of-the-year) | Easy | +| 1155 | [Number of Dice Rolls With Target Sum](https://leetcode.com/problems/number-of-dice-rolls-with-target-sum "掷骰子的N种方法") | [Go](../problems/number-of-dice-rolls-with-target-sum) | Medium | +| 1156 | [Swap For Longest Repeated Character Substring](https://leetcode.com/problems/swap-for-longest-repeated-character-substring "单字符重复子串的最大长度") | [Go](../problems/swap-for-longest-repeated-character-substring) | Medium | +| 1157 | [Online Majority Element In Subarray](https://leetcode.com/problems/online-majority-element-in-subarray "子数组中占绝大多数的元素") | [Go](../problems/online-majority-element-in-subarray) | Hard | +| 1158 | [Market Analysis I](https://leetcode.com/problems/market-analysis-i "市场分析 I") 🔒 | [MySQL](../problems/market-analysis-i) | Medium | +| 1159 | [Market Analysis II](https://leetcode.com/problems/market-analysis-ii "市场分析 II") 🔒 | [MySQL](../problems/market-analysis-ii) | Hard | +| 1160 | [Find Words That Can Be Formed by Characters](https://leetcode.com/problems/find-words-that-can-be-formed-by-characters "拼写单词") | [Go](../problems/find-words-that-can-be-formed-by-characters) | Easy | +| 1161 | [Maximum Level Sum of a Binary Tree](https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree "最大层内元素和") | [Go](../problems/maximum-level-sum-of-a-binary-tree) | Medium | +| 1162 | [As Far from Land as Possible](https://leetcode.com/problems/as-far-from-land-as-possible "地图分析") | [Go](../problems/as-far-from-land-as-possible) | Medium | +| 1163 | [Last Substring in Lexicographical Order](https://leetcode.com/problems/last-substring-in-lexicographical-order "按字典序排在最后的子串") | [Go](../problems/last-substring-in-lexicographical-order) | Hard | +| 1164 | [Product Price at a Given Date](https://leetcode.com/problems/product-price-at-a-given-date "指定日期的产品价格") 🔒 | [MySQL](../problems/product-price-at-a-given-date) | Medium | +| 1165 | [Single-Row Keyboard](https://leetcode.com/problems/single-row-keyboard "单行键盘") 🔒 | [Go](../problems/single-row-keyboard) | Easy | +| 1166 | [Design File System](https://leetcode.com/problems/design-file-system "设计文件系统") 🔒 | [Go](../problems/design-file-system) | Medium | +| 1167 | [Minimum Cost to Connect Sticks](https://leetcode.com/problems/minimum-cost-to-connect-sticks "连接棒材的最低费用") 🔒 | [Go](../problems/minimum-cost-to-connect-sticks) | Medium | +| 1168 | [Optimize Water Distribution in a Village](https://leetcode.com/problems/optimize-water-distribution-in-a-village "水资源分配优化") 🔒 | [Go](../problems/optimize-water-distribution-in-a-village) | Hard | +| 1169 | [Invalid Transactions](https://leetcode.com/problems/invalid-transactions "查询无效交易") | [Go](../problems/invalid-transactions) | Medium | +| 1170 | [Compare Strings by Frequency of the Smallest Character](https://leetcode.com/problems/compare-strings-by-frequency-of-the-smallest-character "比较字符串最小字母出现频次") | [Go](../problems/compare-strings-by-frequency-of-the-smallest-character) | Easy | +| 1171 | [Remove Zero Sum Consecutive Nodes from Linked List](https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list "从链表中删去总和值为零的连续节点") | [Go](../problems/remove-zero-sum-consecutive-nodes-from-linked-list) | Medium | +| 1172 | [Dinner Plate Stacks](https://leetcode.com/problems/dinner-plate-stacks "餐盘栈") | [Go](../problems/dinner-plate-stacks) | Hard | +| 1173 | [Immediate Food Delivery I](https://leetcode.com/problems/immediate-food-delivery-i "即时食物配送 I") 🔒 | [MySQL](../problems/immediate-food-delivery-i) | Easy | +| 1174 | [Immediate Food Delivery II](https://leetcode.com/problems/immediate-food-delivery-ii "即时食物配送 II") 🔒 | [MySQL](../problems/immediate-food-delivery-ii) | Medium | +| 1175 | [Prime Arrangements](https://leetcode.com/problems/prime-arrangements "质数排列") | [Go](../problems/prime-arrangements) | Easy | +| 1176 | [Diet Plan Performance](https://leetcode.com/problems/diet-plan-performance "健身计划评估") 🔒 | [Go](../problems/diet-plan-performance) | Easy | +| 1177 | [Can Make Palindrome from Substring](https://leetcode.com/problems/can-make-palindrome-from-substring "构建回文串检测") | [Go](../problems/can-make-palindrome-from-substring) | Medium | +| 1178 | [Number of Valid Words for Each Puzzle](https://leetcode.com/problems/number-of-valid-words-for-each-puzzle "猜字谜") | [Go](../problems/number-of-valid-words-for-each-puzzle) | Hard | +| 1179 | [Reformat Department Table](https://leetcode.com/problems/reformat-department-table "重新格式化部门表") | [MySQL](../problems/reformat-department-table) | Easy | +| 1180 | [Count Substrings with Only One Distinct Letter](https://leetcode.com/problems/count-substrings-with-only-one-distinct-letter "统计只含单一字母的子串") 🔒 | [Go](../problems/count-substrings-with-only-one-distinct-letter) | Easy | +| 1181 | [Before and After Puzzle](https://leetcode.com/problems/before-and-after-puzzle "前后拼接") 🔒 | [Go](../problems/before-and-after-puzzle) | Medium | +| 1182 | [Shortest Distance to Target Color](https://leetcode.com/problems/shortest-distance-to-target-color "与目标颜色间的最短距离") 🔒 | [Go](../problems/shortest-distance-to-target-color) | Medium | +| 1183 | [Maximum Number of Ones](https://leetcode.com/problems/maximum-number-of-ones "矩阵中 1 的最大数量") 🔒 | [Go](../problems/maximum-number-of-ones) | Hard | +| 1184 | [Distance Between Bus Stops](https://leetcode.com/problems/distance-between-bus-stops "公交站间的距离") | [Go](../problems/distance-between-bus-stops) | Easy | +| 1185 | [Day of the Week](https://leetcode.com/problems/day-of-the-week "一周中的第几天") | [Go](../problems/day-of-the-week) | Easy | +| 1186 | [Maximum Subarray Sum with One Deletion](https://leetcode.com/problems/maximum-subarray-sum-with-one-deletion "删除一次得到子数组最大和") | [Go](../problems/maximum-subarray-sum-with-one-deletion) | Medium | +| 1187 | [Make Array Strictly Increasing](https://leetcode.com/problems/make-array-strictly-increasing "使数组严格递增") | [Go](../problems/make-array-strictly-increasing) | Hard | +| 1188 | [Design Bounded Blocking Queue](https://leetcode.com/problems/design-bounded-blocking-queue "设计有限阻塞队列") 🔒 | [Go](../problems/design-bounded-blocking-queue) | Medium | +| 1189 | [Maximum Number of Balloons](https://leetcode.com/problems/maximum-number-of-balloons "“气球” 的最大数量") | [Go](../problems/maximum-number-of-balloons) | Easy | +| 1190 | [Reverse Substrings Between Each Pair of Parentheses](https://leetcode.com/problems/reverse-substrings-between-each-pair-of-parentheses "反转每对括号间的子串") | [Go](../problems/reverse-substrings-between-each-pair-of-parentheses) | Medium | +| 1191 | [K-Concatenation Maximum Sum](https://leetcode.com/problems/k-concatenation-maximum-sum "K 次串联后最大子数组之和") | [Go](../problems/k-concatenation-maximum-sum) | Medium | +| 1192 | [Critical Connections in a Network](https://leetcode.com/problems/critical-connections-in-a-network "查找集群内的「关键连接」") | [Go](../problems/critical-connections-in-a-network) | Hard | +| 1193 | [Monthly Transactions I](https://leetcode.com/problems/monthly-transactions-i "每月交易 I") 🔒 | [MySQL](../problems/monthly-transactions-i) | Medium | +| 1194 | [Tournament Winners](https://leetcode.com/problems/tournament-winners "锦标赛优胜者") 🔒 | [MySQL](../problems/tournament-winners) | Hard | +| 1195 | [Fizz Buzz Multithreaded](https://leetcode.com/problems/fizz-buzz-multithreaded "交替打印字符串") | [Go](../problems/fizz-buzz-multithreaded) | Medium | +| 1196 | [How Many Apples Can You Put into the Basket](https://leetcode.com/problems/how-many-apples-can-you-put-into-the-basket "最多可以买到的苹果数量") 🔒 | [Go](../problems/how-many-apples-can-you-put-into-the-basket) | Easy | +| 1197 | [Minimum Knight Moves](https://leetcode.com/problems/minimum-knight-moves "进击的骑士") 🔒 | [Go](../problems/minimum-knight-moves) | Medium | +| 1198 | [Find Smallest Common Element in All Rows](https://leetcode.com/problems/find-smallest-common-element-in-all-rows "找出所有行中最小公共元素") 🔒 | [Go](../problems/find-smallest-common-element-in-all-rows) | Medium | +| 1199 | [Minimum Time to Build Blocks](https://leetcode.com/problems/minimum-time-to-build-blocks "建造街区的最短时间") 🔒 | [Go](../problems/minimum-time-to-build-blocks) | Hard | +| 1200 | [Minimum Absolute Difference](https://leetcode.com/problems/minimum-absolute-difference "最小绝对差") | [Go](../problems/minimum-absolute-difference) | Easy | diff --git a/tag/README.md b/tag/README.md index 3108a4597..9b23f734f 100644 --- a/tag/README.md +++ b/tag/README.md @@ -15,7 +15,7 @@ | 7 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | | 8 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 9 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | | 11 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 12 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | -| 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | +| 13 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 14 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 15 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 16 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | | 19 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 20 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | @@ -24,8 +24,8 @@ | 25 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | | 27 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 29 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | -| 31 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | | 32 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | -| 33 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | | 34 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | +| 31 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 32 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | +| 33 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 34 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | | 35 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | | 37 | [Reservoir Sampling](reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | | 38 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | | 39 | [Memoization](memoization/README.md) | [记忆化](https://openset.github.io/tags/memoization/) | | 40 | [Suffix Array](suffix-array/README.md) | [Suffix Array](https://openset.github.io/tags/suffix-array/) | diff --git a/tag/array/README.md b/tag/array/README.md index 8c22d9bc1..c3e024ead 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1503 | [所有蚂蚁掉下来前的最后一刻](../../problems/last-moment-before-all-ants-fall-out-of-a-plank) | [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] | Medium | +| 1502 | [判断能否形成等差数列](../../problems/can-make-arithmetic-progression-from-sequence) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | | 1500 | [Design a File Sharing System](../../problems/design-a-file-sharing-system) 🔒 | [[数组](../array/README.md)] | Medium | | 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/brainteaser/README.md b/tag/brainteaser/README.md index e6f0d0760..8caef952a 100644 --- a/tag/brainteaser/README.md +++ b/tag/brainteaser/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1503 | [所有蚂蚁掉下来前的最后一刻](../../problems/last-moment-before-all-ants-fall-out-of-a-plank) | [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] | Medium | | 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1033 | [移动石子直到连续](../../problems/moving-stones-until-consecutive) | [[脑筋急转弯](../brainteaser/README.md)] | Easy | | 777 | [在LR字符串中交换相邻字符](../../problems/swap-adjacent-in-lr-string) | [[脑筋急转弯](../brainteaser/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index d87b39ed8..0d5ecee39 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1504 | [统计全 1 子矩形](../../problems/count-submatrices-with-all-ones) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1483 | [树节点的第 K 个祖先](../../problems/kth-ancestor-of-a-tree-node) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1477 | [找两个和为目标值且不重叠的子数组](../../problems/find-two-non-overlapping-sub-arrays-each-with-target-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 0e8d15254..9027bc45e 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1505 | [最多 K 次交换相邻数位后得到的最小整数](../../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | [[贪心算法](../greedy/README.md)] | Hard | | 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1414 | [和为 K 的最少斐波那契数字数目](../../problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index ee397f312..2449f3581 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1502 | [判断能否形成等差数列](../../problems/can-make-arithmetic-progression-from-sequence) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | | 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[排序](../sort/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1491 | [去掉最低工资和最高工资后的工资平均值](../../problems/average-salary-excluding-the-minimum-and-maximum-salary) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | | 1481 | [不同整数的最少数目](../../problems/least-number-of-unique-integers-after-k-removals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/tags.json b/tag/tags.json index 1f059d765..2d248ad99 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -59,16 +59,16 @@ "Slug": "stack", "TranslatedName": "栈" }, - { - "Name": "Backtracking", - "Slug": "backtracking", - "TranslatedName": "回溯算法" - }, { "Name": "Sort", "Slug": "sort", "TranslatedName": "排序" }, + { + "Name": "Backtracking", + "Slug": "backtracking", + "TranslatedName": "回溯算法" + }, { "Name": "Bit Manipulation", "Slug": "bit-manipulation", @@ -149,6 +149,11 @@ "Slug": "binary-indexed-tree", "TranslatedName": "树状数组" }, + { + "Name": "Brainteaser", + "Slug": "brainteaser", + "TranslatedName": "脑筋急转弯" + }, { "Name": "Line Sweep", "Slug": "line-sweep", @@ -164,11 +169,6 @@ "Slug": "topological-sort", "TranslatedName": "拓扑排序" }, - { - "Name": "Brainteaser", - "Slug": "brainteaser", - "TranslatedName": "脑筋急转弯" - }, { "Name": "Binary Search Tree", "Slug": "binary-search-tree", From 7a8906bddda696e7312b8db3b1e42df72c0e1b4d Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 7 Jul 2020 14:37:47 +0800 Subject: [PATCH 087/145] A: Destination City --- problems/destination-city/destination_city.go | 14 +++++++ .../destination-city/destination_city_test.go | 41 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 problems/destination-city/destination_city.go create mode 100644 problems/destination-city/destination_city_test.go diff --git a/problems/destination-city/destination_city.go b/problems/destination-city/destination_city.go new file mode 100644 index 000000000..cfac2933c --- /dev/null +++ b/problems/destination-city/destination_city.go @@ -0,0 +1,14 @@ +package problem1436 + +func destCity(paths [][]string) string { + m := make(map[string]bool) + for _, path := range paths { + m[path[0]] = true + } + for _, path := range paths { + if !m[path[1]] { + return path[1] + } + } + return "" +} diff --git a/problems/destination-city/destination_city_test.go b/problems/destination-city/destination_city_test.go new file mode 100644 index 000000000..f8fb17013 --- /dev/null +++ b/problems/destination-city/destination_city_test.go @@ -0,0 +1,41 @@ +package problem1436 + +import "testing" + +type testType struct { + in [][]string + want string +} + +func TestDestCity(t *testing.T) { + tests := [...]testType{ + { + in: [][]string{ + {"London", "New York"}, + {"New York", "Lima"}, + {"Lima", "Sao Paulo"}, + }, + want: "Sao Paulo", + }, + { + in: [][]string{ + {"B", "C"}, + {"D", "B"}, + {"C", "A"}, + }, + want: "A", + }, + { + in: [][]string{ + {"A", "Z"}, + }, + want: "Z", + }, + } + for _, tt := range tests { + got := destCity(tt.in) + if got != tt.want { + t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want) + } + } +} From 6c3b55fdd5686d0c01a703045f5a43df110a44ec Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 7 Jul 2020 14:43:57 +0800 Subject: [PATCH 088/145] A: Destination City --- problems/destination-city/destination_city_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/problems/destination-city/destination_city_test.go b/problems/destination-city/destination_city_test.go index f8fb17013..c305e679d 100644 --- a/problems/destination-city/destination_city_test.go +++ b/problems/destination-city/destination_city_test.go @@ -31,6 +31,13 @@ func TestDestCity(t *testing.T) { }, want: "Z", }, + { + in: [][]string{ + {"A", "B"}, + {"B", "A"}, + }, + want: "", + }, } for _, tt := range tests { got := destCity(tt.in) From cccea337ed95156d2266697fe118ad4b4d3d5e7e Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 13 Jul 2020 13:24:40 +0800 Subject: [PATCH 089/145] A: new --- README.md | 10 +++ .../README.md | 85 +++++++++++++++++++ problems/combination-sum/README.md | 10 +++ problems/customer-order-frequency/README.md | 14 +++ .../mysql_schemas.sql | 23 +++++ problems/decoded-string-at-index/README.md | 14 +-- problems/find-root-of-n-ary-tree/README.md | 20 +++++ .../README.md | 66 ++++++++++++++ .../README.md | 2 +- problems/most-frequent-subtree-sum/README.md | 2 +- problems/number-of-good-pairs/README.md | 61 +++++++++++++ problems/number-of-islands/README.md | 33 +++---- .../README.md | 70 +++++++++++++++ .../path-with-maximum-probability/README.md | 81 ++++++++++++++++++ problems/plus-one/README.md | 4 +- .../README.md | 65 ++++++++++++++ problems/reformat-date/README.md | 71 ++++++++++++++++ problems/stone-game-iv/README.md | 76 +++++++++++++++++ problems/video-stitching/README.md | 2 +- tag/README.md | 8 +- tag/array/README.md | 3 + tag/dynamic-programming/README.md | 1 + tag/geometry/README.md | 1 + tag/graph/README.md | 1 + tag/hash-table/README.md | 1 + tag/math/README.md | 2 + tag/sort/README.md | 2 + tag/string/README.md | 2 + tag/tags.json | 20 ++--- 29 files changed, 708 insertions(+), 42 deletions(-) create mode 100644 problems/best-position-for-a-service-centre/README.md create mode 100644 problems/customer-order-frequency/README.md create mode 100644 problems/customer-order-frequency/mysql_schemas.sql create mode 100644 problems/find-root-of-n-ary-tree/README.md create mode 100644 problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md create mode 100644 problems/number-of-good-pairs/README.md create mode 100644 problems/number-of-substrings-with-only-1s/README.md create mode 100644 problems/path-with-maximum-probability/README.md create mode 100644 problems/range-sum-of-sorted-subarray-sums/README.md create mode 100644 problems/reformat-date/README.md create mode 100644 problems/stone-game-iv/README.md diff --git a/README.md b/README.md index ca5551603..41e851012 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,16 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1515 | [Best Position for a Service Centre](https://leetcode.com/problems/best-position-for-a-service-centre "服务中心的最佳位置") | [Go](problems/best-position-for-a-service-centre) | Hard | +| 1514 | [Path with Maximum Probability](https://leetcode.com/problems/path-with-maximum-probability "概率最大的路径") | [Go](problems/path-with-maximum-probability) | Medium | +| 1513 | [Number of Substrings With Only 1s](https://leetcode.com/problems/number-of-substrings-with-only-1s "仅含 1 的子串数") | [Go](problems/number-of-substrings-with-only-1s) | Medium | +| 1512 | [Number of Good Pairs](https://leetcode.com/problems/number-of-good-pairs "好数对的数目") | [Go](problems/number-of-good-pairs) | Easy | +| 1511 | [Customer Order Frequency](https://leetcode.com/problems/customer-order-frequency) 🔒 | [MySQL](problems/customer-order-frequency) | Easy | +| 1510 | [Stone Game IV](https://leetcode.com/problems/stone-game-iv "石子游戏 IV") | [Go](problems/stone-game-iv) | Hard | +| 1509 | [Minimum Difference Between Largest and Smallest Value in Three Moves](https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves "三次操作后最大值与最小值的最小差") | [Go](problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | Medium | +| 1508 | [Range Sum of Sorted Subarray Sums](https://leetcode.com/problems/range-sum-of-sorted-subarray-sums "子数组和排序后的区间和") | [Go](problems/range-sum-of-sorted-subarray-sums) | Medium | +| 1507 | [Reformat Date](https://leetcode.com/problems/reformat-date "转变日期格式") | [Go](problems/reformat-date) | Easy | +| 1506 | [Find Root of N-Ary Tree](https://leetcode.com/problems/find-root-of-n-ary-tree) 🔒 | [Go](problems/find-root-of-n-ary-tree) | Medium | | 1505 | [Minimum Possible Integer After at Most K Adjacent Swaps On Digits](https://leetcode.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "最多 K 次交换相邻数位后得到的最小整数") | [Go](problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | Hard | | 1504 | [Count Submatrices With All Ones](https://leetcode.com/problems/count-submatrices-with-all-ones "统计全 1 子矩形") | [Go](problems/count-submatrices-with-all-ones) | Medium | | 1503 | [Last Moment Before All Ants Fall Out of a Plank](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank "所有蚂蚁掉下来前的最后一刻") | [Go](problems/last-moment-before-all-ants-fall-out-of-a-plank) | Medium | diff --git a/problems/best-position-for-a-service-centre/README.md b/problems/best-position-for-a-service-centre/README.md new file mode 100644 index 000000000..a3e2ddf1f --- /dev/null +++ b/problems/best-position-for-a-service-centre/README.md @@ -0,0 +1,85 @@ + + + + + + + +[< Previous](../path-with-maximum-probability "Path with Maximum Probability") +                 +Next > + +## [1515. Best Position for a Service Centre (Hard)](https://leetcode.com/problems/best-position-for-a-service-centre "服务中心的最佳位置") + +

      A delivery company wants to build a new service centre in a new city. The company knows the positions of all the customers in this city on a 2D-Map and wants to build the new centre in a position such that the sum of the euclidean distances to all customers is minimum.

      + +

      Given an array positions where positions[i] = [xi, yi] is the position of the ith customer on the map, return the minimum sum of the euclidean distances to all customers.

      + +

      In other words, you need to choose the position of the service centre [xcentre, ycentre] such that the following formula is minimized:

      + +

      Answers within 10^-5 of the actual value will be accepted.

      + +

       

      +

      Example 1:

      + +
      +Input: positions = [[0,1],[1,0],[1,2],[2,1]]
      +Output: 4.00000
      +Explanation: As shown, you can see that choosing [xcentre, ycentre] = [1, 1] will make the distance to each customer = 1, the sum of all distances is 4 which is the minimum possible we can achieve.
      +
      + +

      Example 2:

      + +
      +Input: positions = [[1,1],[3,3]]
      +Output: 2.82843
      +Explanation: The minimum possible sum of distances = sqrt(2) + sqrt(2) = 2.82843
      +
      + +

      Example 3:

      + +
      +Input: positions = [[1,1]]
      +Output: 0.00000
      +
      + +

      Example 4:

      + +
      +Input: positions = [[1,1],[0,0],[2,0]]
      +Output: 2.73205
      +Explanation: At the first glance, you may think that locating the centre at [1, 0] will achieve the minimum sum, but locating it at [1, 0] will make the sum of distances = 3.
      +Try to locate the centre at [1.0, 0.5773502711] you will see that the sum of distances is 2.73205.
      +Be careful with the precision!
      +
      + +

      Example 5:

      + +
      +Input: positions = [[0,1],[3,2],[4,5],[7,6],[8,9],[11,1],[2,12]]
      +Output: 32.94036
      +Explanation: You can use [4.3460852395, 4.9813795505] as the position of the centre.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= positions.length <= 50
      • +
      • positions[i].length == 2
      • +
      • 0 <= positions[i][0], positions[i][1] <= 100
      • +
      + +### Related Topics + [[Geometry](../../tag/geometry/README.md)] + +### Hints +
      +Hint 1 +The problem can be reworded as, giving a set of points on a 2d-plane, return the geometric median. +
      + +
      +Hint 2 +Loop over each triplet of points (positions[i], positions[j], positions[k]) where i < j < k, get the centre of the circle which goes throw the 3 points, check if all other points lie in this circle. +
      diff --git a/problems/combination-sum/README.md b/problems/combination-sum/README.md index 3e9c9ac70..a135f7402 100644 --- a/problems/combination-sum/README.md +++ b/problems/combination-sum/README.md @@ -45,6 +45,16 @@ ] +

       

      +

      Constraints:

      + +
        +
      • 1 <= candidates.length <= 30
      • +
      • 1 <= candidates[i] <= 200
      • +
      • Each element of candidate is unique.
      • +
      • 1 <= target <= 500
      • +
      + ### Related Topics [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/customer-order-frequency/README.md b/problems/customer-order-frequency/README.md new file mode 100644 index 000000000..987168901 --- /dev/null +++ b/problems/customer-order-frequency/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../stone-game-iv "Stone Game IV") +                 +[Next >](../number-of-good-pairs "Number of Good Pairs") + +## [1511. Customer Order Frequency (Easy)](https://leetcode.com/problems/customer-order-frequency "") + + diff --git a/problems/customer-order-frequency/mysql_schemas.sql b/problems/customer-order-frequency/mysql_schemas.sql new file mode 100644 index 000000000..307de3f82 --- /dev/null +++ b/problems/customer-order-frequency/mysql_schemas.sql @@ -0,0 +1,23 @@ +Create table If Not Exists Customers (customer_id int, name varchar(30), country varchar(30)); +Create table If Not Exists Product (product_id int, description varchar(30), price int) +; +Create table If Not Exists Orders (order_id int, customer_id int, product_id int, order_date date, quantity int) +; +Truncate table Customers; +insert into Customers (customer_id, name, country) values ('1', 'Winston', 'USA'); +insert into Customers (customer_id, name, country) values ('2', 'Jonathan', 'Peru'); +insert into Customers (customer_id, name, country) values ('3', 'Moustafa', 'Egypt'); +Truncate table Product; +insert into Product (product_id, description, price) values ('10', 'LC Phone', '300'); +insert into Product (product_id, description, price) values ('20', 'LC T-Shirt', '10'); +insert into Product (product_id, description, price) values ('30', 'LC Book', '45'); +insert into Product (product_id, description, price) values ('40', 'LC Keychain', '2'); +Truncate table Orders; +insert into Orders (order_id, customer_id, product_id, order_date, quantity) values ('1', '1', '10', '2020-06-10', '1'); +insert into Orders (order_id, customer_id, product_id, order_date, quantity) values ('2', '1', '20', '2020-07-01', '1'); +insert into Orders (order_id, customer_id, product_id, order_date, quantity) values ('3', '1', '30', '2020-07-08', '2'); +insert into Orders (order_id, customer_id, product_id, order_date, quantity) values ('4', '2', '10', '2020-06-15', '2'); +insert into Orders (order_id, customer_id, product_id, order_date, quantity) values ('5', '2', '40', '2020-07-01', '10'); +insert into Orders (order_id, customer_id, product_id, order_date, quantity) values ('6', '3', '20', '2020-06-24', '2'); +insert into Orders (order_id, customer_id, product_id, order_date, quantity) values ('7', '3', '30', '2020-06-25', '2'); +insert into Orders (order_id, customer_id, product_id, order_date, quantity) values ('9', '3', '30', '2020-05-08', '3'); diff --git a/problems/decoded-string-at-index/README.md b/problems/decoded-string-at-index/README.md index 08c90384a..6098ee17f 100644 --- a/problems/decoded-string-at-index/README.md +++ b/problems/decoded-string-at-index/README.md @@ -52,21 +52,21 @@ The decoded string is "hahahaha". The 5th letter is "h". Explanation: The decoded string is "a" repeated 8301530446056247680 times. The 1st letter is "a". + + +

       

      +

      Constraints:

      -

      Note:

      - -
        +
        • 2 <= S.length <= 100
        • S will only contain lowercase letters and digits 2 through 9.
        • S starts with a letter.
        • 1 <= K <= 10^9
        • +
        • It's guaranteed that K is less than or equal to the length of the decoded string.
        • The decoded string is guaranteed to have less than 2^63 letters.
        • -
      - - - +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/find-root-of-n-ary-tree/README.md b/problems/find-root-of-n-ary-tree/README.md new file mode 100644 index 000000000..b9d83e14e --- /dev/null +++ b/problems/find-root-of-n-ary-tree/README.md @@ -0,0 +1,20 @@ + + + + + + + +[< Previous](../minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "Minimum Possible Integer After at Most K Adjacent Swaps On Digits") +                 +[Next >](../reformat-date "Reformat Date") + +## [1506. Find Root of N-Ary Tree (Medium)](https://leetcode.com/problems/find-root-of-n-ary-tree "") + + + +### Hints +
    +Hint 1 +Node with indegree 0 is the root +
    diff --git a/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md b/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md new file mode 100644 index 000000000..3e96564df --- /dev/null +++ b/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../range-sum-of-sorted-subarray-sums "Range Sum of Sorted Subarray Sums") +                 +[Next >](../stone-game-iv "Stone Game IV") + +## [1509. Minimum Difference Between Largest and Smallest Value in Three Moves (Medium)](https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves "三次操作后最大值与最小值的最小差") + +

    Given an array nums, you are allowed to choose one element of nums and change it by any value in one move.

    + +

    Return the minimum difference between the largest and smallest value of nums after perfoming at most 3 moves.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [5,3,2,4]
    +Output: 0
    +Explanation: Change the array [5,3,2,4] to [2,2,2,2].
    +The difference between the maximum and minimum is 2-2 = 0.
    + +

    Example 2:

    + +
    +Input: nums = [1,5,0,10,14]
    +Output: 1
    +Explanation: Change the array [1,5,0,10,14] to [1,1,0,1,1]. 
    +The difference between the maximum and minimum is 1-0 = 1.
    +
    + +

    Example 3:

    + +
    +Input: nums = [6,6,0,1,1,4,6]
    +Output: 2
    +
    + +

    Example 4:

    + +
    +Input: nums = [1,5,6,14,15]
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 10^5
    • +
    • -10^9 <= nums[i] <= 10^9
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +The minimum difference possible is is obtained by removing 3 elements between the 3 smallest and 3 largest values in the array. +
    diff --git a/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md b/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md index 833a7c88c..1d21de056 100644 --- a/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md +++ b/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md @@ -7,7 +7,7 @@ [< Previous](../count-submatrices-with-all-ones "Count Submatrices With All Ones")                  -Next > +[Next >](../find-root-of-n-ary-tree "Find Root of N-Ary Tree") ## [1505. Minimum Possible Integer After at Most K Adjacent Swaps On Digits (Hard)](https://leetcode.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "最多 K 次交换相邻数位后得到的最小整数") diff --git a/problems/most-frequent-subtree-sum/README.md b/problems/most-frequent-subtree-sum/README.md index 49dbb76bf..7fd3f56ba 100644 --- a/problems/most-frequent-subtree-sum/README.md +++ b/problems/most-frequent-subtree-sum/README.md @@ -40,8 +40,8 @@ You may assume the sum of values in any subtree is in the range of 32-bit signed

    ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions 1. [Subtree of Another Tree](../subtree-of-another-tree) (Easy) diff --git a/problems/number-of-good-pairs/README.md b/problems/number-of-good-pairs/README.md new file mode 100644 index 000000000..25ba13da7 --- /dev/null +++ b/problems/number-of-good-pairs/README.md @@ -0,0 +1,61 @@ + + + + + + + +[< Previous](../customer-order-frequency "Customer Order Frequency") +                 +[Next >](../number-of-substrings-with-only-1s "Number of Substrings With Only 1s") + +## [1512. Number of Good Pairs (Easy)](https://leetcode.com/problems/number-of-good-pairs "好数对的数目") + +

    Given an array of integers nums.

    + +

    A pair (i,j) is called good if nums[i] == nums[j] and i < j.

    + +

    Return the number of good pairs.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3,1,1,3]
    +Output: 4
    +Explanation: There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,1,1,1]
    +Output: 6
    +Explanation: Each pair in the array are good.
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,2,3]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • 1 <= nums[i] <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Count how many times each number appears. If a number appears n times, then n * (n – 1) // 2 good pairs can be made with this number. +
    diff --git a/problems/number-of-islands/README.md b/problems/number-of-islands/README.md index bac05bb22..6efa55114 100644 --- a/problems/number-of-islands/README.md +++ b/problems/number-of-islands/README.md @@ -13,28 +13,29 @@

    Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input:
    -11110
    -11010
    -11000
    -00000
    -
    -Output: 1
    +Input: grid = [
    +  ["1","1","1","1","0"],
    +  ["1","1","0","1","0"],
    +  ["1","1","0","0","0"],
    +  ["0","0","0","0","0"]
    +]
    +Output: 1
     
    -

    Example 2:

    +

    Example 2:

    -Input:
    -11000
    -11000
    -00100
    -00011
    -
    -Output: 3
    +Input: grid = [
    +  ["1","1","0","0","0"],
    +  ["1","1","0","0","0"],
    +  ["0","0","1","0","0"],
    +  ["0","0","0","1","1"]
    +]
    +Output: 3
     
    ### Related Topics diff --git a/problems/number-of-substrings-with-only-1s/README.md b/problems/number-of-substrings-with-only-1s/README.md new file mode 100644 index 000000000..6a94618ce --- /dev/null +++ b/problems/number-of-substrings-with-only-1s/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../number-of-good-pairs "Number of Good Pairs") +                 +[Next >](../path-with-maximum-probability "Path with Maximum Probability") + +## [1513. Number of Substrings With Only 1s (Medium)](https://leetcode.com/problems/number-of-substrings-with-only-1s "仅含 1 的子串数") + +

    Given a binary string s (a string consisting only of '0' and '1's).

    + +

    Return the number of substrings with all characters 1's.

    + +

    Since the answer may be too large, return it modulo 10^9 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "0110111"
    +Output: 9
    +Explanation: There are 9 substring in total with only 1's characters.
    +"1" -> 5 times.
    +"11" -> 3 times.
    +"111" -> 1 time.
    + +

    Example 2:

    + +
    +Input: s = "101"
    +Output: 2
    +Explanation: Substring "1" is shown 2 times in s.
    +
    + +

    Example 3:

    + +
    +Input: s = "111111"
    +Output: 21
    +Explanation: Each substring contains only 1's characters.
    +
    + +

    Example 4:

    + +
    +Input: s = "000"
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • s[i] == '0' or s[i] == '1'
    • +
    • 1 <= s.length <= 10^5
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Count number of 1s in each consecutive-1 group. For a group with n consecutive 1s, the total contribution of it to the final answer is (n + 1) * n // 2. +
    diff --git a/problems/path-with-maximum-probability/README.md b/problems/path-with-maximum-probability/README.md new file mode 100644 index 000000000..3ff6d6fce --- /dev/null +++ b/problems/path-with-maximum-probability/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../number-of-substrings-with-only-1s "Number of Substrings With Only 1s") +                 +[Next >](../best-position-for-a-service-centre "Best Position for a Service Centre") + +## [1514. Path with Maximum Probability (Medium)](https://leetcode.com/problems/path-with-maximum-probability "概率最大的路径") + +

    You are given an undirected weighted graph of n nodes (0-indexed), represented by an edge list where edges[i] = [a, b] is an undirected edge connecting the nodes a and b with a probability of success of traversing that edge succProb[i].

    + +

    Given two nodes start and end, find the path with the maximum probability of success to go from start to end and return its success probability.

    + +

    If there is no path from start to end, return 0. Your answer will be accepted if it differs from the correct answer by at most 1e-5.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: n = 3, edges = [[0,1],[1,2],[0,2]], succProb = [0.5,0.5,0.2], start = 0, end = 2
    +Output: 0.25000
    +Explanation: There are two paths from start to end, one having a probability of success = 0.2 and the other has 0.5 * 0.5 = 0.25.
    +
    + +

    Example 2:

    + +

    + +
    +Input: n = 3, edges = [[0,1],[1,2],[0,2]], succProb = [0.5,0.5,0.3], start = 0, end = 2
    +Output: 0.30000
    +
    + +

    Example 3:

    + +

    + +
    +Input: n = 3, edges = [[0,1]], succProb = [0.5], start = 0, end = 2
    +Output: 0.00000
    +Explanation: There is no path between 0 and 2.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 10^4
    • +
    • 0 <= start, end < n
    • +
    • start != end
    • +
    • 0 <= a, b < n
    • +
    • a != b
    • +
    • 0 <= succProb.length == edges.length <= 2*10^4
    • +
    • 0 <= succProb[i] <= 1
    • +
    • There is at most one edge between every two nodes.
    • +
    + +### Related Topics + [[Graph](../../tag/graph/README.md)] + +### Hints +
    +Hint 1 +Multiplying probabilities will result in precision errors. +
    + +
    +Hint 2 +Take log probabilities to sum up numbers instead of multiplying them. +
    + +
    +Hint 3 +Use Dijkstra's algorithm to find the minimum path between the two nodes after negating all costs. +
    diff --git a/problems/plus-one/README.md b/problems/plus-one/README.md index 1d9485ad7..787516a64 100644 --- a/problems/plus-one/README.md +++ b/problems/plus-one/README.md @@ -11,9 +11,9 @@ ## [66. Plus One (Easy)](https://leetcode.com/problems/plus-one "加一") -

    Given a non-empty array of digits representing a non-negative integer, plus one to the integer.

    +

    Given a non-empty array of digits representing a non-negative integer, increment one to the integer.

    -

    The digits are stored such that the most significant digit is at the head of the list, and each element in the array contain a single digit.

    +

    The digits are stored such that the most significant digit is at the head of the list, and each element in the array contains a single digit.

    You may assume the integer does not contain any leading zero, except the number 0 itself.

    diff --git a/problems/range-sum-of-sorted-subarray-sums/README.md b/problems/range-sum-of-sorted-subarray-sums/README.md new file mode 100644 index 000000000..0efde7a1c --- /dev/null +++ b/problems/range-sum-of-sorted-subarray-sums/README.md @@ -0,0 +1,65 @@ + + + + + + + +[< Previous](../reformat-date "Reformat Date") +                 +[Next >](../minimum-difference-between-largest-and-smallest-value-in-three-moves "Minimum Difference Between Largest and Smallest Value in Three Moves") + +## [1508. Range Sum of Sorted Subarray Sums (Medium)](https://leetcode.com/problems/range-sum-of-sorted-subarray-sums "子数组和排序后的区间和") + +

    Given the array nums consisting of n positive integers. You computed the sum of all non-empty continous subarrays from the array and then sort them in non-decreasing order, creating a new array of n * (n + 1) / 2 numbers.

    + +

    Return the sum of the numbers from index left to index right (indexed from 1), inclusive, in the new array. Since the answer can be a huge number return it modulo 10^9 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3,4], n = 4, left = 1, right = 5
    +Output: 13 
    +Explanation: All subarray sums are 1, 3, 6, 10, 2, 5, 9, 3, 7, 4. After sorting them in non-decreasing order we have the new array [1, 2, 3, 3, 4, 5, 6, 7, 9, 10]. The sum of the numbers from index le = 1 to ri = 5 is 1 + 2 + 3 + 3 + 4 = 13. 
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,2,3,4], n = 4, left = 3, right = 4
    +Output: 6
    +Explanation: The given array is the same as example 1. We have the new array [1, 2, 3, 3, 4, 5, 6, 7, 9, 10]. The sum of the numbers from index le = 3 to ri = 4 is 3 + 3 = 6.
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,2,3,4], n = 4, left = 1, right = 10
    +Output: 50
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 10^3
    • +
    • nums.length == n
    • +
    • 1 <= nums[i] <= 100
    • +
    • 1 <= left <= right <= n * (n + 1) / 2
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Compute all sums and save it in array. +
    + +
    +Hint 2 +Then just go from LEFT to RIGHT index and calculate answer modulo 1e9 + 7. +
    diff --git a/problems/reformat-date/README.md b/problems/reformat-date/README.md new file mode 100644 index 000000000..672285045 --- /dev/null +++ b/problems/reformat-date/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../find-root-of-n-ary-tree "Find Root of N-Ary Tree") +                 +[Next >](../range-sum-of-sorted-subarray-sums "Range Sum of Sorted Subarray Sums") + +## [1507. Reformat Date (Easy)](https://leetcode.com/problems/reformat-date "转变日期格式") + +

    Given a date string in the form Day Month Year, where:

    + +
      +
    • Day is in the set {"1st", "2nd", "3rd", "4th", ..., "30th", "31st"}.
    • +
    • Month is in the set {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}.
    • +
    • Year is in the range [1900, 2100].
    • +
    + +

    Convert the date string to the format YYYY-MM-DD, where:

    + +
      +
    • YYYY denotes the 4 digit year.
    • +
    • MM denotes the 2 digit month.
    • +
    • DD denotes the 2 digit day.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: date = "20th Oct 2052"
    +Output: "2052-10-20"
    +
    + +

    Example 2:

    + +
    +Input: date = "6th Jun 1933"
    +Output: "1933-06-06"
    +
    + +

    Example 3:

    + +
    +Input: date = "26th May 1960"
    +Output: "1960-05-26"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The given dates are guaranteed to be valid, so no error handling is necessary.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Handle the conversions of day, month and year separately. +
    + +
    +Hint 2 +Notice that days always have a two-word ending, so if you erase the last two characters of this days you'll get the number. +
    diff --git a/problems/stone-game-iv/README.md b/problems/stone-game-iv/README.md new file mode 100644 index 000000000..54f27145f --- /dev/null +++ b/problems/stone-game-iv/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](../minimum-difference-between-largest-and-smallest-value-in-three-moves "Minimum Difference Between Largest and Smallest Value in Three Moves") +                 +[Next >](../customer-order-frequency "Customer Order Frequency") + +## [1510. Stone Game IV (Hard)](https://leetcode.com/problems/stone-game-iv "石子游戏 IV") + +

    Alice and Bob take turns playing a game, with Alice starting first.

    + +

    Initially, there are n stones in a pile.  On each player's turn, that player makes a move consisting of removing any non-zero square number of stones in the pile.

    + +

    Also, if a player cannot make a move, he/she loses the game.

    + +

    Given a positive integer n. Return True if and only if Alice wins the game otherwise return False, assuming both players play optimally.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 1
    +Output: true
    +Explanation: Alice can remove 1 stone winning the game because Bob doesn't have any moves.
    + +

    Example 2:

    + +
    +Input: n = 2
    +Output: false
    +Explanation: Alice can only remove 1 stone, after that Bob removes the last one winning the game (2 -> 1 -> 0).
    + +

    Example 3:

    + +
    +Input: n = 4
    +Output: true
    +Explanation: n is already a perfect square, Alice can win with one move, removing 4 stones (4 -> 0).
    +
    + +

    Example 4:

    + +
    +Input: n = 7
    +Output: false
    +Explanation: Alice can't win the game if Bob plays optimally.
    +If Alice starts removing 4 stones, Bob will remove 1 stone then Alice should remove only 1 stone and finally Bob removes the last one (7 -> 3 -> 2 -> 1 -> 0). 
    +If Alice starts removing 1 stone, Bob will remove 4 stones then Alice only can remove 1 stone and finally Bob removes the last one (7 -> 6 -> 2 -> 1 -> 0).
    + +

    Example 5:

    + +
    +Input: n = 17
    +Output: false
    +Explanation: Alice can't win the game if Bob plays optimally.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 10^5
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Use dynamic programming to keep track of winning and losing states. Given some number of stones, Alice can win if she can force Bob onto a losing state. +
    diff --git a/problems/video-stitching/README.md b/problems/video-stitching/README.md index 18472b3d0..5e0050992 100644 --- a/problems/video-stitching/README.md +++ b/problems/video-stitching/README.md @@ -37,7 +37,7 @@ Now we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 1 Input: clips = [[0,1],[1,2]], T = 5 Output: -1 Explanation: -We can't cover [0,5] with only [0,1] and [0,2]. +We can't cover [0,5] with only [0,1] and [1,2].

    Example 3:

    diff --git a/tag/README.md b/tag/README.md index 9b23f734f..b7540e2f6 100644 --- a/tag/README.md +++ b/tag/README.md @@ -14,16 +14,16 @@ | 5 | [Tree](tree/README.md) | [树](https://openset.github.io/tags/tree/) | | 6 | [Depth-first Search](depth-first-search/README.md) | [深度优先搜索](https://openset.github.io/tags/depth-first-search/) | | 7 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | | 8 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 9 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | -| 11 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 12 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | -| 13 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 14 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | +| 11 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 12 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | +| 13 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | | 14 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 15 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 16 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | | 19 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 20 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | | 21 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | | 22 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | | 23 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | | 25 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | -| 27 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | -| 29 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | +| 27 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | +| 29 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 31 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 32 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | | 33 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 34 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | | 35 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | diff --git a/tag/array/README.md b/tag/array/README.md index c3e024ead..a4046e9e2 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1503 | [所有蚂蚁掉下来前的最后一刻](../../problems/last-moment-before-all-ants-fall-out-of-a-plank) | [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] | Medium | | 1502 | [判断能否形成等差数列](../../problems/can-make-arithmetic-progression-from-sequence) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | | 1500 | [Design a File Sharing System](../../problems/design-a-file-sharing-system) 🔒 | [[数组](../array/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 0d5ecee39..c58fd46e6 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1510 | [石子游戏 IV](../../problems/stone-game-iv) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1504 | [统计全 1 子矩形](../../problems/count-submatrices-with-all-ones) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1483 | [树节点的第 K 个祖先](../../problems/kth-ancestor-of-a-tree-node) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index 6cdb8d902..bbe3153b9 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1515 | [服务中心的最佳位置](../../problems/best-position-for-a-service-centre) | [[几何](../geometry/README.md)] | Hard | | 1453 | [圆形靶内的最大飞镖数量](../../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | [[几何](../geometry/README.md)] | Hard | | 1401 | [圆和矩形是否有重叠](../../problems/circle-and-rectangle-overlapping) | [[几何](../geometry/README.md)] | Medium | | 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] | Easy | diff --git a/tag/graph/README.md b/tag/graph/README.md index 140532a8e..f195964cb 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] | Medium | | 1494 | [并行课程 II](../../problems/parallel-courses-ii) | [[图](../graph/README.md)] | Hard | | 1462 | [课程安排 IV](../../problems/course-schedule-iv) | [[图](../graph/README.md)] | Medium | | 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index e70601db4..0971aa423 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 268d31824..b017f2c51 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1513 | [仅含 1 的子串数](../../problems/number-of-substrings-with-only-1s) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | | 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1492 | [n 的第 k 个因子](../../problems/the-kth-factor-of-n) | [[数学](../math/README.md)] | Medium | | 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/sort/README.md b/tag/sort/README.md index 2449f3581..9daea8b48 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1502 | [判断能否形成等差数列](../../problems/can-make-arithmetic-progression-from-sequence) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | | 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[排序](../sort/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1491 | [去掉最低工资和最高工资后的工资平均值](../../problems/average-salary-excluding-the-minimum-and-maximum-salary) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | diff --git a/tag/string/README.md b/tag/string/README.md index 49cb5540b..e7f33808a 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1513 | [仅含 1 的子串数](../../problems/number-of-substrings-with-only-1s) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1507 | [转变日期格式](../../problems/reformat-date) | [[字符串](../string/README.md)] | Easy | | 1496 | [判断路径是否相交](../../problems/path-crossing) | [[字符串](../string/README.md)] | Easy | | 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/tags.json b/tag/tags.json index 2d248ad99..c3506ec98 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -54,16 +54,16 @@ "Slug": "two-pointers", "TranslatedName": "双指针" }, - { - "Name": "Stack", - "Slug": "stack", - "TranslatedName": "栈" - }, { "Name": "Sort", "Slug": "sort", "TranslatedName": "排序" }, + { + "Name": "Stack", + "Slug": "stack", + "TranslatedName": "栈" + }, { "Name": "Backtracking", "Slug": "backtracking", @@ -134,16 +134,16 @@ "Slug": "queue", "TranslatedName": "队列" }, - { - "Name": "Minimax", - "Slug": "minimax", - "TranslatedName": "极小化极大" - }, { "Name": "Geometry", "Slug": "geometry", "TranslatedName": "几何" }, + { + "Name": "Minimax", + "Slug": "minimax", + "TranslatedName": "极小化极大" + }, { "Name": "Binary Indexed Tree", "Slug": "binary-indexed-tree", From 27bb8eab4885e0b4455e4e97478f8cf0c72fb280 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 20 Jul 2020 09:29:56 +0800 Subject: [PATCH 090/145] A: new --- README.md | 6 ++ .../README.md | 69 ++++++++++++++ .../find-users-with-valid-e-mails/README.md | 14 +++ .../mysql_schemas.sql | 9 ++ .../README.md | 81 +++++++++++++++++ .../maximum-width-of-binary-tree/README.md | 13 ++- .../move-sub-tree-of-n-ary-tree/README.md | 33 +++++++ .../README.md | 90 +++++++++++++++++++ problems/unique-binary-search-trees/README.md | 7 ++ problems/water-bottles/README.md | 72 +++++++++++++++ tag/binary-search/README.md | 1 + tag/bit-manipulation/README.md | 1 + tag/breadth-first-search/README.md | 1 + tag/depth-first-search/README.md | 1 + tag/greedy/README.md | 2 + tag/segment-tree/README.md | 1 + tag/tree/README.md | 1 + 17 files changed, 398 insertions(+), 4 deletions(-) create mode 100644 problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md create mode 100644 problems/find-users-with-valid-e-mails/README.md create mode 100644 problems/find-users-with-valid-e-mails/mysql_schemas.sql create mode 100644 problems/maximum-number-of-non-overlapping-substrings/README.md create mode 100644 problems/move-sub-tree-of-n-ary-tree/README.md create mode 100644 problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md create mode 100644 problems/water-bottles/README.md diff --git a/README.md b/README.md index 41e851012..8918c83c2 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,12 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1521 | [Find a Value of a Mysterious Function Closest to Target](https://leetcode.com/problems/find-a-value-of-a-mysterious-function-closest-to-target "找到最接近目标值的函数值") | [Go](problems/find-a-value-of-a-mysterious-function-closest-to-target) | Hard | +| 1520 | [Maximum Number of Non-Overlapping Substrings](https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings "最多的不重叠子字符串") | [Go](problems/maximum-number-of-non-overlapping-substrings) | Medium | +| 1519 | [Number of Nodes in the Sub-Tree With the Same Label](https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label "子树中标签相同的节点数") | [Go](problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | Medium | +| 1518 | [Water Bottles](https://leetcode.com/problems/water-bottles "换酒问题") | [Go](problems/water-bottles) | Easy | +| 1517 | [Find Users With Valid E-Mails](https://leetcode.com/problems/find-users-with-valid-e-mails) 🔒 | [MySQL](problems/find-users-with-valid-e-mails) | Easy | +| 1516 | [Move Sub-Tree of N-Ary Tree](https://leetcode.com/problems/move-sub-tree-of-n-ary-tree) 🔒 | [Go](problems/move-sub-tree-of-n-ary-tree) | Hard | | 1515 | [Best Position for a Service Centre](https://leetcode.com/problems/best-position-for-a-service-centre "服务中心的最佳位置") | [Go](problems/best-position-for-a-service-centre) | Hard | | 1514 | [Path with Maximum Probability](https://leetcode.com/problems/path-with-maximum-probability "概率最大的路径") | [Go](problems/path-with-maximum-probability) | Medium | | 1513 | [Number of Substrings With Only 1s](https://leetcode.com/problems/number-of-substrings-with-only-1s "仅含 1 的子串数") | [Go](problems/number-of-substrings-with-only-1s) | Medium | diff --git a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md new file mode 100644 index 000000000..42751a46d --- /dev/null +++ b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../maximum-number-of-non-overlapping-substrings "Maximum Number of Non-Overlapping Substrings") +                 +Next > + +## [1521. Find a Value of a Mysterious Function Closest to Target (Hard)](https://leetcode.com/problems/find-a-value-of-a-mysterious-function-closest-to-target "找到最接近目标值的函数值") + +

    + +

    Winston was given the above mysterious function func. He has an integer array arr and an integer target and he wants to find the values l and r that make the value |func(arr, l, r) - target| minimum possible.

    + +

    Return the minimum possible value of |func(arr, l, r) - target|.

    + +

    Notice that func should be called with the values l and r where 0 <= l, r < arr.length.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [9,12,3,7,15], target = 5
    +Output: 2
    +Explanation: Calling func with all the pairs of [l,r] = [[0,0],[1,1],[2,2],[3,3],[4,4],[0,1],[1,2],[2,3],[3,4],[0,2],[1,3],[2,4],[0,3],[1,4],[0,4]], Winston got the following results [9,12,3,7,15,8,0,3,7,0,0,3,0,0,0]. The value closest to 5 is 7 and 3, thus the minimum difference is 2.
    +
    + +

    Example 2:

    + +
    +Input: arr = [1000000,1000000,1000000], target = 1
    +Output: 999999
    +Explanation: Winston called the func with all possible values of [l,r] and he always got 1000000, thus the min difference is 999999.
    +
    + +

    Example 3:

    + +
    +Input: arr = [1,2,4,8,16], target = 0
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 10^5
    • +
    • 1 <= arr[i] <= 10^6
    • +
    • 0 <= target <= 10^7
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +If the and value of sub-array arr[i...j] is ≥ the and value of the sub-array arr[i...j+1]. +
    + +
    +Hint 2 +For each index i using binary search or ternary search find the index j where |target - AND(arr[i...j])| is minimum, minimize this value with the global answer. +
    diff --git a/problems/find-users-with-valid-e-mails/README.md b/problems/find-users-with-valid-e-mails/README.md new file mode 100644 index 000000000..ce7862879 --- /dev/null +++ b/problems/find-users-with-valid-e-mails/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../move-sub-tree-of-n-ary-tree "Move Sub-Tree of N-Ary Tree") +                 +[Next >](../water-bottles "Water Bottles") + +## [1517. Find Users With Valid E-Mails (Easy)](https://leetcode.com/problems/find-users-with-valid-e-mails "") + + diff --git a/problems/find-users-with-valid-e-mails/mysql_schemas.sql b/problems/find-users-with-valid-e-mails/mysql_schemas.sql new file mode 100644 index 000000000..a9fe9964d --- /dev/null +++ b/problems/find-users-with-valid-e-mails/mysql_schemas.sql @@ -0,0 +1,9 @@ +Create table If Not Exists Users (user_id int, name varchar(30), mail varchar(50)); +Truncate table Users; +insert into Users (user_id, name, mail) values ('1', 'Winston', 'winston@leetcode.com'); +insert into Users (user_id, name, mail) values ('2', 'Jonathan', 'jonathanisgreat'); +insert into Users (user_id, name, mail) values ('3', 'Annabelle', 'bella-@leetcode.com'); +insert into Users (user_id, name, mail) values ('4', 'Sally', 'sally.come@leetcode.com'); +insert into Users (user_id, name, mail) values ('5', 'Marwan', 'quarz#2020@leetcode.com'); +insert into Users (user_id, name, mail) values ('6', 'David', 'david69@gmail.com'); +insert into Users (user_id, name, mail) values ('7', 'Shapiro', '.shapo@leetcode.com'); diff --git a/problems/maximum-number-of-non-overlapping-substrings/README.md b/problems/maximum-number-of-non-overlapping-substrings/README.md new file mode 100644 index 000000000..05d056030 --- /dev/null +++ b/problems/maximum-number-of-non-overlapping-substrings/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../number-of-nodes-in-the-sub-tree-with-the-same-label "Number of Nodes in the Sub-Tree With the Same Label") +                 +[Next >](../find-a-value-of-a-mysterious-function-closest-to-target "Find a Value of a Mysterious Function Closest to Target") + +## [1520. Maximum Number of Non-Overlapping Substrings (Medium)](https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings "最多的不重叠子字符串") + +

    Given a string s of lowercase letters, you need to find the maximum number of non-empty substrings of s that meet the following conditions:

    + +
      +
    1. The substrings do not overlap, that is for any two substrings s[i..j] and s[k..l], either j < k or i > l is true.
    2. +
    3. A substring that contains a certain character c must also contain all occurrences of c.
    4. +
    + +

    Find the maximum number of substrings that meet the above conditions. If there are multiple solutions with the same number of substrings, return the one with minimum total length. It can be shown that there exists a unique solution of minimum total length.

    + +

    Notice that you can return the substrings in any order.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "adefaddaccc"
    +Output: ["e","f","ccc"]
    +Explanation: The following are all the possible substrings that meet the conditions:
    +[
    +  "adefaddaccc"
    +  "adefadda",
    +  "ef",
    +  "e",
    +  "f",
    +  "ccc",
    +]
    +If we choose the first string, we cannot choose anything else and we'd get only 1. If we choose "adefadda", we are left with "ccc" which is the only one that doesn't overlap, thus obtaining 2 substrings. Notice also, that it's not optimal to choose "ef" since it can be split into two. Therefore, the optimal way is to choose ["e","f","ccc"] which gives us 3 substrings. No other solution of the same number of substrings exist.
    +
    + +

    Example 2:

    + +
    +Input: s = "abbaccd"
    +Output: ["d","bb","cc"]
    +Explanation: Notice that while the set of substrings ["d","abba","cc"] also has length 3, it's considered incorrect since it has larger total length.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 10^5
    • +
    • s contains only lowercase English letters.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Notice that it's impossible for any two valid substrings to overlap unless one is inside another. +
    + +
    +Hint 2 +We can start by finding the starting and ending index for each character. +
    + +
    +Hint 3 +From these indices, we can form the substrings by expanding each character's range if necessary (if another character exists in the range with smaller/larger starting/ending index). +
    + +
    +Hint 4 +Sort the valid substrings by length and greedily take those with the smallest length, discarding the ones that overlap those we took. +
    diff --git a/problems/maximum-width-of-binary-tree/README.md b/problems/maximum-width-of-binary-tree/README.md index d94b75efe..90401c065 100644 --- a/problems/maximum-width-of-binary-tree/README.md +++ b/problems/maximum-width-of-binary-tree/README.md @@ -11,10 +11,12 @@ ## [662. Maximum Width of Binary Tree (Medium)](https://leetcode.com/problems/maximum-width-of-binary-tree "二叉树最大宽度") -

    Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binary tree has the same structure as a full binary tree, but some nodes are null.

    +

    Given a binary tree, write a function to get the maximum width of the given tree. The maximum width of a tree is the maximum width among all levels.

    The width of one level is defined as the length between the end-nodes (the leftmost and right most non-null nodes in the level, where the null nodes between the end-nodes are also counted into the length calculation.

    +

    It is guaranteed that the answer will in the range of 32-bit signed integer.

    +

    Example 1:

    @@ -74,11 +76,14 @@
         6           7
     Output: 8
     Explanation:The maximum width existing in the fourth level with the length 8 (6,null,null,null,null,null,null,7).
    -
    -
     
    -

    Note: Answer will in the range of 32-bit signed integer.

    +

     

    +

    Constraints:

    + +
      +
    • The given binary tree will have between 1 and 3000 nodes.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/move-sub-tree-of-n-ary-tree/README.md b/problems/move-sub-tree-of-n-ary-tree/README.md new file mode 100644 index 000000000..2451c61bf --- /dev/null +++ b/problems/move-sub-tree-of-n-ary-tree/README.md @@ -0,0 +1,33 @@ + + + + + + + +[< Previous](../best-position-for-a-service-centre "Best Position for a Service Centre") +                 +[Next >](../find-users-with-valid-e-mails "Find Users With Valid E-Mails") + +## [1516. Move Sub-Tree of N-Ary Tree (Hard)](https://leetcode.com/problems/move-sub-tree-of-n-ary-tree "") + + + +### Related Topics + [[Tree](../../tag/tree/README.md)] + +### Hints +
    +Hint 1 +Disconnect node p from its parent and append it to the children list of node q. +
    + +
    +Hint 2 +If q was in the sub-tree of node p (case 1), get the parent node of p and replace p in its children list with q. +
    + +
    +Hint 3 +If p was the root of the tree, make q the root of the tree. +
    diff --git a/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md b/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md new file mode 100644 index 000000000..db85cd18a --- /dev/null +++ b/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md @@ -0,0 +1,90 @@ + + + + + + + +[< Previous](../water-bottles "Water Bottles") +                 +[Next >](../maximum-number-of-non-overlapping-substrings "Maximum Number of Non-Overlapping Substrings") + +## [1519. Number of Nodes in the Sub-Tree With the Same Label (Medium)](https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label "子树中标签相同的节点数") + +

    Given a tree (i.e. a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of the tree is the node 0, and each node of the tree has a label which is a lower-case character given in the string labels (i.e. The node with the number i has the label labels[i]).

    + +

    The edges array is given on the form edges[i] = [ai, bi], which means there is an edge between nodes ai and bi in the tree.

    + +

    Return an array of size n where ans[i] is the number of nodes in the subtree of the ith node which have the same label as node i.

    + +

    A subtree of a tree T is the tree consisting of a node in T and all of its descendant nodes.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], labels = "abaedcd"
    +Output: [2,1,1,1,1,1,1]
    +Explanation: Node 0 has label 'a' and its sub-tree has node 2 with label 'a' as well, thus the answer is 2. Notice that any node is part of its sub-tree.
    +Node 1 has a label 'b'. The sub-tree of node 1 contains nodes 1,4 and 5, as nodes 4 and 5 have different labels than node 1, the answer is just 1 (the node itself).
    +
    + +

    Example 2:

    + +
    +Input: n = 4, edges = [[0,1],[1,2],[0,3]], labels = "bbbb"
    +Output: [4,2,1,1]
    +Explanation: The sub-tree of node 2 contains only node 2, so the answer is 1.
    +The sub-tree of node 3 contains only node 3, so the answer is 1.
    +The sub-tree of node 1 contains nodes 1 and 2, both have label 'b', thus the answer is 2.
    +The sub-tree of node 0 contains nodes 0, 1, 2 and 3, all with label 'b', thus the answer is 4.
    +
    + +

    Example 3:

    + +
    +Input: n = 5, edges = [[0,1],[0,2],[1,3],[0,4]], labels = "aabab"
    +Output: [3,2,1,1,1]
    +
    + +

    Example 4:

    + +
    +Input: n = 6, edges = [[0,1],[0,2],[1,3],[3,4],[4,5]], labels = "cbabaa"
    +Output: [1,2,1,1,2,1]
    +
    + +

    Example 5:

    + +
    +Input: n = 7, edges = [[0,1],[1,2],[2,3],[3,4],[4,5],[5,6]], labels = "aaabaaa"
    +Output: [6,5,4,1,3,2,1]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 10^5
    • +
    • edges.length == n - 1
    • +
    • edges[i].length == 2
    • +
    • 0 <= ai, bi < n
    • +
    • ai != bi
    • +
    • labels.length == n
    • +
    • labels is consisting of only of lower-case English letters.
    • +
    + +### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + +### Hints +
    +Hint 1 +Start traversing the tree and each node should return a vector to its parent node. +
    + +
    +Hint 2 +The vector should be of length 26 and have the count of all the labels in the sub-tree of this node. +
    diff --git a/problems/unique-binary-search-trees/README.md b/problems/unique-binary-search-trees/README.md index 18fe7f087..f95e1a39d 100644 --- a/problems/unique-binary-search-trees/README.md +++ b/problems/unique-binary-search-trees/README.md @@ -28,6 +28,13 @@ 2 1 2 3 +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 19
    • +
    + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/water-bottles/README.md b/problems/water-bottles/README.md new file mode 100644 index 000000000..cdee2ce27 --- /dev/null +++ b/problems/water-bottles/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../find-users-with-valid-e-mails "Find Users With Valid E-Mails") +                 +[Next >](../number-of-nodes-in-the-sub-tree-with-the-same-label "Number of Nodes in the Sub-Tree With the Same Label") + +## [1518. Water Bottles (Easy)](https://leetcode.com/problems/water-bottles "换酒问题") + +

    Given numBottles full water bottles, you can exchange numExchange empty water bottles for one full water bottle.

    + +

    The operation of drinking a full water bottle turns it into an empty bottle.

    + +

    Return the maximum number of water bottles you can drink.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: numBottles = 9, numExchange = 3
    +Output: 13
    +Explanation: You can exchange 3 empty bottles to get 1 full water bottle.
    +Number of water bottles you can drink: 9 + 3 + 1 = 13.
    +
    + +

    Example 2:

    + +

    + +
    +Input: numBottles = 15, numExchange = 4
    +Output: 19
    +Explanation: You can exchange 4 empty bottles to get 1 full water bottle. 
    +Number of water bottles you can drink: 15 + 3 + 1 = 19.
    +
    + +

    Example 3:

    + +
    +Input: numBottles = 5, numExchange = 5
    +Output: 6
    +
    + +

    Example 4:

    + +
    +Input: numBottles = 2, numExchange = 3
    +Output: 2
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= numBottles <= 100
    • +
    • 2 <= numExchange <= 100
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Simulate the process until there are not enough empty bottles for even one full bottle of water. +
    diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 507321fb8..525ef3fbe 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1482 | [制作 m 束花所需的最少天数](../../problems/minimum-number-of-days-to-make-m-bouquets) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 1337 | [方阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index fece1bc71..08245a2e8 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1486 | [数组异或操作](../../problems/xor-operation-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | | 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 91218fbbe..bd49e533d 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index b14efd835..59f35ca12 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | | 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 9027bc45e..1bd691a75 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心算法](../greedy/README.md)] | Medium | +| 1518 | [换酒问题](../../problems/water-bottles) | [[贪心算法](../greedy/README.md)] | Easy | | 1505 | [最多 K 次交换相邻数位后得到的最小整数](../../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | [[贪心算法](../greedy/README.md)] | Hard | | 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index d17f4d302..b4b1612de 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | | 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/tree/README.md b/tag/tree/README.md index f5c592079..f962bab77 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1516 | [Move Sub-Tree of N-Ary Tree](../../problems/move-sub-tree-of-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1469 | [寻找所有的独生节点](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | From 577684ab1438836c7163a3a406819306c4243714 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 27 Jul 2020 10:22:38 +0800 Subject: [PATCH 091/145] A: new --- README.md | 18 +++- .../README.md | 2 +- problems/bulb-switcher-iv/README.md | 78 +++++++++++++++++ .../README.md | 50 +++++++++++ problems/count-of-range-sum/README.md | 6 ++ .../README.md | 2 +- problems/degree-of-an-array/README.md | 33 +++++--- problems/diameter-of-n-ary-tree/README.md | 25 ++++++ .../README.md | 2 +- problems/find-root-of-n-ary-tree/README.md | 2 +- .../README.md | 2 +- problems/implement-strstr/README.md | 7 ++ problems/longest-univalue-path/README.md | 2 +- .../maximum-product-of-word-lengths/README.md | 9 ++ .../README.md | 74 ++++++++++++++++ .../number-of-good-leaf-nodes-pairs/README.md | 84 +++++++++++++++++++ .../README.md | 70 ++++++++++++++++ .../README.md | 81 ++++++++++++++++++ problems/path-sum-ii/README.md | 2 +- problems/path-sum-iii/README.md | 2 +- problems/path-sum-iv/README.md | 2 +- problems/path-sum/README.md | 2 +- problems/patients-with-a-condition/README.md | 14 ++++ .../mysql_schemas.sql | 7 ++ problems/range-sum-query-mutable/README.md | 8 +- problems/shuffle-string/README.md | 81 ++++++++++++++++++ problems/string-compression-ii/README.md | 73 ++++++++++++++++ problems/water-and-jug-problem/README.md | 8 ++ readme/1-300.md | 2 +- readme/301-600.md | 4 +- readme/601-900.md | 2 +- tag/array/README.md | 1 + tag/bit-manipulation/README.md | 1 + tag/depth-first-search/README.md | 1 + tag/dynamic-programming/README.md | 1 + tag/math/README.md | 2 + tag/segment-tree/README.md | 1 + tag/sort/README.md | 1 + tag/string/README.md | 3 + tag/tree/README.md | 3 +- 40 files changed, 733 insertions(+), 35 deletions(-) create mode 100644 problems/bulb-switcher-iv/README.md create mode 100644 problems/count-odd-numbers-in-an-interval-range/README.md create mode 100644 problems/diameter-of-n-ary-tree/README.md create mode 100644 problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md create mode 100644 problems/number-of-good-leaf-nodes-pairs/README.md create mode 100644 problems/number-of-good-ways-to-split-a-string/README.md create mode 100644 problems/number-of-sub-arrays-with-odd-sum/README.md create mode 100644 problems/patients-with-a-condition/README.md create mode 100644 problems/patients-with-a-condition/mysql_schemas.sql create mode 100644 problems/shuffle-string/README.md create mode 100644 problems/string-compression-ii/README.md diff --git a/README.md b/README.md index 8918c83c2..3fb927922 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,18 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1531 | [String Compression II](https://leetcode.com/problems/string-compression-ii "压缩字符串 II") | [Go](problems/string-compression-ii) | Hard | +| 1530 | [Number of Good Leaf Nodes Pairs](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs "好叶子节点对的数量") | [Go](problems/number-of-good-leaf-nodes-pairs) | Medium | +| 1529 | [Bulb Switcher IV](https://leetcode.com/problems/bulb-switcher-iv "灯泡开关 IV") | [Go](problems/bulb-switcher-iv) | Medium | +| 1528 | [Shuffle String](https://leetcode.com/problems/shuffle-string "重新排列字符串") | [Go](problems/shuffle-string) | Easy | +| 1527 | [Patients With a Condition](https://leetcode.com/problems/patients-with-a-condition) 🔒 | [MySQL](problems/patients-with-a-condition) | Easy | +| 1526 | [Minimum Number of Increments on Subarrays to Form a Target Array](https://leetcode.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array "形成目标数组的子数组最少增加次数") | [Go](problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | Hard | +| 1525 | [Number of Good Ways to Split a String](https://leetcode.com/problems/number-of-good-ways-to-split-a-string "字符串的好分割数目") | [Go](problems/number-of-good-ways-to-split-a-string) | Medium | +| 1524 | [Number of Sub-arrays With Odd Sum](https://leetcode.com/problems/number-of-sub-arrays-with-odd-sum "和为奇数的子数组数目") | [Go](problems/number-of-sub-arrays-with-odd-sum) | Medium | +| 1523 | [Count Odd Numbers in an Interval Range](https://leetcode.com/problems/count-odd-numbers-in-an-interval-range "在区间范围内统计奇数数目") | [Go](problems/count-odd-numbers-in-an-interval-range) | Easy | +| 1522 | [Diameter of N-Ary Tree](https://leetcode.com/problems/diameter-of-n-ary-tree) 🔒 | [Go](problems/diameter-of-n-ary-tree) | Medium | | 1521 | [Find a Value of a Mysterious Function Closest to Target](https://leetcode.com/problems/find-a-value-of-a-mysterious-function-closest-to-target "找到最接近目标值的函数值") | [Go](problems/find-a-value-of-a-mysterious-function-closest-to-target) | Hard | -| 1520 | [Maximum Number of Non-Overlapping Substrings](https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings "最多的不重叠子字符串") | [Go](problems/maximum-number-of-non-overlapping-substrings) | Medium | +| 1520 | [Maximum Number of Non-Overlapping Substrings](https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings "最多的不重叠子字符串") | [Go](problems/maximum-number-of-non-overlapping-substrings) | Hard | | 1519 | [Number of Nodes in the Sub-Tree With the Same Label](https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label "子树中标签相同的节点数") | [Go](problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | Medium | | 1518 | [Water Bottles](https://leetcode.com/problems/water-bottles "换酒问题") | [Go](problems/water-bottles) | Easy | | 1517 | [Find Users With Valid E-Mails](https://leetcode.com/problems/find-users-with-valid-e-mails) 🔒 | [MySQL](problems/find-users-with-valid-e-mails) | Easy | @@ -85,18 +95,18 @@ LeetCode Problems' Solutions | 1509 | [Minimum Difference Between Largest and Smallest Value in Three Moves](https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves "三次操作后最大值与最小值的最小差") | [Go](problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | Medium | | 1508 | [Range Sum of Sorted Subarray Sums](https://leetcode.com/problems/range-sum-of-sorted-subarray-sums "子数组和排序后的区间和") | [Go](problems/range-sum-of-sorted-subarray-sums) | Medium | | 1507 | [Reformat Date](https://leetcode.com/problems/reformat-date "转变日期格式") | [Go](problems/reformat-date) | Easy | -| 1506 | [Find Root of N-Ary Tree](https://leetcode.com/problems/find-root-of-n-ary-tree) 🔒 | [Go](problems/find-root-of-n-ary-tree) | Medium | +| 1506 | [Find Root of N-Ary Tree](https://leetcode.com/problems/find-root-of-n-ary-tree "找到 N 叉树的根节点") 🔒 | [Go](problems/find-root-of-n-ary-tree) | Medium | | 1505 | [Minimum Possible Integer After at Most K Adjacent Swaps On Digits](https://leetcode.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "最多 K 次交换相邻数位后得到的最小整数") | [Go](problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | Hard | | 1504 | [Count Submatrices With All Ones](https://leetcode.com/problems/count-submatrices-with-all-ones "统计全 1 子矩形") | [Go](problems/count-submatrices-with-all-ones) | Medium | | 1503 | [Last Moment Before All Ants Fall Out of a Plank](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank "所有蚂蚁掉下来前的最后一刻") | [Go](problems/last-moment-before-all-ants-fall-out-of-a-plank) | Medium | | 1502 | [Can Make Arithmetic Progression From Sequence](https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence "判断能否形成等差数列") | [Go](problems/can-make-arithmetic-progression-from-sequence) | Easy | -| 1501 | [Countries You Can Safely Invest In](https://leetcode.com/problems/countries-you-can-safely-invest-in) 🔒 | [MySQL](problems/countries-you-can-safely-invest-in) | Medium | +| 1501 | [Countries You Can Safely Invest In](https://leetcode.com/problems/countries-you-can-safely-invest-in "可以放心投资的国家") 🔒 | [MySQL](problems/countries-you-can-safely-invest-in) | Medium | | 1500 | [Design a File Sharing System](https://leetcode.com/problems/design-a-file-sharing-system) 🔒 | [Go](problems/design-a-file-sharing-system) | Medium | | 1499 | [Max Value of Equation](https://leetcode.com/problems/max-value-of-equation "满足不等式的最大值") | [Go](problems/max-value-of-equation) | Hard | | 1498 | [Number of Subsequences That Satisfy the Given Sum Condition](https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition "满足条件的子序列数目") | [Go](problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | Medium | | 1497 | [Check If Array Pairs Are Divisible by k](https://leetcode.com/problems/check-if-array-pairs-are-divisible-by-k "检查数组对是否可以被 k 整除") | [Go](problems/check-if-array-pairs-are-divisible-by-k) | Medium | | 1496 | [Path Crossing](https://leetcode.com/problems/path-crossing "判断路径是否相交") | [Go](problems/path-crossing) | Easy | -| 1495 | [Friendly Movies Streamed Last Month](https://leetcode.com/problems/friendly-movies-streamed-last-month) 🔒 | [MySQL](problems/friendly-movies-streamed-last-month) | Easy | +| 1495 | [Friendly Movies Streamed Last Month](https://leetcode.com/problems/friendly-movies-streamed-last-month "上月播放的儿童适宜电影") 🔒 | [MySQL](problems/friendly-movies-streamed-last-month) | Easy | | 1494 | [Parallel Courses II](https://leetcode.com/problems/parallel-courses-ii "并行课程 II") | [Go](problems/parallel-courses-ii) | Hard | | 1493 | [Longest Subarray of 1's After Deleting One Element](https://leetcode.com/problems/longest-subarray-of-1s-after-deleting-one-element "删掉一个元素以后全为 1 的最长子数组") | [Go](problems/longest-subarray-of-1s-after-deleting-one-element) | Medium | | 1492 | [The kth Factor of n](https://leetcode.com/problems/the-kth-factor-of-n "n 的第 k 个因子") | [Go](problems/the-kth-factor-of-n) | Medium | diff --git a/problems/best-position-for-a-service-centre/README.md b/problems/best-position-for-a-service-centre/README.md index a3e2ddf1f..068e39a02 100644 --- a/problems/best-position-for-a-service-centre/README.md +++ b/problems/best-position-for-a-service-centre/README.md @@ -7,7 +7,7 @@ [< Previous](../path-with-maximum-probability "Path with Maximum Probability")                  -Next > +[Next >](../move-sub-tree-of-n-ary-tree "Move Sub-Tree of N-Ary Tree") ## [1515. Best Position for a Service Centre (Hard)](https://leetcode.com/problems/best-position-for-a-service-centre "服务中心的最佳位置") diff --git a/problems/bulb-switcher-iv/README.md b/problems/bulb-switcher-iv/README.md new file mode 100644 index 000000000..d6b7b9e7e --- /dev/null +++ b/problems/bulb-switcher-iv/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../shuffle-string "Shuffle String") +                 +[Next >](../number-of-good-leaf-nodes-pairs "Number of Good Leaf Nodes Pairs") + +## [1529. Bulb Switcher IV (Medium)](https://leetcode.com/problems/bulb-switcher-iv "灯泡开关 IV") + +

    There is a room with n bulbs, numbered from 0 to n-1, arranged in a row from left to right. Initially all the bulbs are turned off.

    + +

    Your task is to obtain the configuration represented by target where target[i] is '1' if the i-th bulb is turned on and is '0' if it is turned off.

    + +

    You have a switch to flip the state of the bulb, a flip operation is defined as follows:

    + +
      +
    • Choose any bulb (index i) of your current configuration.
    • +
    • Flip each bulb from index i to n-1.
    • +
    + +

    When any bulb is flipped it means that if it is 0 it changes to 1 and if it is 1 it changes to 0.

    + +

    Return the minimum number of flips required to form target.

    + +

     

    +

    Example 1:

    + +
    +Input: target = "10111"
    +Output: 3
    +Explanation: Initial configuration "00000".
    +flip from the third bulb:  "00000" -> "00111"
    +flip from the first bulb:  "00111" -> "11000"
    +flip from the second bulb:  "11000" -> "10111"
    +We need at least 3 flip operations to form target.
    + +

    Example 2:

    + +
    +Input: target = "101"
    +Output: 3
    +Explanation: "000" -> "111" -> "100" -> "101".
    +
    + +

    Example 3:

    + +
    +Input: target = "00000"
    +Output: 0
    +
    + +

    Example 4:

    + +
    +Input: target = "001011101"
    +Output: 5
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= target.length <= 10^5
    • +
    • target[i] == '0' or target[i] == '1'
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Consider a strategy where the choice of bulb with number i is increasing. In such a strategy, you no longer need to worry about bulbs that have been set to the left. +
    diff --git a/problems/count-odd-numbers-in-an-interval-range/README.md b/problems/count-odd-numbers-in-an-interval-range/README.md new file mode 100644 index 000000000..787c6b9c3 --- /dev/null +++ b/problems/count-odd-numbers-in-an-interval-range/README.md @@ -0,0 +1,50 @@ + + + + + + + +[< Previous](../diameter-of-n-ary-tree "Diameter of N-Ary Tree") +                 +[Next >](../number-of-sub-arrays-with-odd-sum "Number of Sub-arrays With Odd Sum") + +## [1523. Count Odd Numbers in an Interval Range (Easy)](https://leetcode.com/problems/count-odd-numbers-in-an-interval-range "在区间范围内统计奇数数目") + +

    Given two non-negative integers low and high. Return the count of odd numbers between low and high (inclusive).

    + +

     

    +

    Example 1:

    + +
    +Input: low = 3, high = 7
    +Output: 3
    +Explanation: The odd numbers between 3 and 7 are [3,5,7].
    + +

    Example 2:

    + +
    +Input: low = 8, high = 10
    +Output: 1
    +Explanation: The odd numbers between 8 and 10 are [9].
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= low <= high <= 10^9
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +If the range (high - low + 1) is even, the number of even and odd numbers in this range will be the same. +
    + +
    +Hint 2 +If the range (high - low + 1) is odd, the solution will depend on the parity of high and low. +
    diff --git a/problems/count-of-range-sum/README.md b/problems/count-of-range-sum/README.md index ca49f61da..580e72830 100644 --- a/problems/count-of-range-sum/README.md +++ b/problems/count-of-range-sum/README.md @@ -24,6 +24,12 @@ A naive algorithm of O(n2) is trivial. You MUST do bett Output: 3 Explanation: The three ranges are : [0,0], [2,2], [0,2] and their respective sums are: -2, -1, 2. +

     

    +

    Constraints:

    + +
      +
    • 0 <= nums.length <= 10^4
    • +
    ### Related Topics [[Sort](../../tag/sort/README.md)] diff --git a/problems/countries-you-can-safely-invest-in/README.md b/problems/countries-you-can-safely-invest-in/README.md index 2d037428f..2f8e86b4e 100644 --- a/problems/countries-you-can-safely-invest-in/README.md +++ b/problems/countries-you-can-safely-invest-in/README.md @@ -9,6 +9,6 @@                  [Next >](../can-make-arithmetic-progression-from-sequence "Can Make Arithmetic Progression From Sequence") -## [1501. Countries You Can Safely Invest In (Medium)](https://leetcode.com/problems/countries-you-can-safely-invest-in "") +## [1501. Countries You Can Safely Invest In (Medium)](https://leetcode.com/problems/countries-you-can-safely-invest-in "可以放心投资的国家") diff --git a/problems/degree-of-an-array/README.md b/problems/degree-of-an-array/README.md index af0281478..33f6ab25b 100644 --- a/problems/degree-of-an-array/README.md +++ b/problems/degree-of-an-array/README.md @@ -12,32 +12,39 @@ ## [697. Degree of an Array (Easy)](https://leetcode.com/problems/degree-of-an-array "数组的度")

    Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements.

    +

    Your task is to find the smallest possible length of a (contiguous) subarray of nums, that has the same degree as nums.

    -

    Example 1:
    +

     

    +

    Example 1:

    +
    -Input: [1, 2, 2, 3, 1]
    -Output: 2
    -Explanation: 
    +Input: nums = [1,2,2,3,1]
    +Output: 2
    +Explanation: 
     The input array has a degree of 2 because both elements 1 and 2 appear twice.
     Of the subarrays that have the same degree:
     [1, 2, 2, 3, 1], [1, 2, 2, 3], [2, 2, 3, 1], [1, 2, 2], [2, 2, 3], [2, 2]
     The shortest length is 2. So return 2.
     
    -

    +

    Example 2:

    -

    Example 2:

    -Input: [1,2,2,3,1,4,2]
    -Output: 6
    +Input: nums = [1,2,2,3,1,4,2]
    +Output: 6
    +Explanation: 
    +The degree is 3 because the element 2 is repeated 3 times.
    +So [2,2,3,1,4,2] is the shortest subarray, therefore returning 6.
     
    -

    -

    Note: -

  • nums.length will be between 1 and 50,000.
  • -
  • nums[i] will be an integer between 0 and 49,999.
  • -

    +

     

    +

    Constraints:

    + +
      +
    • nums.length will be between 1 and 50,000.
    • +
    • nums[i] will be an integer between 0 and 49,999.
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/diameter-of-n-ary-tree/README.md b/problems/diameter-of-n-ary-tree/README.md new file mode 100644 index 000000000..d158fee18 --- /dev/null +++ b/problems/diameter-of-n-ary-tree/README.md @@ -0,0 +1,25 @@ + + + + + + + +[< Previous](../find-a-value-of-a-mysterious-function-closest-to-target "Find a Value of a Mysterious Function Closest to Target") +                 +[Next >](../count-odd-numbers-in-an-interval-range "Count Odd Numbers in an Interval Range") + +## [1522. Diameter of N-Ary Tree (Medium)](https://leetcode.com/problems/diameter-of-n-ary-tree "") + + + +### Hints +
    +Hint 1 +For the node i, calculate the height of each of its children and keep the first and second maximum heights (max1_i , max2_i). +
    + +
    +Hint 2 +Check all nodes and return max( 2 + max1_i + max2_i ). +
    diff --git a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md index 42751a46d..34f152d87 100644 --- a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md +++ b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md @@ -7,7 +7,7 @@ [< Previous](../maximum-number-of-non-overlapping-substrings "Maximum Number of Non-Overlapping Substrings")                  -Next > +[Next >](../diameter-of-n-ary-tree "Diameter of N-Ary Tree") ## [1521. Find a Value of a Mysterious Function Closest to Target (Hard)](https://leetcode.com/problems/find-a-value-of-a-mysterious-function-closest-to-target "找到最接近目标值的函数值") diff --git a/problems/find-root-of-n-ary-tree/README.md b/problems/find-root-of-n-ary-tree/README.md index b9d83e14e..37b8828b1 100644 --- a/problems/find-root-of-n-ary-tree/README.md +++ b/problems/find-root-of-n-ary-tree/README.md @@ -9,7 +9,7 @@                  [Next >](../reformat-date "Reformat Date") -## [1506. Find Root of N-Ary Tree (Medium)](https://leetcode.com/problems/find-root-of-n-ary-tree "") +## [1506. Find Root of N-Ary Tree (Medium)](https://leetcode.com/problems/find-root-of-n-ary-tree "找到 N 叉树的根节点") diff --git a/problems/friendly-movies-streamed-last-month/README.md b/problems/friendly-movies-streamed-last-month/README.md index 1fa758c44..02ce09af0 100644 --- a/problems/friendly-movies-streamed-last-month/README.md +++ b/problems/friendly-movies-streamed-last-month/README.md @@ -9,6 +9,6 @@                  [Next >](../path-crossing "Path Crossing") -## [1495. Friendly Movies Streamed Last Month (Easy)](https://leetcode.com/problems/friendly-movies-streamed-last-month "") +## [1495. Friendly Movies Streamed Last Month (Easy)](https://leetcode.com/problems/friendly-movies-streamed-last-month "上月播放的儿童适宜电影") diff --git a/problems/implement-strstr/README.md b/problems/implement-strstr/README.md index 2c50a5f2d..51a0fd80f 100644 --- a/problems/implement-strstr/README.md +++ b/problems/implement-strstr/README.md @@ -35,6 +35,13 @@

    For the purpose of this problem, we will return 0 when needle is an empty string. This is consistent to C's strstr() and Java's indexOf().

    +

     

    +

    Constraints:

    + +
      +
    • haystack and needle consist only of lowercase English characters.
    • +
    + ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/longest-univalue-path/README.md b/problems/longest-univalue-path/README.md index 9fb322073..8d3a7734f 100644 --- a/problems/longest-univalue-path/README.md +++ b/problems/longest-univalue-path/README.md @@ -58,4 +58,4 @@ ### Similar Questions 1. [Binary Tree Maximum Path Sum](../binary-tree-maximum-path-sum) (Hard) 1. [Count Univalue Subtrees](../count-univalue-subtrees) (Medium) - 1. [Path Sum III](../path-sum-iii) (Easy) + 1. [Path Sum III](../path-sum-iii) (Medium) diff --git a/problems/maximum-product-of-word-lengths/README.md b/problems/maximum-product-of-word-lengths/README.md index 5b3597874..2d1350661 100644 --- a/problems/maximum-product-of-word-lengths/README.md +++ b/problems/maximum-product-of-word-lengths/README.md @@ -35,5 +35,14 @@ Explanation: No such pair of words. +

     

    +

    Constraints:

    + +
      +
    • 0 <= words.length <= 10^3
    • +
    • 0 <= words[i].length <= 10^3
    • +
    • words[i] consists only of lowercase English letters.
    • +
    + ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md b/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md new file mode 100644 index 000000000..5903de105 --- /dev/null +++ b/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../number-of-good-ways-to-split-a-string "Number of Good Ways to Split a String") +                 +[Next >](../patients-with-a-condition "Patients With a Condition") + +## [1526. Minimum Number of Increments on Subarrays to Form a Target Array (Hard)](https://leetcode.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array "形成目标数组的子数组最少增加次数") + +

    Given an array of positive integers target and an array initial of same size with all zeros.

    + +

    Return the minimum number of operations to form a target array from initial if you are allowed to do the following operation:

    + +
      +
    • Choose any subarray from initial and increment each value by one.
    • +
    +The answer is guaranteed to fit within the range of a 32-bit signed integer. +

     

    +

    Example 1:

    + +
    +Input: target = [1,2,3,2,1]
    +Output: 3
    +Explanation: We need at least 3 operations to form the target array from the initial array.
    +[0,0,0,0,0] increment 1 from index 0 to 4 (inclusive).
    +[1,1,1,1,1] increment 1 from index 1 to 3 (inclusive).
    +[1,2,2,2,1] increment 1 at index 2.
    +[1,2,3,2,1] target array is formed.
    +
    + +

    Example 2:

    + +
    +Input: target = [3,1,1,2]
    +Output: 4
    +Explanation: (initial)[0,0,0,0] -> [1,1,1,1] -> [1,1,1,2] -> [2,1,1,2] -> [3,1,1,2] (target).
    +
    + +

    Example 3:

    + +
    +Input: target = [3,1,5,4,2]
    +Output: 7
    +Explanation: (initial)[0,0,0,0,0] -> [1,1,1,1,1] -> [2,1,1,1,1] -> [3,1,1,1,1] 
    +                                  -> [3,1,2,2,2] -> [3,1,3,3,2] -> [3,1,4,4,2] -> [3,1,5,4,2] (target).
    +
    + +

    Example 4:

    + +
    +Input: target = [1,1,1,1]
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= target.length <= 10^5
    • +
    • 1 <= target[i] <= 10^5
    • +
    + +### Related Topics + [[Segment Tree](../../tag/segment-tree/README.md)] + +### Hints +
    +Hint 1 +For a given range of values in target, an optimal strategy is to increment the entire range by the minimum value. The minimum in a range could be obtained with Range minimum query or Segment trees algorithm. +
    diff --git a/problems/number-of-good-leaf-nodes-pairs/README.md b/problems/number-of-good-leaf-nodes-pairs/README.md new file mode 100644 index 000000000..b8110dc2e --- /dev/null +++ b/problems/number-of-good-leaf-nodes-pairs/README.md @@ -0,0 +1,84 @@ + + + + + + + +[< Previous](../bulb-switcher-iv "Bulb Switcher IV") +                 +[Next >](../string-compression-ii "String Compression II") + +## [1530. Number of Good Leaf Nodes Pairs (Medium)](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs "好叶子节点对的数量") + +

    Given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the shortest path between them is less than or equal to distance.

    + +

    Return the number of good leaf node pairs in the tree.

    + +

     

    +

    Example 1:

    + +
    +Input: root = [1,2,3,null,4], distance = 3
    +Output: 1
    +Explanation: The leaf nodes of the tree are 3 and 4 and the length of the shortest path between them is 3. This is the only good pair.
    +
    + +

    Example 2:

    + +
    +Input: root = [1,2,3,4,5,6,7], distance = 3
    +Output: 2
    +Explanation: The good pairs are [4,5] and [6,7] with shortest path = 2. The pair [4,6] is not good because the length of ther shortest path between them is 4.
    +
    + +

    Example 3:

    + +
    +Input: root = [7,1,4,6,null,5,3,null,null,null,null,null,2], distance = 3
    +Output: 1
    +Explanation: The only good pair is [2,5].
    +
    + +

    Example 4:

    + +
    +Input: root = [100], distance = 1
    +Output: 0
    +
    + +

    Example 5:

    + +
    +Input: root = [1,1,1], distance = 2
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [1, 2^10].
    • +
    • Each node's value is between [1, 100].
    • +
    • 1 <= distance <= 10
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + +### Hints +
    +Hint 1 +Start DFS from each leaf node. stop the DFS when the number of steps done > distance. +
    + +
    +Hint 2 +If you reach another leaf node within distance steps, add 1 to the answer. +
    + +
    +Hint 3 +Note that all pairs will be counted twice so divide the answer by 2. +
    diff --git a/problems/number-of-good-ways-to-split-a-string/README.md b/problems/number-of-good-ways-to-split-a-string/README.md new file mode 100644 index 000000000..a858f007b --- /dev/null +++ b/problems/number-of-good-ways-to-split-a-string/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../number-of-sub-arrays-with-odd-sum "Number of Sub-arrays With Odd Sum") +                 +[Next >](../minimum-number-of-increments-on-subarrays-to-form-a-target-array "Minimum Number of Increments on Subarrays to Form a Target Array") + +## [1525. Number of Good Ways to Split a String (Medium)](https://leetcode.com/problems/number-of-good-ways-to-split-a-string "字符串的好分割数目") + +

    You are given a string s, a split is called good if you can split s into 2 non-empty strings p and q where its concatenation is equal to s and the number of distinct letters in p and q are the same.

    + +

    Return the number of good splits you can make in s.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "aacaba"
    +Output: 2
    +Explanation: There are 5 ways to split "aacaba" and 2 of them are good. 
    +("a", "acaba") Left string and right string contains 1 and 3 different letters respectively.
    +("aa", "caba") Left string and right string contains 1 and 3 different letters respectively.
    +("aac", "aba") Left string and right string contains 2 and 2 different letters respectively (good split).
    +("aaca", "ba") Left string and right string contains 2 and 2 different letters respectively (good split).
    +("aacab", "a") Left string and right string contains 3 and 1 different letters respectively.
    +
    + +

    Example 2:

    + +
    +Input: s = "abcd"
    +Output: 1
    +Explanation: Split the string as follows ("ab", "cd").
    +
    + +

    Example 3:

    + +
    +Input: s = "aaaaa"
    +Output: 4
    +Explanation: All possible splits are good.
    + +

    Example 4:

    + +
    +Input: s = "acbadbaada"
    +Output: 2
    +
    + +

     

    +

    Constraints:

    + +
      +
    • s contains only lowercase English letters.
    • +
    • 1 <= s.length <= 10^5
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Use two HashMap to store the counts of distinct letters in the left and right substring divided by the current index. +
    diff --git a/problems/number-of-sub-arrays-with-odd-sum/README.md b/problems/number-of-sub-arrays-with-odd-sum/README.md new file mode 100644 index 000000000..719fd3b66 --- /dev/null +++ b/problems/number-of-sub-arrays-with-odd-sum/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../count-odd-numbers-in-an-interval-range "Count Odd Numbers in an Interval Range") +                 +[Next >](../number-of-good-ways-to-split-a-string "Number of Good Ways to Split a String") + +## [1524. Number of Sub-arrays With Odd Sum (Medium)](https://leetcode.com/problems/number-of-sub-arrays-with-odd-sum "和为奇数的子数组数目") + +

    Given an array of integers arr. Return the number of sub-arrays with odd sum.

    + +

    As the answer may grow large, the answer must be computed modulo 10^9 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [1,3,5]
    +Output: 4
    +Explanation: All sub-arrays are [[1],[1,3],[1,3,5],[3],[3,5],[5]]
    +All sub-arrays sum are [1,4,9,3,8,5].
    +Odd sums are [1,9,3,5] so the answer is 4.
    +
    + +

    Example 2:

    + +
    +Input: arr = [2,4,6]
    +Output: 0
    +Explanation: All sub-arrays are [[2],[2,4],[2,4,6],[4],[4,6],[6]]
    +All sub-arrays sum are [2,6,12,4,10,6].
    +All sub-arrays have even sum and the answer is 0.
    +
    + +

    Example 3:

    + +
    +Input: arr = [1,2,3,4,5,6,7]
    +Output: 16
    +
    + +

    Example 4:

    + +
    +Input: arr = [100,100,99,99]
    +Output: 4
    +
    + +

    Example 5:

    + +
    +Input: arr = [7]
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 10^5
    • +
    • 1 <= arr[i] <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Can we use the accumulative sum to keep track of all the odd-sum sub-arrays ? +
    + +
    +Hint 2 +if the current accu sum is odd, we care only about previous even accu sums and vice versa. +
    diff --git a/problems/path-sum-ii/README.md b/problems/path-sum-ii/README.md index 06f289c5c..699a12656 100644 --- a/problems/path-sum-ii/README.md +++ b/problems/path-sum-ii/README.md @@ -45,5 +45,5 @@ ### Similar Questions 1. [Path Sum](../path-sum) (Easy) 1. [Binary Tree Paths](../binary-tree-paths) (Easy) - 1. [Path Sum III](../path-sum-iii) (Easy) + 1. [Path Sum III](../path-sum-iii) (Medium) 1. [Path Sum IV](../path-sum-iv) (Medium) diff --git a/problems/path-sum-iii/README.md b/problems/path-sum-iii/README.md index 5aefe3f75..ae8736af9 100644 --- a/problems/path-sum-iii/README.md +++ b/problems/path-sum-iii/README.md @@ -9,7 +9,7 @@                  [Next >](../find-all-anagrams-in-a-string "Find All Anagrams in a String") -## [437. Path Sum III (Easy)](https://leetcode.com/problems/path-sum-iii "路径总和 III") +## [437. Path Sum III (Medium)](https://leetcode.com/problems/path-sum-iii "路径总和 III")

    You are given a binary tree in which each node contains an integer value.

    diff --git a/problems/path-sum-iv/README.md b/problems/path-sum-iv/README.md index c24266555..4dbe3461f 100644 --- a/problems/path-sum-iv/README.md +++ b/problems/path-sum-iv/README.md @@ -62,4 +62,4 @@ The path sum is (3 + 1) = 4. 1. [Path Sum](../path-sum) (Easy) 1. [Path Sum II](../path-sum-ii) (Medium) 1. [Binary Tree Maximum Path Sum](../binary-tree-maximum-path-sum) (Hard) - 1. [Path Sum III](../path-sum-iii) (Easy) + 1. [Path Sum III](../path-sum-iii) (Medium) diff --git a/problems/path-sum/README.md b/problems/path-sum/README.md index 4938fdd45..f0cf5b237 100644 --- a/problems/path-sum/README.md +++ b/problems/path-sum/README.md @@ -39,5 +39,5 @@ 1. [Path Sum II](../path-sum-ii) (Medium) 1. [Binary Tree Maximum Path Sum](../binary-tree-maximum-path-sum) (Hard) 1. [Sum Root to Leaf Numbers](../sum-root-to-leaf-numbers) (Medium) - 1. [Path Sum III](../path-sum-iii) (Easy) + 1. [Path Sum III](../path-sum-iii) (Medium) 1. [Path Sum IV](../path-sum-iv) (Medium) diff --git a/problems/patients-with-a-condition/README.md b/problems/patients-with-a-condition/README.md new file mode 100644 index 000000000..21c3af3af --- /dev/null +++ b/problems/patients-with-a-condition/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../minimum-number-of-increments-on-subarrays-to-form-a-target-array "Minimum Number of Increments on Subarrays to Form a Target Array") +                 +[Next >](../shuffle-string "Shuffle String") + +## [1527. Patients With a Condition (Easy)](https://leetcode.com/problems/patients-with-a-condition "") + + diff --git a/problems/patients-with-a-condition/mysql_schemas.sql b/problems/patients-with-a-condition/mysql_schemas.sql new file mode 100644 index 000000000..0faba4460 --- /dev/null +++ b/problems/patients-with-a-condition/mysql_schemas.sql @@ -0,0 +1,7 @@ +Create table If Not Exists Patients (patient_id int, patient_name varchar(30), conditions varchar(100)); +Truncate table Patients; +insert into Patients (patient_id, patient_name, conditions) values ('1', 'Daniel', 'YFEV COUGH'); +insert into Patients (patient_id, patient_name, conditions) values ('2', 'Alice', ''); +insert into Patients (patient_id, patient_name, conditions) values ('3', 'Bob', 'DIAB100 MYOP'); +insert into Patients (patient_id, patient_name, conditions) values ('4', 'George', 'ACNE DIAB100'); +insert into Patients (patient_id, patient_name, conditions) values ('5', 'Alain', 'DIAB201'); diff --git a/problems/range-sum-query-mutable/README.md b/problems/range-sum-query-mutable/README.md index 2ab29effe..8771af7ba 100644 --- a/problems/range-sum-query-mutable/README.md +++ b/problems/range-sum-query-mutable/README.md @@ -25,12 +25,14 @@ update(1, 2) sumRange(0, 2) -> 8 -

    Note:

    +

     

    +

    Constraints:

    -
      +
      • The array is only modifiable by the update function.
      • You may assume the number of calls to update and sumRange function is distributed evenly.
      • -
    +
  • 0 <= i <= j <= nums.length - 1
  • + ### Related Topics [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] diff --git a/problems/shuffle-string/README.md b/problems/shuffle-string/README.md new file mode 100644 index 000000000..135df9d15 --- /dev/null +++ b/problems/shuffle-string/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../patients-with-a-condition "Patients With a Condition") +                 +[Next >](../bulb-switcher-iv "Bulb Switcher IV") + +## [1528. Shuffle String (Easy)](https://leetcode.com/problems/shuffle-string "重新排列字符串") + +

    Given a string s and an integer array indices of the same length.

    + +

    The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.

    + +

    Return the shuffled string.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "codeleet", indices = [4,5,6,7,0,2,1,3]
    +Output: "leetcode"
    +Explanation: As shown, "codeleet" becomes "leetcode" after shuffling.
    +
    + +

    Example 2:

    + +
    +Input: s = "abc", indices = [0,1,2]
    +Output: "abc"
    +Explanation: After shuffling, each character remains in its position.
    +
    + +

    Example 3:

    + +
    +Input: s = "aiohn", indices = [3,1,4,2,0]
    +Output: "nihao"
    +
    + +

    Example 4:

    + +
    +Input: s = "aaiougrt", indices = [4,0,2,6,7,3,1,5]
    +Output: "arigatou"
    +
    + +

    Example 5:

    + +
    +Input: s = "art", indices = [1,0,2]
    +Output: "rat"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • s.length == indices.length == n
    • +
    • 1 <= n <= 100
    • +
    • s contains only lower-case English letters.
    • +
    • 0 <= indices[i] < n
    • +
    • All values of indices are unique (i.e. indices is a permutation of the integers from 0 to n - 1).
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + +### Hints +
    +Hint 1 +You can create an auxiliary string t of length n. +
    + +
    +Hint 2 +Assign t[indexes[i]] to s[i] for each i from 0 to n-1. +
    diff --git a/problems/string-compression-ii/README.md b/problems/string-compression-ii/README.md new file mode 100644 index 000000000..8830053fa --- /dev/null +++ b/problems/string-compression-ii/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../number-of-good-leaf-nodes-pairs "Number of Good Leaf Nodes Pairs") +                 +Next > + +## [1531. String Compression II (Hard)](https://leetcode.com/problems/string-compression-ii "压缩字符串 II") + +

    Run-length encoding is a string compression method that works by replacing consecutive identical characters (repeated 2 or more times) with the concatenation of the character and the number marking the count of the characters (length of the run). For example, to compress the string "aabccc" we replace "aa" by "a2" and replace "ccc" by "c3". Thus the compressed string becomes "a2bc3".

    + +

    Notice that in this problem, we are not adding '1' after single characters.

    + +

    Given a string s and an integer k. You need to delete at most k characters from s such that the run-length encoded version of s has minimum length.

    + +

    Find the minimum length of the run-length encoded version of s after deleting at most k characters.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "aaabcccd", k = 2
    +Output: 4
    +Explanation: Compressing s without deleting anything will give us "a3bc3d" of length 6. Deleting any of the characters 'a' or 'c' would at most decrease the length of the compressed string to 5, for instance delete 2 'a' then we will have s = "abcccd" which compressed is abc3d. Therefore, the optimal way is to delete 'b' and 'd', then the compressed version of s will be "a3c3" of length 4.
    + +

    Example 2:

    + +
    +Input: s = "aabbaa", k = 2
    +Output: 2
    +Explanation: If we delete both 'b' characters, the resulting compressed string would be "a4" of length 2.
    +
    + +

    Example 3:

    + +
    +Input: s = "aaaaaaaaaaa", k = 0
    +Output: 3
    +Explanation: Since k is zero, we cannot delete anything. The compressed string is "a11" of length 3.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 100
    • +
    • 0 <= k <= s.length
    • +
    • s contains only lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Use dynamic programming. +
    + +
    +Hint 2 +The state of the DP can be the current index and the remaining characters to delete. +
    + +
    +Hint 3 +Having a prefix sum for each character can help you determine for a certain character c in some specific range, how many characters you need to delete to merge all occurrences of c in that range. +
    diff --git a/problems/water-and-jug-problem/README.md b/problems/water-and-jug-problem/README.md index d073d0ba4..f9ace2243 100644 --- a/problems/water-and-jug-problem/README.md +++ b/problems/water-and-jug-problem/README.md @@ -36,6 +36,14 @@ Output: True Input: x = 2, y = 6, z = 5 Output: False +

     

    +

    Constraints:

    + +
      +
    • 0 <= x <= 10^6
    • +
    • 0 <= y <= 10^6
    • +
    • 0 <= z <= 10^6
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/readme/1-300.md b/readme/1-300.md index ba989f2be..3c358fe50 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -129,7 +129,7 @@ LeetCode Problems' Solutions | 57 | [Insert Interval](https://leetcode.com/problems/insert-interval "插入区间") | [Go](../problems/insert-interval) | Hard | | 58 | [Length of Last Word](https://leetcode.com/problems/length-of-last-word "最后一个单词的长度") | [Go](../problems/length-of-last-word) | Easy | | 59 | [Spiral Matrix II](https://leetcode.com/problems/spiral-matrix-ii "螺旋矩阵 II") | [Go](../problems/spiral-matrix-ii) | Medium | -| 60 | [Permutation Sequence](https://leetcode.com/problems/permutation-sequence "第k个排列") | [Go](../problems/permutation-sequence) | Medium | +| 60 | [Permutation Sequence](https://leetcode.com/problems/permutation-sequence "第k个排列") | [Go](../problems/permutation-sequence) | Hard | | 61 | [Rotate List](https://leetcode.com/problems/rotate-list "旋转链表") | [Go](../problems/rotate-list) | Medium | | 62 | [Unique Paths](https://leetcode.com/problems/unique-paths "不同路径") | [Go](../problems/unique-paths) | Medium | | 63 | [Unique Paths II](https://leetcode.com/problems/unique-paths-ii "不同路径 II") | [Go](../problems/unique-paths-ii) | Medium | diff --git a/readme/301-600.md b/readme/301-600.md index 1bd40461b..70c7c16e8 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -140,7 +140,7 @@ LeetCode Problems' Solutions | 368 | [Largest Divisible Subset](https://leetcode.com/problems/largest-divisible-subset "最大整除子集") | [Go](../problems/largest-divisible-subset) | Medium | | 369 | [Plus One Linked List](https://leetcode.com/problems/plus-one-linked-list "给单链表加一") 🔒 | [Go](../problems/plus-one-linked-list) | Medium | | 370 | [Range Addition](https://leetcode.com/problems/range-addition "区间加法") 🔒 | [Go](../problems/range-addition) | Medium | -| 371 | [Sum of Two Integers](https://leetcode.com/problems/sum-of-two-integers "两整数之和") | [Go](../problems/sum-of-two-integers) | Easy | +| 371 | [Sum of Two Integers](https://leetcode.com/problems/sum-of-two-integers "两整数之和") | [Go](../problems/sum-of-two-integers) | Medium | | 372 | [Super Pow](https://leetcode.com/problems/super-pow "超级次方") | [Go](../problems/super-pow) | Medium | | 373 | [Find K Pairs with Smallest Sums](https://leetcode.com/problems/find-k-pairs-with-smallest-sums "查找和最小的K对数字") | [Go](../problems/find-k-pairs-with-smallest-sums) | Medium | | 374 | [Guess Number Higher or Lower](https://leetcode.com/problems/guess-number-higher-or-lower "猜数字大小") | [Go](../problems/guess-number-higher-or-lower) | Easy | @@ -206,7 +206,7 @@ LeetCode Problems' Solutions | 434 | [Number of Segments in a String](https://leetcode.com/problems/number-of-segments-in-a-string "字符串中的单词数") | [Go](../problems/number-of-segments-in-a-string) | Easy | | 435 | [Non-overlapping Intervals](https://leetcode.com/problems/non-overlapping-intervals "无重叠区间") | [Go](../problems/non-overlapping-intervals) | Medium | | 436 | [Find Right Interval](https://leetcode.com/problems/find-right-interval "寻找右区间") | [Go](../problems/find-right-interval) | Medium | -| 437 | [Path Sum III](https://leetcode.com/problems/path-sum-iii "路径总和 III") | [Go](../problems/path-sum-iii) | Easy | +| 437 | [Path Sum III](https://leetcode.com/problems/path-sum-iii "路径总和 III") | [Go](../problems/path-sum-iii) | Medium | | 438 | [Find All Anagrams in a String](https://leetcode.com/problems/find-all-anagrams-in-a-string "找到字符串中所有字母异位词") | [Go](../problems/find-all-anagrams-in-a-string) | Medium | | 439 | [Ternary Expression Parser](https://leetcode.com/problems/ternary-expression-parser "三元表达式解析器") 🔒 | [Go](../problems/ternary-expression-parser) | Medium | | 440 | [K-th Smallest in Lexicographical Order](https://leetcode.com/problems/k-th-smallest-in-lexicographical-order "字典序的第K小数字") | [Go](../problems/k-th-smallest-in-lexicographical-order) | Hard | diff --git a/readme/601-900.md b/readme/601-900.md index 182a98ded..466619155 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -220,7 +220,7 @@ LeetCode Problems' Solutions | 748 | [Shortest Completing Word](https://leetcode.com/problems/shortest-completing-word "最短完整词") | [Go](../problems/shortest-completing-word) | Easy | | 749 | [Contain Virus](https://leetcode.com/problems/contain-virus "隔离病毒") | [Go](../problems/contain-virus) | Hard | | 750 | [Number Of Corner Rectangles](https://leetcode.com/problems/number-of-corner-rectangles "角矩形的数量") 🔒 | [Go](../problems/number-of-corner-rectangles) | Medium | -| 751 | [IP to CIDR](https://leetcode.com/problems/ip-to-cidr "IP 到 CIDR") 🔒 | [Go](../problems/ip-to-cidr) | Easy | +| 751 | [IP to CIDR](https://leetcode.com/problems/ip-to-cidr "IP 到 CIDR") 🔒 | [Go](../problems/ip-to-cidr) | Medium | | 752 | [Open the Lock](https://leetcode.com/problems/open-the-lock "打开转盘锁") | [Go](../problems/open-the-lock) | Medium | | 753 | [Cracking the Safe](https://leetcode.com/problems/cracking-the-safe "破解保险箱") | [Go](../problems/cracking-the-safe) | Hard | | 754 | [Reach a Number](https://leetcode.com/problems/reach-a-number "到达终点数字") | [Go](../problems/reach-a-number) | Medium | diff --git a/tag/array/README.md b/tag/array/README.md index a4046e9e2..08a8e37d7 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | | 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 08245a2e8..c896a565d 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1486 | [数组异或操作](../../problems/xor-operation-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | | 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 59f35ca12..172ff6c07 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index c58fd46e6..a23611a9b 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1510 | [石子游戏 IV](../../problems/stone-game-iv) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1504 | [统计全 1 子矩形](../../problems/count-submatrices-with-all-ones) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1483 | [树节点的第 K 个祖先](../../problems/kth-ancestor-of-a-tree-node) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/math/README.md b/tag/math/README.md index b017f2c51..6fdaf1fdc 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1523 | [在区间范围内统计奇数数目](../../problems/count-odd-numbers-in-an-interval-range) | [[数学](../math/README.md)] | Easy | | 1513 | [仅含 1 的子串数](../../problems/number-of-substrings-with-only-1s) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | | 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index b4b1612de..3e173c442 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[线段树](../segment-tree/README.md)] | Hard | | 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | | 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | diff --git a/tag/sort/README.md b/tag/sort/README.md index 9daea8b48..7641d5c25 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1528 | [重新排列字符串](../../problems/shuffle-string) | [[排序](../sort/README.md)] | Easy | | 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1502 | [判断能否形成等差数列](../../problems/can-make-arithmetic-progression-from-sequence) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | diff --git a/tag/string/README.md b/tag/string/README.md index e7f33808a..6292c54a7 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[字符串](../string/README.md)] | Medium | +| 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1513 | [仅含 1 的子串数](../../problems/number-of-substrings-with-only-1s) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 1507 | [转变日期格式](../../problems/reformat-date) | [[字符串](../string/README.md)] | Easy | | 1496 | [判断路径是否相交](../../problems/path-crossing) | [[字符串](../string/README.md)] | Easy | diff --git a/tag/tree/README.md b/tag/tree/README.md index f962bab77..444961f7d 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1516 | [Move Sub-Tree of N-Ary Tree](../../problems/move-sub-tree-of-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | @@ -99,7 +100,7 @@ | 501 | [二叉搜索树中的众数](../../problems/find-mode-in-binary-search-tree) | [[树](../tree/README.md)] | Easy | | 450 | [删除二叉搜索树中的节点](../../problems/delete-node-in-a-bst) | [[树](../tree/README.md)] | Medium | | 449 | [序列化和反序列化二叉搜索树](../../problems/serialize-and-deserialize-bst) | [[树](../tree/README.md)] | Medium | -| 437 | [路径总和 III](../../problems/path-sum-iii) | [[树](../tree/README.md)] | Easy | +| 437 | [路径总和 III](../../problems/path-sum-iii) | [[树](../tree/README.md)] | Medium | | 431 | [将 N 叉树编码为二叉树](../../problems/encode-n-ary-tree-to-binary-tree) 🔒 | [[树](../tree/README.md)] | Hard | | 429 | [N叉树的层序遍历](../../problems/n-ary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 428 | [序列化和反序列化 N 叉树](../../problems/serialize-and-deserialize-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard | From a7d9333b2baaea737d236a7220d7b6fa318018df Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 3 Aug 2020 09:38:02 +0800 Subject: [PATCH 092/145] A: new --- README.md | 8 +- .../all-paths-from-source-to-target/README.md | 9 +- problems/brace-expansion/README.md | 2 +- problems/count-good-triplets/README.md | 67 +++++++++++++++ .../README.md | 28 ++++++ .../README.md | 2 +- .../README.md | 81 ++++++++++++++++++ problems/first-missing-positive/README.md | 2 +- .../fraction-to-recurring-decimal/README.md | 2 + problems/get-the-maximum-score/README.md | 85 +++++++++++++++++++ problems/letter-case-permutation/README.md | 5 +- .../README.md | 72 ++++++++++++++++ problems/possible-bipartition/README.md | 1 + problems/range-sum-query-immutable/README.md | 28 +++--- problems/string-compression-ii/README.md | 2 +- problems/subsets/README.md | 2 +- .../the-most-recent-three-orders/README.md | 14 +++ .../mysql_schemas.sql | 19 +++++ problems/validate-stack-sequences/README.md | 11 ++- readme/601-900.md | 2 +- tag/README.md | 2 +- tag/array/README.md | 2 + tag/backtracking/README.md | 2 +- tag/binary-search/README.md | 1 + tag/bit-manipulation/README.md | 2 +- tag/depth-first-search/README.md | 2 +- tag/dynamic-programming/README.md | 1 + tag/graph/README.md | 1 + tag/greedy/README.md | 1 + tag/tags.json | 10 +-- 30 files changed, 426 insertions(+), 40 deletions(-) create mode 100644 problems/count-good-triplets/README.md create mode 100644 problems/find-the-index-of-the-large-integer/README.md create mode 100644 problems/find-the-winner-of-an-array-game/README.md create mode 100644 problems/get-the-maximum-score/README.md create mode 100644 problems/minimum-swaps-to-arrange-a-binary-grid/README.md create mode 100644 problems/the-most-recent-three-orders/README.md create mode 100644 problems/the-most-recent-three-orders/mysql_schemas.sql diff --git a/README.md b/README.md index 3fb927922..a72b2c6e6 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,12 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1537 | [Get the Maximum Score](https://leetcode.com/problems/get-the-maximum-score "最大得分") | [Go](problems/get-the-maximum-score) | Hard | +| 1536 | [Minimum Swaps to Arrange a Binary Grid](https://leetcode.com/problems/minimum-swaps-to-arrange-a-binary-grid "排布二进制网格的最少交换次数") | [Go](problems/minimum-swaps-to-arrange-a-binary-grid) | Medium | +| 1535 | [Find the Winner of an Array Game](https://leetcode.com/problems/find-the-winner-of-an-array-game "找出数组游戏的赢家") | [Go](problems/find-the-winner-of-an-array-game) | Medium | +| 1534 | [Count Good Triplets](https://leetcode.com/problems/count-good-triplets "统计好三元组") | [Go](problems/count-good-triplets) | Easy | +| 1533 | [Find the Index of the Large Integer](https://leetcode.com/problems/find-the-index-of-the-large-integer) 🔒 | [Go](problems/find-the-index-of-the-large-integer) | Medium | +| 1532 | [The Most Recent Three Orders](https://leetcode.com/problems/the-most-recent-three-orders) 🔒 | [MySQL](problems/the-most-recent-three-orders) | Medium | | 1531 | [String Compression II](https://leetcode.com/problems/string-compression-ii "压缩字符串 II") | [Go](problems/string-compression-ii) | Hard | | 1530 | [Number of Good Leaf Nodes Pairs](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs "好叶子节点对的数量") | [Go](problems/number-of-good-leaf-nodes-pairs) | Medium | | 1529 | [Bulb Switcher IV](https://leetcode.com/problems/bulb-switcher-iv "灯泡开关 IV") | [Go](problems/bulb-switcher-iv) | Medium | @@ -189,7 +195,7 @@ LeetCode Problems' Solutions | 1415 | [The k-th Lexicographical String of All Happy Strings of Length n](https://leetcode.com/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n "长度为 n 的开心字符串中字典序第 k 小的字符串") | [Go](problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | Medium | | 1414 | [Find the Minimum Number of Fibonacci Numbers Whose Sum Is K](https://leetcode.com/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k "和为 K 的最少斐波那契数字数目") | [Go](problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | Medium | | 1413 | [Minimum Value to Get Positive Step by Step Sum](https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum "逐步求和得到正数的最小值") | [Go](problems/minimum-value-to-get-positive-step-by-step-sum) | Easy | -| 1412 | [Find the Quiet Students in All Exams](https://leetcode.com/problems/find-the-quiet-students-in-all-exams "查找成绩处于中游的的学生") 🔒 | [MySQL](problems/find-the-quiet-students-in-all-exams) | Hard | +| 1412 | [Find the Quiet Students in All Exams](https://leetcode.com/problems/find-the-quiet-students-in-all-exams "查找成绩处于中游的学生") 🔒 | [MySQL](problems/find-the-quiet-students-in-all-exams) | Hard | | 1411 | [Number of Ways to Paint N × 3 Grid](https://leetcode.com/problems/number-of-ways-to-paint-n-3-grid "给 N x 3 网格图涂色的方案数") | [Go](problems/number-of-ways-to-paint-n-3-grid) | Hard | | 1410 | [HTML Entity Parser](https://leetcode.com/problems/html-entity-parser "HTML 实体解析器") | [Go](problems/html-entity-parser) | Medium | | 1409 | [Queries on a Permutation With Key](https://leetcode.com/problems/queries-on-a-permutation-with-key "查询带键的排列") | [Go](problems/queries-on-a-permutation-with-key) | Medium | diff --git a/problems/all-paths-from-source-to-target/README.md b/problems/all-paths-from-source-to-target/README.md index eb3504a37..ffd550275 100644 --- a/problems/all-paths-from-source-to-target/README.md +++ b/problems/all-paths-from-source-to-target/README.md @@ -11,14 +11,14 @@ ## [797. All Paths From Source to Target (Medium)](https://leetcode.com/problems/all-paths-from-source-to-target "所有可能的路径") -

    Given a directed, acyclic graph of N nodes.  Find all possible paths from node 0 to node N-1, and return them in any order.

    +

    Given a directed acyclic graph of N nodes. Find all possible paths from node 0 to node N-1, and return them in any order.

    The graph is given as follows:  the nodes are 0, 1, ..., graph.length - 1.  graph[i] is a list of all nodes j for which the edge (i, j) exists.

     Example:
    -Input: [[1,2], [3], [3], []] 
    -Output: [[0,1,3],[0,2,3]] 
    +Input: [[1,2],[3],[3],[]]
    +Output: [[0,1,3],[0,2,3]]
     Explanation: The graph looks like this:
     0--->1
     |    |
    @@ -27,7 +27,8 @@ v    v
     There are two paths: 0 -> 1 -> 3 and 0 -> 2 -> 3.
     
    -

    Note:

    +

     

    +

    Constraints:

    • The number of nodes in the graph will be in the range [2, 15].
    • diff --git a/problems/brace-expansion/README.md b/problems/brace-expansion/README.md index 937e39d7a..358f81c0f 100644 --- a/problems/brace-expansion/README.md +++ b/problems/brace-expansion/README.md @@ -50,7 +50,7 @@ ### Similar Questions 1. [Decode String](../decode-string) (Medium) - 1. [Letter Case Permutation](../letter-case-permutation) (Easy) + 1. [Letter Case Permutation](../letter-case-permutation) (Medium) 1. [Brace Expansion II](../brace-expansion-ii) (Hard) ### Hints diff --git a/problems/count-good-triplets/README.md b/problems/count-good-triplets/README.md new file mode 100644 index 000000000..2170a4cf6 --- /dev/null +++ b/problems/count-good-triplets/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../find-the-index-of-the-large-integer "Find the Index of the Large Integer") +                 +[Next >](../find-the-winner-of-an-array-game "Find the Winner of an Array Game") + +## [1534. Count Good Triplets (Easy)](https://leetcode.com/problems/count-good-triplets "统计好三元组") + +

      Given an array of integers arr, and three integers ab and c. You need to find the number of good triplets.

      + +

      A triplet (arr[i], arr[j], arr[k]) is good if the following conditions are true:

      + +
        +
      • 0 <= i < j < k < arr.length
      • +
      • |arr[i] - arr[j]| <= a
      • +
      • |arr[j] - arr[k]| <= b
      • +
      • |arr[i] - arr[k]| <= c
      • +
      + +

      Where |x| denotes the absolute value of x.

      + +

      Return the number of good triplets.

      + +

       

      +

      Example 1:

      + +
      +Input: arr = [3,0,1,1,9,7], a = 7, b = 2, c = 3
      +Output: 4
      +Explanation: There are 4 good triplets: [(3,0,1), (3,0,1), (3,1,1), (0,1,1)].
      +
      + +

      Example 2:

      + +
      +Input: arr = [1,1,2,2,3], a = 0, b = 0, c = 1
      +Output: 0
      +Explanation: No triplet satisfies all conditions.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 3 <= arr.length <= 100
      • +
      • 0 <= arr[i] <= 1000
      • +
      • 0 <= a, b, c <= 1000
      • +
      + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
      +Hint 1 +Notice that the constraints are small enough for a brute force solution to pass. +
      + +
      +Hint 2 +Loop through all triplets, and count the ones that are good. +
      diff --git a/problems/find-the-index-of-the-large-integer/README.md b/problems/find-the-index-of-the-large-integer/README.md new file mode 100644 index 000000000..d397c2dac --- /dev/null +++ b/problems/find-the-index-of-the-large-integer/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../the-most-recent-three-orders "The Most Recent Three Orders") +                 +[Next >](../count-good-triplets "Count Good Triplets") + +## [1533. Find the Index of the Large Integer (Medium)](https://leetcode.com/problems/find-the-index-of-the-large-integer "") + + + +### Related Topics + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
      +Hint 1 +Do a binary search over the array, exclude the half of the array that doesn't contain the largest number. +
      + +
      +Hint 2 +Keep shrinking the search space till it reaches the size of 2 where you can easily determine which one has the largest integer. +
      diff --git a/problems/find-the-quiet-students-in-all-exams/README.md b/problems/find-the-quiet-students-in-all-exams/README.md index 1bf21ead1..7ad2fd8bf 100644 --- a/problems/find-the-quiet-students-in-all-exams/README.md +++ b/problems/find-the-quiet-students-in-all-exams/README.md @@ -9,6 +9,6 @@                  [Next >](../minimum-value-to-get-positive-step-by-step-sum "Minimum Value to Get Positive Step by Step Sum") -## [1412. Find the Quiet Students in All Exams (Hard)](https://leetcode.com/problems/find-the-quiet-students-in-all-exams "查找成绩处于中游的的学生") +## [1412. Find the Quiet Students in All Exams (Hard)](https://leetcode.com/problems/find-the-quiet-students-in-all-exams "查找成绩处于中游的学生") diff --git a/problems/find-the-winner-of-an-array-game/README.md b/problems/find-the-winner-of-an-array-game/README.md new file mode 100644 index 000000000..9d5feff5a --- /dev/null +++ b/problems/find-the-winner-of-an-array-game/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../count-good-triplets "Count Good Triplets") +                 +[Next >](../minimum-swaps-to-arrange-a-binary-grid "Minimum Swaps to Arrange a Binary Grid") + +## [1535. Find the Winner of an Array Game (Medium)](https://leetcode.com/problems/find-the-winner-of-an-array-game "找出数组游戏的赢家") + +

      Given an integer array arr of distinct integers and an integer k.

      + +

      A game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of the game, we compare arr[0] with arr[1], the larger integer wins and remains at position 0 and the smaller integer moves to the end of the array. The game ends when an integer wins k consecutive rounds.

      + +

      Return the integer which will win the game.

      + +

      It is guaranteed that there will be a winner of the game.

      + +

       

      +

      Example 1:

      + +
      +Input: arr = [2,1,3,5,4,6,7], k = 2
      +Output: 5
      +Explanation: Let's see the rounds of the game:
      +Round |       arr       | winner | win_count
      +  1   | [2,1,3,5,4,6,7] | 2      | 1
      +  2   | [2,3,5,4,6,7,1] | 3      | 1
      +  3   | [3,5,4,6,7,1,2] | 5      | 1
      +  4   | [5,4,6,7,1,2,3] | 5      | 2
      +So we can see that 4 rounds will be played and 5 is the winner because it wins 2 consecutive games.
      +
      + +

      Example 2:

      + +
      +Input: arr = [3,2,1], k = 10
      +Output: 3
      +Explanation: 3 will win the first 10 rounds consecutively.
      +
      + +

      Example 3:

      + +
      +Input: arr = [1,9,8,2,3,7,6,4,5], k = 7
      +Output: 9
      +
      + +

      Example 4:

      + +
      +Input: arr = [1,11,22,33,44,55,66,77,88,99], k = 1000000000
      +Output: 99
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 2 <= arr.length <= 10^5
      • +
      • 1 <= arr[i] <= 10^6
      • +
      • arr contains distinct integers.
      • +
      • 1 <= k <= 10^9
      • +
      + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
      +Hint 1 +If k ≥ arr.length return the max element of the array. +
      + +
      +Hint 2 +If k < arr.length simulate the game until a number wins k consecutive games. +
      diff --git a/problems/first-missing-positive/README.md b/problems/first-missing-positive/README.md index 923cce8fa..adf4889ee 100644 --- a/problems/first-missing-positive/README.md +++ b/problems/first-missing-positive/README.md @@ -34,7 +34,7 @@ Input: [7,8,9,11,12] Output: 1 -

      Note:

      +

      Follow up:

      Your algorithm should run in O(n) time and uses constant extra space.

      diff --git a/problems/fraction-to-recurring-decimal/README.md b/problems/fraction-to-recurring-decimal/README.md index 24f9a239c..1853aeca2 100644 --- a/problems/fraction-to-recurring-decimal/README.md +++ b/problems/fraction-to-recurring-decimal/README.md @@ -15,6 +15,8 @@

      If the fractional part is repeating, enclose the repeating part in parentheses.

      +

      If multiple answers are possible, just return any of them.

      +

      Example 1:

      diff --git a/problems/get-the-maximum-score/README.md b/problems/get-the-maximum-score/README.md
      new file mode 100644
      index 000000000..58bedfc89
      --- /dev/null
      +++ b/problems/get-the-maximum-score/README.md
      @@ -0,0 +1,85 @@
      +
      +
      +
      +
      +
      +
      +
      +[< Previous](../minimum-swaps-to-arrange-a-binary-grid "Minimum Swaps to Arrange a Binary Grid")
      +                
      +Next >
      +
      +## [1537. Get the Maximum Score (Hard)](https://leetcode.com/problems/get-the-maximum-score "最大得分")
      +
      +

      You are given two sorted arrays of distinct integers nums1 and nums2.

      + +

      A valid path is defined as follows:

      + +
        +
      • Choose array nums1 or nums2 to traverse (from index-0).
      • +
      • Traverse the current array from left to right.
      • +
      • If you are reading any value that is present in nums1 and nums2 you are allowed to change your path to the other array. (Only one repeated value is considered in the valid path).
      • +
      + +

      Score is defined as the sum of uniques values in a valid path.

      + +

      Return the maximum score you can obtain of all possible valid paths.

      + +

      Since the answer may be too large, return it modulo 10^9 + 7.

      + +

       

      +

      Example 1:

      + +

      + +
      +Input: nums1 = [2,4,5,8,10], nums2 = [4,6,8,9]
      +Output: 30
      +Explanation: Valid paths:
      +[2,4,5,8,10], [2,4,5,8,9], [2,4,6,8,9], [2,4,6,8,10],  (starting from nums1)
      +[4,6,8,9], [4,5,8,10], [4,5,8,9], [4,6,8,10]    (starting from nums2)
      +The maximum is obtained with the path in green [2,4,6,8,10].
      +
      + +

      Example 2:

      + +
      +Input: nums1 = [1,3,5,7,9], nums2 = [3,5,100]
      +Output: 109
      +Explanation: Maximum sum is obtained with the path [1,3,5,100].
      +
      + +

      Example 3:

      + +
      +Input: nums1 = [1,2,3,4,5], nums2 = [6,7,8,9,10]
      +Output: 40
      +Explanation: There are no common elements between nums1 and nums2.
      +Maximum sum is obtained with the path [6,7,8,9,10].
      +
      + +

      Example 4:

      + +
      +Input: nums1 = [1,4,5,8,9,11,19], nums2 = [2,3,4,11,12]
      +Output: 61
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= nums1.length <= 10^5
      • +
      • 1 <= nums2.length <= 10^5
      • +
      • 1 <= nums1[i], nums2[i] <= 10^7
      • +
      • nums1 and nums2 are strictly increasing.
      • +
      + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
      +Hint 1 +Partition the array by common integers, and choose the path with larger sum with a DP technique. +
      diff --git a/problems/letter-case-permutation/README.md b/problems/letter-case-permutation/README.md index 31b3fc159..7df90a000 100644 --- a/problems/letter-case-permutation/README.md +++ b/problems/letter-case-permutation/README.md @@ -9,7 +9,7 @@                  [Next >](../is-graph-bipartite "Is Graph Bipartite?") -## [784. Letter Case Permutation (Easy)](https://leetcode.com/problems/letter-case-permutation "字母大小写全排列") +## [784. Letter Case Permutation (Medium)](https://leetcode.com/problems/letter-case-permutation "字母大小写全排列")

      Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string.  Return a list of all possible strings we could create.

      @@ -25,7 +25,8 @@ Output: ["12345"]
      -

      Note:

      +

       

      +

      Constraints:

      • S will be a string with length between 1 and 12.
      • diff --git a/problems/minimum-swaps-to-arrange-a-binary-grid/README.md b/problems/minimum-swaps-to-arrange-a-binary-grid/README.md new file mode 100644 index 000000000..fb45468ea --- /dev/null +++ b/problems/minimum-swaps-to-arrange-a-binary-grid/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../find-the-winner-of-an-array-game "Find the Winner of an Array Game") +                 +[Next >](../get-the-maximum-score "Get the Maximum Score") + +## [1536. Minimum Swaps to Arrange a Binary Grid (Medium)](https://leetcode.com/problems/minimum-swaps-to-arrange-a-binary-grid "排布二进制网格的最少交换次数") + +

        Given an n x n binary grid, in one step you can choose two adjacent rows of the grid and swap them.

        + +

        A grid is said to be valid if all the cells above the main diagonal are zeros.

        + +

        Return the minimum number of steps needed to make the grid valid, or -1 if the grid cannot be valid.

        + +

        The main diagonal of a grid is the diagonal that starts at cell (1, 1) and ends at cell (n, n).

        + +

         

        +

        Example 1:

        + +
        +Input: grid = [[0,0,1],[1,1,0],[1,0,0]]
        +Output: 3
        +
        + +

        Example 2:

        + +
        +Input: grid = [[0,1,1,0],[0,1,1,0],[0,1,1,0],[0,1,1,0]]
        +Output: -1
        +Explanation: All rows are similar, swaps have no effect on the grid.
        +
        + +

        Example 3:

        + +
        +Input: grid = [[1,0,0],[1,1,0],[1,1,1]]
        +Output: 0
        +
        + +

         

        +

        Constraints:

        + +
          +
        • n == grid.length
        • +
        • n == grid[i].length
        • +
        • 1 <= n <= 200
        • +
        • grid[i][j] is 0 or 1
        • +
        + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
        +Hint 1 +For each row of the grid calculate the most right 1 in the grid in the array maxRight. +
        + +
        +Hint 2 +To check if there exist answer, sort maxRight and check if maxRight[i] ≤ i for all possible i's. +
        + +
        +Hint 3 +If there exist an answer, simulate the swaps. +
        diff --git a/problems/possible-bipartition/README.md b/problems/possible-bipartition/README.md index 251cd5219..998f93166 100644 --- a/problems/possible-bipartition/README.md +++ b/problems/possible-bipartition/README.md @@ -70,3 +70,4 @@ ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] diff --git a/problems/range-sum-query-immutable/README.md b/problems/range-sum-query-immutable/README.md index e1baedfd5..6e3a0fcf7 100644 --- a/problems/range-sum-query-immutable/README.md +++ b/problems/range-sum-query-immutable/README.md @@ -13,22 +13,26 @@

        Given an integer array nums, find the sum of the elements between indices i and j (ij), inclusive.

        -

        Example:
        +

        Example:

        +
         Given nums = [-2, 0, 3, -5, 2, -1]
         
        -sumRange(0, 2) -> 1
        -sumRange(2, 5) -> -1
        -sumRange(0, 5) -> -3
        +sumRange(0, 2) -> 1
        +sumRange(2, 5) -> -1
        +sumRange(0, 5) -> -3
         
        -

        - -

        Note:
        -

          -
        1. You may assume that the array does not change.
        2. -
        3. There are many calls to sumRange function.
        4. -
        -

        + +

         

        +

        Constraints:

        + +
          +
        • You may assume that the array does not change.
        • +
        • There are many calls to sumRange function.
        • +
        • 0 <= nums.length <= 10^4
        • +
        • -10^5 <= nums[i] <= 10^5
        • +
        • 0 <= i <= j < nums.length
        • +
        ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/string-compression-ii/README.md b/problems/string-compression-ii/README.md index 8830053fa..9929ee6c8 100644 --- a/problems/string-compression-ii/README.md +++ b/problems/string-compression-ii/README.md @@ -7,7 +7,7 @@ [< Previous](../number-of-good-leaf-nodes-pairs "Number of Good Leaf Nodes Pairs")                  -Next > +[Next >](../the-most-recent-three-orders "The Most Recent Three Orders") ## [1531. String Compression II (Hard)](https://leetcode.com/problems/string-compression-ii "压缩字符串 II") diff --git a/problems/subsets/README.md b/problems/subsets/README.md index de74d43be..7e07dc0be 100644 --- a/problems/subsets/README.md +++ b/problems/subsets/README.md @@ -39,4 +39,4 @@ ### Similar Questions 1. [Subsets II](../subsets-ii) (Medium) 1. [Generalized Abbreviation](../generalized-abbreviation) (Medium) - 1. [Letter Case Permutation](../letter-case-permutation) (Easy) + 1. [Letter Case Permutation](../letter-case-permutation) (Medium) diff --git a/problems/the-most-recent-three-orders/README.md b/problems/the-most-recent-three-orders/README.md new file mode 100644 index 000000000..faf89fc92 --- /dev/null +++ b/problems/the-most-recent-three-orders/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../string-compression-ii "String Compression II") +                 +[Next >](../find-the-index-of-the-large-integer "Find the Index of the Large Integer") + +## [1532. The Most Recent Three Orders (Medium)](https://leetcode.com/problems/the-most-recent-three-orders "") + + diff --git a/problems/the-most-recent-three-orders/mysql_schemas.sql b/problems/the-most-recent-three-orders/mysql_schemas.sql new file mode 100644 index 000000000..85541ef76 --- /dev/null +++ b/problems/the-most-recent-three-orders/mysql_schemas.sql @@ -0,0 +1,19 @@ +Create table If Not Exists Customers (customer_id int, name varchar(10)); +Create table If Not Exists Orders (order_id int, order_date date, customer_id int, cost int); +Truncate table Customers; +insert into Customers (customer_id, name) values ('1', 'Winston'); +insert into Customers (customer_id, name) values ('2', 'Jonathan'); +insert into Customers (customer_id, name) values ('3', 'Annabelle'); +insert into Customers (customer_id, name) values ('4', 'Marwan'); +insert into Customers (customer_id, name) values ('5', 'Khaled'); +Truncate table Orders; +insert into Orders (order_id, order_date, customer_id, cost) values ('1', '2020-07-31', '1', '30'); +insert into Orders (order_id, order_date, customer_id, cost) values ('2', '2020-7-30', '2', '40'); +insert into Orders (order_id, order_date, customer_id, cost) values ('3', '2020-07-31', '3', '70'); +insert into Orders (order_id, order_date, customer_id, cost) values ('4', '2020-07-29', '4', '100'); +insert into Orders (order_id, order_date, customer_id, cost) values ('5', '2020-06-10', '1', '1010'); +insert into Orders (order_id, order_date, customer_id, cost) values ('6', '2020-08-01', '2', '102'); +insert into Orders (order_id, order_date, customer_id, cost) values ('7', '2020-08-01', '3', '111'); +insert into Orders (order_id, order_date, customer_id, cost) values ('8', '2020-08-03', '1', '99'); +insert into Orders (order_id, order_date, customer_id, cost) values ('9', '2020-08-07', '2', '32'); +insert into Orders (order_id, order_date, customer_id, cost) values ('10', '2020-07-15', '1', '2'); diff --git a/problems/validate-stack-sequences/README.md b/problems/validate-stack-sequences/README.md index 33acc1474..260c3aa5a 100644 --- a/problems/validate-stack-sequences/README.md +++ b/problems/validate-stack-sequences/README.md @@ -34,19 +34,18 @@ push(5), pop() -> 5, pop() -> 3, pop() -> 2, pop() -> 1 Output: false Explanation: 1 cannot be popped before 2. + +

         

        +

        Constraints:

        -

        Note:

        - -
          +
          • 0 <= pushed.length == popped.length <= 1000
          • 0 <= pushed[i], popped[i] < 1000
          • pushed is a permutation of popped.
          • pushed and popped have distinct values.
          • -
        - - +
      ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/readme/601-900.md b/readme/601-900.md index 466619155..6d447983a 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -253,7 +253,7 @@ LeetCode Problems' Solutions | 781 | [Rabbits in Forest](https://leetcode.com/problems/rabbits-in-forest "森林中的兔子") | [Go](../problems/rabbits-in-forest) | Medium | | 782 | [Transform to Chessboard](https://leetcode.com/problems/transform-to-chessboard "变为棋盘") | [Go](../problems/transform-to-chessboard) | Hard | | 783 | [Minimum Distance Between BST Nodes](https://leetcode.com/problems/minimum-distance-between-bst-nodes "二叉搜索树节点最小距离") | [Go](../problems/minimum-distance-between-bst-nodes) | Easy | -| 784 | [Letter Case Permutation](https://leetcode.com/problems/letter-case-permutation "字母大小写全排列") | [Go](../problems/letter-case-permutation) | Easy | +| 784 | [Letter Case Permutation](https://leetcode.com/problems/letter-case-permutation "字母大小写全排列") | [Go](../problems/letter-case-permutation) | Medium | | 785 | [Is Graph Bipartite?](https://leetcode.com/problems/is-graph-bipartite "判断二分图") | [Go](../problems/is-graph-bipartite) | Medium | | 786 | [K-th Smallest Prime Fraction](https://leetcode.com/problems/k-th-smallest-prime-fraction "第 K 个最小的素数分数") | [Go](../problems/k-th-smallest-prime-fraction) | Hard | | 787 | [Cheapest Flights Within K Stops](https://leetcode.com/problems/cheapest-flights-within-k-stops "K 站中转内最便宜的航班") | [Go](../problems/cheapest-flights-within-k-stops) | Medium | diff --git a/tag/README.md b/tag/README.md index b7540e2f6..cf0817e55 100644 --- a/tag/README.md +++ b/tag/README.md @@ -14,7 +14,7 @@ | 5 | [Tree](tree/README.md) | [树](https://openset.github.io/tags/tree/) | | 6 | [Depth-first Search](depth-first-search/README.md) | [深度优先搜索](https://openset.github.io/tags/depth-first-search/) | | 7 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | | 8 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 9 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | -| 11 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 12 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | +| 11 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 13 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | | 14 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 15 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 16 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | diff --git a/tag/array/README.md b/tag/array/README.md index 08a8e37d7..1b05e93e6 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1535 | [找出数组游戏的赢家](../../problems/find-the-winner-of-an-array-game) | [[数组](../array/README.md)] | Medium | +| 1534 | [统计好三元组](../../problems/count-good-triplets) | [[数组](../array/README.md)] | Easy | | 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | | 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 62615e280..277f11155 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -26,7 +26,7 @@ | 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 980 | [不同路径 III](../../problems/unique-paths-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | +| 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 526 | [优美的排列](../../problems/beautiful-arrangement) | [[回溯算法](../backtracking/README.md)] | Medium | | 425 | [单词方块](../../problems/word-squares) 🔒 | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 525ef3fbe..0c4e9ff38 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1533 | [Find the Index of the Large Integer](../../problems/find-the-index-of-the-large-integer) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | | 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1482 | [制作 m 束花所需的最少天数](../../problems/minimum-number-of-days-to-make-m-bouquets) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index c896a565d..03b7ad6b6 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -30,7 +30,7 @@ | 1131 | [绝对值表达式的最大值](../../problems/maximum-of-absolute-value-expression) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | | 1125 | [最小的必要团队](../../problems/smallest-sufficient-team) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 898 | [子数组按位或操作](../../problems/bitwise-ors-of-subarrays) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | +| 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 762 | [二进制表示中质数个计算置位](../../problems/prime-number-of-set-bits-in-binary-representation) | [[位运算](../bit-manipulation/README.md)] | Easy | | 756 | [金字塔转换矩阵](../../problems/pyramid-transition-matrix) | [[位运算](../bit-manipulation/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 751 | [IP 到 CIDR](../../problems/ip-to-cidr) 🔒 | [[位运算](../bit-manipulation/README.md)] | Easy | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 172ff6c07..7bd02307c 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -55,7 +55,7 @@ | 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 924 | [尽量减少恶意软件的传播](../../problems/minimize-malware-spread) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | | 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 851 | [喧闹和富有](../../problems/loud-and-rich) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index a23611a9b..be4e0e823 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1537 | [最大得分](../../problems/get-the-maximum-score) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1510 | [石子游戏 IV](../../problems/stone-game-iv) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1504 | [统计全 1 子矩形](../../problems/count-submatrices-with-all-ones) | [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/graph/README.md b/tag/graph/README.md index f195964cb..2175ba887 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -34,6 +34,7 @@ | 990 | [等式方程的可满足性](../../problems/satisfiability-of-equality-equations) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 854 | [相似度为 K 的字符串](../../problems/k-similar-strings) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Hard | | 841 | [钥匙和房间](../../problems/keys-and-rooms) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 1bd691a75..c25d8c18d 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心算法](../greedy/README.md)] | Medium | | 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心算法](../greedy/README.md)] | Medium | | 1518 | [换酒问题](../../problems/water-bottles) | [[贪心算法](../greedy/README.md)] | Easy | | 1505 | [最多 K 次交换相邻数位后得到的最小整数](../../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | [[贪心算法](../greedy/README.md)] | Hard | diff --git a/tag/tags.json b/tag/tags.json index c3506ec98..7fb7da2e6 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -49,16 +49,16 @@ "Slug": "breadth-first-search", "TranslatedName": "广度优先搜索" }, - { - "Name": "Two Pointers", - "Slug": "two-pointers", - "TranslatedName": "双指针" - }, { "Name": "Sort", "Slug": "sort", "TranslatedName": "排序" }, + { + "Name": "Two Pointers", + "Slug": "two-pointers", + "TranslatedName": "双指针" + }, { "Name": "Stack", "Slug": "stack", From 0e93785521f88740c17f802880d010ff95378a92 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 10 Aug 2020 09:09:24 +0800 Subject: [PATCH 093/145] A: new --- README.md | 10 +++ problems/binary-tree-pruning/README.md | 2 +- .../can-convert-string-in-k-moves/README.md | 76 ++++++++++++++++ .../README.md | 17 +++- .../README.md | 80 +++++++++++++++++ .../find-longest-awesome-substring/README.md | 75 ++++++++++++++++ problems/fix-product-name-format/README.md | 14 +++ .../fix-product-name-format/mysql_schemas.sql | 9 ++ problems/get-the-maximum-score/README.md | 2 +- .../README.md | 20 +++++ .../kth-missing-positive-number/README.md | 53 +++++++++++ problems/make-the-string-great/README.md | 76 ++++++++++++++++ .../README.md | 70 +++++++++++++++ problems/merge-intervals/README.md | 11 ++- .../minimum-cost-to-cut-a-stick/README.md | 66 ++++++++++++++ .../README.md | 89 +++++++++++++++++++ problems/predict-the-winner/README.md | 39 ++++---- tag/array/README.md | 1 + tag/bit-manipulation/README.md | 1 + tag/dynamic-programming/README.md | 2 + tag/greedy/README.md | 1 + tag/hash-table/README.md | 1 + tag/stack/README.md | 2 + tag/string/README.md | 5 ++ 24 files changed, 698 insertions(+), 24 deletions(-) create mode 100644 problems/can-convert-string-in-k-moves/README.md create mode 100644 problems/find-kth-bit-in-nth-binary-string/README.md create mode 100644 problems/find-longest-awesome-substring/README.md create mode 100644 problems/fix-product-name-format/README.md create mode 100644 problems/fix-product-name-format/mysql_schemas.sql create mode 100644 problems/guess-the-majority-in-a-hidden-array/README.md create mode 100644 problems/kth-missing-positive-number/README.md create mode 100644 problems/make-the-string-great/README.md create mode 100644 problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md create mode 100644 problems/minimum-cost-to-cut-a-stick/README.md create mode 100644 problems/minimum-insertions-to-balance-a-parentheses-string/README.md diff --git a/README.md b/README.md index a72b2c6e6..d0624c236 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,16 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1547 | [Minimum Cost to Cut a Stick](https://leetcode.com/problems/minimum-cost-to-cut-a-stick "切棍子的最小成本") | [Go](problems/minimum-cost-to-cut-a-stick) | Hard | +| 1546 | [Maximum Number of Non-Overlapping Subarrays With Sum Equals Target](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值的最大数目不重叠非空子数组数目") | [Go](problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | Medium | +| 1545 | [Find Kth Bit in Nth Binary String](https://leetcode.com/problems/find-kth-bit-in-nth-binary-string "找出第 N 个二进制字符串中的第 K 位") | [Go](problems/find-kth-bit-in-nth-binary-string) | Medium | +| 1544 | [Make The String Great](https://leetcode.com/problems/make-the-string-great "整理字符串") | [Go](problems/make-the-string-great) | Easy | +| 1543 | [Fix Product Name Format](https://leetcode.com/problems/fix-product-name-format) 🔒 | [MySQL](problems/fix-product-name-format) | Easy | +| 1542 | [Find Longest Awesome Substring](https://leetcode.com/problems/find-longest-awesome-substring "找出最长的超赞子字符串") | [Go](problems/find-longest-awesome-substring) | Hard | +| 1541 | [Minimum Insertions to Balance a Parentheses String](https://leetcode.com/problems/minimum-insertions-to-balance-a-parentheses-string "平衡括号字符串的最少插入次数") | [Go](problems/minimum-insertions-to-balance-a-parentheses-string) | Medium | +| 1540 | [Can Convert String in K Moves](https://leetcode.com/problems/can-convert-string-in-k-moves "K 次操作转变字符串") | [Go](problems/can-convert-string-in-k-moves) | Medium | +| 1539 | [Kth Missing Positive Number](https://leetcode.com/problems/kth-missing-positive-number "第 k 个缺失的正整数") | [Go](problems/kth-missing-positive-number) | Easy | +| 1538 | [Guess the Majority in a Hidden Array](https://leetcode.com/problems/guess-the-majority-in-a-hidden-array) 🔒 | [Go](problems/guess-the-majority-in-a-hidden-array) | Medium | | 1537 | [Get the Maximum Score](https://leetcode.com/problems/get-the-maximum-score "最大得分") | [Go](problems/get-the-maximum-score) | Hard | | 1536 | [Minimum Swaps to Arrange a Binary Grid](https://leetcode.com/problems/minimum-swaps-to-arrange-a-binary-grid "排布二进制网格的最少交换次数") | [Go](problems/minimum-swaps-to-arrange-a-binary-grid) | Medium | | 1535 | [Find the Winner of an Array Game](https://leetcode.com/problems/find-the-winner-of-an-array-game "找出数组游戏的赢家") | [Go](problems/find-the-winner-of-an-array-game) | Medium | diff --git a/problems/binary-tree-pruning/README.md b/problems/binary-tree-pruning/README.md index 7fa911708..ab437fa41 100644 --- a/problems/binary-tree-pruning/README.md +++ b/problems/binary-tree-pruning/README.md @@ -50,7 +50,7 @@ The diagram on the right represents the answer.

      Note:

        -
      • The binary tree will have at most 100 nodes.
      • +
      • The binary tree will have at most 200 nodes.
      • The value of each node will only be 0 or 1.
      diff --git a/problems/can-convert-string-in-k-moves/README.md b/problems/can-convert-string-in-k-moves/README.md new file mode 100644 index 000000000..90b7b02e6 --- /dev/null +++ b/problems/can-convert-string-in-k-moves/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](../kth-missing-positive-number "Kth Missing Positive Number") +                 +[Next >](../minimum-insertions-to-balance-a-parentheses-string "Minimum Insertions to Balance a Parentheses String") + +## [1540. Can Convert String in K Moves (Medium)](https://leetcode.com/problems/can-convert-string-in-k-moves "K 次操作转变字符串") + +

      Given two strings s and t, your goal is to convert s into t in k moves or less.

      + +

      During the ith (1 <= i <= kmove you can:

      + +
        +
      • Choose any index j (1-indexed) from s, such that 1 <= j <= s.length and j has not been chosen in any previous move, and shift the character at that index i times.
      • +
      • Do nothing.
      • +
      + +

      Shifting a character means replacing it by the next letter in the alphabet (wrapping around so that 'z' becomes 'a'). Shifting a character by i means applying the shift operations i times.

      + +

      Remember that any index j can be picked at most once.

      + +

      Return true if it's possible to convert s into t in no more than k moves, otherwise return false.

      + +

       

      +

      Example 1:

      + +
      +Input: s = "input", t = "ouput", k = 9
      +Output: true
      +Explanation: In the 6th move, we shift 'i' 6 times to get 'o'. And in the 7th move we shift 'n' to get 'u'.
      +
      + +

      Example 2:

      + +
      +Input: s = "abc", t = "bcd", k = 10
      +Output: false
      +Explanation: We need to shift each character in s one time to convert it into t. We can shift 'a' to 'b' during the 1st move. However, there is no way to shift the other characters in the remaining moves to obtain t from s.
      +
      + +

      Example 3:

      + +
      +Input: s = "aab", t = "bbb", k = 27
      +Output: true
      +Explanation: In the 1st move, we shift the first 'a' 1 time to get 'b'. In the 27th move, we shift the second 'a' 27 times to get 'b'.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= s.length, t.length <= 10^5
      • +
      • 0 <= k <= 10^9
      • +
      • s, t contain only lowercase English letters.
      • +
      + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
      +Hint 1 +Observe that shifting a letter x times has the same effect of shifting the letter x + 26 times. +
      + +
      +Hint 2 +You need to check whether k is large enough to cover all shifts with the same remainder after modulo 26. +
      diff --git a/problems/count-of-smaller-numbers-after-self/README.md b/problems/count-of-smaller-numbers-after-self/README.md index ceae78a02..57edfdf13 100644 --- a/problems/count-of-smaller-numbers-after-self/README.md +++ b/problems/count-of-smaller-numbers-after-self/README.md @@ -13,18 +13,27 @@

      You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].

      -

      Example:

      +

       

      +

      Example 1:

      -Input: [5,2,6,1]
      -Output: [2,1,1,0] 
      -Explanation:
      +Input: nums = [5,2,6,1]
      +Output: [2,1,1,0]
      +Explanation:
       To the right of 5 there are 2 smaller elements (2 and 1).
       To the right of 2 there is only 1 smaller element (1).
       To the right of 6 there is 1 smaller element (1).
       To the right of 1 there is 0 smaller element.
       
      +

       

      +

      Constraints:

      + +
        +
      • 0 <= nums.length <= 10^5
      • +
      • -10^4 <= nums[i] <= 10^4
      • +
      + ### Related Topics [[Sort](../../tag/sort/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] diff --git a/problems/find-kth-bit-in-nth-binary-string/README.md b/problems/find-kth-bit-in-nth-binary-string/README.md new file mode 100644 index 000000000..4b2c310c8 --- /dev/null +++ b/problems/find-kth-bit-in-nth-binary-string/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../make-the-string-great "Make The String Great") +                 +[Next >](../maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "Maximum Number of Non-Overlapping Subarrays With Sum Equals Target") + +## [1545. Find Kth Bit in Nth Binary String (Medium)](https://leetcode.com/problems/find-kth-bit-in-nth-binary-string "找出第 N 个二进制字符串中的第 K 位") + +

      Given two positive integers n and k, the binary string  Sn is formed as follows:

      + +
        +
      • S1 = "0"
      • +
      • Si = Si-1 + "1" + reverse(invert(Si-1)) for i > 1
      • +
      + +

      Where + denotes the concatenation operation, reverse(x) returns the reversed string x, and invert(x) inverts all the bits in x (0 changes to 1 and 1 changes to 0).

      + +

      For example, the first 4 strings in the above sequence are:

      + +
        +
      • S= "0"
      • +
      • S= "011"
      • +
      • S= "0111001"
      • +
      • S4 = "011100110110001"
      • +
      + +

      Return the kth bit in Sn. It is guaranteed that k is valid for the given n.

      + +

       

      +

      Example 1:

      + +
      +Input: n = 3, k = 1
      +Output: "0"
      +Explanation: S3 is "0111001". The first bit is "0".
      +
      + +

      Example 2:

      + +
      +Input: n = 4, k = 11
      +Output: "1"
      +Explanation: S4 is "011100110110001". The 11th bit is "1".
      +
      + +

      Example 3:

      + +
      +Input: n = 1, k = 1
      +Output: "0"
      +
      + +

      Example 4:

      + +
      +Input: n = 2, k = 3
      +Output: "1"
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= n <= 20
      • +
      • 1 <= k <= 2n - 1
      • +
      + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
      +Hint 1 +Since n is small, we can simply simulate the process of constructing S1 to Sn. +
      diff --git a/problems/find-longest-awesome-substring/README.md b/problems/find-longest-awesome-substring/README.md new file mode 100644 index 000000000..79d3b034a --- /dev/null +++ b/problems/find-longest-awesome-substring/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../minimum-insertions-to-balance-a-parentheses-string "Minimum Insertions to Balance a Parentheses String") +                 +[Next >](../fix-product-name-format "Fix Product Name Format") + +## [1542. Find Longest Awesome Substring (Hard)](https://leetcode.com/problems/find-longest-awesome-substring "找出最长的超赞子字符串") + +

      Given a string s. An awesome substring is a non-empty substring of s such that we can make any number of swaps in order to make it palindrome.

      + +

      Return the length of the maximum length awesome substring of s.

      + +

       

      +

      Example 1:

      + +
      +Input: s = "3242415"
      +Output: 5
      +Explanation: "24241" is the longest awesome substring, we can form the palindrome "24142" with some swaps.
      +
      + +

      Example 2:

      + +
      +Input: s = "12345678"
      +Output: 1
      +
      + +

      Example 3:

      + +
      +Input: s = "213123"
      +Output: 6
      +Explanation: "213123" is the longest awesome substring, we can form the palindrome "231132" with some swaps.
      +
      + +

      Example 4:

      + +
      +Input: s = "00"
      +Output: 2
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= s.length <= 10^5
      • +
      • s consists only of digits.
      • +
      + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
      +Hint 1 +Given the character counts, under what conditions can a palindrome be formed ? +
      + +
      +Hint 2 +From left to right, use bitwise xor-operation to compute for any prefix the number of times modulo 2 of each digit. (mask ^= (1<<(s[i]-'0')). +
      + +
      +Hint 3 +Expected complexity is O(n*A) where A is the alphabet (10). +
      diff --git a/problems/fix-product-name-format/README.md b/problems/fix-product-name-format/README.md new file mode 100644 index 000000000..cc674b4fb --- /dev/null +++ b/problems/fix-product-name-format/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../find-longest-awesome-substring "Find Longest Awesome Substring") +                 +[Next >](../make-the-string-great "Make The String Great") + +## [1543. Fix Product Name Format (Easy)](https://leetcode.com/problems/fix-product-name-format "") + + diff --git a/problems/fix-product-name-format/mysql_schemas.sql b/problems/fix-product-name-format/mysql_schemas.sql new file mode 100644 index 000000000..cfc6ec934 --- /dev/null +++ b/problems/fix-product-name-format/mysql_schemas.sql @@ -0,0 +1,9 @@ +Create table If Not Exists Sales (sale_id int, product_name varchar(30), sale_date date) +; +Truncate table Sales; +insert into Sales (sale_id, product_name, sale_date) values ('1', 'LCPHONE', '2000-01-16'); +insert into Sales (sale_id, product_name, sale_date) values ('2', 'LCPhone', '2000-01-17'); +insert into Sales (sale_id, product_name, sale_date) values ('3', 'LcPhOnE', '2000-02-18'); +insert into Sales (sale_id, product_name, sale_date) values ('4', 'LCKeyCHAiN', '2000-02-19'); +insert into Sales (sale_id, product_name, sale_date) values ('5', 'LCKeyChain', '2000-02-28'); +insert into Sales (sale_id, product_name, sale_date) values ('6', 'Matryoshka', '2000-03-31'); diff --git a/problems/get-the-maximum-score/README.md b/problems/get-the-maximum-score/README.md index 58bedfc89..6154f35d4 100644 --- a/problems/get-the-maximum-score/README.md +++ b/problems/get-the-maximum-score/README.md @@ -7,7 +7,7 @@ [< Previous](../minimum-swaps-to-arrange-a-binary-grid "Minimum Swaps to Arrange a Binary Grid")                  -Next > +[Next >](../guess-the-majority-in-a-hidden-array "Guess the Majority in a Hidden Array") ## [1537. Get the Maximum Score (Hard)](https://leetcode.com/problems/get-the-maximum-score "最大得分") diff --git a/problems/guess-the-majority-in-a-hidden-array/README.md b/problems/guess-the-majority-in-a-hidden-array/README.md new file mode 100644 index 000000000..56b3d7405 --- /dev/null +++ b/problems/guess-the-majority-in-a-hidden-array/README.md @@ -0,0 +1,20 @@ + + + + + + + +[< Previous](../get-the-maximum-score "Get the Maximum Score") +                 +[Next >](../kth-missing-positive-number "Kth Missing Positive Number") + +## [1538. Guess the Majority in a Hidden Array (Medium)](https://leetcode.com/problems/guess-the-majority-in-a-hidden-array "") + + + +### Hints +
      +Hint 1 +If you find that 2 indexes in the array (id1, id2) have the same value (nums [id1] == nums [id2]), you could infer the values of (x, y) based on the results of query (id1, id2, x, y). +
      diff --git a/problems/kth-missing-positive-number/README.md b/problems/kth-missing-positive-number/README.md new file mode 100644 index 000000000..714febe8d --- /dev/null +++ b/problems/kth-missing-positive-number/README.md @@ -0,0 +1,53 @@ + + + + + + + +[< Previous](../guess-the-majority-in-a-hidden-array "Guess the Majority in a Hidden Array") +                 +[Next >](../can-convert-string-in-k-moves "Can Convert String in K Moves") + +## [1539. Kth Missing Positive Number (Easy)](https://leetcode.com/problems/kth-missing-positive-number "第 k 个缺失的正整数") + +

      Given an array arr of positive integers sorted in a strictly increasing order, and an integer k.

      + +

      Find the kth positive integer that is missing from this array.

      + +

       

      +

      Example 1:

      + +
      +Input: arr = [2,3,4,7,11], k = 5
      +Output: 9
      +Explanation: The missing positive integers are [1,5,6,8,9,10,12,13,...]. The 5th missing positive integer is 9.
      +
      + +

      Example 2:

      + +
      +Input: arr = [1,2,3,4], k = 2
      +Output: 6
      +Explanation: The missing positive integers are [5,6,7,...]. The 2nd missing positive integer is 6.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= arr.length <= 1000
      • +
      • 1 <= arr[i] <= 1000
      • +
      • 1 <= k <= 1000
      • +
      • arr[i] < arr[j] for 1 <= i < j <= arr.length
      • +
      + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
      +Hint 1 +Keep track of how many positive numbers are missing as you scan the array. +
      diff --git a/problems/make-the-string-great/README.md b/problems/make-the-string-great/README.md new file mode 100644 index 000000000..42c64ae4e --- /dev/null +++ b/problems/make-the-string-great/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](../fix-product-name-format "Fix Product Name Format") +                 +[Next >](../find-kth-bit-in-nth-binary-string "Find Kth Bit in Nth Binary String") + +## [1544. Make The String Great (Easy)](https://leetcode.com/problems/make-the-string-great "整理字符串") + +

      Given a string s of lower and upper case English letters.

      + +

      A good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where:

      + +
        +
      • 0 <= i <= s.length - 2
      • +
      • s[i] is a lower-case letter and s[i + 1] is the same letter but in upper-case or vice-versa.
      • +
      + +

      To make the string good, you can choose two adjacent characters that make the string bad and remove them. You can keep doing this until the string becomes good.

      + +

      Return the string after making it good. The answer is guaranteed to be unique under the given constraints.

      + +

      Notice that an empty string is also good.

      + +

       

      +

      Example 1:

      + +
      +Input: s = "leEeetcode"
      +Output: "leetcode"
      +Explanation: In the first step, either you choose i = 1 or i = 2, both will result "leEeetcode" to be reduced to "leetcode".
      +
      + +

      Example 2:

      + +
      +Input: s = "abBAcC"
      +Output: ""
      +Explanation: We have many possible scenarios, and all lead to the same answer. For example:
      +"abBAcC" --> "aAcC" --> "cC" --> ""
      +"abBAcC" --> "abBA" --> "aA" --> ""
      +
      + +

      Example 3:

      + +
      +Input: s = "s"
      +Output: "s"
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= s.length <= 100
      • +
      • s contains only lower and upper case English letters.
      • +
      + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
      +Hint 1 +The order you choose 2 characters to remove doesn't matter. +
      + +
      +Hint 2 +Keep applying the mentioned step to s till the length of the string is not changed. +
      diff --git a/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md b/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md new file mode 100644 index 000000000..ee1fefba8 --- /dev/null +++ b/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../find-kth-bit-in-nth-binary-string "Find Kth Bit in Nth Binary String") +                 +[Next >](../minimum-cost-to-cut-a-stick "Minimum Cost to Cut a Stick") + +## [1546. Maximum Number of Non-Overlapping Subarrays With Sum Equals Target (Medium)](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值的最大数目不重叠非空子数组数目") + +

      Given an array nums and an integer target.

      + +

      Return the maximum number of non-empty non-overlapping subarrays such that the sum of values in each subarray is equal to target.

      + +

       

      +

      Example 1:

      + +
      +Input: nums = [1,1,1,1,1], target = 2
      +Output: 2
      +Explanation: There are 2 non-overlapping subarrays [1,1,1,1,1] with sum equals to target(2).
      +
      + +

      Example 2:

      + +
      +Input: nums = [-1,3,5,1,4,2,-9], target = 6
      +Output: 2
      +Explanation: There are 3 subarrays with sum equal to 6.
      +([5,1], [4,2], [3,5,1,4,2,-9]) but only the first 2 are non-overlapping.
      + +

      Example 3:

      + +
      +Input: nums = [-2,6,6,3,5,4,1,2,8], target = 10
      +Output: 3
      +
      + +

      Example 4:

      + +
      +Input: nums = [0,0,0], target = 0
      +Output: 3
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= nums.length <= 10^5
      • +
      • -10^4 <= nums[i] <= 10^4
      • +
      • 0 <= target <= 10^6
      • +
      + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
      +Hint 1 +Keep track of prefix sums to quickly look up what subarray that sums "target" can be formed at each step of scanning the input array. +
      + +
      +Hint 2 +It can be proved that greedily forming valid subarrays as soon as one is found is optimal. +
      diff --git a/problems/merge-intervals/README.md b/problems/merge-intervals/README.md index b1da7f102..666523b0f 100644 --- a/problems/merge-intervals/README.md +++ b/problems/merge-intervals/README.md @@ -16,7 +16,7 @@

      Example 1:

      -Input: [[1,3],[2,6],[8,10],[15,18]]
      +Input: intervals = [[1,3],[2,6],[8,10],[15,18]]
       Output: [[1,6],[8,10],[15,18]]
       Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6].
       
      @@ -24,12 +24,19 @@

      Example 2:

      -Input: [[1,4],[4,5]]
      +Input: intervals = [[1,4],[4,5]]
       Output: [[1,5]]
       Explanation: Intervals [1,4] and [4,5] are considered overlapping.

      NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

      +

       

      +

      Constraints:

      + +
        +
      • intervals[i][0] <= intervals[i][1]
      • +
      + ### Related Topics [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] diff --git a/problems/minimum-cost-to-cut-a-stick/README.md b/problems/minimum-cost-to-cut-a-stick/README.md new file mode 100644 index 000000000..87c37b87c --- /dev/null +++ b/problems/minimum-cost-to-cut-a-stick/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "Maximum Number of Non-Overlapping Subarrays With Sum Equals Target") +                 +Next > + +## [1547. Minimum Cost to Cut a Stick (Hard)](https://leetcode.com/problems/minimum-cost-to-cut-a-stick "切棍子的最小成本") + +

      Given a wooden stick of length n units. The stick is labelled from 0 to n. For example, a stick of length 6 is labelled as follows:

      + +

      Given an integer array cuts where cuts[i] denotes a position you should perform a cut at.

      + +

      You should perform the cuts in order, you can change the order of the cuts as you wish.

      + +

      The cost of one cut is the length of the stick to be cut, the total cost is the sum of costs of all cuts. When you cut a stick, it will be split into two smaller sticks (i.e. the sum of their lengths is the length of the stick before the cut). Please refer to the first example for a better explanation.

      + +

      Return the minimum total cost of the cuts.

      + +

       

      +

      Example 1:

      + +
      +Input: n = 7, cuts = [1,3,4,5]
      +Output: 16
      +Explanation: Using cuts order = [1, 3, 4, 5] as in the input leads to the following scenario:
      +
      +The first cut is done to a rod of length 7 so the cost is 7. The second cut is done to a rod of length 6 (i.e. the second part of the first cut), the third is done to a rod of length 4 and the last cut is to a rod of length 3. The total cost is 7 + 6 + 4 + 3 = 20.
      +Rearranging the cuts to be [3, 5, 1, 4] for example will lead to a scenario with total cost = 16 (as shown in the example photo 7 + 4 + 3 + 2 = 16).
      + +

      Example 2:

      + +
      +Input: n = 9, cuts = [5,6,1,4,2]
      +Output: 22
      +Explanation: If you try the given cuts ordering the cost will be 25.
      +There are much ordering with total cost <= 25, for example, the order [4, 6, 5, 2, 1] has total cost = 22 which is the minimum possible.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 2 <= n <= 10^6
      • +
      • 1 <= cuts.length <= min(n - 1, 100)
      • +
      • 1 <= cuts[i] <= n - 1
      • +
      • All the integers in cuts array are distinct.
      • +
      + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
      +Hint 1 +Build a dp array where dp[i][j] is the minimum cost to achieve all the cuts between i and j. +
      + +
      +Hint 2 +When you try to get the minimum cost between i and j, try all possible cuts k between them, dp[i][j] = min(dp[i][k] + dp[k][j]) + (j - i) for all possible cuts k between them. +
      diff --git a/problems/minimum-insertions-to-balance-a-parentheses-string/README.md b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md new file mode 100644 index 000000000..369fd2f3a --- /dev/null +++ b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md @@ -0,0 +1,89 @@ + + + + + + + +[< Previous](../can-convert-string-in-k-moves "Can Convert String in K Moves") +                 +[Next >](../find-longest-awesome-substring "Find Longest Awesome Substring") + +## [1541. Minimum Insertions to Balance a Parentheses String (Medium)](https://leetcode.com/problems/minimum-insertions-to-balance-a-parentheses-string "平衡括号字符串的最少插入次数") + +

      Given a parentheses string s containing only the characters '(' and ')'. A parentheses string is balanced if:

      + +
        +
      • Any left parenthesis '(' must have a corresponding two consecutive right parenthesis '))'.
      • +
      • Left parenthesis '(' must go before the corresponding two consecutive right parenthesis '))'.
      • +
      + +

      For example, "())", "())(())))" and "(())())))" are balanced, ")()", "()))" and "(()))" are not balanced.

      + +

      You can insert the characters '(' and ')' at any position of the string to balance it if needed.

      + +

      Return the minimum number of insertions needed to make s balanced.

      + +

       

      +

      Example 1:

      + +
      +Input: s = "(()))"
      +Output: 1
      +Explanation: The second '(' has two matching '))', but the first '(' has only ')' matching. We need to to add one more ')' at the end of the string to be "(())))" which is balanced.
      +
      + +

      Example 2:

      + +
      +Input: s = "())"
      +Output: 0
      +Explanation: The string is already balanced.
      +
      + +

      Example 3:

      + +
      +Input: s = "))())("
      +Output: 3
      +Explanation: Add '(' to match the first '))', Add '))' to match the last '('.
      +
      + +

      Example 4:

      + +
      +Input: s = "(((((("
      +Output: 12
      +Explanation: Add 12 ')' to balance the string.
      +
      + +

      Example 5:

      + +
      +Input: s = ")))))))"
      +Output: 5
      +Explanation: Add 4 '(' at the beginning of the string and one ')' at the end. The string becomes "(((())))))))".
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= s.length <= 10^5
      • +
      • s consists of '(' and ')' only.
      • +
      + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
      +Hint 1 +Use a stack to keep opening brackets. If you face single closing ')' add 1 to the answer and consider it as '))'. +
      + +
      +Hint 2 +If you have '))' with empty stack, add 1 to the answer, If after finishing you have x opening remaining in the stack, add 2x to the answer. +
      diff --git a/problems/predict-the-winner/README.md b/problems/predict-the-winner/README.md index af29a033d..6d627cf90 100644 --- a/problems/predict-the-winner/README.md +++ b/problems/predict-the-winner/README.md @@ -11,33 +11,40 @@ ## [486. Predict the Winner (Medium)](https://leetcode.com/problems/predict-the-winner "预测赢家") -

      Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a player picks a number, that number will not be available for the next player. This continues until all the scores have been chosen. The player with the maximum score wins.

      +

      Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a player picks a number, that number will not be available for the next player. This continues until all the scores have been chosen. The player with the maximum score wins.

      -

      Given an array of scores, predict whether player 1 is the winner. You can assume each player plays to maximize his score.

      +

      Given an array of scores, predict whether player 1 is the winner. You can assume each player plays to maximize his score.

      + +

      Example 1:

      -

      Example 1:

       Input: [1, 5, 2]
       Output: False
      -Explanation: Initially, player 1 can choose between 1 and 2. 
      If he chooses 2 (or 1), then player 2 can choose from 1 (or 2) and 5. If player 2 chooses 5, then player 1 will be left with 1 (or 2).
      So, final score of player 1 is 1 + 2 = 3, and player 2 is 5.
      Hence, player 1 will never be the winner and you need to return False. +Explanation: Initially, player 1 can choose between 1 and 2. +If he chooses 2 (or 1), then player 2 can choose from 1 (or 2) and 5. If player 2 chooses 5, then player 1 will be left with 1 (or 2). +So, final score of player 1 is 1 + 2 = 3, and player 2 is 5. +Hence, player 1 will never be the winner and you need to return False.
      -

      -

      Example 2:
      +

       

      + +

      Example 2:

      +
       Input: [1, 5, 233, 7]
       Output: True
      -Explanation: Player 1 first chooses 1. Then player 2 have to choose between 5 and 7. No matter which number player 2 choose, player 1 can choose 233.
      Finally, player 1 has more score (234) than player 2 (12), so you need to return True representing player1 can win. +Explanation: Player 1 first chooses 1. Then player 2 have to choose between 5 and 7. No matter which number player 2 choose, player 1 can choose 233. +Finally, player 1 has more score (234) than player 2 (12), so you need to return True representing player1 can win.
      -

      - -

      Note:
      -

        -
      1. 1 <= length of the array <= 20.
      2. -
      3. Any scores in the given array are non-negative integers and will not exceed 10,000,000.
      4. -
      5. If the scores of both players are equal, then player 1 is still the winner.
      6. -
      -

      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= length of the array <= 20.
      • +
      • Any scores in the given array are non-negative integers and will not exceed 10,000,000.
      • +
      • If the scores of both players are equal, then player 1 is still the winner.
      • +
      ### Related Topics [[Minimax](../../tag/minimax/README.md)] diff --git a/tag/array/README.md b/tag/array/README.md index 1b05e93e6..06f8ab50d 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 1535 | [找出数组游戏的赢家](../../problems/find-the-winner-of-an-array-game) | [[数组](../array/README.md)] | Medium | | 1534 | [统计好三元组](../../problems/count-good-triplets) | [[数组](../array/README.md)] | Easy | | 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 03b7ad6b6..f4387cb94 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Hard | | 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1486 | [数组异或操作](../../problems/xor-operation-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index be4e0e823..7ebc2dcd8 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1547 | [切棍子的最小成本](../../problems/minimum-cost-to-cut-a-stick) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1546 | [和为目标值的最大数目不重叠非空子数组数目](../../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1537 | [最大得分](../../problems/get-the-maximum-score) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1510 | [石子游戏 IV](../../problems/stone-game-iv) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index c25d8c18d..aeb3e12ef 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心算法](../greedy/README.md)] | Medium | | 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心算法](../greedy/README.md)] | Medium | | 1518 | [换酒问题](../../problems/water-bottles) | [[贪心算法](../greedy/README.md)] | Easy | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 0971aa423..2a57aab92 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/stack/README.md b/tag/stack/README.md index bbfe948a8..a467c5dcc 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | +| 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | | 1441 | [用栈操作构建数组](../../problems/build-an-array-with-stack-operations) | [[栈](../stack/README.md)] | Easy | | 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | | 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index 6292c54a7..131511648 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1545 | [找出第 N 个二进制字符串中的第 K 位](../../problems/find-kth-bit-in-nth-binary-string) | [[字符串](../string/README.md)] | Medium | +| 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | +| 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Hard | +| 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[字符串](../string/README.md)] | Medium | | 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | From b7fdc4baa28cdef82a8ce22a638c02321bfdfae6 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 17 Aug 2020 12:57:19 +0800 Subject: [PATCH 094/145] A: new --- README.md | 16 ++-- problems/can-i-win/README.md | 49 +++++++---- problems/combinations/README.md | 22 ++++- problems/course-schedule-ii/README.md | 2 +- problems/customer-order-frequency/README.md | 2 +- .../README.md | 68 +++++++++++++++ problems/distribute-candies/README.md | 68 +++++++++++---- problems/find-duplicate-subtrees/README.md | 43 ++++++---- .../find-users-with-valid-e-mails/README.md | 2 +- problems/fix-product-name-format/README.md | 2 +- problems/friend-circles/README.md | 39 +++++---- problems/implement-trie-prefix-tree/README.md | 2 +- problems/letter-case-permutation/README.md | 27 +++++- problems/letter-tile-possibilities/README.md | 29 ++++--- .../README.md | 2 +- .../longest-arithmetic-subsequence/README.md | 55 ++++++++++++ .../README.md | 66 ++++++++++++++ .../README.md | 2 +- problems/merge-k-sorted-lists/README.md | 48 +++++++++-- .../minimum-cost-to-cut-a-stick/README.md | 2 +- .../README.md | 83 ++++++++++++++++++ .../README.md | 4 +- .../README.md | 82 ++++++++++++++++++ .../README.md | 57 ++++++++++++ .../move-sub-tree-of-n-ary-tree/README.md | 2 +- .../README.md | 10 +++ problems/open-the-lock/README.md | 86 ++++++++++--------- problems/palindrome-partitioning-ii/README.md | 31 ++++++- problems/pancake-sorting/README.md | 43 ++++++---- problems/prefix-and-suffix-search/README.md | 2 +- problems/profitable-schemes/README.md | 12 +-- problems/random-pick-with-weight/README.md | 6 +- .../README.md | 2 +- problems/restore-ip-addresses/README.md | 38 +++++--- .../search-in-rotated-sorted-array/README.md | 37 ++++---- .../README.md | 2 +- problems/stone-game/README.md | 12 ++- .../README.md | 14 +++ .../mysql_schemas.sql | 25 ++++++ .../README.md | 29 +++++++ problems/three-consecutive-odds/README.md | 47 ++++++++++ problems/valid-palindrome-iii/README.md | 2 +- problems/validate-ip-address/README.md | 32 +++++-- problems/word-search-ii/README.md | 2 +- readme/1-300.md | 4 +- readme/601-900.md | 2 +- readme/901-1200.md | 2 +- tag/array/README.md | 4 +- tag/backtracking/README.md | 2 +- tag/binary-search/README.md | 1 + tag/design/README.md | 2 +- tag/divide-and-conquer/README.md | 2 +- tag/dynamic-programming/README.md | 4 +- tag/graph/README.md | 1 + tag/greedy/README.md | 4 +- tag/heap/README.md | 2 +- tag/linked-list/README.md | 2 +- tag/math/README.md | 3 +- tag/tree/README.md | 2 +- tag/trie/README.md | 2 +- 60 files changed, 998 insertions(+), 247 deletions(-) create mode 100644 problems/design-add-and-search-words-data-structure/README.md create mode 100644 problems/longest-arithmetic-subsequence/README.md create mode 100644 problems/magnetic-force-between-two-balls/README.md create mode 100644 problems/minimum-cost-to-move-chips-to-the-same-position/README.md create mode 100644 problems/minimum-number-of-days-to-eat-n-oranges/README.md create mode 100644 problems/minimum-operations-to-make-array-equal/README.md create mode 100644 problems/the-most-recent-orders-for-each-product/README.md create mode 100644 problems/the-most-recent-orders-for-each-product/mysql_schemas.sql create mode 100644 problems/the-most-similar-path-in-a-graph/README.md create mode 100644 problems/three-consecutive-odds/README.md diff --git a/README.md b/README.md index d0624c236..f536dfd67 100644 --- a/README.md +++ b/README.md @@ -70,11 +70,17 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1553 | [Minimum Number of Days to Eat N Oranges](https://leetcode.com/problems/minimum-number-of-days-to-eat-n-oranges "吃掉 N 个橘子的最少天数") | [Go](problems/minimum-number-of-days-to-eat-n-oranges) | Hard | +| 1552 | [Magnetic Force Between Two Balls](https://leetcode.com/problems/magnetic-force-between-two-balls "两球之间的磁力") | [Go](problems/magnetic-force-between-two-balls) | Medium | +| 1551 | [Minimum Operations to Make Array Equal](https://leetcode.com/problems/minimum-operations-to-make-array-equal "使数组中所有元素相等的最小操作数") | [Go](problems/minimum-operations-to-make-array-equal) | Medium | +| 1550 | [Three Consecutive Odds](https://leetcode.com/problems/three-consecutive-odds "存在连续三个奇数的数组") | [Go](problems/three-consecutive-odds) | Easy | +| 1549 | [The Most Recent Orders for Each Product](https://leetcode.com/problems/the-most-recent-orders-for-each-product) 🔒 | [MySQL](problems/the-most-recent-orders-for-each-product) | Medium | +| 1548 | [The Most Similar Path in a Graph](https://leetcode.com/problems/the-most-similar-path-in-a-graph) 🔒 | [Go](problems/the-most-similar-path-in-a-graph) | Hard | | 1547 | [Minimum Cost to Cut a Stick](https://leetcode.com/problems/minimum-cost-to-cut-a-stick "切棍子的最小成本") | [Go](problems/minimum-cost-to-cut-a-stick) | Hard | | 1546 | [Maximum Number of Non-Overlapping Subarrays With Sum Equals Target](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值的最大数目不重叠非空子数组数目") | [Go](problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | Medium | | 1545 | [Find Kth Bit in Nth Binary String](https://leetcode.com/problems/find-kth-bit-in-nth-binary-string "找出第 N 个二进制字符串中的第 K 位") | [Go](problems/find-kth-bit-in-nth-binary-string) | Medium | | 1544 | [Make The String Great](https://leetcode.com/problems/make-the-string-great "整理字符串") | [Go](problems/make-the-string-great) | Easy | -| 1543 | [Fix Product Name Format](https://leetcode.com/problems/fix-product-name-format) 🔒 | [MySQL](problems/fix-product-name-format) | Easy | +| 1543 | [Fix Product Name Format](https://leetcode.com/problems/fix-product-name-format "产品名称格式修复") 🔒 | [MySQL](problems/fix-product-name-format) | Easy | | 1542 | [Find Longest Awesome Substring](https://leetcode.com/problems/find-longest-awesome-substring "找出最长的超赞子字符串") | [Go](problems/find-longest-awesome-substring) | Hard | | 1541 | [Minimum Insertions to Balance a Parentheses String](https://leetcode.com/problems/minimum-insertions-to-balance-a-parentheses-string "平衡括号字符串的最少插入次数") | [Go](problems/minimum-insertions-to-balance-a-parentheses-string) | Medium | | 1540 | [Can Convert String in K Moves](https://leetcode.com/problems/can-convert-string-in-k-moves "K 次操作转变字符串") | [Go](problems/can-convert-string-in-k-moves) | Medium | @@ -100,13 +106,13 @@ LeetCode Problems' Solutions | 1520 | [Maximum Number of Non-Overlapping Substrings](https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings "最多的不重叠子字符串") | [Go](problems/maximum-number-of-non-overlapping-substrings) | Hard | | 1519 | [Number of Nodes in the Sub-Tree With the Same Label](https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label "子树中标签相同的节点数") | [Go](problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | Medium | | 1518 | [Water Bottles](https://leetcode.com/problems/water-bottles "换酒问题") | [Go](problems/water-bottles) | Easy | -| 1517 | [Find Users With Valid E-Mails](https://leetcode.com/problems/find-users-with-valid-e-mails) 🔒 | [MySQL](problems/find-users-with-valid-e-mails) | Easy | -| 1516 | [Move Sub-Tree of N-Ary Tree](https://leetcode.com/problems/move-sub-tree-of-n-ary-tree) 🔒 | [Go](problems/move-sub-tree-of-n-ary-tree) | Hard | +| 1517 | [Find Users With Valid E-Mails](https://leetcode.com/problems/find-users-with-valid-e-mails "查找拥有有效邮箱的用户") 🔒 | [MySQL](problems/find-users-with-valid-e-mails) | Easy | +| 1516 | [Move Sub-Tree of N-Ary Tree](https://leetcode.com/problems/move-sub-tree-of-n-ary-tree "移动 N 叉树的子树") 🔒 | [Go](problems/move-sub-tree-of-n-ary-tree) | Hard | | 1515 | [Best Position for a Service Centre](https://leetcode.com/problems/best-position-for-a-service-centre "服务中心的最佳位置") | [Go](problems/best-position-for-a-service-centre) | Hard | | 1514 | [Path with Maximum Probability](https://leetcode.com/problems/path-with-maximum-probability "概率最大的路径") | [Go](problems/path-with-maximum-probability) | Medium | | 1513 | [Number of Substrings With Only 1s](https://leetcode.com/problems/number-of-substrings-with-only-1s "仅含 1 的子串数") | [Go](problems/number-of-substrings-with-only-1s) | Medium | | 1512 | [Number of Good Pairs](https://leetcode.com/problems/number-of-good-pairs "好数对的数目") | [Go](problems/number-of-good-pairs) | Easy | -| 1511 | [Customer Order Frequency](https://leetcode.com/problems/customer-order-frequency) 🔒 | [MySQL](problems/customer-order-frequency) | Easy | +| 1511 | [Customer Order Frequency](https://leetcode.com/problems/customer-order-frequency "消费者下单频率") 🔒 | [MySQL](problems/customer-order-frequency) | Easy | | 1510 | [Stone Game IV](https://leetcode.com/problems/stone-game-iv "石子游戏 IV") | [Go](problems/stone-game-iv) | Hard | | 1509 | [Minimum Difference Between Largest and Smallest Value in Three Moves](https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves "三次操作后最大值与最小值的最小差") | [Go](problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | Medium | | 1508 | [Range Sum of Sorted Subarray Sums](https://leetcode.com/problems/range-sum-of-sorted-subarray-sums "子数组和排序后的区间和") | [Go](problems/range-sum-of-sorted-subarray-sums) | Medium | @@ -400,7 +406,7 @@ LeetCode Problems' Solutions | 1220 | [Count Vowels Permutation](https://leetcode.com/problems/count-vowels-permutation "统计元音字母序列的数目") | [Go](problems/count-vowels-permutation) | Hard | | 1219 | [Path with Maximum Gold](https://leetcode.com/problems/path-with-maximum-gold "黄金矿工") | [Go](problems/path-with-maximum-gold) | Medium | | 1218 | [Longest Arithmetic Subsequence of Given Difference](https://leetcode.com/problems/longest-arithmetic-subsequence-of-given-difference "最长定差子序列") | [Go](problems/longest-arithmetic-subsequence-of-given-difference) | Medium | -| 1217 | [Play with Chips](https://leetcode.com/problems/play-with-chips "玩筹码") | [Go](problems/play-with-chips) | Easy | +| 1217 | [Minimum Cost to Move Chips to The Same Position](https://leetcode.com/problems/minimum-cost-to-move-chips-to-the-same-position "玩筹码") | [Go](problems/minimum-cost-to-move-chips-to-the-same-position) | Easy | | 1216 | [Valid Palindrome III](https://leetcode.com/problems/valid-palindrome-iii "验证回文字符串 III") 🔒 | [Go](problems/valid-palindrome-iii) | Hard | | 1215 | [Stepping Numbers](https://leetcode.com/problems/stepping-numbers "步进数") 🔒 | [Go](problems/stepping-numbers) | Medium | | 1214 | [Two Sum BSTs](https://leetcode.com/problems/two-sum-bsts "查找两棵二叉搜索树之和") 🔒 | [Go](problems/two-sum-bsts) | Medium | diff --git a/problems/can-i-win/README.md b/problems/can-i-win/README.md index 8a62abcae..514ebd380 100644 --- a/problems/can-i-win/README.md +++ b/problems/can-i-win/README.md @@ -11,34 +11,49 @@ ## [464. Can I Win (Medium)](https://leetcode.com/problems/can-i-win "我能赢吗") -

      In the "100 game," two players take turns adding, to a running total, any integer from 1..10. The player who first causes the running total to reach or exceed 100 wins.

      +

      In the "100 game" two players take turns adding, to a running total, any integer from 1 to 10. The player who first causes the running total to reach or exceed 100 wins.

      -

      What if we change the game so that players cannot re-use integers?

      +

      What if we change the game so that players cannot re-use integers?

      -

      For example, two players might take turns drawing from a common pool of numbers of 1..15 without replacement until they reach a total >= 100.

      +

      For example, two players might take turns drawing from a common pool of numbers from 1 to 15 without replacement until they reach a total >= 100.

      -

      Given an integer maxChoosableInteger and another integer desiredTotal, determine if the first player to move can force a win, assuming both players play optimally.

      +

      Given two integers maxChoosableInteger and desiredTotal, return true if the first player to move can force a win, otherwise return false. Assume both players play optimally.

      -

      You can always assume that maxChoosableInteger will not be larger than 20 and desiredTotal will not be larger than 300. -

      +

       

      +

      Example 1:

      -

      Example

      -Input:
      -maxChoosableInteger = 10
      -desiredTotal = 11
      -
      -Output:
      -false
      -
      -Explanation:
      +Input: maxChoosableInteger = 10, desiredTotal = 11
      +Output: false
      +Explanation:
       No matter which integer the first player choose, the first player will lose.
       The first player can choose an integer from 1 up to 10.
       If the first player choose 1, the second player can only choose integers from 2 up to 10.
      -The second player will win by choosing 10 and get a total = 11, which is >= desiredTotal.
      +The second player will win by choosing 10 and get a total = 11, which is >= desiredTotal.
       Same with other integers chosen by the first player, the second player will always win.
       
      -

      + +

      Example 2:

      + +
      +Input: maxChoosableInteger = 10, desiredTotal = 0
      +Output: true
      +
      + +

      Example 3:

      + +
      +Input: maxChoosableInteger = 10, desiredTotal = 1
      +Output: true
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= maxChoosableInteger <= 20
      • +
      • 0 <= desiredTotal <= 300
      • +
      ### Related Topics [[Minimax](../../tag/minimax/README.md)] diff --git a/problems/combinations/README.md b/problems/combinations/README.md index 196e8c701..a3aaa438f 100644 --- a/problems/combinations/README.md +++ b/problems/combinations/README.md @@ -13,10 +13,13 @@

      Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.

      -

      Example:

      +

      You may return the answer in any order.

      + +

       

      +

      Example 1:

      -Input: n = 4, k = 2
      +Input: n = 4, k = 2
       Output:
       [
         [2,4],
      @@ -28,6 +31,21 @@
       ]
       
      +

      Example 2:

      + +
      +Input: n = 1, k = 1
      +Output: [[1]]
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= n <= 20
      • +
      • 1 <= k <= n
      • +
      + ### Related Topics [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/course-schedule-ii/README.md b/problems/course-schedule-ii/README.md index fa278ad52..fa7145a47 100644 --- a/problems/course-schedule-ii/README.md +++ b/problems/course-schedule-ii/README.md @@ -7,7 +7,7 @@ [< Previous](../minimum-size-subarray-sum "Minimum Size Subarray Sum")                  -[Next >](../add-and-search-word-data-structure-design "Add and Search Word - Data structure design") +[Next >](../design-add-and-search-words-data-structure "Design Add and Search Words Data Structure") ## [210. Course Schedule II (Medium)](https://leetcode.com/problems/course-schedule-ii "课程表 II") diff --git a/problems/customer-order-frequency/README.md b/problems/customer-order-frequency/README.md index 987168901..e4487f01e 100644 --- a/problems/customer-order-frequency/README.md +++ b/problems/customer-order-frequency/README.md @@ -9,6 +9,6 @@                  [Next >](../number-of-good-pairs "Number of Good Pairs") -## [1511. Customer Order Frequency (Easy)](https://leetcode.com/problems/customer-order-frequency "") +## [1511. Customer Order Frequency (Easy)](https://leetcode.com/problems/customer-order-frequency "消费者下单频率") diff --git a/problems/design-add-and-search-words-data-structure/README.md b/problems/design-add-and-search-words-data-structure/README.md new file mode 100644 index 000000000..999e4a8f8 --- /dev/null +++ b/problems/design-add-and-search-words-data-structure/README.md @@ -0,0 +1,68 @@ + + + + + + + +[< Previous](../course-schedule-ii "Course Schedule II") +                 +[Next >](../word-search-ii "Word Search II") + +## [211. Design Add and Search Words Data Structure (Medium)](https://leetcode.com/problems/design-add-and-search-words-data-structure "添加与搜索单词 - 数据结构设计") + +

      You should design a data structure that supports adding new words and finding if a string matches any previously added string.

      + +

      Implement the WordDictionary class:

      + +
        +
      • WordDictionary() Initializes the object.
      • +
      • void addWord(word) adds word to the data structure, it can be matched later.
      • +
      • bool search(word) returns true if there is any string in the data structure that matches word or false otherwise. word may contain dots '.' where dots can be matched with any letter.
      • +
      + +

       

      +

      Example:

      + +
      +Input
      +["WordDictionary","addWord","addWord","addWord","search","search","search","search"]
      +[[],["bad"],["dad"],["mad"],["pad"],["bad"],[".ad"],["b.."]]
      +Output
      +[null,null,null,null,false,true,true,true]
      +
      +Explanation
      +WordDictionary wordDictionary = new WordDictionary();
      +wordDictionary.addWord("bad");
      +wordDictionary.addWord("dad");
      +wordDictionary.addWord("mad");
      +wordDictionary.search("pad"); // return False
      +wordDictionary.search("bad"); // return True
      +wordDictionary.search(".ad"); // return True
      +wordDictionary.search("b.."); // return True
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= word.length <= 500
      • +
      • word in addWord consists lower-case English letters.
      • +
      • word in search consist of  '.' or lower-case English letters.
      • +
      • At most 50000 calls will be made to addWord and search .
      • +
      + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + +### Similar Questions + 1. [Implement Trie (Prefix Tree)](../implement-trie-prefix-tree) (Medium) + 1. [Prefix and Suffix Search](../prefix-and-suffix-search) (Hard) + +### Hints +
      +Hint 1 +You should be familiar with how a Trie works. If not, please work on this problem: Implement Trie (Prefix Tree) first. +
      diff --git a/problems/distribute-candies/README.md b/problems/distribute-candies/README.md index 38dff1ca2..9cfd5e983 100644 --- a/problems/distribute-candies/README.md +++ b/problems/distribute-candies/README.md @@ -11,34 +11,66 @@ ## [575. Distribute Candies (Easy)](https://leetcode.com/problems/distribute-candies "分糖果") -Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You need to distribute these candies equally in number to brother and sister. Return the maximum number of kinds of candies the sister could gain. +

      You have n candies of different types, the ith candy is of type candies[i].

      + +

      You want to distribute the candies equally between a sister and a brother so that each of them gets n / 2 candies (n is even). The sister loves to collect different types of candies, so you want to give her the maximum number of different types of candies.

      + +

      Return the maximum number of different types of candies you can give to the sister.

      + +
        +
      + +

       

      +

      Example 1:

      -

      Example 1:

      -Input: candies = [1,1,2,2,3,3]
      -Output: 3
      -Explanation:
      +Input: candies = [1,1,2,2,3,3]
      +Output: 3
      +Explanation:
       There are three different kinds of candies (1, 2 and 3), and two candies for each kind.
       Optimal distribution: The sister has candies [1,2,3] and the brother has candies [1,2,3], too. 
       The sister has three different kinds of candies. 
       
      -

      -

      Example 2:
      +

      Example 2:

      +
      -Input: candies = [1,1,2,3]
      -Output: 2
      -Explanation: For example, the sister has candies [2,3] and the brother has candies [1,1]. 
      -The sister has two different kinds of candies, the brother has only one kind of candies. 
      +Input: candies = [1,1,2,3]
      +Output: 2
      +Explanation: For example, the sister has candies [2,3] and the brother has candies [1,1]. 
      +The sister has two different kinds of candies, the brother has only one kind of candies.
       
      -

      -

      Note: -

        -
      1. The length of the given array is in range [2, 10,000], and will be even.
      2. -
      3. The number in given array is in range [-100,000, 100,000].
      4. -
          -

          +

          Example 3:

          + +
          +Input: candies = [1,1]
          +Output: 1
          +
          + +

          Example 4:

          + +
          +Input: candies = [1,11]
          +Output: 1
          +
          + +

          Example 5:

          + +
          +Input: candies = [2,2]
          +Output: 1
          +
          + +

           

          +

          Constraints:

          + +
            +
          • n == candies.length
          • +
          • 2 <= n <= 10^4
          • +
          • n is even.
          • +
          • -10^5 <= candies[i] <= 10^5
          • +
          ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/find-duplicate-subtrees/README.md b/problems/find-duplicate-subtrees/README.md index 649d1408c..05d1c580c 100644 --- a/problems/find-duplicate-subtrees/README.md +++ b/problems/find-duplicate-subtrees/README.md @@ -11,36 +11,41 @@ ## [652. Find Duplicate Subtrees (Medium)](https://leetcode.com/problems/find-duplicate-subtrees "寻找重复的子树") -

          Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any one of them.

          +

          Given the root of a binary tree, return all duplicate subtrees.

          -

          Two trees are duplicate if they have the same structure with same node values.

          +

          For each kind of duplicate subtrees, you only need to return the root node of any one of them.

          -

          Example 1:

          +

          Two trees are duplicate if they have the same structure with the same node values.

          +

           

          +

          Example 1:

          +
          -        1
          -       / \
          -      2   3
          -     /   / \
          -    4   2   4
          -       /
          -      4
          +Input: root = [1,2,3,4,null,2,4,null,null,4]
          +Output: [[2,4],[4]]
           
          -

          The following are two duplicate subtrees:

          - +

          Example 2:

          +
          -      2
          -     /
          -    4
          +Input: root = [2,1,1]
          +Output: [[1]]
           
          -

          and

          - +

          Example 3:

          +
          -    4
          +Input: root = [2,2,2,3,null,3,null]
          +Output: [[2,3],[3]]
           
          -Therefore, you need to return above trees' root in the form of a list. + +

           

          +

          Constraints:

          + +
            +
          • The number of the nodes in the tree will be in the range [1, 10^4]
          • +
          • -200 <= Node.val <= 200
          • +
          ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/find-users-with-valid-e-mails/README.md b/problems/find-users-with-valid-e-mails/README.md index ce7862879..40adfeae3 100644 --- a/problems/find-users-with-valid-e-mails/README.md +++ b/problems/find-users-with-valid-e-mails/README.md @@ -9,6 +9,6 @@                  [Next >](../water-bottles "Water Bottles") -## [1517. Find Users With Valid E-Mails (Easy)](https://leetcode.com/problems/find-users-with-valid-e-mails "") +## [1517. Find Users With Valid E-Mails (Easy)](https://leetcode.com/problems/find-users-with-valid-e-mails "查找拥有有效邮箱的用户") diff --git a/problems/fix-product-name-format/README.md b/problems/fix-product-name-format/README.md index cc674b4fb..fe5827009 100644 --- a/problems/fix-product-name-format/README.md +++ b/problems/fix-product-name-format/README.md @@ -9,6 +9,6 @@                  [Next >](../make-the-string-great "Make The String Great") -## [1543. Fix Product Name Format (Easy)](https://leetcode.com/problems/fix-product-name-format "") +## [1543. Fix Product Name Format (Easy)](https://leetcode.com/problems/fix-product-name-format "产品名称格式修复") diff --git a/problems/friend-circles/README.md b/problems/friend-circles/README.md index d8eb27439..dea5595e2 100644 --- a/problems/friend-circles/README.md +++ b/problems/friend-circles/README.md @@ -11,44 +11,45 @@ ## [547. Friend Circles (Medium)](https://leetcode.com/problems/friend-circles "朋友圈") -

          -There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, then A is an indirect friend of C. And we defined a friend circle is a group of students who are direct or indirect friends. -

          +

          There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, then A is an indirect friend of C. And we defined a friend circle is a group of students who are direct or indirect friends.

          -

          -Given a N*N matrix M representing the friend relationship between students in the class. If M[i][j] = 1, then the ith and jth students are direct friends with each other, otherwise not. And you have to output the total number of friend circles among all the students. -

          +

          Given a N*N matrix M representing the friend relationship between students in the class. If M[i][j] = 1, then the ith and jth students are direct friends with each other, otherwise not. And you have to output the total number of friend circles among all the students.

          + +

          Example 1:

          -

          Example 1:

           Input: 
           [[1,1,0],
            [1,1,0],
            [0,0,1]]
           Output: 2
          -Explanation:The 0th and 1st students are direct friends, so they are in a friend circle. 
          The 2nd student himself is in a friend circle. So return 2. +Explanation:The 0th and 1st students are direct friends, so they are in a friend circle. +The 2nd student himself is in a friend circle. So return 2.
          -

          -

          Example 2:
          +

           

          + +

          Example 2:

          +
           Input: 
           [[1,1,0],
            [1,1,1],
            [0,1,1]]
           Output: 1
          -Explanation:The 0th and 1st students are direct friends, the 1st and 2nd students are direct friends, 
          so the 0th and 2nd students are indirect friends. All of them are in the same friend circle, so return 1. +Explanation:The 0th and 1st students are direct friends, the 1st and 2nd students are direct friends, +so the 0th and 2nd students are indirect friends. All of them are in the same friend circle, so return 1. +
          -

          +

           

          +

          Constraints:

          -

          Note:
          -

            -
          1. N is in range [1,200].
          2. -
          3. M[i][i] = 1 for all students.
          4. -
          5. If M[i][j] = 1, then M[j][i] = 1.
          6. -
          -

          +
            +
          • 1 <= N <= 200
          • +
          • M[i][i] == 1
          • +
          • M[i][j] == M[j][i]
          • +
          ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/implement-trie-prefix-tree/README.md b/problems/implement-trie-prefix-tree/README.md index 4435545a4..00bcce42e 100644 --- a/problems/implement-trie-prefix-tree/README.md +++ b/problems/implement-trie-prefix-tree/README.md @@ -38,7 +38,7 @@ trie.search("app"); // returns true [[Trie](../../tag/trie/README.md)] ### Similar Questions - 1. [Add and Search Word - Data structure design](../add-and-search-word-data-structure-design) (Medium) + 1. [Design Add and Search Words Data Structure](../design-add-and-search-words-data-structure) (Medium) 1. [Design Search Autocomplete System](../design-search-autocomplete-system) (Hard) 1. [Replace Words](../replace-words) (Medium) 1. [Implement Magic Dictionary](../implement-magic-dictionary) (Medium) diff --git a/problems/letter-case-permutation/README.md b/problems/letter-case-permutation/README.md index 7df90a000..1fb8f93de 100644 --- a/problems/letter-case-permutation/README.md +++ b/problems/letter-case-permutation/README.md @@ -11,20 +11,39 @@ ## [784. Letter Case Permutation (Medium)](https://leetcode.com/problems/letter-case-permutation "字母大小写全排列") -

          Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string.  Return a list of all possible strings we could create.

          +

          Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string.

          + +

          Return a list of all possible strings we could create. You can return the output  in any order.

          + +

           

          +

          Example 1:

          -Examples:
           Input: S = "a1b2"
          -Output: ["a1b2", "a1B2", "A1b2", "A1B2"]
          +Output: ["a1b2","a1B2","A1b2","A1B2"]
          +
          +

          Example 2:

          + +
           Input: S = "3z4"
          -Output: ["3z4", "3Z4"]
          +Output: ["3z4","3Z4"]
          +
          +

          Example 3:

          + +
           Input: S = "12345"
           Output: ["12345"]
           
          +

          Example 4:

          + +
          +Input: S = "0"
          +Output: ["0"]
          +
          +

           

          Constraints:

          diff --git a/problems/letter-tile-possibilities/README.md b/problems/letter-tile-possibilities/README.md index 2823e0444..f72cd0874 100644 --- a/problems/letter-tile-possibilities/README.md +++ b/problems/letter-tile-possibilities/README.md @@ -11,35 +11,40 @@ ## [1079. Letter Tile Possibilities (Medium)](https://leetcode.com/problems/letter-tile-possibilities "活字印刷") -

          You have a set of tiles, where each tile has one letter tiles[i] printed on it.  Return the number of possible non-empty sequences of letters you can make.

          +

          You have n  tiles, where each tile has one letter tiles[i] printed on it.

          -

           

          +

          Return the number of possible non-empty sequences of letters you can make using the letters printed on those tiles.

          +

           

          Example 1:

          -Input: "AAB"
          -Output: 8
          +Input: tiles = "AAB"
          +Output: 8
           Explanation: The possible sequences are "A", "B", "AA", "AB", "BA", "AAB", "ABA", "BAA".
           
          -

          Example 2:

          -Input: "AAABBC"
          -Output: 188
          +Input: tiles = "AAABBC"
          +Output: 188
           
          -

           

          -
          +

          Example 3:

          -

          Note:

          +
          +Input: tiles = "V"
          +Output: 1
          +
          + +

           

          +

          Constraints:

          -
            +
            • 1 <= tiles.length <= 7
            • tiles consists of uppercase English letters.
            • -
          +
    ### Related Topics [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/longest-arithmetic-subsequence-of-given-difference/README.md b/problems/longest-arithmetic-subsequence-of-given-difference/README.md index b56061b0a..5dd08c02d 100644 --- a/problems/longest-arithmetic-subsequence-of-given-difference/README.md +++ b/problems/longest-arithmetic-subsequence-of-given-difference/README.md @@ -5,7 +5,7 @@ -[< Previous](../play-with-chips "Play with Chips") +[< Previous](../minimum-cost-to-move-chips-to-the-same-position "Minimum Cost to Move Chips to The Same Position")                  [Next >](../path-with-maximum-gold "Path with Maximum Gold") diff --git a/problems/longest-arithmetic-subsequence/README.md b/problems/longest-arithmetic-subsequence/README.md new file mode 100644 index 000000000..7d417a079 --- /dev/null +++ b/problems/longest-arithmetic-subsequence/README.md @@ -0,0 +1,55 @@ + + + + + + + +[< Previous](../maximum-difference-between-node-and-ancestor "Maximum Difference Between Node and Ancestor") +                 +[Next >](../recover-a-tree-from-preorder-traversal "Recover a Tree From Preorder Traversal") + +## [1027. Longest Arithmetic Subsequence (Medium)](https://leetcode.com/problems/longest-arithmetic-subsequence "最长等差数列") + +

    Given an array A of integers, return the length of the longest arithmetic subsequence in A.

    + +

    Recall that a subsequence of A is a list A[i_1], A[i_2], ..., A[i_k] with 0 <= i_1 < i_2 < ... < i_k <= A.length - 1, and that a sequence B is arithmetic if B[i+1] - B[i] are all the same value (for 0 <= i < B.length - 1).

    + +

     

    +

    Example 1:

    + +
    +Input: A = [3,6,9,12]
    +Output: 4
    +Explanation: 
    +The whole array is an arithmetic sequence with steps of length = 3.
    +
    + +

    Example 2:

    + +
    +Input: A = [9,4,7,2,10]
    +Output: 3
    +Explanation: 
    +The longest arithmetic subsequence is [4,7,10].
    +
    + +

    Example 3:

    + +
    +Input: A = [20,1,15,3,10,5,8]
    +Output: 4
    +Explanation: 
    +The longest arithmetic subsequence is [20,15,10,5].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= A.length <= 1000
    • +
    • 0 <= A[i] <= 500
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/magnetic-force-between-two-balls/README.md b/problems/magnetic-force-between-two-balls/README.md new file mode 100644 index 000000000..661e4bb9d --- /dev/null +++ b/problems/magnetic-force-between-two-balls/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../minimum-operations-to-make-array-equal "Minimum Operations to Make Array Equal") +                 +[Next >](../minimum-number-of-days-to-eat-n-oranges "Minimum Number of Days to Eat N Oranges") + +## [1552. Magnetic Force Between Two Balls (Medium)](https://leetcode.com/problems/magnetic-force-between-two-balls "两球之间的磁力") + +

    In universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket. Rick has n empty baskets, the ith basket is at position[i], Morty has m balls and needs to distribute the balls into the baskets such that the minimum magnetic force between any two balls is maximum.

    + +

    Rick stated that magnetic force between two different balls at positions x and y is |x - y|.

    + +

    Given the integer array position and the integer m. Return the required force.

    + +

     

    +

    Example 1:

    + +
    +Input: position = [1,2,3,4,7], m = 3
    +Output: 3
    +Explanation: Distributing the 3 balls into baskets 1, 4 and 7 will make the magnetic force between ball pairs [3, 3, 6]. The minimum magnetic force is 3. We cannot achieve a larger minimum magnetic force than 3.
    +
    + +

    Example 2:

    + +
    +Input: position = [5,4,3,2,1,1000000000], m = 2
    +Output: 999999999
    +Explanation: We can use baskets 1 and 1000000000.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == position.length
    • +
    • 2 <= n <= 10^5
    • +
    • 1 <= position[i] <= 10^9
    • +
    • All integers in position are distinct.
    • +
    • 2 <= m <= position.length
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +If you can place balls such that the answer is x then you can do it for y where y < x. +
    + +
    +Hint 2 +Similarly if you cannot place balls such that the answer is x then you can do it for y where y > x. +
    + +
    +Hint 3 +Binary search on the answer and greedily see if it is possible. +
    diff --git a/problems/maximum-difference-between-node-and-ancestor/README.md b/problems/maximum-difference-between-node-and-ancestor/README.md index 8b2246096..e6468749e 100644 --- a/problems/maximum-difference-between-node-and-ancestor/README.md +++ b/problems/maximum-difference-between-node-and-ancestor/README.md @@ -7,7 +7,7 @@ [< Previous](../divisor-game "Divisor Game")                  -[Next >](../longest-arithmetic-sequence "Longest Arithmetic Sequence") +[Next >](../longest-arithmetic-subsequence "Longest Arithmetic Subsequence") ## [1026. Maximum Difference Between Node and Ancestor (Medium)](https://leetcode.com/problems/maximum-difference-between-node-and-ancestor "节点与其祖先之间的最大差值") diff --git a/problems/merge-k-sorted-lists/README.md b/problems/merge-k-sorted-lists/README.md index 28fc7a4fc..eca2c3623 100644 --- a/problems/merge-k-sorted-lists/README.md +++ b/problems/merge-k-sorted-lists/README.md @@ -9,22 +9,54 @@                  [Next >](../swap-nodes-in-pairs "Swap Nodes in Pairs") -## [23. Merge k Sorted Lists (Hard)](https://leetcode.com/problems/merge-k-sorted-lists "合并K个排序链表") +## [23. Merge k Sorted Lists (Hard)](https://leetcode.com/problems/merge-k-sorted-lists "合并K个升序链表") -

    Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.

    +

    Given an array of linked-lists lists, each linked list is sorted in ascending order.

    -

    Example:

    +

    Merge all the linked-lists into one sort linked-list and return it.

    + +

     

    +

    Example 1:

    -Input:
    +Input: lists = [[1,4,5],[1,3,4],[2,6]]
    +Output: [1,1,2,3,4,4,5,6]
    +Explanation: The linked-lists are:
     [
    -  1->4->5,
    -  1->3->4,
    -  2->6
    +  1->4->5,
    +  1->3->4,
    +  2->6
     ]
    -Output: 1->1->2->3->4->4->5->6
    +merging them into one sorted list:
    +1->1->2->3->4->4->5->6
    +
    + +

    Example 2:

    + +
    +Input: lists = []
    +Output: []
     
    +

    Example 3:

    + +
    +Input: lists = [[]]
    +Output: []
    +
    + +

     

    +

    Constraints:

    + +
      +
    • k == lists.length
    • +
    • 0 <= k <= 10^4
    • +
    • 0 <= lists[i].length <= 500
    • +
    • -10^4 <= lists[i][j] <= 10^4
    • +
    • lists[i] is sorted in ascending order.
    • +
    • The sum of lists[i].length won't exceed 10^4.
    • +
    + ### Related Topics [[Heap](../../tag/heap/README.md)] [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/minimum-cost-to-cut-a-stick/README.md b/problems/minimum-cost-to-cut-a-stick/README.md index 87c37b87c..fee9eddb9 100644 --- a/problems/minimum-cost-to-cut-a-stick/README.md +++ b/problems/minimum-cost-to-cut-a-stick/README.md @@ -7,7 +7,7 @@ [< Previous](../maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "Maximum Number of Non-Overlapping Subarrays With Sum Equals Target")                  -Next > +[Next >](../the-most-similar-path-in-a-graph "The Most Similar Path in a Graph") ## [1547. Minimum Cost to Cut a Stick (Hard)](https://leetcode.com/problems/minimum-cost-to-cut-a-stick "切棍子的最小成本") diff --git a/problems/minimum-cost-to-move-chips-to-the-same-position/README.md b/problems/minimum-cost-to-move-chips-to-the-same-position/README.md new file mode 100644 index 000000000..100a49005 --- /dev/null +++ b/problems/minimum-cost-to-move-chips-to-the-same-position/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../valid-palindrome-iii "Valid Palindrome III") +                 +[Next >](../longest-arithmetic-subsequence-of-given-difference "Longest Arithmetic Subsequence of Given Difference") + +## [1217. Minimum Cost to Move Chips to The Same Position (Easy)](https://leetcode.com/problems/minimum-cost-to-move-chips-to-the-same-position "玩筹码") + +

    We have n chips, where the position of the ith chip is position[i].

    + +

    We need to move all the chips to the same position, In one step, we can change the position of the ith chip from position[i] to:

    + +
      +
    • position[i] + 2 or position[i] - 2 with cost = 0.
    • +
    • position[i] + 1 or position[i] - 1 with cost = 1.
    • +
    + +

    Return the minimum cost needed to move all the chips to the same position.

    + +

     

    +

    Example 1:

    + +
    +Input: position = [1,2,3]
    +Output: 1
    +Explanation: First step: Move the chip at position 3 to position 1 with cost = 0.
    +Second step: Move the chip at position 2 to position 1 with cost = 1.
    +Total cost is 1.
    +
    + +

    Example 2:

    + +
    +Input: position = [2,2,2,3,3]
    +Output: 2
    +Explanation: We can move the two chips at poistion 3 to position 2. Each move has cost = 1. The total cost = 2.
    +
    + +

    Example 3:

    + +
    +Input: position = [1,1000000000]
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= position.length <= 100
    • +
    • 1 <= position[i] <= 10^9
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +The first move keeps the parity of the element as it is. +
    + +
    +Hint 2 +The second move changes the parity of the element. +
    + +
    +Hint 3 +Since the first move is free, if all the numbers have the same parity, the answer would be zero. +
    + +
    +Hint 4 +Find the minimum cost to make all the numbers have the same parity. +
    diff --git a/problems/minimum-insertions-to-balance-a-parentheses-string/README.md b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md index 369fd2f3a..5a740a59e 100644 --- a/problems/minimum-insertions-to-balance-a-parentheses-string/README.md +++ b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md @@ -18,9 +18,11 @@
  • Left parenthesis '(' must go before the corresponding two consecutive right parenthesis '))'.
  • +

    In other words, we treat '(' as openning parenthesis and '))' as closing parenthesis.

    +

    For example, "())", "())(())))" and "(())())))" are balanced, ")()", "()))" and "(()))" are not balanced.

    -

    You can insert the characters '(' and ')' at any position of the string to balance it if needed.

    +

    You can insert the characters '(' and ')' at any position of the string to balance it if needed.

    Return the minimum number of insertions needed to make s balanced.

    diff --git a/problems/minimum-number-of-days-to-eat-n-oranges/README.md b/problems/minimum-number-of-days-to-eat-n-oranges/README.md new file mode 100644 index 000000000..3229bcebf --- /dev/null +++ b/problems/minimum-number-of-days-to-eat-n-oranges/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../magnetic-force-between-two-balls "Magnetic Force Between Two Balls") +                 +Next > + +## [1553. Minimum Number of Days to Eat N Oranges (Hard)](https://leetcode.com/problems/minimum-number-of-days-to-eat-n-oranges "吃掉 N 个橘子的最少天数") + +

    There are n oranges in the kitchen and you decided to eat some of these oranges every day as follows:

    + +
      +
    • Eat one orange.
    • +
    • If the number of remaining oranges (n) is divisible by 2 then you can eat  n/2 oranges.
    • +
    • If the number of remaining oranges (n) is divisible by 3 then you can eat  2*(n/3) oranges.
    • +
    + +

    You can only choose one of the actions per day.

    + +

    Return the minimum number of days to eat n oranges.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 10
    +Output: 4
    +Explanation: You have 10 oranges.
    +Day 1: Eat 1 orange,  10 - 1 = 9.  
    +Day 2: Eat 6 oranges, 9 - 2*(9/3) = 9 - 6 = 3. (Since 9 is divisible by 3)
    +Day 3: Eat 2 oranges, 3 - 2*(3/3) = 3 - 2 = 1. 
    +Day 4: Eat the last orange  1 - 1  = 0.
    +You need at least 4 days to eat the 10 oranges.
    +
    + +

    Example 2:

    + +
    +Input: n = 6
    +Output: 3
    +Explanation: You have 6 oranges.
    +Day 1: Eat 3 oranges, 6 - 6/2 = 6 - 3 = 3. (Since 6 is divisible by 2).
    +Day 2: Eat 2 oranges, 3 - 2*(3/3) = 3 - 2 = 1. (Since 3 is divisible by 3)
    +Day 3: Eat the last orange  1 - 1  = 0.
    +You need at least 3 days to eat the 6 oranges.
    +
    + +

    Example 3:

    + +
    +Input: n = 1
    +Output: 1
    +
    + +

    Example 4:

    + +
    +Input: n = 56
    +Output: 6
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 2*10^9
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +In each step, choose between 2 options: +minOranges = 1 + min( (n%2) + f(n/2), (n%3) + f(n/3) ) +where f(n) is the minimum number of days to eat n oranges. +
    diff --git a/problems/minimum-operations-to-make-array-equal/README.md b/problems/minimum-operations-to-make-array-equal/README.md new file mode 100644 index 000000000..a975cb28b --- /dev/null +++ b/problems/minimum-operations-to-make-array-equal/README.md @@ -0,0 +1,57 @@ + + + + + + + +[< Previous](../three-consecutive-odds "Three Consecutive Odds") +                 +[Next >](../magnetic-force-between-two-balls "Magnetic Force Between Two Balls") + +## [1551. Minimum Operations to Make Array Equal (Medium)](https://leetcode.com/problems/minimum-operations-to-make-array-equal "使数组中所有元素相等的最小操作数") + +

    You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i (i.e. 0 <= i < n).

    + +

    In one operation, you can select two indices x and y where 0 <= x, y < n and subtract 1 from arr[x] and add 1 to arr[y] (i.e. perform arr[x] -=1 and arr[y] += 1). The goal is to make all the elements of the array equal. It is guaranteed that all the elements of the array can be made equal using some operations.

    + +

    Given an integer n, the length of the array. Return the minimum number of operations needed to make all the elements of arr equal.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 3
    +Output: 2
    +Explanation: arr = [1, 3, 5]
    +First operation choose x = 2 and y = 0, this leads arr to be [2, 3, 4]
    +In the second operation choose x = 2 and y = 0 again, thus arr = [3, 3, 3].
    +
    + +

    Example 2:

    + +
    +Input: n = 6
    +Output: 9
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 10^4
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Build the array arr using the given formula, define target = sum(arr) / n +
    + +
    +Hint 2 +What is the number of operations needed to convert arr so that all elements equal target ? +
    diff --git a/problems/move-sub-tree-of-n-ary-tree/README.md b/problems/move-sub-tree-of-n-ary-tree/README.md index 2451c61bf..9e0e67911 100644 --- a/problems/move-sub-tree-of-n-ary-tree/README.md +++ b/problems/move-sub-tree-of-n-ary-tree/README.md @@ -9,7 +9,7 @@                  [Next >](../find-users-with-valid-e-mails "Find Users With Valid E-Mails") -## [1516. Move Sub-Tree of N-Ary Tree (Hard)](https://leetcode.com/problems/move-sub-tree-of-n-ary-tree "") +## [1516. Move Sub-Tree of N-Ary Tree (Hard)](https://leetcode.com/problems/move-sub-tree-of-n-ary-tree "移动 N 叉树的子树") diff --git a/problems/number-of-submatrices-that-sum-to-target/README.md b/problems/number-of-submatrices-that-sum-to-target/README.md index 64a0cf50b..14b4947e0 100644 --- a/problems/number-of-submatrices-that-sum-to-target/README.md +++ b/problems/number-of-submatrices-that-sum-to-target/README.md @@ -48,6 +48,16 @@
  • -10^8 <= target <= 10^8
  • +

     

    +

    Constraints:

    + +
      +
    • 1 <= matrix.length <= 100
    • +
    • 1 <= matrix[0].length <= 100
    • +
    • -1000 <= matrix[i] <= 1000
    • +
    • -10^8 <= target <= 10^8
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/open-the-lock/README.md b/problems/open-the-lock/README.md index 94e887a81..fd1e13cea 100644 --- a/problems/open-the-lock/README.md +++ b/problems/open-the-lock/README.md @@ -11,59 +11,61 @@ ## [752. Open the Lock (Medium)](https://leetcode.com/problems/open-the-lock "打开转盘锁") -

    -You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'. The wheels can rotate freely and wrap around: for example we can turn '9' to be '0', or '0' to be '9'. Each move consists of turning one wheel one slot. -

    -The lock initially starts at '0000', a string representing the state of the 4 wheels. -

    -You are given a list of deadends dead ends, meaning if the lock displays any of these codes, the wheels of the lock will stop turning and you will be unable to open it. -

    -Given a target representing the value of the wheels that will unlock the lock, return the minimum total number of turns required to open the lock, or -1 if it is impossible. -

    - -

    Example 1:
    +

    You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'. The wheels can rotate freely and wrap around: for example we can turn '9' to be '0', or '0' to be '9'. Each move consists of turning one wheel one slot.

    + +

    The lock initially starts at '0000', a string representing the state of the 4 wheels.

    + +

    You are given a list of deadends dead ends, meaning if the lock displays any of these codes, the wheels of the lock will stop turning and you will be unable to open it.

    + +

    Given a target representing the value of the wheels that will unlock the lock, return the minimum total number of turns required to open the lock, or -1 if it is impossible.

    + +

     

    +

    Example 1:

    +
    -Input: deadends = ["0201","0101","0102","1212","2002"], target = "0202"
    -Output: 6
    -Explanation:
    -A sequence of valid moves would be "0000" -> "1000" -> "1100" -> "1200" -> "1201" -> "1202" -> "0202".
    -Note that a sequence like "0000" -> "0001" -> "0002" -> "0102" -> "0202" would be invalid,
    -because the wheels of the lock become stuck after the display becomes the dead end "0102".
    +Input: deadends = ["0201","0101","0102","1212","2002"], target = "0202"
    +Output: 6
    +Explanation:
    +A sequence of valid moves would be "0000" -> "1000" -> "1100" -> "1200" -> "1201" -> "1202" -> "0202".
    +Note that a sequence like "0000" -> "0001" -> "0002" -> "0102" -> "0202" would be invalid,
    +because the wheels of the lock become stuck after the display becomes the dead end "0102".
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: deadends = ["8888"], target = "0009"
    -Output: 1
    -Explanation:
    -We can turn the last wheel in reverse to move from "0000" -> "0009".
    +Input: deadends = ["8888"], target = "0009"
    +Output: 1
    +Explanation:
    +We can turn the last wheel in reverse to move from "0000" -> "0009".
     
    -

    -

    Example 3:
    +

    Example 3:

    +
    -Input: deadends = ["8887","8889","8878","8898","8788","8988","7888","9888"], target = "8888"
    -Output: -1
    -Explanation:
    -We can't reach the target without getting stuck.
    +Input: deadends = ["8887","8889","8878","8898","8788","8988","7888","9888"], target = "8888"
    +Output: -1
    +Explanation:
    +We can't reach the target without getting stuck.
     
    -

    -

    Example 4:
    +

    Example 4:

    +
    -Input: deadends = ["0000"], target = "8888"
    -Output: -1
    +Input: deadends = ["0000"], target = "8888"
    +Output: -1
     
    -

    - -

    Note:
    -

      -
    1. The length of deadends will be in the range [1, 500].
    2. -
    3. target will not be in the list deadends.
    4. -
    5. Every string in deadends and the string target will be a string of 4 digits from the 10,000 possibilities '0000' to '9999'.
    6. -
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= deadends.length <= 500
    • +
    • deadends[i].length == 4
    • +
    • target.length == 4
    • +
    • target will not be in the list deadends.
    • +
    • target and deadends[i] consist of digits only.
    • +
    ### Related Topics [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/palindrome-partitioning-ii/README.md b/problems/palindrome-partitioning-ii/README.md index f511bd3c9..9f1832987 100644 --- a/problems/palindrome-partitioning-ii/README.md +++ b/problems/palindrome-partitioning-ii/README.md @@ -11,18 +11,41 @@ ## [132. Palindrome Partitioning II (Hard)](https://leetcode.com/problems/palindrome-partitioning-ii "分割回文串 II") -

    Given a string s, partition s such that every substring of the partition is a palindrome.

    +

    Given a string s, partition s such that every substring of the partition is a palindrome

    -

    Return the minimum cuts needed for a palindrome partitioning of s.

    +

    Return the minimum cuts needed for a palindrome partitioning of s.

    -

    Example:

    +

     

    +

    Example 1:

    -Input: "aab"
    +Input: s = "aab"
     Output: 1
     Explanation: The palindrome partitioning ["aa","b"] could be produced using 1 cut.
     
    +

    Example 2:

    + +
    +Input: s = "a"
    +Output: 0
    +
    + +

    Example 3:

    + +
    +Input: s = "ab"
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 2000
    • +
    • s consists of lower-case English letters only.
    • +
    + ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/pancake-sorting/README.md b/problems/pancake-sorting/README.md index 7c0d1e180..2e2bd5f39 100644 --- a/problems/pancake-sorting/README.md +++ b/problems/pancake-sorting/README.md @@ -11,45 +11,52 @@ ## [969. Pancake Sorting (Medium)](https://leetcode.com/problems/pancake-sorting "煎饼排序") -

    Given an array A, we can perform a pancake flip: We choose some positive integer k <= A.length, then reverse the order of the first k elements of A.  We want to perform zero or more pancake flips (doing them one after another in succession) to sort the array A.

    +

    Given an array of integers A, We need to sort the array performing a series of pancake flips.

    -

    Return the k-values corresponding to a sequence of pancake flips that sort A.  Any valid answer that sorts the array within 10 * A.length flips will be judged as correct.

    +

    In one pancake flip we do the following steps:

    -

     

    +
      +
    • Choose an integer k where 0 <= k < A.length.
    • +
    • Reverse the sub-array A[0...k].
    • +
    + +

    For example, if A = [3,2,1,4] and we performed a pancake flip choosing k = 2, we reverse the sub-array [3,2,1], so A = [1,2,3,4] after the pancake flip at k = 2.

    + +

    Return an array of the k-values of the pancake flips that should be performed in order to sort A. Any valid answer that sorts the array within 10 * A.length flips will be judged as correct.

    +

     

    Example 1:

    -Input: [3,2,4,1]
    -Output: [4,2,4,3]
    +Input: A = [3,2,4,1]
    +Output: [4,2,4,3]
     Explanation: 
     We perform 4 pancake flips, with k values 4, 2, 4, and 3.
     Starting state: A = [3, 2, 4, 1]
    -After 1st flip (k=4): A = [1, 4, 2, 3]
    -After 2nd flip (k=2): A = [4, 1, 2, 3]
    -After 3rd flip (k=4): A = [3, 2, 1, 4]
    -After 4th flip (k=3): A = [1, 2, 3, 4], which is sorted. 
    +After 1st flip (k = 4): A = [1, 4, 2, 3]
    +After 2nd flip (k = 2): A = [4, 1, 2, 3]
    +After 3rd flip (k = 4): A = [3, 2, 1, 4]
    +After 4th flip (k = 3): A = [1, 2, 3, 4], which is sorted.
    +Notice that we return an array of the chosen k values of the pancake flips.
     
    -

    Example 2:

    -Input: [1,2,3]
    -Output: []
    +Input: A = [1,2,3]
    +Output: []
     Explanation: The input is already sorted, so there is no need to flip anything.
     Note that other answers, such as [3, 3], would also be accepted.
     

     

    -
    - -

    Note:

    +

    Constraints:

    -
      +
      • 1 <= A.length <= 100
      • -
      • A[i] is a permutation of [1, 2, ..., A.length]
      • -
    +
  • 1 <= A[i] <= A.length
  • +
  • All integers in A are unique (i.e. A is a permutation of the integers from 1 to A.length).
  • + ### Related Topics [[Sort](../../tag/sort/README.md)] diff --git a/problems/prefix-and-suffix-search/README.md b/problems/prefix-and-suffix-search/README.md index f7fb85160..321939389 100644 --- a/problems/prefix-and-suffix-search/README.md +++ b/problems/prefix-and-suffix-search/README.md @@ -42,7 +42,7 @@ WordFilter.f("b", "") // returns -1 [[Trie](../../tag/trie/README.md)] ### Similar Questions - 1. [Add and Search Word - Data structure design](../add-and-search-word-data-structure-design) (Medium) + 1. [Design Add and Search Words Data Structure](../design-add-and-search-words-data-structure) (Medium) ### Hints
    diff --git a/problems/profitable-schemes/README.md b/problems/profitable-schemes/README.md index 91e524a43..7e3d68adc 100644 --- a/problems/profitable-schemes/README.md +++ b/problems/profitable-schemes/README.md @@ -11,13 +11,13 @@ ## [879. Profitable Schemes (Hard)](https://leetcode.com/problems/profitable-schemes "盈利计划") -

    There are G people in a gang, and a list of various crimes they could commit.

    +

    There is a group of G members, and a list of various crimes they could commit.

    -

    The i-th crime generates a profit[i] and requires group[i] gang members to participate.

    +

    The ith crime generates a profit[i] and requires group[i] members to participate in it.

    -

    If a gang member participates in one crime, that member can't participate in another crime.

    +

    If a member participates in one crime, that member can't participate in another crime.

    -

    Let's call a profitable scheme any subset of these crimes that generates at least P profit, and the total number of gang members participating in that subset of crimes is at most G.

    +

    Let's call a profitable scheme any subset of these crimes that generates at least P profit, and the total number of members participating in that subset of crimes is at most G.

    How many schemes can be chosen?  Since the answer may be very large, return it modulo 10^9 + 7.

    @@ -29,7 +29,7 @@ Input: G = 5, P = 3, group = [2,2], profit = [2,3] Output: 2 Explanation: -To make a profit of at least 3, the gang could either commit crimes 0 and 1, or just crime 1. +To make a profit of at least 3, the group could either commit crimes 0 and 1, or just crime 1. In total, there are 2 schemes. @@ -40,7 +40,7 @@ In total, there are 2 schemes. Input: G = 10, P = 5, group = [2,3,5], profit = [6,7,8] Output: 7 Explanation: -To make a profit of at least 5, the gang could commit any crimes, as long as they commit one. +To make a profit of at least 5, the group could commit any crimes, as long as they commit one. There are 7 possible schemes: (0), (1), (2), (0,1), (0,2), (1,2), and (0,1,2). diff --git a/problems/random-pick-with-weight/README.md b/problems/random-pick-with-weight/README.md index 79ff5c5bf..c6caa1433 100644 --- a/problems/random-pick-with-weight/README.md +++ b/problems/random-pick-with-weight/README.md @@ -11,9 +11,11 @@ ## [528. Random Pick with Weight (Medium)](https://leetcode.com/problems/random-pick-with-weight "按权重随机选择") -

    Given an array w of positive integers, where w[i] describes the weight of index i(0-indexed), write a function pickIndex which randomly picks an index in proportion to its weight.

    +

    Given an array of positive integers w. where w[i] describes the weight of ith index (0-indexed).

    -

    For example, given an input list of values w = [2, 8], when we pick up a number out of it, the chance is that 8 times out of 10 we should pick the number 1 as the answer since it's the second element of the array (w[1] = 8).

    +

    We need to call the function pickIndex() which randomly returns an integer in the range [0, w.length - 1]pickIndex() should return the integer proportional to its weight in the w array. For example, for w = [1, 3], the probability of picking index 0 is 1 / (1 + 3) = 0.25 (i.e 25%) while the probability of picking index 1 is 3 / (1 + 3) = 0.75 (i.e 75%).

    + +

    More formally, the probability of picking index i is w[i] / sum(w).

     

    Example 1:

    diff --git a/problems/recover-a-tree-from-preorder-traversal/README.md b/problems/recover-a-tree-from-preorder-traversal/README.md index f76b12e26..44eddb124 100644 --- a/problems/recover-a-tree-from-preorder-traversal/README.md +++ b/problems/recover-a-tree-from-preorder-traversal/README.md @@ -5,7 +5,7 @@ -[< Previous](../longest-arithmetic-sequence "Longest Arithmetic Sequence") +[< Previous](../longest-arithmetic-subsequence "Longest Arithmetic Subsequence")                  [Next >](../two-city-scheduling "Two City Scheduling") diff --git a/problems/restore-ip-addresses/README.md b/problems/restore-ip-addresses/README.md index 7f44a6fd7..7f562fce0 100644 --- a/problems/restore-ip-addresses/README.md +++ b/problems/restore-ip-addresses/README.md @@ -11,16 +11,34 @@ ## [93. Restore IP Addresses (Medium)](https://leetcode.com/problems/restore-ip-addresses "复原IP地址") -

    Given a string containing only digits, restore it by returning all possible valid IP address combinations.

    - -

    A valid IP address consists of exactly four integers (each integer is between 0 and 255) separated by single points.

    - -

    Example:

    - -
    -Input: "25525511135"
    -Output: ["255.255.11.135", "255.255.111.35"]
    -
    +

    Given a string s containing only digits. Return all possible valid IP addresses that can be obtained from s. You can return them in any order.

    + +

    A valid IP address consists of exactly four integers, each integer is between 0 and 255, separated by single points and cannot have leading zeros. For example, "0.1.2.201" and "192.168.1.1" are valid IP addresses and "0.011.255.245", "192.168.1.312" and "192.168@1.1" are invalid IP addresses. 

    + +

     

    +

    Example 1:

    +
    Input: s = "25525511135"
    +Output: ["255.255.11.135","255.255.111.35"]
    +

    Example 2:

    +
    Input: s = "0000"
    +Output: ["0.0.0.0"]
    +

    Example 3:

    +
    Input: s = "1111"
    +Output: ["1.1.1.1"]
    +

    Example 4:

    +
    Input: s = "010010"
    +Output: ["0.10.0.10","0.100.1.0"]
    +

    Example 5:

    +
    Input: s = "101023"
    +Output: ["1.0.10.23","1.0.102.3","10.1.0.23","10.10.2.3","101.0.2.3"]
    +
    +

     

    +

    Constraints:

    + +
      +
    • 0 <= s.length <= 3000
    • +
    • s consists of digits only.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/search-in-rotated-sorted-array/README.md b/problems/search-in-rotated-sorted-array/README.md index 84e319757..48b8d6919 100644 --- a/problems/search-in-rotated-sorted-array/README.md +++ b/problems/search-in-rotated-sorted-array/README.md @@ -11,28 +11,33 @@ ## [33. Search in Rotated Sorted Array (Medium)](https://leetcode.com/problems/search-in-rotated-sorted-array "搜索旋转排序数组") -

    Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.

    +

    Given an integer array nums sorted in ascending order, and an integer target.

    -

    (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).

    +

    Suppose that nums is rotated at some pivot unknown to you beforehand (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).

    -

    You are given a target value to search. If found in the array return its index, otherwise return -1.

    - -

    You may assume no duplicate exists in the array.

    - -

    Your algorithm's runtime complexity must be in the order of O(log n).

    +

    You should search for target in nums and if you found return its index, otherwise return -1.

    +

     

    Example 1:

    - -
    -Input: nums = [4,5,6,7,0,1,2], target = 0
    +
    Input: nums = [4,5,6,7,0,1,2], target = 0
     Output: 4
    +

    Example 2:

    +
    Input: nums = [4,5,6,7,0,1,2], target = 3
    +Output: -1
    +

    Example 3:

    +
    Input: nums = [1], target = 0
    +Output: -1
     
    - -

    Example 2:

    - -
    -Input: nums = [4,5,6,7,0,1,2], target = 3
    -Output: -1
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 5000
    • +
    • -10^4 <= nums[i] <= 10^4
    • +
    • All values of nums are unique.
    • +
    • nums is guranteed to be rotated at some pivot.
    • +
    • -10^4 <= target <= 10^4
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/set-intersection-size-at-least-two/README.md b/problems/set-intersection-size-at-least-two/README.md index 1e96a4568..55fab50bc 100644 --- a/problems/set-intersection-size-at-least-two/README.md +++ b/problems/set-intersection-size-at-least-two/README.md @@ -9,7 +9,7 @@                  [Next >](../bold-words-in-string "Bold Words in String") -## [757. Set Intersection Size At Least Two (Hard)](https://leetcode.com/problems/set-intersection-size-at-least-two " 设置交集大小至少为2") +## [757. Set Intersection Size At Least Two (Hard)](https://leetcode.com/problems/set-intersection-size-at-least-two "设置交集大小至少为2")

    An integer interval [a, b] (for integers a < b) is a set of all consecutive integers from a to b, including a and b. diff --git a/problems/stone-game/README.md b/problems/stone-game/README.md index b0760bc1b..3ed729a0e 100644 --- a/problems/stone-game/README.md +++ b/problems/stone-game/README.md @@ -20,12 +20,11 @@

    Assuming Alex and Lee play optimally, return True if and only if Alex wins the game.

     

    -

    Example 1:

    -Input: [5,3,4,5]
    -Output: true
    +Input: piles = [5,3,4,5]
    +Output: true
     Explanation: 
     Alex starts first, and can only take the first 5 or the last 5.
     Say he takes the first 5, so that the row becomes [3, 4, 5].
    @@ -35,15 +34,14 @@ This demonstrated that taking the first 5 was a winning move for Alex, so we ret
     

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 2 <= piles.length <= 500
      • piles.length is even.
      • 1 <= piles[i] <= 500
      • sum(piles) is odd.
      • -
    + ### Related Topics [[Minimax](../../tag/minimax/README.md)] diff --git a/problems/the-most-recent-orders-for-each-product/README.md b/problems/the-most-recent-orders-for-each-product/README.md new file mode 100644 index 000000000..812900ece --- /dev/null +++ b/problems/the-most-recent-orders-for-each-product/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../the-most-similar-path-in-a-graph "The Most Similar Path in a Graph") +                 +[Next >](../three-consecutive-odds "Three Consecutive Odds") + +## [1549. The Most Recent Orders for Each Product (Medium)](https://leetcode.com/problems/the-most-recent-orders-for-each-product "") + + diff --git a/problems/the-most-recent-orders-for-each-product/mysql_schemas.sql b/problems/the-most-recent-orders-for-each-product/mysql_schemas.sql new file mode 100644 index 000000000..7da4f47bc --- /dev/null +++ b/problems/the-most-recent-orders-for-each-product/mysql_schemas.sql @@ -0,0 +1,25 @@ +Create table If Not Exists Customers (customer_id int, name varchar(10)); +Create table If Not Exists Orders (order_id int, order_date date, customer_id int, product_id int); +Create table If Not Exists Products (product_id int, product_name varchar(20), price int); +Truncate table Customers; +insert into Customers (customer_id, name) values ('1', 'Winston'); +insert into Customers (customer_id, name) values ('2', 'Jonathan'); +insert into Customers (customer_id, name) values ('3', 'Annabelle'); +insert into Customers (customer_id, name) values ('4', 'Marwan'); +insert into Customers (customer_id, name) values ('5', 'Khaled'); +Truncate table Orders; +insert into Orders (order_id, order_date, customer_id, product_id) values ('1', '2020-07-31', '1', '1'); +insert into Orders (order_id, order_date, customer_id, product_id) values ('2', '2020-7-30', '2', '2'); +insert into Orders (order_id, order_date, customer_id, product_id) values ('3', '2020-08-29', '3', '3'); +insert into Orders (order_id, order_date, customer_id, product_id) values ('4', '2020-07-29', '4', '1'); +insert into Orders (order_id, order_date, customer_id, product_id) values ('5', '2020-06-10', '1', '2'); +insert into Orders (order_id, order_date, customer_id, product_id) values ('6', '2020-08-01', '2', '1'); +insert into Orders (order_id, order_date, customer_id, product_id) values ('7', '2020-08-01', '3', '1'); +insert into Orders (order_id, order_date, customer_id, product_id) values ('8', '2020-08-03', '1', '2'); +insert into Orders (order_id, order_date, customer_id, product_id) values ('9', '2020-08-07', '2', '3'); +insert into Orders (order_id, order_date, customer_id, product_id) values ('10', '2020-07-15', '1', '2'); +Truncate table Products; +insert into Products (product_id, product_name, price) values ('1', 'keyboard', '120'); +insert into Products (product_id, product_name, price) values ('2', 'mouse', '80'); +insert into Products (product_id, product_name, price) values ('3', 'screen', '600'); +insert into Products (product_id, product_name, price) values ('4', 'hard disk', '450'); diff --git a/problems/the-most-similar-path-in-a-graph/README.md b/problems/the-most-similar-path-in-a-graph/README.md new file mode 100644 index 000000000..7d17a5781 --- /dev/null +++ b/problems/the-most-similar-path-in-a-graph/README.md @@ -0,0 +1,29 @@ + + + + + + + +[< Previous](../minimum-cost-to-cut-a-stick "Minimum Cost to Cut a Stick") +                 +[Next >](../the-most-recent-orders-for-each-product "The Most Recent Orders for Each Product") + +## [1548. The Most Similar Path in a Graph (Hard)](https://leetcode.com/problems/the-most-similar-path-in-a-graph "") + + + +### Related Topics + [[Graph](../../tag/graph/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Create an array dp where dp[i][j] is the min edit distance for the path starting at node i and compared to index j of the targetPath. +
    + +
    +Hint 2 +Traverse the dp array to obtain a valid answer. +
    diff --git a/problems/three-consecutive-odds/README.md b/problems/three-consecutive-odds/README.md new file mode 100644 index 000000000..89b1e53d8 --- /dev/null +++ b/problems/three-consecutive-odds/README.md @@ -0,0 +1,47 @@ + + + + + + + +[< Previous](../the-most-recent-orders-for-each-product "The Most Recent Orders for Each Product") +                 +[Next >](../minimum-operations-to-make-array-equal "Minimum Operations to Make Array Equal") + +## [1550. Three Consecutive Odds (Easy)](https://leetcode.com/problems/three-consecutive-odds "存在连续三个奇数的数组") + +Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false. +

     

    +

    Example 1:

    + +
    +Input: arr = [2,6,4,1]
    +Output: false
    +Explanation: There are no three consecutive odds.
    +
    + +

    Example 2:

    + +
    +Input: arr = [1,2,34,3,4,5,7,23,12]
    +Output: true
    +Explanation: [5,7,23] are three consecutive odds.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 1000
    • +
    • 1 <= arr[i] <= 1000
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Check every three consecutive numbers in the array for parity. +
    diff --git a/problems/valid-palindrome-iii/README.md b/problems/valid-palindrome-iii/README.md index d6521343f..b9c826790 100644 --- a/problems/valid-palindrome-iii/README.md +++ b/problems/valid-palindrome-iii/README.md @@ -7,7 +7,7 @@ [< Previous](../stepping-numbers "Stepping Numbers")                  -[Next >](../play-with-chips "Play with Chips") +[Next >](../minimum-cost-to-move-chips-to-the-same-position "Minimum Cost to Move Chips to The Same Position") ## [1216. Valid Palindrome III (Hard)](https://leetcode.com/problems/valid-palindrome-iii "验证回文字符串 III") diff --git a/problems/validate-ip-address/README.md b/problems/validate-ip-address/README.md index 109142b53..6fed36f31 100644 --- a/problems/validate-ip-address/README.md +++ b/problems/validate-ip-address/README.md @@ -11,17 +11,21 @@ ## [468. Validate IP Address (Medium)](https://leetcode.com/problems/validate-ip-address "验证IP地址") -

    Write a function to check whether an input string is a valid IPv4 address or IPv6 address or neither.

    +

    Given a string IP. We need to check If IP is a valid IPv4 address, valid IPv6 address or not a valid IP address.

    -

    IPv4 addresses are canonically represented in dot-decimal notation, which consists of four decimal numbers, each ranging from 0 to 255, separated by dots ("."), e.g.,172.16.254.1;

    +

    Return "IPv4" if IP is a valid IPv4 address, "IPv6" if IP is a valid IPv6 address or "Neither" if IP is not a valid IP of any type.

    -

    Besides, leading zeros in the IPv4 is invalid. For example, the address 172.16.254.01 is invalid.

    +

    A valid IPv4 address is an IP in the form "x1.x2.x3.x4" where 0 <= xi <= 255 and xi cannot contain leading zeros. For example, "192.168.1.1" and "192.168.1.0" are valid IPv4 addresses but "192.168.01.1", "192.168.1.00" and "192.168@1.1" are invalid IPv4 adresses.

    -

    IPv6 addresses are represented as eight groups of four hexadecimal digits, each group representing 16 bits. The groups are separated by colons (":"). For example, the address 2001:0db8:85a3:0000:0000:8a2e:0370:7334 is a valid one. Also, we could omit some leading zeros among four hexadecimal digits and some low-case characters in the address to upper-case ones, so 2001:db8:85a3:0:0:8A2E:0370:7334 is also a valid IPv6 address(Omit leading zeros and using upper cases).

    +

    A valid IPv6 address is an IP in the form "x1:x2:x3:x4:x5:x6:x7:x8" where:

    -

    However, we don't replace a consecutive group of zero value with a single empty group using two consecutive colons (::) to pursue simplicity. For example, 2001:0db8:85a3::8A2E:0370:7334 is an invalid IPv6 address.

    +
      +
    • 1 <= xi.length <= 4
    • +
    • xi is hexadecimal string whcih may contain digits, lower-case English letter ('a' to 'f') and/or upper-case English letters ('A' to 'F').
    • +
    • Leading zeros are allowed in xi.
    • +
    -

    Besides, extra leading zeros in the IPv6 is also invalid. For example, the address 02001:0db8:85a3:0000:0000:8a2e:0370:7334 is invalid.

    +

    For example, "2001:0db8:85a3:0000:0000:8a2e:0370:7334" and "2001:db8:85a3:0:0:8A2E:0370:7334" are valid IPv6 addresses but "2001:0db8:85a3::8A2E:037j:7334" and "02001:0db8:85a3:0000:0000:8a2e:0370:7334" are invalid IPv6 addresses.

     

    Example 1:

    @@ -48,11 +52,25 @@ Explanation: This is neither a IPv4 address nor a IPv6 address.
    +

    Example 4:

    + +
    +Input: IP = "2001:0db8:85a3:0:0:8A2E:0370:7334:"
    +Output: "Neither"
    +
    + +

    Example 5:

    + +
    +Input: IP = "1e1.4.5.6"
    +Output: "Neither"
    +
    +

     

    Constraints:

      -
    • IP consists only of English letters, digits and the characters "." and ":".
    • +
    • IP consists only of English letters, digits and the characters '.' and ':'.
    ### Related Topics diff --git a/problems/word-search-ii/README.md b/problems/word-search-ii/README.md index 0a51d3e59..959bcf2b8 100644 --- a/problems/word-search-ii/README.md +++ b/problems/word-search-ii/README.md @@ -5,7 +5,7 @@ -[< Previous](../add-and-search-word-data-structure-design "Add and Search Word - Data structure design") +[< Previous](../design-add-and-search-words-data-structure "Design Add and Search Words Data Structure")                  [Next >](../house-robber-ii "House Robber II") diff --git a/readme/1-300.md b/readme/1-300.md index 3c358fe50..8d008f9fe 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -92,7 +92,7 @@ LeetCode Problems' Solutions | 20 | [Valid Parentheses](https://leetcode.com/problems/valid-parentheses "有效的括号") | [Go](../problems/valid-parentheses) | Easy | | 21 | [Merge Two Sorted Lists](https://leetcode.com/problems/merge-two-sorted-lists "合并两个有序链表") | [Go](../problems/merge-two-sorted-lists) | Easy | | 22 | [Generate Parentheses](https://leetcode.com/problems/generate-parentheses "括号生成") | [Go](../problems/generate-parentheses) | Medium | -| 23 | [Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists "合并K个排序链表") | [Go](../problems/merge-k-sorted-lists) | Hard | +| 23 | [Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists "合并K个升序链表") | [Go](../problems/merge-k-sorted-lists) | Hard | | 24 | [Swap Nodes in Pairs](https://leetcode.com/problems/swap-nodes-in-pairs "两两交换链表中的节点") | [Go](../problems/swap-nodes-in-pairs) | Medium | | 25 | [Reverse Nodes in k-Group](https://leetcode.com/problems/reverse-nodes-in-k-group "K 个一组翻转链表") | [Go](../problems/reverse-nodes-in-k-group) | Hard | | 26 | [Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array "删除排序数组中的重复项") | [Go](../problems/remove-duplicates-from-sorted-array) | Easy | @@ -280,7 +280,7 @@ LeetCode Problems' Solutions | 208 | [Implement Trie (Prefix Tree)](https://leetcode.com/problems/implement-trie-prefix-tree "实现 Trie (前缀树)") | [Go](../problems/implement-trie-prefix-tree) | Medium | | 209 | [Minimum Size Subarray Sum](https://leetcode.com/problems/minimum-size-subarray-sum "长度最小的子数组") | [Go](../problems/minimum-size-subarray-sum) | Medium | | 210 | [Course Schedule II](https://leetcode.com/problems/course-schedule-ii "课程表 II") | [Go](../problems/course-schedule-ii) | Medium | -| 211 | [Add and Search Word - Data structure design](https://leetcode.com/problems/add-and-search-word-data-structure-design "添加与搜索单词 - 数据结构设计") | [Go](../problems/add-and-search-word-data-structure-design) | Medium | +| 211 | [Design Add and Search Words Data Structure](https://leetcode.com/problems/design-add-and-search-words-data-structure "添加与搜索单词 - 数据结构设计") | [Go](../problems/design-add-and-search-words-data-structure) | Medium | | 212 | [Word Search II](https://leetcode.com/problems/word-search-ii "单词搜索 II") | [Go](../problems/word-search-ii) | Hard | | 213 | [House Robber II](https://leetcode.com/problems/house-robber-ii "打家劫舍 II") | [Go](../problems/house-robber-ii) | Medium | | 214 | [Shortest Palindrome](https://leetcode.com/problems/shortest-palindrome "最短回文串") | [Go](../problems/shortest-palindrome) | Hard | diff --git a/readme/601-900.md b/readme/601-900.md index 6d447983a..5c655eb70 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -226,7 +226,7 @@ LeetCode Problems' Solutions | 754 | [Reach a Number](https://leetcode.com/problems/reach-a-number "到达终点数字") | [Go](../problems/reach-a-number) | Medium | | 755 | [Pour Water](https://leetcode.com/problems/pour-water "倒水") 🔒 | [Go](../problems/pour-water) | Medium | | 756 | [Pyramid Transition Matrix](https://leetcode.com/problems/pyramid-transition-matrix "金字塔转换矩阵") | [Go](../problems/pyramid-transition-matrix) | Medium | -| 757 | [Set Intersection Size At Least Two](https://leetcode.com/problems/set-intersection-size-at-least-two " 设置交集大小至少为2") | [Go](../problems/set-intersection-size-at-least-two) | Hard | +| 757 | [Set Intersection Size At Least Two](https://leetcode.com/problems/set-intersection-size-at-least-two "设置交集大小至少为2") | [Go](../problems/set-intersection-size-at-least-two) | Hard | | 758 | [Bold Words in String](https://leetcode.com/problems/bold-words-in-string "字符串中的加粗单词") 🔒 | [Go](../problems/bold-words-in-string) | Easy | | 759 | [Employee Free Time](https://leetcode.com/problems/employee-free-time "员工空闲时间") 🔒 | [Go](../problems/employee-free-time) | Hard | | 760 | [Find Anagram Mappings](https://leetcode.com/problems/find-anagram-mappings "找出变位映射") 🔒 | [Go](../problems/find-anagram-mappings) | Easy | diff --git a/readme/901-1200.md b/readme/901-1200.md index dfddde6e8..83f160153 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -196,7 +196,7 @@ LeetCode Problems' Solutions | 1024 | [Video Stitching](https://leetcode.com/problems/video-stitching "视频拼接") | [Go](../problems/video-stitching) | Medium | | 1025 | [Divisor Game](https://leetcode.com/problems/divisor-game "除数博弈") | [Go](../problems/divisor-game) | Easy | | 1026 | [Maximum Difference Between Node and Ancestor](https://leetcode.com/problems/maximum-difference-between-node-and-ancestor "节点与其祖先之间的最大差值") | [Go](../problems/maximum-difference-between-node-and-ancestor) | Medium | -| 1027 | [Longest Arithmetic Sequence](https://leetcode.com/problems/longest-arithmetic-sequence "最长等差数列") | [Go](../problems/longest-arithmetic-sequence) | Medium | +| 1027 | [Longest Arithmetic Subsequence](https://leetcode.com/problems/longest-arithmetic-subsequence "最长等差数列") | [Go](../problems/longest-arithmetic-subsequence) | Medium | | 1028 | [Recover a Tree From Preorder Traversal](https://leetcode.com/problems/recover-a-tree-from-preorder-traversal "从先序遍历还原二叉树") | [Go](../problems/recover-a-tree-from-preorder-traversal) | Hard | | 1029 | [Two City Scheduling](https://leetcode.com/problems/two-city-scheduling "两地调度") | [Go](../problems/two-city-scheduling) | Easy | | 1030 | [Matrix Cells in Distance Order](https://leetcode.com/problems/matrix-cells-in-distance-order "距离顺序排列矩阵单元格") | [Go](../problems/matrix-cells-in-distance-order) | Easy | diff --git a/tag/array/README.md b/tag/array/README.md index 06f8ab50d..f5d1ecca2 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1550 | [存在连续三个奇数的数组](../../problems/three-consecutive-odds) | [[数组](../array/README.md)] | Easy | | 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 1535 | [找出数组游戏的赢家](../../problems/find-the-winner-of-an-array-game) | [[数组](../array/README.md)] | Medium | | 1534 | [统计好三元组](../../problems/count-good-triplets) | [[数组](../array/README.md)] | Easy | @@ -86,7 +88,7 @@ | 1233 | [删除子文件夹](../../problems/remove-sub-folders-from-the-filesystem) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1222 | [可以攻击国王的皇后](../../problems/queens-that-can-attack-the-king) | [[数组](../array/README.md)] | Medium | -| 1217 | [玩筹码](../../problems/play-with-chips) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1217 | [玩筹码](../../problems/minimum-cost-to-move-chips-to-the-same-position) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | | 1200 | [最小绝对差](../../problems/minimum-absolute-difference) | [[数组](../array/README.md)] | Easy | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 277f11155..0eacba95d 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -42,7 +42,7 @@ | 254 | [因子的组合](../../problems/factor-combinations) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | | 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 211 | [添加与搜索单词 - 数据结构设计](../../problems/add-and-search-word-data-structure-design) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 140 | [单词拆分 II](../../problems/word-break-ii) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 131 | [分割回文串](../../problems/palindrome-partitioning) | [[回溯算法](../backtracking/README.md)] | Medium | | 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 0c4e9ff38..6a61cce43 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1533 | [Find the Index of the Large Integer](../../problems/find-the-index-of-the-large-integer) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | | 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1482 | [制作 m 束花所需的最少天数](../../problems/minimum-number-of-days-to-make-m-bouquets) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index aabe94b12..ddf640c51 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -53,7 +53,7 @@ | 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | | 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 211 | [添加与搜索单词 - 数据结构设计](../../problems/add-and-search-word-data-structure-design) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium | | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index b0960f7f8..7ef87cf29 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -26,5 +26,5 @@ | 215 | [数组中的第K个最大元素](../../problems/kth-largest-element-in-an-array) | [[堆](../heap/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | | 169 | [多数元素](../../problems/majority-element) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Easy | | 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 23 | [合并K个排序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 4 | [寻找两个正序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 7ebc2dcd8..f3ca6a0e7 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1553 | [吃掉 N 个橘子的最少天数](../../problems/minimum-number-of-days-to-eat-n-oranges) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1548 | [The Most Similar Path in a Graph](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1547 | [切棍子的最小成本](../../problems/minimum-cost-to-cut-a-stick) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1546 | [和为目标值的最大数目不重叠非空子数组数目](../../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1537 | [最大得分](../../problems/get-the-maximum-score) | [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -86,7 +88,7 @@ | 1049 | [最后一块石头的重量 II](../../problems/last-stone-weight-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1048 | [最长字符串链](../../problems/longest-string-chain) | [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1039 | [多边形三角剖分的最低得分](../../problems/minimum-score-triangulation-of-polygon) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1027 | [最长等差数列](../../problems/longest-arithmetic-sequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1027 | [最长等差数列](../../problems/longest-arithmetic-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1025 | [除数博弈](../../problems/divisor-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 1024 | [视频拼接](../../problems/video-stitching) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1012 | [至少有 1 位重复的数字](../../problems/numbers-with-repeated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index 2175ba887..f2d1a1872 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1548 | [The Most Similar Path in a Graph](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] | Medium | | 1494 | [并行课程 II](../../problems/parallel-courses-ii) | [[图](../graph/README.md)] | Hard | | 1462 | [课程安排 IV](../../problems/course-schedule-iv) | [[图](../graph/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index aeb3e12ef..5d2ea69a2 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -33,7 +33,7 @@ | 1247 | [交换字符使得字符串相同](../../problems/minimum-swaps-to-make-strings-equal) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1231 | [分享巧克力](../../problems/divide-chocolate) 🔒 | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1221 | [分割平衡字符串](../../problems/split-a-string-in-balanced-strings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | -| 1217 | [玩筹码](../../problems/play-with-chips) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1217 | [玩筹码](../../problems/minimum-cost-to-move-chips-to-the-same-position) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1196 | [最多可以买到的苹果数量](../../problems/how-many-apples-can-you-put-into-the-basket) 🔒 | [[贪心算法](../greedy/README.md)] | Easy | | 1167 | [连接棒材的最低费用](../../problems/minimum-cost-to-connect-sticks) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | | 1111 | [有效括号的嵌套深度](../../problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -67,7 +67,7 @@ | 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | -| 757 | [ 设置交集大小至少为2](../../problems/set-intersection-size-at-least-two) | [[贪心算法](../greedy/README.md)] | Hard | +| 757 | [设置交集大小至少为2](../../problems/set-intersection-size-at-least-two) | [[贪心算法](../greedy/README.md)] | Hard | | 738 | [单调递增的数字](../../problems/monotone-increasing-digits) | [[贪心算法](../greedy/README.md)] | Medium | | 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | diff --git a/tag/heap/README.md b/tag/heap/README.md index b815bcaee..47a8f4199 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -43,4 +43,4 @@ | 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | | 215 | [数组中的第K个最大元素](../../problems/kth-largest-element-in-an-array) | [[堆](../heap/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 23 | [合并K个排序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index f51d0b0c6..4d131fc44 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -44,7 +44,7 @@ | 61 | [旋转链表](../../problems/rotate-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 25 | [K 个一组翻转链表](../../problems/reverse-nodes-in-k-group) | [[链表](../linked-list/README.md)] | Hard | | 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[链表](../linked-list/README.md)] | Medium | -| 23 | [合并K个排序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[链表](../linked-list/README.md)] | Easy | | 19 | [删除链表的倒数第N个节点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 2 | [两数相加](../../problems/add-two-numbers) | [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 6fdaf1fdc..4df5334bc 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1551 | [使数组中所有元素相等的最小操作数](../../problems/minimum-operations-to-make-array-equal) | [[数学](../math/README.md)] | Medium | | 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1523 | [在区间范围内统计奇数数目](../../problems/count-odd-numbers-in-an-interval-range) | [[数学](../math/README.md)] | Easy | | 1513 | [仅含 1 的子串数](../../problems/number-of-substrings-with-only-1s) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | @@ -44,7 +45,7 @@ | 1228 | [等差数列中缺失的数字](../../problems/missing-number-in-arithmetic-progression) 🔒 | [[数学](../math/README.md)] | Easy | | 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1217 | [玩筹码](../../problems/play-with-chips) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1217 | [玩筹码](../../problems/minimum-cost-to-move-chips-to-the-same-position) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1199 | [建造街区的最短时间](../../problems/minimum-time-to-build-blocks) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1183 | [矩阵中 1 的最大数量](../../problems/maximum-number-of-ones) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/tree/README.md b/tag/tree/README.md index 444961f7d..08171eddf 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -10,7 +10,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1516 | [Move Sub-Tree of N-Ary Tree](../../problems/move-sub-tree-of-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard | +| 1516 | [移动 N 叉树的子树](../../problems/move-sub-tree-of-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1469 | [寻找所有的独生节点](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | diff --git a/tag/trie/README.md b/tag/trie/README.md index 3bd66dc15..f0436f960 100644 --- a/tag/trie/README.md +++ b/tag/trie/README.md @@ -24,5 +24,5 @@ | 421 | [数组中两个数的最大异或值](../../problems/maximum-xor-of-two-numbers-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Medium | | 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 211 | [添加与搜索单词 - 数据结构设计](../../problems/add-and-search-word-data-structure-design) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium | From 5dc31a3d362acfd980c105377666a732b0ea22fe Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 24 Aug 2020 09:09:29 +0800 Subject: [PATCH 095/145] A: new --- README.md | 10 +++ problems/132-pattern/README.md | 50 ++++++----- problems/3sum-with-multiplicity/README.md | 20 ++--- problems/bank-account-summary/README.md | 14 +++ .../bank-account-summary/mysql_schemas.sql | 12 +++ .../README.md | 30 +++++-- .../README.md | 42 +++++++-- problems/detect-cycles-in-2d-grid/README.md | 77 ++++++++++++++++ problems/distribute-candies/README.md | 2 +- .../README.md | 52 ++++++++--- .../find-latest-group-of-size-m/README.md | 90 +++++++++++++++++++ .../flip-equivalent-binary-trees/README.md | 53 +++++++---- problems/grid-illumination/README.md | 61 +++++++------ .../README.md | 8 +- problems/h-index-ii/README.md | 2 +- problems/implement-magic-dictionary/README.md | 60 ++++++++----- problems/knight-dialer/README.md | 62 +++++++------ problems/longest-palindrome/README.md | 41 ++++++--- .../README.md | 75 ++++++++++++++++ .../median-of-two-sorted-arrays/README.md | 53 ++++++++--- .../README.md | 2 +- .../README.md | 68 ++++++++++++++ .../README.md | 86 ++++++++++++++++++ .../README.md | 67 ++++++++++++++ problems/pascals-triangle-ii/README.md | 27 ++++-- problems/plus-one/README.md | 20 ++++- problems/powx-n/README.md | 17 ++-- problems/replace-words/README.md | 39 +++++--- problems/reverse-bits/README.md | 7 ++ problems/rising-temperature/README.md | 46 +++++++--- problems/set-matrix-zeroes/README.md | 53 +++++------ problems/single-number-iii/README.md | 38 ++++++-- problems/split-array-largest-sum/README.md | 52 ++++++----- problems/stone-game-v/README.md | 67 ++++++++++++++ .../strings-differ-by-one-character/README.md | 25 ++++++ problems/thousand-separator/README.md | 59 ++++++++++++ readme/1-300.md | 2 +- tag/array/README.md | 1 + tag/binary-search/README.md | 3 +- tag/depth-first-search/README.md | 1 + tag/dynamic-programming/README.md | 1 + tag/graph/README.md | 1 + tag/greedy/README.md | 1 + tag/sort/README.md | 1 + tag/string/README.md | 1 + 45 files changed, 1205 insertions(+), 294 deletions(-) create mode 100644 problems/bank-account-summary/README.md create mode 100644 problems/bank-account-summary/mysql_schemas.sql create mode 100644 problems/detect-cycles-in-2d-grid/README.md create mode 100644 problems/find-latest-group-of-size-m/README.md create mode 100644 problems/maximum-number-of-coins-you-can-get/README.md create mode 100644 problems/minimum-number-of-vertices-to-reach-all-nodes/README.md create mode 100644 problems/minimum-numbers-of-function-calls-to-make-target-array/README.md create mode 100644 problems/most-visited-sector-in-a-circular-track/README.md create mode 100644 problems/stone-game-v/README.md create mode 100644 problems/strings-differ-by-one-character/README.md create mode 100644 problems/thousand-separator/README.md diff --git a/README.md b/README.md index f536dfd67..eb9ca7433 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,16 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1563 | [Stone Game V](https://leetcode.com/problems/stone-game-v "石子游戏 V") | [Go](problems/stone-game-v) | Hard | +| 1562 | [Find Latest Group of Size M](https://leetcode.com/problems/find-latest-group-of-size-m "查找大小为 M 的最新分组") | [Go](problems/find-latest-group-of-size-m) | Medium | +| 1561 | [Maximum Number of Coins You Can Get](https://leetcode.com/problems/maximum-number-of-coins-you-can-get "你可以获得的最大硬币数目") | [Go](problems/maximum-number-of-coins-you-can-get) | Medium | +| 1560 | [Most Visited Sector in a Circular Track](https://leetcode.com/problems/most-visited-sector-in-a-circular-track "圆形赛道上经过次数最多的扇区") | [Go](problems/most-visited-sector-in-a-circular-track) | Easy | +| 1559 | [Detect Cycles in 2D Grid](https://leetcode.com/problems/detect-cycles-in-2d-grid "二维网格图中探测环") | [Go](problems/detect-cycles-in-2d-grid) | Hard | +| 1558 | [Minimum Numbers of Function Calls to Make Target Array](https://leetcode.com/problems/minimum-numbers-of-function-calls-to-make-target-array "得到目标数组的最少函数调用次数") | [Go](problems/minimum-numbers-of-function-calls-to-make-target-array) | Medium | +| 1557 | [Minimum Number of Vertices to Reach All Nodes](https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes "可以到达所有点的最少点数目") | [Go](problems/minimum-number-of-vertices-to-reach-all-nodes) | Medium | +| 1556 | [Thousand Separator](https://leetcode.com/problems/thousand-separator "千位分隔数") | [Go](problems/thousand-separator) | Easy | +| 1555 | [Bank Account Summary](https://leetcode.com/problems/bank-account-summary) 🔒 | [MySQL](problems/bank-account-summary) | Medium | +| 1554 | [Strings Differ by One Character](https://leetcode.com/problems/strings-differ-by-one-character) 🔒 | [Go](problems/strings-differ-by-one-character) | Medium | | 1553 | [Minimum Number of Days to Eat N Oranges](https://leetcode.com/problems/minimum-number-of-days-to-eat-n-oranges "吃掉 N 个橘子的最少天数") | [Go](problems/minimum-number-of-days-to-eat-n-oranges) | Hard | | 1552 | [Magnetic Force Between Two Balls](https://leetcode.com/problems/magnetic-force-between-two-balls "两球之间的磁力") | [Go](problems/magnetic-force-between-two-balls) | Medium | | 1551 | [Minimum Operations to Make Array Equal](https://leetcode.com/problems/minimum-operations-to-make-array-equal "使数组中所有元素相等的最小操作数") | [Go](problems/minimum-operations-to-make-array-equal) | Medium | diff --git a/problems/132-pattern/README.md b/problems/132-pattern/README.md index 862deef34..dbe20b0de 100644 --- a/problems/132-pattern/README.md +++ b/problems/132-pattern/README.md @@ -11,41 +11,43 @@ ## [456. 132 Pattern (Medium)](https://leetcode.com/problems/132-pattern "132模式") -

    -Given a sequence of n integers a1, a2, ..., an, a 132 pattern is a subsequence ai, aj, ak such -that i < j < k and ai < ak < aj. Design an algorithm that takes a list of n numbers as input and checks whether there is a 132 pattern in the list.

    +

    Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j].

    -

    Note: n will be less than 15,000.

    +

    Return true if there is a 132 pattern in nums, otherwise return false.

    -

    Example 1:
    -

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

     

    +

    Example 1:

    -Explanation: There is no 132 pattern in the sequence. -
    -

    - -

    Example 2:

    -Input: [3, 1, 4, 2]
    +Input: nums = [1,2,3,4]
    +Output: false
    +Explanation: There is no 132 pattern in the sequence.
    +
    -Output: True +

    Example 2:

    -Explanation: There is a 132 pattern in the sequence: [1, 4, 2]. +
    +Input: nums = [3,1,4,2]
    +Output: true
    +Explanation: There is a 132 pattern in the sequence: [1, 4, 2].
     
    -

    -

    Example 3:
    +

    Example 3:

    +
    -Input: [-1, 3, 2, 0]
    +Input: nums = [-1,3,2,0]
    +Output: true
    +Explanation: There are three 132 patterns in the sequence: [-1, 3, 2], [-1, 3, 0] and [-1, 2, 0].
    +
    -Output: True +

     

    +

    Constraints:

    -Explanation: There are three 132 patterns in the sequence: [-1, 3, 2], [-1, 3, 0] and [-1, 2, 0]. - -

    +
      +
    • n == nums.length
    • +
    • 1 <= n <= 3 * 104
    • +
    • -109 <= nums[i] <= 109
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/3sum-with-multiplicity/README.md b/problems/3sum-with-multiplicity/README.md index d7d1d6276..4c805fdda 100644 --- a/problems/3sum-with-multiplicity/README.md +++ b/problems/3sum-with-multiplicity/README.md @@ -13,15 +13,14 @@

    Given an integer array A, and an integer target, return the number of tuples i, j, k  such that i < j < k and A[i] + A[j] + A[k] == target.

    -

    As the answer can be very large, return it modulo 10^9 + 7.

    +

    As the answer can be very large, return it modulo 109 + 7.

     

    -

    Example 1:

    -Input: A = [1,1,2,2,3,3,4,4,5,5], target = 8
    -Output: 20
    +Input: A = [1,1,2,2,3,3,4,4,5,5], target = 8
    +Output: 20
     Explanation: 
     Enumerating by the values (A[i], A[j], A[k]):
     (1, 2, 5) occurs 8 times;
    @@ -30,12 +29,11 @@ Enumerating by the values (A[i], A[j], A[k]):
     (2, 3, 3) occurs 2 times.
     
    -

    Example 2:

    -Input: A = [1,1,2,2,2,2], target = 5
    -Output: 12
    +Input: A = [1,1,2,2,2,2], target = 5
    +Output: 12
     Explanation: 
     A[i] = 1, A[j] = A[k] = 2 occurs 12 times:
     We choose one 1 from [1,1] in 2 ways,
    @@ -43,15 +41,13 @@ and two 2s from [2,2,2,2] in 6 ways.
     

     

    -
    - -

    Note:

    +

    Constraints:

    -
      +
      • 3 <= A.length <= 3000
      • 0 <= A[i] <= 100
      • 0 <= target <= 300
      • -
    + ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/bank-account-summary/README.md b/problems/bank-account-summary/README.md new file mode 100644 index 000000000..f01d2802b --- /dev/null +++ b/problems/bank-account-summary/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../strings-differ-by-one-character "Strings Differ by One Character") +                 +[Next >](../thousand-separator "Thousand Separator") + +## [1555. Bank Account Summary (Medium)](https://leetcode.com/problems/bank-account-summary "") + + diff --git a/problems/bank-account-summary/mysql_schemas.sql b/problems/bank-account-summary/mysql_schemas.sql new file mode 100644 index 000000000..aad88fe3b --- /dev/null +++ b/problems/bank-account-summary/mysql_schemas.sql @@ -0,0 +1,12 @@ +Create table If Not Exists Users (user_id int, user_name varchar(20), credit int) +; +Create table If Not Exists Transaction (trans_id int, paid_by int, paid_to int, amount int, transacted_on date); +Truncate table Users; +insert into Users (user_id, user_name, credit) values ('1', 'Moustafa', '100'); +insert into Users (user_id, user_name, credit) values ('2', 'Jonathan', '200'); +insert into Users (user_id, user_name, credit) values ('3', 'Winston', '10000'); +insert into Users (user_id, user_name, credit) values ('4', 'Luis', '800'); +Truncate table Transaction; +insert into Transaction (trans_id, paid_by, paid_to, amount, transacted_on) values ('1', '1', '3', '400', '2020-08-01'); +insert into Transaction (trans_id, paid_by, paid_to, amount, transacted_on) values ('2', '3', '2', '500', '2020-08-02'); +insert into Transaction (trans_id, paid_by, paid_to, amount, transacted_on) values ('3', '2', '1', '200', '2020-08-03'); diff --git a/problems/best-time-to-buy-and-sell-stock-iii/README.md b/problems/best-time-to-buy-and-sell-stock-iii/README.md index 43adc71d1..fccf2e5fe 100644 --- a/problems/best-time-to-buy-and-sell-stock-iii/README.md +++ b/problems/best-time-to-buy-and-sell-stock-iii/README.md @@ -17,30 +17,46 @@

    Note: You may not engage in multiple transactions at the same time (i.e., you must sell the stock before you buy again).

    +

     

    Example 1:

    -Input: [3,3,5,0,0,3,1,4]
    +Input: prices = [3,3,5,0,0,3,1,4]
     Output: 6
     Explanation: Buy on day 4 (price = 0) and sell on day 6 (price = 3), profit = 3-0 = 3.
    -             Then buy on day 7 (price = 1) and sell on day 8 (price = 4), profit = 4-1 = 3.
    +Then buy on day 7 (price = 1) and sell on day 8 (price = 4), profit = 4-1 = 3.

    Example 2:

    -Input: [1,2,3,4,5]
    +Input: prices = [1,2,3,4,5]
     Output: 4
     Explanation: Buy on day 1 (price = 1) and sell on day 5 (price = 5), profit = 5-1 = 4.
    -             Note that you cannot buy on day 1, buy on day 2 and sell them later, as you are
    -             engaging multiple transactions at the same time. You must sell before buying again.
    +Note that you cannot buy on day 1, buy on day 2 and sell them later, as you are engaging multiple transactions at the same time. You must sell before buying again.
     

    Example 3:

    -Input: [7,6,4,3,1]
    +Input: prices = [7,6,4,3,1]
     Output: 0
    -Explanation: In this case, no transaction is done, i.e. max profit = 0.
    +Explanation: In this case, no transaction is done, i.e. max profit = 0. + + +

    Example 4:

    + +
    +Input: prices = [1]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= prices.length <= 105
    • +
    • 0 <= prices[i] <= 105
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/convert-sorted-list-to-binary-search-tree/README.md b/problems/convert-sorted-list-to-binary-search-tree/README.md index 040b46dbd..eb1b79dfe 100644 --- a/problems/convert-sorted-list-to-binary-search-tree/README.md +++ b/problems/convert-sorted-list-to-binary-search-tree/README.md @@ -11,24 +11,48 @@ ## [109. Convert Sorted List to Binary Search Tree (Medium)](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree "有序链表转换二叉搜索树") -

    Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.

    +

    Given the head of a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.

    For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1.

    -

    Example:

    +

     

    +

    Example 1:

    + +
    +Input: head = [-10,-3,0,5,9]
    +Output: [0,-3,9,-10,null,5]
    +Explanation: One possible answer is [0,-3,9,-10,null,5], which represents the shown height balanced BST.
    +
    + +

    Example 2:

    -Given the sorted linked list: [-10,-3,0,5,9],
    +Input: head = []
    +Output: []
    +
    -One possible answer is: [0,-3,9,-10,null,5], which represents the following height balanced BST: +

    Example 3:

    - 0 - / \ - -3 9 - / / - -10 5 +
    +Input: head = [0]
    +Output: [0]
     
    +

    Example 4:

    + +
    +Input: head = [1,3]
    +Output: [3,1]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The numner of nodes in head is in the range [0, 2 * 10^4].
    • +
    • -10^5 <= Node.val <= 10^5
    • +
    + ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/detect-cycles-in-2d-grid/README.md b/problems/detect-cycles-in-2d-grid/README.md new file mode 100644 index 000000000..10af34343 --- /dev/null +++ b/problems/detect-cycles-in-2d-grid/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../minimum-numbers-of-function-calls-to-make-target-array "Minimum Numbers of Function Calls to Make Target Array") +                 +[Next >](../most-visited-sector-in-a-circular-track "Most Visited Sector in a Circular Track") + +## [1559. Detect Cycles in 2D Grid (Hard)](https://leetcode.com/problems/detect-cycles-in-2d-grid "二维网格图中探测环") + +

    Given a 2D array of characters grid of size m x n, you need to find if there exists any cycle consisting of the same value in grid.

    + +

    A cycle is a path of length 4 or more in the grid that starts and ends at the same cell. From a given cell, you can move to one of the cells adjacent to it - in one of the four directions (up, down, left, or right), if it has the same value of the current cell.

    + +

    Also, you cannot move to the cell that you visited in your last move. For example, the cycle (1, 1) -> (1, 2) -> (1, 1) is invalid because from (1, 2) we visited (1, 1) which was the last visited cell.

    + +

    Return true if any cycle of the same value exists in grid, otherwise, return false.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: grid = [["a","a","a","a"],["a","b","b","a"],["a","b","b","a"],["a","a","a","a"]]
    +Output: true
    +Explanation: There are two valid cycles shown in different colors in the image below:
    +
    +
    + +

    Example 2:

    + +

    + +
    +Input: grid = [["c","c","c","a"],["c","d","c","c"],["c","c","e","c"],["f","c","c","c"]]
    +Output: true
    +Explanation: There is only one valid cycle highlighted in the image below:
    +
    +
    + +

    Example 3:

    + +

    + +
    +Input: grid = [["a","b","b"],["b","z","b"],["b","b","a"]]
    +Output: false
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m <= 500
    • +
    • 1 <= n <= 500
    • +
    • grid consists only of lowercase English letters.
    • +
    + +### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] + +### Hints +
    +Hint 1 +Keep track of the parent (previous position) to avoid considering an invalid path. +
    + +
    +Hint 2 +Use DFS or BFS and keep track of visited cells to see if there is a cycle. +
    diff --git a/problems/distribute-candies/README.md b/problems/distribute-candies/README.md index 9cfd5e983..020e7245d 100644 --- a/problems/distribute-candies/README.md +++ b/problems/distribute-candies/README.md @@ -11,7 +11,7 @@ ## [575. Distribute Candies (Easy)](https://leetcode.com/problems/distribute-candies "分糖果") -

    You have n candies of different types, the ith candy is of type candies[i].

    +

    You have n candies, the ith candy is of type candies[i].

    You want to distribute the candies equally between a sister and a brother so that each of them gets n / 2 candies (n is even). The sister loves to collect different types of candies, so you want to give her the maximum number of different types of candies.

    diff --git a/problems/find-largest-value-in-each-tree-row/README.md b/problems/find-largest-value-in-each-tree-row/README.md index e5c655338..0edbb6110 100644 --- a/problems/find-largest-value-in-each-tree-row/README.md +++ b/problems/find-largest-value-in-each-tree-row/README.md @@ -11,21 +11,53 @@ ## [515. Find Largest Value in Each Tree Row (Medium)](https://leetcode.com/problems/find-largest-value-in-each-tree-row "在每个树行中找最大值") -

    You need to find the largest value in each row of a binary tree.

    +

    Given the root of a binary tree, return an array of the largest value in each row of the tree (0-indexed).

    -

    Example:
    +

     

    + +

     

    +

    Example 1:

    +
    -Input: 
    +Input: root = [1,3,2,5,3,null,9]
    +Output: [1,3,9]
    +
    - 1 - / \ - 3 2 - / \ \ - 5 3 9 +

    Example 2:

    -Output: [1, 3, 9] +
    +Input: root = [1,2,3]
    +Output: [1,3]
     
    -

    + +

    Example 3:

    + +
    +Input: root = [1]
    +Output: [1]
    +
    + +

    Example 4:

    + +
    +Input: root = [1,null,2]
    +Output: [1,2]
    +
    + +

    Example 5:

    + +
    +Input: root = []
    +Output: []
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of the nodes in the tree will be in the range [1, 104].
    • +
    • -231 <= Node.val <= 231 - 1
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/find-latest-group-of-size-m/README.md b/problems/find-latest-group-of-size-m/README.md new file mode 100644 index 000000000..81cb52486 --- /dev/null +++ b/problems/find-latest-group-of-size-m/README.md @@ -0,0 +1,90 @@ + + + + + + + +[< Previous](../maximum-number-of-coins-you-can-get "Maximum Number of Coins You Can Get") +                 +[Next >](../stone-game-v "Stone Game V") + +## [1562. Find Latest Group of Size M (Medium)](https://leetcode.com/problems/find-latest-group-of-size-m "查找大小为 M 的最新分组") + +

    Given an array arr that represents a permutation of numbers from 1 to n. You have a binary string of size n that initially has all its bits set to zero.

    + +

    At each step i (assuming both the binary string and arr are 1-indexed) from 1 to n, the bit at position arr[i] is set to 1. You are given an integer m and you need to find the latest step at which there exists a group of ones of length m. A group of ones is a contiguous substring of 1s such that it cannot be extended in either direction.

    + +

    Return the latest step at which there exists a group of ones of length exactly m. If no such group exists, return -1.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [3,5,1,2,4], m = 1
    +Output: 4
    +Explanation:
    +Step 1: "00100", groups: ["1"]
    +Step 2: "00101", groups: ["1", "1"]
    +Step 3: "10101", groups: ["1", "1", "1"]
    +Step 4: "11101", groups: ["111", "1"]
    +Step 5: "11111", groups: ["11111"]
    +The latest step at which there exists a group of size 1 is step 4.
    + +

    Example 2:

    + +
    +Input: arr = [3,1,5,4,2], m = 2
    +Output: -1
    +Explanation:
    +Step 1: "00100", groups: ["1"]
    +Step 2: "10100", groups: ["1", "1"]
    +Step 3: "10101", groups: ["1", "1", "1"]
    +Step 4: "10111", groups: ["1", "111"]
    +Step 5: "11111", groups: ["11111"]
    +No group of size 2 exists during any step.
    +
    + +

    Example 3:

    + +
    +Input: arr = [1], m = 1
    +Output: 1
    +
    + +

    Example 4:

    + +
    +Input: arr = [2,1], m = 2
    +Output: 2
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == arr.length
    • +
    • 1 <= n <= 10^5
    • +
    • 1 <= arr[i] <= n
    • +
    • All integers in arr are distinct.
    • +
    • 1 <= m <= arr.length
    • +
    + +### Related Topics + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Since the problem asks for the latest step, can you start the searching from the end of arr? +
    + +
    +Hint 2 +Use a map to store the current “1” groups. +
    + +
    +Hint 3 +At each step (going backwards) you need to split one group and update the map. +
    diff --git a/problems/flip-equivalent-binary-trees/README.md b/problems/flip-equivalent-binary-trees/README.md index 32f6b6ba5..d55a6b63e 100644 --- a/problems/flip-equivalent-binary-trees/README.md +++ b/problems/flip-equivalent-binary-trees/README.md @@ -11,35 +11,56 @@ ## [951. Flip Equivalent Binary Trees (Medium)](https://leetcode.com/problems/flip-equivalent-binary-trees "翻转等价二叉树") -

    For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees.

    +

    For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees.

    -

    A binary tree X is flip equivalent to a binary tree Y if and only if we can make X equal to Y after some number of flip operations.

    +

    A binary tree X is flip equivalent to a binary tree Y if and only if we can make X equal to Y after some number of flip operations.

    -

    Write a function that determines whether two binary trees are flip equivalent.  The trees are given by root nodes root1 and root2.

    +

    Given the roots of two binary trees root1 and root2, return true if the two trees are flip equivelent or false otherwise.

     

    -

    Example 1:

    - +Flipped Trees Diagram
    -Input: root1 = [1,2,3,4,5,6,null,null,null,7,8], root2 = [1,3,2,null,6,4,5,null,null,null,null,8,7]
    -Output: true
    +Input: root1 = [1,2,3,4,5,6,null,null,null,7,8], root2 = [1,3,2,null,6,4,5,null,null,null,null,8,7]
    +Output: true
     Explanation: We flipped at nodes with values 1, 3, and 5.
    -Flipped Trees Diagram
     
    -

     

    +

    Example 2:

    -

    Note:

    +
    +Input: root1 = [], root2 = []
    +Output: true
    +
    + +

    Example 3:

    + +
    +Input: root1 = [], root2 = [1]
    +Output: false
    +
    -
      -
    1. Each tree will have at most 100 nodes.
    2. -
    3. Each value in each tree will be a unique integer in the range [0, 99].
    4. -
    +

    Example 4:

    + +
    +Input: root1 = [0,null,1], root2 = []
    +Output: false
    +
    + +

    Example 5:

    + +
    +Input: root1 = [0,null,1], root2 = [0,1]
    +Output: true
    +
    -

     

    -
    +

    Constraints:

    + +
      +
    • The number of nodes in each tree is in the range [0, 100].
    • +
    • Each value in each tree will be a unique integer in the range [0, 99].
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/grid-illumination/README.md b/problems/grid-illumination/README.md index 818a21554..2a73c73da 100644 --- a/problems/grid-illumination/README.md +++ b/problems/grid-illumination/README.md @@ -11,50 +11,53 @@ ## [1001. Grid Illumination (Hard)](https://leetcode.com/problems/grid-illumination "网格照明") -

    On a N x N grid of cells, each cell (x, y) with 0 <= x < N and 0 <= y < N has a lamp.

    +

    Given a grid of size N x N, each cell of this grid has a lamp which is intially turned off.

    -

    Initially, some number of lamps are on.  lamps[i] tells us the location of the i-th lamp that is on.  Each lamp that is on illuminates every square on its x-axis, y-axis, and both diagonals (similar to a Queen in chess).

    +

    Given an array of lamp positions lamps, where lamps[i] = [xi, yi] indicates that the lamp at grid[xi][yi] will be turned on. When a lamp is turned on, it illiminates its cell and any cell in the same row, column or diagonal with this this cell.

    -

    For the i-th query queries[i] = (x, y), the answer to the query is 1 if the cell (x, y) is illuminated, else 0.

    +

    Then you will be given a query array queries, where queries[i] = [xi, yi]. For the ith query, you should answer whether grid[xi][yi] is illuminated or not. After answering the ith query, you should turn off the lamp at grid[xi][yi] and all of its 8 adjacent lamps if they exist (i,e, lamps at adjacent cell which share side or diagonal).

    -

    After each query (x, y) [in the order given by queries], we turn off any lamps that are at cell (x, y) or are adjacent 8-directionally (ie., share a corner or edge with cell (x, y).)

    - -

    Return an array of answers.  Each value answer[i] should be equal to the answer of the i-th query queries[i].

    +

    Return an array of integers ans where each value ans[i] should be equal to the answer of the ith query queries[i].

     

    -

    Example 1:

    + +
    +Input: N = 5, lamps = [[0,0],[4,4]], queries = [[1,1],[1,0]]
    +Output: [1,0]
    +Explanation: We have initial grid with all lamps turned off. In the above picture we see the grid after turning the lamp at grid[0][0] on then turning the lamp at grid[4][4] on.
    +The first query asks if the lamp at grid[1][1] is illuminated or not (the blue square) and as it is illuminated, we return 1. Then we turn off any lamp in the red square.
    +
    +The second query asks if the lamp at grid[1][0] is illuminated or not (the blue square) and as it is not illustrated, we return 0. Then we turn off any lamp in the red rectangle.
    +
    +
    + +

    Example 2:

    -Input: N = 5, lamps = [[0,0],[4,4]], queries = [[1,1],[1,0]]
    -Output: [1,0]
    -Explanation: 
    -Before performing the first query we have both lamps [0,0] and [4,4] on.
    -The grid representing which cells are lit looks like this, where [0,0] is the top left corner, and [4,4] is the bottom right corner:
    -1 1 1 1 1
    -1 1 0 0 1
    -1 0 1 0 1
    -1 0 0 1 1
    -1 1 1 1 1
    -Then the query at [1, 1] returns 1 because the cell is lit.  After this query, the lamp at [0, 0] turns off, and the grid now looks like this:
    -1 0 0 0 1
    -0 1 0 0 1
    -0 0 1 0 1
    -0 0 0 1 1
    -1 1 1 1 1
    -Before performing the second query we have only the lamp [4,4] on.  Now the query at [1,0] returns 0, because the cell is no longer lit.
    +Input: N = 5, lamps = [[0,0],[4,4]], queries = [[1,1],[1,1]]
    +Output: [1,1]
     
    -

     

    +

    Example 3:

    -

    Note:

    +
    +Input: N = 5, lamps = [[0,0],[0,4]], queries = [[0,4],[0,1],[1,4]]
    +Output: [1,1,0]
    +
    + +

     

    +

    Constraints:

    -
      +
      • 1 <= N <= 10^9
      • 0 <= lamps.length <= 20000
      • +
      • lamps[i].length == 2
      • +
      • 0 <= lamps[i][j] < N
      • 0 <= queries.length <= 20000
      • -
      • lamps[i].length == queries[i].length == 2
      • -
    +
  • queries[i].length == 2
  • +
  • 0 <= queries[i][j] < N
  • + ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/group-the-people-given-the-group-size-they-belong-to/README.md b/problems/group-the-people-given-the-group-size-they-belong-to/README.md index cb02db933..69acfc108 100644 --- a/problems/group-the-people-given-the-group-size-they-belong-to/README.md +++ b/problems/group-the-people-given-the-group-size-they-belong-to/README.md @@ -11,9 +11,13 @@ ## [1282. Group the People Given the Group Size They Belong To (Medium)](https://leetcode.com/problems/group-the-people-given-the-group-size-they-belong-to "用户分组") -

    There are n people whose IDs go from 0 to n - 1 and each person belongs exactly to one group. Given the array groupSizes of length n telling the group size each person belongs to, return the groups there are and the people's IDs each group includes.

    +

    There are n people, each of them has a unique ID from 0 to n - 1 and each person of them belongs to exactly one group.

    -

    You can return any solution in any order and the same applies for IDs. Also, it is guaranteed that there exists at least one solution. 

    +

    Given an integer array groupSizes which indicated that the person with ID = i belongs to a group of groupSize[i] persons.

    + +

    Return an array of the groups where ans[j] contains the IDs of the jth group. Each ID should belong to exactly one group and each ID should be present in your answer. Also if a person with ID = i belongs to group j in your answer, then ans[j].length == groupSize[i] should be true.

    + +

    If there is multiple answers, return any of them. It is guaranteed that there will be at least one valid solution for the given input.

     

    Example 1:

    diff --git a/problems/h-index-ii/README.md b/problems/h-index-ii/README.md index 841f4c137..d501faf00 100644 --- a/problems/h-index-ii/README.md +++ b/problems/h-index-ii/README.md @@ -9,7 +9,7 @@                  [Next >](../paint-fence "Paint Fence") -## [275. H-Index II (Medium)](https://leetcode.com/problems/h-index-ii "H指数 II") +## [275. H-Index II (Medium)](https://leetcode.com/problems/h-index-ii "H 指数 II")

    Given an array of citations sorted in ascending order (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.

    diff --git a/problems/implement-magic-dictionary/README.md b/problems/implement-magic-dictionary/README.md index 5d5cef814..1d4558e09 100644 --- a/problems/implement-magic-dictionary/README.md +++ b/problems/implement-magic-dictionary/README.md @@ -11,35 +11,47 @@ ## [676. Implement Magic Dictionary (Medium)](https://leetcode.com/problems/implement-magic-dictionary "实现一个魔法字典") -

    -Implement a magic directory with buildDict, and search methods. -

    +

    We want to implement a data structure that will be intialized with a list of distinct strings, then you will be given another string and you should find if you can change exactly one letter of this string to match any string in the data structure.

    -

    -For the method buildDict, you'll be given a list of non-repetitive words to build a dictionary. -

    +

    Implement the MagicDictionary class:

    -

    -For the method search, you'll be given a word, and judge whether if you modify exactly one character into another character in this word, the modified word is in the dictionary you just built. -

    +
      +
    • MagicDictionary() Initializes the object.
    • +
    • void buildDict(String[] dictionary) Sets the data structure with an array of distinct strings dictionary.
    • +
    • bool search(String searchWord) Returns true if you can change exactly one character in word to match any string in the data structure, otherwise returns false.
    • +
    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: buildDict(["hello", "leetcode"]), Output: Null
    -Input: search("hello"), Output: False
    -Input: search("hhllo"), Output: True
    -Input: search("hell"), Output: False
    -Input: search("leetcoded"), Output: False
    +Input
    +["MagicDictionary", "buildDict", "search", "search", "search", "search"]
    +[[], [["hello", "leetcode"]], ["hello"], ["hhllo"], ["hell"], ["leetcoded"]]
    +Output
    +[null, null, false, true, false, false]
    +
    +Explanation
    +MagicDictionary magicDictionary = new MagicDictionary();
    +magicDictionary.buildDict(["hello", "leetcode"]);
    +magicDictionary.search("hello"); // return False
    +magicDictionary.search("hhllo"); // We can change the second 'h' to 'e' to match "hello" so we return True
    +magicDictionary.search("hell"); // return False
    +magicDictionary.search("leetcoded"); // return False
     
    -

    - -

    Note:
    -

      -
    1. You may assume that all the inputs are consist of lowercase letters a-z.
    2. -
    3. For contest purpose, the test data is rather small by now. You could think about highly efficient algorithm after the contest.
    4. -
    5. Please remember to RESET your class variables declared in class MagicDictionary, as static/class variables are persisted across multiple test cases. Please see here for more details.
    6. -
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= dictionary.length <= 100
    • +
    • 1 <= dictionary[i],length <= 100
    • +
    • dictionary[i] consist of only lower-case English letters.
    • +
    • All strings in dictionary are distinct.
    • +
    • 1 <= searchWord.length <= 100
    • +
    • searchWord consist of only lower-case English letters.
    • +
    • At most 100 calls will be made to search and buildDict,
    • +
    ### Related Topics [[Trie](../../tag/trie/README.md)] diff --git a/problems/knight-dialer/README.md b/problems/knight-dialer/README.md index 03fc04211..a3353836c 100644 --- a/problems/knight-dialer/README.md +++ b/problems/knight-dialer/README.md @@ -11,59 +11,63 @@ ## [935. Knight Dialer (Medium)](https://leetcode.com/problems/knight-dialer "骑士拨号器") -

    A chess knight can move as indicated in the chess diagram below:

    - -

     .           

    - -

     

    - -

    This time, we place our chess knight on any numbered key of a phone pad (indicated above), and the knight makes N-1 hops.  Each hop must be from one key to another numbered key.

    +

    The chess knight has a unique movement, it may move two squares vertically and one square horizontally, or two squares horizontally and one square vertically (with both forming the shape of an L). The possible movements of chess knight are shown in this diagaram:

    -

    Each time it lands on a key (including the initial placement of the knight), it presses the number of that key, pressing N digits total.

    +

    A chess knight can move as indicated in the chess diagram below:

    + +

    We have a chess knight and a phone pad as shown below, the knight can only stand on a numeric cell (i.e. blue cell).

    + +

    Given an integer n, return how many distinct phone numbers of length n we can dial.

    -

    How many distinct numbers can you dial in this manner?

    +

    You are allowed to place the knight on any numeric cell initially and then you should perform n - 1 jumps to dial a number of length n. All jumps should be valid knight jumps.

    -

    Since the answer may be large, output the answer modulo 10^9 + 7.

    +

    As the answer may be very large, return the answer modulo 109 + 7.

     

    - -
      -
    - -

    Example 1:

    -Input: 1
    -Output: 10
    +Input: n = 1
    +Output: 10
    +Explanation: We need to dial a number of length 1, so placing the knight over any numeric cell of the 10 cells is sufficient.
     
    -

    Example 2:

    -Input: 2
    -Output: 20
    +Input: n = 2
    +Output: 20
    +Explanation: All the valid number we can dial are [04, 06, 16, 18, 27, 29, 34, 38, 40, 43, 49, 60, 61, 67, 72, 76, 81, 83, 92, 94]
     
    -

    Example 3:

    -Input: 3
    -Output: 46
    +Input: n = 3
    +Output: 46
     
    -

     

    +

    Example 4:

    + +
    +Input: n = 4
    +Output: 104
    +
    + +

    Example 5:

    -

    Note:

    +
    +Input: n = 3131
    +Output: 136006598
    +Explanation: Please take care of the mod.
    +
    + +

     

    +

    Constraints:

      -
    • 1 <= N <= 5000
    • +
    • 1 <= n <= 5000
    -
    -
    -
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/longest-palindrome/README.md b/problems/longest-palindrome/README.md index 61887ae96..15fd9a6e9 100644 --- a/problems/longest-palindrome/README.md +++ b/problems/longest-palindrome/README.md @@ -11,26 +11,41 @@ ## [409. Longest Palindrome (Easy)](https://leetcode.com/problems/longest-palindrome "最长回文串") -

    Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.

    +

    Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters.

    -

    This is case sensitive, for example "Aa" is not considered a palindrome here.

    +

    Letters are case sensitive, for example, "Aa" is not considered a palindrome here.

    -

    Note:
    -Assume the length of given string will not exceed 1,010. -

    +

     

    +

    Example 1:

    -

    Example:

    -Input:
    -"abccccdd"
    +Input: s = "abccccdd"
    +Output: 7
    +Explanation:
    +One longest palindrome that can be built is "dccaccd", whose length is 7.
    +
    + +

    Example 2:

    + +
    +Input: s = "a"
    +Output: 1
    +
    -Output: -7 +

    Example 3:

    -Explanation: -One longest palindrome that can be built is "dccaccd", whose length is 7. +
    +Input: s = "bb"
    +Output: 2
     
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 2000
    • +
    • s consits of lower-case and/or upper-case English letters only.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/maximum-number-of-coins-you-can-get/README.md b/problems/maximum-number-of-coins-you-can-get/README.md new file mode 100644 index 000000000..0edf8365b --- /dev/null +++ b/problems/maximum-number-of-coins-you-can-get/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../most-visited-sector-in-a-circular-track "Most Visited Sector in a Circular Track") +                 +[Next >](../find-latest-group-of-size-m "Find Latest Group of Size M") + +## [1561. Maximum Number of Coins You Can Get (Medium)](https://leetcode.com/problems/maximum-number-of-coins-you-can-get "你可以获得的最大硬币数目") + +

    There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows:

    + +
      +
    • In each step, you will choose any 3 piles of coins (not necessarily consecutive).
    • +
    • Of your choice, Alice will pick the pile with the maximum number of coins.
    • +
    • You will pick the next pile with maximum number of coins.
    • +
    • Your friend Bob will pick the last pile.
    • +
    • Repeat until there are no more piles of coins.
    • +
    + +

    Given an array of integers piles where piles[i] is the number of coins in the ith pile.

    + +

    Return the maximum number of coins which you can have.

    + +

     

    +

    Example 1:

    + +
    +Input: piles = [2,4,1,2,7,8]
    +Output: 9
    +Explanation: Choose the triplet (2, 7, 8), Alice Pick the pile with 8 coins, you the pile with 7 coins and Bob the last one.
    +Choose the triplet (1, 2, 4), Alice Pick the pile with 4 coins, you the pile with 2 coins and Bob the last one.
    +The maximum number of coins which you can have are: 7 + 2 = 9.
    +On the other hand if we choose this arrangement (1, 2, 8), (2, 4, 7) you only get 2 + 4 = 6 coins which is not optimal.
    +
    + +

    Example 2:

    + +
    +Input: piles = [2,4,5]
    +Output: 4
    +
    + +

    Example 3:

    + +
    +Input: piles = [9,8,7,6,5,1,2,3,4]
    +Output: 18
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= piles.length <= 10^5
    • +
    • piles.length % 3 == 0
    • +
    • 1 <= piles[i] <= 10^4
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + +### Hints +
    +Hint 1 +Which pile of coins will you never be able to pick up? +
    + +
    +Hint 2 +Bob is forced to take the last pile of coins, no matter what it is. Which pile should you give to him? +
    diff --git a/problems/median-of-two-sorted-arrays/README.md b/problems/median-of-two-sorted-arrays/README.md index c49c2fa3c..6d9561d78 100644 --- a/problems/median-of-two-sorted-arrays/README.md +++ b/problems/median-of-two-sorted-arrays/README.md @@ -11,30 +11,61 @@ ## [4. Median of Two Sorted Arrays (Hard)](https://leetcode.com/problems/median-of-two-sorted-arrays "寻找两个正序数组的中位数") -

    There are two sorted arrays nums1 and nums2 of size m and n respectively.

    +

    Given two sorted arrays nums1 and nums2 of size m and n respectively.

    -

    Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).

    +

    Return the median of the two sorted arrays.

    -

    You may assume nums1 and nums2 cannot be both empty.

    +

    Follow up: The overall run time complexity should be O(log (m+n)).

    -

    Example 1:

    +

     

    +

    Example 1:

    -nums1 = [1, 3]
    -nums2 = [2]
    +Input: nums1 = [1,3], nums2 = [2]
    +Output: 2.00000
    +Explanation: merged array = [1,2,3] and median is 2.
    +
    + +

    Example 2:

    + +
    +Input: nums1 = [1,2], nums2 = [3,4]
    +Output: 2.50000
    +Explanation: merged array = [1,2,3,4] and median is (2 + 3) / 2 = 2.5.
    +
    + +

    Example 3:

    -The median is 2.0 +
    +Input: nums1 = [0,0], nums2 = [0,0]
    +Output: 0.00000
     
    -

    Example 2:

    +

    Example 4:

    -nums1 = [1, 2]
    -nums2 = [3, 4]
    +Input: nums1 = [], nums2 = [1]
    +Output: 1.00000
    +
    + +

    Example 5:

    -The median is (2 + 3)/2 = 2.5 +
    +Input: nums1 = [2], nums2 = []
    +Output: 2.00000
     
    +

     

    +

    Constraints:

    + +
      +
    • nums1,length == m
    • +
    • nums2,length == n
    • +
    • 0 <= m <= 1000
    • +
    • 0 <= n <= 1000
    • +
    • 1 <= m + n <= 2000
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/minimum-number-of-days-to-eat-n-oranges/README.md b/problems/minimum-number-of-days-to-eat-n-oranges/README.md index 3229bcebf..6718a052c 100644 --- a/problems/minimum-number-of-days-to-eat-n-oranges/README.md +++ b/problems/minimum-number-of-days-to-eat-n-oranges/README.md @@ -7,7 +7,7 @@ [< Previous](../magnetic-force-between-two-balls "Magnetic Force Between Two Balls")                  -Next > +[Next >](../strings-differ-by-one-character "Strings Differ by One Character") ## [1553. Minimum Number of Days to Eat N Oranges (Hard)](https://leetcode.com/problems/minimum-number-of-days-to-eat-n-oranges "吃掉 N 个橘子的最少天数") diff --git a/problems/minimum-number-of-vertices-to-reach-all-nodes/README.md b/problems/minimum-number-of-vertices-to-reach-all-nodes/README.md new file mode 100644 index 000000000..8dd361e1c --- /dev/null +++ b/problems/minimum-number-of-vertices-to-reach-all-nodes/README.md @@ -0,0 +1,68 @@ + + + + + + + +[< Previous](../thousand-separator "Thousand Separator") +                 +[Next >](../minimum-numbers-of-function-calls-to-make-target-array "Minimum Numbers of Function Calls to Make Target Array") + +## [1557. Minimum Number of Vertices to Reach All Nodes (Medium)](https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes "可以到达所有点的最少点数目") + +

    Given a directed acyclic graph, with n vertices numbered from 0 to n-1, and an array edges where edges[i] = [fromi, toi] represents a directed edge from node fromi to node toi.

    + +

    Find the smallest set of vertices from which all nodes in the graph are reachable. It's guaranteed that a unique solution exists.

    + +

    Notice that you can return the vertices in any order.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: n = 6, edges = [[0,1],[0,2],[2,5],[3,4],[4,2]]
    +Output: [0,3]
    +Explanation: It's not possible to reach all the nodes from a single vertex. From 0 we can reach [0,1,2,5]. From 3 we can reach [3,4,2,5]. So we output [0,3].
    + +

    Example 2:

    + +

    + +
    +Input: n = 5, edges = [[0,1],[2,1],[3,1],[1,4],[2,4]]
    +Output: [0,2,3]
    +Explanation: Notice that vertices 0, 3 and 2 are not reachable from any other node, so we must include them. Also any of these vertices can reach nodes 1 and 4.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 10^5
    • +
    • 1 <= edges.length <= min(10^5, n * (n - 1) / 2)
    • +
    • edges[i].length == 2
    • +
    • 0 <= fromi, toi < n
    • +
    • All pairs (fromi, toi) are distinct.
    • +
    + +### Related Topics + [[Graph](../../tag/graph/README.md)] + +### Hints +
    +Hint 1 +A node that does not have any incoming edge can only be reached by itself. +
    + +
    +Hint 2 +Any other node with incoming edges can be reached from some other node. +
    + +
    +Hint 3 +We only have to count the number of nodes with zero incoming edges. +
    diff --git a/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md b/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md new file mode 100644 index 000000000..5b294bc57 --- /dev/null +++ b/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../minimum-number-of-vertices-to-reach-all-nodes "Minimum Number of Vertices to Reach All Nodes") +                 +[Next >](../detect-cycles-in-2d-grid "Detect Cycles in 2D Grid") + +## [1558. Minimum Numbers of Function Calls to Make Target Array (Medium)](https://leetcode.com/problems/minimum-numbers-of-function-calls-to-make-target-array "得到目标数组的最少函数调用次数") + +

    + +

    Your task is to form an integer array nums from an initial array of zeros arr that is the same size as nums.

    + +

    Return the minimum number of function calls to make nums from arr.

    + +

    The answer is guaranteed to fit in a 32-bit signed integer.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,5]
    +Output: 5
    +Explanation: Increment by 1 (second element): [0, 0] to get [0, 1] (1 operation).
    +Double all the elements: [0, 1] -> [0, 2] -> [0, 4] (2 operations).
    +Increment by 1 (both elements)  [0, 4] -> [1, 4] -> [1, 5] (2 operations).
    +Total of operations: 1 + 2 + 2 = 5.
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,2]
    +Output: 3
    +Explanation: Increment by 1 (both elements) [0, 0] -> [0, 1] -> [1, 1] (2 operations).
    +Double all the elements: [1, 1] -> [2, 2] (1 operation).
    +Total of operations: 2 + 1 = 3.
    +
    + +

    Example 3:

    + +
    +Input: nums = [4,2,5]
    +Output: 6
    +Explanation: (initial)[0,0,0] -> [1,0,0] -> [1,0,1] -> [2,0,2] -> [2,1,2] -> [4,2,4] -> [4,2,5](nums).
    +
    + +

    Example 4:

    + +
    +Input: nums = [3,2,2,4]
    +Output: 7
    +
    + +

    Example 5:

    + +
    +Input: nums = [2,4,8,16]
    +Output: 8
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 10^5
    • +
    • 0 <= nums[i] <= 10^9
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Work backwards: try to go from nums to arr. +
    + +
    +Hint 2 +You should try to divide by 2 as much as possible, but you can only divide by 2 if everything is even. +
    diff --git a/problems/most-visited-sector-in-a-circular-track/README.md b/problems/most-visited-sector-in-a-circular-track/README.md new file mode 100644 index 000000000..f7518226e --- /dev/null +++ b/problems/most-visited-sector-in-a-circular-track/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../detect-cycles-in-2d-grid "Detect Cycles in 2D Grid") +                 +[Next >](../maximum-number-of-coins-you-can-get "Maximum Number of Coins You Can Get") + +## [1560. Most Visited Sector in a Circular Track (Easy)](https://leetcode.com/problems/most-visited-sector-in-a-circular-track "圆形赛道上经过次数最多的扇区") + +

    Given an integer n and an integer array rounds. We have a circular track which consists of n sectors labeled from 1 to n. A marathon will be held on this track, the marathon consists of m rounds. The ith round starts at sector rounds[i - 1] and ends at sector rounds[i]. For example, round 1 starts at sector rounds[0] and ends at sector rounds[1]

    + +

    Return an array of the most visited sectors sorted in ascending order.

    + +

    Notice that you circulate the track in ascending order of sector numbers in the counter-clockwise direction (See the first example).

    + +

     

    +

    Example 1:

    + +
    +Input: n = 4, rounds = [1,3,1,2]
    +Output: [1,2]
    +Explanation: The marathon starts at sector 1. The order of the visited sectors is as follows:
    +1 --> 2 --> 3 (end of round 1) --> 4 --> 1 (end of round 2) --> 2 (end of round 3 and the marathon)
    +We can see that both sectors 1 and 2 are visited twice and they are the most visited sectors. Sectors 3 and 4 are visited only once.
    + +

    Example 2:

    + +
    +Input: n = 2, rounds = [2,1,2,1,2,1,2,1,2]
    +Output: [2]
    +
    + +

    Example 3:

    + +
    +Input: n = 7, rounds = [1,3,5,7]
    +Output: [1,2,3,4,5,6,7]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 100
    • +
    • 1 <= m <= 100
    • +
    • rounds.length == m + 1
    • +
    • 1 <= rounds[i] <= n
    • +
    • rounds[i] != rounds[i + 1] for 0 <= i < m
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +For each round increment the visits of the sectors visited during the marathon with 1. +
    + +
    +Hint 2 +Determine the max number of visits, and return any sector visited the max number of visits. +
    diff --git a/problems/pascals-triangle-ii/README.md b/problems/pascals-triangle-ii/README.md index 1aba95a12..2f96604de 100644 --- a/problems/pascals-triangle-ii/README.md +++ b/problems/pascals-triangle-ii/README.md @@ -11,23 +11,34 @@ ## [119. Pascal's Triangle II (Easy)](https://leetcode.com/problems/pascals-triangle-ii "杨辉三角 II") -

    Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle.

    +

    Given an integer rowIndex, return the rowIndexth row of the Pascal's triangle.

    -

    Note that the row index starts from 0.

    +

    Notice that the row index starts from 0.


    In Pascal's triangle, each number is the sum of the two numbers directly above it.

    -

    Example:

    +

    Follow up:

    + +

    Could you optimize your algorithm to use only O(k) extra space?

    -
    -Input: 3
    +

     

    +

    Example 1:

    +
    Input: rowIndex = 3
     Output: [1,3,3,1]
    +

    Example 2:

    +
    Input: rowIndex = 0
    +Output: [1]
    +

    Example 3:

    +
    Input: rowIndex = 1
    +Output: [1,1]
     
    +

     

    +

    Constraints:

    -

    Follow up:

    - -

    Could you optimize your algorithm to use only O(k) extra space?

    +
      +
    • 0 <= rowIndex <= 40
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/plus-one/README.md b/problems/plus-one/README.md index 787516a64..672ab41dc 100644 --- a/problems/plus-one/README.md +++ b/problems/plus-one/README.md @@ -17,10 +17,11 @@

    You may assume the integer does not contain any leading zero, except the number 0 itself.

    +

     

    Example 1:

    -Input: [1,2,3]
    +Input: digits = [1,2,3]
     Output: [1,2,4]
     Explanation: The array represents the integer 123.
     
    @@ -28,11 +29,26 @@

    Example 2:

    -Input: [4,3,2,1]
    +Input: digits = [4,3,2,1]
     Output: [4,3,2,2]
     Explanation: The array represents the integer 4321.
     
    +

    Example 3:

    + +
    +Input: digits = [0]
    +Output: [1]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= digits.length <= 100
    • +
    • 0 <= digits[i] <= 9
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/powx-n/README.md b/problems/powx-n/README.md index d3c41f6ff..8dee24e5c 100644 --- a/problems/powx-n/README.md +++ b/problems/powx-n/README.md @@ -11,35 +11,38 @@ ## [50. Pow(x, n) (Medium)](https://leetcode.com/problems/powx-n "Pow(x, n)") -

    Implement pow(x, n), which calculates x raised to the power n (xn).

    +

    Implement pow(x, n), which calculates x raised to the power n (i.e. xn).

    +

     

    Example 1:

    -Input: 2.00000, 10
    +Input: x = 2.00000, n = 10
     Output: 1024.00000
     

    Example 2:

    -Input: 2.10000, 3
    +Input: x = 2.10000, n = 3
     Output: 9.26100
     

    Example 3:

    -Input: 2.00000, -2
    +Input: x = 2.00000, n = -2
     Output: 0.25000
     Explanation: 2-2 = 1/22 = 1/4 = 0.25
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • -100.0 < x < 100.0
    • -
    • n is a 32-bit signed integer, within the range [−231, 231 − 1]
    • +
    • -100.0 < x < 100.0
    • +
    • -231 <= n <= 231-1
    • +
    • -104 <= xn <= 104
    ### Related Topics diff --git a/problems/replace-words/README.md b/problems/replace-words/README.md index 28c1950e0..7194b9255 100644 --- a/problems/replace-words/README.md +++ b/problems/replace-words/README.md @@ -11,29 +11,42 @@ ## [648. Replace Words (Medium)](https://leetcode.com/problems/replace-words "单词替换") -

    In English, we have a concept called root, which can be followed by some other words to form another longer word - let's call this word successor. For example, the root an, followed by other, which can form another word another.

    +

    In English, we have a concept called root, which can be followed by some other words to form another longer word - let's call this word successor. For example, when the root "an" is followed by the successor word "other", we can form a new word "another".

    -

    Now, given a dictionary consisting of many roots and a sentence. You need to replace all the successor in the sentence with the root forming it. If a successor has many roots can form it, replace it with the root with the shortest length.

    +

    Given a dictionary consisting of many roots and a sentence consisting of words spearted by spaces. You need to replace all the successors in the sentence with the root forming it. If a successor can be replaced by more than one root, replace it with the root with the shortest length.

    -

    You need to output the sentence after the replacement.

    +

    Return the sentence after the replacement.

     

    Example 1:

    - -
    -Input: dict = ["cat","bat","rat"], sentence = "the cattle was rattled by the battery"
    -Output: "the cat was rat by the bat"
    +
    Input: dictionary = ["cat","bat","rat"], sentence = "the cattle was rattled by the battery"
    +Output: "the cat was rat by the bat"
    +

    Example 2:

    +
    Input: dictionary = ["a","b","c"], sentence = "aadsfasf absbs bbab cadsfafs"
    +Output: "a a b c"
    +

    Example 3:

    +
    Input: dictionary = ["a", "aa", "aaa", "aaaa"], sentence = "a aa a aaaa aaa aaa aaa aaaaaa bbb baba ababa"
    +Output: "a a a a a a a a bbb baba a"
    +

    Example 4:

    +
    Input: dictionary = ["catt","cat","bat","rat"], sentence = "the cattle was rattled by the battery"
    +Output: "the cat was rat by the bat"
    +

    Example 5:

    +
    Input: dictionary = ["ac","ab"], sentence = "it is abnormal that this solution is accepted"
    +Output: "it is ab that this solution is ac"
     
    -

     

    Constraints:

      -
    • The input will only have lower-case letters.
    • -
    • 1 <= dict.length <= 1000
    • -
    • 1 <= dict[i].length <= 100
    • -
    • 1 <= sentence words number <= 1000
    • -
    • 1 <= sentence words length <= 1000
    • +
    • 1 <= dictionary.length <= 1000
    • +
    • 1 <= dictionary[i].length <= 100
    • +
    • dictionary[i] consists of only lower-case letters.
    • +
    • 1 <= sentence.length <= 10^6
    • +
    • sentence consists of only lower-case letters ans spaces.
    • +
    • The number of words in sentence is in the range [1, 1000]
    • +
    • The length of each word in sentence is in the range [1, 1000]
    • +
    • Each two words in sentence will be separted by exactly one space.
    • +
    • sentence doesn't have leading or trailing spaces.
    ### Related Topics diff --git a/problems/reverse-bits/README.md b/problems/reverse-bits/README.md index 4dcbc9d08..43bb1f27a 100644 --- a/problems/reverse-bits/README.md +++ b/problems/reverse-bits/README.md @@ -45,6 +45,13 @@

    If this function is called many times, how would you optimize it?

    +

     

    +

    Constraints:

    + +
      +
    • The input must be a binary string of length = 32
    • +
    + ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/rising-temperature/README.md b/problems/rising-temperature/README.md index 64abfb622..6eec734af 100644 --- a/problems/rising-temperature/README.md +++ b/problems/rising-temperature/README.md @@ -11,26 +11,46 @@ ## [197. Rising Temperature (Easy)](https://leetcode.com/problems/rising-temperature "上升的温度") -

    Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates.

    +

    Table: Weather

    -+---------+------------------+------------------+
    -| Id(INT) | RecordDate(DATE) | Temperature(INT) |
    -+---------+------------------+------------------+
    -|       1 |       2015-01-01 |               10 |
    -|       2 |       2015-01-02 |               25 |
    -|       3 |       2015-01-03 |               20 |
    -|       4 |       2015-01-04 |               30 |
    -+---------+------------------+------------------+
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| id            | int     |
    +| recordDate    | date    |
    +| temperature   | int     |
    ++---------------+---------+
    +id is the primary key for this table.
    +This table contains information about the temperature in a certain day.
     
    -

    For example, return the following Ids for the above Weather table:

    +

     

    + +

    Write an SQL query to find all dates' id with higher temperature compared to its previous dates (yesterday).

    + +

    Return the result table in any order.

    + +

    The query result format is in the following example:

    +Weather
    ++----+------------+-------------+
    +| id | recordDate | Temperature |
    ++----+------------+-------------+
    +| 1  | 2015-01-01 | 10          |
    +| 2  | 2015-01-02 | 25          |
    +| 3  | 2015-01-03 | 20          |
    +| 4  | 2015-01-04 | 30          |
    ++----+------------+-------------+
    +
    +Result table:
     +----+
    -| Id |
    +| id |
     +----+
    -|  2 |
    -|  4 |
    +| 2  |
    +| 4  |
     +----+
    +In 2015-01-02, temperature was higher than the previous day (10 -> 25).
    +In 2015-01-04, temperature was higher than the previous day (30 -> 20).
     
    diff --git a/problems/set-matrix-zeroes/README.md b/problems/set-matrix-zeroes/README.md index 3ea8fd55c..e3e5342a6 100644 --- a/problems/set-matrix-zeroes/README.md +++ b/problems/set-matrix-zeroes/README.md @@ -11,48 +11,39 @@ ## [73. Set Matrix Zeroes (Medium)](https://leetcode.com/problems/set-matrix-zeroes "矩阵置零") -

    Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place.

    +

    Given an m x n matrix. If an element is 0, set its entire row and column to 0. Do it in-place.

    -

    Example 1:

    +

    Follow up:

    + +
      +
    • A straight forward solution using O(mn) space is probably a bad idea.
    • +
    • A simple improvement uses O(m + n) space, but still not the best solution.
    • +
    • Could you devise a constant space solution?
    • +
    +

     

    +

    Example 1:

    +
    -Input: 
    -[
    -  [1,1,1],
    -  [1,0,1],
    -  [1,1,1]
    -]
    -Output: 
    -[
    -  [1,0,1],
    -  [0,0,0],
    -  [1,0,1]
    -]
    +Input: matrix = [[1,1,1],[1,0,1],[1,1,1]]
    +Output: [[1,0,1],[0,0,0],[1,0,1]]
     

    Example 2:

    - +
    -Input: 
    -[
    -  [0,1,2,0],
    -  [3,4,5,2],
    -  [1,3,1,5]
    -]
    -Output: 
    -[
    -  [0,0,0,0],
    -  [0,4,5,0],
    -  [0,3,1,0]
    -]
    +Input: matrix = [[0,1,2,0],[3,4,5,2],[1,3,1,5]]
    +Output: [[0,0,0,0],[0,4,5,0],[0,3,1,0]]
     
    -

    Follow up:

    +

     

    +

    Constraints:

      -
    • A straight forward solution using O(mn) space is probably a bad idea.
    • -
    • A simple improvement uses O(m + n) space, but still not the best solution.
    • -
    • Could you devise a constant space solution?
    • +
    • m == matrix.length
    • +
    • n == matrix[0].length
    • +
    • 1 <= m, n <= 200
    • +
    • -10^9 <= matrix[i][j] <= 10^9
    ### Related Topics diff --git a/problems/single-number-iii/README.md b/problems/single-number-iii/README.md index 005a7c376..1052f6b57 100644 --- a/problems/single-number-iii/README.md +++ b/problems/single-number-iii/README.md @@ -11,20 +11,40 @@ ## [260. Single Number III (Medium)](https://leetcode.com/problems/single-number-iii "只出现一次的数字 III") -

    Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.

    +

    Given an integer array nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. You can return the answer in any order.

    -

    Example:

    +

    Follow up: Your algorithm should run in linear runtime complexity. Could you implement it using only constant space complexity?

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,1,3,2,5]
    +Output: [3,5]
    +Explanation:  [5, 3] is also a valid answer.
    +
    + +

    Example 2:

    + +
    +Input: nums = [-1,0]
    +Output: [-1,0]
    +
    + +

    Example 3:

    -Input:  [1,2,1,3,2,5]
    -Output: [3,5]
    +Input: nums = [0,1] +Output: [1,0] +
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. The order of the result is not important. So in the above example, [5, 3] is also correct.
    2. -
    3. Your algorithm should run in linear runtime complexity. Could you implement it using only constant space complexity?
    4. -
    +
      +
    • 1 <= nums.length <= 30000
    • +
    •  Each integer in nums will appear twice, only two integers will appear once.
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/split-array-largest-sum/README.md b/problems/split-array-largest-sum/README.md index 923fd0683..db339b0b2 100644 --- a/problems/split-array-largest-sum/README.md +++ b/problems/split-array-largest-sum/README.md @@ -11,32 +11,44 @@ ## [410. Split Array Largest Sum (Hard)](https://leetcode.com/problems/split-array-largest-sum "分割数组的最大值") -

    Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among these m subarrays. -

    +

    Given an array nums which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays.

    -

    Note:
    -If n is the length of array, assume the following constraints are satisfied: -

      -
    • 1 ≤ n ≤ 1000
    • -
    • 1 ≤ m ≤ min(50, n)
    • -
    -

    +

    Write an algorithm to minimize the largest sum among these m subarrays.

    + +

     

    +

    Example 1:

    -

    Examples:

    -Input:
    -nums = [7,2,5,10,8]
    -m = 2
    +Input: nums = [7,2,5,10,8], m = 2
    +Output: 18
    +Explanation:
    +There are four ways to split nums into two subarrays.
    +The best way is to split it into [7,2,5] and [10,8],
    +where the largest sum among the two subarrays is only 18.
    +
    -Output: -18 +

    Example 2:

    -Explanation: -There are four ways to split nums into two subarrays. -The best way is to split it into [7,2,5] and [10,8], -where the largest sum among the two subarrays is only 18. +
    +Input: nums = [1,2,3,4,5], m = 2
    +Output: 9
     
    -

    + +

    Example 3:

    + +
    +Input: nums = [1,4,4], m = 3
    +Output: 4
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • 0 <= nums[i] <= 106
    • +
    • 1 <= m <= min(50, nums.length)
    • +
    ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/stone-game-v/README.md b/problems/stone-game-v/README.md new file mode 100644 index 000000000..e2ad8245b --- /dev/null +++ b/problems/stone-game-v/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../find-latest-group-of-size-m "Find Latest Group of Size M") +                 +Next > + +## [1563. Stone Game V (Hard)](https://leetcode.com/problems/stone-game-v "石子游戏 V") + +

    There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.

    + +

    In each round of the game, Alice divides the row into two non-empty rows (i.e. left row and right row), then Bob calculates the value of each row which is the sum of the values of all the stones in this row. Bob throws away the row which has the maximum value, and Alice's score increases by the value of the remaining row. If the value of the two rows are equal, Bob lets Alice decide which row will be thrown away. The next round starts with the remaining row.

    + +

    The game ends when there is only one stone remaining. Alice's is initially zero.

    + +

    Return the maximum score that Alice can obtain.

    + +

     

    +

    Example 1:

    + +
    +Input: stoneValue = [6,2,3,4,5,5]
    +Output: 18
    +Explanation: In the first round, Alice divides the row to [6,2,3], [4,5,5]. The left row has the value 11 and the right row has value 14. Bob throws away the right row and Alice's score is now 11.
    +In the second round Alice divides the row to [6], [2,3]. This time Bob throws away the left row and Alice's score becomes 16 (11 + 5).
    +The last round Alice has only one choice to divide the row which is [2], [3]. Bob throws away the right row and Alice's score is now 18 (16 + 2). The game ends because only one stone is remaining in the row.
    +
    + +

    Example 2:

    + +
    +Input: stoneValue = [7,7,7,7,7,7,7]
    +Output: 28
    +
    + +

    Example 3:

    + +
    +Input: stoneValue = [4]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= stoneValue.length <= 500
    • +
    • 1 <= stoneValue[i] <= 10^6
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +We need to try all possible divisions for the current row to get the max score. +
    + +
    +Hint 2 +As calculating all possible divisions will lead us to calculate some sub-problems more than once, we need to think of dynamic programming. +
    diff --git a/problems/strings-differ-by-one-character/README.md b/problems/strings-differ-by-one-character/README.md new file mode 100644 index 000000000..974be134a --- /dev/null +++ b/problems/strings-differ-by-one-character/README.md @@ -0,0 +1,25 @@ + + + + + + + +[< Previous](../minimum-number-of-days-to-eat-n-oranges "Minimum Number of Days to Eat N Oranges") +                 +[Next >](../bank-account-summary "Bank Account Summary") + +## [1554. Strings Differ by One Character (Medium)](https://leetcode.com/problems/strings-differ-by-one-character "") + + + +### Hints +
    +Hint 1 +BruteForce, check all pairs and verify if they differ in one character. O(n^2 * m) where n is the number of words and m is the length of each string. +
    + +
    +Hint 2 +O(m^2 * n), Use hashset, to insert all possible combinations adding a character "*". For example: If dict[i] = "abc", insert ("*bc", "a*c" and "ab*"). +
    diff --git a/problems/thousand-separator/README.md b/problems/thousand-separator/README.md new file mode 100644 index 000000000..40056c61b --- /dev/null +++ b/problems/thousand-separator/README.md @@ -0,0 +1,59 @@ + + + + + + + +[< Previous](../bank-account-summary "Bank Account Summary") +                 +[Next >](../minimum-number-of-vertices-to-reach-all-nodes "Minimum Number of Vertices to Reach All Nodes") + +## [1556. Thousand Separator (Easy)](https://leetcode.com/problems/thousand-separator "千位分隔数") + +

    Given an integer n, add a dot (".") as the thousands separator and return it in string format.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 987
    +Output: "987"
    +
    + +

    Example 2:

    + +
    +Input: n = 1234
    +Output: "1.234"
    +
    + +

    Example 3:

    + +
    +Input: n = 123456789
    +Output: "123.456.789"
    +
    + +

    Example 4:

    + +
    +Input: n = 0
    +Output: "0"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= n < 2^31
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Scan from the back of the integer and use dots to connect blocks with length 3 except the last block. +
    diff --git a/readme/1-300.md b/readme/1-300.md index 8d008f9fe..5ef8bd213 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -344,7 +344,7 @@ LeetCode Problems' Solutions | 272 | [Closest Binary Search Tree Value II](https://leetcode.com/problems/closest-binary-search-tree-value-ii "最接近的二叉搜索树值 II") 🔒 | [Go](../problems/closest-binary-search-tree-value-ii) | Hard | | 273 | [Integer to English Words](https://leetcode.com/problems/integer-to-english-words "整数转换英文表示") | [Go](../problems/integer-to-english-words) | Hard | | 274 | [H-Index](https://leetcode.com/problems/h-index "H 指数") | [Go](../problems/h-index) | Medium | -| 275 | [H-Index II](https://leetcode.com/problems/h-index-ii "H指数 II") | [Go](../problems/h-index-ii) | Medium | +| 275 | [H-Index II](https://leetcode.com/problems/h-index-ii "H 指数 II") | [Go](../problems/h-index-ii) | Medium | | 276 | [Paint Fence](https://leetcode.com/problems/paint-fence "栅栏涂色") 🔒 | [Go](../problems/paint-fence) | Easy | | 277 | [Find the Celebrity](https://leetcode.com/problems/find-the-celebrity "搜寻名人") 🔒 | [Go](../problems/find-the-celebrity) | Medium | | 278 | [First Bad Version](https://leetcode.com/problems/first-bad-version "第一个错误的版本") | [Go](../problems/first-bad-version) | Easy | diff --git a/tag/array/README.md b/tag/array/README.md index f5d1ecca2..fc2c8b06b 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1560 | [圆形赛道上经过次数最多的扇区](../../problems/most-visited-sector-in-a-circular-track) | [[数组](../array/README.md)] | Easy | | 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1550 | [存在连续三个奇数的数组](../../problems/three-consecutive-odds) | [[数组](../array/README.md)] | Easy | | 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 6a61cce43..94ef29994 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1562 | [查找大小为 M 的最新分组](../../problems/find-latest-group-of-size-m) | [[二分查找](../binary-search/README.md)] | Medium | | 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1533 | [Find the Index of the Large Integer](../../problems/find-the-index-of-the-large-integer) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | | 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | @@ -77,7 +78,7 @@ | 300 | [最长上升子序列](../../problems/longest-increasing-subsequence) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 278 | [第一个错误的版本](../../problems/first-bad-version) | [[二分查找](../binary-search/README.md)] | Easy | -| 275 | [H指数 II](../../problems/h-index-ii) | [[二分查找](../binary-search/README.md)] | Medium | +| 275 | [H 指数 II](../../problems/h-index-ii) | [[二分查找](../binary-search/README.md)] | Medium | | 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | | 230 | [二叉搜索树中第K小的元素](../../problems/kth-smallest-element-in-a-bst) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 7bd02307c..95f002895 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | | 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index f3ca6a0e7..cb84ce8e9 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1563 | [石子游戏 V](../../problems/stone-game-v) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1553 | [吃掉 N 个橘子的最少天数](../../problems/minimum-number-of-days-to-eat-n-oranges) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1548 | [The Most Similar Path in a Graph](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1547 | [切棍子的最小成本](../../problems/minimum-cost-to-cut-a-stick) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index f2d1a1872..037e715e3 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1557 | [可以到达所有点的最少点数目](../../problems/minimum-number-of-vertices-to-reach-all-nodes) | [[图](../graph/README.md)] | Medium | | 1548 | [The Most Similar Path in a Graph](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] | Medium | | 1494 | [并行课程 II](../../problems/parallel-courses-ii) | [[图](../graph/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 5d2ea69a2..cd0742ae3 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1558 | [得到目标数组的最少函数调用次数](../../problems/minimum-numbers-of-function-calls-to-make-target-array) | [[贪心算法](../greedy/README.md)] | Medium | | 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心算法](../greedy/README.md)] | Medium | | 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心算法](../greedy/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index 7641d5c25..19d07d70a 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1561 | [你可以获得的最大硬币数目](../../problems/maximum-number-of-coins-you-can-get) | [[排序](../sort/README.md)] | Medium | | 1528 | [重新排列字符串](../../problems/shuffle-string) | [[排序](../sort/README.md)] | Easy | | 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index 131511648..a5c9fad5b 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1556 | [千位分隔数](../../problems/thousand-separator) | [[字符串](../string/README.md)] | Easy | | 1545 | [找出第 N 个二进制字符串中的第 K 位](../../problems/find-kth-bit-in-nth-binary-string) | [[字符串](../string/README.md)] | Medium | | 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | | 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Hard | From 90cf3989b3797f778e870f0d7f2e17fe05a9b695 Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 2 Sep 2020 10:19:16 +0800 Subject: [PATCH 096/145] A: new --- README.md | 16 ++- problems/bank-account-summary/README.md | 2 +- .../bank-account-summary/mysql_schemas.sql | 10 +- .../binary-tree-inorder-traversal/README.md | 2 +- .../binary-tree-postorder-traversal/README.md | 55 ++++++++--- .../README.md | 57 +++++------ problems/course-schedule-ii/README.md | 53 ++++++---- .../README.md | 78 +++++++++++++++ problems/diameter-of-n-ary-tree/README.md | 2 +- .../README.md | 44 ++++----- problems/group-anagrams/README.md | 36 ++++--- problems/implement-magic-dictionary/README.md | 15 +-- .../implement-rand10-using-rand7/README.md | 63 ++++-------- problems/longest-absolute-file-path/README.md | 61 +++++++----- .../README.md | 84 ++++++++++++++++ problems/minimum-height-trees/README.md | 59 ++++++----- .../README.md | 99 +++++++++++++++++++ .../n-ary-tree-postorder-traversal/README.md | 2 +- .../number-of-segments-in-a-string/README.md | 44 +++++++-- .../README.md | 96 ++++++++++++++++++ problems/palindrome-pairs/README.md | 35 ++++--- problems/patients-with-a-condition/README.md | 2 +- .../peak-index-in-a-mountain-array/README.md | 54 +++++----- problems/prefix-and-suffix-search/README.md | 46 +++++---- .../put-boxes-into-the-warehouse-i/README.md | 23 +++++ problems/repeated-string-match/README.md | 46 +++++++-- problems/repeated-substring-pattern/README.md | 2 +- problems/rotate-image/README.md | 65 ++++++------ problems/scramble-string/README.md | 84 ++++++++-------- .../README.md | 56 ++++++++--- .../README.md | 48 +++++---- problems/stone-game-v/README.md | 2 +- .../strings-differ-by-one-character/README.md | 2 +- problems/task-scheduler/README.md | 7 +- .../the-most-recent-three-orders/README.md | 2 +- problems/two-city-scheduling/README.md | 39 +++++--- problems/two-sum/README.md | 38 +++++-- .../README.md | 14 +++ .../mysql_schemas.sql | 12 +++ problems/valid-parentheses/README.md | 23 +++-- readme/1-300.md | 2 +- readme/601-900.md | 2 +- readme/901-1200.md | 2 +- tag/README.md | 4 +- tag/array/README.md | 1 + tag/dynamic-programming/README.md | 1 + tag/greedy/README.md | 5 +- tag/stack/README.md | 2 +- tag/string/README.md | 2 +- tag/tags.json | 10 +- tag/tree/README.md | 2 +- 51 files changed, 1059 insertions(+), 452 deletions(-) create mode 100644 problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md create mode 100644 problems/maximum-length-of-subarray-with-positive-product/README.md create mode 100644 problems/minimum-number-of-days-to-disconnect-island/README.md create mode 100644 problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md create mode 100644 problems/put-boxes-into-the-warehouse-i/README.md create mode 100644 problems/unique-orders-and-customers-per-month/README.md create mode 100644 problems/unique-orders-and-customers-per-month/mysql_schemas.sql diff --git a/README.md b/README.md index eb9ca7433..3e41820b9 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,12 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1569 | [Number of Ways to Reorder Array to Get Same BST](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst "将子数组重新排序得到同一个二叉查找树的方案数") | [Go](problems/number-of-ways-to-reorder-array-to-get-same-bst) | Hard | +| 1568 | [Minimum Number of Days to Disconnect Island](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数") | [Go](problems/minimum-number-of-days-to-disconnect-island) | Hard | +| 1567 | [Maximum Length of Subarray With Positive Product](https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product "乘积为正数的最长子数组长度") | [Go](problems/maximum-length-of-subarray-with-positive-product) | Medium | +| 1566 | [Detect Pattern of Length M Repeated K or More Times](https://leetcode.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times "重复至少 K 次且长度为 M 的模式") | [Go](problems/detect-pattern-of-length-m-repeated-k-or-more-times) | Easy | +| 1565 | [Unique Orders and Customers Per Month](https://leetcode.com/problems/unique-orders-and-customers-per-month) 🔒 | [MySQL](problems/unique-orders-and-customers-per-month) | Easy | +| 1564 | [Put Boxes Into the Warehouse I](https://leetcode.com/problems/put-boxes-into-the-warehouse-i) 🔒 | [Go](problems/put-boxes-into-the-warehouse-i) | Medium | | 1563 | [Stone Game V](https://leetcode.com/problems/stone-game-v "石子游戏 V") | [Go](problems/stone-game-v) | Hard | | 1562 | [Find Latest Group of Size M](https://leetcode.com/problems/find-latest-group-of-size-m "查找大小为 M 的最新分组") | [Go](problems/find-latest-group-of-size-m) | Medium | | 1561 | [Maximum Number of Coins You Can Get](https://leetcode.com/problems/maximum-number-of-coins-you-can-get "你可以获得的最大硬币数目") | [Go](problems/maximum-number-of-coins-you-can-get) | Medium | @@ -78,8 +84,8 @@ LeetCode Problems' Solutions | 1558 | [Minimum Numbers of Function Calls to Make Target Array](https://leetcode.com/problems/minimum-numbers-of-function-calls-to-make-target-array "得到目标数组的最少函数调用次数") | [Go](problems/minimum-numbers-of-function-calls-to-make-target-array) | Medium | | 1557 | [Minimum Number of Vertices to Reach All Nodes](https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes "可以到达所有点的最少点数目") | [Go](problems/minimum-number-of-vertices-to-reach-all-nodes) | Medium | | 1556 | [Thousand Separator](https://leetcode.com/problems/thousand-separator "千位分隔数") | [Go](problems/thousand-separator) | Easy | -| 1555 | [Bank Account Summary](https://leetcode.com/problems/bank-account-summary) 🔒 | [MySQL](problems/bank-account-summary) | Medium | -| 1554 | [Strings Differ by One Character](https://leetcode.com/problems/strings-differ-by-one-character) 🔒 | [Go](problems/strings-differ-by-one-character) | Medium | +| 1555 | [Bank Account Summary](https://leetcode.com/problems/bank-account-summary "银行账户概要") 🔒 | [MySQL](problems/bank-account-summary) | Medium | +| 1554 | [Strings Differ by One Character](https://leetcode.com/problems/strings-differ-by-one-character "只有一个不同字符的字符串") 🔒 | [Go](problems/strings-differ-by-one-character) | Medium | | 1553 | [Minimum Number of Days to Eat N Oranges](https://leetcode.com/problems/minimum-number-of-days-to-eat-n-oranges "吃掉 N 个橘子的最少天数") | [Go](problems/minimum-number-of-days-to-eat-n-oranges) | Hard | | 1552 | [Magnetic Force Between Two Balls](https://leetcode.com/problems/magnetic-force-between-two-balls "两球之间的磁力") | [Go](problems/magnetic-force-between-two-balls) | Medium | | 1551 | [Minimum Operations to Make Array Equal](https://leetcode.com/problems/minimum-operations-to-make-array-equal "使数组中所有元素相等的最小操作数") | [Go](problems/minimum-operations-to-make-array-equal) | Medium | @@ -101,17 +107,17 @@ LeetCode Problems' Solutions | 1535 | [Find the Winner of an Array Game](https://leetcode.com/problems/find-the-winner-of-an-array-game "找出数组游戏的赢家") | [Go](problems/find-the-winner-of-an-array-game) | Medium | | 1534 | [Count Good Triplets](https://leetcode.com/problems/count-good-triplets "统计好三元组") | [Go](problems/count-good-triplets) | Easy | | 1533 | [Find the Index of the Large Integer](https://leetcode.com/problems/find-the-index-of-the-large-integer) 🔒 | [Go](problems/find-the-index-of-the-large-integer) | Medium | -| 1532 | [The Most Recent Three Orders](https://leetcode.com/problems/the-most-recent-three-orders) 🔒 | [MySQL](problems/the-most-recent-three-orders) | Medium | +| 1532 | [The Most Recent Three Orders](https://leetcode.com/problems/the-most-recent-three-orders "最近的三笔订单") 🔒 | [MySQL](problems/the-most-recent-three-orders) | Medium | | 1531 | [String Compression II](https://leetcode.com/problems/string-compression-ii "压缩字符串 II") | [Go](problems/string-compression-ii) | Hard | | 1530 | [Number of Good Leaf Nodes Pairs](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs "好叶子节点对的数量") | [Go](problems/number-of-good-leaf-nodes-pairs) | Medium | | 1529 | [Bulb Switcher IV](https://leetcode.com/problems/bulb-switcher-iv "灯泡开关 IV") | [Go](problems/bulb-switcher-iv) | Medium | | 1528 | [Shuffle String](https://leetcode.com/problems/shuffle-string "重新排列字符串") | [Go](problems/shuffle-string) | Easy | -| 1527 | [Patients With a Condition](https://leetcode.com/problems/patients-with-a-condition) 🔒 | [MySQL](problems/patients-with-a-condition) | Easy | +| 1527 | [Patients With a Condition](https://leetcode.com/problems/patients-with-a-condition "患某种疾病的患者") 🔒 | [MySQL](problems/patients-with-a-condition) | Easy | | 1526 | [Minimum Number of Increments on Subarrays to Form a Target Array](https://leetcode.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array "形成目标数组的子数组最少增加次数") | [Go](problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | Hard | | 1525 | [Number of Good Ways to Split a String](https://leetcode.com/problems/number-of-good-ways-to-split-a-string "字符串的好分割数目") | [Go](problems/number-of-good-ways-to-split-a-string) | Medium | | 1524 | [Number of Sub-arrays With Odd Sum](https://leetcode.com/problems/number-of-sub-arrays-with-odd-sum "和为奇数的子数组数目") | [Go](problems/number-of-sub-arrays-with-odd-sum) | Medium | | 1523 | [Count Odd Numbers in an Interval Range](https://leetcode.com/problems/count-odd-numbers-in-an-interval-range "在区间范围内统计奇数数目") | [Go](problems/count-odd-numbers-in-an-interval-range) | Easy | -| 1522 | [Diameter of N-Ary Tree](https://leetcode.com/problems/diameter-of-n-ary-tree) 🔒 | [Go](problems/diameter-of-n-ary-tree) | Medium | +| 1522 | [Diameter of N-Ary Tree](https://leetcode.com/problems/diameter-of-n-ary-tree "N 叉树的直径") 🔒 | [Go](problems/diameter-of-n-ary-tree) | Medium | | 1521 | [Find a Value of a Mysterious Function Closest to Target](https://leetcode.com/problems/find-a-value-of-a-mysterious-function-closest-to-target "找到最接近目标值的函数值") | [Go](problems/find-a-value-of-a-mysterious-function-closest-to-target) | Hard | | 1520 | [Maximum Number of Non-Overlapping Substrings](https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings "最多的不重叠子字符串") | [Go](problems/maximum-number-of-non-overlapping-substrings) | Hard | | 1519 | [Number of Nodes in the Sub-Tree With the Same Label](https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label "子树中标签相同的节点数") | [Go](problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | Medium | diff --git a/problems/bank-account-summary/README.md b/problems/bank-account-summary/README.md index f01d2802b..541695d7c 100644 --- a/problems/bank-account-summary/README.md +++ b/problems/bank-account-summary/README.md @@ -9,6 +9,6 @@                  [Next >](../thousand-separator "Thousand Separator") -## [1555. Bank Account Summary (Medium)](https://leetcode.com/problems/bank-account-summary "") +## [1555. Bank Account Summary (Medium)](https://leetcode.com/problems/bank-account-summary "银行账户概要") diff --git a/problems/bank-account-summary/mysql_schemas.sql b/problems/bank-account-summary/mysql_schemas.sql index aad88fe3b..2397d1a15 100644 --- a/problems/bank-account-summary/mysql_schemas.sql +++ b/problems/bank-account-summary/mysql_schemas.sql @@ -1,12 +1,12 @@ Create table If Not Exists Users (user_id int, user_name varchar(20), credit int) ; -Create table If Not Exists Transaction (trans_id int, paid_by int, paid_to int, amount int, transacted_on date); +Create table If Not Exists Transactions (trans_id int, paid_by int, paid_to int, amount int, transacted_on date); Truncate table Users; insert into Users (user_id, user_name, credit) values ('1', 'Moustafa', '100'); insert into Users (user_id, user_name, credit) values ('2', 'Jonathan', '200'); insert into Users (user_id, user_name, credit) values ('3', 'Winston', '10000'); insert into Users (user_id, user_name, credit) values ('4', 'Luis', '800'); -Truncate table Transaction; -insert into Transaction (trans_id, paid_by, paid_to, amount, transacted_on) values ('1', '1', '3', '400', '2020-08-01'); -insert into Transaction (trans_id, paid_by, paid_to, amount, transacted_on) values ('2', '3', '2', '500', '2020-08-02'); -insert into Transaction (trans_id, paid_by, paid_to, amount, transacted_on) values ('3', '2', '1', '200', '2020-08-03'); +Truncate table Transactions; +insert into Transactions (trans_id, paid_by, paid_to, amount, transacted_on) values ('1', '1', '3', '400', '2020-08-01'); +insert into Transactions (trans_id, paid_by, paid_to, amount, transacted_on) values ('2', '3', '2', '500', '2020-08-02'); +insert into Transactions (trans_id, paid_by, paid_to, amount, transacted_on) values ('3', '2', '1', '200', '2020-08-03'); diff --git a/problems/binary-tree-inorder-traversal/README.md b/problems/binary-tree-inorder-traversal/README.md index 541392d4b..6cfc09190 100644 --- a/problems/binary-tree-inorder-traversal/README.md +++ b/problems/binary-tree-inorder-traversal/README.md @@ -35,7 +35,7 @@ ### Similar Questions 1. [Validate Binary Search Tree](../validate-binary-search-tree) (Medium) 1. [Binary Tree Preorder Traversal](../binary-tree-preorder-traversal) (Medium) - 1. [Binary Tree Postorder Traversal](../binary-tree-postorder-traversal) (Hard) + 1. [Binary Tree Postorder Traversal](../binary-tree-postorder-traversal) (Medium) 1. [Binary Search Tree Iterator](../binary-search-tree-iterator) (Medium) 1. [Kth Smallest Element in a BST](../kth-smallest-element-in-a-bst) (Medium) 1. [Closest Binary Search Tree Value II](../closest-binary-search-tree-value-ii) (Hard) diff --git a/problems/binary-tree-postorder-traversal/README.md b/problems/binary-tree-postorder-traversal/README.md index 3b6c1107b..5795c624a 100644 --- a/problems/binary-tree-postorder-traversal/README.md +++ b/problems/binary-tree-postorder-traversal/README.md @@ -9,24 +9,55 @@                  [Next >](../lru-cache "LRU Cache") -## [145. Binary Tree Postorder Traversal (Hard)](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历") +## [145. Binary Tree Postorder Traversal (Medium)](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历") -

    Given a binary tree, return the postorder traversal of its nodes' values.

    +

    Given the root of a binary tree, return the postorder traversal of its nodes' values.

    -

    Example:

    +

    Follow up: Recursive solution is trivial, could you do it iteratively?

    +

     

    +

    Example 1:

    +
    -Input: [1,null,2,3]
    -   1
    -    \
    -     2
    -    /
    -   3
    -
    -Output: [3,2,1]
    +Input: root = [1,null,2,3]
    +Output: [3,2,1]
     
    -

    Follow up: Recursive solution is trivial, could you do it iteratively?

    +

    Example 2:

    + +
    +Input: root = []
    +Output: []
    +
    + +

    Example 3:

    + +
    +Input: root = [1]
    +Output: [1]
    +
    + +

    Example 4:

    + +
    +Input: root = [1,2]
    +Output: [2,1]
    +
    + +

    Example 5:

    + +
    +Input: root = [1,null,2]
    +Output: [2,1]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of the nodes in the tree is in the range [0, 100].
    • +
    • -100 <= Node.val <= 100
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/check-if-word-is-valid-after-substitutions/README.md b/problems/check-if-word-is-valid-after-substitutions/README.md index c52d7b9f1..0a3bd0945 100644 --- a/problems/check-if-word-is-valid-after-substitutions/README.md +++ b/problems/check-if-word-is-valid-after-substitutions/README.md @@ -11,71 +11,60 @@ ## [1003. Check If Word Is Valid After Substitutions (Medium)](https://leetcode.com/problems/check-if-word-is-valid-after-substitutions "检查替换后的词是否有效") -

    We are given that the string "abc" is valid.

    +

    We can say that a string is valid if it follows one of the three following cases:

    -

    From any valid string V, we may split V into two pieces X and Y such that X + Y (X concatenated with Y) is equal to V.  (X or Y may be empty.)  Then, X + "abc" + Y is also valid.

    +
      +
    • An empty string "" is valid.
    • +
    • The string "abc" is also valid.
    • +
    • Any string in the form "a" + str + "bc", "ab" + str + "c", str + "abc" or "abc" + str where str is a valid string is also considered a valid string.
    • +
    -

    If for example S = "abc", then examples of valid strings are: "abc", "aabcbc", "abcabc", "abcabcababcc".  Examples of invalid strings are: "abccba", "ab", "cababc", "bac".

    +

    For example, "", "abc""aabcbc""abcabc" and "abcabcababcc" are all valid strings, while "abccba""ab", "cababc" and "bac" are not valid strings.

    -

    Return true if and only if the given string S is valid.

    +

    Given a string s, return true if it is a valid string, otherwise, return false.

     

    -

    Example 1:

    -Input: "aabcbc"
    -Output: true
    +Input: s = "aabcbc"
    +Output: true
     Explanation: 
     We start with the valid string "abc".
     Then we can insert another "abc" between "a" and "bc", resulting in "a" + "abc" + "bc" which is "aabcbc".
     
    -

    Example 2:

    -Input: "abcabcababcc"
    -Output: true
    +Input: s = "abcabcababcc"
    +Output: true
     Explanation: 
     "abcabcabc" is valid after consecutive insertings of "abc".
     Then we can insert "abc" before the last letter, resulting in "abcabcab" + "abc" + "c" which is "abcabcababcc".
     
    -

    Example 3:

    -Input: "abccba"
    -Output: false
    +Input: s = "abccba"
    +Output: false
     
    -

    Example 4:

    -Input: "cababc"
    -Output: false
    +Input: s = "cababc" +Output: false +

     

    - - - - -

    Note:

    - -
      -
    1. 1 <= S.length <= 20000
    2. -
    3. S[i] is 'a', 'b', or 'c'
    4. -
    - -
    -
    -
    -
     
    -
    -
    -
    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 2 * 104
    • +
    • s[i] is 'a', 'b', or 'c'
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/course-schedule-ii/README.md b/problems/course-schedule-ii/README.md index fa7145a47..6bd7f93e8 100644 --- a/problems/course-schedule-ii/README.md +++ b/problems/course-schedule-ii/README.md @@ -11,37 +11,50 @@ ## [210. Course Schedule II (Medium)](https://leetcode.com/problems/course-schedule-ii "课程表 II") -

    There are a total of n courses you have to take, labeled from 0 to n-1.

    +

    There are a total of n courses you have to take labelled from 0 to n - 1.

    -

    Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1]

    +

    Some courses may have prerequisites, for example, if prerequisites[i] = [ai, bi] this means you must take the course bi before the course ai.

    -

    Given the total number of courses and a list of prerequisite pairs, return the ordering of courses you should take to finish all courses.

    +

    Given the total number of courses numCourses and a list of the prerequisite pairs, return the ordering of courses you should take to finish all courses.

    -

    There may be multiple correct orders, you just need to return one of them. If it is impossible to finish all courses, return an empty array.

    +

    If there are many valid answers, return any of them. If it is impossible to finish all courses, return an empty array.

    +

     

    Example 1:

    -Input: 2, [[1,0]] 
    -Output: [0,1]
    -Explanation: There are a total of 2 courses to take. To take course 1 you should have finished   
    -             course 0. So the correct course order is [0,1] .
    +Input: numCourses = 2, prerequisites = [[1,0]] +Output: [0,1] +Explanation: There are a total of 2 courses to take. To take course 1 you should have finished course 0. So the correct course order is [0,1]. +

    Example 2:

    -Input: 4, [[1,0],[2,0],[3,1],[3,2]]
    -Output: [0,1,2,3] or [0,2,1,3]
    -Explanation: There are a total of 4 courses to take. To take course 3 you should have finished both     
    -             courses 1 and 2. Both courses 1 and 2 should be taken after you finished course 0. 
    -             So one correct course order is [0,1,2,3]. Another correct ordering is [0,2,1,3] .
    - -

    Note:

    - -
      -
    1. The input prerequisites is a graph represented by a list of edges, not adjacency matrices. Read more about how a graph is represented.
    2. -
    3. You may assume that there are no duplicate edges in the input prerequisites.
    4. -
    +Input: numCourses = 4, prerequisites = [[1,0],[2,0],[3,1],[3,2]] +Output: [0,2,1,3] +Explanation: There are a total of 4 courses to take. To take course 3 you should have finished both courses 1 and 2. Both courses 1 and 2 should be taken after you finished course 0. +So one correct course order is [0,1,2,3]. Another correct ordering is [0,2,1,3]. + + +

    Example 3:

    + +
    +Input: numCourses = 1, prerequisites = []
    +Output: [0]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= numCourses <= 2000
    • +
    • 0 <= prerequisites.length <= numCourses * (numCourses - 1)
    • +
    • prerequisites[i].length == 2
    • +
    • 0 <= ai, bi < numCourses
    • +
    • ai != bi
    • +
    • All the pairs [ai, bi] are distinct.
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md b/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md new file mode 100644 index 000000000..16d50f6f0 --- /dev/null +++ b/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../unique-orders-and-customers-per-month "Unique Orders and Customers Per Month") +                 +[Next >](../maximum-length-of-subarray-with-positive-product "Maximum Length of Subarray With Positive Product") + +## [1566. Detect Pattern of Length M Repeated K or More Times (Easy)](https://leetcode.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times "重复至少 K 次且长度为 M 的模式") + +

    Given an array of positive integers arr,  find a pattern of length m that is repeated k or more times.

    + +

    A pattern is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times consecutively without overlapping. A pattern is defined by its length and the number of repetitions.

    + +

    Return true if there exists a pattern of length m that is repeated k or more times, otherwise return false.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [1,2,4,4,4,4], m = 1, k = 3
    +Output: true
    +Explanation: The pattern (4) of length 1 is repeated 4 consecutive times. Notice that pattern can be repeated k or more times but not less.
    +
    + +

    Example 2:

    + +
    +Input: arr = [1,2,1,2,1,1,1,3], m = 2, k = 2
    +Output: true
    +Explanation: The pattern (1,2) of length 2 is repeated 2 consecutive times. Another valid pattern (2,1) is also repeated 2 times.
    +
    + +

    Example 3:

    + +
    +Input: arr = [1,2,1,2,1,3], m = 2, k = 3
    +Output: false
    +Explanation: The pattern (1,2) is of length 2 but is repeated only 2 times. There is no pattern of length 2 that is repeated 3 or more times.
    +
    + +

    Example 4:

    + +
    +Input: arr = [1,2,3,1,2], m = 2, k = 2
    +Output: false
    +Explanation: Notice that the pattern (1,2) exists twice but not consecutively, so it doesn't count.
    +
    + +

    Example 5:

    + +
    +Input: arr = [2,2,2,2], m = 2, k = 3
    +Output: false
    +Explanation: The only pattern of length 2 is (2,2) however it's repeated only twice. Notice that we do not count overlapping repetitions.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= arr.length <= 100
    • +
    • 1 <= arr[i] <= 100
    • +
    • 1 <= m <= 100
    • +
    • 2 <= k <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Use a three-layer loop to check all possible patterns by iterating through all possible starting positions, all indexes less than m, and if the character at the index is repeated k times. +
    diff --git a/problems/diameter-of-n-ary-tree/README.md b/problems/diameter-of-n-ary-tree/README.md index d158fee18..eb5b75419 100644 --- a/problems/diameter-of-n-ary-tree/README.md +++ b/problems/diameter-of-n-ary-tree/README.md @@ -9,7 +9,7 @@                  [Next >](../count-odd-numbers-in-an-interval-range "Count Odd Numbers in an Interval Range") -## [1522. Diameter of N-Ary Tree (Medium)](https://leetcode.com/problems/diameter-of-n-ary-tree "") +## [1522. Diameter of N-Ary Tree (Medium)](https://leetcode.com/problems/diameter-of-n-ary-tree "N 叉树的直径") diff --git a/problems/greatest-common-divisor-of-strings/README.md b/problems/greatest-common-divisor-of-strings/README.md index 1b3cb2011..b1384f1ba 100644 --- a/problems/greatest-common-divisor-of-strings/README.md +++ b/problems/greatest-common-divisor-of-strings/README.md @@ -11,42 +11,32 @@ ## [1071. Greatest Common Divisor of Strings (Easy)](https://leetcode.com/problems/greatest-common-divisor-of-strings "字符串的最大公因子") -

    For strings S and T, we say "T divides S" if and only if S = T + ... + T  (T concatenated with itself 1 or more times)

    +

    For two strings s and t, we say "t divides s" if and only if s = t + ... + t  (t concatenated with itself 1 or more times)

    -

    Return the largest string X such that X divides str1 and X divides str2.

    +

    Given two strings str1 and str2, return the largest string x such that x divides both str1 and str2.

     

    -

    Example 1:

    - -
    -Input: str1 = "ABCABC", str2 = "ABC"
    -Output: "ABC"
    -
    - -

    Example 2:

    - -
    -Input: str1 = "ABABAB", str2 = "ABAB"
    -Output: "AB"
    +
    Input: str1 = "ABCABC", str2 = "ABC"
    +Output: "ABC"
    +

    Example 2:

    +
    Input: str1 = "ABABAB", str2 = "ABAB"
    +Output: "AB"
    +

    Example 3:

    +
    Input: str1 = "LEET", str2 = "CODE"
    +Output: ""
    +

    Example 4:

    +
    Input: str1 = "ABCDEF", str2 = "ABC"
    +Output: ""
     
    - -

    Example 3:

    - -
    -Input: str1 = "LEET", str2 = "CODE"
    -Output: ""
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= str1.length <= 1000
      • 1 <= str2.length <= 1000
      • -
      • str1[i] and str2[i] are English uppercase letters.
      • -
    +
  • str1 and str2 consist of English uppercase letters.
  • + ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/group-anagrams/README.md b/problems/group-anagrams/README.md index 3032aad0f..94de2d95c 100644 --- a/problems/group-anagrams/README.md +++ b/problems/group-anagrams/README.md @@ -11,24 +11,28 @@ ## [49. Group Anagrams (Medium)](https://leetcode.com/problems/group-anagrams "字母异位词分组") -

    Given an array of strings, group anagrams together.

    - -

    Example:

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

    Note:

    +

    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.

    + +

     

    +

    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"]]
    +
    +

     

    +

    Constraints:

      -
    • All inputs will be in lowercase.
    • -
    • The order of your output does not matter.
    • +
    • 1 <= strs.length <= 104
    • +
    • 0 <= strs[i].length <= 100
    • +
    • strs[i] consists of lower-case English letters.
    ### Related Topics diff --git a/problems/implement-magic-dictionary/README.md b/problems/implement-magic-dictionary/README.md index 1d4558e09..334552aee 100644 --- a/problems/implement-magic-dictionary/README.md +++ b/problems/implement-magic-dictionary/README.md @@ -11,14 +11,14 @@ ## [676. Implement Magic Dictionary (Medium)](https://leetcode.com/problems/implement-magic-dictionary "实现一个魔法字典") -

    We want to implement a data structure that will be intialized with a list of distinct strings, then you will be given another string and you should find if you can change exactly one letter of this string to match any string in the data structure.

    +

    Design a data structure that is initialized with a list of different words. Provided a string, you should determine if you can change exactly one character in this string to match any word in the data structure.

    Implement the MagicDictionary class:

    • MagicDictionary() Initializes the object.
    • void buildDict(String[] dictionary) Sets the data structure with an array of distinct strings dictionary.
    • -
    • bool search(String searchWord) Returns true if you can change exactly one character in word to match any string in the data structure, otherwise returns false.
    • +
    • bool search(String searchWord) Returns true if you can change exactly one character in searchWord to match any string in the data structure, otherwise returns false.

     

    @@ -45,12 +45,13 @@ magicDictionary.search("leetcoded"); // return False
    • 1 <= dictionary.length <= 100
    • -
    • 1 <= dictionary[i],length <= 100
    • -
    • dictionary[i] consist of only lower-case English letters.
    • -
    • All strings in dictionary are distinct.
    • +
    • 1 <= dictionary[i].length <= 100
    • +
    • dictionary[i] consists of only lower-case English letters.
    • +
    • All the strings in dictionary are distinct.
    • 1 <= searchWord.length <= 100
    • -
    • searchWord consist of only lower-case English letters.
    • -
    • At most 100 calls will be made to search and buildDict,
    • +
    • searchWord consists of only lower-case English letters.
    • +
    • buildDict will be called only once before search.
    • +
    • At most 100 calls will be made to search.
    ### Related Topics diff --git a/problems/implement-rand10-using-rand7/README.md b/problems/implement-rand10-using-rand7/README.md index 321d10d26..09d1e69a8 100644 --- a/problems/implement-rand10-using-rand7/README.md +++ b/problems/implement-rand10-using-rand7/README.md @@ -11,49 +11,10 @@ ## [470. Implement Rand10() Using Rand7() (Medium)](https://leetcode.com/problems/implement-rand10-using-rand7 "用 Rand7() 实现 Rand10()") -

    Given a function rand7 which generates a uniform random integer in the range 1 to 7, write a function rand10 which generates a uniform random integer in the range 1 to 10.

    - -

    Do NOT use system's Math.random().

    - -
      -
    - -

     

    +

    Given the API rand7 which generates a uniform random integer in the range 1 to 7, write a function rand10 which generates a uniform random integer in the range 1 to 10. You can only call the API rand7 and you shouldn't call any other API. Please don't use the system's Math.random().

    -

    Example 1:

    - -
    -Input: 1
    -Output: [7]
    -
    - -
    -

    Example 2:

    - -
    -Input: 2
    -Output: [8,4]
    -
    - -
    -

    Example 3:

    - -
    -Input: 3
    -Output: [8,1,10]
    -
    - -

     

    - -

    Note:

    - -
      -
    1. rand7 is predefined.
    2. -
    3. Each testcase has one argument: n, the number of times that rand10 is called.
    4. -
    - -

     

    +

    Notice that Each test case has one argument n, the number of times that your implemented function rand10 will be called while testing. 

    Follow up:

    @@ -62,8 +23,24 @@
  • Could you minimize the number of calls to rand7()?
  • -
    -
    + +

     

    +

    Example 1:

    +
    Input: n = 1
    +Output: [2]
    +

    Example 2:

    +
    Input: n = 2
    +Output: [2,8]
    +

    Example 3:

    +
    Input: n = 3
    +Output: [3,8,10]
    +
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 105
    • +
    ### Related Topics [[Random](../../tag/random/README.md)] diff --git a/problems/longest-absolute-file-path/README.md b/problems/longest-absolute-file-path/README.md index d1da1f8bd..196c29bea 100644 --- a/problems/longest-absolute-file-path/README.md +++ b/problems/longest-absolute-file-path/README.md @@ -11,42 +11,49 @@ ## [388. Longest Absolute File Path (Medium)](https://leetcode.com/problems/longest-absolute-file-path "文件的最长绝对路径") -

    Suppose we abstract our file system by a string in the following manner:

    +

    Suppose we have the file system represented in the following picture:

    -

    The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents:

    +

    -
    dir
    -    subdir1
    -    subdir2
    -        file.ext
    -
    +

    We will represent the file system as a string where "\n\t" mean a subdirectory of the main directory, "\n\t\t" means a subdirectory of the subdirectory of the main directory and so on. Each folder will be represented as a string of letters and/or digits. Each file will be in the form "s1.s2" where s1 and s2 are strings of letters and/or digits.

    + +

    For example, the file system above is represented as "dir\n\tsubdir1\n\t\tfile1.ext\n\t\tsubsubdir1\n\tsubdir2\n\t\tsubsubdir2\n\t\t\tfile2.ext".

    -

    The directory dir contains an empty sub-directory subdir1 and a sub-directory subdir2 containing a file file.ext.

    +

    Given a string input representing the file system in the explained format, return the length of the longest absolute path to a file in the abstracted file system. If there is no file in the system, return 0.

    -

    The string "dir\n\tsubdir1\n\t\tfile1.ext\n\t\tsubsubdir1\n\tsubdir2\n\t\tsubsubdir2\n\t\t\tfile2.ext" represents:

    +

     

    +

    Example 1:

    + +
    +Input: input = "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext"
    +Output: 20
    +Explanation: We have only one file and its path is "dir/subdir2/file.ext" of length 20.
    +The path "dir/subdir1" doesn't contain any files.
    +
    -
    dir
    -    subdir1
    -        file1.ext
    -        subsubdir1
    -    subdir2
    -        subsubdir2
    -            file2.ext
    +

    Example 2:

    + +
    +Input: input = "dir\n\tsubdir1\n\t\tfile1.ext\n\t\tsubsubdir1\n\tsubdir2\n\t\tsubsubdir2\n\t\t\tfile2.ext"
    +Output: 32
    +Explanation: We have two files:
    +"dir/subdir1/file1.ext" of length 21
    +"dir/subdir2/subsubdir2/file2.ext" of length 32.
    +We return 32 since it is the longest path.
     
    -

    The directory dir contains two sub-directories subdir1 and subdir2. subdir1 contains a file file1.ext and an empty second-level sub-directory subsubdir1. subdir2 contains a second-level sub-directory subsubdir2 containing a file file2.ext.

    +

    Example 3:

    -

    We are interested in finding the longest (number of characters) absolute path to a file within our file system. For example, in the second example above, the longest absolute path is "dir/subdir2/subsubdir2/file2.ext", and its length is 32 (not including the double quotes).

    +
    +Input: input = "a"
    +Output: 0
    +Explanation: We don't have any files.
    +
    -

    Given a string representing the file system in the above format, return the length of the longest absolute path to file in the abstracted file system. If there is no file in the system, return 0.

    +

     

    +

    Constraints:

    -

    Note:

      -
    • The name of a file contains at least a . and an extension.
    • -
    • The name of a directory or sub-directory will not contain a ..
    • +
    • 1 <= input.length <= 104
    • +
    • input may contain lower-case or upper-case English letters, a new line character '\n', a tab character '\t', a dot '.', a space ' ' or digits.
    -

    - -

    Time complexity required: O(n) where n is the size of the input string.

    - -

    Notice that a/aa/aaa/file1.txt is not the longest file path, if there is another path aaaaaaaaaaaaaaaaaaaaa/sth.png.

    diff --git a/problems/maximum-length-of-subarray-with-positive-product/README.md b/problems/maximum-length-of-subarray-with-positive-product/README.md new file mode 100644 index 000000000..4c3f1c5af --- /dev/null +++ b/problems/maximum-length-of-subarray-with-positive-product/README.md @@ -0,0 +1,84 @@ + + + + + + + +[< Previous](../detect-pattern-of-length-m-repeated-k-or-more-times "Detect Pattern of Length M Repeated K or More Times") +                 +[Next >](../minimum-number-of-days-to-disconnect-island "Minimum Number of Days to Disconnect Island") + +## [1567. Maximum Length of Subarray With Positive Product (Medium)](https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product "乘积为正数的最长子数组长度") + +

    Given an array of integers nums, find the maximum length of a subarray where the product of all its elements is positive.

    + +

    A subarray of an array is a consecutive sequence of zero or more values taken out of that array.

    + +

    Return the maximum length of a subarray with positive product.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,-2,-3,4]
    +Output: 4
    +Explanation: The array nums already has a positive product of 24.
    +
    + +

    Example 2:

    + +
    +Input: nums = [0,1,-2,-3,-4]
    +Output: 3
    +Explanation: The longest subarray with positive product is [1,-2,-3] which has a product of 6.
    +Notice that we cannot include 0 in the subarray since that'll make the product 0 which is not positive.
    + +

    Example 3:

    + +
    +Input: nums = [-1,-2,-3,0,1]
    +Output: 2
    +Explanation: The longest subarray with positive product is [-1,-2] or [-2,-3].
    +
    + +

    Example 4:

    + +
    +Input: nums = [-1,2]
    +Output: 1
    +
    + +

    Example 5:

    + +
    +Input: nums = [1,2,3,5,-6,4,0,10]
    +Output: 4
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 10^5
    • +
    • -10^9 <= nums[i] <= 10^9
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Split the whole array into subarrays by zeroes since a subarray with positive product cannot contain any zero. +
    + +
    +Hint 2 +If the subarray has even number of negative numbers, the whole subarray has positive product. +
    + +
    +Hint 3 +Otherwise, we have two choices, either - remove the prefix till the first negative element in this subarray, or remove the suffix starting from the last negative element in this subarray. +
    diff --git a/problems/minimum-height-trees/README.md b/problems/minimum-height-trees/README.md index 6202f1d64..6bf1fcac9 100644 --- a/problems/minimum-height-trees/README.md +++ b/problems/minimum-height-trees/README.md @@ -11,47 +11,54 @@ ## [310. Minimum Height Trees (Medium)](https://leetcode.com/problems/minimum-height-trees "最小高度树") -

    For an undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called minimum height trees (MHTs). Given such a graph, write a function to find all the MHTs and return a list of their root labels.

    +

    A tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles is a tree.

    -

    Format
    -The graph contains n nodes which are labeled from 0 to n - 1. You will be given the number n and a list of undirected edges (each edge is a pair of labels).

    +

    Given a tree of n nodes and n - 1 edges where edges[i] = [ai, bi] indicates that there is an undirected edge between the two nodes ai and bi in the tree, you can choose any node of the tree as the root. When you select a node x as the root, the result tree has height h. Among all possible rooted trees, those with minimum height (i.e. min(h))  are called minimum height trees (MHTs).

    -

    You can assume that no duplicate edges will appear in edges. Since all edges are undirected, [0, 1] is the same as [1, 0] and thus will not appear together in edges.

    +

    Return a list of the root labels of all the MHTs. You can return the answer in any order.

    -

    Example 1 :

    +

    The height of a rooted tree is the number of edges on the longest downward path between the root and a leaf.

    +

     

    +

    Example 1:

    +
    -Input: n = 4, edges = [[1, 0], [1, 2], [1, 3]]
    -
    -        0
    -        |
    -        1
    -       / \
    -      2   3 
    +Input: n = 4, edges = [[1,0],[1,2],[1,3]]
    +Output: [1]
    +Explanation: As shown, the height of the tree is 1 when the root is one which is the only MHT.
    +
    -Output: [1] +

    Example 2:

    + +
    +Input: n = 6, edges = [[3,0],[3,1],[3,2],[3,4],[5,4]]
    +Output: [3,4]
     
    -

    Example 2 :

    +

    Example 3:

    -Input: n = 6, edges = [[0, 3], [1, 3], [2, 3], [4, 3], [5, 4]]
    +Input: n = 1, edges = []
    +Output: [0]
    +
    - 0 1 2 - \ | / - 3 - | - 4 - | - 5 +

    Example 4:

    -Output: [3, 4]
    +
    +Input: n = 2, edges = [[0,1]]
    +Output: [0,1]
    +
    -

    Note:

    +

     

    +

    Constraints:

      -
    • According to the definition of tree on Wikipedia: “a tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles is a tree.”
    • -
    • The height of a rooted tree is the number of edges on the longest downward path between the root and a leaf.
    • +
    • 1 <= n <= 2 * 104
    • +
    • edges.length == n - 1
    • +
    • 0 <= ai, bi < n
    • +
    • ai != bi
    • +
    • All the pairs (ai, bi) are distinct.
    • +
    • The given input is guaranteed to be a tree.
    ### Related Topics diff --git a/problems/minimum-number-of-days-to-disconnect-island/README.md b/problems/minimum-number-of-days-to-disconnect-island/README.md new file mode 100644 index 000000000..76e8456fe --- /dev/null +++ b/problems/minimum-number-of-days-to-disconnect-island/README.md @@ -0,0 +1,99 @@ + + + + + + + +[< Previous](../maximum-length-of-subarray-with-positive-product "Maximum Length of Subarray With Positive Product") +                 +[Next >](../number-of-ways-to-reorder-array-to-get-same-bst "Number of Ways to Reorder Array to Get Same BST") + +## [1568. Minimum Number of Days to Disconnect Island (Medium)](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数") + +

    Given a 2D grid consisting of 1s (land) and 0s (water).  An island is a maximal 4-directionally (horizontal or vertical) connected group of 1s.

    + +

    The grid is said to be connected if we have exactly one island, otherwise is said disconnected.

    + +

    In one day, we are allowed to change any single land cell (1) into a water cell (0).

    + +

    Return the minimum number of days to disconnect the grid.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: grid = [[0,1,1,0],[0,1,1,0],[0,0,0,0]]
    +Output: 2
    +Explanation: We need at least 2 days to get a disconnected grid.
    +Change land grid[1][1] and grid[0][2] to water and get 2 disconnected island.
    +
    + +

    Example 2:

    + +
    +Input: grid = [[1,1]]
    +Output: 2
    +Explanation: Grid of full water is also disconnected ([[1,1]] -> [[0,0]]), 0 islands.
    +
    + +

    Example 3:

    + +
    +Input: grid = [[1,0,1,0]]
    +Output: 0
    +
    + +

    Example 4:

    + +
    +Input: grid = [[1,1,0,1,1],
    +               [1,1,1,1,1],
    +               [1,1,0,1,1],
    +               [1,1,0,1,1]]
    +Output: 1
    +
    + +

    Example 5:

    + +
    +Input: grid = [[1,1,0,1,1],
    +               [1,1,1,1,1],
    +               [1,1,0,1,1],
    +               [1,1,1,1,1]]
    +Output: 2
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= grid.length, grid[i].length <= 30
    • +
    • grid[i][j] is 0 or 1.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Return 0 if the grid is already disconnected. +
    + +
    +Hint 2 +Return 1 if changing a single land to water disconnect the island. +
    + +
    +Hint 3 +Otherwise return 2. +
    + +
    +Hint 4 +We can disconnect the grid within at most 2 days. +
    diff --git a/problems/n-ary-tree-postorder-traversal/README.md b/problems/n-ary-tree-postorder-traversal/README.md index bab91f0cb..9c86ee0ad 100644 --- a/problems/n-ary-tree-postorder-traversal/README.md +++ b/problems/n-ary-tree-postorder-traversal/README.md @@ -52,6 +52,6 @@ [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Binary Tree Postorder Traversal](../binary-tree-postorder-traversal) (Hard) + 1. [Binary Tree Postorder Traversal](../binary-tree-postorder-traversal) (Medium) 1. [N-ary Tree Level Order Traversal](../n-ary-tree-level-order-traversal) (Medium) 1. [N-ary Tree Preorder Traversal](../n-ary-tree-preorder-traversal) (Easy) diff --git a/problems/number-of-segments-in-a-string/README.md b/problems/number-of-segments-in-a-string/README.md index 099f18bfb..75512a97e 100644 --- a/problems/number-of-segments-in-a-string/README.md +++ b/problems/number-of-segments-in-a-string/README.md @@ -11,16 +11,48 @@ ## [434. Number of Segments in a String (Easy)](https://leetcode.com/problems/number-of-segments-in-a-string "字符串中的单词数") -

    Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.

    +

    You are given a string s, return the number of segments in the string

    -

    Please note that the string does not contain any non-printable characters.

    +

    A segment is defined to be a contiguous sequence of non-space characters.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "Hello, my name is John"
    +Output: 5
    +Explanation: The five segments are ["Hello,", "my", "name", "is", "John"]
    +
    + +

    Example 2:

    -

    Example:

    -Input: "Hello, my name is John"
    -Output: 5
    +Input: s = "Hello"
    +Output: 1
     
    -

    + +

    Example 3:

    + +
    +Input: s = "love live! mu'sic forever"
    +Output: 4
    +
    + +

    Example 4:

    + +
    +Input: s = ""
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= s.length <= 300
    • +
    • s consists of lower-case and upper-case English letters, digits or one of the following characters "!@#$%^&*()_+-=',.:".
    • +
    • The only space character in s is ' '.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md b/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md new file mode 100644 index 000000000..93305364d --- /dev/null +++ b/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md @@ -0,0 +1,96 @@ + + + + + + + +[< Previous](../minimum-number-of-days-to-disconnect-island "Minimum Number of Days to Disconnect Island") +                 +Next > + +## [1569. Number of Ways to Reorder Array to Get Same BST (Hard)](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst "将子数组重新排序得到同一个二叉查找树的方案数") + +

    Given an array nums that represents a permutation of integers from 1 to n. We are going to construct a binary search tree (BST) by inserting the elements of nums in order into an initially empty BST. Find the number of different ways to reorder nums so that the constructed BST is identical to that formed from the original array nums.

    + +

    For example, given nums = [2,1,3], we will have 2 as the root, 1 as a left child, and 3 as a right child. The array [2,3,1] also yields the same BST but [3,2,1] yields a different BST.

    + +

    Return the number of ways to reorder nums such that the BST formed is identical to the original BST formed from nums.

    + +

    Since the answer may be very large, return it modulo 10^9 + 7.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: nums = [2,1,3]
    +Output: 1
    +Explanation: We can reorder nums to be [2,3,1] which will yield the same BST. There are no other ways to reorder nums which will yield the same BST.
    +
    + +

    Example 2:

    + +

    + +
    +Input: nums = [3,4,5,1,2]
    +Output: 5
    +Explanation: The following 5 arrays will yield the same BST: 
    +[3,1,2,4,5]
    +[3,1,4,2,5]
    +[3,1,4,5,2]
    +[3,4,1,2,5]
    +[3,4,1,5,2]
    +
    + +

    Example 3:

    + +

    + +
    +Input: nums = [1,2,3]
    +Output: 0
    +Explanation: There are no other orderings of nums that will yield the same BST.
    +
    + +

    Example 4:

    + +

    + +
    +Input: nums = [3,1,2,5,4,6]
    +Output: 19
    +
    + +

    Example 5:

    + +
    +Input: nums = [9,4,2,1,3,6,5,7,8,14,11,10,12,13,16,15,17,18]
    +Output: 216212978
    +Explanation: The number of ways to reorder nums to get the same BST is 3216212999. Taking this number modulo 10^9 + 7 gives 216212978.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • 1 <= nums[i] <= nums.length
    • +
    • All integers in nums are distinct.
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Use a divide and conquer strategy. +
    + +
    +Hint 2 +The first number will always be the root. Consider the numbers smaller and larger than the root separately. When merging the results together, how many ways can you order x elements in x+y positions? +
    diff --git a/problems/palindrome-pairs/README.md b/problems/palindrome-pairs/README.md index a1005a77d..b3c4ecc2e 100644 --- a/problems/palindrome-pairs/README.md +++ b/problems/palindrome-pairs/README.md @@ -11,27 +11,40 @@ ## [336. Palindrome Pairs (Hard)](https://leetcode.com/problems/palindrome-pairs "回文对") -

    Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome.

    +

    Given a list of unique words, return all the pairs of the distinct indices (i, j) in the given list, so that the concatenation of the two words words[i] + words[j] is a palindrome.

    +

     

    Example 1:

    -
    -Input: ["abcd","dcba","lls","s","sssll"]
    -Output: [[0,1],[1,0],[3,2],[2,4]] 
    -Explanation: The palindromes are ["dcbaabcd","abcddcba","slls","llssssll"]
    +Input: words = ["abcd","dcba","lls","s","sssll"]
    +Output: [[0,1],[1,0],[3,2],[2,4]]
    +Explanation: The palindromes are ["dcbaabcd","abcddcba","slls","llssssll"]
     
    -

    Example 2:

    -Input: ["bat","tab","cat"]
    -Output: [[0,1],[1,0]] 
    -Explanation: The palindromes are ["battab","tabbat"]
    +Input: words = ["bat","tab","cat"]
    +Output: [[0,1],[1,0]]
    +Explanation: The palindromes are ["battab","tabbat"]
     
    -
    -
    + +

    Example 3:

    + +
    +Input: words = ["a",""]
    +Output: [[0,1],[1,0]]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 5000
    • +
    • 0 <= words[i] <= 300
    • +
    • words[i] consists of lower-case English letters.
    • +
    ### Related Topics [[Trie](../../tag/trie/README.md)] diff --git a/problems/patients-with-a-condition/README.md b/problems/patients-with-a-condition/README.md index 21c3af3af..74001dd54 100644 --- a/problems/patients-with-a-condition/README.md +++ b/problems/patients-with-a-condition/README.md @@ -9,6 +9,6 @@                  [Next >](../shuffle-string "Shuffle String") -## [1527. Patients With a Condition (Easy)](https://leetcode.com/problems/patients-with-a-condition "") +## [1527. Patients With a Condition (Easy)](https://leetcode.com/problems/patients-with-a-condition "患某种疾病的患者") diff --git a/problems/peak-index-in-a-mountain-array/README.md b/problems/peak-index-in-a-mountain-array/README.md index 7d7bb7613..9435eeae1 100644 --- a/problems/peak-index-in-a-mountain-array/README.md +++ b/problems/peak-index-in-a-mountain-array/README.md @@ -11,37 +11,45 @@ ## [852. Peak Index in a Mountain Array (Easy)](https://leetcode.com/problems/peak-index-in-a-mountain-array "山脉数组的峰顶索引") -

    Let's call an array A a mountain if the following properties hold:

    +

    Let's call an array arr a mountain if the following properties hold:

      -
    • A.length >= 3
    • -
    • There exists some 0 < i < A.length - 1 such that A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1]
    • +
    • arr.length >= 3
    • +
    • There exists some i with 0 < i < arr.length - 1 such that: +
        +
      • arr[0] < arr[1] < ... arr[i-1] < arr[i]
      • +
      • arr[i] > arr[i+1] > ... > arr[arr.length - 1]
      • +
      +
    -

    Given an array that is definitely a mountain, return any i such that A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1].

    +

    Given an integer array arr that is guaranteed to be a mountain, return any i such that arr[0] < arr[1] < ... arr[i - 1] < arr[i] > arr[i + 1] > ... > arr[arr.length - 1].

    +

     

    Example 1:

    - -
    -Input: [0,1,0]
    -Output: 1
    +
    Input: arr = [0,1,0]
    +Output: 1
    +

    Example 2:

    +
    Input: arr = [0,2,1,0]
    +Output: 1
    +

    Example 3:

    +
    Input: arr = [0,10,5,2]
    +Output: 1
    +

    Example 4:

    +
    Input: arr = [3,4,5,1]
    +Output: 2
    +

    Example 5:

    +
    Input: arr = [24,69,100,99,79,78,67,36,26,19]
    +Output: 2
     
    +

     

    +

    Constraints:

    -
    -

    Example 2:

    - -
    -Input: [0,2,1,0]
    -Output: 1
    -
    - -

    Note:

    - -
      -
    1. 3 <= A.length <= 10000
    2. -
    3. 0 <= A[i] <= 10^6
    4. -
    5. A is a mountain, as defined above.
    6. -
    +
      +
    • 3 <= arr.length <= 104
    • +
    • 0 <= arr[i] <= 106
    • +
    • arr is guaranteed to be a mountain array.
    • +
    ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/prefix-and-suffix-search/README.md b/problems/prefix-and-suffix-search/README.md index 321939389..1b09db9e2 100644 --- a/problems/prefix-and-suffix-search/README.md +++ b/problems/prefix-and-suffix-search/README.md @@ -11,32 +11,40 @@ ## [745. Prefix and Suffix Search (Hard)](https://leetcode.com/problems/prefix-and-suffix-search "前缀和后缀搜索") -

    Given many words, words[i] has weight i.

    +

    Design a special dictionary which has some words and allows you to search the words in it by a prefix and a suffix.

    -

    Design a class WordFilter that supports one function, WordFilter.f(String prefix, String suffix). It will return the word with given prefix and suffix with maximum weight. If no word exists, return -1.

    +

    Implement the WordFilter class:

    -

    Examples:

    - -
    -Input:
    -WordFilter(["apple"])
    -WordFilter.f("a", "e") // returns 0
    -WordFilter.f("b", "") // returns -1
    -
    +
      +
    • WordFilter(string[] words) Initializes the object with the words in the dictionary.
    • +
    • f(string prefix, string suffix) Returns the index of the word in the dictionary which has the prefix prefix and the suffix suffix. If there is more than one valid index, return the largest of them. If there is no such word in the dictionary, return -1.
    • +

     

    +

    Example 1:

    -

    Note:

    - -
      -
    1. words has length in range [1, 15000].
    2. -
    3. For each test case, up to words.length queries WordFilter.f may be made.
    4. -
    5. words[i] has length in range [1, 10].
    6. -
    7. prefix, suffix have lengths in range [0, 10].
    8. -
    9. words[i] and prefix, suffix queries consist of lowercase letters only.
    10. -
    +
    +Input
    +["WordFilter", "f"]
    +[[["apple"]], ["a", "e"]]
    +Output
    +[null, 0]
    +
    +Explanation
    +WordFilter wordFilter = new WordFilter(["apple"]);
    +wordFilter.f("a", "e"); // return 0, because the word at index 0 has prefix = "a" and suffix = 'e".
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 15000
    • +
    • 1 <= words[i].length <= 10
    • +
    • 1 <= prefix.length, suffix.length <= 10
    • +
    • words[i], prefix and suffix consist of lower-case English letters only.
    • +
    • At most 15000 calls will be made to the function f.
    • +
    ### Related Topics [[Trie](../../tag/trie/README.md)] diff --git a/problems/put-boxes-into-the-warehouse-i/README.md b/problems/put-boxes-into-the-warehouse-i/README.md new file mode 100644 index 000000000..f110826d1 --- /dev/null +++ b/problems/put-boxes-into-the-warehouse-i/README.md @@ -0,0 +1,23 @@ + + + + + + + +[< Previous](../stone-game-v "Stone Game V") +                 +[Next >](../unique-orders-and-customers-per-month "Unique Orders and Customers Per Month") + +## [1564. Put Boxes Into the Warehouse I (Medium)](https://leetcode.com/problems/put-boxes-into-the-warehouse-i "") + + + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Sort the boxes in ascending order, try to process the box with the smallest height first. +
    diff --git a/problems/repeated-string-match/README.md b/problems/repeated-string-match/README.md index 3415e0f8b..7d9fb4798 100644 --- a/problems/repeated-string-match/README.md +++ b/problems/repeated-string-match/README.md @@ -9,16 +9,50 @@                  [Next >](../longest-univalue-path "Longest Univalue Path") -## [686. Repeated String Match (Easy)](https://leetcode.com/problems/repeated-string-match "重复叠加字符串匹配") +## [686. Repeated String Match (Medium)](https://leetcode.com/problems/repeated-string-match "重复叠加字符串匹配") -

    Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1.

    +

    Given two strings a and b, return the minimum number of times you should repeat the string a so that string b is a substring of it. If it's impossible for b​​​​​​ to be a substring of a after repeating it, return -1.

    -

    For example, with A = "abcd" and B = "cdabcdab".

    +

    Notice: string "abc" repeated 0 times is "",  repeated 1 time is "abc" and repeated 2 times is "abcabc".

    -

    Return 3, because by repeating A three times (“abcdabcdabcd”), B is a substring of it; and B is not a substring of A repeated two times ("abcdabcd").

    +

     

    +

    Example 1:

    -

    Note:
    -The length of A and B will be between 1 and 10000.

    +
    +Input: a = "abcd", b = "cdabcdab"
    +Output: 3
    +Explanation: We return 3 because by repeating a three times "abcdabcdabcd", b is a substring of it.
    +
    + +

    Example 2:

    + +
    +Input: a = "a", b = "aa"
    +Output: 2
    +
    + +

    Example 3:

    + +
    +Input: a = "a", b = "a"
    +Output: 1
    +
    + +

    Example 4:

    + +
    +Input: a = "abc", b = "wxyz"
    +Output: -1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= a.length <= 104
    • +
    • 1 <= b.length <= 104
    • +
    • a and b consist of lower-case English letters.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/repeated-substring-pattern/README.md b/problems/repeated-substring-pattern/README.md index 2b436c0d0..0f8fa3f30 100644 --- a/problems/repeated-substring-pattern/README.md +++ b/problems/repeated-substring-pattern/README.md @@ -43,4 +43,4 @@ ### Similar Questions 1. [Implement strStr()](../implement-strstr) (Easy) - 1. [Repeated String Match](../repeated-string-match) (Easy) + 1. [Repeated String Match](../repeated-string-match) (Medium) diff --git a/problems/rotate-image/README.md b/problems/rotate-image/README.md index 49da7441d..3c20d79da 100644 --- a/problems/rotate-image/README.md +++ b/problems/rotate-image/README.md @@ -11,51 +11,48 @@ ## [48. Rotate Image (Medium)](https://leetcode.com/problems/rotate-image "旋转图像") -

    You are given an n x n 2D matrix representing an image.

    - -

    Rotate the image by 90 degrees (clockwise).

    - -

    Note:

    +

    You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise).

    You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.

    +

     

    Example 1:

    - +
    -Given input matrix = 
    -[
    -  [1,2,3],
    -  [4,5,6],
    -  [7,8,9]
    -],
    -
    -rotate the input matrix in-place such that it becomes:
    -[
    -  [7,4,1],
    -  [8,5,2],
    -  [9,6,3]
    -]
    +Input: matrix = [[1,2,3],[4,5,6],[7,8,9]]
    +Output: [[7,4,1],[8,5,2],[9,6,3]]
     

    Example 2:

    + +
    +Input: matrix = [[5,1,9,11],[2,4,8,10],[13,3,6,7],[15,14,12,16]]
    +Output: [[15,13,2,5],[14,3,4,1],[12,6,8,9],[16,7,10,11]]
    +
    + +

    Example 3:

    -Given input matrix =
    -[
    -  [ 5, 1, 9,11],
    -  [ 2, 4, 8,10],
    -  [13, 3, 6, 7],
    -  [15,14,12,16]
    -], 
    -
    -rotate the input matrix in-place such that it becomes:
    -[
    -  [15,13, 2, 5],
    -  [14, 3, 4, 1],
    -  [12, 6, 8, 9],
    -  [16, 7,10,11]
    -]
    +Input: matrix = [[1]]
    +Output: [[1]]
     
    +

    Example 4:

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

     

    +

    Constraints:

    + +
      +
    • matrix.length == n
    • +
    • matrix[i].length == n
    • +
    • 1 <= n <= 20
    • +
    • -1000 <= matrix[i][j] <= 1000
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/scramble-string/README.md b/problems/scramble-string/README.md index f28f7e09b..3685dc7d7 100644 --- a/problems/scramble-string/README.md +++ b/problems/scramble-string/README.md @@ -11,64 +11,60 @@ ## [87. Scramble String (Hard)](https://leetcode.com/problems/scramble-string "扰乱字符串") -

    Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.

    - -

    Below is one possible representation of s1 = "great":

    - -
    -    great
    -   /    \
    -  gr    eat
    - / \    /  \
    -g   r  e   at
    -           / \
    -          a   t
    -
    - -

    To scramble the string, we may choose any non-leaf node and swap its two children.

    - -

    For example, if we choose the node "gr" and swap its two children, it produces a scrambled string "rgeat".

    +

    We can scramble a string s to get a string t using the following algorithm:

    + +
      +
    1. If the length of the string is 1, stop.
    2. +
    3. If the length of the string is > 1, do the following: +
        +
      • Split the string into 2 non-empty substrings at a random index, i.e. if the string is s, divide it to x and y where s = x + y.
      • +
      • Randomly, decide to swap the two substrings or to keep them in the same order. i.e. after this step, s may become s = x + y or s = y + x.
      • +
      • Apply step 1 recursively on each of the two substrings x and y.
      • +
      +
    4. +
    + +

    Given two strings s1 and s2 of the same length, return true if s2 is a scrambled string of s1, otherwise, return false.

    + +

     

    +

    Example 1:

    -    rgeat
    -   /    \
    -  rg    eat
    - / \    /  \
    -r   g  e   at
    -           / \
    -          a   t
    +Input: s1 = "great", s2 = "rgeat"
    +Output: true
    +Explanation: One possible scenario applied on s1 is:
    +"great" --> "gr/eat" // divide at random index.
    +"gr/eat" --> "gr/eat" // random decision is not to swap the two substrings and keep them in order.
    +"gr/eat" --> "g/r / e/at" // apply the same algorith recursively on both substrings. divide at ranom index each of them.
    +"g/r / e/at" --> "r/g / e/at" // random decision was to swap the first substing and to keep the second substring in the same order.
    +"r/g / e/at" --> "r/g / e/ a/t" // again apply the algorithm recursively, divide "at" to "a/t".
    +"r/g / e/ a/t" --> "r/g / e/ a/t" // random decision is to keep both substings in the same order.
    +The algorithm stops now and the result string is "rgeat" which is s2.
    +As there is one possible scenario that led s1 to be scrambled to s2, we return true.
     
    -

    We say that "rgeat" is a scrambled string of "great".

    - -

    Similarly, if we continue to swap the children of nodes "eat" and "at", it produces a scrambled string "rgtae".

    +

    Example 2:

    -    rgtae
    -   /    \
    -  rg    tae
    - / \    /  \
    -r   g  ta  e
    -       / \
    -      t   a
    +Input: s1 = "abcde", s2 = "caebd"
    +Output: false
     
    -

    We say that "rgtae" is a scrambled string of "great".

    - -

    Given two strings s1 and s2 of the same length, determine if s2 is a scrambled string of s1.

    - -

    Example 1:

    +

    Example 3:

    -Input: s1 = "great", s2 = "rgeat"
    +Input: s1 = "a", s2 = "a"
     Output: true
     
    -

    Example 2:

    +

     

    +

    Constraints:

    -
    -Input: s1 = "abcde", s2 = "caebd"
    -Output: false
    +
      +
    • s1.length == s2.length
    • +
    • 1 <= s1.length <= 30
    • +
    • s1 and s2 consist of lower-case English letters.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/smallest-range-covering-elements-from-k-lists/README.md b/problems/smallest-range-covering-elements-from-k-lists/README.md index ff1d523e8..854759a9e 100644 --- a/problems/smallest-range-covering-elements-from-k-lists/README.md +++ b/problems/smallest-range-covering-elements-from-k-lists/README.md @@ -11,32 +11,60 @@ ## [632. Smallest Range Covering Elements from K Lists (Hard)](https://leetcode.com/problems/smallest-range-covering-elements-from-k-lists "最小区间") -

    You have k lists of sorted integers in ascending order. Find the smallest range that includes at least one number from each of the k lists.

    +

    You have k lists of sorted integers in non-decreasing order. Find the smallest range that includes at least one number from each of the k lists.

    -

    We define the range [a,b] is smaller than range [c,d] if b-a < d-c or a < c if b-a == d-c.

    +

    We define the range [a, b] is smaller than range [c, d] if b - a < d - c or a < c if b - a == d - c.

     

    - -

    Example 1:

    +

    Example 1:

    -Input: [[4,10,15,24,26], [0,9,12,20], [5,18,22,30]]
    -Output: [20,24]
    -Explanation: 
    +Input: nums = [[4,10,15,24,26],[0,9,12,20],[5,18,22,30]]
    +Output: [20,24]
    +Explanation: 
     List 1: [4, 10, 15, 24,26], 24 is in range [20,24].
     List 2: [0, 9, 12, 20], 20 is in range [20,24].
     List 3: [5, 18, 22, 30], 22 is in range [20,24].
     
    -

     

    +

    Example 2:

    + +
    +Input: nums = [[1,2,3],[1,2,3],[1,2,3]]
    +Output: [1,1]
    +
    + +

    Example 3:

    + +
    +Input: nums = [[10,10],[11,11]]
    +Output: [10,11]
    +
    -

    Note:

    +

    Example 4:

    + +
    +Input: nums = [[10],[11]]
    +Output: [10,11]
    +
    + +

    Example 5:

    + +
    +Input: nums = [[1],[2],[3],[4],[5],[6],[7]]
    +Output: [1,7]
    +
    + +

     

    +

    Constraints:

    -
      -
    1. The given list may contain duplicates, so ascending order means >= here.
    2. -
    3. 1 <= k <= 3500
    4. -
    5. -105 <= value of elements <= 105.
    6. -
    +
      +
    • nums.length == k
    • +
    • 1 <= k <= 3500
    • +
    • 1 <= nums[i].length <= 50
    • +
    • -105 <= nums[i][j] <= 105
    • +
    • nums[i] is sorted in non-decreasing order.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md index 3de6937a8..60115f049 100644 --- a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md +++ b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md @@ -11,39 +11,47 @@ ## [865. Smallest Subtree with all the Deepest Nodes (Medium)](https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes "具有所有最深结点的最小子树") -

    Given a binary tree rooted at root, the depth of each node is the shortest distance to the root.

    +

    Given the root of a binary tree, the depth of each node is the shortest distance to the root.

    -

    A node is deepest if it has the largest depth possible among any node in the entire tree.

    +

    Return the smallest subtree such that it contains all the deepest nodes in the original tree.

    -

    The subtree of a node is that node, plus the set of all descendants of that node.

    +

    A node is called the deepest if it has the largest depth possible among any node in the entire tree.

    -

    Return the node with the largest depth such that it contains all the deepest nodes in its subtree.

    +

    The subtree of a node is tree consisting of that node, plus the set of all descendants of that node.

     

    -

    Example 1:

    + +
    +Input: root = [3,5,1,6,2,0,8,null,null,7,4]
    +Output: [2,7,4]
    +Explanation: We return the node with value 2, colored in yellow in the diagram.
    +The nodes coloured in blue are the deepest nodes of the tree.
    +Notice that nodes 5, 3 and 2 contain the deepest nodes in the tree but node 2 is the smallest subtree among them, so we return it.
    +
    + +

    Example 2:

    -Input: [3,5,1,6,2,0,8,null,null,7,4]
    -Output: [2,7,4]
    -Explanation:
    -
    -
    -
    -We return the node with value 2, colored in yellow in the diagram.
    -The nodes colored in blue are the deepest nodes of the tree.
    -The input "[3, 5, 1, 6, 2, 0, 8, null, null, 7, 4]" is a serialization of the given tree.
    -The output "[2, 7, 4]" is a serialization of the subtree rooted at the node with value 2.
    -Both the input and output have TreeNode type.
    +Input: root = [1]
    +Output: [1]
    +Explanation: The root is the deepest node in the tree.
     
    -

     

    +

    Example 3:

    -

    Note:

    +
    +Input: root = [0,1,3,null,2]
    +Output: [2]
    +Explanation: The deepest node in the tree is 2, the valid subtrees are the subtrees of nodes 2, 1 and 0 but the subtree of node 2 is the smallest.
    +
    + +

     

    +

    Constraints:

      -
    • The number of nodes in the tree will be between 1 and 500.
    • -
    • The values of each node are unique.
    • +
    • The number of nodes in the tree will be between in the range [1, 500].
    • +
    • The values of the nodes in the tree are unique.
    ### Related Topics diff --git a/problems/stone-game-v/README.md b/problems/stone-game-v/README.md index e2ad8245b..967c5c847 100644 --- a/problems/stone-game-v/README.md +++ b/problems/stone-game-v/README.md @@ -7,7 +7,7 @@ [< Previous](../find-latest-group-of-size-m "Find Latest Group of Size M")                  -Next > +[Next >](../put-boxes-into-the-warehouse-i "Put Boxes Into the Warehouse I") ## [1563. Stone Game V (Hard)](https://leetcode.com/problems/stone-game-v "石子游戏 V") diff --git a/problems/strings-differ-by-one-character/README.md b/problems/strings-differ-by-one-character/README.md index 974be134a..e3c1d8902 100644 --- a/problems/strings-differ-by-one-character/README.md +++ b/problems/strings-differ-by-one-character/README.md @@ -9,7 +9,7 @@                  [Next >](../bank-account-summary "Bank Account Summary") -## [1554. Strings Differ by One Character (Medium)](https://leetcode.com/problems/strings-differ-by-one-character "") +## [1554. Strings Differ by One Character (Medium)](https://leetcode.com/problems/strings-differ-by-one-character "只有一个不同字符的字符串") diff --git a/problems/task-scheduler/README.md b/problems/task-scheduler/README.md index e2dff6082..b07e0577e 100644 --- a/problems/task-scheduler/README.md +++ b/problems/task-scheduler/README.md @@ -11,11 +11,11 @@ ## [621. Task Scheduler (Medium)](https://leetcode.com/problems/task-scheduler "任务调度器") -

    You are given a char array representing tasks CPU need to do. It contains capital letters A to Z where each letter represents a different task. Tasks could be done without the original order of the array. Each task is done in one unit of time. For each unit of time, the CPU could complete either one task or just be idle.

    +

    Given a characters array tasks, representing the tasks a CPU needs to do, where each letter represents a different task. Tasks could be done in any order. Each task is done in one unit of time. For each unit of time, the CPU could complete either one task or just be idle.

    However, there is a non-negative integer n that represents the cooldown period between two same tasks (the same letter in the array), that is that there must be at least n units of time between any two same tasks.

    -

    You need to return the least number of units of times that the CPU will take to finish all the given tasks.

    +

    Return the least number of units of times that the CPU will take to finish all the given tasks.

     

    Example 1:

    @@ -55,7 +55,8 @@ A -> B -> C -> A -> D -> E -> A -> F -> G -> A ->

    Constraints:

      -
    • The number of tasks is in the range [1, 10000].
    • +
    • 1 <= task.length <= 104
    • +
    • tasks[i] is upper-case English letter.
    • The integer n is in the range [0, 100].
    diff --git a/problems/the-most-recent-three-orders/README.md b/problems/the-most-recent-three-orders/README.md index faf89fc92..4beb62cb8 100644 --- a/problems/the-most-recent-three-orders/README.md +++ b/problems/the-most-recent-three-orders/README.md @@ -9,6 +9,6 @@                  [Next >](../find-the-index-of-the-large-integer "Find the Index of the Large Integer") -## [1532. The Most Recent Three Orders (Medium)](https://leetcode.com/problems/the-most-recent-three-orders "") +## [1532. The Most Recent Three Orders (Medium)](https://leetcode.com/problems/the-most-recent-three-orders "最近的三笔订单") diff --git a/problems/two-city-scheduling/README.md b/problems/two-city-scheduling/README.md index 91dab595a..315b738c3 100644 --- a/problems/two-city-scheduling/README.md +++ b/problems/two-city-scheduling/README.md @@ -9,19 +9,18 @@                  [Next >](../matrix-cells-in-distance-order "Matrix Cells in Distance Order") -## [1029. Two City Scheduling (Easy)](https://leetcode.com/problems/two-city-scheduling "两地调度") +## [1029. Two City Scheduling (Medium)](https://leetcode.com/problems/two-city-scheduling "两地调度") -

    There are 2N people a company is planning to interview. The cost of flying the i-th person to city A is costs[i][0], and the cost of flying the i-th person to city B is costs[i][1].

    +

    A company is planning to interview 2n people. Given the array costs where costs[i] = [aCosti, bCosti], the cost of flying the ith person to city a is aCosti, and the cost of flying the ith person to city b is bCosti.

    -

    Return the minimum cost to fly every person to a city such that exactly N people arrive in each city.

    +

    Return the minimum cost to fly every person to a city such that exactly n people arrive in each city.

     

    -

    Example 1:

    -Input: [[10,20],[30,200],[400,50],[30,20]]
    -Output: 110
    +Input: costs = [[10,20],[30,200],[400,50],[30,20]]
    +Output: 110
     Explanation: 
     The first person goes to city A for a cost of 10.
     The second person goes to city A for a cost of 30.
    @@ -31,15 +30,29 @@ The fourth person goes to city B for a cost of 20.
     The total minimum cost is 10 + 30 + 50 + 20 = 110 to have half the people interviewing in each city.
     
    -

     

    +

    Example 2:

    + +
    +Input: costs = [[259,770],[448,54],[926,667],[184,139],[840,118],[577,469]]
    +Output: 1859
    +
    -

    Note:

    +

    Example 3:

    -
      -
    1. 1 <= costs.length <= 100
    2. -
    3. It is guaranteed that costs.length is even.
    4. -
    5. 1 <= costs[i][0], costs[i][1] <= 1000
    6. -
    +
    +Input: costs = [[515,563],[451,713],[537,709],[343,819],[855,779],[457,60],[650,359],[631,42]]
    +Output: 3086
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2n == costs.length
    • +
    • 2 <= costs.length <= 100
    • +
    • costs.length is even.
    • +
    • 1 <= aCosti, bCosti <= 1000
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/two-sum/README.md b/problems/two-sum/README.md index 3cf03d834..fcdbef4e5 100644 --- a/problems/two-sum/README.md +++ b/problems/two-sum/README.md @@ -11,19 +11,45 @@ ## [1. Two Sum (Easy)](https://leetcode.com/problems/two-sum "两数之和") -

    Given an array of integers, return indices of the two numbers such that they add up to a specific target.

    +

    Given an array of integers nums and and integer target, return the indices of the two numbers such that they add up to target.

    -

    You may assume that each input would have exactly one solution, and you may not use the same element twice.

    +

    You may assume that each input would have exactly one solution, and you may not use the same element twice.

    -

    Example:

    +

    You can return the answer in any order.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [2,7,11,15], target = 9
    +Output: [0,1]
    +Output: Because nums[0] + nums[1] == 9, we return [0, 1]
    +
    + +

    Example 2:

    -Given nums = [2, 7, 11, 15], target = 9,
    +Input: nums = [3,2,4], target = 6
    +Output: [1,2]
    +
    + +

    Example 3:

    -Because nums[0] + nums[1] = 2 + 7 = 9, -return [0, 1]. +
    +Input: nums = [3,3], target = 6
    +Output: [0,1]
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • -109 <= nums[i] <= 109
    • +
    • -109 <= target <= 109
    • +
    • Only one valid answer exists.
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/unique-orders-and-customers-per-month/README.md b/problems/unique-orders-and-customers-per-month/README.md new file mode 100644 index 000000000..46e6e5f16 --- /dev/null +++ b/problems/unique-orders-and-customers-per-month/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../put-boxes-into-the-warehouse-i "Put Boxes Into the Warehouse I") +                 +[Next >](../detect-pattern-of-length-m-repeated-k-or-more-times "Detect Pattern of Length M Repeated K or More Times") + +## [1565. Unique Orders and Customers Per Month (Easy)](https://leetcode.com/problems/unique-orders-and-customers-per-month "") + + diff --git a/problems/unique-orders-and-customers-per-month/mysql_schemas.sql b/problems/unique-orders-and-customers-per-month/mysql_schemas.sql new file mode 100644 index 000000000..6f3b8f4d1 --- /dev/null +++ b/problems/unique-orders-and-customers-per-month/mysql_schemas.sql @@ -0,0 +1,12 @@ +Create table If Not Exists Orders (order_id int, order_date date, customer_id int, invoice int); +Truncate table Orders; +insert into Orders (order_id, order_date, customer_id, invoice) values ('1', '2020-09-15', '1', '30'); +insert into Orders (order_id, order_date, customer_id, invoice) values ('2', '2020-09-17', '2', '90'); +insert into Orders (order_id, order_date, customer_id, invoice) values ('3', '2020-10-06', '3', '20'); +insert into Orders (order_id, order_date, customer_id, invoice) values ('4', '2020-10-20', '3', '21'); +insert into Orders (order_id, order_date, customer_id, invoice) values ('5', '2020-11-10', '1', '10'); +insert into Orders (order_id, order_date, customer_id, invoice) values ('6', '2020-11-21', '2', '15'); +insert into Orders (order_id, order_date, customer_id, invoice) values ('7', '2020-12-01', '4', '55'); +insert into Orders (order_id, order_date, customer_id, invoice) values ('8', '2020-12-03', '4', '77'); +insert into Orders (order_id, order_date, customer_id, invoice) values ('9', '2021-01-07', '3', '31'); +insert into Orders (order_id, order_date, customer_id, invoice) values ('10', '2021-01-15', '2', '20'); diff --git a/problems/valid-parentheses/README.md b/problems/valid-parentheses/README.md index 62a8bab5f..b71415bce 100644 --- a/problems/valid-parentheses/README.md +++ b/problems/valid-parentheses/README.md @@ -11,7 +11,7 @@ ## [20. Valid Parentheses (Easy)](https://leetcode.com/problems/valid-parentheses "有效的括号") -

    Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

    +

    Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

    An input string is valid if:

    @@ -20,43 +20,50 @@
  • Open brackets must be closed in the correct order.
  • -

    Note that an empty string is also considered valid.

    - +

     

    Example 1:

    -Input: "()"
    +Input: s = "()"
     Output: true
     

    Example 2:

    -Input: "()[]{}"
    +Input: s = "()[]{}"
     Output: true
     

    Example 3:

    -Input: "(]"
    +Input: s = "(]"
     Output: false
     

    Example 4:

    -Input: "([)]"
    +Input: s = "([)]"
     Output: false
     

    Example 5:

    -Input: "{[]}"
    +Input: s = "{[]}"
     Output: true
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 104
    • +
    • s consists of parentheses only '()[]{}'.
    • +
    + ### Related Topics [[Stack](../../tag/stack/README.md)] [[String](../../tag/string/README.md)] diff --git a/readme/1-300.md b/readme/1-300.md index 5ef8bd213..32aa8599a 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -214,7 +214,7 @@ LeetCode Problems' Solutions | 142 | [Linked List Cycle II](https://leetcode.com/problems/linked-list-cycle-ii "环形链表 II") | [Go](../problems/linked-list-cycle-ii) | Medium | | 143 | [Reorder List](https://leetcode.com/problems/reorder-list "重排链表") | [Go](../problems/reorder-list) | Medium | | 144 | [Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal "二叉树的前序遍历") | [Go](../problems/binary-tree-preorder-traversal) | Medium | -| 145 | [Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历") | [Go](../problems/binary-tree-postorder-traversal) | Hard | +| 145 | [Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历") | [Go](../problems/binary-tree-postorder-traversal) | Medium | | 146 | [LRU Cache](https://leetcode.com/problems/lru-cache "LRU缓存机制") | [Go](../problems/lru-cache) | Medium | | 147 | [Insertion Sort List](https://leetcode.com/problems/insertion-sort-list "对链表进行插入排序") | [Go](../problems/insertion-sort-list) | Medium | | 148 | [Sort List](https://leetcode.com/problems/sort-list "排序链表") | [Go](../problems/sort-list) | Medium | diff --git a/readme/601-900.md b/readme/601-900.md index 5c655eb70..926acfe32 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -155,7 +155,7 @@ LeetCode Problems' Solutions | 683 | [K Empty Slots](https://leetcode.com/problems/k-empty-slots "K 个空花盆") 🔒 | [Go](../problems/k-empty-slots) | Hard | | 684 | [Redundant Connection](https://leetcode.com/problems/redundant-connection "冗余连接") | [Go](../problems/redundant-connection) | Medium | | 685 | [Redundant Connection II](https://leetcode.com/problems/redundant-connection-ii "冗余连接 II") | [Go](../problems/redundant-connection-ii) | Hard | -| 686 | [Repeated String Match](https://leetcode.com/problems/repeated-string-match "重复叠加字符串匹配") | [Go](../problems/repeated-string-match) | Easy | +| 686 | [Repeated String Match](https://leetcode.com/problems/repeated-string-match "重复叠加字符串匹配") | [Go](../problems/repeated-string-match) | Medium | | 687 | [Longest Univalue Path](https://leetcode.com/problems/longest-univalue-path "最长同值路径") | [Go](../problems/longest-univalue-path) | Easy | | 688 | [Knight Probability in Chessboard](https://leetcode.com/problems/knight-probability-in-chessboard "“马”在棋盘上的概率") | [Go](../problems/knight-probability-in-chessboard) | Medium | | 689 | [Maximum Sum of 3 Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays "三个无重叠子数组的最大和") | [Go](../problems/maximum-sum-of-3-non-overlapping-subarrays) | Hard | diff --git a/readme/901-1200.md b/readme/901-1200.md index 83f160153..31aff4877 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -198,7 +198,7 @@ LeetCode Problems' Solutions | 1026 | [Maximum Difference Between Node and Ancestor](https://leetcode.com/problems/maximum-difference-between-node-and-ancestor "节点与其祖先之间的最大差值") | [Go](../problems/maximum-difference-between-node-and-ancestor) | Medium | | 1027 | [Longest Arithmetic Subsequence](https://leetcode.com/problems/longest-arithmetic-subsequence "最长等差数列") | [Go](../problems/longest-arithmetic-subsequence) | Medium | | 1028 | [Recover a Tree From Preorder Traversal](https://leetcode.com/problems/recover-a-tree-from-preorder-traversal "从先序遍历还原二叉树") | [Go](../problems/recover-a-tree-from-preorder-traversal) | Hard | -| 1029 | [Two City Scheduling](https://leetcode.com/problems/two-city-scheduling "两地调度") | [Go](../problems/two-city-scheduling) | Easy | +| 1029 | [Two City Scheduling](https://leetcode.com/problems/two-city-scheduling "两地调度") | [Go](../problems/two-city-scheduling) | Medium | | 1030 | [Matrix Cells in Distance Order](https://leetcode.com/problems/matrix-cells-in-distance-order "距离顺序排列矩阵单元格") | [Go](../problems/matrix-cells-in-distance-order) | Easy | | 1031 | [Maximum Sum of Two Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays "两个非重叠子数组的最大和") | [Go](../problems/maximum-sum-of-two-non-overlapping-subarrays) | Medium | | 1032 | [Stream of Characters](https://leetcode.com/problems/stream-of-characters "字符流") | [Go](../problems/stream-of-characters) | Hard | diff --git a/tag/README.md b/tag/README.md index cf0817e55..31537a923 100644 --- a/tag/README.md +++ b/tag/README.md @@ -12,8 +12,8 @@ | 1 | [Array](array/README.md) | [数组](https://openset.github.io/tags/array/) | | 2 | [Dynamic Programming](dynamic-programming/README.md) | [动态规划](https://openset.github.io/tags/dynamic-programming/) | | 3 | [String](string/README.md) | [字符串](https://openset.github.io/tags/string/) | | 4 | [Math](math/README.md) | [数学](https://openset.github.io/tags/math/) | | 5 | [Tree](tree/README.md) | [树](https://openset.github.io/tags/tree/) | | 6 | [Depth-first Search](depth-first-search/README.md) | [深度优先搜索](https://openset.github.io/tags/depth-first-search/) | -| 7 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | | 8 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | -| 9 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | +| 7 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | | 8 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | +| 9 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | | 11 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 13 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | | 14 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 15 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 16 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | diff --git a/tag/array/README.md b/tag/array/README.md index fc2c8b06b..33290425d 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1566 | [重复至少 K 次且长度为 M 的模式](../../problems/detect-pattern-of-length-m-repeated-k-or-more-times) | [[数组](../array/README.md)] | Easy | | 1560 | [圆形赛道上经过次数最多的扇区](../../problems/most-visited-sector-in-a-circular-track) | [[数组](../array/README.md)] | Easy | | 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1550 | [存在连续三个奇数的数组](../../problems/three-consecutive-odds) | [[数组](../array/README.md)] | Easy | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index cb84ce8e9..f45c3c592 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1563 | [石子游戏 V](../../problems/stone-game-v) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1553 | [吃掉 N 个橘子的最少天数](../../problems/minimum-number-of-days-to-eat-n-oranges) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1548 | [The Most Similar Path in a Graph](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index cd0742ae3..78055c7a4 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1568 | [使陆地分离的最少天数](../../problems/minimum-number-of-days-to-disconnect-island) | [[贪心算法](../greedy/README.md)] | Medium | +| 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心算法](../greedy/README.md)] | Medium | +| 1564 | [Put Boxes Into the Warehouse I](../../problems/put-boxes-into-the-warehouse-i) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | | 1558 | [得到目标数组的最少函数调用次数](../../problems/minimum-numbers-of-function-calls-to-make-target-array) | [[贪心算法](../greedy/README.md)] | Medium | | 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心算法](../greedy/README.md)] | Medium | @@ -45,7 +48,7 @@ | 1055 | [形成字符串的最短路径](../../problems/shortest-way-to-form-string) 🔒 | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1053 | [交换一次的先前排列](../../problems/previous-permutation-with-one-swap) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1046 | [最后一块石头的重量](../../problems/last-stone-weight) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Easy | -| 1029 | [两地调度](../../problems/two-city-scheduling) | [[贪心算法](../greedy/README.md)] | Easy | +| 1029 | [两地调度](../../problems/two-city-scheduling) | [[贪心算法](../greedy/README.md)] | Medium | | 1007 | [行相等的最少多米诺旋转](../../problems/minimum-domino-rotations-for-equal-row) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1005 | [K 次取反后最大化的数组和](../../problems/maximize-sum-of-array-after-k-negations) | [[贪心算法](../greedy/README.md)] | Easy | | 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[贪心算法](../greedy/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | diff --git a/tag/stack/README.md b/tag/stack/README.md index a467c5dcc..b18c210d0 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -59,7 +59,7 @@ | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | | 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] | Medium | -| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Hard | +| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | | 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | | 103 | [二叉树的锯齿形层次遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index a5c9fad5b..76e81648a 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -115,7 +115,7 @@ | 722 | [删除注释](../../problems/remove-comments) | [[字符串](../string/README.md)] | Medium | | 709 | [转换成小写字母](../../problems/to-lower-case) | [[字符串](../string/README.md)] | Easy | | 696 | [计数二进制子串](../../problems/count-binary-substrings) | [[字符串](../string/README.md)] | Easy | -| 686 | [重复叠加字符串匹配](../../problems/repeated-string-match) | [[字符串](../string/README.md)] | Easy | +| 686 | [重复叠加字符串匹配](../../problems/repeated-string-match) | [[字符串](../string/README.md)] | Medium | | 681 | [最近时刻](../../problems/next-closest-time) 🔒 | [[字符串](../string/README.md)] | Medium | | 680 | [验证回文字符串 Ⅱ](../../problems/valid-palindrome-ii) | [[字符串](../string/README.md)] | Easy | | 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[字符串](../string/README.md)] | Medium | diff --git a/tag/tags.json b/tag/tags.json index 7fb7da2e6..3c6919a2d 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -34,16 +34,16 @@ "Slug": "hash-table", "TranslatedName": "哈希表" }, - { - "Name": "Binary Search", - "Slug": "binary-search", - "TranslatedName": "二分查找" - }, { "Name": "Greedy", "Slug": "greedy", "TranslatedName": "贪心算法" }, + { + "Name": "Binary Search", + "Slug": "binary-search", + "TranslatedName": "二分查找" + }, { "Name": "Breadth-first Search", "Slug": "breadth-first-search", diff --git a/tag/tree/README.md b/tag/tree/README.md index 08171eddf..b42ee45c4 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -125,7 +125,7 @@ | 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 156 | [上下翻转二叉树](../../problems/binary-tree-upside-down) 🔒 | [[树](../tree/README.md)] | Medium | -| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Hard | +| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | | 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | | 129 | [求根到叶子节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | From 8e5e9627836a82f27e8b80472a2a691c4a889191 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 7 Sep 2020 11:11:01 +0800 Subject: [PATCH 097/145] A: new --- README.md | 10 ++ problems/3sum/README.md | 33 ++++--- problems/contains-duplicate-iii/README.md | 42 ++++---- .../README.md | 2 +- problems/count-all-possible-routes/README.md | 95 +++++++++++++++++++ problems/delete-node-in-a-bst/README.md | 63 ++++++------ .../delete-node-in-a-linked-list/README.md | 43 ++++++--- .../README.md | 10 +- problems/design-browser-history/README.md | 2 +- problems/detect-capital/README.md | 2 +- problems/dinner-plate-stacks/README.md | 6 +- .../README.md | 25 +++++ .../README.md | 2 +- problems/find-right-interval/README.md | 62 ++++++------ problems/find-the-duplicate-number/README.md | 49 ++++++---- .../flip-equivalent-binary-trees/README.md | 2 +- .../README.md | 11 ++- .../guess-number-higher-or-lower-ii/README.md | 6 ++ problems/interleaving-string/README.md | 25 ++++- .../largest-time-for-given-digits/README.md | 39 ++++---- problems/leaf-similar-trees/README.md | 44 ++++++++- problems/letter-case-permutation/README.md | 2 +- problems/linked-list-cycle/README.md | 52 +++++----- .../README.md | 44 +++++---- .../longest-uncommon-subsequence-i/README.md | 6 +- .../longest-uncommon-subsequence-ii/README.md | 4 +- problems/matrix-diagonal-sum/README.md | 63 ++++++++++++ problems/maximum-subarray/README.md | 47 +++++++-- .../median-of-two-sorted-arrays/README.md | 8 +- problems/merge-k-sorted-lists/README.md | 4 +- .../README.md | 2 +- .../README.md | 62 ++++++++++++ problems/minimum-height-trees/README.md | 8 +- .../README.md | 2 +- problems/n-queens/README.md | 2 +- .../README.md | 33 +++---- .../README.md | 2 +- .../README.md | 83 ++++++++++++++++ .../README.md | 74 +++++++++++++++ .../README.md | 41 ++++---- problems/palindrome-partitioning-ii/README.md | 2 +- problems/pancake-sorting/README.md | 30 +++--- .../partition-array-for-maximum-sum/README.md | 40 +++++--- problems/random-pick-with-weight/README.md | 4 +- .../README.md | 92 ++++++++++++++++++ problems/repeated-string-match/README.md | 2 +- .../README.md | 74 +++++++++++++++ problems/replace-words/README.md | 10 +- problems/restore-ip-addresses/README.md | 4 +- .../search-in-rotated-sorted-array/README.md | 4 +- problems/set-matrix-zeroes/README.md | 2 +- .../README.md | 73 ++++++++++++++ .../README.md | 2 +- problems/string-compression/README.md | 12 +-- .../README.md | 35 +++++-- problems/swap-adjacent-in-lr-string/README.md | 26 ++++- .../README.md | 30 +++++- problems/two-sum/README.md | 6 +- problems/validate-ip-address/README.md | 10 +- problems/warehouse-manager/README.md | 14 +++ problems/warehouse-manager/mysql_schemas.sql | 15 +++ readme/1-300.md | 2 +- tag/array/README.md | 3 + tag/backtracking/README.md | 2 +- tag/binary-search/README.md | 1 + tag/dynamic-programming/README.md | 2 + tag/graph/README.md | 1 - tag/greedy/README.md | 3 +- tag/hash-table/README.md | 2 + tag/math/README.md | 1 + tag/string/README.md | 2 + tag/two-pointers/README.md | 1 + tag/union-find/README.md | 1 + 73 files changed, 1250 insertions(+), 370 deletions(-) create mode 100644 problems/count-all-possible-routes/README.md create mode 100644 problems/dot-product-of-two-sparse-vectors/README.md create mode 100644 problems/matrix-diagonal-sum/README.md create mode 100644 problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md create mode 100644 problems/number-of-ways-to-split-a-string/README.md create mode 100644 problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md create mode 100644 problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md create mode 100644 problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md create mode 100644 problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md create mode 100644 problems/warehouse-manager/README.md create mode 100644 problems/warehouse-manager/mysql_schemas.sql diff --git a/README.md b/README.md index 3e41820b9..e49eeacb3 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,16 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1579 | [Remove Max Number of Edges to Keep Graph Fully Traversable](https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable "保证图可完全遍历") | [Go](problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | Hard | +| 1578 | [Minimum Deletion Cost to Avoid Repeating Letters](https://leetcode.com/problems/minimum-deletion-cost-to-avoid-repeating-letters "避免重复字母的最小删除成本") | [Go](problems/minimum-deletion-cost-to-avoid-repeating-letters) | Medium | +| 1577 | [Number of Ways Where Square of Number Is Equal to Product of Two Numbers](https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "数的平方等于两数乘积的方法数") | [Go](problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | Medium | +| 1576 | [Replace All ?'s to Avoid Consecutive Repeating Characters](https://leetcode.com/problems/replace-all-s-to-avoid-consecutive-repeating-characters "替换所有的问号") | [Go](problems/replace-all-s-to-avoid-consecutive-repeating-characters) | Easy | +| 1575 | [Count All Possible Routes](https://leetcode.com/problems/count-all-possible-routes "统计所有可行路径") | [Go](problems/count-all-possible-routes) | Hard | +| 1574 | [Shortest Subarray to be Removed to Make Array Sorted](https://leetcode.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted "删除最短的子数组使剩余数组有序") | [Go](problems/shortest-subarray-to-be-removed-to-make-array-sorted) | Medium | +| 1573 | [Number of Ways to Split a String](https://leetcode.com/problems/number-of-ways-to-split-a-string "分割字符串的方案数") | [Go](problems/number-of-ways-to-split-a-string) | Medium | +| 1572 | [Matrix Diagonal Sum](https://leetcode.com/problems/matrix-diagonal-sum "矩阵对角线元素的和") | [Go](problems/matrix-diagonal-sum) | Easy | +| 1571 | [Warehouse Manager](https://leetcode.com/problems/warehouse-manager) 🔒 | [MySQL](problems/warehouse-manager) | Easy | +| 1570 | [Dot Product of Two Sparse Vectors](https://leetcode.com/problems/dot-product-of-two-sparse-vectors) 🔒 | [Go](problems/dot-product-of-two-sparse-vectors) | Medium | | 1569 | [Number of Ways to Reorder Array to Get Same BST](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst "将子数组重新排序得到同一个二叉查找树的方案数") | [Go](problems/number-of-ways-to-reorder-array-to-get-same-bst) | Hard | | 1568 | [Minimum Number of Days to Disconnect Island](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数") | [Go](problems/minimum-number-of-days-to-disconnect-island) | Hard | | 1567 | [Maximum Length of Subarray With Positive Product](https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product "乘积为正数的最长子数组长度") | [Go](problems/maximum-length-of-subarray-with-positive-product) | Medium | diff --git a/problems/3sum/README.md b/problems/3sum/README.md index f9061e54a..8d221263a 100644 --- a/problems/3sum/README.md +++ b/problems/3sum/README.md @@ -13,21 +13,26 @@

    Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.

    -

    Note:

    - -

    The solution set must not contain duplicate triplets.

    - -

    Example:

    - -
    -Given array nums = [-1, 0, 1, 2, -1, -4],
    -
    -A solution set is:
    -[
    -  [-1, 0, 1],
    -  [-1, -1, 2]
    -]
    +

    Notice that the solution set must not contain duplicate triplets.

    + +

     

    +

    Example 1:

    +
    Input: nums = [-1,0,1,2,-1,-4]
    +Output: [[-1,-1,2],[-1,0,1]]
    +

    Example 2:

    +
    Input: nums = []
    +Output: []
    +

    Example 3:

    +
    Input: nums = [0]
    +Output: []
     
    +

     

    +

    Constraints:

    + +
      +
    • 0 <= nums.length <= 3000
    • +
    • -105 <= nums[i] <= 105
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/contains-duplicate-iii/README.md b/problems/contains-duplicate-iii/README.md index 2e124d496..620dba1a6 100644 --- a/problems/contains-duplicate-iii/README.md +++ b/problems/contains-duplicate-iii/README.md @@ -13,32 +13,26 @@

    Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and nums[j] is at most t and the absolute difference between i and j is at most k.

    -
    +

     

    Example 1:

    - -
    -Input: nums = [1,2,3,1], k = 3, t = 0
    -Output: true
    -
    - -
    -

    Example 2:

    - -
    -Input: nums = [1,0,1,1], k = 1, t = 2
    -Output: true
    -
    - -
    -

    Example 3:

    - -
    -Input: nums = [1,5,9,1,5,9], k = 2, t = 3
    -Output: false
    +
    Input: nums = [1,2,3,1], k = 3, t = 0
    +Output: true
    +

    Example 2:

    +
    Input: nums = [1,0,1,1], k = 1, t = 2
    +Output: true
    +

    Example 3:

    +
    Input: nums = [1,5,9,1,5,9], k = 2, t = 3
    +Output: false
     
    -
    -
    -
    +

     

    +

    Constraints:

    + +
      +
    • 0 <= nums.length <= 2 * 104
    • +
    • -231 <= nums[i] <= 231 - 1
    • +
    • 0 <= k <= 104
    • +
    • 0 <= t <= 231 - 1
    • +
    ### Related Topics [[Sort](../../tag/sort/README.md)] diff --git a/problems/convert-sorted-list-to-binary-search-tree/README.md b/problems/convert-sorted-list-to-binary-search-tree/README.md index eb1b79dfe..32e4d8d78 100644 --- a/problems/convert-sorted-list-to-binary-search-tree/README.md +++ b/problems/convert-sorted-list-to-binary-search-tree/README.md @@ -49,7 +49,7 @@

    Constraints:

      -
    • The numner of nodes in head is in the range [0, 2 * 10^4].
    • +
    • The number of nodes in head is in the range [0, 2 * 104].
    • -10^5 <= Node.val <= 10^5
    diff --git a/problems/count-all-possible-routes/README.md b/problems/count-all-possible-routes/README.md new file mode 100644 index 000000000..1227b3dd0 --- /dev/null +++ b/problems/count-all-possible-routes/README.md @@ -0,0 +1,95 @@ + + + + + + + +[< Previous](../shortest-subarray-to-be-removed-to-make-array-sorted "Shortest Subarray to be Removed to Make Array Sorted") +                 +[Next >](../replace-all-s-to-avoid-consecutive-repeating-characters "Replace All ?'s to Avoid Consecutive Repeating Characters") + +## [1575. Count All Possible Routes (Hard)](https://leetcode.com/problems/count-all-possible-routes "统计所有可行路径") + +

    You are given an array of distinct positive integers locations where locations[i] represents the position of city i. You are also given integers startfinish and fuel representing the starting city, ending city, and the initial amount of fuel you have, respectively.

    + +

    At each step, if you are at city i, you can pick any city j such that j != i and 0 <= j < locations.length and move to city j. Moving from city i to city j reduces the amount of fuel you have by |locations[i] - locations[j]|. Please notice that |x| denotes the absolute value of x.

    + +

    Notice that fuel cannot become negative at any point in time, and that you are allowed to visit any city more than once (including start and finish).

    + +

    Return the count of all possible routes from start to finish.

    + +

    Since the answer may be too large, return it modulo 10^9 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: locations = [2,3,6,8,4], start = 1, finish = 3, fuel = 5
    +Output: 4
    +Explanation: The following are all possible routes, each uses 5 units of fuel:
    +1 -> 3
    +1 -> 2 -> 3
    +1 -> 4 -> 3
    +1 -> 4 -> 2 -> 3
    +
    + +

    Example 2:

    + +
    +Input: locations = [4,3,1], start = 1, finish = 0, fuel = 6
    +Output: 5
    +Explanation: The following are all possible routes:
    +1 -> 0, used fuel = 1
    +1 -> 2 -> 0, used fuel = 5
    +1 -> 2 -> 1 -> 0, used fuel = 5
    +1 -> 0 -> 1 -> 0, used fuel = 3
    +1 -> 0 -> 1 -> 0 -> 1 -> 0, used fuel = 5
    +
    + +

    Example 3:

    + +
    +Input: locations = [5,2,1], start = 0, finish = 2, fuel = 3
    +Output: 0
    +Explanation: It's impossible to get from 0 to 2 using only 3 units of fuel since the shortest route needs 4 units of fuel.
    + +

    Example 4:

    + +
    +Input: locations = [2,1,5], start = 0, finish = 0, fuel = 3
    +Output: 2
    +Explanation: There are two possible routes, 0 and 0 -> 1 -> 0.
    + +

    Example 5:

    + +
    +Input: locations = [1,2,3], start = 0, finish = 2, fuel = 40
    +Output: 615088286
    +Explanation: The total number of possible routes is 2615088300. Taking this number modulo 10^9 + 7 gives us 615088286.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= locations.length <= 100
    • +
    • 1 <= locations[i] <= 10^9
    • +
    • All integers in locations are distinct.
    • +
    • 0 <= start, finish < locations.length
    • +
    • 1 <= fuel <= 200
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Use dynamic programming to solve this problem with each state defined by the city index and fuel left. +
    + +
    +Hint 2 +Since the array contains distinct integers fuel will always be spent in each move and so there can be no cycles. +
    diff --git a/problems/delete-node-in-a-bst/README.md b/problems/delete-node-in-a-bst/README.md index 0381b48dd..1b03a99e8 100644 --- a/problems/delete-node-in-a-bst/README.md +++ b/problems/delete-node-in-a-bst/README.md @@ -13,45 +13,52 @@

    Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.

    -

    Basically, the deletion can be divided into two stages: +

    Basically, the deletion can be divided into two stages:

    +
      -
    1. Search for a node to remove.
    2. -
    3. If the node is found, delete the node.
    4. +
    5. Search for a node to remove.
    6. +
    7. If the node is found, delete the node.
    -

    -

    Note: Time complexity should be O(height of tree).

    +

    Follow up: Can you solve it with time complexity O(height of tree)?

    -

    Example: +

     

    +

    Example 1:

    +
    -root = [5,3,6,2,4,null,7]
    -key = 3
    +Input: root = [5,3,6,2,4,null,7], key = 3
    +Output: [5,4,6,2,null,null,7]
    +Explanation: Given key to delete is 3. So we find the node with value 3 and delete it.
    +One valid answer is [5,4,6,2,null,null,7], shown in the above BST.
    +Please notice that another valid answer is [5,2,6,null,4,null,7] and it's also accepted.
    +
    +
    - 5 - / \ - 3 6 - / \ \ -2 4 7 +

    Example 2:

    -Given key to delete is 3. So we find the node with value 3 and delete it. +
    +Input: root = [5,3,6,2,4,null,7], key = 0
    +Output: [5,3,6,2,4,null,7]
    +Explanation: The tree does not contain a node with value = 0.
    +
    -One valid answer is [5,4,6,2,null,null,7], shown in the following BST. +

    Example 3:

    - 5 - / \ - 4 6 - / \ -2 7 +
    +Input: root = [], key = 0
    +Output: []
    +
    -Another valid answer is [5,2,6,null,4,null,7]. +

     

    +

    Constraints:

    - 5 - / \ - 2 6 - \ \ - 4 7 -
    -

    +
      +
    • The number of nodes in the tree is in the range [0, 104].
    • +
    • -105 <= Node.val <= 105
    • +
    • Each node has a unique value.
    • +
    • root is a valid binary search tree.
    • +
    • -105 <= key <= 105
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/delete-node-in-a-linked-list/README.md b/problems/delete-node-in-a-linked-list/README.md index 13e7acb62..2348ae696 100644 --- a/problems/delete-node-in-a-linked-list/README.md +++ b/problems/delete-node-in-a-linked-list/README.md @@ -11,16 +11,13 @@ ## [237. Delete Node in a Linked List (Easy)](https://leetcode.com/problems/delete-node-in-a-linked-list "删除链表中的节点") -

    Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.

    +

    Write a function to delete a node in a singly-linked list. You will not be given access to the head of the list, instead you will be given access to the node to be deleted directly.

    -

    Given linked list -- head = [4,5,1,9], which looks like following:

    - -

    +

    It is guaranteed that the node to be deleted is not a tail node in the list.

     

    -

    Example 1:

    - +
     Input: head = [4,5,1,9], node = 5
     Output: [4,1,9]
    @@ -28,22 +25,42 @@
     

    Example 2:

    - +
     Input: head = [4,5,1,9], node = 1
     Output: [4,5,9]
     Explanation: You are given the third node with value 1, the linked list should become 4 -> 5 -> 9 after calling your function.
     
    -

     

    +

    Example 3:

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

    Example 4:

    -

    Note:

    +
    +Input: head = [0,1], node = 0
    +Output: [1]
    +
    + +

    Example 5:

    + +
    +Input: head = [-3,5,-99], node = -3
    +Output: [5,-99]
    +
    + +

     

    +

    Constraints:

      -
    • The linked list will have at least two elements.
    • -
    • All of the nodes' values will be unique.
    • -
    • The given node will not be the tail and it will always be a valid node of the linked list.
    • -
    • Do not return anything from your function.
    • +
    • The number of the nodes in the given list is in the range [2, 1000].
    • +
    • -1000 <= Node.val <= 1000
    • +
    • The value of each node in the list is unique.
    • +
    • The node to be deleted is in the list and is not a tail node
    ### Related Topics diff --git a/problems/design-add-and-search-words-data-structure/README.md b/problems/design-add-and-search-words-data-structure/README.md index 999e4a8f8..e2687212e 100644 --- a/problems/design-add-and-search-words-data-structure/README.md +++ b/problems/design-add-and-search-words-data-structure/README.md @@ -11,14 +11,14 @@ ## [211. Design Add and Search Words Data Structure (Medium)](https://leetcode.com/problems/design-add-and-search-words-data-structure "添加与搜索单词 - 数据结构设计") -

    You should design a data structure that supports adding new words and finding if a string matches any previously added string.

    +

    Design a data structure that supports adding new words and finding if a string matches any previously added string.

    Implement the WordDictionary class:

    • WordDictionary() Initializes the object.
    • -
    • void addWord(word) adds word to the data structure, it can be matched later.
    • -
    • bool search(word) returns true if there is any string in the data structure that matches word or false otherwise. word may contain dots '.' where dots can be matched with any letter.
    • +
    • void addWord(word) Adds word to the data structure, it can be matched later.
    • +
    • bool search(word) Returns true if there is any string in the data structure that matches word or false otherwise. word may contain dots '.' where dots can be matched with any letter.

     

    @@ -48,8 +48,8 @@ wordDictionary.search("b.."); // return True
    • 1 <= word.length <= 500
    • word in addWord consists lower-case English letters.
    • -
    • word in search consist of  '.' or lower-case English letters.
    • -
    • At most 50000 calls will be made to addWord and search .
    • +
    • word in search consist of  '.' or lower-case English letters.
    • +
    • At most 50000 calls will be made to addWord and search.
    ### Related Topics diff --git a/problems/design-browser-history/README.md b/problems/design-browser-history/README.md index a068bfe7c..da706143f 100644 --- a/problems/design-browser-history/README.md +++ b/problems/design-browser-history/README.md @@ -17,7 +17,7 @@
    • BrowserHistory(string homepage) Initializes the object with the homepage of the browser.
    • -
    • void visit(string url) visits url from the current page. It clears up all the forward history.
    • +
    • void visit(string url) Visits url from the current page. It clears up all the forward history.
    • string back(int steps) Move steps back in history. If you can only return x steps in the history and steps > x, you will return only x steps. Return the current url after moving back in history at most steps.
    • string forward(int steps) Move steps forward in history. If you can only forward x steps in the history and steps > x, you will forward only x steps. Return the current url after forwarding in history at most steps.
    diff --git a/problems/detect-capital/README.md b/problems/detect-capital/README.md index 8a644ef49..4489feff6 100644 --- a/problems/detect-capital/README.md +++ b/problems/detect-capital/README.md @@ -7,7 +7,7 @@ [< Previous](../random-flip-matrix "Random Flip Matrix")                  -[Next >](../longest-uncommon-subsequence-i "Longest Uncommon Subsequence I ") +[Next >](../longest-uncommon-subsequence-i "Longest Uncommon Subsequence I") ## [520. Detect Capital (Easy)](https://leetcode.com/problems/detect-capital "检测大写字母") diff --git a/problems/dinner-plate-stacks/README.md b/problems/dinner-plate-stacks/README.md index 8c1578558..139745b76 100644 --- a/problems/dinner-plate-stacks/README.md +++ b/problems/dinner-plate-stacks/README.md @@ -17,9 +17,9 @@
    • DinnerPlates(int capacity) Initializes the object with the maximum capacity of the stacks.
    • -
    • void push(int val) pushes the given positive integer val into the leftmost stack with size less than capacity.
    • -
    • int pop() returns the value at the top of the rightmost non-empty stack and removes it from that stack, and returns -1 if all stacks are empty.
    • -
    • int popAtStack(int index) returns the value at the top of the stack with the given index and removes it from that stack, and returns -1 if the stack with that given index is empty.
    • +
    • void push(int val) Pushes the given positive integer val into the leftmost stack with size less than capacity.
    • +
    • int pop() Returns the value at the top of the rightmost non-empty stack and removes it from that stack, and returns -1 if all stacks are empty.
    • +
    • int popAtStack(int index) Returns the value at the top of the stack with the given index and removes it from that stack, and returns -1 if the stack with that given index is empty.

    Example:

    diff --git a/problems/dot-product-of-two-sparse-vectors/README.md b/problems/dot-product-of-two-sparse-vectors/README.md new file mode 100644 index 000000000..c2c0d6fc6 --- /dev/null +++ b/problems/dot-product-of-two-sparse-vectors/README.md @@ -0,0 +1,25 @@ + + + + + + + +[< Previous](../number-of-ways-to-reorder-array-to-get-same-bst "Number of Ways to Reorder Array to Get Same BST") +                 +[Next >](../warehouse-manager "Warehouse Manager") + +## [1570. Dot Product of Two Sparse Vectors (Medium)](https://leetcode.com/problems/dot-product-of-two-sparse-vectors "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + +### Hints +
    +Hint 1 +Because the vector is sparse, use a data structure that stores the index and value where the element is nonzero. +
    diff --git a/problems/find-largest-value-in-each-tree-row/README.md b/problems/find-largest-value-in-each-tree-row/README.md index 0edbb6110..00f25719f 100644 --- a/problems/find-largest-value-in-each-tree-row/README.md +++ b/problems/find-largest-value-in-each-tree-row/README.md @@ -55,7 +55,7 @@

    Constraints:

      -
    • The number of the nodes in the tree will be in the range [1, 104].
    • +
    • The number of nodes in the tree will be in the range [0, 104].
    • -231 <= Node.val <= 231 - 1
    diff --git a/problems/find-right-interval/README.md b/problems/find-right-interval/README.md index b49f70ba0..663344584 100644 --- a/problems/find-right-interval/README.md +++ b/problems/find-right-interval/README.md @@ -11,57 +11,49 @@ ## [436. Find Right Interval (Medium)](https://leetcode.com/problems/find-right-interval "寻找右区间") -

    Given a set of intervals, for each of the interval i, check if there exists an interval j whose start point is bigger than or equal to the end point of the interval i, which can be called that j is on the "right" of i.

    +

    You are given an array of intervals, where intervals[i] = [starti, endi] and each starti is unique.

    -

    For any interval i, you need to store the minimum interval j's index, which means that the interval j has the minimum start point to build the "right" relationship for interval i. If the interval j doesn't exist, store -1 for the interval i. Finally, you need output the stored value of each interval as an array.

    +

    The right interval for an interval i is an interval j such that startj >= endi and startj is minimized.

    -

    Note:

    - -
      -
    1. You may assume the interval's end point is always bigger than its start point.
    2. -
    3. You may assume none of these intervals have the same start point.
    4. -
    +

    Return an array of right interval indices for each interval i. If no right interval exists for interval i, then put -1 at index i.

     

    - -

    Example 1:

    +

    Example 1:

    -Input: [ [1,2] ]
    -
    -Output: [-1]
    -
    -Explanation: There is only one interval in the collection, so it outputs -1.
    +Input: intervals = [[1,2]]
    +Output: [-1]
    +Explanation: There is only one interval in the collection, so it outputs -1.
     
    -

     

    - -

    Example 2:

    +

    Example 2:

    -Input: [ [3,4], [2,3], [1,2] ]
    -
    -Output: [-1, 0, 1]
    -
    -Explanation: There is no satisfied "right" interval for [3,4].
    -For [2,3], the interval [3,4] has minimum-"right" start point;
    -For [1,2], the interval [2,3] has minimum-"right" start point.
    +Input: intervals = [[3,4],[2,3],[1,2]]
    +Output: [-1,0,1]
    +Explanation: There is no right interval for [3,4].
    +The right interval for [2,3] is [3,4] since start0 = 3 is the smallest start that is >= end1 = 3.
    +The right interval for [1,2] is [2,3] since start1 = 2 is the smallest start that is >= end2 = 2.
     
    -

     

    - -

    Example 3:

    +

    Example 3:

    -Input: [ [1,4], [2,3], [3,4] ]
    -
    -Output: [-1, 2, -1]
    -
    -Explanation: There is no satisfied "right" interval for [1,4] and [3,4].
    -For [2,3], the interval [3,4] has minimum-"right" start point.
    +Input: intervals = [[1,4],[2,3],[3,4]]
    +Output: [-1,2,-1]
    +Explanation: There is no right interval for [1,4] and [3,4].
    +The right interval for [2,3] is [3,4] since start2 = 3 is the smallest start that is >= end1 = 3.
     
    -

    NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= intervals.length <= 2 * 104
    • +
    • intervals[i].length == 2
    • +
    • -106 <= starti <= endi <= 106
    • +
    • The start point of each interval is unique.
    • +
    ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/find-the-duplicate-number/README.md b/problems/find-the-duplicate-number/README.md index 5ea4dd5c1..89bc75d38 100644 --- a/problems/find-the-duplicate-number/README.md +++ b/problems/find-the-duplicate-number/README.md @@ -11,30 +11,43 @@ ## [287. Find the Duplicate Number (Medium)](https://leetcode.com/problems/find-the-duplicate-number "寻找重复数") -

    Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one.

    +

    Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive.

    -

    Example 1:

    +

    There is only one duplicate number in nums, return this duplicate number.

    -
    -Input: [1,3,4,2,2]
    -Output: 2
    -
    - -

    Example 2:

    - -
    -Input: [3,1,3,4,2]
    -Output: 3
    - -

    Note:

    +

    Follow-ups:

      -
    1. You must not modify the array (assume the array is read only).
    2. -
    3. You must use only constant, O(1) extra space.
    4. -
    5. Your runtime complexity should be less than O(n2).
    6. -
    7. There is only one duplicate number in the array, but it could be repeated more than once.
    8. +
    9. How can we prove that at least one duplicate number must exist in nums
    10. +
    11. Can you solve the problem without modifying the array nums?
    12. +
    13. Can you solve the problem using only constant, O(1) extra space?
    14. +
    15. Can you solve the problem with runtime complexity less than O(n2)?
    +

     

    +

    Example 1:

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

    Example 2:

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

    Example 3:

    +
    Input: nums = [1,1]
    +Output: 1
    +

    Example 4:

    +
    Input: nums = [1,1,2]
    +Output: 1
    +
    +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 3 * 104
    • +
    • nums.length == n + 1
    • +
    • 1 <= nums[i] <= n
    • +
    • All the integers in nums appear only once except for precisely one integer which appears two or more times.
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/flip-equivalent-binary-trees/README.md b/problems/flip-equivalent-binary-trees/README.md index d55a6b63e..556a2d7d6 100644 --- a/problems/flip-equivalent-binary-trees/README.md +++ b/problems/flip-equivalent-binary-trees/README.md @@ -59,7 +59,7 @@
    • The number of nodes in each tree is in the range [0, 100].
    • -
    • Each value in each tree will be a unique integer in the range [0, 99].
    • +
    • Each tree will have unique node values in the range [0, 99].
    ### Related Topics diff --git a/problems/group-the-people-given-the-group-size-they-belong-to/README.md b/problems/group-the-people-given-the-group-size-they-belong-to/README.md index 69acfc108..416f68e8d 100644 --- a/problems/group-the-people-given-the-group-size-they-belong-to/README.md +++ b/problems/group-the-people-given-the-group-size-they-belong-to/README.md @@ -11,13 +11,13 @@ ## [1282. Group the People Given the Group Size They Belong To (Medium)](https://leetcode.com/problems/group-the-people-given-the-group-size-they-belong-to "用户分组") -

    There are n people, each of them has a unique ID from 0 to n - 1 and each person of them belongs to exactly one group.

    +

    There are n people that are split into some unknown number of groups. Each person is labeled with a unique ID from 0 to n - 1.

    -

    Given an integer array groupSizes which indicated that the person with ID = i belongs to a group of groupSize[i] persons.

    +

    You are given an integer array groupSizes, where groupSizes[i] is the size of the group that person i is in. For example, if groupSizes[1] = 3, then person 1 must be in a group of size 3.

    -

    Return an array of the groups where ans[j] contains the IDs of the jth group. Each ID should belong to exactly one group and each ID should be present in your answer. Also if a person with ID = i belongs to group j in your answer, then ans[j].length == groupSize[i] should be true.

    +

    Return a list of groups such that each person i is in a group of size groupSizes[i].

    -

    If there is multiple answers, return any of them. It is guaranteed that there will be at least one valid solution for the given input.

    +

    Each person should appear in exactly one group, and every person must be in a group. If there are multiple answers, return any of them. It is guaranteed that there will be at least one valid solution for the given input.

     

    Example 1:

    @@ -26,6 +26,9 @@ Input: groupSizes = [3,3,3,3,3,1,3] Output: [[5],[0,1,2],[3,4,6]] Explanation: +The first group is [5]. The size is 1, and groupSizes[5] = 1. +The second group is [0,1,2]. The size is 3, and groupSizes[0] = groupSizes[1] = groupSizes[2] = 3. +The third group is [3,4,6]. The size is 3, and groupSizes[3] = groupSizes[4] = groupSizes[6] = 3. Other possible solutions are [[2,1,6],[5],[0,4,3]] and [[5],[0,6,2],[4,3,1]].
    diff --git a/problems/guess-number-higher-or-lower-ii/README.md b/problems/guess-number-higher-or-lower-ii/README.md index f18636f96..5ff810690 100644 --- a/problems/guess-number-higher-or-lower-ii/README.md +++ b/problems/guess-number-higher-or-lower-ii/README.md @@ -34,6 +34,12 @@ You end up paying $5 + $7 + $9 = $21.

    Given a particular n ≥ 1, find out how much money you need to have to guarantee a win.

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 200
    • +
    ### Related Topics [[Minimax](../../tag/minimax/README.md)] diff --git a/problems/interleaving-string/README.md b/problems/interleaving-string/README.md index 54ef595ff..a89f47b45 100644 --- a/problems/interleaving-string/README.md +++ b/problems/interleaving-string/README.md @@ -11,22 +11,39 @@ ## [97. Interleaving String (Hard)](https://leetcode.com/problems/interleaving-string "交错字符串") -

    Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.

    +

    Given s1, s2, and s3, find whether s3 is formed by the interleaving of s1 and s2.

    +

     

    Example 1:

    - +
    -Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac"
    +Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac"
     Output: true
     

    Example 2:

    -Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbbaccc"
    +Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbbaccc"
     Output: false
     
    +

    Example 3:

    + +
    +Input: s1 = "", s2 = "", s3 = ""
    +Output: true
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= s1.length, s2.length <= 100
    • +
    • 0 <= s3.length <= 200
    • +
    • s1, s2, and s3 consist of lower-case English letters.
    • +
    + ### Related Topics [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/largest-time-for-given-digits/README.md b/problems/largest-time-for-given-digits/README.md index d364beb40..fbbb21966 100644 --- a/problems/largest-time-for-given-digits/README.md +++ b/problems/largest-time-for-given-digits/README.md @@ -18,33 +18,26 @@

    Return the answer as a string of length 5.  If no valid time can be made, return an empty string.

     

    - -

    Example 1:

    - -
    -Input: [1,2,3,4]
    -Output: "23:41"
    +
    Input: A = [1,2,3,4]
    +Output: "23:41"
    +

    Example 2:

    +
    Input: A = [5,5,5,5]
    +Output: ""
    +

    Example 3:

    +
    Input: A = [0,0,0,0]
    +Output: "00:00"
    +

    Example 4:

    +
    Input: A = [0,0,1,0]
    +Output: "10:00"
     
    - -
    -

    Example 2:

    - -
    -Input: [5,5,5,5]
    -Output: ""
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. A.length == 4
    2. -
    3. 0 <= A[i] <= 9
    4. -
    -
    -
    +
      +
    • arr.length == 4
    • +
    • 0 <= arr[i] <= 9
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/leaf-similar-trees/README.md b/problems/leaf-similar-trees/README.md index ec9028c6e..29f5ad7f4 100644 --- a/problems/leaf-similar-trees/README.md +++ b/problems/leaf-similar-trees/README.md @@ -11,9 +11,9 @@ ## [872. Leaf-Similar Trees (Easy)](https://leetcode.com/problems/leaf-similar-trees "叶子相似的树") -

    Consider all the leaves of a binary tree.  From left to right order, the values of those leaves form a leaf value sequence.

    +

    Consider all the leaves of a binary tree, from left to right order, the values of those leaves form a leaf value sequence.

    -

    +

    For example, in the given tree above, the leaf value sequence is (6, 7, 4, 9, 8).

    @@ -21,12 +21,48 @@

    Return true if and only if the two given trees with head nodes root1 and root2 are leaf-similar.

    +

     

    +

    Example 1:

    + +
    +Input: root1 = [3,5,1,6,2,9,8,null,null,7,4], root2 = [3,5,1,6,7,4,2,null,null,null,null,null,null,9,8]
    +Output: true
    +
    + +

    Example 2:

    + +
    +Input: root1 = [1], root2 = [1]
    +Output: true
    +
    + +

    Example 3:

    + +
    +Input: root1 = [1], root2 = [2]
    +Output: false
    +
    + +

    Example 4:

    + +
    +Input: root1 = [1,2], root2 = [2,2]
    +Output: true
    +
    + +

    Example 5:

    + +
    +Input: root1 = [1,2,3], root2 = [1,3,2]
    +Output: false
    +
    +

     

    Constraints:

      -
    • Both of the given trees will have between 1 and 200 nodes.
    • -
    • Both of the given trees will have values between 0 and 200
    • +
    • The number of nodes in each tree will be in the range [1, 200].
    • +
    • Both of the given trees will have values in the range [0, 200].
    ### Related Topics diff --git a/problems/letter-case-permutation/README.md b/problems/letter-case-permutation/README.md index 1fb8f93de..019ff72c8 100644 --- a/problems/letter-case-permutation/README.md +++ b/problems/letter-case-permutation/README.md @@ -13,7 +13,7 @@

    Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string.

    -

    Return a list of all possible strings we could create. You can return the output  in any order.

    +

    Return a list of all possible strings we could create. You can return the output in any order.

     

    Example 1:

    diff --git a/problems/linked-list-cycle/README.md b/problems/linked-list-cycle/README.md index 056383919..daa51e776 100644 --- a/problems/linked-list-cycle/README.md +++ b/problems/linked-list-cycle/README.md @@ -13,51 +13,45 @@

    Given a linked list, determine if it has a cycle in it.

    -

    To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail connects to. If pos is -1, then there is no cycle in the linked list.

    +

    To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where the tail connects to. If pos == -1, then there is no cycle in the linked list.

    -

     

    +

    Follow up:

    -
    -

    Example 1:

    +

    Can you solve it using O(1) (i.e. constant) memory?

    +

     

    +

    Example 1:

    +
    -Input: head = [3,2,0,-4], pos = 1
    -Output: true
    -Explanation: There is a cycle in the linked list, where tail connects to the second node.
    +Input: head = [3,2,0,-4], pos = 1
    +Output: true
    +Explanation: There is a cycle in the linked list, where tail connects to the second node.
     
    -
    - -
    -

    Example 2:

    - +
    -Input: head = [1,2], pos = 0
    -Output: true
    -Explanation: There is a cycle in the linked list, where tail connects to the first node.
    +Input: head = [1,2], pos = 0
    +Output: true
    +Explanation: There is a cycle in the linked list, where tail connects to the first node.
     
    -
    - -
    -

    Example 3:

    - +
    -Input: head = [1], pos = -1
    -Output: false
    -Explanation: There is no cycle in the linked list.
    +Input: head = [1], pos = -1
    +Output: false
    +Explanation: There is no cycle in the linked list.
     
    -
    - -

     

    +

    Constraints:

    -

    Follow up:

    - -

    Can you solve it using O(1) (i.e. constant) memory?

    +
      +
    • The number of the nodes in the list is in the range [0, 104].
    • +
    • -105 <= Node.val <= 105
    • +
    • pos is -1 or a valid index in the linked-list.
    • +
    ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/longest-substring-without-repeating-characters/README.md b/problems/longest-substring-without-repeating-characters/README.md index 584c5f845..7cf835f90 100644 --- a/problems/longest-substring-without-repeating-characters/README.md +++ b/problems/longest-substring-without-repeating-characters/README.md @@ -11,38 +11,48 @@ ## [3. Longest Substring Without Repeating Characters (Medium)](https://leetcode.com/problems/longest-substring-without-repeating-characters "无重复字符的最长子串") -

    Given a string, find the length of the longest substring without repeating characters.

    +

    Given a string s, find the length of the longest substring without repeating characters.

    -
    +

     

    Example 1:

    -Input: "abcabcbb"
    -Output: 3 
    -Explanation: The answer is "abc", with the length of 3. 
    +Input: s = "abcabcbb"
    +Output: 3
    +Explanation: The answer is "abc", with the length of 3.
     
    -

    Example 2:

    -Input: "bbbbb"
    -Output: 1
    -Explanation: The answer is "b", with the length of 1.
    +Input: s = "bbbbb"
    +Output: 1
    +Explanation: The answer is "b", with the length of 1.
     
    -

    Example 3:

    -Input: "pwwkew"
    -Output: 3
    -Explanation: The answer is "wke", with the length of 3. 
    -             Note that the answer must be a substring, "pwke" is a subsequence and not a substring.
    +Input: s = "pwwkew"
    +Output: 3
    +Explanation: The answer is "wke", with the length of 3.
    +Notice that the answer must be a substring, "pwke" is a subsequence and not a substring.
     
    -
    -
    -
    + +

    Example 4:

    + +
    +Input: s = ""
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= s.length <= 5 * 104
    • +
    • s consists of English letters, digits, symbols and spaces.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/longest-uncommon-subsequence-i/README.md b/problems/longest-uncommon-subsequence-i/README.md index 3f3f4d2ed..fc9eabfbd 100644 --- a/problems/longest-uncommon-subsequence-i/README.md +++ b/problems/longest-uncommon-subsequence-i/README.md @@ -9,7 +9,7 @@                  [Next >](../longest-uncommon-subsequence-ii "Longest Uncommon Subsequence II") -## [521. Longest Uncommon Subsequence I (Easy)](https://leetcode.com/problems/longest-uncommon-subsequence-i "最长特殊序列 Ⅰ") +## [521. Longest Uncommon Subsequence I (Easy)](https://leetcode.com/problems/longest-uncommon-subsequence-i "最长特殊序列 Ⅰ")

    Given two strings, you need to find the longest uncommon subsequence of this two strings. The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequence should not be any subsequence of the other string.

    @@ -47,8 +47,8 @@ Note that "cdc" can be also a longest uncommon subsequence.

    Constraints:

      -
    • Both strings' lengths will be between [1 - 100].
    • -
    • Only letters from a ~ z will appear in input strings.
    • +
    • 1 <= a.length, b.length <= 100
    • +
    • a and b consist of lower-case English letters.
    ### Related Topics diff --git a/problems/longest-uncommon-subsequence-ii/README.md b/problems/longest-uncommon-subsequence-ii/README.md index 996887d76..de2e5f0da 100644 --- a/problems/longest-uncommon-subsequence-ii/README.md +++ b/problems/longest-uncommon-subsequence-ii/README.md @@ -5,7 +5,7 @@ -[< Previous](../longest-uncommon-subsequence-i "Longest Uncommon Subsequence I ") +[< Previous](../longest-uncommon-subsequence-i "Longest Uncommon Subsequence I")                  [Next >](../continuous-subarray-sum "Continuous Subarray Sum") @@ -41,4 +41,4 @@ The input will be a list of strings, and the output needs to be the length of th [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Longest Uncommon Subsequence I ](../longest-uncommon-subsequence-i) (Easy) + 1. [Longest Uncommon Subsequence I](../longest-uncommon-subsequence-i) (Easy) diff --git a/problems/matrix-diagonal-sum/README.md b/problems/matrix-diagonal-sum/README.md new file mode 100644 index 000000000..11e07ad2d --- /dev/null +++ b/problems/matrix-diagonal-sum/README.md @@ -0,0 +1,63 @@ + + + + + + + +[< Previous](../warehouse-manager "Warehouse Manager") +                 +[Next >](../number-of-ways-to-split-a-string "Number of Ways to Split a String") + +## [1572. Matrix Diagonal Sum (Easy)](https://leetcode.com/problems/matrix-diagonal-sum "矩阵对角线元素的和") + +

    Given a square matrix mat, return the sum of the matrix diagonals.

    + +

    Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are not part of the primary diagonal.

    + +

     

    +

    Example 1:

    + +
    +Input: mat = [[1,2,3],
    +              [4,5,6],
    +              [7,8,9]]
    +Output: 25
    +Explanation: Diagonals sum: 1 + 5 + 9 + 3 + 7 = 25
    +Notice that element mat[1][1] = 5 is counted only once.
    +
    + +

    Example 2:

    + +
    +Input: mat = [[1,1,1,1],
    +              [1,1,1,1],
    +              [1,1,1,1],
    +              [1,1,1,1]]
    +Output: 8
    +
    + +

    Example 3:

    + +
    +Input: mat = [[5]]
    +Output: 5
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == mat.length == mat[i].length
    • +
    • 1 <= n <= 100
    • +
    • 1 <= mat[i][j] <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +There will be overlap of elements in the primary and secondary diagonals if and only if the length of the matrix is odd, which is at the center. +
    diff --git a/problems/maximum-subarray/README.md b/problems/maximum-subarray/README.md index a16dc4f22..62c98b35b 100644 --- a/problems/maximum-subarray/README.md +++ b/problems/maximum-subarray/README.md @@ -11,19 +11,54 @@ ## [53. Maximum Subarray (Easy)](https://leetcode.com/problems/maximum-subarray "最大子序和") -

    Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.

    +

    Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.

    -

    Example:

    +

    Follow up: If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle.

    + +

     

    +

    Example 1:

    -Input: [-2,1,-3,4,-1,2,1,-5,4],
    +Input: nums = [-2,1,-3,4,-1,2,1,-5,4]
     Output: 6
    -Explanation: [4,-1,2,1] has the largest sum = 6.
    +Explanation: [4,-1,2,1] has the largest sum = 6.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1]
    +Output: 1
    +
    + +

    Example 3:

    + +
    +Input: nums = [0]
    +Output: 0
    +
    + +

    Example 4:

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

    Example 5:

    + +
    +Input: nums = [-2147483647]
    +Output: -2147483647
     
    -

    Follow up:

    +

     

    +

    Constraints:

    -

    If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle.

    +
      +
    • 1 <= nums.length <= 2 * 104
    • +
    • -231 <= nums[i] <= 231 - 1
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/median-of-two-sorted-arrays/README.md b/problems/median-of-two-sorted-arrays/README.md index 6d9561d78..04ebe89cd 100644 --- a/problems/median-of-two-sorted-arrays/README.md +++ b/problems/median-of-two-sorted-arrays/README.md @@ -11,9 +11,7 @@ ## [4. Median of Two Sorted Arrays (Hard)](https://leetcode.com/problems/median-of-two-sorted-arrays "寻找两个正序数组的中位数") -

    Given two sorted arrays nums1 and nums2 of size m and n respectively.

    - -

    Return the median of the two sorted arrays.

    +

    Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.

    Follow up: The overall run time complexity should be O(log (m+n)).

    @@ -59,8 +57,8 @@

    Constraints:

      -
    • nums1,length == m
    • -
    • nums2,length == n
    • +
    • nums1.length == m
    • +
    • nums2.length == n
    • 0 <= m <= 1000
    • 0 <= n <= 1000
    • 1 <= m + n <= 2000
    • diff --git a/problems/merge-k-sorted-lists/README.md b/problems/merge-k-sorted-lists/README.md index eca2c3623..ea4200897 100644 --- a/problems/merge-k-sorted-lists/README.md +++ b/problems/merge-k-sorted-lists/README.md @@ -11,9 +11,9 @@ ## [23. Merge k Sorted Lists (Hard)](https://leetcode.com/problems/merge-k-sorted-lists "合并K个升序链表") -

      Given an array of linked-lists lists, each linked list is sorted in ascending order.

      +

      You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.

      -

      Merge all the linked-lists into one sort linked-list and return it.

      +

      Merge all the linked-lists into one sorted linked-list and return it.

       

      Example 1:

      diff --git a/problems/minimum-cost-to-move-chips-to-the-same-position/README.md b/problems/minimum-cost-to-move-chips-to-the-same-position/README.md index 100a49005..91e5e823f 100644 --- a/problems/minimum-cost-to-move-chips-to-the-same-position/README.md +++ b/problems/minimum-cost-to-move-chips-to-the-same-position/README.md @@ -13,7 +13,7 @@

      We have n chips, where the position of the ith chip is position[i].

      -

      We need to move all the chips to the same position, In one step, we can change the position of the ith chip from position[i] to:

      +

      We need to move all the chips to the same position. In one step, we can change the position of the ith chip from position[i] to:

      • position[i] + 2 or position[i] - 2 with cost = 0.
      • diff --git a/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md b/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md new file mode 100644 index 000000000..5a18b7798 --- /dev/null +++ b/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md @@ -0,0 +1,62 @@ + + + + + + + +[< Previous](../number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "Number of Ways Where Square of Number Is Equal to Product of Two Numbers") +                 +[Next >](../remove-max-number-of-edges-to-keep-graph-fully-traversable "Remove Max Number of Edges to Keep Graph Fully Traversable") + +## [1578. Minimum Deletion Cost to Avoid Repeating Letters (Medium)](https://leetcode.com/problems/minimum-deletion-cost-to-avoid-repeating-letters "避免重复字母的最小删除成本") + +

        Given a string s and an array of integers cost where cost[i] is the cost of deleting the character i in s.

        + +

        Return the minimum cost of deletions such that there are no two identical letters next to each other.

        + +

        Notice that you will delete the chosen characters at the same time, in other words, after deleting a character, the costs of deleting other characters will not change.

        + +

         

        +

        Example 1:

        + +
        +Input: s = "abaac", cost = [1,2,3,4,5]
        +Output: 3
        +Explanation: Delete the letter "a" with cost 3 to get "abac" (String without two identical letters next to each other).
        +
        + +

        Example 2:

        + +
        +Input: s = "abc", cost = [1,2,3]
        +Output: 0
        +Explanation: You don't need to delete any character because there are no identical letters next to each other.
        +
        + +

        Example 3:

        + +
        +Input: s = "aabaa", cost = [1,2,3,4,1]
        +Output: 2
        +Explanation: Delete the first and the last character, getting the string ("aba").
        +
        + +

         

        +

        Constraints:

        + +
          +
        • s.length == cost.length
        • +
        • 1 <= s.length, cost.length <= 10^5
        • +
        • 1 <= cost[i] <= 10^4
        • +
        • s contains only lowercase English letters.
        • +
        + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
        +Hint 1 +Maintain the running sum and max value for repeated letters. +
        diff --git a/problems/minimum-height-trees/README.md b/problems/minimum-height-trees/README.md index 6bf1fcac9..633678fcb 100644 --- a/problems/minimum-height-trees/README.md +++ b/problems/minimum-height-trees/README.md @@ -13,9 +13,9 @@

        A tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles is a tree.

        -

        Given a tree of n nodes and n - 1 edges where edges[i] = [ai, bi] indicates that there is an undirected edge between the two nodes ai and bi in the tree, you can choose any node of the tree as the root. When you select a node x as the root, the result tree has height h. Among all possible rooted trees, those with minimum height (i.e. min(h))  are called minimum height trees (MHTs).

        +

        Given a tree of n nodes labelled from 0 to n - 1, and an array of n - 1 edges where edges[i] = [ai, bi] indicates that there is an undirected edge between the two nodes ai and bi in the tree, you can choose any node of the tree as the root. When you select a node x as the root, the result tree has height h. Among all possible rooted trees, those with minimum height (i.e. min(h))  are called minimum height trees (MHTs).

        -

        Return a list of the root labels of all the MHTs. You can return the answer in any order.

        +

        Return a list of all MHTs' root labels. You can return the answer in any order.

        The height of a rooted tree is the number of edges on the longest downward path between the root and a leaf.

        @@ -25,7 +25,7 @@
         Input: n = 4, edges = [[1,0],[1,2],[1,3]]
         Output: [1]
        -Explanation: As shown, the height of the tree is 1 when the root is one which is the only MHT.
        +Explanation: As shown, the height of the tree is 1 when the root is the node with label 1 which is the only MHT.
         

        Example 2:

        @@ -58,7 +58,7 @@
      • 0 <= ai, bi < n
      • ai != bi
      • All the pairs (ai, bi) are distinct.
      • -
      • The given input is guaranteed to be a tree.
      • +
      • The given input is guaranteed to be a tree and there will be no repeated edges.
      ### Related Topics diff --git a/problems/minimum-number-of-days-to-disconnect-island/README.md b/problems/minimum-number-of-days-to-disconnect-island/README.md index 76e8456fe..a08336a51 100644 --- a/problems/minimum-number-of-days-to-disconnect-island/README.md +++ b/problems/minimum-number-of-days-to-disconnect-island/README.md @@ -9,7 +9,7 @@                  [Next >](../number-of-ways-to-reorder-array-to-get-same-bst "Number of Ways to Reorder Array to Get Same BST") -## [1568. Minimum Number of Days to Disconnect Island (Medium)](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数") +## [1568. Minimum Number of Days to Disconnect Island (Hard)](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数")

      Given a 2D grid consisting of 1s (land) and 0s (water).  An island is a maximal 4-directionally (horizontal or vertical) connected group of 1s.

      diff --git a/problems/n-queens/README.md b/problems/n-queens/README.md index 490a35e02..1e9f9e1cd 100644 --- a/problems/n-queens/README.md +++ b/problems/n-queens/README.md @@ -9,7 +9,7 @@                  [Next >](../n-queens-ii "N-Queens II") -## [51. N-Queens (Hard)](https://leetcode.com/problems/n-queens "N皇后") +## [51. N-Queens (Hard)](https://leetcode.com/problems/n-queens "N 皇后")

      The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.

      diff --git a/problems/number-of-submatrices-that-sum-to-target/README.md b/problems/number-of-submatrices-that-sum-to-target/README.md index 14b4947e0..df3becaef 100644 --- a/problems/number-of-submatrices-that-sum-to-target/README.md +++ b/problems/number-of-submatrices-that-sum-to-target/README.md @@ -11,42 +11,35 @@ ## [1074. Number of Submatrices That Sum to Target (Hard)](https://leetcode.com/problems/number-of-submatrices-that-sum-to-target "元素和为目标值的子矩阵数量") -

      Given a matrix, and a target, return the number of non-empty submatrices that sum to target.

      +

      Given a matrix and a target, return the number of non-empty submatrices that sum to target.

      A submatrix x1, y1, x2, y2 is the set of all cells matrix[x][y] with x1 <= x <= x2 and y1 <= y <= y2.

      Two submatrices (x1, y1, x2, y2) and (x1', y1', x2', y2') are different if they have some coordinate that is different: for example, if x1 != x1'.

       

      -

      Example 1:

      - +
      -Input: matrix = [[0,1,0],[1,1,1],[0,1,0]], target = 0
      -Output: 4
      -Explanation: The four 1x1 submatrices that only contain 0.
      +Input: matrix = [[0,1,0],[1,1,1],[0,1,0]], target = 0
      +Output: 4
      +Explanation: The four 1x1 submatrices that only contain 0.
       
      -

      Example 2:

      -Input: matrix = [[1,-1],[-1,1]], target = 0
      -Output: 5
      -Explanation: The two 1x2 submatrices, plus the two 2x1 submatrices, plus the 2x2 submatrix.
      +Input: matrix = [[1,-1],[-1,1]], target = 0
      +Output: 5
      +Explanation: The two 1x2 submatrices, plus the two 2x1 submatrices, plus the 2x2 submatrix.
       
      -
      - -

       

      -

      Note:

      +

      Example 3:

      -
        -
      1. 1 <= matrix.length <= 300
      2. -
      3. 1 <= matrix[0].length <= 300
      4. -
      5. -1000 <= matrix[i] <= 1000
      6. -
      7. -10^8 <= target <= 10^8
      8. -
      +
      +Input: matrix = [[904]], target = 0
      +Output: 0
      +

       

      Constraints:

      diff --git a/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md b/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md index 93305364d..3ae435352 100644 --- a/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md +++ b/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md @@ -7,7 +7,7 @@ [< Previous](../minimum-number-of-days-to-disconnect-island "Minimum Number of Days to Disconnect Island")                  -Next > +[Next >](../dot-product-of-two-sparse-vectors "Dot Product of Two Sparse Vectors") ## [1569. Number of Ways to Reorder Array to Get Same BST (Hard)](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst "将子数组重新排序得到同一个二叉查找树的方案数") diff --git a/problems/number-of-ways-to-split-a-string/README.md b/problems/number-of-ways-to-split-a-string/README.md new file mode 100644 index 000000000..0423ba39c --- /dev/null +++ b/problems/number-of-ways-to-split-a-string/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../matrix-diagonal-sum "Matrix Diagonal Sum") +                 +[Next >](../shortest-subarray-to-be-removed-to-make-array-sorted "Shortest Subarray to be Removed to Make Array Sorted") + +## [1573. Number of Ways to Split a String (Medium)](https://leetcode.com/problems/number-of-ways-to-split-a-string "分割字符串的方案数") + +

      Given a binary string s (a string consisting only of '0's and '1's), we can split s into 3 non-empty strings s1, s2, s3 (s1+ s2+ s3 = s).

      + +

      Return the number of ways s can be split such that the number of characters '1' is the same in s1, s2, and s3.

      + +

      Since the answer may be too large, return it modulo 10^9 + 7.

      + +

       

      +

      Example 1:

      + +
      +Input: s = "10101"
      +Output: 4
      +Explanation: There are four ways to split s in 3 parts where each part contain the same number of letters '1'.
      +"1|010|1"
      +"1|01|01"
      +"10|10|1"
      +"10|1|01"
      +
      + +

      Example 2:

      + +
      +Input: s = "1001"
      +Output: 0
      +
      + +

      Example 3:

      + +
      +Input: s = "0000"
      +Output: 3
      +Explanation: There are three ways to split s in 3 parts.
      +"0|0|00"
      +"0|00|0"
      +"00|0|0"
      +
      + +

      Example 4:

      + +
      +Input: s = "100100010100110"
      +Output: 12
      +
      + +

       

      +

      Constraints:

      + +
        +
      • s[i] == '0' or s[i] == '1'
      • +
      • 3 <= s.length <= 10^5
      • +
      + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
      +Hint 1 +There is no way if the sum (number of '1's) is not divisible by the number of splits. So sum%3 should be 0. +
      + +
      +Hint 2 +Preffix s1 , and suffix s3 should have sum/3 characters '1'. +
      + +
      +Hint 3 +Follow up: Can you generalize the problem with numbers between [-10^9, 10^9] such the sum between subarrays s1, s2, s3 are the same? +
      diff --git a/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md b/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md new file mode 100644 index 000000000..d1f18496a --- /dev/null +++ b/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../replace-all-s-to-avoid-consecutive-repeating-characters "Replace All ?'s to Avoid Consecutive Repeating Characters") +                 +[Next >](../minimum-deletion-cost-to-avoid-repeating-letters "Minimum Deletion Cost to Avoid Repeating Letters") + +## [1577. Number of Ways Where Square of Number Is Equal to Product of Two Numbers (Medium)](https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "数的平方等于两数乘积的方法数") + +

      Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:

      + +
        +
      • Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
      • +
      • Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where 0 <= i < nums2.length and 0 <= j < k < nums1.length.
      • +
      + +

       

      +

      Example 1:

      + +
      +Input: nums1 = [7,4], nums2 = [5,2,8,9]
      +Output: 1
      +Explanation: Type 1: (1,1,2), nums1[1]^2 = nums2[1] * nums2[2]. (4^2 = 2 * 8). 
      +
      + +

      Example 2:

      + +
      +Input: nums1 = [1,1], nums2 = [1,1,1]
      +Output: 9
      +Explanation: All Triplets are valid, because 1^2 = 1 * 1.
      +Type 1: (0,0,1), (0,0,2), (0,1,2), (1,0,1), (1,0,2), (1,1,2).  nums1[i]^2 = nums2[j] * nums2[k].
      +Type 2: (0,0,1), (1,0,1), (2,0,1). nums2[i]^2 = nums1[j] * nums1[k].
      +
      + +

      Example 3:

      + +
      +Input: nums1 = [7,7,8,3], nums2 = [1,2,9,7]
      +Output: 2
      +Explanation: There are 2 valid triplets.
      +Type 1: (3,0,2).  nums1[3]^2 = nums2[0] * nums2[2].
      +Type 2: (3,0,1).  nums2[3]^2 = nums1[0] * nums1[1].
      +
      + +

      Example 4:

      + +
      +Input: nums1 = [4,7,9,11,23], nums2 = [3,5,1024,12,18]
      +Output: 0
      +Explanation: There are no valid triplets.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= nums1.length, nums2.length <= 1000
      • +
      • 1 <= nums1[i], nums2[i] <= 10^5
      • +
      + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
      +Hint 1 +Precalculate the frequencies of all nums1[i]^2 and nums2[i]^2 +
      diff --git a/problems/numbers-at-most-n-given-digit-set/README.md b/problems/numbers-at-most-n-given-digit-set/README.md index 6f2a2ecc8..4bef084e9 100644 --- a/problems/numbers-at-most-n-given-digit-set/README.md +++ b/problems/numbers-at-most-n-given-digit-set/README.md @@ -11,45 +11,50 @@ ## [902. Numbers At Most N Given Digit Set (Hard)](https://leetcode.com/problems/numbers-at-most-n-given-digit-set "最大为 N 的数字组合") -

      We have a sorted set of digits D, a non-empty subset of {'1','2','3','4','5','6','7','8','9'}.  (Note that '0' is not included.)

      +

      Given an array of digits, you can write numbers using each digits[i] as many times as we want.  For example, if digits = ['1','3','5'], we may write numbers such as '13', '551', and '1351315'.

      -

      Now, we write numbers using these digits, using each digit as many times as we want.  For example, if D = {'1','3','5'}, we may write numbers such as '13', '551', '1351315'.

      - -

      Return the number of positive integers that can be written (using the digits of D) that are less than or equal to N.

      +

      Return the number of positive integers that can be generated that are less than or equal to a given integer n.

       

      -

      Example 1:

      -Input: D = ["1","3","5","7"], N = 100
      -Output: 20
      +Input: digits = ["1","3","5","7"], n = 100
      +Output: 20
       Explanation: 
       The 20 numbers that can be written are:
       1, 3, 5, 7, 11, 13, 15, 17, 31, 33, 35, 37, 51, 53, 55, 57, 71, 73, 75, 77.
       
      -

      Example 2:

      -Input: D = ["1","4","9"], N = 1000000000
      -Output: 29523
      +Input: digits = ["1","4","9"], n = 1000000000
      +Output: 29523
       Explanation: 
       We can write 3 one digit numbers, 9 two digit numbers, 27 three digit numbers,
       81 four digit numbers, 243 five digit numbers, 729 six digit numbers,
       2187 seven digit numbers, 6561 eight digit numbers, and 19683 nine digit numbers.
      -In total, this is 29523 integers that can be written using the digits of D.
      -
      +In total, this is 29523 integers that can be written using the digits array. + -

       

      +

      Example 3:

      -

      Note:

      +
      +Input: digits = ["7"], n = 8
      +Output: 1
      +
      -
        -
      1. D is a subset of digits '1'-'9' in sorted order.
      2. -
      3. 1 <= N <= 10^9
      4. -
      +

       

      +

      Constraints:

      + +
        +
      • 1 <= digits.length <= 9
      • +
      • digits[i].length == 1
      • +
      • digits[i] is a digit from '1' to '9'.
      • +
      • All the values in digits are unique.
      • +
      • 1 <= n <= 109
      • +
      ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/palindrome-partitioning-ii/README.md b/problems/palindrome-partitioning-ii/README.md index 9f1832987..c84c2a044 100644 --- a/problems/palindrome-partitioning-ii/README.md +++ b/problems/palindrome-partitioning-ii/README.md @@ -11,7 +11,7 @@ ## [132. Palindrome Partitioning II (Hard)](https://leetcode.com/problems/palindrome-partitioning-ii "分割回文串 II") -

      Given a string s, partition s such that every substring of the partition is a palindrome

      +

      Given a string s, partition s such that every substring of the partition is a palindrome.

      Return the minimum cuts needed for a palindrome partitioning of s.

      diff --git a/problems/pancake-sorting/README.md b/problems/pancake-sorting/README.md index 2e2bd5f39..e7c8561fa 100644 --- a/problems/pancake-sorting/README.md +++ b/problems/pancake-sorting/README.md @@ -11,39 +11,39 @@ ## [969. Pancake Sorting (Medium)](https://leetcode.com/problems/pancake-sorting "煎饼排序") -

      Given an array of integers A, We need to sort the array performing a series of pancake flips.

      +

      Given an array of integers arr, sort the array by performing a series of pancake flips.

      In one pancake flip we do the following steps:

        -
      • Choose an integer k where 0 <= k < A.length.
      • -
      • Reverse the sub-array A[0...k].
      • +
      • Choose an integer k where 1 <= k <= arr.length.
      • +
      • Reverse the sub-array arr[1...k].
      -

      For example, if A = [3,2,1,4] and we performed a pancake flip choosing k = 2, we reverse the sub-array [3,2,1], so A = [1,2,3,4] after the pancake flip at k = 2.

      +

      For example, if arr = [3,2,1,4] and we performed a pancake flip choosing k = 3, we reverse the sub-array [3,2,1], so arr = [1,2,3,4] after the pancake flip at k = 3.

      -

      Return an array of the k-values of the pancake flips that should be performed in order to sort A. Any valid answer that sorts the array within 10 * A.length flips will be judged as correct.

      +

      Return the k-values corresponding to a sequence of pancake flips that sort arr. Any valid answer that sorts the array within 10 * arr.length flips will be judged as correct.

       

      Example 1:

      -Input: A = [3,2,4,1]
      +Input: arr = [3,2,4,1]
       Output: [4,2,4,3]
       Explanation: 
       We perform 4 pancake flips, with k values 4, 2, 4, and 3.
      -Starting state: A = [3, 2, 4, 1]
      -After 1st flip (k = 4): A = [1, 4, 2, 3]
      -After 2nd flip (k = 2): A = [4, 1, 2, 3]
      -After 3rd flip (k = 4): A = [3, 2, 1, 4]
      -After 4th flip (k = 3): A = [1, 2, 3, 4], which is sorted.
      +Starting state: arr = [3, 2, 4, 1]
      +After 1st flip (k = 4): arr = [1, 4, 2, 3]
      +After 2nd flip (k = 2): arr = [4, 1, 2, 3]
      +After 3rd flip (k = 4): arr = [3, 2, 1, 4]
      +After 4th flip (k = 3): arr = [1, 2, 3, 4], which is sorted.
       Notice that we return an array of the chosen k values of the pancake flips.
       

      Example 2:

      -Input: A = [1,2,3]
      +Input: arr = [1,2,3]
       Output: []
       Explanation: The input is already sorted, so there is no need to flip anything.
       Note that other answers, such as [3, 3], would also be accepted.
      @@ -53,9 +53,9 @@ Note that other answers, such as [3, 3], would also be accepted.
       

      Constraints:

        -
      • 1 <= A.length <= 100
      • -
      • 1 <= A[i] <= A.length
      • -
      • All integers in A are unique (i.e. A is a permutation of the integers from 1 to A.length).
      • +
      • 1 <= arr.length <= 100
      • +
      • 1 <= arr[i] <= arr.length
      • +
      • All integers in arr are unique (i.e. arr is a permutation of the integers from 1 to arr.length).
      ### Related Topics diff --git a/problems/partition-array-for-maximum-sum/README.md b/problems/partition-array-for-maximum-sum/README.md index 0c2ac4cbc..6358fac36 100644 --- a/problems/partition-array-for-maximum-sum/README.md +++ b/problems/partition-array-for-maximum-sum/README.md @@ -11,30 +11,44 @@ ## [1043. Partition Array for Maximum Sum (Medium)](https://leetcode.com/problems/partition-array-for-maximum-sum "分隔数组以得到最大和") -

      Given an integer array A, you partition the array into (contiguous) subarrays of length at most K.  After partitioning, each subarray has their values changed to become the maximum value of that subarray.

      +

      Given an integer array arr, you should partition the array into (contiguous) subarrays of length at most k. After partitioning, each subarray has their values changed to become the maximum value of that subarray.

      -

      Return the largest sum of the given array after partitioning.

      +

      Return the largest sum of the given array after partitioning.

       

      -

      Example 1:

      -Input: A = [1,15,7,9,2,5,10], K = 3
      -Output: 84
      -Explanation: A becomes [15,15,15,9,10,10,10]
      +Input: arr = [1,15,7,9,2,5,10], k = 3 +Output: 84 +Explanation: arr becomes [15,15,15,9,10,10,10] +
      -

       

      +

      Example 2:

      + +
      +Input: arr = [1,4,1,5,7,3,6,1,9,9,3], k = 4
      +Output: 83
      +
      -

      Note:

      +

      Example 3:

      + +
      +Input: arr = [1], k = 1
      +Output: 1
      +
      + +

       

      +

      Constraints:

      -
        -
      1. 1 <= K <= A.length <= 500
      2. -
      3. 0 <= A[i] <= 10^6
      4. -
      +
        +
      • 1 <= arr.length <= 500
      • +
      • 0 <= arr[i] <= 109
      • +
      • 1 <= k <= arr.length
      • +
      ### Related Topics - [[Graph](../../tag/graph/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
      diff --git a/problems/random-pick-with-weight/README.md b/problems/random-pick-with-weight/README.md index c6caa1433..ec1328c8e 100644 --- a/problems/random-pick-with-weight/README.md +++ b/problems/random-pick-with-weight/README.md @@ -11,9 +11,9 @@ ## [528. Random Pick with Weight (Medium)](https://leetcode.com/problems/random-pick-with-weight "按权重随机选择") -

      Given an array of positive integers w. where w[i] describes the weight of ith index (0-indexed).

      +

      You are given an array of positive integers w where w[i] describes the weight of ith index (0-indexed).

      -

      We need to call the function pickIndex() which randomly returns an integer in the range [0, w.length - 1]pickIndex() should return the integer proportional to its weight in the w array. For example, for w = [1, 3], the probability of picking index 0 is 1 / (1 + 3) = 0.25 (i.e 25%) while the probability of picking index 1 is 3 / (1 + 3) = 0.75 (i.e 75%).

      +

      We need to call the function pickIndex() which randomly returns an integer in the range [0, w.length - 1]pickIndex() should return the integer proportional to its weight in the w array. For example, for w = [1, 3], the probability of picking the index 0 is 1 / (1 + 3) = 0.25 (i.e 25%) while the probability of picking the index 1 is 3 / (1 + 3) = 0.75 (i.e 75%).

      More formally, the probability of picking index i is w[i] / sum(w).

      diff --git a/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md b/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md new file mode 100644 index 000000000..d6f46aa42 --- /dev/null +++ b/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md @@ -0,0 +1,92 @@ + + + + + + + +[< Previous](../minimum-deletion-cost-to-avoid-repeating-letters "Minimum Deletion Cost to Avoid Repeating Letters") +                 +Next > + +## [1579. Remove Max Number of Edges to Keep Graph Fully Traversable (Hard)](https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable "保证图可完全遍历") + +

      Alice and Bob have an undirected graph of n nodes and 3 types of edges:

      + +
        +
      • Type 1: Can be traversed by Alice only.
      • +
      • Type 2: Can be traversed by Bob only.
      • +
      • Type 3: Can by traversed by both Alice and Bob.
      • +
      + +

      Given an array edges where edges[i] = [typei, ui, vi] represents a bidirectional edge of type typei between nodes ui and vi, find the maximum number of edges you can remove so that after removing the edges, the graph can still be fully traversed by both Alice and Bob. The graph is fully traversed by Alice and Bob if starting from any node, they can reach all other nodes.

      + +

      Return the maximum number of edges you can remove, or return -1 if it's impossible for the graph to be fully traversed by Alice and Bob.

      + +

       

      +

      Example 1:

      + +

      + +
      +Input: n = 4, edges = [[3,1,2],[3,2,3],[1,1,3],[1,2,4],[1,1,2],[2,3,4]]
      +Output: 2
      +Explanation: If we remove the 2 edges [1,1,2] and [1,1,3]. The graph will still be fully traversable by Alice and Bob. Removing any additional edge will not make it so. So the maximum number of edges we can remove is 2.
      +
      + +

      Example 2:

      + +

      + +
      +Input: n = 4, edges = [[3,1,2],[3,2,3],[1,1,4],[2,1,4]]
      +Output: 0
      +Explanation: Notice that removing any edge will not make the graph fully traversable by Alice and Bob.
      +
      + +

      Example 3:

      + +

      + +
      +Input: n = 4, edges = [[3,2,3],[1,1,2],[2,3,4]]
      +Output: -1
      +Explanation: In the current graph, Alice cannot reach node 4 from the other nodes. Likewise, Bob cannot reach 1. Therefore it's impossible to make the graph fully traversable.
      + +

       

      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= n <= 10^5
      • +
      • 1 <= edges.length <= min(10^5, 3 * n * (n-1) / 2)
      • +
      • edges[i].length == 3
      • +
      • 1 <= edges[i][0] <= 3
      • +
      • 1 <= edges[i][1] < edges[i][2] <= n
      • +
      • All tuples (typei, ui, vi) are distinct.
      • +
      + +### Related Topics + [[Union Find](../../tag/union-find/README.md)] + +### Hints +
      +Hint 1 +Build the network instead of removing extra edges. +
      + +
      +Hint 2 +Suppose you have the final graph (after removing extra edges). Consider the subgraph with only the edges that Alice can traverse. What structure does this subgraph have? How many edges are there? +
      + +
      +Hint 3 +Use disjoint set union data structure for both Alice and Bob. +
      + +
      +Hint 4 +Always use Type 3 edges first, and connect the still isolated ones using other edges. +
      diff --git a/problems/repeated-string-match/README.md b/problems/repeated-string-match/README.md index 7d9fb4798..457d2a20b 100644 --- a/problems/repeated-string-match/README.md +++ b/problems/repeated-string-match/README.md @@ -11,7 +11,7 @@ ## [686. Repeated String Match (Medium)](https://leetcode.com/problems/repeated-string-match "重复叠加字符串匹配") -

      Given two strings a and b, return the minimum number of times you should repeat the string a so that string b is a substring of it. If it's impossible for b​​​​​​ to be a substring of a after repeating it, return -1.

      +

      Given two strings a and b, return the minimum number of times you should repeat string a so that string b is a substring of it. If it is impossible for b​​​​​​ to be a substring of a after repeating it, return -1.

      Notice: string "abc" repeated 0 times is "",  repeated 1 time is "abc" and repeated 2 times is "abcabc".

      diff --git a/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md b/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md new file mode 100644 index 000000000..a3baf7c43 --- /dev/null +++ b/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../count-all-possible-routes "Count All Possible Routes") +                 +[Next >](../number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "Number of Ways Where Square of Number Is Equal to Product of Two Numbers") + +## [1576. Replace All ?'s to Avoid Consecutive Repeating Characters (Easy)](https://leetcode.com/problems/replace-all-s-to-avoid-consecutive-repeating-characters "替换所有的问号") + +

      Given a string s containing only lower case English letters and the '?' character, convert all the '?' characters into lower case letters such that the final string does not contain any consecutive repeating characters. You cannot modify the non '?' characters.

      + +

      It is guaranteed that there are no consecutive repeating characters in the given string except for '?'.

      + +

      Return the final string after all the conversions (possibly zero) have been made. If there is more than one solution, return any of them. It can be shown that an answer is always possible with the given constraints.

      + +

       

      +

      Example 1:

      + +
      +Input: s = "?zs"
      +Output: "azs"
      +Explanation: There are 25 solutions for this problem. From "azs" to "yzs", all are valid. Only "z" is an invalid modification as the string will consist of consecutive repeating characters in "zzs".
      + +

      Example 2:

      + +
      +Input: s = "ubv?w"
      +Output: "ubvaw"
      +Explanation: There are 24 solutions for this problem. Only "v" and "w" are invalid modifications as the strings will consist of consecutive repeating characters in "ubvvw" and "ubvww".
      +
      + +

      Example 3:

      + +
      +Input: s = "j?qg??b"
      +Output: "jaqgacb"
      +
      + +

      Example 4:

      + +
      +Input: s = "??yw?ipkj?"
      +Output: "acywaipkja"
      +
      + +

       

      +

      Constraints:

      + +
        +
      • +

        1 <= s.length <= 100

        +
      • +
      • +

        s contains only lower case English letters and '?'.

        +
      • +
      + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
      +Hint 1 +Processing string from left to right, whenever you get a ‘?’, check left character and right character, and select a character not equal to either of them +
      + +
      +Hint 2 +Do take care to compare with replaced occurrence of ‘?’ when checking the left character. +
      diff --git a/problems/replace-words/README.md b/problems/replace-words/README.md index 7194b9255..940a66dca 100644 --- a/problems/replace-words/README.md +++ b/problems/replace-words/README.md @@ -11,9 +11,9 @@ ## [648. Replace Words (Medium)](https://leetcode.com/problems/replace-words "单词替换") -

      In English, we have a concept called root, which can be followed by some other words to form another longer word - let's call this word successor. For example, when the root "an" is followed by the successor word "other", we can form a new word "another".

      +

      In English, we have a concept called root, which can be followed by some other word to form another longer word - let's call this word successor. For example, when the root "an" is followed by the successor word "other", we can form a new word "another".

      -

      Given a dictionary consisting of many roots and a sentence consisting of words spearted by spaces. You need to replace all the successors in the sentence with the root forming it. If a successor can be replaced by more than one root, replace it with the root with the shortest length.

      +

      Given a dictionary consisting of many roots and a sentence consisting of words separated by spaces, replace all the successors in the sentence with the root forming it. If a successor can be replaced by more than one root, replace it with the root that has the shortest length.

      Return the sentence after the replacement.

      @@ -42,11 +42,11 @@
    • 1 <= dictionary[i].length <= 100
    • dictionary[i] consists of only lower-case letters.
    • 1 <= sentence.length <= 10^6
    • -
    • sentence consists of only lower-case letters ans spaces.
    • +
    • sentence consists of only lower-case letters and spaces.
    • The number of words in sentence is in the range [1, 1000]
    • The length of each word in sentence is in the range [1, 1000]
    • -
    • Each two words in sentence will be separted by exactly one space.
    • -
    • sentence doesn't have leading or trailing spaces.
    • +
    • Each two consecutive words in sentence will be separated by exactly one space.
    • +
    • sentence does not have leading or trailing spaces.
    ### Related Topics diff --git a/problems/restore-ip-addresses/README.md b/problems/restore-ip-addresses/README.md index 7f562fce0..8dfc24cfc 100644 --- a/problems/restore-ip-addresses/README.md +++ b/problems/restore-ip-addresses/README.md @@ -11,9 +11,9 @@ ## [93. Restore IP Addresses (Medium)](https://leetcode.com/problems/restore-ip-addresses "复原IP地址") -

    Given a string s containing only digits. Return all possible valid IP addresses that can be obtained from s. You can return them in any order.

    +

    Given a string s containing only digits, return all possible valid IP addresses that can be obtained from s. You can return them in any order.

    -

    A valid IP address consists of exactly four integers, each integer is between 0 and 255, separated by single points and cannot have leading zeros. For example, "0.1.2.201" and "192.168.1.1" are valid IP addresses and "0.011.255.245", "192.168.1.312" and "192.168@1.1" are invalid IP addresses. 

    +

    A valid IP address consists of exactly four integers, each integer is between 0 and 255, separated by single dots and cannot have leading zeros. For example, "0.1.2.201" and "192.168.1.1" are valid IP addresses and "0.011.255.245", "192.168.1.312" and "192.168@1.1" are invalid IP addresses. 

     

    Example 1:

    diff --git a/problems/search-in-rotated-sorted-array/README.md b/problems/search-in-rotated-sorted-array/README.md index 48b8d6919..7d6c4e470 100644 --- a/problems/search-in-rotated-sorted-array/README.md +++ b/problems/search-in-rotated-sorted-array/README.md @@ -11,11 +11,11 @@ ## [33. Search in Rotated Sorted Array (Medium)](https://leetcode.com/problems/search-in-rotated-sorted-array "搜索旋转排序数组") -

    Given an integer array nums sorted in ascending order, and an integer target.

    +

    You are given an integer array nums sorted in ascending order, and an integer target.

    Suppose that nums is rotated at some pivot unknown to you beforehand (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).

    -

    You should search for target in nums and if you found return its index, otherwise return -1.

    +

    If target is found in the array return its index, otherwise, return -1.

     

    Example 1:

    diff --git a/problems/set-matrix-zeroes/README.md b/problems/set-matrix-zeroes/README.md index e3e5342a6..b49f3ce85 100644 --- a/problems/set-matrix-zeroes/README.md +++ b/problems/set-matrix-zeroes/README.md @@ -43,7 +43,7 @@
  • m == matrix.length
  • n == matrix[0].length
  • 1 <= m, n <= 200
  • -
  • -10^9 <= matrix[i][j] <= 10^9
  • +
  • -231 <= matrix[i][j] <= 231 - 1
  • ### Related Topics diff --git a/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md b/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md new file mode 100644 index 000000000..837fb5589 --- /dev/null +++ b/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../number-of-ways-to-split-a-string "Number of Ways to Split a String") +                 +[Next >](../count-all-possible-routes "Count All Possible Routes") + +## [1574. Shortest Subarray to be Removed to Make Array Sorted (Medium)](https://leetcode.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted "删除最短的子数组使剩余数组有序") + +

    Given an integer array arr, remove a subarray (can be empty) from arr such that the remaining elements in arr are non-decreasing.

    + +

    A subarray is a contiguous subsequence of the array.

    + +

    Return the length of the shortest subarray to remove.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [1,2,3,10,4,2,3,5]
    +Output: 3
    +Explanation: The shortest subarray we can remove is [10,4,2] of length 3. The remaining elements after that will be [1,2,3,3,5] which are sorted.
    +Another correct solution is to remove the subarray [3,10,4].
    + +

    Example 2:

    + +
    +Input: arr = [5,4,3,2,1]
    +Output: 4
    +Explanation: Since the array is strictly decreasing, we can only keep a single element. Therefore we need to remove a subarray of length 4, either [5,4,3,2] or [4,3,2,1].
    +
    + +

    Example 3:

    + +
    +Input: arr = [1,2,3]
    +Output: 0
    +Explanation: The array is already non-decreasing. We do not need to remove any elements.
    +
    + +

    Example 4:

    + +
    +Input: arr = [1]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 10^5
    • +
    • 0 <= arr[i] <= 10^9
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +The key is to find the longest non-decreasing subarray starting with the first element or ending with the last element, respectively. +
    + +
    +Hint 2 +After removing some subarray, the result is the concatenation of a sorted prefix and a sorted suffix, where the last element of the prefix is smaller than the first element of the suffix. +
    diff --git a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md index 60115f049..684f083a9 100644 --- a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md +++ b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md @@ -50,7 +50,7 @@ Notice that nodes 5, 3 and 2 contain the deepest nodes in the tree but node 2 is

    Constraints:

      -
    • The number of nodes in the tree will be between in the range [1, 500].
    • +
    • The number of nodes in the tree will be in the range [1, 500].
    • The values of the nodes in the tree are unique.
    diff --git a/problems/string-compression/README.md b/problems/string-compression/README.md index 6196df087..3c6522a82 100644 --- a/problems/string-compression/README.md +++ b/problems/string-compression/README.md @@ -69,13 +69,13 @@ Notice each digit has it's own entry in the array.

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. All characters have an ASCII value in [35, 126].
    2. -
    3. 1 <= len(chars) <= 1000.
    4. -
    +
      +
    • 1 <= chars.length <= 2000
    • +
    • chars[i].length == 1
    • +
    • chars[i] is a lower-case English letter, upper-case English letter, digit or a symbol.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/substring-with-concatenation-of-all-words/README.md b/problems/substring-with-concatenation-of-all-words/README.md index 717be3254..2de03a46c 100644 --- a/problems/substring-with-concatenation-of-all-words/README.md +++ b/problems/substring-with-concatenation-of-all-words/README.md @@ -11,17 +11,16 @@ ## [30. Substring with Concatenation of All Words (Hard)](https://leetcode.com/problems/substring-with-concatenation-of-all-words "串联所有单词的子串") -

    You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any intervening characters.

    +

    You are given a string s and an array of strings words of the same length. Return all starting indices of substring(s) in s that is a concatenation of each word in words exactly once, in any order, and without any intervening characters.

    -

     

    +

    You can return the answer in any order.

    +

     

    Example 1:

    -Input:
    -  s = "barfoothefoobarman",
    -  words = ["foo","bar"]
    -Output: [0,9]
    +Input: s = "barfoothefoobarman", words = ["foo","bar"]
    +Output: [0,9]
     Explanation: Substrings starting at index 0 and 9 are "barfoo" and "foobar" respectively.
     The output order does not matter, returning [9,0] is fine too.
     
    @@ -29,12 +28,28 @@ The output order does not matter, returning [9,0] is fine too.

    Example 2:

    -Input:
    -  s = "wordgoodgoodgoodbestword",
    -  words = ["word","good","best","word"]
    -Output: []
    +Input: s = "wordgoodgoodgoodbestword", words = ["word","good","best","word"]
    +Output: []
    +
    + +

    Example 3:

    + +
    +Input: s = "barfoofoobarthefoobarman", words = ["bar","foo","the"]
    +Output: [6,9,12]
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 104
    • +
    • s consists of lower-case English letters.
    • +
    • 1 <= words.length <= 5000
    • +
    • 1 <= words[i].length <= 30
    • +
    • words[i] consists of lower-case English letters.
    • +
    + ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/swap-adjacent-in-lr-string/README.md b/problems/swap-adjacent-in-lr-string/README.md index dbd7efcc0..caf43aa97 100644 --- a/problems/swap-adjacent-in-lr-string/README.md +++ b/problems/swap-adjacent-in-lr-string/README.md @@ -13,11 +13,12 @@

    In a string composed of 'L', 'R', and 'X' characters, like "RXXLRXRXL", a move consists of either replacing one occurrence of "XL" with "LX", or replacing one occurrence of "RX" with "XR". Given the starting string start and the ending string end, return True if and only if there exists a sequence of moves to transform one string to the other.

    -

    Example:

    +

     

    +

    Example 1:

    -Input: start = "RXXLRXRXL", end = "XRLXXRRLX"
    -Output: True
    +Input: start = "X", end = "L"
    +Output: false
     Explanation:
     We can transform start to end following these steps:
     RXXLRXRXL ->
    @@ -27,12 +28,27 @@ XRLXXRRXL ->
     XRLXXRRLX
     
    +

    Example 2:

    + +
    +Input: start = "LLR", end = "RRL"
    +Output: false
    +
    + +

    Example 3:

    + +
    +Input: start = "XLLR", end = "LXLX"
    +Output: false
    +
    +

     

    Constraints:

      -
    • 1 <= len(start) == len(end) <= 10000.
    • -
    • Both start and end will only consist of characters in {'L', 'R', 'X'}.
    • +
    • 1 <= start.length <= 104
    • +
    • start.length == end.length
    • +
    • Both start and end will only consist of characters in 'L', 'R', and 'X'.
    ### Related Topics diff --git a/problems/two-sum-ii-input-array-is-sorted/README.md b/problems/two-sum-ii-input-array-is-sorted/README.md index 89af39b78..9b7ad3599 100644 --- a/problems/two-sum-ii-input-array-is-sorted/README.md +++ b/problems/two-sum-ii-input-array-is-sorted/README.md @@ -22,12 +22,38 @@
  • You may assume that each input would have exactly one solution and you may not use the same element twice.
  • -

    Example:

    +

     

    +

    Example 1:

     Input: numbers = [2,7,11,15], target = 9
     Output: [1,2]
    -Explanation: The sum of 2 and 7 is 9. Therefore index1 = 1, index2 = 2.
    +Explanation: The sum of 2 and 7 is 9. Therefore index1 = 1, index2 = 2. + + +

    Example 2:

    + +
    +Input: numbers = [2,3,4], target = 6
    +Output: [1,3]
    +
    + +

    Example 3:

    + +
    +Input: numbers = [-1,0], target = -1
    +Output: [1,2]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= nums.length <= 3 * 104
    • +
    • -1000 <= nums[i] <= 1000
    • +
    • nums is sorted in increasing order.
    • +
    • -1000 <= target <= 1000
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/two-sum/README.md b/problems/two-sum/README.md index fcdbef4e5..bfd2afc9a 100644 --- a/problems/two-sum/README.md +++ b/problems/two-sum/README.md @@ -11,7 +11,7 @@ ## [1. Two Sum (Easy)](https://leetcode.com/problems/two-sum "两数之和") -

    Given an array of integers nums and and integer target, return the indices of the two numbers such that they add up to target.

    +

    Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

    You may assume that each input would have exactly one solution, and you may not use the same element twice.

    @@ -23,7 +23,7 @@
     Input: nums = [2,7,11,15], target = 9
     Output: [0,1]
    -Output: Because nums[0] + nums[1] == 9, we return [0, 1]
    +Output: Because nums[0] + nums[1] == 9, we return [0, 1].
     

    Example 2:

    @@ -44,7 +44,7 @@

    Constraints:

      -
    • 1 <= nums.length <= 105
    • +
    • 2 <= nums.length <= 105
    • -109 <= nums[i] <= 109
    • -109 <= target <= 109
    • Only one valid answer exists.
    • diff --git a/problems/validate-ip-address/README.md b/problems/validate-ip-address/README.md index 6fed36f31..7fe511ecf 100644 --- a/problems/validate-ip-address/README.md +++ b/problems/validate-ip-address/README.md @@ -11,21 +11,19 @@ ## [468. Validate IP Address (Medium)](https://leetcode.com/problems/validate-ip-address "验证IP地址") -

      Given a string IP. We need to check If IP is a valid IPv4 address, valid IPv6 address or not a valid IP address.

      +

      Given a string IP, return "IPv4" if IP is a valid IPv4 address, "IPv6" if IP is a valid IPv6 address or "Neither" if IP is not a correct IP of any type.

      -

      Return "IPv4" if IP is a valid IPv4 address, "IPv6" if IP is a valid IPv6 address or "Neither" if IP is not a valid IP of any type.

      - -

      A valid IPv4 address is an IP in the form "x1.x2.x3.x4" where 0 <= xi <= 255 and xi cannot contain leading zeros. For example, "192.168.1.1" and "192.168.1.0" are valid IPv4 addresses but "192.168.01.1", "192.168.1.00" and "192.168@1.1" are invalid IPv4 adresses.

      +

      A valid IPv4 address is an IP in the form "x1.x2.x3.x4" where 0 <= xi <= 255 and xi cannot contain leading zeros. For example, "192.168.1.1" and "192.168.1.0" are valid IPv4 addresses but "192.168.01.1", while "192.168.1.00" and "192.168@1.1" are invalid IPv4 addresses.

      A valid IPv6 address is an IP in the form "x1:x2:x3:x4:x5:x6:x7:x8" where:

      • 1 <= xi.length <= 4
      • -
      • xi is hexadecimal string whcih may contain digits, lower-case English letter ('a' to 'f') and/or upper-case English letters ('A' to 'F').
      • +
      • xi is a hexadecimal string which may contain digits, lower-case English letter ('a' to 'f') and upper-case English letters ('A' to 'F').
      • Leading zeros are allowed in xi.
      -

      For example, "2001:0db8:85a3:0000:0000:8a2e:0370:7334" and "2001:db8:85a3:0:0:8A2E:0370:7334" are valid IPv6 addresses but "2001:0db8:85a3::8A2E:037j:7334" and "02001:0db8:85a3:0000:0000:8a2e:0370:7334" are invalid IPv6 addresses.

      +

      For example, "2001:0db8:85a3:0000:0000:8a2e:0370:7334" and "2001:db8:85a3:0:0:8A2E:0370:7334" are valid IPv6 addresses, while "2001:0db8:85a3::8A2E:037j:7334" and "02001:0db8:85a3:0000:0000:8a2e:0370:7334" are invalid IPv6 addresses.

       

      Example 1:

      diff --git a/problems/warehouse-manager/README.md b/problems/warehouse-manager/README.md new file mode 100644 index 000000000..53f250028 --- /dev/null +++ b/problems/warehouse-manager/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../dot-product-of-two-sparse-vectors "Dot Product of Two Sparse Vectors") +                 +[Next >](../matrix-diagonal-sum "Matrix Diagonal Sum") + +## [1571. Warehouse Manager (Easy)](https://leetcode.com/problems/warehouse-manager "") + + diff --git a/problems/warehouse-manager/mysql_schemas.sql b/problems/warehouse-manager/mysql_schemas.sql new file mode 100644 index 000000000..6f0007cf0 --- /dev/null +++ b/problems/warehouse-manager/mysql_schemas.sql @@ -0,0 +1,15 @@ +Create table If Not Exists Warehouse (name varchar(50), product_id int, units int) +; +Create table If Not Exists Products (product_id int, product_name varchar(50), Width int,Length int,Height int); +Truncate table Warehouse; +insert into Warehouse (name, product_id, units) values ('LCHouse1', '1', '1'); +insert into Warehouse (name, product_id, units) values ('LCHouse1', '2', '10'); +insert into Warehouse (name, product_id, units) values ('LCHouse1', '3', '5'); +insert into Warehouse (name, product_id, units) values ('LCHouse2', '1', '2'); +insert into Warehouse (name, product_id, units) values ('LCHouse2', '2', '2'); +insert into Warehouse (name, product_id, units) values ('LCHouse3', '4', '1'); +Truncate table Products; +insert into Products (product_id, product_name, Width, Length, Height) values ('1', 'LC-TV', '5', '50', '40'); +insert into Products (product_id, product_name, Width, Length, Height) values ('2', 'LC-KeyChain', '5', '5', '5'); +insert into Products (product_id, product_name, Width, Length, Height) values ('3', 'LC-Phone', '2', '10', '10'); +insert into Products (product_id, product_name, Width, Length, Height) values ('4', 'LC-T-Shirt', '4', '10', '20'); diff --git a/readme/1-300.md b/readme/1-300.md index 32aa8599a..79c90b9c2 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -120,7 +120,7 @@ LeetCode Problems' Solutions | 48 | [Rotate Image](https://leetcode.com/problems/rotate-image "旋转图像") | [Go](../problems/rotate-image) | Medium | | 49 | [Group Anagrams](https://leetcode.com/problems/group-anagrams "字母异位词分组") | [Go](../problems/group-anagrams) | Medium | | 50 | [Pow(x, n)](https://leetcode.com/problems/powx-n "Pow(x, n)") | [Go](../problems/powx-n) | Medium | -| 51 | [N-Queens](https://leetcode.com/problems/n-queens "N皇后") | [Go](../problems/n-queens) | Hard | +| 51 | [N-Queens](https://leetcode.com/problems/n-queens "N 皇后") | [Go](../problems/n-queens) | Hard | | 52 | [N-Queens II](https://leetcode.com/problems/n-queens-ii "N皇后 II") | [Go](../problems/n-queens-ii) | Hard | | 53 | [Maximum Subarray](https://leetcode.com/problems/maximum-subarray "最大子序和") | [Go](../problems/maximum-subarray) | Easy | | 54 | [Spiral Matrix](https://leetcode.com/problems/spiral-matrix "螺旋矩阵") | [Go](../problems/spiral-matrix) | Medium | diff --git a/tag/array/README.md b/tag/array/README.md index 33290425d..b981cf3f4 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1572 | [矩阵对角线元素的和](../../problems/matrix-diagonal-sum) | [[数组](../array/README.md)] | Easy | +| 1570 | [Dot Product of Two Sparse Vectors](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1566 | [重复至少 K 次且长度为 M 的模式](../../problems/detect-pattern-of-length-m-repeated-k-or-more-times) | [[数组](../array/README.md)] | Easy | | 1560 | [圆形赛道上经过次数最多的扇区](../../problems/most-visited-sector-in-a-circular-track) | [[数组](../array/README.md)] | Easy | | 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 0eacba95d..c09372b9d 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -54,7 +54,7 @@ | 77 | [组合](../../problems/combinations) | [[回溯算法](../backtracking/README.md)] | Medium | | 60 | [第k个排列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 52 | [N皇后 II](../../problems/n-queens-ii) | [[回溯算法](../backtracking/README.md)] | Hard | -| 51 | [N皇后](../../problems/n-queens) | [[回溯算法](../backtracking/README.md)] | Hard | +| 51 | [N 皇后](../../problems/n-queens) | [[回溯算法](../backtracking/README.md)] | Hard | | 47 | [全排列 II](../../problems/permutations-ii) | [[回溯算法](../backtracking/README.md)] | Medium | | 46 | [全排列](../../problems/permutations) | [[回溯算法](../backtracking/README.md)] | Medium | | 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 94ef29994..e858cedf9 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1562 | [查找大小为 M 的最新分组](../../problems/find-latest-group-of-size-m) | [[二分查找](../binary-search/README.md)] | Medium | | 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1533 | [Find the Index of the Large Integer](../../problems/find-the-index-of-the-large-integer) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index f45c3c592..91e0b0ddc 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1563 | [石子游戏 V](../../problems/stone-game-v) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1553 | [吃掉 N 个橘子的最少天数](../../problems/minimum-number-of-days-to-eat-n-oranges) | [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -89,6 +90,7 @@ | 1055 | [形成字符串的最短路径](../../problems/shortest-way-to-form-string) 🔒 | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1049 | [最后一块石头的重量 II](../../problems/last-stone-weight-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1048 | [最长字符串链](../../problems/longest-string-chain) | [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1043 | [分隔数组以得到最大和](../../problems/partition-array-for-maximum-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1039 | [多边形三角剖分的最低得分](../../problems/minimum-score-triangulation-of-polygon) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1027 | [最长等差数列](../../problems/longest-arithmetic-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1025 | [除数博弈](../../problems/divisor-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | diff --git a/tag/graph/README.md b/tag/graph/README.md index 037e715e3..6d773775d 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -29,7 +29,6 @@ | 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 1059 | [从始点到终点的所有路径](../../problems/all-paths-from-source-lead-to-destination) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1043 | [分隔数组以得到最大和](../../problems/partition-array-for-maximum-sum) | [[图](../graph/README.md)] | Medium | | 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[图](../graph/README.md)] | Easy | | 997 | [找到小镇的法官](../../problems/find-the-town-judge) | [[图](../graph/README.md)] | Easy | | 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 78055c7a4..9448dd2a3 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,7 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1568 | [使陆地分离的最少天数](../../problems/minimum-number-of-days-to-disconnect-island) | [[贪心算法](../greedy/README.md)] | Medium | +| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心算法](../greedy/README.md)] | Medium | +| 1568 | [使陆地分离的最少天数](../../problems/minimum-number-of-days-to-disconnect-island) | [[贪心算法](../greedy/README.md)] | Hard | | 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心算法](../greedy/README.md)] | Medium | | 1564 | [Put Boxes Into the Warehouse I](../../problems/put-boxes-into-the-warehouse-i) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | | 1558 | [得到目标数组的最少函数调用次数](../../problems/minimum-numbers-of-function-calls-to-make-target-array) | [[贪心算法](../greedy/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 2a57aab92..05ab008ff 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 1570 | [Dot Product of Two Sparse Vectors](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 4df5334bc..a5ed7751c 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 1551 | [使数组中所有元素相等的最小操作数](../../problems/minimum-operations-to-make-array-equal) | [[数学](../math/README.md)] | Medium | | 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1523 | [在区间范围内统计奇数数目](../../problems/count-odd-numbers-in-an-interval-range) | [[数学](../math/README.md)] | Easy | diff --git a/tag/string/README.md b/tag/string/README.md index 76e81648a..82789100f 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1576 | [替换所有的问号](../../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | [[字符串](../string/README.md)] | Easy | +| 1573 | [分割字符串的方案数](../../problems/number-of-ways-to-split-a-string) | [[字符串](../string/README.md)] | Medium | | 1556 | [千位分隔数](../../problems/thousand-separator) | [[字符串](../string/README.md)] | Easy | | 1545 | [找出第 N 个二进制字符串中的第 K 位](../../problems/find-kth-bit-in-nth-binary-string) | [[字符串](../string/README.md)] | Medium | | 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index a749ae488..18bb56e56 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1570 | [Dot Product of Two Sparse Vectors](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1248 | [统计「优美子数组」](../../problems/count-number-of-nice-subarrays) | [[双指针](../two-pointers/README.md)] | Medium | | 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index abac1e797..014ce7d7f 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1579 | [保证图可完全遍历](../../problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | [[并查集](../union-find/README.md)] | Hard | | 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | | 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | From 19f56f6adc4001882d7e777b1f6c580ed77a6c8c Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 15 Sep 2020 14:05:41 +0800 Subject: [PATCH 098/145] A: new --- README.md | 6 ++ .../README.md | 83 ++++++++++++++++++ problems/compare-version-numbers/README.md | 69 +++++++++------ problems/count-and-say/README.md | 2 +- problems/count-unhappy-friends/README.md | 85 +++++++++++++++++++ .../README.md | 14 +++ .../mysql_schemas.sql | 16 ++++ .../design-a-file-sharing-system/README.md | 1 + .../README.md | 2 +- problems/encode-and-decode-strings/README.md | 2 +- problems/exam-room/README.md | 2 +- problems/grid-illumination/README.md | 16 ++-- .../guess-number-higher-or-lower-ii/README.md | 60 ++++++++++--- problems/image-overlap/README.md | 52 ++++++++---- problems/insert-delete-getrandom-o1/README.md | 50 +++++------ problems/island-perimeter/README.md | 41 ++++++--- .../largest-time-for-given-digits/README.md | 47 ++++++---- problems/linked-list-cycle-ii/README.md | 41 ++++----- problems/linked-list-cycle/README.md | 12 +-- .../longest-harmonious-subsequence/README.md | 35 ++++++-- .../longest-uncommon-subsequence-i/README.md | 17 ++-- problems/lru-cache/README.md | 41 ++++++--- problems/magic-squares-in-grid/README.md | 58 ++++++++----- .../README.md | 41 +++++---- .../median-of-two-sorted-arrays/README.md | 1 + .../min-cost-to-connect-all-points/README.md | 83 ++++++++++++++++++ .../README.md | 6 +- .../README.md | 2 +- .../README.md | 51 +++++++---- problems/positions-of-large-groups/README.md | 42 ++++++--- .../put-boxes-into-the-warehouse-ii/README.md | 28 ++++++ .../README.md | 2 +- problems/robot-return-to-origin/README.md | 37 ++++++-- problems/sort-colors/README.md | 54 +++++++++--- .../README.md | 77 +++++++++++++++++ problems/string-compression/README.md | 69 +++++++-------- .../README.md | 44 +++++++--- problems/trim-a-binary-search-tree/README.md | 79 +++++++++-------- problems/word-pattern/README.md | 38 ++++++--- readme/1-300.md | 2 +- readme/301-600.md | 2 +- readme/601-900.md | 4 +- readme/901-1200.md | 2 +- tag/README.md | 4 +- tag/array/README.md | 8 +- tag/brainteaser/README.md | 1 + tag/breadth-first-search/README.md | 1 + tag/depth-first-search/README.md | 1 + tag/design/README.md | 1 + tag/dynamic-programming/README.md | 1 - tag/greedy/README.md | 2 + tag/math/README.md | 2 +- tag/string/README.md | 5 +- tag/tags.json | 10 +-- tag/union-find/README.md | 1 + 55 files changed, 1068 insertions(+), 385 deletions(-) create mode 100644 problems/check-if-string-is-transformable-with-substring-sort-operations/README.md create mode 100644 problems/count-unhappy-friends/README.md create mode 100644 problems/customer-who-visited-but-did-not-make-any-transactions/README.md create mode 100644 problems/customer-who-visited-but-did-not-make-any-transactions/mysql_schemas.sql create mode 100644 problems/min-cost-to-connect-all-points/README.md create mode 100644 problems/put-boxes-into-the-warehouse-ii/README.md create mode 100644 problems/special-positions-in-a-binary-matrix/README.md diff --git a/README.md b/README.md index e49eeacb3..46efba4ff 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,12 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1585 | [Check If String Is Transformable With Substring Sort Operations](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations "检查字符串是否可以通过排序子字符串得到另一个字符串") | [Go](problems/check-if-string-is-transformable-with-substring-sort-operations) | Hard | +| 1584 | [Min Cost to Connect All Points](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") | [Go](problems/min-cost-to-connect-all-points) | Medium | +| 1583 | [Count Unhappy Friends](https://leetcode.com/problems/count-unhappy-friends "统计不开心的朋友") | [Go](problems/count-unhappy-friends) | Medium | +| 1582 | [Special Positions in a Binary Matrix](https://leetcode.com/problems/special-positions-in-a-binary-matrix "二进制矩阵中的特殊位置") | [Go](problems/special-positions-in-a-binary-matrix) | Easy | +| 1581 | [Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions) 🔒 | [MySQL](problems/customer-who-visited-but-did-not-make-any-transactions) | Easy | +| 1580 | [Put Boxes Into the Warehouse II](https://leetcode.com/problems/put-boxes-into-the-warehouse-ii) 🔒 | [Go](problems/put-boxes-into-the-warehouse-ii) | Medium | | 1579 | [Remove Max Number of Edges to Keep Graph Fully Traversable](https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable "保证图可完全遍历") | [Go](problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | Hard | | 1578 | [Minimum Deletion Cost to Avoid Repeating Letters](https://leetcode.com/problems/minimum-deletion-cost-to-avoid-repeating-letters "避免重复字母的最小删除成本") | [Go](problems/minimum-deletion-cost-to-avoid-repeating-letters) | Medium | | 1577 | [Number of Ways Where Square of Number Is Equal to Product of Two Numbers](https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "数的平方等于两数乘积的方法数") | [Go](problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | Medium | diff --git a/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md b/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md new file mode 100644 index 000000000..28f630dcd --- /dev/null +++ b/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../min-cost-to-connect-all-points "Min Cost to Connect All Points") +                 +Next > + +## [1585. Check If String Is Transformable With Substring Sort Operations (Hard)](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations "检查字符串是否可以通过排序子字符串得到另一个字符串") + +

      Given two strings s and t, you want to transform string s into string t using the following operation any number of times:

      + +
        +
      • Choose a non-empty substring in s and sort it in-place so the characters are in ascending order.
      • +
      + +

      For example, applying the operation on the underlined substring in "14234" results in "12344".

      + +

      Return true if it is possible to transform string s into string t. Otherwise, return false.

      + +

      A substring is a contiguous sequence of characters within a string.

      + +

       

      +

      Example 1:

      + +
      +Input: s = "84532", t = "34852"
      +Output: true
      +Explanation: You can transform s into t using the following sort operations:
      +"84532" (from index 2 to 3) -> "84352"
      +"84352" (from index 0 to 2) -> "34852"
      +
      + +

      Example 2:

      + +
      +Input: s = "34521", t = "23415"
      +Output: true
      +Explanation: You can transform s into t using the following sort operations:
      +"34521" -> "23451"
      +"23451" -> "23415"
      +
      + +

      Example 3:

      + +
      +Input: s = "12345", t = "12435"
      +Output: false
      +
      + +

      Example 4:

      + +
      +Input: s = "1", t = "2"
      +Output: false
      +
      + +

       

      +

      Constraints:

      + +
        +
      • s.length == t.length
      • +
      • 1 <= s.length <= 105
      • +
      • s and t only contain digits from '0' to '9'.
      • +
      + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
      +Hint 1 +Suppose the first digit you need is 'd'. How can you determine if it's possible to get that digit there? +
      + +
      +Hint 2 +Consider swapping adjacent characters to maintain relative ordering. +
      diff --git a/problems/compare-version-numbers/README.md b/problems/compare-version-numbers/README.md index b1fe1be1b..48ae604a0 100644 --- a/problems/compare-version-numbers/README.md +++ b/problems/compare-version-numbers/README.md @@ -11,50 +11,71 @@ ## [165. Compare Version Numbers (Medium)](https://leetcode.com/problems/compare-version-numbers "比较版本号") -

      Compare two version numbers version1 and version2.
      -If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0.

      +

      Given two version numbers, version1 and version2, compare them.

      -

      You may assume that the version strings are non-empty and contain only digits and the . character.

      -

      The . character does not represent a decimal point and is used to separate number sequences.

      -

      For instance, 2.5 is not "two and a half" or "half way to version three", it is the fifth second-level revision of the second first-level revision.

      -

      You may assume the default revision number for each level of a version number to be 0. For example, version number 3.4 has a revision number of 3 and 4 for its first and second level revision number. Its third and fourth level revision number are both 0.

      +
        +
      -

       

      +

      Version numbers consist of one or more revisions joined by a dot '.'. Each revision consists of digits and may contain leading zeros. Every revision contains at least one character. Revisions are 0-indexed from left to right, with the leftmost revision being revision 0, the next revision being revision 1, and so on. For example 2.5.33 and 0.1 are valid version numbers.

      + +

      To compare version numbers, compare their revisions in left-to-right order. Revisions are compared using their integer value ignoring any leading zeros. This means that revisions 1 and 001 are considered equal. If a version number does not specify a revision at an index, then treat the revision as 0. For example, version 1.0 is less than version 1.1 because their revision 0s are the same, but their revision 1s are 0 and 1 respectively, and 0 < 1.

      + +

      Return the following:

      + +
        +
      • If version1 < version2, return -1.
      • +
      • If version1 > version2, return 1.
      • +
      • Otherwise, return 0.
      • +
      +

       

      Example 1:

      +
      -Input: version1 = "0.1", version2 = "1.1"
      -Output: -1
      +Input: version1 = "1.01", version2 = "1.001" +Output: 0 +Explanation: Ignoring leading zeroes, both "01" and "001" represent the same integer "1". +

      Example 2:

      +
      -Input: version1 = "1.0.1", version2 = "1"
      -Output: 1
      +Input: version1 = "1.0", version2 = "1.0.0" +Output: 0 +Explanation: version1 does not specify revision 2, which means it is treated as "0". +

      Example 3:

      +
      -Input: version1 = "7.5.2.4", version2 = "7.5.3"
      -Output: -1
      +Input: version1 = "0.1", version2 = "1.1" +Output: -1 +Explanation: version1's revision 0 is "0", while version2's revision 0 is "1". 0 < 1, so version1 < version2. +

      Example 4:

      +
      -Input: version1 = "1.01", version2 = "1.001"
      -Output: 0
      -Explanation: Ignoring leading zeroes, both “01” and “001" represent the same number “1”
      +Input: version1 = "1.0.1", version2 = "1" +Output: 1 +

      Example 5:

      +
      -Input: version1 = "1.0", version2 = "1.0.0"
      -Output: 0
      -Explanation: The first version number does not have a third level revision number, which means its third level revision number is default to "0"
      +Input: version1 = "7.5.2.4", version2 = "7.5.3" +Output: -1 +

       

      +

      Constraints:

      -

      Note:

      -
        -
      1. Version strings are composed of numeric strings separated by dots . and this numeric strings may have leading zeroes.
      2. -
      3. Version strings do not start or end with dots, and they will not be two consecutive dots.
      4. -
      +
        +
      • 1 <= version1.length, version2.length <= 500
      • +
      • version1 and version2 only contain digits and '.'.
      • +
      • version1 and version2 are valid version numbers.
      • +
      • All the given revisions in version1 and version2 can be stored in a 32-bit integer.
      • +
      ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/count-and-say/README.md b/problems/count-and-say/README.md index ff64e1143..a86cec48c 100644 --- a/problems/count-and-say/README.md +++ b/problems/count-and-say/README.md @@ -52,7 +52,7 @@ ### Similar Questions 1. [Encode and Decode Strings](../encode-and-decode-strings) (Medium) - 1. [String Compression](../string-compression) (Easy) + 1. [String Compression](../string-compression) (Medium) ### Hints
      diff --git a/problems/count-unhappy-friends/README.md b/problems/count-unhappy-friends/README.md new file mode 100644 index 000000000..9f5bdc72d --- /dev/null +++ b/problems/count-unhappy-friends/README.md @@ -0,0 +1,85 @@ + + + + + + + +[< Previous](../special-positions-in-a-binary-matrix "Special Positions in a Binary Matrix") +                 +[Next >](../min-cost-to-connect-all-points "Min Cost to Connect All Points") + +## [1583. Count Unhappy Friends (Medium)](https://leetcode.com/problems/count-unhappy-friends "统计不开心的朋友") + +

      You are given a list of preferences for n friends, where n is always even.

      + +

      For each person ipreferences[i] contains a list of friends sorted in the order of preference. In other words, a friend earlier in the list is more preferred than a friend later in the list. Friends in each list are denoted by integers from 0 to n-1.

      + +

      All the friends are divided into pairs. The pairings are given in a list pairs, where pairs[i] = [xi, yi] denotes xi is paired with yi and yi is paired with xi.

      + +

      However, this pairing may cause some of the friends to be unhappy. A friend x is unhappy if x is paired with y and there exists a friend u who is paired with v but:

      + +
        +
      • x prefers u over y, and
      • +
      • u prefers x over v.
      • +
      + +

      Return the number of unhappy friends.

      + +

       

      +

      Example 1:

      + +
      +Input: n = 4, preferences = [[1, 2, 3], [3, 2, 0], [3, 1, 0], [1, 2, 0]], pairs = [[0, 1], [2, 3]]
      +Output: 2
      +Explanation:
      +Friend 1 is unhappy because:
      +- 1 is paired with 0 but prefers 3 over 0, and
      +- 3 prefers 1 over 2.
      +Friend 3 is unhappy because:
      +- 3 is paired with 2 but prefers 1 over 2, and
      +- 1 prefers 3 over 0.
      +Friends 0 and 2 are happy.
      +
      + +

      Example 2:

      + +
      +Input: n = 2, preferences = [[1], [0]], pairs = [[1, 0]]
      +Output: 0
      +Explanation: Both friends 0 and 1 are happy.
      +
      + +

      Example 3:

      + +
      +Input: n = 4, preferences = [[1, 3, 2], [2, 3, 0], [1, 3, 0], [0, 2, 1]], pairs = [[1, 3], [0, 2]]
      +Output: 4
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 2 <= n <= 500
      • +
      • n is even.
      • +
      • preferences.length == n
      • +
      • preferences[i].length == n - 1
      • +
      • 0 <= preferences[i][j] <= n - 1
      • +
      • preferences[i] does not contain i.
      • +
      • All values in preferences[i] are unique.
      • +
      • pairs.length == n/2
      • +
      • pairs[i].length == 2
      • +
      • xi != yi
      • +
      • 0 <= xi, yi <= n - 1
      • +
      • Each person is contained in exactly one pair.
      • +
      + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
      +Hint 1 +Create a matrix “rank” where rank[i][j] holds how highly friend ‘i' views ‘j’. This allows for O(1) comparisons between people +
      diff --git a/problems/customer-who-visited-but-did-not-make-any-transactions/README.md b/problems/customer-who-visited-but-did-not-make-any-transactions/README.md new file mode 100644 index 000000000..980a01ce8 --- /dev/null +++ b/problems/customer-who-visited-but-did-not-make-any-transactions/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../put-boxes-into-the-warehouse-ii "Put Boxes Into the Warehouse II") +                 +[Next >](../special-positions-in-a-binary-matrix "Special Positions in a Binary Matrix") + +## [1581. Customer Who Visited but Did Not Make Any Transactions (Easy)](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "") + + diff --git a/problems/customer-who-visited-but-did-not-make-any-transactions/mysql_schemas.sql b/problems/customer-who-visited-but-did-not-make-any-transactions/mysql_schemas.sql new file mode 100644 index 000000000..9f6c0ba5c --- /dev/null +++ b/problems/customer-who-visited-but-did-not-make-any-transactions/mysql_schemas.sql @@ -0,0 +1,16 @@ +Create table If Not Exists Visits(visit_id int, customer_id int); +Create table If Not Exists Transactions(transaction_id int, visit_id int, amount int); +Truncate table Visits; +insert into Visits (visit_id, customer_id) values ('1', '23'); +insert into Visits (visit_id, customer_id) values ('2', '9'); +insert into Visits (visit_id, customer_id) values ('4', '30'); +insert into Visits (visit_id, customer_id) values ('5', '54'); +insert into Visits (visit_id, customer_id) values ('6', '96'); +insert into Visits (visit_id, customer_id) values ('7', '54'); +insert into Visits (visit_id, customer_id) values ('8', '54'); +Truncate table Transactions; +insert into Transactions (transaction_id, visit_id, amount) values ('2', '5', '310'); +insert into Transactions (transaction_id, visit_id, amount) values ('3', '5', '300'); +insert into Transactions (transaction_id, visit_id, amount) values ('9', '5', '200'); +insert into Transactions (transaction_id, visit_id, amount) values ('12', '1', '910'); +insert into Transactions (transaction_id, visit_id, amount) values ('13', '2', '970'); diff --git a/problems/design-a-file-sharing-system/README.md b/problems/design-a-file-sharing-system/README.md index 62a3064ae..cf0655906 100644 --- a/problems/design-a-file-sharing-system/README.md +++ b/problems/design-a-file-sharing-system/README.md @@ -14,6 +14,7 @@ ### Related Topics + [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] ### Hints diff --git a/problems/design-compressed-string-iterator/README.md b/problems/design-compressed-string-iterator/README.md index c8278cf05..9d573923b 100644 --- a/problems/design-compressed-string-iterator/README.md +++ b/problems/design-compressed-string-iterator/README.md @@ -53,4 +53,4 @@ iterator.next(); // return ' ' ### Similar Questions 1. [LRU Cache](../lru-cache) (Medium) - 1. [String Compression](../string-compression) (Easy) + 1. [String Compression](../string-compression) (Medium) diff --git a/problems/encode-and-decode-strings/README.md b/problems/encode-and-decode-strings/README.md index 5674a6223..e8ebd0074 100644 --- a/problems/encode-and-decode-strings/README.md +++ b/problems/encode-and-decode-strings/README.md @@ -61,5 +61,5 @@ vector<string> strs2 = decode(encoded_string); ### Similar Questions 1. [Count and Say](../count-and-say) (Easy) 1. [Serialize and Deserialize Binary Tree](../serialize-and-deserialize-binary-tree) (Hard) - 1. [String Compression](../string-compression) (Easy) + 1. [String Compression](../string-compression) (Medium) 1. [Count Binary Substrings](../count-binary-substrings) (Easy) diff --git a/problems/exam-room/README.md b/problems/exam-room/README.md index d69790d06..320a72046 100644 --- a/problems/exam-room/README.md +++ b/problems/exam-room/README.md @@ -48,4 +48,4 @@ seat() -> 5, the student sits at the last seat number 5. [[Ordered Map](../../tag/ordered-map/README.md)] ### Similar Questions - 1. [Maximize Distance to Closest Person](../maximize-distance-to-closest-person) (Easy) + 1. [Maximize Distance to Closest Person](../maximize-distance-to-closest-person) (Medium) diff --git a/problems/grid-illumination/README.md b/problems/grid-illumination/README.md index 2a73c73da..db83aaade 100644 --- a/problems/grid-illumination/README.md +++ b/problems/grid-illumination/README.md @@ -11,13 +11,13 @@ ## [1001. Grid Illumination (Hard)](https://leetcode.com/problems/grid-illumination "网格照明") -

      Given a grid of size N x N, each cell of this grid has a lamp which is intially turned off.

      +

      You are given a grid of size N x N, and each cell of this grid has a lamp that is initially turned off.

      -

      Given an array of lamp positions lamps, where lamps[i] = [xi, yi] indicates that the lamp at grid[xi][yi] will be turned on. When a lamp is turned on, it illiminates its cell and any cell in the same row, column or diagonal with this this cell.

      +

      You are also given an array of lamp positions lamps, where lamps[i] = [rowi, coli] indicates that the lamp at grid[rowi][coli] is turned on. When a lamp is turned on, it illuminates its cell and all other cells in the same row, column, or diagonal.

      -

      Then you will be given a query array queries, where queries[i] = [xi, yi]. For the ith query, you should answer whether grid[xi][yi] is illuminated or not. After answering the ith query, you should turn off the lamp at grid[xi][yi] and all of its 8 adjacent lamps if they exist (i,e, lamps at adjacent cell which share side or diagonal).

      +

      Finally, you are given a query array queries, where queries[i] = [rowi, coli]. For the ith query, determine whether grid[rowi][coli] is illuminated or not. After answering the ith query, turn off the lamp at grid[rowi][coli] and its 8 adjacent lamps if they exist. A lamp is adjacent if its cell shares either a side or corner with grid[rowi][coli].

      -

      Return an array of integers ans where each value ans[i] should be equal to the answer of the ith query queries[i].

      +

      Return an array of integers ans, where ans[i] should be 1 if the lamp in the ith query was illuminated, or 0 if the lamp was not.

       

      Example 1:

      @@ -25,10 +25,10 @@
       Input: N = 5, lamps = [[0,0],[4,4]], queries = [[1,1],[1,0]]
       Output: [1,0]
      -Explanation: We have initial grid with all lamps turned off. In the above picture we see the grid after turning the lamp at grid[0][0] on then turning the lamp at grid[4][4] on.
      -The first query asks if the lamp at grid[1][1] is illuminated or not (the blue square) and as it is illuminated, we return 1. Then we turn off any lamp in the red square.
      +Explanation: We have the initial grid with all lamps turned off. In the above picture we see the grid after turning on the lamp at grid[0][0] then turning on the lamp at grid[4][4].
      +The 0th query asks if the lamp at grid[1][1] is illuminated or not (the blue square). It is illuminated, so set ans[0] = 1. Then, we turn off all lamps in the red square.
       
      -The second query asks if the lamp at grid[1][0] is illuminated or not (the blue square) and as it is not illustrated, we return 0. Then we turn off any lamp in the red rectangle.
      +The 1st query asks if the lamp at grid[1][0] is illuminated or not (the blue square). It is not illuminated, so set ans[1] = 1. Then, we turn off all lamps in the red rectangle.
       
       
      @@ -50,7 +50,7 @@ The second query asks if the lamp at grid[1][0] is illuminated or not (the blue

      Constraints:

        -
      • 1 <= N <= 10^9
      • +
      • 1 <= N <= 109
      • 0 <= lamps.length <= 20000
      • lamps[i].length == 2
      • 0 <= lamps[i][j] < N
      • diff --git a/problems/guess-number-higher-or-lower-ii/README.md b/problems/guess-number-higher-or-lower-ii/README.md index 5ff810690..4e8146494 100644 --- a/problems/guess-number-higher-or-lower-ii/README.md +++ b/problems/guess-number-higher-or-lower-ii/README.md @@ -11,29 +11,63 @@ ## [375. Guess Number Higher or Lower II (Medium)](https://leetcode.com/problems/guess-number-higher-or-lower-ii "猜数字大小 II") -

        We are playing the Guess Game. The game is as follows:

        +

        We are playing the Guessing Game. The game will work as follows:

        -

        I pick a number from 1 to n. You have to guess which number I picked.

        +
          +
        1. I pick a number between 1 and n.
        2. +
        3. You guess a number.
        4. +
        5. If you guess the right number, you win the game.
        6. +
        7. If you guess the wrong number, then I will tell you whether the number I picked is higher or lower, and you will continue guessing.
        8. +
        9. Every time you guess a wrong number x, you will pay x dollars. If you run out of money, you lose the game.
        10. +
        -

        Every time you guess wrong, I'll tell you whether the number I picked is higher or lower.

        +

        Given a particular n, return the minimum amount of money you need to guarantee a win regardless of what number I pick.

        -

        However, when you guess a particular number x, and you guess wrong, you pay $x. You win the game when you guess the number I picked.

        +

         

        +

        Example 1:

        + +
        +Input: n = 10
        +Output: 16
        +Explanation: The winning strategy is as follows:
        +- The range is [1,10]. Guess 7.
        +    - If this is my number, your total is $0. Otherwise, you pay $7.
        +    - If my number is higher, the range is [8,10]. Guess 9.
        +        - If this is my number, your total is $7. Otherwise, you pay $9.
        +        - If my number is higher, it must be 10. Guess 10. Your total is $7 + $9 = $16.
        +        - If my number is lower, it must be 8. Guess 8. Your total is $7 + $9 = $16.
        +    - If my number is lower, the range is [1,6]. Guess 3.
        +        - If this is my number, your total is $7. Otherwise, you pay $3.
        +        - If my number is higher, the range is [4,6]. Guess 5.
        +            - If this is my number, your total is $7 + $3 = $10. Otherwise, you pay $5.
        +            - If my number is higher, it must be 6. Guess 6. Your total is $7 + $3 + $5 = $15.
        +            - If my number is lower, it must be 4. Guess 4. Your total is $7 + $3 + $5 = $15.
        +        - If my number is lower, the range is [1,2]. Guess 1.
        +            - If this is my number, your total is $7 + $3 = $10. Otherwise, you pay $1.
        +            - If my number is higher, it must be 2. Guess 2. Your total is $7 + $3 + $1 = $11.
        +The worst case in all these scenarios is that you pay $16. Hence, you only need $16 to guarantee a win.
        +
        -

        Example:

        +

        Example 2:

        -n = 10, I pick 8.
        -
        -First round:  You guess 5, I tell you that it's higher. You pay $5.
        -Second round: You guess 7, I tell you that it's higher. You pay $7.
        -Third round:  You guess 9, I tell you that it's lower. You pay $9.
        +Input: n = 1
        +Output: 0
        +Explanation: There is only one possible number, so you can guess 1 and not have to pay anything.
        +
        -Game over. 8 is the number I picked. +

        Example 3:

        -You end up paying $5 + $7 + $9 = $21. +
        +Input: n = 2
        +Output: 1
        +Explanation: There are two possible numbers, 1 and 2.
        +- Guess 1.
        +    - If this is my number, your total is $0. Otherwise, you pay $1.
        +    - If my number is higher, it must be 2. Guess 2. Your total is $1.
        +The worst case is that you pay $1.
         
        -

        Given a particular n ≥ 1, find out how much money you need to have to guarantee a win.

         

        Constraints:

        diff --git a/problems/image-overlap/README.md b/problems/image-overlap/README.md index 562c1f0a1..d22d9bd37 100644 --- a/problems/image-overlap/README.md +++ b/problems/image-overlap/README.md @@ -11,7 +11,7 @@ ## [835. Image Overlap (Medium)](https://leetcode.com/problems/image-overlap "图像重叠") -

        Two images A and B are given, represented as binary, square matrices of the same size.  (A binary matrix has only 0s and 1s as values.)

        +

        You are given two images img1 and img2 both of size n x n, represented as binary, square matrices of the same size. (A binary matrix has only 0s and 1s as values.)

        We translate one image however we choose (sliding it left, right, up, or down any number of units), and place it on top of the other image.  After, the overlap of this translation is the number of positions that have a 1 in both images.

        @@ -19,24 +19,44 @@

        What is the largest possible overlap?

        +

         

        Example 1:

        + +
        +Input: img1 = [[1,1,0],[0,1,0],[0,1,0]], img2 = [[0,0,0],[0,1,1],[0,0,1]]
        +Output: 3
        +Explanation: We slide img1 to right by 1 unit and down by 1 unit.
        +
        +The number of positions that have a 1 in both images is 3. (Shown in red)
        +
        +
        + +

        Example 2:

        + +
        +Input: img1 = [[1]], img2 = [[1]]
        +Output: 1
        +
        + +

        Example 3:

        -Input: A = [[1,1,0],
        -            [0,1,0],
        -            [0,1,0]]
        -       B = [[0,0,0],
        -            [0,1,1],
        -            [0,0,1]]
        -Output: 3
        -Explanation: We slide A to right by 1 unit and down by 1 unit.
        - -

        Notes: 

        - -
          -
        1. 1 <= A.length = A[0].length = B.length = B[0].length <= 30
        2. -
        3. 0 <= A[i][j], B[i][j] <= 1
        4. -
        +Input: img1 = [[0]], img2 = [[0]] +Output: 0 + + +

         

        +

        Constraints:

        + +
          +
        • n == img1.length
        • +
        • n == img1[i].length
        • +
        • n == img2.length
        • +
        • n == img2[i].length
        • +
        • 1 <= n <= 30
        • +
        • img1[i][j] is 0 or 1.
        • +
        • img2[i][j] is 0 or 1.
        • +
        ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/insert-delete-getrandom-o1/README.md b/problems/insert-delete-getrandom-o1/README.md index 5013ff5f9..24e70239a 100644 --- a/problems/insert-delete-getrandom-o1/README.md +++ b/problems/insert-delete-getrandom-o1/README.md @@ -18,38 +18,38 @@
        1. insert(val): Inserts an item val to the set if not already present.
        2. remove(val): Removes an item val from the set if present.
        3. -
        4. getRandom: Returns a random element from current set of elements (it's guaranteed that at least one element exists when this method is called). Each element must have the same probability of being returned.
        5. +
        6. getRandom: Returns a random element from the current set of elements (it's guaranteed that at least one element exists when this method is called). Each element must have the same probability of being returned.

         

        - -

        Example:

        +

        Example 1:

        -// Init an empty set.
        -RandomizedSet randomSet = new RandomizedSet();
        -
        -// Inserts 1 to the set. Returns true as 1 was inserted successfully.
        -randomSet.insert(1);
        -
        -// Returns false as 2 does not exist in the set.
        -randomSet.remove(2);
        -
        -// Inserts 2 to the set, returns true. Set now contains [1,2].
        -randomSet.insert(2);
        -
        -// getRandom should return either 1 or 2 randomly.
        -randomSet.getRandom();
        -
        -// Removes 1 from the set, returns true. Set now contains [2].
        -randomSet.remove(1);
        +Input
        +["RandomizedSet", "insert", "remove", "insert", "getRandom", "remove", "insert", "getRandom"]
        +[[], [1], [2], [2], [], [1], [2], []]
        +Output
        +[null, true, false, true, 2, true, false, 2]
        +
        +Explanation
        +RandomizedSet randomizedSet = new RandomizedSet();
        +randomizedSet.insert(1); // Inserts 1 to the set. Returns true as 1 was inserted successfully.
        +randomizedSet.remove(2); // Returns false as 2 does not exist in the set.
        +randomizedSet.insert(2); // Inserts 2 to the set, returns true. Set now contains [1,2].
        +randomizedSet.getRandom(); // getRandom should return either 1 or 2 randomly.
        +randomizedSet.remove(1); // Removes 1 from the set, returns true. Set now contains [2].
        +randomizedSet.insert(2); // 2 was already in the set, so return false.
        +randomizedSet.getRandom(); // Since 2 is the only number in the set, getRandom always return 2.
        +
        -// 2 was already in the set, so return false. -randomSet.insert(2); +

         

        +

        Constraints:

        -// Since 2 is the only number in the set, getRandom always return 2. -randomSet.getRandom(); - +
          +
        • -231 <= val <= 231 - 1
        • +
        • At most 105 calls will be made to insertremove, and getRandom.
        • +
        • There will be at least one element in the data structure when getRandom is called.
        • +
        ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/island-perimeter/README.md b/problems/island-perimeter/README.md index 8d27bd661..b2190d723 100644 --- a/problems/island-perimeter/README.md +++ b/problems/island-perimeter/README.md @@ -11,30 +11,45 @@ ## [463. Island Perimeter (Easy)](https://leetcode.com/problems/island-perimeter "岛屿的周长") -

        You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water.

        +

        You are given row x col grid representing a map where grid[i][j] = 1 represents land and grid[i][j] = 0 represents water.

        -

        Grid cells are connected horizontally/vertically (not diagonally). The grid is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells).

        +

        Grid cells are connected horizontally/vertically (not diagonally). The grid is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells).

        -

        The island doesn't have "lakes" (water inside that isn't connected to the water around the island). One cell is a square with side length 1. The grid is rectangular, width and height don't exceed 100. Determine the perimeter of the island.

        +

        The island doesn't have "lakes", meaning the water inside isn't connected to the water around the island. One cell is a square with side length 1. The grid is rectangular, width and height don't exceed 100. Determine the perimeter of the island.

         

        +

        Example 1:

        + +
        +Input: grid = [[0,1,0,0],[1,1,1,0],[0,1,0,0],[1,1,0,0]]
        +Output: 16
        +Explanation: The perimeter is the 16 yellow stripes in the image above.
        +
        -

        Example:

        +

        Example 2:

        -Input:
        -[[0,1,0,0],
        - [1,1,1,0],
        - [0,1,0,0],
        - [1,1,0,0]]
        -
        -Output: 16
        +Input: grid = [[1]]
        +Output: 4
        +
        -Explanation: The perimeter is the 16 yellow stripes in the image below: +

        Example 3:

        - +
        +Input: grid = [[1,0]]
        +Output: 4
         
        +

         

        +

        Constraints:

        + +
          +
        • row == grid.length
        • +
        • col == grid[i].length
        • +
        • 1 <= row, col <= 100
        • +
        • grid[i][j] is 0 or 1.
        • +
        + ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/largest-time-for-given-digits/README.md b/problems/largest-time-for-given-digits/README.md index fbbb21966..4642458a4 100644 --- a/problems/largest-time-for-given-digits/README.md +++ b/problems/largest-time-for-given-digits/README.md @@ -9,28 +9,45 @@                  [Next >](../reveal-cards-in-increasing-order "Reveal Cards In Increasing Order") -## [949. Largest Time for Given Digits (Easy)](https://leetcode.com/problems/largest-time-for-given-digits "给定数字能组成的最大时间") +## [949. Largest Time for Given Digits (Medium)](https://leetcode.com/problems/largest-time-for-given-digits "给定数字能组成的最大时间") -

        Given an array of 4 digits, return the largest 24 hour time that can be made.

        +

        Given an array arr of 4 digits, find the latest 24-hour time that can be made using each digit exactly once.

        -

        The smallest 24 hour time is 00:00, and the largest is 23:59.  Starting from 00:00, a time is larger if more time has elapsed since midnight.

        +

        24-hour times are formatted as "HH:MM", where HH is between 00 and 23, and MM is between 00 and 59. The earliest 24-hour time is 00:00, and the latest is 23:59.

        -

        Return the answer as a string of length 5.  If no valid time can be made, return an empty string.

        +

        Return the latest 24-hour time in "HH:MM" format.  If no valid time can be made, return an empty string.

         

        Example 1:

        -
        Input: A = [1,2,3,4]
        -Output: "23:41"
        -

        Example 2:

        -
        Input: A = [5,5,5,5]
        -Output: ""
        -

        Example 3:

        -
        Input: A = [0,0,0,0]
        -Output: "00:00"
        -

        Example 4:

        -
        Input: A = [0,0,1,0]
        -Output: "10:00"
        +
        +
        +Input: A = [1,2,3,4]
        +Output: "23:41"
        +Explanation: The valid 24-hour times are "12:34", "12:43", "13:24", "13:42", "14:23", "14:32", "21:34", "21:43", "23:14", and "23:41". Of these times, "23:41" is the latest.
        +
        + +

        Example 2:

        + +
        +Input: A = [5,5,5,5]
        +Output: ""
        +Explanation: There are no valid 24-hour times as "55:55" is not valid.
         
        + +

        Example 3:

        + +
        +Input: A = [0,0,0,0]
        +Output: "00:00"
        +
        + +

        Example 4:

        + +
        +Input: A = [0,0,1,0]
        +Output: "10:00"
        +
        +

         

        Constraints:

        diff --git a/problems/linked-list-cycle-ii/README.md b/problems/linked-list-cycle-ii/README.md index beb38d797..cd3c8f0c9 100644 --- a/problems/linked-list-cycle-ii/README.md +++ b/problems/linked-list-cycle-ii/README.md @@ -13,46 +13,47 @@

        Given a linked list, return the node where the cycle begins. If there is no cycle, return null.

        -

        To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail connects to. If pos is -1, then there is no cycle in the linked list.

        +

        There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail's next pointer is connected to. Note that pos is not passed as a parameter.

        -

        Note: Do not modify the linked list.

        +

        Notice that you should not modify the linked list.

        -

         

        +

        Follow up:

        -

        Example 1:

        +

        Can you solve it using O(1) (i.e. constant) memory?

        +

         

        +

        Example 1:

        +
        -Input: head = [3,2,0,-4], pos = 1
        -Output: tail connects to node index 1
        +Input: head = [3,2,0,-4], pos = 1
        +Output: tail connects to node index 1
         Explanation: There is a cycle in the linked list, where tail connects to the second node.
         
        -

        -

        Example 2:

        - +
        -Input: head = [1,2], pos = 0
        -Output: tail connects to node index 0
        +Input: head = [1,2], pos = 0
        +Output: tail connects to node index 0
         Explanation: There is a cycle in the linked list, where tail connects to the first node.
         
        -

        -

        Example 3:

        - +
        -Input: head = [1], pos = -1
        -Output: no cycle
        +Input: head = [1], pos = -1
        +Output: no cycle
         Explanation: There is no cycle in the linked list.
         
        -

        -

         

        +

        Constraints:

        -

        Follow-up:
        -Can you solve it without using extra space?

        +
          +
        • The number of the nodes in the list is in the range [0, 104].
        • +
        • -105 <= Node.val <= 105
        • +
        • pos is -1 or a valid index in the linked-list.
        • +
        ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/linked-list-cycle/README.md b/problems/linked-list-cycle/README.md index daa51e776..db6fe3aa6 100644 --- a/problems/linked-list-cycle/README.md +++ b/problems/linked-list-cycle/README.md @@ -11,13 +11,15 @@ ## [141. Linked List Cycle (Easy)](https://leetcode.com/problems/linked-list-cycle "环形链表") -

        Given a linked list, determine if it has a cycle in it.

        +

        Given head, the head of a linked list, determine if the linked list has a cycle in it.

        -

        To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where the tail connects to. If pos == -1, then there is no cycle in the linked list.

        +

        There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail's next pointer is connected to. Note that pos is not passed as a parameter.

        + +

        Return true if there is a cycle in the linked list. Otherwise, return false.

        Follow up:

        -

        Can you solve it using O(1) (i.e. constant) memory?

        +

        Can you solve it using O(1) (i.e. constant) memory?

         

        Example 1:

        @@ -25,7 +27,7 @@
         Input: head = [3,2,0,-4], pos = 1
         Output: true
        -Explanation: There is a cycle in the linked list, where tail connects to the second node.
        +Explanation: There is a cycle in the linked list, where the tail connects to the 1st node (0-indexed).
         

        Example 2:

        @@ -33,7 +35,7 @@
         Input: head = [1,2], pos = 0
         Output: true
        -Explanation: There is a cycle in the linked list, where tail connects to the first node.
        +Explanation: There is a cycle in the linked list, where the tail connects to the 0th node.
         

        Example 3:

        diff --git a/problems/longest-harmonious-subsequence/README.md b/problems/longest-harmonious-subsequence/README.md index fb83eb1c5..6d54e8055 100644 --- a/problems/longest-harmonious-subsequence/README.md +++ b/problems/longest-harmonious-subsequence/README.md @@ -11,21 +11,42 @@ ## [594. Longest Harmonious Subsequence (Easy)](https://leetcode.com/problems/longest-harmonious-subsequence "最长和谐子序列") -

        We define a harmounious array as an array where the difference between its maximum value and its minimum value is exactly 1.

        +

        We define a harmonious array as an array where the difference between its maximum value and its minimum value is exactly 1.

        -

        Now, given an integer array, you need to find the length of its longest harmonious subsequence among all its possible subsequences.

        +

        Given an integer array nums, return the length of its longest harmonious subsequence among all its possible subsequences.

        -

        Example 1:

        +

        A subsequence of array is a sequence that can be derived from the array by deleting some or no elements without changing the order of the remaining elements.

        + +

         

        +

        Example 1:

        + +
        +Input: nums = [1,3,2,2,5,2,3,7]
        +Output: 5
        +Explanation: The longest harmonious subsequence is [3,2,2,2,3].
        +
        + +

        Example 2:

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

        Example 3:

        -Input: [1,3,2,2,5,2,3,7]
        -Output: 5
        -Explanation: The longest harmonious subsequence is [3,2,2,2,3].
        +Input: nums = [1,1,1,1]
        +Output: 0
         

         

        +

        Constraints:

        -

        Note: The length of the input array will not exceed 20,000.

        +
          +
        • 1 <= nums.length <= 2 * 104
        • +
        • -109 <= nums[i] <= 109
        • +
        ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/longest-uncommon-subsequence-i/README.md b/problems/longest-uncommon-subsequence-i/README.md index fc9eabfbd..443ce744f 100644 --- a/problems/longest-uncommon-subsequence-i/README.md +++ b/problems/longest-uncommon-subsequence-i/README.md @@ -11,11 +11,13 @@ ## [521. Longest Uncommon Subsequence I (Easy)](https://leetcode.com/problems/longest-uncommon-subsequence-i "最长特殊序列 Ⅰ") -

        Given two strings, you need to find the longest uncommon subsequence of this two strings. The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequence should not be any subsequence of the other string.

        +

        Given two strings a and b, find the length of the longest uncommon subsequence between them.

        -

        A subsequence is a sequence that can be derived from one sequence by deleting some characters without changing the order of the remaining elements. Trivially, any string is a subsequence of itself and an empty string is a subsequence of any string.

        +

        subsequence of a string s is a string that can be obtained after deleting any number of characters from s. For example, "abc" is a subsequence of "aebdc" because you can delete the underlined characters in "aebdc" to get "abc". Other subsequences of "aebdc" include "aebdc""aeb", and "" (empty string).

        -

        The input will be two strings, and the output needs to be the length of the longest uncommon subsequence. If the longest uncommon subsequence doesn't exist, return -1.

        +

        An uncommon subsequence between two strings is a string that is a subsequence of one but not the other.

        + +

        Return the length of the longest uncommon subsequence between a and b. If the longest uncommon subsequence doesn't exist, return -1.

         

        Example 1:

        @@ -23,10 +25,8 @@
         Input: a = "aba", b = "cdc"
         Output: 3
        -Explanation: The longest uncommon subsequence is "aba", 
        -because "aba" is a subsequence of "aba", 
        -but not a subsequence of the other string "cdc".
        -Note that "cdc" can be also a longest uncommon subsequence.
        +Explanation: One longest uncommon subsequence is "aba" because "aba" is a subsequence of "aba" but not "cdc".
        +Note that "cdc" is also a longest uncommon subsequence.
         

        Example 2:

        @@ -34,6 +34,7 @@ Note that "cdc" can be also a longest uncommon subsequence.
         Input: a = "aaa", b = "bbb"
         Output: 3
        +Explanation: The longest uncommon subsequences are "aaa" and "bbb".
         

        Example 3:

        @@ -41,6 +42,7 @@ Note that "cdc" can be also a longest uncommon subsequence.
         Input: a = "aaa", b = "aaa"
         Output: -1
        +Explanation: Every subsequence of string a is also a subsequence of string b. Similarly, every subsequence of string b is also a subsequence of string a.
         

         

        @@ -52,6 +54,7 @@ Note that "cdc" can be also a longest uncommon subsequence.
      ### Related Topics + [[Brainteaser](../../tag/brainteaser/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/lru-cache/README.md b/problems/lru-cache/README.md index 9fc8ceb01..af8dfcdf8 100644 --- a/problems/lru-cache/README.md +++ b/problems/lru-cache/README.md @@ -19,25 +19,40 @@

      The cache is initialized with a positive capacity.

      Follow up:
      -Could you do both operations in O(1) time complexity?

      +Could you do both operations in O(1) time complexity?

      -

      Example:

      +

       

      +

      Example 1:

      -LRUCache cache = new LRUCache( 2 /* capacity */ );
      -
      -cache.put(1, 1);
      -cache.put(2, 2);
      -cache.get(1);       // returns 1
      -cache.put(3, 3);    // evicts key 2
      -cache.get(2);       // returns -1 (not found)
      -cache.put(4, 4);    // evicts key 1
      -cache.get(1);       // returns -1 (not found)
      -cache.get(3);       // returns 3
      -cache.get(4);       // returns 4
      +Input
      +["LRUCache", "put", "put", "get", "put", "get", "put", "get", "get", "get"]
      +[[2], [1, 1], [2, 2], [1], [3, 3], [2], [4, 4], [1], [3], [4]]
      +Output
      +[null, null, null, 1, null, -1, null, -1, 3, 4]
      +
      +Explanation
      +LRUCache lRUCache = new LRUCache(2);
      +lRUCache.put(1, 1);
      +lRUCache.put(2, 2);
      +lRUCache.get(1);    // return 1
      +lRUCache.put(3, 3); // evicts key 2
      +lRUCache.get(2);    // returns -1 (not found)
      +lRUCache.put(4, 4); // evicts key 1
      +lRUCache.get(1);    // return -1 (not found)
      +lRUCache.get(3);    // return 3
      +lRUCache.get(4);    // return 4
       

       

      +

      Constraints:

      + +
        +
      • 1 <= capacity <= 3000
      • +
      • 0 <= key <= 3000
      • +
      • 0 <= value <= 104
      • +
      • At most 3 * 104 calls will be made to get and put.
      • +
      ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/magic-squares-in-grid/README.md b/problems/magic-squares-in-grid/README.md index d7b2a0865..c1a79a576 100644 --- a/problems/magic-squares-in-grid/README.md +++ b/problems/magic-squares-in-grid/README.md @@ -9,42 +9,56 @@                  [Next >](../keys-and-rooms "Keys and Rooms") -## [840. Magic Squares In Grid (Easy)](https://leetcode.com/problems/magic-squares-in-grid "矩阵中的幻方") +## [840. Magic Squares In Grid (Medium)](https://leetcode.com/problems/magic-squares-in-grid "矩阵中的幻方") -

      A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum.

      +

      A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum.

      -

      Given an grid of integers, how many 3 x 3 "magic square" subgrids are there?  (Each subgrid is contiguous).

      +

      Given a row x col grid of integers, how many 3 x 3 "magic square" subgrids are there?  (Each subgrid is contiguous).

       

      -

      Example 1:

      - +
      -Input: [[4,3,8,4],
      -        [9,5,1,9],
      -        [2,7,6,2]]
      -Output: 1
      +Input: grid = [[4,3,8,4],[9,5,1,9],[2,7,6,2]]
      +Output: 1
       Explanation: 
       The following subgrid is a 3 x 3 magic square:
      -438
      -951
      -276
      -
      +
       while this one is not:
      -384
      -519
      -762
      -
      +
       In total, there is only one magic square inside the given grid.
       
      -

      Note:

      +

      Example 2:

      + +
      +Input: grid = [[8]]
      +Output: 0
      +
      + +

      Example 3:

      + +
      +Input: grid = [[4,4],[3,3]]
      +Output: 0
      +
      + +

      Example 4:

      + +
      +Input: grid = [[4,7,8],[9,5,1],[2,3,6]]
      +Output: 0
      +
      + +

       

      +

      Constraints:

      -
        -
      1. 1 <= grid.length <= 10
      2. -
      3. 1 <= grid[0].length <= 10
      4. +
          +
        • row == grid.length
        • +
        • col == grid[i].length
        • +
        • 1 <= row, col <= 10
        • 0 <= grid[i][j] <= 15
        • -
      +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/maximize-distance-to-closest-person/README.md b/problems/maximize-distance-to-closest-person/README.md index bcf8f806d..53c48ce05 100644 --- a/problems/maximize-distance-to-closest-person/README.md +++ b/problems/maximize-distance-to-closest-person/README.md @@ -9,46 +9,53 @@                  [Next >](../rectangle-area-ii "Rectangle Area II") -## [849. Maximize Distance to Closest Person (Easy)](https://leetcode.com/problems/maximize-distance-to-closest-person "到最近的人的最大距离") +## [849. Maximize Distance to Closest Person (Medium)](https://leetcode.com/problems/maximize-distance-to-closest-person "到最近的人的最大距离") -

    In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is empty. 

    +

    You are given an array representing a row of seats where seats[i] = 1 represents a person sitting in the ith seat, and seats[i] = 0 represents that the ith seat is empty (0-indexed).

    There is at least one empty seat, and at least one person sitting.

    Alex wants to sit in the seat such that the distance between him and the closest person to him is maximized. 

    -

    Return that maximum distance to closest person.

    +

    Return that maximum distance to the closest person.

    -
    +

     

    Example 1:

    - +
    -Input: [1,0,0,0,1,0,1]
    -Output: 2
    +Input: seats = [1,0,0,0,1,0,1]
    +Output: 2
     Explanation: 
    -If Alex sits in the second open seat (seats[2]), then the closest person has distance 2.
    +If Alex sits in the second open seat (i.e. seats[2]), then the closest person has distance 2.
     If Alex sits in any other open seat, the closest person has distance 1.
    -Thus, the maximum distance to the closest person is 2.
    +Thus, the maximum distance to the closest person is 2. + -

    Example 2:

    -Input: [1,0,0,0]
    -Output: 3
    +Input: seats = [1,0,0,0]
    +Output: 3
     Explanation: 
    -If Alex sits in the last seat, the closest person is 3 seats away.
    +If Alex sits in the last seat (i.e. seats[3]), the closest person is 3 seats away.
     This is the maximum distance possible, so the answer is 3.
     
    -
    -
    + +

    Example 3:

    + +
    +Input: seats = [0,1]
    +Output: 1
    +

     

    Constraints:

      -
    • 2 <= seats.length <= 20000
    • -
    • seats contains only 0s or 1s, at least one 0, and at least one 1.
    • +
    • 2 <= seats.length <= 2 * 104
    • +
    • seats[i] is 0 or 1.
    • +
    • At least one seat is empty.
    • +
    • At least one seat is occupied.
    ### Related Topics diff --git a/problems/median-of-two-sorted-arrays/README.md b/problems/median-of-two-sorted-arrays/README.md index 04ebe89cd..fde07dd5e 100644 --- a/problems/median-of-two-sorted-arrays/README.md +++ b/problems/median-of-two-sorted-arrays/README.md @@ -62,6 +62,7 @@
  • 0 <= m <= 1000
  • 0 <= n <= 1000
  • 1 <= m + n <= 2000
  • +
  • -106 <= nums1[i], nums2[i] <= 106
  • ### Related Topics diff --git a/problems/min-cost-to-connect-all-points/README.md b/problems/min-cost-to-connect-all-points/README.md new file mode 100644 index 000000000..37856ebc4 --- /dev/null +++ b/problems/min-cost-to-connect-all-points/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../count-unhappy-friends "Count Unhappy Friends") +                 +[Next >](../check-if-string-is-transformable-with-substring-sort-operations "Check If String Is Transformable With Substring Sort Operations") + +## [1584. Min Cost to Connect All Points (Medium)](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") + +

    You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].

    + +

    The cost of connecting two points [xi, yi] and [xj, yj] is the manhattan distance between them: |xi - xj| + |yi - yj|, where |val| denotes the absolute value of val.

    + +

    Return the minimum cost to make all points connected. All points are connected if there is exactly one simple path between any two points.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: points = [[0,0],[2,2],[3,10],[5,2],[7,0]]
    +Output: 20
    +Explanation:
    +
    +We can connect the points as shown above to get the minimum cost of 20.
    +Notice that there is a unique path between every pair of points.
    +
    + +

    Example 2:

    + +
    +Input: points = [[3,12],[-2,5],[-4,1]]
    +Output: 18
    +
    + +

    Example 3:

    + +
    +Input: points = [[0,0],[1,1],[1,0],[-1,1]]
    +Output: 4
    +
    + +

    Example 4:

    + +
    +Input: points = [[-1000000,-1000000],[1000000,1000000]]
    +Output: 4000000
    +
    + +

    Example 5:

    + +
    +Input: points = [[0,0]]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= points.length <= 1000
    • +
    • -106 <= xi, yi <= 106
    • +
    • All pairs (xi, yi) are distinct.
    • +
    + +### Related Topics + [[Union Find](../../tag/union-find/README.md)] + +### Hints +
    +Hint 1 +Connect each pair of points with a weighted edge, the weight being the manhattan distance between those points. +
    + +
    +Hint 2 +The problem is now the cost of minimum spanning tree in graph with above edges. +
    diff --git a/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md b/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md index 5a18b7798..1f031cedb 100644 --- a/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md +++ b/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md @@ -11,11 +11,11 @@ ## [1578. Minimum Deletion Cost to Avoid Repeating Letters (Medium)](https://leetcode.com/problems/minimum-deletion-cost-to-avoid-repeating-letters "避免重复字母的最小删除成本") -

    Given a string s and an array of integers cost where cost[i] is the cost of deleting the character i in s.

    +

    Given a string s and an array of integers cost where cost[i] is the cost of deleting the ith character in s.

    -

    Return the minimum cost of deletions such that there are no two identical letters next to each other.

    +

    Return the minimum cost of deletions such that there are no two identical letters next to each other.

    -

    Notice that you will delete the chosen characters at the same time, in other words, after deleting a character, the costs of deleting other characters will not change.

    +

    Notice that you will delete the chosen characters at the same time, in other words, after deleting a character, the costs of deleting other characters will not change.

     

    Example 1:

    diff --git a/problems/number-of-ways-to-split-a-string/README.md b/problems/number-of-ways-to-split-a-string/README.md index 0423ba39c..e1c13b965 100644 --- a/problems/number-of-ways-to-split-a-string/README.md +++ b/problems/number-of-ways-to-split-a-string/README.md @@ -59,8 +59,8 @@

    Constraints:

      -
    • s[i] == '0' or s[i] == '1'
    • 3 <= s.length <= 10^5
    • +
    • s[i] is '0' or '1'.
    ### Related Topics diff --git a/problems/numbers-with-same-consecutive-differences/README.md b/problems/numbers-with-same-consecutive-differences/README.md index ca2e28dfb..049e40dcf 100644 --- a/problems/numbers-with-same-consecutive-differences/README.md +++ b/problems/numbers-with-same-consecutive-differences/README.md @@ -11,38 +11,57 @@ ## [967. Numbers With Same Consecutive Differences (Medium)](https://leetcode.com/problems/numbers-with-same-consecutive-differences "连续差相同的数字") -

    Return all non-negative integers of length N such that the absolute difference between every two consecutive digits is K.

    +

    Return all non-negative integers of length n such that the absolute difference between every two consecutive digits is k.

    Note that every number in the answer must not have leading zeros except for the number 0 itself. For example, 01 has one leading zero and is invalid, but 0 is valid.

    -

    You may return the answer in any order.

    +

    You may return the answer in any order.

     

    -

    Example 1:

    -Input: N = 3, K = 7
    -Output: [181,292,707,818,929]
    +Input: n = 3, k = 7
    +Output: [181,292,707,818,929]
     Explanation: Note that 070 is not a valid number, because it has leading zeroes.
     
    -

    Example 2:

    -Input: N = 2, K = 1
    -Output: [10,12,21,23,32,34,43,45,54,56,65,67,76,78,87,89,98]
    +Input: n = 2, k = 1 +Output: [10,12,21,23,32,34,43,45,54,56,65,67,76,78,87,89,98] + -

     

    -
    +

    Example 3:

    + +
    +Input: n = 2, k = 0
    +Output: [11,22,33,44,55,66,77,88,99]
    +
    -

    Note:

    +

    Example 4:

    + +
    +Input: n = 2, k = 1
    +Output: [10,12,21,23,32,34,43,45,54,56,65,67,76,78,87,89,98]
    +
    + +

    Example 5:

    + +
    +Input: n = 2, k = 2
    +Output: [13,20,24,31,35,42,46,53,57,64,68,75,79,86,97]
    +
    + +

     

    +

    Constraints:

    -
      -
    1. 1 <= N <= 9
    2. -
    3. 0 <= K <= 9
    4. -
    +
      +
    • 2 <= n <= 9
    • +
    • 0 <= k <= 9
    • +
    ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/positions-of-large-groups/README.md b/problems/positions-of-large-groups/README.md index 29f7789c5..a1473233e 100644 --- a/problems/positions-of-large-groups/README.md +++ b/problems/positions-of-large-groups/README.md @@ -11,41 +11,55 @@ ## [830. Positions of Large Groups (Easy)](https://leetcode.com/problems/positions-of-large-groups "较大分组的位置") -

    In a string S of lowercase letters, these letters form consecutive groups of the same character.

    +

    In a string s of lowercase letters, these letters form consecutive groups of the same character.

    -

    For example, a string like S = "abbxxxxzyy" has the groups "a", "bb", "xxxx", "z" and "yy".

    +

    For example, a string like s = "abbxxxxzyy" has the groups "a", "bb", "xxxx", "z", and "yy".

    -

    Call a group large if it has 3 or more characters.  We would like the starting and ending positions of every large group.

    +

    A group is identified by an interval [start, end], where start and end denote the start and end indices (inclusive) of the group. In the above example, "xxxx" has the interval [3,6].

    -

    The final answer should be in lexicographic order.

    +

    A group is considered large if it has 3 or more characters.

    -

     

    +

    Return the intervals of every large group sorted in increasing order by start index.

    +

     

    Example 1:

    -Input: "abbxxxxzzy"
    -Output: [[3,6]]
    -Explanation: "xxxx" is the single large group with starting  3 and ending positions 6.
    +Input: s = "abbxxxxzzy"
    +Output: [[3,6]]
    +Explanation: "xxxx" is the only large group with start index 3 and end index 6.
     

    Example 2:

    -Input: "abc"
    -Output: []
    -Explanation: We have "a","b" and "c" but no large group.
    +Input: s = "abc"
    +Output: []
    +Explanation: We have groups "a", "b", and "c", none of which are large groups.
     

    Example 3:

    -Input: "abcdddeeeeaabbbcd"
    -Output: [[3,5],[6,9],[12,14]]
    +Input: s = "abcdddeeeeaabbbcd" +Output: [[3,5],[6,9],[12,14]] +Explanation: The large groups are "ddd", "eeee", and "bbb". + + +

    Example 4:

    + +
    +Input: s = "aba"
    +Output: []
    +

     

    +

    Constraints:

    -

    Note:  1 <= S.length <= 1000

    +
      +
    • 1 <= s.length <= 1000
    • +
    • s contains lower-case English letters only.
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/put-boxes-into-the-warehouse-ii/README.md b/problems/put-boxes-into-the-warehouse-ii/README.md new file mode 100644 index 000000000..dc52e60d9 --- /dev/null +++ b/problems/put-boxes-into-the-warehouse-ii/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../remove-max-number-of-edges-to-keep-graph-fully-traversable "Remove Max Number of Edges to Keep Graph Fully Traversable") +                 +[Next >](../customer-who-visited-but-did-not-make-any-transactions "Customer Who Visited but Did Not Make Any Transactions") + +## [1580. Put Boxes Into the Warehouse II (Medium)](https://leetcode.com/problems/put-boxes-into-the-warehouse-ii "") + + + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Try to put at least one box in the house pushing it from either side. +
    + +
    +Hint 2 +Once you put one box to the house, you can solve the problem with the same logic used to solve version I. You have a warehouse open from the left only and a warehouse open from the right only. +
    diff --git a/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md b/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md index d6f46aa42..77c108011 100644 --- a/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md +++ b/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md @@ -7,7 +7,7 @@ [< Previous](../minimum-deletion-cost-to-avoid-repeating-letters "Minimum Deletion Cost to Avoid Repeating Letters")                  -Next > +[Next >](../put-boxes-into-the-warehouse-ii "Put Boxes Into the Warehouse II") ## [1579. Remove Max Number of Edges to Keep Graph Fully Traversable (Hard)](https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable "保证图可完全遍历") diff --git a/problems/robot-return-to-origin/README.md b/problems/robot-return-to-origin/README.md index 136450cd1..434b3244a 100644 --- a/problems/robot-return-to-origin/README.md +++ b/problems/robot-return-to-origin/README.md @@ -17,24 +17,45 @@

    Note: The way that the robot is "facing" is irrelevant. "R" will always make the robot move to the right once, "L" will always make it move left, etc. Also, assume that the magnitude of the robot's movement is the same for each move.

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input: "UD"
    -Output: true 
    +Input: moves = "UD"
    +Output: true
     Explanation: The robot moves up once, and then down once. All moves have the same magnitude, so it ended up at the origin where it started. Therefore, we return true.
     
    -

     

    - -

    Example 2:

    +

    Example 2:

    -Input: "LL"
    -Output: false
    +Input: moves = "LL"
    +Output: false
     Explanation: The robot moves left twice. It ends up two "moves" to the left of the origin. We return false because it is not at the origin at the end of its moves.
     
    +

    Example 3:

    + +
    +Input: moves = "RRDD"
    +Output: false
    +
    + +

    Example 4:

    + +
    +Input: moves = "LDRRLRUULR"
    +Output: false
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= moves.length <= 2 * 104
    • +
    • moves only contains the characters 'U', 'D', 'L' and 'R'.
    • +
    + ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/sort-colors/README.md b/problems/sort-colors/README.md index d68e399a4..e5d4fdecb 100644 --- a/problems/sort-colors/README.md +++ b/problems/sort-colors/README.md @@ -11,24 +11,38 @@ ## [75. Sort Colors (Medium)](https://leetcode.com/problems/sort-colors "颜色分类") -

    Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue.

    +

    Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue.

    -

    Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively.

    +

    Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively.

    -

    Note: You are not suppose to use the library's sort function for this problem.

    - -

    Example:

    +

    Follow up:

    -
    -Input: [2,0,2,1,1,0]
    -Output: [0,0,1,1,2,2]
    +
      +
    • Could you solve this problem without using the library's sort function?
    • +
    • Could you come up with a one-pass algorithm using only O(1) constant space?
    • +
    -

    Follow up:

    +

     

    +

    Example 1:

    +
    Input: nums = [2,0,2,1,1,0]
    +Output: [0,0,1,1,2,2]
    +

    Example 2:

    +
    Input: nums = [2,0,1]
    +Output: [0,1,2]
    +

    Example 3:

    +
    Input: nums = [0]
    +Output: [0]
    +

    Example 4:

    +
    Input: nums = [1]
    +Output: [1]
    +
    +

     

    +

    Constraints:

      -
    • A rather straight forward solution is a two-pass algorithm using counting sort.
      - First, iterate the array counting number of 0's, 1's, and 2's, then overwrite array with total number of 0's, then 1's and followed by 2's.
    • -
    • Could you come up with a one-pass algorithm using only constant space?
    • +
    • n == nums.length
    • +
    • 1 <= n <= 300
    • +
    • nums[i] is 0, 1, or 2.
    ### Related Topics @@ -40,3 +54,19 @@ 1. [Sort List](../sort-list) (Medium) 1. [Wiggle Sort](../wiggle-sort) (Medium) 1. [Wiggle Sort II](../wiggle-sort-ii) (Medium) + +### Hints +
    +Hint 1 +A rather straight forward solution is a two-pass algorithm using counting sort. +
    + +
    +Hint 2 +Iterate the array counting number of 0's, 1's, and 2's. +
    + +
    +Hint 3 +Overwrite array with the total number of 0's, then 1's and followed by 2's. +
    diff --git a/problems/special-positions-in-a-binary-matrix/README.md b/problems/special-positions-in-a-binary-matrix/README.md new file mode 100644 index 000000000..4e67d67bf --- /dev/null +++ b/problems/special-positions-in-a-binary-matrix/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../customer-who-visited-but-did-not-make-any-transactions "Customer Who Visited but Did Not Make Any Transactions") +                 +[Next >](../count-unhappy-friends "Count Unhappy Friends") + +## [1582. Special Positions in a Binary Matrix (Easy)](https://leetcode.com/problems/special-positions-in-a-binary-matrix "二进制矩阵中的特殊位置") + +

    Given a rows x cols matrix mat, where mat[i][j] is either 0 or 1, return the number of special positions in mat.

    + +

    A position (i,j) is called special if mat[i][j] == 1 and all other elements in row i and column j are 0 (rows and columns are 0-indexed).

    + +

     

    +

    Example 1:

    + +
    +Input: mat = [[1,0,0],
    +              [0,0,1],
    +              [1,0,0]]
    +Output: 1
    +Explanation: (1,2) is a special position because mat[1][2] == 1 and all other elements in row 1 and column 2 are 0.
    +
    + +

    Example 2:

    + +
    +Input: mat = [[1,0,0],
    +              [0,1,0],
    +              [0,0,1]]
    +Output: 3
    +Explanation: (0,0), (1,1) and (2,2) are special positions. 
    +
    + +

    Example 3:

    + +
    +Input: mat = [[0,0,0,1],
    +              [1,0,0,0],
    +              [0,1,1,0],
    +              [0,0,0,0]]
    +Output: 2
    +
    + +

    Example 4:

    + +
    +Input: mat = [[0,0,0,0,0],
    +              [1,0,0,0,0],
    +              [0,1,0,0,0],
    +              [0,0,1,0,0],
    +              [0,0,0,1,1]]
    +Output: 3
    +
    + +

     

    +

    Constraints:

    + +
      +
    • rows == mat.length
    • +
    • cols == mat[i].length
    • +
    • 1 <= rows, cols <= 100
    • +
    • mat[i][j] is 0 or 1.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Keep track of 1s in each row and in each column. Then while iterating over matrix, if the current position is 1 and current row as well as current column contains exactly one occurrence of 1. +
    diff --git a/problems/string-compression/README.md b/problems/string-compression/README.md index 3c6522a82..70c339043 100644 --- a/problems/string-compression/README.md +++ b/problems/string-compression/README.md @@ -9,63 +9,55 @@                  [Next >](../sequence-reconstruction "Sequence Reconstruction") -## [443. String Compression (Easy)](https://leetcode.com/problems/string-compression "压缩字符串") +## [443. String Compression (Medium)](https://leetcode.com/problems/string-compression "压缩字符串") -

    Given an array of characters, compress it in-place.

    +

    Given an array of characters chars, compress it using the following algorithm:

    -

    The length after compression must always be smaller than or equal to the original array.

    +

    Begin with an empty string s. For each group of consecutive repeating characters in chars:

    -

    Every element of the array should be a character (not int) of length 1.

    +
      +
    • If the group's length is 1, append the character to s.
    • +
    • Otherwise, append the character followed by the group's length.
    • +
    -

    After you are done modifying the input array in-place, return the new length of the array.

    +

    The compressed string s should not be returned separately, but instead be stored in the input character array chars. Note that group lengths that are 10 or longer will be split into multiple characters in chars.

    + +

    After you are done modifying the input array, return the new length of the array.

     

    Follow up:
    -Could you solve it using only O(1) extra space?

    -  +Could you solve it using only O(1) extra space?

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input:
    -["a","a","b","b","c","c","c"]
    -
    -Output:
    -Return 6, and the first 6 characters of the input array should be: ["a","2","b","2","c","3"]
    -
    -Explanation:
    -"aa" is replaced by "a2". "bb" is replaced by "b2". "ccc" is replaced by "c3".
    +Input: chars = ["a","a","b","b","c","c","c"]
    +Output: Return 6, and the first 6 characters of the input array should be: ["a","2","b","2","c","3"]
    +Explanation: The groups are "aa", "bb", and "ccc". This compresses to "a2b2c3".
     
    -

     

    - -

    Example 2:

    +

    Example 2:

    -Input:
    -["a"]
    -
    -Output:
    -Return 1, and the first 1 characters of the input array should be: ["a"]
    -
    -Explanation:
    -Nothing is replaced.
    +Input: chars = ["a"]
    +Output: Return 1, and the first character of the input array should be: ["a"]
    +Explanation: The only group is "a", which remains uncompressed since it's a single character.
     
    -

     

    - -

    Example 3:

    +

    Example 3:

    -Input:
    -["a","b","b","b","b","b","b","b","b","b","b","b","b"]
    +Input: chars = ["a","b","b","b","b","b","b","b","b","b","b","b","b"]
    +Output: Return 4, and the first 4 characters of the input array should be: ["a","b","1","2"].
    +Explanation: The groups are "a" and "bbbbbbbbbbbb". This compresses to "ab12".
    -Output: -Return 4, and the first 4 characters of the input array should be: ["a","b","1","2"]. +

    Example 4:

    -Explanation: -Since the character "a" does not repeat, it is not compressed. "bbbbbbbbbbbb" is replaced by "b12". -Notice each digit has it's own entry in the array. +
    +Input: chars = ["a","a","a","b","b","a","a"]
    +Output: Return 6, and the first 6 characters of the input array should be: ["a","3","b","2","a","2"].
    +Explanation: The groups are "aaa", "bb", and "aa". This compresses to "a3b2a2". Note that each group is independent even if two groups have the same character.
     

     

    @@ -73,8 +65,7 @@ Notice each digit has it's own entry in the array.
    • 1 <= chars.length <= 2000
    • -
    • chars[i].length == 1
    • -
    • chars[i] is a lower-case English letter, upper-case English letter, digit or a symbol.
    • +
    • chars[i] is a lower-case English letter, upper-case English letter, digit, or symbol.
    ### Related Topics diff --git a/problems/sum-of-root-to-leaf-binary-numbers/README.md b/problems/sum-of-root-to-leaf-binary-numbers/README.md index acca3d117..3da4b3899 100644 --- a/problems/sum-of-root-to-leaf-binary-numbers/README.md +++ b/problems/sum-of-root-to-leaf-binary-numbers/README.md @@ -11,33 +11,49 @@ ## [1022. Sum of Root To Leaf Binary Numbers (Easy)](https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers "从根到叶的二进制数之和") -

    Given a binary tree, each node has value 0 or 1.  Each root-to-leaf path represents a binary number starting with the most significant bit.  For example, if the path is 0 -> 1 -> 1 -> 0 -> 1, then this could represent 01101 in binary, which is 13.

    +

    You are given the root of a binary tree where each node has a value 0 or 1.  Each root-to-leaf path represents a binary number starting with the most significant bit.  For example, if the path is 0 -> 1 -> 1 -> 0 -> 1, then this could represent 01101 in binary, which is 13.

    For all leaves in the tree, consider the numbers represented by the path from the root to that leaf.

    -

    Return the sum of these numbers.

    +

    Return the sum of these numbers. The answer is guaranteed to fit in a 32-bits integer.

     

    -

    Example 1:

    + +
    +Input: root = [1,0,1,0,1,0,1]
    +Output: 22
    +Explanation: (100) + (101) + (110) + (111) = 4 + 5 + 6 + 7 = 22
    +
    -

    +

    Example 2:

    -Input: [1,0,1,0,1,0,1]
    -Output: 22
    -Explanation: (100) + (101) + (110) + (111) = 4 + 5 + 6 + 7 = 22
    +Input: root = [0]
    +Output: 0
     
    -

     

    +

    Example 3:

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

    Note:

    +

    Example 4:

    + +
    +Input: root = [1,1]
    +Output: 3
    +
    + +

     

    +

    Constraints:

    -
      -
    1. The number of nodes in the tree is between 1 and 1000.
    2. -
    3. node.val is 0 or 1.
    4. -
    5. The answer will not exceed 2^31 - 1.
    6. -
    +
      +
    • The number of nodes in the tree is in the range [1, 1000].
    • +
    • Node.val is 0 or 1.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/trim-a-binary-search-tree/README.md b/problems/trim-a-binary-search-tree/README.md index 0e8890185..dc8f2cbb1 100644 --- a/problems/trim-a-binary-search-tree/README.md +++ b/problems/trim-a-binary-search-tree/README.md @@ -11,49 +11,54 @@ ## [669. Trim a Binary Search Tree (Easy)](https://leetcode.com/problems/trim-a-binary-search-tree "修剪二叉搜索树") -

    -Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L). You might need to change the root of the tree, so the result should return the new root of the trimmed binary search tree. -

    +

    Given the root of a binary search tree and the lowest and highest boundaries as low and high, trim the tree so that all its elements lies in [low, high]. You might need to change the root of the tree, so the result should return the new root of the trimmed binary search tree.

    -

    Example 1:
    +

     

    +

    Example 1:

    +
    -Input: 
    -    1
    -   / \
    -  0   2
    -
    -  L = 1
    -  R = 2
    -
    -Output: 
    -    1
    -      \
    -       2
    +Input: root = [1,0,2], low = 1, high = 2
    +Output: [1,null,2]
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: 
    -    3
    -   / \
    -  0   4
    -   \
    -    2
    -   /
    -  1
    -
    -  L = 1
    -  R = 3
    -
    -Output: 
    -      3
    -     / 
    -   2   
    -  /
    - 1
    +Input: root = [3,0,4,null,2,null,null,1], low = 1, high = 3
    +Output: [3,2,null,1]
     
    -

    + +

    Example 3:

    + +
    +Input: root = [1], low = 1, high = 2
    +Output: [1]
    +
    + +

    Example 4:

    + +
    +Input: root = [1,null,2], low = 1, high = 3
    +Output: [1,null,2]
    +
    + +

    Example 5:

    + +
    +Input: root = [1,null,2], low = 2, high = 4
    +Output: [2]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree in the range [1, 104].
    • +
    • 0 <= Node.val <= 104
    • +
    • The value of each node in the tree is unique.
    • +
    • root is guaranteed to be a valid binary search tree.
    • +
    • 0 <= l <= r <= 104
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/word-pattern/README.md b/problems/word-pattern/README.md index afa958726..abb6d2af3 100644 --- a/problems/word-pattern/README.md +++ b/problems/word-pattern/README.md @@ -11,36 +11,50 @@ ## [290. Word Pattern (Easy)](https://leetcode.com/problems/word-pattern "单词规律") -

    Given a pattern and a string str, find if str follows the same pattern.

    +

    Given a pattern and a string s, find if s follows the same pattern.

    -

    Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.

    +

    Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in s.

    +

     

    Example 1:

    -Input: pattern = "abba", str = "dog cat cat dog"
    -Output: true
    +Input: pattern = "abba", s = "dog cat cat dog" +Output: true +

    Example 2:

    -Input:pattern = "abba", str = "dog cat cat fish"
    -Output: false
    +Input: pattern = "abba", s = "dog cat cat fish" +Output: false +

    Example 3:

    -Input: pattern = "aaaa", str = "dog cat cat dog"
    -Output: false
    +Input: pattern = "aaaa", s = "dog cat cat dog" +Output: false +

    Example 4:

    -Input: pattern = "abba", str = "dog dog dog dog"
    -Output: false
    +Input: pattern = "abba", s = "dog dog dog dog" +Output: false + -

    Notes:
    -You may assume pattern contains only lowercase letters, and str contains lowercase letters that may be separated by a single space.

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= pattern.length <= 300
    • +
    • pattern contains only lower-case English letters.
    • +
    • 1 <= s.length <= 3000
    • +
    • s contains only lower-case English letters and spaces ' '.
    • +
    • s does not contain any leading or trailing spaces.
    • +
    • All the words in s are separated by a single space.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/readme/1-300.md b/readme/1-300.md index 79c90b9c2..227a2ed97 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -368,5 +368,5 @@ LeetCode Problems' Solutions | 296 | [Best Meeting Point](https://leetcode.com/problems/best-meeting-point "最佳的碰头地点") 🔒 | [Go](../problems/best-meeting-point) | Hard | | 297 | [Serialize and Deserialize Binary Tree](https://leetcode.com/problems/serialize-and-deserialize-binary-tree "二叉树的序列化与反序列化") | [Go](../problems/serialize-and-deserialize-binary-tree) | Hard | | 298 | [Binary Tree Longest Consecutive Sequence](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence "二叉树最长连续序列") 🔒 | [Go](../problems/binary-tree-longest-consecutive-sequence) | Medium | -| 299 | [Bulls and Cows](https://leetcode.com/problems/bulls-and-cows "猜数字游戏") | [Go](../problems/bulls-and-cows) | Easy | +| 299 | [Bulls and Cows](https://leetcode.com/problems/bulls-and-cows "猜数字游戏") | [Go](../problems/bulls-and-cows) | Medium | | 300 | [Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence "最长上升子序列") | [Go](../problems/longest-increasing-subsequence) | Medium | diff --git a/readme/301-600.md b/readme/301-600.md index 70c7c16e8..4361ac502 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -212,7 +212,7 @@ LeetCode Problems' Solutions | 440 | [K-th Smallest in Lexicographical Order](https://leetcode.com/problems/k-th-smallest-in-lexicographical-order "字典序的第K小数字") | [Go](../problems/k-th-smallest-in-lexicographical-order) | Hard | | 441 | [Arranging Coins](https://leetcode.com/problems/arranging-coins "排列硬币") | [Go](../problems/arranging-coins) | Easy | | 442 | [Find All Duplicates in an Array](https://leetcode.com/problems/find-all-duplicates-in-an-array "数组中重复的数据") | [Go](../problems/find-all-duplicates-in-an-array) | Medium | -| 443 | [String Compression](https://leetcode.com/problems/string-compression "压缩字符串") | [Go](../problems/string-compression) | Easy | +| 443 | [String Compression](https://leetcode.com/problems/string-compression "压缩字符串") | [Go](../problems/string-compression) | Medium | | 444 | [Sequence Reconstruction](https://leetcode.com/problems/sequence-reconstruction "序列重建") 🔒 | [Go](../problems/sequence-reconstruction) | Medium | | 445 | [Add Two Numbers II](https://leetcode.com/problems/add-two-numbers-ii "两数相加 II") | [Go](../problems/add-two-numbers-ii) | Medium | | 446 | [Arithmetic Slices II - Subsequence](https://leetcode.com/problems/arithmetic-slices-ii-subsequence "等差数列划分 II - 子序列") | [Go](../problems/arithmetic-slices-ii-subsequence) | Hard | diff --git a/readme/601-900.md b/readme/601-900.md index 926acfe32..86efcc8ca 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -309,7 +309,7 @@ LeetCode Problems' Solutions | 837 | [New 21 Game](https://leetcode.com/problems/new-21-game "新21点") | [Go](../problems/new-21-game) | Medium | | 838 | [Push Dominoes](https://leetcode.com/problems/push-dominoes "推多米诺") | [Go](../problems/push-dominoes) | Medium | | 839 | [Similar String Groups](https://leetcode.com/problems/similar-string-groups "相似字符串组") | [Go](../problems/similar-string-groups) | Hard | -| 840 | [Magic Squares In Grid](https://leetcode.com/problems/magic-squares-in-grid "矩阵中的幻方") | [Go](../problems/magic-squares-in-grid) | Easy | +| 840 | [Magic Squares In Grid](https://leetcode.com/problems/magic-squares-in-grid "矩阵中的幻方") | [Go](../problems/magic-squares-in-grid) | Medium | | 841 | [Keys and Rooms](https://leetcode.com/problems/keys-and-rooms "钥匙和房间") | [Go](../problems/keys-and-rooms) | Medium | | 842 | [Split Array into Fibonacci Sequence](https://leetcode.com/problems/split-array-into-fibonacci-sequence "将数组拆分成斐波那契序列") | [Go](../problems/split-array-into-fibonacci-sequence) | Medium | | 843 | [Guess the Word](https://leetcode.com/problems/guess-the-word "猜猜这个单词") | [Go](../problems/guess-the-word) | Hard | @@ -318,7 +318,7 @@ LeetCode Problems' Solutions | 846 | [Hand of Straights](https://leetcode.com/problems/hand-of-straights "一手顺子") | [Go](../problems/hand-of-straights) | Medium | | 847 | [Shortest Path Visiting All Nodes](https://leetcode.com/problems/shortest-path-visiting-all-nodes "访问所有节点的最短路径") | [Go](../problems/shortest-path-visiting-all-nodes) | Hard | | 848 | [Shifting Letters](https://leetcode.com/problems/shifting-letters "字母移位") | [Go](../problems/shifting-letters) | Medium | -| 849 | [Maximize Distance to Closest Person](https://leetcode.com/problems/maximize-distance-to-closest-person "到最近的人的最大距离") | [Go](../problems/maximize-distance-to-closest-person) | Easy | +| 849 | [Maximize Distance to Closest Person](https://leetcode.com/problems/maximize-distance-to-closest-person "到最近的人的最大距离") | [Go](../problems/maximize-distance-to-closest-person) | Medium | | 850 | [Rectangle Area II](https://leetcode.com/problems/rectangle-area-ii "矩形面积 II") | [Go](../problems/rectangle-area-ii) | Hard | | 851 | [Loud and Rich](https://leetcode.com/problems/loud-and-rich "喧闹和富有") | [Go](../problems/loud-and-rich) | Medium | | 852 | [Peak Index in a Mountain Array](https://leetcode.com/problems/peak-index-in-a-mountain-array "山脉数组的峰顶索引") | [Go](../problems/peak-index-in-a-mountain-array) | Easy | diff --git a/readme/901-1200.md b/readme/901-1200.md index 31aff4877..78cd451c0 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -118,7 +118,7 @@ LeetCode Problems' Solutions | 946 | [Validate Stack Sequences](https://leetcode.com/problems/validate-stack-sequences "验证栈序列") | [Go](../problems/validate-stack-sequences) | Medium | | 947 | [Most Stones Removed with Same Row or Column](https://leetcode.com/problems/most-stones-removed-with-same-row-or-column "移除最多的同行或同列石头") | [Go](../problems/most-stones-removed-with-same-row-or-column) | Medium | | 948 | [Bag of Tokens](https://leetcode.com/problems/bag-of-tokens "令牌放置") | [Go](../problems/bag-of-tokens) | Medium | -| 949 | [Largest Time for Given Digits](https://leetcode.com/problems/largest-time-for-given-digits "给定数字能组成的最大时间") | [Go](../problems/largest-time-for-given-digits) | Easy | +| 949 | [Largest Time for Given Digits](https://leetcode.com/problems/largest-time-for-given-digits "给定数字能组成的最大时间") | [Go](../problems/largest-time-for-given-digits) | Medium | | 950 | [Reveal Cards In Increasing Order](https://leetcode.com/problems/reveal-cards-in-increasing-order "按递增顺序显示卡牌") | [Go](../problems/reveal-cards-in-increasing-order) | Medium | | 951 | [Flip Equivalent Binary Trees](https://leetcode.com/problems/flip-equivalent-binary-trees "翻转等价二叉树") | [Go](../problems/flip-equivalent-binary-trees) | Medium | | 952 | [Largest Component Size by Common Factor](https://leetcode.com/problems/largest-component-size-by-common-factor "按公因数计算最大组件大小") | [Go](../problems/largest-component-size-by-common-factor) | Hard | diff --git a/tag/README.md b/tag/README.md index 31537a923..293a88793 100644 --- a/tag/README.md +++ b/tag/README.md @@ -23,8 +23,8 @@ | 23 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | | 25 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | | 27 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | -| 29 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | -| 31 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 32 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | +| 29 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 30 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | +| 31 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 32 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | | 33 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 34 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | | 35 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | | 37 | [Reservoir Sampling](reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | | 38 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | diff --git a/tag/array/README.md b/tag/array/README.md index b981cf3f4..6bfb60972 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1583 | [统计不开心的朋友](../../problems/count-unhappy-friends) | [[数组](../array/README.md)] | Medium | +| 1582 | [二进制矩阵中的特殊位置](../../problems/special-positions-in-a-binary-matrix) | [[数组](../array/README.md)] | Easy | | 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1572 | [矩阵对角线元素的和](../../problems/matrix-diagonal-sum) | [[数组](../array/README.md)] | Easy | | 1570 | [Dot Product of Two Sparse Vectors](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | @@ -25,7 +27,7 @@ | 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1503 | [所有蚂蚁掉下来前的最后一刻](../../problems/last-moment-before-all-ants-fall-out-of-a-plank) | [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] | Medium | | 1502 | [判断能否形成等差数列](../../problems/can-make-arithmetic-progression-from-sequence) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1500 | [Design a File Sharing System](../../problems/design-a-file-sharing-system) 🔒 | [[数组](../array/README.md)] | Medium | +| 1500 | [Design a File Sharing System](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1493 | [删掉一个元素以后全为 1 的最长子数组](../../problems/longest-subarray-of-1s-after-deleting-one-element) | [[数组](../array/README.md)] | Medium | @@ -159,8 +161,8 @@ | 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 867 | [转置矩阵](../../problems/transpose-matrix) | [[数组](../array/README.md)] | Easy | -| 849 | [到最近的人的最大距离](../../problems/maximize-distance-to-closest-person) | [[数组](../array/README.md)] | Easy | -| 840 | [矩阵中的幻方](../../problems/magic-squares-in-grid) | [[数组](../array/README.md)] | Easy | +| 849 | [到最近的人的最大距离](../../problems/maximize-distance-to-closest-person) | [[数组](../array/README.md)] | Medium | +| 840 | [矩阵中的幻方](../../problems/magic-squares-in-grid) | [[数组](../array/README.md)] | Medium | | 835 | [图像重叠](../../problems/image-overlap) | [[数组](../array/README.md)] | Medium | | 832 | [翻转图像](../../problems/flipping-an-image) | [[数组](../array/README.md)] | Easy | | 830 | [较大分组的位置](../../problems/positions-of-large-groups) | [[数组](../array/README.md)] | Easy | diff --git a/tag/brainteaser/README.md b/tag/brainteaser/README.md index 8caef952a..5c1d0aff4 100644 --- a/tag/brainteaser/README.md +++ b/tag/brainteaser/README.md @@ -13,5 +13,6 @@ | 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1033 | [移动石子直到连续](../../problems/moving-stones-until-consecutive) | [[脑筋急转弯](../brainteaser/README.md)] | Easy | | 777 | [在LR字符串中交换相邻字符](../../problems/swap-adjacent-in-lr-string) | [[脑筋急转弯](../brainteaser/README.md)] | Medium | +| 521 | [最长特殊序列 Ⅰ](../../problems/longest-uncommon-subsequence-i) | [[脑筋急转弯](../brainteaser/README.md)] [[字符串](../string/README.md)] | Easy | | 319 | [灯泡开关](../../problems/bulb-switcher) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Medium | | 292 | [Nim 游戏](../../problems/nim-game) | [[脑筋急转弯](../brainteaser/README.md)] [[极小化极大](../minimax/README.md)] | Easy | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index bd49e533d..afe7f93f1 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -32,6 +32,7 @@ | 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 994 | [腐烂的橘子](../../problems/rotting-oranges) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[极小化极大](../minimax/README.md)] | Hard | | 909 | [蛇梯棋](../../problems/snakes-and-ladders) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 95f002895..ca339e5fe 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -50,6 +50,7 @@ | 979 | [在二叉树中分配硬币](../../problems/distribute-coins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 971 | [翻转二叉树以匹配先序遍历](../../problems/flip-binary-tree-to-match-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 947 | [移除最多的同行或同列石头](../../problems/most-stones-removed-with-same-row-or-column) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index ddf640c51..c32789fae 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1500 | [Design a File Sharing System](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[设计](../design/README.md)] | Medium | | 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 91e0b0ddc..c337941a1 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -102,7 +102,6 @@ | 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | | 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 964 | [表示数字的最少运算符](../../problems/least-operators-to-express-number) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 960 | [删列造序 III](../../problems/delete-columns-to-make-sorted-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 956 | [最高的广告牌](../../problems/tallest-billboard) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 9448dd2a3..849ba2cc4 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | +| 1580 | [Put Boxes Into the Warehouse II](../../problems/put-boxes-into-the-warehouse-ii) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | | 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心算法](../greedy/README.md)] | Medium | | 1568 | [使陆地分离的最少天数](../../problems/minimum-number-of-days-to-disconnect-island) | [[贪心算法](../greedy/README.md)] | Hard | | 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心算法](../greedy/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index a5ed7751c..3ffb8253d 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -81,7 +81,7 @@ | 964 | [表示数字的最少运算符](../../problems/least-operators-to-express-number) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | | 952 | [按公因数计算最大组件大小](../../problems/largest-component-size-by-common-factor) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | -| 949 | [给定数字能组成的最大时间](../../problems/largest-time-for-given-digits) | [[数学](../math/README.md)] | Easy | +| 949 | [给定数字能组成的最大时间](../../problems/largest-time-for-given-digits) | [[数学](../math/README.md)] | Medium | | 942 | [增减字符串匹配](../../problems/di-string-match) | [[数学](../math/README.md)] | Easy | | 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | diff --git a/tag/string/README.md b/tag/string/README.md index 82789100f..ea5bb60cd 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | | 1576 | [替换所有的问号](../../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | [[字符串](../string/README.md)] | Easy | | 1573 | [分割字符串的方案数](../../problems/number-of-ways-to-split-a-string) | [[字符串](../string/README.md)] | Medium | | 1556 | [千位分隔数](../../problems/thousand-separator) | [[字符串](../string/README.md)] | Easy | @@ -143,11 +144,11 @@ | 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | | 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Hard | | 522 | [最长特殊序列 II](../../problems/longest-uncommon-subsequence-ii) | [[字符串](../string/README.md)] | Medium | -| 521 | [最长特殊序列 Ⅰ](../../problems/longest-uncommon-subsequence-i) | [[字符串](../string/README.md)] | Easy | +| 521 | [最长特殊序列 Ⅰ](../../problems/longest-uncommon-subsequence-i) | [[脑筋急转弯](../brainteaser/README.md)] [[字符串](../string/README.md)] | Easy | | 520 | [检测大写字母](../../problems/detect-capital) | [[字符串](../string/README.md)] | Easy | | 468 | [验证IP地址](../../problems/validate-ip-address) | [[字符串](../string/README.md)] | Medium | | 459 | [重复的子字符串](../../problems/repeated-substring-pattern) | [[字符串](../string/README.md)] | Easy | -| 443 | [压缩字符串](../../problems/string-compression) | [[字符串](../string/README.md)] | Easy | +| 443 | [压缩字符串](../../problems/string-compression) | [[字符串](../string/README.md)] | Medium | | 434 | [字符串中的单词数](../../problems/number-of-segments-in-a-string) | [[字符串](../string/README.md)] | Easy | | 415 | [字符串相加](../../problems/add-strings) | [[字符串](../string/README.md)] | Easy | | 408 | [有效单词缩写](../../problems/valid-word-abbreviation) 🔒 | [[字符串](../string/README.md)] | Easy | diff --git a/tag/tags.json b/tag/tags.json index 3c6919a2d..c30dc8cbf 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -144,16 +144,16 @@ "Slug": "minimax", "TranslatedName": "极小化极大" }, - { - "Name": "Binary Indexed Tree", - "Slug": "binary-indexed-tree", - "TranslatedName": "树状数组" - }, { "Name": "Brainteaser", "Slug": "brainteaser", "TranslatedName": "脑筋急转弯" }, + { + "Name": "Binary Indexed Tree", + "Slug": "binary-indexed-tree", + "TranslatedName": "树状数组" + }, { "Name": "Line Sweep", "Slug": "line-sweep", diff --git a/tag/union-find/README.md b/tag/union-find/README.md index 014ce7d7f..f3b58a749 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1584 | [连接所有点的最小费用](../../problems/min-cost-to-connect-all-points) | [[并查集](../union-find/README.md)] | Medium | | 1579 | [保证图可完全遍历](../../problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | [[并查集](../union-find/README.md)] | Hard | | 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | | 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | From 20ae9298c8dc1eff3de7f92aaacf4f6c2ab05633 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 21 Sep 2020 09:20:23 +0800 Subject: [PATCH 099/145] A: new --- README.md | 10 +++ problems/bank-account-summary-ii/README.md | 14 +++ .../bank-account-summary-ii/mysql_schemas.sql | 14 +++ .../README.md | 60 +++++++------ .../binary-search-tree-iterator-ii/README.md | 33 +++++++ .../binary-tree-inorder-traversal/README.md | 52 ++++++++--- problems/bulls-and-cows/README.md | 53 ++++++++--- .../README.md | 2 +- .../README.md | 29 +++---- problems/combination-sum-iii/README.md | 62 ++++++++++--- problems/design-linked-list/README.md | 50 ++++++----- problems/evaluate-division/README.md | 47 +++++++--- .../exclusive-time-of-functions/README.md | 57 ++++++++---- problems/factorial-trailing-zeroes/README.md | 29 +++++-- .../fraction-to-recurring-decimal/README.md | 41 +++++---- .../implement-rand10-using-rand7/README.md | 10 +-- problems/insert-delete-getrandom-o1/README.md | 22 ++--- problems/insert-interval/README.md | 36 +++++++- .../README.md | 47 ---------- problems/lru-cache/README.md | 21 +++-- problems/make-sum-divisible-by-p/README.md | 87 +++++++++++++++++++ problems/maximal-rectangle/README.md | 54 +++++++++--- .../README.md | 78 +++++++++++++++++ .../README.md | 4 +- .../README.md | 69 +++++++++++++++ .../README.md | 44 ++++++++-- .../README.md | 77 ++++++++++++++++ problems/next-permutation/README.md | 2 +- problems/permutation-sequence/README.md | 2 +- problems/permutations/README.md | 2 +- .../rearrange-spaces-between-words/README.md | 74 ++++++++++++++++ problems/scramble-string/README.md | 10 +-- .../README.md | 41 ++++++--- problems/sliding-window-maximum/README.md | 49 ++++++++--- problems/sort-list/README.md | 31 +++++-- problems/spiral-matrix/README.md | 1 + .../README.md | 69 +++++++++++++++ problems/strange-printer-ii/README.md | 75 ++++++++++++++++ .../sum-of-all-odd-length-subarrays/README.md | 67 ++++++++++++++ problems/unique-paths/README.md | 29 +++++-- readme/1-300.md | 2 +- tag/array/README.md | 2 + tag/backtracking/README.md | 3 +- tag/binary-search/README.md | 1 + tag/design/README.md | 1 + tag/dynamic-programming/README.md | 2 + tag/graph/README.md | 1 + tag/greedy/README.md | 3 + tag/hash-table/README.md | 2 +- tag/math/README.md | 2 +- tag/string/README.md | 1 + 51 files changed, 1283 insertions(+), 291 deletions(-) create mode 100644 problems/bank-account-summary-ii/README.md create mode 100644 problems/bank-account-summary-ii/mysql_schemas.sql create mode 100644 problems/binary-search-tree-iterator-ii/README.md create mode 100644 problems/make-sum-divisible-by-p/README.md create mode 100644 problems/maximum-non-negative-product-in-a-matrix/README.md create mode 100644 problems/maximum-sum-obtained-of-any-permutation/README.md create mode 100644 problems/minimum-cost-to-connect-two-groups-of-points/README.md create mode 100644 problems/rearrange-spaces-between-words/README.md create mode 100644 problems/split-a-string-into-the-max-number-of-unique-substrings/README.md create mode 100644 problems/strange-printer-ii/README.md create mode 100644 problems/sum-of-all-odd-length-subarrays/README.md diff --git a/README.md b/README.md index 46efba4ff..d50c1e7f1 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,16 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1595 | [Minimum Cost to Connect Two Groups of Points](https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points "连通两组点的最小成本") | [Go](problems/minimum-cost-to-connect-two-groups-of-points) | Hard | +| 1594 | [Maximum Non Negative Product in a Matrix](https://leetcode.com/problems/maximum-non-negative-product-in-a-matrix "矩阵的最大非负积") | [Go](problems/maximum-non-negative-product-in-a-matrix) | Medium | +| 1593 | [Split a String Into the Max Number of Unique Substrings](https://leetcode.com/problems/split-a-string-into-the-max-number-of-unique-substrings "拆分字符串使唯一子字符串的数目最大") | [Go](problems/split-a-string-into-the-max-number-of-unique-substrings) | Medium | +| 1592 | [Rearrange Spaces Between Words](https://leetcode.com/problems/rearrange-spaces-between-words "重新排列单词间的空格") | [Go](problems/rearrange-spaces-between-words) | Easy | +| 1591 | [Strange Printer II](https://leetcode.com/problems/strange-printer-ii "奇怪的打印机 II") | [Go](problems/strange-printer-ii) | Hard | +| 1590 | [Make Sum Divisible by P](https://leetcode.com/problems/make-sum-divisible-by-p "使数组和能被 P 整除") | [Go](problems/make-sum-divisible-by-p) | Medium | +| 1589 | [Maximum Sum Obtained of Any Permutation](https://leetcode.com/problems/maximum-sum-obtained-of-any-permutation "所有排列中的最大和") | [Go](problems/maximum-sum-obtained-of-any-permutation) | Medium | +| 1588 | [Sum of All Odd Length Subarrays](https://leetcode.com/problems/sum-of-all-odd-length-subarrays "所有奇数长度子数组的和") | [Go](problems/sum-of-all-odd-length-subarrays) | Easy | +| 1587 | [Bank Account Summary II](https://leetcode.com/problems/bank-account-summary-ii) 🔒 | [MySQL](problems/bank-account-summary-ii) | Easy | +| 1586 | [Binary Search Tree Iterator II](https://leetcode.com/problems/binary-search-tree-iterator-ii) 🔒 | [Go](problems/binary-search-tree-iterator-ii) | Medium | | 1585 | [Check If String Is Transformable With Substring Sort Operations](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations "检查字符串是否可以通过排序子字符串得到另一个字符串") | [Go](problems/check-if-string-is-transformable-with-substring-sort-operations) | Hard | | 1584 | [Min Cost to Connect All Points](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") | [Go](problems/min-cost-to-connect-all-points) | Medium | | 1583 | [Count Unhappy Friends](https://leetcode.com/problems/count-unhappy-friends "统计不开心的朋友") | [Go](problems/count-unhappy-friends) | Medium | diff --git a/problems/bank-account-summary-ii/README.md b/problems/bank-account-summary-ii/README.md new file mode 100644 index 000000000..b28ae4cd0 --- /dev/null +++ b/problems/bank-account-summary-ii/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../binary-search-tree-iterator-ii "Binary Search Tree Iterator II") +                 +[Next >](../sum-of-all-odd-length-subarrays "Sum of All Odd Length Subarrays") + +## [1587. Bank Account Summary II (Easy)](https://leetcode.com/problems/bank-account-summary-ii "") + + diff --git a/problems/bank-account-summary-ii/mysql_schemas.sql b/problems/bank-account-summary-ii/mysql_schemas.sql new file mode 100644 index 000000000..a6c25623c --- /dev/null +++ b/problems/bank-account-summary-ii/mysql_schemas.sql @@ -0,0 +1,14 @@ +Create table If Not Exists Users (account int, name varchar(20)); +Create table If Not Exists Transactions (trans_id int, account int, amount int, transacted_on date); +Truncate table Users; +insert into Users (account, name) values ('900001', 'Alice'); +insert into Users (account, name) values ('900002', 'Bob'); +insert into Users (account, name) values ('900003', 'Charlie'); +Truncate table Transactions; +insert into Transactions (trans_id, account, amount, transacted_on) values ('1', '900001', '7000', '2020-08-01'); +insert into Transactions (trans_id, account, amount, transacted_on) values ('2', '900001', '7000', '2020-09-01'); +insert into Transactions (trans_id, account, amount, transacted_on) values ('3', '900001', '-3000', '2020-09-02'); +insert into Transactions (trans_id, account, amount, transacted_on) values ('4', '900002', '1000', '2020-09-12'); +insert into Transactions (trans_id, account, amount, transacted_on) values ('5', '900003', '6000', '2020-08-07'); +insert into Transactions (trans_id, account, amount, transacted_on) values ('6', '900003', '6000', '2020-09-07'); +insert into Transactions (trans_id, account, amount, transacted_on) values ('7', '900003', '-4000', '2020-09-11'); diff --git a/problems/binary-number-with-alternating-bits/README.md b/problems/binary-number-with-alternating-bits/README.md index f05d9ee99..e5f488359 100644 --- a/problems/binary-number-with-alternating-bits/README.md +++ b/problems/binary-number-with-alternating-bits/README.md @@ -13,41 +13,49 @@

    Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values.

    -

    Example 1:
    +

     

    +

    Example 1:

    +
    -Input: 5
    -Output: True
    -Explanation:
    -The binary representation of 5 is: 101
    +Input: n = 5
    +Output: true
    +Explanation: The binary representation of 5 is: 101
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: 7
    -Output: False
    -Explanation:
    -The binary representation of 7 is: 111.
    -
    -

    +Input: n = 7 +Output: false +Explanation: The binary representation of 7 is: 111. + +

    Example 3:

    -

    Example 3:

    -Input: 11
    -Output: False
    -Explanation:
    -The binary representation of 11 is: 1011.
    -
    -

    +Input: n = 1 +Output: true +Explanation: The binary representation of 11 is: 1011. + +

    Example 4:

    -

    Example 4:

    -Input: 10
    -Output: True
    -Explanation:
    -The binary representation of 10 is: 1010.
    +Input: n = 2
    +Output: true
    +Explanation: The binary representation of 10 is: 1010.
    + +

    Example 5:

    + +
    +Input: n = 3
    +Output: false
     
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 231 - 1
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/binary-search-tree-iterator-ii/README.md b/problems/binary-search-tree-iterator-ii/README.md new file mode 100644 index 000000000..9ae868179 --- /dev/null +++ b/problems/binary-search-tree-iterator-ii/README.md @@ -0,0 +1,33 @@ + + + + + + + +[< Previous](../check-if-string-is-transformable-with-substring-sort-operations "Check If String Is Transformable With Substring Sort Operations") +                 +[Next >](../bank-account-summary-ii "Bank Account Summary II") + +## [1586. Binary Search Tree Iterator II (Medium)](https://leetcode.com/problems/binary-search-tree-iterator-ii "") + + + +### Related Topics + [[Design](../../tag/design/README.md)] + +### Hints +
    +Hint 1 +The inorder traversal of a BST gives us the elements in a sorted order. +
    + +
    +Hint 2 +We can use a stack to simulate the inorder traversal of the BST. +
    + +
    +Hint 3 +We can use another stack as a buffer to store numbers returned from calls to next and use this buffer whenever prev is called. +
    diff --git a/problems/binary-tree-inorder-traversal/README.md b/problems/binary-tree-inorder-traversal/README.md index 6cfc09190..909b9c3a7 100644 --- a/problems/binary-tree-inorder-traversal/README.md +++ b/problems/binary-tree-inorder-traversal/README.md @@ -11,21 +11,53 @@ ## [94. Binary Tree Inorder Traversal (Medium)](https://leetcode.com/problems/binary-tree-inorder-traversal "二叉树的中序遍历") -

    Given a binary tree, return the inorder traversal of its nodes' values.

    +

    Given the root of a binary tree, return the inorder traversal of its nodes' values.

    -

    Example:

    +

    Follow up: Recursive solution is trivial, could you do it iteratively?

    +

     

    +

    Example 1:

    +
    -Input: [1,null,2,3]
    -   1
    -    \
    -     2
    -    /
    -   3
    +Input: root = [1,null,2,3]
    +Output: [1,3,2]
    +
    -Output: [1,3,2] +

    Example 2:

    -

    Follow up: Recursive solution is trivial, could you do it iteratively?

    +
    +Input: root = []
    +Output: []
    +
    + +

    Example 3:

    + +
    +Input: root = [1]
    +Output: [1]
    +
    + +

    Example 4:

    + +
    +Input: root = [1,2]
    +Output: [2,1]
    +
    + +

    Example 5:

    + +
    +Input: root = [1,null,2]
    +Output: [1,2]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [0, 100].
    • +
    • -100 <= Node.val <= 100
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/bulls-and-cows/README.md b/problems/bulls-and-cows/README.md index f2c9dbbc6..a5343cd48 100644 --- a/problems/bulls-and-cows/README.md +++ b/problems/bulls-and-cows/README.md @@ -9,33 +9,66 @@                  [Next >](../longest-increasing-subsequence "Longest Increasing Subsequence") -## [299. Bulls and Cows (Easy)](https://leetcode.com/problems/bulls-and-cows "猜数字游戏") +## [299. Bulls and Cows (Medium)](https://leetcode.com/problems/bulls-and-cows "猜数字游戏") -

    You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint that indicates how many digits in said guess match your secret number exactly in both digit and position (called "bulls") and how many digits match the secret number but locate in the wrong position (called "cows"). Your friend will use successive guesses and hints to eventually derive the secret number.

    +

    You are playing the Bulls and Cows game with your friend.

    -

    Write a function to return a hint according to the secret number and friend's guess, use A to indicate the bulls and B to indicate the cows. 

    +

    You write down a secret number and ask your friend to guess what the number is. When your friend makes a guess, you provide a hint with the following info:

    -

    Please note that both secret number and friend's guess may contain duplicate digits.

    +
      +
    • The number of "bulls", which are digits in the guess that are in the correct position.
    • +
    • The number of "cows", which are digits in the guess that are in your secret number but are located in the wrong position. Specifically, the non-bull digits in the guess that could be rearranged such that they become bulls.
    • +
    +

    Given the secret number secret and your friend's guess guess, return the hint for your friend's guess.

    + +

    The hint should be formatted as "xAyB", where x is the number of bulls and y is the number of cows. Note that both secret and guess may contain duplicate digits.

    + +

     

    Example 1:

     Input: secret = "1807", guess = "7810"
    -
     Output: "1A3B"
    -
    -Explanation: 1 bull and 3 cows. The bull is 8, the cows are 0, 1 and 7.
    +Explanation: Bulls are connected with a '|' and cows are underlined: +"1807" + | +"7810"

    Example 2:

     Input: secret = "1123", guess = "0111"
    -
     Output: "1A1B"
    +Explanation: Bulls are connected with a '|' and cows are underlined:
    +"1123"        "1123"
    +  |      or     |
    +"0111"        "0111"
    +Note that only one of the two unmatched 1s is counted as a cow since the non-bull digits can only be rearranged to allow one 1 to be a bull.
    +
    + +

    Example 3:

    + +
    +Input: secret = "1", guess = "0"
    +Output: "0A0B"
    +
    + +

    Example 4:

    + +
    +Input: secret = "1", guess = "1"
    +Output: "1A0B"
    +
    -Explanation: The 1st 1 in friend's guess is a bull, the 2nd or 3rd 1 is a cow. +

     

    +

    Constraints:

    -

    Note: You may assume that the secret number and your friend's guess only contain digits, and their lengths are always equal.

    +
      +
    • 1 <= secret.length, guess.length <= 1000
    • +
    • secret.length == guess.length
    • +
    • secret and guess consist of digits only.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md b/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md index 28f630dcd..eff4fd096 100644 --- a/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md +++ b/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md @@ -7,7 +7,7 @@ [< Previous](../min-cost-to-connect-all-points "Min Cost to Connect All Points")                  -Next > +[Next >](../binary-search-tree-iterator-ii "Binary Search Tree Iterator II") ## [1585. Check If String Is Transformable With Substring Sort Operations (Hard)](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations "检查字符串是否可以通过排序子字符串得到另一个字符串") diff --git a/problems/check-if-word-is-valid-after-substitutions/README.md b/problems/check-if-word-is-valid-after-substitutions/README.md index 0a3bd0945..25bd6c60f 100644 --- a/problems/check-if-word-is-valid-after-substitutions/README.md +++ b/problems/check-if-word-is-valid-after-substitutions/README.md @@ -11,17 +11,15 @@ ## [1003. Check If Word Is Valid After Substitutions (Medium)](https://leetcode.com/problems/check-if-word-is-valid-after-substitutions "检查替换后的词是否有效") -

    We can say that a string is valid if it follows one of the three following cases:

    +

    Given a string s, determine if it is valid.

    + +

    A string s is valid if, starting with an empty string t = "", you can transform t into s after performing the following operation any number of times:

      -
    • An empty string "" is valid.
    • -
    • The string "abc" is also valid.
    • -
    • Any string in the form "a" + str + "bc", "ab" + str + "c", str + "abc" or "abc" + str where str is a valid string is also considered a valid string.
    • +
    • Insert string "abc" into any position in t. More formally, t becomes tleft + "abc" + tright, where t == tleft + tright. Note that tleft and tright may be empty.
    -

    For example, "", "abc""aabcbc""abcabc" and "abcabcababcc" are all valid strings, while "abccba""ab", "cababc" and "bac" are not valid strings.

    - -

    Given a string s, return true if it is a valid string, otherwise, return false.

    +

    Return true if s is a valid string, otherwise, return false.

     

    Example 1:

    @@ -29,19 +27,18 @@
     Input: s = "aabcbc"
     Output: true
    -Explanation: 
    -We start with the valid string "abc".
    -Then we can insert another "abc" between "a" and "bc", resulting in "a" + "abc" + "bc" which is "aabcbc".
    -
    +Explanation: +"" -> "abc" -> "aabcbc" +Thus, "aabcbc" is valid.

    Example 2:

     Input: s = "abcabcababcc"
     Output: true
    -Explanation: 
    -"abcabcabc" is valid after consecutive insertings of "abc".
    -Then we can insert "abc" before the last letter, resulting in "abcabcab" + "abc" + "c" which is "abcabcababcc".
    +Explanation:
    +"" -> "abc" -> "abcabc" -> "abcabcabc" -> "abcabcababcc"
    +Thus, "abcabcababcc" is valid.
     

    Example 3:

    @@ -49,6 +46,7 @@ Then we can insert "abc" before the last letter, resulting in "ab
     Input: s = "abccba"
     Output: false
    +Explanation: It is impossible to get "abccba" using the operation.
     

    Example 4:

    @@ -56,6 +54,7 @@ Then we can insert "abc" before the last letter, resulting in "ab
     Input: s = "cababc"
     Output: false
    +Explanation: It is impossible to get "cababc" using the operation.
     

     

    @@ -63,7 +62,7 @@ Then we can insert "abc" before the last letter, resulting in "ab
    • 1 <= s.length <= 2 * 104
    • -
    • s[i] is 'a', 'b', or 'c'
    • +
    • s consists of letters 'a', 'b', and 'c'
    ### Related Topics diff --git a/problems/combination-sum-iii/README.md b/problems/combination-sum-iii/README.md index 806610e75..7a0d8c1f9 100644 --- a/problems/combination-sum-iii/README.md +++ b/problems/combination-sum-iii/README.md @@ -11,30 +11,70 @@ ## [216. Combination Sum III (Medium)](https://leetcode.com/problems/combination-sum-iii "组合总和 III") -
    -

    Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.

    - -

    Note:

    +

    Find all valid combinations of k numbers that sum up to n such that the following conditions are true:

      -
    • All numbers will be positive integers.
    • -
    • The solution set must not contain duplicate combinations.
    • +
    • Only numbers 1 through 9 are used.
    • +
    • Each number is used at most once.
    +

    Return a list of all possible valid combinations. The list must not contain the same combination twice, and the combinations may be returned in any order.

    + +

     

    Example 1:

    -Input: k = 3, n = 7
    +Input: k = 3, n = 7
     Output: [[1,2,4]]
    -
    +Explanation: +1 + 2 + 4 = 7 +There are no other valid combinations.

    Example 2:

    -Input: k = 3, n = 9
    -Output: [[1,2,6], [1,3,5], [2,3,4]]
    +Input: k = 3, n = 9
    +Output: [[1,2,6],[1,3,5],[2,3,4]]
    +Explanation:
    +1 + 2 + 6 = 9
    +1 + 3 + 5 = 9
    +2 + 3 + 4 = 9
    +There are no other valid combinations.
    +
    + +

    Example 3:

    + +
    +Input: k = 4, n = 1
    +Output: []
    +Explanation: There are no valid combinations. [1,2,1] is not valid because 1 is used twice.
     
    -
    + +

    Example 4:

    + +
    +Input: k = 3, n = 2
    +Output: []
    +Explanation: There are no valid combinations.
    +
    + +

    Example 5:

    + +
    +Input: k = 9, n = 45
    +Output: [[1,2,3,4,5,6,7,8,9]]
    +Explanation:
    +1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 = 45
    +​​​​​​​There are no other valid combinations.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= k <= 9
    • +
    • 1 <= n <= 60
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/design-linked-list/README.md b/problems/design-linked-list/README.md index c4f46cc65..a6737c41a 100644 --- a/problems/design-linked-list/README.md +++ b/problems/design-linked-list/README.md @@ -11,44 +11,46 @@ ## [707. Design Linked List (Medium)](https://leetcode.com/problems/design-linked-list "设计链表") -

    Design your implementation of the linked list. You can choose to use the singly linked list or the doubly linked list. A node in a singly linked list should have two attributes: val and next. val is the value of the current node, and next is a pointer/reference to the next node. If you want to use the doubly linked list, you will need one more attribute prev to indicate the previous node in the linked list. Assume all nodes in the linked list are 0-indexed.

    +

    Design your implementation of the linked list. You can choose to use a singly or doubly linked list.
    +A node in a singly linked list should have two attributes: val and next. val is the value of the current node, and next is a pointer/reference to the next node.
    +If you want to use the doubly linked list, you will need one more attribute prev to indicate the previous node in the linked list. Assume all nodes in the linked list are 0-indexed.

    -

    Implement these functions in your linked list class:

    +

    Implement the MyLinkedList class:

      -
    • get(index) : Get the value of the index-th node in the linked list. If the index is invalid, return -1.
    • -
    • addAtHead(val) : Add a node of value val before the first element of the linked list. After the insertion, the new node will be the first node of the linked list.
    • -
    • addAtTail(val) : Append a node of value val to the last element of the linked list.
    • -
    • addAtIndex(index, val) : Add a node of value val before the index-th node in the linked list. If index equals to the length of linked list, the node will be appended to the end of linked list. If index is greater than the length, the node will not be inserted.
    • -
    • deleteAtIndex(index) : Delete the index-th node in the linked list, if the index is valid.
    • +
    • MyLinkedList() Initializes the MyLinkedList object.
    • +
    • int get(int index) Get the value of the indexth node in the linked list. If the index is invalid, return -1.
    • +
    • void addAtHead(int val) Add a node of value val before the first element of the linked list. After the insertion, the new node will be the first node of the linked list.
    • +
    • void addAtTail(int val) Append a node of value val as the last element of the linked list.
    • +
    • void addAtIndex(int index, int val) Add a node of value val before the indexth node in the linked list. If index equals the length of the linked list, the node will be appended to the end of the linked list. If index is greater than the length, the node will not be inserted.
    • +
    • void deleteAtIndex(int index) Delete the indexth node in the linked list, if the index is valid.

     

    - -

    Example:

    +

    Example 1:

    -Input: 
    -["MyLinkedList","addAtHead","addAtTail","addAtIndex","get","deleteAtIndex","get"]
    -[[],[1],[3],[1,2],[1],[1],[1]]
    -Output:  
    -[null,null,null,null,2,null,3]
    -
    -Explanation:
    -MyLinkedList linkedList = new MyLinkedList(); // Initialize empty LinkedList
    -linkedList.addAtHead(1);
    -linkedList.addAtTail(3);
    -linkedList.addAtIndex(1, 2);  // linked list becomes 1->2->3
    -linkedList.get(1);            // returns 2
    -linkedList.deleteAtIndex(1);  // now the linked list is 1->3
    -linkedList.get(1);            // returns 3
    +Input
    +["MyLinkedList", "addAtHead", "addAtTail", "addAtIndex", "get", "deleteAtIndex", "get"]
    +[[], [1], [3], [1, 2], [1], [1], [1]]
    +Output
    +[null, null, null, null, 2, null, 3]
    +
    +Explanation
    +MyLinkedList myLinkedList = new MyLinkedList();
    +myLinkedList.addAtHead(1);
    +myLinkedList.addAtTail(3);
    +myLinkedList.addAtIndex(1, 2);    // linked list becomes 1->2->3
    +myLinkedList.get(1);              // return 2
    +myLinkedList.deleteAtIndex(1);    // now the linked list is 1->3
    +myLinkedList.get(1);              // return 3
     

     

    Constraints:

      -
    • 0 <= index,val <= 1000
    • +
    • 0 <= index, val <= 1000
    • Please do not use the built-in LinkedList library.
    • At most 2000 calls will be made to getaddAtHeadaddAtTailaddAtIndex and deleteAtIndex.
    diff --git a/problems/evaluate-division/README.md b/problems/evaluate-division/README.md index da828384c..20de64122 100644 --- a/problems/evaluate-division/README.md +++ b/problems/evaluate-division/README.md @@ -11,25 +11,50 @@ ## [399. Evaluate Division (Medium)](https://leetcode.com/problems/evaluate-division "除法求值") -

    Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the answer does not exist, return -1.0.

    +

    You are given equations in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating-point number). Given some queries, return the answers. If the answer does not exist, return -1.0.

    -

    Example:
    -Given a / b = 2.0, b / c = 3.0.
    -queries are: a / c = ?, b / a = ?, a / e = ?, a / a = ?, x / x = ? .
    -return [6.0, 0.5, -1.0, 1.0, -1.0 ].

    +

    The input is always valid. You may assume that evaluating the queries will result in no division by zero and there is no contradiction.

    + +

     

    +

    Example 1:

    + +
    +Input: equations = [["a","b"],["b","c"]], values = [2.0,3.0], queries = [["a","c"],["b","a"],["a","e"],["a","a"],["x","x"]]
    +Output: [6.00000,0.50000,-1.00000,1.00000,-1.00000]
    +Explanation: 
    +Given: a / b = 2.0, b / c = 3.0
    +queries are: a / c = ?, b / a = ?, a / e = ?, a / a = ?, x / x = ?
    +return: [6.0, 0.5, -1.0, 1.0, -1.0 ]
    +
    + +

    Example 2:

    -

    The input is: vector<pair<string, string>> equations, vector<double>& values, vector<pair<string, string>> queries , where equations.size() == values.size(), and the values are positive. This represents the equations. Return vector<double>.

    +
    +Input: equations = [["a","b"],["b","c"],["bc","cd"]], values = [1.5,2.5,5.0], queries = [["a","c"],["c","b"],["bc","cd"],["cd","bc"]]
    +Output: [3.75000,0.40000,5.00000,0.20000]
    +
    -

    According to the example above:

    +

    Example 3:

    -equations = [ ["a", "b"], ["b", "c"] ],
    -values = [2.0, 3.0],
    -queries = [ ["a", "c"], ["b", "a"], ["a", "e"], ["a", "a"], ["x", "x"] ]. 
    +Input: equations = [["a","b"]], values = [0.5], queries = [["a","b"],["b","a"],["a","c"],["x","y"]] +Output: [0.50000,2.00000,-1.00000,-1.00000] +

     

    +

    Constraints:

    -

    The input is always valid. You may assume that evaluating the queries will result in no division by zero and there is no contradiction.

    +
      +
    • 1 <= equations.length <= 20
    • +
    • equations[i].length == 2
    • +
    • 1 <= equations[i][0], equations[i][1] <= 5
    • +
    • values.length == equations.length
    • +
    • 0.0 <= values[i] <= 20.0
    • +
    • 1 <= queries.length <= 20
    • +
    • queries[i].length == 2
    • +
    • 1 <= queries[i][0], queries[i][1] <= 5
    • +
    • equations[i][0], equations[i][1], queries[i][0], queries[i][1] consist of lower case English letters and digits.
    • +
    ### Related Topics [[Union Find](../../tag/union-find/README.md)] diff --git a/problems/exclusive-time-of-functions/README.md b/problems/exclusive-time-of-functions/README.md index 3eb9ebd75..02ea6040b 100644 --- a/problems/exclusive-time-of-functions/README.md +++ b/problems/exclusive-time-of-functions/README.md @@ -24,34 +24,57 @@

    Return the exclusive time of each function, sorted by their function id.

     

    - -

    Example 1:

    - -

    - +

    Example 1:

    +
    -Input:
    -n = 2
    -logs = ["0:start:0","1:start:2","1:end:5","0:end:6"]
    -Output: [3, 4]
    -Explanation:
    +Input: n = 2, logs = ["0:start:0","1:start:2","1:end:5","0:end:6"]
    +Output: [3,4]
    +Explanation:
     Function 0 starts at the beginning of time 0, then it executes 2 units of time and reaches the end of time 1.
     Now function 1 starts at the beginning of time 2, executes 4 units of time and ends at time 5.
     Function 0 is running again at the beginning of time 6, and also ends at the end of time 6, thus executing for 1 unit of time. 
     So function 0 spends 2 + 1 = 3 units of total time executing, and function 1 spends 4 units of total time executing.
     
    -

     

    +

    Example 2:

    + +
    +Input: n = 1, logs = ["0:start:0","0:start:2","0:end:5","0:start:6","0:end:6","0:end:7"]
    +Output: [8]
    +
    -

    Note:

    +

    Example 3:

    -
      -
    1. 1 <= n <= 100
    2. -
    3. Two functions won't start or end at the same time.
    4. -
    5. Functions will always log when they exit.
    6. -
    +
    +Input: n = 2, logs = ["0:start:0","0:start:2","0:end:5","1:start:6","1:end:6","0:end:7"]
    +Output: [7,1]
    +
    + +

    Example 4:

    + +
    +Input: n = 2, logs = ["0:start:0","0:start:2","0:end:5","1:start:7","1:end:7","0:end:8"]
    +Output: [8,1]
    +
    + +

    Example 5:

    + +
    +Input: n = 1, logs = ["0:start:0","0:end:0"]
    +Output: [1]
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 100
    • +
    • 1 <= logs.length <= 500
    • +
    • 0 <= function_id < 100
    • +
    • 0 <= timestamp <= 109
    • +
    • Two functions do not start or end at the same time.
    • +
    • Each function has an "end" log for each "start" log.
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/factorial-trailing-zeroes/README.md b/problems/factorial-trailing-zeroes/README.md index ad390a548..10e4a76f7 100644 --- a/problems/factorial-trailing-zeroes/README.md +++ b/problems/factorial-trailing-zeroes/README.md @@ -11,23 +11,40 @@ ## [172. Factorial Trailing Zeroes (Easy)](https://leetcode.com/problems/factorial-trailing-zeroes "阶乘后的零") -

    Given an integer n, return the number of trailing zeroes in n!.

    +

    Given an integer n, return the number of trailing zeroes in n!.

    +

    Follow up: Could you write a solution that works in logarithmic time complexity?

    + +

     

    Example 1:

    -Input: 3
    +Input: n = 3
     Output: 0
    -Explanation: 3! = 6, no trailing zero.
    +Explanation: 3! = 6, no trailing zero. +

    Example 2:

    -Input: 5
    +Input: n = 5
     Output: 1
    -Explanation: 5! = 120, one trailing zero.
    +Explanation: 5! = 120, one trailing zero. + + +

    Example 3:

    + +
    +Input: n = 0
    +Output: 0
    +
    + +

     

    +

    Constraints:

    -

    Note: Your solution should be in logarithmic time complexity.

    +
      +
    • 1 <= n <= 104
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/fraction-to-recurring-decimal/README.md b/problems/fraction-to-recurring-decimal/README.md index 1853aeca2..ecec11e69 100644 --- a/problems/fraction-to-recurring-decimal/README.md +++ b/problems/fraction-to-recurring-decimal/README.md @@ -11,31 +11,36 @@ ## [166. Fraction to Recurring Decimal (Medium)](https://leetcode.com/problems/fraction-to-recurring-decimal "分数到小数") -

    Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.

    +

    Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.

    If the fractional part is repeating, enclose the repeating part in parentheses.

    -

    If multiple answers are possible, just return any of them.

    +

    If multiple answers are possible, return any of them.

    +

     

    Example 1:

    - -
    -Input: numerator = 1, denominator = 2
    -Output: "0.5"
    +
    Input: numerator = 1, denominator = 2
    +Output: "0.5"
    +

    Example 2:

    +
    Input: numerator = 2, denominator = 1
    +Output: "2"
    +

    Example 3:

    +
    Input: numerator = 2, denominator = 3
    +Output: "0.(6)"
    +

    Example 4:

    +
    Input: numerator = 4, denominator = 333
    +Output: "0.(012)"
    +

    Example 5:

    +
    Input: numerator = 1, denominator = 5
    +Output: "0.2"
     
    +

     

    +

    Constraints:

    -

    Example 2:

    - -
    -Input: numerator = 2, denominator = 1
    -Output: "2"
    - -

    Example 3:

    - -
    -Input: numerator = 2, denominator = 3
    -Output: "0.(6)"
    -
    +
      +
    • -231 <= numerator, denominator <= 231 - 1
    • +
    • denominator != 0
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/implement-rand10-using-rand7/README.md b/problems/implement-rand10-using-rand7/README.md index 09d1e69a8..a29c1c155 100644 --- a/problems/implement-rand10-using-rand7/README.md +++ b/problems/implement-rand10-using-rand7/README.md @@ -11,18 +11,16 @@ ## [470. Implement Rand10() Using Rand7() (Medium)](https://leetcode.com/problems/implement-rand10-using-rand7 "用 Rand7() 实现 Rand10()") -

    Given the API rand7 which generates a uniform random integer in the range 1 to 7, write a function rand10 which generates a uniform random integer in the range 1 to 10. You can only call the API rand7 and you shouldn't call any other API. Please don't use the system's Math.random().

    +

    Given the API rand7() that generates a uniform random integer in the range [1, 7], write a function rand10() that generates a uniform random integer in the range [1, 10]. You can only call the API rand7(), and you shouldn't call any other API. Please do not use a language's built-in random API.

    -
    -

    Notice that Each test case has one argument n, the number of times that your implemented function rand10 will be called while testing. 

    +

    Each test case will have one internal argument n, the number of times that your implemented function rand10() will be called while testing. Note that this is not an argument passed to rand10().

    Follow up:

    -
      +
      • What is the expected value for the number of calls to rand7() function?
      • Could you minimize the number of calls to rand7()?
      • -
    -
    +

     

    Example 1:

    diff --git a/problems/insert-delete-getrandom-o1/README.md b/problems/insert-delete-getrandom-o1/README.md index 24e70239a..4c5b0435b 100644 --- a/problems/insert-delete-getrandom-o1/README.md +++ b/problems/insert-delete-getrandom-o1/README.md @@ -11,15 +11,15 @@ ## [380. Insert Delete GetRandom O(1) (Medium)](https://leetcode.com/problems/insert-delete-getrandom-o1 "常数时间插入、删除和获取随机元素") -

    Design a data structure that supports all following operations in average O(1) time.

    +

    Implement the RandomizedSet class:

    -

     

    +
      +
    • bool insert(int val) Inserts an item val into the set if not present. Returns true if the item was not present, false otherwise.
    • +
    • bool remove(int val) Removes an item val from the set if present. Returns true if the item was present, false otherwise.
    • +
    • int getRandom() Returns a random element from the current set of elements (it's guaranteed that at least one element exists when this method is called). Each element must have the same probability of being returned.
    • +
    -
      -
    1. insert(val): Inserts an item val to the set if not already present.
    2. -
    3. remove(val): Removes an item val from the set if present.
    4. -
    5. getRandom: Returns a random element from the current set of elements (it's guaranteed that at least one element exists when this method is called). Each element must have the same probability of being returned.
    6. -
    +

    Follow up: Could you implement the functions of the class with each function works in average O(1) time?

     

    Example 1:

    @@ -36,10 +36,10 @@ RandomizedSet randomizedSet = new RandomizedSet(); randomizedSet.insert(1); // Inserts 1 to the set. Returns true as 1 was inserted successfully. randomizedSet.remove(2); // Returns false as 2 does not exist in the set. randomizedSet.insert(2); // Inserts 2 to the set, returns true. Set now contains [1,2]. -randomizedSet.getRandom(); // getRandom should return either 1 or 2 randomly. +randomizedSet.getRandom(); // getRandom() should return either 1 or 2 randomly. randomizedSet.remove(1); // Removes 1 from the set, returns true. Set now contains [2]. randomizedSet.insert(2); // 2 was already in the set, so return false. -randomizedSet.getRandom(); // Since 2 is the only number in the set, getRandom always return 2. +randomizedSet.getRandom(); // Since 2 is the only number in the set, getRandom() will always return 2.

     

    @@ -47,8 +47,8 @@ randomizedSet.getRandom(); // Since 2 is the only number in the set, getRandom a
    • -231 <= val <= 231 - 1
    • -
    • At most 105 calls will be made to insertremove, and getRandom.
    • -
    • There will be at least one element in the data structure when getRandom is called.
    • +
    • At most 105 calls will be made to insert, remove, and getRandom.
    • +
    • There will be at least one element in the data structure when getRandom is called.
    ### Related Topics diff --git a/problems/insert-interval/README.md b/problems/insert-interval/README.md index 55aa7affc..5aaeafc03 100644 --- a/problems/insert-interval/README.md +++ b/problems/insert-interval/README.md @@ -15,6 +15,7 @@

    You may assume that the intervals were initially sorted according to their start times.

    +

     

    Example 1:

    @@ -25,11 +26,42 @@
     

    Example 2:

    -Input: intervals = [[1,2],[3,5],[6,7],[8,10],[12,16]], newInterval = [4,8]
    +Input: intervals = [[1,2],[3,5],[6,7],[8,10],[12,16]], newInterval = [4,8]
     Output: [[1,2],[3,10],[12,16]]
     Explanation: Because the new interval [4,8] overlaps with [3,5],[6,7],[8,10].
    -

    NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

    +

    Example 3:

    + +
    +Input: intervals = [], newInterval = [5,7]
    +Output: [[5,7]]
    +
    + +

    Example 4:

    + +
    +Input: intervals = [[1,5]], newInterval = [2,3]
    +Output: [[1,5]]
    +
    + +

    Example 5:

    + +
    +Input: intervals = [[1,5]], newInterval = [2,7]
    +Output: [[1,7]]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= intervals.length <= 104
    • +
    • intervals[i].length == 2
    • +
    • 0 <= intervals[i][0] <= intervals[i][1] <= 105
    • +
    • intervals is sorted by intervals[i][0] in ascending order.
    • +
    • newInterval.length == 2
    • +
    • 0 <= newInterval[0] <= newInterval[1] <= 105
    • +
    ### Related Topics [[Sort](../../tag/sort/README.md)] diff --git a/problems/last-person-to-fit-in-the-elevator/README.md b/problems/last-person-to-fit-in-the-elevator/README.md index 0d8f8558c..0969890cc 100644 --- a/problems/last-person-to-fit-in-the-elevator/README.md +++ b/problems/last-person-to-fit-in-the-elevator/README.md @@ -11,51 +11,4 @@ ## [1204. Last Person to Fit in the Elevator (Medium)](https://leetcode.com/problems/last-person-to-fit-in-the-elevator "最后一个能进入电梯的人") -

    Table: Queue

    -
    -+-------------+---------+
    -| Column Name | Type    |
    -+-------------+---------+
    -| person_id   | int     |
    -| person_name | varchar |
    -| weight      | int     |
    -| turn        | int     |
    -+-------------+---------+
    -person_id is the primary key column for this table.
    -This table has the information about all people waiting for an elevator.
    -The person_id and turn columns will contain all numbers from 1 to n, where n is the number of rows in the table.
    -
    - -

     

    - -

    The maximum weight the elevator can hold is 1000.

    - -

    Write an SQL query to find the person_name of the last person who will fit in the elevator without exceeding the weight limit. It is guaranteed that the person who is first in the queue can fit in the elevator.

    - -

    The query result format is in the following example:

    - -
    -Queue table
    -+-----------+-------------------+--------+------+
    -| person_id | person_name       | weight | turn |
    -+-----------+-------------------+--------+------+
    -| 5         | George Washington | 250    | 1    |
    -| 3         | John Adams        | 350    | 2    |
    -| 6         | Thomas Jefferson  | 400    | 3    |
    -| 2         | Will Johnliams    | 200    | 4    |
    -| 4         | Thomas Jefferson  | 175    | 5    |
    -| 1         | James Elephant    | 500    | 6    |
    -+-----------+-------------------+--------+------+
    -
    -Result table
    -+-------------------+
    -| person_name       |
    -+-------------------+
    -| Thomas Jefferson  |
    -+-------------------+
    -
    -Queue table is ordered by turn in the example for simplicity.
    -In the example George Washington(id 5), John Adams(id 3) and Thomas Jefferson(id 6) will enter the elevator as their weight sum is 250 + 350 + 400 = 1000.
    -Thomas Jefferson(id 6) is the last person to fit in the elevator because he has the last turn in these three people.
    -
    diff --git a/problems/lru-cache/README.md b/problems/lru-cache/README.md index af8dfcdf8..f655e4c09 100644 --- a/problems/lru-cache/README.md +++ b/problems/lru-cache/README.md @@ -11,15 +11,18 @@ ## [146. LRU Cache (Medium)](https://leetcode.com/problems/lru-cache "LRU缓存机制") -

    Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put.

    +

    Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.

    -

    get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.
    -put(key, value) - Set or insert the value if the key is not already present. When the cache reached its capacity, it should invalidate the least recently used item before inserting a new item.

    +

    Implement the LRUCache class:

    -

    The cache is initialized with a positive capacity.

    +
      +
    • LRUCache(int capacity) Initialize the LRU cache with positive size capacity.
    • +
    • int get(int key) Return the value of the key if the key exists, otherwise return -1.
    • +
    • void put(int key, int value) Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used key.
    • +

    Follow up:
    -Could you do both operations in O(1) time complexity?

    +Could you do get and put in O(1) time complexity?

     

    Example 1:

    @@ -33,12 +36,12 @@ Could you do both operations in O(1) time complexity?

    Explanation LRUCache lRUCache = new LRUCache(2); -lRUCache.put(1, 1); -lRUCache.put(2, 2); +lRUCache.put(1, 1); // cache is {1=1} +lRUCache.put(2, 2); // cache is {1=1, 2=2} lRUCache.get(1); // return 1 -lRUCache.put(3, 3); // evicts key 2 +lRUCache.put(3, 3); // LRU key was 2, evicts key 2, cache is {1=1, 3=3} lRUCache.get(2); // returns -1 (not found) -lRUCache.put(4, 4); // evicts key 1 +lRUCache.put(4, 4); // LRU key was 1, evicts key 1, cache is {4=4, 3=3} lRUCache.get(1); // return -1 (not found) lRUCache.get(3); // return 3 lRUCache.get(4); // return 4 diff --git a/problems/make-sum-divisible-by-p/README.md b/problems/make-sum-divisible-by-p/README.md new file mode 100644 index 000000000..74befbe25 --- /dev/null +++ b/problems/make-sum-divisible-by-p/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../maximum-sum-obtained-of-any-permutation "Maximum Sum Obtained of Any Permutation") +                 +[Next >](../strange-printer-ii "Strange Printer II") + +## [1590. Make Sum Divisible by P (Medium)](https://leetcode.com/problems/make-sum-divisible-by-p "使数组和能被 P 整除") + +

    Given an array of positive integers nums, remove the smallest subarray (possibly empty) such that the sum of the remaining elements is divisible by p. It is not allowed to remove the whole array.

    + +

    Return the length of the smallest subarray that you need to remove, or -1 if it's impossible.

    + +

    A subarray is defined as a contiguous block of elements in the array.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [3,1,4,2], p = 6
    +Output: 1
    +Explanation: The sum of the elements in nums is 10, which is not divisible by 6. We can remove the subarray [4], and the sum of the remaining elements is 6, which is divisible by 6.
    +
    + +

    Example 2:

    + +
    +Input: nums = [6,3,5,2], p = 9
    +Output: 2
    +Explanation: We cannot remove a single element to get a sum divisible by 9. The best way is to remove the subarray [5,2], leaving us with [6,3] with sum 9.
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,2,3], p = 3
    +Output: 0
    +Explanation: Here the sum is 6. which is already divisible by 3. Thus we do not need to remove anything.
    +
    + +

    Example 4:

    + +
    +Input: nums = [1,2,3], p = 7
    +Output: -1
    +Explanation: There is no way to remove a subarray in order to get a sum divisible by 7.
    +
    + +

    Example 5:

    + +
    +Input: nums = [1000000000,1000000000,1000000000], p = 3
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 109
    • +
    • 1 <= p <= 109
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Use prefix sums to calculate the subarray sums. +
    + +
    +Hint 2 +Suppose you know the remainder for the sum of the entire array. How does removing a subarray affect that remainder? What remainder does the subarray need to have in order to make the rest of the array sum up to be divisible by k? +
    + +
    +Hint 3 +Use a map to keep track of the rightmost index for every prefix sum % p. +
    diff --git a/problems/maximal-rectangle/README.md b/problems/maximal-rectangle/README.md index 74cafe69a..dbcec2b6a 100644 --- a/problems/maximal-rectangle/README.md +++ b/problems/maximal-rectangle/README.md @@ -11,21 +11,55 @@ ## [85. Maximal Rectangle (Hard)](https://leetcode.com/problems/maximal-rectangle "最大矩形") -

    Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.

    - -

    Example:

    +

    Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.

    +

     

    +

    Example 1:

    +
    -Input:
    -[
    -  ["1","0","1","0","0"],
    -  ["1","0","1","1","1"],
    -  ["1","1","1","1","1"],
    -  ["1","0","0","1","0"]
    -]
    +Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]
     Output: 6
    +Explanation: The maximal rectangle is shown in the above picture.
    +
    + +

    Example 2:

    + +
    +Input: matrix = []
    +Output: 0
     
    +

    Example 3:

    + +
    +Input: matrix = [["0"]]
    +Output: 0
    +
    + +

    Example 4:

    + +
    +Input: matrix = [["1"]]
    +Output: 1
    +
    + +

    Example 5:

    + +
    +Input: matrix = [["0","0"]]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • rows == matrix.length
    • +
    • cols == matrix.length
    • +
    • 0 <= row, cols <= 200
    • +
    • matrix[i][j] is '0' or '1'.
    • +
    + ### Related Topics [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] diff --git a/problems/maximum-non-negative-product-in-a-matrix/README.md b/problems/maximum-non-negative-product-in-a-matrix/README.md new file mode 100644 index 000000000..000ec041a --- /dev/null +++ b/problems/maximum-non-negative-product-in-a-matrix/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../split-a-string-into-the-max-number-of-unique-substrings "Split a String Into the Max Number of Unique Substrings") +                 +[Next >](../minimum-cost-to-connect-two-groups-of-points "Minimum Cost to Connect Two Groups of Points") + +## [1594. Maximum Non Negative Product in a Matrix (Medium)](https://leetcode.com/problems/maximum-non-negative-product-in-a-matrix "矩阵的最大非负积") + +

    You are given a rows x cols matrix grid. Initially, you are located at the top-left corner (0, 0), and in each step, you can only move right or down in the matrix.

    + +

    Among all possible paths starting from the top-left corner (0, 0) and ending in the bottom-right corner (rows - 1, cols - 1), find the path with the maximum non-negative product. The product of a path is the product of all integers in the grid cells visited along the path.

    + +

    Return the maximum non-negative product modulo 109 + 7If the maximum product is negative return -1.

    + +

    Notice that the modulo is performed after getting the maximum product.

    + +

     

    +

    Example 1:

    + +
    +Input: grid = [[-1,-2,-3],
    +               [-2,-3,-3],
    +               [-3,-3,-2]]
    +Output: -1
    +Explanation: It's not possible to get non-negative product in the path from (0, 0) to (2, 2), so return -1.
    +
    + +

    Example 2:

    + +
    +Input: grid = [[1,-2,1],
    +               [1,-2,1],
    +               [3,-4,1]]
    +Output: 8
    +Explanation: Maximum non-negative product is in bold (1 * 1 * -2 * -4 * 1 = 8).
    +
    + +

    Example 3:

    + +
    +Input: grid = [[1, 3],
    +               [0,-4]]
    +Output: 0
    +Explanation: Maximum non-negative product is in bold (1 * 0 * -4 = 0).
    +
    + +

    Example 4:

    + +
    +Input: grid = [[ 1, 4,4,0],
    +               [-2, 0,0,1],
    +               [ 1,-1,1,1]]
    +Output: 2
    +Explanation: Maximum non-negative product is in bold (1 * -2 * 1 * -1 * 1 * 1 = 2).
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= rows, cols <= 15
    • +
    • -4 <= grid[i][j] <= 4
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Use Dynamic programming. Keep the highest value and lowest value you can achieve up to a point. +
    diff --git a/problems/maximum-number-of-events-that-can-be-attended/README.md b/problems/maximum-number-of-events-that-can-be-attended/README.md index abbb0b36a..afabbfcba 100644 --- a/problems/maximum-number-of-events-that-can-be-attended/README.md +++ b/problems/maximum-number-of-events-that-can-be-attended/README.md @@ -62,9 +62,9 @@ Attend the third event on day 3.

    Constraints:

      -
    • 1 <= events.length <= 10^5
    • +
    • 1 <= events.length <= 105
    • events[i].length == 2
    • -
    • 1 <= events[i][0] <= events[i][1] <= 10^5
    • +
    • 1 <= startDayi <= endDayi <= 105
    ### Related Topics diff --git a/problems/maximum-sum-obtained-of-any-permutation/README.md b/problems/maximum-sum-obtained-of-any-permutation/README.md new file mode 100644 index 000000000..1aff347b1 --- /dev/null +++ b/problems/maximum-sum-obtained-of-any-permutation/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../sum-of-all-odd-length-subarrays "Sum of All Odd Length Subarrays") +                 +[Next >](../make-sum-divisible-by-p "Make Sum Divisible by P") + +## [1589. Maximum Sum Obtained of Any Permutation (Medium)](https://leetcode.com/problems/maximum-sum-obtained-of-any-permutation "所有排列中的最大和") + +

    We have an array of integers, nums, and an array of requests where requests[i] = [starti, endi]. The ith request asks for the sum of nums[starti] + nums[starti + 1] + ... + nums[endi - 1] + nums[endi]. Both starti and endi are 0-indexed.

    + +

    Return the maximum total sum of all requests among all permutations of nums.

    + +

    Since the answer may be too large, return it modulo 109 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3,4,5], requests = [[1,3],[0,1]]
    +Output: 19
    +Explanation: One permutation of nums is [2,1,3,4,5] with the following result: 
    +requests[0] -> nums[1] + nums[2] + nums[3] = 1 + 3 + 4 = 8
    +requests[1] -> nums[0] + nums[1] = 2 + 1 = 3
    +Total sum: 8 + 3 = 11.
    +A permutation with a higher total sum is [3,5,4,2,1] with the following result:
    +requests[0] -> nums[1] + nums[2] + nums[3] = 5 + 4 + 2 = 11
    +requests[1] -> nums[0] + nums[1] = 3 + 5  = 8
    +Total sum: 11 + 8 = 19, which is the best that you can do.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,2,3,4,5,6], requests = [[0,1]]
    +Output: 11
    +Explanation: A permutation with the max total sum is [6,5,4,3,2,1] with request sums [11].
    + +

    Example 3:

    + +
    +Input: nums = [1,2,3,4,5,10], requests = [[0,2],[1,3],[1,1]]
    +Output: 47
    +Explanation: A permutation with the max total sum is [4,10,5,3,2,1] with request sums [19,18,10].
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= n <= 105
    • +
    • 0 <= nums[i] <= 105
    • +
    • 1 <= requests.length <= 105
    • +
    • requests[i].length == 2
    • +
    • 0 <= starti <= endi < n
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Indexes with higher frequencies should be bound with larger values +
    diff --git a/problems/maximum-xor-of-two-numbers-in-an-array/README.md b/problems/maximum-xor-of-two-numbers-in-an-array/README.md index f7b9891d7..fccd0eb82 100644 --- a/problems/maximum-xor-of-two-numbers-in-an-array/README.md +++ b/problems/maximum-xor-of-two-numbers-in-an-array/README.md @@ -11,23 +11,53 @@ ## [421. Maximum XOR of Two Numbers in an Array (Medium)](https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array "数组中两个数的最大异或值") -

    Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231.

    +

    Given an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 ≤ i ≤ j < n.

    -

    Find the maximum result of ai XOR aj, where 0 ≤ i, j < n.

    +

    Follow up: Could you do this in O(n) runtime?

    -

    Could you do this in O(n) runtime?

    +

     

    +

    Example 1:

    + +
    +Input: nums = [3,10,5,25,2,8]
    +Output: 28
    +Explanation: The maximum result is 5 XOR 25 = 28.
    + +

    Example 2:

    + +
    +Input: nums = [0]
    +Output: 0
    +
    -

    Example:

    +

    Example 3:

    -Input: [3, 10, 5, 25, 2, 8]
    +Input: nums = [2,4]
    +Output: 6
    +
    -Output: 28 +

    Example 4:

    -Explanation: The maximum result is 5 ^ 25 = 28. +
    +Input: nums = [8,10,2]
    +Output: 10
    +
    + +

    Example 5:

    + +
    +Input: nums = [14,70,53,83,49,91,36,80,92,51,66,70]
    +Output: 127
     

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 2 * 104
    • +
    • 0 <= nums[i] <= 231 - 1
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/minimum-cost-to-connect-two-groups-of-points/README.md b/problems/minimum-cost-to-connect-two-groups-of-points/README.md new file mode 100644 index 000000000..16f17bbef --- /dev/null +++ b/problems/minimum-cost-to-connect-two-groups-of-points/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../maximum-non-negative-product-in-a-matrix "Maximum Non Negative Product in a Matrix") +                 +Next > + +## [1595. Minimum Cost to Connect Two Groups of Points (Hard)](https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points "连通两组点的最小成本") + +

    You are given two groups of points where the first group has size1 points, the second group has size2 points, and size1 >= size2.

    + +

    The cost of the connection between any two points are given in an size1 x size2 matrix where cost[i][j] is the cost of connecting point i of the first group and point j of the second group. The groups are connected if each point in both groups is connected to one or more points in the opposite group. In other words, each point in the first group must be connected to at least one point in the second group, and each point in the second group must be connected to at least one point in the first group.

    + +

    Return the minimum cost it takes to connect the two groups.

    + +

     

    +

    Example 1:

    + +
    +Input: cost = [[15, 96], [36, 2]]
    +Output: 17
    +Explanation: The optimal way of connecting the groups is:
    +1--A
    +2--B
    +This results in a total cost of 17.
    +
    + +

    Example 2:

    + +
    +Input: cost = [[1, 3, 5], [4, 1, 1], [1, 5, 3]]
    +Output: 4
    +Explanation: The optimal way of connecting the groups is:
    +1--A
    +2--B
    +2--C
    +3--A
    +This results in a total cost of 4.
    +Note that there are multiple points connected to point 2 in the first group and point A in the second group. This does not matter as there is no limit to the number of points that can be connected. We only care about the minimum total cost.
    +
    + +

    Example 3:

    + +
    +Input: cost = [[2, 5, 1], [3, 4, 7], [8, 1, 2], [6, 2, 4], [3, 8, 8]]
    +Output: 10
    +
    + +

     

    +

    Constraints:

    + +
      +
    • size1 == cost.length
    • +
    • size2 == cost[i].length
    • +
    • 1 <= size1, size2 <= 12
    • +
    • size1 >= size2
    • +
    • 0 <= cost[i][j] <= 100
    • +
    + +### Related Topics + [[Graph](../../tag/graph/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Each point on the left would either be connected to exactly point already connected to some left node, or a subset of the nodes on the right which are not connected to any node +
    + +
    +Hint 2 +Use dynamic programming with bitmasking, where the state will be (number of points assigned in first group, bitmask of points assigned in second group). +
    diff --git a/problems/next-permutation/README.md b/problems/next-permutation/README.md index f56c5cab4..10a599c5a 100644 --- a/problems/next-permutation/README.md +++ b/problems/next-permutation/README.md @@ -29,5 +29,5 @@ ### Similar Questions 1. [Permutations](../permutations) (Medium) 1. [Permutations II](../permutations-ii) (Medium) - 1. [Permutation Sequence](../permutation-sequence) (Medium) + 1. [Permutation Sequence](../permutation-sequence) (Hard) 1. [Palindrome Permutation II](../palindrome-permutation-ii) (Medium) diff --git a/problems/permutation-sequence/README.md b/problems/permutation-sequence/README.md index 4f57d9204..16251d4d3 100644 --- a/problems/permutation-sequence/README.md +++ b/problems/permutation-sequence/README.md @@ -9,7 +9,7 @@                  [Next >](../rotate-list "Rotate List") -## [60. Permutation Sequence (Medium)](https://leetcode.com/problems/permutation-sequence "第k个排列") +## [60. Permutation Sequence (Hard)](https://leetcode.com/problems/permutation-sequence "第k个排列")

    The set [1,2,3,...,n] contains a total of n! unique permutations.

    diff --git a/problems/permutations/README.md b/problems/permutations/README.md index 68fceb164..c23ce2de3 100644 --- a/problems/permutations/README.md +++ b/problems/permutations/README.md @@ -34,5 +34,5 @@ ### Similar Questions 1. [Next Permutation](../next-permutation) (Medium) 1. [Permutations II](../permutations-ii) (Medium) - 1. [Permutation Sequence](../permutation-sequence) (Medium) + 1. [Permutation Sequence](../permutation-sequence) (Hard) 1. [Combinations](../combinations) (Medium) diff --git a/problems/rearrange-spaces-between-words/README.md b/problems/rearrange-spaces-between-words/README.md new file mode 100644 index 000000000..7705a8c6b --- /dev/null +++ b/problems/rearrange-spaces-between-words/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../strange-printer-ii "Strange Printer II") +                 +[Next >](../split-a-string-into-the-max-number-of-unique-substrings "Split a String Into the Max Number of Unique Substrings") + +## [1592. Rearrange Spaces Between Words (Easy)](https://leetcode.com/problems/rearrange-spaces-between-words "重新排列单词间的空格") + +

    You are given a string text of words that are placed among some number of spaces. Each word consists of one or more lowercase English letters and are separated by at least one space. It's guaranteed that text contains at least one word.

    + +

    Rearrange the spaces so that there is an equal number of spaces between every pair of adjacent words and that number is maximized. If you cannot redistribute all the spaces equally, place the extra spaces at the end, meaning the returned string should be the same length as text.

    + +

    Return the string after rearranging the spaces.

    + +

     

    +

    Example 1:

    + +
    +Input: text = "  this   is  a sentence "
    +Output: "this   is   a   sentence"
    +Explanation: There are a total of 9 spaces and 4 words. We can evenly divide the 9 spaces between the words: 9 / (4-1) = 3 spaces.
    +
    + +

    Example 2:

    + +
    +Input: text = " practice   makes   perfect"
    +Output: "practice   makes   perfect "
    +Explanation: There are a total of 7 spaces and 3 words. 7 / (3-1) = 3 spaces plus 1 extra space. We place this extra space at the end of the string.
    +
    + +

    Example 3:

    + +
    +Input: text = "hello   world"
    +Output: "hello   world"
    +
    + +

    Example 4:

    + +
    +Input: text = "  walks  udp package   into  bar a"
    +Output: "walks  udp  package  into  bar  a "
    +
    + +

    Example 5:

    + +
    +Input: text = "a"
    +Output: "a"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= text.length <= 100
    • +
    • text consists of lowercase English letters and ' '.
    • +
    • text contains at least one word.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Count the total number of spaces and words. Then use the integer division to determine the numbers of spaces to add between each word and at the end. +
    diff --git a/problems/scramble-string/README.md b/problems/scramble-string/README.md index 3685dc7d7..0c661df9b 100644 --- a/problems/scramble-string/README.md +++ b/problems/scramble-string/README.md @@ -17,8 +17,8 @@
  • If the length of the string is 1, stop.
  • If the length of the string is > 1, do the following:
      -
    • Split the string into 2 non-empty substrings at a random index, i.e. if the string is s, divide it to x and y where s = x + y.
    • -
    • Randomly, decide to swap the two substrings or to keep them in the same order. i.e. after this step, s may become s = x + y or s = y + x.
    • +
    • Split the string into two non-empty substrings at a random index, i.e., if the string is s, divide it to x and y where s = x + y.
    • +
    • Randomly decide to swap the two substrings or to keep them in the same order. i.e., after this step, s may become s = x + y or s = y + x.
    • Apply step 1 recursively on each of the two substrings x and y.
  • @@ -35,10 +35,10 @@ Explanation: One possible scenario applied on s1 is: "great" --> "gr/eat" // divide at random index. "gr/eat" --> "gr/eat" // random decision is not to swap the two substrings and keep them in order. -"gr/eat" --> "g/r / e/at" // apply the same algorith recursively on both substrings. divide at ranom index each of them. -"g/r / e/at" --> "r/g / e/at" // random decision was to swap the first substing and to keep the second substring in the same order. +"gr/eat" --> "g/r / e/at" // apply the same algorithm recursively on both substrings. divide at ranom index each of them. +"g/r / e/at" --> "r/g / e/at" // random decision was to swap the first substring and to keep the second substring in the same order. "r/g / e/at" --> "r/g / e/ a/t" // again apply the algorithm recursively, divide "at" to "a/t". -"r/g / e/ a/t" --> "r/g / e/ a/t" // random decision is to keep both substings in the same order. +"r/g / e/ a/t" --> "r/g / e/ a/t" // random decision is to keep both substrings in the same order. The algorithm stops now and the result string is "rgeat" which is s2. As there is one possible scenario that led s1 to be scrambled to s2, we return true.
    diff --git a/problems/serialize-and-deserialize-binary-tree/README.md b/problems/serialize-and-deserialize-binary-tree/README.md index 8a9db3e25..ad5e175a0 100644 --- a/problems/serialize-and-deserialize-binary-tree/README.md +++ b/problems/serialize-and-deserialize-binary-tree/README.md @@ -15,23 +15,44 @@

    Design an algorithm to serialize and deserialize a binary tree. There is no restriction on how your serialization/deserialization algorithm should work. You just need to ensure that a binary tree can be serialized to a string and this string can be deserialized to the original tree structure.

    -

    Example: 

    +

    Clarification: The input/output format is the same as how LeetCode serializes a binary tree. You do not necessarily need to follow this format, so please be creative and come up with different approaches yourself.

    +

     

    +

    Example 1:

    +
    -You may serialize the following tree:
    +Input: root = [1,2,3,null,null,4,5]
    +Output: [1,2,3,null,null,4,5]
    +
    + +

    Example 2:

    + +
    +Input: root = []
    +Output: []
    +
    - 1 - / \ - 2 3 - / \ - 4 5 +

    Example 3:

    -as "[1,2,3,null,null,4,5]" +
    +Input: root = [1]
    +Output: [1]
    +
    + +

    Example 4:

    + +
    +Input: root = [1,2]
    +Output: [1,2]
     
    -

    Clarification: The above format is the same as how LeetCode serializes a binary tree. You do not necessarily need to follow this format, so please be creative and come up with different approaches yourself.

    +

     

    +

    Constraints:

    -

    Note: Do not use class member/global/static variables to store states. Your serialize and deserialize algorithms should be stateless.

    +
      +
    • The number of nodes in the tree is in the range [0, 104].
    • +
    • -1000 <= Node.val <= 1000
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/sliding-window-maximum/README.md b/problems/sliding-window-maximum/README.md index 144dad840..e454d6621 100644 --- a/problems/sliding-window-maximum/README.md +++ b/problems/sliding-window-maximum/README.md @@ -11,18 +11,17 @@ ## [239. Sliding Window Maximum (Hard)](https://leetcode.com/problems/sliding-window-maximum "滑动窗口最大值") -

    Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the max sliding window.

    +

    You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position.

    -

    Follow up:
    -Could you solve it in linear time?

    +

    Return the max sliding window.

    -

    Example:

    +

     

    +

    Example 1:

    -Input: nums = [1,3,-1,-3,5,3,6,7], and k = 3
    -Output: [3,3,5,5,6,7] 
    -Explanation: 
    -
    +Input: nums = [1,3,-1,-3,5,3,6,7], k = 3
    +Output: [3,3,5,5,6,7]
    +Explanation: 
     Window position                Max
     ---------------               -----
     [1  3  -1] -3  5  3  6  7       3
    @@ -33,13 +32,41 @@ Window position                Max
      1  3  -1  -3  5 [3  6  7]      7
     
    +

    Example 2:

    + +
    +Input: nums = [1], k = 1
    +Output: [1]
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,-1], k = 1
    +Output: [1,-1]
    +
    + +

    Example 4:

    + +
    +Input: nums = [9,11], k = 2
    +Output: [11]
    +
    + +

    Example 5:

    + +
    +Input: nums = [4,-2], k = 2
    +Output: [4]
    +
    +

     

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • -10^4 <= nums[i] <= 10^4
    • -
    • 1 <= k <= nums.length
    • +
    • 1 <= nums.length <= 105
    • +
    • -104 <= nums[i] <= 104
    • +
    • 1 <= k <= nums.length
    ### Related Topics diff --git a/problems/sort-list/README.md b/problems/sort-list/README.md index 9b662c369..799e978b5 100644 --- a/problems/sort-list/README.md +++ b/problems/sort-list/README.md @@ -11,20 +11,39 @@ ## [148. Sort List (Medium)](https://leetcode.com/problems/sort-list "排序链表") -

    Sort a linked list in O(n log n) time using constant space complexity.

    +

    Given the head of a linked list, return the list after sorting it in ascending order.

    -

    Example 1:

    +

    Follow up: Can you sort the linked list in O(n logn) time and O(1) memory (i.e. constant space)?

    +

     

    +

    Example 1:

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

    Example 2:

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

    Example 3:

    -Input: -1->5->3->4->0
    -Output: -1->0->3->4->5
    +Input: head = [] +Output: [] + + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is in the range [0, 5 * 104].
    • +
    • -105 <= Node.val <= 105
    • +
    ### Related Topics [[Sort](../../tag/sort/README.md)] diff --git a/problems/spiral-matrix/README.md b/problems/spiral-matrix/README.md index 428ad14cb..4755b96ab 100644 --- a/problems/spiral-matrix/README.md +++ b/problems/spiral-matrix/README.md @@ -26,6 +26,7 @@

    Example 2:

    +
     Input:
     [
    diff --git a/problems/split-a-string-into-the-max-number-of-unique-substrings/README.md b/problems/split-a-string-into-the-max-number-of-unique-substrings/README.md
    new file mode 100644
    index 000000000..f95a420d7
    --- /dev/null
    +++ b/problems/split-a-string-into-the-max-number-of-unique-substrings/README.md
    @@ -0,0 +1,69 @@
    +
    +
    +
    +
    +
    +
    +
    +[< Previous](../rearrange-spaces-between-words "Rearrange Spaces Between Words")
    +                
    +[Next >](../maximum-non-negative-product-in-a-matrix "Maximum Non Negative Product in a Matrix")
    +
    +## [1593. Split a String Into the Max Number of Unique Substrings (Medium)](https://leetcode.com/problems/split-a-string-into-the-max-number-of-unique-substrings "拆分字符串使唯一子字符串的数目最大")
    +
    +

    Given a string s, return the maximum number of unique substrings that the given string can be split into.

    + +

    You can split string s into any list of non-empty substrings, where the concatenation of the substrings forms the original string. However, you must split the substrings such that all of them are unique.

    + +

    A substring is a contiguous sequence of characters within a string.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "ababccc"
    +Output: 5
    +Explanation: One way to split maximally is ['a', 'b', 'ab', 'c', 'cc']. Splitting like ['a', 'b', 'a', 'b', 'c', 'cc'] is not valid as you have 'a' and 'b' multiple times.
    +
    + +

    Example 2:

    + +
    +Input: s = "aba"
    +Output: 2
    +Explanation: One way to split maximally is ['a', 'ba'].
    +
    + +

    Example 3:

    + +
    +Input: s = "aa"
    +Output: 1
    +Explanation: It is impossible to split the string any further.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • +

      1 <= s.length <= 16

      +
    • +
    • +

      s contains only lower case English letters.

      +
    • +
    + +### Related Topics + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
    +Hint 1 +Use a set to keep track of which substrings have been used already +
    + +
    +Hint 2 +Try each possible substring at every position and backtrack if a complete split is not possible +
    diff --git a/problems/strange-printer-ii/README.md b/problems/strange-printer-ii/README.md new file mode 100644 index 000000000..6327fb0b5 --- /dev/null +++ b/problems/strange-printer-ii/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../make-sum-divisible-by-p "Make Sum Divisible by P") +                 +[Next >](../rearrange-spaces-between-words "Rearrange Spaces Between Words") + +## [1591. Strange Printer II (Hard)](https://leetcode.com/problems/strange-printer-ii "奇怪的打印机 II") + +

    There is a strange printer with the following two special requirements:

    + +
      +
    • On each turn, the printer will print a solid rectangular pattern of a single color on the grid. This will cover up the existing colors in the rectangle.
    • +
    • Once the printer has used a color for the above operation, the same color cannot be used again.
    • +
    + +

    You are given a m x n matrix targetGrid, where targetGrid[row][col] is the color in the position (row, col) of the grid.

    + +

    Return true if it is possible to print the matrix targetGrid, otherwise, return false.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: targetGrid = [[1,1,1,1],[1,2,2,1],[1,2,2,1],[1,1,1,1]]
    +Output: true
    +
    + +

    Example 2:

    + +

    + +
    +Input: targetGrid = [[1,1,1,1],[1,1,3,3],[1,1,3,4],[5,5,1,4]]
    +Output: true
    +
    + +

    Example 3:

    + +
    +Input: targetGrid = [[1,2,1],[2,1,2],[1,2,1]]
    +Output: false
    +Explanation: It is impossible to form targetGrid because it is not allowed to print the same color in different turns.
    + +

    Example 4:

    + +
    +Input: targetGrid = [[1,1,1],[3,1,3]]
    +Output: false
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == targetGrid.length
    • +
    • n == targetGrid[i].length
    • +
    • 1 <= m, n <= 60
    • +
    • 1 <= targetGrid[row][col] <= 60
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Try thinking in reverse. Given the grid, how can you tell if a colour was painted last? +
    diff --git a/problems/sum-of-all-odd-length-subarrays/README.md b/problems/sum-of-all-odd-length-subarrays/README.md new file mode 100644 index 000000000..b69281e2d --- /dev/null +++ b/problems/sum-of-all-odd-length-subarrays/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../bank-account-summary-ii "Bank Account Summary II") +                 +[Next >](../maximum-sum-obtained-of-any-permutation "Maximum Sum Obtained of Any Permutation") + +## [1588. Sum of All Odd Length Subarrays (Easy)](https://leetcode.com/problems/sum-of-all-odd-length-subarrays "所有奇数长度子数组的和") + +

    Given an array of positive integers arr, calculate the sum of all possible odd-length subarrays.

    + +

    A subarray is a contiguous subsequence of the array.

    + +

    Return the sum of all odd-length subarrays of arr.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [1,4,2,5,3]
    +Output: 58
    +Explanation: The odd-length subarrays of arr and their sums are:
    +[1] = 1
    +[4] = 4
    +[2] = 2
    +[5] = 5
    +[3] = 3
    +[1,4,2] = 7
    +[4,2,5] = 11
    +[2,5,3] = 10
    +[1,4,2,5,3] = 15
    +If we add all these together we get 1 + 4 + 2 + 5 + 3 + 7 + 11 + 10 + 15 = 58
    + +

    Example 2:

    + +
    +Input: arr = [1,2]
    +Output: 3
    +Explanation: There are only 2 subarrays of odd length, [1] and [2]. Their sum is 3.
    + +

    Example 3:

    + +
    +Input: arr = [10,11,12]
    +Output: 66
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 100
    • +
    • 1 <= arr[i] <= 1000
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +You can brute force – try every (i,j) pair, and if the length is odd, go through and add the sum to the answer. +
    diff --git a/problems/unique-paths/README.md b/problems/unique-paths/README.md index 8f8017a78..c120d1906 100644 --- a/problems/unique-paths/README.md +++ b/problems/unique-paths/README.md @@ -11,41 +11,52 @@ ## [62. Unique Paths (Medium)](https://leetcode.com/problems/unique-paths "不同路径") -

    A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).

    +

    A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).

    The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).

    How many possible unique paths are there?

    -


    -Above is a 7 x 3 grid. How many possible unique paths are there?

    -

     

    Example 1:

    + +
    +Input: m = 3, n = 7
    +Output: 28
    +
    + +

    Example 2:

     Input: m = 3, n = 2
     Output: 3
     Explanation:
     From the top-left corner, there are a total of 3 ways to reach the bottom-right corner:
    -1. Right -> Right -> Down
    -2. Right -> Down -> Right
    -3. Down -> Right -> Right
    +1. Right -> Down -> Down
    +2. Down -> Down -> Right
    +3. Down -> Right -> Down
     
    -

    Example 2:

    +

    Example 3:

     Input: m = 7, n = 3
     Output: 28
     
    +

    Example 4:

    + +
    +Input: m = 3, n = 3
    +Output: 6
    +
    +

     

    Constraints:

    • 1 <= m, n <= 100
    • -
    • It's guaranteed that the answer will be less than or equal to 2 * 10 ^ 9.
    • +
    • It's guaranteed that the answer will be less than or equal to 2 * 109.
    ### Related Topics diff --git a/readme/1-300.md b/readme/1-300.md index 227a2ed97..1da5f9a93 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -126,7 +126,7 @@ LeetCode Problems' Solutions | 54 | [Spiral Matrix](https://leetcode.com/problems/spiral-matrix "螺旋矩阵") | [Go](../problems/spiral-matrix) | Medium | | 55 | [Jump Game](https://leetcode.com/problems/jump-game "跳跃游戏") | [Go](../problems/jump-game) | Medium | | 56 | [Merge Intervals](https://leetcode.com/problems/merge-intervals "合并区间") | [Go](../problems/merge-intervals) | Medium | -| 57 | [Insert Interval](https://leetcode.com/problems/insert-interval "插入区间") | [Go](../problems/insert-interval) | Hard | +| 57 | [Insert Interval](https://leetcode.com/problems/insert-interval "插入区间") | [Go](../problems/insert-interval) | Medium | | 58 | [Length of Last Word](https://leetcode.com/problems/length-of-last-word "最后一个单词的长度") | [Go](../problems/length-of-last-word) | Easy | | 59 | [Spiral Matrix II](https://leetcode.com/problems/spiral-matrix-ii "螺旋矩阵 II") | [Go](../problems/spiral-matrix-ii) | Medium | | 60 | [Permutation Sequence](https://leetcode.com/problems/permutation-sequence "第k个排列") | [Go](../problems/permutation-sequence) | Hard | diff --git a/tag/array/README.md b/tag/array/README.md index 6bfb60972..a17ea1971 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1588 | [所有奇数长度子数组的和](../../problems/sum-of-all-odd-length-subarrays) | [[数组](../array/README.md)] | Easy | | 1583 | [统计不开心的朋友](../../problems/count-unhappy-friends) | [[数组](../array/README.md)] | Medium | | 1582 | [二进制矩阵中的特殊位置](../../problems/special-positions-in-a-binary-matrix) | [[数组](../array/README.md)] | Easy | | 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index c09372b9d..061362c3a 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[回溯算法](../backtracking/README.md)] | Medium | | 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1415 | [长度为 n 的开心字符串中字典序第 k 小的字符串](../../problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | [[回溯算法](../backtracking/README.md)] | Medium | | 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | @@ -52,7 +53,7 @@ | 79 | [单词搜索](../../problems/word-search) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 77 | [组合](../../problems/combinations) | [[回溯算法](../backtracking/README.md)] | Medium | -| 60 | [第k个排列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 60 | [第k个排列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 52 | [N皇后 II](../../problems/n-queens-ii) | [[回溯算法](../backtracking/README.md)] | Hard | | 51 | [N 皇后](../../problems/n-queens) | [[回溯算法](../backtracking/README.md)] | Hard | | 47 | [全排列 II](../../problems/permutations-ii) | [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index e858cedf9..5742a81f5 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1562 | [查找大小为 M 的最新分组](../../problems/find-latest-group-of-size-m) | [[二分查找](../binary-search/README.md)] | Medium | | 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index c32789fae..12a9d71b0 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1586 | [Binary Search Tree Iterator II](../../problems/binary-search-tree-iterator-ii) | [[设计](../design/README.md)] | Medium | | 1500 | [Design a File Sharing System](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[设计](../design/README.md)] | Medium | | 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index c337941a1..90defc1d5 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1563 | [石子游戏 V](../../problems/stone-game-v) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index 6d773775d..867d09068 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1557 | [可以到达所有点的最少点数目](../../problems/minimum-number-of-vertices-to-reach-all-nodes) | [[图](../graph/README.md)] | Medium | | 1548 | [The Most Similar Path in a Graph](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 849ba2cc4..d360f6dc9 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1591 | [奇怪的打印机 II](../../problems/strange-printer-ii) | [[贪心算法](../greedy/README.md)] | Hard | +| 1589 | [所有排列中的最大和](../../problems/maximum-sum-obtained-of-any-permutation) | [[贪心算法](../greedy/README.md)] | Medium | | 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | | 1580 | [Put Boxes Into the Warehouse II](../../problems/put-boxes-into-the-warehouse-ii) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | | 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心算法](../greedy/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 05ab008ff..56ec6b744 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -109,7 +109,7 @@ | 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 325 | [和等于 k 的最长子数组长度](../../problems/maximum-size-subarray-sum-equals-k) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | | 311 | [稀疏矩阵的乘法](../../problems/sparse-matrix-multiplication) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | -| 299 | [猜数字游戏](../../problems/bulls-and-cows) | [[哈希表](../hash-table/README.md)] | Easy | +| 299 | [猜数字游戏](../../problems/bulls-and-cows) | [[哈希表](../hash-table/README.md)] | Medium | | 290 | [单词规律](../../problems/word-pattern) | [[哈希表](../hash-table/README.md)] | Easy | | 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 274 | [H 指数](../../problems/h-index) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 3ffb8253d..9d2077687 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -184,7 +184,7 @@ | 69 | [x 的平方根](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 67 | [二进制求和](../../problems/add-binary) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 65 | [有效数字](../../problems/valid-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 60 | [第k个排列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 60 | [第k个排列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 50 | [Pow(x, n)](../../problems/powx-n) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 29 | [两数相除](../../problems/divide-two-integers) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index ea5bb60cd..76d8fd9dd 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1592 | [重新排列单词间的空格](../../problems/rearrange-spaces-between-words) | [[字符串](../string/README.md)] | Easy | | 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | | 1576 | [替换所有的问号](../../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | [[字符串](../string/README.md)] | Easy | | 1573 | [分割字符串的方案数](../../problems/number-of-ways-to-split-a-string) | [[字符串](../string/README.md)] | Medium | From 63649383ea40bf211e953bc52c619aa0a66d8dec Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 21 Sep 2020 09:27:47 +0800 Subject: [PATCH 100/145] A: new --- .../README.md | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/problems/last-person-to-fit-in-the-elevator/README.md b/problems/last-person-to-fit-in-the-elevator/README.md index 0969890cc..0d8f8558c 100644 --- a/problems/last-person-to-fit-in-the-elevator/README.md +++ b/problems/last-person-to-fit-in-the-elevator/README.md @@ -11,4 +11,51 @@ ## [1204. Last Person to Fit in the Elevator (Medium)](https://leetcode.com/problems/last-person-to-fit-in-the-elevator "最后一个能进入电梯的人") +

    Table: Queue

    +
    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| person_id   | int     |
    +| person_name | varchar |
    +| weight      | int     |
    +| turn        | int     |
    ++-------------+---------+
    +person_id is the primary key column for this table.
    +This table has the information about all people waiting for an elevator.
    +The person_id and turn columns will contain all numbers from 1 to n, where n is the number of rows in the table.
    +
    + +

     

    + +

    The maximum weight the elevator can hold is 1000.

    + +

    Write an SQL query to find the person_name of the last person who will fit in the elevator without exceeding the weight limit. It is guaranteed that the person who is first in the queue can fit in the elevator.

    + +

    The query result format is in the following example:

    + +
    +Queue table
    ++-----------+-------------------+--------+------+
    +| person_id | person_name       | weight | turn |
    ++-----------+-------------------+--------+------+
    +| 5         | George Washington | 250    | 1    |
    +| 3         | John Adams        | 350    | 2    |
    +| 6         | Thomas Jefferson  | 400    | 3    |
    +| 2         | Will Johnliams    | 200    | 4    |
    +| 4         | Thomas Jefferson  | 175    | 5    |
    +| 1         | James Elephant    | 500    | 6    |
    ++-----------+-------------------+--------+------+
    +
    +Result table
    ++-------------------+
    +| person_name       |
    ++-------------------+
    +| Thomas Jefferson  |
    ++-------------------+
    +
    +Queue table is ordered by turn in the example for simplicity.
    +In the example George Washington(id 5), John Adams(id 3) and Thomas Jefferson(id 6) will enter the elevator as their weight sum is 250 + 350 + 400 = 1000.
    +Thomas Jefferson(id 6) is the last person to fit in the elevator because he has the last turn in these three people.
    +
    From 177c833e084ff1d0926ae8cc450de60ad86bc9d1 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 28 Sep 2020 10:32:20 +0800 Subject: [PATCH 101/145] A: new --- README.md | 18 ++- .../adding-two-negabinary-numbers/README.md | 36 +++--- .../binary-search-tree-iterator-ii/README.md | 2 +- .../README.md | 54 +++++---- .../binary-tree-inorder-traversal/README.md | 10 +- .../binary-tree-postorder-traversal/README.md | 12 +- .../binary-tree-preorder-traversal/README.md | 59 ++++++++-- .../README.md | 29 +++++ problems/coin-change/README.md | 49 ++++++-- .../convert-bst-to-greater-tree/README.md | 59 +++++++--- .../count-number-of-nice-subarrays/README.md | 4 +- problems/count-primes/README.md | 28 ++++- problems/crawler-log-folder/README.md | 80 +++++++++++++ .../design-a-file-sharing-system/README.md | 2 +- problems/evaluate-division/README.md | 2 +- .../exclusive-time-of-functions/README.md | 37 ++++-- .../README.md | 2 +- .../README.md | 10 +- .../guess-number-higher-or-lower/README.md | 41 ++++--- .../README.md | 2 +- problems/house-robber-ii/README.md | 2 +- problems/house-robber/README.md | 2 +- problems/majority-element-ii/README.md | 30 ++++- .../README.md | 78 +++++++++++++ .../README.md | 2 +- .../README.md | 106 ++++++++++++++++++ .../README.md | 2 +- problems/number-of-recent-calls/README.md | 46 ++++---- problems/paint-fence/README.md | 2 +- problems/paint-house-ii/README.md | 2 +- problems/paint-house/README.md | 2 +- problems/palindrome-number/README.md | 2 +- problems/power-of-two/README.md | 40 +++++-- .../README.md | 4 +- problems/shortest-completing-word/README.md | 88 +++++++++------ .../README.md | 2 - problems/sum-of-square-numbers/README.md | 45 ++++++-- problems/super-pow/README.md | 38 ++++--- .../README.md | 14 +++ .../mysql_schemas.sql | 25 +++++ .../README.md | 2 +- problems/throne-inheritance/README.md | 101 +++++++++++++++++ problems/two-sum-iv-input-is-a-bst/README.md | 54 +++++---- problems/valid-perfect-square/README.md | 2 +- problems/warehouse-manager/README.md | 2 +- readme/1-300.md | 2 +- readme/301-600.md | 2 +- readme/601-900.md | 2 +- readme/901-1200.md | 2 +- tag/array/README.md | 2 +- tag/binary-search-tree/README.md | 2 +- tag/binary-search/README.md | 2 +- tag/design/README.md | 5 +- tag/dynamic-programming/README.md | 3 +- tag/greedy/README.md | 3 +- tag/math/README.md | 2 +- tag/stack/README.md | 1 + tag/string/README.md | 1 + tag/tree/README.md | 4 +- 59 files changed, 1002 insertions(+), 260 deletions(-) create mode 100644 problems/build-binary-expression-tree-from-infix-expression/README.md create mode 100644 problems/crawler-log-folder/README.md create mode 100644 problems/maximum-number-of-achievable-transfer-requests/README.md create mode 100644 problems/maximum-profit-of-operating-a-centennial-wheel/README.md create mode 100644 problems/the-most-frequently-ordered-products-for-each-customer/README.md create mode 100644 problems/the-most-frequently-ordered-products-for-each-customer/mysql_schemas.sql create mode 100644 problems/throne-inheritance/README.md diff --git a/README.md b/README.md index d50c1e7f1..a9f7ed68d 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,12 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1601 | [Maximum Number of Achievable Transfer Requests](https://leetcode.com/problems/maximum-number-of-achievable-transfer-requests "最多可达成的换楼请求数目") | [Go](problems/maximum-number-of-achievable-transfer-requests) | Hard | +| 1600 | [Throne Inheritance](https://leetcode.com/problems/throne-inheritance "皇位继承顺序") | [Go](problems/throne-inheritance) | Medium | +| 1599 | [Maximum Profit of Operating a Centennial Wheel](https://leetcode.com/problems/maximum-profit-of-operating-a-centennial-wheel "经营摩天轮的最大利润") | [Go](problems/maximum-profit-of-operating-a-centennial-wheel) | Medium | +| 1598 | [Crawler Log Folder](https://leetcode.com/problems/crawler-log-folder "文件夹操作日志搜集器") | [Go](problems/crawler-log-folder) | Easy | +| 1597 | [Build Binary Expression Tree From Infix Expression](https://leetcode.com/problems/build-binary-expression-tree-from-infix-expression) 🔒 | [Go](problems/build-binary-expression-tree-from-infix-expression) | Medium | +| 1596 | [The Most Frequently Ordered Products for Each Customer](https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer) 🔒 | [MySQL](problems/the-most-frequently-ordered-products-for-each-customer) | Medium | | 1595 | [Minimum Cost to Connect Two Groups of Points](https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points "连通两组点的最小成本") | [Go](problems/minimum-cost-to-connect-two-groups-of-points) | Hard | | 1594 | [Maximum Non Negative Product in a Matrix](https://leetcode.com/problems/maximum-non-negative-product-in-a-matrix "矩阵的最大非负积") | [Go](problems/maximum-non-negative-product-in-a-matrix) | Medium | | 1593 | [Split a String Into the Max Number of Unique Substrings](https://leetcode.com/problems/split-a-string-into-the-max-number-of-unique-substrings "拆分字符串使唯一子字符串的数目最大") | [Go](problems/split-a-string-into-the-max-number-of-unique-substrings) | Medium | @@ -79,7 +85,7 @@ LeetCode Problems' Solutions | 1589 | [Maximum Sum Obtained of Any Permutation](https://leetcode.com/problems/maximum-sum-obtained-of-any-permutation "所有排列中的最大和") | [Go](problems/maximum-sum-obtained-of-any-permutation) | Medium | | 1588 | [Sum of All Odd Length Subarrays](https://leetcode.com/problems/sum-of-all-odd-length-subarrays "所有奇数长度子数组的和") | [Go](problems/sum-of-all-odd-length-subarrays) | Easy | | 1587 | [Bank Account Summary II](https://leetcode.com/problems/bank-account-summary-ii) 🔒 | [MySQL](problems/bank-account-summary-ii) | Easy | -| 1586 | [Binary Search Tree Iterator II](https://leetcode.com/problems/binary-search-tree-iterator-ii) 🔒 | [Go](problems/binary-search-tree-iterator-ii) | Medium | +| 1586 | [Binary Search Tree Iterator II](https://leetcode.com/problems/binary-search-tree-iterator-ii "二叉搜索树迭代器 II") 🔒 | [Go](problems/binary-search-tree-iterator-ii) | Medium | | 1585 | [Check If String Is Transformable With Substring Sort Operations](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations "检查字符串是否可以通过排序子字符串得到另一个字符串") | [Go](problems/check-if-string-is-transformable-with-substring-sort-operations) | Hard | | 1584 | [Min Cost to Connect All Points](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") | [Go](problems/min-cost-to-connect-all-points) | Medium | | 1583 | [Count Unhappy Friends](https://leetcode.com/problems/count-unhappy-friends "统计不开心的朋友") | [Go](problems/count-unhappy-friends) | Medium | @@ -94,7 +100,7 @@ LeetCode Problems' Solutions | 1574 | [Shortest Subarray to be Removed to Make Array Sorted](https://leetcode.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted "删除最短的子数组使剩余数组有序") | [Go](problems/shortest-subarray-to-be-removed-to-make-array-sorted) | Medium | | 1573 | [Number of Ways to Split a String](https://leetcode.com/problems/number-of-ways-to-split-a-string "分割字符串的方案数") | [Go](problems/number-of-ways-to-split-a-string) | Medium | | 1572 | [Matrix Diagonal Sum](https://leetcode.com/problems/matrix-diagonal-sum "矩阵对角线元素的和") | [Go](problems/matrix-diagonal-sum) | Easy | -| 1571 | [Warehouse Manager](https://leetcode.com/problems/warehouse-manager) 🔒 | [MySQL](problems/warehouse-manager) | Easy | +| 1571 | [Warehouse Manager](https://leetcode.com/problems/warehouse-manager "仓库经理") 🔒 | [MySQL](problems/warehouse-manager) | Easy | | 1570 | [Dot Product of Two Sparse Vectors](https://leetcode.com/problems/dot-product-of-two-sparse-vectors) 🔒 | [Go](problems/dot-product-of-two-sparse-vectors) | Medium | | 1569 | [Number of Ways to Reorder Array to Get Same BST](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst "将子数组重新排序得到同一个二叉查找树的方案数") | [Go](problems/number-of-ways-to-reorder-array-to-get-same-bst) | Hard | | 1568 | [Minimum Number of Days to Disconnect Island](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数") | [Go](problems/minimum-number-of-days-to-disconnect-island) | Hard | @@ -116,7 +122,7 @@ LeetCode Problems' Solutions | 1552 | [Magnetic Force Between Two Balls](https://leetcode.com/problems/magnetic-force-between-two-balls "两球之间的磁力") | [Go](problems/magnetic-force-between-two-balls) | Medium | | 1551 | [Minimum Operations to Make Array Equal](https://leetcode.com/problems/minimum-operations-to-make-array-equal "使数组中所有元素相等的最小操作数") | [Go](problems/minimum-operations-to-make-array-equal) | Medium | | 1550 | [Three Consecutive Odds](https://leetcode.com/problems/three-consecutive-odds "存在连续三个奇数的数组") | [Go](problems/three-consecutive-odds) | Easy | -| 1549 | [The Most Recent Orders for Each Product](https://leetcode.com/problems/the-most-recent-orders-for-each-product) 🔒 | [MySQL](problems/the-most-recent-orders-for-each-product) | Medium | +| 1549 | [The Most Recent Orders for Each Product](https://leetcode.com/problems/the-most-recent-orders-for-each-product "每件商品的最新订单") 🔒 | [MySQL](problems/the-most-recent-orders-for-each-product) | Medium | | 1548 | [The Most Similar Path in a Graph](https://leetcode.com/problems/the-most-similar-path-in-a-graph) 🔒 | [Go](problems/the-most-similar-path-in-a-graph) | Hard | | 1547 | [Minimum Cost to Cut a Stick](https://leetcode.com/problems/minimum-cost-to-cut-a-stick "切棍子的最小成本") | [Go](problems/minimum-cost-to-cut-a-stick) | Hard | | 1546 | [Maximum Number of Non-Overlapping Subarrays With Sum Equals Target](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值的最大数目不重叠非空子数组数目") | [Go](problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | Medium | @@ -127,12 +133,12 @@ LeetCode Problems' Solutions | 1541 | [Minimum Insertions to Balance a Parentheses String](https://leetcode.com/problems/minimum-insertions-to-balance-a-parentheses-string "平衡括号字符串的最少插入次数") | [Go](problems/minimum-insertions-to-balance-a-parentheses-string) | Medium | | 1540 | [Can Convert String in K Moves](https://leetcode.com/problems/can-convert-string-in-k-moves "K 次操作转变字符串") | [Go](problems/can-convert-string-in-k-moves) | Medium | | 1539 | [Kth Missing Positive Number](https://leetcode.com/problems/kth-missing-positive-number "第 k 个缺失的正整数") | [Go](problems/kth-missing-positive-number) | Easy | -| 1538 | [Guess the Majority in a Hidden Array](https://leetcode.com/problems/guess-the-majority-in-a-hidden-array) 🔒 | [Go](problems/guess-the-majority-in-a-hidden-array) | Medium | +| 1538 | [Guess the Majority in a Hidden Array](https://leetcode.com/problems/guess-the-majority-in-a-hidden-array "找出隐藏数组中出现次数最多的元素") 🔒 | [Go](problems/guess-the-majority-in-a-hidden-array) | Medium | | 1537 | [Get the Maximum Score](https://leetcode.com/problems/get-the-maximum-score "最大得分") | [Go](problems/get-the-maximum-score) | Hard | | 1536 | [Minimum Swaps to Arrange a Binary Grid](https://leetcode.com/problems/minimum-swaps-to-arrange-a-binary-grid "排布二进制网格的最少交换次数") | [Go](problems/minimum-swaps-to-arrange-a-binary-grid) | Medium | | 1535 | [Find the Winner of an Array Game](https://leetcode.com/problems/find-the-winner-of-an-array-game "找出数组游戏的赢家") | [Go](problems/find-the-winner-of-an-array-game) | Medium | | 1534 | [Count Good Triplets](https://leetcode.com/problems/count-good-triplets "统计好三元组") | [Go](problems/count-good-triplets) | Easy | -| 1533 | [Find the Index of the Large Integer](https://leetcode.com/problems/find-the-index-of-the-large-integer) 🔒 | [Go](problems/find-the-index-of-the-large-integer) | Medium | +| 1533 | [Find the Index of the Large Integer](https://leetcode.com/problems/find-the-index-of-the-large-integer "找到最大整数的索引") 🔒 | [Go](problems/find-the-index-of-the-large-integer) | Medium | | 1532 | [The Most Recent Three Orders](https://leetcode.com/problems/the-most-recent-three-orders "最近的三笔订单") 🔒 | [MySQL](problems/the-most-recent-three-orders) | Medium | | 1531 | [String Compression II](https://leetcode.com/problems/string-compression-ii "压缩字符串 II") | [Go](problems/string-compression-ii) | Hard | | 1530 | [Number of Good Leaf Nodes Pairs](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs "好叶子节点对的数量") | [Go](problems/number-of-good-leaf-nodes-pairs) | Medium | @@ -165,7 +171,7 @@ LeetCode Problems' Solutions | 1503 | [Last Moment Before All Ants Fall Out of a Plank](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank "所有蚂蚁掉下来前的最后一刻") | [Go](problems/last-moment-before-all-ants-fall-out-of-a-plank) | Medium | | 1502 | [Can Make Arithmetic Progression From Sequence](https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence "判断能否形成等差数列") | [Go](problems/can-make-arithmetic-progression-from-sequence) | Easy | | 1501 | [Countries You Can Safely Invest In](https://leetcode.com/problems/countries-you-can-safely-invest-in "可以放心投资的国家") 🔒 | [MySQL](problems/countries-you-can-safely-invest-in) | Medium | -| 1500 | [Design a File Sharing System](https://leetcode.com/problems/design-a-file-sharing-system) 🔒 | [Go](problems/design-a-file-sharing-system) | Medium | +| 1500 | [Design a File Sharing System](https://leetcode.com/problems/design-a-file-sharing-system "设计文件分享系统") 🔒 | [Go](problems/design-a-file-sharing-system) | Medium | | 1499 | [Max Value of Equation](https://leetcode.com/problems/max-value-of-equation "满足不等式的最大值") | [Go](problems/max-value-of-equation) | Hard | | 1498 | [Number of Subsequences That Satisfy the Given Sum Condition](https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition "满足条件的子序列数目") | [Go](problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | Medium | | 1497 | [Check If Array Pairs Are Divisible by k](https://leetcode.com/problems/check-if-array-pairs-are-divisible-by-k "检查数组对是否可以被 k 整除") | [Go](problems/check-if-array-pairs-are-divisible-by-k) | Medium | diff --git a/problems/adding-two-negabinary-numbers/README.md b/problems/adding-two-negabinary-numbers/README.md index 9f9dbeec8..9b56b123f 100644 --- a/problems/adding-two-negabinary-numbers/README.md +++ b/problems/adding-two-negabinary-numbers/README.md @@ -13,31 +13,41 @@

    Given two numbers arr1 and arr2 in base -2, return the result of adding them together.

    -

    Each number is given in array format:  as an array of 0s and 1s, from most significant bit to least significant bit.  For example, arr = [1,1,0,1] represents the number (-2)^3 + (-2)^2 + (-2)^0 = -3.  A number arr in array format is also guaranteed to have no leading zeros: either arr == [0] or arr[0] == 1.

    +

    Each number is given in array format:  as an array of 0s and 1s, from most significant bit to least significant bit.  For example, arr = [1,1,0,1] represents the number (-2)^3 + (-2)^2 + (-2)^0 = -3.  A number arr in array, format is also guaranteed to have no leading zeros: either arr == [0] or arr[0] == 1.

    Return the result of adding arr1 and arr2 in the same format: as an array of 0s and 1s with no leading zeros.

     

    -

    Example 1:

    -Input: arr1 = [1,1,1,1,1], arr2 = [1,0,1]
    -Output: [1,0,0,0,0]
    -Explanation: arr1 represents 11, arr2 represents 5, the output represents 16.
    +Input: arr1 = [1,1,1,1,1], arr2 = [1,0,1]
    +Output: [1,0,0,0,0]
    +Explanation: arr1 represents 11, arr2 represents 5, the output represents 16.
     
    -

     

    +

    Example 2:

    + +
    +Input: arr1 = [0], arr2 = [0]
    +Output: [0]
    +
    -

    Note:

    +

    Example 3:

    + +
    +Input: arr1 = [0], arr2 = [1]
    +Output: [1]
    +
    + +

     

    +

    Constraints:

    -
      -
    1. 1 <= arr1.length <= 1000
    2. -
    3. 1 <= arr2.length <= 1000
    4. +
        +
      • 1 <= arr1.length, arr2.length <= 1000
      • +
      • arr1[i] and arr2[i] are 0 or 1
      • arr1 and arr2 have no leading zeros
      • -
      • arr1[i] is 0 or 1
      • -
      • arr2[i] is 0 or 1
      • -
    + ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/binary-search-tree-iterator-ii/README.md b/problems/binary-search-tree-iterator-ii/README.md index 9ae868179..96030951f 100644 --- a/problems/binary-search-tree-iterator-ii/README.md +++ b/problems/binary-search-tree-iterator-ii/README.md @@ -9,7 +9,7 @@                  [Next >](../bank-account-summary-ii "Bank Account Summary II") -## [1586. Binary Search Tree Iterator II (Medium)](https://leetcode.com/problems/binary-search-tree-iterator-ii "") +## [1586. Binary Search Tree Iterator II (Medium)](https://leetcode.com/problems/binary-search-tree-iterator-ii "二叉搜索树迭代器 II") diff --git a/problems/binary-search-tree-to-greater-sum-tree/README.md b/problems/binary-search-tree-to-greater-sum-tree/README.md index 873ca95a4..da20eab45 100644 --- a/problems/binary-search-tree-to-greater-sum-tree/README.md +++ b/problems/binary-search-tree-to-greater-sum-tree/README.md @@ -9,11 +9,11 @@                  [Next >](../minimum-score-triangulation-of-polygon "Minimum Score Triangulation of Polygon") -## [1038. Binary Search Tree to Greater Sum Tree (Medium)](https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree "从二叉搜索树到更大和树") +## [1038. Binary Search Tree to Greater Sum Tree (Medium)](https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree "把二叉搜索树转换为累加树") -

    Given the root of a binary search tree with distinct values, modify it so that every node has a new value equal to the sum of the values of the original tree that are greater than or equal to node.val.

    +

    Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.

    -

    As a reminder, a binary search tree is a tree that satisfies these constraints:

    +

    As a reminder, a binary search tree is a tree that satisfies these constraints:

    • The left subtree of a node contains only nodes with keys less than the node's key.
    • @@ -21,34 +21,46 @@
    • Both the left and right subtrees must also be binary search trees.
    -

     

    +

    Note: This question is the same as 538: https://leetcode.com/problems/convert-bst-to-greater-tree/

    +

     

    Example 1:

    + +
    +Input: root = [4,1,6,0,2,5,7,null,null,null,3,null,null,null,8]
    +Output: [30,36,21,36,35,26,15,null,null,null,33,null,null,null,8]
    +
    -

    +

    Example 2:

    -Input: [4,1,6,0,2,5,7,null,null,null,3,null,null,null,8]
    -Output: [30,36,21,36,35,26,15,null,null,null,33,null,null,null,8]
    +Input: root = [0,null,1]
    +Output: [1,null,1]
     
    -
    -

     

    -
    +

    Example 3:

    + +
    +Input: root = [1,0,2]
    +Output: [3,3,2]
    +
    +

    Example 4:

    + +
    +Input: root = [3,2,4,1]
    +Output: [7,9,4,10]
    +
    + +

     

    Constraints:

    -
      -
    1. The number of nodes in the tree is between 1 and 100.
    2. -
    3. Each node will have value between 0 and 100.
    4. -
    5. The given tree is a binary search tree.
    6. -
    - -
    -
    -
    Note: This question is the same as 538: https://leetcode.com/problems/convert-bst-to-greater-tree/
    -
    -
    +
      +
    • The number of nodes in the tree is in the range [1, 100].
    • +
    • 0 <= Node.val <= 100
    • +
    • All the values in the tree are unique.
    • +
    • root is guaranteed to be a valid binary search tree.
    • +
    ### Related Topics [[Binary Search Tree](../../tag/binary-search-tree/README.md)] diff --git a/problems/binary-tree-inorder-traversal/README.md b/problems/binary-tree-inorder-traversal/README.md index 909b9c3a7..d85b65b80 100644 --- a/problems/binary-tree-inorder-traversal/README.md +++ b/problems/binary-tree-inorder-traversal/README.md @@ -13,8 +13,6 @@

    Given the root of a binary tree, return the inorder traversal of its nodes' values.

    -

    Follow up: Recursive solution is trivial, could you do it iteratively?

    -

     

    Example 1:

    @@ -59,6 +57,14 @@
  • -100 <= Node.val <= 100
  • +

     

    + +

    Follow up:

    + +

    Recursive solution is trivial, could you do it iteratively?

    + +

     

    + ### Related Topics [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] diff --git a/problems/binary-tree-postorder-traversal/README.md b/problems/binary-tree-postorder-traversal/README.md index 5795c624a..0b46dcb03 100644 --- a/problems/binary-tree-postorder-traversal/README.md +++ b/problems/binary-tree-postorder-traversal/README.md @@ -11,9 +11,7 @@ ## [145. Binary Tree Postorder Traversal (Medium)](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历") -

    Given the root of a binary tree, return the postorder traversal of its nodes' values.

    - -

    Follow up: Recursive solution is trivial, could you do it iteratively?

    +

    Given the root of a binary tree, return the postorder traversal of its nodes' values.

     

    Example 1:

    @@ -59,6 +57,14 @@
  • -100 <= Node.val <= 100
  • +

     

    + +

    Follow up:

    + +

    Recursive solution is trivial, could you do it iteratively?

    + +

     

    + ### Related Topics [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] diff --git a/problems/binary-tree-preorder-traversal/README.md b/problems/binary-tree-preorder-traversal/README.md index 1d547ac24..725ba549c 100644 --- a/problems/binary-tree-preorder-traversal/README.md +++ b/problems/binary-tree-preorder-traversal/README.md @@ -11,22 +11,59 @@ ## [144. Binary Tree Preorder Traversal (Medium)](https://leetcode.com/problems/binary-tree-preorder-traversal "二叉树的前序遍历") -

    Given a binary tree, return the preorder traversal of its nodes' values.

    +

    Given the root of a binary tree, return the preorder traversal of its nodes' values.

    -

    Example:

    +

     

    +

    Example 1:

    + +
    +Input: root = [1,null,2,3]
    +Output: [1,2,3]
    +
    + +

    Example 2:

    + +
    +Input: root = []
    +Output: []
    +
    + +

    Example 3:

    + +
    +Input: root = [1]
    +Output: [1]
    +
    +

    Example 4:

    +
    -Input: [1,null,2,3]
    -   1
    -    \
    -     2
    -    /
    -   3
    -
    -Output: [1,2,3]
    +Input: root = [1,2]
    +Output: [1,2]
     
    -

    Follow up: Recursive solution is trivial, could you do it iteratively?

    +

    Example 5:

    + +
    +Input: root = [1,null,2]
    +Output: [1,2]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [0, 100].
    • +
    • -100 <= Node.val <= 100
    • +
    + +

     

    + +

    Follow up:

    + +

    Recursive solution is trivial, could you do it iteratively?

    + +

     

    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/build-binary-expression-tree-from-infix-expression/README.md b/problems/build-binary-expression-tree-from-infix-expression/README.md new file mode 100644 index 000000000..f34a88c05 --- /dev/null +++ b/problems/build-binary-expression-tree-from-infix-expression/README.md @@ -0,0 +1,29 @@ + + + + + + + +[< Previous](../the-most-frequently-ordered-products-for-each-customer "The Most Frequently Ordered Products for Each Customer") +                 +[Next >](../crawler-log-folder "Crawler Log Folder") + +## [1597. Build Binary Expression Tree From Infix Expression (Medium)](https://leetcode.com/problems/build-binary-expression-tree-from-infix-expression "") + + + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Convert infix expression to postfix expression. +
    + +
    +Hint 2 +Build an expression tree from the postfix expression. +
    diff --git a/problems/coin-change/README.md b/problems/coin-change/README.md index 813ce28ba..1836ac4bd 100644 --- a/problems/coin-change/README.md +++ b/problems/coin-change/README.md @@ -13,22 +13,53 @@

    You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.

    -

    Example 1:

    +

    You may assume that you have an infinite number of each kind of coin.

    + +

     

    +

    Example 1:

    + +
    +Input: coins = [1,2,5], amount = 11
    +Output: 3
    +Explanation: 11 = 5 + 5 + 1
    +
    + +

    Example 2:

    -Input: coins = [1, 2, 5], amount = 11
    -Output: 3 
    -Explanation: 11 = 5 + 5 + 1
    +Input: coins = [2], amount = 3 +Output: -1 +
    -

    Example 2:

    +

    Example 3:

    -Input: coins = [2], amount = 3
    -Output: -1
    +Input: coins = [1], amount = 0
    +Output: 0
     
    -

    Note:
    -You may assume that you have an infinite number of each kind of coin.

    +

    Example 4:

    + +
    +Input: coins = [1], amount = 1
    +Output: 1
    +
    + +

    Example 5:

    + +
    +Input: coins = [1], amount = 2
    +Output: 2
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= coins.length <= 12
    • +
    • 1 <= coins[i] <= 231 - 1
    • +
    • 0 <= amount <= 231 - 1
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/convert-bst-to-greater-tree/README.md b/problems/convert-bst-to-greater-tree/README.md index 29a9af0b8..18a1a1db9 100644 --- a/problems/convert-bst-to-greater-tree/README.md +++ b/problems/convert-bst-to-greater-tree/README.md @@ -9,25 +9,58 @@                  [Next >](../minimum-time-difference "Minimum Time Difference") -## [538. Convert BST to Greater Tree (Easy)](https://leetcode.com/problems/convert-bst-to-greater-tree "把二叉搜索树转换为累加树") +## [538. Convert BST to Greater Tree (Medium)](https://leetcode.com/problems/convert-bst-to-greater-tree "把二叉搜索树转换为累加树") -

    Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.

    +

    Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.

    -

    Example:

    +

    As a reminder, a binary search tree is a tree that satisfies these constraints:

    +
      +
    • The left subtree of a node contains only nodes with keys less than the node's key.
    • +
    • The right subtree of a node contains only nodes with keys greater than the node's key.
    • +
    • Both the left and right subtrees must also be binary search trees.
    • +
    + +

    Note: This question is the same as 1038: https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree/

    + +

     

    +

    Example 1:

    +
    -Input: The root of a Binary Search Tree like this:
    -              5
    -            /   \
    -           2     13
    -
    -Output: The root of a Greater Tree like this:
    -             18
    -            /   \
    -          20     13
    +Input: root = [4,1,6,0,2,5,7,null,null,null,3,null,null,null,8]
    +Output: [30,36,21,36,35,26,15,null,null,null,33,null,null,null,8]
     
    -

    Note: This question is the same as 1038: https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree/

    +

    Example 2:

    + +
    +Input: root = [0,null,1]
    +Output: [1,null,1]
    +
    + +

    Example 3:

    + +
    +Input: root = [1,0,2]
    +Output: [3,3,2]
    +
    + +

    Example 4:

    + +
    +Input: root = [3,2,4,1]
    +Output: [7,9,4,10]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [0, 104].
    • +
    • -104 <= Node.val <= 104
    • +
    • All the values in the tree are unique.
    • +
    • root is guaranteed to be a valid binary search tree.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/count-number-of-nice-subarrays/README.md b/problems/count-number-of-nice-subarrays/README.md index dfdd0ad80..5cf5c0d3d 100644 --- a/problems/count-number-of-nice-subarrays/README.md +++ b/problems/count-number-of-nice-subarrays/README.md @@ -11,9 +11,9 @@ ## [1248. Count Number of Nice Subarrays (Medium)](https://leetcode.com/problems/count-number-of-nice-subarrays "统计「优美子数组」") -

    Given an array of integers nums and an integer k. A subarray is called nice if there are k odd numbers on it.

    +

    Given an array of integers nums and an integer k. A continuous subarray is called nice if there are k odd numbers on it.

    -

    Return the number of nice sub-arrays.

    +

    Return the number of nice sub-arrays.

     

    Example 1:

    diff --git a/problems/count-primes/README.md b/problems/count-primes/README.md index 5ff81dc7f..9ecaffa2b 100644 --- a/problems/count-primes/README.md +++ b/problems/count-primes/README.md @@ -11,16 +11,38 @@ ## [204. Count Primes (Easy)](https://leetcode.com/problems/count-primes "计数质数") -

    Count the number of prime numbers less than a non-negative number, n.

    +

    Count the number of prime numbers less than a non-negative number, n.

    -

    Example:

    +

     

    +

    Example 1:

    -Input: 10
    +Input: n = 10
     Output: 4
     Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.
     
    +

    Example 2:

    + +
    +Input: n = 0
    +Output: 0
    +
    + +

    Example 3:

    + +
    +Input: n = 1
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= n <= 5 * 106
    • +
    + ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/crawler-log-folder/README.md b/problems/crawler-log-folder/README.md new file mode 100644 index 000000000..5b134cae2 --- /dev/null +++ b/problems/crawler-log-folder/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../build-binary-expression-tree-from-infix-expression "Build Binary Expression Tree From Infix Expression") +                 +[Next >](../maximum-profit-of-operating-a-centennial-wheel "Maximum Profit of Operating a Centennial Wheel") + +## [1598. Crawler Log Folder (Easy)](https://leetcode.com/problems/crawler-log-folder "文件夹操作日志搜集器") + +

    The Leetcode file system keeps a log each time some user performs a change folder operation.

    + +

    The operations are described below:

    + +
      +
    • "../" : Move to the parent folder of the current folder. (If you are already in the main folder, remain in the same folder).
    • +
    • "./" : Remain in the same folder.
    • +
    • "x/" : Move to the child folder named x (This folder is guaranteed to always exist).
    • +
    + +

    You are given a list of strings logs where logs[i] is the operation performed by the user at the ith step.

    + +

    The file system starts in the main folder, then the operations in logs are performed.

    + +

    Return the minimum number of operations needed to go back to the main folder after the change folder operations.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: logs = ["d1/","d2/","../","d21/","./"]
    +Output: 2
    +Explanation: Use this change folder operation "../" 2 times and go back to the main folder.
    +
    + +

    Example 2:

    + +

    + +
    +Input: logs = ["d1/","d2/","./","d3/","../","d31/"]
    +Output: 3
    +
    + +

    Example 3:

    + +
    +Input: logs = ["d1/","../","../","../"]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= logs.length <= 103
    • +
    • 2 <= logs[i].length <= 10
    • +
    • logs[i] contains lowercase English letters, digits, '.', and '/'.
    • +
    • logs[i] follows the format described in the statement.
    • +
    • Folder names consist of lowercase English letters and digits.
    • +
    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + +### Hints +
    +Hint 1 +Simulate the process but don’t move the pointer beyond the main folder. +
    + +
    +Hint 2 +Simulate the process but don’t move the pointer beyond the main folder. +
    diff --git a/problems/design-a-file-sharing-system/README.md b/problems/design-a-file-sharing-system/README.md index cf0655906..4ef206913 100644 --- a/problems/design-a-file-sharing-system/README.md +++ b/problems/design-a-file-sharing-system/README.md @@ -9,7 +9,7 @@                  [Next >](../countries-you-can-safely-invest-in "Countries You Can Safely Invest In") -## [1500. Design a File Sharing System (Medium)](https://leetcode.com/problems/design-a-file-sharing-system "") +## [1500. Design a File Sharing System (Medium)](https://leetcode.com/problems/design-a-file-sharing-system "设计文件分享系统") diff --git a/problems/evaluate-division/README.md b/problems/evaluate-division/README.md index 20de64122..e402d77b9 100644 --- a/problems/evaluate-division/README.md +++ b/problems/evaluate-division/README.md @@ -49,7 +49,7 @@ return: [6.0, 0.5, -1.0, 1.0, -1.0 ]
  • equations[i].length == 2
  • 1 <= equations[i][0], equations[i][1] <= 5
  • values.length == equations.length
  • -
  • 0.0 <= values[i] <= 20.0
  • +
  • 0.0 < values[i] <= 20.0
  • 1 <= queries.length <= 20
  • queries[i].length == 2
  • 1 <= queries[i][0], queries[i][1] <= 5
  • diff --git a/problems/exclusive-time-of-functions/README.md b/problems/exclusive-time-of-functions/README.md index 02ea6040b..2138a21ef 100644 --- a/problems/exclusive-time-of-functions/README.md +++ b/problems/exclusive-time-of-functions/README.md @@ -11,17 +11,15 @@ ## [636. Exclusive Time of Functions (Medium)](https://leetcode.com/problems/exclusive-time-of-functions "函数的独占时间") -

    On a single threaded CPU, we execute some functions.  Each function has a unique id between 0 and N-1.

    +

    On a single-threaded CPU, we execute a program containing n functions. Each function has a unique ID between 0 and n-1.

    -

    We store logs in timestamp order that describe when a function is entered or exited.

    +

    Function calls are stored in a call stack: when a function call starts, its ID is pushed onto the stack, and when a function call ends, its ID is popped off the stack. The function whose ID is at the top of the stack is the current function being executed. Each time a function starts or ends, we write a log with the ID, whether it started or ended, and the timestamp.

    -

    Each log is a string with this format: "{function_id}:{"start" | "end"}:{timestamp}".  For example, "0:start:3" means the function with id 0 started at the beginning of timestamp 3"1:end:2" means the function with id 1 ended at the end of timestamp 2.

    +

    You are given a list logs, where logs[i] represents the ith log message formatted as a string "{function_id}:{"start" | "end"}:{timestamp}". For example, "0:start:3" means a function call with function ID 0 started at the beginning of timestamp 3, and "1:end:2" means a function call with function ID 1 ended at the end of timestamp 2. Note that a function can be called multiple times, possibly recursively.

    -

    A function's exclusive time is the number of units of time spent in this function.  Note that this does not include any recursive calls to child functions.

    +

    A function's exclusive time is the sum of execution times for all function calls in the program. For example, if a function is called twice, one call executing for 2 time units and another call executing for 1 time unit, the exclusive time is 2 + 1 = 3.

    -

    The CPU is single threaded which means that only one function is being executed at a given time unit.

    - -

    Return the exclusive time of each function, sorted by their function id.

    +

    Return the exclusive time of each function in an array, where the value at the ith index represents the exclusive time for the function with ID i.

     

    Example 1:

    @@ -30,9 +28,9 @@ Input: n = 2, logs = ["0:start:0","1:start:2","1:end:5","0:end:6"] Output: [3,4] Explanation: -Function 0 starts at the beginning of time 0, then it executes 2 units of time and reaches the end of time 1. -Now function 1 starts at the beginning of time 2, executes 4 units of time and ends at time 5. -Function 0 is running again at the beginning of time 6, and also ends at the end of time 6, thus executing for 1 unit of time. +Function 0 starts at the beginning of time 0, then it executes 2 for units of time and reaches the end of time 1. +Function 1 starts at the beginning of time 2, executes for 4 units of time, and ends at the end of time 5. +Function 0 resumes execution at the beginning of time 6 and executes for 1 unit of time. So function 0 spends 2 + 1 = 3 units of total time executing, and function 1 spends 4 units of total time executing. @@ -41,6 +39,13 @@ So function 0 spends 2 + 1 = 3 units of total time executing, and function 1 spe
     Input: n = 1, logs = ["0:start:0","0:start:2","0:end:5","0:start:6","0:end:6","0:end:7"]
     Output: [8]
    +Explanation:
    +Function 0 starts at the beginning of time 0, executes for 2 units of time, and recursively calls itself.
    +Function 0 (recursive call) starts at the beginning of time 2 and executes for 4 units of time.
    +Function 0 (initial call) resumes execution then immediately calls itself again.
    +Function 0 (2nd recursive call) starts at the beginning of time 6 and executes for 1 unit of time.
    +Function 0 (initial call) resumes execution at the beginning of time 7 and executes for 1 unit of time.
    +So function 0 spends 2 + 4 + 1 + 1 = 8 units of total time executing.
     

    Example 3:

    @@ -48,6 +53,13 @@ So function 0 spends 2 + 1 = 3 units of total time executing, and function 1 spe
     Input: n = 2, logs = ["0:start:0","0:start:2","0:end:5","1:start:6","1:end:6","0:end:7"]
     Output: [7,1]
    +Explanation:
    +Function 0 starts at the beginning of time 0, executes for 2 units of time, and recursively calls itself.
    +Function 0 (recursive call) starts at the beginning of time 2 and executes for 4 units of time.
    +Function 0 (initial call) resumes execution then immediately calls function 1.
    +Function 1 starts at the beginning of time 6, executes 1 units of time, and ends at the end of time 6.
    +Function 0 resumes execution at the beginning of time 6 and executes for 2 units of time.
    +So function 0 spends 2 + 4 + 1 = 7 units of total time executing, and function 1 spends 1 unit of total time executing.
     

    Example 4:

    @@ -70,9 +82,10 @@ So function 0 spends 2 + 1 = 3 units of total time executing, and function 1 spe
    • 1 <= n <= 100
    • 1 <= logs.length <= 500
    • -
    • 0 <= function_id < 100
    • +
    • 0 <= function_id < n
    • 0 <= timestamp <= 109
    • -
    • Two functions do not start or end at the same time.
    • +
    • No two start events will happen at the same timestamp.
    • +
    • No two end events will happen at the same timestamp.
    • Each function has an "end" log for each "start" log.
    diff --git a/problems/find-the-index-of-the-large-integer/README.md b/problems/find-the-index-of-the-large-integer/README.md index d397c2dac..ba1049221 100644 --- a/problems/find-the-index-of-the-large-integer/README.md +++ b/problems/find-the-index-of-the-large-integer/README.md @@ -9,7 +9,7 @@                  [Next >](../count-good-triplets "Count Good Triplets") -## [1533. Find the Index of the Large Integer (Medium)](https://leetcode.com/problems/find-the-index-of-the-large-integer "") +## [1533. Find the Index of the Large Integer (Medium)](https://leetcode.com/problems/find-the-index-of-the-large-integer "找到最大整数的索引") diff --git a/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md b/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md index 5b96f49e9..1e62f99b4 100644 --- a/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md +++ b/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md @@ -11,16 +11,16 @@ ## [1414. Find the Minimum Number of Fibonacci Numbers Whose Sum Is K (Medium)](https://leetcode.com/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k "和为 K 的最少斐波那契数字数目") -

    Given the number k, return the minimum number of Fibonacci numbers whose sum is equal to k, whether a Fibonacci number could be used multiple times.

    +

    Given an integer k, return the minimum number of Fibonacci numbers whose sum is equal to k. The same Fibonacci number can be used multiple times.

    The Fibonacci numbers are defined as:

      -
    • F1 = 1
    • -
    • F2 = 1
    • -
    • Fn = Fn-1 + Fn-2 , for n > 2.
    • +
    • F1 = 1
    • +
    • F2 = 1
    • +
    • Fn = Fn-1 + Fn-2 for n > 2.
    -It is guaranteed that for the given constraints we can always find such fibonacci numbers that sum k. +It is guaranteed that for the given constraints we can always find such Fibonacci numbers that sum up to k.

     

    Example 1:

    diff --git a/problems/guess-number-higher-or-lower/README.md b/problems/guess-number-higher-or-lower/README.md index 22924c652..f645a703a 100644 --- a/problems/guess-number-higher-or-lower/README.md +++ b/problems/guess-number-higher-or-lower/README.md @@ -17,22 +17,35 @@

    Every time you guess wrong, I'll tell you whether the number is higher or lower.

    -

    You call a pre-defined API guess(int num) which returns 3 possible results (-1, 1, or 0):

    - -
    --1 : My number is lower
    - 1 : My number is higher
    - 0 : Congrats! You got it!
    +

    You call a pre-defined API guess(int num) which returns 3 possible results:

    + +
      +
    • -1: My number is lower
    • +
    • 1: My number is higher
    • +
    • 0: Congrats! You got it!
    • +
    + +

     

    +

    Example 1:

    +
    Input: n = 10, pick = 6
    +Output: 6
    +

    Example 2:

    +
    Input: n = 1, pick = 1
    +Output: 1
    +

    Example 3:

    +
    Input: n = 2, pick = 1
    +Output: 1
    +

    Example 4:

    +
    Input: n = 2, pick = 2
    +Output: 2
     
    +

     

    +

    Constraints:

    -

    Example :

    - -
    -
    -Input: n = 10, pick = 6
    -Output: 6
    -
    -
    +
      +
    • 1 <= n <= 231 - 1
    • +
    • 1 <= pick <= n
    • +
    ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/guess-the-majority-in-a-hidden-array/README.md b/problems/guess-the-majority-in-a-hidden-array/README.md index 56b3d7405..5e043746a 100644 --- a/problems/guess-the-majority-in-a-hidden-array/README.md +++ b/problems/guess-the-majority-in-a-hidden-array/README.md @@ -9,7 +9,7 @@                  [Next >](../kth-missing-positive-number "Kth Missing Positive Number") -## [1538. Guess the Majority in a Hidden Array (Medium)](https://leetcode.com/problems/guess-the-majority-in-a-hidden-array "") +## [1538. Guess the Majority in a Hidden Array (Medium)](https://leetcode.com/problems/guess-the-majority-in-a-hidden-array "找出隐藏数组中出现次数最多的元素") diff --git a/problems/house-robber-ii/README.md b/problems/house-robber-ii/README.md index feedaf417..5afb71f24 100644 --- a/problems/house-robber-ii/README.md +++ b/problems/house-robber-ii/README.md @@ -37,7 +37,7 @@ ### Similar Questions 1. [House Robber](../house-robber) (Easy) - 1. [Paint House](../paint-house) (Easy) + 1. [Paint House](../paint-house) (Medium) 1. [Paint Fence](../paint-fence) (Easy) 1. [House Robber III](../house-robber-iii) (Medium) 1. [Non-negative Integers without Consecutive Ones](../non-negative-integers-without-consecutive-ones) (Hard) diff --git a/problems/house-robber/README.md b/problems/house-robber/README.md index 7430cf8d5..eec3c1ba5 100644 --- a/problems/house-robber/README.md +++ b/problems/house-robber/README.md @@ -48,7 +48,7 @@ ### Similar Questions 1. [Maximum Product Subarray](../maximum-product-subarray) (Medium) 1. [House Robber II](../house-robber-ii) (Medium) - 1. [Paint House](../paint-house) (Easy) + 1. [Paint House](../paint-house) (Medium) 1. [Paint Fence](../paint-fence) (Easy) 1. [House Robber III](../house-robber-iii) (Medium) 1. [Non-negative Integers without Consecutive Ones](../non-negative-integers-without-consecutive-ones) (Hard) diff --git a/problems/majority-element-ii/README.md b/problems/majority-element-ii/README.md index ba9295772..b58da0ccb 100644 --- a/problems/majority-element-ii/README.md +++ b/problems/majority-element-ii/README.md @@ -11,21 +11,39 @@ ## [229. Majority Element II (Medium)](https://leetcode.com/problems/majority-element-ii "求众数 II") -

    Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times.

    +

    Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times.

    -

    Note: The algorithm should run in linear time and in O(1) space.

    +

    Follow-up: Could you solve the problem in linear time and in O(1) space?

    +

     

    Example 1:

    -Input: [3,2,3]
    -Output: [3]
    +Input: nums = [3,2,3] +Output: [3] +

    Example 2:

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

    Example 3:

    + +
    +Input: nums = [1,2]
    +Output: [1,2]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 5 * 104
    • +
    • -109 <= nums[i] <= 109
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/maximum-number-of-achievable-transfer-requests/README.md b/problems/maximum-number-of-achievable-transfer-requests/README.md new file mode 100644 index 000000000..ce393567a --- /dev/null +++ b/problems/maximum-number-of-achievable-transfer-requests/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../throne-inheritance "Throne Inheritance") +                 +Next > + +## [1601. Maximum Number of Achievable Transfer Requests (Hard)](https://leetcode.com/problems/maximum-number-of-achievable-transfer-requests "最多可达成的换楼请求数目") + +

    We have n buildings numbered from 0 to n - 1. Each building has a number of employees. It's transfer season, and some employees want to change the building they reside in.

    + +

    You are given an array requests where requests[i] = [fromi, toi] represents an employee's request to transfer from building fromi to building toi.

    + +

    All buildings are full, so a list of requests is achievable only if for each building, the net change in employee transfers is zero. This means the number of employees leaving is equal to the number of employees moving in. For example if n = 3 and two employees are leaving building 0, one is leaving building 1, and one is leaving building 2, there should be two employees moving to building 0, one employee moving to building 1, and one employee moving to building 2.

    + +

    Return the maximum number of achievable requests.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 5, requests = [[0,1],[1,0],[0,1],[1,2],[2,0],[3,4]]
    +Output: 5
    +Explantion: Let's see the requests:
    +From building 0 we have employees x and y and both want to move to building 1.
    +From building 1 we have employees a and b and they want to move to buildings 2 and 0 respectively.
    +From building 2 we have employee z and they want to move to building 0.
    +From building 3 we have employee c and they want to move to building 4.
    +From building 4 we don't have any requests.
    +We can achieve the requests of users x and b by swapping their places.
    +We can achieve the requests of users y, a and z by swapping the places in the 3 buildings.
    +
    + +

    Example 2:

    + +
    +Input: n = 3, requests = [[0,0],[1,2],[2,1]]
    +Output: 3
    +Explantion: Let's see the requests:
    +From building 0 we have employee x and they want to stay in the same building 0.
    +From building 1 we have employee y and they want to move to building 2.
    +From building 2 we have employee z and they want to move to building 1.
    +We can achieve all the requests. 
    + +

    Example 3:

    + +
    +Input: n = 4, requests = [[0,3],[3,1],[1,2],[2,0]]
    +Output: 4
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 20
    • +
    • 1 <= requests.length <= 16
    • +
    • requests[i].length == 2
    • +
    • 0 <= fromi, toi < n
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Think brute force +
    + +
    +Hint 2 +When is a subset of requests okay? +
    diff --git a/problems/maximum-number-of-non-overlapping-substrings/README.md b/problems/maximum-number-of-non-overlapping-substrings/README.md index 05d056030..9adf76d92 100644 --- a/problems/maximum-number-of-non-overlapping-substrings/README.md +++ b/problems/maximum-number-of-non-overlapping-substrings/README.md @@ -9,7 +9,7 @@                  [Next >](../find-a-value-of-a-mysterious-function-closest-to-target "Find a Value of a Mysterious Function Closest to Target") -## [1520. Maximum Number of Non-Overlapping Substrings (Medium)](https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings "最多的不重叠子字符串") +## [1520. Maximum Number of Non-Overlapping Substrings (Hard)](https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings "最多的不重叠子字符串")

    Given a string s of lowercase letters, you need to find the maximum number of non-empty substrings of s that meet the following conditions:

    diff --git a/problems/maximum-profit-of-operating-a-centennial-wheel/README.md b/problems/maximum-profit-of-operating-a-centennial-wheel/README.md new file mode 100644 index 000000000..fa141d67a --- /dev/null +++ b/problems/maximum-profit-of-operating-a-centennial-wheel/README.md @@ -0,0 +1,106 @@ + + + + + + + +[< Previous](../crawler-log-folder "Crawler Log Folder") +                 +[Next >](../throne-inheritance "Throne Inheritance") + +## [1599. Maximum Profit of Operating a Centennial Wheel (Medium)](https://leetcode.com/problems/maximum-profit-of-operating-a-centennial-wheel "经营摩天轮的最大利润") + +

    You are the operator of a Centennial Wheel that has four gondolas, and each gondola has room for up to four people. You have the ability to rotate the gondolas counterclockwise, which costs you runningCost dollars.

    + +

    You are given an array customers of length n where customers[i] is the number of new customers arriving just before the ith rotation (0-indexed). This means you must rotate the wheel i times before customers[i] arrive. Each customer pays boardingCost dollars when they board on the gondola closest to the ground and will exit once that gondola reaches the ground again.

    + +

    You can stop the wheel at any time, including before serving all customers. If you decide to stop serving customers, all subsequent rotations are free in order to get all the customers down safely. Note that if there are currently more than four customers waiting at the wheel, only four will board the gondola, and the rest will wait for the next rotation.

    + +

    Return the minimum number of rotations you need to perform to maximize your profit. If there is no scenario where the profit is positive, return -1.

    + +

     

    +

    Example 1:

    + +
    +Input: customers = [8,3], boardingCost = 5, runningCost = 6
    +Output: 3
    +Explanation: The numbers written on the gondolas are the number of people currently there.
    +1. 8 customers arrive, 4 board and 4 wait for the next gondola, the wheel rotates. Current profit is 4 * $5 - 1 * $6 = $14.
    +2. 3 customers arrive, the 4 waiting board the wheel and the other 3 wait, the wheel rotates. Current profit is 8 * $5 - 2 * $6 = $28.
    +3. The final 3 customers board the gondola, the wheel rotates. Current profit is 11 * $5 - 3 * $6 = $37.
    +The highest profit was $37 after rotating the wheel 3 times.
    + +

    Example 2:

    + +
    +Input: customers = [10,9,6], boardingCost = 6, runningCost = 4
    +Output: 7
    +Explanation:
    +1. 10 customers arrive, 4 board and 6 wait for the next gondola, the wheel rotates. Current profit is 4 * $6 - 1 * $4 = $20.
    +2. 9 customers arrive, 4 board and 11 wait (2 originally waiting, 9 newly waiting), the wheel rotates. Current profit is 8 * $6 - 2 * $4 = $40.
    +3. The final 6 customers arrive, 4 board and 13 wait, the wheel rotates. Current profit is 12 * $6 - 3 * $4 = $60.
    +4. 4 board and 9 wait, the wheel rotates. Current profit is 16 * $6 - 4 * $4 = $80.
    +5. 4 board and 5 wait, the wheel rotates. Current profit is 20 * $6 - 5 * $4 = $100.
    +6. 4 board and 1 waits, the wheel rotates. Current profit is 24 * $6 - 6 * $4 = $120.
    +7. 1 boards, the wheel rotates. Current profit is 25 * $6 - 7 * $4 = $122.
    +The highest profit was $122 after rotating the wheel 7 times.
    +
    +
    + +

    Example 3:

    + +
    +Input: customers = [3,4,0,5,1], boardingCost = 1, runningCost = 92
    +Output: -1
    +Explanation:
    +1. 3 customers arrive, 3 board and 0 wait, the wheel rotates. Current profit is 3 * $1 - 1 * $92 = -$89.
    +2. 4 customers arrive, 4 board and 0 wait, the wheel rotates. Current profit is 7 * $1 - 2 * $92 = -$177.
    +3. 0 customers arrive, 0 board and 0 wait, the wheel rotates. Current profit is 7 * $1 - 3 * $92 = -$269.
    +4. 5 customers arrive, 4 board and 1 waits, the wheel rotates. Current profit is 12 * $1 - 4 * $92 = -$356.
    +5. 1 customer arrives, 2 board and 0 wait, the wheel rotates. Current profit is 13 * $1 - 5 * $92 = -$447.
    +The profit was never positive, so return -1.
    +
    + +

    Example 4:

    + +
    +Input: customers = [10,10,6,4,7], boardingCost = 3, runningCost = 8
    +Output: 9
    +Explanation:
    +1. 10 customers arrive, 4 board and 6 wait, the wheel rotates. Current profit is 4 * $3 - 1 * $8 = $4.
    +2. 10 customers arrive, 4 board and 12 wait, the wheel rotates. Current profit is 8 * $3 - 2 * $8 = $8.
    +3. 6 customers arrive, 4 board and 14 wait, the wheel rotates. Current profit is 12 * $3 - 3 * $8 = $12.
    +4. 4 customers arrive, 4 board and 14 wait, the wheel rotates. Current profit is 16 * $3 - 4 * $8 = $16.
    +5. 7 customers arrive, 4 board and 17 wait, the wheel rotates. Current profit is 20 * $3 - 5 * $8 = $20.
    +6. 4 board and 13 wait, the wheel rotates. Current profit is 24 * $3 - 6 * $8 = $24.
    +7. 4 board and 9 wait, the wheel rotates. Current profit is 28 * $3 - 7 * $8 = $28.
    +8. 4 board and 5 wait, the wheel rotates. Current profit is 32 * $3 - 8 * $8 = $32.
    +9. 4 board and 1 waits, the wheel rotates. Current profit is 36 * $3 - 9 * $8 = $36.
    +10. 1 board and 0 wait, the wheel rotates. Current profit is 37 * $3 - 10 * $8 = $31.
    +The highest profit was $36 after rotating the wheel 9 times.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == customers.length
    • +
    • 1 <= n <= 105
    • +
    • 0 <= customers[i] <= 50
    • +
    • 1 <= boardingCost, runningCost <= 100
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Think simulation +
    + +
    +Hint 2 +Note that the number of turns will never be more than 50 / 4 * n +
    diff --git a/problems/minimum-cost-to-connect-two-groups-of-points/README.md b/problems/minimum-cost-to-connect-two-groups-of-points/README.md index 16f17bbef..9be74d9b6 100644 --- a/problems/minimum-cost-to-connect-two-groups-of-points/README.md +++ b/problems/minimum-cost-to-connect-two-groups-of-points/README.md @@ -7,7 +7,7 @@ [< Previous](../maximum-non-negative-product-in-a-matrix "Maximum Non Negative Product in a Matrix")                  -Next > +[Next >](../the-most-frequently-ordered-products-for-each-customer "The Most Frequently Ordered Products for Each Customer") ## [1595. Minimum Cost to Connect Two Groups of Points (Hard)](https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points "连通两组点的最小成本") diff --git a/problems/number-of-recent-calls/README.md b/problems/number-of-recent-calls/README.md index 71a679ce1..e224a7778 100644 --- a/problems/number-of-recent-calls/README.md +++ b/problems/number-of-recent-calls/README.md @@ -11,37 +11,43 @@ ## [933. Number of Recent Calls (Easy)](https://leetcode.com/problems/number-of-recent-calls "最近的请求次数") -

    Write a class RecentCounter to count recent requests.

    +

    You have a RecentCounter class which counts the number of recent requests within a certain time frame.

    -

    It has only one method: ping(int t), where t represents some time in milliseconds.

    +

    Implement the RecentCounter class:

    -

    Return the number of pings that have been made from 3000 milliseconds ago until now.

    +
      +
    • RecentCounter() Initializes the counter with zero recent requests.
    • +
    • int ping(int t) Adds a new request at time t, where t represents some time in milliseconds, and returns the number of requests that has happened in the past 3000 milliseconds (including the new request). Specifically, return the number of requests that have happened in the inclusive range [t - 3000, t].
    • +
    -

    Any ping with time in [t - 3000, t] will count, including the current ping.

    - -

    It is guaranteed that every call to ping uses a strictly larger value of t than before.

    +

    It is guaranteed that every call to ping uses a strictly larger value of t than the previous call.

     

    -

    Example 1:

    -Input: inputs = ["RecentCounter","ping","ping","ping","ping"], inputs = [[],[1],[100],[3001],[3002]]
    -Output: [null,1,2,3,3]
    +Input +["RecentCounter", "ping", "ping", "ping", "ping"] +[[], [1], [100], [3001], [3002]] +Output +[null, 1, 2, 3, 3] + +Explanation +RecentCounter recentCounter = new RecentCounter(); +recentCounter.ping(1); // requests = [1], range is [-2999,1], return 1 +recentCounter.ping(100); // requests = [1, 100], range is [-2900,100], return 2 +recentCounter.ping(3001); // requests = [1, 100, 3001], range is [1,3001], return 3 +recentCounter.ping(3002); // requests = [1, 100, 3001, 3002], range is [2,3002], return 3 +

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. Each test case will have at most 10000 calls to ping.
    2. -
    3. Each test case will call ping with strictly increasing values of t.
    4. -
    5. Each call to ping will have 1 <= t <= 10^9.
    6. -
    - -
    -

     

    -
    +
      +
    • 1 <= t <= 104
    • +
    • Each test case will call ping with strictly increasing values of t.
    • +
    • At most 104 calls will be made to ping.
    • +
    ### Related Topics [[Queue](../../tag/queue/README.md)] diff --git a/problems/paint-fence/README.md b/problems/paint-fence/README.md index 03eb7abea..0b17bbdb1 100644 --- a/problems/paint-fence/README.md +++ b/problems/paint-fence/README.md @@ -43,5 +43,5 @@ n and k are non-negative integers.

    ### Similar Questions 1. [House Robber](../house-robber) (Easy) 1. [House Robber II](../house-robber-ii) (Medium) - 1. [Paint House](../paint-house) (Easy) + 1. [Paint House](../paint-house) (Medium) 1. [Paint House II](../paint-house-ii) (Hard) diff --git a/problems/paint-house-ii/README.md b/problems/paint-house-ii/README.md index 4cf6ca2a3..11ae17a5c 100644 --- a/problems/paint-house-ii/README.md +++ b/problems/paint-house-ii/README.md @@ -36,5 +36,5 @@ Could you solve it in O(nk) runtime?

    ### Similar Questions 1. [Product of Array Except Self](../product-of-array-except-self) (Medium) 1. [Sliding Window Maximum](../sliding-window-maximum) (Hard) - 1. [Paint House](../paint-house) (Easy) + 1. [Paint House](../paint-house) (Medium) 1. [Paint Fence](../paint-fence) (Easy) diff --git a/problems/paint-house/README.md b/problems/paint-house/README.md index ca0ca2513..a7582b0d1 100644 --- a/problems/paint-house/README.md +++ b/problems/paint-house/README.md @@ -9,7 +9,7 @@                  [Next >](../binary-tree-paths "Binary Tree Paths") -## [256. Paint House (Easy)](https://leetcode.com/problems/paint-house "粉刷房子") +## [256. Paint House (Medium)](https://leetcode.com/problems/paint-house "粉刷房子")

    There are a row of n houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.

    diff --git a/problems/palindrome-number/README.md b/problems/palindrome-number/README.md index 2fb012ce4..9db9b5d44 100644 --- a/problems/palindrome-number/README.md +++ b/problems/palindrome-number/README.md @@ -38,7 +38,7 @@

    Follow up:

    -

    Coud you solve it without converting the integer to a string?

    +

    Could you solve it without converting the integer to a string?

    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/power-of-two/README.md b/problems/power-of-two/README.md index 4c9067ae3..fabf9b1a2 100644 --- a/problems/power-of-two/README.md +++ b/problems/power-of-two/README.md @@ -11,28 +11,52 @@ ## [231. Power of Two (Easy)](https://leetcode.com/problems/power-of-two "2的幂") -

    Given an integer, write a function to determine if it is a power of two.

    +

    Given an integer n, write a function to determine if it is a power of two.

    +

     

    Example 1:

    -Input: 1
    -Output: true 
    -Explanation: 20 = 1
    +Input: n = 1
    +Output: true
    +Explanation: 20 = 1
     

    Example 2:

    -Input: 16
    +Input: n = 16
     Output: true
    -Explanation: 24 = 16
    +Explanation: 24 = 16 +

    Example 3:

    -Input: 218
    -Output: false
    +Input: n = 3 +Output: false + + +

    Example 4:

    + +
    +Input: n = 4
    +Output: true
    +
    + +

    Example 5:

    + +
    +Input: n = 5
    +Output: false
    +
    + +

     

    +

    Constraints:

    + +
      +
    • -231 <= n <= 231 - 1
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/remove-duplicates-from-sorted-array/README.md b/problems/remove-duplicates-from-sorted-array/README.md index 24e64268b..388c3048d 100644 --- a/problems/remove-duplicates-from-sorted-array/README.md +++ b/problems/remove-duplicates-from-sorted-array/README.md @@ -11,7 +11,7 @@ ## [26. Remove Duplicates from Sorted Array (Easy)](https://leetcode.com/problems/remove-duplicates-from-sorted-array "删除排序数组中的重复项") -

    Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.

    +

    Given a sorted array nums, remove the duplicates in-place such that each element appears only once and returns the new length.

    Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.

    @@ -38,7 +38,7 @@ It doesn't matter what values are set beyond the returned length.

    Confused why the returned value is an integer but your answer is an array?

    -

    Note that the input array is passed in by reference, which means modification to the input array will be known to the caller as well.

    +

    Note that the input array is passed in by reference, which means a modification to the input array will be known to the caller as well.

    Internally you can think of this:

    diff --git a/problems/shortest-completing-word/README.md b/problems/shortest-completing-word/README.md index 045d2ae78..f434ecf5c 100644 --- a/problems/shortest-completing-word/README.md +++ b/problems/shortest-completing-word/README.md @@ -11,43 +11,67 @@ ## [748. Shortest Completing Word (Easy)](https://leetcode.com/problems/shortest-completing-word "最短完整词") -

    -Find the minimum length word from a given dictionary words, which has all the letters from the string licensePlate. Such a word is said to complete the given string licensePlate -

    -Here, for letters we ignore case. For example, "P" on the licensePlate still matches "p" on the word. -

    -It is guaranteed an answer exists. If there are multiple answers, return the one that occurs first in the array. -

    -The license plate might have the same letter occurring multiple times. For example, given a licensePlate of "PP", the word "pair" does not complete the licensePlate, but the word "supper" does. -

    - -

    Example 1:
    +

    Given a string licensePlate and an array of strings words, find the shortest completing word in words.

    + +

    A completing word is a word that contains all the letters in licensePlate. Ignore numbers and spaces in licensePlate, and treat letters as case insensitive. If a letter appears more than once in licensePlate, then it must appear in the word the same number of times or more.

    + +

    For example, if licensePlate = "aBc 12c", then it contains letters 'a', 'b' (ignoring case), and 'c' twice. Possible completing words are "abccdef", "caaacab", and "cbca".

    + +

    Return the shortest completing word in words. It is guaranteed an answer exists. If there are multiple shortest completing words, return the first one that occurs in words.

    + +

     

    +

    Example 1:

    + +
    +Input: licensePlate = "1s3 PSt", words = ["step","steps","stripe","stepple"]
    +Output: "steps"
    +Explanation: licensePlate contains letters 's', 'p', 's' (ignoring case), and 't'.
    +"step" contains 't' and 'p', but only contains 1 's'.
    +"steps" contains 't', 'p', and both 's' characters.
    +"stripe" is missing an 's'.
    +"stepple" is missing an 's'.
    +Since "steps" is the only word containing all the letters, that is the answer.
    +
    + +

    Example 2:

    + +
    +Input: licensePlate = "1s3 456", words = ["looks","pest","stew","show"]
    +Output: "pest"
    +Explanation: licensePlate only contains the letter 's'. All the words contain 's', but among these "pest", "stew", and "show" are shortest. The answer is "pest" because it is the word that appears earliest of the 3.
    +
    + +

    Example 3:

    + +
    +Input: licensePlate = "Ah71752", words = ["suggest","letter","of","husband","easy","education","drug","prevent","writer","old"]
    +Output: "husband"
    +
    + +

    Example 4:

    +
    -Input: licensePlate = "1s3 PSt", words = ["step", "steps", "stripe", "stepple"]
    -Output: "steps"
    -Explanation: The smallest length word that contains the letters "S", "P", "S", and "T".
    -Note that the answer is not "step", because the letter "s" must occur in the word twice.
    -Also note that we ignored case for the purposes of comparing whether a letter exists in the word.
    +Input: licensePlate = "OgEu755", words = ["enough","these","play","wide","wonder","box","arrive","money","tax","thus"]
    +Output: "enough"
     
    -

    -

    Example 2:
    +

    Example 5:

    +
    -Input: licensePlate = "1s3 456", words = ["looks", "pest", "stew", "show"]
    -Output: "pest"
    -Explanation: There are 3 smallest length words that contains the letters "s".
    -We return the one that occurred first.
    +Input: licensePlate = "iMSlpe4", words = ["claim","consumer","student","camera","public","never","wonder","simple","thought","use"]
    +Output: "simple"
     
    -

    - -

    Note:
    -

      -
    1. licensePlate will be a string with length in range [1, 7].
    2. -
    3. licensePlate will contain digits, spaces, or letters (uppercase or lowercase).
    4. -
    5. words will have a length in the range [10, 1000].
    6. -
    7. Every words[i] will consist of lowercase letters, and have length in range [1, 15].
    8. -
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= licensePlate.length <= 7
    • +
    • licensePlate contains digits, letters (uppercase or lowercase), or space ' '.
    • +
    • 1 <= words.length <= 1000
    • +
    • 1 <= words[i].length <= 15
    • +
    • words[i] consists of lower case English letters.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/split-array-into-consecutive-subsequences/README.md b/problems/split-array-into-consecutive-subsequences/README.md index 9f60d7348..9fb907bfb 100644 --- a/problems/split-array-into-consecutive-subsequences/README.md +++ b/problems/split-array-into-consecutive-subsequences/README.md @@ -24,7 +24,6 @@ You can split them into two consecutive subsequences : 1, 2, 3 3, 4, 5 -

    Example 2:

    @@ -36,7 +35,6 @@ You can split them into two consecutive subsequences : You can split them into two consecutive subsequences : 1, 2, 3, 4, 5 3, 4, 5 -

    Example 3:

    diff --git a/problems/sum-of-square-numbers/README.md b/problems/sum-of-square-numbers/README.md index 92227ec87..c481746b5 100644 --- a/problems/sum-of-square-numbers/README.md +++ b/problems/sum-of-square-numbers/README.md @@ -9,28 +9,53 @@                  [Next >](../find-the-derangement-of-an-array "Find the Derangement of An Array") -## [633. Sum of Square Numbers (Easy)](https://leetcode.com/problems/sum-of-square-numbers "平方数之和") +## [633. Sum of Square Numbers (Medium)](https://leetcode.com/problems/sum-of-square-numbers "平方数之和") -

    Given a non-negative integer c, your task is to decide whether there're two integers a and b such that a2 + b2 = c.

    +

    Given a non-negative integer c, decide whether there're two integers a and b such that a2 + b2 = c.

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input: 5
    -Output: True
    -Explanation: 1 * 1 + 2 * 2 = 5
    +Input: c = 5
    +Output: true
    +Explanation: 1 * 1 + 2 * 2 = 5
     
    -

     

    +

    Example 2:

    + +
    +Input: c = 3
    +Output: false
    +
    + +

    Example 3:

    + +
    +Input: c = 4
    +Output: true
    +
    -

    Example 2:

    +

    Example 4:

    -Input: 3
    -Output: False
    +Input: c = 2
    +Output: true
    +
    + +

    Example 5:

    + +
    +Input: c = 1
    +Output: true
     

     

    +

    Constraints:

    + +
      +
    • 0 <= c <= 231 - 1
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/super-pow/README.md b/problems/super-pow/README.md index 1002c7117..3eb705bce 100644 --- a/problems/super-pow/README.md +++ b/problems/super-pow/README.md @@ -11,25 +11,31 @@ ## [372. Super Pow (Medium)](https://leetcode.com/problems/super-pow "超级次方") -

    Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array.

    +

    Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array.

    +

     

    Example 1:

    - -
    -
    -Input: a = 2, b = [3]
    -Output: 8
    -
    - -
    -

    Example 2:

    - -
    -Input: a = 2, b = [1,0]
    -Output: 1024
    +
    Input: a = 2, b = [3]
    +Output: 8
    +

    Example 2:

    +
    Input: a = 2, b = [1,0]
    +Output: 1024
    +

    Example 3:

    +
    Input: a = 1, b = [4,3,3,8,5,2]
    +Output: 1
    +

    Example 4:

    +
    Input: a = 2147483647, b = [2,0,0]
    +Output: 1198
     
    -
    -
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= a <= 231 - 1
    • +
    • 1 <= b.length <= 2000
    • +
    • 0 <= b[i] <= 9
    • +
    • b doesn't contain leading zeros.
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/the-most-frequently-ordered-products-for-each-customer/README.md b/problems/the-most-frequently-ordered-products-for-each-customer/README.md new file mode 100644 index 000000000..8523d7954 --- /dev/null +++ b/problems/the-most-frequently-ordered-products-for-each-customer/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../minimum-cost-to-connect-two-groups-of-points "Minimum Cost to Connect Two Groups of Points") +                 +[Next >](../build-binary-expression-tree-from-infix-expression "Build Binary Expression Tree From Infix Expression") + +## [1596. The Most Frequently Ordered Products for Each Customer (Medium)](https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer "") + + diff --git a/problems/the-most-frequently-ordered-products-for-each-customer/mysql_schemas.sql b/problems/the-most-frequently-ordered-products-for-each-customer/mysql_schemas.sql new file mode 100644 index 000000000..7294b609b --- /dev/null +++ b/problems/the-most-frequently-ordered-products-for-each-customer/mysql_schemas.sql @@ -0,0 +1,25 @@ +Create table If Not Exists Customers (customer_id int, name varchar(10)); +Create table If Not Exists Orders (order_id int, order_date date, customer_id int, product_id int); +Create table If Not Exists Products (product_id int, product_name varchar(20), price int); +Truncate table Customers; +insert into Customers (customer_id, name) values ('1', 'Alice'); +insert into Customers (customer_id, name) values ('2', 'Bob'); +insert into Customers (customer_id, name) values ('3', 'Tom'); +insert into Customers (customer_id, name) values ('4', 'Jerry'); +insert into Customers (customer_id, name) values ('5', 'John'); +Truncate table Orders; +insert into Orders (order_id, order_date, customer_id, product_id) values ('1', '2020-07-31', '1', '1'); +insert into Orders (order_id, order_date, customer_id, product_id) values ('2', '2020-7-30', '2', '2'); +insert into Orders (order_id, order_date, customer_id, product_id) values ('3', '2020-08-29', '3', '3'); +insert into Orders (order_id, order_date, customer_id, product_id) values ('4', '2020-07-29', '4', '1'); +insert into Orders (order_id, order_date, customer_id, product_id) values ('5', '2020-06-10', '1', '2'); +insert into Orders (order_id, order_date, customer_id, product_id) values ('6', '2020-08-01', '2', '1'); +insert into Orders (order_id, order_date, customer_id, product_id) values ('7', '2020-08-01', '3', '3'); +insert into Orders (order_id, order_date, customer_id, product_id) values ('8', '2020-08-03', '1', '2'); +insert into Orders (order_id, order_date, customer_id, product_id) values ('9', '2020-08-07', '2', '3'); +insert into Orders (order_id, order_date, customer_id, product_id) values ('10', '2020-07-15', '1', '2'); +Truncate table Products; +insert into Products (product_id, product_name, price) values ('1', 'keyboard', '120'); +insert into Products (product_id, product_name, price) values ('2', 'mouse', '80'); +insert into Products (product_id, product_name, price) values ('3', 'screen', '600'); +insert into Products (product_id, product_name, price) values ('4', 'hard disk', '450'); diff --git a/problems/the-most-recent-orders-for-each-product/README.md b/problems/the-most-recent-orders-for-each-product/README.md index 812900ece..c1fff2051 100644 --- a/problems/the-most-recent-orders-for-each-product/README.md +++ b/problems/the-most-recent-orders-for-each-product/README.md @@ -9,6 +9,6 @@                  [Next >](../three-consecutive-odds "Three Consecutive Odds") -## [1549. The Most Recent Orders for Each Product (Medium)](https://leetcode.com/problems/the-most-recent-orders-for-each-product "") +## [1549. The Most Recent Orders for Each Product (Medium)](https://leetcode.com/problems/the-most-recent-orders-for-each-product "每件商品的最新订单") diff --git a/problems/throne-inheritance/README.md b/problems/throne-inheritance/README.md new file mode 100644 index 000000000..d19545da8 --- /dev/null +++ b/problems/throne-inheritance/README.md @@ -0,0 +1,101 @@ + + + + + + + +[< Previous](../maximum-profit-of-operating-a-centennial-wheel "Maximum Profit of Operating a Centennial Wheel") +                 +[Next >](../maximum-number-of-achievable-transfer-requests "Maximum Number of Achievable Transfer Requests") + +## [1600. Throne Inheritance (Medium)](https://leetcode.com/problems/throne-inheritance "皇位继承顺序") + +

    A kingdom consists of a king, his children, his grandchildren, and so on. Every once in a while, someone in the family dies or a child is born.

    + +

    The kingdom has a well-defined order of inheritance that consists of the king as the first member. Let's define the recursive function Successor(x, curOrder), which given a person x and the inheritance order so far, returns who should be the next person after x in the order of inheritance.

    + +
    +Successor(x, curOrder):
    +    if x has no children or all of x's children are in curOrder:
    +        if x is the king return null
    +        else return Successor(x's parent, curOrder)
    +    else return x's oldest child who's not in curOrder
    +
    + +

    For example, assume we have a kingdom that consists of the king, his children Alice and Bob (Alice is older than Bob), and finally Alice's son Jack.

    + +
      +
    1. In the beginning, curOrder will be ["king"].
    2. +
    3. Calling Successor(king, curOrder) will return Alice, so we append to curOrder to get ["king", "Alice"].
    4. +
    5. Calling Successor(Alice, curOrder) will return Jack, so we append to curOrder to get ["king", "Alice", "Jack"].
    6. +
    7. Calling Successor(Jack, curOrder) will return Bob, so we append to curOrder to get ["king", "Alice", "Jack", "Bob"].
    8. +
    9. Calling Successor(Bob, curOrder) will return null. Thus the order of inheritance will be ["king", "Alice", "Jack", "Bob"].
    10. +
    + +

    Using the above function, we can always obtain a unique order of inheritance.

    + +

    Implement the ThroneInheritance class:

    + +
      +
    • ThroneInheritance(string kingName) Initializes an object of the ThroneInheritance class. The name of the king is given as part of the constructor.
    • +
    • void birth(string parentName, string childName) Indicates that parentName gave birth to childName.
    • +
    • void death(string name) Indicates the death of name. The death of the person doesn't affect the Successor function nor the current inheritance order. You can treat it as just marking the person as dead.
    • +
    • string[] getInheritanceOrder() Returns a list representing the current order of inheritance excluding dead people.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input
    +["ThroneInheritance", "birth", "birth", "birth", "birth", "birth", "birth", "getInheritanceOrder", "death", "getInheritanceOrder"]
    +[["king"], ["king", "andy"], ["king", "bob"], ["king", "catherine"], ["andy", "matthew"], ["bob", "alex"], ["bob", "asha"], [null], ["bob"], [null]]
    +Output
    +[null, null, null, null, null, null, null, ["king", "andy", "matthew", "bob", "alex", "asha", "catherine"], null, ["king", "andy", "matthew", "alex", "asha", "catherine"]]
    +
    +Explanation
    +ThroneInheritance t= new ThroneInheritance("king"); // order: king
    +t.birth("king", "andy"); // order: king > andy
    +t.birth("king", "bob"); // order: king > andy > bob
    +t.birth("king", "catherine"); // order: king > andy > bob > catherine
    +t.birth("andy", "matthew"); // order: king > andy > matthew > bob > catherine
    +t.birth("bob", "alex"); // order: king > andy > matthew > bob > alex > catherine
    +t.birth("bob", "asha"); // order: king > andy > matthew > bob > alex > asha > catherine
    +t.getInheritanceOrder(); // return ["king", "andy", "matthew", "bob", "alex", "asha", "catherine"]
    +t.death("bob"); // order: king > andy > matthew > bob > alex > asha > catherine
    +t.getInheritanceOrder(); // return ["king", "andy", "matthew", "alex", "asha", "catherine"]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= kingName.length, parentName.length, childName.length, name.length <= 15
    • +
    • kingName, parentName, childName, and name consist of lowercase English letters only.
    • +
    • All arguments childName and kingName are distinct.
    • +
    • All name arguments of death will be passed to either the constructor or as childName to birth first.
    • +
    • For each call to birth(parentName, childName), it is guaranteed that parentName is alive.
    • +
    • At most 105 calls will be made to birth and death.
    • +
    • At most 10 calls will be made to getInheritanceOrder.
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Design](../../tag/design/README.md)] + +### Hints +
    +Hint 1 +Create a tree structure of the family. +
    + +
    +Hint 2 +Without deaths, the order of inheritance is simply a pre-order traversal of the tree. +
    + +
    +Hint 3 +Mark the dead family members tree nodes and don't include them in the final order. +
    diff --git a/problems/two-sum-iv-input-is-a-bst/README.md b/problems/two-sum-iv-input-is-a-bst/README.md index 17ca798cf..cb1473fad 100644 --- a/problems/two-sum-iv-input-is-a-bst/README.md +++ b/problems/two-sum-iv-input-is-a-bst/README.md @@ -11,41 +11,53 @@ ## [653. Two Sum IV - Input is a BST (Easy)](https://leetcode.com/problems/two-sum-iv-input-is-a-bst "两数之和 IV - 输入 BST") -

    Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target.

    +

    Given the root of a Binary Search Tree and a target number k, return true if there exist two elements in the BST such that their sum is equal to the given target.

    -

    Example 1:

    +

     

    +

    Example 1:

    + +
    +Input: root = [5,3,6,2,4,null,7], k = 9
    +Output: true
    +
    +

    Example 2:

    +
    -Input: 
    -    5
    -   / \
    -  3   6
    - / \   \
    -2   4   7
    +Input: root = [5,3,6,2,4,null,7], k = 28
    +Output: false
    +
    -Target = 9 +

    Example 3:

    -Output: True +
    +Input: root = [2,1,3], k = 4
    +Output: true
     
    -

     

    - -

    Example 2:

    +

    Example 4:

    -Input: 
    -    5
    -   / \
    -  3   6
    - / \   \
    -2   4   7
    +Input: root = [2,1,3], k = 1
    +Output: false
    +
    -Target = 28 +

    Example 5:

    -Output: False +
    +Input: root = [2,1,3], k = 3
    +Output: true
     

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [1, 104].
    • +
    • -104 <= Node.val <= 104
    • +
    • root is guaranteed to be a valid binary search tree.
    • +
    • -105 <= k <= 105
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/valid-perfect-square/README.md b/problems/valid-perfect-square/README.md index 0ba60992e..d014f8517 100644 --- a/problems/valid-perfect-square/README.md +++ b/problems/valid-perfect-square/README.md @@ -36,4 +36,4 @@ ### Similar Questions 1. [Sqrt(x)](../sqrtx) (Easy) - 1. [Sum of Square Numbers](../sum-of-square-numbers) (Easy) + 1. [Sum of Square Numbers](../sum-of-square-numbers) (Medium) diff --git a/problems/warehouse-manager/README.md b/problems/warehouse-manager/README.md index 53f250028..8447ac8ca 100644 --- a/problems/warehouse-manager/README.md +++ b/problems/warehouse-manager/README.md @@ -9,6 +9,6 @@                  [Next >](../matrix-diagonal-sum "Matrix Diagonal Sum") -## [1571. Warehouse Manager (Easy)](https://leetcode.com/problems/warehouse-manager "") +## [1571. Warehouse Manager (Easy)](https://leetcode.com/problems/warehouse-manager "仓库经理") diff --git a/readme/1-300.md b/readme/1-300.md index 1da5f9a93..82c772a6e 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -325,7 +325,7 @@ LeetCode Problems' Solutions | 253 | [Meeting Rooms II](https://leetcode.com/problems/meeting-rooms-ii "会议室 II") 🔒 | [Go](../problems/meeting-rooms-ii) | Medium | | 254 | [Factor Combinations](https://leetcode.com/problems/factor-combinations "因子的组合") 🔒 | [Go](../problems/factor-combinations) | Medium | | 255 | [Verify Preorder Sequence in Binary Search Tree](https://leetcode.com/problems/verify-preorder-sequence-in-binary-search-tree "验证前序遍历序列二叉搜索树") 🔒 | [Go](../problems/verify-preorder-sequence-in-binary-search-tree) | Medium | -| 256 | [Paint House](https://leetcode.com/problems/paint-house "粉刷房子") 🔒 | [Go](../problems/paint-house) | Easy | +| 256 | [Paint House](https://leetcode.com/problems/paint-house "粉刷房子") 🔒 | [Go](../problems/paint-house) | Medium | | 257 | [Binary Tree Paths](https://leetcode.com/problems/binary-tree-paths "二叉树的所有路径") | [Go](../problems/binary-tree-paths) | Easy | | 258 | [Add Digits](https://leetcode.com/problems/add-digits "各位相加") | [Go](../problems/add-digits) | Easy | | 259 | [3Sum Smaller](https://leetcode.com/problems/3sum-smaller "较小的三数之和") 🔒 | [Go](../problems/3sum-smaller) | Medium | diff --git a/readme/301-600.md b/readme/301-600.md index 4361ac502..df6d078a2 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -307,7 +307,7 @@ LeetCode Problems' Solutions | 535 | [Encode and Decode TinyURL](https://leetcode.com/problems/encode-and-decode-tinyurl "TinyURL 的加密与解密") | [Go](../problems/encode-and-decode-tinyurl) | Medium | | 536 | [Construct Binary Tree from String](https://leetcode.com/problems/construct-binary-tree-from-string "从字符串生成二叉树") 🔒 | [Go](../problems/construct-binary-tree-from-string) | Medium | | 537 | [Complex Number Multiplication](https://leetcode.com/problems/complex-number-multiplication "复数乘法") | [Go](../problems/complex-number-multiplication) | Medium | -| 538 | [Convert BST to Greater Tree](https://leetcode.com/problems/convert-bst-to-greater-tree "把二叉搜索树转换为累加树") | [Go](../problems/convert-bst-to-greater-tree) | Easy | +| 538 | [Convert BST to Greater Tree](https://leetcode.com/problems/convert-bst-to-greater-tree "把二叉搜索树转换为累加树") | [Go](../problems/convert-bst-to-greater-tree) | Medium | | 539 | [Minimum Time Difference](https://leetcode.com/problems/minimum-time-difference "最小时间差") | [Go](../problems/minimum-time-difference) | Medium | | 540 | [Single Element in a Sorted Array](https://leetcode.com/problems/single-element-in-a-sorted-array "有序数组中的单一元素") | [Go](../problems/single-element-in-a-sorted-array) | Medium | | 541 | [Reverse String II](https://leetcode.com/problems/reverse-string-ii "反转字符串 II") | [Go](../problems/reverse-string-ii) | Easy | diff --git a/readme/601-900.md b/readme/601-900.md index 86efcc8ca..3fa67f6a7 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -102,7 +102,7 @@ LeetCode Problems' Solutions | 630 | [Course Schedule III](https://leetcode.com/problems/course-schedule-iii "课程表 III") | [Go](../problems/course-schedule-iii) | Hard | | 631 | [Design Excel Sum Formula](https://leetcode.com/problems/design-excel-sum-formula "设计 Excel 求和公式") 🔒 | [Go](../problems/design-excel-sum-formula) | Hard | | 632 | [Smallest Range Covering Elements from K Lists](https://leetcode.com/problems/smallest-range-covering-elements-from-k-lists "最小区间") | [Go](../problems/smallest-range-covering-elements-from-k-lists) | Hard | -| 633 | [Sum of Square Numbers](https://leetcode.com/problems/sum-of-square-numbers "平方数之和") | [Go](../problems/sum-of-square-numbers) | Easy | +| 633 | [Sum of Square Numbers](https://leetcode.com/problems/sum-of-square-numbers "平方数之和") | [Go](../problems/sum-of-square-numbers) | Medium | | 634 | [Find the Derangement of An Array](https://leetcode.com/problems/find-the-derangement-of-an-array "寻找数组的错位排列") 🔒 | [Go](../problems/find-the-derangement-of-an-array) | Medium | | 635 | [Design Log Storage System](https://leetcode.com/problems/design-log-storage-system "设计日志存储系统") 🔒 | [Go](../problems/design-log-storage-system) | Medium | | 636 | [Exclusive Time of Functions](https://leetcode.com/problems/exclusive-time-of-functions "函数的独占时间") | [Go](../problems/exclusive-time-of-functions) | Medium | diff --git a/readme/901-1200.md b/readme/901-1200.md index 78cd451c0..5b8bd5db4 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -207,7 +207,7 @@ LeetCode Problems' Solutions | 1035 | [Uncrossed Lines](https://leetcode.com/problems/uncrossed-lines "不相交的线") | [Go](../problems/uncrossed-lines) | Medium | | 1036 | [Escape a Large Maze](https://leetcode.com/problems/escape-a-large-maze "逃离大迷宫") | [Go](../problems/escape-a-large-maze) | Hard | | 1037 | [Valid Boomerang](https://leetcode.com/problems/valid-boomerang "有效的回旋镖") | [Go](../problems/valid-boomerang) | Easy | -| 1038 | [Binary Search Tree to Greater Sum Tree](https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree "从二叉搜索树到更大和树") | [Go](../problems/binary-search-tree-to-greater-sum-tree) | Medium | +| 1038 | [Binary Search Tree to Greater Sum Tree](https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree "把二叉搜索树转换为累加树") | [Go](../problems/binary-search-tree-to-greater-sum-tree) | Medium | | 1039 | [Minimum Score Triangulation of Polygon](https://leetcode.com/problems/minimum-score-triangulation-of-polygon "多边形三角剖分的最低得分") | [Go](../problems/minimum-score-triangulation-of-polygon) | Medium | | 1040 | [Moving Stones Until Consecutive II](https://leetcode.com/problems/moving-stones-until-consecutive-ii "移动石子直到连续 II") | [Go](../problems/moving-stones-until-consecutive-ii) | Medium | | 1041 | [Robot Bounded In Circle](https://leetcode.com/problems/robot-bounded-in-circle "困于环中的机器人") | [Go](../problems/robot-bounded-in-circle) | Medium | diff --git a/tag/array/README.md b/tag/array/README.md index a17ea1971..17e49de9d 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -29,7 +29,7 @@ | 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1503 | [所有蚂蚁掉下来前的最后一刻](../../problems/last-moment-before-all-ants-fall-out-of-a-plank) | [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] | Medium | | 1502 | [判断能否形成等差数列](../../problems/can-make-arithmetic-progression-from-sequence) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1500 | [Design a File Sharing System](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1493 | [删掉一个元素以后全为 1 的最长子数组](../../problems/longest-subarray-of-1s-after-deleting-one-element) | [[数组](../array/README.md)] | Medium | diff --git a/tag/binary-search-tree/README.md b/tag/binary-search-tree/README.md index d5e801079..0d508d4e1 100644 --- a/tag/binary-search-tree/README.md +++ b/tag/binary-search-tree/README.md @@ -12,4 +12,4 @@ | 1382 | [将二叉搜索树变平衡](../../problems/balance-a-binary-search-tree) | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | | 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | -| 1038 | [从二叉搜索树到更大和树](../../problems/binary-search-tree-to-greater-sum-tree) | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | +| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 5742a81f5..0a1b4a039 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -13,7 +13,7 @@ | 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1562 | [查找大小为 M 的最新分组](../../problems/find-latest-group-of-size-m) | [[二分查找](../binary-search/README.md)] | Medium | | 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1533 | [Find the Index of the Large Integer](../../problems/find-the-index-of-the-large-integer) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | +| 1533 | [找到最大整数的索引](../../problems/find-the-index-of-the-large-integer) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | | 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1482 | [制作 m 束花所需的最少天数](../../problems/minimum-number-of-days-to-make-m-bouquets) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | diff --git a/tag/design/README.md b/tag/design/README.md index 12a9d71b0..bdcad51b6 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,8 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1586 | [Binary Search Tree Iterator II](../../problems/binary-search-tree-iterator-ii) | [[设计](../design/README.md)] | Medium | -| 1500 | [Design a File Sharing System](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[设计](../design/README.md)] | Medium | +| 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[设计](../design/README.md)] | Medium | | 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 90defc1d5..0c7000d85 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -199,7 +200,7 @@ | 276 | [栅栏涂色](../../problems/paint-fence) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Easy | | 265 | [粉刷房子 II](../../problems/paint-house-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | | 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 256 | [粉刷房子](../../problems/paint-house) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Easy | +| 256 | [粉刷房子](../../problems/paint-house) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | | 221 | [最大正方形](../../problems/maximal-square) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 213 | [打家劫舍 II](../../problems/house-robber-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 198 | [打家劫舍](../../problems/house-robber) | [[动态规划](../dynamic-programming/README.md)] | Easy | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index d360f6dc9..a9e6149dc 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1599 | [经营摩天轮的最大利润](../../problems/maximum-profit-of-operating-a-centennial-wheel) | [[贪心算法](../greedy/README.md)] | Medium | | 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1591 | [奇怪的打印机 II](../../problems/strange-printer-ii) | [[贪心算法](../greedy/README.md)] | Hard | | 1589 | [所有排列中的最大和](../../problems/maximum-sum-obtained-of-any-permutation) | [[贪心算法](../greedy/README.md)] | Medium | @@ -21,7 +22,7 @@ | 1558 | [得到目标数组的最少函数调用次数](../../problems/minimum-numbers-of-function-calls-to-make-target-array) | [[贪心算法](../greedy/README.md)] | Medium | | 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心算法](../greedy/README.md)] | Medium | -| 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心算法](../greedy/README.md)] | Medium | +| 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心算法](../greedy/README.md)] | Hard | | 1518 | [换酒问题](../../problems/water-bottles) | [[贪心算法](../greedy/README.md)] | Easy | | 1505 | [最多 K 次交换相邻数位后得到的最小整数](../../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | [[贪心算法](../greedy/README.md)] | Hard | | 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 9d2077687..cad6066d4 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -123,7 +123,7 @@ | 645 | [错误的集合](../../problems/set-mismatch) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | | 640 | [求解方程](../../problems/solve-the-equation) | [[数学](../math/README.md)] | Medium | | 634 | [寻找数组的错位排列](../../problems/find-the-derangement-of-an-array) 🔒 | [[数学](../math/README.md)] | Medium | -| 633 | [平方数之和](../../problems/sum-of-square-numbers) | [[数学](../math/README.md)] | Easy | +| 633 | [平方数之和](../../problems/sum-of-square-numbers) | [[数学](../math/README.md)] | Medium | | 628 | [三个数的最大乘积](../../problems/maximum-product-of-three-numbers) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 598 | [范围求和 II](../../problems/range-addition-ii) | [[数学](../math/README.md)] | Easy | diff --git a/tag/stack/README.md b/tag/stack/README.md index b18c210d0..ab5a7c9c5 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1598 | [文件夹操作日志搜集器](../../problems/crawler-log-folder) | [[栈](../stack/README.md)] | Easy | | 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | | 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | | 1441 | [用栈操作构建数组](../../problems/build-an-array-with-stack-operations) | [[栈](../stack/README.md)] | Easy | diff --git a/tag/string/README.md b/tag/string/README.md index 76d8fd9dd..9487dba8e 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1597 | [Build Binary Expression Tree From Infix Expression](../../problems/build-binary-expression-tree-from-infix-expression) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | | 1592 | [重新排列单词间的空格](../../problems/rearrange-spaces-between-words) | [[字符串](../string/README.md)] | Easy | | 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | | 1576 | [替换所有的问号](../../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | [[字符串](../string/README.md)] | Easy | diff --git a/tag/tree/README.md b/tag/tree/README.md index b42ee45c4..135682ce8 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 1597 | [Build Binary Expression Tree From Infix Expression](../../problems/build-binary-expression-tree-from-infix-expression) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | | 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1516 | [移动 N 叉树的子树](../../problems/move-sub-tree-of-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | @@ -90,7 +92,7 @@ | 549 | [二叉树中最长的连续序列](../../problems/binary-tree-longest-consecutive-sequence-ii) 🔒 | [[树](../tree/README.md)] | Medium | | 545 | [二叉树的边界](../../problems/boundary-of-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | | 543 | [二叉树的直径](../../problems/diameter-of-binary-tree) | [[树](../tree/README.md)] | Easy | -| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] | Easy | +| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] | Medium | | 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | | 530 | [二叉搜索树的最小绝对差](../../problems/minimum-absolute-difference-in-bst) | [[树](../tree/README.md)] | Easy | | 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | From 4bd03779943afa58005054dd43e9dad8ee0af3b4 Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 29 Sep 2020 11:23:05 +0800 Subject: [PATCH 102/145] A: Maximum Score After Splitting a String --- .../maximum_score_after_splitting_a_string.go | 20 +++++++++++ ...mum_score_after_splitting_a_string_test.go | 35 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 problems/maximum-score-after-splitting-a-string/maximum_score_after_splitting_a_string.go create mode 100644 problems/maximum-score-after-splitting-a-string/maximum_score_after_splitting_a_string_test.go diff --git a/problems/maximum-score-after-splitting-a-string/maximum_score_after_splitting_a_string.go b/problems/maximum-score-after-splitting-a-string/maximum_score_after_splitting_a_string.go new file mode 100644 index 000000000..d889bf61f --- /dev/null +++ b/problems/maximum-score-after-splitting-a-string/maximum_score_after_splitting_a_string.go @@ -0,0 +1,20 @@ +package problem1422 + +import "strings" + +func maxScore(s string) int { + ans := 0 + n0 := 0 + n1 := strings.Count(s, "1") + for _, v := range s[:len(s)-1] { + if v == '1' { + n1-- + } else { + n0++ + } + if ans < n0+n1 { + ans = n0 + n1 + } + } + return ans +} diff --git a/problems/maximum-score-after-splitting-a-string/maximum_score_after_splitting_a_string_test.go b/problems/maximum-score-after-splitting-a-string/maximum_score_after_splitting_a_string_test.go new file mode 100644 index 000000000..87dddd3da --- /dev/null +++ b/problems/maximum-score-after-splitting-a-string/maximum_score_after_splitting_a_string_test.go @@ -0,0 +1,35 @@ +package problem1422 + +import "testing" + +type testType struct { + in string + want int +} + +func TestMaxScore(t *testing.T) { + tests := [...]testType{ + { + in: "011101", + want: 5, + }, + { + in: "00111", + want: 5, + }, + { + in: "1111", + want: 3, + }, + { + in: "000000", + want: 5, + }, + } + for _, tt := range tests { + got := maxScore(tt.in) + if got != tt.want { + t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want) + } + } +} From 9c41652f1b63419cb0f7628f4eb9156cb9ef139f Mon Sep 17 00:00:00 2001 From: Shuo Date: Sat, 10 Oct 2020 10:23:16 +0800 Subject: [PATCH 103/145] A: new --- README.md | 25 +++-- problems/4sum/README.md | 32 +++--- problems/active-users/README.md | 2 +- problems/add-two-numbers/README.md | 34 ++++++- .../README.md | 75 ++++++++++++++ .../all-paths-from-source-to-target/README.md | 57 ++++++++--- problems/array-of-doubled-pairs/README.md | 42 +++----- problems/balanced-binary-tree/README.md | 41 ++++---- problems/baseball-game/README.md | 92 ++++++++++-------- problems/binary-gap/README.md | 76 ++++++--------- .../README.md | 6 +- .../binary-search-tree-iterator-ii/README.md | 1 + problems/buddy-strings/README.md | 40 ++++---- .../README.md | 2 +- problems/champagne-tower/README.md | 39 +++++--- .../README.md | 29 ++++++ problems/coin-change/README.md | 2 +- problems/combination-sum/README.md | 56 ++++++----- .../README.md | 2 +- problems/construct-the-rectangle/README.md | 62 ++++++++---- problems/container-with-most-water/README.md | 40 ++++++-- .../copy-list-with-random-pointer/README.md | 2 +- .../README.md | 2 +- problems/decode-ways/README.md | 35 ++++++- problems/design-parking-system/README.md | 57 +++++++++++ problems/divide-two-integers/README.md | 31 +++++- .../README.md | 2 +- problems/escape-the-ghosts/README.md | 64 +++++++----- problems/evaluate-division/README.md | 18 ++-- problems/even-odd-tree/README.md | 93 ++++++++++++++++++ .../README.md | 33 +++---- .../README.md | 39 ++++++++ .../README.md | 97 +++++++++++++++++++ problems/find-the-difference/README.md | 49 +++++++--- .../README.md | 85 ++++++++++++++++ .../README.md | 55 ++++------- problems/generate-parentheses/README.md | 28 +++--- .../guess-number-higher-or-lower/README.md | 14 +-- problems/heaters/README.md | 47 ++++----- problems/house-robber-ii/README.md | 30 ++++-- .../implement-queue-using-stacks/README.md | 52 +++++++--- .../implement-stack-using-queues/README.md | 52 +++++++--- problems/implement-strstr/README.md | 30 +++--- .../README.md | 49 ++++------ problems/integer-to-roman/README.md | 34 ++++--- problems/k-diff-pairs-in-an-array/README.md | 78 +++++++++------ .../kth-largest-element-in-a-stream/README.md | 46 ++++++--- problems/largest-number/README.md | 36 +++++-- .../README.md | 33 +++++-- problems/longest-common-prefix/README.md | 14 ++- .../longest-palindromic-substring/README.md | 29 +++++- problems/longest-valid-parentheses/README.md | 24 ++++- problems/maximum-distance-in-arrays/README.md | 2 +- .../README.md | 30 +++--- .../README.md | 2 +- .../README.md | 82 ++++++++++++++++ .../README.md | 6 +- problems/merge-two-sorted-lists/README.md | 30 +++++- .../README.md | 2 +- .../minimum-index-sum-of-two-lists/README.md | 71 ++++++++------ .../README.md | 52 ++++++++-- .../README.md | 87 +++++++++++++++++ problems/missing-number/README.md | 46 +++++++-- problems/next-permutation/README.md | 34 +++++-- problems/nim-game/README.md | 48 +++++++-- problems/number-of-1-bits/README.md | 10 +- problems/number-of-atoms/README.md | 83 ++++++++-------- problems/number-of-recent-calls/README.md | 2 +- problems/palindrome-number/README.md | 23 ++++- problems/perfect-number/README.md | 56 ++++++++--- .../put-boxes-into-the-warehouse-i/README.md | 2 +- problems/range-addition-ii/README.md | 68 ++++++------- problems/rectangle-overlap/README.md | 43 ++++---- .../regular-expression-matching/README.md | 48 ++++----- problems/remove-covered-intervals/README.md | 39 +++++++- problems/remove-duplicate-letters/README.md | 34 +++++-- .../README.md | 34 +++++-- .../README.md | 8 +- problems/reverse-bits/README.md | 42 ++++---- problems/reverse-integer/README.md | 34 +++---- problems/reverse-nodes-in-k-group/README.md | 44 +++++++-- .../reverse-words-in-a-string-ii/README.md | 2 +- problems/reverse-words-in-a-string/README.md | 50 +++++++--- problems/roman-to-integer/README.md | 36 ++++--- problems/rotate-array/README.md | 8 +- problems/rotate-list/README.md | 2 +- problems/search-a-2d-matrix/README.md | 41 ++++---- problems/search-insert-position/README.md | 45 ++++----- problems/sellers-with-no-sales/README.md | 14 +++ .../sellers-with-no-sales/mysql_schemas.sql | 19 ++++ .../serialize-and-deserialize-bst/README.md | 21 +++- problems/shortest-completing-word/README.md | 2 +- .../README.md | 46 ++++++--- problems/single-number/README.md | 30 +++--- .../README.md | 46 +++------ .../README.md | 76 +++++++++++++++ problems/string-to-integer-atoi/README.md | 36 ++++--- problems/sudoku-solver/README.md | 27 ++++-- problems/summary-ranges/README.md | 65 +++++++++++-- problems/swap-adjacent-in-lr-string/README.md | 23 ++++- problems/swap-nodes-in-pairs/README.md | 28 +++++- .../README.md | 2 +- problems/trim-a-binary-search-tree/README.md | 6 +- .../README.md | 2 +- problems/valid-sudoku/README.md | 72 +++++++------- problems/zigzag-conversion/README.md | 28 +++++- readme/1-300.md | 2 +- readme/301-600.md | 8 +- readme/601-900.md | 4 +- readme/901-1200.md | 2 +- tag/README.md | 4 +- tag/array/README.md | 11 ++- tag/backtracking/README.md | 1 + tag/binary-search/README.md | 2 +- tag/bit-manipulation/README.md | 1 + tag/breadth-first-search/README.md | 2 + tag/depth-first-search/README.md | 1 + tag/design/README.md | 4 +- tag/dynamic-programming/README.md | 3 +- tag/geometry/README.md | 1 + tag/graph/README.md | 4 +- tag/greedy/README.md | 9 +- tag/hash-table/README.md | 7 +- tag/heap/README.md | 2 +- tag/line-sweep/README.md | 2 +- tag/math/README.md | 1 + tag/ordered-map/README.md | 2 + tag/sort/README.md | 2 + tag/stack/README.md | 3 +- tag/string/README.md | 6 +- tag/tags.json | 20 ++-- tag/tree/README.md | 9 +- tag/two-pointers/README.md | 5 +- 133 files changed, 2764 insertions(+), 1156 deletions(-) create mode 100644 problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md create mode 100644 problems/check-if-two-expression-trees-are-equivalent/README.md create mode 100644 problems/design-parking-system/README.md create mode 100644 problems/even-odd-tree/README.md create mode 100644 problems/find-nearest-right-node-in-binary-tree/README.md create mode 100644 problems/find-servers-that-handled-most-number-of-requests/README.md create mode 100644 problems/find-valid-matrix-given-row-and-column-sums/README.md create mode 100644 problems/maximum-number-of-visible-points/README.md create mode 100644 problems/minimum-one-bit-operations-to-make-integers-zero/README.md create mode 100644 problems/sellers-with-no-sales/README.md create mode 100644 problems/sellers-with-no-sales/mysql_schemas.sql create mode 100644 problems/special-array-with-x-elements-greater-than-or-equal-x/README.md diff --git a/README.md b/README.md index a9f7ed68d..ff6ec6210 100644 --- a/README.md +++ b/README.md @@ -70,11 +70,22 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1612 | [Check If Two Expression Trees are Equivalent](https://leetcode.com/problems/check-if-two-expression-trees-are-equivalent) 🔒 | [Go](problems/check-if-two-expression-trees-are-equivalent) | Medium | +| 1611 | [Minimum One Bit Operations to Make Integers Zero](https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero "使整数变为 0 的最少操作次数") | [Go](problems/minimum-one-bit-operations-to-make-integers-zero) | Hard | +| 1610 | [Maximum Number of Visible Points](https://leetcode.com/problems/maximum-number-of-visible-points "可见点的最大数目") | [Go](problems/maximum-number-of-visible-points) | Hard | +| 1609 | [Even Odd Tree](https://leetcode.com/problems/even-odd-tree "奇偶树") | [Go](problems/even-odd-tree) | Medium | +| 1608 | [Special Array With X Elements Greater Than or Equal X](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x "特殊数组的特征值") | [Go](problems/special-array-with-x-elements-greater-than-or-equal-x) | Easy | +| 1607 | [Sellers With No Sales](https://leetcode.com/problems/sellers-with-no-sales) 🔒 | [MySQL](problems/sellers-with-no-sales) | Easy | +| 1606 | [Find Servers That Handled Most Number of Requests](https://leetcode.com/problems/find-servers-that-handled-most-number-of-requests "找到处理最多请求的服务器") | [Go](problems/find-servers-that-handled-most-number-of-requests) | Hard | +| 1605 | [Find Valid Matrix Given Row and Column Sums](https://leetcode.com/problems/find-valid-matrix-given-row-and-column-sums "给定行和列的和求可行矩阵") | [Go](problems/find-valid-matrix-given-row-and-column-sums) | Medium | +| 1604 | [Alert Using Same Key-Card Three or More Times in a One Hour Period](https://leetcode.com/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period "警告一小时内使用相同员工卡大于等于三次的人") | [Go](problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | Medium | +| 1603 | [Design Parking System](https://leetcode.com/problems/design-parking-system "设计停车系统") | [Go](problems/design-parking-system) | Easy | +| 1602 | [Find Nearest Right Node in Binary Tree](https://leetcode.com/problems/find-nearest-right-node-in-binary-tree) 🔒 | [Go](problems/find-nearest-right-node-in-binary-tree) | Medium | | 1601 | [Maximum Number of Achievable Transfer Requests](https://leetcode.com/problems/maximum-number-of-achievable-transfer-requests "最多可达成的换楼请求数目") | [Go](problems/maximum-number-of-achievable-transfer-requests) | Hard | | 1600 | [Throne Inheritance](https://leetcode.com/problems/throne-inheritance "皇位继承顺序") | [Go](problems/throne-inheritance) | Medium | | 1599 | [Maximum Profit of Operating a Centennial Wheel](https://leetcode.com/problems/maximum-profit-of-operating-a-centennial-wheel "经营摩天轮的最大利润") | [Go](problems/maximum-profit-of-operating-a-centennial-wheel) | Medium | | 1598 | [Crawler Log Folder](https://leetcode.com/problems/crawler-log-folder "文件夹操作日志搜集器") | [Go](problems/crawler-log-folder) | Easy | -| 1597 | [Build Binary Expression Tree From Infix Expression](https://leetcode.com/problems/build-binary-expression-tree-from-infix-expression) 🔒 | [Go](problems/build-binary-expression-tree-from-infix-expression) | Medium | +| 1597 | [Build Binary Expression Tree From Infix Expression](https://leetcode.com/problems/build-binary-expression-tree-from-infix-expression "根据中缀表达式构造二叉表达式树") 🔒 | [Go](problems/build-binary-expression-tree-from-infix-expression) | Hard | | 1596 | [The Most Frequently Ordered Products for Each Customer](https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer) 🔒 | [MySQL](problems/the-most-frequently-ordered-products-for-each-customer) | Medium | | 1595 | [Minimum Cost to Connect Two Groups of Points](https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points "连通两组点的最小成本") | [Go](problems/minimum-cost-to-connect-two-groups-of-points) | Hard | | 1594 | [Maximum Non Negative Product in a Matrix](https://leetcode.com/problems/maximum-non-negative-product-in-a-matrix "矩阵的最大非负积") | [Go](problems/maximum-non-negative-product-in-a-matrix) | Medium | @@ -90,7 +101,7 @@ LeetCode Problems' Solutions | 1584 | [Min Cost to Connect All Points](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") | [Go](problems/min-cost-to-connect-all-points) | Medium | | 1583 | [Count Unhappy Friends](https://leetcode.com/problems/count-unhappy-friends "统计不开心的朋友") | [Go](problems/count-unhappy-friends) | Medium | | 1582 | [Special Positions in a Binary Matrix](https://leetcode.com/problems/special-positions-in-a-binary-matrix "二进制矩阵中的特殊位置") | [Go](problems/special-positions-in-a-binary-matrix) | Easy | -| 1581 | [Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions) 🔒 | [MySQL](problems/customer-who-visited-but-did-not-make-any-transactions) | Easy | +| 1581 | [Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的客户") 🔒 | [MySQL](problems/customer-who-visited-but-did-not-make-any-transactions) | Easy | | 1580 | [Put Boxes Into the Warehouse II](https://leetcode.com/problems/put-boxes-into-the-warehouse-ii) 🔒 | [Go](problems/put-boxes-into-the-warehouse-ii) | Medium | | 1579 | [Remove Max Number of Edges to Keep Graph Fully Traversable](https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable "保证图可完全遍历") | [Go](problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | Hard | | 1578 | [Minimum Deletion Cost to Avoid Repeating Letters](https://leetcode.com/problems/minimum-deletion-cost-to-avoid-repeating-letters "避免重复字母的最小删除成本") | [Go](problems/minimum-deletion-cost-to-avoid-repeating-letters) | Medium | @@ -101,13 +112,13 @@ LeetCode Problems' Solutions | 1573 | [Number of Ways to Split a String](https://leetcode.com/problems/number-of-ways-to-split-a-string "分割字符串的方案数") | [Go](problems/number-of-ways-to-split-a-string) | Medium | | 1572 | [Matrix Diagonal Sum](https://leetcode.com/problems/matrix-diagonal-sum "矩阵对角线元素的和") | [Go](problems/matrix-diagonal-sum) | Easy | | 1571 | [Warehouse Manager](https://leetcode.com/problems/warehouse-manager "仓库经理") 🔒 | [MySQL](problems/warehouse-manager) | Easy | -| 1570 | [Dot Product of Two Sparse Vectors](https://leetcode.com/problems/dot-product-of-two-sparse-vectors) 🔒 | [Go](problems/dot-product-of-two-sparse-vectors) | Medium | +| 1570 | [Dot Product of Two Sparse Vectors](https://leetcode.com/problems/dot-product-of-two-sparse-vectors "两个稀疏向量的点积") 🔒 | [Go](problems/dot-product-of-two-sparse-vectors) | Medium | | 1569 | [Number of Ways to Reorder Array to Get Same BST](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst "将子数组重新排序得到同一个二叉查找树的方案数") | [Go](problems/number-of-ways-to-reorder-array-to-get-same-bst) | Hard | | 1568 | [Minimum Number of Days to Disconnect Island](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数") | [Go](problems/minimum-number-of-days-to-disconnect-island) | Hard | | 1567 | [Maximum Length of Subarray With Positive Product](https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product "乘积为正数的最长子数组长度") | [Go](problems/maximum-length-of-subarray-with-positive-product) | Medium | | 1566 | [Detect Pattern of Length M Repeated K or More Times](https://leetcode.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times "重复至少 K 次且长度为 M 的模式") | [Go](problems/detect-pattern-of-length-m-repeated-k-or-more-times) | Easy | -| 1565 | [Unique Orders and Customers Per Month](https://leetcode.com/problems/unique-orders-and-customers-per-month) 🔒 | [MySQL](problems/unique-orders-and-customers-per-month) | Easy | -| 1564 | [Put Boxes Into the Warehouse I](https://leetcode.com/problems/put-boxes-into-the-warehouse-i) 🔒 | [Go](problems/put-boxes-into-the-warehouse-i) | Medium | +| 1565 | [Unique Orders and Customers Per Month](https://leetcode.com/problems/unique-orders-and-customers-per-month "按月统计订单数与顾客数") 🔒 | [MySQL](problems/unique-orders-and-customers-per-month) | Easy | +| 1564 | [Put Boxes Into the Warehouse I](https://leetcode.com/problems/put-boxes-into-the-warehouse-i "把箱子放进仓库里 I") 🔒 | [Go](problems/put-boxes-into-the-warehouse-i) | Medium | | 1563 | [Stone Game V](https://leetcode.com/problems/stone-game-v "石子游戏 V") | [Go](problems/stone-game-v) | Hard | | 1562 | [Find Latest Group of Size M](https://leetcode.com/problems/find-latest-group-of-size-m "查找大小为 M 的最新分组") | [Go](problems/find-latest-group-of-size-m) | Medium | | 1561 | [Maximum Number of Coins You Can Get](https://leetcode.com/problems/maximum-number-of-coins-you-can-get "你可以获得的最大硬币数目") | [Go](problems/maximum-number-of-coins-you-can-get) | Medium | @@ -123,7 +134,7 @@ LeetCode Problems' Solutions | 1551 | [Minimum Operations to Make Array Equal](https://leetcode.com/problems/minimum-operations-to-make-array-equal "使数组中所有元素相等的最小操作数") | [Go](problems/minimum-operations-to-make-array-equal) | Medium | | 1550 | [Three Consecutive Odds](https://leetcode.com/problems/three-consecutive-odds "存在连续三个奇数的数组") | [Go](problems/three-consecutive-odds) | Easy | | 1549 | [The Most Recent Orders for Each Product](https://leetcode.com/problems/the-most-recent-orders-for-each-product "每件商品的最新订单") 🔒 | [MySQL](problems/the-most-recent-orders-for-each-product) | Medium | -| 1548 | [The Most Similar Path in a Graph](https://leetcode.com/problems/the-most-similar-path-in-a-graph) 🔒 | [Go](problems/the-most-similar-path-in-a-graph) | Hard | +| 1548 | [The Most Similar Path in a Graph](https://leetcode.com/problems/the-most-similar-path-in-a-graph "图中最相似的路径") 🔒 | [Go](problems/the-most-similar-path-in-a-graph) | Hard | | 1547 | [Minimum Cost to Cut a Stick](https://leetcode.com/problems/minimum-cost-to-cut-a-stick "切棍子的最小成本") | [Go](problems/minimum-cost-to-cut-a-stick) | Hard | | 1546 | [Maximum Number of Non-Overlapping Subarrays With Sum Equals Target](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值的最大数目不重叠非空子数组数目") | [Go](problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | Medium | | 1545 | [Find Kth Bit in Nth Binary String](https://leetcode.com/problems/find-kth-bit-in-nth-binary-string "找出第 N 个二进制字符串中的第 K 位") | [Go](problems/find-kth-bit-in-nth-binary-string) | Medium | @@ -217,7 +228,7 @@ LeetCode Problems' Solutions | 1457 | [Pseudo-Palindromic Paths in a Binary Tree](https://leetcode.com/problems/pseudo-palindromic-paths-in-a-binary-tree "二叉树中的伪回文路径") | [Go](problems/pseudo-palindromic-paths-in-a-binary-tree) | Medium | | 1456 | [Maximum Number of Vowels in a Substring of Given Length](https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length "定长子串中元音的最大数目") | [Go](problems/maximum-number-of-vowels-in-a-substring-of-given-length) | Medium | | 1455 | [Check If a Word Occurs As a Prefix of Any Word in a Sentence](https://leetcode.com/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence "检查单词是否为句中其他单词的前缀") | [Go](problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | Easy | -| 1454 | [Active Users](https://leetcode.com/problems/active-users " 活跃用户") 🔒 | [MySQL](problems/active-users) | Medium | +| 1454 | [Active Users](https://leetcode.com/problems/active-users "活跃用户") 🔒 | [MySQL](problems/active-users) | Medium | | 1453 | [Maximum Number of Darts Inside of a Circular Dartboard](https://leetcode.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard "圆形靶内的最大飞镖数量") | [Go](problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | Hard | | 1452 | [People Whose List of Favorite Companies Is Not a Subset of Another List](https://leetcode.com/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list "收藏清单") | [Go](problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | Medium | | 1451 | [Rearrange Words in a Sentence](https://leetcode.com/problems/rearrange-words-in-a-sentence "重新排列句子中的单词") | [Go](problems/rearrange-words-in-a-sentence) | Medium | diff --git a/problems/4sum/README.md b/problems/4sum/README.md index c93f2aba1..ee092982c 100644 --- a/problems/4sum/README.md +++ b/problems/4sum/README.md @@ -13,22 +13,24 @@

    Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.

    -

    Note:

    - -

    The solution set must not contain duplicate quadruplets.

    - -

    Example:

    - -
    -Given array nums = [1, 0, -1, 0, -2, 2], and target = 0.
    -
    -A solution set is:
    -[
    -  [-1,  0, 0, 1],
    -  [-2, -1, 1, 2],
    -  [-2,  0, 0, 2]
    -]
    +

    Notice that the solution set must not contain duplicate quadruplets.

    + +

     

    +

    Example 1:

    +
    Input: nums = [1,0,-1,0,-2,2], target = 0
    +Output: [[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]]
    +

    Example 2:

    +
    Input: nums = [], target = 0
    +Output: []
     
    +

     

    +

    Constraints:

    + +
      +
    • 0 <= nums.length <= 200
    • +
    • -109 <= nums[i] <= 109
    • +
    • -109 <= target <= 109
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/active-users/README.md b/problems/active-users/README.md index cccaaa1df..209e911b4 100644 --- a/problems/active-users/README.md +++ b/problems/active-users/README.md @@ -9,6 +9,6 @@                  [Next >](../check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence "Check If a Word Occurs As a Prefix of Any Word in a Sentence") -## [1454. Active Users (Medium)](https://leetcode.com/problems/active-users " 活跃用户") +## [1454. Active Users (Medium)](https://leetcode.com/problems/active-users "活跃用户") diff --git a/problems/add-two-numbers/README.md b/problems/add-two-numbers/README.md index f815a5b22..ed6de676c 100644 --- a/problems/add-two-numbers/README.md +++ b/problems/add-two-numbers/README.md @@ -11,18 +11,42 @@ ## [2. Add Two Numbers (Medium)](https://leetcode.com/problems/add-two-numbers "两数相加") -

    You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

    +

    You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.

    You may assume the two numbers do not contain any leading zero, except the number 0 itself.

    -

    Example:

    +

     

    +

    Example 1:

    + +
    +Input: l1 = [2,4,3], l2 = [5,6,4]
    +Output: [7,0,8]
    +Explanation: 342 + 465 = 807.
    +
    + +

    Example 2:

    -Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
    -Output: 7 -> 0 -> 8
    -Explanation: 342 + 465 = 807.
    +Input: l1 = [0], l2 = [0]
    +Output: [0]
     
    +

    Example 3:

    + +
    +Input: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]
    +Output: [8,9,9,9,0,0,0,1]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in each linked list is in the range [1, 100].
    • +
    • 0 <= Node.val <= 9
    • +
    • It is guaranteed that the list represents a number that does not have leading zeros.
    • +
    + ### Related Topics [[Linked List](../../tag/linked-list/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md b/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md new file mode 100644 index 000000000..a3c4ccbc8 --- /dev/null +++ b/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../design-parking-system "Design Parking System") +                 +[Next >](../find-valid-matrix-given-row-and-column-sums "Find Valid Matrix Given Row and Column Sums") + +## [1604. Alert Using Same Key-Card Three or More Times in a One Hour Period (Medium)](https://leetcode.com/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period "警告一小时内使用相同员工卡大于等于三次的人") + +

    LeetCode company workers use key-cards to unlock office doors. Each time a worker uses their key-card, the security system saves the worker's name and the time when it was used. The system emits an alert if any worker uses the key-card three or more times in a one-hour period.

    + +

    You are given a list of strings keyName and keyTime where [keyName[i], keyTime[i]] corresponds to a person's name and the time when their key-card was used in a single day.

    + +

    Access times are given in the 24-hour time format "HH:MM", such as "23:51" and "09:49".

    + +

    Return a list of unique worker names who received an alert for frequent keycard use. Sort the names in ascending order alphabetically.

    + +

    Notice that "10:00" - "11:00" is considered to be within a one-hour period, while "22:51" - "23:52" is not considered to be within a one-hour period.

    + +

     

    +

    Example 1:

    + +
    +Input: keyName = ["daniel","daniel","daniel","luis","luis","luis","luis"], keyTime = ["10:00","10:40","11:00","09:00","11:00","13:00","15:00"]
    +Output: ["daniel"]
    +Explanation: "daniel" used the keycard 3 times in a one-hour period ("10:00","10:40", "11:00").
    +
    + +

    Example 2:

    + +
    +Input: keyName = ["alice","alice","alice","bob","bob","bob","bob"], keyTime = ["12:01","12:00","18:00","21:00","21:20","21:30","23:00"]
    +Output: ["bob"]
    +Explanation: "bob" used the keycard 3 times in a one-hour period ("21:00","21:20", "21:30").
    +
    + +

    Example 3:

    + +
    +Input: keyName = ["john","john","john"], keyTime = ["23:58","23:59","00:01"]
    +Output: []
    +
    + +

    Example 4:

    + +
    +Input: keyName = ["leslie","leslie","leslie","clare","clare","clare","clare"], keyTime = ["13:00","13:20","14:00","18:00","18:51","19:30","19:49"]
    +Output: ["clare","leslie"]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= keyName.length, keyTime.length <= 105
    • +
    • keyName.length == keyTime.length
    • +
    • keyTime are in the format "HH:MM".
    • +
    • [keyName[i], keyTime[i]] is unique.
    • +
    • 1 <= keyName[i].length <= 10
    • +
    • keyName[i] contains only lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Ordered Map](../../tag/ordered-map/README.md)] + +### Hints +
    +Hint 1 +Group the times by the name of the card user, then sort each group +
    diff --git a/problems/all-paths-from-source-to-target/README.md b/problems/all-paths-from-source-to-target/README.md index ffd550275..29187f2d3 100644 --- a/problems/all-paths-from-source-to-target/README.md +++ b/problems/all-paths-from-source-to-target/README.md @@ -11,26 +11,59 @@ ## [797. All Paths From Source to Target (Medium)](https://leetcode.com/problems/all-paths-from-source-to-target "所有可能的路径") -

    Given a directed acyclic graph of N nodes. Find all possible paths from node 0 to node N-1, and return them in any order.

    +

    Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1, and return them in any order.

    -

    The graph is given as follows:  the nodes are 0, 1, ..., graph.length - 1.  graph[i] is a list of all nodes j for which the edge (i, j) exists.

    +

    The graph is given as follows: graph[i] is a list of all nodes you can visit from node i (i.e., there is a directed edge from node i to node graph[i][j]).

    +

     

    +

    Example 1:

    +
    -Example:
    -Input: [[1,2],[3],[3],[]]
    +Input: graph = [[1,2],[3],[3],[]]
     Output: [[0,1,3],[0,2,3]]
    -Explanation: The graph looks like this:
    -0--->1
    -|    |
    -v    v
    -2--->3
    -There are two paths: 0 -> 1 -> 3 and 0 -> 2 -> 3.
    +Explanation: There are two paths: 0 -> 1 -> 3 and 0 -> 2 -> 3.
    +
    + +

    Example 2:

    + +
    +Input: graph = [[4,3,1],[3,2,4],[3],[4],[]]
    +Output: [[0,4],[0,3,4],[0,1,3,4],[0,1,2,3,4],[0,1,4]]
    +
    + +

    Example 3:

    + +
    +Input: graph = [[1],[]]
    +Output: [[0,1]]
    +
    + +

    Example 4:

    + +
    +Input: graph = [[1,2,3],[2],[3],[]]
    +Output: [[0,1,2,3],[0,2,3],[0,3]]
    +
    + +

    Example 5:

    + +
    +Input: graph = [[1,3],[2],[3],[]]
    +Output: [[0,1,2,3],[0,3]]
     

     

    Constraints:

      -
    • The number of nodes in the graph will be in the range [2, 15].
    • -
    • You can print different paths in any order, but you should keep the order of nodes inside one path.
    • +
    • n == graph.length
    • +
    • 2 <= n <= 15
    • +
    • 0 <= graph[i][j] < n
    • +
    • graph[i][j] != i (i.e., there will be no self-loops).
    • +
    • The input graph is guaranteed to be a DAG.
    + +### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/array-of-doubled-pairs/README.md b/problems/array-of-doubled-pairs/README.md index dd4cc0d38..bc6c763d4 100644 --- a/problems/array-of-doubled-pairs/README.md +++ b/problems/array-of-doubled-pairs/README.md @@ -13,8 +13,6 @@

    Given an array of integers A with even length, return true if and only if it is possible to reorder it such that A[2 * i + 1] = 2 * A[2 * i] for every 0 <= i < len(A) / 2.

    -

     

    -
    @@ -24,52 +22,44 @@
    -
    +

     

    Example 1:

    -Input: [3,1,3,6]
    -Output: false
    +Input: A = [3,1,3,6]
    +Output: false
     
    -

    Example 2:

    -Input: [2,1,2,6]
    -Output: false
    +Input: A = [2,1,2,6]
    +Output: false
     
    -

    Example 3:

    -Input: [4,-2,2,-4]
    -Output: true
    -Explanation: We can take two groups, [-2,-4] and [2,4] to form [-2,-4,2,4] or [2,4,-2,-4].
    +Input: A = [4,-2,2,-4]
    +Output: true
    +Explanation: We can take two groups, [-2,-4] and [2,4] to form [-2,-4,2,4] or [2,4,-2,-4].
     
    -

    Example 4:

    -Input: [1,2,4,16,8,4]
    -Output: false
    +Input: A = [1,2,4,16,8,4]
    +Output: false
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 0 <= A.length <= 30000
    2. -
    3. A.length is even
    4. -
    5. -100000 <= A[i] <= 100000
    6. -
    -
    -
    -
    -
    +
      +
    • 0 <= A.length <= 3 * 104
    • +
    • A.length is even.
    • +
    • -105 <= A[i] <= 105
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/balanced-binary-tree/README.md b/problems/balanced-binary-tree/README.md index 5a8f78860..91cc92e44 100644 --- a/problems/balanced-binary-tree/README.md +++ b/problems/balanced-binary-tree/README.md @@ -20,35 +20,34 @@

     

    -

    Example 1:

    - -

    Given the following tree [3,9,20,null,null,15,7]:

    - +
    -    3
    -   / \
    -  9  20
    -    /  \
    -   15   7
    +Input: root = [3,9,20,null,null,15,7] +Output: true +
    -

    Return true.
    -
    -Example 2:

    +

    Example 2:

    + +
    +Input: root = [1,2,2,3,3,null,null,4,4]
    +Output: false
    +
    -

    Given the following tree [1,2,2,3,3,null,null,4,4]:

    +

    Example 3:

    -       1
    -      / \
    -     2   2
    -    / \
    -   3   3
    -  / \
    - 4   4
    +Input: root = []
    +Output: true
     
    -

    Return false.

    +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [0, 5000].
    • +
    • -104 <= Node.val <= 104
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/baseball-game/README.md b/problems/baseball-game/README.md index c938d3158..ebebcb1ec 100644 --- a/problems/baseball-game/README.md +++ b/problems/baseball-game/README.md @@ -11,61 +11,67 @@ ## [682. Baseball Game (Easy)](https://leetcode.com/problems/baseball-game "棒球比赛") -

    -You're now a baseball game point recorder. -

    +

    You are keeping score for a baseball game with strange rules. The game consists of several rounds, where the scores of past rounds may affect future rounds' scores.

    + +

    At the beginning of the game, you start with an empty record. You are given a list of strings ops, where ops[i] is the ith operation you must apply to the record and is one of the following:

    -

    -Given a list of strings, each string can be one of the 4 following types:

      -
    1. Integer (one round's score): Directly represents the number of points you get in this round.
    2. -
    3. "+" (one round's score): Represents that the points you get in this round are the sum of the last two valid round's points.
    4. -
    5. "D" (one round's score): Represents that the points you get in this round are the doubled data of the last valid round's points.
    6. -
    7. "C" (an operation, which isn't a round's score): Represents the last valid round's points you get were invalid and should be removed.
    8. +
    9. An integer x - Record a new score of x.
    10. +
    11. "+" - Record a new score that is the sum of the previous two scores. It is guaranteed there will always be two previous scores.
    12. +
    13. "D" - Record a new score that is double the previous score. It is guaranteed there will always be a previous score.
    14. +
    15. "C" - Invalidate the previous score, removing it from the record. It is guaranteed there will always be a previous score.
    -

    -

    -Each round's operation is permanent and could have an impact on the round before and the round after. -

    +

    Return the sum of all the scores on the record.

    -

    -You need to return the sum of the points you could get in all the rounds. -

    +

     

    +

    Example 1:

    -

    Example 1:

    -Input: ["5","2","C","D","+"]
    -Output: 30
    -Explanation: 
    -Round 1: You could get 5 points. The sum is: 5.
    -Round 2: You could get 2 points. The sum is: 7.
    -Operation 1: The round 2's data was invalid. The sum is: 5.  
    -Round 3: You could get 10 points (the round 2's data has been removed). The sum is: 15.
    -Round 4: You could get 5 + 10 = 15 points. The sum is: 30.
    +Input: ops = ["5","2","C","D","+"]
    +Output: 30
    +Explanation:
    +"5" - Add 5 to the record, record is now [5].
    +"2" - Add 2 to the record, record is now [5, 2].
    +"C" - Invalidate and remove the previous score, record is now [5].
    +"D" - Add 2 * 5 = 10 to the record, record is now [5, 10].
    +"+" - Add 5 + 10 = 15 to the record, record is now [5, 10, 15].
    +The total sum is 5 + 10 + 15 = 30.
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: ["5","-2","4","C","D","9","+","+"]
    -Output: 27
    -Explanation: 
    -Round 1: You could get 5 points. The sum is: 5.
    -Round 2: You could get -2 points. The sum is: 3.
    -Round 3: You could get 4 points. The sum is: 7.
    -Operation 1: The round 3's data is invalid. The sum is: 3.  
    -Round 4: You could get -4 points (the round 3's data has been removed). The sum is: -1.
    -Round 5: You could get 9 points. The sum is: 8.
    -Round 6: You could get -4 + 9 = 5 points. The sum is 13.
    -Round 7: You could get 9 + 5 = 14 points. The sum is 27.
    +Input: ops = ["5","-2","4","C","D","9","+","+"]
    +Output: 27
    +Explanation:
    +"5" - Add 5 to the record, record is now [5].
    +"-2" - Add -2 to the record, record is now [5, -2].
    +"4" - Add 4 to the record, record is now [5, -2, 4].
    +"C" - Invalidate and remove the previous score, record is now [5, -2].
    +"D" - Add 2 * -2 = -4 to the record, record is now [5, -2, -4].
    +"9" - Add 9 to the record, record is now [5, -2, -4, 9].
    +"+" - Add -4 + 9 = 5 to the record, record is now [5, -2, -4, 9, 5].
    +"+" - Add 9 + 5 = 14 to the record, record is now [5, -2, -4, 9, 5, 14].
    +The total sum is 5 + -2 + -4 + 9 + 5 + 14 = 27.
     
    -

    -

    Note:
    -

  • The size of the input list will be between 1 and 1000.
  • -
  • Every integer represented in the list will be between -30000 and 30000.
  • -

    +

    Example 3:

    + +
    +Input: ops = ["1"]
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= ops.length <= 1000
    • +
    • ops[i] is "C", "D", "+", or a string representing an integer in the range [-3 * 104, 3 * 104].
    • +
    • For operation "+", there will always be at least two previous scores on the record.
    • +
    • For operations "C" and "D", there will always be at least one previous score on the record.
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/binary-gap/README.md b/problems/binary-gap/README.md index 02c250249..c87e63388 100644 --- a/problems/binary-gap/README.md +++ b/problems/binary-gap/README.md @@ -11,83 +11,61 @@ ## [868. Binary Gap (Easy)](https://leetcode.com/problems/binary-gap "二进制间距") -

    Given a positive integer N, find and return the longest distance between two consecutive 1's in the binary representation of N.

    +

    Given a positive integer n, find and return the longest distance between any two adjacent 1's in the binary representation of n. If there are no two adjacent 1's, return 0.

    -

    If there aren't two consecutive 1's, return 0.

    +

    Two 1's are adjacent if there are only 0's separating them (possibly no 0's). The distance between two 1's is the absolute difference between their bit positions. For example, the two 1's in "1001" have a distance of 3.

     

    - -
    -
    -
    -
      -
    -
    -
    -
    - -

    Example 1:

    -Input: 22
    -Output: 2
    -Explanation: 
    -22 in binary is 0b10110.
    -In the binary representation of 22, there are three ones, and two consecutive pairs of 1's.
    -The first consecutive pair of 1's have distance 2.
    -The second consecutive pair of 1's have distance 1.
    +Input: n = 22
    +Output: 2
    +Explanation: 22 in binary is "10110".
    +The first adjacent pair of 1's is "10110" with a distance of 2.
    +The second adjacent pair of 1's is "10110" with a distance of 1.
     The answer is the largest of these two distances, which is 2.
    +Note that "10110" is not a valid pair since there is a 1 separating the two 1's underlined.
     
    -

    Example 2:

    -Input: 5
    -Output: 2
    -Explanation: 
    -5 in binary is 0b101.
    +Input: n = 5
    +Output: 2
    +Explanation: 5 in binary is "101".
     
    -

    Example 3:

    -Input: 6
    -Output: 1
    -Explanation: 
    -6 in binary is 0b110.
    +Input: n = 6
    +Output: 1
    +Explanation: 6 in binary is "110".
     
    -

    Example 4:

    -Input: 8
    -Output: 0
    -Explanation: 
    -8 in binary is 0b1000.
    -There aren't any consecutive pairs of 1's in the binary representation of 8, so we return 0.
    +Input: n = 8
    +Output: 0
    +Explanation: 8 in binary is "1000".
    +There aren't any adjacent pairs of 1's in the binary representation of 8, so we return 0.
     
    -

     

    +

    Example 5:

    -
    -
    -
    -

    Note:

    +
    +Input: n = 1
    +Output: 0
    +
    + +

     

    +

    Constraints:

      -
    • 1 <= N <= 10^9
    • +
    • 1 <= n <= 109
    -
    -
    -
    -
    -
    -
    -
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/binary-number-with-alternating-bits/README.md b/problems/binary-number-with-alternating-bits/README.md index e5f488359..e1a0fdba1 100644 --- a/problems/binary-number-with-alternating-bits/README.md +++ b/problems/binary-number-with-alternating-bits/README.md @@ -32,14 +32,14 @@

    Example 3:

    -Input: n = 1
    -Output: true
    +Input: n = 11
    +Output: false
     Explanation: The binary representation of 11 is: 1011.

    Example 4:

    -Input: n = 2
    +Input: n = 10
     Output: true
     Explanation: The binary representation of 10 is: 1010.
    diff --git a/problems/binary-search-tree-iterator-ii/README.md b/problems/binary-search-tree-iterator-ii/README.md index 96030951f..0a5c2d50d 100644 --- a/problems/binary-search-tree-iterator-ii/README.md +++ b/problems/binary-search-tree-iterator-ii/README.md @@ -14,6 +14,7 @@ ### Related Topics + [[Tree](../../tag/tree/README.md)] [[Design](../../tag/design/README.md)] ### Hints diff --git a/problems/buddy-strings/README.md b/problems/buddy-strings/README.md index 1318d2968..9b53500ae 100644 --- a/problems/buddy-strings/README.md +++ b/problems/buddy-strings/README.md @@ -11,54 +11,48 @@ ## [859. Buddy Strings (Easy)](https://leetcode.com/problems/buddy-strings "亲密字符串") -

    Given two strings A and B of lowercase letters, return true if and only if we can swap two letters in A so that the result equals B.

    +

    Given two strings A and B of lowercase letters, return true if you can swap two letters in A so the result is equal to B, otherwise, return false.

    -

     

    +

    Swapping letters is defined as taking two indices i and j (0-indexed) such that i != j and swapping the characters at A[i] and A[j]. For example, swapping at indices 0 and 2 in "abcd" results in "cbad".

    +

     

    Example 1:

    -
    -Input: A = "ab", B = "ba"
    -Output: true
    +Input: A = "ab", B = "ba"
    +Output: true
    +Explanation: You can swap A[0] = 'a' and A[1] = 'b' to get "ba", which is equal to B.
     
    -

    Example 2:

    -Input: A = "ab", B = "ab"
    -Output: false
    +Input: A = "ab", B = "ab"
    +Output: false
    +Explanation: The only letters you can swap are A[0] = 'a' and A[1] = 'b', which results in "ba" != B.
     
    -

    Example 3:

    -Input: A = "aa", B = "aa"
    -Output: true
    +Input: A = "aa", B = "aa"
    +Output: true
    +Explanation: You can swap A[0] = 'a' and A[1] = 'a' to get "aa", which is equal to B.
     
    -

    Example 4:

    -Input: A = "aaaaaaabc", B = "aaaaaaacb"
    -Output: true
    +Input: A = "aaaaaaabc", B = "aaaaaaacb"
    +Output: true
     
    -

    Example 5:

    -Input: A = "", B = "aa"
    -Output: false
    +Input: A = "", B = "aa"
    +Output: false
     
    -
    -
    -
    -
    -

     

    Constraints:

    @@ -66,7 +60,7 @@
    • 0 <= A.length <= 20000
    • 0 <= B.length <= 20000
    • -
    • A and B consist only of lowercase letters.
    • +
    • A and B consist of lowercase letters.
    ### Related Topics diff --git a/problems/build-binary-expression-tree-from-infix-expression/README.md b/problems/build-binary-expression-tree-from-infix-expression/README.md index f34a88c05..e848a4bbd 100644 --- a/problems/build-binary-expression-tree-from-infix-expression/README.md +++ b/problems/build-binary-expression-tree-from-infix-expression/README.md @@ -9,7 +9,7 @@                  [Next >](../crawler-log-folder "Crawler Log Folder") -## [1597. Build Binary Expression Tree From Infix Expression (Medium)](https://leetcode.com/problems/build-binary-expression-tree-from-infix-expression "") +## [1597. Build Binary Expression Tree From Infix Expression (Hard)](https://leetcode.com/problems/build-binary-expression-tree-from-infix-expression "根据中缀表达式构造二叉表达式树") diff --git a/problems/champagne-tower/README.md b/problems/champagne-tower/README.md index 005487ba5..65b9e9e41 100644 --- a/problems/champagne-tower/README.md +++ b/problems/champagne-tower/README.md @@ -11,37 +11,44 @@ ## [799. Champagne Tower (Medium)](https://leetcode.com/problems/champagne-tower "香槟塔") -

    We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so on until the 100th row.  Each glass holds one cup (250ml) of champagne.

    +

    We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so on until the 100th row.  Each glass holds one cup (250ml) of champagne.

    -

    Then, some champagne is poured in the first glass at the top.  When the top most glass is full, any excess liquid poured will fall equally to the glass immediately to the left and right of it.  When those glasses become full, any excess champagne will fall equally to the left and right of those glasses, and so on.  (A glass at the bottom row has it's excess champagne fall on the floor.)

    +

    Then, some champagne is poured in the first glass at the top.  When the topmost glass is full, any excess liquid poured will fall equally to the glass immediately to the left and right of it.  When those glasses become full, any excess champagne will fall equally to the left and right of those glasses, and so on.  (A glass at the bottom row has its excess champagne fall on the floor.)

    For example, after one cup of champagne is poured, the top most glass is full.  After two cups of champagne are poured, the two glasses on the second row are half full.  After three cups of champagne are poured, those two cups become full - there are 3 full glasses total now.  After four cups of champagne are poured, the third row has the middle glass half full, and the two outside glasses are a quarter full, as pictured below.

    -

    +

    -

    Now after pouring some non-negative integer cups of champagne, return how full the j-th glass in the i-th row is (both i and j are 0 indexed.)

    +

    Now after pouring some non-negative integer cups of champagne, return how full the jth glass in the ith row is (both i and j are 0-indexed.)

     

    +

    Example 1:

    -Example 1:
    -Input: poured = 1, query_glass = 1, query_row = 1
    -Output: 0.0
    +Input: poured = 1, query_row = 1, query_glass = 1
    +Output: 0.00000
     Explanation: We poured 1 cup of champange to the top glass of the tower (which is indexed as (0, 0)). There will be no excess liquid so all the glasses under the top glass will remain empty.
    +
    + +

    Example 2:

    -Example 2: -Input: poured = 2, query_glass = 1, query_row = 1 -Output: 0.5 +
    +Input: poured = 2, query_row = 1, query_glass = 1
    +Output: 0.50000
     Explanation: We poured 2 cups of champange to the top glass of the tower (which is indexed as (0, 0)). There is one cup of excess liquid. The glass indexed as (1, 0) and the glass indexed as (1, 1) will share the excess liquid equally, and each will get half cup of champange.
     
    -

     

    +

    Example 3:

    + +
    +Input: poured = 100000009, query_row = 33, query_glass = 17
    +Output: 1.00000
    +
    -

    Note:

    +

     

    +

    Constraints:

      -
    • poured will be in the range of [0, 10 ^ 9].
    • -
    • query_glass and query_row will be in the range of [0, 99].
    • +
    • 0 <= poured <= 109
    • +
    • 0 <= query_glass <= query_row < 100
    - -

     

    diff --git a/problems/check-if-two-expression-trees-are-equivalent/README.md b/problems/check-if-two-expression-trees-are-equivalent/README.md new file mode 100644 index 000000000..f49b67d5f --- /dev/null +++ b/problems/check-if-two-expression-trees-are-equivalent/README.md @@ -0,0 +1,29 @@ + + + + + + + +[< Previous](../minimum-one-bit-operations-to-make-integers-zero "Minimum One Bit Operations to Make Integers Zero") +                 +Next > + +## [1612. Check If Two Expression Trees are Equivalent (Medium)](https://leetcode.com/problems/check-if-two-expression-trees-are-equivalent "") + + + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +Count for each variable how many times it appeared in the first tree. +
    + +
    +Hint 2 +Do the same for the second tree and check if the count is the same for both tree. +
    diff --git a/problems/coin-change/README.md b/problems/coin-change/README.md index 1836ac4bd..ff84c7591 100644 --- a/problems/coin-change/README.md +++ b/problems/coin-change/README.md @@ -58,7 +58,7 @@
    • 1 <= coins.length <= 12
    • 1 <= coins[i] <= 231 - 1
    • -
    • 0 <= amount <= 231 - 1
    • +
    • 0 <= amount <= 104
    ### Related Topics diff --git a/problems/combination-sum/README.md b/problems/combination-sum/README.md index a135f7402..9a823c811 100644 --- a/problems/combination-sum/README.md +++ b/problems/combination-sum/README.md @@ -11,38 +11,50 @@ ## [39. Combination Sum (Medium)](https://leetcode.com/problems/combination-sum "组合总和") -

    Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.

    +

    Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the combinations in any order.

    -

    The same repeated number may be chosen from candidates unlimited number of times.

    +

    The same number may be chosen from candidates an unlimited number of times. Two combinations are unique if the frequency of at least one of the chosen numbers is different.

    -

    Note:

    - -
      -
    • All numbers (including target) will be positive integers.
    • -
    • The solution set must not contain duplicate combinations.
    • -
    +

    It is guaranteed that the number of unique combinations that sum up to target is less than 150 combinations for the given input.

    +

     

    Example 1:

    -Input: candidates = [2,3,6,7], target = 7,
    -A solution set is:
    -[
    -  [7],
    -  [2,2,3]
    -]
    +Input: candidates = [2,3,6,7], target = 7
    +Output: [[2,2,3],[7]]
    +Explanation:
    +2 and 3 are candidates, and 2 + 2 + 3 = 7. Note that 2 can be used multiple times.
    +7 is a candidate, and 7 = 7.
    +These are the only two combinations.
     

    Example 2:

    -Input: candidates = [2,3,5], target = 8,
    -A solution set is:
    -[
    -  [2,2,2,2],
    -  [2,3,3],
    -  [3,5]
    -]
    +Input: candidates = [2,3,5], target = 8
    +Output: [[2,2,2,2],[2,3,3],[3,5]]
    +
    + +

    Example 3:

    + +
    +Input: candidates = [2], target = 1
    +Output: []
    +
    + +

    Example 4:

    + +
    +Input: candidates = [1], target = 1
    +Output: [[1]]
    +
    + +

    Example 5:

    + +
    +Input: candidates = [1], target = 2
    +Output: [[1,1]]
     

     

    @@ -51,7 +63,7 @@
    • 1 <= candidates.length <= 30
    • 1 <= candidates[i] <= 200
    • -
    • Each element of candidate is unique.
    • +
    • All elements of candidates are distinct.
    • 1 <= target <= 500
    diff --git a/problems/construct-binary-search-tree-from-preorder-traversal/README.md b/problems/construct-binary-search-tree-from-preorder-traversal/README.md index f0f85cc8b..31499290e 100644 --- a/problems/construct-binary-search-tree-from-preorder-traversal/README.md +++ b/problems/construct-binary-search-tree-from-preorder-traversal/README.md @@ -9,7 +9,7 @@                  [Next >](../complement-of-base-10-integer "Complement of Base 10 Integer") -## [1008. Construct Binary Search Tree from Preorder Traversal (Medium)](https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal "先序遍历构造二叉树") +## [1008. Construct Binary Search Tree from Preorder Traversal (Medium)](https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal "前序遍历构造二叉搜索树")

    Return the root node of a binary search tree that matches the given preorder traversal.

    diff --git a/problems/construct-the-rectangle/README.md b/problems/construct-the-rectangle/README.md index a7dc0df8a..10f924dde 100644 --- a/problems/construct-the-rectangle/README.md +++ b/problems/construct-the-rectangle/README.md @@ -11,28 +11,52 @@ ## [492. Construct the Rectangle (Easy)](https://leetcode.com/problems/construct-the-rectangle "构造矩形") -

    -For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L and width W satisfy the following requirements:

    -1. The area of the rectangular web page you designed must equal to the given target area.
    -
    2. The width W should not be larger than the length L, which means L >= W. -
    3. The difference between length L and width W should be as small as possible. -
    -You need to output the length L and the width W of the web page you designed in sequence. -

    +

    A web developer needs to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L and width W satisfy the following requirements:

    + +
      +
    1. The area of the rectangular web page you designed must equal to the given target area.
    2. +
    3. The width W should not be larger than the length L, which means L >= W.
    4. +
    5. The difference between length L and width W should be as small as possible.
    6. +
    + +

    Return an array [L, W] where L and W are the length and width of the web page you designed in sequence.

    +

     

    +

    Example 1:

    -

    Example:

    -Input: 4
    -Output: [2, 2]
    -Explanation: The target area is 4, and all the possible ways to construct it are [1,4], [2,2], [4,1]. 
    +Input: area = 4
    +Output: [2,2]
    +Explanation: The target area is 4, and all the possible ways to construct it are [1,4], [2,2], [4,1]. 
     But according to requirement 2, [1,4] is illegal; according to requirement 3,  [4,1] is not optimal compared to [2,2]. So the length L is 2, and the width W is 2.
     
    -

    -

    Note:
    -

      -
    1. The given area won't exceed 10,000,000 and is a positive integer
    2. -
    3. The web page's width and length you designed must be positive integers.
    4. -
    -

    +

    Example 2:

    + +
    +Input: area = 37
    +Output: [37,1]
    +
    + +

    Example 3:

    + +
    +Input: area = 122122
    +Output: [427,286]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= area <= 107
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +The W is always less than or equal to the square root of the area, so we start searching at sqrt(area) till we find the result. +
    diff --git a/problems/container-with-most-water/README.md b/problems/container-with-most-water/README.md index 6a5accfe4..3f368254f 100644 --- a/problems/container-with-most-water/README.md +++ b/problems/container-with-most-water/README.md @@ -11,23 +11,47 @@ ## [11. Container With Most Water (Medium)](https://leetcode.com/problems/container-with-most-water "盛最多水的容器") -

    Given n non-negative integers a1, a2, ..., a, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water.

    +

    Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.

    -

    Note: You may not slant the container and n is at least 2.

    +

    Notice that you may not slant the container.

     

    +

    Example 1:

    + +
    +Input: height = [1,8,6,2,5,4,8,3,7]
    +Output: 49
    +Explanation: The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49.
    +
    + +

    Example 2:

    -

    +
    +Input: height = [1,1]
    +Output: 1
    +
    -

    The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49.

    +

    Example 3:

    -

     

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

    Example:

    +

    Example 4:

    -Input: [1,8,6,2,5,4,8,3,7]
    -Output: 49
    +Input: height = [1,2,1] +Output: 2 + + +

     

    +

    Constraints:

    + +
      +
    • 2 <= height.length <= 3 * 104
    • +
    • 0 <= height[i] <= 3 * 104
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/copy-list-with-random-pointer/README.md b/problems/copy-list-with-random-pointer/README.md index d09f36026..493606481 100644 --- a/problems/copy-list-with-random-pointer/README.md +++ b/problems/copy-list-with-random-pointer/README.md @@ -60,7 +60,7 @@
    • -10000 <= Node.val <= 10000
    • Node.random is null or pointing to a node in the linked list.
    • -
    • Number of Nodes will not exceed 1000.
    • +
    • The number of nodes will not exceed 1000.
    ### Related Topics diff --git a/problems/customer-who-visited-but-did-not-make-any-transactions/README.md b/problems/customer-who-visited-but-did-not-make-any-transactions/README.md index 980a01ce8..dd3788669 100644 --- a/problems/customer-who-visited-but-did-not-make-any-transactions/README.md +++ b/problems/customer-who-visited-but-did-not-make-any-transactions/README.md @@ -9,6 +9,6 @@                  [Next >](../special-positions-in-a-binary-matrix "Special Positions in a Binary Matrix") -## [1581. Customer Who Visited but Did Not Make Any Transactions (Easy)](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "") +## [1581. Customer Who Visited but Did Not Make Any Transactions (Easy)](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的客户") diff --git a/problems/decode-ways/README.md b/problems/decode-ways/README.md index 933dcf927..62d582026 100644 --- a/problems/decode-ways/README.md +++ b/problems/decode-ways/README.md @@ -22,20 +22,47 @@

    Given a non-empty string containing only digits, determine the total number of ways to decode it.

    +

    The answer is guaranteed to fit in a 32-bit integer.

    + +

     

    Example 1:

    -Input: "12"
    +Input: s = "12"
     Output: 2
    -Explanation: It could be decoded as "AB" (1 2) or "L" (12).
    +Explanation: It could be decoded as "AB" (1 2) or "L" (12).
     

    Example 2:

    -Input: "226"
    +Input: s = "226"
     Output: 3
    -Explanation: It could be decoded as "BZ" (2 26), "VF" (22 6), or "BBF" (2 2 6).
    +Explanation: It could be decoded as "BZ" (2 26), "VF" (22 6), or "BBF" (2 2 6). + + +

    Example 3:

    + +
    +Input: s = "0"
    +Output: 0
    +Explanation: There is no character that is mapped to a number starting with '0'. We cannot ignore a zero when we face it while decoding. So, each '0' should be part of "10" --> 'J' or "20" --> 'T'.
    +
    + +

    Example 4:

    + +
    +Input: s = "1"
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 100
    • +
    • s contains only digits and may contain leading zero(s).
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/design-parking-system/README.md b/problems/design-parking-system/README.md new file mode 100644 index 000000000..79b48982d --- /dev/null +++ b/problems/design-parking-system/README.md @@ -0,0 +1,57 @@ + + + + + + + +[< Previous](../find-nearest-right-node-in-binary-tree "Find Nearest Right Node in Binary Tree") +                 +[Next >](../alert-using-same-key-card-three-or-more-times-in-a-one-hour-period "Alert Using Same Key-Card Three or More Times in a One Hour Period") + +## [1603. Design Parking System (Easy)](https://leetcode.com/problems/design-parking-system "设计停车系统") + +

    Design a parking system for a parking lot. The parking lot has three kinds of parking spaces: big, medium, and small, with a fixed number of slots for each size.

    + +

    Implement the ParkingSystem class:

    + +
      +
    • ParkingSystem(int big, int medium, int small) Initializes object of the ParkingSystem class. The number of slots for each parking space are given as part of the constructor.
    • +
    • bool addCar(int carType) Checks whether there is a parking space of carType for the car that wants to get into the parking lot. carType can be of three kinds: big, medium, or small, which are represented by 1, 2, and 3 respectively. A car can only park in a parking space of its carType. If there is no space available, return false, else park the car in that size space and return true.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input
    +["ParkingSystem", "addCar", "addCar", "addCar", "addCar"]
    +[[1, 1, 0], [1], [2], [3], [1]]
    +Output
    +[null, true, true, false, false]
    +
    +Explanation
    +ParkingSystem parkingSystem = new ParkingSystem(1, 1, 0);
    +parkingSystem.addCar(1); // return true because there is 1 available slot for a big car
    +parkingSystem.addCar(2); // return true because there is 1 available slot for a medium car
    +parkingSystem.addCar(3); // return false because there is no available slot for a small car
    +parkingSystem.addCar(1); // return false because there is no available slot for a big car. It is already occupied.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= big, medium, small <= 1000
    • +
    • carType is 1, 2, or 3
    • +
    • At most 1000 calls will be made to addCar
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + +### Hints +
    +Hint 1 +Record number of parking slots still available for each car type. +
    diff --git a/problems/divide-two-integers/README.md b/problems/divide-two-integers/README.md index 0d0667fd8..00b4dfb87 100644 --- a/problems/divide-two-integers/README.md +++ b/problems/divide-two-integers/README.md @@ -11,12 +11,19 @@ ## [29. Divide Two Integers (Medium)](https://leetcode.com/problems/divide-two-integers "两数相除") -

    Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator.

    +

    Given two integers dividend and divisor, divide two integers without using multiplication, division, and mod operator.

    Return the quotient after dividing dividend by divisor.

    The integer division should truncate toward zero, which means losing its fractional part. For example, truncate(8.345) = 8 and truncate(-2.7335) = -2.

    +

    Note:

    + +
      +
    • Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. For this problem, assume that your function returns 231 − 1 when the division result overflows.
    • +
    + +

     

    Example 1:

    @@ -33,12 +40,26 @@
     Explanation: 7/-3 = truncate(-2.33333..) = -2.
     
    -

    Note:

    +

    Example 3:

    + +
    +Input: dividend = 0, divisor = 1
    +Output: 0
    +
    + +

    Example 4:

    + +
    +Input: dividend = 1, divisor = 1
    +Output: 1
    +
    + +

     

    +

    Constraints:

      -
    • Both dividend and divisor will be 32-bit signed integers.
    • -
    • The divisor will never be 0.
    • -
    • Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. For the purpose of this problem, assume that your function returns 231 − 1 when the division result overflows.
    • +
    • -231 <= dividend, divisor <= 231 - 1
    • +
    • divisor != 0
    ### Related Topics diff --git a/problems/dot-product-of-two-sparse-vectors/README.md b/problems/dot-product-of-two-sparse-vectors/README.md index c2c0d6fc6..fcfcfec67 100644 --- a/problems/dot-product-of-two-sparse-vectors/README.md +++ b/problems/dot-product-of-two-sparse-vectors/README.md @@ -9,7 +9,7 @@                  [Next >](../warehouse-manager "Warehouse Manager") -## [1570. Dot Product of Two Sparse Vectors (Medium)](https://leetcode.com/problems/dot-product-of-two-sparse-vectors "") +## [1570. Dot Product of Two Sparse Vectors (Medium)](https://leetcode.com/problems/dot-product-of-two-sparse-vectors "两个稀疏向量的点积") diff --git a/problems/escape-the-ghosts/README.md b/problems/escape-the-ghosts/README.md index a733cf3dc..b30a9439c 100644 --- a/problems/escape-the-ghosts/README.md +++ b/problems/escape-the-ghosts/README.md @@ -11,49 +11,63 @@ ## [789. Escape The Ghosts (Medium)](https://leetcode.com/problems/escape-the-ghosts "逃脱阻碍者") -

    You are playing a simplified Pacman game. You start at the point (0, 0), and your destination is (target[0], target[1]). There are several ghosts on the map, the i-th ghost starts at (ghosts[i][0], ghosts[i][1]).

    +

    You are playing a simplified PAC-MAN game on an infinite 2-D grid. You start at the point [0, 0], and you are given a destination point target = [xtarget, ytarget], which you are trying to get to. There are several ghosts on the map with their starting positions given as an array ghosts, where ghosts[i] = [xi, yi] represents the starting position of the ith ghost. All inputs are integral coordinates.

    -

    Each turn, you and all ghosts simultaneously *may* move in one of 4 cardinal directions: north, east, west, or south, going from the previous point to a new point 1 unit of distance away.

    +

    Each turn, you and all the ghosts may independently choose to either move 1 unit in any of the four cardinal directions: north, east, south, or west or stay still. All actions happen simultaneously.

    -

    You escape if and only if you can reach the target before any ghost reaches you (for any given moves the ghosts may take.)  If you reach any square (including the target) at the same time as a ghost, it doesn't count as an escape.

    +

    You escape if and only if you can reach the target before any ghost reaches you. If you reach any square (including the target) at the same time as a ghost, it does not count as an escape.

    -

    Return True if and only if it is possible to escape.

    +

    Return true if it is possible to escape, otherwise return false.

    + +

     

    +

    Example 1:

    -Example 1:
    -Input: 
    -ghosts = [[1, 0], [0, 3]]
    -target = [0, 1]
    +Input: ghosts = [[1,0],[0,3]], target = [0,1]
     Output: true
    -Explanation: 
    -You can directly reach the destination (0, 1) at time 1, while the ghosts located at (1, 0) or (0, 3) have no way to catch up with you.
    +Explanation: You can reach the destination (0, 1) after 1 turn, while the ghosts located at (1, 0) and (0, 3) cannot catch up with you.
     
    +

    Example 2:

    +
    -Example 2:
    -Input: 
    -ghosts = [[1, 0]]
    -target = [2, 0]
    +Input: ghosts = [[1,0]], target = [2,0]
     Output: false
    -Explanation: 
    -You need to reach the destination (2, 0), but the ghost at (1, 0) lies between you and the destination.
    +Explanation: You need to reach the destination (2, 0), but the ghost at (1, 0) lies between you and the destination.
     
    +

    Example 3:

    +
    -Example 3:
    -Input: 
    -ghosts = [[2, 0]]
    -target = [1, 0]
    +Input: ghosts = [[2,0]], target = [1,0]
     Output: false
    -Explanation: 
    -The ghost can reach the target at the same time as you.
    +Explanation: The ghost can reach the target at the same time as you.
    +
    + +

    Example 4:

    + +
    +Input: ghosts = [[5,0],[-10,-2],[0,-5],[-2,-2],[-7,1]], target = [7,7]
    +Output: false
    +
    + +

    Example 5:

    + +
    +Input: ghosts = [[-1,0],[0,1],[-1,0],[0,1],[-1,0]], target = [0,0]
    +Output: true
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • All points have coordinates with absolute value <= 10000.
    • -
    • The number of ghosts will not exceed 100.
    • +
    • 1 <= ghosts.length <= 100
    • +
    • ghosts[i].length == 2
    • +
    • -104 <= xi, yi <= 104
    • +
    • There can be multiple ghosts in the same location.
    • +
    • target.length == 2
    • +
    • -104 <= xtarget, ytarget <= 104
    ### Related Topics diff --git a/problems/evaluate-division/README.md b/problems/evaluate-division/README.md index e402d77b9..3212317f2 100644 --- a/problems/evaluate-division/README.md +++ b/problems/evaluate-division/README.md @@ -11,9 +11,13 @@ ## [399. Evaluate Division (Medium)](https://leetcode.com/problems/evaluate-division "除法求值") -

    You are given equations in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating-point number). Given some queries, return the answers. If the answer does not exist, return -1.0.

    +

    You are given an array of variable pairs equations and an array of real numbers values, where equations[i] = [Ai, Bi] and values[i] represent the equation Ai / Bi = values[i]. Each Ai or Bi is a string that represents a single variable.

    -

    The input is always valid. You may assume that evaluating the queries will result in no division by zero and there is no contradiction.

    +

    You are also given some queries, where queries[j] = [Cj, Dj] represents the jth query where you must find the answer for Cj / Dj = ?.

    + +

    Return the answers to all queries. If a single answer cannot be determined, return -1.0.

    + +

    Note: The input is always valid. You may assume that evaluating the queries will not result in division by zero and that there is no contradiction.

     

    Example 1:

    @@ -47,13 +51,13 @@ return: [6.0, 0.5, -1.0, 1.0, -1.0 ]
    • 1 <= equations.length <= 20
    • equations[i].length == 2
    • -
    • 1 <= equations[i][0], equations[i][1] <= 5
    • -
    • values.length == equations.length
    • -
    • 0.0 < values[i] <= 20.0
    • +
    • 1 <= Ai.length, Bi.length <= 5
    • +
    • values.length == equations.length
    • +
    • 0.0 < values[i] <= 20.0
    • 1 <= queries.length <= 20
    • queries[i].length == 2
    • -
    • 1 <= queries[i][0], queries[i][1] <= 5
    • -
    • equations[i][0], equations[i][1], queries[i][0], queries[i][1] consist of lower case English letters and digits.
    • +
    • 1 <= Cj.length, Dj.length <= 5
    • +
    • Ai, Bi, Cj, Dj consist of lower case English letters and digits.
    ### Related Topics diff --git a/problems/even-odd-tree/README.md b/problems/even-odd-tree/README.md new file mode 100644 index 000000000..4d373f08a --- /dev/null +++ b/problems/even-odd-tree/README.md @@ -0,0 +1,93 @@ + + + + + + + +[< Previous](../special-array-with-x-elements-greater-than-or-equal-x "Special Array With X Elements Greater Than or Equal X") +                 +[Next >](../maximum-number-of-visible-points "Maximum Number of Visible Points") + +## [1609. Even Odd Tree (Medium)](https://leetcode.com/problems/even-odd-tree "奇偶树") + +

    A binary tree is named Even-Odd if it meets the following conditions:

    + +
      +
    • The root of the binary tree is at level index 0, its children are at level index 1, their children are at level index 2, etc.
    • +
    • For every even-indexed level, all nodes at the level have odd integer values in strictly increasing order (from left to right).
    • +
    • For every odd-indexed level, all nodes at the level have even integer values in strictly decreasing order (from left to right).
    • +
    + +

    Given the root of a binary tree, return true if the binary tree is Even-Odd, otherwise return false.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: root = [1,10,4,3,null,7,9,12,8,6,null,null,2]
    +Output: true
    +Explanation: The node values on each level are:
    +Level 0: [1]
    +Level 1: [10,4]
    +Level 2: [3,7,9]
    +Level 3: [12,8,6,2]
    +Since levels 0 and 2 are all odd and increasing, and levels 1 and 3 are all even and decreasing, the tree is Even-Odd.
    +
    + +

    Example 2:

    + +

    + +
    +Input: root = [5,4,2,3,3,7]
    +Output: false
    +Explanation: The node values on each level are:
    +Level 0: [5]
    +Level 1: [4,2]
    +Level 2: [3,3,7]
    +Node values in the level 2 must be in strictly increasing order, so the tree is not Even-Odd.
    +
    + +

    Example 3:

    + +

    + +
    +Input: root = [5,9,1,3,5,7]
    +Output: false
    +Explanation: Node values in the level 1 should be even integers.
    +
    + +

    Example 4:

    + +
    +Input: root = [1]
    +Output: true
    +
    + +

    Example 5:

    + +
    +Input: root = [11,8,6,1,3,9,11,30,20,18,16,12,10,4,2,17]
    +Output: true
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [1, 105].
    • +
    • 1 <= Node.val <= 106
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] + +### Hints +
    +Hint 1 +Use the breadth-first search to go through all nodes layer by layer. +
    diff --git a/problems/find-first-and-last-position-of-element-in-sorted-array/README.md b/problems/find-first-and-last-position-of-element-in-sorted-array/README.md index 5e959983d..1cb56b127 100644 --- a/problems/find-first-and-last-position-of-element-in-sorted-array/README.md +++ b/problems/find-first-and-last-position-of-element-in-sorted-array/README.md @@ -13,30 +13,29 @@

    Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.

    -

    Your algorithm's runtime complexity must be in the order of O(log n).

    +

    If target is not found in the array, return [-1, -1].

    -

    If the target is not found in the array, return [-1, -1].

    +

    Follow up: Could you write an algorithm with O(log n) runtime complexity?

    +

     

    Example 1:

    - -
    -Input: nums = [5,7,7,8,8,10], target = 8
    -Output: [3,4]
    - -

    Example 2:

    - -
    -Input: nums = [5,7,7,8,8,10], target = 6
    -Output: [-1,-1]
    - +
    Input: nums = [5,7,7,8,8,10], target = 8
    +Output: [3,4]
    +

    Example 2:

    +
    Input: nums = [5,7,7,8,8,10], target = 6
    +Output: [-1,-1]
    +

    Example 3:

    +
    Input: nums = [], target = 0
    +Output: [-1,-1]
    +

     

    Constraints:

      -
    • 0 <= nums.length <= 10^5
    • -
    • -10^9 <= nums[i] <= 10^9
    • -
    • nums is a non decreasing array.
    • -
    • -10^9 <= target <= 10^9
    • +
    • 0 <= nums.length <= 105
    • +
    • -109 <= nums[i] <= 109
    • +
    • nums is a non-decreasing array.
    • +
    • -109 <= target <= 109
    ### Related Topics diff --git a/problems/find-nearest-right-node-in-binary-tree/README.md b/problems/find-nearest-right-node-in-binary-tree/README.md new file mode 100644 index 000000000..b4e1b4721 --- /dev/null +++ b/problems/find-nearest-right-node-in-binary-tree/README.md @@ -0,0 +1,39 @@ + + + + + + + +[< Previous](../maximum-number-of-achievable-transfer-requests "Maximum Number of Achievable Transfer Requests") +                 +[Next >](../design-parking-system "Design Parking System") + +## [1602. Find Nearest Right Node in Binary Tree (Medium)](https://leetcode.com/problems/find-nearest-right-node-in-binary-tree "") + + + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + +### Hints +
    +Hint 1 +Use BFS, traverse the tree level by level and always push the left node first +
    + +
    +Hint 2 +When you reach the target node, mark a boolean variable true +
    + +
    +Hint 3 +If you meet another node in the same level after marking the boolean true, return this node. +
    + +
    +Hint 4 +If you did not meet new nodes in the same level and started traversing a new level, return Null +
    diff --git a/problems/find-servers-that-handled-most-number-of-requests/README.md b/problems/find-servers-that-handled-most-number-of-requests/README.md new file mode 100644 index 000000000..751e8ed32 --- /dev/null +++ b/problems/find-servers-that-handled-most-number-of-requests/README.md @@ -0,0 +1,97 @@ + + + + + + + +[< Previous](../find-valid-matrix-given-row-and-column-sums "Find Valid Matrix Given Row and Column Sums") +                 +[Next >](../sellers-with-no-sales "Sellers With No Sales") + +## [1606. Find Servers That Handled Most Number of Requests (Hard)](https://leetcode.com/problems/find-servers-that-handled-most-number-of-requests "找到处理最多请求的服务器") + +

    You have k servers numbered from 0 to k-1 that are being used to handle multiple requests simultaneously. Each server has infinite computational capacity but cannot handle more than one request at a time. The requests are assigned to servers according to a specific algorithm:

    + +
      +
    • The ith (0-indexed) request arrives.
    • +
    • If all servers are busy, the request is dropped (not handled at all).
    • +
    • If the (i % k)th server is available, assign the request to that server.
    • +
    • Otherwise, assign the request to the next available server (wrapping around the list of servers and starting from 0 if necessary). For example, if the ith server is busy, try to assign the request to the (i+1)th server, then the (i+2)th server, and so on.
    • +
    + +

    You are given a strictly increasing array arrival of positive integers, where arrival[i] represents the arrival time of the ith request, and another array load, where load[i] represents the load of the ith request (the time it takes to complete). Your goal is to find the busiest server(s). A server is considered busiest if it handled the most number of requests successfully among all the servers.

    + +

    Return a list containing the IDs (0-indexed) of the busiest server(s). You may return the IDs in any order.

    + +

     

    +

    Example 1:

    + +
    +Input: k = 3, arrival = [1,2,3,4,5], load = [5,2,3,3,3] 
    +Output: [1] 
    +Explanation:
    +All of the servers start out available.
    +The first 3 requests are handled by the first 3 servers in order.
    +Request 3 comes in. Server 0 is busy, so it's assigned to the next available server, which is 1.
    +Request 4 comes in. It cannot be handled since all servers are busy, so it is dropped.
    +Servers 0 and 2 handled one request each, while server 1 handled two requests. Hence server 1 is the busiest server.
    +
    + +

    Example 2:

    + +
    +Input: k = 3, arrival = [1,2,3,4], load = [1,2,1,2]
    +Output: [0]
    +Explanation:
    +The first 3 requests are handled by first 3 servers.
    +Request 3 comes in. It is handled by server 0 since the server is available.
    +Server 0 handled two requests, while servers 1 and 2 handled one request each. Hence server 0 is the busiest server.
    +
    + +

    Example 3:

    + +
    +Input: k = 3, arrival = [1,2,3], load = [10,12,11]
    +Output: [0,1,2]
    +Explanation: Each server handles a single request, so they are all considered the busiest.
    +
    + +

    Example 4:

    + +
    +Input: k = 3, arrival = [1,2,3,4,8,9,10], load = [5,2,10,3,1,2,2]
    +Output: [1]
    +
    + +

    Example 5:

    + +
    +Input: k = 1, arrival = [1], load = [1]
    +Output: [0]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= 105
    • +
    • 1 <= arrival.length, load.length <= 105
    • +
    • arrival.length == load.length
    • +
    • 1 <= arrival[i], load[i] <= 109
    • +
    • arrival is strictly increasing.
    • +
    + +### Related Topics + [[Ordered Map](../../tag/ordered-map/README.md)] + +### Hints +
    +Hint 1 +To speed up the next available server search, keep track of the available servers in a sorted structure such as an ordered set. +
    + +
    +Hint 2 +To determine if a server is available, keep track of the end times for each task in a heap and add the server to the available set once the soonest task ending time is less than or equal to the next task to add. +
    diff --git a/problems/find-the-difference/README.md b/problems/find-the-difference/README.md index 4382ca887..ce602c5ec 100644 --- a/problems/find-the-difference/README.md +++ b/problems/find-the-difference/README.md @@ -11,26 +11,51 @@ ## [389. Find the Difference (Easy)](https://leetcode.com/problems/find-the-difference "找不同") -

    -Given two strings s and t which consist of only lowercase letters.

    +

    You are given two strings s and t.

    -

    String t is generated by random shuffling string s and then add one more letter at a random position.

    +

    String t is generated by random shuffling string s and then add one more letter at a random position.

    -

    Find the letter that was added in t.

    +

    Return the letter that was added to t.

    + +

     

    +

    Example 1:

    -

    Example:

    -Input:
    -s = "abcd"
    -t = "abcde"
    +Input: s = "abcd", t = "abcde"
    +Output: "e"
    +Explanation: 'e' is the letter that was added.
    +
    -Output: -e +

    Example 2:

    -Explanation: -'e' is the letter that was added. +
    +Input: s = "", t = "y"
    +Output: "y"
    +
    + +

    Example 3:

    + +
    +Input: s = "a", t = "aa"
    +Output: "a"
     
    +

    Example 4:

    + +
    +Input: s = "ae", t = "aea"
    +Output: "a"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= s.length <= 1000
    • +
    • t.length == s.length + 1
    • +
    • s and t consist of lower-case English letters.
    • +
    + ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/find-valid-matrix-given-row-and-column-sums/README.md b/problems/find-valid-matrix-given-row-and-column-sums/README.md new file mode 100644 index 000000000..340fc484a --- /dev/null +++ b/problems/find-valid-matrix-given-row-and-column-sums/README.md @@ -0,0 +1,85 @@ + + + + + + + +[< Previous](../alert-using-same-key-card-three-or-more-times-in-a-one-hour-period "Alert Using Same Key-Card Three or More Times in a One Hour Period") +                 +[Next >](../find-servers-that-handled-most-number-of-requests "Find Servers That Handled Most Number of Requests") + +## [1605. Find Valid Matrix Given Row and Column Sums (Medium)](https://leetcode.com/problems/find-valid-matrix-given-row-and-column-sums "给定行和列的和求可行矩阵") + +

    You are given two arrays rowSum and colSum of non-negative integers where rowSum[i] is the sum of the elements in the ith row and colSum[j] is the sum of the elements of the jth column of a 2D matrix. In other words, you do not know the elements of the matrix, but you do know the sums of each row and column.

    + +

    Find any matrix of non-negative integers of size rowSum.length x colSum.length that satisfies the rowSum and colSum requirements.

    + +

    Return a 2D array representing any matrix that fulfills the requirements. It's guaranteed that at least one matrix that fulfills the requirements exists.

    + +

     

    +

    Example 1:

    + +
    +Input: rowSum = [3,8], colSum = [4,7]
    +Output: [[3,0],
    +         [1,7]]
    +Explanation:
    +0th row: 3 + 0 = 0 == rowSum[0]
    +1st row: 1 + 7 = 8 == rowSum[1]
    +0th column: 3 + 1 = 4 == colSum[0]
    +1st column: 0 + 7 = 7 == colSum[1]
    +The row and column sums match, and all matrix elements are non-negative.
    +Another possible matrix is: [[1,2],
    +                             [3,5]]
    +
    + +

    Example 2:

    + +
    +Input: rowSum = [5,7,10], colSum = [8,6,8]
    +Output: [[0,5,0],
    +         [6,1,0],
    +         [2,0,8]]
    +
    + +

    Example 3:

    + +
    +Input: rowSum = [14,9], colSum = [6,9,8]
    +Output: [[0,9,5],
    +         [6,0,3]]
    +
    + +

    Example 4:

    + +
    +Input: rowSum = [1,0], colSum = [1]
    +Output: [[1],
    +         [0]]
    +
    + +

    Example 5:

    + +
    +Input: rowSum = [0], colSum = [0]
    +Output: [[0]]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= rowSum.length, colSum.length <= 500
    • +
    • 0 <= rowSum[i], colSum[i] <= 108
    • +
    • sum(rows) == sum(columns)
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Find the smallest rowSum or colSum, and let it be x. Place that number in the grid, and subtract x from rowSum and colSum. Continue until all the sums are satisfied. +
    diff --git a/problems/flower-planting-with-no-adjacent/README.md b/problems/flower-planting-with-no-adjacent/README.md index d678c816f..69302fd62 100644 --- a/problems/flower-planting-with-no-adjacent/README.md +++ b/problems/flower-planting-with-no-adjacent/README.md @@ -11,55 +11,36 @@ ## [1042. Flower Planting With No Adjacent (Easy)](https://leetcode.com/problems/flower-planting-with-no-adjacent "不邻接植花") -

    You have N gardens, labelled 1 to N.  In each garden, you want to plant one of 4 types of flowers.

    +

    You have n gardens, labeled from 1 to n, and an array paths where paths[i] = [xi, yi] describes the existence of a bidirectional path from garden xi to garden yi. In each garden, you want to plant one of 4 types of flowers.

    -

    paths[i] = [x, y] describes the existence of a bidirectional path from garden x to garden y.

    - -

    Also, there is no garden that has more than 3 paths coming into or leaving it.

    +

    There is no garden that has more than three paths coming into or leaving it.

    Your task is to choose a flower type for each garden such that, for any two gardens connected by a path, they have different types of flowers.

    -

    Return any such a choice as an array answer, where answer[i] is the type of flower planted in the (i+1)-th garden.  The flower types are denoted 1, 2, 3, or 4.  It is guaranteed an answer exists.

    +

    Return any such a choice as an array answer, where answer[i] is the type of flower planted in the (i+1)th garden.  The flower types are denoted 1, 2, 3, or 4.  It is guaranteed an answer exists.

     

    - -

    Example 1:

    - -
    -Input: N = 3, paths = [[1,2],[2,3],[3,1]]
    -Output: [1,2,3]
    -
    - -
    -

    Example 2:

    - -
    -Input: N = 4, paths = [[1,2],[3,4]]
    -Output: [1,2,1,2]
    +
    Input: n = 3, paths = [[1,2],[2,3],[3,1]]
    +Output: [1,2,3]
    +

    Example 2:

    +
    Input: n = 4, paths = [[1,2],[3,4]]
    +Output: [1,2,1,2]
    +

    Example 3:

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

    Example 3:

    - -
    -Input: N = 4, paths = [[1,2],[2,3],[3,4],[4,1],[1,3],[2,4]]
    -Output: [1,2,3,4]
    -
    -

     

    - -

    Note:

    +

    Constraints:

      -
    • 1 <= N <= 10000
    • -
    • 0 <= paths.size <= 20000
    • -
    • No garden has 4 or more paths coming into or leaving it.
    • -
    • It is guaranteed an answer exists.
    • +
    • 1 <= n <= 104
    • +
    • 0 <= paths.length <= 2 * 104
    • +
    • paths[i].length == 2
    • +
    • 1 <= xi, yi <= n
    • +
    • xi != yi
    • +
    • No garden has four or more paths coming into or leaving it.
    -
    -
    -
    ### Related Topics [[Graph](../../tag/graph/README.md)] diff --git a/problems/generate-parentheses/README.md b/problems/generate-parentheses/README.md index 2a97c5fa7..518c9789f 100644 --- a/problems/generate-parentheses/README.md +++ b/problems/generate-parentheses/README.md @@ -11,22 +11,22 @@ ## [22. Generate Parentheses (Medium)](https://leetcode.com/problems/generate-parentheses "括号生成") -

    -Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. -

    +

    Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

    -

    -For example, given n = 3, a solution set is: -

    -
    -[
    -  "((()))",
    -  "(()())",
    -  "(())()",
    -  "()(())",
    -  "()()()"
    -]
    +

     

    +

    Example 1:

    +
    Input: n = 3
    +Output: ["((()))","(()())","(())()","()(())","()()()"]
    +

    Example 2:

    +
    Input: n = 1
    +Output: ["()"]
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 8
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/guess-number-higher-or-lower/README.md b/problems/guess-number-higher-or-lower/README.md index f645a703a..f80d41dda 100644 --- a/problems/guess-number-higher-or-lower/README.md +++ b/problems/guess-number-higher-or-lower/README.md @@ -13,18 +13,20 @@

    We are playing the Guess Game. The game is as follows:

    -

    I pick a number from 1 to n. You have to guess which number I picked.

    +

    I pick a number from 1 to n. You have to guess which number I picked.

    -

    Every time you guess wrong, I'll tell you whether the number is higher or lower.

    +

    Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess.

    -

    You call a pre-defined API guess(int num) which returns 3 possible results:

    +

    You call a pre-defined API int guess(int num), which returns 3 possible results:

      -
    • -1: My number is lower
    • -
    • 1: My number is higher
    • -
    • 0: Congrats! You got it!
    • +
    • -1: The number I picked is lower than your guess (i.e. pick < num).
    • +
    • 1: The number I picked is higher than your guess (i.e. pick > num).
    • +
    • 0: The number I picked is equal to your guess (i.e. pick == num).
    +

    Return the number that I picked.

    +

     

    Example 1:

    Input: n = 10, pick = 6
    diff --git a/problems/heaters/README.md b/problems/heaters/README.md
    index db6bfe032..4ac78658c 100644
    --- a/problems/heaters/README.md
    +++ b/problems/heaters/README.md
    @@ -9,44 +9,47 @@
                     
     [Next >](../number-complement "Number Complement")
     
    -## [475. Heaters (Easy)](https://leetcode.com/problems/heaters "供暖器")
    +## [475. Heaters (Medium)](https://leetcode.com/problems/heaters "供暖器")
     
    -

    Winter is coming! Your first job during the contest is to design a standard heater with fixed warm radius to warm all the houses.

    +

    Winter is coming! During the contest, your first job is to design a standard heater with a fixed warm radius to warm all the houses.

    -

    Now, you are given positions of houses and heaters on a horizontal line, find out minimum radius of heaters so that all houses could be covered by those heaters.

    +

    Every house can be warmed, as long as the house is within the heater's warm radius range. 

    -

    So, your input will be the positions of houses and heaters seperately, and your expected output will be the minimum radius standard of heaters.

    +

    Given the positions of houses and heaters on a horizontal line, return the minimum radius standard of heaters so that those heaters could cover all houses.

    -

    Note:

    - -
      -
    1. Numbers of houses and heaters you are given are non-negative and will not exceed 25000.
    2. -
    3. Positions of houses and heaters you are given are non-negative and will not exceed 10^9.
    4. -
    5. As long as a house is in the heaters' warm radius range, it can be warmed.
    6. -
    7. All the heaters follow your radius standard and the warm radius will the same.
    8. -
    +

    Notice that all the heaters follow your radius standard, and the warm radius will the same.

     

    - -

    Example 1:

    +

    Example 1:

    -Input: [1,2,3],[2]
    -Output: 1
    -Explanation: The only heater was placed in the position 2, and if we use the radius 1 standard, then all the houses can be warmed.
    +Input: houses = [1,2,3], heaters = [2]
    +Output: 1
    +Explanation: The only heater was placed in the position 2, and if we use the radius 1 standard, then all the houses can be warmed.
     
    -

     

    +

    Example 2:

    -

    Example 2:

    +
    +Input: houses = [1,2,3,4], heaters = [1,4]
    +Output: 1
    +Explanation: The two heater was placed in the position 1 and 4. We need to use radius 1 standard, then all the houses can be warmed.
    +
    + +

    Example 3:

    -Input: [1,2,3,4],[1,4]
    -Output: 1
    -Explanation: The two heater was placed in the position 1 and 4. We need to use radius 1 standard, then all the houses can be warmed.
    +Input: houses = [1,5], heaters = [2]
    +Output: 3
     

     

    +

    Constraints:

    + +
      +
    • 1 <= houses.length, heaters.length <= 3 * 104
    • +
    • 1 <= houses[i], heaters[i] <= 109
    • +
    ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/house-robber-ii/README.md b/problems/house-robber-ii/README.md index 5afb71f24..aaca6d143 100644 --- a/problems/house-robber-ii/README.md +++ b/problems/house-robber-ii/README.md @@ -11,26 +11,42 @@ ## [213. House Robber II (Medium)](https://leetcode.com/problems/house-robber-ii "打家劫舍 II") -

    You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.

    +

    You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have a security system connected, and it will automatically contact the police if two adjacent houses were broken into on the same night.

    -

    Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police.

    +

    Given a list of non-negative integers nums representing the amount of money of each house, return the maximum amount of money you can rob tonight without alerting the police.

    +

     

    Example 1:

    -Input: [2,3,2]
    +Input: nums = [2,3,2]
     Output: 3
    -Explanation: You cannot rob house 1 (money = 2) and then rob house 3 (money = 2),
    -             because they are adjacent houses.
    +Explanation: You cannot rob house 1 (money = 2) and then rob house 3 (money = 2), because they are adjacent houses.
     

    Example 2:

    -Input: [1,2,3,1]
    +Input: nums = [1,2,3,1]
     Output: 4
     Explanation: Rob house 1 (money = 1) and then rob house 3 (money = 3).
    -             Total amount you can rob = 1 + 3 = 4.
    +Total amount you can rob = 1 + 3 = 4. +
    + +

    Example 3:

    + +
    +Input: nums = [0]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • 0 <= nums[i] <= 1000
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/implement-queue-using-stacks/README.md b/problems/implement-queue-using-stacks/README.md index 09a021b43..d9d00e0cd 100644 --- a/problems/implement-queue-using-stacks/README.md +++ b/problems/implement-queue-using-stacks/README.md @@ -11,32 +11,52 @@ ## [232. Implement Queue using Stacks (Easy)](https://leetcode.com/problems/implement-queue-using-stacks "用栈实现队列") -

    Implement the following operations of a queue using stacks.

    +

    Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (push, peek, pop, and empty).

    + +

    Implement the MyQueue class:

    + +
      +
    • void push(int x) Pushes element x to the back of the queue.
    • +
    • int pop() Removes the element from the front of the queue and returns it.
    • +
    • int peek() Returns the element at the front of the queue.
    • +
    • boolean empty() Returns true if the queue is empty, false otherwise.
    • +
    + +

    Notes:

      -
    • push(x) -- Push element x to the back of queue.
    • -
    • pop() -- Removes the element from in front of queue.
    • -
    • peek() -- Get the front element.
    • -
    • empty() -- Return whether the queue is empty.
    • +
    • You must use only standard operations of a stack, which means only push to top, peek/pop from top, size, and is empty operations are valid.
    • +
    • Depending on your language, the stack may not be supported natively. You may simulate a stack using a list or deque (double-ended queue) as long as you use only a stack's standard operations.
    -

    Example:

    +

    Follow-up: Can you implement the queue such that each operation is amortized O(1) time complexity? In other words, performing n operations will take overall O(n) time even if one of those operations may take longer.

    + +

     

    +

    Example 1:

    -MyQueue queue = new MyQueue();
    +Input
    +["MyQueue", "push", "push", "peek", "pop", "empty"]
    +[[], [1], [2], [], [], []]
    +Output
    +[null, null, null, 1, 1, false]
     
    -queue.push(1);
    -queue.push(2);  
    -queue.peek();  // returns 1
    -queue.pop();   // returns 1
    -queue.empty(); // returns false
    +Explanation +MyQueue myQueue = new MyQueue(); +myQueue.push(1); // queue is: [1] +myQueue.push(2); // queue is: [1, 2] (leftmost is front of the queue) +myQueue.peek(); // return 1 +myQueue.pop(); // return 1, queue is [2] +myQueue.empty(); // return false +
    -

    Notes:

    +

     

    +

    Constraints:

      -
    • You must use only standard operations of a stack -- which means only push to top, peek/pop from top, size, and is empty operations are valid.
    • -
    • Depending on your language, stack may not be supported natively. You may simulate a stack by using a list or deque (double-ended queue), as long as you use only standard operations of a stack.
    • -
    • You may assume that all operations are valid (for example, no pop or peek operations will be called on an empty queue).
    • +
    • 1 <= x <= 9
    • +
    • At most 100 calls will be made to push, pop, peek, and empty.
    • +
    • All the calls to pop and peek are valid.
    ### Related Topics diff --git a/problems/implement-stack-using-queues/README.md b/problems/implement-stack-using-queues/README.md index 75c6c6563..569641522 100644 --- a/problems/implement-stack-using-queues/README.md +++ b/problems/implement-stack-using-queues/README.md @@ -11,32 +11,52 @@ ## [225. Implement Stack using Queues (Easy)](https://leetcode.com/problems/implement-stack-using-queues "用队列实现栈") -

    Implement the following operations of a stack using queues.

    +

    Implement a last in first out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal queue (push, top, pop, and empty).

    + +

    Implement the MyStack class:

    + +
      +
    • void push(int x) Pushes element x to the top of the stack.
    • +
    • int pop() Removes the element on the top of the stack and returns it.
    • +
    • int top() Returns the element on the top of the stack.
    • +
    • boolean empty() Returns true if the stack is empty, false otherwise.
    • +
    + +

    Notes:

      -
    • push(x) -- Push element x onto stack.
    • -
    • pop() -- Removes the element on top of the stack.
    • -
    • top() -- Get the top element.
    • -
    • empty() -- Return whether the stack is empty.
    • +
    • You must use only standard operations of a queue, which means only push to back, peek/pop from front, size, and is empty operations are valid.
    • +
    • Depending on your language, the queue may not be supported natively. You may simulate a queue using a list or deque (double-ended queue), as long as you use only a queue's standard operations.
    -

    Example:

    +

    Follow-up: Can you implement the stack such that each operation is amortized O(1) time complexity? In other words, performing n operations will take overall O(n) time even if one of those operations may take longer.

    + +

     

    +

    Example 1:

    -MyStack stack = new MyStack();
    +Input
    +["MyStack", "push", "push", "top", "pop", "empty"]
    +[[], [1], [2], [], [], []]
    +Output
    +[null, null, null, 2, 2, false]
     
    -stack.push(1);
    -stack.push(2);  
    -stack.top();   // returns 2
    -stack.pop();   // returns 2
    -stack.empty(); // returns false
    +Explanation +MyStack myStack = new MyStack(); +myStack.push(1); +myStack.push(2); +myStack.top(); // return 2 +myStack.pop(); // return 2 +myStack.empty(); // return False + -

    Notes:

    +

     

    +

    Constraints:

      -
    • You must use only standard operations of a queue -- which means only push to back, peek/pop from front, size, and is empty operations are valid.
    • -
    • Depending on your language, queue may not be supported natively. You may simulate a queue by using a list or deque (double-ended queue), as long as you use only standard operations of a queue.
    • -
    • You may assume that all operations are valid (for example, no pop or top operations will be called on an empty stack).
    • +
    • 1 <= x <= 9
    • +
    • At most 100 calls will be made to push, pop, top, and empty.
    • +
    • All the calls to pop and top are valid.
    ### Related Topics diff --git a/problems/implement-strstr/README.md b/problems/implement-strstr/README.md index 51a0fd80f..87474f101 100644 --- a/problems/implement-strstr/README.md +++ b/problems/implement-strstr/README.md @@ -13,21 +13,7 @@

    Implement strStr().

    -

    Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.

    - -

    Example 1:

    - -
    -Input: haystack = "hello", needle = "ll"
    -Output: 2
    -
    - -

    Example 2:

    - -
    -Input: haystack = "aaaaa", needle = "bba"
    -Output: -1
    -
    +

    Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.

    Clarification:

    @@ -35,11 +21,23 @@

    For the purpose of this problem, we will return 0 when needle is an empty string. This is consistent to C's strstr() and Java's indexOf().

    +

     

    +

    Example 1:

    +
    Input: haystack = "hello", needle = "ll"
    +Output: 2
    +

    Example 2:

    +
    Input: haystack = "aaaaa", needle = "bba"
    +Output: -1
    +

    Example 3:

    +
    Input: haystack = "", needle = ""
    +Output: 0
    +

     

    Constraints:

      -
    • haystack and needle consist only of lowercase English characters.
    • +
    • 0 <= haystack.length, needle.length <= 5 * 104
    • +
    • haystack and needle consist of only lower-case English characters.
    ### Related Topics diff --git a/problems/insert-into-a-binary-search-tree/README.md b/problems/insert-into-a-binary-search-tree/README.md index 11807618d..cdbffad90 100644 --- a/problems/insert-into-a-binary-search-tree/README.md +++ b/problems/insert-into-a-binary-search-tree/README.md @@ -11,52 +11,43 @@ ## [701. Insert into a Binary Search Tree (Medium)](https://leetcode.com/problems/insert-into-a-binary-search-tree "二叉搜索树中的插入操作") -

    Given the root node of a binary search tree (BST) and a value to be inserted into the tree, insert the value into the BST. Return the root node of the BST after the insertion. It is guaranteed that the new value does not exist in the original BST.

    +

    You are given the root node of a binary search tree (BST) and a value to insert into the tree. Return the root node of the BST after the insertion. It is guaranteed that the new value does not exist in the original BST.

    -

    Note that there may exist multiple valid ways for the insertion, as long as the tree remains a BST after insertion. You can return any of them.

    - -

    For example, 

    +

    Notice that there may exist multiple valid ways for the insertion, as long as the tree remains a BST after insertion. You can return any of them.

    +

     

    +

    Example 1:

    +
    -Given the tree:
    -        4
    -       / \
    -      2   7
    -     / \
    -    1   3
    -And the value to insert: 5
    +Input: root = [4,2,7,1,3], val = 5
    +Output: [4,2,7,1,3,5]
    +Explanation: Another accepted tree is:
    +
     
    -

    You can return this binary search tree:

    +

    Example 2:

    -         4
    -       /   \
    -      2     7
    -     / \   /
    -    1   3 5
    +Input: root = [40,20,60,10,30,50,70], val = 25
    +Output: [40,20,60,10,30,50,70,null,null,25]
     
    -

    This tree is also valid:

    +

    Example 3:

    -         5
    -       /   \
    -      2     7
    -     / \   
    -    1   3
    -         \
    -          4
    +Input: root = [4,2,7,1,3,null,null,null,null,null,null], val = 5
    +Output: [4,2,7,1,3,5]
     

     

    Constraints:

      -
    • The number of nodes in the given tree will be between 0 and 10^4.
    • -
    • Each node will have a unique integer value from 0 to -10^8, inclusive.
    • -
    • -10^8 <= val <= 10^8
    • -
    • It's guaranteed that val does not exist in the original BST.
    • +
    • The number of nodes in the tree will be in the range [0, 104].
    • +
    • -108 <= Node.val <= 108
    • +
    • All the values Node.val are unique.
    • +
    • -108 <= val <= 108
    • +
    • It's guaranteed that val does not exist in the original BST.
    ### Related Topics diff --git a/problems/integer-to-roman/README.md b/problems/integer-to-roman/README.md index 3797f58c5..ddba6b7db 100644 --- a/problems/integer-to-roman/README.md +++ b/problems/integer-to-roman/README.md @@ -23,7 +23,7 @@ C 100 D 500 M 1000 -

    For example, two is written as II in Roman numeral, just two one's added together. Twelve is written as, XII, which is simply X + II. The number twenty seven is written as XXVII, which is XX + V + II.

    +

    For example, 2 is written as II in Roman numeral, just two one's added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II.

    Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not IIII. Instead, the number four is written as IV. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as IX. There are six instances where subtraction is used:

    @@ -33,30 +33,34 @@ M 1000
  • C can be placed before D (500) and M (1000) to make 400 and 900.
  • -

    Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.

    +

    Given an integer, convert it to a roman numeral.

    +

     

    Example 1:

    -Input: 3
    -Output: "III"
    +Input: num = 3 +Output: "III" +

    Example 2:

    -Input: 4
    -Output: "IV"
    +Input: num = 4 +Output: "IV" +

    Example 3:

    -Input: 9
    -Output: "IX"
    +Input: num = 9 +Output: "IX" +

    Example 4:

    -Input: 58
    +Input: num = 58
     Output: "LVIII"
     Explanation: L = 50, V = 5, III = 3.
     
    @@ -64,9 +68,17 @@ M 1000

    Example 5:

    -Input: 1994
    +Input: num = 1994
     Output: "MCMXCIV"
    -Explanation: M = 1000, CM = 900, XC = 90 and IV = 4.
    +Explanation: M = 1000, CM = 900, XC = 90 and IV = 4. + + +

     

    +

    Constraints:

    + +
      +
    • 1 <= num <= 3999
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/k-diff-pairs-in-an-array/README.md b/problems/k-diff-pairs-in-an-array/README.md index 0a12fb1b7..8b42bc118 100644 --- a/problems/k-diff-pairs-in-an-array/README.md +++ b/problems/k-diff-pairs-in-an-array/README.md @@ -9,44 +9,68 @@                  [Next >](../lonely-pixel-ii "Lonely Pixel II") -## [532. K-diff Pairs in an Array (Easy)](https://leetcode.com/problems/k-diff-pairs-in-an-array "数组中的K-diff数对") +## [532. K-diff Pairs in an Array (Medium)](https://leetcode.com/problems/k-diff-pairs-in-an-array "数组中的 k-diff 数对") -

    -Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i and j are both numbers in the array and their absolute difference is k. -

    +

    Given an array of integers nums and an integer k, return the number of unique k-diff pairs in the array.

    +

    A k-diff pair is an integer pair (nums[i], nums[j]), where the following are true:

    + +
      +
    • 0 <= i, j < nums.length
    • +
    • i != j
    • +
    • |nums[i] - nums[j]| == k
    • +
    + +

    Notice that |val| denotes the absolute value of val.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: [3, 1, 4, 1, 5], k = 2
    -Output: 2
    -Explanation: There are two 2-diff pairs in the array, (1, 3) and (3, 5).
    Although we have two 1s in the input, we should only return the number of unique pairs. +Input: nums = [3,1,4,1,5], k = 2 +Output: 2 +Explanation: There are two 2-diff pairs in the array, (1, 3) and (3, 5). +Although we have two 1s in the input, we should only return the number of unique pairs.
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input:[1, 2, 3, 4, 5], k = 1
    -Output: 4
    -Explanation: There are four 1-diff pairs in the array, (1, 2), (2, 3), (3, 4) and (4, 5).
    +Input: nums = [1,2,3,4,5], k = 1
    +Output: 4
    +Explanation: There are four 1-diff pairs in the array, (1, 2), (2, 3), (3, 4) and (4, 5).
     
    -

    -

    Example 3:
    +

    Example 3:

    +
    -Input: [1, 3, 1, 5, 4], k = 0
    -Output: 1
    -Explanation: There is one 0-diff pair in the array, (1, 1).
    +Input: nums = [1,3,1,5,4], k = 0
    +Output: 1
    +Explanation: There is one 0-diff pair in the array, (1, 1).
     
    -

    - -

    Note:
    -

      -
    1. The pairs (i, j) and (j, i) count as the same pair.
    2. -
    3. The length of the array won't exceed 10,000.
    4. -
    5. All the integers in the given input belong to the range: [-1e7, 1e7].
    6. -
    -

    + +

    Example 4:

    + +
    +Input: nums = [1,2,4,4,3,3,0,9,2,3], k = 3
    +Output: 2
    +
    + +

    Example 5:

    + +
    +Input: nums = [-1,-2,-3], k = 1
    +Output: 2
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 104
    • +
    • -107 <= nums[i] <= 107
    • +
    • 0 <= k <= 107
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/kth-largest-element-in-a-stream/README.md b/problems/kth-largest-element-in-a-stream/README.md index 8b25667eb..e43566415 100644 --- a/problems/kth-largest-element-in-a-stream/README.md +++ b/problems/kth-largest-element-in-a-stream/README.md @@ -11,28 +11,48 @@ ## [703. Kth Largest Element in a Stream (Easy)](https://leetcode.com/problems/kth-largest-element-in-a-stream "数据流中的第K大元素") -

    Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element.

    +

    Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element.

    -

    Your KthLargest class will have a constructor which accepts an integer k and an integer array nums, which contains initial elements from the stream. For each call to the method KthLargest.add, return the element representing the kth largest element in the stream.

    +

    Implement KthLargest class:

    -

    Example:

    +
      +
    • KthLargest(int k, int[] nums) Initializes the object with the integer k and the stream of integers nums.
    • +
    • int add(int val) Returns the element representing the kth largest element in the stream.
    • +
    + +

     

    +

    Example 1:

    -int k = 3;
    -int[] arr = [4,5,8,2];
    -KthLargest kthLargest = new KthLargest(3, arr);
    -kthLargest.add(3);   // returns 4
    -kthLargest.add(5);   // returns 5
    -kthLargest.add(10);  // returns 5
    -kthLargest.add(9);   // returns 8
    -kthLargest.add(4);   // returns 8
    +Input
    +["KthLargest", "add", "add", "add", "add", "add"]
    +[[3, [4, 5, 8, 2]], [3], [5], [10], [9], [4]]
    +Output
    +[null, 4, 5, 5, 8, 8]
    +
    +Explanation
    +KthLargest kthLargest = new KthLargest(3, [4, 5, 8, 2]);
    +kthLargest.add(3);   // return 4
    +kthLargest.add(5);   // return 5
    +kthLargest.add(10);  // return 5
    +kthLargest.add(9);   // return 8
    +kthLargest.add(4);   // return 8
     
    -

    Note:
    -You may assume that nums' length ≥ k-1 and k ≥ 1.

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= 104
    • +
    • 0 <= nums.length <= 104
    • +
    • -104 <= nums[i] <= 104
    • +
    • -104 <= val <= 104
    • +
    • At most 104 calls will be made to add.
    • +
    ### Related Topics [[Heap](../../tag/heap/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions 1. [Kth Largest Element in an Array](../kth-largest-element-in-an-array) (Medium) diff --git a/problems/largest-number/README.md b/problems/largest-number/README.md index a0f8e0e6a..b434066ef 100644 --- a/problems/largest-number/README.md +++ b/problems/largest-number/README.md @@ -11,22 +11,46 @@ ## [179. Largest Number (Medium)](https://leetcode.com/problems/largest-number "最大数") -

    Given a list of non negative integers, arrange them such that they form the largest number.

    +

    Given a list of non-negative integers nums, arrange them such that they form the largest number.

    +

    Note: The result may be very large, so you need to return a string instead of an integer.

    + +

     

    Example 1:

    -Input: [10,2]
    -Output: "210"
    +Input: nums = [10,2] +Output: "210" +

    Example 2:

    -Input: [3,30,34,5,9]
    -Output: "9534330"
    +Input: nums = [3,30,34,5,9]
    +Output: "9534330"
     
    -

    Note: The result may be very large, so you need to return a string instead of an integer.

    +

    Example 3:

    + +
    +Input: nums = [1]
    +Output: "1"
    +
    + +

    Example 4:

    + +
    +Input: nums = [10]
    +Output: "10"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • 0 <= nums[i] <= 109
    • +
    ### Related Topics [[Sort](../../tag/sort/README.md)] diff --git a/problems/letter-combinations-of-a-phone-number/README.md b/problems/letter-combinations-of-a-phone-number/README.md index 91aa19186..f78ed4633 100644 --- a/problems/letter-combinations-of-a-phone-number/README.md +++ b/problems/letter-combinations-of-a-phone-number/README.md @@ -11,22 +11,41 @@ ## [17. Letter Combinations of a Phone Number (Medium)](https://leetcode.com/problems/letter-combinations-of-a-phone-number "电话号码的字母组合") -

    Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.

    +

    Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order.

    A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.

    -

    +

    -

    Example:

    +

     

    +

    Example 1:

    -Input: "23"
    -Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
    +Input: digits = "23"
    +Output: ["ad","ae","af","bd","be","bf","cd","ce","cf"]
     
    -

    Note:

    +

    Example 2:

    -

    Although the above answer is in lexicographical order, your answer could be in any order you want.

    +
    +Input: digits = ""
    +Output: []
    +
    + +

    Example 3:

    + +
    +Input: digits = "2"
    +Output: ["a","b","c"]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= digits.length <= 4
    • +
    • digits[i] is a digit in the range ['2', '9'].
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/longest-common-prefix/README.md b/problems/longest-common-prefix/README.md index a5b6c63d3..f4b79da9f 100644 --- a/problems/longest-common-prefix/README.md +++ b/problems/longest-common-prefix/README.md @@ -15,24 +15,30 @@

    If there is no common prefix, return an empty string "".

    +

     

    Example 1:

    -Input: ["flower","flow","flight"]
    +Input: strs = ["flower","flow","flight"]
     Output: "fl"
     

    Example 2:

    -Input: ["dog","racecar","car"]
    +Input: strs = ["dog","racecar","car"]
     Output: ""
     Explanation: There is no common prefix among the input strings.
     
    -

    Note:

    +

     

    +

    Constraints:

    -

    All given inputs are in lowercase letters a-z.

    +
      +
    • 0 <= strs.length <= 200
    • +
    • 0 <= strs[i].length <= 200
    • +
    • strs[i] consists of only lower-case English letters.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/longest-palindromic-substring/README.md b/problems/longest-palindromic-substring/README.md index 427626ae3..c5f43fee2 100644 --- a/problems/longest-palindromic-substring/README.md +++ b/problems/longest-palindromic-substring/README.md @@ -11,12 +11,13 @@ ## [5. Longest Palindromic Substring (Medium)](https://leetcode.com/problems/longest-palindromic-substring "最长回文子串") -

    Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.

    +

    Given a string s, return the longest palindromic substring in s.

    +

     

    Example 1:

    -Input: "babad"
    +Input: s = "babad"
     Output: "bab"
     Note: "aba" is also a valid answer.
     
    @@ -24,10 +25,32 @@

    Example 2:

    -Input: "cbbd"
    +Input: s = "cbbd"
     Output: "bb"
     
    +

    Example 3:

    + +
    +Input: s = "a"
    +Output: "a"
    +
    + +

    Example 4:

    + +
    +Input: s = "ac"
    +Output: "a"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 1000
    • +
    • s consist of only digits and English letters (lower-case and/or upper-case),
    • +
    + ### Related Topics [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/longest-valid-parentheses/README.md b/problems/longest-valid-parentheses/README.md index f459e20a3..3fde54d09 100644 --- a/problems/longest-valid-parentheses/README.md +++ b/problems/longest-valid-parentheses/README.md @@ -13,22 +13,38 @@

    Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.

    +

     

    Example 1:

    -Input: "(()"
    +Input: s = "(()"
     Output: 2
    -Explanation: The longest valid parentheses substring is "()"
    +Explanation: The longest valid parentheses substring is "()".
     

    Example 2:

    -Input: ")()())"
    +Input: s = ")()())"
     Output: 4
    -Explanation: The longest valid parentheses substring is "()()"
    +Explanation: The longest valid parentheses substring is "()()".
     
    +

    Example 3:

    + +
    +Input: s = ""
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= s.length <= 3 * 104
    • +
    • s[i] is '(', or ')'.
    • +
    + ### Related Topics [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/maximum-distance-in-arrays/README.md b/problems/maximum-distance-in-arrays/README.md index 04caa67f0..1ca07307e 100644 --- a/problems/maximum-distance-in-arrays/README.md +++ b/problems/maximum-distance-in-arrays/README.md @@ -9,7 +9,7 @@                  [Next >](../minimum-factorization "Minimum Factorization") -## [624. Maximum Distance in Arrays (Easy)](https://leetcode.com/problems/maximum-distance-in-arrays "数组列表中的最大距离") +## [624. Maximum Distance in Arrays (Medium)](https://leetcode.com/problems/maximum-distance-in-arrays "数组列表中的最大距离")

    Given m arrays, and each array is sorted in ascending order. Now you can pick up two integers from two different arrays (each array picks one) and calculate the distance. We define the distance between two integers a and b to be their absolute difference |a-b|. Your task is to find the maximum distance. diff --git a/problems/maximum-level-sum-of-a-binary-tree/README.md b/problems/maximum-level-sum-of-a-binary-tree/README.md index 4754b1d4f..56f9074ac 100644 --- a/problems/maximum-level-sum-of-a-binary-tree/README.md +++ b/problems/maximum-level-sum-of-a-binary-tree/README.md @@ -16,14 +16,11 @@

    Return the smallest level X such that the sum of all the values of nodes at level X is maximal.

     

    -

    Example 1:

    - -

    - +
    -Input: [1,7,0,7,-8,null,null]
    -Output: 2
    +Input: root = [1,7,0,7,-8,null,null]
    +Output: 2
     Explanation: 
     Level 1 sum = 1.
     Level 2 sum = 7 + 0 = 7.
    @@ -31,17 +28,24 @@ Level 3 sum = 7 + -8 = -1.
     So we return the level with the maximum sum which is level 2.
     
    -

     

    +

    Example 2:

    -

    Note:

    +
    +Input: root = [989,null,10250,98693,-89388,null,null,null,-32127]
    +Output: 2
    +
    + +

     

    +

    Constraints:

    -
      -
    1. The number of nodes in the given tree is between 1 and 10^4.
    2. -
    3. -10^5 <= node.val <= 10^5
    4. -
    +
      +
    • The number of nodes in the tree is in the range [1, 104].
    • +
    • -105 <= Node.val <= 105
    • +
    ### Related Topics - [[Graph](../../tag/graph/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-achievable-transfer-requests/README.md b/problems/maximum-number-of-achievable-transfer-requests/README.md index ce393567a..f5ba90777 100644 --- a/problems/maximum-number-of-achievable-transfer-requests/README.md +++ b/problems/maximum-number-of-achievable-transfer-requests/README.md @@ -7,7 +7,7 @@ [< Previous](../throne-inheritance "Throne Inheritance")                  -Next > +[Next >](../find-nearest-right-node-in-binary-tree "Find Nearest Right Node in Binary Tree") ## [1601. Maximum Number of Achievable Transfer Requests (Hard)](https://leetcode.com/problems/maximum-number-of-achievable-transfer-requests "最多可达成的换楼请求数目") diff --git a/problems/maximum-number-of-visible-points/README.md b/problems/maximum-number-of-visible-points/README.md new file mode 100644 index 000000000..9dd342b88 --- /dev/null +++ b/problems/maximum-number-of-visible-points/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../even-odd-tree "Even Odd Tree") +                 +[Next >](../minimum-one-bit-operations-to-make-integers-zero "Minimum One Bit Operations to Make Integers Zero") + +## [1610. Maximum Number of Visible Points (Hard)](https://leetcode.com/problems/maximum-number-of-visible-points "可见点的最大数目") + +

    You are given an array points, an integer angle, and your location, where location = [posx, posy] and points[i] = [xi, yi] both denote integral coordinates on the X-Y plane.

    + +

    Initially, you are facing directly east from your position. You cannot move from your position, but you can rotate. In other words, posx and posy cannot be changed. Your field of view in degrees is represented by angle, determining how wide you can see from any given view direction. Let d be the amount in degrees that you rotate counterclockwise. Then, your field of view is the inclusive range of angles [d - angle/2, d + angle/2].

    + +

    + +

    + +

    You can see some set of points if, for each point, the angle formed by the point, your position, and the immediate east direction from your position is in your field of view.

    + +

    There can be multiple points at one coordinate. There may be points at your location, and you can always see these points regardless of your rotation. Points do not obstruct your vision to other points.

    + +

    Return the maximum number of points you can see.

    + +

     

    +

    Example 1:

    + +
    +Input: points = [[2,1],[2,2],[3,3]], angle = 90, location = [1,1]
    +Output: 3
    +Explanation: The shaded region represents your field of view. All points can be made visible in your field of view, including [3,3] even though [2,2] is in front and in the same line of sight.
    +
    + +

    Example 2:

    + +
    +Input: points = [[2,1],[2,2],[3,4],[1,1]], angle = 90, location = [1,1]
    +Output: 4
    +Explanation: All points can be made visible in your field of view, including the one at your location.
    +
    + +

    Example 3:

    + +
    +Input: points = [[1,0],[2,1]], angle = 13, location = [1,1]
    +Output: 1
    +Explanation: You can only see one of the two points, as shown above.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= points.length <= 105
    • +
    • points[i].length == 2
    • +
    • location.length == 2
    • +
    • 0 <= angle < 360
    • +
    • 0 <= posx, posy, xi, yi <= 109
    • +
    + +### Related Topics + [[Geometry](../../tag/geometry/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + +### Hints +
    +Hint 1 +Sort the points by polar angle with the original position. Now only a consecutive collection of points would be visible from any coordinate. +
    + +
    +Hint 2 +We can use two pointers to keep track of visible points for each start point +
    + +
    +Hint 3 +For handling the cyclic condition, it’d be helpful to append the point list to itself after sorting. +
    diff --git a/problems/maximum-profit-of-operating-a-centennial-wheel/README.md b/problems/maximum-profit-of-operating-a-centennial-wheel/README.md index fa141d67a..3a5ec0be3 100644 --- a/problems/maximum-profit-of-operating-a-centennial-wheel/README.md +++ b/problems/maximum-profit-of-operating-a-centennial-wheel/README.md @@ -13,11 +13,11 @@

    You are the operator of a Centennial Wheel that has four gondolas, and each gondola has room for up to four people. You have the ability to rotate the gondolas counterclockwise, which costs you runningCost dollars.

    -

    You are given an array customers of length n where customers[i] is the number of new customers arriving just before the ith rotation (0-indexed). This means you must rotate the wheel i times before customers[i] arrive. Each customer pays boardingCost dollars when they board on the gondola closest to the ground and will exit once that gondola reaches the ground again.

    +

    You are given an array customers of length n where customers[i] is the number of new customers arriving just before the ith rotation (0-indexed). This means you must rotate the wheel i times before the customers[i] customers arrive. You cannot make customers wait if there is room in the gondola. Each customer pays boardingCost dollars when they board on the gondola closest to the ground and will exit once that gondola reaches the ground again.

    You can stop the wheel at any time, including before serving all customers. If you decide to stop serving customers, all subsequent rotations are free in order to get all the customers down safely. Note that if there are currently more than four customers waiting at the wheel, only four will board the gondola, and the rest will wait for the next rotation.

    -

    Return the minimum number of rotations you need to perform to maximize your profit. If there is no scenario where the profit is positive, return -1.

    +

    Return the minimum number of rotations you need to perform to maximize your profit. If there is no scenario where the profit is positive, return -1.

     

    Example 1:

    @@ -57,7 +57,7 @@ The highest profit was $122 after rotating the wheel 7 times. 1. 3 customers arrive, 3 board and 0 wait, the wheel rotates. Current profit is 3 * $1 - 1 * $92 = -$89. 2. 4 customers arrive, 4 board and 0 wait, the wheel rotates. Current profit is 7 * $1 - 2 * $92 = -$177. 3. 0 customers arrive, 0 board and 0 wait, the wheel rotates. Current profit is 7 * $1 - 3 * $92 = -$269. -4. 5 customers arrive, 4 board and 1 waits, the wheel rotates. Current profit is 12 * $1 - 4 * $92 = -$356. +4. 5 customers arrive, 4 board and 1 waits, the wheel rotates. Current profit is 11 * $1 - 4 * $92 = -$357. 5. 1 customer arrives, 2 board and 0 wait, the wheel rotates. Current profit is 13 * $1 - 5 * $92 = -$447. The profit was never positive, so return -1. diff --git a/problems/merge-two-sorted-lists/README.md b/problems/merge-two-sorted-lists/README.md index c60d75e2a..6a43b9d3e 100644 --- a/problems/merge-two-sorted-lists/README.md +++ b/problems/merge-two-sorted-lists/README.md @@ -13,13 +13,37 @@

    Merge two sorted linked lists and return it as a new sorted list. The new list should be made by splicing together the nodes of the first two lists.

    -

    Example:

    +

     

    +

    Example 1:

    + +
    +Input: l1 = [1,2,4], l2 = [1,3,4]
    +Output: [1,1,2,3,4,4]
    +
    + +

    Example 2:

    -Input: 1->2->4, 1->3->4
    -Output: 1->1->2->3->4->4
    +Input: l1 = [], l2 = []
    +Output: []
     
    +

    Example 3:

    + +
    +Input: l1 = [], l2 = [0]
    +Output: [0]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in both lists is in the range [0, 50].
    • +
    • -100 <= Node.val <= 100
    • +
    • Both l1 and l2 are sorted in non-decreasing order.
    • +
    + ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/minimum-absolute-difference-in-bst/README.md b/problems/minimum-absolute-difference-in-bst/README.md index 4341fc091..4bc949173 100644 --- a/problems/minimum-absolute-difference-in-bst/README.md +++ b/problems/minimum-absolute-difference-in-bst/README.md @@ -44,4 +44,4 @@ The minimum absolute difference is 1, which is the difference between 2 and 1 (o [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [K-diff Pairs in an Array](../k-diff-pairs-in-an-array) (Easy) + 1. [K-diff Pairs in an Array](../k-diff-pairs-in-an-array) (Medium) diff --git a/problems/minimum-index-sum-of-two-lists/README.md b/problems/minimum-index-sum-of-two-lists/README.md index 6b4ef8820..92c64dbd8 100644 --- a/problems/minimum-index-sum-of-two-lists/README.md +++ b/problems/minimum-index-sum-of-two-lists/README.md @@ -11,43 +11,58 @@ ## [599. Minimum Index Sum of Two Lists (Easy)](https://leetcode.com/problems/minimum-index-sum-of-two-lists "两个列表的最小索引总和") -

    -Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings. -

    -

    -You need to help them find out their common interest with the least list index sum. If there is a choice tie between answers, output all of them with no order requirement. You could assume there always exists an answer. -

    +

    Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings.

    +

    You need to help them find out their common interest with the least list index sum. If there is a choice tie between answers, output all of them with no order requirement. You could assume there always exists an answer.

    + +

     

    +

    Example 1:

    + +
    +Input: list1 = ["Shogun","Tapioca Express","Burger King","KFC"], list2 = ["Piatti","The Grill at Torrey Pines","Hungry Hunter Steakhouse","Shogun"]
    +Output: ["Shogun"]
    +Explanation: The only restaurant they both like is "Shogun".
    +
    + +

    Example 2:

    + +
    +Input: list1 = ["Shogun","Tapioca Express","Burger King","KFC"], list2 = ["KFC","Shogun","Burger King"]
    +Output: ["Shogun"]
    +Explanation: The restaurant they both like and have the least index sum is "Shogun" with index sum 1 (0+1).
    +
    + +

    Example 3:

    -

    Example 1:

    -Input:
    -["Shogun", "Tapioca Express", "Burger King", "KFC"]
    -["Piatti", "The Grill at Torrey Pines", "Hungry Hunter Steakhouse", "Shogun"]
    -Output: ["Shogun"]
    -Explanation: The only restaurant they both like is "Shogun".
    +Input: list1 = ["Shogun","Tapioca Express","Burger King","KFC"], list2 = ["KFC","Burger King","Tapioca Express","Shogun"]
    +Output: ["KFC","Burger King","Tapioca Express","Shogun"]
     
    -

    -

    Example 2:
    +

    Example 4:

    + +
    +Input: list1 = ["Shogun","Tapioca Express","Burger King","KFC"], list2 = ["KNN","KFC","Burger King","Tapioca Express","Shogun"]
    +Output: ["KFC","Burger King","Tapioca Express","Shogun"]
    +
    + +

    Example 5:

    +
    -Input:
    -["Shogun", "Tapioca Express", "Burger King", "KFC"]
    -["KFC", "Shogun", "Burger King"]
    -Output: ["Shogun"]
    -Explanation: The restaurant they both like and have the least index sum is "Shogun" with index sum 1 (0+1).
    +Input: list1 = ["KFC"], list2 = ["KFC"]
    +Output: ["KFC"]
     
    -

    +

     

    +

    Constraints:

    -

    Note:
    -

      -
    1. The length of both lists will be in the range of [1, 1000].
    2. -
    3. The length of strings in both lists will be in the range of [1, 30].
    4. -
    5. The index is starting from 0 to the list length minus 1.
    6. -
    7. No duplicates in both lists.
    8. -
    -

    +
      +
    • 1 <= list1.length, list2.length <= 1000
    • +
    • 1 <= list1[i].length, list2[i].length <= 30
    • +
    • list1[i] and list2[i] consist of spaces ' ' and English letters.
    • +
    • All the stings of list1 are unique.
    • +
    • All the stings of list2 are unique.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/minimum-number-of-arrows-to-burst-balloons/README.md b/problems/minimum-number-of-arrows-to-burst-balloons/README.md index a42411d06..8954d2033 100644 --- a/problems/minimum-number-of-arrows-to-burst-balloons/README.md +++ b/problems/minimum-number-of-arrows-to-burst-balloons/README.md @@ -11,27 +11,61 @@ ## [452. Minimum Number of Arrows to Burst Balloons (Medium)](https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons "用最少数量的箭引爆气球") -

    There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal, y-coordinates don't matter and hence the x-coordinates of start and end of the diameter suffice. Start is always smaller than end. There will be at most 104 balloons.

    +

    There are some spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal, y-coordinates don't matter, and hence the x-coordinates of start and end of the diameter suffice. The start is always smaller than the end.

    -

    An arrow can be shot up exactly vertically from different points along the x-axis. A balloon with xstart and xend bursts by an arrow shot at x if xstart ≤ x ≤ xend. There is no limit to the number of arrows that can be shot. An arrow once shot keeps travelling up infinitely. The problem is to find the minimum number of arrows that must be shot to burst all balloons.

    +

    An arrow can be shot up exactly vertically from different points along the x-axis. A balloon with xstart and xend bursts by an arrow shot at x if xstart ≤ x ≤ xend. There is no limit to the number of arrows that can be shot. An arrow once shot keeps traveling up infinitely.

    -

    Example:

    +

    Given an array points where points[i] = [xstart, xend], return the minimum number of arrows that must be shot to burst all balloons.

    + +

     

    +

    Example 1:

    -Input:
    -[[10,16], [2,8], [1,6], [7,12]]
    +Input: points = [[10,16],[2,8],[1,6],[7,12]]
    +Output: 2
    +Explanation: One way is to shoot one arrow for example at x = 6 (bursting the balloons [2,8] and [1,6]) and another arrow at x = 11 (bursting the other two balloons).
    +
    -Output: -2 +

    Example 2:

    -Explanation: -One way is to shoot one arrow for example at x = 6 (bursting the balloons [2,8] and [1,6]) and another arrow at x = 11 (bursting the other two balloons). +
    +Input: points = [[1,2],[3,4],[5,6],[7,8]]
    +Output: 4
    +
    + +

    Example 3:

    + +
    +Input: points = [[1,2],[2,3],[3,4],[4,5]]
    +Output: 2
    +
    + +

    Example 4:

    + +
    +Input: points = [[1,2]]
    +Output: 1
    +
    + +

    Example 5:

    + +
    +Input: points = [[2,3],[2,3]]
    +Output: 1
     

     

    +

    Constraints:

    + +
      +
    • 0 <= points.length <= 104
    • +
    • points.length == 2
    • +
    • -231 <= xstart < xend <= 231 - 1
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Sort](../../tag/sort/README.md)] ### Similar Questions 1. [Meeting Rooms II](../meeting-rooms-ii) (Medium) diff --git a/problems/minimum-one-bit-operations-to-make-integers-zero/README.md b/problems/minimum-one-bit-operations-to-make-integers-zero/README.md new file mode 100644 index 000000000..c93f87704 --- /dev/null +++ b/problems/minimum-one-bit-operations-to-make-integers-zero/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../maximum-number-of-visible-points "Maximum Number of Visible Points") +                 +[Next >](../check-if-two-expression-trees-are-equivalent "Check If Two Expression Trees are Equivalent") + +## [1611. Minimum One Bit Operations to Make Integers Zero (Hard)](https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero "使整数变为 0 的最少操作次数") + +

    Given an integer n, you must transform it into 0 using the following operations any number of times:

    + +
      +
    • Change the rightmost (0th) bit in the binary representation of n.
    • +
    • Change the ith bit in the binary representation of n if the (i-1)th bit is set to 1 and the (i-2)th through 0th bits are set to 0.
    • +
    + +

    Return the minimum number of operations to transform n into 0.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 0
    +Output: 0
    +
    + +

    Example 2:

    + +
    +Input: n = 3
    +Output: 2
    +Explanation: The binary representation of 3 is "11".
    +"11" -> "01" with the 2nd operation since the 0th bit is 1.
    +"01" -> "00" with the 1st operation.
    +
    + +

    Example 3:

    + +
    +Input: n = 6
    +Output: 4
    +Explanation: The binary representation of 6 is "110".
    +"110" -> "010" with the 2nd operation since the 1st bit is 1 and 0th through 0th bits are 0.
    +"010" -> "011" with the 1st operation.
    +"011" -> "001" with the 2nd operation since the 0th bit is 1.
    +"001" -> "000" with the 1st operation.
    +
    + +

    Example 4:

    + +
    +Input: n = 9
    +Output: 14
    +
    + +

    Example 5:

    + +
    +Input: n = 333
    +Output: 393
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= n <= 109
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +The fastest way to convert n to zero is to remove all set bits starting from the leftmost one. Try some simple examples to learn the rule of how many steps are needed to remove one set bit. +
    + +
    +Hint 2 +consider n=2^k case first, then solve for all n. +
    diff --git a/problems/missing-number/README.md b/problems/missing-number/README.md index 5e0fa0135..420562a2b 100644 --- a/problems/missing-number/README.md +++ b/problems/missing-number/README.md @@ -11,24 +11,52 @@ ## [268. Missing Number (Easy)](https://leetcode.com/problems/missing-number "缺失数字") -

    Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.

    +

    Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.

    -

    Example 1:

    +

    Follow up: Could you implement a solution using only O(1) extra space complexity and O(n) runtime complexity?

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [3,0,1]
    +Output: 2
    +Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not appear in nums.
    +
    + +

    Example 2:

    -Input: [3,0,1]
    -Output: 2
    +Input: nums = [0,1]
    +Output: 2
    +Explanation: n = 2 since there are 2 numbers, so all numbers are in the range [0,2]. 2 is the missing number in the range since it does not appear in nums.
     
    -

    Example 2:

    +

    Example 3:

    -Input: [9,6,4,2,3,5,7,0,1]
    -Output: 8
    +Input: nums = [9,6,4,2,3,5,7,0,1]
    +Output: 8
    +Explanation: n = 9 since there are 9 numbers, so all numbers are in the range [0,9]. 8 is the missing number in the range since it does not appear in nums.
     
    -

    Note:
    -Your algorithm should run in linear runtime complexity. Could you implement it using only constant extra space complexity?

    +

    Example 4:

    + +
    +Input: nums = [0]
    +Output: 1
    +Explanation: n = 1 since there is 1 number, so all numbers are in the range [0,1]. 1 is the missing number in the range since it does not appear in nums.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= n <= 104
    • +
    • 0 <= nums[i] <= n
    • +
    • All the numbers of nums are unique.
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/next-permutation/README.md b/problems/next-permutation/README.md index 10a599c5a..ea584cb89 100644 --- a/problems/next-permutation/README.md +++ b/problems/next-permutation/README.md @@ -13,15 +13,31 @@

    Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.

    -

    If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).

    - -

    The replacement must be in-place and use only constant extra memory.

    - -

    Here are some examples. Inputs are in the left-hand column and its corresponding outputs are in the right-hand column.

    - -

    1,2,31,3,2
    -3,2,11,2,3
    -1,1,51,5,1

    +

    If such an arrangement is not possible, it must rearrange it as the lowest possible order (i.e., sorted in ascending order).

    + +

    The replacement must be in place and use only constant extra memory.

    + +

     

    +

    Example 1:

    +
    Input: nums = [1,2,3]
    +Output: [1,3,2]
    +

    Example 2:

    +
    Input: nums = [3,2,1]
    +Output: [1,2,3]
    +

    Example 3:

    +
    Input: nums = [1,1,5]
    +Output: [1,5,1]
    +

    Example 4:

    +
    Input: nums = [1]
    +Output: [1]
    +
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • 0 <= nums[i] <= 100
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/nim-game/README.md b/problems/nim-game/README.md index 7e542acab..f4aa57c9e 100644 --- a/problems/nim-game/README.md +++ b/problems/nim-game/README.md @@ -11,18 +11,50 @@ ## [292. Nim Game (Easy)](https://leetcode.com/problems/nim-game "Nim 游戏") -

    You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the winner. You will take the first turn to remove the stones.

    +

    You are playing the following Nim Game with your friend:

    -

    Both of you are very clever and have optimal strategies for the game. Write a function to determine whether you can win the game given the number of stones in the heap.

    +
      +
    • Initially, there is a heap of stones on the table.
    • +
    • You and your friend will alternate taking turns, and you go first.
    • +
    • On each turn, the person whose turn it is will remove 1 to 3 stones from the heap.
    • +
    • The one who removes the last stone is the winner.
    • +
    -

    Example:

    +

    Given n, the number of stones in the heap, return true if you can win the game assuming both you and your friend play optimally, otherwise return false.

    + +

     

    +

    Example 1:

    -Input: 4
    -Output: false 
    -Explanation: If there are 4 stones in the heap, then you will never win the game;
    -             No matter 1, 2, or 3 stones you remove, the last stone will always be 
    -             removed by your friend.
    +Input: n = 4 +Output: false +Explanation: These are the possible outcomes: +1. You remove 1 stone. Your friend removes 3 stones, including the last stone. Your friend wins. +2. You remove 2 stones. Your friend removes 2 stones, including the last stone. Your friend wins. +3. You remove 3 stones. Your friend removes the last stone. Your friend wins. +In all outcomes, your friend wins. + + +

    Example 2:

    + +
    +Input: n = 1
    +Output: true
    +
    + +

    Example 3:

    + +
    +Input: n = 2
    +Output: true
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 231 - 1
    • +
    ### Related Topics [[Brainteaser](../../tag/brainteaser/README.md)] diff --git a/problems/number-of-1-bits/README.md b/problems/number-of-1-bits/README.md index 5afa56ced..10d3d29b7 100644 --- a/problems/number-of-1-bits/README.md +++ b/problems/number-of-1-bits/README.md @@ -11,7 +11,7 @@ ## [191. Number of 1 Bits (Easy)](https://leetcode.com/problems/number-of-1-bits "位1的个数") -

    Write a function that takes an unsigned integer and return the number of '1' bits it has (also known as the Hamming weight).

    +

    Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight).

     

    @@ -43,15 +43,13 @@

    Note:

      -
    • Note that in some languages such as Java, there is no unsigned integer type. In this case, the input will be given as signed integer type and should not affect your implementation, as the internal binary representation of the integer is the same whether it is signed or unsigned.
    • -
    • In Java, the compiler represents the signed integers using 2's complement notation. Therefore, in Example 3 above the input represents the signed integer -3.
    • +
    • Note that in some languages such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type and should not affect your implementation, as the internal binary representation of the integer is the same, whether it is signed or unsigned.
    • +
    • In Java, the compiler represents the signed integers using 2's complement notation. Therefore, in Example 3 above, the input represents the signed integer. -3.

     

    -

    Follow up:

    - -

    If this function is called many times, how would you optimize it?

    +

    Follow up: If this function is called many times, how would you optimize it?

    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/number-of-atoms/README.md b/problems/number-of-atoms/README.md index 26381eb74..3103dce90 100644 --- a/problems/number-of-atoms/README.md +++ b/problems/number-of-atoms/README.md @@ -11,53 +11,60 @@ ## [726. Number of Atoms (Hard)](https://leetcode.com/problems/number-of-atoms "原子的数量") -

    Given a chemical formula (given as a string), return the count of each atom. -

    -An atomic element always starts with an uppercase character, then zero or more lowercase letters, representing the name. -

    -1 or more digits representing the count of that element may follow if the count is greater than 1. If the count is 1, no digits will follow. For example, H2O and H2O2 are possible, but H1O2 is impossible. -

    -Two formulas concatenated together produce another formula. For example, H2O2He3Mg4 is also a formula. -

    -A formula placed in parentheses, and a count (optionally added) is also a formula. For example, (H2O2) and (H2O2)3 are formulas. -

    -Given a formula, output the count of all elements as a string in the following form: the first name (in sorted order), followed by its count (if that count is more than 1), followed by the second name (in sorted order), followed by its count (if that count is more than 1), and so on.

    - -

    Example 1:
    +

    Given a chemical formula (given as a string), return the count of each atom.

    + +

    The atomic element always starts with an uppercase character, then zero or more lowercase letters, representing the name.

    + +

    One or more digits representing that element's count may follow if the count is greater than 1. If the count is 1, no digits will follow. For example, H2O and H2O2 are possible, but H1O2 is impossible.

    + +

    Two formulas concatenated together to produce another formula. For example, H2O2He3Mg4 is also a formula.

    + +

    A formula placed in parentheses, and a count (optionally added) is also a formula. For example, (H2O2) and (H2O2)3 are formulas.

    + +

    Given a formula, return the count of all elements as a string in the following form: the first name (in sorted order), followed by its count (if that count is more than 1), followed by the second name (in sorted order), followed by its count (if that count is more than 1), and so on.

    + +

     

    + +

     

    +

    Example 1:

    +
    -Input: 
    -formula = "H2O"
    -Output: "H2O"
    -Explanation: 
    -The count of elements are {'H': 2, 'O': 1}.
    +Input: formula = "H2O"
    +Output: "H2O"
    +Explanation: The count of elements are {'H': 2, 'O': 1}.
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: 
    -formula = "Mg(OH)2"
    -Output: "H2MgO2"
    -Explanation: 
    -The count of elements are {'H': 2, 'Mg': 1, 'O': 2}.
    +Input: formula = "Mg(OH)2"
    +Output: "H2MgO2"
    +Explanation: The count of elements are {'H': 2, 'Mg': 1, 'O': 2}.
     
    -

    -

    Example 3:
    +

    Example 3:

    +
    -Input: 
    -formula = "K4(ON(SO3)2)2"
    -Output: "K4N2O14S4"
    -Explanation: 
    -The count of elements are {'K': 4, 'N': 2, 'O': 14, 'S': 4}.
    +Input: formula = "K4(ON(SO3)2)2"
    +Output: "K4N2O14S4"
    +Explanation: The count of elements are {'K': 4, 'N': 2, 'O': 14, 'S': 4}.
     
    -

    -

    Note: -

  • All atom names consist of lowercase letters, except for the first character which is uppercase.
  • -
  • The length of formula will be in the range [1, 1000].
  • -
  • formula will only consist of letters, digits, and round parentheses, and is a valid formula as defined in the problem.
  • -

    +

    Example 4:

    + +
    +Input: formula = "Be32"
    +Output: "Be32"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= formula.length <= 1000
    • +
    • formula consists of English letters, digits, '(', and ')'.
    • +
    • formula is always valid.
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/number-of-recent-calls/README.md b/problems/number-of-recent-calls/README.md index e224a7778..9fedfb406 100644 --- a/problems/number-of-recent-calls/README.md +++ b/problems/number-of-recent-calls/README.md @@ -44,7 +44,7 @@ recentCounter.ping(3002); // requests = [1, 100, 3001, 3002Constraints:

      -
    • 1 <= t <= 104
    • +
    • 1 <= t <= 109
    • Each test case will call ping with strictly increasing values of t.
    • At most 104 calls will be made to ping.
    diff --git a/problems/palindrome-number/README.md b/problems/palindrome-number/README.md index 9db9b5d44..95d7cba96 100644 --- a/problems/palindrome-number/README.md +++ b/problems/palindrome-number/README.md @@ -13,17 +13,20 @@

    Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.

    +

    Follow up: Could you solve it without converting the integer to a string?

    + +

     

    Example 1:

    -Input: 121
    +Input: x = 121
     Output: true
     

    Example 2:

    -Input: -121
    +Input: x = -121
     Output: false
     Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.
     
    @@ -31,14 +34,24 @@

    Example 3:

    -Input: 10
    +Input: x = 10
     Output: false
     Explanation: Reads 01 from right to left. Therefore it is not a palindrome.
     
    -

    Follow up:

    +

    Example 4:

    + +
    +Input: x = -101
    +Output: false
    +
    + +

     

    +

    Constraints:

    -

    Could you solve it without converting the integer to a string?

    +
      +
    • -231 <= x <= 231 - 1
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/perfect-number/README.md b/problems/perfect-number/README.md index ad5382ff1..49cdc968c 100644 --- a/problems/perfect-number/README.md +++ b/problems/perfect-number/README.md @@ -11,22 +11,54 @@ ## [507. Perfect Number (Easy)](https://leetcode.com/problems/perfect-number "完美数") -

    We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself. -

    -Now, given an integer n, write a function that returns true when it is a perfect number and false when it is not. -

    +

    A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. A divisor of an integer x is an integer that can divide x evenly.

    + +

    Given an integer n, return true if n is a perfect number, otherwise return false.

    + +

     

    +

    Example 1:

    + +
    +Input: num = 28
    +Output: true
    +Explanation: 28 = 1 + 2 + 4 + 7 + 14
    +1, 2, 4, 7, and 14 are all divisors of 28.
    +
    + +

    Example 2:

    + +
    +Input: num = 6
    +Output: true
    +
    + +

    Example 3:

    -

    Example:

    -Input: 28
    -Output: True
    -Explanation: 28 = 1 + 2 + 4 + 7 + 14
    +Input: num = 496
    +Output: true
     
    -

    -

    Note: -The input number n will not exceed 100,000,000. (1e8) -

    +

    Example 4:

    + +
    +Input: num = 8128
    +Output: true
    +
    + +

    Example 5:

    + +
    +Input: num = 2
    +Output: false
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= num <= 108
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/put-boxes-into-the-warehouse-i/README.md b/problems/put-boxes-into-the-warehouse-i/README.md index f110826d1..d35fb933c 100644 --- a/problems/put-boxes-into-the-warehouse-i/README.md +++ b/problems/put-boxes-into-the-warehouse-i/README.md @@ -9,7 +9,7 @@                  [Next >](../unique-orders-and-customers-per-month "Unique Orders and Customers Per Month") -## [1564. Put Boxes Into the Warehouse I (Medium)](https://leetcode.com/problems/put-boxes-into-the-warehouse-i "") +## [1564. Put Boxes Into the Warehouse I (Medium)](https://leetcode.com/problems/put-boxes-into-the-warehouse-i "把箱子放进仓库里 I") diff --git a/problems/range-addition-ii/README.md b/problems/range-addition-ii/README.md index 50752f199..6ef6fca3a 100644 --- a/problems/range-addition-ii/README.md +++ b/problems/range-addition-ii/README.md @@ -11,43 +11,43 @@ ## [598. Range Addition II (Easy)](https://leetcode.com/problems/range-addition-ii "范围求和 II") -

    Given an m * n matrix M initialized with all 0's and several update operations.

    -

    Operations are represented by a 2D array, and each operation is represented by an array with two positive integers a and b, which means M[i][j] should be added by one for all 0 <= i < a and 0 <= j < b.

    -

    You need to count and return the number of maximum integers in the matrix after performing all the operations.

    +

    You are given an m x n matrix M initialized with all 0's and an array of operations ops, where ops[i] = [ai, bi] means M[x][y] should be incremented by one for all 0 <= x < ai and 0 <= y < bi.

    + +

    Count and return the number of maximum integers in the matrix after performing all the operations.

    + +

     

    +

    Example 1:

    + +
    +Input: m = 3, n = 3, ops = [[2,2],[3,3]]
    +Output: 4
    +Explanation: The maximum integer in M is 2, and there are four of it in M. So return 4.
    +
    + +

    Example 2:

    -

    Example 1:

    -Input: 
    -m = 3, n = 3
    -operations = [[2,2],[3,3]]
    -Output: 4
    -Explanation: 
    -Initially, M = 
    -[[0, 0, 0],
    - [0, 0, 0],
    - [0, 0, 0]]
    -
    -After performing [2,2], M = 
    -[[1, 1, 0],
    - [1, 1, 0],
    - [0, 0, 0]]
    -
    -After performing [3,3], M = 
    -[[2, 2, 1],
    - [2, 2, 1],
    - [1, 1, 1]]
    -
    -So the maximum integer in M is 2, and there are four of it in M. So return 4.
    +Input: m = 3, n = 3, ops = [[2,2],[3,3],[3,3],[3,3],[2,2],[3,3],[3,3],[3,3],[2,2],[3,3],[3,3],[3,3]]
    +Output: 4
     
    -

    - -

    Note:
    -

      -
    1. The range of m and n is [1,40000].
    2. -
    3. The range of a is [1,m], and the range of b is [1,n].
    4. -
    5. The range of operations size won't exceed 10,000.
    6. -
    -

    + +

    Example 3:

    + +
    +Input: m = 3, n = 3, ops = []
    +Output: 9
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= m, n <= 4 * 104
    • +
    • 1 <= ops.length <= 104
    • +
    • ops[i].length == 2
    • +
    • 1 <= ai <= m
    • +
    • 1 <= bi <= n
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/rectangle-overlap/README.md b/problems/rectangle-overlap/README.md index 1665c47ed..97f645c86 100644 --- a/problems/rectangle-overlap/README.md +++ b/problems/rectangle-overlap/README.md @@ -11,32 +11,33 @@ ## [836. Rectangle Overlap (Easy)](https://leetcode.com/problems/rectangle-overlap "矩形重叠") -

    A rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) are the coordinates of its bottom-left corner, and (x2, y2) are the coordinates of its top-right corner.

    +

    An axis-aligned rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) is the coordinate of its bottom-left corner, and (x2, y2) is the coordinate of its top-right corner. Its top and bottom edges are parallel to the X-axis, and its left and right edges are parallel to the Y-axis.

    -

    Two rectangles overlap if the area of their intersection is positive.  To be clear, two rectangles that only touch at the corner or edges do not overlap.

    +

    Two rectangles overlap if the area of their intersection is positive. To be clear, two rectangles that only touch at the corner or edges do not overlap.

    -

    Given two (axis-aligned) rectangles, return whether they overlap.

    +

    Given two axis-aligned rectangles rec1 and rec2, return true if they overlap, otherwise return false.

    +

     

    Example 1:

    - -
    -Input: rec1 = [0,0,2,2], rec2 = [1,1,3,3]
    -Output: true
    -
    - -

    Example 2:

    - -
    -Input: rec1 = [0,0,1,1], rec2 = [1,0,2,1]
    -Output: false
    +
    Input: rec1 = [0,0,2,2], rec2 = [1,1,3,3]
    +Output: true
    +

    Example 2:

    +
    Input: rec1 = [0,0,1,1], rec2 = [1,0,2,1]
    +Output: false
    +

    Example 3:

    +
    Input: rec1 = [0,0,1,1], rec2 = [2,2,3,3]
    +Output: false
     
    - -

    Notes:

    - -
      -
    1. Both rectangles rec1 and rec2 are lists of 4 integers.
    2. -
    3. All coordinates in rectangles will be between -10^9 and 10^9.
    4. -
    +

     

    +

    Constraints:

    + +
      +
    • rect1.length == 4
    • +
    • rect2.length == 4
    • +
    • -109 <= rec1[i], rec2[i] <= 109
    • +
    • rec1[0] <= rec1[2] and rec1[1] <= rec1[3]
    • +
    • rec2[0] <= rec2[2] and rec2[1] <= rec2[3]
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/regular-expression-matching/README.md b/problems/regular-expression-matching/README.md index 62ae6afc9..0a3a2d4d6 100644 --- a/problems/regular-expression-matching/README.md +++ b/problems/regular-expression-matching/README.md @@ -11,28 +11,20 @@ ## [10. Regular Expression Matching (Hard)](https://leetcode.com/problems/regular-expression-matching "正则表达式匹配") -

    Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'.

    - -
    -'.' Matches any single character.
    -'*' Matches zero or more of the preceding element.
    -
    - -

    The matching should cover the entire input string (not partial).

    - -

    Note:

    +

    Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*' where: 

      -
    • s could be empty and contains only lowercase letters a-z.
    • -
    • p could be empty and contains only lowercase letters a-z, and characters like . or *.
    • +
    • '.' Matches any single character.​​​​
    • +
    • '*' Matches zero or more of the preceding element.
    +

    The matching should cover the entire input string (not partial).

    + +

     

    Example 1:

    -Input:
    -s = "aa"
    -p = "a"
    +Input: s = "aa", p = "a"
     Output: false
     Explanation: "a" does not match the entire string "aa".
     
    @@ -40,9 +32,7 @@ p = "a"

    Example 2:

    -Input:
    -s = "aa"
    -p = "a*"
    +Input: s = "aa", p = "a*"
     Output: true
     Explanation: '*' means zero or more of the preceding element, 'a'. Therefore, by repeating 'a' once, it becomes "aa".
     
    @@ -50,9 +40,7 @@ p = "a*"

    Example 3:

    -Input:
    -s = "ab"
    -p = ".*"
    +Input: s = "ab", p = ".*"
     Output: true
     Explanation: ".*" means "zero or more (*) of any character (.)".
     
    @@ -60,9 +48,7 @@ p = ".*"

    Example 4:

    -Input:
    -s = "aab"
    -p = "c*a*b"
    +Input: s = "aab", p = "c*a*b"
     Output: true
     Explanation: c can be repeated 0 times, a can be repeated 1 time. Therefore, it matches "aab".
     
    @@ -70,12 +56,20 @@ p = "c*a*b"

    Example 5:

    -Input:
    -s = "mississippi"
    -p = "mis*is*p*."
    +Input: s = "mississippi", p = "mis*is*p*."
     Output: false
     
    +

     

    +

    Constraints:

    + +
      +
    • 0 <= s.length <= 20
    • +
    • 0 <= p.length <= 30
    • +
    • s contains only lowercase English letters.
    • +
    • p contains only lowercase English letters, '.', and '*'.
    • +
    + ### Related Topics [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/remove-covered-intervals/README.md b/problems/remove-covered-intervals/README.md index 9afd3c7cf..c7b2705d9 100644 --- a/problems/remove-covered-intervals/README.md +++ b/problems/remove-covered-intervals/README.md @@ -11,9 +11,11 @@ ## [1288. Remove Covered Intervals (Medium)](https://leetcode.com/problems/remove-covered-intervals "删除被覆盖区间") -

    Given a list of intervals, remove all intervals that are covered by another interval in the list. Interval [a,b) is covered by interval [c,d) if and only if c <= a and b <= d.

    +

    Given a list of intervals, remove all intervals that are covered by another interval in the list.

    -

    After doing so, return the number of remaining intervals.

    +

    Interval [a,b) is covered by interval [c,d) if and only if c <= a and b <= d.

    + +

    After doing so, return the number of remaining intervals.

     

    Example 1:

    @@ -24,16 +26,47 @@ Explanation: Interval [3,6] is covered by [2,8], therefore it is removed.
    +

    Example 2:

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

    Example 3:

    + +
    +Input: intervals = [[0,10],[5,12]]
    +Output: 2
    +
    + +

    Example 4:

    + +
    +Input: intervals = [[3,10],[4,10],[5,11]]
    +Output: 2
    +
    + +

    Example 5:

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

     

    Constraints:

    • 1 <= intervals.length <= 1000
    • +
    • intervals[i].length == 2
    • 0 <= intervals[i][0] < intervals[i][1] <= 10^5
    • -
    • intervals[i] != intervals[j] for all i != j
    • +
    • All the intervals are unique.
    ### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Sort](../../tag/sort/README.md)] [[Line Sweep](../../tag/line-sweep/README.md)] ### Hints diff --git a/problems/remove-duplicate-letters/README.md b/problems/remove-duplicate-letters/README.md index 996d871f6..90a2726dd 100644 --- a/problems/remove-duplicate-letters/README.md +++ b/problems/remove-duplicate-letters/README.md @@ -9,26 +9,42 @@                  [Next >](../shortest-distance-from-all-buildings "Shortest Distance from All Buildings") -## [316. Remove Duplicate Letters (Hard)](https://leetcode.com/problems/remove-duplicate-letters "去除重复字母") +## [316. Remove Duplicate Letters (Medium)](https://leetcode.com/problems/remove-duplicate-letters "去除重复字母") -

    Given a string which contains only lowercase letters, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.

    +

    Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.

    -

    Example 1:

    +

    Note: This question is the same as 1081: https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/

    + +

     

    +

    Example 1:

    -Input: "bcabc"
    -Output: "abc"
    +Input: s = "bcabc"
    +Output: "abc"
     
    -

    Example 2:

    +

    Example 2:

    -Input: "cbacdcbc"
    -Output: "acdb"
    +Input: s = "cbacdcbc"
    +Output: "acdb"
     
    -

    Note: This question is the same as 1081: https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 104
    • +
    • s consists of lowercase English letters.
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Greedily try to add one missing character. How to check if adding some character will not cause problems ? Use bit-masks to check whether you will be able to complete the sub-sequence if you add the character at some index i. +
    diff --git a/problems/remove-nth-node-from-end-of-list/README.md b/problems/remove-nth-node-from-end-of-list/README.md index 9ee4efe81..a18c4e920 100644 --- a/problems/remove-nth-node-from-end-of-list/README.md +++ b/problems/remove-nth-node-from-end-of-list/README.md @@ -11,23 +11,41 @@ ## [19. Remove Nth Node From End of List (Medium)](https://leetcode.com/problems/remove-nth-node-from-end-of-list "删除链表的倒数第N个节点") -

    Given a linked list, remove the n-th node from the end of list and return its head.

    +

    Given the head of a linked list, remove the nth node from the end of the list and return its head.

    -

    Example:

    +

    Follow up: Could you do this in one pass?

    +

     

    +

    Example 1:

    +
    -Given linked list: 1->2->3->4->5, and n = 2.
    +Input: head = [1,2,3,4,5], n = 2
    +Output: [1,2,3,5]
    +
    + +

    Example 2:

    -After removing the second node from the end, the linked list becomes 1->2->3->5. +
    +Input: head = [1], n = 1
    +Output: []
     
    -

    Note:

    +

    Example 3:

    -

    Given n will always be valid.

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

    Follow up:

    +

     

    +

    Constraints:

    -

    Could you do this in one pass?

    +
      +
    • The number of nodes in the list is sz.
    • +
    • 1 <= sz <= 30
    • +
    • 0 <= Node.val <= 100
    • +
    • 1 <= n <= sz
    • +
    ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md b/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md index a3baf7c43..21f99a538 100644 --- a/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md +++ b/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md @@ -51,12 +51,8 @@

    Constraints:

      -
    • -

      1 <= s.length <= 100

      -
    • -
    • -

      s contains only lower case English letters and '?'.

      -
    • +
    • 1 <= s.length <= 100
    • +
    • s contains only lower case English letters and '?'.
    ### Related Topics diff --git a/problems/reverse-bits/README.md b/problems/reverse-bits/README.md index 43bb1f27a..2170049d8 100644 --- a/problems/reverse-bits/README.md +++ b/problems/reverse-bits/README.md @@ -13,43 +13,39 @@

    Reverse bits of a given 32 bits unsigned integer.

    -

     

    +

    Note:

    + +
      +
    • Note that in some languages such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer's internal binary representation is the same, whether it is signed or unsigned.
    • +
    • In Java, the compiler represents the signed integers using 2's complement notation. Therefore, in Example 2 above, the input represents the signed integer -3 and the output represents the signed integer -1073741825.
    • +
    + +

    Follow up:

    + +

    If this function is called many times, how would you optimize it?

    +

     

    Example 1:

    -Input: 00000010100101000001111010011100
    -Output: 00111001011110000010100101000000
    -Explanation: The input binary string 00000010100101000001111010011100 represents the unsigned integer 43261596, so return 964176192 which its binary representation is 00111001011110000010100101000000.
    +Input: n = 00000010100101000001111010011100
    +Output:    964176192 (00111001011110000010100101000000)
    +Explanation: The input binary string 00000010100101000001111010011100 represents the unsigned integer 43261596, so return 964176192 which its binary representation is 00111001011110000010100101000000.
     

    Example 2:

    -Input: 11111111111111111111111111111101
    -Output: 10111111111111111111111111111111
    -Explanation: The input binary string 11111111111111111111111111111101 represents the unsigned integer 4294967293, so return 3221225471 which its binary representation is 10111111111111111111111111111111.
    - -

     

    - -

    Note:

    - -
      -
    • Note that in some languages such as Java, there is no unsigned integer type. In this case, both input and output will be given as signed integer type and should not affect your implementation, as the internal binary representation of the integer is the same whether it is signed or unsigned.
    • -
    • In Java, the compiler represents the signed integers using 2's complement notation. Therefore, in Example 2 above the input represents the signed integer -3 and the output represents the signed integer -1073741825.
    • -
    - -

     

    - -

    Follow up:

    - -

    If this function is called many times, how would you optimize it?

    +Input: n = 11111111111111111111111111111101 +Output: 3221225471 (10111111111111111111111111111111) +Explanation: The input binary string 11111111111111111111111111111101 represents the unsigned integer 4294967293, so return 3221225471 which its binary representation is 10111111111111111111111111111111. +

     

    Constraints:

      -
    • The input must be a binary string of length = 32
    • +
    • The input must be a binary string of length 32
    ### Related Topics diff --git a/problems/reverse-integer/README.md b/problems/reverse-integer/README.md index 610746349..ac306fad2 100644 --- a/problems/reverse-integer/README.md +++ b/problems/reverse-integer/README.md @@ -13,29 +13,29 @@

    Given a 32-bit signed integer, reverse digits of an integer.

    -

    Example 1:

    +

    Note:
    +Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.

    -
    -Input: 123
    +

     

    +

    Example 1:

    +
    Input: x = 123
     Output: 321
    -
    - -

    Example 2:

    - -
    -Input: -123
    +

    Example 2:

    +
    Input: x = -123
     Output: -321
    -
    - -

    Example 3:

    - -
    -Input: 120
    +

    Example 3:

    +
    Input: x = 120
     Output: 21
    +

    Example 4:

    +
    Input: x = 0
    +Output: 0
     
    +

     

    +

    Constraints:

    -

    Note:
    -Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.

    +
      +
    • -231 <= x <= 231 - 1
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/reverse-nodes-in-k-group/README.md b/problems/reverse-nodes-in-k-group/README.md index 3bdf974b6..6e316eddf 100644 --- a/problems/reverse-nodes-in-k-group/README.md +++ b/problems/reverse-nodes-in-k-group/README.md @@ -13,24 +13,52 @@

    Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.

    -

    k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.

    +

    k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes, in the end, should remain as it is.

    + +

    Follow up:

      +
    • Could you solve the problem in O(1) extra memory space?
    • +
    • You may not alter the values in the list's nodes, only nodes itself may be changed.
    -

    Example:

    +

     

    +

    Example 1:

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

    Example 2:

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

    Given this linked list: 1->2->3->4->5

    +

    Example 3:

    -

    For k = 2, you should return: 2->1->4->3->5

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

    For k = 3, you should return: 3->2->1->4->5

    +

    Example 4:

    -

    Note:

    +
    +Input: head = [1], k = 1
    +Output: [1]
    +
    + +

     

    +

    Constraints:

      -
    • Only constant extra memory is allowed.
    • -
    • You may not alter the values in the list's nodes, only nodes itself may be changed.
    • +
    • The number of nodes in the list is in the range sz.
    • +
    • 1 <= sz <= 5000
    • +
    • 0 <= Node.val <= 1000
    • +
    • 1 <= k <= sz
    ### Related Topics diff --git a/problems/reverse-words-in-a-string-ii/README.md b/problems/reverse-words-in-a-string-ii/README.md index 9ddda9082..5a6b559af 100644 --- a/problems/reverse-words-in-a-string-ii/README.md +++ b/problems/reverse-words-in-a-string-ii/README.md @@ -34,4 +34,4 @@ ### Similar Questions 1. [Reverse Words in a String](../reverse-words-in-a-string) (Medium) - 1. [Rotate Array](../rotate-array) (Easy) + 1. [Rotate Array](../rotate-array) (Medium) diff --git a/problems/reverse-words-in-a-string/README.md b/problems/reverse-words-in-a-string/README.md index a146c81f6..b7ee01055 100644 --- a/problems/reverse-words-in-a-string/README.md +++ b/problems/reverse-words-in-a-string/README.md @@ -11,48 +11,70 @@ ## [151. Reverse Words in a String (Medium)](https://leetcode.com/problems/reverse-words-in-a-string "翻转字符串里的单词") -

    Given an input string, reverse the string word by word.

    +

    Given an input string s, reverse the order of the words.

    -

     

    +

    A word is defined as a sequence of non-space characters. The words in s will be separated by at least one space.

    + +

    Return a string of the words in reverse order concatenated by a single space.

    + +

    Note that s may contain leading or trailing spaces or multiple spaces between two words. The returned string should only have a single space separating the words. Do not include any extra spaces.

    +

     

    Example 1:

    -Input: "the sky is blue"
    -Output: "blue is sky the"
    +Input: s = "the sky is blue"
    +Output: "blue is sky the"
     

    Example 2:

    -Input: "  hello world!  "
    -Output: "world! hello"
    +Input: s = "  hello world  "
    +Output: "world hello"
     Explanation: Your reversed string should not contain leading or trailing spaces.
     

    Example 3:

    -Input: "a good   example"
    -Output: "example good a"
    +Input: s = "a good   example"
    +Output: "example good a"
     Explanation: You need to reduce multiple spaces between two words to a single space in the reversed string.
     
    -

     

    +

    Example 4:

    -

    Note:

    +
    +Input: s = "  Bob    Loves  Alice   "
    +Output: "Alice Loves Bob"
    +
    + +

    Example 5:

    + +
    +Input: s = "Alice does not even like bob"
    +Output: "bob like even not does Alice"
    +
    + +

     

    +

    Constraints:

      -
    • A word is defined as a sequence of non-space characters.
    • -
    • Input string may contain leading or trailing spaces. However, your reversed string should not contain leading or trailing spaces.
    • -
    • You need to reduce multiple spaces between two words to a single space in the reversed string.
    • +
    • 1 <= s.length <= 104
    • +
    • s contains English letters (upper-case and lower-case), digits, and spaces ' '.
    • +
    • There is at least one word in s.

     

    Follow up:

    -

    For C programmers, try to solve it in-place in O(1) extra space.

    +
      +
    • Could you solve it in-place with O(1) extra space?
    • +
    + +

     

    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/roman-to-integer/README.md b/problems/roman-to-integer/README.md index 41b7c6519..595718a95 100644 --- a/problems/roman-to-integer/README.md +++ b/problems/roman-to-integer/README.md @@ -23,7 +23,7 @@ C 100 D 500 M 1000
    -

    For example, two is written as II in Roman numeral, just two one's added together. Twelve is written as, XII, which is simply X + II. The number twenty seven is written as XXVII, which is XX + V + II.

    +

    For example, 2 is written as II in Roman numeral, just two one's added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II.

    Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not IIII. Instead, the number four is written as IV. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as IX. There are six instances where subtraction is used:

    @@ -33,30 +33,34 @@ M 1000
  • C can be placed before D (500) and M (1000) to make 400 and 900.
  • -

    Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.

    +

    Given a roman numeral, convert it to an integer.

    +

     

    Example 1:

    -Input: "III"
    -Output: 3
    +Input: s = "III" +Output: 3 +

    Example 2:

    -Input: "IV"
    -Output: 4
    +Input: s = "IV" +Output: 4 +

    Example 3:

    -Input: "IX"
    -Output: 9
    +Input: s = "IX" +Output: 9 +

    Example 4:

    -Input: "LVIII"
    +Input: s = "LVIII"
     Output: 58
     Explanation: L = 50, V= 5, III = 3.
     
    @@ -64,9 +68,19 @@ M 1000

    Example 5:

    -Input: "MCMXCIV"
    +Input: s = "MCMXCIV"
     Output: 1994
    -Explanation: M = 1000, CM = 900, XC = 90 and IV = 4.
    +Explanation: M = 1000, CM = 900, XC = 90 and IV = 4. + + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 15
    • +
    • s contains only the characters ('I', 'V', 'X', 'L', 'C', 'D', 'M').
    • +
    • It is guaranteed that s is a valid roman numeral in the range [1, 3999].
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/rotate-array/README.md b/problems/rotate-array/README.md index af79af5b7..5a5bb930d 100644 --- a/problems/rotate-array/README.md +++ b/problems/rotate-array/README.md @@ -9,7 +9,7 @@                  [Next >](../reverse-bits "Reverse Bits") -## [189. Rotate Array (Easy)](https://leetcode.com/problems/rotate-array "旋转数组") +## [189. Rotate Array (Medium)](https://leetcode.com/problems/rotate-array "旋转数组")

    Given an array, rotate the array to the right by k steps, where k is non-negative.

    @@ -46,9 +46,9 @@ rotate 2 steps to the right: [3,99,-1,-100]

    Constraints:

      -
    • 1 <= nums.length <= 2 * 10^4
    • -
    • It's guaranteed that nums[i] fits in a 32 bit-signed integer.
    • -
    • k >= 0
    • +
    • 1 <= nums.length <= 2 * 104
    • +
    • -231 <= nums[i] <= 231 - 1
    • +
    • 0 <= k <= 105
    ### Related Topics diff --git a/problems/rotate-list/README.md b/problems/rotate-list/README.md index 183cea056..9a099e4bc 100644 --- a/problems/rotate-list/README.md +++ b/problems/rotate-list/README.md @@ -39,5 +39,5 @@ rotate 4 steps to the right: 2->0->1->NULL [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions - 1. [Rotate Array](../rotate-array) (Easy) + 1. [Rotate Array](../rotate-array) (Medium) 1. [Split Linked List in Parts](../split-linked-list-in-parts) (Medium) diff --git a/problems/search-a-2d-matrix/README.md b/problems/search-a-2d-matrix/README.md index de3448811..70176897f 100644 --- a/problems/search-a-2d-matrix/README.md +++ b/problems/search-a-2d-matrix/README.md @@ -11,37 +11,44 @@ ## [74. Search a 2D Matrix (Medium)](https://leetcode.com/problems/search-a-2d-matrix "搜索二维矩阵") -

    Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:

    +

    Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:

    • Integers in each row are sorted from left to right.
    • The first integer of each row is greater than the last integer of the previous row.
    +

     

    Example 1:

    - +
    -Input:
    -matrix = [
    -  [1,   3,  5,  7],
    -  [10, 11, 16, 20],
    -  [23, 30, 34, 50]
    -]
    -target = 3
    +Input: matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,50]], target = 3
     Output: true
     

    Example 2:

    + +
    +Input: matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,50]], target = 13
    +Output: false
    +
    + +

    Example 3:

    -Input:
    -matrix = [
    -  [1,   3,  5,  7],
    -  [10, 11, 16, 20],
    -  [23, 30, 34, 50]
    -]
    -target = 13
    -Output: false
    +Input: matrix = [], target = 0 +Output: false + + +

     

    +

    Constraints:

    + +
      +
    • m == matrix.length
    • +
    • n == matrix[i].length
    • +
    • 0 <= m, n <= 100
    • +
    • -104 <= matrix[i][j], target <= 104
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/search-insert-position/README.md b/problems/search-insert-position/README.md index 7526ec17d..834581031 100644 --- a/problems/search-insert-position/README.md +++ b/problems/search-insert-position/README.md @@ -11,37 +11,34 @@ ## [35. Search Insert Position (Easy)](https://leetcode.com/problems/search-insert-position "搜索插入位置") -

    Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.

    - -

    You may assume no duplicates in the array.

    +

    Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.

    +

     

    Example 1:

    - -
    -Input: [1,3,5,6], 5
    +
    Input: nums = [1,3,5,6], target = 5
     Output: 2
    -
    - -

    Example 2:

    - -
    -Input: [1,3,5,6], 2
    +

    Example 2:

    +
    Input: nums = [1,3,5,6], target = 2
     Output: 1
    -
    - -

    Example 3:

    - -
    -Input: [1,3,5,6], 7
    +

    Example 3:

    +
    Input: nums = [1,3,5,6], target = 7
     Output: 4
    -
    - -

    Example 4:

    - -
    -Input: [1,3,5,6], 0
    +

    Example 4:

    +
    Input: nums = [1,3,5,6], target = 0
    +Output: 0
    +

    Example 5:

    +
    Input: nums = [1], target = 0
     Output: 0
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 104
    • +
    • -104 <= nums[i] <= 104
    • +
    • nums contains distinct values sorted in ascending order.
    • +
    • -104 <= target <= 104
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/sellers-with-no-sales/README.md b/problems/sellers-with-no-sales/README.md new file mode 100644 index 000000000..725bce583 --- /dev/null +++ b/problems/sellers-with-no-sales/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../find-servers-that-handled-most-number-of-requests "Find Servers That Handled Most Number of Requests") +                 +[Next >](../special-array-with-x-elements-greater-than-or-equal-x "Special Array With X Elements Greater Than or Equal X") + +## [1607. Sellers With No Sales (Easy)](https://leetcode.com/problems/sellers-with-no-sales "") + + diff --git a/problems/sellers-with-no-sales/mysql_schemas.sql b/problems/sellers-with-no-sales/mysql_schemas.sql new file mode 100644 index 000000000..4e56240ee --- /dev/null +++ b/problems/sellers-with-no-sales/mysql_schemas.sql @@ -0,0 +1,19 @@ +Create table If Not Exists Customer (customer_id int, customer_name varchar(20)); +Create table If Not Exists Orders (order_id int, sale_date date, order_cost int, customer_id int, seller_id int) +; +Create table If Not Exists Seller (seller_id int, seller_name varchar(20)) +; +Truncate table Customer; +insert into Customer (customer_id, customer_name) values ('101', 'Alice'); +insert into Customer (customer_id, customer_name) values ('102', 'Bob'); +insert into Customer (customer_id, customer_name) values ('103', 'Charlie'); +Truncate table Orders; +insert into Orders (order_id, sale_date, order_cost, customer_id, seller_id) values ('1', '2020-03-01', '1500', '101', '1'); +insert into Orders (order_id, sale_date, order_cost, customer_id, seller_id) values ('2', '2020-05-25', '2400', '102', '2'); +insert into Orders (order_id, sale_date, order_cost, customer_id, seller_id) values ('3', '2019-05-25', '800', '101', '3'); +insert into Orders (order_id, sale_date, order_cost, customer_id, seller_id) values ('4', '2020-09-13', '1000', '103', '2'); +insert into Orders (order_id, sale_date, order_cost, customer_id, seller_id) values ('5', '2019-02-11', '700', '101', '2'); +Truncate table Seller; +insert into Seller (seller_id, seller_name) values ('1', 'Daniel'); +insert into Seller (seller_id, seller_name) values ('2', 'Elizabeth'); +insert into Seller (seller_id, seller_name) values ('3', 'Frank'); diff --git a/problems/serialize-and-deserialize-bst/README.md b/problems/serialize-and-deserialize-bst/README.md index 254f98ab9..0615a42a6 100644 --- a/problems/serialize-and-deserialize-bst/README.md +++ b/problems/serialize-and-deserialize-bst/README.md @@ -11,13 +11,28 @@ ## [449. Serialize and Deserialize BST (Medium)](https://leetcode.com/problems/serialize-and-deserialize-bst "序列化和反序列化二叉搜索树") -

    Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment.

    +

    Serialization is converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment.

    -

    Design an algorithm to serialize and deserialize a binary search tree. There is no restriction on how your serialization/deserialization algorithm should work. You just need to ensure that a binary search tree can be serialized to a string and this string can be deserialized to the original tree structure.

    +

    Design an algorithm to serialize and deserialize a binary search tree. There is no restriction on how your serialization/deserialization algorithm should work. You need to ensure that a binary search tree can be serialized to a string, and this string can be deserialized to the original tree structure.

    The encoded string should be as compact as possible.

    -

    Note: Do not use class member/global/static variables to store states. Your serialize and deserialize algorithms should be stateless.

    +

     

    +

    Example 1:

    +
    Input: root = [2,1,3]
    +Output: [2,1,3]
    +

    Example 2:

    +
    Input: root = []
    +Output: []
    +
    +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [0, 104].
    • +
    • 0 <= Node.val <= 104
    • +
    • The input tree is guaranteed to be a binary search tree.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/shortest-completing-word/README.md b/problems/shortest-completing-word/README.md index f434ecf5c..133d351f9 100644 --- a/problems/shortest-completing-word/README.md +++ b/problems/shortest-completing-word/README.md @@ -9,7 +9,7 @@                  [Next >](../contain-virus "Contain Virus") -## [748. Shortest Completing Word (Easy)](https://leetcode.com/problems/shortest-completing-word "最短完整词") +## [748. Shortest Completing Word (Easy)](https://leetcode.com/problems/shortest-completing-word "最短补全词")

    Given a string licensePlate and an array of strings words, find the shortest completing word in words.

    diff --git a/problems/shortest-unsorted-continuous-subarray/README.md b/problems/shortest-unsorted-continuous-subarray/README.md index fcdd6de27..b6debfd6d 100644 --- a/problems/shortest-unsorted-continuous-subarray/README.md +++ b/problems/shortest-unsorted-continuous-subarray/README.md @@ -9,26 +9,42 @@                  [Next >](../kill-process "Kill Process") -## [581. Shortest Unsorted Continuous Subarray (Easy)](https://leetcode.com/problems/shortest-unsorted-continuous-subarray "最短无序连续子数组") +## [581. Shortest Unsorted Continuous Subarray (Medium)](https://leetcode.com/problems/shortest-unsorted-continuous-subarray "最短无序连续子数组") -

    Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too.

    +

    Given an integer array nums, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order.

    -

    You need to find the shortest such subarray and output its length.

    +

    Return the shortest such subarray and output its length.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [2,6,4,8,10,9,15]
    +Output: 5
    +Explanation: You need to sort [6, 4, 8, 10, 9] in ascending order to make the whole array sorted in ascending order.
    +
    + +

    Example 2:

    -

    Example 1:

    -Input: [2, 6, 4, 8, 10, 9, 15]
    -Output: 5
    -Explanation: You need to sort [6, 4, 8, 10, 9] in ascending order to make the whole array sorted in ascending order.
    +Input: nums = [1,2,3,4]
    +Output: 0
     
    -

    - -

    Note:
    -

      -
    1. Then length of the input array is in range [1, 10,000].
    2. -
    3. The input array may contain duplicates, so ascending order here means <=.
    4. -
    -

    + +

    Example 3:

    + +
    +Input: nums = [1]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 104
    • +
    • -105 <= nums[i] <= 105
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/single-number/README.md b/problems/single-number/README.md index b9e4ca162..9f34cd764 100644 --- a/problems/single-number/README.md +++ b/problems/single-number/README.md @@ -11,25 +11,29 @@ ## [136. Single Number (Easy)](https://leetcode.com/problems/single-number "只出现一次的数字") -

    Given a non-empty array of integers, every element appears twice except for one. Find that single one.

    +

    Given a non-empty array of integers nums, every element appears twice except for one. Find that single one.

    -

    Note:

    - -

    Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?

    +

    Follow up: Could you implement a solution with a linear runtime complexity and without using extra memory?

    +

     

    Example 1:

    - -
    -Input: [2,2,1]
    +
    Input: nums = [2,2,1]
     Output: 1
    -
    - -

    Example 2:

    - -
    -Input: [4,1,2,1,2]
    +

    Example 2:

    +
    Input: nums = [4,1,2,1,2]
     Output: 4
    +

    Example 3:

    +
    Input: nums = [1]
    +Output: 1
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 3 * 104
    • +
    • -3 * 104 <= nums[i] <= 3 * 104
    • +
    • Each element in the array appears twice except for one element which appears only once.
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/smallest-subsequence-of-distinct-characters/README.md b/problems/smallest-subsequence-of-distinct-characters/README.md index 51438c964..9edaced6f 100644 --- a/problems/smallest-subsequence-of-distinct-characters/README.md +++ b/problems/smallest-subsequence-of-distinct-characters/README.md @@ -11,54 +11,36 @@ ## [1081. Smallest Subsequence of Distinct Characters (Medium)](https://leetcode.com/problems/smallest-subsequence-of-distinct-characters "不同字符的最小子序列") -

    Return the lexicographically smallest subsequence of text that contains all the distinct characters of text exactly once.

    +

    Return the lexicographically smallest subsequence of s that contains all the distinct characters of s exactly once.

    +

    Note: This question is the same as 316: https://leetcode.com/problems/remove-duplicate-letters/

    + +

     

    Example 1:

    -Input: "cdadabcc"
    -Output: "adbc"
    +Input: s = "bcabc"
    +Output: "abc"
     
    -

    Example 2:

    -Input: "abcd"
    -Output: "abcd"
    -
    - -
    -

    Example 3:

    - -
    -Input: "ecbacba"
    -Output: "eacb"
    -
    - -
    -

    Example 4:

    - -
    -Input: "leetcode"
    -Output: "letcod"
    +Input: s = "cbacdcbc"
    +Output: "acdb"
     

     

    -

    Constraints:

    -
      -
    1. 1 <= text.length <= 1000
    2. -
    3. text consists of lowercase English letters.
    4. -
    - -

    Note: This question is the same as 316: https://leetcode.com/problems/remove-duplicate-letters/

    -
    -
    -
    +
      +
    • 1 <= s.length <= 1000
    • +
    • s consists of lowercase English letters.
    • +
    ### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md b/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md new file mode 100644 index 000000000..9c6d14092 --- /dev/null +++ b/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](../sellers-with-no-sales "Sellers With No Sales") +                 +[Next >](../even-odd-tree "Even Odd Tree") + +## [1608. Special Array With X Elements Greater Than or Equal X (Easy)](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x "特殊数组的特征值") + +

    You are given an array nums of non-negative integers. nums is considered special if there exists a number x such that there are exactly x numbers in nums that are greater than or equal to x.

    + +

    Notice that x does not have to be an element in nums.

    + +

    Return x if the array is special, otherwise, return -1. It can be proven that if nums is special, the value for x is unique.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [3,5]
    +Output: 2
    +Explanation: There are 2 values (3 and 5) that are greater than or equal to 2.
    +
    + +

    Example 2:

    + +
    +Input: nums = [0,0]
    +Output: -1
    +Explanation: No numbers fit the criteria for x.
    +If x = 0, there should be 0 numbers >= x, but there are 2.
    +If x = 1, there should be 1 number >= x, but there are 0.
    +If x = 2, there should be 2 numbers >= x, but there are 0.
    +x cannot be greater since there are only 2 numbers in nums.
    +
    + +

    Example 3:

    + +
    +Input: nums = [0,4,3,0,4]
    +Output: 3
    +Explanation: There are 3 values that are greater than or equal to 3.
    +
    + +

    Example 4:

    + +
    +Input: nums = [3,6,7,7,0]
    +Output: -1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • 0 <= nums[i] <= 1000
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Count the number of elements greater than or equal to x for each x in the range [0, nums.length]. +
    + +
    +Hint 2 +If for any x, the condition satisfies, return that x. Otherwise, there is no answer. +
    diff --git a/problems/string-to-integer-atoi/README.md b/problems/string-to-integer-atoi/README.md index 767154ac4..b0a5c214b 100644 --- a/problems/string-to-integer-atoi/README.md +++ b/problems/string-to-integer-atoi/README.md @@ -13,7 +13,7 @@

    Implement atoi which converts a string to an integer.

    -

    The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value.

    +

    The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value.

    The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function.

    @@ -24,30 +24,30 @@

    Note:

      -
    • Only the space character ' ' is considered as whitespace character.
    • -
    • Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. If the numerical value is out of the range of representable values, INT_MAX (231 − 1) or INT_MIN (−231) is returned.
    • +
    • Only the space character ' ' is considered a whitespace character.
    • +
    • Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. If the numerical value is out of the range of representable values, INT_MAX (231 − 1) or INT_MIN (−231) is returned.
    +

     

    Example 1:

    -Input: "42"
    +Input: str = "42"
     Output: 42
     

    Example 2:

    -Input: "   -42"
    +Input: str = "   -42"
     Output: -42
    -Explanation: The first non-whitespace character is '-', which is the minus sign.
    -             Then take as many numerical digits as possible, which gets 42.
    +Explanation: The first non-whitespace character is '-', which is the minus sign. Then take as many numerical digits as possible, which gets 42.
     

    Example 3:

    -Input: "4193 with words"
    +Input: str = "4193 with words"
     Output: 4193
     Explanation: Conversion stops at digit '3' as the next character is not a numerical digit.
     
    @@ -55,18 +55,26 @@

    Example 4:

    -Input: "words and 987"
    +Input: str = "words and 987"
     Output: 0
    -Explanation: The first non-whitespace character is 'w', which is not a numerical 
    -             digit or a +/- sign. Therefore no valid conversion could be performed.
    +Explanation: The first non-whitespace character is 'w', which is not a numerical digit or a +/- sign. Therefore no valid conversion could be performed. +

    Example 5:

    -Input: "-91283472332"
    +Input: str = "-91283472332"
     Output: -2147483648
    -Explanation: The number "-91283472332" is out of the range of a 32-bit signed integer.
    -             Thefore INT_MIN (−231) is returned.
    +Explanation: The number "-91283472332" is out of the range of a 32-bit signed integer. Thefore INT_MIN (−231) is returned. +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= s.length <= 200
    • +
    • s consists of English letters (lower-case and upper-case), digits, ' ', '+', '-' and '.'.
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/sudoku-solver/README.md b/problems/sudoku-solver/README.md index a1e6c8ae4..b1f0b8ad1 100644 --- a/problems/sudoku-solver/README.md +++ b/problems/sudoku-solver/README.md @@ -18,23 +18,30 @@
    1. Each of the digits 1-9 must occur exactly once in each row.
    2. Each of the digits 1-9 must occur exactly once in each column.
    3. -
    4. Each of the the digits 1-9 must occur exactly once in each of the 9 3x3 sub-boxes of the grid.
    5. +
    6. Each of the digits 1-9 must occur exactly once in each of the 9 3x3 sub-boxes of the grid.
    -

    Empty cells are indicated by the character '.'.

    +

    The '.' character indicates empty cells.

    -


    -A sudoku puzzle...

    +

     

    +

    Example 1:

    + +
    +Input: board = [["5","3",".",".","7",".",".",".","."],["6",".",".","1","9","5",".",".","."],[".","9","8",".",".",".",".","6","."],["8",".",".",".","6",".",".",".","3"],["4",".",".","8",".","3",".",".","1"],["7",".",".",".","2",".",".",".","6"],[".","6",".",".",".",".","2","8","."],[".",".",".","4","1","9",".",".","5"],[".",".",".",".","8",".",".","7","9"]]
    +Output: [["5","3","4","6","7","8","9","1","2"],["6","7","2","1","9","5","3","4","8"],["1","9","8","3","4","2","5","6","7"],["8","5","9","7","6","1","4","2","3"],["4","2","6","8","5","3","7","9","1"],["7","1","3","9","2","4","8","5","6"],["9","6","1","5","3","7","2","8","4"],["2","8","7","4","1","9","6","3","5"],["3","4","5","2","8","6","1","7","9"]]
    +Explanation: The input board is shown above and the only valid solution is shown below:
     
    -


    -...and its solution numbers marked in red.

    + +
    -

    Note:

    +

     

    +

    Constraints:

      -
    • The given board contain only digits 1-9 and the character '.'.
    • -
    • You may assume that the given Sudoku puzzle will have a single unique solution.
    • -
    • The given board size is always 9x9.
    • +
    • board.length == 9
    • +
    • board[i].length == 9
    • +
    • board[i][j] is a digit or '.'.
    • +
    • It is guaranteed that the input board has only one solution.
    ### Related Topics diff --git a/problems/summary-ranges/README.md b/problems/summary-ranges/README.md index 89f7fc379..8f63f6cef 100644 --- a/problems/summary-ranges/README.md +++ b/problems/summary-ranges/README.md @@ -11,24 +11,71 @@ ## [228. Summary Ranges (Medium)](https://leetcode.com/problems/summary-ranges "汇总区间") -

    Given a sorted integer array without duplicates, return the summary of its ranges.

    +

    You are given a sorted unique integer array nums.

    -

    Example 1:

    +

    Return the smallest sorted list of ranges that cover all the numbers in the array exactly. That is, each element of nums is covered by exactly one of the ranges, and there is no integer x such that x is in one of the ranges but not in nums.

    + +

    Each range [a,b] in the list should be output as:

    + +
      +
    • "a->b" if a != b
    • +
    • "a" if a == b
    • +
    + +

     

    +

    Example 1:

    -Input:  [0,1,2,4,5,7]
    -Output: ["0->2","4->5","7"]
    -Explanation: 0,1,2 form a continuous range; 4,5 form a continuous range.
    +Input: nums = [0,1,2,4,5,7]
    +Output: ["0->2","4->5","7"]
    +Explanation: The ranges are:
    +[0,2] --> "0->2"
    +[4,5] --> "4->5"
    +[7,7] --> "7"
     
    -

    Example 2:

    +

    Example 2:

    -Input:  [0,2,3,4,6,8,9]
    -Output: ["0","2->4","6","8->9"]
    -Explanation: 2,3,4 form a continuous range; 8,9 form a continuous range.
    +Input: nums = [0,2,3,4,6,8,9]
    +Output: ["0","2->4","6","8->9"]
    +Explanation: The ranges are:
    +[0,0] --> "0"
    +[2,4] --> "2->4"
    +[6,6] --> "6"
    +[8,9] --> "8->9"
     
    +

    Example 3:

    + +
    +Input: nums = []
    +Output: []
    +
    + +

    Example 4:

    + +
    +Input: nums = [-1]
    +Output: ["-1"]
    +
    + +

    Example 5:

    + +
    +Input: nums = [0]
    +Output: ["0"]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= nums.length <= 20
    • +
    • -231 <= nums[i] <= 231 - 1
    • +
    • All the values of nums are unique.
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/swap-adjacent-in-lr-string/README.md b/problems/swap-adjacent-in-lr-string/README.md index caf43aa97..2f569c5f1 100644 --- a/problems/swap-adjacent-in-lr-string/README.md +++ b/problems/swap-adjacent-in-lr-string/README.md @@ -17,10 +17,9 @@

    Example 1:

    -Input: start = "X", end = "L"
    -Output: false
    -Explanation:
    -We can transform start to end following these steps:
    +Input: start = "RXXLRXRXL", end = "XRLXXRRLX"
    +Output: true
    +Explanation: We can transform start to end following these steps:
     RXXLRXRXL ->
     XRXLRXRXL ->
     XRLXRXRXL ->
    @@ -31,12 +30,26 @@ XRLXXRRLX
     

    Example 2:

    -Input: start = "LLR", end = "RRL"
    +Input: start = "X", end = "L"
     Output: false
     

    Example 3:

    +
    +Input: start = "LLR", end = "RRL"
    +Output: false
    +
    + +

    Example 4:

    + +
    +Input: start = "XL", end = "LX"
    +Output: true
    +
    + +

    Example 5:

    +
     Input: start = "XLLR", end = "LXLX"
     Output: false
    diff --git a/problems/swap-nodes-in-pairs/README.md b/problems/swap-nodes-in-pairs/README.md
    index 096ab636b..aa9588786 100644
    --- a/problems/swap-nodes-in-pairs/README.md
    +++ b/problems/swap-nodes-in-pairs/README.md
    @@ -13,16 +13,38 @@
     
     

    Given a linked list, swap every two adjacent nodes and return its head.

    -

    You may not modify the values in the list's nodes, only nodes itself may be changed.

    +

    You may not modify the values in the list's nodes. Only nodes itself may be changed.

     

    +

    Example 1:

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

    Example:

    +

    Example 2:

    -Given 1->2->3->4, you should return the list as 2->1->4->3.
    +Input: head = []
    +Output: []
     
    +

    Example 3:

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

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is in the range [0, 100].
    • +
    • 0 <= Node.val <= 100
    • +
    + ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/the-most-similar-path-in-a-graph/README.md b/problems/the-most-similar-path-in-a-graph/README.md index 7d17a5781..42400599b 100644 --- a/problems/the-most-similar-path-in-a-graph/README.md +++ b/problems/the-most-similar-path-in-a-graph/README.md @@ -9,7 +9,7 @@                  [Next >](../the-most-recent-orders-for-each-product "The Most Recent Orders for Each Product") -## [1548. The Most Similar Path in a Graph (Hard)](https://leetcode.com/problems/the-most-similar-path-in-a-graph "") +## [1548. The Most Similar Path in a Graph (Hard)](https://leetcode.com/problems/the-most-similar-path-in-a-graph "图中最相似的路径") diff --git a/problems/trim-a-binary-search-tree/README.md b/problems/trim-a-binary-search-tree/README.md index dc8f2cbb1..b49488b06 100644 --- a/problems/trim-a-binary-search-tree/README.md +++ b/problems/trim-a-binary-search-tree/README.md @@ -11,7 +11,9 @@ ## [669. Trim a Binary Search Tree (Easy)](https://leetcode.com/problems/trim-a-binary-search-tree "修剪二叉搜索树") -

    Given the root of a binary search tree and the lowest and highest boundaries as low and high, trim the tree so that all its elements lies in [low, high]. You might need to change the root of the tree, so the result should return the new root of the trimmed binary search tree.

    +

    Given the root of a binary search tree and the lowest and highest boundaries as low and high, trim the tree so that all its elements lies in [low, high]. Trimming the tree should not change the relative structure of the elements that will remain in the tree (i.e., any node's descendant should remain a descendant). It can be proven that there is a unique answer.

    + +

    Return the root of the trimmed binary search tree. Note that the root may change depending on the given bounds.

     

    Example 1:

    @@ -57,7 +59,7 @@
  • 0 <= Node.val <= 104
  • The value of each node in the tree is unique.
  • root is guaranteed to be a valid binary search tree.
  • -
  • 0 <= l <= r <= 104
  • +
  • 0 <= low <= high <= 104
  • ### Related Topics diff --git a/problems/unique-orders-and-customers-per-month/README.md b/problems/unique-orders-and-customers-per-month/README.md index 46e6e5f16..d45872da8 100644 --- a/problems/unique-orders-and-customers-per-month/README.md +++ b/problems/unique-orders-and-customers-per-month/README.md @@ -9,6 +9,6 @@                  [Next >](../detect-pattern-of-length-m-repeated-k-or-more-times "Detect Pattern of Length M Repeated K or More Times") -## [1565. Unique Orders and Customers Per Month (Easy)](https://leetcode.com/problems/unique-orders-and-customers-per-month "") +## [1565. Unique Orders and Customers Per Month (Easy)](https://leetcode.com/problems/unique-orders-and-customers-per-month "按月统计订单数与顾客数") diff --git a/problems/valid-sudoku/README.md b/problems/valid-sudoku/README.md index 653c6f0cd..ab5eb36a0 100644 --- a/problems/valid-sudoku/README.md +++ b/problems/valid-sudoku/README.md @@ -11,64 +11,62 @@ ## [36. Valid Sudoku (Medium)](https://leetcode.com/problems/valid-sudoku "有效的数独") -

    Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:

    +

    Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:

    1. Each row must contain the digits 1-9 without repetition.
    2. Each column must contain the digits 1-9 without repetition.
    3. -
    4. Each of the 9 3x3 sub-boxes of the grid must contain the digits 1-9 without repetition.
    5. +
    6. Each of the nine 3 x 3 sub-boxes of the grid must contain the digits 1-9 without repetition.
    -


    -A partially filled sudoku which is valid.

    +

    Note:

    -

    The Sudoku board could be partially filled, where empty cells are filled with the character '.'.

    +
      +
    • A Sudoku board (partially filled) could be valid but is not necessarily solvable.
    • +
    • Only the filled cells need to be validated according to the mentioned rules.
    • +
    +

     

    Example 1:

    - +
    -Input:
    -[
    -  ["5","3",".",".","7",".",".",".","."],
    -  ["6",".",".","1","9","5",".",".","."],
    -  [".","9","8",".",".",".",".","6","."],
    -  ["8",".",".",".","6",".",".",".","3"],
    -  ["4",".",".","8",".","3",".",".","1"],
    -  ["7",".",".",".","2",".",".",".","6"],
    -  [".","6",".",".",".",".","2","8","."],
    -  [".",".",".","4","1","9",".",".","5"],
    -  [".",".",".",".","8",".",".","7","9"]
    -]
    +Input: board = 
    +[["5","3",".",".","7",".",".",".","."]
    +,["6",".",".","1","9","5",".",".","."]
    +,[".","9","8",".",".",".",".","6","."]
    +,["8",".",".",".","6",".",".",".","3"]
    +,["4",".",".","8",".","3",".",".","1"]
    +,["7",".",".",".","2",".",".",".","6"]
    +,[".","6",".",".",".",".","2","8","."]
    +,[".",".",".","4","1","9",".",".","5"]
    +,[".",".",".",".","8",".",".","7","9"]]
     Output: true
     

    Example 2:

    -Input:
    -[
    -  ["8","3",".",".","7",".",".",".","."],
    -  ["6",".",".","1","9","5",".",".","."],
    -  [".","9","8",".",".",".",".","6","."],
    -  ["8",".",".",".","6",".",".",".","3"],
    -  ["4",".",".","8",".","3",".",".","1"],
    -  ["7",".",".",".","2",".",".",".","6"],
    -  [".","6",".",".",".",".","2","8","."],
    -  [".",".",".","4","1","9",".",".","5"],
    -  [".",".",".",".","8",".",".","7","9"]
    -]
    +Input: board = 
    +[["8","3",".",".","7",".",".",".","."]
    +,["6",".",".","1","9","5",".",".","."]
    +,[".","9","8",".",".",".",".","6","."]
    +,["8",".",".",".","6",".",".",".","3"]
    +,["4",".",".","8",".","3",".",".","1"]
    +,["7",".",".",".","2",".",".",".","6"]
    +,[".","6",".",".",".",".","2","8","."]
    +,[".",".",".","4","1","9",".",".","5"]
    +,[".",".",".",".","8",".",".","7","9"]]
     Output: false
    -Explanation: Same as Example 1, except with the 5 in the top left corner being 
    -    modified to 8. Since there are two 8's in the top left 3x3 sub-box, it is invalid.
    +Explanation: Same as Example 1, except with the 5 in the top left corner being modified to 8. Since there are two 8's in the top left 3x3 sub-box, it is invalid.
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • A Sudoku board (partially filled) could be valid but is not necessarily solvable.
    • -
    • Only the filled cells need to be validated according to the mentioned rules.
    • -
    • The given board contain only digits 1-9 and the character '.'.
    • -
    • The given board size is always 9x9.
    • +
    • board.length == 9
    • +
    • board[i].length == 9
    • +
    • board[i][j] is a digit or '.'.
    ### Related Topics diff --git a/problems/zigzag-conversion/README.md b/problems/zigzag-conversion/README.md index e0b4c7f6a..de6d1e232 100644 --- a/problems/zigzag-conversion/README.md +++ b/problems/zigzag-conversion/README.md @@ -24,8 +24,10 @@ Y I R

    Write the code that will take a string and make this conversion given a number of rows:

    -string convert(string s, int numRows);
    +string convert(string s, int numRows); +
    +

     

    Example 1:

    @@ -36,14 +38,30 @@ string convert(string s, int numRows);

    Example 2:

    -Input: s = "PAYPALISHIRING", numRows = 4
    -Output: "PINALSIGYAHRPI"
    +Input: s = "PAYPALISHIRING", numRows = 4
    +Output: "PINALSIGYAHRPI"
     Explanation:
    -
     P     I    N
     A   L S  I G
     Y A   H R
    -P     I
    +P I +
    + +

    Example 3:

    + +
    +Input: s = "A", numRows = 1
    +Output: "A"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 1000
    • +
    • s consists of English letters (lower-case and upper-case), ',' and '.'.
    • +
    • 1 <= numRows <= 1000
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/readme/1-300.md b/readme/1-300.md index 82c772a6e..307cbb528 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -258,7 +258,7 @@ LeetCode Problems' Solutions | 186 | [Reverse Words in a String II](https://leetcode.com/problems/reverse-words-in-a-string-ii "翻转字符串里的单词 II") 🔒 | [Go](../problems/reverse-words-in-a-string-ii) | Medium | | 187 | [Repeated DNA Sequences](https://leetcode.com/problems/repeated-dna-sequences "重复的DNA序列") | [Go](../problems/repeated-dna-sequences) | Medium | | 188 | [Best Time to Buy and Sell Stock IV](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv "买卖股票的最佳时机 IV") | [Go](../problems/best-time-to-buy-and-sell-stock-iv) | Hard | -| 189 | [Rotate Array](https://leetcode.com/problems/rotate-array "旋转数组") | [Go](../problems/rotate-array) | Easy | +| 189 | [Rotate Array](https://leetcode.com/problems/rotate-array "旋转数组") | [Go](../problems/rotate-array) | Medium | | 190 | [Reverse Bits](https://leetcode.com/problems/reverse-bits "颠倒二进制位") | [Go](../problems/reverse-bits) | Easy | | 191 | [Number of 1 Bits](https://leetcode.com/problems/number-of-1-bits "位1的个数") | [Go](../problems/number-of-1-bits) | Easy | | 192 | [Word Frequency](https://leetcode.com/problems/word-frequency "统计词频") | [Bash](../problems/word-frequency) | Medium | diff --git a/readme/301-600.md b/readme/301-600.md index df6d078a2..c7a261919 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -85,7 +85,7 @@ LeetCode Problems' Solutions | 313 | [Super Ugly Number](https://leetcode.com/problems/super-ugly-number "超级丑数") | [Go](../problems/super-ugly-number) | Medium | | 314 | [Binary Tree Vertical Order Traversal](https://leetcode.com/problems/binary-tree-vertical-order-traversal "二叉树的垂直遍历") 🔒 | [Go](../problems/binary-tree-vertical-order-traversal) | Medium | | 315 | [Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self "计算右侧小于当前元素的个数") | [Go](../problems/count-of-smaller-numbers-after-self) | Hard | -| 316 | [Remove Duplicate Letters](https://leetcode.com/problems/remove-duplicate-letters "去除重复字母") | [Go](../problems/remove-duplicate-letters) | Hard | +| 316 | [Remove Duplicate Letters](https://leetcode.com/problems/remove-duplicate-letters "去除重复字母") | [Go](../problems/remove-duplicate-letters) | Medium | | 317 | [Shortest Distance from All Buildings](https://leetcode.com/problems/shortest-distance-from-all-buildings "离建筑物最近的距离") 🔒 | [Go](../problems/shortest-distance-from-all-buildings) | Hard | | 318 | [Maximum Product of Word Lengths](https://leetcode.com/problems/maximum-product-of-word-lengths "最大单词长度乘积") | [Go](../problems/maximum-product-of-word-lengths) | Medium | | 319 | [Bulb Switcher](https://leetcode.com/problems/bulb-switcher "灯泡开关") | [Go](../problems/bulb-switcher) | Medium | @@ -244,7 +244,7 @@ LeetCode Problems' Solutions | 472 | [Concatenated Words](https://leetcode.com/problems/concatenated-words "连接词") | [Go](../problems/concatenated-words) | Hard | | 473 | [Matchsticks to Square](https://leetcode.com/problems/matchsticks-to-square "火柴拼正方形") | [Go](../problems/matchsticks-to-square) | Medium | | 474 | [Ones and Zeroes](https://leetcode.com/problems/ones-and-zeroes "一和零") | [Go](../problems/ones-and-zeroes) | Medium | -| 475 | [Heaters](https://leetcode.com/problems/heaters "供暖器") | [Go](../problems/heaters) | Easy | +| 475 | [Heaters](https://leetcode.com/problems/heaters "供暖器") | [Go](../problems/heaters) | Medium | | 476 | [Number Complement](https://leetcode.com/problems/number-complement "数字的补数") | [Go](../problems/number-complement) | Easy | | 477 | [Total Hamming Distance](https://leetcode.com/problems/total-hamming-distance "汉明距离总和") | [Go](../problems/total-hamming-distance) | Medium | | 478 | [Generate Random Point in a Circle](https://leetcode.com/problems/generate-random-point-in-a-circle "在圆内随机生成点") | [Go](../problems/generate-random-point-in-a-circle) | Medium | @@ -301,7 +301,7 @@ LeetCode Problems' Solutions | 529 | [Minesweeper](https://leetcode.com/problems/minesweeper "扫雷游戏") | [Go](../problems/minesweeper) | Medium | | 530 | [Minimum Absolute Difference in BST](https://leetcode.com/problems/minimum-absolute-difference-in-bst "二叉搜索树的最小绝对差") | [Go](../problems/minimum-absolute-difference-in-bst) | Easy | | 531 | [Lonely Pixel I](https://leetcode.com/problems/lonely-pixel-i "孤独像素 I") 🔒 | [Go](../problems/lonely-pixel-i) | Medium | -| 532 | [K-diff Pairs in an Array](https://leetcode.com/problems/k-diff-pairs-in-an-array "数组中的K-diff数对") | [Go](../problems/k-diff-pairs-in-an-array) | Easy | +| 532 | [K-diff Pairs in an Array](https://leetcode.com/problems/k-diff-pairs-in-an-array "数组中的 k-diff 数对") | [Go](../problems/k-diff-pairs-in-an-array) | Medium | | 533 | [Lonely Pixel II](https://leetcode.com/problems/lonely-pixel-ii "孤独像素 II") 🔒 | [Go](../problems/lonely-pixel-ii) | Medium | | 534 | [Game Play Analysis III](https://leetcode.com/problems/game-play-analysis-iii "游戏玩法分析 III") 🔒 | [MySQL](../problems/game-play-analysis-iii) | Medium | | 535 | [Encode and Decode TinyURL](https://leetcode.com/problems/encode-and-decode-tinyurl "TinyURL 的加密与解密") | [Go](../problems/encode-and-decode-tinyurl) | Medium | @@ -350,7 +350,7 @@ LeetCode Problems' Solutions | 578 | [Get Highest Answer Rate Question](https://leetcode.com/problems/get-highest-answer-rate-question "查询回答率最高的问题") 🔒 | [MySQL](../problems/get-highest-answer-rate-question) | Medium | | 579 | [Find Cumulative Salary of an Employee](https://leetcode.com/problems/find-cumulative-salary-of-an-employee "查询员工的累计薪水") 🔒 | [MySQL](../problems/find-cumulative-salary-of-an-employee) | Hard | | 580 | [Count Student Number in Departments](https://leetcode.com/problems/count-student-number-in-departments "统计各专业学生人数") 🔒 | [MySQL](../problems/count-student-number-in-departments) | Medium | -| 581 | [Shortest Unsorted Continuous Subarray](https://leetcode.com/problems/shortest-unsorted-continuous-subarray "最短无序连续子数组") | [Go](../problems/shortest-unsorted-continuous-subarray) | Easy | +| 581 | [Shortest Unsorted Continuous Subarray](https://leetcode.com/problems/shortest-unsorted-continuous-subarray "最短无序连续子数组") | [Go](../problems/shortest-unsorted-continuous-subarray) | Medium | | 582 | [Kill Process](https://leetcode.com/problems/kill-process "杀死进程") 🔒 | [Go](../problems/kill-process) | Medium | | 583 | [Delete Operation for Two Strings](https://leetcode.com/problems/delete-operation-for-two-strings "两个字符串的删除操作") | [Go](../problems/delete-operation-for-two-strings) | Medium | | 584 | [Find Customer Referee](https://leetcode.com/problems/find-customer-referee "寻找用户推荐人") 🔒 | [MySQL](../problems/find-customer-referee) | Easy | diff --git a/readme/601-900.md b/readme/601-900.md index 3fa67f6a7..efda6311a 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -93,7 +93,7 @@ LeetCode Problems' Solutions | 621 | [Task Scheduler](https://leetcode.com/problems/task-scheduler "任务调度器") | [Go](../problems/task-scheduler) | Medium | | 622 | [Design Circular Queue](https://leetcode.com/problems/design-circular-queue "设计循环队列") | [Go](../problems/design-circular-queue) | Medium | | 623 | [Add One Row to Tree](https://leetcode.com/problems/add-one-row-to-tree "在二叉树中增加一行") | [Go](../problems/add-one-row-to-tree) | Medium | -| 624 | [Maximum Distance in Arrays](https://leetcode.com/problems/maximum-distance-in-arrays "数组列表中的最大距离") 🔒 | [Go](../problems/maximum-distance-in-arrays) | Easy | +| 624 | [Maximum Distance in Arrays](https://leetcode.com/problems/maximum-distance-in-arrays "数组列表中的最大距离") 🔒 | [Go](../problems/maximum-distance-in-arrays) | Medium | | 625 | [Minimum Factorization](https://leetcode.com/problems/minimum-factorization "最小因式分解") 🔒 | [Go](../problems/minimum-factorization) | Medium | | 626 | [Exchange Seats](https://leetcode.com/problems/exchange-seats "换座位") | [MySQL](../problems/exchange-seats) | Medium | | 627 | [Swap Salary](https://leetcode.com/problems/swap-salary "交换工资") | [MySQL](../problems/swap-salary) | Easy | @@ -217,7 +217,7 @@ LeetCode Problems' Solutions | 745 | [Prefix and Suffix Search](https://leetcode.com/problems/prefix-and-suffix-search "前缀和后缀搜索") | [Go](../problems/prefix-and-suffix-search) | Hard | | 746 | [Min Cost Climbing Stairs](https://leetcode.com/problems/min-cost-climbing-stairs "使用最小花费爬楼梯") | [Go](../problems/min-cost-climbing-stairs) | Easy | | 747 | [Largest Number At Least Twice of Others](https://leetcode.com/problems/largest-number-at-least-twice-of-others "至少是其他数字两倍的最大数") | [Go](../problems/largest-number-at-least-twice-of-others) | Easy | -| 748 | [Shortest Completing Word](https://leetcode.com/problems/shortest-completing-word "最短完整词") | [Go](../problems/shortest-completing-word) | Easy | +| 748 | [Shortest Completing Word](https://leetcode.com/problems/shortest-completing-word "最短补全词") | [Go](../problems/shortest-completing-word) | Easy | | 749 | [Contain Virus](https://leetcode.com/problems/contain-virus "隔离病毒") | [Go](../problems/contain-virus) | Hard | | 750 | [Number Of Corner Rectangles](https://leetcode.com/problems/number-of-corner-rectangles "角矩形的数量") 🔒 | [Go](../problems/number-of-corner-rectangles) | Medium | | 751 | [IP to CIDR](https://leetcode.com/problems/ip-to-cidr "IP 到 CIDR") 🔒 | [Go](../problems/ip-to-cidr) | Medium | diff --git a/readme/901-1200.md b/readme/901-1200.md index 5b8bd5db4..0d155999f 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -177,7 +177,7 @@ LeetCode Problems' Solutions | 1005 | [Maximize Sum Of Array After K Negations](https://leetcode.com/problems/maximize-sum-of-array-after-k-negations "K 次取反后最大化的数组和") | [Go](../problems/maximize-sum-of-array-after-k-negations) | Easy | | 1006 | [Clumsy Factorial](https://leetcode.com/problems/clumsy-factorial "笨阶乘") | [Go](../problems/clumsy-factorial) | Medium | | 1007 | [Minimum Domino Rotations For Equal Row](https://leetcode.com/problems/minimum-domino-rotations-for-equal-row "行相等的最少多米诺旋转") | [Go](../problems/minimum-domino-rotations-for-equal-row) | Medium | -| 1008 | [Construct Binary Search Tree from Preorder Traversal](https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal "先序遍历构造二叉树") | [Go](../problems/construct-binary-search-tree-from-preorder-traversal) | Medium | +| 1008 | [Construct Binary Search Tree from Preorder Traversal](https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal "前序遍历构造二叉搜索树") | [Go](../problems/construct-binary-search-tree-from-preorder-traversal) | Medium | | 1009 | [Complement of Base 10 Integer](https://leetcode.com/problems/complement-of-base-10-integer "十进制整数的反码") | [Go](../problems/complement-of-base-10-integer) | Easy | | 1010 | [Pairs of Songs With Total Durations Divisible by 60](https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60 "总持续时间可被 60 整除的歌曲") | [Go](../problems/pairs-of-songs-with-total-durations-divisible-by-60) | Easy | | 1011 | [Capacity To Ship Packages Within D Days](https://leetcode.com/problems/capacity-to-ship-packages-within-d-days "在 D 天内送达包裹的能力") | [Go](../problems/capacity-to-ship-packages-within-d-days) | Medium | diff --git a/tag/README.md b/tag/README.md index 293a88793..818cbe340 100644 --- a/tag/README.md +++ b/tag/README.md @@ -16,13 +16,13 @@ | 9 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | | 11 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 13 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | | 14 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | -| 15 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 16 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | +| 15 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | | 19 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 20 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | | 21 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | | 22 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | | 23 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | | 25 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | -| 27 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | +| 27 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | | 28 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 29 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 30 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 31 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 32 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | | 33 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 34 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | diff --git a/tag/array/README.md b/tag/array/README.md index 17e49de9d..166b6b78f 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,13 +9,14 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1608 | [特殊数组的特征值](../../problems/special-array-with-x-elements-greater-than-or-equal-x) | [[数组](../array/README.md)] | Easy | | 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1588 | [所有奇数长度子数组的和](../../problems/sum-of-all-odd-length-subarrays) | [[数组](../array/README.md)] | Easy | | 1583 | [统计不开心的朋友](../../problems/count-unhappy-friends) | [[数组](../array/README.md)] | Medium | | 1582 | [二进制矩阵中的特殊位置](../../problems/special-positions-in-a-binary-matrix) | [[数组](../array/README.md)] | Easy | | 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1572 | [矩阵对角线元素的和](../../problems/matrix-diagonal-sum) | [[数组](../array/README.md)] | Easy | -| 1570 | [Dot Product of Two Sparse Vectors](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1566 | [重复至少 K 次且长度为 M 的模式](../../problems/detect-pattern-of-length-m-repeated-k-or-more-times) | [[数组](../array/README.md)] | Easy | | 1560 | [圆形赛道上经过次数最多的扇区](../../problems/most-visited-sector-in-a-circular-track) | [[数组](../array/README.md)] | Easy | | 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -198,11 +199,11 @@ | 644 | [最大平均子段和 II](../../problems/maximum-average-subarray-ii) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 643 | [子数组最大平均数 I](../../problems/maximum-average-subarray-i) | [[数组](../array/README.md)] | Easy | | 628 | [三个数的最大乘积](../../problems/maximum-product-of-three-numbers) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | | 611 | [有效三角形的个数](../../problems/valid-triangle-number) | [[数组](../array/README.md)] | Medium | | 605 | [种花问题](../../problems/can-place-flowers) | [[数组](../array/README.md)] | Easy | -| 581 | [最短无序连续子数组](../../problems/shortest-unsorted-continuous-subarray) | [[数组](../array/README.md)] | Easy | +| 581 | [最短无序连续子数组](../../problems/shortest-unsorted-continuous-subarray) | [[数组](../array/README.md)] | Medium | | 566 | [重塑矩阵](../../problems/reshape-the-matrix) | [[数组](../array/README.md)] | Easy | | 565 | [数组嵌套](../../problems/array-nesting) | [[数组](../array/README.md)] | Medium | | 562 | [矩阵中最长的连续1线段](../../problems/longest-line-of-consecutive-one-in-matrix) 🔒 | [[数组](../array/README.md)] | Medium | @@ -210,7 +211,7 @@ | 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 548 | [将数组分割成和相等的子数组](../../problems/split-array-with-equal-sum) 🔒 | [[数组](../array/README.md)] | Medium | | 533 | [孤独像素 II](../../problems/lonely-pixel-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 532 | [数组中的K-diff数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 531 | [孤独像素 I](../../problems/lonely-pixel-i) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 509 | [斐波那契数](../../problems/fibonacci-number) | [[数组](../array/README.md)] | Easy | | 495 | [提莫攻击](../../problems/teemo-attacking) | [[数组](../array/README.md)] | Medium | @@ -238,7 +239,7 @@ | 217 | [存在重复元素](../../problems/contains-duplicate) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 189 | [旋转数组](../../problems/rotate-array) | [[数组](../array/README.md)] | Easy | +| 189 | [旋转数组](../../problems/rotate-array) | [[数组](../array/README.md)] | Medium | | 169 | [多数元素](../../problems/majority-element) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Easy | | 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 163 | [缺失的区间](../../problems/missing-ranges) 🔒 | [[数组](../array/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 061362c3a..78a43cc0c 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -27,6 +27,7 @@ | 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 980 | [不同路径 III](../../problems/unique-paths-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 526 | [优美的排列](../../problems/beautiful-arrangement) | [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 0a1b4a039..0332fc2d6 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -60,7 +60,7 @@ | 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | | 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 483 | [最小好进制](../../problems/smallest-good-base) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 475 | [供暖器](../../problems/heaters) | [[二分查找](../binary-search/README.md)] | Easy | +| 475 | [供暖器](../../problems/heaters) | [[二分查找](../binary-search/README.md)] | Medium | | 454 | [四数相加 II](../../problems/4sum-ii) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 441 | [排列硬币](../../problems/arranging-coins) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 436 | [寻找右区间](../../problems/find-right-interval) | [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index f4387cb94..69cb8033d 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Hard | | 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | | 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index afe7f93f1..da70c43f1 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1602 | [Find Nearest Right Node in Binary Tree](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | @@ -27,6 +28,7 @@ | 1210 | [穿过迷宫的最少移动次数](../../problems/minimum-moves-to-reach-target-with-rotations) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 1197 | [进击的骑士](../../problems/minimum-knight-moves) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1091 | [二进制矩阵中的最短路径](../../problems/shortest-path-in-binary-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index ca339e5fe..a773527fa 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -66,6 +66,7 @@ | 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | | 827 | [最大人工岛](../../problems/making-a-large-island) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | | 802 | [找到最终的安全状态](../../problems/find-eventual-safe-states) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 756 | [金字塔转换矩阵](../../problems/pyramid-transition-matrix) | [[位运算](../bit-manipulation/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index bdcad51b6..cdb6a9ed0 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,8 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1603 | [设计停车系统](../../problems/design-parking-system) | [[设计](../design/README.md)] | Easy | | 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[设计](../design/README.md)] | Medium | +| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[设计](../design/README.md)] | Medium | | 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | @@ -28,6 +29,7 @@ | 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | | 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 703 | [数据流中的第K大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy | | 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Hard | | 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | | 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 0c7000d85..11950fd71 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -16,7 +17,7 @@ | 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1563 | [石子游戏 V](../../problems/stone-game-v) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1553 | [吃掉 N 个橘子的最少天数](../../problems/minimum-number-of-days-to-eat-n-oranges) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1548 | [The Most Similar Path in a Graph](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1548 | [图中最相似的路径](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1547 | [切棍子的最小成本](../../problems/minimum-cost-to-cut-a-stick) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1546 | [和为目标值的最大数目不重叠非空子数组数目](../../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1537 | [最大得分](../../problems/get-the-maximum-score) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index bbe3153b9..085448301 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard | | 1515 | [服务中心的最佳位置](../../problems/best-position-for-a-service-centre) | [[几何](../geometry/README.md)] | Hard | | 1453 | [圆形靶内的最大飞镖数量](../../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | [[几何](../geometry/README.md)] | Hard | | 1401 | [圆和矩形是否有重叠](../../problems/circle-and-rectangle-overlapping) | [[几何](../geometry/README.md)] | Medium | diff --git a/tag/graph/README.md b/tag/graph/README.md index 867d09068..2f11459c2 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -11,7 +11,7 @@ | :-: | - | - | :-: | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1557 | [可以到达所有点的最少点数目](../../problems/minimum-number-of-vertices-to-reach-all-nodes) | [[图](../graph/README.md)] | Medium | -| 1548 | [The Most Similar Path in a Graph](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1548 | [图中最相似的路径](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] | Medium | | 1494 | [并行课程 II](../../problems/parallel-courses-ii) | [[图](../graph/README.md)] | Hard | | 1462 | [课程安排 IV](../../problems/course-schedule-iv) | [[图](../graph/README.md)] | Medium | @@ -23,7 +23,6 @@ | 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | | 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[图](../graph/README.md)] | Medium | | 1153 | [字符串转化](../../problems/string-transforms-into-another-string) 🔒 | [[图](../graph/README.md)] | Hard | | 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1135 | [最低成本联通所有城市](../../problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | @@ -41,6 +40,7 @@ | 841 | [钥匙和房间](../../problems/keys-and-rooms) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 802 | [找到最终的安全状态](../../problems/find-eventual-safe-states) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index a9e6149dc..82dd16476 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1605 | [给定行和列的和求可行矩阵](../../problems/find-valid-matrix-given-row-and-column-sums) | [[贪心算法](../greedy/README.md)] | Medium | | 1599 | [经营摩天轮的最大利润](../../problems/maximum-profit-of-operating-a-centennial-wheel) | [[贪心算法](../greedy/README.md)] | Medium | | 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1591 | [奇怪的打印机 II](../../problems/strange-printer-ii) | [[贪心算法](../greedy/README.md)] | Hard | @@ -18,7 +19,7 @@ | 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心算法](../greedy/README.md)] | Medium | | 1568 | [使陆地分离的最少天数](../../problems/minimum-number-of-days-to-disconnect-island) | [[贪心算法](../greedy/README.md)] | Hard | | 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心算法](../greedy/README.md)] | Medium | -| 1564 | [Put Boxes Into the Warehouse I](../../problems/put-boxes-into-the-warehouse-i) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | +| 1564 | [把箱子放进仓库里 I](../../problems/put-boxes-into-the-warehouse-i) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | | 1558 | [得到目标数组的最少函数调用次数](../../problems/minimum-numbers-of-function-calls-to-make-target-array) | [[贪心算法](../greedy/README.md)] | Medium | | 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心算法](../greedy/README.md)] | Medium | @@ -38,6 +39,7 @@ | 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1326 | [灌溉花园的最少水龙头数目](../../problems/minimum-number-of-taps-to-open-to-water-a-garden) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | | 1282 | [用户分组](../../problems/group-the-people-given-the-group-size-they-belong-to) | [[贪心算法](../greedy/README.md)] | Medium | | 1276 | [不浪费原料的汉堡制作方案](../../problems/number-of-burgers-with-no-waste-of-ingredients) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | | 1253 | [重构 2 行二进制矩阵](../../problems/reconstruct-a-2-row-binary-matrix) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | @@ -50,6 +52,7 @@ | 1111 | [有效括号的嵌套深度](../../problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1094 | [拼车](../../problems/car-pooling) | [[贪心算法](../greedy/README.md)] | Medium | | 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1057 | [校园自行车分配](../../problems/campus-bikes) 🔒 | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | | 1055 | [形成字符串的最短路径](../../problems/shortest-way-to-form-string) 🔒 | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -89,7 +92,7 @@ | 502 | [IPO](../../problems/ipo) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | | 484 | [寻找排列](../../problems/find-permutation) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | | 455 | [分发饼干](../../problems/assign-cookies) | [[贪心算法](../greedy/README.md)] | Easy | -| 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心算法](../greedy/README.md)] | Medium | +| 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | | 435 | [无重叠区间](../../problems/non-overlapping-intervals) | [[贪心算法](../greedy/README.md)] | Medium | | 406 | [根据身高重建队列](../../problems/queue-reconstruction-by-height) | [[贪心算法](../greedy/README.md)] | Medium | | 402 | [移掉K位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | @@ -98,7 +101,7 @@ | 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 330 | [按要求补齐数组](../../problems/patching-array) | [[贪心算法](../greedy/README.md)] | Hard | | 321 | [拼接最大数](../../problems/create-maximum-number) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Hard | +| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | | 135 | [分发糖果](../../problems/candy) | [[贪心算法](../greedy/README.md)] | Hard | | 134 | [加油站](../../problems/gas-station) | [[贪心算法](../greedy/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 56ec6b744..7ec933dce 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,8 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1612 | [Check If Two Expression Trees are Equivalent](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 1570 | [Dot Product of Two Sparse Vectors](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | @@ -60,7 +61,7 @@ | 771 | [宝石与石头](../../problems/jewels-and-stones) | [[哈希表](../hash-table/README.md)] | Easy | | 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 760 | [找出变位映射](../../problems/find-anagram-mappings) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | -| 748 | [最短完整词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] | Easy | +| 748 | [最短补全词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] | Easy | | 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | | 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | @@ -77,7 +78,7 @@ | 648 | [单词替换](../../problems/replace-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 645 | [错误的集合](../../problems/set-mismatch) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | | 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 599 | [两个列表的最小索引总和](../../problems/minimum-index-sum-of-two-lists) | [[哈希表](../hash-table/README.md)] | Easy | | 594 | [最长和谐子序列](../../problems/longest-harmonious-subsequence) | [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/heap/README.md b/tag/heap/README.md index 47a8f4199..0fd1fee5d 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -25,7 +25,7 @@ | 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | | 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 703 | [数据流中的第K大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] | Easy | +| 703 | [数据流中的第K大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy | | 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[堆](../heap/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | | 502 | [IPO](../../problems/ipo) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md index 8dc62c6a6..06c012aa3 100644 --- a/tag/line-sweep/README.md +++ b/tag/line-sweep/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | | 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | | 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[Line Sweep](../line-sweep/README.md)] | Medium | | 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/math/README.md b/tag/math/README.md index cad6066d4..3d932773d 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -136,6 +136,7 @@ | 523 | [连续的子数组和](../../problems/continuous-subarray-sum) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 517 | [超级洗衣机](../../problems/super-washing-machines) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 507 | [完美数](../../problems/perfect-number) | [[数学](../math/README.md)] | Easy | +| 492 | [构造矩形](../../problems/construct-the-rectangle) | [[数学](../math/README.md)] | Easy | | 483 | [最小好进制](../../problems/smallest-good-base) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | | 469 | [凸多边形](../../problems/convex-polygon) 🔒 | [[数学](../math/README.md)] | Medium | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index d8c9d70c3..dd46bf0d8 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | | 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | | 855 | [考场就座](../../problems/exam-room) | [[Ordered Map](../ordered-map/README.md)] | Medium | | 846 | [一手顺子](../../problems/hand-of-straights) | [[Ordered Map](../ordered-map/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index 19d07d70a..9800bd7b9 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -31,6 +31,7 @@ | 1333 | [餐厅过滤器](../../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1329 | [将矩阵按对角线排序](../../problems/sort-the-matrix-diagonally) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[排序](../sort/README.md)] [[树](../tree/README.md)] | Medium | +| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | | 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1183 | [矩阵中 1 的最大数量](../../problems/maximum-number-of-ones) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | @@ -50,6 +51,7 @@ | 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Hard | | 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | | 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/stack/README.md b/tag/stack/README.md index ab5a7c9c5..cbb911901 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -20,6 +20,7 @@ | 1190 | [反转每对括号间的子串](../../problems/reverse-substrings-between-each-pair-of-parentheses) | [[栈](../stack/README.md)] | Medium | | 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1124 | [表现良好的最长时间段](../../problems/longest-well-performing-interval) | [[栈](../stack/README.md)] | Medium | +| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1063 | [有效子数组的数目](../../problems/number-of-valid-subarrays) 🔒 | [[栈](../stack/README.md)] | Hard | | 1047 | [删除字符串中的所有相邻重复项](../../problems/remove-all-adjacent-duplicates-in-string) | [[栈](../stack/README.md)] | Easy | | 1021 | [删除最外层的括号](../../problems/remove-outermost-parentheses) | [[栈](../stack/README.md)] | Easy | @@ -51,7 +52,7 @@ | 385 | [迷你语法分析器](../../problems/mini-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | | 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | | 331 | [验证二叉树的前序序列化](../../problems/verify-preorder-serialization-of-a-binary-tree) | [[栈](../stack/README.md)] | Medium | -| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Hard | +| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Hard | | 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | | 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | diff --git a/tag/string/README.md b/tag/string/README.md index 9487dba8e..4b7ef98c5 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,7 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1597 | [Build Binary Expression Tree From Infix Expression](../../problems/build-binary-expression-tree-from-infix-expression) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | +| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | +| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Hard | | 1592 | [重新排列单词间的空格](../../problems/rearrange-spaces-between-words) | [[字符串](../string/README.md)] | Easy | | 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | | 1576 | [替换所有的问号](../../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | [[字符串](../string/README.md)] | Easy | @@ -79,7 +80,7 @@ | 1106 | [解析布尔表达式](../../problems/parsing-a-boolean-expression) | [[字符串](../string/README.md)] | Hard | | 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1096 | [花括号展开 II](../../problems/brace-expansion-ii) | [[字符串](../string/README.md)] | Hard | -| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[字符串](../string/README.md)] | Medium | +| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1071 | [字符串的最大公因子](../../problems/greatest-common-divisor-of-strings) | [[字符串](../string/README.md)] | Easy | | 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Easy | | 1062 | [最长重复子串](../../problems/longest-repeating-substring) 🔒 | [[字符串](../string/README.md)] | Medium | @@ -161,6 +162,7 @@ | 344 | [反转字符串](../../problems/reverse-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 293 | [翻转游戏](../../problems/flip-game) 🔒 | [[字符串](../string/README.md)] | Easy | | 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | | 271 | [字符串的编码与解码](../../problems/encode-and-decode-strings) 🔒 | [[字符串](../string/README.md)] | Medium | diff --git a/tag/tags.json b/tag/tags.json index c30dc8cbf..2340dd51b 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -69,16 +69,16 @@ "Slug": "backtracking", "TranslatedName": "回溯算法" }, - { - "Name": "Bit Manipulation", - "Slug": "bit-manipulation", - "TranslatedName": "位运算" - }, { "Name": "Design", "Slug": "design", "TranslatedName": "设计" }, + { + "Name": "Bit Manipulation", + "Slug": "bit-manipulation", + "TranslatedName": "位运算" + }, { "Name": "Graph", "Slug": "graph", @@ -129,16 +129,16 @@ "Slug": "ordered-map", "TranslatedName": "Ordered Map" }, - { - "Name": "Queue", - "Slug": "queue", - "TranslatedName": "队列" - }, { "Name": "Geometry", "Slug": "geometry", "TranslatedName": "几何" }, + { + "Name": "Queue", + "Slug": "queue", + "TranslatedName": "队列" + }, { "Name": "Minimax", "Slug": "minimax", diff --git a/tag/tree/README.md b/tag/tree/README.md index 135682ce8..f6bc18e5b 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,8 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1612 | [Check If Two Expression Trees are Equivalent](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1609 | [奇偶树](../../problems/even-odd-tree) | [[树](../tree/README.md)] | Medium | +| 1602 | [Find Nearest Right Node in Binary Tree](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1597 | [Build Binary Expression Tree From Infix Expression](../../problems/build-binary-expression-tree-from-infix-expression) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | +| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Hard | +| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1516 | [移动 N 叉树的子树](../../problems/move-sub-tree-of-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | @@ -32,6 +36,7 @@ | 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1257 | [最小公共区域](../../problems/smallest-common-region) 🔒 | [[树](../tree/README.md)] | Medium | | 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | @@ -41,7 +46,7 @@ | 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | | 1026 | [节点与其祖先之间的最大差值](../../problems/maximum-difference-between-node-and-ancestor) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1022 | [从根到叶的二进制数之和](../../problems/sum-of-root-to-leaf-binary-numbers) | [[树](../tree/README.md)] | Easy | -| 1008 | [先序遍历构造二叉树](../../problems/construct-binary-search-tree-from-preorder-traversal) | [[树](../tree/README.md)] | Medium | +| 1008 | [前序遍历构造二叉搜索树](../../problems/construct-binary-search-tree-from-preorder-traversal) | [[树](../tree/README.md)] | Medium | | 998 | [最大二叉树 II](../../problems/maximum-binary-tree-ii) | [[树](../tree/README.md)] | Medium | | 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 988 | [从叶结点开始的最小字符串](../../problems/smallest-string-starting-from-leaf) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 18bb56e56..0df99c8eb 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,7 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1570 | [Dot Product of Two Sparse Vectors](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard | +| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1248 | [统计「优美子数组」](../../problems/count-number-of-nice-subarrays) | [[双指针](../two-pointers/README.md)] | Medium | | 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | @@ -33,7 +34,7 @@ | 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | | 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 532 | [数组中的K-diff数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 487 | [最大连续1的个数 II](../../problems/max-consecutive-ones-ii) 🔒 | [[双指针](../two-pointers/README.md)] | Medium | | 457 | [环形数组循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | From 459b3872c7ebe7a9f379935e5aa5aa2a4db5e90f Mon Sep 17 00:00:00 2001 From: Shuo Date: Sat, 10 Oct 2020 10:33:57 +0800 Subject: [PATCH 104/145] U: status --- internal/leetcode/problems_status.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/leetcode/problems_status.go b/internal/leetcode/problems_status.go index edd5b8c49..11f8d115b 100644 --- a/internal/leetcode/problems_status.go +++ b/internal/leetcode/problems_status.go @@ -236,6 +236,11 @@ var problemStatus = map[int]bool{ 1185: true, 1189: true, 1221: true, + 1408: true, + 1417: true, + 1422: true, + 1436: true, + 1455: true, } // IsSolved - leetcode.IsSolved From 48ef8ff1abb1ce843b1d49c4d1562f27edf821b4 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 19 Oct 2020 09:37:50 +0800 Subject: [PATCH 105/145] A: new --- README.md | 20 +++-- problems/132-pattern/README.md | 6 +- .../README.md | 2 +- problems/assign-cookies/README.md | 43 +++++----- problems/asteroid-collision/README.md | 76 ++++++++--------- problems/bank-account-summary-ii/README.md | 2 +- .../README.md | 24 ++++-- .../binary-tree-maximum-path-sum/README.md | 33 ++++---- problems/brace-expansion/README.md | 2 +- .../README.md | 2 +- .../README.md | 4 +- problems/combination-sum-ii/README.md | 39 +++++---- .../README.md | 81 ++++++++++++++++++ problems/count-and-say/README.md | 26 +++--- .../README.md | 80 ++++++++++++++++++ problems/count-univalue-subtrees/README.md | 2 +- problems/fancy-sequence/README.md | 73 +++++++++++++++++ .../README.md | 2 +- problems/find-the-missing-ids/README.md | 14 ++++ .../find-the-missing-ids/mysql_schemas.sql | 5 ++ problems/first-bad-version/README.md | 27 ++++-- problems/first-missing-positive/README.md | 40 ++++----- problems/hand-of-straights/README.md | 21 +++-- problems/human-traffic-of-stadium/README.md | 42 +++++++--- .../mysql_schemas.sql | 2 +- problems/integer-to-english-words/README.md | 46 +++++------ problems/interleaving-string/README.md | 13 ++- problems/jump-game-ii/README.md | 28 +++++-- problems/k-empty-slots/README.md | 2 +- problems/lfu-cache/README.md | 53 +++++++----- .../README.md | 41 ++++++---- problems/longest-univalue-path/README.md | 46 ++++------- .../README.md | 25 ++++-- .../README.md | 28 ++++--- .../README.md | 39 +++++---- problems/maximal-network-rank/README.md | 80 ++++++++++++++++++ .../README.md | 24 ++++++ .../README.md | 80 ++++++++++++++++++ .../README.md | 76 +++++++++++++++++ .../minimum-depth-of-binary-tree/README.md | 26 ++++-- .../README.md | 30 +++---- .../README.md | 2 +- problems/minimum-time-difference/README.md | 27 +++--- problems/missing-number/README.md | 2 +- problems/multiply-strings/README.md | 35 ++++---- problems/number-of-1-bits/README.md | 33 ++++---- problems/number-of-islands/README.md | 14 +++- .../README.md | 77 +++++++++++++++++ problems/odd-even-jump/README.md | 75 ++++++++--------- problems/ones-and-zeroes/README.md | 14 ++-- problems/partition-equal-subset-sum/README.md | 38 ++++----- problems/path-sum-iii/README.md | 2 +- problems/range-sum-query-immutable/README.md | 35 +++++--- .../README.md | 45 +++++----- problems/remove-element/README.md | 50 ++++++----- problems/repeated-dna-sequences/README.md | 22 +++-- .../README.md | 40 +++++---- problems/sellers-with-no-sales/README.md | 2 +- problems/shortest-palindrome/README.md | 23 +++--- .../README.md | 3 + .../README.md | 82 +++++++++++++++++++ .../README.md | 2 +- problems/trapping-rain-water/README.md | 28 +++++-- problems/wildcard-matching/README.md | 47 +++++------ problems/word-search/README.md | 31 ++++--- readme/1-300.md | 2 +- readme/601-900.md | 4 +- readme/901-1200.md | 2 +- tag/array/README.md | 3 +- tag/backtracking/README.md | 3 +- tag/binary-search/README.md | 1 + tag/bit-manipulation/README.md | 2 +- tag/breadth-first-search/README.md | 3 +- tag/depth-first-search/README.md | 1 + tag/design/README.md | 1 + tag/dynamic-programming/README.md | 1 + tag/graph/README.md | 1 + tag/greedy/README.md | 2 + tag/hash-table/README.md | 2 +- tag/math/README.md | 4 +- tag/ordered-map/README.md | 2 +- tag/recursion/README.md | 3 +- tag/string/README.md | 6 +- tag/tree/README.md | 8 +- tag/two-pointers/README.md | 1 + tag/union-find/README.md | 1 + 86 files changed, 1472 insertions(+), 615 deletions(-) create mode 100644 problems/coordinate-with-maximum-network-quality/README.md create mode 100644 problems/count-subtrees-with-max-distance-between-cities/README.md create mode 100644 problems/fancy-sequence/README.md create mode 100644 problems/find-the-missing-ids/README.md create mode 100644 problems/find-the-missing-ids/mysql_schemas.sql create mode 100644 problems/maximal-network-rank/README.md create mode 100644 problems/maximum-font-to-fit-a-sentence-in-a-screen/README.md create mode 100644 problems/maximum-nesting-depth-of-the-parentheses/README.md create mode 100644 problems/mean-of-array-after-removing-some-elements/README.md create mode 100644 problems/number-of-sets-of-k-non-overlapping-line-segments/README.md create mode 100644 problems/split-two-strings-to-make-palindrome/README.md diff --git a/README.md b/README.md index ff6ec6210..45d1a7c7c 100644 --- a/README.md +++ b/README.md @@ -70,23 +70,33 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | -| 1612 | [Check If Two Expression Trees are Equivalent](https://leetcode.com/problems/check-if-two-expression-trees-are-equivalent) 🔒 | [Go](problems/check-if-two-expression-trees-are-equivalent) | Medium | +| 1622 | [Fancy Sequence](https://leetcode.com/problems/fancy-sequence "奇妙序列") | [Go](problems/fancy-sequence) | Hard | +| 1621 | [Number of Sets of K Non-Overlapping Line Segments](https://leetcode.com/problems/number-of-sets-of-k-non-overlapping-line-segments "大小为 K 的不重叠线段的数目") | [Go](problems/number-of-sets-of-k-non-overlapping-line-segments) | Medium | +| 1620 | [Coordinate With Maximum Network Quality](https://leetcode.com/problems/coordinate-with-maximum-network-quality "网络信号最好的坐标") | [Go](problems/coordinate-with-maximum-network-quality) | Medium | +| 1619 | [Mean of Array After Removing Some Elements](https://leetcode.com/problems/mean-of-array-after-removing-some-elements "删除某些元素后的数组均值") | [Go](problems/mean-of-array-after-removing-some-elements) | Easy | +| 1618 | [Maximum Font to Fit a Sentence in a Screen](https://leetcode.com/problems/maximum-font-to-fit-a-sentence-in-a-screen "找出适应屏幕的最大字号") 🔒 | [Go](problems/maximum-font-to-fit-a-sentence-in-a-screen) | Medium | +| 1617 | [Count Subtrees With Max Distance Between Cities](https://leetcode.com/problems/count-subtrees-with-max-distance-between-cities "统计子树中城市之间最大距离") | [Go](problems/count-subtrees-with-max-distance-between-cities) | Hard | +| 1616 | [Split Two Strings to Make Palindrome](https://leetcode.com/problems/split-two-strings-to-make-palindrome "分割两个字符串得到回文串") | [Go](problems/split-two-strings-to-make-palindrome) | Medium | +| 1615 | [Maximal Network Rank](https://leetcode.com/problems/maximal-network-rank "最大网络秩") | [Go](problems/maximal-network-rank) | Medium | +| 1614 | [Maximum Nesting Depth of the Parentheses](https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses "括号的最大嵌套深度") | [Go](problems/maximum-nesting-depth-of-the-parentheses) | Easy | +| 1613 | [Find the Missing IDs](https://leetcode.com/problems/find-the-missing-ids "找到遗失的ID") 🔒 | [MySQL](problems/find-the-missing-ids) | Medium | +| 1612 | [Check If Two Expression Trees are Equivalent](https://leetcode.com/problems/check-if-two-expression-trees-are-equivalent "检查两棵二叉表达式树是否等价") 🔒 | [Go](problems/check-if-two-expression-trees-are-equivalent) | Medium | | 1611 | [Minimum One Bit Operations to Make Integers Zero](https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero "使整数变为 0 的最少操作次数") | [Go](problems/minimum-one-bit-operations-to-make-integers-zero) | Hard | | 1610 | [Maximum Number of Visible Points](https://leetcode.com/problems/maximum-number-of-visible-points "可见点的最大数目") | [Go](problems/maximum-number-of-visible-points) | Hard | | 1609 | [Even Odd Tree](https://leetcode.com/problems/even-odd-tree "奇偶树") | [Go](problems/even-odd-tree) | Medium | | 1608 | [Special Array With X Elements Greater Than or Equal X](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x "特殊数组的特征值") | [Go](problems/special-array-with-x-elements-greater-than-or-equal-x) | Easy | -| 1607 | [Sellers With No Sales](https://leetcode.com/problems/sellers-with-no-sales) 🔒 | [MySQL](problems/sellers-with-no-sales) | Easy | +| 1607 | [Sellers With No Sales](https://leetcode.com/problems/sellers-with-no-sales "没有卖出的卖家") 🔒 | [MySQL](problems/sellers-with-no-sales) | Easy | | 1606 | [Find Servers That Handled Most Number of Requests](https://leetcode.com/problems/find-servers-that-handled-most-number-of-requests "找到处理最多请求的服务器") | [Go](problems/find-servers-that-handled-most-number-of-requests) | Hard | | 1605 | [Find Valid Matrix Given Row and Column Sums](https://leetcode.com/problems/find-valid-matrix-given-row-and-column-sums "给定行和列的和求可行矩阵") | [Go](problems/find-valid-matrix-given-row-and-column-sums) | Medium | | 1604 | [Alert Using Same Key-Card Three or More Times in a One Hour Period](https://leetcode.com/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period "警告一小时内使用相同员工卡大于等于三次的人") | [Go](problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | Medium | | 1603 | [Design Parking System](https://leetcode.com/problems/design-parking-system "设计停车系统") | [Go](problems/design-parking-system) | Easy | -| 1602 | [Find Nearest Right Node in Binary Tree](https://leetcode.com/problems/find-nearest-right-node-in-binary-tree) 🔒 | [Go](problems/find-nearest-right-node-in-binary-tree) | Medium | +| 1602 | [Find Nearest Right Node in Binary Tree](https://leetcode.com/problems/find-nearest-right-node-in-binary-tree "找到二叉树中最近的右侧节点") 🔒 | [Go](problems/find-nearest-right-node-in-binary-tree) | Medium | | 1601 | [Maximum Number of Achievable Transfer Requests](https://leetcode.com/problems/maximum-number-of-achievable-transfer-requests "最多可达成的换楼请求数目") | [Go](problems/maximum-number-of-achievable-transfer-requests) | Hard | | 1600 | [Throne Inheritance](https://leetcode.com/problems/throne-inheritance "皇位继承顺序") | [Go](problems/throne-inheritance) | Medium | | 1599 | [Maximum Profit of Operating a Centennial Wheel](https://leetcode.com/problems/maximum-profit-of-operating-a-centennial-wheel "经营摩天轮的最大利润") | [Go](problems/maximum-profit-of-operating-a-centennial-wheel) | Medium | | 1598 | [Crawler Log Folder](https://leetcode.com/problems/crawler-log-folder "文件夹操作日志搜集器") | [Go](problems/crawler-log-folder) | Easy | | 1597 | [Build Binary Expression Tree From Infix Expression](https://leetcode.com/problems/build-binary-expression-tree-from-infix-expression "根据中缀表达式构造二叉表达式树") 🔒 | [Go](problems/build-binary-expression-tree-from-infix-expression) | Hard | -| 1596 | [The Most Frequently Ordered Products for Each Customer](https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer) 🔒 | [MySQL](problems/the-most-frequently-ordered-products-for-each-customer) | Medium | +| 1596 | [The Most Frequently Ordered Products for Each Customer](https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer "每位顾客最经常订购的商品") 🔒 | [MySQL](problems/the-most-frequently-ordered-products-for-each-customer) | Medium | | 1595 | [Minimum Cost to Connect Two Groups of Points](https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points "连通两组点的最小成本") | [Go](problems/minimum-cost-to-connect-two-groups-of-points) | Hard | | 1594 | [Maximum Non Negative Product in a Matrix](https://leetcode.com/problems/maximum-non-negative-product-in-a-matrix "矩阵的最大非负积") | [Go](problems/maximum-non-negative-product-in-a-matrix) | Medium | | 1593 | [Split a String Into the Max Number of Unique Substrings](https://leetcode.com/problems/split-a-string-into-the-max-number-of-unique-substrings "拆分字符串使唯一子字符串的数目最大") | [Go](problems/split-a-string-into-the-max-number-of-unique-substrings) | Medium | @@ -95,7 +105,7 @@ LeetCode Problems' Solutions | 1590 | [Make Sum Divisible by P](https://leetcode.com/problems/make-sum-divisible-by-p "使数组和能被 P 整除") | [Go](problems/make-sum-divisible-by-p) | Medium | | 1589 | [Maximum Sum Obtained of Any Permutation](https://leetcode.com/problems/maximum-sum-obtained-of-any-permutation "所有排列中的最大和") | [Go](problems/maximum-sum-obtained-of-any-permutation) | Medium | | 1588 | [Sum of All Odd Length Subarrays](https://leetcode.com/problems/sum-of-all-odd-length-subarrays "所有奇数长度子数组的和") | [Go](problems/sum-of-all-odd-length-subarrays) | Easy | -| 1587 | [Bank Account Summary II](https://leetcode.com/problems/bank-account-summary-ii) 🔒 | [MySQL](problems/bank-account-summary-ii) | Easy | +| 1587 | [Bank Account Summary II](https://leetcode.com/problems/bank-account-summary-ii "银行账户概要 II") 🔒 | [MySQL](problems/bank-account-summary-ii) | Easy | | 1586 | [Binary Search Tree Iterator II](https://leetcode.com/problems/binary-search-tree-iterator-ii "二叉搜索树迭代器 II") 🔒 | [Go](problems/binary-search-tree-iterator-ii) | Medium | | 1585 | [Check If String Is Transformable With Substring Sort Operations](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations "检查字符串是否可以通过排序子字符串得到另一个字符串") | [Go](problems/check-if-string-is-transformable-with-substring-sort-operations) | Hard | | 1584 | [Min Cost to Connect All Points](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") | [Go](problems/min-cost-to-connect-all-points) | Medium | diff --git a/problems/132-pattern/README.md b/problems/132-pattern/README.md index dbe20b0de..07d1b5481 100644 --- a/problems/132-pattern/README.md +++ b/problems/132-pattern/README.md @@ -13,7 +13,9 @@

    Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j].

    -

    Return true if there is a 132 pattern in nums, otherwise return false.

    +

    Return true if there is a 132 pattern in nums, otherwise, return false.

    + +

    Follow up: The O(n^2) is trivial, could you come up with the O(n logn) or the O(n) solution?

     

    Example 1:

    @@ -45,7 +47,7 @@
    • n == nums.length
    • -
    • 1 <= n <= 3 * 104
    • +
    • 1 <= n <= 104
    • -109 <= nums[i] <= 109
    diff --git a/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md b/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md index a3c4ccbc8..c7a00f797 100644 --- a/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md +++ b/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md @@ -58,7 +58,7 @@
    • 1 <= keyName.length, keyTime.length <= 105
    • keyName.length == keyTime.length
    • -
    • keyTime are in the format "HH:MM".
    • +
    • keyTime[i] is in the format "HH:MM".
    • [keyName[i], keyTime[i]] is unique.
    • 1 <= keyName[i].length <= 10
    • keyName[i] contains only lowercase English letters.
    • diff --git a/problems/assign-cookies/README.md b/problems/assign-cookies/README.md index c72fedcb4..b63510f9f 100644 --- a/problems/assign-cookies/README.md +++ b/problems/assign-cookies/README.md @@ -11,38 +11,41 @@ ## [455. Assign Cookies (Easy)](https://leetcode.com/problems/assign-cookies "分发饼干") -

      -Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a cookie that the child will be content with; and each cookie j has a size sj. If sj >= gi, we can assign the cookie j to the child i, and the child i will be content. Your goal is to maximize the number of your content children and output the maximum number. -

      +

      Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie.

      -

      Note:
      -You may assume the greed factor is always positive.
      -You cannot assign more than one cookie to one child. -

      +

      Each child i has a greed factor g[i], which is the minimum size of a cookie that the child will be content with; and each cookie j has a size s[j]. If s[j] >= g[i], we can assign the cookie j to the child i, and the child i will be content. Your goal is to maximize the number of your content children and output the maximum number.

      -

      Example 1:
      -

      -Input: [1,2,3], [1,1]
      +

       

      -Output: 1 +

       

      +

      Example 1:

      -Explanation: You have 3 children and 2 cookies. The greed factors of 3 children are 1, 2, 3. +
      +Input: g = [1,2,3], s = [1,1]
      +Output: 1
      +Explanation: You have 3 children and 2 cookies. The greed factors of 3 children are 1, 2, 3. 
       And even though you have 2 cookies, since their size is both 1, you could only make the child whose greed factor is 1 content.
       You need to output 1.
       
      -

      - -

      Example 2:
      -

      -Input: [1,2], [1,2,3]
       
      -Output: 2
      +

      Example 2:

      -Explanation: You have 2 children and 3 cookies. The greed factors of 2 children are 1, 2. +
      +Input: g = [1,2], s = [1,2,3]
      +Output: 2
      +Explanation: You have 2 children and 3 cookies. The greed factors of 2 children are 1, 2. 
       You have 3 cookies and their sizes are big enough to gratify all of the children, 
       You need to output 2.
       
      -

      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= g.length <= 3 * 104
      • +
      • 0 <= s.length <= 3 * 104
      • +
      • 1 <= g[i], s[j] <= 231 - 1
      • +
      ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/asteroid-collision/README.md b/problems/asteroid-collision/README.md index 58ce6d9fd..03edf127a 100644 --- a/problems/asteroid-collision/README.md +++ b/problems/asteroid-collision/README.md @@ -11,59 +11,53 @@ ## [735. Asteroid Collision (Medium)](https://leetcode.com/problems/asteroid-collision "行星碰撞") -

      -We are given an array asteroids of integers representing asteroids in a row. -

      -For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed. -

      -Find out the state of the asteroids after all collisions. If two asteroids meet, the smaller one will explode. If both are the same size, both will explode. Two asteroids moving in the same direction will never meet. -

      - -

      Example 1:
      +

      We are given an array asteroids of integers representing asteroids in a row.

      + +

      For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed.

      + +

      Find out the state of the asteroids after all collisions. If two asteroids meet, the smaller one will explode. If both are the same size, both will explode. Two asteroids moving in the same direction will never meet.

      + +

       

      +

      Example 1:

      +
      -Input: 
      -asteroids = [5, 10, -5]
      -Output: [5, 10]
      -Explanation: 
      -The 10 and -5 collide resulting in 10.  The 5 and 10 never collide.
      +Input: asteroids = [5,10,-5]
      +Output: [5,10]
      +Explanation: The 10 and -5 collide resulting in 10.  The 5 and 10 never collide.
       
      -

      -

      Example 2:
      +

      Example 2:

      +
      -Input: 
      -asteroids = [8, -8]
      -Output: []
      -Explanation: 
      -The 8 and -8 collide exploding each other.
      +Input: asteroids = [8,-8]
      +Output: []
      +Explanation: The 8 and -8 collide exploding each other.
       
      -

      -

      Example 3:
      +

      Example 3:

      +
      -Input: 
      -asteroids = [10, 2, -5]
      -Output: [10]
      -Explanation: 
      -The 2 and -5 collide resulting in -5.  The 10 and -5 collide resulting in 10.
      +Input: asteroids = [10,2,-5]
      +Output: [10]
      +Explanation: The 2 and -5 collide resulting in -5. The 10 and -5 collide resulting in 10.
       
      -

      -

      Example 4:
      +

      Example 4:

      +
      -Input: 
      -asteroids = [-2, -1, 1, 2]
      -Output: [-2, -1, 1, 2]
      -Explanation: 
      -The -2 and -1 are moving left, while the 1 and 2 are moving right.
      -Asteroids moving the same direction never meet, so no asteroids will meet each other.
      +Input: asteroids = [-2,-1,1,2]
      +Output: [-2,-1,1,2]
      +Explanation: The -2 and -1 are moving left, while the 1 and 2 are moving right. Asteroids moving the same direction never meet, so no asteroids will meet each other.
       
      -

      -

      Note: -

    • The length of asteroids will be at most 10000.
    • -
    • Each asteroid will be a non-zero integer in the range [-1000, 1000]..
    • -

      +

       

      +

      Constraints:

      + +
        +
      • 1 <= asteroids <= 104
      • +
      • -1000 <= asteroids[i] <= 1000
      • +
      • asteroids[i] != 0
      • +
      ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/bank-account-summary-ii/README.md b/problems/bank-account-summary-ii/README.md index b28ae4cd0..8556dea06 100644 --- a/problems/bank-account-summary-ii/README.md +++ b/problems/bank-account-summary-ii/README.md @@ -9,6 +9,6 @@                  [Next >](../sum-of-all-odd-length-subarrays "Sum of All Odd Length Subarrays") -## [1587. Bank Account Summary II (Easy)](https://leetcode.com/problems/bank-account-summary-ii "") +## [1587. Bank Account Summary II (Easy)](https://leetcode.com/problems/bank-account-summary-ii "银行账户概要 II") diff --git a/problems/best-time-to-buy-and-sell-stock-iv/README.md b/problems/best-time-to-buy-and-sell-stock-iv/README.md index e0f6809f3..89fb41a4b 100644 --- a/problems/best-time-to-buy-and-sell-stock-iv/README.md +++ b/problems/best-time-to-buy-and-sell-stock-iv/README.md @@ -11,17 +11,17 @@ ## [188. Best Time to Buy and Sell Stock IV (Hard)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv "买卖股票的最佳时机 IV") -

      Say you have an array for which the i-th element is the price of a given stock on day i.

      +

      You are given an integer array prices where prices[i] is the price of a given stock on the ith day.

      -

      Design an algorithm to find the maximum profit. You may complete at most k transactions.

      +

      Design an algorithm to find the maximum profit. You may complete at most k transactions.

      -

      Note:
      -You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).

      +

      Notice that you may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).

      +

       

      Example 1:

      -Input: [2,4,1], k = 2
      +Input: k = 2, prices = [2,4,1]
       Output: 2
       Explanation: Buy on day 1 (price = 2) and sell on day 2 (price = 4), profit = 4-2 = 2.
       
      @@ -29,12 +29,20 @@ You may not engage in multiple transactions at the same time (ie, you must sell

      Example 2:

      -Input: [3,2,6,5,0,3], k = 2
      +Input: k = 2, prices = [3,2,6,5,0,3]
       Output: 7
      -Explanation: Buy on day 2 (price = 2) and sell on day 3 (price = 6), profit = 6-2 = 4.
      -             Then buy on day 5 (price = 0) and sell on day 6 (price = 3), profit = 3-0 = 3.
      +Explanation: Buy on day 2 (price = 2) and sell on day 3 (price = 6), profit = 6-2 = 4. Then buy on day 5 (price = 0) and sell on day 6 (price = 3), profit = 3-0 = 3.
       
      +

       

      +

      Constraints:

      + +
        +
      • 0 <= k <= 109
      • +
      • 0 <= prices.length <= 104
      • +
      • 0 <= prices[i] <= 1000
      • +
      + ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/binary-tree-maximum-path-sum/README.md b/problems/binary-tree-maximum-path-sum/README.md index c6bba9c25..b236d9243 100644 --- a/problems/binary-tree-maximum-path-sum/README.md +++ b/problems/binary-tree-maximum-path-sum/README.md @@ -13,34 +13,31 @@

      Given a non-empty binary tree, find the maximum path sum.

      -

      For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does not need to go through the root.

      +

      For this problem, a path is defined as any node sequence from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does not need to go through the root.

      +

       

      Example 1:

      - +
      -Input: [1,2,3]
      -
      -       1
      -      / \
      -     2   3
      -
      +Input: root = [1,2,3]
       Output: 6
       

      Example 2:

      - +
      -Input: [-10,9,20,null,null,15,7]
      -
      -   -10
      -   / \
      -  9  20
      -    /  \
      -   15   7
      -
      +Input: root = [-10,9,20,null,null,15,7]
       Output: 42
       
      +

       

      +

      Constraints:

      + +
        +
      • The number of nodes in the tree is in the range [0, 3 * 104].
      • +
      • -1000 <= Node.val <= 1000
      • +
      + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-first Search](../../tag/depth-first-search/README.md)] @@ -49,4 +46,4 @@ 1. [Path Sum](../path-sum) (Easy) 1. [Sum Root to Leaf Numbers](../sum-root-to-leaf-numbers) (Medium) 1. [Path Sum IV](../path-sum-iv) (Medium) - 1. [Longest Univalue Path](../longest-univalue-path) (Easy) + 1. [Longest Univalue Path](../longest-univalue-path) (Medium) diff --git a/problems/brace-expansion/README.md b/problems/brace-expansion/README.md index 358f81c0f..67cf74d3b 100644 --- a/problems/brace-expansion/README.md +++ b/problems/brace-expansion/README.md @@ -9,7 +9,7 @@                  [Next >](../confusing-number-ii "Confusing Number II") -## [1087. Brace Expansion (Medium)](https://leetcode.com/problems/brace-expansion "字母切换") +## [1087. Brace Expansion (Medium)](https://leetcode.com/problems/brace-expansion "花括号展开")

      A string S represents a list of words.

      diff --git a/problems/check-if-a-string-can-break-another-string/README.md b/problems/check-if-a-string-can-break-another-string/README.md index 8216e3e01..d6b4e8723 100644 --- a/problems/check-if-a-string-can-break-another-string/README.md +++ b/problems/check-if-a-string-can-break-another-string/README.md @@ -11,7 +11,7 @@ ## [1433. Check If a String Can Break Another String (Medium)](https://leetcode.com/problems/check-if-a-string-can-break-another-string "检查一个字符串是否可以打破另一个字符串") -

      Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1).

      +

      Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa. In other words s2 can break s1 or vice-versa.

      A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.

      diff --git a/problems/check-if-two-expression-trees-are-equivalent/README.md b/problems/check-if-two-expression-trees-are-equivalent/README.md index f49b67d5f..6733f508c 100644 --- a/problems/check-if-two-expression-trees-are-equivalent/README.md +++ b/problems/check-if-two-expression-trees-are-equivalent/README.md @@ -7,9 +7,9 @@ [< Previous](../minimum-one-bit-operations-to-make-integers-zero "Minimum One Bit Operations to Make Integers Zero")                  -Next > +[Next >](../find-the-missing-ids "Find the Missing IDs") -## [1612. Check If Two Expression Trees are Equivalent (Medium)](https://leetcode.com/problems/check-if-two-expression-trees-are-equivalent "") +## [1612. Check If Two Expression Trees are Equivalent (Medium)](https://leetcode.com/problems/check-if-two-expression-trees-are-equivalent "检查两棵二叉表达式树是否等价") diff --git a/problems/combination-sum-ii/README.md b/problems/combination-sum-ii/README.md index 765af270b..c99f3bcb8 100644 --- a/problems/combination-sum-ii/README.md +++ b/problems/combination-sum-ii/README.md @@ -11,41 +11,46 @@ ## [40. Combination Sum II (Medium)](https://leetcode.com/problems/combination-sum-ii "组合总和 II") -

      Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.

      +

      Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to target.

      Each number in candidates may only be used once in the combination.

      -

      Note:

      - -
        -
      • All numbers (including target) will be positive integers.
      • -
      • The solution set must not contain duplicate combinations.
      • -
      +

      Note: The solution set must not contain duplicate combinations.

      +

       

      Example 1:

      -Input: candidates = [10,1,2,7,6,1,5], target = 8,
      -A solution set is:
      +Input: candidates = [10,1,2,7,6,1,5], target = 8
      +Output: 
       [
      -  [1, 7],
      -  [1, 2, 5],
      -  [2, 6],
      -  [1, 1, 6]
      +[1,1,6],
      +[1,2,5],
      +[1,7],
      +[2,6]
       ]
       

      Example 2:

      -Input: candidates = [2,5,2,1,2], target = 5,
      -A solution set is:
      +Input: candidates = [2,5,2,1,2], target = 5
      +Output: 
       [
      -  [1,2,2],
      -  [5]
      +[1,2,2],
      +[5]
       ]
       
      +

       

      +

      Constraints:

      + +
        +
      • 1 <= candidates.length <= 100
      • +
      • 1 <= candidates[i] <= 50
      • +
      • 1 <= target <= 30
      • +
      + ### Related Topics [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/coordinate-with-maximum-network-quality/README.md b/problems/coordinate-with-maximum-network-quality/README.md new file mode 100644 index 000000000..b5f457ff0 --- /dev/null +++ b/problems/coordinate-with-maximum-network-quality/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../mean-of-array-after-removing-some-elements "Mean of Array After Removing Some Elements") +                 +[Next >](../number-of-sets-of-k-non-overlapping-line-segments "Number of Sets of K Non-Overlapping Line Segments") + +## [1620. Coordinate With Maximum Network Quality (Medium)](https://leetcode.com/problems/coordinate-with-maximum-network-quality "网络信号最好的坐标") + +

      You are given an array of network towers towers and an integer radius, where towers[i] = [xi, yi, qi] denotes the ith network tower with location (xi, yi) and quality factor qi. All the coordinates are integral coordinates on the X-Y plane, and the distance between two coordinates is the Euclidean distance.

      + +

      The integer radius denotes the maximum distance in which the tower is reachable. The tower is reachable if the distance is less than or equal to radius. Outside that distance, the signal becomes garbled, and the tower is not reachable.

      + +

      The signal quality of the ith tower at a coordinate (x, y) is calculated with the formula ⌊qi / (1 + d)⌋, where d is the distance between the tower and the coordinate. The network quality at a coordinate is the sum of the signal qualities from all the reachable towers.

      + +

      Return the integral coordinate where the network quality is maximum. If there are multiple coordinates with the same network quality, return the lexicographically minimum coordinate.

      + +

      Note:

      + +
        +
      • A coordinate (x1, y1) is lexicographically smaller than (x2, y2) if either x1 < x2 or x1 == x2 and y1 < y2.
      • +
      • ⌊val⌋ is the greatest integer less than or equal to val (the floor function).
      • +
      + +

       

      +

      Example 1:

      + +
      +Input: towers = [[1,2,5],[2,1,7],[3,1,9]], radius = 2
      +Output: [2,1]
      +Explanation: 
      +At coordinate (2, 1) the total quality is 13
      +- Quality of 7 from (2, 1) results in ⌊7 / (1 + sqrt(0)⌋ = ⌊7⌋ = 7
      +- Quality of 5 from (1, 2) results in ⌊5 / (1 + sqrt(2)⌋ = ⌊2.07⌋ = 2
      +- Quality of 9 from (3, 1) results in ⌊9 / (1 + sqrt(1)⌋ = ⌊4.5⌋ = 4
      +No other coordinate has higher quality.
      + +

      Example 2:

      + +
      +Input: towers = [[23,11,21]], radius = 9
      +Output: [23,11]
      +
      + +

      Example 3:

      + +
      +Input: towers = [[1,2,13],[2,1,7],[0,1,9]], radius = 2
      +Output: [1,2]
      +
      + +

      Example 4:

      + +
      +Input: towers = [[2,1,9],[0,1,9]], radius = 2
      +Output: [0,1]
      +Explanation: Both (0, 1) and (2, 1) are optimal in terms of quality but (0, 1) is lexicograpically minimal.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= towers.length <= 50
      • +
      • towers[i].length == 3
      • +
      • 0 <= xi, yi, qi <= 50
      • +
      • 1 <= radius <= 50
      • +
      + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
      +Hint 1 +The constraints are small enough to consider every possible coordinate and calculate its quality. +
      diff --git a/problems/count-and-say/README.md b/problems/count-and-say/README.md index a86cec48c..687c7042b 100644 --- a/problems/count-and-say/README.md +++ b/problems/count-and-say/README.md @@ -25,28 +25,34 @@ 11 is read off as "two 1s" or 21.
      21 is read off as "one 2, then one 1" or 1211.

      -

      Given an integer n where 1 ≤ n ≤ 30, generate the nth term of the count-and-say sequence. You can do so recursively, in other words from the previous member read off the digits, counting the number of digits in groups of the same digit.

      +

      Given an integer n, generate the nth term of the count-and-say sequence. You can do so recursively, in other words from the previous member read off the digits, counting the number of digits in groups of the same digit.

      Note: Each term of the sequence of integers will be represented as a string.

       

      - -

      Example 1:

      +

      Example 1:

      -Input: 1
      -Output: "1"
      -Explanation: This is the base case.
      +Input: n = 1
      +Output: "1"
      +Explanation: This is the base case.
       
      -

      Example 2:

      +

      Example 2:

      -Input: 4
      -Output: "1211"
      -Explanation: For n = 3 the term was "21" in which we have two groups "2" and "1", "2" can be read as "12" which means frequency = 1 and value = 2, the same way "1" is read as "11", so the answer is the concatenation of "12" and "11" which is "1211".
      +Input: n = 4
      +Output: "1211"
      +Explanation: For n = 3 the term was "21" in which we have two groups "2" and "1", "2" can be read as "12" which means frequency = 1 and value = 2, the same way "1" is read as "11", so the answer is the concatenation of "12" and "11" which is "1211".
       
      +

       

      +

      Constraints:

      + +
        +
      • 1 <= n <= 30
      • +
      + ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/count-subtrees-with-max-distance-between-cities/README.md b/problems/count-subtrees-with-max-distance-between-cities/README.md new file mode 100644 index 000000000..d3c9184f2 --- /dev/null +++ b/problems/count-subtrees-with-max-distance-between-cities/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../split-two-strings-to-make-palindrome "Split Two Strings to Make Palindrome") +                 +[Next >](../maximum-font-to-fit-a-sentence-in-a-screen "Maximum Font to Fit a Sentence in a Screen") + +## [1617. Count Subtrees With Max Distance Between Cities (Hard)](https://leetcode.com/problems/count-subtrees-with-max-distance-between-cities "统计子树中城市之间最大距离") + +

      There are n cities numbered from 1 to n. You are given an array edges of size n-1, where edges[i] = [ui, vi] represents a bidirectional edge between cities ui and vi. There exists a unique path between each pair of cities. In other words, the cities form a tree.

      + +

      A subtree is a subset of cities where every city is reachable from every other city in the subset, where the path between each pair passes through only the cities from the subset. Two subtrees are different if there is a city in one subtree that is not present in the other.

      + +

      For each d from 1 to n-1, find the number of subtrees in which the maximum distance between any two cities in the subtree is equal to d.

      + +

      Return an array of size n-1 where the dth element (1-indexed) is the number of subtrees in which the maximum distance between any two cities is equal to d.

      + +

      Notice that the distance between the two cities is the number of edges in the path between them.

      + +

       

      +

      Example 1:

      + +

      + +
      +Input: n = 4, edges = [[1,2],[2,3],[2,4]]
      +Output: [3,4,0]
      +Explanation:
      +The subtrees with subsets {1,2}, {2,3} and {2,4} have a max distance of 1.
      +The subtrees with subsets {1,2,3}, {1,2,4}, {2,3,4} and {1,2,3,4} have a max distance of 2.
      +No subtree has two nodes where the max distance between them is 3.
      +
      + +

      Example 2:

      + +
      +Input: n = 2, edges = [[1,2]]
      +Output: [1]
      +
      + +

      Example 3:

      + +
      +Input: n = 3, edges = [[1,2],[2,3]]
      +Output: [2,1]
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 2 <= n <= 15
      • +
      • edges.length == n-1
      • +
      • edges[i].length == 2
      • +
      • 1 <= ui, vi <= n
      • +
      • All pairs (ui, vi) are distinct.
      • +
      + +### Related Topics + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
      +Hint 1 +Iterate through every possible subtree by doing a bitmask on which vertices to include. How can you determine if a subtree is valid (all vertices are connected)? +
      + +
      +Hint 2 +To determine connectivity, count the number of reachable vertices starting from any included vertex and only traveling on edges connecting 2 vertices in the subtree. The count should be the same as the number of 1s in the bitmask. +
      + +
      +Hint 3 +The diameter is basically the maximum distance between any two nodes. Root the tree at a vertex. The answer is the max of the heights of the two largest subtrees or the longest diameter in any of the subtrees. +
      diff --git a/problems/count-univalue-subtrees/README.md b/problems/count-univalue-subtrees/README.md index 68d57a5be..d90a0644d 100644 --- a/problems/count-univalue-subtrees/README.md +++ b/problems/count-univalue-subtrees/README.md @@ -33,4 +33,4 @@ ### Similar Questions 1. [Subtree of Another Tree](../subtree-of-another-tree) (Easy) - 1. [Longest Univalue Path](../longest-univalue-path) (Easy) + 1. [Longest Univalue Path](../longest-univalue-path) (Medium) diff --git a/problems/fancy-sequence/README.md b/problems/fancy-sequence/README.md new file mode 100644 index 000000000..1a725d9e2 --- /dev/null +++ b/problems/fancy-sequence/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../number-of-sets-of-k-non-overlapping-line-segments "Number of Sets of K Non-Overlapping Line Segments") +                 +Next > + +## [1622. Fancy Sequence (Hard)](https://leetcode.com/problems/fancy-sequence "奇妙序列") + +

      Write an API that generates fancy sequences using the append, addAll, and multAll operations.

      + +

      Implement the Fancy class:

      + +
        +
      • Fancy() Initializes the object with an empty sequence.
      • +
      • void append(val) Appends an integer val to the end of the sequence.
      • +
      • void addAll(inc) Increments all existing values in the sequence by an integer inc.
      • +
      • void multAll(m) Multiplies all existing values in the sequence by an integer m.
      • +
      • int getIndex(idx) Gets the current value at index idx (0-indexed) of the sequence modulo 109 + 7. If the index is greater or equal than the length of the sequence, return -1.
      • +
      + +

       

      +

      Example 1:

      + +
      +Input
      +["Fancy", "append", "addAll", "append", "multAll", "getIndex", "addAll", "append", "multAll", "getIndex", "getIndex", "getIndex"]
      +[[], [2], [3], [7], [2], [0], [3], [10], [2], [0], [1], [2]]
      +Output
      +[null, null, null, null, null, 10, null, null, null, 26, 34, 20]
      +
      +Explanation
      +Fancy fancy = new Fancy();
      +fancy.append(2);   // fancy sequence: [2]
      +fancy.addAll(3);   // fancy sequence: [2+3] -> [5]
      +fancy.append(7);   // fancy sequence: [5, 7]
      +fancy.multAll(2);  // fancy sequence: [5*2, 7*2] -> [10, 14]
      +fancy.getIndex(0); // return 10
      +fancy.addAll(3);   // fancy sequence: [10+3, 14+3] -> [13, 17]
      +fancy.append(10);  // fancy sequence: [13, 17, 10]
      +fancy.multAll(2);  // fancy sequence: [13*2, 17*2, 10*2] -> [26, 34, 20]
      +fancy.getIndex(0); // return 26
      +fancy.getIndex(1); // return 34
      +fancy.getIndex(2); // return 20
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= val, inc, m <= 100
      • +
      • 0 <= idx <= 105
      • +
      • At most 105 calls total will be made to append, addAll, multAll, and getIndex.
      • +
      + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
      +Hint 1 +Use two arrays to save the cumulative multipliers at each time point and cumulative sums adjusted by the current multiplier. +
      + +
      +Hint 2 +The function getIndex(idx) ask to the current value modulo 10^9+7. Use modular inverse and both arrays to calculate this value. +
      diff --git a/problems/find-nearest-right-node-in-binary-tree/README.md b/problems/find-nearest-right-node-in-binary-tree/README.md index b4e1b4721..6f60b3690 100644 --- a/problems/find-nearest-right-node-in-binary-tree/README.md +++ b/problems/find-nearest-right-node-in-binary-tree/README.md @@ -9,7 +9,7 @@                  [Next >](../design-parking-system "Design Parking System") -## [1602. Find Nearest Right Node in Binary Tree (Medium)](https://leetcode.com/problems/find-nearest-right-node-in-binary-tree "") +## [1602. Find Nearest Right Node in Binary Tree (Medium)](https://leetcode.com/problems/find-nearest-right-node-in-binary-tree "找到二叉树中最近的右侧节点") diff --git a/problems/find-the-missing-ids/README.md b/problems/find-the-missing-ids/README.md new file mode 100644 index 000000000..c98123659 --- /dev/null +++ b/problems/find-the-missing-ids/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../check-if-two-expression-trees-are-equivalent "Check If Two Expression Trees are Equivalent") +                 +[Next >](../maximum-nesting-depth-of-the-parentheses "Maximum Nesting Depth of the Parentheses") + +## [1613. Find the Missing IDs (Medium)](https://leetcode.com/problems/find-the-missing-ids "找到遗失的ID") + + diff --git a/problems/find-the-missing-ids/mysql_schemas.sql b/problems/find-the-missing-ids/mysql_schemas.sql new file mode 100644 index 000000000..150f5ff9b --- /dev/null +++ b/problems/find-the-missing-ids/mysql_schemas.sql @@ -0,0 +1,5 @@ +Create table If Not Exists Customers (customer_id int, customer_name varchar(20)); +Truncate table Customers; +insert into Customers (customer_id, customer_name) values ('1', 'Alice'); +insert into Customers (customer_id, customer_name) values ('4', 'Bob'); +insert into Customers (customer_id, customer_name) values ('5', 'Charlie'); diff --git a/problems/first-bad-version/README.md b/problems/first-bad-version/README.md index 00755c011..1d83ec73a 100644 --- a/problems/first-bad-version/README.md +++ b/problems/first-bad-version/README.md @@ -15,20 +15,35 @@

      Suppose you have n versions [1, 2, ..., n] and you want to find out the first bad one, which causes all the following ones to be bad.

      -

      You are given an API bool isBadVersion(version) which will return whether version is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API.

      +

      You are given an API bool isBadVersion(version) which returns whether version is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API.

      -

      Example:

      +

       

      +

      Example 1:

      -Given n = 5, and version = 4 is the first bad version.
      -
      -call isBadVersion(3) -> false
      +Input: n = 5, bad = 4
      +Output: 4
      +Explanation:
      +call isBadVersion(3) -> false
       call isBadVersion(5) -> true
       call isBadVersion(4) -> true
      +Then 4 is the first bad version.
      +
      + +

      Example 2:

      -Then 4 is the first bad version. 
      +
      +Input: n = 1, bad = 1
      +Output: 1
       
      +

       

      +

      Constraints:

      + +
        +
      • 1 <= bad <= n <= 231 - 1
      • +
      + ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/first-missing-positive/README.md b/problems/first-missing-positive/README.md index adf4889ee..eccdb8f6f 100644 --- a/problems/first-missing-positive/README.md +++ b/problems/first-missing-positive/README.md @@ -11,32 +11,28 @@ ## [41. First Missing Positive (Hard)](https://leetcode.com/problems/first-missing-positive "缺失的第一个正数") -

      Given an unsorted integer array, find the smallest missing positive integer.

      +

      Given an unsorted integer array nums, find the smallest missing positive integer.

      -

      Example 1:

      - -
      -Input: [1,2,0]
      -Output: 3
      -
      +

      Follow up: Could you implement an algorithm that runs in O(n) time and uses constant extra space.?

      -

      Example 2:

      - -
      -Input: [3,4,-1,1]
      -Output: 2
      -
      - -

      Example 3:

      - -
      -Input: [7,8,9,11,12]
      -Output: 1
      +

       

      +

      Example 1:

      +
      Input: nums = [1,2,0]
      +Output: 3
      +

      Example 2:

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

      Example 3:

      +
      Input: nums = [7,8,9,11,12]
      +Output: 1
       
      +

       

      +

      Constraints:

      -

      Follow up:

      - -

      Your algorithm should run in O(n) time and uses constant extra space.

      +
        +
      • 0 <= nums.length <= 300
      • +
      • -231 <= nums[i] <= 231 - 1
      • +
      ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/hand-of-straights/README.md b/problems/hand-of-straights/README.md index f3999aa27..5d08bff8f 100644 --- a/problems/hand-of-straights/README.md +++ b/problems/hand-of-straights/README.md @@ -17,24 +17,24 @@

      Return true if and only if she can.

      -

       

      - -
        -
      +

      Note: This question is the same as 1296: https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/

      +

       

      Example 1:

      -Input: hand = [1,2,3,6,2,3,4,7,8], W = 3
      -Output: true
      -Explanation: Alice's hand can be rearranged as [1,2,3],[2,3,4],[6,7,8].
      +Input: hand = [1,2,3,6,2,3,4,7,8], W = 3 +Output: true +Explanation: Alice's hand can be rearranged as [1,2,3],[2,3,4],[6,7,8] +

      Example 2:

      -Input: hand = [1,2,3,4,5], W = 4
      -Output: false
      -Explanation: Alice's hand can't be rearranged into groups of 4.
      +Input: hand = [1,2,3,4,5], W = 4
      +Output: false
      +Explanation: Alice's hand can't be rearranged into groups of 4.
      +
       

       

      @@ -45,7 +45,6 @@
    • 0 <= hand[i] <= 10^9
    • 1 <= W <= hand.length
    -Note: This question is the same as 1296: https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/ ### Related Topics [[Ordered Map](../../tag/ordered-map/README.md)] diff --git a/problems/human-traffic-of-stadium/README.md b/problems/human-traffic-of-stadium/README.md index c7af7319b..30440bda9 100644 --- a/problems/human-traffic-of-stadium/README.md +++ b/problems/human-traffic-of-stadium/README.md @@ -11,12 +11,33 @@ ## [601. Human Traffic of Stadium (Hard)](https://leetcode.com/problems/human-traffic-of-stadium "体育馆的人流量") -

    X city built a new stadium, each day many people visit it and the stats are saved as these columns: id, visit_date, people

    +

    Table: Stadium

    -

    Please write a query to display the records which have 3 or more consecutive rows and the amount of people more than 100(inclusive).

    -For example, the table stadium: +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| id            | int     |
    +| visit_date    | date    |
    +| people        | int     |
    ++---------------+---------+
    +visit_date is the primary key for this table.
    +Each row of this table contains the visit date and visit id to the stadium with the number of people during the visit.
    +No two rows will have the same visit_date, and as the id increases, the dates increase as well.
    +
    + +

     

    + +

    Write an SQL query to display the records with three or more rows with consecutive id's, and the number of people is greater than or equal to 100 for each.

    + +

    Return the result table ordered by visit_date in ascending order.

    + +

    The query result format is in the following example.

    + +

     

    +Stadium table:
     +------+------------+-----------+
     | id   | visit_date | people    |
     +------+------------+-----------+
    @@ -27,22 +48,17 @@ For example, the table stadium:
     | 5    | 2017-01-05 | 145       |
     | 6    | 2017-01-06 | 1455      |
     | 7    | 2017-01-07 | 199       |
    -| 8    | 2017-01-08 | 188       |
    +| 8    | 2017-01-09 | 188       |
     +------+------------+-----------+
    -
    - -

    For the sample data above, the output is:

    -
    +Result table:
     +------+------------+-----------+
     | id   | visit_date | people    |
     +------+------------+-----------+
     | 5    | 2017-01-05 | 145       |
     | 6    | 2017-01-06 | 1455      |
     | 7    | 2017-01-07 | 199       |
    -| 8    | 2017-01-08 | 188       |
    +| 8    | 2017-01-09 | 188       |
     +------+------------+-----------+
    -
    - -

    Note:
    -Each day only have one row record, and the dates are increasing with id increasing.

    +The four rows with ids 5, 6, 7, and 8 have consecutive ids and each of them has >= 100 people attended. Note that row 8 was included even though the visit_date was not the next day after row 7. +The rows with ids 2 and 3 are not included because we need at least three consecutive ids. diff --git a/problems/human-traffic-of-stadium/mysql_schemas.sql b/problems/human-traffic-of-stadium/mysql_schemas.sql index 36a949aed..735337369 100644 --- a/problems/human-traffic-of-stadium/mysql_schemas.sql +++ b/problems/human-traffic-of-stadium/mysql_schemas.sql @@ -7,4 +7,4 @@ insert into stadium (id, visit_date, people) values ('4', '2017-01-04', '99'); insert into stadium (id, visit_date, people) values ('5', '2017-01-05', '145'); insert into stadium (id, visit_date, people) values ('6', '2017-01-06', '1455'); insert into stadium (id, visit_date, people) values ('7', '2017-01-07', '199'); -insert into stadium (id, visit_date, people) values ('8', '2017-01-08', '188'); +insert into stadium (id, visit_date, people) values ('8', '2017-01-09', '188'); diff --git a/problems/integer-to-english-words/README.md b/problems/integer-to-english-words/README.md index d606efbdb..a64ce0e0d 100644 --- a/problems/integer-to-english-words/README.md +++ b/problems/integer-to-english-words/README.md @@ -11,34 +11,28 @@ ## [273. Integer to English Words (Hard)](https://leetcode.com/problems/integer-to-english-words "整数转换英文表示") -

    Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.

    - -

    Example 1:

    - -
    -Input: 123
    -Output: "One Hundred Twenty Three"
    +

    Convert a non-negative integer num to its English words representation.

    + +

     

    +

    Example 1:

    +
    Input: num = 123
    +Output: "One Hundred Twenty Three"
    +

    Example 2:

    +
    Input: num = 12345
    +Output: "Twelve Thousand Three Hundred Forty Five"
    +

    Example 3:

    +
    Input: num = 1234567
    +Output: "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven"
    +

    Example 4:

    +
    Input: num = 1234567891
    +Output: "One Billion Two Hundred Thirty Four Million Five Hundred Sixty Seven Thousand Eight Hundred Ninety One"
     
    +

     

    +

    Constraints:

    -

    Example 2:

    - -
    -Input: 12345
    -Output: "Twelve Thousand Three Hundred Forty Five"
    - -

    Example 3:

    - -
    -Input: 1234567
    -Output: "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven"
    -
    - -

    Example 4:

    - -
    -Input: 1234567891
    -Output: "One Billion Two Hundred Thirty Four Million Five Hundred Sixty Seven Thousand Eight Hundred Ninety One"
    -
    +
      +
    • 0 <= num <= 231 - 1
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/interleaving-string/README.md b/problems/interleaving-string/README.md index a89f47b45..81da4c39c 100644 --- a/problems/interleaving-string/README.md +++ b/problems/interleaving-string/README.md @@ -11,7 +11,18 @@ ## [97. Interleaving String (Hard)](https://leetcode.com/problems/interleaving-string "交错字符串") -

    Given s1, s2, and s3, find whether s3 is formed by the interleaving of s1 and s2.

    +

    Given strings s1, s2, and s3, find whether s3 is formed by an interleaving of s1 and s2.

    + +

    An interleaving of two strings s and t is a configuration where they are divided into non-empty substrings such that:

    + +
      +
    • s = s1 + s2 + ... + sn
    • +
    • t = t1 + t2 + ... + tm
    • +
    • |n - m| <= 1
    • +
    • The interleaving is s1 + t1 + s2 + t2 + s3 + t3 + ... or t1 + s1 + t2 + s2 + t3 + s3 + ...
    • +
    + +

    Note: a + b is the concatenation of strings a and b.

     

    Example 1:

    diff --git a/problems/jump-game-ii/README.md b/problems/jump-game-ii/README.md index 9a57479a2..17fa35682 100644 --- a/problems/jump-game-ii/README.md +++ b/problems/jump-game-ii/README.md @@ -11,23 +11,37 @@ ## [45. Jump Game II (Hard)](https://leetcode.com/problems/jump-game-ii "跳跃游戏 II") -

    Given an array of non-negative integers, you are initially positioned at the first index of the array.

    +

    Given an array of non-negative integers nums, you are initially positioned at the first index of the array.

    Each element in the array represents your maximum jump length at that position.

    Your goal is to reach the last index in the minimum number of jumps.

    -

    Example:

    +

    You can assume that you can always reach the last index.

    + +

     

    +

    Example 1:

    -Input: [2,3,1,1,4]
    +Input: nums = [2,3,1,1,4]
     Output: 2
    -Explanation: The minimum number of jumps to reach the last index is 2.
    -    Jump 1 step from index 0 to 1, then 3 steps to the last index.
    +Explanation: The minimum number of jumps to reach the last index is 2. Jump 1 step from index 0 to 1, then 3 steps to the last index. +
    -

    Note:

    +

    Example 2:

    -

    You can assume that you can always reach the last index.

    +
    +Input: nums = [2,3,0,1,4]
    +Output: 2
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 3 * 104
    • +
    • 0 <= nums[i] <= 105
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/k-empty-slots/README.md b/problems/k-empty-slots/README.md index 6057ff73a..0f71309cb 100644 --- a/problems/k-empty-slots/README.md +++ b/problems/k-empty-slots/README.md @@ -9,7 +9,7 @@                  [Next >](../redundant-connection "Redundant Connection") -## [683. K Empty Slots (Hard)](https://leetcode.com/problems/k-empty-slots "K 个空花盆") +## [683. K Empty Slots (Hard)](https://leetcode.com/problems/k-empty-slots "K 个关闭的灯泡")

    You have N bulbs in a row numbered from 1 to N. Initially, all the bulbs are turned off. We turn on exactly one bulb everyday until all bulbs are on after N days.

    diff --git a/problems/lfu-cache/README.md b/problems/lfu-cache/README.md index 5f0d76269..33f7be07a 100644 --- a/problems/lfu-cache/README.md +++ b/problems/lfu-cache/README.md @@ -11,38 +11,53 @@ ## [460. LFU Cache (Hard)](https://leetcode.com/problems/lfu-cache "LFU缓存") -

    Design and implement a data structure for Least Frequently Used (LFU) cache. It should support the following operations: get and put.

    +

    Design and implement a data structure for Least Frequently Used (LFU) cache.

    -

    get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.
    -put(key, value) - Set or insert the value if the key is not already present. When the cache reaches its capacity, it should invalidate the least frequently used item before inserting a new item. For the purpose of this problem, when there is a tie (i.e., two or more keys that have the same frequency), the least recently used key would be evicted.

    +

    Implement the LFUCache class:

    -

    Note that the number of times an item is used is the number of calls to the get and put functions for that item since it was inserted. This number is set to zero when the item is removed.

    +
      +
    • LFUCache(int capacity) Initializes the object with the capacity of the data structure.
    • +
    • int get(int key) Gets the value of the key if the key exists in the cache. Otherwise, returns -1.
    • +
    • void put(int key, int value) Sets or inserts the value if the key is not already present. When the cache reaches its capacity, it should invalidate the least frequently used item before inserting a new item. For this problem, when there is a tie (i.e., two or more keys with the same frequency), the least recently used key would be evicted.
    • +
    -

     

    +

    Notice that the number of times an item is used is the number of calls to the get and put functions for that item since it was inserted. This number is set to zero when the item is removed.

    Follow up:
    Could you do both operations in O(1) time complexity?

     

    - -

    Example:

    +

    Example 1:

    -LFUCache cache = new LFUCache( 2 /* capacity */ );
    -
    -cache.put(1, 1);
    -cache.put(2, 2);
    -cache.get(1);       // returns 1
    -cache.put(3, 3);    // evicts key 2
    -cache.get(2);       // returns -1 (not found)
    -cache.get(3);       // returns 3.
    -cache.put(4, 4);    // evicts key 1.
    -cache.get(1);       // returns -1 (not found)
    -cache.get(3);       // returns 3
    -cache.get(4);       // returns 4
    +Input
    +["LFUCache", "put", "put", "get", "put", "get", "get", "put", "get", "get", "get"]
    +[[2], [1, 1], [2, 2], [1], [3, 3], [2], [3], [4, 4], [1], [3], [4]]
    +Output
    +[null, null, null, 1, null, -1, 3, null, -1, 3, 4]
    +
    +Explanation
    +LFUCache lFUCache = new LFUCache(2);
    +lFUCache.put(1, 1);
    +lFUCache.put(2, 2);
    +lFUCache.get(1);      // return 1
    +lFUCache.put(3, 3);   // evicts key 2
    +lFUCache.get(2);      // return -1 (not found)
    +lFUCache.get(3);      // return 3
    +lFUCache.put(4, 4);   // evicts key 1.
    +lFUCache.get(1);      // return -1 (not found)
    +lFUCache.get(3);      // return 3
    +lFUCache.get(4);      // return 4
    +
     

     

    +

    Constraints:

    + +
      +
    • 0 <= capacity, key, value <= 104
    • +
    • At most 105 calls will be made to get and put.
    • +
    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/longest-continuous-increasing-subsequence/README.md b/problems/longest-continuous-increasing-subsequence/README.md index b5b65a90a..54f55fc08 100644 --- a/problems/longest-continuous-increasing-subsequence/README.md +++ b/problems/longest-continuous-increasing-subsequence/README.md @@ -11,30 +11,37 @@ ## [674. Longest Continuous Increasing Subsequence (Easy)](https://leetcode.com/problems/longest-continuous-increasing-subsequence "最长连续递增序列") -

    -Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray). -

    +

    Given an unsorted array of integers nums, return the length of the longest continuous increasing subsequence (i.e. subarray). The subsequence must be strictly increasing.

    + +

    A continuous increasing subsequence is defined by two indices l and r (l < r) such that it is [nums[l], nums[l + 1], ..., nums[r - 1], nums[r]] and for each l <= i < r, nums[i] < nums[i + 1].

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: [1,3,5,4,7]
    -Output: 3
    -Explanation: The longest continuous increasing subsequence is [1,3,5], its length is 3. 
    -Even though [1,3,5,7] is also an increasing subsequence, it's not a continuous one where 5 and 7 are separated by 4. 
    +Input: nums = [1,3,5,4,7]
    +Output: 3
    +Explanation: The longest continuous increasing subsequence is [1,3,5] with length 3.
    +Even though [1,3,5,7] is an increasing subsequence, it is not continuous as elements 5 and 7 are separated by element
    +4.
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: [2,2,2,2,2]
    -Output: 1
    -Explanation: The longest continuous increasing subsequence is [2], its length is 1. 
    +Input: nums = [2,2,2,2,2]
    +Output: 1
    +Explanation: The longest continuous increasing subsequence is [2] with length 1. Note that it must be strictly
    +increasing.
     
    -

    -

    Note: -Length of the array will not exceed 10,000. -

    +

     

    +

    Constraints:

    + +
      +
    • 0 <= nums.length <= 104
    • +
    • -109 <= nums[i] <= 109
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/longest-univalue-path/README.md b/problems/longest-univalue-path/README.md index 8d3a7734f..a00baf2f6 100644 --- a/problems/longest-univalue-path/README.md +++ b/problems/longest-univalue-path/README.md @@ -9,47 +9,35 @@                  [Next >](../knight-probability-in-chessboard "Knight Probability in Chessboard") -## [687. Longest Univalue Path (Easy)](https://leetcode.com/problems/longest-univalue-path "最长同值路径") +## [687. Longest Univalue Path (Medium)](https://leetcode.com/problems/longest-univalue-path "最长同值路径") -

    Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the root.

    +

    Given the root of a binary tree, return the length of the longest path, where each node in the path has the same value. This path may or may not pass through the root.

    -

    The length of path between two nodes is represented by the number of edges between them.

    +

    The length of the path between two nodes is represented by the number of edges between them.

     

    - -

    Example 1:

    - -

    Input:

    - +

    Example 1:

    +
    -              5
    -             / \
    -            4   5
    -           / \   \
    -          1   1   5
    +Input: root = [5,4,5,1,1,5]
    +Output: 2
     
    -

    Output: 2

    - -

     

    - -

    Example 2:

    - -

    Input:

    - +

    Example 2:

    +
    -              1
    -             / \
    -            4   5
    -           / \   \
    -          4   4   5
    +Input: root = [1,4,5,4,4,5]
    +Output: 2
     
    -

    Output: 2

    -

     

    +

    Constraints:

    -

    Note: The given binary tree has not more than 10000 nodes. The height of the tree is not more than 1000.

    +
      +
    • The number of nodes in the tree is in the range [0, 104].
    • +
    • -1000 <= Node.val <= 1000
    • +
    • The depth of the tree will not exceed 1000.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md b/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md index a675ce477..a20ce965d 100644 --- a/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md @@ -15,32 +15,39 @@

    According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).”

    -

    Given binary search tree:  root = [6,2,8,0,4,7,9,null,null,3,5]

    -

     

    -

    Example 1:

    - +
     Input: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 8
     Output: 6
    -Explanation: The LCA of nodes 2 and 8 is 6.
    +Explanation: The LCA of nodes 2 and 8 is 6.
     

    Example 2:

    - +
     Input: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 4
     Output: 2
    -Explanation: The LCA of nodes 2 and 4 is 2, since a node can be a descendant of itself according to the LCA definition.
    +Explanation: The LCA of nodes 2 and 4 is 2, since a node can be a descendant of itself according to the LCA definition.
    +
    + +

    Example 3:

    + +
    +Input: root = [2,1], p = 2, q = 1
    +Output: 2
     

     

    Constraints:

      -
    • All of the nodes' values will be unique.
    • -
    • p and q are different and both values will exist in the BST.
    • +
    • The number of nodes in the tree is in the range [2, 105].
    • +
    • -109 <= Node.val <= 109
    • +
    • All Node.val are unique.
    • +
    • p != q
    • +
    • p and q will exist in the BST.
    ### Related Topics diff --git a/problems/lowest-common-ancestor-of-a-binary-tree/README.md b/problems/lowest-common-ancestor-of-a-binary-tree/README.md index 4224236f9..868bb850d 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree/README.md @@ -15,33 +15,39 @@

    According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).”

    -

    Given the following binary tree:  root = [3,5,1,6,2,0,8,null,null,7,4]

    -

     

    -

    Example 1:

    - +
     Input: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1
     Output: 3
    -Explanation: The LCA of nodes 5 and 1 is 3.
    +Explanation: The LCA of nodes 5 and 1 is 3.
     

    Example 2:

    - +
     Input: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 4
     Output: 5
    -Explanation: The LCA of nodes 5 and 4 is 5, since a node can be a descendant of itself according to the LCA definition.
    +Explanation: The LCA of nodes 5 and 4 is 5, since a node can be a descendant of itself according to the LCA definition.
     
    -

     

    +

    Example 3:

    -

    Note:

    +
    +Input: root = [1,2], p = 1, q = 2
    +Output: 1
    +
    + +

     

    +

    Constraints:

      -
    • All of the nodes' values will be unique.
    • -
    • p and q are different and both values will exist in the binary tree.
    • +
    • The number of nodes in the tree is in the range [2, 105].
    • +
    • -109 <= Node.val <= 109
    • +
    • All Node.val are unique.
    • +
    • p != q
    • +
    • p and q will exist in the tree.
    ### Related Topics diff --git a/problems/lowest-common-ancestor-of-deepest-leaves/README.md b/problems/lowest-common-ancestor-of-deepest-leaves/README.md index 134767ebe..aa5600a03 100644 --- a/problems/lowest-common-ancestor-of-deepest-leaves/README.md +++ b/problems/lowest-common-ancestor-of-deepest-leaves/README.md @@ -11,48 +11,51 @@ ## [1123. Lowest Common Ancestor of Deepest Leaves (Medium)](https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves "最深叶节点的最近公共祖先") -

    Given a rooted binary tree, return the lowest common ancestor of its deepest leaves.

    +

    Given the root of a binary tree, return the lowest common ancestor of its deepest leaves.

    Recall that:

      -
    • The node of a binary tree is a leaf if and only if it has no children
    • -
    • The depth of the root of the tree is 0, and if the depth of a node is d, the depth of each of its children is d+1.
    • -
    • The lowest common ancestor of a set S of nodes is the node A with the largest depth such that every node in S is in the subtree with root A.
    • +
    • The node of a binary tree is a leaf if and only if it has no children
    • +
    • The depth of the root of the tree is 0. if the depth of a node is d, the depth of each of its children is d + 1.
    • +
    • The lowest common ancestor of a set S of nodes, is the node A with the largest depth such that every node in S is in the subtree with root A.
    +

    Note: This question is the same as 865: https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/

    +

     

    Example 1:

    - +
    -Input: root = [1,2,3]
    -Output: [1,2,3]
    -Explanation: 
    -The deepest leaves are the nodes with values 2 and 3.
    -The lowest common ancestor of these leaves is the node with value 1.
    -The answer returned is a TreeNode object (not an array) with serialization "[1,2,3]".
    -
    +Input: root = [3,5,1,6,2,0,8,null,null,7,4] +Output: [2,7,4] +Explanation: We return the node with value 2, colored in yellow in the diagram. +The nodes coloured in blue are the deepest leaf-nodes of the tree. +Note that nodes 6, 0, and 8 are also leaf nodes, but the depth of them is 2, but the depth of nodes 7 and 4 is 3.

    Example 2:

    -Input: root = [1,2,3,4]
    -Output: [4]
    +Input: root = [1]
    +Output: [1]
    +Explanation: The root is the deepest node in the tree, and it's the lca of itself.
     

    Example 3:

    -Input: root = [1,2,3,4,5]
    -Output: [2,4,5]
    +Input: root = [0,1,3,null,2]
    +Output: [2]
    +Explanation: The deepest leaf node in the tree is 2, the lca of one node is itself.
     

     

    Constraints:

      -
    • The given tree will have between 1 and 1000 nodes.
    • -
    • Each node of the tree will have a distinct value between 1 and 1000.
    • +
    • The number of nodes in the tree will be in the range [1, 1000].
    • +
    • 0 <= Node.val <= 1000
    • +
    • The values of the nodes in the tree are unique.
    ### Related Topics diff --git a/problems/maximal-network-rank/README.md b/problems/maximal-network-rank/README.md new file mode 100644 index 000000000..6526d1dc1 --- /dev/null +++ b/problems/maximal-network-rank/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../maximum-nesting-depth-of-the-parentheses "Maximum Nesting Depth of the Parentheses") +                 +[Next >](../split-two-strings-to-make-palindrome "Split Two Strings to Make Palindrome") + +## [1615. Maximal Network Rank (Medium)](https://leetcode.com/problems/maximal-network-rank "最大网络秩") + +

    There is an infrastructure of n cities with some number of roads connecting these cities. Each roads[i] = [ai, bi] indicates that there is a bidirectional road between cities ai and bi.

    + +

    The network rank of two different cities is defined as the total number of directly connected roads to either city. If a road is directly connected to both cities, it is only counted once.

    + +

    The maximal network rank of the infrastructure is the maximum network rank of all pairs of different cities.

    + +

    Given the integer n and the array roads, return the maximal network rank of the entire infrastructure.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: n = 4, roads = [[0,1],[0,3],[1,2],[1,3]]
    +Output: 4
    +Explanation: The network rank of cities 0 and 1 is 4 as there are 4 roads that are connected to either 0 or 1. The road between 0 and 1 is only counted once.
    +
    + +

    Example 2:

    + +

    + +
    +Input: n = 5, roads = [[0,1],[0,3],[1,2],[1,3],[2,3],[2,4]]
    +Output: 5
    +Explanation: There are 5 roads that are connected to cities 1 or 2.
    +
    + +

    Example 3:

    + +
    +Input: n = 8, roads = [[0,1],[1,2],[2,3],[2,4],[5,6],[5,7]]
    +Output: 5
    +Explanation: The network rank of 2 and 5 is 5. Notice that all the cities do not have to be connected.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 100
    • +
    • 0 <= roads.length <= n * (n - 1) / 2
    • +
    • roads[i].length == 2
    • +
    • 0 <= ai, bi <= n-1
    • +
    • ai != bi
    • +
    • Each pair of cities has at most one road connecting them.
    • +
    + +### Related Topics + [[Graph](../../tag/graph/README.md)] + +### Hints +
    +Hint 1 +Try every pair of different cities and calculate its network rank. +
    + +
    +Hint 2 +The network rank of two vertices is almost the sum of their degrees. +
    + +
    +Hint 3 +How can you efficiently check if there is a road connecting two different cities? +
    diff --git a/problems/maximum-font-to-fit-a-sentence-in-a-screen/README.md b/problems/maximum-font-to-fit-a-sentence-in-a-screen/README.md new file mode 100644 index 000000000..5ff4fa928 --- /dev/null +++ b/problems/maximum-font-to-fit-a-sentence-in-a-screen/README.md @@ -0,0 +1,24 @@ + + + + + + + +[< Previous](../count-subtrees-with-max-distance-between-cities "Count Subtrees With Max Distance Between Cities") +                 +[Next >](../mean-of-array-after-removing-some-elements "Mean of Array After Removing Some Elements") + +## [1618. Maximum Font to Fit a Sentence in a Screen (Medium)](https://leetcode.com/problems/maximum-font-to-fit-a-sentence-in-a-screen "找出适应屏幕的最大字号") + + + +### Related Topics + [[String](../../tag/string/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Use binary search to find the last valid font. +
    diff --git a/problems/maximum-nesting-depth-of-the-parentheses/README.md b/problems/maximum-nesting-depth-of-the-parentheses/README.md new file mode 100644 index 000000000..aa0ef03d6 --- /dev/null +++ b/problems/maximum-nesting-depth-of-the-parentheses/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../find-the-missing-ids "Find the Missing IDs") +                 +[Next >](../maximal-network-rank "Maximal Network Rank") + +## [1614. Maximum Nesting Depth of the Parentheses (Easy)](https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses "括号的最大嵌套深度") + +

    A string is a valid parentheses string (denoted VPS) if it meets one of the following:

    + +
      +
    • It is an empty string "", or a single character not equal to "(" or ")",
    • +
    • It can be written as AB (A concatenated with B), where A and B are VPS's, or
    • +
    • It can be written as (A), where A is a VPS.
    • +
    + +

    We can similarly define the nesting depth depth(S) of any VPS S as follows:

    + +
      +
    • depth("") = 0
    • +
    • depth(A + B) = max(depth(A), depth(B)), where A and B are VPS's
    • +
    • depth("(" + A + ")") = 1 + depth(A), where A is a VPS.
    • +
    + +

    For example, "", "()()", and "()(()())" are VPS's (with nesting depths 0, 1, and 2), and ")(" and "(()" are not VPS's.

    + +

    Given a VPS represented as string s, return the nesting depth of s.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "(1+(2*3)+((8)/4))+1"
    +Output: 3
    +Explanation: Digit 8 is inside of 3 nested parentheses in the string.
    +
    + +

    Example 2:

    + +
    +Input: s = "(1)+((2))+(((3)))"
    +Output: 3
    +
    + +

    Example 3:

    + +
    +Input: s = "1+(2*3)/(2-1)"
    +Output: 1
    +
    + +

    Example 4:

    + +
    +Input: s = "1"
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 100
    • +
    • s consists of digits 0-9 and characters '+', '-', '*', '/', '(', and ')'.
    • +
    • It is guaranteed that parentheses expression s is a VPS.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +The depth of any character in the VPS is the ( number of left brackets before it ) - ( number of right brackets before it ) +
    diff --git a/problems/mean-of-array-after-removing-some-elements/README.md b/problems/mean-of-array-after-removing-some-elements/README.md new file mode 100644 index 000000000..35f9d41da --- /dev/null +++ b/problems/mean-of-array-after-removing-some-elements/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](../maximum-font-to-fit-a-sentence-in-a-screen "Maximum Font to Fit a Sentence in a Screen") +                 +[Next >](../coordinate-with-maximum-network-quality "Coordinate With Maximum Network Quality") + +## [1619. Mean of Array After Removing Some Elements (Easy)](https://leetcode.com/problems/mean-of-array-after-removing-some-elements "删除某些元素后的数组均值") + +

    Given an integer array arr, return the mean of the remaining integers after removing the smallest 5% and the largest 5% of the elements.

    + +

    Answers within 10-5 of the actual answer will be considered accepted.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3]
    +Output: 2.00000
    +Explanation: After erasing the minimum and the maximum values of this array, all elements are equal to 2, so the mean is 2.
    +
    + +

    Example 2:

    + +
    +Input: arr = [6,2,7,5,1,2,0,3,10,2,5,0,5,5,0,8,7,6,8,0]
    +Output: 4.00000
    +
    + +

    Example 3:

    + +
    +Input: arr = [6,0,7,0,7,5,7,8,3,4,0,7,8,1,6,8,1,1,2,4,8,1,9,5,4,3,8,5,10,8,6,6,1,0,6,10,8,2,3,4]
    +Output: 4.77778
    +
    + +

    Example 4:

    + +
    +Input: arr = [9,7,8,7,7,8,4,4,6,8,8,7,6,8,8,9,2,6,0,0,1,10,8,6,3,3,5,1,10,9,0,7,10,0,10,4,1,10,6,9,3,6,0,0,2,7,0,6,7,2,9,7,7,3,0,1,6,1,10,3]
    +Output: 5.27778
    +
    + +

    Example 5:

    + +
    +Input: arr = [4,8,4,10,0,7,1,3,7,8,8,3,4,1,6,2,1,1,8,0,9,8,0,3,9,10,3,10,1,10,7,3,2,1,4,9,10,7,6,4,0,8,5,1,2,1,6,2,5,0,7,10,9,10,3,7,10,5,8,5,7,6,7,6,10,9,5,10,5,5,7,2,10,7,7,8,2,0,1,1]
    +Output: 5.29167
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 20 <= arr.length <= 1000
    • +
    • arr.length is a multiple of 20.
    • +
    • 0 <= arr[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Sort the given array. +
    + +
    +Hint 2 +Remove the first and last 5% of the sorted array. +
    diff --git a/problems/minimum-depth-of-binary-tree/README.md b/problems/minimum-depth-of-binary-tree/README.md index 9fc183496..6bbff7113 100644 --- a/problems/minimum-depth-of-binary-tree/README.md +++ b/problems/minimum-depth-of-binary-tree/README.md @@ -17,18 +17,28 @@

    Note: A leaf is a node with no children.

    -

    Example:

    +

     

    +

    Example 1:

    + +
    +Input: root = [3,9,20,null,null,15,7]
    +Output: 2
    +
    -

    Given binary tree [3,9,20,null,null,15,7],

    +

    Example 2:

    -    3
    -   / \
    -  9  20
    -    /  \
    -   15   7
    +Input: root = [2,null,3,null,4,null,5,null,6] +Output: 5 + + +

     

    +

    Constraints:

    -

    return its minimum depth = 2.

    +
      +
    • The number of nodes in the tree is in the range [0, 104].
    • +
    • -1000 <= Node.val <= 1000
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/minimum-domino-rotations-for-equal-row/README.md b/problems/minimum-domino-rotations-for-equal-row/README.md index a408778be..6ab0f456d 100644 --- a/problems/minimum-domino-rotations-for-equal-row/README.md +++ b/problems/minimum-domino-rotations-for-equal-row/README.md @@ -11,24 +11,21 @@ ## [1007. Minimum Domino Rotations For Equal Row (Medium)](https://leetcode.com/problems/minimum-domino-rotations-for-equal-row "行相等的最少多米诺旋转") -

    In a row of dominoes, A[i] and B[i] represent the top and bottom halves of the i-th domino.  (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.)

    +

    In a row of dominoes, A[i] and B[i] represent the top and bottom halves of the ith domino.  (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.)

    -

    We may rotate the i-th domino, so that A[i] and B[i] swap values.

    +

    We may rotate the ith domino, so that A[i] and B[i] swap values.

    Return the minimum number of rotations so that all the values in A are the same, or all the values in B are the same.

    If it cannot be done, return -1.

     

    -

    Example 1:

    - -

    - +
    -Input: A = [2,1,2,4,2,2], B = [5,2,6,2,3,2]
    -Output: 2
    -Explanation: 
    +Input: A = [2,1,2,4,2,2], B = [5,2,6,2,3,2]
    +Output: 2
    +Explanation: 
     The first figure represents the dominoes as given by A and B: before we do any rotations.
     If we rotate the second and fourth dominoes, we can make every value in the top row equal to 2, as indicated by the second figure.
     
    @@ -36,20 +33,19 @@ If we rotate the second and fourth dominoes, we can make every value in the top

    Example 2:

    -Input: A = [3,5,1,2,3], B = [3,6,3,3,4]
    -Output: -1
    -Explanation: 
    +Input: A = [3,5,1,2,3], B = [3,6,3,3,4]
    +Output: -1
    +Explanation: 
     In this case, it is not possible to rotate the dominoes to make one row of values equal.
     

     

    +

    Constraints:

    -

    Note:

    - -
      +
        +
      • 2 <= A.length == B.length <= 2 * 104
      • 1 <= A[i], B[i] <= 6
      • -
      • 2 <= A.length == B.length <= 20000
      • -
    + ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/minimum-number-of-arrows-to-burst-balloons/README.md b/problems/minimum-number-of-arrows-to-burst-balloons/README.md index 8954d2033..403cd0ff3 100644 --- a/problems/minimum-number-of-arrows-to-burst-balloons/README.md +++ b/problems/minimum-number-of-arrows-to-burst-balloons/README.md @@ -59,7 +59,7 @@
    • 0 <= points.length <= 104
    • -
    • points.length == 2
    • +
    • points[i].length == 2
    • -231 <= xstart < xend <= 231 - 1
    diff --git a/problems/minimum-time-difference/README.md b/problems/minimum-time-difference/README.md index 6610069b1..fa9891305 100644 --- a/problems/minimum-time-difference/README.md +++ b/problems/minimum-time-difference/README.md @@ -11,21 +11,22 @@ ## [539. Minimum Time Difference (Medium)](https://leetcode.com/problems/minimum-time-difference "最小时间差") -Given a list of 24-hour clock time points in "Hour:Minutes" format, find the minimum minutes difference between any two time points in the list. - -

    Example 1:
    -

    -Input: ["23:59","00:00"]
    -Output: 1
    +Given a list of 24-hour clock time points in "HH:MM" format, return the minimum minutes difference between any two time-points in the list.
    +

     

    +

    Example 1:

    +
    Input: timePoints = ["23:59","00:00"]
    +Output: 1
    +

    Example 2:

    +
    Input: timePoints = ["00:00","23:59","00:00"]
    +Output: 0
     
    -

    +

     

    +

    Constraints:

    -

    Note:
    -

      -
    1. The number of time points in the given list is at least 2 and won't exceed 20000.
    2. -
    3. The input time is legal and ranges from 00:00 to 23:59.
    4. -
    -

    +
      +
    • 2 <= timePoints <= 2 * 104
    • +
    • timePoints[i] is in the format "HH:MM".
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/missing-number/README.md b/problems/missing-number/README.md index 420562a2b..92573152f 100644 --- a/problems/missing-number/README.md +++ b/problems/missing-number/README.md @@ -9,7 +9,7 @@                  [Next >](../alien-dictionary "Alien Dictionary") -## [268. Missing Number (Easy)](https://leetcode.com/problems/missing-number "缺失数字") +## [268. Missing Number (Easy)](https://leetcode.com/problems/missing-number "丢失的数字")

    Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.

    diff --git a/problems/multiply-strings/README.md b/problems/multiply-strings/README.md index 28290addf..2903e95ad 100644 --- a/problems/multiply-strings/README.md +++ b/problems/multiply-strings/README.md @@ -13,27 +13,24 @@

    Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.

    -

    Example 1:

    - -
    -Input: num1 = "2", num2 = "3"
    -Output: "6"
    - -

    Example 2:

    +

    Note: You must not use any built-in BigInteger library or convert the inputs to integer directly.

    -
    -Input: num1 = "123", num2 = "456"
    -Output: "56088"
    +

     

    +

    Example 1:

    +
    Input: num1 = "2", num2 = "3"
    +Output: "6"
    +

    Example 2:

    +
    Input: num1 = "123", num2 = "456"
    +Output: "56088"
     
    - -

    Note:

    - -
      -
    1. The length of both num1 and num2 is < 110.
    2. -
    3. Both num1 and num2 contain only digits 0-9.
    4. -
    5. Both num1 and num2 do not contain any leading zero, except the number 0 itself.
    6. -
    7. You must not use any built-in BigInteger library or convert the inputs to integer directly.
    8. -
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= num1.length, num2.length <= 200
    • +
    • num1 and num2 consist of digits only.
    • +
    • Both num1 and num2 do not contain any leading zero, except the number 0 itself.
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/number-of-1-bits/README.md b/problems/number-of-1-bits/README.md index 10d3d29b7..3332909f4 100644 --- a/problems/number-of-1-bits/README.md +++ b/problems/number-of-1-bits/README.md @@ -13,44 +13,47 @@

    Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight).

    -

     

    +

    Note:

    +
      +
    • Note that in some languages such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type. It should not affect your implementation, as the integer's internal binary representation is the same, whether it is signed or unsigned.
    • +
    • In Java, the compiler represents the signed integers using 2's complement notation. Therefore, in Example 3 above, the input represents the signed integer. -3.
    • +
    + +

    Follow up: If this function is called many times, how would you optimize it?

    + +

     

    Example 1:

    -Input: 00000000000000000000000000001011
    +Input: n = 00000000000000000000000000001011
     Output: 3
    -Explanation: The input binary string 00000000000000000000000000001011 has a total of three '1' bits.
    +Explanation: The input binary string 00000000000000000000000000001011 has a total of three '1' bits.
     

    Example 2:

    -Input: 00000000000000000000000010000000
    +Input: n = 00000000000000000000000010000000
     Output: 1
    -Explanation: The input binary string 00000000000000000000000010000000 has a total of one '1' bit.
    +Explanation: The input binary string 00000000000000000000000010000000 has a total of one '1' bit.
     

    Example 3:

    -Input: 11111111111111111111111111111101
    +Input: n = 11111111111111111111111111111101
     Output: 31
    -Explanation: The input binary string 11111111111111111111111111111101 has a total of thirty one '1' bits.
    +Explanation: The input binary string 11111111111111111111111111111101 has a total of thirty one '1' bits. +

     

    - -

    Note:

    +

    Constraints:

      -
    • Note that in some languages such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type and should not affect your implementation, as the internal binary representation of the integer is the same, whether it is signed or unsigned.
    • -
    • In Java, the compiler represents the signed integers using 2's complement notation. Therefore, in Example 3 above, the input represents the signed integer. -3.
    • +
    • The input must be a binary string of length 32
    -

     

    - -

    Follow up: If this function is called many times, how would you optimize it?

    - ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/number-of-islands/README.md b/problems/number-of-islands/README.md index 6efa55114..f657b3ae2 100644 --- a/problems/number-of-islands/README.md +++ b/problems/number-of-islands/README.md @@ -11,7 +11,9 @@ ## [200. Number of Islands (Medium)](https://leetcode.com/problems/number-of-islands "岛屿数量") -

    Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.

    +

    Given an m x n 2d grid map of '1's (land) and '0's (water), return the number of islands.

    + +

    An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.

     

    Example 1:

    @@ -38,6 +40,16 @@ Output: 3
    +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 300
    • +
    • grid[i][j] is '0' or '1'.
    • +
    + ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md b/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md new file mode 100644 index 000000000..6c74efc59 --- /dev/null +++ b/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../coordinate-with-maximum-network-quality "Coordinate With Maximum Network Quality") +                 +[Next >](../fancy-sequence "Fancy Sequence") + +## [1621. Number of Sets of K Non-Overlapping Line Segments (Medium)](https://leetcode.com/problems/number-of-sets-of-k-non-overlapping-line-segments "大小为 K 的不重叠线段的数目") + +

    Given n points on a 1-D plane, where the ith point (from 0 to n-1) is at x = i, find the number of ways we can draw exactly k non-overlapping line segments such that each segment covers two or more points. The endpoints of each segment must have integral coordinates. The k line segments do not have to cover all n points, and they are allowed to share endpoints.

    + +

    Return the number of ways we can draw k non-overlapping line segments. Since this number can be huge, return it modulo 109 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 4, k = 2
    +Output: 5
    +Explanation: 
    +The two line segments are shown in red and blue.
    +The image above shows the 5 different ways {(0,2),(2,3)}, {(0,1),(1,3)}, {(0,1),(2,3)}, {(1,2),(2,3)}, {(0,1),(1,2)}.
    + +

    Example 2:

    + +
    +Input: n = 3, k = 1
    +Output: 3
    +Explanation: The 3 ways are {(0,1)}, {(0,2)}, {(1,2)}.
    +
    + +

    Example 3:

    + +
    +Input: n = 30, k = 7
    +Output: 796297179
    +Explanation: The total number of possible ways to draw 7 line segments is 3796297200. Taking this number modulo 109 + 7 gives us 796297179.
    +
    + +

    Example 4:

    + +
    +Input: n = 5, k = 3
    +Output: 7
    +
    + +

    Example 5:

    + +
    +Input: n = 3, k = 2
    +Output: 1
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 1000
    • +
    • 1 <= k <= n-1
    • +
    + +### Related Topics + [[Recursion](../../tag/recursion/README.md)] + +### Hints +
    +Hint 1 +Try to use dynamic programming where the current index and remaining number of line segments to form can describe any intermediate state. +
    + +
    +Hint 2 +To make the computation of each state in constant time, we could add another flag to the state that indicates whether or not we are in the middle of placing a line (placed start point but no endpoint). +
    diff --git a/problems/odd-even-jump/README.md b/problems/odd-even-jump/README.md index 6495a0e72..847d6ac0d 100644 --- a/problems/odd-even-jump/README.md +++ b/problems/odd-even-jump/README.md @@ -11,49 +11,53 @@ ## [975. Odd Even Jump (Hard)](https://leetcode.com/problems/odd-even-jump "奇偶跳") -

    You are given an integer array A.  From some starting index, you can make a series of jumps.  The (1st, 3rd, 5th, ...) jumps in the series are called odd numbered jumps, and the (2nd, 4th, 6th, ...) jumps in the series are called even numbered jumps.

    +

    You are given an integer array A. From some starting index, you can make a series of jumps. The (1st, 3rd, 5th, ...) jumps in the series are called odd-numbered jumps, and the (2nd, 4th, 6th, ...) jumps in the series are called even-numbered jumps. Note that the jumps are numbered, not the indices.

    -

    You may from index i jump forward to index j (with i < j) in the following way:

    +

    You may jump forward from index i to index j (with i < j) in the following way:

      -
    • During odd numbered jumps (ie. jumps 1, 3, 5, ...), you jump to the index j such that A[i] <= A[j] and A[j] is the smallest possible value.  If there are multiple such indexes j, you can only jump to the smallest such index j.
    • -
    • During even numbered jumps (ie. jumps 2, 4, 6, ...), you jump to the index j such that A[i] >= A[j] and A[j] is the largest possible value.  If there are multiple such indexes j, you can only jump to the smallest such index j.
    • -
    • (It may be the case that for some index i, there are no legal jumps.)
    • +
    • During odd-numbered jumps (i.e., jumps 1, 3, 5, ...), you jump to the index j such that A[i] <= A[j] and A[j] is the smallest possible value. If there are multiple such indices j, you can only jump to the smallest such index j.
    • +
    • During even-numbered jumps (i.e., jumps 2, 4, 6, ...), you jump to the index j such that A[i] >= A[j] and A[j] is the largest possible value. If there are multiple such indices j, you can only jump to the smallest such index j.
    • +
    • It may be the case that for some index i, there are no legal jumps.
    -

    A starting index is good if, starting from that index, you can reach the end of the array (index A.length - 1) by jumping some number of times (possibly 0 or more than once.)

    +

    A starting index is good if, starting from that index, you can reach the end of the array (index A.length - 1) by jumping some number of times (possibly 0 or more than once).

    -

    Return the number of good starting indexes.

    +

    Return the number of good starting indices.

     

    -

    Example 1:

    -Input: [10,13,12,14,15]
    -Output: 2
    -Explanation: 
    -From starting index i = 0, we can jump to i = 2 (since A[2] is the smallest among A[1], A[2], A[3], A[4] that is greater or equal to A[0]), then we can't jump any more.
    -From starting index i = 1 and i = 2, we can jump to i = 3, then we can't jump any more.
    -From starting index i = 3, we can jump to i = 4, so we've reached the end.
    -From starting index i = 4, we've reached the end already.
    -In total, there are 2 different starting indexes (i = 3, i = 4) where we can reach the end with some number of jumps.
    +Input: A = [10,13,12,14,15]
    +Output: 2
    +Explanation: 
    +From starting index i = 0, we can make our 1st jump to i = 2 (since A[2] is the smallest among A[1], A[2], A[3],
    +A[4] that is greater or equal to A[0]), then we cannot jump any more.
    +From starting index i = 1 and i = 2, we can make our 1st jump to i = 3, then we cannot jump any more.
    +From starting index i = 3, we can make our 1st jump to i = 4, so we have reached the end.
    +From starting index i = 4, we have reached the end already.
    +In total, there are 2 different starting indices i = 3 and i = 4, where we can reach the end with some number of
    +jumps.
     
    -

    Example 2:

    -Input: [2,3,1,1,4]
    -Output: 3
    -Explanation: 
    +Input: A = [2,3,1,1,4]
    +Output: 3
    +Explanation: 
     From starting index i = 0, we make jumps to i = 1, i = 2, i = 3:
     
    -During our 1st jump (odd numbered), we first jump to i = 1 because A[1] is the smallest value in (A[1], A[2], A[3], A[4]) that is greater than or equal to A[0].
    +During our 1st jump (odd-numbered), we first jump to i = 1 because A[1] is the smallest value in [A[1], A[2],
    +A[3], A[4]] that is greater than or equal to A[0].
     
    -During our 2nd jump (even numbered), we jump from i = 1 to i = 2 because A[2] is the largest value in (A[2], A[3], A[4]) that is less than or equal to A[1].  A[3] is also the largest value, but 2 is a smaller index, so we can only jump to i = 2 and not i = 3.
    +During our 2nd jump (even-numbered), we jump from i = 1 to i = 2 because A[2] is the largest value in [A[2], A[3],
    +A[4]] that is less than or equal to A[1]. A[3] is also the largest value, but 2 is a smaller index, so we can
    +only jump to i = 2 and not i = 3
     
    -During our 3rd jump (odd numbered), we jump from i = 2 to i = 3 because A[3] is the smallest value in (A[3], A[4]) that is greater than or equal to A[2].
    +During our 3rd jump (odd-numbered), we jump from i = 2 to i = 3 because A[3] is the smallest value in [A[3], A[4]]
    +that is greater than or equal to A[2].
     
     We can't jump from i = 3 to i = 4, so the starting index i = 0 is not good.
     
    @@ -62,29 +66,26 @@ From starting index i = 1, we jump to i = 4, so we reach the end.
     From starting index i = 2, we jump to i = 3, and then we can't jump anymore.
     From starting index i = 3, we jump to i = 4, so we reach the end.
     From starting index i = 4, we are already at the end.
    -In total, there are 3 different starting indexes (i = 1, i = 3, i = 4) where we can reach the end with some number of jumps.
    +In total, there are 3 different starting indices i = 1, i = 3, and i = 4, where we can reach the end with some
    +number of jumps.
     
    -

    Example 3:

    -Input: [5,1,3,4,2]
    -Output: 3
    -Explanation: 
    -We can reach the end from starting indexes 1, 2, and 4.
    +Input: A = [5,1,3,4,2]
    +Output: 3
    +Explanation: 
    +We can reach the end from starting indices 1, 2, and 4.
     
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= A.length <= 20000
    2. -
    3. 0 <= A[i] < 100000
    4. -
    +
      +
    • 1 <= A.length <= 2 * 104
    • +
    • 0 <= A[i] < 105
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/ones-and-zeroes/README.md b/problems/ones-and-zeroes/README.md index de0279e7a..abfb5155f 100644 --- a/problems/ones-and-zeroes/README.md +++ b/problems/ones-and-zeroes/README.md @@ -11,9 +11,11 @@ ## [474. Ones and Zeroes (Medium)](https://leetcode.com/problems/ones-and-zeroes "一和零") -

    Given an array, strs, with strings consisting of only 0s and 1s. Also two integers m and n.

    +

    You are given an array of binary strings strs and two integers m and n.

    -

    Now your task is to find the maximum number of strings that you can form with given m 0s and n 1s. Each 0 and 1 can be used at most once.

    +

    Return the size of the largest subset of strs such that there are at most m 0's and n 1's in the subset.

    + +

    A set x is a subset of a set y if all elements of x are also elements of y.

     

    Example 1:

    @@ -21,7 +23,9 @@
     Input: strs = ["10","0001","111001","1","0"], m = 5, n = 3
     Output: 4
    -Explanation: This are totally 4 strings can be formed by the using of 5 0s and 3 1s, which are "10","0001","1","0".
    +Explanation: The largest subset with at most 5 0's and 3 1's is {"10", "0001", "1", "0"}, so the answer is 4.
    +Other valid but smaller subsets include {"0001", "1"} and {"10", "1", "0"}.
    +{"111001"} is an invalid subset because it contains 4 1's, greater than the maximum of 3.
     

    Example 2:

    @@ -29,7 +33,7 @@
     Input: strs = ["10","0","1"], m = 1, n = 1
     Output: 2
    -Explanation: You could form "10", but then you'd have nothing left. Better form "0" and "1".
    +Explanation: The largest subset is {"0", "1"}, so the answer is 2.
     

     

    @@ -38,7 +42,7 @@
    • 1 <= strs.length <= 600
    • 1 <= strs[i].length <= 100
    • -
    • strs[i] consists only of digits '0' and '1'.
    • +
    • strs[i] consists only of digits '0' and '1'.
    • 1 <= m, n <= 100
    diff --git a/problems/partition-equal-subset-sum/README.md b/problems/partition-equal-subset-sum/README.md index 2a8918ccf..6654ecd76 100644 --- a/problems/partition-equal-subset-sum/README.md +++ b/problems/partition-equal-subset-sum/README.md @@ -11,40 +11,32 @@ ## [416. Partition Equal Subset Sum (Medium)](https://leetcode.com/problems/partition-equal-subset-sum "分割等和子集") -

    Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.

    - -

    Note:

    - -
      -
    1. Each of the array element will not exceed 100.
    2. -
    3. The array size will not exceed 200.
    4. -
    +

    Given a non-empty array nums containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.

     

    - -

    Example 1:

    +

    Example 1:

    -Input: [1, 5, 11, 5]
    -
    -Output: true
    -
    -Explanation: The array can be partitioned as [1, 5, 5] and [11].
    +Input: nums = [1,5,11,5]
    +Output: true
    +Explanation: The array can be partitioned as [1, 5, 5] and [11].
     
    -

     

    - -

    Example 2:

    +

    Example 2:

    -Input: [1, 2, 3, 5]
    -
    -Output: false
    -
    -Explanation: The array cannot be partitioned into equal sum subsets.
    +Input: nums = [1,2,3,5]
    +Output: false
    +Explanation: The array cannot be partitioned into equal sum subsets.
     

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 200
    • +
    • 1 <= nums[i] <= 100
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/path-sum-iii/README.md b/problems/path-sum-iii/README.md index ae8736af9..73a067462 100644 --- a/problems/path-sum-iii/README.md +++ b/problems/path-sum-iii/README.md @@ -47,4 +47,4 @@ Return 3. The paths that sum to 8 are: 1. [Path Sum](../path-sum) (Easy) 1. [Path Sum II](../path-sum-ii) (Medium) 1. [Path Sum IV](../path-sum-iv) (Medium) - 1. [Longest Univalue Path](../longest-univalue-path) (Easy) + 1. [Longest Univalue Path](../longest-univalue-path) (Medium) diff --git a/problems/range-sum-query-immutable/README.md b/problems/range-sum-query-immutable/README.md index 6e3a0fcf7..cbc0d592c 100644 --- a/problems/range-sum-query-immutable/README.md +++ b/problems/range-sum-query-immutable/README.md @@ -11,27 +11,40 @@ ## [303. Range Sum Query - Immutable (Easy)](https://leetcode.com/problems/range-sum-query-immutable "区域和检索 - 数组不可变") -

    Given an integer array nums, find the sum of the elements between indices i and j (ij), inclusive.

    +

    Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.

    -

    Example:

    +

    Implement the NumArray class:

    -
    -Given nums = [-2, 0, 3, -5, 2, -1]
    +
      +
    • NumArray(int[] nums) Initializes the object with the integer array nums.
    • +
    • int sumRange(int i, int j) Return the sum of the elements of the nums array in the range [i, j] inclusive (i.e., sum(nums[i], nums[i + 1], ... , nums[j]))
    • +
    -sumRange(0, 2) -> 1 -sumRange(2, 5) -> -1 -sumRange(0, 5) -> -3 +

     

    +

    Example 1:

    + +
    +Input
    +["NumArray", "sumRange", "sumRange", "sumRange"]
    +[[[-2, 0, 3, -5, 2, -1]], [0, 2], [2, 5], [0, 5]]
    +Output
    +[null, 1, -1, -3]
    +
    +Explanation
    +NumArray numArray = new NumArray([-2, 0, 3, -5, 2, -1]);
    +numArray.sumRange(0, 2); // return 1 ((-2) + 0 + 3)
    +numArray.sumRange(2, 5); // return -1 (3 + (-5) + 2 + (-1)) 
    +numArray.sumRange(0, 5); // return -3 ((-2) + 0 + 3 + (-5) + 2 + (-1))
     

     

    Constraints:

      -
    • You may assume that the array does not change.
    • -
    • There are many calls to sumRange function.
    • -
    • 0 <= nums.length <= 10^4
    • -
    • -10^5 <= nums[i] <= 10^5
    • +
    • 0 <= nums.length <= 104
    • +
    • -105 <= nums[i] <= 105
    • 0 <= i <= j < nums.length
    • +
    • At most 104 calls will be made to sumRange.
    ### Related Topics diff --git a/problems/remove-duplicates-from-sorted-array/README.md b/problems/remove-duplicates-from-sorted-array/README.md index 388c3048d..f16708618 100644 --- a/problems/remove-duplicates-from-sorted-array/README.md +++ b/problems/remove-duplicates-from-sorted-array/README.md @@ -15,25 +15,6 @@

    Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.

    -

    Example 1:

    - -
    -Given nums = [1,1,2],
    -
    -Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively.
    -
    -It doesn't matter what you leave beyond the returned length.
    - -

    Example 2:

    - -
    -Given nums = [0,0,1,1,1,2,2,3,3,4],
    -
    -Your function should return length = 5, with the first five elements of nums being modified to 0, 1, 2, 3, and 4 respectively.
    -
    -It doesn't matter what values are set beyond the returned length.
    -
    -

    Clarification:

    Confused why the returned value is an integer but your answer is an array?

    @@ -52,6 +33,32 @@ for (int i = 0; i < len; i++) {     print(nums[i]); }
    +

     

    +

    Example 1:

    + +
    +Input: nums = [1,1,2]
    +Output: 2, nums = [1,2]
    +Explanation: Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively. It doesn't matter what you leave beyond the returned length.
    +
    + +

    Example 2:

    + +
    +Input: nums = [0,0,1,1,1,2,2,3,3,4]
    +Output: 5, nums = [0,1,2,3,4]
    +Explanation: Your function should return length = 5, with the first five elements of nums being modified to 0, 1, 2, 3, and 4 respectively. It doesn't matter what values are set beyond the returned length.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= nums.length <= 3 * 104
    • +
    • -104 <= nums[i] <= 104
    • +
    • nums is sorted in ascending order.
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/remove-element/README.md b/problems/remove-element/README.md index 3efd8e8fc..06c8726eb 100644 --- a/problems/remove-element/README.md +++ b/problems/remove-element/README.md @@ -17,32 +17,11 @@

    The order of elements can be changed. It doesn't matter what you leave beyond the new length.

    -

    Example 1:

    - -
    -Given nums = [3,2,2,3], val = 3,
    -
    -Your function should return length = 2, with the first two elements of nums being 2.
    -
    -It doesn't matter what you leave beyond the returned length.
    -
    - -

    Example 2:

    - -
    -Given nums = [0,1,2,2,3,0,4,2], val = 2,
    -
    -Your function should return length = 5, with the first five elements of nums containing 0, 1, 3, 0, and 4.
    -
    -Note that the order of those five elements can be arbitrary.
    -
    -It doesn't matter what values are set beyond the returned length.
    -

    Clarification:

    Confused why the returned value is an integer but your answer is an array?

    -

    Note that the input array is passed in by reference, which means modification to the input array will be known to the caller as well.

    +

    Note that the input array is passed in by reference, which means a modification to the input array will be known to the caller as well.

    Internally you can think of this:

    @@ -56,6 +35,33 @@ for (int i = 0; i < len; i++) {     print(nums[i]); } +

     

    +

    Example 1:

    + +
    +Input: nums = [3,2,2,3], val = 3
    +Output: 2, nums = [2,2]
    +Explanation: Your function should return length = 2, with the first two elements of nums being 2.
    +It doesn't matter what you leave beyond the returned length. For example if you return 2 with nums = [2,2,3,3] or nums = [2,3,0,0], your answer will be accepted.
    +
    + +

    Example 2:

    + +
    +Input: nums = [0,1,2,2,3,0,4,2], val = 2
    +Output: 5, nums = [0,1,4,0,3]
    +Explanation: Your function should return length = 5, with the first five elements of nums containing 0, 1, 3, 0, and 4. Note that the order of those five elements can be arbitrary. It doesn't matter what values are set beyond the returned length.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= nums.length <= 100
    • +
    • 0 <= nums[i] <= 50
    • +
    • 0 <= val <= 100
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/repeated-dna-sequences/README.md b/problems/repeated-dna-sequences/README.md index 596247e54..0740c11c5 100644 --- a/problems/repeated-dna-sequences/README.md +++ b/problems/repeated-dna-sequences/README.md @@ -11,17 +11,25 @@ ## [187. Repeated DNA Sequences (Medium)](https://leetcode.com/problems/repeated-dna-sequences "重复的DNA序列") -

    All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.

    +

    All DNA is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T', for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.

    Write a function to find all the 10-letter-long sequences (substrings) that occur more than once in a DNA molecule.

    -

    Example:

    - -
    -Input: s = "AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT"
    -
    -Output: ["AAAAACCCCC", "CCCCCAAAAA"]
    +

     

    +

    Example 1:

    +
    Input: s = "AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT"
    +Output: ["AAAAACCCCC","CCCCCAAAAA"]
    +

    Example 2:

    +
    Input: s = "AAAAAAAAAAAAA"
    +Output: ["AAAAAAAAAA"]
     
    +

     

    +

    Constraints:

    + +
      +
    • 0 <= s.length <= 105
    • +
    • s[i] is 'A', 'C', 'G', or 'T'.
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/second-minimum-node-in-a-binary-tree/README.md b/problems/second-minimum-node-in-a-binary-tree/README.md index 0affbf89b..db820fa4f 100644 --- a/problems/second-minimum-node-in-a-binary-tree/README.md +++ b/problems/second-minimum-node-in-a-binary-tree/README.md @@ -17,35 +17,33 @@

    If no such second minimum value exists, output -1 instead.

    -

    Example 1:

    +

     

    +

     

    +

    Example 1:

    +
    -Input: 
    -    2
    -   / \
    -  2   5
    -     / \
    -    5   7
    -
    -Output: 5
    -Explanation: The smallest value is 2, the second smallest value is 5.
    +Input: root = [2,2,5,null,null,5,7]
    +Output: 5
    +Explanation: The smallest value is 2, the second smallest value is 5.
     
    -

     

    - -

    Example 2:

    - +

    Example 2:

    +
    -Input: 
    -    2
    -   / \
    -  2   2
    -
    -Output: -1
    -Explanation: The smallest value is 2, but there isn't any second smallest value.
    +Input: root = [2,2,2]
    +Output: -1
    +Explanation: The smallest value is 2, but there isn't any second smallest value.
     

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [1, 25].
    • +
    • 1 <= Node.val <= 231 - 1
    • +
    • root.val == min(root.left.val, root.right.val) for each internal node of the tree.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/sellers-with-no-sales/README.md b/problems/sellers-with-no-sales/README.md index 725bce583..474ea37d3 100644 --- a/problems/sellers-with-no-sales/README.md +++ b/problems/sellers-with-no-sales/README.md @@ -9,6 +9,6 @@                  [Next >](../special-array-with-x-elements-greater-than-or-equal-x "Special Array With X Elements Greater Than or Equal X") -## [1607. Sellers With No Sales (Easy)](https://leetcode.com/problems/sellers-with-no-sales "") +## [1607. Sellers With No Sales (Easy)](https://leetcode.com/problems/sellers-with-no-sales "没有卖出的卖家") diff --git a/problems/shortest-palindrome/README.md b/problems/shortest-palindrome/README.md index fc6cd92fc..e67ed5a3e 100644 --- a/problems/shortest-palindrome/README.md +++ b/problems/shortest-palindrome/README.md @@ -11,20 +11,23 @@ ## [214. Shortest Palindrome (Hard)](https://leetcode.com/problems/shortest-palindrome "最短回文串") -

    Given a string s, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation.

    +

    Given a string s, you can convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation.

    +

     

    Example 1:

    - -
    -Input: "aacecaaa"
    -Output: "aaacecaaa"
    +
    Input: s = "aacecaaa"
    +Output: "aaacecaaa"
    +

    Example 2:

    +
    Input: s = "abcd"
    +Output: "dcbabcd"
     
    +

     

    +

    Constraints:

    -

    Example 2:

    - -
    -Input: "abcd"
    -Output: "dcbabcd"
    +
      +
    • 0 <= s.length <= 5 * 104
    • +
    • s consists of lowercase English letters only.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md index 684f083a9..3f22c05f7 100644 --- a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md +++ b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md @@ -19,6 +19,8 @@

    The subtree of a node is tree consisting of that node, plus the set of all descendants of that node.

    +

    Note: This question is the same as 1123: https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/

    +

     

    Example 1:

    @@ -51,6 +53,7 @@ Notice that nodes 5, 3 and 2 contain the deepest nodes in the tree but node 2 is
    • The number of nodes in the tree will be in the range [1, 500].
    • +
    • 0 <= Node.val <= 500
    • The values of the nodes in the tree are unique.
    diff --git a/problems/split-two-strings-to-make-palindrome/README.md b/problems/split-two-strings-to-make-palindrome/README.md new file mode 100644 index 000000000..1e357df0c --- /dev/null +++ b/problems/split-two-strings-to-make-palindrome/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../maximal-network-rank "Maximal Network Rank") +                 +[Next >](../count-subtrees-with-max-distance-between-cities "Count Subtrees With Max Distance Between Cities") + +## [1616. Split Two Strings to Make Palindrome (Medium)](https://leetcode.com/problems/split-two-strings-to-make-palindrome "分割两个字符串得到回文串") + +

    You are given two strings a and b of the same length. Choose an index and split both strings at the same index, splitting a into two strings: aprefix and asuffix where a = aprefix + asuffix, and splitting b into two strings: bprefix and bsuffix where b = bprefix + bsuffix. Check if aprefix + bsuffix or bprefix + asuffix forms a palindrome.

    + +

    When you split a string s into sprefix and ssuffix, either ssuffix or sprefix is allowed to be empty. For example, if s = "abc", then "" + "abc", "a" + "bc", "ab" + "c" , and "abc" + "" are valid splits.

    + +

    Return true if it is possible to form a palindrome string, otherwise return false.

    + +

    Notice that x + y denotes the concatenation of strings x and y.

    + +

     

    +

    Example 1:

    + +
    +Input: a = "x", b = "y"
    +Output: true
    +Explaination: If either a or b are palindromes the answer is true since you can split in the following way:
    +aprefix = "", asuffix = "x"
    +bprefix = "", bsuffix = "y"
    +Then, aprefix + bsuffix = "" + "y" = "y", which is a palindrome.
    +
    + +

    Example 2:

    + +
    +Input: a = "abdef", b = "fecab"
    +Output: true
    +
    + +

    Example 3:

    + +
    +Input: a = "ulacfd", b = "jizalu"
    +Output: true
    +Explaination: Split them at index 3:
    +aprefix = "ula", asuffix = "cfd"
    +bprefix = "jiz", bsuffix = "alu"
    +Then, aprefix + bsuffix = "ula" + "alu" = "ulaalu", which is a palindrome.
    +
    + +

    Example 4:

    + +
    +Input: a = "xbdef", b = "xecab"
    +Output: false
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= a.length, b.length <= 105
    • +
    • a.length == b.length
    • +
    • a and b consist of lowercase English letters
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Try finding the largest prefix form a that matches a suffix in b +
    + +
    +Hint 2 +Try string matching +
    diff --git a/problems/the-most-frequently-ordered-products-for-each-customer/README.md b/problems/the-most-frequently-ordered-products-for-each-customer/README.md index 8523d7954..7098dc503 100644 --- a/problems/the-most-frequently-ordered-products-for-each-customer/README.md +++ b/problems/the-most-frequently-ordered-products-for-each-customer/README.md @@ -9,6 +9,6 @@                  [Next >](../build-binary-expression-tree-from-infix-expression "Build Binary Expression Tree From Infix Expression") -## [1596. The Most Frequently Ordered Products for Each Customer (Medium)](https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer "") +## [1596. The Most Frequently Ordered Products for Each Customer (Medium)](https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer "每位顾客最经常订购的商品") diff --git a/problems/trapping-rain-water/README.md b/problems/trapping-rain-water/README.md index b84d3a3d9..0a32aec41 100644 --- a/problems/trapping-rain-water/README.md +++ b/problems/trapping-rain-water/README.md @@ -11,16 +11,32 @@ ## [42. Trapping Rain Water (Hard)](https://leetcode.com/problems/trapping-rain-water "接雨水") -

    Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.

    +

    Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.

    -


    -The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped. Thanks Marcos for contributing this image!

    +

     

    +

    Example 1:

    + +
    +Input: height = [0,1,0,2,1,0,1,3,2,1,2,1]
    +Output: 6
    +Explanation: The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped.
    +
    -

    Example:

    +

    Example 2:

    -Input: [0,1,0,2,1,0,1,3,2,1,2,1]
    -Output: 6
    +Input: height = [4,2,0,3,2,5] +Output: 9 +
    + +

     

    +

    Constraints:

    + +
      +
    • n == height.length
    • +
    • 0 <= n <= 3 * 104
    • +
    • 0 <= height[i] <= 105
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/wildcard-matching/README.md b/problems/wildcard-matching/README.md index c4054c560..a6bc7923c 100644 --- a/problems/wildcard-matching/README.md +++ b/problems/wildcard-matching/README.md @@ -11,28 +11,20 @@ ## [44. Wildcard Matching (Hard)](https://leetcode.com/problems/wildcard-matching "通配符匹配") -

    Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'.

    - -
    -'?' Matches any single character.
    -'*' Matches any sequence of characters (including the empty sequence).
    -
    - -

    The matching should cover the entire input string (not partial).

    - -

    Note:

    +

    Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*' where:

      -
    • s could be empty and contains only lowercase letters a-z.
    • -
    • p could be empty and contains only lowercase letters a-z, and characters like ? or *.
    • +
    • '?' Matches any single character.
    • +
    • '*' Matches any sequence of characters (including the empty sequence).
    +

    The matching should cover the entire input string (not partial).

    + +

     

    Example 1:

    -Input:
    -s = "aa"
    -p = "a"
    +Input: s = "aa", p = "a"
     Output: false
     Explanation: "a" does not match the entire string "aa".
     
    @@ -40,9 +32,7 @@ p = "a"

    Example 2:

    -Input:
    -s = "aa"
    -p = "*"
    +Input: s = "aa", p = "*"
     Output: true
     Explanation: '*' matches any sequence.
     
    @@ -50,9 +40,7 @@ p = "*"

    Example 3:

    -Input:
    -s = "cb"
    -p = "?a"
    +Input: s = "cb", p = "?a"
     Output: false
     Explanation: '?' matches 'c', but the second letter is 'a', which does not match 'b'.
     
    @@ -60,9 +48,7 @@ p = "?a"

    Example 4:

    -Input:
    -s = "adceb"
    -p = "*a*b"
    +Input: s = "adceb", p = "*a*b"
     Output: true
     Explanation: The first '*' matches the empty sequence, while the second '*' matches the substring "dce".
     
    @@ -70,12 +56,19 @@ p = "*a*b"

    Example 5:

    -Input:
    -s = "acdcb"
    -p = "a*c?b"
    +Input: s = "acdcb", p = "a*c?b"
     Output: false
     
    +

     

    +

    Constraints:

    + +
      +
    • 0 <= s.length, p.length <= 2000
    • +
    • s contains only lowercase English letters.
    • +
    • p contains only lowercase English letters, '?' or '*'.
    • +
    + ### Related Topics [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/word-search/README.md b/problems/word-search/README.md index be3a29f22..583d51427 100644 --- a/problems/word-search/README.md +++ b/problems/word-search/README.md @@ -13,21 +13,28 @@

    Given a 2D board and a word, find if the word exists in the grid.

    -

    The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once.

    +

    The word can be constructed from letters of sequentially adjacent cells, where "adjacent" cells are horizontally or vertically neighboring. The same letter cell may not be used more than once.

    -

    Example:

    +

     

    +

    Example 1:

    + +
    +Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCCED"
    +Output: true
    +
    + +

    Example 2:

    + +
    +Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "SEE"
    +Output: true
    +
    +

    Example 3:

    +
    -board =
    -[
    -  ['A','B','C','E'],
    -  ['S','F','C','S'],
    -  ['A','D','E','E']
    -]
    -
    -Given word = "ABCCED", return true.
    -Given word = "SEE", return true.
    -Given word = "ABCB", return false.
    +Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCB"
    +Output: false
     

     

    diff --git a/readme/1-300.md b/readme/1-300.md index 307cbb528..fa30b03fa 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -337,7 +337,7 @@ LeetCode Problems' Solutions | 265 | [Paint House II](https://leetcode.com/problems/paint-house-ii "粉刷房子 II") 🔒 | [Go](../problems/paint-house-ii) | Hard | | 266 | [Palindrome Permutation](https://leetcode.com/problems/palindrome-permutation "回文排列") 🔒 | [Go](../problems/palindrome-permutation) | Easy | | 267 | [Palindrome Permutation II](https://leetcode.com/problems/palindrome-permutation-ii "回文排列 II") 🔒 | [Go](../problems/palindrome-permutation-ii) | Medium | -| 268 | [Missing Number](https://leetcode.com/problems/missing-number "缺失数字") | [Go](../problems/missing-number) | Easy | +| 268 | [Missing Number](https://leetcode.com/problems/missing-number "丢失的数字") | [Go](../problems/missing-number) | Easy | | 269 | [Alien Dictionary](https://leetcode.com/problems/alien-dictionary "火星词典") 🔒 | [Go](../problems/alien-dictionary) | Hard | | 270 | [Closest Binary Search Tree Value](https://leetcode.com/problems/closest-binary-search-tree-value "最接近的二叉搜索树值") 🔒 | [Go](../problems/closest-binary-search-tree-value) | Easy | | 271 | [Encode and Decode Strings](https://leetcode.com/problems/encode-and-decode-strings "字符串的编码与解码") 🔒 | [Go](../problems/encode-and-decode-strings) | Medium | diff --git a/readme/601-900.md b/readme/601-900.md index efda6311a..3d55aaeec 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -152,11 +152,11 @@ LeetCode Problems' Solutions | 680 | [Valid Palindrome II](https://leetcode.com/problems/valid-palindrome-ii "验证回文字符串 Ⅱ") | [Go](../problems/valid-palindrome-ii) | Easy | | 681 | [Next Closest Time](https://leetcode.com/problems/next-closest-time "最近时刻") 🔒 | [Go](../problems/next-closest-time) | Medium | | 682 | [Baseball Game](https://leetcode.com/problems/baseball-game "棒球比赛") | [Go](../problems/baseball-game) | Easy | -| 683 | [K Empty Slots](https://leetcode.com/problems/k-empty-slots "K 个空花盆") 🔒 | [Go](../problems/k-empty-slots) | Hard | +| 683 | [K Empty Slots](https://leetcode.com/problems/k-empty-slots "K 个关闭的灯泡") 🔒 | [Go](../problems/k-empty-slots) | Hard | | 684 | [Redundant Connection](https://leetcode.com/problems/redundant-connection "冗余连接") | [Go](../problems/redundant-connection) | Medium | | 685 | [Redundant Connection II](https://leetcode.com/problems/redundant-connection-ii "冗余连接 II") | [Go](../problems/redundant-connection-ii) | Hard | | 686 | [Repeated String Match](https://leetcode.com/problems/repeated-string-match "重复叠加字符串匹配") | [Go](../problems/repeated-string-match) | Medium | -| 687 | [Longest Univalue Path](https://leetcode.com/problems/longest-univalue-path "最长同值路径") | [Go](../problems/longest-univalue-path) | Easy | +| 687 | [Longest Univalue Path](https://leetcode.com/problems/longest-univalue-path "最长同值路径") | [Go](../problems/longest-univalue-path) | Medium | | 688 | [Knight Probability in Chessboard](https://leetcode.com/problems/knight-probability-in-chessboard "“马”在棋盘上的概率") | [Go](../problems/knight-probability-in-chessboard) | Medium | | 689 | [Maximum Sum of 3 Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays "三个无重叠子数组的最大和") | [Go](../problems/maximum-sum-of-3-non-overlapping-subarrays) | Hard | | 690 | [Employee Importance](https://leetcode.com/problems/employee-importance "员工的重要性") | [Go](../problems/employee-importance) | Easy | diff --git a/readme/901-1200.md b/readme/901-1200.md index 0d155999f..c7b5c1b1a 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -256,7 +256,7 @@ LeetCode Problems' Solutions | 1084 | [Sales Analysis III](https://leetcode.com/problems/sales-analysis-iii "销售分析III") 🔒 | [MySQL](../problems/sales-analysis-iii) | Easy | | 1085 | [Sum of Digits in the Minimum Number](https://leetcode.com/problems/sum-of-digits-in-the-minimum-number "最小元素各数位之和") 🔒 | [Go](../problems/sum-of-digits-in-the-minimum-number) | Easy | | 1086 | [High Five](https://leetcode.com/problems/high-five "前五科的均分") 🔒 | [Go](../problems/high-five) | Easy | -| 1087 | [Brace Expansion](https://leetcode.com/problems/brace-expansion "字母切换") 🔒 | [Go](../problems/brace-expansion) | Medium | +| 1087 | [Brace Expansion](https://leetcode.com/problems/brace-expansion "花括号展开") 🔒 | [Go](../problems/brace-expansion) | Medium | | 1088 | [Confusing Number II](https://leetcode.com/problems/confusing-number-ii "易混淆数 II") 🔒 | [Go](../problems/confusing-number-ii) | Hard | | 1089 | [Duplicate Zeros](https://leetcode.com/problems/duplicate-zeros "复写零") | [Go](../problems/duplicate-zeros) | Easy | | 1090 | [Largest Values From Labels](https://leetcode.com/problems/largest-values-from-labels "受标签影响的最大值") | [Go](../problems/largest-values-from-labels) | Medium | diff --git a/tag/array/README.md b/tag/array/README.md index 166b6b78f..36892774c 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1619 | [删除某些元素后的数组均值](../../problems/mean-of-array-after-removing-some-elements) | [[数组](../array/README.md)] | Easy | | 1608 | [特殊数组的特征值](../../problems/special-array-with-x-elements-greater-than-or-equal-x) | [[数组](../array/README.md)] | Easy | | 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1588 | [所有奇数长度子数组的和](../../problems/sum-of-all-odd-length-subarrays) | [[数组](../array/README.md)] | Easy | @@ -228,7 +229,7 @@ | 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 277 | [搜寻名人](../../problems/find-the-celebrity) 🔒 | [[数组](../array/README.md)] | Medium | -| 268 | [缺失数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 268 | [丢失的数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 245 | [最短单词距离 III](../../problems/shortest-word-distance-iii) 🔒 | [[数组](../array/README.md)] | Medium | | 243 | [最短单词距离](../../problems/shortest-word-distance) 🔒 | [[数组](../array/README.md)] | Easy | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 78a43cc0c..5f4c80f64 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[回溯算法](../backtracking/README.md)] | Hard | | 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[回溯算法](../backtracking/README.md)] | Medium | | 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1415 | [长度为 n 的开心字符串中字典序第 k 小的字符串](../../problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | [[回溯算法](../backtracking/README.md)] | Medium | @@ -21,7 +22,7 @@ | 1219 | [黄金矿工](../../problems/path-with-maximum-gold) | [[回溯算法](../backtracking/README.md)] | Medium | | 1215 | [步进数](../../problems/stepping-numbers) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | | 1088 | [易混淆数 II](../../problems/confusing-number-ii) 🔒 | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1087 | [字母切换](../../problems/brace-expansion) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | +| 1087 | [花括号展开](../../problems/brace-expansion) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | | 1079 | [活字印刷](../../problems/letter-tile-possibilities) | [[回溯算法](../backtracking/README.md)] | Medium | | 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 0332fc2d6..49cde1f81 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1562 | [查找大小为 M 的最新分组](../../problems/find-latest-group-of-size-m) | [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 69cb8033d..093b46288 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -52,7 +52,7 @@ | 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 318 | [最大单词长度乘积](../../problems/maximum-product-of-word-lengths) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 268 | [缺失数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 268 | [丢失的数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 260 | [只出现一次的数字 III](../../problems/single-number-iii) | [[位运算](../bit-manipulation/README.md)] | Medium | | 231 | [2的幂](../../problems/power-of-two) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | | 201 | [数字范围按位与](../../problems/bitwise-and-of-numbers-range) | [[位运算](../bit-manipulation/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index da70c43f1..42fc7554a 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,7 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1602 | [Find Nearest Right Node in Binary Tree](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 5544 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index a773527fa..614a32710 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 5544 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | | 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index cdb6a9ed0..ad8f943f3 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard | | 1603 | [设计停车系统](../../problems/design-parking-system) | [[设计](../design/README.md)] | Easy | | 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 11950fd71..a8d19060a 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 5545 | [无矛盾的最佳球队](../../problems/best-team-with-no-conflicts) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index 2f11459c2..d1c05ec24 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1615 | [最大网络秩](../../problems/maximal-network-rank) | [[图](../graph/README.md)] | Medium | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1557 | [可以到达所有点的最少点数目](../../problems/minimum-number-of-vertices-to-reach-all-nodes) | [[图](../graph/README.md)] | Medium | | 1548 | [图中最相似的路径](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 82dd16476..5c48b289b 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1620 | [网络信号最好的坐标](../../problems/coordinate-with-maximum-network-quality) | [[贪心算法](../greedy/README.md)] | Medium | +| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1605 | [给定行和列的和求可行矩阵](../../problems/find-valid-matrix-given-row-and-column-sums) | [[贪心算法](../greedy/README.md)] | Medium | | 1599 | [经营摩天轮的最大利润](../../problems/maximum-profit-of-operating-a-centennial-wheel) | [[贪心算法](../greedy/README.md)] | Medium | | 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 7ec933dce..374707328 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1612 | [Check If Two Expression Trees are Equivalent](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/math/README.md b/tag/math/README.md index 3d932773d..bab6c2f38 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 5128 | [带阈值的图连通性](../../problems/graph-connectivity-with-threshold) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | +| 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard | | 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 1551 | [使数组中所有元素相等的最小操作数](../../problems/minimum-operations-to-make-array-equal) | [[数学](../math/README.md)] | Medium | | 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | @@ -164,7 +166,7 @@ | 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | | 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 268 | [缺失数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 268 | [丢失的数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 263 | [丑数](../../problems/ugly-number) | [[数学](../math/README.md)] | Easy | | 258 | [各位相加](../../problems/add-digits) | [[数学](../math/README.md)] | Easy | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index dd46bf0d8..34c50be84 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -18,6 +18,6 @@ | 731 | [我的日程安排表 II](../../problems/my-calendar-ii) | [[Ordered Map](../ordered-map/README.md)] | Medium | | 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | | 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 683 | [K 个空花盆](../../problems/k-empty-slots) 🔒 | [[Ordered Map](../ordered-map/README.md)] | Hard | +| 683 | [K 个关闭的灯泡](../../problems/k-empty-slots) 🔒 | [[Ordered Map](../ordered-map/README.md)] | Hard | | 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | | 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 542c1e35b..1354ec088 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1621 | [大小为 K 的不重叠线段的数目](../../problems/number-of-sets-of-k-non-overlapping-line-segments) | [[递归](../recursion/README.md)] | Medium | | 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[递归](../recursion/README.md)] | Easy | | 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | | 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | @@ -19,7 +20,7 @@ | 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | | 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | +| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | | 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/string/README.md b/tag/string/README.md index 4b7ef98c5..60985d0ca 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,8 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 5543 | [两个相同字符之间的最长子字符串](../../problems/largest-substring-between-two-equal-characters) | [[字符串](../string/README.md)] | Easy | +| 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1614 | [括号的最大嵌套深度](../../problems/maximum-nesting-depth-of-the-parentheses) | [[字符串](../string/README.md)] | Easy | | 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | -| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Hard | +| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Hard | | 1592 | [重新排列单词间的空格](../../problems/rearrange-spaces-between-words) | [[字符串](../string/README.md)] | Easy | | 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | | 1576 | [替换所有的问号](../../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | [[字符串](../string/README.md)] | Easy | diff --git a/tag/tree/README.md b/tag/tree/README.md index f6bc18e5b..ddcf67217 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,11 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1612 | [Check If Two Expression Trees are Equivalent](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1609 | [奇偶树](../../problems/even-odd-tree) | [[树](../tree/README.md)] | Medium | -| 1602 | [Find Nearest Right Node in Binary Tree](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Hard | +| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Hard | | 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1516 | [移动 N 叉树的子树](../../problems/move-sub-tree-of-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard | @@ -72,7 +72,7 @@ | 742 | [二叉树最近的叶节点](../../problems/closest-leaf-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | | 701 | [二叉搜索树中的插入操作](../../problems/insert-into-a-binary-search-tree) | [[树](../tree/README.md)] | Medium | | 700 | [二叉搜索树中的搜索](../../problems/search-in-a-binary-search-tree) | [[树](../tree/README.md)] | Easy | -| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | +| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 684 | [冗余连接](../../problems/redundant-connection) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 671 | [二叉树中第二小的节点](../../problems/second-minimum-node-in-a-binary-tree) | [[树](../tree/README.md)] | Easy | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 0df99c8eb..29b86a381 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard | | 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1248 | [统计「优美子数组」](../../problems/count-number-of-nice-subarrays) | [[双指针](../two-pointers/README.md)] | Medium | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index f3b58a749..78fa1d2be 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 5128 | [带阈值的图连通性](../../problems/graph-connectivity-with-threshold) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | | 1584 | [连接所有点的最小费用](../../problems/min-cost-to-connect-all-points) | [[并查集](../union-find/README.md)] | Medium | | 1579 | [保证图可完全遍历](../../problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | [[并查集](../union-find/README.md)] | Hard | | 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | From 14db544572ad0e81c0537853f2b5a3550a819fa3 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 26 Oct 2020 17:44:05 +0800 Subject: [PATCH 106/145] A: new --- README.md | 8 +- .../README.md | 14 +++ .../mysql_schemas.sql | 12 ++ problems/bag-of-tokens/README.md | 54 +++++---- .../best-team-with-no-conflicts/README.md | 67 ++++++++++++ .../README.md | 2 +- .../README.md | 39 +++++++ problems/escape-a-large-maze/README.md | 24 ++-- problems/fancy-sequence/README.md | 2 +- problems/find-and-replace-in-string/README.md | 35 +++--- .../README.md | 94 ++++++++++++++++ problems/is-graph-bipartite/README.md | 46 ++++---- .../kth-largest-element-in-a-stream/README.md | 3 +- .../README.md | 70 ++++++++++++ .../README.md | 103 ++++++++++++++++++ problems/make-sum-divisible-by-p/README.md | 2 + problems/map-sum-pairs/README.md | 45 +++++--- .../README.md | 3 +- .../README.md | 36 +++--- .../README.md | 2 +- .../README.md | 2 +- problems/swap-salary/README.md | 2 +- readme/1-300.md | 2 +- readme/301-600.md | 2 +- readme/601-900.md | 6 +- tag/array/README.md | 3 +- tag/binary-search/README.md | 5 +- tag/breadth-first-search/README.md | 2 +- tag/depth-first-search/README.md | 3 +- tag/design/README.md | 5 +- tag/dynamic-programming/README.md | 3 +- tag/graph/README.md | 1 + tag/greedy/README.md | 1 + tag/hash-table/README.md | 1 + tag/heap/README.md | 2 +- tag/math/README.md | 3 +- tag/recursion/README.md | 1 - tag/sort/README.md | 1 + tag/string/README.md | 4 +- tag/tree/README.md | 3 +- tag/union-find/README.md | 4 +- 41 files changed, 576 insertions(+), 141 deletions(-) create mode 100644 problems/all-valid-triplets-that-can-represent-a-country/README.md create mode 100644 problems/all-valid-triplets-that-can-represent-a-country/mysql_schemas.sql create mode 100644 problems/best-team-with-no-conflicts/README.md create mode 100644 problems/design-an-expression-tree-with-evaluate-function/README.md create mode 100644 problems/graph-connectivity-with-threshold/README.md create mode 100644 problems/largest-substring-between-two-equal-characters/README.md create mode 100644 problems/lexicographically-smallest-string-after-applying-operations/README.md diff --git a/README.md b/README.md index 45d1a7c7c..40ab88502 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,12 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1628 | [Design an Expression Tree With Evaluate Function](https://leetcode.com/problems/design-an-expression-tree-with-evaluate-function) 🔒 | [Go](problems/design-an-expression-tree-with-evaluate-function) | Medium | +| 1627 | [Graph Connectivity With Threshold](https://leetcode.com/problems/graph-connectivity-with-threshold "带阈值的图连通性") | [Go](problems/graph-connectivity-with-threshold) | Hard | +| 1626 | [Best Team With No Conflicts](https://leetcode.com/problems/best-team-with-no-conflicts "无矛盾的最佳球队") | [Go](problems/best-team-with-no-conflicts) | Medium | +| 1625 | [Lexicographically Smallest String After Applying Operations](https://leetcode.com/problems/lexicographically-smallest-string-after-applying-operations "执行操作后字典序最小的字符串") | [Go](problems/lexicographically-smallest-string-after-applying-operations) | Medium | +| 1624 | [Largest Substring Between Two Equal Characters](https://leetcode.com/problems/largest-substring-between-two-equal-characters "两个相同字符之间的最长子字符串") | [Go](problems/largest-substring-between-two-equal-characters) | Easy | +| 1623 | [All Valid Triplets That Can Represent a Country](https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country) 🔒 | [MySQL](problems/all-valid-triplets-that-can-represent-a-country) | Easy | | 1622 | [Fancy Sequence](https://leetcode.com/problems/fancy-sequence "奇妙序列") | [Go](problems/fancy-sequence) | Hard | | 1621 | [Number of Sets of K Non-Overlapping Line Segments](https://leetcode.com/problems/number-of-sets-of-k-non-overlapping-line-segments "大小为 K 的不重叠线段的数目") | [Go](problems/number-of-sets-of-k-non-overlapping-line-segments) | Medium | | 1620 | [Coordinate With Maximum Network Quality](https://leetcode.com/problems/coordinate-with-maximum-network-quality "网络信号最好的坐标") | [Go](problems/coordinate-with-maximum-network-quality) | Medium | @@ -111,7 +117,7 @@ LeetCode Problems' Solutions | 1584 | [Min Cost to Connect All Points](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") | [Go](problems/min-cost-to-connect-all-points) | Medium | | 1583 | [Count Unhappy Friends](https://leetcode.com/problems/count-unhappy-friends "统计不开心的朋友") | [Go](problems/count-unhappy-friends) | Medium | | 1582 | [Special Positions in a Binary Matrix](https://leetcode.com/problems/special-positions-in-a-binary-matrix "二进制矩阵中的特殊位置") | [Go](problems/special-positions-in-a-binary-matrix) | Easy | -| 1581 | [Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的客户") 🔒 | [MySQL](problems/customer-who-visited-but-did-not-make-any-transactions) | Easy | +| 1581 | [Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的顾客") 🔒 | [MySQL](problems/customer-who-visited-but-did-not-make-any-transactions) | Easy | | 1580 | [Put Boxes Into the Warehouse II](https://leetcode.com/problems/put-boxes-into-the-warehouse-ii) 🔒 | [Go](problems/put-boxes-into-the-warehouse-ii) | Medium | | 1579 | [Remove Max Number of Edges to Keep Graph Fully Traversable](https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable "保证图可完全遍历") | [Go](problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | Hard | | 1578 | [Minimum Deletion Cost to Avoid Repeating Letters](https://leetcode.com/problems/minimum-deletion-cost-to-avoid-repeating-letters "避免重复字母的最小删除成本") | [Go](problems/minimum-deletion-cost-to-avoid-repeating-letters) | Medium | diff --git a/problems/all-valid-triplets-that-can-represent-a-country/README.md b/problems/all-valid-triplets-that-can-represent-a-country/README.md new file mode 100644 index 000000000..d786653e8 --- /dev/null +++ b/problems/all-valid-triplets-that-can-represent-a-country/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../fancy-sequence "Fancy Sequence") +                 +[Next >](../largest-substring-between-two-equal-characters "Largest Substring Between Two Equal Characters") + +## [1623. All Valid Triplets That Can Represent a Country (Easy)](https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country "") + + diff --git a/problems/all-valid-triplets-that-can-represent-a-country/mysql_schemas.sql b/problems/all-valid-triplets-that-can-represent-a-country/mysql_schemas.sql new file mode 100644 index 000000000..9f28968ca --- /dev/null +++ b/problems/all-valid-triplets-that-can-represent-a-country/mysql_schemas.sql @@ -0,0 +1,12 @@ +Create table If Not Exists SchoolA (student_id int, student_name varchar(20)); +Create table If Not Exists SchoolB (student_id int, student_name varchar(20)); +Create table If Not Exists SchoolC (student_id int, student_name varchar(20)); +Truncate table SchoolA; +insert into SchoolA (student_id, student_name) values ('1', 'Alice'); +insert into SchoolA (student_id, student_name) values ('2', 'Bob'); +Truncate table SchoolB; +insert into SchoolB (student_id, student_name) values ('3', 'Tom'); +Truncate table SchoolC; +insert into SchoolC (student_id, student_name) values ('3', 'Tom'); +insert into SchoolC (student_id, student_name) values ('2', 'Jerry'); +insert into SchoolC (student_id, student_name) values ('10', 'Alice'); diff --git a/problems/bag-of-tokens/README.md b/problems/bag-of-tokens/README.md index d64b7f916..38a239cd5 100644 --- a/problems/bag-of-tokens/README.md +++ b/problems/bag-of-tokens/README.md @@ -11,58 +11,56 @@ ## [948. Bag of Tokens (Medium)](https://leetcode.com/problems/bag-of-tokens "令牌放置") -

    You have an initial power P, an initial score of 0 points, and a bag of tokens.

    +

    You have an initial power of P, an initial score of 0, and a bag of tokens where tokens[i] is the value of the ith token (0-indexed).

    -

    Each token can be used at most once, has a value token[i], and has potentially two ways to use it.

    +

    Your goal is to maximize your total score by potentially playing each token in one of two ways:

      -
    • If we have at least token[i] power, we may play the token face up, losing token[i] power, and gaining 1 point.
    • -
    • If we have at least 1 point, we may play the token face down, gaining token[i] power, and losing 1 point.
    • +
    • If your current power is at least tokens[i], you may play the ith token face up, losing tokens[i] power and gaining 1 score.
    • +
    • If your current score is at least 1, you may play the ith token face down, gaining tokens[i] power and losing 1 score.
    -

    Return the largest number of points we can have after playing any number of tokens.

    +

    Each token may be played at most once and in any order. You do not have to play all the tokens.

    -

     

    - -
      -
    +

    Return the largest possible score you can achieve after playing any number of tokens.

    -
    +

     

    Example 1:

    -Input: tokens = [100], P = 50
    -Output: 0
    +Input: tokens = [100], P = 50
    +Output: 0
    +Explanation: Playing the only token in the bag is impossible because you either have too little power or too little score.
     
    -

    Example 2:

    -Input: tokens = [100,200], P = 150
    -Output: 1
    +Input: tokens = [100,200], P = 150
    +Output: 1
    +Explanation: Play the 0th token (100) face up, your power becomes 50 and score becomes 1.
    +There is no need to play the 1st token since you cannot play it face up to add to your score.
     
    -

    Example 3:

    -Input: tokens = [100,200,300,400], P = 200
    -Output: 2
    +Input: tokens = [100,200,300,400], P = 200
    +Output: 2
    +Explanation: Play the tokens in this order to get a score of 2:
    +1. Play the 0th token (100) face up, your power becomes 100 and score becomes 1.
    +2. Play the 3rd token (400) face down, your power becomes 500 and score becomes 0.
    +3. Play the 1st token (200) face up, your power becomes 300 and score becomes 1.
    +4. Play the 2nd token (300) face up, your power becomes 0 and score becomes 2.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. tokens.length <= 1000
    2. -
    3. 0 <= tokens[i] < 10000
    4. -
    5. 0 <= P < 10000
    6. -
    -
    -
    -
    +
      +
    • 0 <= tokens.length <= 1000
    • +
    • 0 <= tokens[i], P < 104
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/best-team-with-no-conflicts/README.md b/problems/best-team-with-no-conflicts/README.md new file mode 100644 index 000000000..fda2227b6 --- /dev/null +++ b/problems/best-team-with-no-conflicts/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../lexicographically-smallest-string-after-applying-operations "Lexicographically Smallest String After Applying Operations") +                 +[Next >](../graph-connectivity-with-threshold "Graph Connectivity With Threshold") + +## [1626. Best Team With No Conflicts (Medium)](https://leetcode.com/problems/best-team-with-no-conflicts "无矛盾的最佳球队") + +

    You are the manager of a basketball team. For the upcoming tournament, you want to choose the team with the highest overall score. The score of the team is the sum of scores of all the players in the team.

    + +

    However, the basketball team is not allowed to have conflicts. A conflict exists if a younger player has a strictly higher score than an older player. A conflict does not occur between players of the same age.

    + +

    Given two lists, scores and ages, where each scores[i] and ages[i] represents the score and age of the ith player, respectively, return the highest overall score of all possible basketball teams.

    + +

     

    +

    Example 1:

    + +
    +Input: scores = [1,3,5,10,15], ages = [1,2,3,4,5]
    +Output: 34
    +Explanation: You can choose all the players.
    +
    + +

    Example 2:

    + +
    +Input: scores = [4,5,6,5], ages = [2,1,2,1]
    +Output: 16
    +Explanation: It is best to choose the last 3 players. Notice that you are allowed to choose multiple people of the same age.
    +
    + +

    Example 3:

    + +
    +Input: scores = [1,2,3,5], ages = [8,9,10,1]
    +Output: 6
    +Explanation: It is best to choose the first 3 players. 
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= scores.length, ages.length <= 1000
    • +
    • scores.length == ages.length
    • +
    • 1 <= scores[i] <= 106
    • +
    • 1 <= ages[i] <= 1000
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +First, sort players by age and break ties by their score. You can now consider the players from left to right. +
    + +
    +Hint 2 +If you choose to include a player, you must only choose players with at least that score later on. +
    diff --git a/problems/customer-who-visited-but-did-not-make-any-transactions/README.md b/problems/customer-who-visited-but-did-not-make-any-transactions/README.md index dd3788669..868f8d122 100644 --- a/problems/customer-who-visited-but-did-not-make-any-transactions/README.md +++ b/problems/customer-who-visited-but-did-not-make-any-transactions/README.md @@ -9,6 +9,6 @@                  [Next >](../special-positions-in-a-binary-matrix "Special Positions in a Binary Matrix") -## [1581. Customer Who Visited but Did Not Make Any Transactions (Easy)](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的客户") +## [1581. Customer Who Visited but Did Not Make Any Transactions (Easy)](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的顾客") diff --git a/problems/design-an-expression-tree-with-evaluate-function/README.md b/problems/design-an-expression-tree-with-evaluate-function/README.md new file mode 100644 index 000000000..b255e8571 --- /dev/null +++ b/problems/design-an-expression-tree-with-evaluate-function/README.md @@ -0,0 +1,39 @@ + + + + + + + +[< Previous](../graph-connectivity-with-threshold "Graph Connectivity With Threshold") +                 +Next > + +## [1628. Design an Expression Tree With Evaluate Function (Medium)](https://leetcode.com/problems/design-an-expression-tree-with-evaluate-function "") + + + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Design](../../tag/design/README.md)] + +### Hints +
    +Hint 1 +Apply the concept of Polymorphism to get a good design +
    + +
    +Hint 2 +Implement the Node class using NumericNode and OperatorNode classes. +
    + +
    +Hint 3 +NumericNode only maintains the value, and evaluate returns this value. +
    + +
    +Hint 4 +OperatorNode Maintains the left and right nodes representing the the left and right operands, and the evaluate function applies the operator to them. +
    diff --git a/problems/escape-a-large-maze/README.md b/problems/escape-a-large-maze/README.md index 7348bfdea..0163227ef 100644 --- a/problems/escape-a-large-maze/README.md +++ b/problems/escape-a-large-maze/README.md @@ -11,44 +11,40 @@ ## [1036. Escape a Large Maze (Hard)](https://leetcode.com/problems/escape-a-large-maze "逃离大迷宫") -

    In a 1 million by 1 million grid, the coordinates of each grid square are (x, y) with 0 <= x, y < 10^6.

    +

    In a 1 million by 1 million grid, the coordinates of each grid square are (x, y).

    We start at the source square and want to reach the target square.  Each move, we can walk to a 4-directionally adjacent square in the grid that isn't in the given list of blocked squares.

    Return true if and only if it is possible to reach the target square through a sequence of moves.

     

    -

    Example 1:

    -Input: blocked = [[0,1],[1,0]], source = [0,0], target = [0,2]
    -Output: false
    -Explanation: 
    -The target square is inaccessible starting from the source square, because we can't walk outside the grid.
    +Input: blocked = [[0,1],[1,0]], source = [0,0], target = [0,2]
    +Output: false
    +Explanation: The target square is inaccessible starting from the source square, because we can't walk outside the grid.
     

    Example 2:

    -Input: blocked = [], source = [0,0], target = [999999,999999]
    -Output: true
    -Explanation: 
    -Because there are no blocked cells, it's possible to reach the target square.
    +Input: blocked = [], source = [0,0], target = [999999,999999]
    +Output: true
    +Explanation: Because there are no blocked cells, it's possible to reach the target square.
     

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 0 <= blocked.length <= 200
      • blocked[i].length == 2
      • 0 <= blocked[i][j] < 10^6
      • source.length == target.length == 2
      • 0 <= source[i][j], target[i][j] < 10^6
      • source != target
      • -
    + ### Related Topics [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/fancy-sequence/README.md b/problems/fancy-sequence/README.md index 1a725d9e2..d5bb7af8b 100644 --- a/problems/fancy-sequence/README.md +++ b/problems/fancy-sequence/README.md @@ -7,7 +7,7 @@ [< Previous](../number-of-sets-of-k-non-overlapping-line-segments "Number of Sets of K Non-Overlapping Line Segments")                  -Next > +[Next >](../all-valid-triplets-that-can-represent-a-country "All Valid Triplets That Can Represent a Country") ## [1622. Fancy Sequence (Hard)](https://leetcode.com/problems/fancy-sequence "奇妙序列") diff --git a/problems/find-and-replace-in-string/README.md b/problems/find-and-replace-in-string/README.md index 351f3f38d..d2640535e 100644 --- a/problems/find-and-replace-in-string/README.md +++ b/problems/find-and-replace-in-string/README.md @@ -21,33 +21,40 @@

    All these operations occur simultaneously.  It's guaranteed that there won't be any overlap in replacement: for example, S = "abc", indexes = [0, 1], sources = ["ab","bc"] is not a valid test case.

    +

     

    Example 1:

    -Input: S = "abcd", indexes = [0,2], sources = ["a","cd"], targets = ["eee","ffff"]
    -Output: "eeebffff"
    -Explanation: "a" starts at index 0 in S, so it's replaced by "eee".
    +Input: S = "abcd", indexes = [0, 2], sources = ["a", "cd"], targets = ["eee", "ffff"]
    +Output: "eeebffff"
    +Explanation:
    +"a" starts at index 0 in S, so it's replaced by "eee".
     "cd" starts at index 2 in S, so it's replaced by "ffff".
     

    Example 2:

    -Input: S = "abcd", indexes = [0,2], sources = ["ab","ec"], targets = ["eee","ffff"]
    -Output: "eeecd"
    -Explanation: "ab" starts at index 0 in S, so it's replaced by "eee". 
    +Input: S = "abcd", indexes = [0, 2], sources = ["ab","ec"], targets = ["eee","ffff"]
    +Output: "eeecd"
    +Explanation:
    +"ab" starts at index 0 in S, so it's replaced by "eee".
     "ec" doesn't starts at index 2 in the original S, so we do nothing.
     
    -

    Notes:

    - -
      -
    1. 0 <= indexes.length = sources.length = targets.length <= 100
    2. -
    3. 0 < indexes[i] < S.length <= 1000
    4. -
    5. All characters in given inputs are lowercase letters.
    6. -
    -

     

    +

    Constraints:

    + +
      +
    • 0 <= S.length <= 1000
    • +
    • S consists of only lowercase English letters.
    • +
    • 0 <= indexes.length <= 100
    • +
    • 0 <= indexes[i] < S.length
    • +
    • sources.length == indexes.length
    • +
    • targets.length == indexes.length
    • +
    • 1 <= sources[i].length, targets[i].length <= 50
    • +
    • sources[i] and targets[i] consist of only lowercase English letters.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/graph-connectivity-with-threshold/README.md b/problems/graph-connectivity-with-threshold/README.md new file mode 100644 index 000000000..af423892c --- /dev/null +++ b/problems/graph-connectivity-with-threshold/README.md @@ -0,0 +1,94 @@ + + + + + + + +[< Previous](../best-team-with-no-conflicts "Best Team With No Conflicts") +                 +[Next >](../design-an-expression-tree-with-evaluate-function "Design an Expression Tree With Evaluate Function") + +## [1627. Graph Connectivity With Threshold (Hard)](https://leetcode.com/problems/graph-connectivity-with-threshold "带阈值的图连通性") + +

    We have n cities labeled from 1 to n. Two different cities with labels x and y are directly connected by a bidirectional road if and only if x and y share a common divisor strictly greater than some threshold. More formally, cities with labels x and y have a road between them if there exists an integer z such that all of the following are true:

    + +
      +
    • x % z == 0,
    • +
    • y % z == 0, and
    • +
    • z > threshold.
    • +
    + +

    Given the two integers, n and threshold, and an array of queries, you must determine for each queries[i] = [ai, bi] if cities ai and bi are connected (i.e. there is some path between them).

    + +

    Return an array answer, where answer.length == queries.length and answer[i] is true if for the ith query, there is a path between ai and bi, or answer[i] is false if there is no path.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 6, threshold = 2, queries = [[1,4],[2,5],[3,6]]
    +Output: [false,false,true]
    +Explanation: The divisors for each number:
    +1:   1
    +2:   1, 2
    +3:   1, 3
    +4:   1, 2, 4
    +5:   1, 5
    +6:   1, 2, 3, 6
    +Using the underlined divisors above the threshold, only cities 3 and 6 share a common divisor, so they are the
    +only ones directly connected. The result of each query:
    +[1,4]   1 is not connected to 4
    +[2,5]   2 is not connected to 5
    +[3,6]   3 is connected to 6 through path 3--6
    +
    + +

    Example 2:

    + +
    +Input: n = 6, threshold = 0, queries = [[4,5],[3,4],[3,2],[2,6],[1,3]]
    +Output: [true,true,true,true,true]
    +Explanation: The divisors for each number are the same as the previous example. However, since the threshold is 0,
    +all divisors can be used. Since all numbers share 1 as a divisor, all cities are connected.
    +
    + +

    Example 3:

    + +
    +Input: n = 5, threshold = 1, queries = [[4,5],[4,5],[3,2],[2,3],[3,4]]
    +Output: [false,false,false,false,false]
    +Explanation: Only cities 2 and 4 share a common divisor 2 which is strictly greater than the threshold 1, so they are the only ones directly connected.
    +Please notice that there can be multiple queries for the same pair of nodes [x, y], and that the query [x, y] is equivalent to the query [y, x].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 104
    • +
    • 0 <= threshold <= n
    • +
    • 1 <= queries.length <= 105
    • +
    • queries[i].length == 2
    • +
    • 1 <= ai, bi <= cities
    • +
    • ai != bi
    • +
    + +### Related Topics + [[Union Find](../../tag/union-find/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +How to build the graph of the cities? +
    + +
    +Hint 2 +Connect city i with all its multiples 2*i, 3*i, ... +
    + +
    +Hint 3 +Answer the queries using union-find data structure. +
    diff --git a/problems/is-graph-bipartite/README.md b/problems/is-graph-bipartite/README.md index f3f0bc575..a45f0a3fe 100644 --- a/problems/is-graph-bipartite/README.md +++ b/problems/is-graph-bipartite/README.md @@ -11,47 +11,41 @@ ## [785. Is Graph Bipartite? (Medium)](https://leetcode.com/problems/is-graph-bipartite "判断二分图") -

    Given an undirected graph, return true if and only if it is bipartite.

    +

    Given an undirected graph, return true if and only if it is bipartite.

    -

    Recall that a graph is bipartite if we can split it's set of nodes into two independent subsets A and B such that every edge in the graph has one node in A and another node in B.

    +

    Recall that a graph is bipartite if we can split its set of nodes into two independent subsets A and B, such that every edge in the graph has one node in A and another node in B.

    The graph is given in the following form: graph[i] is a list of indexes j for which the edge between nodes i and j exists.  Each node is an integer between 0 and graph.length - 1.  There are no self edges or parallel edges: graph[i] does not contain i, and it doesn't contain any element twice.

    +

     

    +

    Example 1:

    +
    -Example 1:
    -Input: [[1,3], [0,2], [1,3], [0,2]]
    +Input: graph = [[1,3],[0,2],[1,3],[0,2]]
     Output: true
    -Explanation: 
    -The graph looks like this:
    -0----1
    -|    |
    -|    |
    -3----2
    -We can divide the vertices into two groups: {0, 2} and {1, 3}.
    +Explanation: We can divide the vertices into two groups: {0, 2} and {1, 3}.
    +
     
    +

    Example 2:

    +
    -Example 2:
    -Input: [[1,2,3], [0,2], [0,1,3], [0,2]]
    +Input: graph = [[1,2,3],[0,2],[0,1,3],[0,2]]
     Output: false
    -Explanation: 
    -The graph looks like this:
    -0----1
    -| \  |
    -|  \ |
    -3----2
    -We cannot find a way to divide the set of nodes into two independent subsets.
    +Explanation: We cannot find a way to divide the set of nodes into two independent subsets.
    +
     

     

    - -

    Note:

    +

    Constraints:

      -
    • graph will have length in range [1, 100].
    • -
    • graph[i] will contain integers in range [0, graph.length - 1].
    • -
    • graph[i] will not contain i or duplicate values.
    • -
    • The graph is undirected: if any element j is in graph[i], then i will be in graph[j].
    • +
    • 1 <= graph.length <= 100
    • +
    • 0 <= graphp[i].length < 100
    • +
    • 0 <= graph[i][j] <= graph.length - 1
    • +
    • graph[i][j] != i
    • +
    • All the values of graph[i] are unique.
    • +
    • The graph is guaranteed to be undirected
    ### Related Topics diff --git a/problems/kth-largest-element-in-a-stream/README.md b/problems/kth-largest-element-in-a-stream/README.md index e43566415..105c37968 100644 --- a/problems/kth-largest-element-in-a-stream/README.md +++ b/problems/kth-largest-element-in-a-stream/README.md @@ -9,7 +9,7 @@                  [Next >](../binary-search "Binary Search") -## [703. Kth Largest Element in a Stream (Easy)](https://leetcode.com/problems/kth-largest-element-in-a-stream "数据流中的第K大元素") +## [703. Kth Largest Element in a Stream (Easy)](https://leetcode.com/problems/kth-largest-element-in-a-stream "数据流中的第 K 大元素")

    Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element.

    @@ -48,6 +48,7 @@ kthLargest.add(4); // return 8
  • -104 <= nums[i] <= 104
  • -104 <= val <= 104
  • At most 104 calls will be made to add.
  • +
  • It is guaranteed that there will be at least k elements in the array when you search for the kth element.
  • ### Related Topics diff --git a/problems/largest-substring-between-two-equal-characters/README.md b/problems/largest-substring-between-two-equal-characters/README.md new file mode 100644 index 000000000..5ace94ab1 --- /dev/null +++ b/problems/largest-substring-between-two-equal-characters/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../all-valid-triplets-that-can-represent-a-country "All Valid Triplets That Can Represent a Country") +                 +[Next >](../lexicographically-smallest-string-after-applying-operations "Lexicographically Smallest String After Applying Operations") + +## [1624. Largest Substring Between Two Equal Characters (Easy)](https://leetcode.com/problems/largest-substring-between-two-equal-characters "两个相同字符之间的最长子字符串") + +

    Given a string s, return the length of the longest substring between two equal characters, excluding the two characters. If there is no such substring return -1.

    + +

    A substring is a contiguous sequence of characters within a string.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "aa"
    +Output: 0
    +Explanation: The optimal substring here is an empty substring between the two 'a's.
    + +

    Example 2:

    + +
    +Input: s = "abca"
    +Output: 2
    +Explanation: The optimal substring here is "bc".
    +
    + +

    Example 3:

    + +
    +Input: s = "cbzxy"
    +Output: -1
    +Explanation: There are no characters that appear twice in s.
    +
    + +

    Example 4:

    + +
    +Input: s = "cabbac"
    +Output: 4
    +Explanation: The optimal substring here is "abba". Other non-optimal substrings include "bb" and "".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 300
    • +
    • s contains only lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Try saving the first and last position of each character +
    + +
    +Hint 2 +Try finding every pair of indexes with equal characters +
    diff --git a/problems/lexicographically-smallest-string-after-applying-operations/README.md b/problems/lexicographically-smallest-string-after-applying-operations/README.md new file mode 100644 index 000000000..849dd3b78 --- /dev/null +++ b/problems/lexicographically-smallest-string-after-applying-operations/README.md @@ -0,0 +1,103 @@ + + + + + + + +[< Previous](../largest-substring-between-two-equal-characters "Largest Substring Between Two Equal Characters") +                 +[Next >](../best-team-with-no-conflicts "Best Team With No Conflicts") + +## [1625. Lexicographically Smallest String After Applying Operations (Medium)](https://leetcode.com/problems/lexicographically-smallest-string-after-applying-operations "执行操作后字典序最小的字符串") + +

    You are given a string s of even length consisting of digits from 0 to 9, and two integers a and b.

    + +

    You can apply either of the following two operations any number of times and in any order on s:

    + +
      +
    • Add a to all odd indices of s (0-indexed). Digits post 9 are cycled back to 0. For example, if s = "3456" and a = 5, s becomes "3951".
    • +
    • Rotate s to the right by b positions. For example, if s = "3456" and b = 1, s becomes "6345".
    • +
    + +

    Return the lexicographically smallest string you can obtain by applying the above operations any number of times on s.

    + +

    A string a is lexicographically smaller than a string b (of the same length) if in the first position where a and b differ, string a has a letter that appears earlier in the alphabet than the corresponding letter in b. For example, "0158" is lexicographically smaller than "0190" because the first position they differ is at the third letter, and '5' comes before '9'.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "5525", a = 9, b = 2
    +Output: "2050"
    +Explanation: We can apply the following operations:
    +Start:  "5525"
    +Rotate: "2555"
    +Add:    "2454"
    +Add:    "2353"
    +Rotate: "5323"
    +Add:    "5222"
    +​​​​​​​Add:    "5121"
    +​​​​​​​Rotate: "2151"
    +​​​​​​​Add:    "2050"​​​​​​​​​​​​
    +There is no way to obtain a string that is lexicographically smaller then "2050".
    +
    + +

    Example 2:

    + +
    +Input: s = "74", a = 5, b = 1
    +Output: "24"
    +Explanation: We can apply the following operations:
    +Start:  "74"
    +Rotate: "47"
    +​​​​​​​Add:    "42"
    +​​​​​​​Rotate: "24"​​​​​​​​​​​​
    +There is no way to obtain a string that is lexicographically smaller then "24".
    +
    + +

    Example 3:

    + +
    +Input: s = "0011", a = 4, b = 2
    +Output: "0011"
    +Explanation: There are no sequence of operations that will give us a lexicographically smaller string than "0011".
    +
    + +

    Example 4:

    + +
    +Input: s = "43987654", a = 7, b = 3
    +Output: "00553311"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= s.length <= 100
    • +
    • s.length is even.
    • +
    • s consists of digits from 0 to 9 only.
    • +
    • 1 <= a <= 9
    • +
    • 1 <= b <= s.length - 1
    • +
    + +### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + +### Hints +
    +Hint 1 +Since the length of s is even, the total number of possible sequences is at most 10 * 10 * s.length. +
    + +
    +Hint 2 +You can generate all possible sequences and take their minimum. +
    + +
    +Hint 3 +Keep track of already generated sequences so they are not processed again. +
    diff --git a/problems/make-sum-divisible-by-p/README.md b/problems/make-sum-divisible-by-p/README.md index 74befbe25..69cfad339 100644 --- a/problems/make-sum-divisible-by-p/README.md +++ b/problems/make-sum-divisible-by-p/README.md @@ -68,6 +68,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] [[Binary Search](../../tag/binary-search/README.md)] ### Hints diff --git a/problems/map-sum-pairs/README.md b/problems/map-sum-pairs/README.md index 77155594d..50e3ff828 100644 --- a/problems/map-sum-pairs/README.md +++ b/problems/map-sum-pairs/README.md @@ -11,26 +11,41 @@ ## [677. Map Sum Pairs (Medium)](https://leetcode.com/problems/map-sum-pairs "键值映射") -

    -Implement a MapSum class with insert, and sum methods. -

    +

    Implement the MapSum class:

    -

    -For the method insert, you'll be given a pair of (string, integer). The string represents the key and the integer represents the value. If the key already existed, then the original key-value pair will be overridden to the new one. -

    +
      +
    • MapSum() Initializes the MapSum object.
    • +
    • void insert(String key, int val) Inserts the key-val pair into the map. If the key already existed, the original key-value pair will be overridden to the new one.
    • +
    • int sum(string prefix) Returns the sum of all the pairs' value whose key starts with the prefix.
    • +
    -

    -For the method sum, you'll be given a string representing the prefix, and you need to return the sum of all the pairs' value whose key starts with the prefix. -

    +

     

    +

    Example 1:

    -

    Example 1:

    -Input: insert("apple", 3), Output: Null
    -Input: sum("ap"), Output: 3
    -Input: insert("app", 2), Output: Null
    -Input: sum("ap"), Output: 5
    +Input
    +["MapSum", "insert", "sum", "insert", "sum"]
    +[[], ["apple", 3], ["ap"], ["app", 2], ["ap"]]
    +Output
    +[null, null, 3, null, 5]
    +
    +Explanation
    +MapSum mapSum = new MapSum();
    +mapSum.insert("apple", 3);  
    +mapSum.sum("ap");           // return 3 (apple = 3)
    +mapSum.insert("app", 2);    
    +mapSum.sum("ap");           // return 5 (apple + app = 3 + 2 = 5)
     
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= key.length, prefix.length <= 50
    • +
    • key and prefix consist of only lowercase English letters.
    • +
    • 1 <= val <= 1000
    • +
    • At most 50 calls will be made to insert and sum.
    • +
    ### Related Topics [[Trie](../../tag/trie/README.md)] diff --git a/problems/maximum-nesting-depth-of-the-parentheses/README.md b/problems/maximum-nesting-depth-of-the-parentheses/README.md index aa0ef03d6..dc1655b0c 100644 --- a/problems/maximum-nesting-depth-of-the-parentheses/README.md +++ b/problems/maximum-nesting-depth-of-the-parentheses/README.md @@ -23,7 +23,8 @@
    • depth("") = 0
    • -
    • depth(A + B) = max(depth(A), depth(B)), where A and B are VPS's
    • +
    • depth(C) = 0, where C is a string with a single character not equal to "(" or ")".
    • +
    • depth(A + B) = max(depth(A), depth(B)), where A and B are VPS's.
    • depth("(" + A + ")") = 1 + depth(A), where A is a VPS.
    diff --git a/problems/number-of-longest-increasing-subsequence/README.md b/problems/number-of-longest-increasing-subsequence/README.md index 2f7a971ee..f71e06b98 100644 --- a/problems/number-of-longest-increasing-subsequence/README.md +++ b/problems/number-of-longest-increasing-subsequence/README.md @@ -11,29 +11,33 @@ ## [673. Number of Longest Increasing Subsequence (Medium)](https://leetcode.com/problems/number-of-longest-increasing-subsequence "最长递增子序列的个数") -

    -Given an unsorted array of integers, find the number of longest increasing subsequence. -

    +

    Given an integer array nums, return the number of longest increasing subsequences.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: [1,3,5,4,7]
    -Output: 2
    -Explanation: The two longest increasing subsequence are [1, 3, 4, 7] and [1, 3, 5, 7].
    +Input: nums = [1,3,5,4,7]
    +Output: 2
    +Explanation: The two longest increasing subsequences are [1, 3, 4, 7] and [1, 3, 5, 7].
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: [2,2,2,2,2]
    -Output: 5
    -Explanation: The length of longest continuous increasing subsequence is 1, and there are 5 subsequences' length is 1, so output 5.
    +Input: nums = [2,2,2,2,2]
    +Output: 5
    +Explanation: The length of longest continuous increasing subsequence is 1, and there are 5 subsequences' length is 1, so output 5.
    +
     
    -

    -

    Note: -Length of the given array will be not exceed 2000 and the answer is guaranteed to be fit in 32-bit signed int. -

    +

     

    +

    Constraints:

    + +
      +
    • 0 <= nums.length <= 2000
    • +
    • -106 <= nums[i] <= 106
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md b/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md index 6c74efc59..506692891 100644 --- a/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md +++ b/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md @@ -63,7 +63,7 @@ The image above shows the 5 different ways {(0,2),(2,3)}, {(0,1),(1,3)}, {(0,1), ### Related Topics - [[Recursion](../../tag/recursion/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md index 3f22c05f7..0e5ce6c7d 100644 --- a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md +++ b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md @@ -9,7 +9,7 @@                  [Next >](../prime-palindrome "Prime Palindrome") -## [865. Smallest Subtree with all the Deepest Nodes (Medium)](https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes "具有所有最深结点的最小子树") +## [865. Smallest Subtree with all the Deepest Nodes (Medium)](https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes "具有所有最深节点的最小子树")

    Given the root of a binary tree, the depth of each node is the shortest distance to the root.

    diff --git a/problems/swap-salary/README.md b/problems/swap-salary/README.md index 7b1d08c64..3fc6f3824 100644 --- a/problems/swap-salary/README.md +++ b/problems/swap-salary/README.md @@ -9,7 +9,7 @@                  [Next >](../maximum-product-of-three-numbers "Maximum Product of Three Numbers") -## [627. Swap Salary (Easy)](https://leetcode.com/problems/swap-salary "交换工资") +## [627. Swap Salary (Easy)](https://leetcode.com/problems/swap-salary "变更性别")

    Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update statement and no intermediate temp table.

    diff --git a/readme/1-300.md b/readme/1-300.md index fa30b03fa..7ee3c1f83 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -297,7 +297,7 @@ LeetCode Problems' Solutions | 225 | [Implement Stack using Queues](https://leetcode.com/problems/implement-stack-using-queues "用队列实现栈") | [Go](../problems/implement-stack-using-queues) | Easy | | 226 | [Invert Binary Tree](https://leetcode.com/problems/invert-binary-tree "翻转二叉树") | [Go](../problems/invert-binary-tree) | Easy | | 227 | [Basic Calculator II](https://leetcode.com/problems/basic-calculator-ii "基本计算器 II") | [Go](../problems/basic-calculator-ii) | Medium | -| 228 | [Summary Ranges](https://leetcode.com/problems/summary-ranges "汇总区间") | [Go](../problems/summary-ranges) | Medium | +| 228 | [Summary Ranges](https://leetcode.com/problems/summary-ranges "汇总区间") | [Go](../problems/summary-ranges) | Easy | | 229 | [Majority Element II](https://leetcode.com/problems/majority-element-ii "求众数 II") | [Go](../problems/majority-element-ii) | Medium | | 230 | [Kth Smallest Element in a BST](https://leetcode.com/problems/kth-smallest-element-in-a-bst "二叉搜索树中第K小的元素") | [Go](../problems/kth-smallest-element-in-a-bst) | Medium | | 231 | [Power of Two](https://leetcode.com/problems/power-of-two "2的幂") | [Go](../problems/power-of-two) | Easy | diff --git a/readme/301-600.md b/readme/301-600.md index c7a261919..c46bc56a9 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -229,7 +229,7 @@ LeetCode Problems' Solutions | 457 | [Circular Array Loop](https://leetcode.com/problems/circular-array-loop "环形数组循环") | [Go](../problems/circular-array-loop) | Medium | | 458 | [Poor Pigs](https://leetcode.com/problems/poor-pigs "可怜的小猪") | [Go](../problems/poor-pigs) | Hard | | 459 | [Repeated Substring Pattern](https://leetcode.com/problems/repeated-substring-pattern "重复的子字符串") | [Go](../problems/repeated-substring-pattern) | Easy | -| 460 | [LFU Cache](https://leetcode.com/problems/lfu-cache "LFU缓存") | [Go](../problems/lfu-cache) | Hard | +| 460 | [LFU Cache](https://leetcode.com/problems/lfu-cache "LFU 缓存") | [Go](../problems/lfu-cache) | Hard | | 461 | [Hamming Distance](https://leetcode.com/problems/hamming-distance "汉明距离") | [Go](../problems/hamming-distance) | Easy | | 462 | [Minimum Moves to Equal Array Elements II](https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii "最少移动次数使数组元素相等 II") | [Go](../problems/minimum-moves-to-equal-array-elements-ii) | Medium | | 463 | [Island Perimeter](https://leetcode.com/problems/island-perimeter "岛屿的周长") | [Go](../problems/island-perimeter) | Easy | diff --git a/readme/601-900.md b/readme/601-900.md index 3d55aaeec..e447a681d 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -96,7 +96,7 @@ LeetCode Problems' Solutions | 624 | [Maximum Distance in Arrays](https://leetcode.com/problems/maximum-distance-in-arrays "数组列表中的最大距离") 🔒 | [Go](../problems/maximum-distance-in-arrays) | Medium | | 625 | [Minimum Factorization](https://leetcode.com/problems/minimum-factorization "最小因式分解") 🔒 | [Go](../problems/minimum-factorization) | Medium | | 626 | [Exchange Seats](https://leetcode.com/problems/exchange-seats "换座位") | [MySQL](../problems/exchange-seats) | Medium | -| 627 | [Swap Salary](https://leetcode.com/problems/swap-salary "交换工资") | [MySQL](../problems/swap-salary) | Easy | +| 627 | [Swap Salary](https://leetcode.com/problems/swap-salary "变更性别") | [MySQL](../problems/swap-salary) | Easy | | 628 | [Maximum Product of Three Numbers](https://leetcode.com/problems/maximum-product-of-three-numbers "三个数的最大乘积") | [Go](../problems/maximum-product-of-three-numbers) | Easy | | 629 | [K Inverse Pairs Array](https://leetcode.com/problems/k-inverse-pairs-array "K个逆序对数组") | [Go](../problems/k-inverse-pairs-array) | Hard | | 630 | [Course Schedule III](https://leetcode.com/problems/course-schedule-iii "课程表 III") | [Go](../problems/course-schedule-iii) | Hard | @@ -172,7 +172,7 @@ LeetCode Problems' Solutions | 700 | [Search in a Binary Search Tree](https://leetcode.com/problems/search-in-a-binary-search-tree "二叉搜索树中的搜索") | [Go](../problems/search-in-a-binary-search-tree) | Easy | | 701 | [Insert into a Binary Search Tree](https://leetcode.com/problems/insert-into-a-binary-search-tree "二叉搜索树中的插入操作") | [Go](../problems/insert-into-a-binary-search-tree) | Medium | | 702 | [Search in a Sorted Array of Unknown Size](https://leetcode.com/problems/search-in-a-sorted-array-of-unknown-size "搜索长度未知的有序数组") 🔒 | [Go](../problems/search-in-a-sorted-array-of-unknown-size) | Medium | -| 703 | [Kth Largest Element in a Stream](https://leetcode.com/problems/kth-largest-element-in-a-stream "数据流中的第K大元素") | [Go](../problems/kth-largest-element-in-a-stream) | Easy | +| 703 | [Kth Largest Element in a Stream](https://leetcode.com/problems/kth-largest-element-in-a-stream "数据流中的第 K 大元素") | [Go](../problems/kth-largest-element-in-a-stream) | Easy | | 704 | [Binary Search](https://leetcode.com/problems/binary-search "二分查找") | [Go](../problems/binary-search) | Easy | | 705 | [Design HashSet](https://leetcode.com/problems/design-hashset "设计哈希集合") | [Go](../problems/design-hashset) | Easy | | 706 | [Design HashMap](https://leetcode.com/problems/design-hashmap "设计哈希映射") | [Go](../problems/design-hashmap) | Easy | @@ -334,7 +334,7 @@ LeetCode Problems' Solutions | 862 | [Shortest Subarray with Sum at Least K](https://leetcode.com/problems/shortest-subarray-with-sum-at-least-k "和至少为 K 的最短子数组") | [Go](../problems/shortest-subarray-with-sum-at-least-k) | Hard | | 863 | [All Nodes Distance K in Binary Tree](https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree "二叉树中所有距离为 K 的结点") | [Go](../problems/all-nodes-distance-k-in-binary-tree) | Medium | | 864 | [Shortest Path to Get All Keys](https://leetcode.com/problems/shortest-path-to-get-all-keys "获取所有钥匙的最短路径") | [Go](../problems/shortest-path-to-get-all-keys) | Hard | -| 865 | [Smallest Subtree with all the Deepest Nodes](https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes "具有所有最深结点的最小子树") | [Go](../problems/smallest-subtree-with-all-the-deepest-nodes) | Medium | +| 865 | [Smallest Subtree with all the Deepest Nodes](https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes "具有所有最深节点的最小子树") | [Go](../problems/smallest-subtree-with-all-the-deepest-nodes) | Medium | | 866 | [Prime Palindrome](https://leetcode.com/problems/prime-palindrome "回文素数") | [Go](../problems/prime-palindrome) | Medium | | 867 | [Transpose Matrix](https://leetcode.com/problems/transpose-matrix "转置矩阵") | [Go](../problems/transpose-matrix) | Easy | | 868 | [Binary Gap](https://leetcode.com/problems/binary-gap "二进制间距") | [Go](../problems/binary-gap) | Easy | diff --git a/tag/array/README.md b/tag/array/README.md index 36892774c..006edd552 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,9 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1629 | [按键持续时间最长的键](../../problems/slowest-key) | [[数组](../array/README.md)] | Easy | | 1619 | [删除某些元素后的数组均值](../../problems/mean-of-array-after-removing-some-elements) | [[数组](../array/README.md)] | Easy | | 1608 | [特殊数组的特征值](../../problems/special-array-with-x-elements-greater-than-or-equal-x) | [[数组](../array/README.md)] | Easy | -| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1588 | [所有奇数长度子数组的和](../../problems/sum-of-all-odd-length-subarrays) | [[数组](../array/README.md)] | Easy | | 1583 | [统计不开心的朋友](../../problems/count-unhappy-friends) | [[数组](../array/README.md)] | Medium | | 1582 | [二进制矩阵中的特殊位置](../../problems/special-positions-in-a-binary-matrix) | [[数组](../array/README.md)] | Easy | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 49cde1f81..ffe65b9e6 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,8 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1562 | [查找大小为 M 的最新分组](../../problems/find-latest-group-of-size-m) | [[二分查找](../binary-search/README.md)] | Medium | | 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 42fc7554a..37483ff32 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 5544 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1625 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 614a32710..57ce3888f 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,7 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 5544 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1625 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | | 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index ad8f943f3..df5a1efc8 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1628 | [Design an Expression Tree With Evaluate Function](../../problems/design-an-expression-tree-with-evaluate-function) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard | | 1603 | [设计停车系统](../../problems/design-parking-system) | [[设计](../design/README.md)] | Easy | | 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | @@ -30,7 +31,7 @@ | 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | | 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 703 | [数据流中的第K大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy | +| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy | | 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Hard | | 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | | 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | @@ -38,7 +39,7 @@ | 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | | 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] | Easy | | 588 | [设计内存文件系统](../../problems/design-in-memory-file-system) 🔒 | [[设计](../design/README.md)] | Hard | -| 460 | [LFU缓存](../../problems/lfu-cache) | [[设计](../design/README.md)] | Hard | +| 460 | [LFU 缓存](../../problems/lfu-cache) | [[设计](../design/README.md)] | Hard | | 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] | Hard | | 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index a8d19060a..07df805b2 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,7 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 5545 | [无矛盾的最佳球队](../../problems/best-team-with-no-conflicts) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1626 | [无矛盾的最佳球队](../../problems/best-team-with-no-conflicts) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1621 | [大小为 K 的不重叠线段的数目](../../problems/number-of-sets-of-k-non-overlapping-line-segments) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index d1c05ec24..f86e57ad7 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1615 | [最大网络秩](../../problems/maximal-network-rank) | [[图](../graph/README.md)] | Medium | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1557 | [可以到达所有点的最少点数目](../../problems/minimum-number-of-vertices-to-reach-all-nodes) | [[图](../graph/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 5c48b289b..3c0ad9891 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] | Hard | | 1620 | [网络信号最好的坐标](../../problems/coordinate-with-maximum-network-quality) | [[贪心算法](../greedy/README.md)] | Medium | | 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1605 | [给定行和列的和求可行矩阵](../../problems/find-valid-matrix-given-row-and-column-sums) | [[贪心算法](../greedy/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 374707328..c6f11ce31 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -10,6 +10,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/heap/README.md b/tag/heap/README.md index 0fd1fee5d..89a7abecc 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -25,7 +25,7 @@ | 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | | 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 703 | [数据流中的第K大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy | +| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy | | 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[堆](../heap/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | | 502 | [IPO](../../problems/ipo) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | diff --git a/tag/math/README.md b/tag/math/README.md index bab6c2f38..49d3b2e18 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,8 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 5128 | [带阈值的图连通性](../../problems/graph-connectivity-with-threshold) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | +| 1627 | [带阈值的图连通性](../../problems/graph-connectivity-with-threshold) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | | 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard | +| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 1551 | [使数组中所有元素相等的最小操作数](../../problems/minimum-operations-to-make-array-equal) | [[数学](../math/README.md)] | Medium | | 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 1354ec088..c3bdb7b1c 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -9,7 +9,6 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1621 | [大小为 K 的不重叠线段的数目](../../problems/number-of-sets-of-k-non-overlapping-line-segments) | [[递归](../recursion/README.md)] | Medium | | 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[递归](../recursion/README.md)] | Easy | | 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | | 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index 9800bd7b9..be3834028 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1630 | [等差子数组](../../problems/arithmetic-subarrays) | [[排序](../sort/README.md)] | Medium | | 1561 | [你可以获得的最大硬币数目](../../problems/maximum-number-of-coins-you-can-get) | [[排序](../sort/README.md)] | Medium | | 1528 | [重新排列字符串](../../problems/shuffle-string) | [[排序](../sort/README.md)] | Easy | | 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index 60985d0ca..18bd3d850 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,8 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 5543 | [两个相同字符之间的最长子字符串](../../problems/largest-substring-between-two-equal-characters) | [[字符串](../string/README.md)] | Easy | -| 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1624 | [两个相同字符之间的最长子字符串](../../problems/largest-substring-between-two-equal-characters) | [[字符串](../string/README.md)] | Easy | +| 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1614 | [括号的最大嵌套深度](../../problems/maximum-nesting-depth-of-the-parentheses) | [[字符串](../string/README.md)] | Easy | | 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | diff --git a/tag/tree/README.md b/tag/tree/README.md index ddcf67217..3428bb2c5 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1628 | [Design an Expression Tree With Evaluate Function](../../problems/design-an-expression-tree-with-evaluate-function) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1609 | [奇偶树](../../problems/even-odd-tree) | [[树](../tree/README.md)] | Medium | | 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | @@ -63,7 +64,7 @@ | 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] | Medium | | 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 865 | [具有所有最深结点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] | Medium | +| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] | Medium | | 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | | 814 | [二叉树剪枝](../../problems/binary-tree-pruning) | [[树](../tree/README.md)] | Medium | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index 78fa1d2be..1fc59b219 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -9,7 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 5128 | [带阈值的图连通性](../../problems/graph-connectivity-with-threshold) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | +| 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] | Hard | +| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1627 | [带阈值的图连通性](../../problems/graph-connectivity-with-threshold) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | | 1584 | [连接所有点的最小费用](../../problems/min-cost-to-connect-all-points) | [[并查集](../union-find/README.md)] | Medium | | 1579 | [保证图可完全遍历](../../problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | [[并查集](../union-find/README.md)] | Hard | | 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | From dc078f4cf8b73b6a22aa4d913c01249d596ba089 Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 3 Nov 2020 13:44:27 +0800 Subject: [PATCH 107/145] A: new --- README.md | 19 +++- .../README.md | 33 +++++++ .../README.md | 2 +- problems/arithmetic-subarrays/README.md | 80 ++++++++++++++++ problems/array-partition-i/README.md | 41 +++++--- problems/binary-tree-tilt/README.md | 61 +++++++----- problems/champagne-tower/README.md | 7 +- .../README.md | 81 ++++++++++++++++ problems/container-with-most-water/README.md | 5 +- problems/count-and-say/README.md | 29 +++--- problems/count-sorted-vowel-strings/README.md | 70 ++++++++++++++ .../README.md | 84 +++++++++++++++++ .../README.md | 2 +- .../README.md | 4 +- problems/distinct-subsequences/README.md | 54 +++++------ problems/distribute-candies/README.md | 4 +- problems/edit-distance/README.md | 17 +++- .../README.md | 33 ++++--- .../fraction-to-recurring-decimal/README.md | 2 + .../furthest-building-you-can-reach/README.md | 83 ++++++++++++++++ problems/hopper-company-queries-i/README.md | 14 +++ .../mysql_schemas.sql | 39 ++++++++ problems/integer-replacement/README.md | 56 +++++------ problems/kth-smallest-instructions/README.md | 83 ++++++++++++++++ problems/lfu-cache/README.md | 2 +- problems/line-reflection/README.md | 2 +- problems/linked-list-cycle-ii/README.md | 7 +- problems/linked-list-cycle/README.md | 7 +- problems/longest-absolute-file-path/README.md | 40 ++++++-- .../longest-consecutive-sequence/README.md | 24 ++++- .../README.md | 38 +++----- .../minimum-depth-of-binary-tree/README.md | 2 +- problems/minimum-window-substring/README.md | 25 +++-- problems/missing-ranges/README.md | 2 +- problems/number-of-boomerangs/README.md | 40 ++++++-- .../README.md | 2 +- .../README.md | 93 ++++++++++++++++++ problems/path-with-minimum-effort/README.md | 80 ++++++++++++++++ .../README.md | 14 +++ .../mysql_schemas.sql | 19 ++++ problems/permutation-sequence/README.md | 40 ++++---- problems/permutations-ii/README.md | 30 ++++-- .../README.md | 1 + problems/rank-transform-of-a-matrix/README.md | 94 +++++++++++++++++++ problems/recover-binary-search-tree/README.md | 48 +++------- .../regular-expression-matching/README.md | 5 +- .../README.md | 51 +++++----- problems/shuffle-an-array/README.md | 46 ++++++--- problems/slowest-key/README.md | 81 ++++++++++++++++ .../smallest-integer-divisible-by-k/README.md | 27 +++--- .../README.md | 62 ++++++++++++ problems/subarray-sum-equals-k/README.md | 20 ++-- problems/summary-ranges/README.md | 3 +- problems/trapping-rain-water/README.md | 2 +- .../README.md | 58 ++++++++++++ readme/1-300.md | 4 +- readme/301-600.md | 2 +- tag/README.md | 4 +- tag/array/README.md | 4 +- tag/backtracking/README.md | 3 +- tag/binary-search/README.md | 1 + tag/breadth-first-search/README.md | 1 + tag/depth-first-search/README.md | 2 +- tag/design/README.md | 2 +- tag/dynamic-programming/README.md | 4 + tag/hash-table/README.md | 3 +- tag/heap/README.md | 1 + tag/linked-list/README.md | 1 + tag/math/README.md | 4 +- tag/sort/README.md | 3 + tag/string/README.md | 1 + tag/tags.json | 10 +- tag/tree/README.md | 4 +- tag/trie/README.md | 1 + 74 files changed, 1571 insertions(+), 352 deletions(-) create mode 100644 problems/add-two-polynomials-represented-as-linked-lists/README.md create mode 100644 problems/arithmetic-subarrays/README.md create mode 100644 problems/check-array-formation-through-concatenation/README.md create mode 100644 problems/count-sorted-vowel-strings/README.md create mode 100644 problems/count-substrings-that-differ-by-one-character/README.md create mode 100644 problems/furthest-building-you-can-reach/README.md create mode 100644 problems/hopper-company-queries-i/README.md create mode 100644 problems/hopper-company-queries-i/mysql_schemas.sql create mode 100644 problems/kth-smallest-instructions/README.md create mode 100644 problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md create mode 100644 problems/path-with-minimum-effort/README.md create mode 100644 problems/percentage-of-users-attended-a-contest/README.md create mode 100644 problems/percentage-of-users-attended-a-contest/mysql_schemas.sql create mode 100644 problems/rank-transform-of-a-matrix/README.md create mode 100644 problems/slowest-key/README.md create mode 100644 problems/sort-array-by-increasing-frequency/README.md create mode 100644 problems/widest-vertical-area-between-two-points-containing-no-points/README.md diff --git a/README.md b/README.md index 40ab88502..25c4129d8 100644 --- a/README.md +++ b/README.md @@ -70,12 +70,27 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | -| 1628 | [Design an Expression Tree With Evaluate Function](https://leetcode.com/problems/design-an-expression-tree-with-evaluate-function) 🔒 | [Go](problems/design-an-expression-tree-with-evaluate-function) | Medium | +| 1643 | [Kth Smallest Instructions](https://leetcode.com/problems/kth-smallest-instructions "第 K 条最小指令") | [Go](problems/kth-smallest-instructions) | Hard | +| 1642 | [Furthest Building You Can Reach](https://leetcode.com/problems/furthest-building-you-can-reach "可以到达的最远建筑") | [Go](problems/furthest-building-you-can-reach) | Medium | +| 1641 | [Count Sorted Vowel Strings](https://leetcode.com/problems/count-sorted-vowel-strings "统计字典序元音字符串的数目") | [Go](problems/count-sorted-vowel-strings) | Medium | +| 1640 | [Check Array Formation Through Concatenation](https://leetcode.com/problems/check-array-formation-through-concatenation "能否连接形成数组") | [Go](problems/check-array-formation-through-concatenation) | Easy | +| 1639 | [Number of Ways to Form a Target String Given a Dictionary](https://leetcode.com/problems/number-of-ways-to-form-a-target-string-given-a-dictionary "通过给定词典构造目标字符串的方案数") | [Go](problems/number-of-ways-to-form-a-target-string-given-a-dictionary) | Hard | +| 1638 | [Count Substrings That Differ by One Character](https://leetcode.com/problems/count-substrings-that-differ-by-one-character "统计只差一个字符的子串数目") | [Go](problems/count-substrings-that-differ-by-one-character) | Medium | +| 1637 | [Widest Vertical Area Between Two Points Containing No Points](https://leetcode.com/problems/widest-vertical-area-between-two-points-containing-no-points "两点之间不包含任何点的最宽垂直面积") | [Go](problems/widest-vertical-area-between-two-points-containing-no-points) | Medium | +| 1636 | [Sort Array by Increasing Frequency](https://leetcode.com/problems/sort-array-by-increasing-frequency "按照频率将数组升序排序") | [Go](problems/sort-array-by-increasing-frequency) | Easy | +| 1635 | [Hopper Company Queries I](https://leetcode.com/problems/hopper-company-queries-i) 🔒 | [MySQL](problems/hopper-company-queries-i) | Hard | +| 1634 | [Add Two Polynomials Represented as Linked Lists](https://leetcode.com/problems/add-two-polynomials-represented-as-linked-lists) 🔒 | [Go](problems/add-two-polynomials-represented-as-linked-lists) | Medium | +| 1633 | [Percentage of Users Attended a Contest](https://leetcode.com/problems/percentage-of-users-attended-a-contest "各赛事的用户注册率") 🔒 | [MySQL](problems/percentage-of-users-attended-a-contest) | Easy | +| 1632 | [Rank Transform of a Matrix](https://leetcode.com/problems/rank-transform-of-a-matrix "矩阵转换后的秩") | [Go](problems/rank-transform-of-a-matrix) | Hard | +| 1631 | [Path With Minimum Effort](https://leetcode.com/problems/path-with-minimum-effort "最小体力消耗路径") | [Go](problems/path-with-minimum-effort) | Medium | +| 1630 | [Arithmetic Subarrays](https://leetcode.com/problems/arithmetic-subarrays "等差子数组") | [Go](problems/arithmetic-subarrays) | Medium | +| 1629 | [Slowest Key](https://leetcode.com/problems/slowest-key "按键持续时间最长的键") | [Go](problems/slowest-key) | Easy | +| 1628 | [Design an Expression Tree With Evaluate Function](https://leetcode.com/problems/design-an-expression-tree-with-evaluate-function "设计带解析函数的表达式树") 🔒 | [Go](problems/design-an-expression-tree-with-evaluate-function) | Medium | | 1627 | [Graph Connectivity With Threshold](https://leetcode.com/problems/graph-connectivity-with-threshold "带阈值的图连通性") | [Go](problems/graph-connectivity-with-threshold) | Hard | | 1626 | [Best Team With No Conflicts](https://leetcode.com/problems/best-team-with-no-conflicts "无矛盾的最佳球队") | [Go](problems/best-team-with-no-conflicts) | Medium | | 1625 | [Lexicographically Smallest String After Applying Operations](https://leetcode.com/problems/lexicographically-smallest-string-after-applying-operations "执行操作后字典序最小的字符串") | [Go](problems/lexicographically-smallest-string-after-applying-operations) | Medium | | 1624 | [Largest Substring Between Two Equal Characters](https://leetcode.com/problems/largest-substring-between-two-equal-characters "两个相同字符之间的最长子字符串") | [Go](problems/largest-substring-between-two-equal-characters) | Easy | -| 1623 | [All Valid Triplets That Can Represent a Country](https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country) 🔒 | [MySQL](problems/all-valid-triplets-that-can-represent-a-country) | Easy | +| 1623 | [All Valid Triplets That Can Represent a Country](https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country "三人国家代表队") 🔒 | [MySQL](problems/all-valid-triplets-that-can-represent-a-country) | Easy | | 1622 | [Fancy Sequence](https://leetcode.com/problems/fancy-sequence "奇妙序列") | [Go](problems/fancy-sequence) | Hard | | 1621 | [Number of Sets of K Non-Overlapping Line Segments](https://leetcode.com/problems/number-of-sets-of-k-non-overlapping-line-segments "大小为 K 的不重叠线段的数目") | [Go](problems/number-of-sets-of-k-non-overlapping-line-segments) | Medium | | 1620 | [Coordinate With Maximum Network Quality](https://leetcode.com/problems/coordinate-with-maximum-network-quality "网络信号最好的坐标") | [Go](problems/coordinate-with-maximum-network-quality) | Medium | diff --git a/problems/add-two-polynomials-represented-as-linked-lists/README.md b/problems/add-two-polynomials-represented-as-linked-lists/README.md new file mode 100644 index 000000000..fb4e8668f --- /dev/null +++ b/problems/add-two-polynomials-represented-as-linked-lists/README.md @@ -0,0 +1,33 @@ + + + + + + + +[< Previous](../percentage-of-users-attended-a-contest "Percentage of Users Attended a Contest") +                 +[Next >](../hopper-company-queries-i "Hopper Company Queries I") + +## [1634. Add Two Polynomials Represented as Linked Lists (Medium)](https://leetcode.com/problems/add-two-polynomials-represented-as-linked-lists "") + + + +### Related Topics + [[Linked List](../../tag/linked-list/README.md)] + +### Hints +
    +Hint 1 +Process both linked lists at the same time +
    + +
    +Hint 2 +If the current power of the two heads is equal, add this power with the sum of the coefficients to the answer list. +
    + +
    +Hint 3 +If one head has a larger power, add this power to the answer list and move only this head. +
    diff --git a/problems/all-valid-triplets-that-can-represent-a-country/README.md b/problems/all-valid-triplets-that-can-represent-a-country/README.md index d786653e8..3cdc8904c 100644 --- a/problems/all-valid-triplets-that-can-represent-a-country/README.md +++ b/problems/all-valid-triplets-that-can-represent-a-country/README.md @@ -9,6 +9,6 @@                  [Next >](../largest-substring-between-two-equal-characters "Largest Substring Between Two Equal Characters") -## [1623. All Valid Triplets That Can Represent a Country (Easy)](https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country "") +## [1623. All Valid Triplets That Can Represent a Country (Easy)](https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country "三人国家代表队") diff --git a/problems/arithmetic-subarrays/README.md b/problems/arithmetic-subarrays/README.md new file mode 100644 index 000000000..840bdd39a --- /dev/null +++ b/problems/arithmetic-subarrays/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../slowest-key "Slowest Key") +                 +[Next >](../path-with-minimum-effort "Path With Minimum Effort") + +## [1630. Arithmetic Subarrays (Medium)](https://leetcode.com/problems/arithmetic-subarrays "等差子数组") + +

    A sequence of numbers is called arithmetic if it consists of at least two elements, and the difference between every two consecutive elements is the same. More formally, a sequence s is arithmetic if and only if s[i+1] - s[i] == s[1] - s[0] for all valid i.

    + +

    For example, these are arithmetic sequences:

    + +
    +1, 3, 5, 7, 9
    +7, 7, 7, 7
    +3, -1, -5, -9
    + +

    The following sequence is not arithmetic:

    + +
    +1, 1, 2, 5, 7
    + +

    You are given an array of n integers, nums, and two arrays of m integers each, l and r, representing the m range queries, where the ith query is the range [l[i], r[i]]. All the arrays are 0-indexed.

    + +

    Return a list of boolean elements answer, where answer[i] is true if the subarray nums[l[i]], nums[l[i]+1], ... , nums[r[i]] can be rearranged to form an arithmetic sequence, and false otherwise.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [4,6,5,9,3,7], l = [0,0,2], r = [2,3,5]
    +Output: [true,false,true]
    +Explanation:
    +In the 0th query, the subarray is [4,6,5]. This can be rearranged as [6,5,4], which is an arithmetic sequence.
    +In the 1st query, the subarray is [4,6,5,9]. This cannot be rearranged as an arithmetic sequence.
    +In the 2nd query, the subarray is [5,9,3,7]. This can be rearranged as [3,5,7,9], which is an arithmetic sequence.
    + +

    Example 2:

    + +
    +Input: nums = [-12,-9,-3,-12,-6,15,20,-25,-20,-15,-10], l = [0,1,6,4,8,7], r = [4,4,9,7,9,10]
    +Output: [false,true,false,false,true,true]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • m == l.length
    • +
    • m == r.length
    • +
    • 2 <= n <= 500
    • +
    • 1 <= m <= 500
    • +
    • 0 <= l[i] < r[i] < n
    • +
    • -105 <= nums[i] <= 105
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + +### Hints +
    +Hint 1 +To check if a given sequence is arithmetic, just check that the difference between every two consecutive elements is the same. +
    + +
    +Hint 2 +If and only if a set of numbers can make an arithmetic sequence, then its sorted version makes an arithmetic sequence. So to check a set of numbers, sort it, and check if that sequence is arithmetic. +
    + +
    +Hint 3 +For each query, get the corresponding set of numbers which will be the sub-array represented by the query, sort it, and check if the result sequence is arithmetic. +
    diff --git a/problems/array-partition-i/README.md b/problems/array-partition-i/README.md index 87b67dbcc..6a558e5b1 100644 --- a/problems/array-partition-i/README.md +++ b/problems/array-partition-i/README.md @@ -11,25 +11,36 @@ ## [561. Array Partition I (Easy)](https://leetcode.com/problems/array-partition-i "数组拆分 I") -

    -Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as possible. -

    +

    Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), ..., (an, bn) such that the sum of min(ai, bi) for all i is maximized. Return the maximized sum.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: [1,4,3,2]
    +Input: nums = [1,4,3,2]
    +Output: 4
    +Explanation: All possible pairings (ignoring the ordering of elements) are:
    +1. (1, 4), (2, 3) -> min(1, 4) + min(2, 3) = 1 + 2 = 3
    +2. (1, 3), (2, 4) -> min(1, 3) + min(2, 4) = 1 + 2 = 3
    +3. (1, 2), (3, 4) -> min(1, 2) + min(3, 4) = 1 + 3 = 4
    +So the maximum possible sum is 4.
    + +

    Example 2:

    -Output: 4 -Explanation: n is 2, and the maximum sum of pairs is 4 = min(1, 2) + min(3, 4). +
    +Input: nums = [6,2,6,5,1,2]
    +Output: 9
    +Explanation: The optimal pairing is (2, 1), (2, 5), (6, 6). min(2, 1) + min(2, 5) + min(6, 6) = 1 + 2 + 6 = 9.
     
    -

    - -

    Note:
    -

      -
    1. n is a positive integer, which is in the range of [1, 10000].
    2. -
    3. All the integers in the array will be in the range of [-10000, 10000].
    4. -
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 104
    • +
    • nums.length == 2 * n
    • +
    • -104 <= nums[i] <= 104
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/binary-tree-tilt/README.md b/problems/binary-tree-tilt/README.md index 2f13835ec..ac3877475 100644 --- a/problems/binary-tree-tilt/README.md +++ b/problems/binary-tree-tilt/README.md @@ -11,33 +11,52 @@ ## [563. Binary Tree Tilt (Easy)](https://leetcode.com/problems/binary-tree-tilt "二叉树的坡度") -

    Given a binary tree, return the tilt of the whole tree.

    +

    Given the root of a binary tree, return the sum of every tree node's tilt.

    -

    The tilt of a tree node is defined as the absolute difference between the sum of all left subtree node values and the sum of all right subtree node values. Null node has tilt 0.

    +

    The tilt of a tree node is the absolute difference between the sum of all left subtree node values and all right subtree node values. If a node does not have a left child, then the sum of the left subtree node values is treated as 0. The rule is similar if there the node does not have a right child.

    -

    The tilt of the whole tree is defined as the sum of all nodes' tilt.

    +

     

    +

    Example 1:

    + +
    +Input: root = [1,2,3]
    +Output: 1
    +Explanation: 
    +Tilt of node 2 : |0-0| = 0 (no children)
    +Tilt of node 3 : |0-0| = 0 (no children)
    +Tile of node 1 : |2-3| = 1 (left subtree is just left child, so sum is 2; right subtree is just right child, so sum is 3)
    +Sum of every tilt : 0 + 0 + 1 = 1
    +
    + +

    Example 2:

    + +
    +Input: root = [4,2,9,3,5,null,7]
    +Output: 15
    +Explanation: 
    +Tilt of node 3 : |0-0| = 0 (no children)
    +Tilt of node 5 : |0-0| = 0 (no children)
    +Tilt of node 7 : |0-0| = 0 (no children)
    +Tilt of node 2 : |3-5| = 2 (left subtree is just left child, so sum is 3; right subtree is just right child, so sum is 5)
    +Tilt of node 9 : |0-7| = 7 (no left child, so sum is 0; right subtree is just right child, so sum is 7)
    +Tilt of node 4 : |(3+5+2)-(9+7)| = |10-16| = 6 (left subtree values are 3, 5, and 2, which sums to 10; right subtree values are 9 and 7, which sums to 16)
    +Sum of every tilt : 0 + 0 + 0 + 2 + 7 + 6 = 15
    +
    -

    Example:
    +

    Example 3:

    +
    -Input: 
    -         1
    -       /   \
    -      2     3
    -Output: 1
    -Explanation: 
    -Tilt of node 2 : 0
    -Tilt of node 3 : 0
    -Tilt of node 1 : |2-3| = 1
    -Tilt of binary tree : 0 + 0 + 1 = 1
    +Input: root = [21,7,14,1,1,2,2,3,3]
    +Output: 9
     
    -

    -

    Note: -

      -
    1. The sum of node values in any subtree won't exceed the range of 32-bit integer.
    2. -
    3. All the tilt values won't exceed the range of 32-bit integer.
    4. -
    -

    +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [0, 104].
    • +
    • -1000 <= Node.val <= 1000
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/champagne-tower/README.md b/problems/champagne-tower/README.md index 65b9e9e41..198366efc 100644 --- a/problems/champagne-tower/README.md +++ b/problems/champagne-tower/README.md @@ -11,9 +11,9 @@ ## [799. Champagne Tower (Medium)](https://leetcode.com/problems/champagne-tower "香槟塔") -

    We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so on until the 100th row.  Each glass holds one cup (250ml) of champagne.

    +

    We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so on until the 100th row.  Each glass holds one cup of champagne.

    -

    Then, some champagne is poured in the first glass at the top.  When the topmost glass is full, any excess liquid poured will fall equally to the glass immediately to the left and right of it.  When those glasses become full, any excess champagne will fall equally to the left and right of those glasses, and so on.  (A glass at the bottom row has its excess champagne fall on the floor.)

    +

    Then, some champagne is poured into the first glass at the top.  When the topmost glass is full, any excess liquid poured will fall equally to the glass immediately to the left and right of it.  When those glasses become full, any excess champagne will fall equally to the left and right of those glasses, and so on.  (A glass at the bottom row has its excess champagne fall on the floor.)

    For example, after one cup of champagne is poured, the top most glass is full.  After two cups of champagne are poured, the two glasses on the second row are half full.  After three cups of champagne are poured, those two cups become full - there are 3 full glasses total now.  After four cups of champagne are poured, the third row has the middle glass half full, and the two outside glasses are a quarter full, as pictured below.

    @@ -52,3 +52,6 @@
  • 0 <= poured <= 109
  • 0 <= query_glass <= query_row < 100
  • + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/check-array-formation-through-concatenation/README.md b/problems/check-array-formation-through-concatenation/README.md new file mode 100644 index 000000000..d37ff0985 --- /dev/null +++ b/problems/check-array-formation-through-concatenation/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../number-of-ways-to-form-a-target-string-given-a-dictionary "Number of Ways to Form a Target String Given a Dictionary") +                 +[Next >](../count-sorted-vowel-strings "Count Sorted Vowel Strings") + +## [1640. Check Array Formation Through Concatenation (Easy)](https://leetcode.com/problems/check-array-formation-through-concatenation "能否连接形成数组") + +

    You are given an array of distinct integers arr and an array of integer arrays pieces, where the integers in pieces are distinct. Your goal is to form arr by concatenating the arrays in pieces in any order. However, you are not allowed to reorder the integers in each array pieces[i].

    + +

    Return true if it is possible to form the array arr from pieces. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [85], pieces = [[85]]
    +Output: true
    +
    + +

    Example 2:

    + +
    +Input: arr = [15,88], pieces = [[88],[15]]
    +Output: true
    +Explanation: Concatenate [15] then [88]
    +
    + +

    Example 3:

    + +
    +Input: arr = [49,18,16], pieces = [[16,18,49]]
    +Output: false
    +Explanation: Even though the numbers match, we cannot reorder pieces[0].
    +
    + +

    Example 4:

    + +
    +Input: arr = [91,4,64,78], pieces = [[78],[4,64],[91]]
    +Output: true
    +Explanation: Concatenate [91] then [4,64] then [78]
    + +

    Example 5:

    + +
    +Input: arr = [1,3,5,7], pieces = [[2,4,6,8]]
    +Output: false
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= pieces.length <= arr.length <= 100
    • +
    • sum(pieces[i].length) == arr.length
    • +
    • 1 <= pieces[i].length <= arr.length
    • +
    • 1 <= arr[i], pieces[i][j] <= 100
    • +
    • The integers in arr are distinct.
    • +
    • The integers in pieces are distinct (i.e., If we flatten pieces in a 1D array, all the integers in this array are distinct).
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Note that the distinct part means that every position in the array belongs to only one piece +
    + +
    +Hint 2 +Note that you can get the piece every position belongs to naively +
    diff --git a/problems/container-with-most-water/README.md b/problems/container-with-most-water/README.md index 3f368254f..3e9755510 100644 --- a/problems/container-with-most-water/README.md +++ b/problems/container-with-most-water/README.md @@ -49,8 +49,9 @@

    Constraints:

      -
    • 2 <= height.length <= 3 * 104
    • -
    • 0 <= height[i] <= 3 * 104
    • +
    • n = height.length
    • +
    • 2 <= n <= 3 * 104
    • +
    • 0 <= height[i] <= 3 * 104
    ### Related Topics diff --git a/problems/count-and-say/README.md b/problems/count-and-say/README.md index 687c7042b..6efc35cad 100644 --- a/problems/count-and-say/README.md +++ b/problems/count-and-say/README.md @@ -11,23 +11,18 @@ ## [38. Count and Say (Easy)](https://leetcode.com/problems/count-and-say "外观数列") -

    The count-and-say sequence is the sequence of integers with the first five terms as following:

    +

    The count-and-say sequence is a sequence of digit strings defined by the recursive formula:

    -
    -1.     1
    -2.     11
    -3.     21
    -4.     1211
    -5.     111221
    -
    - -

    1 is read off as "one 1" or 11.
    -11 is read off as "two 1s" or 21.
    -21 is read off as "one 2, then one 1" or 1211.

    +
      +
    • countAndSay(1) = "1"
    • +
    • countAndSay(n) is the way you would "say" the digit string from countAndSay(n-1), which is then converted into a different digit string.
    • +
    -

    Given an integer n, generate the nth term of the count-and-say sequence. You can do so recursively, in other words from the previous member read off the digits, counting the number of digits in groups of the same digit.

    +

    To determine how you "say" a digit string, split it into the minimal number of groups so that each group is a contiguous section all of the same character. Then for each group, say the number of characters, then say the character. To convert the saying into a digit string, replace the counts with a number and concatenate every saying.

    -

    Note: Each term of the sequence of integers will be represented as a string.

    +

    For example, the saying and conversion for digit string "3322251":

    + +

    Given a positive integer n, return the nth term of the count-and-say sequence.

     

    Example 1:

    @@ -43,7 +38,11 @@
     Input: n = 4
     Output: "1211"
    -Explanation: For n = 3 the term was "21" in which we have two groups "2" and "1", "2" can be read as "12" which means frequency = 1 and value = 2, the same way "1" is read as "11", so the answer is the concatenation of "12" and "11" which is "1211".
    +Explanation:
    +countAndSay(1) = "1"
    +countAndSay(2) = say "1" = one 1 = "11"
    +countAndSay(3) = say "11" = two 1's = "21"
    +countAndSay(4) = say "21" = one 2 + one 1 = "12" + "11" = "1211"
     

     

    diff --git a/problems/count-sorted-vowel-strings/README.md b/problems/count-sorted-vowel-strings/README.md new file mode 100644 index 000000000..6ddf5b2b8 --- /dev/null +++ b/problems/count-sorted-vowel-strings/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../check-array-formation-through-concatenation "Check Array Formation Through Concatenation") +                 +[Next >](../furthest-building-you-can-reach "Furthest Building You Can Reach") + +## [1641. Count Sorted Vowel Strings (Medium)](https://leetcode.com/problems/count-sorted-vowel-strings "统计字典序元音字符串的数目") + +

    Given an integer n, return the number of strings of length n that consist only of vowels (a, e, i, o, u) and are lexicographically sorted.

    + +

    A string s is lexicographically sorted if for all valid i, s[i] is the same as or comes before s[i+1] in the alphabet.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 1
    +Output: 5
    +Explanation: The 5 sorted strings that consist of vowels only are ["a","e","i","o","u"].
    +
    + +

    Example 2:

    + +
    +Input: n = 2
    +Output: 15
    +Explanation: The 15 sorted strings that consist of vowels only are
    +["aa","ae","ai","ao","au","ee","ei","eo","eu","ii","io","iu","oo","ou","uu"].
    +Note that "ea" is not a valid string since 'e' comes after 'a' in the alphabet.
    +
    + +

    Example 3:

    + +
    +Input: n = 33
    +Output: 66045
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 50 
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
    +Hint 1 +For each character, its possible values will depend on the value of its previous character, because it needs to be not smaller than it. +
    + +
    +Hint 2 +Think backtracking. Build a recursive function count(n, last_character) that counts the number of valid strings of length n and whose first characters are not less than last_character. +
    + +
    +Hint 3 +In this recursive function, iterate on the possible characters for the first character, which will be all the vowels not less than last_character, and for each possible value c, increase the answer by count(n-1, c). +
    diff --git a/problems/count-substrings-that-differ-by-one-character/README.md b/problems/count-substrings-that-differ-by-one-character/README.md new file mode 100644 index 000000000..5c97929d6 --- /dev/null +++ b/problems/count-substrings-that-differ-by-one-character/README.md @@ -0,0 +1,84 @@ + + + + + + + +[< Previous](../widest-vertical-area-between-two-points-containing-no-points "Widest Vertical Area Between Two Points Containing No Points") +                 +[Next >](../number-of-ways-to-form-a-target-string-given-a-dictionary "Number of Ways to Form a Target String Given a Dictionary") + +## [1638. Count Substrings That Differ by One Character (Medium)](https://leetcode.com/problems/count-substrings-that-differ-by-one-character "统计只差一个字符的子串数目") + +

    Given two strings s and t, find the number of ways you can choose a non-empty substring of s and replace a single character by a different character such that the resulting substring is a substring of t. In other words, find the number of substrings in s that differ from some substring in t by exactly one character.

    + +

    For example, the underlined substrings in "computer" and "computation" only differ by the 'e'/'a', so this is a valid way.

    + +

    Return the number of substrings that satisfy the condition above.

    + +

    A substring is a contiguous sequence of characters within a string.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "aba", t = "baba"
    +Output: 6
    +Explanation: The following are the pairs of substrings from s and t that differ by exactly 1 character:
    +("aba", "baba")
    +("aba", "baba")
    +("aba", "baba")
    +("aba", "baba")
    +("aba", "baba")
    +("aba", "baba")
    +The underlined portions are the substrings that are chosen from s and t.
    +
    +​​Example 2: + +
    +Input: s = "ab", t = "bb"
    +Output: 3
    +Explanation: The following are the pairs of substrings from s and t that differ by 1 character:
    +("ab", "bb")
    +("ab", "bb")
    +("ab", "bb")
    +​​​​The underlined portions are the substrings that are chosen from s and t.
    +
    +Example 3: + +
    +Input: s = "a", t = "a"
    +Output: 0
    +
    + +

    Example 4:

    + +
    +Input: s = "abe", t = "bbc"
    +Output: 10
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length, t.length <= 100
    • +
    • s and t consist of lowercase English letters only.
    • +
    + +### Related Topics + [[Trie](../../tag/trie/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Take every substring of s, change a character, and see how many substrings of t match that substring. +
    + +
    +Hint 2 +Use a Trie to store all substrings of t as a dictionary. +
    diff --git a/problems/data-stream-as-disjoint-intervals/README.md b/problems/data-stream-as-disjoint-intervals/README.md index faacb90e7..3f9b567ab 100644 --- a/problems/data-stream-as-disjoint-intervals/README.md +++ b/problems/data-stream-as-disjoint-intervals/README.md @@ -34,6 +34,6 @@ [[Ordered Map](../../tag/ordered-map/README.md)] ### Similar Questions - 1. [Summary Ranges](../summary-ranges) (Medium) + 1. [Summary Ranges](../summary-ranges) (Easy) 1. [Find Right Interval](../find-right-interval) (Medium) 1. [Range Module](../range-module) (Hard) diff --git a/problems/design-an-expression-tree-with-evaluate-function/README.md b/problems/design-an-expression-tree-with-evaluate-function/README.md index b255e8571..7423f5947 100644 --- a/problems/design-an-expression-tree-with-evaluate-function/README.md +++ b/problems/design-an-expression-tree-with-evaluate-function/README.md @@ -7,9 +7,9 @@ [< Previous](../graph-connectivity-with-threshold "Graph Connectivity With Threshold")                  -Next > +[Next >](../slowest-key "Slowest Key") -## [1628. Design an Expression Tree With Evaluate Function (Medium)](https://leetcode.com/problems/design-an-expression-tree-with-evaluate-function "") +## [1628. Design an Expression Tree With Evaluate Function (Medium)](https://leetcode.com/problems/design-an-expression-tree-with-evaluate-function "设计带解析函数的表达式树") diff --git a/problems/distinct-subsequences/README.md b/problems/distinct-subsequences/README.md index 75c52d122..c7d794543 100644 --- a/problems/distinct-subsequences/README.md +++ b/problems/distinct-subsequences/README.md @@ -11,49 +11,45 @@ ## [115. Distinct Subsequences (Hard)](https://leetcode.com/problems/distinct-subsequences "不同的子序列") -

    Given a string S and a string T, count the number of distinct subsequences of S which equals T.

    +

    Given two strings s and t, return the number of distinct subsequences of s which equals t.

    -

    A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, "ACE" is a subsequence of "ABCDE" while "AEC" is not).

    +

    A string's subsequence is a new string formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ACE" is a subsequence of "ABCDE" while "AEC" is not).

    It's guaranteed the answer fits on a 32-bit signed integer.

    +

     

    Example 1:

    -Input: S = "rabbbit", T = "rabbit"
    -Output: 3
    -Explanation:
    +Input: s = "rabbbit", t = "rabbit"
    +Output: 3
    +Explanation:
     As shown below, there are 3 ways you can generate "rabbit" from S.
    -(The caret symbol ^ means the chosen letters)
    -
    -rabbbit
    -^^^^ ^^
    -rabbbit
    -^^ ^^^^
    -rabbbit
    -^^^ ^^^
    +rabbbit
    +rabbbit
    +rabbbit
     

    Example 2:

    -Input: S = "babgbag", T = "bag"
    -Output: 5
    -Explanation:
    +Input: s = "babgbag", t = "bag"
    +Output: 5
    +Explanation:
     As shown below, there are 5 ways you can generate "bag" from S.
    -(The caret symbol ^ means the chosen letters)
    -
    -babgbag
    -^^ ^
    -babgbag
    -^^    ^
    -babgbag
    -^    ^^
    -babgbag
    -  ^  ^^
    -babgbag
    -    ^^^
    -
    +babgbag +babgbag +babgbag +babgbag +babgbag
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= s.length, t.length <= 1000
    • +
    • s and t consist of English letters.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/distribute-candies/README.md b/problems/distribute-candies/README.md index 020e7245d..8013d8d48 100644 --- a/problems/distribute-candies/README.md +++ b/problems/distribute-candies/README.md @@ -67,9 +67,9 @@ The sister has two different kinds of candies, the brother has only one kind of
    • n == candies.length
    • -
    • 2 <= n <= 10^4
    • +
    • 2 <= n <= 104
    • n is even.
    • -
    • -10^5 <= candies[i] <= 10^5
    • +
    • -105 <= candies[i] <= 105
    ### Related Topics diff --git a/problems/edit-distance/README.md b/problems/edit-distance/README.md index 140d75e55..36f4811eb 100644 --- a/problems/edit-distance/README.md +++ b/problems/edit-distance/README.md @@ -11,16 +11,17 @@ ## [72. Edit Distance (Hard)](https://leetcode.com/problems/edit-distance "编辑距离") -

    Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2.

    +

    Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2.

    -

    You have the following 3 operations permitted on a word:

    +

    You have the following three operations permitted on a word:

    -
      +
      • Insert a character
      • Delete a character
      • Replace a character
      • -
    + +

     

    Example 1:

    @@ -45,6 +46,14 @@ exention -> exection (replace 'n' with 'c')
     exection -> execution (insert 'u')
     
    +

     

    +

    Constraints:

    + +
      +
    • 0 <= word1.length, word2.length <= 500
    • +
    • word1 and word2 consist of lowercase English letters.
    • +
    + ### Related Topics [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/find-minimum-in-rotated-sorted-array/README.md b/problems/find-minimum-in-rotated-sorted-array/README.md index eccb58740..0eb160154 100644 --- a/problems/find-minimum-in-rotated-sorted-array/README.md +++ b/problems/find-minimum-in-rotated-sorted-array/README.md @@ -11,27 +11,30 @@ ## [153. Find Minimum in Rotated Sorted Array (Medium)](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array "寻找旋转排序数组中的最小值") -

    Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.

    +

    Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e.,  [0,1,2,4,5,6,7] might become  [4,5,6,7,0,1,2]).

    -

    (i.e.,  [0,1,2,4,5,6,7] might become  [4,5,6,7,0,1,2]).

    - -

    Find the minimum element.

    - -

    You may assume no duplicate exists in the array.

    +

    Return the minimum element of this array.

    +

     

    Example 1:

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

    Example 2:

    - -
    -Input: [4,5,6,7,0,1,2]
    +

    Example 2:

    +
    Input: nums = [4,5,6,7,0,1,2]
     Output: 0
    +

    Example 3:

    +
    Input: nums = [1]
    +Output: 1
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 5000
    • +
    • -5000 <= nums[i] <= 5000
    • +
    • All the integers of nums are unique.
    • +
    • nums is sorted and rotated at some pivot.
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/fraction-to-recurring-decimal/README.md b/problems/fraction-to-recurring-decimal/README.md index ecec11e69..d465cc7ea 100644 --- a/problems/fraction-to-recurring-decimal/README.md +++ b/problems/fraction-to-recurring-decimal/README.md @@ -17,6 +17,8 @@

    If multiple answers are possible, return any of them.

    +

    It is guaranteed that the length of the answer string is less than 104 for all the given inputs.

    +

     

    Example 1:

    Input: numerator = 1, denominator = 2
    diff --git a/problems/furthest-building-you-can-reach/README.md b/problems/furthest-building-you-can-reach/README.md
    new file mode 100644
    index 000000000..e7aa08934
    --- /dev/null
    +++ b/problems/furthest-building-you-can-reach/README.md
    @@ -0,0 +1,83 @@
    +
    +
    +
    +
    +
    +
    +
    +[< Previous](../count-sorted-vowel-strings "Count Sorted Vowel Strings")
    +                
    +[Next >](../kth-smallest-instructions "Kth Smallest Instructions")
    +
    +## [1642. Furthest Building You Can Reach (Medium)](https://leetcode.com/problems/furthest-building-you-can-reach "可以到达的最远建筑")
    +
    +

    You are given an integer array heights representing the heights of buildings, some bricks, and some ladders.

    + +

    You start your journey from building 0 and move to the next building by possibly using bricks or ladders.

    + +

    While moving from building i to building i+1 (0-indexed),

    + +
      +
    • If the current building's height is greater than or equal to the next building's height, you do not need a ladder or bricks.
    • +
    • If the current building's height is less than the next building's height, you can either use one ladder or (h[i+1] - h[i]) bricks.
    • +
    + +

    Return the furthest building index (0-indexed) you can reach if you use the given ladders and bricks optimally.

    + +

     

    +

    Example 1:

    + +
    +Input: heights = [4,2,7,6,9,14,12], bricks = 5, ladders = 1
    +Output: 4
    +Explanation: Starting at building 0, you can follow these steps:
    +- Go to building 1 without using ladders nor bricks since 4 >= 2.
    +- Go to building 2 using 5 bricks. You must use either bricks or ladders because 2 < 7.
    +- Go to building 3 without using ladders nor bricks since 7 >= 6.
    +- Go to building 4 using your only ladder. You must use either bricks or ladders because 6 < 9.
    +It is impossible to go beyond building 4 because you do not have any more bricks or ladders.
    +
    + +

    Example 2:

    + +
    +Input: heights = [4,12,2,7,3,18,20,3,19], bricks = 10, ladders = 2
    +Output: 7
    +
    + +

    Example 3:

    + +
    +Input: heights = [14,3,19,3], bricks = 17, ladders = 0
    +Output: 3
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= heights.length <= 105
    • +
    • 1 <= heights[i] <= 106
    • +
    • 0 <= bricks <= 109
    • +
    • 0 <= ladders <= heights.length
    • +
    + +### Related Topics + [[Heap](../../tag/heap/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Assume the problem is to check whether you can reach the last building or not. +
    + +
    +Hint 2 +You'll have to do a set of jumps, and choose for each one whether to do it using a rope or bricks. It's always optimal to use ropes in the largest jumps. +
    + +
    +Hint 3 +Iterate on the buildings, maintaining the largest r jumps and the sum of the remaining ones so far, and stop whenever this sum exceeds b. +
    diff --git a/problems/hopper-company-queries-i/README.md b/problems/hopper-company-queries-i/README.md new file mode 100644 index 000000000..db0348089 --- /dev/null +++ b/problems/hopper-company-queries-i/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../add-two-polynomials-represented-as-linked-lists "Add Two Polynomials Represented as Linked Lists") +                 +[Next >](../sort-array-by-increasing-frequency "Sort Array by Increasing Frequency") + +## [1635. Hopper Company Queries I (Hard)](https://leetcode.com/problems/hopper-company-queries-i "") + + diff --git a/problems/hopper-company-queries-i/mysql_schemas.sql b/problems/hopper-company-queries-i/mysql_schemas.sql new file mode 100644 index 000000000..f66daff0b --- /dev/null +++ b/problems/hopper-company-queries-i/mysql_schemas.sql @@ -0,0 +1,39 @@ +Create table If Not Exists Drivers (driver_id int, join_date date); +Create table If Not Exists Rides (ride_id int, user_id int, requested_at date); +Create table If Not Exists AcceptedRides (ride_id int, driver_id int, ride_distance int, ride_duration int); +Truncate table Drivers; +insert into Drivers (driver_id, join_date) values ('10', '2019-12-10'); +insert into Drivers (driver_id, join_date) values ('8', '2020-1-13'); +insert into Drivers (driver_id, join_date) values ('5', '2020-2-16'); +insert into Drivers (driver_id, join_date) values ('7', '2020-3-8'); +insert into Drivers (driver_id, join_date) values ('4', '2020-5-17'); +insert into Drivers (driver_id, join_date) values ('1', '2020-10-24'); +insert into Drivers (driver_id, join_date) values ('6', '2021-1-5'); +Truncate table Rides; +insert into Rides (ride_id, user_id, requested_at) values ('6', '75', '2019-12-9'); +insert into Rides (ride_id, user_id, requested_at) values ('1', '54', '2020-2-9'); +insert into Rides (ride_id, user_id, requested_at) values ('10', '63', '2020-3-4'); +insert into Rides (ride_id, user_id, requested_at) values ('19', '39', '2020-4-6'); +insert into Rides (ride_id, user_id, requested_at) values ('3', '41', '2020-6-3'); +insert into Rides (ride_id, user_id, requested_at) values ('13', '52', '2020-6-22'); +insert into Rides (ride_id, user_id, requested_at) values ('7', '69', '2020-7-16'); +insert into Rides (ride_id, user_id, requested_at) values ('17', '70', '2020-8-25'); +insert into Rides (ride_id, user_id, requested_at) values ('20', '81', '2020-11-2'); +insert into Rides (ride_id, user_id, requested_at) values ('5', '57', '2020-11-9'); +insert into Rides (ride_id, user_id, requested_at) values ('2', '42', '2020-12-9'); +insert into Rides (ride_id, user_id, requested_at) values ('11', '68', '2021-1-11'); +insert into Rides (ride_id, user_id, requested_at) values ('15', '32', '2021-1-17'); +insert into Rides (ride_id, user_id, requested_at) values ('12', '11', '2021-1-19'); +insert into Rides (ride_id, user_id, requested_at) values ('14', '18', '2021-1-27'); +Truncate table AcceptedRides; +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('10', '10', '63', '38'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('13', '10', '73', '96'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('7', '8', '100', '28'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('17', '7', '119', '68'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('20', '1', '121', '92'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('5', '7', '42', '101'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('2', '4', '6', '38'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('11', '8', '37', '43'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('15', '8', '108', '82'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('12', '8', '38', '34'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('14', '1', '90', '74'); diff --git a/problems/integer-replacement/README.md b/problems/integer-replacement/README.md index a34ff2c94..905a5d312 100644 --- a/problems/integer-replacement/README.md +++ b/problems/integer-replacement/README.md @@ -11,50 +11,46 @@ ## [397. Integer Replacement (Medium)](https://leetcode.com/problems/integer-replacement "整数替换") -

    -Given a positive integer n and you can do operations as follow: -

    +

    Given a positive integer n, you can apply one of the following operations:

    -

      -
    1. If n is even, replace n with n/2.
    2. -
    3. If n is odd, you can replace n with either n + 1 or n - 1.
    4. +
    5. If n is even, replace n with n / 2.
    6. +
    7. If n is odd, replace n with either n + 1 or n - 1.
    -

    -

    -What is the minimum number of replacements needed for n to become 1? -

    +

    Return the minimum number of operations needed for n to become 1.

    -

    +

     

    +

    Example 1:

    -

    Example 1:

    -Input:
    -8
    +Input: n = 8
    +Output: 3
    +Explanation: 8 -> 4 -> 2 -> 1
    +
    -Output: -3 +

    Example 2:

    -Explanation: -8 -> 4 -> 2 -> 1 +
    +Input: n = 7
    +Output: 4
    +Explanation: 7 -> 8 -> 4 -> 2 -> 1
    +or 7 -> 6 -> 3 -> 2 -> 1
     
    -

    -

    Example 2: +

    Example 3:

    +
    -Input:
    -7
    +Input: n = 4
    +Output: 2
    +
    -Output: -4 +

     

    +

    Constraints:

    -Explanation: -7 -> 8 -> 4 -> 2 -> 1 -or -7 -> 6 -> 3 -> 2 -> 1 -
    -

    +
      +
    • 1 <= n <= 231 - 1
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/kth-smallest-instructions/README.md b/problems/kth-smallest-instructions/README.md new file mode 100644 index 000000000..6e3b47e69 --- /dev/null +++ b/problems/kth-smallest-instructions/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../furthest-building-you-can-reach "Furthest Building You Can Reach") +                 +Next > + +## [1643. Kth Smallest Instructions (Hard)](https://leetcode.com/problems/kth-smallest-instructions "第 K 条最小指令") + +

    Bob is standing at cell (0, 0), and he wants to reach destination: (row, column). He can only travel right and down. You are going to help Bob by providing instructions for him to reach destination.

    + +

    The instructions are represented as a string, where each character is either:

    + +
      +
    • 'H', meaning move horizontally (go right), or
    • +
    • 'V', meaning move vertically (go down).
    • +
    + +

    Multiple instructions will lead Bob to destination. For example, if destination is (2, 3), both "HHHVV" and "HVHVH" are valid instructions.

    + +
      +
    + +

    However, Bob is very picky. Bob has a lucky number k, and he wants the kth lexicographically smallest instructions that will lead him to destination. k is 1-indexed.

    + +

    Given an integer array destination and an integer k, return the kth lexicographically smallest instructions that will take Bob to destination.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: destination = [2,3], k = 1
    +Output: "HHHVV"
    +Explanation: All the instructions that reach (2, 3) in lexicographic order are as follows:
    +["HHHVV", "HHVHV", "HHVVH", "HVHHV", "HVHVH", "HVVHH", "VHHHV", "VHHVH", "VHVHH", "VVHHH"].
    +
    + +

    Example 2:

    + +

    + +
    +Input: destination = [2,3], k = 2
    +Output: "HHVHV"
    +
    + +

    Example 3:

    + +

    + +
    +Input: destination = [2,3], k = 3
    +Output: "HHVVH"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • destination.length == 2
    • +
    • 1 <= row, column <= 15
    • +
    • 1 <= k <= nCr(row + column, row), where nCr(a, b) denotes a choose b​​​​​.
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +There are nCr(row + column, row) possible instructions to reach (row, column). +
    + +
    +Hint 2 +Try building the instructions one step at a time. How many instructions start with "H", and how does this compare with k? +
    diff --git a/problems/lfu-cache/README.md b/problems/lfu-cache/README.md index 33f7be07a..61b940a26 100644 --- a/problems/lfu-cache/README.md +++ b/problems/lfu-cache/README.md @@ -9,7 +9,7 @@                  [Next >](../hamming-distance "Hamming Distance") -## [460. LFU Cache (Hard)](https://leetcode.com/problems/lfu-cache "LFU缓存") +## [460. LFU Cache (Hard)](https://leetcode.com/problems/lfu-cache "LFU 缓存")

    Design and implement a data structure for Least Frequently Used (LFU) cache.

    diff --git a/problems/line-reflection/README.md b/problems/line-reflection/README.md index e08b9984f..aac011c2a 100644 --- a/problems/line-reflection/README.md +++ b/problems/line-reflection/README.md @@ -33,7 +33,7 @@ ### Similar Questions 1. [Max Points on a Line](../max-points-on-a-line) (Hard) - 1. [Number of Boomerangs](../number-of-boomerangs) (Easy) + 1. [Number of Boomerangs](../number-of-boomerangs) (Medium) ### Hints
    diff --git a/problems/linked-list-cycle-ii/README.md b/problems/linked-list-cycle-ii/README.md index cd3c8f0c9..df02b7928 100644 --- a/problems/linked-list-cycle-ii/README.md +++ b/problems/linked-list-cycle-ii/README.md @@ -17,10 +17,6 @@

    Notice that you should not modify the linked list.

    -

    Follow up:

    - -

    Can you solve it using O(1) (i.e. constant) memory?

    -

     

    Example 1:

    @@ -55,6 +51,9 @@
  • pos is -1 or a valid index in the linked-list.
  • +

     

    +

    Follow up: Can you solve it using O(1) (i.e. constant) memory?

    + ### Related Topics [[Linked List](../../tag/linked-list/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/linked-list-cycle/README.md b/problems/linked-list-cycle/README.md index db6fe3aa6..0546e3174 100644 --- a/problems/linked-list-cycle/README.md +++ b/problems/linked-list-cycle/README.md @@ -17,10 +17,6 @@

    Return true if there is a cycle in the linked list. Otherwise, return false.

    -

    Follow up:

    - -

    Can you solve it using O(1) (i.e. constant) memory?

    -

     

    Example 1:

    @@ -55,6 +51,9 @@
  • pos is -1 or a valid index in the linked-list.
  • +

     

    +

    Follow up: Can you solve it using O(1) (i.e. constant) memory?

    + ### Related Topics [[Linked List](../../tag/linked-list/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/longest-absolute-file-path/README.md b/problems/longest-absolute-file-path/README.md index 196c29bea..2db2fda1a 100644 --- a/problems/longest-absolute-file-path/README.md +++ b/problems/longest-absolute-file-path/README.md @@ -11,15 +11,29 @@ ## [388. Longest Absolute File Path (Medium)](https://leetcode.com/problems/longest-absolute-file-path "文件的最长绝对路径") -

    Suppose we have the file system represented in the following picture:

    +

    Suppose we have a file system that stores both files and directories. An example of one system is represented in the following picture:

    -

    We will represent the file system as a string where "\n\t" mean a subdirectory of the main directory, "\n\t\t" means a subdirectory of the subdirectory of the main directory and so on. Each folder will be represented as a string of letters and/or digits. Each file will be in the form "s1.s2" where s1 and s2 are strings of letters and/or digits.

    +

    Here, we have dir as the only directory in the root. dir contains two subdirectories, subdir1 and subdir2. subdir1 contains a file file1.ext and subdirectory subsubdir1. subdir2 contains a subdirectory subsubdir2, which contains a file file2.ext.

    -

    For example, the file system above is represented as "dir\n\tsubdir1\n\t\tfile1.ext\n\t\tsubsubdir1\n\tsubdir2\n\t\tsubsubdir2\n\t\t\tfile2.ext".

    +

    In text form, it looks like this (with ⟶ representing the tab character):

    -

    Given a string input representing the file system in the explained format, return the length of the longest absolute path to a file in the abstracted file system. If there is no file in the system, return 0.

    +
    +dir
    +⟶ subdir1
    +⟶ ⟶ file1.ext
    +⟶ ⟶ subsubdir1
    +⟶ subdir2
    +⟶ ⟶ subsubdir2
    +⟶ ⟶ ⟶ file2.ext
    +
    + +

    If we were to write this representation in code, it will look like this: "dir\n\tsubdir1\n\t\tfile1.ext\n\t\tsubsubdir1\n\tsubdir2\n\t\tsubsubdir2\n\t\t\tfile2.ext". Note that the '\n' and '\t' are the new-line and tab characters.

    + +

    Every file and directory has a unique absolute path in the file system, which is the order of directories that must be opened to reach the file/directory itself, all concatenated by '/'s. Using the above example, the absolute path to file2.ext is "dir/subdir2/subsubdir2/file2.ext". Each directory name consists of letters, digits, and/or spaces. Each file name is of the form name.extension, where name and extension consist of letters, digits, and/or spaces.

    + +

    Given a string input representing the file system in the explained format, return the length of the longest absolute path to a file in the abstracted file system. If there is no file in the system, return 0.

     

    Example 1:

    @@ -27,8 +41,7 @@
     Input: input = "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext"
     Output: 20
    -Explanation: We have only one file and its path is "dir/subdir2/file.ext" of length 20.
    -The path "dir/subdir1" doesn't contain any files.
    +Explanation: We have only one file, and the absolute path is "dir/subdir2/file.ext" of length 20.
     

    Example 2:

    @@ -39,7 +52,7 @@ The path "dir/subdir1" doesn't contain any files. Explanation: We have two files: "dir/subdir1/file1.ext" of length 21 "dir/subdir2/subsubdir2/file2.ext" of length 32. -We return 32 since it is the longest path. +We return 32 since it is the longest absolute path to a file.

    Example 3:

    @@ -47,7 +60,16 @@ We return 32 since it is the longest path.
     Input: input = "a"
     Output: 0
    -Explanation: We don't have any files.
    +Explanation: We do not have any files, just a single directory named "a".
    +
    + +

    Example 4:

    + +
    +Input: input = "file1.txt\nfile2.txt\nlongfile.txt"
    +Output: 12
    +Explanation: There are 3 files at the root directory.
    +Since the absolute path for anything at the root directory is just the name itself, the answer is "longfile.txt" with length 12.
     

     

    @@ -55,5 +77,5 @@ We return 32 since it is the longest path.
    • 1 <= input.length <= 104
    • -
    • input may contain lower-case or upper-case English letters, a new line character '\n', a tab character '\t', a dot '.', a space ' ' or digits.
    • +
    • input may contain lowercase or uppercase English letters, a new line character '\n', a tab character '\t', a dot '.', a space ' ', and digits.
    diff --git a/problems/longest-consecutive-sequence/README.md b/problems/longest-consecutive-sequence/README.md index b85a5bd21..bb9824cce 100644 --- a/problems/longest-consecutive-sequence/README.md +++ b/problems/longest-consecutive-sequence/README.md @@ -11,18 +11,34 @@ ## [128. Longest Consecutive Sequence (Hard)](https://leetcode.com/problems/longest-consecutive-sequence "最长连续序列") -

    Given an unsorted array of integers, find the length of the longest consecutive elements sequence.

    +

    Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.

    -

    Your algorithm should run in O(n) complexity.

    +

    Follow up: Could you implement the O(n) solution? 

    -

    Example:

    +

     

    +

    Example 1:

    -Input: [100, 4, 200, 1, 3, 2]
    +Input: nums = [100,4,200,1,3,2]
     Output: 4
     Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4.
     
    +

    Example 2:

    + +
    +Input: nums = [0,3,7,2,5,8,4,6,0,1]
    +Output: 9
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= nums.length <= 104
    • +
    • -109 <= nums[i] <= 109
    • +
    + ### Related Topics [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] diff --git a/problems/maximum-product-of-three-numbers/README.md b/problems/maximum-product-of-three-numbers/README.md index eda024fee..706b42890 100644 --- a/problems/maximum-product-of-three-numbers/README.md +++ b/problems/maximum-product-of-three-numbers/README.md @@ -11,34 +11,26 @@ ## [628. Maximum Product of Three Numbers (Easy)](https://leetcode.com/problems/maximum-product-of-three-numbers "三个数的最大乘积") -

    Given an integer array, find three numbers whose product is maximum and output the maximum product.

    - -

    Example 1:

    - -
    -Input: [1,2,3]
    -Output: 6
    -
    +

    Given an integer array nums, find three numbers whose product is maximum and return the maximum product.

     

    - -

    Example 2:

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

    Example 1:

    +
    Input: nums = [1,2,3]
    +Output: 6
    +

    Example 2:

    +
    Input: nums = [1,2,3,4]
    +Output: 24
    +

    Example 3:

    +
    Input: nums = [-1,-2,-3]
    +Output: -6
     
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. The length of the given array will be in range [3,104] and all elements are in the range [-1000, 1000].
    2. -
    3. Multiplication of any three numbers in the input won't exceed the range of 32-bit signed integer.
    4. -
    - -

     

    +
      +
    • 3 <= nums.length <= 104
    • +
    • -1000 <= nums[i] <= 1000
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/minimum-depth-of-binary-tree/README.md b/problems/minimum-depth-of-binary-tree/README.md index 6bbff7113..8f8be211b 100644 --- a/problems/minimum-depth-of-binary-tree/README.md +++ b/problems/minimum-depth-of-binary-tree/README.md @@ -36,7 +36,7 @@

    Constraints:

      -
    • The number of nodes in the tree is in the range [0, 104].
    • +
    • The number of nodes in the tree is in the range [0, 105].
    • -1000 <= Node.val <= 1000
    diff --git a/problems/minimum-window-substring/README.md b/problems/minimum-window-substring/README.md index fd1081335..12f62672f 100644 --- a/problems/minimum-window-substring/README.md +++ b/problems/minimum-window-substring/README.md @@ -11,22 +11,29 @@ ## [76. Minimum Window Substring (Hard)](https://leetcode.com/problems/minimum-window-substring "最小覆盖子串") -

    Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).

    +

    Given two strings s and t, return the minimum window in s which will contain all the characters in t. If there is no such window in s that covers all characters in t, return the empty string "".

    -

    Example:

    +

    Note that If there is such a window, it is guaranteed that there will always be only one unique minimum window in s.

    -
    -Input: S = "ADOBECODEBANC", T = "ABC"
    -Output: "BANC"
    +

     

    +

    Example 1:

    +
    Input: s = "ADOBECODEBANC", t = "ABC"
    +Output: "BANC"
    +

    Example 2:

    +
    Input: s = "a", t = "a"
    +Output: "a"
     
    - -

    Note:

    +

     

    +

    Constraints:

      -
    • If there is no such window in S that covers all characters in T, return the empty string "".
    • -
    • If there is such window, you are guaranteed that there will always be only one unique minimum window in S.
    • +
    • 1 <= s.length, t.length <= 105
    • +
    • s and t consist of English letters.
    +

     

    +Follow up: Could you find an algorithm that runs in O(n) time? + ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/missing-ranges/README.md b/problems/missing-ranges/README.md index f99e5676f..484395253 100644 --- a/problems/missing-ranges/README.md +++ b/problems/missing-ranges/README.md @@ -24,4 +24,4 @@ [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Summary Ranges](../summary-ranges) (Medium) + 1. [Summary Ranges](../summary-ranges) (Easy) diff --git a/problems/number-of-boomerangs/README.md b/problems/number-of-boomerangs/README.md index 607602129..9c3aea724 100644 --- a/problems/number-of-boomerangs/README.md +++ b/problems/number-of-boomerangs/README.md @@ -9,29 +9,49 @@                  [Next >](../find-all-numbers-disappeared-in-an-array "Find All Numbers Disappeared in an Array") -## [447. Number of Boomerangs (Easy)](https://leetcode.com/problems/number-of-boomerangs "回旋镖的数量") +## [447. Number of Boomerangs (Medium)](https://leetcode.com/problems/number-of-boomerangs "回旋镖的数量") -

    Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of the tuple matters).

    +

    You are given n points in the plane that are all distinct, where points[i] = [xi, yi]. A boomerang is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of the tuple matters).

    -

    Find the number of boomerangs. You may assume that n will be at most 500 and coordinates of points are all in the range [-10000, 10000] (inclusive).

    +

    Return the number of boomerangs.

    -

    Example:

    +

     

    +

    Example 1:

    + +
    +Input: points = [[0,0],[1,0],[2,0]]
    +Output: 2
    +Explanation: The two boomerangs are [[1,0],[0,0],[2,0]] and [[1,0],[2,0],[0,0]].
    +
    + +

    Example 2:

    -Input:
    -[[0,0],[1,0],[2,0]]
    +Input: points = [[1,1],[2,2],[3,3]]
    +Output: 2
    +
    -Output: -2 +

    Example 3:

    -Explanation: -The two boomerangs are [[1,0],[0,0],[2,0]] and [[1,0],[2,0],[0,0]] +
    +Input: points = [[1,1]]
    +Output: 0
     

     

    +

    Constraints:

    + +
      +
    • n == points.length
    • +
    • 1 <= n <= 500
    • +
    • points[i].length == 2
    • +
    • -104 <= xi, yi <= 104
    • +
    • All the points are unique.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Line Reflection](../line-reflection) (Medium) diff --git a/problems/number-of-longest-increasing-subsequence/README.md b/problems/number-of-longest-increasing-subsequence/README.md index f71e06b98..590de3f69 100644 --- a/problems/number-of-longest-increasing-subsequence/README.md +++ b/problems/number-of-longest-increasing-subsequence/README.md @@ -35,7 +35,7 @@

    Constraints:

      -
    • 0 <= nums.length <= 2000
    • +
    • 1 <= nums.length <= 2000
    • -106 <= nums[i] <= 106
    diff --git a/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md b/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md new file mode 100644 index 000000000..f0d78492d --- /dev/null +++ b/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md @@ -0,0 +1,93 @@ + + + + + + + +[< Previous](../count-substrings-that-differ-by-one-character "Count Substrings That Differ by One Character") +                 +[Next >](../check-array-formation-through-concatenation "Check Array Formation Through Concatenation") + +## [1639. Number of Ways to Form a Target String Given a Dictionary (Hard)](https://leetcode.com/problems/number-of-ways-to-form-a-target-string-given-a-dictionary "通过给定词典构造目标字符串的方案数") + +

    You are given a list of strings of the same length words and a string target.

    + +

    Your task is to form target using the given words under the following rules:

    + +
      +
    • target should be formed from left to right.
    • +
    • To form the ith character (0-indexed) of target, you can choose the kth character of the jth string in words if target[i] = words[j][k].
    • +
    • Once you use the kth character of the jth string of words, you can no longer use the xth character of any string in words where x <= k. In other words, all characters to the left of or at index k become unusuable for every string.
    • +
    • Repeat the process until you form the string target.
    • +
    + +

    Notice that you can use multiple characters from the same string in words provided the conditions above are met.

    + +

    Return the number of ways to form target from words. Since the answer may be too large, return it modulo 109 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: words = ["acca","bbbb","caca"], target = "aba"
    +Output: 6
    +Explanation: There are 6 ways to form target.
    +"aba" -> index 0 ("acca"), index 1 ("bbbb"), index 3 ("caca")
    +"aba" -> index 0 ("acca"), index 2 ("bbbb"), index 3 ("caca")
    +"aba" -> index 0 ("acca"), index 1 ("bbbb"), index 3 ("acca")
    +"aba" -> index 0 ("acca"), index 2 ("bbbb"), index 3 ("acca")
    +"aba" -> index 1 ("caca"), index 2 ("bbbb"), index 3 ("acca")
    +"aba" -> index 1 ("caca"), index 2 ("bbbb"), index 3 ("caca")
    +
    + +

    Example 2:

    + +
    +Input: words = ["abba","baab"], target = "bab"
    +Output: 4
    +Explanation: There are 4 ways to form target.
    +"bab" -> index 0 ("baab"), index 1 ("baab"), index 2 ("abba")
    +"bab" -> index 0 ("baab"), index 1 ("baab"), index 3 ("baab")
    +"bab" -> index 0 ("baab"), index 2 ("baab"), index 3 ("baab")
    +"bab" -> index 1 ("abba"), index 2 ("baab"), index 3 ("baab")
    +
    + +

    Example 3:

    + +
    +Input: words = ["abcd"], target = "abcd"
    +Output: 1
    +
    + +

    Example 4:

    + +
    +Input: words = ["abab","baba","abba","baab"], target = "abba"
    +Output: 16
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 1000
    • +
    • 1 <= words[i].length <= 1000
    • +
    • All strings in words have the same length.
    • +
    • 1 <= target.length <= 1000
    • +
    • words[i] and target contain only lowercase English letters.
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +For each index i, store the frequency of each character in the ith row. +
    + +
    +Hint 2 +Use dynamic programing to calculate the number of ways to get the target string using the frequency array, +
    diff --git a/problems/path-with-minimum-effort/README.md b/problems/path-with-minimum-effort/README.md new file mode 100644 index 000000000..1b0bbd4e9 --- /dev/null +++ b/problems/path-with-minimum-effort/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../arithmetic-subarrays "Arithmetic Subarrays") +                 +[Next >](../rank-transform-of-a-matrix "Rank Transform of a Matrix") + +## [1631. Path With Minimum Effort (Medium)](https://leetcode.com/problems/path-with-minimum-effort "最小体力消耗路径") + +

    You are a hiker preparing for an upcoming hike. You are given heights, a 2D array of size rows x columns, where heights[row][col] represents the height of cell (row, col). You are situated in the top-left cell, (0, 0), and you hope to travel to the bottom-right cell, (rows-1, columns-1) (i.e., 0-indexed). You can move up, down, left, or right, and you wish to find a route that requires the minimum effort.

    + +

    A route's effort is the maximum absolute difference in heights between two consecutive cells of the route.

    + +

    Return the minimum effort required to travel from the top-left cell to the bottom-right cell.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: heights = [[1,2,2],[3,8,2],[5,3,5]]
    +Output: 2
    +Explanation: The route of [1,3,5,3,5] has a maximum absolute difference of 2 in consecutive cells.
    +This is better than the route of [1,2,2,2,5], where the maximum absolute difference is 3.
    +
    + +

    Example 2:

    + +

    + +
    +Input: heights = [[1,2,3],[3,8,4],[5,3,5]]
    +Output: 1
    +Explanation: The route of [1,2,3,4,5] has a maximum absolute difference of 1 in consecutive cells, which is better than route [1,3,5,3,5].
    +
    + +

    Example 3:

    + +
    +Input: heights = [[1,2,1,1,1],[1,2,1,2,1],[1,2,1,2,1],[1,2,1,2,1],[1,1,1,2,1]]
    +Output: 0
    +Explanation: This route does not require any effort.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • rows == heights.length
    • +
    • columns == heights[i].length
    • +
    • 1 <= rows, columns <= 100
    • +
    • 1 <= heights[i][j] <= 106
    • +
    + +### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Consider the grid as a graph, where adjacent cells have an edge with cost of the difference between the cells. +
    + +
    +Hint 2 +If you are given threshold k, check if it is possible to go from (0, 0) to (n-1, m-1) using only edges of ≤ k cost. +
    + +
    +Hint 3 +Binary search the k value. +
    diff --git a/problems/percentage-of-users-attended-a-contest/README.md b/problems/percentage-of-users-attended-a-contest/README.md new file mode 100644 index 000000000..98bffa828 --- /dev/null +++ b/problems/percentage-of-users-attended-a-contest/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../rank-transform-of-a-matrix "Rank Transform of a Matrix") +                 +[Next >](../add-two-polynomials-represented-as-linked-lists "Add Two Polynomials Represented as Linked Lists") + +## [1633. Percentage of Users Attended a Contest (Easy)](https://leetcode.com/problems/percentage-of-users-attended-a-contest "各赛事的用户注册率") + + diff --git a/problems/percentage-of-users-attended-a-contest/mysql_schemas.sql b/problems/percentage-of-users-attended-a-contest/mysql_schemas.sql new file mode 100644 index 000000000..722f57248 --- /dev/null +++ b/problems/percentage-of-users-attended-a-contest/mysql_schemas.sql @@ -0,0 +1,19 @@ +Create table If Not Exists Users (user_id int, user_name varchar(20)); +Create table If Not Exists Register (contest_id int, user_id int); +Truncate table Users; +insert into Users (user_id, user_name) values ('6', 'Alice'); +insert into Users (user_id, user_name) values ('2', 'Bob'); +insert into Users (user_id, user_name) values ('7', 'Alex'); +Truncate table Register; +insert into Register (contest_id, user_id) values ('215', '6'); +insert into Register (contest_id, user_id) values ('209', '2'); +insert into Register (contest_id, user_id) values ('208', '2'); +insert into Register (contest_id, user_id) values ('210', '6'); +insert into Register (contest_id, user_id) values ('208', '6'); +insert into Register (contest_id, user_id) values ('209', '7'); +insert into Register (contest_id, user_id) values ('209', '6'); +insert into Register (contest_id, user_id) values ('215', '7'); +insert into Register (contest_id, user_id) values ('208', '7'); +insert into Register (contest_id, user_id) values ('210', '2'); +insert into Register (contest_id, user_id) values ('207', '2'); +insert into Register (contest_id, user_id) values ('210', '7'); diff --git a/problems/permutation-sequence/README.md b/problems/permutation-sequence/README.md index 16251d4d3..57ba1e116 100644 --- a/problems/permutation-sequence/README.md +++ b/problems/permutation-sequence/README.md @@ -9,11 +9,11 @@                  [Next >](../rotate-list "Rotate List") -## [60. Permutation Sequence (Hard)](https://leetcode.com/problems/permutation-sequence "第k个排列") +## [60. Permutation Sequence (Hard)](https://leetcode.com/problems/permutation-sequence "排列序列") -

    The set [1,2,3,...,n] contains a total of n! unique permutations.

    +

    The set [1, 2, 3, ..., n] contains a total of n! unique permutations.

    -

    By listing and labeling all of the permutations in order, we get the following sequence for n = 3:

    +

    By listing and labeling all of the permutations in order, we get the following sequence for n = 3:

    1. "123"
    2. @@ -24,28 +24,26 @@
    3. "321"
    -

    Given n and k, return the kth permutation sequence.

    - -

    Note:

    - -
      -
    • Given n will be between 1 and 9 inclusive.
    • -
    • Given k will be between 1 and n! inclusive.
    • -
    +

    Given n and k, return the kth permutation sequence.

    +

     

    Example 1:

    - -
    -Input: n = 3, k = 3
    -Output: "213"
    +
    Input: n = 3, k = 3
    +Output: "213"
    +

    Example 2:

    +
    Input: n = 4, k = 9
    +Output: "2314"
    +

    Example 3:

    +
    Input: n = 3, k = 1
    +Output: "123"
     
    +

     

    +

    Constraints:

    -

    Example 2:

    - -
    -Input: n = 4, k = 9
    -Output: "2314"
    -
    +
      +
    • 1 <= n <= 9
    • +
    • 1 <= k <= n!
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/permutations-ii/README.md b/problems/permutations-ii/README.md index 2aa447990..e5a4f804b 100644 --- a/problems/permutations-ii/README.md +++ b/problems/permutations-ii/README.md @@ -11,20 +11,34 @@ ## [47. Permutations II (Medium)](https://leetcode.com/problems/permutations-ii "全排列 II") -

    Given a collection of numbers that might contain duplicates, return all possible unique permutations.

    +

    Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order.

    -

    Example:

    +

     

    +

    Example 1:

    -Input: [1,1,2]
    +Input: nums = [1,1,2]
     Output:
    -[
    -  [1,1,2],
    -  [1,2,1],
    -  [2,1,1]
    -]
    +[[1,1,2],
    + [1,2,1],
    + [2,1,1]]
     
    +

    Example 2:

    + +
    +Input: nums = [1,2,3]
    +Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 8
    • +
    • -10 <= nums[i] <= 10
    • +
    + ### Related Topics [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/populating-next-right-pointers-in-each-node/README.md b/problems/populating-next-right-pointers-in-each-node/README.md index 06b846950..24f5ca19a 100644 --- a/problems/populating-next-right-pointers-in-each-node/README.md +++ b/problems/populating-next-right-pointers-in-each-node/README.md @@ -57,6 +57,7 @@ struct Node { ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions 1. [Populating Next Right Pointers in Each Node II](../populating-next-right-pointers-in-each-node-ii) (Medium) diff --git a/problems/rank-transform-of-a-matrix/README.md b/problems/rank-transform-of-a-matrix/README.md new file mode 100644 index 000000000..f3ff32117 --- /dev/null +++ b/problems/rank-transform-of-a-matrix/README.md @@ -0,0 +1,94 @@ + + + + + + + +[< Previous](../path-with-minimum-effort "Path With Minimum Effort") +                 +[Next >](../percentage-of-users-attended-a-contest "Percentage of Users Attended a Contest") + +## [1632. Rank Transform of a Matrix (Hard)](https://leetcode.com/problems/rank-transform-of-a-matrix "矩阵转换后的秩") + +

    Given an m x n matrix, return a new matrix answer where answer[row][col] is the rank of matrix[row][col].

    + +

    The rank is an integer that represents how large an element is compared to other elements. It is calculated using the following rules:

    + +
      +
    • The rank is an integer starting from 1.
    • +
    • If two elements p and q are in the same row or column, then: +
        +
      • If p < q then rank(p) < rank(q)
      • +
      • If p == q then rank(p) == rank(q)
      • +
      • If p > q then rank(p) > rank(q)
      • +
      +
    • +
    • The rank should be as small as possible.
    • +
    + +

    It is guaranteed that answer is unique under the given rules.

    + +

     

    +

    Example 1:

    + +
    +Input: matrix = [[1,2],[3,4]]
    +Output: [[1,2],[2,3]]
    +Explanation:
    +The rank of matrix[0][0] is 1 because it is the smallest integer in its row and column.
    +The rank of matrix[0][1] is 2 because matrix[0][1] > matrix[0][0] and matrix[0][0] is rank 1.
    +The rank of matrix[1][0] is 2 because matrix[1][0] > matrix[0][0] and matrix[0][0] is rank 1.
    +The rank of matrix[1][1] is 3 because matrix[1][1] > matrix[0][1], matrix[1][1] > matrix[1][0], and both matrix[0][1] and matrix[1][0] are rank 2.
    +
    + +

    Example 2:

    + +
    +Input: matrix = [[7,7],[7,7]]
    +Output: [[1,1],[1,1]]
    +
    + +

    Example 3:

    + +
    +Input: matrix = [[20,-21,14],[-19,4,19],[22,-47,24],[-19,4,19]]
    +Output: [[4,2,3],[1,3,4],[5,1,6],[1,3,4]]
    +
    + +

    Example 4:

    + +
    +Input: matrix = [[7,3,6],[1,4,5],[9,8,2]]
    +Output: [[5,1,4],[1,2,3],[6,3,1]]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == matrix.length
    • +
    • n == matrix[i].length
    • +
    • 1 <= m, n <= 500
    • +
    • -109 <= matrix[row][col] <= 109
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Union Find](../../tag/union-find/README.md)] + +### Hints +
    +Hint 1 +Sort the cells by value and process them in increasing order. +
    + +
    +Hint 2 +The rank of a cell is the maximum rank in its row and column plus one. +
    + +
    +Hint 3 +Handle the equal cells by treating them as components using a union-find data structure. +
    diff --git a/problems/recover-binary-search-tree/README.md b/problems/recover-binary-search-tree/README.md index 81af2a3a8..340e554f7 100644 --- a/problems/recover-binary-search-tree/README.md +++ b/problems/recover-binary-search-tree/README.md @@ -11,55 +11,33 @@ ## [99. Recover Binary Search Tree (Hard)](https://leetcode.com/problems/recover-binary-search-tree "恢复二叉搜索树") -

    Two elements of a binary search tree (BST) are swapped by mistake.

    +

    You are given the root of a binary search tree (BST), where exactly two nodes of the tree were swapped by mistake. Recover the tree without changing its structure.

    -

    Recover the tree without changing its structure.

    +

    Follow up: A solution using O(n) space is pretty straight forward. Could you devise a constant space solution?

    +

     

    Example 1:

    - +
    -Input: [1,3,null,null,2]
    -
    -   1
    -  /
    - 3
    -  \
    -   2
    -
    +Input: root = [1,3,null,null,2]
     Output: [3,1,null,null,2]
    -
    -   3
    -  /
    - 1
    -  \
    -   2
    +Explanation: 3 cannot be a left child of 1 because 3 > 1. Swapping 1 and 3 makes the BST valid.
     

    Example 2:

    - +
    -Input: [3,1,4,null,null,2]
    -
    -  3
    - / \
    -1   4
    -   /
    -  2
    -
    +Input: root = [3,1,4,null,null,2]
     Output: [2,1,4,null,null,3]
    -
    -  2
    - / \
    -1   4
    -   /
    -  3
    +Explanation: 2 cannot be in the right subtree of 3 because 2 < 3. Swapping 2 and 3 makes the BST valid.
     
    -

    Follow up:

    +

     

    +

    Constraints:

      -
    • A solution using O(n) space is pretty straight forward.
    • -
    • Could you devise a constant space solution?
    • +
    • The number of nodes in the tree is in the range [2, 1000].
    • +
    • -231 <= Node.val <= 231 - 1
    ### Related Topics diff --git a/problems/regular-expression-matching/README.md b/problems/regular-expression-matching/README.md index 0a3a2d4d6..5412bf285 100644 --- a/problems/regular-expression-matching/README.md +++ b/problems/regular-expression-matching/README.md @@ -66,8 +66,9 @@
    • 0 <= s.length <= 20
    • 0 <= p.length <= 30
    • -
    • s contains only lowercase English letters.
    • -
    • p contains only lowercase English letters, '.', and '*'.
    • +
    • s contains only lowercase English letters.
    • +
    • p contains only lowercase English letters, '.', and '*'.
    • +
    • It is guaranteed for each appearance of the character '*', there will be a previous valid character to match.
    ### Related Topics diff --git a/problems/remove-duplicates-from-sorted-array-ii/README.md b/problems/remove-duplicates-from-sorted-array-ii/README.md index e7bd74569..0643564e0 100644 --- a/problems/remove-duplicates-from-sorted-array-ii/README.md +++ b/problems/remove-duplicates-from-sorted-array-ii/README.md @@ -13,32 +13,13 @@

    Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length.

    -

    Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.

    - -

    Example 1:

    - -
    -Given nums = [1,1,1,2,2,3],
    -
    -Your function should return length = 5, with the first five elements of nums being 1, 1, 2, 2 and 3 respectively.
    -
    -It doesn't matter what you leave beyond the returned length.
    - -

    Example 2:

    - -
    -Given nums = [0,0,1,1,1,1,2,3,3],
    -
    -Your function should return length = 7, with the first seven elements of nums being modified to 0, 0, 1, 1, 2, 3 and 3 respectively.
    -
    -It doesn't matter what values are set beyond the returned length.
    -
    +

    Do not allocate extra space for another array; you must do this by modifying the input array in-place with O(1) extra memory.

    Clarification:

    -

    Confused why the returned value is an integer but your answer is an array?

    +

    Confused why the returned value is an integer, but your answer is an array?

    -

    Note that the input array is passed in by reference, which means modification to the input array will be known to the caller as well.

    +

    Note that the input array is passed in by reference, which means a modification to the input array will be known to the caller.

    Internally you can think of this:

    @@ -53,6 +34,32 @@ for (int i = 0; i < len; i++) { }
    +

     

    +

    Example 1:

    + +
    +Input: nums = [1,1,1,2,2,3]
    +Output: 5, nums = [1,1,2,2,3]
    +Explanation: Your function should return length = 5, with the first five elements of nums being 1, 1, 2, 2 and 3 respectively. It doesn't matter what you leave beyond the returned length.
    +
    + +

    Example 2:

    + +
    +Input: nums = [0,0,1,1,1,1,2,3,3]
    +Output: 7, nums = [0,0,1,1,2,3,3]
    +Explanation: Your function should return length = 7, with the first seven elements of nums being modified to 0, 0, 1, 1, 2, 3 and 3 respectively. It doesn't matter what values are set beyond the returned length.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= nums.length <= 3 * 104
    • +
    • -104 <= nums[i] <= 104
    • +
    • nums is sorted in ascending order.
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/shuffle-an-array/README.md b/problems/shuffle-an-array/README.md index 0600b6030..b8383b48c 100644 --- a/problems/shuffle-an-array/README.md +++ b/problems/shuffle-an-array/README.md @@ -11,25 +11,43 @@ ## [384. Shuffle an Array (Medium)](https://leetcode.com/problems/shuffle-an-array "打乱数组") -

    Shuffle a set of numbers without duplicates. -

    +

    Given an integer array nums, design an algorithm to randomly shuffle the array.

    -

    Example: -

    -// Init an array with set 1, 2, and 3.
    -int[] nums = {1,2,3};
    -Solution solution = new Solution(nums);
    +

    Implement the Solution class:

    + +
      +
    • Solution(int[] nums) Initializes the object with the integer array nums.
    • +
    • int[] reset() Resets the array to its original configuration and returns it.
    • +
    • int[] shuffle() Returns a random shuffling of the array.
    • +
    -// Shuffle the array [1,2,3] and return its result. Any permutation of [1,2,3] must equally likely to be returned. -solution.shuffle(); +

     

    +

    Example 1:

    -// Resets the array back to its original configuration [1,2,3]. -solution.reset(); +
    +Input
    +["Solution", "shuffle", "reset", "shuffle"]
    +[[[1, 2, 3]], [], [], []]
    +Output
    +[null, [3, 1, 2], [1, 2, 3], [1, 3, 2]]
    +
    +Explanation
    +Solution solution = new Solution([1, 2, 3]);
    +solution.shuffle();    // Shuffle the array [1,2,3] and return its result. Any permutation of [1,2,3] must be equally likely to be returned. Example: return [3, 1, 2]
    +solution.reset();      // Resets the array back to its original configuration [1,2,3]. Return [1, 2, 3]
    +solution.shuffle();    // Returns the random shuffling of array [1,2,3]. Example: return [1, 3, 2]
     
    -// Returns the random shuffling of array [1,2,3].
    -solution.shuffle();
     
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 200
    • +
    • -106 <= nums[i] <= 106
    • +
    • All the elements of nums are unique.
    • +
    • At most 5 * 104 calls will be made to reset and shuffle.
    • +
    ### Hints
    diff --git a/problems/slowest-key/README.md b/problems/slowest-key/README.md new file mode 100644 index 000000000..42f86f821 --- /dev/null +++ b/problems/slowest-key/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../design-an-expression-tree-with-evaluate-function "Design an Expression Tree With Evaluate Function") +                 +[Next >](../arithmetic-subarrays "Arithmetic Subarrays") + +## [1629. Slowest Key (Easy)](https://leetcode.com/problems/slowest-key "按键持续时间最长的键") + +

    A newly designed keypad was tested, where a tester pressed a sequence of n keys, one at a time.

    + +

    You are given a string keysPressed of length n, where keysPressed[i] was the ith key pressed in the testing sequence, and a sorted list releaseTimes, where releaseTimes[i] was the time the ith key was released. Both arrays are 0-indexed. The 0th key was pressed at the time 0, and every subsequent key was pressed at the exact time the previous key was released.

    + +

    The tester wants to know the key of the keypress that had the longest duration. The ith keypress had a duration of releaseTimes[i] - releaseTimes[i - 1], and the 0th keypress had a duration of releaseTimes[0].

    + +

    Note that the same key could have been pressed multiple times during the test, and these multiple presses of the same key may not have had the same duration.

    + +

    Return the key of the keypress that had the longest duration. If there are multiple such keypresses, return the lexicographically largest key of the keypresses.

    + +

     

    +

    Example 1:

    + +
    +Input: releaseTimes = [9,29,49,50], keysPressed = "cbcd"
    +Output: "c"
    +Explanation: The keypresses were as follows:
    +Keypress for 'c' had a duration of 9 (pressed at time 0 and released at time 9).
    +Keypress for 'b' had a duration of 29 - 9 = 20 (pressed at time 9 right after the release of the previous character and released at time 29).
    +Keypress for 'c' had a duration of 49 - 29 = 20 (pressed at time 29 right after the release of the previous character and released at time 49).
    +Keypress for 'd' had a duration of 50 - 49 = 1 (pressed at time 49 right after the release of the previous character and released at time 50).
    +The longest of these was the keypress for 'b' and the second keypress for 'c', both with duration 20.
    +'c' is lexicographically larger than 'b', so the answer is 'c'.
    +
    + +

    Example 2:

    + +
    +Input: releaseTimes = [12,23,36,46,62], keysPressed = "spuda"
    +Output: "a"
    +Explanation: The keypresses were as follows:
    +Keypress for 's' had a duration of 12.
    +Keypress for 'p' had a duration of 23 - 12 = 11.
    +Keypress for 'u' had a duration of 36 - 23 = 13.
    +Keypress for 'd' had a duration of 46 - 36 = 10.
    +Keypress for 'a' had a duration of 62 - 46 = 16.
    +The longest of these was the keypress for 'a' with duration 16.
    + +

     

    +

    Constraints:

    + +
      +
    • releaseTimes.length == n
    • +
    • keysPressed.length == n
    • +
    • 2 <= n <= 1000
    • +
    • 1 <= releaseTimes[i] <= 109
    • +
    • releaseTimes[i] < releaseTimes[i+1]
    • +
    • keysPressed contains only lowercase English letters.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Get for each press its key and amount of time taken. +
    + +
    +Hint 2 +Iterate on the presses, maintaining the answer so far. +
    + +
    +Hint 3 +The current press will change the answer if and only if its amount of time taken is longer than that of the previous answer, or they are equal but the key is larger than that of the previous answer. +
    diff --git a/problems/smallest-integer-divisible-by-k/README.md b/problems/smallest-integer-divisible-by-k/README.md index 92ccb4cba..54898a3ea 100644 --- a/problems/smallest-integer-divisible-by-k/README.md +++ b/problems/smallest-integer-divisible-by-k/README.md @@ -11,39 +11,42 @@ ## [1015. Smallest Integer Divisible by K (Medium)](https://leetcode.com/problems/smallest-integer-divisible-by-k "可被 K 整除的最小整数") -

    Given a positive integer K, you need find the smallest positive integer N such that N is divisible by K, and N only contains the digit 1.

    +

    Given a positive integer K, you need to find the length of the smallest positive integer N such that N is divisible by K, and N only contains the digit 1.

    -

    Return the length of N.  If there is no such N, return -1.

    +

    Return the length of N. If there is no such N, return -1.

    -

     

    +

    Note: N may not fit in a 64-bit signed integer.

    +

     

    Example 1:

    -Input: 1
    +Input: K = 1
     Output: 1
    -Explanation: The smallest answer is N = 1, which has length 1.
    +Explanation: The smallest answer is N = 1, which has length 1. +

    Example 2:

    -Input: 2
    +Input: K = 2
     Output: -1
    -Explanation: There is no such positive integer N divisible by 2.
    +Explanation: There is no such positive integer N divisible by 2. +

    Example 3:

    -Input: 3
    +Input: K = 3
     Output: 3
    -Explanation: The smallest answer is N = 111, which has length 3.
    +Explanation: The smallest answer is N = 111, which has length 3. +

     

    - -

    Note:

    +

    Constraints:

      -
    • 1 <= K <= 10^5
    • +
    • 1 <= K <= 105
    ### Related Topics diff --git a/problems/sort-array-by-increasing-frequency/README.md b/problems/sort-array-by-increasing-frequency/README.md new file mode 100644 index 000000000..82ede2513 --- /dev/null +++ b/problems/sort-array-by-increasing-frequency/README.md @@ -0,0 +1,62 @@ + + + + + + + +[< Previous](../hopper-company-queries-i "Hopper Company Queries I") +                 +[Next >](../widest-vertical-area-between-two-points-containing-no-points "Widest Vertical Area Between Two Points Containing No Points") + +## [1636. Sort Array by Increasing Frequency (Easy)](https://leetcode.com/problems/sort-array-by-increasing-frequency "按照频率将数组升序排序") + +

    Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same frequency, sort them in decreasing order.

    + +

    Return the sorted array.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,1,2,2,2,3]
    +Output: [3,1,1,2,2,2]
    +Explanation: '3' has a frequency of 1, '1' has a frequency of 2, and '2' has a frequency of 3.
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,3,1,3,2]
    +Output: [1,3,3,2,2]
    +Explanation: '2' and '3' both have a frequency of 2, so they are sorted in decreasing order.
    +
    + +

    Example 3:

    + +
    +Input: nums = [-1,1,-6,4,5,-6,1,4,1]
    +Output: [5,-1,4,4,-6,-6,1,1,1]
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • -100 <= nums[i] <= 100
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Count the frequency of each value. +
    + +
    +Hint 2 +Use a custom comparator to compare values by their frequency. If two values have the same frequency, compare their values. +
    diff --git a/problems/subarray-sum-equals-k/README.md b/problems/subarray-sum-equals-k/README.md index 40472369f..0b90f720e 100644 --- a/problems/subarray-sum-equals-k/README.md +++ b/problems/subarray-sum-equals-k/README.md @@ -11,21 +11,23 @@ ## [560. Subarray Sum Equals K (Medium)](https://leetcode.com/problems/subarray-sum-equals-k "和为K的子数组") -

    Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.

    +

    Given an array of integers nums and an integer k, return the total number of continuous subarrays whose sum equals to k.

    -

    Example 1:

    - -
    -Input:nums = [1,1,1], k = 2
    -Output: 2
    +

     

    +

    Example 1:

    +
    Input: nums = [1,1,1], k = 2
    +Output: 2
    +

    Example 2:

    +
    Input: nums = [1,2,3], k = 3
    +Output: 2
     
    -

     

    Constraints:

      -
    • The length of the array is in range [1, 20,000].
    • -
    • The range of numbers in the array is [-1000, 1000] and the range of the integer k is [-1e7, 1e7].
    • +
    • 1 <= nums.length <= 2 * 104
    • +
    • -1000 <= nums[i] <= 1000
    • +
    • -107 <= k <= 107
    ### Related Topics diff --git a/problems/summary-ranges/README.md b/problems/summary-ranges/README.md index 8f63f6cef..4c7a94de8 100644 --- a/problems/summary-ranges/README.md +++ b/problems/summary-ranges/README.md @@ -9,7 +9,7 @@                  [Next >](../majority-element-ii "Majority Element II") -## [228. Summary Ranges (Medium)](https://leetcode.com/problems/summary-ranges "汇总区间") +## [228. Summary Ranges (Easy)](https://leetcode.com/problems/summary-ranges "汇总区间")

    You are given a sorted unique integer array nums.

    @@ -74,6 +74,7 @@
  • 0 <= nums.length <= 20
  • -231 <= nums[i] <= 231 - 1
  • All the values of nums are unique.
  • +
  • nums is sorted in ascending order.
  • ### Related Topics diff --git a/problems/trapping-rain-water/README.md b/problems/trapping-rain-water/README.md index 0a32aec41..04053ca4f 100644 --- a/problems/trapping-rain-water/README.md +++ b/problems/trapping-rain-water/README.md @@ -19,7 +19,7 @@
     Input: height = [0,1,0,2,1,0,1,3,2,1,2,1]
     Output: 6
    -Explanation: The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped.
    +Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped.
     

    Example 2:

    diff --git a/problems/widest-vertical-area-between-two-points-containing-no-points/README.md b/problems/widest-vertical-area-between-two-points-containing-no-points/README.md new file mode 100644 index 000000000..83b343754 --- /dev/null +++ b/problems/widest-vertical-area-between-two-points-containing-no-points/README.md @@ -0,0 +1,58 @@ + + + + + + + +[< Previous](../sort-array-by-increasing-frequency "Sort Array by Increasing Frequency") +                 +[Next >](../count-substrings-that-differ-by-one-character "Count Substrings That Differ by One Character") + +## [1637. Widest Vertical Area Between Two Points Containing No Points (Medium)](https://leetcode.com/problems/widest-vertical-area-between-two-points-containing-no-points "两点之间不包含任何点的最宽垂直面积") + +

    Given n points on a 2D plane where points[i] = [xi, yi], Return the widest vertical area between two points such that no points are inside the area.

    + +

    A vertical area is an area of fixed-width extending infinitely along the y-axis (i.e., infinite height). The widest vertical area is the one with the maximum width.

    + +

    Note that points on the edge of a vertical area are not considered included in the area.

    + +

     

    +

    Example 1:

    +​ +
    +Input: points = [[8,7],[9,9],[7,4],[9,7]]
    +Output: 1
    +Explanation: Both the red and the blue area are optimal.
    +
    + +

    Example 2:

    + +
    +Input: points = [[3,1],[9,0],[1,0],[1,4],[5,3],[8,8]]
    +Output: 3
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == points.length
    • +
    • 2 <= n <= 105
    • +
    • points[i].length == 2
    • +
    • 0 <= xi, yi <= 109
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + +### Hints +
    +Hint 1 +Try sorting the points +
    + +
    +Hint 2 +Think is the y-axis of a point relevant +
    diff --git a/readme/1-300.md b/readme/1-300.md index 7ee3c1f83..12560305c 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -129,7 +129,7 @@ LeetCode Problems' Solutions | 57 | [Insert Interval](https://leetcode.com/problems/insert-interval "插入区间") | [Go](../problems/insert-interval) | Medium | | 58 | [Length of Last Word](https://leetcode.com/problems/length-of-last-word "最后一个单词的长度") | [Go](../problems/length-of-last-word) | Easy | | 59 | [Spiral Matrix II](https://leetcode.com/problems/spiral-matrix-ii "螺旋矩阵 II") | [Go](../problems/spiral-matrix-ii) | Medium | -| 60 | [Permutation Sequence](https://leetcode.com/problems/permutation-sequence "第k个排列") | [Go](../problems/permutation-sequence) | Hard | +| 60 | [Permutation Sequence](https://leetcode.com/problems/permutation-sequence "排列序列") | [Go](../problems/permutation-sequence) | Hard | | 61 | [Rotate List](https://leetcode.com/problems/rotate-list "旋转链表") | [Go](../problems/rotate-list) | Medium | | 62 | [Unique Paths](https://leetcode.com/problems/unique-paths "不同路径") | [Go](../problems/unique-paths) | Medium | | 63 | [Unique Paths II](https://leetcode.com/problems/unique-paths-ii "不同路径 II") | [Go](../problems/unique-paths-ii) | Medium | @@ -232,7 +232,7 @@ LeetCode Problems' Solutions | 160 | [Intersection of Two Linked Lists](https://leetcode.com/problems/intersection-of-two-linked-lists "相交链表") | [Go](../problems/intersection-of-two-linked-lists) | Easy | | 161 | [One Edit Distance](https://leetcode.com/problems/one-edit-distance "相隔为 1 的编辑距离") 🔒 | [Go](../problems/one-edit-distance) | Medium | | 162 | [Find Peak Element](https://leetcode.com/problems/find-peak-element "寻找峰值") | [Go](../problems/find-peak-element) | Medium | -| 163 | [Missing Ranges](https://leetcode.com/problems/missing-ranges "缺失的区间") 🔒 | [Go](../problems/missing-ranges) | Medium | +| 163 | [Missing Ranges](https://leetcode.com/problems/missing-ranges "缺失的区间") 🔒 | [Go](../problems/missing-ranges) | Easy | | 164 | [Maximum Gap](https://leetcode.com/problems/maximum-gap "最大间距") | [Go](../problems/maximum-gap) | Hard | | 165 | [Compare Version Numbers](https://leetcode.com/problems/compare-version-numbers "比较版本号") | [Go](../problems/compare-version-numbers) | Medium | | 166 | [Fraction to Recurring Decimal](https://leetcode.com/problems/fraction-to-recurring-decimal "分数到小数") | [Go](../problems/fraction-to-recurring-decimal) | Medium | diff --git a/readme/301-600.md b/readme/301-600.md index c46bc56a9..b787b73b8 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -216,7 +216,7 @@ LeetCode Problems' Solutions | 444 | [Sequence Reconstruction](https://leetcode.com/problems/sequence-reconstruction "序列重建") 🔒 | [Go](../problems/sequence-reconstruction) | Medium | | 445 | [Add Two Numbers II](https://leetcode.com/problems/add-two-numbers-ii "两数相加 II") | [Go](../problems/add-two-numbers-ii) | Medium | | 446 | [Arithmetic Slices II - Subsequence](https://leetcode.com/problems/arithmetic-slices-ii-subsequence "等差数列划分 II - 子序列") | [Go](../problems/arithmetic-slices-ii-subsequence) | Hard | -| 447 | [Number of Boomerangs](https://leetcode.com/problems/number-of-boomerangs "回旋镖的数量") | [Go](../problems/number-of-boomerangs) | Easy | +| 447 | [Number of Boomerangs](https://leetcode.com/problems/number-of-boomerangs "回旋镖的数量") | [Go](../problems/number-of-boomerangs) | Medium | | 448 | [Find All Numbers Disappeared in an Array](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array "找到所有数组中消失的数字") | [Go](../problems/find-all-numbers-disappeared-in-an-array) | Easy | | 449 | [Serialize and Deserialize BST](https://leetcode.com/problems/serialize-and-deserialize-bst "序列化和反序列化二叉搜索树") | [Go](../problems/serialize-and-deserialize-bst) | Medium | | 450 | [Delete Node in a BST](https://leetcode.com/problems/delete-node-in-a-bst "删除二叉搜索树中的节点") | [Go](../problems/delete-node-in-a-bst) | Medium | diff --git a/tag/README.md b/tag/README.md index 818cbe340..e026aff3a 100644 --- a/tag/README.md +++ b/tag/README.md @@ -26,6 +26,6 @@ | 29 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 30 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 31 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 32 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | | 33 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 34 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | -| 35 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | -| 37 | [Reservoir Sampling](reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | | 38 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | +| 35 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | +| 37 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | | 38 | [Reservoir Sampling](reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | | 39 | [Memoization](memoization/README.md) | [记忆化](https://openset.github.io/tags/memoization/) | | 40 | [Suffix Array](suffix-array/README.md) | [Suffix Array](https://openset.github.io/tags/suffix-array/) | diff --git a/tag/array/README.md b/tag/array/README.md index 006edd552..d830dfbd0 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 1636 | [按照频率将数组升序排序](../../problems/sort-array-by-increasing-frequency) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | | 1629 | [按键持续时间最长的键](../../problems/slowest-key) | [[数组](../array/README.md)] | Easy | | 1619 | [删除某些元素后的数组均值](../../problems/mean-of-array-after-removing-some-elements) | [[数组](../array/README.md)] | Easy | | 1608 | [特殊数组的特征值](../../problems/special-array-with-x-elements-greater-than-or-equal-x) | [[数组](../array/README.md)] | Easy | @@ -236,7 +238,7 @@ | 243 | [最短单词距离](../../problems/shortest-word-distance) 🔒 | [[数组](../array/README.md)] | Easy | | 238 | [除自身以外数组的乘积](../../problems/product-of-array-except-self) | [[数组](../array/README.md)] | Medium | | 229 | [求众数 II](../../problems/majority-element-ii) | [[数组](../array/README.md)] | Medium | -| 228 | [汇总区间](../../problems/summary-ranges) | [[数组](../array/README.md)] | Medium | +| 228 | [汇总区间](../../problems/summary-ranges) | [[数组](../array/README.md)] | Easy | | 219 | [存在重复元素 II](../../problems/contains-duplicate-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 217 | [存在重复元素](../../problems/contains-duplicate) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 5f4c80f64..2b62f1a03 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[回溯算法](../backtracking/README.md)] | Hard | | 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[回溯算法](../backtracking/README.md)] | Medium | | 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | @@ -55,7 +56,7 @@ | 79 | [单词搜索](../../problems/word-search) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 77 | [组合](../../problems/combinations) | [[回溯算法](../backtracking/README.md)] | Medium | -| 60 | [第k个排列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 60 | [排列序列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 52 | [N皇后 II](../../problems/n-queens-ii) | [[回溯算法](../backtracking/README.md)] | Hard | | 51 | [N 皇后](../../problems/n-queens) | [[回溯算法](../backtracking/README.md)] | Hard | | 47 | [全排列 II](../../problems/permutations-ii) | [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index ffe65b9e6..f5eb15424 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1642 | [可以到达的最远建筑](../../problems/furthest-building-you-can-reach) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 37483ff32..1674caf60 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -78,6 +78,7 @@ | 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 127 | [单词接龙](../../problems/word-ladder) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 107 | [二叉树的层次遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 103 | [二叉树的锯齿形层次遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 57ce3888f..022605c7f 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -130,7 +130,7 @@ | 129 | [求根到叶子节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | | 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | diff --git a/tag/design/README.md b/tag/design/README.md index df5a1efc8..663b050ba 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1628 | [Design an Expression Tree With Evaluate Function](../../problems/design-an-expression-tree-with-evaluate-function) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard | | 1603 | [设计停车系统](../../problems/design-parking-system) | [[设计](../design/README.md)] | Easy | | 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 07df805b2..2c2a180dd 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1643 | [第 K 条最小指令](../../problems/kth-smallest-instructions) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1639 | [通过给定词典构造目标字符串的方案数](../../problems/number-of-ways-to-form-a-target-string-given-a-dictionary) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1626 | [无矛盾的最佳球队](../../problems/best-team-with-no-conflicts) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1621 | [大小为 K 的不重叠线段的数目](../../problems/number-of-sets-of-k-non-overlapping-line-segments) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -131,6 +134,7 @@ | 813 | [最大平均值和的分组](../../problems/largest-sum-of-averages) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 808 | [分汤](../../problems/soup-servings) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 801 | [使序列递增的最小交换次数](../../problems/minimum-swaps-to-make-sequences-increasing) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 799 | [香槟塔](../../problems/champagne-tower) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 790 | [多米诺和托米诺平铺](../../problems/domino-and-tromino-tiling) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 764 | [最大加号标志](../../problems/largest-plus-sign) | [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index c6f11ce31..cce72614d 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | @@ -93,7 +94,7 @@ | 463 | [岛屿的周长](../../problems/island-perimeter) | [[哈希表](../hash-table/README.md)] | Easy | | 454 | [四数相加 II](../../problems/4sum-ii) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 447 | [回旋镖的数量](../../problems/number-of-boomerangs) | [[哈希表](../hash-table/README.md)] | Easy | +| 447 | [回旋镖的数量](../../problems/number-of-boomerangs) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 438 | [找到字符串中所有字母异位词](../../problems/find-all-anagrams-in-a-string) | [[哈希表](../hash-table/README.md)] | Medium | | 409 | [最长回文串](../../problems/longest-palindrome) | [[哈希表](../hash-table/README.md)] | Easy | | 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/heap/README.md b/tag/heap/README.md index 89a7abecc..8e2580486 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1642 | [可以到达的最远建筑](../../problems/furthest-building-you-can-reach) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1439 | [有序矩阵中的第 k 个最小数组和](../../problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | [[堆](../heap/README.md)] | Hard | | 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] | Medium | | 1046 | [最后一块石头的重量](../../problems/last-stone-weight) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Easy | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index 4d131fc44..9b2fa3241 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1634 | [Add Two Polynomials Represented as Linked Lists](../../problems/add-two-polynomials-represented-as-linked-lists) 🔒 | [[链表](../linked-list/README.md)] | Medium | | 1474 | [删除链表 M 个节点之后的 N 个节点](../../problems/delete-n-nodes-after-m-nodes-of-a-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Easy | | 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)] | Easy | diff --git a/tag/math/README.md b/tag/math/README.md index 49d3b2e18..6480d4122 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1627 | [带阈值的图连通性](../../problems/graph-connectivity-with-threshold) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | | 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard | | 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -146,6 +147,7 @@ | 462 | [最少移动次数使数组元素相等 II](../../problems/minimum-moves-to-equal-array-elements-ii) | [[数学](../math/README.md)] | Medium | | 458 | [可怜的小猪](../../problems/poor-pigs) | [[数学](../math/README.md)] | Hard | | 453 | [最小移动次数使数组元素相等](../../problems/minimum-moves-to-equal-array-elements) | [[数学](../math/README.md)] | Easy | +| 447 | [回旋镖的数量](../../problems/number-of-boomerangs) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 441 | [排列硬币](../../problems/arranging-coins) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 423 | [从英文中重建数字](../../problems/reconstruct-original-digits-from-english) | [[数学](../math/README.md)] | Medium | | 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -188,7 +190,7 @@ | 69 | [x 的平方根](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 67 | [二进制求和](../../problems/add-binary) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 65 | [有效数字](../../problems/valid-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 60 | [第k个排列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 60 | [排列序列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 50 | [Pow(x, n)](../../problems/powx-n) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 29 | [两数相除](../../problems/divide-two-integers) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index be3834028..f8dcd8870 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 1637 | [两点之间不包含任何点的最宽垂直面积](../../problems/widest-vertical-area-between-two-points-containing-no-points) | [[排序](../sort/README.md)] | Medium | +| 1636 | [按照频率将数组升序排序](../../problems/sort-array-by-increasing-frequency) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | | 1630 | [等差子数组](../../problems/arithmetic-subarrays) | [[排序](../sort/README.md)] | Medium | | 1561 | [你可以获得的最大硬币数目](../../problems/maximum-number-of-coins-you-can-get) | [[排序](../sort/README.md)] | Medium | | 1528 | [重新排列字符串](../../problems/shuffle-string) | [[排序](../sort/README.md)] | Easy | diff --git a/tag/string/README.md b/tag/string/README.md index 18bd3d850..de06ccfac 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1624 | [两个相同字符之间的最长子字符串](../../problems/largest-substring-between-two-equal-characters) | [[字符串](../string/README.md)] | Easy | | 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/tags.json b/tag/tags.json index 2340dd51b..3ef270e69 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -174,6 +174,11 @@ "Slug": "binary-search-tree", "TranslatedName": "二叉搜索树" }, + { + "Name": "Rolling Hash", + "Slug": "rolling-hash", + "TranslatedName": "Rolling Hash" + }, { "Name": "Rejection Sampling", "Slug": "rejection-sampling", @@ -184,11 +189,6 @@ "Slug": "reservoir-sampling", "TranslatedName": "蓄水池抽样" }, - { - "Name": "Rolling Hash", - "Slug": "rolling-hash", - "TranslatedName": "Rolling Hash" - }, { "Name": "Memoization", "Slug": "memoization", diff --git a/tag/tree/README.md b/tag/tree/README.md index 3428bb2c5..912d25a23 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1628 | [Design an Expression Tree With Evaluate Function](../../problems/design-an-expression-tree-with-evaluate-function) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1609 | [奇偶树](../../problems/even-odd-tree) | [[树](../tree/README.md)] | Medium | | 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | @@ -138,7 +138,7 @@ | 129 | [求根到叶子节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | | 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | diff --git a/tag/trie/README.md b/tag/trie/README.md index f0436f960..b819271ee 100644 --- a/tag/trie/README.md +++ b/tag/trie/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Easy | | 1032 | [字符流](../../problems/stream-of-characters) | [[字典树](../trie/README.md)] | Hard | | 1023 | [驼峰式匹配](../../problems/camelcase-matching) | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | From aad60c40c9c722dda6ef5dfdfcaf6aad0e5fd810 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 9 Nov 2020 16:00:02 +0800 Subject: [PATCH 108/145] A: new --- README.md | 6 ++ .../README.md | 2 +- problems/binary-tree-tilt/README.md | 2 + problems/bulb-switcher/README.md | 45 ++++++--- .../README.md | 93 +++++++++++++++++++ .../README.md | 38 +++++--- .../get-maximum-in-generated-array/README.md | 78 ++++++++++++++++ problems/hopper-company-queries-ii/README.md | 14 +++ .../mysql_schemas.sql | 39 ++++++++ problems/kth-smallest-instructions/README.md | 2 +- .../README.md | 28 ++++++ .../README.md | 35 +++---- .../README.md | 2 +- .../README.md | 72 ++++++++++++++ problems/minimum-path-sum/README.md | 33 +++++-- .../README.md | 2 + problems/plus-one/README.md | 2 +- problems/power-of-three/README.md | 44 +++++---- problems/range-sum-of-bst/README.md | 36 +++---- .../README.md | 49 ++++------ .../README.md | 84 +++++++++++++++++ problems/simplify-path/README.md | 42 ++++----- problems/toeplitz-matrix/README.md | 54 +++++------ problems/two-sum-less-than-k/README.md | 2 + problems/unique-paths-ii/README.md | 38 +++++--- problems/valid-mountain-array/README.md | 65 ++++--------- problems/word-search-ii/README.md | 43 +++++---- problems/word-search/README.md | 4 +- readme/901-1200.md | 2 +- tag/README.md | 4 +- tag/array/README.md | 3 +- tag/binary-indexed-tree/README.md | 1 + tag/depth-first-search/README.md | 1 + tag/graph/README.md | 2 +- tag/greedy/README.md | 2 + tag/math/README.md | 1 + tag/ordered-map/README.md | 1 + tag/recursion/README.md | 1 + tag/segment-tree/README.md | 1 + tag/sort/README.md | 3 + tag/tags.json | 10 +- tag/tree/README.md | 3 +- tag/two-pointers/README.md | 1 + 43 files changed, 712 insertions(+), 278 deletions(-) create mode 100644 problems/create-sorted-array-through-instructions/README.md create mode 100644 problems/get-maximum-in-generated-array/README.md create mode 100644 problems/hopper-company-queries-ii/README.md create mode 100644 problems/hopper-company-queries-ii/mysql_schemas.sql create mode 100644 problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md create mode 100644 problems/minimum-deletions-to-make-character-frequencies-unique/README.md create mode 100644 problems/sell-diminishing-valued-colored-balls/README.md diff --git a/README.md b/README.md index 25c4129d8..e2e115c82 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,12 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1649 | [Create Sorted Array through Instructions](https://leetcode.com/problems/create-sorted-array-through-instructions "通过指令创建有序数组") | [Go](problems/create-sorted-array-through-instructions) | Hard | +| 1648 | [Sell Diminishing-Valued Colored Balls](https://leetcode.com/problems/sell-diminishing-valued-colored-balls "销售价值减少的颜色球") | [Go](problems/sell-diminishing-valued-colored-balls) | Medium | +| 1647 | [Minimum Deletions to Make Character Frequencies Unique](https://leetcode.com/problems/minimum-deletions-to-make-character-frequencies-unique "字符频次唯一的最小删除次数") | [Go](problems/minimum-deletions-to-make-character-frequencies-unique) | Medium | +| 1646 | [Get Maximum in Generated Array](https://leetcode.com/problems/get-maximum-in-generated-array "获取生成数组中的最大值") | [Go](problems/get-maximum-in-generated-array) | Easy | +| 1645 | [Hopper Company Queries II](https://leetcode.com/problems/hopper-company-queries-ii) 🔒 | [MySQL](problems/hopper-company-queries-ii) | Hard | +| 1644 | [Lowest Common Ancestor of a Binary Tree II](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-ii) 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-ii) | Medium | | 1643 | [Kth Smallest Instructions](https://leetcode.com/problems/kth-smallest-instructions "第 K 条最小指令") | [Go](problems/kth-smallest-instructions) | Hard | | 1642 | [Furthest Building You Can Reach](https://leetcode.com/problems/furthest-building-you-can-reach "可以到达的最远建筑") | [Go](problems/furthest-building-you-can-reach) | Medium | | 1641 | [Count Sorted Vowel Strings](https://leetcode.com/problems/count-sorted-vowel-strings "统计字典序元音字符串的数目") | [Go](problems/count-sorted-vowel-strings) | Medium | diff --git a/problems/best-time-to-buy-and-sell-stock-iv/README.md b/problems/best-time-to-buy-and-sell-stock-iv/README.md index 89fb41a4b..702f8ceb6 100644 --- a/problems/best-time-to-buy-and-sell-stock-iv/README.md +++ b/problems/best-time-to-buy-and-sell-stock-iv/README.md @@ -39,7 +39,7 @@
    • 0 <= k <= 109
    • -
    • 0 <= prices.length <= 104
    • +
    • 0 <= prices.length <= 1000
    • 0 <= prices[i] <= 1000
    diff --git a/problems/binary-tree-tilt/README.md b/problems/binary-tree-tilt/README.md index ac3877475..1f27ea1c0 100644 --- a/problems/binary-tree-tilt/README.md +++ b/problems/binary-tree-tilt/README.md @@ -60,6 +60,8 @@ Sum of every tilt : 0 + 0 + 0 + 2 + 7 + 6 = 15 ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Hints
    diff --git a/problems/bulb-switcher/README.md b/problems/bulb-switcher/README.md index b8cdb6bab..646c4a73c 100644 --- a/problems/bulb-switcher/README.md +++ b/problems/bulb-switcher/README.md @@ -11,22 +11,45 @@ ## [319. Bulb Switcher (Medium)](https://leetcode.com/problems/bulb-switcher "灯泡开关") -

    There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turning off if it's on). For the i-th round, you toggle every i bulb. For the n-th round, you only toggle the last bulb. Find how many bulbs are on after n rounds.

    +

    There are n bulbs that are initially off. You first turn on all the bulbs, then you turn off every second bulb.

    -

    Example:

    +

    On the third round, you toggle every third bulb (turning on if it's off or turning off if it's on). For the ith round, you toggle every i bulb. For the nth round, you only toggle the last bulb.

    + +

    Return the number of bulbs that are on after n rounds.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 3
    +Output: 1
    +Explanation: At first, the three bulbs are [off, off, off].
    +After the first round, the three bulbs are [on, on, on].
    +After the second round, the three bulbs are [on, off, on].
    +After the third round, the three bulbs are [on, off, off]. 
    +So you should return 1 because there is only one bulb is on.
    + +

    Example 2:

    + +
    +Input: n = 0
    +Output: 0
    +
    + +

    Example 3:

    -Input: 3
    -Output: 1 
    -Explanation: 
    -At first, the three bulbs are [off, off, off].
    -After first round, the three bulbs are [on, on, on].
    -After second round, the three bulbs are [on, off, on].
    -After third round, the three bulbs are [on, off, off]. 
    -
    -So you should return 1, because there is only one bulb is on.
    +Input: n = 1
    +Output: 1
     
    +

     

    +

    Constraints:

    + +
      +
    • 0 <= n <= 109
    • +
    + ### Related Topics [[Brainteaser](../../tag/brainteaser/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/create-sorted-array-through-instructions/README.md b/problems/create-sorted-array-through-instructions/README.md new file mode 100644 index 000000000..09d92d7f4 --- /dev/null +++ b/problems/create-sorted-array-through-instructions/README.md @@ -0,0 +1,93 @@ + + + + + + + +[< Previous](../sell-diminishing-valued-colored-balls "Sell Diminishing-Valued Colored Balls") +                 +Next > + +## [1649. Create Sorted Array through Instructions (Hard)](https://leetcode.com/problems/create-sorted-array-through-instructions "通过指令创建有序数组") + +

    Given an integer array instructions, you are asked to create a sorted array from the elements in instructions. You start with an empty container nums. For each element from left to right in instructions, insert it into nums. The cost of each insertion is the minimum of the following:

    + +
      +
    • The number of elements currently in nums that are strictly less than instructions[i].
    • +
    • The number of elements currently in nums that are strictly greater than instructions[i].
    • +
    + +

    For example, if inserting element 3 into nums = [1,2,3,5], the cost of insertion is min(2, 1) (elements 1 and 2 are less than 3, element 5 is greater than 3) and nums will become [1,2,3,3,5].

    + +

    Return the total cost to insert all elements from instructions into nums. Since the answer may be large, return it modulo 109 + 7

    + +

     

    +

    Example 1:

    + +
    +Input: instructions = [1,5,6,2]
    +Output: 1
    +Explanation: Begin with nums = [].
    +Insert 1 with cost min(0, 0) = 0, now nums = [1].
    +Insert 5 with cost min(1, 0) = 0, now nums = [1,5].
    +Insert 6 with cost min(2, 0) = 0, now nums = [1,5,6].
    +Insert 2 with cost min(1, 2) = 1, now nums = [1,2,5,6].
    +The total cost is 0 + 0 + 0 + 1 = 1.
    + +

    Example 2:

    + +
    +Input: instructions = [1,2,3,6,5,4]
    +Output: 3
    +Explanation: Begin with nums = [].
    +Insert 1 with cost min(0, 0) = 0, now nums = [1].
    +Insert 2 with cost min(1, 0) = 0, now nums = [1,2].
    +Insert 3 with cost min(2, 0) = 0, now nums = [1,2,3].
    +Insert 6 with cost min(3, 0) = 0, now nums = [1,2,3,6].
    +Insert 5 with cost min(3, 1) = 1, now nums = [1,2,3,5,6].
    +Insert 4 with cost min(3, 2) = 2, now nums = [1,2,3,4,5,6].
    +The total cost is 0 + 0 + 0 + 0 + 1 + 2 = 3.
    +
    + +

    Example 3:

    + +
    +Input: instructions = [1,3,3,3,2,4,2,1,2]
    +Output: 4
    +Explanation: Begin with nums = [].
    +Insert 1 with cost min(0, 0) = 0, now nums = [1].
    +Insert 3 with cost min(1, 0) = 0, now nums = [1,3].
    +Insert 3 with cost min(1, 0) = 0, now nums = [1,3,3].
    +Insert 3 with cost min(1, 0) = 0, now nums = [1,3,3,3].
    +Insert 2 with cost min(1, 3) = 1, now nums = [1,2,3,3,3].
    +Insert 4 with cost min(5, 0) = 0, now nums = [1,2,3,3,3,4].
    +​​​​​​​Insert 2 with cost min(1, 4) = 1, now nums = [1,2,2,3,3,3,4].
    +​​​​​​​Insert 1 with cost min(0, 6) = 0, now nums = [1,1,2,2,3,3,3,4].
    +​​​​​​​Insert 2 with cost min(2, 4) = 2, now nums = [1,1,2,2,2,3,3,3,4].
    +The total cost is 0 + 0 + 0 + 0 + 1 + 0 + 1 + 0 + 2 = 4.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= instructions.length <= 105
    • +
    • 1 <= instructions[i] <= 105
    • +
    + +### Related Topics + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Ordered Map](../../tag/ordered-map/README.md)] + +### Hints +
    +Hint 1 +This problem is closely related to finding the number of inversions in an array +
    + +
    +Hint 2 +if i know the position in which i will insert the i-th element in I can find the minimum cost to insert it +
    diff --git a/problems/flower-planting-with-no-adjacent/README.md b/problems/flower-planting-with-no-adjacent/README.md index 69302fd62..633e1d140 100644 --- a/problems/flower-planting-with-no-adjacent/README.md +++ b/problems/flower-planting-with-no-adjacent/README.md @@ -9,27 +9,43 @@                  [Next >](../partition-array-for-maximum-sum "Partition Array for Maximum Sum") -## [1042. Flower Planting With No Adjacent (Easy)](https://leetcode.com/problems/flower-planting-with-no-adjacent "不邻接植花") +## [1042. Flower Planting With No Adjacent (Medium)](https://leetcode.com/problems/flower-planting-with-no-adjacent "不邻接植花") -

    You have n gardens, labeled from 1 to n, and an array paths where paths[i] = [xi, yi] describes the existence of a bidirectional path from garden xi to garden yi. In each garden, you want to plant one of 4 types of flowers.

    +

    You have n gardens, labeled from 1 to n, and an array paths where paths[i] = [xi, yi] describes a bidirectional path between garden xi to garden yi. In each garden, you want to plant one of 4 types of flowers.

    -

    There is no garden that has more than three paths coming into or leaving it.

    +

    All gardens have at most 3 paths coming into or leaving it.

    -

    Your task is to choose a flower type for each garden such that, for any two gardens connected by a path, they have different types of flowers.

    +

    Your task is to choose a flower type for each garden such that, for any two gardens connected by a path, they have different types of flowers.

    -

    Return any such a choice as an array answer, where answer[i] is the type of flower planted in the (i+1)th garden.  The flower types are denoted 1, 2, 3, or 4.  It is guaranteed an answer exists.

    +

    Return any such a choice as an array answer, where answer[i] is the type of flower planted in the (i+1)th garden. The flower types are denoted 1, 2, 3, or 4. It is guaranteed an answer exists.

     

    Example 1:

    -
    Input: n = 3, paths = [[1,2],[2,3],[3,1]]
    +
    +
    +Input: n = 3, paths = [[1,2],[2,3],[3,1]]
     Output: [1,2,3]
    -

    Example 2:

    -
    Input: n = 4, paths = [[1,2],[3,4]]
    +Explanation:
    +Gardens 1 and 2 have different types.
    +Gardens 2 and 3 have different types.
    +Gardens 3 and 1 have different types.
    +Hence, [1,2,3] is a valid answer. Other valid answers include [1,2,4], [1,4,2], and [3,2,1].
    +
    + +

    Example 2:

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

    Example 3:

    -
    Input: n = 4, paths = [[1,2],[2,3],[3,4],[4,1],[1,3],[2,4]]
    +
    + +

    Example 3:

    + +
    +Input: n = 4, paths = [[1,2],[2,3],[3,4],[4,1],[1,3],[2,4]]
     Output: [1,2,3,4]
     
    +

     

    Constraints:

    @@ -39,7 +55,7 @@
  • paths[i].length == 2
  • 1 <= xi, yi <= n
  • xi != yi
  • -
  • No garden has four or more paths coming into or leaving it.
  • +
  • Every garden has at most 3 paths coming into or leaving it.
  • ### Related Topics diff --git a/problems/get-maximum-in-generated-array/README.md b/problems/get-maximum-in-generated-array/README.md new file mode 100644 index 000000000..0635621da --- /dev/null +++ b/problems/get-maximum-in-generated-array/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../hopper-company-queries-ii "Hopper Company Queries II") +                 +[Next >](../minimum-deletions-to-make-character-frequencies-unique "Minimum Deletions to Make Character Frequencies Unique") + +## [1646. Get Maximum in Generated Array (Easy)](https://leetcode.com/problems/get-maximum-in-generated-array "获取生成数组中的最大值") + +

    You are given an integer n. An array nums of length n + 1 is generated in the following way:

    + +
      +
    • nums[0] = 0
    • +
    • nums[1] = 1
    • +
    • nums[2 * i] = nums[i] when 2 <= 2 * i <= n
    • +
    • nums[2 * i + 1] = nums[i] + nums[i + 1] when 2 <= 2 * i + 1 <= n
    • +
    + +

    Return the maximum integer in the array nums​​​.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 7
    +Output: 3
    +Explanation: According to the given rules:
    +  nums[0] = 0
    +  nums[1] = 1
    +  nums[(1 * 2) = 2] = nums[1] = 1
    +  nums[(1 * 2) + 1 = 3] = nums[1] + nums[2] = 1 + 1 = 2
    +  nums[(2 * 2) = 4] = nums[2] = 1
    +  nums[(2 * 2) + 1 = 5] = nums[2] + nums[3] = 1 + 2 = 3
    +  nums[(3 * 2) = 6] = nums[3] = 2
    +  nums[(3 * 2) + 1 = 7] = nums[3] + nums[4] = 2 + 1 = 3
    +Hence, nums = [0,1,1,2,1,3,2,3], and the maximum is 3.
    +
    + +

    Example 2:

    + +
    +Input: n = 2
    +Output: 1
    +Explanation: According to the given rules, the maximum between nums[0], nums[1], and nums[2] is 1.
    +
    + +

    Example 3:

    + +
    +Input: n = 3
    +Output: 2
    +Explanation: According to the given rules, the maximum between nums[0], nums[1], nums[2], and nums[3] is 2.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= n <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Try generating the array. +
    + +
    +Hint 2 +Make sure not to fall in the base case of 0. +
    diff --git a/problems/hopper-company-queries-ii/README.md b/problems/hopper-company-queries-ii/README.md new file mode 100644 index 000000000..b5e721c20 --- /dev/null +++ b/problems/hopper-company-queries-ii/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../lowest-common-ancestor-of-a-binary-tree-ii "Lowest Common Ancestor of a Binary Tree II") +                 +[Next >](../get-maximum-in-generated-array "Get Maximum in Generated Array") + +## [1645. Hopper Company Queries II (Hard)](https://leetcode.com/problems/hopper-company-queries-ii "") + + diff --git a/problems/hopper-company-queries-ii/mysql_schemas.sql b/problems/hopper-company-queries-ii/mysql_schemas.sql new file mode 100644 index 000000000..f66daff0b --- /dev/null +++ b/problems/hopper-company-queries-ii/mysql_schemas.sql @@ -0,0 +1,39 @@ +Create table If Not Exists Drivers (driver_id int, join_date date); +Create table If Not Exists Rides (ride_id int, user_id int, requested_at date); +Create table If Not Exists AcceptedRides (ride_id int, driver_id int, ride_distance int, ride_duration int); +Truncate table Drivers; +insert into Drivers (driver_id, join_date) values ('10', '2019-12-10'); +insert into Drivers (driver_id, join_date) values ('8', '2020-1-13'); +insert into Drivers (driver_id, join_date) values ('5', '2020-2-16'); +insert into Drivers (driver_id, join_date) values ('7', '2020-3-8'); +insert into Drivers (driver_id, join_date) values ('4', '2020-5-17'); +insert into Drivers (driver_id, join_date) values ('1', '2020-10-24'); +insert into Drivers (driver_id, join_date) values ('6', '2021-1-5'); +Truncate table Rides; +insert into Rides (ride_id, user_id, requested_at) values ('6', '75', '2019-12-9'); +insert into Rides (ride_id, user_id, requested_at) values ('1', '54', '2020-2-9'); +insert into Rides (ride_id, user_id, requested_at) values ('10', '63', '2020-3-4'); +insert into Rides (ride_id, user_id, requested_at) values ('19', '39', '2020-4-6'); +insert into Rides (ride_id, user_id, requested_at) values ('3', '41', '2020-6-3'); +insert into Rides (ride_id, user_id, requested_at) values ('13', '52', '2020-6-22'); +insert into Rides (ride_id, user_id, requested_at) values ('7', '69', '2020-7-16'); +insert into Rides (ride_id, user_id, requested_at) values ('17', '70', '2020-8-25'); +insert into Rides (ride_id, user_id, requested_at) values ('20', '81', '2020-11-2'); +insert into Rides (ride_id, user_id, requested_at) values ('5', '57', '2020-11-9'); +insert into Rides (ride_id, user_id, requested_at) values ('2', '42', '2020-12-9'); +insert into Rides (ride_id, user_id, requested_at) values ('11', '68', '2021-1-11'); +insert into Rides (ride_id, user_id, requested_at) values ('15', '32', '2021-1-17'); +insert into Rides (ride_id, user_id, requested_at) values ('12', '11', '2021-1-19'); +insert into Rides (ride_id, user_id, requested_at) values ('14', '18', '2021-1-27'); +Truncate table AcceptedRides; +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('10', '10', '63', '38'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('13', '10', '73', '96'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('7', '8', '100', '28'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('17', '7', '119', '68'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('20', '1', '121', '92'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('5', '7', '42', '101'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('2', '4', '6', '38'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('11', '8', '37', '43'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('15', '8', '108', '82'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('12', '8', '38', '34'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('14', '1', '90', '74'); diff --git a/problems/kth-smallest-instructions/README.md b/problems/kth-smallest-instructions/README.md index 6e3b47e69..72f4e121b 100644 --- a/problems/kth-smallest-instructions/README.md +++ b/problems/kth-smallest-instructions/README.md @@ -7,7 +7,7 @@ [< Previous](../furthest-building-you-can-reach "Furthest Building You Can Reach")                  -Next > +[Next >](../lowest-common-ancestor-of-a-binary-tree-ii "Lowest Common Ancestor of a Binary Tree II") ## [1643. Kth Smallest Instructions (Hard)](https://leetcode.com/problems/kth-smallest-instructions "第 K 条最小指令") diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md new file mode 100644 index 000000000..94c69f692 --- /dev/null +++ b/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../kth-smallest-instructions "Kth Smallest Instructions") +                 +[Next >](../hopper-company-queries-ii "Hopper Company Queries II") + +## [1644. Lowest Common Ancestor of a Binary Tree II (Medium)](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-ii "") + + + +### Related Topics + [[Tree](../../tag/tree/README.md)] + +### Hints +
    +Hint 1 +Traverse the graph visiting root, left, root, right, root to make an Euler Path +
    + +
    +Hint 2 +Return the node (LCA) that is at the lowest depth between p and q in the Euler Path +
    diff --git a/problems/maximum-difference-between-node-and-ancestor/README.md b/problems/maximum-difference-between-node-and-ancestor/README.md index e6468749e..275faa7d6 100644 --- a/problems/maximum-difference-between-node-and-ancestor/README.md +++ b/problems/maximum-difference-between-node-and-ancestor/README.md @@ -11,36 +11,37 @@ ## [1026. Maximum Difference Between Node and Ancestor (Medium)](https://leetcode.com/problems/maximum-difference-between-node-and-ancestor "节点与其祖先之间的最大差值") -

    Given the root of a binary tree, find the maximum value V for which there exists different nodes A and B where V = |A.val - B.val| and A is an ancestor of B.

    +

    Given the root of a binary tree, find the maximum value V for which there exist different nodes A and B where V = |A.val - B.val| and A is an ancestor of B.

    -

    (A node A is an ancestor of B if either: any child of A is equal to B, or any child of A is an ancestor of B.)

    +

    A node A is an ancestor of B if either: any child of A is equal to B, or any child of A is an ancestor of B.

     

    -

    Example 1:

    - -

    - +
    -Input: [8,3,10,1,6,null,14,null,null,4,7,13]
    -Output: 7
    -Explanation: 
    -We have various ancestor-node differences, some of which are given below :
    +Input: root = [8,3,10,1,6,null,14,null,null,4,7,13]
    +Output: 7
    +Explanation: We have various ancestor-node differences, some of which are given below :
     |8 - 3| = 5
     |3 - 7| = 4
     |8 - 1| = 7
     |10 - 13| = 3
    -Among all possible differences, the maximum value of 7 is obtained by |8 - 1| = 7.
    +Among all possible differences, the maximum value of 7 is obtained by |8 - 1| = 7.
    + +

    Example 2:

    + +
    +Input: root = [1,null,2,null,0,3]
    +Output: 3
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. The number of nodes in the tree is between 2 and 5000.
    2. -
    3. Each node will have value between 0 and 100000.
    4. -
    +
      +
    • The number of nodes in the tree is in the range [2, 5000].
    • +
    • 0 <= Node.val <= 105
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/minimum-cost-to-move-chips-to-the-same-position/README.md b/problems/minimum-cost-to-move-chips-to-the-same-position/README.md index 91e5e823f..27009f7be 100644 --- a/problems/minimum-cost-to-move-chips-to-the-same-position/README.md +++ b/problems/minimum-cost-to-move-chips-to-the-same-position/README.md @@ -38,7 +38,7 @@ Total cost is 1.
     Input: position = [2,2,2,3,3]
     Output: 2
    -Explanation: We can move the two chips at poistion 3 to position 2. Each move has cost = 1. The total cost = 2.
    +Explanation: We can move the two chips at position  3 to position 2. Each move has cost = 1. The total cost = 2.
     

    Example 3:

    diff --git a/problems/minimum-deletions-to-make-character-frequencies-unique/README.md b/problems/minimum-deletions-to-make-character-frequencies-unique/README.md new file mode 100644 index 000000000..e73019275 --- /dev/null +++ b/problems/minimum-deletions-to-make-character-frequencies-unique/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../get-maximum-in-generated-array "Get Maximum in Generated Array") +                 +[Next >](../sell-diminishing-valued-colored-balls "Sell Diminishing-Valued Colored Balls") + +## [1647. Minimum Deletions to Make Character Frequencies Unique (Medium)](https://leetcode.com/problems/minimum-deletions-to-make-character-frequencies-unique "字符频次唯一的最小删除次数") + +

    A string s is called good if there are no two different characters in s that have the same frequency.

    + +

    Given a string s, return the minimum number of characters you need to delete to make s good.

    + +

    The frequency of a character in a string is the number of times it appears in the string. For example, in the string "aab", the frequency of 'a' is 2, while the frequency of 'b' is 1.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "aab"
    +Output: 0
    +Explanation: s is already good.
    +
    + +

    Example 2:

    + +
    +Input: s = "aaabbbcc"
    +Output: 2
    +Explanation: You can delete two 'b's resulting in the good string "aaabcc".
    +Another way it to delete one 'b' and one 'c' resulting in the good string "aaabbc".
    + +

    Example 3:

    + +
    +Input: s = "ceabaacb"
    +Output: 2
    +Explanation: You can delete both 'c's resulting in the good string "eabaab".
    +Note that we only care about characters that are still in the string at the end (i.e. frequency of 0 is ignored).
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 105
    • +
    • s contains only lowercase English letters.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Sort](../../tag/sort/README.md)] + +### Hints +
    +Hint 1 +As we can only delete characters, if we have multiple characters having the same frequency, we must decrease all the frequencies of them, except one. +
    + +
    +Hint 2 +Sort the alphabet characters by their frequencies non-increasingly. +
    + +
    +Hint 3 +Iterate on the alphabet characters, keep decreasing the frequency of the current character until it reaches a value that has not appeared before. +
    diff --git a/problems/minimum-path-sum/README.md b/problems/minimum-path-sum/README.md index 43de41172..bb6cd5a44 100644 --- a/problems/minimum-path-sum/README.md +++ b/problems/minimum-path-sum/README.md @@ -11,23 +11,36 @@ ## [64. Minimum Path Sum (Medium)](https://leetcode.com/problems/minimum-path-sum "最小路径和") -

    Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.

    +

    Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path.

    Note: You can only move either down or right at any point in time.

    -

    Example:

    - +

     

    +

    Example 1:

    +
    -Input:
    -[
    -  [1,3,1],
    -  [1,5,1],
    -  [4,2,1]
    -]
    +Input: grid = [[1,3,1],[1,5,1],[4,2,1]]
     Output: 7
    -Explanation: Because the path 1→3→1→1→1 minimizes the sum.
    +Explanation: Because the path 1 → 3 → 1 → 1 → 1 minimizes the sum.
     
    +

    Example 2:

    + +
    +Input: grid = [[1,2,3],[4,5,6]]
    +Output: 12
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 200
    • +
    • 0 <= grid[i][j] <= 100
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/number-of-longest-increasing-subsequence/README.md b/problems/number-of-longest-increasing-subsequence/README.md index 590de3f69..452a7bc8e 100644 --- a/problems/number-of-longest-increasing-subsequence/README.md +++ b/problems/number-of-longest-increasing-subsequence/README.md @@ -13,6 +13,8 @@

    Given an integer array nums, return the number of longest increasing subsequences.

    +

    Notice that the sequence has to be strictly increasing.

    +

     

    Example 1:

    diff --git a/problems/plus-one/README.md b/problems/plus-one/README.md index 672ab41dc..af79ddd64 100644 --- a/problems/plus-one/README.md +++ b/problems/plus-one/README.md @@ -11,7 +11,7 @@ ## [66. Plus One (Easy)](https://leetcode.com/problems/plus-one "加一") -

    Given a non-empty array of digits representing a non-negative integer, increment one to the integer.

    +

    Given a non-empty array of decimal digits representing a non-negative integer, increment one to the integer.

    The digits are stored such that the most significant digit is at the head of the list, and each element in the array contains a single digit.

    diff --git a/problems/power-of-three/README.md b/problems/power-of-three/README.md index 5e4d3b688..b12b8f411 100644 --- a/problems/power-of-three/README.md +++ b/problems/power-of-three/README.md @@ -11,35 +11,33 @@ ## [326. Power of Three (Easy)](https://leetcode.com/problems/power-of-three "3的幂") -

    Given an integer, write a function to determine if it is a power of three.

    +

    Given an integer n, return true if it is a power of three. Otherwise, return false.

    -

    Example 1:

    +

    An integer n is a power of three, if there exists an integer x such that n == x3.

    -
    -Input: 27
    +

     

    +

    Example 1:

    +
    Input: n = 27
     Output: true
    +

    Example 2:

    +
    Input: n = 0
    +Output: false
    +

    Example 3:

    +
    Input: n = 9
    +Output: true
    +

    Example 4:

    +
    Input: n = 45
    +Output: false
     
    +

     

    +

    Constraints:

    -

    Example 2:

    - -
    -Input: 0
    -Output: false
    - -

    Example 3:

    - -
    -Input: 9
    -Output: true
    - -

    Example 4:

    - -
    -Input: 45
    -Output: false
    +
      +
    • -231 <= n <= 231 - 1
    • +
    -

    Follow up:
    -Could you do it without using any loop / recursion?

    +

     

    +Follow up: Could you do it without using any loop / recursion? ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/range-sum-of-bst/README.md b/problems/range-sum-of-bst/README.md index 118d72922..9eaee31e2 100644 --- a/problems/range-sum-of-bst/README.md +++ b/problems/range-sum-of-bst/README.md @@ -11,38 +11,32 @@ ## [938. Range Sum of BST (Easy)](https://leetcode.com/problems/range-sum-of-bst "二叉搜索树的范围和") -

    Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive).

    - -

    The binary search tree is guaranteed to have unique values.

    +

    Given the root node of a binary search tree, return the sum of values of all nodes with a value in the range [low, high].

     

    - -

    Example 1:

    - +
    -Input: root = [10,5,15,3,7,null,18], L = 7, R = 15
    -Output: 32
    +Input: root = [10,5,15,3,7,null,18], low = 7, high = 15
    +Output: 32
     
    -

    Example 2:

    - +
    -Input: root = [10,5,15,3,7,13,18,1,null,6], L = 6, R = 10
    -Output: 23
    +Input: root = [10,5,15,3,7,13,18,1,null,6], low = 6, high = 10
    +Output: 23
     

     

    - -

    Note:

    - -
      -
    1. The number of nodes in the tree is at most 10000.
    2. -
    3. The final answer is guaranteed to be less than 2^31.
    4. -
    -
    -
    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [1, 2 * 104].
    • +
    • 1 <= Node.val <= 105
    • +
    • 1 <= low <= high <= 105
    • +
    • All Node.val are unique.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/recover-a-tree-from-preorder-traversal/README.md b/problems/recover-a-tree-from-preorder-traversal/README.md index 44eddb124..f0b7fabef 100644 --- a/problems/recover-a-tree-from-preorder-traversal/README.md +++ b/problems/recover-a-tree-from-preorder-traversal/README.md @@ -11,58 +11,43 @@ ## [1028. Recover a Tree From Preorder Traversal (Hard)](https://leetcode.com/problems/recover-a-tree-from-preorder-traversal "从先序遍历还原二叉树") -

    We run a preorder depth first search on the root of a binary tree.

    +

    We run a preorder depth-first search (DFS) on the root of a binary tree.

    -

    At each node in this traversal, we output D dashes (where D is the depth of this node), then we output the value of this node.  (If the depth of a node is D, the depth of its immediate child is D+1.  The depth of the root node is 0.)

    +

    At each node in this traversal, we output D dashes (where D is the depth of this node), then we output the value of this node.  If the depth of a node is D, the depth of its immediate child is D + 1.  The depth of the root node is 0.

    -

    If a node has only one child, that child is guaranteed to be the left child.

    +

    If a node has only one child, that child is guaranteed to be the left child.

    -

    Given the output S of this traversal, recover the tree and return its root.

    +

    Given the output S of this traversal, recover the tree and return its root.

     

    -

    Example 1:

    - -

    - +
    -Input: "1-2--3--4-5--6--7"
    -Output: [1,2,5,3,4,6,7]
    +Input: S = "1-2--3--4-5--6--7"
    +Output: [1,2,5,3,4,6,7]
     
    -

    Example 2:

    - -

    - +
    -Input: "1-2--3---4-5--6---7"
    -Output: [1,2,5,3,null,6,null,4,null,7]
    -
    - -
    -

     

    +Input: S = "1-2--3---4-5--6---7" +Output: [1,2,5,3,null,6,null,4,null,7] +
    -

    Example 3:

    - -

    - +
    -Input: "1-401--349---90--88"
    -Output: [1,401,null,349,88,90]
    +Input: S = "1-401--349---90--88"
    +Output: [1,401,null,349,88,90]
     
    -

     

    - -

    Note:

    +

    Constraints:

      -
    • The number of nodes in the original tree is between 1 and 1000.
    • -
    • Each node will have a value between 1 and 10^9.
    • +
    • The number of nodes in the original tree is in the range [1, 1000].
    • +
    • 1 <= Node.val <= 109
    - ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/sell-diminishing-valued-colored-balls/README.md b/problems/sell-diminishing-valued-colored-balls/README.md new file mode 100644 index 000000000..ae1042150 --- /dev/null +++ b/problems/sell-diminishing-valued-colored-balls/README.md @@ -0,0 +1,84 @@ + + + + + + + +[< Previous](../minimum-deletions-to-make-character-frequencies-unique "Minimum Deletions to Make Character Frequencies Unique") +                 +[Next >](../create-sorted-array-through-instructions "Create Sorted Array through Instructions") + +## [1648. Sell Diminishing-Valued Colored Balls (Medium)](https://leetcode.com/problems/sell-diminishing-valued-colored-balls "销售价值减少的颜色球") + +

    You have an inventory of different colored balls, and there is a customer that wants orders balls of any color.

    + +

    The customer weirdly values the colored balls. Each colored ball's value is the number of balls of that color you currently have in your inventory. For example, if you own 6 yellow balls, the customer would pay 6 for the first yellow ball. After the transaction, there are only 5 yellow balls left, so the next yellow ball is then valued at 5 (i.e., the value of the balls decreases as you sell more to the customer).

    + +

    You are given an integer array, inventory, where inventory[i] represents the number of balls of the ith color that you initially own. You are also given an integer orders, which represents the total number of balls that the customer wants. You can sell the balls in any order.

    + +

    Return the maximum total value that you can attain after selling orders colored balls. As the answer may be too large, return it modulo 109 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: inventory = [2,5], orders = 4
    +Output: 14
    +Explanation: Sell the 1st color 1 time (2) and the 2nd color 3 times (5 + 4 + 3).
    +The maximum total value is 2 + 5 + 4 + 3 = 14.
    +
    + +

    Example 2:

    + +
    +Input: inventory = [3,5], orders = 6
    +Output: 19
    +Explanation: Sell the 1st color 2 times (3 + 2) and the 2nd color 4 times (5 + 4 + 3 + 2).
    +The maximum total value is 3 + 2 + 5 + 4 + 3 + 2 = 19.
    +
    + +

    Example 3:

    + +
    +Input: inventory = [2,8,4,10,6], orders = 20
    +Output: 110
    +
    + +

    Example 4:

    + +
    +Input: inventory = [1000000000], orders = 1000000000
    +Output: 21
    +Explanation: Sell the 1st color 1000000000 times for a total value of 500000000500000000. 500000000500000000 modulo 109 + 7 = 21.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= inventory.length <= 105
    • +
    • 1 <= inventory[i] <= 109
    • +
    • 1 <= orders <= min(sum(inventory[i]), 109)
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Greedily sell the most expensive ball. +
    + +
    +Hint 2 +There is some value k where all balls of value > k are sold, and some, (maybe 0) of balls of value k are sold. +
    + +
    +Hint 3 +Use binary search to find this value k, and use maths to find the total sum. +
    diff --git a/problems/simplify-path/README.md b/problems/simplify-path/README.md index cb9780bdb..75f48fa37 100644 --- a/problems/simplify-path/README.md +++ b/problems/simplify-path/README.md @@ -13,56 +13,50 @@

    Given an absolute path for a file (Unix-style), simplify it. Or in other words, convert it to the canonical path.

    -

    In a UNIX-style file system, a period . refers to the current directory. Furthermore, a double period .. moves the directory up a level.

    +

    In a UNIX-style file system, a period '.' refers to the current directory. Furthermore, a double period '..' moves the directory up a level.

    -

    Note that the returned canonical path must always begin with a slash /, and there must be only a single slash / between two directory names. The last directory name (if it exists) must not end with a trailing /. Also, the canonical path must be the shortest string representing the absolute path.

    +

    Note that the returned canonical path must always begin with a slash '/', and there must be only a single slash '/' between two directory names. The last directory name (if it exists) must not end with a trailing '/'. Also, the canonical path must be the shortest string representing the absolute path.

     

    -

    Example 1:

    -Input: "/home/"
    -Output: "/home"
    -Explanation: Note that there is no trailing slash after the last directory name.
    +Input: path = "/home/"
    +Output: "/home"
    +Explanation: Note that there is no trailing slash after the last directory name.
     

    Example 2:

    -Input: "/../"
    -Output: "/"
    +Input: path = "/../"
    +Output: "/"
     Explanation: Going one level up from the root directory is a no-op, as the root level is the highest level you can go.
     

    Example 3:

    -Input: "/home//foo/"
    -Output: "/home/foo"
    +Input: path = "/home//foo/"
    +Output: "/home/foo"
     Explanation: In the canonical path, multiple consecutive slashes are replaced by a single one.
     

    Example 4:

    -Input: "/a/./b/../../c/"
    -Output: "/c"
    -
    - -

    Example 5:

    - -
    -Input: "/a/../../b/../c//.//"
    -Output: "/c"
    +Input: path = "/a/./b/../../c/"
    +Output: "/c"
     
    -

    Example 6:

    +

     

    +

    Constraints:

    -
    -Input: "/a//b////c/d//././/.."
    -Output: "/a/b/c"
    -
    +
      +
    • 1 <= path.length <= 3000
    • +
    • path consists of English letters, digits, period '.', slash '/' or '_'.
    • +
    • path is a valid Unix path.
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/toeplitz-matrix/README.md b/problems/toeplitz-matrix/README.md index a3f337771..d1f65f188 100644 --- a/problems/toeplitz-matrix/README.md +++ b/problems/toeplitz-matrix/README.md @@ -11,21 +11,16 @@ ## [766. Toeplitz Matrix (Easy)](https://leetcode.com/problems/toeplitz-matrix "托普利茨矩阵") -

    A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element.

    +

    Given an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false.

    -

    Now given an M x N matrix, return True if and only if the matrix is Toeplitz.

    +

    A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same elements.

    +

     

    Example 1:

    - +
    -Input:
    -matrix = [
    -  [1,2,3,4],
    -  [5,1,2,3],
    -  [9,5,1,2]
    -]
    -Output: True
    +Input: matrix = [[1,2,3,4],[5,1,2,3],[9,5,1,2]]
    +Output: true
     Explanation:
     In the above grid, the diagonals are:
     "[9]", "[5, 5]", "[1, 1, 1]", "[2, 2, 2]", "[3, 3]", "[4]".
    @@ -33,34 +28,31 @@ In each diagonal all elements are the same, so the answer is True.
     

    Example 2:

    - +
    -Input:
    -matrix = [
    -  [1,2],
    -  [2,2]
    -]
    -Output: False
    +Input: matrix = [[1,2],[2,2]]
    +Output: false
     Explanation:
     The diagonal "[1, 2]" has different elements.
     
    -


    -Note:

    +

     

    +

    Constraints:

    -
      -
    1. matrix will be a 2D array of integers.
    2. -
    3. matrix will have a number of rows and columns in range [1, 20].
    4. -
    5. matrix[i][j] will be integers in range [0, 99].
    6. -
    +
      +
    • m == matrix.length
    • +
    • n == matrix[i].length
    • +
    • 1 <= m, n <= 20
    • +
    • 0 <= matrix[i][j] <= 99
    • +
    -


    -Follow up:

    +

     

    +

    Follow up:

    -
      -
    1. What if the matrix is stored on disk, and the memory is limited such that you can only load at most one row of the matrix into the memory at once?
    2. -
    3. What if the matrix is so large that you can only load up a partial row into the memory at once?
    4. -
    +
      +
    • What if the matrix is stored on disk, and the memory is limited such that you can only load at most one row of the matrix into the memory at once?
    • +
    • What if the matrix is so large that you can only load up a partial row into the memory at once?
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/two-sum-less-than-k/README.md b/problems/two-sum-less-than-k/README.md index a45c44a84..0c8c8d768 100644 --- a/problems/two-sum-less-than-k/README.md +++ b/problems/two-sum-less-than-k/README.md @@ -44,7 +44,9 @@ In this case it's not possible to get a pair sum less that 15. ### Related Topics + [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions 1. [Two Sum](../two-sum) (Easy) diff --git a/problems/unique-paths-ii/README.md b/problems/unique-paths-ii/README.md index 222f9a960..c3a8fee74 100644 --- a/problems/unique-paths-ii/README.md +++ b/problems/unique-paths-ii/README.md @@ -11,35 +11,43 @@ ## [63. Unique Paths II (Medium)](https://leetcode.com/problems/unique-paths-ii "不同路径 II") -

    A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).

    +

    A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).

    The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).

    Now consider if some obstacles are added to the grids. How many unique paths would there be?

    -

    - -

    An obstacle and empty space is marked as 1 and 0 respectively in the grid.

    - -

    Note: m and n will be at most 100.

    +

    An obstacle and space is marked as 1 and 0 respectively in the grid.

    +

     

    Example 1:

    - +
    -Input:
    -[
    -  [0,0,0],
    -  [0,1,0],
    -  [0,0,0]
    -]
    +Input: obstacleGrid = [[0,0,0],[0,1,0],[0,0,0]]
     Output: 2
    -Explanation:
    -There is one obstacle in the middle of the 3x3 grid above.
    +Explanation: There is one obstacle in the middle of the 3x3 grid above.
     There are two ways to reach the bottom-right corner:
     1. Right -> Right -> Down -> Down
     2. Down -> Down -> Right -> Right
     
    +

    Example 2:

    + +
    +Input: obstacleGrid = [[0,1],[0,0]]
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == obstacleGrid.length
    • +
    • n == obstacleGrid[i].length
    • +
    • 1 <= m, n <= 100
    • +
    • obstacleGrid[i][j] is 0 or 1.
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/valid-mountain-array/README.md b/problems/valid-mountain-array/README.md index de6e3a005..c194f6c86 100644 --- a/problems/valid-mountain-array/README.md +++ b/problems/valid-mountain-array/README.md @@ -11,65 +11,38 @@ ## [941. Valid Mountain Array (Easy)](https://leetcode.com/problems/valid-mountain-array "有效的山脉数组") -

    Given an array A of integers, return true if and only if it is a valid mountain array.

    +

    Given an array of integers arr, return true if and only if it is a valid mountain array.

    -

    Recall that A is a mountain array if and only if:

    +

    Recall that arr is a mountain array if and only if:

      -
    • A.length >= 3
    • -
    • There exists some i with 0 < i < A.length - 1 such that: +
    • arr.length >= 3
    • +
    • There exists some i with 0 < i < arr.length - 1 such that:
        -
      • A[0] < A[1] < ... A[i-1] < A[i]
      • -
      • A[i] > A[i+1] > ... > A[A.length - 1]
      • +
      • arr[0] < arr[1] < ... < arr[i - 1] < A[i]
      • +
      • arr[i] > arr[i + 1] > ... > arr[arr.length - 1]
    - -
    -

     

    -

    Example 1:

    - -
    -Input: [2,1]
    -Output: false
    +
    Input: arr = [2,1]
    +Output: false
    +

    Example 2:

    +
    Input: arr = [3,5,5]
    +Output: false
    +

    Example 3:

    +
    Input: arr = [0,3,2,1]
    +Output: true
     
    - -
    -

    Example 2:

    - -
    -Input: [3,5,5]
    -Output: false
    -
    - -
    -

    Example 3:

    - -
    -Input: [0,3,2,1]
    -Output: true
    -
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 0 <= A.length <= 10000
    2. -
    3. 0 <= A[i] <= 10000 
    4. -
    - -

     

    +

    Constraints:

    -
    -
     
    -
    -
    +
      +
    • 1 <= arr.length <= 104
    • +
    • 0 <= arr[i] <= 104
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/word-search-ii/README.md b/problems/word-search-ii/README.md index 959bcf2b8..87cf5d135 100644 --- a/problems/word-search-ii/README.md +++ b/problems/word-search-ii/README.md @@ -11,35 +11,38 @@ ## [212. Word Search II (Hard)](https://leetcode.com/problems/word-search-ii "单词搜索 II") -

    Given a 2D board and a list of words from the dictionary, find all words in the board.

    +

    Given an m x n board of characters and a list of strings words, return all words on the board.

    -

    Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once in a word.

    +

    Each word must be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once in a word.

     

    +

    Example 1:

    + +
    +Input: board = [["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f","l","v"]], words = ["oath","pea","eat","rain"]
    +Output: ["eat","oath"]
    +
    -

    Example:

    - +

    Example 2:

    +
    -Input: 
    -board = [
    -  ['o','a','a','n'],
    -  ['e','t','a','e'],
    -  ['i','h','k','r'],
    -  ['i','f','l','v']
    -]
    -words = ["oath","pea","eat","rain"]
    -
    -Output: ["eat","oath"]
    +Input: board = [["a","b"],["c","d"]], words = ["abcb"]
    +Output: []
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. All inputs are consist of lowercase letters a-z.
    2. -
    3. The values of words are distinct.
    4. -
    +
      +
    • m == board.length
    • +
    • n == board[i].length
    • +
    • 1 <= m, n <= 12
    • +
    • board[i][j] is a lowercase English letter.
    • +
    • 1 <= words.length <= 3 * 104
    • +
    • 1 <= words[i].length <= 10
    • +
    • words[i] consists of lowercase English letters.
    • +
    • All the strings of words are unique.
    • +
    ### Related Topics [[Trie](../../tag/trie/README.md)] diff --git a/problems/word-search/README.md b/problems/word-search/README.md index 583d51427..d1849fa00 100644 --- a/problems/word-search/README.md +++ b/problems/word-search/README.md @@ -17,14 +17,14 @@

     

    Example 1:

    - +
     Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCCED"
     Output: true
     

    Example 2:

    - +
     Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "SEE"
     Output: true
    diff --git a/readme/901-1200.md b/readme/901-1200.md
    index c7b5c1b1a..0ac0c10db 100644
    --- a/readme/901-1200.md
    +++ b/readme/901-1200.md
    @@ -211,7 +211,7 @@ LeetCode Problems' Solutions
     | 1039 | [Minimum Score Triangulation of Polygon](https://leetcode.com/problems/minimum-score-triangulation-of-polygon "多边形三角剖分的最低得分") | [Go](../problems/minimum-score-triangulation-of-polygon) | Medium |
     | 1040 | [Moving Stones Until Consecutive II](https://leetcode.com/problems/moving-stones-until-consecutive-ii "移动石子直到连续 II") | [Go](../problems/moving-stones-until-consecutive-ii) | Medium |
     | 1041 | [Robot Bounded In Circle](https://leetcode.com/problems/robot-bounded-in-circle "困于环中的机器人") | [Go](../problems/robot-bounded-in-circle) | Medium |
    -| 1042 | [Flower Planting With No Adjacent](https://leetcode.com/problems/flower-planting-with-no-adjacent "不邻接植花") | [Go](../problems/flower-planting-with-no-adjacent) | Easy |
    +| 1042 | [Flower Planting With No Adjacent](https://leetcode.com/problems/flower-planting-with-no-adjacent "不邻接植花") | [Go](../problems/flower-planting-with-no-adjacent) | Medium |
     | 1043 | [Partition Array for Maximum Sum](https://leetcode.com/problems/partition-array-for-maximum-sum "分隔数组以得到最大和") | [Go](../problems/partition-array-for-maximum-sum) | Medium |
     | 1044 | [Longest Duplicate Substring](https://leetcode.com/problems/longest-duplicate-substring "最长重复子串") | [Go](../problems/longest-duplicate-substring) | Hard |
     | 1045 | [Customers Who Bought All Products](https://leetcode.com/problems/customers-who-bought-all-products "买下所有产品的客户") 🔒 | [MySQL](../problems/customers-who-bought-all-products) | Medium |
    diff --git a/tag/README.md b/tag/README.md
    index e026aff3a..7e961aaad 100644
    --- a/tag/README.md
    +++ b/tag/README.md
    @@ -23,8 +23,8 @@
     | 23 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | 
     | 25 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | 
     | 27 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | | 28 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | 
    -| 29 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 30 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | 
    -| 31 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 32 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | 
    +| 29 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | 
    +| 31 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 32 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | 
     | 33 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 34 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | 
     | 35 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | 
     | 37 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | | 38 | [Reservoir Sampling](reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | 
    diff --git a/tag/array/README.md b/tag/array/README.md
    index d830dfbd0..d48298774 100644
    --- a/tag/array/README.md
    +++ b/tag/array/README.md
    @@ -9,6 +9,7 @@
     
     | # | 题目 | 标签 | 难度 |
     | :-: | - | - | :-: |
    +| 1646 | [获取生成数组中的最大值](../../problems/get-maximum-in-generated-array) | [[数组](../array/README.md)]  | Easy |
     | 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)]  | Easy |
     | 1636 | [按照频率将数组升序排序](../../problems/sort-array-by-increasing-frequency) | [[排序](../sort/README.md)] [[数组](../array/README.md)]  | Easy |
     | 1629 | [按键持续时间最长的键](../../problems/slowest-key) | [[数组](../array/README.md)]  | Easy |
    @@ -123,7 +124,7 @@
     | 1128 | [等价多米诺骨牌对的数量](../../problems/number-of-equivalent-domino-pairs) | [[数组](../array/README.md)]  | Easy |
     | 1122 | [数组的相对排序](../../problems/relative-sort-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)]  | Easy |
     | 1109 | [航班预订统计](../../problems/corporate-flight-bookings) | [[数组](../array/README.md)] [[数学](../math/README.md)]  | Medium |
    -| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[数组](../array/README.md)]  | Easy |
    +| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)]  | Easy |
     | 1089 | [复写零](../../problems/duplicate-zeros) | [[数组](../array/README.md)]  | Easy |
     | 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)]  | Easy |
     | 1085 | [最小元素各数位之和](../../problems/sum-of-digits-in-the-minimum-number) 🔒 | [[数组](../array/README.md)]  | Easy |
    diff --git a/tag/binary-indexed-tree/README.md b/tag/binary-indexed-tree/README.md
    index 3e21d1daf..de58cc980 100644
    --- a/tag/binary-indexed-tree/README.md
    +++ b/tag/binary-indexed-tree/README.md
    @@ -9,6 +9,7 @@
     
     | # | 题目 | 标签 | 难度 |
     | :-: | - | - | :-: |
    +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)]  | Hard |
     | 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)]  | Hard |
     | 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)]  | Hard |
     | 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)]  | Hard |
    diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md
    index 022605c7f..dc9a4e60a 100644
    --- a/tag/depth-first-search/README.md
    +++ b/tag/depth-first-search/README.md
    @@ -87,6 +87,7 @@
     | 664 | [奇怪的打印机](../../problems/strange-printer) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)]  | Hard |
     | 638 | [大礼包](../../problems/shopping-offers) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)]  | Medium |
     | 576 | [出界的路径数](../../problems/out-of-boundary-paths) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)]  | Medium |
    +| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)]  | Easy |
     | 559 | [N叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)]  | Easy |
     | 547 | [朋友圈](../../problems/friend-circles) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)]  | Medium |
     | 546 | [移除盒子](../../problems/remove-boxes) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)]  | Hard |
    diff --git a/tag/graph/README.md b/tag/graph/README.md
    index f86e57ad7..1c5b8478a 100644
    --- a/tag/graph/README.md
    +++ b/tag/graph/README.md
    @@ -31,7 +31,7 @@
     | 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)]  | Medium |
     | 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)]  | Medium |
     | 1059 | [从始点到终点的所有路径](../../problems/all-paths-from-source-lead-to-destination) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)]  | Medium |
    -| 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[图](../graph/README.md)]  | Easy |
    +| 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[图](../graph/README.md)]  | Medium |
     | 997 | [找到小镇的法官](../../problems/find-the-town-judge) | [[图](../graph/README.md)]  | Easy |
     | 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)]  | Hard |
     | 990 | [等式方程的可满足性](../../problems/satisfiability-of-equality-equations) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)]  | Medium |
    diff --git a/tag/greedy/README.md b/tag/greedy/README.md
    index 3c0ad9891..589e0963d 100644
    --- a/tag/greedy/README.md
    +++ b/tag/greedy/README.md
    @@ -9,6 +9,8 @@
     
     | # | 题目 | 标签 | 难度 |
     | :-: | - | - | :-: |
    +| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)]  | Medium |
    +| 1647 | [字符频次唯一的最小删除次数](../../problems/minimum-deletions-to-make-character-frequencies-unique) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)]  | Medium |
     | 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)]  | Hard |
     | 1620 | [网络信号最好的坐标](../../problems/coordinate-with-maximum-network-quality) | [[贪心算法](../greedy/README.md)]  | Medium |
     | 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)]  | Medium |
    diff --git a/tag/math/README.md b/tag/math/README.md
    index 6480d4122..42045a79a 100644
    --- a/tag/math/README.md
    +++ b/tag/math/README.md
    @@ -9,6 +9,7 @@
     
     | # | 题目 | 标签 | 难度 |
     | :-: | - | - | :-: |
    +| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)]  | Medium |
     | 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)]  | Medium |
     | 1627 | [带阈值的图连通性](../../problems/graph-connectivity-with-threshold) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)]  | Hard |
     | 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)]  | Hard |
    diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md
    index 34c50be84..c9d6641d8 100644
    --- a/tag/ordered-map/README.md
    +++ b/tag/ordered-map/README.md
    @@ -9,6 +9,7 @@
     
     | # | 题目 | 标签 | 难度 |
     | :-: | - | - | :-: |
    +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)]  | Hard |
     | 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[Ordered Map](../ordered-map/README.md)]  | Hard |
     | 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)]  | Medium |
     | 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)]  | Hard |
    diff --git a/tag/recursion/README.md b/tag/recursion/README.md
    index c3bdb7b1c..ce0aa14f8 100644
    --- a/tag/recursion/README.md
    +++ b/tag/recursion/README.md
    @@ -21,6 +21,7 @@
     | 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)]  | Medium |
     | 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)]  | Medium |
     | 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)]  | Medium |
    +| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)]  | Easy |
     | 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)]  | Medium |
     | 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)]  | Hard |
     | 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)]  | Medium |
    diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md
    index 3e173c442..45c8a364b 100644
    --- a/tag/segment-tree/README.md
    +++ b/tag/segment-tree/README.md
    @@ -9,6 +9,7 @@
     
     | # | 题目 | 标签 | 难度 |
     | :-: | - | - | :-: |
    +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)]  | Hard |
     | 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[线段树](../segment-tree/README.md)]  | Hard |
     | 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)]  | Hard |
     | 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)]  | Medium |
    diff --git a/tag/sort/README.md b/tag/sort/README.md
    index f8dcd8870..a3fe0b99d 100644
    --- a/tag/sort/README.md
    +++ b/tag/sort/README.md
    @@ -9,6 +9,8 @@
     
     | # | 题目 | 标签 | 难度 |
     | :-: | - | - | :-: |
    +| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)]  | Medium |
    +| 1647 | [字符频次唯一的最小删除次数](../../problems/minimum-deletions-to-make-character-frequencies-unique) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)]  | Medium |
     | 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)]  | Easy |
     | 1637 | [两点之间不包含任何点的最宽垂直面积](../../problems/widest-vertical-area-between-two-points-containing-no-points) | [[排序](../sort/README.md)]  | Medium |
     | 1636 | [按照频率将数组升序排序](../../problems/sort-array-by-increasing-frequency) | [[排序](../sort/README.md)] [[数组](../array/README.md)]  | Easy |
    @@ -41,6 +43,7 @@
     | 1183 | [矩阵中 1 的最大数量](../../problems/maximum-number-of-ones) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)]  | Hard |
     | 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)]  | Medium |
     | 1122 | [数组的相对排序](../../problems/relative-sort-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)]  | Easy |
    +| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)]  | Easy |
     | 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)]  | Easy |
     | 1057 | [校园自行车分配](../../problems/campus-bikes) 🔒 | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)]  | Medium |
     | 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[堆](../heap/README.md)] [[排序](../sort/README.md)]  | Medium |
    diff --git a/tag/tags.json b/tag/tags.json
    index 3ef270e69..bf366605e 100644
    --- a/tag/tags.json
    +++ b/tag/tags.json
    @@ -144,16 +144,16 @@
     		"Slug": "minimax",
     		"TranslatedName": "极小化极大"
     	},
    -	{
    -		"Name": "Brainteaser",
    -		"Slug": "brainteaser",
    -		"TranslatedName": "脑筋急转弯"
    -	},
     	{
     		"Name": "Binary Indexed Tree",
     		"Slug": "binary-indexed-tree",
     		"TranslatedName": "树状数组"
     	},
    +	{
    +		"Name": "Brainteaser",
    +		"Slug": "brainteaser",
    +		"TranslatedName": "脑筋急转弯"
    +	},
     	{
     		"Name": "Line Sweep",
     		"Slug": "line-sweep",
    diff --git a/tag/tree/README.md b/tag/tree/README.md
    index 912d25a23..adf26f14e 100644
    --- a/tag/tree/README.md
    +++ b/tag/tree/README.md
    @@ -9,6 +9,7 @@
     
     | # | 题目 | 标签 | 难度 |
     | :-: | - | - | :-: |
    +| 1644 | [Lowest Common Ancestor of a Binary Tree II](../../problems/lowest-common-ancestor-of-a-binary-tree-ii) 🔒 | [[树](../tree/README.md)]  | Medium |
     | 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) | [[树](../tree/README.md)] [[设计](../design/README.md)]  | Medium |
     | 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)]  | Medium |
     | 1609 | [奇偶树](../../problems/even-odd-tree) | [[树](../tree/README.md)]  | Medium |
    @@ -93,7 +94,7 @@
     | 589 | [N叉树的前序遍历](../../problems/n-ary-tree-preorder-traversal) | [[树](../tree/README.md)]  | Easy |
     | 582 | [杀死进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)]  | Medium |
     | 572 | [另一个树的子树](../../problems/subtree-of-another-tree) | [[树](../tree/README.md)]  | Easy |
    -| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)]  | Easy |
    +| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)]  | Easy |
     | 559 | [N叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)]  | Easy |
     | 549 | [二叉树中最长的连续序列](../../problems/binary-tree-longest-consecutive-sequence-ii) 🔒 | [[树](../tree/README.md)]  | Medium |
     | 545 | [二叉树的边界](../../problems/boundary-of-binary-tree) 🔒 | [[树](../tree/README.md)]  | Medium |
    diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md
    index 29b86a381..8f027246d 100644
    --- a/tag/two-pointers/README.md
    +++ b/tag/two-pointers/README.md
    @@ -15,6 +15,7 @@
     | 1248 | [统计「优美子数组」](../../problems/count-number-of-nice-subarrays) | [[双指针](../two-pointers/README.md)]  | Medium |
     | 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)]  | Medium |
     | 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)]  | Easy |
    +| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)]  | Easy |
     | 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)]  | Medium |
     | 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)]  | Medium |
     | 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)]  | Hard |
    
    From 6450a74028d91f405ecd2bd4e2af129d7ce7fbf4 Mon Sep 17 00:00:00 2001
    From: Shuo 
    Date: Mon, 16 Nov 2020 09:23:38 +0800
    Subject: [PATCH 109/145] A: new
    
    ---
     README.md                                     | 14 ++-
     problems/add-binary/README.md                 | 28 +++---
     .../README.md                                 |  2 +-
     problems/bricks-falling-when-hit/README.md    | 53 +++++++----
     problems/climbing-stairs/README.md            |  9 +-
     .../README.md                                 |  2 +-
     problems/defuse-the-bomb/README.md            | 75 +++++++++++++++
     problems/design-an-ordered-stream/README.md   | 81 ++++++++++++++++
     .../README.md                                 | 91 ++++++++++++++++++
     .../distribute-repeating-integers/README.md   | 95 +++++++++++++++++++
     .../README.md                                 |  8 +-
     .../README.md                                 | 42 ++++++--
     problems/hopper-company-queries-iii/README.md | 14 +++
     .../mysql_schemas.sql                         | 39 ++++++++
     problems/length-of-last-word/README.md        | 25 +++--
     problems/lfu-cache/README.md                  | 29 +++---
     problems/longest-turbulent-subarray/README.md | 56 +++++------
     .../README.md                                 |  2 +-
     .../README.md                                 | 28 ++++++
     problems/maximize-grid-happiness/README.md    | 89 +++++++++++++++++
     .../README.md                                 |  4 +-
     problems/merge-intervals/README.md            | 12 ++-
     .../README.md                                 | 60 ++++++++++++
     .../minimum-jumps-to-reach-home/README.md     | 77 +++++++++++++++
     .../README.md                                 | 65 +++++++++++++
     problems/n-queens-ii/README.md                | 38 ++++----
     problems/n-queens/README.md                   | 39 ++++----
     problems/palindrome-pairs/README.md           |  2 +-
     problems/permutations/README.md               | 33 ++++---
     problems/power-of-four/README.md              | 32 ++++---
     problems/power-of-three/README.md             |  2 +-
     problems/power-of-two/README.md               |  4 +-
     problems/range-sum-of-bst/README.md           |  1 +
     problems/rotate-list/README.md                | 33 ++++---
     problems/similar-string-groups/README.md      | 25 +++--
     problems/spiral-matrix-ii/README.md           | 28 ++++--
     problems/spiral-matrix/README.md              | 31 +++---
     problems/sqrtx/README.md                      | 22 +++--
     problems/stone-game-ii/README.md              | 17 +++-
     problems/string-to-integer-atoi/README.md     |  2 +-
     problems/strong-password-checker/README.md    | 41 ++++++--
     problems/subsets/README.md                    | 35 ++++---
     problems/sum-of-subarray-minimums/README.md   | 27 ++++++
     problems/text-justification/README.md         | 37 ++++----
     problems/valid-number/README.md               | 19 +++-
     problems/valid-square/README.md               | 37 +++++---
     problems/word-search/README.md                |  9 +-
     tag/README.md                                 |  2 +-
     tag/array/README.md                           |  2 +
     tag/backtracking/README.md                    |  2 +
     tag/binary-search/README.md                   |  1 +
     tag/breadth-first-search/README.md            |  1 +
     tag/depth-first-search/README.md              |  1 +
     tag/design/README.md                          |  1 +
     tag/dynamic-programming/README.md             |  3 +
     tag/greedy/README.md                          |  3 +
     tag/linked-list/README.md                     |  2 +-
     tag/recursion/README.md                       |  2 +-
     tag/string/README.md                          |  1 +
     tag/tags.json                                 | 10 +-
     tag/tree/README.md                            |  5 +-
     tag/two-pointers/README.md                    |  1 +
     62 files changed, 1234 insertions(+), 317 deletions(-)
     create mode 100644 problems/defuse-the-bomb/README.md
     create mode 100644 problems/design-an-ordered-stream/README.md
     create mode 100644 problems/determine-if-two-strings-are-close/README.md
     create mode 100644 problems/distribute-repeating-integers/README.md
     create mode 100644 problems/hopper-company-queries-iii/README.md
     create mode 100644 problems/hopper-company-queries-iii/mysql_schemas.sql
     create mode 100644 problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md
     create mode 100644 problems/maximize-grid-happiness/README.md
     create mode 100644 problems/minimum-deletions-to-make-string-balanced/README.md
     create mode 100644 problems/minimum-jumps-to-reach-home/README.md
     create mode 100644 problems/minimum-operations-to-reduce-x-to-zero/README.md
    
    diff --git a/README.md b/README.md
    index e2e115c82..1d37785b4 100644
    --- a/README.md
    +++ b/README.md
    @@ -70,12 +70,22 @@ LeetCode Problems' Solutions
     
     | # | Title | Solution | Difficulty |
     | :-: | - | - | :-: |
    +| 1659 | [Maximize Grid Happiness](https://leetcode.com/problems/maximize-grid-happiness "最大化网格幸福感") | [Go](problems/maximize-grid-happiness) | Hard |
    +| 1658 | [Minimum Operations to Reduce X to Zero](https://leetcode.com/problems/minimum-operations-to-reduce-x-to-zero "将 x 减到 0 的最小操作数") | [Go](problems/minimum-operations-to-reduce-x-to-zero) | Medium |
    +| 1657 | [Determine if Two Strings Are Close](https://leetcode.com/problems/determine-if-two-strings-are-close "确定两个字符串是否接近") | [Go](problems/determine-if-two-strings-are-close) | Medium |
    +| 1656 | [Design an Ordered Stream](https://leetcode.com/problems/design-an-ordered-stream "设计有序流") | [Go](problems/design-an-ordered-stream) | Easy |
    +| 1655 | [Distribute Repeating Integers](https://leetcode.com/problems/distribute-repeating-integers "分配重复整数") | [Go](problems/distribute-repeating-integers) | Hard |
    +| 1654 | [Minimum Jumps to Reach Home](https://leetcode.com/problems/minimum-jumps-to-reach-home "到家的最少跳跃次数") | [Go](problems/minimum-jumps-to-reach-home) | Medium |
    +| 1653 | [Minimum Deletions to Make String Balanced](https://leetcode.com/problems/minimum-deletions-to-make-string-balanced "使字符串平衡的最少删除次数") | [Go](problems/minimum-deletions-to-make-string-balanced) | Medium |
    +| 1652 | [Defuse the Bomb](https://leetcode.com/problems/defuse-the-bomb "拆炸弹") | [Go](problems/defuse-the-bomb) | Easy |
    +| 1651 | [Hopper Company Queries III](https://leetcode.com/problems/hopper-company-queries-iii) 🔒 | [MySQL](problems/hopper-company-queries-iii) | Hard |
    +| 1650 | [Lowest Common Ancestor of a Binary Tree III](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iii) 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-iii) | Medium |
     | 1649 | [Create Sorted Array through Instructions](https://leetcode.com/problems/create-sorted-array-through-instructions "通过指令创建有序数组") | [Go](problems/create-sorted-array-through-instructions) | Hard |
     | 1648 | [Sell Diminishing-Valued Colored Balls](https://leetcode.com/problems/sell-diminishing-valued-colored-balls "销售价值减少的颜色球") | [Go](problems/sell-diminishing-valued-colored-balls) | Medium |
     | 1647 | [Minimum Deletions to Make Character Frequencies Unique](https://leetcode.com/problems/minimum-deletions-to-make-character-frequencies-unique "字符频次唯一的最小删除次数") | [Go](problems/minimum-deletions-to-make-character-frequencies-unique) | Medium |
     | 1646 | [Get Maximum in Generated Array](https://leetcode.com/problems/get-maximum-in-generated-array "获取生成数组中的最大值") | [Go](problems/get-maximum-in-generated-array) | Easy |
     | 1645 | [Hopper Company Queries II](https://leetcode.com/problems/hopper-company-queries-ii) 🔒 | [MySQL](problems/hopper-company-queries-ii) | Hard |
    -| 1644 | [Lowest Common Ancestor of a Binary Tree II](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-ii) 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-ii) | Medium |
    +| 1644 | [Lowest Common Ancestor of a Binary Tree II](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-ii "二叉树的最近公共祖先 II") 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-ii) | Medium |
     | 1643 | [Kth Smallest Instructions](https://leetcode.com/problems/kth-smallest-instructions "第 K 条最小指令") | [Go](problems/kth-smallest-instructions) | Hard |
     | 1642 | [Furthest Building You Can Reach](https://leetcode.com/problems/furthest-building-you-can-reach "可以到达的最远建筑") | [Go](problems/furthest-building-you-can-reach) | Medium |
     | 1641 | [Count Sorted Vowel Strings](https://leetcode.com/problems/count-sorted-vowel-strings "统计字典序元音字符串的数目") | [Go](problems/count-sorted-vowel-strings) | Medium |
    @@ -85,7 +95,7 @@ LeetCode Problems' Solutions
     | 1637 | [Widest Vertical Area Between Two Points Containing No Points](https://leetcode.com/problems/widest-vertical-area-between-two-points-containing-no-points "两点之间不包含任何点的最宽垂直面积") | [Go](problems/widest-vertical-area-between-two-points-containing-no-points) | Medium |
     | 1636 | [Sort Array by Increasing Frequency](https://leetcode.com/problems/sort-array-by-increasing-frequency "按照频率将数组升序排序") | [Go](problems/sort-array-by-increasing-frequency) | Easy |
     | 1635 | [Hopper Company Queries I](https://leetcode.com/problems/hopper-company-queries-i) 🔒 | [MySQL](problems/hopper-company-queries-i) | Hard |
    -| 1634 | [Add Two Polynomials Represented as Linked Lists](https://leetcode.com/problems/add-two-polynomials-represented-as-linked-lists) 🔒 | [Go](problems/add-two-polynomials-represented-as-linked-lists) | Medium |
    +| 1634 | [Add Two Polynomials Represented as Linked Lists](https://leetcode.com/problems/add-two-polynomials-represented-as-linked-lists "求两个多项式链表的和") 🔒 | [Go](problems/add-two-polynomials-represented-as-linked-lists) | Medium |
     | 1633 | [Percentage of Users Attended a Contest](https://leetcode.com/problems/percentage-of-users-attended-a-contest "各赛事的用户注册率") 🔒 | [MySQL](problems/percentage-of-users-attended-a-contest) | Easy |
     | 1632 | [Rank Transform of a Matrix](https://leetcode.com/problems/rank-transform-of-a-matrix "矩阵转换后的秩") | [Go](problems/rank-transform-of-a-matrix) | Hard |
     | 1631 | [Path With Minimum Effort](https://leetcode.com/problems/path-with-minimum-effort "最小体力消耗路径") | [Go](problems/path-with-minimum-effort) | Medium |
    diff --git a/problems/add-binary/README.md b/problems/add-binary/README.md
    index 072f50da0..5ea213e32 100644
    --- a/problems/add-binary/README.md
    +++ b/problems/add-binary/README.md
    @@ -11,29 +11,23 @@
     
     ## [67. Add Binary (Easy)](https://leetcode.com/problems/add-binary "二进制求和")
     
    -

    Given two binary strings, return their sum (also a binary string).

    - -

    The input strings are both non-empty and contains only characters 1 or 0.

    +

    Given two binary strings a and b, return their sum as a binary string.

    +

     

    Example 1:

    - -
    -Input: a = "11", b = "1"
    -Output: "100"
    - -

    Example 2:

    - -
    -Input: a = "1010", b = "1011"
    -Output: "10101"
    - +
    Input: a = "11", b = "1"
    +Output: "100"
    +

    Example 2:

    +
    Input: a = "1010", b = "1011"
    +Output: "10101"
    +

     

    Constraints:

      -
    • Each string consists only of '0' or '1' characters.
    • -
    • 1 <= a.length, b.length <= 10^4
    • -
    • Each string is either "0" or doesn't contain any leading zero.
    • +
    • 1 <= a.length, b.length <= 104
    • +
    • a and b consist only of '0' or '1' characters.
    • +
    • Each string does not contain leading zeros except for the zero itself.
    ### Related Topics diff --git a/problems/add-two-polynomials-represented-as-linked-lists/README.md b/problems/add-two-polynomials-represented-as-linked-lists/README.md index fb4e8668f..6bccb2b37 100644 --- a/problems/add-two-polynomials-represented-as-linked-lists/README.md +++ b/problems/add-two-polynomials-represented-as-linked-lists/README.md @@ -9,7 +9,7 @@                  [Next >](../hopper-company-queries-i "Hopper Company Queries I") -## [1634. Add Two Polynomials Represented as Linked Lists (Medium)](https://leetcode.com/problems/add-two-polynomials-represented-as-linked-lists "") +## [1634. Add Two Polynomials Represented as Linked Lists (Medium)](https://leetcode.com/problems/add-two-polynomials-represented-as-linked-lists "求两个多项式链表的和") diff --git a/problems/bricks-falling-when-hit/README.md b/problems/bricks-falling-when-hit/README.md index 47c98e432..6be8d38b1 100644 --- a/problems/bricks-falling-when-hit/README.md +++ b/problems/bricks-falling-when-hit/README.md @@ -11,39 +11,50 @@ ## [803. Bricks Falling When Hit (Hard)](https://leetcode.com/problems/bricks-falling-when-hit "打砖块") -

    We have a grid of 1s and 0s; the 1s in a cell represent bricks.  A brick will not drop if and only if it is directly connected to the top of the grid, or at least one of its (4-way) adjacent bricks will not drop.

    +

    You are given an m x n binary grid, where each 1 represents a brick. A brick will not drop if:

    -

    We will do some erasures sequentially. Each time we want to do the erasure at the location (i, j), the brick (if it exists) on that location will disappear, and then some other bricks may drop because of that erasure.

    +
      +
    • It is directly connected to the top of the grid, or
    • +
    • At least one of its four adjacent bricks will not drop.
    • +
    + +

    You are also given an array hits. We will do some erasures sequentially. Each time we want to do the erasure at the location hits[i] = (xi, yi), the brick (if it exists) on that location will disappear, and then some other bricks may drop because of that erasure.

    + +

    Return an array representing the number of bricks that will drop after each erasure in sequence.

    -

    Return an array representing the number of bricks that will drop after each erasure in sequence.

    +

    Note that an erasure may refer to a location with no brick and if it does, no bricks drop.

    + +

     

    +

    Example 1:

    -Example 1:
    -Input: 
    -grid = [[1,0,0,0],[1,1,1,0]]
    -hits = [[1,0]]
    +Input: grid = [[1,0,0,0],[1,1,1,0]], hits = [[1,0]]
     Output: [2]
    -Explanation: 
    -If we erase the brick at (1, 0), the brick at (1, 1) and (1, 2) will drop. So we should return 2.
    +Explanation: If we erase the brick at (1, 0), the brick at (1, 1) and (1, 2) will drop. So we should return 2. +
    + +

    Example 2:

    -Example 2:
    -Input: 
    -grid = [[1,0,0,0],[1,1,0,0]]
    -hits = [[1,1],[1,0]]
    +Input: grid = [[1,0,0,0],[1,1,0,0]], hits = [[1,1],[1,0]]
     Output: [0,0]
    -Explanation: 
    -When we erase the brick at (1, 0), the brick at (1, 1) has already disappeared due to the last move. So each erasure will cause no bricks dropping.  Note that the erased brick (1, 0) will not be counted as a dropped brick.
    +Explanation: When we erase the brick at (1, 0), the brick at (1, 1) has already disappeared due to the last move. So each erasure will cause no bricks dropping. +Note that the erased brick (1, 0) will not be counted as a dropped brick. +

     

    - -

    Note:

    +

    Constraints:

      -
    • The number of rows and columns in the grid will be in the range [1, 200].
    • -
    • The number of erasures will not exceed the area of the grid.
    • -
    • It is guaranteed that each erasure will be different from any other erasure, and located inside the grid.
    • -
    • An erasure may refer to a location with no brick - if it does, no bricks drop.
    • +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 200
    • +
    • grid[i][j] is 0 or 1.
    • +
    • 1 <= hits.length <= 4 * 104
    • +
    • hits[i].length == 2
    • +
    • 0 <= x<= m - 1
    • +
    • 0 <= yi <= n - 1
    • +
    • All (xi, yi) are unique.
    ### Related Topics diff --git a/problems/climbing-stairs/README.md b/problems/climbing-stairs/README.md index 1058f7503..28cbb8904 100644 --- a/problems/climbing-stairs/README.md +++ b/problems/climbing-stairs/README.md @@ -11,14 +11,15 @@ ## [70. Climbing Stairs (Easy)](https://leetcode.com/problems/climbing-stairs "爬楼梯") -

    You are climbing a stair case. It takes n steps to reach to the top.

    +

    You are climbing a staircase. It takes n steps to reach the top.

    -

    Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?

    +

    Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?

    +

     

    Example 1:

    -Input: 2
    +Input: n = 2
     Output: 2
     Explanation: There are two ways to climb to the top.
     1. 1 step + 1 step
    @@ -28,7 +29,7 @@
     

    Example 2:

    -Input: 3
    +Input: n = 3
     Output: 3
     Explanation: There are three ways to climb to the top.
     1. 1 step + 1 step + 1 step
    diff --git a/problems/create-sorted-array-through-instructions/README.md b/problems/create-sorted-array-through-instructions/README.md
    index 09d92d7f4..87cb04c65 100644
    --- a/problems/create-sorted-array-through-instructions/README.md
    +++ b/problems/create-sorted-array-through-instructions/README.md
    @@ -7,7 +7,7 @@
     
     [< Previous](../sell-diminishing-valued-colored-balls "Sell Diminishing-Valued Colored Balls")
                     
    -Next >
    +[Next >](../lowest-common-ancestor-of-a-binary-tree-iii "Lowest Common Ancestor of a Binary Tree III")
     
     ## [1649. Create Sorted Array through Instructions (Hard)](https://leetcode.com/problems/create-sorted-array-through-instructions "通过指令创建有序数组")
     
    diff --git a/problems/defuse-the-bomb/README.md b/problems/defuse-the-bomb/README.md
    new file mode 100644
    index 000000000..49481547e
    --- /dev/null
    +++ b/problems/defuse-the-bomb/README.md
    @@ -0,0 +1,75 @@
    +
    +
    +
    +
    +
    +
    +
    +[< Previous](../hopper-company-queries-iii "Hopper Company Queries III")
    +                
    +[Next >](../minimum-deletions-to-make-string-balanced "Minimum Deletions to Make String Balanced")
    +
    +## [1652. Defuse the Bomb (Easy)](https://leetcode.com/problems/defuse-the-bomb "拆炸弹")
    +
    +

    You have a bomb to defuse, and your time is running out! Your informer will provide you with a circular array code of length of n and a key k.

    + +

    To decrypt the code, you must replace every number. All the numbers are replaced simultaneously.

    + +
      +
    • If k > 0, replace the ith number with the sum of the next k numbers.
    • +
    • If k < 0, replace the ith number with the sum of the previous k numbers.
    • +
    • If k == 0, replace the ith number with 0.
    • +
    + +

    As code is circular, the next element of code[n-1] is code[0], and the previous element of code[0] is code[n-1].

    + +

    Given the circular array code and an integer key k, return the decrypted code to defuse the bomb!

    + +

     

    +

    Example 1:

    + +
    +Input: code = [5,7,1,4], k = 3
    +Output: [12,10,16,13]
    +Explanation: Each number is replaced by the sum of the next 3 numbers. The decrypted code is [7+1+4, 1+4+5, 4+5+7, 5+7+1]. Notice that the numbers wrap around.
    +
    + +

    Example 2:

    + +
    +Input: code = [1,2,3,4], k = 0
    +Output: [0,0,0,0]
    +Explanation: When k is zero, the numbers are replaced by 0. 
    +
    + +

    Example 3:

    + +
    +Input: code = [2,4,9,3], k = -2
    +Output: [12,5,6,13]
    +Explanation: The decrypted code is [3+9, 2+3, 4+2, 9+4]. Notice that the numbers wrap around again. If k is negative, the sum is of the previous numbers.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == code.length
    • +
    • 1 <= n <= 100
    • +
    • 1 <= code[i] <= 100
    • +
    • -(n - 1) <= k <= n - 1
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +As the array is circular, use modulo to find the correct index. +
    + +
    +Hint 2 +The constraints are low enough for a brute-force solution. +
    diff --git a/problems/design-an-ordered-stream/README.md b/problems/design-an-ordered-stream/README.md new file mode 100644 index 000000000..adad5c7c3 --- /dev/null +++ b/problems/design-an-ordered-stream/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../distribute-repeating-integers "Distribute Repeating Integers") +                 +[Next >](../determine-if-two-strings-are-close "Determine if Two Strings Are Close") + +## [1656. Design an Ordered Stream (Easy)](https://leetcode.com/problems/design-an-ordered-stream "设计有序流") + +

    There are n (id, value) pairs, where id is an integer between 1 and n and value is a string. No two pairs have the same id.

    + +

    Design a stream that takes the n pairs in an arbitrary order, and returns the values over several calls in increasing order of their ids.

    + +

    Implement the OrderedStream class:

    + +
      +
    • OrderedStream(int n) Constructs the stream to take n values and sets a current ptr to 1.
    • +
    • String[] insert(int id, String value) Stores the new (id, value) pair in the stream. After storing the pair: +
        +
      • If the stream has stored a pair with id = ptr, then find the longest contiguous incrementing sequence of ids starting with id = ptr and return a list of the values associated with those ids in order. Then, update ptr to the last id + 1.
      • +
      • Otherwise, return an empty list.
      • +
      +
    • +
    + +

     

    +

    Example:

    + +

    + +
    +Input
    +["OrderedStream", "insert", "insert", "insert", "insert", "insert"]
    +[[5], [3, "ccccc"], [1, "aaaaa"], [2, "bbbbb"], [5, "eeeee"], [4, "ddddd"]]
    +Output
    +[null, [], ["aaaaa"], ["bbbbb", "ccccc"], [], ["ddddd", "eeeee"]]
    +
    +Explanation
    +OrderedStream os= new OrderedStream(5);
    +os.insert(3, "ccccc"); // Inserts (3, "ccccc"), returns [].
    +os.insert(1, "aaaaa"); // Inserts (1, "aaaaa"), returns ["aaaaa"].
    +os.insert(2, "bbbbb"); // Inserts (2, "bbbbb"), returns ["bbbbb", "ccccc"].
    +os.insert(5, "eeeee"); // Inserts (5, "eeeee"), returns [].
    +os.insert(4, "ddddd"); // Inserts (4, "ddddd"), returns ["ddddd", "eeeee"].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 1000
    • +
    • 1 <= id <= n
    • +
    • value.length == 5
    • +
    • value consists only of lowercase letters.
    • +
    • Each call to insert will have a unique id.
    • +
    • Exactly n calls will be made to insert.
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Maintain the next id that should be outputted. +
    + +
    +Hint 2 +Maintain the ids that were inserted in the stream. +
    + +
    +Hint 3 +Per each insert, make a loop where you check if the id that has the turn has been inserted, and if so increment the id that has the turn and continue the loop, else break. +
    diff --git a/problems/determine-if-two-strings-are-close/README.md b/problems/determine-if-two-strings-are-close/README.md new file mode 100644 index 000000000..88f533583 --- /dev/null +++ b/problems/determine-if-two-strings-are-close/README.md @@ -0,0 +1,91 @@ + + + + + + + +[< Previous](../design-an-ordered-stream "Design an Ordered Stream") +                 +[Next >](../minimum-operations-to-reduce-x-to-zero "Minimum Operations to Reduce X to Zero") + +## [1657. Determine if Two Strings Are Close (Medium)](https://leetcode.com/problems/determine-if-two-strings-are-close "确定两个字符串是否接近") + +

    Two strings are considered close if you can attain one from the other using the following operations:

    + +
      +
    • Operation 1: Swap any two existing characters. +
        +
      • For example, abcde -> aecdb
      • +
      +
    • +
    • Operation 2: Transform every occurrence of one existing character into another existing character, and do the same with the other character. +
        +
      • For example, aacabb -> bbcbaa (all a's turn into b's, and all b's turn into a's)
      • +
      +
    • +
    + +

    You can use the operations on either string as many times as necessary.

    + +

    Given two strings, word1 and word2, return true if word1 and word2 are close, and false otherwise.

    + +

     

    +

    Example 1:

    + +
    +Input: word1 = "abc", word2 = "bca"
    +Output: true
    +Explanation: You can attain word2 from word1 in 2 operations.
    +Apply Operation 1: "abc" -> "acb"
    +Apply Operation 1: "acb" -> "bca"
    +
    + +

    Example 2:

    + +
    +Input: word1 = "a", word2 = "aa"
    +Output: false
    +Explanation: It is impossible to attain word2 from word1, or vice versa, in any number of operations.
    +
    + +

    Example 3:

    + +
    +Input: word1 = "cabbba", word2 = "abbccc"
    +Output: true
    +Explanation: You can attain word2 from word1 in 3 operations.
    +Apply Operation 1: "cabbba" -> "caabbb"
    +Apply Operation 2: "caabbb" -> "baaccc"
    +Apply Operation 2: "baaccc" -> "abbccc"
    +
    + +

    Example 4:

    + +
    +Input: word1 = "cabbba", word2 = "aabbss"
    +Output: false
    +Explanation: It is impossible to attain word2 from word1, or vice versa, in any amount of operations.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= word1.length, word2.length <= 105
    • +
    • word1 and word2 contain only lowercase English letters.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Operation 1 allows you to freely reorder the string. +
    + +
    +Hint 2 +Operation 2 allows you to freely reassign the letters' frequencies. +
    diff --git a/problems/distribute-repeating-integers/README.md b/problems/distribute-repeating-integers/README.md new file mode 100644 index 000000000..497d9a6b3 --- /dev/null +++ b/problems/distribute-repeating-integers/README.md @@ -0,0 +1,95 @@ + + + + + + + +[< Previous](../minimum-jumps-to-reach-home "Minimum Jumps to Reach Home") +                 +[Next >](../design-an-ordered-stream "Design an Ordered Stream") + +## [1655. Distribute Repeating Integers (Hard)](https://leetcode.com/problems/distribute-repeating-integers "分配重复整数") + +

    You are given an array of n integers, nums, where there are at most 50 unique values in the array. You are also given an array of m customer order quantities, quantity, where quantity[i] is the amount of integers the ith customer ordered. Determine if it is possible to distribute nums such that:

    + +
      +
    • The ith customer gets exactly quantity[i] integers,
    • +
    • The integers the ith customer gets are all equal, and
    • +
    • Every customer is satisfied.
    • +
    + +

    Return true if it is possible to distribute nums according to the above conditions.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3,4], quantity = [2]
    +Output: false
    +Explanation: The 0th customer cannot be given two different integers.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,2,3,3], quantity = [2]
    +Output: true
    +Explanation: The 0th customer is given [3,3]. The integers [1,2] are not used.
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,1,2,2], quantity = [2,2]
    +Output: true
    +Explanation: The 0th customer is given [1,1], and the 1st customer is given [2,2].
    +
    + +

    Example 4:

    + +
    +Input: nums = [1,1,2,3], quantity = [2,2]
    +Output: false
    +Explanation: Although the 0th customer could be given [1,1], the 1st customer cannot be satisfied.
    + +

    Example 5:

    + +
    +Input: nums = [1,1,1,1,1], quantity = [2,3]
    +Output: true
    +Explanation: The 0th customer is given [1,1], and the 1st customer is given [1,1,1].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= nums[i] <= 1000
    • +
    • m == quantity.length
    • +
    • 1 <= m <= 10
    • +
    • 1 <= quantity[i] <= 105
    • +
    • There are at most 50 unique values in nums.
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
    +Hint 1 +Count the frequencies of each number. For example, if nums = [4,4,5,5,5], frequencies = [2,3]. +
    + +
    +Hint 2 +Each customer wants all of their numbers to be the same. This means that each customer will be assigned to one number. +
    + +
    +Hint 3 +Use dynamic programming. Iterate through the numbers' frequencies, and choose some subset of customers to be assigned to this number. +
    diff --git a/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md b/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md index 3d12015d3..dafa8151a 100644 --- a/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md +++ b/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md @@ -11,9 +11,9 @@ ## [1489. Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree (Hard)](https://leetcode.com/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree "找到最小生成树里的关键边和伪关键边") -

    Given a weighted undirected connected graph with n vertices numbered from 0 to n-1, and an array edges where edges[i] = [fromi, toi, weighti] represents a bidirectional and weighted edge between nodes fromi and toi. A minimum spanning tree (MST) is a subset of the edges of the graph that connects all vertices without cycles and with the minimum possible total edge weight.

    +

    Given a weighted undirected connected graph with n vertices numbered from 0 to n - 1, and an array edges where edges[i] = [ai, bi, weighti] represents a bidirectional and weighted edge between nodes ai and bi. A minimum spanning tree (MST) is a subset of the graph's edges that connects all vertices without cycles and with the minimum possible total edge weight.

    -

    Find all the critical and pseudo-critical edges in the minimum spanning tree (MST) of the given graph. An MST edge whose deletion from the graph would cause the MST weight to increase is called a critical edge. A pseudo-critical edge, on the other hand, is that which can appear in some MSTs but not all.

    +

    Find all the critical and pseudo-critical edges in the given graph's minimum spanning tree (MST). An MST edge whose deletion from the graph would cause the MST weight to increase is called a critical edge. On the other hand, a pseudo-critical edge is that which can appear in some MSTs but not all.

    Note that you can return the indices of the edges in any order.

    @@ -49,9 +49,9 @@ The edges 2, 3, 4, and 5 are only part of some MSTs, therefore they are consider
  • 2 <= n <= 100
  • 1 <= edges.length <= min(200, n * (n - 1) / 2)
  • edges[i].length == 3
  • -
  • 0 <= fromi < toi < n
  • +
  • 0 <= ai < bi < n
  • 1 <= weighti <= 1000
  • -
  • All pairs (fromi, toi) are distinct.
  • +
  • All pairs (ai, bi) are distinct.
  • ### Related Topics diff --git a/problems/find-minimum-in-rotated-sorted-array/README.md b/problems/find-minimum-in-rotated-sorted-array/README.md index 0eb160154..b7a6c720e 100644 --- a/problems/find-minimum-in-rotated-sorted-array/README.md +++ b/problems/find-minimum-in-rotated-sorted-array/README.md @@ -11,29 +11,51 @@ ## [153. Find Minimum in Rotated Sorted Array (Medium)](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array "寻找旋转排序数组中的最小值") -

    Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e.,  [0,1,2,4,5,6,7] might become  [4,5,6,7,0,1,2]).

    +

    Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become:

    -

    Return the minimum element of this array.

    +
      +
    • [4,5,6,7,0,1,2] if it was rotated 4 times.
    • +
    • [0,1,2,4,5,6,7] if it was rotated 7 times.
    • +
    + +

    Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in the array [a[n-1], a[0], a[1], a[2], ..., a[n-2]].

    + +

    Given the sorted rotated array nums, return the minimum element of this array.

     

    Example 1:

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

    Example 2:

    -
    Input: nums = [4,5,6,7,0,1,2]
    +Explanation: The original array was [1,2,3,4,5] rotated 3 times.
    +
    + +

    Example 2:

    + +
    +Input: nums = [4,5,6,7,0,1,2]
     Output: 0
    -

    Example 3:

    -
    Input: nums = [1]
    -Output: 1
    +Explanation: The original array was [0,1,2,4,5,6,7] and it was rotated 4 times.
    +
    + +

    Example 3:

    + +
    +Input: nums = [11,13,15,17]
    +Output: 11
    +Explanation: The original array was [11,13,15,17] and it was rotated 4 times. 
     
    +

     

    Constraints:

      -
    • 1 <= nums.length <= 5000
    • +
    • n == nums.length
    • +
    • 1 <= n <= 5000
    • -5000 <= nums[i] <= 5000
    • All the integers of nums are unique.
    • -
    • nums is sorted and rotated at some pivot.
    • +
    • nums is sorted and rotated between 1 and n times.
    ### Related Topics diff --git a/problems/hopper-company-queries-iii/README.md b/problems/hopper-company-queries-iii/README.md new file mode 100644 index 000000000..5fc4b1c56 --- /dev/null +++ b/problems/hopper-company-queries-iii/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../lowest-common-ancestor-of-a-binary-tree-iii "Lowest Common Ancestor of a Binary Tree III") +                 +[Next >](../defuse-the-bomb "Defuse the Bomb") + +## [1651. Hopper Company Queries III (Hard)](https://leetcode.com/problems/hopper-company-queries-iii "") + + diff --git a/problems/hopper-company-queries-iii/mysql_schemas.sql b/problems/hopper-company-queries-iii/mysql_schemas.sql new file mode 100644 index 000000000..f66daff0b --- /dev/null +++ b/problems/hopper-company-queries-iii/mysql_schemas.sql @@ -0,0 +1,39 @@ +Create table If Not Exists Drivers (driver_id int, join_date date); +Create table If Not Exists Rides (ride_id int, user_id int, requested_at date); +Create table If Not Exists AcceptedRides (ride_id int, driver_id int, ride_distance int, ride_duration int); +Truncate table Drivers; +insert into Drivers (driver_id, join_date) values ('10', '2019-12-10'); +insert into Drivers (driver_id, join_date) values ('8', '2020-1-13'); +insert into Drivers (driver_id, join_date) values ('5', '2020-2-16'); +insert into Drivers (driver_id, join_date) values ('7', '2020-3-8'); +insert into Drivers (driver_id, join_date) values ('4', '2020-5-17'); +insert into Drivers (driver_id, join_date) values ('1', '2020-10-24'); +insert into Drivers (driver_id, join_date) values ('6', '2021-1-5'); +Truncate table Rides; +insert into Rides (ride_id, user_id, requested_at) values ('6', '75', '2019-12-9'); +insert into Rides (ride_id, user_id, requested_at) values ('1', '54', '2020-2-9'); +insert into Rides (ride_id, user_id, requested_at) values ('10', '63', '2020-3-4'); +insert into Rides (ride_id, user_id, requested_at) values ('19', '39', '2020-4-6'); +insert into Rides (ride_id, user_id, requested_at) values ('3', '41', '2020-6-3'); +insert into Rides (ride_id, user_id, requested_at) values ('13', '52', '2020-6-22'); +insert into Rides (ride_id, user_id, requested_at) values ('7', '69', '2020-7-16'); +insert into Rides (ride_id, user_id, requested_at) values ('17', '70', '2020-8-25'); +insert into Rides (ride_id, user_id, requested_at) values ('20', '81', '2020-11-2'); +insert into Rides (ride_id, user_id, requested_at) values ('5', '57', '2020-11-9'); +insert into Rides (ride_id, user_id, requested_at) values ('2', '42', '2020-12-9'); +insert into Rides (ride_id, user_id, requested_at) values ('11', '68', '2021-1-11'); +insert into Rides (ride_id, user_id, requested_at) values ('15', '32', '2021-1-17'); +insert into Rides (ride_id, user_id, requested_at) values ('12', '11', '2021-1-19'); +insert into Rides (ride_id, user_id, requested_at) values ('14', '18', '2021-1-27'); +Truncate table AcceptedRides; +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('10', '10', '63', '38'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('13', '10', '73', '96'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('7', '8', '100', '28'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('17', '7', '119', '68'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('20', '1', '121', '92'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('5', '7', '42', '101'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('2', '4', '6', '38'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('11', '8', '37', '43'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('15', '8', '108', '82'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('12', '8', '38', '34'); +insert into AcceptedRides (ride_id, driver_id, ride_distance, ride_duration) values ('14', '1', '90', '74'); diff --git a/problems/length-of-last-word/README.md b/problems/length-of-last-word/README.md index 3ac31cbac..6bbee543f 100644 --- a/problems/length-of-last-word/README.md +++ b/problems/length-of-last-word/README.md @@ -11,20 +11,25 @@ ## [58. Length of Last Word (Easy)](https://leetcode.com/problems/length-of-last-word "最后一个单词的长度") -

    Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word (last word means the last appearing word if we loop from left to right) in the string.

    +

    Given a string s consists of some words separated by spaces, return the length of the last word in the string. If the last word does not exist, return 0.

    -

    If the last word does not exist, return 0.

    +

    A word is a maximal substring consisting of non-space characters only.

    -

    Note: A word is defined as a maximal substring consisting of non-space characters only.

    - -

    Example:

    - -
    -Input: "Hello World"
    -Output: 5
    +

     

    +

    Example 1:

    +
    Input: s = "Hello World"
    +Output: 5
    +

    Example 2:

    +
    Input: s = " "
    +Output: 0
     
    -

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 104
    • +
    • s consists of only English letters and spaces ' '.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/lfu-cache/README.md b/problems/lfu-cache/README.md index 61b940a26..f951ee4ce 100644 --- a/problems/lfu-cache/README.md +++ b/problems/lfu-cache/README.md @@ -23,9 +23,6 @@

    Notice that the number of times an item is used is the number of calls to the get and put functions for that item since it was inserted. This number is set to zero when the item is removed.

    -

    Follow up:
    -Could you do both operations in O(1) time complexity?

    -

     

    Example 1:

    @@ -37,18 +34,17 @@ Could you do both operations in O(1) time complexity?

    [null, null, null, 1, null, -1, 3, null, -1, 3, 4] Explanation -LFUCache lFUCache = new LFUCache(2); -lFUCache.put(1, 1); -lFUCache.put(2, 2); -lFUCache.get(1); // return 1 -lFUCache.put(3, 3); // evicts key 2 -lFUCache.get(2); // return -1 (not found) -lFUCache.get(3); // return 3 -lFUCache.put(4, 4); // evicts key 1. -lFUCache.get(1); // return -1 (not found) -lFUCache.get(3); // return 3 -lFUCache.get(4); // return 4 - +LFUCache lfu = new LFUCache(2); +lfu.put(1, 1); +lfu.put(2, 2); +lfu.get(1); // return 1 +lfu.put(3, 3); // evicts key 2 +lfu.get(2); // return -1 (not found) +lfu.get(3); // return 3 +lfu.put(4, 4); // evicts key 1. +lfu.get(1); // return -1 (not found) +lfu.get(3); // return 3 +lfu.get(4); // return 4

     

    @@ -59,6 +55,9 @@ lFUCache.get(4); // return 4
  • At most 105 calls will be made to get and put.
  • +

     

    +Follow up: Could you do both operations in O(1) time complexity?  + ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/longest-turbulent-subarray/README.md b/problems/longest-turbulent-subarray/README.md index 6883463ad..7487ae651 100644 --- a/problems/longest-turbulent-subarray/README.md +++ b/problems/longest-turbulent-subarray/README.md @@ -11,55 +11,57 @@ ## [978. Longest Turbulent Subarray (Medium)](https://leetcode.com/problems/longest-turbulent-subarray "最长湍流子数组") -

    A subarray A[i], A[i+1], ..., A[j] of A is said to be turbulent if and only if:

    +

    Given an integer array arr, return the length of a maximum size turbulent subarray of arr.

    -
      -
    • For i <= k < j, A[k] > A[k+1] when k is odd, and A[k] < A[k+1] when k is even;
    • -
    • OR, for i <= k < j, A[k] > A[k+1] when k is even, and A[k] < A[k+1] when k is odd.
    • -
    +

    A subarray is turbulent if the comparison sign flips between each adjacent pair of elements in the subarray.

    -

    That is, the subarray is turbulent if the comparison sign flips between each adjacent pair of elements in the subarray.

    +

    More formally, a subarray [arr[i], arr[i + 1], ..., arr[j]] of arr is said to be turbulent if and only if:

    -

    Return the length of a maximum size turbulent subarray of A.

    +
      +
    • For i <= k < j: +
        +
      • arr[k] > arr[k + 1] when k is odd, and
      • +
      • arr[k] < arr[k + 1] when k is even.
      • +
      +
    • +
    • Or, for i <= k < j: +
        +
      • arr[k] > arr[k + 1] when k is even, and
      • +
      • arr[k] < arr[k + 1] when k is odd.
      • +
      +
    • +

     

    - -

    Example 1:

    -Input: [9,4,2,10,7,8,8,1,9]
    -Output: 5
    -Explanation: (A[1] > A[2] < A[3] > A[4] < A[5])
    +Input: arr = [9,4,2,10,7,8,8,1,9]
    +Output: 5
    +Explanation: arr[1] > arr[2] < arr[3] > arr[4] < arr[5]
     
    -

    Example 2:

    -Input: [4,8,12,16]
    -Output: 2
    +Input: arr = [4,8,12,16]
    +Output: 2
     
    -

    Example 3:

    -Input: [100]
    -Output: 1
    +Input: arr = [100]
    +Output: 1
     
    -
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= A.length <= 40000
    2. -
    3. 0 <= A[i] <= 10^9
    4. -
    +
      +
    • 1 <= arr.length <= 4 * 104
    • +
    • 0 <= arr[i] <= 109
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md index 94c69f692..21d5ff7b0 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md @@ -9,7 +9,7 @@                  [Next >](../hopper-company-queries-ii "Hopper Company Queries II") -## [1644. Lowest Common Ancestor of a Binary Tree II (Medium)](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-ii "") +## [1644. Lowest Common Ancestor of a Binary Tree II (Medium)](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-ii "二叉树的最近公共祖先 II") diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md new file mode 100644 index 000000000..0221e0f0a --- /dev/null +++ b/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../create-sorted-array-through-instructions "Create Sorted Array through Instructions") +                 +[Next >](../hopper-company-queries-iii "Hopper Company Queries III") + +## [1650. Lowest Common Ancestor of a Binary Tree III (Medium)](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iii "") + + + +### Related Topics + [[Tree](../../tag/tree/README.md)] + +### Hints +
    +Hint 1 +Store the path from p to the root. +
    + +
    +Hint 2 +Traverse the path from q to the root, the first common point of the two paths is the LCA. +
    diff --git a/problems/maximize-grid-happiness/README.md b/problems/maximize-grid-happiness/README.md new file mode 100644 index 000000000..f4ac6f46b --- /dev/null +++ b/problems/maximize-grid-happiness/README.md @@ -0,0 +1,89 @@ + + + + + + + +[< Previous](../minimum-operations-to-reduce-x-to-zero "Minimum Operations to Reduce X to Zero") +                 +Next > + +## [1659. Maximize Grid Happiness (Hard)](https://leetcode.com/problems/maximize-grid-happiness "最大化网格幸福感") + +

    You are given four integers, m, n, introvertsCount, and extrovertsCount. You have an m x n grid, and there are two types of people: introverts and extroverts. There are introvertsCount introverts and extrovertsCount extroverts.

    + +

    You should decide how many people you want to live in the grid and assign each of them one grid cell. Note that you do not have to have all the people living in the grid.

    + +

    The happiness of each person is calculated as follows:

    + +
      +
    • Introverts start with 120 happiness and lose 30 happiness for each neighbor (introvert or extrovert).
    • +
    • Extroverts start with 40 happiness and gain 20 happiness for each neighbor (introvert or extrovert).
    • +
    + +

    Neighbors live in the directly adjacent cells north, east, south, and west of a person's cell.

    + +

    The grid happiness is the sum of each person's happiness. Return the maximum possible grid happiness.

    + +

     

    +

    Example 1:

    + +
    +Input: m = 2, n = 3, introvertsCount = 1, extrovertsCount = 2
    +Output: 240
    +Explanation: Assume the grid is 1-indexed with coordinates (row, column).
    +We can put the introvert in cell (1,1) and put the extroverts in cells (1,3) and (2,3).
    +- Introvert at (1,1) happiness: 120 (starting happiness) - (0 * 30) (0 neighbors) = 120
    +- Extrovert at (1,3) happiness: 40 (starting happiness) + (1 * 20) (1 neighbor) = 60
    +- Extrovert at (2,3) happiness: 40 (starting happiness) + (1 * 20) (1 neighbor) = 60
    +The grid happiness is 120 + 60 + 60 = 240.
    +The above figure shows the grid in this example with each person's happiness. The introvert stays in the light green cell while the extroverts live on the light purple cells.
    +
    + +

    Example 2:

    + +
    +Input: m = 3, n = 1, introvertsCount = 2, extrovertsCount = 1
    +Output: 260
    +Explanation: Place the two introverts in (1,1) and (3,1) and the extrovert at (2,1).
    +- Introvert at (1,1) happiness: 120 (starting happiness) - (1 * 30) (1 neighbor) = 90
    +- Extrovert at (2,1) happiness: 40 (starting happiness) + (2 * 20) (2 neighbors) = 80
    +- Introvert at (3,1) happiness: 120 (starting happiness) - (1 * 30) (1 neighbor) = 90
    +The grid happiness is 90 + 80 + 90 = 260.
    +
    + +

    Example 3:

    + +
    +Input: m = 2, n = 2, introvertsCount = 4, extrovertsCount = 0
    +Output: 240
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= m, n <= 5
    • +
    • 0 <= introvertsCount, extrovertsCount <= min(m * n, 6)
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
    +Hint 1 +For each cell, it has 3 options, either it is empty, or contains an introvert, or an extrovert. +
    + +
    +Hint 2 +You can do DP where you maintain the state of the previous row, the number of remaining introverts and extroverts, the current row and column, and try the 3 options for each cell. +
    + +
    +Hint 3 +Assume that the previous columns in the current row already belong to the previous row. +
    diff --git a/problems/maximum-difference-between-node-and-ancestor/README.md b/problems/maximum-difference-between-node-and-ancestor/README.md index 275faa7d6..205a684e7 100644 --- a/problems/maximum-difference-between-node-and-ancestor/README.md +++ b/problems/maximum-difference-between-node-and-ancestor/README.md @@ -17,7 +17,7 @@

     

    Example 1:

    - +
     Input: root = [8,3,10,1,6,null,14,null,null,4,7,13]
     Output: 7
    @@ -29,7 +29,7 @@
     Among all possible differences, the maximum value of 7 is obtained by |8 - 1| = 7.

    Example 2:

    - +
     Input: root = [1,null,2,null,0,3]
     Output: 3
    diff --git a/problems/merge-intervals/README.md b/problems/merge-intervals/README.md
    index 666523b0f..ebfc285ad 100644
    --- a/problems/merge-intervals/README.md
    +++ b/problems/merge-intervals/README.md
    @@ -11,8 +11,9 @@
     
     ## [56. Merge Intervals (Medium)](https://leetcode.com/problems/merge-intervals "合并区间")
     
    -

    Given a collection of intervals, merge all overlapping intervals.

    +

    Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.

    +

     

    Example 1:

    @@ -26,15 +27,16 @@
     
     Input: intervals = [[1,4],[4,5]]
     Output: [[1,5]]
    -Explanation: Intervals [1,4] and [4,5] are considered overlapping.
    - -

    NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

    +Explanation: Intervals [1,4] and [4,5] are considered overlapping. +

     

    Constraints:

      -
    • intervals[i][0] <= intervals[i][1]
    • +
    • 1 <= intervals.length <= 104
    • +
    • intervals[i].length == 2
    • +
    • 0 <= starti <= endi <= 104
    ### Related Topics diff --git a/problems/minimum-deletions-to-make-string-balanced/README.md b/problems/minimum-deletions-to-make-string-balanced/README.md new file mode 100644 index 000000000..3a1f549b6 --- /dev/null +++ b/problems/minimum-deletions-to-make-string-balanced/README.md @@ -0,0 +1,60 @@ + + + + + + + +[< Previous](../defuse-the-bomb "Defuse the Bomb") +                 +[Next >](../minimum-jumps-to-reach-home "Minimum Jumps to Reach Home") + +## [1653. Minimum Deletions to Make String Balanced (Medium)](https://leetcode.com/problems/minimum-deletions-to-make-string-balanced "使字符串平衡的最少删除次数") + +

    You are given a string s consisting only of characters 'a' and 'b'​​​​.

    + +

    You can delete any number of characters in s to make s balanced. s is balanced if there is no pair of indices (i,j) such that i < j and s[i] = 'b' and s[j]= 'a'.

    + +

    Return the minimum number of deletions needed to make s balanced.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "aababbab"
    +Output: 2
    +Explanation: You can either:
    +Delete the characters at 0-indexed positions 2 and 6 ("aababbab" -> "aaabbb"), or
    +Delete the characters at 0-indexed positions 3 and 6 ("aababbab" -> "aabbbb").
    +
    + +

    Example 2:

    + +
    +Input: s = "bbaaaaabb"
    +Output: 2
    +Explanation: The only solution is to delete the first two characters.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 105
    • +
    • s[i] is 'a' or 'b'​​.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +You need to find for every index the number of Bs before it and the number of A's after it +
    + +
    +Hint 2 +You can speed up the finding of A's and B's in suffix and prefix using preprocessing +
    diff --git a/problems/minimum-jumps-to-reach-home/README.md b/problems/minimum-jumps-to-reach-home/README.md new file mode 100644 index 000000000..a1f96b45a --- /dev/null +++ b/problems/minimum-jumps-to-reach-home/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../minimum-deletions-to-make-string-balanced "Minimum Deletions to Make String Balanced") +                 +[Next >](../distribute-repeating-integers "Distribute Repeating Integers") + +## [1654. Minimum Jumps to Reach Home (Medium)](https://leetcode.com/problems/minimum-jumps-to-reach-home "到家的最少跳跃次数") + +

    A certain bug's home is on the x-axis at position x. Help them get there from position 0.

    + +

    The bug jumps according to the following rules:

    + +
      +
    • It can jump exactly a positions forward (to the right).
    • +
    • It can jump exactly b positions backward (to the left).
    • +
    • It cannot jump backward twice in a row.
    • +
    • It cannot jump to any forbidden positions.
    • +
    + +

    The bug may jump forward beyond its home, but it cannot jump to positions numbered with negative integers.

    + +

    Given an array of integers forbidden, where forbidden[i] means that the bug cannot jump to the position forbidden[i], and integers a, b, and x, return the minimum number of jumps needed for the bug to reach its home. If there is no possible sequence of jumps that lands the bug on position x, return -1.

    + +

     

    +

    Example 1:

    + +
    +Input: forbidden = [14,4,18,1,15], a = 3, b = 15, x = 9
    +Output: 3
    +Explanation: 3 jumps forward (0 -> 3 -> 6 -> 9) will get the bug home.
    +
    + +

    Example 2:

    + +
    +Input: forbidden = [8,3,16,6,12,20], a = 15, b = 13, x = 11
    +Output: -1
    +
    + +

    Example 3:

    + +
    +Input: forbidden = [1,6,2,14,5,17,4], a = 16, b = 9, x = 7
    +Output: 2
    +Explanation: One jump forward (0 -> 16) then one jump backward (16 -> 7) will get the bug home.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= forbidden.length <= 1000
    • +
    • 1 <= a, b, forbidden[i] <= 2000
    • +
    • 0 <= x <= 2000
    • +
    • All the elements in forbidden are distinct.
    • +
    • Position x is not forbidden.
    • +
    + +### Related Topics + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Think of the line as a graph +
    + +
    +Hint 2 +to handle the no double back jumps condition you can handle it by holding the state of your previous jump +
    diff --git a/problems/minimum-operations-to-reduce-x-to-zero/README.md b/problems/minimum-operations-to-reduce-x-to-zero/README.md new file mode 100644 index 000000000..28215e19f --- /dev/null +++ b/problems/minimum-operations-to-reduce-x-to-zero/README.md @@ -0,0 +1,65 @@ + + + + + + + +[< Previous](../determine-if-two-strings-are-close "Determine if Two Strings Are Close") +                 +[Next >](../maximize-grid-happiness "Maximize Grid Happiness") + +## [1658. Minimum Operations to Reduce X to Zero (Medium)](https://leetcode.com/problems/minimum-operations-to-reduce-x-to-zero "将 x 减到 0 的最小操作数") + +

    You are given an integer array nums and an integer x. In one operation, you can either remove the leftmost or the rightmost element from the array nums and subtract its value from x. Note that this modifies the array for future operations.

    + +

    Return the minimum number of operations to reduce x to exactly 0 if it's possible, otherwise, return -1.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,1,4,2,3], x = 5
    +Output: 2
    +Explanation: The optimal solution is to remove the last two elements to reduce x to zero.
    +
    + +

    Example 2:

    + +
    +Input: nums = [5,6,7,8,9], x = 4
    +Output: -1
    +
    + +

    Example 3:

    + +
    +Input: nums = [3,2,20,1,1,3], x = 10
    +Output: 5
    +Explanation: The optimal solution is to remove the last three elements and the first two elements (5 operations in total) to reduce x to zero.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 104
    • +
    • 1 <= x <= 109
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Think in reverse instead of finding the minimum prefix + suffix find the maximum subarray +
    + +
    +Hint 2 +to find the maximum subarray a is standard and can be done greedily +
    diff --git a/problems/n-queens-ii/README.md b/problems/n-queens-ii/README.md index 8aba5974f..199e724f3 100644 --- a/problems/n-queens-ii/README.md +++ b/problems/n-queens-ii/README.md @@ -11,31 +11,33 @@ ## [52. N-Queens II (Hard)](https://leetcode.com/problems/n-queens-ii "N皇后 II") -

    The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.

    +

    The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other.

    -

    +

    Given an integer n, return the number of distinct solutions to the n-queens puzzle.

    -

    Given an integer n, return the number of distinct solutions to the n-queens puzzle.

    +

     

    +

    Example 1:

    + +
    +Input: n = 4
    +Output: 2
    +Explanation: There are two distinct solutions to the 4-queens puzzle as shown.
    +
    -

    Example:

    +

    Example 2:

    -Input: 4
    -Output: 2
    -Explanation: There are two distinct solutions to the 4-queens puzzle as shown below.
    -[
    - [".Q..",  // Solution 1
    -  "...Q",
    -  "Q...",
    -  "..Q."],
    -
    - ["..Q.",  // Solution 2
    -  "Q...",
    -  "...Q",
    -  ".Q.."]
    -]
    +Input: n = 1
    +Output: 1
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 9
    • +
    + ### Related Topics [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/n-queens/README.md b/problems/n-queens/README.md index 1e9f9e1cd..f11283afb 100644 --- a/problems/n-queens/README.md +++ b/problems/n-queens/README.md @@ -11,32 +11,35 @@ ## [51. N-Queens (Hard)](https://leetcode.com/problems/n-queens "N 皇后") -

    The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.

    +

    The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other.

    -

    +

    Given an integer n, return all distinct solutions to the n-queens puzzle.

    -

    Given an integer n, return all distinct solutions to the n-queens puzzle.

    +

    Each solution contains a distinct board configuration of the n-queens' placement, where 'Q' and '.' both indicate a queen and an empty space, respectively.

    -

    Each solution contains a distinct board configuration of the n-queens' placement, where 'Q' and '.' both indicate a queen and an empty space respectively.

    +

     

    +

    Example 1:

    + +
    +Input: n = 4
    +Output: [[".Q..","...Q","Q...","..Q."],["..Q.","Q...","...Q",".Q.."]]
    +Explanation: There exist two distinct solutions to the 4-queens puzzle as shown above
    +
    -

    Example:

    +

    Example 2:

    -Input: 4
    -Output: [
    - [".Q..",  // Solution 1
    -  "...Q",
    -  "Q...",
    -  "..Q."],
    -
    - ["..Q.",  // Solution 2
    -  "Q...",
    -  "...Q",
    -  ".Q.."]
    -]
    -Explanation: There exist two distinct solutions to the 4-queens puzzle as shown above.
    +Input: n = 1
    +Output: [["Q"]]
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 9
    • +
    + ### Related Topics [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/palindrome-pairs/README.md b/problems/palindrome-pairs/README.md index b3c4ecc2e..d128b81f4 100644 --- a/problems/palindrome-pairs/README.md +++ b/problems/palindrome-pairs/README.md @@ -42,7 +42,7 @@
    • 1 <= words.length <= 5000
    • -
    • 0 <= words[i] <= 300
    • +
    • 0 <= words[i].length <= 300
    • words[i] consists of lower-case English letters.
    diff --git a/problems/permutations/README.md b/problems/permutations/README.md index c23ce2de3..b550c55a1 100644 --- a/problems/permutations/README.md +++ b/problems/permutations/README.md @@ -11,22 +11,27 @@ ## [46. Permutations (Medium)](https://leetcode.com/problems/permutations "全排列") -

    Given a collection of distinct integers, return all possible permutations.

    +

    Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.

    -

    Example:

    - -
    -Input: [1,2,3]
    -Output:
    -[
    -  [1,2,3],
    -  [1,3,2],
    -  [2,1,3],
    -  [2,3,1],
    -  [3,1,2],
    -  [3,2,1]
    -]
    +

     

    +

    Example 1:

    +
    Input: nums = [1,2,3]
    +Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
    +

    Example 2:

    +
    Input: nums = [0,1]
    +Output: [[0,1],[1,0]]
    +

    Example 3:

    +
    Input: nums = [1]
    +Output: [[1]]
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 6
    • +
    • -10 <= nums[i] <= 10
    • +
    • All the integers of nums are unique.
    • +
    ### Related Topics [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/power-of-four/README.md b/problems/power-of-four/README.md index 5b577262f..360567d24 100644 --- a/problems/power-of-four/README.md +++ b/problems/power-of-four/README.md @@ -11,24 +11,30 @@ ## [342. Power of Four (Easy)](https://leetcode.com/problems/power-of-four "4的幂") -

    Given an integer (signed 32 bits), write a function to check whether it is a power of 4.

    +

    Given an integer n, return true if it is a power of four. Otherwise, return false.

    -

    Example 1:

    +

    An integer n is a power of four, if there exists an integer x such that n == 4x.

    -
    -Input: 16
    -Output: true
    +

     

    +

    Example 1:

    +
    Input: n = 16
    +Output: true
    +

    Example 2:

    +
    Input: n = 5
    +Output: false
    +

    Example 3:

    +
    Input: n = 1
    +Output: true
     
    +

     

    +

    Constraints:

    -
    -

    Example 2:

    - -
    -Input: 5
    -Output: false
    -
    +
      +
    • -231 <= n <= 231 - 1
    • +
    -

    Follow up: Could you solve it without loops/recursion?

    +

     

    +Follow up: Could you solve it without loops/recursion? ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/power-of-three/README.md b/problems/power-of-three/README.md index b12b8f411..c59c0a6f4 100644 --- a/problems/power-of-three/README.md +++ b/problems/power-of-three/README.md @@ -13,7 +13,7 @@

    Given an integer n, return true if it is a power of three. Otherwise, return false.

    -

    An integer n is a power of three, if there exists an integer x such that n == x3.

    +

    An integer n is a power of three, if there exists an integer x such that n == 3x.

     

    Example 1:

    diff --git a/problems/power-of-two/README.md b/problems/power-of-two/README.md index fabf9b1a2..e86dfa527 100644 --- a/problems/power-of-two/README.md +++ b/problems/power-of-two/README.md @@ -11,7 +11,9 @@ ## [231. Power of Two (Easy)](https://leetcode.com/problems/power-of-two "2的幂") -

    Given an integer n, write a function to determine if it is a power of two.

    +

    Given an integer n, return true if it is a power of two. Otherwise, return false.

    + +

    An integer n is a power of two, if there exists an integer x such that n == 2x.

     

    Example 1:

    diff --git a/problems/range-sum-of-bst/README.md b/problems/range-sum-of-bst/README.md index 9eaee31e2..be003f447 100644 --- a/problems/range-sum-of-bst/README.md +++ b/problems/range-sum-of-bst/README.md @@ -40,4 +40,5 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Recursion](../../tag/recursion/README.md)] diff --git a/problems/rotate-list/README.md b/problems/rotate-list/README.md index 9a099e4bc..3c11dc9dc 100644 --- a/problems/rotate-list/README.md +++ b/problems/rotate-list/README.md @@ -11,28 +11,31 @@ ## [61. Rotate List (Medium)](https://leetcode.com/problems/rotate-list "旋转链表") -

    Given a linked list, rotate the list to the right by k places, where k is non-negative.

    +

    Given the head of a linked list, rotate the list to the right by k places.

    +

     

    Example 1:

    - +
    -Input: 1->2->3->4->5->NULL, k = 2
    -Output: 4->5->1->2->3->NULL
    -Explanation:
    -rotate 1 steps to the right: 5->1->2->3->4->NULL
    -rotate 2 steps to the right: 4->5->1->2->3->NULL
    +Input: head = [1,2,3,4,5], k = 2
    +Output: [4,5,1,2,3]
     

    Example 2:

    - +
    -Input: 0->1->2->NULL, k = 4
    -Output: 2->0->1->NULL
    -Explanation:
    -rotate 1 steps to the right: 2->0->1->NULL
    -rotate 2 steps to the right: 1->2->0->NULL
    -rotate 3 steps to the right: 0->1->2->NULL
    -rotate 4 steps to the right: 2->0->1->NULL
    +Input: head = [0,1,2], k = 4 +Output: [2,0,1] +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is in the range [0, 500].
    • +
    • -100 <= Node.val <= 100
    • +
    • 0 <= k <= 2 * 109
    • +
    ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/similar-string-groups/README.md b/problems/similar-string-groups/README.md index 1f01cae1a..b7f247746 100644 --- a/problems/similar-string-groups/README.md +++ b/problems/similar-string-groups/README.md @@ -17,23 +17,32 @@

    Together, these form two connected groups by similarity: {"tars", "rats", "arts"} and {"star"}.  Notice that "tars" and "arts" are in the same group even though they are not similar.  Formally, each group is such that a word is in the group if and only if it is similar to at least one other word in the group.

    -

    We are given a list A of strings.  Every string in A is an anagram of every other string in A.  How many groups are there?

    +

    We are given a list strs of strings where every string in strs is an anagram of every other string in strs. How many groups are there?

     

    Example 1:

    -
    Input: A = ["tars","rats","arts","star"]
    +
    +
    +Input: strs = ["tars","rats","arts","star"]
     Output: 2
     
    + +

    Example 2:

    + +
    +Input: strs = ["omv","ovm"]
    +Output: 1
    +
    +

     

    Constraints:

      -
    • 1 <= A.length <= 2000
    • -
    • 1 <= A[i].length <= 1000
    • -
    • A.length * A[i].length <= 20000
    • -
    • All words in A consist of lowercase letters only.
    • -
    • All words in A have the same length and are anagrams of each other.
    • -
    • The judging time limit has been increased for this question.
    • +
    • 1 <= strs.length <= 100
    • +
    • 1 <= strs[i].length <= 1000
    • +
    • sum(strs[i].length) <= 2 * 104
    • +
    • strs[i] consists of lowercase letters only.
    • +
    • All words in strs have the same length and are anagrams of each other.
    ### Related Topics diff --git a/problems/spiral-matrix-ii/README.md b/problems/spiral-matrix-ii/README.md index bddfb831a..8713bb82e 100644 --- a/problems/spiral-matrix-ii/README.md +++ b/problems/spiral-matrix-ii/README.md @@ -11,20 +11,30 @@ ## [59. Spiral Matrix II (Medium)](https://leetcode.com/problems/spiral-matrix-ii "螺旋矩阵 II") -

    Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.

    +

    Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order.

    -

    Example:

    +

     

    +

    Example 1:

    + +
    +Input: n = 3
    +Output: [[1,2,3],[8,9,4],[7,6,5]]
    +
    + +

    Example 2:

    -Input: 3
    -Output:
    -[
    - [ 1, 2, 3 ],
    - [ 8, 9, 4 ],
    - [ 7, 6, 5 ]
    -]
    +Input: n = 1
    +Output: [[1]]
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 20
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/spiral-matrix/README.md b/problems/spiral-matrix/README.md index 4755b96ab..1deb730ef 100644 --- a/problems/spiral-matrix/README.md +++ b/problems/spiral-matrix/README.md @@ -11,32 +11,33 @@ ## [54. Spiral Matrix (Medium)](https://leetcode.com/problems/spiral-matrix "螺旋矩阵") -

    Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.

    +

    Given an m x n matrix, return all elements of the matrix in spiral order.

    +

     

    Example 1:

    - +
    -Input:
    -[
    - [ 1, 2, 3 ],
    - [ 4, 5, 6 ],
    - [ 7, 8, 9 ]
    -]
    +Input: matrix = [[1,2,3],[4,5,6],[7,8,9]]
     Output: [1,2,3,6,9,8,7,4,5]
     

    Example 2:

    - +
    -Input:
    -[
    -  [1, 2, 3, 4],
    -  [5, 6, 7, 8],
    -  [9,10,11,12]
    -]
    +Input: matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
     Output: [1,2,3,4,8,12,11,10,9,5,6,7]
     
    +

     

    +

    Constraints:

    + +
      +
    • m == matrix.length
    • +
    • n == matrix[i].length
    • +
    • 1 <= m, n <= 10
    • +
    • -100 <= matrix[i][j] <= 100
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/sqrtx/README.md b/problems/sqrtx/README.md index 1462371e4..2920d7969 100644 --- a/problems/sqrtx/README.md +++ b/problems/sqrtx/README.md @@ -11,27 +11,31 @@ ## [69. Sqrt(x) (Easy)](https://leetcode.com/problems/sqrtx "x 的平方根") -

    Implement int sqrt(int x).

    +

    Given a non-negative integer x, compute and return the square root of x.

    -

    Compute and return the square root of x, where x is guaranteed to be a non-negative integer.

    - -

    Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned.

    +

    Since the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned.

    +

     

    Example 1:

    -Input: 4
    +Input: x = 4
     Output: 2
     

    Example 2:

    -Input: 8
    +Input: x = 8
     Output: 2
    -Explanation: The square root of 8 is 2.82842..., and since 
    -             the decimal part is truncated, 2 is returned.
    -
    +Explanation: The square root of 8 is 2.82842..., and since the decimal part is truncated, 2 is returned.
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= x <= 231 - 1
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/stone-game-ii/README.md b/problems/stone-game-ii/README.md index f609cb77c..bf299632e 100644 --- a/problems/stone-game-ii/README.md +++ b/problems/stone-game-ii/README.md @@ -11,15 +11,15 @@ ## [1140. Stone Game II (Medium)](https://leetcode.com/problems/stone-game-ii "石子游戏 II") -

    Alex and Lee continue their games with piles of stones.  There are a number of piles arranged in a row, and each pile has a positive integer number of stones piles[i].  The objective of the game is to end with the most stones. 

    +

    Alice and Bob continue their games with piles of stones.  There are a number of piles arranged in a row, and each pile has a positive integer number of stones piles[i].  The objective of the game is to end with the most stones. 

    -

    Alex and Lee take turns, with Alex starting first.  Initially, M = 1.

    +

    Alice and Bob take turns, with Alice starting first.  Initially, M = 1.

    On each player's turn, that player can take all the stones in the first X remaining piles, where 1 <= X <= 2M.  Then, we set M = max(M, X).

    The game continues until all the stones have been taken.

    -

    Assuming Alex and Lee play optimally, return the maximum number of stones Alex can get.

    +

    Assuming Alice and Bob play optimally, return the maximum number of stones Alice can get.

     

    Example 1:

    @@ -27,7 +27,14 @@
     Input: piles = [2,7,9,4,4]
     Output: 10
    -Explanation:  If Alex takes one pile at the beginning, Lee takes two piles, then Alex takes 2 piles again. Alex can get 2 + 4 + 4 = 10 piles in total. If Alex takes two piles at the beginning, then Lee can take all three piles left. In this case, Alex get 2 + 7 = 9 piles in total. So we return 10 since it's larger. 
    +Explanation:  If Alice takes one pile at the beginning, Bob takes two piles, then Alice takes 2 piles again. Alice can get 2 + 4 + 4 = 10 piles in total. If Alice takes two piles at the beginning, then Bob can take all three piles left. In this case, Alice get 2 + 7 = 9 piles in total. So we return 10 since it's larger. 
    +
    + +

    Example 2:

    + +
    +Input: piles = [1,2,3,4,5,100]
    +Output: 104
     

     

    @@ -35,7 +42,7 @@
    • 1 <= piles.length <= 100
    • -
    • 1 <= piles[i] <= 10 ^ 4
    • +
    • 1 <= piles[i] <= 104
    ### Related Topics diff --git a/problems/string-to-integer-atoi/README.md b/problems/string-to-integer-atoi/README.md index b0a5c214b..7324a1e60 100644 --- a/problems/string-to-integer-atoi/README.md +++ b/problems/string-to-integer-atoi/README.md @@ -25,7 +25,7 @@
    • Only the space character ' ' is considered a whitespace character.
    • -
    • Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. If the numerical value is out of the range of representable values, INT_MAX (231 − 1) or INT_MIN (−231) is returned.
    • +
    • Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. If the numerical value is out of the range of representable values, 231 − 1 or −231 is returned.

     

    diff --git a/problems/strong-password-checker/README.md b/problems/strong-password-checker/README.md index ec53406d3..0a85c673f 100644 --- a/problems/strong-password-checker/README.md +++ b/problems/strong-password-checker/README.md @@ -11,14 +11,39 @@ ## [420. Strong Password Checker (Hard)](https://leetcode.com/problems/strong-password-checker "强密码检验器") -

    A password is considered strong if below conditions are all met:

    +

    A password is considered strong if the below conditions are all met:

    -
      -
    1. It has at least 6 characters and at most 20 characters.
    2. -
    3. It must contain at least one lowercase letter, at least one uppercase letter, and at least one digit.
    4. -
    5. It must NOT contain three repeating characters in a row ("...aaa..." is weak, but "...aa...a..." is strong, assuming other conditions are met).
    6. -
    +
      +
    • It has at least 6 characters and at most 20 characters.
    • +
    • It contains at least one lowercase letter, at least one uppercase letter, and at least one digit.
    • +
    • It does not contain three repeating characters in a row (i.e., "...aaa..." is weak, but "...aa...a..." is strong, assuming other conditions are met).
    • +
    -

    Write a function strongPasswordChecker(s), that takes a string s as input, and return the MINIMUM change required to make s a strong password. If s is already strong, return 0.

    +

    Given a string password, return the minimum number of steps required to make password strong. if password is already strong, return 0.

    -

    Insertion, deletion or replace of any one character are all considered as one change.

    +

    In one step, you can:

    + +
      +
    • Insert one character to password,
    • +
    • Delete one character from password, or
    • +
    • Replace one character of password with another character.
    • +
    + +

     

    +

    Example 1:

    +
    Input: password = "a"
    +Output: 5
    +

    Example 2:

    +
    Input: password = "aA1"
    +Output: 3
    +

    Example 3:

    +
    Input: password = "1337C0d3"
    +Output: 0
    +
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= password.length <= 50
    • +
    • password consists of letters, digits, dot '.' or exclamation mark '!'.
    • +
    diff --git a/problems/subsets/README.md b/problems/subsets/README.md index 7e07dc0be..035aea1d9 100644 --- a/problems/subsets/README.md +++ b/problems/subsets/README.md @@ -11,25 +11,32 @@ ## [78. Subsets (Medium)](https://leetcode.com/problems/subsets "子集") -

    Given a set of distinct integers, nums, return all possible subsets (the power set).

    +

    Given an integer array nums, return all possible subsets (the power set).

    -

    Note: The solution set must not contain duplicate subsets.

    +

    The solution set must not contain duplicate subsets.

    -

    Example:

    +

     

    +

    Example 1:

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

    Example 2:

    + +
    +Input: nums = [0]
    +Output: [[],[0]]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 10
    • +
    • -10 <= nums[i] <= 10
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/sum-of-subarray-minimums/README.md b/problems/sum-of-subarray-minimums/README.md index 0809c6df5..349f90aa5 100644 --- a/problems/sum-of-subarray-minimums/README.md +++ b/problems/sum-of-subarray-minimums/README.md @@ -38,6 +38,33 @@ Minimums are 3, 1, 2, 4, 1, 1, 2, 1, 1, 1.  Sum is 17.

     

    +

     

    +

    Example 1:

    + +
    +Input: arr = [3,1,2,4]
    +Output: 17
    +Explanation: 
    +Subarrays are [3], [1], [2], [4], [3,1], [1,2], [2,4], [3,1,2], [1,2,4], [3,1,2,4]. 
    +Minimums are 3, 1, 2, 4, 1, 1, 2, 1, 1, 1.
    +Sum is 17.
    +
    + +

    Example 2:

    + +
    +Input: arr = [11,81,94,43,3]
    +Output: 444
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 3 * 104
    • +
    • 1 <= arr[i] <= 3 * 104
    • +
    + ### Related Topics [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] diff --git a/problems/text-justification/README.md b/problems/text-justification/README.md index d86a652d8..e0aa410b7 100644 --- a/problems/text-justification/README.md +++ b/problems/text-justification/README.md @@ -27,44 +27,35 @@
  • The input array words contains at least one word.
  • +

     

    Example 1:

    -Input:
    -words = ["This", "is", "an", "example", "of", "text", "justification."]
    -maxWidth = 16
    +Input: words = ["This", "is", "an", "example", "of", "text", "justification."], maxWidth = 16
     Output:
     [
        "This    is    an",
        "example  of text",
        "justification.  "
    -]
    -
    +]

    Example 2:

    -Input:
    -words = ["What","must","be","acknowledgment","shall","be"]
    -maxWidth = 16
    +Input: words = ["What","must","be","acknowledgment","shall","be"], maxWidth = 16
     Output:
     [
       "What   must   be",
       "acknowledgment  ",
       "shall be        "
     ]
    -Explanation: Note that the last line is "shall be    " instead of "shall     be",
    -             because the last line must be left-justified instead of fully-justified.
    -             Note that the second line is also left-justified becase it contains only one word.
    -
    +Explanation: Note that the last line is "shall be " instead of "shall be", because the last line must be left-justified instead of fully-justified. +Note that the second line is also left-justified becase it contains only one word.

    Example 3:

    -Input:
    -words = ["Science","is","what","we","understand","well","enough","to","explain",
    -         "to","a","computer.","Art","is","everything","else","we","do"]
    -maxWidth = 20
    +Input: words = ["Science","is","what","we","understand","well","enough","to","explain","to","a","computer.","Art","is","everything","else","we","do"], maxWidth = 20
     Output:
     [
       "Science  is  what we",
    @@ -73,8 +64,18 @@ maxWidth = 20
       "a  computer.  Art is",
       "everything  else  we",
       "do                  "
    -]
    -
    +]
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 300
    • +
    • 1 <= words[i].length <= 20
    • +
    • words[i] consists of only English letters and symbols.
    • +
    • 1 <= maxWidth <= 100
    • +
    • words[i].length <= maxWidth
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/valid-number/README.md b/problems/valid-number/README.md index ddee7b6ab..371b589a2 100644 --- a/problems/valid-number/README.md +++ b/problems/valid-number/README.md @@ -29,7 +29,7 @@ "-+3" => false
    "95a54e53" => false

    -

    Note: It is intended for the problem statement to be ambiguous. You should gather all requirements up front before implementing one. However, here is a list of characters that can be in a valid decimal number:

    +

    Note: It is intended for the problem statement to be ambiguous. It would be best if you gathered all requirements up front before implementing one. However, here is a list of characters that can be in a valid decimal number:

    • Numbers 0-9
    • @@ -40,8 +40,21 @@

      Of course, the context of these characters also matters in the input.

      -

      Update (2015-02-10):
      -The signature of the C++ function had been updated. If you still see your function signature accepts a const char * argument, please click the reload button to reset your code definition.

      +

       

      +

      Example 1:

      +
      Input: s = "0"
      +Output: true
      +

      Example 2:

      +
      Input: s = "3"
      +Output: true
      +
      +

       

      +

      Constraints:

      + +
        +
      • 1 <= s.length <= 20
      • +
      • s consists of only English letters, digits, space ' ', plus '+', minus '-', or dot '.'.
      • +
      ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/valid-square/README.md b/problems/valid-square/README.md index f10ffd466..175432ba5 100644 --- a/problems/valid-square/README.md +++ b/problems/valid-square/README.md @@ -11,28 +11,41 @@ ## [593. Valid Square (Medium)](https://leetcode.com/problems/valid-square "有效的正方形") -

      Given the coordinates of four points in 2D space, return whether the four points could construct a square.

      +

      Given the coordinates of four points in 2D space p1, p2, p3 and p4, return true if the four points construct a square.

      -

      The coordinate (x,y) of a point is represented by an integer array with two integers.

      +

      The coordinate of a point pi is represented as [xi, yi]. The input is not given in any order.

      -

      Example:

      +

      A valid square has four equal sides with positive length and four equal angles (90-degree angles).

      + +

       

      +

      Example 1:

      -Input: p1 = [0,0], p2 = [1,1], p3 = [1,0], p4 = [0,1]
      -Output: True
      +Input: p1 = [0,0], p2 = [1,1], p3 = [1,0], p4 = [0,1]
      +Output: true
       
      -

       

      +

      Example 2:

      -

      Note:

      +
      +Input: p1 = [0,0], p2 = [1,1], p3 = [1,0], p4 = [0,12]
      +Output: false
      +
      -
        -
      1. All the input integers are in the range [-10000, 10000].
      2. -
      3. A valid square has four equal sides with positive length and four equal angles (90-degree angles).
      4. -
      5. Input points have no order.
      6. -
      +

      Example 3:

      + +
      +Input: p1 = [1,0], p2 = [-1,0], p3 = [0,1], p4 = [0,-1]
      +Output: true
      +

       

      +

      Constraints:

      + +
        +
      • p1.length == p2.length == p3.length == p4.length == 2
      • +
      • -104 <= xi, yi <= 104
      • +
      ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/word-search/README.md b/problems/word-search/README.md index d1849fa00..b3ad25f25 100644 --- a/problems/word-search/README.md +++ b/problems/word-search/README.md @@ -11,7 +11,7 @@ ## [79. Word Search (Medium)](https://leetcode.com/problems/word-search "单词搜索") -

      Given a 2D board and a word, find if the word exists in the grid.

      +

      Given an m x n board and a word, find if the word exists in the grid.

      The word can be constructed from letters of sequentially adjacent cells, where "adjacent" cells are horizontally or vertically neighboring. The same letter cell may not be used more than once.

      @@ -41,10 +41,11 @@

      Constraints:

        +
      • m == board.length
      • +
      • n = board[i].length
      • +
      • 1 <= m, n <= 200
      • +
      • 1 <= word.length <= 103
      • board and word consists only of lowercase and uppercase English letters.
      • -
      • 1 <= board.length <= 200
      • -
      • 1 <= board[i].length <= 200
      • -
      • 1 <= word.length <= 10^3
      ### Related Topics diff --git a/tag/README.md b/tag/README.md index 7e961aaad..bba637222 100644 --- a/tag/README.md +++ b/tag/README.md @@ -15,7 +15,7 @@ | 7 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | | 8 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 9 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | | 11 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | -| 13 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | | 14 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | +| 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | | 15 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | | 19 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 20 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | diff --git a/tag/array/README.md b/tag/array/README.md index d48298774..ae20176b6 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Easy | +| 1652 | [拆炸弹](../../problems/defuse-the-bomb) | [[数组](../array/README.md)] | Easy | | 1646 | [获取生成数组中的最大值](../../problems/get-maximum-in-generated-array) | [[数组](../array/README.md)] | Easy | | 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | | 1636 | [按照频率将数组升序排序](../../problems/sort-array-by-increasing-frequency) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 2b62f1a03..21bdb8a56 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[回溯算法](../backtracking/README.md)] | Hard | | 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index f5eb15424..72be60eda 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1642 | [可以到达的最远建筑](../../problems/furthest-building-you-can-reach) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 1674caf60..efe046218 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1654 | [到家的最少跳跃次数](../../problems/minimum-jumps-to-reach-home) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1625 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index dc9a4e60a..490f19ce0 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -55,6 +55,7 @@ | 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 947 | [移除最多的同行或同列石头](../../problems/most-stones-removed-with-same-row-or-column) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 924 | [尽量减少恶意软件的传播](../../problems/minimize-malware-spread) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | diff --git a/tag/design/README.md b/tag/design/README.md index 663b050ba..a72370d84 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Easy | | 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard | | 1603 | [设计停车系统](../../problems/design-parking-system) | [[设计](../design/README.md)] | Easy | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 2c2a180dd..a7a8bc734 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1654 | [到家的最少跳跃次数](../../problems/minimum-jumps-to-reach-home) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1643 | [第 K 条最小指令](../../problems/kth-smallest-instructions) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1639 | [通过给定词典构造目标字符串的方案数](../../problems/number-of-ways-to-form-a-target-string-given-a-dictionary) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 589e0963d..377fceca8 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1657 | [确定两个字符串是否接近](../../problems/determine-if-two-strings-are-close) | [[贪心算法](../greedy/README.md)] | Medium | +| 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | | 1647 | [字符频次唯一的最小删除次数](../../problems/minimum-deletions-to-make-character-frequencies-unique) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | | 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] | Hard | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index 9b2fa3241..5ff4c0c59 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1634 | [Add Two Polynomials Represented as Linked Lists](../../problems/add-two-polynomials-represented-as-linked-lists) 🔒 | [[链表](../linked-list/README.md)] | Medium | +| 1634 | [求两个多项式链表的和](../../problems/add-two-polynomials-represented-as-linked-lists) 🔒 | [[链表](../linked-list/README.md)] | Medium | | 1474 | [删除链表 M 个节点之后的 N 个节点](../../problems/delete-n-nodes-after-m-nodes-of-a-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Easy | | 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)] | Easy | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index ce0aa14f8..d6e9ab81b 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -10,7 +10,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[递归](../recursion/README.md)] | Easy | -| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | +| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | diff --git a/tag/string/README.md b/tag/string/README.md index de06ccfac..eb4156a35 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1624 | [两个相同字符之间的最长子字符串](../../problems/largest-substring-between-two-equal-characters) | [[字符串](../string/README.md)] | Easy | | 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/tags.json b/tag/tags.json index bf366605e..8652fdf51 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -59,16 +59,16 @@ "Slug": "two-pointers", "TranslatedName": "双指针" }, - { - "Name": "Stack", - "Slug": "stack", - "TranslatedName": "栈" - }, { "Name": "Backtracking", "Slug": "backtracking", "TranslatedName": "回溯算法" }, + { + "Name": "Stack", + "Slug": "stack", + "TranslatedName": "栈" + }, { "Name": "Design", "Slug": "design", diff --git a/tag/tree/README.md b/tag/tree/README.md index adf26f14e..230b0b3af 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,7 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1644 | [Lowest Common Ancestor of a Binary Tree II](../../problems/lowest-common-ancestor-of-a-binary-tree-ii) 🔒 | [[树](../tree/README.md)] | Medium | +| 1650 | [Lowest Common Ancestor of a Binary Tree III](../../problems/lowest-common-ancestor-of-a-binary-tree-iii) 🔒 | [[树](../tree/README.md)] | Medium | +| 1644 | [二叉树的最近公共祖先 II](../../problems/lowest-common-ancestor-of-a-binary-tree-ii) 🔒 | [[树](../tree/README.md)] | Medium | | 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1609 | [奇偶树](../../problems/even-odd-tree) | [[树](../tree/README.md)] | Medium | @@ -59,7 +60,7 @@ | 965 | [单值二叉树](../../problems/univalued-binary-tree) | [[树](../tree/README.md)] | Easy | | 958 | [二叉树的完全性检验](../../problems/check-completeness-of-a-binary-tree) | [[树](../tree/README.md)] | Medium | | 951 | [翻转等价二叉树](../../problems/flip-equivalent-binary-trees) | [[树](../tree/README.md)] | Medium | -| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | +| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 919 | [完全二叉树插入器](../../problems/complete-binary-tree-inserter) | [[树](../tree/README.md)] | Medium | | 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 8f027246d..e21f00156 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard | | 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | From 1e14d9e95f8e6c9e7b8f611dd786d88b788105a5 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 7 Dec 2020 15:55:21 +0800 Subject: [PATCH 110/145] A: new --- README.md | 28 ++++- .../README.md | 14 +++ .../mysql_schemas.sql | 14 +++ problems/bag-of-tokens/README.md | 2 + problems/basic-calculator-ii/README.md | 38 +++--- .../binary-search-tree-iterator/README.md | 56 +++++---- problems/bitwise-ors-of-subarrays/README.md | 45 +++----- problems/bricks-falling-when-hit/README.md | 37 ++++-- problems/can-place-flowers/README.md | 39 +++---- problems/cat-and-mouse/README.md | 53 +++++---- .../README.md | 29 +++++ .../README.md | 42 +++---- .../README.md | 65 +++++++++++ .../README.md | 58 ++++++++++ problems/correct-a-binary-tree/README.md | 23 ++++ .../cut-off-trees-for-golf-event/README.md | 74 +++++------- problems/decode-string/README.md | 9 ++ .../delete-duplicate-emails/mysql_schemas.sql | 4 + .../README.md | 4 +- problems/design-an-ordered-stream/README.md | 19 ++- .../design-front-middle-back-queue/README.md | 79 +++++++++++++ problems/distant-barcodes/README.md | 34 ++---- problems/distribute-candies/README.md | 42 ++----- problems/find-k-closest-elements/README.md | 13 ++- problems/find-peak-element/README.md | 29 +++-- .../README.md | 53 +++++++++ problems/fix-names-in-a-table/README.md | 14 +++ .../fix-names-in-a-table/mysql_schemas.sql | 4 + .../README.md | 4 +- .../mysql_schemas.sql | 28 ++--- .../frog-position-after-t-seconds/README.md | 12 +- problems/goal-parser-interpretation/README.md | 60 ++++++++++ .../increasing-order-search-tree/README.md | 47 +++----- problems/is-graph-bipartite/README.md | 2 +- problems/iterator-for-combination/README.md | 36 +++--- problems/jump-game-iii/README.md | 3 +- .../README.md | 2 + problems/long-pressed-name/README.md | 6 +- .../longest-duplicate-substring/README.md | 33 ++---- .../longest-increasing-subsequence/README.md | 43 +++++-- problems/longest-mountain-in-array/README.md | 42 ++++--- problems/longest-string-chain/README.md | 25 ++-- .../README.md | 43 ++++--- .../README.md | 2 +- .../README.md | 34 ++++++ problems/lru-cache/README.md | 2 +- problems/max-number-of-k-sum-pairs/README.md | 66 +++++++++++ problems/maximal-square/README.md | 39 +++++-- problems/maximize-grid-happiness/README.md | 2 +- .../maximum-depth-of-binary-tree/README.md | 45 ++++++-- .../maximum-depth-of-n-ary-tree/README.md | 4 +- .../maximum-repeating-substring/README.md | 64 +++++++++++ .../README.md | 4 +- .../merge-in-between-linked-lists/README.md | 65 +++++++++++ .../minimize-deviation-in-array/README.md | 86 ++++++++++++++ problems/minimum-incompatibility/README.md | 71 ++++++++++++ .../README.md | 88 ++++++++++++++ .../README.md | 77 +++++++++++++ .../README.md | 80 +++++++++++++ .../README.md | 8 +- .../README.md | 4 +- problems/next-greater-element-iii/README.md | 25 ++-- .../README.md | 10 +- .../README.md | 5 +- .../README.md | 26 ++--- problems/pascals-triangle-ii/README.md | 2 +- problems/poor-pigs/README.md | 39 ++++--- .../products-worth-over-invoices/README.md | 14 +++ .../mysql_schemas.sql | 12 ++ .../put-boxes-into-the-warehouse-ii/README.md | 2 +- .../queue-reconstruction-by-height/README.md | 37 ++++-- problems/relative-sort-array/README.md | 4 +- problems/richest-customer-wealth/README.md | 70 ++++++++++++ problems/search-a-2d-matrix-ii/README.md | 36 +++--- .../README.md | 46 ++++---- .../README.md | 3 + problems/single-number-ii/README.md | 27 +++-- .../README.md | 58 ++++++++++ problems/squares-of-a-sorted-array/README.md | 30 +++-- .../mysql_schemas.sql | 2 +- .../the-k-weakest-rows-in-a-matrix/README.md | 2 +- problems/the-skyline-problem/README.md | 46 ++++++-- problems/two-city-scheduling/README.md | 2 +- problems/two-sum/README.md | 2 +- .../validate-binary-search-tree/README.md | 32 +++--- problems/ways-to-make-a-fair-array/README.md | 79 +++++++++++++ readme/1-300.md | 2 +- readme/301-600.md | 4 +- readme/901-1200.md | 2 +- tag/README.md | 11 +- tag/array/README.md | 7 +- tag/backtracking/README.md | 3 +- tag/binary-search/README.md | 3 +- tag/breadth-first-search/README.md | 76 ------------ tag/depth-first-search/README.md | 12 +- tag/dequeue/README.md | 11 ++ tag/design/README.md | 5 +- tag/divide-and-conquer/README.md | 1 + tag/dynamic-programming/README.md | 3 + tag/graph/README.md | 1 - tag/greedy/README.md | 108 ------------------ tag/hash-table/README.md | 1 + tag/heap/README.md | 1 + tag/line-sweep/README.md | 6 - tag/linked-list/README.md | 2 + tag/math/README.md | 1 + tag/oop/README.md | 11 ++ tag/ordered-map/README.md | 13 --- tag/recursion/README.md | 6 + tag/rejection-sampling/README.md | 2 - tag/reservoir-sampling/README.md | 2 - tag/sliding-window/README.md | 1 + tag/sort/README.md | 1 + tag/stack/README.md | 2 + tag/string/README.md | 7 +- tag/tags.json | 36 +++--- tag/tree/README.md | 17 +-- tag/two-pointers/README.md | 1 + 118 files changed, 2146 insertions(+), 872 deletions(-) create mode 100644 problems/average-time-of-process-per-machine/README.md create mode 100644 problems/average-time-of-process-per-machine/mysql_schemas.sql create mode 100644 problems/change-the-root-of-a-binary-tree/README.md create mode 100644 problems/check-if-two-string-arrays-are-equivalent/README.md create mode 100644 problems/concatenation-of-consecutive-binary-numbers/README.md create mode 100644 problems/correct-a-binary-tree/README.md create mode 100644 problems/delete-duplicate-emails/mysql_schemas.sql create mode 100644 problems/design-front-middle-back-queue/README.md create mode 100644 problems/find-the-most-competitive-subsequence/README.md create mode 100644 problems/fix-names-in-a-table/README.md create mode 100644 problems/fix-names-in-a-table/mysql_schemas.sql create mode 100644 problems/goal-parser-interpretation/README.md create mode 100644 problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md create mode 100644 problems/max-number-of-k-sum-pairs/README.md create mode 100644 problems/maximum-repeating-substring/README.md create mode 100644 problems/merge-in-between-linked-lists/README.md create mode 100644 problems/minimize-deviation-in-array/README.md create mode 100644 problems/minimum-incompatibility/README.md create mode 100644 problems/minimum-initial-energy-to-finish-tasks/README.md create mode 100644 problems/minimum-moves-to-make-array-complementary/README.md create mode 100644 problems/minimum-number-of-removals-to-make-mountain-array/README.md create mode 100644 problems/products-worth-over-invoices/README.md create mode 100644 problems/products-worth-over-invoices/mysql_schemas.sql create mode 100644 problems/richest-customer-wealth/README.md create mode 100644 problems/smallest-string-with-a-given-numeric-value/README.md create mode 100644 problems/ways-to-make-a-fair-array/README.md create mode 100644 tag/dequeue/README.md create mode 100644 tag/oop/README.md diff --git a/README.md b/README.md index 1d37785b4..974a91e7d 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,28 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1681 | [Minimum Incompatibility](https://leetcode.com/problems/minimum-incompatibility "最小不兼容性") | [Go](problems/minimum-incompatibility) | Hard | +| 1680 | [Concatenation of Consecutive Binary Numbers](https://leetcode.com/problems/concatenation-of-consecutive-binary-numbers "连接连续二进制数字") | [Go](problems/concatenation-of-consecutive-binary-numbers) | Medium | +| 1679 | [Max Number of K-Sum Pairs](https://leetcode.com/problems/max-number-of-k-sum-pairs "K 和数对的最大数目") | [Go](problems/max-number-of-k-sum-pairs) | Medium | +| 1678 | [Goal Parser Interpretation](https://leetcode.com/problems/goal-parser-interpretation "设计 Goal 解析器") | [Go](problems/goal-parser-interpretation) | Easy | +| 1677 | [Product's Worth Over Invoices](https://leetcode.com/problems/products-worth-over-invoices) 🔒 | [MySQL](problems/products-worth-over-invoices) | Easy | +| 1676 | [Lowest Common Ancestor of a Binary Tree IV](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-iv) | Medium | +| 1675 | [Minimize Deviation in Array](https://leetcode.com/problems/minimize-deviation-in-array "数组的最小偏移量") | [Go](problems/minimize-deviation-in-array) | Hard | +| 1674 | [Minimum Moves to Make Array Complementary](https://leetcode.com/problems/minimum-moves-to-make-array-complementary "使数组互补的最少操作次数") | [Go](problems/minimum-moves-to-make-array-complementary) | Medium | +| 1673 | [Find the Most Competitive Subsequence](https://leetcode.com/problems/find-the-most-competitive-subsequence "找出最具竞争力的子序列") | [Go](problems/find-the-most-competitive-subsequence) | Medium | +| 1672 | [Richest Customer Wealth](https://leetcode.com/problems/richest-customer-wealth "最富有客户的资产总量") | [Go](problems/richest-customer-wealth) | Easy | +| 1671 | [Minimum Number of Removals to Make Mountain Array](https://leetcode.com/problems/minimum-number-of-removals-to-make-mountain-array "得到山形数组的最少删除次数") | [Go](problems/minimum-number-of-removals-to-make-mountain-array) | Hard | +| 1670 | [Design Front Middle Back Queue](https://leetcode.com/problems/design-front-middle-back-queue "设计前中后队列") | [Go](problems/design-front-middle-back-queue) | Medium | +| 1669 | [Merge In Between Linked Lists](https://leetcode.com/problems/merge-in-between-linked-lists "合并两个链表") | [Go](problems/merge-in-between-linked-lists) | Medium | +| 1668 | [Maximum Repeating Substring](https://leetcode.com/problems/maximum-repeating-substring "最大重复子字符串") | [Go](problems/maximum-repeating-substring) | Easy | +| 1667 | [Fix Names in a Table](https://leetcode.com/problems/fix-names-in-a-table) 🔒 | [MySQL](problems/fix-names-in-a-table) | Easy | +| 1666 | [Change the Root of a Binary Tree](https://leetcode.com/problems/change-the-root-of-a-binary-tree) 🔒 | [Go](problems/change-the-root-of-a-binary-tree) | Medium | +| 1665 | [Minimum Initial Energy to Finish Tasks](https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks "完成所有任务的最少初始能量") | [Go](problems/minimum-initial-energy-to-finish-tasks) | Hard | +| 1664 | [Ways to Make a Fair Array](https://leetcode.com/problems/ways-to-make-a-fair-array "生成平衡数组的方案数") | [Go](problems/ways-to-make-a-fair-array) | Medium | +| 1663 | [Smallest String With A Given Numeric Value](https://leetcode.com/problems/smallest-string-with-a-given-numeric-value "具有给定数值的最小字符串") | [Go](problems/smallest-string-with-a-given-numeric-value) | Medium | +| 1662 | [Check If Two String Arrays are Equivalent](https://leetcode.com/problems/check-if-two-string-arrays-are-equivalent "检查两个字符串数组是否相等") | [Go](problems/check-if-two-string-arrays-are-equivalent) | Easy | +| 1661 | [Average Time of Process per Machine](https://leetcode.com/problems/average-time-of-process-per-machine) 🔒 | [MySQL](problems/average-time-of-process-per-machine) | Easy | +| 1660 | [Correct a Binary Tree](https://leetcode.com/problems/correct-a-binary-tree "纠正二叉树") 🔒 | [Go](problems/correct-a-binary-tree) | Medium | | 1659 | [Maximize Grid Happiness](https://leetcode.com/problems/maximize-grid-happiness "最大化网格幸福感") | [Go](problems/maximize-grid-happiness) | Hard | | 1658 | [Minimum Operations to Reduce X to Zero](https://leetcode.com/problems/minimum-operations-to-reduce-x-to-zero "将 x 减到 0 的最小操作数") | [Go](problems/minimum-operations-to-reduce-x-to-zero) | Medium | | 1657 | [Determine if Two Strings Are Close](https://leetcode.com/problems/determine-if-two-strings-are-close "确定两个字符串是否接近") | [Go](problems/determine-if-two-strings-are-close) | Medium | @@ -79,7 +101,7 @@ LeetCode Problems' Solutions | 1653 | [Minimum Deletions to Make String Balanced](https://leetcode.com/problems/minimum-deletions-to-make-string-balanced "使字符串平衡的最少删除次数") | [Go](problems/minimum-deletions-to-make-string-balanced) | Medium | | 1652 | [Defuse the Bomb](https://leetcode.com/problems/defuse-the-bomb "拆炸弹") | [Go](problems/defuse-the-bomb) | Easy | | 1651 | [Hopper Company Queries III](https://leetcode.com/problems/hopper-company-queries-iii) 🔒 | [MySQL](problems/hopper-company-queries-iii) | Hard | -| 1650 | [Lowest Common Ancestor of a Binary Tree III](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iii) 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-iii) | Medium | +| 1650 | [Lowest Common Ancestor of a Binary Tree III](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iii "二叉树的最近公共祖先 III") 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-iii) | Medium | | 1649 | [Create Sorted Array through Instructions](https://leetcode.com/problems/create-sorted-array-through-instructions "通过指令创建有序数组") | [Go](problems/create-sorted-array-through-instructions) | Hard | | 1648 | [Sell Diminishing-Valued Colored Balls](https://leetcode.com/problems/sell-diminishing-valued-colored-balls "销售价值减少的颜色球") | [Go](problems/sell-diminishing-valued-colored-balls) | Medium | | 1647 | [Minimum Deletions to Make Character Frequencies Unique](https://leetcode.com/problems/minimum-deletions-to-make-character-frequencies-unique "字符频次唯一的最小删除次数") | [Go](problems/minimum-deletions-to-make-character-frequencies-unique) | Medium | @@ -149,7 +171,7 @@ LeetCode Problems' Solutions | 1583 | [Count Unhappy Friends](https://leetcode.com/problems/count-unhappy-friends "统计不开心的朋友") | [Go](problems/count-unhappy-friends) | Medium | | 1582 | [Special Positions in a Binary Matrix](https://leetcode.com/problems/special-positions-in-a-binary-matrix "二进制矩阵中的特殊位置") | [Go](problems/special-positions-in-a-binary-matrix) | Easy | | 1581 | [Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的顾客") 🔒 | [MySQL](problems/customer-who-visited-but-did-not-make-any-transactions) | Easy | -| 1580 | [Put Boxes Into the Warehouse II](https://leetcode.com/problems/put-boxes-into-the-warehouse-ii) 🔒 | [Go](problems/put-boxes-into-the-warehouse-ii) | Medium | +| 1580 | [Put Boxes Into the Warehouse II](https://leetcode.com/problems/put-boxes-into-the-warehouse-ii "把箱子放进仓库里 II") 🔒 | [Go](problems/put-boxes-into-the-warehouse-ii) | Medium | | 1579 | [Remove Max Number of Edges to Keep Graph Fully Traversable](https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable "保证图可完全遍历") | [Go](problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | Hard | | 1578 | [Minimum Deletion Cost to Avoid Repeating Letters](https://leetcode.com/problems/minimum-deletion-cost-to-avoid-repeating-letters "避免重复字母的最小删除成本") | [Go](problems/minimum-deletion-cost-to-avoid-repeating-letters) | Medium | | 1577 | [Number of Ways Where Square of Number Is Equal to Product of Two Numbers](https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "数的平方等于两数乘积的方法数") | [Go](problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | Medium | @@ -392,7 +414,7 @@ LeetCode Problems' Solutions | 1340 | [Jump Game V](https://leetcode.com/problems/jump-game-v "跳跃游戏 V") | [Go](problems/jump-game-v) | Hard | | 1339 | [Maximum Product of Splitted Binary Tree](https://leetcode.com/problems/maximum-product-of-splitted-binary-tree "分裂二叉树的最大乘积") | [Go](problems/maximum-product-of-splitted-binary-tree) | Medium | | 1338 | [Reduce Array Size to The Half](https://leetcode.com/problems/reduce-array-size-to-the-half "数组大小减半") | [Go](problems/reduce-array-size-to-the-half) | Medium | -| 1337 | [The K Weakest Rows in a Matrix](https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix "方阵中战斗力最弱的 K 行") | [Go](problems/the-k-weakest-rows-in-a-matrix) | Easy | +| 1337 | [The K Weakest Rows in a Matrix](https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix "矩阵中战斗力最弱的 K 行") | [Go](problems/the-k-weakest-rows-in-a-matrix) | Easy | | 1336 | [Number of Transactions per Visit](https://leetcode.com/problems/number-of-transactions-per-visit "每次访问的交易次数") 🔒 | [MySQL](problems/number-of-transactions-per-visit) | Hard | | 1335 | [Minimum Difficulty of a Job Schedule](https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule "工作计划的最低难度") | [Go](problems/minimum-difficulty-of-a-job-schedule) | Hard | | 1334 | [Find the City With the Smallest Number of Neighbors at a Threshold Distance](https://leetcode.com/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance "阈值距离内邻居最少的城市") | [Go](problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | Medium | diff --git a/problems/average-time-of-process-per-machine/README.md b/problems/average-time-of-process-per-machine/README.md new file mode 100644 index 000000000..bf492a5da --- /dev/null +++ b/problems/average-time-of-process-per-machine/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../correct-a-binary-tree "Correct a Binary Tree") +                 +[Next >](../check-if-two-string-arrays-are-equivalent "Check If Two String Arrays are Equivalent") + +## [1661. Average Time of Process per Machine (Easy)](https://leetcode.com/problems/average-time-of-process-per-machine "") + + diff --git a/problems/average-time-of-process-per-machine/mysql_schemas.sql b/problems/average-time-of-process-per-machine/mysql_schemas.sql new file mode 100644 index 000000000..7ae9bb48a --- /dev/null +++ b/problems/average-time-of-process-per-machine/mysql_schemas.sql @@ -0,0 +1,14 @@ +Create table If Not Exists Activity (machine_id int, process_id int, activity_type ENUM('start', 'end'), timestamp float); +Truncate table Activity; +insert into Activity (machine_id, process_id, activity_type, timestamp) values ('0', '0', 'start', '0.712'); +insert into Activity (machine_id, process_id, activity_type, timestamp) values ('0', '0', 'end', '1.52'); +insert into Activity (machine_id, process_id, activity_type, timestamp) values ('0', '1', 'start', '3.14'); +insert into Activity (machine_id, process_id, activity_type, timestamp) values ('0', '1', 'end', '4.12'); +insert into Activity (machine_id, process_id, activity_type, timestamp) values ('1', '0', 'start', '0.55'); +insert into Activity (machine_id, process_id, activity_type, timestamp) values ('1', '0', 'end', '1.55'); +insert into Activity (machine_id, process_id, activity_type, timestamp) values ('1', '1', 'start', '0.43'); +insert into Activity (machine_id, process_id, activity_type, timestamp) values ('1', '1', 'end', '1.42'); +insert into Activity (machine_id, process_id, activity_type, timestamp) values ('2', '0', 'start', '4.1'); +insert into Activity (machine_id, process_id, activity_type, timestamp) values ('2', '0', 'end', '4.512'); +insert into Activity (machine_id, process_id, activity_type, timestamp) values ('2', '1', 'start', '2.5'); +insert into Activity (machine_id, process_id, activity_type, timestamp) values ('2', '1', 'end', '5'); diff --git a/problems/bag-of-tokens/README.md b/problems/bag-of-tokens/README.md index 38a239cd5..beadcd680 100644 --- a/problems/bag-of-tokens/README.md +++ b/problems/bag-of-tokens/README.md @@ -64,3 +64,5 @@ There is no need to play the 1st token since you cannot play it face ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Sort](../../tag/sort/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/basic-calculator-ii/README.md b/problems/basic-calculator-ii/README.md index 76950166f..2528f927b 100644 --- a/problems/basic-calculator-ii/README.md +++ b/problems/basic-calculator-ii/README.md @@ -11,38 +11,34 @@ ## [227. Basic Calculator II (Medium)](https://leetcode.com/problems/basic-calculator-ii "基本计算器 II") -

      Implement a basic calculator to evaluate a simple expression string.

      +

      Given a string s which represents an expression, evaluate this expression and return its value

      -

      The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The integer division should truncate toward zero.

      +

      The integer division should truncate toward zero.

      +

       

      Example 1:

      - -
      -Input: "3+2*2"
      +
      Input: s = "3+2*2"
       Output: 7
      -
      - -

      Example 2:

      - -
      -Input: " 3/2 "
      -Output: 1
      - -

      Example 3:

      - -
      -Input: " 3+5 / 2 "
      +

      Example 2:

      +
      Input: s = " 3/2 "
      +Output: 1
      +

      Example 3:

      +
      Input: s = " 3+5 / 2 "
       Output: 5
       
      - -

      Note:

      +

       

      +

      Constraints:

        -
      • You may assume that the given expression is always valid.
      • -
      • Do not use the eval built-in library function.
      • +
      • 1 <= s.length <= 3 * 105
      • +
      • s consists of integers and operators ('+', '-', '*', '/') separated by some number of spaces.
      • +
      • s represents a valid expression.
      • +
      • All the integers in the expression are non-negative integers in the range [0, 231 - 1].
      • +
      • The answer is guaranteed to fit in a 32-bit integer.
      ### Related Topics + [[Stack](../../tag/stack/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/binary-search-tree-iterator/README.md b/problems/binary-search-tree-iterator/README.md index 78b95f3d7..8254542ad 100644 --- a/problems/binary-search-tree-iterator/README.md +++ b/problems/binary-search-tree-iterator/README.md @@ -11,39 +11,55 @@ ## [173. Binary Search Tree Iterator (Medium)](https://leetcode.com/problems/binary-search-tree-iterator "二叉搜索树迭代器") -

      Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.

      - -

      Calling next() will return the next smallest number in the BST.

      - -

       

      +

      Implement the BSTIterator class that represents an iterator over the in-order traversal of a binary search tree (BST):

        +
      • BSTIterator(TreeNode root) Initializes an object of the BSTIterator class. The root of the BST is given as part of the constructor. The pointer should be initialized to a non-existent number smaller than any element in the BST.
      • +
      • boolean hasNext() Returns true if there exists a number in the traversal to the right of the pointer, otherwise returns false.
      • +
      • int next() Moves the pointer to the right, then returns the number at the pointer.
      -

      Example:

      +

      Notice that by initializing the pointer to a non-existent smallest number, the first call to next() will return the smallest element in the BST.

      -

      +

      You may assume that next() calls will always be valid. That is, there will be at least a next number in the in-order traversal when next() is called.

      +

       

      +

      Example 1:

      +
      -BSTIterator iterator = new BSTIterator(root);
      -iterator.next();    // return 3
      -iterator.next();    // return 7
      -iterator.hasNext(); // return true
      -iterator.next();    // return 9
      -iterator.hasNext(); // return true
      -iterator.next();    // return 15
      -iterator.hasNext(); // return true
      -iterator.next();    // return 20
      -iterator.hasNext(); // return false
      +Input
      +["BSTIterator", "next", "next", "hasNext", "next", "hasNext", "next", "hasNext", "next", "hasNext"]
      +[[[7, 3, 15, null, null, 9, 20]], [], [], [], [], [], [], [], [], []]
      +Output
      +[null, 3, 7, true, 9, true, 15, true, 20, false]
      +
      +Explanation
      +BSTIterator bSTIterator = new BSTIterator([7, 3, 15, null, null, 9, 20]);
      +bSTIterator.next();    // return 3
      +bSTIterator.next();    // return 7
      +bSTIterator.hasNext(); // return True
      +bSTIterator.next();    // return 9
      +bSTIterator.hasNext(); // return True
      +bSTIterator.next();    // return 15
      +bSTIterator.hasNext(); // return True
      +bSTIterator.next();    // return 20
      +bSTIterator.hasNext(); // return False
       

       

      +

      Constraints:

      -

      Note:

      +
        +
      • The number of nodes in the tree is in the range [1, 105].
      • +
      • 0 <= Node.val <= 106
      • +
      • At most 105 calls will be made to hasNext, and next.
      • +
      + +

       

      +

      Follow up:

        -
      • next() and hasNext() should run in average O(1) time and uses O(h) memory, where h is the height of the tree.
      • -
      • You may assume that next() call will always be valid, that is, there will be at least a next smallest number in the BST when next() is called.
      • +
      • Could you implement next() and hasNext() to run in average O(1) time and use O(h) memory, where h is the height of the tree?
      ### Related Topics diff --git a/problems/bitwise-ors-of-subarrays/README.md b/problems/bitwise-ors-of-subarrays/README.md index 56b41a488..f9fadacdc 100644 --- a/problems/bitwise-ors-of-subarrays/README.md +++ b/problems/bitwise-ors-of-subarrays/README.md @@ -11,57 +11,46 @@ ## [898. Bitwise ORs of Subarrays (Medium)](https://leetcode.com/problems/bitwise-ors-of-subarrays "子数组按位或操作") -

      We have an array A of non-negative integers.

      +

      We have an array arr of non-negative integers.

      -

      For every (contiguous) subarray B = [A[i], A[i+1], ..., A[j]] (with i <= j), we take the bitwise OR of all the elements in B, obtaining a result A[i] | A[i+1] | ... | A[j].

      +

      For every (contiguous) subarray sub = [arr[i], arr[i + 1], ..., arr[j]] (with i <= j), we take the bitwise OR of all the elements in sub, obtaining a result arr[i] | arr[i + 1] | ... | arr[j].

      -

      Return the number of possible results.  (Results that occur more than once are only counted once in the final answer.)

      +

      Return the number of possible results. Results that occur more than once are only counted once in the final answer

       

      - -

      Example 1:

      -Input: [0]
      -Output: 1
      -Explanation: 
      -There is only one possible result: 0.
      +Input: arr = [0]
      +Output: 1
      +Explanation: There is only one possible result: 0.
       
      -

      Example 2:

      -Input: [1,1,2]
      -Output: 3
      -Explanation: 
      -The possible subarrays are [1], [1], [2], [1, 1], [1, 2], [1, 1, 2].
      +Input: arr = [1,1,2]
      +Output: 3
      +Explanation: The possible subarrays are [1], [1], [2], [1, 1], [1, 2], [1, 1, 2].
       These yield the results 1, 1, 2, 1, 3, 3.
       There are 3 unique values, so the answer is 3.
       
      -

      Example 3:

      -Input: [1,2,4]
      -Output: 6
      -Explanation: 
      -The possible results are 1, 2, 3, 4, 6, and 7.
      +Input: arr = [1,2,4]
      +Output: 6
      +Explanation: The possible results are 1, 2, 3, 4, 6, and 7.
       
      -
      -
      -

       

      +

      Constraints:

      -

      Note:

      - -
        -
      1. 1 <= A.length <= 50000
      2. -
      3. 0 <= A[i] <= 10^9
      4. -
      +
        +
      • 1 <= nums.length <= 5 * 104
      • +
      • 0 <= nums[i] <= 109
      • +
      ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/bricks-falling-when-hit/README.md b/problems/bricks-falling-when-hit/README.md index 6be8d38b1..49c4d99d3 100644 --- a/problems/bricks-falling-when-hit/README.md +++ b/problems/bricks-falling-when-hit/README.md @@ -11,18 +11,18 @@ ## [803. Bricks Falling When Hit (Hard)](https://leetcode.com/problems/bricks-falling-when-hit "打砖块") -

      You are given an m x n binary grid, where each 1 represents a brick. A brick will not drop if:

      +

      You are given an m x n binary grid, where each 1 represents a brick and 0 represents an empty space. A brick is stable if:

      • It is directly connected to the top of the grid, or
      • -
      • At least one of its four adjacent bricks will not drop.
      • +
      • At least one other brick in its four adjacent cells is stable.
      -

      You are also given an array hits. We will do some erasures sequentially. Each time we want to do the erasure at the location hits[i] = (xi, yi), the brick (if it exists) on that location will disappear, and then some other bricks may drop because of that erasure.

      +

      You are also given an array hits, which is a sequence of erasures we want to apply. Each time we want to erase the brick at the location hits[i] = (rowi, coli). The brick on that location (if it exists) will disappear. Some other bricks may no longer be stable because of that erasure and will fall. Once a brick falls, it is immediately erased from the grid (i.e., it does not land on other stable bricks).

      -

      Return an array representing the number of bricks that will drop after each erasure in sequence.

      +

      Return an array result, where each result[i] is the number of bricks that will fall after the ith erasure is applied.

      -

      Note that an erasure may refer to a location with no brick and if it does, no bricks drop.

      +

      Note that an erasure may refer to a location with no brick, and if it does, no bricks drop.

       

      Example 1:

      @@ -30,7 +30,16 @@
       Input: grid = [[1,0,0,0],[1,1,1,0]], hits = [[1,0]]
       Output: [2]
      -Explanation: If we erase the brick at (1, 0), the brick at (1, 1) and (1, 2) will drop. So we should return 2.
      +Explanation: Starting with the grid:
      +[[1,0,0,0],
      + [1,1,1,0]]
      +We erase the underlined brick at (1,0), resulting in the grid:
      +[[1,0,0,0],
      + [0,1,1,0]]
      +The two underlined bricks are no longer stable as they are no longer connected to the top nor adjacent to another stable brick, so they will fall. The resulting grid is:
      +[[1,0,0,0],
      + [0,0,0,0]]
      +Hence the result is [2].
       

      Example 2:

      @@ -38,8 +47,20 @@
       Input: grid = [[1,0,0,0],[1,1,0,0]], hits = [[1,1],[1,0]]
       Output: [0,0]
      -Explanation: When we erase the brick at (1, 0), the brick at (1, 1) has already disappeared due to the last move. So each erasure will cause no bricks dropping.
      -Note that the erased brick (1, 0) will not be counted as a dropped brick.
      +Explanation: Starting with the grid:
      +[[1,0,0,0],
      + [1,1,0,0]]
      +We erase the underlined brick at (1,1), resulting in the grid:
      +[[1,0,0,0],
      + [1,0,0,0]]
      +All remaining bricks are still stable, so no bricks fall. The grid remains the same:
      +[[1,0,0,0],
      + [1,0,0,0]]
      +Next, we erase the underlined brick at (1,0), resulting in the grid:
      +[[1,0,0,0],
      + [0,0,0,0]]
      +Once again, all remaining bricks are still stable, so no bricks fall.
      +Hence the result is [0,0].
       

       

      diff --git a/problems/can-place-flowers/README.md b/problems/can-place-flowers/README.md index 18f55a282..a486b01f2 100644 --- a/problems/can-place-flowers/README.md +++ b/problems/can-place-flowers/README.md @@ -11,33 +11,30 @@ ## [605. Can Place Flowers (Easy)](https://leetcode.com/problems/can-place-flowers "种花问题") -

      Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and both would die.

      +

      You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in adjacent plots.

      -

      Given a flowerbed (represented as an array containing 0 and 1, where 0 means empty and 1 means not empty), and a number n, return if n new flowers can be planted in it without violating the no-adjacent-flowers rule.

      +

      Given an integer array flowerbed containing 0's and 1's, where 0 means empty and 1 means not empty, and an integer n, return if n new flowers can be planted in the flowerbed without violating the no-adjacent-flowers rule.

      -

      Example 1:
      -

      -Input: flowerbed = [1,0,0,0,1], n = 1
      -Output: True
      +

       

      +

      Example 1:

      +
      Input: flowerbed = [1,0,0,0,1], n = 1
      +Output: true
      +

      Example 2:

      +
      Input: flowerbed = [1,0,0,0,1], n = 2
      +Output: false
       
      -

      +

       

      +

      Constraints:

      -

      Example 2:
      -

      -Input: flowerbed = [1,0,0,0,1], n = 2
      -Output: False
      -
      -

      - -

      Note:
      -

        -
      1. The input array won't violate no-adjacent-flowers rule.
      2. -
      3. The input array size is in the range of [1, 20000].
      4. -
      5. n is a non-negative integer which won't exceed the input array size.
      6. -
      -

      +
        +
      • 1 <= flowerbed.length <= 2 * 104
      • +
      • flowerbed[i] is 0 or 1.
      • +
      • There are no two adjacent flowers in flowerbed.
      • +
      • 0 <= n <= flowerbed.length
      • +
      ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] ### Similar Questions diff --git a/problems/cat-and-mouse/README.md b/problems/cat-and-mouse/README.md index 51ad3256e..2654f1174 100644 --- a/problems/cat-and-mouse/README.md +++ b/problems/cat-and-mouse/README.md @@ -15,51 +15,54 @@

      The graph is given as follows: graph[a] is a list of all nodes b such that ab is an edge of the graph.

      -

      Mouse starts at node 1 and goes first, Cat starts at node 2 and goes second, and there is a Hole at node 0.

      +

      The mouse starts at node 1 and goes first, the cat starts at node 2 and goes second, and there is a hole at node 0.

      -

      During each player's turn, they must travel along one edge of the graph that meets where they are.  For example, if the Mouse is at node 1, it must travel to any node in graph[1].

      +

      During each player's turn, they must travel along one edge of the graph that meets where they are.  For example, if the Mouse is at node 1, it must travel to any node in graph[1].

      Additionally, it is not allowed for the Cat to travel to the Hole (node 0.)

      -

      Then, the game can end in 3 ways:

      +

      Then, the game can end in three ways:

      • If ever the Cat occupies the same node as the Mouse, the Cat wins.
      • If ever the Mouse reaches the Hole, the Mouse wins.
      • -
      • If ever a position is repeated (ie. the players are in the same position as a previous turn, and it is the same player's turn to move), the game is a draw.
      • +
      • If ever a position is repeated (i.e., the players are in the same position as a previous turn, and it is the same player's turn to move), the game is a draw.
      -

      Given a graph, and assuming both players play optimally, return 1 if the game is won by Mouse, 2 if the game is won by Cat, and 0 if the game is a draw.

      +

      Given a graph, and assuming both players play optimally, return

      -

       

      - -
        -
      +
        +
      • 1 if the mouse wins the game,
      • +
      • 2 if the cat wins the game, or
      • +
      • 0 if the game is a draw.
      • +
      -
      +

       

      Example 1:

      + +
      +Input: graph = [[2,5],[3],[0,4,5],[1,4,5],[2,3],[0,2,3]]
      +Output: 0
      +
      +

      Example 2:

      +
      -Input: [[2,5],[3],[0,4,5],[1,4,5],[2,3],[0,2,3]]
      -Output: 0
      -Explanation:
      -4---3---1
      -|   |
      -2---5
      - \ /
      -  0
      +Input: graph = [[1,3],[0],[3],[0,2]]
      +Output: 1
       

       

      +

      Constraints:

      -

      Note:

      - -
        +
        • 3 <= graph.length <= 50
        • -
        • It is guaranteed that graph[1] is non-empty.
        • -
        • It is guaranteed that graph[2] contains a non-zero element. 
        • -
      -
      +
    • 1 <= graph[i].length < graph.length
    • +
    • 0 <= graph[i][j] < graph.length
    • +
    • graph[i][j] != i
    • +
    • graph[i] is unique.
    • +
    • The mouse and the cat can always move. 
    • +
    ### Related Topics [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/change-the-root-of-a-binary-tree/README.md b/problems/change-the-root-of-a-binary-tree/README.md new file mode 100644 index 000000000..77a2fe0f1 --- /dev/null +++ b/problems/change-the-root-of-a-binary-tree/README.md @@ -0,0 +1,29 @@ + + + + + + + +[< Previous](../minimum-initial-energy-to-finish-tasks "Minimum Initial Energy to Finish Tasks") +                 +[Next >](../fix-names-in-a-table "Fix Names in a Table") + +## [1666. Change the Root of a Binary Tree (Medium)](https://leetcode.com/problems/change-the-root-of-a-binary-tree "") + + + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + +### Hints +
    +Hint 1 +Start traversing from the leaf. Always go up till you reach the root. +
    + +
    +Hint 2 +Change pointers as asked, make the current node's parent its left child, and make the left child the right one if needed. +
    diff --git a/problems/check-completeness-of-a-binary-tree/README.md b/problems/check-completeness-of-a-binary-tree/README.md index 1640ba56e..2ca969e95 100644 --- a/problems/check-completeness-of-a-binary-tree/README.md +++ b/problems/check-completeness-of-a-binary-tree/README.md @@ -11,42 +11,34 @@ ## [958. Check Completeness of a Binary Tree (Medium)](https://leetcode.com/problems/check-completeness-of-a-binary-tree "二叉树的完全性检验") -

    Given a binary tree, determine if it is a complete binary tree.

    +

    Given the root of a binary tree, determine if it is a complete binary tree.

    -

    Definition of a complete binary tree from Wikipedia:
    -In a complete binary tree every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible. It can have between 1 and 2h nodes inclusive at the last level h.

    +

    In a complete binary tree, every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible. It can have between 1 and 2h nodes inclusive at the last level h.

     

    -

    Example 1:

    - -

    - +
    -Input: [1,2,3,4,5,6]
    -Output: true
    -Explanation: Every level before the last is full (ie. levels with node-values {1} and {2, 3}), and all nodes in the last level ({4, 5, 6}) are as far left as possible.
    +Input: root = [1,2,3,4,5,6]
    +Output: true
    +Explanation: Every level before the last is full (ie. levels with node-values {1} and {2, 3}), and all nodes in the last level ({4, 5, 6}) are as far left as possible.
     
    -

    Example 2:

    - -

    - +
    -Input: [1,2,3,4,5,null,7]
    -Output: false
    -Explanation: The node with value 7 isn't as far left as possible.
    -
    - -
     
    -
    +Input: root = [1,2,3,4,5,null,7] +Output: false +Explanation: The node with value 7 isn't as far left as possible. +
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. The tree will have between 1 and 100 nodes.
    2. -
    +
      +
    • The number of nodes in the tree is in the range [1, 100].
    • +
    • 1 <= Node.val <= 1000
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/check-if-two-string-arrays-are-equivalent/README.md b/problems/check-if-two-string-arrays-are-equivalent/README.md new file mode 100644 index 000000000..77589443f --- /dev/null +++ b/problems/check-if-two-string-arrays-are-equivalent/README.md @@ -0,0 +1,65 @@ + + + + + + + +[< Previous](../average-time-of-process-per-machine "Average Time of Process per Machine") +                 +[Next >](../smallest-string-with-a-given-numeric-value "Smallest String With A Given Numeric Value") + +## [1662. Check If Two String Arrays are Equivalent (Easy)](https://leetcode.com/problems/check-if-two-string-arrays-are-equivalent "检查两个字符串数组是否相等") + +

    Given two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise.

    + +

    A string is represented by an array if the array elements concatenated in order forms the string.

    + +

     

    +

    Example 1:

    + +
    +Input: word1 = ["ab", "c"], word2 = ["a", "bc"]
    +Output: true
    +Explanation:
    +word1 represents string "ab" + "c" -> "abc"
    +word2 represents string "a" + "bc" -> "abc"
    +The strings are the same, so return true.
    + +

    Example 2:

    + +
    +Input: word1 = ["a", "cb"], word2 = ["ab", "c"]
    +Output: false
    +
    + +

    Example 3:

    + +
    +Input: word1  = ["abc", "d", "defg"], word2 = ["abcddefg"]
    +Output: true
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= word1.length, word2.length <= 103
    • +
    • 1 <= word1[i].length, word2[i].length <= 103
    • +
    • 1 <= sum(word1[i].length), sum(word2[i].length) <= 103
    • +
    • word1[i] and word2[i] consist of lowercase letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Concatenate all strings in the first array into a single string in the given order, the same for the second array. +
    + +
    +Hint 2 +Both arrays represent the same string if and only if the generated strings are the same. +
    diff --git a/problems/concatenation-of-consecutive-binary-numbers/README.md b/problems/concatenation-of-consecutive-binary-numbers/README.md new file mode 100644 index 000000000..c60ace665 --- /dev/null +++ b/problems/concatenation-of-consecutive-binary-numbers/README.md @@ -0,0 +1,58 @@ + + + + + + + +[< Previous](../max-number-of-k-sum-pairs "Max Number of K-Sum Pairs") +                 +[Next >](../minimum-incompatibility "Minimum Incompatibility") + +## [1680. Concatenation of Consecutive Binary Numbers (Medium)](https://leetcode.com/problems/concatenation-of-consecutive-binary-numbers "连接连续二进制数字") + +

    Given an integer n, return the decimal value of the binary string formed by concatenating the binary representations of 1 to n in order, modulo 109 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 1
    +Output: 1
    +Explanation: "1" in binary corresponds to the decimal value 1. 
    +
    + +

    Example 2:

    + +
    +Input: n = 3
    +Output: 27
    +Explanation: In binary, 1, 2, and 3 corresponds to "1", "10", and "11".
    +After concatenating them, we have "11011", which corresponds to the decimal value 27.
    +
    + +

    Example 3:

    + +
    +Input: n = 12
    +Output: 505379714
    +Explanation: The concatenation results in "1101110010111011110001001101010111100".
    +The decimal value of that is 118505380540.
    +After modulo 109 + 7, the result is 505379714.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 105
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Express the nth number value in a recursion formula and think about how we can do a fast evaluation. +
    diff --git a/problems/correct-a-binary-tree/README.md b/problems/correct-a-binary-tree/README.md new file mode 100644 index 000000000..17e19bdd5 --- /dev/null +++ b/problems/correct-a-binary-tree/README.md @@ -0,0 +1,23 @@ + + + + + + + +[< Previous](../maximize-grid-happiness "Maximize Grid Happiness") +                 +[Next >](../average-time-of-process-per-machine "Average Time of Process per Machine") + +## [1660. Correct a Binary Tree (Medium)](https://leetcode.com/problems/correct-a-binary-tree "纠正二叉树") + + + +### Related Topics + [[Tree](../../tag/tree/README.md)] + +### Hints +
    +Hint 1 +If you traverse the tree from right to left, the invalid node will point to a node that has already been visited. +
    diff --git a/problems/cut-off-trees-for-golf-event/README.md b/problems/cut-off-trees-for-golf-event/README.md index d00dda833..4f8b85117 100644 --- a/problems/cut-off-trees-for-golf-event/README.md +++ b/problems/cut-off-trees-for-golf-event/README.md @@ -11,70 +11,56 @@ ## [675. Cut Off Trees for Golf Event (Hard)](https://leetcode.com/problems/cut-off-trees-for-golf-event "为高尔夫比赛砍树") -

    You are asked to cut off trees in a forest for a golf event. The forest is represented as a non-negative 2D map, in this map:

    +

    You are asked to cut off all the trees in a forest for a golf event. The forest is represented as an m x n matrix. In this matrix:

    -
      -
    1. 0 represents the obstacle can't be reached.
    2. -
    3. 1 represents the ground can be walked through.
    4. -
    5. The place with number bigger than 1 represents a tree can be walked through, and this positive number represents the tree's height.
    6. -
    - -

    In one step you can walk in any of the four directions top, bottom, left and right also when standing in a point which is a tree you can decide whether or not to cut off the tree.

    +
      +
    • 0 means the cell cannot be walked through.
    • +
    • 1 represents an empty cell that can be walked through.
    • +
    • A number greater than 1 represents a tree in a cell that can be walked through, and this number is the tree's height.
    • +
    -

    You are asked to cut off all the trees in this forest in the order of tree's height - always cut off the tree with lowest height first. And after cutting, the original place has the tree will become a grass (value 1).

    +

    In one step, you can walk in any of the four directions: north, east, south, and west. If you are standing in a cell with a tree, you can choose whether to cut it off.

    -

    You will start from the point (0, 0) and you should output the minimum steps you need to walk to cut off all the trees. If you can't cut off all the trees, output -1 in that situation.

    +

    You must cut off the trees in order from shortest to tallest. When you cut off a tree, the value at its cell becomes 1 (an empty cell).

    -

    You are guaranteed that no two trees have the same height and there is at least one tree needs to be cut off.

    +

    Starting from the point (0, 0), return the minimum steps you need to walk to cut off all the trees. If you cannot cut off all the trees, return -1.

    -

    Example 1:

    +

    You are guaranteed that no two trees have the same height, and there is at least one tree needs to be cut off.

    +

     

    +

    Example 1:

    +
    -Input: 
    -[
    - [1,2,3],
    - [0,0,4],
    - [7,6,5]
    -]
    -Output: 6
    +Input: forest = [[1,2,3],[0,0,4],[7,6,5]]
    +Output: 6
    +Explanation: Following the path above allows you to cut off the trees from shortest to tallest in 6 steps.
     
    -

     

    - -

    Example 2:

    - +

    Example 2:

    +
    -Input: 
    -[
    - [1,2,3],
    - [0,0,0],
    - [7,6,5]
    -]
    -Output: -1
    +Input: forest = [[1,2,3],[0,0,0],[7,6,5]]
    +Output: -1
    +Explanation: The trees in the bottom row cannot be accessed as the middle row is blocked.
     
    -

     

    - -

    Example 3:

    +

    Example 3:

    -Input: 
    -[
    - [2,3,4],
    - [0,0,5],
    - [8,7,6]
    -]
    -Output: 6
    -Explanation: You started from the point (0,0) and you can cut off the tree in (0,0) directly without walking.
    +Input: forest = [[2,3,4],[0,0,5],[8,7,6]]
    +Output: 6
    +Explanation: You can follow the same path as Example 1 to cut off all the trees.
    +Note that you can cut off the first tree at (0, 0) before making any steps.
     

     

    Constraints:

      -
    • 1 <= forest.length <= 50
    • -
    • 1 <= forest[i].length <= 50
    • -
    • 0 <= forest[i][j] <= 10^9
    • +
    • m == forest.length
    • +
    • n == forest[i].length
    • +
    • 1 <= m, n <= 50
    • +
    • 0 <= forest[i][j] <= 109
    ### Related Topics diff --git a/problems/decode-string/README.md b/problems/decode-string/README.md index cc017aceb..d555f839c 100644 --- a/problems/decode-string/README.md +++ b/problems/decode-string/README.md @@ -33,6 +33,15 @@
    Input: s = "abc3[cd]xyz"
     Output: "abccdcdcdxyz"
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 30
    • +
    • s consists of lowercase English letters, digits, and square brackets '[]'.
    • +
    • s is guaranteed to be a valid input.
    • +
    • All the integers in s are in the range [1, 300].
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/delete-duplicate-emails/mysql_schemas.sql b/problems/delete-duplicate-emails/mysql_schemas.sql new file mode 100644 index 000000000..89062100e --- /dev/null +++ b/problems/delete-duplicate-emails/mysql_schemas.sql @@ -0,0 +1,4 @@ +Truncate table Person; +insert into Person (Id, Email) values ('1', 'john@example.com'); +insert into Person (Id, Email) values ('2', 'bob@example.com'); +insert into Person (Id, Email) values ('3', 'john@example.com'); diff --git a/problems/design-an-expression-tree-with-evaluate-function/README.md b/problems/design-an-expression-tree-with-evaluate-function/README.md index 7423f5947..9a51695ea 100644 --- a/problems/design-an-expression-tree-with-evaluate-function/README.md +++ b/problems/design-an-expression-tree-with-evaluate-function/README.md @@ -30,10 +30,10 @@ Implement the Node class using NumericNode and OperatorNode classes.
    Hint 3 -NumericNode only maintains the value, and evaluate returns this value. +NumericNode only maintains the value and evaluate returns this value.
    Hint 4 -OperatorNode Maintains the left and right nodes representing the the left and right operands, and the evaluate function applies the operator to them. +OperatorNode Maintains the left and right nodes representing the left and right operands, and the evaluate function applies the operator to them.
    diff --git a/problems/design-an-ordered-stream/README.md b/problems/design-an-ordered-stream/README.md index adad5c7c3..9dc2d1e53 100644 --- a/problems/design-an-ordered-stream/README.md +++ b/problems/design-an-ordered-stream/README.md @@ -11,20 +11,15 @@ ## [1656. Design an Ordered Stream (Easy)](https://leetcode.com/problems/design-an-ordered-stream "设计有序流") -

    There are n (id, value) pairs, where id is an integer between 1 and n and value is a string. No two pairs have the same id.

    +

    There is a stream of n (id, value) pairs arriving in an arbitrary order, where id is an integer between 1 and n and value is a string. No two pairs have the same id.

    -

    Design a stream that takes the n pairs in an arbitrary order, and returns the values over several calls in increasing order of their ids.

    +

    Design a stream that returns the values in increasing order of their IDs by returning a chunk (list) of values after each insertion. The concatenation of all the chunks should result in a list of the sorted values.

    Implement the OrderedStream class:

      -
    • OrderedStream(int n) Constructs the stream to take n values and sets a current ptr to 1.
    • -
    • String[] insert(int id, String value) Stores the new (id, value) pair in the stream. After storing the pair: -
        -
      • If the stream has stored a pair with id = ptr, then find the longest contiguous incrementing sequence of ids starting with id = ptr and return a list of the values associated with those ids in order. Then, update ptr to the last id + 1.
      • -
      • Otherwise, return an empty list.
      • -
      -
    • +
    • OrderedStream(int n) Constructs the stream to take n values.
    • +
    • String[] insert(int id, String value) Inserts the pair (id, value) into the stream, then returns the largest possible chunk of currently inserted values that appear next in the order.

     

    @@ -40,12 +35,16 @@ [null, [], ["aaaaa"], ["bbbbb", "ccccc"], [], ["ddddd", "eeeee"]] Explanation -OrderedStream os= new OrderedStream(5); +// Note that the values ordered by ID is ["aaaaa", "bbbbb", "ccccc", "ddddd", "eeeee"]. +OrderedStream os = new OrderedStream(5); os.insert(3, "ccccc"); // Inserts (3, "ccccc"), returns []. os.insert(1, "aaaaa"); // Inserts (1, "aaaaa"), returns ["aaaaa"]. os.insert(2, "bbbbb"); // Inserts (2, "bbbbb"), returns ["bbbbb", "ccccc"]. os.insert(5, "eeeee"); // Inserts (5, "eeeee"), returns []. os.insert(4, "ddddd"); // Inserts (4, "ddddd"), returns ["ddddd", "eeeee"]. +// Concatentating all the chunks returned: +// [] + ["aaaaa"] + ["bbbbb", "ccccc"] + [] + ["ddddd", "eeeee"] = ["aaaaa", "bbbbb", "ccccc", "ddddd", "eeeee"] +// The resulting order is the same as the order above.

     

    diff --git a/problems/design-front-middle-back-queue/README.md b/problems/design-front-middle-back-queue/README.md new file mode 100644 index 000000000..de831172d --- /dev/null +++ b/problems/design-front-middle-back-queue/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../merge-in-between-linked-lists "Merge In Between Linked Lists") +                 +[Next >](../minimum-number-of-removals-to-make-mountain-array "Minimum Number of Removals to Make Mountain Array") + +## [1670. Design Front Middle Back Queue (Medium)](https://leetcode.com/problems/design-front-middle-back-queue "设计前中后队列") + +

    Design a queue that supports push and pop operations in the front, middle, and back.

    + +

    Implement the FrontMiddleBack class:

    + +
      +
    • FrontMiddleBack() Initializes the queue.
    • +
    • void pushFront(int val) Adds val to the front of the queue.
    • +
    • void pushMiddle(int val) Adds val to the middle of the queue.
    • +
    • void pushBack(int val) Adds val to the back of the queue.
    • +
    • int popFront() Removes the front element of the queue and returns it. If the queue is empty, return -1.
    • +
    • int popMiddle() Removes the middle element of the queue and returns it. If the queue is empty, return -1.
    • +
    • int popBack() Removes the back element of the queue and returns it. If the queue is empty, return -1.
    • +
    + +

    Notice that when there are two middle position choices, the operation is performed on the frontmost middle position choice. For example:

    + +
      +
    • Pushing 6 into the middle of [1, 2, 3, 4, 5] results in [1, 2, 6, 3, 4, 5].
    • +
    • Popping the middle from [1, 2, 3, 4, 5, 6] returns 3 and results in [1, 2, 4, 5, 6].
    • +
    + +

     

    +

    Example 1:

    + +
    +Input:
    +["FrontMiddleBackQueue", "pushFront", "pushBack", "pushMiddle", "pushMiddle", "popFront", "popMiddle", "popMiddle", "popBack", "popFront"]
    +[[], [1], [2], [3], [4], [], [], [], [], []]
    +Output:
    +[null, null, null, null, null, 1, 3, 4, 2, -1]
    +
    +Explanation:
    +FrontMiddleBackQueue q = new FrontMiddleBackQueue();
    +q.pushFront(1);   // [1]
    +q.pushBack(2);    // [1, 2]
    +q.pushMiddle(3);  // [1, 3, 2]
    +q.pushMiddle(4);  // [1, 4, 3, 2]
    +q.popFront();     // return 1 -> [4, 3, 2]
    +q.popMiddle();    // return 3 -> [4, 2]
    +q.popMiddle();    // return 4 -> [2]
    +q.popBack();      // return 2 -> []
    +q.popFront();     // return -1 -> [] (The queue is empty)
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= val <= 109
    • +
    • At most 1000 calls will be made to pushFrontpushMiddlepushBack, popFront, popMiddle, and popBack.
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + +### Hints +
    +Hint 1 +The constraints are low enough for a brute force, single array approach. +
    + +
    +Hint 2 +For an O(1) per method approach, use 2 double-ended queues: one for the first half and one for the second half. +
    diff --git a/problems/distant-barcodes/README.md b/problems/distant-barcodes/README.md index b77e33d66..18ae20f69 100644 --- a/problems/distant-barcodes/README.md +++ b/problems/distant-barcodes/README.md @@ -11,39 +11,25 @@ ## [1054. Distant Barcodes (Medium)](https://leetcode.com/problems/distant-barcodes "距离相等的条形码") -

    In a warehouse, there is a row of barcodes, where the i-th barcode is barcodes[i].

    +

    In a warehouse, there is a row of barcodes, where the ith barcode is barcodes[i].

    -

    Rearrange the barcodes so that no two adjacent barcodes are equal.  You may return any answer, and it is guaranteed an answer exists.

    +

    Rearrange the barcodes so that no two adjacent barcodes are equal. You may return any answer, and it is guaranteed an answer exists.

     

    -

    Example 1:

    - -
    -Input: [1,1,1,2,2,2]
    -Output: [2,1,2,1,2,1]
    +
    Input: barcodes = [1,1,1,2,2,2]
    +Output: [2,1,2,1,2,1]
    +

    Example 2:

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

    Example 2:

    - -
    -Input: [1,1,1,1,2,2,3,3]
    -Output: [1,3,1,3,2,1,2,1]
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= barcodes.length <= 10000
      • 1 <= barcodes[i] <= 10000
      • -
    - -
    -
     
    -
    + ### Related Topics [[Heap](../../tag/heap/README.md)] diff --git a/problems/distribute-candies/README.md b/problems/distribute-candies/README.md index 8013d8d48..e59aecc31 100644 --- a/problems/distribute-candies/README.md +++ b/problems/distribute-candies/README.md @@ -11,65 +11,45 @@ ## [575. Distribute Candies (Easy)](https://leetcode.com/problems/distribute-candies "分糖果") -

    You have n candies, the ith candy is of type candies[i].

    +

    Alice has n candies, where the ith candy is of type candyType[i]. Alice noticed that she started to gain weight, so she visited a doctor.

    -

    You want to distribute the candies equally between a sister and a brother so that each of them gets n / 2 candies (n is even). The sister loves to collect different types of candies, so you want to give her the maximum number of different types of candies.

    +

    The doctor advised Alice to only eat n / 2 of the candies she has (n is always even). Alice likes her candies very much, and she wants to eat the maximum number of different types of candies while still following the doctor's advice.

    -

    Return the maximum number of different types of candies you can give to the sister.

    - -
      -
    +

    Given the integer array candyType of length n, return the maximum number of different types of candies she can eat if she only eats n / 2 of them.

     

    Example 1:

    -Input: candies = [1,1,2,2,3,3]
    +Input: candyType = [1,1,2,2,3,3]
     Output: 3
    -Explanation:
    -There are three different kinds of candies (1, 2 and 3), and two candies for each kind.
    -Optimal distribution: The sister has candies [1,2,3] and the brother has candies [1,2,3], too. 
    -The sister has three different kinds of candies. 
    +Explanation: Alice can only eat 6 / 2 = 3 candies. Since there are only 3 types, she can eat one of each type.
     

    Example 2:

    -Input: candies = [1,1,2,3]
    +Input: candyType = [1,1,2,3]
     Output: 2
    -Explanation: For example, the sister has candies [2,3] and the brother has candies [1,1]. 
    -The sister has two different kinds of candies, the brother has only one kind of candies.
    +Explanation: Alice can only eat 4 / 2 = 2 candies. Whether she eats types [1,2], [1,3], or [2,3], she still can only eat 2 different types.
     

    Example 3:

    -Input: candies = [1,1]
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: candies = [1,11]
    -Output: 1
    -
    - -

    Example 5:

    - -
    -Input: candies = [2,2]
    +Input: candyType = [6,6,6,6]
     Output: 1
    +Explanation: Alice can only eat 4 / 2 = 2 candies. Even though she can eat 2 candies, she only has 1 type.
     

     

    Constraints:

      -
    • n == candies.length
    • +
    • n == candyType.length
    • 2 <= n <= 104
    • n is even.
    • -
    • -105 <= candies[i] <= 105
    • +
    • -105 <= candyType[i] <= 105
    ### Related Topics diff --git a/problems/find-k-closest-elements/README.md b/problems/find-k-closest-elements/README.md index eadcf4ad5..ab9557ab8 100644 --- a/problems/find-k-closest-elements/README.md +++ b/problems/find-k-closest-elements/README.md @@ -11,7 +11,14 @@ ## [658. Find K Closest Elements (Medium)](https://leetcode.com/problems/find-k-closest-elements "找到 K 个最接近的元素") -

    Given a sorted array arr, two integers k and x, find the k closest elements to x in the array. The result should also be sorted in ascending order. If there is a tie, the smaller elements are always preferred.

    +

    Given a sorted integer array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending order.

    + +

    An integer a is closer to x than an integer b if:

    + +
      +
    • |a - x| < |b - x|, or
    • +
    • |a - x| == |b - x| and a < b
    • +

     

    Example 1:

    @@ -26,8 +33,8 @@
    • 1 <= k <= arr.length
    • -
    • 1 <= arr.length <= 10^4
    • -
    • Absolute value of elements in the array and x will not exceed 104
    • +
    • 1 <= arr.length <= 104
    • +
    • Absolute value of elements in the array and x will not exceed 104
    ### Related Topics diff --git a/problems/find-peak-element/README.md b/problems/find-peak-element/README.md index 0e6e3069d..a2dc1edef 100644 --- a/problems/find-peak-element/README.md +++ b/problems/find-peak-element/README.md @@ -11,31 +11,38 @@ ## [162. Find Peak Element (Medium)](https://leetcode.com/problems/find-peak-element "寻找峰值") -

    A peak element is an element that is greater than its neighbors.

    +

    A peak element is an element that is strictly greater than its neighbors.

    -

    Given an input array nums, where nums[i] ≠ nums[i+1], find a peak element and return its index.

    - -

    The array may contain multiple peaks, in that case return the index to any one of the peaks is fine.

    +

    Given an integer array nums, find a peak element, and return its index. If the array contains multiple peaks, return the index to any of the peaks.

    You may imagine that nums[-1] = nums[n] = -∞.

    +

     

    Example 1:

    -Input: nums = [1,2,3,1]
    +Input: nums = [1,2,3,1]
     Output: 2
     Explanation: 3 is a peak element and your function should return the index number 2.

    Example 2:

    -Input: nums = [1,2,1,3,5,6,4]
    -Output: 1 or 5 
    -Explanation: Your function can return either index number 1 where the peak element is 2, 
    -             or index number 5 where the peak element is 6.
    -
    +Input: nums = [1,2,1,3,5,6,4] +Output: 5 +Explanation: Your function can return either index number 1 where the peak element is 2, or index number 5 where the peak element is 6.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • -231 <= nums[i] <= 231 - 1
    • +
    • nums[i] != nums[i + 1] for all valid i.
    • +
    -

    Follow up: Your solution should be in logarithmic complexity.

    +

     

    +Follow up: Could you implement a solution with logarithmic complexity? ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/find-the-most-competitive-subsequence/README.md b/problems/find-the-most-competitive-subsequence/README.md new file mode 100644 index 000000000..6368432fa --- /dev/null +++ b/problems/find-the-most-competitive-subsequence/README.md @@ -0,0 +1,53 @@ + + + + + + + +[< Previous](../richest-customer-wealth "Richest Customer Wealth") +                 +[Next >](../minimum-moves-to-make-array-complementary "Minimum Moves to Make Array Complementary") + +## [1673. Find the Most Competitive Subsequence (Medium)](https://leetcode.com/problems/find-the-most-competitive-subsequence "找出最具竞争力的子序列") + +

    Given an integer array nums and a positive integer k, return the most competitive subsequence of nums of size k.

    + +

    An array's subsequence is a resulting sequence obtained by erasing some (possibly zero) elements from the array.

    + +

    We define that a subsequence a is more competitive than a subsequence b (of the same length) if in the first position where a and b differ, subsequence a has a number less than the corresponding number in b. For example, [1,3,4] is more competitive than [1,3,5] because the first position they differ is at the final number, and 4 is less than 5.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [3,5,2,6], k = 2
    +Output: [2,6]
    +Explanation: Among the set of every possible subsequence: {[3,5], [3,2], [3,6], [5,2], [5,6], [2,6]}, [2,6] is the most competitive.
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,4,3,3,5,4,9,6], k = 4
    +Output: [2,3,3,4]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 0 <= nums[i] <= 109
    • +
    • 1 <= k <= nums.length
    • +
    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +In lexicographical order, the elements to the left have higher priority than those that come after. Can you think of a strategy that incrementally builds the answer from left to right? +
    diff --git a/problems/fix-names-in-a-table/README.md b/problems/fix-names-in-a-table/README.md new file mode 100644 index 000000000..3f8f064c4 --- /dev/null +++ b/problems/fix-names-in-a-table/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../change-the-root-of-a-binary-tree "Change the Root of a Binary Tree") +                 +[Next >](../maximum-repeating-substring "Maximum Repeating Substring") + +## [1667. Fix Names in a Table (Easy)](https://leetcode.com/problems/fix-names-in-a-table "") + + diff --git a/problems/fix-names-in-a-table/mysql_schemas.sql b/problems/fix-names-in-a-table/mysql_schemas.sql new file mode 100644 index 000000000..2f40f9f43 --- /dev/null +++ b/problems/fix-names-in-a-table/mysql_schemas.sql @@ -0,0 +1,4 @@ +Create table If Not Exists Users (user_id int, name varchar(40)); +Truncate table Users; +insert into Users (user_id, name) values ('1', 'aLice'); +insert into Users (user_id, name) values ('2', 'bOB'); diff --git a/problems/flatten-a-multilevel-doubly-linked-list/README.md b/problems/flatten-a-multilevel-doubly-linked-list/README.md index 6a4366de6..cf1171c63 100644 --- a/problems/flatten-a-multilevel-doubly-linked-list/README.md +++ b/problems/flatten-a-multilevel-doubly-linked-list/README.md @@ -91,8 +91,8 @@ After flattening the multilevel linked list it becomes:

    Constraints:

      -
    • Number of Nodes will not exceed 1000.
    • -
    • 1 <= Node.val <= 10^5
    • +
    • The number of Nodes will not exceed 1000.
    • +
    • 1 <= Node.val <= 105
    ### Related Topics diff --git a/problems/friend-requests-i-overall-acceptance-rate/mysql_schemas.sql b/problems/friend-requests-i-overall-acceptance-rate/mysql_schemas.sql index bd0ed2be6..c5b60b0ec 100644 --- a/problems/friend-requests-i-overall-acceptance-rate/mysql_schemas.sql +++ b/problems/friend-requests-i-overall-acceptance-rate/mysql_schemas.sql @@ -1,14 +1,14 @@ -Create table If Not Exists friend_request ( sender_id INT NOT NULL, send_to_id INT NULL, request_date DATE NULL); -Create table If Not Exists request_accepted ( requester_id INT NOT NULL, accepter_id INT NULL, accept_date DATE NULL); -Truncate table friend_request; -insert into friend_request (sender_id, send_to_id, request_date) values ('1', '2', '2016/06/01'); -insert into friend_request (sender_id, send_to_id, request_date) values ('1', '3', '2016/06/01'); -insert into friend_request (sender_id, send_to_id, request_date) values ('1', '4', '2016/06/01'); -insert into friend_request (sender_id, send_to_id, request_date) values ('2', '3', '2016/06/02'); -insert into friend_request (sender_id, send_to_id, request_date) values ('3', '4', '2016/06/09'); -Truncate table request_accepted; -insert into request_accepted (requester_id, accepter_id, accept_date) values ('1', '2', '2016/06/03'); -insert into request_accepted (requester_id, accepter_id, accept_date) values ('1', '3', '2016/06/08'); -insert into request_accepted (requester_id, accepter_id, accept_date) values ('2', '3', '2016/06/08'); -insert into request_accepted (requester_id, accepter_id, accept_date) values ('3', '4', '2016/06/09'); -insert into request_accepted (requester_id, accepter_id, accept_date) values ('3', '4', '2016/06/10'); +Create table If Not Exists FriendRequest (sender_id int, send_to_id int, request_date date); +Create table If Not Exists RequestAccepted (requester_id int, accepter_id int, accept_date date); +Truncate table FriendRequest; +insert into FriendRequest (sender_id, send_to_id, request_date) values ('1', '2', '2016/06/01'); +insert into FriendRequest (sender_id, send_to_id, request_date) values ('1', '3', '2016/06/01'); +insert into FriendRequest (sender_id, send_to_id, request_date) values ('1', '4', '2016/06/01'); +insert into FriendRequest (sender_id, send_to_id, request_date) values ('2', '3', '2016/06/02'); +insert into FriendRequest (sender_id, send_to_id, request_date) values ('3', '4', '2016/06/09'); +Truncate table RequestAccepted; +insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('1', '2', '2016/06/03'); +insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('1', '3', '2016/06/08'); +insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('2', '3', '2016/06/08'); +insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('3', '4', '2016/06/09'); +insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('3', '4', '2016/06/10'); diff --git a/problems/frog-position-after-t-seconds/README.md b/problems/frog-position-after-t-seconds/README.md index b54d2c14a..a546fd343 100644 --- a/problems/frog-position-after-t-seconds/README.md +++ b/problems/frog-position-after-t-seconds/README.md @@ -11,11 +11,11 @@ ## [1377. Frog Position After T Seconds (Hard)](https://leetcode.com/problems/frog-position-after-t-seconds "T 秒后青蛙的位置") -

    Given an undirected tree consisting of n vertices numbered from 1 to n. A frog starts jumping from the vertex 1. In one second, the frog jumps from its current vertex to another unvisited vertex if they are directly connected. The frog can not jump back to a visited vertex. In case the frog can jump to several vertices it jumps randomly to one of them with the same probability, otherwise, when the frog can not jump to any unvisited vertex it jumps forever on the same vertex. 

    +

    Given an undirected tree consisting of n vertices numbered from 1 to n. A frog starts jumping from vertex 1. In one second, the frog jumps from its current vertex to another unvisited vertex if they are directly connected. The frog can not jump back to a visited vertex. In case the frog can jump to several vertices, it jumps randomly to one of them with the same probability. Otherwise, when the frog can not jump to any unvisited vertex, it jumps forever on the same vertex.

    -

    The edges of the undirected tree are given in the array edges, where edges[i] = [fromi, toi] means that exists an edge connecting directly the vertices fromi and toi.

    +

    The edges of the undirected tree are given in the array edges, where edges[i] = [ai, bi] means that exists an edge connecting the vertices ai and bi.

    -

    Return the probability that after t seconds the frog is on the vertex target.

    +

    Return the probability that after t seconds the frog is on the vertex target.

     

    Example 1:

    @@ -50,12 +50,12 @@
    • 1 <= n <= 100
    • -
    • edges.length == n-1
    • +
    • edges.length == n - 1
    • edges[i].length == 2
    • -
    • 1 <= edges[i][0], edges[i][1] <= n
    • +
    • 1 <= ai, bi <= n
    • 1 <= t <= 50
    • 1 <= target <= n
    • -
    • Answers within 10^-5 of the actual value will be accepted as correct.
    • +
    • Answers within 10-5 of the actual value will be accepted as correct.
    ### Related Topics diff --git a/problems/goal-parser-interpretation/README.md b/problems/goal-parser-interpretation/README.md new file mode 100644 index 000000000..fbd323536 --- /dev/null +++ b/problems/goal-parser-interpretation/README.md @@ -0,0 +1,60 @@ + + + + + + + +[< Previous](../products-worth-over-invoices "Product's Worth Over Invoices") +                 +[Next >](../max-number-of-k-sum-pairs "Max Number of K-Sum Pairs") + +## [1678. Goal Parser Interpretation (Easy)](https://leetcode.com/problems/goal-parser-interpretation "设计 Goal 解析器") + +

    You own a Goal Parser that can interpret a string command. The command consists of an alphabet of "G", "()" and/or "(al)" in some order. The Goal Parser will interpret "G" as the string "G", "()" as the string "o", and "(al)" as the string "al". The interpreted strings are then concatenated in the original order.

    + +

    Given the string command, return the Goal Parser's interpretation of command.

    + +

     

    +

    Example 1:

    + +
    +Input: command = "G()(al)"
    +Output: "Goal"
    +Explanation: The Goal Parser interprets the command as follows:
    +G -> G
    +() -> o
    +(al) -> al
    +The final concatenated result is "Goal".
    +
    + +

    Example 2:

    + +
    +Input: command = "G()()()()(al)"
    +Output: "Gooooal"
    +
    + +

    Example 3:

    + +
    +Input: command = "(al)G(al)()()G"
    +Output: "alGalooG"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= command.length <= 100
    • +
    • command consists of "G", "()", and/or "(al)" in some order.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +You need to check at most 2 characters to determine which character comes next. +
    diff --git a/problems/increasing-order-search-tree/README.md b/problems/increasing-order-search-tree/README.md index 6bd71fc00..6969f0f7f 100644 --- a/problems/increasing-order-search-tree/README.md +++ b/problems/increasing-order-search-tree/README.md @@ -11,47 +11,32 @@ ## [897. Increasing Order Search Tree (Easy)](https://leetcode.com/problems/increasing-order-search-tree "递增顺序查找树") -

    Given a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only 1 right child.

    +

    Given the root of a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only one right child.

    +

     

    +

    Example 1:

    +
    -Example 1:
    -Input: [5,3,6,2,4,null,8,1,null,null,null,7,9]
    -
    -       5
    -      / \
    -    3    6
    -   / \    \
    -  2   4    8
    - /        / \ 
    -1        7   9
    -
    +Input: root = [5,3,6,2,4,null,8,1,null,null,null,7,9]
     Output: [1,null,2,null,3,null,4,null,5,null,6,null,7,null,8,null,9]
    +
    + +

    Example 2:

    + +
    +Input: root = [5,1,7]
    +Output: [1,null,5,null,7]
    +
    - 1 -  \ -  2 -  \ -  3 -  \ -  4 -  \ -  5 -  \ -  6 -  \ -  7 -  \ -  8 -  \ - 9

     

    Constraints:

      -
    • The number of nodes in the given tree will be between 1 and 100.
    • -
    • Each node will have a unique integer value from 0 to 1000.
    • +
    • The number of nodes in the given tree will be in the range [1, 100].
    • +
    • 0 <= Node.val <= 1000
    ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Recursion](../../tag/recursion/README.md)] diff --git a/problems/is-graph-bipartite/README.md b/problems/is-graph-bipartite/README.md index a45f0a3fe..ff69add19 100644 --- a/problems/is-graph-bipartite/README.md +++ b/problems/is-graph-bipartite/README.md @@ -41,7 +41,7 @@
    • 1 <= graph.length <= 100
    • -
    • 0 <= graphp[i].length < 100
    • +
    • 0 <= graph[i].length < 100
    • 0 <= graph[i][j] <= graph.length - 1
    • graph[i][j] != i
    • All the values of graph[i] are unique.
    • diff --git a/problems/iterator-for-combination/README.md b/problems/iterator-for-combination/README.md index f4afa69bc..366387cee 100644 --- a/problems/iterator-for-combination/README.md +++ b/problems/iterator-for-combination/README.md @@ -11,27 +11,32 @@ ## [1286. Iterator for Combination (Medium)](https://leetcode.com/problems/iterator-for-combination "字母组合迭代器") -

      Design an Iterator class, which has:

      +

      Design the CombinationIterator class:

        -
      • A constructor that takes a string characters of sorted distinct lowercase English letters and a number combinationLength as arguments.
      • -
      • A function next() that returns the next combination of length combinationLength in lexicographical order.
      • -
      • A function hasNext() that returns True if and only if there exists a next combination.
      • +
      • CombinationIterator(string characters, int combinationLength) Initializes the object with a string characters of sorted distinct lowercase English letters and a number combinationLength as arguments.
      • +
      • next() Returns the next combination of length combinationLength in lexicographical order.
      • +
      • hasNext() Returns true if and only if there exists a next combination.

       

      - -

      Example:

      +

      Example 1:

      -CombinationIterator iterator = new CombinationIterator("abc", 2); // creates the iterator.
      -
      -iterator.next(); // returns "ab"
      -iterator.hasNext(); // returns true
      -iterator.next(); // returns "ac"
      -iterator.hasNext(); // returns true
      -iterator.next(); // returns "bc"
      -iterator.hasNext(); // returns false
      +Input
      +["CombinationIterator", "next", "hasNext", "next", "hasNext", "next", "hasNext"]
      +[["abc", 2], [], [], [], [], [], []]
      +Output
      +[null, "ab", true, "ac", true, "bc", false]
      +
      +Explanation
      +CombinationIterator itr = new CombinationIterator("abc", 2);
      +itr.next();    // return "ab"
      +itr.hasNext(); // return True
      +itr.next();    // return "ac"
      +itr.hasNext(); // return True
      +itr.next();    // return "bc"
      +itr.hasNext(); // return False
       

       

      @@ -39,7 +44,8 @@ iterator.hasNext(); // returns false
      • 1 <= combinationLength <= characters.length <= 15
      • -
      • There will be at most 10^4 function calls per test.
      • +
      • All the characters of characters are unique.
      • +
      • At most 104 calls will be made to next and hasNext.
      • It's guaranteed that all calls of the function next are valid.
      diff --git a/problems/jump-game-iii/README.md b/problems/jump-game-iii/README.md index ad2a1e1c5..9b9c278ff 100644 --- a/problems/jump-game-iii/README.md +++ b/problems/jump-game-iii/README.md @@ -55,8 +55,9 @@ index 0 -> index 4 -> index 1 -> index 3
    ### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Breadth-first Search](../../tag/breadth-first-search/README.md)] - [[Graph](../../tag/graph/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Hints
    diff --git a/problems/letter-combinations-of-a-phone-number/README.md b/problems/letter-combinations-of-a-phone-number/README.md index f78ed4633..c8f86c688 100644 --- a/problems/letter-combinations-of-a-phone-number/README.md +++ b/problems/letter-combinations-of-a-phone-number/README.md @@ -48,6 +48,8 @@ ### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Recursion](../../tag/recursion/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/long-pressed-name/README.md b/problems/long-pressed-name/README.md index 41ab868d8..490632cb6 100644 --- a/problems/long-pressed-name/README.md +++ b/problems/long-pressed-name/README.md @@ -11,9 +11,9 @@ ## [925. Long Pressed Name (Easy)](https://leetcode.com/problems/long-pressed-name "长按键入") -

    Your friend is typing his name into a keyboard.  Sometimes, when typing a character c, the key might get long pressed, and the character will be typed 1 or more times.

    +

    Your friend is typing his name into a keyboard. Sometimes, when typing a character c, the key might get long pressed, and the character will be typed 1 or more times.

    -

    You examine the typed characters of the keyboard.  Return True if it is possible that it was your friends name, with some characters (possibly none) being long pressed.

    +

    You examine the typed characters of the keyboard. Return True if it is possible that it was your friends name, with some characters (possibly none) being long pressed.

     

    Example 1:

    @@ -53,7 +53,7 @@
    • 1 <= name.length <= 1000
    • 1 <= typed.length <= 1000
    • -
    • The characters of name and typed are lowercase letters.
    • +
    • name and typed contain only lowercase English letters.
    ### Related Topics diff --git a/problems/longest-duplicate-substring/README.md b/problems/longest-duplicate-substring/README.md index 40e889317..5be37fe61 100644 --- a/problems/longest-duplicate-substring/README.md +++ b/problems/longest-duplicate-substring/README.md @@ -11,34 +11,25 @@ ## [1044. Longest Duplicate Substring (Hard)](https://leetcode.com/problems/longest-duplicate-substring "最长重复子串") -

    Given a string S, consider all duplicated substrings: (contiguous) substrings of S that occur 2 or more times.  (The occurrences may overlap.)

    +

    Given a string s, consider all duplicated substrings: (contiguous) substrings of s that occur 2 or more times. The occurrences may overlap.

    -

    Return any duplicated substring that has the longest possible length.  (If S does not have a duplicated substring, the answer is "".)

    +

    Return any duplicated substring that has the longest possible length. If s does not have a duplicated substring, the answer is "".

     

    -

    Example 1:

    - -
    -Input: "banana"
    -Output: "ana"
    +
    Input: s = "banana"
    +Output: "ana"
    +

    Example 2:

    +
    Input: s = "abcd"
    +Output: ""
     
    - -

    Example 2:

    - -
    -Input: "abcd"
    -Output: ""
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 2 <= S.length <= 10^5
    2. -
    3. S consists of lowercase English letters.
    4. -
    +
      +
    • 2 <= s.length <= 3 * 104
    • +
    • s consists of lowercase English letters.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/longest-increasing-subsequence/README.md b/problems/longest-increasing-subsequence/README.md index 1f0fe7f8f..f19c9c7d6 100644 --- a/problems/longest-increasing-subsequence/README.md +++ b/problems/longest-increasing-subsequence/README.md @@ -11,23 +11,48 @@ ## [300. Longest Increasing Subsequence (Medium)](https://leetcode.com/problems/longest-increasing-subsequence "最长上升子序列") -

    Given an unsorted array of integers, find the length of longest increasing subsequence.

    +

    Given an integer array nums, return the length of the longest strictly increasing subsequence.

    -

    Example:

    +

    A subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements. For example, [3,6,2,7] is a subsequence of the array [0,3,1,6,2,2,7].

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [10,9,2,5,3,7,101,18]
    +Output: 4
    +Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4.
    +
    + +

    Example 2:

    + +
    +Input: nums = [0,1,0,3,2,3]
    +Output: 4
    +
    + +

    Example 3:

    -Input: [10,9,2,5,3,7,101,18]
    -Output: 4 
    -Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4. 
    +Input: nums = [7,7,7,7,7,7,7] +Output: 1 +
    -

    Note:

    +

     

    +

    Constraints:

      -
    • There may be more than one LIS combination, it is only necessary for you to return the length.
    • -
    • Your algorithm should run in O(n2) complexity.
    • +
    • 1 <= nums.length <= 2500
    • +
    • -104 <= nums[i] <= 104
    -

    Follow up: Could you improve it to O(n log n) time complexity?

    +

     

    +

    Follow up:

    + +
      +
    • Could you come up with the O(n2) solution?
    • +
    • Could you improve it to O(n log(n)) time complexity?
    • +
    ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/longest-mountain-in-array/README.md b/problems/longest-mountain-in-array/README.md index 11c50003d..a0b388aff 100644 --- a/problems/longest-mountain-in-array/README.md +++ b/problems/longest-mountain-in-array/README.md @@ -11,42 +11,46 @@ ## [845. Longest Mountain in Array (Medium)](https://leetcode.com/problems/longest-mountain-in-array "数组中的最长山脉") -

    Let's call any (contiguous) subarray B (of A) a mountain if the following properties hold:

    +

    You may recall that an array arr is a mountain array if and only if:

      -
    • B.length >= 3
    • -
    • There exists some 0 < i < B.length - 1 such that B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length - 1]
    • +
    • arr.length >= 3
    • +
    • There exists some index i (0-indexed) with 0 < i < arr.length - 1 such that: +
        +
      • arr[0] < arr[1] < ... < arr[i - 1] < arr[i]
      • +
      • arr[i] > arr[i + 1] > ... > arr[arr.length - 1]
      • +
      +
    -

    (Note that B could be any subarray of A, including the entire array A.)

    - -

    Given an array A of integers, return the length of the longest mountain

    - -

    Return 0 if there is no mountain.

    +

    Given an integer array arr, return the length of the longest subarray, which is a mountain. Return 0 if there is no mountain subarray.

    +

     

    Example 1:

    -Input: [2,1,4,7,3,2,5]
    -Output: 5
    -Explanation: The largest mountain is [1,4,7,3,2] which has length 5.
    +Input: arr = [2,1,4,7,3,2,5]
    +Output: 5
    +Explanation: The largest mountain is [1,4,7,3,2] which has length 5.
     

    Example 2:

    -Input: [2,2,2]
    -Output: 0
    -Explanation: There is no mountain.
    +Input: arr = [2,2,2]
    +Output: 0
    +Explanation: There is no mountain.
     
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. 0 <= A.length <= 10000
    2. -
    3. 0 <= A[i] <= 10000
    4. -
    +
      +
    • 1 <= arr.length <= 104
    • +
    • 0 <= arr[i] <= 104
    • +
    +

     

    Follow up:

      diff --git a/problems/longest-string-chain/README.md b/problems/longest-string-chain/README.md index 0a2b5f042..318cfa9b2 100644 --- a/problems/longest-string-chain/README.md +++ b/problems/longest-string-chain/README.md @@ -20,28 +20,29 @@

      Return the longest possible length of a word chain with words chosen from the given list of words.

       

      -

      Example 1:

      -Input: ["a","b","ba","bca","bda","bdca"]
      -Output: 4
      -Explanation: one of the longest word chain is "a","ba","bda","bdca".
      +Input: words = ["a","b","ba","bca","bda","bdca"]
      +Output: 4
      +Explanation: One of the longest word chain is "a","ba","bda","bdca".
       
      -

       

      +

      Example 2:

      + +
      +Input: words = ["xbc","pcxbcf","xb","cxbc","pcxbc"]
      +Output: 5
      +
      -

      Note:

      +

       

      +

      Constraints:

      -
        +
        • 1 <= words.length <= 1000
        • 1 <= words[i].length <= 16
        • words[i] only consists of English lowercase letters.
        • -
      - -
      -

       

      -
      +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/longest-substring-with-at-least-k-repeating-characters/README.md b/problems/longest-substring-with-at-least-k-repeating-characters/README.md index 0043cf6de..0889484c6 100644 --- a/problems/longest-substring-with-at-least-k-repeating-characters/README.md +++ b/problems/longest-substring-with-at-least-k-repeating-characters/README.md @@ -11,30 +11,35 @@ ## [395. Longest Substring with At Least K Repeating Characters (Medium)](https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters "至少有K个重复字符的最长子串") -

    -Find the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T appears no less than k times. -

    +

    Given a string s and an integer k, return the length of the longest substring of s such that the frequency of each character in this substring is greater than or equal to k.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input:
    -s = "aaabb", k = 3
    +Input: s = "aaabb", k = 3
    +Output: 3
    +Explanation: The longest substring is "aaa", as 'a' is repeated 3 times.
    +
    -Output: -3 +

    Example 2:

    -The longest substring is "aaa", as 'a' is repeated 3 times. +
    +Input: s = "ababbc", k = 2
    +Output: 5
    +Explanation: The longest substring is "ababb", as 'a' is repeated 2 times and 'b' is repeated 3 times.
     
    -

    -

    Example 2: -

    -Input:
    -s = "ababbc", k = 2
    +

     

    +

    Constraints:

    -Output: -5 +
      +
    • 1 <= s.length <= 104
    • +
    • s consists of only lowercase English letters.
    • +
    • 1 <= k <= 105
    • +
    -The longest substring is "ababb", as 'a' is repeated 2 times and 'b' is repeated 3 times. -
    -

    +### Related Topics + [[Recursion](../../tag/recursion/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md index 0221e0f0a..fbe2cad0c 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md @@ -9,7 +9,7 @@                  [Next >](../hopper-company-queries-iii "Hopper Company Queries III") -## [1650. Lowest Common Ancestor of a Binary Tree III (Medium)](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iii "") +## [1650. Lowest Common Ancestor of a Binary Tree III (Medium)](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iii "二叉树的最近公共祖先 III") diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md new file mode 100644 index 000000000..4959075d1 --- /dev/null +++ b/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md @@ -0,0 +1,34 @@ + + + + + + + +[< Previous](../minimize-deviation-in-array "Minimize Deviation in Array") +                 +[Next >](../products-worth-over-invoices "Product's Worth Over Invoices") + +## [1676. Lowest Common Ancestor of a Binary Tree IV (Medium)](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iv "") + + + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + +### Hints +
    +Hint 1 +Starting from the root, traverse the left and the right subtrees, checking if one of the nodes exist there. +
    + +
    +Hint 2 +If one of the subtrees doesn't contain any given node, the LCA can be the node returned from the other subtree +
    + +
    +Hint 3 +If both subtrees contain nodes, the LCA node is the current node. +
    diff --git a/problems/lru-cache/README.md b/problems/lru-cache/README.md index f655e4c09..89199a8cb 100644 --- a/problems/lru-cache/README.md +++ b/problems/lru-cache/README.md @@ -9,7 +9,7 @@                  [Next >](../insertion-sort-list "Insertion Sort List") -## [146. LRU Cache (Medium)](https://leetcode.com/problems/lru-cache "LRU缓存机制") +## [146. LRU Cache (Medium)](https://leetcode.com/problems/lru-cache "LRU 缓存机制")

    Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.

    diff --git a/problems/max-number-of-k-sum-pairs/README.md b/problems/max-number-of-k-sum-pairs/README.md new file mode 100644 index 000000000..e798423d7 --- /dev/null +++ b/problems/max-number-of-k-sum-pairs/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../goal-parser-interpretation "Goal Parser Interpretation") +                 +[Next >](../concatenation-of-consecutive-binary-numbers "Concatenation of Consecutive Binary Numbers") + +## [1679. Max Number of K-Sum Pairs (Medium)](https://leetcode.com/problems/max-number-of-k-sum-pairs "K 和数对的最大数目") + +

    You are given an integer array nums and an integer k.

    + +

    In one operation, you can pick two numbers from the array whose sum equals k and remove them from the array.

    + +

    Return the maximum number of operations you can perform on the array.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3,4], k = 5
    +Output: 2
    +Explanation: Starting with nums = [1,2,3,4]:
    +- Remove numbers 1 and 4, then nums = [2,3]
    +- Remove numbers 2 and 3, then nums = []
    +There are no more pairs that sum up to 5, hence a total of 2 operations.
    + +

    Example 2:

    + +
    +Input: nums = [3,1,3,4,3], k = 6
    +Output: 1
    +Explanation: Starting with nums = [3,1,3,4,3]:
    +- Remove the first two 3's, then nums = [1,4,3]
    +There are no more pairs that sum up to 6, hence a total of 1 operation.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 109
    • +
    • 1 <= k <= 109
    • +
    + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +The abstract problem asks to count the number of disjoint pairs with a given sum k. +
    + +
    +Hint 2 +For each possible value x, it can be paired up with k - x. +
    + +
    +Hint 3 +The number of such pairs equals to min(count(x), count(k-x)), unless that x = k / 2, where the number of such pairs will be floor(count(x) / 2). +
    diff --git a/problems/maximal-square/README.md b/problems/maximal-square/README.md index 07e1c6484..de050fead 100644 --- a/problems/maximal-square/README.md +++ b/problems/maximal-square/README.md @@ -11,21 +11,40 @@ ## [221. Maximal Square (Medium)](https://leetcode.com/problems/maximal-square "最大正方形") -

    Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.

    +

    Given an m x n binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.

    -

    Example:

    +

     

    +

    Example 1:

    + +
    +Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]
    +Output: 4
    +
    + +

    Example 2:

    + +
    +Input: matrix = [["0","1"],["1","0"]]
    +Output: 1
    +
    + +

    Example 3:

    -Input: 
    -
    -1 0 1 0 0
    -1 0 1 1 1
    -1 1 1 1 1
    -1 0 0 1 0
    -
    -Output: 4
    +Input: matrix = [["0"]]
    +Output: 0
     
    +

     

    +

    Constraints:

    + +
      +
    • m == matrix.length
    • +
    • n == matrix[i].length
    • +
    • 1 <= m, n <= 300
    • +
    • matrix[i][j] is '0' or '1'.
    • +
    + ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/maximize-grid-happiness/README.md b/problems/maximize-grid-happiness/README.md index f4ac6f46b..fe10923f6 100644 --- a/problems/maximize-grid-happiness/README.md +++ b/problems/maximize-grid-happiness/README.md @@ -7,7 +7,7 @@ [< Previous](../minimum-operations-to-reduce-x-to-zero "Minimum Operations to Reduce X to Zero")                  -Next > +[Next >](../correct-a-binary-tree "Correct a Binary Tree") ## [1659. Maximize Grid Happiness (Hard)](https://leetcode.com/problems/maximize-grid-happiness "最大化网格幸福感") diff --git a/problems/maximum-depth-of-binary-tree/README.md b/problems/maximum-depth-of-binary-tree/README.md index 8b17749cf..727699e57 100644 --- a/problems/maximum-depth-of-binary-tree/README.md +++ b/problems/maximum-depth-of-binary-tree/README.md @@ -11,28 +11,51 @@ ## [104. Maximum Depth of Binary Tree (Easy)](https://leetcode.com/problems/maximum-depth-of-binary-tree "二叉树的最大深度") -

    Given a binary tree, find its maximum depth.

    +

    Given the root of a binary tree, return its maximum depth.

    -

    The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

    +

    A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

    -

    Note: A leaf is a node with no children.

    +

     

    +

    Example 1:

    + +
    +Input: root = [3,9,20,null,null,15,7]
    +Output: 3
    +
    + +

    Example 2:

    -

    Example:

    +
    +Input: root = [1,null,2]
    +Output: 2
    +
    -

    Given binary tree [3,9,20,null,null,15,7],

    +

    Example 3:

    -    3
    -   / \
    -  9  20
    -    /  \
    -   15   7
    +Input: root = [] +Output: 0 + + +

    Example 4:

    + +
    +Input: root = [0]
    +Output: 1
    +
    + +

     

    +

    Constraints:

    -

    return its depth = 3.

    +
      +
    • The number of nodes in the tree is in the range [0, 104].
    • +
    • -100 <= Node.val <= 100
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions 1. [Balanced Binary Tree](../balanced-binary-tree) (Easy) diff --git a/problems/maximum-depth-of-n-ary-tree/README.md b/problems/maximum-depth-of-n-ary-tree/README.md index 676d323a5..921bb5083 100644 --- a/problems/maximum-depth-of-n-ary-tree/README.md +++ b/problems/maximum-depth-of-n-ary-tree/README.md @@ -9,7 +9,7 @@                  [Next >](../subarray-sum-equals-k "Subarray Sum Equals K") -## [559. Maximum Depth of N-ary Tree (Easy)](https://leetcode.com/problems/maximum-depth-of-n-ary-tree "N叉树的最大深度") +## [559. Maximum Depth of N-ary Tree (Easy)](https://leetcode.com/problems/maximum-depth-of-n-ary-tree "N 叉树的最大深度")

    Given a n-ary tree, find its maximum depth.

    @@ -41,7 +41,7 @@
    • The depth of the n-ary tree is less than or equal to 1000.
    • -
    • The total number of nodes is between [0, 10^4].
    • +
    • The total number of nodes is between [0, 104].
    ### Related Topics diff --git a/problems/maximum-repeating-substring/README.md b/problems/maximum-repeating-substring/README.md new file mode 100644 index 000000000..e9924de65 --- /dev/null +++ b/problems/maximum-repeating-substring/README.md @@ -0,0 +1,64 @@ + + + + + + + +[< Previous](../fix-names-in-a-table "Fix Names in a Table") +                 +[Next >](../merge-in-between-linked-lists "Merge In Between Linked Lists") + +## [1668. Maximum Repeating Substring (Easy)](https://leetcode.com/problems/maximum-repeating-substring "最大重复子字符串") + +

    For a string sequence, a string word is k-repeating if word concatenated k times is a substring of sequence. The word's maximum k-repeating value is the highest value k where word is k-repeating in sequence. If word is not a substring of sequence, word's maximum k-repeating value is 0.

    + +

    Given strings sequence and word, return the maximum k-repeating value of word in sequence.

    + +

     

    +

    Example 1:

    + +
    +Input: sequence = "ababc", word = "ab"
    +Output: 2
    +Explanation: "abab" is a substring in "ababc".
    +
    + +

    Example 2:

    + +
    +Input: sequence = "ababc", word = "ba"
    +Output: 1
    +Explanation: "ba" is a substring in "ababc". "baba" is not a substring in "ababc".
    +
    + +

    Example 3:

    + +
    +Input: sequence = "ababc", word = "ac"
    +Output: 0
    +Explanation: "ac" is not a substring in "ababc". 
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= sequence.length <= 100
    • +
    • 1 <= word.length <= 100
    • +
    • sequence and word contains only lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +The constraints are low enough for a brute force approach. +
    + +
    +Hint 2 +Try every k value from 0 upwards until word is no longer k-repeating. +
    diff --git a/problems/maximum-subarray-sum-with-one-deletion/README.md b/problems/maximum-subarray-sum-with-one-deletion/README.md index 86a0b4bc9..417f93f04 100644 --- a/problems/maximum-subarray-sum-with-one-deletion/README.md +++ b/problems/maximum-subarray-sum-with-one-deletion/README.md @@ -43,8 +43,8 @@

    Constraints:

      -
    • 1 <= arr.length <= 10^5
    • -
    • -10^4 <= arr[i] <= 10^4
    • +
    • 1 <= arr.length <= 105
    • +
    • -104 <= arr[i] <= 104
    ### Related Topics diff --git a/problems/merge-in-between-linked-lists/README.md b/problems/merge-in-between-linked-lists/README.md new file mode 100644 index 000000000..35e8f41ff --- /dev/null +++ b/problems/merge-in-between-linked-lists/README.md @@ -0,0 +1,65 @@ + + + + + + + +[< Previous](../maximum-repeating-substring "Maximum Repeating Substring") +                 +[Next >](../design-front-middle-back-queue "Design Front Middle Back Queue") + +## [1669. Merge In Between Linked Lists (Medium)](https://leetcode.com/problems/merge-in-between-linked-lists "合并两个链表") + +

    You are given two linked lists: list1 and list2 of sizes n and m respectively.

    + +

    Remove list1's nodes from the ath node to the bth node, and put list2 in their place.

    + +

    The blue edges and nodes in the following figure incidate the result:

    + +

    Build the result list and return its head.

    + +

     

    +

    Example 1:

    + +
    +Input: list1 = [0,1,2,3,4,5], a = 3, b = 4, list2 = [1000000,1000001,1000002]
    +Output: [0,1,2,1000000,1000001,1000002,5]
    +Explanation: We remove the nodes 3 and 4 and put the entire list2 in their place. The blue edges and nodes in the above figure indicate the result.
    +
    + +

    Example 2:

    + +
    +Input: list1 = [0,1,2,3,4,5,6], a = 2, b = 5, list2 = [1000000,1000001,1000002,1000003,1000004]
    +Output: [0,1,1000000,1000001,1000002,1000003,1000004,6]
    +Explanation: The blue edges and nodes in the above figure indicate the result.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= list1.length <= 104
    • +
    • 1 <= a <= b < list1.length - 1
    • +
    • 1 <= list2.length <= 104
    • +
    + +### Related Topics + [[Linked List](../../tag/linked-list/README.md)] + +### Hints +
    +Hint 1 +Check which edges need to be changed. +
    + +
    +Hint 2 +Let the next node of the (a-1)th node of list1 be the 0-th node in list 2. +
    + +
    +Hint 3 +Let the next node of the last node of list2 be the (b+1)-th node in list 1. +
    diff --git a/problems/minimize-deviation-in-array/README.md b/problems/minimize-deviation-in-array/README.md new file mode 100644 index 000000000..92c4cd234 --- /dev/null +++ b/problems/minimize-deviation-in-array/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../minimum-moves-to-make-array-complementary "Minimum Moves to Make Array Complementary") +                 +[Next >](../lowest-common-ancestor-of-a-binary-tree-iv "Lowest Common Ancestor of a Binary Tree IV") + +## [1675. Minimize Deviation in Array (Hard)](https://leetcode.com/problems/minimize-deviation-in-array "数组的最小偏移量") + +

    You are given an array nums of n positive integers.

    + +

    You can perform two types of operations on any element of the array any number of times:

    + +
      +
    • If the element is even, divide it by 2. +
        +
      • For example, if the array is [1,2,3,4], then you can do this operation on the last element, and the array will be [1,2,3,2].
      • +
      +
    • +
    • If the element is odd, multiply it by 2. +
        +
      • For example, if the array is [1,2,3,4], then you can do this operation on the first element, and the array will be [2,2,3,4].
      • +
      +
    • +
    + +

    The deviation of the array is the maximum difference between any two elements in the array.

    + +

    Return the minimum deviation the array can have after performing some number of operations.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3,4]
    +Output: 1
    +Explanation: You can transform the array to [1,2,3,2], then to [2,2,3,2], then the deviation will be 3 - 2 = 1.
    +
    + +

    Example 2:

    + +
    +Input: nums = [4,1,5,20,3]
    +Output: 3
    +Explanation: You can transform the array after two operations to [4,2,5,5,3], then the deviation will be 5 - 2 = 3.
    +
    + +

    Example 3:

    + +
    +Input: nums = [2,10,8]
    +Output: 3
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 2 <= n <= 105
    • +
    • 1 <= nums[i] <= 109
    • +
    + +### Related Topics + [[Heap](../../tag/heap/README.md)] + [[Ordered Map](../../tag/ordered-map/README.md)] + +### Hints +
    +Hint 1 +Assume you start with the minimum possible value for each number so you can only multiply a number by 2 till it reaches its maximum possible value. +
    + +
    +Hint 2 +If there is a better solution than the current one, then it must have either its maximum value less than the current maximum value, or the minimum value larger than the current minimum value. +
    + +
    +Hint 3 +Since that we only increase numbers (multiply them by 2), we cannot decrease the current maximum value, so we must multiply the current minimum number by 2. +
    diff --git a/problems/minimum-incompatibility/README.md b/problems/minimum-incompatibility/README.md new file mode 100644 index 000000000..723fe1e6c --- /dev/null +++ b/problems/minimum-incompatibility/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../concatenation-of-consecutive-binary-numbers "Concatenation of Consecutive Binary Numbers") +                 +Next > + +## [1681. Minimum Incompatibility (Hard)](https://leetcode.com/problems/minimum-incompatibility "最小不兼容性") + +

    You are given an integer array nums​​​ and an integer k. You are asked to distribute this array into k subsets of equal size such that there are no two equal elements in the same subset.

    + +

    A subset's incompatibility is the difference between the maximum and minimum elements in that array.

    + +

    Return the minimum possible sum of incompatibilities of the k subsets after distributing the array optimally, or return -1 if it is not possible.

    + +

    A subset is a group integers that appear in the array with no particular order.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,1,4], k = 2
    +Output: 4
    +Explanation: The optimal distribution of subsets is [1,2] and [1,4].
    +The incompatibility is (2-1) + (4-1) = 4.
    +Note that [1,1] and [2,4] would result in a smaller sum, but the first subset contains 2 equal elements.
    + +

    Example 2:

    + +
    +Input: nums = [6,3,8,1,3,1,2,2], k = 4
    +Output: 6
    +Explanation: The optimal distribution of subsets is [1,2], [2,3], [6,8], and [1,3].
    +The incompatibility is (2-1) + (3-2) + (8-6) + (3-1) = 6.
    +
    + +

    Example 3:

    + +
    +Input: nums = [5,3,3,6,3,3], k = 3
    +Output: -1
    +Explanation: It is impossible to distribute nums into 3 subsets where no two elements are equal in the same subset.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= nums.length <= 16
    • +
    • nums.length is divisible by k
    • +
    • 1 <= nums[i] <= nums.length
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
    +Hint 1 +The constraints are small enough for a backtrack solution but not any backtrack solution +
    + +
    +Hint 2 +If we use a naive n^k don't you think it can be optimized +
    diff --git a/problems/minimum-initial-energy-to-finish-tasks/README.md b/problems/minimum-initial-energy-to-finish-tasks/README.md new file mode 100644 index 000000000..7c836fbe7 --- /dev/null +++ b/problems/minimum-initial-energy-to-finish-tasks/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../ways-to-make-a-fair-array "Ways to Make a Fair Array") +                 +[Next >](../change-the-root-of-a-binary-tree "Change the Root of a Binary Tree") + +## [1665. Minimum Initial Energy to Finish Tasks (Hard)](https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks "完成所有任务的最少初始能量") + +

    You are given an array tasks where tasks[i] = [actuali, minimumi]:

    + +
      +
    • actuali is the actual amount of energy you spend to finish the ith task.
    • +
    • minimumi is the minimum amount of energy you require to begin the ith task.
    • +
    + +

    For example, if the task is [10, 12] and your current energy is 11, you cannot start this task. However, if your current energy is 13, you can complete this task, and your energy will be 3 after finishing it.

    + +

    You can finish the tasks in any order you like.

    + +

    Return the minimum initial amount of energy you will need to finish all the tasks.

    + +

     

    +

    Example 1:

    + +
    +Input: tasks = [[1,2],[2,4],[4,8]]
    +Output: 8
    +Explanation:
    +Starting with 8 energy, we finish the tasks in the following order:
    +    - 3rd task. Now energy = 8 - 4 = 4.
    +    - 2nd task. Now energy = 4 - 2 = 2.
    +    - 1st task. Now energy = 2 - 1 = 1.
    +Notice that even though we have leftover energy, starting with 7 energy does not work because we cannot do the 3rd task.
    + +

    Example 2:

    + +
    +Input: tasks = [[1,3],[2,4],[10,11],[10,12],[8,9]]
    +Output: 32
    +Explanation:
    +Starting with 32 energy, we finish the tasks in the following order:
    +    - 1st task. Now energy = 32 - 1 = 31.
    +    - 2nd task. Now energy = 31 - 2 = 29.
    +    - 3rd task. Now energy = 29 - 10 = 19.
    +    - 4th task. Now energy = 19 - 10 = 9.
    +    - 5th task. Now energy = 9 - 8 = 1.
    + +

    Example 3:

    + +
    +Input: tasks = [[1,7],[2,8],[3,9],[4,10],[5,11],[6,12]]
    +Output: 27
    +Explanation:
    +Starting with 27 energy, we finish the tasks in the following order:
    +    - 5th task. Now energy = 27 - 5 = 22.
    +    - 2nd task. Now energy = 22 - 2 = 20.
    +    - 3rd task. Now energy = 20 - 3 = 17.
    +    - 1st task. Now energy = 17 - 1 = 16.
    +    - 4th task. Now energy = 16 - 4 = 12.
    +    - 6th task. Now energy = 12 - 6 = 6.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= tasks.length <= 105
    • +
    • 1 <= actual​i <= minimumi <= 104
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +We can easily figure that the f(x) : does x solve this array is monotonic so binary Search is doable +
    + +
    +Hint 2 +Figure a sorting pattern +
    diff --git a/problems/minimum-moves-to-make-array-complementary/README.md b/problems/minimum-moves-to-make-array-complementary/README.md new file mode 100644 index 000000000..64677afeb --- /dev/null +++ b/problems/minimum-moves-to-make-array-complementary/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../find-the-most-competitive-subsequence "Find the Most Competitive Subsequence") +                 +[Next >](../minimize-deviation-in-array "Minimize Deviation in Array") + +## [1674. Minimum Moves to Make Array Complementary (Medium)](https://leetcode.com/problems/minimum-moves-to-make-array-complementary "使数组互补的最少操作次数") + +

    You are given an integer array nums of even length n and an integer limit. In one move, you can replace any integer from nums with another integer between 1 and limit, inclusive.

    + +

    The array nums is complementary if for all indices i (0-indexed), nums[i] + nums[n - 1 - i] equals the same number. For example, the array [1,2,3,4] is complementary because for all indices i, nums[i] + nums[n - 1 - i] = 5.

    + +

    Return the minimum number of moves required to make nums complementary.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,4,3], limit = 4
    +Output: 1
    +Explanation: In 1 move, you can change nums to [1,2,2,3] (underlined elements are changed).
    +nums[0] + nums[3] = 1 + 3 = 4.
    +nums[1] + nums[2] = 2 + 2 = 4.
    +nums[2] + nums[1] = 2 + 2 = 4.
    +nums[3] + nums[0] = 3 + 1 = 4.
    +Therefore, nums[i] + nums[n-1-i] = 4 for every i, so nums is complementary.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,2,2,1], limit = 2
    +Output: 2
    +Explanation: In 2 moves, you can change nums to [2,2,2,2]. You cannot change any number to 3 since 3 > limit.
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,2,1,2], limit = 2
    +Output: 0
    +Explanation: nums is already complementary.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 2 <= n <= 105
    • +
    • 1 <= nums[i] <= limit <= 105
    • +
    • n is even.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Given a target sum x, each pair of nums[i] and nums[n-1-i] would either need 0, 1, or 2 modifications. +
    + +
    +Hint 2 +Can you find the optimal target sum x value such that the sum of modifications is minimized? +
    + +
    +Hint 3 +Create a difference array to efficiently sum all the modifications. +
    diff --git a/problems/minimum-number-of-removals-to-make-mountain-array/README.md b/problems/minimum-number-of-removals-to-make-mountain-array/README.md new file mode 100644 index 000000000..3c0470c55 --- /dev/null +++ b/problems/minimum-number-of-removals-to-make-mountain-array/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../design-front-middle-back-queue "Design Front Middle Back Queue") +                 +[Next >](../richest-customer-wealth "Richest Customer Wealth") + +## [1671. Minimum Number of Removals to Make Mountain Array (Hard)](https://leetcode.com/problems/minimum-number-of-removals-to-make-mountain-array "得到山形数组的最少删除次数") + +

    You may recall that an array arr is a mountain array if and only if:

    + +
      +
    • arr.length >= 3
    • +
    • There exists some index i (0-indexed) with 0 < i < arr.length - 1 such that: +
        +
      • arr[0] < arr[1] < ... < arr[i - 1] < arr[i]
      • +
      • arr[i] > arr[i + 1] > ... > arr[arr.length - 1]
      • +
      +
    • +
    + +

    Given an integer array nums​​​, return the minimum number of elements to remove to make nums​​​ a mountain array.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,3,1]
    +Output: 0
    +Explanation: The array itself is a mountain array so we do not need to remove any elements.
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,1,1,5,6,2,3,1]
    +Output: 3
    +Explanation: One solution is to remove the elements at indices 0, 1, and 5, making the array nums = [1,5,6,3,1].
    +
    + +

    Example 3:

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

    Example 4:

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

     

    +

    Constraints:

    + +
      +
    • 3 <= nums.length <= 1000
    • +
    • 1 <= nums[i] <= 109
    • +
    • It is guaranteed that you can make a mountain array out of nums.
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Think the opposite direction instead of minimum elements to remove the maximum mountain subsequence +
    + +
    +Hint 2 +Think of LIS it's kind of close +
    diff --git a/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md b/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md index 0a303646b..7c687c37a 100644 --- a/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md +++ b/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md @@ -11,9 +11,9 @@ ## [1443. Minimum Time to Collect All Apples in a Tree (Medium)](https://leetcode.com/problems/minimum-time-to-collect-all-apples-in-a-tree "收集树上所有苹果的最少时间") -

    Given an undirected tree consisting of n vertices numbered from 0 to n-1, which has some apples in their vertices. You spend 1 second to walk over one edge of the tree. Return the minimum time in seconds you have to spend in order to collect all apples in the tree starting at vertex 0 and coming back to this vertex.

    +

    Given an undirected tree consisting of n vertices numbered from 0 to n-1, which has some apples in their vertices. You spend 1 second to walk over one edge of the tree. Return the minimum time in seconds you have to spend to collect all apples in the tree, starting at vertex 0 and coming back to this vertex.

    -

    The edges of the undirected tree are given in the array edges, where edges[i] = [fromi, toi] means that exists an edge connecting the vertices fromi and toi. Additionally, there is a boolean array hasApple, where hasApple[i] = true means that vertex i has an apple, otherwise, it does not have any apple.

    +

    The edges of the undirected tree are given in the array edges, where edges[i] = [ai, bi] means that exists an edge connecting the vertices ai and bi. Additionally, there is a boolean array hasApple, where hasApple[i] = true means that vertex i has an apple; otherwise, it does not have any apple.

     

    Example 1:

    @@ -48,9 +48,9 @@
    • 1 <= n <= 10^5
    • -
    • edges.length == n-1
    • +
    • edges.length == n - 1
    • edges[i].length == 2
    • -
    • 0 <= fromi, toi <= n-1
    • +
    • 0 <= ai < bi <= n - 1
    • fromi < toi
    • hasApple.length == n
    diff --git a/problems/n-ary-tree-level-order-traversal/README.md b/problems/n-ary-tree-level-order-traversal/README.md index 97c8fc45d..3a518f52e 100644 --- a/problems/n-ary-tree-level-order-traversal/README.md +++ b/problems/n-ary-tree-level-order-traversal/README.md @@ -9,7 +9,7 @@                  [Next >](../flatten-a-multilevel-doubly-linked-list "Flatten a Multilevel Doubly Linked List") -## [429. N-ary Tree Level Order Traversal (Medium)](https://leetcode.com/problems/n-ary-tree-level-order-traversal "N叉树的层序遍历") +## [429. N-ary Tree Level Order Traversal (Medium)](https://leetcode.com/problems/n-ary-tree-level-order-traversal "N 叉树的层序遍历")

    Given an n-ary tree, return the level order traversal of its nodes' values.

    @@ -39,7 +39,7 @@
    • The height of the n-ary tree is less than or equal to 1000
    • -
    • The total number of nodes is between [0, 10^4]
    • +
    • The total number of nodes is between [0, 104]
    ### Related Topics diff --git a/problems/next-greater-element-iii/README.md b/problems/next-greater-element-iii/README.md index a3728a178..ca7c28805 100644 --- a/problems/next-greater-element-iii/README.md +++ b/problems/next-greater-element-iii/README.md @@ -11,25 +11,24 @@ ## [556. Next Greater Element III (Medium)](https://leetcode.com/problems/next-greater-element-iii "下一个更大元素 III") -

    Given a positive 32-bit integer n, you need to find the smallest 32-bit integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive 32-bit integer exists, you need to return -1.

    +

    Given a positive integer n, find the smallest integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive integer exists, return -1.

    -

    Example 1:

    - -
    -Input: 12
    -Output: 21
    -
    +

    Note that the returned integer should fit in 32-bit integer, if there is a valid answer but it does not fit in 32-bit integer, return -1.

     

    - -

    Example 2:

    - -
    -Input: 21
    +

    Example 1:

    +
    Input: n = 12
    +Output: 21
    +

    Example 2:

    +
    Input: n = 21
     Output: -1
     
    -

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 231 - 1
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md b/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md index 04b4533ab..930c50e72 100644 --- a/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md +++ b/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md @@ -13,9 +13,7 @@

    Given an array of integers nums and an integer target.

    -

    Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal than target.

    - -

    Since the answer may be too large, return it modulo 10^9 + 7.

    +

    Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too large, return it modulo 109 + 7.

     

    Example 1:

    @@ -58,9 +56,9 @@ Number of valid subsequences (63 - 2 = 61).

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • 1 <= nums[i] <= 10^6
    • -
    • 1 <= target <= 10^6
    • +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 106
    • +
    • 1 <= target <= 106
    ### Related Topics diff --git a/problems/numbers-at-most-n-given-digit-set/README.md b/problems/numbers-at-most-n-given-digit-set/README.md index 4bef084e9..4dc7a830c 100644 --- a/problems/numbers-at-most-n-given-digit-set/README.md +++ b/problems/numbers-at-most-n-given-digit-set/README.md @@ -11,9 +11,9 @@ ## [902. Numbers At Most N Given Digit Set (Hard)](https://leetcode.com/problems/numbers-at-most-n-given-digit-set "最大为 N 的数字组合") -

    Given an array of digits, you can write numbers using each digits[i] as many times as we want.  For example, if digits = ['1','3','5'], we may write numbers such as '13', '551', and '1351315'.

    +

    Given an array of digits which is sorted in non-decreasing order. You can write numbers using each digits[i] as many times as we want. For example, if digits = ['1','3','5'], we may write numbers such as '13', '551', and '1351315'.

    -

    Return the number of positive integers that can be generated that are less than or equal to a given integer n.

    +

    Return the number of positive integers that can be generated that are less than or equal to a given integer n.

     

    Example 1:

    @@ -53,6 +53,7 @@ In total, this is 29523 integers that can be written using the digits array.
  • digits[i].length == 1
  • digits[i] is a digit from '1' to '9'.
  • All the values in digits are unique.
  • +
  • digits is sorted in non-decreasing order.
  • 1 <= n <= 109
  • diff --git a/problems/pairs-of-songs-with-total-durations-divisible-by-60/README.md b/problems/pairs-of-songs-with-total-durations-divisible-by-60/README.md index 9a03fc86c..3a9795fa6 100644 --- a/problems/pairs-of-songs-with-total-durations-divisible-by-60/README.md +++ b/problems/pairs-of-songs-with-total-durations-divisible-by-60/README.md @@ -9,41 +9,37 @@                  [Next >](../capacity-to-ship-packages-within-d-days "Capacity To Ship Packages Within D Days") -## [1010. Pairs of Songs With Total Durations Divisible by 60 (Easy)](https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60 "总持续时间可被 60 整除的歌曲") +## [1010. Pairs of Songs With Total Durations Divisible by 60 (Medium)](https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60 "总持续时间可被 60 整除的歌曲") -

    In a list of songs, the i-th song has a duration of time[i] seconds. 

    +

    You are given a list of songs where the ith song has a duration of time[i] seconds.

    -

    Return the number of pairs of songs for which their total duration in seconds is divisible by 60.  Formally, we want the number of indices i, j such that i < j with (time[i] + time[j]) % 60 == 0.

    +

    Return the number of pairs of songs for which their total duration in seconds is divisible by 60. Formally, we want the number of indices i, j such that i < j with (time[i] + time[j]) % 60 == 0.

     

    -

    Example 1:

    -Input: [30,20,150,100,40]
    -Output: 3
    -Explanation: Three pairs have a total duration divisible by 60:
    +Input: time = [30,20,150,100,40]
    +Output: 3
    +Explanation: Three pairs have a total duration divisible by 60:
     (time[0] = 30, time[2] = 150): total duration 180
     (time[1] = 20, time[3] = 100): total duration 120
     (time[1] = 20, time[4] = 40): total duration 60
     
    -

    Example 2:

    -Input: [60,60,60]
    -Output: 3
    -Explanation: All three pairs have a total duration of 120, which is divisible by 60.
    +Input: time = [60,60,60]
    +Output: 3
    +Explanation: All three pairs have a total duration of 120, which is divisible by 60.
     
    -

     

    - -

    Note:

    +

    Constraints:

      -
    • 1 <= time.length <= 60000
    • +
    • 1 <= time.length <= 6 * 104
    • 1 <= time[i] <= 500
    diff --git a/problems/pascals-triangle-ii/README.md b/problems/pascals-triangle-ii/README.md index 2f96604de..eb483e16c 100644 --- a/problems/pascals-triangle-ii/README.md +++ b/problems/pascals-triangle-ii/README.md @@ -37,7 +37,7 @@

    Constraints:

      -
    • 0 <= rowIndex <= 40
    • +
    • 0 <= rowIndex <= 33
    ### Related Topics diff --git a/problems/poor-pigs/README.md b/problems/poor-pigs/README.md index fd4ed9099..ec051e9d2 100644 --- a/problems/poor-pigs/README.md +++ b/problems/poor-pigs/README.md @@ -11,25 +11,38 @@ ## [458. Poor Pigs (Hard)](https://leetcode.com/problems/poor-pigs "可怜的小猪") -

    There are 1000 buckets, one and only one of them is poisonous, while the rest are filled with water. They all look identical. If a pig drinks the poison it will die within 15 minutes. What is the minimum amount of pigs you need to figure out which bucket is poisonous within one hour?

    +

    There are buckets buckets of liquid, where exactly one of the buckets is poisonous. To figure out which one is poisonous, you feed some number of (poor) pigs the liquid to see whether they will die or not. Unfortunately, you only have minutesToTest minutes to determine which bucket is poisonous.

    -

    Answer this question, and write an algorithm for the general case.

    +

    You can feed the pigs according to these steps:

    -

     

    - -

    General case:

    +
      +
    1. Choose some live pigs to feed.
    2. +
    3. For each pig, choose which buckets to feed it. The pig will consume all the chosen buckets simultaneously and will take no time.
    4. +
    5. Wait for minutesToDie minutes. You may not feed any other pigs during this time.
    6. +
    7. After minutesToDie minutes have passed, any pigs that have been fed the poisonous bucket will die, and all others will survive.
    8. +
    9. Repeat this process until you run out of time.
    10. +
    -

    If there are n buckets and a pig drinking poison will die within m minutes, how many pigs (x) you need to figure out the poisonous bucket within p minutes? There is exactly one bucket with poison.

    +

    Given buckets, minutesToDie, and minutesToTest, return the minimum number of pigs needed to figure out which bucket is poisonous within the allotted time.

     

    +

    Example 1:

    +
    Input: buckets = 1000, minutesToDie = 15, minutesToTest = 60
    +Output: 5
    +

    Example 2:

    +
    Input: buckets = 4, minutesToDie = 15, minutesToTest = 15
    +Output: 2
    +

    Example 3:

    +
    Input: buckets = 4, minutesToDie = 15, minutesToTest = 30
    +Output: 2
    +
    +

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. A pig can be allowed to drink simultaneously on as many buckets as one would like, and the feeding takes no time.
    2. -
    3. After a pig has instantly finished drinking buckets, there has to be a cool down time of minutes. During this time, only observation is allowed and no feedings at all.
    4. -
    5. Any given bucket can be sampled an infinite number of times (by an unlimited number of pigs).
    6. -
    +
      +
    • 1 <= buckets <= 1000
    • +
    • 1 <= minutesToDie <= minutesToTest <= 100
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/products-worth-over-invoices/README.md b/problems/products-worth-over-invoices/README.md new file mode 100644 index 000000000..2b8857123 --- /dev/null +++ b/problems/products-worth-over-invoices/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../lowest-common-ancestor-of-a-binary-tree-iv "Lowest Common Ancestor of a Binary Tree IV") +                 +[Next >](../goal-parser-interpretation "Goal Parser Interpretation") + +## [1677. Product's Worth Over Invoices (Easy)](https://leetcode.com/problems/products-worth-over-invoices "") + + diff --git a/problems/products-worth-over-invoices/mysql_schemas.sql b/problems/products-worth-over-invoices/mysql_schemas.sql new file mode 100644 index 000000000..42dfdb2b8 --- /dev/null +++ b/problems/products-worth-over-invoices/mysql_schemas.sql @@ -0,0 +1,12 @@ +Create table If Not Exists Product(product_id int, name varchar(15)); +Create table If Not Exists Invoice(invoice_id int,product_id int,rest int, paid int, canceled int, refunded int); +Truncate table Product; +insert into Product (product_id, name) values ('0', 'ham'); +insert into Product (product_id, name) values ('1', 'bacon'); +Truncate table Invoice; +insert into Invoice (invoice_id, product_id, rest, paid, canceled, refunded) values ('23', '0', '2', '0', '5', '0'); +insert into Invoice (invoice_id, product_id, rest, paid, canceled, refunded) values ('12', '0', '0', '4', '0', '3'); +insert into Invoice (invoice_id, product_id, rest, paid, canceled, refunded) values ('1', '1', '1', '1', '0', '1'); +insert into Invoice (invoice_id, product_id, rest, paid, canceled, refunded) values ('2', '1', '1', '0', '1', '1'); +insert into Invoice (invoice_id, product_id, rest, paid, canceled, refunded) values ('3', '1', '0', '1', '1', '1'); +insert into Invoice (invoice_id, product_id, rest, paid, canceled, refunded) values ('4', '1', '1', '1', '1', '0'); diff --git a/problems/put-boxes-into-the-warehouse-ii/README.md b/problems/put-boxes-into-the-warehouse-ii/README.md index dc52e60d9..f0226fc91 100644 --- a/problems/put-boxes-into-the-warehouse-ii/README.md +++ b/problems/put-boxes-into-the-warehouse-ii/README.md @@ -9,7 +9,7 @@                  [Next >](../customer-who-visited-but-did-not-make-any-transactions "Customer Who Visited but Did Not Make Any Transactions") -## [1580. Put Boxes Into the Warehouse II (Medium)](https://leetcode.com/problems/put-boxes-into-the-warehouse-ii "") +## [1580. Put Boxes Into the Warehouse II (Medium)](https://leetcode.com/problems/put-boxes-into-the-warehouse-ii "把箱子放进仓库里 II") diff --git a/problems/queue-reconstruction-by-height/README.md b/problems/queue-reconstruction-by-height/README.md index 01a24bfa6..44686b402 100644 --- a/problems/queue-reconstruction-by-height/README.md +++ b/problems/queue-reconstruction-by-height/README.md @@ -11,23 +11,42 @@ ## [406. Queue Reconstruction by Height (Medium)](https://leetcode.com/problems/queue-reconstruction-by-height "根据身高重建队列") -

    Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in front of this person who have a height greater than or equal to h. Write an algorithm to reconstruct the queue.

    +

    You are given an array of people, people, which are the attributes of some people in a queue (not necessarily in order). Each people[i] = [hi, ki] represents the ith person of height hi with exactly ki other people in front who have a height greater than or equal to hi.

    -

    Note:
    -The number of people is less than 1,100.

    -  +

    Reconstruct and return the queue that is represented by the input array people. The returned queue should be formatted as an array queue, where queue[j] = [hj, kj] is the attributes of the jth person in the queue (queue[0] is the person at the front of the queue).

    -

    Example

    +

     

    +

    Example 1:

    -Input:
    -[[7,0], [4,4], [7,1], [5,0], [6,1], [5,2]]
    +Input: people = [[7,0],[4,4],[7,1],[5,0],[6,1],[5,2]]
    +Output: [[5,0],[7,0],[5,2],[6,1],[4,4],[7,1]]
    +Explanation:
    +Person 0 has height 5 with no other people taller or the same height in front.
    +Person 1 has height 7 with no other people taller or the same height in front.
    +Person 2 has height 5 with two persons taller or the same height in front, which is person 0 and 1.
    +Person 3 has height 6 with one person taller or the same height in front, which is person 1.
    +Person 4 has height 4 with four people taller or the same height in front, which are people 0, 1, 2, and 3.
    +Person 5 has height 7 with one person taller or the same height in front, which is person 1.
    +Hence [[5,0],[7,0],[5,2],[6,1],[4,4],[7,1]] is the reconstructed queue.
    +
    + +

    Example 2:

    -Output: -[[5,0], [7,0], [5,2], [6,1], [4,4], [7,1]] +
    +Input: people = [[6,0],[5,0],[4,0],[3,2],[2,2],[1,4]]
    +Output: [[4,0],[5,0],[2,2],[3,2],[1,4],[6,0]]
     

     

    +

    Constraints:

    + +
      +
    • 1 <= people.length <= 2000
    • +
    • 0 <= hi <= 106
    • +
    • 0 <= ki < people.length
    • +
    • It is guaranteed that the queue can be reconstructed.
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/relative-sort-array/README.md b/problems/relative-sort-array/README.md index b3de2b749..bb842c717 100644 --- a/problems/relative-sort-array/README.md +++ b/problems/relative-sort-array/README.md @@ -24,9 +24,9 @@

    Constraints:

      -
    • arr1.length, arr2.length <= 1000
    • +
    • 1 <= arr1.length, arr2.length <= 1000
    • 0 <= arr1[i], arr2[i] <= 1000
    • -
    • Each arr2[i] is distinct.
    • +
    • All the elements of arr2 are distinct.
    • Each arr2[i] is in arr1.
    diff --git a/problems/richest-customer-wealth/README.md b/problems/richest-customer-wealth/README.md new file mode 100644 index 000000000..48a1f107e --- /dev/null +++ b/problems/richest-customer-wealth/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../minimum-number-of-removals-to-make-mountain-array "Minimum Number of Removals to Make Mountain Array") +                 +[Next >](../find-the-most-competitive-subsequence "Find the Most Competitive Subsequence") + +## [1672. Richest Customer Wealth (Easy)](https://leetcode.com/problems/richest-customer-wealth "最富有客户的资产总量") + +

    You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the i​​​​​​​​​​​th​​​​ customer has in the j​​​​​​​​​​​th​​​​ bank. Return the wealth that the richest customer has.

    + +

    A customer's wealth is the amount of money they have in all their bank accounts. The richest customer is the customer that has the maximum wealth.

    + +

     

    +

    Example 1:

    + +
    +Input: accounts = [[1,2,3],[3,2,1]]
    +Output: 6
    +Explanation:
    +1st customer has wealth = 1 + 2 + 3 = 6
    +2nd customer has wealth = 3 + 2 + 1 = 6
    +Both customers are considered the richest with a wealth of 6 each, so return 6.
    +
    + +

    Example 2:

    + +
    +Input: accounts = [[1,5],[7,3],[3,5]]
    +Output: 10
    +Explanation: 
    +1st customer has wealth = 6
    +2nd customer has wealth = 10 
    +3rd customer has wealth = 8
    +The 2nd customer is the richest with a wealth of 10.
    + +

    Example 3:

    + +
    +Input: accounts = [[2,8,7],[7,1,3],[1,9,5]]
    +Output: 17
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == accounts.length
    • +
    • n == accounts[i].length
    • +
    • 1 <= m, n <= 50
    • +
    • 1 <= accounts[i][j] <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Calculate the wealth of each customer +
    + +
    +Hint 2 +Find the maximum element in array. +
    diff --git a/problems/search-a-2d-matrix-ii/README.md b/problems/search-a-2d-matrix-ii/README.md index af706d37e..0c9894026 100644 --- a/problems/search-a-2d-matrix-ii/README.md +++ b/problems/search-a-2d-matrix-ii/README.md @@ -11,30 +11,40 @@ ## [240. Search a 2D Matrix II (Medium)](https://leetcode.com/problems/search-a-2d-matrix-ii "搜索二维矩阵 II") -

    Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:

    +

    Write an efficient algorithm that searches for a target value in an m x n integer matrix. The matrix has the following properties:

    • Integers in each row are sorted in ascending from left to right.
    • Integers in each column are sorted in ascending from top to bottom.
    -

    Example:

    - -

    Consider the following matrix:

    +

     

    +

    Example 1:

    + +
    +Input: matrix = [[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]], target = 5
    +Output: true
    +
    +

    Example 2:

    +
    -[
    -  [1,   4,  7, 11, 15],
    -  [2,   5,  8, 12, 19],
    -  [3,   6,  9, 16, 22],
    -  [10, 13, 14, 17, 24],
    -  [18, 21, 23, 26, 30]
    -]
    +Input: matrix = [[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]], target = 20
    +Output: false
     
    -

    Given target = 5, return true.

    +

     

    +

    Constraints:

    -

    Given target = 20, return false.

    +
      +
    • m == matrix.length
    • +
    • n == matrix[i].length
    • +
    • 1 <= n, m <= 300
    • +
    • -109 <= matix[i][j] <= 109
    • +
    • All the integers in each row are sorted in ascending order.
    • +
    • All the integers in each column are sorted in ascending order.
    • +
    • -109 <= target <= 109
    • +
    ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/set-intersection-size-at-least-two/README.md b/problems/set-intersection-size-at-least-two/README.md index 55fab50bc..384ab268f 100644 --- a/problems/set-intersection-size-at-least-two/README.md +++ b/problems/set-intersection-size-at-least-two/README.md @@ -11,37 +11,37 @@ ## [757. Set Intersection Size At Least Two (Hard)](https://leetcode.com/problems/set-intersection-size-at-least-two "设置交集大小至少为2") -

    -An integer interval [a, b] (for integers a < b) is a set of all consecutive integers from a to b, including a and b. -

    -Find the minimum size of a set S such that for every integer interval A in intervals, the intersection of S with A has size at least 2. -

    +

    An integer interval [a, b] (for integers a < b) is a set of all consecutive integers from a to b, including a and b.

    + +

    Find the minimum size of a set S such that for every integer interval A in intervals, the intersection of S with A has a size of at least two.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: intervals = [[1, 3], [1, 4], [2, 5], [3, 5]]
    -Output: 3
    -Explanation:
    -Consider the set S = {2, 3, 4}.  For each interval, there are at least 2 elements from S in the interval.
    -Also, there isn't a smaller size set that fulfills the above condition.
    +Input: intervals = [[1,3],[1,4],[2,5],[3,5]]
    +Output: 3
    +Explanation: Consider the set S = {2, 3, 4}.  For each interval, there are at least 2 elements from S in the interval.
    +Also, there isn't a smaller size set that fulfills the above condition.
     Thus, we output the size of this set, which is 3.
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: intervals = [[1, 2], [2, 3], [2, 4], [4, 5]]
    -Output: 5
    -Explanation:
    -An example of a minimum sized set is {1, 2, 3, 4, 5}.
    +Input: intervals = [[1,2],[2,3],[2,4],[4,5]]
    +Output: 5
    +Explanation: An example of a minimum sized set is {1, 2, 3, 4, 5}.
     
    -

    -

    Note:

      -
    1. intervals will have length in range [1, 3000].
    2. -
    3. intervals[i] will have length 2, representing some integer interval.
    4. -
    5. intervals[i][j] will be an integer in [0, 10^8].
    6. -

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= intervals.length <= 3000
    • +
    • intervals[i].length == 2
    • +
    • 0 <= ai < bi <= 108
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/single-element-in-a-sorted-array/README.md b/problems/single-element-in-a-sorted-array/README.md index b76ff4d35..a18a0b9db 100644 --- a/problems/single-element-in-a-sorted-array/README.md +++ b/problems/single-element-in-a-sorted-array/README.md @@ -30,3 +30,6 @@
  • 1 <= nums.length <= 10^5
  • 0 <= nums[i] <= 10^5
  • + +### Related Topics + [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/single-number-ii/README.md b/problems/single-number-ii/README.md index cd578e54b..a59956112 100644 --- a/problems/single-number-ii/README.md +++ b/problems/single-number-ii/README.md @@ -11,24 +11,27 @@ ## [137. Single Number II (Medium)](https://leetcode.com/problems/single-number-ii "只出现一次的数字 II") -

    Given a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single one.

    - -

    Note:

    - -

    Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?

    +

    Given an integer array nums where every element appears three times except for one, which appears exactly once. Find the single element and return it.

    +

     

    Example 1:

    - -
    -Input: [2,2,3,2]
    +
    Input: nums = [2,2,3,2]
     Output: 3
    +

    Example 2:

    +
    Input: nums = [0,1,0,1,0,1,99]
    +Output: 99
     
    +

     

    +

    Constraints:

    -

    Example 2:

    +
      +
    • 1 <= nums.length <= 3 * 104
    • +
    • -231 <= nums[i] <= 231 - 1
    • +
    • Each element in nums appears exactly three times except for one element which appears once.
    • +
    -
    -Input: [0,1,0,1,0,1,99]
    -Output: 99
    +

     

    +

    Follow up: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?

    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/smallest-string-with-a-given-numeric-value/README.md b/problems/smallest-string-with-a-given-numeric-value/README.md new file mode 100644 index 000000000..de4f941b0 --- /dev/null +++ b/problems/smallest-string-with-a-given-numeric-value/README.md @@ -0,0 +1,58 @@ + + + + + + + +[< Previous](../check-if-two-string-arrays-are-equivalent "Check If Two String Arrays are Equivalent") +                 +[Next >](../ways-to-make-a-fair-array "Ways to Make a Fair Array") + +## [1663. Smallest String With A Given Numeric Value (Medium)](https://leetcode.com/problems/smallest-string-with-a-given-numeric-value "具有给定数值的最小字符串") + +

    The numeric value of a lowercase character is defined as its position (1-indexed) in the alphabet, so the numeric value of a is 1, the numeric value of b is 2, the numeric value of c is 3, and so on.

    + +

    The numeric value of a string consisting of lowercase characters is defined as the sum of its characters' numeric values. For example, the numeric value of the string "abe" is equal to 1 + 2 + 5 = 8.

    + +

    You are given two integers n and k. Return the lexicographically smallest string with length equal to n and numeric value equal to k.

    + +

    Note that a string x is lexicographically smaller than string y if x comes before y in dictionary order, that is, either x is a prefix of y, or if i is the first position such that x[i] != y[i], then x[i] comes before y[i] in alphabetic order.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 3, k = 27
    +Output: "aay"
    +Explanation: The numeric value of the string is 1 + 1 + 25 = 27, and it is the smallest string with such a value and length equal to 3.
    +
    + +

    Example 2:

    + +
    +Input: n = 5, k = 73
    +Output: "aaszz"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 105
    • +
    • n <= k <= 26 * n
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Think greedily. +
    + +
    +Hint 2 +If you build the string from the end to the beginning, it will always be optimal to put the highest possible character at the current index. +
    diff --git a/problems/squares-of-a-sorted-array/README.md b/problems/squares-of-a-sorted-array/README.md index 479f1d0ec..e2a6688d5 100644 --- a/problems/squares-of-a-sorted-array/README.md +++ b/problems/squares-of-a-sorted-array/README.md @@ -11,37 +11,33 @@ ## [977. Squares of a Sorted Array (Easy)](https://leetcode.com/problems/squares-of-a-sorted-array "有序数组的平方") -

    Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order.

    +

    Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.

     

    - -

    Example 1:

    -Input: [-4,-1,0,3,10]
    -Output: [0,1,9,16,100]
    +Input: nums = [-4,-1,0,3,10]
    +Output: [0,1,9,16,100]
    +Explanation: After squaring, the array becomes [16,1,0,9,100].
    +After sorting, it becomes [0,1,9,16,100].
     
    -

    Example 2:

    -Input: [-7,-3,2,3,11]
    -Output: [4,9,9,49,121]
    +Input: nums = [-7,-3,2,3,11]
    +Output: [4,9,9,49,121]
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= A.length <= 10000
    2. -
    3. -10000 <= A[i] <= 10000
    4. -
    5. A is sorted in non-decreasing order.
    6. -
    -
    -
    +
      +
    • 1 <= nums.length <= 104
    • +
    • -104 <= nums[i] <= 104
    • +
    • nums is sorted in non-decreasing order.
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/team-scores-in-football-tournament/mysql_schemas.sql b/problems/team-scores-in-football-tournament/mysql_schemas.sql index 978263cbe..a09fa129d 100644 --- a/problems/team-scores-in-football-tournament/mysql_schemas.sql +++ b/problems/team-scores-in-football-tournament/mysql_schemas.sql @@ -7,7 +7,7 @@ insert into Teams (team_id, team_name) values ('30', 'Atlanta FC'); insert into Teams (team_id, team_name) values ('40', 'Chicago FC'); insert into Teams (team_id, team_name) values ('50', 'Toronto FC'); Truncate table Matches; -insert into Matches (match_id, host_team, guest_team, host_goals, guest_goals) values ('1', '10', '20', '30', '0'); +insert into Matches (match_id, host_team, guest_team, host_goals, guest_goals) values ('1', '10', '20', '3', '0'); insert into Matches (match_id, host_team, guest_team, host_goals, guest_goals) values ('2', '30', '10', '2', '2'); insert into Matches (match_id, host_team, guest_team, host_goals, guest_goals) values ('3', '10', '50', '5', '1'); insert into Matches (match_id, host_team, guest_team, host_goals, guest_goals) values ('4', '20', '30', '1', '0'); diff --git a/problems/the-k-weakest-rows-in-a-matrix/README.md b/problems/the-k-weakest-rows-in-a-matrix/README.md index 411515b6c..7ca124453 100644 --- a/problems/the-k-weakest-rows-in-a-matrix/README.md +++ b/problems/the-k-weakest-rows-in-a-matrix/README.md @@ -9,7 +9,7 @@                  [Next >](../reduce-array-size-to-the-half "Reduce Array Size to The Half") -## [1337. The K Weakest Rows in a Matrix (Easy)](https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix "方阵中战斗力最弱的 K 行") +## [1337. The K Weakest Rows in a Matrix (Easy)](https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix "矩阵中战斗力最弱的 K 行")

    Given a m * n matrix mat of ones (representing soldiers) and zeros (representing civilians), return the indexes of the k weakest rows in the matrix ordered from the weakest to the strongest.

    diff --git a/problems/the-skyline-problem/README.md b/problems/the-skyline-problem/README.md index 93add4fcd..23d15b9c8 100644 --- a/problems/the-skyline-problem/README.md +++ b/problems/the-skyline-problem/README.md @@ -11,24 +11,48 @@ ## [218. The Skyline Problem (Hard)](https://leetcode.com/problems/the-skyline-problem "天际线问题") -

    A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are given the locations and height of all the buildings as shown on a cityscape photo (Figure A), write a program to output the skyline formed by these buildings collectively (Figure B).

    -Buildings Skyline Contour +

    A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and heights of all the buildings, return the skyline formed by these buildings collectively.

    -

    The geometric information of each building is represented by a triplet of integers [Li, Ri, Hi], where Li and Ri are the x coordinates of the left and right edge of the ith building, respectively, and Hi is its height. It is guaranteed that 0 ≤ Li, Ri ≤ INT_MAX, 0 < Hi ≤ INT_MAX, and Ri - Li > 0. You may assume all buildings are perfect rectangles grounded on an absolutely flat surface at height 0.

    +

    The geometric information of each building is given in the array buildings where buildings[i] = [lefti, righti, heighti]:

    -

    For instance, the dimensions of all buildings in Figure A are recorded as: [ [2 9 10], [3 7 15], [5 12 12], [15 20 10], [19 24 8] ] .

    +
      +
    • lefti is the x coordinate of the left edge of the ith building.
    • +
    • righti is the x coordinate of the right edge of the ith building.
    • +
    • heighti is the height of the ith building.
    • +
    + +

    You may assume all buildings are perfect rectangles grounded on an absolutely flat surface at height 0.

    + +

    The skyline should be represented as a list of "key points" sorted by their x-coordinate in the form [[x1,y1],[x2,y2],...]. Each key point is the left endpoint of some horizontal segment in the skyline except the last point in the list, which always has a y-coordinate 0 and is used to mark the skyline's termination where the rightmost building ends. Any ground between the leftmost and rightmost buildings should be part of the skyline's contour.

    + +

    Note: There must be no consecutive horizontal lines of equal height in the output skyline. For instance, [...,[2 3],[4 5],[7 5],[11 5],[12 7],...] is not acceptable; the three lines of height 5 should be merged into one in the final output as such: [...,[2 3],[4 5],[12 7],...]

    + +

     

    +

    Example 1:

    + +
    +Input: buildings = [[2,9,10],[3,7,15],[5,12,12],[15,20,10],[19,24,8]]
    +Output: [[2,10],[3,15],[7,12],[12,0],[15,10],[20,8],[24,0]]
    +Explanation:
    +Figure A shows the buildings of the input.
    +Figure B shows the skyline formed by those buildings. The red points in figure B represent the key points in the output list.
    +
    -

    The output is a list of "key points" (red dots in Figure B) in the format of [ [x1,y1], [x2, y2], [x3, y3], ... ] that uniquely defines a skyline. A key point is the left endpoint of a horizontal line segment. Note that the last key point, where the rightmost building ends, is merely used to mark the termination of the skyline, and always has zero height. Also, the ground in between any two adjacent buildings should be considered part of the skyline contour.

    +

    Example 2:

    -

    For instance, the skyline in Figure B should be represented as:[ [2 10], [3 15], [7 12], [12 0], [15 10], [20 8], [24, 0] ].

    +
    +Input: buildings = [[0,2,3],[2,5,3]]
    +Output: [[0,3],[5,0]]
    +
    -

    Notes:

    +

     

    +

    Constraints:

      -
    • The number of buildings in any input list is guaranteed to be in the range [0, 10000].
    • -
    • The input list is already sorted in ascending order by the left x position Li.
    • -
    • The output list must be sorted by the x position.
    • -
    • There must be no consecutive horizontal lines of equal height in the output skyline. For instance, [...[2 3], [4 5], [7 5], [11 5], [12 7]...] is not acceptable; the three lines of height 5 should be merged into one in the final output as such: [...[2 3], [4 5], [12 7], ...]
    • +
    • 1 <= buildings.length <= 104
    • +
    • 0 <= lefti < righti <= 231 - 1
    • +
    • 1 <= heighti <= 231 - 1
    • +
    • buildings is sorted by lefti in non-decreasing order.
    ### Related Topics diff --git a/problems/two-city-scheduling/README.md b/problems/two-city-scheduling/README.md index 315b738c3..949c11d5d 100644 --- a/problems/two-city-scheduling/README.md +++ b/problems/two-city-scheduling/README.md @@ -48,7 +48,7 @@ The total minimum cost is 10 + 30 + 50 + 20 = 110 to have half the people interv

    Constraints:

      -
    • 2n == costs.length
    • +
    • 2 * n == costs.length
    • 2 <= costs.length <= 100
    • costs.length is even.
    • 1 <= aCosti, bCosti <= 1000
    • diff --git a/problems/two-sum/README.md b/problems/two-sum/README.md index bfd2afc9a..3a518e534 100644 --- a/problems/two-sum/README.md +++ b/problems/two-sum/README.md @@ -44,7 +44,7 @@

      Constraints:

        -
      • 2 <= nums.length <= 105
      • +
      • 2 <= nums.length <= 103
      • -109 <= nums[i] <= 109
      • -109 <= target <= 109
      • Only one valid answer exists.
      • diff --git a/problems/validate-binary-search-tree/README.md b/problems/validate-binary-search-tree/README.md index 87c7158ef..e0feda0ec 100644 --- a/problems/validate-binary-search-tree/README.md +++ b/problems/validate-binary-search-tree/README.md @@ -11,9 +11,9 @@ ## [98. Validate Binary Search Tree (Medium)](https://leetcode.com/problems/validate-binary-search-tree "验证二叉搜索树") -

        Given a binary tree, determine if it is a valid binary search tree (BST).

        +

        Given the root of a binary tree, determine if it is a valid binary search tree (BST).

        -

        Assume a BST is defined as follows:

        +

        A valid BST is defined as follows:

        • The left subtree of a node contains only nodes with keys less than the node's key.
        • @@ -22,35 +22,33 @@

         

        -

        Example 1:

        - +
        -    2
        -   / \
        -  1   3
        -
        -Input: [2,1,3]
        +Input: root = [2,1,3]
         Output: true
         

        Example 2:

        - +
        -    5
        -   / \
        -  1   4
        -     / \
        -    3   6
        -
        -Input: [5,1,4,null,null,3,6]
        +Input: root = [5,1,4,null,null,3,6]
         Output: false
         Explanation: The root node's value is 5 but its right child's value is 4.
         
        +

         

        +

        Constraints:

        + +
          +
        • The number of nodes in the tree is in the range [1, 104].
        • +
        • -231 <= Node.val <= 231 - 1
        • +
        + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Medium) diff --git a/problems/ways-to-make-a-fair-array/README.md b/problems/ways-to-make-a-fair-array/README.md new file mode 100644 index 000000000..da30e10e4 --- /dev/null +++ b/problems/ways-to-make-a-fair-array/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../smallest-string-with-a-given-numeric-value "Smallest String With A Given Numeric Value") +                 +[Next >](../minimum-initial-energy-to-finish-tasks "Minimum Initial Energy to Finish Tasks") + +## [1664. Ways to Make a Fair Array (Medium)](https://leetcode.com/problems/ways-to-make-a-fair-array "生成平衡数组的方案数") + +

        You are given an integer array nums. You can choose exactly one index (0-indexed) and remove the element. Notice that the index of the elements may change after the removal.

        + +

        For example, if nums = [6,1,7,4,1]:

        + +
          +
        • Choosing to remove index 1 results in nums = [6,7,4,1].
        • +
        • Choosing to remove index 2 results in nums = [6,1,4,1].
        • +
        • Choosing to remove index 4 results in nums = [6,1,7,4].
        • +
        + +

        An array is fair if the sum of the odd-indexed values equals the sum of the even-indexed values.

        + +

        Return the number of indices that you could choose such that after the removal, nums is fair.

        + +

         

        +

        Example 1:

        + +
        +Input: nums = [2,1,6,4]
        +Output: 1
        +Explanation:
        +Remove index 0: [1,6,4] -> Even sum: 1 + 4 = 5. Odd sum: 6. Not fair.
        +Remove index 1: [2,6,4] -> Even sum: 2 + 4 = 6. Odd sum: 6. Fair.
        +Remove index 2: [2,1,4] -> Even sum: 2 + 4 = 6. Odd sum: 1. Not fair.
        +Remove index 3: [2,1,6] -> Even sum: 2 + 6 = 8. Odd sum: 1. Not fair.
        +There is 1 index that you can remove to make nums fair.
        +
        + +

        Example 2:

        + +
        +Input: nums = [1,1,1]
        +Output: 3
        +Explanation: You can remove any index and the remaining array is fair.
        +
        + +

        Example 3:

        + +
        +Input: nums = [1,2,3]
        +Output: 0
        +Explanation: You cannot make a fair array after removing any index.
        +
        + +

         

        +

        Constraints:

        + +
          +
        • 1 <= nums.length <= 105
        • +
        • 1 <= nums[i] <= 104
        • +
        + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
        +Hint 1 +The parity of the indices after the removed element changes. +
        + +
        +Hint 2 +Calculate prefix sums for even and odd indices separately to calculate for each index in O(1). +
        diff --git a/readme/1-300.md b/readme/1-300.md index 12560305c..12363d525 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -215,7 +215,7 @@ LeetCode Problems' Solutions | 143 | [Reorder List](https://leetcode.com/problems/reorder-list "重排链表") | [Go](../problems/reorder-list) | Medium | | 144 | [Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal "二叉树的前序遍历") | [Go](../problems/binary-tree-preorder-traversal) | Medium | | 145 | [Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历") | [Go](../problems/binary-tree-postorder-traversal) | Medium | -| 146 | [LRU Cache](https://leetcode.com/problems/lru-cache "LRU缓存机制") | [Go](../problems/lru-cache) | Medium | +| 146 | [LRU Cache](https://leetcode.com/problems/lru-cache "LRU 缓存机制") | [Go](../problems/lru-cache) | Medium | | 147 | [Insertion Sort List](https://leetcode.com/problems/insertion-sort-list "对链表进行插入排序") | [Go](../problems/insertion-sort-list) | Medium | | 148 | [Sort List](https://leetcode.com/problems/sort-list "排序链表") | [Go](../problems/sort-list) | Medium | | 149 | [Max Points on a Line](https://leetcode.com/problems/max-points-on-a-line "直线上最多的点数") | [Go](../problems/max-points-on-a-line) | Hard | diff --git a/readme/301-600.md b/readme/301-600.md index b787b73b8..76dc35af2 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -198,7 +198,7 @@ LeetCode Problems' Solutions | 426 | [Convert Binary Search Tree to Sorted Doubly Linked List](https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list "将二叉搜索树转化为排序的双向链表") 🔒 | [Go](../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) | Medium | | 427 | [Construct Quad Tree](https://leetcode.com/problems/construct-quad-tree "建立四叉树") | [Go](../problems/construct-quad-tree) | Medium | | 428 | [Serialize and Deserialize N-ary Tree](https://leetcode.com/problems/serialize-and-deserialize-n-ary-tree "序列化和反序列化 N 叉树") 🔒 | [Go](../problems/serialize-and-deserialize-n-ary-tree) | Hard | -| 429 | [N-ary Tree Level Order Traversal](https://leetcode.com/problems/n-ary-tree-level-order-traversal "N叉树的层序遍历") | [Go](../problems/n-ary-tree-level-order-traversal) | Medium | +| 429 | [N-ary Tree Level Order Traversal](https://leetcode.com/problems/n-ary-tree-level-order-traversal "N 叉树的层序遍历") | [Go](../problems/n-ary-tree-level-order-traversal) | Medium | | 430 | [Flatten a Multilevel Doubly Linked List](https://leetcode.com/problems/flatten-a-multilevel-doubly-linked-list "扁平化多级双向链表") | [Go](../problems/flatten-a-multilevel-doubly-linked-list) | Medium | | 431 | [Encode N-ary Tree to Binary Tree](https://leetcode.com/problems/encode-n-ary-tree-to-binary-tree "将 N 叉树编码为二叉树") 🔒 | [Go](../problems/encode-n-ary-tree-to-binary-tree) | Hard | | 432 | [All O`one Data Structure](https://leetcode.com/problems/all-oone-data-structure "全 O(1) 的数据结构") | [Go](../problems/all-oone-data-structure) | Hard | @@ -328,7 +328,7 @@ LeetCode Problems' Solutions | 556 | [Next Greater Element III](https://leetcode.com/problems/next-greater-element-iii "下一个更大元素 III") | [Go](../problems/next-greater-element-iii) | Medium | | 557 | [Reverse Words in a String III](https://leetcode.com/problems/reverse-words-in-a-string-iii "反转字符串中的单词 III") | [Go](../problems/reverse-words-in-a-string-iii) | Easy | | 558 | [Logical OR of Two Binary Grids Represented as Quad-Trees](https://leetcode.com/problems/logical-or-of-two-binary-grids-represented-as-quad-trees "四叉树交集") | [Go](../problems/logical-or-of-two-binary-grids-represented-as-quad-trees) | Medium | -| 559 | [Maximum Depth of N-ary Tree](https://leetcode.com/problems/maximum-depth-of-n-ary-tree "N叉树的最大深度") | [Go](../problems/maximum-depth-of-n-ary-tree) | Easy | +| 559 | [Maximum Depth of N-ary Tree](https://leetcode.com/problems/maximum-depth-of-n-ary-tree "N 叉树的最大深度") | [Go](../problems/maximum-depth-of-n-ary-tree) | Easy | | 560 | [Subarray Sum Equals K](https://leetcode.com/problems/subarray-sum-equals-k "和为K的子数组") | [Go](../problems/subarray-sum-equals-k) | Medium | | 561 | [Array Partition I](https://leetcode.com/problems/array-partition-i "数组拆分 I") | [Go](../problems/array-partition-i) | Easy | | 562 | [Longest Line of Consecutive One in Matrix](https://leetcode.com/problems/longest-line-of-consecutive-one-in-matrix "矩阵中最长的连续1线段") 🔒 | [Go](../problems/longest-line-of-consecutive-one-in-matrix) | Medium | diff --git a/readme/901-1200.md b/readme/901-1200.md index 0ac0c10db..63c050c12 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -179,7 +179,7 @@ LeetCode Problems' Solutions | 1007 | [Minimum Domino Rotations For Equal Row](https://leetcode.com/problems/minimum-domino-rotations-for-equal-row "行相等的最少多米诺旋转") | [Go](../problems/minimum-domino-rotations-for-equal-row) | Medium | | 1008 | [Construct Binary Search Tree from Preorder Traversal](https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal "前序遍历构造二叉搜索树") | [Go](../problems/construct-binary-search-tree-from-preorder-traversal) | Medium | | 1009 | [Complement of Base 10 Integer](https://leetcode.com/problems/complement-of-base-10-integer "十进制整数的反码") | [Go](../problems/complement-of-base-10-integer) | Easy | -| 1010 | [Pairs of Songs With Total Durations Divisible by 60](https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60 "总持续时间可被 60 整除的歌曲") | [Go](../problems/pairs-of-songs-with-total-durations-divisible-by-60) | Easy | +| 1010 | [Pairs of Songs With Total Durations Divisible by 60](https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60 "总持续时间可被 60 整除的歌曲") | [Go](../problems/pairs-of-songs-with-total-durations-divisible-by-60) | Medium | | 1011 | [Capacity To Ship Packages Within D Days](https://leetcode.com/problems/capacity-to-ship-packages-within-d-days "在 D 天内送达包裹的能力") | [Go](../problems/capacity-to-ship-packages-within-d-days) | Medium | | 1012 | [Numbers With Repeated Digits](https://leetcode.com/problems/numbers-with-repeated-digits "至少有 1 位重复的数字") | [Go](../problems/numbers-with-repeated-digits) | Hard | | 1013 | [Partition Array Into Three Parts With Equal Sum](https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum "将数组分成和相等的三个部分") | [Go](../problems/partition-array-into-three-parts-with-equal-sum) | Easy | diff --git a/tag/README.md b/tag/README.md index bba637222..9fc67df4d 100644 --- a/tag/README.md +++ b/tag/README.md @@ -15,17 +15,18 @@ | 7 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | | 8 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 9 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | | 11 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | -| 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | +| 13 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | | 14 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 15 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | | 19 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 20 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | -| 21 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | | 22 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | -| 23 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | +| 21 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | | 22 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | +| 23 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | | 24 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 25 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | | 27 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | | 28 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 29 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 31 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 32 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | | 33 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 34 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | | 35 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | -| 37 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | | 38 | [Reservoir Sampling](reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | -| 39 | [Memoization](memoization/README.md) | [记忆化](https://openset.github.io/tags/memoization/) | | 40 | [Suffix Array](suffix-array/README.md) | [Suffix Array](https://openset.github.io/tags/suffix-array/) | +| 37 | [](dequeue/README.md) | [](https://openset.github.io/tags/dequeue/) | | 38 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | +| 39 | [Reservoir Sampling](reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | | 40 | [Suffix Array](suffix-array/README.md) | [Suffix Array](https://openset.github.io/tags/suffix-array/) | +| 41 | [Memoization](memoization/README.md) | [记忆化](https://openset.github.io/tags/memoization/) | | 42 | [](oop/README.md) | [](https://openset.github.io/tags/oop/) | diff --git a/tag/array/README.md b/tag/array/README.md index ae20176b6..637095778 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1672 | [最富有客户的资产总量](../../problems/richest-customer-wealth) | [[数组](../array/README.md)] | Easy | | 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Easy | | 1652 | [拆炸弹](../../problems/defuse-the-bomb) | [[数组](../array/README.md)] | Easy | | 1646 | [获取生成数组中的最大值](../../problems/get-maximum-in-generated-array) | [[数组](../array/README.md)] | Easy | @@ -82,7 +83,7 @@ | 1346 | [检查整数及其两倍数是否存在](../../problems/check-if-n-and-its-double-exist) | [[数组](../array/README.md)] | Easy | | 1343 | [大小为 K 且平均值大于等于阈值的子数组数目](../../problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold) | [[数组](../array/README.md)] | Medium | | 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1337 | [方阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1337 | [矩阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 1333 | [餐厅过滤器](../../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1331 | [数组序号转换](../../problems/rank-transform-of-an-array) | [[数组](../array/README.md)] | Easy | | 1330 | [翻转子数组得到最大的数组值](../../problems/reverse-subarray-to-maximize-array-value) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | @@ -142,7 +143,7 @@ | 1014 | [最佳观光组合](../../problems/best-sightseeing-pair) | [[数组](../array/README.md)] | Medium | | 1013 | [将数组分成和相等的三个部分](../../problems/partition-array-into-three-parts-with-equal-sum) | [[数组](../array/README.md)] | Easy | | 1011 | [在 D 天内送达包裹的能力](../../problems/capacity-to-ship-packages-within-d-days) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1010 | [总持续时间可被 60 整除的歌曲](../../problems/pairs-of-songs-with-total-durations-divisible-by-60) | [[数组](../array/README.md)] | Easy | +| 1010 | [总持续时间可被 60 整除的歌曲](../../problems/pairs-of-songs-with-total-durations-divisible-by-60) | [[数组](../array/README.md)] | Medium | | 1007 | [行相等的最少多米诺旋转](../../problems/minimum-domino-rotations-for-equal-row) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 999 | [可以被一步捕获的棋子数](../../problems/available-captures-for-rook) | [[数组](../array/README.md)] | Easy | @@ -209,7 +210,7 @@ | 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | | 611 | [有效三角形的个数](../../problems/valid-triangle-number) | [[数组](../array/README.md)] | Medium | -| 605 | [种花问题](../../problems/can-place-flowers) | [[数组](../array/README.md)] | Easy | +| 605 | [种花问题](../../problems/can-place-flowers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 581 | [最短无序连续子数组](../../problems/shortest-unsorted-continuous-subarray) | [[数组](../array/README.md)] | Medium | | 566 | [重塑矩阵](../../problems/reshape-the-matrix) | [[数组](../array/README.md)] | Easy | | 565 | [数组嵌套](../../problems/array-nesting) | [[数组](../array/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 21bdb8a56..5cec3ae89 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1681 | [最小不兼容性](../../problems/minimum-incompatibility) | [[贪心算法](../greedy/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | @@ -68,5 +69,5 @@ | 39 | [组合总和](../../problems/combination-sum) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 37 | [解数独](../../problems/sudoku-solver) | [[哈希表](../hash-table/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 72be60eda..4c89615a8 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -21,7 +21,7 @@ | 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1482 | [制作 m 束花所需的最少天数](../../problems/minimum-number-of-days-to-make-m-bouquets) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1337 | [方阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1337 | [矩阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1283 | [使结果不超过阈值的最小除数](../../problems/find-the-smallest-divisor-given-a-threshold) | [[二分查找](../binary-search/README.md)] | Medium | @@ -60,6 +60,7 @@ | 668 | [乘法表中第k小的数](../../problems/kth-smallest-number-in-multiplication-table) | [[二分查找](../binary-search/README.md)] | Hard | | 658 | [找到 K 个最接近的元素](../../problems/find-k-closest-elements) | [[二分查找](../binary-search/README.md)] | Medium | | 644 | [最大平均子段和 II](../../problems/maximum-average-subarray-ii) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 540 | [有序数组中的单一元素](../../problems/single-element-in-a-sorted-array) | [[二分查找](../binary-search/README.md)] | Medium | | 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | | 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | | 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index efe046218..97922c717 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,79 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1654 | [到家的最少跳跃次数](../../problems/minimum-jumps-to-reach-home) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1625 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1345 | [跳跃游戏 IV](../../problems/jump-game-iv) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1298 | [你能从盒子里获得的最大糖果数](../../problems/maximum-candies-you-can-get-from-boxes) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1293 | [网格中的最短路径](../../problems/shortest-path-in-a-grid-with-obstacles-elimination) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1284 | [转化为全零矩阵的最少反转次数](../../problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1263 | [推箱子](../../problems/minimum-moves-to-move-a-box-to-their-target-location) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1242 | [多线程网页爬虫](../../problems/web-crawler-multithreaded) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1236 | [网络爬虫](../../problems/web-crawler) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1210 | [穿过迷宫的最少移动次数](../../problems/minimum-moves-to-reach-target-with-rotations) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1197 | [进击的骑士](../../problems/minimum-knight-moves) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1091 | [二进制矩阵中的最短路径](../../problems/shortest-path-in-binary-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 994 | [腐烂的橘子](../../problems/rotting-oranges) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[极小化极大](../minimax/README.md)] | Hard | -| 909 | [蛇梯棋](../../problems/snakes-and-ladders) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 864 | [获取所有钥匙的最短路径](../../problems/shortest-path-to-get-all-keys) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 854 | [相似度为 K 的字符串](../../problems/k-similar-strings) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Hard | -| 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 773 | [滑动谜题](../../problems/sliding-puzzle) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 675 | [为高尔夫比赛砍树](../../problems/cut-off-trees-for-golf-event) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 559 | [N叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 542 | [01 矩阵](../../problems/01-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 529 | [扫雷游戏](../../problems/minesweeper) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 505 | [迷宫 II](../../problems/the-maze-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 499 | [迷宫 III](../../problems/the-maze-iii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 490 | [迷宫](../../problems/the-maze) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 429 | [N叉树的层序遍历](../../problems/n-ary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 417 | [太平洋大西洋水流问题](../../problems/pacific-atlantic-water-flow) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 317 | [离建筑物最近的距离](../../problems/shortest-distance-from-all-buildings) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 310 | [最小高度树](../../problems/minimum-height-trees) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 301 | [删除无效的括号](../../problems/remove-invalid-parentheses) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 286 | [墙与门](../../problems/walls-and-gates) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 127 | [单词接龙](../../problems/word-ladder) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 107 | [二叉树的层次遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 103 | [二叉树的锯齿形层次遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 102 | [二叉树的层序遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 490f19ce0..ba34937f2 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1676 | [Lowest Common Ancestor of a Binary Tree IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1666 | [Change the Root of a Binary Tree](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1625 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | @@ -27,6 +29,7 @@ | 1376 | [通知所有员工所需的时间](../../problems/time-needed-to-inform-all-employees) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 1315 | [祖父节点值为偶数的节点和](../../problems/sum-of-nodes-with-even-valued-grandparent) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | | 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1273 | [删除树节点](../../problems/delete-tree-nodes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1254 | [统计封闭岛屿的数目](../../problems/number-of-closed-islands) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | @@ -59,7 +62,7 @@ | 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 924 | [尽量减少恶意软件的传播](../../problems/minimize-malware-spread) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | -| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | @@ -89,7 +92,7 @@ | 638 | [大礼包](../../problems/shopping-offers) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 576 | [出界的路径数](../../problems/out-of-boundary-paths) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 559 | [N叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 559 | [N 叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 547 | [朋友圈](../../problems/friend-circles) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 546 | [移除盒子](../../problems/remove-boxes) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 542 | [01 矩阵](../../problems/01-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | @@ -142,8 +145,9 @@ | 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 100 | [相同的树](../../problems/same-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 99 | [恢复二叉搜索树](../../problems/recover-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/dequeue/README.md b/tag/dequeue/README.md new file mode 100644 index 000000000..dac9adc9e --- /dev/null +++ b/tag/dequeue/README.md @@ -0,0 +1,11 @@ + + + + + + + +## [话题分类](../README.md) > + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | diff --git a/tag/design/README.md b/tag/design/README.md index a72370d84..4a85371d3 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,8 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | | 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Easy | -| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard | | 1603 | [设计停车系统](../../problems/design-parking-system) | [[设计](../design/README.md)] | Easy | | 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | @@ -66,4 +67,4 @@ | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 146 | [LRU缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] | Medium | +| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] | Medium | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index 7ef87cf29..9fcc476e7 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -16,6 +16,7 @@ | 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 395 | [至少有K个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 312 | [戳气球](../../problems/burst-balloons) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index a7a8bc734..ad1a7a83a 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1671 | [得到山形数组的最少删除次数](../../problems/minimum-number-of-removals-to-make-mountain-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1664 | [生成平衡数组的方案数](../../problems/ways-to-make-a-fair-array) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1654 | [到家的最少跳跃次数](../../problems/minimum-jumps-to-reach-home) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -240,3 +242,4 @@ | 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 5 | [最长回文子串](../../problems/longest-palindromic-substring) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1 | [01 背包问题](../../problems/07MoiZ) | [[动态规划](../dynamic-programming/README.md)] | Easy | diff --git a/tag/graph/README.md b/tag/graph/README.md index 1c5b8478a..0d01c1b08 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -20,7 +20,6 @@ | 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | | 1361 | [验证二叉树](../../problems/validate-binary-tree-nodes) | [[图](../graph/README.md)] | Medium | | 1334 | [阈值距离内邻居最少的城市](../../problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | [[图](../graph/README.md)] | Medium | -| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | | 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 377fceca8..be24a7a70 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,111 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1657 | [确定两个字符串是否接近](../../problems/determine-if-two-strings-are-close) | [[贪心算法](../greedy/README.md)] | Medium | -| 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | -| 1647 | [字符频次唯一的最小删除次数](../../problems/minimum-deletions-to-make-character-frequencies-unique) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] | Hard | -| 1620 | [网络信号最好的坐标](../../problems/coordinate-with-maximum-network-quality) | [[贪心算法](../greedy/README.md)] | Medium | -| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1605 | [给定行和列的和求可行矩阵](../../problems/find-valid-matrix-given-row-and-column-sums) | [[贪心算法](../greedy/README.md)] | Medium | -| 1599 | [经营摩天轮的最大利润](../../problems/maximum-profit-of-operating-a-centennial-wheel) | [[贪心算法](../greedy/README.md)] | Medium | -| 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1591 | [奇怪的打印机 II](../../problems/strange-printer-ii) | [[贪心算法](../greedy/README.md)] | Hard | -| 1589 | [所有排列中的最大和](../../problems/maximum-sum-obtained-of-any-permutation) | [[贪心算法](../greedy/README.md)] | Medium | -| 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | -| 1580 | [Put Boxes Into the Warehouse II](../../problems/put-boxes-into-the-warehouse-ii) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心算法](../greedy/README.md)] | Medium | -| 1568 | [使陆地分离的最少天数](../../problems/minimum-number-of-days-to-disconnect-island) | [[贪心算法](../greedy/README.md)] | Hard | -| 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心算法](../greedy/README.md)] | Medium | -| 1564 | [把箱子放进仓库里 I](../../problems/put-boxes-into-the-warehouse-i) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | -| 1558 | [得到目标数组的最少函数调用次数](../../problems/minimum-numbers-of-function-calls-to-make-target-array) | [[贪心算法](../greedy/README.md)] | Medium | -| 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心算法](../greedy/README.md)] | Medium | -| 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心算法](../greedy/README.md)] | Hard | -| 1518 | [换酒问题](../../problems/water-bottles) | [[贪心算法](../greedy/README.md)] | Easy | -| 1505 | [最多 K 次交换相邻数位后得到的最小整数](../../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | [[贪心算法](../greedy/README.md)] | Hard | -| 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1414 | [和为 K 的最少斐波那契数字数目](../../problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | -| 1400 | [构造 K 个回文字符串](../../problems/construct-k-palindrome-strings) | [[贪心算法](../greedy/README.md)] | Medium | -| 1386 | [安排电影院座位](../../problems/cinema-seat-allocation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Hard | -| 1354 | [多次求和构造目标数组](../../problems/construct-target-array-with-multiple-sums) | [[贪心算法](../greedy/README.md)] | Hard | -| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | -| 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1326 | [灌溉花园的最少水龙头数目](../../problems/minimum-number-of-taps-to-open-to-water-a-garden) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1282 | [用户分组](../../problems/group-the-people-given-the-group-size-they-belong-to) | [[贪心算法](../greedy/README.md)] | Medium | -| 1276 | [不浪费原料的汉堡制作方案](../../problems/number-of-burgers-with-no-waste-of-ingredients) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 1253 | [重构 2 行二进制矩阵](../../problems/reconstruct-a-2-row-binary-matrix) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 1247 | [交换字符使得字符串相同](../../problems/minimum-swaps-to-make-strings-equal) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1231 | [分享巧克力](../../problems/divide-chocolate) 🔒 | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1221 | [分割平衡字符串](../../problems/split-a-string-in-balanced-strings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | -| 1217 | [玩筹码](../../problems/minimum-cost-to-move-chips-to-the-same-position) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 1196 | [最多可以买到的苹果数量](../../problems/how-many-apples-can-you-put-into-the-basket) 🔒 | [[贪心算法](../greedy/README.md)] | Easy | -| 1167 | [连接棒材的最低费用](../../problems/minimum-cost-to-connect-sticks) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | -| 1111 | [有效括号的嵌套深度](../../problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1094 | [拼车](../../problems/car-pooling) | [[贪心算法](../greedy/README.md)] | Medium | -| 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1057 | [校园自行车分配](../../problems/campus-bikes) 🔒 | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1055 | [形成字符串的最短路径](../../problems/shortest-way-to-form-string) 🔒 | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1053 | [交换一次的先前排列](../../problems/previous-permutation-with-one-swap) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1046 | [最后一块石头的重量](../../problems/last-stone-weight) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Easy | -| 1029 | [两地调度](../../problems/two-city-scheduling) | [[贪心算法](../greedy/README.md)] | Medium | -| 1007 | [行相等的最少多米诺旋转](../../problems/minimum-domino-rotations-for-equal-row) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1005 | [K 次取反后最大化的数组和](../../problems/maximize-sum-of-array-after-k-negations) | [[贪心算法](../greedy/README.md)] | Easy | -| 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[贪心算法](../greedy/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 991 | [坏了的计算器](../../problems/broken-calculator) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 984 | [不含 AAA 或 BBB 的字符串](../../problems/string-without-aaa-or-bbb) | [[贪心算法](../greedy/README.md)] | Medium | -| 955 | [删列造序 II](../../problems/delete-columns-to-make-sorted-ii) | [[贪心算法](../greedy/README.md)] | Medium | -| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心算法](../greedy/README.md)] | Medium | -| 944 | [删列造序](../../problems/delete-columns-to-make-sorted) | [[贪心算法](../greedy/README.md)] | Easy | -| 936 | [戳印序列](../../problems/stamping-the-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | -| 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 921 | [使括号有效的最少添加](../../problems/minimum-add-to-make-parentheses-valid) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 910 | [最小差值 II](../../problems/smallest-range-ii) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 874 | [模拟行走机器人](../../problems/walking-robot-simulation) | [[贪心算法](../greedy/README.md)] | Easy | -| 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 861 | [翻转矩阵后的得分](../../problems/score-after-flipping-matrix) | [[贪心算法](../greedy/README.md)] | Medium | -| 860 | [柠檬水找零](../../problems/lemonade-change) | [[贪心算法](../greedy/README.md)] | Easy | -| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | -| 757 | [设置交集大小至少为2](../../problems/set-intersection-size-at-least-two) | [[贪心算法](../greedy/README.md)] | Hard | -| 738 | [单调递增的数字](../../problems/monotone-increasing-digits) | [[贪心算法](../greedy/README.md)] | Medium | -| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 651 | [4键键盘](../../problems/4-keys-keyboard) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 649 | [Dota2 参议院](../../problems/dota2-senate) | [[贪心算法](../greedy/README.md)] | Medium | -| 630 | [课程表 III](../../problems/course-schedule-iii) | [[贪心算法](../greedy/README.md)] | Hard | -| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | -| 502 | [IPO](../../problems/ipo) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | -| 484 | [寻找排列](../../problems/find-permutation) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | -| 455 | [分发饼干](../../problems/assign-cookies) | [[贪心算法](../greedy/README.md)] | Easy | -| 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 435 | [无重叠区间](../../problems/non-overlapping-intervals) | [[贪心算法](../greedy/README.md)] | Medium | -| 406 | [根据身高重建队列](../../problems/queue-reconstruction-by-height) | [[贪心算法](../greedy/README.md)] | Medium | -| 402 | [移掉K位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 330 | [按要求补齐数组](../../problems/patching-array) | [[贪心算法](../greedy/README.md)] | Hard | -| 321 | [拼接最大数](../../problems/create-maximum-number) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 135 | [分发糖果](../../problems/candy) | [[贪心算法](../greedy/README.md)] | Hard | -| 134 | [加油站](../../problems/gas-station) | [[贪心算法](../greedy/README.md)] | Medium | -| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 55 | [跳跃游戏](../../problems/jump-game) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Hard | -| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index cce72614d..12e3dde8b 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1679 | [K 和数对的最大数目](../../problems/max-number-of-k-sum-pairs) | [[哈希表](../hash-table/README.md)] | Medium | | 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/heap/README.md b/tag/heap/README.md index 8e2580486..3eb76f0d0 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | | 1642 | [可以到达的最远建筑](../../problems/furthest-building-you-can-reach) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1439 | [有序矩阵中的第 k 个最小数组和](../../problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | [[堆](../heap/README.md)] | Hard | | 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] | Medium | diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md index 06c012aa3..592ea3e0f 100644 --- a/tag/line-sweep/README.md +++ b/tag/line-sweep/README.md @@ -9,9 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[Line Sweep](../line-sweep/README.md)] | Medium | -| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | -| 391 | [完美矩形](../../problems/perfect-rectangle) | [[Line Sweep](../line-sweep/README.md)] | Hard | -| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index 5ff4c0c59..b0d6454fe 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 1669 | [合并两个链表](../../problems/merge-in-between-linked-lists) | [[链表](../linked-list/README.md)] | Medium | | 1634 | [求两个多项式链表的和](../../problems/add-two-polynomials-represented-as-linked-lists) 🔒 | [[链表](../linked-list/README.md)] | Medium | | 1474 | [删除链表 M 个节点之后的 N 个节点](../../problems/delete-n-nodes-after-m-nodes-of-a-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Easy | | 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 42045a79a..9b412a55f 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1680 | [连接连续二进制数字](../../problems/concatenation-of-consecutive-binary-numbers) | [[数学](../math/README.md)] | Medium | | 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | | 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1627 | [带阈值的图连通性](../../problems/graph-connectivity-with-threshold) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/oop/README.md b/tag/oop/README.md new file mode 100644 index 000000000..dac9adc9e --- /dev/null +++ b/tag/oop/README.md @@ -0,0 +1,11 @@ + + + + + + + +## [话题分类](../README.md) > + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index c9d6641d8..52afd5989 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -9,16 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | -| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 855 | [考场就座](../../problems/exam-room) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 846 | [一手顺子](../../problems/hand-of-straights) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 731 | [我的日程安排表 II](../../problems/my-calendar-ii) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 683 | [K 个关闭的灯泡](../../problems/k-empty-slots) 🔒 | [[Ordered Map](../ordered-map/README.md)] | Hard | -| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index d6e9ab81b..b1cd7a2b0 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -9,8 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | | 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[递归](../recursion/README.md)] | Easy | | 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | @@ -23,5 +25,9 @@ | 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | +| 395 | [至少有K个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | | 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/rejection-sampling/README.md b/tag/rejection-sampling/README.md index fc2d396f2..8622c93e1 100644 --- a/tag/rejection-sampling/README.md +++ b/tag/rejection-sampling/README.md @@ -9,5 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | -| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | diff --git a/tag/reservoir-sampling/README.md b/tag/reservoir-sampling/README.md index 1fc516eb3..7d9ca74cc 100644 --- a/tag/reservoir-sampling/README.md +++ b/tag/reservoir-sampling/README.md @@ -9,5 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 398 | [随机数索引](../../problems/random-pick-index) | [[蓄水池抽样](../reservoir-sampling/README.md)] | Medium | -| 382 | [链表随机节点](../../problems/linked-list-random-node) | [[蓄水池抽样](../reservoir-sampling/README.md)] | Medium | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index 674b421a7..d01d133ef 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -29,6 +29,7 @@ | 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 480 | [滑动窗口中位数](../../problems/sliding-window-median) | [[Sliding Window](../sliding-window/README.md)] | Hard | | 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 395 | [至少有K个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index a3fe0b99d..d4e07b582 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -51,6 +51,7 @@ | 976 | [三角形的最大周长](../../problems/largest-perimeter-triangle) | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Easy | | 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | | 969 | [煎饼排序](../../problems/pancake-sorting) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 922 | [按奇偶排序数组 II](../../problems/sort-array-by-parity-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | | 853 | [车队](../../problems/car-fleet) | [[排序](../sort/README.md)] | Medium | | 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/stack/README.md b/tag/stack/README.md index cbb911901..e3cdc14db 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | | 1598 | [文件夹操作日志搜集器](../../problems/crawler-log-folder) | [[栈](../stack/README.md)] | Easy | | 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | | 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | @@ -56,6 +57,7 @@ | 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Hard | | 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | | 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | | 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | | 224 | [基本计算器](../../problems/basic-calculator) | [[栈](../stack/README.md)] [[数学](../math/README.md)] | Hard | | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index eb4156a35..ca3d0540d 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1678 | [设计 Goal 解析器](../../problems/goal-parser-interpretation) | [[字符串](../string/README.md)] | Easy | +| 1668 | [最大重复子字符串](../../problems/maximum-repeating-substring) | [[字符串](../string/README.md)] | Easy | +| 1662 | [检查两个字符串数组是否相等](../../problems/check-if-two-string-arrays-are-equivalent) | [[字符串](../string/README.md)] | Easy | | 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1624 | [两个相同字符之间的最长子字符串](../../problems/largest-substring-between-two-equal-characters) | [[字符串](../string/README.md)] | Easy | @@ -173,7 +176,7 @@ | 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | | 271 | [字符串的编码与解码](../../problems/encode-and-decode-strings) 🔒 | [[字符串](../string/README.md)] | Medium | | 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[字符串](../string/README.md)] | Medium | +| 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | | 214 | [最短回文串](../../problems/shortest-palindrome) | [[字符串](../string/README.md)] | Hard | | 186 | [翻转字符串里的单词 II](../../problems/reverse-words-in-a-string-ii) 🔒 | [[字符串](../string/README.md)] | Medium | | 165 | [比较版本号](../../problems/compare-version-numbers) | [[字符串](../string/README.md)] | Medium | @@ -205,7 +208,7 @@ | 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 20 | [有效的括号](../../problems/valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | -| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 14 | [最长公共前缀](../../problems/longest-common-prefix) | [[字符串](../string/README.md)] | Easy | | 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/tags.json b/tag/tags.json index 8652fdf51..7be43fb7b 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -59,16 +59,16 @@ "Slug": "two-pointers", "TranslatedName": "双指针" }, - { - "Name": "Backtracking", - "Slug": "backtracking", - "TranslatedName": "回溯算法" - }, { "Name": "Stack", "Slug": "stack", "TranslatedName": "栈" }, + { + "Name": "Backtracking", + "Slug": "backtracking", + "TranslatedName": "回溯算法" + }, { "Name": "Design", "Slug": "design", @@ -104,6 +104,11 @@ "Slug": "sliding-window", "TranslatedName": "Sliding Window" }, + { + "Name": "Recursion", + "Slug": "recursion", + "TranslatedName": "递归" + }, { "Name": "Divide and Conquer", "Slug": "divide-and-conquer", @@ -114,11 +119,6 @@ "Slug": "trie", "TranslatedName": "字典树" }, - { - "Name": "Recursion", - "Slug": "recursion", - "TranslatedName": "递归" - }, { "Name": "Segment Tree", "Slug": "segment-tree", @@ -179,6 +179,11 @@ "Slug": "rolling-hash", "TranslatedName": "Rolling Hash" }, + { + "Name": "", + "Slug": "dequeue", + "TranslatedName": "" + }, { "Name": "Rejection Sampling", "Slug": "rejection-sampling", @@ -189,14 +194,19 @@ "Slug": "reservoir-sampling", "TranslatedName": "蓄水池抽样" }, + { + "Name": "Suffix Array", + "Slug": "suffix-array", + "TranslatedName": "Suffix Array" + }, { "Name": "Memoization", "Slug": "memoization", "TranslatedName": "记忆化" }, { - "Name": "Suffix Array", - "Slug": "suffix-array", - "TranslatedName": "Suffix Array" + "Name": "", + "Slug": "oop", + "TranslatedName": "" } ] \ No newline at end of file diff --git a/tag/tree/README.md b/tag/tree/README.md index 230b0b3af..56d129a2d 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,9 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1650 | [Lowest Common Ancestor of a Binary Tree III](../../problems/lowest-common-ancestor-of-a-binary-tree-iii) 🔒 | [[树](../tree/README.md)] | Medium | +| 1676 | [Lowest Common Ancestor of a Binary Tree IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1666 | [Change the Root of a Binary Tree](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1660 | [纠正二叉树](../../problems/correct-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | +| 1650 | [二叉树的最近公共祖先 III](../../problems/lowest-common-ancestor-of-a-binary-tree-iii) 🔒 | [[树](../tree/README.md)] | Medium | | 1644 | [二叉树的最近公共祖先 II](../../problems/lowest-common-ancestor-of-a-binary-tree-ii) 🔒 | [[树](../tree/README.md)] | Medium | -| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1609 | [奇偶树](../../problems/even-odd-tree) | [[树](../tree/README.md)] | Medium | | 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | @@ -62,7 +65,7 @@ | 951 | [翻转等价二叉树](../../problems/flip-equivalent-binary-trees) | [[树](../tree/README.md)] | Medium | | 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 919 | [完全二叉树插入器](../../problems/complete-binary-tree-inserter) | [[树](../tree/README.md)] | Medium | -| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] | Medium | | 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | @@ -96,7 +99,7 @@ | 582 | [杀死进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | | 572 | [另一个树的子树](../../problems/subtree-of-another-tree) | [[树](../tree/README.md)] | Easy | | 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 559 | [N叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 559 | [N 叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 549 | [二叉树中最长的连续序列](../../problems/binary-tree-longest-consecutive-sequence-ii) 🔒 | [[树](../tree/README.md)] | Medium | | 545 | [二叉树的边界](../../problems/boundary-of-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | | 543 | [二叉树的直径](../../problems/diameter-of-binary-tree) | [[树](../tree/README.md)] | Easy | @@ -112,7 +115,7 @@ | 449 | [序列化和反序列化二叉搜索树](../../problems/serialize-and-deserialize-bst) | [[树](../tree/README.md)] | Medium | | 437 | [路径总和 III](../../problems/path-sum-iii) | [[树](../tree/README.md)] | Medium | | 431 | [将 N 叉树编码为二叉树](../../problems/encode-n-ary-tree-to-binary-tree) 🔒 | [[树](../tree/README.md)] | Hard | -| 429 | [N叉树的层序遍历](../../problems/n-ary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 429 | [N 叉树的层序遍历](../../problems/n-ary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 428 | [序列化和反序列化 N 叉树](../../problems/serialize-and-deserialize-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard | | 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | | 404 | [左叶子之和](../../problems/sum-of-left-leaves) | [[树](../tree/README.md)] | Easy | @@ -150,13 +153,13 @@ | 107 | [二叉树的层次遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 103 | [二叉树的锯齿形层次遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 102 | [二叉树的层序遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 100 | [相同的树](../../problems/same-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 99 | [恢复二叉搜索树](../../problems/recover-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | | 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index e21f00156..58d26671c 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -22,6 +22,7 @@ | 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 986 | [区间列表的交集](../../problems/interval-list-intersections) | [[双指针](../two-pointers/README.md)] | Medium | | 977 | [有序数组的平方](../../problems/squares-of-a-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 925 | [长按键入](../../problems/long-pressed-name) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 923 | [三数之和的多种可能](../../problems/3sum-with-multiplicity) | [[双指针](../two-pointers/README.md)] | Medium | From b45e5b49aec9813b900e4fd88badcf77bf7f5737 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 7 Dec 2020 15:55:48 +0800 Subject: [PATCH 111/145] A: new --- .../as-far-from-land-as-possible/README.md | 44 ++++++++----------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/problems/as-far-from-land-as-possible/README.md b/problems/as-far-from-land-as-possible/README.md index 827a3150a..ea5e33b61 100644 --- a/problems/as-far-from-land-as-possible/README.md +++ b/problems/as-far-from-land-as-possible/README.md @@ -11,44 +11,36 @@ ## [1162. As Far from Land as Possible (Medium)](https://leetcode.com/problems/as-far-from-land-as-possible "地图分析") -

        Given an N x N grid containing only values 0 and 1, where 0 represents water and 1 represents land, find a water cell such that its distance to the nearest land cell is maximized and return the distance.

        +

        Given an n x n grid containing only values 0 and 1, where 0 represents water and 1 represents land, find a water cell such that its distance to the nearest land cell is maximized, and return the distance. If no land or water exists in the grid, return -1.

        -

        The distance used in this problem is the Manhattan distance: the distance between two cells (x0, y0) and (x1, y1) is |x0 - x1| + |y0 - y1|.

        - -

        If no land or water exists in the grid, return -1.

        +

        The distance used in this problem is the Manhattan distance: the distance between two cells (x0, y0) and (x1, y1) is |x0 - x1| + |y0 - y1|.

         

        -

        Example 1:

        - -

        - +
        -Input: [[1,0,1],[0,0,0],[1,0,1]]
        -Output: 2
        -Explanation: 
        -The cell (1, 1) is as far as possible from all the land with distance 2.
        +Input: grid = [[1,0,1],[0,0,0],[1,0,1]]
        +Output: 2
        +Explanation: The cell (1, 1) is as far as possible from all the land with distance 2.
         

        Example 2:

        - -

        - +
        -Input: [[1,0,0],[0,0,0],[0,0,0]]
        -Output: 4
        -Explanation: 
        -The cell (2, 2) is as far as possible from all the land with distance 4.
        +Input: grid = [[1,0,0],[0,0,0],[0,0,0]]
        +Output: 4
        +Explanation: The cell (2, 2) is as far as possible from all the land with distance 4.
         

         

        - -

        Note:

        - -
          -
        1. 1 <= grid.length == grid[0].length <= 100
        2. -
        3. grid[i][j] is 0 or 1
        4. -
        +

        Constraints:

        + +
          +
        • n == grid.length
        • +
        • n == grid[i].length
        • +
        • 1 <= n <= 100
        • +
        • grid[i][j] is 0 or 1
        • +
        ### Related Topics [[Breadth-first Search](../../tag/breadth-first-search/README.md)] From e1da1245dd74c20bde2a0cea2a8b564913b5c189 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 14 Dec 2020 13:49:41 +0800 Subject: [PATCH 112/145] A: new --- README.md | 12 +- problems/binary-trees-with-factors/README.md | 26 ++-- .../README.md | 8 +- .../README.md | 2 +- .../constrained-subsequence-sum/README.md | 8 +- .../count-of-matches-in-tournament/README.md | 68 ++++++++++ .../README.md | 66 ++++++++++ problems/decode-string/README.md | 4 +- .../README.md | 111 ++++++++++++++++ problems/design-circular-queue/README.md | 59 +++++---- problems/find-eventual-safe-states/README.md | 34 +++-- .../implement-stack-using-queues/README.md | 5 +- problems/invalid-tweets/README.md | 14 +++ problems/invalid-tweets/mysql_schemas.sql | 4 + problems/linked-list-random-node/README.md | 46 +++++-- .../README.md | 29 +++++ .../README.md | 78 ++++++++++++ problems/minimum-incompatibility/README.md | 2 +- .../number-of-lines-to-write-string/README.md | 59 ++++----- problems/palindrome-partitioning/README.md | 29 +++-- .../README.md | 67 ++++++++++ problems/plus-one-linked-list/README.md | 1 + problems/short-encoding-of-words/README.md | 33 +++-- .../README.md | 3 + problems/stone-game-vi/README.md | 84 +++++++++++++ problems/stone-game-vii/README.md | 64 ++++++++++ .../README.md | 65 ++++++++++ tag/README.md | 6 +- tag/backtracking/README.md | 3 +- tag/bit-manipulation/README.md | 54 -------- tag/breadth-first-search/README.md | 77 ++++++++++++ tag/depth-first-search/README.md | 4 +- tag/divide-and-conquer/README.md | 20 --- tag/dynamic-programming/README.md | 5 + tag/graph/README.md | 48 ------- tag/greedy/README.md | 118 ++++++++++++++++++ tag/linked-list/README.md | 42 ------- tag/math/README.md | 1 + tag/ordered-map/README.md | 14 +++ tag/random/README.md | 6 - tag/recursion/README.md | 2 + tag/rejection-sampling/README.md | 2 + tag/segment-tree/README.md | 1 + tag/sort/README.md | 1 + tag/string/README.md | 2 + tag/tags.json | 20 +-- tag/topological-sort/README.md | 6 - tag/tree/README.md | 4 +- tag/two-pointers/README.md | 1 + 49 files changed, 1091 insertions(+), 327 deletions(-) create mode 100644 problems/count-of-matches-in-tournament/README.md create mode 100644 problems/count-the-number-of-consistent-strings/README.md create mode 100644 problems/delivering-boxes-from-storage-to-ports/README.md create mode 100644 problems/invalid-tweets/README.md create mode 100644 problems/invalid-tweets/mysql_schemas.sql create mode 100644 problems/longest-palindromic-subsequence-ii/README.md create mode 100644 problems/maximum-height-by-stacking-cuboids/README.md create mode 100644 problems/partitioning-into-minimum-number-of-deci-binary-numbers/README.md create mode 100644 problems/stone-game-vi/README.md create mode 100644 problems/stone-game-vii/README.md create mode 100644 problems/sum-of-absolute-differences-in-a-sorted-array/README.md diff --git a/README.md b/README.md index 974a91e7d..8ebdd386d 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,16 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1691 | [Maximum Height by Stacking Cuboids](https://leetcode.com/problems/maximum-height-by-stacking-cuboids "堆叠长方体的最大高度") | [Go](problems/maximum-height-by-stacking-cuboids) | Hard | +| 1690 | [Stone Game VII](https://leetcode.com/problems/stone-game-vii "石子游戏 VII") | [Go](problems/stone-game-vii) | Medium | +| 1689 | [Partitioning Into Minimum Number Of Deci-Binary Numbers](https://leetcode.com/problems/partitioning-into-minimum-number-of-deci-binary-numbers "十-二进制数的最少数目") | [Go](problems/partitioning-into-minimum-number-of-deci-binary-numbers) | Medium | +| 1688 | [Count of Matches in Tournament](https://leetcode.com/problems/count-of-matches-in-tournament "比赛中的配对次数") | [Go](problems/count-of-matches-in-tournament) | Easy | +| 1687 | [Delivering Boxes from Storage to Ports](https://leetcode.com/problems/delivering-boxes-from-storage-to-ports "从仓库到码头运输箱子") | [Go](problems/delivering-boxes-from-storage-to-ports) | Hard | +| 1686 | [Stone Game VI](https://leetcode.com/problems/stone-game-vi "石子游戏 VI") | [Go](problems/stone-game-vi) | Medium | +| 1685 | [Sum of Absolute Differences in a Sorted Array](https://leetcode.com/problems/sum-of-absolute-differences-in-a-sorted-array "有序数组中差绝对值之和") | [Go](problems/sum-of-absolute-differences-in-a-sorted-array) | Medium | +| 1684 | [Count the Number of Consistent Strings](https://leetcode.com/problems/count-the-number-of-consistent-strings "统计一致字符串的数目") | [Go](problems/count-the-number-of-consistent-strings) | Easy | +| 1683 | [Invalid Tweets](https://leetcode.com/problems/invalid-tweets) 🔒 | [MySQL](problems/invalid-tweets) | Easy | +| 1682 | [Longest Palindromic Subsequence II](https://leetcode.com/problems/longest-palindromic-subsequence-ii) 🔒 | [Go](problems/longest-palindromic-subsequence-ii) | Medium | | 1681 | [Minimum Incompatibility](https://leetcode.com/problems/minimum-incompatibility "最小不兼容性") | [Go](problems/minimum-incompatibility) | Hard | | 1680 | [Concatenation of Consecutive Binary Numbers](https://leetcode.com/problems/concatenation-of-consecutive-binary-numbers "连接连续二进制数字") | [Go](problems/concatenation-of-consecutive-binary-numbers) | Medium | | 1679 | [Max Number of K-Sum Pairs](https://leetcode.com/problems/max-number-of-k-sum-pairs "K 和数对的最大数目") | [Go](problems/max-number-of-k-sum-pairs) | Medium | @@ -85,7 +95,7 @@ LeetCode Problems' Solutions | 1669 | [Merge In Between Linked Lists](https://leetcode.com/problems/merge-in-between-linked-lists "合并两个链表") | [Go](problems/merge-in-between-linked-lists) | Medium | | 1668 | [Maximum Repeating Substring](https://leetcode.com/problems/maximum-repeating-substring "最大重复子字符串") | [Go](problems/maximum-repeating-substring) | Easy | | 1667 | [Fix Names in a Table](https://leetcode.com/problems/fix-names-in-a-table) 🔒 | [MySQL](problems/fix-names-in-a-table) | Easy | -| 1666 | [Change the Root of a Binary Tree](https://leetcode.com/problems/change-the-root-of-a-binary-tree) 🔒 | [Go](problems/change-the-root-of-a-binary-tree) | Medium | +| 1666 | [Change the Root of a Binary Tree](https://leetcode.com/problems/change-the-root-of-a-binary-tree "改变二叉树的根节点") 🔒 | [Go](problems/change-the-root-of-a-binary-tree) | Medium | | 1665 | [Minimum Initial Energy to Finish Tasks](https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks "完成所有任务的最少初始能量") | [Go](problems/minimum-initial-energy-to-finish-tasks) | Hard | | 1664 | [Ways to Make a Fair Array](https://leetcode.com/problems/ways-to-make-a-fair-array "生成平衡数组的方案数") | [Go](problems/ways-to-make-a-fair-array) | Medium | | 1663 | [Smallest String With A Given Numeric Value](https://leetcode.com/problems/smallest-string-with-a-given-numeric-value "具有给定数值的最小字符串") | [Go](problems/smallest-string-with-a-given-numeric-value) | Medium | diff --git a/problems/binary-trees-with-factors/README.md b/problems/binary-trees-with-factors/README.md index acfc166b7..4a650658d 100644 --- a/problems/binary-trees-with-factors/README.md +++ b/problems/binary-trees-with-factors/README.md @@ -11,33 +11,31 @@ ## [823. Binary Trees With Factors (Medium)](https://leetcode.com/problems/binary-trees-with-factors "带因子的二叉树") -

        Given an array of unique integers, each integer is strictly greater than 1.

        +

        Given an array of unique integers, arr, where each integer arr[i] is strictly greater than 1.

        -

        We make a binary tree using these integers and each number may be used for any number of times.

        +

        We make a binary tree using these integers, and each number may be used for any number of times. Each non-leaf node's value should be equal to the product of the values of its children.

        -

        Each non-leaf node's value should be equal to the product of the values of it's children.

        - -

        How many binary trees can we make?  Return the answer modulo 10 ** 9 + 7.

        +

        Return the number of binary trees we can make. The answer may be too large so return the answer modulo 109 + 7.

        +

         

        Example 1:

        -Input: A = [2, 4]
        +Input: arr = [2,4]
         Output: 3
         Explanation: We can make these trees: [2], [4], [4, 2, 2]

        Example 2:

        -Input: A = [2, 4, 5, 10]
        -Output: 7
        +Input: arr = [2,4,5,10]
        +Output: 7
         Explanation: We can make these trees: [2], [4], [5], [10], [4, 2, 2], [10, 2, 5], [10, 5, 2].

         

        +

        Constraints:

        -

        Note:

        - -
          -
        1. 1 <= A.length <= 1000.
        2. -
        3. 2 <= A[i] <= 10 ^ 9.
        4. -
        +
          +
        • 1 <= arr.length <= 1000
        • +
        • 2 <= arr[i] <= 109
        • +
        diff --git a/problems/build-an-array-with-stack-operations/README.md b/problems/build-an-array-with-stack-operations/README.md index 0f11e7d05..4fdc98a70 100644 --- a/problems/build-an-array-with-stack-operations/README.md +++ b/problems/build-an-array-with-stack-operations/README.md @@ -21,11 +21,7 @@
      • If the target array is already built, stop reading more elements.
      -

      You are guaranteed that the target array is strictly increasing, only containing numbers between 1 to n inclusive.

      - -

      Return the operations to build the target array.

      - -

      You are guaranteed that the answer is unique.

      +

      Return the operations to build the target array. You are guaranteed that the answer is unique.

       

      Example 1:

      @@ -66,7 +62,7 @@ Read number 3 and automatically push in the array -> [1,3]
      • 1 <= target.length <= 100
      • -
      • 1 <= target[i] <= 100
      • +
      • 1 <= target[i] <= n
      • 1 <= n <= 100
      • target is strictly increasing.
      diff --git a/problems/change-the-root-of-a-binary-tree/README.md b/problems/change-the-root-of-a-binary-tree/README.md index 77a2fe0f1..647535119 100644 --- a/problems/change-the-root-of-a-binary-tree/README.md +++ b/problems/change-the-root-of-a-binary-tree/README.md @@ -9,7 +9,7 @@                  [Next >](../fix-names-in-a-table "Fix Names in a Table") -## [1666. Change the Root of a Binary Tree (Medium)](https://leetcode.com/problems/change-the-root-of-a-binary-tree "") +## [1666. Change the Root of a Binary Tree (Medium)](https://leetcode.com/problems/change-the-root-of-a-binary-tree "改变二叉树的根节点") diff --git a/problems/constrained-subsequence-sum/README.md b/problems/constrained-subsequence-sum/README.md index 7c76eaa23..1854b10ec 100644 --- a/problems/constrained-subsequence-sum/README.md +++ b/problems/constrained-subsequence-sum/README.md @@ -11,9 +11,9 @@ ## [1425. Constrained Subsequence Sum (Hard)](https://leetcode.com/problems/constrained-subsequence-sum "带限制的子序列和") -

      Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence, nums[i] and nums[j], where i < j, the condition j - i <= k is satisfied.

      +

      Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence, nums[i] and nums[j], where i < j, the condition j - i <= k is satisfied.

      -

      subsequence of an array is obtained by deleting some number of elements (can be zero) from the array, leaving the remaining elements in their original order.

      +

      A subsequence of an array is obtained by deleting some number of elements (can be zero) from the array, leaving the remaining elements in their original order.

       

      Example 1:

      @@ -44,8 +44,8 @@

      Constraints:

        -
      • 1 <= k <= nums.length <= 10^5
      • -
      • -10^4 <= nums[i] <= 10^4
      • +
      • 1 <= k <= nums.length <= 105
      • +
      • -104 <= nums[i] <= 104
      ### Related Topics diff --git a/problems/count-of-matches-in-tournament/README.md b/problems/count-of-matches-in-tournament/README.md new file mode 100644 index 000000000..d981d3783 --- /dev/null +++ b/problems/count-of-matches-in-tournament/README.md @@ -0,0 +1,68 @@ + + + + + + + +[< Previous](../delivering-boxes-from-storage-to-ports "Delivering Boxes from Storage to Ports") +                 +[Next >](../partitioning-into-minimum-number-of-deci-binary-numbers "Partitioning Into Minimum Number Of Deci-Binary Numbers") + +## [1688. Count of Matches in Tournament (Easy)](https://leetcode.com/problems/count-of-matches-in-tournament "比赛中的配对次数") + +

      You are given an integer n, the number of teams in a tournament that has strange rules:

      + +
        +
      • If the current number of teams is even, each team gets paired with another team. A total of n / 2 matches are played, and n / 2 teams advance to the next round.
      • +
      • If the current number of teams is odd, one team randomly advances in the tournament, and the rest gets paired. A total of (n - 1) / 2 matches are played, and (n - 1) / 2 + 1 teams advance to the next round.
      • +
      + +

      Return the number of matches played in the tournament until a winner is decided.

      + +

       

      +

      Example 1:

      + +
      +Input: n = 7
      +Output: 6
      +Explanation: Details of the tournament: 
      +- 1st Round: Teams = 7, Matches = 3, and 4 teams advance.
      +- 2nd Round: Teams = 4, Matches = 2, and 2 teams advance.
      +- 3rd Round: Teams = 2, Matches = 1, and 1 team is declared the winner.
      +Total number of matches = 3 + 2 + 1 = 6.
      +
      + +

      Example 2:

      + +
      +Input: n = 14
      +Output: 13
      +Explanation: Details of the tournament:
      +- 1st Round: Teams = 14, Matches = 7, and 7 teams advance.
      +- 2nd Round: Teams = 7, Matches = 3, and 4 teams advance.
      +- 3rd Round: Teams = 4, Matches = 2, and 2 teams advance.
      +- 4th Round: Teams = 2, Matches = 1, and 1 team is declared the winner.
      +Total number of matches = 7 + 3 + 2 + 1 = 13.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= n <= 200
      • +
      + +### Related Topics + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
      +Hint 1 +Simulate the tournament as given in the statement. +
      + +
      +Hint 2 +Be careful when handling odd integers. +
      diff --git a/problems/count-the-number-of-consistent-strings/README.md b/problems/count-the-number-of-consistent-strings/README.md new file mode 100644 index 000000000..ac8713c98 --- /dev/null +++ b/problems/count-the-number-of-consistent-strings/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../invalid-tweets "Invalid Tweets") +                 +[Next >](../sum-of-absolute-differences-in-a-sorted-array "Sum of Absolute Differences in a Sorted Array") + +## [1684. Count the Number of Consistent Strings (Easy)](https://leetcode.com/problems/count-the-number-of-consistent-strings "统计一致字符串的数目") + +

      You are given a string allowed consisting of distinct characters and an array of strings words. A string is consistent if all characters in the string appear in the string allowed.

      + +

      Return the number of consistent strings in the array words.

      + +

       

      +

      Example 1:

      + +
      +Input: allowed = "ab", words = ["ad","bd","aaab","baa","badab"]
      +Output: 2
      +Explanation: Strings "aaab" and "baa" are consistent since they only contain characters 'a' and 'b'.
      +
      + +

      Example 2:

      + +
      +Input: allowed = "abc", words = ["a","b","c","ab","ac","bc","abc"]
      +Output: 7
      +Explanation: All strings are consistent.
      +
      + +

      Example 3:

      + +
      +Input: allowed = "cad", words = ["cc","acd","b","ba","bac","bad","ac","d"]
      +Output: 4
      +Explanation: Strings "cc", "acd", "ac", and "d" are consistent.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= words.length <= 104
      • +
      • 1 <= allowed.length <= 26
      • +
      • 1 <= words[i].length <= 10
      • +
      • The characters in allowed are distinct.
      • +
      • words[i] and allowed contain only lowercase English letters.
      • +
      + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
      +Hint 1 +A string is incorrect if it contains a character that is not allowed +
      + +
      +Hint 2 +Constraints are small enough for brute force +
      diff --git a/problems/decode-string/README.md b/problems/decode-string/README.md index d555f839c..b791ba287 100644 --- a/problems/decode-string/README.md +++ b/problems/decode-string/README.md @@ -13,11 +13,11 @@

      Given an encoded string, return its decoded string.

      -

      The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer.

      +

      The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer.

      You may assume that the input string is always valid; No extra white spaces, square brackets are well-formed, etc.

      -

      Furthermore, you may assume that the original data does not contain any digits and that digits are only for those repeat numbers, k. For example, there won't be input like 3a or 2[4].

      +

      Furthermore, you may assume that the original data does not contain any digits and that digits are only for those repeat numbers, k. For example, there won't be input like 3a or 2[4].

       

      Example 1:

      diff --git a/problems/delivering-boxes-from-storage-to-ports/README.md b/problems/delivering-boxes-from-storage-to-ports/README.md new file mode 100644 index 000000000..7d8a1ba48 --- /dev/null +++ b/problems/delivering-boxes-from-storage-to-ports/README.md @@ -0,0 +1,111 @@ + + + + + + + +[< Previous](../stone-game-vi "Stone Game VI") +                 +[Next >](../count-of-matches-in-tournament "Count of Matches in Tournament") + +## [1687. Delivering Boxes from Storage to Ports (Hard)](https://leetcode.com/problems/delivering-boxes-from-storage-to-ports "从仓库到码头运输箱子") + +

      You have the task of delivering some boxes from storage to their ports using only one ship. However, this ship has a limit on the number of boxes and the total weight that it can carry.

      + +

      You are given an array boxes, where boxes[i] = [ports​​i​, weighti], and three integers portsCount, maxBoxes, and maxWeight.

      + +
        +
      • ports​​i is the port where you need to deliver the ith box and weightsi is the weight of the ith box.
      • +
      • portsCount is the number of ports.
      • +
      • maxBoxes and maxWeight are the respective box and weight limits of the ship.
      • +
      + +

      The boxes need to be delivered in the order they are given. The ship will follow these steps:

      + +
        +
      • The ship will take some number of boxes from the boxes queue, not violating the maxBoxes and maxWeight constraints.
      • +
      • For each loaded box in order, the ship will make a trip to the port the box needs to be delivered to and deliver it. If the ship is already at the correct port, no trip is needed, and the box can immediately be delivered.
      • +
      • The ship then makes a return trip to storage to take more boxes from the queue.
      • +
      + +

      The ship must end at storage after all the boxes have been delivered.

      + +

      Return the minimum number of trips the ship needs to make to deliver all boxes to their respective ports.

      + +

       

      +

      Example 1:

      + +
      +Input: boxes = [[1,1],[2,1],[1,1]], portsCount = 2, maxBoxes = 3, maxWeight = 3
      +Output: 4
      +Explanation: The optimal strategy is as follows: 
      +- The ship takes all the boxes in the queue, goes to port 1, then port 2, then port 1 again, then returns to storage. 4 trips.
      +So the total number of trips is 4.
      +Note that the first and third boxes cannot be delivered together because the boxes need to be delivered in order (i.e. the second box needs to be delivered at port 2 before the third box).
      +
      + +

      Example 2:

      + +
      +Input: boxes = [[1,2],[3,3],[3,1],[3,1],[2,4]], portsCount = 3, maxBoxes = 3, maxWeight = 6
      +Output: 6
      +Explanation: The optimal strategy is as follows: 
      +- The ship takes the first box, goes to port 1, then returns to storage. 2 trips.
      +- The ship takes the second, third and fourth boxes, goes to port 3, then returns to storage. 2 trips.
      +- The ship takes the fifth box, goes to port 3, then returns to storage. 2 trips.
      +So the total number of trips is 2 + 2 + 2 = 6.
      +
      + +

      Example 3:

      + +
      +Input: boxes = [[1,4],[1,2],[2,1],[2,1],[3,2],[3,4]], portsCount = 3, maxBoxes = 6, maxWeight = 7
      +Output: 6
      +Explanation: The optimal strategy is as follows:
      +- The ship takes the first and second boxes, goes to port 1, then returns to storage. 2 trips.
      +- The ship takes the third and fourth boxes, goes to port 2, then returns to storage. 2 trips.
      +- The ship takes the fifth and sixth boxes, goes to port 3, then returns to storage. 2 trips.
      +So the total number of trips is 2 + 2 + 2 = 6.
      +
      + +

      Example 4:

      + +
      +Input: boxes = [[2,4],[2,5],[3,1],[3,2],[3,7],[3,1],[4,4],[1,3],[5,2]], portsCount = 5, maxBoxes = 5, maxWeight = 7
      +Output: 14
      +Explanation: The optimal strategy is as follows:
      +- The ship takes the first box, goes to port 2, then storage. 2 trips.
      +- The ship takes the second box, goes to port 2, then storage. 2 trips.
      +- The ship takes the third and fourth boxes, goes to port 3, then storage. 2 trips.
      +- The ship takes the fifth box, goes to port 3, then storage. 2 trips.
      +- The ship takes the sixth and seventh boxes, goes to port 3, then port 4, then storage. 3 trips. 
      +- The ship takes the eighth and ninth boxes, goes to port 1, then port 5, then storage. 3 trips.
      +So the total number of trips is 2 + 2 + 2 + 2 + 3 + 3 = 14.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= boxes.length <= 105
      • +
      • 1 <= portsCount, maxBoxes, maxWeight <= 105
      • +
      • 1 <= ports​​i <= portsCount
      • +
      • 1 <= weightsi <= maxWeight
      • +
      + +### Related Topics + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
      +Hint 1 +Try to think of the most basic dp which is n^2 now optimize it +
      + +
      +Hint 2 +Think of any range query data structure to optimize +
      diff --git a/problems/design-circular-queue/README.md b/problems/design-circular-queue/README.md index 5d16b4293..fd4ce3cc6 100644 --- a/problems/design-circular-queue/README.md +++ b/problems/design-circular-queue/README.md @@ -15,44 +15,53 @@

      One of the benefits of the circular queue is that we can make use of the spaces in front of the queue. In a normal queue, once the queue becomes full, we cannot insert the next element even if there is a space in front of the queue. But using the circular queue, we can use the space to store new values.

      -

      Your implementation should support following operations:

      +

      Implementation the MyCircularQueue class:

        -
      • MyCircularQueue(k): Constructor, set the size of the queue to be k.
      • -
      • Front: Get the front item from the queue. If the queue is empty, return -1.
      • -
      • Rear: Get the last item from the queue. If the queue is empty, return -1.
      • -
      • enQueue(value): Insert an element into the circular queue. Return true if the operation is successful.
      • -
      • deQueue(): Delete an element from the circular queue. Return true if the operation is successful.
      • -
      • isEmpty(): Checks whether the circular queue is empty or not.
      • -
      • isFull(): Checks whether the circular queue is full or not.
      • +
      • MyCircularQueue(k) Initializes the object with the size of the queue to be k.
      • +
      • int Front() Gets the front item from the queue. If the queue is empty, return -1.
      • +
      • int Rear() Gets the last item from the queue. If the queue is empty, return -1.
      • +
      • boolean enQueue(int value) Inserts an element into the circular queue. Return true if the operation is successful.
      • +
      • boolean deQueue() Deletes an element from the circular queue. Return true if the operation is successful.
      • +
      • boolean isEmpty() Checks whether the circular queue is empty or not.
      • +
      • boolean isFull() Checks whether the circular queue is full or not.

       

      - -

      Example:

      +

      Example 1:

      -MyCircularQueue circularQueue = new MyCircularQueue(3); // set the size to be 3
      -circularQueue.enQueue(1);  // return true
      -circularQueue.enQueue(2);  // return true
      -circularQueue.enQueue(3);  // return true
      -circularQueue.enQueue(4);  // return false, the queue is full
      -circularQueue.Rear();  // return 3
      -circularQueue.isFull();  // return true
      -circularQueue.deQueue();  // return true
      -circularQueue.enQueue(4);  // return true
      -circularQueue.Rear();  // return 4
      +Input
      +["MyCircularQueue", "enQueue", "enQueue", "enQueue", "enQueue", "Rear", "isFull", "deQueue", "enQueue", "Rear"]
      +[[3], [1], [2], [3], [4], [], [], [], [4], []]
      +Output
      +[null, true, true, true, false, 3, true, true, true, 4]
      +
      +Explanation
      +MyCircularQueue myCircularQueue = new MyCircularQueue(3);
      +myCircularQueue.enQueue(1); // return True
      +myCircularQueue.enQueue(2); // return True
      +myCircularQueue.enQueue(3); // return True
      +myCircularQueue.enQueue(4); // return False
      +myCircularQueue.Rear();     // return 3
      +myCircularQueue.isFull();   // return True
      +myCircularQueue.deQueue();  // return True
      +myCircularQueue.enQueue(4); // return True
      +myCircularQueue.Rear();     // return 4
       
      -  -

      Note:

      +

       

      +

      Constraints:

        -
      • All values will be in the range of [0, 1000].
      • -
      • The number of operations will be in the range of [1, 1000].
      • -
      • Please do not use the built-in Queue library.
      • +
      • 1 <= k <= 1000
      • +
      • 0 <= value <= 1000
      • +
      • At most 3000 calls will be made to enQueue, deQueueFrontRearisEmpty, and isFull.
      +

       

      +Follow up: Could you solve the problem without using the built-in queue?  + ### Related Topics [[Design](../../tag/design/README.md)] [[Queue](../../tag/queue/README.md)] diff --git a/problems/find-eventual-safe-states/README.md b/problems/find-eventual-safe-states/README.md index 86188cf43..cad2aa1c7 100644 --- a/problems/find-eventual-safe-states/README.md +++ b/problems/find-eventual-safe-states/README.md @@ -11,30 +11,40 @@ ## [802. Find Eventual Safe States (Medium)](https://leetcode.com/problems/find-eventual-safe-states "找到最终的安全状态") -

      In a directed graph, we start at some node and every turn, walk along a directed edge of the graph.  If we reach a node that is terminal (that is, it has no outgoing directed edges), we stop.

      +

      We start at some node in a directed graph, and every turn, we walk along a directed edge of the graph. If we reach a terminal node (that is, it has no outgoing directed edges), we stop.

      -

      Now, say our starting node is eventually safe if and only if we must eventually walk to a terminal node.  More specifically, there exists a natural number K so that for any choice of where to walk, we must have stopped at a terminal node in less than K steps.

      +

      We define a starting node to be safe if we must eventually walk to a terminal node. More specifically, there is a natural number k, so that we must have stopped at a terminal node in less than k steps for any choice of where to walk.

      -

      Which nodes are eventually safe?  Return them as an array in sorted order.

      +

      Return an array containing all the safe nodes of the graph. The answer should be sorted in ascending order.

      -

      The directed graph has N nodes with labels 0, 1, ..., N-1, where N is the length of graph.  The graph is given in the following form: graph[i] is a list of labels j such that (i, j) is a directed edge of the graph.

      +

      The directed graph has n nodes with labels from 0 to n - 1, where n is the length of graph. The graph is given in the following form: graph[i] is a list of labels j such that (i, j) is a directed edge of the graph, going from node i to node j.

      +

       

      +

      Example 1:

      +Illustration of graph
      -Example:
       Input: graph = [[1,2],[2,3],[5],[0],[5],[],[]]
       Output: [2,4,5,6]
      -Here is a diagram of the above graph.
      -
      +Explanation: The given graph is shown above.
       
      -

      Illustration of graph

      +

      Example 2:

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

      Note:

      +

       

      +

      Constraints:

        -
      • graph will have length at most 10000.
      • -
      • The number of edges in the graph will not exceed 32000.
      • -
      • Each graph[i] will be a sorted list of different integers, chosen within the range [0, graph.length - 1].
      • +
      • n == graph.length
      • +
      • 1 <= n <= 104
      • +
      • 0 <= graph[i].legnth <= n
      • +
      • graph[i] is sorted in a strictly increasing order.
      • +
      • The graph may contain self-loops.
      • +
      • The number of edges in the graph will be in the range [1, 4 * 104].
      ### Related Topics diff --git a/problems/implement-stack-using-queues/README.md b/problems/implement-stack-using-queues/README.md index 569641522..ae6a8f5f7 100644 --- a/problems/implement-stack-using-queues/README.md +++ b/problems/implement-stack-using-queues/README.md @@ -29,8 +29,6 @@
    • Depending on your language, the queue may not be supported natively. You may simulate a queue using a list or deque (double-ended queue), as long as you use only a queue's standard operations.
    -

    Follow-up: Can you implement the stack such that each operation is amortized O(1) time complexity? In other words, performing n operations will take overall O(n) time even if one of those operations may take longer.

    -

     

    Example 1:

    @@ -59,6 +57,9 @@ myStack.empty(); // return False
  • All the calls to pop and top are valid.
  • +

     

    +Follow-up: Can you implement the stack such that each operation is amortized O(1) time complexity? In other words, performing n operations will take overall O(n) time even if one of those operations may take longer. + ### Related Topics [[Stack](../../tag/stack/README.md)] [[Design](../../tag/design/README.md)] diff --git a/problems/invalid-tweets/README.md b/problems/invalid-tweets/README.md new file mode 100644 index 000000000..121d0161d --- /dev/null +++ b/problems/invalid-tweets/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../longest-palindromic-subsequence-ii "Longest Palindromic Subsequence II") +                 +[Next >](../count-the-number-of-consistent-strings "Count the Number of Consistent Strings") + +## [1683. Invalid Tweets (Easy)](https://leetcode.com/problems/invalid-tweets "") + + diff --git a/problems/invalid-tweets/mysql_schemas.sql b/problems/invalid-tweets/mysql_schemas.sql new file mode 100644 index 000000000..f3839daf1 --- /dev/null +++ b/problems/invalid-tweets/mysql_schemas.sql @@ -0,0 +1,4 @@ +Create table If Not Exists Tweets(tweet_id int, content varchar(50)); +Truncate table Tweets; +insert into Tweets (tweet_id, content) values ('1', 'Vote for Biden'); +insert into Tweets (tweet_id, content) values ('2', 'Let us make America great again!'); diff --git a/problems/linked-list-random-node/README.md b/problems/linked-list-random-node/README.md index 87e4bdd5e..27ec5020a 100644 --- a/problems/linked-list-random-node/README.md +++ b/problems/linked-list-random-node/README.md @@ -11,24 +11,44 @@ ## [382. Linked List Random Node (Medium)](https://leetcode.com/problems/linked-list-random-node "链表随机节点") -

    Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen.

    +

    Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen.

    -

    Follow up:
    -What if the linked list is extremely large and its length is unknown to you? Could you solve this efficiently without using extra space? -

    +

     

    +

    Example 1:

    -

    Example:

    -// Init a singly linked list [1,2,3].
    -ListNode head = new ListNode(1);
    -head.next = new ListNode(2);
    -head.next.next = new ListNode(3);
    -Solution solution = new Solution(head);
    -
    +Input
    +["Solution", "getRandom", "getRandom", "getRandom", "getRandom", "getRandom"]
    +[[[1, 2, 3]], [], [], [], [], []]
    +Output
    +[null, 1, 3, 2, 2, 3]
    +
    +Explanation
    +Solution solution = new Solution([1, 2, 3]);
    +solution.getRandom(); // return 1
    +solution.getRandom(); // return 3
    +solution.getRandom(); // return 2
    +solution.getRandom(); // return 2
    +solution.getRandom(); // return 3
     // getRandom() should return either 1, 2, or 3 randomly. Each element should have equal probability of returning.
    -solution.getRandom();
     
    -

    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the linked list will be in the range [1, 104]
    • +
    • -104 <= Node.val <= 104
    • +
    • At most 104 calls will be made to getRandom.
    • +
    + +

     

    +

    Follow up:

    + +
      +
    • What if the linked list is extremely large and its length is unknown to you?
    • +
    • Could you solve this efficiently without using extra space?
    • +
    ### Related Topics [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] diff --git a/problems/longest-palindromic-subsequence-ii/README.md b/problems/longest-palindromic-subsequence-ii/README.md new file mode 100644 index 000000000..7480e4324 --- /dev/null +++ b/problems/longest-palindromic-subsequence-ii/README.md @@ -0,0 +1,29 @@ + + + + + + + +[< Previous](../minimum-incompatibility "Minimum Incompatibility") +                 +[Next >](../invalid-tweets "Invalid Tweets") + +## [1682. Longest Palindromic Subsequence II (Medium)](https://leetcode.com/problems/longest-palindromic-subsequence-ii "") + + + +### Related Topics + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +As with any good dp problem that uses palindromes, try building the palindrome from the edges +
    + +
    +Hint 2 +The prime point is to check that no two adjacent characters are equal, so save the past character while building the palindrome. +
    diff --git a/problems/maximum-height-by-stacking-cuboids/README.md b/problems/maximum-height-by-stacking-cuboids/README.md new file mode 100644 index 000000000..2f6182622 --- /dev/null +++ b/problems/maximum-height-by-stacking-cuboids/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../stone-game-vii "Stone Game VII") +                 +Next > + +## [1691. Maximum Height by Stacking Cuboids (Hard)](https://leetcode.com/problems/maximum-height-by-stacking-cuboids "堆叠长方体的最大高度") + +

    Given n cuboids where the dimensions of the ith cuboid is cuboids[i] = [widthi, lengthi, heighti] (0-indexed). Choose a subset of cuboids and place them on each other.

    + +

    You can place cuboid i on cuboid j if widthi <= widthj and lengthi <= lengthj and heighti <= heightj. You can rearrange any cuboid's dimensions by rotating it to put it on another cuboid.

    + +

    Return the maximum height of the stacked cuboids.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: cuboids = [[50,45,20],[95,37,53],[45,23,12]]
    +Output: 190
    +Explanation:
    +Cuboid 1 is placed on the bottom with the 53x37 side facing down with height 95.
    +Cuboid 0 is placed next with the 45x20 side facing down with height 50.
    +Cuboid 2 is placed next with the 23x12 side facing down with height 45.
    +The total height is 95 + 50 + 45 = 190.
    +
    + +

    Example 2:

    + +
    +Input: cuboids = [[38,25,45],[76,35,3]]
    +Output: 76
    +Explanation:
    +You can't place any of the cuboids on the other.
    +We choose cuboid 1 and rotate it so that the 35x3 side is facing down and its height is 76.
    +
    + +

    Example 3:

    + +
    +Input: cuboids = [[7,11,17],[7,17,11],[11,7,17],[11,17,7],[17,7,11],[17,11,7]]
    +Output: 102
    +Explanation:
    +After rearranging the cuboids, you can see that all cuboids have the same dimension.
    +You can place the 11x7 side down on all cuboids so their heights are 17.
    +The maximum height of stacked cuboids is 6 * 17 = 102.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == cuboids.length
    • +
    • 1 <= n <= 100
    • +
    • 1 <= widthi, lengthi, heighti <= 100
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Does the dynamic programming sound like the right algorithm after sorting? +
    + +
    +Hint 2 +Let's say box1 can be placed on top of box2. No matter what orientation box2 is in, we can rotate box1 so that it can be placed on top. Why don't we orient everything such that height is the biggest? +
    diff --git a/problems/minimum-incompatibility/README.md b/problems/minimum-incompatibility/README.md index 723fe1e6c..b947ec41c 100644 --- a/problems/minimum-incompatibility/README.md +++ b/problems/minimum-incompatibility/README.md @@ -7,7 +7,7 @@ [< Previous](../concatenation-of-consecutive-binary-numbers "Concatenation of Consecutive Binary Numbers")                  -Next > +[Next >](../longest-palindromic-subsequence-ii "Longest Palindromic Subsequence II") ## [1681. Minimum Incompatibility (Hard)](https://leetcode.com/problems/minimum-incompatibility "最小不兼容性") diff --git a/problems/number-of-lines-to-write-string/README.md b/problems/number-of-lines-to-write-string/README.md index b4d78966f..df7454057 100644 --- a/problems/number-of-lines-to-write-string/README.md +++ b/problems/number-of-lines-to-write-string/README.md @@ -11,44 +11,45 @@ ## [806. Number of Lines To Write String (Easy)](https://leetcode.com/problems/number-of-lines-to-write-string "写字符串需要的行数") -

    We are to write the letters of a given string S, from left to right into lines. Each line has maximum width 100 units, and if writing a letter would cause the width of the line to exceed 100 units, it is written on the next line. We are given an array widths, an array where widths[0] is the width of 'a', widths[1] is the width of 'b', ..., and widths[25] is the width of 'z'.

    +

    You are given a string s of lowercase English letters and an array widths denoting how many pixels wide each lowercase English letter is. Specifically, widths[0] is the width of 'a', widths[1] is the width of 'b', and so on.

    -

    Now answer two questions: how many lines have at least one character from S, and what is the width used by the last such line? Return your answer as an integer list of length 2.

    +

    You are trying to write s across several lines, where each line is no longer than 100 pixels. Starting at the beginning of s, write as many letters on the first line such that the total width does not exceed 100 pixels. Then, from where you stopped in s, continue writing as many letters as you can on the second line. Continue this process until you have written all of s.

    + +

    Return an array result of length 2 where:

    + +
      +
    • result[0] is the total number of lines.
    • +
    • result[1] is the width of the last line in pixels.
    • +

     

    +

    Example 1:

    -Example :
    -Input: 
    -widths = [10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]
    -S = "abcdefghijklmnopqrstuvwxyz"
    -Output: [3, 60]
    -Explanation: 
    -All letters have the same length of 10. To write all 26 letters,
    -we need two full lines and one line with 60 units.
    -
    +Input: widths = [10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10], s = "abcdefghijklmnopqrstuvwxyz" +Output: [3,60] +Explanation: You can write s as follows: +abcdefghij // 100 pixels wide +klmnopqrst // 100 pixels wide +uvwxyz // 60 pixels wide +There are a total of 3 lines, and the last line is 60 pixels wide.
    + +

    Example 2:

    -Example :
    -Input: 
    -widths = [4,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]
    -S = "bbbcccdddaaa"
    -Output: [2, 4]
    -Explanation: 
    -All letters except 'a' have the same length of 10, and 
    -"bbbcccdddaa" will cover 9 * 10 + 2 * 4 = 98 units.
    -For the last 'a', it is written on the second line because
    -there is only 2 units left in the first line.
    -So the answer is 2 lines, plus 4 units in the second line.
    -
    +Input: widths = [4,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10], s = "bbbcccdddaaa" +Output: [2,4] +Explanation: You can write s as follows: +bbbcccdddaa // 98 pixels wide +a // 4 pixels wide +There are a total of 2 lines, and the last line is 4 pixels wide.

     

    - -

    Note:

    +

    Constraints:

      -
    • The length of S will be in the range [1, 1000].
    • -
    • S will only contain lowercase letters.
    • -
    • widths is an array of length 26.
    • -
    • widths[i] will be in the range of [2, 10].
    • +
    • widths.length == 26
    • +
    • 2 <= widths[i] <= 10
    • +
    • 1 <= s.length <= 1000
    • +
    • s contains only lowercase English letters.
    diff --git a/problems/palindrome-partitioning/README.md b/problems/palindrome-partitioning/README.md index 8fefdf049..87c7cca47 100644 --- a/problems/palindrome-partitioning/README.md +++ b/problems/palindrome-partitioning/README.md @@ -11,22 +11,29 @@ ## [131. Palindrome Partitioning (Medium)](https://leetcode.com/problems/palindrome-partitioning "分割回文串") -

    Given a string s, partition s such that every substring of the partition is a palindrome.

    +

    Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s.

    -

    Return all possible palindrome partitioning of s.

    +

    A palindrome string is a string that reads the same backward as forward.

    -

    Example:

    - -
    -Input: "aab"
    -Output:
    -[
    -  ["aa","b"],
    -  ["a","a","b"]
    -]
    +

     

    +

    Example 1:

    +
    Input: s = "aab"
    +Output: [["a","a","b"],["aa","b"]]
    +

    Example 2:

    +
    Input: s = "a"
    +Output: [["a"]]
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 16
    • +
    • s contains only lowercase English letters.
    • +
    ### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions diff --git a/problems/partitioning-into-minimum-number-of-deci-binary-numbers/README.md b/problems/partitioning-into-minimum-number-of-deci-binary-numbers/README.md new file mode 100644 index 000000000..f9df751b4 --- /dev/null +++ b/problems/partitioning-into-minimum-number-of-deci-binary-numbers/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../count-of-matches-in-tournament "Count of Matches in Tournament") +                 +[Next >](../stone-game-vii "Stone Game VII") + +## [1689. Partitioning Into Minimum Number Of Deci-Binary Numbers (Medium)](https://leetcode.com/problems/partitioning-into-minimum-number-of-deci-binary-numbers "十-二进制数的最少数目") + +

    A decimal number is called deci-binary if each of its digits is either 0 or 1 without any leading zeros. For example, 101 and 1100 are deci-binary, while 112 and 3001 are not.

    + +

    Given a string n that represents a positive decimal integer, return the minimum number of positive deci-binary numbers needed so that they sum up to n.

    + +

     

    +

    Example 1:

    + +
    +Input: n = "32"
    +Output: 3
    +Explanation: 10 + 11 + 11 = 32
    +
    + +

    Example 2:

    + +
    +Input: n = "82734"
    +Output: 8
    +
    + +

    Example 3:

    + +
    +Input: n = "27346209830709182346"
    +Output: 9
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n.length <= 105
    • +
    • n consists of only digits.
    • +
    • n does not contain any leading zeros and represents a positive integer.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Think about if the input was only one digit. Then you need to add up as many ones as the value of this digit. +
    + +
    +Hint 2 +If the input has multiple digits, then you can solve for each digit independently, and merge the answers to form numbers that add up to that input. +
    + +
    +Hint 3 +Thus the answer is equal to the max digit. +
    diff --git a/problems/plus-one-linked-list/README.md b/problems/plus-one-linked-list/README.md index 63596dd4e..a75d14325 100644 --- a/problems/plus-one-linked-list/README.md +++ b/problems/plus-one-linked-list/README.md @@ -26,6 +26,7 @@
    ### Related Topics + [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions diff --git a/problems/short-encoding-of-words/README.md b/problems/short-encoding-of-words/README.md index a3c915941..c18dc8979 100644 --- a/problems/short-encoding-of-words/README.md +++ b/problems/short-encoding-of-words/README.md @@ -11,28 +11,35 @@ ## [820. Short Encoding of Words (Medium)](https://leetcode.com/problems/short-encoding-of-words "单词的压缩编码") -

    Given a list of words, we may encode it by writing a reference string S and a list of indexes A.

    +

    Given a list of words, we may encode it by writing a reference string s and a list of indexes a.

    -

    For example, if the list of words is ["time", "me", "bell"], we can write it as S = "time#bell#" and indexes = [0, 2, 5].

    +

    For example, if the list of words is ["time", "me", "bell"], we can write it as s = "time#bell#" and indexes = [0, 2, 5].

    Then for each index, we will recover the word by reading from the reference string from that index until we reach a "#" character.

    -

    What is the length of the shortest reference string S possible that encodes the given words?

    +

    Return the length of the shortest reference string s possible that encodes the given words.

    -

    Example:

    +

     

    +

    Example 1:

    -Input: words = ["time", "me", "bell"]
    +Input: words = ["time", "me", "bell"]
     Output: 10
    -Explanation: S = "time#bell#" and indexes = [0, 2, 5].
    +Explanation: s = "time#bell#" and indexes = [0, 2, 5].
     
    -

     

    +

    Example 2:

    + +
    +Input: words = ["t"]
    +Output: 2
    +
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. 1 <= words.length <= 2000.
    2. -
    3. 1 <= words[i].length <= 7.
    4. -
    5. Each word has only lowercase letters.
    6. -
    +
      +
    • 1 <= words.length <= 2000
    • +
    • 1 <= words[i].length <= 7
    • +
    • words[i] consists of only lowercase letters.
    • +
    diff --git a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md index 0e5ce6c7d..c12facba0 100644 --- a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md +++ b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md @@ -59,3 +59,6 @@ Notice that nodes 5, 3 and 2 contain the deepest nodes in the tree but node 2 is ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Recursion](../../tag/recursion/README.md)] diff --git a/problems/stone-game-vi/README.md b/problems/stone-game-vi/README.md new file mode 100644 index 000000000..ee65e1a73 --- /dev/null +++ b/problems/stone-game-vi/README.md @@ -0,0 +1,84 @@ + + + + + + + +[< Previous](../sum-of-absolute-differences-in-a-sorted-array "Sum of Absolute Differences in a Sorted Array") +                 +[Next >](../delivering-boxes-from-storage-to-ports "Delivering Boxes from Storage to Ports") + +## [1686. Stone Game VI (Medium)](https://leetcode.com/problems/stone-game-vi "石子游戏 VI") + +

    Alice and Bob take turns playing a game, with Alice starting first.

    + +

    There are n stones in a pile. On each player's turn, they can remove a stone from the pile and receive points based on the stone's value. Alice and Bob may value the stones differently.

    + +

    You are given two integer arrays of length n, aliceValues and bobValues. Each aliceValues[i] and bobValues[i] represents how Alice and Bob, respectively, value the ith stone.

    + +

    The winner is the person with the most points after all the stones are chosen. If both players have the same amount of points, the game results in a draw. Both players will play optimally.

    + +

    Determine the result of the game, and:

    + +
      +
    • If Alice wins, return 1.
    • +
    • If Bob wins, return -1.
    • +
    • If the game results in a draw, return 0.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: aliceValues = [1,3], bobValues = [2,1]
    +Output: 1
    +Explanation:
    +If Alice takes stone 1 (0-indexed) first, Alice will receive 3 points.
    +Bob can only choose stone 0, and will only receive 2 points.
    +Alice wins.
    +
    + +

    Example 2:

    + +
    +Input: aliceValues = [1,2], bobValues = [3,1]
    +Output: 0
    +Explanation:
    +If Alice takes stone 0, and Bob takes stone 1, they will both have 1 point.
    +Draw.
    +
    + +

    Example 3:

    + +
    +Input: aliceValues = [2,4,3], bobValues = [1,6,7]
    +Output: -1
    +Explanation:
    +Regardless of how Alice plays, Bob will be able to have more points than Alice.
    +For example, if Alice takes stone 1, Bob can take stone 2, and Alice takes stone 0, Alice will have 6 points to Bob's 7.
    +Bob wins.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == aliceValues.length == bobValues.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= aliceValues[i], bobValues[i] <= 100
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +When one takes the stone, they not only get the points, but they take them away from the other player too. +
    + +
    +Hint 2 +Greedily choose the stone with the maximum aliceValues[i] + bobValues[i]. +
    diff --git a/problems/stone-game-vii/README.md b/problems/stone-game-vii/README.md new file mode 100644 index 000000000..74a93ef48 --- /dev/null +++ b/problems/stone-game-vii/README.md @@ -0,0 +1,64 @@ + + + + + + + +[< Previous](../partitioning-into-minimum-number-of-deci-binary-numbers "Partitioning Into Minimum Number Of Deci-Binary Numbers") +                 +[Next >](../maximum-height-by-stacking-cuboids "Maximum Height by Stacking Cuboids ") + +## [1690. Stone Game VII (Medium)](https://leetcode.com/problems/stone-game-vii "石子游戏 VII") + +

    Alice and Bob take turns playing a game, with Alice starting first.

    + +

    There are n stones arranged in a row. On each player's turn, they can remove either the leftmost stone or the rightmost stone from the row and receive points equal to the sum of the remaining stones' values in the row. The winner is the one with the higher score when there are no stones left to remove.

    + +

    Bob found that he will always lose this game (poor Bob, he always loses), so he decided to minimize the score's difference. Alice's goal is to maximize the difference in the score.

    + +

    Given an array of integers stones where stones[i] represents the value of the ith stone from the left, return the difference in Alice and Bob's score if they both play optimally.

    + +

     

    +

    Example 1:

    + +
    +Input: stones = [5,3,1,4,2]
    +Output: 6
    +Explanation: 
    +- Alice removes 2 and gets 5 + 3 + 1 + 4 = 13 points. Alice = 13, Bob = 0, stones = [5,3,1,4].
    +- Bob removes 5 and gets 3 + 1 + 4 = 8 points. Alice = 13, Bob = 8, stones = [3,1,4].
    +- Alice removes 3 and gets 1 + 4 = 5 points. Alice = 18, Bob = 8, stones = [1,4].
    +- Bob removes 1 and gets 4 points. Alice = 18, Bob = 12, stones = [4].
    +- Alice removes 4 and gets 0 points. Alice = 18, Bob = 12, stones = [].
    +The score difference is 18 - 12 = 6.
    +
    + +

    Example 2:

    + +
    +Input: stones = [7,90,5,1,100,10,10,2]
    +Output: 122
    + +

     

    +

    Constraints:

    + +
      +
    • n == stones.length
    • +
    • 2 <= n <= 1000
    • +
    • 1 <= stones[i] <= 1000
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +The constraints are small enough for an N^2 solution. +
    + +
    +Hint 2 +Try using dynamic programming. +
    diff --git a/problems/sum-of-absolute-differences-in-a-sorted-array/README.md b/problems/sum-of-absolute-differences-in-a-sorted-array/README.md new file mode 100644 index 000000000..a73fc0b62 --- /dev/null +++ b/problems/sum-of-absolute-differences-in-a-sorted-array/README.md @@ -0,0 +1,65 @@ + + + + + + + +[< Previous](../count-the-number-of-consistent-strings "Count the Number of Consistent Strings") +                 +[Next >](../stone-game-vi "Stone Game VI") + +## [1685. Sum of Absolute Differences in a Sorted Array (Medium)](https://leetcode.com/problems/sum-of-absolute-differences-in-a-sorted-array "有序数组中差绝对值之和") + +

    You are given an integer array nums sorted in non-decreasing order.

    + +

    Build and return an integer array result with the same length as nums such that result[i] is equal to the summation of absolute differences between nums[i] and all the other elements in the array.

    + +

    In other words, result[i] is equal to sum(|nums[i]-nums[j]|) where 0 <= j < nums.length and j != i (0-indexed).

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [2,3,5]
    +Output: [4,3,5]
    +Explanation: Assuming the arrays are 0-indexed, then
    +result[0] = |2-2| + |2-3| + |2-5| = 0 + 1 + 3 = 4,
    +result[1] = |3-2| + |3-3| + |3-5| = 1 + 0 + 2 = 3,
    +result[2] = |5-2| + |5-3| + |5-5| = 3 + 2 + 0 = 5.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,4,6,8,10]
    +Output: [24,15,13,15,21]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= nums[i + 1] <= 104
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Absolute difference is the same as max(a, b) - min(a, b). How can you use this fact with the fact that the array is sorted? +
    + +
    +Hint 2 +For nums[i], the answer is (nums[i] - nums[0]) + (nums[i] - nums[1]) + ... + (nums[i] - nums[i-1]) + (nums[i+1] - nums[i]) + (nums[i+2] - nums[i]) + ... + (nums[n-1] - nums[i]). +
    + +
    +Hint 3 +It can be simplified to (nums[i] * i - (nums[0] + nums[1] + ... + nums[i-1])) + ((nums[i+1] + nums[i+2] + ... + nums[n-1]) - nums[i] * (n-i-1)). One can build prefix and suffix sums to compute this quickly. +
    diff --git a/tag/README.md b/tag/README.md index 9fc67df4d..aee906df4 100644 --- a/tag/README.md +++ b/tag/README.md @@ -15,7 +15,7 @@ | 7 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | | 8 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 9 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | | 11 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | -| 13 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | | 14 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | +| 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | | 15 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | | 19 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 20 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | @@ -26,7 +26,7 @@ | 29 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 31 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 32 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | | 33 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 34 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | -| 35 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | -| 37 | [](dequeue/README.md) | [](https://openset.github.io/tags/dequeue/) | | 38 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | +| 35 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [](dequeue/README.md) | [](https://openset.github.io/tags/dequeue/) | +| 37 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | | 38 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | | 39 | [Reservoir Sampling](reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | | 40 | [Suffix Array](suffix-array/README.md) | [Suffix Array](https://openset.github.io/tags/suffix-array/) | | 41 | [Memoization](memoization/README.md) | [记忆化](https://openset.github.io/tags/memoization/) | | 42 | [](oop/README.md) | [](https://openset.github.io/tags/oop/) | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 5cec3ae89..1d67a2924 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1688 | [比赛中的配对次数](../../problems/count-of-matches-in-tournament) | [[回溯算法](../backtracking/README.md)] | Easy | | 1681 | [最小不兼容性](../../problems/minimum-incompatibility) | [[贪心算法](../greedy/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | @@ -51,7 +52,7 @@ | 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 140 | [单词拆分 II](../../problems/word-break-ii) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[回溯算法](../backtracking/README.md)] | Medium | +| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 93 | [复原IP地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 90 | [子集 II](../../problems/subsets-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 093b46288..0406a0869 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,57 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Hard | -| 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1486 | [数组异或操作](../../problems/xor-operation-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | -| 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1404 | [将二进制表示减到 1 的步骤数](../../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[排序](../sort/README.md)] [[位运算](../bit-manipulation/README.md)] | Easy | -| 1342 | [将数字变成 0 的操作次数](../../problems/number-of-steps-to-reduce-a-number-to-zero) | [[位运算](../bit-manipulation/README.md)] | Easy | -| 1318 | [或运算的最小翻转次数](../../problems/minimum-flips-to-make-a-or-b-equal-to-c) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 1310 | [子数组异或查询](../../problems/xor-queries-of-a-subarray) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)] | Easy | -| 1256 | [加密数字](../../problems/encode-number) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | -| 1255 | [得分最高的单词集合](../../problems/maximum-score-words-formed-by-letters) | [[位运算](../bit-manipulation/README.md)] | Hard | -| 1239 | [串联字符串的最大长度](../../problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1178 | [猜字谜](../../problems/number-of-valid-words-for-each-puzzle) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 1131 | [绝对值表达式的最大值](../../problems/maximum-of-absolute-value-expression) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | -| 1125 | [最小的必要团队](../../problems/smallest-sufficient-team) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 898 | [子数组按位或操作](../../problems/bitwise-ors-of-subarrays) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 762 | [二进制表示中质数个计算置位](../../problems/prime-number-of-set-bits-in-binary-representation) | [[位运算](../bit-manipulation/README.md)] | Easy | -| 756 | [金字塔转换矩阵](../../problems/pyramid-transition-matrix) | [[位运算](../bit-manipulation/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 751 | [IP 到 CIDR](../../problems/ip-to-cidr) 🔒 | [[位运算](../bit-manipulation/README.md)] | Easy | -| 693 | [交替位二进制数](../../problems/binary-number-with-alternating-bits) | [[位运算](../bit-manipulation/README.md)] | Easy | -| 477 | [汉明距离总和](../../problems/total-hamming-distance) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 476 | [数字的补数](../../problems/number-complement) | [[位运算](../bit-manipulation/README.md)] | Easy | -| 461 | [汉明距离](../../problems/hamming-distance) | [[位运算](../bit-manipulation/README.md)] | Easy | -| 421 | [数组中两个数的最大异或值](../../problems/maximum-xor-of-two-numbers-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Medium | -| 411 | [最短特异单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 405 | [数字转换为十六进制数](../../problems/convert-a-number-to-hexadecimal) | [[位运算](../bit-manipulation/README.md)] | Easy | -| 401 | [二进制手表](../../problems/binary-watch) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | -| 397 | [整数替换](../../problems/integer-replacement) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | -| 393 | [UTF-8 编码验证](../../problems/utf-8-validation) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 371 | [两整数之和](../../problems/sum-of-two-integers) | [[位运算](../bit-manipulation/README.md)] | Easy | -| 342 | [4的幂](../../problems/power-of-four) | [[位运算](../bit-manipulation/README.md)] | Easy | -| 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 318 | [最大单词长度乘积](../../problems/maximum-product-of-word-lengths) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 268 | [丢失的数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 260 | [只出现一次的数字 III](../../problems/single-number-iii) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 231 | [2的幂](../../problems/power-of-two) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | -| 201 | [数字范围按位与](../../problems/bitwise-and-of-numbers-range) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 191 | [位1的个数](../../problems/number-of-1-bits) | [[位运算](../bit-manipulation/README.md)] | Easy | -| 190 | [颠倒二进制位](../../problems/reverse-bits) | [[位运算](../bit-manipulation/README.md)] | Easy | -| 187 | [重复的DNA序列](../../problems/repeated-dna-sequences) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 169 | [多数元素](../../problems/majority-element) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Easy | -| 137 | [只出现一次的数字 II](../../problems/single-number-ii) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 136 | [只出现一次的数字](../../problems/single-number) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 97922c717..a4976f342 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,3 +9,80 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1654 | [到家的最少跳跃次数](../../problems/minimum-jumps-to-reach-home) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1625 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1345 | [跳跃游戏 IV](../../problems/jump-game-iv) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 1298 | [你能从盒子里获得的最大糖果数](../../problems/maximum-candies-you-can-get-from-boxes) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1293 | [网格中的最短路径](../../problems/shortest-path-in-a-grid-with-obstacles-elimination) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1284 | [转化为全零矩阵的最少反转次数](../../problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1263 | [推箱子](../../problems/minimum-moves-to-move-a-box-to-their-target-location) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1242 | [多线程网页爬虫](../../problems/web-crawler-multithreaded) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1236 | [网络爬虫](../../problems/web-crawler) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1210 | [穿过迷宫的最少移动次数](../../problems/minimum-moves-to-reach-target-with-rotations) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1197 | [进击的骑士](../../problems/minimum-knight-moves) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1091 | [二进制矩阵中的最短路径](../../problems/shortest-path-in-binary-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 994 | [腐烂的橘子](../../problems/rotting-oranges) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[极小化极大](../minimax/README.md)] | Hard | +| 909 | [蛇梯棋](../../problems/snakes-and-ladders) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 864 | [获取所有钥匙的最短路径](../../problems/shortest-path-to-get-all-keys) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 854 | [相似度为 K 的字符串](../../problems/k-similar-strings) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Hard | +| 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 773 | [滑动谜题](../../problems/sliding-puzzle) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 675 | [为高尔夫比赛砍树](../../problems/cut-off-trees-for-golf-event) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 559 | [N 叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 542 | [01 矩阵](../../problems/01-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 529 | [扫雷游戏](../../problems/minesweeper) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 505 | [迷宫 II](../../problems/the-maze-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 499 | [迷宫 III](../../problems/the-maze-iii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 490 | [迷宫](../../problems/the-maze) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 429 | [N 叉树的层序遍历](../../problems/n-ary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 417 | [太平洋大西洋水流问题](../../problems/pacific-atlantic-water-flow) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 317 | [离建筑物最近的距离](../../problems/shortest-distance-from-all-buildings) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 310 | [最小高度树](../../problems/minimum-height-trees) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 301 | [删除无效的括号](../../problems/remove-invalid-parentheses) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 286 | [墙与门](../../problems/walls-and-gates) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 127 | [单词接龙](../../problems/word-ladder) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 107 | [二叉树的层次遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 103 | [二叉树的锯齿形层次遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 102 | [二叉树的层序遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index ba34937f2..e486dbba9 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -10,7 +10,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1676 | [Lowest Common Ancestor of a Binary Tree IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1666 | [Change the Root of a Binary Tree](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1625 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | @@ -65,6 +65,7 @@ | 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | | 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 851 | [喧闹和富有](../../problems/loud-and-rich) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 841 | [钥匙和房间](../../problems/keys-and-rooms) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | @@ -131,6 +132,7 @@ | 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 129 | [求根到叶子节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index 9fcc476e7..0d334b142 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -9,23 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1274 | [矩形内船只的数目](../../problems/number-of-ships-in-a-rectangle) 🔒 | [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 932 | [漂亮数组](../../problems/beautiful-array) | [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 903 | [DI 序列的有效排列](../../problems/valid-permutations-for-di-sequence) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 395 | [至少有K个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 312 | [戳气球](../../problems/burst-balloons) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 282 | [给表达式添加运算符](../../problems/expression-add-operators) | [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 241 | [为运算表达式设计优先级](../../problems/different-ways-to-add-parentheses) | [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | -| 215 | [数组中的第K个最大元素](../../problems/kth-largest-element-in-an-array) | [[堆](../heap/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 169 | [多数元素](../../problems/majority-element) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Easy | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 4 | [寻找两个正序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index ad1a7a83a..58277ef32 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1691 | [堆叠长方体的最大高度](../../problems/maximum-height-by-stacking-cuboids) | [[排序](../sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1690 | [石子游戏 VII](../../problems/stone-game-vii) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1682 | [Longest Palindromic Subsequence II](../../problems/longest-palindromic-subsequence-ii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1671 | [得到山形数组的最少删除次数](../../problems/minimum-number-of-removals-to-make-mountain-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1664 | [生成平衡数组的方案数](../../problems/ways-to-make-a-fair-array) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | @@ -222,6 +226,7 @@ | 140 | [单词拆分 II](../../problems/word-break-ii) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 139 | [单词拆分](../../problems/word-break) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 132 | [分割回文串 II](../../problems/palindrome-partitioning-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 123 | [买卖股票的最佳时机 III](../../problems/best-time-to-buy-and-sell-stock-iii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 121 | [买卖股票的最佳时机](../../problems/best-time-to-buy-and-sell-stock) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 120 | [三角形最小路径和](../../problems/triangle) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/graph/README.md b/tag/graph/README.md index 0d01c1b08..1e8098532 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,51 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1615 | [最大网络秩](../../problems/maximal-network-rank) | [[图](../graph/README.md)] | Medium | -| 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1557 | [可以到达所有点的最少点数目](../../problems/minimum-number-of-vertices-to-reach-all-nodes) | [[图](../graph/README.md)] | Medium | -| 1548 | [图中最相似的路径](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] | Medium | -| 1494 | [并行课程 II](../../problems/parallel-courses-ii) | [[图](../graph/README.md)] | Hard | -| 1462 | [课程安排 IV](../../problems/course-schedule-iv) | [[图](../graph/README.md)] | Medium | -| 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | -| 1361 | [验证二叉树](../../problems/validate-binary-tree-nodes) | [[图](../graph/README.md)] | Medium | -| 1334 | [阈值距离内邻居最少的城市](../../problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | [[图](../graph/README.md)] | Medium | -| 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | -| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | -| 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1153 | [字符串转化](../../problems/string-transforms-into-another-string) 🔒 | [[图](../graph/README.md)] | Hard | -| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1135 | [最低成本联通所有城市](../../problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 1059 | [从始点到终点的所有路径](../../problems/all-paths-from-source-lead-to-destination) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[图](../graph/README.md)] | Medium | -| 997 | [找到小镇的法官](../../problems/find-the-town-judge) | [[图](../graph/README.md)] | Easy | -| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 990 | [等式方程的可满足性](../../problems/satisfiability-of-equality-equations) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 854 | [相似度为 K 的字符串](../../problems/k-similar-strings) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Hard | -| 841 | [钥匙和房间](../../problems/keys-and-rooms) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 802 | [找到最终的安全状态](../../problems/find-eventual-safe-states) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 684 | [冗余连接](../../problems/redundant-connection) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 444 | [序列重建](../../problems/sequence-reconstruction) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 399 | [除法求值](../../problems/evaluate-division) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 310 | [最小高度树](../../problems/minimum-height-trees) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | -| 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index be24a7a70..c8e90abd2 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,3 +9,121 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1689 | [十-二进制数的最少数目](../../problems/partitioning-into-minimum-number-of-deci-binary-numbers) | [[贪心算法](../greedy/README.md)] | Medium | +| 1686 | [石子游戏 VI](../../problems/stone-game-vi) | [[贪心算法](../greedy/README.md)] | Medium | +| 1685 | [有序数组中差绝对值之和](../../problems/sum-of-absolute-differences-in-a-sorted-array) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 1681 | [最小不兼容性](../../problems/minimum-incompatibility) | [[贪心算法](../greedy/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1674 | [使数组互补的最少操作次数](../../problems/minimum-moves-to-make-array-complementary) | [[贪心算法](../greedy/README.md)] | Medium | +| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 1665 | [完成所有任务的最少初始能量](../../problems/minimum-initial-energy-to-finish-tasks) | [[贪心算法](../greedy/README.md)] | Hard | +| 1664 | [生成平衡数组的方案数](../../problems/ways-to-make-a-fair-array) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1663 | [具有给定数值的最小字符串](../../problems/smallest-string-with-a-given-numeric-value) | [[贪心算法](../greedy/README.md)] | Medium | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1657 | [确定两个字符串是否接近](../../problems/determine-if-two-strings-are-close) | [[贪心算法](../greedy/README.md)] | Medium | +| 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | +| 1647 | [字符频次唯一的最小删除次数](../../problems/minimum-deletions-to-make-character-frequencies-unique) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] | Hard | +| 1620 | [网络信号最好的坐标](../../problems/coordinate-with-maximum-network-quality) | [[贪心算法](../greedy/README.md)] | Medium | +| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1605 | [给定行和列的和求可行矩阵](../../problems/find-valid-matrix-given-row-and-column-sums) | [[贪心算法](../greedy/README.md)] | Medium | +| 1599 | [经营摩天轮的最大利润](../../problems/maximum-profit-of-operating-a-centennial-wheel) | [[贪心算法](../greedy/README.md)] | Medium | +| 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1591 | [奇怪的打印机 II](../../problems/strange-printer-ii) | [[贪心算法](../greedy/README.md)] | Hard | +| 1589 | [所有排列中的最大和](../../problems/maximum-sum-obtained-of-any-permutation) | [[贪心算法](../greedy/README.md)] | Medium | +| 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | +| 1580 | [把箱子放进仓库里 II](../../problems/put-boxes-into-the-warehouse-ii) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | +| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心算法](../greedy/README.md)] | Medium | +| 1568 | [使陆地分离的最少天数](../../problems/minimum-number-of-days-to-disconnect-island) | [[贪心算法](../greedy/README.md)] | Hard | +| 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心算法](../greedy/README.md)] | Medium | +| 1564 | [把箱子放进仓库里 I](../../problems/put-boxes-into-the-warehouse-i) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | +| 1558 | [得到目标数组的最少函数调用次数](../../problems/minimum-numbers-of-function-calls-to-make-target-array) | [[贪心算法](../greedy/README.md)] | Medium | +| 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心算法](../greedy/README.md)] | Medium | +| 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心算法](../greedy/README.md)] | Hard | +| 1518 | [换酒问题](../../problems/water-bottles) | [[贪心算法](../greedy/README.md)] | Easy | +| 1505 | [最多 K 次交换相邻数位后得到的最小整数](../../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | [[贪心算法](../greedy/README.md)] | Hard | +| 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1414 | [和为 K 的最少斐波那契数字数目](../../problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | +| 1400 | [构造 K 个回文字符串](../../problems/construct-k-palindrome-strings) | [[贪心算法](../greedy/README.md)] | Medium | +| 1386 | [安排电影院座位](../../problems/cinema-seat-allocation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Hard | +| 1354 | [多次求和构造目标数组](../../problems/construct-target-array-with-multiple-sums) | [[贪心算法](../greedy/README.md)] | Hard | +| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | +| 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1326 | [灌溉花园的最少水龙头数目](../../problems/minimum-number-of-taps-to-open-to-water-a-garden) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1282 | [用户分组](../../problems/group-the-people-given-the-group-size-they-belong-to) | [[贪心算法](../greedy/README.md)] | Medium | +| 1276 | [不浪费原料的汉堡制作方案](../../problems/number-of-burgers-with-no-waste-of-ingredients) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 1253 | [重构 2 行二进制矩阵](../../problems/reconstruct-a-2-row-binary-matrix) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 1247 | [交换字符使得字符串相同](../../problems/minimum-swaps-to-make-strings-equal) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1231 | [分享巧克力](../../problems/divide-chocolate) 🔒 | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1221 | [分割平衡字符串](../../problems/split-a-string-in-balanced-strings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | +| 1217 | [玩筹码](../../problems/minimum-cost-to-move-chips-to-the-same-position) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1196 | [最多可以买到的苹果数量](../../problems/how-many-apples-can-you-put-into-the-basket) 🔒 | [[贪心算法](../greedy/README.md)] | Easy | +| 1167 | [连接棒材的最低费用](../../problems/minimum-cost-to-connect-sticks) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | +| 1111 | [有效括号的嵌套深度](../../problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1094 | [拼车](../../problems/car-pooling) | [[贪心算法](../greedy/README.md)] | Medium | +| 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1057 | [校园自行车分配](../../problems/campus-bikes) 🔒 | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 1055 | [形成字符串的最短路径](../../problems/shortest-way-to-form-string) 🔒 | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1053 | [交换一次的先前排列](../../problems/previous-permutation-with-one-swap) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1046 | [最后一块石头的重量](../../problems/last-stone-weight) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Easy | +| 1029 | [两地调度](../../problems/two-city-scheduling) | [[贪心算法](../greedy/README.md)] | Medium | +| 1007 | [行相等的最少多米诺旋转](../../problems/minimum-domino-rotations-for-equal-row) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1005 | [K 次取反后最大化的数组和](../../problems/maximize-sum-of-array-after-k-negations) | [[贪心算法](../greedy/README.md)] | Easy | +| 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[贪心算法](../greedy/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 991 | [坏了的计算器](../../problems/broken-calculator) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 984 | [不含 AAA 或 BBB 的字符串](../../problems/string-without-aaa-or-bbb) | [[贪心算法](../greedy/README.md)] | Medium | +| 955 | [删列造序 II](../../problems/delete-columns-to-make-sorted-ii) | [[贪心算法](../greedy/README.md)] | Medium | +| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 944 | [删列造序](../../problems/delete-columns-to-make-sorted) | [[贪心算法](../greedy/README.md)] | Easy | +| 936 | [戳印序列](../../problems/stamping-the-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | +| 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 921 | [使括号有效的最少添加](../../problems/minimum-add-to-make-parentheses-valid) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 910 | [最小差值 II](../../problems/smallest-range-ii) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 874 | [模拟行走机器人](../../problems/walking-robot-simulation) | [[贪心算法](../greedy/README.md)] | Easy | +| 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 861 | [翻转矩阵后的得分](../../problems/score-after-flipping-matrix) | [[贪心算法](../greedy/README.md)] | Medium | +| 860 | [柠檬水找零](../../problems/lemonade-change) | [[贪心算法](../greedy/README.md)] | Easy | +| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | +| 757 | [设置交集大小至少为2](../../problems/set-intersection-size-at-least-two) | [[贪心算法](../greedy/README.md)] | Hard | +| 738 | [单调递增的数字](../../problems/monotone-increasing-digits) | [[贪心算法](../greedy/README.md)] | Medium | +| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 651 | [4键键盘](../../problems/4-keys-keyboard) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 649 | [Dota2 参议院](../../problems/dota2-senate) | [[贪心算法](../greedy/README.md)] | Medium | +| 630 | [课程表 III](../../problems/course-schedule-iii) | [[贪心算法](../greedy/README.md)] | Hard | +| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | +| 605 | [种花问题](../../problems/can-place-flowers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 502 | [IPO](../../problems/ipo) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | +| 484 | [寻找排列](../../problems/find-permutation) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | +| 455 | [分发饼干](../../problems/assign-cookies) | [[贪心算法](../greedy/README.md)] | Easy | +| 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 435 | [无重叠区间](../../problems/non-overlapping-intervals) | [[贪心算法](../greedy/README.md)] | Medium | +| 406 | [根据身高重建队列](../../problems/queue-reconstruction-by-height) | [[贪心算法](../greedy/README.md)] | Medium | +| 402 | [移掉K位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 330 | [按要求补齐数组](../../problems/patching-array) | [[贪心算法](../greedy/README.md)] | Hard | +| 321 | [拼接最大数](../../problems/create-maximum-number) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 135 | [分发糖果](../../problems/candy) | [[贪心算法](../greedy/README.md)] | Hard | +| 134 | [加油站](../../problems/gas-station) | [[贪心算法](../greedy/README.md)] | Medium | +| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 55 | [跳跃游戏](../../problems/jump-game) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Hard | +| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index b0d6454fe..8642b2274 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -9,45 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 1669 | [合并两个链表](../../problems/merge-in-between-linked-lists) | [[链表](../linked-list/README.md)] | Medium | -| 1634 | [求两个多项式链表的和](../../problems/add-two-polynomials-represented-as-linked-lists) 🔒 | [[链表](../linked-list/README.md)] | Medium | -| 1474 | [删除链表 M 个节点之后的 N 个节点](../../problems/delete-n-nodes-after-m-nodes-of-a-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Easy | -| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)] | Easy | -| 1171 | [从链表中删去总和值为零的连续节点](../../problems/remove-zero-sum-consecutive-nodes-from-linked-list) | [[链表](../linked-list/README.md)] | Medium | -| 1019 | [链表中的下一个更大节点](../../problems/next-greater-node-in-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 876 | [链表的中间结点](../../problems/middle-of-the-linked-list) | [[链表](../linked-list/README.md)] | Easy | -| 817 | [链表组件](../../problems/linked-list-components) | [[链表](../linked-list/README.md)] | Medium | -| 725 | [分隔链表](../../problems/split-linked-list-in-parts) | [[链表](../linked-list/README.md)] | Medium | -| 708 | [循环有序列表的插入](../../problems/insert-into-a-sorted-circular-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Medium | -| 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 445 | [两数相加 II](../../problems/add-two-numbers-ii) | [[链表](../linked-list/README.md)] | Medium | -| 430 | [扁平化多级双向链表](../../problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Medium | -| 328 | [奇偶链表](../../problems/odd-even-linked-list) | [[链表](../linked-list/README.md)] | Medium | -| 237 | [删除链表中的节点](../../problems/delete-node-in-a-linked-list) | [[链表](../linked-list/README.md)] | Easy | -| 234 | [回文链表](../../problems/palindrome-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 206 | [反转链表](../../problems/reverse-linked-list) | [[链表](../linked-list/README.md)] | Easy | -| 203 | [移除链表元素](../../problems/remove-linked-list-elements) | [[链表](../linked-list/README.md)] | Easy | -| 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[链表](../linked-list/README.md)] | Easy | -| 148 | [排序链表](../../problems/sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 143 | [重排链表](../../problems/reorder-list) | [[链表](../linked-list/README.md)] | Medium | -| 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 141 | [环形链表](../../problems/linked-list-cycle) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 138 | [复制带随机指针的链表](../../problems/copy-list-with-random-pointer) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 92 | [反转链表 II](../../problems/reverse-linked-list-ii) | [[链表](../linked-list/README.md)] | Medium | -| 86 | [分隔链表](../../problems/partition-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 83 | [删除排序链表中的重复元素](../../problems/remove-duplicates-from-sorted-list) | [[链表](../linked-list/README.md)] | Easy | -| 82 | [删除排序链表中的重复元素 II](../../problems/remove-duplicates-from-sorted-list-ii) | [[链表](../linked-list/README.md)] | Medium | -| 61 | [旋转链表](../../problems/rotate-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 25 | [K 个一组翻转链表](../../problems/reverse-nodes-in-k-group) | [[链表](../linked-list/README.md)] | Hard | -| 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[链表](../linked-list/README.md)] | Medium | -| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[链表](../linked-list/README.md)] | Easy | -| 19 | [删除链表的倒数第N个节点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 2 | [两数相加](../../problems/add-two-numbers) | [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 9b412a55f..6483efac2 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1685 | [有序数组中差绝对值之和](../../problems/sum-of-absolute-differences-in-a-sorted-array) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | | 1680 | [连接连续二进制数字](../../problems/concatenation-of-consecutive-binary-numbers) | [[数学](../math/README.md)] | Medium | | 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | | 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index 52afd5989..838436e43 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -9,3 +9,17 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | +| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 855 | [考场就座](../../problems/exam-room) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 846 | [一手顺子](../../problems/hand-of-straights) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 731 | [我的日程安排表 II](../../problems/my-calendar-ii) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 683 | [K 个关闭的灯泡](../../problems/k-empty-slots) 🔒 | [[Ordered Map](../ordered-map/README.md)] | Hard | +| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | diff --git a/tag/random/README.md b/tag/random/README.md index 25144cd0a..72a82d98f 100644 --- a/tag/random/README.md +++ b/tag/random/README.md @@ -9,9 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | -| 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | -| 519 | [随机翻转矩阵](../../problems/random-flip-matrix) | [[Random](../random/README.md)] | Medium | -| 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | -| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | -| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index b1cd7a2b0..f99d827a5 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -14,6 +14,7 @@ | 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | | 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | | 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[递归](../recursion/README.md)] | Medium | @@ -26,6 +27,7 @@ | 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | | 395 | [至少有K个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | | 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | | 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | diff --git a/tag/rejection-sampling/README.md b/tag/rejection-sampling/README.md index 8622c93e1..fc2d396f2 100644 --- a/tag/rejection-sampling/README.md +++ b/tag/rejection-sampling/README.md @@ -9,3 +9,5 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | +| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index 45c8a364b..2904f5725 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | | 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[线段树](../segment-tree/README.md)] | Hard | | 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | diff --git a/tag/sort/README.md b/tag/sort/README.md index d4e07b582..8532603a2 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1691 | [堆叠长方体的最大高度](../../problems/maximum-height-by-stacking-cuboids) | [[排序](../sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | | 1647 | [字符频次唯一的最小删除次数](../../problems/minimum-deletions-to-make-character-frequencies-unique) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | | 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | diff --git a/tag/string/README.md b/tag/string/README.md index ca3d0540d..47dcec77c 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1684 | [统计一致字符串的数目](../../problems/count-the-number-of-consistent-strings) | [[字符串](../string/README.md)] | Easy | +| 1682 | [Longest Palindromic Subsequence II](../../problems/longest-palindromic-subsequence-ii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1678 | [设计 Goal 解析器](../../problems/goal-parser-interpretation) | [[字符串](../string/README.md)] | Easy | | 1668 | [最大重复子字符串](../../problems/maximum-repeating-substring) | [[字符串](../string/README.md)] | Easy | | 1662 | [检查两个字符串数组是否相等](../../problems/check-if-two-string-arrays-are-equivalent) | [[字符串](../string/README.md)] | Easy | diff --git a/tag/tags.json b/tag/tags.json index 7be43fb7b..820b1f6b7 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -59,16 +59,16 @@ "Slug": "two-pointers", "TranslatedName": "双指针" }, - { - "Name": "Stack", - "Slug": "stack", - "TranslatedName": "栈" - }, { "Name": "Backtracking", "Slug": "backtracking", "TranslatedName": "回溯算法" }, + { + "Name": "Stack", + "Slug": "stack", + "TranslatedName": "栈" + }, { "Name": "Design", "Slug": "design", @@ -174,16 +174,16 @@ "Slug": "binary-search-tree", "TranslatedName": "二叉搜索树" }, - { - "Name": "Rolling Hash", - "Slug": "rolling-hash", - "TranslatedName": "Rolling Hash" - }, { "Name": "", "Slug": "dequeue", "TranslatedName": "" }, + { + "Name": "Rolling Hash", + "Slug": "rolling-hash", + "TranslatedName": "Rolling Hash" + }, { "Name": "Rejection Sampling", "Slug": "rejection-sampling", diff --git a/tag/topological-sort/README.md b/tag/topological-sort/README.md index 5a051c022..845df9d71 100644 --- a/tag/topological-sort/README.md +++ b/tag/topological-sort/README.md @@ -9,9 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | -| 444 | [序列重建](../../problems/sequence-reconstruction) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | -| 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | -| 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | diff --git a/tag/tree/README.md b/tag/tree/README.md index 56d129a2d..10c1417de 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -10,7 +10,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1676 | [Lowest Common Ancestor of a Binary Tree IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1666 | [Change the Root of a Binary Tree](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1660 | [纠正二叉树](../../problems/correct-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | | 1650 | [二叉树的最近公共祖先 III](../../problems/lowest-common-ancestor-of-a-binary-tree-iii) 🔒 | [[树](../tree/README.md)] | Medium | | 1644 | [二叉树的最近公共祖先 II](../../problems/lowest-common-ancestor-of-a-binary-tree-ii) 🔒 | [[树](../tree/README.md)] | Medium | @@ -69,7 +69,7 @@ | 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] | Medium | | 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] | Medium | +| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | | 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | | 814 | [二叉树剪枝](../../problems/binary-tree-pruning) | [[树](../tree/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 58d26671c..1cd23c4b5 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard | From 23522f7ad7855ef797af672816b1c8acf22d9a42 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 14 Dec 2020 14:42:21 +0800 Subject: [PATCH 113/145] A: Check If Two String Arrays are Equivalent --- ...eck_if_two_string_arrays_are_equivalent.go | 15 ++++++++ ...f_two_string_arrays_are_equivalent_test.go | 35 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 problems/check-if-two-string-arrays-are-equivalent/check_if_two_string_arrays_are_equivalent.go create mode 100644 problems/check-if-two-string-arrays-are-equivalent/check_if_two_string_arrays_are_equivalent_test.go diff --git a/problems/check-if-two-string-arrays-are-equivalent/check_if_two_string_arrays_are_equivalent.go b/problems/check-if-two-string-arrays-are-equivalent/check_if_two_string_arrays_are_equivalent.go new file mode 100644 index 000000000..2d596f45f --- /dev/null +++ b/problems/check-if-two-string-arrays-are-equivalent/check_if_two_string_arrays_are_equivalent.go @@ -0,0 +1,15 @@ +package problem1662 + +import "strings" + +func arrayStringsAreEqual(word1 []string, word2 []string) bool { + str1 := strings.Builder{} + for _, s := range word1 { + str1.WriteString(s) + } + str2 := strings.Builder{} + for _, s := range word2 { + str2.WriteString(s) + } + return str1.String() == str2.String() +} diff --git a/problems/check-if-two-string-arrays-are-equivalent/check_if_two_string_arrays_are_equivalent_test.go b/problems/check-if-two-string-arrays-are-equivalent/check_if_two_string_arrays_are_equivalent_test.go new file mode 100644 index 000000000..7fa5a0486 --- /dev/null +++ b/problems/check-if-two-string-arrays-are-equivalent/check_if_two_string_arrays_are_equivalent_test.go @@ -0,0 +1,35 @@ +package problem1662 + +import "testing" + +type testType struct { + word1 []string + word2 []string + want bool +} + +func TestArrayStringsAreEqual(t *testing.T) { + tests := [...]testType{ + { + word1: []string{"ab", "c"}, + word2: []string{"a", "bc"}, + want: true, + }, + { + word1: []string{"a", "cb"}, + word2: []string{"ab", "c"}, + want: false, + }, + { + word1: []string{"abc", "d", "defg"}, + word2: []string{"abcddefg"}, + want: true, + }, + } + for _, tt := range tests { + got := arrayStringsAreEqual(tt.word1, tt.word2) + if got != tt.want { + t.Fatalf("word1: %v, word2: %v, got: %v, want: %v", tt.word1, tt.word2, got, tt.want) + } + } +} From 9904ed44091c0b059a467908d916f3e58dd03f28 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 14 Dec 2020 14:42:42 +0800 Subject: [PATCH 114/145] U: go1.14 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 6320d1775..d10dc824a 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/openset/leetcode -go 1.13 +go 1.14 From f217b06a610f998dd3b3b1453f01369a37a8f0cf Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 28 Dec 2020 14:22:56 +0800 Subject: [PATCH 115/145] A: new --- README.md | 16 ++ problems/average-waiting-time/README.md | 77 ++++++ problems/balanced-binary-tree/README.md | 1 + problems/basic-calculator/README.md | 26 +- .../README.md | 2 +- .../binary-tree-maximum-path-sum/README.md | 1 + .../README.md | 2 +- problems/burst-balloons/README.md | 36 ++- .../README.md | 6 +- .../README.md | 62 +++++ problems/cherry-pickup/README.md | 63 ++--- problems/concatenated-words/README.md | 39 +-- problems/consecutive-numbers/README.md | 43 +++- .../README.md | 38 +++ problems/daily-leads-and-partners/README.md | 14 + .../mysql_schemas.sql | 12 + problems/design-underground-system/README.md | 50 ++-- .../README.md | 68 +++++ .../distribute-coins-in-binary-tree/README.md | 60 ++--- problems/exchange-seats/README.md | 17 +- problems/factorial-trailing-zeroes/README.md | 2 +- problems/fibonacci-number/README.md | 22 +- .../find-bottom-left-tree-value/README.md | 47 ++-- .../README.md | 6 +- .../README.md | 2 +- problems/game-of-life/README.md | 47 ++-- problems/grid-illumination/README.md | 2 +- problems/happy-number/README.md | 35 ++- .../implement-stack-using-queues/README.md | 2 +- .../increasing-triplet-subsequence/README.md | 43 ++-- problems/jewels-and-stones/README.md | 26 +- problems/jump-game-iii/README.md | 2 +- problems/jump-game-vi/README.md | 63 +++++ problems/jump-game/README.md | 6 +- .../README.md | 37 +-- .../longest-increasing-subsequence/README.md | 2 +- problems/longest-palindrome/README.md | 2 +- .../README.md | 2 +- .../README.md | 3 +- .../README.md | 2 +- .../README.md | 2 +- problems/max-consecutive-ones-iii/README.md | 2 +- .../README.md | 68 +++++ problems/maximum-binary-tree/README.md | 52 ++-- problems/maximum-erasure-value/README.md | 57 +++++ .../README.md | 2 +- .../maximum-number-of-eaten-apples/README.md | 68 +++++ .../README.md | 71 ++++++ .../README.md | 69 +++++ problems/minimum-genetic-mutation/README.md | 2 +- .../README.md | 2 +- .../README.md | 13 +- .../README.md | 35 +-- problems/nth-magical-number/README.md | 65 ++--- .../README.md | 14 + .../mysql_schemas.sql | 9 + problems/number-of-digit-one/README.md | 24 +- .../README.md | 38 +++ .../README.md | 74 ++++++ .../README.md | 4 +- .../README.md | 14 +- .../README.md | 38 ++- problems/rectangle-area-ii/README.md | 26 +- problems/redundant-connection-ii/README.md | 58 ++--- problems/reformat-phone-number/README.md | 98 +++++++ .../README.md | 2 +- problems/remove-element/README.md | 6 +- problems/rising-temperature/README.md | 2 +- problems/same-tree/README.md | 40 ++- problems/search-a-2d-matrix/README.md | 13 +- problems/short-encoding-of-words/README.md | 19 +- problems/single-number-iii/README.md | 5 +- problems/sort-the-matrix-diagonally/README.md | 4 +- problems/stone-game-vi/README.md | 2 +- problems/string-without-aaa-or-bbb/README.md | 34 ++- .../README.md | 2 +- problems/swap-nodes-in-pairs/README.md | 1 + problems/triangle/README.md | 36 ++- problems/valid-mountain-array/README.md | 6 +- problems/where-will-the-ball-fall/README.md | 73 ++++++ problems/word-ladder-ii/README.md | 2 +- problems/word-ladder/README.md | 52 ++-- readme/1-300.md | 10 +- readme/301-600.md | 6 +- tag/README.md | 6 +- tag/array/README.md | 2 + tag/backtracking/README.md | 1 + tag/binary-search/README.md | 2 +- tag/bit-manipulation/README.md | 55 ++++ tag/breadth-first-search/README.md | 8 +- tag/depth-first-search/README.md | 6 +- tag/divide-and-conquer/README.md | 20 ++ tag/dynamic-programming/README.md | 239 ------------------ tag/geometry/README.md | 9 - tag/graph/README.md | 48 ++++ tag/greedy/README.md | 2 + tag/hash-table/README.md | 2 +- tag/heap/README.md | 1 + tag/line-sweep/README.md | 6 + tag/linked-list/README.md | 42 +++ tag/math/README.md | 2 +- tag/minimax/README.md | 8 - tag/queue/README.md | 9 - tag/random/README.md | 6 + tag/recursion/README.md | 4 + tag/reservoir-sampling/README.md | 2 + tag/sliding-window/README.md | 2 +- tag/sort/README.md | 71 ------ tag/stack/README.md | 3 +- tag/string/README.md | 210 --------------- tag/tags.json | 20 +- tag/tree/README.md | 8 +- tag/trie/README.md | 1 + tag/two-pointers/README.md | 2 + tag/union-find/README.md | 35 --- 115 files changed, 1828 insertions(+), 1210 deletions(-) create mode 100644 problems/average-waiting-time/README.md create mode 100644 problems/checking-existence-of-edge-length-limited-paths/README.md create mode 100644 problems/count-ways-to-distribute-candies/README.md create mode 100644 problems/daily-leads-and-partners/README.md create mode 100644 problems/daily-leads-and-partners/mysql_schemas.sql create mode 100644 problems/determine-if-string-halves-are-alike/README.md create mode 100644 problems/jump-game-vi/README.md create mode 100644 problems/maximum-binary-string-after-change/README.md create mode 100644 problems/maximum-erasure-value/README.md create mode 100644 problems/maximum-number-of-eaten-apples/README.md create mode 100644 problems/maximum-xor-with-an-element-from-array/README.md create mode 100644 problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md create mode 100644 problems/number-of-calls-between-two-persons/README.md create mode 100644 problems/number-of-calls-between-two-persons/mysql_schemas.sql create mode 100644 problems/number-of-distinct-substrings-in-a-string/README.md create mode 100644 problems/number-of-students-unable-to-eat-lunch/README.md create mode 100644 problems/reformat-phone-number/README.md create mode 100644 problems/where-will-the-ball-fall/README.md diff --git a/README.md b/README.md index 8ebdd386d..2b3e02071 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,22 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1707 | [Maximum XOR With an Element From Array](https://leetcode.com/problems/maximum-xor-with-an-element-from-array "与数组中元素的最大异或值") | [Go](problems/maximum-xor-with-an-element-from-array) | Hard | +| 1706 | [Where Will the Ball Fall](https://leetcode.com/problems/where-will-the-ball-fall "球会落何处") | [Go](problems/where-will-the-ball-fall) | Medium | +| 1705 | [Maximum Number of Eaten Apples](https://leetcode.com/problems/maximum-number-of-eaten-apples "吃苹果的最大数目") | [Go](problems/maximum-number-of-eaten-apples) | Medium | +| 1704 | [Determine if String Halves Are Alike](https://leetcode.com/problems/determine-if-string-halves-are-alike "判断字符串的两半是否相似") | [Go](problems/determine-if-string-halves-are-alike) | Easy | +| 1703 | [Minimum Adjacent Swaps for K Consecutive Ones](https://leetcode.com/problems/minimum-adjacent-swaps-for-k-consecutive-ones "得到连续 K 个 1 的最少相邻交换次数") | [Go](problems/minimum-adjacent-swaps-for-k-consecutive-ones) | Hard | +| 1702 | [Maximum Binary String After Change](https://leetcode.com/problems/maximum-binary-string-after-change "修改后的最大二进制字符串") | [Go](problems/maximum-binary-string-after-change) | Medium | +| 1701 | [Average Waiting Time](https://leetcode.com/problems/average-waiting-time "平均等待时间") | [Go](problems/average-waiting-time) | Medium | +| 1700 | [Number of Students Unable to Eat Lunch](https://leetcode.com/problems/number-of-students-unable-to-eat-lunch "无法吃午餐的学生数量") | [Go](problems/number-of-students-unable-to-eat-lunch) | Easy | +| 1699 | [Number of Calls Between Two Persons](https://leetcode.com/problems/number-of-calls-between-two-persons) 🔒 | [MySQL](problems/number-of-calls-between-two-persons) | Medium | +| 1698 | [Number of Distinct Substrings in a String](https://leetcode.com/problems/number-of-distinct-substrings-in-a-string) 🔒 | [Go](problems/number-of-distinct-substrings-in-a-string) | Medium | +| 1697 | [Checking Existence of Edge Length Limited Paths](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths "检查边长度限制的路径是否存在") | [Go](problems/checking-existence-of-edge-length-limited-paths) | Hard | +| 1696 | [Jump Game VI](https://leetcode.com/problems/jump-game-vi "跳跃游戏 VI") | [Go](problems/jump-game-vi) | Medium | +| 1695 | [Maximum Erasure Value](https://leetcode.com/problems/maximum-erasure-value "删除子数组的最大得分") | [Go](problems/maximum-erasure-value) | Medium | +| 1694 | [Reformat Phone Number](https://leetcode.com/problems/reformat-phone-number "重新格式化电话号码") | [Go](problems/reformat-phone-number) | Easy | +| 1693 | [Daily Leads and Partners](https://leetcode.com/problems/daily-leads-and-partners) 🔒 | [MySQL](problems/daily-leads-and-partners) | Easy | +| 1692 | [Count Ways to Distribute Candies](https://leetcode.com/problems/count-ways-to-distribute-candies) 🔒 | [Go](problems/count-ways-to-distribute-candies) | Hard | | 1691 | [Maximum Height by Stacking Cuboids](https://leetcode.com/problems/maximum-height-by-stacking-cuboids "堆叠长方体的最大高度") | [Go](problems/maximum-height-by-stacking-cuboids) | Hard | | 1690 | [Stone Game VII](https://leetcode.com/problems/stone-game-vii "石子游戏 VII") | [Go](problems/stone-game-vii) | Medium | | 1689 | [Partitioning Into Minimum Number Of Deci-Binary Numbers](https://leetcode.com/problems/partitioning-into-minimum-number-of-deci-binary-numbers "十-二进制数的最少数目") | [Go](problems/partitioning-into-minimum-number-of-deci-binary-numbers) | Medium | diff --git a/problems/average-waiting-time/README.md b/problems/average-waiting-time/README.md new file mode 100644 index 000000000..464b5a9ec --- /dev/null +++ b/problems/average-waiting-time/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../number-of-students-unable-to-eat-lunch "Number of Students Unable to Eat Lunch") +                 +[Next >](../maximum-binary-string-after-change "Maximum Binary String After Change") + +## [1701. Average Waiting Time (Medium)](https://leetcode.com/problems/average-waiting-time "平均等待时间") + +

    There is a restaurant with a single chef. You are given an array customers, where customers[i] = [arrivali, timei]:

    + +
      +
    • arrivali is the arrival time of the ith customer. The arrival times are sorted in non-decreasing order.
    • +
    • timei is the time needed to prepare the order of the ith customer.
    • +
    + +

    When a customer arrives, he gives the chef his order, and the chef starts preparing it once he is idle. The customer waits till the chef finishes preparing his order. The chef does not prepare food for more than one customer at a time. The chef prepares food for customers in the order they were given in the input.

    + +

    Return the average waiting time of all customers. Solutions within 10-5 from the actual answer are considered accepted.

    + +

     

    +

    Example 1:

    + +
    +Input: customers = [[1,2],[2,5],[4,3]]
    +Output: 5.00000
    +Explanation:
    +1) The first customer arrives at time 1, the chef takes his order and starts preparing it immediately at time 1, and finishes at time 3, so the waiting time of the first customer is 3 - 1 = 2.
    +2) The second customer arrives at time 2, the chef takes his order and starts preparing it at time 3, and finishes at time 8, so the waiting time of the second customer is 8 - 2 = 6.
    +3) The third customer arrives at time 4, the chef takes his order and starts preparing it at time 8, and finishes at time 11, so the waiting time of the third customer is 11 - 4 = 7.
    +So the average waiting time = (2 + 6 + 7) / 3 = 5.
    +
    + +

    Example 2:

    + +
    +Input: customers = [[5,2],[5,4],[10,3],[20,1]]
    +Output: 3.25000
    +Explanation:
    +1) The first customer arrives at time 5, the chef takes his order and starts preparing it immediately at time 5, and finishes at time 7, so the waiting time of the first customer is 7 - 5 = 2.
    +2) The second customer arrives at time 5, the chef takes his order and starts preparing it at time 7, and finishes at time 11, so the waiting time of the second customer is 11 - 5 = 6.
    +3) The third customer arrives at time 10, the chef takes his order and starts preparing it at time 11, and finishes at time 14, so the waiting time of the third customer is 14 - 10 = 4.
    +4) The fourth customer arrives at time 20, the chef takes his order and starts preparing it immediately at time 20, and finishes at time 21, so the waiting time of the fourth customer is 21 - 20 = 1.
    +So the average waiting time = (2 + 6 + 4 + 1) / 4 = 3.25.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= customers.length <= 105
    • +
    • 1 <= arrivali, timei <= 104
    • +
    • arrival<= arrivali+1
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Iterate on the customers, maintaining the time the chef will finish the previous orders. +
    + +
    +Hint 2 +If that time is before the current arrival time, the chef starts immediately. Else, the current customer waits till the chef finishes, and then the chef starts. +
    + +
    +Hint 3 +Update the running time by the time when the chef starts preparing + preparation time. +
    diff --git a/problems/balanced-binary-tree/README.md b/problems/balanced-binary-tree/README.md index 91cc92e44..cd36c5406 100644 --- a/problems/balanced-binary-tree/README.md +++ b/problems/balanced-binary-tree/README.md @@ -52,6 +52,7 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions 1. [Maximum Depth of Binary Tree](../maximum-depth-of-binary-tree) (Easy) diff --git a/problems/basic-calculator/README.md b/problems/basic-calculator/README.md index ce4653dd8..aec611066 100644 --- a/problems/basic-calculator/README.md +++ b/problems/basic-calculator/README.md @@ -11,33 +11,37 @@ ## [224. Basic Calculator (Hard)](https://leetcode.com/problems/basic-calculator "基本计算器") -

    Implement a basic calculator to evaluate a simple expression string.

    - -

    The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty spaces .

    +

    Given a string s representing an expression, implement a basic calculator to evaluate it.

    +

     

    Example 1:

    -Input: "1 + 1"
    +Input: s = "1 + 1"
     Output: 2
     

    Example 2:

    -Input: " 2-1 + 2 "
    -Output: 3
    +Input: s = " 2-1 + 2 " +Output: 3 +

    Example 3:

    -Input: "(1+(4+5+2)-3)+(6+8)"
    -Output: 23
    -Note: +Input: s = "(1+(4+5+2)-3)+(6+8)" +Output: 23 + + +

     

    +

    Constraints:

      -
    • You may assume that the given expression is always valid.
    • -
    • Do not use the eval built-in library function.
    • +
    • 1 <= s.length <= 3 * 105
    • +
    • s consists of digits, '+', '-', '(', ')', and ' '.
    • +
    • s represents a valid expression.
    ### Related Topics diff --git a/problems/binary-tree-level-order-traversal-ii/README.md b/problems/binary-tree-level-order-traversal-ii/README.md index d9e2f1472..979c5576a 100644 --- a/problems/binary-tree-level-order-traversal-ii/README.md +++ b/problems/binary-tree-level-order-traversal-ii/README.md @@ -9,7 +9,7 @@                  [Next >](../convert-sorted-array-to-binary-search-tree "Convert Sorted Array to Binary Search Tree") -## [107. Binary Tree Level Order Traversal II (Easy)](https://leetcode.com/problems/binary-tree-level-order-traversal-ii "二叉树的层次遍历 II") +## [107. Binary Tree Level Order Traversal II (Easy)](https://leetcode.com/problems/binary-tree-level-order-traversal-ii "二叉树的层序遍历 II")

    Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).

    diff --git a/problems/binary-tree-maximum-path-sum/README.md b/problems/binary-tree-maximum-path-sum/README.md index b236d9243..508e0d2df 100644 --- a/problems/binary-tree-maximum-path-sum/README.md +++ b/problems/binary-tree-maximum-path-sum/README.md @@ -41,6 +41,7 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions 1. [Path Sum](../path-sum) (Easy) diff --git a/problems/binary-tree-zigzag-level-order-traversal/README.md b/problems/binary-tree-zigzag-level-order-traversal/README.md index 10e9b8169..16ffa8bda 100644 --- a/problems/binary-tree-zigzag-level-order-traversal/README.md +++ b/problems/binary-tree-zigzag-level-order-traversal/README.md @@ -9,7 +9,7 @@                  [Next >](../maximum-depth-of-binary-tree "Maximum Depth of Binary Tree") -## [103. Binary Tree Zigzag Level Order Traversal (Medium)](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal "二叉树的锯齿形层次遍历") +## [103. Binary Tree Zigzag Level Order Traversal (Medium)](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal "二叉树的锯齿形层序遍历")

    Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).

    diff --git a/problems/burst-balloons/README.md b/problems/burst-balloons/README.md index 8dff26fd9..1ea3f3b9f 100644 --- a/problems/burst-balloons/README.md +++ b/problems/burst-balloons/README.md @@ -11,26 +11,38 @@ ## [312. Burst Balloons (Hard)](https://leetcode.com/problems/burst-balloons "戳气球") -

    Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will get nums[left] * nums[i] * nums[right] coins. Here left and right are adjacent indices of i. After the burst, the left and right then becomes adjacent.

    +

    You are given n balloons, indexed from 0 to n - 1. Each balloon is painted with a number on it represented by an array nums. You are asked to burst all the balloons.

    -

    Find the maximum coins you can collect by bursting the balloons wisely.

    +

    If you burst the ith balloon, you will get nums[left] * nums[i] * nums[right] coins. Here left and right are adjacent indices of i. After the burst, the left and right then becomes adjacent.

    -

    Note:

    +

    Return the maximum coins you can collect by bursting the balloons wisely.

    -
      -
    • You may imagine nums[-1] = nums[n] = 1. They are not real therefore you can not burst them.
    • -
    • 0 ≤ n ≤ 500, 0 ≤ nums[i] ≤ 100
    • -
    +

     

    +

    Example 1:

    + +
    +Input: nums = [3,1,5,8]
    +Output: 167
    +Explanation:
    +nums = [3,1,5,8] --> [3,5,8] --> [3,8] --> [8] --> []
    +coins =  3*1*5    +   3*5*8   +  1*3*8  + 1*8*1 = 167
    -

    Example:

    +

    Example 2:

    -Input: [3,1,5,8]
    -Output: 167 
    -Explanation: nums = [3,1,5,8] --> [3,5,8] -->   [3,8]   -->  [8]  --> []
    -             coins =  3*1*5      +  3*5*8    +  1*3*8      + 1*8*1   = 167
    +Input: nums = [1,5]
    +Output: 10
     
    +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= n <= 500
    • +
    • 0 <= nums[i] <= 100
    • +
    + ### Related Topics [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/check-if-array-pairs-are-divisible-by-k/README.md b/problems/check-if-array-pairs-are-divisible-by-k/README.md index d023b74de..273b50fc4 100644 --- a/problems/check-if-array-pairs-are-divisible-by-k/README.md +++ b/problems/check-if-array-pairs-are-divisible-by-k/README.md @@ -61,10 +61,10 @@
    • arr.length == n
    • -
    • 1 <= n <= 10^5
    • +
    • 1 <= n <= 105
    • n is even.
    • -
    • -10^9 <= arr[i] <= 10^9
    • -
    • 1 <= k <= 10^5
    • +
    • -109 <= arr[i] <= 109
    • +
    • 1 <= k <= 105
    ### Related Topics diff --git a/problems/checking-existence-of-edge-length-limited-paths/README.md b/problems/checking-existence-of-edge-length-limited-paths/README.md new file mode 100644 index 000000000..1365ed803 --- /dev/null +++ b/problems/checking-existence-of-edge-length-limited-paths/README.md @@ -0,0 +1,62 @@ + + + + + + + +[< Previous](../jump-game-vi "Jump Game VI") +                 +[Next >](../number-of-distinct-substrings-in-a-string "Number of Distinct Substrings in a String") + +## [1697. Checking Existence of Edge Length Limited Paths (Hard)](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths "检查边长度限制的路径是否存在") + +

    An undirected graph of n nodes is defined by edgeList, where edgeList[i] = [ui, vi, disi] denotes an edge between nodes ui and vi with distance disi. Note that there may be multiple edges between two nodes.

    + +

    Given an array queries, where queries[j] = [pj, qj, limitj], your task is to determine for each queries[j] whether there is a path between pj and qj such that each edge on the path has a distance strictly less than limitj .

    + +

    Return a boolean array answer, where answer.length == queries.length and the jth value of answer is true if there is a path for queries[j] is true, and false otherwise.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 3, edgeList = [[0,1,2],[1,2,4],[2,0,8],[1,0,16]], queries = [[0,1,2],[0,2,5]]
    +Output: [false,true]
    +Explanation: The above figure shows the given graph. Note that there are two overlapping edges between 0 and 1 with distances 2 and 16.
    +For the first query, between 0 and 1 there is no path where each distance is less than 2, thus we return false for this query.
    +For the second query, there is a path (0 -> 1 -> 2) of two edges with distances less than 5, thus we return true for this query.
    +
    + +

    Example 2:

    + +
    +Input: n = 5, edgeList = [[0,1,10],[1,2,5],[2,3,9],[3,4,13]], queries = [[0,4,14],[1,4,13]]
    +Output: [true,false]
    +Exaplanation: The above figure shows the given graph.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 105
    • +
    • 1 <= edgeList.length, queries.length <= 105
    • +
    • edgeList[i].length == 3
    • +
    • queries[j].length == 3
    • +
    • 0 <= ui, vi, pj, qj <= n - 1
    • +
    • ui != vi
    • +
    • pj != qj
    • +
    • 1 <= disi, limitj <= 109
    • +
    • There may be multiple edges between two nodes.
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Union Find](../../tag/union-find/README.md)] + +### Hints +
    +Hint 1 +All the queries are given in advance. Is there a way you can reorder the queries to avoid repeated computations? +
    diff --git a/problems/cherry-pickup/README.md b/problems/cherry-pickup/README.md index d78c181cc..bda881439 100644 --- a/problems/cherry-pickup/README.md +++ b/problems/cherry-pickup/README.md @@ -11,59 +11,52 @@ ## [741. Cherry Pickup (Hard)](https://leetcode.com/problems/cherry-pickup "摘樱桃") -

    In a N x N grid representing a field of cherries, each cell is one of three possible integers.

    - -

     

    +

    You are given an n x n grid representing a field of cherries, each cell is one of three possible integers.

      -
    • 0 means the cell is empty, so you can pass through;
    • -
    • 1 means the cell contains a cherry, that you can pick up and pass through;
    • -
    • -1 means the cell contains a thorn that blocks your way.
    • +
    • 0 means the cell is empty, so you can pass through,
    • +
    • 1 means the cell contains a cherry that you can pick up and pass through, or
    • +
    • -1 means the cell contains a thorn that blocks your way.
    -

     

    - -

    Your task is to collect maximum number of cherries possible by following the rules below:

    - -

     

    +

    Return the maximum number of cherries you can collect by following the rules below:

      -
    • Starting at the position (0, 0) and reaching (N-1, N-1) by moving right or down through valid path cells (cells with value 0 or 1);
    • -
    • After reaching (N-1, N-1), returning to (0, 0) by moving left or up through valid path cells;
    • -
    • When passing through a path cell containing a cherry, you pick it up and the cell becomes an empty cell (0);
    • -
    • If there is no valid path between (0, 0) and (N-1, N-1), then no cherries can be collected.
    • +
    • Starting at the position (0, 0) and reaching (n - 1, n - 1) by moving right or down through valid path cells (cells with value 0 or 1).
    • +
    • After reaching (n - 1, n - 1), returning to (0, 0) by moving left or up through valid path cells.
    • +
    • When passing through a path cell containing a cherry, you pick it up, and the cell becomes an empty cell 0.
    • +
    • If there is no valid path between (0, 0) and (n - 1, n - 1), then no cherries can be collected.

     

    - -

     

    - -

    Example 1:

    - +

    Example 1:

    +
    -Input: grid =
    -[[0, 1, -1],
    - [1, 0, -1],
    - [1, 1,  1]]
    -Output: 5
    -Explanation: 
    -The player started at (0, 0) and went down, down, right right to reach (2, 2).
    +Input: grid = [[0,1,-1],[1,0,-1],[1,1,1]]
    +Output: 5
    +Explanation: The player started at (0, 0) and went down, down, right right to reach (2, 2).
     4 cherries were picked up during this single trip, and the matrix becomes [[0,1,-1],[0,0,-1],[0,0,0]].
     Then, the player went left, up, up, left to return home, picking up one more cherry.
     The total number of cherries picked up is 5, and this is the maximum possible.
     
    -

     

    +

    Example 2:

    -

    Note:

    +
    +Input: grid = [[1,1,-1],[1,-1,1],[-1,1,1]]
    +Output: 0
    +
    + +

     

    +

    Constraints:

      -
    • grid is an N by N 2D array, with 1 <= N <= 50.
    • -
    • Each grid[i][j] is an integer in the set {-1, 0, 1}.
    • -
    • It is guaranteed that grid[0][0] and grid[N-1][N-1] are not -1.
    • -
    • -

       

      -
    • +
    • n == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= n <= 50
    • +
    • grid[i][j] is -1, 0, or 1.
    • +
    • grid[0][0] != -1
    • +
    • grid[n - 1][n - 1] != -1
    ### Related Topics diff --git a/problems/concatenated-words/README.md b/problems/concatenated-words/README.md index bb66dc160..df394b693 100644 --- a/problems/concatenated-words/README.md +++ b/problems/concatenated-words/README.md @@ -11,27 +11,36 @@ ## [472. Concatenated Words (Hard)](https://leetcode.com/problems/concatenated-words "连接词") -Given a list of words (without duplicates), please write a program that returns all concatenated words in the given list of words. +

    Given a list of words (without duplicates), please write a program that returns all concatenated words in the given list of words.

    +

    A concatenated word is defined as a string that is comprised entirely of at least two shorter words in the given array.

    -

    Example:
    +

     

    +

    Example 1:

    +
    -Input: ["cat","cats","catsdogcats","dog","dogcatsdog","hippopotamuses","rat","ratcatdogcat"]
    +Input: words = ["cat","cats","catsdogcats","dog","dogcatsdog","hippopotamuses","rat","ratcatdogcat"]
    +Output: ["catsdogcats","dogcatsdog","ratcatdogcat"]
    +Explanation: "catsdogcats" can be concatenated by "cats", "dog" and "cats"; 
    +"dogcatsdog" can be concatenated by "dog", "cats" and "dog"; 
    +"ratcatdogcat" can be concatenated by "rat", "cat", "dog" and "cat".
    -Output: ["catsdogcats","dogcatsdog","ratcatdogcat"] +

    Example 2:

    -Explanation: "catsdogcats" can be concatenated by "cats", "dog" and "cats";
    "dogcatsdog" can be concatenated by "dog", "cats" and "dog";
    "ratcatdogcat" can be concatenated by "rat", "cat", "dog" and "cat". +
    +Input: words = ["cat","dog","catdog"]
    +Output: ["catdog"]
     
    -

    - -

    Note:
    -

      -
    1. The number of elements of the given array will not exceed 10,000 -
    2. The length sum of elements in the given array will not exceed 600,000.
    3. -
    4. All the input string will only include lower case letters.
    5. -
    6. The returned elements order does not matter.
    7. -
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 104
    • +
    • 0 <= words[i].length <= 1000
    • +
    • words[i] consists of only lowercase English letters.
    • +
    • 0 <= sum(words[i].length) <= 6 * 105
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/consecutive-numbers/README.md b/problems/consecutive-numbers/README.md index 6a5efe60c..2944d265c 100644 --- a/problems/consecutive-numbers/README.md +++ b/problems/consecutive-numbers/README.md @@ -11,28 +11,47 @@ ## [180. Consecutive Numbers (Medium)](https://leetcode.com/problems/consecutive-numbers "连续出现的数字") -

    Write a SQL query to find all numbers that appear at least three times consecutively.

    +

    Table: Logs

    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| id          | int     |
    +| num         | varchar |
    ++-------------+---------+
    +id is the primary key for this table.
    +
    + +

     

    + +

    Write an SQL query to find all numbers that appear at least three times consecutively.

    + +

    Return the result table in any order.

    + +

    The query result format is in the following example:

    + +

     

    + +
    +Logs table:
     +----+-----+
     | Id | Num |
     +----+-----+
    -| 1  |  1  |
    -| 2  |  1  |
    -| 3  |  1  |
    -| 4  |  2  |
    -| 5  |  1  |
    -| 6  |  2  |
    -| 7  |  2  |
    +| 1  | 1   |
    +| 2  | 1   |
    +| 3  | 1   |
    +| 4  | 2   |
    +| 5  | 1   |
    +| 6  | 2   |
    +| 7  | 2   |
     +----+-----+
    -
    -

    For example, given the above Logs table, 1 is the only number that appears consecutively for at least three times.

    - -
    +Result table:
     +-----------------+
     | ConsecutiveNums |
     +-----------------+
     | 1               |
     +-----------------+
    +1 is the only number that appears consecutively for at least three times.
     
    diff --git a/problems/count-ways-to-distribute-candies/README.md b/problems/count-ways-to-distribute-candies/README.md new file mode 100644 index 000000000..e63e5eb22 --- /dev/null +++ b/problems/count-ways-to-distribute-candies/README.md @@ -0,0 +1,38 @@ + + + + + + + +[< Previous](../maximum-height-by-stacking-cuboids "Maximum Height by Stacking Cuboids ") +                 +[Next >](../daily-leads-and-partners "Daily Leads and Partners") + +## [1692. Count Ways to Distribute Candies (Hard)](https://leetcode.com/problems/count-ways-to-distribute-candies "") + + + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Try to define a recursive approach. For the ith candies, there will be one of the two following cases: +
    + +
    +Hint 2 +If the i - 1 previous candies are already distributed into k bags for the ith candy, you can have k * dp[n - 1][k] ways to distribute the ith candy. We need then to solve the state of (n - 1, k). +
    + +
    +Hint 3 +If the i - 1 previous candies are already distributed into k - 1 bags for the ith candy, you can have dp[n - 1][k - 1] ways to distribute the ith candy. We need then to solve the state of (n - 1, k - 1). +
    + +
    +Hint 4 +This approach will be too slow and will traverse some states more than once. We should use memoization to make the algorithm efficient. +
    diff --git a/problems/daily-leads-and-partners/README.md b/problems/daily-leads-and-partners/README.md new file mode 100644 index 000000000..aaf480f21 --- /dev/null +++ b/problems/daily-leads-and-partners/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../count-ways-to-distribute-candies "Count Ways to Distribute Candies") +                 +[Next >](../reformat-phone-number "Reformat Phone Number") + +## [1693. Daily Leads and Partners (Easy)](https://leetcode.com/problems/daily-leads-and-partners "") + + diff --git a/problems/daily-leads-and-partners/mysql_schemas.sql b/problems/daily-leads-and-partners/mysql_schemas.sql new file mode 100644 index 000000000..53e2eb911 --- /dev/null +++ b/problems/daily-leads-and-partners/mysql_schemas.sql @@ -0,0 +1,12 @@ +Create table If Not Exists DailySales(date_id date, make_name varchar(20), lead_id int, partner_id int); +Truncate table DailySales; +insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-8', 'toyota', '0', '1'); +insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-8', 'toyota', '1', '0'); +insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-8', 'toyota', '1', '2'); +insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-7', 'toyota', '0', '2'); +insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-7', 'toyota', '0', '1'); +insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-8', 'honda', '1', '2'); +insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-8', 'honda', '2', '1'); +insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-7', 'honda', '0', '1'); +insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-7', 'honda', '1', '2'); +insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-7', 'honda', '2', '1'); diff --git a/problems/design-underground-system/README.md b/problems/design-underground-system/README.md index 18ab2eb5a..ddd1c885f 100644 --- a/problems/design-underground-system/README.md +++ b/problems/design-underground-system/README.md @@ -11,30 +11,30 @@ ## [1396. Design Underground System (Medium)](https://leetcode.com/problems/design-underground-system "设计地铁系统") -

    Implement the class UndergroundSystem that supports three methods:

    - -

    1. checkIn(int id, string stationName, int t)

    - -
      -
    • A customer with id card equal to id, gets in the station stationName at time t.
    • -
    • A customer can only be checked into one place at a time.
    • -
    - -

    2. checkOut(int id, string stationName, int t)

    - -
      -
    • A customer with id card equal to id, gets out from the station stationName at time t.
    • -
    - -

    3. getAverageTime(string startStation, string endStation) 

    +

    Implement the UndergroundSystem class:

      -
    • Returns the average time to travel between the startStation and the endStation.
    • -
    • The average time is computed from all the previous traveling from startStation to endStation that happened directly.
    • -
    • Call to getAverageTime is always valid.
    • +
    • void checkIn(int id, string stationName, int t) +
        +
      • A customer with a card id equal to id, gets in the station stationName at time t.
      • +
      • A customer can only be checked into one place at a time.
      • +
      +
    • +
    • void checkOut(int id, string stationName, int t) +
        +
      • A customer with a card id equal to id, gets out from the station stationName at time t.
      • +
      +
    • +
    • double getAverageTime(string startStation, string endStation) +
        +
      • Returns the average time to travel between the startStation and the endStation.
      • +
      • The average time is computed from all the previous traveling from startStation to endStation that happened directly.
      • +
      • Call to getAverageTime is always valid.
      • +
      +
    -

    You can assume all calls to checkIn and checkOut methods are consistent. That is, if a customer gets in at time t1 at some station, then it gets out at time t2 with t2 > t1. All events happen in chronological order.

    +

    You can assume all calls to checkIn and checkOut methods are consistent. If a customer gets in at time t1 at some station, they get out at time t2 with t2 > t1. All events happen in chronological order.

     

    Example 1:

    @@ -90,11 +90,11 @@ undergroundSystem.getAverageTime("Leyton", "Paradise"); // r

    Constraints:

      -
    • There will be at most 20000 operations.
    • -
    • 1 <= id, t <= 10^6
    • -
    • All strings consist of uppercase, lowercase English letters and digits.
    • -
    • 1 <= stationName.length <= 10
    • -
    • Answers within 10^-5 of the actual value will be accepted as correct.
    • +
    • There will be at most 20000 operations.
    • +
    • 1 <= id, t <= 106
    • +
    • All strings consist of uppercase and lowercase English letters, and digits.
    • +
    • 1 <= stationName.length <= 10
    • +
    • Answers within 10-5 of the actual value will be accepted as correct.
    ### Related Topics diff --git a/problems/determine-if-string-halves-are-alike/README.md b/problems/determine-if-string-halves-are-alike/README.md new file mode 100644 index 000000000..52fddc049 --- /dev/null +++ b/problems/determine-if-string-halves-are-alike/README.md @@ -0,0 +1,68 @@ + + + + + + + +[< Previous](../minimum-adjacent-swaps-for-k-consecutive-ones "Minimum Adjacent Swaps for K Consecutive Ones") +                 +[Next >](../maximum-number-of-eaten-apples "Maximum Number of Eaten Apples") + +## [1704. Determine if String Halves Are Alike (Easy)](https://leetcode.com/problems/determine-if-string-halves-are-alike "判断字符串的两半是否相似") + +

    You are given a string s of even length. Split this string into two halves of equal lengths, and let a be the first half and b be the second half.

    + +

    Two strings are alike if they have the same number of vowels ('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'). Notice that s contains uppercase and lowercase letters.

    + +

    Return true if a and b are alike. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "book"
    +Output: true
    +Explanation: a = "bo" and b = "ok". a has 1 vowel and b has 1 vowel. Therefore, they are alike.
    +
    + +

    Example 2:

    + +
    +Input: s = "textbook"
    +Output: false
    +Explanation: a = "text" and b = "book". a has 1 vowel whereas b has 2. Therefore, they are not alike.
    +Notice that the vowel o is counted twice.
    +
    + +

    Example 3:

    + +
    +Input: s = "MerryChristmas"
    +Output: false
    +
    + +

    Example 4:

    + +
    +Input: s = "AbCdEfGh"
    +Output: true
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= s.length <= 1000
    • +
    • s.length is even.
    • +
    • s consists of uppercase and lowercase letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Create a function that checks if a character is a vowel, either uppercase or lowercase. +
    diff --git a/problems/distribute-coins-in-binary-tree/README.md b/problems/distribute-coins-in-binary-tree/README.md index 5a8d2fecc..f58dc8a7c 100644 --- a/problems/distribute-coins-in-binary-tree/README.md +++ b/problems/distribute-coins-in-binary-tree/README.md @@ -11,68 +11,52 @@ ## [979. Distribute Coins in Binary Tree (Medium)](https://leetcode.com/problems/distribute-coins-in-binary-tree "在二叉树中分配硬币") -

    Given the root of a binary tree with N nodes, each node in the tree has node.val coins, and there are N coins total.

    +

    You are given the root of a binary tree with n nodes where each node in the tree has node.val coins and there are n coins total.

    -

    In one move, we may choose two adjacent nodes and move one coin from one node to another.  (The move may be from parent to child, or from child to parent.)

    +

    In one move, we may choose two adjacent nodes and move one coin from one node to another. (A move may be from parent to child, or from child to parent.)

    Return the number of moves required to make every node have exactly one coin.

     

    - -

    Example 1:

    - -

    - +
    -Input: [3,0,0]
    -Output: 2
    +Input: root = [3,0,0]
    +Output: 2
     Explanation: From the root of the tree, we move one coin to its left child, and one coin to its right child.
     
    -

    Example 2:

    - -

    - +
    -Input: [0,3,0]
    -Output: 3
    +Input: root = [0,3,0]
    +Output: 3
     Explanation: From the left child of the root, we move two coins to the root [taking two moves].  Then, we move one coin from the root of the tree to the right child.
     
    -

    Example 3:

    - -

    - +
    -Input: [1,0,2]
    -Output: 2
    +Input: root = [1,0,2]
    +Output: 2
     
    -

    Example 4:

    - -

    - +
    -Input: [1,0,0,null,3]
    -Output: 4
    +Input: root = [1,0,0,null,3]
    +Output: 4
     

     

    - -

    Note:

    - -
      -
    1. 1<= N <= 100
    2. -
    3. 0 <= node.val <= N
    4. -
    -
    -
    -
    -
    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is n.
    • +
    • 1 <= n <= 100
    • +
    • 0 <= Node.val <= n
    • +
    • The sum of Node.val is n.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/exchange-seats/README.md b/problems/exchange-seats/README.md index b68568d1a..f05ac0931 100644 --- a/problems/exchange-seats/README.md +++ b/problems/exchange-seats/README.md @@ -12,13 +12,12 @@ ## [626. Exchange Seats (Medium)](https://leetcode.com/problems/exchange-seats "换座位")

    Mary is a teacher in a middle school and she has a table seat storing students' names and their corresponding seat ids.

    -The column id is continuous increment. -

     

    -Mary wants to change seats for the adjacent students. +

    The column id is continuous increment.

    -

     

    -Can you write a SQL query to output the result for Mary? +

    Mary wants to change seats for the adjacent students.

    + +

    Can you write a SQL query to output the result for Mary?

     

    @@ -33,9 +32,8 @@ Can you write a SQL query to output the result for Mary? | 5 | Jeames | +---------+---------+ -For the sample input, the output is: -

     

    +

    For the sample input, the output is:

     +---------+---------+
    @@ -49,5 +47,6 @@ For the sample input, the output is:
     +---------+---------+
     
    -

    Note:
    -If the number of students is odd, there is no need to change the last one's seat.

    +

    Note:

    + +

    If the number of students is odd, there is no need to change the last one's seat.

    diff --git a/problems/factorial-trailing-zeroes/README.md b/problems/factorial-trailing-zeroes/README.md index 10e4a76f7..d5a86fafa 100644 --- a/problems/factorial-trailing-zeroes/README.md +++ b/problems/factorial-trailing-zeroes/README.md @@ -43,7 +43,7 @@

    Constraints:

      -
    • 1 <= n <= 104
    • +
    • 0 <= n <= 104
    ### Related Topics diff --git a/problems/fibonacci-number/README.md b/problems/fibonacci-number/README.md index c4047fe08..667678df2 100644 --- a/problems/fibonacci-number/README.md +++ b/problems/fibonacci-number/README.md @@ -11,21 +11,20 @@ ## [509. Fibonacci Number (Easy)](https://leetcode.com/problems/fibonacci-number "斐波那契数") -

    The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,

    +

    The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,

    -F(0) = 0,   F(1) = 1
    -F(N) = F(N - 1) + F(N - 2), for N > 1.
    +F(0) = 0, F(1) = 1
    +F(n) = F(n - 1) + F(n - 2), for n > 1.
     
    -

    Given N, calculate F(N).

    +

    Given n, calculate F(n).

     

    -

    Example 1:

    -Input: 2
    +Input: n = 2
     Output: 1
     Explanation: F(2) = F(1) + F(0) = 1 + 0 = 1.
     
    @@ -33,7 +32,7 @@ F(N) = F(N - 1) + F(N - 2), for N > 1.

    Example 2:

    -Input: 3
    +Input: n = 3
     Output: 2
     Explanation: F(3) = F(2) + F(1) = 1 + 1 = 2.
     
    @@ -41,16 +40,17 @@ F(N) = F(N - 1) + F(N - 2), for N > 1.

    Example 3:

    -Input: 4
    +Input: n = 4
     Output: 3
     Explanation: F(4) = F(3) + F(2) = 2 + 1 = 3.
     

     

    +

    Constraints:

    -

    Note:

    - -

    0 ≤ N ≤ 30.

    +
      +
    • 0 <= n <= 30
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/find-bottom-left-tree-value/README.md b/problems/find-bottom-left-tree-value/README.md index fbca72dfd..eda7a540a 100644 --- a/problems/find-bottom-left-tree-value/README.md +++ b/problems/find-bottom-left-tree-value/README.md @@ -11,43 +11,30 @@ ## [513. Find Bottom Left Tree Value (Medium)](https://leetcode.com/problems/find-bottom-left-tree-value "找树左下角的值") -

    -Given a binary tree, find the leftmost value in the last row of the tree. -

    +

    Given the root of a binary tree, return the leftmost value in the last row of the tree.

    -

    Example 1:
    +

     

    +

    Example 1:

    +
    -Input:
    -
    -    2
    -   / \
    -  1   3
    -
    -Output:
    -1
    +Input: root = [2,1,3]
    +Output: 1
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input:
    -
    -        1
    -       / \
    -      2   3
    -     /   / \
    -    4   5   6
    -       /
    -      7
    -
    -Output:
    -7
    +Input: root = [1,2,3,4,null,5,6,null,null,7]
    +Output: 7
     
    -

    -

    Note: -You may assume the tree (i.e., the given root node) is not NULL. -

    +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [1, 104].
    • +
    • -231 <= Node.val <= 231 - 1
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/find-the-smallest-divisor-given-a-threshold/README.md b/problems/find-the-smallest-divisor-given-a-threshold/README.md index 2dec8542a..daee6eb4b 100644 --- a/problems/find-the-smallest-divisor-given-a-threshold/README.md +++ b/problems/find-the-smallest-divisor-given-a-threshold/README.md @@ -45,9 +45,9 @@ If the divisor is 4 we can get a sum to 7 (1+1+2+3) and if the divisor is 5 the

    Constraints:

      -
    • 1 <= nums.length <= 5 * 10^4
    • -
    • 1 <= nums[i] <= 10^6
    • -
    • nums.length <= threshold <= 10^6
    • +
    • 1 <= nums.length <= 5 * 104
    • +
    • 1 <= nums[i] <= 106
    • +
    • nums.length <= threshold <= 106
    ### Related Topics diff --git a/problems/friend-requests-i-overall-acceptance-rate/README.md b/problems/friend-requests-i-overall-acceptance-rate/README.md index 455c32bf6..ea607c203 100644 --- a/problems/friend-requests-i-overall-acceptance-rate/README.md +++ b/problems/friend-requests-i-overall-acceptance-rate/README.md @@ -9,7 +9,7 @@                  [Next >](../range-addition-ii "Range Addition II") -## [597. Friend Requests I: Overall Acceptance Rate (Easy)](https://leetcode.com/problems/friend-requests-i-overall-acceptance-rate "好友申请 I :总体通过率") +## [597. Friend Requests I: Overall Acceptance Rate (Easy)](https://leetcode.com/problems/friend-requests-i-overall-acceptance-rate "好友申请 I:总体通过率") In social network like Facebook or Twitter, people send friend requests and accept others’ requests as well. Now given two tables as below:

     

    diff --git a/problems/game-of-life/README.md b/problems/game-of-life/README.md index 59dfaf890..5022a55d0 100644 --- a/problems/game-of-life/README.md +++ b/problems/game-of-life/README.md @@ -18,37 +18,44 @@
    1. Any live cell with fewer than two live neighbors dies, as if caused by under-population.
    2. Any live cell with two or three live neighbors lives on to the next generation.
    3. -
    4. Any live cell with more than three live neighbors dies, as if by over-population..
    5. +
    6. Any live cell with more than three live neighbors dies, as if by over-population.
    7. Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.

    Write a function to compute the next state (after one update) of the board given its current state. The next state is created by applying the above rules simultaneously to every cell in the current state, where births and deaths occur simultaneously.

    -

    Example:

    +

     

    +

    Example 1:

    + +
    +Input: board = [[0,1,0],[0,0,1],[1,1,1],[0,0,0]]
    +Output: [[0,0,0],[1,0,1],[0,1,1],[0,1,0]]
    +
    +

    Example 2:

    +
    -Input: 
    -[
    -  [0,1,0],
    -  [0,0,1],
    -  [1,1,1],
    -  [0,0,0]
    -]
    -Output: 
    -[
    -  [0,0,0],
    -  [1,0,1],
    -  [0,1,1],
    -  [0,1,0]
    -]
    +Input: board = [[1,1],[1,0]]
    +Output: [[1,1],[1,1]]
     
    -

    Follow up:

    +

     

    +

    Constraints:

    -
      -
    1. Could you solve it in-place? Remember that the board needs to be updated at the same time: You cannot update some cells first and then use their updated values to update other cells.
    2. +
        +
      • m == board.length
      • +
      • n == board[i].length
      • +
      • 1 <= m, n <= 25
      • +
      • board[i][j] is 0 or 1.
      • +
      + +

       

      +

      Follow up:

      + +
        +
      • Could you solve it in-place? Remember that the board needs to be updated simultaneously: You cannot update some cells first and then use their updated values to update other cells.
      • In this question, we represent the board using a 2D array. In principle, the board is infinite, which would cause problems when the active area encroaches the border of the array. How would you address these problems?
      • -
    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/grid-illumination/README.md b/problems/grid-illumination/README.md index db83aaade..bbf36b197 100644 --- a/problems/grid-illumination/README.md +++ b/problems/grid-illumination/README.md @@ -28,7 +28,7 @@ Explanation: We have the initial grid with all lamps turned off. In the above picture we see the grid after turning on the lamp at grid[0][0] then turning on the lamp at grid[4][4]. The 0th query asks if the lamp at grid[1][1] is illuminated or not (the blue square). It is illuminated, so set ans[0] = 1. Then, we turn off all lamps in the red square. -The 1st query asks if the lamp at grid[1][0] is illuminated or not (the blue square). It is not illuminated, so set ans[1] = 1. Then, we turn off all lamps in the red rectangle. +The 1st query asks if the lamp at grid[1][0] is illuminated or not (the blue square). It is not illuminated, so set ans[1] = 0. Then, we turn off all lamps in the red rectangle. diff --git a/problems/happy-number/README.md b/problems/happy-number/README.md index 5c6fe7fc3..8240a0ad8 100644 --- a/problems/happy-number/README.md +++ b/problems/happy-number/README.md @@ -11,24 +11,45 @@ ## [202. Happy Number (Easy)](https://leetcode.com/problems/happy-number "快乐数") -

    Write an algorithm to determine if a number n is "happy".

    +

    Write an algorithm to determine if a number n is happy.

    -

    A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers.

    +

    A happy number is a number defined by the following process:

    -

    Return True if n is a happy number, and False if not.

    +
      +
    • Starting with any positive integer, replace the number by the sum of the squares of its digits.
    • +
    • Repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1.
    • +
    • Those numbers for which this process ends in 1 are happy.
    • +
    -

    Example: 

    +

    Return true if n is a happy number, and false if not.

    + +

     

    +

    Example 1:

    -Input: 19
    +Input: n = 19
     Output: true
    -Explanation: 
    -12 + 92 = 82
    +Explanation:
    +12 + 92 = 82
     82 + 22 = 68
     62 + 82 = 100
     12 + 02 + 02 = 1
     
    +

    Example 2:

    + +
    +Input: n = 2
    +Output: false
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 231 - 1
    • +
    + ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/implement-stack-using-queues/README.md b/problems/implement-stack-using-queues/README.md index ae6a8f5f7..958a77d5d 100644 --- a/problems/implement-stack-using-queues/README.md +++ b/problems/implement-stack-using-queues/README.md @@ -58,7 +58,7 @@ myStack.empty(); // return False

     

    -Follow-up: Can you implement the stack such that each operation is amortized O(1) time complexity? In other words, performing n operations will take overall O(n) time even if one of those operations may take longer. +Follow-up: Can you implement the stack such that each operation is amortized O(1) time complexity? In other words, performing n operations will take overall O(n) time even if one of those operations may take longer. You can use more than two queues. ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/increasing-triplet-subsequence/README.md b/problems/increasing-triplet-subsequence/README.md index 257fbdbac..fb3e9d238 100644 --- a/problems/increasing-triplet-subsequence/README.md +++ b/problems/increasing-triplet-subsequence/README.md @@ -11,32 +11,43 @@ ## [334. Increasing Triplet Subsequence (Medium)](https://leetcode.com/problems/increasing-triplet-subsequence "递增的三元子序列") -

    Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.

    +

    Given an integer array nums, return true if there exists a triple of indices (i, j, k) such that i < j < k and nums[i] < nums[j] < nums[k]. If no such indices exists, return false.

    -

    Formally the function should:

    - -
    Return true if there exists i, j, k
    -such that arr[i] < arr[j] < arr[k] given 0 ≤ i < j < kn-1 else return false.
    - -

    Note: Your algorithm should run in O(n) time complexity and O(1) space complexity.

    - -
    +

     

    Example 1:

    -Input: [1,2,3,4,5]
    -Output: true
    +Input: nums = [1,2,3,4,5]
    +Output: true
    +Explanation: Any triplet where i < j < k is valid.
     
    -

    Example 2:

    -Input: [5,4,3,2,1]
    -Output: false
    +Input: nums = [5,4,3,2,1]
    +Output: false
    +Explanation: No triplet exists.
    +
    + +

    Example 3:

    + +
    +Input: nums = [2,1,5,0,4,6]
    +Output: true
    +Explanation: The triplet (3, 4, 5) is valid because nums[3] == 0 < nums[4] == 4 < nums[5] == 6.
     
    -
    -
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • -231 <= nums[i] <= 231 - 1
    • +
    + +

     

    +Follow up: Could you implement a solution that runs in O(n) time complexity and O(1) space complexity? ### Similar Questions 1. [Longest Increasing Subsequence](../longest-increasing-subsequence) (Medium) diff --git a/problems/jewels-and-stones/README.md b/problems/jewels-and-stones/README.md index 62e973d48..04d02219c 100644 --- a/problems/jewels-and-stones/README.md +++ b/problems/jewels-and-stones/README.md @@ -11,29 +11,25 @@ ## [771. Jewels and Stones (Easy)](https://leetcode.com/problems/jewels-and-stones "宝石与石头") -

    You're given strings J representing the types of stones that are jewels, and S representing the stones you have.  Each character in S is a type of stone you have.  You want to know how many of the stones you have are also jewels.

    +

    You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the stones you have are also jewels.

    -

    The letters in J are guaranteed distinct, and all characters in J and S are letters. Letters are case sensitive, so "a" is considered a different type of stone from "A".

    +

    Letters are case sensitive, so "a" is considered a different type of stone from "A".

    +

     

    Example 1:

    - -
    -Input: J = "aA", S = "aAAbbbb"
    +
    Input: jewels = "aA", stones = "aAAbbbb"
     Output: 3
    -
    - -

    Example 2:

    - -
    -Input: J = "z", S = "ZZ"
    +

    Example 2:

    +
    Input: jewels = "z", stones = "ZZ"
     Output: 0
     
    - -

    Note:

    +

     

    +

    Constraints:

      -
    • S and J will consist of letters and have length at most 50.
    • -
    • The characters in J are distinct.
    • +
    • 1 <= jewels.length, stones.length <= 50
    • +
    • jewels and stones consist of only English letters.
    • +
    • All the characters of jewels are unique.
    ### Related Topics diff --git a/problems/jump-game-iii/README.md b/problems/jump-game-iii/README.md index 9b9c278ff..4b5109f5d 100644 --- a/problems/jump-game-iii/README.md +++ b/problems/jump-game-iii/README.md @@ -49,7 +49,7 @@ index 0 -> index 4 -> index 1 -> index 3

    Constraints:

      -
    • 1 <= arr.length <= 5 * 10^4
    • +
    • 1 <= arr.length <= 5 * 104
    • 0 <= arr[i] < arr.length
    • 0 <= start < arr.length
    diff --git a/problems/jump-game-vi/README.md b/problems/jump-game-vi/README.md new file mode 100644 index 000000000..2e41a72ec --- /dev/null +++ b/problems/jump-game-vi/README.md @@ -0,0 +1,63 @@ + + + + + + + +[< Previous](../maximum-erasure-value "Maximum Erasure Value") +                 +[Next >](../checking-existence-of-edge-length-limited-paths "Checking Existence of Edge Length Limited Paths") + +## [1696. Jump Game VI (Medium)](https://leetcode.com/problems/jump-game-vi "跳跃游戏 VI") + +

    You are given a 0-indexed integer array nums and an integer k.

    + +

    You are initially standing at index 0. In one move, you can jump at most k steps forward without going outside the boundaries of the array. That is, you can jump from index i to any index in the range [i + 1, min(n - 1, i + k)] inclusive.

    + +

    You want to reach the last index of the array (index n - 1). Your score is the sum of all nums[j] for each index j you visited in the array.

    + +

    Return the maximum score you can get.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,-1,-2,4,-7,3], k = 2
    +Output: 7
    +Explanation: You can choose your jumps forming the subsequence [1,-1,4,3] (underlined above). The sum is 7.
    +
    + +

    Example 2:

    + +
    +Input: nums = [10,-5,-2,4,0,3], k = 3
    +Output: 17
    +Explanation: You can choose your jumps forming the subsequence [10,4,3] (underlined above). The sum is 17.
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,-5,-20,4,-1,3,-6,-3], k = 2
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    •  1 <= nums.length, k <= 105
    • +
    • -104 <= nums[i] <= 104
    • +
    + +### Hints +
    +Hint 1 +Let dp[i] be "the maximum score to reach the end starting at index i". The answer for dp[i] is nums[i] + min{dp[i+j]} for 1 <= j <= k. That gives an O(n*k) solution. +
    + +
    +Hint 2 +Instead of checking every j for every i, keep track of the smallest dp[i] values in a heap and calculate dp[i] from right to left. When the smallest value in the heap is out of bounds of the current index, remove it and keep checking. +
    diff --git a/problems/jump-game/README.md b/problems/jump-game/README.md index 566f54531..b0d1ac8b7 100644 --- a/problems/jump-game/README.md +++ b/problems/jump-game/README.md @@ -11,7 +11,7 @@ ## [55. Jump Game (Medium)](https://leetcode.com/problems/jump-game "跳跃游戏") -

    Given an array of non-negative integers, you are initially positioned at the first index of the array.

    +

    Given an array of non-negative integers nums, you are initially positioned at the first index of the array.

    Each element in the array represents your maximum jump length at that position.

    @@ -38,8 +38,8 @@

    Constraints:

      -
    • 1 <= nums.length <= 3 * 10^4
    • -
    • 0 <= nums[i][j] <= 10^5
    • +
    • 1 <= nums.length <= 3 * 104
    • +
    • 0 <= nums[i] <= 105
    ### Related Topics diff --git a/problems/length-of-longest-fibonacci-subsequence/README.md b/problems/length-of-longest-fibonacci-subsequence/README.md index 9ee36d6ae..2d0bb2b6b 100644 --- a/problems/length-of-longest-fibonacci-subsequence/README.md +++ b/problems/length-of-longest-fibonacci-subsequence/README.md @@ -11,49 +11,38 @@ ## [873. Length of Longest Fibonacci Subsequence (Medium)](https://leetcode.com/problems/length-of-longest-fibonacci-subsequence "最长的斐波那契子序列的长度") -

    A sequence X_1, X_2, ..., X_n is fibonacci-like if:

    +

    A sequence X1, X2, ..., Xn is Fibonacci-like if:

    • n >= 3
    • -
    • X_i + X_{i+1} = X_{i+2} for all i + 2 <= n
    • +
    • Xi + Xi+1 = Xi+2 for all i + 2 <= n
    -

    Given a strictly increasing array A of positive integers forming a sequence, find the length of the longest fibonacci-like subsequence of A.  If one does not exist, return 0.

    +

    Given a strictly increasing array arr of positive integers forming a sequence, return the length of the longest Fibonacci-like subsequence of arr. If one does not exist, return 0.

    -

    (Recall that a subsequence is derived from another sequence A by deleting any number of elements (including none) from A, without changing the order of the remaining elements.  For example, [3, 5, 8] is a subsequence of [3, 4, 5, 6, 7, 8].)

    +

    A subsequence is derived from another sequence arr by deleting any number of elements (including none) from arr, without changing the order of the remaining elements. For example, [3, 5, 8] is a subsequence of [3, 4, 5, 6, 7, 8].

     

    - -
      -
    -

    Example 1:

    -Input: [1,2,3,4,5,6,7,8]
    -Output: 5
    -Explanation:
    -The longest subsequence that is fibonacci-like: [1,2,3,5,8].
    -
    +Input: arr = [1,2,3,4,5,6,7,8] +Output: 5 +Explanation: The longest subsequence that is fibonacci-like: [1,2,3,5,8].

    Example 2:

    -Input: [1,3,7,11,12,14,18]
    -Output: 3
    -Explanation:
    -The longest subsequence that is fibonacci-like:
    -[1,11,12], [3,11,14] or [7,11,18].
    -
    +Input: arr = [1,3,7,11,12,14,18] +Output: 3 +Explanation: The longest subsequence that is fibonacci-like: [1,11,12], [3,11,14] or [7,11,18].

     

    - -

    Note:

    +

    Constraints:

      -
    • 3 <= A.length <= 1000
    • -
    • 1 <= A[0] < A[1] < ... < A[A.length - 1] <= 10^9
    • -
    • (The time limit has been reduced by 50% for submissions in Java, C, and C++.)
    • +
    • 3 <= arr.length <= 1000
    • +
    • 1 <= arr[i] < arr[i + 1] <= 109
    ### Related Topics diff --git a/problems/longest-increasing-subsequence/README.md b/problems/longest-increasing-subsequence/README.md index f19c9c7d6..47fd7b3f7 100644 --- a/problems/longest-increasing-subsequence/README.md +++ b/problems/longest-increasing-subsequence/README.md @@ -9,7 +9,7 @@                  [Next >](../remove-invalid-parentheses "Remove Invalid Parentheses") -## [300. Longest Increasing Subsequence (Medium)](https://leetcode.com/problems/longest-increasing-subsequence "最长上升子序列") +## [300. Longest Increasing Subsequence (Medium)](https://leetcode.com/problems/longest-increasing-subsequence "最长递增子序列")

    Given an integer array nums, return the length of the longest strictly increasing subsequence.

    diff --git a/problems/longest-palindrome/README.md b/problems/longest-palindrome/README.md index 15fd9a6e9..7839ec9e3 100644 --- a/problems/longest-palindrome/README.md +++ b/problems/longest-palindrome/README.md @@ -44,7 +44,7 @@ One longest palindrome that can be built is "dccaccd", whose length is
    • 1 <= s.length <= 2000
    • -
    • s consits of lower-case and/or upper-case English letters only.
    • +
    • s consists of lowercase and/or uppercase English letters only.
    ### Related Topics diff --git a/problems/longest-repeating-character-replacement/README.md b/problems/longest-repeating-character-replacement/README.md index 4effd154d..24bd5af8d 100644 --- a/problems/longest-repeating-character-replacement/README.md +++ b/problems/longest-repeating-character-replacement/README.md @@ -56,5 +56,5 @@ The substring "BBBB" has the longest repeating letters, which is 4. [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions - 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Hard) + 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Medium) 1. [Max Consecutive Ones III](../max-consecutive-ones-iii) (Medium) diff --git a/problems/longest-substring-with-at-most-k-distinct-characters/README.md b/problems/longest-substring-with-at-most-k-distinct-characters/README.md index 2ef66431a..8c2122c1d 100644 --- a/problems/longest-substring-with-at-most-k-distinct-characters/README.md +++ b/problems/longest-substring-with-at-most-k-distinct-characters/README.md @@ -9,7 +9,7 @@                  [Next >](../flatten-nested-list-iterator "Flatten Nested List Iterator") -## [340. Longest Substring with At Most K Distinct Characters (Hard)](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters "至多包含 K 个不同字符的最长子串") +## [340. Longest Substring with At Most K Distinct Characters (Medium)](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters "至多包含 K 个不同字符的最长子串")

    Given a string, find the length of the longest substring T that contains at most k distinct characters.

    @@ -32,6 +32,7 @@ ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] diff --git a/problems/longest-substring-with-at-most-two-distinct-characters/README.md b/problems/longest-substring-with-at-most-two-distinct-characters/README.md index a8177ceef..f7fc0adc4 100644 --- a/problems/longest-substring-with-at-most-two-distinct-characters/README.md +++ b/problems/longest-substring-with-at-most-two-distinct-characters/README.md @@ -36,5 +36,5 @@ ### Similar Questions 1. [Longest Substring Without Repeating Characters](../longest-substring-without-repeating-characters) (Medium) 1. [Sliding Window Maximum](../sliding-window-maximum) (Hard) - 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Hard) + 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Medium) 1. [Subarrays with K Different Integers](../subarrays-with-k-different-integers) (Hard) diff --git a/problems/longest-substring-without-repeating-characters/README.md b/problems/longest-substring-without-repeating-characters/README.md index 7cf835f90..1eeb9dc6c 100644 --- a/problems/longest-substring-without-repeating-characters/README.md +++ b/problems/longest-substring-without-repeating-characters/README.md @@ -62,5 +62,5 @@ Notice that the answer must be a substring, "pwke" is a subsequence an ### Similar Questions 1. [Longest Substring with At Most Two Distinct Characters](../longest-substring-with-at-most-two-distinct-characters) (Medium) - 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Hard) + 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Medium) 1. [Subarrays with K Different Integers](../subarrays-with-k-different-integers) (Hard) diff --git a/problems/max-consecutive-ones-iii/README.md b/problems/max-consecutive-ones-iii/README.md index 508de2dfd..4c0876bc1 100644 --- a/problems/max-consecutive-ones-iii/README.md +++ b/problems/max-consecutive-ones-iii/README.md @@ -55,7 +55,7 @@ Bolded numbers were flipped from 0 to 1. The longest subarray is underlined. [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions - 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Hard) + 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Medium) 1. [Longest Repeating Character Replacement](../longest-repeating-character-replacement) (Medium) 1. [Max Consecutive Ones](../max-consecutive-ones) (Easy) 1. [Max Consecutive Ones II](../max-consecutive-ones-ii) (Medium) diff --git a/problems/maximum-binary-string-after-change/README.md b/problems/maximum-binary-string-after-change/README.md new file mode 100644 index 000000000..c12ef6abb --- /dev/null +++ b/problems/maximum-binary-string-after-change/README.md @@ -0,0 +1,68 @@ + + + + + + + +[< Previous](../average-waiting-time "Average Waiting Time") +                 +[Next >](../minimum-adjacent-swaps-for-k-consecutive-ones "Minimum Adjacent Swaps for K Consecutive Ones") + +## [1702. Maximum Binary String After Change (Medium)](https://leetcode.com/problems/maximum-binary-string-after-change "修改后的最大二进制字符串") + +

    You are given a binary string binary consisting of only 0's or 1's. You can apply each of the following operations any number of times:

    + +
      +
    • Operation 1: If the number contains the substring "00", you can replace it with "10". +
        +
      • For example, "00010" -> "10010"
      • +
      +
    • +
    • Operation 2: If the number contains the substring "10", you can replace it with "01". +
        +
      • For example, "00010" -> "00001"
      • +
      +
    • +
    + +

    Return the maximum binary string you can obtain after any number of operations. Binary string x is greater than binary string y if x's decimal representation is greater than y's decimal representation.

    + +

     

    +

    Example 1:

    + +
    +Input: binary = "000110"
    +Output: "111011"
    +Explanation: A valid transformation sequence can be:
    +"000110" -> "000101" 
    +"000101" -> "100101" 
    +"100101" -> "110101" 
    +"110101" -> "110011" 
    +"110011" -> "111011"
    +
    + +

    Example 2:

    + +
    +Input: binary = "01"
    +Output: "01"
    +Explanation: "01" cannot be transformed any further.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= binary.length <= 105
    • +
    • binary consist of '0' and '1'.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Note that with the operations, you can always make the string only contain at most 1 zero. +
    diff --git a/problems/maximum-binary-tree/README.md b/problems/maximum-binary-tree/README.md index 0c572f88c..13580bfb6 100644 --- a/problems/maximum-binary-tree/README.md +++ b/problems/maximum-binary-tree/README.md @@ -11,39 +11,39 @@ ## [654. Maximum Binary Tree (Medium)](https://leetcode.com/problems/maximum-binary-tree "最大二叉树") -

    -Given an integer array with no duplicates. A maximum tree building on this array is defined as follow: +

    Given an integer array with no duplicates. A maximum tree building on this array is defined as follow:

    +
      -
    1. The root is the maximum number in the array.
    2. -
    3. The left subtree is the maximum tree constructed from left part subarray divided by the maximum number.
    4. -
    5. The right subtree is the maximum tree constructed from right part subarray divided by the maximum number.
    6. +
    7. The root is the maximum number in the array.
    8. +
    9. The left subtree is the maximum tree constructed from left part subarray divided by the maximum number.
    10. +
    11. The right subtree is the maximum tree constructed from right part subarray divided by the maximum number.
    -

    -

    -Construct the maximum tree by the given array and output the root node of this tree. -

    +

    Construct the maximum tree by the given array and output the root node of this tree.

    -

    Example 1:
    +

     

    +

    Example 1:

    +
    -Input: [3,2,1,6,0,5]
    -Output: return the tree root node representing the following tree:
    -
    -      6
    -    /   \
    -   3     5
    -    \    / 
    -     2  0   
    -       \
    -        1
    +Input: nums = [3,2,1,6,0,5]
    +Output: [6,3,5,null,2,0,null,null,1]
     
    -

    -

    Note:
    -

      -
    1. The size of the given array will be in the range [1,1000].
    2. -
    -

    +

    Example 2:

    + +
    +Input: nums = [3,2,1]
    +Output: [3,null,2,null,1]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • 0 <= nums[i] <= 1000
    • +
    • All integers in nums are unique.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/maximum-erasure-value/README.md b/problems/maximum-erasure-value/README.md new file mode 100644 index 000000000..688835a6e --- /dev/null +++ b/problems/maximum-erasure-value/README.md @@ -0,0 +1,57 @@ + + + + + + + +[< Previous](../reformat-phone-number "Reformat Phone Number") +                 +[Next >](../jump-game-vi "Jump Game VI") + +## [1695. Maximum Erasure Value (Medium)](https://leetcode.com/problems/maximum-erasure-value "删除子数组的最大得分") + +

    You are given an array of positive integers nums and want to erase a subarray containing unique elements. The score you get by erasing the subarray is equal to the sum of its elements.

    + +

    Return the maximum score you can get by erasing exactly one subarray.

    + +

    An array b is called to be a subarray of a if it forms a contiguous subsequence of a, that is, if it is equal to a[l],a[l+1],...,a[r] for some (l,r).

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [4,2,4,5,6]
    +Output: 17
    +Explanation: The optimal subarray here is [2,4,5,6].
    +
    + +

    Example 2:

    + +
    +Input: nums = [5,2,1,2,5,2,1,2,5]
    +Output: 8
    +Explanation: The optimal subarray here is [5,2,1] or [1,2,5].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 104
    • +
    + +### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] + +### Hints +
    +Hint 1 +The main point here is for the subarray to contain unique elements for each index. Only the first subarrays starting from that index have unique elements. +
    + +
    +Hint 2 +This can be solved using the two pointers technique +
    diff --git a/problems/maximum-height-by-stacking-cuboids/README.md b/problems/maximum-height-by-stacking-cuboids/README.md index 2f6182622..1d77d2dec 100644 --- a/problems/maximum-height-by-stacking-cuboids/README.md +++ b/problems/maximum-height-by-stacking-cuboids/README.md @@ -7,7 +7,7 @@ [< Previous](../stone-game-vii "Stone Game VII")                  -Next > +[Next >](../count-ways-to-distribute-candies "Count Ways to Distribute Candies") ## [1691. Maximum Height by Stacking Cuboids (Hard)](https://leetcode.com/problems/maximum-height-by-stacking-cuboids "堆叠长方体的最大高度") diff --git a/problems/maximum-number-of-eaten-apples/README.md b/problems/maximum-number-of-eaten-apples/README.md new file mode 100644 index 000000000..0c47a6301 --- /dev/null +++ b/problems/maximum-number-of-eaten-apples/README.md @@ -0,0 +1,68 @@ + + + + + + + +[< Previous](../determine-if-string-halves-are-alike "Determine if String Halves Are Alike") +                 +[Next >](../where-will-the-ball-fall "Where Will the Ball Fall") + +## [1705. Maximum Number of Eaten Apples (Medium)](https://leetcode.com/problems/maximum-number-of-eaten-apples "吃苹果的最大数目") + +

    There is a special kind of apple tree that grows apples every day for n days. On the ith day, the tree grows apples[i] apples that will rot after days[i] days, that is on day i + days[i] the apples will be rotten and cannot be eaten. On some days, the apple tree does not grow any apples, which are denoted by apples[i] == 0 and days[i] == 0.

    + +

    You decided to eat at most one apple a day (to keep the doctors away). Note that you can keep eating after the first n days.

    + +

    Given two integer arrays days and apples of length n, return the maximum number of apples you can eat.

    + +

     

    +

    Example 1:

    + +
    +Input: apples = [1,2,3,5,2], days = [3,2,1,4,2]
    +Output: 7
    +Explanation: You can eat 7 apples:
    +- On the first day, you eat an apple that grew on the first day.
    +- On the second day, you eat an apple that grew on the second day.
    +- On the third day, you eat an apple that grew on the second day. After this day, the apples that grew on the third day rot.
    +- On the fourth to the seventh days, you eat apples that grew on the fourth day.
    +
    + +

    Example 2:

    + +
    +Input: apples = [3,0,0,0,0,2], days = [3,0,0,0,0,2]
    +Output: 5
    +Explanation: You can eat 5 apples:
    +- On the first to the third day you eat apples that grew on the first day.
    +- Do nothing on the fouth and fifth days.
    +- On the sixth and seventh days you eat apples that grew on the sixth day.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • apples.length == n
    • +
    • days.length == n
    • +
    • 1 <= n <= 2 * 104
    • +
    • 0 <= apples[i], days[i] <= 2 * 104
    • +
    • days[i] = 0 if and only if apples[i] = 0.
    • +
    + +### Related Topics + [[Heap](../../tag/heap/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +It's optimal to finish the apples that will rot first before those that will rot last +
    + +
    +Hint 2 +You need a structure to keep the apples sorted by their finish time +
    diff --git a/problems/maximum-xor-with-an-element-from-array/README.md b/problems/maximum-xor-with-an-element-from-array/README.md new file mode 100644 index 000000000..61cf253d5 --- /dev/null +++ b/problems/maximum-xor-with-an-element-from-array/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../where-will-the-ball-fall "Where Will the Ball Fall") +                 +Next > + +## [1707. Maximum XOR With an Element From Array (Hard)](https://leetcode.com/problems/maximum-xor-with-an-element-from-array "与数组中元素的最大异或值") + +

    You are given an array nums consisting of non-negative integers. You are also given a queries array, where queries[i] = [xi, mi].

    + +

    The answer to the ith query is the maximum bitwise XOR value of xi and any element of nums that does not exceed mi. In other words, the answer is max(nums[j] XOR xi) for all j such that nums[j] <= mi. If all elements in nums are larger than mi, then the answer is -1.

    + +

    Return an integer array answer where answer.length == queries.length and answer[i] is the answer to the ith query.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [0,1,2,3,4], queries = [[3,1],[1,3],[5,6]]
    +Output: [3,3,7]
    +Explanation:
    +1) 0 and 1 are the only two integers not greater than 1. 0 XOR 3 = 3 and 1 XOR 3 = 2. The larger of the two is 3.
    +2) 1 XOR 2 = 3.
    +3) 5 XOR 2 = 7.
    +
    + +

    Example 2:

    + +
    +Input: nums = [5,2,4,6,6,3], queries = [[12,4],[8,1],[6,3]]
    +Output: [15,-1,5]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length, queries.length <= 105
    • +
    • queries[i].length == 2
    • +
    • 0 <= nums[j], xi, mi <= 109
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Trie](../../tag/trie/README.md)] + +### Hints +
    +Hint 1 +In problems involving bitwise operations, we often think on the bits level. In this problem, we can think that to maximize the result of an xor operation, we need to maximize the most significant bit, then the next one, and so on. +
    + +
    +Hint 2 +If there's some number in the array that is less than m and whose the most significant bit is different than that of x, then xoring with this number maximizes the most significant bit, so I know this bit in the answer is 1. +
    + +
    +Hint 3 +To check the existence of such numbers and narrow your scope for further bits based on your choice, you can use trie. +
    + +
    +Hint 4 +You can sort the array and the queries, and maintain the trie such that in each query the trie consists exactly of the valid elements. +
    diff --git a/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md b/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md new file mode 100644 index 000000000..41faceb26 --- /dev/null +++ b/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../maximum-binary-string-after-change "Maximum Binary String After Change") +                 +[Next >](../determine-if-string-halves-are-alike "Determine if String Halves Are Alike") + +## [1703. Minimum Adjacent Swaps for K Consecutive Ones (Hard)](https://leetcode.com/problems/minimum-adjacent-swaps-for-k-consecutive-ones "得到连续 K 个 1 的最少相邻交换次数") + +

    You are given an integer array, nums, and an integer k. nums comprises of only 0's and 1's. In one move, you can choose two adjacent indices and swap their values.

    + +

    Return the minimum number of moves required so that nums has k consecutive 1's.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,0,0,1,0,1], k = 2
    +Output: 1
    +Explanation: In 1 move, nums could be [1,0,0,0,1,1] and have 2 consecutive 1's.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,0,0,0,0,0,1,1], k = 3
    +Output: 5
    +Explanation: In 5 moves, the leftmost 1 can be shifted right until nums = [0,0,0,0,0,1,1,1].
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,1,0,1], k = 2
    +Output: 0
    +Explanation: nums already has 2 consecutive 1's.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • nums[i] is 0 or 1.
    • +
    • 1 <= k <= sum(nums)
    • +
    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + +### Hints +
    +Hint 1 +Choose k 1s and determine how many steps are required to move them into 1 group. +
    + +
    +Hint 2 +Maintain a sliding window of k 1s, and maintain the steps required to group them. +
    + +
    +Hint 3 +When you slide the window across, should you move the group to the right? Once you move the group to the right, it will never need to slide to the left again. +
    diff --git a/problems/minimum-genetic-mutation/README.md b/problems/minimum-genetic-mutation/README.md index 9ebb42a3c..87fca633e 100644 --- a/problems/minimum-genetic-mutation/README.md +++ b/problems/minimum-genetic-mutation/README.md @@ -68,4 +68,4 @@ return: 3

     

    ### Similar Questions - 1. [Word Ladder](../word-ladder) (Medium) + 1. [Word Ladder](../word-ladder) (Hard) diff --git a/problems/minimum-moves-to-equal-array-elements/README.md b/problems/minimum-moves-to-equal-array-elements/README.md index 30e37eeb0..5ec44f81f 100644 --- a/problems/minimum-moves-to-equal-array-elements/README.md +++ b/problems/minimum-moves-to-equal-array-elements/README.md @@ -9,7 +9,7 @@                  [Next >](../4sum-ii "4Sum II") -## [453. Minimum Moves to Equal Array Elements (Easy)](https://leetcode.com/problems/minimum-moves-to-equal-array-elements "最小移动次数使数组元素相等") +## [453. Minimum Moves to Equal Array Elements (Easy)](https://leetcode.com/problems/minimum-moves-to-equal-array-elements "最小操作次数使数组元素相等")

    Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.

    diff --git a/problems/minimum-time-visiting-all-points/README.md b/problems/minimum-time-visiting-all-points/README.md index bd6d6dc5f..b50308ecf 100644 --- a/problems/minimum-time-visiting-all-points/README.md +++ b/problems/minimum-time-visiting-all-points/README.md @@ -11,13 +11,20 @@ ## [1266. Minimum Time Visiting All Points (Easy)](https://leetcode.com/problems/minimum-time-visiting-all-points "访问所有点的最小时间") -

    On a plane there are n points with integer coordinates points[i] = [xi, yi]. Your task is to find the minimum time in seconds to visit all points.

    +

    On a 2D plane, there are n points with integer coordinates points[i] = [xi, yi]. Return the minimum time in seconds to visit all the points in the order given by points.

    -

    You can move according to the next rules:

    +

    You can move according to these rules:

      -
    • In one second always you can either move vertically, horizontally by one unit or diagonally (it means to move one unit vertically and one unit horizontally in one second).
    • +
    • In 1 second, you can either: +
        +
      • move vertically by one unit,
      • +
      • move horizontally by one unit, or
      • +
      • move diagonally sqrt(2) units (in other words, move one unit vertically then one unit horizontally in 1 second).
      • +
      +
    • You have to visit the points in the same order as they appear in the array.
    • +
    • You are allowed to pass through points that appear later in the order, but these do not count as visits.

     

    diff --git a/problems/most-stones-removed-with-same-row-or-column/README.md b/problems/most-stones-removed-with-same-row-or-column/README.md index 4be096fc6..8e45d05d1 100644 --- a/problems/most-stones-removed-with-same-row-or-column/README.md +++ b/problems/most-stones-removed-with-same-row-or-column/README.md @@ -11,49 +11,42 @@ ## [947. Most Stones Removed with Same Row or Column (Medium)](https://leetcode.com/problems/most-stones-removed-with-same-row-or-column "移除最多的同行或同列石头") -

    On a 2D plane, we place stones at some integer coordinate points.  Each coordinate point may have at most one stone.

    +

    On a 2D plane, we place stones at some integer coordinate points. Each coordinate point may have at most one stone.

    -

    Now, a move consists of removing a stone that shares a column or row with another stone on the grid.

    +

    A move consists of removing a stone that shares a column or row with another stone on the grid.

    -

    What is the largest possible number of moves we can make?

    +

    Given an array stones where stones[i] = [xi, yi], return the largest possible number of moves we can make.

     

    - -

    Example 1:

    -Input: stones = [[0,0],[0,1],[1,0],[1,2],[2,1],[2,2]]
    -Output: 5
    +Input: stones = [[0,0],[0,1],[1,0],[1,2],[2,1],[2,2]]
    +Output: 5
     
    -

    Example 2:

    -Input: stones = [[0,0],[0,2],[1,1],[2,0],[2,2]]
    -Output: 3
    +Input: stones = [[0,0],[0,2],[1,1],[2,0],[2,2]]
    +Output: 3
     
    -

    Example 3:

    -Input: stones = [[0,0]]
    -Output: 0
    +Input: stones = [[0,0]]
    +Output: 0
     

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= stones.length <= 1000
      • -
      • 0 <= stones[i][j] < 10000
      • -
    -
    -
    -
    +
  • 0 <= xi, yi < 104
  • +
  • stones contains unique values.
  • + ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/nth-magical-number/README.md b/problems/nth-magical-number/README.md index 88e9ae5b7..c7aaf6b59 100644 --- a/problems/nth-magical-number/README.md +++ b/problems/nth-magical-number/README.md @@ -11,60 +11,31 @@ ## [878. Nth Magical Number (Hard)](https://leetcode.com/problems/nth-magical-number "第 N 个神奇数字") -

    A positive integer is magical if it is divisible by either A or B.

    +

    A positive integer is magical if it is divisible by either a or b.

    -

    Return the N-th magical number.  Since the answer may be very large, return it modulo 10^9 + 7.

    +

    Given the three integers n, a, and b, return the nth magical number. Since the answer may be very large, return it modulo 109 + 7.

     

    - -
      -
    - -

    Example 1:

    - -
    -Input: N = 1, A = 2, B = 3
    -Output: 2
    -
    - -
    -

    Example 2:

    - -
    -Input: N = 4, A = 2, B = 3
    -Output: 6
    -
    - -
    -

    Example 3:

    - -
    -Input: N = 5, A = 2, B = 4
    -Output: 10
    +
    Input: n = 1, a = 2, b = 3
    +Output: 2
    +

    Example 2:

    +
    Input: n = 4, a = 2, b = 3
    +Output: 6
    +

    Example 3:

    +
    Input: n = 5, a = 2, b = 4
    +Output: 10
    +

    Example 4:

    +
    Input: n = 3, a = 6, b = 4
    +Output: 8
     
    - -
    -

    Example 4:

    - -
    -Input: N = 3, A = 6, B = 4
    -Output: 8
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= N <= 10^9
    2. -
    3. 2 <= A <= 40000
    4. -
    5. 2 <= B <= 40000
    6. -
    -
    -
    -
    -
    +
      +
    • 1 <= n <= 109
    • +
    • 2 <= a, b <= 4 * 104
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/number-of-calls-between-two-persons/README.md b/problems/number-of-calls-between-two-persons/README.md new file mode 100644 index 000000000..0a6b30900 --- /dev/null +++ b/problems/number-of-calls-between-two-persons/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../number-of-distinct-substrings-in-a-string "Number of Distinct Substrings in a String") +                 +[Next >](../number-of-students-unable-to-eat-lunch "Number of Students Unable to Eat Lunch") + +## [1699. Number of Calls Between Two Persons (Medium)](https://leetcode.com/problems/number-of-calls-between-two-persons "") + + diff --git a/problems/number-of-calls-between-two-persons/mysql_schemas.sql b/problems/number-of-calls-between-two-persons/mysql_schemas.sql new file mode 100644 index 000000000..d2578c68b --- /dev/null +++ b/problems/number-of-calls-between-two-persons/mysql_schemas.sql @@ -0,0 +1,9 @@ +Create table If Not Exists Calls (from_id int, to_id int, duration int); +Truncate table Calls; +insert into Calls (from_id, to_id, duration) values ('1', '2', '59'); +insert into Calls (from_id, to_id, duration) values ('2', '1', '11'); +insert into Calls (from_id, to_id, duration) values ('1', '3', '20'); +insert into Calls (from_id, to_id, duration) values ('3', '4', '100'); +insert into Calls (from_id, to_id, duration) values ('3', '4', '200'); +insert into Calls (from_id, to_id, duration) values ('3', '4', '200'); +insert into Calls (from_id, to_id, duration) values ('4', '3', '499'); diff --git a/problems/number-of-digit-one/README.md b/problems/number-of-digit-one/README.md index 787f8f7e0..7c3ca78c1 100644 --- a/problems/number-of-digit-one/README.md +++ b/problems/number-of-digit-one/README.md @@ -11,16 +11,30 @@ ## [233. Number of Digit One (Hard)](https://leetcode.com/problems/number-of-digit-one "数字 1 的个数") -

    Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.

    +

    Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.

    -

    Example:

    +

     

    +

    Example 1:

    -Input: 13
    -Output: 6 
    -Explanation: Digit 1 occurred in the following numbers: 1, 10, 11, 12, 13.
    +Input: n = 13
    +Output: 6
     
    +

    Example 2:

    + +
    +Input: n = 0
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= n <= 2 * 109
    • +
    + ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/number-of-distinct-substrings-in-a-string/README.md b/problems/number-of-distinct-substrings-in-a-string/README.md new file mode 100644 index 000000000..568bad013 --- /dev/null +++ b/problems/number-of-distinct-substrings-in-a-string/README.md @@ -0,0 +1,38 @@ + + + + + + + +[< Previous](../checking-existence-of-edge-length-limited-paths "Checking Existence of Edge Length Limited Paths") +                 +[Next >](../number-of-calls-between-two-persons "Number of Calls Between Two Persons") + +## [1698. Number of Distinct Substrings in a String (Medium)](https://leetcode.com/problems/number-of-distinct-substrings-in-a-string "") + + + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Calculate the prefix hashing array for s. +
    + +
    +Hint 2 +Use the prefix hashing array to calculate the hashing value of each substring. +
    + +
    +Hint 3 +Compare the hashing values to determine the unique substrings. +
    + +
    +Hint 4 +There could be collisions if you use hashing, what about double hashing. +
    diff --git a/problems/number-of-students-unable-to-eat-lunch/README.md b/problems/number-of-students-unable-to-eat-lunch/README.md new file mode 100644 index 000000000..8e0012d46 --- /dev/null +++ b/problems/number-of-students-unable-to-eat-lunch/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../number-of-calls-between-two-persons "Number of Calls Between Two Persons") +                 +[Next >](../average-waiting-time "Average Waiting Time") + +## [1700. Number of Students Unable to Eat Lunch (Easy)](https://leetcode.com/problems/number-of-students-unable-to-eat-lunch "无法吃午餐的学生数量") + +

    The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively. All students stand in a queue. Each student either prefers square or circular sandwiches.

    + +

    The number of sandwiches in the cafeteria is equal to the number of students. The sandwiches are placed in a stack. At each step:

    + +
      +
    • If the student at the front of the queue prefers the sandwich on the top of the stack, they will take it and leave the queue.
    • +
    • Otherwise, they will leave it and go to the queue's end.
    • +
    + +

    This continues until none of the queue students want to take the top sandwich and are thus unable to eat.

    + +

    You are given two integer arrays students and sandwiches where sandwiches[i] is the type of the i​​​​​​th sandwich in the stack (i = 0 is the top of the stack) and students[j] is the preference of the j​​​​​​th student in the initial queue (j = 0 is the front of the queue). Return the number of students that are unable to eat.

    + +

     

    +

    Example 1:

    + +
    +Input: students = [1,1,0,0], sandwiches = [0,1,0,1]
    +Output: 0 
    +Explanation:
    +- Front student leaves the top sandwich and returns to the end of the line making students = [1,0,0,1].
    +- Front student leaves the top sandwich and returns to the end of the line making students = [0,0,1,1].
    +- Front student takes the top sandwich and leaves the line making students = [0,1,1] and sandwiches = [1,0,1].
    +- Front student leaves the top sandwich and returns to the end of the line making students = [1,1,0].
    +- Front student takes the top sandwich and leaves the line making students = [1,0] and sandwiches = [0,1].
    +- Front student leaves the top sandwich and returns to the end of the line making students = [0,1].
    +- Front student takes the top sandwich and leaves the line making students = [1] and sandwiches = [1].
    +- Front student takes the top sandwich and leaves the line making students = [] and sandwiches = [].
    +Hence all students are able to eat.
    +
    + +

    Example 2:

    + +
    +Input: students = [1,1,1,0,0,1], sandwiches = [1,0,0,0,1,1]
    +Output: 3
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= students.length, sandwiches.length <= 100
    • +
    • students.length == sandwiches.length
    • +
    • sandwiches[i] is 0 or 1.
    • +
    • students[i] is 0 or 1.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Simulate the given in the statement +
    + +
    +Hint 2 +Calculate those who will eat instead of those who will not. +
    diff --git a/problems/numbers-with-same-consecutive-differences/README.md b/problems/numbers-with-same-consecutive-differences/README.md index 049e40dcf..ce80e4f3c 100644 --- a/problems/numbers-with-same-consecutive-differences/README.md +++ b/problems/numbers-with-same-consecutive-differences/README.md @@ -13,7 +13,7 @@

    Return all non-negative integers of length n such that the absolute difference between every two consecutive digits is k.

    -

    Note that every number in the answer must not have leading zeros except for the number 0 itself. For example, 01 has one leading zero and is invalid, but 0 is valid.

    +

    Note that every number in the answer must not have leading zeros. For example, 01 has one leading zero and is invalid.

    You may return the answer in any order.

    @@ -65,3 +65,5 @@ ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/partition-array-into-three-parts-with-equal-sum/README.md b/problems/partition-array-into-three-parts-with-equal-sum/README.md index 0d9a74fe5..44cc8fba4 100644 --- a/problems/partition-array-into-three-parts-with-equal-sum/README.md +++ b/problems/partition-array-into-three-parts-with-equal-sum/README.md @@ -11,15 +11,15 @@ ## [1013. Partition Array Into Three Parts With Equal Sum (Easy)](https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum "将数组分成和相等的三个部分") -

    Given an array A of integers, return true if and only if we can partition the array into three non-empty parts with equal sums.

    +

    Given an array of integers arr, return true if we can partition the array into three non-empty parts with equal sums.

    -

    Formally, we can partition the array if we can find indexes i+1 < j with (A[0] + A[1] + ... + A[i] == A[i+1] + A[i+2] + ... + A[j-1] == A[j] + A[j-1] + ... + A[A.length - 1])

    +

    Formally, we can partition the array if we can find indexes i + 1 < j with (arr[0] + arr[1] + ... + arr[i] == arr[i + 1] + arr[i + 2] + ... + arr[j - 1] == arr[j] + arr[j + 1] + ... + arr[arr.length - 1])

     

    Example 1:

    -Input: A = [0,2,1,-6,6,-7,9,1,2,0,1]
    +Input: arr = [0,2,1,-6,6,-7,9,1,2,0,1]
     Output: true
     Explanation: 0 + 2 + 1 = -6 + 6 - 7 + 9 + 1 = 2 + 0 + 1
     
    @@ -27,14 +27,14 @@

    Example 2:

    -Input: A = [0,2,1,-6,6,7,9,-1,2,0,1]
    +Input: arr = [0,2,1,-6,6,7,9,-1,2,0,1]
     Output: false
     

    Example 3:

    -Input: A = [3,3,6,5,-2,2,5,1,-9,4]
    +Input: arr = [3,3,6,5,-2,2,5,1,-9,4]
     Output: true
     Explanation: 3 + 3 = 6 = 5 - 2 + 2 + 5 + 1 - 9 + 4
     
    @@ -43,8 +43,8 @@

    Constraints:

      -
    • 3 <= A.length <= 50000
    • -
    • -10^4 <= A[i] <= 10^4
    • +
    • 3 <= arr.length <= 5 * 104
    • +
    • -104 <= arr[i] <= 104
    ### Related Topics diff --git a/problems/previous-permutation-with-one-swap/README.md b/problems/previous-permutation-with-one-swap/README.md index dffedec5a..053e6e743 100644 --- a/problems/previous-permutation-with-one-swap/README.md +++ b/problems/previous-permutation-with-one-swap/README.md @@ -11,50 +11,48 @@ ## [1053. Previous Permutation With One Swap (Medium)](https://leetcode.com/problems/previous-permutation-with-one-swap "交换一次的先前排列") -

    Given an array A of positive integers (not necessarily distinct), return the lexicographically largest permutation that is smaller than A, that can be made with one swap (A swap exchanges the positions of two numbers A[i] and A[j]).  If it cannot be done, then return the same array.

    +

    Given an array of positive integers arr (not necessarily distinct), return the lexicographically largest permutation that is smaller than arr, that can be made with exactly one swap (A swap exchanges the positions of two numbers arr[i] and arr[j]). If it cannot be done, then return the same array.

     

    -

    Example 1:

    -Input: [3,2,1]
    -Output: [3,1,2]
    -Explanation: Swapping 2 and 1.
    +Input: arr = [3,2,1]
    +Output: [3,1,2]
    +Explanation: Swapping 2 and 1.
     

    Example 2:

    -Input: [1,1,5]
    -Output: [1,1,5]
    -Explanation: This is already the smallest permutation.
    +Input: arr = [1,1,5]
    +Output: [1,1,5]
    +Explanation: This is already the smallest permutation.
     

    Example 3:

    -Input: [1,9,4,6,7]
    -Output: [1,7,4,6,9]
    -Explanation: Swapping 9 and 7.
    +Input: arr = [1,9,4,6,7]
    +Output: [1,7,4,6,9]
    +Explanation: Swapping 9 and 7.
     

    Example 4:

    -Input: [3,1,1,3]
    -Output: [1,3,1,3]
    -Explanation: Swapping 1 and 3.
    +Input: arr = [3,1,1,3]
    +Output: [1,3,1,3]
    +Explanation: Swapping 1 and 3.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= A.length <= 10000
    2. -
    3. 1 <= A[i] <= 10000
    4. -
    +
      +
    • 1 <= arr.length <= 104
    • +
    • 1 <= arr[i] <= 104
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/rectangle-area-ii/README.md b/problems/rectangle-area-ii/README.md index eac757cc8..d96646f5c 100644 --- a/problems/rectangle-area-ii/README.md +++ b/problems/rectangle-area-ii/README.md @@ -11,35 +11,35 @@ ## [850. Rectangle Area II (Hard)](https://leetcode.com/problems/rectangle-area-ii "矩形面积 II") -

    We are given a list of (axis-aligned) rectangles.  Each rectangle[i] = [x1, y1, x2, y2] , where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the ith rectangle.

    +

    We are given a list of (axis-aligned) rectangles. Each rectangle[i] = [xi1, yi1, xi2, yi2] , where (xi1, yi1) are the coordinates of the bottom-left corner, and (xi2, yi2) are the coordinates of the top-right corner of the ith rectangle.

    -

    Find the total area covered by all rectangles in the plane.  Since the answer may be too large, return it modulo 10^9 + 7.

    - -

    +

    Find the total area covered by all rectangles in the plane. Since the answer may be too large, return it modulo 109 + 7.

    +

     

    Example 1:

    - +
    -Input: [[0,0,2,2],[1,0,2,3],[1,0,3,1]]
    -Output: 6
    +Input: rectangles = [[0,0,2,2],[1,0,2,3],[1,0,3,1]]
    +Output: 6
     Explanation: As illustrated in the picture.
     

    Example 2:

    -Input: [[0,0,1000000000,1000000000]]
    -Output: 49
    -Explanation: The answer is 10^18 modulo (10^9 + 7), which is (10^9)^2 = (-7)^2 = 49.
    +Input: rectangles = [[0,0,1000000000,1000000000]]
    +Output: 49
    +Explanation: The answer is 1018 modulo (109 + 7), which is (109)2 = (-7)2 = 49.
     
    -

    Note:

    +

     

    +

    Constraints:

    • 1 <= rectangles.length <= 200
    • rectanges[i].length = 4
    • -
    • 0 <= rectangles[i][j] <= 10^9
    • -
    • The total area covered by all rectangles will never exceed 2^63 - 1 and thus will fit in a 64-bit signed integer.
    • +
    • 0 <= rectangles[i][j] <= 109
    • +
    • The total area covered by all rectangles will never exceed 263 - 1 and thus will fit in a 64-bit signed integer.
    ### Related Topics diff --git a/problems/redundant-connection-ii/README.md b/problems/redundant-connection-ii/README.md index 32c267e4d..493b91de8 100644 --- a/problems/redundant-connection-ii/README.md +++ b/problems/redundant-connection-ii/README.md @@ -11,40 +11,38 @@ ## [685. Redundant Connection II (Hard)](https://leetcode.com/problems/redundant-connection-ii "冗余连接 II") -

    -In this problem, a rooted tree is a directed graph such that, there is exactly one node (the root) for which all other nodes are descendants of this node, plus every node has exactly one parent, except for the root node which has no parents. -

    -The given input is a directed graph that started as a rooted tree with N nodes (with distinct values 1, 2, ..., N), with one additional directed edge added. The added edge has two different vertices chosen from 1 to N, and was not an edge that already existed. -

    -The resulting graph is given as a 2D-array of edges. Each element of edges is a pair [u, v] that represents a directed edge connecting nodes u and v, where u is a parent of child v. -

    -Return an edge that can be removed so that the resulting graph is a rooted tree of N nodes. If there are multiple answers, return the answer that occurs last in the given 2D-array. -

    Example 1:
    +

    In this problem, a rooted tree is a directed graph such that, there is exactly one node (the root) for which all other nodes are descendants of this node, plus every node has exactly one parent, except for the root node which has no parents.

    + +

    The given input is a directed graph that started as a rooted tree with n nodes (with distinct values from 1 to n), with one additional directed edge added. The added edge has two different vertices chosen from 1 to n, and was not an edge that already existed.

    + +

    The resulting graph is given as a 2D-array of edges. Each element of edges is a pair [ui, vi] that represents a directed edge connecting nodes ui and vi, where ui is a parent of child vi.

    + +

    Return an edge that can be removed so that the resulting graph is a rooted tree of n nodes. If there are multiple answers, return the answer that occurs last in the given 2D-array.

    + +

     

    +

    Example 1:

    +
    -Input: [[1,2], [1,3], [2,3]]
    -Output: [2,3]
    -Explanation: The given directed graph will be like this:
    -  1
    - / \
    -v   v
    -2-->3
    +Input: edges = [[1,2],[1,3],[2,3]]
    +Output: [2,3]
     
    -

    -

    Example 2:
    + +

    Example 2:

    +
    -Input: [[1,2], [2,3], [3,4], [4,1], [1,5]]
    -Output: [4,1]
    -Explanation: The given directed graph will be like this:
    -5 <- 1 -> 2
    -     ^    |
    -     |    v
    -     4 <- 3
    +Input: edges = [[1,2],[2,3],[3,4],[4,1],[1,5]]
    +Output: [4,1]
     
    -

    -

    Note:
    -

  • The size of the input 2D-array will be between 3 and 1000.
  • -
  • Every integer represented in the 2D-array will be between 1 and N, where N is the size of the input array.
  • -

    + +

     

    +

    Constraints:

    + +
      +
    • n == edges.length
    • +
    • 3 <= n <= 1000
    • +
    • edges[i].length == 2
    • +
    • 1 <= ui, vi <= n
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/reformat-phone-number/README.md b/problems/reformat-phone-number/README.md new file mode 100644 index 000000000..3efa683ad --- /dev/null +++ b/problems/reformat-phone-number/README.md @@ -0,0 +1,98 @@ + + + + + + + +[< Previous](../daily-leads-and-partners "Daily Leads and Partners") +                 +[Next >](../maximum-erasure-value "Maximum Erasure Value") + +## [1694. Reformat Phone Number (Easy)](https://leetcode.com/problems/reformat-phone-number "重新格式化电话号码") + +

    You are given a phone number as a string number. number consists of digits, spaces ' ', and/or dashes '-'.

    + +

    You would like to reformat the phone number in a certain manner. Firstly, remove all spaces and dashes. Then, group the digits from left to right into blocks of length 3 until there are 4 or fewer digits. The final digits are then grouped as follows:

    + +
      +
    • 2 digits: A single block of length 2.
    • +
    • 3 digits: A single block of length 3.
    • +
    • 4 digits: Two blocks of length 2 each.
    • +
    + +

    The blocks are then joined by dashes. Notice that the reformatting process should never produce any blocks of length 1 and produce at most two blocks of length 2.

    + +

    Return the phone number after formatting.

    + +

     

    +

    Example 1:

    + +
    +Input: number = "1-23-45 6"
    +Output: "123-456"
    +Explanation: The digits are "123456".
    +Step 1: There are more than 4 digits, so group the next 3 digits. The 1st block is "123".
    +Step 2: There are 3 digits remaining, so put them in a single block of length 3. The 2nd block is "456".
    +Joining the blocks gives "123-456".
    +
    + +

    Example 2:

    + +
    +Input: number = "123 4-567"
    +Output: "123-45-67"
    +Explanation: The digits are "1234567".
    +Step 1: There are more than 4 digits, so group the next 3 digits. The 1st block is "123".
    +Step 2: There are 4 digits left, so split them into two blocks of length 2. The blocks are "45" and "67".
    +Joining the blocks gives "123-45-67".
    +
    + +

    Example 3:

    + +
    +Input: number = "123 4-5678"
    +Output: "123-456-78"
    +Explanation: The digits are "12345678".
    +Step 1: The 1st block is "123".
    +Step 2: The 2nd block is "456".
    +Step 3: There are 2 digits left, so put them in a single block of length 2. The 3rd block is "78".
    +Joining the blocks gives "123-456-78".
    +
    + +

    Example 4:

    + +
    +Input: number = "12"
    +Output: "12"
    +
    + +

    Example 5:

    + +
    +Input: number = "--17-5 229 35-39475 "
    +Output: "175-229-353-94-75"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= number.length <= 100
    • +
    • number consists of digits and the characters '-' and ' '.
    • +
    • There are at least two digits in number.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Discard all the spaces and dashes. +
    + +
    +Hint 2 +Use a while loop. While the string still has digits, check its length and see which rule to apply. +
    diff --git a/problems/remove-duplicates-from-sorted-array-ii/README.md b/problems/remove-duplicates-from-sorted-array-ii/README.md index 0643564e0..a6766e6c0 100644 --- a/problems/remove-duplicates-from-sorted-array-ii/README.md +++ b/problems/remove-duplicates-from-sorted-array-ii/README.md @@ -55,7 +55,7 @@ for (int i = 0; i < len; i++) {

    Constraints:

      -
    • 0 <= nums.length <= 3 * 104
    • +
    • 1 <= nums.length <= 3 * 104
    • -104 <= nums[i] <= 104
    • nums is sorted in ascending order.
    diff --git a/problems/remove-element/README.md b/problems/remove-element/README.md index 06c8726eb..f9d2427bd 100644 --- a/problems/remove-element/README.md +++ b/problems/remove-element/README.md @@ -11,9 +11,9 @@ ## [27. Remove Element (Easy)](https://leetcode.com/problems/remove-element "移除元素") -

    Given an array nums and a value val, remove all instances of that value in-place and return the new length.

    +

    Given an array nums and a value val, remove all instances of that value in-place and return the new length.

    -

    Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.

    +

    Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.

    The order of elements can be changed. It doesn't matter what you leave beyond the new length.

    @@ -42,7 +42,7 @@ for (int i = 0; i < len; i++) { Input: nums = [3,2,2,3], val = 3 Output: 2, nums = [2,2] Explanation: Your function should return length = 2, with the first two elements of nums being 2. -It doesn't matter what you leave beyond the returned length. For example if you return 2 with nums = [2,2,3,3] or nums = [2,3,0,0], your answer will be accepted. +It doesn't matter what you leave beyond the returned length. For example if you return 2 with nums = [2,2,3,3] or nums = [2,2,0,0], your answer will be accepted.

    Example 2:

    diff --git a/problems/rising-temperature/README.md b/problems/rising-temperature/README.md index 6eec734af..87eccc276 100644 --- a/problems/rising-temperature/README.md +++ b/problems/rising-temperature/README.md @@ -52,5 +52,5 @@ Result table: | 4 | +----+ In 2015-01-02, temperature was higher than the previous day (10 -> 25). -In 2015-01-04, temperature was higher than the previous day (30 -> 20). +In 2015-01-04, temperature was higher than the previous day (20 -> 30). diff --git a/problems/same-tree/README.md b/problems/same-tree/README.md index 162173b56..63caeb36f 100644 --- a/problems/same-tree/README.md +++ b/problems/same-tree/README.md @@ -11,46 +11,40 @@ ## [100. Same Tree (Easy)](https://leetcode.com/problems/same-tree "相同的树") -

    Given two binary trees, write a function to check if they are the same or not.

    +

    Given the roots of two binary trees p and q, write a function to check if they are the same or not.

    -

    Two binary trees are considered the same if they are structurally identical and the nodes have the same value.

    +

    Two binary trees are considered the same if they are structurally identical, and the nodes have the same value.

    +

     

    Example 1:

    - +
    -Input:     1         1
    -          / \       / \
    -         2   3     2   3
    -
    -        [1,2,3],   [1,2,3]
    -
    +Input: p = [1,2,3], q = [1,2,3]
     Output: true
     

    Example 2:

    - +
    -Input:     1         1
    -          /           \
    -         2             2
    -
    -        [1,2],     [1,null,2]
    -
    +Input: p = [1,2], q = [1,null,2]
     Output: false
     

    Example 3:

    - +
    -Input:     1         1
    -          / \       / \
    -         2   1     1   2
    -
    -        [1,2,1],   [1,1,2]
    -
    +Input: p = [1,2,1], q = [1,1,2]
     Output: false
     
    +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in both trees is in the range [0, 100].
    • +
    • -104 <= Node.val <= 104
    • +
    + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/search-a-2d-matrix/README.md b/problems/search-a-2d-matrix/README.md index 70176897f..a17dcd2f6 100644 --- a/problems/search-a-2d-matrix/README.md +++ b/problems/search-a-2d-matrix/README.md @@ -22,21 +22,14 @@

    Example 1:

    -Input: matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,50]], target = 3
    +Input: matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 3
     Output: true
     

    Example 2:

    -Input: matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,50]], target = 13
    -Output: false
    -
    - -

    Example 3:

    - -
    -Input: matrix = [], target = 0
    +Input: matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 13
     Output: false
     
    @@ -46,7 +39,7 @@
    • m == matrix.length
    • n == matrix[i].length
    • -
    • 0 <= m, n <= 100
    • +
    • 1 <= m, n <= 100
    • -104 <= matrix[i][j], target <= 104
    diff --git a/problems/short-encoding-of-words/README.md b/problems/short-encoding-of-words/README.md index c18dc8979..c45811240 100644 --- a/problems/short-encoding-of-words/README.md +++ b/problems/short-encoding-of-words/README.md @@ -11,13 +11,15 @@ ## [820. Short Encoding of Words (Medium)](https://leetcode.com/problems/short-encoding-of-words "单词的压缩编码") -

    Given a list of words, we may encode it by writing a reference string s and a list of indexes a.

    +

    A valid encoding of an array of words is any reference string s and array of indices indices such that:

    -

    For example, if the list of words is ["time", "me", "bell"], we can write it as s = "time#bell#" and indexes = [0, 2, 5].

    - -

    Then for each index, we will recover the word by reading from the reference string from that index until we reach a "#" character.

    +
      +
    • words.length == indices.length
    • +
    • The reference string s ends with the '#' character.
    • +
    • For each index indices[i], the substring of s starting from indices[i] and up to (but not including) the next '#' character is equal to words[i].
    • +
    -

    Return the length of the shortest reference string s possible that encodes the given words.

    +

    Given an array of words, return the length of the shortest reference string s possible of any valid encoding of words.

     

    Example 1:

    @@ -25,7 +27,10 @@
     Input: words = ["time", "me", "bell"]
     Output: 10
    -Explanation: s = "time#bell#" and indexes = [0, 2, 5].
    +Explanation: A valid encoding would be s = "time#bell#" and indices = [0, 2, 5].
    +words[0] = "time", the substring of s starting from indices[0] = 0 to the next '#' is underlined in "time#bell#"
    +words[1] = "me", the substring of s starting from indices[1] = 2 to the next '#' is underlined in "time#bell#"
    +words[2] = "bell", the substring of s starting from indices[2] = 5 to the next '#' is underlined in "time#bell#"
     

    Example 2:

    @@ -33,6 +38,8 @@
     Input: words = ["t"]
     Output: 2
    +Explanation: A valid encoding would be s = "t#" and indices = [0].
    +
     

     

    diff --git a/problems/single-number-iii/README.md b/problems/single-number-iii/README.md index 1052f6b57..8ff056aa4 100644 --- a/problems/single-number-iii/README.md +++ b/problems/single-number-iii/README.md @@ -42,8 +42,9 @@

    Constraints:

      -
    • 1 <= nums.length <= 30000
    • -
    •  Each integer in nums will appear twice, only two integers will appear once.
    • +
    • 2 <= nums.length <= 3 * 104
    • +
    • -231 <= nums[i] <= 231 - 1
    • +
    • Each integer in nums will appear twice, only two integers will appear once.
    ### Related Topics diff --git a/problems/sort-the-matrix-diagonally/README.md b/problems/sort-the-matrix-diagonally/README.md index d99b12887..31bb6d3b4 100644 --- a/problems/sort-the-matrix-diagonally/README.md +++ b/problems/sort-the-matrix-diagonally/README.md @@ -11,7 +11,9 @@ ## [1329. Sort the Matrix Diagonally (Medium)](https://leetcode.com/problems/sort-the-matrix-diagonally "将矩阵按对角线排序") -

    Given a m * n matrix mat of integers, sort it diagonally in ascending order from the top-left to the bottom-right then return the sorted array.

    +

    A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until reaching the matrix's end. For example, the matrix diagonal starting from mat[2][0], where mat is a 6 x 3 matrix, includes cells mat[2][0], mat[3][1], and mat[4][2].

    + +

    Given an m x n matrix mat of integers, sort each matrix diagonal in ascending order and return the resulting matrix.

     

    Example 1:

    diff --git a/problems/stone-game-vi/README.md b/problems/stone-game-vi/README.md index ee65e1a73..62f6a7854 100644 --- a/problems/stone-game-vi/README.md +++ b/problems/stone-game-vi/README.md @@ -17,7 +17,7 @@

    You are given two integer arrays of length n, aliceValues and bobValues. Each aliceValues[i] and bobValues[i] represents how Alice and Bob, respectively, value the ith stone.

    -

    The winner is the person with the most points after all the stones are chosen. If both players have the same amount of points, the game results in a draw. Both players will play optimally.

    +

    The winner is the person with the most points after all the stones are chosen. If both players have the same amount of points, the game results in a draw. Both players will play optimally. Both players know the other's values.

    Determine the result of the game, and:

    diff --git a/problems/string-without-aaa-or-bbb/README.md b/problems/string-without-aaa-or-bbb/README.md index a252e92b6..6be32faa8 100644 --- a/problems/string-without-aaa-or-bbb/README.md +++ b/problems/string-without-aaa-or-bbb/README.md @@ -11,41 +11,37 @@ ## [984. String Without AAA or BBB (Medium)](https://leetcode.com/problems/string-without-aaa-or-bbb "不含 AAA 或 BBB 的字符串") -

    Given two integers A and B, return any string S such that:

    +

    Given two integers a and b, return any string s such that:

      -
    • S has length A + B and contains exactly A 'a' letters, and exactly B 'b' letters;
    • -
    • The substring 'aaa' does not occur in S;
    • -
    • The substring 'bbb' does not occur in S.
    • +
    • s has length a + b and contains exactly a 'a' letters, and exactly b 'b' letters,
    • +
    • The substring 'aaa' does not occur in s, and
    • +
    • The substring 'bbb' does not occur in s.

     

    -

    Example 1:

    -Input: A = 1, B = 2
    -Output: "abb"
    -Explanation: "abb", "bab" and "bba" are all correct answers.
    +Input: a = 1, b = 2
    +Output: "abb"
    +Explanation: "abb", "bab" and "bba" are all correct answers.
     
    -

    Example 2:

    -Input: A = 4, B = 1
    -Output: "aabaa"
    +Input: a = 4, b = 1 +Output: "aabaa" +

     

    -
    - -

    Note:

    +

    Constraints:

    -
      -
    1. 0 <= A <= 100
    2. -
    3. 0 <= B <= 100
    4. -
    5. It is guaranteed such an S exists for the given A and B.
    6. -
    +
      +
    • 0 <= a, b <= 100
    • +
    • It is guaranteed such an s exists for the given a and b.
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/subarrays-with-k-different-integers/README.md b/problems/subarrays-with-k-different-integers/README.md index 0ca5646b9..baa2312b3 100644 --- a/problems/subarrays-with-k-different-integers/README.md +++ b/problems/subarrays-with-k-different-integers/README.md @@ -53,4 +53,4 @@ ### Similar Questions 1. [Longest Substring Without Repeating Characters](../longest-substring-without-repeating-characters) (Medium) 1. [Longest Substring with At Most Two Distinct Characters](../longest-substring-with-at-most-two-distinct-characters) (Medium) - 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Hard) + 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Medium) diff --git a/problems/swap-nodes-in-pairs/README.md b/problems/swap-nodes-in-pairs/README.md index aa9588786..a16086aa5 100644 --- a/problems/swap-nodes-in-pairs/README.md +++ b/problems/swap-nodes-in-pairs/README.md @@ -46,6 +46,7 @@ ### Related Topics + [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions diff --git a/problems/triangle/README.md b/problems/triangle/README.md index eaf8a2655..d7612fbb3 100644 --- a/problems/triangle/README.md +++ b/problems/triangle/README.md @@ -11,24 +11,38 @@ ## [120. Triangle (Medium)](https://leetcode.com/problems/triangle "三角形最小路径和") -

    Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.

    +

    Given a triangle array, return the minimum path sum from top to bottom.

    -

    For example, given the following triangle

    +

    For each step, you may move to an adjacent number on the row below.

    + +

     

    +

    Example 1:

    + +
    +Input: triangle = [[2],[3,4],[6,5,7],[4,1,8,3]]
    +Output: 11
    +Explanation: The minimum path sum from top to bottom is 11 (i.e., 2 + 3 + 5 + 1 = 11).
    +
    + +

    Example 2:

    -[
    -     [2],
    -    [3,4],
    -   [6,5,7],
    -  [4,1,8,3]
    -]
    +Input: triangle = [[-10]]
    +Output: -10
     
    -

    The minimum path sum from top to bottom is 11 (i.e., 2 + 3 + 5 + 1 = 11).

    +

     

    +

    Constraints:

    -

    Note:

    +
      +
    • 1 <= triangle.length <= 200
    • +
    • triangle[0].length == 1
    • +
    • triangle[i].length == triangle[i - 1].length + 1
    • +
    • -104 <= triangle[i][j] <= 104
    • +
    -

    Bonus point if you are able to do this using only O(n) extra space, where n is the total number of rows in the triangle.

    +

     

    +Follow up: Could you do this using only O(n) extra space, where n is the total number of rows in the triangle? ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/valid-mountain-array/README.md b/problems/valid-mountain-array/README.md index c194f6c86..ce394ccd2 100644 --- a/problems/valid-mountain-array/README.md +++ b/problems/valid-mountain-array/README.md @@ -11,15 +11,15 @@ ## [941. Valid Mountain Array (Easy)](https://leetcode.com/problems/valid-mountain-array "有效的山脉数组") -

    Given an array of integers arr, return true if and only if it is a valid mountain array.

    +

    Given an array of integers arr, return true if and only if it is a valid mountain array.

    Recall that arr is a mountain array if and only if:

    • arr.length >= 3
    • -
    • There exists some i with 0 < i < arr.length - 1 such that: +
    • There exists some i with 0 < i < arr.length - 1 such that:
        -
      • arr[0] < arr[1] < ... < arr[i - 1] < A[i]
      • +
      • arr[0] < arr[1] < ... < arr[i - 1] < arr[i]
      • arr[i] > arr[i + 1] > ... > arr[arr.length - 1]
    • diff --git a/problems/where-will-the-ball-fall/README.md b/problems/where-will-the-ball-fall/README.md new file mode 100644 index 000000000..ee6f59080 --- /dev/null +++ b/problems/where-will-the-ball-fall/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../maximum-number-of-eaten-apples "Maximum Number of Eaten Apples") +                 +[Next >](../maximum-xor-with-an-element-from-array "Maximum XOR With an Element From Array") + +## [1706. Where Will the Ball Fall (Medium)](https://leetcode.com/problems/where-will-the-ball-fall "球会落何处") + +

      You have a 2-D grid of size m x n representing a box, and you have n balls. The box is open on the top and bottom sides.

      + +

      Each cell in the box has a diagonal board spanning two corners of the cell that can redirect a ball to the right or to the left.

      + +
        +
      • A board that redirects the ball to the right spans the top-left corner to the bottom-right corner and is represented in the grid as 1.
      • +
      • A board that redirects the ball to the left spans the top-right corner to the bottom-left corner and is represented in the grid as -1.
      • +
      + +

      We drop one ball at the top of each column of the box. Each ball can get stuck in the box or fall out of the bottom. A ball gets stuck if it hits a "V" shaped pattern between two boards or if a board redirects the ball into either wall of the box.

      + +

      Return an array answer of size n where answer[i] is the column that the ball falls out of at the bottom after dropping the ball from the ith column at the top, or -1 if the ball gets stuck in the box.

      + +

       

      +

      Example 1:

      + +

      + +
      +Input: grid = [[1,1,1,-1,-1],[1,1,1,-1,-1],[-1,-1,-1,1,1],[1,1,1,1,-1],[-1,-1,-1,-1,-1]]
      +Output: [1,-1,-1,-1,-1]
      +Explanation: This example is shown in the photo.
      +Ball b0 is dropped at column 0 and falls out of the box at column 1.
      +Ball b1 is dropped at column 1 and will get stuck in the box between column 2 and 3 and row 1.
      +Ball b2 is dropped at column 2 and will get stuck on the box between column 2 and 3 and row 0.
      +Ball b3 is dropped at column 3 and will get stuck on the box between column 2 and 3 and row 0.
      +Ball b4 is dropped at column 4 and will get stuck on the box between column 2 and 3 and row 1.
      +
      + +

      Example 2:

      + +
      +Input: grid = [[-1]]
      +Output: [-1]
      +Explanation: The ball gets stuck against the left wall.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • m == grid.length
      • +
      • n == grid[i].length
      • +
      • 1 <= m, n <= 100
      • +
      • grid[i][j] is 1 or -1.
      • +
      + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
      +Hint 1 +Use DFS. +
      + +
      +Hint 2 +Traverse the path of the ball downwards until you reach the bottom or get stuck. +
      diff --git a/problems/word-ladder-ii/README.md b/problems/word-ladder-ii/README.md index 89166942d..89a3a383f 100644 --- a/problems/word-ladder-ii/README.md +++ b/problems/word-ladder-ii/README.md @@ -66,4 +66,4 @@ wordList = ["hot","dot","dog","lot",&quo [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [Word Ladder](../word-ladder) (Medium) + 1. [Word Ladder](../word-ladder) (Hard) diff --git a/problems/word-ladder/README.md b/problems/word-ladder/README.md index 008dce79f..da04e85e8 100644 --- a/problems/word-ladder/README.md +++ b/problems/word-ladder/README.md @@ -9,53 +9,45 @@                  [Next >](../longest-consecutive-sequence "Longest Consecutive Sequence") -## [127. Word Ladder (Medium)](https://leetcode.com/problems/word-ladder "单词接龙") +## [127. Word Ladder (Hard)](https://leetcode.com/problems/word-ladder "单词接龙") -

      Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such that:

      +

      Given two words beginWord and endWord, and a dictionary wordList, return the length of the shortest transformation sequence from beginWord to endWord, such that:

      -
        +
        • Only one letter can be changed at a time.
        • Each transformed word must exist in the word list.
        • -
      - -

      Note:

      - -
        -
      • Return 0 if there is no such transformation sequence.
      • -
      • All words have the same length.
      • -
      • All words contain only lowercase alphabetic characters.
      • -
      • You may assume no duplicates in the word list.
      • -
      • You may assume beginWord and endWord are non-empty and are not the same.
      +

      Return 0 if there is no such transformation sequence.

      + +

       

      Example 1:

      -Input:
      -beginWord = "hit",
      -endWord = "cog",
      -wordList = ["hot","dot","dog","lot","log","cog"]
      -
      -Output: 5
      -
      -Explanation: As one shortest transformation is "hit" -> "hot" -> "dot" -> "dog" -> "cog",
      -return its length 5.
      +Input: beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log","cog"]
      +Output: 5
      +Explanation: As one shortest transformation is "hit" -> "hot" -> "dot" -> "dog" -> "cog", return its length 5.
       

      Example 2:

      -Input:
      -beginWord = "hit"
      -endWord = "cog"
      -wordList = ["hot","dot","dog","lot","log"]
      -
      -Output: 0
      -
      -Explanation: The endWord "cog" is not in wordList, therefore no possible transformation.
      +Input: beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log"]
      +Output: 0
      +Explanation: The endWord "cog" is not in wordList, therefore no possible transformation.
       
      +

       

      +

      Constraints:

      +
        +
      • 1 <= beginWord.length <= 100
      • +
      • endWord.length == beginWord.length
      • +
      • 1 <= wordList.length <= 5000
      • +
      • wordList[i].length == beginWord.length
      • +
      • beginWordendWord, and wordList[i] consist of lowercase English letters.
      • +
      • beginWord != endWord
      • +
      • All the strings in wordList are unique.
      ### Related Topics diff --git a/readme/1-300.md b/readme/1-300.md index 12363d525..63d054eac 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -172,11 +172,11 @@ LeetCode Problems' Solutions | 100 | [Same Tree](https://leetcode.com/problems/same-tree "相同的树") | [Go](../problems/same-tree) | Easy | | 101 | [Symmetric Tree](https://leetcode.com/problems/symmetric-tree "对称二叉树") | [Go](../problems/symmetric-tree) | Easy | | 102 | [Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal "二叉树的层序遍历") | [Go](../problems/binary-tree-level-order-traversal) | Medium | -| 103 | [Binary Tree Zigzag Level Order Traversal](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal "二叉树的锯齿形层次遍历") | [Go](../problems/binary-tree-zigzag-level-order-traversal) | Medium | +| 103 | [Binary Tree Zigzag Level Order Traversal](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal "二叉树的锯齿形层序遍历") | [Go](../problems/binary-tree-zigzag-level-order-traversal) | Medium | | 104 | [Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree "二叉树的最大深度") | [Go](../problems/maximum-depth-of-binary-tree) | Easy | | 105 | [Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal "从前序与中序遍历序列构造二叉树") | [Go](../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | Medium | | 106 | [Construct Binary Tree from Inorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal "从中序与后序遍历序列构造二叉树") | [Go](../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | Medium | -| 107 | [Binary Tree Level Order Traversal II](https://leetcode.com/problems/binary-tree-level-order-traversal-ii "二叉树的层次遍历 II") | [Go](../problems/binary-tree-level-order-traversal-ii) | Easy | +| 107 | [Binary Tree Level Order Traversal II](https://leetcode.com/problems/binary-tree-level-order-traversal-ii "二叉树的层序遍历 II") | [Go](../problems/binary-tree-level-order-traversal-ii) | Easy | | 108 | [Convert Sorted Array to Binary Search Tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree "将有序数组转换为二叉搜索树") | [Go](../problems/convert-sorted-array-to-binary-search-tree) | Easy | | 109 | [Convert Sorted List to Binary Search Tree](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree "有序链表转换二叉搜索树") | [Go](../problems/convert-sorted-list-to-binary-search-tree) | Medium | | 110 | [Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree "平衡二叉树") | [Go](../problems/balanced-binary-tree) | Easy | @@ -196,7 +196,7 @@ LeetCode Problems' Solutions | 124 | [Binary Tree Maximum Path Sum](https://leetcode.com/problems/binary-tree-maximum-path-sum "二叉树中的最大路径和") | [Go](../problems/binary-tree-maximum-path-sum) | Hard | | 125 | [Valid Palindrome](https://leetcode.com/problems/valid-palindrome "验证回文串") | [Go](../problems/valid-palindrome) | Easy | | 126 | [Word Ladder II](https://leetcode.com/problems/word-ladder-ii "单词接龙 II") | [Go](../problems/word-ladder-ii) | Hard | -| 127 | [Word Ladder](https://leetcode.com/problems/word-ladder "单词接龙") | [Go](../problems/word-ladder) | Medium | +| 127 | [Word Ladder](https://leetcode.com/problems/word-ladder "单词接龙") | [Go](../problems/word-ladder) | Hard | | 128 | [Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence "最长连续序列") | [Go](../problems/longest-consecutive-sequence) | Hard | | 129 | [Sum Root to Leaf Numbers](https://leetcode.com/problems/sum-root-to-leaf-numbers "求根到叶子节点数字之和") | [Go](../problems/sum-root-to-leaf-numbers) | Medium | | 130 | [Surrounded Regions](https://leetcode.com/problems/surrounded-regions "被围绕的区域") | [Go](../problems/surrounded-regions) | Medium | @@ -267,7 +267,7 @@ LeetCode Problems' Solutions | 195 | [Tenth Line](https://leetcode.com/problems/tenth-line "第十行") | [Bash](../problems/tenth-line) | Easy | | 196 | [Delete Duplicate Emails](https://leetcode.com/problems/delete-duplicate-emails "删除重复的电子邮箱") | [MySQL](../problems/delete-duplicate-emails) | Easy | | 197 | [Rising Temperature](https://leetcode.com/problems/rising-temperature "上升的温度") | [MySQL](../problems/rising-temperature) | Easy | -| 198 | [House Robber](https://leetcode.com/problems/house-robber "打家劫舍") | [Go](../problems/house-robber) | Easy | +| 198 | [House Robber](https://leetcode.com/problems/house-robber "打家劫舍") | [Go](../problems/house-robber) | Medium | | 199 | [Binary Tree Right Side View](https://leetcode.com/problems/binary-tree-right-side-view "二叉树的右视图") | [Go](../problems/binary-tree-right-side-view) | Medium | | 200 | [Number of Islands](https://leetcode.com/problems/number-of-islands "岛屿数量") | [Go](../problems/number-of-islands) | Medium | | 201 | [Bitwise AND of Numbers Range](https://leetcode.com/problems/bitwise-and-of-numbers-range "数字范围按位与") | [Go](../problems/bitwise-and-of-numbers-range) | Medium | @@ -369,4 +369,4 @@ LeetCode Problems' Solutions | 297 | [Serialize and Deserialize Binary Tree](https://leetcode.com/problems/serialize-and-deserialize-binary-tree "二叉树的序列化与反序列化") | [Go](../problems/serialize-and-deserialize-binary-tree) | Hard | | 298 | [Binary Tree Longest Consecutive Sequence](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence "二叉树最长连续序列") 🔒 | [Go](../problems/binary-tree-longest-consecutive-sequence) | Medium | | 299 | [Bulls and Cows](https://leetcode.com/problems/bulls-and-cows "猜数字游戏") | [Go](../problems/bulls-and-cows) | Medium | -| 300 | [Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence "最长上升子序列") | [Go](../problems/longest-increasing-subsequence) | Medium | +| 300 | [Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence "最长递增子序列") | [Go](../problems/longest-increasing-subsequence) | Medium | diff --git a/readme/301-600.md b/readme/301-600.md index 76dc35af2..fb99096b5 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -109,7 +109,7 @@ LeetCode Problems' Solutions | 337 | [House Robber III](https://leetcode.com/problems/house-robber-iii "打家劫舍 III") | [Go](../problems/house-robber-iii) | Medium | | 338 | [Counting Bits](https://leetcode.com/problems/counting-bits "比特位计数") | [Go](../problems/counting-bits) | Medium | | 339 | [Nested List Weight Sum](https://leetcode.com/problems/nested-list-weight-sum "嵌套列表权重和") 🔒 | [Go](../problems/nested-list-weight-sum) | Easy | -| 340 | [Longest Substring with At Most K Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters "至多包含 K 个不同字符的最长子串") 🔒 | [Go](../problems/longest-substring-with-at-most-k-distinct-characters) | Hard | +| 340 | [Longest Substring with At Most K Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters "至多包含 K 个不同字符的最长子串") 🔒 | [Go](../problems/longest-substring-with-at-most-k-distinct-characters) | Medium | | 341 | [Flatten Nested List Iterator](https://leetcode.com/problems/flatten-nested-list-iterator "扁平化嵌套列表迭代器") | [Go](../problems/flatten-nested-list-iterator) | Medium | | 342 | [Power of Four](https://leetcode.com/problems/power-of-four "4的幂") | [Go](../problems/power-of-four) | Easy | | 343 | [Integer Break](https://leetcode.com/problems/integer-break "整数拆分") | [Go](../problems/integer-break) | Medium | @@ -222,7 +222,7 @@ LeetCode Problems' Solutions | 450 | [Delete Node in a BST](https://leetcode.com/problems/delete-node-in-a-bst "删除二叉搜索树中的节点") | [Go](../problems/delete-node-in-a-bst) | Medium | | 451 | [Sort Characters By Frequency](https://leetcode.com/problems/sort-characters-by-frequency "根据字符出现频率排序") | [Go](../problems/sort-characters-by-frequency) | Medium | | 452 | [Minimum Number of Arrows to Burst Balloons](https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons "用最少数量的箭引爆气球") | [Go](../problems/minimum-number-of-arrows-to-burst-balloons) | Medium | -| 453 | [Minimum Moves to Equal Array Elements](https://leetcode.com/problems/minimum-moves-to-equal-array-elements "最小移动次数使数组元素相等") | [Go](../problems/minimum-moves-to-equal-array-elements) | Easy | +| 453 | [Minimum Moves to Equal Array Elements](https://leetcode.com/problems/minimum-moves-to-equal-array-elements "最小操作次数使数组元素相等") | [Go](../problems/minimum-moves-to-equal-array-elements) | Easy | | 454 | [4Sum II](https://leetcode.com/problems/4sum-ii "四数相加 II") | [Go](../problems/4sum-ii) | Medium | | 455 | [Assign Cookies](https://leetcode.com/problems/assign-cookies "分发饼干") | [Go](../problems/assign-cookies) | Easy | | 456 | [132 Pattern](https://leetcode.com/problems/132-pattern "132模式") | [Go](../problems/132-pattern) | Medium | @@ -366,7 +366,7 @@ LeetCode Problems' Solutions | 594 | [Longest Harmonious Subsequence](https://leetcode.com/problems/longest-harmonious-subsequence "最长和谐子序列") | [Go](../problems/longest-harmonious-subsequence) | Easy | | 595 | [Big Countries](https://leetcode.com/problems/big-countries "大的国家") | [MySQL](../problems/big-countries) | Easy | | 596 | [Classes More Than 5 Students](https://leetcode.com/problems/classes-more-than-5-students "超过5名学生的课") | [MySQL](../problems/classes-more-than-5-students) | Easy | -| 597 | [Friend Requests I: Overall Acceptance Rate](https://leetcode.com/problems/friend-requests-i-overall-acceptance-rate "好友申请 I :总体通过率") 🔒 | [MySQL](../problems/friend-requests-i-overall-acceptance-rate) | Easy | +| 597 | [Friend Requests I: Overall Acceptance Rate](https://leetcode.com/problems/friend-requests-i-overall-acceptance-rate "好友申请 I:总体通过率") 🔒 | [MySQL](../problems/friend-requests-i-overall-acceptance-rate) | Easy | | 598 | [Range Addition II](https://leetcode.com/problems/range-addition-ii "范围求和 II") | [Go](../problems/range-addition-ii) | Easy | | 599 | [Minimum Index Sum of Two Lists](https://leetcode.com/problems/minimum-index-sum-of-two-lists "两个列表的最小索引总和") | [Go](../problems/minimum-index-sum-of-two-lists) | Easy | | 600 | [Non-negative Integers without Consecutive Ones](https://leetcode.com/problems/non-negative-integers-without-consecutive-ones "不含连续1的非负整数") | [Go](../problems/non-negative-integers-without-consecutive-ones) | Hard | diff --git a/tag/README.md b/tag/README.md index aee906df4..44eea5ddf 100644 --- a/tag/README.md +++ b/tag/README.md @@ -19,7 +19,7 @@ | 15 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | | 19 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 20 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | -| 21 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | | 22 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | +| 21 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | | 22 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | | 23 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | | 24 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 25 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | | 27 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | | 28 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | @@ -27,6 +27,6 @@ | 31 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 32 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | | 33 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 34 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | | 35 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [](dequeue/README.md) | [](https://openset.github.io/tags/dequeue/) | -| 37 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | | 38 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | -| 39 | [Reservoir Sampling](reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | | 40 | [Suffix Array](suffix-array/README.md) | [Suffix Array](https://openset.github.io/tags/suffix-array/) | +| 37 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | | 38 | [Suffix Array](suffix-array/README.md) | [Suffix Array](https://openset.github.io/tags/suffix-array/) | +| 39 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | | 40 | [Reservoir Sampling](reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | | 41 | [Memoization](memoization/README.md) | [记忆化](https://openset.github.io/tags/memoization/) | | 42 | [](oop/README.md) | [](https://openset.github.io/tags/oop/) | diff --git a/tag/array/README.md b/tag/array/README.md index 637095778..db6a5e763 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1701 | [平均等待时间](../../problems/average-waiting-time) | [[数组](../array/README.md)] | Medium | +| 1700 | [无法吃午餐的学生数量](../../problems/number-of-students-unable-to-eat-lunch) | [[数组](../array/README.md)] | Easy | | 1672 | [最富有客户的资产总量](../../problems/richest-customer-wealth) | [[数组](../array/README.md)] | Easy | | 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Easy | | 1652 | [拆炸弹](../../problems/defuse-the-bomb) | [[数组](../array/README.md)] | Easy | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 1d67a2924..fce6888d9 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -32,6 +32,7 @@ | 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 980 | [不同路径 III](../../problems/unique-paths-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 4c89615a8..155852663 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -82,7 +82,7 @@ | 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 302 | [包含全部黑色像素的最小矩形](../../problems/smallest-rectangle-enclosing-black-pixels) 🔒 | [[二分查找](../binary-search/README.md)] | Hard | -| 300 | [最长上升子序列](../../problems/longest-increasing-subsequence) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 300 | [最长递增子序列](../../problems/longest-increasing-subsequence) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 278 | [第一个错误的版本](../../problems/first-bad-version) | [[二分查找](../binary-search/README.md)] | Easy | | 275 | [H 指数 II](../../problems/h-index-ii) | [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 0406a0869..fc676bb79 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,3 +9,58 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1707 | [与数组中元素的最大异或值](../../problems/maximum-xor-with-an-element-from-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Hard | +| 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Hard | +| 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1486 | [数组异或操作](../../problems/xor-operation-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | +| 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1404 | [将二进制表示减到 1 的步骤数](../../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[排序](../sort/README.md)] [[位运算](../bit-manipulation/README.md)] | Easy | +| 1342 | [将数字变成 0 的操作次数](../../problems/number-of-steps-to-reduce-a-number-to-zero) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 1318 | [或运算的最小翻转次数](../../problems/minimum-flips-to-make-a-or-b-equal-to-c) | [[位运算](../bit-manipulation/README.md)] | Medium | +| 1310 | [子数组异或查询](../../problems/xor-queries-of-a-subarray) | [[位运算](../bit-manipulation/README.md)] | Medium | +| 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)] | Easy | +| 1256 | [加密数字](../../problems/encode-number) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | +| 1255 | [得分最高的单词集合](../../problems/maximum-score-words-formed-by-letters) | [[位运算](../bit-manipulation/README.md)] | Hard | +| 1239 | [串联字符串的最大长度](../../problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1178 | [猜字谜](../../problems/number-of-valid-words-for-each-puzzle) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 1131 | [绝对值表达式的最大值](../../problems/maximum-of-absolute-value-expression) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | +| 1125 | [最小的必要团队](../../problems/smallest-sufficient-team) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 898 | [子数组按位或操作](../../problems/bitwise-ors-of-subarrays) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 762 | [二进制表示中质数个计算置位](../../problems/prime-number-of-set-bits-in-binary-representation) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 756 | [金字塔转换矩阵](../../problems/pyramid-transition-matrix) | [[位运算](../bit-manipulation/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 751 | [IP 到 CIDR](../../problems/ip-to-cidr) 🔒 | [[位运算](../bit-manipulation/README.md)] | Easy | +| 693 | [交替位二进制数](../../problems/binary-number-with-alternating-bits) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 477 | [汉明距离总和](../../problems/total-hamming-distance) | [[位运算](../bit-manipulation/README.md)] | Medium | +| 476 | [数字的补数](../../problems/number-complement) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 461 | [汉明距离](../../problems/hamming-distance) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 421 | [数组中两个数的最大异或值](../../problems/maximum-xor-of-two-numbers-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Medium | +| 411 | [最短特异单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 405 | [数字转换为十六进制数](../../problems/convert-a-number-to-hexadecimal) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 401 | [二进制手表](../../problems/binary-watch) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | +| 397 | [整数替换](../../problems/integer-replacement) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | +| 393 | [UTF-8 编码验证](../../problems/utf-8-validation) | [[位运算](../bit-manipulation/README.md)] | Medium | +| 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 371 | [两整数之和](../../problems/sum-of-two-integers) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 342 | [4的幂](../../problems/power-of-four) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 318 | [最大单词长度乘积](../../problems/maximum-product-of-word-lengths) | [[位运算](../bit-manipulation/README.md)] | Medium | +| 268 | [丢失的数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 260 | [只出现一次的数字 III](../../problems/single-number-iii) | [[位运算](../bit-manipulation/README.md)] | Medium | +| 231 | [2的幂](../../problems/power-of-two) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | +| 201 | [数字范围按位与](../../problems/bitwise-and-of-numbers-range) | [[位运算](../bit-manipulation/README.md)] | Medium | +| 191 | [位1的个数](../../problems/number-of-1-bits) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 190 | [颠倒二进制位](../../problems/reverse-bits) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 187 | [重复的DNA序列](../../problems/repeated-dna-sequences) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 169 | [多数元素](../../problems/majority-element) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Easy | +| 137 | [只出现一次的数字 II](../../problems/single-number-ii) | [[位运算](../bit-manipulation/README.md)] | Medium | +| 136 | [只出现一次的数字](../../problems/single-number) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index a4976f342..0bfc32364 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -36,7 +36,7 @@ | 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 994 | [腐烂的橘子](../../problems/rotting-oranges) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[极小化极大](../minimax/README.md)] | Hard | | 909 | [蛇梯棋](../../problems/snakes-and-ladders) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | @@ -78,11 +78,11 @@ | 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 127 | [单词接龙](../../problems/word-ladder) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 127 | [单词接龙](../../problems/word-ladder) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 107 | [二叉树的层次遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 103 | [二叉树的锯齿形层次遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 102 | [二叉树的层序遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index e486dbba9..d7abc14a2 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -55,7 +55,7 @@ | 979 | [在二叉树中分配硬币](../../problems/distribute-coins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 971 | [翻转二叉树以匹配先序遍历](../../problems/flip-binary-tree-to-match-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 947 | [移除最多的同行或同列石头](../../problems/most-stones-removed-with-same-row-or-column) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | @@ -135,14 +135,14 @@ | 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 129 | [求根到叶子节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | | 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | | 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index 0d334b142..9fcc476e7 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -9,3 +9,23 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1274 | [矩形内船只的数目](../../problems/number-of-ships-in-a-rectangle) 🔒 | [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 932 | [漂亮数组](../../problems/beautiful-array) | [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 903 | [DI 序列的有效排列](../../problems/valid-permutations-for-di-sequence) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 395 | [至少有K个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 312 | [戳气球](../../problems/burst-balloons) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 282 | [给表达式添加运算符](../../problems/expression-add-operators) | [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 241 | [为运算表达式设计优先级](../../problems/different-ways-to-add-parentheses) | [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | +| 215 | [数组中的第K个最大元素](../../problems/kth-largest-element-in-an-array) | [[堆](../heap/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 169 | [多数元素](../../problems/majority-element) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Easy | +| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 4 | [寻找两个正序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 58277ef32..882b2c7e5 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,242 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1691 | [堆叠长方体的最大高度](../../problems/maximum-height-by-stacking-cuboids) | [[排序](../sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1690 | [石子游戏 VII](../../problems/stone-game-vii) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1682 | [Longest Palindromic Subsequence II](../../problems/longest-palindromic-subsequence-ii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1671 | [得到山形数组的最少删除次数](../../problems/minimum-number-of-removals-to-make-mountain-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1664 | [生成平衡数组的方案数](../../problems/ways-to-make-a-fair-array) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1654 | [到家的最少跳跃次数](../../problems/minimum-jumps-to-reach-home) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1643 | [第 K 条最小指令](../../problems/kth-smallest-instructions) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1639 | [通过给定词典构造目标字符串的方案数](../../problems/number-of-ways-to-form-a-target-string-given-a-dictionary) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1626 | [无矛盾的最佳球队](../../problems/best-team-with-no-conflicts) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1621 | [大小为 K 的不重叠线段的数目](../../problems/number-of-sets-of-k-non-overlapping-line-segments) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1563 | [石子游戏 V](../../problems/stone-game-v) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1553 | [吃掉 N 个橘子的最少天数](../../problems/minimum-number-of-days-to-eat-n-oranges) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1548 | [图中最相似的路径](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1547 | [切棍子的最小成本](../../problems/minimum-cost-to-cut-a-stick) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1546 | [和为目标值的最大数目不重叠非空子数组数目](../../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1537 | [最大得分](../../problems/get-the-maximum-score) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1510 | [石子游戏 IV](../../problems/stone-game-iv) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1504 | [统计全 1 子矩形](../../problems/count-submatrices-with-all-ones) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1483 | [树节点的第 K 个祖先](../../problems/kth-ancestor-of-a-tree-node) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1477 | [找两个和为目标值且不重叠的子数组](../../problems/find-two-non-overlapping-sub-arrays-each-with-target-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1473 | [给房子涂色 III](../../problems/paint-house-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1463 | [摘樱桃 II](../../problems/cherry-pickup-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1458 | [两个子序列的最大点积](../../problems/max-dot-product-of-two-subsequences) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1444 | [切披萨的方案数](../../problems/number-of-ways-of-cutting-a-pizza) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1425 | [带限制的子序列和](../../problems/constrained-subsequence-sum) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1420 | [生成数组](../../problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1416 | [恢复数组](../../problems/restore-the-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1411 | [给 N x 3 网格图涂色的方案数](../../problems/number-of-ways-to-paint-n-x-3-grid) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1406 | [石子游戏 III](../../problems/stone-game-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1402 | [做菜顺序](../../problems/reducing-dishes) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1397 | [找到所有好字符串](../../problems/find-all-good-strings) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1388 | [3n 块披萨](../../problems/pizza-with-3n-slices) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1359 | [有效的快递序列数目](../../problems/count-all-valid-pickup-and-delivery-options) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1349 | [参加考试的最大学生数](../../problems/maximum-students-taking-exam) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1340 | [跳跃游戏 V](../../problems/jump-game-v) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1335 | [工作计划的最低难度](../../problems/minimum-difficulty-of-a-job-schedule) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1326 | [灌溉花园的最少水龙头数目](../../problems/minimum-number-of-taps-to-open-to-water-a-garden) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1320 | [二指输入的的最小距离](../../problems/minimum-distance-to-type-a-word-using-two-fingers) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1314 | [矩阵区域和](../../problems/matrix-block-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1312 | [让字符串成为回文串的最少插入次数](../../problems/minimum-insertion-steps-to-make-a-string-palindrome) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1301 | [最大得分的路径数目](../../problems/number-of-paths-with-max-score) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1289 | [下降路径最小和 II](../../problems/minimum-falling-path-sum-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1278 | [分割回文串 III](../../problems/palindrome-partitioning-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1277 | [统计全为 1 的正方形子矩阵](../../problems/count-square-submatrices-with-all-ones) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1273 | [删除树节点](../../problems/delete-tree-nodes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1269 | [停在原地的方案数](../../problems/number-of-ways-to-stay-in-the-same-place-after-some-steps) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1262 | [可被三整除的最大和](../../problems/greatest-sum-divisible-by-three) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1259 | [不相交的握手](../../problems/handshakes-that-dont-cross) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1246 | [删除回文子数组](../../problems/palindrome-removal) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1240 | [铺瓷砖](../../problems/tiling-a-rectangle-with-the-fewest-squares) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1230 | [抛掷硬币](../../problems/toss-strange-coins) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1223 | [掷骰子模拟](../../problems/dice-roll-simulation) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1220 | [统计元音字母序列的数目](../../problems/count-vowels-permutation) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1216 | [验证回文字符串 III](../../problems/valid-palindrome-iii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1199 | [建造街区的最短时间](../../problems/minimum-time-to-build-blocks) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1191 | [K 次串联后最大子数组之和](../../problems/k-concatenation-maximum-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1187 | [使数组严格递增](../../problems/make-array-strictly-increasing) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1186 | [删除一次得到子数组最大和](../../problems/maximum-subarray-sum-with-one-deletion) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1155 | [掷骰子的N种方法](../../problems/number-of-dice-rolls-with-target-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1147 | [段式回文](../../problems/longest-chunked-palindrome-decomposition) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1143 | [最长公共子序列](../../problems/longest-common-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1140 | [石子游戏 II](../../problems/stone-game-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1139 | [最大的以 1 为边界的正方形](../../problems/largest-1-bordered-square) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1125 | [最小的必要团队](../../problems/smallest-sufficient-team) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1105 | [填充书架](../../problems/filling-bookcase-shelves) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1092 | [最短公共超序列](../../problems/shortest-common-supersequence) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 1067 | [范围内的数字计数](../../problems/digit-count-in-range) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1055 | [形成字符串的最短路径](../../problems/shortest-way-to-form-string) 🔒 | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1049 | [最后一块石头的重量 II](../../problems/last-stone-weight-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1048 | [最长字符串链](../../problems/longest-string-chain) | [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1043 | [分隔数组以得到最大和](../../problems/partition-array-for-maximum-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1039 | [多边形三角剖分的最低得分](../../problems/minimum-score-triangulation-of-polygon) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1027 | [最长等差数列](../../problems/longest-arithmetic-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1025 | [除数博弈](../../problems/divisor-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 1024 | [视频拼接](../../problems/video-stitching) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1012 | [至少有 1 位重复的数字](../../problems/numbers-with-repeated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1000 | [合并石头的最低成本](../../problems/minimum-cost-to-merge-stones) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 983 | [最低票价](../../problems/minimum-cost-for-tickets) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 982 | [按位与为零的三元组](../../problems/triples-with-bitwise-and-equal-to-zero) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 964 | [表示数字的最少运算符](../../problems/least-operators-to-express-number) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 960 | [删列造序 III](../../problems/delete-columns-to-make-sorted-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 956 | [最高的广告牌](../../problems/tallest-billboard) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 943 | [最短超级串](../../problems/find-the-shortest-superstring) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 940 | [不同的子序列 II](../../problems/distinct-subsequences-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 935 | [骑士拨号器](../../problems/knight-dialer) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 931 | [下降路径最小和](../../problems/minimum-falling-path-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 920 | [播放列表的数量](../../problems/number-of-music-playlists) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 903 | [DI 序列的有效排列](../../problems/valid-permutations-for-di-sequence) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 902 | [最大为 N 的数字组合](../../problems/numbers-at-most-n-given-digit-set) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 898 | [子数组按位或操作](../../problems/bitwise-ors-of-subarrays) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 879 | [盈利计划](../../problems/profitable-schemes) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 877 | [石子游戏](../../problems/stone-game) | [[极小化极大](../minimax/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 871 | [最低加油次数](../../problems/minimum-number-of-refueling-stops) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 837 | [新21点](../../problems/new-21-game) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 818 | [赛车](../../problems/race-car) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 813 | [最大平均值和的分组](../../problems/largest-sum-of-averages) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 808 | [分汤](../../problems/soup-servings) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 801 | [使序列递增的最小交换次数](../../problems/minimum-swaps-to-make-sequences-increasing) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 799 | [香槟塔](../../problems/champagne-tower) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 790 | [多米诺和托米诺平铺](../../problems/domino-and-tromino-tiling) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 764 | [最大加号标志](../../problems/largest-plus-sign) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 750 | [角矩形的数量](../../problems/number-of-corner-rectangles) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 746 | [使用最小花费爬楼梯](../../problems/min-cost-climbing-stairs) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 741 | [摘樱桃](../../problems/cherry-pickup) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 740 | [删除与获得点数](../../problems/delete-and-earn) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 712 | [两个字符串的最小ASCII删除和](../../problems/minimum-ascii-delete-sum-for-two-strings) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 689 | [三个无重叠子数组的最大和](../../problems/maximum-sum-of-3-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 688 | [“马”在棋盘上的概率](../../problems/knight-probability-in-chessboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 673 | [最长递增子序列的个数](../../problems/number-of-longest-increasing-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 664 | [奇怪的打印机](../../problems/strange-printer) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 656 | [金币路径](../../problems/coin-path) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 651 | [4键键盘](../../problems/4-keys-keyboard) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 650 | [只有两个键的键盘](../../problems/2-keys-keyboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 647 | [回文子串](../../problems/palindromic-substrings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 646 | [最长数对链](../../problems/maximum-length-of-pair-chain) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 639 | [解码方法 2](../../problems/decode-ways-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 638 | [大礼包](../../problems/shopping-offers) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 629 | [K个逆序对数组](../../problems/k-inverse-pairs-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 600 | [不含连续1的非负整数](../../problems/non-negative-integers-without-consecutive-ones) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 576 | [出界的路径数](../../problems/out-of-boundary-paths) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 568 | [最大休假天数](../../problems/maximum-vacation-days) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 552 | [学生出勤记录 II](../../problems/student-attendance-record-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 546 | [移除盒子](../../problems/remove-boxes) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 523 | [连续的子数组和](../../problems/continuous-subarray-sum) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 517 | [超级洗衣机](../../problems/super-washing-machines) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 516 | [最长回文子序列](../../problems/longest-palindromic-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 494 | [目标和](../../problems/target-sum) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 486 | [预测赢家](../../problems/predict-the-winner) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 474 | [一和零](../../problems/ones-and-zeroes) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 471 | [编码最短长度的字符串](../../problems/encode-string-with-shortest-length) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 467 | [环绕字符串中唯一的子字符串](../../problems/unique-substrings-in-wraparound-string) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 466 | [统计重复个数](../../problems/count-the-repetitions) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 464 | [我能赢吗](../../problems/can-i-win) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 446 | [等差数列划分 II - 子序列](../../problems/arithmetic-slices-ii-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 416 | [分割等和子集](../../problems/partition-equal-subset-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 403 | [青蛙过河](../../problems/frog-jump) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 377 | [组合总和 Ⅳ](../../problems/combination-sum-iv) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 375 | [猜数字大小 II](../../problems/guess-number-higher-or-lower-ii) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 361 | [轰炸敌人](../../problems/bomb-enemy) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 354 | [俄罗斯套娃信封问题](../../problems/russian-doll-envelopes) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 351 | [安卓系统手势解锁](../../problems/android-unlock-patterns) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 343 | [整数拆分](../../problems/integer-break) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 322 | [零钱兑换](../../problems/coin-change) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 321 | [拼接最大数](../../problems/create-maximum-number) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 312 | [戳气球](../../problems/burst-balloons) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 309 | [最佳买卖股票时机含冷冻期](../../problems/best-time-to-buy-and-sell-stock-with-cooldown) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 304 | [二维区域和检索 - 矩阵不可变](../../problems/range-sum-query-2d-immutable) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 303 | [区域和检索 - 数组不可变](../../problems/range-sum-query-immutable) | [[动态规划](../dynamic-programming/README.md)] | Easy | -| 300 | [最长上升子序列](../../problems/longest-increasing-subsequence) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 276 | [栅栏涂色](../../problems/paint-fence) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Easy | -| 265 | [粉刷房子 II](../../problems/paint-house-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 256 | [粉刷房子](../../problems/paint-house) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 221 | [最大正方形](../../problems/maximal-square) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 213 | [打家劫舍 II](../../problems/house-robber-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 198 | [打家劫舍](../../problems/house-robber) | [[动态规划](../dynamic-programming/README.md)] | Easy | -| 188 | [买卖股票的最佳时机 IV](../../problems/best-time-to-buy-and-sell-stock-iv) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 174 | [地下城游戏](../../problems/dungeon-game) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 152 | [乘积最大子数组](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 140 | [单词拆分 II](../../problems/word-break-ii) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 139 | [单词拆分](../../problems/word-break) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 132 | [分割回文串 II](../../problems/palindrome-partitioning-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 123 | [买卖股票的最佳时机 III](../../problems/best-time-to-buy-and-sell-stock-iii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 121 | [买卖股票的最佳时机](../../problems/best-time-to-buy-and-sell-stock) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 120 | [三角形最小路径和](../../problems/triangle) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 115 | [不同的子序列](../../problems/distinct-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 91 | [解码方法](../../problems/decode-ways) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 87 | [扰乱字符串](../../problems/scramble-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 72 | [编辑距离](../../problems/edit-distance) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 70 | [爬楼梯](../../problems/climbing-stairs) | [[动态规划](../dynamic-programming/README.md)] | Easy | -| 64 | [最小路径和](../../problems/minimum-path-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 63 | [不同路径 II](../../problems/unique-paths-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 62 | [不同路径](../../problems/unique-paths) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 5 | [最长回文子串](../../problems/longest-palindromic-substring) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1 | [01 背包问题](../../problems/07MoiZ) | [[动态规划](../dynamic-programming/README.md)] | Easy | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index 085448301..5a8521ed2 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -9,12 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard | -| 1515 | [服务中心的最佳位置](../../problems/best-position-for-a-service-centre) | [[几何](../geometry/README.md)] | Hard | -| 1453 | [圆形靶内的最大飞镖数量](../../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | [[几何](../geometry/README.md)] | Hard | -| 1401 | [圆和矩形是否有重叠](../../problems/circle-and-rectangle-overlapping) | [[几何](../geometry/README.md)] | Medium | -| 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] | Easy | -| 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | -| 892 | [三维形体的表面积](../../problems/surface-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | -| 587 | [安装栅栏](../../problems/erect-the-fence) | [[几何](../geometry/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index 1e8098532..0d01c1b08 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,3 +9,51 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1615 | [最大网络秩](../../problems/maximal-network-rank) | [[图](../graph/README.md)] | Medium | +| 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1557 | [可以到达所有点的最少点数目](../../problems/minimum-number-of-vertices-to-reach-all-nodes) | [[图](../graph/README.md)] | Medium | +| 1548 | [图中最相似的路径](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] | Medium | +| 1494 | [并行课程 II](../../problems/parallel-courses-ii) | [[图](../graph/README.md)] | Hard | +| 1462 | [课程安排 IV](../../problems/course-schedule-iv) | [[图](../graph/README.md)] | Medium | +| 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | +| 1361 | [验证二叉树](../../problems/validate-binary-tree-nodes) | [[图](../graph/README.md)] | Medium | +| 1334 | [阈值距离内邻居最少的城市](../../problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | [[图](../graph/README.md)] | Medium | +| 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | +| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1153 | [字符串转化](../../problems/string-transforms-into-another-string) 🔒 | [[图](../graph/README.md)] | Hard | +| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1135 | [最低成本联通所有城市](../../problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 1059 | [从始点到终点的所有路径](../../problems/all-paths-from-source-lead-to-destination) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[图](../graph/README.md)] | Medium | +| 997 | [找到小镇的法官](../../problems/find-the-town-judge) | [[图](../graph/README.md)] | Easy | +| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 990 | [等式方程的可满足性](../../problems/satisfiability-of-equality-equations) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 854 | [相似度为 K 的字符串](../../problems/k-similar-strings) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Hard | +| 841 | [钥匙和房间](../../problems/keys-and-rooms) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 802 | [找到最终的安全状态](../../problems/find-eventual-safe-states) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 684 | [冗余连接](../../problems/redundant-connection) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 444 | [序列重建](../../problems/sequence-reconstruction) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 399 | [除法求值](../../problems/evaluate-division) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 310 | [最小高度树](../../problems/minimum-height-trees) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index c8e90abd2..e76cdd027 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1705 | [吃苹果的最大数目](../../problems/maximum-number-of-eaten-apples) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 1702 | [修改后的最大二进制字符串](../../problems/maximum-binary-string-after-change) | [[贪心算法](../greedy/README.md)] | Medium | | 1689 | [十-二进制数的最少数目](../../problems/partitioning-into-minimum-number-of-deci-binary-numbers) | [[贪心算法](../greedy/README.md)] | Medium | | 1686 | [石子游戏 VI](../../problems/stone-game-vi) | [[贪心算法](../greedy/README.md)] | Medium | | 1685 | [有序数组中差绝对值之和](../../problems/sum-of-absolute-differences-in-a-sorted-array) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 12e3dde8b..f54222616 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -109,7 +109,7 @@ | 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 325 | [和等于 k 的最长子数组长度](../../problems/maximum-size-subarray-sum-equals-k) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | | 311 | [稀疏矩阵的乘法](../../problems/sparse-matrix-multiplication) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/heap/README.md b/tag/heap/README.md index 3eb76f0d0..885e5e859 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1705 | [吃苹果的最大数目](../../problems/maximum-number-of-eaten-apples) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | | 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | | 1642 | [可以到达的最远建筑](../../problems/furthest-building-you-can-reach) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1439 | [有序矩阵中的第 k 个最小数组和](../../problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | [[堆](../heap/README.md)] | Hard | diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md index 592ea3e0f..06c012aa3 100644 --- a/tag/line-sweep/README.md +++ b/tag/line-sweep/README.md @@ -9,3 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[Line Sweep](../line-sweep/README.md)] | Medium | +| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | +| 391 | [完美矩形](../../problems/perfect-rectangle) | [[Line Sweep](../line-sweep/README.md)] | Hard | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index 8642b2274..3f7f71b02 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -9,3 +9,45 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 1669 | [合并两个链表](../../problems/merge-in-between-linked-lists) | [[链表](../linked-list/README.md)] | Medium | +| 1634 | [求两个多项式链表的和](../../problems/add-two-polynomials-represented-as-linked-lists) 🔒 | [[链表](../linked-list/README.md)] | Medium | +| 1474 | [删除链表 M 个节点之后的 N 个节点](../../problems/delete-n-nodes-after-m-nodes-of-a-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Easy | +| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)] | Easy | +| 1171 | [从链表中删去总和值为零的连续节点](../../problems/remove-zero-sum-consecutive-nodes-from-linked-list) | [[链表](../linked-list/README.md)] | Medium | +| 1019 | [链表中的下一个更大节点](../../problems/next-greater-node-in-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 876 | [链表的中间结点](../../problems/middle-of-the-linked-list) | [[链表](../linked-list/README.md)] | Easy | +| 817 | [链表组件](../../problems/linked-list-components) | [[链表](../linked-list/README.md)] | Medium | +| 725 | [分隔链表](../../problems/split-linked-list-in-parts) | [[链表](../linked-list/README.md)] | Medium | +| 708 | [循环有序列表的插入](../../problems/insert-into-a-sorted-circular-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Medium | +| 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 445 | [两数相加 II](../../problems/add-two-numbers-ii) | [[链表](../linked-list/README.md)] | Medium | +| 430 | [扁平化多级双向链表](../../problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 328 | [奇偶链表](../../problems/odd-even-linked-list) | [[链表](../linked-list/README.md)] | Medium | +| 237 | [删除链表中的节点](../../problems/delete-node-in-a-linked-list) | [[链表](../linked-list/README.md)] | Easy | +| 234 | [回文链表](../../problems/palindrome-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 206 | [反转链表](../../problems/reverse-linked-list) | [[链表](../linked-list/README.md)] | Easy | +| 203 | [移除链表元素](../../problems/remove-linked-list-elements) | [[链表](../linked-list/README.md)] | Easy | +| 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[链表](../linked-list/README.md)] | Easy | +| 148 | [排序链表](../../problems/sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 143 | [重排链表](../../problems/reorder-list) | [[链表](../linked-list/README.md)] | Medium | +| 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 141 | [环形链表](../../problems/linked-list-cycle) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 138 | [复制带随机指针的链表](../../problems/copy-list-with-random-pointer) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 92 | [反转链表 II](../../problems/reverse-linked-list-ii) | [[链表](../linked-list/README.md)] | Medium | +| 86 | [分隔链表](../../problems/partition-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 83 | [删除排序链表中的重复元素](../../problems/remove-duplicates-from-sorted-list) | [[链表](../linked-list/README.md)] | Easy | +| 82 | [删除排序链表中的重复元素 II](../../problems/remove-duplicates-from-sorted-list-ii) | [[链表](../linked-list/README.md)] | Medium | +| 61 | [旋转链表](../../problems/rotate-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 25 | [K 个一组翻转链表](../../problems/reverse-nodes-in-k-group) | [[链表](../linked-list/README.md)] | Hard | +| 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[链表](../linked-list/README.md)] | Easy | +| 19 | [删除链表的倒数第N个节点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2 | [两数相加](../../problems/add-two-numbers) | [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 6483efac2..a2c1c456d 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -149,7 +149,7 @@ | 469 | [凸多边形](../../problems/convex-polygon) 🔒 | [[数学](../math/README.md)] | Medium | | 462 | [最少移动次数使数组元素相等 II](../../problems/minimum-moves-to-equal-array-elements-ii) | [[数学](../math/README.md)] | Medium | | 458 | [可怜的小猪](../../problems/poor-pigs) | [[数学](../math/README.md)] | Hard | -| 453 | [最小移动次数使数组元素相等](../../problems/minimum-moves-to-equal-array-elements) | [[数学](../math/README.md)] | Easy | +| 453 | [最小操作次数使数组元素相等](../../problems/minimum-moves-to-equal-array-elements) | [[数学](../math/README.md)] | Easy | | 447 | [回旋镖的数量](../../problems/number-of-boomerangs) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 441 | [排列硬币](../../problems/arranging-coins) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 423 | [从英文中重建数字](../../problems/reconstruct-original-digits-from-english) | [[数学](../math/README.md)] | Medium | diff --git a/tag/minimax/README.md b/tag/minimax/README.md index 0cf0739a7..dd3b3951d 100644 --- a/tag/minimax/README.md +++ b/tag/minimax/README.md @@ -9,11 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[极小化极大](../minimax/README.md)] | Hard | -| 877 | [石子游戏](../../problems/stone-game) | [[极小化极大](../minimax/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 843 | [猜猜这个单词](../../problems/guess-the-word) | [[极小化极大](../minimax/README.md)] | Hard | -| 486 | [预测赢家](../../problems/predict-the-winner) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 464 | [我能赢吗](../../problems/can-i-win) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 375 | [猜数字大小 II](../../problems/guess-number-higher-or-lower-ii) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 294 | [翻转游戏 II](../../problems/flip-game-ii) 🔒 | [[极小化极大](../minimax/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 292 | [Nim 游戏](../../problems/nim-game) | [[脑筋急转弯](../brainteaser/README.md)] [[极小化极大](../minimax/README.md)] | Easy | diff --git a/tag/queue/README.md b/tag/queue/README.md index 16db88027..8922feba8 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -9,12 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 933 | [最近的请求次数](../../problems/number-of-recent-calls) | [[队列](../queue/README.md)] | Easy | -| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | -| 582 | [杀死进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | -| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | diff --git a/tag/random/README.md b/tag/random/README.md index 72a82d98f..25144cd0a 100644 --- a/tag/random/README.md +++ b/tag/random/README.md @@ -9,3 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | +| 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | +| 519 | [随机翻转矩阵](../../problems/random-flip-matrix) | [[Random](../random/README.md)] | Medium | +| 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | +| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | +| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index f99d827a5..044d10bbf 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -11,6 +11,7 @@ | :-: | - | - | :-: | | 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | | 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[递归](../recursion/README.md)] | Easy | +| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | @@ -30,6 +31,9 @@ | 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | | 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | | 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | +| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | | 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/reservoir-sampling/README.md b/tag/reservoir-sampling/README.md index 7d9ca74cc..1fc516eb3 100644 --- a/tag/reservoir-sampling/README.md +++ b/tag/reservoir-sampling/README.md @@ -9,3 +9,5 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 398 | [随机数索引](../../problems/random-pick-index) | [[蓄水池抽样](../reservoir-sampling/README.md)] | Medium | +| 382 | [链表随机节点](../../problems/linked-list-random-node) | [[蓄水池抽样](../reservoir-sampling/README.md)] | Medium | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index d01d133ef..101291dc2 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -30,7 +30,7 @@ | 480 | [滑动窗口中位数](../../problems/sliding-window-median) | [[Sliding Window](../sliding-window/README.md)] | Hard | | 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 395 | [至少有K个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | diff --git a/tag/sort/README.md b/tag/sort/README.md index 8532603a2..49e4c7112 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,74 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1691 | [堆叠长方体的最大高度](../../problems/maximum-height-by-stacking-cuboids) | [[排序](../sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | -| 1647 | [字符频次唯一的最小删除次数](../../problems/minimum-deletions-to-make-character-frequencies-unique) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1637 | [两点之间不包含任何点的最宽垂直面积](../../problems/widest-vertical-area-between-two-points-containing-no-points) | [[排序](../sort/README.md)] | Medium | -| 1636 | [按照频率将数组升序排序](../../problems/sort-array-by-increasing-frequency) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1630 | [等差子数组](../../problems/arithmetic-subarrays) | [[排序](../sort/README.md)] | Medium | -| 1561 | [你可以获得的最大硬币数目](../../problems/maximum-number-of-coins-you-can-get) | [[排序](../sort/README.md)] | Medium | -| 1528 | [重新排列字符串](../../problems/shuffle-string) | [[排序](../sort/README.md)] | Easy | -| 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1502 | [判断能否形成等差数列](../../problems/can-make-arithmetic-progression-from-sequence) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[排序](../sort/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1491 | [去掉最低工资和最高工资后的工资平均值](../../problems/average-salary-excluding-the-minimum-and-maximum-salary) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1481 | [不同整数的最少数目](../../problems/least-number-of-unique-integers-after-k-removals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1471 | [数组中的 k 个最强值](../../problems/the-k-strongest-values-in-an-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | -| 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | -| 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Hard | -| 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | -| 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[排序](../sort/README.md)] [[位运算](../bit-manipulation/README.md)] | Easy | -| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | -| 1333 | [餐厅过滤器](../../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1329 | [将矩阵按对角线排序](../../problems/sort-the-matrix-diagonally) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[排序](../sort/README.md)] [[树](../tree/README.md)] | Medium | -| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1183 | [矩阵中 1 的最大数量](../../problems/maximum-number-of-ones) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | -| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1122 | [数组的相对排序](../../problems/relative-sort-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1057 | [校园自行车分配](../../problems/campus-bikes) 🔒 | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] | Medium | -| 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[排序](../sort/README.md)] | Easy | -| 976 | [三角形的最大周长](../../problems/largest-perimeter-triangle) | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Easy | -| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 969 | [煎饼排序](../../problems/pancake-sorting) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 922 | [按奇偶排序数组 II](../../problems/sort-array-by-parity-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 853 | [车队](../../problems/car-fleet) | [[排序](../sort/README.md)] | Medium | -| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | -| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Hard | -| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 324 | [摆动排序 II](../../problems/wiggle-sort-ii) | [[排序](../sort/README.md)] | Medium | -| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | -| 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 274 | [H 指数](../../problems/h-index) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 252 | [会议室](../../problems/meeting-rooms) 🔒 | [[排序](../sort/README.md)] | Easy | -| 242 | [有效的字母异位词](../../problems/valid-anagram) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | -| 179 | [最大数](../../problems/largest-number) | [[排序](../sort/README.md)] | Medium | -| 164 | [最大间距](../../problems/maximum-gap) | [[排序](../sort/README.md)] | Hard | -| 148 | [排序链表](../../problems/sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 57 | [插入区间](../../problems/insert-interval) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Hard | -| 56 | [合并区间](../../problems/merge-intervals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/stack/README.md b/tag/stack/README.md index e3cdc14db..9aabcd33e 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1703 | [得到连续 K 个 1 的最少相邻交换次数](../../problems/minimum-adjacent-swaps-for-k-consecutive-ones) | [[栈](../stack/README.md)] | Hard | | 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | | 1598 | [文件夹操作日志搜集器](../../problems/crawler-log-folder) | [[栈](../stack/README.md)] | Easy | | 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | @@ -65,7 +66,7 @@ | 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] | Medium | | 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | | 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | -| 103 | [二叉树的锯齿形层次遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 84 | [柱状图中最大的矩形](../../problems/largest-rectangle-in-histogram) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Hard | diff --git a/tag/string/README.md b/tag/string/README.md index 47dcec77c..dabd214b3 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,213 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1684 | [统计一致字符串的数目](../../problems/count-the-number-of-consistent-strings) | [[字符串](../string/README.md)] | Easy | -| 1682 | [Longest Palindromic Subsequence II](../../problems/longest-palindromic-subsequence-ii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1678 | [设计 Goal 解析器](../../problems/goal-parser-interpretation) | [[字符串](../string/README.md)] | Easy | -| 1668 | [最大重复子字符串](../../problems/maximum-repeating-substring) | [[字符串](../string/README.md)] | Easy | -| 1662 | [检查两个字符串数组是否相等](../../problems/check-if-two-string-arrays-are-equivalent) | [[字符串](../string/README.md)] | Easy | -| 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1624 | [两个相同字符之间的最长子字符串](../../problems/largest-substring-between-two-equal-characters) | [[字符串](../string/README.md)] | Easy | -| 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1614 | [括号的最大嵌套深度](../../problems/maximum-nesting-depth-of-the-parentheses) | [[字符串](../string/README.md)] | Easy | -| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | -| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Hard | -| 1592 | [重新排列单词间的空格](../../problems/rearrange-spaces-between-words) | [[字符串](../string/README.md)] | Easy | -| 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | -| 1576 | [替换所有的问号](../../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | [[字符串](../string/README.md)] | Easy | -| 1573 | [分割字符串的方案数](../../problems/number-of-ways-to-split-a-string) | [[字符串](../string/README.md)] | Medium | -| 1556 | [千位分隔数](../../problems/thousand-separator) | [[字符串](../string/README.md)] | Easy | -| 1545 | [找出第 N 个二进制字符串中的第 K 位](../../problems/find-kth-bit-in-nth-binary-string) | [[字符串](../string/README.md)] | Medium | -| 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | -| 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Hard | -| 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[字符串](../string/README.md)] | Medium | -| 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1513 | [仅含 1 的子串数](../../problems/number-of-substrings-with-only-1s) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 1507 | [转变日期格式](../../problems/reformat-date) | [[字符串](../string/README.md)] | Easy | -| 1496 | [判断路径是否相交](../../problems/path-crossing) | [[字符串](../string/README.md)] | Easy | -| 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1455 | [检查单词是否为句中其他单词的前缀](../../problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | [[字符串](../string/README.md)] | Easy | -| 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1446 | [连续字符](../../problems/consecutive-characters) | [[字符串](../string/README.md)] | Easy | -| 1436 | [旅行终点站](../../problems/destination-city) | [[字符串](../string/README.md)] | Easy | -| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1432 | [改变一个整数能得到的最大差值](../../problems/max-difference-you-can-get-from-changing-an-integer) | [[字符串](../string/README.md)] | Medium | -| 1422 | [分割字符串的最大得分](../../problems/maximum-score-after-splitting-a-string) | [[字符串](../string/README.md)] | Easy | -| 1419 | [数青蛙](../../problems/minimum-number-of-frogs-croaking) | [[字符串](../string/README.md)] | Medium | -| 1417 | [重新格式化字符串](../../problems/reformat-the-string) | [[字符串](../string/README.md)] | Easy | -| 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1408 | [数组中的字符串匹配](../../problems/string-matching-in-an-array) | [[字符串](../string/README.md)] | Easy | -| 1404 | [将二进制表示减到 1 的步骤数](../../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1392 | [最长快乐前缀](../../problems/longest-happy-prefix) | [[字符串](../string/README.md)] | Hard | -| 1374 | [生成每种字符都是奇数个的字符串](../../problems/generate-a-string-with-characters-that-have-odd-counts) | [[字符串](../string/README.md)] | Easy | -| 1371 | [每个元音包含偶数次的最长子字符串](../../problems/find-the-longest-substring-containing-vowels-in-even-counts) | [[字符串](../string/README.md)] | Medium | -| 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | -| 1358 | [包含所有三种字符的子字符串数目](../../problems/number-of-substrings-containing-all-three-characters) | [[字符串](../string/README.md)] | Medium | -| 1347 | [制造字母异位词的最小步骤数](../../problems/minimum-number-of-steps-to-make-two-strings-anagram) | [[字符串](../string/README.md)] | Medium | -| 1332 | [删除回文子序列](../../problems/remove-palindromic-subsequences) | [[字符串](../string/README.md)] | Easy | -| 1328 | [破坏回文串](../../problems/break-a-palindrome) | [[字符串](../string/README.md)] | Medium | -| 1324 | [竖直打印单词](../../problems/print-words-vertically) | [[字符串](../string/README.md)] | Medium | -| 1316 | [不同的循环子字符串](../../problems/distinct-echo-substrings) | [[字符串](../string/README.md)] | Hard | -| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1309 | [解码字母到整数映射](../../problems/decrypt-string-from-alphabet-to-integer-mapping) | [[字符串](../string/README.md)] | Easy | -| 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1271 | [十六进制魔术数字](../../problems/hexspeak) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 1268 | [搜索推荐系统](../../problems/search-suggestions-system) | [[字符串](../string/README.md)] | Medium | -| 1249 | [移除无效的括号](../../problems/minimum-remove-to-make-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1247 | [交换字符使得字符串相同](../../problems/minimum-swaps-to-make-strings-equal) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1233 | [删除子文件夹](../../problems/remove-sub-folders-from-the-filesystem) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | -| 1221 | [分割平衡字符串](../../problems/split-a-string-in-balanced-strings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | -| 1216 | [验证回文字符串 III](../../problems/valid-palindrome-iii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1189 | [“气球” 的最大数量](../../problems/maximum-number-of-balloons) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 1181 | [前后拼接](../../problems/before-and-after-puzzle) 🔒 | [[字符串](../string/README.md)] | Medium | -| 1180 | [统计只含单一字母的子串](../../problems/count-substrings-with-only-one-distinct-letter) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 1177 | [构建回文串检测](../../problems/can-make-palindrome-from-substring) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | -| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | -| 1169 | [查询无效交易](../../problems/invalid-transactions) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | -| 1165 | [单行键盘](../../problems/single-row-keyboard) 🔒 | [[字符串](../string/README.md)] | Easy | -| 1163 | [按字典序排在最后的子串](../../problems/last-substring-in-lexicographical-order) | [[字符串](../string/README.md)] | Hard | -| 1156 | [单字符重复子串的最大长度](../../problems/swap-for-longest-repeated-character-substring) | [[字符串](../string/README.md)] | Medium | -| 1138 | [字母板上的路径](../../problems/alphabet-board-path) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1119 | [删去字符串中的元音](../../problems/remove-vowels-from-a-string) 🔒 | [[字符串](../string/README.md)] | Easy | -| 1108 | [IP 地址无效化](../../problems/defanging-an-ip-address) | [[字符串](../string/README.md)] | Easy | -| 1106 | [解析布尔表达式](../../problems/parsing-a-boolean-expression) | [[字符串](../string/README.md)] | Hard | -| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1096 | [花括号展开 II](../../problems/brace-expansion-ii) | [[字符串](../string/README.md)] | Hard | -| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1071 | [字符串的最大公因子](../../problems/greatest-common-divisor-of-strings) | [[字符串](../string/README.md)] | Easy | -| 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Easy | -| 1062 | [最长重复子串](../../problems/longest-repeating-substring) 🔒 | [[字符串](../string/README.md)] | Medium | -| 1023 | [驼峰式匹配](../../problems/camelcase-matching) | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | -| 1016 | [子串能表示从 1 到 N 数字的二进制串](../../problems/binary-string-with-substrings-representing-1-to-n) | [[字符串](../string/README.md)] | Medium | -| 1003 | [检查替换后的词是否有效](../../problems/check-if-word-is-valid-after-substitutions) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 937 | [重新排列日志文件](../../problems/reorder-data-in-log-files) | [[字符串](../string/README.md)] | Easy | -| 936 | [戳印序列](../../problems/stamping-the-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | -| 929 | [独特的电子邮件地址](../../problems/unique-email-addresses) | [[字符串](../string/README.md)] | Easy | -| 925 | [长按键入](../../problems/long-pressed-name) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 917 | [仅仅反转字母](../../problems/reverse-only-letters) | [[字符串](../string/README.md)] | Easy | -| 916 | [单词子集](../../problems/word-subsets) | [[字符串](../string/README.md)] | Medium | -| 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[字符串](../string/README.md)] | Easy | -| 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[字符串](../string/README.md)] | Medium | -| 859 | [亲密字符串](../../problems/buddy-strings) | [[字符串](../string/README.md)] | Easy | -| 856 | [括号的分数](../../problems/score-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 848 | [字母移位](../../problems/shifting-letters) | [[字符串](../string/README.md)] | Medium | -| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 833 | [字符串中的查找与替换](../../problems/find-and-replace-in-string) | [[字符串](../string/README.md)] | Medium | -| 831 | [隐藏个人信息](../../problems/masking-personal-information) | [[字符串](../string/README.md)] | Medium | -| 824 | [山羊拉丁文](../../problems/goat-latin) | [[字符串](../string/README.md)] | Easy | -| 819 | [最常见的单词](../../problems/most-common-word) | [[字符串](../string/README.md)] | Easy | -| 816 | [模糊坐标](../../problems/ambiguous-coordinates) | [[字符串](../string/README.md)] | Medium | -| 809 | [情感丰富的文字](../../problems/expressive-words) | [[字符串](../string/README.md)] | Medium | -| 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[字符串](../string/README.md)] | Easy | -| 800 | [相似 RGB 颜色](../../problems/similar-rgb-color) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 791 | [自定义字符串排序](../../problems/custom-sort-string) | [[字符串](../string/README.md)] | Medium | -| 788 | [旋转数字](../../problems/rotated-digits) | [[字符串](../string/README.md)] | Easy | -| 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | -| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | -| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | -| 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字符串](../string/README.md)] | Easy | -| 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[字符串](../string/README.md)] | Hard | -| 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 722 | [删除注释](../../problems/remove-comments) | [[字符串](../string/README.md)] | Medium | -| 709 | [转换成小写字母](../../problems/to-lower-case) | [[字符串](../string/README.md)] | Easy | -| 696 | [计数二进制子串](../../problems/count-binary-substrings) | [[字符串](../string/README.md)] | Easy | -| 686 | [重复叠加字符串匹配](../../problems/repeated-string-match) | [[字符串](../string/README.md)] | Medium | -| 681 | [最近时刻](../../problems/next-closest-time) 🔒 | [[字符串](../string/README.md)] | Medium | -| 680 | [验证回文字符串 Ⅱ](../../problems/valid-palindrome-ii) | [[字符串](../string/README.md)] | Easy | -| 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[字符串](../string/README.md)] | Medium | -| 657 | [机器人能否返回原点](../../problems/robot-return-to-origin) | [[字符串](../string/README.md)] | Easy | -| 647 | [回文子串](../../problems/palindromic-substrings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | -| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 616 | [给字符串添加加粗标签](../../problems/add-bold-tag-in-string) 🔒 | [[字符串](../string/README.md)] | Medium | -| 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 606 | [根据二叉树创建字符串](../../problems/construct-string-from-binary-tree) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Easy | -| 591 | [标签验证器](../../problems/tag-validator) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | -| 583 | [两个字符串的删除操作](../../problems/delete-operation-for-two-strings) | [[字符串](../string/README.md)] | Medium | -| 564 | [寻找最近的回文数](../../problems/find-the-closest-palindrome) | [[字符串](../string/README.md)] | Hard | -| 557 | [反转字符串中的单词 III](../../problems/reverse-words-in-a-string-iii) | [[字符串](../string/README.md)] | Easy | -| 556 | [下一个更大元素 III](../../problems/next-greater-element-iii) | [[字符串](../string/README.md)] | Medium | -| 555 | [分割连接字符串](../../problems/split-concatenated-strings) 🔒 | [[字符串](../string/README.md)] | Medium | -| 553 | [最优除法](../../problems/optimal-division) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 551 | [学生出勤记录 I](../../problems/student-attendance-record-i) | [[字符串](../string/README.md)] | Easy | -| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | -| 541 | [反转字符串 II](../../problems/reverse-string-ii) | [[字符串](../string/README.md)] | Easy | -| 539 | [最小时间差](../../problems/minimum-time-difference) | [[字符串](../string/README.md)] | Medium | -| 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | -| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Hard | -| 522 | [最长特殊序列 II](../../problems/longest-uncommon-subsequence-ii) | [[字符串](../string/README.md)] | Medium | -| 521 | [最长特殊序列 Ⅰ](../../problems/longest-uncommon-subsequence-i) | [[脑筋急转弯](../brainteaser/README.md)] [[字符串](../string/README.md)] | Easy | -| 520 | [检测大写字母](../../problems/detect-capital) | [[字符串](../string/README.md)] | Easy | -| 468 | [验证IP地址](../../problems/validate-ip-address) | [[字符串](../string/README.md)] | Medium | -| 459 | [重复的子字符串](../../problems/repeated-substring-pattern) | [[字符串](../string/README.md)] | Easy | -| 443 | [压缩字符串](../../problems/string-compression) | [[字符串](../string/README.md)] | Medium | -| 434 | [字符串中的单词数](../../problems/number-of-segments-in-a-string) | [[字符串](../string/README.md)] | Easy | -| 415 | [字符串相加](../../problems/add-strings) | [[字符串](../string/README.md)] | Easy | -| 408 | [有效单词缩写](../../problems/valid-word-abbreviation) 🔒 | [[字符串](../string/README.md)] | Easy | -| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 385 | [迷你语法分析器](../../problems/mini-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 383 | [赎金信](../../problems/ransom-note) | [[字符串](../string/README.md)] | Easy | -| 345 | [反转字符串中的元音字母](../../problems/reverse-vowels-of-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 344 | [反转字符串](../../problems/reverse-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | -| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 293 | [翻转游戏](../../problems/flip-game) 🔒 | [[字符串](../string/README.md)] | Easy | -| 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 271 | [字符串的编码与解码](../../problems/encode-and-decode-strings) 🔒 | [[字符串](../string/README.md)] | Medium | -| 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 214 | [最短回文串](../../problems/shortest-palindrome) | [[字符串](../string/README.md)] | Hard | -| 186 | [翻转字符串里的单词 II](../../problems/reverse-words-in-a-string-ii) 🔒 | [[字符串](../string/README.md)] | Medium | -| 165 | [比较版本号](../../problems/compare-version-numbers) | [[字符串](../string/README.md)] | Medium | -| 161 | [相隔为 1 的编辑距离](../../problems/one-edit-distance) 🔒 | [[字符串](../string/README.md)] | Medium | -| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 158 | [用 Read4 读取 N 个字符 II](../../problems/read-n-characters-given-read4-ii-call-multiple-times) 🔒 | [[字符串](../string/README.md)] | Hard | -| 157 | [用 Read4 读取 N 个字符](../../problems/read-n-characters-given-read4) 🔒 | [[字符串](../string/README.md)] | Easy | -| 151 | [翻转字符串里的单词](../../problems/reverse-words-in-a-string) | [[字符串](../string/README.md)] | Medium | -| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 125 | [验证回文串](../../problems/valid-palindrome) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 115 | [不同的子序列](../../problems/distinct-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 93 | [复原IP地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 91 | [解码方法](../../problems/decode-ways) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 87 | [扰乱字符串](../../problems/scramble-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 72 | [编辑距离](../../problems/edit-distance) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 71 | [简化路径](../../problems/simplify-path) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 68 | [文本左右对齐](../../problems/text-justification) | [[字符串](../string/README.md)] | Hard | -| 67 | [二进制求和](../../problems/add-binary) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 65 | [有效数字](../../problems/valid-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 58 | [最后一个单词的长度](../../problems/length-of-last-word) | [[字符串](../string/README.md)] | Easy | -| 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 38 | [外观数列](../../problems/count-and-say) | [[字符串](../string/README.md)] | Easy | -| 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 20 | [有效的括号](../../problems/valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | -| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 14 | [最长公共前缀](../../problems/longest-common-prefix) | [[字符串](../string/README.md)] | Easy | -| 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 8 | [字符串转换整数 (atoi)](../../problems/string-to-integer-atoi) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 6 | [Z 字形变换](../../problems/zigzag-conversion) | [[字符串](../string/README.md)] | Medium | -| 5 | [最长回文子串](../../problems/longest-palindromic-substring) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/tags.json b/tag/tags.json index 820b1f6b7..dd04f1731 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -99,16 +99,16 @@ "Slug": "union-find", "TranslatedName": "并查集" }, - { - "Name": "Sliding Window", - "Slug": "sliding-window", - "TranslatedName": "Sliding Window" - }, { "Name": "Recursion", "Slug": "recursion", "TranslatedName": "递归" }, + { + "Name": "Sliding Window", + "Slug": "sliding-window", + "TranslatedName": "Sliding Window" + }, { "Name": "Divide and Conquer", "Slug": "divide-and-conquer", @@ -184,6 +184,11 @@ "Slug": "rolling-hash", "TranslatedName": "Rolling Hash" }, + { + "Name": "Suffix Array", + "Slug": "suffix-array", + "TranslatedName": "Suffix Array" + }, { "Name": "Rejection Sampling", "Slug": "rejection-sampling", @@ -194,11 +199,6 @@ "Slug": "reservoir-sampling", "TranslatedName": "蓄水池抽样" }, - { - "Name": "Suffix Array", - "Slug": "suffix-array", - "TranslatedName": "Suffix Array" - }, { "Name": "Memoization", "Slug": "memoization", diff --git a/tag/tree/README.md b/tag/tree/README.md index 10c1417de..0dd6cb631 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -141,20 +141,20 @@ | 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | | 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | | 129 | [求根到叶子节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | | 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 107 | [二叉树的层次遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 103 | [二叉树的锯齿形层次遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 102 | [二叉树的层序遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 100 | [相同的树](../../problems/same-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | diff --git a/tag/trie/README.md b/tag/trie/README.md index b819271ee..a008b2d35 100644 --- a/tag/trie/README.md +++ b/tag/trie/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1707 | [与数组中元素的最大异或值](../../problems/maximum-xor-with-an-element-from-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Hard | | 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Easy | | 1032 | [字符流](../../problems/stream-of-characters) | [[字典树](../trie/README.md)] | Hard | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 1cd23c4b5..bbccc6652 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1695 | [删除子数组的最大得分](../../problems/maximum-erasure-value) | [[双指针](../two-pointers/README.md)] | Medium | | 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | @@ -49,6 +50,7 @@ | 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 345 | [反转字符串中的元音字母](../../problems/reverse-vowels-of-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 344 | [反转字符串](../../problems/reverse-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index 1fc59b219..e84ea907e 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -9,38 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] | Hard | -| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1627 | [带阈值的图连通性](../../problems/graph-connectivity-with-threshold) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | -| 1584 | [连接所有点的最小费用](../../problems/min-cost-to-connect-all-points) | [[并查集](../union-find/README.md)] | Medium | -| 1579 | [保证图可完全遍历](../../problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | [[并查集](../union-find/README.md)] | Hard | -| 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | -| 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | -| 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 1135 | [最低成本联通所有城市](../../problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 1101 | [彼此熟识的最早时间](../../problems/the-earliest-moment-when-everyone-become-friends) 🔒 | [[并查集](../union-find/README.md)] | Medium | -| 1061 | [按字典序排列最小的等效字符串](../../problems/lexicographically-smallest-equivalent-string) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 990 | [等式方程的可满足性](../../problems/satisfiability-of-equality-equations) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 952 | [按公因数计算最大组件大小](../../problems/largest-component-size-by-common-factor) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | -| 947 | [移除最多的同行或同列石头](../../problems/most-stones-removed-with-same-row-or-column) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 924 | [尽量减少恶意软件的传播](../../problems/minimize-malware-spread) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | -| 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 803 | [打砖块](../../problems/bricks-falling-when-hit) | [[并查集](../union-find/README.md)] | Hard | -| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 721 | [账户合并](../../problems/accounts-merge) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 684 | [冗余连接](../../problems/redundant-connection) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 547 | [朋友圈](../../problems/friend-circles) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 399 | [除法求值](../../problems/evaluate-division) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 305 | [岛屿数量 II](../../problems/number-of-islands-ii) 🔒 | [[并查集](../union-find/README.md)] | Hard | -| 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 128 | [最长连续序列](../../problems/longest-consecutive-sequence) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Hard | From 6cc9b8efcaa12bb6e58055c0a9d0fb66daf259f9 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 11 Jan 2021 09:21:45 +0800 Subject: [PATCH 116/145] A: new --- README.md | 28 +- problems/3sum-with-multiplicity/README.md | 16 +- problems/add-two-numbers/README.md | 1 + problems/avoid-flood-in-the-city/README.md | 4 +- problems/beautiful-arrangement/README.md | 54 ++-- .../README.md | 2 +- .../biggest-window-between-visits/README.md | 14 + .../mysql_schemas.sql | 8 + .../binary-tree-maximum-path-sum/README.md | 4 +- .../README.md | 60 +++++ .../README.md | 1 + .../README.md | 59 +++++ problems/container-with-most-water/README.md | 2 +- problems/count-apples-and-oranges/README.md | 14 + .../mysql_schemas.sql | 16 ++ problems/count-good-meals/README.md | 61 +++++ .../README.md | 7 +- .../README.md | 2 +- .../README.md | 1 + problems/daily-leads-and-partners/README.md | 2 +- problems/decode-ways/README.md | 19 +- problems/decode-xored-array/README.md | 60 +++++ .../README.md | 3 + .../README.md | 55 ++++ problems/find-the-duplicate-number/README.md | 21 +- .../README.md | 23 +- .../README.md | 2 +- problems/fix-names-in-a-table/README.md | 2 +- problems/frog-jump/README.md | 50 ++-- problems/game-of-life/README.md | 10 +- problems/gas-station/README.md | 45 ++-- problems/gray-code/README.md | 42 +-- problems/isomorphic-strings/README.md | 40 ++- problems/jump-game-iv/README.md | 4 +- problems/largest-divisible-subset/README.md | 32 ++- .../largest-rectangle-in-histogram/README.md | 25 ++ problems/largest-subarray-length-k/README.md | 29 +++ .../README.md | 24 +- problems/linked-list-in-binary-tree/README.md | 6 +- .../README.md | 48 ++-- .../README.md | 2 +- .../README.md | 2 +- problems/majority-element/README.md | 29 ++- .../maximum-average-subarray-ii/README.md | 2 +- problems/maximum-binary-tree/README.md | 20 +- .../README.md | 72 ++++++ problems/maximum-subarray/README.md | 15 +- problems/maximum-units-on-a-truck/README.md | 73 ++++++ .../README.md | 2 +- problems/merge-sorted-array/README.md | 29 +-- problems/merge-two-sorted-lists/README.md | 3 +- .../README.md | 80 ++++++ problems/minimize-malware-spread/README.md | 56 ++-- .../README.md | 64 +++++ .../README.md | 23 +- problems/my-calendar-iii/README.md | 51 ++-- problems/nth-digit/README.md | 2 +- .../README.md | 2 +- .../README.md | 3 +- problems/number-of-provinces/README.md | 58 +++++ .../README.md | 99 +++++++ problems/partition-list/README.md | 27 +- problems/profitable-schemes/README.md | 51 ++-- .../README.md | 4 +- .../queens-that-can-attack-the-king/README.md | 4 +- problems/remove-boxes/README.md | 24 +- .../README.md | 26 +- .../README.md | 24 +- .../README.md | 24 +- problems/reverse-integer/README.md | 5 +- problems/robot-return-to-origin/README.md | 2 +- problems/rotting-oranges/README.md | 53 ++-- .../README.md | 33 +-- .../search-in-rotated-sorted-array/README.md | 8 +- problems/sentence-similarity-ii/README.md | 2 +- problems/sentence-similarity/README.md | 2 +- .../README.md | 8 +- problems/split-array-with-equal-sum/README.md | 2 +- problems/squares-of-a-sorted-array/README.md | 5 +- problems/subsets/README.md | 1 + .../README.md | 30 +++ problems/super-palindromes/README.md | 39 +-- problems/surface-area-of-3d-shapes/README.md | 63 ++--- problems/swap-nodes-in-pairs/README.md | 5 +- .../swapping-nodes-in-a-linked-list/README.md | 75 ++++++ .../README.md | 2 +- problems/third-maximum-number/README.md | 48 ++-- problems/triangle/README.md | 9 +- problems/verbal-arithmetic-puzzle/README.md | 6 +- .../README.md | 56 ++-- problems/walking-robot-simulation/README.md | 44 ++-- .../README.md | 75 ++++++ problems/where-will-the-ball-fall/README.md | 7 + problems/wiggle-sort-ii/README.md | 34 ++- readme/301-600.md | 4 +- readme/601-900.md | 2 +- tag/array/README.md | 6 +- tag/backtracking/README.md | 4 +- tag/binary-indexed-tree/README.md | 7 - tag/binary-search-tree/README.md | 4 - tag/binary-search/README.md | 4 +- tag/bit-manipulation/README.md | 1 + tag/breadth-first-search/README.md | 1 + tag/depth-first-search/README.md | 7 +- tag/dynamic-programming/README.md | 241 ++++++++++++++++++ tag/geometry/README.md | 9 + tag/graph/README.md | 1 + tag/greedy/README.md | 6 + tag/hash-table/README.md | 2 + tag/line-sweep/README.md | 6 - tag/linked-list/README.md | 5 +- tag/math/README.md | 5 +- tag/memoization/README.md | 1 - tag/minimax/README.md | 8 + tag/ordered-map/README.md | 2 +- tag/queue/README.md | 9 + tag/random/README.md | 6 - tag/recursion/README.md | 5 + tag/rejection-sampling/README.md | 2 - tag/reservoir-sampling/README.md | 2 - tag/segment-tree/README.md | 2 +- tag/sort/README.md | 73 ++++++ tag/string/README.md | 213 ++++++++++++++++ tag/tree/README.md | 5 +- tag/trie/README.md | 1 + tag/two-pointers/README.md | 2 + tag/union-find/README.md | 37 +++ 127 files changed, 2388 insertions(+), 676 deletions(-) create mode 100644 problems/biggest-window-between-visits/README.md create mode 100644 problems/biggest-window-between-visits/mysql_schemas.sql create mode 100644 problems/calculate-money-in-leetcode-bank/README.md create mode 100644 problems/construct-the-lexicographically-largest-valid-sequence/README.md create mode 100644 problems/count-apples-and-oranges/README.md create mode 100644 problems/count-apples-and-oranges/mysql_schemas.sql create mode 100644 problems/count-good-meals/README.md create mode 100644 problems/decode-xored-array/README.md create mode 100644 problems/find-minimum-time-to-finish-all-jobs/README.md create mode 100644 problems/largest-subarray-length-k/README.md create mode 100644 problems/maximum-score-from-removing-substrings/README.md create mode 100644 problems/maximum-units-on-a-truck/README.md create mode 100644 problems/minimize-hamming-distance-after-swap-operations/README.md create mode 100644 problems/minimum-operations-to-make-a-subsequence/README.md create mode 100644 problems/number-of-provinces/README.md create mode 100644 problems/number-of-ways-to-reconstruct-a-tree/README.md create mode 100644 problems/sum-of-special-evenly-spaced-elements-in-array/README.md create mode 100644 problems/swapping-nodes-in-a-linked-list/README.md create mode 100644 problems/ways-to-split-array-into-three-subarrays/README.md diff --git a/README.md b/README.md index 2b3e02071..f6db8115f 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,22 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1723 | [Find Minimum Time to Finish All Jobs](https://leetcode.com/problems/find-minimum-time-to-finish-all-jobs "完成所有工作的最短时间") | [Go](problems/find-minimum-time-to-finish-all-jobs) | Hard | +| 1722 | [Minimize Hamming Distance After Swap Operations](https://leetcode.com/problems/minimize-hamming-distance-after-swap-operations "执行交换操作后的最小汉明距离") | [Go](problems/minimize-hamming-distance-after-swap-operations) | Medium | +| 1721 | [Swapping Nodes in a Linked List](https://leetcode.com/problems/swapping-nodes-in-a-linked-list "交换链表中的节点") | [Go](problems/swapping-nodes-in-a-linked-list) | Medium | +| 1720 | [Decode XORed Array](https://leetcode.com/problems/decode-xored-array "解码异或后的数组") | [Go](problems/decode-xored-array) | Easy | +| 1719 | [Number Of Ways To Reconstruct A Tree](https://leetcode.com/problems/number-of-ways-to-reconstruct-a-tree "重构一棵树的方案数") | [Go](problems/number-of-ways-to-reconstruct-a-tree) | Hard | +| 1718 | [Construct the Lexicographically Largest Valid Sequence](https://leetcode.com/problems/construct-the-lexicographically-largest-valid-sequence "构建字典序最大的可行序列") | [Go](problems/construct-the-lexicographically-largest-valid-sequence) | Medium | +| 1717 | [Maximum Score From Removing Substrings](https://leetcode.com/problems/maximum-score-from-removing-substrings "删除子字符串的最大得分") | [Go](problems/maximum-score-from-removing-substrings) | Medium | +| 1716 | [Calculate Money in Leetcode Bank](https://leetcode.com/problems/calculate-money-in-leetcode-bank "计算力扣银行的钱") | [Go](problems/calculate-money-in-leetcode-bank) | Easy | +| 1715 | [Count Apples and Oranges](https://leetcode.com/problems/count-apples-and-oranges) 🔒 | [MySQL](problems/count-apples-and-oranges) | Medium | +| 1714 | [Sum Of Special Evenly-Spaced Elements In Array](https://leetcode.com/problems/sum-of-special-evenly-spaced-elements-in-array) 🔒 | [Go](problems/sum-of-special-evenly-spaced-elements-in-array) | Hard | +| 1713 | [Minimum Operations to Make a Subsequence](https://leetcode.com/problems/minimum-operations-to-make-a-subsequence "得到子序列的最少操作次数") | [Go](problems/minimum-operations-to-make-a-subsequence) | Hard | +| 1712 | [Ways to Split Array Into Three Subarrays](https://leetcode.com/problems/ways-to-split-array-into-three-subarrays "将数组分成三个子数组的方案数") | [Go](problems/ways-to-split-array-into-three-subarrays) | Medium | +| 1711 | [Count Good Meals](https://leetcode.com/problems/count-good-meals "大餐计数") | [Go](problems/count-good-meals) | Medium | +| 1710 | [Maximum Units on a Truck](https://leetcode.com/problems/maximum-units-on-a-truck "卡车上的最大单元数") | [Go](problems/maximum-units-on-a-truck) | Easy | +| 1709 | [Biggest Window Between Visits](https://leetcode.com/problems/biggest-window-between-visits) 🔒 | [MySQL](problems/biggest-window-between-visits) | Medium | +| 1708 | [Largest Subarray Length K](https://leetcode.com/problems/largest-subarray-length-k) 🔒 | [Go](problems/largest-subarray-length-k) | Easy | | 1707 | [Maximum XOR With an Element From Array](https://leetcode.com/problems/maximum-xor-with-an-element-from-array "与数组中元素的最大异或值") | [Go](problems/maximum-xor-with-an-element-from-array) | Hard | | 1706 | [Where Will the Ball Fall](https://leetcode.com/problems/where-will-the-ball-fall "球会落何处") | [Go](problems/where-will-the-ball-fall) | Medium | | 1705 | [Maximum Number of Eaten Apples](https://leetcode.com/problems/maximum-number-of-eaten-apples "吃苹果的最大数目") | [Go](problems/maximum-number-of-eaten-apples) | Medium | @@ -79,13 +95,13 @@ LeetCode Problems' Solutions | 1701 | [Average Waiting Time](https://leetcode.com/problems/average-waiting-time "平均等待时间") | [Go](problems/average-waiting-time) | Medium | | 1700 | [Number of Students Unable to Eat Lunch](https://leetcode.com/problems/number-of-students-unable-to-eat-lunch "无法吃午餐的学生数量") | [Go](problems/number-of-students-unable-to-eat-lunch) | Easy | | 1699 | [Number of Calls Between Two Persons](https://leetcode.com/problems/number-of-calls-between-two-persons) 🔒 | [MySQL](problems/number-of-calls-between-two-persons) | Medium | -| 1698 | [Number of Distinct Substrings in a String](https://leetcode.com/problems/number-of-distinct-substrings-in-a-string) 🔒 | [Go](problems/number-of-distinct-substrings-in-a-string) | Medium | +| 1698 | [Number of Distinct Substrings in a String](https://leetcode.com/problems/number-of-distinct-substrings-in-a-string "字符串的不同子字符串个数") 🔒 | [Go](problems/number-of-distinct-substrings-in-a-string) | Medium | | 1697 | [Checking Existence of Edge Length Limited Paths](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths "检查边长度限制的路径是否存在") | [Go](problems/checking-existence-of-edge-length-limited-paths) | Hard | | 1696 | [Jump Game VI](https://leetcode.com/problems/jump-game-vi "跳跃游戏 VI") | [Go](problems/jump-game-vi) | Medium | | 1695 | [Maximum Erasure Value](https://leetcode.com/problems/maximum-erasure-value "删除子数组的最大得分") | [Go](problems/maximum-erasure-value) | Medium | | 1694 | [Reformat Phone Number](https://leetcode.com/problems/reformat-phone-number "重新格式化电话号码") | [Go](problems/reformat-phone-number) | Easy | -| 1693 | [Daily Leads and Partners](https://leetcode.com/problems/daily-leads-and-partners) 🔒 | [MySQL](problems/daily-leads-and-partners) | Easy | -| 1692 | [Count Ways to Distribute Candies](https://leetcode.com/problems/count-ways-to-distribute-candies) 🔒 | [Go](problems/count-ways-to-distribute-candies) | Hard | +| 1693 | [Daily Leads and Partners](https://leetcode.com/problems/daily-leads-and-partners "每天的领导和合伙人") 🔒 | [MySQL](problems/daily-leads-and-partners) | Easy | +| 1692 | [Count Ways to Distribute Candies](https://leetcode.com/problems/count-ways-to-distribute-candies "计算分配糖果的不同方式") 🔒 | [Go](problems/count-ways-to-distribute-candies) | Hard | | 1691 | [Maximum Height by Stacking Cuboids](https://leetcode.com/problems/maximum-height-by-stacking-cuboids "堆叠长方体的最大高度") | [Go](problems/maximum-height-by-stacking-cuboids) | Hard | | 1690 | [Stone Game VII](https://leetcode.com/problems/stone-game-vii "石子游戏 VII") | [Go](problems/stone-game-vii) | Medium | | 1689 | [Partitioning Into Minimum Number Of Deci-Binary Numbers](https://leetcode.com/problems/partitioning-into-minimum-number-of-deci-binary-numbers "十-二进制数的最少数目") | [Go](problems/partitioning-into-minimum-number-of-deci-binary-numbers) | Medium | @@ -95,13 +111,13 @@ LeetCode Problems' Solutions | 1685 | [Sum of Absolute Differences in a Sorted Array](https://leetcode.com/problems/sum-of-absolute-differences-in-a-sorted-array "有序数组中差绝对值之和") | [Go](problems/sum-of-absolute-differences-in-a-sorted-array) | Medium | | 1684 | [Count the Number of Consistent Strings](https://leetcode.com/problems/count-the-number-of-consistent-strings "统计一致字符串的数目") | [Go](problems/count-the-number-of-consistent-strings) | Easy | | 1683 | [Invalid Tweets](https://leetcode.com/problems/invalid-tweets) 🔒 | [MySQL](problems/invalid-tweets) | Easy | -| 1682 | [Longest Palindromic Subsequence II](https://leetcode.com/problems/longest-palindromic-subsequence-ii) 🔒 | [Go](problems/longest-palindromic-subsequence-ii) | Medium | +| 1682 | [Longest Palindromic Subsequence II](https://leetcode.com/problems/longest-palindromic-subsequence-ii "最长回文子序列 II") 🔒 | [Go](problems/longest-palindromic-subsequence-ii) | Medium | | 1681 | [Minimum Incompatibility](https://leetcode.com/problems/minimum-incompatibility "最小不兼容性") | [Go](problems/minimum-incompatibility) | Hard | | 1680 | [Concatenation of Consecutive Binary Numbers](https://leetcode.com/problems/concatenation-of-consecutive-binary-numbers "连接连续二进制数字") | [Go](problems/concatenation-of-consecutive-binary-numbers) | Medium | | 1679 | [Max Number of K-Sum Pairs](https://leetcode.com/problems/max-number-of-k-sum-pairs "K 和数对的最大数目") | [Go](problems/max-number-of-k-sum-pairs) | Medium | | 1678 | [Goal Parser Interpretation](https://leetcode.com/problems/goal-parser-interpretation "设计 Goal 解析器") | [Go](problems/goal-parser-interpretation) | Easy | | 1677 | [Product's Worth Over Invoices](https://leetcode.com/problems/products-worth-over-invoices) 🔒 | [MySQL](problems/products-worth-over-invoices) | Easy | -| 1676 | [Lowest Common Ancestor of a Binary Tree IV](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-iv) | Medium | +| 1676 | [Lowest Common Ancestor of a Binary Tree IV](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iv "二叉树的最近公共祖先 IV") 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-iv) | Medium | | 1675 | [Minimize Deviation in Array](https://leetcode.com/problems/minimize-deviation-in-array "数组的最小偏移量") | [Go](problems/minimize-deviation-in-array) | Hard | | 1674 | [Minimum Moves to Make Array Complementary](https://leetcode.com/problems/minimum-moves-to-make-array-complementary "使数组互补的最少操作次数") | [Go](problems/minimum-moves-to-make-array-complementary) | Medium | | 1673 | [Find the Most Competitive Subsequence](https://leetcode.com/problems/find-the-most-competitive-subsequence "找出最具竞争力的子序列") | [Go](problems/find-the-most-competitive-subsequence) | Medium | @@ -110,7 +126,7 @@ LeetCode Problems' Solutions | 1670 | [Design Front Middle Back Queue](https://leetcode.com/problems/design-front-middle-back-queue "设计前中后队列") | [Go](problems/design-front-middle-back-queue) | Medium | | 1669 | [Merge In Between Linked Lists](https://leetcode.com/problems/merge-in-between-linked-lists "合并两个链表") | [Go](problems/merge-in-between-linked-lists) | Medium | | 1668 | [Maximum Repeating Substring](https://leetcode.com/problems/maximum-repeating-substring "最大重复子字符串") | [Go](problems/maximum-repeating-substring) | Easy | -| 1667 | [Fix Names in a Table](https://leetcode.com/problems/fix-names-in-a-table) 🔒 | [MySQL](problems/fix-names-in-a-table) | Easy | +| 1667 | [Fix Names in a Table](https://leetcode.com/problems/fix-names-in-a-table "修复表中的名字") 🔒 | [MySQL](problems/fix-names-in-a-table) | Easy | | 1666 | [Change the Root of a Binary Tree](https://leetcode.com/problems/change-the-root-of-a-binary-tree "改变二叉树的根节点") 🔒 | [Go](problems/change-the-root-of-a-binary-tree) | Medium | | 1665 | [Minimum Initial Energy to Finish Tasks](https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks "完成所有任务的最少初始能量") | [Go](problems/minimum-initial-energy-to-finish-tasks) | Hard | | 1664 | [Ways to Make a Fair Array](https://leetcode.com/problems/ways-to-make-a-fair-array "生成平衡数组的方案数") | [Go](problems/ways-to-make-a-fair-array) | Medium | diff --git a/problems/3sum-with-multiplicity/README.md b/problems/3sum-with-multiplicity/README.md index 4c805fdda..1f7a1230c 100644 --- a/problems/3sum-with-multiplicity/README.md +++ b/problems/3sum-with-multiplicity/README.md @@ -11,18 +11,18 @@ ## [923. 3Sum With Multiplicity (Medium)](https://leetcode.com/problems/3sum-with-multiplicity "三数之和的多种可能") -

      Given an integer array A, and an integer target, return the number of tuples i, j, k  such that i < j < k and A[i] + A[j] + A[k] == target.

      +

      Given an integer array arr, and an integer target, return the number of tuples i, j, k such that i < j < k and arr[i] + arr[j] + arr[k] == target.

      -

      As the answer can be very large, return it modulo 109 + 7.

      +

      As the answer can be very large, return it modulo 109 + 7.

       

      Example 1:

      -Input: A = [1,1,2,2,3,3,4,4,5,5], target = 8
      +Input: arr = [1,1,2,2,3,3,4,4,5,5], target = 8
       Output: 20
       Explanation: 
      -Enumerating by the values (A[i], A[j], A[k]):
      +Enumerating by the values (arr[i], arr[j], arr[k]):
       (1, 2, 5) occurs 8 times;
       (1, 3, 4) occurs 8 times;
       (2, 2, 4) occurs 2 times;
      @@ -32,10 +32,10 @@ Enumerating by the values (A[i], A[j], A[k]):
       

      Example 2:

      -Input: A = [1,1,2,2,2,2], target = 5
      +Input: arr = [1,1,2,2,2,2], target = 5
       Output: 12
       Explanation: 
      -A[i] = 1, A[j] = A[k] = 2 occurs 12 times:
      +arr[i] = 1, arr[j] = arr[k] = 2 occurs 12 times:
       We choose one 1 from [1,1] in 2 ways,
       and two 2s from [2,2,2,2] in 6 ways.
       
      @@ -44,8 +44,8 @@ and two 2s from [2,2,2,2] in 6 ways.

      Constraints:

        -
      • 3 <= A.length <= 3000
      • -
      • 0 <= A[i] <= 100
      • +
      • 3 <= arr.length <= 3000
      • +
      • 0 <= arr[i] <= 100
      • 0 <= target <= 300
      diff --git a/problems/add-two-numbers/README.md b/problems/add-two-numbers/README.md index ed6de676c..f1038803f 100644 --- a/problems/add-two-numbers/README.md +++ b/problems/add-two-numbers/README.md @@ -48,6 +48,7 @@
    ### Related Topics + [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/avoid-flood-in-the-city/README.md b/problems/avoid-flood-in-the-city/README.md index fade8b947..2bb9eba1d 100644 --- a/problems/avoid-flood-in-the-city/README.md +++ b/problems/avoid-flood-in-the-city/README.md @@ -88,8 +88,8 @@ After that, it will rain over lakes [1,2]. It's easy to prove that no matter

    Constraints:

      -
    • 1 <= rains.length <= 10^5
    • -
    • 0 <= rains[i] <= 10^9
    • +
    • 1 <= rains.length <= 105
    • +
    • 0 <= rains[i] <= 109
    ### Related Topics diff --git a/problems/beautiful-arrangement/README.md b/problems/beautiful-arrangement/README.md index e49690af1..fa70246ff 100644 --- a/problems/beautiful-arrangement/README.md +++ b/problems/beautiful-arrangement/README.md @@ -11,48 +11,46 @@ ## [526. Beautiful Arrangement (Medium)](https://leetcode.com/problems/beautiful-arrangement "优美的排列") -

    Suppose you have N integers from 1 to N. We define a beautiful arrangement as an array that is constructed by these N numbers successfully if one of the following is true for the ith position (1 <= i <= N) in this array:

    +

    Suppose you have n integers labeled 1 through n. A permutation of those n integers perm (1-indexed) is considered a beautiful arrangement if for every i (1 <= i <= n), either of the following is true:

    -
      -
    1. The number at the ith position is divisible by i.
    2. -
    3. i is divisible by the number at the ith position.
    4. -
    +
      +
    • perm[i] is divisible by i.
    • +
    • i is divisible by perm[i].
    • +
    -

     

    - -

    Now given N, how many beautiful arrangements can you construct?

    +

    Given an integer n, return the number of the beautiful arrangements that you can construct.

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input: 2
    -Output: 2
    +Input: n = 2
    +Output: 2
     Explanation: 
    +The first beautiful arrangement is [1,2]:
    +    - perm[1] = 1 is divisible by i = 1
    +    - perm[2] = 2 is divisible by i = 2
    +The second beautiful arrangement is [2,1]:
    +    - perm[1] = 2 is divisible by i = 1
    +    - i = 2 is divisible by perm[2] = 1
    +
    -The first beautiful arrangement is [1, 2]: - -Number at the 1st position (i=1) is 1, and 1 is divisible by i (i=1). - -Number at the 2nd position (i=2) is 2, and 2 is divisible by i (i=2). - -The second beautiful arrangement is [2, 1]: - -Number at the 1st position (i=1) is 2, and 2 is divisible by i (i=1). +

    Example 2:

    -Number at the 2nd position (i=2) is 1, and i (i=2) is divisible by 1. +
    +Input: n = 1
    +Output: 1
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. N is a positive integer and will not exceed 15.
    2. -
    - -

     

    +
      +
    • 1 <= n <= 15
    • +
    ### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions diff --git a/problems/best-time-to-buy-and-sell-stock-iv/README.md b/problems/best-time-to-buy-and-sell-stock-iv/README.md index 702f8ceb6..4eb4c93a2 100644 --- a/problems/best-time-to-buy-and-sell-stock-iv/README.md +++ b/problems/best-time-to-buy-and-sell-stock-iv/README.md @@ -38,7 +38,7 @@

    Constraints:

      -
    • 0 <= k <= 109
    • +
    • 0 <= k <= 100
    • 0 <= prices.length <= 1000
    • 0 <= prices[i] <= 1000
    diff --git a/problems/biggest-window-between-visits/README.md b/problems/biggest-window-between-visits/README.md new file mode 100644 index 000000000..34849e3a6 --- /dev/null +++ b/problems/biggest-window-between-visits/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../largest-subarray-length-k "Largest Subarray Length K") +                 +[Next >](../maximum-units-on-a-truck "Maximum Units on a Truck") + +## [1709. Biggest Window Between Visits (Medium)](https://leetcode.com/problems/biggest-window-between-visits "") + + diff --git a/problems/biggest-window-between-visits/mysql_schemas.sql b/problems/biggest-window-between-visits/mysql_schemas.sql new file mode 100644 index 000000000..fba17a19a --- /dev/null +++ b/problems/biggest-window-between-visits/mysql_schemas.sql @@ -0,0 +1,8 @@ +Create table If Not Exists UserVisits(user_id int, visit_date date); +Truncate table UserVisits; +insert into UserVisits (user_id, visit_date) values ('1', '2020-11-28'); +insert into UserVisits (user_id, visit_date) values ('1', '2020-10-20'); +insert into UserVisits (user_id, visit_date) values ('1', '2020-12-3'); +insert into UserVisits (user_id, visit_date) values ('2', '2020-10-5'); +insert into UserVisits (user_id, visit_date) values ('2', '2020-12-9'); +insert into UserVisits (user_id, visit_date) values ('3', '2020-11-11'); diff --git a/problems/binary-tree-maximum-path-sum/README.md b/problems/binary-tree-maximum-path-sum/README.md index 508e0d2df..e0d877648 100644 --- a/problems/binary-tree-maximum-path-sum/README.md +++ b/problems/binary-tree-maximum-path-sum/README.md @@ -11,7 +11,7 @@ ## [124. Binary Tree Maximum Path Sum (Hard)](https://leetcode.com/problems/binary-tree-maximum-path-sum "二叉树中的最大路径和") -

    Given a non-empty binary tree, find the maximum path sum.

    +

    Given the root of a binary tree, return the maximum path sum.

    For this problem, a path is defined as any node sequence from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does not need to go through the root.

    @@ -34,7 +34,7 @@

    Constraints:

      -
    • The number of nodes in the tree is in the range [0, 3 * 104].
    • +
    • The number of nodes in the tree is in the range [1, 3 * 104].
    • -1000 <= Node.val <= 1000
    diff --git a/problems/calculate-money-in-leetcode-bank/README.md b/problems/calculate-money-in-leetcode-bank/README.md new file mode 100644 index 000000000..4232e2cdc --- /dev/null +++ b/problems/calculate-money-in-leetcode-bank/README.md @@ -0,0 +1,60 @@ + + + + + + + +[< Previous](../count-apples-and-oranges "Count Apples and Oranges") +                 +[Next >](../maximum-score-from-removing-substrings "Maximum Score From Removing Substrings") + +## [1716. Calculate Money in Leetcode Bank (Easy)](https://leetcode.com/problems/calculate-money-in-leetcode-bank "计算力扣银行的钱") + +

    Hercy wants to save money for his first car. He puts money in the Leetcode bank every day.

    + +

    He starts by putting in $1 on Monday, the first day. Every day from Tuesday to Sunday, he will put in $1 more than the day before. On every subsequent Monday, he will put in $1 more than the previous Monday.

    + +

    Given n, return the total amount of money he will have in the Leetcode bank at the end of the nth day.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 4
    +Output: 10
    +Explanation: After the 4th day, the total is 1 + 2 + 3 + 4 = 10.
    +
    + +

    Example 2:

    + +
    +Input: n = 10
    +Output: 37
    +Explanation: After the 10th day, the total is (1 + 2 + 3 + 4 + 5 + 6 + 7) + (2 + 3 + 4) = 37. Notice that on the 2nd Monday, Hercy only puts in $2.
    +
    + +

    Example 3:

    + +
    +Input: n = 20
    +Output: 96
    +Explanation: After the 20th day, the total is (1 + 2 + 3 + 4 + 5 + 6 + 7) + (2 + 3 + 4 + 5 + 6 + 7 + 8) + (3 + 4 + 5 + 6 + 7 + 8) = 96.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 1000
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Simulate the process by keeping track of how much money John is putting in and which day of the week it is, and use this information to deduce how much money John will put in the next day. +
    diff --git a/problems/check-array-formation-through-concatenation/README.md b/problems/check-array-formation-through-concatenation/README.md index d37ff0985..c6b5bb6b5 100644 --- a/problems/check-array-formation-through-concatenation/README.md +++ b/problems/check-array-formation-through-concatenation/README.md @@ -68,6 +68,7 @@ ### Related Topics [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/construct-the-lexicographically-largest-valid-sequence/README.md b/problems/construct-the-lexicographically-largest-valid-sequence/README.md new file mode 100644 index 000000000..2efa1c694 --- /dev/null +++ b/problems/construct-the-lexicographically-largest-valid-sequence/README.md @@ -0,0 +1,59 @@ + + + + + + + +[< Previous](../maximum-score-from-removing-substrings "Maximum Score From Removing Substrings") +                 +[Next >](../number-of-ways-to-reconstruct-a-tree "Number Of Ways To Reconstruct A Tree") + +## [1718. Construct the Lexicographically Largest Valid Sequence (Medium)](https://leetcode.com/problems/construct-the-lexicographically-largest-valid-sequence "构建字典序最大的可行序列") + +

    Given an integer n, find a sequence that satisfies all of the following:

    + +
      +
    • The integer 1 occurs once in the sequence.
    • +
    • Each integer between 2 and n occurs twice in the sequence.
    • +
    • For every integer i between 2 and n, the distance between the two occurrences of i is exactly i.
    • +
    + +

    The distance between two numbers on the sequence, a[i] and a[j], is the absolute difference of their indices, |j - i|.

    + +

    Return the lexicographically largest sequence. It is guaranteed that under the given constraints, there is always a solution.

    + +

    A sequence a is lexicographically larger than a sequence b (of the same length) if in the first position where a and b differ, sequence a has a number greater than the corresponding number in b. For example, [0,1,9,0] is lexicographically larger than [0,1,5,6] because the first position they differ is at the third number, and 9 is greater than 5.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 3
    +Output: [3,1,2,3,2]
    +Explanation: [2,3,2,1,3] is also a valid sequence, but [3,1,2,3,2] is the lexicographically largest valid sequence.
    +
    + +

    Example 2:

    + +
    +Input: n = 5
    +Output: [5,3,1,4,3,5,2,4,2]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 20
    • +
    + +### Related Topics + [[Recursion](../../tag/recursion/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
    +Hint 1 +Heuristic algorithm may work. +
    diff --git a/problems/container-with-most-water/README.md b/problems/container-with-most-water/README.md index 3e9755510..b4bb591b6 100644 --- a/problems/container-with-most-water/README.md +++ b/problems/container-with-most-water/README.md @@ -49,7 +49,7 @@

    Constraints:

      -
    • n = height.length
    • +
    • n == height.length
    • 2 <= n <= 3 * 104
    • 0 <= height[i] <= 3 * 104
    diff --git a/problems/count-apples-and-oranges/README.md b/problems/count-apples-and-oranges/README.md new file mode 100644 index 000000000..51d64860c --- /dev/null +++ b/problems/count-apples-and-oranges/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../sum-of-special-evenly-spaced-elements-in-array "Sum Of Special Evenly-Spaced Elements In Array") +                 +[Next >](../calculate-money-in-leetcode-bank "Calculate Money in Leetcode Bank") + +## [1715. Count Apples and Oranges (Medium)](https://leetcode.com/problems/count-apples-and-oranges "") + + diff --git a/problems/count-apples-and-oranges/mysql_schemas.sql b/problems/count-apples-and-oranges/mysql_schemas.sql new file mode 100644 index 000000000..89d31e15c --- /dev/null +++ b/problems/count-apples-and-oranges/mysql_schemas.sql @@ -0,0 +1,16 @@ +Create table If Not Exists Boxes (box_id int, chest_id int, apple_count int, orange_count int); +Create table If Not Exists Chests (chest_id int, apple_count int, orange_count int); +Truncate table Boxes; +insert into Boxes (box_id, chest_id, apple_count, orange_count) values ('2', 'None', '6', '15'); +insert into Boxes (box_id, chest_id, apple_count, orange_count) values ('18', '14', '4', '15'); +insert into Boxes (box_id, chest_id, apple_count, orange_count) values ('19', '3', '8', '4'); +insert into Boxes (box_id, chest_id, apple_count, orange_count) values ('12', '2', '19', '20'); +insert into Boxes (box_id, chest_id, apple_count, orange_count) values ('20', '6', '12', '9'); +insert into Boxes (box_id, chest_id, apple_count, orange_count) values ('8', '6', '9', '9'); +insert into Boxes (box_id, chest_id, apple_count, orange_count) values ('3', '14', '16', '7'); +Truncate table Chests; +insert into Chests (chest_id, apple_count, orange_count) values ('6', '5', '6'); +insert into Chests (chest_id, apple_count, orange_count) values ('14', '20', '10'); +insert into Chests (chest_id, apple_count, orange_count) values ('2', '8', '8'); +insert into Chests (chest_id, apple_count, orange_count) values ('3', '19', '4'); +insert into Chests (chest_id, apple_count, orange_count) values ('16', '19', '19'); diff --git a/problems/count-good-meals/README.md b/problems/count-good-meals/README.md new file mode 100644 index 000000000..e341e4284 --- /dev/null +++ b/problems/count-good-meals/README.md @@ -0,0 +1,61 @@ + + + + + + + +[< Previous](../maximum-units-on-a-truck "Maximum Units on a Truck") +                 +[Next >](../ways-to-split-array-into-three-subarrays "Ways to Split Array Into Three Subarrays") + +## [1711. Count Good Meals (Medium)](https://leetcode.com/problems/count-good-meals "大餐计数") + +

    A good meal is a meal that contains exactly two different food items with a sum of deliciousness equal to a power of two.

    + +

    You can pick any two different foods to make a good meal.

    + +

    Given an array of integers deliciousness where deliciousness[i] is the deliciousness of the i​​​​​​th​​​​​​​​ item of food, return the number of different good meals you can make from this list modulo 109 + 7.

    + +

    Note that items with different indices are considered different even if they have the same deliciousness value.

    + +

     

    +

    Example 1:

    + +
    +Input: deliciousness = [1,3,5,7,9]
    +Output: 4
    +Explanation: The good meals are (1,3), (1,7), (3,5) and, (7,9).
    +Their respective sums are 4, 8, 8, and 16, all of which are powers of 2.
    +
    + +

    Example 2:

    + +
    +Input: deliciousness = [1,1,1,3,3,3,7]
    +Output: 15
    +Explanation: The good meals are (1,1) with 3 ways, (1,3) with 9 ways, and (1,7) with 3 ways.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= deliciousness.length <= 105
    • +
    • 0 <= deliciousness[i] <= 220
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + +### Hints +
    +Hint 1 +Note that the number of powers of 2 is at most 21 so this turns the problem to a classic find the number of pairs that sum to a certain value but for 21 values +
    + +
    +Hint 2 +You need to use something fasters than the NlogN approach since there is already the log of iterating over the powers so one idea is two pointers +
    diff --git a/problems/count-negative-numbers-in-a-sorted-matrix/README.md b/problems/count-negative-numbers-in-a-sorted-matrix/README.md index 075589a10..24742bd45 100644 --- a/problems/count-negative-numbers-in-a-sorted-matrix/README.md +++ b/problems/count-negative-numbers-in-a-sorted-matrix/README.md @@ -11,9 +11,7 @@ ## [1351. Count Negative Numbers in a Sorted Matrix (Easy)](https://leetcode.com/problems/count-negative-numbers-in-a-sorted-matrix "统计有序矩阵中的负数") -

    Given a m * n matrix grid which is sorted in non-increasing order both row-wise and column-wise. 

    - -

    Return the number of negative numbers in grid.

    +

    Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid.

     

    Example 1:

    @@ -55,6 +53,9 @@
  • -100 <= grid[i][j] <= 100
  • +

     

    +Follow up: Could you find an O(n + m) solution? + ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/count-ways-to-distribute-candies/README.md b/problems/count-ways-to-distribute-candies/README.md index e63e5eb22..6c08f4c9c 100644 --- a/problems/count-ways-to-distribute-candies/README.md +++ b/problems/count-ways-to-distribute-candies/README.md @@ -9,7 +9,7 @@                  [Next >](../daily-leads-and-partners "Daily Leads and Partners") -## [1692. Count Ways to Distribute Candies (Hard)](https://leetcode.com/problems/count-ways-to-distribute-candies "") +## [1692. Count Ways to Distribute Candies (Hard)](https://leetcode.com/problems/count-ways-to-distribute-candies "计算分配糖果的不同方式") diff --git a/problems/create-sorted-array-through-instructions/README.md b/problems/create-sorted-array-through-instructions/README.md index 87cb04c65..6b9553bf1 100644 --- a/problems/create-sorted-array-through-instructions/README.md +++ b/problems/create-sorted-array-through-instructions/README.md @@ -79,6 +79,7 @@ The total cost is 0 + 0 + 0 + 0 + 1 + 0 + 1 + 0 + 2 = 4. ### Related Topics [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Ordered Map](../../tag/ordered-map/README.md)] ### Hints diff --git a/problems/daily-leads-and-partners/README.md b/problems/daily-leads-and-partners/README.md index aaf480f21..d8ce6f166 100644 --- a/problems/daily-leads-and-partners/README.md +++ b/problems/daily-leads-and-partners/README.md @@ -9,6 +9,6 @@                  [Next >](../reformat-phone-number "Reformat Phone Number") -## [1693. Daily Leads and Partners (Easy)](https://leetcode.com/problems/daily-leads-and-partners "") +## [1693. Daily Leads and Partners (Easy)](https://leetcode.com/problems/daily-leads-and-partners "每天的领导和合伙人") diff --git a/problems/decode-ways/README.md b/problems/decode-ways/README.md index 62d582026..eda25cb55 100644 --- a/problems/decode-ways/README.md +++ b/problems/decode-ways/README.md @@ -11,16 +11,18 @@ ## [91. Decode Ways (Medium)](https://leetcode.com/problems/decode-ways "解码方法") -

    A message containing letters from A-Z is being encoded to numbers using the following mapping:

    +

    A message containing letters from A-Z can be encoded into numbers using the following mapping:

    -'A' -> 1
    -'B' -> 2
    +'A' -> "1"
    +'B' -> "2"
     ...
    -'Z' -> 26
    +'Z' -> "26"
     
    -

    Given a non-empty string containing only digits, determine the total number of ways to decode it.

    +

    To decode an encoded message, all the digits must be mapped back into letters using the reverse of the mapping above (there may be multiple ways). For example, "111" can have each of its "1"s be mapped into 'A's to make "AAA", or it could be mapped to "11" and "1" ('K' and 'A' respectively) to make "KA". Note that "06" cannot be mapped into 'F' since "6" is different from "06".

    + +

    Given a non-empty string num containing only digits, return the number of ways to decode it.

    The answer is guaranteed to fit in a 32-bit integer.

    @@ -30,7 +32,7 @@
     Input: s = "12"
     Output: 2
    -Explanation: It could be decoded as "AB" (1 2) or "L" (12).
    +Explanation: "12" could be decoded as "AB" (1 2) or "L" (12).
     

    Example 2:

    @@ -38,7 +40,7 @@
     Input: s = "226"
     Output: 3
    -Explanation: It could be decoded as "BZ" (2 26), "VF" (22 6), or "BBF" (2 2 6).
    +Explanation: "226" could be decoded as "BZ" (2 26), "VF" (22 6), or "BBF" (2 2 6).
     

    Example 3:

    @@ -46,7 +48,8 @@
     Input: s = "0"
     Output: 0
    -Explanation: There is no character that is mapped to a number starting with '0'. We cannot ignore a zero when we face it while decoding. So, each '0' should be part of "10" --> 'J' or "20" --> 'T'.
    +Explanation: There is no character that is mapped to a number starting with 0. The only valid mappings with 0 are 'J' -> "10" and 'T' -> "20".
    +Since there is no character, there are no valid ways to decode this since all digits need to be mapped.
     

    Example 4:

    diff --git a/problems/decode-xored-array/README.md b/problems/decode-xored-array/README.md new file mode 100644 index 000000000..92381b873 --- /dev/null +++ b/problems/decode-xored-array/README.md @@ -0,0 +1,60 @@ + + + + + + + +[< Previous](../number-of-ways-to-reconstruct-a-tree "Number Of Ways To Reconstruct A Tree") +                 +[Next >](../swapping-nodes-in-a-linked-list "Swapping Nodes in a Linked List") + +## [1720. Decode XORed Array (Easy)](https://leetcode.com/problems/decode-xored-array "解码异或后的数组") + +

    There is a hidden integer array arr that consists of n non-negative integers.

    + +

    It was encoded into another integer array encoded of length n - 1, such that encoded[i] = arr[i] XOR arr[i + 1]. For example, if arr = [1,0,2,1], then encoded = [1,2,3].

    + +

    You are given the encoded array. You are also given an integer first, that is the first element of arr, i.e. arr[0].

    + +

    Return the original array arr. It can be proved that the answer exists and is unique.

    + +

     

    +

    Example 1:

    + +
    +Input: encoded = [1,2,3], first = 1
    +Output: [1,0,2,1]
    +Explanation: If arr = [1,0,2,1], then first = 1 and encoded = [1 XOR 0, 0 XOR 2, 2 XOR 1] = [1,2,3]
    +
    + +

    Example 2:

    + +
    +Input: encoded = [6,2,7,3], first = 4
    +Output: [4,2,0,7,4]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 104
    • +
    • encoded.length == n - 1
    • +
    • 0 <= encoded[i] <= 105
    • +
    • 0 <= first <= 105
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + +### Hints +
    +Hint 1 +Since that encoded[i] = arr[i] XOR arr[i+1], then arr[i+1] = encoded[i] XOR arr[i]. +
    + +
    +Hint 2 +Iterate on i from beginning to end, and set arr[i+1] = encoded[i] XOR arr[i]. +
    diff --git a/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md b/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md index 0f47e5ccb..aecbaee7d 100644 --- a/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md +++ b/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md @@ -69,3 +69,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Recursion](../../tag/recursion/README.md)] diff --git a/problems/find-minimum-time-to-finish-all-jobs/README.md b/problems/find-minimum-time-to-finish-all-jobs/README.md new file mode 100644 index 000000000..4e1521129 --- /dev/null +++ b/problems/find-minimum-time-to-finish-all-jobs/README.md @@ -0,0 +1,55 @@ + + + + + + + +[< Previous](../minimize-hamming-distance-after-swap-operations "Minimize Hamming Distance After Swap Operations") +                 +Next > + +## [1723. Find Minimum Time to Finish All Jobs (Hard)](https://leetcode.com/problems/find-minimum-time-to-finish-all-jobs "完成所有工作的最短时间") + +

    You are given an integer array jobs, where jobs[i] is the amount of time it takes to complete the ith job.

    + +

    There are k workers that you can assign jobs to. Each job should be assigned to exactly one worker. The working time of a worker is the sum of the time it takes to complete all jobs assigned to them. Your goal is to devise an optimal assignment such that the maximum working time of any worker is minimized.

    + +

    Return the minimum possible maximum working time of any assignment.

    + +

     

    +

    Example 1:

    + +
    +Input: jobs = [3,2,3], k = 3
    +Output: 3
    +Explanation: By assigning each person one job, the maximum time is 3.
    +
    + +

    Example 2:

    + +
    +Input: jobs = [1,2,4,7,8], k = 2
    +Output: 11
    +Explanation: Assign the jobs the following way:
    +Worker 1: 1, 2, 8 (working time = 1 + 2 + 8 = 11)
    +Worker 2: 4, 7 (working time = 4 + 7 = 11)
    +The maximum working time is 11.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= jobs.length <= 12
    • +
    • 1 <= jobs[i] <= 107
    • +
    + +### Related Topics + [[Recursion](../../tag/recursion/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
    +Hint 1 +We can select a subset of tasks and assign it to a worker then solve the subproblem on the remaining tasks +
    diff --git a/problems/find-the-duplicate-number/README.md b/problems/find-the-duplicate-number/README.md index 89bc75d38..ebf2a8044 100644 --- a/problems/find-the-duplicate-number/README.md +++ b/problems/find-the-duplicate-number/README.md @@ -13,16 +13,7 @@

    Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive.

    -

    There is only one duplicate number in nums, return this duplicate number.

    - -

    Follow-ups:

    - -
      -
    1. How can we prove that at least one duplicate number must exist in nums
    2. -
    3. Can you solve the problem without modifying the array nums?
    4. -
    5. Can you solve the problem using only constant, O(1) extra space?
    6. -
    7. Can you solve the problem with runtime complexity less than O(n2)?
    8. -
    +

    There is only one repeated number in nums, return this repeated number.

     

    Example 1:

    @@ -48,6 +39,16 @@
  • All the integers in nums appear only once except for precisely one integer which appears two or more times.
  • +

     

    +

    Follow up:

    + +
      +
    • How can we prove that at least one duplicate number must exist in nums?
    • +
    • Can you solve the problem without modifying the array nums?
    • +
    • Can you solve the problem using only constant, O(1) extra space?
    • +
    • Can you solve the problem with runtime complexity less than O(n2)?
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/find-the-smallest-divisor-given-a-threshold/README.md b/problems/find-the-smallest-divisor-given-a-threshold/README.md index daee6eb4b..71534f890 100644 --- a/problems/find-the-smallest-divisor-given-a-threshold/README.md +++ b/problems/find-the-smallest-divisor-given-a-threshold/README.md @@ -11,9 +11,9 @@ ## [1283. Find the Smallest Divisor Given a Threshold (Medium)](https://leetcode.com/problems/find-the-smallest-divisor-given-a-threshold "使结果不超过阈值的最小除数") -

    Given an array of integers nums and an integer threshold, we will choose a positive integer divisor and divide all the array by it and sum the result of the division. Find the smallest divisor such that the result mentioned above is less than or equal to threshold.

    +

    Given an array of integers nums and an integer threshold, we will choose a positive integer divisor, divide all the array by it, and sum the division's result. Find the smallest divisor such that the result mentioned above is less than or equal to threshold.

    -

    Each result of division is rounded to the nearest integer greater than or equal to that element. (For example: 7/3 = 3 and 10/2 = 5).

    +

    Each result of the division is rounded to the nearest integer greater than or equal to that element. (For example: 7/3 = 3 and 10/2 = 5).

    It is guaranteed that there will be an answer.

    @@ -24,21 +24,28 @@ Input: nums = [1,2,5,9], threshold = 6 Output: 5 Explanation: We can get a sum to 17 (1+2+5+9) if the divisor is 1. -If the divisor is 4 we can get a sum to 7 (1+1+2+3) and if the divisor is 5 the sum will be 5 (1+1+1+2). +If the divisor is 4 we can get a sum of 7 (1+1+2+3) and if the divisor is 5 the sum will be 5 (1+1+1+2).

    Example 2:

    -Input: nums = [2,3,5,7,11], threshold = 11
    -Output: 3
    +Input: nums = [44,22,33,11,1], threshold = 5
    +Output: 44
     

    Example 3:

    -Input: nums = [19], threshold = 5
    -Output: 4
    +Input: nums = [21212,10101,12121], threshold = 1000000
    +Output: 1
    +
    + +

    Example 4:

    + +
    +Input: nums = [2,3,5,7,11], threshold = 11
    +Output: 3
     

     

    @@ -47,7 +54,7 @@ If the divisor is 4 we can get a sum to 7 (1+1+2+3) and if the divisor is 5 the
    • 1 <= nums.length <= 5 * 104
    • 1 <= nums[i] <= 106
    • -
    • nums.length <= threshold <= 106
    • +
    • nums.length <= threshold <= 106
    ### Related Topics diff --git a/problems/find-valid-matrix-given-row-and-column-sums/README.md b/problems/find-valid-matrix-given-row-and-column-sums/README.md index 340fc484a..f2970cfeb 100644 --- a/problems/find-valid-matrix-given-row-and-column-sums/README.md +++ b/problems/find-valid-matrix-given-row-and-column-sums/README.md @@ -25,7 +25,7 @@ Output: [[3,0], [1,7]] Explanation: -0th row: 3 + 0 = 0 == rowSum[0] +0th row: 3 + 0 = 3 == rowSum[0] 1st row: 1 + 7 = 8 == rowSum[1] 0th column: 3 + 1 = 4 == colSum[0] 1st column: 0 + 7 = 7 == colSum[1] diff --git a/problems/fix-names-in-a-table/README.md b/problems/fix-names-in-a-table/README.md index 3f8f064c4..e7f1521dc 100644 --- a/problems/fix-names-in-a-table/README.md +++ b/problems/fix-names-in-a-table/README.md @@ -9,6 +9,6 @@                  [Next >](../maximum-repeating-substring "Maximum Repeating Substring") -## [1667. Fix Names in a Table (Easy)](https://leetcode.com/problems/fix-names-in-a-table "") +## [1667. Fix Names in a Table (Easy)](https://leetcode.com/problems/fix-names-in-a-table "修复表中的名字") diff --git a/problems/frog-jump/README.md b/problems/frog-jump/README.md index d53a1cc85..82971c829 100644 --- a/problems/frog-jump/README.md +++ b/problems/frog-jump/README.md @@ -11,45 +11,37 @@ ## [403. Frog Jump (Hard)](https://leetcode.com/problems/frog-jump "青蛙过河") -

    A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water.

    +

    A frog is crossing a river. The river is divided into some number of units, and at each unit, there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water.

    -

    Given a list of stones' positions (in units) in sorted ascending order, determine if the frog is able to cross the river by landing on the last stone. Initially, the frog is on the first stone and assume the first jump must be 1 unit. -

    +

    Given a list of stones' positions (in units) in sorted ascending order, determine if the frog can cross the river by landing on the last stone. Initially, the frog is on the first stone and assumes the first jump must be 1 unit.

    -

    If the frog's last jump was k units, then its next jump must be either k - 1, k, or k + 1 units. Note that the frog can only jump in the forward direction.

    +

    If the frog's last jump was k units, its next jump must be either k - 1, k, or k + 1 units. The frog can only jump in the forward direction.

    -

    Note: -

      -
    • The number of stones is ≥ 2 and is < 1,100.
    • -
    • Each stone's position will be a non-negative integer < 231.
    • -
    • The first stone's position is always 0.
    • -
    -

    +

     

    +

    Example 1:

    -

    Example 1:

    -[0,1,3,5,6,8,12,17]
    +Input: stones = [0,1,3,5,6,8,12,17]
    +Output: true
    +Explanation: The frog can jump to the last stone by jumping 1 unit to the 2nd stone, then 2 units to the 3rd stone, then 2 units to the 4th stone, then 3 units to the 6th stone, 4 units to the 7th stone, and 5 units to the 8th stone.
    +
    -There are a total of 8 stones. -The first stone at the 0th unit, second stone at the 1st unit, -third stone at the 3rd unit, and so on... -The last stone at the 17th unit. +

    Example 2:

    -Return true. The frog can jump to the last stone by jumping -1 unit to the 2nd stone, then 2 units to the 3rd stone, then -2 units to the 4th stone, then 3 units to the 6th stone, -4 units to the 7th stone, and 5 units to the 8th stone. +
    +Input: stones = [0,1,2,3,4,8,9,11]
    +Output: false
    +Explanation: There is no way to jump to the last stone as the gap between the 5th and 6th stone is too large.
     
    -

    -

    Example 2: -

    -[0,1,2,3,4,8,9,11]
    +

     

    +

    Constraints:

    -Return false. There is no way to jump to the last stone as -the gap between the 5th and 6th stone is too large. -
    -

    +
      +
    • 2 <= stones.length <= 2000
    • +
    • 0 <= stones[i] <= 231 - 1
    • +
    • stones[0] == 0
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/game-of-life/README.md b/problems/game-of-life/README.md index 5022a55d0..3ad025edb 100644 --- a/problems/game-of-life/README.md +++ b/problems/game-of-life/README.md @@ -11,18 +11,18 @@ ## [289. Game of Life (Medium)](https://leetcode.com/problems/game-of-life "生命游戏") -

    According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."

    +

    According to Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."

    -

    Given a board with m by n cells, each cell has an initial state live (1) or dead (0). Each cell interacts with its eight neighbors (horizontal, vertical, diagonal) using the following four rules (taken from the above Wikipedia article):

    +

    The board is made up of an m x n grid of cells, where each cell has an initial state: live (represented by a 1) or dead (represented by a 0). Each cell interacts with its eight neighbors (horizontal, vertical, diagonal) using the following four rules (taken from the above Wikipedia article):

      -
    1. Any live cell with fewer than two live neighbors dies, as if caused by under-population.
    2. +
    3. Any live cell with fewer than two live neighbors dies as if caused by under-population.
    4. Any live cell with two or three live neighbors lives on to the next generation.
    5. Any live cell with more than three live neighbors dies, as if by over-population.
    6. Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.
    -

    Write a function to compute the next state (after one update) of the board given its current state. The next state is created by applying the above rules simultaneously to every cell in the current state, where births and deaths occur simultaneously.

    +

    The next state is created by applying the above rules simultaneously to every cell in the current state, where births and deaths occur simultaneously. Given the current state of the m x n grid board, return the next state.

     

    Example 1:

    @@ -54,7 +54,7 @@
    • Could you solve it in-place? Remember that the board needs to be updated simultaneously: You cannot update some cells first and then use their updated values to update other cells.
    • -
    • In this question, we represent the board using a 2D array. In principle, the board is infinite, which would cause problems when the active area encroaches the border of the array. How would you address these problems?
    • +
    • In this question, we represent the board using a 2D array. In principle, the board is infinite, which would cause problems when the active area encroaches upon the border of the array (i.e., live cells reach the border). How would you address these problems?
    ### Related Topics diff --git a/problems/gas-station/README.md b/problems/gas-station/README.md index 2f7fb4a75..25ccdd190 100644 --- a/problems/gas-station/README.md +++ b/problems/gas-station/README.md @@ -11,31 +11,20 @@ ## [134. Gas Station (Medium)](https://leetcode.com/problems/gas-station "加油站") -

    There are N gas stations along a circular route, where the amount of gas at station i is gas[i].

    +

    There are n gas stations along a circular route, where the amount of gas at the ith station is gas[i].

    -

    You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its next station (i+1). You begin the journey with an empty tank at one of the gas stations.

    +

    You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from the ith station to its next (i + 1)th station. You begin the journey with an empty tank at one of the gas stations.

    -

    Return the starting gas station's index if you can travel around the circuit once in the clockwise direction, otherwise return -1.

    - -

    Note:

    - -
      -
    • If there exists a solution, it is guaranteed to be unique.
    • -
    • Both input arrays are non-empty and have the same length.
    • -
    • Each element in the input arrays is a non-negative integer.
    • -
    +

    Given two integer arrays gas and cost, return the starting gas station's index if you can travel around the circuit once in the clockwise direction, otherwise return -1. If there exists a solution, it is guaranteed to be unique

    +

     

    Example 1:

    -Input: 
    -gas  = [1,2,3,4,5]
    -cost = [3,4,5,1,2]
    -
    +Input: gas = [1,2,3,4,5], cost = [3,4,5,1,2]
     Output: 3
    -
    -Explanation:
    -Start at station 3 (index 3) and fill up with 4 unit of gas. Your tank = 0 + 4 = 4
    +Explanation:
    +Start at station 3 (index 3) and fill up with 4 unit of gas. Your tank = 0 + 4 = 4
     Travel to station 4. Your tank = 4 - 1 + 5 = 8
     Travel to station 0. Your tank = 8 - 2 + 1 = 7
     Travel to station 1. Your tank = 7 - 3 + 2 = 6
    @@ -47,14 +36,10 @@ Therefore, return 3 as the starting index.
     

    Example 2:

    -Input: 
    -gas  = [2,3,4]
    -cost = [3,4,3]
    -
    +Input: gas = [2,3,4], cost = [3,4,3]
     Output: -1
    -
    -Explanation:
    -You can't start at station 0 or 1, as there is not enough gas to travel to the next station.
    +Explanation:
    +You can't start at station 0 or 1, as there is not enough gas to travel to the next station.
     Let's start at station 2 and fill up with 4 unit of gas. Your tank = 0 + 4 = 4
     Travel to station 0. Your tank = 4 - 3 + 2 = 3
     Travel to station 1. Your tank = 3 - 3 + 3 = 3
    @@ -62,5 +47,15 @@ You cannot travel back to station 2, as it requires 4 unit of gas but you only h
     Therefore, you can't travel around the circuit once no matter where you start.
     
    +

     

    +

    Constraints:

    + +
      +
    • gas.length == n
    • +
    • cost.length == n
    • +
    • 1 <= n <= 104
    • +
    • 0 <= gas[i], cost[i] <= 104
    • +
    + ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/gray-code/README.md b/problems/gray-code/README.md index 45b98b773..d8f55d259 100644 --- a/problems/gray-code/README.md +++ b/problems/gray-code/README.md @@ -11,40 +11,44 @@ ## [89. Gray Code (Medium)](https://leetcode.com/problems/gray-code "格雷编码") -

    The gray code is a binary numeral system where two successive values differ in only one bit.

    +

    The gray code is a binary numeral system where two successive values differ in only one bit.

    -

    Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0.

    +

    Given an integer n representing the total number of bits in the code, return any sequence of gray code.

    +

    A gray code sequence must begin with 0.

    + +

     

    Example 1:

    -Input: 2
    -Output: [0,1,3,2]
    +Input: n = 2
    +Output: [0,1,3,2]
     Explanation:
     00 - 0
    -01 - 1
    -11 - 3
    -10 - 2
    -
    -For a given n, a gray code sequence may not be uniquely defined.
    -For example, [0,2,3,1] is also a valid gray code sequence.
    -
    +01 - 1
    +11 - 3
    +10 - 2
    +[0,2,3,1] is also a valid gray code sequence.
     00 - 0
    -10 - 2
    -11 - 3
    -01 - 1
    +10 - 2
    +11 - 3
    +01 - 1
     

    Example 2:

    -Input: 0
    -Output: [0]
    -Explanation: We define the gray code sequence to begin with 0.
    -             A gray code sequence of n has size = 2n, which for n = 0 the size is 20 = 1.
    -             Therefore, for n = 0 the gray code sequence is [0].
    +Input: n = 1
    +Output: [0,1]
     
    +

     

    +

    Constraints:

    + +
      +
    • 0 <= n <= 15
    • +
    + ### Related Topics [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/isomorphic-strings/README.md b/problems/isomorphic-strings/README.md index 1634e7f3d..9d2609d9b 100644 --- a/problems/isomorphic-strings/README.md +++ b/problems/isomorphic-strings/README.md @@ -11,33 +11,31 @@ ## [205. Isomorphic Strings (Easy)](https://leetcode.com/problems/isomorphic-strings "同构字符串") -

    Given two strings s and t, determine if they are isomorphic.

    +

    Given two strings s and t, determine if they are isomorphic.

    -

    Two strings are isomorphic if the characters in s can be replaced to get t.

    +

    Two strings s and t are isomorphic if the characters in s can be replaced to get t.

    -

    All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character but a character may map to itself.

    +

    All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character, but a character may map to itself.

    +

     

    Example 1:

    - -
    -Input: s = "egg", t = "add"
    +
    Input: s = "egg", t = "add"
    +Output: true
    +

    Example 2:

    +
    Input: s = "foo", t = "bar"
    +Output: false
    +

    Example 3:

    +
    Input: s = "paper", t = "title"
     Output: true
     
    - -

    Example 2:

    - -
    -Input: s = "foo", t = "bar"
    -Output: false
    - -

    Example 3:

    - -
    -Input: s = "paper", t = "title"
    -Output: true
    - -

    Note:
    -You may assume both and have the same length.

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 5 * 104
    • +
    • t.length == s.length
    • +
    • s and t consist of any valid ascii character.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/jump-game-iv/README.md b/problems/jump-game-iv/README.md index 1e5d81d6d..01391e5fd 100644 --- a/problems/jump-game-iv/README.md +++ b/problems/jump-game-iv/README.md @@ -68,8 +68,8 @@

    Constraints:

      -
    • 1 <= arr.length <= 5 * 10^4
    • -
    • -10^8 <= arr[i] <= 10^8
    • +
    • 1 <= arr.length <= 5 * 104
    • +
    • -108 <= arr[i] <= 108
    ### Related Topics diff --git a/problems/largest-divisible-subset/README.md b/problems/largest-divisible-subset/README.md index 50f2cf432..09476e7d5 100644 --- a/problems/largest-divisible-subset/README.md +++ b/problems/largest-divisible-subset/README.md @@ -11,29 +11,39 @@ ## [368. Largest Divisible Subset (Medium)](https://leetcode.com/problems/largest-divisible-subset "最大整除子集") -

    Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies:

    +

    Given a set of distinct positive integers nums, return the largest subset answer such that every pair (answer[i], answer[j]) of elements in this subset satisfies:

    -

    Si % Sj = 0 or Sj % Si = 0.

    +
      +
    • answer[i] % answer[j] == 0, or
    • +
    • answer[j] % answer[i] == 0
    • +
    -

    If there are multiple solutions, return any subset is fine.

    +

    If there are multiple solutions, return any of them.

    +

     

    Example 1:

    -
    -Input: [1,2,3]
    -Output: [1,2] (of course, [1,3] will also be ok)
    +Input: nums = [1,2,3]
    +Output: [1,2]
    +Explanation: [1,3] is also accepted.
     
    -

    Example 2:

    -Input: [1,2,4,8]
    -Output: [1,2,4,8]
    +Input: nums = [1,2,4,8]
    +Output: [1,2,4,8]
     
    -
    -
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • 1 <= nums[i] <= 2 * 109
    • +
    • All the integers in nums are unique.
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/largest-rectangle-in-histogram/README.md b/problems/largest-rectangle-in-histogram/README.md index 493e234d5..b258adf12 100644 --- a/problems/largest-rectangle-in-histogram/README.md +++ b/problems/largest-rectangle-in-histogram/README.md @@ -32,6 +32,31 @@ Output: 10
    +

     

    +

    Example 1:

    + +
    +Input: heights = [2,1,5,6,2,3]
    +Output: 10
    +Explanation: The above is a histogram where width of each bar is 1.
    +The largest rectangle is shown in the red area, which has an area = 10 units.
    +
    + +

    Example 2:

    + +
    +Input: heights = [2,4]
    +Output: 4
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= heights.length <= 105
    • +
    • 0 <= heights[i] <= 104
    • +
    + ### Related Topics [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] diff --git a/problems/largest-subarray-length-k/README.md b/problems/largest-subarray-length-k/README.md new file mode 100644 index 000000000..f4c475c66 --- /dev/null +++ b/problems/largest-subarray-length-k/README.md @@ -0,0 +1,29 @@ + + + + + + + +[< Previous](../maximum-xor-with-an-element-from-array "Maximum XOR With an Element From Array") +                 +[Next >](../biggest-window-between-visits "Biggest Window Between Visits") + +## [1708. Largest Subarray Length K (Easy)](https://leetcode.com/problems/largest-subarray-length-k "") + + + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Search for the largest integer in the range [0, n - k] +
    + +
    +Hint 2 +This integer is the first element in the subarray. You should take it with the k - 1 elements after it. +
    diff --git a/problems/last-substring-in-lexicographical-order/README.md b/problems/last-substring-in-lexicographical-order/README.md index 22c17fd2f..4767d05ab 100644 --- a/problems/last-substring-in-lexicographical-order/README.md +++ b/problems/last-substring-in-lexicographical-order/README.md @@ -11,33 +11,31 @@ ## [1163. Last Substring in Lexicographical Order (Hard)](https://leetcode.com/problems/last-substring-in-lexicographical-order "按字典序排在最后的子串") -

    Given a string s, return the last substring of s in lexicographical order.

    +

    Given a string s, return the last substring of s in lexicographical order.

     

    -

    Example 1:

    -Input: "abab"
    -Output: "bab"
    -Explanation: The substrings are ["a", "ab", "aba", "abab", "b", "ba", "bab"]. The lexicographically maximum substring is "bab".
    +Input: s = "abab"
    +Output: "bab"
    +Explanation: The substrings are ["a", "ab", "aba", "abab", "b", "ba", "bab"]. The lexicographically maximum substring is "bab".
     

    Example 2:

    -Input: "leetcode"
    -Output: "tcode"
    +Input: s = "leetcode"
    +Output: "tcode"
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= s.length <= 4 * 10^5
    2. -
    3. s contains only lowercase English letters.
    4. -
    +
      +
    • 1 <= s.length <= 4 * 105
    • +
    • s contains only lowercase English letters.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/linked-list-in-binary-tree/README.md b/problems/linked-list-in-binary-tree/README.md index 55de122a8..72731a9b8 100644 --- a/problems/linked-list-in-binary-tree/README.md +++ b/problems/linked-list-in-binary-tree/README.md @@ -49,9 +49,9 @@

    Constraints:

      -
    • 1 <= node.val <= 100 for each node in the linked list and binary tree.
    • -
    • The given linked list will contain between 1 and 100 nodes.
    • -
    • The given binary tree will contain between 1 and 2500 nodes.
    • +
    • The number of nodes in the tree will be in the range [1, 2500].
    • +
    • The number of nodes in the list will be in the range [1, 100].
    • +
    • 1 <= Node.val <= 100 for each node in the linked list and binary tree.
    ### Related Topics diff --git a/problems/longest-increasing-path-in-a-matrix/README.md b/problems/longest-increasing-path-in-a-matrix/README.md index 73f1cf63f..729dda6e6 100644 --- a/problems/longest-increasing-path-in-a-matrix/README.md +++ b/problems/longest-increasing-path-in-a-matrix/README.md @@ -11,36 +11,44 @@ ## [329. Longest Increasing Path in a Matrix (Hard)](https://leetcode.com/problems/longest-increasing-path-in-a-matrix "矩阵中的最长递增路径") -

    Given an integer matrix, find the length of the longest increasing path.

    +

    Given an m x n matrix, return the length of the longest increasing path in matrix.

    -

    From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside of the boundary (i.e. wrap-around is not allowed).

    - -

    Example 1:

    +

    From each cell, you can either move in four directions: left, right, up, or down. You may not move diagonally or move outside the boundary (i.e., wrap-around is not allowed).

    +

     

    +

    Example 1:

    +
    -Input: nums = 
    -[
    -  [9,9,4],
    -  [6,6,8],
    -  [2,1,1]
    -] 
    -Output: 4 
    +Input: matrix = [[9,9,4],[6,6,8],[2,1,1]]
    +Output: 4
     Explanation: The longest increasing path is [1, 2, 6, 9].
     
    -

    Example 2:

    - +

    Example 2:

    +
    -Input: nums = 
    -[
    -  [3,4,5],
    -  [3,2,6],
    -  [2,2,1]
    -] 
    -Output: 4 
    +Input: matrix = [[3,4,5],[3,2,6],[2,2,1]]
    +Output: 4
     Explanation: The longest increasing path is [3, 4, 5, 6]. Moving diagonally is not allowed.
     
    +

    Example 3:

    + +
    +Input: matrix = [[1]]
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == matrix.length
    • +
    • n == matrix[i].length
    • +
    • 1 <= m, n <= 200
    • +
    • 0 <= matrix[i][j] <= 231 - 1
    • +
    + ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] diff --git a/problems/longest-palindromic-subsequence-ii/README.md b/problems/longest-palindromic-subsequence-ii/README.md index 7480e4324..01a6261bd 100644 --- a/problems/longest-palindromic-subsequence-ii/README.md +++ b/problems/longest-palindromic-subsequence-ii/README.md @@ -9,7 +9,7 @@                  [Next >](../invalid-tweets "Invalid Tweets") -## [1682. Longest Palindromic Subsequence II (Medium)](https://leetcode.com/problems/longest-palindromic-subsequence-ii "") +## [1682. Longest Palindromic Subsequence II (Medium)](https://leetcode.com/problems/longest-palindromic-subsequence-ii "最长回文子序列 II") diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md index 4959075d1..4700d6b76 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md @@ -9,7 +9,7 @@                  [Next >](../products-worth-over-invoices "Product's Worth Over Invoices") -## [1676. Lowest Common Ancestor of a Binary Tree IV (Medium)](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iv "") +## [1676. Lowest Common Ancestor of a Binary Tree IV (Medium)](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iv "二叉树的最近公共祖先 IV") diff --git a/problems/majority-element/README.md b/problems/majority-element/README.md index 146a0f308..12478b008 100644 --- a/problems/majority-element/README.md +++ b/problems/majority-element/README.md @@ -11,22 +11,29 @@ ## [169. Majority Element (Easy)](https://leetcode.com/problems/majority-element "多数元素") -

    Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.

    +

    Given an array nums of size n, return the majority element.

    -

    You may assume that the array is non-empty and the majority element always exist in the array.

    +

    The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array.

    +

     

    Example 1:

    - -
    -Input: [3,2,3]
    -Output: 3
    - -

    Example 2:

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

    Example 2:

    +
    Input: nums = [2,2,1,1,1,2,2]
     Output: 2
     
    +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= n <= 5 * 104
    • +
    • -231 <= nums[i] <= 231 - 1
    • +
    + +

     

    +Follow-up: Could you solve the problem in linear time and in O(1) space? ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/maximum-average-subarray-ii/README.md b/problems/maximum-average-subarray-ii/README.md index d6203b0d6..30b24b8d5 100644 --- a/problems/maximum-average-subarray-ii/README.md +++ b/problems/maximum-average-subarray-ii/README.md @@ -9,7 +9,7 @@                  [Next >](../set-mismatch "Set Mismatch") -## [644. Maximum Average Subarray II (Hard)](https://leetcode.com/problems/maximum-average-subarray-ii "最大平均子段和 II") +## [644. Maximum Average Subarray II (Hard)](https://leetcode.com/problems/maximum-average-subarray-ii "子数组最大平均数 II")

    Given an array consisting of n integers, find the contiguous subarray whose length is greater than or equal to k that has the maximum average value. And you need to output the maximum average value. diff --git a/problems/maximum-binary-tree/README.md b/problems/maximum-binary-tree/README.md index 13580bfb6..7c8044cd2 100644 --- a/problems/maximum-binary-tree/README.md +++ b/problems/maximum-binary-tree/README.md @@ -11,15 +11,15 @@ ## [654. Maximum Binary Tree (Medium)](https://leetcode.com/problems/maximum-binary-tree "最大二叉树") -

    Given an integer array with no duplicates. A maximum tree building on this array is defined as follow:

    +

    You are given an integer array nums with no duplicates. A maximum binary tree can be built recursively from nums using the following algorithm:

      -
    1. The root is the maximum number in the array.
    2. -
    3. The left subtree is the maximum tree constructed from left part subarray divided by the maximum number.
    4. -
    5. The right subtree is the maximum tree constructed from right part subarray divided by the maximum number.
    6. +
    7. Create a root node whose value is the maximum value in nums.
    8. +
    9. Recursively build the left subtree on the subarray prefix to the left of the maximum value.
    10. +
    11. Recursively build the right subtree on the subarray suffix to the right of the maximum value.
    -

    Construct the maximum tree by the given array and output the root node of this tree.

    +

    Return the maximum binary tree built from nums.

     

    Example 1:

    @@ -27,6 +27,16 @@
     Input: nums = [3,2,1,6,0,5]
     Output: [6,3,5,null,2,0,null,null,1]
    +Explanation: The recursive calls are as follow:
    +- The largest value in [3,2,1,6,0,5] is 6. Left prefix is [3,2,1] and right suffix is [0,5].
    +    - The largest value in [3,2,1] is 3. Left prefix is [] and right suffix is [2,1].
    +        - Empty array, so no child.
    +        - The largest value in [2,1] is 2. Left prefix is [] and right suffix is [1].
    +            - Empty array, so no child.
    +            - Only one element, so child is a node with value 1.
    +    - The largest value in [0,5] is 5. Left prefix is [0] and right suffix is [].
    +        - Only one element, so child is a node with value 0.
    +        - Empty array, so no child.
     

    Example 2:

    diff --git a/problems/maximum-score-from-removing-substrings/README.md b/problems/maximum-score-from-removing-substrings/README.md new file mode 100644 index 000000000..a6738ec97 --- /dev/null +++ b/problems/maximum-score-from-removing-substrings/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../calculate-money-in-leetcode-bank "Calculate Money in Leetcode Bank") +                 +[Next >](../construct-the-lexicographically-largest-valid-sequence "Construct the Lexicographically Largest Valid Sequence") + +## [1717. Maximum Score From Removing Substrings (Medium)](https://leetcode.com/problems/maximum-score-from-removing-substrings "删除子字符串的最大得分") + +

    You are given a string s and two integers x and y. You can perform two types of operations any number of times.

    + +
      +
    • Remove substring "ab" and gain x points. +
        +
      • For example, when removing "ab" from "cabxbae" it becomes "cxbae".
      • +
      +
    • +
    • Remove substring "ba" and gain y points. +
        +
      • For example, when removing "ba" from "cabxbae" it becomes "cabxe".
      • +
      +
    • +
    + +

    Return the maximum points you can gain after applying the above operations on s.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "cdbcbbaaabab", x = 4, y = 5
    +Output: 19
    +Explanation:
    +- Remove the "ba" underlined in "cdbcbbaaabab". Now, s = "cdbcbbaaab" and 5 points are added to the score.
    +- Remove the "ab" underlined in "cdbcbbaaab". Now, s = "cdbcbbaa" and 4 points are added to the score.
    +- Remove the "ba" underlined in "cdbcbbaa". Now, s = "cdbcba" and 5 points are added to the score.
    +- Remove the "ba" underlined in "cdbcba". Now, s = "cdbc" and 5 points are added to the score.
    +Total score = 5 + 4 + 5 + 5 = 19.
    + +

    Example 2:

    + +
    +Input: s = "aabbaaxybbaabb", x = 5, y = 4
    +Output: 20
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 105
    • +
    • 1 <= x, y <= 104
    • +
    • s consists of lowercase English letters.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Note that it is always more optimal to take one type of substring before another +
    + +
    +Hint 2 +You can use a stack to handle erasures +
    diff --git a/problems/maximum-subarray/README.md b/problems/maximum-subarray/README.md index 62c98b35b..aa6c9f871 100644 --- a/problems/maximum-subarray/README.md +++ b/problems/maximum-subarray/README.md @@ -11,9 +11,7 @@ ## [53. Maximum Subarray (Easy)](https://leetcode.com/problems/maximum-subarray "最大子序和") -

    Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.

    - -

    Follow up: If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle.

    +

    Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.

     

    Example 1:

    @@ -48,18 +46,21 @@

    Example 5:

    -Input: nums = [-2147483647]
    -Output: -2147483647
    +Input: nums = [-100000]
    +Output: -100000
     

     

    Constraints:

      -
    • 1 <= nums.length <= 2 * 104
    • -
    • -231 <= nums[i] <= 231 - 1
    • +
    • 1 <= nums.length <= 3 * 104
    • +
    • -105 <= nums[i] <= 105
    +

     

    +Follow up: If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle. + ### Related Topics [[Array](../../tag/array/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] diff --git a/problems/maximum-units-on-a-truck/README.md b/problems/maximum-units-on-a-truck/README.md new file mode 100644 index 000000000..da2814007 --- /dev/null +++ b/problems/maximum-units-on-a-truck/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../biggest-window-between-visits "Biggest Window Between Visits") +                 +[Next >](../count-good-meals "Count Good Meals") + +## [1710. Maximum Units on a Truck (Easy)](https://leetcode.com/problems/maximum-units-on-a-truck "卡车上的最大单元数") + +

    You are assigned to put some amount of boxes onto one truck. You are given a 2D array boxTypes, where boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]:

    + +
      +
    • numberOfBoxesi is the number of boxes of type i.
    • +
    • numberOfUnitsPerBoxi is the number of units in each box of the type i.
    • +
    + +

    You are also given an integer truckSize, which is the maximum number of boxes that can be put on the truck. You can choose any boxes to put on the truck as long as the number of boxes does not exceed truckSize.

    + +

    Return the maximum total number of units that can be put on the truck.

    + +

     

    +

    Example 1:

    + +
    +Input: boxTypes = [[1,3],[2,2],[3,1]], truckSize = 4
    +Output: 8
    +Explanation: There are:
    +- 1 box of the first type that contains 3 units.
    +- 2 boxes of the second type that contain 2 units each.
    +- 3 boxes of the third type that contain 1 unit each.
    +You can take all the boxes of the first and second types, and one box of the third type.
    +The total number of units will be = (1 * 3) + (2 * 2) + (1 * 1) = 8.
    +
    + +

    Example 2:

    + +
    +Input: boxTypes = [[5,10],[2,5],[4,7],[3,9]], truckSize = 10
    +Output: 91
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= boxTypes.length <= 1000
    • +
    • 1 <= numberOfBoxesi, numberOfUnitsPerBoxi <= 1000
    • +
    • 1 <= truckSize <= 106
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Sort](../../tag/sort/README.md)] + +### Hints +
    +Hint 1 +If we have space for at least one box, it's always optimal to put the box with the most units. +
    + +
    +Hint 2 +Sort the box types with the number of units per box non-increasingly. +
    + +
    +Hint 3 +Iterate on the box types and take from each type as many as you can. +
    diff --git a/problems/maximum-xor-with-an-element-from-array/README.md b/problems/maximum-xor-with-an-element-from-array/README.md index 61cf253d5..8c7b78eaf 100644 --- a/problems/maximum-xor-with-an-element-from-array/README.md +++ b/problems/maximum-xor-with-an-element-from-array/README.md @@ -7,7 +7,7 @@ [< Previous](../where-will-the-ball-fall "Where Will the Ball Fall")                  -Next > +[Next >](../largest-subarray-length-k "Largest Subarray Length K") ## [1707. Maximum XOR With an Element From Array (Hard)](https://leetcode.com/problems/maximum-xor-with-an-element-from-array "与数组中元素的最大异或值") diff --git a/problems/merge-sorted-array/README.md b/problems/merge-sorted-array/README.md index d8f1548ce..be265a7c6 100644 --- a/problems/merge-sorted-array/README.md +++ b/problems/merge-sorted-array/README.md @@ -11,32 +11,27 @@ ## [88. Merge Sorted Array (Easy)](https://leetcode.com/problems/merge-sorted-array "合并两个有序数组") -

    Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.

    +

    Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.

    -

    Note:

    +

    The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has enough space (size that is equal to m + n) to hold additional elements from nums2.

    -
      -
    • The number of elements initialized in nums1 and nums2 are m and n respectively.
    • -
    • You may assume that nums1 has enough space (size that is equal to m + n) to hold additional elements from nums2.
    • -
    - -

    Example:

    - -
    -Input:
    -nums1 = [1,2,3,0,0,0], m = 3
    -nums2 = [2,5,6],       n = 3
    -
    -Output: [1,2,2,3,5,6]
    +

     

    +

    Example 1:

    +
    Input: nums1 = [1,2,3,0,0,0], m = 3, nums2 = [2,5,6], n = 3
    +Output: [1,2,2,3,5,6]
    +

    Example 2:

    +
    Input: nums1 = [1], m = 1, nums2 = [], n = 0
    +Output: [1]
     
    -

     

    Constraints:

      -
    • -10^9 <= nums1[i], nums2[i] <= 10^9
    • +
    • 0 <= n, m <= 200
    • +
    • 1 <= n + m <= 200
    • nums1.length == m + n
    • nums2.length == n
    • +
    • -109 <= nums1[i], nums2[i] <= 109
    ### Related Topics diff --git a/problems/merge-two-sorted-lists/README.md b/problems/merge-two-sorted-lists/README.md index 6a43b9d3e..e8bcebf0f 100644 --- a/problems/merge-two-sorted-lists/README.md +++ b/problems/merge-two-sorted-lists/README.md @@ -11,7 +11,7 @@ ## [21. Merge Two Sorted Lists (Easy)](https://leetcode.com/problems/merge-two-sorted-lists "合并两个有序链表") -

    Merge two sorted linked lists and return it as a new sorted list. The new list should be made by splicing together the nodes of the first two lists.

    +

    Merge two sorted linked lists and return it as a sorted list. The list should be made by splicing together the nodes of the first two lists.

     

    Example 1:

    @@ -45,6 +45,7 @@ ### Related Topics + [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions diff --git a/problems/minimize-hamming-distance-after-swap-operations/README.md b/problems/minimize-hamming-distance-after-swap-operations/README.md new file mode 100644 index 000000000..8149d9665 --- /dev/null +++ b/problems/minimize-hamming-distance-after-swap-operations/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../swapping-nodes-in-a-linked-list "Swapping Nodes in a Linked List") +                 +[Next >](../find-minimum-time-to-finish-all-jobs "Find Minimum Time to Finish All Jobs") + +## [1722. Minimize Hamming Distance After Swap Operations (Medium)](https://leetcode.com/problems/minimize-hamming-distance-after-swap-operations "执行交换操作后的最小汉明距离") + +

    You are given two integer arrays, source and target, both of length n. You are also given an array allowedSwaps where each allowedSwaps[i] = [ai, bi] indicates that you are allowed to swap the elements at index ai and index bi (0-indexed) of array source. Note that you can swap elements at a specific pair of indices multiple times and in any order.

    + +

    The Hamming distance of two arrays of the same length, source and target, is the number of positions where the elements are different. Formally, it is the number of indices i for 0 <= i <= n-1 where source[i] != target[i] (0-indexed).

    + +

    Return the minimum Hamming distance of source and target after performing any amount of swap operations on array source.

    + +

     

    +

    Example 1:

    + +
    +Input: source = [1,2,3,4], target = [2,1,4,5], allowedSwaps = [[0,1],[2,3]]
    +Output: 1
    +Explanation: source can be transformed the following way:
    +- Swap indices 0 and 1: source = [2,1,3,4]
    +- Swap indices 2 and 3: source = [2,1,4,3]
    +The Hamming distance of source and target is 1 as they differ in 1 position: index 3.
    +
    + +

    Example 2:

    + +
    +Input: source = [1,2,3,4], target = [1,3,2,4], allowedSwaps = []
    +Output: 2
    +Explanation: There are no allowed swaps.
    +The Hamming distance of source and target is 2 as they differ in 2 positions: index 1 and index 2.
    +
    + +

    Example 3:

    + +
    +Input: source = [5,1,2,4,3], target = [1,5,4,2,3], allowedSwaps = [[0,4],[4,2],[1,3],[1,4]]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == source.length == target.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= source[i], target[i] <= 105
    • +
    • 0 <= allowedSwaps.length <= 105
    • +
    • allowedSwaps[i].length == 2
    • +
    • 0 <= ai, bi <= n - 1
    • +
    • ai != bi
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + +### Hints +
    +Hint 1 +The source array can be imagined as a graph where each index is a node and each allowedSwaps[i] is an edge. +
    + +
    +Hint 2 +Nodes within the same component can be freely swapped with each other. +
    + +
    +Hint 3 +For each component, find the number of common elements. The elements that are not in common will contribute to the total Hamming distance. +
    diff --git a/problems/minimize-malware-spread/README.md b/problems/minimize-malware-spread/README.md index fc61aba51..7006bac65 100644 --- a/problems/minimize-malware-spread/README.md +++ b/problems/minimize-malware-spread/README.md @@ -11,52 +11,40 @@ ## [924. Minimize Malware Spread (Hard)](https://leetcode.com/problems/minimize-malware-spread "尽量减少恶意软件的传播") -

    In a network of nodes, each node i is directly connected to another node j if and only if graph[i][j] = 1.

    +

    You are given a network of n nodes represented as an n x n adjacency matrix graph, where the ith node is directly connected to the jth node if graph[i][j] == 1.

    -

    Some nodes initial are initially infected by malware.  Whenever two nodes are directly connected and at least one of those two nodes is infected by malware, both nodes will be infected by malware.  This spread of malware will continue until no more nodes can be infected in this manner.

    +

    Some nodes initial are initially infected by malware. Whenever two nodes are directly connected and at least one of those two nodes is infected by malware, both nodes will be infected by malware. This spread of malware will continue until no more nodes can be infected in this manner.

    -

    Suppose M(initial) is the final number of nodes infected with malware in the entire network, after the spread of malware stops.

    +

    Suppose M(initial) is the final number of nodes infected with malware in the entire network after the spread of malware stops. We will remove exactly one node from initial.

    -

    We will remove one node from the initial list.  Return the node that if removed, would minimize M(initial).  If multiple nodes could be removed to minimize M(initial), return such a node with the smallest index.

    +

    Return the node that if removed, would minimize M(initial). If multiple nodes could be removed to minimize M(initial), return such a node with the smallest index.

    -

    Note that if a node was removed from the initial list of infected nodes, it may still be infected later as a result of the malware spread.

    +

    Note that if a node was removed from the initial list of infected nodes, it may still be infected later as a result of the malware spread.

     

    - -
      -
    -

    Example 1:

    - -
    -Input: graph = [[1,1,0],[1,1,0],[0,0,1]], initial = [0,1]
    -Output: 0
    -
    - -

    Example 2:

    - -
    -Input: graph = [[1,0,0],[0,1,0],[0,0,1]], initial = [0,2]
    -Output: 0
    +
    Input: graph = [[1,1,0],[1,1,0],[0,0,1]], initial = [0,1]
    +Output: 0
    +

    Example 2:

    +
    Input: graph = [[1,0,0],[0,1,0],[0,0,1]], initial = [0,2]
    +Output: 0
    +

    Example 3:

    +
    Input: graph = [[1,1,1],[1,1,1],[1,1,1]], initial = [1,2]
    +Output: 1
     
    - -

    Example 3:

    - -
    -Input: graph = [[1,1,1],[1,1,1],[1,1,1]], initial = [1,2]
    -Output: 1
    -
    -

     

    - -

    Note:

    +

    Constraints:

      -
    • 1 < graph.length = graph[0].length <= 300
    • -
    • 0 <= graph[i][j] == graph[j][i] <= 1
    • +
    • n == graph.length
    • +
    • n == graph[i].length
    • +
    • 2 <= n <= 300
    • +
    • graph[i][j] is 0 or 1.
    • +
    • graph[i][j] == graph[j][i]
    • graph[i][i] == 1
    • -
    • 1 <= initial.length <= graph.length
    • -
    • 0 <= initial[i] < graph.length
    • +
    • 1 <= initial.length <= n
    • +
    • 0 <= initial[i] <= n - 1
    • +
    • All the integers in initial are unique.
    ### Related Topics diff --git a/problems/minimum-operations-to-make-a-subsequence/README.md b/problems/minimum-operations-to-make-a-subsequence/README.md new file mode 100644 index 000000000..4f9931e34 --- /dev/null +++ b/problems/minimum-operations-to-make-a-subsequence/README.md @@ -0,0 +1,64 @@ + + + + + + + +[< Previous](../ways-to-split-array-into-three-subarrays "Ways to Split Array Into Three Subarrays") +                 +[Next >](../sum-of-special-evenly-spaced-elements-in-array "Sum Of Special Evenly-Spaced Elements In Array") + +## [1713. Minimum Operations to Make a Subsequence (Hard)](https://leetcode.com/problems/minimum-operations-to-make-a-subsequence "得到子序列的最少操作次数") + +

    You are given an array target that consists of distinct integers and another integer array arr that can have duplicates.

    + +

    In one operation, you can insert any integer at any position in arr. For example, if arr = [1,4,1,2], you can add 3 in the middle and make it [1,4,3,1,2]. Note that you can insert the integer at the very beginning or end of the array.

    + +

    Return the minimum number of operations needed to make target a subsequence of arr.

    + +

    A subsequence of an array is a new array generated from the original array by deleting some elements (possibly none) without changing the remaining elements' relative order. For example, [2,7,4] is a subsequence of [4,2,3,7,2,1,4] (the underlined elements), while [2,4,2] is not.

    + +

     

    +

    Example 1:

    + +
    +Input: target = [5,1,3], arr = [9,4,2,3,4]
    +Output: 2
    +Explanation: You can add 5 and 1 in such a way that makes arr = [5,9,4,1,2,3,4], then target will be a subsequence of arr.
    +
    + +

    Example 2:

    + +
    +Input: target = [6,4,8,1,3,2], arr = [4,7,6,2,3,8,6,1]
    +Output: 3
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= target.length, arr.length <= 105
    • +
    • 1 <= target[i], arr[i] <= 109
    • +
    • target contains no duplicates.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +The problem can be reduced to computing Longest Common Subsequence between both arrays. +
    + +
    +Hint 2 +Since one of the arrays has distinct elements, we can consider that these elements describe an arrangement of numbers, and we can replace each element in the other array with the index it appeared at in the first array. +
    + +
    +Hint 3 +Then the problem is converted to finding Longest Increasing Subsequence in the second array, which can be done in O(n log n). +
    diff --git a/problems/most-stones-removed-with-same-row-or-column/README.md b/problems/most-stones-removed-with-same-row-or-column/README.md index 8e45d05d1..49ec708e4 100644 --- a/problems/most-stones-removed-with-same-row-or-column/README.md +++ b/problems/most-stones-removed-with-same-row-or-column/README.md @@ -11,11 +11,11 @@ ## [947. Most Stones Removed with Same Row or Column (Medium)](https://leetcode.com/problems/most-stones-removed-with-same-row-or-column "移除最多的同行或同列石头") -

    On a 2D plane, we place stones at some integer coordinate points. Each coordinate point may have at most one stone.

    +

    On a 2D plane, we place n stones at some integer coordinate points. Each coordinate point may have at most one stone.

    -

    A move consists of removing a stone that shares a column or row with another stone on the grid.

    +

    A stone can be removed if it shares either the same row or the same column as another stone that has not been removed.

    -

    Given an array stones where stones[i] = [xi, yi], return the largest possible number of moves we can make.

    +

    Given an array stones of length n where stones[i] = [xi, yi] represents the location of the ith stone, return the largest possible number of stones that can be removed.

     

    Example 1:

    @@ -23,6 +23,13 @@
     Input: stones = [[0,0],[0,1],[1,0],[1,2],[2,1],[2,2]]
     Output: 5
    +Explanation: One way to remove 5 stones is as follows:
    +1. Remove stone [2,2] because it shares the same row as [2,1].
    +2. Remove stone [2,1] because it shares the same column as [0,1].
    +3. Remove stone [1,2] because it shares the same row as [1,0].
    +4. Remove stone [1,0] because it shares the same column as [0,0].
    +5. Remove stone [0,1] because it shares the same row as [0,0].
    +Stone [0,0] cannot be removed since it does not share a row/column with another stone still on the plane.
     

    Example 2:

    @@ -30,6 +37,11 @@
     Input: stones = [[0,0],[0,2],[1,1],[2,0],[2,2]]
     Output: 3
    +Explanation: One way to make 3 moves is as follows:
    +1. Remove stone [2,2] because it shares the same row as [2,0].
    +2. Remove stone [2,0] because it shares the same column as [0,0].
    +3. Remove stone [0,2] because it shares the same row as [0,0].
    +Stones [0,0] and [1,1] cannot be removed since they do not share a row/column with another stone still on the plane.
     

    Example 3:

    @@ -37,6 +49,7 @@
     Input: stones = [[0,0]]
     Output: 0
    +Explanation: [0,0] is the only stone on the plane, so you cannot remove it.
     

     

    @@ -44,8 +57,8 @@
    • 1 <= stones.length <= 1000
    • -
    • 0 <= xi, yi < 104
    • -
    • stones contains unique values.
    • +
    • 0 <= xi, yi <= 104
    • +
    • No two stones are at the same coordinate point.
    ### Related Topics diff --git a/problems/my-calendar-iii/README.md b/problems/my-calendar-iii/README.md index 14f448754..5e21e5204 100644 --- a/problems/my-calendar-iii/README.md +++ b/problems/my-calendar-iii/README.md @@ -11,44 +11,45 @@ ## [732. My Calendar III (Hard)](https://leetcode.com/problems/my-calendar-iii "我的日程安排表 III") -

    Implement a MyCalendarThree class to store your events. A new event can always be added.

    +

    A k-booking happens when k events have some non-empty intersection (i.e., there is some time that is common to all k events.)

    -

    Your class will have one method, book(int start, int end). Formally, this represents a booking on the half open interval [start, end), the range of real numbers x such that start <= x < end.

    +

    You are given some events [start, end), after each given event, return an integer k representing the maximum k-booking between all the previous events.

    -

    A K-booking happens when K events have some non-empty intersection (ie., there is some time that is common to all K events.)

    +

    Implement the MyCalendarThree class:

    -

    For each call to the method MyCalendar.book, return an integer K representing the largest integer such that there exists a K-booking in the calendar.

    -Your class will be called like this: MyCalendarThree cal = new MyCalendarThree(); MyCalendarThree.book(start, end) +
      +
    • MyCalendarThree() Initializes the object.
    • +
    • int book(int start, int end) Returns an integer k representing the largest integer such that there exists a k-booking in the calendar.
    • +
    -

    Example 1:

    +

     

    +

    Example 1:

    -MyCalendarThree();
    -MyCalendarThree.book(10, 20); // returns 1
    -MyCalendarThree.book(50, 60); // returns 1
    -MyCalendarThree.book(10, 40); // returns 2
    -MyCalendarThree.book(5, 15); // returns 3
    -MyCalendarThree.book(5, 10); // returns 3
    -MyCalendarThree.book(25, 55); // returns 3
    -Explanation: 
    -The first two events can be booked and are disjoint, so the maximum K-booking is a 1-booking.
    -The third event [10, 40) intersects the first event, and the maximum K-booking is a 2-booking.
    -The remaining events cause the maximum K-booking to be only a 3-booking.
    -Note that the last event locally causes a 2-booking, but the answer is still 3 because
    -eg. [10, 20), [10, 40), and [5, 15) are still triple booked.
    +Input
    +["MyCalendarThree", "book", "book", "book", "book", "book", "book"]
    +[[], [10, 20], [50, 60], [10, 40], [5, 15], [5, 10], [25, 55]]
    +Output
    +[null, 1, 1, 2, 3, 3, 3]
    +
    +Explanation
    +MyCalendarThree myCalendarThree = new MyCalendarThree();
    +myCalendarThree.book(10, 20); // return 1, The first event can be booked and is disjoint, so the maximum k-booking is a 1-booking.
    +myCalendarThree.book(50, 60); // return 1, The second event can be booked and is disjoint, so the maximum k-booking is a 1-booking.
    +myCalendarThree.book(10, 40); // return 2, The third event [10, 40) intersects the first event, and the maximum k-booking is a 2-booking.
    +myCalendarThree.book(5, 15); // return 3, The remaining events cause the maximum K-booking to be only a 3-booking.
    +myCalendarThree.book(5, 10); // return 3
    +myCalendarThree.book(25, 55); // return 3
     

     

    - -

    Note:

    +

    Constraints:

      -
    • The number of calls to MyCalendarThree.book per test case will be at most 400.
    • -
    • In calls to MyCalendarThree.book(start, end), start and end are integers in the range [0, 10^9].
    • +
    • 0 <= start < end <= 109
    • +
    • At most 400 calls will be made to book.
    -

     

    - ### Related Topics [[Segment Tree](../../tag/segment-tree/README.md)] [[Ordered Map](../../tag/ordered-map/README.md)] diff --git a/problems/nth-digit/README.md b/problems/nth-digit/README.md index dc096e6ca..1d4d46c27 100644 --- a/problems/nth-digit/README.md +++ b/problems/nth-digit/README.md @@ -9,7 +9,7 @@                  [Next >](../binary-watch "Binary Watch") -## [400. Nth Digit (Medium)](https://leetcode.com/problems/nth-digit "第N个数字") +## [400. Nth Digit (Medium)](https://leetcode.com/problems/nth-digit "第 N 位数字")

    Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...

    diff --git a/problems/number-of-connected-components-in-an-undirected-graph/README.md b/problems/number-of-connected-components-in-an-undirected-graph/README.md index 2985f5ffb..e2b2c8bfa 100644 --- a/problems/number-of-connected-components-in-an-undirected-graph/README.md +++ b/problems/number-of-connected-components-in-an-undirected-graph/README.md @@ -49,4 +49,4 @@ You can assume that no duplicate edges will appear in edges. Since ### Similar Questions 1. [Number of Islands](../number-of-islands) (Medium) 1. [Graph Valid Tree](../graph-valid-tree) (Medium) - 1. [Friend Circles](../friend-circles) (Medium) + 1. [Number of Provinces](../number-of-provinces) (Medium) diff --git a/problems/number-of-distinct-substrings-in-a-string/README.md b/problems/number-of-distinct-substrings-in-a-string/README.md index 568bad013..02c8eb32f 100644 --- a/problems/number-of-distinct-substrings-in-a-string/README.md +++ b/problems/number-of-distinct-substrings-in-a-string/README.md @@ -9,11 +9,12 @@                  [Next >](../number-of-calls-between-two-persons "Number of Calls Between Two Persons") -## [1698. Number of Distinct Substrings in a String (Medium)](https://leetcode.com/problems/number-of-distinct-substrings-in-a-string "") +## [1698. Number of Distinct Substrings in a String (Medium)](https://leetcode.com/problems/number-of-distinct-substrings-in-a-string "字符串的不同子字符串个数") ### Related Topics + [[Trie](../../tag/trie/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/number-of-provinces/README.md b/problems/number-of-provinces/README.md new file mode 100644 index 000000000..cd0364d15 --- /dev/null +++ b/problems/number-of-provinces/README.md @@ -0,0 +1,58 @@ + + + + + + + +[< Previous](../remove-boxes "Remove Boxes") +                 +[Next >](../split-array-with-equal-sum "Split Array with Equal Sum") + +## [547. Number of Provinces (Medium)](https://leetcode.com/problems/number-of-provinces "省份数量") + +

    There are n cities. Some of them are connected, while some are not. If city a is connected directly with city b, and city b is connected directly with city c, then city a is connected indirectly with city c.

    + +

    A province is a group of directly or indirectly connected cities and no other cities outside of the group.

    + +

    You are given an n x n matrix isConnected where isConnected[i][j] = 1 if the ith city and the jth city are directly connected, and isConnected[i][j] = 0 otherwise.

    + +

    Return the total number of provinces.

    + +

     

    +

    Example 1:

    + +
    +Input: isConnected = [[1,1,0],[1,1,0],[0,0,1]]
    +Output: 2
    +
    + +

    Example 2:

    + +
    +Input: isConnected = [[1,0,0],[0,1,0],[0,0,1]]
    +Output: 3
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 200
    • +
    • n == isConnected.length
    • +
    • n == isConnected[i].length
    • +
    • isConnected[i][j] is 1 or 0.
    • +
    • isConnected[i][i] == 1
    • +
    • isConnected[i][j] == isConnected[j][i]
    • +
    + +### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + +### Similar Questions + 1. [Number of Connected Components in an Undirected Graph](../number-of-connected-components-in-an-undirected-graph) (Medium) + 1. [Robot Return to Origin](../robot-return-to-origin) (Easy) + 1. [Sentence Similarity](../sentence-similarity) (Easy) + 1. [Sentence Similarity II](../sentence-similarity-ii) (Medium) + 1. [The Earliest Moment When Everyone Become Friends](../the-earliest-moment-when-everyone-become-friends) (Medium) diff --git a/problems/number-of-ways-to-reconstruct-a-tree/README.md b/problems/number-of-ways-to-reconstruct-a-tree/README.md new file mode 100644 index 000000000..422e6d038 --- /dev/null +++ b/problems/number-of-ways-to-reconstruct-a-tree/README.md @@ -0,0 +1,99 @@ + + + + + + + +[< Previous](../construct-the-lexicographically-largest-valid-sequence "Construct the Lexicographically Largest Valid Sequence") +                 +[Next >](../decode-xored-array "Decode XORed Array") + +## [1719. Number Of Ways To Reconstruct A Tree (Hard)](https://leetcode.com/problems/number-of-ways-to-reconstruct-a-tree "重构一棵树的方案数") + +

    You are given an array pairs, where pairs[i] = [xi, yi], and:

    + +
      +
    • There are no duplicates.
    • +
    • xi < yi
    • +
    + +

    Let ways be the number of rooted trees that satisfy the following conditions:

    + +
      +
    • The tree consists of nodes whose values appeared in pairs.
    • +
    • A pair [xi, yi] exists in pairs if and only if xi is an ancestor of yi or yi is an ancestor of xi.
    • +
    • Note: the tree does not have to be a binary tree.
    • +
    + +

    Two ways are considered to be different if there is at least one node that has different parents in both ways.

    + +

    Return:

    + +
      +
    • 0 if ways == 0
    • +
    • 1 if ways == 1
    • +
    • 2 if ways > 1
    • +
    + +

    A rooted tree is a tree that has a single root node, and all edges are oriented to be outgoing from the root.

    + +

    An ancestor of a node is any node on the path from the root to that node (excluding the node itself). The root has no ancestors.

    + +

     

    +

    Example 1:

    + +
    +Input: pairs = [[1,2],[2,3]]
    +Output: 1
    +Explanation: There is exactly one valid rooted tree, which is shown in the above figure.
    +
    + +

    Example 2:

    + +
    +Input: pairs = [[1,2],[2,3],[1,3]]
    +Output: 2
    +Explanation: There are multiple valid rooted trees. Three of them are shown in the above figures.
    +
    + +

    Example 3:

    + +
    +Input: pairs = [[1,2],[2,3],[2,4],[1,5]]
    +Output: 0
    +Explanation: There are no valid rooted trees.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= pairs.length <= 105
    • +
    • 1 <= xi < yi <= 500
    • +
    • The elements in pairs are unique.
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Graph](../../tag/graph/README.md)] + +### Hints +
    +Hint 1 +Think inductively. The first step is to get the root. Obviously, the root should be in pairs with all the nodes. If there isn't exactly one such node, then there are 0 ways. +
    + +
    +Hint 2 +The number of pairs involving a node must be less than or equal to that number of its parent. +
    + +
    +Hint 3 +Actually, if it's equal, then there is not exactly 1 way, because they can be swapped. +
    + +
    +Hint 4 +Recursively, given a set of nodes, get the node with the most pairs, then this must be a root and have no parents in the current set of nodes. +
    diff --git a/problems/partition-list/README.md b/problems/partition-list/README.md index 9d88e31d5..dbfa30257 100644 --- a/problems/partition-list/README.md +++ b/problems/partition-list/README.md @@ -11,17 +11,34 @@ ## [86. Partition List (Medium)](https://leetcode.com/problems/partition-list "分隔链表") -

    Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.

    +

    Given the head of a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.

    -

    You should preserve the original relative order of the nodes in each of the two partitions.

    +

    You should preserve the original relative order of the nodes in each of the two partitions.

    -

    Example:

    +

     

    +

    Example 1:

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

    Example 2:

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

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [0, 200].
    • +
    • -100 <= Node.val <= 100
    • +
    • -200 <= x <= 200
    • +
    + ### Related Topics [[Linked List](../../tag/linked-list/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/profitable-schemes/README.md b/problems/profitable-schemes/README.md index 7e3d68adc..bfb99ea9b 100644 --- a/problems/profitable-schemes/README.md +++ b/problems/profitable-schemes/README.md @@ -11,55 +11,40 @@ ## [879. Profitable Schemes (Hard)](https://leetcode.com/problems/profitable-schemes "盈利计划") -

    There is a group of G members, and a list of various crimes they could commit.

    +

    There is a group of n members, and a list of various crimes they could commit. The ith crime generates a profit[i] and requires group[i] members to participate in it. If a member participates in one crime, that member can't participate in another crime.

    -

    The ith crime generates a profit[i] and requires group[i] members to participate in it.

    +

    Let's call a profitable scheme any subset of these crimes that generates at least minProfit profit, and the total number of members participating in that subset of crimes is at most n.

    -

    If a member participates in one crime, that member can't participate in another crime.

    - -

    Let's call a profitable scheme any subset of these crimes that generates at least P profit, and the total number of members participating in that subset of crimes is at most G.

    - -

    How many schemes can be chosen?  Since the answer may be very large, return it modulo 10^9 + 7.

    +

    Return the number of schemes that can be chosen. Since the answer may be very large, return it modulo 109 + 7.

     

    -

    Example 1:

    -Input: G = 5, P = 3, group = [2,2], profit = [2,3]
    -Output: 2
    -Explanation: 
    -To make a profit of at least 3, the group could either commit crimes 0 and 1, or just crime 1.
    -In total, there are 2 schemes.
    -
    +Input: n = 5, minProfit = 3, group = [2,2], profit = [2,3] +Output: 2 +Explanation: To make a profit of at least 3, the group could either commit crimes 0 and 1, or just crime 1. +In total, there are 2 schemes.
    -

    Example 2:

    -Input: G = 10, P = 5, group = [2,3,5], profit = [6,7,8]
    -Output: 7
    -Explanation: 
    -To make a profit of at least 5, the group could commit any crimes, as long as they commit one.
    -There are 7 possible schemes: (0), (1), (2), (0,1), (0,2), (1,2), and (0,1,2).
    -
    +Input: n = 10, minProfit = 5, group = [2,3,5], profit = [6,7,8] +Output: 7 +Explanation: To make a profit of at least 5, the group could commit any crimes, as long as they commit one. +There are 7 possible schemes: (0), (1), (2), (0,1), (0,2), (1,2), and (0,1,2).

     

    - +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= G <= 100
    2. -
    3. 0 <= P <= 100
    4. +
        +
      • 1 <= n <= 100
      • +
      • 0 <= minProfit <= 100
      • +
      • 1 <= group.length <= 100
      • 1 <= group[i] <= 100
      • +
      • profit.length == group.length
      • 0 <= profit[i] <= 100
      • -
      • 1 <= group.length = profit.length <= 100
      • -
    - -
    -
     
    -
    + ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md b/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md index b673de543..0b14c5012 100644 --- a/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md +++ b/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md @@ -47,8 +47,8 @@

    Constraints:

      -
    • The given binary tree will have between 1 and 10^5 nodes.
    • -
    • Node values are digits from 1 to 9.
    • +
    • The number of nodes in the tree is in the range [1, 105].
    • +
    • 1 <= Node.val <= 9
    ### Related Topics diff --git a/problems/queens-that-can-attack-the-king/README.md b/problems/queens-that-can-attack-the-king/README.md index 53edb6653..d10e1a712 100644 --- a/problems/queens-that-can-attack-the-king/README.md +++ b/problems/queens-that-can-attack-the-king/README.md @@ -14,7 +14,6 @@

    On an 8x8 chessboard, there can be multiple Black Queens and one White King.

    Given an array of integer coordinates queens that represents the positions of the Black Queens, and a pair of coordinates king that represent the position of the White King, return the coordinates of all the queens (in any order) that can attack the King.

    -

     

    Example 1:

    @@ -49,13 +48,12 @@ The queen at [2,4] can't attack the king cause it's not in the same row/ Input: queens = [[5,6],[7,7],[2,1],[0,7],[1,6],[5,1],[3,7],[0,3],[4,0],[1,2],[6,3],[5,0],[0,4],[2,2],[1,1],[6,4],[5,4],[0,0],[2,6],[4,5],[5,2],[1,4],[7,5],[2,3],[0,5],[4,2],[1,0],[2,7],[0,1],[4,6],[6,1],[0,6],[4,3],[1,7]], king = [3,4] Output: [[2,3],[1,4],[1,6],[3,7],[4,3],[5,4],[4,5]]
    -

     

    Constraints:

    • 1 <= queens.length <= 63
    • -
    • queens[0].length == 2
    • +
    • queens[i].length == 2
    • 0 <= queens[i][j] < 8
    • king.length == 2
    • 0 <= king[0], king[1] < 8
    • diff --git a/problems/remove-boxes/README.md b/problems/remove-boxes/README.md index 553648a4d..77230a971 100644 --- a/problems/remove-boxes/README.md +++ b/problems/remove-boxes/README.md @@ -7,13 +7,15 @@ [< Previous](../boundary-of-binary-tree "Boundary of Binary Tree")                  -[Next >](../friend-circles "Friend Circles") +[Next >](../number-of-provinces "Number of Provinces") ## [546. Remove Boxes (Hard)](https://leetcode.com/problems/remove-boxes "移除盒子") -

      Given several boxes with different colors represented by different positive numbers.
      -You may experience several rounds to remove boxes until there is no box left. Each time you can choose some continuous boxes with the same color (composed of k boxes, k >= 1), remove them and get k*k points.
      -Find the maximum points you can get.

      +

      You are given several boxes with different colors represented by different positive numbers.

      + +

      You may experience several rounds to remove boxes until there is no box left. Each time you can choose some continuous boxes with the same color (i.e., composed of k boxes, k >= 1), remove them and get k * k points.

      + +

      Return the maximum points you can get.

       

      Example 1:

      @@ -29,6 +31,20 @@ Find the maximum points you can get.

      ----> [] (2*2=4 points)
    +

    Example 2:

    + +
    +Input: boxes = [1,1,1]
    +Output: 9
    +
    + +

    Example 3:

    + +
    +Input: boxes = [1]
    +Output: 1
    +
    +

     

    Constraints:

    diff --git a/problems/remove-duplicates-from-sorted-list-ii/README.md b/problems/remove-duplicates-from-sorted-list-ii/README.md index a59209fb5..15a05034f 100644 --- a/problems/remove-duplicates-from-sorted-list-ii/README.md +++ b/problems/remove-duplicates-from-sorted-list-ii/README.md @@ -11,24 +11,32 @@ ## [82. Remove Duplicates from Sorted List II (Medium)](https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii "删除排序链表中的重复元素 II") -

    Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.

    - -

    Return the linked list sorted as well.

    +

    Given the head of a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Return the linked list sorted as well.

    +

     

    Example 1:

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

    Example 2:

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

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is in the range [0, 300].
    • +
    • -100 <= Node.val <= 100
    • +
    • The list is guaranteed to be sorted in ascending order.
    • +
    + ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/remove-duplicates-from-sorted-list/README.md b/problems/remove-duplicates-from-sorted-list/README.md index bcf7db1ce..31a128b39 100644 --- a/problems/remove-duplicates-from-sorted-list/README.md +++ b/problems/remove-duplicates-from-sorted-list/README.md @@ -11,22 +11,32 @@ ## [83. Remove Duplicates from Sorted List (Easy)](https://leetcode.com/problems/remove-duplicates-from-sorted-list "删除排序链表中的重复元素") -

    Given a sorted linked list, delete all duplicates such that each element appear only once.

    +

    Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well.

    +

     

    Example 1:

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

    Example 2:

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

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is in the range [0, 300].
    • +
    • -100 <= Node.val <= 100
    • +
    • The list is guaranteed to be sorted in ascending order.
    • +
    + ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/replace-elements-with-greatest-element-on-right-side/README.md b/problems/replace-elements-with-greatest-element-on-right-side/README.md index 3ea525177..c8e5376fb 100644 --- a/problems/replace-elements-with-greatest-element-on-right-side/README.md +++ b/problems/replace-elements-with-greatest-element-on-right-side/README.md @@ -17,15 +17,33 @@

     

    Example 1:

    -
    Input: arr = [17,18,5,4,6,1]
    +
    +
    +Input: arr = [17,18,5,4,6,1]
     Output: [18,6,6,6,1,-1]
    +Explanation: 
    +- index 0 --> the greatest element to the right of index 0 is index 1 (18).
    +- index 1 --> the greatest element to the right of index 1 is index 4 (6).
    +- index 2 --> the greatest element to the right of index 2 is index 4 (6).
    +- index 3 --> the greatest element to the right of index 3 is index 4 (6).
    +- index 4 --> the greatest element to the right of index 4 is index 5 (1).
    +- index 5 --> there are no elements to the right of index 5, so we put -1.
     
    + +

    Example 2:

    + +
    +Input: arr = [400]
    +Output: [-1]
    +Explanation: There are no elements to the right of index 0.
    +
    +

     

    Constraints:

      -
    • 1 <= arr.length <= 10^4
    • -
    • 1 <= arr[i] <= 10^5
    • +
    • 1 <= arr.length <= 104
    • +
    • 1 <= arr[i] <= 105
    ### Related Topics diff --git a/problems/reverse-integer/README.md b/problems/reverse-integer/README.md index ac306fad2..cd697a63e 100644 --- a/problems/reverse-integer/README.md +++ b/problems/reverse-integer/README.md @@ -11,10 +11,9 @@ ## [7. Reverse Integer (Easy)](https://leetcode.com/problems/reverse-integer "整数反转") -

    Given a 32-bit signed integer, reverse digits of an integer.

    +

    Given a 32-bit signed integer, reverse digits of an integer.

    -

    Note:
    -Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.

    +

    Note: Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. For this problem, assume that your function returns 0 when the reversed integer overflows.

     

    Example 1:

    diff --git a/problems/robot-return-to-origin/README.md b/problems/robot-return-to-origin/README.md index 434b3244a..3d67fa8d2 100644 --- a/problems/robot-return-to-origin/README.md +++ b/problems/robot-return-to-origin/README.md @@ -60,4 +60,4 @@ [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Friend Circles](../friend-circles) (Medium) + 1. [Number of Provinces](../number-of-provinces) (Medium) diff --git a/problems/rotting-oranges/README.md b/problems/rotting-oranges/README.md index 2713cf07f..812af76c4 100644 --- a/problems/rotting-oranges/README.md +++ b/problems/rotting-oranges/README.md @@ -11,60 +11,51 @@ ## [994. Rotting Oranges (Medium)](https://leetcode.com/problems/rotting-oranges "腐烂的橘子") -

    In a given grid, each cell can have one of three values:

    +

    You are given an m x n grid where each cell can have one of three values:

      -
    • the value 0 representing an empty cell;
    • -
    • the value 1 representing a fresh orange;
    • -
    • the value 2 representing a rotten orange.
    • +
    • 0 representing an empty cell,
    • +
    • 1 representing a fresh orange, or
    • +
    • 2 representing a rotten orange.
    -

    Every minute, any fresh orange that is adjacent (4-directionally) to a rotten orange becomes rotten.

    +

    Every minute, any fresh orange that is 4-directionally adjacent to a rotten orange becomes rotten.

    -

    Return the minimum number of minutes that must elapse until no cell has a fresh orange.  If this is impossible, return -1 instead.

    +

    Return the minimum number of minutes that must elapse until no cell has a fresh orange. If this is impossible, return -1.

     

    - -

    Example 1:

    - -

    - +
    -Input: [[2,1,1],[1,1,0],[0,1,1]]
    -Output: 4
    +Input: grid = [[2,1,1],[1,1,0],[0,1,1]]
    +Output: 4
     
    -

    Example 2:

    -Input: [[2,1,1],[0,1,1],[1,0,1]]
    -Output: -1
    -Explanation:  The orange in the bottom left corner (row 2, column 0) is never rotten, because rotting only happens 4-directionally.
    +Input: grid = [[2,1,1],[0,1,1],[1,0,1]]
    +Output: -1
    +Explanation: The orange in the bottom left corner (row 2, column 0) is never rotten, because rotting only happens 4-directionally.
     
    -

    Example 3:

    -Input: [[0,2]]
    -Output: 0
    -Explanation:  Since there are already no fresh oranges at minute 0, the answer is just 0.
    +Input: grid = [[0,2]]
    +Output: 0
    +Explanation: Since there are already no fresh oranges at minute 0, the answer is just 0.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= grid.length <= 10
    2. -
    3. 1 <= grid[0].length <= 10
    4. -
    5. grid[i][j] is only 0, 1, or 2.
    6. -
    -
    -
    -
    +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 10
    • +
    • grid[i][j] is 0, 1, or 2.
    • +
    ### Related Topics [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/search-in-rotated-sorted-array-ii/README.md b/problems/search-in-rotated-sorted-array-ii/README.md index 6930dbd99..d61592cd3 100644 --- a/problems/search-in-rotated-sorted-array-ii/README.md +++ b/problems/search-in-rotated-sorted-array-ii/README.md @@ -11,32 +11,33 @@ ## [81. Search in Rotated Sorted Array II (Medium)](https://leetcode.com/problems/search-in-rotated-sorted-array-ii "搜索旋转排序数组 II") -

    Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.

    +

    You are given an integer array nums sorted in ascending order (not necessarily distinct values), and an integer target.

    -

    (i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]).

    +

    Suppose that nums is rotated at some pivot unknown to you beforehand (i.e., [0,1,2,4,4,4,5,6,6,7] might become [4,5,6,6,7,0,1,2,4,4]).

    -

    You are given a target value to search. If found in the array return true, otherwise return false.

    +

    If target is found in the array return its index, otherwise, return -1.

    +

     

    Example 1:

    - -
    -Input: nums = [2,5,6,0,0,1,2], target = 0
    +
    Input: nums = [2,5,6,0,0,1,2], target = 0
     Output: true
    +

    Example 2:

    +
    Input: nums = [2,5,6,0,0,1,2], target = 3
    +Output: false
     
    - -

    Example 2:

    - -
    -Input: nums = [2,5,6,0,0,1,2], target = 3
    -Output: false
    - -

    Follow up:

    +

     

    +

    Constraints:

      -
    • This is a follow up problem to Search in Rotated Sorted Array, where nums may contain duplicates.
    • -
    • Would this affect the run-time complexity? How and why?
    • +
    • 1 <= nums.length <= 5000
    • +
    • -104 <= nums[i] <= 104
    • +
    • nums is guaranteed to be rotated at some pivot.
    • +
    • -104 <= target <= 104
    +

     

    +Follow up: This problem is the same as Search in Rotated Sorted Array, where nums may contain duplicates. Would this affect the run-time complexity? How and why? + ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/search-in-rotated-sorted-array/README.md b/problems/search-in-rotated-sorted-array/README.md index 7d6c4e470..e6d7c8e89 100644 --- a/problems/search-in-rotated-sorted-array/README.md +++ b/problems/search-in-rotated-sorted-array/README.md @@ -11,7 +11,7 @@ ## [33. Search in Rotated Sorted Array (Medium)](https://leetcode.com/problems/search-in-rotated-sorted-array "搜索旋转排序数组") -

    You are given an integer array nums sorted in ascending order, and an integer target.

    +

    You are given an integer array nums sorted in ascending order (with distinct values), and an integer target.

    Suppose that nums is rotated at some pivot unknown to you beforehand (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).

    @@ -33,10 +33,10 @@
    • 1 <= nums.length <= 5000
    • -
    • -10^4 <= nums[i] <= 10^4
    • +
    • -104 <= nums[i] <= 104
    • All values of nums are unique.
    • -
    • nums is guranteed to be rotated at some pivot.
    • -
    • -10^4 <= target <= 10^4
    • +
    • nums is guaranteed to be rotated at some pivot.
    • +
    • -104 <= target <= 104
    ### Related Topics diff --git a/problems/sentence-similarity-ii/README.md b/problems/sentence-similarity-ii/README.md index d94e4d940..3ff5d9691 100644 --- a/problems/sentence-similarity-ii/README.md +++ b/problems/sentence-similarity-ii/README.md @@ -39,7 +39,7 @@ [[Union Find](../../tag/union-find/README.md)] ### Similar Questions - 1. [Friend Circles](../friend-circles) (Medium) + 1. [Number of Provinces](../number-of-provinces) (Medium) 1. [Accounts Merge](../accounts-merge) (Medium) 1. [Sentence Similarity](../sentence-similarity) (Easy) diff --git a/problems/sentence-similarity/README.md b/problems/sentence-similarity/README.md index 97d6a6713..4b4c47156 100644 --- a/problems/sentence-similarity/README.md +++ b/problems/sentence-similarity/README.md @@ -38,7 +38,7 @@ [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Friend Circles](../friend-circles) (Medium) + 1. [Number of Provinces](../number-of-provinces) (Medium) 1. [Accounts Merge](../accounts-merge) (Medium) 1. [Sentence Similarity II](../sentence-similarity-ii) (Medium) diff --git a/problems/sort-items-by-groups-respecting-dependencies/README.md b/problems/sort-items-by-groups-respecting-dependencies/README.md index ec7c51434..c3b398a6b 100644 --- a/problems/sort-items-by-groups-respecting-dependencies/README.md +++ b/problems/sort-items-by-groups-respecting-dependencies/README.md @@ -44,11 +44,11 @@

    Constraints:

      -
    • 1 <= m <= n <= 3*10^4
    • +
    • 1 <= m <= n <= 3 * 104
    • group.length == beforeItems.length == n
    • -
    • -1 <= group[i] <= m-1
    • -
    • 0 <= beforeItems[i].length <= n-1
    • -
    • 0 <= beforeItems[i][j] <= n-1
    • +
    • -1 <= group[i] <= m - 1
    • +
    • 0 <= beforeItems[i].length <= n - 1
    • +
    • 0 <= beforeItems[i][j] <= n - 1
    • i != beforeItems[i][j]
    • beforeItems[i] does not contain duplicates elements.
    diff --git a/problems/split-array-with-equal-sum/README.md b/problems/split-array-with-equal-sum/README.md index fac6e7e7d..8873b82e1 100644 --- a/problems/split-array-with-equal-sum/README.md +++ b/problems/split-array-with-equal-sum/README.md @@ -5,7 +5,7 @@ -[< Previous](../friend-circles "Friend Circles") +[< Previous](../number-of-provinces "Number of Provinces")                  [Next >](../binary-tree-longest-consecutive-sequence-ii "Binary Tree Longest Consecutive Sequence II") diff --git a/problems/squares-of-a-sorted-array/README.md b/problems/squares-of-a-sorted-array/README.md index e2a6688d5..2efc259bd 100644 --- a/problems/squares-of-a-sorted-array/README.md +++ b/problems/squares-of-a-sorted-array/README.md @@ -11,7 +11,7 @@ ## [977. Squares of a Sorted Array (Easy)](https://leetcode.com/problems/squares-of-a-sorted-array "有序数组的平方") -

    Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.

    +

    Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.

     

    Example 1:

    @@ -39,6 +39,9 @@ After sorting, it becomes [0,1,9,16,100].
  • nums is sorted in non-decreasing order.
  • +

     

    +Follow up: Squaring each element and sorting the new array is very trivial, could you find an O(n) solution using a different approach? + ### Related Topics [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/subsets/README.md b/problems/subsets/README.md index 035aea1d9..075a60080 100644 --- a/problems/subsets/README.md +++ b/problems/subsets/README.md @@ -36,6 +36,7 @@
    • 1 <= nums.length <= 10
    • -10 <= nums[i] <= 10
    • +
    • All the numbers of nums are unique.
    ### Related Topics diff --git a/problems/sum-of-special-evenly-spaced-elements-in-array/README.md b/problems/sum-of-special-evenly-spaced-elements-in-array/README.md new file mode 100644 index 000000000..744ddf074 --- /dev/null +++ b/problems/sum-of-special-evenly-spaced-elements-in-array/README.md @@ -0,0 +1,30 @@ + + + + + + + +[< Previous](../minimum-operations-to-make-a-subsequence "Minimum Operations to Make a Subsequence") +                 +[Next >](../count-apples-and-oranges "Count Apples and Oranges") + +## [1714. Sum Of Special Evenly-Spaced Elements In Array (Hard)](https://leetcode.com/problems/sum-of-special-evenly-spaced-elements-in-array "") + + + +### Hints +
    +Hint 1 +Think if y cannot be small. You can solve a query in O(n/y), so if y is large enough, it won't be a problem. +
    + +
    +Hint 2 +If y is small, like less than B, you can preprocess the answers for all such ys in O(n * B), then answer each such query in O(1). +
    + +
    +Hint 3 +As you might have already guessed, the optimal value for B is ~sqrt(n). +
    diff --git a/problems/super-palindromes/README.md b/problems/super-palindromes/README.md index e472475a6..b0abe0157 100644 --- a/problems/super-palindromes/README.md +++ b/problems/super-palindromes/README.md @@ -11,34 +11,37 @@ ## [906. Super Palindromes (Hard)](https://leetcode.com/problems/super-palindromes "超级回文数") -

    Let's say a positive integer is a superpalindrome if it is a palindrome, and it is also the square of a palindrome.

    +

    Let's say a positive integer is a super-palindrome if it is a palindrome, and it is also the square of a palindrome.

    -

    Now, given two positive integers L and R (represented as strings), return the number of superpalindromes in the inclusive range [L, R].

    +

    Given two positive integers left and right represented as strings, return the number of super-palindromes integers in the inclusive range [left, right].

     

    -

    Example 1:

    -Input: L = "4", R = "1000"
    -Output: 4
    -Explanation: 4, 9, 121, and 484 are superpalindromes.
    -Note that 676 is not a superpalindrome: 26 * 26 = 676, but 26 is not a palindrome.
    - -

     

    +Input: left = "4", right = "1000" +Output: 4 +Explanation: 4, 9, 121, and 484 are superpalindromes. +Note that 676 is not a superpalindrome: 26 * 26 = 676, but 26 is not a palindrome. +
    -

    Note:

    +

    Example 2:

    -
      -
    1. 1 <= len(L) <= 18
    2. -
    3. 1 <= len(R) <= 18
    4. -
    5. L and R are strings representing integers in the range [1, 10^18).
    6. -
    7. int(L) <= int(R)
    8. -
    +
    +Input: left = "1", right = "2"
    +Output: 1
    +
    -

     

    -
    +

    Constraints:

    + +
      +
    • 1 <= left.length, right.length <= 18
    • +
    • left and right consist of only digits.
    • +
    • left and right cannot have leading zeros.
    • +
    • left and right represent integers in the range [1, 1018].
    • +
    • left is less than or equal to right.
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/surface-area-of-3d-shapes/README.md b/problems/surface-area-of-3d-shapes/README.md index ee4fe1698..03eb25c6d 100644 --- a/problems/surface-area-of-3d-shapes/README.md +++ b/problems/surface-area-of-3d-shapes/README.md @@ -11,76 +11,57 @@ ## [892. Surface Area of 3D Shapes (Easy)](https://leetcode.com/problems/surface-area-of-3d-shapes "三维形体的表面积") -

    On a N * N grid, we place some 1 * 1 * 1 cubes.

    +

    You are given an n x n grid where we can place some 1 x 1 x 1 cubes.

    -

    Each value v = grid[i][j] represents a tower of v cubes placed on top of grid cell (i, j).

    +

    Each value v = grid[i][j] represents a tower of v cubes placed on top of the grid cell (i, j).

    -

    Return the total surface area of the resulting shapes.

    +

    Return the total surface area of the resulting shapes.

     

    - -
    -
    -
    -
      -
    -
    -
    -
    - -

    Example 1:

    - +
    -Input: [[2]]
    -Output: 10
    +Input: grid = [[2]]
    +Output: 10
     
    -

    Example 2:

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

    Example 3:

    - +
    -Input: [[1,0],[0,2]]
    -Output: 16
    +Input: grid = [[1,0],[0,2]]
    +Output: 16
     
    -

    Example 4:

    - +
    -Input: [[1,1,1],[1,0,1],[1,1,1]]
    -Output: 32
    +Input: grid = [[1,1,1],[1,0,1],[1,1,1]]
    +Output: 32
     
    -

    Example 5:

    - +
    -Input: [[2,2,2],[2,1,2],[2,2,2]]
    -Output: 46
    +Input: grid = [[2,2,2],[2,1,2],[2,2,2]]
    +Output: 46
     

     

    - -

    Note:

    +

    Constraints:

      -
    • 1 <= N <= 50
    • +
    • n == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= n <= 50
    • 0 <= grid[i][j] <= 50
    -
    -
    -
    -
    -
    ### Related Topics [[Geometry](../../tag/geometry/README.md)] diff --git a/problems/swap-nodes-in-pairs/README.md b/problems/swap-nodes-in-pairs/README.md index a16086aa5..12e7ad620 100644 --- a/problems/swap-nodes-in-pairs/README.md +++ b/problems/swap-nodes-in-pairs/README.md @@ -13,8 +13,6 @@

    Given a linked list, swap every two adjacent nodes and return its head.

    -

    You may not modify the values in the list's nodes. Only nodes itself may be changed.

    -

     

    Example 1:

    @@ -45,6 +43,9 @@
  • 0 <= Node.val <= 100
  • +

     

    +Follow up: Can you solve the problem without modifying the values in the list's nodes? (i.e., Only nodes themselves may be changed.) + ### Related Topics [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/swapping-nodes-in-a-linked-list/README.md b/problems/swapping-nodes-in-a-linked-list/README.md new file mode 100644 index 000000000..22814398a --- /dev/null +++ b/problems/swapping-nodes-in-a-linked-list/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../decode-xored-array "Decode XORed Array") +                 +[Next >](../minimize-hamming-distance-after-swap-operations "Minimize Hamming Distance After Swap Operations") + +## [1721. Swapping Nodes in a Linked List (Medium)](https://leetcode.com/problems/swapping-nodes-in-a-linked-list "交换链表中的节点") + +

    You are given the head of a linked list, and an integer k.

    + +

    Return the head of the linked list after swapping the values of the kth node from the beginning and the kth node from the end (the list is 1-indexed).

    + +

     

    +

    Example 1:

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

    Example 2:

    + +
    +Input: head = [7,9,6,6,7,8,3,0,9,5], k = 5
    +Output: [7,9,6,6,8,7,3,0,9,5]
    +
    + +

    Example 3:

    + +
    +Input: head = [1], k = 1
    +Output: [1]
    +
    + +

    Example 4:

    + +
    +Input: head = [1,2], k = 1
    +Output: [2,1]
    +
    + +

    Example 5:

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

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is n.
    • +
    • 1 <= k <= n <= 105
    • +
    • 0 <= Node.val <= 100
    • +
    + +### Related Topics + [[Linked List](../../tag/linked-list/README.md)] + +### Hints +
    +Hint 1 +We can transform the linked list to an array this should ease things up +
    + +
    +Hint 2 +After transforming the linked list to an array it becomes as easy as swapping two integers in an array then rebuilding the linked list +
    diff --git a/problems/the-earliest-moment-when-everyone-become-friends/README.md b/problems/the-earliest-moment-when-everyone-become-friends/README.md index 555bde857..1d17ee123 100644 --- a/problems/the-earliest-moment-when-everyone-become-friends/README.md +++ b/problems/the-earliest-moment-when-everyone-become-friends/README.md @@ -55,7 +55,7 @@ The sixth event occurs at timestamp = 20190301 and after 0 and 3 become friends [[Union Find](../../tag/union-find/README.md)] ### Similar Questions - 1. [Friend Circles](../friend-circles) (Medium) + 1. [Number of Provinces](../number-of-provinces) (Medium) ### Hints
    diff --git a/problems/third-maximum-number/README.md b/problems/third-maximum-number/README.md index e9f44de98..3fad785b5 100644 --- a/problems/third-maximum-number/README.md +++ b/problems/third-maximum-number/README.md @@ -11,38 +11,44 @@ ## [414. Third Maximum Number (Easy)](https://leetcode.com/problems/third-maximum-number "第三大的数") -

    Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).

    +

    Given integer array nums, return the third maximum number in this array. If the third maximum does not exist, return the maximum number.

    -

    Example 1:
    -

    -Input: [3, 2, 1]
    -
    -Output: 1
    +

     

    +

    Example 1:

    -Explanation: The third maximum is 1. +
    +Input: nums = [3,2,1]
    +Output: 1
    +Explanation: The third maximum is 1.
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: [1, 2]
    +Input: nums = [1,2]
    +Output: 2
    +Explanation: The third maximum does not exist, so the maximum (2) is returned instead.
    +
    -Output: 2 +

    Example 3:

    -Explanation: The third maximum does not exist, so the maximum (2) is returned instead. +
    +Input: nums = [2,2,3,1]
    +Output: 1
    +Explanation: Note that the third maximum here means the third maximum distinct number.
    +Both numbers with value 2 are both considered as second maximum.
     
    -

    -

    Example 3:
    -

    -Input: [2, 2, 3, 1]
    +

     

    +

    Constraints:

    -Output: 1 +
      +
    • 1 <= nums.length <= 104
    • +
    • 231 <= nums[i] <= 231 - 1
    • +
    -Explanation: Note that the third maximum here means the third maximum distinct number. -Both numbers with value 2 are both considered as second maximum. -
    -

    +

     

    +Follow up: Can you find an O(n) solution? ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/triangle/README.md b/problems/triangle/README.md index d7612fbb3..645657618 100644 --- a/problems/triangle/README.md +++ b/problems/triangle/README.md @@ -13,7 +13,7 @@

    Given a triangle array, return the minimum path sum from top to bottom.

    -

    For each step, you may move to an adjacent number on the row below.

    +

    For each step, you may move to an adjacent number of the row below. More formally, if you are on index i on the current row, you may move to either index i or index i + 1 on the next row.

     

    Example 1:

    @@ -21,7 +21,12 @@
     Input: triangle = [[2],[3,4],[6,5,7],[4,1,8,3]]
     Output: 11
    -Explanation: The minimum path sum from top to bottom is 11 (i.e., 2 + 3 + 5 + 1 = 11).
    +Explanation: The triangle looks like:
    +   2
    +  3 4
    + 6 5 7
    +4 1 8 3
    +The minimum path sum from top to bottom is 2 + 3 + 5 + 1 = 11 (underlined above).
     

    Example 2:

    diff --git a/problems/verbal-arithmetic-puzzle/README.md b/problems/verbal-arithmetic-puzzle/README.md index 0724fe028..bdf37791c 100644 --- a/problems/verbal-arithmetic-puzzle/README.md +++ b/problems/verbal-arithmetic-puzzle/README.md @@ -60,9 +60,9 @@ Such that: "SIX" + "SEVEN" + "SEVEN" = "TWENT
    • 2 <= words.length <= 5
    • -
    • 1 <= words[i].length, result.length <= 7
    • -
    • words[i], result contains only upper case English letters.
    • -
    • Number of different characters used on the expression is at most 10.
    • +
    • 1 <= words[i].length, result.length <= 7
    • +
    • words[i], result contain only uppercase English letters.
    • +
    • The number of different characters used in the expression is at most 10.
    ### Related Topics diff --git a/problems/vertical-order-traversal-of-a-binary-tree/README.md b/problems/vertical-order-traversal-of-a-binary-tree/README.md index ed7f0aecd..0830cfee7 100644 --- a/problems/vertical-order-traversal-of-a-binary-tree/README.md +++ b/problems/vertical-order-traversal-of-a-binary-tree/README.md @@ -11,61 +11,43 @@ ## [987. Vertical Order Traversal of a Binary Tree (Medium)](https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree "二叉树的垂序遍历") -

    Given a binary tree, return the vertical order traversal of its nodes values.

    +

    Given the root of a binary tree, return the vertical order traversal of its nodes values.

    -

    For each node at position (X, Y), its left and right children respectively will be at positions (X-1, Y-1) and (X+1, Y-1).

    +

    For each node at position (x, y), its left and right children respectively will be at positions (x - 1, y - 1) and (x + 1, y - 1).

    -

    Running a vertical line from X = -infinity to X = +infinity, whenever the vertical line touches some nodes, we report the values of the nodes in order from top to bottom (decreasing Y coordinates).

    +

    Running a vertical line from x = -∞ to x = +∞, whenever the vertical line touches some nodes, we report the values of the nodes in order from top to bottom (decreasing y coordinates).

    If two nodes have the same position, then the value of the node that is reported first is the value that is smaller.

    -

    Return an list of non-empty reports in order of X coordinate.  Every report will have a list of values of nodes.

    +

    Return a list of non-empty reports in order of x coordinate. Every report will have a list of values of nodes.

     

    -

    Example 1:

    - -

    - -
    +
    -Input: [3,9,20,null,null,15,7]
    -Output: [[9],[3,15],[20],[7]]
    -Explanation: 
    -Without loss of generality, we can assume the root node is at position (0, 0):
    +Input: root = [3,9,20,null,null,15,7]
    +Output: [[9],[3,15],[20],[7]]
    +Explanation: Without loss of generality, we can assume the root node is at position (0, 0):
     Then, the node with value 9 occurs at position (-1, -1);
     The nodes with values 3 and 15 occur at positions (0, 0) and (0, -2);
     The node with value 20 occurs at position (1, -1);
    -The node with value 7 occurs at position (2, -2).
    -
    +The node with value 7 occurs at position (2, -2).
    -

    Example 2:

    - -

    - +
    -Input: [1,2,3,4,5,6,7]
    -Output: [[4],[2],[1,5,6],[3],[7]]
    -Explanation: 
    -The node with value 5 and the node with value 6 have the same position according to the given scheme.
    -However, in the report "[1,5,6]", the node value of 5 comes first since 5 is smaller than 6.
    -
    +Input: root = [1,2,3,4,5,6,7] +Output: [[4],[2],[1,5,6],[3],[7]] +Explanation: The node with value 5 and the node with value 6 have the same position according to the given scheme. +However, in the report "[1,5,6]", the node value of 5 comes first since 5 is smaller than 6.

     

    - - -

    Note:

    - -
      -
    1. The tree will have between 1 and 1000 nodes.
    2. -
    3. Each node's value will be between 0 and 1000.
    4. -
    - +

    Constraints:

    -
    -
     
    -
    +
      +
    • The number of nodes in the tree is in the range [1, 1000].
    • +
    • 0 <= Node.val <= 1000
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/walking-robot-simulation/README.md b/problems/walking-robot-simulation/README.md index 94341741b..4b1ec763f 100644 --- a/problems/walking-robot-simulation/README.md +++ b/problems/walking-robot-simulation/README.md @@ -11,53 +11,47 @@ ## [874. Walking Robot Simulation (Easy)](https://leetcode.com/problems/walking-robot-simulation "模拟行走机器人") -

    A robot on an infinite grid starts at point (0, 0) and faces north.  The robot can receive one of three possible types of commands:

    +

    A robot on an infinite grid starts at point (0, 0) and faces north. The robot can receive one of three possible types of commands:

      -
    • -2: turn left 90 degrees
    • -
    • -1: turn right 90 degrees
    • +
    • -2: turn left 90 degrees,
    • +
    • -1: turn right 90 degrees, or
    • 1 <= x <= 9: move forward x units
    -

    Some of the grid squares are obstacles. 

    - -

    The i-th obstacle is at grid point (obstacles[i][0], obstacles[i][1])

    +

    Some of the grid squares are obstacles. The ith obstacle is at grid point obstacles[i] = (xi, yi).

    If the robot would try to move onto them, the robot stays on the previous grid square instead (but still continues following the rest of the route.)

    -

    Return the square of the maximum Euclidean distance that the robot will be from the origin.

    +

    Return the square of the maximum Euclidean distance that the robot will be from the origin.

     

    -

    Example 1:

    -Input: commands = [4,-1,3], obstacles = []
    -Output: 25
    -Explanation: robot will go to (3, 4)
    +Input: commands = [4,-1,3], obstacles = []
    +Output: 25
    +Explanation: robot will go to (3, 4)
     
    -

    Example 2:

    -Input: commands = [4,-1,4,-2,4], obstacles = [[2,4]]
    -Output: 65
    -Explanation: robot will be stuck at (1, 4) before turning left and going to (1, 8)
    +Input: commands = [4,-1,4,-2,4], obstacles = [[2,4]]
    +Output: 65
    +Explanation: robot will be stuck at (1, 4) before turning left and going to (1, 8)
     
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 0 <= commands.length <= 10000
    2. -
    3. 0 <= obstacles.length <= 10000
    4. -
    5. -30000 <= obstacle[i][0] <= 30000
    6. -
    7. -30000 <= obstacle[i][1] <= 30000
    8. -
    9. The answer is guaranteed to be less than 2 ^ 31.
    10. -
    +
      +
    • 1 <= commands.length <= 104
    • +
    • commands[i] is in the list [-2,-1,1,2,3,4,5,6,7,8,9].
    • +
    • 0 <= obstacles.length <= 104
    • +
    • -3 * 104 <= xi, yi <= 3 * 104
    • +
    • The answer is guaranteed to be less than 231.
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/ways-to-split-array-into-three-subarrays/README.md b/problems/ways-to-split-array-into-three-subarrays/README.md new file mode 100644 index 000000000..2f3ca03c7 --- /dev/null +++ b/problems/ways-to-split-array-into-three-subarrays/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../count-good-meals "Count Good Meals") +                 +[Next >](../minimum-operations-to-make-a-subsequence "Minimum Operations to Make a Subsequence") + +## [1712. Ways to Split Array Into Three Subarrays (Medium)](https://leetcode.com/problems/ways-to-split-array-into-three-subarrays "将数组分成三个子数组的方案数") + +

    A split of an integer array is good if:

    + +
      +
    • The array is split into three non-empty contiguous subarrays - named left, mid, right respectively from left to right.
    • +
    • The sum of the elements in left is less than or equal to the sum of the elements in mid, and the sum of the elements in mid is less than or equal to the sum of the elements in right.
    • +
    + +

    Given nums, an array of non-negative integers, return the number of good ways to split nums. As the number may be too large, return it modulo 109 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,1,1]
    +Output: 1
    +Explanation: The only good way to split nums is [1] [1] [1].
    + +

    Example 2:

    + +
    +Input: nums = [1,2,2,2,5,0]
    +Output: 3
    +Explanation: There are three good ways of splitting nums:
    +[1] [2] [2,2,5,0]
    +[1] [2,2] [2,5,0]
    +[1,2] [2,2] [5,0]
    +
    + +

    Example 3:

    + +
    +Input: nums = [3,2,1]
    +Output: 0
    +Explanation: There is no good way to split nums.
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= nums.length <= 105
    • +
    • 0 <= nums[i] <= 104
    • +
    + +### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Create a prefix array to efficiently find the sum of subarrays. +
    + +
    +Hint 2 +As we are dividing the array into three subarrays, there are two "walls". Iterate over the right wall positions and find where the left wall could be for each right wall position. +
    + +
    +Hint 3 +Use binary search to find the left-most position and right-most position the left wall could be. +
    diff --git a/problems/where-will-the-ball-fall/README.md b/problems/where-will-the-ball-fall/README.md index ee6f59080..dd4891085 100644 --- a/problems/where-will-the-ball-fall/README.md +++ b/problems/where-will-the-ball-fall/README.md @@ -48,6 +48,13 @@ Ball b4 is dropped at column 4 and will get stuck on the box between column 2 an Explanation: The ball gets stuck against the left wall. +

    Example 3:

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

     

    Constraints:

    diff --git a/problems/wiggle-sort-ii/README.md b/problems/wiggle-sort-ii/README.md index 7843a9470..78a401a1b 100644 --- a/problems/wiggle-sort-ii/README.md +++ b/problems/wiggle-sort-ii/README.md @@ -11,25 +11,37 @@ ## [324. Wiggle Sort II (Medium)](https://leetcode.com/problems/wiggle-sort-ii "摆动排序 II") -

    Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]....

    +

    Given an integer array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]....

    -

    Example 1:

    +

    You may assume the input array always has a valid answer.

    + +

     

    +

    Example 1:

    -Input: nums = [1, 5, 1, 1, 6, 4]
    -Output: One possible answer is [1, 4, 1, 5, 1, 6].
    +Input: nums = [1,5,1,1,6,4] +Output: [1,6,1,5,1,4] +Explanation: [1,4,1,5,1,6] is also accepted. + -

    Example 2:

    +

    Example 2:

    -Input: nums = [1, 3, 2, 2, 3, 1]
    -Output: One possible answer is [2, 3, 1, 3, 1, 2].
    +Input: nums = [1,3,2,2,3,1] +Output: [2,3,1,3,1,2] + + +

     

    +

    Constraints:

    -

    Note:
    -You may assume all input has valid answer.

    +
      +
    • 1 <= nums.length <= 5 * 104
    • +
    • 0 <= nums[i] <= 5000
    • +
    • It is guaranteed that there will be an answer for the given input nums.
    • +
    -

    Follow Up:
    -Can you do it in O(n) time and/or in-place with O(1) extra space?

    +

     

    +Follow Up: Can you do it in O(n) time and/or in-place with O(1) extra space? ### Related Topics [[Sort](../../tag/sort/README.md)] diff --git a/readme/301-600.md b/readme/301-600.md index fb99096b5..026123fec 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -169,7 +169,7 @@ LeetCode Problems' Solutions | 397 | [Integer Replacement](https://leetcode.com/problems/integer-replacement "整数替换") | [Go](../problems/integer-replacement) | Medium | | 398 | [Random Pick Index](https://leetcode.com/problems/random-pick-index "随机数索引") | [Go](../problems/random-pick-index) | Medium | | 399 | [Evaluate Division](https://leetcode.com/problems/evaluate-division "除法求值") | [Go](../problems/evaluate-division) | Medium | -| 400 | [Nth Digit](https://leetcode.com/problems/nth-digit "第N个数字") | [Go](../problems/nth-digit) | Medium | +| 400 | [Nth Digit](https://leetcode.com/problems/nth-digit "第 N 位数字") | [Go](../problems/nth-digit) | Medium | | 401 | [Binary Watch](https://leetcode.com/problems/binary-watch "二进制手表") | [Go](../problems/binary-watch) | Easy | | 402 | [Remove K Digits](https://leetcode.com/problems/remove-k-digits "移掉K位数字") | [Go](../problems/remove-k-digits) | Medium | | 403 | [Frog Jump](https://leetcode.com/problems/frog-jump "青蛙过河") | [Go](../problems/frog-jump) | Hard | @@ -316,7 +316,7 @@ LeetCode Problems' Solutions | 544 | [Output Contest Matches](https://leetcode.com/problems/output-contest-matches "输出比赛匹配对") 🔒 | [Go](../problems/output-contest-matches) | Medium | | 545 | [Boundary of Binary Tree](https://leetcode.com/problems/boundary-of-binary-tree "二叉树的边界") 🔒 | [Go](../problems/boundary-of-binary-tree) | Medium | | 546 | [Remove Boxes](https://leetcode.com/problems/remove-boxes "移除盒子") | [Go](../problems/remove-boxes) | Hard | -| 547 | [Friend Circles](https://leetcode.com/problems/friend-circles "朋友圈") | [Go](../problems/friend-circles) | Medium | +| 547 | [Number of Provinces](https://leetcode.com/problems/number-of-provinces "省份数量") | [Go](../problems/number-of-provinces) | Medium | | 548 | [Split Array with Equal Sum](https://leetcode.com/problems/split-array-with-equal-sum "将数组分割成和相等的子数组") 🔒 | [Go](../problems/split-array-with-equal-sum) | Medium | | 549 | [Binary Tree Longest Consecutive Sequence II](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence-ii "二叉树中最长的连续序列") 🔒 | [Go](../problems/binary-tree-longest-consecutive-sequence-ii) | Medium | | 550 | [Game Play Analysis IV](https://leetcode.com/problems/game-play-analysis-iv "游戏玩法分析 IV") 🔒 | [MySQL](../problems/game-play-analysis-iv) | Medium | diff --git a/readme/601-900.md b/readme/601-900.md index e447a681d..4fc035be6 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -113,7 +113,7 @@ LeetCode Problems' Solutions | 641 | [Design Circular Deque](https://leetcode.com/problems/design-circular-deque "设计循环双端队列") | [Go](../problems/design-circular-deque) | Medium | | 642 | [Design Search Autocomplete System](https://leetcode.com/problems/design-search-autocomplete-system "设计搜索自动补全系统") 🔒 | [Go](../problems/design-search-autocomplete-system) | Hard | | 643 | [Maximum Average Subarray I](https://leetcode.com/problems/maximum-average-subarray-i "子数组最大平均数 I") | [Go](../problems/maximum-average-subarray-i) | Easy | -| 644 | [Maximum Average Subarray II](https://leetcode.com/problems/maximum-average-subarray-ii "最大平均子段和 II") 🔒 | [Go](../problems/maximum-average-subarray-ii) | Hard | +| 644 | [Maximum Average Subarray II](https://leetcode.com/problems/maximum-average-subarray-ii "子数组最大平均数 II") 🔒 | [Go](../problems/maximum-average-subarray-ii) | Hard | | 645 | [Set Mismatch](https://leetcode.com/problems/set-mismatch "错误的集合") | [Go](../problems/set-mismatch) | Easy | | 646 | [Maximum Length of Pair Chain](https://leetcode.com/problems/maximum-length-of-pair-chain "最长数对链") | [Go](../problems/maximum-length-of-pair-chain) | Medium | | 647 | [Palindromic Substrings](https://leetcode.com/problems/palindromic-substrings "回文子串") | [Go](../problems/palindromic-substrings) | Medium | diff --git a/tag/array/README.md b/tag/array/README.md index db6a5e763..2aff55126 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,13 +9,15 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1708 | [Largest Subarray Length K](../../problems/largest-subarray-length-k) 🔒 | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 1701 | [平均等待时间](../../problems/average-waiting-time) | [[数组](../array/README.md)] | Medium | | 1700 | [无法吃午餐的学生数量](../../problems/number-of-students-unable-to-eat-lunch) | [[数组](../array/README.md)] | Easy | | 1672 | [最富有客户的资产总量](../../problems/richest-customer-wealth) | [[数组](../array/README.md)] | Easy | | 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Easy | | 1652 | [拆炸弹](../../problems/defuse-the-bomb) | [[数组](../array/README.md)] | Easy | | 1646 | [获取生成数组中的最大值](../../problems/get-maximum-in-generated-array) | [[数组](../array/README.md)] | Easy | -| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 1636 | [按照频率将数组升序排序](../../problems/sort-array-by-increasing-frequency) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | | 1629 | [按键持续时间最长的键](../../problems/slowest-key) | [[数组](../array/README.md)] | Easy | | 1619 | [删除某些元素后的数组均值](../../problems/mean-of-array-after-removing-some-elements) | [[数组](../array/README.md)] | Easy | @@ -206,7 +208,7 @@ | 667 | [优美的排列 II](../../problems/beautiful-arrangement-ii) | [[数组](../array/README.md)] | Medium | | 665 | [非递减数列](../../problems/non-decreasing-array) | [[数组](../array/README.md)] | Easy | | 661 | [图片平滑器](../../problems/image-smoother) | [[数组](../array/README.md)] | Easy | -| 644 | [最大平均子段和 II](../../problems/maximum-average-subarray-ii) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 644 | [子数组最大平均数 II](../../problems/maximum-average-subarray-ii) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 643 | [子数组最大平均数 I](../../problems/maximum-average-subarray-i) | [[数组](../array/README.md)] | Easy | | 628 | [三个数的最大乘积](../../problems/maximum-product-of-three-numbers) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index fce6888d9..3d7addb8b 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1688 | [比赛中的配对次数](../../problems/count-of-matches-in-tournament) | [[回溯算法](../backtracking/README.md)] | Easy | | 1681 | [最小不兼容性](../../problems/minimum-incompatibility) | [[贪心算法](../greedy/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | @@ -37,7 +39,7 @@ | 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 526 | [优美的排列](../../problems/beautiful-arrangement) | [[回溯算法](../backtracking/README.md)] | Medium | +| 526 | [优美的排列](../../problems/beautiful-arrangement) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 425 | [单词方块](../../problems/word-squares) 🔒 | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 411 | [最短特异单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 401 | [二进制手表](../../problems/binary-watch) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | diff --git a/tag/binary-indexed-tree/README.md b/tag/binary-indexed-tree/README.md index de58cc980..c899b2671 100644 --- a/tag/binary-indexed-tree/README.md +++ b/tag/binary-indexed-tree/README.md @@ -9,10 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 308 | [二维区域和检索 - 可变](../../problems/range-sum-query-2d-mutable) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Hard | -| 307 | [区域和检索 - 数组可修改](../../problems/range-sum-query-mutable) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Medium | -| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/binary-search-tree/README.md b/tag/binary-search-tree/README.md index 0d508d4e1..43b103e11 100644 --- a/tag/binary-search-tree/README.md +++ b/tag/binary-search-tree/README.md @@ -9,7 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1382 | [将二叉搜索树变平衡](../../problems/balance-a-binary-search-tree) | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | -| 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | -| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 155852663..6379fffed 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,7 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | | 1642 | [可以到达的最远建筑](../../problems/furthest-building-you-can-reach) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -59,7 +61,7 @@ | 702 | [搜索长度未知的有序数组](../../problems/search-in-a-sorted-array-of-unknown-size) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | | 668 | [乘法表中第k小的数](../../problems/kth-smallest-number-in-multiplication-table) | [[二分查找](../binary-search/README.md)] | Hard | | 658 | [找到 K 个最接近的元素](../../problems/find-k-closest-elements) | [[二分查找](../binary-search/README.md)] | Medium | -| 644 | [最大平均子段和 II](../../problems/maximum-average-subarray-ii) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 644 | [子数组最大平均数 II](../../problems/maximum-average-subarray-ii) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 540 | [有序数组中的单一元素](../../problems/single-element-in-a-sorted-array) | [[二分查找](../binary-search/README.md)] | Medium | | 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | | 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index fc676bb79..88d28a8bc 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1720 | [解码异或后的数组](../../problems/decode-xored-array) | [[位运算](../bit-manipulation/README.md)] | Easy | | 1707 | [与数组中元素的最大异或值](../../problems/maximum-xor-with-an-element-from-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Hard | | 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Hard | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 0bfc32364..e5a4936b5 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -15,6 +15,7 @@ | 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | | 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 1345 | [跳跃游戏 IV](../../problems/jump-game-iv) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index d7abc14a2..61e398909 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,7 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1676 | [Lowest Common Ancestor of a Binary Tree IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[贪心算法](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1625 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | @@ -25,6 +26,7 @@ | 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | | 1377 | [T 秒后青蛙的位置](../../problems/frog-position-after-t-seconds) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | | 1376 | [通知所有员工所需的时间](../../problems/time-needed-to-inform-all-employees) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | @@ -94,12 +96,13 @@ | 576 | [出界的路径数](../../problems/out-of-boundary-paths) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 559 | [N 叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 547 | [朋友圈](../../problems/friend-circles) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 547 | [省份数量](../../problems/number-of-provinces) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 546 | [移除盒子](../../problems/remove-boxes) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 542 | [01 矩阵](../../problems/01-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 533 | [孤独像素 II](../../problems/lonely-pixel-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 531 | [孤独像素 I](../../problems/lonely-pixel-i) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 529 | [扫雷游戏](../../problems/minesweeper) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 526 | [优美的排列](../../problems/beautiful-arrangement) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 882b2c7e5..cce163a3a 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,3 +9,244 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1706 | [球会落何处](../../problems/where-will-the-ball-fall) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1692 | [计算分配糖果的不同方式](../../problems/count-ways-to-distribute-candies) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1691 | [堆叠长方体的最大高度](../../problems/maximum-height-by-stacking-cuboids) | [[排序](../sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1690 | [石子游戏 VII](../../problems/stone-game-vii) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1682 | [最长回文子序列 II](../../problems/longest-palindromic-subsequence-ii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1671 | [得到山形数组的最少删除次数](../../problems/minimum-number-of-removals-to-make-mountain-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1664 | [生成平衡数组的方案数](../../problems/ways-to-make-a-fair-array) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1654 | [到家的最少跳跃次数](../../problems/minimum-jumps-to-reach-home) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1643 | [第 K 条最小指令](../../problems/kth-smallest-instructions) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1639 | [通过给定词典构造目标字符串的方案数](../../problems/number-of-ways-to-form-a-target-string-given-a-dictionary) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1626 | [无矛盾的最佳球队](../../problems/best-team-with-no-conflicts) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1621 | [大小为 K 的不重叠线段的数目](../../problems/number-of-sets-of-k-non-overlapping-line-segments) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1563 | [石子游戏 V](../../problems/stone-game-v) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1553 | [吃掉 N 个橘子的最少天数](../../problems/minimum-number-of-days-to-eat-n-oranges) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1548 | [图中最相似的路径](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1547 | [切棍子的最小成本](../../problems/minimum-cost-to-cut-a-stick) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1546 | [和为目标值的最大数目不重叠非空子数组数目](../../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1537 | [最大得分](../../problems/get-the-maximum-score) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1510 | [石子游戏 IV](../../problems/stone-game-iv) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1504 | [统计全 1 子矩形](../../problems/count-submatrices-with-all-ones) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1483 | [树节点的第 K 个祖先](../../problems/kth-ancestor-of-a-tree-node) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1477 | [找两个和为目标值且不重叠的子数组](../../problems/find-two-non-overlapping-sub-arrays-each-with-target-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1473 | [给房子涂色 III](../../problems/paint-house-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1463 | [摘樱桃 II](../../problems/cherry-pickup-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1458 | [两个子序列的最大点积](../../problems/max-dot-product-of-two-subsequences) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1444 | [切披萨的方案数](../../problems/number-of-ways-of-cutting-a-pizza) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1425 | [带限制的子序列和](../../problems/constrained-subsequence-sum) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1420 | [生成数组](../../problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1416 | [恢复数组](../../problems/restore-the-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1411 | [给 N x 3 网格图涂色的方案数](../../problems/number-of-ways-to-paint-n-x-3-grid) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1406 | [石子游戏 III](../../problems/stone-game-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1402 | [做菜顺序](../../problems/reducing-dishes) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1397 | [找到所有好字符串](../../problems/find-all-good-strings) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1388 | [3n 块披萨](../../problems/pizza-with-3n-slices) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1359 | [有效的快递序列数目](../../problems/count-all-valid-pickup-and-delivery-options) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1349 | [参加考试的最大学生数](../../problems/maximum-students-taking-exam) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1340 | [跳跃游戏 V](../../problems/jump-game-v) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1335 | [工作计划的最低难度](../../problems/minimum-difficulty-of-a-job-schedule) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1326 | [灌溉花园的最少水龙头数目](../../problems/minimum-number-of-taps-to-open-to-water-a-garden) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1320 | [二指输入的的最小距离](../../problems/minimum-distance-to-type-a-word-using-two-fingers) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1314 | [矩阵区域和](../../problems/matrix-block-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1312 | [让字符串成为回文串的最少插入次数](../../problems/minimum-insertion-steps-to-make-a-string-palindrome) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1301 | [最大得分的路径数目](../../problems/number-of-paths-with-max-score) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1289 | [下降路径最小和 II](../../problems/minimum-falling-path-sum-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1278 | [分割回文串 III](../../problems/palindrome-partitioning-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1277 | [统计全为 1 的正方形子矩阵](../../problems/count-square-submatrices-with-all-ones) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1273 | [删除树节点](../../problems/delete-tree-nodes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1269 | [停在原地的方案数](../../problems/number-of-ways-to-stay-in-the-same-place-after-some-steps) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1262 | [可被三整除的最大和](../../problems/greatest-sum-divisible-by-three) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1259 | [不相交的握手](../../problems/handshakes-that-dont-cross) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1246 | [删除回文子数组](../../problems/palindrome-removal) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1240 | [铺瓷砖](../../problems/tiling-a-rectangle-with-the-fewest-squares) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1230 | [抛掷硬币](../../problems/toss-strange-coins) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1223 | [掷骰子模拟](../../problems/dice-roll-simulation) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1220 | [统计元音字母序列的数目](../../problems/count-vowels-permutation) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1216 | [验证回文字符串 III](../../problems/valid-palindrome-iii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1199 | [建造街区的最短时间](../../problems/minimum-time-to-build-blocks) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1191 | [K 次串联后最大子数组之和](../../problems/k-concatenation-maximum-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1187 | [使数组严格递增](../../problems/make-array-strictly-increasing) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1186 | [删除一次得到子数组最大和](../../problems/maximum-subarray-sum-with-one-deletion) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1155 | [掷骰子的N种方法](../../problems/number-of-dice-rolls-with-target-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1147 | [段式回文](../../problems/longest-chunked-palindrome-decomposition) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1143 | [最长公共子序列](../../problems/longest-common-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1140 | [石子游戏 II](../../problems/stone-game-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1139 | [最大的以 1 为边界的正方形](../../problems/largest-1-bordered-square) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1125 | [最小的必要团队](../../problems/smallest-sufficient-team) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1105 | [填充书架](../../problems/filling-bookcase-shelves) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1092 | [最短公共超序列](../../problems/shortest-common-supersequence) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 1067 | [范围内的数字计数](../../problems/digit-count-in-range) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1055 | [形成字符串的最短路径](../../problems/shortest-way-to-form-string) 🔒 | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1049 | [最后一块石头的重量 II](../../problems/last-stone-weight-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1048 | [最长字符串链](../../problems/longest-string-chain) | [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1043 | [分隔数组以得到最大和](../../problems/partition-array-for-maximum-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1039 | [多边形三角剖分的最低得分](../../problems/minimum-score-triangulation-of-polygon) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1027 | [最长等差数列](../../problems/longest-arithmetic-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1025 | [除数博弈](../../problems/divisor-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 1024 | [视频拼接](../../problems/video-stitching) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1012 | [至少有 1 位重复的数字](../../problems/numbers-with-repeated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1000 | [合并石头的最低成本](../../problems/minimum-cost-to-merge-stones) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 983 | [最低票价](../../problems/minimum-cost-for-tickets) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 982 | [按位与为零的三元组](../../problems/triples-with-bitwise-and-equal-to-zero) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 964 | [表示数字的最少运算符](../../problems/least-operators-to-express-number) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 960 | [删列造序 III](../../problems/delete-columns-to-make-sorted-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 956 | [最高的广告牌](../../problems/tallest-billboard) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 943 | [最短超级串](../../problems/find-the-shortest-superstring) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 940 | [不同的子序列 II](../../problems/distinct-subsequences-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 935 | [骑士拨号器](../../problems/knight-dialer) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 931 | [下降路径最小和](../../problems/minimum-falling-path-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 920 | [播放列表的数量](../../problems/number-of-music-playlists) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 903 | [DI 序列的有效排列](../../problems/valid-permutations-for-di-sequence) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 902 | [最大为 N 的数字组合](../../problems/numbers-at-most-n-given-digit-set) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 898 | [子数组按位或操作](../../problems/bitwise-ors-of-subarrays) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 879 | [盈利计划](../../problems/profitable-schemes) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 877 | [石子游戏](../../problems/stone-game) | [[极小化极大](../minimax/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 871 | [最低加油次数](../../problems/minimum-number-of-refueling-stops) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 837 | [新21点](../../problems/new-21-game) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 818 | [赛车](../../problems/race-car) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 813 | [最大平均值和的分组](../../problems/largest-sum-of-averages) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 808 | [分汤](../../problems/soup-servings) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 801 | [使序列递增的最小交换次数](../../problems/minimum-swaps-to-make-sequences-increasing) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 799 | [香槟塔](../../problems/champagne-tower) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 790 | [多米诺和托米诺平铺](../../problems/domino-and-tromino-tiling) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 764 | [最大加号标志](../../problems/largest-plus-sign) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 750 | [角矩形的数量](../../problems/number-of-corner-rectangles) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 746 | [使用最小花费爬楼梯](../../problems/min-cost-climbing-stairs) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 741 | [摘樱桃](../../problems/cherry-pickup) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 740 | [删除与获得点数](../../problems/delete-and-earn) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 712 | [两个字符串的最小ASCII删除和](../../problems/minimum-ascii-delete-sum-for-two-strings) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 689 | [三个无重叠子数组的最大和](../../problems/maximum-sum-of-3-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 688 | [“马”在棋盘上的概率](../../problems/knight-probability-in-chessboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 673 | [最长递增子序列的个数](../../problems/number-of-longest-increasing-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 664 | [奇怪的打印机](../../problems/strange-printer) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 656 | [金币路径](../../problems/coin-path) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 651 | [4键键盘](../../problems/4-keys-keyboard) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 650 | [只有两个键的键盘](../../problems/2-keys-keyboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 647 | [回文子串](../../problems/palindromic-substrings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 646 | [最长数对链](../../problems/maximum-length-of-pair-chain) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 639 | [解码方法 2](../../problems/decode-ways-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 638 | [大礼包](../../problems/shopping-offers) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 629 | [K个逆序对数组](../../problems/k-inverse-pairs-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 600 | [不含连续1的非负整数](../../problems/non-negative-integers-without-consecutive-ones) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 576 | [出界的路径数](../../problems/out-of-boundary-paths) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 568 | [最大休假天数](../../problems/maximum-vacation-days) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 552 | [学生出勤记录 II](../../problems/student-attendance-record-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 546 | [移除盒子](../../problems/remove-boxes) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 523 | [连续的子数组和](../../problems/continuous-subarray-sum) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 517 | [超级洗衣机](../../problems/super-washing-machines) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 516 | [最长回文子序列](../../problems/longest-palindromic-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 494 | [目标和](../../problems/target-sum) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 486 | [预测赢家](../../problems/predict-the-winner) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 474 | [一和零](../../problems/ones-and-zeroes) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 471 | [编码最短长度的字符串](../../problems/encode-string-with-shortest-length) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 467 | [环绕字符串中唯一的子字符串](../../problems/unique-substrings-in-wraparound-string) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 466 | [统计重复个数](../../problems/count-the-repetitions) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 464 | [我能赢吗](../../problems/can-i-win) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 446 | [等差数列划分 II - 子序列](../../problems/arithmetic-slices-ii-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 416 | [分割等和子集](../../problems/partition-equal-subset-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 403 | [青蛙过河](../../problems/frog-jump) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 377 | [组合总和 Ⅳ](../../problems/combination-sum-iv) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 375 | [猜数字大小 II](../../problems/guess-number-higher-or-lower-ii) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 361 | [轰炸敌人](../../problems/bomb-enemy) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 354 | [俄罗斯套娃信封问题](../../problems/russian-doll-envelopes) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 351 | [安卓系统手势解锁](../../problems/android-unlock-patterns) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 343 | [整数拆分](../../problems/integer-break) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 322 | [零钱兑换](../../problems/coin-change) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 321 | [拼接最大数](../../problems/create-maximum-number) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 312 | [戳气球](../../problems/burst-balloons) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 309 | [最佳买卖股票时机含冷冻期](../../problems/best-time-to-buy-and-sell-stock-with-cooldown) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 304 | [二维区域和检索 - 矩阵不可变](../../problems/range-sum-query-2d-immutable) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 303 | [区域和检索 - 数组不可变](../../problems/range-sum-query-immutable) | [[动态规划](../dynamic-programming/README.md)] | Easy | +| 300 | [最长递增子序列](../../problems/longest-increasing-subsequence) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 276 | [栅栏涂色](../../problems/paint-fence) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Easy | +| 265 | [粉刷房子 II](../../problems/paint-house-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 256 | [粉刷房子](../../problems/paint-house) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 221 | [最大正方形](../../problems/maximal-square) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 213 | [打家劫舍 II](../../problems/house-robber-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 198 | [打家劫舍](../../problems/house-robber) | [[动态规划](../dynamic-programming/README.md)] | Easy | +| 188 | [买卖股票的最佳时机 IV](../../problems/best-time-to-buy-and-sell-stock-iv) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 174 | [地下城游戏](../../problems/dungeon-game) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 152 | [乘积最大子数组](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 140 | [单词拆分 II](../../problems/word-break-ii) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 139 | [单词拆分](../../problems/word-break) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 132 | [分割回文串 II](../../problems/palindrome-partitioning-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 123 | [买卖股票的最佳时机 III](../../problems/best-time-to-buy-and-sell-stock-iii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 121 | [买卖股票的最佳时机](../../problems/best-time-to-buy-and-sell-stock) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 120 | [三角形最小路径和](../../problems/triangle) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 115 | [不同的子序列](../../problems/distinct-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 91 | [解码方法](../../problems/decode-ways) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 87 | [扰乱字符串](../../problems/scramble-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 72 | [编辑距离](../../problems/edit-distance) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 70 | [爬楼梯](../../problems/climbing-stairs) | [[动态规划](../dynamic-programming/README.md)] | Easy | +| 64 | [最小路径和](../../problems/minimum-path-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 63 | [不同路径 II](../../problems/unique-paths-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 62 | [不同路径](../../problems/unique-paths) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 5 | [最长回文子串](../../problems/longest-palindromic-substring) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1 | [01 背包问题](../../problems/07MoiZ) | [[动态规划](../dynamic-programming/README.md)] | Easy | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index 5a8521ed2..085448301 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -9,3 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard | +| 1515 | [服务中心的最佳位置](../../problems/best-position-for-a-service-centre) | [[几何](../geometry/README.md)] | Hard | +| 1453 | [圆形靶内的最大飞镖数量](../../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | [[几何](../geometry/README.md)] | Hard | +| 1401 | [圆和矩形是否有重叠](../../problems/circle-and-rectangle-overlapping) | [[几何](../geometry/README.md)] | Medium | +| 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] | Easy | +| 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | +| 892 | [三维形体的表面积](../../problems/surface-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | +| 587 | [安装栅栏](../../problems/erect-the-fence) | [[几何](../geometry/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index 0d01c1b08..ba9a7fc00 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] | Hard | | 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1615 | [最大网络秩](../../problems/maximal-network-rank) | [[图](../graph/README.md)] | Medium | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index e76cdd027..87df25ab7 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[贪心算法](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 1717 | [删除子字符串的最大得分](../../problems/maximum-score-from-removing-substrings) | [[贪心算法](../greedy/README.md)] | Medium | +| 1716 | [计算力扣银行的钱](../../problems/calculate-money-in-leetcode-bank) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Easy | +| 1713 | [得到子序列的最少操作次数](../../problems/minimum-operations-to-make-a-subsequence) | [[贪心算法](../greedy/README.md)] | Hard | +| 1710 | [卡车上的最大单元数](../../problems/maximum-units-on-a-truck) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | +| 1708 | [Largest Subarray Length K](../../problems/largest-subarray-length-k) 🔒 | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 1705 | [吃苹果的最大数目](../../problems/maximum-number-of-eaten-apples) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | | 1702 | [修改后的最大二进制字符串](../../problems/maximum-binary-string-after-change) | [[贪心算法](../greedy/README.md)] | Medium | | 1689 | [十-二进制数的最少数目](../../problems/partitioning-into-minimum-number-of-deci-binary-numbers) | [[贪心算法](../greedy/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index f54222616..00cd2fdf4 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,7 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1679 | [K 和数对的最大数目](../../problems/max-number-of-k-sum-pairs) | [[哈希表](../hash-table/README.md)] | Medium | +| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md index 06c012aa3..592ea3e0f 100644 --- a/tag/line-sweep/README.md +++ b/tag/line-sweep/README.md @@ -9,9 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[Line Sweep](../line-sweep/README.md)] | Medium | -| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | -| 391 | [完美矩形](../../problems/perfect-rectangle) | [[Line Sweep](../line-sweep/README.md)] | Hard | -| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index 3f7f71b02..a34ab29f8 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1721 | [交换链表中的节点](../../problems/swapping-nodes-in-a-linked-list) | [[链表](../linked-list/README.md)] | Medium | | 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | | 1669 | [合并两个链表](../../problems/merge-in-between-linked-lists) | [[链表](../linked-list/README.md)] | Medium | | 1634 | [求两个多项式链表的和](../../problems/add-two-polynomials-represented-as-linked-lists) 🔒 | [[链表](../linked-list/README.md)] | Medium | @@ -48,6 +49,6 @@ | 25 | [K 个一组翻转链表](../../problems/reverse-nodes-in-k-group) | [[链表](../linked-list/README.md)] | Hard | | 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | | 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[链表](../linked-list/README.md)] | Easy | +| 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Easy | | 19 | [删除链表的倒数第N个节点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 2 | [两数相加](../../problems/add-two-numbers) | [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | +| 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index a2c1c456d..c58dcdb99 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1716 | [计算力扣银行的钱](../../problems/calculate-money-in-leetcode-bank) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Easy | | 1685 | [有序数组中差绝对值之和](../../problems/sum-of-absolute-differences-in-a-sorted-array) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | | 1680 | [连接连续二进制数字](../../problems/concatenation-of-consecutive-binary-numbers) | [[数学](../math/README.md)] | Medium | | 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | @@ -154,7 +155,7 @@ | 441 | [排列硬币](../../problems/arranging-coins) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 423 | [从英文中重建数字](../../problems/reconstruct-original-digits-from-english) | [[数学](../math/README.md)] | Medium | | 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 400 | [第N个数字](../../problems/nth-digit) | [[数学](../math/README.md)] | Medium | +| 400 | [第 N 位数字](../../problems/nth-digit) | [[数学](../math/README.md)] | Medium | | 397 | [整数替换](../../problems/integer-replacement) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | | 396 | [旋转函数](../../problems/rotate-function) | [[数学](../math/README.md)] | Medium | | 372 | [超级次方](../../problems/super-pow) | [[数学](../math/README.md)] | Medium | @@ -202,4 +203,4 @@ | 9 | [回文数](../../problems/palindrome-number) | [[数学](../math/README.md)] | Easy | | 8 | [字符串转换整数 (atoi)](../../problems/string-to-integer-atoi) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 7 | [整数反转](../../problems/reverse-integer) | [[数学](../math/README.md)] | Easy | -| 2 | [两数相加](../../problems/add-two-numbers) | [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | +| 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/memoization/README.md b/tag/memoization/README.md index 2c6a5dffd..f418d566c 100644 --- a/tag/memoization/README.md +++ b/tag/memoization/README.md @@ -9,4 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | diff --git a/tag/minimax/README.md b/tag/minimax/README.md index dd3b3951d..0cf0739a7 100644 --- a/tag/minimax/README.md +++ b/tag/minimax/README.md @@ -9,3 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[极小化极大](../minimax/README.md)] | Hard | +| 877 | [石子游戏](../../problems/stone-game) | [[极小化极大](../minimax/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 843 | [猜猜这个单词](../../problems/guess-the-word) | [[极小化极大](../minimax/README.md)] | Hard | +| 486 | [预测赢家](../../problems/predict-the-winner) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 464 | [我能赢吗](../../problems/can-i-win) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 375 | [猜数字大小 II](../../problems/guess-number-higher-or-lower-ii) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 294 | [翻转游戏 II](../../problems/flip-game-ii) 🔒 | [[极小化极大](../minimax/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 292 | [Nim 游戏](../../problems/nim-game) | [[脑筋急转弯](../brainteaser/README.md)] [[极小化极大](../minimax/README.md)] | Easy | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index 838436e43..85faedb8e 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -10,7 +10,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | | 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[Ordered Map](../ordered-map/README.md)] | Hard | | 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | | 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | diff --git a/tag/queue/README.md b/tag/queue/README.md index 8922feba8..16db88027 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -9,3 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 933 | [最近的请求次数](../../problems/number-of-recent-calls) | [[队列](../queue/README.md)] | Easy | +| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | +| 582 | [杀死进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | +| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | diff --git a/tag/random/README.md b/tag/random/README.md index 25144cd0a..72a82d98f 100644 --- a/tag/random/README.md +++ b/tag/random/README.md @@ -9,9 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | -| 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | -| 519 | [随机翻转矩阵](../../problems/random-flip-matrix) | [[Random](../random/README.md)] | Medium | -| 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | -| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | -| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 044d10bbf..614bd16a1 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | | 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | | 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[递归](../recursion/README.md)] | Easy | | 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | @@ -36,4 +39,6 @@ | 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | | 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Easy | | 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/rejection-sampling/README.md b/tag/rejection-sampling/README.md index fc2d396f2..8622c93e1 100644 --- a/tag/rejection-sampling/README.md +++ b/tag/rejection-sampling/README.md @@ -9,5 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | -| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | diff --git a/tag/reservoir-sampling/README.md b/tag/reservoir-sampling/README.md index 1fc516eb3..7d9ca74cc 100644 --- a/tag/reservoir-sampling/README.md +++ b/tag/reservoir-sampling/README.md @@ -9,5 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 398 | [随机数索引](../../problems/random-pick-index) | [[蓄水池抽样](../reservoir-sampling/README.md)] | Medium | -| 382 | [链表随机节点](../../problems/linked-list-random-node) | [[蓄水池抽样](../reservoir-sampling/README.md)] | Medium | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index 2904f5725..b34d04e3d 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -10,7 +10,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | | 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[线段树](../segment-tree/README.md)] | Hard | | 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index 49e4c7112..b691d2565 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,3 +9,76 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1710 | [卡车上的最大单元数](../../problems/maximum-units-on-a-truck) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | +| 1697 | [检查边长度限制的路径是否存在](../../problems/checking-existence-of-edge-length-limited-paths) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] | Hard | +| 1691 | [堆叠长方体的最大高度](../../problems/maximum-height-by-stacking-cuboids) | [[排序](../sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | +| 1647 | [字符频次唯一的最小删除次数](../../problems/minimum-deletions-to-make-character-frequencies-unique) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1637 | [两点之间不包含任何点的最宽垂直面积](../../problems/widest-vertical-area-between-two-points-containing-no-points) | [[排序](../sort/README.md)] | Medium | +| 1636 | [按照频率将数组升序排序](../../problems/sort-array-by-increasing-frequency) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 1630 | [等差子数组](../../problems/arithmetic-subarrays) | [[排序](../sort/README.md)] | Medium | +| 1561 | [你可以获得的最大硬币数目](../../problems/maximum-number-of-coins-you-can-get) | [[排序](../sort/README.md)] | Medium | +| 1528 | [重新排列字符串](../../problems/shuffle-string) | [[排序](../sort/README.md)] | Easy | +| 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1502 | [判断能否形成等差数列](../../problems/can-make-arithmetic-progression-from-sequence) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[排序](../sort/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1491 | [去掉最低工资和最高工资后的工资平均值](../../problems/average-salary-excluding-the-minimum-and-maximum-salary) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 1481 | [不同整数的最少数目](../../problems/least-number-of-unique-integers-after-k-removals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1471 | [数组中的 k 个最强值](../../problems/the-k-strongest-values-in-an-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | +| 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | +| 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Hard | +| 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | +| 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[排序](../sort/README.md)] [[位运算](../bit-manipulation/README.md)] | Easy | +| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | +| 1333 | [餐厅过滤器](../../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1329 | [将矩阵按对角线排序](../../problems/sort-the-matrix-diagonally) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[排序](../sort/README.md)] [[树](../tree/README.md)] | Medium | +| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1183 | [矩阵中 1 的最大数量](../../problems/maximum-number-of-ones) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | +| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1122 | [数组的相对排序](../../problems/relative-sort-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1057 | [校园自行车分配](../../problems/campus-bikes) 🔒 | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] | Medium | +| 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[排序](../sort/README.md)] | Easy | +| 976 | [三角形的最大周长](../../problems/largest-perimeter-triangle) | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Easy | +| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 969 | [煎饼排序](../../problems/pancake-sorting) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 922 | [按奇偶排序数组 II](../../problems/sort-array-by-parity-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 853 | [车队](../../problems/car-fleet) | [[排序](../sort/README.md)] | Medium | +| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | +| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Hard | +| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 324 | [摆动排序 II](../../problems/wiggle-sort-ii) | [[排序](../sort/README.md)] | Medium | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | +| 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 274 | [H 指数](../../problems/h-index) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 252 | [会议室](../../problems/meeting-rooms) 🔒 | [[排序](../sort/README.md)] | Easy | +| 242 | [有效的字母异位词](../../problems/valid-anagram) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | +| 179 | [最大数](../../problems/largest-number) | [[排序](../sort/README.md)] | Medium | +| 164 | [最大间距](../../problems/maximum-gap) | [[排序](../sort/README.md)] | Hard | +| 148 | [排序链表](../../problems/sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 57 | [插入区间](../../problems/insert-interval) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Hard | +| 56 | [合并区间](../../problems/merge-intervals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index dabd214b3..80ca3dd45 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,3 +9,216 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1704 | [判断字符串的两半是否相似](../../problems/determine-if-string-halves-are-alike) | [[字符串](../string/README.md)] | Easy | +| 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | +| 1694 | [重新格式化电话号码](../../problems/reformat-phone-number) | [[字符串](../string/README.md)] | Easy | +| 1684 | [统计一致字符串的数目](../../problems/count-the-number-of-consistent-strings) | [[字符串](../string/README.md)] | Easy | +| 1682 | [最长回文子序列 II](../../problems/longest-palindromic-subsequence-ii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1678 | [设计 Goal 解析器](../../problems/goal-parser-interpretation) | [[字符串](../string/README.md)] | Easy | +| 1668 | [最大重复子字符串](../../problems/maximum-repeating-substring) | [[字符串](../string/README.md)] | Easy | +| 1662 | [检查两个字符串数组是否相等](../../problems/check-if-two-string-arrays-are-equivalent) | [[字符串](../string/README.md)] | Easy | +| 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1624 | [两个相同字符之间的最长子字符串](../../problems/largest-substring-between-two-equal-characters) | [[字符串](../string/README.md)] | Easy | +| 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1614 | [括号的最大嵌套深度](../../problems/maximum-nesting-depth-of-the-parentheses) | [[字符串](../string/README.md)] | Easy | +| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | +| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Hard | +| 1592 | [重新排列单词间的空格](../../problems/rearrange-spaces-between-words) | [[字符串](../string/README.md)] | Easy | +| 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | +| 1576 | [替换所有的问号](../../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | [[字符串](../string/README.md)] | Easy | +| 1573 | [分割字符串的方案数](../../problems/number-of-ways-to-split-a-string) | [[字符串](../string/README.md)] | Medium | +| 1556 | [千位分隔数](../../problems/thousand-separator) | [[字符串](../string/README.md)] | Easy | +| 1545 | [找出第 N 个二进制字符串中的第 K 位](../../problems/find-kth-bit-in-nth-binary-string) | [[字符串](../string/README.md)] | Medium | +| 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | +| 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Hard | +| 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[字符串](../string/README.md)] | Medium | +| 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 1513 | [仅含 1 的子串数](../../problems/number-of-substrings-with-only-1s) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1507 | [转变日期格式](../../problems/reformat-date) | [[字符串](../string/README.md)] | Easy | +| 1496 | [判断路径是否相交](../../problems/path-crossing) | [[字符串](../string/README.md)] | Easy | +| 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1455 | [检查单词是否为句中其他单词的前缀](../../problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | [[字符串](../string/README.md)] | Easy | +| 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1446 | [连续字符](../../problems/consecutive-characters) | [[字符串](../string/README.md)] | Easy | +| 1436 | [旅行终点站](../../problems/destination-city) | [[字符串](../string/README.md)] | Easy | +| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1432 | [改变一个整数能得到的最大差值](../../problems/max-difference-you-can-get-from-changing-an-integer) | [[字符串](../string/README.md)] | Medium | +| 1422 | [分割字符串的最大得分](../../problems/maximum-score-after-splitting-a-string) | [[字符串](../string/README.md)] | Easy | +| 1419 | [数青蛙](../../problems/minimum-number-of-frogs-croaking) | [[字符串](../string/README.md)] | Medium | +| 1417 | [重新格式化字符串](../../problems/reformat-the-string) | [[字符串](../string/README.md)] | Easy | +| 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1408 | [数组中的字符串匹配](../../problems/string-matching-in-an-array) | [[字符串](../string/README.md)] | Easy | +| 1404 | [将二进制表示减到 1 的步骤数](../../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 1392 | [最长快乐前缀](../../problems/longest-happy-prefix) | [[字符串](../string/README.md)] | Hard | +| 1374 | [生成每种字符都是奇数个的字符串](../../problems/generate-a-string-with-characters-that-have-odd-counts) | [[字符串](../string/README.md)] | Easy | +| 1371 | [每个元音包含偶数次的最长子字符串](../../problems/find-the-longest-substring-containing-vowels-in-even-counts) | [[字符串](../string/README.md)] | Medium | +| 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | +| 1358 | [包含所有三种字符的子字符串数目](../../problems/number-of-substrings-containing-all-three-characters) | [[字符串](../string/README.md)] | Medium | +| 1347 | [制造字母异位词的最小步骤数](../../problems/minimum-number-of-steps-to-make-two-strings-anagram) | [[字符串](../string/README.md)] | Medium | +| 1332 | [删除回文子序列](../../problems/remove-palindromic-subsequences) | [[字符串](../string/README.md)] | Easy | +| 1328 | [破坏回文串](../../problems/break-a-palindrome) | [[字符串](../string/README.md)] | Medium | +| 1324 | [竖直打印单词](../../problems/print-words-vertically) | [[字符串](../string/README.md)] | Medium | +| 1316 | [不同的循环子字符串](../../problems/distinct-echo-substrings) | [[字符串](../string/README.md)] | Hard | +| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1309 | [解码字母到整数映射](../../problems/decrypt-string-from-alphabet-to-integer-mapping) | [[字符串](../string/README.md)] | Easy | +| 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 1271 | [十六进制魔术数字](../../problems/hexspeak) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1268 | [搜索推荐系统](../../problems/search-suggestions-system) | [[字符串](../string/README.md)] | Medium | +| 1249 | [移除无效的括号](../../problems/minimum-remove-to-make-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1247 | [交换字符使得字符串相同](../../problems/minimum-swaps-to-make-strings-equal) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1233 | [删除子文件夹](../../problems/remove-sub-folders-from-the-filesystem) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1221 | [分割平衡字符串](../../problems/split-a-string-in-balanced-strings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | +| 1216 | [验证回文字符串 III](../../problems/valid-palindrome-iii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1189 | [“气球” 的最大数量](../../problems/maximum-number-of-balloons) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1181 | [前后拼接](../../problems/before-and-after-puzzle) 🔒 | [[字符串](../string/README.md)] | Medium | +| 1180 | [统计只含单一字母的子串](../../problems/count-substrings-with-only-one-distinct-letter) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1177 | [构建回文串检测](../../problems/can-make-palindrome-from-substring) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1169 | [查询无效交易](../../problems/invalid-transactions) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1165 | [单行键盘](../../problems/single-row-keyboard) 🔒 | [[字符串](../string/README.md)] | Easy | +| 1163 | [按字典序排在最后的子串](../../problems/last-substring-in-lexicographical-order) | [[字符串](../string/README.md)] | Hard | +| 1156 | [单字符重复子串的最大长度](../../problems/swap-for-longest-repeated-character-substring) | [[字符串](../string/README.md)] | Medium | +| 1138 | [字母板上的路径](../../problems/alphabet-board-path) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1119 | [删去字符串中的元音](../../problems/remove-vowels-from-a-string) 🔒 | [[字符串](../string/README.md)] | Easy | +| 1108 | [IP 地址无效化](../../problems/defanging-an-ip-address) | [[字符串](../string/README.md)] | Easy | +| 1106 | [解析布尔表达式](../../problems/parsing-a-boolean-expression) | [[字符串](../string/README.md)] | Hard | +| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1096 | [花括号展开 II](../../problems/brace-expansion-ii) | [[字符串](../string/README.md)] | Hard | +| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1071 | [字符串的最大公因子](../../problems/greatest-common-divisor-of-strings) | [[字符串](../string/README.md)] | Easy | +| 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Easy | +| 1062 | [最长重复子串](../../problems/longest-repeating-substring) 🔒 | [[字符串](../string/README.md)] | Medium | +| 1023 | [驼峰式匹配](../../problems/camelcase-matching) | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | +| 1016 | [子串能表示从 1 到 N 数字的二进制串](../../problems/binary-string-with-substrings-representing-1-to-n) | [[字符串](../string/README.md)] | Medium | +| 1003 | [检查替换后的词是否有效](../../problems/check-if-word-is-valid-after-substitutions) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 937 | [重新排列日志文件](../../problems/reorder-data-in-log-files) | [[字符串](../string/README.md)] | Easy | +| 936 | [戳印序列](../../problems/stamping-the-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | +| 929 | [独特的电子邮件地址](../../problems/unique-email-addresses) | [[字符串](../string/README.md)] | Easy | +| 925 | [长按键入](../../problems/long-pressed-name) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 917 | [仅仅反转字母](../../problems/reverse-only-letters) | [[字符串](../string/README.md)] | Easy | +| 916 | [单词子集](../../problems/word-subsets) | [[字符串](../string/README.md)] | Medium | +| 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[字符串](../string/README.md)] | Easy | +| 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[字符串](../string/README.md)] | Medium | +| 859 | [亲密字符串](../../problems/buddy-strings) | [[字符串](../string/README.md)] | Easy | +| 856 | [括号的分数](../../problems/score-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 848 | [字母移位](../../problems/shifting-letters) | [[字符串](../string/README.md)] | Medium | +| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 833 | [字符串中的查找与替换](../../problems/find-and-replace-in-string) | [[字符串](../string/README.md)] | Medium | +| 831 | [隐藏个人信息](../../problems/masking-personal-information) | [[字符串](../string/README.md)] | Medium | +| 824 | [山羊拉丁文](../../problems/goat-latin) | [[字符串](../string/README.md)] | Easy | +| 819 | [最常见的单词](../../problems/most-common-word) | [[字符串](../string/README.md)] | Easy | +| 816 | [模糊坐标](../../problems/ambiguous-coordinates) | [[字符串](../string/README.md)] | Medium | +| 809 | [情感丰富的文字](../../problems/expressive-words) | [[字符串](../string/README.md)] | Medium | +| 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[字符串](../string/README.md)] | Easy | +| 800 | [相似 RGB 颜色](../../problems/similar-rgb-color) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 791 | [自定义字符串排序](../../problems/custom-sort-string) | [[字符串](../string/README.md)] | Medium | +| 788 | [旋转数字](../../problems/rotated-digits) | [[字符串](../string/README.md)] | Easy | +| 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | +| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | +| 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字符串](../string/README.md)] | Easy | +| 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[字符串](../string/README.md)] | Hard | +| 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 722 | [删除注释](../../problems/remove-comments) | [[字符串](../string/README.md)] | Medium | +| 709 | [转换成小写字母](../../problems/to-lower-case) | [[字符串](../string/README.md)] | Easy | +| 696 | [计数二进制子串](../../problems/count-binary-substrings) | [[字符串](../string/README.md)] | Easy | +| 686 | [重复叠加字符串匹配](../../problems/repeated-string-match) | [[字符串](../string/README.md)] | Medium | +| 681 | [最近时刻](../../problems/next-closest-time) 🔒 | [[字符串](../string/README.md)] | Medium | +| 680 | [验证回文字符串 Ⅱ](../../problems/valid-palindrome-ii) | [[字符串](../string/README.md)] | Easy | +| 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[字符串](../string/README.md)] | Medium | +| 657 | [机器人能否返回原点](../../problems/robot-return-to-origin) | [[字符串](../string/README.md)] | Easy | +| 647 | [回文子串](../../problems/palindromic-substrings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | +| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 616 | [给字符串添加加粗标签](../../problems/add-bold-tag-in-string) 🔒 | [[字符串](../string/README.md)] | Medium | +| 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 606 | [根据二叉树创建字符串](../../problems/construct-string-from-binary-tree) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Easy | +| 591 | [标签验证器](../../problems/tag-validator) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | +| 583 | [两个字符串的删除操作](../../problems/delete-operation-for-two-strings) | [[字符串](../string/README.md)] | Medium | +| 564 | [寻找最近的回文数](../../problems/find-the-closest-palindrome) | [[字符串](../string/README.md)] | Hard | +| 557 | [反转字符串中的单词 III](../../problems/reverse-words-in-a-string-iii) | [[字符串](../string/README.md)] | Easy | +| 556 | [下一个更大元素 III](../../problems/next-greater-element-iii) | [[字符串](../string/README.md)] | Medium | +| 555 | [分割连接字符串](../../problems/split-concatenated-strings) 🔒 | [[字符串](../string/README.md)] | Medium | +| 553 | [最优除法](../../problems/optimal-division) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 551 | [学生出勤记录 I](../../problems/student-attendance-record-i) | [[字符串](../string/README.md)] | Easy | +| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | +| 541 | [反转字符串 II](../../problems/reverse-string-ii) | [[字符串](../string/README.md)] | Easy | +| 539 | [最小时间差](../../problems/minimum-time-difference) | [[字符串](../string/README.md)] | Medium | +| 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | +| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Hard | +| 522 | [最长特殊序列 II](../../problems/longest-uncommon-subsequence-ii) | [[字符串](../string/README.md)] | Medium | +| 521 | [最长特殊序列 Ⅰ](../../problems/longest-uncommon-subsequence-i) | [[脑筋急转弯](../brainteaser/README.md)] [[字符串](../string/README.md)] | Easy | +| 520 | [检测大写字母](../../problems/detect-capital) | [[字符串](../string/README.md)] | Easy | +| 468 | [验证IP地址](../../problems/validate-ip-address) | [[字符串](../string/README.md)] | Medium | +| 459 | [重复的子字符串](../../problems/repeated-substring-pattern) | [[字符串](../string/README.md)] | Easy | +| 443 | [压缩字符串](../../problems/string-compression) | [[字符串](../string/README.md)] | Medium | +| 434 | [字符串中的单词数](../../problems/number-of-segments-in-a-string) | [[字符串](../string/README.md)] | Easy | +| 415 | [字符串相加](../../problems/add-strings) | [[字符串](../string/README.md)] | Easy | +| 408 | [有效单词缩写](../../problems/valid-word-abbreviation) 🔒 | [[字符串](../string/README.md)] | Easy | +| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 385 | [迷你语法分析器](../../problems/mini-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 383 | [赎金信](../../problems/ransom-note) | [[字符串](../string/README.md)] | Easy | +| 345 | [反转字符串中的元音字母](../../problems/reverse-vowels-of-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 344 | [反转字符串](../../problems/reverse-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 293 | [翻转游戏](../../problems/flip-game) 🔒 | [[字符串](../string/README.md)] | Easy | +| 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 271 | [字符串的编码与解码](../../problems/encode-and-decode-strings) 🔒 | [[字符串](../string/README.md)] | Medium | +| 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 214 | [最短回文串](../../problems/shortest-palindrome) | [[字符串](../string/README.md)] | Hard | +| 186 | [翻转字符串里的单词 II](../../problems/reverse-words-in-a-string-ii) 🔒 | [[字符串](../string/README.md)] | Medium | +| 165 | [比较版本号](../../problems/compare-version-numbers) | [[字符串](../string/README.md)] | Medium | +| 161 | [相隔为 1 的编辑距离](../../problems/one-edit-distance) 🔒 | [[字符串](../string/README.md)] | Medium | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 158 | [用 Read4 读取 N 个字符 II](../../problems/read-n-characters-given-read4-ii-call-multiple-times) 🔒 | [[字符串](../string/README.md)] | Hard | +| 157 | [用 Read4 读取 N 个字符](../../problems/read-n-characters-given-read4) 🔒 | [[字符串](../string/README.md)] | Easy | +| 151 | [翻转字符串里的单词](../../problems/reverse-words-in-a-string) | [[字符串](../string/README.md)] | Medium | +| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 125 | [验证回文串](../../problems/valid-palindrome) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 115 | [不同的子序列](../../problems/distinct-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 93 | [复原IP地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 91 | [解码方法](../../problems/decode-ways) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 87 | [扰乱字符串](../../problems/scramble-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 72 | [编辑距离](../../problems/edit-distance) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 71 | [简化路径](../../problems/simplify-path) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 68 | [文本左右对齐](../../problems/text-justification) | [[字符串](../string/README.md)] | Hard | +| 67 | [二进制求和](../../problems/add-binary) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 65 | [有效数字](../../problems/valid-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 58 | [最后一个单词的长度](../../problems/length-of-last-word) | [[字符串](../string/README.md)] | Easy | +| 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 38 | [外观数列](../../problems/count-and-say) | [[字符串](../string/README.md)] | Easy | +| 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 20 | [有效的括号](../../problems/valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | +| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 14 | [最长公共前缀](../../problems/longest-common-prefix) | [[字符串](../string/README.md)] | Easy | +| 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 8 | [字符串转换整数 (atoi)](../../problems/string-to-integer-atoi) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 6 | [Z 字形变换](../../problems/zigzag-conversion) | [[字符串](../string/README.md)] | Medium | +| 5 | [最长回文子串](../../problems/longest-palindromic-substring) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/tree/README.md b/tag/tree/README.md index 0dd6cb631..a9e1b7c95 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,7 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1676 | [Lowest Common Ancestor of a Binary Tree IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] | Hard | +| 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1660 | [纠正二叉树](../../problems/correct-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | | 1650 | [二叉树的最近公共祖先 III](../../problems/lowest-common-ancestor-of-a-binary-tree-iii) 🔒 | [[树](../tree/README.md)] | Medium | @@ -31,7 +32,7 @@ | 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1430 | [判断给定的序列是否是二叉树从根到叶的路径](../../problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | -| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] | Medium | +| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | | 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/trie/README.md b/tag/trie/README.md index a008b2d35..0e2a77cce 100644 --- a/tag/trie/README.md +++ b/tag/trie/README.md @@ -10,6 +10,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1707 | [与数组中元素的最大异或值](../../problems/maximum-xor-with-an-element-from-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Hard | +| 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | | 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Easy | | 1032 | [字符流](../../problems/stream-of-characters) | [[字典树](../trie/README.md)] | Hard | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index bbccc6652..71fdc75ca 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1695 | [删除子数组的最大得分](../../problems/maximum-erasure-value) | [[双指针](../two-pointers/README.md)] | Medium | | 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index e84ea907e..de255cc71 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -9,3 +9,40 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[贪心算法](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 1697 | [检查边长度限制的路径是否存在](../../problems/checking-existence-of-edge-length-limited-paths) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] | Hard | +| 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] | Hard | +| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1627 | [带阈值的图连通性](../../problems/graph-connectivity-with-threshold) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | +| 1584 | [连接所有点的最小费用](../../problems/min-cost-to-connect-all-points) | [[并查集](../union-find/README.md)] | Medium | +| 1579 | [保证图可完全遍历](../../problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | [[并查集](../union-find/README.md)] | Hard | +| 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | +| 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | +| 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 1135 | [最低成本联通所有城市](../../problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 1101 | [彼此熟识的最早时间](../../problems/the-earliest-moment-when-everyone-become-friends) 🔒 | [[并查集](../union-find/README.md)] | Medium | +| 1061 | [按字典序排列最小的等效字符串](../../problems/lexicographically-smallest-equivalent-string) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 990 | [等式方程的可满足性](../../problems/satisfiability-of-equality-equations) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 952 | [按公因数计算最大组件大小](../../problems/largest-component-size-by-common-factor) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | +| 947 | [移除最多的同行或同列石头](../../problems/most-stones-removed-with-same-row-or-column) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 924 | [尽量减少恶意软件的传播](../../problems/minimize-malware-spread) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | +| 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 803 | [打砖块](../../problems/bricks-falling-when-hit) | [[并查集](../union-find/README.md)] | Hard | +| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 721 | [账户合并](../../problems/accounts-merge) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 684 | [冗余连接](../../problems/redundant-connection) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 547 | [省份数量](../../problems/number-of-provinces) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 399 | [除法求值](../../problems/evaluate-division) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 305 | [岛屿数量 II](../../problems/number-of-islands-ii) 🔒 | [[并查集](../union-find/README.md)] | Hard | +| 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 128 | [最长连续序列](../../problems/longest-consecutive-sequence) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Hard | From a7c50eba16df5a21da272023954bd7db09171213 Mon Sep 17 00:00:00 2001 From: Shuo Date: Fri, 29 Jan 2021 11:52:33 +0800 Subject: [PATCH 117/145] A: new --- README.md | 31 +++-- problems/array-of-doubled-pairs/README.md | 25 ++-- problems/asteroid-collision/README.md | 4 +- .../README.md | 2 +- .../best-time-to-buy-and-sell-stock/README.md | 23 ++-- .../binary-tree-maximum-path-sum/README.md | 8 +- .../binary-tree-preorder-traversal/README.md | 7 +- problems/boats-to-save-people/README.md | 39 +++---- problems/building-boxes/README.md | 76 ++++++++++++ problems/burst-balloons/README.md | 6 +- .../README.md | 27 ++--- problems/cat-and-mouse-ii/README.md | 107 +++++++++++++++++ .../README.md | 68 +++++++++++ .../README.md | 6 +- .../README.md | 35 ++++++ problems/coin-path/README.md | 2 +- .../README.md | 11 +- problems/count-complete-tree-nodes/README.md | 45 +++++--- problems/count-number-of-teams/README.md | 13 ++- .../README.md | 20 +++- .../README.md | 57 +++++++++ problems/decode-ways/README.md | 5 +- problems/decode-xored-permutation/README.md | 67 +++++++++++ problems/delete-and-earn/README.md | 2 +- .../README.md | 1 + problems/design-hashset/README.md | 54 +++++---- .../README.md | 13 ++- .../README.md | 10 +- .../find-distance-in-a-binary-tree/README.md | 30 +++++ problems/find-followers-count/README.md | 14 +++ .../find-followers-count/mysql_schemas.sql | 6 + problems/find-k-closest-elements/README.md | 7 +- .../README.md | 67 +++++++++++ .../README.md | 2 +- .../README.md | 38 ++++-- problems/find-the-highest-altitude/README.md | 56 +++++++++ .../README.md | 2 + problems/first-missing-positive/README.md | 7 +- .../README.md | 50 +++++--- problems/gray-code/README.md | 2 +- problems/house-robber-ii/README.md | 2 +- problems/house-robber-iii/README.md | 2 +- problems/house-robber/README.md | 2 +- problems/insert-interval/README.md | 2 +- .../interval-list-intersections/README.md | 52 ++++++--- problems/invalid-transactions/README.md | 16 +-- problems/invalid-tweets/README.md | 2 +- .../k-concatenation-maximum-sum/README.md | 14 +-- .../k-th-smallest-prime-fraction/README.md | 39 ++++--- problems/keyboard-row/README.md | 42 +++++-- .../kth-smallest-element-in-a-bst/README.md | 33 ++---- problems/largest-subarray-length-k/README.md | 2 +- .../README.md | 78 +++++++++++++ .../README.md | 64 ++++++++++ problems/lfu-cache/README.md | 30 +++-- .../README.md | 9 +- .../longest-consecutive-sequence/README.md | 5 +- .../README.md | 4 +- .../README.md | 6 +- .../README.md | 4 +- problems/maximum-product-subarray/README.md | 2 +- problems/meeting-scheduler/README.md | 2 + problems/merge-intervals/README.md | 2 +- problems/merge-sorted-array/README.md | 6 +- problems/minimize-malware-spread-ii/README.md | 70 +++++------ problems/minimize-malware-spread/README.md | 6 +- .../README.md | 71 ++++++++++++ .../README.md | 5 +- problems/missing-ranges/README.md | 2 +- problems/nested-list-weight-sum/README.md | 1 + problems/network-delay-time/README.md | 43 ++++--- problems/next-greater-element-i/README.md | 66 ++++++----- problems/non-decreasing-array/README.md | 9 +- .../README.md | 2 +- .../README.md | 66 +++++++++++ problems/paint-fence/README.md | 2 +- problems/paint-house/README.md | 2 +- problems/palindrome-number/README.md | 7 +- problems/pancake-sorting/README.md | 17 ++- problems/path-sum-ii/README.md | 42 ++++--- problems/path-sum/README.md | 39 +++++-- .../peak-index-in-a-mountain-array/README.md | 5 +- problems/perfect-squares/README.md | 30 +++-- .../products-worth-over-invoices/README.md | 2 +- .../projection-area-of-3d-shapes/README.md | 104 ++++------------- problems/range-module/README.md | 2 +- problems/range-sum-query-mutable/README.md | 38 ++++-- .../README.md | 67 +++++------ .../README.md | 2 +- problems/reorder-data-in-log-files/README.md | 31 +++-- problems/reverse-integer/README.md | 4 +- problems/robot-bounded-in-circle/README.md | 40 +++---- .../search-in-a-binary-search-tree/README.md | 36 +++--- problems/set-mismatch/README.md | 35 +++--- problems/shortest-path-to-get-food/README.md | 40 +++++++ .../README.md | 5 +- problems/sort-colors/README.md | 19 +-- problems/sort-the-matrix-diagonally/README.md | 13 ++- problems/string-to-integer-atoi/README.md | 80 ++++++++++--- problems/subsets-ii/README.md | 35 +++--- problems/subsets/README.md | 4 +- problems/sum-of-subarray-minimums/README.md | 27 +---- problems/summary-ranges/README.md | 2 +- problems/surface-area-of-3d-shapes/README.md | 6 +- .../README.md | 14 +++ .../mysql_schemas.sql | 6 + problems/third-maximum-number/README.md | 4 +- problems/three-equal-parts/README.md | 51 ++++---- problems/trapping-rain-water/README.md | 1 + problems/trim-a-binary-search-tree/README.md | 3 +- problems/trips-and-users/README.md | 109 ++++++++++++------ problems/tuple-with-same-product/README.md | 75 ++++++++++++ .../README.md | 18 ++- problems/ugly-number-iii/README.md | 10 +- .../unique-binary-search-trees-ii/README.md | 33 +++--- problems/unique-binary-search-trees/README.md | 24 ++-- problems/valid-number/README.md | 83 ++++++++----- .../README.md | 18 ++- problems/walking-robot-simulation/README.md | 31 ++++- problems/word-ladder/README.md | 24 ++-- problems/word-pattern-ii/README.md | 2 +- problems/word-pattern/README.md | 2 +- readme/1-300.md | 4 +- readme/301-600.md | 2 +- readme/601-900.md | 4 +- readme/901-1200.md | 4 +- tag/README.md | 2 +- tag/array/README.md | 16 ++- tag/backtracking/README.md | 4 +- tag/binary-indexed-tree/README.md | 7 ++ tag/binary-search-tree/README.md | 4 + tag/binary-search/README.md | 6 +- tag/bit-manipulation/README.md | 1 + tag/breadth-first-search/README.md | 78 ------------- tag/depth-first-search/README.md | 5 +- tag/design/README.md | 2 +- tag/dynamic-programming/README.md | 7 +- tag/graph/README.md | 2 + tag/greedy/README.md | 11 +- tag/hash-table/README.md | 2 + tag/heap/README.md | 3 +- tag/line-sweep/README.md | 6 + tag/linked-list/README.md | 2 +- tag/math/README.md | 6 +- tag/memoization/README.md | 1 + tag/ordered-map/README.md | 14 --- tag/queue/README.md | 9 -- tag/recursion/README.md | 1 + tag/rejection-sampling/README.md | 2 + tag/reservoir-sampling/README.md | 2 + tag/segment-tree/README.md | 16 --- tag/sliding-window/README.md | 1 + tag/sort/README.md | 4 +- tag/stack/README.md | 4 +- tag/string/README.md | 4 +- tag/tags.json | 10 +- tag/tree/README.md | 3 +- tag/trie/README.md | 2 +- tag/two-pointers/README.md | 7 +- tag/union-find/README.md | 1 + 160 files changed, 2232 insertions(+), 1077 deletions(-) create mode 100644 problems/building-boxes/README.md create mode 100644 problems/cat-and-mouse-ii/README.md create mode 100644 problems/change-minimum-characters-to-satisfy-one-of-three-conditions/README.md create mode 100644 problems/checking-existence-of-edge-length-limited-paths-ii/README.md create mode 100644 problems/count-ways-to-make-array-with-product/README.md create mode 100644 problems/decode-xored-permutation/README.md create mode 100644 problems/find-distance-in-a-binary-tree/README.md create mode 100644 problems/find-followers-count/README.md create mode 100644 problems/find-followers-count/mysql_schemas.sql create mode 100644 problems/find-kth-largest-xor-coordinate-value/README.md create mode 100644 problems/find-the-highest-altitude/README.md create mode 100644 problems/largest-submatrix-with-rearrangements/README.md create mode 100644 problems/latest-time-by-replacing-hidden-digits/README.md create mode 100644 problems/minimum-number-of-people-to-teach/README.md create mode 100644 problems/number-of-rectangles-that-can-form-the-largest-square/README.md create mode 100644 problems/shortest-path-to-get-food/README.md create mode 100644 problems/the-number-of-employees-which-report-to-each-employee/README.md create mode 100644 problems/the-number-of-employees-which-report-to-each-employee/mysql_schemas.sql create mode 100644 problems/tuple-with-same-product/README.md diff --git a/README.md b/README.md index f6db8115f..49353f20e 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,23 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1740 | [Find Distance in a Binary Tree](https://leetcode.com/problems/find-distance-in-a-binary-tree) 🔒 | [Go](problems/find-distance-in-a-binary-tree) | Easy | +| 1739 | [Building Boxes](https://leetcode.com/problems/building-boxes "放置盒子") | [Go](problems/building-boxes) | Hard | +| 1738 | [Find Kth Largest XOR Coordinate Value](https://leetcode.com/problems/find-kth-largest-xor-coordinate-value "找出第 K 大的异或坐标值") | [Go](problems/find-kth-largest-xor-coordinate-value) | Medium | +| 1737 | [Change Minimum Characters to Satisfy One of Three Conditions](https://leetcode.com/problems/change-minimum-characters-to-satisfy-one-of-three-conditions "满足三条件之一需改变的最少字符数") | [Go](problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | Medium | +| 1736 | [Latest Time by Replacing Hidden Digits](https://leetcode.com/problems/latest-time-by-replacing-hidden-digits "替换隐藏数字得到的最晚时间") | [Go](problems/latest-time-by-replacing-hidden-digits) | Easy | +| 1735 | [Count Ways to Make Array With Product](https://leetcode.com/problems/count-ways-to-make-array-with-product "生成乘积数组的方案数") | [Go](problems/count-ways-to-make-array-with-product) | Hard | +| 1734 | [Decode XORed Permutation](https://leetcode.com/problems/decode-xored-permutation "解码异或后的排列") | [Go](problems/decode-xored-permutation) | Medium | +| 1733 | [Minimum Number of People to Teach](https://leetcode.com/problems/minimum-number-of-people-to-teach "需要教语言的最少人数") | [Go](problems/minimum-number-of-people-to-teach) | Medium | +| 1732 | [Find the Highest Altitude](https://leetcode.com/problems/find-the-highest-altitude "找到最高海拔") | [Go](problems/find-the-highest-altitude) | Easy | +| 1731 | [The Number of Employees Which Report to Each Employee](https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee) 🔒 | [MySQL](problems/the-number-of-employees-which-report-to-each-employee) | Easy | +| 1730 | [Shortest Path to Get Food](https://leetcode.com/problems/shortest-path-to-get-food) 🔒 | [Go](problems/shortest-path-to-get-food) | Medium | +| 1729 | [Find Followers Count](https://leetcode.com/problems/find-followers-count) 🔒 | [MySQL](problems/find-followers-count) | Easy | +| 1728 | [Cat and Mouse II](https://leetcode.com/problems/cat-and-mouse-ii "猫和老鼠 II") | [Go](problems/cat-and-mouse-ii) | Hard | +| 1727 | [Largest Submatrix With Rearrangements](https://leetcode.com/problems/largest-submatrix-with-rearrangements "重新排列后的最大子矩阵") | [Go](problems/largest-submatrix-with-rearrangements) | Medium | +| 1726 | [Tuple with Same Product](https://leetcode.com/problems/tuple-with-same-product "同积元组") | [Go](problems/tuple-with-same-product) | Medium | +| 1725 | [Number Of Rectangles That Can Form The Largest Square](https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square "可以形成最大正方形的矩形数目") | [Go](problems/number-of-rectangles-that-can-form-the-largest-square) | Easy | +| 1724 | [Checking Existence of Edge Length Limited Paths II](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [Go](problems/checking-existence-of-edge-length-limited-paths-ii) | Hard | | 1723 | [Find Minimum Time to Finish All Jobs](https://leetcode.com/problems/find-minimum-time-to-finish-all-jobs "完成所有工作的最短时间") | [Go](problems/find-minimum-time-to-finish-all-jobs) | Hard | | 1722 | [Minimize Hamming Distance After Swap Operations](https://leetcode.com/problems/minimize-hamming-distance-after-swap-operations "执行交换操作后的最小汉明距离") | [Go](problems/minimize-hamming-distance-after-swap-operations) | Medium | | 1721 | [Swapping Nodes in a Linked List](https://leetcode.com/problems/swapping-nodes-in-a-linked-list "交换链表中的节点") | [Go](problems/swapping-nodes-in-a-linked-list) | Medium | @@ -85,7 +102,7 @@ LeetCode Problems' Solutions | 1711 | [Count Good Meals](https://leetcode.com/problems/count-good-meals "大餐计数") | [Go](problems/count-good-meals) | Medium | | 1710 | [Maximum Units on a Truck](https://leetcode.com/problems/maximum-units-on-a-truck "卡车上的最大单元数") | [Go](problems/maximum-units-on-a-truck) | Easy | | 1709 | [Biggest Window Between Visits](https://leetcode.com/problems/biggest-window-between-visits) 🔒 | [MySQL](problems/biggest-window-between-visits) | Medium | -| 1708 | [Largest Subarray Length K](https://leetcode.com/problems/largest-subarray-length-k) 🔒 | [Go](problems/largest-subarray-length-k) | Easy | +| 1708 | [Largest Subarray Length K](https://leetcode.com/problems/largest-subarray-length-k "长度为 K 的最大子数组") 🔒 | [Go](problems/largest-subarray-length-k) | Easy | | 1707 | [Maximum XOR With an Element From Array](https://leetcode.com/problems/maximum-xor-with-an-element-from-array "与数组中元素的最大异或值") | [Go](problems/maximum-xor-with-an-element-from-array) | Hard | | 1706 | [Where Will the Ball Fall](https://leetcode.com/problems/where-will-the-ball-fall "球会落何处") | [Go](problems/where-will-the-ball-fall) | Medium | | 1705 | [Maximum Number of Eaten Apples](https://leetcode.com/problems/maximum-number-of-eaten-apples "吃苹果的最大数目") | [Go](problems/maximum-number-of-eaten-apples) | Medium | @@ -110,13 +127,13 @@ LeetCode Problems' Solutions | 1686 | [Stone Game VI](https://leetcode.com/problems/stone-game-vi "石子游戏 VI") | [Go](problems/stone-game-vi) | Medium | | 1685 | [Sum of Absolute Differences in a Sorted Array](https://leetcode.com/problems/sum-of-absolute-differences-in-a-sorted-array "有序数组中差绝对值之和") | [Go](problems/sum-of-absolute-differences-in-a-sorted-array) | Medium | | 1684 | [Count the Number of Consistent Strings](https://leetcode.com/problems/count-the-number-of-consistent-strings "统计一致字符串的数目") | [Go](problems/count-the-number-of-consistent-strings) | Easy | -| 1683 | [Invalid Tweets](https://leetcode.com/problems/invalid-tweets) 🔒 | [MySQL](problems/invalid-tweets) | Easy | +| 1683 | [Invalid Tweets](https://leetcode.com/problems/invalid-tweets "无效的推文") 🔒 | [MySQL](problems/invalid-tweets) | Easy | | 1682 | [Longest Palindromic Subsequence II](https://leetcode.com/problems/longest-palindromic-subsequence-ii "最长回文子序列 II") 🔒 | [Go](problems/longest-palindromic-subsequence-ii) | Medium | | 1681 | [Minimum Incompatibility](https://leetcode.com/problems/minimum-incompatibility "最小不兼容性") | [Go](problems/minimum-incompatibility) | Hard | | 1680 | [Concatenation of Consecutive Binary Numbers](https://leetcode.com/problems/concatenation-of-consecutive-binary-numbers "连接连续二进制数字") | [Go](problems/concatenation-of-consecutive-binary-numbers) | Medium | | 1679 | [Max Number of K-Sum Pairs](https://leetcode.com/problems/max-number-of-k-sum-pairs "K 和数对的最大数目") | [Go](problems/max-number-of-k-sum-pairs) | Medium | | 1678 | [Goal Parser Interpretation](https://leetcode.com/problems/goal-parser-interpretation "设计 Goal 解析器") | [Go](problems/goal-parser-interpretation) | Easy | -| 1677 | [Product's Worth Over Invoices](https://leetcode.com/problems/products-worth-over-invoices) 🔒 | [MySQL](problems/products-worth-over-invoices) | Easy | +| 1677 | [Product's Worth Over Invoices](https://leetcode.com/problems/products-worth-over-invoices "发票中的产品金额") 🔒 | [MySQL](problems/products-worth-over-invoices) | Easy | | 1676 | [Lowest Common Ancestor of a Binary Tree IV](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iv "二叉树的最近公共祖先 IV") 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-iv) | Medium | | 1675 | [Minimize Deviation in Array](https://leetcode.com/problems/minimize-deviation-in-array "数组的最小偏移量") | [Go](problems/minimize-deviation-in-array) | Hard | | 1674 | [Minimum Moves to Make Array Complementary](https://leetcode.com/problems/minimum-moves-to-make-array-complementary "使数组互补的最少操作次数") | [Go](problems/minimum-moves-to-make-array-complementary) | Medium | @@ -132,7 +149,7 @@ LeetCode Problems' Solutions | 1664 | [Ways to Make a Fair Array](https://leetcode.com/problems/ways-to-make-a-fair-array "生成平衡数组的方案数") | [Go](problems/ways-to-make-a-fair-array) | Medium | | 1663 | [Smallest String With A Given Numeric Value](https://leetcode.com/problems/smallest-string-with-a-given-numeric-value "具有给定数值的最小字符串") | [Go](problems/smallest-string-with-a-given-numeric-value) | Medium | | 1662 | [Check If Two String Arrays are Equivalent](https://leetcode.com/problems/check-if-two-string-arrays-are-equivalent "检查两个字符串数组是否相等") | [Go](problems/check-if-two-string-arrays-are-equivalent) | Easy | -| 1661 | [Average Time of Process per Machine](https://leetcode.com/problems/average-time-of-process-per-machine) 🔒 | [MySQL](problems/average-time-of-process-per-machine) | Easy | +| 1661 | [Average Time of Process per Machine](https://leetcode.com/problems/average-time-of-process-per-machine "每台机器的进程平均运行时间") 🔒 | [MySQL](problems/average-time-of-process-per-machine) | Easy | | 1660 | [Correct a Binary Tree](https://leetcode.com/problems/correct-a-binary-tree "纠正二叉树") 🔒 | [Go](problems/correct-a-binary-tree) | Medium | | 1659 | [Maximize Grid Happiness](https://leetcode.com/problems/maximize-grid-happiness "最大化网格幸福感") | [Go](problems/maximize-grid-happiness) | Hard | | 1658 | [Minimum Operations to Reduce X to Zero](https://leetcode.com/problems/minimum-operations-to-reduce-x-to-zero "将 x 减到 0 的最小操作数") | [Go](problems/minimum-operations-to-reduce-x-to-zero) | Medium | @@ -356,7 +373,7 @@ LeetCode Problems' Solutions | 1440 | [Evaluate Boolean Expression](https://leetcode.com/problems/evaluate-boolean-expression "计算布尔表达式的值") 🔒 | [MySQL](problems/evaluate-boolean-expression) | Medium | | 1439 | [Find the Kth Smallest Sum of a Matrix With Sorted Rows](https://leetcode.com/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows "有序矩阵中的第 k 个最小数组和") | [Go](problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | Hard | | 1438 | [Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit](https://leetcode.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "绝对差不超过限制的最长连续子数组") | [Go](problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | Medium | -| 1437 | [Check If All 1's Are at Least Length K Places Away](https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away "是否所有 1 都至少相隔 k 个元素") | [Go](problems/check-if-all-1s-are-at-least-length-k-places-away) | Medium | +| 1437 | [Check If All 1's Are at Least Length K Places Away](https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away "是否所有 1 都至少相隔 k 个元素") | [Go](problems/check-if-all-1s-are-at-least-length-k-places-away) | Easy | | 1436 | [Destination City](https://leetcode.com/problems/destination-city "旅行终点站") | [Go](problems/destination-city) | Easy | | 1435 | [Create a Session Bar Chart](https://leetcode.com/problems/create-a-session-bar-chart "制作会话柱状图") 🔒 | [MySQL](problems/create-a-session-bar-chart) | Easy | | 1434 | [Number of Ways to Wear Different Hats to Each Other](https://leetcode.com/problems/number-of-ways-to-wear-different-hats-to-each-other "每个人戴不同帽子的方案数") | [Go](problems/number-of-ways-to-wear-different-hats-to-each-other) | Hard | @@ -556,7 +573,7 @@ LeetCode Problems' Solutions | 1240 | [Tiling a Rectangle with the Fewest Squares](https://leetcode.com/problems/tiling-a-rectangle-with-the-fewest-squares "铺瓷砖") | [Go](problems/tiling-a-rectangle-with-the-fewest-squares) | Hard | | 1239 | [Maximum Length of a Concatenated String with Unique Characters](https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters "串联字符串的最大长度") | [Go](problems/maximum-length-of-a-concatenated-string-with-unique-characters) | Medium | | 1238 | [Circular Permutation in Binary Representation](https://leetcode.com/problems/circular-permutation-in-binary-representation "循环码排列") | [Go](problems/circular-permutation-in-binary-representation) | Medium | -| 1237 | [Find Positive Integer Solution for a Given Equation](https://leetcode.com/problems/find-positive-integer-solution-for-a-given-equation "找出给定方程的正整数解") | [Go](problems/find-positive-integer-solution-for-a-given-equation) | Easy | +| 1237 | [Find Positive Integer Solution for a Given Equation](https://leetcode.com/problems/find-positive-integer-solution-for-a-given-equation "找出给定方程的正整数解") | [Go](problems/find-positive-integer-solution-for-a-given-equation) | Medium | | 1236 | [Web Crawler](https://leetcode.com/problems/web-crawler "网络爬虫") 🔒 | [Go](problems/web-crawler) | Medium | | 1235 | [Maximum Profit in Job Scheduling](https://leetcode.com/problems/maximum-profit-in-job-scheduling "规划兼职工作") | [Go](problems/maximum-profit-in-job-scheduling) | Hard | | 1234 | [Replace the Substring for Balanced String](https://leetcode.com/problems/replace-the-substring-for-balanced-string "替换子串得到平衡字符串") | [Go](problems/replace-the-substring-for-balanced-string) | Medium | @@ -570,7 +587,7 @@ LeetCode Problems' Solutions | 1226 | [The Dining Philosophers](https://leetcode.com/problems/the-dining-philosophers "哲学家进餐") | [Go](problems/the-dining-philosophers) | Medium | | 1225 | [Report Contiguous Dates](https://leetcode.com/problems/report-contiguous-dates "报告系统状态的连续日期") 🔒 | [MySQL](problems/report-contiguous-dates) | Hard | | 1224 | [Maximum Equal Frequency](https://leetcode.com/problems/maximum-equal-frequency "最大相等频率") | [Go](problems/maximum-equal-frequency) | Hard | -| 1223 | [Dice Roll Simulation](https://leetcode.com/problems/dice-roll-simulation "掷骰子模拟") | [Go](problems/dice-roll-simulation) | Medium | +| 1223 | [Dice Roll Simulation](https://leetcode.com/problems/dice-roll-simulation "掷骰子模拟") | [Go](problems/dice-roll-simulation) | Hard | | 1222 | [Queens That Can Attack the King](https://leetcode.com/problems/queens-that-can-attack-the-king "可以攻击国王的皇后") | [Go](problems/queens-that-can-attack-the-king) | Medium | | 1221 | [Split a String in Balanced Strings](https://leetcode.com/problems/split-a-string-in-balanced-strings "分割平衡字符串") | [Go](problems/split-a-string-in-balanced-strings) | Easy | | 1220 | [Count Vowels Permutation](https://leetcode.com/problems/count-vowels-permutation "统计元音字母序列的数目") | [Go](problems/count-vowels-permutation) | Hard | diff --git a/problems/array-of-doubled-pairs/README.md b/problems/array-of-doubled-pairs/README.md index bc6c763d4..9385c0569 100644 --- a/problems/array-of-doubled-pairs/README.md +++ b/problems/array-of-doubled-pairs/README.md @@ -11,36 +11,27 @@ ## [954. Array of Doubled Pairs (Medium)](https://leetcode.com/problems/array-of-doubled-pairs "二倍数对数组") -

    Given an array of integers A with even length, return true if and only if it is possible to reorder it such that A[2 * i + 1] = 2 * A[2 * i] for every 0 <= i < len(A) / 2.

    - -
    -
    -
    -
      -
    -
    -
    -
    +

    Given an array of integers arr of even length, return true if and only if it is possible to reorder it such that arr[2 * i + 1] = 2 * arr[2 * i] for every 0 <= i < len(arr) / 2.

     

    Example 1:

    -Input: A = [3,1,3,6]
    +Input: arr = [3,1,3,6]
     Output: false
     

    Example 2:

    -Input: A = [2,1,2,6]
    +Input: arr = [2,1,2,6]
     Output: false
     

    Example 3:

    -Input: A = [4,-2,2,-4]
    +Input: arr = [4,-2,2,-4]
     Output: true
     Explanation: We can take two groups, [-2,-4] and [2,4] to form [-2,-4,2,4] or [2,4,-2,-4].
     
    @@ -48,7 +39,7 @@

    Example 4:

    -Input: A = [1,2,4,16,8,4]
    +Input: arr = [1,2,4,16,8,4]
     Output: false
     
    @@ -56,9 +47,9 @@

    Constraints:

      -
    • 0 <= A.length <= 3 * 104
    • -
    • A.length is even.
    • -
    • -105 <= A[i] <= 105
    • +
    • 0 <= arr.length <= 3 * 104
    • +
    • arr.length is even.
    • +
    • -105 <= arr[i] <= 105
    ### Related Topics diff --git a/problems/asteroid-collision/README.md b/problems/asteroid-collision/README.md index 03edf127a..220b6f4e5 100644 --- a/problems/asteroid-collision/README.md +++ b/problems/asteroid-collision/README.md @@ -23,7 +23,7 @@
     Input: asteroids = [5,10,-5]
     Output: [5,10]
    -Explanation: The 10 and -5 collide resulting in 10.  The 5 and 10 never collide.
    +Explanation: The 10 and -5 collide resulting in 10. The 5 and 10 never collide.
     

    Example 2:

    @@ -54,7 +54,7 @@

    Constraints:

      -
    • 1 <= asteroids <= 104
    • +
    • 2 <= asteroids <= 104
    • -1000 <= asteroids[i] <= 1000
    • asteroids[i] != 0
    diff --git a/problems/average-time-of-process-per-machine/README.md b/problems/average-time-of-process-per-machine/README.md index bf492a5da..f2f9aa0bc 100644 --- a/problems/average-time-of-process-per-machine/README.md +++ b/problems/average-time-of-process-per-machine/README.md @@ -9,6 +9,6 @@                  [Next >](../check-if-two-string-arrays-are-equivalent "Check If Two String Arrays are Equivalent") -## [1661. Average Time of Process per Machine (Easy)](https://leetcode.com/problems/average-time-of-process-per-machine "") +## [1661. Average Time of Process per Machine (Easy)](https://leetcode.com/problems/average-time-of-process-per-machine "每台机器的进程平均运行时间") diff --git a/problems/best-time-to-buy-and-sell-stock/README.md b/problems/best-time-to-buy-and-sell-stock/README.md index 0c951ccd2..119db2613 100644 --- a/problems/best-time-to-buy-and-sell-stock/README.md +++ b/problems/best-time-to-buy-and-sell-stock/README.md @@ -11,29 +11,38 @@ ## [121. Best Time to Buy and Sell Stock (Easy)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock "买卖股票的最佳时机") -

    Say you have an array for which the ith element is the price of a given stock on day i.

    +

    You are given an array prices where prices[i] is the price of a given stock on the ith day.

    -

    If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit.

    +

    You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock.

    -

    Note that you cannot sell a stock before you buy one.

    +

    Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0.

    +

     

    Example 1:

    -Input: [7,1,5,3,6,4]
    +Input: prices = [7,1,5,3,6,4]
     Output: 5
     Explanation: Buy on day 2 (price = 1) and sell on day 5 (price = 6), profit = 6-1 = 5.
    -             Not 7-1 = 6, as selling price needs to be larger than buying price.
    +Note that buying on day 2 and selling on day 1 is not allowed because you must buy before you sell.
     

    Example 2:

    -Input: [7,6,4,3,1]
    +Input: prices = [7,6,4,3,1]
     Output: 0
    -Explanation: In this case, no transaction is done, i.e. max profit = 0.
    +Explanation: In this case, no transactions are done and the max profit = 0.
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= prices.length <= 105
    • +
    • 0 <= prices[i] <= 104
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/binary-tree-maximum-path-sum/README.md b/problems/binary-tree-maximum-path-sum/README.md index e0d877648..e77db851b 100644 --- a/problems/binary-tree-maximum-path-sum/README.md +++ b/problems/binary-tree-maximum-path-sum/README.md @@ -11,9 +11,11 @@ ## [124. Binary Tree Maximum Path Sum (Hard)](https://leetcode.com/problems/binary-tree-maximum-path-sum "二叉树中的最大路径和") -

    Given the root of a binary tree, return the maximum path sum.

    +

    A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence at most once. Note that the path does not need to pass through the root.

    -

    For this problem, a path is defined as any node sequence from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does not need to go through the root.

    +

    The path sum of a path is the sum of the node's values in the path.

    + +

    Given the root of a binary tree, return the maximum path sum of any path.

     

    Example 1:

    @@ -21,6 +23,7 @@
     Input: root = [1,2,3]
     Output: 6
    +Explanation: The optimal path is 2 -> 1 -> 3 with a path sum of 2 + 1 + 3 = 6.
     

    Example 2:

    @@ -28,6 +31,7 @@
     Input: root = [-10,9,20,null,null,15,7]
     Output: 42
    +Explanation: The optimal path is 15 -> 20 -> 7 with a path sum of 15 + 20 + 7 = 42.
     

     

    diff --git a/problems/binary-tree-preorder-traversal/README.md b/problems/binary-tree-preorder-traversal/README.md index 725ba549c..e3638d691 100644 --- a/problems/binary-tree-preorder-traversal/README.md +++ b/problems/binary-tree-preorder-traversal/README.md @@ -58,12 +58,7 @@

     

    - -

    Follow up:

    - -

    Recursive solution is trivial, could you do it iteratively?

    - -

     

    +

    Follow up: Recursive solution is trivial, could you do it iteratively?

    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/boats-to-save-people/README.md b/problems/boats-to-save-people/README.md index 80af1ce36..0c7d5be79 100644 --- a/problems/boats-to-save-people/README.md +++ b/problems/boats-to-save-people/README.md @@ -11,49 +11,42 @@ ## [881. Boats to Save People (Medium)](https://leetcode.com/problems/boats-to-save-people "救生艇") -

    The i-th person has weight people[i], and each boat can carry a maximum weight of limit.

    +

    You are given an array people where people[i] is the weight of the ith person, and an infinite number of boats where each boat can carry a maximum weight of limit. Each boat carries at most two people at the same time, provided the sum of the weight of those people is at most limit.

    -

    Each boat carries at most 2 people at the same time, provided the sum of the weight of those people is at most limit.

    - -

    Return the minimum number of boats to carry every given person.  (It is guaranteed each person can be carried by a boat.)

    +

    Return the minimum number of boats to carry every given person.

     

    - -

    Example 1:

    -Input: people = [1,2], limit = 3
    -Output: 1
    -Explanation: 1 boat (1, 2)
    +Input: people = [1,2], limit = 3
    +Output: 1
    +Explanation: 1 boat (1, 2)
     
    -

    Example 2:

    -Input: people = [3,2,2,1], limit = 3
    -Output: 3
    -Explanation: 3 boats (1, 2), (2) and (3)
    +Input: people = [3,2,2,1], limit = 3
    +Output: 3
    +Explanation: 3 boats (1, 2), (2) and (3)
     
    -

    Example 3:

    -Input: people = [3,5,3,4], limit = 5
    -Output: 4
    -Explanation: 4 boats (3), (3), (4), (5)
    +Input: people = [3,5,3,4], limit = 5 +Output: 4 +Explanation: 4 boats (3), (3), (4), (5) + -

    Note:

    +

     

    +

    Constraints:

      -
    • 1 <= people.length <= 50000
    • -
    • 1 <= people[i] <= limit <= 30000
    • +
    • 1 <= people.length <= 5 * 104
    • +
    • 1 <= people[i] <= limit <= 3 * 104
    -
    -
    -
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/building-boxes/README.md b/problems/building-boxes/README.md new file mode 100644 index 000000000..f9ca91771 --- /dev/null +++ b/problems/building-boxes/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](../find-kth-largest-xor-coordinate-value "Find Kth Largest XOR Coordinate Value") +                 +[Next >](../find-distance-in-a-binary-tree "Find Distance in a Binary Tree") + +## [1739. Building Boxes (Hard)](https://leetcode.com/problems/building-boxes "放置盒子") + +

    You have a cubic storeroom where the width, length, and height of the room are all equal to n units. You are asked to place n boxes in this room where each box is a cube of unit side length. There are however some rules to placing the boxes:

    + +
      +
    • You can place the boxes anywhere on the floor.
    • +
    • If box x is placed on top of the box y, then each side of the four vertical sides of the box y must either be adjacent to another box or to a wall.
    • +
    + +

    Given an integer n, return the minimum possible number of boxes touching the floor.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: n = 3
    +Output: 3
    +Explanation: The figure above is for the placement of the three boxes.
    +These boxes are placed in the corner of the room, where the corner is on the left side.
    +
    + +

    Example 2:

    + +

    + +
    +Input: n = 4
    +Output: 3
    +Explanation: The figure above is for the placement of the four boxes.
    +These boxes are placed in the corner of the room, where the corner is on the left side.
    +
    + +

    Example 3:

    + +

    + +
    +Input: n = 10
    +Output: 6
    +Explanation: The figure above is for the placement of the ten boxes.
    +These boxes are placed in the corner of the room, where the corner is on the back side.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 109
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Suppose We can put m boxes on the floor, within all the ways to put the boxes, what’s the maximum number of boxes we can put in? +
    + +
    +Hint 2 +The first box should always start in the corner +
    diff --git a/problems/burst-balloons/README.md b/problems/burst-balloons/README.md index 1ea3f3b9f..01d0681b5 100644 --- a/problems/burst-balloons/README.md +++ b/problems/burst-balloons/README.md @@ -13,7 +13,7 @@

    You are given n balloons, indexed from 0 to n - 1. Each balloon is painted with a number on it represented by an array nums. You are asked to burst all the balloons.

    -

    If you burst the ith balloon, you will get nums[left] * nums[i] * nums[right] coins. Here left and right are adjacent indices of i. After the burst, the left and right then becomes adjacent.

    +

    If you burst the ith balloon, you will get nums[i - 1] * nums[i] * nums[i + 1] coins. If i - 1 or i + 1 goes out of bounds of the array, then treat it as if there is a balloon with a 1 painted on it.

    Return the maximum coins you can collect by bursting the balloons wisely.

    @@ -23,8 +23,8 @@
     Input: nums = [3,1,5,8]
     Output: 167
    -Explanation:
    -nums = [3,1,5,8] --> [3,5,8] --> [3,8] --> [8] --> []
    +Explanation:
    +nums = [3,1,5,8] --> [3,5,8] --> [3,8] --> [8] --> []
     coins =  3*1*5    +   3*5*8   +  1*3*8  + 1*8*1 = 167

    Example 2:

    diff --git a/problems/capacity-to-ship-packages-within-d-days/README.md b/problems/capacity-to-ship-packages-within-d-days/README.md index e311fa320..6832bd250 100644 --- a/problems/capacity-to-ship-packages-within-d-days/README.md +++ b/problems/capacity-to-ship-packages-within-d-days/README.md @@ -13,35 +13,32 @@

    A conveyor belt has packages that must be shipped from one port to another within D days.

    -

    The i-th package on the conveyor belt has a weight of weights[i].  Each day, we load the ship with packages on the conveyor belt (in the order given by weights). We may not load more weight than the maximum weight capacity of the ship.

    +

    The ith package on the conveyor belt has a weight of weights[i]. Each day, we load the ship with packages on the conveyor belt (in the order given by weights). We may not load more weight than the maximum weight capacity of the ship.

    Return the least weight capacity of the ship that will result in all the packages on the conveyor belt being shipped within D days.

     

    -

    Example 1:

    -Input: weights = [1,2,3,4,5,6,7,8,9,10], D = 5
    -Output: 15
    -Explanation: 
    -A ship capacity of 15 is the minimum to ship all the packages in 5 days like this:
    +Input: weights = [1,2,3,4,5,6,7,8,9,10], D = 5
    +Output: 15
    +Explanation: A ship capacity of 15 is the minimum to ship all the packages in 5 days like this:
     1st day: 1, 2, 3, 4, 5
     2nd day: 6, 7
     3rd day: 8
     4th day: 9
     5th day: 10
     
    -Note that the cargo must be shipped in the order given, so using a ship of capacity 14 and splitting the packages into parts like (2, 3, 4, 5), (1, 6, 7), (8), (9), (10) is not allowed. 
    +Note that the cargo must be shipped in the order given, so using a ship of capacity 14 and splitting the packages into parts like (2, 3, 4, 5), (1, 6, 7), (8), (9), (10) is not allowed.
     

    Example 2:

    -Input: weights = [3,2,2,4,1,4], D = 3
    -Output: 6
    -Explanation: 
    -A ship capacity of 6 is the minimum to ship all the packages in 3 days like this:
    +Input: weights = [3,2,2,4,1,4], D = 3
    +Output: 6
    +Explanation: A ship capacity of 6 is the minimum to ship all the packages in 3 days like this:
     1st day: 3, 2
     2nd day: 2, 4
     3rd day: 1, 4
    @@ -50,9 +47,9 @@ A ship capacity of 6 is the minimum to ship all the packages in 3 days like this
     

    Example 3:

    -Input: weights = [1,2,3,1,1], D = 4
    -Output: 3
    -Explanation: 
    +Input: weights = [1,2,3,1,1], D = 4
    +Output: 3
    +Explanation:
     1st day: 1
     2nd day: 2
     3rd day: 3
    @@ -63,7 +60,7 @@ A ship capacity of 6 is the minimum to ship all the packages in 3 days like this
     

    Constraints:

      -
    • 1 <= D <= weights.length <= 50000
    • +
    • 1 <= D <= weights.length <= 5 * 104
    • 1 <= weights[i] <= 500
    diff --git a/problems/cat-and-mouse-ii/README.md b/problems/cat-and-mouse-ii/README.md new file mode 100644 index 000000000..711a42f2b --- /dev/null +++ b/problems/cat-and-mouse-ii/README.md @@ -0,0 +1,107 @@ + + + + + + + +[< Previous](../largest-submatrix-with-rearrangements "Largest Submatrix With Rearrangements") +                 +[Next >](../find-followers-count "Find Followers Count") + +## [1728. Cat and Mouse II (Hard)](https://leetcode.com/problems/cat-and-mouse-ii "猫和老鼠 II") + +

    A game is played by a cat and a mouse named Cat and Mouse.

    + +

    The environment is represented by a grid of size rows x cols, where each element is a wall, floor, player (Cat, Mouse), or food.

    + +
      +
    • Players are represented by the characters 'C'(Cat),'M'(Mouse).
    • +
    • Floors are represented by the character '.' and can be walked on.
    • +
    • Walls are represented by the character '#' and cannot be walked on.
    • +
    • Food is represented by the character 'F' and can be walked on.
    • +
    • There is only one of each character 'C', 'M', and 'F' in grid.
    • +
    + +

    Mouse and Cat play according to the following rules:

    + +
      +
    • Mouse moves first, then they take turns to move.
    • +
    • During each turn, Cat and Mouse can jump in one of the four directions (left, right, up, down). They cannot jump over the wall nor outside of the grid.
    • +
    • catJump, mouseJump are the maximum lengths Cat and Mouse can jump at a time, respectively. Cat and Mouse can jump less than the maximum length.
    • +
    • Staying in the same position is allowed.
    • +
    • Mouse can jump over Cat.
    • +
    + +

    The game can end in 4 ways:

    + +
      +
    • If Cat occupies the same position as Mouse, Cat wins.
    • +
    • If Cat reaches the food first, Cat wins.
    • +
    • If Mouse reaches the food first, Mouse wins.
    • +
    • If Mouse cannot get to the food within 1000 turns, Cat wins.
    • +
    + +

    Given a rows x cols matrix grid and two integers catJump and mouseJump, return true if Mouse can win the game if both Cat and Mouse play optimally, otherwise return false.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: grid = ["####F","#C...","M...."], catJump = 1, mouseJump = 2
    +Output: true
    +Explanation: Cat cannot catch Mouse on its turn nor can it get the food before Mouse.
    +
    + +

    Example 2:

    + +

    + +
    +Input: grid = ["M.C...F"], catJump = 1, mouseJump = 4
    +Output: true
    +
    + +

    Example 3:

    + +
    +Input: grid = ["M.C...F"], catJump = 1, mouseJump = 3
    +Output: false
    +
    + +

    Example 4:

    + +
    +Input: grid = ["C...#","...#F","....#","M...."], catJump = 2, mouseJump = 5
    +Output: false
    +
    + +

    Example 5:

    + +
    +Input: grid = [".M...","..#..","#..#.","C#.#.","...#F"], catJump = 3, mouseJump = 1
    +Output: true
    +
    + +

     

    +

    Constraints:

    + +
      +
    • rows == grid.length
    • +
    • cols = grid[i].length
    • +
    • 1 <= rows, cols <= 8
    • +
    • grid[i][j] consist only of characters 'C', 'M', 'F', '.', and '#'.
    • +
    • There is only one of each character 'C', 'M', and 'F' in grid.
    • +
    • 1 <= catJump, mouseJump <= 8
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Try working backward: consider all trivial states you know to be winning or losing, and work backward to determine which other states can be labeled as winning or losing. +
    diff --git a/problems/change-minimum-characters-to-satisfy-one-of-three-conditions/README.md b/problems/change-minimum-characters-to-satisfy-one-of-three-conditions/README.md new file mode 100644 index 000000000..0c02683b5 --- /dev/null +++ b/problems/change-minimum-characters-to-satisfy-one-of-three-conditions/README.md @@ -0,0 +1,68 @@ + + + + + + + +[< Previous](../latest-time-by-replacing-hidden-digits "Latest Time by Replacing Hidden Digits") +                 +[Next >](../find-kth-largest-xor-coordinate-value "Find Kth Largest XOR Coordinate Value") + +## [1737. Change Minimum Characters to Satisfy One of Three Conditions (Medium)](https://leetcode.com/problems/change-minimum-characters-to-satisfy-one-of-three-conditions "满足三条件之一需改变的最少字符数") + +

    You are given two strings a and b that consist of lowercase letters. In one operation, you can change any character in a or b to any lowercase letter.

    + +

    Your goal is to satisfy one of the following three conditions:

    + +
      +
    • Every letter in a is strictly less than every letter in b in the alphabet.
    • +
    • Every letter in b is strictly less than every letter in a in the alphabet.
    • +
    • Both a and b consist of only one distinct letter.
    • +
    + +

    Return the minimum number of operations needed to achieve your goal.

    + +

     

    +

    Example 1:

    + +
    +Input: a = "aba", b = "caa"
    +Output: 2
    +Explanation: Consider the best way to make each condition true:
    +1) Change b to "ccc" in 2 operations, then every letter in a is less than every letter in b.
    +2) Change a to "bbb" and b to "aaa" in 3 operations, then every letter in b is less than every letter in a.
    +3) Change a to "aaa" and b to "aaa" in 2 operations, then a and b consist of one distinct letter.
    +The best way was done in 2 operations (either condition 1 or condition 3).
    +
    + +

    Example 2:

    + +
    +Input: a = "dabadd", b = "cda"
    +Output: 3
    +Explanation: The best way is to make condition 1 true by changing b to "eee".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= a.length, b.length <= 105
    • +
    • a and b consist only of lowercase letters.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Iterate on each letter in the alphabet, and check the smallest number of operations needed to make it one of the following: the largest letter in a and smaller than the smallest one in b, vice versa, or let a and b consist only of this letter. +
    + +
    +Hint 2 +For the first 2 conditions, take care that you can only change characters to lowercase letters, so you can't make 'z' the smallest letter in one of the strings or 'a' the largest letter in one of them. +
    diff --git a/problems/check-if-all-1s-are-at-least-length-k-places-away/README.md b/problems/check-if-all-1s-are-at-least-length-k-places-away/README.md index b285ea86e..7e7b72d6f 100644 --- a/problems/check-if-all-1s-are-at-least-length-k-places-away/README.md +++ b/problems/check-if-all-1s-are-at-least-length-k-places-away/README.md @@ -9,7 +9,7 @@                  [Next >](../longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit") -## [1437. Check If All 1's Are at Least Length K Places Away (Medium)](https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away "是否所有 1 都至少相隔 k 个元素") +## [1437. Check If All 1's Are at Least Length K Places Away (Easy)](https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away "是否所有 1 都至少相隔 k 个元素")

    Given an array nums of 0s and 1s and an integer k, return True if all 1's are at least k places away from each other, otherwise return False.

    @@ -51,9 +51,9 @@

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • +
    • 1 <= nums.length <= 105
    • 0 <= k <= nums.length
    • -
    • nums[i] is 0 or 1
    • +
    • nums[i] is 0 or 1
    ### Related Topics diff --git a/problems/checking-existence-of-edge-length-limited-paths-ii/README.md b/problems/checking-existence-of-edge-length-limited-paths-ii/README.md new file mode 100644 index 000000000..159005616 --- /dev/null +++ b/problems/checking-existence-of-edge-length-limited-paths-ii/README.md @@ -0,0 +1,35 @@ + + + + + + + +[< Previous](../find-minimum-time-to-finish-all-jobs "Find Minimum Time to Finish All Jobs") +                 +[Next >](../number-of-rectangles-that-can-form-the-largest-square "Number Of Rectangles That Can Form The Largest Square") + +## [1724. Checking Existence of Edge Length Limited Paths II (Hard)](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths-ii "") + + + +### Related Topics + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Find the minimum spanning tree of the given graph. +
    + +
    +Hint 2 +Root the tree in an arbitrary node and calculate the maximum weight of the edge from each node to the chosen root. +
    + +
    +Hint 3 +To answer a query, find the lca between the two nodes, and find the maximum weight from each of the query nodes to their lca and compare it to the given limit. +
    diff --git a/problems/coin-path/README.md b/problems/coin-path/README.md index d230d792b..4bc08d280 100644 --- a/problems/coin-path/README.md +++ b/problems/coin-path/README.md @@ -52,5 +52,5 @@ [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [House Robber](../house-robber) (Easy) + 1. [House Robber](../house-robber) (Medium) 1. [House Robber II](../house-robber-ii) (Medium) diff --git a/problems/compare-strings-by-frequency-of-the-smallest-character/README.md b/problems/compare-strings-by-frequency-of-the-smallest-character/README.md index c17b913ac..6741914e6 100644 --- a/problems/compare-strings-by-frequency-of-the-smallest-character/README.md +++ b/problems/compare-strings-by-frequency-of-the-smallest-character/README.md @@ -9,11 +9,13 @@                  [Next >](../remove-zero-sum-consecutive-nodes-from-linked-list "Remove Zero Sum Consecutive Nodes from Linked List") -## [1170. Compare Strings by Frequency of the Smallest Character (Easy)](https://leetcode.com/problems/compare-strings-by-frequency-of-the-smallest-character "比较字符串最小字母出现频次") +## [1170. Compare Strings by Frequency of the Smallest Character (Medium)](https://leetcode.com/problems/compare-strings-by-frequency-of-the-smallest-character "比较字符串最小字母出现频次") -

    Let's define a function f(s) over a non-empty string s, which calculates the frequency of the smallest character in s. For example, if s = "dcce" then f(s) = 2 because the smallest character is "c" and its frequency is 2.

    +

    Let the function f(s) be the frequency of the lexicographically smallest character in a non-empty string s. For example, if s = "dcce" then f(s) = 2 because the lexicographically smallest character is 'c', which has a frequency of 2.

    -

    Now, given string arrays queries and words, return an integer array answer, where each answer[i] is the number of words such that f(queries[i]) < f(W), where W is a word in words.

    +

    You are given an array of strings words and another array of query strings queries. For each query queries[i], count the number of words in words such that f(queries[i]) < f(W) for each W in words.

    + +

    Return an integer array answer, where each answer[i] is the answer to the ith query.

     

    Example 1:

    @@ -39,12 +41,13 @@
  • 1 <= queries.length <= 2000
  • 1 <= words.length <= 2000
  • 1 <= queries[i].length, words[i].length <= 10
  • -
  • queries[i][j], words[i][j] are English lowercase letters.
  • +
  • queries[i][j], words[i][j] consist of lowercase English letters.
  • ### Related Topics [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
    diff --git a/problems/count-complete-tree-nodes/README.md b/problems/count-complete-tree-nodes/README.md index bcc3eedbc..ae2d96bfb 100644 --- a/problems/count-complete-tree-nodes/README.md +++ b/problems/count-complete-tree-nodes/README.md @@ -11,24 +11,43 @@ ## [222. Count Complete Tree Nodes (Medium)](https://leetcode.com/problems/count-complete-tree-nodes "完全二叉树的节点个数") -

    Given a complete binary tree, count the number of nodes.

    +

    Given the root of a complete binary tree, return the number of the nodes in the tree.

    -

    Note:

    +

    According to Wikipedia, every level, except possibly the last, is completely filled in a complete binary tree, and all nodes in the last level are as far left as possible. It can have between 1 and 2h nodes inclusive at the last level h.

    -

    Definition of a complete binary tree from Wikipedia:
    -In a complete binary tree every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible. It can have between 1 and 2h nodes inclusive at the last level h.

    +

     

    +

    Example 1:

    + +
    +Input: root = [1,2,3,4,5,6]
    +Output: 6
    +
    + +

    Example 2:

    + +
    +Input: root = []
    +Output: 0
    +
    -

    Example:

    +

    Example 3:

    -Input: 
    -    1
    -   / \
    -  2   3
    - / \  /
    -4  5 6
    -
    -Output: 6
    +Input: root = [1] +Output: 1 +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [0, 5 * 104].
    • +
    • 0 <= Node.val <= 5 * 104
    • +
    • The tree is guaranteed to be complete.
    • +
    + +

     

    +Follow up: Traversing the tree to count the number of nodes in the tree is an easy solution but with O(n) complexity. Could you find a faster algorithm? ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/count-number-of-teams/README.md b/problems/count-number-of-teams/README.md index 6f7670f95..81fb7b979 100644 --- a/problems/count-number-of-teams/README.md +++ b/problems/count-number-of-teams/README.md @@ -11,13 +11,13 @@ ## [1395. Count Number of Teams (Medium)](https://leetcode.com/problems/count-number-of-teams "统计作战单位数") -

    There are n soldiers standing in a line. Each soldier is assigned a unique rating value.

    +

    There are n soldiers standing in a line. Each soldier is assigned a unique rating value.

    -

    You have to form a team of 3 soldiers amongst them under the following rules:

    +

    You have to form a team of 3 soldiers amongst them under the following rules:

      -
    • Choose 3 soldiers with index (i, j, k) with rating (rating[i], rating[j], rating[k]).
    • -
    • A team is valid if:  (rating[i] < rating[j] < rating[k]) or (rating[i] > rating[j] > rating[k]) where (0 <= i < j < k < n).
    • +
    • Choose 3 soldiers with index (i, j, k) with rating (rating[i], rating[j], rating[k]).
    • +
    • A team is valid if: (rating[i] < rating[j] < rating[k]) or (rating[i] > rating[j] > rating[k]) where (0 <= i < j < k < n).

    Return the number of teams you can form given the conditions. (soldiers can be part of multiple teams).

    @@ -51,8 +51,9 @@
    • n == rating.length
    • -
    • 1 <= n <= 200
    • -
    • 1 <= rating[i] <= 10^5
    • +
    • 3 <= n <= 1000
    • +
    • 1 <= rating[i] <= 105
    • +
    • All the integers in rating are unique.
    ### Related Topics diff --git a/problems/count-of-smaller-numbers-after-self/README.md b/problems/count-of-smaller-numbers-after-self/README.md index 57edfdf13..d6731f452 100644 --- a/problems/count-of-smaller-numbers-after-self/README.md +++ b/problems/count-of-smaller-numbers-after-self/README.md @@ -11,7 +11,7 @@ ## [315. Count of Smaller Numbers After Self (Hard)](https://leetcode.com/problems/count-of-smaller-numbers-after-self "计算右侧小于当前元素的个数") -

    You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].

    +

    You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].

     

    Example 1:

    @@ -26,12 +26,26 @@ To the right of 6 there is 1 smaller element (1). To the right of 1 there is 0 smaller element.
    +

    Example 2:

    + +
    +Input: nums = [-1]
    +Output: [0]
    +
    + +

    Example 3:

    + +
    +Input: nums = [-1,-1]
    +Output: [0,0]
    +
    +

     

    Constraints:

      -
    • 0 <= nums.length <= 10^5
    • -
    • -10^4 <= nums[i] <= 10^4
    • +
    • 1 <= nums.length <= 105
    • +
    • -104 <= nums[i] <= 104
    ### Related Topics diff --git a/problems/count-ways-to-make-array-with-product/README.md b/problems/count-ways-to-make-array-with-product/README.md new file mode 100644 index 000000000..c2db3b12b --- /dev/null +++ b/problems/count-ways-to-make-array-with-product/README.md @@ -0,0 +1,57 @@ + + + + + + + +[< Previous](../decode-xored-permutation "Decode XORed Permutation") +                 +[Next >](../latest-time-by-replacing-hidden-digits "Latest Time by Replacing Hidden Digits") + +## [1735. Count Ways to Make Array With Product (Hard)](https://leetcode.com/problems/count-ways-to-make-array-with-product "生成乘积数组的方案数") + +

    You are given a 2D integer array, queries. For each queries[i], where queries[i] = [ni, ki], find the number of different ways you can place positive integers into an array of size ni such that the product of the integers is ki. As the number of ways may be too large, the answer to the ith query is the number of ways modulo 109 + 7.

    + +

    Return an integer array answer where answer.length == queries.length, and answer[i] is the answer to the ith query.

    + +

     

    +

    Example 1:

    + +
    +Input: queries = [[2,6],[5,1],[73,660]]
    +Output: [4,1,50734910]
    +Explanation: Each query is independent.
    +[2,6]: There are 4 ways to fill an array of size 2 that multiply to 6: [1,6], [2,3], [3,2], [6,1].
    +[5,1]: There is 1 way to fill an array of size 5 that multiply to 1: [1,1,1,1,1].
    +[73,660]: There are 1050734917 ways to fill an array of size 73 that multiply to 660. 1050734917 modulo 109 + 7 = 50734910.
    +
    + +

    Example 2:

    + +
    +Input: queries = [[1,1],[2,2],[3,3],[4,4],[5,5]]
    +Output: [1,2,3,10,5]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= queries.length <= 104
    • +
    • 1 <= ni, ki <= 104
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Prime-factorize ki and count how many ways you can distribute the primes among the ni positions. +
    + +
    +Hint 2 +After prime factorizing ki, suppose there are x amount of prime factor. There are (x + n - 1) choose (n - 1) ways to distribute the x prime factors into k positions, allowing repetitions. +
    diff --git a/problems/decode-ways/README.md b/problems/decode-ways/README.md index eda25cb55..58e0cc639 100644 --- a/problems/decode-ways/README.md +++ b/problems/decode-ways/README.md @@ -55,8 +55,9 @@ Since there is no character, there are no valid ways to decode this since all di

    Example 4:

    -Input: s = "1"
    -Output: 1
    +Input: s = "06"
    +Output: 0
    +Explanation: "06" cannot be mapped to "F" because the zero at the beginning of the string can't make a valid character. 
     

     

    diff --git a/problems/decode-xored-permutation/README.md b/problems/decode-xored-permutation/README.md new file mode 100644 index 000000000..ca6f80de0 --- /dev/null +++ b/problems/decode-xored-permutation/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../minimum-number-of-people-to-teach "Minimum Number of People to Teach") +                 +[Next >](../count-ways-to-make-array-with-product "Count Ways to Make Array With Product") + +## [1734. Decode XORed Permutation (Medium)](https://leetcode.com/problems/decode-xored-permutation "解码异或后的排列") + +

    There is an integer array perm that is a permutation of the first n positive integers, where n is always odd.

    + +

    It was encoded into another integer array encoded of length n - 1, such that encoded[i] = perm[i] XOR perm[i + 1]. For example, if perm = [1,3,2], then encoded = [2,1].

    + +

    Given the encoded array, return the original array perm. It is guaranteed that the answer exists and is unique.

    + +

     

    +

    Example 1:

    + +
    +Input: encoded = [3,1]
    +Output: [1,2,3]
    +Explanation: If perm = [1,2,3], then encoded = [1 XOR 2,2 XOR 3] = [3,1]
    +
    + +

    Example 2:

    + +
    +Input: encoded = [6,5,4,6]
    +Output: [2,4,1,5,3]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= n < 105
    • +
    • n is odd.
    • +
    • encoded.length == n - 1
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + +### Hints +
    +Hint 1 +Compute the XOR of the numbers between 1 and n, and think about how it can be used. Let it be x. +
    + +
    +Hint 2 +Think why n is odd. +
    + +
    +Hint 3 +perm[0] = x XOR encoded[1] XOR encoded[3] XOR encoded[5] ... +
    + +
    +Hint 4 +perm[i] = perm[i-1] XOR encoded[i-1] +
    diff --git a/problems/delete-and-earn/README.md b/problems/delete-and-earn/README.md index 517fcfb44..d6912c94a 100644 --- a/problems/delete-and-earn/README.md +++ b/problems/delete-and-earn/README.md @@ -55,7 +55,7 @@ Then, delete 3 again to earn 3 points, and 3 again to earn 3 points. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [House Robber](../house-robber) (Easy) + 1. [House Robber](../house-robber) (Medium) ### Hints
    diff --git a/problems/design-add-and-search-words-data-structure/README.md b/problems/design-add-and-search-words-data-structure/README.md index e2687212e..29acf55cb 100644 --- a/problems/design-add-and-search-words-data-structure/README.md +++ b/problems/design-add-and-search-words-data-structure/README.md @@ -53,6 +53,7 @@ wordDictionary.search("b.."); // return True ### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Design](../../tag/design/README.md)] [[Trie](../../tag/trie/README.md)] [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/design-hashset/README.md b/problems/design-hashset/README.md index 4af6db33c..c073a3e73 100644 --- a/problems/design-hashset/README.md +++ b/problems/design-hashset/README.md @@ -11,40 +11,48 @@ ## [705. Design HashSet (Easy)](https://leetcode.com/problems/design-hashset "设计哈希集合") -

    Design a HashSet without using any built-in hash table libraries.

    +

    Design a HashSet without using any built-in hash table libraries.

    -

    To be specific, your design should include these functions:

    +

    Implement MyHashSet class:

      -
    • add(value): Insert a value into the HashSet. 
    • -
    • contains(value) : Return whether the value exists in the HashSet or not.
    • -
    • remove(value): Remove a value in the HashSet. If the value does not exist in the HashSet, do nothing.
    • +
    • void add(key) Inserts the value key into the HashSet.
    • +
    • bool contains(key) Returns whether the value key exists in the HashSet or not.
    • +
    • void remove(key) Removes the value key in the HashSet. If key does not exist in the HashSet, do nothing.
    -


    -Example:

    +

     

    +

    Example 1:

    -MyHashSet hashSet = new MyHashSet();
    -hashSet.add(1);         
    -hashSet.add(2);         
    -hashSet.contains(1);    // returns true
    -hashSet.contains(3);    // returns false (not found)
    -hashSet.add(2);          
    -hashSet.contains(2);    // returns true
    -hashSet.remove(2);          
    -hashSet.contains(2);    // returns false (already removed)
    -
    - -


    -Note:

    +Input +["MyHashSet", "add", "add", "contains", "contains", "add", "contains", "remove", "contains"] +[[], [1], [2], [1], [3], [2], [2], [2], [2]] +Output +[null, null, null, true, false, null, true, null, false] + +Explanation +MyHashSet myHashSet = new MyHashSet(); +myHashSet.add(1); // set = [1] +myHashSet.add(2); // set = [1, 2] +myHashSet.contains(1); // return True +myHashSet.contains(3); // return False, (not found) +myHashSet.add(2); // set = [1, 2] +myHashSet.contains(2); // return True +myHashSet.remove(2); // set = [1] +myHashSet.contains(2); // return False, (already removed) + +

     

    +

    Constraints:

      -
    • All values will be in the range of [0, 1000000].
    • -
    • The number of operations will be in the range of [1, 10000].
    • -
    • Please do not use the built-in HashSet library.
    • +
    • 0 <= key <= 106
    • +
    • At most 104 calls will be made to add, remove, and contains.
    +

     

    +Follow up: Could you solve the problem without using the built-in HashSet library? + ### Related Topics [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md b/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md index b5867e953..1f1029eef 100644 --- a/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md +++ b/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md @@ -11,8 +11,8 @@ ## [1296. Divide Array in Sets of K Consecutive Numbers (Medium)](https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers "划分数组为连续数字的集合") -

    Given an array of integers nums and a positive integer k, find whether it's possible to divide this array into sets of k consecutive numbers
    -Return True if its possible otherwise return False.

    +

    Given an array of integers nums and a positive integer k, find whether it's possible to divide this array into sets of k consecutive numbers
    +Return True if it is possible. Otherwise, return False.

     

    Example 1:

    @@ -50,11 +50,12 @@ Return True if its possible otherwi

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • 1 <= nums[i] <= 10^9
    • -
    • 1 <= k <= nums.length
    • +
    • 1 <= k <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 109
    -Note: This question is the same as 846: https://leetcode.com/problems/hand-of-straights/ + +

     

    +Note: This question is the same as 846: https://leetcode.com/problems/hand-of-straights/ ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md index 34f152d87..5b6881e14 100644 --- a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md +++ b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md @@ -13,11 +13,11 @@

    -

    Winston was given the above mysterious function func. He has an integer array arr and an integer target and he wants to find the values l and r that make the value |func(arr, l, r) - target| minimum possible.

    +

    Winston was given the above mysterious function func. He has an integer array arr and an integer target and he wants to find the values l and r that make the value |func(arr, l, r) - target| minimum possible.

    Return the minimum possible value of |func(arr, l, r) - target|.

    -

    Notice that func should be called with the values l and r where 0 <= l, r < arr.length.

    +

    Notice that func should be called with the values l and r where 0 <= l, r < arr.length.

     

    Example 1:

    @@ -47,9 +47,9 @@

    Constraints:

      -
    • 1 <= arr.length <= 10^5
    • -
    • 1 <= arr[i] <= 10^6
    • -
    • 0 <= target <= 10^7
    • +
    • 1 <= arr.length <= 105
    • +
    • 1 <= arr[i] <= 106
    • +
    • 0 <= target <= 107
    ### Related Topics diff --git a/problems/find-distance-in-a-binary-tree/README.md b/problems/find-distance-in-a-binary-tree/README.md new file mode 100644 index 000000000..e0d51c19f --- /dev/null +++ b/problems/find-distance-in-a-binary-tree/README.md @@ -0,0 +1,30 @@ + + + + + + + +[< Previous](../building-boxes "Building Boxes") +                 +Next > + +## [1740. Find Distance in a Binary Tree (Easy)](https://leetcode.com/problems/find-distance-in-a-binary-tree "") + + + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + +### Hints +
    +Hint 1 +Get the LCA of p and q. +
    + +
    +Hint 2 +The answer is the sum of distances between p-LCA and q-LCA +
    diff --git a/problems/find-followers-count/README.md b/problems/find-followers-count/README.md new file mode 100644 index 000000000..52d82b032 --- /dev/null +++ b/problems/find-followers-count/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../cat-and-mouse-ii "Cat and Mouse II") +                 +[Next >](../shortest-path-to-get-food "Shortest Path to Get Food") + +## [1729. Find Followers Count (Easy)](https://leetcode.com/problems/find-followers-count "") + + diff --git a/problems/find-followers-count/mysql_schemas.sql b/problems/find-followers-count/mysql_schemas.sql new file mode 100644 index 000000000..dda0ddddf --- /dev/null +++ b/problems/find-followers-count/mysql_schemas.sql @@ -0,0 +1,6 @@ +Create table If Not Exists Followers(user_id int, follower_id int); +Truncate table Followers; +insert into Followers (user_id, follower_id) values ('0', '1'); +insert into Followers (user_id, follower_id) values ('1', '0'); +insert into Followers (user_id, follower_id) values ('2', '0'); +insert into Followers (user_id, follower_id) values ('2', '1'); diff --git a/problems/find-k-closest-elements/README.md b/problems/find-k-closest-elements/README.md index ab9557ab8..7a62a8d2a 100644 --- a/problems/find-k-closest-elements/README.md +++ b/problems/find-k-closest-elements/README.md @@ -11,7 +11,7 @@ ## [658. Find K Closest Elements (Medium)](https://leetcode.com/problems/find-k-closest-elements "找到 K 个最接近的元素") -

    Given a sorted integer array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending order.

    +

    Given a sorted integer array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending order.

    An integer a is closer to x than an integer b if:

    @@ -33,8 +33,9 @@
    • 1 <= k <= arr.length
    • -
    • 1 <= arr.length <= 104
    • -
    • Absolute value of elements in the array and x will not exceed 104
    • +
    • 1 <= arr.length <= 104
    • +
    • arr is sorted in ascending order.
    • +
    • -104 <= arr[i], x <= 104
    ### Related Topics diff --git a/problems/find-kth-largest-xor-coordinate-value/README.md b/problems/find-kth-largest-xor-coordinate-value/README.md new file mode 100644 index 000000000..9f4c9e140 --- /dev/null +++ b/problems/find-kth-largest-xor-coordinate-value/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../change-minimum-characters-to-satisfy-one-of-three-conditions "Change Minimum Characters to Satisfy One of Three Conditions") +                 +[Next >](../building-boxes "Building Boxes") + +## [1738. Find Kth Largest XOR Coordinate Value (Medium)](https://leetcode.com/problems/find-kth-largest-xor-coordinate-value "找出第 K 大的异或坐标值") + +

    You are given a 2D matrix of size m x n, consisting of non-negative integers. You are also given an integer k.

    + +

    The value of coordinate (a, b) of the matrix is the XOR of all matrix[i][j] where 0 <= i <= a < m and 0 <= j <= b < n (0-indexed).

    + +

    Find the kth largest value (1-indexed) of all the coordinates of matrix.

    + +

     

    +

    Example 1:

    + +
    +Input: matrix = [[5,2],[1,6]], k = 1
    +Output: 7
    +Explanation: The value of coordinate (0,1) is 5 XOR 2 = 7, which is the largest value.
    + +

    Example 2:

    + +
    +Input: matrix = [[5,2],[1,6]], k = 2
    +Output: 5
    +Explanation: The value of coordinate (0,0) is 5 = 5, which is the 2nd largest value.
    + +

    Example 3:

    + +
    +Input: matrix = [[5,2],[1,6]], k = 3
    +Output: 4
    +Explanation: The value of coordinate (1,0) is 5 XOR 1 = 4, which is the 3rd largest value.
    + +

    Example 4:

    + +
    +Input: matrix = [[5,2],[1,6]], k = 4
    +Output: 0
    +Explanation: The value of coordinate (1,1) is 5 XOR 2 XOR 1 XOR 6 = 0, which is the 4th largest value.
    + +

     

    +

    Constraints:

    + +
      +
    • m == matrix.length
    • +
    • n == matrix[i].length
    • +
    • 1 <= m, n <= 1000
    • +
    • 0 <= matrix[i][j] <= 106
    • +
    • 1 <= k <= m * n
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Use a 2D prefix sum to precalculate the xor-sum of the upper left submatrix. +
    diff --git a/problems/find-minimum-time-to-finish-all-jobs/README.md b/problems/find-minimum-time-to-finish-all-jobs/README.md index 4e1521129..03362e8ee 100644 --- a/problems/find-minimum-time-to-finish-all-jobs/README.md +++ b/problems/find-minimum-time-to-finish-all-jobs/README.md @@ -7,7 +7,7 @@ [< Previous](../minimize-hamming-distance-after-swap-operations "Minimize Hamming Distance After Swap Operations")                  -Next > +[Next >](../checking-existence-of-edge-length-limited-paths-ii "Checking Existence of Edge Length Limited Paths II") ## [1723. Find Minimum Time to Finish All Jobs (Hard)](https://leetcode.com/problems/find-minimum-time-to-finish-all-jobs "完成所有工作的最短时间") diff --git a/problems/find-positive-integer-solution-for-a-given-equation/README.md b/problems/find-positive-integer-solution-for-a-given-equation/README.md index f70520803..71355c3fa 100644 --- a/problems/find-positive-integer-solution-for-a-given-equation/README.md +++ b/problems/find-positive-integer-solution-for-a-given-equation/README.md @@ -9,30 +9,35 @@                  [Next >](../circular-permutation-in-binary-representation "Circular Permutation in Binary Representation") -## [1237. Find Positive Integer Solution for a Given Equation (Easy)](https://leetcode.com/problems/find-positive-integer-solution-for-a-given-equation "找出给定方程的正整数解") +## [1237. Find Positive Integer Solution for a Given Equation (Medium)](https://leetcode.com/problems/find-positive-integer-solution-for-a-given-equation "找出给定方程的正整数解") -

    Given a function  f(x, y) and a value z, return all positive integer pairs x and y where f(x,y) == z.

    +

    Given a callable function f(x, y) with a hidden formula and a value z, reverse engineer the formula and return all positive integer pairs x and y where f(x,y) == z. You may return the pairs in any order.

    -

    The function is constantly increasing, i.e.:

    +

    While the exact formula is hidden, the function is monotonically increasing, i.e.:

    • f(x, y) < f(x + 1, y)
    • f(x, y) < f(x, y + 1)
    -

    The function interface is defined like this: 

    +

    The function interface is defined like this:

     interface CustomFunction {
     public:
    -  // Returns positive integer f(x, y) for any given positive integer x and y.
    -  int f(int x, int y);
    +  // Returns some positive integer f(x, y) for two positive integers x and y based on a formula.
    +  int f(int x, int y);
     };
     
    -

    For custom testing purposes you're given an integer function_id and a target z as input, where function_id represent one function from an secret internal list, on the examples you'll know only two functions from the list.  

    +

    We will judge your solution as follows:

    -

    You may return the solutions in any order.

    +
      +
    • The judge has a list of 9 hidden implementations of CustomFunction, along with a way to generate an answer key of all valid pairs for a specific z.
    • +
    • The judge will receive two inputs: a function_id (to determine which implementation to test your code with), and the target z.
    • +
    • The judge will call your findSolution and compare your results with the answer key.
    • +
    • If your results match the answer key, your solution will be Accepted.
    • +

     

    Example 1:

    @@ -40,14 +45,23 @@ public:
     Input: function_id = 1, z = 5
     Output: [[1,4],[2,3],[3,2],[4,1]]
    -Explanation: function_id = 1 means that f(x, y) = x + y
    +Explanation: The hidden formula for function_id = 1 is f(x, y) = x + y. +The following positive integer values of x and y make f(x, y) equal to 5: +x=1, y=4 -> f(1, 4) = 1 + 4 = 5. +x=2, y=3 -> f(2, 3) = 2 + 3 = 5. +x=3, y=2 -> f(3, 2) = 3 + 2 = 5. +x=4, y=1 -> f(4, 1) = 4 + 1 = 5. +

    Example 2:

     Input: function_id = 2, z = 5
     Output: [[1,5],[5,1]]
    -Explanation: function_id = 2 means that f(x, y) = x * y
    +Explanation: The hidden formula for function_id = 2 is f(x, y) = x * y.
    +The following positive integer values of x and y make f(x, y) equal to 5:
    +x=1, y=5 -> f(1, 5) = 1 * 5 = 5.
    +x=5, y=1 -> f(5, 1) = 5 * 1 = 5.
     

     

    @@ -56,8 +70,8 @@ public:
    • 1 <= function_id <= 9
    • 1 <= z <= 100
    • -
    • It's guaranteed that the solutions of f(x, y) == z will be on the range 1 <= x, y <= 1000
    • -
    • It's also guaranteed that f(x, y) will fit in 32 bit signed integer if 1 <= x, y <= 1000
    • +
    • It is guaranteed that the solutions of f(x, y) == z will be in the range 1 <= x, y <= 1000.
    • +
    • It is also guaranteed that f(x, y) will fit in 32 bit signed integer if 1 <= x, y <= 1000.
    ### Related Topics diff --git a/problems/find-the-highest-altitude/README.md b/problems/find-the-highest-altitude/README.md new file mode 100644 index 000000000..d2c7c859d --- /dev/null +++ b/problems/find-the-highest-altitude/README.md @@ -0,0 +1,56 @@ + + + + + + + +[< Previous](../the-number-of-employees-which-report-to-each-employee "The Number of Employees Which Report to Each Employee") +                 +[Next >](../minimum-number-of-people-to-teach "Minimum Number of People to Teach") + +## [1732. Find the Highest Altitude (Easy)](https://leetcode.com/problems/find-the-highest-altitude "找到最高海拔") + +

    There is a biker going on a road trip. The road trip consists of n + 1 points at different altitudes. The biker starts his trip on point 0 with altitude equal 0.

    + +

    You are given an integer array gain of length n where gain[i] is the net gain in altitude between points i​​​​​​ and i + 1 for all (0 <= i < n). Return the highest altitude of a point.

    + +

     

    +

    Example 1:

    + +
    +Input: gain = [-5,1,5,0,-7]
    +Output: 1
    +Explanation: The altitudes are [0,-5,-4,1,1,-6]. The highest is 1.
    +
    + +

    Example 2:

    + +
    +Input: gain = [-4,-3,-2,-1,4,3,2]
    +Output: 0
    +Explanation: The altitudes are [0,-4,-7,-9,-10,-6,-3,-1]. The highest is 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == gain.length
    • +
    • 1 <= n <= 100
    • +
    • -100 <= gain[i] <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Let's note that the altitude of an element is the sum of gains of all the elements behind it +
    + +
    +Hint 2 +Getting the altitudes can be done by getting the prefix sum array of the given array +
    diff --git a/problems/find-the-most-competitive-subsequence/README.md b/problems/find-the-most-competitive-subsequence/README.md index 6368432fa..1672cf137 100644 --- a/problems/find-the-most-competitive-subsequence/README.md +++ b/problems/find-the-most-competitive-subsequence/README.md @@ -44,7 +44,9 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Heap](../../tag/heap/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Queue](../../tag/queue/README.md)] ### Hints
    diff --git a/problems/first-missing-positive/README.md b/problems/first-missing-positive/README.md index eccdb8f6f..6795f0dd1 100644 --- a/problems/first-missing-positive/README.md +++ b/problems/first-missing-positive/README.md @@ -11,9 +11,7 @@ ## [41. First Missing Positive (Hard)](https://leetcode.com/problems/first-missing-positive "缺失的第一个正数") -

    Given an unsorted integer array nums, find the smallest missing positive integer.

    - -

    Follow up: Could you implement an algorithm that runs in O(n) time and uses constant extra space.?

    +

    Given an unsorted integer array nums, find the smallest missing positive integer.

     

    Example 1:

    @@ -34,6 +32,9 @@
  • -231 <= nums[i] <= 231 - 1
  • +

     

    +

    Follow up: Could you implement an algorithm that runs in O(n) time and uses constant extra space?

    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/flatten-binary-tree-to-linked-list/README.md b/problems/flatten-binary-tree-to-linked-list/README.md index 52b53dbca..7613f1785 100644 --- a/problems/flatten-binary-tree-to-linked-list/README.md +++ b/problems/flatten-binary-tree-to-linked-list/README.md @@ -11,34 +11,46 @@ ## [114. Flatten Binary Tree to Linked List (Medium)](https://leetcode.com/problems/flatten-binary-tree-to-linked-list "二叉树展开为链表") -

    Given a binary tree, flatten it to a linked list in-place.

    +

    Given the root of a binary tree, flatten the tree into a "linked list":

    -

    For example, given the following tree:

    +
      +
    • The "linked list" should use the same TreeNode class where the right child pointer points to the next node in the list and the left child pointer is always null.
    • +
    • The "linked list" should be in the same order as a pre-order traversal of the binary tree.
    • +
    +

     

    +

    Example 1:

    +
    -    1
    -   / \
    -  2   5
    - / \   \
    -3   4   6
    +Input: root = [1,2,5,3,4,null,6]
    +Output: [1,null,2,null,3,null,4,null,5,null,6]
     
    -

    The flattened tree should look like:

    +

    Example 2:

    -1
    - \
    -  2
    -   \
    -    3
    -     \
    -      4
    -       \
    -        5
    -         \
    -          6
    +Input: root = []
    +Output: []
     
    +

    Example 3:

    + +
    +Input: root = [0]
    +Output: [0]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [0, 2000].
    • +
    • -100 <= Node.val <= 100
    • +
    + +

     

    +Follow up: Can you flatten the tree in-place (with O(1) extra space)? + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/gray-code/README.md b/problems/gray-code/README.md index d8f55d259..59eb1aaf0 100644 --- a/problems/gray-code/README.md +++ b/problems/gray-code/README.md @@ -46,7 +46,7 @@

    Constraints:

      -
    • 0 <= n <= 15
    • +
    • 1 <= n <= 16
    ### Related Topics diff --git a/problems/house-robber-ii/README.md b/problems/house-robber-ii/README.md index aaca6d143..08afb0147 100644 --- a/problems/house-robber-ii/README.md +++ b/problems/house-robber-ii/README.md @@ -52,7 +52,7 @@ Total amount you can rob = 1 + 3 = 4. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [House Robber](../house-robber) (Easy) + 1. [House Robber](../house-robber) (Medium) 1. [Paint House](../paint-house) (Medium) 1. [Paint Fence](../paint-fence) (Easy) 1. [House Robber III](../house-robber-iii) (Medium) diff --git a/problems/house-robber-iii/README.md b/problems/house-robber-iii/README.md index 55f2fe6f3..67ac3eb50 100644 --- a/problems/house-robber-iii/README.md +++ b/problems/house-robber-iii/README.md @@ -49,5 +49,5 @@ [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [House Robber](../house-robber) (Easy) + 1. [House Robber](../house-robber) (Medium) 1. [House Robber II](../house-robber-ii) (Medium) diff --git a/problems/house-robber/README.md b/problems/house-robber/README.md index eec3c1ba5..004111de6 100644 --- a/problems/house-robber/README.md +++ b/problems/house-robber/README.md @@ -9,7 +9,7 @@                  [Next >](../binary-tree-right-side-view "Binary Tree Right Side View") -## [198. House Robber (Easy)](https://leetcode.com/problems/house-robber "打家劫舍") +## [198. House Robber (Medium)](https://leetcode.com/problems/house-robber "打家劫舍")

    You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.

    diff --git a/problems/insert-interval/README.md b/problems/insert-interval/README.md index 5aaeafc03..2937fb262 100644 --- a/problems/insert-interval/README.md +++ b/problems/insert-interval/README.md @@ -9,7 +9,7 @@                  [Next >](../length-of-last-word "Length of Last Word") -## [57. Insert Interval (Hard)](https://leetcode.com/problems/insert-interval "插入区间") +## [57. Insert Interval (Medium)](https://leetcode.com/problems/insert-interval "插入区间")

    Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).

    diff --git a/problems/interval-list-intersections/README.md b/problems/interval-list-intersections/README.md index b394cb21e..52e4f92ad 100644 --- a/problems/interval-list-intersections/README.md +++ b/problems/interval-list-intersections/README.md @@ -11,34 +11,54 @@ ## [986. Interval List Intersections (Medium)](https://leetcode.com/problems/interval-list-intersections "区间列表的交集") -

    Given two lists of closed intervals, each list of intervals is pairwise disjoint and in sorted order.

    +

    You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [starti, endi] and secondList[j] = [startj, endj]. Each list of intervals is pairwise disjoint and in sorted order.

    -

    Return the intersection of these two interval lists.

    +

    Return the intersection of these two interval lists.

    -

    (Formally, a closed interval [a, b] (with a <= b) denotes the set of real numbers x with a <= x <= b.  The intersection of two closed intervals is a set of real numbers that is either empty, or can be represented as a closed interval.  For example, the intersection of [1, 3] and [2, 4] is [2, 3].)

    +

    A closed interval [a, b] (with a < b) denotes the set of real numbers x with a <= x <= b.

    -
    -

     

    +

    The intersection of two closed intervals is a set of real numbers that are either empty or represented as a closed interval. For example, the intersection of [1, 3] and [2, 4] is [2, 3].

    +

     

    Example 1:

    + +
    +Input: firstList = [[0,2],[5,10],[13,23],[24,25]], secondList = [[1,5],[8,12],[15,24],[25,26]]
    +Output: [[1,2],[5,5],[8,10],[15,23],[24,24],[25,25]]
    +
    -

    +

    Example 2:

    -Input: A = [[0,2],[5,10],[13,23],[24,25]], B = [[1,5],[8,12],[15,24],[25,26]]
    -Output: [[1,2],[5,5],[8,10],[15,23],[24,24],[25,25]]
    +Input: firstList = [[1,3],[5,9]], secondList = []
    +Output: []
     
    -

     

    +

    Example 3:

    -

    Note:

    +
    +Input: firstList = [], secondList = [[4,8],[10,12]]
    +Output: []
    +
    + +

    Example 4:

    + +
    +Input: firstList = [[1,7]], secondList = [[3,10]]
    +Output: [[3,7]]
    +
    + +

     

    +

    Constraints:

    -
      -
    1. 0 <= A.length < 1000
    2. -
    3. 0 <= B.length < 1000
    4. -
    5. 0 <= A[i].start, A[i].end, B[i].start, B[i].end < 10^9
    6. -
    -
    +
      +
    • 0 <= firstList.length, secondList.length <= 1000
    • +
    • firstList.length + secondList.length >= 1
    • +
    • 0 <= starti < endi <= 109
    • +
    • endi < starti+1
    • +
    • 0 <= startj < endj <= 109
    • +
    • endj < startj+1
    • +
    ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/invalid-transactions/README.md b/problems/invalid-transactions/README.md index efdd20ee9..3e0997baf 100644 --- a/problems/invalid-transactions/README.md +++ b/problems/invalid-transactions/README.md @@ -11,16 +11,16 @@ ## [1169. Invalid Transactions (Medium)](https://leetcode.com/problems/invalid-transactions "查询无效交易") -

    A transaction is possibly invalid if:

    +

    A transaction is possibly invalid if:

      -
    • the amount exceeds $1000, or;
    • -
    • if it occurs within (and including) 60 minutes of another transaction with the same name in a different city.
    • +
    • the amount exceeds $1000, or;
    • +
    • if it occurs within (and including) 60 minutes of another transaction with the same name in a different city.
    -

    Each transaction string transactions[i] consists of comma separated values representing the name, time (in minutes), amount, and city of the transaction.

    +

    You are given an array of strings transaction where transactions[i] consists of comma-separated values representing the name, time (in minutes), amount, and city of the transaction.

    -

    Given a list of transactions, return a list of transactions that are possibly invalid.  You may return the answer in any order.

    +

    Return a list of transactions that are possibly invalid. You may return the answer in any order.

     

    Example 1:

    @@ -50,9 +50,9 @@
    • transactions.length <= 1000
    • Each transactions[i] takes the form "{name},{time},{amount},{city}"
    • -
    • Each {name} and {city} consist of lowercase English letters, and have lengths between 1 and 10.
    • -
    • Each {time} consist of digits, and represent an integer between 0 and 1000.
    • -
    • Each {amount} consist of digits, and represent an integer between 0 and 2000.
    • +
    • Each {name} and {city} consist of lowercase English letters, and have lengths between 1 and 10.
    • +
    • Each {time} consist of digits, and represent an integer between 0 and 1000.
    • +
    • Each {amount} consist of digits, and represent an integer between 0 and 2000.
    ### Related Topics diff --git a/problems/invalid-tweets/README.md b/problems/invalid-tweets/README.md index 121d0161d..501bb631a 100644 --- a/problems/invalid-tweets/README.md +++ b/problems/invalid-tweets/README.md @@ -9,6 +9,6 @@                  [Next >](../count-the-number-of-consistent-strings "Count the Number of Consistent Strings") -## [1683. Invalid Tweets (Easy)](https://leetcode.com/problems/invalid-tweets "") +## [1683. Invalid Tweets (Easy)](https://leetcode.com/problems/invalid-tweets "无效的推文") diff --git a/problems/k-concatenation-maximum-sum/README.md b/problems/k-concatenation-maximum-sum/README.md index 5e6b5ecb3..a42ff6462 100644 --- a/problems/k-concatenation-maximum-sum/README.md +++ b/problems/k-concatenation-maximum-sum/README.md @@ -11,13 +11,13 @@ ## [1191. K-Concatenation Maximum Sum (Medium)](https://leetcode.com/problems/k-concatenation-maximum-sum "K 次串联后最大子数组之和") -

    Given an integer array arr and an integer k, modify the array by repeating it k times.

    +

    Given an integer array arr and an integer k, modify the array by repeating it k times.

    -

    For example, if arr = [1, 2] and k = 3 then the modified array will be [1, 2, 1, 2, 1, 2].

    +

    For example, if arr = [1, 2] and k = 3 then the modified array will be [1, 2, 1, 2, 1, 2].

    -

    Return the maximum sub-array sum in the modified array. Note that the length of the sub-array can be 0 and its sum in that case is 0.

    +

    Return the maximum sub-array sum in the modified array. Note that the length of the sub-array can be 0 and its sum in that case is 0.

    -

    As the answer can be very large, return the answer modulo 10^9 + 7.

    +

    As the answer can be very large, return the answer modulo 109 + 7.

     

    Example 1:

    @@ -45,9 +45,9 @@

    Constraints:

      -
    • 1 <= arr.length <= 10^5
    • -
    • 1 <= k <= 10^5
    • -
    • -10^4 <= arr[i] <= 10^4
    • +
    • 1 <= arr.length <= 105
    • +
    • 1 <= k <= 105
    • +
    • -104 <= arr[i] <= 104
    ### Related Topics diff --git a/problems/k-th-smallest-prime-fraction/README.md b/problems/k-th-smallest-prime-fraction/README.md index e93afd957..2b091d885 100644 --- a/problems/k-th-smallest-prime-fraction/README.md +++ b/problems/k-th-smallest-prime-fraction/README.md @@ -11,29 +11,40 @@ ## [786. K-th Smallest Prime Fraction (Hard)](https://leetcode.com/problems/k-th-smallest-prime-fraction "第 K 个最小的素数分数") -

    A sorted list A contains 1, plus some number of primes.  Then, for every p < q in the list, we consider the fraction p/q.

    +

    You are given a sorted integer array arr containing 1 and prime numbers, where all the integers of arr are unique. You are also given an integer k.

    -

    What is the K-th smallest fraction considered?  Return your answer as an array of ints, where answer[0] = p and answer[1] = q.

    +

    For every i and j where 0 <= i < j < arr.length, we consider the fraction arr[i] / arr[j].

    + +

    Return the kth smallest fraction considered. Return your answer as an array of integers of size 2, where answer[0] == arr[i] and answer[1] == arr[j].

    + +

     

    +

    Example 1:

    -Examples:
    -Input: A = [1, 2, 3, 5], K = 3
    -Output: [2, 5]
    -Explanation:
    -The fractions to be considered in sorted order are:
    -1/5, 1/3, 2/5, 1/2, 3/5, 2/3.
    +Input: arr = [1,2,3,5], k = 3
    +Output: [2,5]
    +Explanation: The fractions to be considered in sorted order are:
    +1/5, 1/3, 2/5, 1/2, 3/5, and 2/3.
     The third fraction is 2/5.
    +
    -Input: A = [1, 7], K = 1 -Output: [1, 7] +

    Example 2:

    + +
    +Input: arr = [1,7], k = 1
    +Output: [1,7]
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • A will have length between 2 and 2000.
    • -
    • Each A[i] will be between 1 and 30000.
    • -
    • K will be between 1 and A.length * (A.length - 1) / 2.
    • +
    • 2 <= arr.length <= 1000
    • +
    • 1 <= arr[i] <= 3 * 104
    • +
    • arr[0] == 1
    • +
    • arr[i] is a prime number for i > 0.
    • +
    • All the numbers of arr are unique and sorted in strictly increasing order.
    • +
    • 1 <= k <= arr.length * (arr.length - 1) / 2
    ### Related Topics diff --git a/problems/keyboard-row/README.md b/problems/keyboard-row/README.md index 78137a474..140f7649a 100644 --- a/problems/keyboard-row/README.md +++ b/problems/keyboard-row/README.md @@ -11,28 +11,46 @@ ## [500. Keyboard Row (Easy)](https://leetcode.com/problems/keyboard-row "键盘行") -

    Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below.

    +

    Given an array of strings words, return the words that can be typed using letters of the alphabet on only one row of American keyboard like the image below.

    +

    In the American keyboard:

    + +
      +
    • the first row consists of the characters "qwertyuiop",
    • +
    • the second row consists of the characters "asdfghjkl", and
    • +
    • the third row consists of the characters "zxcvbnm".
    • +
    +

     

    +

    Example 1:

    -

    -  +
    +Input: words = ["Hello","Alaska","Dad","Peace"]
    +Output: ["Alaska","Dad"]
    +
    -

    Example:

    +

    Example 2:

    -Input: ["Hello", "Alaska", "Dad", "Peace"]
    -Output: ["Alaska", "Dad"]
    +Input: words = ["omk"]
    +Output: []
     
    -

     

    +

    Example 3:

    -

    Note:

    +
    +Input: words = ["adsdf","sfd"]
    +Output: ["adsdf","sfd"]
    +
    + +

     

    +

    Constraints:

    -
      -
    1. You may use one character in the keyboard more than once.
    2. -
    3. You may assume the input string will only contain letters of alphabet.
    4. -
    +
      +
    • 1 <= words.length <= 20
    • +
    • 1 <= words[i].length <= 100
    • +
    • words[i] consists of English letters (both lowercase and uppercase). 
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/kth-smallest-element-in-a-bst/README.md b/problems/kth-smallest-element-in-a-bst/README.md index ccb774a3b..c36d3271e 100644 --- a/problems/kth-smallest-element-in-a-bst/README.md +++ b/problems/kth-smallest-element-in-a-bst/README.md @@ -11,46 +11,35 @@ ## [230. Kth Smallest Element in a BST (Medium)](https://leetcode.com/problems/kth-smallest-element-in-a-bst "二叉搜索树中第K小的元素") -

    Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.

    +

    Given the root of a binary search tree, and an integer k, return the kth (1-indexed) smallest element in the tree.

     

    -

    Example 1:

    - +
     Input: root = [3,1,4,null,2], k = 1
    -   3
    -  / \
    - 1   4
    -  \
    -   2
    -Output: 1
    +Output: 1 +

    Example 2:

    - +
     Input: root = [5,3,6,2,4,null,null,1], k = 3
    -       5
    -      / \
    -     3   6
    -    / \
    -   2   4
    -  /
    - 1
     Output: 3
     
    -

    Follow up:
    -What if the BST is modified (insert/delete operations) often and you need to find the kth smallest frequently? How would you optimize the kthSmallest routine?

    -

     

    Constraints:

      -
    • The number of elements of the BST is between 1 to 10^4.
    • -
    • You may assume k is always valid, 1 ≤ k ≤ BST's total elements.
    • +
    • The number of nodes in the tree is n.
    • +
    • 1 <= k <= n <= 104
    • +
    • 0 <= Node.val <= 104
    +

     

    +Follow up: If the BST is modified often (i.e., we can do insert and delete operations) and you need to find the kth smallest frequently, how would you optimize? + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/largest-subarray-length-k/README.md b/problems/largest-subarray-length-k/README.md index f4c475c66..c4643ca22 100644 --- a/problems/largest-subarray-length-k/README.md +++ b/problems/largest-subarray-length-k/README.md @@ -9,7 +9,7 @@                  [Next >](../biggest-window-between-visits "Biggest Window Between Visits") -## [1708. Largest Subarray Length K (Easy)](https://leetcode.com/problems/largest-subarray-length-k "") +## [1708. Largest Subarray Length K (Easy)](https://leetcode.com/problems/largest-subarray-length-k "长度为 K 的最大子数组") diff --git a/problems/largest-submatrix-with-rearrangements/README.md b/problems/largest-submatrix-with-rearrangements/README.md new file mode 100644 index 000000000..0a91dc32b --- /dev/null +++ b/problems/largest-submatrix-with-rearrangements/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../tuple-with-same-product "Tuple with Same Product") +                 +[Next >](../cat-and-mouse-ii "Cat and Mouse II") + +## [1727. Largest Submatrix With Rearrangements (Medium)](https://leetcode.com/problems/largest-submatrix-with-rearrangements "重新排列后的最大子矩阵") + +

    You are given a binary matrix matrix of size m x n, and you are allowed to rearrange the columns of the matrix in any order.

    + +

    Return the area of the largest submatrix within matrix where every element of the submatrix is 1 after reordering the columns optimally.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: matrix = [[0,0,1],[1,1,1],[1,0,1]]
    +Output: 4
    +Explanation: You can rearrange the columns as shown above.
    +The largest submatrix of 1s, in bold, has an area of 4.
    +
    + +

    Example 2:

    + +

    + +
    +Input: matrix = [[1,0,1,0,1]]
    +Output: 3
    +Explanation: You can rearrange the columns as shown above.
    +The largest submatrix of 1s, in bold, has an area of 3.
    +
    + +

    Example 3:

    + +
    +Input: matrix = [[1,1,0],[1,0,1]]
    +Output: 2
    +Explanation: Notice that you must rearrange entire columns, and there is no way to make a submatrix of 1s larger than an area of 2.
    + +

    Example 4:

    + +
    +Input: matrix = [[0,0],[0,0]]
    +Output: 0
    +Explanation: As there are no 1s, no submatrix of 1s can be formed and the area is 0.
    + +

     

    +

    Constraints:

    + +
      +
    • m == matrix.length
    • +
    • n == matrix[i].length
    • +
    • 1 <= m * n <= 105
    • +
    • matrix[i][j] is 0 or 1.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Sort](../../tag/sort/README.md)] + +### Hints +
    +Hint 1 +For each column, find the number of consecutive ones ending at each position. +
    + +
    +Hint 2 +For each row, sort the cumulative ones in non-increasing order and "fit" the largest submatrix. +
    diff --git a/problems/latest-time-by-replacing-hidden-digits/README.md b/problems/latest-time-by-replacing-hidden-digits/README.md new file mode 100644 index 000000000..518bb1569 --- /dev/null +++ b/problems/latest-time-by-replacing-hidden-digits/README.md @@ -0,0 +1,64 @@ + + + + + + + +[< Previous](../count-ways-to-make-array-with-product "Count Ways to Make Array With Product") +                 +[Next >](../change-minimum-characters-to-satisfy-one-of-three-conditions "Change Minimum Characters to Satisfy One of Three Conditions") + +## [1736. Latest Time by Replacing Hidden Digits (Easy)](https://leetcode.com/problems/latest-time-by-replacing-hidden-digits "替换隐藏数字得到的最晚时间") + +

    You are given a string time in the form of hh:mm, where some of the digits in the string are hidden (represented by ?).

    + +

    The valid times are those inclusively between 00:00 and 23:59.

    + +

    Return the latest valid time you can get from time by replacing the hidden digits.

    + +

     

    +

    Example 1:

    + +
    +Input: time = "2?:?0"
    +Output: "23:50"
    +Explanation: The latest hour beginning with the digit '2' is 23 and the latest minute ending with the digit '0' is 50.
    +
    + +

    Example 2:

    + +
    +Input: time = "0?:3?"
    +Output: "09:39"
    +
    + +

    Example 3:

    + +
    +Input: time = "1?:22"
    +Output: "19:22"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • time is in the format hh:mm.
    • +
    • It is guaranteed that you can produce a valid time from the given string.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Trying out all possible solutions from biggest to smallest would fit in the time limit. +
    + +
    +Hint 2 +To check if the solution is okay, you need to find out if it's valid and matches every character +
    diff --git a/problems/lfu-cache/README.md b/problems/lfu-cache/README.md index f951ee4ce..94c9f70ca 100644 --- a/problems/lfu-cache/README.md +++ b/problems/lfu-cache/README.md @@ -11,17 +11,19 @@ ## [460. LFU Cache (Hard)](https://leetcode.com/problems/lfu-cache "LFU 缓存") -

    Design and implement a data structure for Least Frequently Used (LFU) cache.

    +

    Design and implement a data structure for a Least Frequently Used (LFU) cache.

    -

    Implement the LFUCache class:

    +

    Implement the LFUCache class:

    • LFUCache(int capacity) Initializes the object with the capacity of the data structure.
    • -
    • int get(int key) Gets the value of the key if the key exists in the cache. Otherwise, returns -1.
    • -
    • void put(int key, int value) Sets or inserts the value if the key is not already present. When the cache reaches its capacity, it should invalidate the least frequently used item before inserting a new item. For this problem, when there is a tie (i.e., two or more keys with the same frequency), the least recently used key would be evicted.
    • +
    • int get(int key) Gets the value of the key if the key exists in the cache. Otherwise, returns -1.
    • +
    • void put(int key, int value) Update the value of the key if present, or inserts the key if not already present. When the cache reaches its capacity, it should invalidate and remove the least frequently used key before inserting a new item. For this problem, when there is a tie (i.e., two or more keys with the same frequency), the least recently used key would be invalidated.
    -

    Notice that the number of times an item is used is the number of calls to the get and put functions for that item since it was inserted. This number is set to zero when the item is removed.

    +

    To determine the least frequently used key, a use counter is maintained for each key in the cache. The key with the smallest use counter is the least frequently used key.

    + +

    When a key is first inserted into the cache, its use counter is set to 1 (due to the put operation). The use counter for a key in the cache is incremented either a get or put operation is called on it.

     

    Example 1:

    @@ -34,24 +36,32 @@ [null, null, null, 1, null, -1, 3, null, -1, 3, 4] Explanation +// cnt(x) = the use counter for key x +// cache=[] will show the last used order for tiebreakers (leftmost element is most recent) LFUCache lfu = new LFUCache(2); -lfu.put(1, 1); -lfu.put(2, 2); +lfu.put(1, 1); // cache=[1,_], cnt(1)=1 +lfu.put(2, 2); // cache=[2,1], cnt(2)=1, cnt(1)=1 lfu.get(1); // return 1 -lfu.put(3, 3); // evicts key 2 + // cache=[1,2], cnt(2)=1, cnt(1)=2 +lfu.put(3, 3); // 2 is the LFU key because cnt(2)=1 is the smallest, invalidate 2. +  // cache=[3,1], cnt(3)=1, cnt(1)=2 lfu.get(2); // return -1 (not found) lfu.get(3); // return 3 -lfu.put(4, 4); // evicts key 1. + // cache=[3,1], cnt(3)=2, cnt(1)=2 +lfu.put(4, 4); // Both 1 and 3 have the same cnt, but 1 is LRU, invalidate 1. + // cache=[4,3], cnt(4)=1, cnt(3)=2 lfu.get(1); // return -1 (not found) lfu.get(3); // return 3 + // cache=[3,4], cnt(4)=1, cnt(3)=3 lfu.get(4); // return 4 + // cache=[3,4], cnt(4)=2, cnt(3)=3

     

    Constraints:

      -
    • 0 <= capacity, key, value <= 104
    • +
    • 0 <= capacity, key, value <= 104
    • At most 105 calls will be made to get and put.
    diff --git a/problems/longest-arithmetic-subsequence-of-given-difference/README.md b/problems/longest-arithmetic-subsequence-of-given-difference/README.md index 5dd08c02d..bfd9c439d 100644 --- a/problems/longest-arithmetic-subsequence-of-given-difference/README.md +++ b/problems/longest-arithmetic-subsequence-of-given-difference/README.md @@ -11,7 +11,9 @@ ## [1218. Longest Arithmetic Subsequence of Given Difference (Medium)](https://leetcode.com/problems/longest-arithmetic-subsequence-of-given-difference "最长定差子序列") -

    Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that the difference between adjacent elements in the subsequence equals difference.

    +

    Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that the difference between adjacent elements in the subsequence equals difference.

    + +

    A subsequence is a sequence that can be derived from arr by deleting some or no elements without changing the order of the remaining elements.

     

    Example 1:

    @@ -41,11 +43,12 @@

    Constraints:

      -
    • 1 <= arr.length <= 10^5
    • -
    • -10^4 <= arr[i], difference <= 10^4
    • +
    • 1 <= arr.length <= 105
    • +
    • -104 <= arr[i], difference <= 104
    ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/longest-consecutive-sequence/README.md b/problems/longest-consecutive-sequence/README.md index bb9824cce..2c7ab18a4 100644 --- a/problems/longest-consecutive-sequence/README.md +++ b/problems/longest-consecutive-sequence/README.md @@ -13,8 +13,6 @@

    Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.

    -

    Follow up: Could you implement the O(n) solution? 

    -

     

    Example 1:

    @@ -39,6 +37,9 @@
  • -109 <= nums[i] <= 109
  • +

     

    +Follow up: Could you implement the O(n) solution? + ### Related Topics [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] diff --git a/problems/longest-increasing-path-in-a-matrix/README.md b/problems/longest-increasing-path-in-a-matrix/README.md index 729dda6e6..c00d9c570 100644 --- a/problems/longest-increasing-path-in-a-matrix/README.md +++ b/problems/longest-increasing-path-in-a-matrix/README.md @@ -11,7 +11,7 @@ ## [329. Longest Increasing Path in a Matrix (Hard)](https://leetcode.com/problems/longest-increasing-path-in-a-matrix "矩阵中的最长递增路径") -

    Given an m x n matrix, return the length of the longest increasing path in matrix.

    +

    Given an m x n integers matrix, return the length of the longest increasing path in matrix.

    From each cell, you can either move in four directions: left, right, up, or down. You may not move diagonally or move outside the boundary (i.e., wrap-around is not allowed).

    @@ -25,7 +25,7 @@

    Example 2:

    - +
     Input: matrix = [[3,4,5],[3,2,6],[2,2,1]]
     Output: 4
    diff --git a/problems/maximum-level-sum-of-a-binary-tree/README.md b/problems/maximum-level-sum-of-a-binary-tree/README.md
    index 56f9074ac..caea5dfc4 100644
    --- a/problems/maximum-level-sum-of-a-binary-tree/README.md
    +++ b/problems/maximum-level-sum-of-a-binary-tree/README.md
    @@ -11,9 +11,9 @@
     
     ## [1161. Maximum Level Sum of a Binary Tree (Medium)](https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree "最大层内元素和")
     
    -

    Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on.

    +

    Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on.

    -

    Return the smallest level X such that the sum of all the values of nodes at level X is maximal.

    +

    Return the smallest level x such that the sum of all the values of nodes at level x is maximal.

     

    Example 1:

    @@ -40,7 +40,7 @@ So we return the level with the maximum sum which is level 2.
    • The number of nodes in the tree is in the range [1, 104].
    • -
    • -105 <= Node.val <= 105
    • +
    • -105 <= Node.val <= 105
    ### Related Topics diff --git a/problems/maximum-number-of-visible-points/README.md b/problems/maximum-number-of-visible-points/README.md index 9dd342b88..4f0326cf0 100644 --- a/problems/maximum-number-of-visible-points/README.md +++ b/problems/maximum-number-of-visible-points/README.md @@ -13,7 +13,7 @@

    You are given an array points, an integer angle, and your location, where location = [posx, posy] and points[i] = [xi, yi] both denote integral coordinates on the X-Y plane.

    -

    Initially, you are facing directly east from your position. You cannot move from your position, but you can rotate. In other words, posx and posy cannot be changed. Your field of view in degrees is represented by angle, determining how wide you can see from any given view direction. Let d be the amount in degrees that you rotate counterclockwise. Then, your field of view is the inclusive range of angles [d - angle/2, d + angle/2].

    +

    Initially, you are facing directly east from your position. You cannot move from your position, but you can rotate. In other words, posx and posy cannot be changed. Your field of view in degrees is represented by angle, determining how wide you can see from any given view direction. Let d be the amount in degrees that you rotate counterclockwise. Then, your field of view is the inclusive range of angles [d - angle/2, d + angle/2].

    @@ -58,7 +58,7 @@

  • points[i].length == 2
  • location.length == 2
  • 0 <= angle < 360
  • -
  • 0 <= posx, posy, xi, yi <= 109
  • +
  • 0 <= posx, posy, xi, yi <= 100
  • ### Related Topics diff --git a/problems/maximum-product-subarray/README.md b/problems/maximum-product-subarray/README.md index f2ebe7fbf..9e981d397 100644 --- a/problems/maximum-product-subarray/README.md +++ b/problems/maximum-product-subarray/README.md @@ -34,7 +34,7 @@ ### Similar Questions 1. [Maximum Subarray](../maximum-subarray) (Easy) - 1. [House Robber](../house-robber) (Easy) + 1. [House Robber](../house-robber) (Medium) 1. [Product of Array Except Self](../product-of-array-except-self) (Medium) 1. [Maximum Product of Three Numbers](../maximum-product-of-three-numbers) (Easy) 1. [Subarray Product Less Than K](../subarray-product-less-than-k) (Medium) diff --git a/problems/meeting-scheduler/README.md b/problems/meeting-scheduler/README.md index 361377598..1bc07e1e8 100644 --- a/problems/meeting-scheduler/README.md +++ b/problems/meeting-scheduler/README.md @@ -47,6 +47,8 @@ ### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] [[Line Sweep](../../tag/line-sweep/README.md)] ### Hints diff --git a/problems/merge-intervals/README.md b/problems/merge-intervals/README.md index ebfc285ad..364a16562 100644 --- a/problems/merge-intervals/README.md +++ b/problems/merge-intervals/README.md @@ -44,7 +44,7 @@ [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Insert Interval](../insert-interval) (Hard) + 1. [Insert Interval](../insert-interval) (Medium) 1. [Meeting Rooms](../meeting-rooms) (Easy) 1. [Meeting Rooms II](../meeting-rooms-ii) (Medium) 1. [Teemo Attacking](../teemo-attacking) (Medium) diff --git a/problems/merge-sorted-array/README.md b/problems/merge-sorted-array/README.md index be265a7c6..92c40344e 100644 --- a/problems/merge-sorted-array/README.md +++ b/problems/merge-sorted-array/README.md @@ -13,7 +13,7 @@

    Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.

    -

    The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has enough space (size that is equal to m + n) to hold additional elements from nums2.

    +

    The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has a size equal to m + n such that it has enough space to hold additional elements from nums2.

     

    Example 1:

    @@ -27,10 +27,10 @@

    Constraints:

      -
    • 0 <= n, m <= 200
    • -
    • 1 <= n + m <= 200
    • nums1.length == m + n
    • nums2.length == n
    • +
    • 0 <= m, n <= 200
    • +
    • 1 <= m + n <= 200
    • -109 <= nums1[i], nums2[i] <= 109
    diff --git a/problems/minimize-malware-spread-ii/README.md b/problems/minimize-malware-spread-ii/README.md index 7c8751027..f150f2105 100644 --- a/problems/minimize-malware-spread-ii/README.md +++ b/problems/minimize-malware-spread-ii/README.md @@ -11,59 +11,41 @@ ## [928. Minimize Malware Spread II (Hard)](https://leetcode.com/problems/minimize-malware-spread-ii "尽量减少恶意软件的传播 II") -

    (This problem is the same as Minimize Malware Spread, with the differences bolded.)

    +

    You are given a network of n nodes represented as an n x n adjacency matrix graph, where the ith node is directly connected to the jth node if graph[i][j] == 1.

    -

    In a network of nodes, each node i is directly connected to another node j if and only if graph[i][j] = 1.

    +

    Some nodes initial are initially infected by malware. Whenever two nodes are directly connected, and at least one of those two nodes is infected by malware, both nodes will be infected by malware. This spread of malware will continue until no more nodes can be infected in this manner.

    -

    Some nodes initial are initially infected by malware.  Whenever two nodes are directly connected and at least one of those two nodes is infected by malware, both nodes will be infected by malware.  This spread of malware will continue until no more nodes can be infected in this manner.

    +

    Suppose M(initial) is the final number of nodes infected with malware in the entire network after the spread of malware stops.

    -

    Suppose M(initial) is the final number of nodes infected with malware in the entire network, after the spread of malware stops.

    +

    We will remove exactly one node from initial, completely removing it and any connections from this node to any other node.

    -

    We will remove one node from the initial list, completely removing it and any connections from this node to any other node.  Return the node that if removed, would minimize M(initial).  If multiple nodes could be removed to minimize M(initial), return such a node with the smallest index.

    +

    Return the node that, if removed, would minimize M(initial). If multiple nodes could be removed to minimize M(initial), return such a node with the smallest index.

     

    - -
      -
    - -

    Example 1:

    - -
    -Input: graph = [[1,1,0],[1,1,0],[0,0,1]], initial = [0,1]
    -Output: 0
    -
    - -
    -

    Example 2:

    - -
    -Input: graph = [[1,1,0],[1,1,1],[0,1,1]], initial = [0,1]
    -Output: 1
    +
    Input: graph = [[1,1,0],[1,1,0],[0,0,1]], initial = [0,1]
    +Output: 0
    +

    Example 2:

    +
    Input: graph = [[1,1,0],[1,1,1],[0,1,1]], initial = [0,1]
    +Output: 1
    +

    Example 3:

    +
    Input: graph = [[1,1,0,0],[1,1,1,0],[0,1,1,1],[0,0,1,1]], initial = [0,1]
    +Output: 1
     
    - -
    -

    Example 3:

    - -
    -Input: graph = [[1,1,0,0],[1,1,1,0],[0,1,1,1],[0,0,1,1]], initial = [0,1]
    -Output: 1
    -
    -

     

    - -

    Note:

    - -
      -
    1. 1 < graph.length = graph[0].length <= 300
    2. -
    3. 0 <= graph[i][j] == graph[j][i] <= 1
    4. -
    5. graph[i][i] = 1
    6. -
    7. 1 <= initial.length < graph.length
    8. -
    9. 0 <= initial[i] < graph.length
    10. -
    -
    -
    -
    +

    Constraints:

    + +
      +
    • n == graph.length
    • +
    • n == graph[i].length
    • +
    • 2 <= n <= 300
    • +
    • graph[i][j] is 0 or 1.
    • +
    • graph[i][j] == graph[j][i]
    • +
    • graph[i][i] == 1
    • +
    • 1 <= initial.length < n
    • +
    • 0 <= initial[i] <= n - 1
    • +
    • All the integers in initial are unique.
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/minimize-malware-spread/README.md b/problems/minimize-malware-spread/README.md index 7006bac65..b55400056 100644 --- a/problems/minimize-malware-spread/README.md +++ b/problems/minimize-malware-spread/README.md @@ -13,13 +13,13 @@

    You are given a network of n nodes represented as an n x n adjacency matrix graph, where the ith node is directly connected to the jth node if graph[i][j] == 1.

    -

    Some nodes initial are initially infected by malware. Whenever two nodes are directly connected and at least one of those two nodes is infected by malware, both nodes will be infected by malware. This spread of malware will continue until no more nodes can be infected in this manner.

    +

    Some nodes initial are initially infected by malware. Whenever two nodes are directly connected, and at least one of those two nodes is infected by malware, both nodes will be infected by malware. This spread of malware will continue until no more nodes can be infected in this manner.

    Suppose M(initial) is the final number of nodes infected with malware in the entire network after the spread of malware stops. We will remove exactly one node from initial.

    -

    Return the node that if removed, would minimize M(initial). If multiple nodes could be removed to minimize M(initial), return such a node with the smallest index.

    +

    Return the node that, if removed, would minimize M(initial). If multiple nodes could be removed to minimize M(initial), return such a node with the smallest index.

    -

    Note that if a node was removed from the initial list of infected nodes, it may still be infected later as a result of the malware spread.

    +

    Note that if a node was removed from the initial list of infected nodes, it might still be infected later due to the malware spread.

     

    Example 1:

    diff --git a/problems/minimum-number-of-people-to-teach/README.md b/problems/minimum-number-of-people-to-teach/README.md new file mode 100644 index 000000000..0da9d8daa --- /dev/null +++ b/problems/minimum-number-of-people-to-teach/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../find-the-highest-altitude "Find the Highest Altitude") +                 +[Next >](../decode-xored-permutation "Decode XORed Permutation") + +## [1733. Minimum Number of People to Teach (Medium)](https://leetcode.com/problems/minimum-number-of-people-to-teach "需要教语言的最少人数") + +

    On a social network consisting of m users and some friendships between users, two users can communicate with each other if they know a common language.

    + +

    You are given an integer n, an array languages, and an array friendships where:

    + +
      +
    • There are n languages numbered 1 through n,
    • +
    • languages[i] is the set of languages the i​​​​​​th​​​​ user knows, and
    • +
    • friendships[i] = [u​​​​​​i​​​, v​​​​​​i] denotes a friendship between the users u​​​​​​​​​​​i​​​​​ and vi.
    • +
    + +

    You can choose one language and teach it to some users so that all friends can communicate with each other. Return the minimum number of users you need to teach.

    +Note that friendships are not transitive, meaning if x is a friend of y and y is a friend of z, this doesn't guarantee that x is a friend of z. +

     

    +

    Example 1:

    + +
    +Input: n = 2, languages = [[1],[2],[1,2]], friendships = [[1,2],[1,3],[2,3]]
    +Output: 1
    +Explanation: You can either teach user 1 the second language or user 2 the first language.
    +
    + +

    Example 2:

    + +
    +Input: n = 3, languages = [[2],[1,3],[1,2],[3]], friendships = [[1,4],[1,2],[3,4],[2,3]]
    +Output: 2
    +Explanation: Teach the third language to users 1 and 3, yielding two users to teach.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 500
    • +
    • languages.length == m
    • +
    • 1 <= m <= 500
    • +
    • 1 <= languages[i].length <= n
    • +
    • 1 <= languages[i][j] <= n
    • +
    • 1 <= u​​​​​​i < v​​​​​​i <= languages.length
    • +
    • 1 <= friendships.length <= 500
    • +
    • All tuples (u​​​​​i, v​​​​​​i) are unique
    • +
    • languages[i] contains only unique values
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +You can just use brute force and find out for each language the number of users you need to teach +
    + +
    +Hint 2 +Note that a user can appear in multiple friendships but you need to teach that user only once +
    diff --git a/problems/minimum-operations-to-reduce-x-to-zero/README.md b/problems/minimum-operations-to-reduce-x-to-zero/README.md index 28215e19f..034a45d1d 100644 --- a/problems/minimum-operations-to-reduce-x-to-zero/README.md +++ b/problems/minimum-operations-to-reduce-x-to-zero/README.md @@ -52,14 +52,15 @@ [[Greedy](../../tag/greedy/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    Hint 1 -Think in reverse instead of finding the minimum prefix + suffix find the maximum subarray +Think in reverse; instead of finding the minimum prefix + suffix, find the maximum subarray.
    Hint 2 -to find the maximum subarray a is standard and can be done greedily +Finding the maximum subarray is standard and can be done greedily.
    diff --git a/problems/missing-ranges/README.md b/problems/missing-ranges/README.md index 484395253..0b127da34 100644 --- a/problems/missing-ranges/README.md +++ b/problems/missing-ranges/README.md @@ -9,7 +9,7 @@                  [Next >](../maximum-gap "Maximum Gap") -## [163. Missing Ranges (Medium)](https://leetcode.com/problems/missing-ranges "缺失的区间") +## [163. Missing Ranges (Easy)](https://leetcode.com/problems/missing-ranges "缺失的区间")

    Given a sorted integer array nums, where the range of elements are in the inclusive range [lower, upper], return its missing ranges.

    diff --git a/problems/nested-list-weight-sum/README.md b/problems/nested-list-weight-sum/README.md index 18040d25a..a7de0b83f 100644 --- a/problems/nested-list-weight-sum/README.md +++ b/problems/nested-list-weight-sum/README.md @@ -33,6 +33,7 @@ ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] ### Similar Questions 1. [Nested List Weight Sum II](../nested-list-weight-sum-ii) (Medium) diff --git a/problems/network-delay-time/README.md b/problems/network-delay-time/README.md index a5703b8f6..f99307e18 100644 --- a/problems/network-delay-time/README.md +++ b/problems/network-delay-time/README.md @@ -11,33 +11,44 @@ ## [743. Network Delay Time (Medium)](https://leetcode.com/problems/network-delay-time "网络延迟时间") -

    There are N network nodes, labelled 1 to N.

    +

    You are given a network of n nodes, labeled from 1 to n. You are also given times, a list of travel times as directed edges times[i] = (ui, vi, wi), where ui is the source node, vi is the target node, and wi is the time it takes for a signal to travel from source to target.

    -

    Given times, a list of travel times as directed edges times[i] = (u, v, w), where u is the source node, v is the target node, and w is the time it takes for a signal to travel from source to target.

    - -

    Now, we send a signal from a certain node K. How long will it take for all nodes to receive the signal? If it is impossible, return -1.

    +

    We will send a signal from a given node k. Return the time it takes for all the n nodes to receive the signal. If it is impossible for all the n nodes to receive the signal, return -1.

     

    -

    Example 1:

    + +
    +Input: times = [[2,1,1],[2,3,1],[3,4,1]], n = 4, k = 2
    +Output: 2
    +
    -

    +

    Example 2:

    -Input: times = [[2,1,1],[2,3,1],[3,4,1]], N = 4, K = 2
    -Output: 2
    +Input: times = [[1,2,1]], n = 2, k = 1
    +Output: 1
     
    -

     

    +

    Example 3:

    -

    Note:

    +
    +Input: times = [[1,2,1]], n = 2, k = 2
    +Output: -1
    +
    -
      -
    1. N will be in the range [1, 100].
    2. -
    3. K will be in the range [1, N].
    4. -
    5. The length of times will be in the range [1, 6000].
    6. -
    7. All edges times[i] = (u, v, w) will have 1 <= u, v <= N and 0 <= w <= 100.
    8. -
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= n <= 100
    • +
    • 1 <= times.length <= 6000
    • +
    • times[i].length == 3
    • +
    • 1 <= ui, vi <= n
    • +
    • ui != vi
    • +
    • 0 <= wi <= 100
    • +
    • All the pairs (ui, vi) are unique. (i.e., no multiple edges.)
    • +
    ### Related Topics [[Heap](../../tag/heap/README.md)] diff --git a/problems/next-greater-element-i/README.md b/problems/next-greater-element-i/README.md index eacbe1de6..261f7079b 100644 --- a/problems/next-greater-element-i/README.md +++ b/problems/next-greater-element-i/README.md @@ -11,42 +11,44 @@ ## [496. Next Greater Element I (Easy)](https://leetcode.com/problems/next-greater-element-i "下一个更大元素 I") -

    -You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding places of nums2. -

    +

    You are given two integer arrays nums1 and nums2 both of unique elements, where nums1 is a subset of nums2.

    -

    -The Next Greater Number of a number x in nums1 is the first greater number to its right in nums2. If it does not exist, output -1 for this number. -

    +

    Find all the next greater numbers for nums1's elements in the corresponding places of nums2.

    + +

    The Next Greater Number of a number x in nums1 is the first greater number to its right in nums2. If it does not exist, return -1 for this number.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: nums1 = [4,1,2], nums2 = [1,3,4,2].
    -Output: [-1,3,-1]
    -Explanation:
    -    For number 4 in the first array, you cannot find the next greater number for it in the second array, so output -1.
    -    For number 1 in the first array, the next greater number for it in the second array is 3.
    -    For number 2 in the first array, there is no next greater number for it in the second array, so output -1.
    -
    -

    - -

    Example 2:
    +Input: nums1 = [4,1,2], nums2 = [1,3,4,2] +Output: [-1,3,-1] +Explanation: +For number 4 in the first array, you cannot find the next greater number for it in the second array, so output -1. +For number 1 in the first array, the next greater number for it in the second array is 3. +For number 2 in the first array, there is no next greater number for it in the second array, so output -1.

    + +

    Example 2:

    +
    -Input: nums1 = [2,4], nums2 = [1,2,3,4].
    -Output: [3,-1]
    -Explanation:
    -    For number 2 in the first array, the next greater number for it in the second array is 3.
    -    For number 4 in the first array, there is no next greater number for it in the second array, so output -1.
    -
    -

    - - -

    Note:
    -

      -
    1. All elements in nums1 and nums2 are unique.
    2. -
    3. The length of both nums1 and nums2 would not exceed 1000.
    4. -
    -

    +Input: nums1 = [2,4], nums2 = [1,2,3,4] +Output: [3,-1] +Explanation: +For number 2 in the first array, the next greater number for it in the second array is 3. +For number 4 in the first array, there is no next greater number for it in the second array, so output -1. + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums1.length <= nums2.length <= 1000
    • +
    • 0 <= nums1[i], nums2[i] <= 104
    • +
    • All integers in nums1 and nums2 are unique.
    • +
    • All the integers of nums1 also appear in nums2.
    • +
    + +

     

    +Follow up: Could you find an O(nums1.length + nums2.length) solution? ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/non-decreasing-array/README.md b/problems/non-decreasing-array/README.md index bf06ba4f0..2978ce872 100644 --- a/problems/non-decreasing-array/README.md +++ b/problems/non-decreasing-array/README.md @@ -11,9 +11,9 @@ ## [665. Non-decreasing Array (Easy)](https://leetcode.com/problems/non-decreasing-array "非递减数列") -

    Given an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most 1 element.

    +

    Given an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most one element.

    -

    We define an array is non-decreasing if nums[i] <= nums[i + 1] holds for every i (0-based) such that (0 <= i <= n - 2).

    +

    We define an array is non-decreasing if nums[i] <= nums[i + 1] holds for every i (0-based) such that (0 <= i <= n - 2).

     

    Example 1:

    @@ -36,8 +36,9 @@

    Constraints:

      -
    • 1 <= n <= 10 ^ 4
    • -
    • - 10 ^ 5 <= nums[i] <= 10 ^ 5
    • +
    • n == nums.length
    • +
    • 1 <= n <= 104
    • +
    • -105 <= nums[i] <= 105
    ### Related Topics diff --git a/problems/non-negative-integers-without-consecutive-ones/README.md b/problems/non-negative-integers-without-consecutive-ones/README.md index a8a48a286..f5710de52 100644 --- a/problems/non-negative-integers-without-consecutive-ones/README.md +++ b/problems/non-negative-integers-without-consecutive-ones/README.md @@ -37,6 +37,6 @@ Among them, only integer 3 disobeys the rule (two consecutive ones) and the othe [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [House Robber](../house-robber) (Easy) + 1. [House Robber](../house-robber) (Medium) 1. [House Robber II](../house-robber-ii) (Medium) 1. [Ones and Zeroes](../ones-and-zeroes) (Medium) diff --git a/problems/number-of-rectangles-that-can-form-the-largest-square/README.md b/problems/number-of-rectangles-that-can-form-the-largest-square/README.md new file mode 100644 index 000000000..282ba3127 --- /dev/null +++ b/problems/number-of-rectangles-that-can-form-the-largest-square/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../checking-existence-of-edge-length-limited-paths-ii "Checking Existence of Edge Length Limited Paths II") +                 +[Next >](../tuple-with-same-product "Tuple with Same Product") + +## [1725. Number Of Rectangles That Can Form The Largest Square (Easy)](https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square "可以形成最大正方形的矩形数目") + +

    You are given an array rectangles where rectangles[i] = [li, wi] represents the ith rectangle of length li and width wi.

    + +

    You can cut the ith rectangle to form a square with a side length of k if both k <= li and k <= wi. For example, if you have a rectangle [4,6], you can cut it to get a square with a side length of at most 4.

    + +

    Let maxLen be the side length of the largest square you can obtain from any of the given rectangles.

    + +

    Return the number of rectangles that can make a square with a side length of maxLen.

    + +

     

    +

    Example 1:

    + +
    +Input: rectangles = [[5,8],[3,9],[5,12],[16,5]]
    +Output: 3
    +Explanation: The largest squares you can get from each rectangle are of lengths [5,3,5,5].
    +The largest possible square is of length 5, and you can get it out of 3 rectangles.
    +
    + +

    Example 2:

    + +
    +Input: rectangles = [[2,3],[3,7],[4,3],[3,7]]
    +Output: 3
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= rectangles.length <= 1000
    • +
    • rectangles[i].length == 2
    • +
    • 1 <= li, wi <= 109
    • +
    • li != wi
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +What is the length of the largest square the can be cut out of some rectangle? It'll be equal to min(rectangle.length, rectangle.width). Replace each rectangle with this value. +
    + +
    +Hint 2 +Calculate maxSize by iterating over the given rectangles and maximizing the answer with their values denoted in the first hint. +
    + +
    +Hint 3 +Then iterate again on the rectangles and calculate the number whose values = maxSize. +
    diff --git a/problems/paint-fence/README.md b/problems/paint-fence/README.md index 0b17bbdb1..739c6dee1 100644 --- a/problems/paint-fence/README.md +++ b/problems/paint-fence/README.md @@ -41,7 +41,7 @@ n and k are non-negative integers.

    [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [House Robber](../house-robber) (Easy) + 1. [House Robber](../house-robber) (Medium) 1. [House Robber II](../house-robber-ii) (Medium) 1. [Paint House](../paint-house) (Medium) 1. [Paint House II](../paint-house-ii) (Hard) diff --git a/problems/paint-house/README.md b/problems/paint-house/README.md index a7582b0d1..4ec08d22b 100644 --- a/problems/paint-house/README.md +++ b/problems/paint-house/README.md @@ -31,7 +31,7 @@ All costs are positive integers.

    [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [House Robber](../house-robber) (Easy) + 1. [House Robber](../house-robber) (Medium) 1. [House Robber II](../house-robber-ii) (Medium) 1. [Paint House II](../paint-house-ii) (Hard) 1. [Paint Fence](../paint-fence) (Easy) diff --git a/problems/palindrome-number/README.md b/problems/palindrome-number/README.md index 95d7cba96..442e51538 100644 --- a/problems/palindrome-number/README.md +++ b/problems/palindrome-number/README.md @@ -11,9 +11,9 @@ ## [9. Palindrome Number (Easy)](https://leetcode.com/problems/palindrome-number "回文数") -

    Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.

    +

    Given an integer x, return true if x is palindrome integer.

    -

    Follow up: Could you solve it without converting the integer to a string?

    +

    An integer is a palindrome when it reads the same backward as forward. For example, 121 is palindrome while 123 is not.

     

    Example 1:

    @@ -53,6 +53,9 @@
  • -231 <= x <= 231 - 1
  • +

     

    +Follow up: Could you solve it without converting the integer to a string? + ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/pancake-sorting/README.md b/problems/pancake-sorting/README.md index e7c8561fa..da75550b4 100644 --- a/problems/pancake-sorting/README.md +++ b/problems/pancake-sorting/README.md @@ -11,18 +11,18 @@ ## [969. Pancake Sorting (Medium)](https://leetcode.com/problems/pancake-sorting "煎饼排序") -

    Given an array of integers arr, sort the array by performing a series of pancake flips.

    +

    Given an array of integers arr, sort the array by performing a series of pancake flips.

    In one pancake flip we do the following steps:

    • Choose an integer k where 1 <= k <= arr.length.
    • -
    • Reverse the sub-array arr[1...k].
    • +
    • Reverse the sub-array arr[0...k-1] (0-indexed).
    -

    For example, if arr = [3,2,1,4] and we performed a pancake flip choosing k = 3, we reverse the sub-array [3,2,1], so arr = [1,2,3,4] after the pancake flip at k = 3.

    +

    For example, if arr = [3,2,1,4] and we performed a pancake flip choosing k = 3, we reverse the sub-array [3,2,1], so arr = [1,2,3,4] after the pancake flip at k = 3.

    -

    Return the k-values corresponding to a sequence of pancake flips that sort arr. Any valid answer that sorts the array within 10 * arr.length flips will be judged as correct.

    +

    Return an array of the k-values corresponding to a sequence of pancake flips that sort arr. Any valid answer that sorts the array within 10 * arr.length flips will be judged as correct.

     

    Example 1:

    @@ -33,11 +33,10 @@ Explanation: We perform 4 pancake flips, with k values 4, 2, 4, and 3. Starting state: arr = [3, 2, 4, 1] -After 1st flip (k = 4): arr = [1, 4, 2, 3] -After 2nd flip (k = 2): arr = [4, 1, 2, 3] -After 3rd flip (k = 4): arr = [3, 2, 1, 4] -After 4th flip (k = 3): arr = [1, 2, 3, 4], which is sorted. -Notice that we return an array of the chosen k values of the pancake flips. +After 1st flip (k = 4): arr = [1, 4, 2, 3] +After 2nd flip (k = 2): arr = [4, 1, 2, 3] +After 3rd flip (k = 4): arr = [3, 2, 1, 4] +After 4th flip (k = 3): arr = [1, 2, 3, 4], which is sorted.

    Example 2:

    diff --git a/problems/path-sum-ii/README.md b/problems/path-sum-ii/README.md index 699a12656..bcb94c932 100644 --- a/problems/path-sum-ii/README.md +++ b/problems/path-sum-ii/README.md @@ -11,33 +11,41 @@ ## [113. Path Sum II (Medium)](https://leetcode.com/problems/path-sum-ii "路径总和 II") -

    Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.

    +

    Given the root of a binary tree and an integer targetSum, return all root-to-leaf paths where each path's sum equals targetSum.

    -

    Note: A leaf is a node with no children.

    +

    A leaf is a node with no children.

    -

    Example:

    - -

    Given the below binary tree and sum = 22,

    +

     

    +

    Example 1:

    + +
    +Input: root = [5,4,8,11,null,13,4,7,2,null,null,5,1], targetSum = 22
    +Output: [[5,4,11,2],[5,8,4,5]]
    +
    +

    Example 2:

    +
    -      5
    -     / \
    -    4   8
    -   /   / \
    -  11  13  4
    - /  \    / \
    -7    2  5   1
    +Input: root = [1,2,3], targetSum = 5
    +Output: []
     
    -

    Return:

    +

    Example 3:

    -[
    -   [5,4,11,2],
    -   [5,8,4,5]
    -]
    +Input: root = [1,2], targetSum = 0
    +Output: []
     
    +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [0, 5000].
    • +
    • -1000 <= Node.val <= 1000
    • +
    • -1000 <= targetSum <= 1000
    • +
    + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/path-sum/README.md b/problems/path-sum/README.md index f0cf5b237..231679a08 100644 --- a/problems/path-sum/README.md +++ b/problems/path-sum/README.md @@ -11,25 +11,40 @@ ## [112. Path Sum (Easy)](https://leetcode.com/problems/path-sum "路径总和") -

    Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.

    +

    Given the root of a binary tree and an integer targetSum, return true if the tree has a root-to-leaf path such that adding up all the values along the path equals targetSum.

    -

    Note: A leaf is a node with no children.

    +

    A leaf is a node with no children.

    -

    Example:

    +

     

    +

    Example 1:

    + +
    +Input: root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum = 22
    +Output: true
    +
    + +

    Example 2:

    + +
    +Input: root = [1,2,3], targetSum = 5
    +Output: false
    +
    -

    Given the below binary tree and sum = 22,

    +

    Example 3:

    -      5
    -     / \
    -    4   8
    -   /   / \
    -  11  13  4
    - /  \      \
    -7    2      1
    +Input: root = [1,2], targetSum = 0
    +Output: false
     
    -

    return true, as there exist a root-to-leaf path 5->4->11->2 which sum is 22.

    +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [0, 5000].
    • +
    • -1000 <= Node.val <= 1000
    • +
    • -1000 <= targetSum <= 1000
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/peak-index-in-a-mountain-array/README.md b/problems/peak-index-in-a-mountain-array/README.md index 9435eeae1..019cb1b84 100644 --- a/problems/peak-index-in-a-mountain-array/README.md +++ b/problems/peak-index-in-a-mountain-array/README.md @@ -23,7 +23,7 @@ -

    Given an integer array arr that is guaranteed to be a mountain, return any i such that arr[0] < arr[1] < ... arr[i - 1] < arr[i] > arr[i + 1] > ... > arr[arr.length - 1].

    +

    Given an integer array arr that is guaranteed to be a mountain, return any i such that arr[0] < arr[1] < ... arr[i - 1] < arr[i] > arr[i + 1] > ... > arr[arr.length - 1].

     

    Example 1:

    @@ -51,6 +51,9 @@
  • arr is guaranteed to be a mountain array.
  • +

     

    +Follow up: Finding the O(n) is straightforward, could you find an O(log(n)) solution? + ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/perfect-squares/README.md b/problems/perfect-squares/README.md index 71e721af9..2a32572c3 100644 --- a/problems/perfect-squares/README.md +++ b/problems/perfect-squares/README.md @@ -11,21 +11,33 @@ ## [279. Perfect Squares (Medium)](https://leetcode.com/problems/perfect-squares "完全平方数") -

    Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.

    +

    Given an integer n, return the least number of perfect square numbers that sum to n.

    -

    Example 1:

    +

    A perfect square is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, 1, 4, 9, and 16 are perfect squares while 3 and 11 are not.

    + +

     

    +

    Example 1:

    -Input: n = 12
    -Output: 3 
    -Explanation: 12 = 4 + 4 + 4.
    +Input: n = 12 +Output: 3 +Explanation: 12 = 4 + 4 + 4. + -

    Example 2:

    +

    Example 2:

    -Input: n = 13
    -Output: 2
    -Explanation: 13 = 4 + 9.
    +Input: n = 13 +Output: 2 +Explanation: 13 = 4 + 9. + + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 104
    • +
    ### Related Topics [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/products-worth-over-invoices/README.md b/problems/products-worth-over-invoices/README.md index 2b8857123..175170405 100644 --- a/problems/products-worth-over-invoices/README.md +++ b/problems/products-worth-over-invoices/README.md @@ -9,6 +9,6 @@                  [Next >](../goal-parser-interpretation "Goal Parser Interpretation") -## [1677. Product's Worth Over Invoices (Easy)](https://leetcode.com/problems/products-worth-over-invoices "") +## [1677. Product's Worth Over Invoices (Easy)](https://leetcode.com/problems/products-worth-over-invoices "发票中的产品金额") diff --git a/problems/projection-area-of-3d-shapes/README.md b/problems/projection-area-of-3d-shapes/README.md index 4b9df535e..0bd685f7e 100644 --- a/problems/projection-area-of-3d-shapes/README.md +++ b/problems/projection-area-of-3d-shapes/README.md @@ -11,124 +11,62 @@ ## [883. Projection Area of 3D Shapes (Easy)](https://leetcode.com/problems/projection-area-of-3d-shapes "三维形体投影面积") -

    On a N * N grid, we place some 1 * 1 * 1 cubes that are axis-aligned with the x, y, and z axes.

    +

    You are given an n x n grid where we place some 1 x 1 x 1 cubes that are axis-aligned with the x, y, and z axes.

    -

    Each value v = grid[i][j] represents a tower of v cubes placed on top of grid cell (i, j).

    +

    Each value v = grid[i][j] represents a tower of v cubes placed on top of the cell (i, j).

    -

    Now we view the projection of these cubes onto the xy, yz, and zx planes.

    +

    We view the projection of these cubes onto the xy, yz, and zx planes.

    -

    A projection is like a shadow, that maps our 3 dimensional figure to a 2 dimensional plane. 

    +

    A projection is like a shadow, that maps our 3-dimensional figure to a 2-dimensional plane. We are viewing the "shadow" when looking at the cubes from the top, the front, and the side.

    -

    Here, we are viewing the "shadow" when looking at the cubes from the top, the front, and the side.

    - -

    Return the total area of all three projections.

    +

    Return the total area of all three projections.

     

    - -
    -
      -
    -
    - -
    -
    -
      -
    -
    -
    - -
    -
    -
    -
    -
      -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    -
    -
    -
      -
    -
    -
    -
    -
    -
    -
    -
    -
    - -

    Example 1:

    - +
    -Input: [[2]]
    -Output: 5
    +Input: grid = [[1,2],[3,4]]
    +Output: 17
    +Explanation: Here are the three projections ("shadows") of the shape made with each axis-aligned plane.
     
    -

    Example 2:

    -Input: [[1,2],[3,4]]
    -Output: 17
    -Explanation: 
    -Here are the three projections ("shadows") of the shape made with each axis-aligned plane.
    -
    +Input: grid = [[2]]
    +Output: 5
     
    -

    Example 3:

    -Input: [[1,0],[0,2]]
    -Output: 8
    +Input: grid = [[1,0],[0,2]]
    +Output: 8
     
    -

    Example 4:

    -Input: [[1,1,1],[1,0,1],[1,1,1]]
    -Output: 14
    +Input: grid = [[1,1,1],[1,0,1],[1,1,1]]
    +Output: 14
     
    -

    Example 5:

    -Input: [[2,2,2],[2,1,2],[2,2,2]]
    -Output: 21
    +Input: grid = [[2,2,2],[2,1,2],[2,2,2]]
    +Output: 21
     

     

    - -
    -
    -
    -

    Note:

    +

    Constraints:

      -
    • 1 <= grid.length = grid[0].length <= 50
    • +
    • n == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= n <= 50
    • 0 <= grid[i][j] <= 50
    -
    -
    -
    -
    -
    -
    -
    -
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/range-module/README.md b/problems/range-module/README.md index 53f405c50..ceec5b9fd 100644 --- a/problems/range-module/README.md +++ b/problems/range-module/README.md @@ -45,7 +45,7 @@ ### Similar Questions 1. [Merge Intervals](../merge-intervals) (Medium) - 1. [Insert Interval](../insert-interval) (Hard) + 1. [Insert Interval](../insert-interval) (Medium) 1. [Data Stream as Disjoint Intervals](../data-stream-as-disjoint-intervals) (Hard) ### Hints diff --git a/problems/range-sum-query-mutable/README.md b/problems/range-sum-query-mutable/README.md index 8771af7ba..2fa493df9 100644 --- a/problems/range-sum-query-mutable/README.md +++ b/problems/range-sum-query-mutable/README.md @@ -11,27 +11,43 @@ ## [307. Range Sum Query - Mutable (Medium)](https://leetcode.com/problems/range-sum-query-mutable "区域和检索 - 数组可修改") -

    Given an integer array nums, find the sum of the elements between indices i and j (ij), inclusive.

    +

    Given an array nums and two types of queries where you should update the value of an index in the array, and retrieve the sum of a range in the array.

    -

    The update(i, val) function modifies nums by updating the element at index i to val.

    +

    Implement the NumArray class:

    -

    Example:

    +
      +
    • NumArray(int[] nums) Initializes the object with the integer array nums.
    • +
    • void update(int index, int val) Updates the value of nums[index] to be val.
    • +
    • int sumRange(int left, int right) Returns the sum of the subarray nums[left, right] (i.e., nums[left] + nums[left + 1], ..., nums[right]).
    • +
    -
    -Given nums = [1, 3, 5]
    +

     

    +

    Example 1:

    -sumRange(0, 2) -> 9 -update(1, 2) -sumRange(0, 2) -> 8 +
    +Input
    +["NumArray", "sumRange", "update", "sumRange"]
    +[[[1, 3, 5]], [0, 2], [1, 2], [0, 2]]
    +Output
    +[null, 9, null, 8]
    +
    +Explanation
    +NumArray numArray = new NumArray([1, 3, 5]);
    +numArray.sumRange(0, 2); // return 9 = sum([1,3,5])
    +numArray.update(1, 2);   // nums = [1,2,5]
    +numArray.sumRange(0, 2); // return 8 = sum([1,2,5])
     

     

    Constraints:

      -
    • The array is only modifiable by the update function.
    • -
    • You may assume the number of calls to update and sumRange function is distributed evenly.
    • -
    • 0 <= i <= j <= nums.length - 1
    • +
    • 1 <= nums.length <= 3 * 104
    • +
    • -100 <= nums[i] <= 100
    • +
    • 0 <= index < nums.length
    • +
    • -100 <= val <= 100
    • +
    • 0 <= left <= right < nums.length
    • +
    • At most 3 * 104 calls will be made to update and sumRange.
    ### Related Topics diff --git a/problems/reachable-nodes-in-subdivided-graph/README.md b/problems/reachable-nodes-in-subdivided-graph/README.md index b33cd0903..1fd1fb599 100644 --- a/problems/reachable-nodes-in-subdivided-graph/README.md +++ b/problems/reachable-nodes-in-subdivided-graph/README.md @@ -11,58 +11,53 @@ ## [882. Reachable Nodes In Subdivided Graph (Hard)](https://leetcode.com/problems/reachable-nodes-in-subdivided-graph "细分图中的可到达结点") -

    Starting with an undirected graph (the "original graph") with nodes from 0 to N-1, subdivisions are made to some of the edges.

    +

    You are given an undirected graph (the "original graph") with n nodes labeled from 0 to n - 1, subdivisions are made to some of the edges.

    -

    The graph is given as follows: edges[k] is a list of integer pairs (i, j, n) such that (i, j) is an edge of the original graph,

    +

    The graph is given as an array of edges where edges[i] = [ui, vi, cnti] indicates that there is an edge between nodes ui and vi in the original graph, and cnti is the total number of new nodes on that edge.

    -

    and n is the total number of new nodes on that edge. 

    +

    Then, the edge [ui, vi] is deleted from the original graph, and cnti new nodes (x1, x2, ..., xcnti) are added to the original graph, and cnti + 1 new edges (ui, x1), (x1, x2), (x2, x3), ..., (xcnti - 1 , xcnti), (xcnti, vi) are added to the original graph.

    -

    Then, the edge (i, j) is deleted from the original graph, n new nodes (x_1, x_2, ..., x_n) are added to the original graph,

    +

    Now, you start at node 0 from the original graph, and in each move, you travel along one edge.

    -

    and n+1 new edges (i, x_1), (x_1, x_2), (x_2, x_3), ..., (x_{n-1}, x_n), (x_n, j) are added to the original graph.

    - -

    Now, you start at node 0 from the original graph, and in each move, you travel along one edge. 

    - -

    Return how many nodes you can reach in at most M moves.

    +

    Return the number of nodes you can reach in at most maxMoves moves.

     

    -

    Example 1:

    - +
    -Input: edges = [[0,1,10],[0,2,1],[1,2,2]], M = 6, N = 3
    -Output: 13
    -Explanation: 
    -The nodes that are reachable in the final graph after M = 6 moves are indicated below.
    -
    +Input: edges = [[0,1,10],[0,2,1],[1,2,2]], maxMoves = 6, n = 3
    +Output: 13
    +Explanation: The nodes that are reachable in the final graph after maxMoves = 6 moves are indicated above.
     
    -

    Example 2:

    -Input: edges = [[0,1,4],[1,2,6],[0,2,8],[1,3,1]], M = 10, N = 4
    -Output: 23
    - -

     

    -
    +Input: edges = [[0,1,4],[1,2,6],[0,2,8],[1,3,1]], maxMoves = 10, n = 4 +Output: 23 +
    -

    Note:

    +

    Example 3:

    -
      -
    1. 0 <= edges.length <= 10000
    2. -
    3. 0 <= edges[i][0] < edges[i][1] < N
    4. -
    5. There does not exist any i != j for which edges[i][0] == edges[j][0] and edges[i][1] == edges[j][1].
    6. -
    7. The original graph has no parallel edges.
    8. -
    9. 0 <= edges[i][2] <= 10000
    10. -
    11. 0 <= M <= 10^9
    12. -
    13. 1 <= N <= 3000
    14. -
    15. A reachable node is a node that can be travelled to using at most M moves starting from node 0.
    16. -
    +
    +Input: edges = [[1,2,4],[1,4,5],[1,3,1],[2,3,4],[3,4,5]], maxMoves = 17, n = 5
    +Output: 1
    +Explanation: The graph is disconnected, you can only reach node 0
    +
    -
    -
     
    -
    +

     

    +

    Constraints:

    + +
      +
    • 0 <= edges.length <= min(n * (n - 1) / 2, 104)
    • +
    • edges[i].length == 3
    • +
    • 0 <= ui < vi < n
    • +
    • There are no multiple edges in the graph.
    • +
    • 0 <= cnti <= 104
    • +
    • 0 <= maxMoves <= 109
    • +
    • 1 <= n <= 3000
    • +
    ### Related Topics [[Heap](../../tag/heap/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/remove-nth-node-from-end-of-list/README.md b/problems/remove-nth-node-from-end-of-list/README.md index a18c4e920..451a0a8e4 100644 --- a/problems/remove-nth-node-from-end-of-list/README.md +++ b/problems/remove-nth-node-from-end-of-list/README.md @@ -9,7 +9,7 @@                  [Next >](../valid-parentheses "Valid Parentheses") -## [19. Remove Nth Node From End of List (Medium)](https://leetcode.com/problems/remove-nth-node-from-end-of-list "删除链表的倒数第N个节点") +## [19. Remove Nth Node From End of List (Medium)](https://leetcode.com/problems/remove-nth-node-from-end-of-list "删除链表的倒数第 N 个结点")

    Given the head of a linked list, remove the nth node from the end of the list and return its head.

    diff --git a/problems/reorder-data-in-log-files/README.md b/problems/reorder-data-in-log-files/README.md index 6bfee801b..769d19a18 100644 --- a/problems/reorder-data-in-log-files/README.md +++ b/problems/reorder-data-in-log-files/README.md @@ -11,34 +11,45 @@ ## [937. Reorder Data in Log Files (Easy)](https://leetcode.com/problems/reorder-data-in-log-files "重新排列日志文件") -

    You have an array of logs.  Each log is a space delimited string of words.

    +

    You have an array of logs. Each log is a space-delimited string of words.

    -

    For each log, the first word in each log is an alphanumeric identifier.  Then, either:

    +

    For each log, the first word in each log is an alphanumeric identifier. Then, either:

    • Each word after the identifier will consist only of lowercase letters, or;
    • Each word after the identifier will consist only of digits.
    -

    We will call these two varieties of logs letter-logs and digit-logs.  It is guaranteed that each log has at least one word after its identifier.

    +

    We will call these two varieties of logs letter-logs and digit-logs. It is guaranteed that each log has at least one word after its identifier.

    -

    Reorder the logs so that all of the letter-logs come before any digit-log.  The letter-logs are ordered lexicographically ignoring identifier, with the identifier used in case of ties.  The digit-logs should be put in their original order.

    +

    Reorder the logs so that all of the letter-logs come before any digit-log. The letter-logs are ordered lexicographically, ignoring identifiers, with the identifier used in case of ties. The digit-logs should be put in their original order.

    Return the final order of the logs.

     

    Example 1:

    -
    Input: logs = ["dig1 8 1 5 1","let1 art can","dig2 3 6","let2 own kit dig","let3 art zero"]
    -Output: ["let1 art can","let3 art zero","let2 own kit dig","dig1 8 1 5 1","dig2 3 6"]
    +
    +
    +Input: logs = ["dig1 8 1 5 1","let1 art can","dig2 3 6","let2 own kit dig","let3 art zero"]
    +Output: ["let1 art can","let3 art zero","let2 own kit dig","dig1 8 1 5 1","dig2 3 6"]
    +
    + +

    Example 2:

    + +
    +Input: logs = ["a1 9 2 3 1","g1 act car","zo4 4 7","ab1 off key dog","a8 act zoo"]
    +Output: ["g1 act car","a8 act zoo","ab1 off key dog","a1 9 2 3 1","zo4 4 7"]
     
    +

     

    Constraints:

    -
      -
    1. 0 <= logs.length <= 100
    2. +
        +
      • 1 <= logs.length <= 100
      • 3 <= logs[i].length <= 100
      • -
      • logs[i] is guaranteed to have an identifier, and a word after the identifier.
      • -
    +
  • All the tokens of logs[i] are separated by single spaces.
  • +
  • logs[i] is guaranteed to have an identifier and a word after the identifier.
  • + ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/reverse-integer/README.md b/problems/reverse-integer/README.md index cd697a63e..443f96087 100644 --- a/problems/reverse-integer/README.md +++ b/problems/reverse-integer/README.md @@ -11,9 +11,9 @@ ## [7. Reverse Integer (Easy)](https://leetcode.com/problems/reverse-integer "整数反转") -

    Given a 32-bit signed integer, reverse digits of an integer.

    +

    Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0.

    -

    Note: Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. For this problem, assume that your function returns 0 when the reversed integer overflows.

    +

    Assume the environment does not allow you to store 64-bit integers (signed or unsigned).

     

    Example 1:

    diff --git a/problems/robot-bounded-in-circle/README.md b/problems/robot-bounded-in-circle/README.md index ead8a72f6..31aad4ab0 100644 --- a/problems/robot-bounded-in-circle/README.md +++ b/problems/robot-bounded-in-circle/README.md @@ -11,12 +11,12 @@ ## [1041. Robot Bounded In Circle (Medium)](https://leetcode.com/problems/robot-bounded-in-circle "困于环中的机器人") -

    On an infinite plane, a robot initially stands at (0, 0) and faces north.  The robot can receive one of three instructions:

    +

    On an infinite plane, a robot initially stands at (0, 0) and faces north. The robot can receive one of three instructions:

    • "G": go straight 1 unit;
    • "L": turn 90 degrees to the left;
    • -
    • "R": turn 90 degress to the right.
    • +
    • "R": turn 90 degrees to the right.

    The robot performs the instructions given in order, and repeats them forever.

    @@ -24,43 +24,35 @@

    Return true if and only if there exists a circle in the plane such that the robot never leaves the circle.

     

    -

    Example 1:

    -Input: "GGLLGG"
    -Output: true
    -Explanation: 
    -The robot moves from (0,0) to (0,2), turns 180 degrees, and then returns to (0,0).
    -When repeating these instructions, the robot remains in the circle of radius 2 centered at the origin.
    -
    +Input: instructions = "GGLLGG" +Output: true +Explanation: The robot moves from (0,0) to (0,2), turns 180 degrees, and then returns to (0,0). +When repeating these instructions, the robot remains in the circle of radius 2 centered at the origin.

    Example 2:

    -Input: "GG"
    -Output: false
    -Explanation: 
    -The robot moves north indefinitely.
    -
    +Input: instructions = "GG" +Output: false +Explanation: The robot moves north indefinitely.

    Example 3:

    -Input: "GL"
    -Output: true
    -Explanation: 
    -The robot moves from (0, 0) -> (0, 1) -> (-1, 1) -> (-1, 0) -> (0, 0) -> ...
    -
    +Input: instructions = "GL" +Output: true +Explanation: The robot moves from (0, 0) -> (0, 1) -> (-1, 1) -> (-1, 0) -> (0, 0) -> ...

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= instructions.length <= 100
      • -
      • instructions[i] is in {'G', 'L', 'R'}
      • -
    +
  • instructions[i] is 'G', 'L' or, 'R'.
  • + ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/search-in-a-binary-search-tree/README.md b/problems/search-in-a-binary-search-tree/README.md index 24a5e7f02..8baa90f04 100644 --- a/problems/search-in-a-binary-search-tree/README.md +++ b/problems/search-in-a-binary-search-tree/README.md @@ -11,32 +11,34 @@ ## [700. Search in a Binary Search Tree (Easy)](https://leetcode.com/problems/search-in-a-binary-search-tree "二叉搜索树中的搜索") -

    Given the root node of a binary search tree (BST) and a value. You need to find the node in the BST that the node's value equals the given value. Return the subtree rooted with that node. If such node doesn't exist, you should return NULL.

    +

    You are given the root of a binary search tree (BST) and an integer val.

    -

    For example, 

    +

    Find the node in the BST that the node's value equals val and return the subtree rooted with that node. If such a node does not exist, return null.

    +

     

    +

    Example 1:

    +
    -Given the tree:
    -        4
    -       / \
    -      2   7
    -     / \
    -    1   3
    -
    -And the value to search: 2
    +Input: root = [4,2,7,1,3], val = 2
    +Output: [2,1,3]
     
    -

    You should return this subtree:

    - +

    Example 2:

    +
    -      2     
    -     / \   
    -    1   3
    +Input: root = [4,2,7,1,3], val = 5
    +Output: []
     
    -

    In the example above, if we want to search the value 5, since there is no node with value 5, we should return NULL.

    +

     

    +

    Constraints:

    -

    Note that an empty tree is represented by NULL, therefore you would see the expected output (serialized tree format) as [], not null.

    +
      +
    • The number of nodes in the tree is in the range [1, 5000].
    • +
    • 1 <= Node.val <= 107
    • +
    • root is a binary search tree.
    • +
    • 1 <= val <= 107
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/set-mismatch/README.md b/problems/set-mismatch/README.md index 49bb9d549..9b96464a9 100644 --- a/problems/set-mismatch/README.md +++ b/problems/set-mismatch/README.md @@ -11,28 +11,27 @@ ## [645. Set Mismatch (Easy)](https://leetcode.com/problems/set-mismatch "错误的集合") -

    -The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of the numbers in the set got duplicated to another number in the set, which results in repetition of one number and loss of another number. -

    +

    You have a set of integers s, which originally contains all the numbers from 1 to n. Unfortunately, due to some error, one of the numbers in s got duplicated to another number in the set, which results in repetition of one number and loss of another number.

    -

    -Given an array nums representing the data status of this set after the error. Your task is to firstly find the number occurs twice and then find the number that is missing. Return them in the form of an array. -

    +

    You are given an integer array nums representing the data status of this set after the error.

    +

    Find the number that occurs twice and the number that is missing and return them in the form of an array.

    -

    Example 1:
    -

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

     

    +

    Example 1:

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

    Example 2:

    +
    Input: nums = [1,1]
    +Output: [1,2]
     
    -

    - -

    Note:
    -

      -
    1. The given array size will in the range [2, 10000].
    2. -
    3. The given array's numbers won't have any order.
    4. -
    -

    +

     

    +

    Constraints:

    + +
      +
    • 2 <= nums.length <= 104
    • +
    • 1 <= nums[i] <= 104
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/shortest-path-to-get-food/README.md b/problems/shortest-path-to-get-food/README.md new file mode 100644 index 000000000..599559db3 --- /dev/null +++ b/problems/shortest-path-to-get-food/README.md @@ -0,0 +1,40 @@ + + + + + + + +[< Previous](../find-followers-count "Find Followers Count") +                 +[Next >](../the-number-of-employees-which-report-to-each-employee "The Number of Employees Which Report to Each Employee") + +## [1730. Shortest Path to Get Food (Medium)](https://leetcode.com/problems/shortest-path-to-get-food "") + + + +### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + +### Hints +
    +Hint 1 +Run BFS starting from the '*' position. +
    + +
    +Hint 2 +Keep the current number of the steps as a state in the queue. +
    + +
    +Hint 3 +The first time you reach a food, return the number of steps as the answer. +
    + +
    +Hint 4 +In case the queue is empty and you still did not manage to reach a food, return -1. +
    diff --git a/problems/shortest-unsorted-continuous-subarray/README.md b/problems/shortest-unsorted-continuous-subarray/README.md index b6debfd6d..3bf01a5d0 100644 --- a/problems/shortest-unsorted-continuous-subarray/README.md +++ b/problems/shortest-unsorted-continuous-subarray/README.md @@ -13,7 +13,7 @@

    Given an integer array nums, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order.

    -

    Return the shortest such subarray and output its length.

    +

    Return the shortest such subarray and output its length.

     

    Example 1:

    @@ -46,5 +46,8 @@
  • -105 <= nums[i] <= 105
  • +

     

    +Follow up: Can you solve it in O(n) time complexity? + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/sort-colors/README.md b/problems/sort-colors/README.md index e5d4fdecb..c48d94b28 100644 --- a/problems/sort-colors/README.md +++ b/problems/sort-colors/README.md @@ -11,16 +11,9 @@ ## [75. Sort Colors (Medium)](https://leetcode.com/problems/sort-colors "颜色分类") -

    Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue.

    +

    Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue.

    -

    Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively.

    - -

    Follow up:

    - -
      -
    • Could you solve this problem without using the library's sort function?
    • -
    • Could you come up with a one-pass algorithm using only O(1) constant space?
    • -
    +

    We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively.

     

    Example 1:

    @@ -45,6 +38,14 @@
  • nums[i] is 0, 1, or 2.
  • +

     

    +

    Follow up:

    + +
      +
    • Could you solve this problem without using the library's sort function?
    • +
    • Could you come up with a one-pass algorithm using only O(1) constant space?
    • +
    + ### Related Topics [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] diff --git a/problems/sort-the-matrix-diagonally/README.md b/problems/sort-the-matrix-diagonally/README.md index 31bb6d3b4..00118b71e 100644 --- a/problems/sort-the-matrix-diagonally/README.md +++ b/problems/sort-the-matrix-diagonally/README.md @@ -23,13 +23,20 @@ Output: [[1,1,1,1],[1,2,2,2],[1,2,3,3]]
    +

    Example 2:

    + +
    +Input: mat = [[11,25,66,1,69,7],[23,55,17,45,15,52],[75,31,36,44,58,8],[22,27,33,25,68,4],[84,28,14,11,5,50]]
    +Output: [[5,17,4,1,52,7],[11,11,25,45,8,69],[14,23,25,44,58,15],[22,27,31,36,50,66],[84,28,75,33,55,68]]
    +
    +

     

    Constraints:

      -
    • m == mat.length
    • -
    • n == mat[i].length
    • -
    • 1 <= m, n <= 100
    • +
    • m == mat.length
    • +
    • n == mat[i].length
    • +
    • 1 <= m, n <= 100
    • 1 <= mat[i][j] <= 100
    diff --git a/problems/string-to-integer-atoi/README.md b/problems/string-to-integer-atoi/README.md index 7324a1e60..4d1cda325 100644 --- a/problems/string-to-integer-atoi/README.md +++ b/problems/string-to-integer-atoi/README.md @@ -11,61 +11,105 @@ ## [8. String to Integer (atoi) (Medium)](https://leetcode.com/problems/string-to-integer-atoi "字符串转换整数 (atoi)") -

    Implement atoi which converts a string to an integer.

    +

    Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer (similar to C/C++'s atoi function).

    -

    The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value.

    +

    The algorithm for myAtoi(string s) is as follows:

    -

    The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function.

    - -

    If the first sequence of non-whitespace characters in str is not a valid integral number, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed.

    - -

    If no valid conversion could be performed, a zero value is returned.

    +
      +
    1. Read in and ignore any leading whitespace.
    2. +
    3. Check if the next character (if not already at the end of the string) is '-' or '+'. Read this character in if it is either. This determines if the final result is negative or positive respectively. Assume the result is positive if neither is present.
    4. +
    5. Read in next the characters until the next non-digit charcter or the end of the input is reached. The rest of the string is ignored.
    6. +
    7. Convert these digits into an integer (i.e. "123" -> 123, "0032" -> 32). If no digits were read, then the integer is 0. Change the sign as necessary (from step 2).
    8. +
    9. If the integer is out of the 32-bit signed integer range [-231, 231 - 1], then clamp the integer so that it remains in the range. Specifically, integers less than -231 should be clamped to -231, and integers greater than 231 - 1 should be clamped to 231 - 1.
    10. +
    11. Return the integer as the final result.
    12. +

    Note:

    • Only the space character ' ' is considered a whitespace character.
    • -
    • Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. If the numerical value is out of the range of representable values, 231 − 1 or −231 is returned.
    • +
    • Do not ignore any characters other than the leading whitespace or the rest of the string after the digits.

     

    Example 1:

    -Input: str = "42"
    +Input: s = "42"
     Output: 42
    +Explanation: The underlined characters are what is read in, the caret is the current reader position.
    +Step 1: "42" (no characters read because there is no leading whitespace)
    +         ^
    +Step 2: "42" (no characters read because there is neither a '-' nor '+')
    +         ^
    +Step 3: "42" ("42" is read in)
    +           ^
    +The parsed integer is 42.
    +Since 42 is in the range [-231, 231 - 1], the final result is 42.
     

    Example 2:

    -Input: str = "   -42"
    +Input: s = "   -42"
     Output: -42
    -Explanation: The first non-whitespace character is '-', which is the minus sign. Then take as many numerical digits as possible, which gets 42.
    +Explanation:
    +Step 1: "   -42" (leading whitespace is read and ignored)
    +            ^
    +Step 2: "   -42" ('-' is read, so the result should be negative)
    +             ^
    +Step 3: "   -42" ("42" is read in)
    +               ^
    +The parsed integer is -42.
    +Since -42 is in the range [-231, 231 - 1], the final result is -42.
     

    Example 3:

    -Input: str = "4193 with words"
    +Input: s = "4193 with words"
     Output: 4193
    -Explanation: Conversion stops at digit '3' as the next character is not a numerical digit.
    +Explanation:
    +Step 1: "4193 with words" (no characters read because there is no leading whitespace)
    +         ^
    +Step 2: "4193 with words" (no characters read because there is neither a '-' nor '+')
    +         ^
    +Step 3: "4193 with words" ("4193" is read in; reading stops because the next character is a non-digit)
    +             ^
    +The parsed integer is 4193.
    +Since 4193 is in the range [-231, 231 - 1], the final result is 4193.
     

    Example 4:

    -Input: str = "words and 987"
    +Input: s = "words and 987"
     Output: 0
    -Explanation: The first non-whitespace character is 'w', which is not a numerical digit or a +/- sign. Therefore no valid conversion could be performed.
    +Explanation:
    +Step 1: "words and 987" (no characters read because there is no leading whitespace)
    +         ^
    +Step 2: "words and 987" (no characters read because there is neither a '-' nor '+')
    +         ^
    +Step 3: "words and 987" (reading stops immediately because there is a non-digit 'w')
    +         ^
    +The parsed integer is 0 because no digits were read.
    +Since 0 is in the range [-231, 231 - 1], the final result is 0.
     

    Example 5:

    -Input: str = "-91283472332"
    +Input: s = "-91283472332"
     Output: -2147483648
    -Explanation: The number "-91283472332" is out of the range of a 32-bit signed integer. Thefore INT_MIN (−231) is returned.
    +Explanation:
    +Step 1: "-91283472332" (no characters read because there is no leading whitespace)
    +         ^
    +Step 2: "-91283472332" ('-' is read, so the result should be negative)
    +          ^
    +Step 3: "-91283472332" ("91283472332" is read in)
    +                     ^
    +The parsed integer is -91283472332.
    +Since -91283472332 is less than the lower bound of the range [-231, 231 - 1], the final result is clamped to -231 = -2147483648. 
     

     

    @@ -73,7 +117,7 @@
    • 0 <= s.length <= 200
    • -
    • s consists of English letters (lower-case and upper-case), digits, ' ', '+', '-' and '.'.
    • +
    • s consists of English letters (lower-case and upper-case), digits (0-9), ' ', '+', '-', and '.'.
    ### Related Topics diff --git a/problems/subsets-ii/README.md b/problems/subsets-ii/README.md index 42c17dd50..212b49a70 100644 --- a/problems/subsets-ii/README.md +++ b/problems/subsets-ii/README.md @@ -11,24 +11,25 @@ ## [90. Subsets II (Medium)](https://leetcode.com/problems/subsets-ii "子集 II") -

    Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set).

    - -

    Note: The solution set must not contain duplicate subsets.

    - -

    Example:

    - -
    -Input: [1,2,2]
    -Output:
    -[
    -  [2],
    -  [1],
    -  [1,2,2],
    -  [2,2],
    -  [1,2],
    -  []
    -]
    +

    Given an integer array nums that may contain duplicates, return all possible subsets (the power set).

    + +

    The solution set must not contain duplicate subsets. Return the solution in any order.

    + +

     

    +

    Example 1:

    +
    Input: nums = [1,2,2]
    +Output: [[],[1],[1,2],[1,2,2],[2],[2,2]]
    +

    Example 2:

    +
    Input: nums = [0]
    +Output: [[],[0]]
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 10
    • +
    • -10 <= nums[i] <= 10
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/subsets/README.md b/problems/subsets/README.md index 075a60080..28e5bcd05 100644 --- a/problems/subsets/README.md +++ b/problems/subsets/README.md @@ -11,9 +11,9 @@ ## [78. Subsets (Medium)](https://leetcode.com/problems/subsets "子集") -

    Given an integer array nums, return all possible subsets (the power set).

    +

    Given an integer array nums of unique elements, return all possible subsets (the power set).

    -

    The solution set must not contain duplicate subsets.

    +

    The solution set must not contain duplicate subsets. Return the solution in any order.

     

    Example 1:

    diff --git a/problems/sum-of-subarray-minimums/README.md b/problems/sum-of-subarray-minimums/README.md index 349f90aa5..a34173d2a 100644 --- a/problems/sum-of-subarray-minimums/README.md +++ b/problems/sum-of-subarray-minimums/README.md @@ -11,32 +11,7 @@ ## [907. Sum of Subarray Minimums (Medium)](https://leetcode.com/problems/sum-of-subarray-minimums "子数组的最小值之和") -

    Given an array of integers A, find the sum of min(B), where B ranges over every (contiguous) subarray of A.

    - -

    Since the answer may be large, return the answer modulo 10^9 + 7.

    - -

     

    - -

    Example 1:

    - -
    -Input: [3,1,2,4]
    -Output: 17
    -Explanation: Subarrays are [3], [1], [2], [4], [3,1], [1,2], [2,4], [3,1,2], [1,2,4], [3,1,2,4]. 
    -Minimums are 3, 1, 2, 4, 1, 1, 2, 1, 1, 1.  Sum is 17.
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= A.length <= 30000
    2. -
    3. 1 <= A[i] <= 30000
    4. -
    - -
    -

     

    -
    +

    Given an array of integers arr, find the sum of min(b), where b ranges over every (contiguous) subarray of arr. Since the answer may be large, return the answer modulo 109 + 7.

     

    Example 1:

    diff --git a/problems/summary-ranges/README.md b/problems/summary-ranges/README.md index 4c7a94de8..f9d073e35 100644 --- a/problems/summary-ranges/README.md +++ b/problems/summary-ranges/README.md @@ -81,5 +81,5 @@ [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Missing Ranges](../missing-ranges) (Medium) + 1. [Missing Ranges](../missing-ranges) (Easy) 1. [Data Stream as Disjoint Intervals](../data-stream-as-disjoint-intervals) (Hard) diff --git a/problems/surface-area-of-3d-shapes/README.md b/problems/surface-area-of-3d-shapes/README.md index 03eb25c6d..f8544c12a 100644 --- a/problems/surface-area-of-3d-shapes/README.md +++ b/problems/surface-area-of-3d-shapes/README.md @@ -11,12 +11,14 @@ ## [892. Surface Area of 3D Shapes (Easy)](https://leetcode.com/problems/surface-area-of-3d-shapes "三维形体的表面积") -

    You are given an n x n grid where we can place some 1 x 1 x 1 cubes.

    +

    You are given an n x n grid where you have placed some 1 x 1 x 1 cubes. Each value v = grid[i][j] represents a tower of v cubes placed on top of cell (i, j).

    -

    Each value v = grid[i][j] represents a tower of v cubes placed on top of the grid cell (i, j).

    +

    After placing these cubes, you have decided to glue any directly adjacent cubes to each other, forming several irregular 3D shapes.

    Return the total surface area of the resulting shapes.

    +

    Note: The bottom face of each shape counts toward its surface area.

    +

     

    Example 1:

    diff --git a/problems/the-number-of-employees-which-report-to-each-employee/README.md b/problems/the-number-of-employees-which-report-to-each-employee/README.md new file mode 100644 index 000000000..593e0015c --- /dev/null +++ b/problems/the-number-of-employees-which-report-to-each-employee/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../shortest-path-to-get-food "Shortest Path to Get Food") +                 +[Next >](../find-the-highest-altitude "Find the Highest Altitude") + +## [1731. The Number of Employees Which Report to Each Employee (Easy)](https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee "") + + diff --git a/problems/the-number-of-employees-which-report-to-each-employee/mysql_schemas.sql b/problems/the-number-of-employees-which-report-to-each-employee/mysql_schemas.sql new file mode 100644 index 000000000..a819253b1 --- /dev/null +++ b/problems/the-number-of-employees-which-report-to-each-employee/mysql_schemas.sql @@ -0,0 +1,6 @@ +Create table If Not Exists Employees(employee_id int, name varchar(20), reports_to int, age int); +Truncate table Employees; +insert into Employees (employee_id, name, reports_to, age) values ('9', 'Hercy', 'None', '43'); +insert into Employees (employee_id, name, reports_to, age) values ('6', 'Alice', '9', '41'); +insert into Employees (employee_id, name, reports_to, age) values ('4', 'Bob', '9', '36'); +insert into Employees (employee_id, name, reports_to, age) values ('2', 'Winston', 'None', '37'); diff --git a/problems/third-maximum-number/README.md b/problems/third-maximum-number/README.md index 3fad785b5..8f5da7966 100644 --- a/problems/third-maximum-number/README.md +++ b/problems/third-maximum-number/README.md @@ -43,8 +43,8 @@ Both numbers with value 2 are both considered as second maximum.

    Constraints:

      -
    • 1 <= nums.length <= 104
    • -
    • 231 <= nums[i] <= 231 - 1
    • +
    • 1 <= nums.length <= 104
    • +
    • -231 <= nums[i] <= 231 - 1

     

    diff --git a/problems/three-equal-parts/README.md b/problems/three-equal-parts/README.md index 1996c733e..93e627f70 100644 --- a/problems/three-equal-parts/README.md +++ b/problems/three-equal-parts/README.md @@ -11,50 +11,39 @@ ## [927. Three Equal Parts (Hard)](https://leetcode.com/problems/three-equal-parts "三等分") -

    Given an array A of 0s and 1s, divide the array into 3 non-empty parts such that all of these parts represent the same binary value.

    +

    You are given an array arr which consists of only zeros and ones, divide the array into three non-empty parts such that all of these parts represent the same binary value.

    -

    If it is possible, return any [i, j] with i+1 < j, such that:

    +

    If it is possible, return any [i, j] with i + 1 < j, such that:

      -
    • A[0], A[1], ..., A[i] is the first part;
    • -
    • A[i+1], A[i+2], ..., A[j-1] is the second part, and
    • -
    • A[j], A[j+1], ..., A[A.length - 1] is the third part.
    • -
    • All three parts have equal binary value.
    • +
    • arr[0], arr[1], ..., arr[i] is the first part,
    • +
    • arr[i + 1], arr[i + 2], ..., arr[j - 1] is the second part, and
    • +
    • arr[j], arr[j + 1], ..., arr[arr.length - 1] is the third part.
    • +
    • All three parts have equal binary values.

    If it is not possible, return [-1, -1].

    -

    Note that the entire part is used when considering what binary value it represents.  For example, [1,1,0] represents 6 in decimal, not 3.  Also, leading zeros are allowed, so [0,1,1] and [1,1] represent the same value.

    +

    Note that the entire part is used when considering what binary value it represents. For example, [1,1,0] represents 6 in decimal, not 3. Also, leading zeros are allowed, so [0,1,1] and [1,1] represent the same value.

     

    -

    Example 1:

    - -
    -Input: [1,0,1,0,1]
    -Output: [0,3]
    +
    Input: arr = [1,0,1,0,1]
    +Output: [0,3]
    +

    Example 2:

    +
    Input: arr = [1,1,0,1,1]
    +Output: [-1,-1]
    +

    Example 3:

    +
    Input: arr = [1,1,0,0,1]
    +Output: [0,2]
     
    - -
    -

    Example 2:

    - -
    -Input: [1,1,0,1,1]
    -Output: [-1,-1]
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 3 <= A.length <= 30000
    2. -
    3. A[i] == 0 or A[i] == 1
    4. -
    - -
    -
     
    -
    +
      +
    • 3 <= arr.length <= 3 * 104
    • +
    • arr[i] is 0 or 1
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/trapping-rain-water/README.md b/problems/trapping-rain-water/README.md index 04053ca4f..eebeecd03 100644 --- a/problems/trapping-rain-water/README.md +++ b/problems/trapping-rain-water/README.md @@ -42,6 +42,7 @@ [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Container With Most Water](../container-with-most-water) (Medium) diff --git a/problems/trim-a-binary-search-tree/README.md b/problems/trim-a-binary-search-tree/README.md index b49488b06..cbeb41662 100644 --- a/problems/trim-a-binary-search-tree/README.md +++ b/problems/trim-a-binary-search-tree/README.md @@ -9,7 +9,7 @@                  [Next >](../maximum-swap "Maximum Swap") -## [669. Trim a Binary Search Tree (Easy)](https://leetcode.com/problems/trim-a-binary-search-tree "修剪二叉搜索树") +## [669. Trim a Binary Search Tree (Medium)](https://leetcode.com/problems/trim-a-binary-search-tree "修剪二叉搜索树")

    Given the root of a binary search tree and the lowest and highest boundaries as low and high, trim the tree so that all its elements lies in [low, high]. Trimming the tree should not change the relative structure of the elements that will remain in the tree (i.e., any node's descendant should remain a descendant). It can be proven that there is a unique answer.

    @@ -64,3 +64,4 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Recursion](../../tag/recursion/README.md)] diff --git a/problems/trips-and-users/README.md b/problems/trips-and-users/README.md index fba9141a1..6b5209d40 100644 --- a/problems/trips-and-users/README.md +++ b/problems/trips-and-users/README.md @@ -11,55 +11,90 @@ ## [262. Trips and Users (Hard)](https://leetcode.com/problems/trips-and-users "行程和用户") -

    The Trips table holds all taxi trips. Each trip has a unique Id, while Client_Id and Driver_Id are both foreign keys to the Users_Id at the Users table. Status is an ENUM type of (‘completed’, ‘cancelled_by_driver’, ‘cancelled_by_client’).

    +

    Table: Trips

    -+----+-----------+-----------+---------+--------------------+----------+
    -| Id | Client_Id | Driver_Id | City_Id |        Status      |Request_at|
    -+----+-----------+-----------+---------+--------------------+----------+
    -| 1  |     1     |    10     |    1    |     completed      |2013-10-01|
    -| 2  |     2     |    11     |    1    | cancelled_by_driver|2013-10-01|
    -| 3  |     3     |    12     |    6    |     completed      |2013-10-01|
    -| 4  |     4     |    13     |    6    | cancelled_by_client|2013-10-01|
    -| 5  |     1     |    10     |    1    |     completed      |2013-10-02|
    -| 6  |     2     |    11     |    6    |     completed      |2013-10-02|
    -| 7  |     3     |    12     |    6    |     completed      |2013-10-02|
    -| 8  |     2     |    12     |    12   |     completed      |2013-10-03|
    -| 9  |     3     |    10     |    12   |     completed      |2013-10-03| 
    -| 10 |     4     |    13     |    12   | cancelled_by_driver|2013-10-03|
    -+----+-----------+-----------+---------+--------------------+----------+
    ++-------------+----------+
    +| Column Name | Type     |
    ++-------------+----------+
    +| Id          | int      |
    +| Client_Id   | int      |
    +| Driver_Id   | int      |
    +| City_Id     | int      |
    +| Status      | enum     |
    +| Request_at  | date     |     
    ++-------------+----------+
    +Id is the primary key for this table.
    +The table holds all taxi trips. Each trip has a unique Id, while Client_Id and Driver_Id are both foreign keys to the Users_Id at the Users table.
    +Status is an ENUM type of (‘completed’, ‘cancelled_by_driver’, ‘cancelled_by_client’).
     
    -

    The Users table holds all users. Each user has an unique Users_Id, and Role is an ENUM type of (‘client’, ‘driver’, ‘partner’).

    +

     

    + +

    Table: Users

    -+----------+--------+--------+
    -| Users_Id | Banned |  Role  |
    -+----------+--------+--------+
    -|    1     |   No   | client |
    -|    2     |   Yes  | client |
    -|    3     |   No   | client |
    -|    4     |   No   | client |
    -|    10    |   No   | driver |
    -|    11    |   No   | driver |
    -|    12    |   No   | driver |
    -|    13    |   No   | driver |
    -+----------+--------+--------+
    ++-------------+----------+
    +| Column Name | Type     |
    ++-------------+----------+
    +| Users_Id    | int      |
    +| Banned      | enum     |
    +| Role        | enum     |
    ++-------------+----------+
    +Users_Id is the primary key for this table.
    +The table holds all users. Each user has a unique Users_Id, and Role is an ENUM type of (‘client’, ‘driver’, ‘partner’).
    +Status is an ENUM type of (‘Yes’, ‘No’).
     
    -

    Write a SQL query to find the cancellation rate of requests made by unbanned users (both client and driver must be unbanned) between Oct 1, 2013 and Oct 3, 2013. The cancellation rate is computed by dividing the number of canceled (by client or driver) requests made by unbanned users by the total number of requests made by unbanned users.

    +

     

    + +

    Write a SQL query to find the cancellation rate of requests made by unbanned users (both client and driver must be unbanned) between "2013-10-01" and "2013-10-01".

    + +

    The cancellation rate is computed by dividing the number of canceled (by client or driver) requests made by unbanned users by the total number of requests made by unbanned users.

    + +

    Return the result table in any order. Round Cancellation Rate to two decimal points.

    -

    For the above tables, your SQL query should return the following rows with the cancellation rate being rounded to two decimal places.

    +

    The query result format is in the following example:

    + +

     

    +Trips table:
    ++----+-----------+-----------+---------+---------------------+------------+
    +| Id | Client_Id | Driver_Id | City_Id | Status              | Request_at |
    ++----+-----------+-----------+---------+---------------------+------------+
    +| 1  | 1         | 10        | 1       | completed           | 2013-10-01 |
    +| 2  | 2         | 11        | 1       | cancelled_by_driver | 2013-10-01 |
    +| 3  | 3         | 12        | 6       | completed           | 2013-10-01 |
    +| 4  | 4         | 13        | 6       | cancelled_by_client | 2013-10-01 |
    +| 5  | 1         | 10        | 1       | completed           | 2013-10-02 |
    +| 6  | 2         | 11        | 6       | completed           | 2013-10-02 |
    +| 7  | 3         | 12        | 6       | completed           | 2013-10-02 |
    +| 8  | 2         | 12        | 12      | completed           | 2013-10-03 |
    +| 9  | 3         | 10        | 12      | completed           | 2013-10-03 |
    +| 10 | 4         | 13        | 12      | cancelled_by_driver | 2013-10-03 |
    ++----+-----------+-----------+---------+---------------------+------------+
    +
    +Users table:
    ++----------+--------+--------+
    +| Users_Id | Banned | Role   |
    ++----------+--------+--------+
    +| 1        | No     | client |
    +| 2        | Yes    | client |
    +| 3        | No     | client |
    +| 4        | No     | client |
    +| 10       | No     | driver |
    +| 11       | No     | driver |
    +| 12       | No     | driver |
    +| 13       | No     | driver |
    ++----------+--------+--------+
    +
    +Result table:
     +------------+-------------------+
    -|     Day    | Cancellation Rate |
    +| Day        | Cancellation Rate |
     +------------+-------------------+
    -| 2013-10-01 |       0.33        |
    -| 2013-10-02 |       0.00        |
    -| 2013-10-03 |       0.50        |
    +| 2013-10-01 | 0.33              |
    +| 2013-10-02 | 0.00              |
    +| 2013-10-03 | 0.50              |
     +------------+-------------------+
     
    - -

    Credits:
    -Special thanks to @cak1erlizhou for contributing this question, writing the problem description and adding part of the test cases.

    diff --git a/problems/tuple-with-same-product/README.md b/problems/tuple-with-same-product/README.md new file mode 100644 index 000000000..fe5ce5a96 --- /dev/null +++ b/problems/tuple-with-same-product/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../number-of-rectangles-that-can-form-the-largest-square "Number Of Rectangles That Can Form The Largest Square") +                 +[Next >](../largest-submatrix-with-rearrangements "Largest Submatrix With Rearrangements") + +## [1726. Tuple with Same Product (Medium)](https://leetcode.com/problems/tuple-with-same-product "同积元组") + +

    Given an array nums of distinct positive integers, return the number of tuples (a, b, c, d) such that a * b = c * d where a, b, c, and d are elements of nums, and a != b != c != d.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [2,3,4,6]
    +Output: 8
    +Explanation: There are 8 valid tuples:
    +(2,6,3,4) , (2,6,4,3) , (6,2,3,4) , (6,2,4,3)
    +(3,4,2,6) , (4,3,2,6) , (3,4,6,2) , (4,3,6,2)
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,2,4,5,10]
    +Output: 16
    +Explanation: There are 16 valids tuples:
    +(1,10,2,5) , (1,10,5,2) , (10,1,2,5) , (10,1,5,2)
    +(2,5,1,10) , (2,5,10,1) , (5,2,1,10) , (5,2,10,1)
    +(2,10,4,5) , (2,10,5,4) , (10,2,4,5) , (10,2,4,5)
    +(4,5,2,10) , (4,5,10,2) , (5,4,2,10) , (5,4,10,2)
    +
    + +

    Example 3:

    + +
    +Input: nums = [2,3,4,6,8,12]
    +Output: 40
    +
    + +

    Example 4:

    + +
    +Input: nums = [2,3,5,7]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • 1 <= nums[i] <= 104
    • +
    • All elements in nums are distinct.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +Note that all of the integers are distinct. This means that each time a product is formed it must be formed by two unique integers. +
    + +
    +Hint 2 +Count the frequency of each product of 2 distinct numbers. Then calculate the permutations formed. +
    diff --git a/problems/two-sum-ii-input-array-is-sorted/README.md b/problems/two-sum-ii-input-array-is-sorted/README.md index 9b7ad3599..cbbdebf3f 100644 --- a/problems/two-sum-ii-input-array-is-sorted/README.md +++ b/problems/two-sum-ii-input-array-is-sorted/README.md @@ -11,16 +11,11 @@ ## [167. Two Sum II - Input array is sorted (Easy)](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted "两数之和 II - 输入有序数组") -

    Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.

    +

    Given an array of integers numbers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.

    -

    The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2.

    +

    Return the indices of the two numbers (1-indexed) as an integer array answer of size 2, where 1 <= answer[0] < answer[1] <= numbers.length.

    -

    Note:

    - -
      -
    • Your returned answers (both index1 and index2) are not zero-based.
    • -
    • You may assume that each input would have exactly one solution and you may not use the same element twice.
    • -
    +

    You may assume that each input would have exactly one solution and you may not use the same element twice.

     

    Example 1:

    @@ -49,10 +44,11 @@

    Constraints:

      -
    • 2 <= nums.length <= 3 * 104
    • -
    • -1000 <= nums[i] <= 1000
    • -
    • nums is sorted in increasing order.
    • +
    • 2 <= numbers.length <= 3 * 104
    • +
    • -1000 <= numbers[i] <= 1000
    • +
    • numbers is sorted in increasing order.
    • -1000 <= target <= 1000
    • +
    • Only one valid answer exists.
    ### Related Topics diff --git a/problems/ugly-number-iii/README.md b/problems/ugly-number-iii/README.md index 5cd9b128f..03f1f90e1 100644 --- a/problems/ugly-number-iii/README.md +++ b/problems/ugly-number-iii/README.md @@ -11,9 +11,9 @@ ## [1201. Ugly Number III (Medium)](https://leetcode.com/problems/ugly-number-iii "丑数 III") -

    Write a program to find the n-th ugly number.

    +

    Given four integers n, a, b, and c, return the nth ugly number.

    -

    Ugly numbers are positive integers which are divisible by a or b or c.

    +

    Ugly numbers are positive integers that are divisible by a, b, or c.

     

    Example 1:

    @@ -50,9 +50,9 @@

    Constraints:

      -
    • 1 <= n, a, b, c <= 10^9
    • -
    • 1 <= a * b * c <= 10^18
    • -
    • It's guaranteed that the result will be in range [1, 2 * 10^9]
    • +
    • 1 <= n, a, b, c <= 109
    • +
    • 1 <= a * b * c <= 1018
    • +
    • It is guaranteed that the result will be in range [1, 2 * 109].
    ### Related Topics diff --git a/problems/unique-binary-search-trees-ii/README.md b/problems/unique-binary-search-trees-ii/README.md index 482638ce5..b4b0445f3 100644 --- a/problems/unique-binary-search-trees-ii/README.md +++ b/problems/unique-binary-search-trees-ii/README.md @@ -11,35 +11,28 @@ ## [95. Unique Binary Search Trees II (Medium)](https://leetcode.com/problems/unique-binary-search-trees-ii "不同的二叉搜索树 II") -

    Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1 ... n.

    +

    Given an integer n, return all the structurally unique BST's (binary search trees), which has exactly n nodes of unique values from 1 to n. Return the answer in any order.

    -

    Example:

    +

     

    +

    Example 1:

    + +
    +Input: n = 3
    +Output: [[1,null,2,null,3],[1,null,3,2],[2,1,3],[3,1,null,null,2],[3,2,null,1]]
    +
    + +

    Example 2:

    -Input: 3
    -Output:
    -[
    -  [1,null,3,2],
    -  [3,2,null,1],
    -  [3,1,null,null,2],
    -  [2,1,3],
    -  [1,null,2,null,3]
    -]
    -Explanation:
    -The above output corresponds to the 5 unique BST's shown below:
    -
    -   1         3     3      2      1
    -    \       /     /      / \      \
    -     3     2     1      1   3      2
    -    /     /       \                 \
    -   2     1         2                 3
    +Input: n = 1
    +Output: [[1]]
     

     

    Constraints:

      -
    • 0 <= n <= 8
    • +
    • 1 <= n <= 8
    ### Related Topics diff --git a/problems/unique-binary-search-trees/README.md b/problems/unique-binary-search-trees/README.md index f95e1a39d..ab550f3e7 100644 --- a/problems/unique-binary-search-trees/README.md +++ b/problems/unique-binary-search-trees/README.md @@ -11,21 +11,21 @@ ## [96. Unique Binary Search Trees (Medium)](https://leetcode.com/problems/unique-binary-search-trees "不同的二叉搜索树") -

    Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n?

    - -

    Example:

    +

    Given an integer n, return the number of structurally unique BST's (binary search trees) which has exactly n nodes of unique values from 1 to n.

    +

     

    +

    Example 1:

    +
    -Input: 3
    +Input: n = 3
     Output: 5
    -Explanation:
    -Given n = 3, there are a total of 5 unique BST's:
    -
    -   1         3     3      2      1
    -    \       /     /      / \      \
    -     3     2     1      1   3      2
    -    /     /       \                 \
    -   2     1         2                 3
    +
    + +

    Example 2:

    + +
    +Input: n = 1
    +Output: 1
     

     

    diff --git a/problems/valid-number/README.md b/problems/valid-number/README.md index 371b589a2..3425706a8 100644 --- a/problems/valid-number/README.md +++ b/problems/valid-number/README.md @@ -11,49 +11,72 @@ ## [65. Valid Number (Hard)](https://leetcode.com/problems/valid-number "有效数字") -

    Validate if a given string can be interpreted as a decimal number.

    - -

    Some examples:
    -"0" => true
    -" 0.1 " => true
    -"abc" => false
    -"1 a" => false
    -"2e10" => true
    -" -90e3   " => true
    -" 1e" => false
    -"e3" => false
    -" 6e-1" => true
    -" 99e2.5 " => false
    -"53.5e93" => true
    -" --6 " => false
    -"-+3" => false
    -"95a54e53" => false

    - -

    Note: It is intended for the problem statement to be ambiguous. It would be best if you gathered all requirements up front before implementing one. However, here is a list of characters that can be in a valid decimal number:

    +

    A valid number can be split up into these components (in order):

    -
      -
    • Numbers 0-9
    • -
    • Exponent - "e"
    • -
    • Positive/negative sign - "+"/"-"
    • -
    • Decimal point - "."
    • -
    +
      +
    1. A decimal number or an integer.
    2. +
    3. (Optional) An 'e' or 'E', followed by an integer.
    4. +
    + +

    A decimal number can be split up into these components (in order):

    + +
      +
    1. (Optional) A sign character (either '+' or '-').
    2. +
    3. One of the following formats: +
        +
      1. At least one digit, followed by a dot '.'.
      2. +
      3. At least one digit, followed by a dot '.', followed by at least one digit.
      4. +
      5. A dot '.', followed by at least one digit.
      6. +
      +
    4. +
    + +

    An integer can be split up into these components (in order):

    -

    Of course, the context of these characters also matters in the input.

    +
      +
    1. (Optional) A sign character (either '+' or '-').
    2. +
    3. At least one digit.
    4. +
    + +

    For example, all the following are valid numbers: ["2", "0089", "-0.1", "+3.14", "4.", "-.9", "2e10", "-90E3", "3e+7", "+6e-1", "53.5e93", "-123.456e789"], while the following are not valid numbers: ["abc", "1a", "1e", "e3", "99e2.5", "--6", "-+3", "95a54e53"].

    + +

    Given a string s, return true if s is a valid number.

     

    Example 1:

    -
    Input: s = "0"
    +
    +
    +Input: s = "0"
     Output: true
    -

    Example 2:

    -
    Input: s = "3"
    +
    + +

    Example 2:

    + +
    +Input: s = "e"
    +Output: false
    +
    + +

    Example 3:

    + +
    +Input: s = "."
    +Output: false
    +
    + +

    Example 4:

    + +
    +Input: s = ".1"
     Output: true
     
    +

     

    Constraints:

    • 1 <= s.length <= 20
    • -
    • s consists of only English letters, digits, space ' ', plus '+', minus '-', or dot '.'.
    • +
    • s consists of only English letters (both uppercase and lowercase), digits (0-9), plus '+', minus '-', or dot '.'.
    ### Related Topics diff --git a/problems/vertical-order-traversal-of-a-binary-tree/README.md b/problems/vertical-order-traversal-of-a-binary-tree/README.md index 0830cfee7..1906502cf 100644 --- a/problems/vertical-order-traversal-of-a-binary-tree/README.md +++ b/problems/vertical-order-traversal-of-a-binary-tree/README.md @@ -11,15 +11,13 @@ ## [987. Vertical Order Traversal of a Binary Tree (Medium)](https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree "二叉树的垂序遍历") -

    Given the root of a binary tree, return the vertical order traversal of its nodes values.

    +

    Given the root of a binary tree, calculate the vertical order traversal of the binary tree.

    -

    For each node at position (x, y), its left and right children respectively will be at positions (x - 1, y - 1) and (x + 1, y - 1).

    +

    For each node at position (x, y), its left and right children will be at positions (x - 1, y - 1) and (x + 1, y - 1) respectively.

    -

    Running a vertical line from x = -∞ to x = +∞, whenever the vertical line touches some nodes, we report the values of the nodes in order from top to bottom (decreasing y coordinates).

    +

    The vertical order traversal of a binary tree is a list of non-empty reports for each unique x-coordinate from left to right. Each report is a list of all nodes at a given x-coordinate. The report should be primarily sorted by y-coordinate from highest y-coordinate to lowest. If any two nodes have the same y-coordinate in the report, the node with the smaller value should appear earlier.

    -

    If two nodes have the same position, then the value of the node that is reported first is the value that is smaller.

    - -

    Return a list of non-empty reports in order of x coordinate. Every report will have a list of values of nodes.

    +

    Return the vertical order traversal of the binary tree.

     

    Example 1:

    @@ -28,9 +26,9 @@ Input: root = [3,9,20,null,null,15,7] Output: [[9],[3,15],[20],[7]] Explanation: Without loss of generality, we can assume the root node is at position (0, 0): -Then, the node with value 9 occurs at position (-1, -1); -The nodes with values 3 and 15 occur at positions (0, 0) and (0, -2); -The node with value 20 occurs at position (1, -1); +The node with value 9 occurs at position (-1, -1). +The nodes with values 3 and 15 occur at positions (0, 0) and (0, -2). +The node with value 20 occurs at position (1, -1). The node with value 7 occurs at position (2, -2).

    Example 2:

    @@ -39,7 +37,7 @@ The node with value 7 occurs at position (2, -2).
    Input: root = [1,2,3,4,5,6,7] Output: [[4],[2],[1,5,6],[3],[7]] Explanation: The node with value 5 and the node with value 6 have the same position according to the given scheme. -However, in the report "[1,5,6]", the node value of 5 comes first since 5 is smaller than 6.
    +However, in the report [1,5,6], the node with value 5 comes first since 5 is smaller than 6.

     

    Constraints:

    diff --git a/problems/walking-robot-simulation/README.md b/problems/walking-robot-simulation/README.md index 4b1ec763f..7a8a80243 100644 --- a/problems/walking-robot-simulation/README.md +++ b/problems/walking-robot-simulation/README.md @@ -11,19 +11,28 @@ ## [874. Walking Robot Simulation (Easy)](https://leetcode.com/problems/walking-robot-simulation "模拟行走机器人") -

    A robot on an infinite grid starts at point (0, 0) and faces north. The robot can receive one of three possible types of commands:

    +

    A robot on an infinite XY-plane starts at point (0, 0) and faces north. The robot can receive one of three possible types of commands:

    • -2: turn left 90 degrees,
    • -1: turn right 90 degrees, or
    • -
    • 1 <= x <= 9: move forward x units
    • +
    • 1 <= k <= 9: move forward k units.

    Some of the grid squares are obstacles. The ith obstacle is at grid point obstacles[i] = (xi, yi).

    If the robot would try to move onto them, the robot stays on the previous grid square instead (but still continues following the rest of the route.)

    -

    Return the square of the maximum Euclidean distance that the robot will be from the origin.

    +

    Return the maximum Euclidean distance that the robot will be from the origin squared (i.e. if the distance is 5, return 25).

    + +

    Note:

    + +
      +
    • North means +Y direction.
    • +
    • East means +X direction.
    • +
    • South means -Y direction.
    • +
    • West means -X direction.
    • +

     

    Example 1:

    @@ -31,7 +40,11 @@
     Input: commands = [4,-1,3], obstacles = []
     Output: 25
    -Explanation: robot will go to (3, 4)
    +Explanation: The robot starts at (0, 0):
    +1. Move north 4 units to (0, 4).
    +2. Turn right.
    +3. Move east 3 units to (3, 4).
    +The furthest point away from the origin is (3, 4), which is 32 + 42 = 25 units away.
     

    Example 2:

    @@ -39,7 +52,13 @@
     Input: commands = [4,-1,4,-2,4], obstacles = [[2,4]]
     Output: 65
    -Explanation: robot will be stuck at (1, 4) before turning left and going to (1, 8)
    +Explanation: The robot starts at (0, 0):
    +1. Move north 4 units to (0, 4).
    +2. Turn right.
    +3. Move east 1 unit and get blocked by the obstacle at (2, 4), robot is at (1, 4).
    +4. Turn left.
    +5. Move north 4 units to (1, 8).
    +The furthest point away from the origin is (1, 8), which is 12 + 82 = 65 units away.
     

     

    @@ -47,7 +66,7 @@
    • 1 <= commands.length <= 104
    • -
    • commands[i] is in the list [-2,-1,1,2,3,4,5,6,7,8,9].
    • +
    • commands[i] is one of the values in the list [-2,-1,1,2,3,4,5,6,7,8,9].
    • 0 <= obstacles.length <= 104
    • -3 * 104 <= xi, yi <= 3 * 104
    • The answer is guaranteed to be less than 231.
    • diff --git a/problems/word-ladder/README.md b/problems/word-ladder/README.md index da04e85e8..980ee23d7 100644 --- a/problems/word-ladder/README.md +++ b/problems/word-ladder/README.md @@ -11,14 +11,16 @@ ## [127. Word Ladder (Hard)](https://leetcode.com/problems/word-ladder "单词接龙") -

      Given two words beginWord and endWord, and a dictionary wordList, return the length of the shortest transformation sequence from beginWord to endWord, such that:

      +

      A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words such that:

        -
      • Only one letter can be changed at a time.
      • -
      • Each transformed word must exist in the word list.
      • +
      • The first word in the sequence is beginWord.
      • +
      • The last word in the sequence is endWord.
      • +
      • Only one letter is different between each adjacent pair of words in the sequence.
      • +
      • Every word in the sequence is in wordList.
      -

      Return 0 if there is no such transformation sequence.

      +

      Given two words, beginWord and endWord, and a dictionary wordList, return the number of words in the shortest transformation sequence from beginWord to endWord, or 0 if no such sequence exists.

       

      Example 1:

      @@ -26,7 +28,7 @@
       Input: beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log","cog"]
       Output: 5
      -Explanation: As one shortest transformation is "hit" -> "hot" -> "dot" -> "dog" -> "cog", return its length 5.
      +Explanation: One shortest transformation is "hit" -> "hot" -> "dot" -> "dog" -> "cog" with 5 words.
       

      Example 2:

      @@ -34,20 +36,20 @@
       Input: beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log"]
       Output: 0
      -Explanation: The endWord "cog" is not in wordList, therefore no possible transformation.
      +Explanation: The endWord "cog" is not in wordList, therefore there is no possible transformation.
       

       

      Constraints:

        -
      • 1 <= beginWord.length <= 100
      • +
      • 1 <= beginWord.length <= 10
      • endWord.length == beginWord.length
      • 1 <= wordList.length <= 5000
      • -
      • wordList[i].length == beginWord.length
      • -
      • beginWordendWord, and wordList[i] consist of lowercase English letters.
      • -
      • beginWord != endWord
      • -
      • All the strings in wordList are unique.
      • +
      • wordList[i].length == beginWord.length
      • +
      • beginWord, endWord, and wordList[i] consist of lowercase English letters.
      • +
      • beginWord != endWord
      • +
      • All the strings in wordList are unique.
      ### Related Topics diff --git a/problems/word-pattern-ii/README.md b/problems/word-pattern-ii/README.md index 4bb45671f..5e9c20a60 100644 --- a/problems/word-pattern-ii/README.md +++ b/problems/word-pattern-ii/README.md @@ -9,7 +9,7 @@                  [Next >](../nim-game "Nim Game") -## [291. Word Pattern II (Hard)](https://leetcode.com/problems/word-pattern-ii "单词规律 II") +## [291. Word Pattern II (Medium)](https://leetcode.com/problems/word-pattern-ii "单词规律 II")

      Given a pattern and a string str, find if str follows the same pattern.

      diff --git a/problems/word-pattern/README.md b/problems/word-pattern/README.md index abb6d2af3..f5da65655 100644 --- a/problems/word-pattern/README.md +++ b/problems/word-pattern/README.md @@ -61,4 +61,4 @@ ### Similar Questions 1. [Isomorphic Strings](../isomorphic-strings) (Easy) - 1. [Word Pattern II](../word-pattern-ii) (Hard) + 1. [Word Pattern II](../word-pattern-ii) (Medium) diff --git a/readme/1-300.md b/readme/1-300.md index 63d054eac..6d10e1a70 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -88,7 +88,7 @@ LeetCode Problems' Solutions | 16 | [3Sum Closest](https://leetcode.com/problems/3sum-closest "最接近的三数之和") | [Go](../problems/3sum-closest) | Medium | | 17 | [Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number "电话号码的字母组合") | [Go](../problems/letter-combinations-of-a-phone-number) | Medium | | 18 | [4Sum](https://leetcode.com/problems/4sum "四数之和") | [Go](../problems/4sum) | Medium | -| 19 | [Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list "删除链表的倒数第N个节点") | [Go](../problems/remove-nth-node-from-end-of-list) | Medium | +| 19 | [Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list "删除链表的倒数第 N 个结点") | [Go](../problems/remove-nth-node-from-end-of-list) | Medium | | 20 | [Valid Parentheses](https://leetcode.com/problems/valid-parentheses "有效的括号") | [Go](../problems/valid-parentheses) | Easy | | 21 | [Merge Two Sorted Lists](https://leetcode.com/problems/merge-two-sorted-lists "合并两个有序链表") | [Go](../problems/merge-two-sorted-lists) | Easy | | 22 | [Generate Parentheses](https://leetcode.com/problems/generate-parentheses "括号生成") | [Go](../problems/generate-parentheses) | Medium | @@ -360,7 +360,7 @@ LeetCode Problems' Solutions | 288 | [Unique Word Abbreviation](https://leetcode.com/problems/unique-word-abbreviation "单词的唯一缩写") 🔒 | [Go](../problems/unique-word-abbreviation) | Medium | | 289 | [Game of Life](https://leetcode.com/problems/game-of-life "生命游戏") | [Go](../problems/game-of-life) | Medium | | 290 | [Word Pattern](https://leetcode.com/problems/word-pattern "单词规律") | [Go](../problems/word-pattern) | Easy | -| 291 | [Word Pattern II](https://leetcode.com/problems/word-pattern-ii "单词规律 II") 🔒 | [Go](../problems/word-pattern-ii) | Hard | +| 291 | [Word Pattern II](https://leetcode.com/problems/word-pattern-ii "单词规律 II") 🔒 | [Go](../problems/word-pattern-ii) | Medium | | 292 | [Nim Game](https://leetcode.com/problems/nim-game "Nim 游戏") | [Go](../problems/nim-game) | Easy | | 293 | [Flip Game](https://leetcode.com/problems/flip-game "翻转游戏") 🔒 | [Go](../problems/flip-game) | Easy | | 294 | [Flip Game II](https://leetcode.com/problems/flip-game-ii "翻转游戏 II") 🔒 | [Go](../problems/flip-game-ii) | Medium | diff --git a/readme/301-600.md b/readme/301-600.md index 026123fec..7e8d51d89 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -108,7 +108,7 @@ LeetCode Problems' Solutions | 336 | [Palindrome Pairs](https://leetcode.com/problems/palindrome-pairs "回文对") | [Go](../problems/palindrome-pairs) | Hard | | 337 | [House Robber III](https://leetcode.com/problems/house-robber-iii "打家劫舍 III") | [Go](../problems/house-robber-iii) | Medium | | 338 | [Counting Bits](https://leetcode.com/problems/counting-bits "比特位计数") | [Go](../problems/counting-bits) | Medium | -| 339 | [Nested List Weight Sum](https://leetcode.com/problems/nested-list-weight-sum "嵌套列表权重和") 🔒 | [Go](../problems/nested-list-weight-sum) | Easy | +| 339 | [Nested List Weight Sum](https://leetcode.com/problems/nested-list-weight-sum "嵌套列表权重和") 🔒 | [Go](../problems/nested-list-weight-sum) | Medium | | 340 | [Longest Substring with At Most K Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters "至多包含 K 个不同字符的最长子串") 🔒 | [Go](../problems/longest-substring-with-at-most-k-distinct-characters) | Medium | | 341 | [Flatten Nested List Iterator](https://leetcode.com/problems/flatten-nested-list-iterator "扁平化嵌套列表迭代器") | [Go](../problems/flatten-nested-list-iterator) | Medium | | 342 | [Power of Four](https://leetcode.com/problems/power-of-four "4的幂") | [Go](../problems/power-of-four) | Easy | diff --git a/readme/601-900.md b/readme/601-900.md index 4fc035be6..c33491502 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -134,11 +134,11 @@ LeetCode Problems' Solutions | 662 | [Maximum Width of Binary Tree](https://leetcode.com/problems/maximum-width-of-binary-tree "二叉树最大宽度") | [Go](../problems/maximum-width-of-binary-tree) | Medium | | 663 | [Equal Tree Partition](https://leetcode.com/problems/equal-tree-partition "均匀树划分") 🔒 | [Go](../problems/equal-tree-partition) | Medium | | 664 | [Strange Printer](https://leetcode.com/problems/strange-printer "奇怪的打印机") | [Go](../problems/strange-printer) | Hard | -| 665 | [Non-decreasing Array](https://leetcode.com/problems/non-decreasing-array "非递减数列") | [Go](../problems/non-decreasing-array) | Easy | +| 665 | [Non-decreasing Array](https://leetcode.com/problems/non-decreasing-array "非递减数列") | [Go](../problems/non-decreasing-array) | Medium | | 666 | [Path Sum IV](https://leetcode.com/problems/path-sum-iv "路径和 IV") 🔒 | [Go](../problems/path-sum-iv) | Medium | | 667 | [Beautiful Arrangement II](https://leetcode.com/problems/beautiful-arrangement-ii "优美的排列 II") | [Go](../problems/beautiful-arrangement-ii) | Medium | | 668 | [Kth Smallest Number in Multiplication Table](https://leetcode.com/problems/kth-smallest-number-in-multiplication-table "乘法表中第k小的数") | [Go](../problems/kth-smallest-number-in-multiplication-table) | Hard | -| 669 | [Trim a Binary Search Tree](https://leetcode.com/problems/trim-a-binary-search-tree "修剪二叉搜索树") | [Go](../problems/trim-a-binary-search-tree) | Easy | +| 669 | [Trim a Binary Search Tree](https://leetcode.com/problems/trim-a-binary-search-tree "修剪二叉搜索树") | [Go](../problems/trim-a-binary-search-tree) | Medium | | 670 | [Maximum Swap](https://leetcode.com/problems/maximum-swap "最大交换") | [Go](../problems/maximum-swap) | Medium | | 671 | [Second Minimum Node In a Binary Tree](https://leetcode.com/problems/second-minimum-node-in-a-binary-tree "二叉树中第二小的节点") | [Go](../problems/second-minimum-node-in-a-binary-tree) | Easy | | 672 | [Bulb Switcher II](https://leetcode.com/problems/bulb-switcher-ii "灯泡开关 Ⅱ") | [Go](../problems/bulb-switcher-ii) | Medium | diff --git a/readme/901-1200.md b/readme/901-1200.md index 63c050c12..dfd88444f 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -156,7 +156,7 @@ LeetCode Problems' Solutions | 984 | [String Without AAA or BBB](https://leetcode.com/problems/string-without-aaa-or-bbb "不含 AAA 或 BBB 的字符串") | [Go](../problems/string-without-aaa-or-bbb) | Medium | | 985 | [Sum of Even Numbers After Queries](https://leetcode.com/problems/sum-of-even-numbers-after-queries "查询后的偶数和") | [Go](../problems/sum-of-even-numbers-after-queries) | Easy | | 986 | [Interval List Intersections](https://leetcode.com/problems/interval-list-intersections "区间列表的交集") | [Go](../problems/interval-list-intersections) | Medium | -| 987 | [Vertical Order Traversal of a Binary Tree](https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree "二叉树的垂序遍历") | [Go](../problems/vertical-order-traversal-of-a-binary-tree) | Medium | +| 987 | [Vertical Order Traversal of a Binary Tree](https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree "二叉树的垂序遍历") | [Go](../problems/vertical-order-traversal-of-a-binary-tree) | Hard | | 988 | [Smallest String Starting From Leaf](https://leetcode.com/problems/smallest-string-starting-from-leaf "从叶结点开始的最小字符串") | [Go](../problems/smallest-string-starting-from-leaf) | Medium | | 989 | [Add to Array-Form of Integer](https://leetcode.com/problems/add-to-array-form-of-integer "数组形式的整数加法") | [Go](../problems/add-to-array-form-of-integer) | Easy | | 990 | [Satisfiability of Equality Equations](https://leetcode.com/problems/satisfiability-of-equality-equations "等式方程的可满足性") | [Go](../problems/satisfiability-of-equality-equations) | Medium | @@ -339,7 +339,7 @@ LeetCode Problems' Solutions | 1167 | [Minimum Cost to Connect Sticks](https://leetcode.com/problems/minimum-cost-to-connect-sticks "连接棒材的最低费用") 🔒 | [Go](../problems/minimum-cost-to-connect-sticks) | Medium | | 1168 | [Optimize Water Distribution in a Village](https://leetcode.com/problems/optimize-water-distribution-in-a-village "水资源分配优化") 🔒 | [Go](../problems/optimize-water-distribution-in-a-village) | Hard | | 1169 | [Invalid Transactions](https://leetcode.com/problems/invalid-transactions "查询无效交易") | [Go](../problems/invalid-transactions) | Medium | -| 1170 | [Compare Strings by Frequency of the Smallest Character](https://leetcode.com/problems/compare-strings-by-frequency-of-the-smallest-character "比较字符串最小字母出现频次") | [Go](../problems/compare-strings-by-frequency-of-the-smallest-character) | Easy | +| 1170 | [Compare Strings by Frequency of the Smallest Character](https://leetcode.com/problems/compare-strings-by-frequency-of-the-smallest-character "比较字符串最小字母出现频次") | [Go](../problems/compare-strings-by-frequency-of-the-smallest-character) | Medium | | 1171 | [Remove Zero Sum Consecutive Nodes from Linked List](https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list "从链表中删去总和值为零的连续节点") | [Go](../problems/remove-zero-sum-consecutive-nodes-from-linked-list) | Medium | | 1172 | [Dinner Plate Stacks](https://leetcode.com/problems/dinner-plate-stacks "餐盘栈") | [Go](../problems/dinner-plate-stacks) | Hard | | 1173 | [Immediate Food Delivery I](https://leetcode.com/problems/immediate-food-delivery-i "即时食物配送 I") 🔒 | [MySQL](../problems/immediate-food-delivery-i) | Easy | diff --git a/tag/README.md b/tag/README.md index 44eea5ddf..1da49de17 100644 --- a/tag/README.md +++ b/tag/README.md @@ -22,7 +22,7 @@ | 21 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | | 22 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | | 23 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | | 24 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 25 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | -| 27 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | | 28 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | +| 27 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | | 29 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 31 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 32 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | | 33 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 34 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | diff --git a/tag/array/README.md b/tag/array/README.md index 2aff55126..edac25008 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,8 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1738 | [找出第 K 大的异或坐标值](../../problems/find-kth-largest-xor-coordinate-value) | [[数组](../array/README.md)] | Medium | +| 1733 | [需要教语言的最少人数](../../problems/minimum-number-of-people-to-teach) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1732 | [找到最高海拔](../../problems/find-the-highest-altitude) | [[数组](../array/README.md)] | Easy | +| 1726 | [同积元组](../../problems/tuple-with-same-product) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1708 | [Largest Subarray Length K](../../problems/largest-subarray-length-k) 🔒 | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 1708 | [长度为 K 的最大子数组](../../problems/largest-subarray-length-k) 🔒 | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 1701 | [平均等待时间](../../problems/average-waiting-time) | [[数组](../array/README.md)] | Medium | | 1700 | [无法吃午餐的学生数量](../../problems/number-of-students-unable-to-eat-lunch) | [[数组](../array/README.md)] | Easy | | 1672 | [最富有客户的资产总量](../../problems/richest-customer-wealth) | [[数组](../array/README.md)] | Easy | @@ -62,7 +66,7 @@ | 1450 | [在既定时间做作业的学生人数](../../problems/number-of-students-doing-homework-at-a-given-time) | [[数组](../array/README.md)] | Easy | | 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1437 | [是否所有 1 都至少相隔 k 个元素](../../problems/check-if-all-1s-are-at-least-length-k-places-away) | [[数组](../array/README.md)] | Medium | +| 1437 | [是否所有 1 都至少相隔 k 个元素](../../problems/check-if-all-1s-are-at-least-length-k-places-away) | [[数组](../array/README.md)] | Easy | | 1431 | [拥有最多糖果的孩子](../../problems/kids-with-the-greatest-number-of-candies) | [[数组](../array/README.md)] | Easy | | 1428 | [至少有一个 1 的最左端列](../../problems/leftmost-column-with-at-least-a-one) 🔒 | [[数组](../array/README.md)] | Medium | | 1427 | [字符串的左右移](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | @@ -118,7 +122,7 @@ | 1184 | [公交站间的距离](../../problems/distance-between-bus-stops) | [[数组](../array/README.md)] | Easy | | 1177 | [构建回文串检测](../../problems/can-make-palindrome-from-substring) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 1176 | [健身计划评估](../../problems/diet-plan-performance) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Easy | -| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1169 | [查询无效交易](../../problems/invalid-transactions) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 1160 | [拼写单词](../../problems/find-words-that-can-be-formed-by-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | @@ -254,7 +258,7 @@ | 189 | [旋转数组](../../problems/rotate-array) | [[数组](../array/README.md)] | Medium | | 169 | [多数元素](../../problems/majority-element) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Easy | | 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 163 | [缺失的区间](../../problems/missing-ranges) 🔒 | [[数组](../array/README.md)] | Medium | +| 163 | [缺失的区间](../../problems/missing-ranges) 🔒 | [[数组](../array/README.md)] | Easy | | 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 154 | [寻找旋转排序数组中的最小值 II](../../problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -285,14 +289,14 @@ | 63 | [不同路径 II](../../problems/unique-paths-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 62 | [不同路径](../../problems/unique-paths) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 59 | [螺旋矩阵 II](../../problems/spiral-matrix-ii) | [[数组](../array/README.md)] | Medium | -| 57 | [插入区间](../../problems/insert-interval) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Hard | +| 57 | [插入区间](../../problems/insert-interval) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 56 | [合并区间](../../problems/merge-intervals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 55 | [跳跃游戏](../../problems/jump-game) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 54 | [螺旋矩阵](../../problems/spiral-matrix) | [[数组](../array/README.md)] | Medium | | 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 48 | [旋转图像](../../problems/rotate-image) | [[数组](../array/README.md)] | Medium | | 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Hard | -| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Hard | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 41 | [缺失的第一个正数](../../problems/first-missing-positive) | [[数组](../array/README.md)] | Hard | | 40 | [组合总和 II](../../problems/combination-sum-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 39 | [组合总和](../../problems/combination-sum) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 3d7addb8b..f25f28a74 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -48,12 +48,12 @@ | 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 306 | [累加数](../../problems/additive-number) | [[回溯算法](../backtracking/README.md)] | Medium | | 294 | [翻转游戏 II](../../problems/flip-game-ii) 🔒 | [[极小化极大](../minimax/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 291 | [单词规律 II](../../problems/word-pattern-ii) 🔒 | [[回溯算法](../backtracking/README.md)] | Hard | +| 291 | [单词规律 II](../../problems/word-pattern-ii) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | | 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | | 254 | [因子的组合](../../problems/factor-combinations) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | | 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 140 | [单词拆分 II](../../problems/word-break-ii) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/binary-indexed-tree/README.md b/tag/binary-indexed-tree/README.md index c899b2671..0beece97f 100644 --- a/tag/binary-indexed-tree/README.md +++ b/tag/binary-indexed-tree/README.md @@ -9,3 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 308 | [二维区域和检索 - 可变](../../problems/range-sum-query-2d-mutable) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Hard | +| 307 | [区域和检索 - 数组可修改](../../problems/range-sum-query-mutable) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Medium | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/binary-search-tree/README.md b/tag/binary-search-tree/README.md index 43b103e11..0d508d4e1 100644 --- a/tag/binary-search-tree/README.md +++ b/tag/binary-search-tree/README.md @@ -9,3 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1382 | [将二叉搜索树变平衡](../../problems/balance-a-binary-search-tree) | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | +| 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | +| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 6379fffed..31963f6d8 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,8 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1739 | [放置盒子](../../problems/building-boxes) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | | 1642 | [可以到达的最远建筑](../../problems/furthest-building-you-can-reach) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -27,12 +28,13 @@ | 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1283 | [使结果不超过阈值的最小除数](../../problems/find-the-smallest-divisor-given-a-threshold) | [[二分查找](../binary-search/README.md)] | Medium | -| 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1231 | [分享巧克力](../../problems/divide-chocolate) 🔒 | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1182 | [与目标颜色间的最短距离](../../problems/shortest-distance-to-target-color) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | +| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1150 | [检查一个数是否在数组中占绝大多数](../../problems/check-if-a-number-is-majority-element-in-a-sorted-array) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 1111 | [有效括号的嵌套深度](../../problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 88d28a8bc..864999c74 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1734 | [解码异或后的排列](../../problems/decode-xored-permutation) | [[位运算](../bit-manipulation/README.md)] | Medium | | 1720 | [解码异或后的数组](../../problems/decode-xored-array) | [[位运算](../bit-manipulation/README.md)] | Easy | | 1707 | [与数组中元素的最大异或值](../../problems/maximum-xor-with-an-element-from-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Hard | | 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index e5a4936b5..97922c717 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,81 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1654 | [到家的最少跳跃次数](../../problems/minimum-jumps-to-reach-home) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1625 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1345 | [跳跃游戏 IV](../../problems/jump-game-iv) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1298 | [你能从盒子里获得的最大糖果数](../../problems/maximum-candies-you-can-get-from-boxes) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1293 | [网格中的最短路径](../../problems/shortest-path-in-a-grid-with-obstacles-elimination) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1284 | [转化为全零矩阵的最少反转次数](../../problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1263 | [推箱子](../../problems/minimum-moves-to-move-a-box-to-their-target-location) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1242 | [多线程网页爬虫](../../problems/web-crawler-multithreaded) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1236 | [网络爬虫](../../problems/web-crawler) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1210 | [穿过迷宫的最少移动次数](../../problems/minimum-moves-to-reach-target-with-rotations) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1197 | [进击的骑士](../../problems/minimum-knight-moves) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1091 | [二进制矩阵中的最短路径](../../problems/shortest-path-in-binary-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 994 | [腐烂的橘子](../../problems/rotting-oranges) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[极小化极大](../minimax/README.md)] | Hard | -| 909 | [蛇梯棋](../../problems/snakes-and-ladders) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 864 | [获取所有钥匙的最短路径](../../problems/shortest-path-to-get-all-keys) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 854 | [相似度为 K 的字符串](../../problems/k-similar-strings) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Hard | -| 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 773 | [滑动谜题](../../problems/sliding-puzzle) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 675 | [为高尔夫比赛砍树](../../problems/cut-off-trees-for-golf-event) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 559 | [N 叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 542 | [01 矩阵](../../problems/01-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 529 | [扫雷游戏](../../problems/minesweeper) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 505 | [迷宫 II](../../problems/the-maze-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 499 | [迷宫 III](../../problems/the-maze-iii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 490 | [迷宫](../../problems/the-maze) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 429 | [N 叉树的层序遍历](../../problems/n-ary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 417 | [太平洋大西洋水流问题](../../problems/pacific-atlantic-water-flow) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 317 | [离建筑物最近的距离](../../problems/shortest-distance-from-all-buildings) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 310 | [最小高度树](../../problems/minimum-height-trees) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 301 | [删除无效的括号](../../problems/remove-invalid-parentheses) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 286 | [墙与门](../../problems/walls-and-gates) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 127 | [单词接龙](../../problems/word-ladder) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 102 | [二叉树的层序遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 61e398909..9deef5ef0 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1740 | [Find Distance in a Binary Tree](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 1730 | [Shortest Path to Get Food](../../problems/shortest-path-to-get-food) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[贪心算法](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | @@ -121,7 +123,7 @@ | 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 366 | [寻找二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 364 | [加权嵌套序列和 II](../../problems/nested-list-weight-sum-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 339 | [嵌套列表权重和](../../problems/nested-list-weight-sum) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 339 | [嵌套列表权重和](../../problems/nested-list-weight-sum) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | @@ -130,6 +132,7 @@ | 301 | [删除无效的括号](../../problems/remove-invalid-parentheses) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | | 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | | 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index 4a85371d3..1bbe3ca62 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -62,7 +62,7 @@ | 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | | 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium | | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index cce163a3a..792ed5487 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1728 | [猫和老鼠 II](../../problems/cat-and-mouse-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1724 | [Checking Existence of Edge Length Limited Paths II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1706 | [球会落何处](../../problems/where-will-the-ball-fall) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1692 | [计算分配糖果的不同方式](../../problems/count-ways-to-distribute-candies) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1691 | [堆叠长方体的最大高度](../../problems/maximum-height-by-stacking-cuboids) | [[排序](../sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -87,7 +89,7 @@ | 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1223 | [掷骰子模拟](../../problems/dice-roll-simulation) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1220 | [统计元音字母序列的数目](../../problems/count-vowels-permutation) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1216 | [验证回文字符串 III](../../problems/valid-palindrome-iii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1199 | [建造街区的最短时间](../../problems/minimum-time-to-build-blocks) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1191 | [K 次串联后最大子数组之和](../../problems/k-concatenation-maximum-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -221,7 +223,7 @@ | 256 | [粉刷房子](../../problems/paint-house) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | | 221 | [最大正方形](../../problems/maximal-square) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 213 | [打家劫舍 II](../../problems/house-robber-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 198 | [打家劫舍](../../problems/house-robber) | [[动态规划](../dynamic-programming/README.md)] | Easy | +| 198 | [打家劫舍](../../problems/house-robber) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 188 | [买卖股票的最佳时机 IV](../../problems/best-time-to-buy-and-sell-stock-iv) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 174 | [地下城游戏](../../problems/dungeon-game) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 152 | [乘积最大子数组](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -246,6 +248,7 @@ | 62 | [不同路径](../../problems/unique-paths) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 5 | [最长回文子串](../../problems/longest-palindromic-substring) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/graph/README.md b/tag/graph/README.md index ba9a7fc00..986d03a27 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1730 | [Shortest Path to Get Food](../../problems/shortest-path-to-get-food) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1724 | [Checking Existence of Edge Length Limited Paths II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] | Hard | | 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1615 | [最大网络秩](../../problems/maximal-network-rank) | [[图](../graph/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 87df25ab7..a9e90fd80 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,12 +9,17 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1737 | [满足三条件之一需改变的最少字符数](../../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1736 | [替换隐藏数字得到的最晚时间](../../problems/latest-time-by-replacing-hidden-digits) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | +| 1733 | [需要教语言的最少人数](../../problems/minimum-number-of-people-to-teach) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1727 | [重新排列后的最大子矩阵](../../problems/largest-submatrix-with-rearrangements) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 1725 | [可以形成最大正方形的矩形数目](../../problems/number-of-rectangles-that-can-form-the-largest-square) | [[贪心算法](../greedy/README.md)] | Easy | | 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[贪心算法](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 1717 | [删除子字符串的最大得分](../../problems/maximum-score-from-removing-substrings) | [[贪心算法](../greedy/README.md)] | Medium | | 1716 | [计算力扣银行的钱](../../problems/calculate-money-in-leetcode-bank) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Easy | | 1713 | [得到子序列的最少操作次数](../../problems/minimum-operations-to-make-a-subsequence) | [[贪心算法](../greedy/README.md)] | Hard | | 1710 | [卡车上的最大单元数](../../problems/maximum-units-on-a-truck) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | -| 1708 | [Largest Subarray Length K](../../problems/largest-subarray-length-k) 🔒 | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 1708 | [长度为 K 的最大子数组](../../problems/largest-subarray-length-k) 🔒 | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 1705 | [吃苹果的最大数目](../../problems/maximum-number-of-eaten-apples) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | | 1702 | [修改后的最大二进制字符串](../../problems/maximum-binary-string-after-change) | [[贪心算法](../greedy/README.md)] | Medium | | 1689 | [十-二进制数的最少数目](../../problems/partitioning-into-minimum-number-of-deci-binary-numbers) | [[贪心算法](../greedy/README.md)] | Medium | @@ -22,11 +27,11 @@ | 1685 | [有序数组中差绝对值之和](../../problems/sum-of-absolute-differences-in-a-sorted-array) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | | 1681 | [最小不兼容性](../../problems/minimum-incompatibility) | [[贪心算法](../greedy/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1674 | [使数组互补的最少操作次数](../../problems/minimum-moves-to-make-array-complementary) | [[贪心算法](../greedy/README.md)] | Medium | -| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | | 1665 | [完成所有任务的最少初始能量](../../problems/minimum-initial-energy-to-finish-tasks) | [[贪心算法](../greedy/README.md)] | Hard | | 1664 | [生成平衡数组的方案数](../../problems/ways-to-make-a-fair-array) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1663 | [具有给定数值的最小字符串](../../problems/smallest-string-with-a-given-numeric-value) | [[贪心算法](../greedy/README.md)] | Medium | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1657 | [确定两个字符串是否接近](../../problems/determine-if-two-strings-are-close) | [[贪心算法](../greedy/README.md)] | Medium | | 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 00cd2fdf4..79ef05332 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1726 | [同积元组](../../problems/tuple-with-same-product) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1679 | [K 和数对的最大数目](../../problems/max-number-of-k-sum-pairs) | [[哈希表](../hash-table/README.md)] | Medium | | 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | @@ -29,6 +30,7 @@ | 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1224 | [最大相等频率](../../problems/maximum-equal-frequency) | [[哈希表](../hash-table/README.md)] | Hard | +| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 1207 | [独一无二的出现次数](../../problems/unique-number-of-occurrences) | [[哈希表](../hash-table/README.md)] | Easy | | 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/heap/README.md b/tag/heap/README.md index 885e5e859..4bf8bcc92 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -11,12 +11,13 @@ | :-: | - | - | :-: | | 1705 | [吃苹果的最大数目](../../problems/maximum-number-of-eaten-apples) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | | 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | | 1642 | [可以到达的最远建筑](../../problems/furthest-building-you-can-reach) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1439 | [有序矩阵中的第 k 个最小数组和](../../problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | [[堆](../heap/README.md)] | Hard | | 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] | Medium | | 1046 | [最后一块石头的重量](../../problems/last-stone-weight) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Easy | | 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 882 | [细分图中的可到达结点](../../problems/reachable-nodes-in-subdivided-graph) | [[堆](../heap/README.md)] | Hard | +| 882 | [细分图中的可到达结点](../../problems/reachable-nodes-in-subdivided-graph) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 871 | [最低加油次数](../../problems/minimum-number-of-refueling-stops) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 864 | [获取所有钥匙的最短路径](../../problems/shortest-path-to-get-all-keys) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[堆](../heap/README.md)] | Hard | diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md index 592ea3e0f..932db1472 100644 --- a/tag/line-sweep/README.md +++ b/tag/line-sweep/README.md @@ -9,3 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | +| 391 | [完美矩形](../../problems/perfect-rectangle) | [[Line Sweep](../line-sweep/README.md)] | Hard | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index a34ab29f8..8103f6eff 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -50,5 +50,5 @@ | 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | | 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Easy | -| 19 | [删除链表的倒数第N个节点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 19 | [删除链表的倒数第 N 个结点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index c58dcdb99..841dc593e 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1739 | [放置盒子](../../problems/building-boxes) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1735 | [生成乘积数组的方案数](../../problems/count-ways-to-make-array-with-product) | [[数学](../math/README.md)] | Hard | | 1716 | [计算力扣银行的钱](../../problems/calculate-money-in-leetcode-bank) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Easy | | 1685 | [有序数组中差绝对值之和](../../problems/sum-of-absolute-differences-in-a-sorted-array) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | | 1680 | [连接连续二进制数字](../../problems/concatenation-of-consecutive-binary-numbers) | [[数学](../math/README.md)] | Medium | @@ -48,12 +50,12 @@ | 1253 | [重构 2 行二进制矩阵](../../problems/reconstruct-a-2-row-binary-matrix) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | | 1250 | [检查「好数组」](../../problems/check-if-it-is-a-good-array) | [[数学](../math/README.md)] | Hard | | 1238 | [循环码排列](../../problems/circular-permutation-in-binary-representation) | [[数学](../math/README.md)] | Medium | -| 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1230 | [抛掷硬币](../../problems/toss-strange-coins) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1228 | [等差数列中缺失的数字](../../problems/missing-number-in-arithmetic-progression) 🔒 | [[数学](../math/README.md)] | Easy | | 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1217 | [玩筹码](../../problems/minimum-cost-to-move-chips-to-the-same-position) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1199 | [建造街区的最短时间](../../problems/minimum-time-to-build-blocks) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/memoization/README.md b/tag/memoization/README.md index f418d566c..2c6a5dffd 100644 --- a/tag/memoization/README.md +++ b/tag/memoization/README.md @@ -9,3 +9,4 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index 85faedb8e..52afd5989 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -9,17 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | -| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 855 | [考场就座](../../problems/exam-room) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 846 | [一手顺子](../../problems/hand-of-straights) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 731 | [我的日程安排表 II](../../problems/my-calendar-ii) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 683 | [K 个关闭的灯泡](../../problems/k-empty-slots) 🔒 | [[Ordered Map](../ordered-map/README.md)] | Hard | -| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index 16db88027..8922feba8 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -9,12 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 933 | [最近的请求次数](../../problems/number-of-recent-calls) | [[队列](../queue/README.md)] | Easy | -| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | -| 582 | [杀死进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | -| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 614bd16a1..f17ca04aa 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -27,6 +27,7 @@ | 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/rejection-sampling/README.md b/tag/rejection-sampling/README.md index 8622c93e1..fc2d396f2 100644 --- a/tag/rejection-sampling/README.md +++ b/tag/rejection-sampling/README.md @@ -9,3 +9,5 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | +| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | diff --git a/tag/reservoir-sampling/README.md b/tag/reservoir-sampling/README.md index 7d9ca74cc..1fc516eb3 100644 --- a/tag/reservoir-sampling/README.md +++ b/tag/reservoir-sampling/README.md @@ -9,3 +9,5 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 398 | [随机数索引](../../problems/random-pick-index) | [[蓄水池抽样](../reservoir-sampling/README.md)] | Medium | +| 382 | [链表随机节点](../../problems/linked-list-random-node) | [[蓄水池抽样](../reservoir-sampling/README.md)] | Medium | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index b34d04e3d..bdf264168 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -9,19 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[线段树](../segment-tree/README.md)] | Hard | -| 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | -| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | -| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 308 | [二维区域和检索 - 可变](../../problems/range-sum-query-2d-mutable) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Hard | -| 307 | [区域和检索 - 数组可修改](../../problems/range-sum-query-mutable) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Medium | -| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index 101291dc2..56d607bc2 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[排序](../sort/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index b691d2565..3ae174849 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1727 | [重新排列后的最大子矩阵](../../problems/largest-submatrix-with-rearrangements) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | | 1710 | [卡车上的最大单元数](../../problems/maximum-units-on-a-truck) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | | 1697 | [检查边长度限制的路径是否存在](../../problems/checking-existence-of-edge-length-limited-paths) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] | Hard | | 1691 | [堆叠长方体的最大高度](../../problems/maximum-height-by-stacking-cuboids) | [[排序](../sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -43,6 +44,7 @@ | 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | | 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | | 1183 | [矩阵中 1 的最大数量](../../problems/maximum-number-of-ones) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | | 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1122 | [数组的相对排序](../../problems/relative-sort-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | @@ -80,5 +82,5 @@ | 148 | [排序链表](../../problems/sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | | 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | | 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 57 | [插入区间](../../problems/insert-interval) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Hard | +| 57 | [插入区间](../../problems/insert-interval) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 56 | [合并区间](../../problems/merge-intervals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/stack/README.md b/tag/stack/README.md index 9aabcd33e..238b0b4da 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -10,7 +10,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1703 | [得到连续 K 个 1 的最少相邻交换次数](../../problems/minimum-adjacent-swaps-for-k-consecutive-ones) | [[栈](../stack/README.md)] | Hard | -| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | | 1598 | [文件夹操作日志搜集器](../../problems/crawler-log-folder) | [[栈](../stack/README.md)] | Easy | | 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | | 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | @@ -71,5 +71,5 @@ | 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 84 | [柱状图中最大的矩形](../../problems/largest-rectangle-in-histogram) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Hard | | 71 | [简化路径](../../problems/simplify-path) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Hard | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 20 | [有效的括号](../../problems/valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | diff --git a/tag/string/README.md b/tag/string/README.md index 80ca3dd45..cd7990fb5 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1737 | [满足三条件之一需改变的最少字符数](../../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1736 | [替换隐藏数字得到的最晚时间](../../problems/latest-time-by-replacing-hidden-digits) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | | 1704 | [判断字符串的两半是否相似](../../problems/determine-if-string-halves-are-alike) | [[字符串](../string/README.md)] | Easy | | 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | | 1694 | [重新格式化电话号码](../../problems/reformat-phone-number) | [[字符串](../string/README.md)] | Easy | @@ -83,7 +85,7 @@ | 1181 | [前后拼接](../../problems/before-and-after-puzzle) 🔒 | [[字符串](../string/README.md)] | Medium | | 1180 | [统计只含单一字母的子串](../../problems/count-substrings-with-only-one-distinct-letter) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 1177 | [构建回文串检测](../../problems/can-make-palindrome-from-substring) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | -| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1169 | [查询无效交易](../../problems/invalid-transactions) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 1165 | [单行键盘](../../problems/single-row-keyboard) 🔒 | [[字符串](../string/README.md)] | Easy | | 1163 | [按字典序排在最后的子串](../../problems/last-substring-in-lexicographical-order) | [[字符串](../string/README.md)] | Hard | diff --git a/tag/tags.json b/tag/tags.json index dd04f1731..4ca263579 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -129,16 +129,16 @@ "Slug": "ordered-map", "TranslatedName": "Ordered Map" }, - { - "Name": "Geometry", - "Slug": "geometry", - "TranslatedName": "几何" - }, { "Name": "Queue", "Slug": "queue", "TranslatedName": "队列" }, + { + "Name": "Geometry", + "Slug": "geometry", + "TranslatedName": "几何" + }, { "Name": "Minimax", "Slug": "minimax", diff --git a/tag/tree/README.md b/tag/tree/README.md index a9e1b7c95..c99ee46d3 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1740 | [Find Distance in a Binary Tree](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] | Hard | | 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | @@ -83,7 +84,7 @@ | 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 684 | [冗余连接](../../problems/redundant-connection) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 671 | [二叉树中第二小的节点](../../problems/second-minimum-node-in-a-binary-tree) | [[树](../tree/README.md)] | Easy | -| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] | Easy | +| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 666 | [路径和 IV](../../problems/path-sum-iv) 🔒 | [[树](../tree/README.md)] | Medium | | 663 | [均匀树划分](../../problems/equal-tree-partition) 🔒 | [[树](../tree/README.md)] | Medium | | 662 | [二叉树最大宽度](../../problems/maximum-width-of-binary-tree) | [[树](../tree/README.md)] | Medium | diff --git a/tag/trie/README.md b/tag/trie/README.md index 0e2a77cce..1269938dc 100644 --- a/tag/trie/README.md +++ b/tag/trie/README.md @@ -27,5 +27,5 @@ | 421 | [数组中两个数的最大异或值](../../problems/maximum-xor-of-two-numbers-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Medium | | 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 71fdc75ca..e14c8fe4e 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -13,12 +13,13 @@ | 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1695 | [删除子数组的最大得分](../../problems/maximum-erasure-value) | [[双指针](../two-pointers/README.md)] | Medium | | 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard | | 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1248 | [统计「优美子数组」](../../problems/count-number-of-nice-subarrays) | [[双指针](../two-pointers/README.md)] | Medium | | 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | | 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | @@ -69,12 +70,12 @@ | 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 61 | [旋转链表](../../problems/rotate-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Hard | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | | 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 27 | [移除元素](../../problems/remove-element) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 26 | [删除排序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 19 | [删除链表的倒数第N个节点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 19 | [删除链表的倒数第 N 个结点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index de255cc71..bf4d14937 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1724 | [Checking Existence of Edge Length Limited Paths II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[贪心算法](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 1697 | [检查边长度限制的路径是否存在](../../problems/checking-existence-of-edge-length-limited-paths) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] | Hard | | 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] | Hard | From 521a6c19dd5106371c4eabea29831449c495f3f7 Mon Sep 17 00:00:00 2001 From: Shuo Date: Sat, 6 Feb 2021 17:52:02 +0800 Subject: [PATCH 118/145] A: new --- README.md | 29 +- problems/asteroid-collision/README.md | 2 +- .../biggest-window-between-visits/README.md | 2 +- .../README.md | 3 + problems/break-a-palindrome/README.md | 6 +- problems/bus-routes/README.md | 36 ++- .../README.md | 84 +++++ .../README.md | 2 +- problems/concatenated-words/README.md | 4 +- .../convert-bst-to-greater-tree/README.md | 3 + .../copy-list-with-random-pointer/README.md | 20 +- problems/count-apples-and-oranges/README.md | 2 +- problems/course-schedule-iv/README.md | 2 +- problems/course-schedule/README.md | 25 +- problems/decode-ways-ii/README.md | 79 +++-- problems/decode-ways/README.md | 18 +- problems/delete-and-earn/README.md | 35 +- .../README.md | 74 ++--- .../README.md | 61 ++-- .../delete-columns-to-make-sorted/README.md | 45 ++- problems/fair-candy-swap/README.md | 2 +- .../find-distance-in-a-binary-tree/README.md | 4 +- problems/find-followers-count/README.md | 2 +- problems/find-pivot-index/README.md | 29 +- .../find-the-shortest-superstring/README.md | 41 +-- .../README.md | 14 + .../mysql_schemas.sql | 7 + .../README.md | 61 ++-- .../README.md | 2 +- problems/hopper-company-queries-i/README.md | 2 +- problems/is-subsequence/README.md | 17 +- .../README.md | 42 ++- .../README.md | 52 ++- problems/leetflex-banned-accounts/README.md | 14 + .../mysql_schemas.sql | 10 + .../README.md | 12 +- .../longest-palindromic-substring/README.md | 2 +- problems/making-a-large-island/README.md | 28 +- .../README.md | 72 +++++ .../README.md | 15 +- .../README.md | 33 ++ problems/merge-two-binary-trees/README.md | 40 +-- .../README.md | 39 ++- problems/minimum-falling-path-sum/README.md | 42 ++- problems/minimum-size-subarray-sum/README.md | 36 ++- .../README.md | 2 +- .../README.md | 9 +- problems/paint-house-iii/README.md | 2 +- problems/palindrome-partitioning-iv/README.md | 56 ++++ problems/partition-list/README.md | 2 +- problems/powerful-integers/README.md | 45 ++- .../README.md | 19 +- problems/reorder-data-in-log-files/README.md | 25 +- .../README.md | 72 +++++ .../README.md | 26 +- problems/shortest-path-to-get-food/README.md | 2 +- problems/similar-string-groups/README.md | 5 +- problems/simplify-path/README.md | 17 +- .../README.md | 9 +- .../README.md | 2 +- problems/tallest-billboard/README.md | 36 +-- .../README.md | 14 +- problems/trips-and-users/README.md | 22 +- .../README.md | 43 ++- readme/601-900.md | 2 +- readme/901-1200.md | 2 +- tag/array/README.md | 303 ------------------ tag/backtracking/README.md | 66 ---- tag/binary-search-tree/README.md | 3 +- tag/breadth-first-search/README.md | 84 +++++ tag/depth-first-search/README.md | 150 --------- tag/dynamic-programming/README.md | 7 +- tag/graph/README.md | 51 --- tag/greedy/README.md | 1 + tag/hash-table/README.md | 139 -------- tag/math/README.md | 197 ------------ tag/ordered-map/README.md | 14 + tag/queue/README.md | 10 + tag/random/README.md | 6 + tag/recursion/README.md | 4 +- tag/string/README.md | 215 ------------- tag/topological-sort/README.md | 6 + tag/tree/README.md | 9 +- tag/union-find/README.md | 2 +- 84 files changed, 1153 insertions(+), 1676 deletions(-) create mode 100644 problems/can-you-eat-your-favorite-candy-on-your-favorite-day/README.md create mode 100644 problems/find-total-time-spent-by-each-employee/README.md create mode 100644 problems/find-total-time-spent-by-each-employee/mysql_schemas.sql create mode 100644 problems/leetflex-banned-accounts/README.md create mode 100644 problems/leetflex-banned-accounts/mysql_schemas.sql create mode 100644 problems/maximum-number-of-balls-in-a-box/README.md create mode 100644 problems/maximum-subarray-sum-after-one-operation/README.md create mode 100644 problems/palindrome-partitioning-iv/README.md create mode 100644 problems/restore-the-array-from-adjacent-pairs/README.md diff --git a/README.md b/README.md index 49353f20e..fb78fb408 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,14 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | -| 1740 | [Find Distance in a Binary Tree](https://leetcode.com/problems/find-distance-in-a-binary-tree) 🔒 | [Go](problems/find-distance-in-a-binary-tree) | Easy | +| 1747 | [Leetflex Banned Accounts](https://leetcode.com/problems/leetflex-banned-accounts) 🔒 | [MySQL](problems/leetflex-banned-accounts) | Medium | +| 1746 | [Maximum Subarray Sum After One Operation](https://leetcode.com/problems/maximum-subarray-sum-after-one-operation) 🔒 | [Go](problems/maximum-subarray-sum-after-one-operation) | Medium | +| 1745 | [Palindrome Partitioning IV](https://leetcode.com/problems/palindrome-partitioning-iv "回文串分割 IV") | [Go](problems/palindrome-partitioning-iv) | Hard | +| 1744 | [Can You Eat Your Favorite Candy on Your Favorite Day?](https://leetcode.com/problems/can-you-eat-your-favorite-candy-on-your-favorite-day "你能在你最喜欢的那天吃到你最喜欢的糖果吗?") | [Go](problems/can-you-eat-your-favorite-candy-on-your-favorite-day) | Medium | +| 1743 | [Restore the Array From Adjacent Pairs](https://leetcode.com/problems/restore-the-array-from-adjacent-pairs "从相邻元素对还原数组") | [Go](problems/restore-the-array-from-adjacent-pairs) | Medium | +| 1742 | [Maximum Number of Balls in a Box](https://leetcode.com/problems/maximum-number-of-balls-in-a-box "盒子中小球的最大数量") | [Go](problems/maximum-number-of-balls-in-a-box) | Easy | +| 1741 | [Find Total Time Spent by Each Employee](https://leetcode.com/problems/find-total-time-spent-by-each-employee) 🔒 | [MySQL](problems/find-total-time-spent-by-each-employee) | Easy | +| 1740 | [Find Distance in a Binary Tree](https://leetcode.com/problems/find-distance-in-a-binary-tree "找到二叉树中的距离") 🔒 | [Go](problems/find-distance-in-a-binary-tree) | Medium | | 1739 | [Building Boxes](https://leetcode.com/problems/building-boxes "放置盒子") | [Go](problems/building-boxes) | Hard | | 1738 | [Find Kth Largest XOR Coordinate Value](https://leetcode.com/problems/find-kth-largest-xor-coordinate-value "找出第 K 大的异或坐标值") | [Go](problems/find-kth-largest-xor-coordinate-value) | Medium | | 1737 | [Change Minimum Characters to Satisfy One of Three Conditions](https://leetcode.com/problems/change-minimum-characters-to-satisfy-one-of-three-conditions "满足三条件之一需改变的最少字符数") | [Go](problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | Medium | @@ -80,13 +87,13 @@ LeetCode Problems' Solutions | 1733 | [Minimum Number of People to Teach](https://leetcode.com/problems/minimum-number-of-people-to-teach "需要教语言的最少人数") | [Go](problems/minimum-number-of-people-to-teach) | Medium | | 1732 | [Find the Highest Altitude](https://leetcode.com/problems/find-the-highest-altitude "找到最高海拔") | [Go](problems/find-the-highest-altitude) | Easy | | 1731 | [The Number of Employees Which Report to Each Employee](https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee) 🔒 | [MySQL](problems/the-number-of-employees-which-report-to-each-employee) | Easy | -| 1730 | [Shortest Path to Get Food](https://leetcode.com/problems/shortest-path-to-get-food) 🔒 | [Go](problems/shortest-path-to-get-food) | Medium | -| 1729 | [Find Followers Count](https://leetcode.com/problems/find-followers-count) 🔒 | [MySQL](problems/find-followers-count) | Easy | +| 1730 | [Shortest Path to Get Food](https://leetcode.com/problems/shortest-path-to-get-food "获取食物的最短路径") 🔒 | [Go](problems/shortest-path-to-get-food) | Medium | +| 1729 | [Find Followers Count](https://leetcode.com/problems/find-followers-count "求关注者的数量") 🔒 | [MySQL](problems/find-followers-count) | Easy | | 1728 | [Cat and Mouse II](https://leetcode.com/problems/cat-and-mouse-ii "猫和老鼠 II") | [Go](problems/cat-and-mouse-ii) | Hard | | 1727 | [Largest Submatrix With Rearrangements](https://leetcode.com/problems/largest-submatrix-with-rearrangements "重新排列后的最大子矩阵") | [Go](problems/largest-submatrix-with-rearrangements) | Medium | | 1726 | [Tuple with Same Product](https://leetcode.com/problems/tuple-with-same-product "同积元组") | [Go](problems/tuple-with-same-product) | Medium | | 1725 | [Number Of Rectangles That Can Form The Largest Square](https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square "可以形成最大正方形的矩形数目") | [Go](problems/number-of-rectangles-that-can-form-the-largest-square) | Easy | -| 1724 | [Checking Existence of Edge Length Limited Paths II](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [Go](problems/checking-existence-of-edge-length-limited-paths-ii) | Hard | +| 1724 | [Checking Existence of Edge Length Limited Paths II](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths-ii "检查边长度限制的路径是否存在 II") 🔒 | [Go](problems/checking-existence-of-edge-length-limited-paths-ii) | Hard | | 1723 | [Find Minimum Time to Finish All Jobs](https://leetcode.com/problems/find-minimum-time-to-finish-all-jobs "完成所有工作的最短时间") | [Go](problems/find-minimum-time-to-finish-all-jobs) | Hard | | 1722 | [Minimize Hamming Distance After Swap Operations](https://leetcode.com/problems/minimize-hamming-distance-after-swap-operations "执行交换操作后的最小汉明距离") | [Go](problems/minimize-hamming-distance-after-swap-operations) | Medium | | 1721 | [Swapping Nodes in a Linked List](https://leetcode.com/problems/swapping-nodes-in-a-linked-list "交换链表中的节点") | [Go](problems/swapping-nodes-in-a-linked-list) | Medium | @@ -95,13 +102,13 @@ LeetCode Problems' Solutions | 1718 | [Construct the Lexicographically Largest Valid Sequence](https://leetcode.com/problems/construct-the-lexicographically-largest-valid-sequence "构建字典序最大的可行序列") | [Go](problems/construct-the-lexicographically-largest-valid-sequence) | Medium | | 1717 | [Maximum Score From Removing Substrings](https://leetcode.com/problems/maximum-score-from-removing-substrings "删除子字符串的最大得分") | [Go](problems/maximum-score-from-removing-substrings) | Medium | | 1716 | [Calculate Money in Leetcode Bank](https://leetcode.com/problems/calculate-money-in-leetcode-bank "计算力扣银行的钱") | [Go](problems/calculate-money-in-leetcode-bank) | Easy | -| 1715 | [Count Apples and Oranges](https://leetcode.com/problems/count-apples-and-oranges) 🔒 | [MySQL](problems/count-apples-and-oranges) | Medium | -| 1714 | [Sum Of Special Evenly-Spaced Elements In Array](https://leetcode.com/problems/sum-of-special-evenly-spaced-elements-in-array) 🔒 | [Go](problems/sum-of-special-evenly-spaced-elements-in-array) | Hard | +| 1715 | [Count Apples and Oranges](https://leetcode.com/problems/count-apples-and-oranges "苹果和橘子的个数") 🔒 | [MySQL](problems/count-apples-and-oranges) | Medium | +| 1714 | [Sum Of Special Evenly-Spaced Elements In Array](https://leetcode.com/problems/sum-of-special-evenly-spaced-elements-in-array "数组中特殊等间距元素的和") 🔒 | [Go](problems/sum-of-special-evenly-spaced-elements-in-array) | Hard | | 1713 | [Minimum Operations to Make a Subsequence](https://leetcode.com/problems/minimum-operations-to-make-a-subsequence "得到子序列的最少操作次数") | [Go](problems/minimum-operations-to-make-a-subsequence) | Hard | | 1712 | [Ways to Split Array Into Three Subarrays](https://leetcode.com/problems/ways-to-split-array-into-three-subarrays "将数组分成三个子数组的方案数") | [Go](problems/ways-to-split-array-into-three-subarrays) | Medium | | 1711 | [Count Good Meals](https://leetcode.com/problems/count-good-meals "大餐计数") | [Go](problems/count-good-meals) | Medium | | 1710 | [Maximum Units on a Truck](https://leetcode.com/problems/maximum-units-on-a-truck "卡车上的最大单元数") | [Go](problems/maximum-units-on-a-truck) | Easy | -| 1709 | [Biggest Window Between Visits](https://leetcode.com/problems/biggest-window-between-visits) 🔒 | [MySQL](problems/biggest-window-between-visits) | Medium | +| 1709 | [Biggest Window Between Visits](https://leetcode.com/problems/biggest-window-between-visits "访问日期之间最大的空档期") 🔒 | [MySQL](problems/biggest-window-between-visits) | Medium | | 1708 | [Largest Subarray Length K](https://leetcode.com/problems/largest-subarray-length-k "长度为 K 的最大子数组") 🔒 | [Go](problems/largest-subarray-length-k) | Easy | | 1707 | [Maximum XOR With an Element From Array](https://leetcode.com/problems/maximum-xor-with-an-element-from-array "与数组中元素的最大异或值") | [Go](problems/maximum-xor-with-an-element-from-array) | Hard | | 1706 | [Where Will the Ball Fall](https://leetcode.com/problems/where-will-the-ball-fall "球会落何处") | [Go](problems/where-will-the-ball-fall) | Medium | @@ -111,7 +118,7 @@ LeetCode Problems' Solutions | 1702 | [Maximum Binary String After Change](https://leetcode.com/problems/maximum-binary-string-after-change "修改后的最大二进制字符串") | [Go](problems/maximum-binary-string-after-change) | Medium | | 1701 | [Average Waiting Time](https://leetcode.com/problems/average-waiting-time "平均等待时间") | [Go](problems/average-waiting-time) | Medium | | 1700 | [Number of Students Unable to Eat Lunch](https://leetcode.com/problems/number-of-students-unable-to-eat-lunch "无法吃午餐的学生数量") | [Go](problems/number-of-students-unable-to-eat-lunch) | Easy | -| 1699 | [Number of Calls Between Two Persons](https://leetcode.com/problems/number-of-calls-between-two-persons) 🔒 | [MySQL](problems/number-of-calls-between-two-persons) | Medium | +| 1699 | [Number of Calls Between Two Persons](https://leetcode.com/problems/number-of-calls-between-two-persons "两人之间的通话次数") 🔒 | [MySQL](problems/number-of-calls-between-two-persons) | Medium | | 1698 | [Number of Distinct Substrings in a String](https://leetcode.com/problems/number-of-distinct-substrings-in-a-string "字符串的不同子字符串个数") 🔒 | [Go](problems/number-of-distinct-substrings-in-a-string) | Medium | | 1697 | [Checking Existence of Edge Length Limited Paths](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths "检查边长度限制的路径是否存在") | [Go](problems/checking-existence-of-edge-length-limited-paths) | Hard | | 1696 | [Jump Game VI](https://leetcode.com/problems/jump-game-vi "跳跃游戏 VI") | [Go](problems/jump-game-vi) | Medium | @@ -175,7 +182,7 @@ LeetCode Problems' Solutions | 1638 | [Count Substrings That Differ by One Character](https://leetcode.com/problems/count-substrings-that-differ-by-one-character "统计只差一个字符的子串数目") | [Go](problems/count-substrings-that-differ-by-one-character) | Medium | | 1637 | [Widest Vertical Area Between Two Points Containing No Points](https://leetcode.com/problems/widest-vertical-area-between-two-points-containing-no-points "两点之间不包含任何点的最宽垂直面积") | [Go](problems/widest-vertical-area-between-two-points-containing-no-points) | Medium | | 1636 | [Sort Array by Increasing Frequency](https://leetcode.com/problems/sort-array-by-increasing-frequency "按照频率将数组升序排序") | [Go](problems/sort-array-by-increasing-frequency) | Easy | -| 1635 | [Hopper Company Queries I](https://leetcode.com/problems/hopper-company-queries-i) 🔒 | [MySQL](problems/hopper-company-queries-i) | Hard | +| 1635 | [Hopper Company Queries I](https://leetcode.com/problems/hopper-company-queries-i "Hopper 公司查询 I") 🔒 | [MySQL](problems/hopper-company-queries-i) | Hard | | 1634 | [Add Two Polynomials Represented as Linked Lists](https://leetcode.com/problems/add-two-polynomials-represented-as-linked-lists "求两个多项式链表的和") 🔒 | [Go](problems/add-two-polynomials-represented-as-linked-lists) | Medium | | 1633 | [Percentage of Users Attended a Contest](https://leetcode.com/problems/percentage-of-users-attended-a-contest "各赛事的用户注册率") 🔒 | [MySQL](problems/percentage-of-users-attended-a-contest) | Easy | | 1632 | [Rank Transform of a Matrix](https://leetcode.com/problems/rank-transform-of-a-matrix "矩阵转换后的秩") | [Go](problems/rank-transform-of-a-matrix) | Hard | @@ -337,7 +344,7 @@ LeetCode Problems' Solutions | 1476 | [Subrectangle Queries](https://leetcode.com/problems/subrectangle-queries "子矩形查询") | [Go](problems/subrectangle-queries) | Medium | | 1475 | [Final Prices With a Special Discount in a Shop](https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop "商品折扣后的最终价格") | [Go](problems/final-prices-with-a-special-discount-in-a-shop) | Easy | | 1474 | [Delete N Nodes After M Nodes of a Linked List](https://leetcode.com/problems/delete-n-nodes-after-m-nodes-of-a-linked-list "删除链表 M 个节点之后的 N 个节点") 🔒 | [Go](problems/delete-n-nodes-after-m-nodes-of-a-linked-list) | Easy | -| 1473 | [Paint House III](https://leetcode.com/problems/paint-house-iii "给房子涂色 III") | [Go](problems/paint-house-iii) | Hard | +| 1473 | [Paint House III](https://leetcode.com/problems/paint-house-iii "粉刷房子 III") | [Go](problems/paint-house-iii) | Hard | | 1472 | [Design Browser History](https://leetcode.com/problems/design-browser-history "设计浏览器历史记录") | [Go](problems/design-browser-history) | Medium | | 1471 | [The k Strongest Values in an Array](https://leetcode.com/problems/the-k-strongest-values-in-an-array "数组中的 k 个最强值") | [Go](problems/the-k-strongest-values-in-an-array) | Medium | | 1470 | [Shuffle the Array](https://leetcode.com/problems/shuffle-the-array "重新排列数组") | [Go](problems/shuffle-the-array) | Easy | @@ -348,7 +355,7 @@ LeetCode Problems' Solutions | 1465 | [Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts](https://leetcode.com/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts "切割后面积最大的蛋糕") | [Go](problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts) | Medium | | 1464 | [Maximum Product of Two Elements in an Array](https://leetcode.com/problems/maximum-product-of-two-elements-in-an-array "数组中两元素的最大乘积") | [Go](problems/maximum-product-of-two-elements-in-an-array) | Easy | | 1463 | [Cherry Pickup II](https://leetcode.com/problems/cherry-pickup-ii "摘樱桃 II") | [Go](problems/cherry-pickup-ii) | Hard | -| 1462 | [Course Schedule IV](https://leetcode.com/problems/course-schedule-iv "课程安排 IV") | [Go](problems/course-schedule-iv) | Medium | +| 1462 | [Course Schedule IV](https://leetcode.com/problems/course-schedule-iv "课程表 IV") | [Go](problems/course-schedule-iv) | Medium | | 1461 | [Check If a String Contains All Binary Codes of Size K](https://leetcode.com/problems/check-if-a-string-contains-all-binary-codes-of-size-k "检查一个字符串是否包含所有长度为 K 的二进制子串") | [Go](problems/check-if-a-string-contains-all-binary-codes-of-size-k) | Medium | | 1460 | [Make Two Arrays Equal by Reversing Sub-arrays](https://leetcode.com/problems/make-two-arrays-equal-by-reversing-sub-arrays "通过翻转子数组使两个数组相等") | [Go](problems/make-two-arrays-equal-by-reversing-sub-arrays) | Easy | | 1459 | [Rectangles Area](https://leetcode.com/problems/rectangles-area "矩形面积") 🔒 | [MySQL](problems/rectangles-area) | Medium | diff --git a/problems/asteroid-collision/README.md b/problems/asteroid-collision/README.md index 220b6f4e5..96f1b8384 100644 --- a/problems/asteroid-collision/README.md +++ b/problems/asteroid-collision/README.md @@ -54,7 +54,7 @@

      Constraints:

        -
      • 2 <= asteroids <= 104
      • +
      • 2 <= asteroids.length <= 104
      • -1000 <= asteroids[i] <= 1000
      • asteroids[i] != 0
      diff --git a/problems/biggest-window-between-visits/README.md b/problems/biggest-window-between-visits/README.md index 34849e3a6..ab2a55cb3 100644 --- a/problems/biggest-window-between-visits/README.md +++ b/problems/biggest-window-between-visits/README.md @@ -9,6 +9,6 @@                  [Next >](../maximum-units-on-a-truck "Maximum Units on a Truck") -## [1709. Biggest Window Between Visits (Medium)](https://leetcode.com/problems/biggest-window-between-visits "") +## [1709. Biggest Window Between Visits (Medium)](https://leetcode.com/problems/biggest-window-between-visits "访问日期之间最大的空档期") diff --git a/problems/binary-search-tree-to-greater-sum-tree/README.md b/problems/binary-search-tree-to-greater-sum-tree/README.md index da20eab45..d0ef4fb73 100644 --- a/problems/binary-search-tree-to-greater-sum-tree/README.md +++ b/problems/binary-search-tree-to-greater-sum-tree/README.md @@ -63,7 +63,10 @@
    ### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Hints
    diff --git a/problems/break-a-palindrome/README.md b/problems/break-a-palindrome/README.md index b64bba2c8..bf8c6aaac 100644 --- a/problems/break-a-palindrome/README.md +++ b/problems/break-a-palindrome/README.md @@ -11,9 +11,9 @@ ## [1328. Break a Palindrome (Medium)](https://leetcode.com/problems/break-a-palindrome "破坏回文串") -

    Given a palindromic string palindrome, replace exactly one character by any lowercase English letter so that the string becomes the lexicographically smallest possible string that isn't a palindrome.

    +

    Given a palindromic string palindrome, replace exactly one character with any lowercase English letter so that the string becomes the lexicographically smallest possible string that is not a palindrome.

    -

    After doing so, return the final string.  If there is no way to do so, return the empty string.

    +

    After doing so, return the final string. If there is no way to do so, return an empty string.

     

    Example 1:

    @@ -35,7 +35,7 @@
    • 1 <= palindrome.length <= 1000
    • -
    • palindrome consists of only lowercase English letters.
    • +
    • palindrome consists of only lowercase English letters.
    ### Related Topics diff --git a/problems/bus-routes/README.md b/problems/bus-routes/README.md index 58e43ac65..467f27925 100644 --- a/problems/bus-routes/README.md +++ b/problems/bus-routes/README.md @@ -11,19 +11,30 @@ ## [815. Bus Routes (Hard)](https://leetcode.com/problems/bus-routes "公交路线") -

    We have a list of bus routes. Each routes[i] is a bus route that the i-th bus repeats forever. For example if routes[0] = [1, 5, 7], this means that the first bus (0-th indexed) travels in the sequence 1->5->7->1->5->7->1->... forever.

    +

    You are given an array routes representing bus routes where routes[i] is a bus route that the ith bus repeats forever.

    -

    We start at bus stop S (initially not on a bus), and we want to go to bus stop T. Travelling by buses only, what is the least number of buses we must take to reach our destination? Return -1 if it is not possible.

    +
      +
    • For example, if routes[0] = [1, 5, 7], this means that the 0th bus travels in the sequence 1 -> 5 -> 7 -> 1 -> 5 -> 7 -> 1 -> ... forever.
    • +
    + +

    You will start at the bus stop source (You are not on any bus initially), and you want to go to the bus stop target. You can travel between bus stops by buses only.

    + +

    Return the least number of buses you must take to travel from source to target. Return -1 if it is not possible.

    + +

     

    +

    Example 1:

    -Example:
    -Input: 
    -routes = [[1, 2, 7], [3, 6, 7]]
    -S = 1
    -T = 6
    +Input: routes = [[1,2,7],[3,6,7]], source = 1, target = 6
     Output: 2
    -Explanation: 
    -The best strategy is take the first bus to the bus stop 7, then take the second bus to the bus stop 6.
    +Explanation: The best strategy is take the first bus to the bus stop 7, then take the second bus to the bus stop 6.
    +
    + +

    Example 2:

    + +
    +Input: routes = [[7,12],[4,5,15],[6],[15,19],[9,12,13]], source = 15, target = 12
    +Output: -1
     

     

    @@ -31,8 +42,11 @@ The best strategy is take the first bus to the bus stop 7, then take the second
    • 1 <= routes.length <= 500.
    • -
    • 1 <= routes[i].length <= 10^5.
    • -
    • 0 <= routes[i][j] < 10 ^ 6.
    • +
    • 1 <= routes[i].length <= 105
    • +
    • All the values of routes[i] are unique.
    • +
    • sum(routes[i].length) <= 105
    • +
    • 0 <= routes[i][j] < 106
    • +
    • 0 <= source, target < 106
    ### Related Topics diff --git a/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/README.md b/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/README.md new file mode 100644 index 000000000..d2bdf53a8 --- /dev/null +++ b/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/README.md @@ -0,0 +1,84 @@ + + + + + + + +[< Previous](../restore-the-array-from-adjacent-pairs "Restore the Array From Adjacent Pairs") +                 +[Next >](../palindrome-partitioning-iv "Palindrome Partitioning IV") + +## [1744. Can You Eat Your Favorite Candy on Your Favorite Day? (Medium)](https://leetcode.com/problems/can-you-eat-your-favorite-candy-on-your-favorite-day "你能在你最喜欢的那天吃到你最喜欢的糖果吗?") + +

    You are given a (0-indexed) array of positive integers candiesCount where candiesCount[i] represents the number of candies of the ith type you have. You are also given a 2D array queries where queries[i] = [favoriteTypei, favoriteDayi, dailyCapi].

    + +

    You play a game with the following rules:

    + +
      +
    • You start eating candies on day 0.
    • +
    • You cannot eat any candy of type i unless you have eaten all candies of type i - 1.
    • +
    • You must eat at least one candy per day until you have eaten all the candies.
    • +
    + +

    Construct a boolean array answer such that answer.length == queries.length and answer[i] is true if you can eat a candy of type favoriteTypei on day favoriteDayi without eating more than dailyCapi candies on any day, and false otherwise. Note that you can eat different types of candy on the same day, provided that you follow rule 2.

    + +

    Return the constructed array answer.

    + +

     

    +

    Example 1:

    + +
    +Input: candiesCount = [7,4,5,3,8], queries = [[0,2,2],[4,2,4],[2,13,1000000000]]
    +Output: [true,false,true]
    +Explanation:
    +1- If you eat 2 candies (type 0) on day 0 and 2 candies (type 0) on day 1, you will eat a candy of type 0 on day 2.
    +2- You can eat at most 4 candies each day.
    +   If you eat 4 candies every day, you will eat 4 candies (type 0) on day 0 and 4 candies (type 0 and type 1) on day 1.
    +   On day 2, you can only eat 4 candies (type 1 and type 2), so you cannot eat a candy of type 4 on day 2.
    +3- If you eat 1 candy each day, you will eat a candy of type 2 on day 13.
    +
    + +

    Example 2:

    + +
    +Input: candiesCount = [5,2,6,4,1], queries = [[3,1,2],[4,10,3],[3,10,100],[4,100,30],[1,3,1]]
    +Output: [false,true,true,false,false]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= candiesCount.length <= 105
    • +
    • 1 <= candiesCount[i] <= 105
    • +
    • 1 <= queries.length <= 105
    • +
    • queries[i].length == 3
    • +
    • 0 <= favoriteTypei < candiesCount.length
    • +
    • 0 <= favoriteDayi <= 109
    • +
    • 1 <= dailyCapi <= 109
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +The query is true if and only if your favorite day is in between the earliest and latest possible days to eat your favorite candy. +
    + +
    +Hint 2 +To get the earliest day, you need to eat dailyCap candies every day. To get the latest day, you need to eat 1 candy every day. +
    + +
    +Hint 3 +The latest possible day is the total number of candies with a smaller type plus the number of your favorite candy minus 1. +
    + +
    +Hint 4 +The earliest possible day that you can eat your favorite candy is the total number of candies with a smaller type divided by dailyCap. +
    diff --git a/problems/checking-existence-of-edge-length-limited-paths-ii/README.md b/problems/checking-existence-of-edge-length-limited-paths-ii/README.md index 159005616..af6e21d25 100644 --- a/problems/checking-existence-of-edge-length-limited-paths-ii/README.md +++ b/problems/checking-existence-of-edge-length-limited-paths-ii/README.md @@ -9,7 +9,7 @@                  [Next >](../number-of-rectangles-that-can-form-the-largest-square "Number Of Rectangles That Can Form The Largest Square") -## [1724. Checking Existence of Edge Length Limited Paths II (Hard)](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths-ii "") +## [1724. Checking Existence of Edge Length Limited Paths II (Hard)](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths-ii "检查边长度限制的路径是否存在 II") diff --git a/problems/concatenated-words/README.md b/problems/concatenated-words/README.md index df394b693..e3404100e 100644 --- a/problems/concatenated-words/README.md +++ b/problems/concatenated-words/README.md @@ -11,9 +11,9 @@ ## [472. Concatenated Words (Hard)](https://leetcode.com/problems/concatenated-words "连接词") -

    Given a list of words (without duplicates), please write a program that returns all concatenated words in the given list of words.

    +

    Given an array of strings words (without duplicates), return all the concatenated words in the given list of words.

    -

    A concatenated word is defined as a string that is comprised entirely of at least two shorter words in the given array.

    +

    A concatenated word is defined as a string that is comprised entirely of at least two shorter words in the given array.

     

    Example 1:

    diff --git a/problems/convert-bst-to-greater-tree/README.md b/problems/convert-bst-to-greater-tree/README.md index 18a1a1db9..0bfe66e87 100644 --- a/problems/convert-bst-to-greater-tree/README.md +++ b/problems/convert-bst-to-greater-tree/README.md @@ -64,3 +64,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Recursion](../../tag/recursion/README.md)] diff --git a/problems/copy-list-with-random-pointer/README.md b/problems/copy-list-with-random-pointer/README.md index 493606481..d6f283200 100644 --- a/problems/copy-list-with-random-pointer/README.md +++ b/problems/copy-list-with-random-pointer/README.md @@ -11,17 +11,23 @@ ## [138. Copy List with Random Pointer (Medium)](https://leetcode.com/problems/copy-list-with-random-pointer "复制带随机指针的链表") -

    A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.

    +

    A linked list of length n is given such that each node contains an additional random pointer, which could point to any node in the list, or null.

    -

    Return a deep copy of the list.

    +

    Construct a deep copy of the list. The deep copy should consist of exactly n brand new nodes, where each new node has its value set to the value of its corresponding original node. Both the next and random pointer of the new nodes should point to new nodes in the copied list such that the pointers in the original list and copied list represent the same list state. None of the pointers in the new list should point to nodes in the original list.

    -

    The Linked List is represented in the input/output as a list of n nodes. Each node is represented as a pair of [val, random_index] where:

    +

    For example, if there are two nodes X and Y in the original list, where X.random --> Y, then for the corresponding two nodes x and y in the copied list, x.random --> y.

    + +

    Return the head of the copied linked list.

    + +

    The linked list is represented in the input/output as a list of n nodes. Each node is represented as a pair of [val, random_index] where:

    • val: an integer representing Node.val
    • -
    • random_index: the index of the node (range from 0 to n-1) where random pointer points to, or null if it does not point to any node.
    • +
    • random_index: the index of the node (range from 0 to n-1) that the random pointer points to, or null if it does not point to any node.
    +

    Your code will only be given the head of the original linked list.

    +

     

    Example 1:

    @@ -51,16 +57,16 @@
     Input: head = []
     Output: []
    -Explanation: Given linked list is empty (null pointer), so return null.
    +Explanation: The given linked list is empty (null pointer), so return null.
     

     

    Constraints:

      +
    • 0 <= n <= 1000
    • -10000 <= Node.val <= 10000
    • -
    • Node.random is null or pointing to a node in the linked list.
    • -
    • The number of nodes will not exceed 1000.
    • +
    • Node.random is null or is pointing to some node in the linked list.
    ### Related Topics diff --git a/problems/count-apples-and-oranges/README.md b/problems/count-apples-and-oranges/README.md index 51d64860c..dd5692422 100644 --- a/problems/count-apples-and-oranges/README.md +++ b/problems/count-apples-and-oranges/README.md @@ -9,6 +9,6 @@                  [Next >](../calculate-money-in-leetcode-bank "Calculate Money in Leetcode Bank") -## [1715. Count Apples and Oranges (Medium)](https://leetcode.com/problems/count-apples-and-oranges "") +## [1715. Count Apples and Oranges (Medium)](https://leetcode.com/problems/count-apples-and-oranges "苹果和橘子的个数") diff --git a/problems/course-schedule-iv/README.md b/problems/course-schedule-iv/README.md index 75eee50ff..73fe187bb 100644 --- a/problems/course-schedule-iv/README.md +++ b/problems/course-schedule-iv/README.md @@ -9,7 +9,7 @@                  [Next >](../cherry-pickup-ii "Cherry Pickup II") -## [1462. Course Schedule IV (Medium)](https://leetcode.com/problems/course-schedule-iv "课程安排 IV") +## [1462. Course Schedule IV (Medium)](https://leetcode.com/problems/course-schedule-iv "课程表 IV")

    There are a total of n courses you have to take, labeled from 0 to n-1.

    diff --git a/problems/course-schedule/README.md b/problems/course-schedule/README.md index 02808f090..f701a0b2e 100644 --- a/problems/course-schedule/README.md +++ b/problems/course-schedule/README.md @@ -11,11 +11,13 @@ ## [207. Course Schedule (Medium)](https://leetcode.com/problems/course-schedule "课程表") -

    There are a total of numCourses courses you have to take, labeled from 0 to numCourses-1.

    +

    There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi first if you want to take course ai.

    -

    Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1]

    +
      +
    • For example, the pair [0, 1], indicates that to take course 0 you have to first take course 1.
    • +
    -

    Given the total number of courses and a list of prerequisite pairs, is it possible for you to finish all courses?

    +

    Return true if you can finish all courses. Otherwise, return false.

     

    Example 1:

    @@ -23,8 +25,8 @@
     Input: numCourses = 2, prerequisites = [[1,0]]
     Output: true
    -Explanation: There are a total of 2 courses to take. 
    -             To take course 1 you should have finished course 0. So it is possible.
    +Explanation: There are a total of 2 courses to take. 
    +To take course 1 you should have finished course 0. So it is possible.
     

    Example 2:

    @@ -32,18 +34,19 @@
     Input: numCourses = 2, prerequisites = [[1,0],[0,1]]
     Output: false
    -Explanation: There are a total of 2 courses to take. 
    -             To take course 1 you should have finished course 0, and to take course 0 you should
    -             also have finished course 1. So it is impossible.
    +Explanation: There are a total of 2 courses to take. 
    +To take course 1 you should have finished course 0, and to take course 0 you should also have finished course 1. So it is impossible.
     

     

    Constraints:

      -
    • The input prerequisites is a graph represented by a list of edges, not adjacency matrices. Read more about how a graph is represented.
    • -
    • You may assume that there are no duplicate edges in the input prerequisites.
    • -
    • 1 <= numCourses <= 10^5
    • +
    • 1 <= numCourses <= 105
    • +
    • 0 <= prerequisites.length <= 5000
    • +
    • prerequisites[i].length == 2
    • +
    • 0 <= ai, bi < numCourses
    • +
    • All the pairs prerequisites[i] are unique.
    ### Related Topics diff --git a/problems/decode-ways-ii/README.md b/problems/decode-ways-ii/README.md index 78a0e77f0..e7875df03 100644 --- a/problems/decode-ways-ii/README.md +++ b/problems/decode-ways-ii/README.md @@ -11,51 +11,68 @@ ## [639. Decode Ways II (Hard)](https://leetcode.com/problems/decode-ways-ii "解码方法 2") -

    -A message containing letters from A-Z is being encoded to numbers using the following mapping way: -

    +

    A message containing letters from A-Z can be encoded into numbers using the following mapping:

    -'A' -> 1
    -'B' -> 2
    +'A' -> "1"
    +'B' -> "2"
     ...
    -'Z' -> 26
    +'Z' -> "26"
     
    -

    -Beyond that, now the encoded string can also contain the character '*', which can be treated as one of the numbers from 1 to 9. -

    +

    To decode an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For example, "11106" can be mapped into:

    +
      +
    • "AAJF" with the grouping (1 1 10 6)
    • +
    • "KJF" with the grouping (11 10 6)
    • +
    -

    -Given the encoded message containing digits and the character '*', return the total number of ways to decode it. -

    +

    Note that the grouping (1 11 06) is invalid because "06" cannot be mapped into 'F' since "6" is different from "06".

    -

    -Also, since the answer may be very large, you should return the output mod 109 + 7. -

    +

    In addition to the mapping above, an encoded message may contain the '*' character, which can represent any digit from '1' to '9' ('0' is excluded). For example, the encoded message "1*" may represent any of the encoded messages "11", "12", "13", "14", "15", "16", "17", "18", or "19". Decoding "1*" is equivalent to decoding any of the encoded messages it can represent.

    + +

    Given a string s containing digits and the '*' character, return the number of ways to decode it.

    + +

    Since the answer may be very large, return it modulo 109 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "*"
    +Output: 9
    +Explanation: The encoded message can represent any of the encoded messages "1", "2", "3", "4", "5", "6", "7", "8", or "9".
    +Each of these can be decoded to the strings "A", "B", "C", "D", "E", "F", "G", "H", and "I" respectively.
    +Hence, there are a total of 9 ways to decode "*".
    +
    + +

    Example 2:

    -

    Example 1:

    -Input: "*"
    -Output: 9
    -Explanation: The encoded message can be decoded to the string: "A", "B", "C", "D", "E", "F", "G", "H", "I".
    +Input: s = "1*"
    +Output: 18
    +Explanation: The encoded message can represent any of the encoded messages "11", "12", "13", "14", "15", "16", "17", "18", or "19".
    +Each of these encoded messages have 2 ways to be decoded (e.g. "11" can be decoded to "AA" or "K").
    +Hence, there are a total of 9 * 2 = 18 ways to decode "1*".
     
    -

    -

    Example 2:
    +

    Example 3:

    +
    -Input: "1*"
    -Output: 9 + 9 = 18
    +Input: s = "2*"
    +Output: 15
    +Explanation: The encoded message can represent any of the encoded messages "21", "22", "23", "24", "25", "26", "27", "28", or "29".
    +"21", "22", "23", "24", "25", and "26" have 2 ways of being decoded, but "27", "28", and "29" only have 1 way.
    +Hence, there are a total of (6 * 2) + (3 * 1) = 12 + 3 = 15 ways to decode "2*".
     
    -

    - -

    Note:
    -

      -
    1. The length of the input string will fit in range [1, 105].
    2. -
    3. The input string will only contain the character '*' and digits '0' - '9'.
    4. -
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 105
    • +
    • s[i] is a digit or '*'.
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/decode-ways/README.md b/problems/decode-ways/README.md index 58e0cc639..c33e1a58f 100644 --- a/problems/decode-ways/README.md +++ b/problems/decode-ways/README.md @@ -20,9 +20,16 @@ 'Z' -> "26" -

    To decode an encoded message, all the digits must be mapped back into letters using the reverse of the mapping above (there may be multiple ways). For example, "111" can have each of its "1"s be mapped into 'A's to make "AAA", or it could be mapped to "11" and "1" ('K' and 'A' respectively) to make "KA". Note that "06" cannot be mapped into 'F' since "6" is different from "06".

    +

    To decode an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For example, "11106" can be mapped into:

    -

    Given a non-empty string num containing only digits, return the number of ways to decode it.

    +
      +
    • "AAJF" with the grouping (1 1 10 6)
    • +
    • "KJF" with the grouping (11 10 6)
    • +
    + +

    Note that the grouping (1 11 06) is invalid because "06" cannot be mapped into 'F' since "6" is different from "06".

    + +

    Given a string s containing only digits, return the number of ways to decode it.

    The answer is guaranteed to fit in a 32-bit integer.

    @@ -48,8 +55,9 @@
     Input: s = "0"
     Output: 0
    -Explanation: There is no character that is mapped to a number starting with 0. The only valid mappings with 0 are 'J' -> "10" and 'T' -> "20".
    -Since there is no character, there are no valid ways to decode this since all digits need to be mapped.
    +Explanation: There is no character that is mapped to a number starting with 0.
    +The only valid mappings with 0 are 'J' -> "10" and 'T' -> "20", neither of which start with 0.
    +Hence, there are no valid ways to decode this since all digits need to be mapped.
     

    Example 4:

    @@ -57,7 +65,7 @@ Since there is no character, there are no valid ways to decode this since all di
     Input: s = "06"
     Output: 0
    -Explanation: "06" cannot be mapped to "F" because the zero at the beginning of the string can't make a valid character. 
    +Explanation: "06" cannot be mapped to "F" because of the leading zero ("6" is different from "06").
     

     

    diff --git a/problems/delete-and-earn/README.md b/problems/delete-and-earn/README.md index d6912c94a..ef46a1e37 100644 --- a/problems/delete-and-earn/README.md +++ b/problems/delete-and-earn/README.md @@ -15,42 +15,37 @@

    In each operation, you pick any nums[i] and delete it to earn nums[i] points. After, you must delete every element equal to nums[i] - 1 or nums[i] + 1.

    -

    You start with 0 points. Return the maximum number of points you can earn by applying such operations.

    +

    You start with 0 points. Return the maximum number of points you can earn by applying such operations.

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input: nums = [3, 4, 2]
    -Output: 6
    -Explanation: 
    -Delete 4 to earn 4 points, consequently 3 is also deleted.
    -Then, delete 2 to earn 2 points. 6 total points are earned.
    +Input: nums = [3,4,2]
    +Output: 6
    +Explanation: Delete 4 to earn 4 points, consequently 3 is also deleted.
    +Then, delete 2 to earn 2 points.
    +6 total points are earned.
     
    -

     

    - -

    Example 2:

    +

    Example 2:

    -Input: nums = [2, 2, 3, 3, 3, 4]
    -Output: 9
    -Explanation: 
    -Delete 3 to earn 3 points, deleting both 2's and the 4.
    +Input: nums = [2,2,3,3,3,4]
    +Output: 9
    +Explanation: Delete 3 to earn 3 points, deleting both 2's and the 4.
     Then, delete 3 again to earn 3 points, and 3 again to earn 3 points.
     9 total points are earned.
     

     

    - -

    Note:

    +

    Constraints:

      -
    • The length of nums is at most 20000.
    • -
    • Each element nums[i] is an integer in the range [1, 10000].
    • +
    • 1 <= nums.length <= 2 * 104
    • +
    • 1 <= nums[i] <= 104
    -

     

    - ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/delete-columns-to-make-sorted-ii/README.md b/problems/delete-columns-to-make-sorted-ii/README.md index 5e5583679..cb6976940 100644 --- a/problems/delete-columns-to-make-sorted-ii/README.md +++ b/problems/delete-columns-to-make-sorted-ii/README.md @@ -11,74 +11,54 @@ ## [955. Delete Columns to Make Sorted II (Medium)](https://leetcode.com/problems/delete-columns-to-make-sorted-ii "删列造序 II") -

    We are given an array A of N lowercase letter strings, all of the same length.

    +

    You are given an array of n strings strs, all of the same length.

    -

    Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices.

    +

    We may choose any deletion indices, and we delete all the characters in those indices for each string.

    -

    For example, if we have an array A = ["abcdef","uvwxyz"] and deletion indices {0, 2, 3}, then the final array after deletions is ["bef","vyz"].

    +

    For example, if we have strs = ["abcdef","uvwxyz"] and deletion indices {0, 2, 3}, then the final array after deletions is ["bef", "vyz"].

    -

    Suppose we chose a set of deletion indices D such that after deletions, the final array has its elements in lexicographic order (A[0] <= A[1] <= A[2] ... <= A[A.length - 1]).

    - -

    Return the minimum possible value of D.length.

    +

    Suppose we chose a set of deletion indices answer such that after deletions, the final array has its elements in lexicographic order (i.e., strs[0] <= strs[1] <= strs[2] <= ... <= strs[n - 1]). Return the minimum possible value of answer.length.

     

    - -
    -
    -
      -
    -
    -
    - -

    Example 1:

    -Input: ["ca","bb","ac"]
    -Output: 1
    -Explanation: 
    -After deleting the first column, A = ["a", "b", "c"].
    -Now A is in lexicographic order (ie. A[0] <= A[1] <= A[2]).
    -We require at least 1 deletion since initially A was not in lexicographic order, so the answer is 1.
    +Input: strs = ["ca","bb","ac"]
    +Output: 1
    +Explanation: 
    +After deleting the first column, strs = ["a", "b", "c"].
    +Now strs is in lexicographic order (ie. strs[0] <= strs[1] <= strs[2]).
    +We require at least 1 deletion since initially strs was not in lexicographic order, so the answer is 1.
     
    -

    Example 2:

    -Input: ["xc","yb","za"]
    -Output: 0
    -Explanation: 
    -A is already in lexicographic order, so we don't need to delete anything.
    -Note that the rows of A are not necessarily in lexicographic order:
    -ie. it is NOT necessarily true that (A[0][0] <= A[0][1] <= ...)
    +Input: strs = ["xc","yb","za"]
    +Output: 0
    +Explanation: 
    +strs is already in lexicographic order, so we do not need to delete anything.
    +Note that the rows of strs are not necessarily in lexicographic order:
    +i.e., it is NOT necessarily true that (strs[0][0] <= strs[0][1] <= ...)
     
    -

    Example 3:

    -Input: ["zyx","wvu","tsr"]
    -Output: 3
    -Explanation: 
    -We have to delete every column.
    +Input: strs = ["zyx","wvu","tsr"]
    +Output: 3
    +Explanation: We have to delete every column.
     

     

    - -
    -
    -

    Note:

    - -
      -
    1. 1 <= A.length <= 100
    2. -
    3. 1 <= A[i].length <= 100
    4. -
    -
    -
    -
    -
    -
    +

    Constraints:

    + +
      +
    • n == strs.length
    • +
    • 1 <= n <= 100
    • +
    • 1 <= strs[i].length <= 100
    • +
    • strs[i] consists of lowercase English letters.
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/delete-columns-to-make-sorted-iii/README.md b/problems/delete-columns-to-make-sorted-iii/README.md index 36088fa3b..310256a9c 100644 --- a/problems/delete-columns-to-make-sorted-iii/README.md +++ b/problems/delete-columns-to-make-sorted-iii/README.md @@ -11,60 +11,53 @@ ## [960. Delete Columns to Make Sorted III (Hard)](https://leetcode.com/problems/delete-columns-to-make-sorted-iii "删列造序 III") -

    We are given an array A of N lowercase letter strings, all of the same length.

    +

    You are given an array of n strings strs, all of the same length.

    -

    Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices.

    +

    We may choose any deletion indices, and we delete all the characters in those indices for each string.

    -

    For example, if we have an array A = ["babca","bbazb"] and deletion indices {0, 1, 4}, then the final array after deletions is ["bc","az"].

    +

    For example, if we have strs = ["abcdef","uvwxyz"] and deletion indices {0, 2, 3}, then the final array after deletions is ["bef", "vyz"].

    -

    Suppose we chose a set of deletion indices D such that after deletions, the final array has every element (row) in lexicographic order.

    - -

    For clarity, A[0] is in lexicographic order (ie. A[0][0] <= A[0][1] <= ... <= A[0][A[0].length - 1]), A[1] is in lexicographic order (ie. A[1][0] <= A[1][1] <= ... <= A[1][A[1].length - 1]), and so on.

    - -

    Return the minimum possible value of D.length.

    +

    Suppose we chose a set of deletion indices answer such that after deletions, the final array has every string (row) in lexicographic order. (i.e., (strs[0][0] <= strs[0][1] <= ... <= strs[0][strs[0].length - 1]), and (strs[1][0] <= strs[1][1] <= ... <= strs[1][strs[1].length - 1]), and so on). Return the minimum possible value of answer.length.

     

    - -

    Example 1:

    -Input: ["babca","bbazb"]
    -Output: 3
    -Explanation: After deleting columns 0, 1, and 4, the final array is A = ["bc", "az"].
    -Both these rows are individually in lexicographic order (ie. A[0][0] <= A[0][1] and A[1][0] <= A[1][1]).
    -Note that A[0] > A[1] - the array A isn't necessarily in lexicographic order.
    -
    +Input: strs = ["babca","bbazb"] +Output: 3 +Explanation: After deleting columns 0, 1, and 4, the final array is strs = ["bc", "az"]. +Both these rows are individually in lexicographic order (ie. strs[0][0] <= strs[0][1] and strs[1][0] <= strs[1][1]). +Note that strs[0] > strs[1] - the array strs is not necessarily in lexicographic order. -

    Example 2:

    -Input: ["edcba"]
    -Output: 4
    -Explanation: If we delete less than 4 columns, the only row won't be lexicographically sorted.
    +Input: strs = ["edcba"]
    +Output: 4
    +Explanation: If we delete less than 4 columns, the only row will not be lexicographically sorted.
     
    -

    Example 3:

    -Input: ["ghi","def","abc"]
    -Output: 0
    -Explanation: All rows are already lexicographically sorted.
    +Input: strs = ["ghi","def","abc"]
    +Output: 0
    +Explanation: All rows are already lexicographically sorted.
     

     

    -
    -
    -
    - -

    Note:

    - -
      -
    1. 1 <= A.length <= 100
    2. -
    3. 1 <= A[i].length <= 100
    4. -
    +

    Constraints:

    + +
      +
    • n == strs.length
    • +
    • 1 <= n <= 100
    • +
    • 1 <= strs[i].length <= 100
    • +
    • strs[i] consists of lowercase English letters.
    • +
    + +
      +
    •  
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/delete-columns-to-make-sorted/README.md b/problems/delete-columns-to-make-sorted/README.md index 82afaae3d..3e91311c1 100644 --- a/problems/delete-columns-to-make-sorted/README.md +++ b/problems/delete-columns-to-make-sorted/README.md @@ -11,49 +11,64 @@ ## [944. Delete Columns to Make Sorted (Easy)](https://leetcode.com/problems/delete-columns-to-make-sorted "删列造序") -

    We are given an array A of N lowercase letter strings, all of the same length.

    +

    You are given an array of n strings strs, all of the same length.

    -

    Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices.

    +

    The strings can be arranged such that there is one on each line, making a grid. For example, strs = ["abc", "bce", "cae"] can be arranged as:

    -

    For example, if we have an array A = ["abcdef","uvwxyz"] and deletion indices {0, 2, 3}, then the final array after deletions is ["bef", "vyz"], and the remaining columns of A are ["b","v"], ["e","y"], and ["f","z"].  (Formally, the c-th column is [A[0][c], A[1][c], ..., A[A.length-1][c]]).

    +
    +abc
    +bce
    +cae
    +
    -

    Suppose we chose a set of deletion indices D such that after deletions, each remaining column in A is in non-decreasing sorted order.

    +

    You want to delete the columns that are not sorted lexicographically. In the above example (0-indexed), columns 0 ('a', 'b', 'c') and 2 ('c', 'e', 'e') are sorted while column 1 ('b', 'c', 'a') is not, so you would delete column 1.

    -

    Return the minimum possible value of D.length.

    +

    Return the number of columns that you will delete.

     

    Example 1:

    -Input: A = ["cba","daf","ghi"]
    +Input: strs = ["cba","daf","ghi"]
     Output: 1
    -Explanation: 
    -After choosing D = {1}, each column ["c","d","g"] and ["a","f","i"] are in non-decreasing sorted order.
    -If we chose D = {}, then a column ["b","a","h"] would not be in non-decreasing sorted order.
    +Explanation: The grid looks as follows:
    +  cba
    +  daf
    +  ghi
    +Columns 0 and 2 are sorted, but column 1 is not, so you only need to delete 1 column.
     

    Example 2:

    -Input: A = ["a","b"]
    +Input: strs = ["a","b"]
     Output: 0
    -Explanation: D = {}
    +Explanation: The grid looks as follows:
    +  a
    +  b
    +Column 0 is the only column and is sorted, so you will not delete any columns.
     

    Example 3:

    -Input: A = ["zyx","wvu","tsr"]
    +Input: strs = ["zyx","wvu","tsr"]
     Output: 3
    -Explanation: D = {0, 1, 2}
    +Explanation: The grid looks as follows:
    +  zyx
    +  wvu
    +  tsr
    +All 3 columns are not sorted, so you will delete all 3.
     

     

    Constraints:

      -
    • 1 <= A.length <= 100
    • -
    • 1 <= A[i].length <= 1000
    • +
    • n == strs.length
    • +
    • 1 <= n <= 100
    • +
    • 1 <= strs[i].length <= 1000
    • +
    • strs[i] consists of lowercase English letters.
    ### Related Topics diff --git a/problems/fair-candy-swap/README.md b/problems/fair-candy-swap/README.md index 79fe3e629..e78ae571e 100644 --- a/problems/fair-candy-swap/README.md +++ b/problems/fair-candy-swap/README.md @@ -9,7 +9,7 @@                  [Next >](../construct-binary-tree-from-preorder-and-postorder-traversal "Construct Binary Tree from Preorder and Postorder Traversal") -## [888. Fair Candy Swap (Easy)](https://leetcode.com/problems/fair-candy-swap "公平的糖果交换") +## [888. Fair Candy Swap (Easy)](https://leetcode.com/problems/fair-candy-swap "公平的糖果棒交换")

    Alice and Bob have candy bars of different sizes: A[i] is the size of the i-th bar of candy that Alice has, and B[j] is the size of the j-th bar of candy that Bob has.

    diff --git a/problems/find-distance-in-a-binary-tree/README.md b/problems/find-distance-in-a-binary-tree/README.md index e0d51c19f..400efb227 100644 --- a/problems/find-distance-in-a-binary-tree/README.md +++ b/problems/find-distance-in-a-binary-tree/README.md @@ -7,9 +7,9 @@ [< Previous](../building-boxes "Building Boxes")                  -Next > +[Next >](../find-total-time-spent-by-each-employee "Find Total Time Spent by Each Employee") -## [1740. Find Distance in a Binary Tree (Easy)](https://leetcode.com/problems/find-distance-in-a-binary-tree "") +## [1740. Find Distance in a Binary Tree (Medium)](https://leetcode.com/problems/find-distance-in-a-binary-tree "找到二叉树中的距离") diff --git a/problems/find-followers-count/README.md b/problems/find-followers-count/README.md index 52d82b032..3b4dde38c 100644 --- a/problems/find-followers-count/README.md +++ b/problems/find-followers-count/README.md @@ -9,6 +9,6 @@                  [Next >](../shortest-path-to-get-food "Shortest Path to Get Food") -## [1729. Find Followers Count (Easy)](https://leetcode.com/problems/find-followers-count "") +## [1729. Find Followers Count (Easy)](https://leetcode.com/problems/find-followers-count "求关注者的数量") diff --git a/problems/find-pivot-index/README.md b/problems/find-pivot-index/README.md index 03aa0c5b9..3ba48f5f0 100644 --- a/problems/find-pivot-index/README.md +++ b/problems/find-pivot-index/README.md @@ -11,11 +11,13 @@ ## [724. Find Pivot Index (Easy)](https://leetcode.com/problems/find-pivot-index "寻找数组的中心索引") -

    Given an array of integers nums, write a method that returns the "pivot" index of this array.

    +

    Given an array of integers nums, calculate the pivot index of this array.

    -

    We define the pivot index as the index where the sum of all the numbers to the left of the index is equal to the sum of all the numbers to the right of the index.

    +

    The pivot index is the index where the sum of all the numbers strictly to the left of the index is equal to the sum of all the numbers strictly to the index's right.

    -

    If no such index exists, we should return -1. If there are multiple pivot indexes, you should return the left-most pivot index.

    +

    If the index is on the left edge of the array, then the left sum is 0 because there are no elements to the left. This also applies to the right edge of the array.

    + +

    Return the leftmost pivot index. If no such index exists, return -1.

     

    Example 1:

    @@ -24,8 +26,9 @@ Input: nums = [1,7,3,6,5,6] Output: 3 Explanation: -The sum of the numbers to the left of index 3 (nums[3] = 6) is equal to the sum of numbers to the right of index 3. -Also, 3 is the first index where this occurs. +The pivot index is 3. +Left sum = nums[0] + nums[1] + nums[2] = 1 + 7 + 3 = 11 +Right sum = nums[4] + nums[5] = 5 + 6 = 11

    Example 2:

    @@ -34,15 +37,25 @@ Also, 3 is the first index where this occurs. Input: nums = [1,2,3] Output: -1 Explanation: -There is no index that satisfies the conditions in the problem statement. +There is no index that satisfies the conditions in the problem statement. + +

    Example 3:

    + +
    +Input: nums = [2,1,-1]
    +Output: 0
    +Explanation:
    +The pivot index is 0.
    +Left sum = 0 (no elements to the left of index 0)
    +Right sum = nums[1] + nums[2] = 1 + -1 = 0
     

     

    Constraints:

      -
    • The length of nums will be in the range [0, 10000].
    • -
    • Each element nums[i] will be an integer in the range [-1000, 1000].
    • +
    • 1 <= nums.length <= 104
    • +
    • -1000 <= nums[i] <= 1000
    ### Related Topics diff --git a/problems/find-the-shortest-superstring/README.md b/problems/find-the-shortest-superstring/README.md index b10ab5c72..40948a115 100644 --- a/problems/find-the-shortest-superstring/README.md +++ b/problems/find-the-shortest-superstring/README.md @@ -11,42 +11,35 @@ ## [943. Find the Shortest Superstring (Hard)](https://leetcode.com/problems/find-the-shortest-superstring "最短超级串") -

    Given an array A of strings, find any smallest string that contains each string in A as a substring.

    +

    Given an array of strings words, return the smallest string that contains each string in words as a substring. If there are multiple valid strings of the smallest length, return any of them.

    -

    We may assume that no string in A is substring of another string in A.

    +

    You may assume that no string in words is a substring of another string in words.

    -
     
    - -
    +

     

    Example 1:

    -Input: ["alex","loves","leetcode"]
    -Output: "alexlovesleetcode"
    -Explanation: All permutations of "alex","loves","leetcode" would also be accepted.
    +Input: words = ["alex","loves","leetcode"]
    +Output: "alexlovesleetcode"
    +Explanation: All permutations of "alex","loves","leetcode" would also be accepted.
     
    -

    Example 2:

    -Input: ["catg","ctaagt","gcta","ttca","atgcatc"]
    -Output: "gctaagttcatgcatc"
    +Input: words = ["catg","ctaagt","gcta","ttca","atgcatc"] +Output: "gctaagttcatgcatc" +

     

    -
    -
    - -

    Note:

    - -
      -
    1. 1 <= A.length <= 12
    2. -
    3. 1 <= A[i].length <= 20
    4. -
    - -
    -
     
    -
    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 12
    • +
    • 1 <= words[i].length <= 20
    • +
    • words[i] consists of lowercase English letters.
    • +
    • All the strings of words are unique.
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/find-total-time-spent-by-each-employee/README.md b/problems/find-total-time-spent-by-each-employee/README.md new file mode 100644 index 000000000..3202167f1 --- /dev/null +++ b/problems/find-total-time-spent-by-each-employee/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../find-distance-in-a-binary-tree "Find Distance in a Binary Tree") +                 +[Next >](../maximum-number-of-balls-in-a-box "Maximum Number of Balls in a Box") + +## [1741. Find Total Time Spent by Each Employee (Easy)](https://leetcode.com/problems/find-total-time-spent-by-each-employee "") + + diff --git a/problems/find-total-time-spent-by-each-employee/mysql_schemas.sql b/problems/find-total-time-spent-by-each-employee/mysql_schemas.sql new file mode 100644 index 000000000..1431641c1 --- /dev/null +++ b/problems/find-total-time-spent-by-each-employee/mysql_schemas.sql @@ -0,0 +1,7 @@ +Create table If Not Exists Employees(emp_id int, event_day date, in_time int, out_time int); +Truncate table Employees; +insert into Employees (emp_id, event_day, in_time, out_time) values ('1', '2020-11-28', '4', '32'); +insert into Employees (emp_id, event_day, in_time, out_time) values ('1', '2020-11-28', '55', '200'); +insert into Employees (emp_id, event_day, in_time, out_time) values ('1', '2020-12-3', '1', '42'); +insert into Employees (emp_id, event_day, in_time, out_time) values ('2', '2020-11-28', '3', '33'); +insert into Employees (emp_id, event_day, in_time, out_time) values ('2', '2020-12-9', '47', '74'); diff --git a/problems/flip-binary-tree-to-match-preorder-traversal/README.md b/problems/flip-binary-tree-to-match-preorder-traversal/README.md index 00e9baf57..516b4670a 100644 --- a/problems/flip-binary-tree-to-match-preorder-traversal/README.md +++ b/problems/flip-binary-tree-to-match-preorder-traversal/README.md @@ -11,62 +11,49 @@ ## [971. Flip Binary Tree To Match Preorder Traversal (Medium)](https://leetcode.com/problems/flip-binary-tree-to-match-preorder-traversal "翻转二叉树以匹配先序遍历") -

    Given a binary tree with N nodes, each node has a different value from {1, ..., N}.

    +

    You are given the root of a binary tree with n nodes, each node has a different value from 1 to n. You are also given a sequence of n values voyage, reported by a preorder traversal starting from the root.

    -

    A node in this binary tree can be flipped by swapping the left child and the right child of that node.

    +

    A node in this binary tree can be flipped by swapping its left child and its right child.

    -

    Consider the sequence of N values reported by a preorder traversal starting from the root.  Call such a sequence of N values the voyage of the tree.

    +

    Flip the least number of nodes in the tree so that the preorder traversal of the tree matches voyage.

    -

    (Recall that a preorder traversal of a node means we report the current node's value, then preorder-traverse the left child, then preorder-traverse the right child.)

    +

    Return a list of the values of all nodes flipped. You may return the answer in any order. If we cannot flip the nodes in the tree to obtain voyage, return the list [-1].

    -

    Our goal is to flip the least number of nodes in the tree so that the voyage of the tree matches the voyage we are given.

    - -

    If we can do so, then return a list of the values of all nodes flipped.  You may return the answer in any order.

    - -

    If we cannot do so, then return the list [-1].

    +

    The preorder traversal of a node means we report the current node's value, then preorder-traverse the left child, then preorder-traverse the right child.

     

    - -

    Example 1:

    - -

    - +
    -Input: root = [1,2], voyage = [2,1]
    -Output: [-1]
    +Input: root = [1,2], voyage = [2,1]
    +Output: [-1]
     
    -

    Example 2:

    - -

    - +
    -Input: root = [1,2,3], voyage = [1,3,2]
    -Output: [1]
    +Input: root = [1,2,3], voyage = [1,3,2]
    +Output: [1]
     
    -

    Example 3:

    - -

    - +
    -Input: root = [1,2,3], voyage = [1,2,3]
    -Output: []
    +Input: root = [1,2,3], voyage = [1,2,3]
    +Output: []
     

     

    - -

    Note:

    - -
      -
    1. 1 <= N <= 100
    2. -
    -
    -
    -
    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is n.
    • +
    • n == voyage.length
    • +
    • 1 <= n <= 100
    • +
    • 1 <= Node.val, voyage[i] <= n
    • +
    • All the values of the tree are unique.
    • +
    • All the values of voyage are unique.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/graph-connectivity-with-threshold/README.md b/problems/graph-connectivity-with-threshold/README.md index af423892c..d06698eea 100644 --- a/problems/graph-connectivity-with-threshold/README.md +++ b/problems/graph-connectivity-with-threshold/README.md @@ -19,7 +19,7 @@
  • z > threshold.
  • -

    Given the two integers, n and threshold, and an array of queries, you must determine for each queries[i] = [ai, bi] if cities ai and bi are connected (i.e. there is some path between them).

    +

    Given the two integers, n and threshold, and an array of queries, you must determine for each queries[i] = [ai, bi] if cities ai and bi are connected directly or indirectly. (i.e. there is some path between them).

    Return an array answer, where answer.length == queries.length and answer[i] is true if for the ith query, there is a path between ai and bi, or answer[i] is false if there is no path.

    diff --git a/problems/hopper-company-queries-i/README.md b/problems/hopper-company-queries-i/README.md index db0348089..64e586468 100644 --- a/problems/hopper-company-queries-i/README.md +++ b/problems/hopper-company-queries-i/README.md @@ -9,6 +9,6 @@                  [Next >](../sort-array-by-increasing-frequency "Sort Array by Increasing Frequency") -## [1635. Hopper Company Queries I (Hard)](https://leetcode.com/problems/hopper-company-queries-i "") +## [1635. Hopper Company Queries I (Hard)](https://leetcode.com/problems/hopper-company-queries-i "Hopper 公司查询 I") diff --git a/problems/is-subsequence/README.md b/problems/is-subsequence/README.md index 0155e185f..7675c6b1e 100644 --- a/problems/is-subsequence/README.md +++ b/problems/is-subsequence/README.md @@ -11,15 +11,9 @@ ## [392. Is Subsequence (Easy)](https://leetcode.com/problems/is-subsequence "判断子序列") -

    Given a string s and a string t, check if s is subsequence of t.

    +

    Given two strings s and t, check if s is a subsequence of t.

    -

    A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, "ace" is a subsequence of "abcde" while "aec" is not).

    - -

    Follow up:
    -If there are lots of incoming S, say S1, S2, ... , Sk where k >= 1B, and you want to check one by one to see if T has its subsequence. In this scenario, how would you change your code?

    - -

    Credits:
    -Special thanks to @pbrother for adding this problem and creating all test cases.

    +

    A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ace" is a subsequence of "abcde" while "aec" is not).

     

    Example 1:

    @@ -34,10 +28,13 @@ Special thanks to @pbrother for add
    • 0 <= s.length <= 100
    • -
    • 0 <= t.length <= 10^4
    • -
    • Both strings consists only of lowercase characters.
    • +
    • 0 <= t.length <= 104
    • +
    • s and t consist only of lowercase English letters.
    +

     

    +Follow up: If there are lots of incoming s, say s1, s2, ..., sk where k >= 109, and you want to check one by one to see if t has its subsequence. In this scenario, how would you change your code? + ### Related Topics [[Greedy](../../tag/greedy/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/kth-smallest-element-in-a-sorted-matrix/README.md b/problems/kth-smallest-element-in-a-sorted-matrix/README.md index ae807bcb4..b9418780d 100644 --- a/problems/kth-smallest-element-in-a-sorted-matrix/README.md +++ b/problems/kth-smallest-element-in-a-sorted-matrix/README.md @@ -11,27 +11,37 @@ ## [378. Kth Smallest Element in a Sorted Matrix (Medium)](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix "有序矩阵中第K小的元素") -

    Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.

    +

    Given an n x n matrix where each of the rows and columns are sorted in ascending order, return the kth smallest element in the matrix.

    -

    -Note that it is the kth smallest element in the sorted order, not the kth distinct element. -

    +

    Note that it is the kth smallest element in the sorted order, not the kth distinct element.

    + +

     

    +

    Example 1:

    + +
    +Input: matrix = [[1,5,9],[10,11,13],[12,13,15]], k = 8
    +Output: 13
    +Explanation: The elements in the matrix are [1,5,9,10,11,12,13,13,15], and the 8th largest number is 13
    +
    + +

    Example 2:

    -

    Example:

    -matrix = [
    -   [ 1,  5,  9],
    -   [10, 11, 13],
    -   [12, 13, 15]
    -],
    -k = 8,
    -
    -return 13.
    +Input: matrix = [[-5]], k = 1
    +Output: -5
     
    -

    -

    Note:
    -You may assume k is always valid, 1 ≤ k ≤ n2.

    +

     

    +

    Constraints:

    + +
      +
    • n == matrix.length
    • +
    • n == matrix[i].length
    • +
    • 1 <= n <= 300
    • +
    • -109 <= matrix[i][j] <= -109
    • +
    • All the rows and columns of matrix are guaranteed to be sorted in non-degreasing order.
    • +
    • 1 <= k <= n2
    • +
    ### Related Topics [[Heap](../../tag/heap/README.md)] diff --git a/problems/least-operators-to-express-number/README.md b/problems/least-operators-to-express-number/README.md index f50bba289..d85bbf369 100644 --- a/problems/least-operators-to-express-number/README.md +++ b/problems/least-operators-to-express-number/README.md @@ -11,65 +11,55 @@ ## [964. Least Operators to Express Number (Hard)](https://leetcode.com/problems/least-operators-to-express-number "表示数字的最少运算符") -

    Given a single positive integer x, we will write an expression of the form x (op1) x (op2) x (op3) x ... where each operator op1, op2, etc. is either addition, subtraction, multiplication, or division (+, -, *, or /).  For example, with x = 3, we might write 3 * 3 / 3 + 3 - 3 which is a value of 3.

    +

    Given a single positive integer x, we will write an expression of the form x (op1) x (op2) x (op3) x ... where each operator op1, op2, etc. is either addition, subtraction, multiplication, or division (+, -, *, or /). For example, with x = 3, we might write 3 * 3 / 3 + 3 - 3 which is a value of 3.

    When writing such an expression, we adhere to the following conventions:

    -
      +
      • The division operator (/) returns rational numbers.
      • There are no parentheses placed anywhere.
      • -
      • We use the usual order of operations: multiplication and division happens before addition and subtraction.
      • -
      • It's not allowed to use the unary negation operator (-).  For example, "x - x" is a valid expression as it only uses subtraction, but "-x + x" is not because it uses negation.
      • -
    +
  • We use the usual order of operations: multiplication and division happen before addition and subtraction.
  • +
  • It is not allowed to use the unary negation operator (-). For example, "x - x" is a valid expression as it only uses subtraction, but "-x + x" is not because it uses negation.
  • + -

    We would like to write an expression with the least number of operators such that the expression equals the given target.  Return the least number of operators used.

    +

    We would like to write an expression with the least number of operators such that the expression equals the given target. Return the least number of operators used.

     

    - -

    Example 1:

    -Input: x = 3, target = 19
    -Output: 5
    -Explanation: 3 * 3 + 3 * 3 + 3 / 3.  The expression contains 5 operations.
    +Input: x = 3, target = 19
    +Output: 5
    +Explanation: 3 * 3 + 3 * 3 + 3 / 3.
    +The expression contains 5 operations.
     

    Example 2:

    -
    -Input: x = 5, target = 501
    -Output: 8
    -Explanation: 5 * 5 * 5 * 5 - 5 * 5 * 5 + 5 / 5.  The expression contains 8 operations.
    +Input: x = 5, target = 501
    +Output: 8
    +Explanation: 5 * 5 * 5 * 5 - 5 * 5 * 5 + 5 / 5.
    +The expression contains 8 operations.
     
    -

    Example 3:

    -Input: x = 100, target = 100000000
    -Output: 3
    -Explanation: 100 * 100 * 100 * 100.  The expression contains 3 operations.
    +Input: x = 100, target = 100000000 +Output: 3 +Explanation: 100 * 100 * 100 * 100. +The expression contains 3 operations. +

     

    -
    -
    -
    - -

    Note:

    +

    Constraints:

    • 2 <= x <= 100
    • -
    • 1 <= target <= 2 * 10^8
    • +
    • 1 <= target <= 2 * 108
    -
    -
    -
     
    -
    -
    - ### Related Topics [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/leetflex-banned-accounts/README.md b/problems/leetflex-banned-accounts/README.md new file mode 100644 index 000000000..3977c250a --- /dev/null +++ b/problems/leetflex-banned-accounts/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../maximum-subarray-sum-after-one-operation "Maximum Subarray Sum After One Operation") +                 +Next > + +## [1747. Leetflex Banned Accounts (Medium)](https://leetcode.com/problems/leetflex-banned-accounts "") + + diff --git a/problems/leetflex-banned-accounts/mysql_schemas.sql b/problems/leetflex-banned-accounts/mysql_schemas.sql new file mode 100644 index 000000000..d9f5775c4 --- /dev/null +++ b/problems/leetflex-banned-accounts/mysql_schemas.sql @@ -0,0 +1,10 @@ +Create table If Not Exists LogInfo (account_id int, ip_address int, login datetime, logout datetime); +Truncate table LogInfo; +insert into LogInfo (account_id, ip_address, login, logout) values ('1', '1', '2021-02-01 09:00:00', '2021-02-01 09:30:00'); +insert into LogInfo (account_id, ip_address, login, logout) values ('1', '2', '2021-02-01 08:00:00', '2021-02-01 11:30:00'); +insert into LogInfo (account_id, ip_address, login, logout) values ('2', '6', '2021-02-01 20:30:00', '2021-02-01 22:00:00'); +insert into LogInfo (account_id, ip_address, login, logout) values ('2', '7', '2021-02-02 20:30:00', '2021-02-02 22:00:00'); +insert into LogInfo (account_id, ip_address, login, logout) values ('3', '9', '2021-02-01 16:00:00', '2021-02-01 16:59:59'); +insert into LogInfo (account_id, ip_address, login, logout) values ('3', '13', '2021-02-01 17:00:00', '2021-02-01 17:59:59'); +insert into LogInfo (account_id, ip_address, login, logout) values ('4', '10', '2021-02-01 16:00:00', '2021-02-01 17:00:00'); +insert into LogInfo (account_id, ip_address, login, logout) values ('4', '11', '2021-02-01 17:00:00', '2021-02-01 17:59:59'); diff --git a/problems/longest-chunked-palindrome-decomposition/README.md b/problems/longest-chunked-palindrome-decomposition/README.md index d2b9239a5..af24912aa 100644 --- a/problems/longest-chunked-palindrome-decomposition/README.md +++ b/problems/longest-chunked-palindrome-decomposition/README.md @@ -11,14 +11,16 @@ ## [1147. Longest Chunked Palindrome Decomposition (Hard)](https://leetcode.com/problems/longest-chunked-palindrome-decomposition "段式回文") -

    Return the largest possible k such that there exists a_1, a_2, ..., a_k such that:

    +

    You are given a string text. You should split it to k substrings (subtext1, subtext2, ..., subtextk) such that:

      -
    • Each a_i is a non-empty string;
    • -
    • Their concatenation a_1 + a_2 + ... + a_k is equal to text;
    • -
    • For all 1 <= i <= k,  a_i = a_{k+1 - i}.
    • +
    • subtexti is a non-empty string.
    • +
    • The concatenation of all the substrings is equal to text (i.e., subtext1 + subtext2 + ... + subtextk == text).
    • +
    • subtexti == subtextk - i + 1 for all valid values of i (i.e., 1 <= i <= k).
    +

    Return the largest possible value of k.

    +

     

    Example 1:

    @@ -56,8 +58,8 @@

    Constraints:

      -
    • text consists only of lowercase English characters.
    • 1 <= text.length <= 1000
    • +
    • text consists only of lowercase English characters.
    ### Related Topics diff --git a/problems/longest-palindromic-substring/README.md b/problems/longest-palindromic-substring/README.md index c5f43fee2..397658072 100644 --- a/problems/longest-palindromic-substring/README.md +++ b/problems/longest-palindromic-substring/README.md @@ -70,7 +70,7 @@ How can we reuse a previously computed palindrome to compute a larger palindrome
    Hint 2 -If “aba” is a palindrome, is “xabax” and palindrome? Similarly is “xabay” a palindrome? +If “aba” is a palindrome, is “xabax” a palindrome? Similarly is “xabay” a palindrome?
    diff --git a/problems/making-a-large-island/README.md b/problems/making-a-large-island/README.md index 927a173d4..f92380080 100644 --- a/problems/making-a-large-island/README.md +++ b/problems/making-a-large-island/README.md @@ -11,14 +11,17 @@ ## [827. Making A Large Island (Hard)](https://leetcode.com/problems/making-a-large-island "最大人工岛") -

    In a 2D grid of 0s and 1s, we change at most one 0 to a 1.

    +

    You are given an n x n binary matrix grid. You are allowed to change at most one 0 to be 1.

    -

    After, what is the size of the largest island? (An island is a 4-directionally connected group of 1s).

    +

    Return the size of the largest island in grid after applying this operation.

    +

    An island is a 4-directionally connected group of 1s.

    + +

     

    Example 1:

    -Input: [[1, 0], [0, 1]]
    +Input: grid = [[1,0],[0,1]]
     Output: 3
     Explanation: Change one 0 to 1 and connect two 1s, then we get an island with area = 3.
     
    @@ -26,27 +29,28 @@

    Example 2:

    -Input: [[1, 1], [1, 0]]
    +Input: grid = [[1,1],[1,0]]
     Output: 4
     Explanation: Change the 0 to 1 and make the island bigger, only one island with area = 4.

    Example 3:

    -Input: [[1, 1], [1, 1]]
    +Input: grid = [[1,1],[1,1]]
     Output: 4
    -Explanation: Can't change any 0 to 1, only one island with area = 4.
    +Explanation: Can't change any 0 to 1, only one island with area = 4. +

     

    - -

    Notes:

    +

    Constraints:

      -
    • 1 <= grid.length = grid[0].length <= 50.
    • -
    • 0 <= grid[i][j] <= 1.
    • +
    • n == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= n <= 500
    • +
    • grid[i][j] is either 0 or 1.
    -

     

    - ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/maximum-number-of-balls-in-a-box/README.md b/problems/maximum-number-of-balls-in-a-box/README.md new file mode 100644 index 000000000..2d9649821 --- /dev/null +++ b/problems/maximum-number-of-balls-in-a-box/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../find-total-time-spent-by-each-employee "Find Total Time Spent by Each Employee") +                 +[Next >](../restore-the-array-from-adjacent-pairs "Restore the Array From Adjacent Pairs") + +## [1742. Maximum Number of Balls in a Box (Easy)](https://leetcode.com/problems/maximum-number-of-balls-in-a-box "盒子中小球的最大数量") + +

    You are working in a ball factory where you have n balls numbered from lowLimit up to highLimit inclusive (i.e., n == highLimit - lowLimit + 1), and an infinite number of boxes numbered from 1 to infinity.

    + +

    Your job at this factory is to put each ball in the box with a number equal to the sum of digits of the ball's number. For example, the ball number 321 will be put in the box number 3 + 2 + 1 = 6 and the ball number 10 will be put in the box number 1 + 0 = 1.

    + +

    Given two integers lowLimit and highLimit, return the number of balls in the box with the most balls.

    + +

     

    +

    Example 1:

    + +
    +Input: lowLimit = 1, highLimit = 10
    +Output: 2
    +Explanation:
    +Box Number:  1 2 3 4 5 6 7 8 9 10 11 ...
    +Ball Count:  2 1 1 1 1 1 1 1 1 0  0  ...
    +Box 1 has the most number of balls with 2 balls.
    + +

    Example 2:

    + +
    +Input: lowLimit = 5, highLimit = 15
    +Output: 2
    +Explanation:
    +Box Number:  1 2 3 4 5 6 7 8 9 10 11 ...
    +Ball Count:  1 1 1 1 2 2 1 1 1 0  0  ...
    +Boxes 5 and 6 have the most number of balls with 2 balls in each.
    +
    + +

    Example 3:

    + +
    +Input: lowLimit = 19, highLimit = 28
    +Output: 2
    +Explanation:
    +Box Number:  1 2 3 4 5 6 7 8 9 10 11 12 ...
    +Ball Count:  0 1 1 1 1 1 1 1 1 2  0  0  ...
    +Box 10 has the most number of balls with 2 balls.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= lowLimit <= highLimit <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Note that both lowLimit and highLimit are of small constraints so you can iterate on all nubmer between them +
    + +
    +Hint 2 +You can simulate the boxes by counting for each box the number of balls with digit sum equal to that box number +
    diff --git a/problems/maximum-profit-in-job-scheduling/README.md b/problems/maximum-profit-in-job-scheduling/README.md index 9201f646b..dc099fba5 100644 --- a/problems/maximum-profit-in-job-scheduling/README.md +++ b/problems/maximum-profit-in-job-scheduling/README.md @@ -11,11 +11,11 @@ ## [1235. Maximum Profit in Job Scheduling (Hard)](https://leetcode.com/problems/maximum-profit-in-job-scheduling "规划兼职工作") -

    We have n jobs, where every job is scheduled to be done from startTime[i] to endTime[i], obtaining a profit of profit[i].

    +

    We have n jobs, where every job is scheduled to be done from startTime[i] to endTime[i], obtaining a profit of profit[i].

    -

    You're given the startTime , endTime and profit arrays, you need to output the maximum profit you can take such that there are no 2 jobs in the subset with overlapping time range.

    +

    You're given the startTime, endTime and profit arrays, return the maximum profit you can take such that there are no two jobs in the subset with overlapping time range.

    -

    If you choose a job that ends at time X you will be able to start another job that starts at time X.

    +

    If you choose a job that ends at time X you will be able to start another job that starts at time X.

     

    Example 1:

    @@ -34,8 +34,7 @@ Time range [1-3]+[3-6] , we get profit of 120 = 50 + 70.

    -
    -Input: startTime = [1,2,3,4,6], endTime = [3,5,10,6,9], profit = [20,20,100,70,60]
    +Input: startTime = [1,2,3,4,6], endTime = [3,5,10,6,9], profit = [20,20,100,70,60]
     Output: 150
     Explanation: The subset chosen is the first, fourth and fifth job. 
     Profit obtained 150 = 20 + 70 + 60.
    @@ -54,9 +53,9 @@ Profit obtained 150 = 20 + 70 + 60.
     

    Constraints:

      -
    • 1 <= startTime.length == endTime.length == profit.length <= 5 * 10^4
    • -
    • 1 <= startTime[i] < endTime[i] <= 10^9
    • -
    • 1 <= profit[i] <= 10^4
    • +
    • 1 <= startTime.length == endTime.length == profit.length <= 5 * 104
    • +
    • 1 <= startTime[i] < endTime[i] <= 109
    • +
    • 1 <= profit[i] <= 104
    ### Related Topics diff --git a/problems/maximum-subarray-sum-after-one-operation/README.md b/problems/maximum-subarray-sum-after-one-operation/README.md new file mode 100644 index 000000000..4a219af0b --- /dev/null +++ b/problems/maximum-subarray-sum-after-one-operation/README.md @@ -0,0 +1,33 @@ + + + + + + + +[< Previous](../palindrome-partitioning-iv "Palindrome Partitioning IV") +                 +[Next >](../leetflex-banned-accounts "Leetflex Banned Accounts") + +## [1746. Maximum Subarray Sum After One Operation (Medium)](https://leetcode.com/problems/maximum-subarray-sum-after-one-operation "") + + + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Think about dynamic programming +
    + +
    +Hint 2 +Define an array dp[nums.length][2], where dp[i][0] is the max subarray sum including nums[i] and without squaring any element. +
    + +
    +Hint 3 +dp[i][1] is the max subarray sum including nums[i] and having only one element squared. +
    diff --git a/problems/merge-two-binary-trees/README.md b/problems/merge-two-binary-trees/README.md index 36437c476..c90fcfc5e 100644 --- a/problems/merge-two-binary-trees/README.md +++ b/problems/merge-two-binary-trees/README.md @@ -11,32 +11,36 @@ ## [617. Merge Two Binary Trees (Easy)](https://leetcode.com/problems/merge-two-binary-trees "合并二叉树") -

    Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.

    +

    You are given two binary trees root1 and root2.

    -

    You need to merge them into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new value of the merged node. Otherwise, the NOT null node will be used as the node of new tree.

    +

    Imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge the two trees into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new value of the merged node. Otherwise, the NOT null node will be used as the node of the new tree.

    -

    Example 1:

    +

    Return the merged tree.

    + +

    Note: The merging process must start from the root nodes of both trees.

    + +

     

    +

    Example 1:

    + +
    +Input: root1 = [1,3,2,5], root2 = [2,1,3,null,4,null,7]
    +Output: [3,4,5,5,4,null,7]
    +
    + +

    Example 2:

    -Input: 
    -	Tree 1                     Tree 2                  
    -          1                         2                             
    -         / \                       / \                            
    -        3   2                     1   3                        
    -       /                           \   \                      
    -      5                             4   7                  
    -Output: 
    -Merged tree:
    -	     3
    -	    / \
    -	   4   5
    -	  / \   \ 
    -	 5   4   7
    +Input: root1 = [1], root2 = [1,2]
    +Output: [2,2]
     

     

    +

    Constraints:

    -

    Note: The merging process must start from the root nodes of both trees.

    +
      +
    • The number of nodes in both trees is in the range [0, 2000].
    • +
    • -104 <= Node.val <= 104
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/minimum-distance-between-bst-nodes/README.md b/problems/minimum-distance-between-bst-nodes/README.md index be7bc9ceb..cd41946ba 100644 --- a/problems/minimum-distance-between-bst-nodes/README.md +++ b/problems/minimum-distance-between-bst-nodes/README.md @@ -11,37 +11,36 @@ ## [783. Minimum Distance Between BST Nodes (Easy)](https://leetcode.com/problems/minimum-distance-between-bst-nodes "二叉搜索树节点最小距离") -

    Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the values of any two different nodes in the tree.

    +

    Given the root of a Binary Search Tree (BST), return the minimum difference between the values of any two different nodes in the tree.

    -

    Example :

    +

    Note: This question is the same as 530: https://leetcode.com/problems/minimum-absolute-difference-in-bst/

    +

     

    +

    Example 1:

    +
    -Input: root = [4,2,6,1,3,null,null]
    +Input: root = [4,2,6,1,3]
     Output: 1
    -Explanation:
    -Note that root is a TreeNode object, not an array.
    -
    -The given tree [4,2,6,1,3,null,null] is represented by the following diagram:
    -
    -          4
    -        /   \
    -      2      6
    -     / \    
    -    1   3  
    +
    -while the minimum difference in this tree is 1, it occurs between node 1 and node 2, also between node 3 and node 2. +

    Example 2:

    + +
    +Input: root = [1,0,48,null,null,12,49]
    +Output: 1
     
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. The size of the BST will be between 2 and 100.
    2. -
    3. The BST is always valid, each node's value is an integer, and each node's value is different.
    4. -
    5. This question is the same as 530: https://leetcode.com/problems/minimum-absolute-difference-in-bst/
    6. -
    +
      +
    • The number of nodes in the tree is in the range [2, 100].
    • +
    • 0 <= Node.val <= 105
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Recursion](../../tag/recursion/README.md)] ### Similar Questions diff --git a/problems/minimum-falling-path-sum/README.md b/problems/minimum-falling-path-sum/README.md index 2d1e6e612..61ac1658f 100644 --- a/problems/minimum-falling-path-sum/README.md +++ b/problems/minimum-falling-path-sum/README.md @@ -11,35 +11,47 @@ ## [931. Minimum Falling Path Sum (Medium)](https://leetcode.com/problems/minimum-falling-path-sum "下降路径最小和") -

    Given a square array of integers A, we want the minimum sum of a falling path through A.

    +

    Given an n x n array of integers matrix, return the minimum sum of any falling path through matrix.

    -

    A falling path starts at any element in the first row, and chooses one element from each row.  The next row's choice must be in a column that is different from the previous row's column by at most one.

    +

    A falling path starts at any element in the first row and chooses the element in the next row that is either directly below or diagonally left/right. Specifically, the next element from position (row, col) will be (row + 1, col - 1), (row + 1, col), or (row + 1, col + 1).

     

    -

    Example 1:

    -Input: [[1,2,3],[4,5,6],[7,8,9]]
    -Output: 12
    -Explanation: 
    -The possible falling paths are:
    +Input: matrix = [[2,1,3],[6,5,4],[7,8,9]]
    +Output: 13
    +Explanation: There are two falling paths with a minimum sum underlined below:
    +[[2,1,3],      [[2,1,3],
    + [6,5,4],       [6,5,4],
    + [7,8,9]]       [7,8,9]]
     
    -
      -
    • [1,4,7], [1,4,8], [1,5,7], [1,5,8], [1,5,9]
    • -
    • [2,4,7], [2,4,8], [2,5,7], [2,5,8], [2,5,9], [2,6,8], [2,6,9]
    • -
    • [3,5,7], [3,5,8], [3,5,9], [3,6,8], [3,6,9]
    • -
    +

    Example 2:

    -

    The falling path with the smallest sum is [1,4,7], so the answer is 12.

    +
    +Input: matrix = [[-19,57],[-40,-5]]
    +Output: -59
    +Explanation: The falling path with a minimum sum is underlined below:
    +[[-19,57],
    + [-40,-5]]
    +
    + +

    Example 3:

    + +
    +Input: matrix = [[-48]]
    +Output: -48
    +

     

    Constraints:

      -
    • 1 <= A.length == A[0].length <= 100
    • -
    • -100 <= A[i][j] <= 100
    • +
    • n == matrix.length
    • +
    • n == matrix[i].length
    • +
    • 1 <= n <= 100
    • +
    • -100 <= matrix[i][j] <= 100
    ### Related Topics diff --git a/problems/minimum-size-subarray-sum/README.md b/problems/minimum-size-subarray-sum/README.md index ea6678920..d24b88532 100644 --- a/problems/minimum-size-subarray-sum/README.md +++ b/problems/minimum-size-subarray-sum/README.md @@ -11,18 +11,42 @@ ## [209. Minimum Size Subarray Sum (Medium)](https://leetcode.com/problems/minimum-size-subarray-sum "长度最小的子数组") -

    Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't one, return 0 instead.

    +

    Given an array of positive integers nums and a positive integer target, return the minimal length of a contiguous subarray [numsl, numsl+1, ..., numsr-1, numsr] of which the sum is greater than or equal to target. If there is no such subarray, return 0 instead.

    -

    Example: 

    +

     

    +

    Example 1:

    -Input: s = 7, nums = [2,3,1,2,4,3]
    +Input: target = 7, nums = [2,3,1,2,4,3]
     Output: 2
    -Explanation: the subarray [4,3] has the minimal length under the problem constraint.
    +Explanation: The subarray [4,3] has the minimal length under the problem constraint. +
    -
    Follow up:
    +

    Example 2:

    -
    If you have figured out the O(n) solution, try coding another solution of which the time complexity is O(n log n). 
    +
    +Input: target = 4, nums = [1,4,4]
    +Output: 1
    +
    + +

    Example 3:

    + +
    +Input: target = 11, nums = [1,1,1,1,1,1,1,1]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= target <= 109
    • +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 105
    • +
    + +

     

    +Follow up: If you have figured out the O(n) solution, try coding another solution of which the time complexity is O(n log(n)). ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/number-of-calls-between-two-persons/README.md b/problems/number-of-calls-between-two-persons/README.md index 0a6b30900..383969902 100644 --- a/problems/number-of-calls-between-two-persons/README.md +++ b/problems/number-of-calls-between-two-persons/README.md @@ -9,6 +9,6 @@                  [Next >](../number-of-students-unable-to-eat-lunch "Number of Students Unable to Eat Lunch") -## [1699. Number of Calls Between Two Persons (Medium)](https://leetcode.com/problems/number-of-calls-between-two-persons "") +## [1699. Number of Calls Between Two Persons (Medium)](https://leetcode.com/problems/number-of-calls-between-two-persons "两人之间的通话次数") diff --git a/problems/numbers-with-same-consecutive-differences/README.md b/problems/numbers-with-same-consecutive-differences/README.md index ce80e4f3c..5bb16a766 100644 --- a/problems/numbers-with-same-consecutive-differences/README.md +++ b/problems/numbers-with-same-consecutive-differences/README.md @@ -23,7 +23,7 @@
     Input: n = 3, k = 7
     Output: [181,292,707,818,929]
    -Explanation: Note that 070 is not a valid number, because it has leading zeroes.
    +Explanation: Note that 070 is not a valid number, because it has leading zeroes.
     

    Example 2:

    @@ -42,13 +42,6 @@

    Example 4:

    -
    -Input: n = 2, k = 1
    -Output: [10,12,21,23,32,34,43,45,54,56,65,67,76,78,87,89,98]
    -
    - -

    Example 5:

    -
     Input: n = 2, k = 2
     Output: [13,20,24,31,35,42,46,53,57,64,68,75,79,86,97]
    diff --git a/problems/paint-house-iii/README.md b/problems/paint-house-iii/README.md
    index 6bc7167c3..a17042736 100644
    --- a/problems/paint-house-iii/README.md
    +++ b/problems/paint-house-iii/README.md
    @@ -9,7 +9,7 @@
                     
     [Next >](../delete-n-nodes-after-m-nodes-of-a-linked-list "Delete N Nodes After M Nodes of a Linked List")
     
    -## [1473. Paint House III (Hard)](https://leetcode.com/problems/paint-house-iii "给房子涂色 III")
    +## [1473. Paint House III (Hard)](https://leetcode.com/problems/paint-house-iii "粉刷房子 III")
     
     

    There is a row of m houses in a small city, each house must be painted with one of the n colors (labeled from 1 to n), some houses that has been painted last summer should not be painted again.

    diff --git a/problems/palindrome-partitioning-iv/README.md b/problems/palindrome-partitioning-iv/README.md new file mode 100644 index 000000000..e5baddac7 --- /dev/null +++ b/problems/palindrome-partitioning-iv/README.md @@ -0,0 +1,56 @@ + + + + + + + +[< Previous](../can-you-eat-your-favorite-candy-on-your-favorite-day "Can You Eat Your Favorite Candy on Your Favorite Day?") +                 +[Next >](../maximum-subarray-sum-after-one-operation "Maximum Subarray Sum After One Operation") + +## [1745. Palindrome Partitioning IV (Hard)](https://leetcode.com/problems/palindrome-partitioning-iv "回文串分割 IV") + +

    Given a string s, return true if it is possible to split the string s into three non-empty palindromic substrings. Otherwise, return false.​​​​​

    + +

    A string is said to be palindrome if it the same string when reversed.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "abcbdd"
    +Output: true
    +Explanation: "abcbdd" = "a" + "bcb" + "dd", and all three substrings are palindromes.
    +
    + +

    Example 2:

    + +
    +Input: s = "bcbddxy"
    +Output: false
    +Explanation: s cannot be split into 3 palindromes.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= s.length <= 2000
    • +
    • s​​​​​​ consists only of lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Preprocess checking palindromes in O(1) +
    + +
    +Hint 2 +Note that one string is a prefix and another one is a suffix you can try brute forcing the rest +
    diff --git a/problems/partition-list/README.md b/problems/partition-list/README.md index dbfa30257..fc0ea514d 100644 --- a/problems/partition-list/README.md +++ b/problems/partition-list/README.md @@ -34,7 +34,7 @@

    Constraints:

      -
    • The number of nodes in the tree is in the range [0, 200].
    • +
    • The number of nodes in the list is in the range [0, 200].
    • -100 <= Node.val <= 100
    • -200 <= x <= 200
    diff --git a/problems/powerful-integers/README.md b/problems/powerful-integers/README.md index 23a348d75..92b9a3fc2 100644 --- a/problems/powerful-integers/README.md +++ b/problems/powerful-integers/README.md @@ -9,50 +9,43 @@                  [Next >](../flip-binary-tree-to-match-preorder-traversal "Flip Binary Tree To Match Preorder Traversal") -## [970. Powerful Integers (Easy)](https://leetcode.com/problems/powerful-integers "强整数") +## [970. Powerful Integers (Medium)](https://leetcode.com/problems/powerful-integers "强整数") -

    Given two positive integers x and y, an integer is powerful if it is equal to x^i + y^j for some integers i >= 0 and j >= 0.

    +

    Given three integers x, y, and bound, return a list of all the powerful integers that have a value less than or equal to bound.

    -

    Return a list of all powerful integers that have value less than or equal to bound.

    +

    An integer is powerful if it can be represented as xi + yj for some integers i >= 0 and j >= 0.

    -

    You may return the answer in any order.  In your answer, each value should occur at most once.

    +

    You may return the answer in any order. In your answer, each value should occur at most once.

     

    - -

    Example 1:

    -Input: x = 2, y = 3, bound = 10
    -Output: [2,3,4,5,7,9,10]
    -Explanation: 
    -2 = 2^0 + 3^0
    -3 = 2^1 + 3^0
    -4 = 2^0 + 3^1
    -5 = 2^1 + 3^1
    -7 = 2^2 + 3^1
    -9 = 2^3 + 3^0
    -10 = 2^0 + 3^2
    +Input: x = 2, y = 3, bound = 10
    +Output: [2,3,4,5,7,9,10]
    +Explanation:
    +2 = 20 + 30
    +3 = 21 + 30
    +4 = 20 + 31
    +5 = 21 + 31
    +7 = 22 + 31
    +9 = 23 + 30
    +10 = 20 + 32
     
    -

    Example 2:

    -Input: x = 3, y = 5, bound = 15
    -Output: [2,4,6,8,10,14]
    +Input: x = 3, y = 5, bound = 15
    +Output: [2,4,6,8,10,14]
     
    -
    -

     

    - -

    Note:

    +

    Constraints:

      -
    • 1 <= x <= 100
    • -
    • 1 <= y <= 100
    • -
    • 0 <= bound <= 10^6
    • +
    • 1 <= x, y <= 100
    • +
    • 0 <= bound <= 106
    ### Related Topics diff --git a/problems/reachable-nodes-in-subdivided-graph/README.md b/problems/reachable-nodes-in-subdivided-graph/README.md index 1fd1fb599..8a03d37f9 100644 --- a/problems/reachable-nodes-in-subdivided-graph/README.md +++ b/problems/reachable-nodes-in-subdivided-graph/README.md @@ -11,15 +11,15 @@ ## [882. Reachable Nodes In Subdivided Graph (Hard)](https://leetcode.com/problems/reachable-nodes-in-subdivided-graph "细分图中的可到达结点") -

    You are given an undirected graph (the "original graph") with n nodes labeled from 0 to n - 1, subdivisions are made to some of the edges.

    +

    You are given an undirected graph (the "original graph") with n nodes labeled from 0 to n - 1. You decide to subdivide each edge in the graph into a chain of nodes, with the number of new nodes varying between each edge.

    -

    The graph is given as an array of edges where edges[i] = [ui, vi, cnti] indicates that there is an edge between nodes ui and vi in the original graph, and cnti is the total number of new nodes on that edge.

    +

    The graph is given as a 2D array of edges where edges[i] = [ui, vi, cnti] indicates that there is an edge between nodes ui and vi in the original graph, and cnti is the total number of new nodes that you will subdivide the edge into. Note that cnti == 0 means you will not subdivide the edge.

    -

    Then, the edge [ui, vi] is deleted from the original graph, and cnti new nodes (x1, x2, ..., xcnti) are added to the original graph, and cnti + 1 new edges (ui, x1), (x1, x2), (x2, x3), ..., (xcnti - 1 , xcnti), (xcnti, vi) are added to the original graph.

    +

    To subdivide the edge [ui, vi], replace it with (cnti + 1) new edges and cnti new nodes. The new nodes are x1, x2, ..., xcnti, and the new edges are [ui, x1], [x1, x2], [x2, x3], ..., [xcnti+1, xcnti], [xcnti, vi].

    -

    Now, you start at node 0 from the original graph, and in each move, you travel along one edge.

    +

    In this new graph, you want to know how many nodes are reachable from the node 0, where a node is reachable if the distance is maxMoves or less.

    -

    Return the number of nodes you can reach in at most maxMoves moves.

    +

    Given the original graph and maxMoves, return the number of nodes that are reachable from node 0 in the new graph.

     

    Example 1:

    @@ -27,7 +27,8 @@
     Input: edges = [[0,1,10],[0,2,1],[1,2,2]], maxMoves = 6, n = 3
     Output: 13
    -Explanation: The nodes that are reachable in the final graph after maxMoves = 6 moves are indicated above.
    +Explanation: The edge subdivisions are shown in the image above.
    +The nodes that are reachable are highlighted in yellow.
     

    Example 2:

    @@ -42,7 +43,7 @@
     Input: edges = [[1,2,4],[1,4,5],[1,3,1],[2,3,4],[3,4,5]], maxMoves = 17, n = 5
     Output: 1
    -Explanation: The graph is disconnected, you can only reach node 0
    +Explanation: Node 0 is disconnected from the rest of the graph, so only node 0 is reachable.
     

     

    @@ -51,11 +52,11 @@
    • 0 <= edges.length <= min(n * (n - 1) / 2, 104)
    • edges[i].length == 3
    • -
    • 0 <= ui < vi < n
    • +
    • 0 <= ui < vi < n
    • There are no multiple edges in the graph.
    • 0 <= cnti <= 104
    • 0 <= maxMoves <= 109
    • -
    • 1 <= n <= 3000
    • +
    • 1 <= n <= 3000
    ### Related Topics diff --git a/problems/reorder-data-in-log-files/README.md b/problems/reorder-data-in-log-files/README.md index 769d19a18..4da6b2ed1 100644 --- a/problems/reorder-data-in-log-files/README.md +++ b/problems/reorder-data-in-log-files/README.md @@ -11,20 +11,24 @@ ## [937. Reorder Data in Log Files (Easy)](https://leetcode.com/problems/reorder-data-in-log-files "重新排列日志文件") -

    You have an array of logs. Each log is a space-delimited string of words.

    +

    You are given an array of logs. Each log is a space-delimited string of words, where the first word is the identifier.

    -

    For each log, the first word in each log is an alphanumeric identifier. Then, either:

    +

    There are two types of logs:

      -
    • Each word after the identifier will consist only of lowercase letters, or;
    • -
    • Each word after the identifier will consist only of digits.
    • +
    • Letter-logs: All words (except the identifier) consist of lowercase English letters.
    • +
    • Digit-logs: All words (except the identifier) consist of digits.
    -

    We will call these two varieties of logs letter-logs and digit-logs. It is guaranteed that each log has at least one word after its identifier.

    +

    Reorder these logs so that:

    -

    Reorder the logs so that all of the letter-logs come before any digit-log. The letter-logs are ordered lexicographically, ignoring identifiers, with the identifier used in case of ties. The digit-logs should be put in their original order.

    +
      +
    1. The letter-logs come before all digit-logs.
    2. +
    3. The letter-logs are sorted lexicographically by their contents. If their contents are the same, then sort them lexicographically by their identifiers.
    4. +
    5. The digit-logs maintain their relative ordering.
    6. +
    -

    Return the final order of the logs.

    +

    Return the final order of the logs.

     

    Example 1:

    @@ -32,6 +36,9 @@
     Input: logs = ["dig1 8 1 5 1","let1 art can","dig2 3 6","let2 own kit dig","let3 art zero"]
     Output: ["let1 art can","let3 art zero","let2 own kit dig","dig1 8 1 5 1","dig2 3 6"]
    +Explanation:
    +The letter-log contents are all different, so their ordering is "art can", "art zero", "own kit dig".
    +The digit-logs have a relative order of "dig1 8 1 5 1", "dig2 3 6".
     

    Example 2:

    @@ -47,8 +54,8 @@
    • 1 <= logs.length <= 100
    • 3 <= logs[i].length <= 100
    • -
    • All the tokens of logs[i] are separated by single spaces.
    • -
    • logs[i] is guaranteed to have an identifier and a word after the identifier.
    • +
    • All the tokens of logs[i] are separated by a single space.
    • +
    • logs[i] is guaranteed to have an identifier and at least one word after the identifier.
    ### Related Topics diff --git a/problems/restore-the-array-from-adjacent-pairs/README.md b/problems/restore-the-array-from-adjacent-pairs/README.md new file mode 100644 index 000000000..2e6e2c38a --- /dev/null +++ b/problems/restore-the-array-from-adjacent-pairs/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../maximum-number-of-balls-in-a-box "Maximum Number of Balls in a Box") +                 +[Next >](../can-you-eat-your-favorite-candy-on-your-favorite-day "Can You Eat Your Favorite Candy on Your Favorite Day?") + +## [1743. Restore the Array From Adjacent Pairs (Medium)](https://leetcode.com/problems/restore-the-array-from-adjacent-pairs "从相邻元素对还原数组") + +

    There is an integer array nums that consists of n unique elements, but you have forgotten it. However, you do remember every pair of adjacent elements in nums.

    + +

    You are given a 2D integer array adjacentPairs of size n - 1 where each adjacentPairs[i] = [ui, vi] indicates that the elements ui and vi are adjacent in nums.

    + +

    It is guaranteed that every adjacent pair of elements nums[i] and nums[i+1] will exist in adjacentPairs, either as [nums[i], nums[i+1]] or [nums[i+1], nums[i]]. The pairs can appear in any order.

    + +

    Return the original array nums. If there are multiple solutions, return any of them.

    + +

     

    +

    Example 1:

    + +
    +Input: adjacentPairs = [[2,1],[3,4],[3,2]]
    +Output: [1,2,3,4]
    +Explanation: This array has all its adjacent pairs in adjacentPairs.
    +Notice that adjacentPairs[i] may not be in left-to-right order.
    +
    + +

    Example 2:

    + +
    +Input: adjacentPairs = [[4,-2],[1,4],[-3,1]]
    +Output: [-2,4,1,-3]
    +Explanation: There can be negative numbers.
    +Another solution is [-3,1,4,-2], which would also be accepted.
    +
    + +

    Example 3:

    + +
    +Input: adjacentPairs = [[100000,-100000]]
    +Output: [100000,-100000]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • nums.length == n
    • +
    • adjacentPairs.length == n - 1
    • +
    • adjacentPairs[i].length == 2
    • +
    • 2 <= n <= 105
    • +
    • -105 <= nums[i], ui, vi <= 105
    • +
    • There exists some nums that has adjacentPairs as its pairs.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Find the first element of nums - it will only appear once in adjacentPairs. +
    + +
    +Hint 2 +The adjacent pairs are like edges of a graph. Perform a depth-first search from the first element. +
    diff --git a/problems/shortest-distance-to-a-character/README.md b/problems/shortest-distance-to-a-character/README.md index c9fb378ac..bebafa834 100644 --- a/problems/shortest-distance-to-a-character/README.md +++ b/problems/shortest-distance-to-a-character/README.md @@ -11,21 +11,21 @@ ## [821. Shortest Distance to a Character (Easy)](https://leetcode.com/problems/shortest-distance-to-a-character "字符的最短距离") -

    Given a string S and a character C, return an array of integers representing the shortest distance from the character C in the string.

    +

    Given a string s and a character c that occurs in s, return an array of integers answer where answer.length == s.length and answer[i] is the shortest distance from s[i] to the character c in s.

    +

     

    Example 1:

    - -
    -Input: S = "loveleetcode", C = 'e'
    -Output: [3, 2, 1, 0, 1, 0, 0, 1, 2, 2, 1, 0]
    +
    Input: s = "loveleetcode", c = "e"
    +Output: [3,2,1,0,1,0,0,1,2,2,1,0]
    +

    Example 2:

    +
    Input: s = "aaab", c = "b"
    +Output: [3,2,1,0]
     
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. S string length is in [1, 10000].
    2. -
    3. C is a single character, and guaranteed to be in string S.
    4. -
    5. All letters in S and C are lowercase.
    6. -
    +
      +
    • 1 <= s.length <= 104
    • +
    • s[i] and c are lowercase English letters.
    • +
    • c occurs at least once in s.
    • +
    diff --git a/problems/shortest-path-to-get-food/README.md b/problems/shortest-path-to-get-food/README.md index 599559db3..770c6f720 100644 --- a/problems/shortest-path-to-get-food/README.md +++ b/problems/shortest-path-to-get-food/README.md @@ -9,7 +9,7 @@                  [Next >](../the-number-of-employees-which-report-to-each-employee "The Number of Employees Which Report to Each Employee") -## [1730. Shortest Path to Get Food (Medium)](https://leetcode.com/problems/shortest-path-to-get-food "") +## [1730. Shortest Path to Get Food (Medium)](https://leetcode.com/problems/shortest-path-to-get-food "获取食物的最短路径") diff --git a/problems/similar-string-groups/README.md b/problems/similar-string-groups/README.md index b7f247746..845237a23 100644 --- a/problems/similar-string-groups/README.md +++ b/problems/similar-string-groups/README.md @@ -38,9 +38,8 @@

    Constraints:

      -
    • 1 <= strs.length <= 100
    • -
    • 1 <= strs[i].length <= 1000
    • -
    • sum(strs[i].length) <= 2 * 104
    • +
    • 1 <= strs.length <= 300
    • +
    • 1 <= strs[i].length <= 300
    • strs[i] consists of lowercase letters only.
    • All words in strs have the same length and are anagrams of each other.
    diff --git a/problems/simplify-path/README.md b/problems/simplify-path/README.md index 75f48fa37..dee67b0ef 100644 --- a/problems/simplify-path/README.md +++ b/problems/simplify-path/README.md @@ -11,11 +11,20 @@ ## [71. Simplify Path (Medium)](https://leetcode.com/problems/simplify-path "简化路径") -

    Given an absolute path for a file (Unix-style), simplify it. Or in other words, convert it to the canonical path.

    +

    Given a string path, which is an absolute path (starting with a slash '/') to a file or directory in a Unix-style file system, convert it to the simplified canonical path.

    -

    In a UNIX-style file system, a period '.' refers to the current directory. Furthermore, a double period '..' moves the directory up a level.

    +

    In a Unix-style file system, a period '.' refers to the current directory, a double period '..' refers to the directory up a level, and any multiple consecutive slashes (i.e. '//') are treated as a single slash '/'. For this problem, any other format of periods such as '...' are treated as file/directory names.

    -

    Note that the returned canonical path must always begin with a slash '/', and there must be only a single slash '/' between two directory names. The last directory name (if it exists) must not end with a trailing '/'. Also, the canonical path must be the shortest string representing the absolute path.

    +

    The canonical path should have the following format:

    + +
      +
    • The path starts with a single slash '/'.
    • +
    • Any two directories are separated by a single slash '/'.
    • +
    • The path does not end with a trailing '/'.
    • +
    • The path only contains the directories on the path from the root directory to the target file or directory (i.e., no period '.' or double period '..')
    • +
    + +

    Return the simplified canonical path.

     

    Example 1:

    @@ -55,7 +64,7 @@
    • 1 <= path.length <= 3000
    • path consists of English letters, digits, period '.', slash '/' or '_'.
    • -
    • path is a valid Unix path.
    • +
    • path is a valid absolute Unix path.
    ### Related Topics diff --git a/problems/split-a-string-in-balanced-strings/README.md b/problems/split-a-string-in-balanced-strings/README.md index 8d97a4325..8e47d9c37 100644 --- a/problems/split-a-string-in-balanced-strings/README.md +++ b/problems/split-a-string-in-balanced-strings/README.md @@ -11,11 +11,11 @@ ## [1221. Split a String in Balanced Strings (Easy)](https://leetcode.com/problems/split-a-string-in-balanced-strings "分割平衡字符串") -

    Balanced strings are those who have equal quantity of 'L' and 'R' characters.

    +

    Balanced strings are those that have an equal quantity of 'L' and 'R' characters.

    -

    Given a balanced string s split it in the maximum amount of balanced strings.

    +

    Given a balanced string s, split it in the maximum amount of balanced strings.

    -

    Return the maximum amount of splitted balanced strings.

    +

    Return the maximum amount of split balanced strings.

     

    Example 1:

    @@ -55,7 +55,8 @@
    • 1 <= s.length <= 1000
    • -
    • s[i] = 'L' or 'R'
    • +
    • s[i] is either 'L' or 'R'.
    • +
    • s is a balanced string.
    ### Related Topics diff --git a/problems/sum-of-special-evenly-spaced-elements-in-array/README.md b/problems/sum-of-special-evenly-spaced-elements-in-array/README.md index 744ddf074..a79e00668 100644 --- a/problems/sum-of-special-evenly-spaced-elements-in-array/README.md +++ b/problems/sum-of-special-evenly-spaced-elements-in-array/README.md @@ -9,7 +9,7 @@                  [Next >](../count-apples-and-oranges "Count Apples and Oranges") -## [1714. Sum Of Special Evenly-Spaced Elements In Array (Hard)](https://leetcode.com/problems/sum-of-special-evenly-spaced-elements-in-array "") +## [1714. Sum Of Special Evenly-Spaced Elements In Array (Hard)](https://leetcode.com/problems/sum-of-special-evenly-spaced-elements-in-array "数组中特殊等间距元素的和") diff --git a/problems/tallest-billboard/README.md b/problems/tallest-billboard/README.md index b679a03ce..16b069a1e 100644 --- a/problems/tallest-billboard/README.md +++ b/problems/tallest-billboard/README.md @@ -11,51 +11,45 @@ ## [956. Tallest Billboard (Hard)](https://leetcode.com/problems/tallest-billboard "最高的广告牌") -

    You are installing a billboard and want it to have the largest height.  The billboard will have two steel supports, one on each side.  Each steel support must be an equal height.

    +

    You are installing a billboard and want it to have the largest height. The billboard will have two steel supports, one on each side. Each steel support must be an equal height.

    -

    You have a collection of rods which can be welded together.  For example, if you have rods of lengths 1, 2, and 3, you can weld them together to make a support of length 6.

    +

    You are given a collection of rods that can be welded together. For example, if you have rods of lengths 1, 2, and 3, you can weld them together to make a support of length 6.

    -

    Return the largest possible height of your billboard installation.  If you cannot support the billboard, return 0.

    +

    Return the largest possible height of your billboard installation. If you cannot support the billboard, return 0.

     

    -

    Example 1:

    -Input: [1,2,3,6]
    -Output: 6
    +Input: rods = [1,2,3,6]
    +Output: 6
     Explanation: We have two disjoint subsets {1,2,3} and {6}, which have the same sum = 6.
     
    -

    Example 2:

    -Input: [1,2,3,4,5,6]
    -Output: 10
    +Input: rods = [1,2,3,4,5,6]
    +Output: 10
     Explanation: We have two disjoint subsets {2,3,5} and {4,6}, which have the same sum = 10.
     
    -
    -

    Example 3:

    -Input: [1,2]
    -Output: 0
    -Explanation: The billboard cannot be supported, so we return 0.
    +Input: rods = [1,2]
    +Output: 0
    +Explanation: The billboard cannot be supported, so we return 0.
     
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 0 <= rods.length <= 20
    2. +
        +
      • 1 <= rods.length <= 20
      • 1 <= rods[i] <= 1000
      • -
      • The sum of rods is at most 5000.
      • -
    +
  • sum(rods[i]) <= 5000
  • + ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/time-needed-to-inform-all-employees/README.md b/problems/time-needed-to-inform-all-employees/README.md index aa0893d59..9877175c0 100644 --- a/problems/time-needed-to-inform-all-employees/README.md +++ b/problems/time-needed-to-inform-all-employees/README.md @@ -11,13 +11,13 @@ ## [1376. Time Needed to Inform All Employees (Medium)](https://leetcode.com/problems/time-needed-to-inform-all-employees "通知所有员工所需的时间") -

    A company has n employees with a unique ID for each employee from 0 to n - 1. The head of the company has is the one with headID.

    +

    A company has n employees with a unique ID for each employee from 0 to n - 1. The head of the company is the one with headID.

    -

    Each employee has one direct manager given in the manager array where manager[i] is the direct manager of the i-th employee, manager[headID] = -1. Also it's guaranteed that the subordination relationships have a tree structure.

    +

    Each employee has one direct manager given in the manager array where manager[i] is the direct manager of the i-th employee, manager[headID] = -1. Also, it is guaranteed that the subordination relationships have a tree structure.

    -

    The head of the company wants to inform all the employees of the company of an urgent piece of news. He will inform his direct subordinates and they will inform their subordinates and so on until all employees know about the urgent news.

    +

    The head of the company wants to inform all the company employees of an urgent piece of news. He will inform his direct subordinates, and they will inform their subordinates, and so on until all employees know about the urgent news.

    -

    The i-th employee needs informTime[i] minutes to inform all of his direct subordinates (i.e After informTime[i] minutes, all his direct subordinates can start spreading the news).

    +

    The i-th employee needs informTime[i] minutes to inform all of his direct subordinates (i.e., After informTime[i] minutes, all his direct subordinates can start spreading the news).

    Return the number of minutes needed to inform all the employees about the urgent news.

    @@ -74,14 +74,14 @@ The third minute they will inform the rest of employees.

    Constraints:

      -
    • 1 <= n <= 10^5
    • +
    • 1 <= n <= 105
    • 0 <= headID < n
    • manager.length == n
    • 0 <= manager[i] < n
    • manager[headID] == -1
    • -
    • informTime.length == n
    • +
    • informTime.length == n
    • 0 <= informTime[i] <= 1000
    • -
    • informTime[i] == 0 if employee i has no subordinates.
    • +
    • informTime[i] == 0 if employee i has no subordinates.
    • It is guaranteed that all the employees can be informed.
    diff --git a/problems/trips-and-users/README.md b/problems/trips-and-users/README.md index 6b5209d40..742673df0 100644 --- a/problems/trips-and-users/README.md +++ b/problems/trips-and-users/README.md @@ -25,7 +25,7 @@ | Request_at | date | +-------------+----------+ Id is the primary key for this table. -The table holds all taxi trips. Each trip has a unique Id, while Client_Id and Driver_Id are both foreign keys to the Users_Id at the Users table. +The table holds all taxi trips. Each trip has a unique Id, while Client_Id and Driver_Id are foreign keys to the Users_Id at the Users table. Status is an ENUM type of (‘completed’, ‘cancelled_by_driver’, ‘cancelled_by_client’).
    @@ -48,9 +48,9 @@ Status is an ENUM type of (‘Yes’, ‘No’).

     

    -

    Write a SQL query to find the cancellation rate of requests made by unbanned users (both client and driver must be unbanned) between "2013-10-01" and "2013-10-01".

    +

    Write a SQL query to find the cancellation rate of requests with unbanned users (both client and driver must not be banned) each day between "2013-10-01" and "2013-10-03".

    -

    The cancellation rate is computed by dividing the number of canceled (by client or driver) requests made by unbanned users by the total number of requests made by unbanned users.

    +

    The cancellation rate is computed by dividing the number of canceled (by client or driver) requests with unbanned users by the total number of requests with unbanned users on that day.

    Return the result table in any order. Round Cancellation Rate to two decimal points.

    @@ -97,4 +97,20 @@ Result table: | 2013-10-02 | 0.00 | | 2013-10-03 | 0.50 | +------------+-------------------+ + +On 2013-10-01: + - There were 4 requests in total, 2 of which were canceled. + - However, the request with Id=2 was made by a banned client (User_Id=2), so it is ignored in the calculation. + - Hence there are 3 unbanned requests in total, 1 of which was canceled. + - The Cancellation Rate is (1 / 3) = 0.33 +On 2013-10-02: + - There were 3 requests in total, 0 of which were canceled. + - The request with Id=6 was made by a banned client, so it is ignored. + - Hence there are 2 unbanned requests in total, 0 of which were canceled. + - The Cancellation Rate is (0 / 2) = 0.00 +On 2013-10-03: + - There were 3 requests in total, 1 of which was canceled. + - The request with Id=8 was made by a banned client, so it is ignored. + - Hence there are 2 unbanned request in total, 1 of which were canceled. + - The Cancellation Rate is (1 / 2) = 0.50
    diff --git a/problems/vertical-order-traversal-of-a-binary-tree/README.md b/problems/vertical-order-traversal-of-a-binary-tree/README.md index 1906502cf..10516fbe2 100644 --- a/problems/vertical-order-traversal-of-a-binary-tree/README.md +++ b/problems/vertical-order-traversal-of-a-binary-tree/README.md @@ -9,35 +9,52 @@                  [Next >](../smallest-string-starting-from-leaf "Smallest String Starting From Leaf") -## [987. Vertical Order Traversal of a Binary Tree (Medium)](https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree "二叉树的垂序遍历") +## [987. Vertical Order Traversal of a Binary Tree (Hard)](https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree "二叉树的垂序遍历")

    Given the root of a binary tree, calculate the vertical order traversal of the binary tree.

    -

    For each node at position (x, y), its left and right children will be at positions (x - 1, y - 1) and (x + 1, y - 1) respectively.

    +

    For each node at position (row, col), its left and right children will be at positions (row + 1, col - 1) and (row + 1, col + 1) respectively. The root of the tree is at (0, 0).

    -

    The vertical order traversal of a binary tree is a list of non-empty reports for each unique x-coordinate from left to right. Each report is a list of all nodes at a given x-coordinate. The report should be primarily sorted by y-coordinate from highest y-coordinate to lowest. If any two nodes have the same y-coordinate in the report, the node with the smaller value should appear earlier.

    +

    The vertical order traversal of a binary tree is a list of top-to-bottom orderings for each column index starting from the leftmost column and ending on the rightmost column. There may be multiple nodes in the same row and same column. In such a case, sort these nodes by their values.

    Return the vertical order traversal of the binary tree.

     

    Example 1:

    - +
     Input: root = [3,9,20,null,null,15,7]
     Output: [[9],[3,15],[20],[7]]
    -Explanation: Without loss of generality, we can assume the root node is at position (0, 0):
    -The node with value 9 occurs at position (-1, -1).
    -The nodes with values 3 and 15 occur at positions (0, 0) and (0, -2).
    -The node with value 20 occurs at position (1, -1).
    -The node with value 7 occurs at position (2, -2).
    +Explanation: +Column -1: Only node 9 is in this column. +Column 0: Nodes 3 and 15 are in this column in that order from top to bottom. +Column 1: Only node 20 is in this column. +Column 2: Only node 7 is in this column.

    Example 2:

    - +
     Input: root = [1,2,3,4,5,6,7]
     Output: [[4],[2],[1,5,6],[3],[7]]
    -Explanation: The node with value 5 and the node with value 6 have the same position according to the given scheme.
    -However, in the report [1,5,6], the node with value 5 comes first since 5 is smaller than 6.
    +Explanation: +Column -2: Only node 4 is in this column. +Column -1: Only node 2 is in this column. +Column 0: Nodes 1, 5, and 6 are in this column. + 1 is at the top, so it comes first. + 5 and 6 are at the same position (2, 0), so we order them by their value, 5 before 6. +Column 1: Only node 3 is in this column. +Column 2: Only node 7 is in this column. + + +

    Example 3:

    + +
    +Input: root = [1,2,3,4,6,5,7]
    +Output: [[4],[2],[1,5,6],[3],[7]]
    +Explanation:
    +This case is the exact same as example 2, but with nodes 5 and 6 swapped.
    +Note that the solution remains the same since 5 and 6 are in the same location and should be ordered by their values.
    +

     

    Constraints:

    @@ -49,4 +66,6 @@ However, in the report [1,5,6], the node with value 5 comes first since 5 is sma ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] [[Hash Table](../../tag/hash-table/README.md)] diff --git a/readme/601-900.md b/readme/601-900.md index c33491502..3030e2337 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -357,7 +357,7 @@ LeetCode Problems' Solutions | 885 | [Spiral Matrix III](https://leetcode.com/problems/spiral-matrix-iii "螺旋矩阵 III") | [Go](../problems/spiral-matrix-iii) | Medium | | 886 | [Possible Bipartition](https://leetcode.com/problems/possible-bipartition "可能的二分法") | [Go](../problems/possible-bipartition) | Medium | | 887 | [Super Egg Drop](https://leetcode.com/problems/super-egg-drop "鸡蛋掉落") | [Go](../problems/super-egg-drop) | Hard | -| 888 | [Fair Candy Swap](https://leetcode.com/problems/fair-candy-swap "公平的糖果交换") | [Go](../problems/fair-candy-swap) | Easy | +| 888 | [Fair Candy Swap](https://leetcode.com/problems/fair-candy-swap "公平的糖果棒交换") | [Go](../problems/fair-candy-swap) | Easy | | 889 | [Construct Binary Tree from Preorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal "根据前序和后序遍历构造二叉树") | [Go](../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | Medium | | 890 | [Find and Replace Pattern](https://leetcode.com/problems/find-and-replace-pattern "查找和替换模式") | [Go](../problems/find-and-replace-pattern) | Medium | | 891 | [Sum of Subsequence Widths](https://leetcode.com/problems/sum-of-subsequence-widths "子序列宽度之和") | [Go](../problems/sum-of-subsequence-widths) | Hard | diff --git a/readme/901-1200.md b/readme/901-1200.md index dfd88444f..c04d88e5d 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -139,7 +139,7 @@ LeetCode Problems' Solutions | 967 | [Numbers With Same Consecutive Differences](https://leetcode.com/problems/numbers-with-same-consecutive-differences "连续差相同的数字") | [Go](../problems/numbers-with-same-consecutive-differences) | Medium | | 968 | [Binary Tree Cameras](https://leetcode.com/problems/binary-tree-cameras "监控二叉树") | [Go](../problems/binary-tree-cameras) | Hard | | 969 | [Pancake Sorting](https://leetcode.com/problems/pancake-sorting "煎饼排序") | [Go](../problems/pancake-sorting) | Medium | -| 970 | [Powerful Integers](https://leetcode.com/problems/powerful-integers "强整数") | [Go](../problems/powerful-integers) | Easy | +| 970 | [Powerful Integers](https://leetcode.com/problems/powerful-integers "强整数") | [Go](../problems/powerful-integers) | Medium | | 971 | [Flip Binary Tree To Match Preorder Traversal](https://leetcode.com/problems/flip-binary-tree-to-match-preorder-traversal "翻转二叉树以匹配先序遍历") | [Go](../problems/flip-binary-tree-to-match-preorder-traversal) | Medium | | 972 | [Equal Rational Numbers](https://leetcode.com/problems/equal-rational-numbers "相等的有理数") | [Go](../problems/equal-rational-numbers) | Hard | | 973 | [K Closest Points to Origin](https://leetcode.com/problems/k-closest-points-to-origin "最接近原点的 K 个点") | [Go](../problems/k-closest-points-to-origin) | Medium | diff --git a/tag/array/README.md b/tag/array/README.md index edac25008..b22899942 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,306 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1738 | [找出第 K 大的异或坐标值](../../problems/find-kth-largest-xor-coordinate-value) | [[数组](../array/README.md)] | Medium | -| 1733 | [需要教语言的最少人数](../../problems/minimum-number-of-people-to-teach) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1732 | [找到最高海拔](../../problems/find-the-highest-altitude) | [[数组](../array/README.md)] | Easy | -| 1726 | [同积元组](../../problems/tuple-with-same-product) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1708 | [长度为 K 的最大子数组](../../problems/largest-subarray-length-k) 🔒 | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 1701 | [平均等待时间](../../problems/average-waiting-time) | [[数组](../array/README.md)] | Medium | -| 1700 | [无法吃午餐的学生数量](../../problems/number-of-students-unable-to-eat-lunch) | [[数组](../array/README.md)] | Easy | -| 1672 | [最富有客户的资产总量](../../problems/richest-customer-wealth) | [[数组](../array/README.md)] | Easy | -| 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Easy | -| 1652 | [拆炸弹](../../problems/defuse-the-bomb) | [[数组](../array/README.md)] | Easy | -| 1646 | [获取生成数组中的最大值](../../problems/get-maximum-in-generated-array) | [[数组](../array/README.md)] | Easy | -| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1636 | [按照频率将数组升序排序](../../problems/sort-array-by-increasing-frequency) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1629 | [按键持续时间最长的键](../../problems/slowest-key) | [[数组](../array/README.md)] | Easy | -| 1619 | [删除某些元素后的数组均值](../../problems/mean-of-array-after-removing-some-elements) | [[数组](../array/README.md)] | Easy | -| 1608 | [特殊数组的特征值](../../problems/special-array-with-x-elements-greater-than-or-equal-x) | [[数组](../array/README.md)] | Easy | -| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1588 | [所有奇数长度子数组的和](../../problems/sum-of-all-odd-length-subarrays) | [[数组](../array/README.md)] | Easy | -| 1583 | [统计不开心的朋友](../../problems/count-unhappy-friends) | [[数组](../array/README.md)] | Medium | -| 1582 | [二进制矩阵中的特殊位置](../../problems/special-positions-in-a-binary-matrix) | [[数组](../array/README.md)] | Easy | -| 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1572 | [矩阵对角线元素的和](../../problems/matrix-diagonal-sum) | [[数组](../array/README.md)] | Easy | -| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1566 | [重复至少 K 次且长度为 M 的模式](../../problems/detect-pattern-of-length-m-repeated-k-or-more-times) | [[数组](../array/README.md)] | Easy | -| 1560 | [圆形赛道上经过次数最多的扇区](../../problems/most-visited-sector-in-a-circular-track) | [[数组](../array/README.md)] | Easy | -| 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1550 | [存在连续三个奇数的数组](../../problems/three-consecutive-odds) | [[数组](../array/README.md)] | Easy | -| 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1535 | [找出数组游戏的赢家](../../problems/find-the-winner-of-an-array-game) | [[数组](../array/README.md)] | Medium | -| 1534 | [统计好三元组](../../problems/count-good-triplets) | [[数组](../array/README.md)] | Easy | -| 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1503 | [所有蚂蚁掉下来前的最后一刻](../../problems/last-moment-before-all-ants-fall-out-of-a-plank) | [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] | Medium | -| 1502 | [判断能否形成等差数列](../../problems/can-make-arithmetic-progression-from-sequence) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | -| 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1493 | [删掉一个元素以后全为 1 的最长子数组](../../problems/longest-subarray-of-1s-after-deleting-one-element) | [[数组](../array/README.md)] | Medium | -| 1491 | [去掉最低工资和最高工资后的工资平均值](../../problems/average-salary-excluding-the-minimum-and-maximum-salary) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1486 | [数组异或操作](../../problems/xor-operation-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | -| 1482 | [制作 m 束花所需的最少天数](../../problems/minimum-number-of-days-to-make-m-bouquets) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1481 | [不同整数的最少数目](../../problems/least-number-of-unique-integers-after-k-removals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1480 | [一维数组的动态和](../../problems/running-sum-of-1d-array) | [[数组](../array/README.md)] | Easy | -| 1476 | [子矩形查询](../../problems/subrectangle-queries) | [[数组](../array/README.md)] | Medium | -| 1475 | [商品折扣后的最终价格](../../problems/final-prices-with-a-special-discount-in-a-shop) | [[数组](../array/README.md)] | Easy | -| 1471 | [数组中的 k 个最强值](../../problems/the-k-strongest-values-in-an-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1470 | [重新排列数组](../../problems/shuffle-the-array) | [[数组](../array/README.md)] | Easy | -| 1465 | [切割后面积最大的蛋糕](../../problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts) | [[数组](../array/README.md)] | Medium | -| 1464 | [数组中两元素的最大乘积](../../problems/maximum-product-of-two-elements-in-an-array) | [[数组](../array/README.md)] | Easy | -| 1460 | [通过翻转子数组使两个数组相等](../../problems/make-two-arrays-equal-by-reversing-sub-arrays) | [[数组](../array/README.md)] | Easy | -| 1450 | [在既定时间做作业的学生人数](../../problems/number-of-students-doing-homework-at-a-given-time) | [[数组](../array/README.md)] | Easy | -| 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1437 | [是否所有 1 都至少相隔 k 个元素](../../problems/check-if-all-1s-are-at-least-length-k-places-away) | [[数组](../array/README.md)] | Easy | -| 1431 | [拥有最多糖果的孩子](../../problems/kids-with-the-greatest-number-of-candies) | [[数组](../array/README.md)] | Easy | -| 1428 | [至少有一个 1 的最左端列](../../problems/leftmost-column-with-at-least-a-one) 🔒 | [[数组](../array/README.md)] | Medium | -| 1427 | [字符串的左右移](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 1426 | [数元素](../../problems/counting-elements) 🔒 | [[数组](../array/README.md)] | Easy | -| 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1414 | [和为 K 的最少斐波那契数字数目](../../problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1413 | [逐步求和得到正数的最小值](../../problems/minimum-value-to-get-positive-step-by-step-sum) | [[数组](../array/README.md)] | Easy | -| 1409 | [查询带键的排列](../../problems/queries-on-a-permutation-with-key) | [[数组](../array/README.md)] | Medium | -| 1399 | [统计最大组的数目](../../problems/count-largest-group) | [[数组](../array/README.md)] | Easy | -| 1395 | [统计作战单位数](../../problems/count-number-of-teams) | [[数组](../array/README.md)] | Medium | -| 1394 | [找出数组中的幸运数](../../problems/find-lucky-integer-in-an-array) | [[数组](../array/README.md)] | Easy | -| 1389 | [按既定顺序创建目标数组](../../problems/create-target-array-in-the-given-order) | [[数组](../array/README.md)] | Easy | -| 1386 | [安排电影院座位](../../problems/cinema-seat-allocation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1385 | [两个数组间的距离值](../../problems/find-the-distance-value-between-two-arrays) | [[数组](../array/README.md)] | Easy | -| 1380 | [矩阵中的幸运数](../../problems/lucky-numbers-in-a-matrix) | [[数组](../array/README.md)] | Easy | -| 1375 | [灯泡开关 III](../../problems/bulb-switcher-iii) | [[数组](../array/README.md)] | Medium | -| 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | -| 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1346 | [检查整数及其两倍数是否存在](../../problems/check-if-n-and-its-double-exist) | [[数组](../array/README.md)] | Easy | -| 1343 | [大小为 K 且平均值大于等于阈值的子数组数目](../../problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold) | [[数组](../array/README.md)] | Medium | -| 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1337 | [矩阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1333 | [餐厅过滤器](../../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1331 | [数组序号转换](../../problems/rank-transform-of-an-array) | [[数组](../array/README.md)] | Easy | -| 1330 | [翻转子数组得到最大的数组值](../../problems/reverse-subarray-to-maximize-array-value) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | -| 1329 | [将矩阵按对角线排序](../../problems/sort-the-matrix-diagonally) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1313 | [解压缩编码列表](../../problems/decompress-run-length-encoded-list) | [[数组](../array/README.md)] | Easy | -| 1304 | [和为零的N个唯一整数](../../problems/find-n-unique-integers-sum-up-to-zero) | [[数组](../array/README.md)] | Easy | -| 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1299 | [将每个元素替换为右侧最大元素](../../problems/replace-elements-with-greatest-element-on-right-side) | [[数组](../array/README.md)] | Easy | -| 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1295 | [统计位数为偶数的数字](../../problems/find-numbers-with-even-number-of-digits) | [[数组](../array/README.md)] | Easy | -| 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1287 | [有序数组中出现次数超过25%的元素](../../problems/element-appearing-more-than-25-in-sorted-array) | [[数组](../array/README.md)] | Easy | -| 1277 | [统计全为 1 的正方形子矩阵](../../problems/count-square-submatrices-with-all-ones) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1275 | [找出井字棋的获胜者](../../problems/find-winner-on-a-tic-tac-toe-game) | [[数组](../array/README.md)] | Easy | -| 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | -| 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] | Easy | -| 1260 | [二维网格迁移](../../problems/shift-2d-grid) | [[数组](../array/README.md)] | Easy | -| 1252 | [奇数值单元格的数目](../../problems/cells-with-odd-values-in-a-matrix) | [[数组](../array/README.md)] | Easy | -| 1243 | [数组变换](../../problems/array-transformation) 🔒 | [[数组](../array/README.md)] | Easy | -| 1233 | [删除子文件夹](../../problems/remove-sub-folders-from-the-filesystem) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | -| 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 1222 | [可以攻击国王的皇后](../../problems/queens-that-can-attack-the-king) | [[数组](../array/README.md)] | Medium | -| 1217 | [玩筹码](../../problems/minimum-cost-to-move-chips-to-the-same-position) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | -| 1200 | [最小绝对差](../../problems/minimum-absolute-difference) | [[数组](../array/README.md)] | Easy | -| 1185 | [一周中的第几天](../../problems/day-of-the-week) | [[数组](../array/README.md)] | Easy | -| 1184 | [公交站间的距离](../../problems/distance-between-bus-stops) | [[数组](../array/README.md)] | Easy | -| 1177 | [构建回文串检测](../../problems/can-make-palindrome-from-substring) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | -| 1176 | [健身计划评估](../../problems/diet-plan-performance) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Easy | -| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1169 | [查询无效交易](../../problems/invalid-transactions) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | -| 1160 | [拼写单词](../../problems/find-words-that-can-be-formed-by-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1151 | [最少交换次数来组合所有的 1](../../problems/minimum-swaps-to-group-all-1s-together) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1150 | [检查一个数是否在数组中占绝大多数](../../problems/check-if-a-number-is-majority-element-in-a-sorted-array) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1146 | [快照数组](../../problems/snapshot-array) | [[数组](../array/README.md)] | Medium | -| 1144 | [递减元素使数组呈锯齿状](../../problems/decrease-elements-to-make-array-zigzag) | [[数组](../array/README.md)] | Medium | -| 1133 | [最大唯一数](../../problems/largest-unique-number) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1128 | [等价多米诺骨牌对的数量](../../problems/number-of-equivalent-domino-pairs) | [[数组](../array/README.md)] | Easy | -| 1122 | [数组的相对排序](../../problems/relative-sort-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1109 | [航班预订统计](../../problems/corporate-flight-bookings) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 1089 | [复写零](../../problems/duplicate-zeros) | [[数组](../array/README.md)] | Easy | -| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1085 | [最小元素各数位之和](../../problems/sum-of-digits-in-the-minimum-number) 🔒 | [[数组](../array/README.md)] | Easy | -| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 1064 | [不动点](../../problems/fixed-point) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1053 | [交换一次的先前排列](../../problems/previous-permutation-with-one-swap) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1052 | [爱生气的书店老板](../../problems/grumpy-bookstore-owner) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1051 | [高度检查器](../../problems/height-checker) | [[数组](../array/README.md)] | Easy | -| 1040 | [移动石子直到连续 II](../../problems/moving-stones-until-consecutive-ii) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1035 | [不相交的线](../../problems/uncrossed-lines) | [[数组](../array/README.md)] | Medium | -| 1031 | [两个非重叠子数组的最大和](../../problems/maximum-sum-of-two-non-overlapping-subarrays) | [[数组](../array/README.md)] | Medium | -| 1018 | [可被 5 整除的二进制前缀](../../problems/binary-prefix-divisible-by-5) | [[数组](../array/README.md)] | Easy | -| 1014 | [最佳观光组合](../../problems/best-sightseeing-pair) | [[数组](../array/README.md)] | Medium | -| 1013 | [将数组分成和相等的三个部分](../../problems/partition-array-into-three-parts-with-equal-sum) | [[数组](../array/README.md)] | Easy | -| 1011 | [在 D 天内送达包裹的能力](../../problems/capacity-to-ship-packages-within-d-days) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1010 | [总持续时间可被 60 整除的歌曲](../../problems/pairs-of-songs-with-total-durations-divisible-by-60) | [[数组](../array/README.md)] | Medium | -| 1007 | [行相等的最少多米诺旋转](../../problems/minimum-domino-rotations-for-equal-row) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 999 | [可以被一步捕获的棋子数](../../problems/available-captures-for-rook) | [[数组](../array/README.md)] | Easy | -| 989 | [数组形式的整数加法](../../problems/add-to-array-form-of-integer) | [[数组](../array/README.md)] | Easy | -| 985 | [查询后的偶数和](../../problems/sum-of-even-numbers-after-queries) | [[数组](../array/README.md)] | Easy | -| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 977 | [有序数组的平方](../../problems/squares-of-a-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 974 | [和可被 K 整除的子数组](../../problems/subarray-sums-divisible-by-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 969 | [煎饼排序](../../problems/pancake-sorting) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 962 | [最大宽度坡](../../problems/maximum-width-ramp) | [[数组](../array/README.md)] | Medium | -| 954 | [二倍数对数组](../../problems/array-of-doubled-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 950 | [按递增顺序显示卡牌](../../problems/reveal-cards-in-increasing-order) | [[数组](../array/README.md)] | Medium | -| 945 | [使数组唯一的最小增量](../../problems/minimum-increment-to-make-array-unique) | [[数组](../array/README.md)] | Medium | -| 941 | [有效的山脉数组](../../problems/valid-mountain-array) | [[数组](../array/README.md)] | Easy | -| 926 | [将字符串翻转到单调递增](../../problems/flip-string-to-monotone-increasing) | [[数组](../array/README.md)] | Medium | -| 922 | [按奇偶排序数组 II](../../problems/sort-array-by-parity-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 918 | [环形子数组的最大和](../../problems/maximum-sum-circular-subarray) | [[数组](../array/README.md)] | Medium | -| 915 | [分割数组](../../problems/partition-array-into-disjoint-intervals) | [[数组](../array/README.md)] | Medium | -| 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 907 | [子数组的最小值之和](../../problems/sum-of-subarray-minimums) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Medium | -| 905 | [按奇偶排序数组](../../problems/sort-array-by-parity) | [[数组](../array/README.md)] | Easy | -| 900 | [RLE 迭代器](../../problems/rle-iterator) | [[数组](../array/README.md)] | Medium | -| 896 | [单调数列](../../problems/monotonic-array) | [[数组](../array/README.md)] | Easy | -| 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | -| 888 | [公平的糖果交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] | Easy | -| 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 867 | [转置矩阵](../../problems/transpose-matrix) | [[数组](../array/README.md)] | Easy | -| 849 | [到最近的人的最大距离](../../problems/maximize-distance-to-closest-person) | [[数组](../array/README.md)] | Medium | -| 840 | [矩阵中的幻方](../../problems/magic-squares-in-grid) | [[数组](../array/README.md)] | Medium | -| 835 | [图像重叠](../../problems/image-overlap) | [[数组](../array/README.md)] | Medium | -| 832 | [翻转图像](../../problems/flipping-an-image) | [[数组](../array/README.md)] | Easy | -| 830 | [较大分组的位置](../../problems/positions-of-large-groups) | [[数组](../array/README.md)] | Easy | -| 825 | [适龄的朋友](../../problems/friends-of-appropriate-ages) | [[数组](../array/README.md)] | Medium | -| 795 | [区间子数组个数](../../problems/number-of-subarrays-with-bounded-maximum) | [[数组](../array/README.md)] | Medium | -| 792 | [匹配子序列的单词数](../../problems/number-of-matching-subsequences) | [[数组](../array/README.md)] | Medium | -| 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | -| 775 | [全局倒置与局部倒置](../../problems/global-and-local-inversions) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 769 | [最多能完成排序的块](../../problems/max-chunks-to-make-sorted) | [[数组](../array/README.md)] | Medium | -| 768 | [最多能完成排序的块 II](../../problems/max-chunks-to-make-sorted-ii) | [[数组](../array/README.md)] | Hard | -| 766 | [托普利茨矩阵](../../problems/toeplitz-matrix) | [[数组](../array/README.md)] | Easy | -| 755 | [倒水](../../problems/pour-water) 🔒 | [[数组](../array/README.md)] | Medium | -| 747 | [至少是其他数字两倍的最大数](../../problems/largest-number-at-least-twice-of-others) | [[数组](../array/README.md)] | Easy | -| 746 | [使用最小花费爬楼梯](../../problems/min-cost-climbing-stairs) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 729 | [我的日程安排表 I](../../problems/my-calendar-i) | [[数组](../array/README.md)] | Medium | -| 724 | [寻找数组的中心索引](../../problems/find-pivot-index) | [[数组](../array/README.md)] | Easy | -| 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 717 | [1比特与2比特字符](../../problems/1-bit-and-2-bit-characters) | [[数组](../array/README.md)] | Easy | -| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 697 | [数组的度](../../problems/degree-of-an-array) | [[数组](../array/README.md)] | Easy | -| 695 | [岛屿的最大面积](../../problems/max-area-of-island) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 689 | [三个无重叠子数组的最大和](../../problems/maximum-sum-of-3-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 674 | [最长连续递增序列](../../problems/longest-continuous-increasing-subsequence) | [[数组](../array/README.md)] | Easy | -| 670 | [最大交换](../../problems/maximum-swap) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 667 | [优美的排列 II](../../problems/beautiful-arrangement-ii) | [[数组](../array/README.md)] | Medium | -| 665 | [非递减数列](../../problems/non-decreasing-array) | [[数组](../array/README.md)] | Easy | -| 661 | [图片平滑器](../../problems/image-smoother) | [[数组](../array/README.md)] | Easy | -| 644 | [子数组最大平均数 II](../../problems/maximum-average-subarray-ii) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 643 | [子数组最大平均数 I](../../problems/maximum-average-subarray-i) | [[数组](../array/README.md)] | Easy | -| 628 | [三个数的最大乘积](../../problems/maximum-product-of-three-numbers) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | -| 611 | [有效三角形的个数](../../problems/valid-triangle-number) | [[数组](../array/README.md)] | Medium | -| 605 | [种花问题](../../problems/can-place-flowers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 581 | [最短无序连续子数组](../../problems/shortest-unsorted-continuous-subarray) | [[数组](../array/README.md)] | Medium | -| 566 | [重塑矩阵](../../problems/reshape-the-matrix) | [[数组](../array/README.md)] | Easy | -| 565 | [数组嵌套](../../problems/array-nesting) | [[数组](../array/README.md)] | Medium | -| 562 | [矩阵中最长的连续1线段](../../problems/longest-line-of-consecutive-one-in-matrix) 🔒 | [[数组](../array/README.md)] | Medium | -| 561 | [数组拆分 I](../../problems/array-partition-i) | [[数组](../array/README.md)] | Easy | -| 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 548 | [将数组分割成和相等的子数组](../../problems/split-array-with-equal-sum) 🔒 | [[数组](../array/README.md)] | Medium | -| 533 | [孤独像素 II](../../problems/lonely-pixel-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 531 | [孤独像素 I](../../problems/lonely-pixel-i) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 509 | [斐波那契数](../../problems/fibonacci-number) | [[数组](../array/README.md)] | Easy | -| 495 | [提莫攻击](../../problems/teemo-attacking) | [[数组](../array/README.md)] | Medium | -| 485 | [最大连续1的个数](../../problems/max-consecutive-ones) | [[数组](../array/README.md)] | Easy | -| 457 | [环形数组循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 448 | [找到所有数组中消失的数字](../../problems/find-all-numbers-disappeared-in-an-array) | [[数组](../array/README.md)] | Easy | -| 442 | [数组中重复的数据](../../problems/find-all-duplicates-in-an-array) | [[数组](../array/README.md)] | Medium | -| 414 | [第三大的数](../../problems/third-maximum-number) | [[数组](../array/README.md)] | Easy | -| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 370 | [区间加法](../../problems/range-addition) 🔒 | [[数组](../array/README.md)] | Medium | -| 289 | [生命游戏](../../problems/game-of-life) | [[数组](../array/README.md)] | Medium | -| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 277 | [搜寻名人](../../problems/find-the-celebrity) 🔒 | [[数组](../array/README.md)] | Medium | -| 268 | [丢失的数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 245 | [最短单词距离 III](../../problems/shortest-word-distance-iii) 🔒 | [[数组](../array/README.md)] | Medium | -| 243 | [最短单词距离](../../problems/shortest-word-distance) 🔒 | [[数组](../array/README.md)] | Easy | -| 238 | [除自身以外数组的乘积](../../problems/product-of-array-except-self) | [[数组](../array/README.md)] | Medium | -| 229 | [求众数 II](../../problems/majority-element-ii) | [[数组](../array/README.md)] | Medium | -| 228 | [汇总区间](../../problems/summary-ranges) | [[数组](../array/README.md)] | Easy | -| 219 | [存在重复元素 II](../../problems/contains-duplicate-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 217 | [存在重复元素](../../problems/contains-duplicate) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 189 | [旋转数组](../../problems/rotate-array) | [[数组](../array/README.md)] | Medium | -| 169 | [多数元素](../../problems/majority-element) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Easy | -| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 163 | [缺失的区间](../../problems/missing-ranges) 🔒 | [[数组](../array/README.md)] | Easy | -| 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 154 | [寻找旋转排序数组中的最小值 II](../../problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 152 | [乘积最大子数组](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 128 | [最长连续序列](../../problems/longest-consecutive-sequence) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Hard | -| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 123 | [买卖股票的最佳时机 III](../../problems/best-time-to-buy-and-sell-stock-iii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 121 | [买卖股票的最佳时机](../../problems/best-time-to-buy-and-sell-stock) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 120 | [三角形最小路径和](../../problems/triangle) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 119 | [杨辉三角 II](../../problems/pascals-triangle-ii) | [[数组](../array/README.md)] | Easy | -| 118 | [杨辉三角](../../problems/pascals-triangle) | [[数组](../array/README.md)] | Easy | -| 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 90 | [子集 II](../../problems/subsets-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 88 | [合并两个有序数组](../../problems/merge-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 84 | [柱状图中最大的矩形](../../problems/largest-rectangle-in-histogram) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Hard | -| 81 | [搜索旋转排序数组 II](../../problems/search-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 80 | [删除排序数组中的重复项 II](../../problems/remove-duplicates-from-sorted-array-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 79 | [单词搜索](../../problems/word-search) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 74 | [搜索二维矩阵](../../problems/search-a-2d-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 73 | [矩阵置零](../../problems/set-matrix-zeroes) | [[数组](../array/README.md)] | Medium | -| 66 | [加一](../../problems/plus-one) | [[数组](../array/README.md)] | Easy | -| 64 | [最小路径和](../../problems/minimum-path-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 63 | [不同路径 II](../../problems/unique-paths-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 62 | [不同路径](../../problems/unique-paths) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 59 | [螺旋矩阵 II](../../problems/spiral-matrix-ii) | [[数组](../array/README.md)] | Medium | -| 57 | [插入区间](../../problems/insert-interval) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 56 | [合并区间](../../problems/merge-intervals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 55 | [跳跃游戏](../../problems/jump-game) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 54 | [螺旋矩阵](../../problems/spiral-matrix) | [[数组](../array/README.md)] | Medium | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 48 | [旋转图像](../../problems/rotate-image) | [[数组](../array/README.md)] | Medium | -| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Hard | -| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 41 | [缺失的第一个正数](../../problems/first-missing-positive) | [[数组](../array/README.md)] | Hard | -| 40 | [组合总和 II](../../problems/combination-sum-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 39 | [组合总和](../../problems/combination-sum) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 35 | [搜索插入位置](../../problems/search-insert-position) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 34 | [在排序数组中查找元素的第一个和最后一个位置](../../problems/find-first-and-last-position-of-element-in-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 33 | [搜索旋转排序数组](../../problems/search-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 31 | [下一个排列](../../problems/next-permutation) | [[数组](../array/README.md)] | Medium | -| 27 | [移除元素](../../problems/remove-element) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 26 | [删除排序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 11 | [盛最多水的容器](../../problems/container-with-most-water) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 4 | [寻找两个正序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 1 | [两数之和](../../problems/two-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index f25f28a74..94b8cca71 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,69 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1688 | [比赛中的配对次数](../../problems/count-of-matches-in-tournament) | [[回溯算法](../backtracking/README.md)] | Easy | -| 1681 | [最小不兼容性](../../problems/minimum-incompatibility) | [[贪心算法](../greedy/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[回溯算法](../backtracking/README.md)] | Hard | -| 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[回溯算法](../backtracking/README.md)] | Medium | -| 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1415 | [长度为 n 的开心字符串中字典序第 k 小的字符串](../../problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | [[回溯算法](../backtracking/README.md)] | Medium | -| 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1291 | [顺次数](../../problems/sequential-digits) | [[回溯算法](../backtracking/README.md)] | Medium | -| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1258 | [近义词句子](../../problems/synonymous-sentences) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | -| 1240 | [铺瓷砖](../../problems/tiling-a-rectangle-with-the-fewest-squares) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1239 | [串联字符串的最大长度](../../problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1219 | [黄金矿工](../../problems/path-with-maximum-gold) | [[回溯算法](../backtracking/README.md)] | Medium | -| 1215 | [步进数](../../problems/stepping-numbers) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | -| 1088 | [易混淆数 II](../../problems/confusing-number-ii) 🔒 | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1087 | [花括号展开](../../problems/brace-expansion) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | -| 1079 | [活字印刷](../../problems/letter-tile-possibilities) | [[回溯算法](../backtracking/README.md)] | Medium | -| 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 980 | [不同路径 III](../../problems/unique-paths-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 526 | [优美的排列](../../problems/beautiful-arrangement) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 425 | [单词方块](../../problems/word-squares) 🔒 | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 411 | [最短特异单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 401 | [二进制手表](../../problems/binary-watch) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | -| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 351 | [安卓系统手势解锁](../../problems/android-unlock-patterns) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 306 | [累加数](../../problems/additive-number) | [[回溯算法](../backtracking/README.md)] | Medium | -| 294 | [翻转游戏 II](../../problems/flip-game-ii) 🔒 | [[极小化极大](../minimax/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 291 | [单词规律 II](../../problems/word-pattern-ii) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | -| 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | -| 254 | [因子的组合](../../problems/factor-combinations) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | -| 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 140 | [单词拆分 II](../../problems/word-break-ii) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 93 | [复原IP地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 90 | [子集 II](../../problems/subsets-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 89 | [格雷编码](../../problems/gray-code) | [[回溯算法](../backtracking/README.md)] | Medium | -| 79 | [单词搜索](../../problems/word-search) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 77 | [组合](../../problems/combinations) | [[回溯算法](../backtracking/README.md)] | Medium | -| 60 | [排列序列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 52 | [N皇后 II](../../problems/n-queens-ii) | [[回溯算法](../backtracking/README.md)] | Hard | -| 51 | [N 皇后](../../problems/n-queens) | [[回溯算法](../backtracking/README.md)] | Hard | -| 47 | [全排列 II](../../problems/permutations-ii) | [[回溯算法](../backtracking/README.md)] | Medium | -| 46 | [全排列](../../problems/permutations) | [[回溯算法](../backtracking/README.md)] | Medium | -| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 40 | [组合总和 II](../../problems/combination-sum-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 39 | [组合总和](../../problems/combination-sum) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 37 | [解数独](../../problems/sudoku-solver) | [[哈希表](../hash-table/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/binary-search-tree/README.md b/tag/binary-search-tree/README.md index 0d508d4e1..a95cd2821 100644 --- a/tag/binary-search-tree/README.md +++ b/tag/binary-search-tree/README.md @@ -12,4 +12,5 @@ | 1382 | [将二叉搜索树变平衡](../../problems/balance-a-binary-search-tree) | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | | 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | -| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | +| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 97922c717..e88d1c101 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,3 +9,87 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1730 | [获取食物的最短路径](../../problems/shortest-path-to-get-food) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1654 | [到家的最少跳跃次数](../../problems/minimum-jumps-to-reach-home) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1625 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1345 | [跳跃游戏 IV](../../problems/jump-game-iv) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 1298 | [你能从盒子里获得的最大糖果数](../../problems/maximum-candies-you-can-get-from-boxes) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1293 | [网格中的最短路径](../../problems/shortest-path-in-a-grid-with-obstacles-elimination) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1284 | [转化为全零矩阵的最少反转次数](../../problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1263 | [推箱子](../../problems/minimum-moves-to-move-a-box-to-their-target-location) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1242 | [多线程网页爬虫](../../problems/web-crawler-multithreaded) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1236 | [网络爬虫](../../problems/web-crawler) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1210 | [穿过迷宫的最少移动次数](../../problems/minimum-moves-to-reach-target-with-rotations) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1197 | [进击的骑士](../../problems/minimum-knight-moves) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1091 | [二进制矩阵中的最短路径](../../problems/shortest-path-in-binary-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 994 | [腐烂的橘子](../../problems/rotting-oranges) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[极小化极大](../minimax/README.md)] | Hard | +| 909 | [蛇梯棋](../../problems/snakes-and-ladders) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 882 | [细分图中的可到达结点](../../problems/reachable-nodes-in-subdivided-graph) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 864 | [获取所有钥匙的最短路径](../../problems/shortest-path-to-get-all-keys) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 854 | [相似度为 K 的字符串](../../problems/k-similar-strings) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Hard | +| 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 827 | [最大人工岛](../../problems/making-a-large-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 773 | [滑动谜题](../../problems/sliding-puzzle) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 675 | [为高尔夫比赛砍树](../../problems/cut-off-trees-for-golf-event) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 559 | [N 叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 542 | [01 矩阵](../../problems/01-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 529 | [扫雷游戏](../../problems/minesweeper) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 505 | [迷宫 II](../../problems/the-maze-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 499 | [迷宫 III](../../problems/the-maze-iii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 490 | [迷宫](../../problems/the-maze) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 429 | [N 叉树的层序遍历](../../problems/n-ary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 417 | [太平洋大西洋水流问题](../../problems/pacific-atlantic-water-flow) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 339 | [嵌套列表权重和](../../problems/nested-list-weight-sum) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 317 | [离建筑物最近的距离](../../problems/shortest-distance-from-all-buildings) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 310 | [最小高度树](../../problems/minimum-height-trees) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 301 | [删除无效的括号](../../problems/remove-invalid-parentheses) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 286 | [墙与门](../../problems/walls-and-gates) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 127 | [单词接龙](../../problems/word-ladder) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 102 | [二叉树的层序遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 9deef5ef0..fd6aef291 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,153 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1740 | [Find Distance in a Binary Tree](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 1730 | [Shortest Path to Get Food](../../problems/shortest-path-to-get-food) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[贪心算法](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1625 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | -| 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1469 | [寻找所有的独生节点](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 1466 | [重新规划路线](../../problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1377 | [T 秒后青蛙的位置](../../problems/frog-position-after-t-seconds) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 1376 | [通知所有员工所需的时间](../../problems/time-needed-to-inform-all-employees) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 1315 | [祖父节点值为偶数的节点和](../../problems/sum-of-nodes-with-even-valued-grandparent) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1273 | [删除树节点](../../problems/delete-tree-nodes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1254 | [统计封闭岛屿的数目](../../problems/number-of-closed-islands) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1242 | [多线程网页爬虫](../../problems/web-crawler-multithreaded) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1236 | [网络爬虫](../../problems/web-crawler) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | -| 1192 | [查找集群内的「关键连接」](../../problems/critical-connections-in-a-network) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1110 | [删点成林](../../problems/delete-nodes-and-return-forest) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 1080 | [根到叶路径上的不足节点](../../problems/insufficient-nodes-in-root-to-leaf-paths) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1061 | [按字典序排列最小的等效字符串](../../problems/lexicographically-smallest-equivalent-string) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 1059 | [从始点到终点的所有路径](../../problems/all-paths-from-source-lead-to-destination) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 1026 | [节点与其祖先之间的最大差值](../../problems/maximum-difference-between-node-and-ancestor) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1020 | [飞地的数量](../../problems/number-of-enclaves) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 988 | [从叶结点开始的最小字符串](../../problems/smallest-string-starting-from-leaf) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 980 | [不同路径 III](../../problems/unique-paths-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 979 | [在二叉树中分配硬币](../../problems/distribute-coins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 971 | [翻转二叉树以匹配先序遍历](../../problems/flip-binary-tree-to-match-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 947 | [移除最多的同行或同列石头](../../problems/most-stones-removed-with-same-row-or-column) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 924 | [尽量减少恶意软件的传播](../../problems/minimize-malware-spread) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | -| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 851 | [喧闹和富有](../../problems/loud-and-rich) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 841 | [钥匙和房间](../../problems/keys-and-rooms) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 827 | [最大人工岛](../../problems/making-a-large-island) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 802 | [找到最终的安全状态](../../problems/find-eventual-safe-states) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 756 | [金字塔转换矩阵](../../problems/pyramid-transition-matrix) | [[位运算](../bit-manipulation/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 753 | [破解保险箱](../../problems/cracking-the-safe) | [[深度优先搜索](../depth-first-search/README.md)] [[数学](../math/README.md)] | Hard | -| 749 | [隔离病毒](../../problems/contain-virus) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 733 | [图像渲染](../../problems/flood-fill) | [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 721 | [账户合并](../../problems/accounts-merge) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 695 | [岛屿的最大面积](../../problems/max-area-of-island) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 679 | [24 点游戏](../../problems/24-game) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 664 | [奇怪的打印机](../../problems/strange-printer) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 638 | [大礼包](../../problems/shopping-offers) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 576 | [出界的路径数](../../problems/out-of-boundary-paths) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 559 | [N 叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 547 | [省份数量](../../problems/number-of-provinces) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 546 | [移除盒子](../../problems/remove-boxes) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 542 | [01 矩阵](../../problems/01-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 533 | [孤独像素 II](../../problems/lonely-pixel-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 531 | [孤独像素 I](../../problems/lonely-pixel-i) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 529 | [扫雷游戏](../../problems/minesweeper) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 526 | [优美的排列](../../problems/beautiful-arrangement) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 505 | [迷宫 II](../../problems/the-maze-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 499 | [迷宫 III](../../problems/the-maze-iii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 494 | [目标和](../../problems/target-sum) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 491 | [递增子序列](../../problems/increasing-subsequences) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 490 | [迷宫](../../problems/the-maze) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 489 | [扫地机器人](../../problems/robot-room-cleaner) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 488 | [祖玛游戏](../../problems/zuma-game) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 473 | [火柴拼正方形](../../problems/matchsticks-to-square) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 439 | [三元表达式解析器](../../problems/ternary-expression-parser) 🔒 | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 430 | [扁平化多级双向链表](../../problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 417 | [太平洋大西洋水流问题](../../problems/pacific-atlantic-water-flow) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 366 | [寻找二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 364 | [加权嵌套序列和 II](../../problems/nested-list-weight-sum-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 339 | [嵌套列表权重和](../../problems/nested-list-weight-sum) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | -| 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 301 | [删除无效的括号](../../problems/remove-invalid-parentheses) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 129 | [求根到叶子节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 100 | [相同的树](../../problems/same-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 99 | [恢复二叉搜索树](../../problems/recover-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 792ed5487..11f2f43fb 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,8 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1746 | [Maximum Subarray Sum After One Operation](../../problems/maximum-subarray-sum-after-one-operation) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1745 | [回文串分割 IV](../../problems/palindrome-partitioning-iv) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1728 | [猫和老鼠 II](../../problems/cat-and-mouse-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1724 | [Checking Existence of Edge Length Limited Paths II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1724 | [检查边长度限制的路径是否存在 II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1706 | [球会落何处](../../problems/where-will-the-ball-fall) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1692 | [计算分配糖果的不同方式](../../problems/count-ways-to-distribute-candies) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1691 | [堆叠长方体的最大高度](../../problems/maximum-height-by-stacking-cuboids) | [[排序](../sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -45,7 +47,7 @@ | 1483 | [树节点的第 K 个祖先](../../problems/kth-ancestor-of-a-tree-node) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1477 | [找两个和为目标值且不重叠的子数组](../../problems/find-two-non-overlapping-sub-arrays-each-with-target-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1473 | [给房子涂色 III](../../problems/paint-house-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1473 | [粉刷房子 III](../../problems/paint-house-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1463 | [摘樱桃 II](../../problems/cherry-pickup-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1458 | [两个子序列的最大点积](../../problems/max-dot-product-of-two-subsequences) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -252,4 +254,3 @@ | 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 5 | [最长回文子串](../../problems/longest-palindromic-substring) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1 | [01 背包问题](../../problems/07MoiZ) | [[动态规划](../dynamic-programming/README.md)] | Easy | diff --git a/tag/graph/README.md b/tag/graph/README.md index 986d03a27..1e8098532 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,54 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1730 | [Shortest Path to Get Food](../../problems/shortest-path-to-get-food) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1724 | [Checking Existence of Edge Length Limited Paths II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] | Hard | -| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1615 | [最大网络秩](../../problems/maximal-network-rank) | [[图](../graph/README.md)] | Medium | -| 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1557 | [可以到达所有点的最少点数目](../../problems/minimum-number-of-vertices-to-reach-all-nodes) | [[图](../graph/README.md)] | Medium | -| 1548 | [图中最相似的路径](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] | Medium | -| 1494 | [并行课程 II](../../problems/parallel-courses-ii) | [[图](../graph/README.md)] | Hard | -| 1462 | [课程安排 IV](../../problems/course-schedule-iv) | [[图](../graph/README.md)] | Medium | -| 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | -| 1361 | [验证二叉树](../../problems/validate-binary-tree-nodes) | [[图](../graph/README.md)] | Medium | -| 1334 | [阈值距离内邻居最少的城市](../../problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | [[图](../graph/README.md)] | Medium | -| 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | -| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | -| 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1153 | [字符串转化](../../problems/string-transforms-into-another-string) 🔒 | [[图](../graph/README.md)] | Hard | -| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1135 | [最低成本联通所有城市](../../problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 1059 | [从始点到终点的所有路径](../../problems/all-paths-from-source-lead-to-destination) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[图](../graph/README.md)] | Medium | -| 997 | [找到小镇的法官](../../problems/find-the-town-judge) | [[图](../graph/README.md)] | Easy | -| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 990 | [等式方程的可满足性](../../problems/satisfiability-of-equality-equations) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 854 | [相似度为 K 的字符串](../../problems/k-similar-strings) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Hard | -| 841 | [钥匙和房间](../../problems/keys-and-rooms) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 802 | [找到最终的安全状态](../../problems/find-eventual-safe-states) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 684 | [冗余连接](../../problems/redundant-connection) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 444 | [序列重建](../../problems/sequence-reconstruction) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 399 | [除法求值](../../problems/evaluate-division) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 310 | [最小高度树](../../problems/minimum-height-trees) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | -| 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index a9e90fd80..f55fc7e68 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1743 | [从相邻元素对还原数组](../../problems/restore-the-array-from-adjacent-pairs) | [[贪心算法](../greedy/README.md)] | Medium | | 1737 | [满足三条件之一需改变的最少字符数](../../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1736 | [替换隐藏数字得到的最晚时间](../../problems/latest-time-by-replacing-hidden-digits) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | | 1733 | [需要教语言的最少人数](../../problems/minimum-number-of-people-to-teach) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 79ef05332..1adf15714 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,142 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1726 | [同积元组](../../problems/tuple-with-same-product) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1679 | [K 和数对的最大数目](../../problems/max-number-of-k-sum-pairs) | [[哈希表](../hash-table/README.md)] | Medium | -| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1418 | [点菜展示表](../../problems/display-table-of-food-orders-in-a-restaurant) | [[哈希表](../hash-table/README.md)] | Medium | -| 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1224 | [最大相等频率](../../problems/maximum-equal-frequency) | [[哈希表](../hash-table/README.md)] | Hard | -| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 1207 | [独一无二的出现次数](../../problems/unique-number-of-occurrences) | [[哈希表](../hash-table/README.md)] | Easy | -| 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1189 | [“气球” 的最大数量](../../problems/maximum-number-of-balloons) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 1178 | [猜字谜](../../problems/number-of-valid-words-for-each-puzzle) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1160 | [拼写单词](../../problems/find-words-that-can-be-formed-by-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1138 | [字母板上的路径](../../problems/alphabet-board-path) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1133 | [最大唯一数](../../problems/largest-unique-number) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1078 | [Bigram 分词](../../problems/occurrences-after-bigram) | [[哈希表](../hash-table/README.md)] | Easy | -| 1072 | [按列翻转得到最大值等行数](../../problems/flip-columns-for-maximum-number-of-equal-rows) | [[哈希表](../hash-table/README.md)] | Medium | -| 1048 | [最长字符串链](../../problems/longest-string-chain) | [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1001 | [网格照明](../../problems/grid-illumination) | [[哈希表](../hash-table/README.md)] | Hard | -| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 974 | [和可被 K 整除的子数组](../../problems/subarray-sums-divisible-by-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 970 | [强整数](../../problems/powerful-integers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 961 | [重复 N 次的元素](../../problems/n-repeated-element-in-size-2n-array) | [[哈希表](../hash-table/README.md)] | Easy | -| 957 | [N 天后的牢房](../../problems/prison-cells-after-n-days) | [[哈希表](../hash-table/README.md)] | Medium | -| 954 | [二倍数对数组](../../problems/array-of-doubled-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 953 | [验证外星语词典](../../problems/verifying-an-alien-dictionary) | [[哈希表](../hash-table/README.md)] | Easy | -| 939 | [最小面积矩形](../../problems/minimum-area-rectangle) | [[哈希表](../hash-table/README.md)] | Medium | -| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 884 | [两句话中的不常见单词](../../problems/uncommon-words-from-two-sentences) | [[哈希表](../hash-table/README.md)] | Easy | -| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[哈希表](../hash-table/README.md)] | Easy | -| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 771 | [宝石与石头](../../problems/jewels-and-stones) | [[哈希表](../hash-table/README.md)] | Easy | -| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | -| 760 | [找出变位映射](../../problems/find-anagram-mappings) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | -| 748 | [最短补全词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] | Easy | -| 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | -| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[堆](../heap/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 676 | [实现一个魔法字典](../../problems/implement-magic-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 648 | [单词替换](../../problems/replace-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 645 | [错误的集合](../../problems/set-mismatch) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 599 | [两个列表的最小索引总和](../../problems/minimum-index-sum-of-two-lists) | [[哈希表](../hash-table/README.md)] | Easy | -| 594 | [最长和谐子序列](../../problems/longest-harmonious-subsequence) | [[哈希表](../hash-table/README.md)] | Easy | -| 575 | [分糖果](../../problems/distribute-candies) | [[哈希表](../hash-table/README.md)] | Easy | -| 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 554 | [砖墙](../../problems/brick-wall) | [[哈希表](../hash-table/README.md)] | Medium | -| 535 | [TinyURL 的加密与解密](../../problems/encode-and-decode-tinyurl) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 525 | [连续数组](../../problems/contiguous-array) | [[哈希表](../hash-table/README.md)] | Medium | -| 508 | [出现次数最多的子树元素和](../../problems/most-frequent-subtree-sum) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 500 | [键盘行](../../problems/keyboard-row) | [[哈希表](../hash-table/README.md)] | Easy | -| 463 | [岛屿的周长](../../problems/island-perimeter) | [[哈希表](../hash-table/README.md)] | Easy | -| 454 | [四数相加 II](../../problems/4sum-ii) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 447 | [回旋镖的数量](../../problems/number-of-boomerangs) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 438 | [找到字符串中所有字母异位词](../../problems/find-all-anagrams-in-a-string) | [[哈希表](../hash-table/README.md)] | Medium | -| 409 | [最长回文串](../../problems/longest-palindrome) | [[哈希表](../hash-table/README.md)] | Easy | -| 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 356 | [直线镜像](../../problems/line-reflection) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | -| 325 | [和等于 k 的最长子数组长度](../../problems/maximum-size-subarray-sum-equals-k) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | -| 311 | [稀疏矩阵的乘法](../../problems/sparse-matrix-multiplication) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | -| 299 | [猜数字游戏](../../problems/bulls-and-cows) | [[哈希表](../hash-table/README.md)] | Medium | -| 290 | [单词规律](../../problems/word-pattern) | [[哈希表](../hash-table/README.md)] | Easy | -| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 274 | [H 指数](../../problems/h-index) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 266 | [回文排列](../../problems/palindrome-permutation) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | -| 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 246 | [中心对称数](../../problems/strobogrammatic-number) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 242 | [有效的字母异位词](../../problems/valid-anagram) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 219 | [存在重复元素 II](../../problems/contains-duplicate-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 217 | [存在重复元素](../../problems/contains-duplicate) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 205 | [同构字符串](../../problems/isomorphic-strings) | [[哈希表](../hash-table/README.md)] | Easy | -| 204 | [计数质数](../../problems/count-primes) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 202 | [快乐数](../../problems/happy-number) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 187 | [重复的DNA序列](../../problems/repeated-dna-sequences) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | -| 138 | [复制带随机指针的链表](../../problems/copy-list-with-random-pointer) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 136 | [只出现一次的数字](../../problems/single-number) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 37 | [解数独](../../problems/sudoku-solver) | [[哈希表](../hash-table/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 36 | [有效的数独](../../problems/valid-sudoku) | [[哈希表](../hash-table/README.md)] | Medium | -| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1 | [两数之和](../../problems/two-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/math/README.md b/tag/math/README.md index 841dc593e..fb0072c87 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,200 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1739 | [放置盒子](../../problems/building-boxes) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1735 | [生成乘积数组的方案数](../../problems/count-ways-to-make-array-with-product) | [[数学](../math/README.md)] | Hard | -| 1716 | [计算力扣银行的钱](../../problems/calculate-money-in-leetcode-bank) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Easy | -| 1685 | [有序数组中差绝对值之和](../../problems/sum-of-absolute-differences-in-a-sorted-array) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 1680 | [连接连续二进制数字](../../problems/concatenation-of-consecutive-binary-numbers) | [[数学](../math/README.md)] | Medium | -| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | -| 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1627 | [带阈值的图连通性](../../problems/graph-connectivity-with-threshold) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | -| 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard | -| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 1551 | [使数组中所有元素相等的最小操作数](../../problems/minimum-operations-to-make-array-equal) | [[数学](../math/README.md)] | Medium | -| 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1523 | [在区间范围内统计奇数数目](../../problems/count-odd-numbers-in-an-interval-range) | [[数学](../math/README.md)] | Easy | -| 1513 | [仅含 1 的子串数](../../problems/number-of-substrings-with-only-1s) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1492 | [n 的第 k 个因子](../../problems/the-kth-factor-of-n) | [[数学](../math/README.md)] | Medium | -| 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] | Medium | -| 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1427 | [字符串的左右移](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 1390 | [四因数](../../problems/four-divisors) | [[数学](../math/README.md)] | Medium | -| 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1362 | [最接近的因数](../../problems/closest-divisors) | [[数学](../math/README.md)] | Medium | -| 1359 | [有效的快递序列数目](../../problems/count-all-valid-pickup-and-delivery-options) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1344 | [时钟指针的夹角](../../problems/angle-between-hands-of-a-clock) | [[数学](../math/README.md)] | Medium | -| 1330 | [翻转子数组得到最大的数组值](../../problems/reverse-subarray-to-maximize-array-value) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | -| 1323 | [6 和 9 组成的最大数字](../../problems/maximum-69-number) | [[数学](../math/README.md)] | Easy | -| 1317 | [将整数转换为两个无零整数的和](../../problems/convert-integer-to-the-sum-of-two-no-zero-integers) | [[数学](../math/README.md)] | Easy | -| 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1281 | [整数的各位积和之差](../../problems/subtract-the-product-and-sum-of-digits-of-an-integer) | [[数学](../math/README.md)] | Easy | -| 1276 | [不浪费原料的汉堡制作方案](../../problems/number-of-burgers-with-no-waste-of-ingredients) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1271 | [十六进制魔术数字](../../problems/hexspeak) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 1259 | [不相交的握手](../../problems/handshakes-that-dont-cross) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1256 | [加密数字](../../problems/encode-number) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | -| 1253 | [重构 2 行二进制矩阵](../../problems/reconstruct-a-2-row-binary-matrix) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 1250 | [检查「好数组」](../../problems/check-if-it-is-a-good-array) | [[数学](../math/README.md)] | Hard | -| 1238 | [循环码排列](../../problems/circular-permutation-in-binary-representation) | [[数学](../math/README.md)] | Medium | -| 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 1230 | [抛掷硬币](../../problems/toss-strange-coins) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1228 | [等差数列中缺失的数字](../../problems/missing-number-in-arithmetic-progression) 🔒 | [[数学](../math/README.md)] | Easy | -| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1217 | [玩筹码](../../problems/minimum-cost-to-move-chips-to-the-same-position) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1199 | [建造街区的最短时间](../../problems/minimum-time-to-build-blocks) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1183 | [矩阵中 1 的最大数量](../../problems/maximum-number-of-ones) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | -| 1180 | [统计只含单一字母的子串](../../problems/count-substrings-with-only-one-distinct-letter) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 1175 | [质数排列](../../problems/prime-arrangements) | [[数学](../math/README.md)] | Easy | -| 1154 | [一年中的第几天](../../problems/day-of-the-year) | [[数学](../math/README.md)] | Easy | -| 1134 | [阿姆斯特朗数](../../problems/armstrong-number) 🔒 | [[数学](../math/README.md)] | Easy | -| 1131 | [绝对值表达式的最大值](../../problems/maximum-of-absolute-value-expression) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | -| 1121 | [将数组分成几个递增序列](../../problems/divide-array-into-increasing-sequences) 🔒 | [[数学](../math/README.md)] | Hard | -| 1109 | [航班预订统计](../../problems/corporate-flight-bookings) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1104 | [二叉树寻路](../../problems/path-in-zigzag-labelled-binary-tree) | [[树](../tree/README.md)] [[数学](../math/README.md)] | Medium | -| 1103 | [分糖果 II](../../problems/distribute-candies-to-people) | [[数学](../math/README.md)] | Easy | -| 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1088 | [易混淆数 II](../../problems/confusing-number-ii) 🔒 | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1073 | [负二进制数相加](../../problems/adding-two-negabinary-numbers) | [[数学](../math/README.md)] | Medium | -| 1067 | [范围内的数字计数](../../problems/digit-count-in-range) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1056 | [易混淆数](../../problems/confusing-number) 🔒 | [[数学](../math/README.md)] | Easy | -| 1041 | [困于环中的机器人](../../problems/robot-bounded-in-circle) | [[数学](../math/README.md)] | Medium | -| 1037 | [有效的回旋镖](../../problems/valid-boomerang) | [[数学](../math/README.md)] | Easy | -| 1025 | [除数博弈](../../problems/divisor-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 1017 | [负二进制转换](../../problems/convert-to-base-2) | [[数学](../math/README.md)] | Medium | -| 1015 | [可被 K 整除的最小整数](../../problems/smallest-integer-divisible-by-k) | [[数学](../math/README.md)] | Medium | -| 1012 | [至少有 1 位重复的数字](../../problems/numbers-with-repeated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1009 | [十进制整数的反码](../../problems/complement-of-base-10-integer) | [[数学](../math/README.md)] | Easy | -| 1006 | [笨阶乘](../../problems/clumsy-factorial) | [[数学](../math/README.md)] | Medium | -| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 991 | [坏了的计算器](../../problems/broken-calculator) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 976 | [三角形的最大周长](../../problems/largest-perimeter-triangle) | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Easy | -| 972 | [相等的有理数](../../problems/equal-rational-numbers) | [[数学](../math/README.md)] | Hard | -| 970 | [强整数](../../problems/powerful-integers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 964 | [表示数字的最少运算符](../../problems/least-operators-to-express-number) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | -| 952 | [按公因数计算最大组件大小](../../problems/largest-component-size-by-common-factor) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | -| 949 | [给定数字能组成的最大时间](../../problems/largest-time-for-given-digits) | [[数学](../math/README.md)] | Medium | -| 942 | [增减字符串匹配](../../problems/di-string-match) | [[数学](../math/README.md)] | Easy | -| 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 910 | [最小差值 II](../../problems/smallest-range-ii) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 908 | [最小差值 I](../../problems/smallest-range-i) | [[数学](../math/README.md)] | Easy | -| 906 | [超级回文数](../../problems/super-palindromes) | [[数学](../math/README.md)] | Hard | -| 902 | [最大为 N 的数字组合](../../problems/numbers-at-most-n-given-digit-set) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 892 | [三维形体的表面积](../../problems/surface-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | -| 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | -| 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 885 | [螺旋矩阵 III](../../problems/spiral-matrix-iii) | [[数学](../math/README.md)] | Medium | -| 883 | [三维形体投影面积](../../problems/projection-area-of-3d-shapes) | [[数学](../math/README.md)] | Easy | -| 878 | [第 N 个神奇数字](../../problems/nth-magical-number) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 877 | [石子游戏](../../problems/stone-game) | [[极小化极大](../minimax/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 869 | [重新排序得到 2 的幂](../../problems/reordered-power-of-2) | [[数学](../math/README.md)] | Medium | -| 868 | [二进制间距](../../problems/binary-gap) | [[数学](../math/README.md)] | Easy | -| 866 | [回文素数](../../problems/prime-palindrome) | [[数学](../math/README.md)] | Medium | -| 858 | [镜面反射](../../problems/mirror-reflection) | [[数学](../math/README.md)] | Medium | -| 836 | [矩形重叠](../../problems/rectangle-overlap) | [[数学](../math/README.md)] | Easy | -| 829 | [连续整数求和](../../problems/consecutive-numbers-sum) | [[数学](../math/README.md)] | Hard | -| 812 | [最大三角形面积](../../problems/largest-triangle-area) | [[数学](../math/README.md)] | Easy | -| 810 | [黑板异或游戏](../../problems/chalkboard-xor-game) | [[数学](../math/README.md)] | Hard | -| 805 | [数组的均值分割](../../problems/split-array-with-same-average) | [[数学](../math/README.md)] | Hard | -| 800 | [相似 RGB 颜色](../../problems/similar-rgb-color) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 789 | [逃脱阻碍者](../../problems/escape-the-ghosts) | [[数学](../math/README.md)] | Medium | -| 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | -| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 780 | [到达终点](../../problems/reaching-points) | [[数学](../math/README.md)] | Hard | -| 775 | [全局倒置与局部倒置](../../problems/global-and-local-inversions) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 754 | [到达终点数字](../../problems/reach-a-number) | [[数学](../math/README.md)] | Medium | -| 753 | [破解保险箱](../../problems/cracking-the-safe) | [[深度优先搜索](../depth-first-search/README.md)] [[数学](../math/README.md)] | Hard | -| 728 | [自除数](../../problems/self-dividing-numbers) | [[数学](../math/README.md)] | Easy | -| 672 | [灯泡开关 Ⅱ](../../problems/bulb-switcher-ii) | [[数学](../math/README.md)] | Medium | -| 670 | [最大交换](../../problems/maximum-swap) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 660 | [移除 9](../../problems/remove-9) 🔒 | [[数学](../math/README.md)] | Hard | -| 651 | [4键键盘](../../problems/4-keys-keyboard) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 645 | [错误的集合](../../problems/set-mismatch) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 640 | [求解方程](../../problems/solve-the-equation) | [[数学](../math/README.md)] | Medium | -| 634 | [寻找数组的错位排列](../../problems/find-the-derangement-of-an-array) 🔒 | [[数学](../math/README.md)] | Medium | -| 633 | [平方数之和](../../problems/sum-of-square-numbers) | [[数学](../math/README.md)] | Medium | -| 628 | [三个数的最大乘积](../../problems/maximum-product-of-three-numbers) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 598 | [范围求和 II](../../problems/range-addition-ii) | [[数学](../math/README.md)] | Easy | -| 593 | [有效的正方形](../../problems/valid-square) | [[数学](../math/README.md)] | Medium | -| 592 | [分数加减运算](../../problems/fraction-addition-and-subtraction) | [[数学](../math/README.md)] | Medium | -| 573 | [松鼠模拟](../../problems/squirrel-simulation) 🔒 | [[数学](../math/README.md)] | Medium | -| 553 | [最优除法](../../problems/optimal-division) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 535 | [TinyURL 的加密与解密](../../problems/encode-and-decode-tinyurl) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 523 | [连续的子数组和](../../problems/continuous-subarray-sum) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 517 | [超级洗衣机](../../problems/super-washing-machines) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 507 | [完美数](../../problems/perfect-number) | [[数学](../math/README.md)] | Easy | -| 492 | [构造矩形](../../problems/construct-the-rectangle) | [[数学](../math/README.md)] | Easy | -| 483 | [最小好进制](../../problems/smallest-good-base) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | -| 469 | [凸多边形](../../problems/convex-polygon) 🔒 | [[数学](../math/README.md)] | Medium | -| 462 | [最少移动次数使数组元素相等 II](../../problems/minimum-moves-to-equal-array-elements-ii) | [[数学](../math/README.md)] | Medium | -| 458 | [可怜的小猪](../../problems/poor-pigs) | [[数学](../math/README.md)] | Hard | -| 453 | [最小操作次数使数组元素相等](../../problems/minimum-moves-to-equal-array-elements) | [[数学](../math/README.md)] | Easy | -| 447 | [回旋镖的数量](../../problems/number-of-boomerangs) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 441 | [排列硬币](../../problems/arranging-coins) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 423 | [从英文中重建数字](../../problems/reconstruct-original-digits-from-english) | [[数学](../math/README.md)] | Medium | -| 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 400 | [第 N 位数字](../../problems/nth-digit) | [[数学](../math/README.md)] | Medium | -| 397 | [整数替换](../../problems/integer-replacement) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | -| 396 | [旋转函数](../../problems/rotate-function) | [[数学](../math/README.md)] | Medium | -| 372 | [超级次方](../../problems/super-pow) | [[数学](../math/README.md)] | Medium | -| 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 367 | [有效的完全平方数](../../problems/valid-perfect-square) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 365 | [水壶问题](../../problems/water-and-jug-problem) | [[数学](../math/README.md)] | Medium | -| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 356 | [直线镜像](../../problems/line-reflection) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 343 | [整数拆分](../../problems/integer-break) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 335 | [路径交叉](../../problems/self-crossing) | [[数学](../math/README.md)] | Hard | -| 326 | [3的幂](../../problems/power-of-three) | [[数学](../math/README.md)] | Easy | -| 319 | [灯泡开关](../../problems/bulb-switcher) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Medium | -| 313 | [超级丑数](../../problems/super-ugly-number) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | -| 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | -| 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 268 | [丢失的数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 263 | [丑数](../../problems/ugly-number) | [[数学](../math/README.md)] | Easy | -| 258 | [各位相加](../../problems/add-digits) | [[数学](../math/README.md)] | Easy | -| 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | -| 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 246 | [中心对称数](../../problems/strobogrammatic-number) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 233 | [数字 1 的个数](../../problems/number-of-digit-one) | [[数学](../math/README.md)] | Hard | -| 231 | [2的幂](../../problems/power-of-two) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | -| 224 | [基本计算器](../../problems/basic-calculator) | [[栈](../stack/README.md)] [[数学](../math/README.md)] | Hard | -| 223 | [矩形面积](../../problems/rectangle-area) | [[数学](../math/README.md)] | Medium | -| 204 | [计数质数](../../problems/count-primes) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 202 | [快乐数](../../problems/happy-number) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 172 | [阶乘后的零](../../problems/factorial-trailing-zeroes) | [[数学](../math/README.md)] | Easy | -| 171 | [Excel表列序号](../../problems/excel-sheet-column-number) | [[数学](../math/README.md)] | Easy | -| 168 | [Excel表列名称](../../problems/excel-sheet-column-title) | [[数学](../math/README.md)] | Easy | -| 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | -| 69 | [x 的平方根](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 67 | [二进制求和](../../problems/add-binary) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 65 | [有效数字](../../problems/valid-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 60 | [排列序列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 50 | [Pow(x, n)](../../problems/powx-n) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 29 | [两数相除](../../problems/divide-two-integers) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 9 | [回文数](../../problems/palindrome-number) | [[数学](../math/README.md)] | Easy | -| 8 | [字符串转换整数 (atoi)](../../problems/string-to-integer-atoi) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 7 | [整数反转](../../problems/reverse-integer) | [[数学](../math/README.md)] | Easy | -| 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index 52afd5989..85faedb8e 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -9,3 +9,17 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | +| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 855 | [考场就座](../../problems/exam-room) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 846 | [一手顺子](../../problems/hand-of-straights) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 731 | [我的日程安排表 II](../../problems/my-calendar-ii) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 683 | [K 个关闭的灯泡](../../problems/k-empty-slots) 🔒 | [[Ordered Map](../ordered-map/README.md)] | Hard | +| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index 8922feba8..71e7795da 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -9,3 +9,13 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | +| 933 | [最近的请求次数](../../problems/number-of-recent-calls) | [[队列](../queue/README.md)] | Easy | +| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | +| 582 | [杀死进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | +| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | diff --git a/tag/random/README.md b/tag/random/README.md index 72a82d98f..25144cd0a 100644 --- a/tag/random/README.md +++ b/tag/random/README.md @@ -9,3 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | +| 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | +| 519 | [随机翻转矩阵](../../problems/random-flip-matrix) | [[Random](../random/README.md)] | Medium | +| 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | +| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | +| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index f17ca04aa..cf753e23c 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -14,13 +14,14 @@ | 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | | 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | | 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[递归](../recursion/README.md)] | Easy | +| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | | 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | +| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[递归](../recursion/README.md)] | Medium | | 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | @@ -31,6 +32,7 @@ | 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | +| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 395 | [至少有K个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | | 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/string/README.md b/tag/string/README.md index cd7990fb5..dabd214b3 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,218 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1737 | [满足三条件之一需改变的最少字符数](../../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1736 | [替换隐藏数字得到的最晚时间](../../problems/latest-time-by-replacing-hidden-digits) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | -| 1704 | [判断字符串的两半是否相似](../../problems/determine-if-string-halves-are-alike) | [[字符串](../string/README.md)] | Easy | -| 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | -| 1694 | [重新格式化电话号码](../../problems/reformat-phone-number) | [[字符串](../string/README.md)] | Easy | -| 1684 | [统计一致字符串的数目](../../problems/count-the-number-of-consistent-strings) | [[字符串](../string/README.md)] | Easy | -| 1682 | [最长回文子序列 II](../../problems/longest-palindromic-subsequence-ii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1678 | [设计 Goal 解析器](../../problems/goal-parser-interpretation) | [[字符串](../string/README.md)] | Easy | -| 1668 | [最大重复子字符串](../../problems/maximum-repeating-substring) | [[字符串](../string/README.md)] | Easy | -| 1662 | [检查两个字符串数组是否相等](../../problems/check-if-two-string-arrays-are-equivalent) | [[字符串](../string/README.md)] | Easy | -| 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1624 | [两个相同字符之间的最长子字符串](../../problems/largest-substring-between-two-equal-characters) | [[字符串](../string/README.md)] | Easy | -| 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1614 | [括号的最大嵌套深度](../../problems/maximum-nesting-depth-of-the-parentheses) | [[字符串](../string/README.md)] | Easy | -| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | -| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Hard | -| 1592 | [重新排列单词间的空格](../../problems/rearrange-spaces-between-words) | [[字符串](../string/README.md)] | Easy | -| 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | -| 1576 | [替换所有的问号](../../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | [[字符串](../string/README.md)] | Easy | -| 1573 | [分割字符串的方案数](../../problems/number-of-ways-to-split-a-string) | [[字符串](../string/README.md)] | Medium | -| 1556 | [千位分隔数](../../problems/thousand-separator) | [[字符串](../string/README.md)] | Easy | -| 1545 | [找出第 N 个二进制字符串中的第 K 位](../../problems/find-kth-bit-in-nth-binary-string) | [[字符串](../string/README.md)] | Medium | -| 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | -| 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Hard | -| 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[字符串](../string/README.md)] | Medium | -| 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1513 | [仅含 1 的子串数](../../problems/number-of-substrings-with-only-1s) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 1507 | [转变日期格式](../../problems/reformat-date) | [[字符串](../string/README.md)] | Easy | -| 1496 | [判断路径是否相交](../../problems/path-crossing) | [[字符串](../string/README.md)] | Easy | -| 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1455 | [检查单词是否为句中其他单词的前缀](../../problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | [[字符串](../string/README.md)] | Easy | -| 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1446 | [连续字符](../../problems/consecutive-characters) | [[字符串](../string/README.md)] | Easy | -| 1436 | [旅行终点站](../../problems/destination-city) | [[字符串](../string/README.md)] | Easy | -| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1432 | [改变一个整数能得到的最大差值](../../problems/max-difference-you-can-get-from-changing-an-integer) | [[字符串](../string/README.md)] | Medium | -| 1422 | [分割字符串的最大得分](../../problems/maximum-score-after-splitting-a-string) | [[字符串](../string/README.md)] | Easy | -| 1419 | [数青蛙](../../problems/minimum-number-of-frogs-croaking) | [[字符串](../string/README.md)] | Medium | -| 1417 | [重新格式化字符串](../../problems/reformat-the-string) | [[字符串](../string/README.md)] | Easy | -| 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1408 | [数组中的字符串匹配](../../problems/string-matching-in-an-array) | [[字符串](../string/README.md)] | Easy | -| 1404 | [将二进制表示减到 1 的步骤数](../../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1392 | [最长快乐前缀](../../problems/longest-happy-prefix) | [[字符串](../string/README.md)] | Hard | -| 1374 | [生成每种字符都是奇数个的字符串](../../problems/generate-a-string-with-characters-that-have-odd-counts) | [[字符串](../string/README.md)] | Easy | -| 1371 | [每个元音包含偶数次的最长子字符串](../../problems/find-the-longest-substring-containing-vowels-in-even-counts) | [[字符串](../string/README.md)] | Medium | -| 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | -| 1358 | [包含所有三种字符的子字符串数目](../../problems/number-of-substrings-containing-all-three-characters) | [[字符串](../string/README.md)] | Medium | -| 1347 | [制造字母异位词的最小步骤数](../../problems/minimum-number-of-steps-to-make-two-strings-anagram) | [[字符串](../string/README.md)] | Medium | -| 1332 | [删除回文子序列](../../problems/remove-palindromic-subsequences) | [[字符串](../string/README.md)] | Easy | -| 1328 | [破坏回文串](../../problems/break-a-palindrome) | [[字符串](../string/README.md)] | Medium | -| 1324 | [竖直打印单词](../../problems/print-words-vertically) | [[字符串](../string/README.md)] | Medium | -| 1316 | [不同的循环子字符串](../../problems/distinct-echo-substrings) | [[字符串](../string/README.md)] | Hard | -| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1309 | [解码字母到整数映射](../../problems/decrypt-string-from-alphabet-to-integer-mapping) | [[字符串](../string/README.md)] | Easy | -| 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1271 | [十六进制魔术数字](../../problems/hexspeak) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 1268 | [搜索推荐系统](../../problems/search-suggestions-system) | [[字符串](../string/README.md)] | Medium | -| 1249 | [移除无效的括号](../../problems/minimum-remove-to-make-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1247 | [交换字符使得字符串相同](../../problems/minimum-swaps-to-make-strings-equal) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1233 | [删除子文件夹](../../problems/remove-sub-folders-from-the-filesystem) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | -| 1221 | [分割平衡字符串](../../problems/split-a-string-in-balanced-strings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | -| 1216 | [验证回文字符串 III](../../problems/valid-palindrome-iii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1189 | [“气球” 的最大数量](../../problems/maximum-number-of-balloons) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 1181 | [前后拼接](../../problems/before-and-after-puzzle) 🔒 | [[字符串](../string/README.md)] | Medium | -| 1180 | [统计只含单一字母的子串](../../problems/count-substrings-with-only-one-distinct-letter) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 1177 | [构建回文串检测](../../problems/can-make-palindrome-from-substring) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | -| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1169 | [查询无效交易](../../problems/invalid-transactions) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | -| 1165 | [单行键盘](../../problems/single-row-keyboard) 🔒 | [[字符串](../string/README.md)] | Easy | -| 1163 | [按字典序排在最后的子串](../../problems/last-substring-in-lexicographical-order) | [[字符串](../string/README.md)] | Hard | -| 1156 | [单字符重复子串的最大长度](../../problems/swap-for-longest-repeated-character-substring) | [[字符串](../string/README.md)] | Medium | -| 1138 | [字母板上的路径](../../problems/alphabet-board-path) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1119 | [删去字符串中的元音](../../problems/remove-vowels-from-a-string) 🔒 | [[字符串](../string/README.md)] | Easy | -| 1108 | [IP 地址无效化](../../problems/defanging-an-ip-address) | [[字符串](../string/README.md)] | Easy | -| 1106 | [解析布尔表达式](../../problems/parsing-a-boolean-expression) | [[字符串](../string/README.md)] | Hard | -| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1096 | [花括号展开 II](../../problems/brace-expansion-ii) | [[字符串](../string/README.md)] | Hard | -| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1071 | [字符串的最大公因子](../../problems/greatest-common-divisor-of-strings) | [[字符串](../string/README.md)] | Easy | -| 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Easy | -| 1062 | [最长重复子串](../../problems/longest-repeating-substring) 🔒 | [[字符串](../string/README.md)] | Medium | -| 1023 | [驼峰式匹配](../../problems/camelcase-matching) | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | -| 1016 | [子串能表示从 1 到 N 数字的二进制串](../../problems/binary-string-with-substrings-representing-1-to-n) | [[字符串](../string/README.md)] | Medium | -| 1003 | [检查替换后的词是否有效](../../problems/check-if-word-is-valid-after-substitutions) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 937 | [重新排列日志文件](../../problems/reorder-data-in-log-files) | [[字符串](../string/README.md)] | Easy | -| 936 | [戳印序列](../../problems/stamping-the-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | -| 929 | [独特的电子邮件地址](../../problems/unique-email-addresses) | [[字符串](../string/README.md)] | Easy | -| 925 | [长按键入](../../problems/long-pressed-name) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 917 | [仅仅反转字母](../../problems/reverse-only-letters) | [[字符串](../string/README.md)] | Easy | -| 916 | [单词子集](../../problems/word-subsets) | [[字符串](../string/README.md)] | Medium | -| 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[字符串](../string/README.md)] | Easy | -| 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[字符串](../string/README.md)] | Medium | -| 859 | [亲密字符串](../../problems/buddy-strings) | [[字符串](../string/README.md)] | Easy | -| 856 | [括号的分数](../../problems/score-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 848 | [字母移位](../../problems/shifting-letters) | [[字符串](../string/README.md)] | Medium | -| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 833 | [字符串中的查找与替换](../../problems/find-and-replace-in-string) | [[字符串](../string/README.md)] | Medium | -| 831 | [隐藏个人信息](../../problems/masking-personal-information) | [[字符串](../string/README.md)] | Medium | -| 824 | [山羊拉丁文](../../problems/goat-latin) | [[字符串](../string/README.md)] | Easy | -| 819 | [最常见的单词](../../problems/most-common-word) | [[字符串](../string/README.md)] | Easy | -| 816 | [模糊坐标](../../problems/ambiguous-coordinates) | [[字符串](../string/README.md)] | Medium | -| 809 | [情感丰富的文字](../../problems/expressive-words) | [[字符串](../string/README.md)] | Medium | -| 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[字符串](../string/README.md)] | Easy | -| 800 | [相似 RGB 颜色](../../problems/similar-rgb-color) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 791 | [自定义字符串排序](../../problems/custom-sort-string) | [[字符串](../string/README.md)] | Medium | -| 788 | [旋转数字](../../problems/rotated-digits) | [[字符串](../string/README.md)] | Easy | -| 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | -| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | -| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | -| 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字符串](../string/README.md)] | Easy | -| 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[字符串](../string/README.md)] | Hard | -| 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 722 | [删除注释](../../problems/remove-comments) | [[字符串](../string/README.md)] | Medium | -| 709 | [转换成小写字母](../../problems/to-lower-case) | [[字符串](../string/README.md)] | Easy | -| 696 | [计数二进制子串](../../problems/count-binary-substrings) | [[字符串](../string/README.md)] | Easy | -| 686 | [重复叠加字符串匹配](../../problems/repeated-string-match) | [[字符串](../string/README.md)] | Medium | -| 681 | [最近时刻](../../problems/next-closest-time) 🔒 | [[字符串](../string/README.md)] | Medium | -| 680 | [验证回文字符串 Ⅱ](../../problems/valid-palindrome-ii) | [[字符串](../string/README.md)] | Easy | -| 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[字符串](../string/README.md)] | Medium | -| 657 | [机器人能否返回原点](../../problems/robot-return-to-origin) | [[字符串](../string/README.md)] | Easy | -| 647 | [回文子串](../../problems/palindromic-substrings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | -| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 616 | [给字符串添加加粗标签](../../problems/add-bold-tag-in-string) 🔒 | [[字符串](../string/README.md)] | Medium | -| 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 606 | [根据二叉树创建字符串](../../problems/construct-string-from-binary-tree) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Easy | -| 591 | [标签验证器](../../problems/tag-validator) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | -| 583 | [两个字符串的删除操作](../../problems/delete-operation-for-two-strings) | [[字符串](../string/README.md)] | Medium | -| 564 | [寻找最近的回文数](../../problems/find-the-closest-palindrome) | [[字符串](../string/README.md)] | Hard | -| 557 | [反转字符串中的单词 III](../../problems/reverse-words-in-a-string-iii) | [[字符串](../string/README.md)] | Easy | -| 556 | [下一个更大元素 III](../../problems/next-greater-element-iii) | [[字符串](../string/README.md)] | Medium | -| 555 | [分割连接字符串](../../problems/split-concatenated-strings) 🔒 | [[字符串](../string/README.md)] | Medium | -| 553 | [最优除法](../../problems/optimal-division) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 551 | [学生出勤记录 I](../../problems/student-attendance-record-i) | [[字符串](../string/README.md)] | Easy | -| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | -| 541 | [反转字符串 II](../../problems/reverse-string-ii) | [[字符串](../string/README.md)] | Easy | -| 539 | [最小时间差](../../problems/minimum-time-difference) | [[字符串](../string/README.md)] | Medium | -| 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | -| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Hard | -| 522 | [最长特殊序列 II](../../problems/longest-uncommon-subsequence-ii) | [[字符串](../string/README.md)] | Medium | -| 521 | [最长特殊序列 Ⅰ](../../problems/longest-uncommon-subsequence-i) | [[脑筋急转弯](../brainteaser/README.md)] [[字符串](../string/README.md)] | Easy | -| 520 | [检测大写字母](../../problems/detect-capital) | [[字符串](../string/README.md)] | Easy | -| 468 | [验证IP地址](../../problems/validate-ip-address) | [[字符串](../string/README.md)] | Medium | -| 459 | [重复的子字符串](../../problems/repeated-substring-pattern) | [[字符串](../string/README.md)] | Easy | -| 443 | [压缩字符串](../../problems/string-compression) | [[字符串](../string/README.md)] | Medium | -| 434 | [字符串中的单词数](../../problems/number-of-segments-in-a-string) | [[字符串](../string/README.md)] | Easy | -| 415 | [字符串相加](../../problems/add-strings) | [[字符串](../string/README.md)] | Easy | -| 408 | [有效单词缩写](../../problems/valid-word-abbreviation) 🔒 | [[字符串](../string/README.md)] | Easy | -| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 385 | [迷你语法分析器](../../problems/mini-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 383 | [赎金信](../../problems/ransom-note) | [[字符串](../string/README.md)] | Easy | -| 345 | [反转字符串中的元音字母](../../problems/reverse-vowels-of-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 344 | [反转字符串](../../problems/reverse-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | -| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 293 | [翻转游戏](../../problems/flip-game) 🔒 | [[字符串](../string/README.md)] | Easy | -| 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 271 | [字符串的编码与解码](../../problems/encode-and-decode-strings) 🔒 | [[字符串](../string/README.md)] | Medium | -| 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 214 | [最短回文串](../../problems/shortest-palindrome) | [[字符串](../string/README.md)] | Hard | -| 186 | [翻转字符串里的单词 II](../../problems/reverse-words-in-a-string-ii) 🔒 | [[字符串](../string/README.md)] | Medium | -| 165 | [比较版本号](../../problems/compare-version-numbers) | [[字符串](../string/README.md)] | Medium | -| 161 | [相隔为 1 的编辑距离](../../problems/one-edit-distance) 🔒 | [[字符串](../string/README.md)] | Medium | -| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 158 | [用 Read4 读取 N 个字符 II](../../problems/read-n-characters-given-read4-ii-call-multiple-times) 🔒 | [[字符串](../string/README.md)] | Hard | -| 157 | [用 Read4 读取 N 个字符](../../problems/read-n-characters-given-read4) 🔒 | [[字符串](../string/README.md)] | Easy | -| 151 | [翻转字符串里的单词](../../problems/reverse-words-in-a-string) | [[字符串](../string/README.md)] | Medium | -| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 125 | [验证回文串](../../problems/valid-palindrome) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 115 | [不同的子序列](../../problems/distinct-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 93 | [复原IP地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 91 | [解码方法](../../problems/decode-ways) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 87 | [扰乱字符串](../../problems/scramble-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 72 | [编辑距离](../../problems/edit-distance) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 71 | [简化路径](../../problems/simplify-path) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 68 | [文本左右对齐](../../problems/text-justification) | [[字符串](../string/README.md)] | Hard | -| 67 | [二进制求和](../../problems/add-binary) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 65 | [有效数字](../../problems/valid-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 58 | [最后一个单词的长度](../../problems/length-of-last-word) | [[字符串](../string/README.md)] | Easy | -| 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 38 | [外观数列](../../problems/count-and-say) | [[字符串](../string/README.md)] | Easy | -| 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 20 | [有效的括号](../../problems/valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | -| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 14 | [最长公共前缀](../../problems/longest-common-prefix) | [[字符串](../string/README.md)] | Easy | -| 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 8 | [字符串转换整数 (atoi)](../../problems/string-to-integer-atoi) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 6 | [Z 字形变换](../../problems/zigzag-conversion) | [[字符串](../string/README.md)] | Medium | -| 5 | [最长回文子串](../../problems/longest-palindromic-substring) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/topological-sort/README.md b/tag/topological-sort/README.md index 845df9d71..5a051c022 100644 --- a/tag/topological-sort/README.md +++ b/tag/topological-sort/README.md @@ -9,3 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 444 | [序列重建](../../problems/sequence-reconstruction) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | +| 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | diff --git a/tag/tree/README.md b/tag/tree/README.md index c99ee46d3..cf7af3ead 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1740 | [Find Distance in a Binary Tree](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] | Hard | | 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | @@ -51,6 +51,7 @@ | 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] | Medium | | 1110 | [删点成林](../../problems/delete-nodes-and-return-forest) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1104 | [二叉树寻路](../../problems/path-in-zigzag-labelled-binary-tree) | [[树](../tree/README.md)] [[数学](../math/README.md)] | Medium | +| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | | 1026 | [节点与其祖先之间的最大差值](../../problems/maximum-difference-between-node-and-ancestor) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1022 | [从根到叶的二进制数之和](../../problems/sum-of-root-to-leaf-binary-numbers) | [[树](../tree/README.md)] | Easy | @@ -58,7 +59,7 @@ | 998 | [最大二叉树 II](../../problems/maximum-binary-tree-ii) | [[树](../tree/README.md)] | Medium | | 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 988 | [从叶结点开始的最小字符串](../../problems/smallest-string-starting-from-leaf) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 979 | [在二叉树中分配硬币](../../problems/distribute-coins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 971 | [翻转二叉树以匹配先序遍历](../../problems/flip-binary-tree-to-match-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -75,7 +76,7 @@ | 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | | 814 | [二叉树剪枝](../../problems/binary-tree-pruning) | [[树](../tree/README.md)] | Medium | -| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Easy | +| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 742 | [二叉树最近的叶节点](../../problems/closest-leaf-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | | 701 | [二叉搜索树中的插入操作](../../problems/insert-into-a-binary-search-tree) | [[树](../tree/README.md)] | Medium | @@ -105,7 +106,7 @@ | 549 | [二叉树中最长的连续序列](../../problems/binary-tree-longest-consecutive-sequence-ii) 🔒 | [[树](../tree/README.md)] | Medium | | 545 | [二叉树的边界](../../problems/boundary-of-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | | 543 | [二叉树的直径](../../problems/diameter-of-binary-tree) | [[树](../tree/README.md)] | Easy | -| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] | Medium | +| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | | 530 | [二叉搜索树的最小绝对差](../../problems/minimum-absolute-difference-in-bst) | [[树](../tree/README.md)] | Easy | | 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index bf4d14937..2a1a9e85a 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1724 | [Checking Existence of Edge Length Limited Paths II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1724 | [检查边长度限制的路径是否存在 II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[贪心算法](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 1697 | [检查边长度限制的路径是否存在](../../problems/checking-existence-of-edge-length-limited-paths) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] | Hard | | 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] | Hard | From 18de5fd02df283af813c7b10af8e4faf5bf8b752 Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 24 Feb 2021 16:22:12 +0800 Subject: [PATCH 119/145] A: new --- README.md | 24 ++ problems/best-sightseeing-pair/README.md | 31 ++- .../README.md | 25 +- .../README.md | 46 ++-- .../README.md | 46 ++-- .../binary-tree-right-side-view/README.md | 40 ++- .../README.md | 44 ++-- problems/break-a-palindrome/README.md | 22 +- .../buildings-with-an-ocean-view/README.md | 28 ++ problems/candy/README.md | 20 +- .../README.md | 80 ++++++ problems/closest-subsequence-sum/README.md | 79 ++++++ .../README.md | 37 ++- .../README.md | 38 ++- .../README.md | 35 ++- .../README.md | 71 +++++ .../mysql_schemas.sql | 2 +- problems/decode-ways-ii/README.md | 2 +- problems/design-an-ordered-stream/README.md | 4 +- .../design-most-recently-used-queue/README.md | 34 +++ problems/design-tic-tac-toe/README.md | 2 +- problems/distinct-subsequences/README.md | 6 +- problems/equal-rational-numbers/README.md | 69 ++--- .../README.md | 2 +- .../README.md | 12 +- .../README.md | 14 + .../mysql_schemas.sql | 12 + .../README.md | 20 +- .../README.md | 74 ++++++ problems/is-graph-bipartite/README.md | 44 ++-- .../README.md | 4 +- .../largest-merge-of-two-strings/README.md | 85 ++++++ problems/leetflex-banned-accounts/README.md | 2 +- problems/longest-nice-substring/README.md | 65 +++++ .../README.md | 38 +-- problems/map-of-highest-peak/README.md | 80 ++++++ problems/max-consecutive-ones/README.md | 2 +- .../README.md | 70 +++++ .../README.md | 72 +++++ .../README.md | 72 +++++ .../README.md | 80 ++++++ .../README.md | 79 ++++++ problems/merge-strings-alternately/README.md | 67 +++++ .../README.md | 71 +++++ .../README.md | 66 +++++ .../README.md | 76 ++++++ .../minimum-limit-of-balls-in-a-bag/README.md | 83 ++++++ .../README.md | 67 +++++ .../README.md | 2 +- problems/number-of-1-bits/README.md | 9 +- problems/number-of-enclaves/README.md | 43 ++- problems/pascals-triangle-ii/README.md | 18 +- problems/pascals-triangle/README.md | 34 +-- problems/path-sum-iv/README.md | 2 +- problems/peeking-iterator/README.md | 44 +++- .../README.md | 2 +- .../recyclable-and-low-fat-products/README.md | 14 + .../mysql_schemas.sql | 7 + problems/relative-ranks/README.md | 50 +++- problems/repeated-substring-pattern/README.md | 33 ++- problems/restore-ip-addresses/README.md | 2 +- problems/reverse-linked-list-ii/README.md | 29 ++- problems/reverse-linked-list/README.md | 34 ++- problems/roman-to-integer/README.md | 16 +- .../README.md | 8 +- .../search-in-rotated-sorted-array/README.md | 9 +- .../README.md | 24 +- .../shortest-path-in-binary-matrix/README.md | 51 ++-- .../README.md | 30 +-- problems/sum-of-unique-elements/README.md | 59 +++++ problems/sum-root-to-leaf-numbers/README.md | 44 ++-- problems/surrounded-regions/README.md | 34 +-- problems/swap-salary/README.md | 39 ++- problems/symmetric-tree/README.md | 36 +-- .../the-k-weakest-rows-in-a-matrix/README.md | 47 ++-- problems/transpose-matrix/README.md | 36 ++- problems/tree-of-coprimes/README.md | 78 ++++++ problems/valid-palindrome/README.md | 12 +- problems/valid-parenthesis-string/README.md | 62 ++--- problems/validate-binary-tree-nodes/README.md | 22 +- problems/word-ladder-ii/README.md | 54 ++-- readme/1-300.md | 6 +- readme/301-600.md | 8 +- readme/601-900.md | 6 +- tag/README.md | 3 +- tag/backtracking/README.md | 66 +++++ tag/binary-search/README.md | 6 +- tag/bit-manipulation/README.md | 2 +- tag/breadth-first-search/README.md | 6 +- tag/depth-first-search/README.md | 155 +++++++++++ tag/design/README.md | 3 +- tag/divide-and-conquer/README.md | 1 + tag/dynamic-programming/README.md | 245 ------------------ tag/geometry/README.md | 9 - tag/graph/README.md | 53 ++++ tag/greedy/README.md | 7 + tag/hash-table/README.md | 140 ++++++++++ tag/heap/README.md | 4 +- tag/line-sweep/README.md | 6 - tag/linked-list/README.md | 43 --- tag/math/README.md | 200 ++++++++++++++ tag/meet-in-the-middle/README.md | 11 + tag/ordered-map/README.md | 14 - tag/queue/README.md | 1 + tag/recursion/README.md | 1 + tag/segment-tree/README.md | 16 ++ tag/sliding-window/README.md | 27 -- tag/sort/README.md | 75 ------ tag/string/README.md | 219 ++++++++++++++++ tag/tags.json | 5 + tag/tree/README.md | 7 +- tag/two-pointers/README.md | 1 + 112 files changed, 3334 insertions(+), 1038 deletions(-) create mode 100644 problems/buildings-with-an-ocean-view/README.md create mode 100644 problems/check-if-array-is-sorted-and-rotated/README.md create mode 100644 problems/closest-subsequence-sum/README.md create mode 100644 problems/count-number-of-homogenous-substrings/README.md create mode 100644 problems/design-most-recently-used-queue/README.md create mode 100644 problems/find-the-subtasks-that-did-not-execute/README.md create mode 100644 problems/find-the-subtasks-that-did-not-execute/mysql_schemas.sql create mode 100644 problems/form-array-by-concatenating-subarrays-of-another-array/README.md create mode 100644 problems/largest-merge-of-two-strings/README.md create mode 100644 problems/longest-nice-substring/README.md create mode 100644 problems/map-of-highest-peak/README.md create mode 100644 problems/maximize-palindrome-length-from-subsequences/README.md create mode 100644 problems/maximum-absolute-sum-of-any-subarray/README.md create mode 100644 problems/maximum-number-of-events-that-can-be-attended-ii/README.md create mode 100644 problems/maximum-score-from-performing-multiplication-operations/README.md create mode 100644 problems/maximum-score-from-removing-stones/README.md create mode 100644 problems/merge-strings-alternately/README.md create mode 100644 problems/minimum-changes-to-make-alternating-binary-string/README.md create mode 100644 problems/minimum-degree-of-a-connected-trio-in-a-graph/README.md create mode 100644 problems/minimum-length-of-string-after-deleting-similar-ends/README.md create mode 100644 problems/minimum-limit-of-balls-in-a-bag/README.md create mode 100644 problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md create mode 100644 problems/recyclable-and-low-fat-products/README.md create mode 100644 problems/recyclable-and-low-fat-products/mysql_schemas.sql create mode 100644 problems/sum-of-unique-elements/README.md create mode 100644 problems/tree-of-coprimes/README.md create mode 100644 tag/meet-in-the-middle/README.md diff --git a/README.md b/README.md index fb78fb408..729abf1fb 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,30 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1771 | [Maximize Palindrome Length From Subsequences](https://leetcode.com/problems/maximize-palindrome-length-from-subsequences "由子序列构造的最长回文串的长度") | [Go](problems/maximize-palindrome-length-from-subsequences) | Hard | +| 1770 | [Maximum Score from Performing Multiplication Operations](https://leetcode.com/problems/maximum-score-from-performing-multiplication-operations "执行乘法运算的最大分数") | [Go](problems/maximum-score-from-performing-multiplication-operations) | Medium | +| 1769 | [Minimum Number of Operations to Move All Balls to Each Box](https://leetcode.com/problems/minimum-number-of-operations-to-move-all-balls-to-each-box "移动所有球到每个盒子所需的最小操作数") | [Go](problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | Medium | +| 1768 | [Merge Strings Alternately](https://leetcode.com/problems/merge-strings-alternately "交替合并字符串") | [Go](problems/merge-strings-alternately) | Easy | +| 1767 | [Find the Subtasks That Did Not Execute](https://leetcode.com/problems/find-the-subtasks-that-did-not-execute) 🔒 | [MySQL](problems/find-the-subtasks-that-did-not-execute) | Hard | +| 1766 | [Tree of Coprimes](https://leetcode.com/problems/tree-of-coprimes "互质树") | [Go](problems/tree-of-coprimes) | Hard | +| 1765 | [Map of Highest Peak](https://leetcode.com/problems/map-of-highest-peak "地图中的最高点") | [Go](problems/map-of-highest-peak) | Medium | +| 1764 | [Form Array by Concatenating Subarrays of Another Array](https://leetcode.com/problems/form-array-by-concatenating-subarrays-of-another-array "通过连接另一个数组的子数组得到一个数组") | [Go](problems/form-array-by-concatenating-subarrays-of-another-array) | Medium | +| 1763 | [Longest Nice Substring](https://leetcode.com/problems/longest-nice-substring "最长的美好子字符串") | [Go](problems/longest-nice-substring) | Easy | +| 1762 | [Buildings With an Ocean View](https://leetcode.com/problems/buildings-with-an-ocean-view) 🔒 | [Go](problems/buildings-with-an-ocean-view) | Medium | +| 1761 | [Minimum Degree of a Connected Trio in a Graph](https://leetcode.com/problems/minimum-degree-of-a-connected-trio-in-a-graph "一个图中连通三元组的最小度数") | [Go](problems/minimum-degree-of-a-connected-trio-in-a-graph) | Hard | +| 1760 | [Minimum Limit of Balls in a Bag](https://leetcode.com/problems/minimum-limit-of-balls-in-a-bag "袋子里最少数目的球") | [Go](problems/minimum-limit-of-balls-in-a-bag) | Medium | +| 1759 | [Count Number of Homogenous Substrings](https://leetcode.com/problems/count-number-of-homogenous-substrings "统计同构子字符串的数目") | [Go](problems/count-number-of-homogenous-substrings) | Medium | +| 1758 | [Minimum Changes To Make Alternating Binary String](https://leetcode.com/problems/minimum-changes-to-make-alternating-binary-string "生成交替二进制字符串的最少操作数") | [Go](problems/minimum-changes-to-make-alternating-binary-string) | Easy | +| 1757 | [Recyclable and Low Fat Products](https://leetcode.com/problems/recyclable-and-low-fat-products) 🔒 | [MySQL](problems/recyclable-and-low-fat-products) | Easy | +| 1756 | [Design Most Recently Used Queue](https://leetcode.com/problems/design-most-recently-used-queue) 🔒 | [Go](problems/design-most-recently-used-queue) | Medium | +| 1755 | [Closest Subsequence Sum](https://leetcode.com/problems/closest-subsequence-sum "最接近目标值的子序列和") | [Go](problems/closest-subsequence-sum) | Hard | +| 1754 | [Largest Merge Of Two Strings](https://leetcode.com/problems/largest-merge-of-two-strings "构造字典序最大的合并字符串") | [Go](problems/largest-merge-of-two-strings) | Medium | +| 1753 | [Maximum Score From Removing Stones](https://leetcode.com/problems/maximum-score-from-removing-stones "移除石子的最大得分") | [Go](problems/maximum-score-from-removing-stones) | Medium | +| 1752 | [Check if Array Is Sorted and Rotated](https://leetcode.com/problems/check-if-array-is-sorted-and-rotated "检查数组是否经排序和轮转得到") | [Go](problems/check-if-array-is-sorted-and-rotated) | Easy | +| 1751 | [Maximum Number of Events That Can Be Attended II](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended-ii "最多可以参加的会议数目 II") | [Go](problems/maximum-number-of-events-that-can-be-attended-ii) | Hard | +| 1750 | [Minimum Length of String After Deleting Similar Ends](https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends "删除字符串两端相同字符后的最短长度") | [Go](problems/minimum-length-of-string-after-deleting-similar-ends) | Medium | +| 1749 | [Maximum Absolute Sum of Any Subarray](https://leetcode.com/problems/maximum-absolute-sum-of-any-subarray "任意子数组和的绝对值的最大值") | [Go](problems/maximum-absolute-sum-of-any-subarray) | Medium | +| 1748 | [Sum of Unique Elements](https://leetcode.com/problems/sum-of-unique-elements "唯一元素的和") | [Go](problems/sum-of-unique-elements) | Easy | | 1747 | [Leetflex Banned Accounts](https://leetcode.com/problems/leetflex-banned-accounts) 🔒 | [MySQL](problems/leetflex-banned-accounts) | Medium | | 1746 | [Maximum Subarray Sum After One Operation](https://leetcode.com/problems/maximum-subarray-sum-after-one-operation) 🔒 | [Go](problems/maximum-subarray-sum-after-one-operation) | Medium | | 1745 | [Palindrome Partitioning IV](https://leetcode.com/problems/palindrome-partitioning-iv "回文串分割 IV") | [Go](problems/palindrome-partitioning-iv) | Hard | diff --git a/problems/best-sightseeing-pair/README.md b/problems/best-sightseeing-pair/README.md index 73535759b..25ba93e5d 100644 --- a/problems/best-sightseeing-pair/README.md +++ b/problems/best-sightseeing-pair/README.md @@ -11,30 +11,35 @@ ## [1014. Best Sightseeing Pair (Medium)](https://leetcode.com/problems/best-sightseeing-pair "最佳观光组合") -

    Given an array A of positive integers, A[i] represents the value of the i-th sightseeing spot, and two sightseeing spots i and j have distance j - i between them.

    +

    You are given an integer array values where values[i] represents the value of the ith sightseeing spot. Two sightseeing spots i and j have a distance j - i between them.

    -

    The score of a pair (i < j) of sightseeing spots is (A[i] + A[j] + i - j) : the sum of the values of the sightseeing spots, minus the distance between them.

    +

    The score of a pair (i < j) of sightseeing spots is values[i] + values[j] + i - j: the sum of the values of the sightseeing spots, minus the distance between them.

    -

    Return the maximum score of a pair of sightseeing spots.

    +

    Return the maximum score of a pair of sightseeing spots.

     

    -

    Example 1:

    -Input: [8,1,5,2,6]
    -Output: 11
    -Explanation: i = 0, j = 2, A[i] + A[j] + i - j = 8 + 5 + 0 - 2 = 11
    +Input: values = [8,1,5,2,6]
    +Output: 11
    +Explanation: i = 0, j = 2, values[i] + values[j] + i - j = 8 + 5 + 0 - 2 = 11
     
    -

     

    +

    Example 2:

    + +
    +Input: values = [1,2]
    +Output: 2
    +
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. 2 <= A.length <= 50000
    2. -
    3. 1 <= A[i] <= 1000
    4. -
    +
      +
    • 2 <= values.length <= 5 * 104
    • +
    • 1 <= values[i] <= 1000
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/best-time-to-buy-and-sell-stock-ii/README.md b/problems/best-time-to-buy-and-sell-stock-ii/README.md index ab394120d..94814f1bc 100644 --- a/problems/best-time-to-buy-and-sell-stock-ii/README.md +++ b/problems/best-time-to-buy-and-sell-stock-ii/README.md @@ -11,44 +11,45 @@ ## [122. Best Time to Buy and Sell Stock II (Easy)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii "买卖股票的最佳时机 II") -

    Say you have an array prices for which the ith element is the price of a given stock on day i.

    +

    You are given an array prices for which the ith element is the price of a given stock on day i.

    -

    Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times).

    +

    Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times).

    -

    Note: You may not engage in multiple transactions at the same time (i.e., you must sell the stock before you buy again).

    +

    Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).

    +

     

    Example 1:

    -Input: [7,1,5,3,6,4]
    +Input: prices = [7,1,5,3,6,4]
     Output: 7
     Explanation: Buy on day 2 (price = 1) and sell on day 3 (price = 5), profit = 5-1 = 4.
    -             Then buy on day 4 (price = 3) and sell on day 5 (price = 6), profit = 6-3 = 3.
    +Then buy on day 4 (price = 3) and sell on day 5 (price = 6), profit = 6-3 = 3.
     

    Example 2:

    -Input: [1,2,3,4,5]
    +Input: prices = [1,2,3,4,5]
     Output: 4
     Explanation: Buy on day 1 (price = 1) and sell on day 5 (price = 5), profit = 5-1 = 4.
    -             Note that you cannot buy on day 1, buy on day 2 and sell them later, as you are
    -             engaging multiple transactions at the same time. You must sell before buying again.
    +Note that you cannot buy on day 1, buy on day 2 and sell them later, as you are engaging multiple transactions at the same time. You must sell before buying again.
     

    Example 3:

    -Input: [7,6,4,3,1]
    +Input: prices = [7,6,4,3,1]
     Output: 0
    -Explanation: In this case, no transaction is done, i.e. max profit = 0.
    +Explanation: In this case, no transaction is done, i.e., max profit = 0. +

     

    Constraints:

      -
    • 1 <= prices.length <= 3 * 10 ^ 4
    • -
    • 0 <= prices[i] <= 10 ^ 4
    • +
    • 1 <= prices.length <= 3 * 104
    • +
    • 0 <= prices[i] <= 104
    ### Related Topics diff --git a/problems/binary-tree-level-order-traversal-ii/README.md b/problems/binary-tree-level-order-traversal-ii/README.md index 979c5576a..8affa67ef 100644 --- a/problems/binary-tree-level-order-traversal-ii/README.md +++ b/problems/binary-tree-level-order-traversal-ii/README.md @@ -9,31 +9,39 @@                  [Next >](../convert-sorted-array-to-binary-search-tree "Convert Sorted Array to Binary Search Tree") -## [107. Binary Tree Level Order Traversal II (Easy)](https://leetcode.com/problems/binary-tree-level-order-traversal-ii "二叉树的层序遍历 II") +## [107. Binary Tree Level Order Traversal II (Medium)](https://leetcode.com/problems/binary-tree-level-order-traversal-ii "二叉树的层序遍历 II") -

    Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).

    +

    Given the root of a binary tree, return the bottom-up level order traversal of its nodes' values. (i.e., from left to right, level by level from leaf to root).

    -

    -For example:
    -Given binary tree [3,9,20,null,null,15,7],
    +

     

    +

    Example 1:

    +
    -    3
    -   / \
    -  9  20
    -    /  \
    -   15   7
    +Input: root = [3,9,20,null,null,15,7]
    +Output: [[15,7],[9,20],[3]]
     
    -

    -

    -return its bottom-up level order traversal as:
    + +

    Example 2:

    + +
    +Input: root = [1]
    +Output: [[1]]
    +
    + +

    Example 3:

    +
    -[
    -  [15,7],
    -  [9,20],
    -  [3]
    -]
    +Input: root = []
    +Output: []
     
    -

    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [0, 2000].
    • +
    • -1000 <= Node.val <= 1000
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/binary-tree-level-order-traversal/README.md b/problems/binary-tree-level-order-traversal/README.md index 31c4ec7a1..14a022f14 100644 --- a/problems/binary-tree-level-order-traversal/README.md +++ b/problems/binary-tree-level-order-traversal/README.md @@ -11,29 +11,37 @@ ## [102. Binary Tree Level Order Traversal (Medium)](https://leetcode.com/problems/binary-tree-level-order-traversal "二叉树的层序遍历") -

    Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).

    +

    Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level).

    -

    -For example:
    -Given binary tree [3,9,20,null,null,15,7],
    +

     

    +

    Example 1:

    +
    -    3
    -   / \
    -  9  20
    -    /  \
    -   15   7
    +Input: root = [3,9,20,null,null,15,7]
    +Output: [[3],[9,20],[15,7]]
     
    -

    -

    -return its level order traversal as:
    + +

    Example 2:

    + +
    +Input: root = [1]
    +Output: [[1]]
    +
    + +

    Example 3:

    +
    -[
    -  [3],
    -  [9,20],
    -  [15,7]
    -]
    +Input: root = []
    +Output: []
     
    -

    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [0, 2000].
    • +
    • -1000 <= Node.val <= 1000
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] @@ -41,7 +49,7 @@ return its level order traversal as:
    ### Similar Questions 1. [Binary Tree Zigzag Level Order Traversal](../binary-tree-zigzag-level-order-traversal) (Medium) - 1. [Binary Tree Level Order Traversal II](../binary-tree-level-order-traversal-ii) (Easy) + 1. [Binary Tree Level Order Traversal II](../binary-tree-level-order-traversal-ii) (Medium) 1. [Minimum Depth of Binary Tree](../minimum-depth-of-binary-tree) (Easy) 1. [Binary Tree Vertical Order Traversal](../binary-tree-vertical-order-traversal) (Medium) 1. [Average of Levels in Binary Tree](../average-of-levels-in-binary-tree) (Easy) diff --git a/problems/binary-tree-right-side-view/README.md b/problems/binary-tree-right-side-view/README.md index c4c1c1725..22244fcf6 100644 --- a/problems/binary-tree-right-side-view/README.md +++ b/problems/binary-tree-right-side-view/README.md @@ -11,26 +11,44 @@ ## [199. Binary Tree Right Side View (Medium)](https://leetcode.com/problems/binary-tree-right-side-view "二叉树的右视图") -

    Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.

    +

    Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.

    -

    Example:

    +

     

    +

    Example 1:

    + +
    +Input: root = [1,2,3,null,5,null,4]
    +Output: [1,3,4]
    +
    + +

    Example 2:

    -Input: [1,2,3,null,5,null,4]
    -Output: [1, 3, 4]
    -Explanation:
    -
    -   1            <---
    - /   \
    -2     3         <---
    - \     \
    -  5     4       <---
    +Input: root = [1,null,3]
    +Output: [1,3]
     
    +

    Example 3:

    + +
    +Input: root = []
    +Output: []
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [0, 100].
    • +
    • -100 <= Node.val <= 100
    • +
    + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Queue](../../tag/queue/README.md)] ### Similar Questions 1. [Populating Next Right Pointers in Each Node](../populating-next-right-pointers-in-each-node) (Medium) diff --git a/problems/binary-tree-zigzag-level-order-traversal/README.md b/problems/binary-tree-zigzag-level-order-traversal/README.md index 16ffa8bda..fee5e1949 100644 --- a/problems/binary-tree-zigzag-level-order-traversal/README.md +++ b/problems/binary-tree-zigzag-level-order-traversal/README.md @@ -11,29 +11,37 @@ ## [103. Binary Tree Zigzag Level Order Traversal (Medium)](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal "二叉树的锯齿形层序遍历") -

    Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).

    +

    Given the root of a binary tree, return the zigzag level order traversal of its nodes' values. (i.e., from left to right, then right to left for the next level and alternate between).

    -

    -For example:
    -Given binary tree [3,9,20,null,null,15,7],
    +

     

    +

    Example 1:

    +
    -    3
    -   / \
    -  9  20
    -    /  \
    -   15   7
    +Input: root = [3,9,20,null,null,15,7]
    +Output: [[3],[20,9],[15,7]]
     
    -

    -

    -return its zigzag level order traversal as:
    + +

    Example 2:

    + +
    +Input: root = [1]
    +Output: [[1]]
    +
    + +

    Example 3:

    +
    -[
    -  [3],
    -  [20,9],
    -  [15,7]
    -]
    +Input: root = []
    +Output: []
     
    -

    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [0, 2000].
    • +
    • -100 <= Node.val <= 100
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/break-a-palindrome/README.md b/problems/break-a-palindrome/README.md index bf8c6aaac..062474487 100644 --- a/problems/break-a-palindrome/README.md +++ b/problems/break-a-palindrome/README.md @@ -11,9 +11,11 @@ ## [1328. Break a Palindrome (Medium)](https://leetcode.com/problems/break-a-palindrome "破坏回文串") -

    Given a palindromic string palindrome, replace exactly one character with any lowercase English letter so that the string becomes the lexicographically smallest possible string that is not a palindrome.

    +

    Given a palindromic string of lowercase English letters palindrome, replace exactly one character with any lowercase English letter so that the resulting string is not a palindrome and that it is the lexicographically smallest one possible.

    -

    After doing so, return the final string. If there is no way to do so, return an empty string.

    +

    Return the resulting string. If there is no way to replace a character to make it not a palindrome, return an empty string.

    + +

    A string a is lexicographically smaller than a string b (of the same length) if in the first position where a and b differ, a has a character strictly smaller than the corresponding character in b. For example, "abcc" is lexicographically smaller than "abcd" because the first position they differ is at the fourth character, and 'c' is smaller than 'd'.

     

    Example 1:

    @@ -21,6 +23,8 @@
     Input: palindrome = "abccba"
     Output: "aaccba"
    +Explanation: There are many ways to make "abccba" not a palindrome, such as "zbccba", "aaccba", and "abacba".
    +Of all the ways, "aaccba" is the lexicographically smallest.
     

    Example 2:

    @@ -28,6 +32,20 @@
     Input: palindrome = "a"
     Output: ""
    +Explanation: There is no way to replace a single character to make "a" not a palindrome, so return an empty string.
    +
    + +

    Example 3:

    + +
    +Input: palindrome = "aa"
    +Output: "ab"
    + +

    Example 4:

    + +
    +Input: palindrome = "aba"
    +Output: "abb"
     

     

    diff --git a/problems/buildings-with-an-ocean-view/README.md b/problems/buildings-with-an-ocean-view/README.md new file mode 100644 index 000000000..6eaec32b0 --- /dev/null +++ b/problems/buildings-with-an-ocean-view/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../minimum-degree-of-a-connected-trio-in-a-graph "Minimum Degree of a Connected Trio in a Graph") +                 +[Next >](../longest-nice-substring "Longest Nice Substring") + +## [1762. Buildings With an Ocean View (Medium)](https://leetcode.com/problems/buildings-with-an-ocean-view "") + + + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +You can traverse the buildings from the nearest to the ocean to the furthest. +
    + +
    +Hint 2 +Keep with you the maximum to the right while traversing to determine if you can see the ocean or not. +
    diff --git a/problems/candy/README.md b/problems/candy/README.md index 4254bd489..5edb3f3c1 100644 --- a/problems/candy/README.md +++ b/problems/candy/README.md @@ -11,7 +11,7 @@ ## [135. Candy (Hard)](https://leetcode.com/problems/candy "分发糖果") -

    There are N children standing in a line. Each child is assigned a rating value.

    +

    There are n children standing in a line. Each child is assigned a rating value given in the integer array ratings.

    You are giving candies to these children subjected to the following requirements:

    @@ -20,12 +20,13 @@
  • Children with a higher rating get more candies than their neighbors.
  • -

    What is the minimum candies you must give?

    +

    Return the minimum number of candies you need to have to distribute the candies to the children.

    +

     

    Example 1:

    -Input: [1,0,2]
    +Input: ratings = [1,0,2]
     Output: 5
     Explanation: You can allocate to the first, second and third child with 2, 1, 2 candies respectively.
     
    @@ -33,11 +34,20 @@

    Example 2:

    -Input: [1,2,2]
    +Input: ratings = [1,2,2]
     Output: 4
     Explanation: You can allocate to the first, second and third child with 1, 2, 1 candies respectively.
    -             The third child gets 1 candy because it satisfies the above two conditions.
    +The third child gets 1 candy because it satisfies the above two conditions.
     
    +

     

    +

    Constraints:

    + +
      +
    • n == ratings.length
    • +
    • 1 <= n <= 2 * 104
    • +
    • 1 <= ratings[i] <= 2 * 104
    • +
    + ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/check-if-array-is-sorted-and-rotated/README.md b/problems/check-if-array-is-sorted-and-rotated/README.md new file mode 100644 index 000000000..cf7fd74e0 --- /dev/null +++ b/problems/check-if-array-is-sorted-and-rotated/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../maximum-number-of-events-that-can-be-attended-ii "Maximum Number of Events That Can Be Attended II") +                 +[Next >](../maximum-score-from-removing-stones "Maximum Score From Removing Stones") + +## [1752. Check if Array Is Sorted and Rotated (Easy)](https://leetcode.com/problems/check-if-array-is-sorted-and-rotated "检查数组是否经排序和轮转得到") + +

    Given an array nums, return true if the array was originally sorted in non-decreasing order, then rotated some number of positions (including zero). Otherwise, return false.

    + +

    There may be duplicates in the original array.

    + +

    Note: An array A rotated by x positions results in an array B of the same length such that A[i] == B[(i+x) % A.length], where % is the modulo operation.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [3,4,5,1,2]
    +Output: true
    +Explanation: [1,2,3,4,5] is the original sorted array.
    +You can rotate the array by x = 3 positions to begin on the the element of value 3: [3,4,5,1,2].
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,1,3,4]
    +Output: false
    +Explanation: There is no sorted array once rotated that can make nums.
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,2,3]
    +Output: true
    +Explanation: [1,2,3] is the original sorted array.
    +You can rotate the array by x = 0 positions (i.e. no rotation) to make nums.
    +
    + +

    Example 4:

    + +
    +Input: nums = [1,1,1]
    +Output: true
    +Explanation: [1,1,1] is the original sorted array.
    +You can rotate any number of positions to make nums.
    +
    + +

    Example 5:

    + +
    +Input: nums = [2,1]
    +Output: true
    +Explanation: [1,2] is the original sorted array.
    +You can rotate the array by x = 5 positions to begin on the element of value 2: [2,1].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • 1 <= nums[i] <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Brute force and check if it is possible for a sorted array to start from each position. +
    diff --git a/problems/closest-subsequence-sum/README.md b/problems/closest-subsequence-sum/README.md new file mode 100644 index 000000000..5ba810908 --- /dev/null +++ b/problems/closest-subsequence-sum/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../largest-merge-of-two-strings "Largest Merge Of Two Strings") +                 +[Next >](../design-most-recently-used-queue "Design Most Recently Used Queue") + +## [1755. Closest Subsequence Sum (Hard)](https://leetcode.com/problems/closest-subsequence-sum "最接近目标值的子序列和") + +

    You are given an integer array nums and an integer goal.

    + +

    You want to choose a subsequence of nums such that the sum of its elements is the closest possible to goal. That is, if the sum of the subsequence's elements is sum, then you want to minimize the absolute difference abs(sum - goal).

    + +

    Return the minimum possible value of abs(sum - goal).

    + +

    Note that a subsequence of an array is an array formed by removing some elements (possibly all or none) of the original array.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [5,-7,3,5], goal = 6
    +Output: 0
    +Explanation: Choose the whole array as a subsequence, with a sum of 6.
    +This is equal to the goal, so the absolute difference is 0.
    +
    + +

    Example 2:

    + +
    +Input: nums = [7,-9,15,-2], goal = -5
    +Output: 1
    +Explanation: Choose the subsequence [7,-9,-2], with a sum of -4.
    +The absolute difference is abs(-4 - (-5)) = abs(1) = 1, which is the minimum.
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,2,3], goal = -7
    +Output: 7
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 40
    • +
    • -107 <= nums[i] <= 107
    • +
    • -109 <= goal <= 109
    • +
    + +### Related Topics + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + +### Hints +
    +Hint 1 +The naive solution is to check all possible subsequences. This works in O(2^n). +
    + +
    +Hint 2 +Divide the array into two parts of nearly is equal size. +
    + +
    +Hint 3 +Consider all subsets of one part and make a list of all possible subset sums and sort this list. +
    + +
    +Hint 4 +Consider all subsets of the other part, and for each one, let its sum = x, do binary search to get the nearest possible value to goal - x in the first part. +
    diff --git a/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md b/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md index 6cab3faca..e4383d3bb 100644 --- a/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md +++ b/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md @@ -11,27 +11,36 @@ ## [106. Construct Binary Tree from Inorder and Postorder Traversal (Medium)](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal "从中序与后序遍历序列构造二叉树") -

    Given inorder and postorder traversal of a tree, construct the binary tree.

    - -

    Note:
    -You may assume that duplicates do not exist in the tree.

    - -

    For example, given

    +

    Given two integer arrays inorder and postorder where inorder is the inorder traversal of a binary tree and postorder is the postorder traversal of the same tree, construct and return the binary tree.

    +

     

    +

    Example 1:

    +
    -inorder = [9,3,15,20,7]
    -postorder = [9,15,7,20,3]
    +Input: inorder = [9,3,15,20,7], postorder = [9,15,7,20,3] +Output: [3,9,20,null,null,15,7] + -

    Return the following binary tree:

    +

    Example 2:

    -    3
    -   / \
    -  9  20
    -    /  \
    -   15   7
    +Input: inorder = [-1], postorder = [-1]
    +Output: []
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= inorder.length <= 3000
    • +
    • postorder.length == inorder.length
    • +
    • -3000 <= inorder[i], postorder[i] <= 3000
    • +
    • inorder and postorder consist of unique values.
    • +
    • Each value of postorder also appears in inorder.
    • +
    • inorder is guaranteed to be the inorder traversal of the tree.
    • +
    • postorder is guaranteed to be the postorder traversal of the tree.
    • +
    + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md b/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md index b90901203..8e1ffa01e 100644 --- a/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md +++ b/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md @@ -11,25 +11,35 @@ ## [105. Construct Binary Tree from Preorder and Inorder Traversal (Medium)](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal "从前序与中序遍历序列构造二叉树") -

    Given preorder and inorder traversal of a tree, construct the binary tree.

    - -

    Note:
    -You may assume that duplicates do not exist in the tree.

    - -

    For example, given

    +

    Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the same tree, construct and return the binary tree.

    +

     

    +

    Example 1:

    +
    -preorder = [3,9,20,15,7]
    -inorder = [9,3,15,20,7]
    +Input: preorder = [3,9,20,15,7], inorder = [9,3,15,20,7] +Output: [3,9,20,null,null,15,7] + -

    Return the following binary tree:

    +

    Example 2:

    -    3
    -   / \
    -  9  20
    -    /  \
    -   15   7
    +Input: preorder = [-1], inorder = [-1] +Output: [-1] + + +

     

    +

    Constraints:

    + +
      +
    • 1 <= preorder.length <= 3000
    • +
    • inorder.length == preorder.length
    • +
    • -3000 <= preorder[i], inorder[i] <= 3000
    • +
    • preorder and inorder consist of unique values.
    • +
    • Each value of inorder also appears in preorder.
    • +
    • preorder is guaranteed to be the preorder traversal of the tree.
    • +
    • inorder is guaranteed to be the inorder traversal of the tree.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/convert-sorted-array-to-binary-search-tree/README.md b/problems/convert-sorted-array-to-binary-search-tree/README.md index 7b9ec6396..2fe1439c5 100644 --- a/problems/convert-sorted-array-to-binary-search-tree/README.md +++ b/problems/convert-sorted-array-to-binary-search-tree/README.md @@ -11,23 +11,36 @@ ## [108. Convert Sorted Array to Binary Search Tree (Easy)](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree "将有序数组转换为二叉搜索树") -

    Given an array where elements are sorted in ascending order, convert it to a height balanced BST.

    +

    Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree.

    -

    For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1.

    +

    A height-balanced binary tree is a binary tree in which the depth of the two subtrees of every node never differs by more than one.

    -

    Example:

    +

     

    +

    Example 1:

    + +
    +Input: nums = [-10,-3,0,5,9]
    +Output: [0,-3,9,-10,null,5]
    +Explanation: [0,-10,5,null,-3,null,9] is also accepted:
    +
    +
    +

    Example 2:

    +
    -Given the sorted array: [-10,-3,0,5,9],
    +Input: nums = [1,3]
    +Output: [3,1]
    +Explanation: [1,3] and [3,1] are both a height-balanced BSTs.
    +
    -One possible answer is: [0,-3,9,-10,null,5], which represents the following height balanced BST: +

     

    +

    Constraints:

    - 0 - / \ - -3 9 - / / - -10 5 - +
      +
    • 1 <= nums.length <= 104
    • +
    • -104 <= nums[i] <= 104
    • +
    • nums is sorted in a strictly increasing order.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/count-number-of-homogenous-substrings/README.md b/problems/count-number-of-homogenous-substrings/README.md new file mode 100644 index 000000000..517f518d7 --- /dev/null +++ b/problems/count-number-of-homogenous-substrings/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../minimum-changes-to-make-alternating-binary-string "Minimum Changes To Make Alternating Binary String") +                 +[Next >](../minimum-limit-of-balls-in-a-bag "Minimum Limit of Balls in a Bag") + +## [1759. Count Number of Homogenous Substrings (Medium)](https://leetcode.com/problems/count-number-of-homogenous-substrings "统计同构子字符串的数目") + +

    Given a string s, return the number of homogenous substrings of s. Since the answer may be too large, return it modulo 109 + 7.

    + +

    A string is homogenous if all the characters of the string are the same.

    + +

    A substring is a contiguous sequence of characters within a string.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "abbcccaa"
    +Output: 13
    +Explanation: The homogenous substrings are listed as below:
    +"a"   appears 3 times.
    +"aa"  appears 1 time.
    +"b"   appears 2 times.
    +"bb"  appears 1 time.
    +"c"   appears 3 times.
    +"cc"  appears 2 times.
    +"ccc" appears 1 time.
    +3 + 1 + 2 + 1 + 3 + 2 + 1 = 13.
    + +

    Example 2:

    + +
    +Input: s = "xy"
    +Output: 2
    +Explanation: The homogenous substrings are "x" and "y".
    + +

    Example 3:

    + +
    +Input: s = "zzzzz"
    +Output: 15
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 105
    • +
    • s consists of lowercase letters.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +A string of only 'a's of length k contains k choose 2 homogenous substrings. +
    + +
    +Hint 2 +Split the string into substrings where each substring contains only one letter, and apply the formula on each substring's length. +
    diff --git a/problems/customer-placing-the-largest-number-of-orders/mysql_schemas.sql b/problems/customer-placing-the-largest-number-of-orders/mysql_schemas.sql index 66bb81aa2..989cb5c24 100644 --- a/problems/customer-placing-the-largest-number-of-orders/mysql_schemas.sql +++ b/problems/customer-placing-the-largest-number-of-orders/mysql_schemas.sql @@ -1,4 +1,4 @@ -Create table If Not Exists orders (order_number int, customer_number int, order_date date, required_date date, shipped_date date, status char(15), comment char(200), key(order_number)); +Create table If Not Exists orders (order_number int, customer_number int); Truncate table orders; insert into orders (order_number, customer_number) values ('1', '1'); insert into orders (order_number, customer_number) values ('2', '2'); diff --git a/problems/decode-ways-ii/README.md b/problems/decode-ways-ii/README.md index e7875df03..01d69c8a7 100644 --- a/problems/decode-ways-ii/README.md +++ b/problems/decode-ways-ii/README.md @@ -9,7 +9,7 @@                  [Next >](../solve-the-equation "Solve the Equation") -## [639. Decode Ways II (Hard)](https://leetcode.com/problems/decode-ways-ii "解码方法 2") +## [639. Decode Ways II (Hard)](https://leetcode.com/problems/decode-ways-ii "解码方法 II")

    A message containing letters from A-Z can be encoded into numbers using the following mapping:

    diff --git a/problems/design-an-ordered-stream/README.md b/problems/design-an-ordered-stream/README.md index 9dc2d1e53..b80e3bace 100644 --- a/problems/design-an-ordered-stream/README.md +++ b/problems/design-an-ordered-stream/README.md @@ -11,7 +11,7 @@ ## [1656. Design an Ordered Stream (Easy)](https://leetcode.com/problems/design-an-ordered-stream "设计有序流") -

    There is a stream of n (id, value) pairs arriving in an arbitrary order, where id is an integer between 1 and n and value is a string. No two pairs have the same id.

    +

    There is a stream of n (idKey, value) pairs arriving in an arbitrary order, where idKey is an integer between 1 and n and value is a string. No two pairs have the same id.

    Design a stream that returns the values in increasing order of their IDs by returning a chunk (list) of values after each insertion. The concatenation of all the chunks should result in a list of the sorted values.

    @@ -19,7 +19,7 @@
    • OrderedStream(int n) Constructs the stream to take n values.
    • -
    • String[] insert(int id, String value) Inserts the pair (id, value) into the stream, then returns the largest possible chunk of currently inserted values that appear next in the order.
    • +
    • String[] insert(int idKey, String value) Inserts the pair (idKey, value) into the stream, then returns the largest possible chunk of currently inserted values that appear next in the order.

     

    diff --git a/problems/design-most-recently-used-queue/README.md b/problems/design-most-recently-used-queue/README.md new file mode 100644 index 000000000..8f7116780 --- /dev/null +++ b/problems/design-most-recently-used-queue/README.md @@ -0,0 +1,34 @@ + + + + + + + +[< Previous](../closest-subsequence-sum "Closest Subsequence Sum") +                 +[Next >](../recyclable-and-low-fat-products "Recyclable and Low Fat Products") + +## [1756. Design Most Recently Used Queue (Medium)](https://leetcode.com/problems/design-most-recently-used-queue "") + + + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +You can store the data in an array and apply each fetch by moving the ith element to the end of the array (i.e, O(n) per operation). +
    + +
    +Hint 2 +A better way is to use the square root decomposition technique. +
    + +
    +Hint 3 +You can build chunks of size sqrt(n). For each fetch operation, You can search for the chunk which has the ith element and update it (i.e., O(sqrt(n)) per operation), and move this element to an empty chunk at the end. +
    diff --git a/problems/design-tic-tac-toe/README.md b/problems/design-tic-tac-toe/README.md index 46731adcc..7d822d9fb 100644 --- a/problems/design-tic-tac-toe/README.md +++ b/problems/design-tic-tac-toe/README.md @@ -9,7 +9,7 @@                  [Next >](../intersection-of-two-arrays "Intersection of Two Arrays") -## [348. Design Tic-Tac-Toe (Medium)](https://leetcode.com/problems/design-tic-tac-toe "判定井字棋胜负") +## [348. Design Tic-Tac-Toe (Medium)](https://leetcode.com/problems/design-tic-tac-toe "设计井字棋")

    Design a Tic-tac-toe game that is played between two players on a n x n grid.

    diff --git a/problems/distinct-subsequences/README.md b/problems/distinct-subsequences/README.md index c7d794543..e411aaf39 100644 --- a/problems/distinct-subsequences/README.md +++ b/problems/distinct-subsequences/README.md @@ -11,11 +11,11 @@ ## [115. Distinct Subsequences (Hard)](https://leetcode.com/problems/distinct-subsequences "不同的子序列") -

    Given two strings s and t, return the number of distinct subsequences of s which equals t.

    +

    Given two strings s and t, return the number of distinct subsequences of s which equals t.

    -

    A string's subsequence is a new string formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ACE" is a subsequence of "ABCDE" while "AEC" is not).

    +

    A string's subsequence is a new string formed from the original string by deleting some (can be none) of the characters without disturbing the remaining characters' relative positions. (i.e., "ACE" is a subsequence of "ABCDE" while "AEC" is not).

    -

    It's guaranteed the answer fits on a 32-bit signed integer.

    +

    It is guaranteed the answer fits on a 32-bit signed integer.

     

    Example 1:

    diff --git a/problems/equal-rational-numbers/README.md b/problems/equal-rational-numbers/README.md index 1f778ea6a..7013c6e0b 100644 --- a/problems/equal-rational-numbers/README.md +++ b/problems/equal-rational-numbers/README.md @@ -11,64 +11,69 @@ ## [972. Equal Rational Numbers (Hard)](https://leetcode.com/problems/equal-rational-numbers "相等的有理数") -

    Given two strings S and T, each of which represents a non-negative rational number, return True if and only if they represent the same number. The strings may use parentheses to denote the repeating part of the rational number.

    +

    Given two strings s and t, each of which represents a non-negative rational number, return true if and only if they represent the same number. The strings may use parentheses to denote the repeating part of the rational number.

    -

    In general a rational number can be represented using up to three parts: an integer part, a non-repeating part, and a repeating part. The number will be represented in one of the following three ways:

    +

    A rational number can be represented using up to three parts: <IntegerPart>, <NonRepeatingPart>, and a <RepeatingPart>. The number will be represented in one of the following three ways:

      -
    • <IntegerPart> (e.g. 0, 12, 123)
    • -
    • <IntegerPart><.><NonRepeatingPart>  (e.g. 0.5, 1., 2.12, 2.0001)
    • -
    • <IntegerPart><.><NonRepeatingPart><(><RepeatingPart><)> (e.g. 0.1(6), 0.9(9), 0.00(1212))
    • +
    • <IntegerPart> +
        +
      • For example, 12, 0, and 123.
      • +
      +
    • +
    • <IntegerPart><.><NonRepeatingPart> +
        +
      • For example, 0.5, 1., 2.12, and 123.0001.
      • +
      +
    • +
    • <IntegerPart><.><NonRepeatingPart><(><RepeatingPart><)> +
        +
      • For example, 0.1(6), 1.(9), 123.00(1212).
      • +
      +
    -

    The repeating portion of a decimal expansion is conventionally denoted within a pair of round brackets.  For example:

    +

    The repeating portion of a decimal expansion is conventionally denoted within a pair of round brackets. For example:

    -

    1 / 6 = 0.16666666... = 0.1(6) = 0.1666(6) = 0.166(66)

    - -

    Both 0.1(6) or 0.1666(6) or 0.166(66) are correct representations of 1 / 6.

    +
      +
    • 1/6 = 0.16666666... = 0.1(6) = 0.1666(6) = 0.166(66).
    • +

     

    -

    Example 1:

    -Input: S = "0.(52)", T = "0.5(25)"
    -Output: true
    -Explanation:
    -Because "0.(52)" represents 0.52525252..., and "0.5(25)" represents 0.52525252525..... , the strings represent the same number.
    +Input: s = "0.(52)", t = "0.5(25)"
    +Output: true
    +Explanation: Because "0.(52)" represents 0.52525252..., and "0.5(25)" represents 0.52525252525..... , the strings represent the same number.
     
    -

    Example 2:

    -Input: S = "0.1666(6)", T = "0.166(66)"
    -Output: true
    +Input: s = "0.1666(6)", t = "0.166(66)"
    +Output: true
     
    -

    Example 3:

    -Input: S = "0.9(9)", T = "1."
    -Output: true
    -Explanation: 
    -"0.9(9)" represents 0.999999999... repeated forever, which equals 1.  [See this link for an explanation.]
    -"1." represents the number 1, which is formed correctly: (IntegerPart) = "1" and (NonRepeatingPart) = "".
    +Input: s = "0.9(9)", t = "1." +Output: true +Explanation: "0.9(9)" represents 0.999999999... repeated forever, which equals 1. [See this link for an explanation.] +"1." represents the number 1, which is formed correctly: (IntegerPart) = "1" and (NonRepeatingPart) = "". +

     

    -
    -
    - -

    Note:

    +

    Constraints:

    -
      +
      • Each part consists only of digits.
      • -
      • The <IntegerPart> will not begin with 2 or more zeros.  (There is no other restriction on the digits of each part.)
      • -
      • 1 <= <IntegerPart>.length <= 4
      • -
      • 0 <= <NonRepeatingPart>.length <= 4
      • +
      • The <IntegerPart> does not have leading zeros (except for the zero itself).
      • +
      • 1 <= <IntegerPart>.length <= 4
      • +
      • 0 <= <NonRepeatingPart>.length <= 4
      • 1 <= <RepeatingPart>.length <= 4
      • -
    + ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/find-n-unique-integers-sum-up-to-zero/README.md b/problems/find-n-unique-integers-sum-up-to-zero/README.md index a4cb10af2..2251d1fbc 100644 --- a/problems/find-n-unique-integers-sum-up-to-zero/README.md +++ b/problems/find-n-unique-integers-sum-up-to-zero/README.md @@ -11,7 +11,7 @@ ## [1304. Find N Unique Integers Sum up to Zero (Easy)](https://leetcode.com/problems/find-n-unique-integers-sum-up-to-zero "和为零的N个唯一整数") -

    Given an integer n, return any array containing n unique integers such that they add up to 0.

    +

    Given an integer n, return any array containing n unique integers such that they add up to 0.

     

    Example 1:

    diff --git a/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md b/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md index d0ddb9996..33aa491a9 100644 --- a/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md +++ b/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md @@ -11,17 +11,15 @@ ## [1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance (Medium)](https://leetcode.com/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance "阈值距离内邻居最少的城市") -

    There are n cities numbered from 0 to n-1. Given the array edges where edges[i] = [fromi, toi, weighti] represents a bidirectional and weighted edge between cities fromi and toi, and given the integer distanceThreshold.

    +

    There are n cities numbered from 0 to n-1. Given the array edges where edges[i] = [fromi, toi, weighti] represents a bidirectional and weighted edge between cities fromi and toi, and given the integer distanceThreshold.

    -

    Return the city with the smallest number of cities that are reachable through some path and whose distance is at most distanceThreshold, If there are multiple such cities, return the city with the greatest number.

    +

    Return the city with the smallest number of cities that are reachable through some path and whose distance is at most distanceThreshold, If there are multiple such cities, return the city with the greatest number.

    Notice that the distance of a path connecting cities i and j is equal to the sum of the edges' weights along that path.

     

    Example 1:

    - -

    - +
     Input: n = 4, edges = [[0,1,3],[1,2,1],[1,3,4],[2,3,1]], distanceThreshold = 4
     Output: 3
    @@ -35,9 +33,7 @@ Cities 0 and 3 have 2 neighboring cities at a distanceThreshold = 4, but we have
     

    Example 2:

    - -

    - +
     Input: n = 5, edges = [[0,1,2],[0,4,8],[1,2,3],[1,4,2],[2,3,1],[3,4,1]], distanceThreshold = 2
     Output: 0
    diff --git a/problems/find-the-subtasks-that-did-not-execute/README.md b/problems/find-the-subtasks-that-did-not-execute/README.md
    new file mode 100644
    index 000000000..98fd0f448
    --- /dev/null
    +++ b/problems/find-the-subtasks-that-did-not-execute/README.md
    @@ -0,0 +1,14 @@
    +
    +
    +
    +
    +
    +
    +
    +[< Previous](../tree-of-coprimes "Tree of Coprimes")
    +                
    +[Next >](../merge-strings-alternately "Merge Strings Alternately")
    +
    +## [1767. Find the Subtasks That Did Not Execute (Hard)](https://leetcode.com/problems/find-the-subtasks-that-did-not-execute "")
    +
    +
    diff --git a/problems/find-the-subtasks-that-did-not-execute/mysql_schemas.sql b/problems/find-the-subtasks-that-did-not-execute/mysql_schemas.sql
    new file mode 100644
    index 000000000..fd4398ea6
    --- /dev/null
    +++ b/problems/find-the-subtasks-that-did-not-execute/mysql_schemas.sql
    @@ -0,0 +1,12 @@
    +Create table If Not Exists Tasks (task_id int, subtasks_count int);
    +Create table If Not Exists Executed (task_id int, subtask_id int);
    +Truncate table Tasks;
    +insert into Tasks (task_id, subtasks_count) values ('1', '3');
    +insert into Tasks (task_id, subtasks_count) values ('2', '2');
    +insert into Tasks (task_id, subtasks_count) values ('3', '4');
    +Truncate table Executed;
    +insert into Executed (task_id, subtask_id) values ('1', '2');
    +insert into Executed (task_id, subtask_id) values ('3', '1');
    +insert into Executed (task_id, subtask_id) values ('3', '2');
    +insert into Executed (task_id, subtask_id) values ('3', '3');
    +insert into Executed (task_id, subtask_id) values ('3', '4');
    diff --git a/problems/flip-binary-tree-to-match-preorder-traversal/README.md b/problems/flip-binary-tree-to-match-preorder-traversal/README.md
    index 516b4670a..f5288b36a 100644
    --- a/problems/flip-binary-tree-to-match-preorder-traversal/README.md
    +++ b/problems/flip-binary-tree-to-match-preorder-traversal/README.md
    @@ -11,15 +11,13 @@
     
     ## [971. Flip Binary Tree To Match Preorder Traversal (Medium)](https://leetcode.com/problems/flip-binary-tree-to-match-preorder-traversal "翻转二叉树以匹配先序遍历")
     
    -

    You are given the root of a binary tree with n nodes, each node has a different value from 1 to n. You are also given a sequence of n values voyage, reported by a preorder traversal starting from the root.

    +

    You are given the root of a binary tree with n nodes, where each node is uniquely assigned a value from 1 to n. You are also given a sequence of n values voyage, which is the desired pre-order traversal of the binary tree.

    -

    A node in this binary tree can be flipped by swapping its left child and its right child.

    +

    Any node in the binary tree can be flipped by swapping its left and right subtrees. For example, flipping node 1 will have the following effect:

    + +

    Flip the smallest number of nodes so that the pre-order traversal of the tree matches voyage.

    -

    Flip the least number of nodes in the tree so that the preorder traversal of the tree matches voyage.

    - -

    Return a list of the values of all nodes flipped. You may return the answer in any order. If we cannot flip the nodes in the tree to obtain voyage, return the list [-1].

    - -

    The preorder traversal of a node means we report the current node's value, then preorder-traverse the left child, then preorder-traverse the right child.

    +

    Return a list of the values of all flipped nodes. You may return the answer in any order. If it is impossible to flip the nodes in the tree to make the pre-order traversal match voyage, return the list [-1].

     

    Example 1:

    @@ -27,6 +25,7 @@
     Input: root = [1,2], voyage = [2,1]
     Output: [-1]
    +Explanation: It is impossible to flip the nodes such that the pre-order traversal matches voyage.
     

    Example 2:

    @@ -34,13 +33,14 @@
     Input: root = [1,2,3], voyage = [1,3,2]
     Output: [1]
    -
    +Explanation: Flipping node 1 swaps nodes 2 and 3, so the pre-order traversal matches voyage.

    Example 3:

     Input: root = [1,2,3], voyage = [1,2,3]
     Output: []
    +Explanation: The tree's pre-order traversal already matches voyage, so no nodes need to be flipped.
     

     

    @@ -51,8 +51,8 @@
  • n == voyage.length
  • 1 <= n <= 100
  • 1 <= Node.val, voyage[i] <= n
  • -
  • All the values of the tree are unique.
  • -
  • All the values of voyage are unique.
  • +
  • All the values in the tree are unique.
  • +
  • All the values in voyage are unique.
  • ### Related Topics diff --git a/problems/form-array-by-concatenating-subarrays-of-another-array/README.md b/problems/form-array-by-concatenating-subarrays-of-another-array/README.md new file mode 100644 index 000000000..70d5d05e6 --- /dev/null +++ b/problems/form-array-by-concatenating-subarrays-of-another-array/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../longest-nice-substring "Longest Nice Substring") +                 +[Next >](../map-of-highest-peak "Map of Highest Peak") + +## [1764. Form Array by Concatenating Subarrays of Another Array (Medium)](https://leetcode.com/problems/form-array-by-concatenating-subarrays-of-another-array "通过连接另一个数组的子数组得到一个数组") + +

    You are given a 2D integer array groups of length n. You are also given an integer array nums.

    + +

    You are asked if you can choose n disjoint subarrays from the array nums such that the ith subarray is equal to groups[i] (0-indexed), and if i > 0, the (i-1)th subarray appears before the ith subarray in nums (i.e. the subarrays must be in the same order as groups).

    + +

    Return true if you can do this task, and false otherwise.

    + +

    Note that the subarrays are disjoint if and only if there is no index k such that nums[k] belongs to more than one subarray. A subarray is a contiguous sequence of elements within an array.

    + +

     

    +

    Example 1:

    + +
    +Input: groups = [[1,-1,-1],[3,-2,0]], nums = [1,-1,0,1,-1,-1,3,-2,0]
    +Output: true
    +Explanation: You can choose the 0th subarray as [1,-1,0,1,-1,-1,3,-2,0] and the 1st one as [1,-1,0,1,-1,-1,3,-2,0].
    +These subarrays are disjoint as they share no common nums[k] element.
    +
    + +

    Example 2:

    + +
    +Input: groups = [[10,-2],[1,2,3,4]], nums = [1,2,3,4,10,-2]
    +Output: false
    +Explanation: Note that choosing the subarrays [1,2,3,4,10,-2] and [1,2,3,4,10,-2] is incorrect because they are not in the same order as in groups.
    +[10,-2] must come before [1,2,3,4].
    +
    + +

    Example 3:

    + +
    +Input: groups = [[1,2,3],[3,4]], nums = [7,7,1,2,3,4,7,7]
    +Output: false
    +Explanation: Note that choosing the subarrays [7,7,1,2,3,4,7,7] and [7,7,1,2,3,4,7,7] is invalid because they are not disjoint.
    +They share a common elements nums[4] (0-indexed).
    +
    + +

     

    +

    Constraints:

    + +
      +
    • groups.length == n
    • +
    • 1 <= n <= 103
    • +
    • 1 <= groups[i].length, sum(groups[i].length) <= 103
    • +
    • 1 <= nums.length <= 103
    • +
    • -107 <= groups[i][j], nums[k] <= 107
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +When we use a subarray, the room for the next subarrays will be the suffix after the used subarray. +
    + +
    +Hint 2 +If we can match a group with multiple subarrays, we should choose the first one, as this will just leave the largest room for the next subarrays. +
    diff --git a/problems/is-graph-bipartite/README.md b/problems/is-graph-bipartite/README.md index ff69add19..d5f24efcd 100644 --- a/problems/is-graph-bipartite/README.md +++ b/problems/is-graph-bipartite/README.md @@ -11,41 +11,45 @@ ## [785. Is Graph Bipartite? (Medium)](https://leetcode.com/problems/is-graph-bipartite "判断二分图") -

    Given an undirected graph, return true if and only if it is bipartite.

    +

    There is an undirected graph with n nodes, where each node is numbered between 0 and n - 1. You are given a 2D array graph, where graph[u] is an array of nodes that node u is adjacent to. More formally, for each v in graph[u], there is an undirected edge between node u and node v. The graph has the following properties:

    -

    Recall that a graph is bipartite if we can split its set of nodes into two independent subsets A and B, such that every edge in the graph has one node in A and another node in B.

    +
      +
    • There are no self-edges (graph[u] does not contain u).
    • +
    • There are no parallel edges (graph[u] does not contain duplicate values).
    • +
    • If v is in graph[u], then u is in graph[v] (the graph is undirected).
    • +
    • The graph may not be connected, meaning there may be two nodes u and v such that there is no path between them.
    • +
    -

    The graph is given in the following form: graph[i] is a list of indexes j for which the edge between nodes i and j exists.  Each node is an integer between 0 and graph.length - 1.  There are no self edges or parallel edges: graph[i] does not contain i, and it doesn't contain any element twice.

    +

    A graph is bipartite if the nodes can be partitioned into two independent sets A and B such that every edge in the graph connects a node in set A and a node in set B.

    + +

    Return true if and only if it is bipartite.

     

    Example 1:

    - -
    -Input: graph = [[1,3],[0,2],[1,3],[0,2]]
    -Output: true
    -Explanation: We can divide the vertices into two groups: {0, 2} and {1, 3}.
    -
    -
    - -

    Example 2:

     Input: graph = [[1,2,3],[0,2],[0,1,3],[0,2]]
     Output: false
    -Explanation: We cannot find a way to divide the set of nodes into two independent subsets.
    +Explanation: There is no way to partition the nodes into two independent sets such that every edge connects a node in one and a node in the other.
    - +

    Example 2:

    + +
    +Input: graph = [[1,3],[0,2],[1,3],[0,2]]
    +Output: true
    +Explanation: We can partition the nodes into two sets: {0, 2} and {1, 3}.

     

    Constraints:

      -
    • 1 <= graph.length <= 100
    • -
    • 0 <= graph[i].length < 100
    • -
    • 0 <= graph[i][j] <= graph.length - 1
    • -
    • graph[i][j] != i
    • -
    • All the values of graph[i] are unique.
    • -
    • The graph is guaranteed to be undirected
    • +
    • graph.length == n
    • +
    • 1 <= n <= 100
    • +
    • 0 <= graph[u].length < n
    • +
    • 0 <= graph[u][i] <= n - 1
    • +
    • graph[u] does not contain u.
    • +
    • All the values of graph[u] are unique.
    • +
    • If graph[u] contains v, then graph[v] contains u.
    ### Related Topics diff --git a/problems/kth-smallest-element-in-a-sorted-matrix/README.md b/problems/kth-smallest-element-in-a-sorted-matrix/README.md index b9418780d..1f2780795 100644 --- a/problems/kth-smallest-element-in-a-sorted-matrix/README.md +++ b/problems/kth-smallest-element-in-a-sorted-matrix/README.md @@ -9,7 +9,7 @@                  [Next >](../design-phone-directory "Design Phone Directory") -## [378. Kth Smallest Element in a Sorted Matrix (Medium)](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix "有序矩阵中第K小的元素") +## [378. Kth Smallest Element in a Sorted Matrix (Medium)](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix "有序矩阵中第 K 小的元素")

    Given an n x n matrix where each of the rows and columns are sorted in ascending order, return the kth smallest element in the matrix.

    @@ -21,7 +21,7 @@
     Input: matrix = [[1,5,9],[10,11,13],[12,13,15]], k = 8
     Output: 13
    -Explanation: The elements in the matrix are [1,5,9,10,11,12,13,13,15], and the 8th largest number is 13
    +Explanation: The elements in the matrix are [1,5,9,10,11,12,13,13,15], and the 8th smallest number is 13
     

    Example 2:

    diff --git a/problems/largest-merge-of-two-strings/README.md b/problems/largest-merge-of-two-strings/README.md new file mode 100644 index 000000000..0892bf50e --- /dev/null +++ b/problems/largest-merge-of-two-strings/README.md @@ -0,0 +1,85 @@ + + + + + + + +[< Previous](../maximum-score-from-removing-stones "Maximum Score From Removing Stones") +                 +[Next >](../closest-subsequence-sum "Closest Subsequence Sum") + +## [1754. Largest Merge Of Two Strings (Medium)](https://leetcode.com/problems/largest-merge-of-two-strings "构造字典序最大的合并字符串") + +

    You are given two strings word1 and word2. You want to construct a string merge in the following way: while either word1 or word2 are non-empty, choose one of the following options:

    + +
      +
    • If word1 is non-empty, append the first character in word1 to merge and delete it from word1. +
        +
      • For example, if word1 = "abc" and merge = "dv", then after choosing this operation, word1 = "bc" and merge = "dva".
      • +
      +
    • +
    • If word2 is non-empty, append the first character in word2 to merge and delete it from word2. +
        +
      • For example, if word2 = "abc" and merge = "", then after choosing this operation, word2 = "bc" and merge = "a".
      • +
      +
    • +
    + +

    Return the lexicographically largest merge you can construct.

    + +

    A string a is lexicographically larger than a string b (of the same length) if in the first position where a and b differ, a has a character strictly larger than the corresponding character in b. For example, "abcd" is lexicographically larger than "abcc" because the first position they differ is at the fourth character, and d is greater than c.

    + +

     

    +

    Example 1:

    + +
    +Input: word1 = "cabaa", word2 = "bcaaa"
    +Output: "cbcabaaaaa"
    +Explanation: One way to get the lexicographically largest merge is:
    +- Take from word1: merge = "c", word1 = "abaa", word2 = "bcaaa"
    +- Take from word2: merge = "cb", word1 = "abaa", word2 = "caaa"
    +- Take from word2: merge = "cbc", word1 = "abaa", word2 = "aaa"
    +- Take from word1: merge = "cbca", word1 = "baa", word2 = "aaa"
    +- Take from word1: merge = "cbcab", word1 = "aa", word2 = "aaa"
    +- Append the remaining 5 a's from word1 and word2 at the end of merge.
    +
    + +

    Example 2:

    + +
    +Input: word1 = "abcabc", word2 = "abdcaba"
    +Output: "abdcabcabcaba"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= word1.length, word2.length <= 3000
    • +
    • word1 and word2 consist only of lowercase English letters.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Build the result character by character. At each step, you choose a character from one of the two strings. +
    + +
    +Hint 2 +If the next character of the first string is larger than that of the second string, or vice versa, it's optimal to use the larger one. +
    + +
    +Hint 3 +If both are equal, think of a criteria that lets you decide which string to consume the next character from. +
    + +
    +Hint 4 +You should choose the next character from the larger string. +
    diff --git a/problems/leetflex-banned-accounts/README.md b/problems/leetflex-banned-accounts/README.md index 3977c250a..3efd973fc 100644 --- a/problems/leetflex-banned-accounts/README.md +++ b/problems/leetflex-banned-accounts/README.md @@ -7,7 +7,7 @@ [< Previous](../maximum-subarray-sum-after-one-operation "Maximum Subarray Sum After One Operation")                  -Next > +[Next >](../sum-of-unique-elements "Sum of Unique Elements") ## [1747. Leetflex Banned Accounts (Medium)](https://leetcode.com/problems/leetflex-banned-accounts "") diff --git a/problems/longest-nice-substring/README.md b/problems/longest-nice-substring/README.md new file mode 100644 index 000000000..deefb52e2 --- /dev/null +++ b/problems/longest-nice-substring/README.md @@ -0,0 +1,65 @@ + + + + + + + +[< Previous](../buildings-with-an-ocean-view "Buildings With an Ocean View") +                 +[Next >](../form-array-by-concatenating-subarrays-of-another-array "Form Array by Concatenating Subarrays of Another Array") + +## [1763. Longest Nice Substring (Easy)](https://leetcode.com/problems/longest-nice-substring "最长的美好子字符串") + +

    A string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, "abABB" is nice because 'A' and 'a' appear, and 'B' and 'b' appear. However, "abA" is not because 'b' appears, but 'B' does not.

    + +

    Given a string s, return the longest substring of s that is nice. If there are multiple, return the substring of the earliest occurrence. If there are none, return an empty string.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "YazaAay"
    +Output: "aAa"
    +Explanation: "aAa" is a nice string because 'A/a' is the only letter of the alphabet in s, and both 'A' and 'a' appear.
    +"aAa" is the longest nice substring.
    +
    + +

    Example 2:

    + +
    +Input: s = "Bb"
    +Output: "Bb"
    +Explanation: "Bb" is a nice string because both 'B' and 'b' appear. The whole string is a substring.
    + +

    Example 3:

    + +
    +Input: s = "c"
    +Output: ""
    +Explanation: There are no nice substrings.
    + +

    Example 4:

    + +
    +Input: s = "dDzeE"
    +Output: "dD"
    +Explanation: Both "dD" and "eE" are the longest nice substrings.
    +As there are multiple longest nice substrings, return "dD" since it occurs earlier.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 100
    • +
    • s consists of uppercase and lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Brute force and check each substring to see if it is nice. +
    diff --git a/problems/longest-word-in-dictionary-through-deleting/README.md b/problems/longest-word-in-dictionary-through-deleting/README.md index 6b9cecf28..c6d3d8a6b 100644 --- a/problems/longest-word-in-dictionary-through-deleting/README.md +++ b/problems/longest-word-in-dictionary-through-deleting/README.md @@ -11,37 +11,41 @@ ## [524. Longest Word in Dictionary through Deleting (Medium)](https://leetcode.com/problems/longest-word-in-dictionary-through-deleting "通过删除字母匹配到字典里最长单词") -

    -Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. If there are more than one possible results, return the longest word with the smallest lexicographical order. If there is no possible result, return the empty string. -

    -

    Example 1:
    +

    Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. If there are more than one possible results, return the longest word with the smallest lexicographical order. If there is no possible result, return the empty string.

    + +

    Example 1:

    +
     Input:
    -s = "abpcplea", d = ["ale","apple","monkey","plea"]
    +s = "abpcplea", d = ["ale","apple","monkey","plea"]
     
     Output: 
    -"apple"
    +"apple"
     
    -

    -

    -

    Example 2:
    +

     

    + +

    Example 2:

    +
     Input:
    -s = "abpcplea", d = ["a","b","c"]
    +s = "abpcplea", d = ["a","b","c"]
     
     Output: 
    -"a"
    +"a"
     
    -

    -

    Note:
    +

     

    + +

    Note:

    +
      -
    1. All the strings in the input will only contain lower-case letters.
    2. -
    3. The size of the dictionary won't exceed 1,000.
    4. -
    5. The length of all the strings in the input won't exceed 1,000.
    6. +
    7. All the strings in the input will only contain lower-case letters.
    8. +
    9. The size of the dictionary won't exceed 1,000.
    10. +
    11. The length of all the strings in the input won't exceed 1,000.
    -

    + +

     

    ### Related Topics [[Sort](../../tag/sort/README.md)] diff --git a/problems/map-of-highest-peak/README.md b/problems/map-of-highest-peak/README.md new file mode 100644 index 000000000..2b8cfaa18 --- /dev/null +++ b/problems/map-of-highest-peak/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../form-array-by-concatenating-subarrays-of-another-array "Form Array by Concatenating Subarrays of Another Array") +                 +[Next >](../tree-of-coprimes "Tree of Coprimes") + +## [1765. Map of Highest Peak (Medium)](https://leetcode.com/problems/map-of-highest-peak "地图中的最高点") + +

    You are given an integer matrix isWater of size m x n that represents a map of land and water cells.

    + +
      +
    • If isWater[i][j] == 0, cell (i, j) is a land cell.
    • +
    • If isWater[i][j] == 1, cell (i, j) is a water cell.
    • +
    + +

    You must assign each cell a height in a way that follows these rules:

    + +
      +
    • The height of each cell must be non-negative.
    • +
    • If the cell is a water cell, its height must be 0.
    • +
    • Any two adjacent cells must have an absolute height difference of at most 1. A cell is adjacent to another cell if the former is directly north, east, south, or west of the latter (i.e., their sides are touching).
    • +
    + +

    Find an assignment of heights such that the maximum height in the matrix is maximized.

    + +

    Return an integer matrix height of size m x n where height[i][j] is cell (i, j)'s height. If there are multiple solutions, return any of them.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: isWater = [[0,1],[0,0]]
    +Output: [[1,0],[2,1]]
    +Explanation: The image shows the assigned heights of each cell.
    +The blue cell is the water cell, and the green cells are the land cells.
    +
    + +

    Example 2:

    + +

    + +
    +Input: isWater = [[0,0,1],[1,0,0],[0,0,0]]
    +Output: [[1,1,0],[0,1,1],[1,2,2]]
    +Explanation: A height of 2 is the maximum possible height of any assignment.
    +Any height assignment that has a maximum height of 2 while still meeting the rules will also be accepted.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == isWater.length
    • +
    • n == isWater[i].length
    • +
    • 1 <= m, n <= 1000
    • +
    • isWater[i][j] is 0 or 1.
    • +
    • There is at least one water cell.
    • +
    + +### Related Topics + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + +### Hints +
    +Hint 1 +Set each water cell to be 0. The height of each cell is limited by its closest water cell. +
    + +
    +Hint 2 +Perform a multi-source BFS with all the water cells as sources. +
    diff --git a/problems/max-consecutive-ones/README.md b/problems/max-consecutive-ones/README.md index 3b77bb078..185c3b257 100644 --- a/problems/max-consecutive-ones/README.md +++ b/problems/max-consecutive-ones/README.md @@ -9,7 +9,7 @@                  [Next >](../predict-the-winner "Predict the Winner") -## [485. Max Consecutive Ones (Easy)](https://leetcode.com/problems/max-consecutive-ones "最大连续1的个数") +## [485. Max Consecutive Ones (Easy)](https://leetcode.com/problems/max-consecutive-ones "最大连续 1 的个数")

    Given a binary array, find the maximum number of consecutive 1s in this array.

    diff --git a/problems/maximize-palindrome-length-from-subsequences/README.md b/problems/maximize-palindrome-length-from-subsequences/README.md new file mode 100644 index 000000000..627b4c671 --- /dev/null +++ b/problems/maximize-palindrome-length-from-subsequences/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../maximum-score-from-performing-multiplication-operations "Maximum Score from Performing Multiplication Operations") +                 +Next > + +## [1771. Maximize Palindrome Length From Subsequences (Hard)](https://leetcode.com/problems/maximize-palindrome-length-from-subsequences "由子序列构造的最长回文串的长度") + +

    You are given two strings, word1 and word2. You want to construct a string in the following manner:

    + +
      +
    • Choose some non-empty subsequence subsequence1 from word1.
    • +
    • Choose some non-empty subsequence subsequence2 from word2.
    • +
    • Concatenate the subsequences: subsequence1 + subsequence2, to make the string.
    • +
    + +

    Return the length of the longest palindrome that can be constructed in the described manner. If no palindromes can be constructed, return 0.

    + +

    A subsequence of a string s is a string that can be made by deleting some (possibly none) characters from s without changing the order of the remaining characters.

    + +

    A palindrome is a string that reads the same forward as well as backward.

    + +

     

    +

    Example 1:

    + +
    +Input: word1 = "cacb", word2 = "cbba"
    +Output: 5
    +Explanation: Choose "ab" from word1 and "cba" from word2 to make "abcba", which is a palindrome.
    + +

    Example 2:

    + +
    +Input: word1 = "ab", word2 = "ab"
    +Output: 3
    +Explanation: Choose "ab" from word1 and "a" from word2 to make "aba", which is a palindrome.
    + +

    Example 3:

    + +
    +Input: word1 = "aa", word2 = "bb"
    +Output: 0
    +Explanation: You cannot construct a palindrome from the described method, so return 0.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= word1.length, word2.length <= 1000
    • +
    • word1 and word2 consist of lowercase English letters.
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Let's ignore the non-empty subsequence constraint. We can concatenate the two strings and find the largest palindromic subsequence with dynamic programming. +
    + +
    +Hint 2 +Iterate through every pair of characters word1[i] and word2[j], and see if some palindrome begins with word1[i] and ends with word2[j]. This ensures that the subsequences are non-empty. +
    diff --git a/problems/maximum-absolute-sum-of-any-subarray/README.md b/problems/maximum-absolute-sum-of-any-subarray/README.md new file mode 100644 index 000000000..201f7ff7e --- /dev/null +++ b/problems/maximum-absolute-sum-of-any-subarray/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../sum-of-unique-elements "Sum of Unique Elements") +                 +[Next >](../minimum-length-of-string-after-deleting-similar-ends "Minimum Length of String After Deleting Similar Ends") + +## [1749. Maximum Absolute Sum of Any Subarray (Medium)](https://leetcode.com/problems/maximum-absolute-sum-of-any-subarray "任意子数组和的绝对值的最大值") + +

    You are given an integer array nums. The absolute sum of a subarray [numsl, numsl+1, ..., numsr-1, numsr] is abs(numsl + numsl+1 + ... + numsr-1 + numsr).

    + +

    Return the maximum absolute sum of any (possibly empty) subarray of nums.

    + +

    Note that abs(x) is defined as follows:

    + +
      +
    • If x is a negative integer, then abs(x) = -x.
    • +
    • If x is a non-negative integer, then abs(x) = x.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,-3,2,3,-4]
    +Output: 5
    +Explanation: The subarray [2,3] has absolute sum = abs(2+3) = abs(5) = 5.
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,-5,1,-4,3,-2]
    +Output: 8
    +Explanation: The subarray [-5,1,-4] has absolute sum = abs(-5+1-4) = abs(-8) = 8.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • -104 <= nums[i] <= 104
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +What if we asked for maximum sum, not absolute sum? +
    + +
    +Hint 2 +It's a standard problem that can be solved by Kadane's algorithm. +
    + +
    +Hint 3 +The key idea is the max absolute sum will be either the max sum or the min sum. +
    + +
    +Hint 4 +So just run kadane twice, once calculating the max sum and once calculating the min sum. +
    diff --git a/problems/maximum-number-of-events-that-can-be-attended-ii/README.md b/problems/maximum-number-of-events-that-can-be-attended-ii/README.md new file mode 100644 index 000000000..f61651cc9 --- /dev/null +++ b/problems/maximum-number-of-events-that-can-be-attended-ii/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../minimum-length-of-string-after-deleting-similar-ends "Minimum Length of String After Deleting Similar Ends") +                 +[Next >](../check-if-array-is-sorted-and-rotated "Check if Array Is Sorted and Rotated") + +## [1751. Maximum Number of Events That Can Be Attended II (Hard)](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended-ii "最多可以参加的会议数目 II") + +

    You are given an array of events where events[i] = [startDayi, endDayi, valuei]. The ith event starts at startDayi and ends at endDayi, and if you attend this event, you will receive a value of valuei. You are also given an integer k which represents the maximum number of events you can attend.

    + +

    You can only attend one event at a time. If you choose to attend an event, you must attend the entire event. Note that the end day is inclusive: that is, you cannot attend two events where one of them starts and the other ends on the same day.

    + +

    Return the maximum sum of values that you can receive by attending events.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: events = [[1,2,4],[3,4,3],[2,3,1]], k = 2
    +Output: 7
    +Explanation: Choose the green events, 0 and 1 (0-indexed) for a total value of 4 + 3 = 7.
    + +

    Example 2:

    + +

    + +
    +Input: events = [[1,2,4],[3,4,3],[2,3,10]], k = 2
    +Output: 10
    +Explanation: Choose event 2 for a total value of 10.
    +Notice that you cannot attend any other event as they overlap, and that you do not have to attend k events.
    + +

    Example 3:

    + +

    + +
    +Input: events = [[1,1,1],[2,2,2],[3,3,3],[4,4,4]], k = 3
    +Output: 9
    +Explanation: Although the events do not overlap, you can only attend 3 events. Pick the highest valued three.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= events.length
    • +
    • 1 <= k * events.length <= 106
    • +
    • 1 <= startDayi <= endDayi <= 109
    • +
    • 1 <= valuei <= 106
    • +
    + +### Related Topics + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Sort the events by its startTime. +
    + +
    +Hint 2 +For every event, you can either choose it and consider the next event available, or you can ignore it. You can efficiently find the next event that is available using binary search. +
    diff --git a/problems/maximum-score-from-performing-multiplication-operations/README.md b/problems/maximum-score-from-performing-multiplication-operations/README.md new file mode 100644 index 000000000..097d29180 --- /dev/null +++ b/problems/maximum-score-from-performing-multiplication-operations/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../minimum-number-of-operations-to-move-all-balls-to-each-box "Minimum Number of Operations to Move All Balls to Each Box") +                 +[Next >](../maximize-palindrome-length-from-subsequences "Maximize Palindrome Length From Subsequences") + +## [1770. Maximum Score from Performing Multiplication Operations (Medium)](https://leetcode.com/problems/maximum-score-from-performing-multiplication-operations "执行乘法运算的最大分数") + +

    You are given two integer arrays nums and multipliers of size n and m respectively, where n >= m. The arrays are 1-indexed.

    + +

    You begin with a score of 0. You want to perform exactly m operations. On the ith operation (1-indexed), you will:

    + +
      +
    • Choose one integer x from either the start or the end of the array nums.
    • +
    • Add multipliers[i] * x to your score.
    • +
    • Remove x from the array nums.
    • +
    + +

    Return the maximum score after performing m operations.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3], multipliers = [3,2,1]
    +Output: 14
    +Explanation: An optimal solution is as follows:
    +- Choose from the end, [1,2,3], adding 3 * 3 = 9 to the score.
    +- Choose from the end, [1,2], adding 2 * 2 = 4 to the score.
    +- Choose from the end, [1], adding 1 * 1 = 1 to the score.
    +The total score is 9 + 4 + 1 = 14.
    + +

    Example 2:

    + +
    +Input: nums = [-5,-3,-3,-2,7,1], multipliers = [-10,-5,3,4,6]
    +Output: 102
    +Explanation: An optimal solution is as follows:
    +- Choose from the start, [-5,-3,-3,-2,7,1], adding -5 * -10 = 50 to the score.
    +- Choose from the start, [-3,-3,-2,7,1], adding -3 * -5 = 15 to the score.
    +- Choose from the start, [-3,-2,7,1], adding -3 * 3 = -9 to the score.
    +- Choose from the end, [-2,7,1], adding 1 * 4 = 4 to the score.
    +- Choose from the end, [-2,7], adding 7 * 6 = 42 to the score. 
    +The total score is 50 + 15 - 9 + 4 + 42 = 102.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • m == multipliers.length
    • +
    • 1 <= m <= 103
    • +
    • m <= n <= 105
    • +
    • -1000 <= nums[i], multipliers[i] <= 1000
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +At first glance, the solution seems to be greedy, but if you try to greedily take the largest value from the begging or the end, this will not be optimal. +
    + +
    +Hint 2 +You should try all scenarios but this will be costy. +
    + +
    +Hint 3 +Memoizing the pre-visited states while trying all the possible scenarios will reduce the complexity, and hence dp is the perfect choice here. +
    diff --git a/problems/maximum-score-from-removing-stones/README.md b/problems/maximum-score-from-removing-stones/README.md new file mode 100644 index 000000000..dd2d1cc49 --- /dev/null +++ b/problems/maximum-score-from-removing-stones/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../check-if-array-is-sorted-and-rotated "Check if Array Is Sorted and Rotated") +                 +[Next >](../largest-merge-of-two-strings "Largest Merge Of Two Strings") + +## [1753. Maximum Score From Removing Stones (Medium)](https://leetcode.com/problems/maximum-score-from-removing-stones "移除石子的最大得分") + +

    You are playing a solitaire game with three piles of stones of sizes a​​​​​​, b,​​​​​​ and c​​​​​​ respectively. Each turn you choose two different non-empty piles, take one stone from each, and add 1 point to your score. The game stops when there are fewer than two non-empty piles (meaning there are no more available moves).

    + +

    Given three integers a​​​​​, b,​​​​​ and c​​​​​, return the maximum score you can get.

    + +

     

    +

    Example 1:

    + +
    +Input: a = 2, b = 4, c = 6
    +Output: 6
    +Explanation: The starting state is (2, 4, 6). One optimal set of moves is:
    +- Take from 1st and 3rd piles, state is now (1, 4, 5)
    +- Take from 1st and 3rd piles, state is now (0, 4, 4)
    +- Take from 2nd and 3rd piles, state is now (0, 3, 3)
    +- Take from 2nd and 3rd piles, state is now (0, 2, 2)
    +- Take from 2nd and 3rd piles, state is now (0, 1, 1)
    +- Take from 2nd and 3rd piles, state is now (0, 0, 0)
    +There are fewer than two non-empty piles, so the game ends. Total: 6 points.
    +
    + +

    Example 2:

    + +
    +Input: a = 4, b = 4, c = 6
    +Output: 7
    +Explanation: The starting state is (4, 4, 6). One optimal set of moves is:
    +- Take from 1st and 2nd piles, state is now (3, 3, 6)
    +- Take from 1st and 3rd piles, state is now (2, 3, 5)
    +- Take from 1st and 3rd piles, state is now (1, 3, 4)
    +- Take from 1st and 3rd piles, state is now (0, 3, 3)
    +- Take from 2nd and 3rd piles, state is now (0, 2, 2)
    +- Take from 2nd and 3rd piles, state is now (0, 1, 1)
    +- Take from 2nd and 3rd piles, state is now (0, 0, 0)
    +There are fewer than two non-empty piles, so the game ends. Total: 7 points.
    +
    + +

    Example 3:

    + +
    +Input: a = 1, b = 8, c = 8
    +Output: 8
    +Explanation: One optimal set of moves is to take from the 2nd and 3rd piles for 8 turns until they are empty.
    +After that, there are fewer than two non-empty piles, so the game ends.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= a, b, c <= 105
    • +
    + +### Related Topics + [[Heap](../../tag/heap/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +It's optimal to always remove one stone from the biggest 2 piles +
    + +
    +Hint 2 +Note that the limits are small enough for simulation +
    diff --git a/problems/merge-strings-alternately/README.md b/problems/merge-strings-alternately/README.md new file mode 100644 index 000000000..649329a07 --- /dev/null +++ b/problems/merge-strings-alternately/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../find-the-subtasks-that-did-not-execute "Find the Subtasks That Did Not Execute") +                 +[Next >](../minimum-number-of-operations-to-move-all-balls-to-each-box "Minimum Number of Operations to Move All Balls to Each Box") + +## [1768. Merge Strings Alternately (Easy)](https://leetcode.com/problems/merge-strings-alternately "交替合并字符串") + +

    You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additional letters onto the end of the merged string.

    + +

    Return the merged string.

    + +

     

    +

    Example 1:

    + +
    +Input: word1 = "abc", word2 = "pqr"
    +Output: "apbqcr"
    +Explanation: The merged string will be merged as so:
    +word1:  a   b   c
    +word2:    p   q   r
    +merged: a p b q c r
    +
    + +

    Example 2:

    + +
    +Input: word1 = "ab", word2 = "pqrs"
    +Output: "apbqrs"
    +Explanation: Notice that as word2 is longer, "rs" is appended to the end.
    +word1:  a   b 
    +word2:    p   q   r   s
    +merged: a p b q   r   s
    +
    + +

    Example 3:

    + +
    +Input: word1 = "abcd", word2 = "pq"
    +Output: "apbqcd"
    +Explanation: Notice that as word1 is longer, "cd" is appended to the end.
    +word1:  a   b   c   d
    +word2:    p   q 
    +merged: a p b q c   d
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= word1.length, word2.length <= 100
    • +
    • word1 and word2 consist of lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Use two pointers, one pointer for each string. Alternately choose the character from each pointer, and move the pointer upwards. +
    diff --git a/problems/minimum-changes-to-make-alternating-binary-string/README.md b/problems/minimum-changes-to-make-alternating-binary-string/README.md new file mode 100644 index 000000000..b5c8bb806 --- /dev/null +++ b/problems/minimum-changes-to-make-alternating-binary-string/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../recyclable-and-low-fat-products "Recyclable and Low Fat Products") +                 +[Next >](../count-number-of-homogenous-substrings "Count Number of Homogenous Substrings") + +## [1758. Minimum Changes To Make Alternating Binary String (Easy)](https://leetcode.com/problems/minimum-changes-to-make-alternating-binary-string "生成交替二进制字符串的最少操作数") + +

    You are given a string s consisting only of the characters '0' and '1'. In one operation, you can change any '0' to '1' or vice versa.

    + +

    The string is called alternating if no two adjacent characters are equal. For example, the string "010" is alternating, while the string "0100" is not.

    + +

    Return the minimum number of operations needed to make s alternating.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "0100"
    +Output: 1
    +Explanation: If you change the last character to '1', s will be "0101", which is alternating.
    +
    + +

    Example 2:

    + +
    +Input: s = "10"
    +Output: 0
    +Explanation: s is already alternating.
    +
    + +

    Example 3:

    + +
    +Input: s = "1111"
    +Output: 2
    +Explanation: You need two operations to reach "0101" or "1010".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 104
    • +
    • s[i] is either '0' or '1'.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Think about how the final string will look like. +
    + +
    +Hint 2 +It will either start with a '0' and be like '010101010..' or with a '1' and be like '10101010..' +
    + +
    +Hint 3 +Try both ways, and check for each way, the number of changes needed to reach it from the given string. The answer is the minimum of both ways. +
    diff --git a/problems/minimum-degree-of-a-connected-trio-in-a-graph/README.md b/problems/minimum-degree-of-a-connected-trio-in-a-graph/README.md new file mode 100644 index 000000000..7f3055dc2 --- /dev/null +++ b/problems/minimum-degree-of-a-connected-trio-in-a-graph/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../minimum-limit-of-balls-in-a-bag "Minimum Limit of Balls in a Bag") +                 +[Next >](../buildings-with-an-ocean-view "Buildings With an Ocean View") + +## [1761. Minimum Degree of a Connected Trio in a Graph (Hard)](https://leetcode.com/problems/minimum-degree-of-a-connected-trio-in-a-graph "一个图中连通三元组的最小度数") + +

    You are given an undirected graph. You are given an integer n which is the number of nodes in the graph and an array edges, where each edges[i] = [ui, vi] indicates that there is an undirected edge between ui and vi.

    + +

    A connected trio is a set of three nodes where there is an edge between every pair of them.

    + +

    The degree of a connected trio is the number of edges where one endpoint is in the trio, and the other is not.

    + +

    Return the minimum degree of a connected trio in the graph, or -1 if the graph has no connected trios.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 6, edges = [[1,2],[1,3],[3,2],[4,1],[5,2],[3,6]]
    +Output: 3
    +Explanation: There is exactly one trio, which is [1,2,3]. The edges that form its degree are bolded in the figure above.
    +
    + +

    Example 2:

    + +
    +Input: n = 7, edges = [[1,3],[4,1],[4,3],[2,5],[5,6],[6,7],[7,5],[2,6]]
    +Output: 0
    +Explanation: There are exactly three trios:
    +1) [1,4,3] with degree 0.
    +2) [2,5,6] with degree 2.
    +3) [5,6,7] with degree 2.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 400
    • +
    • edges[i].length == 2
    • +
    • 1 <= edges.length <= n * (n-1) / 2
    • +
    • 1 <= ui, vi <= n
    • +
    • ui != vi
    • +
    • There are no repeated edges.
    • +
    + +### Related Topics + [[Graph](../../tag/graph/README.md)] + +### Hints +
    +Hint 1 +Consider a trio with nodes u, v, and w. The degree of the trio is just degree(u) + degree(v) + degree(w) - 6. The -6 comes from subtracting the edges u-v, u-w, and v-w, which are counted twice each in the vertex degree calculation. +
    + +
    +Hint 2 +To get the trios (u,v,w), you can iterate on u, then iterate on each w,v such that w and v are neighbors of u and are neighbors of each other. +
    diff --git a/problems/minimum-length-of-string-after-deleting-similar-ends/README.md b/problems/minimum-length-of-string-after-deleting-similar-ends/README.md new file mode 100644 index 000000000..9778661bb --- /dev/null +++ b/problems/minimum-length-of-string-after-deleting-similar-ends/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](../maximum-absolute-sum-of-any-subarray "Maximum Absolute Sum of Any Subarray") +                 +[Next >](../maximum-number-of-events-that-can-be-attended-ii "Maximum Number of Events That Can Be Attended II") + +## [1750. Minimum Length of String After Deleting Similar Ends (Medium)](https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends "删除字符串两端相同字符后的最短长度") + +

    Given a string s consisting only of characters 'a', 'b', and 'c'. You are asked to apply the following algorithm on the string any number of times:

    + +
      +
    1. Pick a non-empty prefix from the string s where all the characters in the prefix are equal.
    2. +
    3. Pick a non-empty suffix from the string s where all the characters in this suffix are equal.
    4. +
    5. The prefix and the suffix should not intersect at any index.
    6. +
    7. The characters from the prefix and suffix must be the same.
    8. +
    9. Delete both the prefix and the suffix.
    10. +
    + +

    Return the minimum length of s after performing the above operation any number of times (possibly zero times).

    + +

     

    +

    Example 1:

    + +
    +Input: s = "ca"
    +Output: 2
    +Explanation: You can't remove any characters, so the string stays as is.
    +
    + +

    Example 2:

    + +
    +Input: s = "cabaabac"
    +Output: 0
    +Explanation: An optimal sequence of operations is:
    +- Take prefix = "c" and suffix = "c" and remove them, s = "abaaba".
    +- Take prefix = "a" and suffix = "a" and remove them, s = "baab".
    +- Take prefix = "b" and suffix = "b" and remove them, s = "aa".
    +- Take prefix = "a" and suffix = "a" and remove them, s = "".
    + +

    Example 3:

    + +
    +Input: s = "aabccabba"
    +Output: 3
    +Explanation: An optimal sequence of operations is:
    +- Take prefix = "aa" and suffix = "a" and remove them, s = "bccabb".
    +- Take prefix = "b" and suffix = "bb" and remove them, s = "cca".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 105
    • +
    • s only consists of characters 'a', 'b', and 'c'.
    • +
    + +### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] + +### Hints +
    +Hint 1 +If both ends have distinct characters, no more operations can be made. Otherwise, the only operation is to remove all of the same characters from both ends. We will do this as many times as we can. +
    + +
    +Hint 2 +Note that if the length is equal 1 the answer is 1 +
    diff --git a/problems/minimum-limit-of-balls-in-a-bag/README.md b/problems/minimum-limit-of-balls-in-a-bag/README.md new file mode 100644 index 000000000..bfeefb85f --- /dev/null +++ b/problems/minimum-limit-of-balls-in-a-bag/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../count-number-of-homogenous-substrings "Count Number of Homogenous Substrings") +                 +[Next >](../minimum-degree-of-a-connected-trio-in-a-graph "Minimum Degree of a Connected Trio in a Graph") + +## [1760. Minimum Limit of Balls in a Bag (Medium)](https://leetcode.com/problems/minimum-limit-of-balls-in-a-bag "袋子里最少数目的球") + +

    You are given an integer array nums where the ith bag contains nums[i] balls. You are also given an integer maxOperations.

    + +

    You can perform the following operation at most maxOperations times:

    + +
      +
    • Take any bag of balls and divide it into two new bags with a positive number of balls. +
        +
      • For example, a bag of 5 balls can become two new bags of 1 and 4 balls, or two new bags of 2 and 3 balls.
      • +
      +
    • +
    + +

    Your penalty is the maximum number of balls in a bag. You want to minimize your penalty after the operations.

    + +

    Return the minimum possible penalty after performing the operations.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [9], maxOperations = 2
    +Output: 3
    +Explanation: 
    +- Divide the bag with 9 balls into two bags of sizes 6 and 3. [9] -> [6,3].
    +- Divide the bag with 6 balls into two bags of sizes 3 and 3. [6,3] -> [3,3,3].
    +The bag with the most number of balls has 3 balls, so your penalty is 3 and you should return 3.
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,4,8,2], maxOperations = 4
    +Output: 2
    +Explanation:
    +- Divide the bag with 8 balls into two bags of sizes 4 and 4. [2,4,8,2] -> [2,4,4,4,2].
    +- Divide the bag with 4 balls into two bags of sizes 2 and 2. [2,4,4,4,2] -> [2,2,2,4,4,2].
    +- Divide the bag with 4 balls into two bags of sizes 2 and 2. [2,2,2,4,4,2] -> [2,2,2,2,2,4,2].
    +- Divide the bag with 4 balls into two bags of sizes 2 and 2. [2,2,2,2,2,4,2] -> [2,2,2,2,2,2,2,2].
    +The bag with the most number of balls has 2 balls, so your penalty is 2 an you should return 2.
    +
    + +

    Example 3:

    + +
    +Input: nums = [7,17], maxOperations = 2
    +Output: 7
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 1 <= maxOperations, nums[i] <= 109
    • +
    + +### Related Topics + [[Heap](../../tag/heap/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Let's change the question if we know the maximum size of a bag what is the minimum number of bags you can make +
    + +
    +Hint 2 +note that as the maximum size increases the minimum number of bags decreases so we can binary search the maximum size +
    diff --git a/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md b/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md new file mode 100644 index 000000000..4947d0761 --- /dev/null +++ b/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../merge-strings-alternately "Merge Strings Alternately") +                 +[Next >](../maximum-score-from-performing-multiplication-operations "Maximum Score from Performing Multiplication Operations") + +## [1769. Minimum Number of Operations to Move All Balls to Each Box (Medium)](https://leetcode.com/problems/minimum-number-of-operations-to-move-all-balls-to-each-box "移动所有球到每个盒子所需的最小操作数") + +

    You have n boxes. You are given a binary string boxes of length n, where boxes[i] is '0' if the ith box is empty, and '1' if it contains one ball.

    + +

    In one operation, you can move one ball from a box to an adjacent box. Box i is adjacent to box j if abs(i - j) == 1. Note that after doing so, there may be more than one ball in some boxes.

    + +

    Return an array answer of size n, where answer[i] is the minimum number of operations needed to move all the balls to the ith box.

    + +

    Each answer[i] is calculated considering the initial state of the boxes.

    + +

     

    +

    Example 1:

    + +
    +Input: boxes = "110"
    +Output: [1,1,3]
    +Explanation: The answer for each box is as follows:
    +1) First box: you will have to move one ball from the second box to the first box in one operation.
    +2) Second box: you will have to move one ball from the first box to the second box in one operation.
    +3) Third box: you will have to move one ball from the first box to the third box in two operations, and move one ball from the second box to the third box in one operation.
    +
    + +

    Example 2:

    + +
    +Input: boxes = "001011"
    +Output: [11,8,5,4,3,4]
    + +

     

    +

    Constraints:

    + +
      +
    • n == boxes.length
    • +
    • 1 <= n <= 2000
    • +
    • boxes[i] is either '0' or '1'.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +If you want to move a ball from box i to box j, you'll need abs(i-j) moves. +
    + +
    +Hint 2 +To move all balls to some box, you can move them one by one. +
    + +
    +Hint 3 +For each box i, iterate on each ball in a box j, and add abs(i-j) to answers[i]. +
    diff --git a/problems/minimum-unique-word-abbreviation/README.md b/problems/minimum-unique-word-abbreviation/README.md index 26b1ecb05..355b569bb 100644 --- a/problems/minimum-unique-word-abbreviation/README.md +++ b/problems/minimum-unique-word-abbreviation/README.md @@ -9,7 +9,7 @@                  [Next >](../fizz-buzz "Fizz Buzz") -## [411. Minimum Unique Word Abbreviation (Hard)](https://leetcode.com/problems/minimum-unique-word-abbreviation "最短特异单词缩写") +## [411. Minimum Unique Word Abbreviation (Hard)](https://leetcode.com/problems/minimum-unique-word-abbreviation "最短独占单词缩写")

    A string such as "word" contains the following abbreviations:

    diff --git a/problems/number-of-1-bits/README.md b/problems/number-of-1-bits/README.md index 3332909f4..5732c15d0 100644 --- a/problems/number-of-1-bits/README.md +++ b/problems/number-of-1-bits/README.md @@ -11,17 +11,15 @@ ## [191. Number of 1 Bits (Easy)](https://leetcode.com/problems/number-of-1-bits "位1的个数") -

    Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight).

    +

    Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight).

    Note:

    • Note that in some languages such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type. It should not affect your implementation, as the integer's internal binary representation is the same, whether it is signed or unsigned.
    • -
    • In Java, the compiler represents the signed integers using 2's complement notation. Therefore, in Example 3 above, the input represents the signed integer. -3.
    • +
    • In Java, the compiler represents the signed integers using 2's complement notation. Therefore, in Example 3, the input represents the signed integer. -3.
    -

    Follow up: If this function is called many times, how would you optimize it?

    -

     

    Example 1:

    @@ -54,6 +52,9 @@
  • The input must be a binary string of length 32
  • +

     

    +Follow up: If this function is called many times, how would you optimize it? + ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/number-of-enclaves/README.md b/problems/number-of-enclaves/README.md index e578da4be..8efe7a5cf 100644 --- a/problems/number-of-enclaves/README.md +++ b/problems/number-of-enclaves/README.md @@ -11,41 +11,38 @@ ## [1020. Number of Enclaves (Medium)](https://leetcode.com/problems/number-of-enclaves "飞地的数量") -

    Given a 2D array A, each cell is 0 (representing sea) or 1 (representing land)

    +

    You are given an m x n binary matrix grid, where 0 represents a sea cell and 1 represents a land cell.

    -

    A move consists of walking from one land square 4-directionally to another land square, or off the boundary of the grid.

    +

    A move consists of walking from one land cell to another adjacent (4-directionally) land cell or walking off the boundary of the grid.

    -

    Return the number of land squares in the grid for which we cannot walk off the boundary of the grid in any number of moves.

    +

    Return the number of land cells in grid for which we cannot walk off the boundary of the grid in any number of moves.

     

    -

    Example 1:

    - +
    -Input: [[0,0,0,0],[1,0,1,0],[0,1,1,0],[0,0,0,0]]
    -Output: 3
    -Explanation: 
    -There are three 1s that are enclosed by 0s, and one 1 that isn't enclosed because its on the boundary.
    +Input: grid = [[0,0,0,0],[1,0,1,0],[0,1,1,0],[0,0,0,0]] +Output: 3 +Explanation: There are three 1s that are enclosed by 0s, and one 1 that is not enclosed because its on the boundary. +

    Example 2:

    - +
    -Input: [[0,1,1,0],[0,0,1,0],[0,0,1,0],[0,0,0,0]]
    -Output: 0
    -Explanation: 
    -All 1s are either on the boundary or can reach the boundary.
    +Input: grid = [[0,1,1,0],[0,0,1,0],[0,0,1,0],[0,0,0,0]]
    +Output: 0
    +Explanation: All 1s are either on the boundary or can reach the boundary.
     

     

    - -

    Note:

    - -
      -
    1. 1 <= A.length <= 500
    2. -
    3. 1 <= A[i].length <= 500
    4. -
    5. 0 <= A[i][j] <= 1
    6. -
    7. All rows have the same size.
    8. -
    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 500
    • +
    • grid[i][j] is either 0 or 1.
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/pascals-triangle-ii/README.md b/problems/pascals-triangle-ii/README.md index eb483e16c..485894bde 100644 --- a/problems/pascals-triangle-ii/README.md +++ b/problems/pascals-triangle-ii/README.md @@ -11,17 +11,10 @@ ## [119. Pascal's Triangle II (Easy)](https://leetcode.com/problems/pascals-triangle-ii "杨辉三角 II") -

    Given an integer rowIndex, return the rowIndexth row of the Pascal's triangle.

    - -

    Notice that the row index starts from 0.

    - -


    -In Pascal's triangle, each number is the sum of the two numbers directly above it.

    - -

    Follow up:

    - -

    Could you optimize your algorithm to use only O(k) extra space?

    +

    Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle.

    +

    In Pascal's triangle, each number is the sum of the two numbers directly above it as shown:

    +

     

    Example 1:

    Input: rowIndex = 3
    @@ -37,9 +30,12 @@
     

    Constraints:

      -
    • 0 <= rowIndex <= 33
    • +
    • 0 <= rowIndex <= 33
    +

     

    +

    Follow up: Could you optimize your algorithm to use only O(rowIndex) extra space?

    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/pascals-triangle/README.md b/problems/pascals-triangle/README.md index 2ef0d3e30..05cfa20e7 100644 --- a/problems/pascals-triangle/README.md +++ b/problems/pascals-triangle/README.md @@ -11,24 +11,24 @@ ## [118. Pascal's Triangle (Easy)](https://leetcode.com/problems/pascals-triangle "杨辉三角") -

    Given a non-negative integer numRows, generate the first numRows of Pascal's triangle.

    - -


    -In Pascal's triangle, each number is the sum of the two numbers directly above it.

    - -

    Example:

    - -
    -Input: 5
    -Output:
    -[
    -     [1],
    -    [1,1],
    -   [1,2,1],
    -  [1,3,3,1],
    - [1,4,6,4,1]
    -]
    +

    Given an integer numRows, return the first numRows of Pascal's triangle.

    + +

    In Pascal's triangle, each number is the sum of the two numbers directly above it as shown:

    + +

     

    +

    Example 1:

    +
    Input: numRows = 5
    +Output: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]
    +

    Example 2:

    +
    Input: numRows = 1
    +Output: [[1]]
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= numRows <= 30
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/path-sum-iv/README.md b/problems/path-sum-iv/README.md index 4dbe3461f..3218705e0 100644 --- a/problems/path-sum-iv/README.md +++ b/problems/path-sum-iv/README.md @@ -9,7 +9,7 @@                  [Next >](../beautiful-arrangement-ii "Beautiful Arrangement II") -## [666. Path Sum IV (Medium)](https://leetcode.com/problems/path-sum-iv "路径和 IV") +## [666. Path Sum IV (Medium)](https://leetcode.com/problems/path-sum-iv "路径总和 IV")

    If the depth of a tree is smaller than 5, then this tree can be represented by a list of three-digits integers.

    diff --git a/problems/peeking-iterator/README.md b/problems/peeking-iterator/README.md index 62371eb61..19c92cdea 100644 --- a/problems/peeking-iterator/README.md +++ b/problems/peeking-iterator/README.md @@ -11,20 +11,48 @@ ## [284. Peeking Iterator (Medium)](https://leetcode.com/problems/peeking-iterator "顶端迭代器") -

    Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek() operation -- it essentially peek() at the element that will be returned by the next call to next().

    +

    Design an iterator that supports the peek operation on a list in addition to the hasNext and the next operations.

    -

    Example:

    +

    Implement the PeekingIterator class:

    + +
      +
    • PeekingIterator(int[] nums) Initializes the object with the given integer array nums.
    • +
    • int next() Returns the next element in the array and moves the pointer to the next element.
    • +
    • bool hasNext() Returns true if there are still elements in the array.
    • +
    • int peek() Returns the next element in the array without moving the pointer.
    • +
    + +

     

    +

    Example 1:

    -Assume that the iterator is initialized to the beginning of the list: [1,2,3].
    +Input
    +["PeekingIterator", "next", "peek", "next", "next", "hasNext"]
    +[[[1, 2, 3]], [], [], [], [], []]
    +Output
    +[null, 1, 2, 2, 3, false]
     
    -Call next() gets you 1, the first element in the list.
    -Now you call peek() and it returns 2, the next element. Calling next() after that still return 2. 
    -You call next() the final time and it returns 3, the last element. 
    -Calling hasNext() after that should return false.
    +Explanation
    +PeekingIterator peekingIterator = new PeekingIterator([1, 2, 3]); // [1,2,3]
    +peekingIterator.next();    // return 1, the pointer moves to the next element [1,2,3].
    +peekingIterator.peek();    // return 2, the pointer does not move [1,2,3].
    +peekingIterator.next();    // return 2, the pointer moves to the next element [1,2,3]
    +peekingIterator.next();    // return 3, the pointer moves to the next element [1,2,3]
    +peekingIterator.hasNext(); // return False
     
    -

    Follow up: How would you extend your design to be generic and work with all types, not just integer?

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • 1 <= nums[i] <= 1000
    • +
    • All the calls to next and peek are valid.
    • +
    • At most 1000 calls will be made to next, hasNext, and peek.
    • +
    + +

     

    +Follow up: How would you extend your design to be generic and work with all types, not just integer? ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/preimage-size-of-factorial-zeroes-function/README.md b/problems/preimage-size-of-factorial-zeroes-function/README.md index 782d598d5..2362656ce 100644 --- a/problems/preimage-size-of-factorial-zeroes-function/README.md +++ b/problems/preimage-size-of-factorial-zeroes-function/README.md @@ -9,7 +9,7 @@                  [Next >](../valid-tic-tac-toe-state "Valid Tic-Tac-Toe State") -## [793. Preimage Size of Factorial Zeroes Function (Hard)](https://leetcode.com/problems/preimage-size-of-factorial-zeroes-function "阶乘函数后K个零") +## [793. Preimage Size of Factorial Zeroes Function (Hard)](https://leetcode.com/problems/preimage-size-of-factorial-zeroes-function "阶乘函数后 K 个零")

    Let f(x) be the number of zeroes at the end of x!. (Recall that x! = 1 * 2 * 3 * ... * x, and by convention, 0! = 1.)

    diff --git a/problems/recyclable-and-low-fat-products/README.md b/problems/recyclable-and-low-fat-products/README.md new file mode 100644 index 000000000..d591b2303 --- /dev/null +++ b/problems/recyclable-and-low-fat-products/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../design-most-recently-used-queue "Design Most Recently Used Queue") +                 +[Next >](../minimum-changes-to-make-alternating-binary-string "Minimum Changes To Make Alternating Binary String") + +## [1757. Recyclable and Low Fat Products (Easy)](https://leetcode.com/problems/recyclable-and-low-fat-products "") + + diff --git a/problems/recyclable-and-low-fat-products/mysql_schemas.sql b/problems/recyclable-and-low-fat-products/mysql_schemas.sql new file mode 100644 index 000000000..bffc7a5fb --- /dev/null +++ b/problems/recyclable-and-low-fat-products/mysql_schemas.sql @@ -0,0 +1,7 @@ +Create table If Not Exists Products (product_id int, low_fats ENUM('Y', 'N'), recyclable ENUM('Y','N')); +Truncate table Products; +insert into Products (product_id, low_fats, recyclable) values ('0', 'Y', 'N'); +insert into Products (product_id, low_fats, recyclable) values ('1', 'Y', 'Y'); +insert into Products (product_id, low_fats, recyclable) values ('2', 'N', 'Y'); +insert into Products (product_id, low_fats, recyclable) values ('3', 'Y', 'Y'); +insert into Products (product_id, low_fats, recyclable) values ('4', 'N', 'N'); diff --git a/problems/relative-ranks/README.md b/problems/relative-ranks/README.md index ab21ccd9a..4e61c6bbc 100644 --- a/problems/relative-ranks/README.md +++ b/problems/relative-ranks/README.md @@ -11,20 +11,42 @@ ## [506. Relative Ranks (Easy)](https://leetcode.com/problems/relative-ranks "相对名次") -

    -Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: "Gold Medal", "Silver Medal" and "Bronze Medal".

    +

    You are given an integer array score of size n, where score[i] is the score of the ith athlete in a competition. All the scores are guaranteed to be unique.

    + +

    The athletes are placed based on their scores, where the 1st place athlete has the highest score, the 2nd place athlete has the 2nd highest score, and so on. The placement of each athlete determines their rank:

    + +
      +
    • The 1st place athlete's rank is "Gold Medal".
    • +
    • The 2nd place athlete's rank is "Silver Medal".
    • +
    • The 3rd place athlete's rank is "Bronze Medal".
    • +
    • For the 4th place to the nth place athlete, their rank is their placement number (i.e., the xth place athlete's rank is "x").
    • +
    + +

    Return an array answer of size n where answer[i] is the rank of the ith athlete.

    + +

     

    +

    Example 1:

    + +
    +Input: score = [5,4,3,2,1]
    +Output: ["Gold Medal","Silver Medal","Bronze Medal","4","5"]
    +Explanation: The placements are [1st, 2nd, 3rd, 4th, 5th].
    + +

    Example 2:

    -

    Example 1:

    -Input: [5, 4, 3, 2, 1]
    -Output: ["Gold Medal", "Silver Medal", "Bronze Medal", "4", "5"]
    -Explanation: The first three athletes got the top three highest scores, so they got "Gold Medal", "Silver Medal" and "Bronze Medal". 
    For the left two athletes, you just need to output their relative ranks according to their scores. +Input: score = [10,3,8,9,4] +Output: ["Gold Medal","5","Bronze Medal","Silver Medal","4"] +Explanation: The placements are [1st, 5th, 3rd, 2nd, 4th]. +
    -

    - -

    Note:
    -

      -
    1. N is a positive integer and won't exceed 10,000.
    2. -
    3. All the scores of athletes are guaranteed to be unique.
    4. -
    -

    + +

     

    +

    Constraints:

    + +
      +
    • n == score.length
    • +
    • 1 <= n <= 104
    • +
    • 0 <= score[i] <= 106
    • +
    • All the values in score are unique.
    • +
    diff --git a/problems/repeated-substring-pattern/README.md b/problems/repeated-substring-pattern/README.md index 0f8fa3f30..d5cf1a1d3 100644 --- a/problems/repeated-substring-pattern/README.md +++ b/problems/repeated-substring-pattern/README.md @@ -11,33 +11,40 @@ ## [459. Repeated Substring Pattern (Easy)](https://leetcode.com/problems/repeated-substring-pattern "重复的子字符串") -

    Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase English letters only and its length will not exceed 10000.

    +

    Given a string s, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together.

     

    - -

    Example 1:

    +

    Example 1:

    -Input: "abab"
    -Output: True
    -Explanation: It's the substring "ab" twice.
    +Input: s = "abab"
    +Output: true
    +Explanation: It is the substring "ab" twice.
     
    -

    Example 2:

    +

    Example 2:

    -Input: "aba"
    -Output: False
    +Input: s = "aba"
    +Output: false
     
    -

    Example 3:

    +

    Example 3:

    -Input: "abcabcabcabc"
    -Output: True
    -Explanation: It's the substring "abc" four times. (And the substring "abcabc" twice.)
    +Input: s = "abcabcabcabc"
    +Output: true
    +Explanation: It is the substring "abc" four times or the substring "abcabc" twice.
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 104
    • +
    • s consists of lowercase English letters.
    • +
    + ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/restore-ip-addresses/README.md b/problems/restore-ip-addresses/README.md index 8dfc24cfc..cb6a583eb 100644 --- a/problems/restore-ip-addresses/README.md +++ b/problems/restore-ip-addresses/README.md @@ -9,7 +9,7 @@                  [Next >](../binary-tree-inorder-traversal "Binary Tree Inorder Traversal") -## [93. Restore IP Addresses (Medium)](https://leetcode.com/problems/restore-ip-addresses "复原IP地址") +## [93. Restore IP Addresses (Medium)](https://leetcode.com/problems/restore-ip-addresses "复原 IP 地址")

    Given a string s containing only digits, return all possible valid IP addresses that can be obtained from s. You can return them in any order.

    diff --git a/problems/reverse-linked-list-ii/README.md b/problems/reverse-linked-list-ii/README.md index 9e99a57a2..e348ad947 100644 --- a/problems/reverse-linked-list-ii/README.md +++ b/problems/reverse-linked-list-ii/README.md @@ -11,17 +11,36 @@ ## [92. Reverse Linked List II (Medium)](https://leetcode.com/problems/reverse-linked-list-ii "反转链表 II") -

    Reverse a linked list from position m to n. Do it in one-pass.

    +

    Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list from position left to position right, and return the reversed list.

    -

    Note: 1 ≤ mn ≤ length of list.

    +

     

    +

    Example 1:

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

    Example:

    +

    Example 2:

    -Input: 1->2->3->4->5->NULL, m = 2, n = 4
    -Output: 1->4->3->2->5->NULL
    +Input: head = [5], left = 1, right = 1
    +Output: [5]
     
    +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is n.
    • +
    • 1 <= n <= 500
    • +
    • -500 <= Node.val <= 500
    • +
    • 1 <= left <= right <= n
    • +
    + +

     

    +Follow up: Could you do it in one pass? + ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/reverse-linked-list/README.md b/problems/reverse-linked-list/README.md index 932df0fe5..d03c625ab 100644 --- a/problems/reverse-linked-list/README.md +++ b/problems/reverse-linked-list/README.md @@ -11,18 +11,40 @@ ## [206. Reverse Linked List (Easy)](https://leetcode.com/problems/reverse-linked-list "反转链表") -

    Reverse a singly linked list.

    +

    Given the head of a singly linked list, reverse the list, and return the reversed list.

    -

    Example:

    +

     

    +

    Example 1:

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

    Example 2:

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

    Follow up:

    +

    Example 3:

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

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is the range [0, 5000].
    • +
    • -5000 <= Node.val <= 5000
    • +
    -

    A linked list can be reversed either iteratively or recursively. Could you implement both?

    +

     

    +

    Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both?

    ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/roman-to-integer/README.md b/problems/roman-to-integer/README.md index 595718a95..a8386bbd3 100644 --- a/problems/roman-to-integer/README.md +++ b/problems/roman-to-integer/README.md @@ -92,19 +92,5 @@ M 1000
    ### Hints
    Hint 1 -I - 1
    -V - 5
    -X - 10
    -L - 50
    -C - 100
    -D - 500
    -M - 1000
    -
    - -
    -Hint 2 -Rules:
    -* If I comes before V or X, subtract 1 eg: IV = 4 and IX = 9
    -* If X comes before L or C, subtract 10 eg: XL = 40 and XC = 90
    -* If C comes before D or M, subtract 100 eg: CD = 400 and CM = 900
    +Problem is simpler to solve by working the string from back to front and using a map.
    diff --git a/problems/search-in-rotated-sorted-array-ii/README.md b/problems/search-in-rotated-sorted-array-ii/README.md index d61592cd3..c1d27b58c 100644 --- a/problems/search-in-rotated-sorted-array-ii/README.md +++ b/problems/search-in-rotated-sorted-array-ii/README.md @@ -11,11 +11,11 @@ ## [81. Search in Rotated Sorted Array II (Medium)](https://leetcode.com/problems/search-in-rotated-sorted-array-ii "搜索旋转排序数组 II") -

    You are given an integer array nums sorted in ascending order (not necessarily distinct values), and an integer target.

    +

    There is an integer array nums sorted in non-decreasing order (not necessarily with distinct values).

    -

    Suppose that nums is rotated at some pivot unknown to you beforehand (i.e., [0,1,2,4,4,4,5,6,6,7] might become [4,5,6,6,7,0,1,2,4,4]).

    +

    Before being passed to your function, nums is rotated at an unknown pivot index k (0 <= k < nums.length) such that the resulting array is [nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]] (0-indexed). For example, [0,1,2,4,4,4,5,6,6,7] might be rotated at pivot index 5 and become [4,5,6,6,7,0,1,2,4,4].

    -

    If target is found in the array return its index, otherwise, return -1.

    +

    Given the array nums after the rotation and an integer target, return true if target is in nums, or false if it is not in nums.

     

    Example 1:

    @@ -36,7 +36,7 @@

     

    -Follow up: This problem is the same as Search in Rotated Sorted Array, where nums may contain duplicates. Would this affect the run-time complexity? How and why? +Follow up: This problem is the same as Search in Rotated Sorted Array, where nums may contain duplicates. Would this affect the runtime complexity? How and why? ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/search-in-rotated-sorted-array/README.md b/problems/search-in-rotated-sorted-array/README.md index e6d7c8e89..b299214e8 100644 --- a/problems/search-in-rotated-sorted-array/README.md +++ b/problems/search-in-rotated-sorted-array/README.md @@ -11,11 +11,11 @@ ## [33. Search in Rotated Sorted Array (Medium)](https://leetcode.com/problems/search-in-rotated-sorted-array "搜索旋转排序数组") -

    You are given an integer array nums sorted in ascending order (with distinct values), and an integer target.

    +

    There is an integer array nums sorted in ascending order (with distinct values).

    -

    Suppose that nums is rotated at some pivot unknown to you beforehand (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).

    +

    Prior to being passed to your function, nums is rotated at an unknown pivot index k (0 <= k < nums.length) such that the resulting array is [nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]] (0-indexed). For example, [0,1,2,4,5,6,7] might be rotated at pivot index 3 and become [4,5,6,7,0,1,2].

    -

    If target is found in the array return its index, otherwise, return -1.

    +

    Given the array nums after the rotation and an integer target, return the index of target if it is in nums, or -1 if it is not in nums.

     

    Example 1:

    @@ -39,6 +39,9 @@
  • -104 <= target <= 104
  • +

     

    +Follow up: Can you achieve this in O(log n) time complexity? + ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/shortest-distance-to-a-character/README.md b/problems/shortest-distance-to-a-character/README.md index bebafa834..0406ae171 100644 --- a/problems/shortest-distance-to-a-character/README.md +++ b/problems/shortest-distance-to-a-character/README.md @@ -11,21 +11,35 @@ ## [821. Shortest Distance to a Character (Easy)](https://leetcode.com/problems/shortest-distance-to-a-character "字符的最短距离") -

    Given a string s and a character c that occurs in s, return an array of integers answer where answer.length == s.length and answer[i] is the shortest distance from s[i] to the character c in s.

    +

    Given a string s and a character c that occurs in s, return an array of integers answer where answer.length == s.length and answer[i] is the distance from index i to the closest occurrence of character c in s.

    + +

    The distance between two indices i and j is abs(i - j), where abs is the absolute value function.

     

    Example 1:

    -
    Input: s = "loveleetcode", c = "e"
    +
    +
    +Input: s = "loveleetcode", c = "e"
     Output: [3,2,1,0,1,0,0,1,2,2,1,0]
    -

    Example 2:

    -
    Input: s = "aaab", c = "b"
    +Explanation: The character 'e' appears at indices 3, 5, 6, and 11 (0-indexed).
    +The closest occurrence of 'e' for index 0 is at index 3, so the distance is abs(0 - 3) = 3.
    +The closest occurrence of 'e' for index 1 is at index 3, so the distance is abs(1 - 3) = 3.
    +For index 4, there is a tie between the 'e' at index 3 and the 'e' at index 5, but the distance is still the same: abs(4 - 3) == abs(4 - 5) = 1.
    +The closest occurrence of 'e' for index 8 is at index 6, so the distance is abs(8 - 6) = 2.
    +
    + +

    Example 2:

    + +
    +Input: s = "aaab", c = "b"
     Output: [3,2,1,0]
     
    +

     

    Constraints:

    • 1 <= s.length <= 104
    • s[i] and c are lowercase English letters.
    • -
    • c occurs at least once in s.
    • +
    • It is guaranteed that c occurs at least once in s.
    diff --git a/problems/shortest-path-in-binary-matrix/README.md b/problems/shortest-path-in-binary-matrix/README.md index aa9ac7b98..2ebb3f0e8 100644 --- a/problems/shortest-path-in-binary-matrix/README.md +++ b/problems/shortest-path-in-binary-matrix/README.md @@ -11,51 +11,48 @@ ## [1091. Shortest Path in Binary Matrix (Medium)](https://leetcode.com/problems/shortest-path-in-binary-matrix "二进制矩阵中的最短路径") -

    In an N by N square grid, each cell is either empty (0) or blocked (1).

    +

    Given an n x n binary matrix grid, return the length of the shortest clear path in the matrix. If there is no clear path, return -1.

    -

    clear path from top-left to bottom-right has length k if and only if it is composed of cells C_1, C_2, ..., C_k such that:

    +

    A clear path in a binary matrix is a path from the top-left cell (i.e., (0, 0)) to the bottom-right cell (i.e., (n - 1, n - 1)) such that:

      -
    • Adjacent cells C_i and C_{i+1} are connected 8-directionally (ie., they are different and share an edge or corner)
    • -
    • C_1 is at location (0, 0) (ie. has value grid[0][0])
    • -
    • C_k is at location (N-1, N-1) (ie. has value grid[N-1][N-1])
    • -
    • If C_i is located at (r, c), then grid[r][c] is empty (ie. grid[r][c] == 0).
    • +
    • All the visited cells of the path are 0.
    • +
    • All the adjacent cells of the path are 8-directionally connected (i.e., they are different and they share an edge or a corner).
    -

    Return the length of the shortest such clear path from top-left to bottom-right.  If such a path does not exist, return -1.

    +

    The length of a clear path is the number of visited cells of this path.

     

    -

    Example 1:

    - +
    -Input: [[0,1],[1,0]]
    -
    -
    -Output: 2
    -
    +Input: grid = [[0,1],[1,0]]
    +Output: 2
     
    -

    Example 2:

    - +
    -Input: [[0,0,0],[1,1,0],[1,1,0]]
    -
    -
    +Input: grid = [[0,0,0],[1,1,0],[1,1,0]]
     Output: 4
    -
     
    -

     

    -
    +

    Example 3:

    + +
    +Input: grid = [[1,0,0],[1,1,0],[1,1,0]]
    +Output: -1
    +
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. 1 <= grid.length == grid[0].length <= 100
    2. -
    3. grid[r][c] is 0 or 1
    4. -
    +
      +
    • n == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= n <= 100
    • +
    • grid[i][j] is 0 or 1
    • +
    ### Related Topics [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/split-array-into-consecutive-subsequences/README.md b/problems/split-array-into-consecutive-subsequences/README.md index 9fb907bfb..a54202f42 100644 --- a/problems/split-array-into-consecutive-subsequences/README.md +++ b/problems/split-array-into-consecutive-subsequences/README.md @@ -11,49 +11,47 @@ ## [659. Split Array into Consecutive Subsequences (Medium)](https://leetcode.com/problems/split-array-into-consecutive-subsequences "分割数组为连续子序列") -

    Given an array nums sorted in ascending order, return true if and only if you can split it into 1 or more subsequences such that each subsequence consists of consecutive integers and has length at least 3.

    +

    Given an integer array nums that is sorted in ascending order, return true if and only if you can split it into one or more subsequences such that each subsequence consists of consecutive integers and has a length of at least 3.

     

    - -

    Example 1:

    +

    Example 1:

    -Input: [1,2,3,3,4,5]
    -Output: True
    +Input: nums = [1,2,3,3,4,5]
    +Output: true
     Explanation:
     You can split them into two consecutive subsequences : 
     1, 2, 3
     3, 4, 5
     
    -

    Example 2:

    +

    Example 2:

    -Input: [1,2,3,3,4,4,5,5]
    -Output: True
    +Input: nums = [1,2,3,3,4,4,5,5]
    +Output: true
     Explanation:
     You can split them into two consecutive subsequences : 
     1, 2, 3, 4, 5
     3, 4, 5
     
    -

    Example 3:

    +

    Example 3:

    -Input: [1,2,3,4,4,5]
    -Output: False
    +Input: nums = [1,2,3,4,4,5]
    +Output: false
     

     

    - -

    Constraints:

    +

    Constraints:

      -
    • 1 <= nums.length <= 10000
    • +
    • 1 <= nums.length <= 104
    • +
    • -1000 <= nums[i] <= 1000
    • +
    • nums is sorted in an ascending order.
    -

     

    - ### Related Topics [[Heap](../../tag/heap/README.md)] [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/sum-of-unique-elements/README.md b/problems/sum-of-unique-elements/README.md new file mode 100644 index 000000000..067d9813a --- /dev/null +++ b/problems/sum-of-unique-elements/README.md @@ -0,0 +1,59 @@ + + + + + + + +[< Previous](../leetflex-banned-accounts "Leetflex Banned Accounts") +                 +[Next >](../maximum-absolute-sum-of-any-subarray "Maximum Absolute Sum of Any Subarray") + +## [1748. Sum of Unique Elements (Easy)](https://leetcode.com/problems/sum-of-unique-elements "唯一元素的和") + +

    You are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array.

    + +

    Return the sum of all the unique elements of nums.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3,2]
    +Output: 4
    +Explanation: The unique elements are [1,3], and the sum is 4.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,1,1,1,1]
    +Output: 0
    +Explanation: There are no unique elements, and the sum is 0.
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,2,3,4,5]
    +Output: 15
    +Explanation: The unique elements are [1,2,3,4,5], and the sum is 15.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • 1 <= nums[i] <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +Use a dictionary to count the frequency of each number. +
    diff --git a/problems/sum-root-to-leaf-numbers/README.md b/problems/sum-root-to-leaf-numbers/README.md index b6da1efa5..f5f8ef2f9 100644 --- a/problems/sum-root-to-leaf-numbers/README.md +++ b/problems/sum-root-to-leaf-numbers/README.md @@ -11,42 +11,50 @@ ## [129. Sum Root to Leaf Numbers (Medium)](https://leetcode.com/problems/sum-root-to-leaf-numbers "求根到叶子节点数字之和") -

    Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.

    +

    You are given the root of a binary tree containing digits from 0 to 9 only.

    -

    An example is the root-to-leaf path 1->2->3 which represents the number 123.

    +

    Each root-to-leaf path in the tree represents a number.

    -

    Find the total sum of all root-to-leaf numbers.

    +
      +
    • For example, the root-to-leaf path 1 -> 2 -> 3 represents the number 123.
    • +
    -

    Note: A leaf is a node with no children.

    +

    Return the total sum of all root-to-leaf numbers.

    -

    Example:

    +

    A leaf node is a node with no children.

    +

     

    +

    Example 1:

    +
    -Input: [1,2,3]
    -    1
    -   / \
    -  2   3
    +Input: root = [1,2,3]
     Output: 25
     Explanation:
     The root-to-leaf path 1->2 represents the number 12.
     The root-to-leaf path 1->3 represents the number 13.
    -Therefore, sum = 12 + 13 = 25.
    +Therefore, sum = 12 + 13 = 25. +

    Example 2:

    - +
    -Input: [4,9,0,5,1]
    -    4
    -   / \
    -  9   0
    - / \
    -5   1
    +Input: root = [4,9,0,5,1]
     Output: 1026
     Explanation:
     The root-to-leaf path 4->9->5 represents the number 495.
     The root-to-leaf path 4->9->1 represents the number 491.
     The root-to-leaf path 4->0 represents the number 40.
    -Therefore, sum = 495 + 491 + 40 = 1026.
    +Therefore, sum = 495 + 491 + 40 = 1026. +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [1, 1000].
    • +
    • 0 <= Node.val <= 9
    • +
    • The depth of the tree will not exceed 10.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/surrounded-regions/README.md b/problems/surrounded-regions/README.md index 0a565a22b..f0434e8fd 100644 --- a/problems/surrounded-regions/README.md +++ b/problems/surrounded-regions/README.md @@ -11,31 +11,35 @@ ## [130. Surrounded Regions (Medium)](https://leetcode.com/problems/surrounded-regions "被围绕的区域") -

    Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.

    +

    Given an m x n matrix board containing 'X' and 'O', capture all regions surrounded by 'X'.

    -

    A region is captured by flipping all 'O's into 'X's in that surrounded region.

    - -

    Example:

    +

    A region is captured by flipping all 'O's into 'X's in that surrounded region.

    +

     

    +

    Example 1:

    +
    -X X X X
    -X O O X
    -X X O X
    -X O X X
    +Input: board = [["X","X","X","X"],["X","O","O","X"],["X","X","O","X"],["X","O","X","X"]]
    +Output: [["X","X","X","X"],["X","X","X","X"],["X","X","X","X"],["X","O","X","X"]]
    +Explanation: Surrounded regions should not be on the border, which means that any 'O' on the border of the board are not flipped to 'X'. Any 'O' that is not on the border and it is not connected to an 'O' on the border will be flipped to 'X'. Two cells are connected if they are adjacent cells connected horizontally or vertically.
     
    -

    After running your function, the board should be:

    +

    Example 2:

    -X X X X
    -X X X X
    -X X X X
    -X O X X
    +Input: board = [["X"]]
    +Output: [["X"]]
     
    -

    Explanation:

    +

     

    +

    Constraints:

    -

    Surrounded regions shouldn’t be on the border, which means that any 'O' on the border of the board are not flipped to 'X'. Any 'O' that is not on the border and it is not connected to an 'O' on the border will be flipped to 'X'. Two cells are connected if they are adjacent cells connected horizontally or vertically.

    +
      +
    • m == board.length
    • +
    • n == board[i].length
    • +
    • 1 <= m, n <= 200
    • +
    • board[i][j] is 'X' or 'O'.
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/swap-salary/README.md b/problems/swap-salary/README.md index 3fc6f3824..f9e7f212c 100644 --- a/problems/swap-salary/README.md +++ b/problems/swap-salary/README.md @@ -11,29 +11,52 @@ ## [627. Swap Salary (Easy)](https://leetcode.com/problems/swap-salary "变更性别") -

    Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update statement and no intermediate temp table.

    +

    Table: Salary

    -

    Note that you must write a single update statement, DO NOT write any select statement for this problem.

    +
    ++-------------+----------+
    +| Column Name | Type     |
    ++-------------+----------+
    +| id          | int      |
    +| name        | varchar  |
    +| sex         | ENUM     |
    +| salary      | int      |
    ++-------------+----------+
    +id is the primary key for this table.
    +The sex column is ENUM value of type ('m', 'f').
    +The table contains information about an employee.
    +

     

    -

    Example:

    +

    Write an SQL query to swap all 'f' and 'm' values (i.e., change all 'f' values to 'm' and vice versa) with a single update statement and no intermediate temp table(s).

    + +

    Note that you must write a single update statement, DO NOT write any select statement for this problem.

    + +

    The query result format is in the following example:

    + +

     

    +Salary table:
    ++----+------+-----+--------+
     | id | name | sex | salary |
    -|----|------|-----|--------|
    ++----+------+-----+--------+
     | 1  | A    | m   | 2500   |
     | 2  | B    | f   | 1500   |
     | 3  | C    | m   | 5500   |
     | 4  | D    | f   | 500    |
    -
    -After running your update statement, the above salary table should have the following rows: ++----+------+-----+--------+ -
    +Result table:
    ++----+------+-----+--------+
     | id | name | sex | salary |
    -|----|------|-----|--------|
    ++----+------+-----+--------+
     | 1  | A    | f   | 2500   |
     | 2  | B    | m   | 1500   |
     | 3  | C    | f   | 5500   |
     | 4  | D    | m   | 500    |
    ++----+------+-----+--------+
    +(1, A) and (2, C) were changed from 'm' to 'f'.
    +(2, B) and (4, D) were changed from 'f' to 'm'.
     
    diff --git a/problems/symmetric-tree/README.md b/problems/symmetric-tree/README.md index 31daa7e32..b63ee43fe 100644 --- a/problems/symmetric-tree/README.md +++ b/problems/symmetric-tree/README.md @@ -11,33 +11,33 @@ ## [101. Symmetric Tree (Easy)](https://leetcode.com/problems/symmetric-tree "对称二叉树") -

    Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).

    - -

    For example, this binary tree [1,2,2,3,4,4,3] is symmetric:

    +

    Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).

    +

     

    +

    Example 1:

    +
    -    1
    -   / \
    -  2   2
    - / \ / \
    -3  4 4  3
    +Input: root = [1,2,2,3,4,4,3]
    +Output: true
     
    -

     

    - -

    But the following [1,2,2,null,3,null,3] is not:

    - +

    Example 2:

    +
    -    1
    -   / \
    -  2   2
    -   \   \
    -   3    3
    +Input: root = [1,2,2,null,3,null,3]
    +Output: false
     

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [1, 1000].
    • +
    • -100 <= Node.val <= 100
    • +
    -

    Follow up: Solve it both recursively and iteratively.

    +

     

    +Follow up: Could you solve it both recursively and iteratively? ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/the-k-weakest-rows-in-a-matrix/README.md b/problems/the-k-weakest-rows-in-a-matrix/README.md index 7ca124453..0ce7840ee 100644 --- a/problems/the-k-weakest-rows-in-a-matrix/README.md +++ b/problems/the-k-weakest-rows-in-a-matrix/README.md @@ -11,9 +11,16 @@ ## [1337. The K Weakest Rows in a Matrix (Easy)](https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix "矩阵中战斗力最弱的 K 行") -

    Given a m * n matrix mat of ones (representing soldiers) and zeros (representing civilians), return the indexes of the k weakest rows in the matrix ordered from the weakest to the strongest.

    +

    You are given an m x n binary matrix mat of 1's (representing soldiers) and 0's (representing civilians). The soldiers are positioned in front of the civilians. That is, all the 1's will appear to the left of all the 0's in each row.

    -

    A row i is weaker than row j, if the number of soldiers in row i is less than the number of soldiers in row j, or they have the same number of soldiers but i is less than j. Soldiers are always stand in the frontier of a row, that is, always ones may appear first and then zeros.

    +

    A row i is weaker than a row j if one of the following is true:

    + +
      +
    • The number of soldiers in row i is less than the number of soldiers in row j.
    • +
    • Both rows have the same number of soldiers and i < j.
    • +
    + +

    Return the indices of the k weakest rows in the matrix ordered from weakest to strongest.

     

    Example 1:

    @@ -28,13 +35,13 @@ k = 3 Output: [2,0,3] Explanation: -The number of soldiers for each row is: -row 0 -> 2 -row 1 -> 4 -row 2 -> 1 -row 3 -> 2 -row 4 -> 5 -Rows ordered from the weakest to the strongest are [2,0,3,1,4] +The number of soldiers in each row is: +- Row 0: 2 +- Row 1: 4 +- Row 2: 1 +- Row 3: 2 +- Row 4: 5 +The rows ordered from weakest to strongest are [2,0,3,1,4].

    Example 2:

    @@ -42,18 +49,18 @@ Rows ordered from the weakest to the strongest are [2,0,3,1,4]
     Input: mat = 
     [[1,0,0,0],
    - [1,1,1,1],
    - [1,0,0,0],
    - [1,0,0,0]], 
    + [1,1,1,1],
    + [1,0,0,0],
    + [1,0,0,0]], 
     k = 2
     Output: [0,2]
     Explanation: 
    -The number of soldiers for each row is: 
    -row 0 -> 1 
    -row 1 -> 4 
    -row 2 -> 1 
    -row 3 -> 1 
    -Rows ordered from the weakest to the strongest are [0,2,3,1]
    +The number of soldiers in each row is: 
    +- Row 0: 1 
    +- Row 1: 4 
    +- Row 2: 1 
    +- Row 3: 1 
    +The rows ordered from weakest to strongest are [0,2,3,1].
     

     

    @@ -62,9 +69,9 @@ Rows ordered from the weakest to the strongest are [0,2,3,1]
    • m == mat.length
    • n == mat[i].length
    • -
    • 2 <= n, m <= 100
    • +
    • 2 <= n, m <= 100
    • 1 <= k <= m
    • -
    • matrix[i][j] is either 0 or 1.
    • +
    • matrix[i][j] is either 0 or 1.
    ### Related Topics diff --git a/problems/transpose-matrix/README.md b/problems/transpose-matrix/README.md index aaf46fee7..adbc9403d 100644 --- a/problems/transpose-matrix/README.md +++ b/problems/transpose-matrix/README.md @@ -11,41 +11,37 @@ ## [867. Transpose Matrix (Easy)](https://leetcode.com/problems/transpose-matrix "转置矩阵") -

    Given a matrix A, return the transpose of A.

    +

    Given a 2D integer array matrix, return the transpose of matrix.

    -

    The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the matrix.

    +

    The transpose of a matrix is the matrix flipped over its main diagonal, switching the matrix's row and column indices.

    -
    - +

     

    - -

    Example 1:

    -Input: [[1,2,3],[4,5,6],[7,8,9]]
    -Output: [[1,4,7],[2,5,8],[3,6,9]]
    +Input: matrix = [[1,2,3],[4,5,6],[7,8,9]]
    +Output: [[1,4,7],[2,5,8],[3,6,9]]
     
    -

    Example 2:

    -Input: [[1,2,3],[4,5,6]]
    -Output: [[1,4],[2,5],[3,6]]
    +Input: matrix = [[1,2,3],[4,5,6]]
    +Output: [[1,4],[2,5],[3,6]]
     

     

    - -

    Note:

    - -
      -
    1. 1 <= A.length <= 1000
    2. -
    3. 1 <= A[0].length <= 1000
    4. -
    -
    -
    +

    Constraints:

    + +
      +
    • m == matrix.length
    • +
    • n == matrix[i].length
    • +
    • 1 <= m, n <= 1000
    • +
    • 1 <= m * n <= 105
    • +
    • -109 <= matrix[i][j] <= 109
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/tree-of-coprimes/README.md b/problems/tree-of-coprimes/README.md new file mode 100644 index 000000000..5939557a2 --- /dev/null +++ b/problems/tree-of-coprimes/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../map-of-highest-peak "Map of Highest Peak") +                 +[Next >](../find-the-subtasks-that-did-not-execute "Find the Subtasks That Did Not Execute") + +## [1766. Tree of Coprimes (Hard)](https://leetcode.com/problems/tree-of-coprimes "互质树") + +

    There is a tree (i.e., a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. Each node has a value associated with it, and the root of the tree is node 0.

    + +

    To represent this tree, you are given an integer array nums and a 2D array edges. Each nums[i] represents the ith node's value, and each edges[j] = [uj, vj] represents an edge between nodes uj and vj in the tree.

    + +

    Two values x and y are coprime if gcd(x, y) == 1 where gcd(x, y) is the greatest common divisor of x and y.

    + +

    An ancestor of a node i is any other node on the shortest path from node i to the root. A node is not considered an ancestor of itself.

    + +

    Return an array ans of size n, where ans[i] is the closest ancestor to node i such that nums[i] and nums[ans[i]] are coprime, or -1 if there is no such ancestor.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: nums = [2,3,3,2], edges = [[0,1],[1,2],[1,3]]
    +Output: [-1,0,0,1]
    +Explanation: In the above figure, each node's value is in parentheses.
    +- Node 0 has no coprime ancestors.
    +- Node 1 has only one ancestor, node 0. Their values are coprime (gcd(2,3) == 1).
    +- Node 2 has two ancestors, nodes 1 and 0. Node 1's value is not coprime (gcd(3,3) == 3), but node 0's
    +  value is (gcd(2,3) == 1), so node 0 is the closest valid ancestor.
    +- Node 3 has two ancestors, nodes 1 and 0. It is coprime with node 1 (gcd(3,2) == 1), so node 1 is its
    +  closest valid ancestor.
    +
    + +

    Example 2:

    + +

    + +
    +Input: nums = [5,6,10,2,3,6,15], edges = [[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]]
    +Output: [-1,0,-1,0,0,0,-1]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • nums.length == n
    • +
    • 1 <= nums[i] <= 50
    • +
    • 1 <= n <= 105
    • +
    • edges.length == n - 1
    • +
    • edges[j].length == 2
    • +
    • 0 <= uj, vj < n
    • +
    • uj != vj
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Note that for a node, it's not optimal to consider two nodes with the same value. +
    + +
    +Hint 2 +Note that the values are small enough for you to iterate over them instead of iterating over the parent nodes. +
    diff --git a/problems/valid-palindrome/README.md b/problems/valid-palindrome/README.md index 46d89f104..c4df1f022 100644 --- a/problems/valid-palindrome/README.md +++ b/problems/valid-palindrome/README.md @@ -11,28 +11,30 @@ ## [125. Valid Palindrome (Easy)](https://leetcode.com/problems/valid-palindrome "验证回文串") -

    Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.

    - -

    Note: For the purpose of this problem, we define empty string as valid palindrome.

    +

    Given a string s, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.

    +

     

    Example 1:

    -Input: "A man, a plan, a canal: Panama"
    +Input: s = "A man, a plan, a canal: Panama"
     Output: true
    +Explanation: "amanaplanacanalpanama" is a palindrome.
     

    Example 2:

    -Input: "race a car"
    +Input: s = "race a car"
     Output: false
    +Explanation: "raceacar" is not a palindrome.
     

     

    Constraints:

      +
    • 1 <= s.length <= 2 * 105
    • s consists only of printable ASCII characters.
    diff --git a/problems/valid-parenthesis-string/README.md b/problems/valid-parenthesis-string/README.md index 86f71797c..93260c4b9 100644 --- a/problems/valid-parenthesis-string/README.md +++ b/problems/valid-parenthesis-string/README.md @@ -11,43 +11,35 @@ ## [678. Valid Parenthesis String (Medium)](https://leetcode.com/problems/valid-parenthesis-string "有效的括号字符串") -

    -Given a string containing only three types of characters: '(', ')' and '*', write a function to check whether this string is valid. We define the validity of a string by these rules: -

      -
    1. Any left parenthesis '(' must have a corresponding right parenthesis ')'.
    2. -
    3. Any right parenthesis ')' must have a corresponding left parenthesis '('.
    4. -
    5. Left parenthesis '(' must go before the corresponding right parenthesis ')'.
    6. -
    7. '*' could be treated as a single right parenthesis ')' or a single left parenthesis '(' or an empty string.
    8. -
    9. An empty string is also valid.
    10. -
    -

    - -

    Example 1:
    -

    -Input: "()"
    -Output: True
    +

    Given a string s containing only three types of characters: '(', ')' and '*', return true if s is valid.

    + +

    The following rules define a valid string:

    + +
      +
    • Any left parenthesis '(' must have a corresponding right parenthesis ')'.
    • +
    • Any right parenthesis ')' must have a corresponding left parenthesis '('.
    • +
    • Left parenthesis '(' must go before the corresponding right parenthesis ')'.
    • +
    • '*' could be treated as a single right parenthesis ')' or a single left parenthesis '(' or an empty string "".
    • +
    + +

     

    +

    Example 1:

    +
    Input: s = "()"
    +Output: true
    +

    Example 2:

    +
    Input: s = "(*)"
    +Output: true
    +

    Example 3:

    +
    Input: s = "(*))"
    +Output: true
     
    -

    +

     

    +

    Constraints:

    -

    Example 2:
    -

    -Input: "(*)"
    -Output: True
    -
    -

    - -

    Example 3:
    -

    -Input: "(*))"
    -Output: True
    -
    -

    - -

    Note:
    -

      -
    1. The string size will be in the range [1, 100].
    2. -
    -

    +
      +
    • 1 <= s.length <= 100
    • +
    • s[i] is '(', ')' or '*'.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/validate-binary-tree-nodes/README.md b/problems/validate-binary-tree-nodes/README.md index fe4ac2367..e09236345 100644 --- a/problems/validate-binary-tree-nodes/README.md +++ b/problems/validate-binary-tree-nodes/README.md @@ -11,44 +11,36 @@ ## [1361. Validate Binary Tree Nodes (Medium)](https://leetcode.com/problems/validate-binary-tree-nodes "验证二叉树") -

    You have n binary tree nodes numbered from 0 to n - 1 where node i has two children leftChild[i] and rightChild[i], return true if and only if all the given nodes form exactly one valid binary tree.

    +

    You have n binary tree nodes numbered from 0 to n - 1 where node i has two children leftChild[i] and rightChild[i], return true if and only if all the given nodes form exactly one valid binary tree.

    -

    If node i has no left child then leftChild[i] will equal -1, similarly for the right child.

    +

    If node i has no left child then leftChild[i] will equal -1, similarly for the right child.

    Note that the nodes have no values and that we only use the node numbers in this problem.

     

    Example 1:

    - -

    - +
     Input: n = 4, leftChild = [1,-1,3,-1], rightChild = [2,-1,-1,-1]
     Output: true
     

    Example 2:

    - -

    - +
     Input: n = 4, leftChild = [1,-1,3,-1], rightChild = [2,3,-1,-1]
     Output: false
     

    Example 3:

    - -

    - +
     Input: n = 2, leftChild = [1,0], rightChild = [-1,-1]
     Output: false
     

    Example 4:

    - -

    - +
     Input: n = 6, leftChild = [1,-1,-1,4,-1,-1], rightChild = [2,-1,-1,5,-1,-1]
     Output: false
    @@ -58,7 +50,7 @@
     

    Constraints:

      -
    • 1 <= n <= 10^4
    • +
    • 1 <= n <= 104
    • leftChild.length == rightChild.length == n
    • -1 <= leftChild[i], rightChild[i] <= n - 1
    diff --git a/problems/word-ladder-ii/README.md b/problems/word-ladder-ii/README.md index 89a3a383f..cc6960a6a 100644 --- a/problems/word-ladder-ii/README.md +++ b/problems/word-ladder-ii/README.md @@ -11,52 +11,44 @@ ## [126. Word Ladder II (Hard)](https://leetcode.com/problems/word-ladder-ii "单词接龙 II") -

    Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord to endWord, such that:

    - -
      -
    1. Only one letter can be changed at a time
    2. -
    3. Each transformed word must exist in the word list. Note that beginWord is not a transformed word.
    4. -
    - -

    Note:

    +

    A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words such that:

      -
    • Return an empty list if there is no such transformation sequence.
    • -
    • All words have the same length.
    • -
    • All words contain only lowercase alphabetic characters.
    • -
    • You may assume no duplicates in the word list.
    • -
    • You may assume beginWord and endWord are non-empty and are not the same.
    • +
    • The first word in the sequence is beginWord.
    • +
    • The last word in the sequence is endWord.
    • +
    • Only one letter is different between each adjacent pair of words in the sequence.
    • +
    • Every word in the sequence is in wordList.
    +

    Given two words, beginWord and endWord, and a dictionary wordList, return all the shortest transformation sequences from beginWord to endWord, or an empty list if no such sequence exists.

    + +

     

    Example 1:

    -Input:
    -beginWord = "hit",
    -endWord = "cog",
    -wordList = ["hot","dot","dog","lot","log","cog"]
    -
    -Output:
    -[
    -  ["hit","hot","dot","dog","cog"],
    -  ["hit","hot","lot","log","cog"]
    -]
    +Input: beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log","cog"]
    +Output: [["hit","hot","dot","dog","cog"],["hit","hot","lot","log","cog"]]
     

    Example 2:

    -Input:
    -beginWord = "hit"
    -endWord = "cog"
    -wordList = ["hot","dot","dog","lot","log"]
    -
    -Output: []
    -
    -Explanation: The endWord "cog" is not in wordList, therefore no possible transformation.
    +Input: beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log"]
    +Output: []
    +Explanation: The endWord "cog" is not in wordList, therefore no possible transformation.
     
    +

     

    +

    Constraints:

    +
      +
    • 1 <= beginWord.length <= 10
    • +
    • endWord.length == beginWord.length
    • +
    • 1 <= wordList.length <= 5000
    • +
    • wordList[i].length == beginWord.length
    • +
    • beginWord, endWord, and wordList[i] consist of lowercase English letters.
    • +
    • beginWord != endWord
    • +
    • All the strings in wordList are unique.
    ### Related Topics diff --git a/readme/1-300.md b/readme/1-300.md index 6d10e1a70..af0abba75 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -107,7 +107,7 @@ LeetCode Problems' Solutions | 35 | [Search Insert Position](https://leetcode.com/problems/search-insert-position "搜索插入位置") | [Go](../problems/search-insert-position) | Easy | | 36 | [Valid Sudoku](https://leetcode.com/problems/valid-sudoku "有效的数独") | [Go](../problems/valid-sudoku) | Medium | | 37 | [Sudoku Solver](https://leetcode.com/problems/sudoku-solver "解数独") | [Go](../problems/sudoku-solver) | Hard | -| 38 | [Count and Say](https://leetcode.com/problems/count-and-say "外观数列") | [Go](../problems/count-and-say) | Easy | +| 38 | [Count and Say](https://leetcode.com/problems/count-and-say "外观数列") | [Go](../problems/count-and-say) | Medium | | 39 | [Combination Sum](https://leetcode.com/problems/combination-sum "组合总和") | [Go](../problems/combination-sum) | Medium | | 40 | [Combination Sum II](https://leetcode.com/problems/combination-sum-ii "组合总和 II") | [Go](../problems/combination-sum-ii) | Medium | | 41 | [First Missing Positive](https://leetcode.com/problems/first-missing-positive "缺失的第一个正数") | [Go](../problems/first-missing-positive) | Hard | @@ -162,7 +162,7 @@ LeetCode Problems' Solutions | 90 | [Subsets II](https://leetcode.com/problems/subsets-ii "子集 II") | [Go](../problems/subsets-ii) | Medium | | 91 | [Decode Ways](https://leetcode.com/problems/decode-ways "解码方法") | [Go](../problems/decode-ways) | Medium | | 92 | [Reverse Linked List II](https://leetcode.com/problems/reverse-linked-list-ii "反转链表 II") | [Go](../problems/reverse-linked-list-ii) | Medium | -| 93 | [Restore IP Addresses](https://leetcode.com/problems/restore-ip-addresses "复原IP地址") | [Go](../problems/restore-ip-addresses) | Medium | +| 93 | [Restore IP Addresses](https://leetcode.com/problems/restore-ip-addresses "复原 IP 地址") | [Go](../problems/restore-ip-addresses) | Medium | | 94 | [Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal "二叉树的中序遍历") | [Go](../problems/binary-tree-inorder-traversal) | Medium | | 95 | [Unique Binary Search Trees II](https://leetcode.com/problems/unique-binary-search-trees-ii "不同的二叉搜索树 II") | [Go](../problems/unique-binary-search-trees-ii) | Medium | | 96 | [Unique Binary Search Trees](https://leetcode.com/problems/unique-binary-search-trees "不同的二叉搜索树") | [Go](../problems/unique-binary-search-trees) | Medium | @@ -176,7 +176,7 @@ LeetCode Problems' Solutions | 104 | [Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree "二叉树的最大深度") | [Go](../problems/maximum-depth-of-binary-tree) | Easy | | 105 | [Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal "从前序与中序遍历序列构造二叉树") | [Go](../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | Medium | | 106 | [Construct Binary Tree from Inorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal "从中序与后序遍历序列构造二叉树") | [Go](../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | Medium | -| 107 | [Binary Tree Level Order Traversal II](https://leetcode.com/problems/binary-tree-level-order-traversal-ii "二叉树的层序遍历 II") | [Go](../problems/binary-tree-level-order-traversal-ii) | Easy | +| 107 | [Binary Tree Level Order Traversal II](https://leetcode.com/problems/binary-tree-level-order-traversal-ii "二叉树的层序遍历 II") | [Go](../problems/binary-tree-level-order-traversal-ii) | Medium | | 108 | [Convert Sorted Array to Binary Search Tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree "将有序数组转换为二叉搜索树") | [Go](../problems/convert-sorted-array-to-binary-search-tree) | Easy | | 109 | [Convert Sorted List to Binary Search Tree](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree "有序链表转换二叉搜索树") | [Go](../problems/convert-sorted-list-to-binary-search-tree) | Medium | | 110 | [Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree "平衡二叉树") | [Go](../problems/balanced-binary-tree) | Easy | diff --git a/readme/301-600.md b/readme/301-600.md index 7e8d51d89..abdde95ce 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -117,7 +117,7 @@ LeetCode Problems' Solutions | 345 | [Reverse Vowels of a String](https://leetcode.com/problems/reverse-vowels-of-a-string "反转字符串中的元音字母") | [Go](../problems/reverse-vowels-of-a-string) | Easy | | 346 | [Moving Average from Data Stream](https://leetcode.com/problems/moving-average-from-data-stream "数据流中的移动平均值") 🔒 | [Go](../problems/moving-average-from-data-stream) | Easy | | 347 | [Top K Frequent Elements](https://leetcode.com/problems/top-k-frequent-elements "前 K 个高频元素") | [Go](../problems/top-k-frequent-elements) | Medium | -| 348 | [Design Tic-Tac-Toe](https://leetcode.com/problems/design-tic-tac-toe "判定井字棋胜负") 🔒 | [Go](../problems/design-tic-tac-toe) | Medium | +| 348 | [Design Tic-Tac-Toe](https://leetcode.com/problems/design-tic-tac-toe "设计井字棋") 🔒 | [Go](../problems/design-tic-tac-toe) | Medium | | 349 | [Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays "两个数组的交集") | [Go](../problems/intersection-of-two-arrays) | Easy | | 350 | [Intersection of Two Arrays II](https://leetcode.com/problems/intersection-of-two-arrays-ii "两个数组的交集 II") | [Go](../problems/intersection-of-two-arrays-ii) | Easy | | 351 | [Android Unlock Patterns](https://leetcode.com/problems/android-unlock-patterns "安卓系统手势解锁") 🔒 | [Go](../problems/android-unlock-patterns) | Medium | @@ -147,7 +147,7 @@ LeetCode Problems' Solutions | 375 | [Guess Number Higher or Lower II](https://leetcode.com/problems/guess-number-higher-or-lower-ii "猜数字大小 II") | [Go](../problems/guess-number-higher-or-lower-ii) | Medium | | 376 | [Wiggle Subsequence](https://leetcode.com/problems/wiggle-subsequence "摆动序列") | [Go](../problems/wiggle-subsequence) | Medium | | 377 | [Combination Sum IV](https://leetcode.com/problems/combination-sum-iv "组合总和 Ⅳ") | [Go](../problems/combination-sum-iv) | Medium | -| 378 | [Kth Smallest Element in a Sorted Matrix](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix "有序矩阵中第K小的元素") | [Go](../problems/kth-smallest-element-in-a-sorted-matrix) | Medium | +| 378 | [Kth Smallest Element in a Sorted Matrix](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix "有序矩阵中第 K 小的元素") | [Go](../problems/kth-smallest-element-in-a-sorted-matrix) | Medium | | 379 | [Design Phone Directory](https://leetcode.com/problems/design-phone-directory "电话目录管理系统") 🔒 | [Go](../problems/design-phone-directory) | Medium | | 380 | [Insert Delete GetRandom O(1)](https://leetcode.com/problems/insert-delete-getrandom-o1 "常数时间插入、删除和获取随机元素") | [Go](../problems/insert-delete-getrandom-o1) | Medium | | 381 | [Insert Delete GetRandom O(1) - Duplicates allowed](https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed "O(1) 时间插入、删除和获取随机元素 - 允许重复") | [Go](../problems/insert-delete-getrandom-o1-duplicates-allowed) | Hard | @@ -180,7 +180,7 @@ LeetCode Problems' Solutions | 408 | [Valid Word Abbreviation](https://leetcode.com/problems/valid-word-abbreviation "有效单词缩写") 🔒 | [Go](../problems/valid-word-abbreviation) | Easy | | 409 | [Longest Palindrome](https://leetcode.com/problems/longest-palindrome "最长回文串") | [Go](../problems/longest-palindrome) | Easy | | 410 | [Split Array Largest Sum](https://leetcode.com/problems/split-array-largest-sum "分割数组的最大值") | [Go](../problems/split-array-largest-sum) | Hard | -| 411 | [Minimum Unique Word Abbreviation](https://leetcode.com/problems/minimum-unique-word-abbreviation "最短特异单词缩写") 🔒 | [Go](../problems/minimum-unique-word-abbreviation) | Hard | +| 411 | [Minimum Unique Word Abbreviation](https://leetcode.com/problems/minimum-unique-word-abbreviation "最短独占单词缩写") 🔒 | [Go](../problems/minimum-unique-word-abbreviation) | Hard | | 412 | [Fizz Buzz](https://leetcode.com/problems/fizz-buzz "Fizz Buzz") | [Go](../problems/fizz-buzz) | Easy | | 413 | [Arithmetic Slices](https://leetcode.com/problems/arithmetic-slices "等差数列划分") | [Go](../problems/arithmetic-slices) | Medium | | 414 | [Third Maximum Number](https://leetcode.com/problems/third-maximum-number "第三大的数") | [Go](../problems/third-maximum-number) | Easy | @@ -254,7 +254,7 @@ LeetCode Problems' Solutions | 482 | [License Key Formatting](https://leetcode.com/problems/license-key-formatting "密钥格式化") | [Go](../problems/license-key-formatting) | Easy | | 483 | [Smallest Good Base](https://leetcode.com/problems/smallest-good-base "最小好进制") | [Go](../problems/smallest-good-base) | Hard | | 484 | [Find Permutation](https://leetcode.com/problems/find-permutation "寻找排列") 🔒 | [Go](../problems/find-permutation) | Medium | -| 485 | [Max Consecutive Ones](https://leetcode.com/problems/max-consecutive-ones "最大连续1的个数") | [Go](../problems/max-consecutive-ones) | Easy | +| 485 | [Max Consecutive Ones](https://leetcode.com/problems/max-consecutive-ones "最大连续 1 的个数") | [Go](../problems/max-consecutive-ones) | Easy | | 486 | [Predict the Winner](https://leetcode.com/problems/predict-the-winner "预测赢家") | [Go](../problems/predict-the-winner) | Medium | | 487 | [Max Consecutive Ones II](https://leetcode.com/problems/max-consecutive-ones-ii "最大连续1的个数 II") 🔒 | [Go](../problems/max-consecutive-ones-ii) | Medium | | 488 | [Zuma Game](https://leetcode.com/problems/zuma-game "祖玛游戏") | [Go](../problems/zuma-game) | Hard | diff --git a/readme/601-900.md b/readme/601-900.md index 3030e2337..27be07057 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -108,7 +108,7 @@ LeetCode Problems' Solutions | 636 | [Exclusive Time of Functions](https://leetcode.com/problems/exclusive-time-of-functions "函数的独占时间") | [Go](../problems/exclusive-time-of-functions) | Medium | | 637 | [Average of Levels in Binary Tree](https://leetcode.com/problems/average-of-levels-in-binary-tree "二叉树的层平均值") | [Go](../problems/average-of-levels-in-binary-tree) | Easy | | 638 | [Shopping Offers](https://leetcode.com/problems/shopping-offers "大礼包") | [Go](../problems/shopping-offers) | Medium | -| 639 | [Decode Ways II](https://leetcode.com/problems/decode-ways-ii "解码方法 2") | [Go](../problems/decode-ways-ii) | Hard | +| 639 | [Decode Ways II](https://leetcode.com/problems/decode-ways-ii "解码方法 II") | [Go](../problems/decode-ways-ii) | Hard | | 640 | [Solve the Equation](https://leetcode.com/problems/solve-the-equation "求解方程") | [Go](../problems/solve-the-equation) | Medium | | 641 | [Design Circular Deque](https://leetcode.com/problems/design-circular-deque "设计循环双端队列") | [Go](../problems/design-circular-deque) | Medium | | 642 | [Design Search Autocomplete System](https://leetcode.com/problems/design-search-autocomplete-system "设计搜索自动补全系统") 🔒 | [Go](../problems/design-search-autocomplete-system) | Hard | @@ -135,7 +135,7 @@ LeetCode Problems' Solutions | 663 | [Equal Tree Partition](https://leetcode.com/problems/equal-tree-partition "均匀树划分") 🔒 | [Go](../problems/equal-tree-partition) | Medium | | 664 | [Strange Printer](https://leetcode.com/problems/strange-printer "奇怪的打印机") | [Go](../problems/strange-printer) | Hard | | 665 | [Non-decreasing Array](https://leetcode.com/problems/non-decreasing-array "非递减数列") | [Go](../problems/non-decreasing-array) | Medium | -| 666 | [Path Sum IV](https://leetcode.com/problems/path-sum-iv "路径和 IV") 🔒 | [Go](../problems/path-sum-iv) | Medium | +| 666 | [Path Sum IV](https://leetcode.com/problems/path-sum-iv "路径总和 IV") 🔒 | [Go](../problems/path-sum-iv) | Medium | | 667 | [Beautiful Arrangement II](https://leetcode.com/problems/beautiful-arrangement-ii "优美的排列 II") | [Go](../problems/beautiful-arrangement-ii) | Medium | | 668 | [Kth Smallest Number in Multiplication Table](https://leetcode.com/problems/kth-smallest-number-in-multiplication-table "乘法表中第k小的数") | [Go](../problems/kth-smallest-number-in-multiplication-table) | Hard | | 669 | [Trim a Binary Search Tree](https://leetcode.com/problems/trim-a-binary-search-tree "修剪二叉搜索树") | [Go](../problems/trim-a-binary-search-tree) | Medium | @@ -262,7 +262,7 @@ LeetCode Problems' Solutions | 790 | [Domino and Tromino Tiling](https://leetcode.com/problems/domino-and-tromino-tiling "多米诺和托米诺平铺") | [Go](../problems/domino-and-tromino-tiling) | Medium | | 791 | [Custom Sort String](https://leetcode.com/problems/custom-sort-string "自定义字符串排序") | [Go](../problems/custom-sort-string) | Medium | | 792 | [Number of Matching Subsequences](https://leetcode.com/problems/number-of-matching-subsequences "匹配子序列的单词数") | [Go](../problems/number-of-matching-subsequences) | Medium | -| 793 | [Preimage Size of Factorial Zeroes Function](https://leetcode.com/problems/preimage-size-of-factorial-zeroes-function "阶乘函数后K个零") | [Go](../problems/preimage-size-of-factorial-zeroes-function) | Hard | +| 793 | [Preimage Size of Factorial Zeroes Function](https://leetcode.com/problems/preimage-size-of-factorial-zeroes-function "阶乘函数后 K 个零") | [Go](../problems/preimage-size-of-factorial-zeroes-function) | Hard | | 794 | [Valid Tic-Tac-Toe State](https://leetcode.com/problems/valid-tic-tac-toe-state "有效的井字游戏") | [Go](../problems/valid-tic-tac-toe-state) | Medium | | 795 | [Number of Subarrays with Bounded Maximum](https://leetcode.com/problems/number-of-subarrays-with-bounded-maximum "区间子数组个数") | [Go](../problems/number-of-subarrays-with-bounded-maximum) | Medium | | 796 | [Rotate String](https://leetcode.com/problems/rotate-string "旋转字符串") | [Go](../problems/rotate-string) | Easy | diff --git a/tag/README.md b/tag/README.md index 1da49de17..d5c45a064 100644 --- a/tag/README.md +++ b/tag/README.md @@ -29,4 +29,5 @@ | 35 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [](dequeue/README.md) | [](https://openset.github.io/tags/dequeue/) | | 37 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | | 38 | [Suffix Array](suffix-array/README.md) | [Suffix Array](https://openset.github.io/tags/suffix-array/) | | 39 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | | 40 | [Reservoir Sampling](reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | -| 41 | [Memoization](memoization/README.md) | [记忆化](https://openset.github.io/tags/memoization/) | | 42 | [](oop/README.md) | [](https://openset.github.io/tags/oop/) | +| 41 | [](meet-in-the-middle/README.md) | [](https://openset.github.io/tags/meet-in-the-middle/) | | 42 | [Memoization](memoization/README.md) | [记忆化](https://openset.github.io/tags/memoization/) | +| 43 | [](oop/README.md) | [](https://openset.github.io/tags/oop/) | \ No newline at end of file diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 94b8cca71..124b4c278 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,3 +9,69 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1688 | [比赛中的配对次数](../../problems/count-of-matches-in-tournament) | [[回溯算法](../backtracking/README.md)] | Easy | +| 1681 | [最小不兼容性](../../problems/minimum-incompatibility) | [[贪心算法](../greedy/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[回溯算法](../backtracking/README.md)] | Hard | +| 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[回溯算法](../backtracking/README.md)] | Medium | +| 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1415 | [长度为 n 的开心字符串中字典序第 k 小的字符串](../../problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | [[回溯算法](../backtracking/README.md)] | Medium | +| 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1291 | [顺次数](../../problems/sequential-digits) | [[回溯算法](../backtracking/README.md)] | Medium | +| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1258 | [近义词句子](../../problems/synonymous-sentences) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | +| 1240 | [铺瓷砖](../../problems/tiling-a-rectangle-with-the-fewest-squares) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1239 | [串联字符串的最大长度](../../problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1219 | [黄金矿工](../../problems/path-with-maximum-gold) | [[回溯算法](../backtracking/README.md)] | Medium | +| 1215 | [步进数](../../problems/stepping-numbers) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | +| 1088 | [易混淆数 II](../../problems/confusing-number-ii) 🔒 | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1087 | [花括号展开](../../problems/brace-expansion) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | +| 1079 | [活字印刷](../../problems/letter-tile-possibilities) | [[回溯算法](../backtracking/README.md)] | Medium | +| 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 980 | [不同路径 III](../../problems/unique-paths-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 526 | [优美的排列](../../problems/beautiful-arrangement) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 425 | [单词方块](../../problems/word-squares) 🔒 | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 411 | [最短独占单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 401 | [二进制手表](../../problems/binary-watch) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | +| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 351 | [安卓系统手势解锁](../../problems/android-unlock-patterns) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 306 | [累加数](../../problems/additive-number) | [[回溯算法](../backtracking/README.md)] | Medium | +| 294 | [翻转游戏 II](../../problems/flip-game-ii) 🔒 | [[极小化极大](../minimax/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 291 | [单词规律 II](../../problems/word-pattern-ii) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | +| 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | +| 254 | [因子的组合](../../problems/factor-combinations) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | +| 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 140 | [单词拆分 II](../../problems/word-break-ii) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 93 | [复原 IP 地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 90 | [子集 II](../../problems/subsets-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 89 | [格雷编码](../../problems/gray-code) | [[回溯算法](../backtracking/README.md)] | Medium | +| 79 | [单词搜索](../../problems/word-search) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 77 | [组合](../../problems/combinations) | [[回溯算法](../backtracking/README.md)] | Medium | +| 60 | [排列序列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 52 | [N皇后 II](../../problems/n-queens-ii) | [[回溯算法](../backtracking/README.md)] | Hard | +| 51 | [N 皇后](../../problems/n-queens) | [[回溯算法](../backtracking/README.md)] | Hard | +| 47 | [全排列 II](../../problems/permutations-ii) | [[回溯算法](../backtracking/README.md)] | Medium | +| 46 | [全排列](../../problems/permutations) | [[回溯算法](../backtracking/README.md)] | Medium | +| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 40 | [组合总和 II](../../problems/combination-sum-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 39 | [组合总和](../../problems/combination-sum) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 37 | [解数独](../../problems/sudoku-solver) | [[哈希表](../hash-table/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 31963f6d8..66f158290 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1760 | [袋子里最少数目的球](../../problems/minimum-limit-of-balls-in-a-bag) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1751 | [最多可以参加的会议数目 II](../../problems/maximum-number-of-events-that-can-be-attended-ii) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1739 | [放置盒子](../../problems/building-boxes) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | @@ -51,7 +53,7 @@ | 875 | [爱吃香蕉的珂珂](../../problems/koko-eating-bananas) | [[二分查找](../binary-search/README.md)] | Medium | | 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 852 | [山脉数组的峰顶索引](../../problems/peak-index-in-a-mountain-array) | [[二分查找](../binary-search/README.md)] | Easy | -| 793 | [阶乘函数后K个零](../../problems/preimage-size-of-factorial-zeroes-function) | [[二分查找](../binary-search/README.md)] | Hard | +| 793 | [阶乘函数后 K 个零](../../problems/preimage-size-of-factorial-zeroes-function) | [[二分查找](../binary-search/README.md)] | Hard | | 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 774 | [最小化去加油站的最大距离](../../problems/minimize-max-distance-to-gas-station) 🔒 | [[二分查找](../binary-search/README.md)] | Hard | @@ -75,7 +77,7 @@ | 436 | [寻找右区间](../../problems/find-right-interval) | [[二分查找](../binary-search/README.md)] | Medium | | 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 378 | [有序矩阵中第K小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 374 | [猜数字大小](../../problems/guess-number-higher-or-lower) | [[二分查找](../binary-search/README.md)] | Easy | | 367 | [有效的完全平方数](../../problems/valid-perfect-square) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 864999c74..5e37da64c 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -44,7 +44,7 @@ | 476 | [数字的补数](../../problems/number-complement) | [[位运算](../bit-manipulation/README.md)] | Easy | | 461 | [汉明距离](../../problems/hamming-distance) | [[位运算](../bit-manipulation/README.md)] | Easy | | 421 | [数组中两个数的最大异或值](../../problems/maximum-xor-of-two-numbers-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Medium | -| 411 | [最短特异单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 411 | [最短独占单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 405 | [数字转换为十六进制数](../../problems/convert-a-number-to-hexadecimal) | [[位运算](../bit-manipulation/README.md)] | Easy | | 401 | [二进制手表](../../problems/binary-watch) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | | 397 | [整数替换](../../problems/integer-replacement) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index e88d1c101..f68972b31 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | +| 1765 | [地图中的最高点](../../problems/map-of-highest-peak) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1730 | [获取食物的最短路径](../../problems/shortest-path-to-get-food) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1654 | [到家的最少跳跃次数](../../problems/minimum-jumps-to-reach-home) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -82,14 +84,14 @@ | 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | | 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | | 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | | 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 127 | [单词接龙](../../problems/word-ladder) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 102 | [二叉树的层序遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index fd6aef291..92f2a97c3 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,3 +9,158 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | +| 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1730 | [获取食物的最短路径](../../problems/shortest-path-to-get-food) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[贪心算法](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1625 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | +| 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1469 | [寻找所有的独生节点](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 1466 | [重新规划路线](../../problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 1377 | [T 秒后青蛙的位置](../../problems/frog-position-after-t-seconds) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 1376 | [通知所有员工所需的时间](../../problems/time-needed-to-inform-all-employees) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 1315 | [祖父节点值为偶数的节点和](../../problems/sum-of-nodes-with-even-valued-grandparent) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1273 | [删除树节点](../../problems/delete-tree-nodes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1254 | [统计封闭岛屿的数目](../../problems/number-of-closed-islands) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1242 | [多线程网页爬虫](../../problems/web-crawler-multithreaded) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1236 | [网络爬虫](../../problems/web-crawler) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 1192 | [查找集群内的「关键连接」](../../problems/critical-connections-in-a-network) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1110 | [删点成林](../../problems/delete-nodes-and-return-forest) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 1080 | [根到叶路径上的不足节点](../../problems/insufficient-nodes-in-root-to-leaf-paths) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1061 | [按字典序排列最小的等效字符串](../../problems/lexicographically-smallest-equivalent-string) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 1059 | [从始点到终点的所有路径](../../problems/all-paths-from-source-lead-to-destination) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 1026 | [节点与其祖先之间的最大差值](../../problems/maximum-difference-between-node-and-ancestor) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1020 | [飞地的数量](../../problems/number-of-enclaves) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 988 | [从叶结点开始的最小字符串](../../problems/smallest-string-starting-from-leaf) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 980 | [不同路径 III](../../problems/unique-paths-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 979 | [在二叉树中分配硬币](../../problems/distribute-coins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 971 | [翻转二叉树以匹配先序遍历](../../problems/flip-binary-tree-to-match-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 947 | [移除最多的同行或同列石头](../../problems/most-stones-removed-with-same-row-or-column) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 924 | [尽量减少恶意软件的传播](../../problems/minimize-malware-spread) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | +| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 851 | [喧闹和富有](../../problems/loud-and-rich) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 841 | [钥匙和房间](../../problems/keys-and-rooms) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 827 | [最大人工岛](../../problems/making-a-large-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 802 | [找到最终的安全状态](../../problems/find-eventual-safe-states) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 756 | [金字塔转换矩阵](../../problems/pyramid-transition-matrix) | [[位运算](../bit-manipulation/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 753 | [破解保险箱](../../problems/cracking-the-safe) | [[深度优先搜索](../depth-first-search/README.md)] [[数学](../math/README.md)] | Hard | +| 749 | [隔离病毒](../../problems/contain-virus) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 733 | [图像渲染](../../problems/flood-fill) | [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 721 | [账户合并](../../problems/accounts-merge) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 695 | [岛屿的最大面积](../../problems/max-area-of-island) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 679 | [24 点游戏](../../problems/24-game) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 664 | [奇怪的打印机](../../problems/strange-printer) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 638 | [大礼包](../../problems/shopping-offers) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 576 | [出界的路径数](../../problems/out-of-boundary-paths) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 559 | [N 叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 547 | [省份数量](../../problems/number-of-provinces) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 546 | [移除盒子](../../problems/remove-boxes) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 542 | [01 矩阵](../../problems/01-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 533 | [孤独像素 II](../../problems/lonely-pixel-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 531 | [孤独像素 I](../../problems/lonely-pixel-i) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 529 | [扫雷游戏](../../problems/minesweeper) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 526 | [优美的排列](../../problems/beautiful-arrangement) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 505 | [迷宫 II](../../problems/the-maze-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 499 | [迷宫 III](../../problems/the-maze-iii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 494 | [目标和](../../problems/target-sum) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 491 | [递增子序列](../../problems/increasing-subsequences) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 490 | [迷宫](../../problems/the-maze) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 489 | [扫地机器人](../../problems/robot-room-cleaner) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 488 | [祖玛游戏](../../problems/zuma-game) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 473 | [火柴拼正方形](../../problems/matchsticks-to-square) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 439 | [三元表达式解析器](../../problems/ternary-expression-parser) 🔒 | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 430 | [扁平化多级双向链表](../../problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 417 | [太平洋大西洋水流问题](../../problems/pacific-atlantic-water-flow) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 366 | [寻找二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 364 | [加权嵌套序列和 II](../../problems/nested-list-weight-sum-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 339 | [嵌套列表权重和](../../problems/nested-list-weight-sum) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | +| 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 301 | [删除无效的括号](../../problems/remove-invalid-parentheses) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | +| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 129 | [求根到叶子节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 100 | [相同的树](../../problems/same-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 99 | [恢复二叉搜索树](../../problems/recover-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index 1bbe3ca62..f50d33a44 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1756 | [Design Most Recently Used Queue](../../problems/design-most-recently-used-queue) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | | 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Easy | | 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | @@ -50,7 +51,7 @@ | 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 348 | [判定井字棋胜负](../../problems/design-tic-tac-toe) 🔒 | [[设计](../design/README.md)] | Medium | +| 348 | [设计井字棋](../../problems/design-tic-tac-toe) 🔒 | [[设计](../design/README.md)] | Medium | | 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | | 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | | 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index 9fcc476e7..22827330d 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1755 | [最接近目标值的子序列和](../../problems/closest-subsequence-sum) | [[分治算法](../divide-and-conquer/README.md)] | Hard | | 1274 | [矩形内船只的数目](../../problems/number-of-ships-in-a-rectangle) 🔒 | [[分治算法](../divide-and-conquer/README.md)] | Hard | | 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | | 932 | [漂亮数组](../../problems/beautiful-array) | [[分治算法](../divide-and-conquer/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 11f2f43fb..882b2c7e5 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,248 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1746 | [Maximum Subarray Sum After One Operation](../../problems/maximum-subarray-sum-after-one-operation) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1745 | [回文串分割 IV](../../problems/palindrome-partitioning-iv) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1728 | [猫和老鼠 II](../../problems/cat-and-mouse-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1724 | [检查边长度限制的路径是否存在 II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1706 | [球会落何处](../../problems/where-will-the-ball-fall) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1692 | [计算分配糖果的不同方式](../../problems/count-ways-to-distribute-candies) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1691 | [堆叠长方体的最大高度](../../problems/maximum-height-by-stacking-cuboids) | [[排序](../sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1690 | [石子游戏 VII](../../problems/stone-game-vii) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1682 | [最长回文子序列 II](../../problems/longest-palindromic-subsequence-ii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1671 | [得到山形数组的最少删除次数](../../problems/minimum-number-of-removals-to-make-mountain-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1664 | [生成平衡数组的方案数](../../problems/ways-to-make-a-fair-array) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1654 | [到家的最少跳跃次数](../../problems/minimum-jumps-to-reach-home) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1643 | [第 K 条最小指令](../../problems/kth-smallest-instructions) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1639 | [通过给定词典构造目标字符串的方案数](../../problems/number-of-ways-to-form-a-target-string-given-a-dictionary) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1626 | [无矛盾的最佳球队](../../problems/best-team-with-no-conflicts) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1621 | [大小为 K 的不重叠线段的数目](../../problems/number-of-sets-of-k-non-overlapping-line-segments) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1563 | [石子游戏 V](../../problems/stone-game-v) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1553 | [吃掉 N 个橘子的最少天数](../../problems/minimum-number-of-days-to-eat-n-oranges) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1548 | [图中最相似的路径](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1547 | [切棍子的最小成本](../../problems/minimum-cost-to-cut-a-stick) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1546 | [和为目标值的最大数目不重叠非空子数组数目](../../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1537 | [最大得分](../../problems/get-the-maximum-score) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1510 | [石子游戏 IV](../../problems/stone-game-iv) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1504 | [统计全 1 子矩形](../../problems/count-submatrices-with-all-ones) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1483 | [树节点的第 K 个祖先](../../problems/kth-ancestor-of-a-tree-node) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1477 | [找两个和为目标值且不重叠的子数组](../../problems/find-two-non-overlapping-sub-arrays-each-with-target-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1473 | [粉刷房子 III](../../problems/paint-house-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1463 | [摘樱桃 II](../../problems/cherry-pickup-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1458 | [两个子序列的最大点积](../../problems/max-dot-product-of-two-subsequences) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1444 | [切披萨的方案数](../../problems/number-of-ways-of-cutting-a-pizza) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1425 | [带限制的子序列和](../../problems/constrained-subsequence-sum) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1420 | [生成数组](../../problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1416 | [恢复数组](../../problems/restore-the-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1411 | [给 N x 3 网格图涂色的方案数](../../problems/number-of-ways-to-paint-n-x-3-grid) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1406 | [石子游戏 III](../../problems/stone-game-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1402 | [做菜顺序](../../problems/reducing-dishes) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1397 | [找到所有好字符串](../../problems/find-all-good-strings) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1388 | [3n 块披萨](../../problems/pizza-with-3n-slices) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1359 | [有效的快递序列数目](../../problems/count-all-valid-pickup-and-delivery-options) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1349 | [参加考试的最大学生数](../../problems/maximum-students-taking-exam) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1340 | [跳跃游戏 V](../../problems/jump-game-v) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1335 | [工作计划的最低难度](../../problems/minimum-difficulty-of-a-job-schedule) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1326 | [灌溉花园的最少水龙头数目](../../problems/minimum-number-of-taps-to-open-to-water-a-garden) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1320 | [二指输入的的最小距离](../../problems/minimum-distance-to-type-a-word-using-two-fingers) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1314 | [矩阵区域和](../../problems/matrix-block-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1312 | [让字符串成为回文串的最少插入次数](../../problems/minimum-insertion-steps-to-make-a-string-palindrome) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1301 | [最大得分的路径数目](../../problems/number-of-paths-with-max-score) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1289 | [下降路径最小和 II](../../problems/minimum-falling-path-sum-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1278 | [分割回文串 III](../../problems/palindrome-partitioning-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1277 | [统计全为 1 的正方形子矩阵](../../problems/count-square-submatrices-with-all-ones) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1273 | [删除树节点](../../problems/delete-tree-nodes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1269 | [停在原地的方案数](../../problems/number-of-ways-to-stay-in-the-same-place-after-some-steps) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1262 | [可被三整除的最大和](../../problems/greatest-sum-divisible-by-three) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1259 | [不相交的握手](../../problems/handshakes-that-dont-cross) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1246 | [删除回文子数组](../../problems/palindrome-removal) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1240 | [铺瓷砖](../../problems/tiling-a-rectangle-with-the-fewest-squares) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1230 | [抛掷硬币](../../problems/toss-strange-coins) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1223 | [掷骰子模拟](../../problems/dice-roll-simulation) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1220 | [统计元音字母序列的数目](../../problems/count-vowels-permutation) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1216 | [验证回文字符串 III](../../problems/valid-palindrome-iii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1199 | [建造街区的最短时间](../../problems/minimum-time-to-build-blocks) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1191 | [K 次串联后最大子数组之和](../../problems/k-concatenation-maximum-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1187 | [使数组严格递增](../../problems/make-array-strictly-increasing) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1186 | [删除一次得到子数组最大和](../../problems/maximum-subarray-sum-with-one-deletion) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1155 | [掷骰子的N种方法](../../problems/number-of-dice-rolls-with-target-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1147 | [段式回文](../../problems/longest-chunked-palindrome-decomposition) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1143 | [最长公共子序列](../../problems/longest-common-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1140 | [石子游戏 II](../../problems/stone-game-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1139 | [最大的以 1 为边界的正方形](../../problems/largest-1-bordered-square) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1125 | [最小的必要团队](../../problems/smallest-sufficient-team) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1105 | [填充书架](../../problems/filling-bookcase-shelves) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1092 | [最短公共超序列](../../problems/shortest-common-supersequence) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 1067 | [范围内的数字计数](../../problems/digit-count-in-range) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1055 | [形成字符串的最短路径](../../problems/shortest-way-to-form-string) 🔒 | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1049 | [最后一块石头的重量 II](../../problems/last-stone-weight-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1048 | [最长字符串链](../../problems/longest-string-chain) | [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1043 | [分隔数组以得到最大和](../../problems/partition-array-for-maximum-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1039 | [多边形三角剖分的最低得分](../../problems/minimum-score-triangulation-of-polygon) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1027 | [最长等差数列](../../problems/longest-arithmetic-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1025 | [除数博弈](../../problems/divisor-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 1024 | [视频拼接](../../problems/video-stitching) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1012 | [至少有 1 位重复的数字](../../problems/numbers-with-repeated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1000 | [合并石头的最低成本](../../problems/minimum-cost-to-merge-stones) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 983 | [最低票价](../../problems/minimum-cost-for-tickets) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 982 | [按位与为零的三元组](../../problems/triples-with-bitwise-and-equal-to-zero) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 964 | [表示数字的最少运算符](../../problems/least-operators-to-express-number) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 960 | [删列造序 III](../../problems/delete-columns-to-make-sorted-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 956 | [最高的广告牌](../../problems/tallest-billboard) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 943 | [最短超级串](../../problems/find-the-shortest-superstring) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 940 | [不同的子序列 II](../../problems/distinct-subsequences-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 935 | [骑士拨号器](../../problems/knight-dialer) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 931 | [下降路径最小和](../../problems/minimum-falling-path-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 920 | [播放列表的数量](../../problems/number-of-music-playlists) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 903 | [DI 序列的有效排列](../../problems/valid-permutations-for-di-sequence) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 902 | [最大为 N 的数字组合](../../problems/numbers-at-most-n-given-digit-set) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 898 | [子数组按位或操作](../../problems/bitwise-ors-of-subarrays) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 879 | [盈利计划](../../problems/profitable-schemes) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 877 | [石子游戏](../../problems/stone-game) | [[极小化极大](../minimax/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 871 | [最低加油次数](../../problems/minimum-number-of-refueling-stops) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 837 | [新21点](../../problems/new-21-game) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 818 | [赛车](../../problems/race-car) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 813 | [最大平均值和的分组](../../problems/largest-sum-of-averages) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 808 | [分汤](../../problems/soup-servings) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 801 | [使序列递增的最小交换次数](../../problems/minimum-swaps-to-make-sequences-increasing) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 799 | [香槟塔](../../problems/champagne-tower) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 790 | [多米诺和托米诺平铺](../../problems/domino-and-tromino-tiling) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 764 | [最大加号标志](../../problems/largest-plus-sign) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 750 | [角矩形的数量](../../problems/number-of-corner-rectangles) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 746 | [使用最小花费爬楼梯](../../problems/min-cost-climbing-stairs) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 741 | [摘樱桃](../../problems/cherry-pickup) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 740 | [删除与获得点数](../../problems/delete-and-earn) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 712 | [两个字符串的最小ASCII删除和](../../problems/minimum-ascii-delete-sum-for-two-strings) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 689 | [三个无重叠子数组的最大和](../../problems/maximum-sum-of-3-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 688 | [“马”在棋盘上的概率](../../problems/knight-probability-in-chessboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 673 | [最长递增子序列的个数](../../problems/number-of-longest-increasing-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 664 | [奇怪的打印机](../../problems/strange-printer) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 656 | [金币路径](../../problems/coin-path) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 651 | [4键键盘](../../problems/4-keys-keyboard) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 650 | [只有两个键的键盘](../../problems/2-keys-keyboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 647 | [回文子串](../../problems/palindromic-substrings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 646 | [最长数对链](../../problems/maximum-length-of-pair-chain) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 639 | [解码方法 2](../../problems/decode-ways-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 638 | [大礼包](../../problems/shopping-offers) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 629 | [K个逆序对数组](../../problems/k-inverse-pairs-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 600 | [不含连续1的非负整数](../../problems/non-negative-integers-without-consecutive-ones) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 576 | [出界的路径数](../../problems/out-of-boundary-paths) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 568 | [最大休假天数](../../problems/maximum-vacation-days) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 552 | [学生出勤记录 II](../../problems/student-attendance-record-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 546 | [移除盒子](../../problems/remove-boxes) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 523 | [连续的子数组和](../../problems/continuous-subarray-sum) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 517 | [超级洗衣机](../../problems/super-washing-machines) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 516 | [最长回文子序列](../../problems/longest-palindromic-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 494 | [目标和](../../problems/target-sum) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 486 | [预测赢家](../../problems/predict-the-winner) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 474 | [一和零](../../problems/ones-and-zeroes) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 471 | [编码最短长度的字符串](../../problems/encode-string-with-shortest-length) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 467 | [环绕字符串中唯一的子字符串](../../problems/unique-substrings-in-wraparound-string) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 466 | [统计重复个数](../../problems/count-the-repetitions) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 464 | [我能赢吗](../../problems/can-i-win) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 446 | [等差数列划分 II - 子序列](../../problems/arithmetic-slices-ii-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 416 | [分割等和子集](../../problems/partition-equal-subset-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 403 | [青蛙过河](../../problems/frog-jump) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 377 | [组合总和 Ⅳ](../../problems/combination-sum-iv) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 375 | [猜数字大小 II](../../problems/guess-number-higher-or-lower-ii) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 361 | [轰炸敌人](../../problems/bomb-enemy) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 354 | [俄罗斯套娃信封问题](../../problems/russian-doll-envelopes) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 351 | [安卓系统手势解锁](../../problems/android-unlock-patterns) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 343 | [整数拆分](../../problems/integer-break) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 322 | [零钱兑换](../../problems/coin-change) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 321 | [拼接最大数](../../problems/create-maximum-number) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 312 | [戳气球](../../problems/burst-balloons) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 309 | [最佳买卖股票时机含冷冻期](../../problems/best-time-to-buy-and-sell-stock-with-cooldown) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 304 | [二维区域和检索 - 矩阵不可变](../../problems/range-sum-query-2d-immutable) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 303 | [区域和检索 - 数组不可变](../../problems/range-sum-query-immutable) | [[动态规划](../dynamic-programming/README.md)] | Easy | -| 300 | [最长递增子序列](../../problems/longest-increasing-subsequence) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 276 | [栅栏涂色](../../problems/paint-fence) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Easy | -| 265 | [粉刷房子 II](../../problems/paint-house-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 256 | [粉刷房子](../../problems/paint-house) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 221 | [最大正方形](../../problems/maximal-square) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 213 | [打家劫舍 II](../../problems/house-robber-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 198 | [打家劫舍](../../problems/house-robber) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 188 | [买卖股票的最佳时机 IV](../../problems/best-time-to-buy-and-sell-stock-iv) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 174 | [地下城游戏](../../problems/dungeon-game) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 152 | [乘积最大子数组](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 140 | [单词拆分 II](../../problems/word-break-ii) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 139 | [单词拆分](../../problems/word-break) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 132 | [分割回文串 II](../../problems/palindrome-partitioning-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 123 | [买卖股票的最佳时机 III](../../problems/best-time-to-buy-and-sell-stock-iii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 121 | [买卖股票的最佳时机](../../problems/best-time-to-buy-and-sell-stock) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 120 | [三角形最小路径和](../../problems/triangle) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 115 | [不同的子序列](../../problems/distinct-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 91 | [解码方法](../../problems/decode-ways) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 87 | [扰乱字符串](../../problems/scramble-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 72 | [编辑距离](../../problems/edit-distance) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 70 | [爬楼梯](../../problems/climbing-stairs) | [[动态规划](../dynamic-programming/README.md)] | Easy | -| 64 | [最小路径和](../../problems/minimum-path-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 63 | [不同路径 II](../../problems/unique-paths-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 62 | [不同路径](../../problems/unique-paths) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 5 | [最长回文子串](../../problems/longest-palindromic-substring) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index 085448301..5a8521ed2 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -9,12 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard | -| 1515 | [服务中心的最佳位置](../../problems/best-position-for-a-service-centre) | [[几何](../geometry/README.md)] | Hard | -| 1453 | [圆形靶内的最大飞镖数量](../../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | [[几何](../geometry/README.md)] | Hard | -| 1401 | [圆和矩形是否有重叠](../../problems/circle-and-rectangle-overlapping) | [[几何](../geometry/README.md)] | Medium | -| 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] | Easy | -| 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | -| 892 | [三维形体的表面积](../../problems/surface-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | -| 587 | [安装栅栏](../../problems/erect-the-fence) | [[几何](../geometry/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index 1e8098532..3abb38b20 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,3 +9,56 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1765 | [地图中的最高点](../../problems/map-of-highest-peak) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1761 | [一个图中连通三元组的最小度数](../../problems/minimum-degree-of-a-connected-trio-in-a-graph) | [[图](../graph/README.md)] | Hard | +| 1730 | [获取食物的最短路径](../../problems/shortest-path-to-get-food) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1724 | [检查边长度限制的路径是否存在 II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] | Hard | +| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1615 | [最大网络秩](../../problems/maximal-network-rank) | [[图](../graph/README.md)] | Medium | +| 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1557 | [可以到达所有点的最少点数目](../../problems/minimum-number-of-vertices-to-reach-all-nodes) | [[图](../graph/README.md)] | Medium | +| 1548 | [图中最相似的路径](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] | Medium | +| 1494 | [并行课程 II](../../problems/parallel-courses-ii) | [[图](../graph/README.md)] | Hard | +| 1462 | [课程表 IV](../../problems/course-schedule-iv) | [[图](../graph/README.md)] | Medium | +| 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | +| 1361 | [验证二叉树](../../problems/validate-binary-tree-nodes) | [[图](../graph/README.md)] | Medium | +| 1334 | [阈值距离内邻居最少的城市](../../problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | [[图](../graph/README.md)] | Medium | +| 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | +| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1153 | [字符串转化](../../problems/string-transforms-into-another-string) 🔒 | [[图](../graph/README.md)] | Hard | +| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1135 | [最低成本联通所有城市](../../problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 1059 | [从始点到终点的所有路径](../../problems/all-paths-from-source-lead-to-destination) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[图](../graph/README.md)] | Medium | +| 997 | [找到小镇的法官](../../problems/find-the-town-judge) | [[图](../graph/README.md)] | Easy | +| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 990 | [等式方程的可满足性](../../problems/satisfiability-of-equality-equations) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 854 | [相似度为 K 的字符串](../../problems/k-similar-strings) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Hard | +| 841 | [钥匙和房间](../../problems/keys-and-rooms) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 802 | [找到最终的安全状态](../../problems/find-eventual-safe-states) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 684 | [冗余连接](../../problems/redundant-connection) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 444 | [序列重建](../../problems/sequence-reconstruction) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 399 | [除法求值](../../problems/evaluate-division) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 310 | [最小高度树](../../problems/minimum-height-trees) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index f55fc7e68..529ffe482 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,13 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1769 | [移动所有球到每个盒子所需的最小操作数](../../problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1764 | [通过连接另一个数组的子数组得到一个数组](../../problems/form-array-by-concatenating-subarrays-of-another-array) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1762 | [Buildings With an Ocean View](../../problems/buildings-with-an-ocean-view) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | +| 1759 | [统计同构子字符串的数目](../../problems/count-number-of-homogenous-substrings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1758 | [生成交替二进制字符串的最少操作数](../../problems/minimum-changes-to-make-alternating-binary-string) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 1754 | [构造字典序最大的合并字符串](../../problems/largest-merge-of-two-strings) | [[贪心算法](../greedy/README.md)] | Medium | +| 1749 | [任意子数组和的绝对值的最大值](../../problems/maximum-absolute-sum-of-any-subarray) | [[贪心算法](../greedy/README.md)] | Medium | | 1743 | [从相邻元素对还原数组](../../problems/restore-the-array-from-adjacent-pairs) | [[贪心算法](../greedy/README.md)] | Medium | | 1737 | [满足三条件之一需改变的最少字符数](../../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1736 | [替换隐藏数字得到的最晚时间](../../problems/latest-time-by-replacing-hidden-digits) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 1adf15714..f78d7bc25 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,3 +9,143 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1748 | [唯一元素的和](../../problems/sum-of-unique-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1726 | [同积元组](../../problems/tuple-with-same-product) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1679 | [K 和数对的最大数目](../../problems/max-number-of-k-sum-pairs) | [[哈希表](../hash-table/README.md)] | Medium | +| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1418 | [点菜展示表](../../problems/display-table-of-food-orders-in-a-restaurant) | [[哈希表](../hash-table/README.md)] | Medium | +| 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1224 | [最大相等频率](../../problems/maximum-equal-frequency) | [[哈希表](../hash-table/README.md)] | Hard | +| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1207 | [独一无二的出现次数](../../problems/unique-number-of-occurrences) | [[哈希表](../hash-table/README.md)] | Easy | +| 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1189 | [“气球” 的最大数量](../../problems/maximum-number-of-balloons) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1178 | [猜字谜](../../problems/number-of-valid-words-for-each-puzzle) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1160 | [拼写单词](../../problems/find-words-that-can-be-formed-by-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1138 | [字母板上的路径](../../problems/alphabet-board-path) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1133 | [最大唯一数](../../problems/largest-unique-number) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1078 | [Bigram 分词](../../problems/occurrences-after-bigram) | [[哈希表](../hash-table/README.md)] | Easy | +| 1072 | [按列翻转得到最大值等行数](../../problems/flip-columns-for-maximum-number-of-equal-rows) | [[哈希表](../hash-table/README.md)] | Medium | +| 1048 | [最长字符串链](../../problems/longest-string-chain) | [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1001 | [网格照明](../../problems/grid-illumination) | [[哈希表](../hash-table/README.md)] | Hard | +| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 974 | [和可被 K 整除的子数组](../../problems/subarray-sums-divisible-by-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 970 | [强整数](../../problems/powerful-integers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 961 | [重复 N 次的元素](../../problems/n-repeated-element-in-size-2n-array) | [[哈希表](../hash-table/README.md)] | Easy | +| 957 | [N 天后的牢房](../../problems/prison-cells-after-n-days) | [[哈希表](../hash-table/README.md)] | Medium | +| 954 | [二倍数对数组](../../problems/array-of-doubled-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 953 | [验证外星语词典](../../problems/verifying-an-alien-dictionary) | [[哈希表](../hash-table/README.md)] | Easy | +| 939 | [最小面积矩形](../../problems/minimum-area-rectangle) | [[哈希表](../hash-table/README.md)] | Medium | +| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 884 | [两句话中的不常见单词](../../problems/uncommon-words-from-two-sentences) | [[哈希表](../hash-table/README.md)] | Easy | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[哈希表](../hash-table/README.md)] | Easy | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 771 | [宝石与石头](../../problems/jewels-and-stones) | [[哈希表](../hash-table/README.md)] | Easy | +| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 760 | [找出变位映射](../../problems/find-anagram-mappings) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | +| 748 | [最短补全词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] | Easy | +| 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | +| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[堆](../heap/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 676 | [实现一个魔法字典](../../problems/implement-magic-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 648 | [单词替换](../../problems/replace-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 645 | [错误的集合](../../problems/set-mismatch) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 599 | [两个列表的最小索引总和](../../problems/minimum-index-sum-of-two-lists) | [[哈希表](../hash-table/README.md)] | Easy | +| 594 | [最长和谐子序列](../../problems/longest-harmonious-subsequence) | [[哈希表](../hash-table/README.md)] | Easy | +| 575 | [分糖果](../../problems/distribute-candies) | [[哈希表](../hash-table/README.md)] | Easy | +| 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 554 | [砖墙](../../problems/brick-wall) | [[哈希表](../hash-table/README.md)] | Medium | +| 535 | [TinyURL 的加密与解密](../../problems/encode-and-decode-tinyurl) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 525 | [连续数组](../../problems/contiguous-array) | [[哈希表](../hash-table/README.md)] | Medium | +| 508 | [出现次数最多的子树元素和](../../problems/most-frequent-subtree-sum) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 500 | [键盘行](../../problems/keyboard-row) | [[哈希表](../hash-table/README.md)] | Easy | +| 463 | [岛屿的周长](../../problems/island-perimeter) | [[哈希表](../hash-table/README.md)] | Easy | +| 454 | [四数相加 II](../../problems/4sum-ii) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 447 | [回旋镖的数量](../../problems/number-of-boomerangs) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 438 | [找到字符串中所有字母异位词](../../problems/find-all-anagrams-in-a-string) | [[哈希表](../hash-table/README.md)] | Medium | +| 409 | [最长回文串](../../problems/longest-palindrome) | [[哈希表](../hash-table/README.md)] | Easy | +| 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 356 | [直线镜像](../../problems/line-reflection) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 325 | [和等于 k 的最长子数组长度](../../problems/maximum-size-subarray-sum-equals-k) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | +| 311 | [稀疏矩阵的乘法](../../problems/sparse-matrix-multiplication) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | +| 299 | [猜数字游戏](../../problems/bulls-and-cows) | [[哈希表](../hash-table/README.md)] | Medium | +| 290 | [单词规律](../../problems/word-pattern) | [[哈希表](../hash-table/README.md)] | Easy | +| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 274 | [H 指数](../../problems/h-index) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 266 | [回文排列](../../problems/palindrome-permutation) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | +| 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 246 | [中心对称数](../../problems/strobogrammatic-number) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 242 | [有效的字母异位词](../../problems/valid-anagram) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 219 | [存在重复元素 II](../../problems/contains-duplicate-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 217 | [存在重复元素](../../problems/contains-duplicate) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 205 | [同构字符串](../../problems/isomorphic-strings) | [[哈希表](../hash-table/README.md)] | Easy | +| 204 | [计数质数](../../problems/count-primes) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 202 | [快乐数](../../problems/happy-number) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 187 | [重复的DNA序列](../../problems/repeated-dna-sequences) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 138 | [复制带随机指针的链表](../../problems/copy-list-with-random-pointer) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 136 | [只出现一次的数字](../../problems/single-number) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 37 | [解数独](../../problems/sudoku-solver) | [[哈希表](../hash-table/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 36 | [有效的数独](../../problems/valid-sudoku) | [[哈希表](../hash-table/README.md)] | Medium | +| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1 | [两数之和](../../problems/two-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/heap/README.md b/tag/heap/README.md index 4bf8bcc92..4a7028b71 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1760 | [袋子里最少数目的球](../../problems/minimum-limit-of-balls-in-a-bag) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1753 | [移除石子的最大得分](../../problems/maximum-score-from-removing-stones) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | | 1705 | [吃苹果的最大数目](../../problems/maximum-number-of-eaten-apples) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | | 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | | 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | @@ -35,7 +37,7 @@ | 502 | [IPO](../../problems/ipo) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | | 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 378 | [有序矩阵中第K小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 373 | [查找和最小的K对数字](../../problems/find-k-pairs-with-smallest-sums) | [[堆](../heap/README.md)] | Medium | | 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md index 932db1472..592ea3e0f 100644 --- a/tag/line-sweep/README.md +++ b/tag/line-sweep/README.md @@ -9,9 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | -| 391 | [完美矩形](../../problems/perfect-rectangle) | [[Line Sweep](../line-sweep/README.md)] | Hard | -| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index 8103f6eff..8642b2274 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -9,46 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1721 | [交换链表中的节点](../../problems/swapping-nodes-in-a-linked-list) | [[链表](../linked-list/README.md)] | Medium | -| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 1669 | [合并两个链表](../../problems/merge-in-between-linked-lists) | [[链表](../linked-list/README.md)] | Medium | -| 1634 | [求两个多项式链表的和](../../problems/add-two-polynomials-represented-as-linked-lists) 🔒 | [[链表](../linked-list/README.md)] | Medium | -| 1474 | [删除链表 M 个节点之后的 N 个节点](../../problems/delete-n-nodes-after-m-nodes-of-a-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Easy | -| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)] | Easy | -| 1171 | [从链表中删去总和值为零的连续节点](../../problems/remove-zero-sum-consecutive-nodes-from-linked-list) | [[链表](../linked-list/README.md)] | Medium | -| 1019 | [链表中的下一个更大节点](../../problems/next-greater-node-in-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 876 | [链表的中间结点](../../problems/middle-of-the-linked-list) | [[链表](../linked-list/README.md)] | Easy | -| 817 | [链表组件](../../problems/linked-list-components) | [[链表](../linked-list/README.md)] | Medium | -| 725 | [分隔链表](../../problems/split-linked-list-in-parts) | [[链表](../linked-list/README.md)] | Medium | -| 708 | [循环有序列表的插入](../../problems/insert-into-a-sorted-circular-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Medium | -| 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 445 | [两数相加 II](../../problems/add-two-numbers-ii) | [[链表](../linked-list/README.md)] | Medium | -| 430 | [扁平化多级双向链表](../../problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 328 | [奇偶链表](../../problems/odd-even-linked-list) | [[链表](../linked-list/README.md)] | Medium | -| 237 | [删除链表中的节点](../../problems/delete-node-in-a-linked-list) | [[链表](../linked-list/README.md)] | Easy | -| 234 | [回文链表](../../problems/palindrome-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 206 | [反转链表](../../problems/reverse-linked-list) | [[链表](../linked-list/README.md)] | Easy | -| 203 | [移除链表元素](../../problems/remove-linked-list-elements) | [[链表](../linked-list/README.md)] | Easy | -| 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[链表](../linked-list/README.md)] | Easy | -| 148 | [排序链表](../../problems/sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 143 | [重排链表](../../problems/reorder-list) | [[链表](../linked-list/README.md)] | Medium | -| 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 141 | [环形链表](../../problems/linked-list-cycle) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 138 | [复制带随机指针的链表](../../problems/copy-list-with-random-pointer) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 92 | [反转链表 II](../../problems/reverse-linked-list-ii) | [[链表](../linked-list/README.md)] | Medium | -| 86 | [分隔链表](../../problems/partition-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 83 | [删除排序链表中的重复元素](../../problems/remove-duplicates-from-sorted-list) | [[链表](../linked-list/README.md)] | Easy | -| 82 | [删除排序链表中的重复元素 II](../../problems/remove-duplicates-from-sorted-list-ii) | [[链表](../linked-list/README.md)] | Medium | -| 61 | [旋转链表](../../problems/rotate-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 25 | [K 个一组翻转链表](../../problems/reverse-nodes-in-k-group) | [[链表](../linked-list/README.md)] | Hard | -| 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Easy | -| 19 | [删除链表的倒数第 N 个结点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index fb0072c87..556dd37eb 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,3 +9,203 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | +| 1753 | [移除石子的最大得分](../../problems/maximum-score-from-removing-stones) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | +| 1744 | [你能在你最喜欢的那天吃到你最喜欢的糖果吗?](../../problems/can-you-eat-your-favorite-candy-on-your-favorite-day) | [[数学](../math/README.md)] | Medium | +| 1739 | [放置盒子](../../problems/building-boxes) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1735 | [生成乘积数组的方案数](../../problems/count-ways-to-make-array-with-product) | [[数学](../math/README.md)] | Hard | +| 1716 | [计算力扣银行的钱](../../problems/calculate-money-in-leetcode-bank) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Easy | +| 1685 | [有序数组中差绝对值之和](../../problems/sum-of-absolute-differences-in-a-sorted-array) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 1680 | [连接连续二进制数字](../../problems/concatenation-of-consecutive-binary-numbers) | [[数学](../math/README.md)] | Medium | +| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | +| 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1627 | [带阈值的图连通性](../../problems/graph-connectivity-with-threshold) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | +| 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard | +| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 1551 | [使数组中所有元素相等的最小操作数](../../problems/minimum-operations-to-make-array-equal) | [[数学](../math/README.md)] | Medium | +| 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1523 | [在区间范围内统计奇数数目](../../problems/count-odd-numbers-in-an-interval-range) | [[数学](../math/README.md)] | Easy | +| 1513 | [仅含 1 的子串数](../../problems/number-of-substrings-with-only-1s) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1492 | [n 的第 k 个因子](../../problems/the-kth-factor-of-n) | [[数学](../math/README.md)] | Medium | +| 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] | Medium | +| 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1427 | [字符串的左右移](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1390 | [四因数](../../problems/four-divisors) | [[数学](../math/README.md)] | Medium | +| 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1362 | [最接近的因数](../../problems/closest-divisors) | [[数学](../math/README.md)] | Medium | +| 1359 | [有效的快递序列数目](../../problems/count-all-valid-pickup-and-delivery-options) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1344 | [时钟指针的夹角](../../problems/angle-between-hands-of-a-clock) | [[数学](../math/README.md)] | Medium | +| 1330 | [翻转子数组得到最大的数组值](../../problems/reverse-subarray-to-maximize-array-value) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1323 | [6 和 9 组成的最大数字](../../problems/maximum-69-number) | [[数学](../math/README.md)] | Easy | +| 1317 | [将整数转换为两个无零整数的和](../../problems/convert-integer-to-the-sum-of-two-no-zero-integers) | [[数学](../math/README.md)] | Easy | +| 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1281 | [整数的各位积和之差](../../problems/subtract-the-product-and-sum-of-digits-of-an-integer) | [[数学](../math/README.md)] | Easy | +| 1276 | [不浪费原料的汉堡制作方案](../../problems/number-of-burgers-with-no-waste-of-ingredients) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1271 | [十六进制魔术数字](../../problems/hexspeak) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1259 | [不相交的握手](../../problems/handshakes-that-dont-cross) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1256 | [加密数字](../../problems/encode-number) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | +| 1253 | [重构 2 行二进制矩阵](../../problems/reconstruct-a-2-row-binary-matrix) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 1250 | [检查「好数组」](../../problems/check-if-it-is-a-good-array) | [[数学](../math/README.md)] | Hard | +| 1238 | [循环码排列](../../problems/circular-permutation-in-binary-representation) | [[数学](../math/README.md)] | Medium | +| 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1230 | [抛掷硬币](../../problems/toss-strange-coins) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1228 | [等差数列中缺失的数字](../../problems/missing-number-in-arithmetic-progression) 🔒 | [[数学](../math/README.md)] | Easy | +| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1217 | [玩筹码](../../problems/minimum-cost-to-move-chips-to-the-same-position) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1199 | [建造街区的最短时间](../../problems/minimum-time-to-build-blocks) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1183 | [矩阵中 1 的最大数量](../../problems/maximum-number-of-ones) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | +| 1180 | [统计只含单一字母的子串](../../problems/count-substrings-with-only-one-distinct-letter) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1175 | [质数排列](../../problems/prime-arrangements) | [[数学](../math/README.md)] | Easy | +| 1154 | [一年中的第几天](../../problems/day-of-the-year) | [[数学](../math/README.md)] | Easy | +| 1134 | [阿姆斯特朗数](../../problems/armstrong-number) 🔒 | [[数学](../math/README.md)] | Easy | +| 1131 | [绝对值表达式的最大值](../../problems/maximum-of-absolute-value-expression) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | +| 1121 | [将数组分成几个递增序列](../../problems/divide-array-into-increasing-sequences) 🔒 | [[数学](../math/README.md)] | Hard | +| 1109 | [航班预订统计](../../problems/corporate-flight-bookings) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1104 | [二叉树寻路](../../problems/path-in-zigzag-labelled-binary-tree) | [[树](../tree/README.md)] [[数学](../math/README.md)] | Medium | +| 1103 | [分糖果 II](../../problems/distribute-candies-to-people) | [[数学](../math/README.md)] | Easy | +| 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1088 | [易混淆数 II](../../problems/confusing-number-ii) 🔒 | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1073 | [负二进制数相加](../../problems/adding-two-negabinary-numbers) | [[数学](../math/README.md)] | Medium | +| 1067 | [范围内的数字计数](../../problems/digit-count-in-range) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1056 | [易混淆数](../../problems/confusing-number) 🔒 | [[数学](../math/README.md)] | Easy | +| 1041 | [困于环中的机器人](../../problems/robot-bounded-in-circle) | [[数学](../math/README.md)] | Medium | +| 1037 | [有效的回旋镖](../../problems/valid-boomerang) | [[数学](../math/README.md)] | Easy | +| 1025 | [除数博弈](../../problems/divisor-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 1017 | [负二进制转换](../../problems/convert-to-base-2) | [[数学](../math/README.md)] | Medium | +| 1015 | [可被 K 整除的最小整数](../../problems/smallest-integer-divisible-by-k) | [[数学](../math/README.md)] | Medium | +| 1012 | [至少有 1 位重复的数字](../../problems/numbers-with-repeated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1009 | [十进制整数的反码](../../problems/complement-of-base-10-integer) | [[数学](../math/README.md)] | Easy | +| 1006 | [笨阶乘](../../problems/clumsy-factorial) | [[数学](../math/README.md)] | Medium | +| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 991 | [坏了的计算器](../../problems/broken-calculator) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 976 | [三角形的最大周长](../../problems/largest-perimeter-triangle) | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Easy | +| 972 | [相等的有理数](../../problems/equal-rational-numbers) | [[数学](../math/README.md)] | Hard | +| 970 | [强整数](../../problems/powerful-integers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 964 | [表示数字的最少运算符](../../problems/least-operators-to-express-number) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | +| 952 | [按公因数计算最大组件大小](../../problems/largest-component-size-by-common-factor) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | +| 949 | [给定数字能组成的最大时间](../../problems/largest-time-for-given-digits) | [[数学](../math/README.md)] | Medium | +| 942 | [增减字符串匹配](../../problems/di-string-match) | [[数学](../math/README.md)] | Easy | +| 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 910 | [最小差值 II](../../problems/smallest-range-ii) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 908 | [最小差值 I](../../problems/smallest-range-i) | [[数学](../math/README.md)] | Easy | +| 906 | [超级回文数](../../problems/super-palindromes) | [[数学](../math/README.md)] | Hard | +| 902 | [最大为 N 的数字组合](../../problems/numbers-at-most-n-given-digit-set) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 892 | [三维形体的表面积](../../problems/surface-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | +| 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 885 | [螺旋矩阵 III](../../problems/spiral-matrix-iii) | [[数学](../math/README.md)] | Medium | +| 883 | [三维形体投影面积](../../problems/projection-area-of-3d-shapes) | [[数学](../math/README.md)] | Easy | +| 878 | [第 N 个神奇数字](../../problems/nth-magical-number) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 877 | [石子游戏](../../problems/stone-game) | [[极小化极大](../minimax/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 869 | [重新排序得到 2 的幂](../../problems/reordered-power-of-2) | [[数学](../math/README.md)] | Medium | +| 868 | [二进制间距](../../problems/binary-gap) | [[数学](../math/README.md)] | Easy | +| 866 | [回文素数](../../problems/prime-palindrome) | [[数学](../math/README.md)] | Medium | +| 858 | [镜面反射](../../problems/mirror-reflection) | [[数学](../math/README.md)] | Medium | +| 836 | [矩形重叠](../../problems/rectangle-overlap) | [[数学](../math/README.md)] | Easy | +| 829 | [连续整数求和](../../problems/consecutive-numbers-sum) | [[数学](../math/README.md)] | Hard | +| 812 | [最大三角形面积](../../problems/largest-triangle-area) | [[数学](../math/README.md)] | Easy | +| 810 | [黑板异或游戏](../../problems/chalkboard-xor-game) | [[数学](../math/README.md)] | Hard | +| 805 | [数组的均值分割](../../problems/split-array-with-same-average) | [[数学](../math/README.md)] | Hard | +| 800 | [相似 RGB 颜色](../../problems/similar-rgb-color) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 789 | [逃脱阻碍者](../../problems/escape-the-ghosts) | [[数学](../math/README.md)] | Medium | +| 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 780 | [到达终点](../../problems/reaching-points) | [[数学](../math/README.md)] | Hard | +| 775 | [全局倒置与局部倒置](../../problems/global-and-local-inversions) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 754 | [到达终点数字](../../problems/reach-a-number) | [[数学](../math/README.md)] | Medium | +| 753 | [破解保险箱](../../problems/cracking-the-safe) | [[深度优先搜索](../depth-first-search/README.md)] [[数学](../math/README.md)] | Hard | +| 728 | [自除数](../../problems/self-dividing-numbers) | [[数学](../math/README.md)] | Easy | +| 672 | [灯泡开关 Ⅱ](../../problems/bulb-switcher-ii) | [[数学](../math/README.md)] | Medium | +| 670 | [最大交换](../../problems/maximum-swap) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 660 | [移除 9](../../problems/remove-9) 🔒 | [[数学](../math/README.md)] | Hard | +| 651 | [4键键盘](../../problems/4-keys-keyboard) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 645 | [错误的集合](../../problems/set-mismatch) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 640 | [求解方程](../../problems/solve-the-equation) | [[数学](../math/README.md)] | Medium | +| 634 | [寻找数组的错位排列](../../problems/find-the-derangement-of-an-array) 🔒 | [[数学](../math/README.md)] | Medium | +| 633 | [平方数之和](../../problems/sum-of-square-numbers) | [[数学](../math/README.md)] | Medium | +| 628 | [三个数的最大乘积](../../problems/maximum-product-of-three-numbers) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 598 | [范围求和 II](../../problems/range-addition-ii) | [[数学](../math/README.md)] | Easy | +| 593 | [有效的正方形](../../problems/valid-square) | [[数学](../math/README.md)] | Medium | +| 592 | [分数加减运算](../../problems/fraction-addition-and-subtraction) | [[数学](../math/README.md)] | Medium | +| 573 | [松鼠模拟](../../problems/squirrel-simulation) 🔒 | [[数学](../math/README.md)] | Medium | +| 553 | [最优除法](../../problems/optimal-division) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 535 | [TinyURL 的加密与解密](../../problems/encode-and-decode-tinyurl) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 523 | [连续的子数组和](../../problems/continuous-subarray-sum) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 517 | [超级洗衣机](../../problems/super-washing-machines) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 507 | [完美数](../../problems/perfect-number) | [[数学](../math/README.md)] | Easy | +| 492 | [构造矩形](../../problems/construct-the-rectangle) | [[数学](../math/README.md)] | Easy | +| 483 | [最小好进制](../../problems/smallest-good-base) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | +| 469 | [凸多边形](../../problems/convex-polygon) 🔒 | [[数学](../math/README.md)] | Medium | +| 462 | [最少移动次数使数组元素相等 II](../../problems/minimum-moves-to-equal-array-elements-ii) | [[数学](../math/README.md)] | Medium | +| 458 | [可怜的小猪](../../problems/poor-pigs) | [[数学](../math/README.md)] | Hard | +| 453 | [最小操作次数使数组元素相等](../../problems/minimum-moves-to-equal-array-elements) | [[数学](../math/README.md)] | Easy | +| 447 | [回旋镖的数量](../../problems/number-of-boomerangs) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 441 | [排列硬币](../../problems/arranging-coins) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 423 | [从英文中重建数字](../../problems/reconstruct-original-digits-from-english) | [[数学](../math/README.md)] | Medium | +| 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 400 | [第 N 位数字](../../problems/nth-digit) | [[数学](../math/README.md)] | Medium | +| 397 | [整数替换](../../problems/integer-replacement) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | +| 396 | [旋转函数](../../problems/rotate-function) | [[数学](../math/README.md)] | Medium | +| 372 | [超级次方](../../problems/super-pow) | [[数学](../math/README.md)] | Medium | +| 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 367 | [有效的完全平方数](../../problems/valid-perfect-square) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 365 | [水壶问题](../../problems/water-and-jug-problem) | [[数学](../math/README.md)] | Medium | +| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 356 | [直线镜像](../../problems/line-reflection) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 343 | [整数拆分](../../problems/integer-break) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 335 | [路径交叉](../../problems/self-crossing) | [[数学](../math/README.md)] | Hard | +| 326 | [3的幂](../../problems/power-of-three) | [[数学](../math/README.md)] | Easy | +| 319 | [灯泡开关](../../problems/bulb-switcher) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Medium | +| 313 | [超级丑数](../../problems/super-ugly-number) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | +| 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | +| 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 268 | [丢失的数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 263 | [丑数](../../problems/ugly-number) | [[数学](../math/README.md)] | Easy | +| 258 | [各位相加](../../problems/add-digits) | [[数学](../math/README.md)] | Easy | +| 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | +| 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 246 | [中心对称数](../../problems/strobogrammatic-number) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 233 | [数字 1 的个数](../../problems/number-of-digit-one) | [[数学](../math/README.md)] | Hard | +| 231 | [2的幂](../../problems/power-of-two) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | +| 224 | [基本计算器](../../problems/basic-calculator) | [[栈](../stack/README.md)] [[数学](../math/README.md)] | Hard | +| 223 | [矩形面积](../../problems/rectangle-area) | [[数学](../math/README.md)] | Medium | +| 204 | [计数质数](../../problems/count-primes) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 202 | [快乐数](../../problems/happy-number) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 172 | [阶乘后的零](../../problems/factorial-trailing-zeroes) | [[数学](../math/README.md)] | Easy | +| 171 | [Excel表列序号](../../problems/excel-sheet-column-number) | [[数学](../math/README.md)] | Easy | +| 168 | [Excel表列名称](../../problems/excel-sheet-column-title) | [[数学](../math/README.md)] | Easy | +| 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 69 | [x 的平方根](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 67 | [二进制求和](../../problems/add-binary) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 65 | [有效数字](../../problems/valid-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 60 | [排列序列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 50 | [Pow(x, n)](../../problems/powx-n) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 29 | [两数相除](../../problems/divide-two-integers) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 9 | [回文数](../../problems/palindrome-number) | [[数学](../math/README.md)] | Easy | +| 8 | [字符串转换整数 (atoi)](../../problems/string-to-integer-atoi) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 7 | [整数反转](../../problems/reverse-integer) | [[数学](../math/README.md)] | Easy | +| 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/meet-in-the-middle/README.md b/tag/meet-in-the-middle/README.md new file mode 100644 index 000000000..dac9adc9e --- /dev/null +++ b/tag/meet-in-the-middle/README.md @@ -0,0 +1,11 @@ + + + + + + + +## [话题分类](../README.md) > + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index 85faedb8e..52afd5989 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -9,17 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | -| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 855 | [考场就座](../../problems/exam-room) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 846 | [一手顺子](../../problems/hand-of-straights) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 731 | [我的日程安排表 II](../../problems/my-calendar-ii) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 683 | [K 个关闭的灯泡](../../problems/k-empty-slots) 🔒 | [[Ordered Map](../ordered-map/README.md)] | Hard | -| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index 71e7795da..88fe0bfa0 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -19,3 +19,4 @@ | 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | | 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index cf753e23c..ad51289a2 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -37,6 +37,7 @@ | 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | | 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | | 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | | 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index bdf264168..b34d04e3d 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -9,3 +9,19 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[线段树](../segment-tree/README.md)] | Hard | +| 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | +| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | +| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 308 | [二维区域和检索 - 可变](../../problems/range-sum-query-2d-mutable) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Hard | +| 307 | [区域和检索 - 数组可修改](../../problems/range-sum-query-mutable) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Medium | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index 56d607bc2..fbbfc5182 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -9,30 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[排序](../sort/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1176 | [健身计划评估](../../problems/diet-plan-performance) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Easy | -| 1151 | [最少交换次数来组合所有的 1](../../problems/minimum-swaps-to-group-all-1s-together) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 1052 | [爱生气的书店老板](../../problems/grumpy-bookstore-owner) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1040 | [移动石子直到连续 II](../../problems/moving-stones-until-consecutive-ii) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[贪心算法](../greedy/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 480 | [滑动窗口中位数](../../problems/sliding-window-median) | [[Sliding Window](../sliding-window/README.md)] | Hard | -| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 395 | [至少有K个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index 3ae174849..49e4c7112 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,78 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1727 | [重新排列后的最大子矩阵](../../problems/largest-submatrix-with-rearrangements) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1710 | [卡车上的最大单元数](../../problems/maximum-units-on-a-truck) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | -| 1697 | [检查边长度限制的路径是否存在](../../problems/checking-existence-of-edge-length-limited-paths) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] | Hard | -| 1691 | [堆叠长方体的最大高度](../../problems/maximum-height-by-stacking-cuboids) | [[排序](../sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | -| 1647 | [字符频次唯一的最小删除次数](../../problems/minimum-deletions-to-make-character-frequencies-unique) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1637 | [两点之间不包含任何点的最宽垂直面积](../../problems/widest-vertical-area-between-two-points-containing-no-points) | [[排序](../sort/README.md)] | Medium | -| 1636 | [按照频率将数组升序排序](../../problems/sort-array-by-increasing-frequency) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1630 | [等差子数组](../../problems/arithmetic-subarrays) | [[排序](../sort/README.md)] | Medium | -| 1561 | [你可以获得的最大硬币数目](../../problems/maximum-number-of-coins-you-can-get) | [[排序](../sort/README.md)] | Medium | -| 1528 | [重新排列字符串](../../problems/shuffle-string) | [[排序](../sort/README.md)] | Easy | -| 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1502 | [判断能否形成等差数列](../../problems/can-make-arithmetic-progression-from-sequence) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[排序](../sort/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1491 | [去掉最低工资和最高工资后的工资平均值](../../problems/average-salary-excluding-the-minimum-and-maximum-salary) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1481 | [不同整数的最少数目](../../problems/least-number-of-unique-integers-after-k-removals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1471 | [数组中的 k 个最强值](../../problems/the-k-strongest-values-in-an-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | -| 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | -| 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Hard | -| 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | -| 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[排序](../sort/README.md)] [[位运算](../bit-manipulation/README.md)] | Easy | -| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | -| 1333 | [餐厅过滤器](../../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1329 | [将矩阵按对角线排序](../../problems/sort-the-matrix-diagonally) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[排序](../sort/README.md)] [[树](../tree/README.md)] | Medium | -| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1183 | [矩阵中 1 的最大数量](../../problems/maximum-number-of-ones) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | -| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1122 | [数组的相对排序](../../problems/relative-sort-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1057 | [校园自行车分配](../../problems/campus-bikes) 🔒 | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] | Medium | -| 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[排序](../sort/README.md)] | Easy | -| 976 | [三角形的最大周长](../../problems/largest-perimeter-triangle) | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Easy | -| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 969 | [煎饼排序](../../problems/pancake-sorting) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 922 | [按奇偶排序数组 II](../../problems/sort-array-by-parity-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 853 | [车队](../../problems/car-fleet) | [[排序](../sort/README.md)] | Medium | -| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | -| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Hard | -| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 324 | [摆动排序 II](../../problems/wiggle-sort-ii) | [[排序](../sort/README.md)] | Medium | -| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | -| 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 274 | [H 指数](../../problems/h-index) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 252 | [会议室](../../problems/meeting-rooms) 🔒 | [[排序](../sort/README.md)] | Easy | -| 242 | [有效的字母异位词](../../problems/valid-anagram) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | -| 179 | [最大数](../../problems/largest-number) | [[排序](../sort/README.md)] | Medium | -| 164 | [最大间距](../../problems/maximum-gap) | [[排序](../sort/README.md)] | Hard | -| 148 | [排序链表](../../problems/sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 57 | [插入区间](../../problems/insert-interval) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 56 | [合并区间](../../problems/merge-intervals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index dabd214b3..9549c364f 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,3 +9,222 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1768 | [交替合并字符串](../../problems/merge-strings-alternately) | [[字符串](../string/README.md)] | Easy | +| 1763 | [最长的美好子字符串](../../problems/longest-nice-substring) | [[字符串](../string/README.md)] | Easy | +| 1759 | [统计同构子字符串的数目](../../problems/count-number-of-homogenous-substrings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1745 | [回文串分割 IV](../../problems/palindrome-partitioning-iv) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1737 | [满足三条件之一需改变的最少字符数](../../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1736 | [替换隐藏数字得到的最晚时间](../../problems/latest-time-by-replacing-hidden-digits) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | +| 1704 | [判断字符串的两半是否相似](../../problems/determine-if-string-halves-are-alike) | [[字符串](../string/README.md)] | Easy | +| 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | +| 1694 | [重新格式化电话号码](../../problems/reformat-phone-number) | [[字符串](../string/README.md)] | Easy | +| 1684 | [统计一致字符串的数目](../../problems/count-the-number-of-consistent-strings) | [[字符串](../string/README.md)] | Easy | +| 1682 | [最长回文子序列 II](../../problems/longest-palindromic-subsequence-ii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1678 | [设计 Goal 解析器](../../problems/goal-parser-interpretation) | [[字符串](../string/README.md)] | Easy | +| 1668 | [最大重复子字符串](../../problems/maximum-repeating-substring) | [[字符串](../string/README.md)] | Easy | +| 1662 | [检查两个字符串数组是否相等](../../problems/check-if-two-string-arrays-are-equivalent) | [[字符串](../string/README.md)] | Easy | +| 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1624 | [两个相同字符之间的最长子字符串](../../problems/largest-substring-between-two-equal-characters) | [[字符串](../string/README.md)] | Easy | +| 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1614 | [括号的最大嵌套深度](../../problems/maximum-nesting-depth-of-the-parentheses) | [[字符串](../string/README.md)] | Easy | +| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | +| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Hard | +| 1592 | [重新排列单词间的空格](../../problems/rearrange-spaces-between-words) | [[字符串](../string/README.md)] | Easy | +| 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | +| 1576 | [替换所有的问号](../../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | [[字符串](../string/README.md)] | Easy | +| 1573 | [分割字符串的方案数](../../problems/number-of-ways-to-split-a-string) | [[字符串](../string/README.md)] | Medium | +| 1556 | [千位分隔数](../../problems/thousand-separator) | [[字符串](../string/README.md)] | Easy | +| 1545 | [找出第 N 个二进制字符串中的第 K 位](../../problems/find-kth-bit-in-nth-binary-string) | [[字符串](../string/README.md)] | Medium | +| 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | +| 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Hard | +| 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[字符串](../string/README.md)] | Medium | +| 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 1513 | [仅含 1 的子串数](../../problems/number-of-substrings-with-only-1s) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1507 | [转变日期格式](../../problems/reformat-date) | [[字符串](../string/README.md)] | Easy | +| 1496 | [判断路径是否相交](../../problems/path-crossing) | [[字符串](../string/README.md)] | Easy | +| 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1455 | [检查单词是否为句中其他单词的前缀](../../problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | [[字符串](../string/README.md)] | Easy | +| 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1446 | [连续字符](../../problems/consecutive-characters) | [[字符串](../string/README.md)] | Easy | +| 1436 | [旅行终点站](../../problems/destination-city) | [[字符串](../string/README.md)] | Easy | +| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1432 | [改变一个整数能得到的最大差值](../../problems/max-difference-you-can-get-from-changing-an-integer) | [[字符串](../string/README.md)] | Medium | +| 1422 | [分割字符串的最大得分](../../problems/maximum-score-after-splitting-a-string) | [[字符串](../string/README.md)] | Easy | +| 1419 | [数青蛙](../../problems/minimum-number-of-frogs-croaking) | [[字符串](../string/README.md)] | Medium | +| 1417 | [重新格式化字符串](../../problems/reformat-the-string) | [[字符串](../string/README.md)] | Easy | +| 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1408 | [数组中的字符串匹配](../../problems/string-matching-in-an-array) | [[字符串](../string/README.md)] | Easy | +| 1404 | [将二进制表示减到 1 的步骤数](../../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 1392 | [最长快乐前缀](../../problems/longest-happy-prefix) | [[字符串](../string/README.md)] | Hard | +| 1374 | [生成每种字符都是奇数个的字符串](../../problems/generate-a-string-with-characters-that-have-odd-counts) | [[字符串](../string/README.md)] | Easy | +| 1371 | [每个元音包含偶数次的最长子字符串](../../problems/find-the-longest-substring-containing-vowels-in-even-counts) | [[字符串](../string/README.md)] | Medium | +| 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | +| 1358 | [包含所有三种字符的子字符串数目](../../problems/number-of-substrings-containing-all-three-characters) | [[字符串](../string/README.md)] | Medium | +| 1347 | [制造字母异位词的最小步骤数](../../problems/minimum-number-of-steps-to-make-two-strings-anagram) | [[字符串](../string/README.md)] | Medium | +| 1332 | [删除回文子序列](../../problems/remove-palindromic-subsequences) | [[字符串](../string/README.md)] | Easy | +| 1328 | [破坏回文串](../../problems/break-a-palindrome) | [[字符串](../string/README.md)] | Medium | +| 1324 | [竖直打印单词](../../problems/print-words-vertically) | [[字符串](../string/README.md)] | Medium | +| 1316 | [不同的循环子字符串](../../problems/distinct-echo-substrings) | [[字符串](../string/README.md)] | Hard | +| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1309 | [解码字母到整数映射](../../problems/decrypt-string-from-alphabet-to-integer-mapping) | [[字符串](../string/README.md)] | Easy | +| 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 1271 | [十六进制魔术数字](../../problems/hexspeak) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1268 | [搜索推荐系统](../../problems/search-suggestions-system) | [[字符串](../string/README.md)] | Medium | +| 1249 | [移除无效的括号](../../problems/minimum-remove-to-make-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1247 | [交换字符使得字符串相同](../../problems/minimum-swaps-to-make-strings-equal) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1233 | [删除子文件夹](../../problems/remove-sub-folders-from-the-filesystem) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1221 | [分割平衡字符串](../../problems/split-a-string-in-balanced-strings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | +| 1216 | [验证回文字符串 III](../../problems/valid-palindrome-iii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1189 | [“气球” 的最大数量](../../problems/maximum-number-of-balloons) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1181 | [前后拼接](../../problems/before-and-after-puzzle) 🔒 | [[字符串](../string/README.md)] | Medium | +| 1180 | [统计只含单一字母的子串](../../problems/count-substrings-with-only-one-distinct-letter) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1177 | [构建回文串检测](../../problems/can-make-palindrome-from-substring) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1169 | [查询无效交易](../../problems/invalid-transactions) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1165 | [单行键盘](../../problems/single-row-keyboard) 🔒 | [[字符串](../string/README.md)] | Easy | +| 1163 | [按字典序排在最后的子串](../../problems/last-substring-in-lexicographical-order) | [[字符串](../string/README.md)] | Hard | +| 1156 | [单字符重复子串的最大长度](../../problems/swap-for-longest-repeated-character-substring) | [[字符串](../string/README.md)] | Medium | +| 1138 | [字母板上的路径](../../problems/alphabet-board-path) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1119 | [删去字符串中的元音](../../problems/remove-vowels-from-a-string) 🔒 | [[字符串](../string/README.md)] | Easy | +| 1108 | [IP 地址无效化](../../problems/defanging-an-ip-address) | [[字符串](../string/README.md)] | Easy | +| 1106 | [解析布尔表达式](../../problems/parsing-a-boolean-expression) | [[字符串](../string/README.md)] | Hard | +| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1096 | [花括号展开 II](../../problems/brace-expansion-ii) | [[字符串](../string/README.md)] | Hard | +| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1071 | [字符串的最大公因子](../../problems/greatest-common-divisor-of-strings) | [[字符串](../string/README.md)] | Easy | +| 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Easy | +| 1062 | [最长重复子串](../../problems/longest-repeating-substring) 🔒 | [[字符串](../string/README.md)] | Medium | +| 1023 | [驼峰式匹配](../../problems/camelcase-matching) | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | +| 1016 | [子串能表示从 1 到 N 数字的二进制串](../../problems/binary-string-with-substrings-representing-1-to-n) | [[字符串](../string/README.md)] | Medium | +| 1003 | [检查替换后的词是否有效](../../problems/check-if-word-is-valid-after-substitutions) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 937 | [重新排列日志文件](../../problems/reorder-data-in-log-files) | [[字符串](../string/README.md)] | Easy | +| 936 | [戳印序列](../../problems/stamping-the-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | +| 929 | [独特的电子邮件地址](../../problems/unique-email-addresses) | [[字符串](../string/README.md)] | Easy | +| 925 | [长按键入](../../problems/long-pressed-name) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 917 | [仅仅反转字母](../../problems/reverse-only-letters) | [[字符串](../string/README.md)] | Easy | +| 916 | [单词子集](../../problems/word-subsets) | [[字符串](../string/README.md)] | Medium | +| 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[字符串](../string/README.md)] | Easy | +| 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[字符串](../string/README.md)] | Medium | +| 859 | [亲密字符串](../../problems/buddy-strings) | [[字符串](../string/README.md)] | Easy | +| 856 | [括号的分数](../../problems/score-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 848 | [字母移位](../../problems/shifting-letters) | [[字符串](../string/README.md)] | Medium | +| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 833 | [字符串中的查找与替换](../../problems/find-and-replace-in-string) | [[字符串](../string/README.md)] | Medium | +| 831 | [隐藏个人信息](../../problems/masking-personal-information) | [[字符串](../string/README.md)] | Medium | +| 824 | [山羊拉丁文](../../problems/goat-latin) | [[字符串](../string/README.md)] | Easy | +| 819 | [最常见的单词](../../problems/most-common-word) | [[字符串](../string/README.md)] | Easy | +| 816 | [模糊坐标](../../problems/ambiguous-coordinates) | [[字符串](../string/README.md)] | Medium | +| 809 | [情感丰富的文字](../../problems/expressive-words) | [[字符串](../string/README.md)] | Medium | +| 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[字符串](../string/README.md)] | Easy | +| 800 | [相似 RGB 颜色](../../problems/similar-rgb-color) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 791 | [自定义字符串排序](../../problems/custom-sort-string) | [[字符串](../string/README.md)] | Medium | +| 788 | [旋转数字](../../problems/rotated-digits) | [[字符串](../string/README.md)] | Easy | +| 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | +| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | +| 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字符串](../string/README.md)] | Easy | +| 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[字符串](../string/README.md)] | Hard | +| 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 722 | [删除注释](../../problems/remove-comments) | [[字符串](../string/README.md)] | Medium | +| 709 | [转换成小写字母](../../problems/to-lower-case) | [[字符串](../string/README.md)] | Easy | +| 696 | [计数二进制子串](../../problems/count-binary-substrings) | [[字符串](../string/README.md)] | Easy | +| 686 | [重复叠加字符串匹配](../../problems/repeated-string-match) | [[字符串](../string/README.md)] | Medium | +| 681 | [最近时刻](../../problems/next-closest-time) 🔒 | [[字符串](../string/README.md)] | Medium | +| 680 | [验证回文字符串 Ⅱ](../../problems/valid-palindrome-ii) | [[字符串](../string/README.md)] | Easy | +| 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[字符串](../string/README.md)] | Medium | +| 657 | [机器人能否返回原点](../../problems/robot-return-to-origin) | [[字符串](../string/README.md)] | Easy | +| 647 | [回文子串](../../problems/palindromic-substrings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | +| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 616 | [给字符串添加加粗标签](../../problems/add-bold-tag-in-string) 🔒 | [[字符串](../string/README.md)] | Medium | +| 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 606 | [根据二叉树创建字符串](../../problems/construct-string-from-binary-tree) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Easy | +| 591 | [标签验证器](../../problems/tag-validator) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | +| 583 | [两个字符串的删除操作](../../problems/delete-operation-for-two-strings) | [[字符串](../string/README.md)] | Medium | +| 564 | [寻找最近的回文数](../../problems/find-the-closest-palindrome) | [[字符串](../string/README.md)] | Hard | +| 557 | [反转字符串中的单词 III](../../problems/reverse-words-in-a-string-iii) | [[字符串](../string/README.md)] | Easy | +| 556 | [下一个更大元素 III](../../problems/next-greater-element-iii) | [[字符串](../string/README.md)] | Medium | +| 555 | [分割连接字符串](../../problems/split-concatenated-strings) 🔒 | [[字符串](../string/README.md)] | Medium | +| 553 | [最优除法](../../problems/optimal-division) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 551 | [学生出勤记录 I](../../problems/student-attendance-record-i) | [[字符串](../string/README.md)] | Easy | +| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | +| 541 | [反转字符串 II](../../problems/reverse-string-ii) | [[字符串](../string/README.md)] | Easy | +| 539 | [最小时间差](../../problems/minimum-time-difference) | [[字符串](../string/README.md)] | Medium | +| 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | +| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Hard | +| 522 | [最长特殊序列 II](../../problems/longest-uncommon-subsequence-ii) | [[字符串](../string/README.md)] | Medium | +| 521 | [最长特殊序列 Ⅰ](../../problems/longest-uncommon-subsequence-i) | [[脑筋急转弯](../brainteaser/README.md)] [[字符串](../string/README.md)] | Easy | +| 520 | [检测大写字母](../../problems/detect-capital) | [[字符串](../string/README.md)] | Easy | +| 468 | [验证IP地址](../../problems/validate-ip-address) | [[字符串](../string/README.md)] | Medium | +| 459 | [重复的子字符串](../../problems/repeated-substring-pattern) | [[字符串](../string/README.md)] | Easy | +| 443 | [压缩字符串](../../problems/string-compression) | [[字符串](../string/README.md)] | Medium | +| 434 | [字符串中的单词数](../../problems/number-of-segments-in-a-string) | [[字符串](../string/README.md)] | Easy | +| 415 | [字符串相加](../../problems/add-strings) | [[字符串](../string/README.md)] | Easy | +| 408 | [有效单词缩写](../../problems/valid-word-abbreviation) 🔒 | [[字符串](../string/README.md)] | Easy | +| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 385 | [迷你语法分析器](../../problems/mini-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 383 | [赎金信](../../problems/ransom-note) | [[字符串](../string/README.md)] | Easy | +| 345 | [反转字符串中的元音字母](../../problems/reverse-vowels-of-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 344 | [反转字符串](../../problems/reverse-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 293 | [翻转游戏](../../problems/flip-game) 🔒 | [[字符串](../string/README.md)] | Easy | +| 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 271 | [字符串的编码与解码](../../problems/encode-and-decode-strings) 🔒 | [[字符串](../string/README.md)] | Medium | +| 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 214 | [最短回文串](../../problems/shortest-palindrome) | [[字符串](../string/README.md)] | Hard | +| 186 | [翻转字符串里的单词 II](../../problems/reverse-words-in-a-string-ii) 🔒 | [[字符串](../string/README.md)] | Medium | +| 165 | [比较版本号](../../problems/compare-version-numbers) | [[字符串](../string/README.md)] | Medium | +| 161 | [相隔为 1 的编辑距离](../../problems/one-edit-distance) 🔒 | [[字符串](../string/README.md)] | Medium | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 158 | [用 Read4 读取 N 个字符 II](../../problems/read-n-characters-given-read4-ii-call-multiple-times) 🔒 | [[字符串](../string/README.md)] | Hard | +| 157 | [用 Read4 读取 N 个字符](../../problems/read-n-characters-given-read4) 🔒 | [[字符串](../string/README.md)] | Easy | +| 151 | [翻转字符串里的单词](../../problems/reverse-words-in-a-string) | [[字符串](../string/README.md)] | Medium | +| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 125 | [验证回文串](../../problems/valid-palindrome) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 115 | [不同的子序列](../../problems/distinct-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 93 | [复原 IP 地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 91 | [解码方法](../../problems/decode-ways) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 87 | [扰乱字符串](../../problems/scramble-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 72 | [编辑距离](../../problems/edit-distance) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 71 | [简化路径](../../problems/simplify-path) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 68 | [文本左右对齐](../../problems/text-justification) | [[字符串](../string/README.md)] | Hard | +| 67 | [二进制求和](../../problems/add-binary) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 65 | [有效数字](../../problems/valid-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 58 | [最后一个单词的长度](../../problems/length-of-last-word) | [[字符串](../string/README.md)] | Easy | +| 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 38 | [外观数列](../../problems/count-and-say) | [[字符串](../string/README.md)] | Easy | +| 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 20 | [有效的括号](../../problems/valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | +| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 14 | [最长公共前缀](../../problems/longest-common-prefix) | [[字符串](../string/README.md)] | Easy | +| 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 8 | [字符串转换整数 (atoi)](../../problems/string-to-integer-atoi) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 6 | [Z 字形变换](../../problems/zigzag-conversion) | [[字符串](../string/README.md)] | Medium | +| 5 | [最长回文子串](../../problems/longest-palindromic-substring) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/tags.json b/tag/tags.json index 4ca263579..3938e0e01 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -199,6 +199,11 @@ "Slug": "reservoir-sampling", "TranslatedName": "蓄水池抽样" }, + { + "Name": "", + "Slug": "meet-in-the-middle", + "TranslatedName": "" + }, { "Name": "Memoization", "Slug": "memoization", diff --git a/tag/tree/README.md b/tag/tree/README.md index cf7af3ead..b7e90ec33 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | | 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] | Hard | | 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | @@ -86,7 +87,7 @@ | 684 | [冗余连接](../../problems/redundant-connection) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 671 | [二叉树中第二小的节点](../../problems/second-minimum-node-in-a-binary-tree) | [[树](../tree/README.md)] | Easy | | 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 666 | [路径和 IV](../../problems/path-sum-iv) 🔒 | [[树](../tree/README.md)] | Medium | +| 666 | [路径总和 IV](../../problems/path-sum-iv) 🔒 | [[树](../tree/README.md)] | Medium | | 663 | [均匀树划分](../../problems/equal-tree-partition) 🔒 | [[树](../tree/README.md)] | Medium | | 662 | [二叉树最大宽度](../../problems/maximum-width-of-binary-tree) | [[树](../tree/README.md)] | Medium | | 655 | [输出二叉树](../../problems/print-binary-tree) | [[树](../tree/README.md)] | Medium | @@ -138,7 +139,7 @@ | 230 | [二叉搜索树中第K小的元素](../../problems/kth-smallest-element-in-a-bst) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 226 | [翻转二叉树](../../problems/invert-binary-tree) | [[树](../tree/README.md)] | Easy | | 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 156 | [上下翻转二叉树](../../problems/binary-tree-upside-down) 🔒 | [[树](../tree/README.md)] | Medium | | 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | @@ -153,7 +154,7 @@ | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index e14c8fe4e..461770ab9 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1750 | [删除字符串两端相同字符后的最短长度](../../problems/minimum-length-of-string-after-deleting-similar-ends) | [[双指针](../two-pointers/README.md)] | Medium | | 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1695 | [删除子数组的最大得分](../../problems/maximum-erasure-value) | [[双指针](../two-pointers/README.md)] | Medium | From 32e298b1177a4bff770804564ccad1b7fbe4967e Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 24 Feb 2021 16:25:15 +0800 Subject: [PATCH 120/145] A: tag --- .../README.md | 2 +- tag/README.md | 6 +- tag/array/README.md | 310 ++++++++++++++++++ tag/dequeue/README.md | 2 +- tag/dynamic-programming/README.md | 248 ++++++++++++++ tag/geometry/README.md | 9 + tag/line-sweep/README.md | 6 + tag/linked-list/README.md | 43 +++ tag/meet-in-the-middle/README.md | 2 +- tag/oop/README.md | 2 +- tag/ordered-map/README.md | 14 + tag/sliding-window/README.md | 27 ++ tag/sort/README.md | 75 +++++ tag/tags.json | 12 +- 14 files changed, 745 insertions(+), 13 deletions(-) diff --git a/problems/average-of-levels-in-binary-tree/README.md b/problems/average-of-levels-in-binary-tree/README.md index 14a2b4973..da85b7d73 100644 --- a/problems/average-of-levels-in-binary-tree/README.md +++ b/problems/average-of-levels-in-binary-tree/README.md @@ -38,4 +38,4 @@ The average value of nodes on level 0 is 3, on level 1 is 14.5, and on level 2 ### Similar Questions 1. [Binary Tree Level Order Traversal](../binary-tree-level-order-traversal) (Medium) - 1. [Binary Tree Level Order Traversal II](../binary-tree-level-order-traversal-ii) (Easy) + 1. [Binary Tree Level Order Traversal II](../binary-tree-level-order-traversal-ii) (Medium) diff --git a/tag/README.md b/tag/README.md index d5c45a064..a81c4006c 100644 --- a/tag/README.md +++ b/tag/README.md @@ -26,8 +26,8 @@ | 29 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 31 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 32 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | | 33 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 34 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | -| 35 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [](dequeue/README.md) | [](https://openset.github.io/tags/dequeue/) | +| 35 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [Dequeue](dequeue/README.md) | [Dequeue](https://openset.github.io/tags/dequeue/) | | 37 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | | 38 | [Suffix Array](suffix-array/README.md) | [Suffix Array](https://openset.github.io/tags/suffix-array/) | | 39 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | | 40 | [Reservoir Sampling](reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | -| 41 | [](meet-in-the-middle/README.md) | [](https://openset.github.io/tags/meet-in-the-middle/) | | 42 | [Memoization](memoization/README.md) | [记忆化](https://openset.github.io/tags/memoization/) | -| 43 | [](oop/README.md) | [](https://openset.github.io/tags/oop/) | \ No newline at end of file +| 41 | [Meet In The Middle](meet-in-the-middle/README.md) | [Meet In The Middle](https://openset.github.io/tags/meet-in-the-middle/) | | 42 | [Memoization](memoization/README.md) | [记忆化](https://openset.github.io/tags/memoization/) | +| 43 | [OOP](oop/README.md) | [OOP](https://openset.github.io/tags/oop/) | \ No newline at end of file diff --git a/tag/array/README.md b/tag/array/README.md index b22899942..f39e14f91 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,3 +9,313 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1769 | [移动所有球到每个盒子所需的最小操作数](../../problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1764 | [通过连接另一个数组的子数组得到一个数组](../../problems/form-array-by-concatenating-subarrays-of-another-array) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1758 | [生成交替二进制字符串的最少操作数](../../problems/minimum-changes-to-make-alternating-binary-string) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 1756 | [Design Most Recently Used Queue](../../problems/design-most-recently-used-queue) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1752 | [检查数组是否经排序和轮转得到](../../problems/check-if-array-is-sorted-and-rotated) | [[数组](../array/README.md)] | Easy | +| 1748 | [唯一元素的和](../../problems/sum-of-unique-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1742 | [盒子中小球的最大数量](../../problems/maximum-number-of-balls-in-a-box) | [[数组](../array/README.md)] | Easy | +| 1738 | [找出第 K 大的异或坐标值](../../problems/find-kth-largest-xor-coordinate-value) | [[数组](../array/README.md)] | Medium | +| 1733 | [需要教语言的最少人数](../../problems/minimum-number-of-people-to-teach) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1732 | [找到最高海拔](../../problems/find-the-highest-altitude) | [[数组](../array/README.md)] | Easy | +| 1726 | [同积元组](../../problems/tuple-with-same-product) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1708 | [长度为 K 的最大子数组](../../problems/largest-subarray-length-k) 🔒 | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 1701 | [平均等待时间](../../problems/average-waiting-time) | [[数组](../array/README.md)] | Medium | +| 1700 | [无法吃午餐的学生数量](../../problems/number-of-students-unable-to-eat-lunch) | [[数组](../array/README.md)] | Easy | +| 1672 | [最富有客户的资产总量](../../problems/richest-customer-wealth) | [[数组](../array/README.md)] | Easy | +| 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Easy | +| 1652 | [拆炸弹](../../problems/defuse-the-bomb) | [[数组](../array/README.md)] | Easy | +| 1646 | [获取生成数组中的最大值](../../problems/get-maximum-in-generated-array) | [[数组](../array/README.md)] | Easy | +| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1636 | [按照频率将数组升序排序](../../problems/sort-array-by-increasing-frequency) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 1629 | [按键持续时间最长的键](../../problems/slowest-key) | [[数组](../array/README.md)] | Easy | +| 1619 | [删除某些元素后的数组均值](../../problems/mean-of-array-after-removing-some-elements) | [[数组](../array/README.md)] | Easy | +| 1608 | [特殊数组的特征值](../../problems/special-array-with-x-elements-greater-than-or-equal-x) | [[数组](../array/README.md)] | Easy | +| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1588 | [所有奇数长度子数组的和](../../problems/sum-of-all-odd-length-subarrays) | [[数组](../array/README.md)] | Easy | +| 1583 | [统计不开心的朋友](../../problems/count-unhappy-friends) | [[数组](../array/README.md)] | Medium | +| 1582 | [二进制矩阵中的特殊位置](../../problems/special-positions-in-a-binary-matrix) | [[数组](../array/README.md)] | Easy | +| 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1572 | [矩阵对角线元素的和](../../problems/matrix-diagonal-sum) | [[数组](../array/README.md)] | Easy | +| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1566 | [重复至少 K 次且长度为 M 的模式](../../problems/detect-pattern-of-length-m-repeated-k-or-more-times) | [[数组](../array/README.md)] | Easy | +| 1560 | [圆形赛道上经过次数最多的扇区](../../problems/most-visited-sector-in-a-circular-track) | [[数组](../array/README.md)] | Easy | +| 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1550 | [存在连续三个奇数的数组](../../problems/three-consecutive-odds) | [[数组](../array/README.md)] | Easy | +| 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1535 | [找出数组游戏的赢家](../../problems/find-the-winner-of-an-array-game) | [[数组](../array/README.md)] | Medium | +| 1534 | [统计好三元组](../../problems/count-good-triplets) | [[数组](../array/README.md)] | Easy | +| 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1503 | [所有蚂蚁掉下来前的最后一刻](../../problems/last-moment-before-all-ants-fall-out-of-a-plank) | [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] | Medium | +| 1502 | [判断能否形成等差数列](../../problems/can-make-arithmetic-progression-from-sequence) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1493 | [删掉一个元素以后全为 1 的最长子数组](../../problems/longest-subarray-of-1s-after-deleting-one-element) | [[数组](../array/README.md)] | Medium | +| 1491 | [去掉最低工资和最高工资后的工资平均值](../../problems/average-salary-excluding-the-minimum-and-maximum-salary) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1486 | [数组异或操作](../../problems/xor-operation-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | +| 1482 | [制作 m 束花所需的最少天数](../../problems/minimum-number-of-days-to-make-m-bouquets) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1481 | [不同整数的最少数目](../../problems/least-number-of-unique-integers-after-k-removals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1480 | [一维数组的动态和](../../problems/running-sum-of-1d-array) | [[数组](../array/README.md)] | Easy | +| 1476 | [子矩形查询](../../problems/subrectangle-queries) | [[数组](../array/README.md)] | Medium | +| 1475 | [商品折扣后的最终价格](../../problems/final-prices-with-a-special-discount-in-a-shop) | [[数组](../array/README.md)] | Easy | +| 1471 | [数组中的 k 个最强值](../../problems/the-k-strongest-values-in-an-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1470 | [重新排列数组](../../problems/shuffle-the-array) | [[数组](../array/README.md)] | Easy | +| 1465 | [切割后面积最大的蛋糕](../../problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts) | [[数组](../array/README.md)] | Medium | +| 1464 | [数组中两元素的最大乘积](../../problems/maximum-product-of-two-elements-in-an-array) | [[数组](../array/README.md)] | Easy | +| 1460 | [通过翻转子数组使两个数组相等](../../problems/make-two-arrays-equal-by-reversing-sub-arrays) | [[数组](../array/README.md)] | Easy | +| 1450 | [在既定时间做作业的学生人数](../../problems/number-of-students-doing-homework-at-a-given-time) | [[数组](../array/README.md)] | Easy | +| 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1437 | [是否所有 1 都至少相隔 k 个元素](../../problems/check-if-all-1s-are-at-least-length-k-places-away) | [[数组](../array/README.md)] | Easy | +| 1431 | [拥有最多糖果的孩子](../../problems/kids-with-the-greatest-number-of-candies) | [[数组](../array/README.md)] | Easy | +| 1428 | [至少有一个 1 的最左端列](../../problems/leftmost-column-with-at-least-a-one) 🔒 | [[数组](../array/README.md)] | Medium | +| 1427 | [字符串的左右移](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1426 | [数元素](../../problems/counting-elements) 🔒 | [[数组](../array/README.md)] | Easy | +| 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1414 | [和为 K 的最少斐波那契数字数目](../../problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1413 | [逐步求和得到正数的最小值](../../problems/minimum-value-to-get-positive-step-by-step-sum) | [[数组](../array/README.md)] | Easy | +| 1409 | [查询带键的排列](../../problems/queries-on-a-permutation-with-key) | [[数组](../array/README.md)] | Medium | +| 1399 | [统计最大组的数目](../../problems/count-largest-group) | [[数组](../array/README.md)] | Easy | +| 1395 | [统计作战单位数](../../problems/count-number-of-teams) | [[数组](../array/README.md)] | Medium | +| 1394 | [找出数组中的幸运数](../../problems/find-lucky-integer-in-an-array) | [[数组](../array/README.md)] | Easy | +| 1389 | [按既定顺序创建目标数组](../../problems/create-target-array-in-the-given-order) | [[数组](../array/README.md)] | Easy | +| 1386 | [安排电影院座位](../../problems/cinema-seat-allocation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1385 | [两个数组间的距离值](../../problems/find-the-distance-value-between-two-arrays) | [[数组](../array/README.md)] | Easy | +| 1380 | [矩阵中的幸运数](../../problems/lucky-numbers-in-a-matrix) | [[数组](../array/README.md)] | Easy | +| 1375 | [灯泡开关 III](../../problems/bulb-switcher-iii) | [[数组](../array/README.md)] | Medium | +| 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1346 | [检查整数及其两倍数是否存在](../../problems/check-if-n-and-its-double-exist) | [[数组](../array/README.md)] | Easy | +| 1343 | [大小为 K 且平均值大于等于阈值的子数组数目](../../problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold) | [[数组](../array/README.md)] | Medium | +| 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1337 | [矩阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1333 | [餐厅过滤器](../../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1331 | [数组序号转换](../../problems/rank-transform-of-an-array) | [[数组](../array/README.md)] | Easy | +| 1330 | [翻转子数组得到最大的数组值](../../problems/reverse-subarray-to-maximize-array-value) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1329 | [将矩阵按对角线排序](../../problems/sort-the-matrix-diagonally) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1313 | [解压缩编码列表](../../problems/decompress-run-length-encoded-list) | [[数组](../array/README.md)] | Easy | +| 1304 | [和为零的N个唯一整数](../../problems/find-n-unique-integers-sum-up-to-zero) | [[数组](../array/README.md)] | Easy | +| 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1299 | [将每个元素替换为右侧最大元素](../../problems/replace-elements-with-greatest-element-on-right-side) | [[数组](../array/README.md)] | Easy | +| 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1295 | [统计位数为偶数的数字](../../problems/find-numbers-with-even-number-of-digits) | [[数组](../array/README.md)] | Easy | +| 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1287 | [有序数组中出现次数超过25%的元素](../../problems/element-appearing-more-than-25-in-sorted-array) | [[数组](../array/README.md)] | Easy | +| 1277 | [统计全为 1 的正方形子矩阵](../../problems/count-square-submatrices-with-all-ones) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1275 | [找出井字棋的获胜者](../../problems/find-winner-on-a-tic-tac-toe-game) | [[数组](../array/README.md)] | Easy | +| 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | +| 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] | Easy | +| 1260 | [二维网格迁移](../../problems/shift-2d-grid) | [[数组](../array/README.md)] | Easy | +| 1252 | [奇数值单元格的数目](../../problems/cells-with-odd-values-in-a-matrix) | [[数组](../array/README.md)] | Easy | +| 1243 | [数组变换](../../problems/array-transformation) 🔒 | [[数组](../array/README.md)] | Easy | +| 1233 | [删除子文件夹](../../problems/remove-sub-folders-from-the-filesystem) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1222 | [可以攻击国王的皇后](../../problems/queens-that-can-attack-the-king) | [[数组](../array/README.md)] | Medium | +| 1217 | [玩筹码](../../problems/minimum-cost-to-move-chips-to-the-same-position) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | +| 1200 | [最小绝对差](../../problems/minimum-absolute-difference) | [[数组](../array/README.md)] | Easy | +| 1185 | [一周中的第几天](../../problems/day-of-the-week) | [[数组](../array/README.md)] | Easy | +| 1184 | [公交站间的距离](../../problems/distance-between-bus-stops) | [[数组](../array/README.md)] | Easy | +| 1177 | [构建回文串检测](../../problems/can-make-palindrome-from-substring) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1176 | [健身计划评估](../../problems/diet-plan-performance) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Easy | +| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1169 | [查询无效交易](../../problems/invalid-transactions) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1160 | [拼写单词](../../problems/find-words-that-can-be-formed-by-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1151 | [最少交换次数来组合所有的 1](../../problems/minimum-swaps-to-group-all-1s-together) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1150 | [检查一个数是否在数组中占绝大多数](../../problems/check-if-a-number-is-majority-element-in-a-sorted-array) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1146 | [快照数组](../../problems/snapshot-array) | [[数组](../array/README.md)] | Medium | +| 1144 | [递减元素使数组呈锯齿状](../../problems/decrease-elements-to-make-array-zigzag) | [[数组](../array/README.md)] | Medium | +| 1133 | [最大唯一数](../../problems/largest-unique-number) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1128 | [等价多米诺骨牌对的数量](../../problems/number-of-equivalent-domino-pairs) | [[数组](../array/README.md)] | Easy | +| 1122 | [数组的相对排序](../../problems/relative-sort-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 1109 | [航班预订统计](../../problems/corporate-flight-bookings) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1089 | [复写零](../../problems/duplicate-zeros) | [[数组](../array/README.md)] | Easy | +| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1085 | [最小元素各数位之和](../../problems/sum-of-digits-in-the-minimum-number) 🔒 | [[数组](../array/README.md)] | Easy | +| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 1064 | [不动点](../../problems/fixed-point) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1053 | [交换一次的先前排列](../../problems/previous-permutation-with-one-swap) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1052 | [爱生气的书店老板](../../problems/grumpy-bookstore-owner) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1051 | [高度检查器](../../problems/height-checker) | [[数组](../array/README.md)] | Easy | +| 1040 | [移动石子直到连续 II](../../problems/moving-stones-until-consecutive-ii) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1035 | [不相交的线](../../problems/uncrossed-lines) | [[数组](../array/README.md)] | Medium | +| 1031 | [两个非重叠子数组的最大和](../../problems/maximum-sum-of-two-non-overlapping-subarrays) | [[数组](../array/README.md)] | Medium | +| 1018 | [可被 5 整除的二进制前缀](../../problems/binary-prefix-divisible-by-5) | [[数组](../array/README.md)] | Easy | +| 1014 | [最佳观光组合](../../problems/best-sightseeing-pair) | [[数组](../array/README.md)] | Medium | +| 1013 | [将数组分成和相等的三个部分](../../problems/partition-array-into-three-parts-with-equal-sum) | [[数组](../array/README.md)] | Easy | +| 1011 | [在 D 天内送达包裹的能力](../../problems/capacity-to-ship-packages-within-d-days) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1010 | [总持续时间可被 60 整除的歌曲](../../problems/pairs-of-songs-with-total-durations-divisible-by-60) | [[数组](../array/README.md)] | Medium | +| 1007 | [行相等的最少多米诺旋转](../../problems/minimum-domino-rotations-for-equal-row) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 999 | [可以被一步捕获的棋子数](../../problems/available-captures-for-rook) | [[数组](../array/README.md)] | Easy | +| 989 | [数组形式的整数加法](../../problems/add-to-array-form-of-integer) | [[数组](../array/README.md)] | Easy | +| 985 | [查询后的偶数和](../../problems/sum-of-even-numbers-after-queries) | [[数组](../array/README.md)] | Easy | +| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 977 | [有序数组的平方](../../problems/squares-of-a-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 974 | [和可被 K 整除的子数组](../../problems/subarray-sums-divisible-by-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 969 | [煎饼排序](../../problems/pancake-sorting) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 962 | [最大宽度坡](../../problems/maximum-width-ramp) | [[数组](../array/README.md)] | Medium | +| 954 | [二倍数对数组](../../problems/array-of-doubled-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 950 | [按递增顺序显示卡牌](../../problems/reveal-cards-in-increasing-order) | [[数组](../array/README.md)] | Medium | +| 945 | [使数组唯一的最小增量](../../problems/minimum-increment-to-make-array-unique) | [[数组](../array/README.md)] | Medium | +| 941 | [有效的山脉数组](../../problems/valid-mountain-array) | [[数组](../array/README.md)] | Easy | +| 926 | [将字符串翻转到单调递增](../../problems/flip-string-to-monotone-increasing) | [[数组](../array/README.md)] | Medium | +| 922 | [按奇偶排序数组 II](../../problems/sort-array-by-parity-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 918 | [环形子数组的最大和](../../problems/maximum-sum-circular-subarray) | [[数组](../array/README.md)] | Medium | +| 915 | [分割数组](../../problems/partition-array-into-disjoint-intervals) | [[数组](../array/README.md)] | Medium | +| 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 907 | [子数组的最小值之和](../../problems/sum-of-subarray-minimums) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Medium | +| 905 | [按奇偶排序数组](../../problems/sort-array-by-parity) | [[数组](../array/README.md)] | Easy | +| 900 | [RLE 迭代器](../../problems/rle-iterator) | [[数组](../array/README.md)] | Medium | +| 896 | [单调数列](../../problems/monotonic-array) | [[数组](../array/README.md)] | Easy | +| 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] | Easy | +| 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 867 | [转置矩阵](../../problems/transpose-matrix) | [[数组](../array/README.md)] | Easy | +| 849 | [到最近的人的最大距离](../../problems/maximize-distance-to-closest-person) | [[数组](../array/README.md)] | Medium | +| 840 | [矩阵中的幻方](../../problems/magic-squares-in-grid) | [[数组](../array/README.md)] | Medium | +| 835 | [图像重叠](../../problems/image-overlap) | [[数组](../array/README.md)] | Medium | +| 832 | [翻转图像](../../problems/flipping-an-image) | [[数组](../array/README.md)] | Easy | +| 830 | [较大分组的位置](../../problems/positions-of-large-groups) | [[数组](../array/README.md)] | Easy | +| 825 | [适龄的朋友](../../problems/friends-of-appropriate-ages) | [[数组](../array/README.md)] | Medium | +| 795 | [区间子数组个数](../../problems/number-of-subarrays-with-bounded-maximum) | [[数组](../array/README.md)] | Medium | +| 792 | [匹配子序列的单词数](../../problems/number-of-matching-subsequences) | [[数组](../array/README.md)] | Medium | +| 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 775 | [全局倒置与局部倒置](../../problems/global-and-local-inversions) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 769 | [最多能完成排序的块](../../problems/max-chunks-to-make-sorted) | [[数组](../array/README.md)] | Medium | +| 768 | [最多能完成排序的块 II](../../problems/max-chunks-to-make-sorted-ii) | [[数组](../array/README.md)] | Hard | +| 766 | [托普利茨矩阵](../../problems/toeplitz-matrix) | [[数组](../array/README.md)] | Easy | +| 755 | [倒水](../../problems/pour-water) 🔒 | [[数组](../array/README.md)] | Medium | +| 747 | [至少是其他数字两倍的最大数](../../problems/largest-number-at-least-twice-of-others) | [[数组](../array/README.md)] | Easy | +| 746 | [使用最小花费爬楼梯](../../problems/min-cost-climbing-stairs) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 729 | [我的日程安排表 I](../../problems/my-calendar-i) | [[数组](../array/README.md)] | Medium | +| 724 | [寻找数组的中心索引](../../problems/find-pivot-index) | [[数组](../array/README.md)] | Easy | +| 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 717 | [1比特与2比特字符](../../problems/1-bit-and-2-bit-characters) | [[数组](../array/README.md)] | Easy | +| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 697 | [数组的度](../../problems/degree-of-an-array) | [[数组](../array/README.md)] | Easy | +| 695 | [岛屿的最大面积](../../problems/max-area-of-island) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 689 | [三个无重叠子数组的最大和](../../problems/maximum-sum-of-3-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 674 | [最长连续递增序列](../../problems/longest-continuous-increasing-subsequence) | [[数组](../array/README.md)] | Easy | +| 670 | [最大交换](../../problems/maximum-swap) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 667 | [优美的排列 II](../../problems/beautiful-arrangement-ii) | [[数组](../array/README.md)] | Medium | +| 665 | [非递减数列](../../problems/non-decreasing-array) | [[数组](../array/README.md)] | Easy | +| 661 | [图片平滑器](../../problems/image-smoother) | [[数组](../array/README.md)] | Easy | +| 644 | [子数组最大平均数 II](../../problems/maximum-average-subarray-ii) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 643 | [子数组最大平均数 I](../../problems/maximum-average-subarray-i) | [[数组](../array/README.md)] | Easy | +| 628 | [三个数的最大乘积](../../problems/maximum-product-of-three-numbers) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | +| 611 | [有效三角形的个数](../../problems/valid-triangle-number) | [[数组](../array/README.md)] | Medium | +| 605 | [种花问题](../../problems/can-place-flowers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 581 | [最短无序连续子数组](../../problems/shortest-unsorted-continuous-subarray) | [[数组](../array/README.md)] | Medium | +| 566 | [重塑矩阵](../../problems/reshape-the-matrix) | [[数组](../array/README.md)] | Easy | +| 565 | [数组嵌套](../../problems/array-nesting) | [[数组](../array/README.md)] | Medium | +| 562 | [矩阵中最长的连续1线段](../../problems/longest-line-of-consecutive-one-in-matrix) 🔒 | [[数组](../array/README.md)] | Medium | +| 561 | [数组拆分 I](../../problems/array-partition-i) | [[数组](../array/README.md)] | Easy | +| 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 548 | [将数组分割成和相等的子数组](../../problems/split-array-with-equal-sum) 🔒 | [[数组](../array/README.md)] | Medium | +| 533 | [孤独像素 II](../../problems/lonely-pixel-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 531 | [孤独像素 I](../../problems/lonely-pixel-i) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 509 | [斐波那契数](../../problems/fibonacci-number) | [[数组](../array/README.md)] | Easy | +| 495 | [提莫攻击](../../problems/teemo-attacking) | [[数组](../array/README.md)] | Medium | +| 485 | [最大连续 1 的个数](../../problems/max-consecutive-ones) | [[数组](../array/README.md)] | Easy | +| 457 | [环形数组循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 448 | [找到所有数组中消失的数字](../../problems/find-all-numbers-disappeared-in-an-array) | [[数组](../array/README.md)] | Easy | +| 442 | [数组中重复的数据](../../problems/find-all-duplicates-in-an-array) | [[数组](../array/README.md)] | Medium | +| 414 | [第三大的数](../../problems/third-maximum-number) | [[数组](../array/README.md)] | Easy | +| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 370 | [区间加法](../../problems/range-addition) 🔒 | [[数组](../array/README.md)] | Medium | +| 289 | [生命游戏](../../problems/game-of-life) | [[数组](../array/README.md)] | Medium | +| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 277 | [搜寻名人](../../problems/find-the-celebrity) 🔒 | [[数组](../array/README.md)] | Medium | +| 268 | [丢失的数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 245 | [最短单词距离 III](../../problems/shortest-word-distance-iii) 🔒 | [[数组](../array/README.md)] | Medium | +| 243 | [最短单词距离](../../problems/shortest-word-distance) 🔒 | [[数组](../array/README.md)] | Easy | +| 238 | [除自身以外数组的乘积](../../problems/product-of-array-except-self) | [[数组](../array/README.md)] | Medium | +| 229 | [求众数 II](../../problems/majority-element-ii) | [[数组](../array/README.md)] | Medium | +| 228 | [汇总区间](../../problems/summary-ranges) | [[数组](../array/README.md)] | Easy | +| 219 | [存在重复元素 II](../../problems/contains-duplicate-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 217 | [存在重复元素](../../problems/contains-duplicate) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 189 | [旋转数组](../../problems/rotate-array) | [[数组](../array/README.md)] | Medium | +| 169 | [多数元素](../../problems/majority-element) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Easy | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 163 | [缺失的区间](../../problems/missing-ranges) 🔒 | [[数组](../array/README.md)] | Easy | +| 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 154 | [寻找旋转排序数组中的最小值 II](../../problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 152 | [乘积最大子数组](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 128 | [最长连续序列](../../problems/longest-consecutive-sequence) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Hard | +| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 123 | [买卖股票的最佳时机 III](../../problems/best-time-to-buy-and-sell-stock-iii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 121 | [买卖股票的最佳时机](../../problems/best-time-to-buy-and-sell-stock) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 120 | [三角形最小路径和](../../problems/triangle) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 119 | [杨辉三角 II](../../problems/pascals-triangle-ii) | [[数组](../array/README.md)] | Easy | +| 118 | [杨辉三角](../../problems/pascals-triangle) | [[数组](../array/README.md)] | Easy | +| 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 90 | [子集 II](../../problems/subsets-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 88 | [合并两个有序数组](../../problems/merge-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 84 | [柱状图中最大的矩形](../../problems/largest-rectangle-in-histogram) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Hard | +| 81 | [搜索旋转排序数组 II](../../problems/search-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 80 | [删除排序数组中的重复项 II](../../problems/remove-duplicates-from-sorted-array-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 79 | [单词搜索](../../problems/word-search) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 74 | [搜索二维矩阵](../../problems/search-a-2d-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 73 | [矩阵置零](../../problems/set-matrix-zeroes) | [[数组](../array/README.md)] | Medium | +| 66 | [加一](../../problems/plus-one) | [[数组](../array/README.md)] | Easy | +| 64 | [最小路径和](../../problems/minimum-path-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 63 | [不同路径 II](../../problems/unique-paths-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 62 | [不同路径](../../problems/unique-paths) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 59 | [螺旋矩阵 II](../../problems/spiral-matrix-ii) | [[数组](../array/README.md)] | Medium | +| 57 | [插入区间](../../problems/insert-interval) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 56 | [合并区间](../../problems/merge-intervals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 55 | [跳跃游戏](../../problems/jump-game) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 54 | [螺旋矩阵](../../problems/spiral-matrix) | [[数组](../array/README.md)] | Medium | +| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 48 | [旋转图像](../../problems/rotate-image) | [[数组](../array/README.md)] | Medium | +| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Hard | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 41 | [缺失的第一个正数](../../problems/first-missing-positive) | [[数组](../array/README.md)] | Hard | +| 40 | [组合总和 II](../../problems/combination-sum-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 39 | [组合总和](../../problems/combination-sum) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 35 | [搜索插入位置](../../problems/search-insert-position) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 34 | [在排序数组中查找元素的第一个和最后一个位置](../../problems/find-first-and-last-position-of-element-in-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 33 | [搜索旋转排序数组](../../problems/search-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 31 | [下一个排列](../../problems/next-permutation) | [[数组](../array/README.md)] | Medium | +| 27 | [移除元素](../../problems/remove-element) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 26 | [删除排序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 11 | [盛最多水的容器](../../problems/container-with-most-water) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 4 | [寻找两个正序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 1 | [两数之和](../../problems/two-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/dequeue/README.md b/tag/dequeue/README.md index dac9adc9e..337f59d12 100644 --- a/tag/dequeue/README.md +++ b/tag/dequeue/README.md @@ -5,7 +5,7 @@ -## [话题分类](../README.md) > +## [话题分类](../README.md) > Dequeue | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 882b2c7e5..012e08c38 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,3 +9,251 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1771 | [由子序列构造的最长回文串的长度](../../problems/maximize-palindrome-length-from-subsequences) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1770 | [执行乘法运算的最大分数](../../problems/maximum-score-from-performing-multiplication-operations) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1751 | [最多可以参加的会议数目 II](../../problems/maximum-number-of-events-that-can-be-attended-ii) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1746 | [Maximum Subarray Sum After One Operation](../../problems/maximum-subarray-sum-after-one-operation) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1745 | [回文串分割 IV](../../problems/palindrome-partitioning-iv) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1728 | [猫和老鼠 II](../../problems/cat-and-mouse-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1724 | [检查边长度限制的路径是否存在 II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1706 | [球会落何处](../../problems/where-will-the-ball-fall) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1692 | [计算分配糖果的不同方式](../../problems/count-ways-to-distribute-candies) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1691 | [堆叠长方体的最大高度](../../problems/maximum-height-by-stacking-cuboids) | [[排序](../sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1690 | [石子游戏 VII](../../problems/stone-game-vii) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1682 | [最长回文子序列 II](../../problems/longest-palindromic-subsequence-ii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1671 | [得到山形数组的最少删除次数](../../problems/minimum-number-of-removals-to-make-mountain-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1664 | [生成平衡数组的方案数](../../problems/ways-to-make-a-fair-array) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1654 | [到家的最少跳跃次数](../../problems/minimum-jumps-to-reach-home) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1643 | [第 K 条最小指令](../../problems/kth-smallest-instructions) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1639 | [通过给定词典构造目标字符串的方案数](../../problems/number-of-ways-to-form-a-target-string-given-a-dictionary) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1626 | [无矛盾的最佳球队](../../problems/best-team-with-no-conflicts) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1621 | [大小为 K 的不重叠线段的数目](../../problems/number-of-sets-of-k-non-overlapping-line-segments) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1563 | [石子游戏 V](../../problems/stone-game-v) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1553 | [吃掉 N 个橘子的最少天数](../../problems/minimum-number-of-days-to-eat-n-oranges) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1548 | [图中最相似的路径](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1547 | [切棍子的最小成本](../../problems/minimum-cost-to-cut-a-stick) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1546 | [和为目标值的最大数目不重叠非空子数组数目](../../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1537 | [最大得分](../../problems/get-the-maximum-score) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1510 | [石子游戏 IV](../../problems/stone-game-iv) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1504 | [统计全 1 子矩形](../../problems/count-submatrices-with-all-ones) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1483 | [树节点的第 K 个祖先](../../problems/kth-ancestor-of-a-tree-node) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1477 | [找两个和为目标值且不重叠的子数组](../../problems/find-two-non-overlapping-sub-arrays-each-with-target-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1473 | [粉刷房子 III](../../problems/paint-house-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1463 | [摘樱桃 II](../../problems/cherry-pickup-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1458 | [两个子序列的最大点积](../../problems/max-dot-product-of-two-subsequences) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1444 | [切披萨的方案数](../../problems/number-of-ways-of-cutting-a-pizza) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1425 | [带限制的子序列和](../../problems/constrained-subsequence-sum) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1420 | [生成数组](../../problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1416 | [恢复数组](../../problems/restore-the-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1411 | [给 N x 3 网格图涂色的方案数](../../problems/number-of-ways-to-paint-n-x-3-grid) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1406 | [石子游戏 III](../../problems/stone-game-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1402 | [做菜顺序](../../problems/reducing-dishes) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1397 | [找到所有好字符串](../../problems/find-all-good-strings) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1388 | [3n 块披萨](../../problems/pizza-with-3n-slices) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1359 | [有效的快递序列数目](../../problems/count-all-valid-pickup-and-delivery-options) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1349 | [参加考试的最大学生数](../../problems/maximum-students-taking-exam) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1340 | [跳跃游戏 V](../../problems/jump-game-v) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1335 | [工作计划的最低难度](../../problems/minimum-difficulty-of-a-job-schedule) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1326 | [灌溉花园的最少水龙头数目](../../problems/minimum-number-of-taps-to-open-to-water-a-garden) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1320 | [二指输入的的最小距离](../../problems/minimum-distance-to-type-a-word-using-two-fingers) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1314 | [矩阵区域和](../../problems/matrix-block-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1312 | [让字符串成为回文串的最少插入次数](../../problems/minimum-insertion-steps-to-make-a-string-palindrome) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1301 | [最大得分的路径数目](../../problems/number-of-paths-with-max-score) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1289 | [下降路径最小和 II](../../problems/minimum-falling-path-sum-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1278 | [分割回文串 III](../../problems/palindrome-partitioning-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1277 | [统计全为 1 的正方形子矩阵](../../problems/count-square-submatrices-with-all-ones) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1273 | [删除树节点](../../problems/delete-tree-nodes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1269 | [停在原地的方案数](../../problems/number-of-ways-to-stay-in-the-same-place-after-some-steps) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1262 | [可被三整除的最大和](../../problems/greatest-sum-divisible-by-three) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1259 | [不相交的握手](../../problems/handshakes-that-dont-cross) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1246 | [删除回文子数组](../../problems/palindrome-removal) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1240 | [铺瓷砖](../../problems/tiling-a-rectangle-with-the-fewest-squares) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1230 | [抛掷硬币](../../problems/toss-strange-coins) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1223 | [掷骰子模拟](../../problems/dice-roll-simulation) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1220 | [统计元音字母序列的数目](../../problems/count-vowels-permutation) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1216 | [验证回文字符串 III](../../problems/valid-palindrome-iii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1199 | [建造街区的最短时间](../../problems/minimum-time-to-build-blocks) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1191 | [K 次串联后最大子数组之和](../../problems/k-concatenation-maximum-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1187 | [使数组严格递增](../../problems/make-array-strictly-increasing) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1186 | [删除一次得到子数组最大和](../../problems/maximum-subarray-sum-with-one-deletion) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1155 | [掷骰子的N种方法](../../problems/number-of-dice-rolls-with-target-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1147 | [段式回文](../../problems/longest-chunked-palindrome-decomposition) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1143 | [最长公共子序列](../../problems/longest-common-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1140 | [石子游戏 II](../../problems/stone-game-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1139 | [最大的以 1 为边界的正方形](../../problems/largest-1-bordered-square) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1125 | [最小的必要团队](../../problems/smallest-sufficient-team) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1105 | [填充书架](../../problems/filling-bookcase-shelves) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1092 | [最短公共超序列](../../problems/shortest-common-supersequence) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 1067 | [范围内的数字计数](../../problems/digit-count-in-range) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1055 | [形成字符串的最短路径](../../problems/shortest-way-to-form-string) 🔒 | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1049 | [最后一块石头的重量 II](../../problems/last-stone-weight-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1048 | [最长字符串链](../../problems/longest-string-chain) | [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1043 | [分隔数组以得到最大和](../../problems/partition-array-for-maximum-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1039 | [多边形三角剖分的最低得分](../../problems/minimum-score-triangulation-of-polygon) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1027 | [最长等差数列](../../problems/longest-arithmetic-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1025 | [除数博弈](../../problems/divisor-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 1024 | [视频拼接](../../problems/video-stitching) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1012 | [至少有 1 位重复的数字](../../problems/numbers-with-repeated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1000 | [合并石头的最低成本](../../problems/minimum-cost-to-merge-stones) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 983 | [最低票价](../../problems/minimum-cost-for-tickets) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 982 | [按位与为零的三元组](../../problems/triples-with-bitwise-and-equal-to-zero) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 964 | [表示数字的最少运算符](../../problems/least-operators-to-express-number) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 960 | [删列造序 III](../../problems/delete-columns-to-make-sorted-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 956 | [最高的广告牌](../../problems/tallest-billboard) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 943 | [最短超级串](../../problems/find-the-shortest-superstring) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 940 | [不同的子序列 II](../../problems/distinct-subsequences-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 935 | [骑士拨号器](../../problems/knight-dialer) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 931 | [下降路径最小和](../../problems/minimum-falling-path-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 920 | [播放列表的数量](../../problems/number-of-music-playlists) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 903 | [DI 序列的有效排列](../../problems/valid-permutations-for-di-sequence) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 902 | [最大为 N 的数字组合](../../problems/numbers-at-most-n-given-digit-set) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 898 | [子数组按位或操作](../../problems/bitwise-ors-of-subarrays) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 879 | [盈利计划](../../problems/profitable-schemes) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 877 | [石子游戏](../../problems/stone-game) | [[极小化极大](../minimax/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 871 | [最低加油次数](../../problems/minimum-number-of-refueling-stops) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 837 | [新21点](../../problems/new-21-game) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 818 | [赛车](../../problems/race-car) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 813 | [最大平均值和的分组](../../problems/largest-sum-of-averages) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 808 | [分汤](../../problems/soup-servings) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 801 | [使序列递增的最小交换次数](../../problems/minimum-swaps-to-make-sequences-increasing) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 799 | [香槟塔](../../problems/champagne-tower) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 790 | [多米诺和托米诺平铺](../../problems/domino-and-tromino-tiling) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 764 | [最大加号标志](../../problems/largest-plus-sign) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 750 | [角矩形的数量](../../problems/number-of-corner-rectangles) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 746 | [使用最小花费爬楼梯](../../problems/min-cost-climbing-stairs) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 741 | [摘樱桃](../../problems/cherry-pickup) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 740 | [删除与获得点数](../../problems/delete-and-earn) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 712 | [两个字符串的最小ASCII删除和](../../problems/minimum-ascii-delete-sum-for-two-strings) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 689 | [三个无重叠子数组的最大和](../../problems/maximum-sum-of-3-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 688 | [“马”在棋盘上的概率](../../problems/knight-probability-in-chessboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 673 | [最长递增子序列的个数](../../problems/number-of-longest-increasing-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 664 | [奇怪的打印机](../../problems/strange-printer) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 656 | [金币路径](../../problems/coin-path) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 651 | [4键键盘](../../problems/4-keys-keyboard) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 650 | [只有两个键的键盘](../../problems/2-keys-keyboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 647 | [回文子串](../../problems/palindromic-substrings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 646 | [最长数对链](../../problems/maximum-length-of-pair-chain) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 639 | [解码方法 II](../../problems/decode-ways-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 638 | [大礼包](../../problems/shopping-offers) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 629 | [K个逆序对数组](../../problems/k-inverse-pairs-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 600 | [不含连续1的非负整数](../../problems/non-negative-integers-without-consecutive-ones) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 576 | [出界的路径数](../../problems/out-of-boundary-paths) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 568 | [最大休假天数](../../problems/maximum-vacation-days) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 552 | [学生出勤记录 II](../../problems/student-attendance-record-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 546 | [移除盒子](../../problems/remove-boxes) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 523 | [连续的子数组和](../../problems/continuous-subarray-sum) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 517 | [超级洗衣机](../../problems/super-washing-machines) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 516 | [最长回文子序列](../../problems/longest-palindromic-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 494 | [目标和](../../problems/target-sum) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 486 | [预测赢家](../../problems/predict-the-winner) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 474 | [一和零](../../problems/ones-and-zeroes) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 471 | [编码最短长度的字符串](../../problems/encode-string-with-shortest-length) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 467 | [环绕字符串中唯一的子字符串](../../problems/unique-substrings-in-wraparound-string) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 466 | [统计重复个数](../../problems/count-the-repetitions) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 464 | [我能赢吗](../../problems/can-i-win) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 446 | [等差数列划分 II - 子序列](../../problems/arithmetic-slices-ii-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 416 | [分割等和子集](../../problems/partition-equal-subset-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 403 | [青蛙过河](../../problems/frog-jump) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 377 | [组合总和 Ⅳ](../../problems/combination-sum-iv) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 375 | [猜数字大小 II](../../problems/guess-number-higher-or-lower-ii) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 361 | [轰炸敌人](../../problems/bomb-enemy) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 354 | [俄罗斯套娃信封问题](../../problems/russian-doll-envelopes) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 351 | [安卓系统手势解锁](../../problems/android-unlock-patterns) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 343 | [整数拆分](../../problems/integer-break) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 322 | [零钱兑换](../../problems/coin-change) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 321 | [拼接最大数](../../problems/create-maximum-number) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 312 | [戳气球](../../problems/burst-balloons) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 309 | [最佳买卖股票时机含冷冻期](../../problems/best-time-to-buy-and-sell-stock-with-cooldown) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 304 | [二维区域和检索 - 矩阵不可变](../../problems/range-sum-query-2d-immutable) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 303 | [区域和检索 - 数组不可变](../../problems/range-sum-query-immutable) | [[动态规划](../dynamic-programming/README.md)] | Easy | +| 300 | [最长递增子序列](../../problems/longest-increasing-subsequence) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 276 | [栅栏涂色](../../problems/paint-fence) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Easy | +| 265 | [粉刷房子 II](../../problems/paint-house-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 256 | [粉刷房子](../../problems/paint-house) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 221 | [最大正方形](../../problems/maximal-square) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 213 | [打家劫舍 II](../../problems/house-robber-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 198 | [打家劫舍](../../problems/house-robber) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 188 | [买卖股票的最佳时机 IV](../../problems/best-time-to-buy-and-sell-stock-iv) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 174 | [地下城游戏](../../problems/dungeon-game) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 152 | [乘积最大子数组](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 140 | [单词拆分 II](../../problems/word-break-ii) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 139 | [单词拆分](../../problems/word-break) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 132 | [分割回文串 II](../../problems/palindrome-partitioning-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 123 | [买卖股票的最佳时机 III](../../problems/best-time-to-buy-and-sell-stock-iii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 121 | [买卖股票的最佳时机](../../problems/best-time-to-buy-and-sell-stock) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 120 | [三角形最小路径和](../../problems/triangle) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 115 | [不同的子序列](../../problems/distinct-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 91 | [解码方法](../../problems/decode-ways) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 87 | [扰乱字符串](../../problems/scramble-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 72 | [编辑距离](../../problems/edit-distance) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 70 | [爬楼梯](../../problems/climbing-stairs) | [[动态规划](../dynamic-programming/README.md)] | Easy | +| 64 | [最小路径和](../../problems/minimum-path-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 63 | [不同路径 II](../../problems/unique-paths-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 62 | [不同路径](../../problems/unique-paths) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 5 | [最长回文子串](../../problems/longest-palindromic-substring) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index 5a8521ed2..085448301 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -9,3 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard | +| 1515 | [服务中心的最佳位置](../../problems/best-position-for-a-service-centre) | [[几何](../geometry/README.md)] | Hard | +| 1453 | [圆形靶内的最大飞镖数量](../../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | [[几何](../geometry/README.md)] | Hard | +| 1401 | [圆和矩形是否有重叠](../../problems/circle-and-rectangle-overlapping) | [[几何](../geometry/README.md)] | Medium | +| 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] | Easy | +| 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | +| 892 | [三维形体的表面积](../../problems/surface-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | +| 587 | [安装栅栏](../../problems/erect-the-fence) | [[几何](../geometry/README.md)] | Hard | diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md index 592ea3e0f..932db1472 100644 --- a/tag/line-sweep/README.md +++ b/tag/line-sweep/README.md @@ -9,3 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | +| 391 | [完美矩形](../../problems/perfect-rectangle) | [[Line Sweep](../line-sweep/README.md)] | Hard | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index 8642b2274..8103f6eff 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -9,3 +9,46 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1721 | [交换链表中的节点](../../problems/swapping-nodes-in-a-linked-list) | [[链表](../linked-list/README.md)] | Medium | +| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 1669 | [合并两个链表](../../problems/merge-in-between-linked-lists) | [[链表](../linked-list/README.md)] | Medium | +| 1634 | [求两个多项式链表的和](../../problems/add-two-polynomials-represented-as-linked-lists) 🔒 | [[链表](../linked-list/README.md)] | Medium | +| 1474 | [删除链表 M 个节点之后的 N 个节点](../../problems/delete-n-nodes-after-m-nodes-of-a-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Easy | +| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)] | Easy | +| 1171 | [从链表中删去总和值为零的连续节点](../../problems/remove-zero-sum-consecutive-nodes-from-linked-list) | [[链表](../linked-list/README.md)] | Medium | +| 1019 | [链表中的下一个更大节点](../../problems/next-greater-node-in-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 876 | [链表的中间结点](../../problems/middle-of-the-linked-list) | [[链表](../linked-list/README.md)] | Easy | +| 817 | [链表组件](../../problems/linked-list-components) | [[链表](../linked-list/README.md)] | Medium | +| 725 | [分隔链表](../../problems/split-linked-list-in-parts) | [[链表](../linked-list/README.md)] | Medium | +| 708 | [循环有序列表的插入](../../problems/insert-into-a-sorted-circular-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Medium | +| 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 445 | [两数相加 II](../../problems/add-two-numbers-ii) | [[链表](../linked-list/README.md)] | Medium | +| 430 | [扁平化多级双向链表](../../problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 328 | [奇偶链表](../../problems/odd-even-linked-list) | [[链表](../linked-list/README.md)] | Medium | +| 237 | [删除链表中的节点](../../problems/delete-node-in-a-linked-list) | [[链表](../linked-list/README.md)] | Easy | +| 234 | [回文链表](../../problems/palindrome-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 206 | [反转链表](../../problems/reverse-linked-list) | [[链表](../linked-list/README.md)] | Easy | +| 203 | [移除链表元素](../../problems/remove-linked-list-elements) | [[链表](../linked-list/README.md)] | Easy | +| 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[链表](../linked-list/README.md)] | Easy | +| 148 | [排序链表](../../problems/sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 143 | [重排链表](../../problems/reorder-list) | [[链表](../linked-list/README.md)] | Medium | +| 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 141 | [环形链表](../../problems/linked-list-cycle) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 138 | [复制带随机指针的链表](../../problems/copy-list-with-random-pointer) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 92 | [反转链表 II](../../problems/reverse-linked-list-ii) | [[链表](../linked-list/README.md)] | Medium | +| 86 | [分隔链表](../../problems/partition-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 83 | [删除排序链表中的重复元素](../../problems/remove-duplicates-from-sorted-list) | [[链表](../linked-list/README.md)] | Easy | +| 82 | [删除排序链表中的重复元素 II](../../problems/remove-duplicates-from-sorted-list-ii) | [[链表](../linked-list/README.md)] | Medium | +| 61 | [旋转链表](../../problems/rotate-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 25 | [K 个一组翻转链表](../../problems/reverse-nodes-in-k-group) | [[链表](../linked-list/README.md)] | Hard | +| 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Easy | +| 19 | [删除链表的倒数第 N 个结点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/meet-in-the-middle/README.md b/tag/meet-in-the-middle/README.md index dac9adc9e..e22e2978d 100644 --- a/tag/meet-in-the-middle/README.md +++ b/tag/meet-in-the-middle/README.md @@ -5,7 +5,7 @@ -## [话题分类](../README.md) > +## [话题分类](../README.md) > Meet In The Middle | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | diff --git a/tag/oop/README.md b/tag/oop/README.md index dac9adc9e..4871b5c65 100644 --- a/tag/oop/README.md +++ b/tag/oop/README.md @@ -5,7 +5,7 @@ -## [话题分类](../README.md) > +## [话题分类](../README.md) > OOP | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index 52afd5989..85faedb8e 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -9,3 +9,17 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | +| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 855 | [考场就座](../../problems/exam-room) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 846 | [一手顺子](../../problems/hand-of-straights) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 731 | [我的日程安排表 II](../../problems/my-calendar-ii) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 683 | [K 个关闭的灯泡](../../problems/k-empty-slots) 🔒 | [[Ordered Map](../ordered-map/README.md)] | Hard | +| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index fbbfc5182..56d607bc2 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -9,3 +9,30 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[排序](../sort/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1176 | [健身计划评估](../../problems/diet-plan-performance) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Easy | +| 1151 | [最少交换次数来组合所有的 1](../../problems/minimum-swaps-to-group-all-1s-together) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 1052 | [爱生气的书店老板](../../problems/grumpy-bookstore-owner) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1040 | [移动石子直到连续 II](../../problems/moving-stones-until-consecutive-ii) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[贪心算法](../greedy/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 480 | [滑动窗口中位数](../../problems/sliding-window-median) | [[Sliding Window](../sliding-window/README.md)] | Hard | +| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 395 | [至少有K个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index 49e4c7112..3ae174849 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,3 +9,78 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1727 | [重新排列后的最大子矩阵](../../problems/largest-submatrix-with-rearrangements) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 1710 | [卡车上的最大单元数](../../problems/maximum-units-on-a-truck) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | +| 1697 | [检查边长度限制的路径是否存在](../../problems/checking-existence-of-edge-length-limited-paths) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] | Hard | +| 1691 | [堆叠长方体的最大高度](../../problems/maximum-height-by-stacking-cuboids) | [[排序](../sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | +| 1647 | [字符频次唯一的最小删除次数](../../problems/minimum-deletions-to-make-character-frequencies-unique) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1637 | [两点之间不包含任何点的最宽垂直面积](../../problems/widest-vertical-area-between-two-points-containing-no-points) | [[排序](../sort/README.md)] | Medium | +| 1636 | [按照频率将数组升序排序](../../problems/sort-array-by-increasing-frequency) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 1630 | [等差子数组](../../problems/arithmetic-subarrays) | [[排序](../sort/README.md)] | Medium | +| 1561 | [你可以获得的最大硬币数目](../../problems/maximum-number-of-coins-you-can-get) | [[排序](../sort/README.md)] | Medium | +| 1528 | [重新排列字符串](../../problems/shuffle-string) | [[排序](../sort/README.md)] | Easy | +| 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1502 | [判断能否形成等差数列](../../problems/can-make-arithmetic-progression-from-sequence) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[排序](../sort/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1491 | [去掉最低工资和最高工资后的工资平均值](../../problems/average-salary-excluding-the-minimum-and-maximum-salary) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 1481 | [不同整数的最少数目](../../problems/least-number-of-unique-integers-after-k-removals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1471 | [数组中的 k 个最强值](../../problems/the-k-strongest-values-in-an-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | +| 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | +| 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Hard | +| 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | +| 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[排序](../sort/README.md)] [[位运算](../bit-manipulation/README.md)] | Easy | +| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | +| 1333 | [餐厅过滤器](../../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1329 | [将矩阵按对角线排序](../../problems/sort-the-matrix-diagonally) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[排序](../sort/README.md)] [[树](../tree/README.md)] | Medium | +| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1183 | [矩阵中 1 的最大数量](../../problems/maximum-number-of-ones) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | +| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1122 | [数组的相对排序](../../problems/relative-sort-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1057 | [校园自行车分配](../../problems/campus-bikes) 🔒 | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] | Medium | +| 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[排序](../sort/README.md)] | Easy | +| 976 | [三角形的最大周长](../../problems/largest-perimeter-triangle) | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Easy | +| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 969 | [煎饼排序](../../problems/pancake-sorting) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 922 | [按奇偶排序数组 II](../../problems/sort-array-by-parity-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | +| 853 | [车队](../../problems/car-fleet) | [[排序](../sort/README.md)] | Medium | +| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | +| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Hard | +| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 324 | [摆动排序 II](../../problems/wiggle-sort-ii) | [[排序](../sort/README.md)] | Medium | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | +| 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 274 | [H 指数](../../problems/h-index) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 252 | [会议室](../../problems/meeting-rooms) 🔒 | [[排序](../sort/README.md)] | Easy | +| 242 | [有效的字母异位词](../../problems/valid-anagram) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | +| 179 | [最大数](../../problems/largest-number) | [[排序](../sort/README.md)] | Medium | +| 164 | [最大间距](../../problems/maximum-gap) | [[排序](../sort/README.md)] | Hard | +| 148 | [排序链表](../../problems/sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 57 | [插入区间](../../problems/insert-interval) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 56 | [合并区间](../../problems/merge-intervals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/tags.json b/tag/tags.json index 3938e0e01..a01a1babe 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -175,9 +175,9 @@ "TranslatedName": "二叉搜索树" }, { - "Name": "", + "Name": "Dequeue", "Slug": "dequeue", - "TranslatedName": "" + "TranslatedName": "Dequeue" }, { "Name": "Rolling Hash", @@ -200,9 +200,9 @@ "TranslatedName": "蓄水池抽样" }, { - "Name": "", + "Name": "Meet In The Middle", "Slug": "meet-in-the-middle", - "TranslatedName": "" + "TranslatedName": "Meet In The Middle" }, { "Name": "Memoization", @@ -210,8 +210,8 @@ "TranslatedName": "记忆化" }, { - "Name": "", + "Name": "OOP", "Slug": "oop", - "TranslatedName": "" + "TranslatedName": "OOP" } ] \ No newline at end of file From 51c2064e2df8f0623df756b5c679ce78947fae78 Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 24 Feb 2021 16:42:09 +0800 Subject: [PATCH 121/145] U: string() --- problems/base-7/base_7.go | 4 +++- .../excel-sheet-column-title/excel_sheet_column_title.go | 8 +++++--- problems/find-common-characters/find_common_characters.go | 4 +++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/problems/base-7/base_7.go b/problems/base-7/base_7.go index eb5d7b6fb..a33edf3b2 100644 --- a/problems/base-7/base_7.go +++ b/problems/base-7/base_7.go @@ -1,5 +1,7 @@ package problem504 +import "fmt" + func convertToBase7(num int) string { ans := "" if num < 0 { @@ -8,5 +10,5 @@ func convertToBase7(num int) string { if num >= 7 { ans += convertToBase7(num / 7) } - return ans + string('0'+num%7) + return ans + fmt.Sprintf("%c", '0'+num%7) } diff --git a/problems/excel-sheet-column-title/excel_sheet_column_title.go b/problems/excel-sheet-column-title/excel_sheet_column_title.go index 4e739214f..60a5e5e20 100644 --- a/problems/excel-sheet-column-title/excel_sheet_column_title.go +++ b/problems/excel-sheet-column-title/excel_sheet_column_title.go @@ -1,11 +1,13 @@ package problem168 +import "fmt" + // Solution 1: recursive func convertToTitle(n int) string { if n--; n < 26 { - return string(n + 'A') + return fmt.Sprintf("%c", n+'A') } - return convertToTitle(n/26) + string(n%26+'A') + return convertToTitle(n/26) + fmt.Sprintf("%c", n%26+'A') } // Solution 2: iteration @@ -13,7 +15,7 @@ func convertToTitle2(n int) string { ans := "" for ; n > 0; n /= 26 { n-- - ans = string(n%26+'A') + ans + ans = fmt.Sprintf("%c", n%26+'A') + ans } return ans } diff --git a/problems/find-common-characters/find_common_characters.go b/problems/find-common-characters/find_common_characters.go index 5582457b7..468ed7a6d 100644 --- a/problems/find-common-characters/find_common_characters.go +++ b/problems/find-common-characters/find_common_characters.go @@ -1,5 +1,7 @@ package problem1002 +import "fmt" + func commonChars(A []string) []string { ans, m, l := make([]string, 0), make([][26]int, len(A)), len(A) for i, str := range A { @@ -19,7 +21,7 @@ func commonChars(A []string) []string { } } if c >= 0 { - ans = append(ans, string(i+'a')) + ans = append(ans, fmt.Sprintf("%c", i+'a')) } } } From a13df076f26c48288b89dbdfc3ff6e5397274ac1 Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 11 Mar 2021 15:33:27 +0800 Subject: [PATCH 122/145] A: new --- README.md | 25 ++- problems/add-two-numbers/README.md | 2 +- .../all-possible-full-binary-trees/README.md | 27 +-- problems/arithmetic-slices/README.md | 45 ++--- .../available-captures-for-rook/README.md | 52 +++--- .../README.md | 38 +++-- .../README.md | 2 +- .../README.md | 10 +- .../README.md | 6 +- .../README.md | 31 +++- .../README.md | 44 +++-- .../binary-search-tree-iterator/README.md | 4 +- problems/binary-search/README.md | 31 ++-- problems/binary-tree-tilt/README.md | 2 +- .../bitwise-and-of-numbers-range/README.md | 24 ++- problems/buddy-strings/README.md | 30 ++-- .../buildings-with-an-ocean-view/README.md | 2 +- problems/car-fleet-ii/README.md | 67 ++++++++ .../README.md | 52 ++++++ .../README.md | 63 +++++++ problems/circular-array-loop/README.md | 71 +++++--- problems/closest-dessert-cost/README.md | 93 +++++++++++ .../README.md | 25 ++- problems/container-with-most-water/README.md | 8 +- problems/contains-duplicate-ii/README.md | 30 ++-- problems/contains-duplicate-iii/README.md | 4 +- problems/contains-duplicate/README.md | 37 ++-- problems/corporate-flight-bookings/README.md | 35 +++- .../count-items-matching-a-rule/README.md | 60 +++++++ problems/count-of-range-sum/README.md | 30 +++- problems/count-pairs-of-nodes/README.md | 82 +++++++++ problems/counting-bits/README.md | 39 ++++- .../README.md | 2 +- problems/deepest-leaves-sum/README.md | 17 +- .../delete-nodes-and-return-forest/README.md | 17 +- .../README.md | 39 +++-- problems/design-hashmap/README.md | 52 +++--- problems/design-linked-list/README.md | 22 +-- .../design-most-recently-used-queue/README.md | 2 +- problems/diameter-of-binary-tree/README.md | 45 ++--- problems/divide-two-integers/README.md | 8 +- .../README.md | 71 ++++++++ problems/escape-a-large-maze/README.md | 19 ++- .../README.md | 27 +-- problems/excel-sheet-column-number/README.md | 39 +++-- problems/excel-sheet-column-title/README.md | 39 +++-- .../README.md | 41 +++-- .../README.md | 2 +- .../README.md | 58 +++++++ problems/find-pivot-index/README.md | 2 +- .../README.md | 51 +++--- problems/flipping-an-image/README.md | 32 ++-- problems/grand-slam-titles/README.md | 14 ++ problems/grand-slam-titles/mysql_schemas.sql | 10 ++ problems/h-index-ii/README.md | 39 +++-- problems/h-index/README.md | 38 +++-- problems/house-robber-ii/README.md | 2 +- problems/house-robber-iii/README.md | 47 +++--- problems/house-robber/README.md | 12 +- problems/implement-trie-prefix-tree/README.md | 40 +++-- problems/inorder-successor-in-bst/README.md | 2 +- problems/insertion-sort-list/README.md | 45 +++-- .../README.md | 65 +++---- problems/jump-game-ii/README.md | 4 +- problems/jump-game/README.md | 2 +- problems/k-closest-points-to-origin/README.md | 39 ++--- problems/kill-process/README.md | 2 +- problems/koko-eating-bananas/README.md | 35 ++-- .../kth-largest-element-in-an-array/README.md | 26 +-- problems/largest-perimeter-triangle/README.md | 64 ++----- .../largest-rectangle-in-histogram/README.md | 21 +-- problems/last-stone-weight-ii/README.md | 48 ++++-- problems/longest-common-subsequence/README.md | 15 +- .../longest-palindromic-subsequence/README.md | 30 ++-- .../README.md | 2 +- .../README.md | 37 ++-- .../README.md | 4 +- .../README.md | 4 +- .../README.md | 62 +++++++ problems/max-points-on-a-line/README.md | 38 ++--- problems/maximal-rectangle/README.md | 2 +- .../README.md | 2 +- .../README.md | 28 ++++ problems/maximum-frequency-stack/README.md | 63 ++++--- problems/maximum-gap/README.md | 26 +-- problems/maximum-product-subarray/README.md | 26 ++- problems/maximum-subarray/README.md | 18 +- .../median-of-two-sorted-arrays/README.md | 5 +- .../README.md | 68 ++++++++ .../README.md | 35 ++-- .../README.md | 55 +++--- problems/most-common-word/README.md | 33 ++-- problems/move-zeroes/README.md | 36 ++-- .../n-ary-tree-postorder-traversal/README.md | 2 +- .../n-ary-tree-preorder-traversal/README.md | 2 +- problems/number-of-1-bits/README.md | 4 +- problems/number-of-islands/README.md | 2 +- .../number-of-matching-subsequences/README.md | 36 ++-- .../README.md | 74 ++++++++ .../README.md | 11 +- problems/odd-even-jump/README.md | 39 ++--- problems/odd-even-linked-list/README.md | 29 ++-- problems/paint-fence/README.md | 2 +- problems/paint-house-ii/README.md | 2 +- problems/paint-house/README.md | 2 +- problems/palindrome-linked-list/README.md | 29 +++- problems/parallel-courses-ii/README.md | 8 +- problems/parallel-courses/README.md | 33 +--- problems/power-of-three/README.md | 2 +- problems/power-of-two/README.md | 3 + problems/prison-cells-after-n-days/README.md | 45 ++--- .../products-price-for-each-store/README.md | 14 ++ .../mysql_schemas.sql | 7 + .../recyclable-and-low-fat-products/README.md | 2 +- .../remove-linked-list-elements/README.md | 32 +++- .../remove-palindromic-subsequences/README.md | 13 +- problems/reorder-list/README.md | 35 +++- problems/repeated-dna-sequences/README.md | 14 +- problems/reverse-string-ii/README.md | 32 ++-- .../reverse-words-in-a-string-iii/README.md | 26 ++- problems/reverse-words-in-a-string/README.md | 9 +- problems/russian-doll-envelopes/README.md | 36 ++-- problems/search-a-2d-matrix-ii/README.md | 2 +- problems/short-encoding-of-words/README.md | 1 - .../shortest-path-in-a-hidden-grid/README.md | 35 ++++ problems/sort-array-by-parity-ii/README.md | 36 ++-- .../sort-features-by-popularity/README.md | 29 ++++ .../split-array-with-same-average/README.md | 33 ++-- .../statistics-from-a-large-sample/README.md | 22 +-- .../student-attendance-record-i/README.md | 50 +++--- .../student-attendance-record-ii/README.md | 56 ++++--- .../sum-of-beauty-of-all-substrings/README.md | 58 +++++++ problems/sum-of-two-integers/README.md | 29 ++-- problems/sum-root-to-leaf-numbers/README.md | 2 +- problems/super-egg-drop/README.md | 53 +++--- problems/super-ugly-number/README.md | 37 ++-- problems/transpose-file/README.md | 4 +- problems/ugly-number-ii/README.md | 28 +++- problems/ugly-number-iii/README.md | 7 +- problems/ugly-number/README.md | 37 ++-- problems/unique-email-addresses/README.md | 42 +++-- problems/valid-boomerang/README.md | 36 ++-- problems/valid-phone-numbers/README.md | 2 +- problems/word-break-ii/README.md | 50 +++--- problems/word-break/README.md | 33 ++-- problems/word-search/README.md | 12 +- readme/1-300.md | 8 +- readme/301-600.md | 10 +- readme/601-900.md | 2 +- readme/901-1200.md | 2 +- tag/README.md | 6 +- tag/array/README.md | 10 +- tag/backtracking/README.md | 66 -------- tag/bit-manipulation/README.md | 2 +- tag/brainteaser/README.md | 7 - tag/breadth-first-search/README.md | 1 + tag/depth-first-search/README.md | 7 +- tag/design/README.md | 60 ------- tag/divide-and-conquer/README.md | 2 +- tag/dynamic-programming/README.md | 9 +- tag/geometry/README.md | 9 - tag/graph/README.md | 5 +- tag/greedy/README.md | 9 +- tag/hash-table/README.md | 140 ---------------- tag/line-sweep/README.md | 6 - tag/math/README.md | 2 + tag/queue/README.md | 2 +- tag/recursion/README.md | 37 ---- tag/rejection-sampling/README.md | 2 - tag/sliding-window/README.md | 2 +- tag/sort/README.md | 1 + tag/stack/README.md | 64 ------- tag/string/README.md | 2 + tag/tags.json | 20 +-- tag/tree/README.md | 158 ------------------ tag/two-pointers/README.md | 2 +- 176 files changed, 2705 insertions(+), 1987 deletions(-) create mode 100644 problems/car-fleet-ii/README.md create mode 100644 problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md create mode 100644 problems/check-if-number-is-a-sum-of-powers-of-three/README.md create mode 100644 problems/closest-dessert-cost/README.md create mode 100644 problems/count-items-matching-a-rule/README.md create mode 100644 problems/count-pairs-of-nodes/README.md create mode 100644 problems/equal-sum-arrays-with-minimum-number-of-operations/README.md create mode 100644 problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md create mode 100644 problems/grand-slam-titles/README.md create mode 100644 problems/grand-slam-titles/mysql_schemas.sql create mode 100644 problems/make-the-xor-of-all-segments-equal-to-zero/README.md create mode 100644 problems/maximize-the-beauty-of-the-garden/README.md create mode 100644 problems/minimum-elements-to-add-to-form-a-given-sum/README.md create mode 100644 problems/number-of-restricted-paths-from-first-to-last-node/README.md create mode 100644 problems/products-price-for-each-store/README.md create mode 100644 problems/products-price-for-each-store/mysql_schemas.sql create mode 100644 problems/shortest-path-in-a-hidden-grid/README.md create mode 100644 problems/sort-features-by-popularity/README.md create mode 100644 problems/sum-of-beauty-of-all-substrings/README.md diff --git a/README.md b/README.md index 729abf1fb..7abbfddb0 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,23 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1788 | [Maximize the Beauty of the Garden](https://leetcode.com/problems/maximize-the-beauty-of-the-garden) 🔒 | [Go](problems/maximize-the-beauty-of-the-garden) | Hard | +| 1787 | [Make the XOR of All Segments Equal to Zero](https://leetcode.com/problems/make-the-xor-of-all-segments-equal-to-zero "使所有区间的异或结果为零") | [Go](problems/make-the-xor-of-all-segments-equal-to-zero) | Hard | +| 1786 | [Number of Restricted Paths From First to Last Node](https://leetcode.com/problems/number-of-restricted-paths-from-first-to-last-node "从第一个节点出发到最后一个节点的受限路径数") | [Go](problems/number-of-restricted-paths-from-first-to-last-node) | Medium | +| 1785 | [Minimum Elements to Add to Form a Given Sum](https://leetcode.com/problems/minimum-elements-to-add-to-form-a-given-sum "构成特定和需要添加的最少元素") | [Go](problems/minimum-elements-to-add-to-form-a-given-sum) | Medium | +| 1784 | [Check if Binary String Has at Most One Segment of Ones](https://leetcode.com/problems/check-if-binary-string-has-at-most-one-segment-of-ones "检查二进制字符串字段") | [Go](problems/check-if-binary-string-has-at-most-one-segment-of-ones) | Easy | +| 1783 | [Grand Slam Titles](https://leetcode.com/problems/grand-slam-titles) 🔒 | [MySQL](problems/grand-slam-titles) | Medium | +| 1782 | [Count Pairs Of Nodes](https://leetcode.com/problems/count-pairs-of-nodes "统计点对的数目") | [Go](problems/count-pairs-of-nodes) | Hard | +| 1781 | [Sum of Beauty of All Substrings](https://leetcode.com/problems/sum-of-beauty-of-all-substrings "所有子字符串美丽值之和") | [Go](problems/sum-of-beauty-of-all-substrings) | Medium | +| 1780 | [Check if Number is a Sum of Powers of Three](https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three "判断一个数字是否可以表示成三的幂的和") | [Go](problems/check-if-number-is-a-sum-of-powers-of-three) | Medium | +| 1779 | [Find Nearest Point That Has the Same X or Y Coordinate](https://leetcode.com/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate "找到最近的有相同 X 或 Y 坐标的点") | [Go](problems/find-nearest-point-that-has-the-same-x-or-y-coordinate) | Easy | +| 1778 | [Shortest Path in a Hidden Grid](https://leetcode.com/problems/shortest-path-in-a-hidden-grid) 🔒 | [Go](problems/shortest-path-in-a-hidden-grid) | Medium | +| 1777 | [Product's Price for Each Store](https://leetcode.com/problems/products-price-for-each-store "每家商店的产品价格") 🔒 | [MySQL](problems/products-price-for-each-store) | Easy | +| 1776 | [Car Fleet II](https://leetcode.com/problems/car-fleet-ii "车队 II") | [Go](problems/car-fleet-ii) | Hard | +| 1775 | [Equal Sum Arrays With Minimum Number of Operations](https://leetcode.com/problems/equal-sum-arrays-with-minimum-number-of-operations "通过最少操作次数使数组的和相等") | [Go](problems/equal-sum-arrays-with-minimum-number-of-operations) | Medium | +| 1774 | [Closest Dessert Cost](https://leetcode.com/problems/closest-dessert-cost "最接近目标价格的甜点成本") | [Go](problems/closest-dessert-cost) | Medium | +| 1773 | [Count Items Matching a Rule](https://leetcode.com/problems/count-items-matching-a-rule "统计匹配检索规则的物品数量") | [Go](problems/count-items-matching-a-rule) | Easy | +| 1772 | [Sort Features by Popularity](https://leetcode.com/problems/sort-features-by-popularity "按受欢迎程度排列功能") 🔒 | [Go](problems/sort-features-by-popularity) | Medium | | 1771 | [Maximize Palindrome Length From Subsequences](https://leetcode.com/problems/maximize-palindrome-length-from-subsequences "由子序列构造的最长回文串的长度") | [Go](problems/maximize-palindrome-length-from-subsequences) | Hard | | 1770 | [Maximum Score from Performing Multiplication Operations](https://leetcode.com/problems/maximum-score-from-performing-multiplication-operations "执行乘法运算的最大分数") | [Go](problems/maximum-score-from-performing-multiplication-operations) | Medium | | 1769 | [Minimum Number of Operations to Move All Balls to Each Box](https://leetcode.com/problems/minimum-number-of-operations-to-move-all-balls-to-each-box "移动所有球到每个盒子所需的最小操作数") | [Go](problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | Medium | @@ -79,13 +96,13 @@ LeetCode Problems' Solutions | 1765 | [Map of Highest Peak](https://leetcode.com/problems/map-of-highest-peak "地图中的最高点") | [Go](problems/map-of-highest-peak) | Medium | | 1764 | [Form Array by Concatenating Subarrays of Another Array](https://leetcode.com/problems/form-array-by-concatenating-subarrays-of-another-array "通过连接另一个数组的子数组得到一个数组") | [Go](problems/form-array-by-concatenating-subarrays-of-another-array) | Medium | | 1763 | [Longest Nice Substring](https://leetcode.com/problems/longest-nice-substring "最长的美好子字符串") | [Go](problems/longest-nice-substring) | Easy | -| 1762 | [Buildings With an Ocean View](https://leetcode.com/problems/buildings-with-an-ocean-view) 🔒 | [Go](problems/buildings-with-an-ocean-view) | Medium | +| 1762 | [Buildings With an Ocean View](https://leetcode.com/problems/buildings-with-an-ocean-view "能看到海景的建筑物") 🔒 | [Go](problems/buildings-with-an-ocean-view) | Medium | | 1761 | [Minimum Degree of a Connected Trio in a Graph](https://leetcode.com/problems/minimum-degree-of-a-connected-trio-in-a-graph "一个图中连通三元组的最小度数") | [Go](problems/minimum-degree-of-a-connected-trio-in-a-graph) | Hard | | 1760 | [Minimum Limit of Balls in a Bag](https://leetcode.com/problems/minimum-limit-of-balls-in-a-bag "袋子里最少数目的球") | [Go](problems/minimum-limit-of-balls-in-a-bag) | Medium | | 1759 | [Count Number of Homogenous Substrings](https://leetcode.com/problems/count-number-of-homogenous-substrings "统计同构子字符串的数目") | [Go](problems/count-number-of-homogenous-substrings) | Medium | | 1758 | [Minimum Changes To Make Alternating Binary String](https://leetcode.com/problems/minimum-changes-to-make-alternating-binary-string "生成交替二进制字符串的最少操作数") | [Go](problems/minimum-changes-to-make-alternating-binary-string) | Easy | -| 1757 | [Recyclable and Low Fat Products](https://leetcode.com/problems/recyclable-and-low-fat-products) 🔒 | [MySQL](problems/recyclable-and-low-fat-products) | Easy | -| 1756 | [Design Most Recently Used Queue](https://leetcode.com/problems/design-most-recently-used-queue) 🔒 | [Go](problems/design-most-recently-used-queue) | Medium | +| 1757 | [Recyclable and Low Fat Products](https://leetcode.com/problems/recyclable-and-low-fat-products "可回收且低脂的产品") 🔒 | [MySQL](problems/recyclable-and-low-fat-products) | Easy | +| 1756 | [Design Most Recently Used Queue](https://leetcode.com/problems/design-most-recently-used-queue "设计最近使用(MRU)队列") 🔒 | [Go](problems/design-most-recently-used-queue) | Medium | | 1755 | [Closest Subsequence Sum](https://leetcode.com/problems/closest-subsequence-sum "最接近目标值的子序列和") | [Go](problems/closest-subsequence-sum) | Hard | | 1754 | [Largest Merge Of Two Strings](https://leetcode.com/problems/largest-merge-of-two-strings "构造字典序最大的合并字符串") | [Go](problems/largest-merge-of-two-strings) | Medium | | 1753 | [Maximum Score From Removing Stones](https://leetcode.com/problems/maximum-score-from-removing-stones "移除石子的最大得分") | [Go](problems/maximum-score-from-removing-stones) | Medium | @@ -443,7 +460,7 @@ LeetCode Problems' Solutions | 1401 | [Circle and Rectangle Overlapping](https://leetcode.com/problems/circle-and-rectangle-overlapping "圆和矩形是否有重叠") | [Go](problems/circle-and-rectangle-overlapping) | Medium | | 1400 | [Construct K Palindrome Strings](https://leetcode.com/problems/construct-k-palindrome-strings "构造 K 个回文字符串") | [Go](problems/construct-k-palindrome-strings) | Medium | | 1399 | [Count Largest Group](https://leetcode.com/problems/count-largest-group "统计最大组的数目") | [Go](problems/count-largest-group) | Easy | -| 1398 | [Customers Who Bought Products A and B but Not C](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c "购买了产品A和产品B却没有购买产品C的顾客") 🔒 | [MySQL](problems/customers-who-bought-products-a-and-b-but-not-c) | Medium | +| 1398 | [Customers Who Bought Products A and B but Not C](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c "购买了产品 A 和产品 B 却没有购买产品 C 的顾客") 🔒 | [MySQL](problems/customers-who-bought-products-a-and-b-but-not-c) | Medium | | 1397 | [Find All Good Strings](https://leetcode.com/problems/find-all-good-strings "找到所有好字符串") | [Go](problems/find-all-good-strings) | Hard | | 1396 | [Design Underground System](https://leetcode.com/problems/design-underground-system "设计地铁系统") | [Go](problems/design-underground-system) | Medium | | 1395 | [Count Number of Teams](https://leetcode.com/problems/count-number-of-teams "统计作战单位数") | [Go](problems/count-number-of-teams) | Medium | diff --git a/problems/add-two-numbers/README.md b/problems/add-two-numbers/README.md index f1038803f..2648e97af 100644 --- a/problems/add-two-numbers/README.md +++ b/problems/add-two-numbers/README.md @@ -55,7 +55,7 @@ ### Similar Questions 1. [Multiply Strings](../multiply-strings) (Medium) 1. [Add Binary](../add-binary) (Easy) - 1. [Sum of Two Integers](../sum-of-two-integers) (Easy) + 1. [Sum of Two Integers](../sum-of-two-integers) (Medium) 1. [Add Strings](../add-strings) (Easy) 1. [Add Two Numbers II](../add-two-numbers-ii) (Medium) 1. [Add to Array-Form of Integer](../add-to-array-form-of-integer) (Easy) diff --git a/problems/all-possible-full-binary-trees/README.md b/problems/all-possible-full-binary-trees/README.md index 168409c86..b9d4707df 100644 --- a/problems/all-possible-full-binary-trees/README.md +++ b/problems/all-possible-full-binary-trees/README.md @@ -11,31 +11,32 @@ ## [894. All Possible Full Binary Trees (Medium)](https://leetcode.com/problems/all-possible-full-binary-trees "所有可能的满二叉树") -

    A full binary tree is a binary tree where each node has exactly 0 or 2 children.

    +

    Given an integer n, return a list of all possible full binary trees with n nodes. Each node of each tree in the answer must have Node.val == 0.

    -

    Return a list of all possible full binary trees with N nodes.  Each element of the answer is the root node of one possible tree.

    +

    Each element of the answer is the root node of one possible tree. You may return the final list of trees in any order.

    -

    Each node of each tree in the answer must have node.val = 0.

    - -

    You may return the final list of trees in any order.

    +

    A full binary tree is a binary tree where each node has exactly 0 or 2 children.

     

    -

    Example 1:

    + +
    +Input: n = 7
    +Output: [[0,0,0,null,null,0,0,null,null,0,0],[0,0,0,null,null,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,null,null,null,null,0,0],[0,0,0,0,0,null,null,0,0]]
    +
    + +

    Example 2:

    -Input: 7
    -Output: [[0,0,0,null,null,0,0,null,null,0,0],[0,0,0,null,null,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,null,null,null,null,0,0],[0,0,0,0,0,null,null,0,0]]
    -Explanation:
    -
    +Input: n = 3
    +Output: [[0,0,0]]
     

     

    - -

    Note:

    +

    Constraints:

      -
    • 1 <= N <= 20
    • +
    • 1 <= n <= 20
    ### Related Topics diff --git a/problems/arithmetic-slices/README.md b/problems/arithmetic-slices/README.md index 220578503..75d5d0a70 100644 --- a/problems/arithmetic-slices/README.md +++ b/problems/arithmetic-slices/README.md @@ -11,37 +11,40 @@ ## [413. Arithmetic Slices (Medium)](https://leetcode.com/problems/arithmetic-slices "等差数列划分") -

    A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.

    +

    An integer array is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.

    -

    For example, these are arithmetic sequences:

    +
      +
    • For example, [1,3,5,7,9], [7,7,7,7], and [3,-1,-5,-9] are arithmetic sequences.
    • +
    -
    -1, 3, 5, 7, 9
    -7, 7, 7, 7
    -3, -1, -5, -9
    - -

    The following sequence is not arithmetic.

    +

    Given an integer array nums, return the number of arithmetic subarrays of nums.

    -
    -1, 1, 2, 5, 7
    -  +

    A subarray is a contiguous subsequence of the array.

    -

    A zero-indexed array A consisting of N numbers is given. A slice of that array is any pair of integers (P, Q) such that 0 <= P < Q < N.

    +

     

    +

    Example 1:

    -

    A slice (P, Q) of the array A is called arithmetic if the sequence:
    -A[P], A[P + 1], ..., A[Q - 1], A[Q] is arithmetic. In particular, this means that P + 1 < Q.

    - -

    The function should return the number of arithmetic slices in the array A.

    -  +
    +Input: nums = [1,2,3,4]
    +Output: 3
    +Explanation: We have 3 arithmetic slices in nums: [1, 2, 3], [2, 3, 4] and [1,2,3,4] itself.
    +
    -

    Example:

    +

    Example 2:

    -A = [1, 2, 3, 4]
    -
    -return: 3, for 3 arithmetic slices in A: [1, 2, 3], [2, 3, 4] and [1, 2, 3, 4] itself.
    +Input: nums = [1]
    +Output: 0
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 5000
    • +
    • -1000 <= nums[i] <= 1000
    • +
    + ### Related Topics [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/available-captures-for-rook/README.md b/problems/available-captures-for-rook/README.md index 4ccfa4383..3e5962fd5 100644 --- a/problems/available-captures-for-rook/README.md +++ b/problems/available-captures-for-rook/README.md @@ -11,56 +11,46 @@ ## [999. Available Captures for Rook (Easy)](https://leetcode.com/problems/available-captures-for-rook "可以被一步捕获的棋子数") -

    On an 8 x 8 chessboard, there is one white rook.  There also may be empty squares, white bishops, and black pawns.  These are given as characters 'R', '.', 'B', and 'p' respectively. Uppercase characters represent white pieces, and lowercase characters represent black pieces.

    +

    On an 8 x 8 chessboard, there is exactly one white rook 'R' and some number of white bishops 'B', black pawns 'p', and empty squares '.'.

    -

    The rook moves as in the rules of Chess: it chooses one of four cardinal directions (north, east, west, and south), then moves in that direction until it chooses to stop, reaches the edge of the board, or captures an opposite colored pawn by moving to the same square it occupies.  Also, rooks cannot move into the same square as other friendly bishops.

    +

    When the rook moves, it chooses one of four cardinal directions (north, east, south, or west), then moves in that direction until it chooses to stop, reaches the edge of the board, captures a black pawn, or is blocked by a white bishop. A rook is considered attacking a pawn if the rook can capture the pawn on the rook's turn. The number of available captures for the white rook is the number of pawns that the rook is attacking.

    -

    Return the number of pawns the rook can capture in one move.

    +

    Return the number of available captures for the white rook.

     

    -

    Example 1:

    - -

    - +
    -Input: [[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".","R",".",".",".","p"],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."]]
    -Output: 3
    -Explanation: 
    -In this example the rook is able to capture all the pawns.
    +Input: board = [[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".","R",".",".",".","p"],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."]]
    +Output: 3
    +Explanation: In this example, the rook is attacking all the pawns.
     

    Example 2:

    - -

    - +
    -Input: [[".",".",".",".",".",".",".","."],[".","p","p","p","p","p",".","."],[".","p","p","B","p","p",".","."],[".","p","B","R","B","p",".","."],[".","p","p","B","p","p",".","."],[".","p","p","p","p","p",".","."],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."]]
    -Output: 0
    -Explanation: 
    -Bishops are blocking the rook to capture any pawn.
    +Input: board = [[".",".",".",".",".",".",".","."],[".","p","p","p","p","p",".","."],[".","p","p","B","p","p",".","."],[".","p","B","R","B","p",".","."],[".","p","p","B","p","p",".","."],[".","p","p","p","p","p",".","."],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."]]
    +Output: 0
    +Explanation: The bishops are blocking the rook from attacking any of the pawns.
     

    Example 3:

    - -

    - +
    -Input: [[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".","p",".",".",".","."],["p","p",".","R",".","p","B","."],[".",".",".",".",".",".",".","."],[".",".",".","B",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".",".",".",".",".","."]]
    -Output: 3
    -Explanation: 
    -The rook can capture the pawns at positions b5, d6 and f5.
    +Input: board = [[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".","p",".",".",".","."],["p","p",".","R",".","p","B","."],[".",".",".",".",".",".",".","."],[".",".",".","B",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".",".",".",".",".","."]]
    +Output: 3
    +Explanation: The rook is attacking the pawns at positions b5, d6, and f5.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. board.length == board[i].length == 8
    2. -
    3. board[i][j] is either 'R', '.', 'B', or 'p'
    4. +
        +
      • board.length == 8
      • +
      • board[i].length == 8
      • +
      • board[i][j] is either 'R', '.', 'B', or 'p'
      • There is exactly one cell with board[i][j] == 'R'
      • -
    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/average-of-levels-in-binary-tree/README.md b/problems/average-of-levels-in-binary-tree/README.md index da85b7d73..98c382d1f 100644 --- a/problems/average-of-levels-in-binary-tree/README.md +++ b/problems/average-of-levels-in-binary-tree/README.md @@ -11,27 +11,31 @@ ## [637. Average of Levels in Binary Tree (Easy)](https://leetcode.com/problems/average-of-levels-in-binary-tree "二叉树的层平均值") -Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. +Given the root of a binary tree, return the average value of the nodes on each level in the form of an array. Answers within 10-5 of the actual answer will be accepted. +

     

    +

    Example 1:

    + +
    +Input: root = [3,9,20,null,15,7]
    +Output: [3.00000,14.50000,11.00000]
    +Explanation: The average value of nodes on level 0 is 3, on level 1 is 14.5, and on level 2 is 11.
    +Hence return [3, 14.5, 11].
    +
    -

    Example 1:
    +

    Example 2:

    +
    -Input:
    -    3
    -   / \
    -  9  20
    -    /  \
    -   15   7
    -Output: [3, 14.5, 11]
    -Explanation:
    -The average value of nodes on level 0 is 3,  on level 1 is 14.5, and on level 2 is 11. Hence return [3, 14.5, 11].
    +Input: root = [3,9,20,15,7]
    +Output: [3.00000,14.50000,11.00000]
     
    -

    -

    Note:
    -

      -
    1. The range of node's value is in the range of 32-bit signed integer.
    2. -
    -

    +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [1, 104].
    • +
    • -231 <= Node.val <= 231 - 1
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/best-time-to-buy-and-sell-stock-ii/README.md b/problems/best-time-to-buy-and-sell-stock-ii/README.md index 94814f1bc..8052d1e8b 100644 --- a/problems/best-time-to-buy-and-sell-stock-ii/README.md +++ b/problems/best-time-to-buy-and-sell-stock-ii/README.md @@ -11,7 +11,7 @@ ## [122. Best Time to Buy and Sell Stock II (Easy)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii "买卖股票的最佳时机 II") -

    You are given an array prices for which the ith element is the price of a given stock on day i.

    +

    You are given an array prices where prices[i] is the price of a given stock on the ith day.

    Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times).

    diff --git a/problems/best-time-to-buy-and-sell-stock-iii/README.md b/problems/best-time-to-buy-and-sell-stock-iii/README.md index fccf2e5fe..47e162791 100644 --- a/problems/best-time-to-buy-and-sell-stock-iii/README.md +++ b/problems/best-time-to-buy-and-sell-stock-iii/README.md @@ -11,11 +11,11 @@ ## [123. Best Time to Buy and Sell Stock III (Hard)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii "买卖股票的最佳时机 III") -

    Say you have an array for which the ith element is the price of a given stock on day i.

    +

    You are given an array prices where prices[i] is the price of a given stock on the ith day.

    -

    Design an algorithm to find the maximum profit. You may complete at most two transactions.

    +

    Find the maximum profit you can achieve. You may complete at most two transactions.

    -

    Note: You may not engage in multiple transactions at the same time (i.e., you must sell the stock before you buy again).

    +

    Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).

     

    Example 1:

    @@ -54,8 +54,8 @@ Note that you cannot buy on day 1, buy on day 2 and sell them later, as you are

    Constraints:

      -
    • 1 <= prices.length <= 105
    • -
    • 0 <= prices[i] <= 105
    • +
    • 1 <= prices.length <= 105
    • +
    • 0 <= prices[i] <= 105
    ### Related Topics diff --git a/problems/best-time-to-buy-and-sell-stock-iv/README.md b/problems/best-time-to-buy-and-sell-stock-iv/README.md index 4eb4c93a2..5683ae33f 100644 --- a/problems/best-time-to-buy-and-sell-stock-iv/README.md +++ b/problems/best-time-to-buy-and-sell-stock-iv/README.md @@ -11,11 +11,11 @@ ## [188. Best Time to Buy and Sell Stock IV (Hard)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv "买卖股票的最佳时机 IV") -

    You are given an integer array prices where prices[i] is the price of a given stock on the ith day.

    +

    You are given an integer array prices where prices[i] is the price of a given stock on the ith day, and an integer k.

    -

    Design an algorithm to find the maximum profit. You may complete at most k transactions.

    +

    Find the maximum profit you can achieve. You may complete at most k transactions.

    -

    Notice that you may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).

    +

    Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).

     

    Example 1:

    diff --git a/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md b/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md index e57cb5155..98b415a4f 100644 --- a/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md +++ b/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md @@ -11,23 +11,40 @@ ## [309. Best Time to Buy and Sell Stock with Cooldown (Medium)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown "最佳买卖股票时机含冷冻期") -

    Say you have an array for which the ith element is the price of a given stock on day i.

    +

    You are given an array prices where prices[i] is the price of a given stock on the ith day.

    -

    Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times) with the following restrictions:

    +

    Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times) with the following restrictions:

      -
    • You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).
    • -
    • After you sell your stock, you cannot buy stock on next day. (ie, cooldown 1 day)
    • +
    • After you sell your stock, you cannot buy stock on the next day (i.e., cooldown one day).
    -

    Example:

    +

    Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).

    + +

     

    +

    Example 1:

    -Input: [1,2,3,0,2]
    -Output: 3 
    +Input: prices = [1,2,3,0,2]
    +Output: 3
     Explanation: transactions = [buy, sell, cooldown, buy, sell]
     
    +

    Example 2:

    + +
    +Input: prices = [1]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= prices.length <= 5000
    • +
    • 0 <= prices[i] <= 1000
    • +
    + ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md b/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md index b1ad894a5..858166250 100644 --- a/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md +++ b/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md @@ -11,24 +11,40 @@ ## [714. Best Time to Buy and Sell Stock with Transaction Fee (Medium)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee "买卖股票的最佳时机含手续费") -

    Your are given an array of integers prices, for which the i-th element is the price of a given stock on day i; and a non-negative integer fee representing a transaction fee.

    -

    You may complete as many transactions as you like, but you need to pay the transaction fee for each transaction. You may not buy more than 1 share of a stock at a time (ie. you must sell the stock share before you buy again.)

    -

    Return the maximum profit you can make.

    +

    You are given an array prices where prices[i] is the price of a given stock on the ith day, and an integer fee representing a transaction fee.

    + +

    Find the maximum profit you can achieve. You may complete as many transactions as you like, but you need to pay the transaction fee for each transaction.

    + +

    Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).

    + +

     

    +

    Example 1:

    + +
    +Input: prices = [1,3,2,8,4,9], fee = 2
    +Output: 8
    +Explanation: The maximum profit can be achieved by:
    +- Buying at prices[0] = 1
    +- Selling at prices[3] = 8
    +- Buying at prices[4] = 4
    +- Selling at prices[5] = 9
    +The total profit is ((8 - 1) - 2) + ((9 - 4) - 2) = 8.
    +
    + +

    Example 2:

    -

    Example 1:

    -Input: prices = [1, 3, 2, 8, 4, 9], fee = 2
    -Output: 8
    -Explanation: The maximum profit can be achieved by:
    -
  • Buying at prices[0] = 1
  • Selling at prices[3] = 8
  • Buying at prices[4] = 4
  • Selling at prices[5] = 9
  • The total profit is ((8 - 1) - 2) + ((9 - 4) - 2) = 8. +Input: prices = [1,3,7,5,10,3], fee = 3 +Output: 6
    -

    -

    Note: -

  • 0 < prices.length <= 50000.
  • -
  • 0 < prices[i] < 50000.
  • -
  • 0 <= fee < 50000.
  • -

    +

     

    +

    Constraints:

    + +
      +
    • 1 < prices.length <= 5 * 104
    • +
    • 0 < prices[i], fee < 5 * 104
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/binary-search-tree-iterator/README.md b/problems/binary-search-tree-iterator/README.md index 8254542ad..aaac3d2a1 100644 --- a/problems/binary-search-tree-iterator/README.md +++ b/problems/binary-search-tree-iterator/README.md @@ -11,7 +11,7 @@ ## [173. Binary Search Tree Iterator (Medium)](https://leetcode.com/problems/binary-search-tree-iterator "二叉搜索树迭代器") -

    Implement the BSTIterator class that represents an iterator over the in-order traversal of a binary search tree (BST):

    +

    Implement the BSTIterator class that represents an iterator over the in-order traversal of a binary search tree (BST):

    • BSTIterator(TreeNode root) Initializes an object of the BSTIterator class. The root of the BST is given as part of the constructor. The pointer should be initialized to a non-existent number smaller than any element in the BST.
    • @@ -21,7 +21,7 @@

      Notice that by initializing the pointer to a non-existent smallest number, the first call to next() will return the smallest element in the BST.

      -

      You may assume that next() calls will always be valid. That is, there will be at least a next number in the in-order traversal when next() is called.

      +

      You may assume that next() calls will always be valid. That is, there will be at least a next number in the in-order traversal when next() is called.

       

      Example 1:

      diff --git a/problems/binary-search/README.md b/problems/binary-search/README.md index 34d2cf28e..01078452d 100644 --- a/problems/binary-search/README.md +++ b/problems/binary-search/README.md @@ -11,35 +11,34 @@ ## [704. Binary Search (Easy)](https://leetcode.com/problems/binary-search "二分查找") -

      Given a sorted (in ascending order) integer array nums of n elements and a target value, write a function to search target in nums. If target exists, then return its index, otherwise return -1.

      +

      Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1.

      -


      -Example 1:

      +

       

      +

      Example 1:

      -Input: nums = [-1,0,3,5,9,12], target = 9
      +Input: nums = [-1,0,3,5,9,12], target = 9
       Output: 4
      -Explanation: 9 exists in nums and its index is 4
      -
      +Explanation: 9 exists in nums and its index is 4
       

      Example 2:

      -Input: nums = [-1,0,3,5,9,12], target = 2
      +Input: nums = [-1,0,3,5,9,12], target = 2
       Output: -1
      -Explanation: 2 does not exist in nums so return -1
      +Explanation: 2 does not exist in nums so return -1
       

       

      - -

      Note:

      - -
        -
      1. You may assume that all elements in nums are unique.
      2. -
      3. n will be in the range [1, 10000].
      4. -
      5. The value of each element in nums will be in the range [-9999, 9999].
      6. -
      +

      Constraints:

      + +
        +
      • 1 <= nums.length <= 104
      • +
      • -9999 <= nums[i], target <= 9999
      • +
      • All the integers in nums are unique.
      • +
      • nums is sorted in an ascending order.
      • +
      ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/binary-tree-tilt/README.md b/problems/binary-tree-tilt/README.md index 1f27ea1c0..508eecacf 100644 --- a/problems/binary-tree-tilt/README.md +++ b/problems/binary-tree-tilt/README.md @@ -24,7 +24,7 @@ Explanation: Tilt of node 2 : |0-0| = 0 (no children) Tilt of node 3 : |0-0| = 0 (no children) -Tile of node 1 : |2-3| = 1 (left subtree is just left child, so sum is 2; right subtree is just right child, so sum is 3) +Tilt of node 1 : |2-3| = 1 (left subtree is just left child, so sum is 2; right subtree is just right child, so sum is 3) Sum of every tilt : 0 + 0 + 1 = 1
    diff --git a/problems/bitwise-and-of-numbers-range/README.md b/problems/bitwise-and-of-numbers-range/README.md index cf9e4d9c7..fb838725c 100644 --- a/problems/bitwise-and-of-numbers-range/README.md +++ b/problems/bitwise-and-of-numbers-range/README.md @@ -11,20 +11,36 @@ ## [201. Bitwise AND of Numbers Range (Medium)](https://leetcode.com/problems/bitwise-and-of-numbers-range "数字范围按位与") -

    Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.

    +

    Given two integers left and right that represent the range [left, right], return the bitwise AND of all numbers in this range, inclusive.

    +

     

    Example 1:

    -Input: [5,7]
    +Input: left = 5, right = 7
     Output: 4
     

    Example 2:

    -Input: [0,1]
    -Output: 0
    +Input: left = 0, right = 0 +Output: 0 +
    + +

    Example 3:

    + +
    +Input: left = 1, right = 2147483647
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= left <= right <= 231 - 1
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/buddy-strings/README.md b/problems/buddy-strings/README.md index 9b53500ae..dff223507 100644 --- a/problems/buddy-strings/README.md +++ b/problems/buddy-strings/README.md @@ -11,56 +11,48 @@ ## [859. Buddy Strings (Easy)](https://leetcode.com/problems/buddy-strings "亲密字符串") -

    Given two strings A and B of lowercase letters, return true if you can swap two letters in A so the result is equal to B, otherwise, return false.

    +

    Given two strings a and b, return true if you can swap two letters in a so the result is equal to b, otherwise, return false.

    -

    Swapping letters is defined as taking two indices i and j (0-indexed) such that i != j and swapping the characters at A[i] and A[j]. For example, swapping at indices 0 and 2 in "abcd" results in "cbad".

    +

    Swapping letters is defined as taking two indices i and j (0-indexed) such that i != j and swapping the characters at a[i] and b[j]. For example, swapping at indices 0 and 2 in "abcd" results in "cbad".

     

    Example 1:

    -Input: A = "ab", B = "ba"
    +Input: a = "ab", b = "ba"
     Output: true
    -Explanation: You can swap A[0] = 'a' and A[1] = 'b' to get "ba", which is equal to B.
    +Explanation: You can swap a[0] = 'a' and a[1] = 'b' to get "ba", which is equal to b.
     

    Example 2:

    -Input: A = "ab", B = "ab"
    +Input: a = "ab", b = "ab"
     Output: false
    -Explanation: The only letters you can swap are A[0] = 'a' and A[1] = 'b', which results in "ba" != B.
    +Explanation: The only letters you can swap are a[0] = 'a' and a[1] = 'b', which results in "ba" != b.
     

    Example 3:

    -Input: A = "aa", B = "aa"
    +Input: a = "aa", b = "aa"
     Output: true
    -Explanation: You can swap A[0] = 'a' and A[1] = 'a' to get "aa", which is equal to B.
    +Explanation: You can swap a[0] = 'a' and a[1] = 'a' to get "aa", which is equal to b.
     

    Example 4:

    -Input: A = "aaaaaaabc", B = "aaaaaaacb"
    +Input: a = "aaaaaaabc", b = "aaaaaaacb"
     Output: true
     
    -

    Example 5:

    - -
    -Input: A = "", B = "aa"
    -Output: false
    -
    -

     

    Constraints:

      -
    • 0 <= A.length <= 20000
    • -
    • 0 <= B.length <= 20000
    • -
    • A and B consist of lowercase letters.
    • +
    • 1 <= a.length, b.length <= 2 * 104
    • +
    • a and b consist of lowercase letters.
    ### Related Topics diff --git a/problems/buildings-with-an-ocean-view/README.md b/problems/buildings-with-an-ocean-view/README.md index 6eaec32b0..694bb1f42 100644 --- a/problems/buildings-with-an-ocean-view/README.md +++ b/problems/buildings-with-an-ocean-view/README.md @@ -9,7 +9,7 @@                  [Next >](../longest-nice-substring "Longest Nice Substring") -## [1762. Buildings With an Ocean View (Medium)](https://leetcode.com/problems/buildings-with-an-ocean-view "") +## [1762. Buildings With an Ocean View (Medium)](https://leetcode.com/problems/buildings-with-an-ocean-view "能看到海景的建筑物") diff --git a/problems/car-fleet-ii/README.md b/problems/car-fleet-ii/README.md new file mode 100644 index 000000000..3ea5843a2 --- /dev/null +++ b/problems/car-fleet-ii/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../equal-sum-arrays-with-minimum-number-of-operations "Equal Sum Arrays With Minimum Number of Operations") +                 +[Next >](../products-price-for-each-store "Product's Price for Each Store") + +## [1776. Car Fleet II (Hard)](https://leetcode.com/problems/car-fleet-ii "车队 II") + +

    There are n cars traveling at different speeds in the same direction along a one-lane road. You are given an array cars of length n, where cars[i] = [positioni, speedi] represents:

    + +
      +
    • positioni is the distance between the ith car and the beginning of the road in meters. It is guaranteed that positioni < positioni+1.
    • +
    • speedi is the initial speed of the ith car in meters per second.
    • +
    + +

    For simplicity, cars can be considered as points moving along the number line. Two cars collide when they occupy the same position. Once a car collides with another car, they unite and form a single car fleet. The cars in the formed fleet will have the same position and the same speed, which is the initial speed of the slowest car in the fleet.

    + +

    Return an array answer, where answer[i] is the time, in seconds, at which the ith car collides with the next car, or -1 if the car does not collide with the next car. Answers within 10-5 of the actual answers are accepted.

    + +

     

    +

    Example 1:

    + +
    +Input: cars = [[1,2],[2,1],[4,3],[7,2]]
    +Output: [1.00000,-1.00000,3.00000,-1.00000]
    +Explanation: After exactly one second, the first car will collide with the second car, and form a car fleet with speed 1 m/s. After exactly 3 seconds, the third car will collide with the fourth car, and form a car fleet with speed 2 m/s.
    +
    + +

    Example 2:

    + +
    +Input: cars = [[3,4],[5,4],[6,3],[9,1]]
    +Output: [2.00000,1.00000,1.50000,-1.00000]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= cars.length <= 105
    • +
    • 1 <= positioni, speedi <= 106
    • +
    • positioni < positioni+1
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +We can simply ignore the merging of any car fleet, simply assume they cross each other. Now the aim is to find the first car to the right, which intersects with the current car before any other. +
    + +
    +Hint 2 +Assume we have already considered all cars to the right already, now the current car is to be considered. Let’s ignore all cars with speeds higher than the current car since the current car cannot intersect with those ones. Now, all cars to the right having speed strictly less than current car are to be considered. Now, for two cars c1 and c2 with positions p1 and p2 (p1 < p2) and speed s1 and s2 (s1 > s2), if c1 and c2 intersect before the current car and c2, then c1 can never be the first car of intersection for any car to the left of current car including current car. So we can remove that car from our consideration. +
    + +
    +Hint 3 +We can see that we can maintain candidate cars in this way using a stack, removing cars with speed greater than or equal to current car, and then removing cars which can never be first point of intersection. The first car after this process (if any) would be first point of intersection. +
    diff --git a/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md b/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md new file mode 100644 index 000000000..315722b60 --- /dev/null +++ b/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md @@ -0,0 +1,52 @@ + + + + + + + +[< Previous](../grand-slam-titles "Grand Slam Titles") +                 +[Next >](../minimum-elements-to-add-to-form-a-given-sum "Minimum Elements to Add to Form a Given Sum") + +## [1784. Check if Binary String Has at Most One Segment of Ones (Easy)](https://leetcode.com/problems/check-if-binary-string-has-at-most-one-segment-of-ones "检查二进制字符串字段") + +

    Given a binary string s ​​​​​without leading zeros, return true​​​ if s contains at most one contiguous segment of ones. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "1001"
    +Output: false
    +Explanation: The ones do not form a contiguous segment.
    +
    + +

    Example 2:

    + +
    +Input: s = "110"
    +Output: true
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 100
    • +
    • s[i]​​​​ is either '0' or '1'.
    • +
    • s[0] is '1'.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +It's guaranteed to have at least one segment +
    + +
    +Hint 2 +The string size is small so you can count all segments of ones with no that have no adjacent ones. +
    diff --git a/problems/check-if-number-is-a-sum-of-powers-of-three/README.md b/problems/check-if-number-is-a-sum-of-powers-of-three/README.md new file mode 100644 index 000000000..3ae982ed7 --- /dev/null +++ b/problems/check-if-number-is-a-sum-of-powers-of-three/README.md @@ -0,0 +1,63 @@ + + + + + + + +[< Previous](../find-nearest-point-that-has-the-same-x-or-y-coordinate "Find Nearest Point That Has the Same X or Y Coordinate") +                 +[Next >](../sum-of-beauty-of-all-substrings "Sum of Beauty of All Substrings") + +## [1780. Check if Number is a Sum of Powers of Three (Medium)](https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three "判断一个数字是否可以表示成三的幂的和") + +

    Given an integer n, return true if it is possible to represent n as the sum of distinct powers of three. Otherwise, return false.

    + +

    An integer y is a power of three if there exists an integer x such that y == 3x.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 12
    +Output: true
    +Explanation: 12 = 31 + 32
    +
    + +

    Example 2:

    + +
    +Input: n = 91
    +Output: true
    +Explanation: 91 = 30 + 32 + 34
    +
    + +

    Example 3:

    + +
    +Input: n = 21
    +Output: false
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 107
    • +
    + +### Related Topics + [[Recursion](../../tag/recursion/README.md)] + [[Math](../../tag/math/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
    +Hint 1 +Let's note that the maximum power of 3 you'll use in your soln is 3^16 +
    + +
    +Hint 2 +The number can not be represented as a sum of powers of 3 if it's ternary presentation has a 2 in it +
    diff --git a/problems/circular-array-loop/README.md b/problems/circular-array-loop/README.md index 64aa6188a..ae64092e9 100644 --- a/problems/circular-array-loop/README.md +++ b/problems/circular-array-loop/README.md @@ -9,52 +9,69 @@                  [Next >](../poor-pigs "Poor Pigs") -## [457. Circular Array Loop (Medium)](https://leetcode.com/problems/circular-array-loop "环形数组循环") +## [457. Circular Array Loop (Medium)](https://leetcode.com/problems/circular-array-loop "环形数组是否存在循环") -

    You are given a circular array nums of positive and negative integers. If a number k at an index is positive, then move forward k steps. Conversely, if it's negative (-k), move backward k steps. Since the array is circular, you may assume that the last element's next element is the first element, and the first element's previous element is the last element.

    +

    You are playing a game involving a circular array of non-zero integers nums. Each nums[i] denotes the number of indices forward/backward you must move if you are located at index i:

    -

    Determine if there is a loop (or a cycle) in nums. A cycle must start and end at the same index and the cycle's length > 1. Furthermore, movements in a cycle must all follow a single direction. In other words, a cycle must not consist of both forward and backward movements.

    +
      +
    • If nums[i] is positive, move nums[i] steps forward, and
    • +
    • If nums[i] is negative, move nums[i] steps backward.
    • +
    -

     

    +

    Since the array is circular, you may assume that moving forward from the last element puts you on the first element, and moving backwards from the first element puts you on the last element.

    + +

    A cycle in the array consists of a sequence of indices seq of length k where:

    + +
      +
    • Following the movement rules above results in the repeating index sequence seq[0] -> seq[1] -> ... -> seq[k - 1] -> seq[0] -> ...
    • +
    • Every nums[seq[j]] is either all positive or all negative.
    • +
    • k > 1
    • +
    -

    Example 1:

    +

    Return true if there is a cycle in nums, or false otherwise.

    + +

     

    +

    Example 1:

    -Input: [2,-1,1,2,2]
    -Output: true
    -Explanation: There is a cycle, from index 0 -> 2 -> 3 -> 0. The cycle's length is 3.
    +Input: nums = [2,-1,1,2,2]
    +Output: true
    +Explanation:
    +There is a cycle from index 0 -> 2 -> 3 -> 0 -> ...
    +The cycle's length is 3.
     
    -

    Example 2:

    +

    Example 2:

    -Input: [-1,2]
    -Output: false
    -Explanation: The movement from index 1 -> 1 -> 1 ... is not a cycle, because the cycle's length is 1. By definition the cycle's length must be greater than 1.
    +Input: nums = [-1,2]
    +Output: false
    +Explanation:
    +The sequence from index 1 -> 1 -> 1 -> ... is not a cycle because the sequence's length is 1.
    +By definition the sequence's length must be strictly greater than 1 to be a cycle.
     
    -

    Example 3:

    +

    Example 3:

    -Input: [-2,1,-1,-2,-2]
    -Output: false
    -Explanation: The movement from index 1 -> 2 -> 1 -> ... is not a cycle, because movement from index 1 -> 2 is a forward movement, but movement from index 2 -> 1 is a backward movement. All movements in a cycle must follow a single direction.
    +Input: nums = [-2,1,-1,-2,-2] +Output: false +Explanation: +The sequence from index 1 -> 2 -> 1 -> ... is not a cycle because nums[1] is positive, but nums[2] is negative. +Every nums[seq[j]] must be either all positive or all negative. +

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. -1000 ≤ nums[i] ≤ 1000
    2. -
    3. nums[i] ≠ 0
    4. -
    5. 1 ≤ nums.length ≤ 5000
    6. -
    +
      +
    • 1 <= nums.length <= 5000
    • +
    • -1000 <= nums[i] <= 1000
    • +
    • nums[i] != 0
    • +

     

    - -

    Follow up:

    - -

    Could you solve it in O(n) time complexity and O(1) extra space complexity?

    +

    Follow up: Could you solve it in O(n) time complexity and O(1) extra space complexity?

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/closest-dessert-cost/README.md b/problems/closest-dessert-cost/README.md new file mode 100644 index 000000000..89dcc5878 --- /dev/null +++ b/problems/closest-dessert-cost/README.md @@ -0,0 +1,93 @@ + + + + + + + +[< Previous](../count-items-matching-a-rule "Count Items Matching a Rule") +                 +[Next >](../equal-sum-arrays-with-minimum-number-of-operations "Equal Sum Arrays With Minimum Number of Operations") + +## [1774. Closest Dessert Cost (Medium)](https://leetcode.com/problems/closest-dessert-cost "最接近目标价格的甜点成本") + +

    You would like to make dessert and are preparing to buy the ingredients. You have n ice cream base flavors and m types of toppings to choose from. You must follow these rules when making your dessert:

    + +
      +
    • There must be exactly one ice cream base.
    • +
    • You can add one or more types of topping or have no toppings at all.
    • +
    • There are at most two of each type of topping.
    • +
    + +

    You are given three inputs:

    + +
      +
    • baseCosts, an integer array of length n, where each baseCosts[i] represents the price of the ith ice cream base flavor.
    • +
    • toppingCosts, an integer array of length m, where each toppingCosts[i] is the price of one of the ith topping.
    • +
    • target, an integer representing your target price for dessert.
    • +
    + +

    You want to make a dessert with a total cost as close to target as possible.

    + +

    Return the closest possible cost of the dessert to target. If there are multiple, return the lower one.

    + +

     

    +

    Example 1:

    + +
    +Input: baseCosts = [1,7], toppingCosts = [3,4], target = 10
    +Output: 10
    +Explanation: Consider the following combination (all 0-indexed):
    +- Choose base 1: cost 7
    +- Take 1 of topping 0: cost 1 x 3 = 3
    +- Take 0 of topping 1: cost 0 x 4 = 0
    +Total: 7 + 3 + 0 = 10.
    +
    + +

    Example 2:

    + +
    +Input: baseCosts = [2,3], toppingCosts = [4,5,100], target = 18
    +Output: 17
    +Explanation: Consider the following combination (all 0-indexed):
    +- Choose base 1: cost 3
    +- Take 1 of topping 0: cost 1 x 4 = 4
    +- Take 2 of topping 1: cost 2 x 5 = 10
    +- Take 0 of topping 2: cost 0 x 100 = 0
    +Total: 3 + 4 + 10 + 0 = 17. You cannot make a dessert with a total cost of 18.
    +
    + +

    Example 3:

    + +
    +Input: baseCosts = [3,10], toppingCosts = [2,5], target = 9
    +Output: 8
    +Explanation: It is possible to make desserts with cost 8 and 10. Return 8 as it is the lower cost.
    +
    + +

    Example 4:

    + +
    +Input: baseCosts = [10], toppingCosts = [1], target = 1
    +Output: 10
    +Explanation: Notice that you don't have to have any toppings, but you must have exactly one base.
    + +

     

    +

    Constraints:

    + +
      +
    • n == baseCosts.length
    • +
    • m == toppingCosts.length
    • +
    • 1 <= n, m <= 10
    • +
    • 1 <= baseCosts[i], toppingCosts[i] <= 104
    • +
    • 1 <= target <= 104
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +As the constraints are not large, you can brute force and enumerate all the possibilities. +
    diff --git a/problems/construct-binary-search-tree-from-preorder-traversal/README.md b/problems/construct-binary-search-tree-from-preorder-traversal/README.md index 31499290e..9e0f5594e 100644 --- a/problems/construct-binary-search-tree-from-preorder-traversal/README.md +++ b/problems/construct-binary-search-tree-from-preorder-traversal/README.md @@ -11,18 +11,27 @@ ## [1008. Construct Binary Search Tree from Preorder Traversal (Medium)](https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal "前序遍历构造二叉搜索树") -

    Return the root node of a binary search tree that matches the given preorder traversal.

    +

    Given an array of integers preorder, which represents the preorder traversal of a BST (i.e., binary search tree), construct the tree and return its root.

    -

    (Recall that a binary search tree is a binary tree where for every node, any descendant of node.left has a value < node.val, and any descendant of node.right has a value > node.val.  Also recall that a preorder traversal displays the value of the node first, then traverses node.left, then traverses node.right.)

    +

    It is guaranteed that there is always possible to find a binary search tree with the given requirements for the given test cases.

    -

    It's guaranteed that for the given test cases there is always possible to find a binary search tree with the given requirements.

    +

    A binary search tree is a binary tree where for every node, any descendant of Node.left has a value strictly less than Node.val, and any descendant of Node.right has a value strictly greater than Node.val.

    +

    A preorder traversal of a binary tree displays the value of the node first, then traverses Node.left, then traverses Node.right.

    + +

     

    Example 1:

    + +
    +Input: preorder = [8,5,1,7,10,12]
    +Output: [8,5,10,1,7,null,12]
    +
    + +

    Example 2:

    -Input: [8,5,1,7,10,12]
    -Output: [8,5,10,1,7,null,12]
    -
    +Input: preorder = [1,3]
    +Output: [1,null,3]
     

     

    @@ -30,8 +39,8 @@
    • 1 <= preorder.length <= 100
    • -
    • 1 <= preorder[i] <= 10^8
    • -
    • The values of preorder are distinct.
    • +
    • 1 <= preorder[i] <= 108
    • +
    • All the values of preorder are unique.
    ### Related Topics diff --git a/problems/container-with-most-water/README.md b/problems/container-with-most-water/README.md index b4bb591b6..dfdce6ead 100644 --- a/problems/container-with-most-water/README.md +++ b/problems/container-with-most-water/README.md @@ -11,9 +11,9 @@ ## [11. Container With Most Water (Medium)](https://leetcode.com/problems/container-with-most-water "盛最多水的容器") -

    Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.

    +

    Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.

    -

    Notice that you may not slant the container.

    +

    Notice that you may not slant the container.

     

    Example 1:

    @@ -50,8 +50,8 @@
    • n == height.length
    • -
    • 2 <= n <= 3 * 104
    • -
    • 0 <= height[i] <= 3 * 104
    • +
    • 2 <= n <= 105
    • +
    • 0 <= height[i] <= 104
    ### Related Topics diff --git a/problems/contains-duplicate-ii/README.md b/problems/contains-duplicate-ii/README.md index c90582922..0ccf3af4d 100644 --- a/problems/contains-duplicate-ii/README.md +++ b/problems/contains-duplicate-ii/README.md @@ -11,34 +11,38 @@ ## [219. Contains Duplicate II (Easy)](https://leetcode.com/problems/contains-duplicate-ii "存在重复元素 II") -

    Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is at most k.

    +

    Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k.

    -
    +

     

    Example 1:

    -Input: nums = [1,2,3,1], k = 3
    -Output: true
    +Input: nums = [1,2,3,1], k = 3
    +Output: true
     
    -

    Example 2:

    -Input: nums = [1,0,1,1], k = 1
    -Output: true
    +Input: nums = [1,0,1,1], k = 1
    +Output: true
     
    -

    Example 3:

    -Input: nums = [1,2,3,1,2,3], k = 2
    -Output: false
    +Input: nums = [1,2,3,1,2,3], k = 2
    +Output: false
     
    -
    -
    -
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • -109 <= nums[i] <= 109
    • +
    • 0 <= k <= 105
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/contains-duplicate-iii/README.md b/problems/contains-duplicate-iii/README.md index 620dba1a6..03b136785 100644 --- a/problems/contains-duplicate-iii/README.md +++ b/problems/contains-duplicate-iii/README.md @@ -11,7 +11,7 @@ ## [220. Contains Duplicate III (Medium)](https://leetcode.com/problems/contains-duplicate-iii "存在重复元素 III") -

    Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and nums[j] is at most t and the absolute difference between i and j is at most k.

    +

    Given an integer array nums and two integers k and t, return true if there are two distinct indices i and j in the array such that abs(nums[i] - nums[j]) <= t and abs(i - j) <= k.

     

    Example 1:

    @@ -29,7 +29,7 @@
    • 0 <= nums.length <= 2 * 104
    • -
    • -231 <= nums[i] <= 231 - 1
    • +
    • -231 <= nums[i] <= 231 - 1
    • 0 <= k <= 104
    • 0 <= t <= 231 - 1
    diff --git a/problems/contains-duplicate/README.md b/problems/contains-duplicate/README.md index 1a922e7cf..423ccf0e8 100644 --- a/problems/contains-duplicate/README.md +++ b/problems/contains-duplicate/README.md @@ -11,27 +11,26 @@ ## [217. Contains Duplicate (Easy)](https://leetcode.com/problems/contains-duplicate "存在重复元素") -

    Given an array of integers, find if the array contains any duplicates.

    - -

    Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct.

    +

    Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.

    +

     

    Example 1:

    - -
    -Input: [1,2,3,1]
    -Output: true
    - -

    Example 2:

    - -
    -Input: [1,2,3,4]
    -Output: false
    - -

    Example 3:

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

    Example 2:

    +
    Input: nums = [1,2,3,4]
    +Output: false
    +

    Example 3:

    +
    Input: nums = [1,1,1,3,3,4,3,2,4,2]
    +Output: true
    +
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • -109 <= nums[i] <= 109
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/corporate-flight-bookings/README.md b/problems/corporate-flight-bookings/README.md index dac77489e..ecc1f3221 100644 --- a/problems/corporate-flight-bookings/README.md +++ b/problems/corporate-flight-bookings/README.md @@ -11,11 +11,11 @@ ## [1109. Corporate Flight Bookings (Medium)](https://leetcode.com/problems/corporate-flight-bookings "航班预订统计") -

    There are n flights, and they are labeled from 1 to n.

    +

    There are n flights that are labeled from 1 to n.

    -

    We have a list of flight bookings.  The i-th booking bookings[i] = [i, j, k] means that we booked k seats from flights labeled i to j inclusive.

    +

    You are given an array of flight bookings bookings, where bookings[i] = [firsti, lasti, seatsi] represents a booking for flights firsti through lasti (inclusive) with seatsi seats reserved for each flight in the range.

    -

    Return an array answer of length n, representing the number of seats booked on each flight in order of their label.

    +

    Return an array answer of length n, where answer[i] is the total number of seats reserved for flight i.

     

    Example 1:

    @@ -23,15 +23,38 @@
     Input: bookings = [[1,2,10],[2,3,20],[2,5,25]], n = 5
     Output: [10,55,45,25,25]
    +Explanation:
    +Flight labels:        1   2   3   4   5
    +Booking 1 reserved:  10  10
    +Booking 2 reserved:      20  20
    +Booking 3 reserved:      25  25  25  25
    +Total seats:         10  55  45  25  25
    +Hence, answer = [10,55,45,25,25]
    +
    + +

    Example 2:

    + +
    +Input: bookings = [[1,2,10],[2,2,15]], n = 2
    +Output: [10,25]
    +Explanation:
    +Flight labels:        1   2
    +Booking 1 reserved:  10  10
    +Booking 2 reserved:      15
    +Total seats:         10  25
    +Hence, answer = [10,25]
    +
     

     

    Constraints:

      -
    • 1 <= bookings.length <= 20000
    • -
    • 1 <= bookings[i][0] <= bookings[i][1] <= n <= 20000
    • -
    • 1 <= bookings[i][2] <= 10000
    • +
    • 1 <= n <= 2 * 104
    • +
    • 1 <= bookings.length <= 2 * 104
    • +
    • bookings[i].length == 3
    • +
    • 1 <= firsti <= lasti <= n
    • +
    • 1 <= seatsi <= 104
    ### Related Topics diff --git a/problems/count-items-matching-a-rule/README.md b/problems/count-items-matching-a-rule/README.md new file mode 100644 index 000000000..06bc64a51 --- /dev/null +++ b/problems/count-items-matching-a-rule/README.md @@ -0,0 +1,60 @@ + + + + + + + +[< Previous](../sort-features-by-popularity "Sort Features by Popularity") +                 +[Next >](../closest-dessert-cost "Closest Dessert Cost") + +## [1773. Count Items Matching a Rule (Easy)](https://leetcode.com/problems/count-items-matching-a-rule "统计匹配检索规则的物品数量") + +

    You are given an array items, where each items[i] = [typei, colori, namei] describes the type, color, and name of the ith item. You are also given a rule represented by two strings, ruleKey and ruleValue.

    + +

    The ith item is said to match the rule if one of the following is true:

    + +
      +
    • ruleKey == "type" and ruleValue == typei.
    • +
    • ruleKey == "color" and ruleValue == colori.
    • +
    • ruleKey == "name" and ruleValue == namei.
    • +
    + +

    Return the number of items that match the given rule.

    + +

     

    +

    Example 1:

    + +
    +Input: items = [["phone","blue","pixel"],["computer","silver","lenovo"],["phone","gold","iphone"]], ruleKey = "color", ruleValue = "silver"
    +Output: 1
    +Explanation: There is only one item matching the given rule, which is ["computer","silver","lenovo"].
    +
    + +

    Example 2:

    + +
    +Input: items = [["phone","blue","pixel"],["computer","silver","phone"],["phone","gold","iphone"]], ruleKey = "type", ruleValue = "phone"
    +Output: 2
    +Explanation: There are only two items matching the given rule, which are ["phone","blue","pixel"] and ["phone","gold","iphone"]. Note that the item ["computer","silver","phone"] does not match.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= items.length <= 104
    • +
    • 1 <= typei.length, colori.length, namei.length, ruleValue.length <= 10
    • +
    • ruleKey is equal to either "type", "color", or "name".
    • +
    • All strings consist only of lowercase letters.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Iterate on each item, and check if each one matches the rule according to the statement. +
    diff --git a/problems/count-of-range-sum/README.md b/problems/count-of-range-sum/README.md index 580e72830..74429591c 100644 --- a/problems/count-of-range-sum/README.md +++ b/problems/count-of-range-sum/README.md @@ -11,26 +11,38 @@ ## [327. Count of Range Sum (Hard)](https://leetcode.com/problems/count-of-range-sum "区间和的个数") -

    Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive.
    -Range sum S(i, j) is defined as the sum of the elements in nums between indices i and j (ij), inclusive.

    +

    Given an integer array nums and two integers lower and upper, return the number of range sums that lie in [lower, upper] inclusive.

    -

    Note:
    -A naive algorithm of O(n2) is trivial. You MUST do better than that.

    +

    Range sum S(i, j) is defined as the sum of the elements in nums between indices i and j inclusive, where i <= j.

    -

    Example:

    +

     

    +

    Example 1:

    + +
    +Input: nums = [-2,5,-1], lower = -2, upper = 2
    +Output: 3
    +Explanation: The three ranges are: [0,0], [2,2], and [0,2] and their respective sums are: -2, -1, 2.
    +
    + +

    Example 2:

    -Input: nums = [-2,5,-1], lower = -2, upper = 2,
    -Output: 3 
    -Explanation: The three ranges are : [0,0], [2,2], [0,2] and their respective sums are: -2, -1, 2.
    +Input: nums = [0], lower = 0, upper = 0
    +Output: 1
     
    +

     

    Constraints:

      -
    • 0 <= nums.length <= 10^4
    • +
    • 1 <= nums.length <= 104
    • +
    • -231 <= nums[i] <= 231 - 1
    • +
    • -3 * 104 <= lower <= upper <= 3 * 104
    +

     

    +Follow up: A naive algorithm of O(n2) is trivial, Could you do better than that? + ### Related Topics [[Sort](../../tag/sort/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] diff --git a/problems/count-pairs-of-nodes/README.md b/problems/count-pairs-of-nodes/README.md new file mode 100644 index 000000000..a6cc82f6b --- /dev/null +++ b/problems/count-pairs-of-nodes/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../sum-of-beauty-of-all-substrings "Sum of Beauty of All Substrings") +                 +[Next >](../grand-slam-titles "Grand Slam Titles") + +## [1782. Count Pairs Of Nodes (Hard)](https://leetcode.com/problems/count-pairs-of-nodes "统计点对的数目") + +

    You are given an undirected graph represented by an integer n, which is the number of nodes, and edges, where edges[i] = [ui, vi] which indicates that there is an undirected edge between ui and vi. You are also given an integer array queries.

    + +

    The answer to the jth query is the number of pairs of nodes (a, b) that satisfy the following conditions:

    + +
      +
    • a < b
    • +
    • cnt is strictly greater than queries[j], where cnt is the number of edges incident to a or b.
    • +
    + +

    Return an array answers such that answers.length == queries.length and answers[j] is the answer of the jth query.

    + +

    Note that there can be repeated edges.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 4, edges = [[1,2],[2,4],[1,3],[2,3],[2,1]], queries = [2,3]
    +Output: [6,5]
    +Explanation: The number of edges incident to at least one of each pair is shown above.
    +
    + +

    Example 2:

    + +
    +Input: n = 5, edges = [[1,5],[1,5],[3,4],[2,5],[1,3],[5,1],[2,3],[2,5]], queries = [1,2,3,4,5]
    +Output: [10,10,9,8,6]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 2 * 104
    • +
    • 1 <= edges.length <= 105
    • +
    • 1 <= ui, vi <= n
    • +
    • ui != vi
    • +
    • 1 <= queries.length <= 20
    • +
    • 0 <= queries[j] < edges.length
    • +
    + +### Related Topics + [[Graph](../../tag/graph/README.md)] + +### Hints +
    +Hint 1 +We want to count pairs (x,y) such that degree[x] + degree[y] - occurrences(x,y) > k +
    + +
    +Hint 2 +Think about iterating on x, and counting the number of valid y to pair with x. +
    + +
    +Hint 3 +You can consider at first that the (- occurrences(x,y)) isn't there, or it is 0 at first for all y. Count the valid y this way. +
    + +
    +Hint 4 +Then you can iterate on the neighbors of x, let that neighbor be y, and update occurrences(x,y). +
    + +
    +Hint 5 +When you update occurrences(x,y), the left-hand side decreases. Once it reaches k, then y is not valid for x anymore, so you should decrease the answer by 1. +
    diff --git a/problems/counting-bits/README.md b/problems/counting-bits/README.md index e8d6a286b..e226ac9f9 100644 --- a/problems/counting-bits/README.md +++ b/problems/counting-bits/README.md @@ -11,27 +11,48 @@ ## [338. Counting Bits (Medium)](https://leetcode.com/problems/counting-bits "比特位计数") -

    Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.

    +

    Given an integer num, return an array of the number of 1's in the binary representation of every number in the range [0, num].

    +

     

    Example 1:

    -Input: 2
    -Output: [0,1,1]
    +Input: num = 2 +Output: [0,1,1] +Explanation: +0 --> 0 +1 --> 1 +2 --> 10 +

    Example 2:

    -Input: 5
    -Output: [0,1,1,2,1,2]
    +Input: num = 5
    +Output: [0,1,1,2,1,2]
    +Explanation:
    +0 --> 0
    +1 --> 1
    +2 --> 10
    +3 --> 11
    +4 --> 100
    +5 --> 101
     
    -

    Follow up:

    +

     

    +

    Constraints:

    + +
      +
    • 0 <= num <= 105
    • +
    + +

     

    +

    Follow up:

      -
    • It is very easy to come up with a solution with run time O(n*sizeof(integer)). But can you do it in linear time O(n) /possibly in a single pass?
    • -
    • Space complexity should be O(n).
    • -
    • Can you do it like a boss? Do it without using any builtin function like __builtin_popcount in c++ or in any other language.
    • +
    • It is very easy to come up with a solution with run time O(32n). Can you do it in linear time O(n) and possibly in a single pass?
    • +
    • Could you solve it in O(n) space complexity?
    • +
    • Can you do it without using any built-in function (i.e., like __builtin_popcount in C++)?
    ### Related Topics diff --git a/problems/customers-who-bought-products-a-and-b-but-not-c/README.md b/problems/customers-who-bought-products-a-and-b-but-not-c/README.md index 07a9674a7..ad22327ae 100644 --- a/problems/customers-who-bought-products-a-and-b-but-not-c/README.md +++ b/problems/customers-who-bought-products-a-and-b-but-not-c/README.md @@ -9,7 +9,7 @@                  [Next >](../count-largest-group "Count Largest Group") -## [1398. Customers Who Bought Products A and B but Not C (Medium)](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c "购买了产品A和产品B却没有购买产品C的顾客") +## [1398. Customers Who Bought Products A and B but Not C (Medium)](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c "购买了产品 A 和产品 B 却没有购买产品 C 的顾客")

    Table: Customers

    diff --git a/problems/deepest-leaves-sum/README.md b/problems/deepest-leaves-sum/README.md
    index eebaa5614..bd3d01c5a 100644
    --- a/problems/deepest-leaves-sum/README.md
    +++ b/problems/deepest-leaves-sum/README.md
    @@ -11,23 +11,28 @@
     
     ## [1302. Deepest Leaves Sum (Medium)](https://leetcode.com/problems/deepest-leaves-sum "层数最深叶子节点的和")
     
    -Given a binary tree, return the sum of values of its deepest leaves.
    +Given the root of a binary tree, return the sum of values of its deepest leaves.
     

     

    Example 1:

    - -

    - +
     Input: root = [1,2,3,4,5,null,6,7,null,null,null,null,8]
     Output: 15
     
    +

    Example 2:

    + +
    +Input: root = [6,7,8,2,7,1,3,9,null,1,4,null,null,null,5]
    +Output: 19
    +
    +

     

    Constraints:

      -
    • The number of nodes in the tree is between 1 and 10^4.
    • -
    • The value of nodes is between 1 and 100.
    • +
    • The number of nodes in the tree is in the range [1, 104].
    • +
    • 1 <= Node.val <= 100
    ### Related Topics diff --git a/problems/delete-nodes-and-return-forest/README.md b/problems/delete-nodes-and-return-forest/README.md index 5f6290874..a75659640 100644 --- a/problems/delete-nodes-and-return-forest/README.md +++ b/problems/delete-nodes-and-return-forest/README.md @@ -11,22 +11,27 @@ ## [1110. Delete Nodes And Return Forest (Medium)](https://leetcode.com/problems/delete-nodes-and-return-forest "删点成林") -

    Given the root of a binary tree, each node in the tree has a distinct value.

    +

    Given the root of a binary tree, each node in the tree has a distinct value.

    -

    After deleting all nodes with a value in to_delete, we are left with a forest (a disjoint union of trees).

    +

    After deleting all nodes with a value in to_delete, we are left with a forest (a disjoint union of trees).

    -

    Return the roots of the trees in the remaining forest.  You may return the result in any order.

    +

    Return the roots of the trees in the remaining forest. You may return the result in any order.

     

    Example 1:

    - -

    - +
     Input: root = [1,2,3,4,5,6,7], to_delete = [3,5]
     Output: [[1,2,null,4],[6],[7]]
     
    +

    Example 2:

    + +
    +Input: root = [1,2,4,null,3], to_delete = [3]
    +Output: [[1,2,4]]
    +
    +

     

    Constraints:

    diff --git a/problems/delete-operation-for-two-strings/README.md b/problems/delete-operation-for-two-strings/README.md index 436c2977a..a10bb31c4 100644 --- a/problems/delete-operation-for-two-strings/README.md +++ b/problems/delete-operation-for-two-strings/README.md @@ -11,24 +11,33 @@ ## [583. Delete Operation for Two Strings (Medium)](https://leetcode.com/problems/delete-operation-for-two-strings "两个字符串的删除操作") -

    -Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 the same, where in each step you can delete one character in either string. -

    +

    Given two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same.

    + +

    In one step, you can delete exactly one character in either string.

    + +

     

    +

    Example 1:

    + +
    +Input: word1 = "sea", word2 = "eat"
    +Output: 2
    +Explanation: You need one step to make "sea" to "ea" and another step to make "eat" to "ea".
    +
    + +

    Example 2:

    -

    Example 1:

    -Input: "sea", "eat"
    -Output: 2
    -Explanation: You need one step to make "sea" to "ea" and another step to make "eat" to "ea".
    +Input: word1 = "leetcode", word2 = "etco"
    +Output: 4
     
    -

    - -

    Note:
    -

      -
    1. The length of given words won't exceed 500.
    2. -
    3. Characters in given words can only be lower-case letters.
    4. -
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= word1.length, word2.length <= 500
    • +
    • word1 and word2 consist of only lowercase English letters.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/design-hashmap/README.md b/problems/design-hashmap/README.md index 1bcfdc4ac..d4234bdf2 100644 --- a/problems/design-hashmap/README.md +++ b/problems/design-hashmap/README.md @@ -11,40 +11,50 @@ ## [706. Design HashMap (Easy)](https://leetcode.com/problems/design-hashmap "设计哈希映射") -

    Design a HashMap without using any built-in hash table libraries.

    +

    Design a HashMap without using any built-in hash table libraries.

    -

    To be specific, your design should include these functions:

    +

    Implement the MyHashMap class:

      -
    • put(key, value) : Insert a (key, value) pair into the HashMap. If the value already exists in the HashMap, update the value.
    • -
    • get(key): Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key.
    • -
    • remove(key) : Remove the mapping for the value key if this map contains the mapping for the key.
    • +
    • MyHashMap() initializes the object with an empty map.
    • +
    • void put(int key, int value) inserts a (key, value) pair into the HashMap. If the key already exists in the map, update the corresponding value.
    • +
    • int get(int key) returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key.
    • +
    • void remove(key) removes the key and its corresponding value if the map contains the mapping for the key.
    -


    -Example:

    +

     

    +

    Example 1:

    -MyHashMap hashMap = new MyHashMap();
    -hashMap.put(1, 1);          
    -hashMap.put(2, 2);         
    -hashMap.get(1);            // returns 1
    -hashMap.get(3);            // returns -1 (not found)
    -hashMap.put(2, 1);          // update the existing value
    -hashMap.get(2);            // returns 1 
    -hashMap.remove(2);          // remove the mapping for 2
    -hashMap.get(2);            // returns -1 (not found) 
    +Input
    +["MyHashMap", "put", "put", "get", "get", "put", "get", "remove", "get"]
    +[[], [1, 1], [2, 2], [1], [3], [2, 1], [2], [2], [2]]
    +Output
    +[null, null, null, 1, -1, null, 1, null, -1]
    +
    +Explanation
    +MyHashMap myHashMap = new MyHashMap();
    +myHashMap.put(1, 1); // The map is now [[1,1]]
    +myHashMap.put(2, 2); // The map is now [[1,1], [2,2]]
    +myHashMap.get(1);    // return 1, The map is now [[1,1], [2,2]]
    +myHashMap.get(3);    // return -1 (i.e., not found), The map is now [[1,1], [2,2]]
    +myHashMap.put(2, 1); // The map is now [[1,1], [2,1]] (i.e., update the existing value)
    +myHashMap.get(2);    // return 1, The map is now [[1,1], [2,1]]
    +myHashMap.remove(2); // remove the mapping for 2, The map is now [[1,1]]
    +myHashMap.get(2);    // return -1 (i.e., not found), The map is now [[1,1]]
     
    -


    -Note:

    +

     

    +

    Constraints:

      -
    • All keys and values will be in the range of [0, 1000000].
    • -
    • The number of operations will be in the range of [1, 10000].
    • -
    • Please do not use the built-in HashMap library.
    • +
    • 0 <= key, value <= 106
    • +
    • At most 104 calls will be made to put, get, and remove.
    +

     

    +

    Follow up: Please do not use the built-in HashMap library.

    + ### Related Topics [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/design-linked-list/README.md b/problems/design-linked-list/README.md index a6737c41a..573e5df43 100644 --- a/problems/design-linked-list/README.md +++ b/problems/design-linked-list/README.md @@ -11,19 +11,19 @@ ## [707. Design Linked List (Medium)](https://leetcode.com/problems/design-linked-list "设计链表") -

    Design your implementation of the linked list. You can choose to use a singly or doubly linked list.
    -A node in a singly linked list should have two attributes: val and next. val is the value of the current node, and next is a pointer/reference to the next node.
    -If you want to use the doubly linked list, you will need one more attribute prev to indicate the previous node in the linked list. Assume all nodes in the linked list are 0-indexed.

    +

    Design your implementation of the linked list. You can choose to use a singly or doubly linked list.
    +A node in a singly linked list should have two attributes: val and next. val is the value of the current node, and next is a pointer/reference to the next node.
    +If you want to use the doubly linked list, you will need one more attribute prev to indicate the previous node in the linked list. Assume all nodes in the linked list are 0-indexed.

    -

    Implement the MyLinkedList class:

    +

    Implement the MyLinkedList class:

      -
    • MyLinkedList() Initializes the MyLinkedList object.
    • -
    • int get(int index) Get the value of the indexth node in the linked list. If the index is invalid, return -1.
    • -
    • void addAtHead(int val) Add a node of value val before the first element of the linked list. After the insertion, the new node will be the first node of the linked list.
    • -
    • void addAtTail(int val) Append a node of value val as the last element of the linked list.
    • -
    • void addAtIndex(int index, int val) Add a node of value val before the indexth node in the linked list. If index equals the length of the linked list, the node will be appended to the end of the linked list. If index is greater than the length, the node will not be inserted.
    • -
    • void deleteAtIndex(int index) Delete the indexth node in the linked list, if the index is valid.
    • +
    • MyLinkedList() Initializes the MyLinkedList object.
    • +
    • int get(int index) Get the value of the indexth node in the linked list. If the index is invalid, return -1.
    • +
    • void addAtHead(int val) Add a node of value val before the first element of the linked list. After the insertion, the new node will be the first node of the linked list.
    • +
    • void addAtTail(int val) Append a node of value val as the last element of the linked list.
    • +
    • void addAtIndex(int index, int val) Add a node of value val before the indexth node in the linked list. If index equals the length of the linked list, the node will be appended to the end of the linked list. If index is greater than the length, the node will not be inserted.
    • +
    • void deleteAtIndex(int index) Delete the indexth node in the linked list, if the index is valid.

     

    @@ -52,7 +52,7 @@ myLinkedList.get(1); // return 3
    • 0 <= index, val <= 1000
    • Please do not use the built-in LinkedList library.
    • -
    • At most 2000 calls will be made to getaddAtHeadaddAtTailaddAtIndex and deleteAtIndex.
    • +
    • At most 2000 calls will be made to get, addAtHead, addAtTail, addAtIndex and deleteAtIndex.
    ### Related Topics diff --git a/problems/design-most-recently-used-queue/README.md b/problems/design-most-recently-used-queue/README.md index 8f7116780..636c3c229 100644 --- a/problems/design-most-recently-used-queue/README.md +++ b/problems/design-most-recently-used-queue/README.md @@ -9,7 +9,7 @@                  [Next >](../recyclable-and-low-fat-products "Recyclable and Low Fat Products") -## [1756. Design Most Recently Used Queue (Medium)](https://leetcode.com/problems/design-most-recently-used-queue "") +## [1756. Design Most Recently Used Queue (Medium)](https://leetcode.com/problems/design-most-recently-used-queue "设计最近使用(MRU)队列") diff --git a/problems/diameter-of-binary-tree/README.md b/problems/diameter-of-binary-tree/README.md index 9a717ccc8..d4bbeb038 100644 --- a/problems/diameter-of-binary-tree/README.md +++ b/problems/diameter-of-binary-tree/README.md @@ -11,28 +11,35 @@ ## [543. Diameter of Binary Tree (Easy)](https://leetcode.com/problems/diameter-of-binary-tree "二叉树的直径") -

    -Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root. -

    +

    Given the root of a binary tree, return the length of the diameter of the tree.

    + +

    The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root.

    + +

    The length of a path between two nodes is represented by the number of edges between them.

    + +

     

    +

    Example 1:

    + +
    +Input: root = [1,2,3,4,5]
    +Output: 3
    +Explanation: 3is the length of the path [4,2,1,3] or [5,2,1,3].
    +
    + +

    Example 2:

    -

    -Example:
    -Given a binary tree

    -          1
    -         / \
    -        2   3
    -       / \     
    -      4   5    
    +Input: root = [1,2]
    +Output: 1
     
    -

    -

    -Return 3, which is the length of the path [4,2,1,3] or [5,2,1,3]. -

    - -

    Note: -The length of path between two nodes is represented by the number of edges between them. -

    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [1, 104].
    • +
    • -100 <= Node.val <= 100
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/divide-two-integers/README.md b/problems/divide-two-integers/README.md index 00b4dfb87..590405578 100644 --- a/problems/divide-two-integers/README.md +++ b/problems/divide-two-integers/README.md @@ -17,11 +17,7 @@

    The integer division should truncate toward zero, which means losing its fractional part. For example, truncate(8.345) = 8 and truncate(-2.7335) = -2.

    -

    Note:

    - -
      -
    • Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. For this problem, assume that your function returns 231 − 1 when the division result overflows.
    • -
    +

    Note: Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For this problem, assume that your function returns 231 − 1 when the division result overflows.

     

    Example 1:

    @@ -58,7 +54,7 @@

    Constraints:

      -
    • -231 <= dividend, divisor <= 231 - 1
    • +
    • -231 <= dividend, divisor <= 231 - 1
    • divisor != 0
    diff --git a/problems/equal-sum-arrays-with-minimum-number-of-operations/README.md b/problems/equal-sum-arrays-with-minimum-number-of-operations/README.md new file mode 100644 index 000000000..56b3bea92 --- /dev/null +++ b/problems/equal-sum-arrays-with-minimum-number-of-operations/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../closest-dessert-cost "Closest Dessert Cost") +                 +[Next >](../car-fleet-ii "Car Fleet II") + +## [1775. Equal Sum Arrays With Minimum Number of Operations (Medium)](https://leetcode.com/problems/equal-sum-arrays-with-minimum-number-of-operations "通过最少操作次数使数组的和相等") + +

    You are given two arrays of integers nums1 and nums2, possibly of different lengths. The values in the arrays are between 1 and 6, inclusive.

    + +

    In one operation, you can change any integer's value in any of the arrays to any value between 1 and 6, inclusive.

    + +

    Return the minimum number of operations required to make the sum of values in nums1 equal to the sum of values in nums2. Return -1​​​​​ if it is not possible to make the sum of the two arrays equal.

    + +

     

    +

    Example 1:

    + +
    +Input: nums1 = [1,2,3,4,5,6], nums2 = [1,1,2,2,2,2]
    +Output: 3
    +Explanation: You can make the sums of nums1 and nums2 equal with 3 operations. All indices are 0-indexed.
    +- Change nums2[0] to 6. nums1 = [1,2,3,4,5,6], nums2 = [6,1,2,2,2,2].
    +- Change nums1[5] to 1. nums1 = [1,2,3,4,5,1], nums2 = [6,1,2,2,2,2].
    +- Change nums1[2] to 2. nums1 = [1,2,2,4,5,1], nums2 = [6,1,2,2,2,2].
    +
    + +

    Example 2:

    + +
    +Input: nums1 = [1,1,1,1,1,1,1], nums2 = [6]
    +Output: -1
    +Explanation: There is no way to decrease the sum of nums1 or to increase the sum of nums2 to make them equal.
    +
    + +

    Example 3:

    + +
    +Input: nums1 = [6,6], nums2 = [1]
    +Output: 3
    +Explanation: You can make the sums of nums1 and nums2 equal with 3 operations. All indices are 0-indexed. 
    +- Change nums1[0] to 2. nums1 = [2,6], nums2 = [1].
    +- Change nums1[1] to 2. nums1 = [2,2], nums2 = [1].
    +- Change nums2[0] to 4. nums1 = [2,2], nums2 = [4].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums1.length, nums2.length <= 105
    • +
    • 1 <= nums1[i], nums2[i] <= 6
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Let's note that we want to either decrease the sum of the array with a larger sum or increase the array's sum with the smaller sum. +
    + +
    +Hint 2 +You can maintain the largest increase or decrease you can make in a binary search tree and each time get the maximum one. +
    diff --git a/problems/escape-a-large-maze/README.md b/problems/escape-a-large-maze/README.md index 0163227ef..8eb48d84f 100644 --- a/problems/escape-a-large-maze/README.md +++ b/problems/escape-a-large-maze/README.md @@ -11,11 +11,13 @@ ## [1036. Escape a Large Maze (Hard)](https://leetcode.com/problems/escape-a-large-maze "逃离大迷宫") -

    In a 1 million by 1 million grid, the coordinates of each grid square are (x, y).

    +

    There is a 1 million by 1 million grid on an XY-plane, and the coordinates of each grid square are (x, y).

    -

    We start at the source square and want to reach the target square.  Each move, we can walk to a 4-directionally adjacent square in the grid that isn't in the given list of blocked squares.

    +

    We start at the source = [sx, sy] square and want to reach the target = [tx, ty] square. There is also an array of blocked squares, where each blocked[i] = [xi, yi] represents a blocked square with coordinates (xi, yi).

    -

    Return true if and only if it is possible to reach the target square through a sequence of moves.

    +

    Each move, we can walk one square north, east, south, or west if the square is not in the array of blocked squares. We are also not allowed to walk outside of the grid.

    + +

    Return true if and only if it is possible to reach the target square from the source square through a sequence of valid moves.

     

    Example 1:

    @@ -23,7 +25,9 @@
     Input: blocked = [[0,1],[1,0]], source = [0,0], target = [0,2]
     Output: false
    -Explanation: The target square is inaccessible starting from the source square, because we can't walk outside the grid.
    +Explanation: The target square is inaccessible starting from the source square because we cannot move.
    +We cannot move north or east because those squares are blocked.
    +We cannot move south or west because we cannot go outside of the grid.
     

    Example 2:

    @@ -31,7 +35,7 @@
     Input: blocked = [], source = [0,0], target = [999999,999999]
     Output: true
    -Explanation: Because there are no blocked cells, it's possible to reach the target square.
    +Explanation: Because there are no blocked cells, it is possible to reach the target square.
     

     

    @@ -40,10 +44,11 @@
    • 0 <= blocked.length <= 200
    • blocked[i].length == 2
    • -
    • 0 <= blocked[i][j] < 10^6
    • +
    • 0 <= xi, yi < 106
    • source.length == target.length == 2
    • -
    • 0 <= source[i][j], target[i][j] < 10^6
    • +
    • 0 <= sx, sy, tx, ty < 106
    • source != target
    • +
    • It is guaranteed that source and target are not blocked.
    ### Related Topics diff --git a/problems/evaluate-reverse-polish-notation/README.md b/problems/evaluate-reverse-polish-notation/README.md index 8517d4438..15146320e 100644 --- a/problems/evaluate-reverse-polish-notation/README.md +++ b/problems/evaluate-reverse-polish-notation/README.md @@ -13,19 +13,17 @@

    Evaluate the value of an arithmetic expression in Reverse Polish Notation.

    -

    Valid operators are +, -, *, /. Each operand may be an integer or another expression.

    +

    Valid operators are +, -, *, and /. Each operand may be an integer or another expression.

    -

    Note:

    +

    Note that division between two integers should truncate toward zero.

    -
      -
    • Division between two integers should truncate toward zero.
    • -
    • The given RPN expression is always valid. That means the expression would always evaluate to a result and there won't be any divide by zero operation.
    • -
    +

    It is guaranteed that the given RPN expression is always valid. That means the expression would always evaluate to a result, and there will not be any division by zero operation.

    +

     

    Example 1:

    -Input: ["2", "1", "+", "3", "*"]
    +Input: tokens = ["2","1","+","3","*"]
     Output: 9
     Explanation: ((2 + 1) * 3) = 9
     
    @@ -33,7 +31,7 @@

    Example 2:

    -Input: ["4", "13", "5", "/", "+"]
    +Input: tokens = ["4","13","5","/","+"]
     Output: 6
     Explanation: (4 + (13 / 5)) = 6
     
    @@ -41,10 +39,9 @@

    Example 3:

    -Input: ["10", "6", "9", "3", "+", "-11", "*", "/", "*", "17", "+", "5", "+"]
    +Input: tokens = ["10","6","9","3","+","-11","*","/","*","17","+","5","+"]
     Output: 22
    -Explanation: 
    -  ((10 * (6 / ((9 + 3) * -11))) + 17) + 5
    +Explanation: ((10 * (6 / ((9 + 3) * -11))) + 17) + 5
     = ((10 * (6 / (12 * -11))) + 17) + 5
     = ((10 * (6 / -132)) + 17) + 5
     = ((10 * 0) + 17) + 5
    @@ -53,6 +50,14 @@
     = 22
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= tokens.length <= 104
    • +
    • tokens[i] is either an operator: "+", "-", "*", or "/", or an integer in the range [-200, 200].
    • +
    + ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/excel-sheet-column-number/README.md b/problems/excel-sheet-column-number/README.md index cc8d7ae28..9700b3966 100644 --- a/problems/excel-sheet-column-number/README.md +++ b/problems/excel-sheet-column-number/README.md @@ -11,48 +11,57 @@ ## [171. Excel Sheet Column Number (Easy)](https://leetcode.com/problems/excel-sheet-column-number "Excel表列序号") -

    Given a column title as appear in an Excel sheet, return its corresponding column number.

    +

    Given a string columnTitle that represents the column title as appear in an Excel sheet, return its corresponding column number.

    For example:

    -    A -> 1
    -    B -> 2
    -    C -> 3
    -    ...
    -    Z -> 26
    -    AA -> 27
    -    AB -> 28 
    -    ...
    +A -> 1
    +B -> 2
    +C -> 3
    +...
    +Z -> 26
    +AA -> 27
    +AB -> 28 
    +...
     
    +

     

    Example 1:

    -Input: "A"
    +Input: columnTitle = "A"
     Output: 1
     

    Example 2:

    -Input: "AB"
    +Input: columnTitle = "AB"
     Output: 28
     

    Example 3:

    -Input: "ZY"
    +Input: columnTitle = "ZY"
     Output: 701
     
    + +

    Example 4:

    + +
    +Input: columnTitle = "FXSHRXW"
    +Output: 2147483647
    +
    +

     

    Constraints:

      -
    • 1 <= s.length <= 7
    • -
    • s consists only of uppercase English letters.
    • -
    • s is between "A" and "FXSHRXW".
    • +
    • 1 <= columnTitle.length <= 7
    • +
    • columnTitle consists only of uppercase English letters.
    • +
    • columnTitle is in the range ["A", "FXSHRXW"].
    ### Related Topics diff --git a/problems/excel-sheet-column-title/README.md b/problems/excel-sheet-column-title/README.md index 9992a826c..afe10387f 100644 --- a/problems/excel-sheet-column-title/README.md +++ b/problems/excel-sheet-column-title/README.md @@ -11,42 +11,57 @@ ## [168. Excel Sheet Column Title (Easy)](https://leetcode.com/problems/excel-sheet-column-title "Excel表列名称") -

    Given a positive integer, return its corresponding column title as appear in an Excel sheet.

    +

    Given an integer columnNumber, return its corresponding column title as it appears in an Excel sheet.

    For example:

    -    1 -> A
    -    2 -> B
    -    3 -> C
    -    ...
    -    26 -> Z
    -    27 -> AA
    -    28 -> AB 
    -    ...
    +A -> 1
    +B -> 2
    +C -> 3
    +...
    +Z -> 26
    +AA -> 27
    +AB -> 28 
    +...
     
    +

     

    Example 1:

    -Input: 1
    +Input: columnNumber = 1
     Output: "A"
     

    Example 2:

    -Input: 28
    +Input: columnNumber = 28
     Output: "AB"
     

    Example 3:

    -Input: 701
    +Input: columnNumber = 701
     Output: "ZY"
     
    +

    Example 4:

    + +
    +Input: columnNumber = 2147483647
    +Output: "FXSHRXW"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= columnNumber <= 231 - 1
    • +
    + ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/find-minimum-in-rotated-sorted-array-ii/README.md b/problems/find-minimum-in-rotated-sorted-array-ii/README.md index 322b4d2d7..97759c93e 100644 --- a/problems/find-minimum-in-rotated-sorted-array-ii/README.md +++ b/problems/find-minimum-in-rotated-sorted-array-ii/README.md @@ -11,33 +11,38 @@ ## [154. Find Minimum in Rotated Sorted Array II (Hard)](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii "寻找旋转排序数组中的最小值 II") -

    Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.

    +

    Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,4,4,5,6,7] might become:

    -

    (i.e.,  [0,1,2,4,5,6,7] might become  [4,5,6,7,0,1,2]).

    +
      +
    • [4,5,6,7,0,1,4] if it was rotated 4 times.
    • +
    • [0,1,4,4,5,6,7] if it was rotated 7 times.
    • +
    -

    Find the minimum element.

    +

    Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in the array [a[n-1], a[0], a[1], a[2], ..., a[n-2]].

    -

    The array may contain duplicates.

    +

    Given the sorted rotated array nums that may contain duplicates, return the minimum element of this array.

    +

     

    Example 1:

    - -
    -Input: [1,3,5]
    -Output: 1
    - -

    Example 2:

    - -
    -Input: [2,2,2,0,1]
    -Output: 0
    - -

    Note:

    +
    Input: nums = [1,3,5]
    +Output: 1
    +

    Example 2:

    +
    Input: nums = [2,2,2,0,1]
    +Output: 0
    +
    +

     

    +

    Constraints:

      -
    • This is a follow up problem to Find Minimum in Rotated Sorted Array.
    • -
    • Would allow duplicates affect the run-time complexity? How and why?
    • +
    • n == nums.length
    • +
    • 1 <= n <= 5000
    • +
    • -5000 <= nums[i] <= 5000
    • +
    • nums is sorted and rotated between 1 and n times.
    +

     

    +Follow up: This is the same as Find Minimum in Rotated Sorted Array but with duplicates. Would allow duplicates affect the run-time complexity? How and why? + ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/find-minimum-in-rotated-sorted-array/README.md b/problems/find-minimum-in-rotated-sorted-array/README.md index b7a6c720e..aade6faf9 100644 --- a/problems/find-minimum-in-rotated-sorted-array/README.md +++ b/problems/find-minimum-in-rotated-sorted-array/README.md @@ -20,7 +20,7 @@

    Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in the array [a[n-1], a[0], a[1], a[2], ..., a[n-2]].

    -

    Given the sorted rotated array nums, return the minimum element of this array.

    +

    Given the sorted rotated array nums of unique elements, return the minimum element of this array.

     

    Example 1:

    diff --git a/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md b/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md new file mode 100644 index 000000000..870808615 --- /dev/null +++ b/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md @@ -0,0 +1,58 @@ + + + + + + + +[< Previous](../shortest-path-in-a-hidden-grid "Shortest Path in a Hidden Grid") +                 +[Next >](../check-if-number-is-a-sum-of-powers-of-three "Check if Number is a Sum of Powers of Three") + +## [1779. Find Nearest Point That Has the Same X or Y Coordinate (Easy)](https://leetcode.com/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate "找到最近的有相同 X 或 Y 坐标的点") + +

    You are given two integers, x and y, which represent your current location on a Cartesian grid: (x, y). You are also given an array points where each points[i] = [ai, bi] represents that a point exists at (ai, bi). A point is valid if it shares the same x-coordinate or the same y-coordinate as your location.

    + +

    Return the index (0-indexed) of the valid point with the smallest Manhattan distance from your current location. If there are multiple, return the valid point with the smallest index. If there are no valid points, return -1.

    + +

    The Manhattan distance between two points (x1, y1) and (x2, y2) is abs(x1 - x2) + abs(y1 - y2).

    + +

     

    +

    Example 1:

    + +
    +Input: x = 3, y = 4, points = [[1,2],[3,1],[2,4],[2,3],[4,4]]
    +Output: 2
    +Explanation: Of all the points, only [3,1], [2,4] and [4,4] are valid. Of the valid points, [2,4] and [4,4] have the smallest Manhattan distance from your current location, with a distance of 1. [2,4] has the smallest index, so return 2.
    + +

    Example 2:

    + +
    +Input: x = 3, y = 4, points = [[3,4]]
    +Output: 0
    +Explanation: The answer is allowed to be on the same location as your current location.
    + +

    Example 3:

    + +
    +Input: x = 3, y = 4, points = [[2,3]]
    +Output: -1
    +Explanation: There are no valid points.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= points.length <= 104
    • +
    • points[i].length == 2
    • +
    • 1 <= x, y, ai, bi <= 104
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Iterate through each point, and keep track of the current point with the smallest Manhattan distance from your current location. +
    diff --git a/problems/find-pivot-index/README.md b/problems/find-pivot-index/README.md index 3ba48f5f0..9774506f1 100644 --- a/problems/find-pivot-index/README.md +++ b/problems/find-pivot-index/README.md @@ -9,7 +9,7 @@                  [Next >](../split-linked-list-in-parts "Split Linked List in Parts") -## [724. Find Pivot Index (Easy)](https://leetcode.com/problems/find-pivot-index "寻找数组的中心索引") +## [724. Find Pivot Index (Easy)](https://leetcode.com/problems/find-pivot-index "寻找数组的中心下标")

    Given an array of integers nums, calculate the pivot index of this array.

    diff --git a/problems/flip-columns-for-maximum-number-of-equal-rows/README.md b/problems/flip-columns-for-maximum-number-of-equal-rows/README.md index eb25ef95a..836d48166 100644 --- a/problems/flip-columns-for-maximum-number-of-equal-rows/README.md +++ b/problems/flip-columns-for-maximum-number-of-equal-rows/README.md @@ -11,55 +11,46 @@ ## [1072. Flip Columns For Maximum Number of Equal Rows (Medium)](https://leetcode.com/problems/flip-columns-for-maximum-number-of-equal-rows "按列翻转得到最大值等行数") -

    Given a matrix consisting of 0s and 1s, we may choose any number of columns in the matrix and flip every cell in that column.  Flipping a cell changes the value of that cell from 0 to 1 or from 1 to 0.

    +

    You are given an m x n binary matrix matrix.

    -

    Return the maximum number of rows that have all values equal after some number of flips.

    +

    You can choose any number of columns in the matrix and flip every cell in that column (i.e., Change the value of the cell from 0 to 1 or vice versa).

    -

     

    - -
      -
    +

    Return the maximum number of rows that have all values equal after some number of flips.

    -
    +

     

    Example 1:

    -Input: [[0,1],[1,1]]
    -Output: 1
    -Explanation: After flipping no values, 1 row has all values equal.
    +Input: matrix = [[0,1],[1,1]]
    +Output: 1
    +Explanation: After flipping no values, 1 row has all values equal.
     
    -

    Example 2:

    -Input: [[0,1],[1,0]]
    -Output: 2
    -Explanation: After flipping values in the first column, both rows have equal values.
    +Input: matrix = [[0,1],[1,0]]
    +Output: 2
    +Explanation: After flipping values in the first column, both rows have equal values.
     
    -

    Example 3:

    -Input: [[0,0,0],[0,0,1],[1,1,0]]
    -Output: 2
    -Explanation: After flipping values in the first two columns, the last two rows have equal values.
    +Input: matrix = [[0,0,0],[0,0,1],[1,1,0]]
    +Output: 2
    +Explanation: After flipping values in the first two columns, the last two rows have equal values.
     

     

    - -

    Note:

    - -
      -
    1. 1 <= matrix.length <= 300
    2. -
    3. 1 <= matrix[i].length <= 300
    4. -
    5. All matrix[i].length's are equal
    6. -
    7. matrix[i][j] is 0 or 1
    8. -
    -
    -
    -
    +

    Constraints:

    + +
      +
    • m == matrix.length
    • +
    • n == matrix[i].length
    • +
    • 1 <= m, n <= 300
    • +
    • matrix[i][j] is either 0 or 1.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/flipping-an-image/README.md b/problems/flipping-an-image/README.md index a15791ada..5bf0dcf57 100644 --- a/problems/flipping-an-image/README.md +++ b/problems/flipping-an-image/README.md @@ -11,17 +11,26 @@ ## [832. Flipping an Image (Easy)](https://leetcode.com/problems/flipping-an-image "翻转图像") -

    Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image.

    +

    Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image.

    -

    To flip an image horizontally means that each row of the image is reversed.  For example, flipping [1, 1, 0] horizontally results in [0, 1, 1].

    +

    To flip an image horizontally means that each row of the image is reversed.

    -

    To invert an image means that each 0 is replaced by 1, and each 1 is replaced by 0. For example, inverting [0, 1, 1] results in [1, 0, 0].

    +
      +
    • For example, flipping [1,1,0] horizontally results in [0,1,1].
    • +
    + +

    To invert an image means that each 0 is replaced by 1, and each 1 is replaced by 0.

    + +
      +
    • For example, inverting [0,1,1] results in [1,0,0].
    • +
    +

     

    Example 1:

    -Input: [[1,1,0],[1,0,1],[0,0,0]]
    -Output: [[1,0,0],[0,1,0],[1,1,1]]
    +Input: image = [[1,1,0],[1,0,1],[0,0,0]]
    +Output: [[1,0,0],[0,1,0],[1,1,1]]
     Explanation: First reverse each row: [[0,1,1],[1,0,1],[0,0,0]].
     Then, invert the image: [[1,0,0],[0,1,0],[1,1,1]]
     
    @@ -29,17 +38,20 @@ Then, invert the image: [[1,0,0],[0,1,0],[1,1,1]]

    Example 2:

    -Input: [[1,1,0,0],[1,0,0,1],[0,1,1,1],[1,0,1,0]]
    -Output: [[1,1,0,0],[0,1,1,0],[0,0,0,1],[1,0,1,0]]
    +Input: image = [[1,1,0,0],[1,0,0,1],[0,1,1,1],[1,0,1,0]]
    +Output: [[1,1,0,0],[0,1,1,0],[0,0,0,1],[1,0,1,0]]
     Explanation: First reverse each row: [[0,0,1,1],[1,0,0,1],[1,1,1,0],[0,1,0,1]].
     Then invert the image: [[1,1,0,0],[0,1,1,0],[0,0,0,1],[1,0,1,0]]
     
    -

    Notes:

    +

     

    +

    Constraints:

      -
    • 1 <= A.length = A[0].length <= 20
    • -
    • 0 <= A[i][j] <= 1
    • +
    • n == image.length
    • +
    • n == image[i].length
    • +
    • 1 <= n <= 20
    • +
    • images[i][j] is either 0 or 1.
    ### Related Topics diff --git a/problems/grand-slam-titles/README.md b/problems/grand-slam-titles/README.md new file mode 100644 index 000000000..cb4e14e5b --- /dev/null +++ b/problems/grand-slam-titles/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../count-pairs-of-nodes "Count Pairs Of Nodes") +                 +[Next >](../check-if-binary-string-has-at-most-one-segment-of-ones "Check if Binary String Has at Most One Segment of Ones") + +## [1783. Grand Slam Titles (Medium)](https://leetcode.com/problems/grand-slam-titles "") + + diff --git a/problems/grand-slam-titles/mysql_schemas.sql b/problems/grand-slam-titles/mysql_schemas.sql new file mode 100644 index 000000000..dd19af729 --- /dev/null +++ b/problems/grand-slam-titles/mysql_schemas.sql @@ -0,0 +1,10 @@ +Create table If Not Exists Players (player_id int, player_name varchar(20)); +Create table If Not Exists Championships (year int, Wimbledon int, Fr_open int, US_open int, Au_open int); +Truncate table Players; +insert into Players (player_id, player_name) values ('1', 'Nadal'); +insert into Players (player_id, player_name) values ('2', 'Federer'); +insert into Players (player_id, player_name) values ('3', 'Novak'); +Truncate table Championships; +insert into Championships (year, Wimbledon, Fr_open, US_open, Au_open) values ('2018', '1', '1', '1', '1'); +insert into Championships (year, Wimbledon, Fr_open, US_open, Au_open) values ('2019', '1', '1', '2', '2'); +insert into Championships (year, Wimbledon, Fr_open, US_open, Au_open) values ('2020', '2', '1', '2', '2'); diff --git a/problems/h-index-ii/README.md b/problems/h-index-ii/README.md index d501faf00..791166a18 100644 --- a/problems/h-index-ii/README.md +++ b/problems/h-index-ii/README.md @@ -11,31 +11,42 @@ ## [275. H-Index II (Medium)](https://leetcode.com/problems/h-index-ii "H 指数 II") -

    Given an array of citations sorted in ascending order (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.

    +

    Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper and citations is sorted in an ascending order, return compute the researcher's h-index.

    -

    According to the definition of h-index on Wikipedia: "A scientist has index h if h of his/her N papers have at least h citations each, and the other N − h papers have no more than citations each."

    +

    According to the definition of h-index on Wikipedia: A scientist has an index h if h of their n papers have at least h citations each, and the other n − h papers have no more than h citations each.

    -

    Example:

    +

    If there are several possible values for h, the maximum one is taken as the h-index.

    + +

     

    +

    Example 1:

    -Input: citations = [0,1,3,5,6]
    -Output: 3 
    -Explanation: [0,1,3,5,6] means the researcher has 5 papers in total and each of them had 
    -             received 0, 1, 3, 5, 6 citations respectively. 
    -             Since the researcher has 3 papers with at least 3 citations each and the remaining 
    -             two with no more than 3 citations each, her h-index is 3.
    +Input: citations = [0,1,3,5,6] +Output: 3 +Explanation: [0,1,3,5,6] means the researcher has 5 papers in total and each of them had received 0, 1, 3, 5, 6 citations respectively. +Since the researcher has 3 papers with at least 3 citations each and the remaining two with no more than 3 citations each, their h-index is 3. +
    -

    Note:

    +

    Example 2:

    -

    If there are several possible values for h, the maximum one is taken as the h-index.

    +
    +Input: citations = [1,2,100]
    +Output: 0
    +
    -

    Follow up:

    +

     

    +

    Constraints:

      -
    • This is a follow up problem to H-Index, where citations is now guaranteed to be sorted in ascending order.
    • -
    • Could you solve it in logarithmic time complexity?
    • +
    • n == citations.length
    • +
    • 1 <= n <= 105
    • +
    • 0 <= citations[i] <= 1000
    • +
    • citations is sorted in ascending order.
    +

     

    +

    Follow up: Could you solve it in logarithmic time complexity?

    + ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/h-index/README.md b/problems/h-index/README.md index 734b667b4..fde6daec3 100644 --- a/problems/h-index/README.md +++ b/problems/h-index/README.md @@ -11,21 +11,37 @@ ## [274. H-Index (Medium)](https://leetcode.com/problems/h-index "H 指数") -

    Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.

    +

    Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper, return compute the researcher's h-index.

    -

    According to the definition of h-index on Wikipedia: "A scientist has index h if h of his/her N papers have at least h citations each, and the other N − h papers have no more than h citations each."

    +

    According to the definition of h-index on Wikipedia: A scientist has an index h if h of their n papers have at least h citations each, and the other n − h papers have no more than h citations each.

    -

    Example:

    +

    If there are several possible values for h, the maximum one is taken as the h-index.

    + +

     

    +

    Example 1:

    + +
    +Input: citations = [3,0,6,1,5]
    +Output: 3
    +Explanation: [3,0,6,1,5] means the researcher has 5 papers in total and each of them had received 3, 0, 6, 1, 5 citations respectively.
    +Since the researcher has 3 papers with at least 3 citations each and the remaining two with no more than 3 citations each, their h-index is 3.
    +
    + +

    Example 2:

    -Input: citations = [3,0,6,1,5]
    -Output: 3 
    -Explanation: [3,0,6,1,5] means the researcher has 5 papers in total and each of them had 
    -             received 3, 0, 6, 1, 5 citations respectively. 
    -             Since the researcher has 3 papers with at least 3 citations each and the remaining 
    -             two with no more than 3 citations each, her h-index is 3.
    - -

    Note: If there are several possible values for h, the maximum one is taken as the h-index.

    +Input: citations = [1,3,1] +Output: 1 + + +

     

    +

    Constraints:

    + +
      +
    • n == citations.length
    • +
    • 1 <= n <= 5000
    • +
    • 0 <= citations[i] <= 1000
    • +
    ### Related Topics [[Sort](../../tag/sort/README.md)] diff --git a/problems/house-robber-ii/README.md b/problems/house-robber-ii/README.md index 08afb0147..815191ce6 100644 --- a/problems/house-robber-ii/README.md +++ b/problems/house-robber-ii/README.md @@ -54,7 +54,7 @@ Total amount you can rob = 1 + 3 = 4. ### Similar Questions 1. [House Robber](../house-robber) (Medium) 1. [Paint House](../paint-house) (Medium) - 1. [Paint Fence](../paint-fence) (Easy) + 1. [Paint Fence](../paint-fence) (Medium) 1. [House Robber III](../house-robber-iii) (Medium) 1. [Non-negative Integers without Consecutive Ones](../non-negative-integers-without-consecutive-ones) (Hard) 1. [Coin Path](../coin-path) (Hard) diff --git a/problems/house-robber-iii/README.md b/problems/house-robber-iii/README.md index 67ac3eb50..32cd66c87 100644 --- a/problems/house-robber-iii/README.md +++ b/problems/house-robber-iii/README.md @@ -11,42 +11,41 @@ ## [337. House Robber III (Medium)](https://leetcode.com/problems/house-robber-iii "打家劫舍 III") -

    The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that "all houses in this place forms a binary tree". It will automatically contact the police if two directly-linked houses were broken into on the same night.

    +

    The thief has found himself a new place for his thievery again. There is only one entrance to this area, called root.

    -

    Determine the maximum amount of money the thief can rob tonight without alerting the police.

    +

    Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will automatically contact the police if two directly-linked houses were broken into on the same night.

    -

    Example 1:

    +

    Given the root of the binary tree, return the maximum amount of money the thief can rob without alerting the police.

    +

     

    +

    Example 1:

    +
    -Input: [3,2,3,null,3,null,1]
    -
    -     3
    -    / \
    -   2   3
    -    \   \ 
    -     3   1
    -
    -Output: 7 
    -Explanation: Maximum amount of money the thief can rob = 3 + 3 + 1 = 7.
    - -

    Example 2:

    +Input: root = [3,2,3,null,3,null,1] +Output: 7 +Explanation: Maximum amount of money the thief can rob = 3 + 3 + 1 = 7. + +

    Example 2:

    +
    -Input: [3,4,5,1,3,null,1]
    -
    -     3
    -    / \
    -   4   5
    -  / \   \ 
    - 1   3   1
    -
    +Input: root = [3,4,5,1,3,null,1]
     Output: 9
    -Explanation: Maximum amount of money the thief can rob = 4 + 5 = 9.
    +Explanation: Maximum amount of money the thief can rob = 4 + 5 = 9.
     
    +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [1, 104].
    • +
    • 0 <= Node.val <= 104
    • +
    + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [House Robber](../house-robber) (Medium) diff --git a/problems/house-robber/README.md b/problems/house-robber/README.md index 004111de6..c44764161 100644 --- a/problems/house-robber/README.md +++ b/problems/house-robber/README.md @@ -11,9 +11,9 @@ ## [198. House Robber (Medium)](https://leetcode.com/problems/house-robber "打家劫舍") -

    You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.

    +

    You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected and it will automatically contact the police if two adjacent houses were broken into on the same night.

    -

    Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police.

    +

    Given an integer array nums representing the amount of money of each house, return the maximum amount of money you can rob tonight without alerting the police.

     

    Example 1:

    @@ -22,7 +22,7 @@ Input: nums = [1,2,3,1] Output: 4 Explanation: Rob house 1 (money = 1) and then rob house 3 (money = 3). -  Total amount you can rob = 1 + 3 = 4. +Total amount you can rob = 1 + 3 = 4.

    Example 2:

    @@ -31,14 +31,14 @@ Input: nums = [2,7,9,3,1] Output: 12 Explanation: Rob house 1 (money = 2), rob house 3 (money = 9) and rob house 5 (money = 1). -  Total amount you can rob = 2 + 9 + 1 = 12. +Total amount you can rob = 2 + 9 + 1 = 12.

     

    Constraints:

      -
    • 0 <= nums.length <= 100
    • +
    • 1 <= nums.length <= 100
    • 0 <= nums[i] <= 400
    @@ -49,7 +49,7 @@ 1. [Maximum Product Subarray](../maximum-product-subarray) (Medium) 1. [House Robber II](../house-robber-ii) (Medium) 1. [Paint House](../paint-house) (Medium) - 1. [Paint Fence](../paint-fence) (Easy) + 1. [Paint Fence](../paint-fence) (Medium) 1. [House Robber III](../house-robber-iii) (Medium) 1. [Non-negative Integers without Consecutive Ones](../non-negative-integers-without-consecutive-ones) (Hard) 1. [Coin Path](../coin-path) (Hard) diff --git a/problems/implement-trie-prefix-tree/README.md b/problems/implement-trie-prefix-tree/README.md index 00bcce42e..d740026d7 100644 --- a/problems/implement-trie-prefix-tree/README.md +++ b/problems/implement-trie-prefix-tree/README.md @@ -11,26 +11,44 @@ ## [208. Implement Trie (Prefix Tree) (Medium)](https://leetcode.com/problems/implement-trie-prefix-tree "实现 Trie (前缀树)") -

    Implement a trie with insert, search, and startsWith methods.

    +

    Trie (we pronounce "try") or prefix tree is a tree data structure used to retrieve a key in a strings dataset. There are various applications of this very efficient data structure, such as autocomplete and spellchecker.

    -

    Example:

    +

    Implement the Trie class:

    + +
      +
    • Trie() initializes the trie object.
    • +
    • void insert(String word) inserts the string word to the trie.
    • +
    • boolean search(String word) returns true if the string word is in the trie (i.e., was inserted before), and false otherwise.
    • +
    • boolean startsWith(String prefix) returns true if there is a previously inserted string word that has the prefix prefix, and false otherwise.
    • +
    + +

     

    +

    Example 1:

    -Trie trie = new Trie();
    +Input
    +["Trie", "insert", "search", "search", "startsWith", "insert", "search"]
    +[[], ["apple"], ["apple"], ["app"], ["app"], ["app"], ["app"]]
    +Output
    +[null, null, true, false, true, null, true]
     
    +Explanation
    +Trie trie = new Trie();
     trie.insert("apple");
    -trie.search("apple");   // returns true
    -trie.search("app");     // returns false
    -trie.startsWith("app"); // returns true
    -trie.insert("app");   
    -trie.search("app");     // returns true
    +trie.search("apple");   // return True
    +trie.search("app");     // return False
    +trie.startsWith("app"); // return True
    +trie.insert("app");
    +trie.search("app");     // return True
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • You may assume that all inputs are consist of lowercase letters a-z.
    • -
    • All inputs are guaranteed to be non-empty strings.
    • +
    • 1 <= word.length, prefix.length <= 2000
    • +
    • word and prefix consist of lowercase English letters.
    • +
    • At most 3 * 104 calls will be made to insert, search, and startsWith.
    ### Related Topics diff --git a/problems/inorder-successor-in-bst/README.md b/problems/inorder-successor-in-bst/README.md index 649abbec5..11fc3ef36 100644 --- a/problems/inorder-successor-in-bst/README.md +++ b/problems/inorder-successor-in-bst/README.md @@ -9,7 +9,7 @@                  [Next >](../walls-and-gates "Walls and Gates") -## [285. Inorder Successor in BST (Medium)](https://leetcode.com/problems/inorder-successor-in-bst "二叉搜索树中的顺序后继") +## [285. Inorder Successor in BST (Medium)](https://leetcode.com/problems/inorder-successor-in-bst "二叉搜索树中的中序后继")

    Given a binary search tree and a node in it, find the in-order successor of that node in the BST.

    diff --git a/problems/insertion-sort-list/README.md b/problems/insertion-sort-list/README.md index e91075c57..2de949f40 100644 --- a/problems/insertion-sort-list/README.md +++ b/problems/insertion-sort-list/README.md @@ -11,42 +11,41 @@ ## [147. Insertion Sort List (Medium)](https://leetcode.com/problems/insertion-sort-list "对链表进行插入排序") -

    Sort a linked list using insertion sort.

    +

    Given the head of a singly linked list, sort the list using insertion sort, and return the sorted list's head.

    -
      -
    - -


    -A graphical example of insertion sort. The partial sorted list (black) initially contains only the first element in the list.
    -With each iteration one element (red) is removed from the input data and inserted in-place into the sorted list

    +

    The steps of the insertion sort algorithm:

      -
    - -

    Algorithm of Insertion Sort:

    - -
      -
    1. Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list.
    2. -
    3. At each iteration, insertion sort removes one element from the input data, finds the location it belongs within the sorted list, and inserts it there.
    4. +
    5. Insertion sort iterates, consuming one input element each repetition and growing a sorted output list.
    6. +
    7. At each iteration, insertion sort removes one element from the input data, finds the location it belongs within the sorted list and inserts it there.
    8. It repeats until no input elements remain.
    -


    -Example 1:

    - +

    The following is a graphical example of the insertion sort algorithm. The partially sorted list (black) initially contains only the first element in the list. One element (red) is removed from the input data and inserted in-place into the sorted list with each iteration.

    + +

     

    +

    Example 1:

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

    Example 2:

    - +
    -Input: -1->5->3->4->0
    -Output: -1->0->3->4->5
    +Input: head = [-1,5,3,4,0]
    +Output: [-1,0,3,4,5]
     
    +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is in the range [1, 5000].
    • +
    • -5000 <= Node.val <= 5000
    • +
    + ### Related Topics [[Sort](../../tag/sort/README.md)] [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/intersection-of-two-linked-lists/README.md b/problems/intersection-of-two-linked-lists/README.md index 3e7090f99..35ee928a9 100644 --- a/problems/intersection-of-two-linked-lists/README.md +++ b/problems/intersection-of-two-linked-lists/README.md @@ -11,58 +11,59 @@ ## [160. Intersection of Two Linked Lists (Easy)](https://leetcode.com/problems/intersection-of-two-linked-lists "相交链表") -

    Write a program to find the node at which the intersection of two singly linked lists begins.

    +

    Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersection at all, return null.

    -

    For example, the following two linked lists:

    - +

    For example, the following two linked lists begin to intersect at node c1:

    + +

    It is guaranteed that there are no cycles anywhere in the entire linked structure.

    -

    begin to intersect at node c1.

    +

    Note that the linked lists must retain their original structure after the function returns.

     

    -

    Example 1:

    - - +
    -Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,6,1,8,4,5], skipA = 2, skipB = 3
    -Output: Reference of the node with value = 8
    -Input Explanation: The intersected node's value is 8 (note that this must not be 0 if the two lists intersect). From the head of A, it reads as [4,1,8,4,5]. From the head of B, it reads as [5,6,1,8,4,5]. There are 2 nodes before the intersected node in A; There are 3 nodes before the intersected node in B.
    - -

     

    +Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,6,1,8,4,5], skipA = 2, skipB = 3 +Output: Intersected at '8' +Explanation: The intersected node's value is 8 (note that this must not be 0 if the two lists intersect). +From the head of A, it reads as [4,1,8,4,5]. From the head of B, it reads as [5,6,1,8,4,5]. There are 2 nodes before the intersected node in A; There are 3 nodes before the intersected node in B. +

    Example 2:

    - - +
    -Input: intersectVal = 2, listA = [1,9,1,2,4], listB = [3,2,4], skipA = 3, skipB = 1
    -Output: Reference of the node with value = 2
    -Input Explanation: The intersected node's value is 2 (note that this must not be 0 if the two lists intersect). From the head of A, it reads as [1,9,1,2,4]. From the head of B, it reads as [3,2,4]. There are 3 nodes before the intersected node in A; There are 1 node before the intersected node in B.
    +Input: intersectVal = 2, listA = [1,9,1,2,4], listB = [3,2,4], skipA = 3, skipB = 1
    +Output: Intersected at '2'
    +Explanation: The intersected node's value is 2 (note that this must not be 0 if the two lists intersect).
    +From the head of A, it reads as [1,9,1,2,4]. From the head of B, it reads as [3,2,4]. There are 3 nodes before the intersected node in A; There are 1 node before the intersected node in B.
     
    -

     

    -

    Example 3:

    - - +
    -Input: intersectVal = 0, listA = [2,6,4], listB = [1,5], skipA = 3, skipB = 2
    -Output: null
    -Input Explanation: From the head of A, it reads as [2,6,4]. From the head of B, it reads as [1,5]. Since the two lists do not intersect, intersectVal must be 0, while skipA and skipB can be arbitrary values.
    -Explanation: The two lists do not intersect, so return null.
    +Input: intersectVal = 0, listA = [2,6,4], listB = [1,5], skipA = 3, skipB = 2
    +Output: No intersection
    +Explanation: From the head of A, it reads as [2,6,4]. From the head of B, it reads as [1,5]. Since the two lists do not intersect, intersectVal must be 0, while skipA and skipB can be arbitrary values.
    +Explanation: The two lists do not intersect, so return null.
     

     

    - -

    Notes:

    +

    Constraints:

      -
    • If the two linked lists have no intersection at all, return null.
    • -
    • The linked lists must retain their original structure after the function returns.
    • -
    • You may assume there are no cycles anywhere in the entire linked structure.
    • -
    • Each value on each linked list is in the range [1, 10^9].
    • -
    • Your code should preferably run in O(n) time and use only O(1) memory.
    • +
    • The number of nodes of listA is in the m.
    • +
    • The number of nodes of listB is in the n.
    • +
    • 1 <= m, n <= 3 * 104
    • +
    • 1 <= Node.val <= 105
    • +
    • 1 <= skipA <= m
    • +
    • 1 <= skipB <= n
    • +
    • intersectVal is 0 if listA and listB do not intersect.
    • +
    • intersectVal == listA[skipA + 1] == listB[skipB + 1] if listA and listB intersect.
    +

     

    +Follow up: Could you write a solution that runs in O(n) time and use only O(1) memory? + ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/jump-game-ii/README.md b/problems/jump-game-ii/README.md index 17fa35682..ac0e0385c 100644 --- a/problems/jump-game-ii/README.md +++ b/problems/jump-game-ii/README.md @@ -9,7 +9,7 @@                  [Next >](../permutations "Permutations") -## [45. Jump Game II (Hard)](https://leetcode.com/problems/jump-game-ii "跳跃游戏 II") +## [45. Jump Game II (Medium)](https://leetcode.com/problems/jump-game-ii "跳跃游戏 II")

    Given an array of non-negative integers nums, you are initially positioned at the first index of the array.

    @@ -39,7 +39,7 @@

    Constraints:

      -
    • 1 <= nums.length <= 3 * 104
    • +
    • 1 <= nums.length <= 1000
    • 0 <= nums[i] <= 105
    diff --git a/problems/jump-game/README.md b/problems/jump-game/README.md index b0d1ac8b7..391a3b615 100644 --- a/problems/jump-game/README.md +++ b/problems/jump-game/README.md @@ -47,4 +47,4 @@ [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Jump Game II](../jump-game-ii) (Hard) + 1. [Jump Game II](../jump-game-ii) (Medium) diff --git a/problems/k-closest-points-to-origin/README.md b/problems/k-closest-points-to-origin/README.md index 4ae0f6d86..4f273231d 100644 --- a/problems/k-closest-points-to-origin/README.md +++ b/problems/k-closest-points-to-origin/README.md @@ -11,47 +11,40 @@ ## [973. K Closest Points to Origin (Medium)](https://leetcode.com/problems/k-closest-points-to-origin "最接近原点的 K 个点") -

    We have a list of points on the plane.  Find the K closest points to the origin (0, 0).

    +

    Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0).

    -

    (Here, the distance between two points on a plane is the Euclidean distance.)

    +

    The distance between two points on the X-Y plane is the Euclidean distance (i.e, √(x1 - x2)2 + (y1 - y2)2).

    -

    You may return the answer in any order.  The answer is guaranteed to be unique (except for the order that it is in.)

    +

    You may return the answer in any order. The answer is guaranteed to be unique (except for the order that it is in).

     

    - -

    Example 1:

    - +
    -Input: points = [[1,3],[-2,2]], K = 1
    -Output: [[-2,2]]
    -Explanation: 
    +Input: points = [[1,3],[-2,2]], k = 1
    +Output: [[-2,2]]
    +Explanation:
     The distance between (1, 3) and the origin is sqrt(10).
     The distance between (-2, 2) and the origin is sqrt(8).
     Since sqrt(8) < sqrt(10), (-2, 2) is closer to the origin.
    -We only want the closest K = 1 points from the origin, so the answer is just [[-2,2]].
    +We only want the closest k = 1 points from the origin, so the answer is just [[-2,2]].
     
    -

    Example 2:

    -Input: points = [[3,3],[5,-1],[-2,4]], K = 2
    -Output: [[3,3],[-2,4]]
    -(The answer [[-2,4],[3,3]] would also be accepted.)
    +Input: points = [[3,3],[5,-1],[-2,4]], k = 2
    +Output: [[3,3],[-2,4]]
    +Explanation: The answer [[-2,4],[3,3]] would also be accepted.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= K <= points.length <= 10000
    2. -
    3. -10000 < points[i][0] < 10000
    4. -
    5. -10000 < points[i][1] < 10000
    6. -
    -
    -
    +
      +
    • 1 <= k <= points.length <= 104
    • +
    • -104 < xi, yi < 104
    • +
    ### Related Topics [[Heap](../../tag/heap/README.md)] diff --git a/problems/kill-process/README.md b/problems/kill-process/README.md index 3df553616..fc8bf6ef2 100644 --- a/problems/kill-process/README.md +++ b/problems/kill-process/README.md @@ -9,7 +9,7 @@                  [Next >](../delete-operation-for-two-strings "Delete Operation for Two Strings") -## [582. Kill Process (Medium)](https://leetcode.com/problems/kill-process "杀死进程") +## [582. Kill Process (Medium)](https://leetcode.com/problems/kill-process "杀掉进程")

    Given n processes, each process has a unique PID (process id) and its PPID (parent process id). diff --git a/problems/koko-eating-bananas/README.md b/problems/koko-eating-bananas/README.md index dcef83a39..f9bf79576 100644 --- a/problems/koko-eating-bananas/README.md +++ b/problems/koko-eating-bananas/README.md @@ -11,32 +11,43 @@ ## [875. Koko Eating Bananas (Medium)](https://leetcode.com/problems/koko-eating-bananas "爱吃香蕉的珂珂") -

    Koko loves to eat bananas.  There are N piles of bananas, the i-th pile has piles[i] bananas.  The guards have gone and will come back in H hours.

    +

    Koko loves to eat bananas. There are n piles of bananas, the ith pile has piles[i] bananas. The guards have gone and will come back in h hours.

    -

    Koko can decide her bananas-per-hour eating speed of K.  Each hour, she chooses some pile of bananas, and eats K bananas from that pile.  If the pile has less than K bananas, she eats all of them instead, and won't eat any more bananas during this hour.

    +

    Koko can decide her bananas-per-hour eating speed of k. Each hour, she chooses some pile of bananas and eats k bananas from that pile. If the pile has less than k bananas, she eats all of them instead and will not eat any more bananas during this hour.

    -

    Koko likes to eat slowly, but still wants to finish eating all the bananas before the guards come back.

    +

    Koko likes to eat slowly but still wants to finish eating all the bananas before the guards return.

    -

    Return the minimum integer K such that she can eat all the bananas within H hours.

    +

    Return the minimum integer k such that she can eat all the bananas within h hours.

     

    Example 1:

    -
    Input: piles = [3,6,7,11], H = 8
    +
    +
    +Input: piles = [3,6,7,11], h = 8
     Output: 4
    -

    Example 2:

    -
    Input: piles = [30,11,23,4,20], H = 5
    +
    + +

    Example 2:

    + +
    +Input: piles = [30,11,23,4,20], h = 5
     Output: 30
    -

    Example 3:

    -
    Input: piles = [30,11,23,4,20], H = 6
    +
    + +

    Example 3:

    + +
    +Input: piles = [30,11,23,4,20], h = 6
     Output: 23
     
    +

     

    Constraints:

      -
    • 1 <= piles.length <= 10^4
    • -
    • piles.length <= H <= 10^9
    • -
    • 1 <= piles[i] <= 10^9
    • +
    • 1 <= piles.length <= 104
    • +
    • piles.length <= h <= 109
    • +
    • 1 <= piles[i] <= 109
    ### Related Topics diff --git a/problems/kth-largest-element-in-an-array/README.md b/problems/kth-largest-element-in-an-array/README.md index e3227feed..1545efc36 100644 --- a/problems/kth-largest-element-in-an-array/README.md +++ b/problems/kth-largest-element-in-an-array/README.md @@ -11,23 +11,25 @@ ## [215. Kth Largest Element in an Array (Medium)](https://leetcode.com/problems/kth-largest-element-in-an-array "数组中的第K个最大元素") -

    Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.

    +

    Given an integer array nums and an integer k, return the kth largest element in the array.

    -

    Example 1:

    +

    Note that it is the kth largest element in the sorted order, not the kth distinct element.

    -
    -Input: [3,2,1,5,6,4] and k = 2
    +

     

    +

    Example 1:

    +
    Input: nums = [3,2,1,5,6,4], k = 2
     Output: 5
    +

    Example 2:

    +
    Input: nums = [3,2,3,1,2,4,5,5,6], k = 4
    +Output: 4
     
    +

     

    +

    Constraints:

    -

    Example 2:

    - -
    -Input: [3,2,3,1,2,4,5,5,6] and k = 4
    -Output: 4
    - -

    Note:
    -You may assume k is always valid, 1 ≤ k ≤ array's length.

    +
      +
    • 1 <= k <= nums.length <= 104
    • +
    • -104 <= nums[i] <= 104
    • +
    ### Related Topics [[Heap](../../tag/heap/README.md)] diff --git a/problems/largest-perimeter-triangle/README.md b/problems/largest-perimeter-triangle/README.md index 843973455..41478ee1d 100644 --- a/problems/largest-perimeter-triangle/README.md +++ b/problems/largest-perimeter-triangle/README.md @@ -11,59 +11,29 @@ ## [976. Largest Perimeter Triangle (Easy)](https://leetcode.com/problems/largest-perimeter-triangle "三角形的最大周长") -

    Given an array A of positive lengths, return the largest perimeter of a triangle with non-zero area, formed from 3 of these lengths.

    - -

    If it is impossible to form any triangle of non-zero area, return 0.

    +

    Given an integer array nums, return the largest perimeter of a triangle with a non-zero area, formed from three of these lengths. If it is impossible to form any triangle of a non-zero area, return 0.

     

    - -
      -
    - -

    Example 1:

    - -
    -Input: [2,1,2]
    -Output: 5
    +
    Input: nums = [2,1,2]
    +Output: 5
    +

    Example 2:

    +
    Input: nums = [1,2,1]
    +Output: 0
    +

    Example 3:

    +
    Input: nums = [3,2,3,4]
    +Output: 10
    +

    Example 4:

    +
    Input: nums = [3,6,2,3]
    +Output: 8
     
    - -
    -

    Example 2:

    - -
    -Input: [1,2,1]
    -Output: 0
    -
    - -
    -

    Example 3:

    - -
    -Input: [3,2,3,4]
    -Output: 10
    -
    - -
    -

    Example 4:

    - -
    -Input: [3,6,2,3]
    -Output: 8
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 3 <= A.length <= 10000
    2. -
    3. 1 <= A[i] <= 10^6
    4. -
    -
    -
    -
    -
    +
      +
    • 3 <= nums.length <= 104
    • +
    • 1 <= nums[i] <= 106
    • +
    ### Related Topics [[Sort](../../tag/sort/README.md)] diff --git a/problems/largest-rectangle-in-histogram/README.md b/problems/largest-rectangle-in-histogram/README.md index b258adf12..a944c55db 100644 --- a/problems/largest-rectangle-in-histogram/README.md +++ b/problems/largest-rectangle-in-histogram/README.md @@ -11,26 +11,7 @@ ## [84. Largest Rectangle in Histogram (Hard)](https://leetcode.com/problems/largest-rectangle-in-histogram "柱状图中最大的矩形") -

    Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.

    - -

     

    - -


    -Above is a histogram where width of each bar is 1, given height = [2,1,5,6,2,3].

    - -

     

    - -


    -The largest rectangle is shown in the shaded area, which has area = 10 unit.

    - -

     

    - -

    Example:

    - -
    -Input: [2,1,5,6,2,3]
    -Output: 10
    -
    +

    Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram.

     

    Example 1:

    diff --git a/problems/last-stone-weight-ii/README.md b/problems/last-stone-weight-ii/README.md index 0686f14ff..11c649299 100644 --- a/problems/last-stone-weight-ii/README.md +++ b/problems/last-stone-weight-ii/README.md @@ -11,39 +11,53 @@ ## [1049. Last Stone Weight II (Medium)](https://leetcode.com/problems/last-stone-weight-ii "最后一块石头的重量 II") -

    We have a collection of rocks, each rock has a positive integer weight.

    +

    You are given an array of integers stones where stones[i] is the weight of the ith stone.

    -

    Each turn, we choose any two rocks and smash them together.  Suppose the stones have weights x and y with x <= y.  The result of this smash is:

    +

    We are playing a game with the stones. On each turn, we choose any two stones and smash them together. Suppose the stones have weights x and y with x <= y. The result of this smash is:

      -
    • If x == y, both stones are totally destroyed;
    • -
    • If x != y, the stone of weight x is totally destroyed, and the stone of weight y has new weight y-x.
    • +
    • If x == y, both stones are destroyed, and
    • +
    • If x != y, the stone of weight x is destroyed, and the stone of weight y has new weight y - x.
    -

    At the end, there is at most 1 stone left.  Return the smallest possible weight of this stone (the weight is 0 if there are no stones left.)

    +

    At the end of the game, there is at most one stone left.

    -

     

    +

    Return the smallest possible weight of the left stone. If there are no stones left, return 0.

    +

     

    Example 1:

    -Input: [2,7,4,1,8,1]
    -Output: 1
    -Explanation: 
    -We can combine 2 and 4 to get 2 so the array converts to [2,7,1,8,1] then,
    -we can combine 7 and 8 to get 1 so the array converts to [2,1,1,1] then,
    -we can combine 2 and 1 to get 1 so the array converts to [1,1,1] then,
    -we can combine 1 and 1 to get 0 so the array converts to [1] then that's the optimal value.
    +Input: stones = [2,7,4,1,8,1]
    +Output: 1
    +Explanation:
    +We can combine 2 and 4 to get 2, so the array converts to [2,7,1,8,1] then,
    +we can combine 7 and 8 to get 1, so the array converts to [2,1,1,1] then,
    +we can combine 2 and 1 to get 1, so the array converts to [1,1,1] then,
    +we can combine 1 and 1 to get 0, so the array converts to [1], then that's the optimal value.
     
    -

     

    +

    Example 2:

    -

    Note:

    +
    +Input: stones = [31,26,33,21,40]
    +Output: 5
    +
    + +

    Example 3:

    -
      +
      +Input: stones = [1,2]
      +Output: 1
      +
      + +

       

      +

      Constraints:

      + +
      • 1 <= stones.length <= 30
      • 1 <= stones[i] <= 100
      • -
    + ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/longest-common-subsequence/README.md b/problems/longest-common-subsequence/README.md index 75d8cfed4..a62f8c0bc 100644 --- a/problems/longest-common-subsequence/README.md +++ b/problems/longest-common-subsequence/README.md @@ -11,13 +11,15 @@ ## [1143. Longest Common Subsequence (Medium)](https://leetcode.com/problems/longest-common-subsequence "最长公共子序列") -

    Given two strings text1 and text2, return the length of their longest common subsequence.

    +

    Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0.

    -

    A subsequence of a string is a new string generated from the original string with some characters(can be none) deleted without changing the relative order of the remaining characters. (eg, "ace" is a subsequence of "abcde" while "aec" is not). A common subsequence of two strings is a subsequence that is common to both strings.

    +

    A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.

    -

     

    +
      +
    • For example, "ace" is a subsequence of "abcde".
    • +
    -

    If there is no common subsequence, return 0.

    +

    A common subsequence of two strings is a subsequence that is common to both strings.

     

    Example 1:

    @@ -48,9 +50,8 @@

    Constraints:

      -
    • 1 <= text1.length <= 1000
    • -
    • 1 <= text2.length <= 1000
    • -
    • The input strings consist of lowercase English characters only.
    • +
    • 1 <= text1.length, text2.length <= 1000
    • +
    • text1 and text2 consist of only lowercase English characters.
    ### Related Topics diff --git a/problems/longest-palindromic-subsequence/README.md b/problems/longest-palindromic-subsequence/README.md index 267d342b3..a75e0a99b 100644 --- a/problems/longest-palindromic-subsequence/README.md +++ b/problems/longest-palindromic-subsequence/README.md @@ -11,35 +11,27 @@ ## [516. Longest Palindromic Subsequence (Medium)](https://leetcode.com/problems/longest-palindromic-subsequence "最长回文子序列") -

    Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000.

    +

    Given a string s, find the longest palindromic subsequence's length in s.

    -

    Example 1:
    -Input:

    +

    A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.

    -
    -"bbbab"
    -
    -Output: +

     

    +

    Example 1:

    -4
    +Input: s = "bbbab"
    +Output: 4
    +Explanation: One possible longest palindromic subsequence is "bbbb".
     
    -One possible longest palindromic subsequence is "bbbb". -

     

    - -

    Example 2:
    -Input:

    +

    Example 2:

    -"cbbd"
    +Input: s = "cbbd"
    +Output: 2
    +Explanation: One possible longest palindromic subsequence is "bb".
     
    -Output: -
    -2
    -
    -One possible longest palindromic subsequence is "bb".

     

    Constraints:

    diff --git a/problems/longest-substring-with-at-least-k-repeating-characters/README.md b/problems/longest-substring-with-at-least-k-repeating-characters/README.md index 0889484c6..00017f565 100644 --- a/problems/longest-substring-with-at-least-k-repeating-characters/README.md +++ b/problems/longest-substring-with-at-least-k-repeating-characters/README.md @@ -9,7 +9,7 @@                  [Next >](../rotate-function "Rotate Function") -## [395. Longest Substring with At Least K Repeating Characters (Medium)](https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters "至少有K个重复字符的最长子串") +## [395. Longest Substring with At Least K Repeating Characters (Medium)](https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters "至少有 K 个重复字符的最长子串")

    Given a string s and an integer k, return the length of the longest substring of s such that the frequency of each character in this substring is greater than or equal to k.

    diff --git a/problems/longest-word-in-dictionary-through-deleting/README.md b/problems/longest-word-in-dictionary-through-deleting/README.md index c6d3d8a6b..d3283512a 100644 --- a/problems/longest-word-in-dictionary-through-deleting/README.md +++ b/problems/longest-word-in-dictionary-through-deleting/README.md @@ -11,41 +11,32 @@ ## [524. Longest Word in Dictionary through Deleting (Medium)](https://leetcode.com/problems/longest-word-in-dictionary-through-deleting "通过删除字母匹配到字典里最长单词") -

    Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. If there are more than one possible results, return the longest word with the smallest lexicographical order. If there is no possible result, return the empty string.

    +

    Given a string s and a string array dictionary, return the longest string in the dictionary that can be formed by deleting some of the given string characters. If there is more than one possible result, return the longest word with the smallest lexicographical order. If there is no possible result, return the empty string.

    +

     

    Example 1:

    -Input:
    -s = "abpcplea", d = ["ale","apple","monkey","plea"]
    -
    -Output: 
    -"apple"
    +Input: s = "abpcplea", dictionary = ["ale","apple","monkey","plea"]
    +Output: "apple"
     
    -

     

    -

    Example 2:

    -Input:
    -s = "abpcplea", d = ["a","b","c"]
    -
    -Output: 
    -"a"
    +Input: s = "abpcplea", dictionary = ["a","b","c"]
    +Output: "a"
     

     

    - -

    Note:

    - -
      -
    1. All the strings in the input will only contain lower-case letters.
    2. -
    3. The size of the dictionary won't exceed 1,000.
    4. -
    5. The length of all the strings in the input won't exceed 1,000.
    6. -
    - -

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 1000
    • +
    • 1 <= dictionary.length <= 1000
    • +
    • 1 <= dictionary[i].length <= 1000
    • +
    • s and dictionary[i] consist of lowercase English letters.
    • +
    ### Related Topics [[Sort](../../tag/sort/README.md)] diff --git a/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md b/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md index a20ce965d..b272602b6 100644 --- a/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md @@ -13,7 +13,7 @@

    Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.

    -

    According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).”

    +

    According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).”

     

    Example 1:

    @@ -47,7 +47,7 @@
  • -109 <= Node.val <= 109
  • All Node.val are unique.
  • p != q
  • -
  • p and q will exist in the BST.
  • +
  • p and q will exist in the BST.
  • ### Related Topics diff --git a/problems/lowest-common-ancestor-of-a-binary-tree/README.md b/problems/lowest-common-ancestor-of-a-binary-tree/README.md index 868bb850d..477a0c0f9 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree/README.md @@ -13,7 +13,7 @@

    Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.

    -

    According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).”

    +

    According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).”

     

    Example 1:

    @@ -47,7 +47,7 @@
  • -109 <= Node.val <= 109
  • All Node.val are unique.
  • p != q
  • -
  • p and q will exist in the tree.
  • +
  • p and q will exist in the tree.
  • ### Related Topics diff --git a/problems/make-the-xor-of-all-segments-equal-to-zero/README.md b/problems/make-the-xor-of-all-segments-equal-to-zero/README.md new file mode 100644 index 000000000..7dbe899d4 --- /dev/null +++ b/problems/make-the-xor-of-all-segments-equal-to-zero/README.md @@ -0,0 +1,62 @@ + + + + + + + +[< Previous](../number-of-restricted-paths-from-first-to-last-node "Number of Restricted Paths From First to Last Node") +                 +[Next >](../maximize-the-beauty-of-the-garden "Maximize the Beauty of the Garden") + +## [1787. Make the XOR of All Segments Equal to Zero (Hard)](https://leetcode.com/problems/make-the-xor-of-all-segments-equal-to-zero "使所有区间的异或结果为零") + +

    You are given an array nums​​​ and an integer k​​​​​. The XOR of a segment [left, right] where left <= right is the XOR of all the elements with indices between left and right, inclusive: nums[left] XOR nums[left+1] XOR ... XOR nums[right].

    + +

    Return the minimum number of elements to change in the array such that the XOR of all segments of size k​​​​​​ is equal to zero.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,0,3,0], k = 1
    +Output: 3
    +Explanation: Modify the array from [1,2,0,3,0] to from [0,0,0,0,0].
    +
    + +

    Example 2:

    + +
    +Input: nums = [3,4,5,2,1,7,3,4,7], k = 3
    +Output: 3
    +Explanation: Modify the array from [3,4,5,2,1,7,3,4,7] to [3,4,7,3,4,7,3,4,7].
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,2,4,1,2,5,1,2,6], k = 3
    +Output: 3
    +Explanation: Modify the array from [1,2,4,1,2,5,1,2,6] to [1,2,3,1,2,3,1,2,3].
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= nums.length <= 2000
    • +
    • ​​​​​​0 <= nums[i] < 210
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Let's note that for the XOR of all segments with size K to be equal to zeros, nums[i] has to be equal to nums[i+k] +
    + +
    +Hint 2 +Basically, we need to make the first K elements have XOR = 0 and then modify them. +
    diff --git a/problems/max-points-on-a-line/README.md b/problems/max-points-on-a-line/README.md index 316d5ef75..a9537e7fb 100644 --- a/problems/max-points-on-a-line/README.md +++ b/problems/max-points-on-a-line/README.md @@ -11,40 +11,32 @@ ## [149. Max Points on a Line (Hard)](https://leetcode.com/problems/max-points-on-a-line "直线上最多的点数") -

    Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.

    +

    Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane, return the maximum number of points that lie on the same straight line.

    +

     

    Example 1:

    - +
    -Input: [[1,1],[2,2],[3,3]]
    +Input: points = [[1,1],[2,2],[3,3]]
     Output: 3
    -Explanation:
    -^
    -|
    -|        o
    -|     o
    -|  o  
    -+------------->
    -0  1  2  3  4
     

    Example 2:

    - +
    -Input: [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]
    +Input: points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]
     Output: 4
    -Explanation:
    -^
    -|
    -|  o
    -|     o        o
    -|        o
    -|  o        o
    -+------------------->
    -0  1  2  3  4  5  6
     
    -

    NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= points.length <= 300
    • +
    • points[i].length == 2
    • +
    • -104 <= xi, yi <= 104
    • +
    • All the points are unique.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/maximal-rectangle/README.md b/problems/maximal-rectangle/README.md index dbcec2b6a..3d2c84181 100644 --- a/problems/maximal-rectangle/README.md +++ b/problems/maximal-rectangle/README.md @@ -55,7 +55,7 @@
    • rows == matrix.length
    • -
    • cols == matrix.length
    • +
    • cols == matrix[i].length
    • 0 <= row, cols <= 200
    • matrix[i][j] is '0' or '1'.
    diff --git a/problems/maximize-palindrome-length-from-subsequences/README.md b/problems/maximize-palindrome-length-from-subsequences/README.md index 627b4c671..3652abf10 100644 --- a/problems/maximize-palindrome-length-from-subsequences/README.md +++ b/problems/maximize-palindrome-length-from-subsequences/README.md @@ -7,7 +7,7 @@ [< Previous](../maximum-score-from-performing-multiplication-operations "Maximum Score from Performing Multiplication Operations")                  -Next > +[Next >](../sort-features-by-popularity "Sort Features by Popularity") ## [1771. Maximize Palindrome Length From Subsequences (Hard)](https://leetcode.com/problems/maximize-palindrome-length-from-subsequences "由子序列构造的最长回文串的长度") diff --git a/problems/maximize-the-beauty-of-the-garden/README.md b/problems/maximize-the-beauty-of-the-garden/README.md new file mode 100644 index 000000000..45813fb91 --- /dev/null +++ b/problems/maximize-the-beauty-of-the-garden/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../make-the-xor-of-all-segments-equal-to-zero "Make the XOR of All Segments Equal to Zero") +                 +Next > + +## [1788. Maximize the Beauty of the Garden (Hard)](https://leetcode.com/problems/maximize-the-beauty-of-the-garden "") + + + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Consider every possible beauty and its first and last index in flowers. +
    + +
    +Hint 2 +Remove all flowers with negative beauties within those indices. +
    diff --git a/problems/maximum-frequency-stack/README.md b/problems/maximum-frequency-stack/README.md index 203c00854..37a7d0dda 100644 --- a/problems/maximum-frequency-stack/README.md +++ b/problems/maximum-frequency-stack/README.md @@ -11,60 +11,53 @@ ## [895. Maximum Frequency Stack (Hard)](https://leetcode.com/problems/maximum-frequency-stack "最大频率栈") -

    Implement FreqStack, a class which simulates the operation of a stack-like data structure.

    +

    Design a stack-like data structure to push elements to the stack and pop the most frequent element from the stack.

    -

    FreqStack has two functions:

    +

    Implement the FreqStack class:

      -
    • push(int x), which pushes an integer x onto the stack.
    • -
    • pop(), which removes and returns the most frequent element in the stack. +
    • FreqStack() constructs an empty frequency stack.
    • +
    • void push(int val) pushes an integer val onto the top of the stack.
    • +
    • int pop() removes and returns the most frequent element in the stack.
        -
      • If there is a tie for most frequent element, the element closest to the top of the stack is removed and returned.
      • +
      • If there is a tie for the most frequent element, the element closest to the stack's top is removed and returned.

     

    -

    Example 1:

    -Input: 
    -["FreqStack","push","push","push","push","push","push","pop","pop","pop","pop"],
    -[[],[5],[7],[5],[7],[4],[5],[],[],[],[]]
    -Output: [null,null,null,null,null,null,null,5,7,5,4]
    -Explanation:
    -After making six .push operations, the stack is [5,7,5,7,4,5] from bottom to top.  Then:
    -
    -pop() -> returns 5, as 5 is the most frequent.
    -The stack becomes [5,7,5,7,4].
    -
    -pop() -> returns 7, as 5 and 7 is the most frequent, but 7 is closest to the top.
    -The stack becomes [5,7,5,4].
    -
    -pop() -> returns 5.
    -The stack becomes [5,7,4].
    -
    -pop() -> returns 4.
    -The stack becomes [5,7].
    +Input
    +["FreqStack", "push", "push", "push", "push", "push", "push", "pop", "pop", "pop", "pop"]
    +[[], [5], [7], [5], [7], [4], [5], [], [], [], []]
    +Output
    +[null, null, null, null, null, null, null, 5, 7, 5, 4]
    +
    +Explanation
    +FreqStack freqStack = new FreqStack();
    +freqStack.push(5); // The stack is [5]
    +freqStack.push(7); // The stack is [5,7]
    +freqStack.push(5); // The stack is [5,7,5]
    +freqStack.push(7); // The stack is [5,7,5,7]
    +freqStack.push(4); // The stack is [5,7,5,7,4]
    +freqStack.push(5); // The stack is [5,7,5,7,4,5]
    +freqStack.pop();   // return 5, as 5 is the most frequent. The stack becomes [5,7,5,7,4].
    +freqStack.pop();   // return 7, as 5 and 7 is the most frequent, but 7 is closest to the top. The stack becomes [5,7,5,4].
    +freqStack.pop();   // return 5, as 5 is the most frequent. The stack becomes [5,7,4].
    +freqStack.pop();   // return 4, as 4, 5 and 7 is the most frequent, but 4 is closest to the top. The stack becomes [5,7].
     

     

    - -

    Note:

    +

    Constraints:

      -
    • Calls to FreqStack.push(int x) will be such that 0 <= x <= 10^9.
    • -
    • It is guaranteed that FreqStack.pop() won't be called if the stack has zero elements.
    • -
    • The total number of FreqStack.push calls will not exceed 10000 in a single test case.
    • -
    • The total number of FreqStack.pop calls will not exceed 10000 in a single test case.
    • -
    • The total number of FreqStack.push and FreqStack.pop calls will not exceed 150000 across all test cases.
    • +
    • 0 <= val <= 109
    • +
    • At most 2 * 104 calls will be made to push and pop.
    • +
    • It is guaranteed that there will be at least one element in the stack before calling pop.
    -
    -

     

    -
    - ### Related Topics [[Stack](../../tag/stack/README.md)] [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/maximum-gap/README.md b/problems/maximum-gap/README.md index bc4492580..38be7a47a 100644 --- a/problems/maximum-gap/README.md +++ b/problems/maximum-gap/README.md @@ -11,31 +11,35 @@ ## [164. Maximum Gap (Hard)](https://leetcode.com/problems/maximum-gap "最大间距") -

    Given an unsorted array, find the maximum difference between the successive elements in its sorted form.

    - -

    Return 0 if the array contains less than 2 elements.

    +

    Given an integer array nums, return the maximum difference between two successive elements in its sorted form. If the array contains less than two elements, return 0.

    +

     

    Example 1:

    -Input: [3,6,9,1]
    +Input: nums = [3,6,9,1]
     Output: 3
    -Explanation: The sorted form of the array is [1,3,6,9], either
    -             (3,6) or (6,9) has the maximum difference 3.
    +Explanation: The sorted form of the array is [1,3,6,9], either (3,6) or (6,9) has the maximum difference 3. +

    Example 2:

    -Input: [10]
    +Input: nums = [10]
     Output: 0
    -Explanation: The array contains less than 2 elements, therefore return 0.
    +Explanation: The array contains less than 2 elements, therefore return 0. +
    -

    Note:

    +

     

    +

    Constraints:

      -
    • You may assume all elements in the array are non-negative integers and fit in the 32-bit signed integer range.
    • -
    • Try to solve it in linear time/space.
    • +
    • 1 <= nums.length <= 104
    • +
    • 0 <= nums[i] <= 109
    +

     

    +Follow up: Could you solve it in linear time/space? + ### Related Topics [[Sort](../../tag/sort/README.md)] diff --git a/problems/maximum-product-subarray/README.md b/problems/maximum-product-subarray/README.md index 9e981d397..3125d9fca 100644 --- a/problems/maximum-product-subarray/README.md +++ b/problems/maximum-product-subarray/README.md @@ -11,22 +11,36 @@ ## [152. Maximum Product Subarray (Medium)](https://leetcode.com/problems/maximum-product-subarray "乘积最大子数组") -

    Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.

    +

    Given an integer array nums, find a contiguous non-empty subarray within the array that has the largest product, and return the product.

    +

    It is guaranteed that the answer will fit in a 32-bit integer.

    + +

    A subarray is a contiguous subsequence of the array.

    + +

     

    Example 1:

    -Input: [2,3,-2,4]
    -Output: 6
    -Explanation: [2,3] has the largest product 6.
    +Input: nums = [2,3,-2,4]
    +Output: 6
    +Explanation: [2,3] has the largest product 6.
     

    Example 2:

    -Input: [-2,0,-1]
    +Input: nums = [-2,0,-1]
     Output: 0
    -Explanation: The result cannot be 2, because [-2,-1] is not a subarray.
    +Explanation: The result cannot be 2, because [-2,-1] is not a subarray. + + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 2 * 104
    • +
    • -10 <= nums[i] <= 10
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/maximum-subarray/README.md b/problems/maximum-subarray/README.md index aa6c9f871..4685ab121 100644 --- a/problems/maximum-subarray/README.md +++ b/problems/maximum-subarray/README.md @@ -32,22 +32,8 @@

    Example 3:

    -Input: nums = [0]
    -Output: 0
    -
    - -

    Example 4:

    - -
    -Input: nums = [-1]
    -Output: -1
    -
    - -

    Example 5:

    - -
    -Input: nums = [-100000]
    -Output: -100000
    +Input: nums = [5,4,-1,7,8]
    +Output: 23
     

     

    diff --git a/problems/median-of-two-sorted-arrays/README.md b/problems/median-of-two-sorted-arrays/README.md index fde07dd5e..9dcdd1d4b 100644 --- a/problems/median-of-two-sorted-arrays/README.md +++ b/problems/median-of-two-sorted-arrays/README.md @@ -13,8 +13,6 @@

    Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.

    -

    Follow up: The overall run time complexity should be O(log (m+n)).

    -

     

    Example 1:

    @@ -65,6 +63,9 @@
  • -106 <= nums1[i], nums2[i] <= 106
  • +

     

    +Follow up: The overall run time complexity should be O(log (m+n)). + ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/minimum-elements-to-add-to-form-a-given-sum/README.md b/problems/minimum-elements-to-add-to-form-a-given-sum/README.md new file mode 100644 index 000000000..2bf45ea82 --- /dev/null +++ b/problems/minimum-elements-to-add-to-form-a-given-sum/README.md @@ -0,0 +1,68 @@ + + + + + + + +[< Previous](../check-if-binary-string-has-at-most-one-segment-of-ones "Check if Binary String Has at Most One Segment of Ones") +                 +[Next >](../number-of-restricted-paths-from-first-to-last-node "Number of Restricted Paths From First to Last Node") + +## [1785. Minimum Elements to Add to Form a Given Sum (Medium)](https://leetcode.com/problems/minimum-elements-to-add-to-form-a-given-sum "构成特定和需要添加的最少元素") + +

    You are given an integer array nums and two integers limit and goal. The array nums has an interesting property that abs(nums[i]) <= limit.

    + +

    Return the minimum number of elements you need to add to make the sum of the array equal to goal. The array must maintain its property that abs(nums[i]) <= limit.

    + +

    Note that abs(x) equals x if x >= 0, and -x otherwise.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,-1,1], limit = 3, goal = -4
    +Output: 2
    +Explanation: You can add -2 and -3, then the sum of the array will be 1 - 1 + 1 - 2 - 3 = -4.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,-10,9,1], limit = 100, goal = 0
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 1 <= limit <= 106
    • +
    • -limit <= nums[i] <= limit
    • +
    • -109 <= goal <= 109
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Try thinking about the problem as if the array is empty. Then you only need to form goal using elements whose absolute value is <= limit. +
    + +
    +Hint 2 +You can greedily set all of the elements except one to limit or -limit, so the number of elements you need is ceil(abs(goal)/ limit). +
    + +
    +Hint 3 +You can "normalize" goal by offsetting it by the sum of the array. For example, if the goal is 5 and the sum is -3, then it's exactly the same as if the goal is 8 and the array is empty. +
    + +
    +Hint 4 +The answer is ceil(abs(goal-sum)/limit) = (abs(goal-sum)+limit-1) / limit. +
    diff --git a/problems/minimum-moves-to-equal-array-elements/README.md b/problems/minimum-moves-to-equal-array-elements/README.md index 5ec44f81f..cb3c5ecc6 100644 --- a/problems/minimum-moves-to-equal-array-elements/README.md +++ b/problems/minimum-moves-to-equal-array-elements/README.md @@ -11,22 +11,35 @@ ## [453. Minimum Moves to Equal Array Elements (Easy)](https://leetcode.com/problems/minimum-moves-to-equal-array-elements "最小操作次数使数组元素相等") -

    Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.

    +

    Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal.

    -

    Example: -

    -Input:
    -[1,2,3]
    +

    In one move, you can increment n - 1 elements of the array by 1.

    + +

     

    +

    Example 1:

    -Output: -3 +
    +Input: nums = [1,2,3]
    +Output: 3
    +Explanation: Only three moves are needed (remember each move increments two elements):
    +[1,2,3]  =>  [2,3,3]  =>  [3,4,3]  =>  [4,4,4]
    +
    -Explanation: -Only three moves are needed (remember each move increments two elements): +

    Example 2:

    -[1,2,3] => [2,3,3] => [3,4,3] => [4,4,4] +
    +Input: nums = [1,1,1]
    +Output: 0
     
    -

    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= nums.length <= 104
    • +
    • -109 <= nums[i] <= 109
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/minimum-score-triangulation-of-polygon/README.md b/problems/minimum-score-triangulation-of-polygon/README.md index 4ac0645ed..b6e17a52d 100644 --- a/problems/minimum-score-triangulation-of-polygon/README.md +++ b/problems/minimum-score-triangulation-of-polygon/README.md @@ -11,57 +11,46 @@ ## [1039. Minimum Score Triangulation of Polygon (Medium)](https://leetcode.com/problems/minimum-score-triangulation-of-polygon "多边形三角剖分的最低得分") -

    Given N, consider a convex N-sided polygon with vertices labelled A[0], A[i], ..., A[N-1] in clockwise order.

    +

    You have a convex n-sided polygon where each vertex has an integer value. You are given an integer array values where values[i] is the value of the ith vertex (i.e., clockwise order).

    -

    Suppose you triangulate the polygon into N-2 triangles.  For each triangle, the value of that triangle is the product of the labels of the vertices, and the total score of the triangulation is the sum of these values over all N-2 triangles in the triangulation.

    +

    You will triangulate the polygon into n - 2 triangles. For each triangle, the value of that triangle is the product of the values of its vertices, and the total score of the triangulation is the sum of these values over all n - 2 triangles in the triangulation.

    -

    Return the smallest possible total score that you can achieve with some triangulation of the polygon.

    +

    Return the smallest possible total score that you can achieve with some triangulation of the polygon.

     

    - -
      -
    - -

    Example 1:

    - +
    -Input: [1,2,3]
    -Output: 6
    -Explanation: The polygon is already triangulated, and the score of the only triangle is 6.
    +Input: values = [1,2,3]
    +Output: 6
    +Explanation: The polygon is already triangulated, and the score of the only triangle is 6.
     
    -

    Example 2:

    - -

    - +
    -Input: [3,7,4,5]
    -Output: 144
    -Explanation: There are two triangulations, with possible scores: 3*7*5 + 4*5*7 = 245, or 3*4*5 + 3*4*7 = 144.  The minimum score is 144.
    +Input: values = [3,7,4,5]
    +Output: 144
    +Explanation: There are two triangulations, with possible scores: 3*7*5 + 4*5*7 = 245, or 3*4*5 + 3*4*7 = 144.
    +The minimum score is 144.
     
    -

    Example 3:

    - +
    -Input: [1,3,1,4,1,5]
    -Output: 13
    -Explanation: The minimum score triangulation has score 1*1*3 + 1*1*4 + 1*1*5 + 1*1*1 = 13.
    +Input: values = [1,3,1,4,1,5]
    +Output: 13
    +Explanation: The minimum score triangulation has score 1*1*3 + 1*1*4 + 1*1*5 + 1*1*1 = 13.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 3 <= A.length <= 50
    2. -
    3. 1 <= A[i] <= 100
    4. -
    -
    -
    -
    +
      +
    • n == values.length
    • +
    • 3 <= n <= 50
    • +
    • 1 <= values[i] <= 100
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/most-common-word/README.md b/problems/most-common-word/README.md index f36586ff2..3a96dcf61 100644 --- a/problems/most-common-word/README.md +++ b/problems/most-common-word/README.md @@ -11,18 +11,15 @@ ## [819. Most Common Word (Easy)](https://leetcode.com/problems/most-common-word "最常见的单词") -

    Given a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words.  It is guaranteed there is at least one word that isn't banned, and that the answer is unique.

    +

    Given a string paragraph and a string array of the banned words banned, return the most frequent word that is not banned. It is guaranteed there is at least one word that is not banned, and that the answer is unique.

    -

    Words in the list of banned words are given in lowercase, and free of punctuation.  Words in the paragraph are not case sensitive.  The answer is in lowercase.

    +

    The words in paragraph are case-insensitive and the answer should be returned in lowercase.

     

    - -

    Example:

    +

    Example 1:

    -Input: 
    -paragraph = "Bob hit a ball, the hit BALL flew far after it was hit."
    -banned = ["hit"]
    +Input: paragraph = "Bob hit a ball, the hit BALL flew far after it was hit.", banned = ["hit"]
     Output: "ball"
     Explanation: 
     "hit" occurs 3 times, but it is a banned word.
    @@ -32,18 +29,22 @@ that punctuation is ignored (even if adjacent to words, such as "ball,"
     and that "hit" isn't the answer even though it occurs more because it is banned.
     
    -

     

    +

    Example 2:

    + +
    +Input: paragraph = "a.", banned = []
    +Output: "a"
    +
    -

    Note:

    +

     

    +

    Constraints:

      -
    • 1 <= paragraph.length <= 1000.
    • -
    • 0 <= banned.length <= 100.
    • -
    • 1 <= banned[i].length <= 10.
    • -
    • The answer is unique, and written in lowercase (even if its occurrences in paragraph may have uppercase symbols, and even if it is a proper noun.)
    • -
    • paragraph only consists of letters, spaces, or the punctuation symbols !?',;.
    • -
    • There are no hyphens or hyphenated words.
    • -
    • Words only consist of letters, never apostrophes or other punctuation symbols.
    • +
    • 1 <= paragraph.length <= 1000
    • +
    • paragraph consists of English letters, space ' ', or one of the symbols: "!?',;.".
    • +
    • 0 <= banned.length <= 100
    • +
    • 1 <= banned[i].length <= 10
    • +
    • banned[i] consists of only lowercase English letters.
    ### Related Topics diff --git a/problems/move-zeroes/README.md b/problems/move-zeroes/README.md index 855dd078e..78420e9e4 100644 --- a/problems/move-zeroes/README.md +++ b/problems/move-zeroes/README.md @@ -11,20 +11,28 @@ ## [283. Move Zeroes (Easy)](https://leetcode.com/problems/move-zeroes "移动零") -

    Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.

    - -

    Example:

    - -
    -Input: [0,1,0,3,12]
    -Output: [1,3,12,0,0]
    - -

    Note:

    - -
      -
    1. You must do this in-place without making a copy of the array.
    2. -
    3. Minimize the total number of operations.
    4. -
    +

    Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements.

    + +

    Note that you must do this in-place without making a copy of the array.

    + +

     

    +

    Example 1:

    +
    Input: nums = [0,1,0,3,12]
    +Output: [1,3,12,0,0]
    +

    Example 2:

    +
    Input: nums = [0]
    +Output: [0]
    +
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 104
    • +
    • -231 <= nums[i] <= 231 - 1
    • +
    + +

     

    +Follow up: Could you minimize the total number of operations done? ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/n-ary-tree-postorder-traversal/README.md b/problems/n-ary-tree-postorder-traversal/README.md index 9c86ee0ad..1877d7459 100644 --- a/problems/n-ary-tree-postorder-traversal/README.md +++ b/problems/n-ary-tree-postorder-traversal/README.md @@ -9,7 +9,7 @@                  [Next >](../tag-validator "Tag Validator") -## [590. N-ary Tree Postorder Traversal (Easy)](https://leetcode.com/problems/n-ary-tree-postorder-traversal "N叉树的后序遍历") +## [590. N-ary Tree Postorder Traversal (Easy)](https://leetcode.com/problems/n-ary-tree-postorder-traversal "N 叉树的后序遍历")

    Given an n-ary tree, return the postorder traversal of its nodes' values.

    diff --git a/problems/n-ary-tree-preorder-traversal/README.md b/problems/n-ary-tree-preorder-traversal/README.md index ec719eca8..8b1717293 100644 --- a/problems/n-ary-tree-preorder-traversal/README.md +++ b/problems/n-ary-tree-preorder-traversal/README.md @@ -9,7 +9,7 @@                  [Next >](../n-ary-tree-postorder-traversal "N-ary Tree Postorder Traversal") -## [589. N-ary Tree Preorder Traversal (Easy)](https://leetcode.com/problems/n-ary-tree-preorder-traversal "N叉树的前序遍历") +## [589. N-ary Tree Preorder Traversal (Easy)](https://leetcode.com/problems/n-ary-tree-preorder-traversal "N 叉树的前序遍历")

    Given an n-ary tree, return the preorder traversal of its nodes' values.

    diff --git a/problems/number-of-1-bits/README.md b/problems/number-of-1-bits/README.md index 5732c15d0..c5a399386 100644 --- a/problems/number-of-1-bits/README.md +++ b/problems/number-of-1-bits/README.md @@ -16,7 +16,7 @@

    Note:

      -
    • Note that in some languages such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type. It should not affect your implementation, as the integer's internal binary representation is the same, whether it is signed or unsigned.
    • +
    • Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type. It should not affect your implementation, as the integer's internal binary representation is the same, whether it is signed or unsigned.
    • In Java, the compiler represents the signed integers using 2's complement notation. Therefore, in Example 3, the input represents the signed integer. -3.
    @@ -49,7 +49,7 @@

    Constraints:

      -
    • The input must be a binary string of length 32
    • +
    • The input must be a binary string of length 32.

     

    diff --git a/problems/number-of-islands/README.md b/problems/number-of-islands/README.md index f657b3ae2..e39630a2b 100644 --- a/problems/number-of-islands/README.md +++ b/problems/number-of-islands/README.md @@ -11,7 +11,7 @@ ## [200. Number of Islands (Medium)](https://leetcode.com/problems/number-of-islands "岛屿数量") -

    Given an m x n 2d grid map of '1's (land) and '0's (water), return the number of islands.

    +

    Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands.

    An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.

    diff --git a/problems/number-of-matching-subsequences/README.md b/problems/number-of-matching-subsequences/README.md index a73b2dbec..383d1cc65 100644 --- a/problems/number-of-matching-subsequences/README.md +++ b/problems/number-of-matching-subsequences/README.md @@ -11,24 +11,38 @@ ## [792. Number of Matching Subsequences (Medium)](https://leetcode.com/problems/number-of-matching-subsequences "匹配子序列的单词数") -

    Given string S and a dictionary of words words, find the number of words[i] that is a subsequence of S.

    +

    Given a string s and an array of strings words, return the number of words[i] that is a subsequence of s.

    + +

    A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.

    + +
      +
    • For example, "ace" is a subsequence of "abcde".
    • +
    + +

     

    +

    Example 1:

    -Example :
    -Input: 
    -S = "abcde"
    -words = ["a", "bb", "acd", "ace"]
    +Input: s = "abcde", words = ["a","bb","acd","ace"]
     Output: 3
    -Explanation: There are three words in words that are a subsequence of S: "a", "acd", "ace".
    +Explanation: There are three strings in words that are a subsequence of s: "a", "acd", "ace".
    +
    + +

    Example 2:

    + +
    +Input: s = "dsahjpjauf", words = ["ahjpjau","ja","ahbwzgqnuk","tnmlanowax"]
    +Output: 2
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • All words in words and S will only consists of lowercase letters.
    • -
    • The length of S will be in the range of [1, 50000].
    • -
    • The length of words will be in the range of [1, 5000].
    • -
    • The length of words[i] will be in the range of [1, 50].
    • +
    • 1 <= s.length <= 5 * 104
    • +
    • 1 <= words.length <= 5000
    • +
    • 1 <= words[i].length <= 50
    • +
    • s and words[i] consist of only lowercase English letters.
    ### Related Topics diff --git a/problems/number-of-restricted-paths-from-first-to-last-node/README.md b/problems/number-of-restricted-paths-from-first-to-last-node/README.md new file mode 100644 index 000000000..17d6a7a58 --- /dev/null +++ b/problems/number-of-restricted-paths-from-first-to-last-node/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../minimum-elements-to-add-to-form-a-given-sum "Minimum Elements to Add to Form a Given Sum") +                 +[Next >](../make-the-xor-of-all-segments-equal-to-zero "Make the XOR of All Segments Equal to Zero") + +## [1786. Number of Restricted Paths From First to Last Node (Medium)](https://leetcode.com/problems/number-of-restricted-paths-from-first-to-last-node "从第一个节点出发到最后一个节点的受限路径数") + +

    There is an undirected weighted connected graph. You are given a positive integer n which denotes that the graph has n nodes labeled from 1 to n, and an array edges where each edges[i] = [ui, vi, weighti] denotes that there is an edge between nodes ui and vi with weight equal to weighti.

    + +

    A path from node start to node end is a sequence of nodes [z0, z1, z2, ..., zk] such that z0 = start and zk = end and there is an edge between zi and zi+1 where 0 <= i <= k-1.

    + +

    The distance of a path is the sum of the weights on the edges of the path. Let distanceToLastNode(x) denote the shortest distance of a path between node n and node x. A restricted path is a path that also satisfies that distanceToLastNode(zi) > distanceToLastNode(zi+1) where 0 <= i <= k-1.

    + +

    Return the number of restricted paths from node 1 to node n. Since that number may be too large, return it modulo 109 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 5, edges = [[1,2,3],[1,3,3],[2,3,1],[1,4,2],[5,2,2],[3,5,1],[5,4,10]]
    +Output: 3
    +Explanation: Each circle contains the node number in black and its distanceToLastNode value in blue. The three restricted paths are:
    +1) 1 --> 2 --> 5
    +2) 1 --> 2 --> 3 --> 5
    +3) 1 --> 3 --> 5
    +
    + +

    Example 2:

    + +
    +Input: n = 7, edges = [[1,3,1],[4,1,2],[7,3,4],[2,5,3],[5,6,1],[6,7,2],[7,5,3],[2,6,4]]
    +Output: 1
    +Explanation: Each circle contains the node number in black and its distanceToLastNode value in blue. The only restricted path is 1 --> 3 --> 7.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 2 * 104
    • +
    • n - 1 <= edges.length <= 4 * 104
    • +
    • edges[i].length == 3
    • +
    • 1 <= ui, vi <= n
    • +
    • ui != vi
    • +
    • 1 <= weighti <= 105
    • +
    • There is at most one edge between any two nodes.
    • +
    • There is at least one path between any two nodes.
    • +
    + +### Related Topics + [[Graph](../../tag/graph/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Run a Dijkstra from node numbered n to compute distance from the last node. +
    + +
    +Hint 2 +Consider all edges [u, v] one by one and direct them such that distance of u to n > distance of v to n. If both u and v are at the same distance from n, discard this edge. +
    + +
    +Hint 3 +Now this problem reduces to computing the number of paths from 1 to n in a DAG, a standard DP problem. +
    diff --git a/problems/number-of-ways-to-paint-n-3-grid/README.md b/problems/number-of-ways-to-paint-n-3-grid/README.md index 52b5ea05a..0db030cab 100644 --- a/problems/number-of-ways-to-paint-n-3-grid/README.md +++ b/problems/number-of-ways-to-paint-n-3-grid/README.md @@ -11,20 +11,17 @@ ## [1411. Number of Ways to Paint N × 3 Grid (Hard)](https://leetcode.com/problems/number-of-ways-to-paint-n-3-grid "给 N x 3 网格图涂色的方案数") -

    You have a grid of size n x 3 and you want to paint each cell of the grid with exactly one of the three colours: Red, Yellow or Green while making sure that no two adjacent cells have the same colour (i.e no two cells that share vertical or horizontal sides have the same colour).

    +

    You have a grid of size n x 3 and you want to paint each cell of the grid with exactly one of the three colors: Red, Yellow, or Green while making sure that no two adjacent cells have the same color (i.e., no two cells that share vertical or horizontal sides have the same color).

    -

    You are given n the number of rows of the grid.

    - -

    Return the number of ways you can paint this grid. As the answer may grow large, the answer must be computed modulo 10^9 + 7.

    +

    Given n the number of rows of the grid, return the number of ways you can paint this grid. As the answer may grow large, the answer must be computed modulo 109 + 7.

     

    Example 1:

    - +
     Input: n = 1
     Output: 12
    -Explanation: There are 12 possible way to paint the grid as shown:
    -
    +Explanation: There are 12 possible way to paint the grid as shown.
     

    Example 2:

    diff --git a/problems/odd-even-jump/README.md b/problems/odd-even-jump/README.md index 847d6ac0d..85822e3bd 100644 --- a/problems/odd-even-jump/README.md +++ b/problems/odd-even-jump/README.md @@ -11,17 +11,17 @@ ## [975. Odd Even Jump (Hard)](https://leetcode.com/problems/odd-even-jump "奇偶跳") -

    You are given an integer array A. From some starting index, you can make a series of jumps. The (1st, 3rd, 5th, ...) jumps in the series are called odd-numbered jumps, and the (2nd, 4th, 6th, ...) jumps in the series are called even-numbered jumps. Note that the jumps are numbered, not the indices.

    +

    You are given an integer array arr. From some starting index, you can make a series of jumps. The (1st, 3rd, 5th, ...) jumps in the series are called odd-numbered jumps, and the (2nd, 4th, 6th, ...) jumps in the series are called even-numbered jumps. Note that the jumps are numbered, not the indices.

    You may jump forward from index i to index j (with i < j) in the following way:

      -
    • During odd-numbered jumps (i.e., jumps 1, 3, 5, ...), you jump to the index j such that A[i] <= A[j] and A[j] is the smallest possible value. If there are multiple such indices j, you can only jump to the smallest such index j.
    • -
    • During even-numbered jumps (i.e., jumps 2, 4, 6, ...), you jump to the index j such that A[i] >= A[j] and A[j] is the largest possible value. If there are multiple such indices j, you can only jump to the smallest such index j.
    • +
    • During odd-numbered jumps (i.e., jumps 1, 3, 5, ...), you jump to the index j such that arr[i] <= arr[j] and arr[j] is the smallest possible value. If there are multiple such indices j, you can only jump to the smallest such index j.
    • +
    • During even-numbered jumps (i.e., jumps 2, 4, 6, ...), you jump to the index j such that arr[i] >= arr[j] and arr[j] is the largest possible value. If there are multiple such indices j, you can only jump to the smallest such index j.
    • It may be the case that for some index i, there are no legal jumps.
    -

    A starting index is good if, starting from that index, you can reach the end of the array (index A.length - 1) by jumping some number of times (possibly 0 or more than once).

    +

    A starting index is good if, starting from that index, you can reach the end of the array (index arr.length - 1) by jumping some number of times (possibly 0 or more than once).

    Return the number of good starting indices.

    @@ -29,11 +29,10 @@

    Example 1:

    -Input: A = [10,13,12,14,15]
    +Input: arr = [10,13,12,14,15]
     Output: 2
     Explanation: 
    -From starting index i = 0, we can make our 1st jump to i = 2 (since A[2] is the smallest among A[1], A[2], A[3],
    -A[4] that is greater or equal to A[0]), then we cannot jump any more.
    +From starting index i = 0, we can make our 1st jump to i = 2 (since arr[2] is the smallest among arr[1], arr[2], arr[3], arr[4] that is greater or equal to arr[0]), then we cannot jump any more.
     From starting index i = 1 and i = 2, we can make our 1st jump to i = 3, then we cannot jump any more.
     From starting index i = 3, we can make our 1st jump to i = 4, so we have reached the end.
     From starting index i = 4, we have reached the end already.
    @@ -44,23 +43,14 @@ jumps.
     

    Example 2:

    -Input: A = [2,3,1,1,4]
    +Input: arr = [2,3,1,1,4]
     Output: 3
     Explanation: 
     From starting index i = 0, we make jumps to i = 1, i = 2, i = 3:
    -
    -During our 1st jump (odd-numbered), we first jump to i = 1 because A[1] is the smallest value in [A[1], A[2],
    -A[3], A[4]] that is greater than or equal to A[0].
    -
    -During our 2nd jump (even-numbered), we jump from i = 1 to i = 2 because A[2] is the largest value in [A[2], A[3],
    -A[4]] that is less than or equal to A[1]. A[3] is also the largest value, but 2 is a smaller index, so we can
    -only jump to i = 2 and not i = 3
    -
    -During our 3rd jump (odd-numbered), we jump from i = 2 to i = 3 because A[3] is the smallest value in [A[3], A[4]]
    -that is greater than or equal to A[2].
    -
    +During our 1st jump (odd-numbered), we first jump to i = 1 because arr[1] is the smallest value in [arr[1], arr[2], arr[3], arr[4]] that is greater than or equal to arr[0].
    +During our 2nd jump (even-numbered), we jump from i = 1 to i = 2 because arr[2] is the largest value in [arr[2], arr[3], arr[4]] that is less than or equal to arr[1]. arr[3] is also the largest value, but 2 is a smaller index, so we can only jump to i = 2 and not i = 3
    +During our 3rd jump (odd-numbered), we jump from i = 2 to i = 3 because arr[3] is the smallest value in [arr[3], arr[4]] that is greater than or equal to arr[2].
     We can't jump from i = 3 to i = 4, so the starting index i = 0 is not good.
    -
     In a similar manner, we can deduce that:
     From starting index i = 1, we jump to i = 4, so we reach the end.
     From starting index i = 2, we jump to i = 3, and then we can't jump anymore.
    @@ -73,18 +63,17 @@ number of jumps.
     

    Example 3:

    -Input: A = [5,1,3,4,2]
    +Input: arr = [5,1,3,4,2]
     Output: 3
    -Explanation: 
    -We can reach the end from starting indices 1, 2, and 4.
    +Explanation: We can reach the end from starting indices 1, 2, and 4.
     

     

    Constraints:

      -
    • 1 <= A.length <= 2 * 104
    • -
    • 0 <= A[i] < 105
    • +
    • 1 <= arr.length <= 2 * 104
    • +
    • 0 <= arr[i] < 105
    ### Related Topics diff --git a/problems/odd-even-linked-list/README.md b/problems/odd-even-linked-list/README.md index 4abbe37ec..b936534d1 100644 --- a/problems/odd-even-linked-list/README.md +++ b/problems/odd-even-linked-list/README.md @@ -11,33 +11,38 @@ ## [328. Odd Even Linked List (Medium)](https://leetcode.com/problems/odd-even-linked-list "奇偶链表") -

    Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.

    +

    Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list.

    -

    You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity.

    +

    The first node is considered odd, and the second node is even, and so on.

    -

    Example 1:

    +

    Note that the relative order inside both the even and odd groups should remain as it was in the input.

    +

     

    +

    Example 1:

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

    Example 2:

    - +

    Example 2:

    +
    -Input: 2->1->3->5->6->4->7->NULL
    -Output: 2->3->6->7->1->5->4->NULL
    +Input: head = [2,1,3,5,6,4,7]
    +Output: [2,3,6,7,1,5,4]
     

     

    Constraints:

      -
    • The relative order inside both the even and odd groups should remain as it was in the input.
    • -
    • The first node is considered odd, the second node even and so on ...
    • -
    • The length of the linked list is between [0, 10^4].
    • +
    • The number of nodes in the linked list is in the range [0, 104].
    • +
    • -106 <= Node.val <= 106
    +

     

    +Follow up: Could you solve it in O(1) space complexity and O(nodes) time complexity? + ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/paint-fence/README.md b/problems/paint-fence/README.md index 739c6dee1..3317001f8 100644 --- a/problems/paint-fence/README.md +++ b/problems/paint-fence/README.md @@ -9,7 +9,7 @@                  [Next >](../find-the-celebrity "Find the Celebrity") -## [276. Paint Fence (Easy)](https://leetcode.com/problems/paint-fence "栅栏涂色") +## [276. Paint Fence (Medium)](https://leetcode.com/problems/paint-fence "栅栏涂色")

    There is a fence with n posts, each post can be painted with one of the k colors.

    diff --git a/problems/paint-house-ii/README.md b/problems/paint-house-ii/README.md index 11ae17a5c..847316443 100644 --- a/problems/paint-house-ii/README.md +++ b/problems/paint-house-ii/README.md @@ -37,4 +37,4 @@ Could you solve it in O(nk) runtime?

    1. [Product of Array Except Self](../product-of-array-except-self) (Medium) 1. [Sliding Window Maximum](../sliding-window-maximum) (Hard) 1. [Paint House](../paint-house) (Medium) - 1. [Paint Fence](../paint-fence) (Easy) + 1. [Paint Fence](../paint-fence) (Medium) diff --git a/problems/paint-house/README.md b/problems/paint-house/README.md index 4ec08d22b..7867156c2 100644 --- a/problems/paint-house/README.md +++ b/problems/paint-house/README.md @@ -34,4 +34,4 @@ All costs are positive integers.

    1. [House Robber](../house-robber) (Medium) 1. [House Robber II](../house-robber-ii) (Medium) 1. [Paint House II](../paint-house-ii) (Hard) - 1. [Paint Fence](../paint-fence) (Easy) + 1. [Paint Fence](../paint-fence) (Medium) diff --git a/problems/palindrome-linked-list/README.md b/problems/palindrome-linked-list/README.md index 1bb515a82..f18a0ee0a 100644 --- a/problems/palindrome-linked-list/README.md +++ b/problems/palindrome-linked-list/README.md @@ -11,22 +11,33 @@ ## [234. Palindrome Linked List (Easy)](https://leetcode.com/problems/palindrome-linked-list "回文链表") -

    Given a singly linked list, determine if it is a palindrome.

    +

    Given the head of a singly linked list, return true if it is a palindrome.

    +

     

    Example 1:

    - +
    -Input: 1->2
    -Output: false
    +Input: head = [1,2,2,1] +Output: true +

    Example 2:

    - +
    -Input: 1->2->2->1
    -Output: true
    +Input: head = [1,2] +Output: false +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is in the range [1, 105].
    • +
    • 0 <= Node.val <= 9
    • +
    -

    Follow up:
    -Could you do it in O(n) time and O(1) space?

    +

     

    +Follow up: Could you do it in O(n) time and O(1) space? ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/parallel-courses-ii/README.md b/problems/parallel-courses-ii/README.md index 1bb3fea26..247da8ad5 100644 --- a/problems/parallel-courses-ii/README.md +++ b/problems/parallel-courses-ii/README.md @@ -11,11 +11,11 @@ ## [1494. Parallel Courses II (Hard)](https://leetcode.com/problems/parallel-courses-ii "并行课程 II") -

    Given the integer n representing the number of courses at some university labeled from 1 to n, and the array dependencies where dependencies[i] = [xi, yi]  represents a prerequisite relationship, that is, the course xi must be taken before the course yi.  Also, you are given the integer k.

    +

    Given the integer n representing the number of courses at some university labeled from 1 to n, and the array dependencies where dependencies[i] = [xi, yi] represents a prerequisite relationship, that is, the course xi must be taken before the course yi. Also, you are given the integer k.

    In one semester you can take at most k courses as long as you have taken all the prerequisites for the courses you are taking.

    -

    Return the minimum number of semesters to take all courses. It is guaranteed that you can take all courses in some way.

    +

    Return the minimum number of semesters to take all courses. It is guaranteed that you can take all courses in some way.

     

    Example 1:

    @@ -51,9 +51,9 @@
    • 1 <= n <= 15
    • 1 <= k <= n
    • -
    • 0 <= dependencies.length <= n * (n-1) / 2
    • +
    • 0 <= dependencies.length <= n * (n-1) / 2
    • dependencies[i].length == 2
    • -
    • 1 <= xi, yi <= n
    • +
    • 1 <= xi, yi <= n
    • xi != yi
    • All prerequisite relationships are distinct, that is, dependencies[i] != dependencies[j].
    • The given graph is a directed acyclic graph.
    • diff --git a/problems/parallel-courses/README.md b/problems/parallel-courses/README.md index 823516bf4..b2eda5f2d 100644 --- a/problems/parallel-courses/README.md +++ b/problems/parallel-courses/README.md @@ -9,7 +9,7 @@                  [Next >](../n-th-tribonacci-number "N-th Tribonacci Number") -## [1136. Parallel Courses (Hard)](https://leetcode.com/problems/parallel-courses "平行课程") +## [1136. Parallel Courses (Medium)](https://leetcode.com/problems/parallel-courses "平行课程")

      There are N courses, labelled from 1 to N.

      @@ -62,40 +62,15 @@ No course can be studied because they depend on each other. ### Hints
      Hint 1 -Try to think of it as a graph problem. +Try to think of it as a graph problem. It will be impossible to study all the courses if the graph had a cycle.
      Hint 2 -When will be impossible to study all the courses? +The graph is a directed acyclic graph (DAG). The answer is the longes path in this DAG.
      Hint 3 -What if the directed graph has a cycle? -
      - -
      -Hint 4 -If you build a graph using the relations, what would be the graph type? -
      - -
      -Hint 5 -So the graph is a directed acyclic graph (DAG). -
      - -
      -Hint 6 -Imagine having a long path in the DAG, what can you say about the answer then? -
      - -
      -Hint 7 -How to find the longest path in a DAG? -
      - -
      -Hint 8 -We can use DP in order to solve this. +You can use DP to find the longest path in the DAG.
      diff --git a/problems/power-of-three/README.md b/problems/power-of-three/README.md index c59c0a6f4..8be2c0ac1 100644 --- a/problems/power-of-three/README.md +++ b/problems/power-of-three/README.md @@ -37,7 +37,7 @@

     

    -Follow up: Could you do it without using any loop / recursion? +Follow up: Could you solve it without loops/recursion? ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/power-of-two/README.md b/problems/power-of-two/README.md index e86dfa527..6ad9597ee 100644 --- a/problems/power-of-two/README.md +++ b/problems/power-of-two/README.md @@ -60,6 +60,9 @@
  • -231 <= n <= 231 - 1
  • +

     

    +Follow up: Could you solve it without loops/recursion? + ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/prison-cells-after-n-days/README.md b/problems/prison-cells-after-n-days/README.md index e11dfd15f..ddcee25c5 100644 --- a/problems/prison-cells-after-n-days/README.md +++ b/problems/prison-cells-after-n-days/README.md @@ -11,36 +11,28 @@ ## [957. Prison Cells After N Days (Medium)](https://leetcode.com/problems/prison-cells-after-n-days "N 天后的牢房") -

    There are 8 prison cells in a row, and each cell is either occupied or vacant.

    +

    There are 8 prison cells in a row and each cell is either occupied or vacant.

    Each day, whether the cell is occupied or vacant changes according to the following rules:

      -
    • If a cell has two adjacent neighbors that are both occupied or both vacant, then the cell becomes occupied.
    • +
    • If a cell has two adjacent neighbors that are both occupied or both vacant, then the cell becomes occupied.
    • Otherwise, it becomes vacant.
    -

    (Note that because the prison is a row, the first and the last cells in the row can't have two adjacent neighbors.)

    +

    Note that because the prison is a row, the first and the last cells in the row can't have two adjacent neighbors.

    -

    We describe the current state of the prison in the following way: cells[i] == 1 if the i-th cell is occupied, else cells[i] == 0.

    +

    You are given an integer array cells where cells[i] == 1 if the ith cell is occupied and cells[i] == 0 if the ith cell is vacant, and you are given an integer n.

    -

    Given the initial state of the prison, return the state of the prison after N days (and N such changes described above.)

    +

    Return the state of the prison after n days (i.e., n such changes described above).

     

    - -
    -
      -
    -
    - -

    Example 1:

    -Input: cells = [0,1,0,1,1,0,0,1], N = 7
    -Output: [0,0,1,1,0,0,0,0]
    -Explanation: 
    -The following table summarizes the state of the prison on each day:
    +Input: cells = [0,1,0,1,1,0,0,1], n = 7
    +Output: [0,0,1,1,0,0,0,0]
    +Explanation: The following table summarizes the state of the prison on each day:
     Day 0: [0, 1, 0, 1, 1, 0, 0, 1]
     Day 1: [0, 1, 1, 0, 0, 0, 0, 0]
     Day 2: [0, 0, 0, 0, 1, 1, 1, 0]
    @@ -48,29 +40,24 @@ Day 3: [0, 1, 1, 0, 0, 1, 0, 0]
     Day 4: [0, 0, 0, 0, 0, 1, 0, 0]
     Day 5: [0, 1, 1, 1, 0, 1, 0, 0]
     Day 6: [0, 0, 1, 0, 1, 1, 0, 0]
    -Day 7: [0, 0, 1, 1, 0, 0, 0, 0]
    -
    +Day 7: [0, 0, 1, 1, 0, 0, 0, 0]
     
    -

    Example 2:

    -Input: cells = [1,0,0,1,0,0,1,0], N = 1000000000
    -Output: [0,0,1,1,1,1,1,0]
    +Input: cells = [1,0,0,1,0,0,1,0], n = 1000000000
    +Output: [0,0,1,1,1,1,1,0]
     

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • cells.length == 8
      • -
      • cells[i] is in {0, 1}
      • -
      • 1 <= N <= 10^9
      • -
    -
    -
    +
  • cells[i] is either 0 or 1.
  • +
  • 1 <= n <= 109
  • + ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/products-price-for-each-store/README.md b/problems/products-price-for-each-store/README.md new file mode 100644 index 000000000..2cf997444 --- /dev/null +++ b/problems/products-price-for-each-store/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../car-fleet-ii "Car Fleet II") +                 +[Next >](../shortest-path-in-a-hidden-grid "Shortest Path in a Hidden Grid") + +## [1777. Product's Price for Each Store (Easy)](https://leetcode.com/problems/products-price-for-each-store "每家商店的产品价格") + + diff --git a/problems/products-price-for-each-store/mysql_schemas.sql b/problems/products-price-for-each-store/mysql_schemas.sql new file mode 100644 index 000000000..e1187f768 --- /dev/null +++ b/problems/products-price-for-each-store/mysql_schemas.sql @@ -0,0 +1,7 @@ +Create table If Not Exists Products (product_id int, store ENUM('store1', 'store2', 'store3'), price int); +Truncate table Products; +insert into Products (product_id, store, price) values ('0', 'store1', '95'); +insert into Products (product_id, store, price) values ('0', 'store3', '105'); +insert into Products (product_id, store, price) values ('0', 'store2', '100'); +insert into Products (product_id, store, price) values ('1', 'store1', '70'); +insert into Products (product_id, store, price) values ('1', 'store3', '80'); diff --git a/problems/recyclable-and-low-fat-products/README.md b/problems/recyclable-and-low-fat-products/README.md index d591b2303..7a6203f4b 100644 --- a/problems/recyclable-and-low-fat-products/README.md +++ b/problems/recyclable-and-low-fat-products/README.md @@ -9,6 +9,6 @@                  [Next >](../minimum-changes-to-make-alternating-binary-string "Minimum Changes To Make Alternating Binary String") -## [1757. Recyclable and Low Fat Products (Easy)](https://leetcode.com/problems/recyclable-and-low-fat-products "") +## [1757. Recyclable and Low Fat Products (Easy)](https://leetcode.com/problems/recyclable-and-low-fat-products "可回收且低脂的产品") diff --git a/problems/remove-linked-list-elements/README.md b/problems/remove-linked-list-elements/README.md index 085bfd5c4..4ef36a677 100644 --- a/problems/remove-linked-list-elements/README.md +++ b/problems/remove-linked-list-elements/README.md @@ -11,15 +11,39 @@ ## [203. Remove Linked List Elements (Easy)](https://leetcode.com/problems/remove-linked-list-elements "移除链表元素") -

    Remove all elements from a linked list of integers that have value val.

    +

    Given the head of a linked list and an integer val, remove all the nodes of the linked list that has Node.val == val, and return the new head.

    -

    Example:

    +

     

    +

    Example 1:

    + +
    +Input: head = [1,2,6,3,4,5,6], val = 6
    +Output: [1,2,3,4,5]
    +
    + +

    Example 2:

    -Input:  1->2->6->3->4->5->6, val = 6
    -Output: 1->2->3->4->5
    +Input: head = [], val = 1
    +Output: []
     
    +

    Example 3:

    + +
    +Input: head = [7,7,7,7], val = 7
    +Output: []
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is in the range [0, 104].
    • +
    • 1 <= Node.val <= 50
    • +
    • 0 <= k <= 50
    • +
    + ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/remove-palindromic-subsequences/README.md b/problems/remove-palindromic-subsequences/README.md index 4380f54d4..3e2ee2ab9 100644 --- a/problems/remove-palindromic-subsequences/README.md +++ b/problems/remove-palindromic-subsequences/README.md @@ -11,7 +11,7 @@ ## [1332. Remove Palindromic Subsequences (Easy)](https://leetcode.com/problems/remove-palindromic-subsequences "删除回文子序列") -

    Given a string s consisting only of letters 'a' and 'b'. In a single step you can remove one palindromic subsequence from s.

    +

    Given a string s consisting only of letters 'a' and 'b'. In a single step you can remove one palindromic subsequence from s.

    Return the minimum number of steps to make the given string empty.

    @@ -46,19 +46,12 @@ Remove palindromic subsequence "a" then "bb". Remove palindromic subsequence "baab" then "b".
    -

    Example 4:

    - -
    -Input: s = ""
    -Output: 0
    -
    -

     

    Constraints:

      -
    • 0 <= s.length <= 1000
    • -
    • s only consists of letters 'a' and 'b'
    • +
    • 1 <= s.length <= 1000
    • +
    • s[i] is either 'a' or 'b'.
    ### Related Topics diff --git a/problems/reorder-list/README.md b/problems/reorder-list/README.md index a556af73d..15cbbc4ec 100644 --- a/problems/reorder-list/README.md +++ b/problems/reorder-list/README.md @@ -11,21 +11,42 @@ ## [143. Reorder List (Medium)](https://leetcode.com/problems/reorder-list "重排链表") -

    Given a singly linked list L: L0L1→…→Ln-1Ln,
    -reorder it to: L0LnL1Ln-1L2Ln-2→…

    +

    You are given the head of a singly linked-list. The list can be represented as:

    -

    You may not modify the values in the list's nodes, only nodes itself may be changed.

    +
    +L0 → L1 → … → Ln - 1 → Ln
    +
    -

    Example 1:

    +

    Reorder the list to be on the following form:

    -Given 1->2->3->4, reorder it to 1->4->2->3.
    +L0 → Ln → L1 → Ln - 1 → L2 → Ln - 2 → … + -

    Example 2:

    +

    You may not modify the values in the list's nodes. Only nodes themselves may be changed.

    + +

     

    +

    Example 1:

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

    Example 2:

    +
    -Given 1->2->3->4->5, reorder it to 1->5->2->4->3.
    +Input: head = [1,2,3,4,5]
    +Output: [1,5,2,4,3]
     
    +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is in the range [1, 5 * 104].
    • +
    • 1 <= Node.val <= 1000
    • +
    + ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/repeated-dna-sequences/README.md b/problems/repeated-dna-sequences/README.md index 0740c11c5..2e352da8d 100644 --- a/problems/repeated-dna-sequences/README.md +++ b/problems/repeated-dna-sequences/README.md @@ -11,9 +11,15 @@ ## [187. Repeated DNA Sequences (Medium)](https://leetcode.com/problems/repeated-dna-sequences "重复的DNA序列") -

    All DNA is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T', for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.

    +

    The DNA sequence is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'.

    -

    Write a function to find all the 10-letter-long sequences (substrings) that occur more than once in a DNA molecule.

    +
      +
    • For example, "ACGAATTCCG" is a DNA sequence.
    • +
    + +

    When studying DNA, it is useful to identify repeated sequences within the DNA.

    + +

    Given a string s that represents a DNA sequence, return all the 10-letter-long sequences (substrings) that occur more than once in a DNA molecule. You may return the answer in any order.

     

    Example 1:

    @@ -27,8 +33,8 @@

    Constraints:

      -
    • 0 <= s.length <= 105
    • -
    • s[i] is 'A', 'C', 'G', or 'T'.
    • +
    • 1 <= s.length <= 105
    • +
    • s[i] is either 'A', 'C', 'G', or 'T'.
    ### Related Topics diff --git a/problems/reverse-string-ii/README.md b/problems/reverse-string-ii/README.md index b968e041c..a7f75c867 100644 --- a/problems/reverse-string-ii/README.md +++ b/problems/reverse-string-ii/README.md @@ -11,22 +11,26 @@ ## [541. Reverse String II (Easy)](https://leetcode.com/problems/reverse-string-ii "反转字符串 II") -

    -Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of them. If there are less than 2k but greater than or equal to k characters, then reverse the first k characters and left the other as original. -

    - -

    Example:
    -

    -Input: s = "abcdefg", k = 2
    -Output: "bacdfeg"
    +

    Given a string s and an integer k, reverse the first k characters for every 2k characters counting from the start of the string.

    + +

    If there are fewer than k characters left, reverse all of them. If there are less than 2k but greater than or equal to k characters, then reverse the first k characters and left the other as original.

    + +

     

    +

    Example 1:

    +
    Input: s = "abcdefg", k = 2
    +Output: "bacdfeg"
    +

    Example 2:

    +
    Input: s = "abcd", k = 2
    +Output: "bacd"
     
    -

    +

     

    +

    Constraints:

    -Restrictions: -
      -
    1. The string consists of lower English letters only.
    2. -
    3. Length of the given string and k will in the range [1, 10000]
    4. -
    +
      +
    • 1 <= s.length <= 104
    • +
    • s consists of only lowercase English letters.
    • +
    • 1 <= k <= 104
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/reverse-words-in-a-string-iii/README.md b/problems/reverse-words-in-a-string-iii/README.md index 8076b5b6d..033cce7e8 100644 --- a/problems/reverse-words-in-a-string-iii/README.md +++ b/problems/reverse-words-in-a-string-iii/README.md @@ -11,18 +11,26 @@ ## [557. Reverse Words in a String III (Easy)](https://leetcode.com/problems/reverse-words-in-a-string-iii "反转字符串中的单词 III") -

    Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.

    +

    Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.

    -

    Example 1:
    -

    -Input: "Let's take LeetCode contest"
    -Output: "s'teL ekat edoCteeL tsetnoc"
    +

     

    +

    Example 1:

    +
    Input: s = "Let's take LeetCode contest"
    +Output: "s'teL ekat edoCteeL tsetnoc"
    +

    Example 2:

    +
    Input: s = "God Ding"
    +Output: "doG gniD"
     
    -

    +

     

    +

    Constraints:

    -

    Note: -In the string, each word is separated by single space and there will not be any extra space in the string. -

    +
      +
    • 1 <= s.length <= 5 * 104
    • +
    • s contains printable ASCII characters.
    • +
    • s does not contain any leading or trailing spaces.
    • +
    • There is at least one word in s.
    • +
    • All the words in s are separated by a single space.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/reverse-words-in-a-string/README.md b/problems/reverse-words-in-a-string/README.md index b7ee01055..c83eac0e6 100644 --- a/problems/reverse-words-in-a-string/README.md +++ b/problems/reverse-words-in-a-string/README.md @@ -67,14 +67,7 @@

     

    - -

    Follow up:

    - -
      -
    • Could you solve it in-place with O(1) extra space?
    • -
    - -

     

    +

    Follow up: Could you solve it in-place with O(1) extra space?

    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/russian-doll-envelopes/README.md b/problems/russian-doll-envelopes/README.md index 69574adf1..f2d04ee88 100644 --- a/problems/russian-doll-envelopes/README.md +++ b/problems/russian-doll-envelopes/README.md @@ -11,22 +11,38 @@ ## [354. Russian Doll Envelopes (Hard)](https://leetcode.com/problems/russian-doll-envelopes "俄罗斯套娃信封问题") -

    You have a number of envelopes with widths and heights given as a pair of integers (w, h). One envelope can fit into another if and only if both the width and height of one envelope is greater than the width and height of the other envelope.

    +

    You are given a 2D array of integers envelopes where envelopes[i] = [wi, hi] represents the width and the height of an envelope.

    -

    What is the maximum number of envelopes can you Russian doll? (put one inside other)

    +

    One envelope can fit into another if and only if both the width and height of one envelope is greater than the width and height of the other envelope.

    -

    Note:
    -Rotation is not allowed.

    +

    Return the maximum number of envelopes can you Russian doll (i.e., put one inside the other).

    -

    Example:

    +

    Note: You cannot rotate an envelope.

    + +

     

    +

    Example 1:

    -
    -Input: [[5,4],[6,4],[6,7],[2,3]]
    -Output: 3 
    -Explanation: The maximum number of envelopes you can Russian doll is 3 ([2,3] => [5,4] => [6,7]).
    +Input: envelopes = [[5,4],[6,4],[6,7],[2,3]]
    +Output: 3
    +Explanation: The maximum number of envelopes you can Russian doll is 3 ([2,3] => [5,4] => [6,7]).
     
    -
    + +

    Example 2:

    + +
    +Input: envelopes = [[1,1],[1,1],[1,1]]
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= envelopes.length <= 5000
    • +
    • envelopes[i].length == 2
    • +
    • 1 <= wi, hi <= 104
    • +
    ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/search-a-2d-matrix-ii/README.md b/problems/search-a-2d-matrix-ii/README.md index 0c9894026..270c208cc 100644 --- a/problems/search-a-2d-matrix-ii/README.md +++ b/problems/search-a-2d-matrix-ii/README.md @@ -11,7 +11,7 @@ ## [240. Search a 2D Matrix II (Medium)](https://leetcode.com/problems/search-a-2d-matrix-ii "搜索二维矩阵 II") -

    Write an efficient algorithm that searches for a target value in an m x n integer matrix. The matrix has the following properties:

    +

    Write an efficient algorithm that searches for a target value in an m x n integer matrix. The matrix has the following properties:

    • Integers in each row are sorted in ascending from left to right.
    • diff --git a/problems/short-encoding-of-words/README.md b/problems/short-encoding-of-words/README.md index c45811240..319b94133 100644 --- a/problems/short-encoding-of-words/README.md +++ b/problems/short-encoding-of-words/README.md @@ -39,7 +39,6 @@ words[2] = "bell", the substring of s starting from indices[2] = 5 to Input: words = ["t"] Output: 2 Explanation: A valid encoding would be s = "t#" and indices = [0]. -

     

    diff --git a/problems/shortest-path-in-a-hidden-grid/README.md b/problems/shortest-path-in-a-hidden-grid/README.md new file mode 100644 index 000000000..791e8ad3f --- /dev/null +++ b/problems/shortest-path-in-a-hidden-grid/README.md @@ -0,0 +1,35 @@ + + + + + + + +[< Previous](../products-price-for-each-store "Product's Price for Each Store") +                 +[Next >](../find-nearest-point-that-has-the-same-x-or-y-coordinate "Find Nearest Point That Has the Same X or Y Coordinate") + +## [1778. Shortest Path in a Hidden Grid (Medium)](https://leetcode.com/problems/shortest-path-in-a-hidden-grid "") + + + +### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + +### Hints +
    +Hint 1 +The grid is at a maximum 500 x 500, so it is clever to assume that the robot's initial cell is grid[501][501] +
    + +
    +Hint 2 +Run a DFS from the robot's position to make sure that you can reach the target, otherwise you should return -1. +
    + +
    +Hint 3 +Now that you are sure you can reach the target, run BFS to find the shortest path. +
    diff --git a/problems/sort-array-by-parity-ii/README.md b/problems/sort-array-by-parity-ii/README.md index 6da52d820..b09b0298f 100644 --- a/problems/sort-array-by-parity-ii/README.md +++ b/problems/sort-array-by-parity-ii/README.md @@ -11,35 +11,37 @@ ## [922. Sort Array By Parity II (Easy)](https://leetcode.com/problems/sort-array-by-parity-ii "按奇偶排序数组 II") -

    Given an array A of non-negative integers, half of the integers in A are odd, and half of the integers are even.

    +

    Given an array of integers nums, half of the integers in nums are odd, and the other half are even.

    -

    Sort the array so that whenever A[i] is odd, i is odd; and whenever A[i] is even, i is even.

    +

    Sort the array so that whenever nums[i] is odd, i is odd, and whenever nums[i] is even, i is even.

    -

    You may return any answer array that satisfies this condition.

    +

    Return any answer array that satisfies this condition.

     

    -

    Example 1:

    -Input: [4,2,5,7]
    -Output: [4,5,2,7]
    -Explanation: [4,7,2,5], [2,5,4,7], [2,7,4,5] would also have been accepted.
    +Input: nums = [4,2,5,7]
    +Output: [4,5,2,7]
    +Explanation: [4,7,2,5], [2,5,4,7], [2,7,4,5] would also have been accepted.
     
    -

     

    - -

    Note:

    +

    Example 2:

    -
      -
    1. 2 <= A.length <= 20000
    2. -
    3. A.length % 2 == 0
    4. -
    5. 0 <= A[i] <= 1000
    6. -
    +
    +Input: nums = [2,3]
    +Output: [2,3]
    +
    -

     

    -
    +

    Constraints:

    + +
      +
    • 2 <= nums.length <= 2 * 104
    • +
    • nums.length is even.
    • +
    • Half of the integers in nums are even.
    • +
    • 0 <= nums[i] <= 1000
    • +
    ### Related Topics [[Sort](../../tag/sort/README.md)] diff --git a/problems/sort-features-by-popularity/README.md b/problems/sort-features-by-popularity/README.md new file mode 100644 index 000000000..e322bd8f1 --- /dev/null +++ b/problems/sort-features-by-popularity/README.md @@ -0,0 +1,29 @@ + + + + + + + +[< Previous](../maximize-palindrome-length-from-subsequences "Maximize Palindrome Length From Subsequences") +                 +[Next >](../count-items-matching-a-rule "Count Items Matching a Rule") + +## [1772. Sort Features by Popularity (Medium)](https://leetcode.com/problems/sort-features-by-popularity "按受欢迎程度排列功能") + + + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +Use a hash map to count the frequency of each word of each string. +
    + +
    +Hint 2 +Use the map for sorting the features. +
    diff --git a/problems/split-array-with-same-average/README.md b/problems/split-array-with-same-average/README.md index 7a479df48..93d92b82d 100644 --- a/problems/split-array-with-same-average/README.md +++ b/problems/split-array-with-same-average/README.md @@ -11,26 +11,37 @@ ## [805. Split Array With Same Average (Hard)](https://leetcode.com/problems/split-array-with-same-average "数组的均值分割") -

    In a given integer array A, we must move every element of A to either list B or list C. (B and C initially start empty.)

    +

    You are given an integer array nums.

    -

    Return true if and only if after such a move, it is possible that the average value of B is equal to the average value of C, and B and C are both non-empty.

    +

    You should move each element of nums into one of the two arrays A and B such that A and B are non-empty, and average(A) == average(B).

    + +

    Return true if it is possible to achieve that and false otherwise.

    + +

    Note that for an array arr, average(arr) is the sum of all the elements of arr over the length of arr.

    + +

     

    +

    Example 1:

    -Example :
    -Input: 
    -[1,2,3,4,5,6,7,8]
    +Input: nums = [1,2,3,4,5,6,7,8]
     Output: true
    -Explanation: We can split the array into [1,4,5,8] and [2,3,6,7], and both of them have the average of 4.5.
    +Explanation: We can split the array into [1,4,5,8] and [2,3,6,7], and both of them have an average of 4.5.
     
    -

    Note:

    +

    Example 2:

    -
      -
    • The length of A will be in the range [1, 30].
    • -
    • A[i] will be in the range of [0, 10000].
    • -
    +
    +Input: nums = [3,1]
    +Output: false
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 30
    • +
    • 0 <= nums[i] <= 104
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/statistics-from-a-large-sample/README.md b/problems/statistics-from-a-large-sample/README.md index b59d03b09..519bf51be 100644 --- a/problems/statistics-from-a-large-sample/README.md +++ b/problems/statistics-from-a-large-sample/README.md @@ -11,15 +11,17 @@ ## [1093. Statistics from a Large Sample (Medium)](https://leetcode.com/problems/statistics-from-a-large-sample "大样本统计") -

    We sampled integers between 0 and 255, and stored the results in an array countcount[k] is the number of integers we sampled equal to k.

    +

    We sampled integers in the range [0, 255] and stored the results in an array count where count[k] is the number of integers we sampled equal to k.

    -

    Return the minimum, maximum, mean, median, and mode of the sample respectively, as an array of floating point numbers.  The mode is guaranteed to be unique.

    +

    Return the minimum, maximum, mean, median, and mode of the sample respectively, as an array of floating-point numbers. Answers within 10-5 of the actual answer will be considered accepted.

    -

    (Recall that the median of a sample is:

    +

    The mode is guaranteed to be unique.

    + +

    The median of a sample is:

      -
    • The middle element, if the elements of the sample were sorted and the number of elements is odd;
    • -
    • The average of the middle two elements, if the elements of the sample were sorted and the number of elements is even.)
    • +
    • The middle element, if the elements of the sample were sorted and the number of elements is odd, or
    • +
    • The average of the middle two elements, if the elements of the sample were sorted and the number of elements is even.

     

    @@ -33,12 +35,12 @@

     

    Constraints:

    -
      +
      • count.length == 256
      • -
      • 1 <= sum(count) <= 10^9
      • -
      • The mode of the sample that count represents is unique.
      • -
      • Answers within 10^-5 of the true value will be accepted as correct.
      • -
    +
  • 0 <= count[i] <= 256
  • +
  • 1 <= sum(count) <= 109
  • +
  • The mode of the sample that count represents is unique.
  • + ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/student-attendance-record-i/README.md b/problems/student-attendance-record-i/README.md index 4cc3b0c62..db14aff35 100644 --- a/problems/student-attendance-record-i/README.md +++ b/problems/student-attendance-record-i/README.md @@ -11,34 +11,32 @@ ## [551. Student Attendance Record I (Easy)](https://leetcode.com/problems/student-attendance-record-i "学生出勤记录 I") -You are given a string representing an attendance record for a student. The record only contains the following three characters: - -

    -

      -
    1. 'A' : Absent.
    2. -
    3. 'L' : Late.
    4. -
    5. 'P' : Present.
    6. -
    -

    - -

    -A student could be rewarded if his attendance record doesn't contain more than one 'A' (absent) or more than two continuous 'L' (late).

    - -

    You need to return whether the student could be rewarded according to his attendance record.

    - -

    Example 1:
    -

    -Input: "PPALLP"
    -Output: True
    +You are given a string s representing an attendance record for a student. The record only contains the following three characters:
    +
      +
    • 'A': Absent.
    • +
    • 'L': Late.
    • +
    • 'P': Present.
    • +
    + +

    A student could be rewarded if his attendance record does not contain more than one 'A' (absent) or more than two consecutive 'L' (late).

    + +

    Return true if the student could be rewarded according to his attendance record, and false otherwise.

    + +

     

    +

    Example 1:

    +
    Input: s = "PPALLP"
    +Output: true
    +

    Example 2:

    +
    Input: s = "PPALLL"
    +Output: false
     
    -

    +

     

    +

    Constraints:

    -

    Example 2:
    -

    -Input: "PPALLL"
    -Output: False
    -
    -

    +
      +
    • 1 <= s.length <= 1000
    • +
    • s[i] is either 'A', 'L', or 'P'.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/student-attendance-record-ii/README.md b/problems/student-attendance-record-ii/README.md index 10ad57c82..20b3cfd87 100644 --- a/problems/student-attendance-record-ii/README.md +++ b/problems/student-attendance-record-ii/README.md @@ -11,35 +11,49 @@ ## [552. Student Attendance Record II (Hard)](https://leetcode.com/problems/student-attendance-record-ii "学生出勤记录 II") -

    Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, return it after mod 109 + 7.

    +

    Given an integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, return it modulo 109 + 7.

    A student attendance record is a string that only contains the following three characters:

    -

    -

      -
    1. 'A' : Absent.
    2. -
    3. 'L' : Late.
    4. -
    5. 'P' : Present.
    6. -
    -

    +
      +
    • 'A': Absent.
    • +
    • 'L': Late.
    • +
    • 'P': Present.
    • +
    -

    -A record is regarded as rewardable if it doesn't contain more than one 'A' (absent) or more than two continuous 'L' (late).

    +

    A record is regarded as rewardable if it does not contain more than one 'A' (absent) or more than two consecutive 'L' (late).

    + +

     

    +

    Example 1:

    + +
    +Input: n = 2
    +Output: 8
    +Explanation: There are 8 records with length 2 will be regarded as rewardable:
    +"PP" , "AP", "PA", "LP", "PL", "AL", "LA", "LL"
    +Only "AA" won't be regarded as rewardable owing to more than one absent time.
    +
    + +

    Example 2:

    -

    Example 1:

    -Input: n = 2
    -Output: 8 
    -Explanation:
    -There are 8 records with length 2 will be regarded as rewardable:
    -"PP" , "AP", "PA", "LP", "PL", "AL", "LA", "LL"
    -Only "AA" won't be regarded as rewardable owing to more than one absent times. 
    +Input: n = 1
    +Output: 3
     
    -

    -

    Note: -The value of n won't exceed 100,000. -

    +

    Example 3:

    + +
    +Input: n = 10101
    +Output: 183236316
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 105
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/sum-of-beauty-of-all-substrings/README.md b/problems/sum-of-beauty-of-all-substrings/README.md new file mode 100644 index 000000000..3f91dbd23 --- /dev/null +++ b/problems/sum-of-beauty-of-all-substrings/README.md @@ -0,0 +1,58 @@ + + + + + + + +[< Previous](../check-if-number-is-a-sum-of-powers-of-three "Check if Number is a Sum of Powers of Three") +                 +[Next >](../count-pairs-of-nodes "Count Pairs Of Nodes") + +## [1781. Sum of Beauty of All Substrings (Medium)](https://leetcode.com/problems/sum-of-beauty-of-all-substrings "所有子字符串美丽值之和") + +

    The beauty of a string is the difference in frequencies between the most frequent and least frequent characters.

    + +
      +
    • For example, the beauty of "abaacc" is 3 - 1 = 2.
    • +
    + +

    Given a string s, return the sum of beauty of all of its substrings.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "aabcb"
    +Output: 5
    +Explanation: The substrings with non-zero beauty are ["aab","aabc","aabcb","abcb","bcb"], each with beauty equal to 1.
    + +

    Example 2:

    + +
    +Input: s = "aabcbaa"
    +Output: 17
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 500
    • +
    • s consists of only lowercase English letters.
    • +
    + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Maintain a prefix sum for the frequencies of characters. +
    + +
    +Hint 2 +You can iterate over all substring then iterate over the alphabet and find which character appears most and which appears least using the prefix sum array +
    diff --git a/problems/sum-of-two-integers/README.md b/problems/sum-of-two-integers/README.md index 2246f3da4..e28244e2c 100644 --- a/problems/sum-of-two-integers/README.md +++ b/problems/sum-of-two-integers/README.md @@ -9,27 +9,24 @@                  [Next >](../super-pow "Super Pow") -## [371. Sum of Two Integers (Easy)](https://leetcode.com/problems/sum-of-two-integers "两整数之和") +## [371. Sum of Two Integers (Medium)](https://leetcode.com/problems/sum-of-two-integers "两整数之和") -

    Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.

    +

    Given two integers a and b, return the sum of the two integers without using the operators + and -.

    -
    +

     

    Example 1:

    - -
    -Input: a = 1, b = 2
    -Output: 3
    +
    Input: a = 1, b = 2
    +Output: 3
    +

    Example 2:

    +
    Input: a = 2, b = 3
    +Output: 5
     
    +

     

    +

    Constraints:

    -
    -

    Example 2:

    - -
    -Input: a = -2, b = 3
    -Output: 1
    -
    -
    -
    +
      +
    • -1000 <= a, b <= 1000
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/sum-root-to-leaf-numbers/README.md b/problems/sum-root-to-leaf-numbers/README.md index f5f8ef2f9..86cd2f79e 100644 --- a/problems/sum-root-to-leaf-numbers/README.md +++ b/problems/sum-root-to-leaf-numbers/README.md @@ -9,7 +9,7 @@                  [Next >](../surrounded-regions "Surrounded Regions") -## [129. Sum Root to Leaf Numbers (Medium)](https://leetcode.com/problems/sum-root-to-leaf-numbers "求根到叶子节点数字之和") +## [129. Sum Root to Leaf Numbers (Medium)](https://leetcode.com/problems/sum-root-to-leaf-numbers "求根节点到叶节点数字之和")

    You are given the root of a binary tree containing digits from 0 to 9 only.

    diff --git a/problems/super-egg-drop/README.md b/problems/super-egg-drop/README.md index 469a1468f..940fd886a 100644 --- a/problems/super-egg-drop/README.md +++ b/problems/super-egg-drop/README.md @@ -11,63 +11,52 @@ ## [887. Super Egg Drop (Hard)](https://leetcode.com/problems/super-egg-drop "鸡蛋掉落") -

    You are given K eggs, and you have access to a building with N floors from 1 to N

    +

    You are given k eggs, and you have access to a building with n floors labeled from 1 to n.

    -

    Each egg is identical in function, and if an egg breaks, you cannot drop it again.

    +

    Each egg is identical in function, and if an egg breaks, you cannot drop it again.

    -

    You know that there exists a floor F with 0 <= F <= N such that any egg dropped at a floor higher than F will break, and any egg dropped at or below floor F will not break.

    +

    You know that there exists a floor f with 0 <= f <= n such that any egg dropped at a floor higher than f will break, and any egg dropped at or below floor f will not break.

    -

    Each move, you may take an egg (if you have an unbroken one) and drop it from any floor X (with 1 <= X <= N). 

    +

    Each move, you may take an egg (if you have an unbroken one) and drop it from any floor x (with 1 <= x <= n).

    -

    Your goal is to know with certainty what the value of F is.

    +

    Your goal is to know with certainty what the value of f is.

    -

    What is the minimum number of moves that you need to know with certainty what F is, regardless of the initial value of F?

    +

    Return the minimum number of moves that you need to know with certainty the value of f.

     

    - -
      -
    - -

    Example 1:

    -Input: K = 1, N = 2
    -Output: 2
    +Input: k = 1, n = 2
    +Output: 2
     Explanation: 
    -Drop the egg from floor 1.  If it breaks, we know with certainty that F = 0.
    -Otherwise, drop the egg from floor 2.  If it breaks, we know with certainty that F = 1.
    -If it didn't break, then we know with certainty F = 2.
    -Hence, we needed 2 moves in the worst case to know what F is with certainty.
    +Drop the egg from floor 1. If it breaks, we know with certainty that f = 0.
    +Otherwise, drop the egg from floor 2. If it breaks, we know with certainty that f = 1.
    +If it did not break, then we know with certainty f = 2.
    +Hence, we needed 2 moves in the worst case to know what f is with certainty.
     
    -

    Example 2:

    -Input: K = 2, N = 6
    -Output: 3
    +Input: k = 2, n = 6
    +Output: 3
     
    -

    Example 3:

    -Input: K = 3, N = 14
    -Output: 4
    +Input: k = 3, n = 14
    +Output: 4
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= K <= 100
    2. -
    3. 1 <= N <= 10000
    4. -
    -
    -
    -
    +
      +
    • 1 <= k <= 100
    • +
    • 1 <= n <= 104
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/super-ugly-number/README.md b/problems/super-ugly-number/README.md index df2add319..e12b2ba83 100644 --- a/problems/super-ugly-number/README.md +++ b/problems/super-ugly-number/README.md @@ -11,25 +11,38 @@ ## [313. Super Ugly Number (Medium)](https://leetcode.com/problems/super-ugly-number "超级丑数") -

    Write a program to find the nth super ugly number.

    +

    Given an integer n and an array of integers primes, return the nth super ugly number.

    -

    Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k.

    +

    Super ugly number is a positive number whose all prime factors are in the array primes.

    -

    Example:

    +

    The nth super ugly number is guaranteed to fit in a 32-bit signed integer.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 12, primes = [2,7,13,19]
    +Output: 32
    +Explanation: [1,2,4,7,8,13,14,16,19,26,28,32] is the sequence of the first 12 super ugly numbers given primes == [2,7,13,19].
    +
    + +

    Example 2:

    -Input: n = 12, primes = [2,7,13,19]
    -Output: 32 
    -Explanation: [1,2,4,7,8,13,14,16,19,26,28,32] is the sequence of the first 12 
    -             super ugly numbers given primes = [2,7,13,19] of size 4.
    +Input: n = 1, primes = [2,3,5] +Output: 1 +Explanation: 1 is a super ugly number for any given primes. +
    -

    Note:

    +

     

    +

    Constraints:

      -
    • 1 is a super ugly number for any given primes.
    • -
    • The given numbers in primes are in ascending order.
    • -
    • 0 < k ≤ 100, 0 < n ≤ 106, 0 < primes[i] < 1000.
    • -
    • The nth super ugly number is guaranteed to fit in a 32-bit signed integer.
    • +
    • 1 <= n <= 106
    • +
    • 1 <= primes.length <= 100
    • +
    • 2 <= primes[i] <= 1000
    • +
    • primes[i] is guaranteed to be a prime number.
    • +
    • All the values of primes are unique and sorted in ascending order.
    ### Related Topics diff --git a/problems/transpose-file/README.md b/problems/transpose-file/README.md index ec2f0ca36..7c56747f8 100644 --- a/problems/transpose-file/README.md +++ b/problems/transpose-file/README.md @@ -13,7 +13,7 @@

    Given a text file file.txt, transpose its content.

    -

    You may assume that each row has the same number of columns and each field is separated by the ' ' character.

    +

    You may assume that each row has the same number of columns, and each field is separated by the ' ' character.

    Example:

    @@ -31,5 +31,3 @@ ryan 30 name alice ryan age 21 30
    - -

     

    diff --git a/problems/ugly-number-ii/README.md b/problems/ugly-number-ii/README.md index 12bc00022..3ae2905dd 100644 --- a/problems/ugly-number-ii/README.md +++ b/problems/ugly-number-ii/README.md @@ -11,23 +11,33 @@ ## [264. Ugly Number II (Medium)](https://leetcode.com/problems/ugly-number-ii "丑数 II") -

    Write a program to find the n-th ugly number.

    +

    Given an integer n, return the nth ugly number.

    -

    Ugly numbers are positive numbers whose prime factors only include 2, 3, 5

    +

    Ugly number is a positive number whose prime factors only include 2, 3, and/or 5.

    -

    Example:

    +

     

    +

    Example 1:

     Input: n = 10
     Output: 12
    -Explanation: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly numbers.
    +Explanation: [1, 2, 3, 4, 5, 6, 8, 9, 10, 12] is the sequence of the first 10 ugly numbers. + -

    Note:  

    +

    Example 2:

    -
      -
    1. 1 is typically treated as an ugly number.
    2. -
    3. n does not exceed 1690.
    4. -
    +
    +Input: n = 1
    +Output: 1
    +Explanation: 1 is typically treated as an ugly number.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 1690
    • +
    ### Related Topics [[Heap](../../tag/heap/README.md)] diff --git a/problems/ugly-number-iii/README.md b/problems/ugly-number-iii/README.md index 03f1f90e1..72cbe62de 100644 --- a/problems/ugly-number-iii/README.md +++ b/problems/ugly-number-iii/README.md @@ -21,14 +21,15 @@
     Input: n = 3, a = 2, b = 3, c = 5
     Output: 4
    -Explanation: The ugly numbers are 2, 3, 4, 5, 6, 8, 9, 10... The 3rd is 4.
    +Explanation: The ugly numbers are 2, 3, 4, 5, 6, 8, 9, 10... The 3rd is 4. +

    Example 2:

     Input: n = 4, a = 2, b = 3, c = 4
     Output: 6
    -Explanation: The ugly numbers are 2, 3, 4, 6, 8, 9, 10, 12... The 4th is 6.
    +Explanation: The ugly numbers are 2, 3, 4, 6, 8, 9, 10, 12... The 4th is 6.
     

    Example 3:

    @@ -36,7 +37,7 @@
     Input: n = 5, a = 2, b = 11, c = 13
     Output: 10
    -Explanation: The ugly numbers are 2, 4, 6, 8, 10, 11, 12, 13... The 5th is 10.
    +Explanation: The ugly numbers are 2, 4, 6, 8, 10, 11, 12, 13... The 5th is 10.
     

    Example 4:

    diff --git a/problems/ugly-number/README.md b/problems/ugly-number/README.md index 47f61475e..42513d22b 100644 --- a/problems/ugly-number/README.md +++ b/problems/ugly-number/README.md @@ -11,39 +11,48 @@ ## [263. Ugly Number (Easy)](https://leetcode.com/problems/ugly-number "丑数") -

    Write a program to check whether a given number is an ugly number.

    +

    Given an integer n, return true if n is an ugly number.

    -

    Ugly numbers are positive numbers whose prime factors only include 2, 3, 5.

    +

    Ugly number is a positive number whose prime factors only include 2, 3, and/or 5.

    +

     

    Example 1:

    -Input: 6
    +Input: n = 6
     Output: true
    -Explanation: 6 = 2 × 3
    +Explanation: 6 = 2 × 3

    Example 2:

    -Input: 8
    +Input: n = 8
     Output: true
    -Explanation: 8 = 2 × 2 × 2
    +Explanation: 8 = 2 × 2 × 2
     

    Example 3:

    -Input: 14
    -Output: false 
    -Explanation: 14 is not ugly since it includes another prime factor 7.
    +Input: n = 14
    +Output: false
    +Explanation: 14 is not ugly since it includes another prime factor 7.
     
    -

    Note:

    +

    Example 4:

    -
      -
    1. 1 is typically treated as an ugly number.
    2. -
    3. Input is within the 32-bit signed integer range: [−231,  231 − 1].
    4. -
    +
    +Input: n = 1
    +Output: true
    +Explanation: 1 is typically treated as an ugly number.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • -231 <= n <= 231 - 1
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/unique-email-addresses/README.md b/problems/unique-email-addresses/README.md index bd66b8fc8..736b95979 100644 --- a/problems/unique-email-addresses/README.md +++ b/problems/unique-email-addresses/README.md @@ -11,43 +11,55 @@ ## [929. Unique Email Addresses (Easy)](https://leetcode.com/problems/unique-email-addresses "独特的电子邮件地址") -

    Every email consists of a local name and a domain name, separated by the @ sign.

    +

    Every valid email consists of a local name and a domain name, separated by the '@' sign. Besides lowercase letters, the email may contain one or more '.' or '+'.

    -

    For example, in alice@leetcode.comalice is the local name, and leetcode.com is the domain name.

    +
      +
    • For example, in "alice@leetcode.com", "alice" is the local name, and "leetcode.com" is the domain name.
    • +
    -

    Besides lowercase letters, these emails may contain '.'s or '+'s.

    +

    If you add periods '.' between some characters in the local name part of an email address, mail sent there will be forwarded to the same address without dots in the local name. Note that this rule does not apply to domain names.

    -

    If you add periods ('.') between some characters in the local name part of an email address, mail sent there will be forwarded to the same address without dots in the local name.  For example, "alice.z@leetcode.com" and "alicez@leetcode.com" forward to the same email address.  (Note that this rule does not apply for domain names.)

    +
      +
    • For example, "alice.z@leetcode.com" and "alicez@leetcode.com" forward to the same email address.
    • +
    -

    If you add a plus ('+') in the local name, everything after the first plus sign will be ignored. This allows certain emails to be filtered, for example m.y+name@email.com will be forwarded to my@email.com.  (Again, this rule does not apply for domain names.)

    +

    If you add a plus '+' in the local name, everything after the first plus sign will be ignored. This allows certain emails to be filtered. Note that this rule does not apply to domain names.

    + +
      +
    • For example, "m.y+name@email.com" will be forwarded to "my@email.com".
    • +

    It is possible to use both of these rules at the same time.

    -

    Given a list of emails, we send one email to each address in the list.  How many different addresses actually receive mails? 

    +

    Given an array of strings emails where we send one email to each email[i], return the number of different addresses that actually receive mails.

     

    - -

    Example 1:

    -Input: ["test.email+alex@leetcode.com","test.e.mail+bob.cathy@leetcode.com","testemail+david@lee.tcode.com"]
    -Output: 2
    -Explanation: "testemail@leetcode.com" and "testemail@lee.tcode.com" actually receive mails
    +Input: emails = ["test.email+alex@leetcode.com","test.e.mail+bob.cathy@leetcode.com","testemail+david@lee.tcode.com"]
    +Output: 2
    +Explanation: "testemail@leetcode.com" and "testemail@lee.tcode.com" actually receive mails.
     
    -

     

    +

    Example 2:

    + +
    +Input: emails = ["a@leetcode.com","b@leetcode.com","c@leetcode.com"]
    +Output: 3
    +
    -

    Note:

    +

     

    +

    Constraints:

      -
    • 1 <= emails[i].length <= 100
    • 1 <= emails.length <= 100
    • +
    • 1 <= emails[i].length <= 100
    • +
    • email[i] consist of lowercase English letters, '+', '.' and '@'.
    • Each emails[i] contains exactly one '@' character.
    • All local and domain names are non-empty.
    • Local names do not start with a '+' character.
    -
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/valid-boomerang/README.md b/problems/valid-boomerang/README.md index 4ae5826c4..a1275f407 100644 --- a/problems/valid-boomerang/README.md +++ b/problems/valid-boomerang/README.md @@ -11,40 +11,26 @@ ## [1037. Valid Boomerang (Easy)](https://leetcode.com/problems/valid-boomerang "有效的回旋镖") -

    A boomerang is a set of 3 points that are all distinct and not in a straight line.

    +

    Given an array points where points[i] = [xi, yi] represents a point on the X-Y plane, return true if these points are a boomerang.

    -

    Given a list of three points in the plane, return whether these points are a boomerang.

    +

    A boomerang is a set of three points that are all distinct and not in a straight line.

     

    -

    Example 1:

    - -
    -Input: [[1,1],[2,3],[3,2]]
    -Output: true
    +
    Input: points = [[1,1],[2,3],[3,2]]
    +Output: true
    +

    Example 2:

    +
    Input: points = [[1,1],[2,2],[3,3]]
    +Output: false
     
    - -
    -

    Example 2:

    - -
    -Input: [[1,1],[2,2],[3,3]]
    -Output: false
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • points.length == 3
      • points[i].length == 2
      • -
      • 0 <= points[i][j] <= 100
      • -
    - -
    -
     
    -
    +
  • 0 <= xi, yi <= 100
  • + ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/valid-phone-numbers/README.md b/problems/valid-phone-numbers/README.md index ff3a84800..bb41929e2 100644 --- a/problems/valid-phone-numbers/README.md +++ b/problems/valid-phone-numbers/README.md @@ -11,7 +11,7 @@ ## [193. Valid Phone Numbers (Easy)](https://leetcode.com/problems/valid-phone-numbers "有效电话号码") -

    Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bash script to print all valid phone numbers.

    +

    Given a text file file.txt that contains a list of phone numbers (one per line), write a one-liner bash script to print all valid phone numbers.

    You may assume that a valid phone number must appear in one of the following two formats: (xxx) xxx-xxxx or xxx-xxx-xxxx. (x means a digit)

    diff --git a/problems/word-break-ii/README.md b/problems/word-break-ii/README.md index 5bfaa2a84..56c94652b 100644 --- a/problems/word-break-ii/README.md +++ b/problems/word-break-ii/README.md @@ -11,51 +11,43 @@ ## [140. Word Break II (Hard)](https://leetcode.com/problems/word-break-ii "单词拆分 II") -

    Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences.

    +

    Given a string s and a dictionary of strings wordDict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences in any order.

    -

    Note:

    - -
      -
    • The same word in the dictionary may be reused multiple times in the segmentation.
    • -
    • You may assume the dictionary does not contain duplicate words.
    • -
    +

    Note that the same word in the dictionary may be reused multiple times in the segmentation.

    +

     

    Example 1:

    -Input:
    -s = "catsanddog"
    -wordDict = ["cat", "cats", "and", "sand", "dog"]
    -Output:
    -[
    -  "cats and dog",
    -  "cat sand dog"
    -]
    +Input: s = "catsanddog", wordDict = ["cat","cats","and","sand","dog"]
    +Output: ["cats and dog","cat sand dog"]
     

    Example 2:

    -Input:
    -s = "pineapplepenapple"
    -wordDict = ["apple", "pen", "applepen", "pine", "pineapple"]
    -Output:
    -[
    -  "pine apple pen apple",
    -  "pineapple pen apple",
    -  "pine applepen apple"
    -]
    +Input: s = "pineapplepenapple", wordDict = ["apple","pen","applepen","pine","pineapple"]
    +Output: ["pine apple pen apple","pineapple pen apple","pine applepen apple"]
     Explanation: Note that you are allowed to reuse a dictionary word.
     

    Example 3:

    -Input:
    -s = "catsandog"
    -wordDict = ["cats", "dog", "sand", "and", "cat"]
    -Output:
    -[]
    +Input: s = "catsandog", wordDict = ["cats","dog","sand","and","cat"] +Output: [] +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 20
    • +
    • 1 <= wordDict.length <= 1000
    • +
    • 1 <= wordDict[i].length <= 10
    • +
    • s and wordDict[i] consist of only lowercase English letters.
    • +
    • All the strings of wordDict are unique.
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/word-break/README.md b/problems/word-break/README.md index b33b0291e..b061997e4 100644 --- a/problems/word-break/README.md +++ b/problems/word-break/README.md @@ -11,39 +11,46 @@ ## [139. Word Break (Medium)](https://leetcode.com/problems/word-break "单词拆分") -

    Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.

    +

    Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words.

    -

    Note:

    - -
      -
    • The same word in the dictionary may be reused multiple times in the segmentation.
    • -
    • You may assume the dictionary does not contain duplicate words.
    • -
    +

    Note that the same word in the dictionary may be reused multiple times in the segmentation.

    +

     

    Example 1:

    -Input: s = "leetcode", wordDict = ["leet", "code"]
    +Input: s = "leetcode", wordDict = ["leet","code"]
     Output: true
    -Explanation: Return true because "leetcode" can be segmented as "leet code".
    +Explanation: Return true because "leetcode" can be segmented as "leet code".
     

    Example 2:

    -Input: s = "applepenapple", wordDict = ["apple", "pen"]
    +Input: s = "applepenapple", wordDict = ["apple","pen"]
     Output: true
    -Explanation: Return true because "applepenapple" can be segmented as "apple pen apple".
    -             Note that you are allowed to reuse a dictionary word.
    +Explanation: Return true because "applepenapple" can be segmented as "apple pen apple".
    +Note that you are allowed to reuse a dictionary word.
     

    Example 3:

    -Input: s = "catsandog", wordDict = ["cats", "dog", "sand", "and", "cat"]
    +Input: s = "catsandog", wordDict = ["cats","dog","sand","and","cat"]
     Output: false
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 300
    • +
    • 1 <= wordDict.length <= 1000
    • +
    • 1 <= wordDict[i].length <= 20
    • +
    • s and wordDict[i] consist of only lowercase English letters.
    • +
    • All the strings of wordDict are unique.
    • +
    + ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/word-search/README.md b/problems/word-search/README.md index b3ad25f25..7d0419bff 100644 --- a/problems/word-search/README.md +++ b/problems/word-search/README.md @@ -11,9 +11,11 @@ ## [79. Word Search (Medium)](https://leetcode.com/problems/word-search "单词搜索") -

    Given an m x n board and a word, find if the word exists in the grid.

    +

    Given an m x n grid of characters board and a string word, return true if word exists in the grid.

    -

    The word can be constructed from letters of sequentially adjacent cells, where "adjacent" cells are horizontally or vertically neighboring. The same letter cell may not be used more than once.

    +

    The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once.

    + +

    Note: There will be some test cases with a board or a word larger than constraints to test if your solution is using pruning.

     

    Example 1:

    @@ -43,9 +45,9 @@
    • m == board.length
    • n = board[i].length
    • -
    • 1 <= m, n <= 200
    • -
    • 1 <= word.length <= 103
    • -
    • board and word consists only of lowercase and uppercase English letters.
    • +
    • 1 <= m, n <= 6
    • +
    • 1 <= word.length <= 15
    • +
    • board and word consists of only lowercase and uppercase English letters.
    ### Related Topics diff --git a/readme/1-300.md b/readme/1-300.md index af0abba75..ee7426b72 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -114,7 +114,7 @@ LeetCode Problems' Solutions | 42 | [Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water "接雨水") | [Go](../problems/trapping-rain-water) | Hard | | 43 | [Multiply Strings](https://leetcode.com/problems/multiply-strings "字符串相乘") | [Go](../problems/multiply-strings) | Medium | | 44 | [Wildcard Matching](https://leetcode.com/problems/wildcard-matching "通配符匹配") | [Go](../problems/wildcard-matching) | Hard | -| 45 | [Jump Game II](https://leetcode.com/problems/jump-game-ii "跳跃游戏 II") | [Go](../problems/jump-game-ii) | Hard | +| 45 | [Jump Game II](https://leetcode.com/problems/jump-game-ii "跳跃游戏 II") | [Go](../problems/jump-game-ii) | Medium | | 46 | [Permutations](https://leetcode.com/problems/permutations "全排列") | [Go](../problems/permutations) | Medium | | 47 | [Permutations II](https://leetcode.com/problems/permutations-ii "全排列 II") | [Go](../problems/permutations-ii) | Medium | | 48 | [Rotate Image](https://leetcode.com/problems/rotate-image "旋转图像") | [Go](../problems/rotate-image) | Medium | @@ -198,7 +198,7 @@ LeetCode Problems' Solutions | 126 | [Word Ladder II](https://leetcode.com/problems/word-ladder-ii "单词接龙 II") | [Go](../problems/word-ladder-ii) | Hard | | 127 | [Word Ladder](https://leetcode.com/problems/word-ladder "单词接龙") | [Go](../problems/word-ladder) | Hard | | 128 | [Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence "最长连续序列") | [Go](../problems/longest-consecutive-sequence) | Hard | -| 129 | [Sum Root to Leaf Numbers](https://leetcode.com/problems/sum-root-to-leaf-numbers "求根到叶子节点数字之和") | [Go](../problems/sum-root-to-leaf-numbers) | Medium | +| 129 | [Sum Root to Leaf Numbers](https://leetcode.com/problems/sum-root-to-leaf-numbers "求根节点到叶节点数字之和") | [Go](../problems/sum-root-to-leaf-numbers) | Medium | | 130 | [Surrounded Regions](https://leetcode.com/problems/surrounded-regions "被围绕的区域") | [Go](../problems/surrounded-regions) | Medium | | 131 | [Palindrome Partitioning](https://leetcode.com/problems/palindrome-partitioning "分割回文串") | [Go](../problems/palindrome-partitioning) | Medium | | 132 | [Palindrome Partitioning II](https://leetcode.com/problems/palindrome-partitioning-ii "分割回文串 II") | [Go](../problems/palindrome-partitioning-ii) | Hard | @@ -345,7 +345,7 @@ LeetCode Problems' Solutions | 273 | [Integer to English Words](https://leetcode.com/problems/integer-to-english-words "整数转换英文表示") | [Go](../problems/integer-to-english-words) | Hard | | 274 | [H-Index](https://leetcode.com/problems/h-index "H 指数") | [Go](../problems/h-index) | Medium | | 275 | [H-Index II](https://leetcode.com/problems/h-index-ii "H 指数 II") | [Go](../problems/h-index-ii) | Medium | -| 276 | [Paint Fence](https://leetcode.com/problems/paint-fence "栅栏涂色") 🔒 | [Go](../problems/paint-fence) | Easy | +| 276 | [Paint Fence](https://leetcode.com/problems/paint-fence "栅栏涂色") 🔒 | [Go](../problems/paint-fence) | Medium | | 277 | [Find the Celebrity](https://leetcode.com/problems/find-the-celebrity "搜寻名人") 🔒 | [Go](../problems/find-the-celebrity) | Medium | | 278 | [First Bad Version](https://leetcode.com/problems/first-bad-version "第一个错误的版本") | [Go](../problems/first-bad-version) | Easy | | 279 | [Perfect Squares](https://leetcode.com/problems/perfect-squares "完全平方数") | [Go](../problems/perfect-squares) | Medium | @@ -354,7 +354,7 @@ LeetCode Problems' Solutions | 282 | [Expression Add Operators](https://leetcode.com/problems/expression-add-operators "给表达式添加运算符") | [Go](../problems/expression-add-operators) | Hard | | 283 | [Move Zeroes](https://leetcode.com/problems/move-zeroes "移动零") | [Go](../problems/move-zeroes) | Easy | | 284 | [Peeking Iterator](https://leetcode.com/problems/peeking-iterator "顶端迭代器") | [Go](../problems/peeking-iterator) | Medium | -| 285 | [Inorder Successor in BST](https://leetcode.com/problems/inorder-successor-in-bst "二叉搜索树中的顺序后继") 🔒 | [Go](../problems/inorder-successor-in-bst) | Medium | +| 285 | [Inorder Successor in BST](https://leetcode.com/problems/inorder-successor-in-bst "二叉搜索树中的中序后继") 🔒 | [Go](../problems/inorder-successor-in-bst) | Medium | | 286 | [Walls and Gates](https://leetcode.com/problems/walls-and-gates "墙与门") 🔒 | [Go](../problems/walls-and-gates) | Medium | | 287 | [Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number "寻找重复数") | [Go](../problems/find-the-duplicate-number) | Medium | | 288 | [Unique Word Abbreviation](https://leetcode.com/problems/unique-word-abbreviation "单词的唯一缩写") 🔒 | [Go](../problems/unique-word-abbreviation) | Medium | diff --git a/readme/301-600.md b/readme/301-600.md index abdde95ce..bacc496a6 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -164,7 +164,7 @@ LeetCode Problems' Solutions | 392 | [Is Subsequence](https://leetcode.com/problems/is-subsequence "判断子序列") | [Go](../problems/is-subsequence) | Easy | | 393 | [UTF-8 Validation](https://leetcode.com/problems/utf-8-validation "UTF-8 编码验证") | [Go](../problems/utf-8-validation) | Medium | | 394 | [Decode String](https://leetcode.com/problems/decode-string "字符串解码") | [Go](../problems/decode-string) | Medium | -| 395 | [Longest Substring with At Least K Repeating Characters](https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters "至少有K个重复字符的最长子串") | [Go](../problems/longest-substring-with-at-least-k-repeating-characters) | Medium | +| 395 | [Longest Substring with At Least K Repeating Characters](https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters "至少有 K 个重复字符的最长子串") | [Go](../problems/longest-substring-with-at-least-k-repeating-characters) | Medium | | 396 | [Rotate Function](https://leetcode.com/problems/rotate-function "旋转函数") | [Go](../problems/rotate-function) | Medium | | 397 | [Integer Replacement](https://leetcode.com/problems/integer-replacement "整数替换") | [Go](../problems/integer-replacement) | Medium | | 398 | [Random Pick Index](https://leetcode.com/problems/random-pick-index "随机数索引") | [Go](../problems/random-pick-index) | Medium | @@ -226,7 +226,7 @@ LeetCode Problems' Solutions | 454 | [4Sum II](https://leetcode.com/problems/4sum-ii "四数相加 II") | [Go](../problems/4sum-ii) | Medium | | 455 | [Assign Cookies](https://leetcode.com/problems/assign-cookies "分发饼干") | [Go](../problems/assign-cookies) | Easy | | 456 | [132 Pattern](https://leetcode.com/problems/132-pattern "132模式") | [Go](../problems/132-pattern) | Medium | -| 457 | [Circular Array Loop](https://leetcode.com/problems/circular-array-loop "环形数组循环") | [Go](../problems/circular-array-loop) | Medium | +| 457 | [Circular Array Loop](https://leetcode.com/problems/circular-array-loop "环形数组是否存在循环") | [Go](../problems/circular-array-loop) | Medium | | 458 | [Poor Pigs](https://leetcode.com/problems/poor-pigs "可怜的小猪") | [Go](../problems/poor-pigs) | Hard | | 459 | [Repeated Substring Pattern](https://leetcode.com/problems/repeated-substring-pattern "重复的子字符串") | [Go](../problems/repeated-substring-pattern) | Easy | | 460 | [LFU Cache](https://leetcode.com/problems/lfu-cache "LFU 缓存") | [Go](../problems/lfu-cache) | Hard | @@ -351,15 +351,15 @@ LeetCode Problems' Solutions | 579 | [Find Cumulative Salary of an Employee](https://leetcode.com/problems/find-cumulative-salary-of-an-employee "查询员工的累计薪水") 🔒 | [MySQL](../problems/find-cumulative-salary-of-an-employee) | Hard | | 580 | [Count Student Number in Departments](https://leetcode.com/problems/count-student-number-in-departments "统计各专业学生人数") 🔒 | [MySQL](../problems/count-student-number-in-departments) | Medium | | 581 | [Shortest Unsorted Continuous Subarray](https://leetcode.com/problems/shortest-unsorted-continuous-subarray "最短无序连续子数组") | [Go](../problems/shortest-unsorted-continuous-subarray) | Medium | -| 582 | [Kill Process](https://leetcode.com/problems/kill-process "杀死进程") 🔒 | [Go](../problems/kill-process) | Medium | +| 582 | [Kill Process](https://leetcode.com/problems/kill-process "杀掉进程") 🔒 | [Go](../problems/kill-process) | Medium | | 583 | [Delete Operation for Two Strings](https://leetcode.com/problems/delete-operation-for-two-strings "两个字符串的删除操作") | [Go](../problems/delete-operation-for-two-strings) | Medium | | 584 | [Find Customer Referee](https://leetcode.com/problems/find-customer-referee "寻找用户推荐人") 🔒 | [MySQL](../problems/find-customer-referee) | Easy | | 585 | [Investments in 2016](https://leetcode.com/problems/investments-in-2016 "2016年的投资") 🔒 | [MySQL](../problems/investments-in-2016) | Medium | | 586 | [Customer Placing the Largest Number of Orders](https://leetcode.com/problems/customer-placing-the-largest-number-of-orders "订单最多的客户") 🔒 | [MySQL](../problems/customer-placing-the-largest-number-of-orders) | Easy | | 587 | [Erect the Fence](https://leetcode.com/problems/erect-the-fence "安装栅栏") | [Go](../problems/erect-the-fence) | Hard | | 588 | [Design In-Memory File System](https://leetcode.com/problems/design-in-memory-file-system "设计内存文件系统") 🔒 | [Go](../problems/design-in-memory-file-system) | Hard | -| 589 | [N-ary Tree Preorder Traversal](https://leetcode.com/problems/n-ary-tree-preorder-traversal "N叉树的前序遍历") | [Go](../problems/n-ary-tree-preorder-traversal) | Easy | -| 590 | [N-ary Tree Postorder Traversal](https://leetcode.com/problems/n-ary-tree-postorder-traversal "N叉树的后序遍历") | [Go](../problems/n-ary-tree-postorder-traversal) | Easy | +| 589 | [N-ary Tree Preorder Traversal](https://leetcode.com/problems/n-ary-tree-preorder-traversal "N 叉树的前序遍历") | [Go](../problems/n-ary-tree-preorder-traversal) | Easy | +| 590 | [N-ary Tree Postorder Traversal](https://leetcode.com/problems/n-ary-tree-postorder-traversal "N 叉树的后序遍历") | [Go](../problems/n-ary-tree-postorder-traversal) | Easy | | 591 | [Tag Validator](https://leetcode.com/problems/tag-validator "标签验证器") | [Go](../problems/tag-validator) | Hard | | 592 | [Fraction Addition and Subtraction](https://leetcode.com/problems/fraction-addition-and-subtraction "分数加减运算") | [Go](../problems/fraction-addition-and-subtraction) | Medium | | 593 | [Valid Square](https://leetcode.com/problems/valid-square "有效的正方形") | [Go](../problems/valid-square) | Medium | diff --git a/readme/601-900.md b/readme/601-900.md index 27be07057..a893646e9 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -193,7 +193,7 @@ LeetCode Problems' Solutions | 721 | [Accounts Merge](https://leetcode.com/problems/accounts-merge "账户合并") | [Go](../problems/accounts-merge) | Medium | | 722 | [Remove Comments](https://leetcode.com/problems/remove-comments "删除注释") | [Go](../problems/remove-comments) | Medium | | 723 | [Candy Crush](https://leetcode.com/problems/candy-crush "粉碎糖果") 🔒 | [Go](../problems/candy-crush) | Medium | -| 724 | [Find Pivot Index](https://leetcode.com/problems/find-pivot-index "寻找数组的中心索引") | [Go](../problems/find-pivot-index) | Easy | +| 724 | [Find Pivot Index](https://leetcode.com/problems/find-pivot-index "寻找数组的中心下标") | [Go](../problems/find-pivot-index) | Easy | | 725 | [Split Linked List in Parts](https://leetcode.com/problems/split-linked-list-in-parts "分隔链表") | [Go](../problems/split-linked-list-in-parts) | Medium | | 726 | [Number of Atoms](https://leetcode.com/problems/number-of-atoms "原子的数量") | [Go](../problems/number-of-atoms) | Hard | | 727 | [Minimum Window Subsequence](https://leetcode.com/problems/minimum-window-subsequence "最小窗口子序列") 🔒 | [Go](../problems/minimum-window-subsequence) | Hard | diff --git a/readme/901-1200.md b/readme/901-1200.md index c04d88e5d..cdd0dd513 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -305,7 +305,7 @@ LeetCode Problems' Solutions | 1133 | [Largest Unique Number](https://leetcode.com/problems/largest-unique-number "最大唯一数") 🔒 | [Go](../problems/largest-unique-number) | Easy | | 1134 | [Armstrong Number](https://leetcode.com/problems/armstrong-number "阿姆斯特朗数") 🔒 | [Go](../problems/armstrong-number) | Easy | | 1135 | [Connecting Cities With Minimum Cost](https://leetcode.com/problems/connecting-cities-with-minimum-cost "最低成本联通所有城市") 🔒 | [Go](../problems/connecting-cities-with-minimum-cost) | Medium | -| 1136 | [Parallel Courses](https://leetcode.com/problems/parallel-courses "平行课程") 🔒 | [Go](../problems/parallel-courses) | Hard | +| 1136 | [Parallel Courses](https://leetcode.com/problems/parallel-courses "平行课程") 🔒 | [Go](../problems/parallel-courses) | Medium | | 1137 | [N-th Tribonacci Number](https://leetcode.com/problems/n-th-tribonacci-number "第 N 个泰波那契数") | [Go](../problems/n-th-tribonacci-number) | Easy | | 1138 | [Alphabet Board Path](https://leetcode.com/problems/alphabet-board-path "字母板上的路径") | [Go](../problems/alphabet-board-path) | Medium | | 1139 | [Largest 1-Bordered Square](https://leetcode.com/problems/largest-1-bordered-square "最大的以 1 为边界的正方形") | [Go](../problems/largest-1-bordered-square) | Medium | diff --git a/tag/README.md b/tag/README.md index a81c4006c..d54aea1ae 100644 --- a/tag/README.md +++ b/tag/README.md @@ -12,14 +12,14 @@ | 1 | [Array](array/README.md) | [数组](https://openset.github.io/tags/array/) | | 2 | [Dynamic Programming](dynamic-programming/README.md) | [动态规划](https://openset.github.io/tags/dynamic-programming/) | | 3 | [String](string/README.md) | [字符串](https://openset.github.io/tags/string/) | | 4 | [Math](math/README.md) | [数学](https://openset.github.io/tags/math/) | | 5 | [Tree](tree/README.md) | [树](https://openset.github.io/tags/tree/) | | 6 | [Depth-first Search](depth-first-search/README.md) | [深度优先搜索](https://openset.github.io/tags/depth-first-search/) | -| 7 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | | 8 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | +| 7 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 8 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | | 9 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | | 11 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | | 15 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | -| 19 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 20 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | -| 21 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | | 22 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | +| 19 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 20 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | +| 21 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | | 22 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | | 23 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | | 24 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 25 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | | 27 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | diff --git a/tag/array/README.md b/tag/array/README.md index f39e14f91..8dd280a2a 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,10 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1779 | [找到最近的有相同 X 或 Y 坐标的点](../../problems/find-nearest-point-that-has-the-same-x-or-y-coordinate) | [[数组](../array/README.md)] | Easy | +| 1773 | [统计匹配检索规则的物品数量](../../problems/count-items-matching-a-rule) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 1769 | [移动所有球到每个盒子所需的最小操作数](../../problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1764 | [通过连接另一个数组的子数组得到一个数组](../../problems/form-array-by-concatenating-subarrays-of-another-array) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1758 | [生成交替二进制字符串的最少操作数](../../problems/minimum-changes-to-make-alternating-binary-string) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 1756 | [Design Most Recently Used Queue](../../problems/design-most-recently-used-queue) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1752 | [检查数组是否经排序和轮转得到](../../problems/check-if-array-is-sorted-and-rotated) | [[数组](../array/README.md)] | Easy | | 1748 | [唯一元素的和](../../problems/sum-of-unique-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 1742 | [盒子中小球的最大数量](../../problems/maximum-number-of-balls-in-a-box) | [[数组](../array/README.md)] | Easy | @@ -204,7 +206,7 @@ | 747 | [至少是其他数字两倍的最大数](../../problems/largest-number-at-least-twice-of-others) | [[数组](../array/README.md)] | Easy | | 746 | [使用最小花费爬楼梯](../../problems/min-cost-climbing-stairs) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 729 | [我的日程安排表 I](../../problems/my-calendar-i) | [[数组](../array/README.md)] | Medium | -| 724 | [寻找数组的中心索引](../../problems/find-pivot-index) | [[数组](../array/README.md)] | Easy | +| 724 | [寻找数组的中心下标](../../problems/find-pivot-index) | [[数组](../array/README.md)] | Easy | | 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -239,7 +241,7 @@ | 509 | [斐波那契数](../../problems/fibonacci-number) | [[数组](../array/README.md)] | Easy | | 495 | [提莫攻击](../../problems/teemo-attacking) | [[数组](../array/README.md)] | Medium | | 485 | [最大连续 1 的个数](../../problems/max-consecutive-ones) | [[数组](../array/README.md)] | Easy | -| 457 | [环形数组循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 457 | [环形数组是否存在循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 448 | [找到所有数组中消失的数字](../../problems/find-all-numbers-disappeared-in-an-array) | [[数组](../array/README.md)] | Easy | | 442 | [数组中重复的数据](../../problems/find-all-duplicates-in-an-array) | [[数组](../array/README.md)] | Medium | | 414 | [第三大的数](../../problems/third-maximum-number) | [[数组](../array/README.md)] | Easy | @@ -302,7 +304,7 @@ | 54 | [螺旋矩阵](../../problems/spiral-matrix) | [[数组](../array/README.md)] | Medium | | 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 48 | [旋转图像](../../problems/rotate-image) | [[数组](../array/README.md)] | Medium | -| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Hard | +| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 41 | [缺失的第一个正数](../../problems/first-missing-positive) | [[数组](../array/README.md)] | Hard | | 40 | [组合总和 II](../../problems/combination-sum-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 124b4c278..94b8cca71 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,69 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1688 | [比赛中的配对次数](../../problems/count-of-matches-in-tournament) | [[回溯算法](../backtracking/README.md)] | Easy | -| 1681 | [最小不兼容性](../../problems/minimum-incompatibility) | [[贪心算法](../greedy/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[回溯算法](../backtracking/README.md)] | Hard | -| 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[回溯算法](../backtracking/README.md)] | Medium | -| 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1415 | [长度为 n 的开心字符串中字典序第 k 小的字符串](../../problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | [[回溯算法](../backtracking/README.md)] | Medium | -| 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1291 | [顺次数](../../problems/sequential-digits) | [[回溯算法](../backtracking/README.md)] | Medium | -| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1258 | [近义词句子](../../problems/synonymous-sentences) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | -| 1240 | [铺瓷砖](../../problems/tiling-a-rectangle-with-the-fewest-squares) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1239 | [串联字符串的最大长度](../../problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1219 | [黄金矿工](../../problems/path-with-maximum-gold) | [[回溯算法](../backtracking/README.md)] | Medium | -| 1215 | [步进数](../../problems/stepping-numbers) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | -| 1088 | [易混淆数 II](../../problems/confusing-number-ii) 🔒 | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1087 | [花括号展开](../../problems/brace-expansion) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | -| 1079 | [活字印刷](../../problems/letter-tile-possibilities) | [[回溯算法](../backtracking/README.md)] | Medium | -| 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 980 | [不同路径 III](../../problems/unique-paths-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 526 | [优美的排列](../../problems/beautiful-arrangement) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 425 | [单词方块](../../problems/word-squares) 🔒 | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 411 | [最短独占单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 401 | [二进制手表](../../problems/binary-watch) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | -| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 351 | [安卓系统手势解锁](../../problems/android-unlock-patterns) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 306 | [累加数](../../problems/additive-number) | [[回溯算法](../backtracking/README.md)] | Medium | -| 294 | [翻转游戏 II](../../problems/flip-game-ii) 🔒 | [[极小化极大](../minimax/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 291 | [单词规律 II](../../problems/word-pattern-ii) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | -| 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | -| 254 | [因子的组合](../../problems/factor-combinations) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | -| 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 140 | [单词拆分 II](../../problems/word-break-ii) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 93 | [复原 IP 地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 90 | [子集 II](../../problems/subsets-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 89 | [格雷编码](../../problems/gray-code) | [[回溯算法](../backtracking/README.md)] | Medium | -| 79 | [单词搜索](../../problems/word-search) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 77 | [组合](../../problems/combinations) | [[回溯算法](../backtracking/README.md)] | Medium | -| 60 | [排列序列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 52 | [N皇后 II](../../problems/n-queens-ii) | [[回溯算法](../backtracking/README.md)] | Hard | -| 51 | [N 皇后](../../problems/n-queens) | [[回溯算法](../backtracking/README.md)] | Hard | -| 47 | [全排列 II](../../problems/permutations-ii) | [[回溯算法](../backtracking/README.md)] | Medium | -| 46 | [全排列](../../problems/permutations) | [[回溯算法](../backtracking/README.md)] | Medium | -| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 40 | [组合总和 II](../../problems/combination-sum-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 39 | [组合总和](../../problems/combination-sum) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 37 | [解数独](../../problems/sudoku-solver) | [[哈希表](../hash-table/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 5e37da64c..51e2e5675 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -50,7 +50,7 @@ | 397 | [整数替换](../../problems/integer-replacement) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | | 393 | [UTF-8 编码验证](../../problems/utf-8-validation) | [[位运算](../bit-manipulation/README.md)] | Medium | | 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 371 | [两整数之和](../../problems/sum-of-two-integers) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 371 | [两整数之和](../../problems/sum-of-two-integers) | [[位运算](../bit-manipulation/README.md)] | Medium | | 342 | [4的幂](../../problems/power-of-four) | [[位运算](../bit-manipulation/README.md)] | Easy | | 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/brainteaser/README.md b/tag/brainteaser/README.md index 5c1d0aff4..64fa3edd0 100644 --- a/tag/brainteaser/README.md +++ b/tag/brainteaser/README.md @@ -9,10 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1503 | [所有蚂蚁掉下来前的最后一刻](../../problems/last-moment-before-all-ants-fall-out-of-a-plank) | [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] | Medium | -| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1033 | [移动石子直到连续](../../problems/moving-stones-until-consecutive) | [[脑筋急转弯](../brainteaser/README.md)] | Easy | -| 777 | [在LR字符串中交换相邻字符](../../problems/swap-adjacent-in-lr-string) | [[脑筋急转弯](../brainteaser/README.md)] | Medium | -| 521 | [最长特殊序列 Ⅰ](../../problems/longest-uncommon-subsequence-i) | [[脑筋急转弯](../brainteaser/README.md)] [[字符串](../string/README.md)] | Easy | -| 319 | [灯泡开关](../../problems/bulb-switcher) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Medium | -| 292 | [Nim 游戏](../../problems/nim-game) | [[脑筋急转弯](../brainteaser/README.md)] [[极小化极大](../minimax/README.md)] | Easy | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index f68972b31..e1ebf1d82 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | | 1765 | [地图中的最高点](../../problems/map-of-highest-peak) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 92f2a97c3..3f0ef6a26 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | | 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1730 | [获取食物的最短路径](../../problems/shortest-path-to-get-food) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | @@ -44,7 +45,7 @@ | 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | | 1192 | [查找集群内的「关键连接」](../../problems/critical-connections-in-a-network) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | | 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1110 | [删点成林](../../problems/delete-nodes-and-return-forest) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | @@ -129,7 +130,7 @@ | 366 | [寻找二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 364 | [加权嵌套序列和 II](../../problems/nested-list-weight-sum-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 339 | [嵌套列表权重和](../../problems/nested-list-weight-sum) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | | 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | @@ -145,7 +146,7 @@ | 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 129 | [求根到叶子节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | | 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index f50d33a44..14091cf0c 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,63 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1756 | [Design Most Recently Used Queue](../../problems/design-most-recently-used-queue) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | -| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Easy | -| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard | -| 1603 | [设计停车系统](../../problems/design-parking-system) | [[设计](../design/README.md)] | Easy | -| 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | -| 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[设计](../design/README.md)] | Medium | -| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] | Medium | -| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | -| 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] | Medium | -| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | -| 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] | Medium | -| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1206 | [设计跳表](../../problems/design-skiplist) | [[设计](../design/README.md)] | Hard | -| 1172 | [餐盘栈](../../problems/dinner-plate-stacks) | [[设计](../design/README.md)] | Hard | -| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 716 | [最大栈](../../problems/max-stack) 🔒 | [[设计](../design/README.md)] | Easy | -| 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy | -| 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Hard | -| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | -| 631 | [设计 Excel 求和公式](../../problems/design-excel-sum-formula) 🔒 | [[设计](../design/README.md)] | Hard | -| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] | Easy | -| 588 | [设计内存文件系统](../../problems/design-in-memory-file-system) 🔒 | [[设计](../design/README.md)] | Hard | -| 460 | [LFU 缓存](../../problems/lfu-cache) | [[设计](../design/README.md)] | Hard | -| 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] | Hard | -| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 362 | [敲击计数器](../../problems/design-hit-counter) 🔒 | [[设计](../design/README.md)] | Medium | -| 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 348 | [设计井字棋](../../problems/design-tic-tac-toe) 🔒 | [[设计](../design/README.md)] | Medium | -| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | -| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | -| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard | -| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard | -| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] | Medium | -| 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] | Medium | -| 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] | Medium | -| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium | -| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] | Medium | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index 22827330d..279bfab7a 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -17,7 +17,7 @@ | 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 395 | [至少有K个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 312 | [戳气球](../../problems/burst-balloons) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 012e08c38..d831e0c26 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1787 | [使所有区间的异或结果为零](../../problems/make-the-xor-of-all-segments-equal-to-zero) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1771 | [由子序列构造的最长回文串的长度](../../problems/maximize-palindrome-length-from-subsequences) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1770 | [执行乘法运算的最大分数](../../problems/maximum-score-from-performing-multiplication-operations) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1751 | [最多可以参加的会议数目 II](../../problems/maximum-number-of-events-that-can-be-attended-ii) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -60,7 +62,7 @@ | 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 1420 | [生成数组](../../problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1416 | [恢复数组](../../problems/restore-the-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1411 | [给 N x 3 网格图涂色的方案数](../../problems/number-of-ways-to-paint-n-x-3-grid) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1411 | [给 N x 3 网格图涂色的方案数](../../problems/number-of-ways-to-paint-n-3-grid) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1406 | [石子游戏 III](../../problems/stone-game-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1402 | [做菜顺序](../../problems/reducing-dishes) | [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -105,7 +107,7 @@ | 1143 | [最长公共子序列](../../problems/longest-common-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1140 | [石子游戏 II](../../problems/stone-game-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1139 | [最大的以 1 为边界的正方形](../../problems/largest-1-bordered-square) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1125 | [最小的必要团队](../../problems/smallest-sufficient-team) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1105 | [填充书架](../../problems/filling-bookcase-shelves) | [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -214,6 +216,7 @@ | 351 | [安卓系统手势解锁](../../problems/android-unlock-patterns) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 343 | [整数拆分](../../problems/integer-break) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 322 | [零钱兑换](../../problems/coin-change) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 321 | [拼接最大数](../../problems/create-maximum-number) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 312 | [戳气球](../../problems/burst-balloons) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -222,7 +225,7 @@ | 303 | [区域和检索 - 数组不可变](../../problems/range-sum-query-immutable) | [[动态规划](../dynamic-programming/README.md)] | Easy | | 300 | [最长递增子序列](../../problems/longest-increasing-subsequence) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 276 | [栅栏涂色](../../problems/paint-fence) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Easy | +| 276 | [栅栏涂色](../../problems/paint-fence) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | | 265 | [粉刷房子 II](../../problems/paint-house-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | | 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 256 | [粉刷房子](../../problems/paint-house) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index 085448301..5a8521ed2 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -9,12 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard | -| 1515 | [服务中心的最佳位置](../../problems/best-position-for-a-service-centre) | [[几何](../geometry/README.md)] | Hard | -| 1453 | [圆形靶内的最大飞镖数量](../../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | [[几何](../geometry/README.md)] | Hard | -| 1401 | [圆和矩形是否有重叠](../../problems/circle-and-rectangle-overlapping) | [[几何](../geometry/README.md)] | Medium | -| 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] | Easy | -| 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | -| 892 | [三维形体的表面积](../../problems/surface-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | -| 587 | [安装栅栏](../../problems/erect-the-fence) | [[几何](../geometry/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index 3abb38b20..b0dee529a 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1782 | [统计点对的数目](../../problems/count-pairs-of-nodes) | [[图](../graph/README.md)] | Hard | +| 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1765 | [地图中的最高点](../../problems/map-of-highest-peak) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1761 | [一个图中连通三元组的最小度数](../../problems/minimum-degree-of-a-connected-trio-in-a-graph) | [[图](../graph/README.md)] | Hard | | 1730 | [获取食物的最短路径](../../problems/shortest-path-to-get-food) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | @@ -30,7 +33,7 @@ | 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1153 | [字符串转化](../../problems/string-transforms-into-another-string) 🔒 | [[图](../graph/README.md)] | Hard | -| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1135 | [最低成本联通所有城市](../../problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 529ffe482..81f982b38 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,9 +9,14 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1788 | [Maximize the Beauty of the Garden](../../problems/maximize-the-beauty-of-the-garden) 🔒 | [[贪心算法](../greedy/README.md)] | Hard | +| 1785 | [构成特定和需要添加的最少元素](../../problems/minimum-elements-to-add-to-form-a-given-sum) | [[贪心算法](../greedy/README.md)] | Medium | +| 1784 | [检查二进制字符串字段](../../problems/check-if-binary-string-has-at-most-one-segment-of-ones) | [[贪心算法](../greedy/README.md)] | Easy | +| 1775 | [通过最少操作次数使数组的和相等](../../problems/equal-sum-arrays-with-minimum-number-of-operations) | [[贪心算法](../greedy/README.md)] | Medium | +| 1774 | [最接近目标价格的甜点成本](../../problems/closest-dessert-cost) | [[贪心算法](../greedy/README.md)] | Medium | | 1769 | [移动所有球到每个盒子所需的最小操作数](../../problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1764 | [通过连接另一个数组的子数组得到一个数组](../../problems/form-array-by-concatenating-subarrays-of-another-array) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1762 | [Buildings With an Ocean View](../../problems/buildings-with-an-ocean-view) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | +| 1762 | [能看到海景的建筑物](../../problems/buildings-with-an-ocean-view) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | | 1759 | [统计同构子字符串的数目](../../problems/count-number-of-homogenous-substrings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1758 | [生成交替二进制字符串的最少操作数](../../problems/minimum-changes-to-make-alternating-binary-string) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 1754 | [构造字典序最大的合并字符串](../../problems/largest-merge-of-two-strings) | [[贪心算法](../greedy/README.md)] | Medium | @@ -146,5 +151,5 @@ | 134 | [加油站](../../problems/gas-station) | [[贪心算法](../greedy/README.md)] | Medium | | 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 55 | [跳跃游戏](../../problems/jump-game) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Hard | +| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index f78d7bc25..1adf15714 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,143 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1748 | [唯一元素的和](../../problems/sum-of-unique-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1726 | [同积元组](../../problems/tuple-with-same-product) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1679 | [K 和数对的最大数目](../../problems/max-number-of-k-sum-pairs) | [[哈希表](../hash-table/README.md)] | Medium | -| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1418 | [点菜展示表](../../problems/display-table-of-food-orders-in-a-restaurant) | [[哈希表](../hash-table/README.md)] | Medium | -| 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1224 | [最大相等频率](../../problems/maximum-equal-frequency) | [[哈希表](../hash-table/README.md)] | Hard | -| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 1207 | [独一无二的出现次数](../../problems/unique-number-of-occurrences) | [[哈希表](../hash-table/README.md)] | Easy | -| 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1189 | [“气球” 的最大数量](../../problems/maximum-number-of-balloons) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 1178 | [猜字谜](../../problems/number-of-valid-words-for-each-puzzle) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1160 | [拼写单词](../../problems/find-words-that-can-be-formed-by-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1138 | [字母板上的路径](../../problems/alphabet-board-path) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1133 | [最大唯一数](../../problems/largest-unique-number) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1078 | [Bigram 分词](../../problems/occurrences-after-bigram) | [[哈希表](../hash-table/README.md)] | Easy | -| 1072 | [按列翻转得到最大值等行数](../../problems/flip-columns-for-maximum-number-of-equal-rows) | [[哈希表](../hash-table/README.md)] | Medium | -| 1048 | [最长字符串链](../../problems/longest-string-chain) | [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1001 | [网格照明](../../problems/grid-illumination) | [[哈希表](../hash-table/README.md)] | Hard | -| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 974 | [和可被 K 整除的子数组](../../problems/subarray-sums-divisible-by-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 970 | [强整数](../../problems/powerful-integers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 961 | [重复 N 次的元素](../../problems/n-repeated-element-in-size-2n-array) | [[哈希表](../hash-table/README.md)] | Easy | -| 957 | [N 天后的牢房](../../problems/prison-cells-after-n-days) | [[哈希表](../hash-table/README.md)] | Medium | -| 954 | [二倍数对数组](../../problems/array-of-doubled-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 953 | [验证外星语词典](../../problems/verifying-an-alien-dictionary) | [[哈希表](../hash-table/README.md)] | Easy | -| 939 | [最小面积矩形](../../problems/minimum-area-rectangle) | [[哈希表](../hash-table/README.md)] | Medium | -| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 884 | [两句话中的不常见单词](../../problems/uncommon-words-from-two-sentences) | [[哈希表](../hash-table/README.md)] | Easy | -| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[哈希表](../hash-table/README.md)] | Easy | -| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 771 | [宝石与石头](../../problems/jewels-and-stones) | [[哈希表](../hash-table/README.md)] | Easy | -| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | -| 760 | [找出变位映射](../../problems/find-anagram-mappings) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | -| 748 | [最短补全词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] | Easy | -| 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | -| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[堆](../heap/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 676 | [实现一个魔法字典](../../problems/implement-magic-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 648 | [单词替换](../../problems/replace-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 645 | [错误的集合](../../problems/set-mismatch) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 599 | [两个列表的最小索引总和](../../problems/minimum-index-sum-of-two-lists) | [[哈希表](../hash-table/README.md)] | Easy | -| 594 | [最长和谐子序列](../../problems/longest-harmonious-subsequence) | [[哈希表](../hash-table/README.md)] | Easy | -| 575 | [分糖果](../../problems/distribute-candies) | [[哈希表](../hash-table/README.md)] | Easy | -| 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 554 | [砖墙](../../problems/brick-wall) | [[哈希表](../hash-table/README.md)] | Medium | -| 535 | [TinyURL 的加密与解密](../../problems/encode-and-decode-tinyurl) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 525 | [连续数组](../../problems/contiguous-array) | [[哈希表](../hash-table/README.md)] | Medium | -| 508 | [出现次数最多的子树元素和](../../problems/most-frequent-subtree-sum) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 500 | [键盘行](../../problems/keyboard-row) | [[哈希表](../hash-table/README.md)] | Easy | -| 463 | [岛屿的周长](../../problems/island-perimeter) | [[哈希表](../hash-table/README.md)] | Easy | -| 454 | [四数相加 II](../../problems/4sum-ii) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 447 | [回旋镖的数量](../../problems/number-of-boomerangs) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 438 | [找到字符串中所有字母异位词](../../problems/find-all-anagrams-in-a-string) | [[哈希表](../hash-table/README.md)] | Medium | -| 409 | [最长回文串](../../problems/longest-palindrome) | [[哈希表](../hash-table/README.md)] | Easy | -| 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 356 | [直线镜像](../../problems/line-reflection) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | -| 325 | [和等于 k 的最长子数组长度](../../problems/maximum-size-subarray-sum-equals-k) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | -| 311 | [稀疏矩阵的乘法](../../problems/sparse-matrix-multiplication) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | -| 299 | [猜数字游戏](../../problems/bulls-and-cows) | [[哈希表](../hash-table/README.md)] | Medium | -| 290 | [单词规律](../../problems/word-pattern) | [[哈希表](../hash-table/README.md)] | Easy | -| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 274 | [H 指数](../../problems/h-index) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 266 | [回文排列](../../problems/palindrome-permutation) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | -| 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 246 | [中心对称数](../../problems/strobogrammatic-number) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 242 | [有效的字母异位词](../../problems/valid-anagram) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 219 | [存在重复元素 II](../../problems/contains-duplicate-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 217 | [存在重复元素](../../problems/contains-duplicate) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 205 | [同构字符串](../../problems/isomorphic-strings) | [[哈希表](../hash-table/README.md)] | Easy | -| 204 | [计数质数](../../problems/count-primes) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 202 | [快乐数](../../problems/happy-number) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 187 | [重复的DNA序列](../../problems/repeated-dna-sequences) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | -| 138 | [复制带随机指针的链表](../../problems/copy-list-with-random-pointer) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 136 | [只出现一次的数字](../../problems/single-number) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 37 | [解数独](../../problems/sudoku-solver) | [[哈希表](../hash-table/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 36 | [有效的数独](../../problems/valid-sudoku) | [[哈希表](../hash-table/README.md)] | Medium | -| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1 | [两数之和](../../problems/two-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md index 932db1472..592ea3e0f 100644 --- a/tag/line-sweep/README.md +++ b/tag/line-sweep/README.md @@ -9,9 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | -| 391 | [完美矩形](../../problems/perfect-rectangle) | [[Line Sweep](../line-sweep/README.md)] | Hard | -| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/math/README.md b/tag/math/README.md index 556dd37eb..7b2bfa353 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1776 | [车队 II](../../problems/car-fleet-ii) | [[数学](../math/README.md)] | Hard | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | | 1753 | [移除石子的最大得分](../../problems/maximum-score-from-removing-stones) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | | 1744 | [你能在你最喜欢的那天吃到你最喜欢的糖果吗?](../../problems/can-you-eat-your-favorite-candy-on-your-favorite-day) | [[数学](../math/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index 88fe0bfa0..0c9155aea 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -15,7 +15,7 @@ | 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | | 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | | 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | -| 582 | [杀死进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | +| 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | | 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | | 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index ad51289a2..42f90d3a9 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -9,40 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[递归](../recursion/README.md)] | Easy | -| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[递归](../recursion/README.md)] | Medium | -| 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | -| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 395 | [至少有K个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | -| 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | -| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | -| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Easy | -| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/rejection-sampling/README.md b/tag/rejection-sampling/README.md index fc2d396f2..8622c93e1 100644 --- a/tag/rejection-sampling/README.md +++ b/tag/rejection-sampling/README.md @@ -9,5 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | -| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index 56d607bc2..ee49220e1 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -30,7 +30,7 @@ | 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 480 | [滑动窗口中位数](../../problems/sliding-window-median) | [[Sliding Window](../sliding-window/README.md)] | Hard | | 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 395 | [至少有K个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index 3ae174849..469d3f3fb 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1772 | [按受欢迎程度排列功能](../../problems/sort-features-by-popularity) 🔒 | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1727 | [重新排列后的最大子矩阵](../../problems/largest-submatrix-with-rearrangements) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | | 1710 | [卡车上的最大单元数](../../problems/maximum-units-on-a-truck) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | | 1697 | [检查边长度限制的路径是否存在](../../problems/checking-existence-of-edge-length-limited-paths) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] | Hard | diff --git a/tag/stack/README.md b/tag/stack/README.md index 238b0b4da..23154cbab 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -9,67 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1703 | [得到连续 K 个 1 的最少相邻交换次数](../../problems/minimum-adjacent-swaps-for-k-consecutive-ones) | [[栈](../stack/README.md)] | Hard | -| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | -| 1598 | [文件夹操作日志搜集器](../../problems/crawler-log-folder) | [[栈](../stack/README.md)] | Easy | -| 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | -| 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1441 | [用栈操作构建数组](../../problems/build-an-array-with-stack-operations) | [[栈](../stack/README.md)] | Easy | -| 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | -| 1249 | [移除无效的括号](../../problems/minimum-remove-to-make-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1209 | [删除字符串中的所有相邻重复项 II](../../problems/remove-all-adjacent-duplicates-in-string-ii) | [[栈](../stack/README.md)] | Medium | -| 1190 | [反转每对括号间的子串](../../problems/reverse-substrings-between-each-pair-of-parentheses) | [[栈](../stack/README.md)] | Medium | -| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1124 | [表现良好的最长时间段](../../problems/longest-well-performing-interval) | [[栈](../stack/README.md)] | Medium | -| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1063 | [有效子数组的数目](../../problems/number-of-valid-subarrays) 🔒 | [[栈](../stack/README.md)] | Hard | -| 1047 | [删除字符串中的所有相邻重复项](../../problems/remove-all-adjacent-duplicates-in-string) | [[栈](../stack/README.md)] | Easy | -| 1021 | [删除最外层的括号](../../problems/remove-outermost-parentheses) | [[栈](../stack/README.md)] | Easy | -| 1019 | [链表中的下一个更大节点](../../problems/next-greater-node-in-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 1003 | [检查替换后的词是否有效](../../problems/check-if-word-is-valid-after-substitutions) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 946 | [验证栈序列](../../problems/validate-stack-sequences) | [[栈](../stack/README.md)] | Medium | -| 921 | [使括号有效的最少添加](../../problems/minimum-add-to-make-parentheses-valid) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 907 | [子数组的最小值之和](../../problems/sum-of-subarray-minimums) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Medium | -| 901 | [股票价格跨度](../../problems/online-stock-span) | [[栈](../stack/README.md)] | Medium | -| 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 880 | [索引处的解码字符串](../../problems/decoded-string-at-index) | [[栈](../stack/README.md)] | Medium | -| 856 | [括号的分数](../../problems/score-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | -| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | -| 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 735 | [行星碰撞](../../problems/asteroid-collision) | [[栈](../stack/README.md)] | Medium | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 682 | [棒球比赛](../../problems/baseball-game) | [[栈](../stack/README.md)] | Easy | -| 636 | [函数的独占时间](../../problems/exclusive-time-of-functions) | [[栈](../stack/README.md)] | Medium | -| 591 | [标签验证器](../../problems/tag-validator) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | -| 503 | [下一个更大元素 II](../../problems/next-greater-element-ii) | [[栈](../stack/README.md)] | Medium | -| 496 | [下一个更大元素 I](../../problems/next-greater-element-i) | [[栈](../stack/README.md)] | Easy | -| 456 | [132模式](../../problems/132-pattern) | [[栈](../stack/README.md)] | Medium | -| 439 | [三元表达式解析器](../../problems/ternary-expression-parser) 🔒 | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 402 | [移掉K位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 385 | [迷你语法分析器](../../problems/mini-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | -| 331 | [验证二叉树的前序序列化](../../problems/verify-preorder-serialization-of-a-binary-tree) | [[栈](../stack/README.md)] | Medium | -| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Hard | -| 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | -| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 224 | [基本计算器](../../problems/basic-calculator) | [[栈](../stack/README.md)] [[数学](../math/README.md)] | Hard | -| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] | Medium | -| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | -| 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | -| 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 84 | [柱状图中最大的矩形](../../problems/largest-rectangle-in-histogram) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Hard | -| 71 | [简化路径](../../problems/simplify-path) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 20 | [有效的括号](../../problems/valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | diff --git a/tag/string/README.md b/tag/string/README.md index 9549c364f..d7176ade4 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1781 | [所有子字符串美丽值之和](../../problems/sum-of-beauty-of-all-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1773 | [统计匹配检索规则的物品数量](../../problems/count-items-matching-a-rule) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 1768 | [交替合并字符串](../../problems/merge-strings-alternately) | [[字符串](../string/README.md)] | Easy | | 1763 | [最长的美好子字符串](../../problems/longest-nice-substring) | [[字符串](../string/README.md)] | Easy | | 1759 | [统计同构子字符串的数目](../../problems/count-number-of-homogenous-substrings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/tags.json b/tag/tags.json index a01a1babe..a013ad07a 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -29,16 +29,16 @@ "Slug": "depth-first-search", "TranslatedName": "深度优先搜索" }, - { - "Name": "Hash Table", - "Slug": "hash-table", - "TranslatedName": "哈希表" - }, { "Name": "Greedy", "Slug": "greedy", "TranslatedName": "贪心算法" }, + { + "Name": "Hash Table", + "Slug": "hash-table", + "TranslatedName": "哈希表" + }, { "Name": "Binary Search", "Slug": "binary-search", @@ -94,16 +94,16 @@ "Slug": "heap", "TranslatedName": "堆" }, - { - "Name": "Union Find", - "Slug": "union-find", - "TranslatedName": "并查集" - }, { "Name": "Recursion", "Slug": "recursion", "TranslatedName": "递归" }, + { + "Name": "Union Find", + "Slug": "union-find", + "TranslatedName": "并查集" + }, { "Name": "Sliding Window", "Slug": "sliding-window", diff --git a/tag/tree/README.md b/tag/tree/README.md index b7e90ec33..838c82596 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,161 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | -| 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] | Hard | -| 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1660 | [纠正二叉树](../../problems/correct-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | -| 1650 | [二叉树的最近公共祖先 III](../../problems/lowest-common-ancestor-of-a-binary-tree-iii) 🔒 | [[树](../tree/README.md)] | Medium | -| 1644 | [二叉树的最近公共祖先 II](../../problems/lowest-common-ancestor-of-a-binary-tree-ii) 🔒 | [[树](../tree/README.md)] | Medium | -| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1609 | [奇偶树](../../problems/even-odd-tree) | [[树](../tree/README.md)] | Medium | -| 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Hard | -| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1516 | [移动 N 叉树的子树](../../problems/move-sub-tree-of-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard | -| 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1469 | [寻找所有的独生节点](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 1466 | [重新规划路线](../../problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1430 | [判断给定的序列是否是二叉树从根到叶的路径](../../problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | -| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1325 | [删除给定值的叶子节点](../../problems/delete-leaves-with-a-given-value) | [[树](../tree/README.md)] | Medium | -| 1315 | [祖父节点值为偶数的节点和](../../problems/sum-of-nodes-with-even-valued-grandparent) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[排序](../sort/README.md)] [[树](../tree/README.md)] | Medium | -| 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1257 | [最小公共区域](../../problems/smallest-common-region) 🔒 | [[树](../tree/README.md)] | Medium | -| 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] | Medium | -| 1110 | [删点成林](../../problems/delete-nodes-and-return-forest) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1104 | [二叉树寻路](../../problems/path-in-zigzag-labelled-binary-tree) | [[树](../tree/README.md)] [[数学](../math/README.md)] | Medium | -| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 1026 | [节点与其祖先之间的最大差值](../../problems/maximum-difference-between-node-and-ancestor) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1022 | [从根到叶的二进制数之和](../../problems/sum-of-root-to-leaf-binary-numbers) | [[树](../tree/README.md)] | Easy | -| 1008 | [前序遍历构造二叉搜索树](../../problems/construct-binary-search-tree-from-preorder-traversal) | [[树](../tree/README.md)] | Medium | -| 998 | [最大二叉树 II](../../problems/maximum-binary-tree-ii) | [[树](../tree/README.md)] | Medium | -| 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 988 | [从叶结点开始的最小字符串](../../problems/smallest-string-starting-from-leaf) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 979 | [在二叉树中分配硬币](../../problems/distribute-coins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 971 | [翻转二叉树以匹配先序遍历](../../problems/flip-binary-tree-to-match-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 965 | [单值二叉树](../../problems/univalued-binary-tree) | [[树](../tree/README.md)] | Easy | -| 958 | [二叉树的完全性检验](../../problems/check-completeness-of-a-binary-tree) | [[树](../tree/README.md)] | Medium | -| 951 | [翻转等价二叉树](../../problems/flip-equivalent-binary-trees) | [[树](../tree/README.md)] | Medium | -| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 919 | [完全二叉树插入器](../../problems/complete-binary-tree-inserter) | [[树](../tree/README.md)] | Medium | -| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] | Medium | -| 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 814 | [二叉树剪枝](../../problems/binary-tree-pruning) | [[树](../tree/README.md)] | Medium | -| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 742 | [二叉树最近的叶节点](../../problems/closest-leaf-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | -| 701 | [二叉搜索树中的插入操作](../../problems/insert-into-a-binary-search-tree) | [[树](../tree/README.md)] | Medium | -| 700 | [二叉搜索树中的搜索](../../problems/search-in-a-binary-search-tree) | [[树](../tree/README.md)] | Easy | -| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 684 | [冗余连接](../../problems/redundant-connection) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 671 | [二叉树中第二小的节点](../../problems/second-minimum-node-in-a-binary-tree) | [[树](../tree/README.md)] | Easy | -| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 666 | [路径总和 IV](../../problems/path-sum-iv) 🔒 | [[树](../tree/README.md)] | Medium | -| 663 | [均匀树划分](../../problems/equal-tree-partition) 🔒 | [[树](../tree/README.md)] | Medium | -| 662 | [二叉树最大宽度](../../problems/maximum-width-of-binary-tree) | [[树](../tree/README.md)] | Medium | -| 655 | [输出二叉树](../../problems/print-binary-tree) | [[树](../tree/README.md)] | Medium | -| 654 | [最大二叉树](../../problems/maximum-binary-tree) | [[树](../tree/README.md)] | Medium | -| 653 | [两数之和 IV - 输入 BST](../../problems/two-sum-iv-input-is-a-bst) | [[树](../tree/README.md)] | Easy | -| 652 | [寻找重复的子树](../../problems/find-duplicate-subtrees) | [[树](../tree/README.md)] | Medium | -| 637 | [二叉树的层平均值](../../problems/average-of-levels-in-binary-tree) | [[树](../tree/README.md)] | Easy | -| 623 | [在二叉树中增加一行](../../problems/add-one-row-to-tree) | [[树](../tree/README.md)] | Medium | -| 617 | [合并二叉树](../../problems/merge-two-binary-trees) | [[树](../tree/README.md)] | Easy | -| 606 | [根据二叉树创建字符串](../../problems/construct-string-from-binary-tree) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Easy | -| 590 | [N叉树的后序遍历](../../problems/n-ary-tree-postorder-traversal) | [[树](../tree/README.md)] | Easy | -| 589 | [N叉树的前序遍历](../../problems/n-ary-tree-preorder-traversal) | [[树](../tree/README.md)] | Easy | -| 582 | [杀死进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | -| 572 | [另一个树的子树](../../problems/subtree-of-another-tree) | [[树](../tree/README.md)] | Easy | -| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 559 | [N 叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 549 | [二叉树中最长的连续序列](../../problems/binary-tree-longest-consecutive-sequence-ii) 🔒 | [[树](../tree/README.md)] | Medium | -| 545 | [二叉树的边界](../../problems/boundary-of-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | -| 543 | [二叉树的直径](../../problems/diameter-of-binary-tree) | [[树](../tree/README.md)] | Easy | -| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | -| 530 | [二叉搜索树的最小绝对差](../../problems/minimum-absolute-difference-in-bst) | [[树](../tree/README.md)] | Easy | -| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 510 | [二叉搜索树中的中序后继 II](../../problems/inorder-successor-in-bst-ii) 🔒 | [[树](../tree/README.md)] | Medium | -| 508 | [出现次数最多的子树元素和](../../problems/most-frequent-subtree-sum) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 501 | [二叉搜索树中的众数](../../problems/find-mode-in-binary-search-tree) | [[树](../tree/README.md)] | Easy | -| 450 | [删除二叉搜索树中的节点](../../problems/delete-node-in-a-bst) | [[树](../tree/README.md)] | Medium | -| 449 | [序列化和反序列化二叉搜索树](../../problems/serialize-and-deserialize-bst) | [[树](../tree/README.md)] | Medium | -| 437 | [路径总和 III](../../problems/path-sum-iii) | [[树](../tree/README.md)] | Medium | -| 431 | [将 N 叉树编码为二叉树](../../problems/encode-n-ary-tree-to-binary-tree) 🔒 | [[树](../tree/README.md)] | Hard | -| 429 | [N 叉树的层序遍历](../../problems/n-ary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 428 | [序列化和反序列化 N 叉树](../../problems/serialize-and-deserialize-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard | -| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 404 | [左叶子之和](../../problems/sum-of-left-leaves) | [[树](../tree/README.md)] | Easy | -| 366 | [寻找二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 333 | [最大 BST 子树](../../problems/largest-bst-subtree) 🔒 | [[树](../tree/README.md)] | Medium | -| 298 | [二叉树最长连续序列](../../problems/binary-tree-longest-consecutive-sequence) 🔒 | [[树](../tree/README.md)] | Medium | -| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard | -| 285 | [二叉搜索树中的顺序后继](../../problems/inorder-successor-in-bst) 🔒 | [[树](../tree/README.md)] | Medium | -| 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Hard | -| 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | -| 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] | Medium | -| 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] | Medium | -| 235 | [二叉搜索树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-search-tree) | [[树](../tree/README.md)] | Easy | -| 230 | [二叉搜索树中第K小的元素](../../problems/kth-smallest-element-in-a-bst) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 226 | [翻转二叉树](../../problems/invert-binary-tree) | [[树](../tree/README.md)] | Easy | -| 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | -| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 156 | [上下翻转二叉树](../../problems/binary-tree-upside-down) 🔒 | [[树](../tree/README.md)] | Medium | -| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | -| 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | -| 129 | [求根到叶子节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 102 | [二叉树的层序遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 100 | [相同的树](../../problems/same-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 99 | [恢复二叉搜索树](../../problems/recover-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 461770ab9..869c5d53e 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -47,7 +47,7 @@ | 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 487 | [最大连续1的个数 II](../../problems/max-consecutive-ones-ii) 🔒 | [[双指针](../two-pointers/README.md)] | Medium | -| 457 | [环形数组循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 457 | [环形数组是否存在循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | | 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | From c2830869e7d60491997f3742d728057f2cb60a20 Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 23 Mar 2021 09:30:59 +0800 Subject: [PATCH 123/145] U: go1.15 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index d10dc824a..b4846db92 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/openset/leetcode -go 1.14 +go 1.15 From 6b7fcecff1395f417f4efc75e20a32e14e723fa9 Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 23 Mar 2021 09:31:21 +0800 Subject: [PATCH 124/145] A: new --- README.md | 335 ++------------- problems/accounts-merge/README.md | 48 ++- problems/add-digits/README.md | 33 +- problems/add-one-row-to-tree/README.md | 82 ++-- .../README.md | 5 +- problems/binary-tree-paths/README.md | 33 +- problems/binary-trees-with-factors/README.md | 1 + .../README.md | 29 +- .../README.md | 6 +- .../README.md | 71 ++++ problems/coin-change/README.md | 4 +- problems/combination-sum-iv/README.md | 36 +- .../README.md | 2 +- .../README.md | 29 ++ .../count-pairs-with-xor-in-a-range/README.md | 69 ++++ problems/create-maximum-number/README.md | 53 +-- .../design-authentication-manager/README.md | 84 ++++ .../README.md | 36 +- problems/dungeon-game/README.md | 55 ++- problems/expression-add-operators/README.md | 55 +-- problems/find-center-of-star-graph/README.md | 63 +++ .../find-median-from-data-stream/README.md | 54 ++- .../find-mode-in-binary-search-tree/README.md | 35 +- .../README.md | 51 ++- problems/h-index-ii/README.md | 2 +- problems/house-robber-ii/README.md | 2 +- .../implement-stack-using-queues/README.md | 4 +- .../README.md | 62 +-- problems/insert-delete-getrandom-o1/README.md | 10 +- problems/integer-break/README.md | 30 +- .../intersection-of-two-arrays-ii/README.md | 29 +- problems/intersection-of-two-arrays/README.md | 24 +- .../README.md | 6 +- problems/invert-binary-tree/README.md | 41 +- problems/k-similar-strings/README.md | 62 ++- problems/linked-list-random-node/README.md | 4 +- .../README.md | 8 +- .../README.md | 40 +- .../README.md | 79 ++++ .../README.md | 2 +- .../maximum-ascending-subarray-sum/README.md | 72 ++++ problems/maximum-average-pass-ratio/README.md | 70 ++++ .../README.md | 74 ++++ .../maximum-product-of-word-lengths/README.md | 33 +- .../README.md | 58 +++ .../README.md | 75 ++++ problems/min-stack/README.md | 13 +- .../n-ary-tree-postorder-traversal/README.md | 26 +- .../n-ary-tree-preorder-traversal/README.md | 18 +- problems/nth-digit/README.md | 36 +- .../number-of-orders-in-the-backlog/README.md | 82 ++++ problems/paint-house-iii/README.md | 20 +- problems/patching-array/README.md | 42 +- .../README.md | 14 + .../mysql_schemas.sql | 9 + .../product-of-array-except-self/README.md | 37 +- problems/pyramid-transition-matrix/README.md | 37 +- .../range-sum-query-2d-immutable/README.md | 60 +-- problems/range-sum-query-immutable/README.md | 14 +- problems/range-sum-query-mutable/README.md | 6 +- problems/rearrange-products-table/README.md | 14 + .../mysql_schemas.sql | 4 + problems/reconstruct-itinerary/README.md | 45 ++- problems/rectangle-area/README.md | 28 +- problems/rectangles-area/mysql_schemas.sql | 4 +- .../README.md | 2 +- problems/remove-invalid-parentheses/README.md | 32 +- .../remove-palindromic-subsequences/README.md | 14 +- problems/reverse-string/README.md | 33 +- .../README.md | 55 +++ problems/self-crossing/README.md | 55 ++- problems/shortest-palindrome/README.md | 4 +- problems/smallest-sufficient-team/README.md | 24 +- problems/sort-transformed-array/README.md | 1 + .../statistics-from-a-large-sample/README.md | 47 ++- .../student-attendance-record-i/README.md | 27 +- .../student-attendance-record-ii/README.md | 19 +- problems/super-egg-drop/README.md | 20 +- problems/swap-salary/README.md | 2 +- problems/top-k-frequent-elements/README.md | 34 +- problems/valid-anagram/README.md | 35 +- .../README.md | 67 ++- problems/wiggle-subsequence/README.md | 47 ++- problems/word-ladder-ii/README.md | 18 +- problems/word-ladder/README.md | 15 +- .../x-of-a-kind-in-a-deck-of-cards/README.md | 8 +- readme/1-300.md | 22 +- readme/1201-1500.md | 380 ++++++++++++++++++ readme/301-600.md | 20 +- readme/601-900.md | 20 +- readme/901-1200.md | 20 +- tag/README.md | 4 +- tag/array/README.md | 2 +- tag/backtracking/README.md | 68 ++++ tag/binary-search/README.md | 1 + tag/brainteaser/README.md | 7 + tag/design/README.md | 61 +++ tag/dynamic-programming/README.md | 1 + tag/geometry/README.md | 9 + tag/graph/README.md | 1 + tag/greedy/README.md | 144 ------- tag/hash-table/README.md | 143 +++++++ tag/heap/README.md | 2 + tag/line-sweep/README.md | 6 + tag/math/README.md | 2 +- tag/ordered-map/README.md | 14 - tag/queue/README.md | 11 - tag/recursion/README.md | 39 ++ tag/rejection-sampling/README.md | 2 + tag/sort/README.md | 1 + tag/stack/README.md | 64 +++ tag/string/README.md | 221 ---------- tag/tags.json | 10 +- tag/topological-sort/README.md | 6 - tag/trie/README.md | 1 + tag/two-pointers/README.md | 5 +- 116 files changed, 2837 insertions(+), 1574 deletions(-) create mode 100644 problems/check-if-one-string-swap-can-make-strings-equal/README.md create mode 100644 problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md create mode 100644 problems/count-pairs-with-xor-in-a-range/README.md create mode 100644 problems/design-authentication-manager/README.md create mode 100644 problems/find-center-of-star-graph/README.md create mode 100644 problems/maximize-score-after-n-operations/README.md create mode 100644 problems/maximum-ascending-subarray-sum/README.md create mode 100644 problems/maximum-average-pass-ratio/README.md create mode 100644 problems/maximum-number-of-consecutive-values-you-can-make/README.md create mode 100644 problems/maximum-score-of-a-good-subarray/README.md create mode 100644 problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md create mode 100644 problems/number-of-orders-in-the-backlog/README.md create mode 100644 problems/primary-department-for-each-employee/README.md create mode 100644 problems/primary-department-for-each-employee/mysql_schemas.sql create mode 100644 problems/rearrange-products-table/README.md create mode 100644 problems/rearrange-products-table/mysql_schemas.sql create mode 100644 problems/second-largest-digit-in-a-string/README.md create mode 100644 readme/1201-1500.md diff --git a/README.md b/README.md index 7abbfddb0..e8fc2478e 100644 --- a/README.md +++ b/README.md @@ -51,12 +51,12 @@ LeetCode Problems' Solutions [1151-1200] - [1201-1250] - [1251-1300] - [1301-1350] - [1351-1400] - [1401-1450] - [1451-1500] + [1201-1250] + [1251-1300] + [1301-1350] + [1351-1400] + [1401-1450] + [1451-1500] [1501-1550] @@ -66,10 +66,33 @@ LeetCode Problems' Solutions [1701-1750] [1751-1800] + + [1801-1850] + [1851-1900] + [1901-1950] + [1951-2000] + [2001-2050] + [2051-2100] + | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1803 | [Count Pairs With XOR in a Range](https://leetcode.com/problems/count-pairs-with-xor-in-a-range "统计异或值在范围内的数对有多少") | [Go](problems/count-pairs-with-xor-in-a-range) | Hard | +| 1802 | [Maximum Value at a Given Index in a Bounded Array](https://leetcode.com/problems/maximum-value-at-a-given-index-in-a-bounded-array "有界数组中指定下标处的最大值") | [Go](problems/maximum-value-at-a-given-index-in-a-bounded-array) | Medium | +| 1801 | [Number of Orders in the Backlog](https://leetcode.com/problems/number-of-orders-in-the-backlog "积压订单中的订单总数") | [Go](problems/number-of-orders-in-the-backlog) | Medium | +| 1800 | [Maximum Ascending Subarray Sum](https://leetcode.com/problems/maximum-ascending-subarray-sum "最大升序子数组和") | [Go](problems/maximum-ascending-subarray-sum) | Easy | +| 1799 | [Maximize Score After N Operations](https://leetcode.com/problems/maximize-score-after-n-operations "N 次操作后的最大分数和") | [Go](problems/maximize-score-after-n-operations) | Hard | +| 1798 | [Maximum Number of Consecutive Values You Can Make](https://leetcode.com/problems/maximum-number-of-consecutive-values-you-can-make "你能构造出连续值的最大数目") | [Go](problems/maximum-number-of-consecutive-values-you-can-make) | Medium | +| 1797 | [Design Authentication Manager](https://leetcode.com/problems/design-authentication-manager "设计一个验证系统") | [Go](problems/design-authentication-manager) | Medium | +| 1796 | [Second Largest Digit in a String](https://leetcode.com/problems/second-largest-digit-in-a-string "字符串中第二大的数字") | [Go](problems/second-largest-digit-in-a-string) | Easy | +| 1795 | [Rearrange Products Table](https://leetcode.com/problems/rearrange-products-table) 🔒 | [MySQL](problems/rearrange-products-table) | Easy | +| 1794 | [Count Pairs of Equal Substrings With Minimum Difference](https://leetcode.com/problems/count-pairs-of-equal-substrings-with-minimum-difference) 🔒 | [Go](problems/count-pairs-of-equal-substrings-with-minimum-difference) | Medium | +| 1793 | [Maximum Score of a Good Subarray](https://leetcode.com/problems/maximum-score-of-a-good-subarray "好子数组的最大分数") | [Go](problems/maximum-score-of-a-good-subarray) | Hard | +| 1792 | [Maximum Average Pass Ratio](https://leetcode.com/problems/maximum-average-pass-ratio "最大平均通过率") | [Go](problems/maximum-average-pass-ratio) | Medium | +| 1791 | [Find Center of Star Graph](https://leetcode.com/problems/find-center-of-star-graph "找出星型图的中心节点") | [Go](problems/find-center-of-star-graph) | Medium | +| 1790 | [Check if One String Swap Can Make Strings Equal](https://leetcode.com/problems/check-if-one-string-swap-can-make-strings-equal "仅执行一次字符串交换能否使两个字符串相等") | [Go](problems/check-if-one-string-swap-can-make-strings-equal) | Easy | +| 1789 | [Primary Department for Each Employee](https://leetcode.com/problems/primary-department-for-each-employee) 🔒 | [MySQL](problems/primary-department-for-each-employee) | Easy | | 1788 | [Maximize the Beauty of the Garden](https://leetcode.com/problems/maximize-the-beauty-of-the-garden) 🔒 | [Go](problems/maximize-the-beauty-of-the-garden) | Hard | | 1787 | [Make the XOR of All Segments Equal to Zero](https://leetcode.com/problems/make-the-xor-of-all-segments-equal-to-zero "使所有区间的异或结果为零") | [Go](problems/make-the-xor-of-all-segments-equal-to-zero) | Hard | | 1786 | [Number of Restricted Paths From First to Last Node](https://leetcode.com/problems/number-of-restricted-paths-from-first-to-last-node "从第一个节点出发到最后一个节点的受限路径数") | [Go](problems/number-of-restricted-paths-from-first-to-last-node) | Medium | @@ -358,303 +381,3 @@ LeetCode Problems' Solutions | 1503 | [Last Moment Before All Ants Fall Out of a Plank](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank "所有蚂蚁掉下来前的最后一刻") | [Go](problems/last-moment-before-all-ants-fall-out-of-a-plank) | Medium | | 1502 | [Can Make Arithmetic Progression From Sequence](https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence "判断能否形成等差数列") | [Go](problems/can-make-arithmetic-progression-from-sequence) | Easy | | 1501 | [Countries You Can Safely Invest In](https://leetcode.com/problems/countries-you-can-safely-invest-in "可以放心投资的国家") 🔒 | [MySQL](problems/countries-you-can-safely-invest-in) | Medium | -| 1500 | [Design a File Sharing System](https://leetcode.com/problems/design-a-file-sharing-system "设计文件分享系统") 🔒 | [Go](problems/design-a-file-sharing-system) | Medium | -| 1499 | [Max Value of Equation](https://leetcode.com/problems/max-value-of-equation "满足不等式的最大值") | [Go](problems/max-value-of-equation) | Hard | -| 1498 | [Number of Subsequences That Satisfy the Given Sum Condition](https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition "满足条件的子序列数目") | [Go](problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | Medium | -| 1497 | [Check If Array Pairs Are Divisible by k](https://leetcode.com/problems/check-if-array-pairs-are-divisible-by-k "检查数组对是否可以被 k 整除") | [Go](problems/check-if-array-pairs-are-divisible-by-k) | Medium | -| 1496 | [Path Crossing](https://leetcode.com/problems/path-crossing "判断路径是否相交") | [Go](problems/path-crossing) | Easy | -| 1495 | [Friendly Movies Streamed Last Month](https://leetcode.com/problems/friendly-movies-streamed-last-month "上月播放的儿童适宜电影") 🔒 | [MySQL](problems/friendly-movies-streamed-last-month) | Easy | -| 1494 | [Parallel Courses II](https://leetcode.com/problems/parallel-courses-ii "并行课程 II") | [Go](problems/parallel-courses-ii) | Hard | -| 1493 | [Longest Subarray of 1's After Deleting One Element](https://leetcode.com/problems/longest-subarray-of-1s-after-deleting-one-element "删掉一个元素以后全为 1 的最长子数组") | [Go](problems/longest-subarray-of-1s-after-deleting-one-element) | Medium | -| 1492 | [The kth Factor of n](https://leetcode.com/problems/the-kth-factor-of-n "n 的第 k 个因子") | [Go](problems/the-kth-factor-of-n) | Medium | -| 1491 | [Average Salary Excluding the Minimum and Maximum Salary](https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary "去掉最低工资和最高工资后的工资平均值") | [Go](problems/average-salary-excluding-the-minimum-and-maximum-salary) | Easy | -| 1490 | [Clone N-ary Tree](https://leetcode.com/problems/clone-n-ary-tree "克隆 N 叉树") 🔒 | [Go](problems/clone-n-ary-tree) | Medium | -| 1489 | [Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree](https://leetcode.com/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree "找到最小生成树里的关键边和伪关键边") | [Go](problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | Hard | -| 1488 | [Avoid Flood in The City](https://leetcode.com/problems/avoid-flood-in-the-city "避免洪水泛滥") | [Go](problems/avoid-flood-in-the-city) | Medium | -| 1487 | [Making File Names Unique](https://leetcode.com/problems/making-file-names-unique "保证文件名唯一") | [Go](problems/making-file-names-unique) | Medium | -| 1486 | [XOR Operation in an Array](https://leetcode.com/problems/xor-operation-in-an-array "数组异或操作") | [Go](problems/xor-operation-in-an-array) | Easy | -| 1485 | [Clone Binary Tree With Random Pointer](https://leetcode.com/problems/clone-binary-tree-with-random-pointer "克隆含随机指针的二叉树") 🔒 | [Go](problems/clone-binary-tree-with-random-pointer) | Medium | -| 1484 | [Group Sold Products By The Date](https://leetcode.com/problems/group-sold-products-by-the-date "按日期分组销售产品") 🔒 | [MySQL](problems/group-sold-products-by-the-date) | Easy | -| 1483 | [Kth Ancestor of a Tree Node](https://leetcode.com/problems/kth-ancestor-of-a-tree-node "树节点的第 K 个祖先") | [Go](problems/kth-ancestor-of-a-tree-node) | Hard | -| 1482 | [Minimum Number of Days to Make m Bouquets](https://leetcode.com/problems/minimum-number-of-days-to-make-m-bouquets "制作 m 束花所需的最少天数") | [Go](problems/minimum-number-of-days-to-make-m-bouquets) | Medium | -| 1481 | [Least Number of Unique Integers after K Removals](https://leetcode.com/problems/least-number-of-unique-integers-after-k-removals "不同整数的最少数目") | [Go](problems/least-number-of-unique-integers-after-k-removals) | Medium | -| 1480 | [Running Sum of 1d Array](https://leetcode.com/problems/running-sum-of-1d-array "一维数组的动态和") | [Go](problems/running-sum-of-1d-array) | Easy | -| 1479 | [Sales by Day of the Week](https://leetcode.com/problems/sales-by-day-of-the-week "周内每天的销售情况") 🔒 | [MySQL](problems/sales-by-day-of-the-week) | Hard | -| 1478 | [Allocate Mailboxes](https://leetcode.com/problems/allocate-mailboxes "安排邮筒") | [Go](problems/allocate-mailboxes) | Hard | -| 1477 | [Find Two Non-overlapping Sub-arrays Each With Target Sum](https://leetcode.com/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum "找两个和为目标值且不重叠的子数组") | [Go](problems/find-two-non-overlapping-sub-arrays-each-with-target-sum) | Medium | -| 1476 | [Subrectangle Queries](https://leetcode.com/problems/subrectangle-queries "子矩形查询") | [Go](problems/subrectangle-queries) | Medium | -| 1475 | [Final Prices With a Special Discount in a Shop](https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop "商品折扣后的最终价格") | [Go](problems/final-prices-with-a-special-discount-in-a-shop) | Easy | -| 1474 | [Delete N Nodes After M Nodes of a Linked List](https://leetcode.com/problems/delete-n-nodes-after-m-nodes-of-a-linked-list "删除链表 M 个节点之后的 N 个节点") 🔒 | [Go](problems/delete-n-nodes-after-m-nodes-of-a-linked-list) | Easy | -| 1473 | [Paint House III](https://leetcode.com/problems/paint-house-iii "粉刷房子 III") | [Go](problems/paint-house-iii) | Hard | -| 1472 | [Design Browser History](https://leetcode.com/problems/design-browser-history "设计浏览器历史记录") | [Go](problems/design-browser-history) | Medium | -| 1471 | [The k Strongest Values in an Array](https://leetcode.com/problems/the-k-strongest-values-in-an-array "数组中的 k 个最强值") | [Go](problems/the-k-strongest-values-in-an-array) | Medium | -| 1470 | [Shuffle the Array](https://leetcode.com/problems/shuffle-the-array "重新排列数组") | [Go](problems/shuffle-the-array) | Easy | -| 1469 | [Find All The Lonely Nodes](https://leetcode.com/problems/find-all-the-lonely-nodes "寻找所有的独生节点") 🔒 | [Go](problems/find-all-the-lonely-nodes) | Easy | -| 1468 | [Calculate Salaries](https://leetcode.com/problems/calculate-salaries "计算税后工资") 🔒 | [MySQL](problems/calculate-salaries) | Medium | -| 1467 | [Probability of a Two Boxes Having The Same Number of Distinct Balls](https://leetcode.com/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "两个盒子中球的颜色数相同的概率") | [Go](problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | Hard | -| 1466 | [Reorder Routes to Make All Paths Lead to the City Zero](https://leetcode.com/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero "重新规划路线") | [Go](problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | Medium | -| 1465 | [Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts](https://leetcode.com/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts "切割后面积最大的蛋糕") | [Go](problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts) | Medium | -| 1464 | [Maximum Product of Two Elements in an Array](https://leetcode.com/problems/maximum-product-of-two-elements-in-an-array "数组中两元素的最大乘积") | [Go](problems/maximum-product-of-two-elements-in-an-array) | Easy | -| 1463 | [Cherry Pickup II](https://leetcode.com/problems/cherry-pickup-ii "摘樱桃 II") | [Go](problems/cherry-pickup-ii) | Hard | -| 1462 | [Course Schedule IV](https://leetcode.com/problems/course-schedule-iv "课程表 IV") | [Go](problems/course-schedule-iv) | Medium | -| 1461 | [Check If a String Contains All Binary Codes of Size K](https://leetcode.com/problems/check-if-a-string-contains-all-binary-codes-of-size-k "检查一个字符串是否包含所有长度为 K 的二进制子串") | [Go](problems/check-if-a-string-contains-all-binary-codes-of-size-k) | Medium | -| 1460 | [Make Two Arrays Equal by Reversing Sub-arrays](https://leetcode.com/problems/make-two-arrays-equal-by-reversing-sub-arrays "通过翻转子数组使两个数组相等") | [Go](problems/make-two-arrays-equal-by-reversing-sub-arrays) | Easy | -| 1459 | [Rectangles Area](https://leetcode.com/problems/rectangles-area "矩形面积") 🔒 | [MySQL](problems/rectangles-area) | Medium | -| 1458 | [Max Dot Product of Two Subsequences](https://leetcode.com/problems/max-dot-product-of-two-subsequences "两个子序列的最大点积") | [Go](problems/max-dot-product-of-two-subsequences) | Hard | -| 1457 | [Pseudo-Palindromic Paths in a Binary Tree](https://leetcode.com/problems/pseudo-palindromic-paths-in-a-binary-tree "二叉树中的伪回文路径") | [Go](problems/pseudo-palindromic-paths-in-a-binary-tree) | Medium | -| 1456 | [Maximum Number of Vowels in a Substring of Given Length](https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length "定长子串中元音的最大数目") | [Go](problems/maximum-number-of-vowels-in-a-substring-of-given-length) | Medium | -| 1455 | [Check If a Word Occurs As a Prefix of Any Word in a Sentence](https://leetcode.com/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence "检查单词是否为句中其他单词的前缀") | [Go](problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | Easy | -| 1454 | [Active Users](https://leetcode.com/problems/active-users "活跃用户") 🔒 | [MySQL](problems/active-users) | Medium | -| 1453 | [Maximum Number of Darts Inside of a Circular Dartboard](https://leetcode.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard "圆形靶内的最大飞镖数量") | [Go](problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | Hard | -| 1452 | [People Whose List of Favorite Companies Is Not a Subset of Another List](https://leetcode.com/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list "收藏清单") | [Go](problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | Medium | -| 1451 | [Rearrange Words in a Sentence](https://leetcode.com/problems/rearrange-words-in-a-sentence "重新排列句子中的单词") | [Go](problems/rearrange-words-in-a-sentence) | Medium | -| 1450 | [Number of Students Doing Homework at a Given Time](https://leetcode.com/problems/number-of-students-doing-homework-at-a-given-time "在既定时间做作业的学生人数") | [Go](problems/number-of-students-doing-homework-at-a-given-time) | Easy | -| 1449 | [Form Largest Integer With Digits That Add up to Target](https://leetcode.com/problems/form-largest-integer-with-digits-that-add-up-to-target "数位成本和为目标值的最大数字") | [Go](problems/form-largest-integer-with-digits-that-add-up-to-target) | Hard | -| 1448 | [Count Good Nodes in Binary Tree](https://leetcode.com/problems/count-good-nodes-in-binary-tree "统计二叉树中好节点的数目") | [Go](problems/count-good-nodes-in-binary-tree) | Medium | -| 1447 | [Simplified Fractions](https://leetcode.com/problems/simplified-fractions "最简分数") | [Go](problems/simplified-fractions) | Medium | -| 1446 | [Consecutive Characters](https://leetcode.com/problems/consecutive-characters "连续字符") | [Go](problems/consecutive-characters) | Easy | -| 1445 | [Apples & Oranges](https://leetcode.com/problems/apples-oranges "苹果和桔子") 🔒 | [MySQL](problems/apples-oranges) | Medium | -| 1444 | [Number of Ways of Cutting a Pizza](https://leetcode.com/problems/number-of-ways-of-cutting-a-pizza "切披萨的方案数") | [Go](problems/number-of-ways-of-cutting-a-pizza) | Hard | -| 1443 | [Minimum Time to Collect All Apples in a Tree](https://leetcode.com/problems/minimum-time-to-collect-all-apples-in-a-tree "收集树上所有苹果的最少时间") | [Go](problems/minimum-time-to-collect-all-apples-in-a-tree) | Medium | -| 1442 | [Count Triplets That Can Form Two Arrays of Equal XOR](https://leetcode.com/problems/count-triplets-that-can-form-two-arrays-of-equal-xor "形成两个异或相等数组的三元组数目") | [Go](problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | Medium | -| 1441 | [Build an Array With Stack Operations](https://leetcode.com/problems/build-an-array-with-stack-operations "用栈操作构建数组") | [Go](problems/build-an-array-with-stack-operations) | Easy | -| 1440 | [Evaluate Boolean Expression](https://leetcode.com/problems/evaluate-boolean-expression "计算布尔表达式的值") 🔒 | [MySQL](problems/evaluate-boolean-expression) | Medium | -| 1439 | [Find the Kth Smallest Sum of a Matrix With Sorted Rows](https://leetcode.com/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows "有序矩阵中的第 k 个最小数组和") | [Go](problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | Hard | -| 1438 | [Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit](https://leetcode.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "绝对差不超过限制的最长连续子数组") | [Go](problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | Medium | -| 1437 | [Check If All 1's Are at Least Length K Places Away](https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away "是否所有 1 都至少相隔 k 个元素") | [Go](problems/check-if-all-1s-are-at-least-length-k-places-away) | Easy | -| 1436 | [Destination City](https://leetcode.com/problems/destination-city "旅行终点站") | [Go](problems/destination-city) | Easy | -| 1435 | [Create a Session Bar Chart](https://leetcode.com/problems/create-a-session-bar-chart "制作会话柱状图") 🔒 | [MySQL](problems/create-a-session-bar-chart) | Easy | -| 1434 | [Number of Ways to Wear Different Hats to Each Other](https://leetcode.com/problems/number-of-ways-to-wear-different-hats-to-each-other "每个人戴不同帽子的方案数") | [Go](problems/number-of-ways-to-wear-different-hats-to-each-other) | Hard | -| 1433 | [Check If a String Can Break Another String](https://leetcode.com/problems/check-if-a-string-can-break-another-string "检查一个字符串是否可以打破另一个字符串") | [Go](problems/check-if-a-string-can-break-another-string) | Medium | -| 1432 | [Max Difference You Can Get From Changing an Integer](https://leetcode.com/problems/max-difference-you-can-get-from-changing-an-integer "改变一个整数能得到的最大差值") | [Go](problems/max-difference-you-can-get-from-changing-an-integer) | Medium | -| 1431 | [Kids With the Greatest Number of Candies](https://leetcode.com/problems/kids-with-the-greatest-number-of-candies "拥有最多糖果的孩子") | [Go](problems/kids-with-the-greatest-number-of-candies) | Easy | -| 1430 | [Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree](https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree "判断给定的序列是否是二叉树从根到叶的路径") 🔒 | [Go](problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) | Medium | -| 1429 | [First Unique Number](https://leetcode.com/problems/first-unique-number "第一个唯一数字") 🔒 | [Go](problems/first-unique-number) | Medium | -| 1428 | [Leftmost Column with at Least a One](https://leetcode.com/problems/leftmost-column-with-at-least-a-one "至少有一个 1 的最左端列") 🔒 | [Go](problems/leftmost-column-with-at-least-a-one) | Medium | -| 1427 | [Perform String Shifts](https://leetcode.com/problems/perform-string-shifts "字符串的左右移") 🔒 | [Go](problems/perform-string-shifts) | Easy | -| 1426 | [Counting Elements](https://leetcode.com/problems/counting-elements "数元素") 🔒 | [Go](problems/counting-elements) | Easy | -| 1425 | [Constrained Subsequence Sum](https://leetcode.com/problems/constrained-subsequence-sum "带限制的子序列和") | [Go](problems/constrained-subsequence-sum) | Hard | -| 1424 | [Diagonal Traverse II](https://leetcode.com/problems/diagonal-traverse-ii "对角线遍历 II") | [Go](problems/diagonal-traverse-ii) | Medium | -| 1423 | [Maximum Points You Can Obtain from Cards](https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards "可获得的最大点数") | [Go](problems/maximum-points-you-can-obtain-from-cards) | Medium | -| 1422 | [Maximum Score After Splitting a String](https://leetcode.com/problems/maximum-score-after-splitting-a-string "分割字符串的最大得分") | [Go](problems/maximum-score-after-splitting-a-string) | Easy | -| 1421 | [NPV Queries](https://leetcode.com/problems/npv-queries "净现值查询") 🔒 | [MySQL](problems/npv-queries) | Medium | -| 1420 | [Build Array Where You Can Find The Maximum Exactly K Comparisons](https://leetcode.com/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons "生成数组") | [Go](problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons) | Hard | -| 1419 | [Minimum Number of Frogs Croaking](https://leetcode.com/problems/minimum-number-of-frogs-croaking "数青蛙") | [Go](problems/minimum-number-of-frogs-croaking) | Medium | -| 1418 | [Display Table of Food Orders in a Restaurant](https://leetcode.com/problems/display-table-of-food-orders-in-a-restaurant "点菜展示表") | [Go](problems/display-table-of-food-orders-in-a-restaurant) | Medium | -| 1417 | [Reformat The String](https://leetcode.com/problems/reformat-the-string "重新格式化字符串") | [Go](problems/reformat-the-string) | Easy | -| 1416 | [Restore The Array](https://leetcode.com/problems/restore-the-array "恢复数组") | [Go](problems/restore-the-array) | Hard | -| 1415 | [The k-th Lexicographical String of All Happy Strings of Length n](https://leetcode.com/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n "长度为 n 的开心字符串中字典序第 k 小的字符串") | [Go](problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | Medium | -| 1414 | [Find the Minimum Number of Fibonacci Numbers Whose Sum Is K](https://leetcode.com/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k "和为 K 的最少斐波那契数字数目") | [Go](problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | Medium | -| 1413 | [Minimum Value to Get Positive Step by Step Sum](https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum "逐步求和得到正数的最小值") | [Go](problems/minimum-value-to-get-positive-step-by-step-sum) | Easy | -| 1412 | [Find the Quiet Students in All Exams](https://leetcode.com/problems/find-the-quiet-students-in-all-exams "查找成绩处于中游的学生") 🔒 | [MySQL](problems/find-the-quiet-students-in-all-exams) | Hard | -| 1411 | [Number of Ways to Paint N × 3 Grid](https://leetcode.com/problems/number-of-ways-to-paint-n-3-grid "给 N x 3 网格图涂色的方案数") | [Go](problems/number-of-ways-to-paint-n-3-grid) | Hard | -| 1410 | [HTML Entity Parser](https://leetcode.com/problems/html-entity-parser "HTML 实体解析器") | [Go](problems/html-entity-parser) | Medium | -| 1409 | [Queries on a Permutation With Key](https://leetcode.com/problems/queries-on-a-permutation-with-key "查询带键的排列") | [Go](problems/queries-on-a-permutation-with-key) | Medium | -| 1408 | [String Matching in an Array](https://leetcode.com/problems/string-matching-in-an-array "数组中的字符串匹配") | [Go](problems/string-matching-in-an-array) | Easy | -| 1407 | [Top Travellers](https://leetcode.com/problems/top-travellers "排名靠前的旅行者") 🔒 | [MySQL](problems/top-travellers) | Easy | -| 1406 | [Stone Game III](https://leetcode.com/problems/stone-game-iii "石子游戏 III") | [Go](problems/stone-game-iii) | Hard | -| 1405 | [Longest Happy String](https://leetcode.com/problems/longest-happy-string "最长快乐字符串") | [Go](problems/longest-happy-string) | Medium | -| 1404 | [Number of Steps to Reduce a Number in Binary Representation to One](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one "将二进制表示减到 1 的步骤数") | [Go](problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | Medium | -| 1403 | [Minimum Subsequence in Non-Increasing Order](https://leetcode.com/problems/minimum-subsequence-in-non-increasing-order "非递增顺序的最小子序列") | [Go](problems/minimum-subsequence-in-non-increasing-order) | Easy | -| 1402 | [Reducing Dishes](https://leetcode.com/problems/reducing-dishes "做菜顺序") | [Go](problems/reducing-dishes) | Hard | -| 1401 | [Circle and Rectangle Overlapping](https://leetcode.com/problems/circle-and-rectangle-overlapping "圆和矩形是否有重叠") | [Go](problems/circle-and-rectangle-overlapping) | Medium | -| 1400 | [Construct K Palindrome Strings](https://leetcode.com/problems/construct-k-palindrome-strings "构造 K 个回文字符串") | [Go](problems/construct-k-palindrome-strings) | Medium | -| 1399 | [Count Largest Group](https://leetcode.com/problems/count-largest-group "统计最大组的数目") | [Go](problems/count-largest-group) | Easy | -| 1398 | [Customers Who Bought Products A and B but Not C](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c "购买了产品 A 和产品 B 却没有购买产品 C 的顾客") 🔒 | [MySQL](problems/customers-who-bought-products-a-and-b-but-not-c) | Medium | -| 1397 | [Find All Good Strings](https://leetcode.com/problems/find-all-good-strings "找到所有好字符串") | [Go](problems/find-all-good-strings) | Hard | -| 1396 | [Design Underground System](https://leetcode.com/problems/design-underground-system "设计地铁系统") | [Go](problems/design-underground-system) | Medium | -| 1395 | [Count Number of Teams](https://leetcode.com/problems/count-number-of-teams "统计作战单位数") | [Go](problems/count-number-of-teams) | Medium | -| 1394 | [Find Lucky Integer in an Array](https://leetcode.com/problems/find-lucky-integer-in-an-array "找出数组中的幸运数") | [Go](problems/find-lucky-integer-in-an-array) | Easy | -| 1393 | [Capital Gain/Loss](https://leetcode.com/problems/capital-gainloss "股票的资本损益") 🔒 | [MySQL](problems/capital-gainloss) | Medium | -| 1392 | [Longest Happy Prefix](https://leetcode.com/problems/longest-happy-prefix "最长快乐前缀") | [Go](problems/longest-happy-prefix) | Hard | -| 1391 | [Check if There is a Valid Path in a Grid](https://leetcode.com/problems/check-if-there-is-a-valid-path-in-a-grid "检查网格中是否存在有效路径") | [Go](problems/check-if-there-is-a-valid-path-in-a-grid) | Medium | -| 1390 | [Four Divisors](https://leetcode.com/problems/four-divisors "四因数") | [Go](problems/four-divisors) | Medium | -| 1389 | [Create Target Array in the Given Order](https://leetcode.com/problems/create-target-array-in-the-given-order "按既定顺序创建目标数组") | [Go](problems/create-target-array-in-the-given-order) | Easy | -| 1388 | [Pizza With 3n Slices](https://leetcode.com/problems/pizza-with-3n-slices "3n 块披萨") | [Go](problems/pizza-with-3n-slices) | Hard | -| 1387 | [Sort Integers by The Power Value](https://leetcode.com/problems/sort-integers-by-the-power-value "将整数按权重排序") | [Go](problems/sort-integers-by-the-power-value) | Medium | -| 1386 | [Cinema Seat Allocation](https://leetcode.com/problems/cinema-seat-allocation "安排电影院座位") | [Go](problems/cinema-seat-allocation) | Medium | -| 1385 | [Find the Distance Value Between Two Arrays](https://leetcode.com/problems/find-the-distance-value-between-two-arrays "两个数组间的距离值") | [Go](problems/find-the-distance-value-between-two-arrays) | Easy | -| 1384 | [Total Sales Amount by Year](https://leetcode.com/problems/total-sales-amount-by-year "按年度列出销售总额") 🔒 | [MySQL](problems/total-sales-amount-by-year) | Hard | -| 1383 | [Maximum Performance of a Team](https://leetcode.com/problems/maximum-performance-of-a-team "最大的团队表现值") | [Go](problems/maximum-performance-of-a-team) | Hard | -| 1382 | [Balance a Binary Search Tree](https://leetcode.com/problems/balance-a-binary-search-tree "将二叉搜索树变平衡") | [Go](problems/balance-a-binary-search-tree) | Medium | -| 1381 | [Design a Stack With Increment Operation](https://leetcode.com/problems/design-a-stack-with-increment-operation "设计一个支持增量操作的栈") | [Go](problems/design-a-stack-with-increment-operation) | Medium | -| 1380 | [Lucky Numbers in a Matrix](https://leetcode.com/problems/lucky-numbers-in-a-matrix "矩阵中的幸运数") | [Go](problems/lucky-numbers-in-a-matrix) | Easy | -| 1379 | [Find a Corresponding Node of a Binary Tree in a Clone of That Tree](https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree "找出克隆二叉树中的相同节点") | [Go](problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | Medium | -| 1378 | [Replace Employee ID With The Unique Identifier](https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier "使用唯一标识码替换员工ID") 🔒 | [MySQL](problems/replace-employee-id-with-the-unique-identifier) | Easy | -| 1377 | [Frog Position After T Seconds](https://leetcode.com/problems/frog-position-after-t-seconds "T 秒后青蛙的位置") | [Go](problems/frog-position-after-t-seconds) | Hard | -| 1376 | [Time Needed to Inform All Employees](https://leetcode.com/problems/time-needed-to-inform-all-employees "通知所有员工所需的时间") | [Go](problems/time-needed-to-inform-all-employees) | Medium | -| 1375 | [Bulb Switcher III](https://leetcode.com/problems/bulb-switcher-iii "灯泡开关 III") | [Go](problems/bulb-switcher-iii) | Medium | -| 1374 | [Generate a String With Characters That Have Odd Counts](https://leetcode.com/problems/generate-a-string-with-characters-that-have-odd-counts "生成每种字符都是奇数个的字符串") | [Go](problems/generate-a-string-with-characters-that-have-odd-counts) | Easy | -| 1373 | [Maximum Sum BST in Binary Tree](https://leetcode.com/problems/maximum-sum-bst-in-binary-tree "二叉搜索子树的最大键值和") | [Go](problems/maximum-sum-bst-in-binary-tree) | Hard | -| 1372 | [Longest ZigZag Path in a Binary Tree](https://leetcode.com/problems/longest-zigzag-path-in-a-binary-tree "二叉树中的最长交错路径") | [Go](problems/longest-zigzag-path-in-a-binary-tree) | Medium | -| 1371 | [Find the Longest Substring Containing Vowels in Even Counts](https://leetcode.com/problems/find-the-longest-substring-containing-vowels-in-even-counts "每个元音包含偶数次的最长子字符串") | [Go](problems/find-the-longest-substring-containing-vowels-in-even-counts) | Medium | -| 1370 | [Increasing Decreasing String](https://leetcode.com/problems/increasing-decreasing-string "上升下降字符串") | [Go](problems/increasing-decreasing-string) | Easy | -| 1369 | [Get the Second Most Recent Activity](https://leetcode.com/problems/get-the-second-most-recent-activity "获取最近第二次的活动") 🔒 | [MySQL](problems/get-the-second-most-recent-activity) | Hard | -| 1368 | [Minimum Cost to Make at Least One Valid Path in a Grid](https://leetcode.com/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid "使网格图至少有一条有效路径的最小代价") | [Go](problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | Hard | -| 1367 | [Linked List in Binary Tree](https://leetcode.com/problems/linked-list-in-binary-tree "二叉树中的列表") | [Go](problems/linked-list-in-binary-tree) | Medium | -| 1366 | [Rank Teams by Votes](https://leetcode.com/problems/rank-teams-by-votes "通过投票对团队排名") | [Go](problems/rank-teams-by-votes) | Medium | -| 1365 | [How Many Numbers Are Smaller Than the Current Number](https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number "有多少小于当前数字的数字") | [Go](problems/how-many-numbers-are-smaller-than-the-current-number) | Easy | -| 1364 | [Number of Trusted Contacts of a Customer](https://leetcode.com/problems/number-of-trusted-contacts-of-a-customer "顾客的可信联系人数量") 🔒 | [MySQL](problems/number-of-trusted-contacts-of-a-customer) | Medium | -| 1363 | [Largest Multiple of Three](https://leetcode.com/problems/largest-multiple-of-three "形成三的最大倍数") | [Go](problems/largest-multiple-of-three) | Hard | -| 1362 | [Closest Divisors](https://leetcode.com/problems/closest-divisors "最接近的因数") | [Go](problems/closest-divisors) | Medium | -| 1361 | [Validate Binary Tree Nodes](https://leetcode.com/problems/validate-binary-tree-nodes "验证二叉树") | [Go](problems/validate-binary-tree-nodes) | Medium | -| 1360 | [Number of Days Between Two Dates](https://leetcode.com/problems/number-of-days-between-two-dates "日期之间隔几天") | [Go](problems/number-of-days-between-two-dates) | Easy | -| 1359 | [Count All Valid Pickup and Delivery Options](https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options "有效的快递序列数目") | [Go](problems/count-all-valid-pickup-and-delivery-options) | Hard | -| 1358 | [Number of Substrings Containing All Three Characters](https://leetcode.com/problems/number-of-substrings-containing-all-three-characters "包含所有三种字符的子字符串数目") | [Go](problems/number-of-substrings-containing-all-three-characters) | Medium | -| 1357 | [Apply Discount Every n Orders](https://leetcode.com/problems/apply-discount-every-n-orders "每隔 n 个顾客打折") | [Go](problems/apply-discount-every-n-orders) | Medium | -| 1356 | [Sort Integers by The Number of 1 Bits](https://leetcode.com/problems/sort-integers-by-the-number-of-1-bits "根据数字二进制下 1 的数目排序") | [Go](problems/sort-integers-by-the-number-of-1-bits) | Easy | -| 1355 | [Activity Participants](https://leetcode.com/problems/activity-participants "活动参与者") 🔒 | [MySQL](problems/activity-participants) | Medium | -| 1354 | [Construct Target Array With Multiple Sums](https://leetcode.com/problems/construct-target-array-with-multiple-sums "多次求和构造目标数组") | [Go](problems/construct-target-array-with-multiple-sums) | Hard | -| 1353 | [Maximum Number of Events That Can Be Attended](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended "最多可以参加的会议数目") | [Go](problems/maximum-number-of-events-that-can-be-attended) | Medium | -| 1352 | [Product of the Last K Numbers](https://leetcode.com/problems/product-of-the-last-k-numbers "最后 K 个数的乘积") | [Go](problems/product-of-the-last-k-numbers) | Medium | -| 1351 | [Count Negative Numbers in a Sorted Matrix](https://leetcode.com/problems/count-negative-numbers-in-a-sorted-matrix "统计有序矩阵中的负数") | [Go](problems/count-negative-numbers-in-a-sorted-matrix) | Easy | -| 1350 | [Students With Invalid Departments](https://leetcode.com/problems/students-with-invalid-departments "院系无效的学生") 🔒 | [MySQL](problems/students-with-invalid-departments) | Easy | -| 1349 | [Maximum Students Taking Exam](https://leetcode.com/problems/maximum-students-taking-exam "参加考试的最大学生数") | [Go](problems/maximum-students-taking-exam) | Hard | -| 1348 | [Tweet Counts Per Frequency](https://leetcode.com/problems/tweet-counts-per-frequency "推文计数") | [Go](problems/tweet-counts-per-frequency) | Medium | -| 1347 | [Minimum Number of Steps to Make Two Strings Anagram](https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram "制造字母异位词的最小步骤数") | [Go](problems/minimum-number-of-steps-to-make-two-strings-anagram) | Medium | -| 1346 | [Check If N and Its Double Exist](https://leetcode.com/problems/check-if-n-and-its-double-exist "检查整数及其两倍数是否存在") | [Go](problems/check-if-n-and-its-double-exist) | Easy | -| 1345 | [Jump Game IV](https://leetcode.com/problems/jump-game-iv "跳跃游戏 IV") | [Go](problems/jump-game-iv) | Hard | -| 1344 | [Angle Between Hands of a Clock](https://leetcode.com/problems/angle-between-hands-of-a-clock "时钟指针的夹角") | [Go](problems/angle-between-hands-of-a-clock) | Medium | -| 1343 | [Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold](https://leetcode.com/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold "大小为 K 且平均值大于等于阈值的子数组数目") | [Go](problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold) | Medium | -| 1342 | [Number of Steps to Reduce a Number to Zero](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero "将数字变成 0 的操作次数") | [Go](problems/number-of-steps-to-reduce-a-number-to-zero) | Easy | -| 1341 | [Movie Rating](https://leetcode.com/problems/movie-rating "电影评分") 🔒 | [MySQL](problems/movie-rating) | Medium | -| 1340 | [Jump Game V](https://leetcode.com/problems/jump-game-v "跳跃游戏 V") | [Go](problems/jump-game-v) | Hard | -| 1339 | [Maximum Product of Splitted Binary Tree](https://leetcode.com/problems/maximum-product-of-splitted-binary-tree "分裂二叉树的最大乘积") | [Go](problems/maximum-product-of-splitted-binary-tree) | Medium | -| 1338 | [Reduce Array Size to The Half](https://leetcode.com/problems/reduce-array-size-to-the-half "数组大小减半") | [Go](problems/reduce-array-size-to-the-half) | Medium | -| 1337 | [The K Weakest Rows in a Matrix](https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix "矩阵中战斗力最弱的 K 行") | [Go](problems/the-k-weakest-rows-in-a-matrix) | Easy | -| 1336 | [Number of Transactions per Visit](https://leetcode.com/problems/number-of-transactions-per-visit "每次访问的交易次数") 🔒 | [MySQL](problems/number-of-transactions-per-visit) | Hard | -| 1335 | [Minimum Difficulty of a Job Schedule](https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule "工作计划的最低难度") | [Go](problems/minimum-difficulty-of-a-job-schedule) | Hard | -| 1334 | [Find the City With the Smallest Number of Neighbors at a Threshold Distance](https://leetcode.com/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance "阈值距离内邻居最少的城市") | [Go](problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | Medium | -| 1333 | [Filter Restaurants by Vegan-Friendly, Price and Distance](https://leetcode.com/problems/filter-restaurants-by-vegan-friendly-price-and-distance "餐厅过滤器") | [Go](problems/filter-restaurants-by-vegan-friendly-price-and-distance) | Medium | -| 1332 | [Remove Palindromic Subsequences](https://leetcode.com/problems/remove-palindromic-subsequences "删除回文子序列") | [Go](problems/remove-palindromic-subsequences) | Easy | -| 1331 | [Rank Transform of an Array](https://leetcode.com/problems/rank-transform-of-an-array "数组序号转换") | [Go](problems/rank-transform-of-an-array) | Easy | -| 1330 | [Reverse Subarray To Maximize Array Value](https://leetcode.com/problems/reverse-subarray-to-maximize-array-value "翻转子数组得到最大的数组值") | [Go](problems/reverse-subarray-to-maximize-array-value) | Hard | -| 1329 | [Sort the Matrix Diagonally](https://leetcode.com/problems/sort-the-matrix-diagonally "将矩阵按对角线排序") | [Go](problems/sort-the-matrix-diagonally) | Medium | -| 1328 | [Break a Palindrome](https://leetcode.com/problems/break-a-palindrome "破坏回文串") | [Go](problems/break-a-palindrome) | Medium | -| 1327 | [List the Products Ordered in a Period](https://leetcode.com/problems/list-the-products-ordered-in-a-period "列出指定时间段内所有的下单产品") 🔒 | [MySQL](problems/list-the-products-ordered-in-a-period) | Easy | -| 1326 | [Minimum Number of Taps to Open to Water a Garden](https://leetcode.com/problems/minimum-number-of-taps-to-open-to-water-a-garden "灌溉花园的最少水龙头数目") | [Go](problems/minimum-number-of-taps-to-open-to-water-a-garden) | Hard | -| 1325 | [Delete Leaves With a Given Value](https://leetcode.com/problems/delete-leaves-with-a-given-value "删除给定值的叶子节点") | [Go](problems/delete-leaves-with-a-given-value) | Medium | -| 1324 | [Print Words Vertically](https://leetcode.com/problems/print-words-vertically "竖直打印单词") | [Go](problems/print-words-vertically) | Medium | -| 1323 | [Maximum 69 Number](https://leetcode.com/problems/maximum-69-number "6 和 9 组成的最大数字") | [Go](problems/maximum-69-number) | Easy | -| 1322 | [Ads Performance](https://leetcode.com/problems/ads-performance "广告效果") 🔒 | [MySQL](problems/ads-performance) | Easy | -| 1321 | [Restaurant Growth](https://leetcode.com/problems/restaurant-growth "餐馆营业额变化增长") 🔒 | [MySQL](problems/restaurant-growth) | Medium | -| 1320 | [Minimum Distance to Type a Word Using Two Fingers](https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers "二指输入的的最小距离") | [Go](problems/minimum-distance-to-type-a-word-using-two-fingers) | Hard | -| 1319 | [Number of Operations to Make Network Connected](https://leetcode.com/problems/number-of-operations-to-make-network-connected "连通网络的操作次数") | [Go](problems/number-of-operations-to-make-network-connected) | Medium | -| 1318 | [Minimum Flips to Make a OR b Equal to c](https://leetcode.com/problems/minimum-flips-to-make-a-or-b-equal-to-c "或运算的最小翻转次数") | [Go](problems/minimum-flips-to-make-a-or-b-equal-to-c) | Medium | -| 1317 | [Convert Integer to the Sum of Two No-Zero Integers](https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers "将整数转换为两个无零整数的和") | [Go](problems/convert-integer-to-the-sum-of-two-no-zero-integers) | Easy | -| 1316 | [Distinct Echo Substrings](https://leetcode.com/problems/distinct-echo-substrings "不同的循环子字符串") | [Go](problems/distinct-echo-substrings) | Hard | -| 1315 | [Sum of Nodes with Even-Valued Grandparent](https://leetcode.com/problems/sum-of-nodes-with-even-valued-grandparent "祖父节点值为偶数的节点和") | [Go](problems/sum-of-nodes-with-even-valued-grandparent) | Medium | -| 1314 | [Matrix Block Sum](https://leetcode.com/problems/matrix-block-sum "矩阵区域和") | [Go](problems/matrix-block-sum) | Medium | -| 1313 | [Decompress Run-Length Encoded List](https://leetcode.com/problems/decompress-run-length-encoded-list "解压缩编码列表") | [Go](problems/decompress-run-length-encoded-list) | Easy | -| 1312 | [Minimum Insertion Steps to Make a String Palindrome](https://leetcode.com/problems/minimum-insertion-steps-to-make-a-string-palindrome "让字符串成为回文串的最少插入次数") | [Go](problems/minimum-insertion-steps-to-make-a-string-palindrome) | Hard | -| 1311 | [Get Watched Videos by Your Friends](https://leetcode.com/problems/get-watched-videos-by-your-friends "获取你好友已观看的视频") | [Go](problems/get-watched-videos-by-your-friends) | Medium | -| 1310 | [XOR Queries of a Subarray](https://leetcode.com/problems/xor-queries-of-a-subarray "子数组异或查询") | [Go](problems/xor-queries-of-a-subarray) | Medium | -| 1309 | [Decrypt String from Alphabet to Integer Mapping](https://leetcode.com/problems/decrypt-string-from-alphabet-to-integer-mapping "解码字母到整数映射") | [Go](problems/decrypt-string-from-alphabet-to-integer-mapping) | Easy | -| 1308 | [Running Total for Different Genders](https://leetcode.com/problems/running-total-for-different-genders "不同性别每日分数总计") 🔒 | [MySQL](problems/running-total-for-different-genders) | Medium | -| 1307 | [Verbal Arithmetic Puzzle](https://leetcode.com/problems/verbal-arithmetic-puzzle "口算难题") | [Go](problems/verbal-arithmetic-puzzle) | Hard | -| 1306 | [Jump Game III](https://leetcode.com/problems/jump-game-iii "跳跃游戏 III") | [Go](problems/jump-game-iii) | Medium | -| 1305 | [All Elements in Two Binary Search Trees](https://leetcode.com/problems/all-elements-in-two-binary-search-trees "两棵二叉搜索树中的所有元素") | [Go](problems/all-elements-in-two-binary-search-trees) | Medium | -| 1304 | [Find N Unique Integers Sum up to Zero](https://leetcode.com/problems/find-n-unique-integers-sum-up-to-zero "和为零的N个唯一整数") | [Go](problems/find-n-unique-integers-sum-up-to-zero) | Easy | -| 1303 | [Find the Team Size](https://leetcode.com/problems/find-the-team-size "求团队人数") 🔒 | [MySQL](problems/find-the-team-size) | Easy | -| 1302 | [Deepest Leaves Sum](https://leetcode.com/problems/deepest-leaves-sum "层数最深叶子节点的和") | [Go](problems/deepest-leaves-sum) | Medium | -| 1301 | [Number of Paths with Max Score](https://leetcode.com/problems/number-of-paths-with-max-score "最大得分的路径数目") | [Go](problems/number-of-paths-with-max-score) | Hard | -| 1300 | [Sum of Mutated Array Closest to Target](https://leetcode.com/problems/sum-of-mutated-array-closest-to-target "转变数组后最接近目标值的数组和") | [Go](problems/sum-of-mutated-array-closest-to-target) | Medium | -| 1299 | [Replace Elements with Greatest Element on Right Side](https://leetcode.com/problems/replace-elements-with-greatest-element-on-right-side "将每个元素替换为右侧最大元素") | [Go](problems/replace-elements-with-greatest-element-on-right-side) | Easy | -| 1298 | [Maximum Candies You Can Get from Boxes](https://leetcode.com/problems/maximum-candies-you-can-get-from-boxes "你能从盒子里获得的最大糖果数") | [Go](problems/maximum-candies-you-can-get-from-boxes) | Hard | -| 1297 | [Maximum Number of Occurrences of a Substring](https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring "子串的最大出现次数") | [Go](problems/maximum-number-of-occurrences-of-a-substring) | Medium | -| 1296 | [Divide Array in Sets of K Consecutive Numbers](https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers "划分数组为连续数字的集合") | [Go](problems/divide-array-in-sets-of-k-consecutive-numbers) | Medium | -| 1295 | [Find Numbers with Even Number of Digits](https://leetcode.com/problems/find-numbers-with-even-number-of-digits "统计位数为偶数的数字") | [Go](problems/find-numbers-with-even-number-of-digits) | Easy | -| 1294 | [Weather Type in Each Country](https://leetcode.com/problems/weather-type-in-each-country "不同国家的天气类型") 🔒 | [MySQL](problems/weather-type-in-each-country) | Easy | -| 1293 | [Shortest Path in a Grid with Obstacles Elimination](https://leetcode.com/problems/shortest-path-in-a-grid-with-obstacles-elimination "网格中的最短路径") | [Go](problems/shortest-path-in-a-grid-with-obstacles-elimination) | Hard | -| 1292 | [Maximum Side Length of a Square with Sum Less than or Equal to Threshold](https://leetcode.com/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold "元素和小于等于阈值的正方形的最大边长") | [Go](problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | Medium | -| 1291 | [Sequential Digits](https://leetcode.com/problems/sequential-digits "顺次数") | [Go](problems/sequential-digits) | Medium | -| 1290 | [Convert Binary Number in a Linked List to Integer](https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer "二进制链表转整数") | [Go](problems/convert-binary-number-in-a-linked-list-to-integer) | Easy | -| 1289 | [Minimum Falling Path Sum II](https://leetcode.com/problems/minimum-falling-path-sum-ii "下降路径最小和 II") | [Go](problems/minimum-falling-path-sum-ii) | Hard | -| 1288 | [Remove Covered Intervals](https://leetcode.com/problems/remove-covered-intervals "删除被覆盖区间") | [Go](problems/remove-covered-intervals) | Medium | -| 1287 | [Element Appearing More Than 25% In Sorted Array](https://leetcode.com/problems/element-appearing-more-than-25-in-sorted-array "有序数组中出现次数超过25%的元素") | [Go](problems/element-appearing-more-than-25-in-sorted-array) | Easy | -| 1286 | [Iterator for Combination](https://leetcode.com/problems/iterator-for-combination "字母组合迭代器") | [Go](problems/iterator-for-combination) | Medium | -| 1285 | [Find the Start and End Number of Continuous Ranges](https://leetcode.com/problems/find-the-start-and-end-number-of-continuous-ranges "找到连续区间的开始和结束数字") 🔒 | [MySQL](problems/find-the-start-and-end-number-of-continuous-ranges) | Medium | -| 1284 | [Minimum Number of Flips to Convert Binary Matrix to Zero Matrix](https://leetcode.com/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix "转化为全零矩阵的最少反转次数") | [Go](problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | Hard | -| 1283 | [Find the Smallest Divisor Given a Threshold](https://leetcode.com/problems/find-the-smallest-divisor-given-a-threshold "使结果不超过阈值的最小除数") | [Go](problems/find-the-smallest-divisor-given-a-threshold) | Medium | -| 1282 | [Group the People Given the Group Size They Belong To](https://leetcode.com/problems/group-the-people-given-the-group-size-they-belong-to "用户分组") | [Go](problems/group-the-people-given-the-group-size-they-belong-to) | Medium | -| 1281 | [Subtract the Product and Sum of Digits of an Integer](https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer "整数的各位积和之差") | [Go](problems/subtract-the-product-and-sum-of-digits-of-an-integer) | Easy | -| 1280 | [Students and Examinations](https://leetcode.com/problems/students-and-examinations "学生们参加各科测试的次数") 🔒 | [MySQL](problems/students-and-examinations) | Easy | -| 1279 | [Traffic Light Controlled Intersection](https://leetcode.com/problems/traffic-light-controlled-intersection "红绿灯路口") 🔒 | [Go](problems/traffic-light-controlled-intersection) | Easy | -| 1278 | [Palindrome Partitioning III](https://leetcode.com/problems/palindrome-partitioning-iii "分割回文串 III") | [Go](problems/palindrome-partitioning-iii) | Hard | -| 1277 | [Count Square Submatrices with All Ones](https://leetcode.com/problems/count-square-submatrices-with-all-ones "统计全为 1 的正方形子矩阵") | [Go](problems/count-square-submatrices-with-all-ones) | Medium | -| 1276 | [Number of Burgers with No Waste of Ingredients](https://leetcode.com/problems/number-of-burgers-with-no-waste-of-ingredients "不浪费原料的汉堡制作方案") | [Go](problems/number-of-burgers-with-no-waste-of-ingredients) | Medium | -| 1275 | [Find Winner on a Tic Tac Toe Game](https://leetcode.com/problems/find-winner-on-a-tic-tac-toe-game "找出井字棋的获胜者") | [Go](problems/find-winner-on-a-tic-tac-toe-game) | Easy | -| 1274 | [Number of Ships in a Rectangle](https://leetcode.com/problems/number-of-ships-in-a-rectangle "矩形内船只的数目") 🔒 | [Go](problems/number-of-ships-in-a-rectangle) | Hard | -| 1273 | [Delete Tree Nodes](https://leetcode.com/problems/delete-tree-nodes "删除树节点") 🔒 | [Go](problems/delete-tree-nodes) | Medium | -| 1272 | [Remove Interval](https://leetcode.com/problems/remove-interval "删除区间") 🔒 | [Go](problems/remove-interval) | Medium | -| 1271 | [Hexspeak](https://leetcode.com/problems/hexspeak "十六进制魔术数字") 🔒 | [Go](problems/hexspeak) | Easy | -| 1270 | [All People Report to the Given Manager](https://leetcode.com/problems/all-people-report-to-the-given-manager "向公司CEO汇报工作的所有人") 🔒 | [MySQL](problems/all-people-report-to-the-given-manager) | Medium | -| 1269 | [Number of Ways to Stay in the Same Place After Some Steps](https://leetcode.com/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps "停在原地的方案数") | [Go](problems/number-of-ways-to-stay-in-the-same-place-after-some-steps) | Hard | -| 1268 | [Search Suggestions System](https://leetcode.com/problems/search-suggestions-system "搜索推荐系统") | [Go](problems/search-suggestions-system) | Medium | -| 1267 | [Count Servers that Communicate](https://leetcode.com/problems/count-servers-that-communicate "统计参与通信的服务器") | [Go](problems/count-servers-that-communicate) | Medium | -| 1266 | [Minimum Time Visiting All Points](https://leetcode.com/problems/minimum-time-visiting-all-points "访问所有点的最小时间") | [Go](problems/minimum-time-visiting-all-points) | Easy | -| 1265 | [Print Immutable Linked List in Reverse](https://leetcode.com/problems/print-immutable-linked-list-in-reverse "逆序打印不可变链表") 🔒 | [Go](problems/print-immutable-linked-list-in-reverse) | Medium | -| 1264 | [Page Recommendations](https://leetcode.com/problems/page-recommendations "页面推荐") 🔒 | [MySQL](problems/page-recommendations) | Medium | -| 1263 | [Minimum Moves to Move a Box to Their Target Location](https://leetcode.com/problems/minimum-moves-to-move-a-box-to-their-target-location "推箱子") | [Go](problems/minimum-moves-to-move-a-box-to-their-target-location) | Hard | -| 1262 | [Greatest Sum Divisible by Three](https://leetcode.com/problems/greatest-sum-divisible-by-three "可被三整除的最大和") | [Go](problems/greatest-sum-divisible-by-three) | Medium | -| 1261 | [Find Elements in a Contaminated Binary Tree](https://leetcode.com/problems/find-elements-in-a-contaminated-binary-tree "在受污染的二叉树中查找元素") | [Go](problems/find-elements-in-a-contaminated-binary-tree) | Medium | -| 1260 | [Shift 2D Grid](https://leetcode.com/problems/shift-2d-grid "二维网格迁移") | [Go](problems/shift-2d-grid) | Easy | -| 1259 | [Handshakes That Don't Cross](https://leetcode.com/problems/handshakes-that-dont-cross "不相交的握手") 🔒 | [Go](problems/handshakes-that-dont-cross) | Hard | -| 1258 | [Synonymous Sentences](https://leetcode.com/problems/synonymous-sentences "近义词句子") 🔒 | [Go](problems/synonymous-sentences) | Medium | -| 1257 | [Smallest Common Region](https://leetcode.com/problems/smallest-common-region "最小公共区域") 🔒 | [Go](problems/smallest-common-region) | Medium | -| 1256 | [Encode Number](https://leetcode.com/problems/encode-number "加密数字") 🔒 | [Go](problems/encode-number) | Medium | -| 1255 | [Maximum Score Words Formed by Letters](https://leetcode.com/problems/maximum-score-words-formed-by-letters "得分最高的单词集合") | [Go](problems/maximum-score-words-formed-by-letters) | Hard | -| 1254 | [Number of Closed Islands](https://leetcode.com/problems/number-of-closed-islands "统计封闭岛屿的数目") | [Go](problems/number-of-closed-islands) | Medium | -| 1253 | [Reconstruct a 2-Row Binary Matrix](https://leetcode.com/problems/reconstruct-a-2-row-binary-matrix "重构 2 行二进制矩阵") | [Go](problems/reconstruct-a-2-row-binary-matrix) | Medium | -| 1252 | [Cells with Odd Values in a Matrix](https://leetcode.com/problems/cells-with-odd-values-in-a-matrix "奇数值单元格的数目") | [Go](problems/cells-with-odd-values-in-a-matrix) | Easy | -| 1251 | [Average Selling Price](https://leetcode.com/problems/average-selling-price "平均售价") 🔒 | [MySQL](problems/average-selling-price) | Easy | -| 1250 | [Check If It Is a Good Array](https://leetcode.com/problems/check-if-it-is-a-good-array "检查「好数组」") | [Go](problems/check-if-it-is-a-good-array) | Hard | -| 1249 | [Minimum Remove to Make Valid Parentheses](https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses "移除无效的括号") | [Go](problems/minimum-remove-to-make-valid-parentheses) | Medium | -| 1248 | [Count Number of Nice Subarrays](https://leetcode.com/problems/count-number-of-nice-subarrays "统计「优美子数组」") | [Go](problems/count-number-of-nice-subarrays) | Medium | -| 1247 | [Minimum Swaps to Make Strings Equal](https://leetcode.com/problems/minimum-swaps-to-make-strings-equal "交换字符使得字符串相同") | [Go](problems/minimum-swaps-to-make-strings-equal) | Medium | -| 1246 | [Palindrome Removal](https://leetcode.com/problems/palindrome-removal "删除回文子数组") 🔒 | [Go](problems/palindrome-removal) | Hard | -| 1245 | [Tree Diameter](https://leetcode.com/problems/tree-diameter "树的直径") 🔒 | [Go](problems/tree-diameter) | Medium | -| 1244 | [Design A Leaderboard](https://leetcode.com/problems/design-a-leaderboard "力扣排行榜") 🔒 | [Go](problems/design-a-leaderboard) | Medium | -| 1243 | [Array Transformation](https://leetcode.com/problems/array-transformation "数组变换") 🔒 | [Go](problems/array-transformation) | Easy | -| 1242 | [Web Crawler Multithreaded](https://leetcode.com/problems/web-crawler-multithreaded "多线程网页爬虫") 🔒 | [Go](problems/web-crawler-multithreaded) | Medium | -| 1241 | [Number of Comments per Post](https://leetcode.com/problems/number-of-comments-per-post "每个帖子的评论数") 🔒 | [MySQL](problems/number-of-comments-per-post) | Easy | -| 1240 | [Tiling a Rectangle with the Fewest Squares](https://leetcode.com/problems/tiling-a-rectangle-with-the-fewest-squares "铺瓷砖") | [Go](problems/tiling-a-rectangle-with-the-fewest-squares) | Hard | -| 1239 | [Maximum Length of a Concatenated String with Unique Characters](https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters "串联字符串的最大长度") | [Go](problems/maximum-length-of-a-concatenated-string-with-unique-characters) | Medium | -| 1238 | [Circular Permutation in Binary Representation](https://leetcode.com/problems/circular-permutation-in-binary-representation "循环码排列") | [Go](problems/circular-permutation-in-binary-representation) | Medium | -| 1237 | [Find Positive Integer Solution for a Given Equation](https://leetcode.com/problems/find-positive-integer-solution-for-a-given-equation "找出给定方程的正整数解") | [Go](problems/find-positive-integer-solution-for-a-given-equation) | Medium | -| 1236 | [Web Crawler](https://leetcode.com/problems/web-crawler "网络爬虫") 🔒 | [Go](problems/web-crawler) | Medium | -| 1235 | [Maximum Profit in Job Scheduling](https://leetcode.com/problems/maximum-profit-in-job-scheduling "规划兼职工作") | [Go](problems/maximum-profit-in-job-scheduling) | Hard | -| 1234 | [Replace the Substring for Balanced String](https://leetcode.com/problems/replace-the-substring-for-balanced-string "替换子串得到平衡字符串") | [Go](problems/replace-the-substring-for-balanced-string) | Medium | -| 1233 | [Remove Sub-Folders from the Filesystem](https://leetcode.com/problems/remove-sub-folders-from-the-filesystem "删除子文件夹") | [Go](problems/remove-sub-folders-from-the-filesystem) | Medium | -| 1232 | [Check If It Is a Straight Line](https://leetcode.com/problems/check-if-it-is-a-straight-line "缀点成线") | [Go](problems/check-if-it-is-a-straight-line) | Easy | -| 1231 | [Divide Chocolate](https://leetcode.com/problems/divide-chocolate "分享巧克力") 🔒 | [Go](problems/divide-chocolate) | Hard | -| 1230 | [Toss Strange Coins](https://leetcode.com/problems/toss-strange-coins "抛掷硬币") 🔒 | [Go](problems/toss-strange-coins) | Medium | -| 1229 | [Meeting Scheduler](https://leetcode.com/problems/meeting-scheduler "安排会议日程") 🔒 | [Go](problems/meeting-scheduler) | Medium | -| 1228 | [Missing Number In Arithmetic Progression](https://leetcode.com/problems/missing-number-in-arithmetic-progression "等差数列中缺失的数字") 🔒 | [Go](problems/missing-number-in-arithmetic-progression) | Easy | -| 1227 | [Airplane Seat Assignment Probability](https://leetcode.com/problems/airplane-seat-assignment-probability "飞机座位分配概率") | [Go](problems/airplane-seat-assignment-probability) | Medium | -| 1226 | [The Dining Philosophers](https://leetcode.com/problems/the-dining-philosophers "哲学家进餐") | [Go](problems/the-dining-philosophers) | Medium | -| 1225 | [Report Contiguous Dates](https://leetcode.com/problems/report-contiguous-dates "报告系统状态的连续日期") 🔒 | [MySQL](problems/report-contiguous-dates) | Hard | -| 1224 | [Maximum Equal Frequency](https://leetcode.com/problems/maximum-equal-frequency "最大相等频率") | [Go](problems/maximum-equal-frequency) | Hard | -| 1223 | [Dice Roll Simulation](https://leetcode.com/problems/dice-roll-simulation "掷骰子模拟") | [Go](problems/dice-roll-simulation) | Hard | -| 1222 | [Queens That Can Attack the King](https://leetcode.com/problems/queens-that-can-attack-the-king "可以攻击国王的皇后") | [Go](problems/queens-that-can-attack-the-king) | Medium | -| 1221 | [Split a String in Balanced Strings](https://leetcode.com/problems/split-a-string-in-balanced-strings "分割平衡字符串") | [Go](problems/split-a-string-in-balanced-strings) | Easy | -| 1220 | [Count Vowels Permutation](https://leetcode.com/problems/count-vowels-permutation "统计元音字母序列的数目") | [Go](problems/count-vowels-permutation) | Hard | -| 1219 | [Path with Maximum Gold](https://leetcode.com/problems/path-with-maximum-gold "黄金矿工") | [Go](problems/path-with-maximum-gold) | Medium | -| 1218 | [Longest Arithmetic Subsequence of Given Difference](https://leetcode.com/problems/longest-arithmetic-subsequence-of-given-difference "最长定差子序列") | [Go](problems/longest-arithmetic-subsequence-of-given-difference) | Medium | -| 1217 | [Minimum Cost to Move Chips to The Same Position](https://leetcode.com/problems/minimum-cost-to-move-chips-to-the-same-position "玩筹码") | [Go](problems/minimum-cost-to-move-chips-to-the-same-position) | Easy | -| 1216 | [Valid Palindrome III](https://leetcode.com/problems/valid-palindrome-iii "验证回文字符串 III") 🔒 | [Go](problems/valid-palindrome-iii) | Hard | -| 1215 | [Stepping Numbers](https://leetcode.com/problems/stepping-numbers "步进数") 🔒 | [Go](problems/stepping-numbers) | Medium | -| 1214 | [Two Sum BSTs](https://leetcode.com/problems/two-sum-bsts "查找两棵二叉搜索树之和") 🔒 | [Go](problems/two-sum-bsts) | Medium | -| 1213 | [Intersection of Three Sorted Arrays](https://leetcode.com/problems/intersection-of-three-sorted-arrays "三个有序数组的交集") 🔒 | [Go](problems/intersection-of-three-sorted-arrays) | Easy | -| 1212 | [Team Scores in Football Tournament](https://leetcode.com/problems/team-scores-in-football-tournament "查询球队积分") 🔒 | [MySQL](problems/team-scores-in-football-tournament) | Medium | -| 1211 | [Queries Quality and Percentage](https://leetcode.com/problems/queries-quality-and-percentage "查询结果的质量和占比") 🔒 | [MySQL](problems/queries-quality-and-percentage) | Easy | -| 1210 | [Minimum Moves to Reach Target with Rotations](https://leetcode.com/problems/minimum-moves-to-reach-target-with-rotations "穿过迷宫的最少移动次数") | [Go](problems/minimum-moves-to-reach-target-with-rotations) | Hard | -| 1209 | [Remove All Adjacent Duplicates in String II](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii "删除字符串中的所有相邻重复项 II") | [Go](problems/remove-all-adjacent-duplicates-in-string-ii) | Medium | -| 1208 | [Get Equal Substrings Within Budget](https://leetcode.com/problems/get-equal-substrings-within-budget "尽可能使字符串相等") | [Go](problems/get-equal-substrings-within-budget) | Medium | -| 1207 | [Unique Number of Occurrences](https://leetcode.com/problems/unique-number-of-occurrences "独一无二的出现次数") | [Go](problems/unique-number-of-occurrences) | Easy | -| 1206 | [Design Skiplist](https://leetcode.com/problems/design-skiplist "设计跳表") | [Go](problems/design-skiplist) | Hard | -| 1205 | [Monthly Transactions II](https://leetcode.com/problems/monthly-transactions-ii "每月交易II") 🔒 | [MySQL](problems/monthly-transactions-ii) | Medium | -| 1204 | [Last Person to Fit in the Elevator](https://leetcode.com/problems/last-person-to-fit-in-the-elevator "最后一个能进入电梯的人") 🔒 | [MySQL](problems/last-person-to-fit-in-the-elevator) | Medium | -| 1203 | [Sort Items by Groups Respecting Dependencies](https://leetcode.com/problems/sort-items-by-groups-respecting-dependencies "项目管理") | [Go](problems/sort-items-by-groups-respecting-dependencies) | Hard | -| 1202 | [Smallest String With Swaps](https://leetcode.com/problems/smallest-string-with-swaps "交换字符串中的元素") | [Go](problems/smallest-string-with-swaps) | Medium | -| 1201 | [Ugly Number III](https://leetcode.com/problems/ugly-number-iii "丑数 III") | [Go](problems/ugly-number-iii) | Medium | diff --git a/problems/accounts-merge/README.md b/problems/accounts-merge/README.md index 90de80088..4d02996c1 100644 --- a/problems/accounts-merge/README.md +++ b/problems/accounts-merge/README.md @@ -11,30 +11,42 @@ ## [721. Accounts Merge (Medium)](https://leetcode.com/problems/accounts-merge "账户合并") -

    Given a list accounts, each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails representing emails of the account.

    +

    Given a list of accounts where each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails representing emails of the account.

    -

    Now, we would like to merge these accounts. Two accounts definitely belong to the same person if there is some email that is common to both accounts. Note that even if two accounts have the same name, they may belong to different people as people could have the same name. A person can have any number of accounts initially, but all of their accounts definitely have the same name.

    +

    Now, we would like to merge these accounts. Two accounts definitely belong to the same person if there is some common email to both accounts. Note that even if two accounts have the same name, they may belong to different people as people could have the same name. A person can have any number of accounts initially, but all of their accounts definitely have the same name.

    -

    After merging the accounts, return the accounts in the following format: the first element of each account is the name, and the rest of the elements are emails in sorted order. The accounts themselves can be returned in any order.

    +

    After merging the accounts, return the accounts in the following format: the first element of each account is the name, and the rest of the elements are emails in sorted order. The accounts themselves can be returned in any order.

    -

    Example 1:
    -

    -Input: 
    -accounts = [["John", "johnsmith@mail.com", "john00@mail.com"], ["John", "johnnybravo@mail.com"], ["John", "johnsmith@mail.com", "john_newyork@mail.com"], ["Mary", "mary@mail.com"]]
    -Output: [["John", 'john00@mail.com', 'john_newyork@mail.com', 'johnsmith@mail.com'],  ["John", "johnnybravo@mail.com"], ["Mary", "mary@mail.com"]]
    -Explanation: 
    -The first and third John's are the same person as they have the common email "johnsmith@mail.com".
    +

     

    +

    Example 1:

    + +
    +Input: accounts = [["John","johnsmith@mail.com","john_newyork@mail.com"],["John","johnsmith@mail.com","john00@mail.com"],["Mary","mary@mail.com"],["John","johnnybravo@mail.com"]]
    +Output: [["John","john00@mail.com","john_newyork@mail.com","johnsmith@mail.com"],["Mary","mary@mail.com"],["John","johnnybravo@mail.com"]]
    +Explanation:
    +The first and third John's are the same person as they have the common email "johnsmith@mail.com".
     The second John and Mary are different people as none of their email addresses are used by other accounts.
    -We could return these lists in any order, for example the answer [['Mary', 'mary@mail.com'], ['John', 'johnnybravo@mail.com'], 
    -['John', 'john00@mail.com', 'john_newyork@mail.com', 'johnsmith@mail.com']] would still be accepted.
    +We could return these lists in any order, for example the answer [['Mary', 'mary@mail.com'], ['John', 'johnnybravo@mail.com'], 
    +['John', 'john00@mail.com', 'john_newyork@mail.com', 'johnsmith@mail.com']] would still be accepted.
     
    -

    -

    Note: -

  • The length of accounts will be in the range [1, 1000].
  • -
  • The length of accounts[i] will be in the range [1, 10].
  • -
  • The length of accounts[i][j] will be in the range [1, 30].
  • -

    +

    Example 2:

    + +
    +Input: accounts = [["Gabe","Gabe0@m.co","Gabe3@m.co","Gabe1@m.co"],["Kevin","Kevin3@m.co","Kevin5@m.co","Kevin0@m.co"],["Ethan","Ethan5@m.co","Ethan4@m.co","Ethan0@m.co"],["Hanzo","Hanzo3@m.co","Hanzo1@m.co","Hanzo0@m.co"],["Fern","Fern5@m.co","Fern1@m.co","Fern0@m.co"]]
    +Output: [["Ethan","Ethan0@m.co","Ethan4@m.co","Ethan5@m.co"],["Gabe","Gabe0@m.co","Gabe1@m.co","Gabe3@m.co"],["Hanzo","Hanzo0@m.co","Hanzo1@m.co","Hanzo3@m.co"],["Kevin","Kevin0@m.co","Kevin3@m.co","Kevin5@m.co"],["Fern","Fern0@m.co","Fern1@m.co","Fern5@m.co"]]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= accounts.length <= 1000
    • +
    • 2 <= accounts[i].length <= 10
    • +
    • 1 <= accounts[i][j] <= 30
    • +
    • accounts[i][0] consists of English letters.
    • +
    • accounts[i][j] (for j > 0) is a valid email.
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/add-digits/README.md b/problems/add-digits/README.md index e9f8c53bd..e97ef4737 100644 --- a/problems/add-digits/README.md +++ b/problems/add-digits/README.md @@ -11,19 +11,36 @@ ## [258. Add Digits (Easy)](https://leetcode.com/problems/add-digits "各位相加") -

    Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.

    +

    Given an integer num, repeatedly add all its digits until the result has only one digit, and return it.

    -

    Example:

    +

     

    +

    Example 1:

    -Input: 38
    -Output: 2 
    -Explanation: The process is like: 3 + 8 = 11, 1 + 1 = 2. 
    -             Since 2 has only one digit, return it.
    +Input: num = 38
    +Output: 2
    +Explanation: The process is
    +38 --> 3 + 8 --> 11
    +11 --> 1 + 1 --> 2 
    +Since 2 has only one digit, return it.
     
    -

    Follow up:
    -Could you do it without any loop/recursion in O(1) runtime?

    +

    Example 2:

    + +
    +Input: num = 0
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= num <= 231 - 1
    • +
    + +

     

    +

    Follow up: Could you do it without any loop/recursion in O(1) runtime?

    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/add-one-row-to-tree/README.md b/problems/add-one-row-to-tree/README.md index 6f5c67cbf..b0ef4d18a 100644 --- a/problems/add-one-row-to-tree/README.md +++ b/problems/add-one-row-to-tree/README.md @@ -11,68 +11,44 @@ ## [623. Add One Row to Tree (Medium)](https://leetcode.com/problems/add-one-row-to-tree "在二叉树中增加一行") -

    Given the root of a binary tree, then value v and depth d, you need to add a row of nodes with value v at the given depth d. The root node is at depth 1.

    +

    Given the root of a binary tree and two integers val and depth, add a row of nodes with value val at the given depth depth.

    -

    The adding rule is: given a positive integer depth d, for each NOT null tree nodes N in depth d-1, create two tree nodes with value v as N's left subtree root and right subtree root. And N's original left subtree should be the left subtree of the new left subtree root, its original right subtree should be the right subtree of the new right subtree root. If depth d is 1 that means there is no depth d-1 at all, then create a tree node with value v as the new root of the whole original tree, and the original tree is the new root's left subtree.

    +

    Note that the root node is at depth 1.

    -

    Example 1:
    -

    -Input: 
    -A binary tree as following:
    -       4
    -     /   \
    -    2     6
    -   / \   / 
    -  3   1 5   
    -
    -v = 1
    -
    -d = 2
    +

    The adding rule is:

    -Output: - 4 - / \ - 1 1 - / \ - 2 6 - / \ / - 3 1 5 +
      +
    • Given the integer depth, for each not null tree node cur at the depth depth - 1, create two tree nodes with value val as cur's left subtree root and right subtree root.
    • +
    • cur's original left subtree should be the left subtree of the new left subtree root.
    • +
    • cur's original right subtree should be the right subtree of the new right subtree root.
    • +
    • If depth == 1 that means there is no depth depth - 1 at all, then create a tree node with value val as the new root of the whole original tree, and the original tree is the new root's left subtree.
    • +
    +

     

    +

    Example 1:

    + +
    +Input: root = [4,2,6,3,1,5], val = 1, depth = 2
    +Output: [4,1,1,2,null,null,6,3,1,5]
     
    -

    - -

    Example 2:
    +

    Example 2:

    +
    -Input: 
    -A binary tree as following:
    -      4
    -     /   
    -    2    
    -   / \   
    -  3   1    
    -
    -v = 1
    -
    -d = 3
    -
    -Output: 
    -      4
    -     /   
    -    2
    -   / \    
    -  1   1
    - /     \  
    -3       1
    +Input: root = [4,2,null,3,1], val = 1, depth = 3
    +Output: [4,2,null,1,1,3,null,null,1]
     
    -

    -

    Note:
    -

      -
    1. The given d is in range [1, maximum depth of the given tree + 1].
    2. -
    3. The given binary tree has at least one tree node.
    4. -
    -

    +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [1, 104].
    • +
    • The depth of the tree is in the range [1, 104].
    • +
    • -100 <= Node.val <= 100
    • +
    • -105 <= val <= 105
    • +
    • 1 <= depth <= the depth of tree + 1
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md b/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md index 858166250..cbd299585 100644 --- a/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md +++ b/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md @@ -42,8 +42,9 @@ The total profit is ((8 - 1) - 2) + ((9 - 4) - 2) = 8.

    Constraints:

      -
    • 1 < prices.length <= 5 * 104
    • -
    • 0 < prices[i], fee < 5 * 104
    • +
    • 1 <= prices.length <= 5 * 104
    • +
    • 1 <= prices[i] < 5 * 104
    • +
    • 0 <= fee < 5 * 104
    ### Related Topics diff --git a/problems/binary-tree-paths/README.md b/problems/binary-tree-paths/README.md index 236c890f6..83f4c5226 100644 --- a/problems/binary-tree-paths/README.md +++ b/problems/binary-tree-paths/README.md @@ -11,26 +11,33 @@ ## [257. Binary Tree Paths (Easy)](https://leetcode.com/problems/binary-tree-paths "二叉树的所有路径") -

    Given a binary tree, return all root-to-leaf paths.

    +

    Given the root of a binary tree, return all root-to-leaf paths in any order.

    -

    Note: A leaf is a node with no children.

    - -

    Example:

    +

    A leaf is a node with no children.

    +

     

    +

    Example 1:

    +
    -Input:
    -
    -   1
    - /   \
    -2     3
    - \
    -  5
    +Input: root = [1,2,3,null,5]
    +Output: ["1->2->5","1->3"]
    +
    -Output: ["1->2->5", "1->3"] +

    Example 2:

    -Explanation: All root-to-leaf paths are: 1->2->5, 1->3 +
    +Input: root = [1]
    +Output: ["1"]
     
    +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [1, 100].
    • +
    • -100 <= Node.val <= 100
    • +
    + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/binary-trees-with-factors/README.md b/problems/binary-trees-with-factors/README.md index 4a650658d..48ecd79c9 100644 --- a/problems/binary-trees-with-factors/README.md +++ b/problems/binary-trees-with-factors/README.md @@ -38,4 +38,5 @@
    • 1 <= arr.length <= 1000
    • 2 <= arr[i] <= 109
    • +
    • All the values of arr are unique.
    diff --git a/problems/cells-with-odd-values-in-a-matrix/README.md b/problems/cells-with-odd-values-in-a-matrix/README.md index 6c2beb96f..fa60d5807 100644 --- a/problems/cells-with-odd-values-in-a-matrix/README.md +++ b/problems/cells-with-odd-values-in-a-matrix/README.md @@ -11,40 +11,49 @@ ## [1252. Cells with Odd Values in a Matrix (Easy)](https://leetcode.com/problems/cells-with-odd-values-in-a-matrix "奇数值单元格的数目") -

    Given n and m which are the dimensions of a matrix initialized by zeros and given an array indices where indices[i] = [ri, ci]. For each pair of [ri, ci] you have to increment all cells in row ri and column ci by 1.

    +

    There is an m x n matrix that is initialized to all 0's. There is also a 2D array indices where each indices[i] = [ri, ci] represents a 0-indexed location to perform some increment operations on the matrix.

    -

    Return the number of cells with odd values in the matrix after applying the increment to all indices.

    +

    For each location indices[i], do both of the following:

    + +
      +
    1. Increment all the cells on row ri.
    2. +
    3. Increment all the cells on column ci.
    4. +
    + +

    Given m, n, and indices, return the number of odd-valued cells in the matrix after applying the increment to all locations in indices.

     

    Example 1:

    -Input: n = 2, m = 3, indices = [[0,1],[1,1]]
    +Input: m = 2, n = 3, indices = [[0,1],[1,1]]
     Output: 6
     Explanation: Initial matrix = [[0,0,0],[0,0,0]].
     After applying first increment it becomes [[1,2,1],[0,1,0]].
    -The final matrix will be [[1,3,1],[1,3,1]] which contains 6 odd numbers.
    +The final matrix is [[1,3,1],[1,3,1]], which contains 6 odd numbers.
     

    Example 2:

    -Input: n = 2, m = 2, indices = [[1,1],[0,0]]
    +Input: m = 2, n = 2, indices = [[1,1],[0,0]]
     Output: 0
    -Explanation: Final matrix = [[2,2],[2,2]]. There is no odd number in the final matrix.
    +Explanation: Final matrix = [[2,2],[2,2]]. There are no odd numbers in the final matrix.
     

     

    Constraints:

      -
    • 1 <= n <= 50
    • -
    • 1 <= m <= 50
    • +
    • 1 <= m, n <= 50
    • 1 <= indices.length <= 100
    • -
    • 0 <= indices[i][0] < n
    • -
    • 0 <= indices[i][1] < m
    • +
    • 0 <= ri < m
    • +
    • 0 <= ci < n
    +

     

    +

    Follow up: Could you solve this in O(n + m + indices.length) time with only O(n + m) extra space?

    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md b/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md index ccb31ff31..243ca260e 100644 --- a/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md +++ b/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md @@ -13,7 +13,7 @@

    Given a binary string s and an integer k.

    -

    Return True if every binary code of length k is a substring of s. Otherwise, return False.

    +

    Return true if every binary code of length k is a substring of s. Otherwise, return false.

     

    Example 1:

    @@ -58,8 +58,8 @@

    Constraints:

      -
    • 1 <= s.length <= 5 * 10^5
    • -
    • s consists of 0's and 1's only.
    • +
    • 1 <= s.length <= 5 * 105
    • +
    • s[i] is either '0' or '1'.
    • 1 <= k <= 20
    diff --git a/problems/check-if-one-string-swap-can-make-strings-equal/README.md b/problems/check-if-one-string-swap-can-make-strings-equal/README.md new file mode 100644 index 000000000..128fee8f7 --- /dev/null +++ b/problems/check-if-one-string-swap-can-make-strings-equal/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../primary-department-for-each-employee "Primary Department for Each Employee") +                 +[Next >](../find-center-of-star-graph "Find Center of Star Graph") + +## [1790. Check if One String Swap Can Make Strings Equal (Easy)](https://leetcode.com/problems/check-if-one-string-swap-can-make-strings-equal "仅执行一次字符串交换能否使两个字符串相等") + +

    You are given two strings s1 and s2 of equal length. A string swap is an operation where you choose two indices in a string (not necessarily different) and swap the characters at these indices.

    + +

    Return true if it is possible to make both strings equal by performing at most one string swap on exactly one of the strings. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: s1 = "bank", s2 = "kanb"
    +Output: true
    +Explanation: For example, swap the first character with the last character of s2 to make "bank".
    +
    + +

    Example 2:

    + +
    +Input: s1 = "attack", s2 = "defend"
    +Output: false
    +Explanation: It is impossible to make them equal with one string swap.
    +
    + +

    Example 3:

    + +
    +Input: s1 = "kelb", s2 = "kelb"
    +Output: true
    +Explanation: The two strings are already equal, so no string swap operation is required.
    +
    + +

    Example 4:

    + +
    +Input: s1 = "abcd", s2 = "dcba"
    +Output: false
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s1.length, s2.length <= 100
    • +
    • s1.length == s2.length
    • +
    • s1 and s2 consist of only lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +The answer is false if the number of nonequal positions in the strings is not equal to 0 or 2. +
    + +
    +Hint 2 +Check that these positions have the same set of characters. +
    diff --git a/problems/coin-change/README.md b/problems/coin-change/README.md index ff84c7591..689e7a96e 100644 --- a/problems/coin-change/README.md +++ b/problems/coin-change/README.md @@ -11,7 +11,9 @@ ## [322. Coin Change (Medium)](https://leetcode.com/problems/coin-change "零钱兑换") -

    You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.

    +

    You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.

    + +

    Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.

    You may assume that you have an infinite number of each kind of coin.

    diff --git a/problems/combination-sum-iv/README.md b/problems/combination-sum-iv/README.md index 5b6a981df..6931fa619 100644 --- a/problems/combination-sum-iv/README.md +++ b/problems/combination-sum-iv/README.md @@ -11,14 +11,17 @@ ## [377. Combination Sum IV (Medium)](https://leetcode.com/problems/combination-sum-iv "组合总和 Ⅳ") -

    Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.

    +

    Given an array of distinct integers nums and a target integer target, return the number of possible combinations that add up to target.

    -

    Example:

    +

    The answer is guaranteed to fit in a 32-bit integer.

    -
    -nums = [1, 2, 3]
    -target = 4
    +

     

    +

    Example 1:

    +
    +Input: nums = [1,2,3], target = 4
    +Output: 7
    +Explanation:
     The possible combination ways are:
     (1, 1, 1, 1)
     (1, 1, 2)
    @@ -27,21 +30,28 @@ The possible combination ways are:
     (2, 1, 1)
     (2, 2)
     (3, 1)
    -
     Note that different sequences are counted as different combinations.
    +
    + +

    Example 2:

    -Therefore the output is 7. +
    +Input: nums = [9], target = 3
    +Output: 0
     

     

    +

    Constraints:

    -

    Follow up:
    -What if negative numbers are allowed in the given array?
    -How does it change the problem?
    -What limitation we need to add to the question to allow negative numbers?

    +
      +
    • 1 <= nums.length <= 200
    • +
    • 1 <= nums[i] <= 1000
    • +
    • All the elements of nums are unique.
    • +
    • 1 <= target <= 1000
    • +
    -

    Credits:
    -Special thanks to @pbrother for adding this problem and creating all test cases.

    +

     

    +

    Follow up: What if negative numbers are allowed in the given array? How does it change the problem? What limitation we need to add to the question to allow negative numbers?

    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md b/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md index e4383d3bb..79443f274 100644 --- a/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md +++ b/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md @@ -25,7 +25,7 @@
     Input: inorder = [-1], postorder = [-1]
    -Output: []
    +Output: [-1]
     

     

    diff --git a/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md b/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md new file mode 100644 index 000000000..5b5b4c518 --- /dev/null +++ b/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md @@ -0,0 +1,29 @@ + + + + + + + +[< Previous](../maximum-score-of-a-good-subarray "Maximum Score of a Good Subarray") +                 +[Next >](../rearrange-products-table "Rearrange Products Table") + +## [1794. Count Pairs of Equal Substrings With Minimum Difference (Medium)](https://leetcode.com/problems/count-pairs-of-equal-substrings-with-minimum-difference "") + + + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +If the chosen substrings are of size larger than 1, then you can remove all but the first character from both substrings, and you'll get equal substrings of size 1, with the same a but less j. Hence, it's always optimal to choose substrings of size 1. +
    + +
    +Hint 2 +If you choose a specific letter, then it's optimal to choose its first occurrence in firstString, and its last occurrence in secondString, to minimize j-a. +
    diff --git a/problems/count-pairs-with-xor-in-a-range/README.md b/problems/count-pairs-with-xor-in-a-range/README.md new file mode 100644 index 000000000..fa4fe3c9e --- /dev/null +++ b/problems/count-pairs-with-xor-in-a-range/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../maximum-value-at-a-given-index-in-a-bounded-array "Maximum Value at a Given Index in a Bounded Array") +                 +Next > + +## [1803. Count Pairs With XOR in a Range (Hard)](https://leetcode.com/problems/count-pairs-with-xor-in-a-range "统计异或值在范围内的数对有多少") + +

    Given a (0-indexed) integer array nums and two integers low and high, return the number of nice pairs.

    + +

    A nice pair is a pair (i, j) where 0 <= i < j < nums.length and low <= (nums[i] XOR nums[j]) <= high.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,4,2,7], low = 2, high = 6
    +Output: 6
    +Explanation: All nice pairs (i, j) are as follows:
    +    - (0, 1): nums[0] XOR nums[1] = 5 
    +    - (0, 2): nums[0] XOR nums[2] = 3
    +    - (0, 3): nums[0] XOR nums[3] = 6
    +    - (1, 2): nums[1] XOR nums[2] = 6
    +    - (1, 3): nums[1] XOR nums[3] = 3
    +    - (2, 3): nums[2] XOR nums[3] = 5
    +
    + +

    Example 2:

    + +
    +Input: nums = [9,8,4,2,1], low = 5, high = 14
    +Output: 8
    +Explanation: All nice pairs (i, j) are as follows:
    +​​​​​    - (0, 2): nums[0] XOR nums[2] = 13
    +    - (0, 3): nums[0] XOR nums[3] = 11
    +    - (0, 4): nums[0] XOR nums[4] = 8
    +    - (1, 2): nums[1] XOR nums[2] = 12
    +    - (1, 3): nums[1] XOR nums[3] = 10
    +    - (1, 4): nums[1] XOR nums[4] = 9
    +    - (2, 3): nums[2] XOR nums[3] = 6
    +    - (2, 4): nums[2] XOR nums[4] = 5
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 2 * 104
    • +
    • 1 <= nums[i] <= 2 * 104
    • +
    • 1 <= low <= high <= 2 * 104
    • +
    + +### Related Topics + [[Trie](../../tag/trie/README.md)] + +### Hints +
    +Hint 1 +Let's note that we can count all pairs with XOR ≤ K, so the answer would be to subtract the number of pairs with XOR ≤ high from the number of pairs withs XOR < low. +
    + +
    +Hint 2 +For each value, find out the number of values when you XOR it with the result is ≤ K using a trie. +
    diff --git a/problems/create-maximum-number/README.md b/problems/create-maximum-number/README.md index 56b92324f..426415cac 100644 --- a/problems/create-maximum-number/README.md +++ b/problems/create-maximum-number/README.md @@ -11,41 +11,48 @@ ## [321. Create Maximum Number (Hard)](https://leetcode.com/problems/create-maximum-number "拼接最大数") -

    Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. The relative order of the digits from the same array must be preserved. Return an array of the k digits.

    +

    You are given two integer arrays nums1 and nums2 of lengths m and n respectively. nums1 and nums2 represent the digits of two numbers. You are also given an integer k.

    -

    Note: You should try to optimize your time and space complexity.

    +

    Create the maximum number of length k <= m + n from digits of the two numbers. The relative order of the digits from the same array must be preserved.

    -

    Example 1:

    +

    Return an array of the k digits representing the answer.

    + +

     

    +

    Example 1:

    -Input:
    -nums1 = [3, 4, 6, 5]
    -nums2 = [9, 1, 2, 5, 8, 3]
    -k = 5
    -Output:
    -[9, 8, 6, 5, 3]
    +Input: nums1 = [3,4,6,5], nums2 = [9,1,2,5,8,3], k = 5 +Output: [9,8,6,5,3] +
    -

    Example 2:

    +

    Example 2:

    -Input:
    -nums1 = [6, 7]
    -nums2 = [6, 0, 4]
    -k = 5
    -Output:
    -[6, 7, 6, 0, 4]
    +Input: nums1 = [6,7], nums2 = [6,0,4], k = 5 +Output: [6,7,6,0,4] +
    -

    Example 3:

    +

    Example 3:

    -Input:
    -nums1 = [3, 9]
    -nums2 = [8, 9]
    -k = 3
    -Output:
    -[9, 8, 9]
    +Input: nums1 = [3,9], nums2 = [8,9], k = 3
    +Output: [9,8,9]
     
    +

     

    +

    Constraints:

    + +
      +
    • m == nums1.length
    • +
    • n == nums2.length
    • +
    • 1 <= m, n <= 500
    • +
    • 0 <= nums1[i], nums2[i] <= 9
    • +
    • 1 <= k <= m + n
    • +
    + +

     

    +

    Follow up: Try to optimize your time and space complexity.

    + ### Related Topics [[Greedy](../../tag/greedy/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/design-authentication-manager/README.md b/problems/design-authentication-manager/README.md new file mode 100644 index 000000000..8bf9e9234 --- /dev/null +++ b/problems/design-authentication-manager/README.md @@ -0,0 +1,84 @@ + + + + + + + +[< Previous](../second-largest-digit-in-a-string "Second Largest Digit in a String") +                 +[Next >](../maximum-number-of-consecutive-values-you-can-make "Maximum Number of Consecutive Values You Can Make") + +## [1797. Design Authentication Manager (Medium)](https://leetcode.com/problems/design-authentication-manager "设计一个验证系统") + +

    There is an authentication system that works with authentication tokens. For each session, the user will receive a new authentication token that will expire timeToLive seconds after the currentTime. If the token is renewed, the expiry time will be extended to expire timeToLive seconds after the (potentially different) currentTime.

    + +

    Implement the AuthenticationManager class:

    + +
      +
    • AuthenticationManager(int timeToLive) constructs the AuthenticationManager and sets the timeToLive.
    • +
    • generate(string tokenId, int currentTime) generates a new token with the given tokenId at the given currentTime in seconds.
    • +
    • renew(string tokenId, int currentTime) renews the unexpired token with the given tokenId at the given currentTime in seconds. If there are no unexpired tokens with the given tokenId, the request is ignored, and nothing happens.
    • +
    • countUnexpiredTokens(int currentTime) returns the number of unexpired tokens at the given currentTime.
    • +
    + +

    Note that if a token expires at time t, and another action happens on time t (renew or countUnexpiredTokens), the expiration takes place before the other actions.

    + +

     

    +

    Example 1:

    + +
    +Input
    +["AuthenticationManager", "renew", "generate", "countUnexpiredTokens", "generate", "renew", "renew", "countUnexpiredTokens"]
    +[[5], ["aaa", 1], ["aaa", 2], [6], ["bbb", 7], ["aaa", 8], ["bbb", 10], [15]]
    +Output
    +[null, null, null, 1, null, null, null, 0]
    +
    +Explanation
    +AuthenticationManager authenticationManager = new AuthenticationManager(5); // Constructs the AuthenticationManager with timeToLive = 5 seconds.
    +authenticationManager.renew("aaa", 1); // No token exists with tokenId "aaa" at time 1, so nothing happens.
    +authenticationManager.generate("aaa", 2); // Generates a new token with tokenId "aaa" at time 2.
    +authenticationManager.countUnexpiredTokens(6); // The token with tokenId "aaa" is the only unexpired one at time 6, so return 1.
    +authenticationManager.generate("bbb", 7); // Generates a new token with tokenId "bbb" at time 7.
    +authenticationManager.renew("aaa", 8); // The token with tokenId "aaa" expired at time 7, and 8 >= 7, so at time 8 the renew request is ignored, and nothing happens.
    +authenticationManager.renew("bbb", 10); // The token with tokenId "bbb" is unexpired at time 10, so the renew request is fulfilled and now the token will expire at time 15.
    +authenticationManager.countUnexpiredTokens(15); // The token with tokenId "bbb" expires at time 15, and the token with tokenId "aaa" expired at time 7, so currently no token is unexpired, so return 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= timeToLive <= 108
    • +
    • 1 <= currentTime <= 108
    • +
    • 1 <= tokenId.length <= 5
    • +
    • tokenId consists only of lowercase letters.
    • +
    • All calls to generate will contain unique values of tokenId.
    • +
    • The values of currentTime across all the function calls will be strictly increasing.
    • +
    • At most 2000 calls will be made to all functions combined.
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +Using a map, track the expiry times of the tokens. +
    + +
    +Hint 2 +When generating a new token, add it to the map with its expiry time. +
    + +
    +Hint 3 +When renewing a token, check if it's on the map and has not expired yet. If so, update its expiry time. +
    + +
    +Hint 4 +To count unexpired tokens, iterate on the map and check for each token if it's not expired yet. +
    diff --git a/problems/different-ways-to-add-parentheses/README.md b/problems/different-ways-to-add-parentheses/README.md index 270723339..2a66d7389 100644 --- a/problems/different-ways-to-add-parentheses/README.md +++ b/problems/different-ways-to-add-parentheses/README.md @@ -11,29 +11,39 @@ ## [241. Different Ways to Add Parentheses (Medium)](https://leetcode.com/problems/different-ways-to-add-parentheses "为运算表达式设计优先级") -

    Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *.

    +

    Given a string expression of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. You may return the answer in any order.

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input: "2-1-1"
    -Output: [0, 2]
    -Explanation: 
    +Input: expression = "2-1-1"
    +Output: [0,2]
    +Explanation:
     ((2-1)-1) = 0 
    -(2-(1-1)) = 2
    +(2-(1-1)) = 2 +
    -

    Example 2:

    +

    Example 2:

    -Input: "2*3-4*5"
    -Output: [-34, -14, -10, -10, 10]
    -Explanation: 
    -(2*(3-(4*5))) = -34 
    +Input: expression = "2*3-4*5"
    +Output: [-34,-14,-10,-10,10]
    +Explanation:
    +(2*(3-(4*5))) = -34 
     ((2*3)-(4*5)) = -14 
     ((2*(3-4))*5) = -10 
     (2*((3-4)*5)) = -10 
    -(((2*3)-4)*5) = 10
    -
    +(((2*3)-4)*5) = 10 + + +

     

    +

    Constraints:

    + +
      +
    • 1 <= expression.length <= 20
    • +
    • expression consists of digits and the operator '+', '-', and '*'.
    • +
    ### Related Topics [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] diff --git a/problems/dungeon-game/README.md b/problems/dungeon-game/README.md index 24582265b..59f3657da 100644 --- a/problems/dungeon-game/README.md +++ b/problems/dungeon-game/README.md @@ -11,47 +11,42 @@ ## [174. Dungeon Game (Hard)](https://leetcode.com/problems/dungeon-game "地下城游戏") -

    The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially positioned in the top-left room and must fight his way through the dungeon to rescue the princess.

    +

    The demons had captured the princess and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of m x n rooms laid out in a 2D grid. Our valiant knight was initially positioned in the top-left room and must fight his way through dungeon to rescue the princess.

    -

    The knight has an initial health point represented by a positive integer. If at any point his health point drops to 0 or below, he dies immediately.

    +

    The knight has an initial health point represented by a positive integer. If at any point his health point drops to 0 or below, he dies immediately.

    -

    Some of the rooms are guarded by demons, so the knight loses health (negative integers) upon entering these rooms; other rooms are either empty (0's) or contain magic orbs that increase the knight's health (positive integers).

    +

    Some of the rooms are guarded by demons (represented by negative integers), so the knight loses health upon entering these rooms; other rooms are either empty (represented as 0) or contain magic orbs that increase the knight's health (represented by positive integers).

    -

    In order to reach the princess as quickly as possible, the knight decides to move only rightward or downward in each step.

    +

    To reach the princess as quickly as possible, the knight decides to move only rightward or downward in each step.

    -

     

    +

    Return the knight's minimum initial health so that he can rescue the princess.

    + +

    Note that any room can contain threats or power-ups, even the first room the knight enters and the bottom-right room where the princess is imprisoned.

    -

    Write a function to determine the knight's minimum initial health so that he is able to rescue the princess.

    +

     

    +

    Example 1:

    + +
    +Input: dungeon = [[-2,-3,3],[-5,-10,1],[10,30,-5]]
    +Output: 7
    +Explanation: The initial health of the knight must be at least 7 if he follows the optimal path: RIGHT-> RIGHT -> DOWN -> DOWN.
    +
    -

    For example, given the dungeon below, the initial health of the knight must be at least 7 if he follows the optimal path RIGHT-> RIGHT -> DOWN -> DOWN.

    +

    Example 2:

    - - - - - - - - - - - - - - - - - - -
    -2 (K)-33
    -5-101
    1030-5 (P)
    +
    +Input: dungeon = [[0]]
    +Output: 1
    +

     

    - -

    Note:

    +

    Constraints:

      -
    • The knight's health has no upper bound.
    • -
    • Any room can contain threats or power-ups, even the first room the knight enters and the bottom-right room where the princess is imprisoned.
    • +
    • m == dungeon.length
    • +
    • n == dungeon[i].length
    • +
    • 1 <= m, n <= 200
    • +
    • -1000 <= dungeon[i][j] <= 1000
    ### Related Topics diff --git a/problems/expression-add-operators/README.md b/problems/expression-add-operators/README.md index 67e43041c..8a93fea11 100644 --- a/problems/expression-add-operators/README.md +++ b/problems/expression-add-operators/README.md @@ -11,47 +11,32 @@ ## [282. Expression Add Operators (Hard)](https://leetcode.com/problems/expression-add-operators "给表达式添加运算符") -

    Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the digits so they evaluate to the target value.

    +

    Given a string num that contains only digits and an integer target, return all possibilities to add the binary operators '+', '-', or '*' between the digits of num so that the resultant expression evaluates to the target value.

    -

    Example 1:

    - -
    -Input: num = "123", target = 6
    -Output: ["1+2+3", "1*2*3"] 
    -
    - -

    Example 2:

    - -
    -Input: num = "232", target = 8
    -Output: ["2*3+2", "2+3*2"]
    - -

    Example 3:

    - -
    -Input: num = "105", target = 5
    -Output: ["1*0+5","10-5"]
    - -

    Example 4:

    - -
    -Input: num = "00", target = 0
    -Output: ["0+0", "0-0", "0*0"]
    -
    - -

    Example 5:

    - -
    -Input: num = "3456237490", target = 9191
    -Output: []
    +

     

    +

    Example 1:

    +
    Input: num = "123", target = 6
    +Output: ["1*2*3","1+2+3"]
    +

    Example 2:

    +
    Input: num = "232", target = 8
    +Output: ["2*3+2","2+3*2"]
    +

    Example 3:

    +
    Input: num = "105", target = 5
    +Output: ["1*0+5","10-5"]
    +

    Example 4:

    +
    Input: num = "00", target = 0
    +Output: ["0*0","0+0","0-0"]
    +

    Example 5:

    +
    Input: num = "3456237490", target = 9191
    +Output: []
     
    -

     

    Constraints:

      -
    • 0 <= num.length <= 10
    • -
    • num only contain digits.
    • +
    • 1 <= num.length <= 10
    • +
    • num consists of only digits.
    • +
    • -231 <= target <= 231 - 1
    ### Related Topics diff --git a/problems/find-center-of-star-graph/README.md b/problems/find-center-of-star-graph/README.md new file mode 100644 index 000000000..5a95710f0 --- /dev/null +++ b/problems/find-center-of-star-graph/README.md @@ -0,0 +1,63 @@ + + + + + + + +[< Previous](../check-if-one-string-swap-can-make-strings-equal "Check if One String Swap Can Make Strings Equal") +                 +[Next >](../maximum-average-pass-ratio "Maximum Average Pass Ratio") + +## [1791. Find Center of Star Graph (Medium)](https://leetcode.com/problems/find-center-of-star-graph "找出星型图的中心节点") + +

    There is an undirected star graph consisting of n nodes labeled from 1 to n. A star graph is a graph where there is one center node and exactly n - 1 edges that connect the center node with every other node.

    + +

    You are given a 2D integer array edges where each edges[i] = [ui, vi] indicates that there is an edge between the nodes ui and vi. Return the center of the given star graph.

    + +

     

    +

    Example 1:

    + +
    +Input: edges = [[1,2],[2,3],[4,2]]
    +Output: 2
    +Explanation: As shown in the figure above, node 2 is connected to every other node, so 2 is the center.
    +
    + +

    Example 2:

    + +
    +Input: edges = [[1,2],[5,1],[1,3],[1,4]]
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= n <= 105
    • +
    • edges.length == n - 1
    • +
    • edges[i].length == 2
    • +
    • 1 <= ui, vi <= n
    • +
    • ui != vi
    • +
    • The given edges represent a valid star graph.
    • +
    + +### Related Topics + [[Graph](../../tag/graph/README.md)] + +### Hints +
    +Hint 1 +The center is the only node that has more than one edge. +
    + +
    +Hint 2 +The center is also connected to all other nodes. +
    + +
    +Hint 3 +Any two edges must have a common node, which is the center. +
    diff --git a/problems/find-median-from-data-stream/README.md b/problems/find-median-from-data-stream/README.md index 3416a3a92..d6c753979 100644 --- a/problems/find-median-from-data-stream/README.md +++ b/problems/find-median-from-data-stream/README.md @@ -11,40 +11,56 @@ ## [295. Find Median from Data Stream (Hard)](https://leetcode.com/problems/find-median-from-data-stream "数据流的中位数") -

    Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.

    -For example, +

    The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value and the median is the mean of the two middle values.

    -

    [2,3,4], the median is 3

    - -

    [2,3], the median is (2 + 3) / 2 = 2.5

    +
      +
    • For example, for arr = [2,3,4], the median is 3.
    • +
    • For example, for arr = [2,3], the median is (2 + 3) / 2 = 2.5.
    • +
    -

    Design a data structure that supports the following two operations:

    +

    Implement the MedianFinder class:

      -
    • void addNum(int num) - Add a integer number from the data stream to the data structure.
    • -
    • double findMedian() - Return the median of all elements so far.
    • +
    • MedianFinder() initializes the MedianFinder object.
    • +
    • void addNum(int num) adds the integer num from the data stream to the data structure.
    • +
    • double findMedian() returns the median of all elements so far. Answers within 10-5 of the actual answer will be accepted.

     

    - -

    Example:

    +

    Example 1:

    -addNum(1)
    -addNum(2)
    -findMedian() -> 1.5
    -addNum(3) 
    -findMedian() -> 2
    +Input
    +["MedianFinder", "addNum", "addNum", "findMedian", "addNum", "findMedian"]
    +[[], [1], [2], [], [3], []]
    +Output
    +[null, null, null, 1.5, null, 2.0]
    +
    +Explanation
    +MedianFinder medianFinder = new MedianFinder();
    +medianFinder.addNum(1);    // arr = [1]
    +medianFinder.addNum(2);    // arr = [1, 2]
    +medianFinder.findMedian(); // return 1.5 (i.e., (1 + 2) / 2)
    +medianFinder.addNum(3);    // arr[1, 2, 3]
    +medianFinder.findMedian(); // return 2.0
     

     

    +

    Constraints:

    +
      +
    • -105 <= num <= 105
    • +
    • There will be at least one element in the data structure before calling findMedian.
    • +
    • At most 5 * 104 calls will be made to addNum and findMedian.
    • +
    + +

     

    Follow up:

    -
      -
    1. If all integer numbers from the stream are between 0 and 100, how would you optimize it?
    2. -
    3. If 99% of all integer numbers from the stream are between 0 and 100, how would you optimize it?
    4. -
    +
      +
    • If all integer numbers from the stream are in the range [0, 100], how would you optimize your solution?
    • +
    • If 99% of all integer numbers from the stream are in the range [0, 100], how would you optimize your solution?
    • +
    ### Related Topics [[Heap](../../tag/heap/README.md)] diff --git a/problems/find-mode-in-binary-search-tree/README.md b/problems/find-mode-in-binary-search-tree/README.md index 3c86f61c1..ca3e6d056 100644 --- a/problems/find-mode-in-binary-search-tree/README.md +++ b/problems/find-mode-in-binary-search-tree/README.md @@ -11,36 +11,43 @@ ## [501. Find Mode in Binary Search Tree (Easy)](https://leetcode.com/problems/find-mode-in-binary-search-tree "二叉搜索树中的众数") -

    Given a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred element) in the given BST.

    +

    Given the root of a binary search tree (BST) with duplicates, return all the mode(s) (i.e., the most frequently occurred element) in it.

    + +

    If the tree has more than one mode, return them in any order.

    Assume a BST is defined as follows:

      -
    • The left subtree of a node contains only nodes with keys less than or equal to the node's key.
    • -
    • The right subtree of a node contains only nodes with keys greater than or equal to the node's key.
    • +
    • The left subtree of a node contains only nodes with keys less than or equal to the node's key.
    • +
    • The right subtree of a node contains only nodes with keys greater than or equal to the node's key.
    • Both the left and right subtrees must also be binary search trees.

     

    +

    Example 1:

    + +
    +Input: root = [1,null,2,2]
    +Output: [2]
    +
    -

    For example:
    -Given BST [1,null,2,2],

    +

    Example 2:

    -   1
    -    \
    -     2
    -    /
    -   2
    +Input: root = [0]
    +Output: [0]
     

     

    +

    Constraints:

    -

    return [2].

    - -

    Note: If a tree has more than one mode, you can return them in any order.

    +
      +
    • The number of nodes in the tree is in the range [1, 104].
    • +
    • -105 <= Node.val <= 105
    • +
    -

    Follow up: Could you do that without using any extra space? (Assume that the implicit stack space incurred due to recursion does not count).

    +

     

    +Follow up: Could you do that without using any extra space? (Assume that the implicit stack space incurred due to recursion does not count). ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/generate-random-point-in-a-circle/README.md b/problems/generate-random-point-in-a-circle/README.md index fd63e7eab..ed1d71d2c 100644 --- a/problems/generate-random-point-in-a-circle/README.md +++ b/problems/generate-random-point-in-a-circle/README.md @@ -11,41 +11,40 @@ ## [478. Generate Random Point in a Circle (Medium)](https://leetcode.com/problems/generate-random-point-in-a-circle "在圆内随机生成点") -

    Given the radius and x-y positions of the center of a circle, write a function randPoint which generates a uniform random point in the circle.

    +

    Given the radius and the position of the center of a circle, implement the function randPoint which generates a uniform random point inside the circle.

    -

    Note:

    +

    Implement the Solution class:

    -
      -
    1. input and output values are in floating-point.
    2. -
    3. radius and x-y position of the center of the circle is passed into the class constructor.
    4. -
    5. a point on the circumference of the circle is considered to be in the circle.
    6. -
    7. randPoint returns a size 2 array containing x-position and y-position of the random point, in that order.
    8. -
    +
      +
    • Solution(double radius, double x_center, double y_center) initializes the object with the radius of the circle radius and the position of the center (x_center, y_center).
    • +
    • randPoint() returns a random point inside the circle. A point on the circumference of the circle is considered to be in the circle. The answer is returned as an array [x, y].
    • +
    -
    +

     

    Example 1:

    -Input: 
    -["Solution","randPoint","randPoint","randPoint"]
    -[[1,0,0],[],[],[]]
    -Output: [null,[-0.72939,-0.65505],[-0.78502,-0.28626],[-0.83119,-0.19803]]
    +Input
    +["Solution", "randPoint", "randPoint", "randPoint"]
    +[[1.0, 0.0, 0.0], [], [], []]
    +Output
    +[null, [-0.02493, -0.38077], [0.82314, 0.38945], [0.36572, 0.17248]]
    +
    +Explanation
    +Solution solution = new Solution(1.0, 0.0, 0.0);
    +solution.randPoint(); // return [-0.02493, -0.38077]
    +solution.randPoint(); // return [0.82314, 0.38945]
    +solution.randPoint(); // return [0.36572, 0.17248]
     
    -
    -

    Example 2:

    +

     

    +

    Constraints:

    -
    -Input: 
    -["Solution","randPoint","randPoint","randPoint"]
    -[[10,5,-7.5],[],[],[]]
    -Output: [null,[11.52438,-8.33273],[2.46992,-16.21705],[11.13430,-12.42337]]
    -
    - -

    Explanation of Input Syntax:

    - -

    The input is two lists: the subroutines called and their arguments. Solution's constructor has three arguments, the radius, x-position of the center, and y-position of the center of the circle. randPoint has no arguments. Arguments are always wrapped with a list, even if there aren't any.

    -
    +
      +
    • 0 < radius <= 108
    • +
    • -107 <= x_center, y_center <= 107
    • +
    • At most 3 * 104 calls will be made to randPoint.
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/h-index-ii/README.md b/problems/h-index-ii/README.md index 791166a18..8ee35fcd2 100644 --- a/problems/h-index-ii/README.md +++ b/problems/h-index-ii/README.md @@ -31,7 +31,7 @@ Since the researcher has 3 papers with at least 3 citations each and the remaini
     Input: citations = [1,2,100]
    -Output: 0
    +Output: 2
     

     

    diff --git a/problems/house-robber-ii/README.md b/problems/house-robber-ii/README.md index 815191ce6..0ce16fcf6 100644 --- a/problems/house-robber-ii/README.md +++ b/problems/house-robber-ii/README.md @@ -13,7 +13,7 @@

    You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have a security system connected, and it will automatically contact the police if two adjacent houses were broken into on the same night.

    -

    Given a list of non-negative integers nums representing the amount of money of each house, return the maximum amount of money you can rob tonight without alerting the police.

    +

    Given an integer array nums representing the amount of money of each house, return the maximum amount of money you can rob tonight without alerting the police.

     

    Example 1:

    diff --git a/problems/implement-stack-using-queues/README.md b/problems/implement-stack-using-queues/README.md index 958a77d5d..43fb91a44 100644 --- a/problems/implement-stack-using-queues/README.md +++ b/problems/implement-stack-using-queues/README.md @@ -53,12 +53,12 @@ myStack.empty(); // return False
    • 1 <= x <= 9
    • -
    • At most 100 calls will be made to push, pop, top, and empty.
    • +
    • At most 100 calls will be made to push, pop, top, and empty.
    • All the calls to pop and top are valid.

     

    -Follow-up: Can you implement the stack such that each operation is amortized O(1) time complexity? In other words, performing n operations will take overall O(n) time even if one of those operations may take longer. You can use more than two queues. +

    Follow-up: Can you implement the stack such that each operation is amortized O(1) time complexity? In other words, performing n operations will take overall O(n) time even if one of those operations may take longer. You can use more than two queues.

    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md b/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md index 2dff0654c..d8c4574fc 100644 --- a/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md +++ b/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md @@ -11,40 +11,46 @@ ## [381. Insert Delete GetRandom O(1) - Duplicates allowed (Hard)](https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed "O(1) 时间插入、删除和获取随机元素 - 允许重复") -

    Design a data structure that supports all following operations in average O(1) time.

    -Note: Duplicate elements are allowed. -

    -

      -
    1. insert(val): Inserts an item val to the collection.
    2. -
    3. remove(val): Removes an item val from the collection if present.
    4. -
    5. getRandom: Returns a random element from current collection of elements. The probability of each element being returned is linearly related to the number of same value the collection contains.
    6. -
    -

    - -

    Example: -

    -// Init an empty collection.
    -RandomizedCollection collection = new RandomizedCollection();
    +

    Implement the RandomizedCollection class:

    -// Inserts 1 to the collection. Returns true as the collection did not contain 1. -collection.insert(1); +
      +
    • RandomizedCollection() Initializes the RandomizedCollection object.
    • +
    • bool insert(int val) Inserts an item val into the multiset if not present. Returns true if the item was not present, false otherwise.
    • +
    • bool remove(int val) Removes an item val from the multiset if present. Returns true if the item was present, false otherwise. Note that if val has multiple occurrences in the multiset, we only remove one of them.
    • +
    • int getRandom() Returns a random element from the current multiset of elements (it's guaranteed that at least one element exists when this method is called). The probability of each element being returned is linearly related to the number of same values the multiset contains.
    • +
    -// Inserts another 1 to the collection. Returns false as the collection contained 1. Collection now contains [1,1]. -collection.insert(1); +

     

    +

    Example 1:

    -// Inserts 2 to the collection, returns true. Collection now contains [1,1,2]. -collection.insert(2); +
    +Input
    +["RandomizedCollection", "insert", "insert", "insert", "getRandom", "remove", "getRandom"]
    +[[], [1], [1], [2], [], [1], []]
    +Output
    +[null, true, false, true, 2, true, 1]
    +
    +Explanation
    +RandomizedCollection randomizedCollection = new RandomizedCollection();
    +randomizedCollection.insert(1);   // return True. Inserts 1 to the collection. Returns true as the collection did not contain 1.
    +randomizedCollection.insert(1);   // return False. Inserts another 1 to the collection. Returns false as the collection contained 1. Collection now contains [1,1].
    +randomizedCollection.insert(2);   // return True. Inserts 2 to the collection, returns true. Collection now contains [1,1,2].
    +randomizedCollection.getRandom(); // getRandom should return 1 with the probability 2/3, and returns 2 with the probability 1/3.
    +randomizedCollection.remove(1);   // return True. Removes 1 from the collection, returns true. Collection now contains [1,2].
    +randomizedCollection.getRandom(); // getRandom should return 1 and 2 both equally likely.
    +
    -// getRandom should return 1 with the probability 2/3, and returns 2 with the probability 1/3. -collection.getRandom(); +

     

    +

    Constraints:

    -// Removes 1 from the collection, returns true. Collection now contains [1,2]. -collection.remove(1); +
      +
    • -231 <= val <= 231 - 1
    • +
    • At most 105 calls will be made to insert, remove, and getRandom.
    • +
    • There will be at least one element in the data structure when getRandom is called.
    • +
    -// getRandom should return 1 and 2 both equally likely. -collection.getRandom(); -
    -

    +

     

    +Follow up: Could you implement the functions of the class with each function works in average O(1) time? ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/insert-delete-getrandom-o1/README.md b/problems/insert-delete-getrandom-o1/README.md index 4c5b0435b..d41ed0818 100644 --- a/problems/insert-delete-getrandom-o1/README.md +++ b/problems/insert-delete-getrandom-o1/README.md @@ -11,16 +11,15 @@ ## [380. Insert Delete GetRandom O(1) (Medium)](https://leetcode.com/problems/insert-delete-getrandom-o1 "常数时间插入、删除和获取随机元素") -

    Implement the RandomizedSet class:

    +

    Implement the RandomizedSet class:

      +
    • RandomizedSet() Initializes the RandomizedSet object.
    • bool insert(int val) Inserts an item val into the set if not present. Returns true if the item was not present, false otherwise.
    • bool remove(int val) Removes an item val from the set if present. Returns true if the item was present, false otherwise.
    • int getRandom() Returns a random element from the current set of elements (it's guaranteed that at least one element exists when this method is called). Each element must have the same probability of being returned.
    -

    Follow up: Could you implement the functions of the class with each function works in average O(1) time?

    -

     

    Example 1:

    @@ -48,9 +47,12 @@ randomizedSet.getRandom(); // Since 2 is the only number in the set, getRandom()
    • -231 <= val <= 231 - 1
    • At most 105 calls will be made to insert, remove, and getRandom.
    • -
    • There will be at least one element in the data structure when getRandom is called.
    • +
    • There will be at least one element in the data structure when getRandom is called.
    +

     

    +Follow up: Could you implement the functions of the class with each function works in average O(1) time? + ### Related Topics [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] diff --git a/problems/integer-break/README.md b/problems/integer-break/README.md index 5cf4dc96f..0358214d1 100644 --- a/problems/integer-break/README.md +++ b/problems/integer-break/README.md @@ -11,27 +11,33 @@ ## [343. Integer Break (Medium)](https://leetcode.com/problems/integer-break "整数拆分") -

    Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.

    +

    Given an integer n, break it into the sum of k positive integers, where k >= 2, and maximize the product of those integers.

    +

    Return the maximum product you can get.

    + +

     

    Example 1:

    -
    -Input: 2
    -Output: 1
    -Explanation: 2 = 1 + 1, 1 × 1 = 1.
    +Input: n = 2 +Output: 1 +Explanation: 2 = 1 + 1, 1 × 1 = 1. +
    -

    Example 2:

    -Input: 10
    -Output: 36
    -Explanation: 10 = 3 + 3 + 4, 3 × 3 × 4 = 36.
    +Input: n = 10 +Output: 36 +Explanation: 10 = 3 + 3 + 4, 3 × 3 × 4 = 36. + + +

     

    +

    Constraints:

    -

    Note: You may assume that n is not less than 2 and not larger than 58.

    -
    - +
      +
    • 2 <= n <= 58
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/intersection-of-two-arrays-ii/README.md b/problems/intersection-of-two-arrays-ii/README.md index 4bc295a48..bc912348b 100644 --- a/problems/intersection-of-two-arrays-ii/README.md +++ b/problems/intersection-of-two-arrays-ii/README.md @@ -11,36 +11,39 @@ ## [350. Intersection of Two Arrays II (Easy)](https://leetcode.com/problems/intersection-of-two-arrays-ii "两个数组的交集 II") -

    Given two arrays, write a function to compute their intersection.

    +

    Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must appear as many times as it shows in both arrays and you may return the result in any order.

    +

     

    Example 1:

    -Input: nums1 = [1,2,2,1], nums2 = [2,2]
    -Output: [2,2]
    +Input: nums1 = [1,2,2,1], nums2 = [2,2]
    +Output: [2,2]
     
    -

    Example 2:

    -Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4]
    -Output: [4,9]
    -
    +Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] +Output: [4,9] +Explanation: [9,4] is also accepted. + -

    Note:

    +

     

    +

    Constraints:

      -
    • Each element in the result should appear as many times as it shows in both arrays.
    • -
    • The result can be in any order.
    • +
    • 1 <= nums1.length, nums2.length <= 1000
    • +
    • 0 <= nums1[i], nums2[i] <= 1000
    -

    Follow up:

    +

     

    +

    Follow up:

    • What if the given array is already sorted? How would you optimize your algorithm?
    • -
    • What if nums1's size is small compared to nums2's size? Which algorithm is better?
    • -
    • What if elements of nums2 are stored on disk, and the memory is limited such that you cannot load all elements into the memory at once?
    • +
    • What if nums1's size is small compared to nums2's size? Which algorithm is better?
    • +
    • What if elements of nums2 are stored on disk, and the memory is limited such that you cannot load all elements into the memory at once?
    ### Related Topics diff --git a/problems/intersection-of-two-arrays/README.md b/problems/intersection-of-two-arrays/README.md index 09355375f..f694a017f 100644 --- a/problems/intersection-of-two-arrays/README.md +++ b/problems/intersection-of-two-arrays/README.md @@ -11,32 +11,32 @@ ## [349. Intersection of Two Arrays (Easy)](https://leetcode.com/problems/intersection-of-two-arrays "两个数组的交集") -

    Given two arrays, write a function to compute their intersection.

    +

    Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any order.

    +

     

    Example 1:

    -Input: nums1 = [1,2,2,1], nums2 = [2,2]
    -Output: [2]
    +Input: nums1 = [1,2,2,1], nums2 = [2,2]
    +Output: [2]
     
    -

    Example 2:

    -Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4]
    -Output: [9,4]
    -
    +Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] +Output: [9,4] +Explanation: [4,9] is also accepted. + -

    Note:

    +

     

    +

    Constraints:

      -
    • Each element in the result must be unique.
    • -
    • The result can be in any order.
    • +
    • 1 <= nums1.length, nums2.length <= 1000
    • +
    • 0 <= nums1[i], nums2[i] <= 1000
    -

     

    - ### Related Topics [[Sort](../../tag/sort/README.md)] [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/intersection-of-two-linked-lists/README.md b/problems/intersection-of-two-linked-lists/README.md index 35ee928a9..1a31b9d34 100644 --- a/problems/intersection-of-two-linked-lists/README.md +++ b/problems/intersection-of-two-linked-lists/README.md @@ -53,10 +53,10 @@ Explanation: The two lists do not intersect, so return null.
    • The number of nodes of listA is in the m.
    • The number of nodes of listB is in the n.
    • -
    • 1 <= m, n <= 3 * 104
    • +
    • 0 <= m, n <= 3 * 104
    • 1 <= Node.val <= 105
    • -
    • 1 <= skipA <= m
    • -
    • 1 <= skipB <= n
    • +
    • 0 <= skipA <= m
    • +
    • 0 <= skipB <= n
    • intersectVal is 0 if listA and listB do not intersect.
    • intersectVal == listA[skipA + 1] == listB[skipB + 1] if listA and listB intersect.
    diff --git a/problems/invert-binary-tree/README.md b/problems/invert-binary-tree/README.md index 10154674f..6f779a293 100644 --- a/problems/invert-binary-tree/README.md +++ b/problems/invert-binary-tree/README.md @@ -11,32 +11,37 @@ ## [226. Invert Binary Tree (Easy)](https://leetcode.com/problems/invert-binary-tree "翻转二叉树") -

    Invert a binary tree.

    +

    Given the root of a binary tree, invert the tree, and return its root.

    -

    Example:

    - -

    Input:

    +

     

    +

    Example 1:

    + +
    +Input: root = [4,2,7,1,3,6,9]
    +Output: [4,7,2,9,6,3,1]
    +
    +

    Example 2:

    +
    -     4
    -   /   \
    -  2     7
    - / \   / \
    -1   3 6   9
    +Input: root = [2,1,3] +Output: [2,3,1] + -

    Output:

    +

    Example 3:

    -     4
    -   /   \
    -  7     2
    - / \   / \
    -9   6 3   1
    +Input: root = [] +Output: [] + -

    Trivia:
    -This problem was inspired by this original tweet by Max Howell:

    +

     

    +

    Constraints:

    -
    Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so f*** off.
    +
      +
    • The number of nodes in the tree is in the range [0, 100].
    • +
    • -100 <= Node.val <= 100
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/k-similar-strings/README.md b/problems/k-similar-strings/README.md index 66df9c7bd..c510bbcc9 100644 --- a/problems/k-similar-strings/README.md +++ b/problems/k-similar-strings/README.md @@ -11,49 +11,33 @@ ## [854. K-Similar Strings (Hard)](https://leetcode.com/problems/k-similar-strings "相似度为 K 的字符串") -

    Strings A and B are K-similar (for some non-negative integer K) if we can swap the positions of two letters in A exactly K times so that the resulting string equals B.

    +

    Strings s1 and s2 are k-similar (for some non-negative integer k) if we can swap the positions of two letters in s1 exactly k times so that the resulting string equals s2.

    -

    Given two anagrams A and B, return the smallest K for which A and B are K-similar.

    +

    Given two anagrams s1 and s2, return the smallest k for which s1 and s2 are k-similar.

    +

     

    Example 1:

    - -
    -Input: A = "ab", B = "ba"
    -Output: 1
    -
    - -
    -

    Example 2:

    - -
    -Input: A = "abc", B = "bca"
    -Output: 2
    +
    Input: s1 = "ab", s2 = "ba"
    +Output: 1
    +

    Example 2:

    +
    Input: s1 = "abc", s2 = "bca"
    +Output: 2
    +

    Example 3:

    +
    Input: s1 = "abac", s2 = "baca"
    +Output: 2
    +

    Example 4:

    +
    Input: s1 = "aabc", s2 = "abca"
    +Output: 2
     
    - -
    -

    Example 3:

    - -
    -Input: A = "abac", B = "baca"
    -Output: 2
    -
    - -
    -

    Example 4:

    - -
    -Input: A = "aabc", B = "abca"
    -Output: 2
    -
    -
    -
    - -

    Note:

    - -
      -
    1. 1 <= A.length == B.length <= 20
    2. -
    3. A and B contain only lowercase letters from the set {'a', 'b', 'c', 'd', 'e', 'f'}
    4. -
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= s1.length <= 20
    • +
    • s2.length == s1.length
    • +
    • s1 and s2 contain only lowercase letters from the set {'a', 'b', 'c', 'd', 'e', 'f'}.
    • +
    • s2 is an anagram of s1.
    • +
    ### Related Topics [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/linked-list-random-node/README.md b/problems/linked-list-random-node/README.md index 27ec5020a..960499cef 100644 --- a/problems/linked-list-random-node/README.md +++ b/problems/linked-list-random-node/README.md @@ -15,7 +15,7 @@

     

    Example 1:

    - +
     Input
     ["Solution", "getRandom", "getRandom", "getRandom", "getRandom", "getRandom"]
    @@ -37,7 +37,7 @@ solution.getRandom(); // return 3
     

    Constraints:

      -
    • The number of nodes in the linked list will be in the range [1, 104]
    • +
    • The number of nodes in the linked list will be in the range [1, 104].
    • -104 <= Node.val <= 104
    • At most 104 calls will be made to getRandom.
    diff --git a/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md index f51d9833c..cb8ef9108 100644 --- a/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md +++ b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md @@ -11,7 +11,7 @@ ## [1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit (Medium)](https://leetcode.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "绝对差不超过限制的最长连续子数组") -

    Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference between any two elements of this subarray is less than or equal to limit.

    +

    Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference between any two elements of this subarray is less than or equal to limit.

     

    Example 1:

    @@ -52,9 +52,9 @@ Therefore, the size of the longest subarray is 2.

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • 1 <= nums[i] <= 10^9
    • -
    • 0 <= limit <= 10^9
    • +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 109
    • +
    • 0 <= limit <= 109
    ### Related Topics diff --git a/problems/max-sum-of-rectangle-no-larger-than-k/README.md b/problems/max-sum-of-rectangle-no-larger-than-k/README.md index 532527854..332f0d7ea 100644 --- a/problems/max-sum-of-rectangle-no-larger-than-k/README.md +++ b/problems/max-sum-of-rectangle-no-larger-than-k/README.md @@ -11,22 +11,40 @@ ## [363. Max Sum of Rectangle No Larger Than K (Hard)](https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k "矩形区域不超过 K 的最大数值和") -

    Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix such that its sum is no larger than k.

    +

    Given an m x n matrix matrix and an integer k, return the max sum of a rectangle in the matrix such that its sum is no larger than k.

    -

    Example:

    +

    It is guaranteed that there will be a rectangle with a sum no larger than k.

    +

     

    +

    Example 1:

    +
    -Input: matrix = [[1,0,1],[0,-2,3]], k = 2
    -Output: 2 
    -Explanation: Because the sum of rectangle [[0, 1], [-2, 3]] is 2,
    -             and 2 is the max number no larger than k (k = 2).
    +Input: matrix = [[1,0,1],[0,-2,3]], k = 2 +Output: 2 +Explanation: Because the sum of the blue rectangle [[0, 1], [-2, 3]] is 2, and 2 is the max number no larger than k (k = 2). +
    -

    Note:

    +

    Example 2:

    -
      -
    1. The rectangle inside the matrix must have an area > 0.
    2. -
    3. What if the number of rows is much larger than the number of columns?
    4. -
    +
    +Input: matrix = [[2,2,-1]], k = 3
    +Output: 3
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == matrix.length
    • +
    • n == matrix[i].length
    • +
    • 1 <= m, n <= 3000
    • +
    • 1 <= m * n <= 5 * 104
    • +
    • -100 <= matrix[i][j] <= 100
    • +
    • -105 <= k <= 105
    • +
    + +

     

    +

    Follow up: What if the number of rows is much larger than the number of columns?

    ### Related Topics [[Queue](../../tag/queue/README.md)] diff --git a/problems/maximize-score-after-n-operations/README.md b/problems/maximize-score-after-n-operations/README.md new file mode 100644 index 000000000..92149c733 --- /dev/null +++ b/problems/maximize-score-after-n-operations/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../maximum-number-of-consecutive-values-you-can-make "Maximum Number of Consecutive Values You Can Make") +                 +[Next >](../maximum-ascending-subarray-sum "Maximum Ascending Subarray Sum") + +## [1799. Maximize Score After N Operations (Hard)](https://leetcode.com/problems/maximize-score-after-n-operations "N 次操作后的最大分数和") + +

    You are given nums, an array of positive integers of size 2 * n. You must perform n operations on this array.

    + +

    In the ith operation (1-indexed), you will:

    + +
      +
    • Choose two elements, x and y.
    • +
    • Receive a score of i * gcd(x, y).
    • +
    • Remove x and y from nums.
    • +
    + +

    Return the maximum score you can receive after performing n operations.

    + +

    The function gcd(x, y) is the greatest common divisor of x and y.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2]
    +Output: 1
    +Explanation: The optimal choice of operations is:
    +(1 * gcd(1, 2)) = 1
    +
    + +

    Example 2:

    + +
    +Input: nums = [3,4,6,8]
    +Output: 11
    +Explanation: The optimal choice of operations is:
    +(1 * gcd(3, 6)) + (2 * gcd(4, 8)) = 3 + 8 = 11
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,2,3,4,5,6]
    +Output: 14
    +Explanation: The optimal choice of operations is:
    +(1 * gcd(1, 5)) + (2 * gcd(2, 4)) + (3 * gcd(3, 6)) = 1 + 4 + 9 = 14
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 7
    • +
    • nums.length == 2 * n
    • +
    • 1 <= nums[i] <= 106
    • +
    + +### Related Topics + [[Recursion](../../tag/recursion/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
    +Hint 1 +Find every way to split the array until n groups of 2. Brute force recursion is acceptable. +
    + +
    +Hint 2 +Calculate the gcd of every pair and greedily multiply the largest gcds. +
    diff --git a/problems/maximize-the-beauty-of-the-garden/README.md b/problems/maximize-the-beauty-of-the-garden/README.md index 45813fb91..9c9894cfe 100644 --- a/problems/maximize-the-beauty-of-the-garden/README.md +++ b/problems/maximize-the-beauty-of-the-garden/README.md @@ -7,7 +7,7 @@ [< Previous](../make-the-xor-of-all-segments-equal-to-zero "Make the XOR of All Segments Equal to Zero")                  -Next > +[Next >](../primary-department-for-each-employee "Primary Department for Each Employee") ## [1788. Maximize the Beauty of the Garden (Hard)](https://leetcode.com/problems/maximize-the-beauty-of-the-garden "") diff --git a/problems/maximum-ascending-subarray-sum/README.md b/problems/maximum-ascending-subarray-sum/README.md new file mode 100644 index 000000000..a324c3026 --- /dev/null +++ b/problems/maximum-ascending-subarray-sum/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../maximize-score-after-n-operations "Maximize Score After N Operations") +                 +[Next >](../number-of-orders-in-the-backlog "Number of Orders in the Backlog") + +## [1800. Maximum Ascending Subarray Sum (Easy)](https://leetcode.com/problems/maximum-ascending-subarray-sum "最大升序子数组和") + +

    Given an array of positive integers nums, return the maximum possible sum of an ascending subarray in nums.

    + +

    A subarray is defined as a contiguous sequence of numbers in an array.

    + +

    A subarray [numsl, numsl+1, ..., numsr-1, numsr] is ascending if for all i where l <= i < r, numsi < numsi+1. Note that a subarray of size 1 is ascending.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [10,20,30,5,10,50]
    +Output: 65
    +Explanation: [5,10,50] is the ascending subarray with the maximum sum of 65.
    +
    + +

    Example 2:

    + +
    +Input: nums = [10,20,30,40,50]
    +Output: 150
    +Explanation: [10,20,30,40,50] is the ascending subarray with the maximum sum of 150.
    +
    + +

    Example 3:

    + +
    +Input: nums = [12,17,15,13,10,11,12]
    +Output: 33
    +Explanation: [10,11,12] is the ascending subarray with the maximum sum of 33.
    +
    + +

    Example 4:

    + +
    +Input: nums = [100,10,1]
    +Output: 100
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • 1 <= nums[i] <= 100
    • +
    + +### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] + +### Hints +
    +Hint 1 +It is fast enough to check all possible subarrays +
    + +
    +Hint 2 +The end of each ascending subarray will be the start of the next +
    diff --git a/problems/maximum-average-pass-ratio/README.md b/problems/maximum-average-pass-ratio/README.md new file mode 100644 index 000000000..be407aae5 --- /dev/null +++ b/problems/maximum-average-pass-ratio/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../find-center-of-star-graph "Find Center of Star Graph") +                 +[Next >](../maximum-score-of-a-good-subarray "Maximum Score of a Good Subarray") + +## [1792. Maximum Average Pass Ratio (Medium)](https://leetcode.com/problems/maximum-average-pass-ratio "最大平均通过率") + +

    There is a school that has classes of students and each class will be having a final exam. You are given a 2D integer array classes, where classes[i] = [passi, totali]. You know beforehand that in the ith class, there are totali total students, but only passi number of students will pass the exam.

    + +

    You are also given an integer extraStudents. There are another extraStudents brilliant students that are guaranteed to pass the exam of any class they are assigned to. You want to assign each of the extraStudents students to a class in a way that maximizes the average pass ratio across all the classes.

    + +

    The pass ratio of a class is equal to the number of students of the class that will pass the exam divided by the total number of students of the class. The average pass ratio is the sum of pass ratios of all the classes divided by the number of the classes.

    + +

    Return the maximum possible average pass ratio after assigning the extraStudents students. Answers within 10-5 of the actual answer will be accepted.

    + +

     

    +

    Example 1:

    + +
    +Input: classes = [[1,2],[3,5],[2,2]], extraStudents = 2
    +Output: 0.78333
    +Explanation: You can assign the two extra students to the first class. The average pass ratio will be equal to (3/4 + 3/5 + 2/2) / 3 = 0.78333.
    +
    + +

    Example 2:

    + +
    +Input: classes = [[2,4],[3,9],[4,5],[2,10]], extraStudents = 4
    +Output: 0.53485
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= classes.length <= 105
    • +
    • classes[i].length == 2
    • +
    • 1 <= passi <= totali <= 105
    • +
    • 1 <= extraStudents <= 105
    • +
    + +### Related Topics + [[Heap](../../tag/heap/README.md)] + +### Hints +
    +Hint 1 +Pay attention to how much the pass ratio changes when you add a student to the class. If you keep adding students, what happens to the change in pass ratio? The more students you add to a class, the smaller the change in pass ratio becomes. +
    + +
    +Hint 2 +Since the change in the pass ratio is always decreasing with the more students you add, then the very first student you add to each class is the one that makes the biggest change in the pass ratio. +
    + +
    +Hint 3 +Because each class's pass ratio is weighted equally, it's always optimal to put the student in the class that makes the biggest change among all the other classes. +
    + +
    +Hint 4 +Keep a max heap of the current class sizes and order them by the change in pass ratio. For each extra student, take the top of the heap, update the class size, and put it back in the heap. +
    diff --git a/problems/maximum-number-of-consecutive-values-you-can-make/README.md b/problems/maximum-number-of-consecutive-values-you-can-make/README.md new file mode 100644 index 000000000..34b7ad472 --- /dev/null +++ b/problems/maximum-number-of-consecutive-values-you-can-make/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../design-authentication-manager "Design Authentication Manager") +                 +[Next >](../maximize-score-after-n-operations "Maximize Score After N Operations") + +## [1798. Maximum Number of Consecutive Values You Can Make (Medium)](https://leetcode.com/problems/maximum-number-of-consecutive-values-you-can-make "你能构造出连续值的最大数目") + +

    You are given an integer array coins of length n which represents the n coins that you own. The value of the ith coin is coins[i]. You can make some value x if you can choose some of your n coins such that their values sum up to x.

    + +

    Return the maximum number of consecutive integer values that you can make with your coins starting from and including 0.

    + +

    Note that you may have multiple coins of the same value.

    + +

     

    +

    Example 1:

    + +
    +Input: coins = [1,3]
    +Output: 2
    +Explanation: You can make the following values:
    +- 0: take []
    +- 1: take [1]
    +You can make 2 consecutive integer values starting from 0.
    + +

    Example 2:

    + +
    +Input: coins = [1,1,1,4]
    +Output: 8
    +Explanation: You can make the following values:
    +- 0: take []
    +- 1: take [1]
    +- 2: take [1,1]
    +- 3: take [1,1,1]
    +- 4: take [4]
    +- 5: take [4,1]
    +- 6: take [4,1,1]
    +- 7: take [4,1,1,1]
    +You can make 8 consecutive integer values starting from 0.
    + +

    Example 3:

    + +
    +Input: nums = [1,4,10,3,1]
    +Output: 20
    + +

     

    +

    Constraints:

    + +
      +
    • coins.length == n
    • +
    • 1 <= n <= 4 * 104
    • +
    • 1 <= coins[i] <= 4 * 104
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Let's note that if you can make the first x values then you can and you have a value v≤x+1 then you can make all values ≤v+x +
    + +
    +Hint 2 +The smaller v is the smaller the x you need so it's optimal to process elements in a sorted order +
    diff --git a/problems/maximum-product-of-word-lengths/README.md b/problems/maximum-product-of-word-lengths/README.md index 2d1350661..cbd9bea69 100644 --- a/problems/maximum-product-of-word-lengths/README.md +++ b/problems/maximum-product-of-word-lengths/README.md @@ -11,36 +11,39 @@ ## [318. Maximum Product of Word Lengths (Medium)](https://leetcode.com/problems/maximum-product-of-word-lengths "最大单词长度乘积") -

    Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case letters. If no such two words exist, return 0.

    +

    Given a string array words, return the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. If no such two words exist, return 0.

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input: ["abcw","baz","foo","bar","xtfn","abcdef"]
    -Output: 16 
    -Explanation: The two words can be "abcw", "xtfn".
    +Input: words = ["abcw","baz","foo","bar","xtfn","abcdef"] +Output: 16 +Explanation: The two words can be "abcw", "xtfn". + -

    Example 2:

    +

    Example 2:

    -Input: ["a","ab","abc","d","cd","bcd","abcd"]
    -Output: 4 
    -Explanation: The two words can be "ab", "cd".
    +Input: words = ["a","ab","abc","d","cd","bcd","abcd"] +Output: 4 +Explanation: The two words can be "ab", "cd". + -

    Example 3:

    +

    Example 3:

    -Input: ["a","aa","aaa","aaaa"]
    -Output: 0 
    -Explanation: No such pair of words.
    +Input: words = ["a","aa","aaa","aaaa"]
    +Output: 0
    +Explanation: No such pair of words.
     

     

    Constraints:

      -
    • 0 <= words.length <= 10^3
    • -
    • 0 <= words[i].length <= 10^3
    • +
    • 2 <= words.length <= 1000
    • +
    • 1 <= words[i].length <= 1000
    • words[i] consists only of lowercase English letters.
    diff --git a/problems/maximum-score-of-a-good-subarray/README.md b/problems/maximum-score-of-a-good-subarray/README.md new file mode 100644 index 000000000..289c998b4 --- /dev/null +++ b/problems/maximum-score-of-a-good-subarray/README.md @@ -0,0 +1,58 @@ + + + + + + + +[< Previous](../maximum-average-pass-ratio "Maximum Average Pass Ratio") +                 +[Next >](../count-pairs-of-equal-substrings-with-minimum-difference "Count Pairs of Equal Substrings With Minimum Difference") + +## [1793. Maximum Score of a Good Subarray (Hard)](https://leetcode.com/problems/maximum-score-of-a-good-subarray "好子数组的最大分数") + +

    You are given an array of integers nums (0-indexed) and an integer k.

    + +

    The score of a subarray (i, j) is defined as min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1). A good subarray is a subarray where i <= k <= j.

    + +

    Return the maximum possible score of a good subarray.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,4,3,7,4,5], k = 3
    +Output: 15
    +Explanation: The optimal subarray is (1, 5) with a score of min(4,3,7,4,5) * (5-1+1) = 3 * 5 = 15. 
    +
    + +

    Example 2:

    + +
    +Input: nums = [5,5,4,5,4,1,1,1], k = 0
    +Output: 20
    +Explanation: The optimal subarray is (0, 4) with a score of min(5,5,4,5,4) * (4-0+1) = 4 * 5 = 20.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 2 * 104
    • +
    • 0 <= k < nums.length
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Try thinking about the prefix before index k and the suffix after index k as two separate arrays. +
    + +
    +Hint 2 +Using two pointers or binary search, we can find the maximum prefix of each array where the numbers are less than or equal to a certain value +
    diff --git a/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md b/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md new file mode 100644 index 000000000..0c57bbf23 --- /dev/null +++ b/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../number-of-orders-in-the-backlog "Number of Orders in the Backlog") +                 +[Next >](../count-pairs-with-xor-in-a-range "Count Pairs With XOR in a Range") + +## [1802. Maximum Value at a Given Index in a Bounded Array (Medium)](https://leetcode.com/problems/maximum-value-at-a-given-index-in-a-bounded-array "有界数组中指定下标处的最大值") + +

    You are given three positive integers n, index and maxSum. You want to construct an array nums (0-indexed) that satisfies the following conditions:

    + +
      +
    • nums.length == n
    • +
    • nums[i] is a positive integer where 0 <= i < n.
    • +
    • abs(nums[i] - nums[i+1]) <= 1 where 0 <= i < n-1.
    • +
    • The sum of all the elements of nums does not exceed maxSum.
    • +
    • nums[index] is maximized.
    • +
    + +

    Return nums[index] of the constructed array.

    + +

    Note that abs(x) equals x if x >= 0, and -x otherwise.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 4, index = 2,  maxSum = 6
    +Output: 2
    +Explanation: The arrays [1,1,2,1] and [1,2,2,1] satisfy all the conditions. There are no other valid arrays with a larger value at the given index.
    +
    + +

    Example 2:

    + +
    +Input: n = 6, index = 1,  maxSum = 10
    +Output: 3
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= maxSum <= 109
    • +
    • 0 <= index < n
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +What if the problem was instead determining if you could generate a valid array with nums[index] == target? +
    + +
    +Hint 2 +To generate the array, set nums[index] to target, nums[index-i] to target-i, and nums[index+i] to target-i. Then, this will give the minimum possible sum, so check if the sum is less than or equal to maxSum. +
    + +
    +Hint 3 +n is too large to actually generate the array, so you can use the formula 1 + 2 + ... + n = n * (n+1) / 2 to quickly find the sum of nums[0...index] and nums[index...n-1]. +
    + +
    +Hint 4 +Binary search for the target. If it is possible, then move the lower bound up. Otherwise, move the upper bound down. +
    diff --git a/problems/min-stack/README.md b/problems/min-stack/README.md index 337b2bb83..61955b7d8 100644 --- a/problems/min-stack/README.md +++ b/problems/min-stack/README.md @@ -13,11 +13,14 @@

    Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.

    +

    Implement the MinStack class:

    +
      -
    • push(x) -- Push element x onto stack.
    • -
    • pop() -- Removes the element on top of the stack.
    • -
    • top() -- Get the top element.
    • -
    • getMin() -- Retrieve the minimum element in the stack.
    • +
    • MinStack() initializes the stack object.
    • +
    • void push(val) pushes the element val onto the stack.
    • +
    • void pop() removes the element on the top of the stack.
    • +
    • int top() gets the top element of the stack.
    • +
    • int getMin() retrieves the minimum element in the stack.

     

    @@ -46,7 +49,9 @@ minStack.getMin(); // return -2

    Constraints:

      +
    • -231 <= val <= 231 - 1
    • Methods pop, top and getMin operations will always be called on non-empty stacks.
    • +
    • At most 3 * 104 calls will be made to push, pop, top, and getMin.
    ### Related Topics diff --git a/problems/n-ary-tree-postorder-traversal/README.md b/problems/n-ary-tree-postorder-traversal/README.md index 1877d7459..f0984b32d 100644 --- a/problems/n-ary-tree-postorder-traversal/README.md +++ b/problems/n-ary-tree-postorder-traversal/README.md @@ -11,30 +11,20 @@ ## [590. N-ary Tree Postorder Traversal (Easy)](https://leetcode.com/problems/n-ary-tree-postorder-traversal "N 叉树的后序遍历") -

    Given an n-ary tree, return the postorder traversal of its nodes' values.

    +

    Given the root of an n-ary tree, return the postorder traversal of its nodes' values.

    -

    Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples).

    - -

     

    - -

    Follow up:

    - -

    Recursive solution is trivial, could you do it iteratively?

    +

    Nary-Tree input serialization is represented in their level order traversal. Each group of children is separated by the null value (See examples)

     

    Example 1:

    - -

    - +
     Input: root = [1,null,3,2,4,null,5,6]
     Output: [5,6,3,2,4,1]
     

    Example 2:

    - -

    - +
     Input: root = [1,null,2,3,4,5,null,null,6,7,null,8,null,9,10,null,null,11,null,12,null,13,null,null,14]
     Output: [2,6,14,11,7,3,12,8,4,13,9,10,5,1]
    @@ -44,10 +34,14 @@
     

    Constraints:

      -
    • The height of the n-ary tree is less than or equal to 1000
    • -
    • The total number of nodes is between [0, 10^4]
    • +
    • The number of nodes in the tree is in the range [0, 104].
    • +
    • 0 <= Node.val <= 104
    • +
    • The height of the n-ary tree is less than or equal to 1000.
    +

     

    +

    Follow up: Recursive solution is trivial, could you do it iteratively?

    + ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/n-ary-tree-preorder-traversal/README.md b/problems/n-ary-tree-preorder-traversal/README.md index 8b1717293..ce13ab0d0 100644 --- a/problems/n-ary-tree-preorder-traversal/README.md +++ b/problems/n-ary-tree-preorder-traversal/README.md @@ -11,15 +11,9 @@ ## [589. N-ary Tree Preorder Traversal (Easy)](https://leetcode.com/problems/n-ary-tree-preorder-traversal "N 叉树的前序遍历") -

    Given an n-ary tree, return the preorder traversal of its nodes' values.

    +

    Given the root of an n-ary tree, return the preorder traversal of its nodes' values.

    -

    Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples).

    - -

     

    - -

    Follow up:

    - -

    Recursive solution is trivial, could you do it iteratively?

    +

    Nary-Tree input serialization is represented in their level order traversal. Each group of children is separated by the null value (See examples)

     

    Example 1:

    @@ -44,10 +38,14 @@

    Constraints:

      -
    • The height of the n-ary tree is less than or equal to 1000
    • -
    • The total number of nodes is between [0, 10^4]
    • +
    • The number of nodes in the tree is in the range [0, 104].
    • +
    • 0 <= Node.val <= 104
    • +
    • The height of the n-ary tree is less than or equal to 1000.
    +

     

    +

    Follow up: Recursive solution is trivial, could you do it iteratively?

    + ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/nth-digit/README.md b/problems/nth-digit/README.md index 1d4d46c27..401d46f96 100644 --- a/problems/nth-digit/README.md +++ b/problems/nth-digit/README.md @@ -11,34 +11,30 @@ ## [400. Nth Digit (Medium)](https://leetcode.com/problems/nth-digit "第 N 位数字") -

    Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...

    +

    Given an integer n, return the nth digit of the infinite integer sequence [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...].

    -

    Note:
    -n is positive and will fit within the range of a 32-bit signed integer (n < 231). -

    +

     

    +

    Example 1:

    -

    Example 1:

    -Input:
    -3
    -
    -Output:
    -3
    +Input: n = 3
    +Output: 3
     
    -

    -

    Example 2: +

    Example 2:

    +
    -Input:
    -11
    +Input: n = 11
    +Output: 0
    +Explanation: The 11th digit of the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... is a 0, which is part of the number 10.
    +
    -Output: -0 +

     

    +

    Constraints:

    -Explanation: -The 11th digit of the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... is a 0, which is part of the number 10. -
    -

    +
      +
    • 1 <= n <= 231 - 1
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/number-of-orders-in-the-backlog/README.md b/problems/number-of-orders-in-the-backlog/README.md new file mode 100644 index 000000000..36a25dd1d --- /dev/null +++ b/problems/number-of-orders-in-the-backlog/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../maximum-ascending-subarray-sum "Maximum Ascending Subarray Sum") +                 +[Next >](../maximum-value-at-a-given-index-in-a-bounded-array "Maximum Value at a Given Index in a Bounded Array") + +## [1801. Number of Orders in the Backlog (Medium)](https://leetcode.com/problems/number-of-orders-in-the-backlog "积压订单中的订单总数") + +

    You are given a 2D integer array orders, where each orders[i] = [pricei, amounti, orderTypei] denotes that amounti orders have been placed of type orderTypei at the price pricei. The orderTypei is:

    + +
      +
    • 0 if it is a batch of buy orders, or
    • +
    • 1 if it is a batch of sell orders.
    • +
    + +

    Note that orders[i] represents a batch of amounti independent orders with the same price and order type. All orders represented by orders[i] will be placed before all orders represented by orders[i+1] for all valid i.

    + +

    There is a backlog that consists of orders that have not been executed. The backlog is initially empty. When an order is placed, the following happens:

    + +
      +
    • If the order is a buy order, you look at the sell order with the smallest price in the backlog. If that sell order's price is smaller than or equal to the current buy order's price, they will match and be executed, and that sell order will be removed from the backlog. Else, the buy order is added to the backlog.
    • +
    • Vice versa, if the order is a sell order, you look at the buy order with the largest price in the backlog. If that buy order's price is larger than or equal to the current sell order's price, they will match and be executed, and that buy order will be removed from the backlog. Else, the sell order is added to the backlog.
    • +
    + +

    Return the total amount of orders in the backlog after placing all the orders from the input. Since this number can be large, return it modulo 109 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: orders = [[10,5,0],[15,2,1],[25,1,1],[30,4,0]]
    +Output: 6
    +Explanation: Here is what happens with the orders:
    +- 5 orders of type buy with price 10 are placed. There are no sell orders, so the 5 orders are added to the backlog.
    +- 2 orders of type sell with price 15 are placed. There are no buy orders with prices larger than or equal to 15, so the 2 orders are added to the backlog.
    +- 1 order of type sell with price 25 is placed. There are no buy orders with prices larger than or equal to 25 in the backlog, so this order is added to the backlog.
    +- 4 orders of type buy with price 30 are placed. The first 2 orders are matched with the 2 sell orders of the least price, which is 15 and these 2 sell orders are removed from the backlog. The 3rd order is matched with the sell order of the least price, which is 25 and this sell order is removed from the backlog. Then, there are no more sell orders in the backlog, so the 4th order is added to the backlog.
    +Finally, the backlog has 5 buy orders with price 10, and 1 buy order with price 30. So the total number of orders in the backlog is 6.
    +
    + +

    Example 2:

    + +
    +Input: orders = [[7,1000000000,1],[15,3,0],[5,999999995,0],[5,1,1]]
    +Output: 999999984
    +Explanation: Here is what happens with the orders:
    +- 109 orders of type sell with price 7 are placed. There are no buy orders, so the 109 orders are added to the backlog.
    +- 3 orders of type buy with price 15 are placed. They are matched with the 3 sell orders with the least price which is 7, and those 3 sell orders are removed from the backlog.
    +- 999999995 orders of type buy with price 5 are placed. The least price of a sell order is 7, so the 999999995 orders are added to the backlog.
    +- 1 order of type sell with price 5 is placed. It is matched with the buy order of the highest price, which is 5, and that buy order is removed from the backlog.
    +Finally, the backlog has (1000000000-3) sell orders with price 7, and (999999995-1) buy orders with price 5. So the total number of orders = 1999999991, which is equal to 999999984 % (109 + 7).
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= orders.length <= 105
    • +
    • orders[i].length == 3
    • +
    • 1 <= pricei, amounti <= 109
    • +
    • orderTypei is either 0 or 1.
    • +
    + +### Related Topics + [[Heap](../../tag/heap/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Store the backlog buy and sell orders in two heaps, the buy orders in a max heap by price and the sell orders in a min heap by price. +
    + +
    +Hint 2 +Store the orders in batches and update the fields according to new incoming orders. Each batch should only take 1 "slot" in the heap. +
    diff --git a/problems/paint-house-iii/README.md b/problems/paint-house-iii/README.md index a17042736..51bbcb835 100644 --- a/problems/paint-house-iii/README.md +++ b/problems/paint-house-iii/README.md @@ -11,18 +11,22 @@ ## [1473. Paint House III (Hard)](https://leetcode.com/problems/paint-house-iii "粉刷房子 III") -

    There is a row of m houses in a small city, each house must be painted with one of the n colors (labeled from 1 to n), some houses that has been painted last summer should not be painted again.

    +

    There is a row of m houses in a small city, each house must be painted with one of the n colors (labeled from 1 to n), some houses that have been painted last summer should not be painted again.

    -

    A neighborhood is a maximal group of continuous houses that are painted with the same color. (For example: houses = [1,2,2,3,3,2,1,1] contains 5 neighborhoods  [{1}, {2,2}, {3,3}, {2}, {1,1}]).

    +

    A neighborhood is a maximal group of continuous houses that are painted with the same color.

    -

    Given an array houses, an m * n matrix cost and an integer target where:

    +
      +
    • For example: houses = [1,2,2,3,3,2,1,1] contains 5 neighborhoods [{1}, {2,2}, {3,3}, {2}, {1,1}].
    • +
    + +

    Given an array houses, an m x n matrix cost and an integer target where:

      -
    • houses[i]: is the color of the house i, 0 if the house is not painted yet.
    • -
    • cost[i][j]: is the cost of paint the house i with the color j+1.
    • +
    • houses[i]: is the color of the house i, and 0 if the house is not painted yet.
    • +
    • cost[i][j]: is the cost of paint the house i with the color j + 1.
    -

    Return the minimum cost of painting all the remaining houses in such a way that there are exactly target neighborhoods, if not possible return -1.

    +

    Return the minimum cost of painting all the remaining houses in such a way that there are exactly target neighborhoods. If it is not possible, return -1.

     

    Example 1:

    @@ -68,8 +72,8 @@ Cost of paint the first and last house (10 + 1) = 11.
  • n == cost[i].length
  • 1 <= m <= 100
  • 1 <= n <= 20
  • -
  • 1 <= target <= m
  • -
  • 0 <= houses[i] <= n
  • +
  • 1 <= target <= m
  • +
  • 0 <= houses[i] <= n
  • 1 <= cost[i][j] <= 10^4
  • diff --git a/problems/patching-array/README.md b/problems/patching-array/README.md index d89e2785c..5848e733c 100644 --- a/problems/patching-array/README.md +++ b/problems/patching-array/README.md @@ -11,33 +11,47 @@ ## [330. Patching Array (Hard)](https://leetcode.com/problems/patching-array "按要求补齐数组") -

    Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be formed by the sum of some elements in the array. Return the minimum number of patches required.

    +

    Given a sorted integer array nums and an integer n, add/patch elements to the array such that any number in the range [1, n] inclusive can be formed by the sum of some elements in the array.

    -

    Example 1:

    +

    Return the minimum number of patches required.

    + +

     

    +

    Example 1:

    -Input: nums = [1,3], n = 6
    -Output: 1 
    -Explanation:
    -Combinations of nums are [1], [3], [1,3], which form possible sums of: 1, 3, 4.
    -Now if we add/patch 2 to nums, the combinations are: [1], [2], [3], [1,3], [2,3], [1,2,3].
    -Possible sums are 1, 2, 3, 4, 5, 6, which now covers the range [1, 6].
    -So we only need 1 patch.
    +Input: nums = [1,3], n = 6 +Output: 1 +Explanation: +Combinations of nums are [1], [3], [1,3], which form possible sums of: 1, 3, 4. +Now if we add/patch 2 to nums, the combinations are: [1], [2], [3], [1,3], [2,3], [1,2,3]. +Possible sums are 1, 2, 3, 4, 5, 6, which now covers the range [1, 6]. +So we only need 1 patch. + -

    Example 2:

    +

    Example 2:

    -Input: nums = [1,5,10], n = 20
    +Input: nums = [1,5,10], n = 20
     Output: 2
    -Explanation: The two patches can be [2, 4].
    +Explanation: The two patches can be [2, 4].
     
    -

    Example 3:

    +

    Example 3:

    -Input: nums = [1,2,2], n = 5
    +Input: nums = [1,2,2], n = 5
     Output: 0
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • 1 <= nums[i] <= 104
    • +
    • nums is sorted in ascending order.
    • +
    • 1 <= n <= 231 - 1
    • +
    + ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/primary-department-for-each-employee/README.md b/problems/primary-department-for-each-employee/README.md new file mode 100644 index 000000000..6a4594d23 --- /dev/null +++ b/problems/primary-department-for-each-employee/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../maximize-the-beauty-of-the-garden "Maximize the Beauty of the Garden") +                 +[Next >](../check-if-one-string-swap-can-make-strings-equal "Check if One String Swap Can Make Strings Equal") + +## [1789. Primary Department for Each Employee (Easy)](https://leetcode.com/problems/primary-department-for-each-employee "") + + diff --git a/problems/primary-department-for-each-employee/mysql_schemas.sql b/problems/primary-department-for-each-employee/mysql_schemas.sql new file mode 100644 index 000000000..bae508bb0 --- /dev/null +++ b/problems/primary-department-for-each-employee/mysql_schemas.sql @@ -0,0 +1,9 @@ +Create table If Not Exists Employee (employee_id int, department_id int, primary_flag ENUM('Y','N')); +Truncate table Employee; +insert into Employee (employee_id, department_id, primary_flag) values ('1', '1', 'N'); +insert into Employee (employee_id, department_id, primary_flag) values ('2', '1', 'Y'); +insert into Employee (employee_id, department_id, primary_flag) values ('2', '2', 'N'); +insert into Employee (employee_id, department_id, primary_flag) values ('3', '3', 'N'); +insert into Employee (employee_id, department_id, primary_flag) values ('4', '2', 'N'); +insert into Employee (employee_id, department_id, primary_flag) values ('4', '3', 'Y'); +insert into Employee (employee_id, department_id, primary_flag) values ('4', '4', 'N'); diff --git a/problems/product-of-array-except-self/README.md b/problems/product-of-array-except-self/README.md index 1fad35bc7..722405440 100644 --- a/problems/product-of-array-except-self/README.md +++ b/problems/product-of-array-except-self/README.md @@ -11,21 +11,34 @@ ## [238. Product of Array Except Self (Medium)](https://leetcode.com/problems/product-of-array-except-self "除自身以外数组的乘积") -

    Given an array nums of n integers where n > 1,  return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].

    +

    Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].

    -

    Example:

    +

    The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.

    -
    -Input:  [1,2,3,4]
    -Output: [24,12,8,6]
    +

     

    +

    Example 1:

    +
    Input: nums = [1,2,3,4]
    +Output: [24,12,8,6]
    +

    Example 2:

    +
    Input: nums = [-1,1,0,-3,3]
    +Output: [0,0,9,0,0]
     
    - -

    Constraint: It's guaranteed that the product of the elements of any prefix or suffix of the array (including the whole array) fits in a 32 bit integer.

    - -

    Note: Please solve it without division and in O(n).

    - -

    Follow up:
    -Could you solve it with constant space complexity? (The output array does not count as extra space for the purpose of space complexity analysis.)

    +

     

    +

    Constraints:

    + +
      +
    • 2 <= nums.length <= 105
    • +
    • -30 <= nums[i] <= 30
    • +
    • The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.
    • +
    + +

     

    +

    Follow up:

    + +
      +
    • Could you solve it in O(n) time complexity and without using division?
    • +
    • Could you solve it with O(1) constant space complexity? (The output array does not count as extra space for space complexity analysis.)
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/pyramid-transition-matrix/README.md b/problems/pyramid-transition-matrix/README.md index d09d7af8c..69faa941a 100644 --- a/problems/pyramid-transition-matrix/README.md +++ b/problems/pyramid-transition-matrix/README.md @@ -11,20 +11,21 @@ ## [756. Pyramid Transition Matrix (Medium)](https://leetcode.com/problems/pyramid-transition-matrix "金字塔转换矩阵") -

    We are stacking blocks to form a pyramid. Each block has a color which is a one letter string.

    +

    We are stacking blocks to form a pyramid. Each block has a color which is a one-letter string.

    We are allowed to place any color block C on top of two adjacent blocks of colors A and B, if and only if ABC is an allowed triple.

    -

    We start with a bottom row of bottom, represented as a single string. We also start with a list of allowed triples allowed. Each allowed triple is represented as a string of length 3.

    +

    We start with a bottom row of bottom, represented as a single string. We also start with a list of allowed triples allowed. Each allowed triple is represented as a string of length 3.

    -

    Return true if we can build the pyramid all the way to the top, otherwise false.

    +

    Return true if we can build the pyramid all the way to the top, otherwise false.

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input: bottom = "BCD", allowed = ["BCG", "CDE", "GEA", "FFF"]
    -Output: true
    -Explanation:
    +Input: bottom = "BCD", allowed = ["BCG","CDE","GEA","FFF"]
    +Output: true
    +Explanation:
     We can stack the pyramid like this:
         A
        / \
    @@ -32,17 +33,16 @@ We can stack the pyramid like this:
      / \ / \
     B   C   D
     
    -We are allowed to place G on top of B and C because BCG is an allowed triple.  Similarly, we can place E on top of C and D, then A on top of G and E.
    - -

     

    +We are allowed to place G on top of B and C because BCG is an allowed triple. Similarly, we can place E on top of C and D, then A on top of G and E. +
    -

    Example 2:

    +

    Example 2:

    -Input: bottom = "AABA", allowed = ["AAA", "AAB", "ABA", "ABB", "BAC"]
    -Output: false
    -Explanation:
    -We can't stack the pyramid to the top.
    +Input: bottom = "AABA", allowed = ["AAA","AAB","ABA","ABB","BAC"]
    +Output: false
    +Explanation:
    +We cannot stack the pyramid to the top.
     Note that there could be allowed triples (A, B, C) and (A, B, D) with C != D.
     
    @@ -50,9 +50,10 @@ Note that there could be allowed triples (A, B, C) and (A, B, D) with C != D.

    Constraints:

      -
    • bottom will be a string with length in range [2, 8].
    • -
    • allowed will have length in range [0, 200].
    • -
    • Letters in all strings will be chosen from the set {'A', 'B', 'C', 'D', 'E', 'F', 'G'}.
    • +
    • 2 <= bottom.length <= 8
    • +
    • 0 <= allowed.length <= 200
    • +
    • allowed[i].length == 3
    • +
    • The letters in all input strings are from the set {'A', 'B', 'C', 'D', 'E', 'F', 'G'}.
    ### Related Topics diff --git a/problems/range-sum-query-2d-immutable/README.md b/problems/range-sum-query-2d-immutable/README.md index 0798fa03e..43fb0ece6 100644 --- a/problems/range-sum-query-2d-immutable/README.md +++ b/problems/range-sum-query-2d-immutable/README.md @@ -11,36 +11,44 @@ ## [304. Range Sum Query 2D - Immutable (Medium)](https://leetcode.com/problems/range-sum-query-2d-immutable "二维区域和检索 - 矩阵不可变") -

    Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).

    +

    Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).

    -

    -Range Sum Query 2D
    -The above rectangle (with the red border) is defined by (row1, col1) = (2, 1) and (row2, col2) = (4, 3), which contains sum = 8. -

    +

    Implement the NumMatrix class:

    -

    Example:
    +

      +
    • NumMatrix(int[][] matrix) initializes the object with the integer matrix matrix.
    • +
    • int sumRegion(int row1, int col1, int row2, int col2) returns the sum of the elements of the matrix array inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).
    • +
    + +

     

    +

    Example 1:

    +
    -Given matrix = [
    -  [3, 0, 1, 4, 2],
    -  [5, 6, 3, 2, 1],
    -  [1, 2, 0, 1, 5],
    -  [4, 1, 0, 1, 7],
    -  [1, 0, 3, 0, 5]
    -]
    -
    -sumRegion(2, 1, 4, 3) -> 8
    -sumRegion(1, 1, 2, 2) -> 11
    -sumRegion(1, 2, 2, 4) -> 12
    +Input
    +["NumMatrix", "sumRegion", "sumRegion", "sumRegion"]
    +[[[[3, 0, 1, 4, 2], [5, 6, 3, 2, 1], [1, 2, 0, 1, 5], [4, 1, 0, 1, 7], [1, 0, 3, 0, 5]]], [2, 1, 4, 3], [1, 1, 2, 2], [1, 2, 2, 4]]
    +Output
    +[null, 8, 11, 12]
    +
    +Explanation
    +NumMatrix numMatrix = new NumMatrix([[3, 0, 1, 4, 2], [5, 6, 3, 2, 1], [1, 2, 0, 1, 5], [4, 1, 0, 1, 7], [1, 0, 3, 0, 5]]);
    +numMatrix.sumRegion(2, 1, 4, 3); // return 8 (i.e sum of the red rectangele).
    +numMatrix.sumRegion(1, 1, 2, 2); // return 11 (i.e sum of the green rectangele).
    +numMatrix.sumRegion(1, 2, 2, 4); // return 12 (i.e sum of the blue rectangele).
     
    -

    - -

    Note:
    -

      -
    1. You may assume that the matrix does not change.
    2. -
    3. There are many calls to sumRegion function.
    4. -
    5. You may assume that row1 ≤ row2 and col1 ≤ col2.
    6. -
    -

    + +

     

    +

    Constraints:

    + +
      +
    • m == matrix.length
    • +
    • n == matrix[i].length
    • +
    • 1 <= m, n <= 200
    • +
    • -105 <= matrix[i][j] <= 105
    • +
    • 0 <= row1 <= row2 < m
    • +
    • 0 <= col1 <= col2 < n
    • +
    • At most 104 calls will be made to sumRegion.
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/range-sum-query-immutable/README.md b/problems/range-sum-query-immutable/README.md index cbc0d592c..e175b5c73 100644 --- a/problems/range-sum-query-immutable/README.md +++ b/problems/range-sum-query-immutable/README.md @@ -11,13 +11,13 @@ ## [303. Range Sum Query - Immutable (Easy)](https://leetcode.com/problems/range-sum-query-immutable "区域和检索 - 数组不可变") -

    Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.

    +

    Given an integer array nums, find the sum of the elements between indices left and right inclusive, where (left <= right).

    -

    Implement the NumArray class:

    +

    Implement the NumArray class:

      -
    • NumArray(int[] nums) Initializes the object with the integer array nums.
    • -
    • int sumRange(int i, int j) Return the sum of the elements of the nums array in the range [i, j] inclusive (i.e., sum(nums[i], nums[i + 1], ... , nums[j]))
    • +
    • NumArray(int[] nums) initializes the object with the integer array nums.
    • +
    • int sumRange(int left, int right) returns the sum of the elements of the nums array in the range [left, right] inclusive (i.e., sum(nums[left], nums[left + 1], ... , nums[right])).

     

    @@ -41,9 +41,9 @@ numArray.sumRange(0, 5); // return -3 ((-2) + 0 + 3 + (-5) + 2 + (-1))

    Constraints:

      -
    • 0 <= nums.length <= 104
    • -
    • -105 <= nums[i] <= 105
    • -
    • 0 <= i <= j < nums.length
    • +
    • 1 <= nums.length <= 104
    • +
    • -105 <= nums[i] <= 105
    • +
    • 0 <= left <= right < nums.length
    • At most 104 calls will be made to sumRange.
    diff --git a/problems/range-sum-query-mutable/README.md b/problems/range-sum-query-mutable/README.md index 2fa493df9..10c0e3c8c 100644 --- a/problems/range-sum-query-mutable/README.md +++ b/problems/range-sum-query-mutable/README.md @@ -16,9 +16,9 @@

    Implement the NumArray class:

      -
    • NumArray(int[] nums) Initializes the object with the integer array nums.
    • -
    • void update(int index, int val) Updates the value of nums[index] to be val.
    • -
    • int sumRange(int left, int right) Returns the sum of the subarray nums[left, right] (i.e., nums[left] + nums[left + 1], ..., nums[right]).
    • +
    • NumArray(int[] nums) initializes the object with the integer array nums.
    • +
    • void update(int index, int val) updates the value of nums[index] to be val.
    • +
    • int sumRange(int left, int right) returns the sum of the subarray nums[left, right] (i.e., nums[left] + nums[left + 1], ..., nums[right]).

     

    diff --git a/problems/rearrange-products-table/README.md b/problems/rearrange-products-table/README.md new file mode 100644 index 000000000..160e6e193 --- /dev/null +++ b/problems/rearrange-products-table/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../count-pairs-of-equal-substrings-with-minimum-difference "Count Pairs of Equal Substrings With Minimum Difference") +                 +[Next >](../second-largest-digit-in-a-string "Second Largest Digit in a String") + +## [1795. Rearrange Products Table (Easy)](https://leetcode.com/problems/rearrange-products-table "") + + diff --git a/problems/rearrange-products-table/mysql_schemas.sql b/problems/rearrange-products-table/mysql_schemas.sql new file mode 100644 index 000000000..80706d663 --- /dev/null +++ b/problems/rearrange-products-table/mysql_schemas.sql @@ -0,0 +1,4 @@ +Create table If Not Exists Products (product_id int, store1 int, store2 int, store3 int); +Truncate table Products; +insert into Products (product_id, store1, store2, store3) values ('0', '95', '100', '105'); +insert into Products (product_id, store1, store2, store3) values ('1', '70', 'None', '80'); diff --git a/problems/reconstruct-itinerary/README.md b/problems/reconstruct-itinerary/README.md index 5038676bc..bba68f27a 100644 --- a/problems/reconstruct-itinerary/README.md +++ b/problems/reconstruct-itinerary/README.md @@ -11,33 +11,44 @@ ## [332. Reconstruct Itinerary (Medium)](https://leetcode.com/problems/reconstruct-itinerary "重新安排行程") -

    Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus, the itinerary must begin with JFK.

    +

    You are given a list of airline tickets where tickets[i] = [fromi, toi] represent the departure and the arrival airports of one flight. Reconstruct the itinerary in order and return it.

    -

    Note:

    +

    All of the tickets belong to a man who departs from "JFK", thus, the itinerary must begin with "JFK". If there are multiple valid itineraries, you should return the itinerary that has the smallest lexical order when read as a single string.

    -
      -
    1. If there are multiple valid itineraries, you should return the itinerary that has the smallest lexical order when read as a single string. For example, the itinerary ["JFK", "LGA"] has a smaller lexical order than ["JFK", "LGB"].
    2. -
    3. All airports are represented by three capital letters (IATA code).
    4. -
    5. You may assume all tickets form at least one valid itinerary.
    6. -
    7. One must use all the tickets once and only once.
    8. -
    +
      +
    • For example, the itinerary ["JFK", "LGA"] has a smaller lexical order than ["JFK", "LGB"].
    • +
    -

    Example 1:

    +

    You may assume all tickets form at least one valid itinerary. You must use all the tickets once and only once.

    +

     

    +

    Example 1:

    +
    -Input: [["MUC", "LHR"], ["JFK", "MUC"], ["SFO", "SJC"], ["LHR", "SFO"]]
    -Output: ["JFK", "MUC", "LHR", "SFO", "SJC"]
    +Input: tickets = [["MUC","LHR"],["JFK","MUC"],["SFO","SJC"],["LHR","SFO"]]
    +Output: ["JFK","MUC","LHR","SFO","SJC"]
     
    -

    Example 2:

    - +

    Example 2:

    +
    -Input: [["JFK","SFO"],["JFK","ATL"],["SFO","ATL"],["ATL","JFK"],["ATL","SFO"]]
    -Output: ["JFK","ATL","JFK","SFO","ATL","SFO"]
    -Explanation: Another possible reconstruction is ["JFK","SFO","ATL","JFK","ATL","SFO"].
    -             But it is larger in lexical order.
    +Input: tickets = [["JFK","SFO"],["JFK","ATL"],["SFO","ATL"],["ATL","JFK"],["ATL","SFO"]]
    +Output: ["JFK","ATL","JFK","SFO","ATL","SFO"]
    +Explanation: Another possible reconstruction is ["JFK","SFO","ATL","JFK","ATL","SFO"] but it is larger in lexical order.
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= tickets.length <= 300
    • +
    • tickets[i].length == 2
    • +
    • fromi.length == 3
    • +
    • toi.length == 3
    • +
    • fromi and toi consist of uppercase English letters.
    • +
    • fromi != toi
    • +
    + ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] diff --git a/problems/rectangle-area/README.md b/problems/rectangle-area/README.md index a90cbf5dd..851d6c112 100644 --- a/problems/rectangle-area/README.md +++ b/problems/rectangle-area/README.md @@ -11,21 +11,33 @@ ## [223. Rectangle Area (Medium)](https://leetcode.com/problems/rectangle-area "矩形面积") -

    Find the total area covered by two rectilinear rectangles in a 2D plane.

    +

    Given the coordinates of two rectilinear rectangles in a 2D plane, return the total area covered by the two rectangles.

    -

    Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.

    +

    The first rectangle is defined by its bottom-left corner (A, B) and its top-right corner (C, D).

    -

    Rectangle Area

    +

    The second rectangle is defined by its bottom-left corner (E, F) and its top-right corner (G, H).

    -

    Example:

    +

     

    +

    Example 1:

    +Rectangle Area +
    +Input: A = -3, B = 0, C = 3, D = 4, E = 0, F = -1, G = 9, H = 2
    +Output: 45
    +
    + +

    Example 2:

    -Input: A = -3, B = 0, C = 3, D = 4, E = 0, F = -1, G = 9, H = 2
    -Output: 45
    +Input: A = -2, B = -2, C = 2, D = 2, E = -2, F = -2, G = 2, H = 2 +Output: 16 + -

    Note:

    +

     

    +

    Constraints:

    -

    Assume that the total area is never beyond the maximum possible value of int.

    +
      +
    • -104 <= A, B, C, D, E, F, G, H <= 104
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/rectangles-area/mysql_schemas.sql b/problems/rectangles-area/mysql_schemas.sql index 75f4fb6f3..63988bb64 100644 --- a/problems/rectangles-area/mysql_schemas.sql +++ b/problems/rectangles-area/mysql_schemas.sql @@ -1,5 +1,5 @@ Create table If Not Exists Points (id int, x_value int, y_value int); Truncate table Points; -insert into Points (id, x_value, y_value) values ('1', '2', '8'); -insert into Points (id, x_value, y_value) values ('2', '4', '7'); +insert into Points (id, x_value, y_value) values ('1', '2', '7'); +insert into Points (id, x_value, y_value) values ('2', '4', '8'); insert into Points (id, x_value, y_value) values ('3', '2', '10'); diff --git a/problems/remove-duplicates-from-sorted-array/README.md b/problems/remove-duplicates-from-sorted-array/README.md index f16708618..461920620 100644 --- a/problems/remove-duplicates-from-sorted-array/README.md +++ b/problems/remove-duplicates-from-sorted-array/README.md @@ -9,7 +9,7 @@                  [Next >](../remove-element "Remove Element") -## [26. Remove Duplicates from Sorted Array (Easy)](https://leetcode.com/problems/remove-duplicates-from-sorted-array "删除排序数组中的重复项") +## [26. Remove Duplicates from Sorted Array (Easy)](https://leetcode.com/problems/remove-duplicates-from-sorted-array "删除有序数组中的重复项")

    Given a sorted array nums, remove the duplicates in-place such that each element appears only once and returns the new length.

    diff --git a/problems/remove-invalid-parentheses/README.md b/problems/remove-invalid-parentheses/README.md index afa3e89a4..7007597fa 100644 --- a/problems/remove-invalid-parentheses/README.md +++ b/problems/remove-invalid-parentheses/README.md @@ -11,31 +11,41 @@ ## [301. Remove Invalid Parentheses (Hard)](https://leetcode.com/problems/remove-invalid-parentheses "删除无效的括号") -

    Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.

    +

    Given a string s that contains parentheses and letters, remove the minimum number of invalid parentheses to make the input string valid.

    -

    Note: The input string may contain letters other than the parentheses ( and ).

    +

    Return all the possible results. You may return the answer in any order.

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input: "()())()"
    -Output: ["()()()", "(())()"]
    +Input: s = "()())()"
    +Output: ["(())()","()()()"]
     
    -

    Example 2:

    +

    Example 2:

    -Input: "(a)())()"
    -Output: ["(a)()()", "(a())()"]
    +Input: s = "(a)())()"
    +Output: ["(a())()","(a)()()"]
     
    -

    Example 3:

    +

    Example 3:

    -Input: ")("
    -Output: [""]
    +Input: s = ")("
    +Output: [""]
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 25
    • +
    • s consists of lowercase English letters and parentheses '(' and ')'.
    • +
    • There will be at most 20 parentheses in s.
    • +
    + ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/remove-palindromic-subsequences/README.md b/problems/remove-palindromic-subsequences/README.md index 3e2ee2ab9..ce888c06c 100644 --- a/problems/remove-palindromic-subsequences/README.md +++ b/problems/remove-palindromic-subsequences/README.md @@ -11,13 +11,13 @@ ## [1332. Remove Palindromic Subsequences (Easy)](https://leetcode.com/problems/remove-palindromic-subsequences "删除回文子序列") -

    Given a string s consisting only of letters 'a' and 'b'. In a single step you can remove one palindromic subsequence from s.

    +

    You are given a string s consisting only of letters 'a' and 'b'. In a single step you can remove one palindromic subsequence from s.

    -

    Return the minimum number of steps to make the given string empty.

    +

    Return the minimum number of steps to make the given string empty.

    -

    A string is a subsequence of a given string, if it is generated by deleting some characters of a given string without changing its order.

    +

    A string is a subsequence of a given string if it is generated by deleting some characters of a given string without changing its order. Note that a subsequence does not necessarily need to be contiguous.

    -

    A string is called palindrome if is one that reads the same backward as well as forward.

    +

    A string is called palindrome if is one that reads the same backward as well as forward.

     

    Example 1:

    @@ -25,7 +25,7 @@
     Input: s = "ababa"
     Output: 1
    -Explanation: String is already palindrome
    +Explanation: s is already a palindrome, so its entirety can be removed in a single step.
     

    Example 2:

    @@ -33,7 +33,7 @@
     Input: s = "abb"
     Output: 2
    -Explanation: "abb" -> "bb" -> "". 
    +Explanation: "abb" -> "bb" -> "". 
     Remove palindromic subsequence "a" then "bb".
     
    @@ -42,7 +42,7 @@ Remove palindromic subsequence "a" then "bb".
     Input: s = "baabb"
     Output: 2
    -Explanation: "baabb" -> "b" -> "". 
    +Explanation: "baabb" -> "b" -> "". 
     Remove palindromic subsequence "baab" then "b".
     
    diff --git a/problems/reverse-string/README.md b/problems/reverse-string/README.md index 94874454e..916361916 100644 --- a/problems/reverse-string/README.md +++ b/problems/reverse-string/README.md @@ -11,31 +11,26 @@ ## [344. Reverse String (Easy)](https://leetcode.com/problems/reverse-string "反转字符串") -

    Write a function that reverses a string. The input string is given as an array of characters char[].

    - -

    Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.

    - -

    You may assume all the characters consist of printable ascii characters.

    +

    Write a function that reverses a string. The input string is given as an array of characters s.

     

    - -

    Example 1:

    - -
    -Input: ["h","e","l","l","o"]
    -Output: ["o","l","l","e","h"]
    +
    Input: s = ["h","e","l","l","o"]
    +Output: ["o","l","l","e","h"]
    +

    Example 2:

    +
    Input: s = ["H","a","n","n","a","h"]
    +Output: ["h","a","n","n","a","H"]
     
    +

     

    +

    Constraints:

    -
    -

    Example 2:

    + -
    -Input: ["H","a","n","n","a","h"]
    -Output: ["h","a","n","n","a","H"]
    -
    -
    -
    +

     

    +

    Follow up: Do not allocate extra space for another array. You must do this by modifying the input array in-place with O(1) extra memory.

    ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/second-largest-digit-in-a-string/README.md b/problems/second-largest-digit-in-a-string/README.md new file mode 100644 index 000000000..a25119347 --- /dev/null +++ b/problems/second-largest-digit-in-a-string/README.md @@ -0,0 +1,55 @@ + + + + + + + +[< Previous](../rearrange-products-table "Rearrange Products Table") +                 +[Next >](../design-authentication-manager "Design Authentication Manager") + +## [1796. Second Largest Digit in a String (Easy)](https://leetcode.com/problems/second-largest-digit-in-a-string "字符串中第二大的数字") + +

    Given an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist.

    + +

    An alphanumeric string is a string consisting of lowercase English letters and digits.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "dfa12321afd"
    +Output: 2
    +Explanation: The digits that appear in s are [1, 2, 3]. The second largest digit is 2.
    +
    + +

    Example 2:

    + +
    +Input: s = "abc1111"
    +Output: -1
    +Explanation: The digits that appear in s are [1]. There is no second largest digit. 
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 500
    • +
    • s consists of only lowercase English letters and/or digits.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +First of all, get the distinct characters since we are only interested in those +
    + +
    +Hint 2 +Let's note that there might not be any digits. +
    diff --git a/problems/self-crossing/README.md b/problems/self-crossing/README.md index 5f302c012..1540d2e0c 100644 --- a/problems/self-crossing/README.md +++ b/problems/self-crossing/README.md @@ -11,47 +11,44 @@ ## [335. Self Crossing (Hard)](https://leetcode.com/problems/self-crossing "路径交叉") -

    You are given an array x of n positive numbers. You start at point (0,0) and moves x[0] metres to the north, then x[1] metres to the west, x[2] metres to the south, x[3] metres to the east and so on. In other words, after each move your direction changes counter-clockwise.

    +

    You are given an array of integers distance.

    -

    Write a one-pass algorithm with O(1) extra space to determine, if your path crosses itself, or not.

    +

    You start at point (0,0) on an X-Y plane and you move distance[0] meters to the north, then distance[1] meters to the west, distance[2] meters to the south, distance[3] meters to the east, and so on. In other words, after each move, your direction changes counter-clockwise.

    -

     

    - -

    Example 1:

    +

    Return true if your path crosses itself, and false if it does not.

    +

     

    +

    Example 1:

    +
    -┌───┐
    -│   │
    -└───┼──>
    -    │
    -
    -Input: [2,1,1,2]
    -Output: true
    +Input: distance = [2,1,1,2]
    +Output: true
     
    -

    Example 2:

    +

    Example 2:

    + +
    +Input: distance = [1,2,3,4]
    +Output: false
    +
    +

    Example 3:

    +
    -┌──────┐
    -│      │
    -│
    -│
    -└────────────>
    -
    -Input: [1,2,3,4]
    -Output: false 
    +Input: distance = [1,1,1,1]
    +Output: true
     
    -

    Example 3:

    +

     

    +

    Constraints:

    -
    -┌───┐
    -│   │
    -└───┼>
    +
      +
    • 1 <= distance.length <= 500
    • +
    • 1 <= distance[i] <= 500
    • +
    -Input:
    [1,1,1,1] -Output: true -
    +

     

    +

    Follow up: Could you write a one-pass algorithm with O(1) extra space?

    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/shortest-palindrome/README.md b/problems/shortest-palindrome/README.md index e67ed5a3e..fdb318268 100644 --- a/problems/shortest-palindrome/README.md +++ b/problems/shortest-palindrome/README.md @@ -11,7 +11,9 @@ ## [214. Shortest Palindrome (Hard)](https://leetcode.com/problems/shortest-palindrome "最短回文串") -

    Given a string s, you can convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation.

    +

    You are given a string s. You can convert s to a palindrome by adding characters in front of it.

    + +

    Return the shortest palindrome you can find by performing this transformation.

     

    Example 1:

    diff --git a/problems/smallest-sufficient-team/README.md b/problems/smallest-sufficient-team/README.md index 651b91afb..57d33f517 100644 --- a/problems/smallest-sufficient-team/README.md +++ b/problems/smallest-sufficient-team/README.md @@ -11,13 +11,17 @@ ## [1125. Smallest Sufficient Team (Hard)](https://leetcode.com/problems/smallest-sufficient-team "最小的必要团队") -

    In a project, you have a list of required skills req_skills, and a list of people.  The i-th person people[i] contains a list of skills that person has.

    +

    In a project, you have a list of required skills req_skills, and a list of people. The ith person people[i] contains a list of skills that the person has.

    -

    Consider a sufficient team: a set of people such that for every required skill in req_skills, there is at least one person in the team who has that skill.  We can represent these teams by the index of each person: for example, team = [0, 1, 3] represents the people with skills people[0], people[1], and people[3].

    +

    Consider a sufficient team: a set of people such that for every required skill in req_skills, there is at least one person in the team who has that skill. We can represent these teams by the index of each person.

    -

    Return any sufficient team of the smallest possible size, represented by the index of each person.

    +
      +
    • For example, team = [0, 1, 3] represents the people with skills people[0], people[1], and people[3].
    • +
    + +

    Return any sufficient team of the smallest possible size, represented by the index of each person. You may return the answer in any order.

    -

    You may return the answer in any order.  It is guaranteed an answer exists.

    +

    It is guaranteed an answer exists.

     

    Example 1:

    @@ -32,11 +36,15 @@
    • 1 <= req_skills.length <= 16
    • +
    • 1 <= req_skills[i].length <= 16
    • +
    • req_skills[i] consists of lowercase English letters.
    • +
    • All the strings of req_skills are unique.
    • 1 <= people.length <= 60
    • -
    • 1 <= people[i].length, req_skills[i].length, people[i][j].length <= 16
    • -
    • Elements of req_skills and people[i] are (respectively) distinct.
    • -
    • req_skills[i][j], people[i][j][k] are lowercase English letters.
    • -
    • Every skill in people[i] is a skill in req_skills.
    • +
    • 0 <= people[i].length <= 16
    • +
    • 1 <= people[i][j].length <= 16
    • +
    • people[i][j] consists of lowercase English letters.
    • +
    • All the strings of people[i] are unique.
    • +
    • Every skill in people[i] is a skill in req_skills.
    • It is guaranteed a sufficient team exists.
    diff --git a/problems/sort-transformed-array/README.md b/problems/sort-transformed-array/README.md index 1d70cd120..5693c762d 100644 --- a/problems/sort-transformed-array/README.md +++ b/problems/sort-transformed-array/README.md @@ -34,6 +34,7 @@ ### Related Topics + [[Sort](../../tag/sort/README.md)] [[Math](../../tag/math/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/statistics-from-a-large-sample/README.md b/problems/statistics-from-a-large-sample/README.md index 519bf51be..531cba012 100644 --- a/problems/statistics-from-a-large-sample/README.md +++ b/problems/statistics-from-a-large-sample/README.md @@ -11,33 +11,56 @@ ## [1093. Statistics from a Large Sample (Medium)](https://leetcode.com/problems/statistics-from-a-large-sample "大样本统计") -

    We sampled integers in the range [0, 255] and stored the results in an array count where count[k] is the number of integers we sampled equal to k.

    +

    You are given a large sample of integers in the range [0, 255]. Since the sample is so large, it is represented by an array count where count[k] is the number of times that k appears in the sample.

    -

    Return the minimum, maximum, mean, median, and mode of the sample respectively, as an array of floating-point numbers. Answers within 10-5 of the actual answer will be considered accepted.

    - -

    The mode is guaranteed to be unique.

    - -

    The median of a sample is:

    +

    Calculate the following statistics:

      -
    • The middle element, if the elements of the sample were sorted and the number of elements is odd, or
    • -
    • The average of the middle two elements, if the elements of the sample were sorted and the number of elements is even.
    • +
    • minimum: The minimum element in the sample.
    • +
    • maximum: The maximum element in the sample.
    • +
    • mean: The average of the sample, calculated as the total sum of all elements divided by the total number of elements.
    • +
    • median: +
        +
      • If the sample has an odd number of elements, then the median is the middle element once the sample is sorted.
      • +
      • If the sample has an even number of elements, then the median is the average of the two middle elements once the sample is sorted.
      • +
      +
    • +
    • mode: The number that appears the most in the sample. It is guaranteed to be unique.
    +

    Return the statistics of the sample as an array of floating-point numbers [minimum, maximum, mean, median, mode]. Answers within 10-5 of the actual answer will be accepted.

    +

     

    Example 1:

    -
    Input: count = [0,1,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    +
    +
    +Input: count = [0,1,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
     Output: [1.00000,3.00000,2.37500,2.50000,3.00000]
    -

    Example 2:

    -
    Input: count = [0,4,3,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    +Explanation: The sample represented by count is [1,2,2,2,3,3,3,3].
    +The minimum and maximum are 1 and 3 respectively.
    +The mean is (1+2+2+2+3+3+3+3) / 8 = 19 / 8 = 2.375.
    +Since the size of the sample is even, the median is the average of the two middle elements 2 and 3, which is 2.5.
    +The mode is 3 as it appears the most in the sample.
    +
    + +

    Example 2:

    + +
    +Input: count = [0,4,3,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
     Output: [1.00000,4.00000,2.18182,2.00000,1.00000]
    +Explanation: The sample represented by count is [1,1,1,1,2,2,2,3,3,4,4].
    +The minimum and maximum are 1 and 4 respectively.
    +The mean is (1+1+1+1+2+2+2+3+3+4+4) / 11 = 24 / 11 = 2.18181818... (for display purposes, the output shows the rounded number 2.18182).
    +Since the size of the sample is odd, the median is the middle element 2.
    +The mode is 1 as it appears the most in the sample.
     
    +

     

    Constraints:

    • count.length == 256
    • -
    • 0 <= count[i] <= 256
    • +
    • 0 <= count[i] <= 109
    • 1 <= sum(count) <= 109
    • The mode of the sample that count represents is unique.
    diff --git a/problems/student-attendance-record-i/README.md b/problems/student-attendance-record-i/README.md index db14aff35..e360626a9 100644 --- a/problems/student-attendance-record-i/README.md +++ b/problems/student-attendance-record-i/README.md @@ -11,25 +11,40 @@ ## [551. Student Attendance Record I (Easy)](https://leetcode.com/problems/student-attendance-record-i "学生出勤记录 I") -You are given a string s representing an attendance record for a student. The record only contains the following three characters: +

    You are given a string s representing an attendance record for a student where each character signifies whether the student was absent, late, or present on that day. The record only contains the following three characters:

    +
    • 'A': Absent.
    • 'L': Late.
    • 'P': Present.
    -

    A student could be rewarded if his attendance record does not contain more than one 'A' (absent) or more than two consecutive 'L' (late).

    +

    The student is eligible for an attendance award if they meet both of the following criteria:

    -

    Return true if the student could be rewarded according to his attendance record, and false otherwise.

    +
      +
    • The student was absent ('A') for strictly fewer than 2 days total.
    • +
    • The student was never late ('L') for 3 or more consecutive days.
    • +
    + +

    Return true if the student is eligible for an attendance award, or false otherwise.

     

    Example 1:

    -
    Input: s = "PPALLP"
    +
    +
    +Input: s = "PPALLP"
     Output: true
    -

    Example 2:

    -
    Input: s = "PPALLL"
    +Explanation: The student has fewer than 2 absences and was never late 3 or more consecutive days.
    +
    + +

    Example 2:

    + +
    +Input: s = "PPALLL"
     Output: false
    +Explanation: The student was late 3 consecutive days in the last 3 days, so is not eligible for the award.
     
    +

     

    Constraints:

    diff --git a/problems/student-attendance-record-ii/README.md b/problems/student-attendance-record-ii/README.md index 20b3cfd87..2db7f1dce 100644 --- a/problems/student-attendance-record-ii/README.md +++ b/problems/student-attendance-record-ii/README.md @@ -11,9 +11,7 @@ ## [552. Student Attendance Record II (Hard)](https://leetcode.com/problems/student-attendance-record-ii "学生出勤记录 II") -

    Given an integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, return it modulo 109 + 7.

    - -

    A student attendance record is a string that only contains the following three characters:

    +

    An attendance record for a student can be represented as a string where each character signifies whether the student was absent, late, or present on that day. The record only contains the following three characters:

    • 'A': Absent.
    • @@ -21,7 +19,14 @@
    • 'P': Present.
    -

    A record is regarded as rewardable if it does not contain more than one 'A' (absent) or more than two consecutive 'L' (late).

    +

    Any student is eligible for an attendance award if they meet both of the following criteria:

    + +
      +
    • The student was absent ('A') for strictly fewer than 2 days total.
    • +
    • The student was never late ('L') for 3 or more consecutive days.
    • +
    + +

    Given an integer n, return the number of possible attendance records of length n that make a student eligible for an attendance award. The answer may be very large, so return it modulo 109 + 7.

     

    Example 1:

    @@ -29,9 +34,9 @@
     Input: n = 2
     Output: 8
    -Explanation: There are 8 records with length 2 will be regarded as rewardable:
    -"PP" , "AP", "PA", "LP", "PL", "AL", "LA", "LL"
    -Only "AA" won't be regarded as rewardable owing to more than one absent time.
    +Explanation: There are 8 records with length 2 that are eligible for an award:
    +"PP", "AP", "PA", "LP", "PL", "AL", "LA", "LL"
    +Only "AA" is not eligible because there are 2 absences (there need to be fewer than 2).
     

    Example 2:

    diff --git a/problems/super-egg-drop/README.md b/problems/super-egg-drop/README.md index 940fd886a..092bac05e 100644 --- a/problems/super-egg-drop/README.md +++ b/problems/super-egg-drop/README.md @@ -11,17 +11,13 @@ ## [887. Super Egg Drop (Hard)](https://leetcode.com/problems/super-egg-drop "鸡蛋掉落") -

    You are given k eggs, and you have access to a building with n floors labeled from 1 to n.

    +

    You are given k identical eggs and you have access to a building with n floors labeled from 1 to n.

    -

    Each egg is identical in function, and if an egg breaks, you cannot drop it again.

    +

    You know that there exists a floor f where 0 <= f <= n such that any egg dropped at a floor higher than f will break, and any egg dropped at or below floor f will not break.

    -

    You know that there exists a floor f with 0 <= f <= n such that any egg dropped at a floor higher than f will break, and any egg dropped at or below floor f will not break.

    +

    Each move, you may take an unbroken egg and drop it from any floor x (where 1 <= x <= n). If the egg breaks, you can no longer use it. However, if the egg does not break, you may reuse it in future moves.

    -

    Each move, you may take an egg (if you have an unbroken one) and drop it from any floor x (with 1 <= x <= n).

    - -

    Your goal is to know with certainty what the value of f is.

    - -

    Return the minimum number of moves that you need to know with certainty the value of f.

    +

    Return the minimum number of moves that you need to determine with certainty what the value of f is.

     

    Example 1:

    @@ -30,10 +26,10 @@ Input: k = 1, n = 2 Output: 2 Explanation: -Drop the egg from floor 1. If it breaks, we know with certainty that f = 0. -Otherwise, drop the egg from floor 2. If it breaks, we know with certainty that f = 1. -If it did not break, then we know with certainty f = 2. -Hence, we needed 2 moves in the worst case to know what f is with certainty. +Drop the egg from floor 1. If it breaks, we know that f = 0. +Otherwise, drop the egg from floor 2. If it breaks, we know that f = 1. +If it does not break, then we know f = 2. +Hence, we need at minimum 2 moves to determine with certainty what the value of f is.

    Example 2:

    diff --git a/problems/swap-salary/README.md b/problems/swap-salary/README.md index f9e7f212c..920f9aafe 100644 --- a/problems/swap-salary/README.md +++ b/problems/swap-salary/README.md @@ -57,6 +57,6 @@ Result table: | 3 | C | f | 5500 | | 4 | D | m | 500 | +----+------+-----+--------+ -(1, A) and (2, C) were changed from 'm' to 'f'. +(1, A) and (3, C) were changed from 'm' to 'f'. (2, B) and (4, D) were changed from 'f' to 'm'.
    diff --git a/problems/top-k-frequent-elements/README.md b/problems/top-k-frequent-elements/README.md index 0ad927e36..d54678f47 100644 --- a/problems/top-k-frequent-elements/README.md +++ b/problems/top-k-frequent-elements/README.md @@ -11,32 +11,28 @@ ## [347. Top K Frequent Elements (Medium)](https://leetcode.com/problems/top-k-frequent-elements "前 K 个高频元素") -

    Given a non-empty array of integers, return the k most frequent elements.

    +

    Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.

    +

     

    Example 1:

    - -
    -Input: nums = [1,1,1,2,2,3], k = 2
    -Output: [1,2]
    +
    Input: nums = [1,1,1,2,2,3], k = 2
    +Output: [1,2]
    +

    Example 2:

    +
    Input: nums = [1], k = 1
    +Output: [1]
     
    - -
    -

    Example 2:

    - -
    -Input: nums = [1], k = 1
    -Output: [1]
    -
    - -

    Note:

    +

     

    +

    Constraints:

      -
    • You may assume k is always valid, 1 ≤ k ≤ number of unique elements.
    • -
    • Your algorithm's time complexity must be better than O(n log n), where n is the array's size.
    • -
    • It's guaranteed that the answer is unique, in other words the set of the top k frequent elements is unique.
    • -
    • You can return the answer in any order.
    • +
    • 1 <= nums.legth <= 105
    • +
    • k is in the range [1, the number of unique elements in the array].
    • +
    • It is guaranteed that the answer is unique.
    +

     

    +

    Follow up: Your algorithm's time complexity must be better than O(n log n), where n is the array's size.

    + ### Related Topics [[Heap](../../tag/heap/README.md)] [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/valid-anagram/README.md b/problems/valid-anagram/README.md index 2c97538c5..cc14f2c77 100644 --- a/problems/valid-anagram/README.md +++ b/problems/valid-anagram/README.md @@ -11,27 +11,26 @@ ## [242. Valid Anagram (Easy)](https://leetcode.com/problems/valid-anagram "有效的字母异位词") -

    Given two strings s and , write a function to determine if t is an anagram of s.

    - -

    Example 1:

    - -
    -Input: s = "anagram", t = "nagaram"
    -Output: true
    -
    - -

    Example 2:

    - -
    -Input: s = "rat", t = "car"
    -Output: false
    +

    Given two strings s and t, return true if t is an anagram of s, and false otherwise.

    + +

     

    +

    Example 1:

    +
    Input: s = "anagram", t = "nagaram"
    +Output: true
    +

    Example 2:

    +
    Input: s = "rat", t = "car"
    +Output: false
     
    +

     

    +

    Constraints:

    -

    Note:
    -You may assume the string contains only lowercase alphabets.

    +
      +
    • 1 <= s.length, t.length <= 5 * 104
    • +
    • s and t consist of lowercase English letters.
    • +
    -

    Follow up:
    -What if the inputs contain unicode characters? How would you adapt your solution to such case?

    +

     

    +

    Follow up: What if the inputs contain Unicode characters? How would you adapt your solution to such a case?

    ### Related Topics [[Sort](../../tag/sort/README.md)] diff --git a/problems/verify-preorder-serialization-of-a-binary-tree/README.md b/problems/verify-preorder-serialization-of-a-binary-tree/README.md index a8a6b2c3b..871ee6ad3 100644 --- a/problems/verify-preorder-serialization-of-a-binary-tree/README.md +++ b/problems/verify-preorder-serialization-of-a-binary-tree/README.md @@ -11,44 +11,41 @@ ## [331. Verify Preorder Serialization of a Binary Tree (Medium)](https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree "验证二叉树的前序序列化") -

    One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as #.

    - -
    -     _9_
    -    /   \
    -   3     2
    -  / \   / \
    - 4   1  #  6
    -/ \ / \   / \
    -# # # #   # #
    +

    One way to serialize a binary tree is to use preorder traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as '#'.

    + +

    For example, the above binary tree can be serialized to the string "9,3,4,#,#,1,#,#,2,#,6,#,#", where '#' represents a null node.

    + +

    Given a string of comma-separated values preorder, return true if it is a correct preorder traversal serialization of a binary tree.

    + +

    It is guaranteed that each comma-separated value in the string must be either an integer or a character '#' representing null pointer.

    + +

    You may assume that the input format is always valid.

    + +
      +
    • For example, it could never contain two consecutive commas, such as "1,,3".
    • +
    + +

     

    +

    Example 1:

    +
    Input: preorder = "9,3,4,#,#,1,#,#,2,#,6,#,#"
    +Output: true
    +

    Example 2:

    +
    Input: preorder = "1,#"
    +Output: false
    +

    Example 3:

    +
    Input: preorder = "9,#,#,1"
    +Output: false
     
    +

     

    +

    Constraints:

    -

    For example, the above binary tree can be serialized to the string "9,3,4,#,#,1,#,#,2,#,6,#,#", where # represents a null node.

    +
      +
    • 1 <= preorder.length <= 104
    • +
    • preoder consist of integers in the range [0, 100] and '#' separated by commas ','.
    • +
    -

    Given a string of comma separated values, verify whether it is a correct preorder traversal serialization of a binary tree. Find an algorithm without reconstructing the tree.

    - -

    Each comma separated value in the string must be either an integer or a character '#' representing null pointer.

    - -

    You may assume that the input format is always valid, for example it could never contain two consecutive commas such as "1,,3".

    - -

    Example 1:

    - -
    -Input: "9,3,4,#,#,1,#,#,2,#,6,#,#"
    -Output: true
    - -

    Example 2:

    - -
    -Input: "1,#"
    -Output: false
    -
    - -

    Example 3:

    - -
    -Input: "9,#,#,1"
    -Output: false
    +

     

    +

    Follow up: Find an algorithm without reconstructing the tree.

    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/wiggle-subsequence/README.md b/problems/wiggle-subsequence/README.md index 546c59697..73fab926b 100644 --- a/problems/wiggle-subsequence/README.md +++ b/problems/wiggle-subsequence/README.md @@ -11,38 +11,51 @@ ## [376. Wiggle Subsequence (Medium)](https://leetcode.com/problems/wiggle-subsequence "摆动序列") -

    A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a wiggle sequence.

    +

    Given an integer array nums, return the length of the longest wiggle sequence.

    -

    For example, [1,7,4,9,2,5] is a wiggle sequence because the differences (6,-3,5,-7,3) are alternately positive and negative. In contrast, [1,4,7,2,5] and [1,7,4,5,5] are not wiggle sequences, the first because its first two differences are positive and the second because its last difference is zero.

    +

    A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a wiggle sequence.

    -

    Given a sequence of integers, return the length of the longest subsequence that is a wiggle sequence. A subsequence is obtained by deleting some number of elements (eventually, also zero) from the original sequence, leaving the remaining elements in their original order.

    +
      +
    • For example, [1, 7, 4, 9, 2, 5] is a wiggle sequence because the differences (6, -3, 5, -7, 3) are alternately positive and negative.
    • +
    • In contrast, [1, 4, 7, 2, 5] and [1, 7, 4, 5, 5] are not wiggle sequences, the first because its first two differences are positive and the second because its last difference is zero.
    • +
    +

    A subsequence is obtained by deleting some elements (eventually, also zero) from the original sequence, leaving the remaining elements in their original order.

    + +

     

    Example 1:

    -Input: [1,7,4,9,2,5]
    -Output: 6
    -Explanation: The entire sequence is a wiggle sequence.
    +Input: nums = [1,7,4,9,2,5] +Output: 6 +Explanation: The entire sequence is a wiggle sequence. +
    -

    Example 2:

    -Input: [1,17,5,10,13,15,10,5,16,8]
    -Output: 7
    -Explanation: There are several subsequences that achieve this length. One is [1,17,10,13,10,16,8].
    +Input: nums = [1,17,5,10,13,15,10,5,16,8] +Output: 7 +Explanation: There are several subsequences that achieve this length. One is [1,17,10,13,10,16,8]. +
    -

    Example 3:

    -Input: [1,2,3,4,5,6,7,8,9]
    -Output: 2
    +Input: nums = [1,2,3,4,5,6,7,8,9] +Output: 2 +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • 0 <= nums[i] <= 1000
    • +
    -

    Follow up:
    -Can you do it in O(n) time?

    - - +

     

    +

    Follow up: Could you solve this in O(n) time?

    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/word-ladder-ii/README.md b/problems/word-ladder-ii/README.md index cc6960a6a..cfa5eac50 100644 --- a/problems/word-ladder-ii/README.md +++ b/problems/word-ladder-ii/README.md @@ -11,16 +11,15 @@ ## [126. Word Ladder II (Hard)](https://leetcode.com/problems/word-ladder-ii "单词接龙 II") -

    A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words such that:

    +

    A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that:

      -
    • The first word in the sequence is beginWord.
    • -
    • The last word in the sequence is endWord.
    • -
    • Only one letter is different between each adjacent pair of words in the sequence.
    • -
    • Every word in the sequence is in wordList.
    • +
    • Every adjacent pair of words differs by a single letter.
    • +
    • Every si for 1 <= i <= k is in wordList. Note that beginWord does not need to be in wordList.
    • +
    • sk == endWord
    -

    Given two words, beginWord and endWord, and a dictionary wordList, return all the shortest transformation sequences from beginWord to endWord, or an empty list if no such sequence exists.

    +

    Given two words, beginWord and endWord, and a dictionary wordList, return all the shortest transformation sequences from beginWord to endWord, or an empty list if no such sequence exists. Each sequence should be returned as a list of the words [beginWord, s1, s2, ..., sk].

     

    Example 1:

    @@ -28,6 +27,9 @@
     Input: beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log","cog"]
     Output: [["hit","hot","dot","dog","cog"],["hit","hot","lot","log","cog"]]
    +Explanation: There are 2 shortest transformation sequences:
    +"hit" -> "hot" -> "dot" -> "dog" -> "cog"
    +"hit" -> "hot" -> "lot" -> "log" -> "cog"
     

    Example 2:

    @@ -35,7 +37,7 @@
     Input: beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log"]
     Output: []
    -Explanation: The endWord "cog" is not in wordList, therefore no possible transformation.
    +Explanation: The endWord "cog" is not in wordList, therefore there is no valid transformation sequence.
     

     

    @@ -48,7 +50,7 @@
  • wordList[i].length == beginWord.length
  • beginWord, endWord, and wordList[i] consist of lowercase English letters.
  • beginWord != endWord
  • -
  • All the strings in wordList are unique.
  • +
  • All the words in wordList are unique.
  • ### Related Topics diff --git a/problems/word-ladder/README.md b/problems/word-ladder/README.md index 980ee23d7..3464ba32d 100644 --- a/problems/word-ladder/README.md +++ b/problems/word-ladder/README.md @@ -11,13 +11,12 @@ ## [127. Word Ladder (Hard)](https://leetcode.com/problems/word-ladder "单词接龙") -

    A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words such that:

    +

    A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that:

      -
    • The first word in the sequence is beginWord.
    • -
    • The last word in the sequence is endWord.
    • -
    • Only one letter is different between each adjacent pair of words in the sequence.
    • -
    • Every word in the sequence is in wordList.
    • +
    • Every adjacent pair of words differs by a single letter.
    • +
    • Every si for 1 <= i <= k is in wordList. Note that beginWord does not need to be in wordList.
    • +
    • sk == endWord

    Given two words, beginWord and endWord, and a dictionary wordList, return the number of words in the shortest transformation sequence from beginWord to endWord, or 0 if no such sequence exists.

    @@ -28,7 +27,7 @@
     Input: beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log","cog"]
     Output: 5
    -Explanation: One shortest transformation is "hit" -> "hot" -> "dot" -> "dog" -> "cog" with 5 words.
    +Explanation: One shortest transformation sequence is "hit" -> "hot" -> "dot" -> "dog" -> cog", which is 5 words long.
     

    Example 2:

    @@ -36,7 +35,7 @@
     Input: beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log"]
     Output: 0
    -Explanation: The endWord "cog" is not in wordList, therefore there is no possible transformation.
    +Explanation: The endWord "cog" is not in wordList, therefore there is no valid transformation sequence.
     

     

    @@ -49,7 +48,7 @@
  • wordList[i].length == beginWord.length
  • beginWord, endWord, and wordList[i] consist of lowercase English letters.
  • beginWord != endWord
  • -
  • All the strings in wordList are unique.
  • +
  • All the words in wordList are unique.
  • ### Related Topics diff --git a/problems/x-of-a-kind-in-a-deck-of-cards/README.md b/problems/x-of-a-kind-in-a-deck-of-cards/README.md index 2cb334781..6c076aa73 100644 --- a/problems/x-of-a-kind-in-a-deck-of-cards/README.md +++ b/problems/x-of-a-kind-in-a-deck-of-cards/README.md @@ -13,7 +13,7 @@

    In a deck of cards, each card has an integer written on it.

    -

    Return true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more groups of cards, where:

    +

    Return true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more groups of cards, where:

    • Each group has exactly X cards.
    • @@ -33,7 +33,7 @@
       Input: deck = [1,1,1,2,2,2,3,3]
      -Output: false´
      +Output: false
       Explanation: No possible partition.
       
      @@ -65,8 +65,8 @@

      Constraints:

        -
      • 1 <= deck.length <= 10^4
      • -
      • 0 <= deck[i] < 10^4
      • +
      • 1 <= deck.length <= 104
      • +
      • 0 <= deck[i] < 104
      ### Related Topics diff --git a/readme/1-300.md b/readme/1-300.md index ee7426b72..c557a377e 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -51,12 +51,12 @@ LeetCode Problems' Solutions [1151-1200] - [1201-1250] - [1251-1300] - [1301-1350] - [1351-1400] - [1401-1450] - [1451-1500] + [1201-1250] + [1251-1300] + [1301-1350] + [1351-1400] + [1401-1450] + [1451-1500] [1501-1550] @@ -66,6 +66,14 @@ LeetCode Problems' Solutions [1701-1750] [1751-1800] + + [1801-1850] + [1851-1900] + [1901-1950] + [1951-2000] + [2001-2050] + [2051-2100] + | # | Title | Solution | Difficulty | @@ -95,7 +103,7 @@ LeetCode Problems' Solutions | 23 | [Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists "合并K个升序链表") | [Go](../problems/merge-k-sorted-lists) | Hard | | 24 | [Swap Nodes in Pairs](https://leetcode.com/problems/swap-nodes-in-pairs "两两交换链表中的节点") | [Go](../problems/swap-nodes-in-pairs) | Medium | | 25 | [Reverse Nodes in k-Group](https://leetcode.com/problems/reverse-nodes-in-k-group "K 个一组翻转链表") | [Go](../problems/reverse-nodes-in-k-group) | Hard | -| 26 | [Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array "删除排序数组中的重复项") | [Go](../problems/remove-duplicates-from-sorted-array) | Easy | +| 26 | [Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array "删除有序数组中的重复项") | [Go](../problems/remove-duplicates-from-sorted-array) | Easy | | 27 | [Remove Element](https://leetcode.com/problems/remove-element "移除元素") | [Go](../problems/remove-element) | Easy | | 28 | [Implement strStr()](https://leetcode.com/problems/implement-strstr "实现 strStr()") | [Go](../problems/implement-strstr) | Easy | | 29 | [Divide Two Integers](https://leetcode.com/problems/divide-two-integers "两数相除") | [Go](../problems/divide-two-integers) | Medium | diff --git a/readme/1201-1500.md b/readme/1201-1500.md new file mode 100644 index 000000000..d1b3a3d29 --- /dev/null +++ b/readme/1201-1500.md @@ -0,0 +1,380 @@ + + + + + + + +# [LeetCode](https://openset.github.io/leetcode) +LeetCode Problems' Solutions +[[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] + +[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) +[![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) +[![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) +[![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) +[![license](https://img.shields.io/github/license/openset/leetcode.svg)](https://github.com/openset/leetcode/blob/master/LICENSE) +[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fopenset%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fopenset%2Fleetcode?ref=badge_shield) +[![Join the chat](https://badges.gitter.im/openset/leetcode.svg)](https://gitter.im/openset/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      [1-50][51-100][101-150][151-200][201-250][251-300]
      [301-350][351-400][401-450][451-500][501-550][551-600]
      [601-650][651-700][701-750][751-800][801-850][851-900]
      [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
      [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
      [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
      [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
      + +| # | Title | Solution | Difficulty | +| :-: | - | - | :-: | +| 1201 | [Ugly Number III](https://leetcode.com/problems/ugly-number-iii "丑数 III") | [Go](../problems/ugly-number-iii) | Medium | +| 1202 | [Smallest String With Swaps](https://leetcode.com/problems/smallest-string-with-swaps "交换字符串中的元素") | [Go](../problems/smallest-string-with-swaps) | Medium | +| 1203 | [Sort Items by Groups Respecting Dependencies](https://leetcode.com/problems/sort-items-by-groups-respecting-dependencies "项目管理") | [Go](../problems/sort-items-by-groups-respecting-dependencies) | Hard | +| 1204 | [Last Person to Fit in the Elevator](https://leetcode.com/problems/last-person-to-fit-in-the-elevator "最后一个能进入电梯的人") 🔒 | [MySQL](../problems/last-person-to-fit-in-the-elevator) | Medium | +| 1205 | [Monthly Transactions II](https://leetcode.com/problems/monthly-transactions-ii "每月交易II") 🔒 | [MySQL](../problems/monthly-transactions-ii) | Medium | +| 1206 | [Design Skiplist](https://leetcode.com/problems/design-skiplist "设计跳表") | [Go](../problems/design-skiplist) | Hard | +| 1207 | [Unique Number of Occurrences](https://leetcode.com/problems/unique-number-of-occurrences "独一无二的出现次数") | [Go](../problems/unique-number-of-occurrences) | Easy | +| 1208 | [Get Equal Substrings Within Budget](https://leetcode.com/problems/get-equal-substrings-within-budget "尽可能使字符串相等") | [Go](../problems/get-equal-substrings-within-budget) | Medium | +| 1209 | [Remove All Adjacent Duplicates in String II](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii "删除字符串中的所有相邻重复项 II") | [Go](../problems/remove-all-adjacent-duplicates-in-string-ii) | Medium | +| 1210 | [Minimum Moves to Reach Target with Rotations](https://leetcode.com/problems/minimum-moves-to-reach-target-with-rotations "穿过迷宫的最少移动次数") | [Go](../problems/minimum-moves-to-reach-target-with-rotations) | Hard | +| 1211 | [Queries Quality and Percentage](https://leetcode.com/problems/queries-quality-and-percentage "查询结果的质量和占比") 🔒 | [MySQL](../problems/queries-quality-and-percentage) | Easy | +| 1212 | [Team Scores in Football Tournament](https://leetcode.com/problems/team-scores-in-football-tournament "查询球队积分") 🔒 | [MySQL](../problems/team-scores-in-football-tournament) | Medium | +| 1213 | [Intersection of Three Sorted Arrays](https://leetcode.com/problems/intersection-of-three-sorted-arrays "三个有序数组的交集") 🔒 | [Go](../problems/intersection-of-three-sorted-arrays) | Easy | +| 1214 | [Two Sum BSTs](https://leetcode.com/problems/two-sum-bsts "查找两棵二叉搜索树之和") 🔒 | [Go](../problems/two-sum-bsts) | Medium | +| 1215 | [Stepping Numbers](https://leetcode.com/problems/stepping-numbers "步进数") 🔒 | [Go](../problems/stepping-numbers) | Medium | +| 1216 | [Valid Palindrome III](https://leetcode.com/problems/valid-palindrome-iii "验证回文字符串 III") 🔒 | [Go](../problems/valid-palindrome-iii) | Hard | +| 1217 | [Minimum Cost to Move Chips to The Same Position](https://leetcode.com/problems/minimum-cost-to-move-chips-to-the-same-position "玩筹码") | [Go](../problems/minimum-cost-to-move-chips-to-the-same-position) | Easy | +| 1218 | [Longest Arithmetic Subsequence of Given Difference](https://leetcode.com/problems/longest-arithmetic-subsequence-of-given-difference "最长定差子序列") | [Go](../problems/longest-arithmetic-subsequence-of-given-difference) | Medium | +| 1219 | [Path with Maximum Gold](https://leetcode.com/problems/path-with-maximum-gold "黄金矿工") | [Go](../problems/path-with-maximum-gold) | Medium | +| 1220 | [Count Vowels Permutation](https://leetcode.com/problems/count-vowels-permutation "统计元音字母序列的数目") | [Go](../problems/count-vowels-permutation) | Hard | +| 1221 | [Split a String in Balanced Strings](https://leetcode.com/problems/split-a-string-in-balanced-strings "分割平衡字符串") | [Go](../problems/split-a-string-in-balanced-strings) | Easy | +| 1222 | [Queens That Can Attack the King](https://leetcode.com/problems/queens-that-can-attack-the-king "可以攻击国王的皇后") | [Go](../problems/queens-that-can-attack-the-king) | Medium | +| 1223 | [Dice Roll Simulation](https://leetcode.com/problems/dice-roll-simulation "掷骰子模拟") | [Go](../problems/dice-roll-simulation) | Hard | +| 1224 | [Maximum Equal Frequency](https://leetcode.com/problems/maximum-equal-frequency "最大相等频率") | [Go](../problems/maximum-equal-frequency) | Hard | +| 1225 | [Report Contiguous Dates](https://leetcode.com/problems/report-contiguous-dates "报告系统状态的连续日期") 🔒 | [MySQL](../problems/report-contiguous-dates) | Hard | +| 1226 | [The Dining Philosophers](https://leetcode.com/problems/the-dining-philosophers "哲学家进餐") | [Go](../problems/the-dining-philosophers) | Medium | +| 1227 | [Airplane Seat Assignment Probability](https://leetcode.com/problems/airplane-seat-assignment-probability "飞机座位分配概率") | [Go](../problems/airplane-seat-assignment-probability) | Medium | +| 1228 | [Missing Number In Arithmetic Progression](https://leetcode.com/problems/missing-number-in-arithmetic-progression "等差数列中缺失的数字") 🔒 | [Go](../problems/missing-number-in-arithmetic-progression) | Easy | +| 1229 | [Meeting Scheduler](https://leetcode.com/problems/meeting-scheduler "安排会议日程") 🔒 | [Go](../problems/meeting-scheduler) | Medium | +| 1230 | [Toss Strange Coins](https://leetcode.com/problems/toss-strange-coins "抛掷硬币") 🔒 | [Go](../problems/toss-strange-coins) | Medium | +| 1231 | [Divide Chocolate](https://leetcode.com/problems/divide-chocolate "分享巧克力") 🔒 | [Go](../problems/divide-chocolate) | Hard | +| 1232 | [Check If It Is a Straight Line](https://leetcode.com/problems/check-if-it-is-a-straight-line "缀点成线") | [Go](../problems/check-if-it-is-a-straight-line) | Easy | +| 1233 | [Remove Sub-Folders from the Filesystem](https://leetcode.com/problems/remove-sub-folders-from-the-filesystem "删除子文件夹") | [Go](../problems/remove-sub-folders-from-the-filesystem) | Medium | +| 1234 | [Replace the Substring for Balanced String](https://leetcode.com/problems/replace-the-substring-for-balanced-string "替换子串得到平衡字符串") | [Go](../problems/replace-the-substring-for-balanced-string) | Medium | +| 1235 | [Maximum Profit in Job Scheduling](https://leetcode.com/problems/maximum-profit-in-job-scheduling "规划兼职工作") | [Go](../problems/maximum-profit-in-job-scheduling) | Hard | +| 1236 | [Web Crawler](https://leetcode.com/problems/web-crawler "网络爬虫") 🔒 | [Go](../problems/web-crawler) | Medium | +| 1237 | [Find Positive Integer Solution for a Given Equation](https://leetcode.com/problems/find-positive-integer-solution-for-a-given-equation "找出给定方程的正整数解") | [Go](../problems/find-positive-integer-solution-for-a-given-equation) | Medium | +| 1238 | [Circular Permutation in Binary Representation](https://leetcode.com/problems/circular-permutation-in-binary-representation "循环码排列") | [Go](../problems/circular-permutation-in-binary-representation) | Medium | +| 1239 | [Maximum Length of a Concatenated String with Unique Characters](https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters "串联字符串的最大长度") | [Go](../problems/maximum-length-of-a-concatenated-string-with-unique-characters) | Medium | +| 1240 | [Tiling a Rectangle with the Fewest Squares](https://leetcode.com/problems/tiling-a-rectangle-with-the-fewest-squares "铺瓷砖") | [Go](../problems/tiling-a-rectangle-with-the-fewest-squares) | Hard | +| 1241 | [Number of Comments per Post](https://leetcode.com/problems/number-of-comments-per-post "每个帖子的评论数") 🔒 | [MySQL](../problems/number-of-comments-per-post) | Easy | +| 1242 | [Web Crawler Multithreaded](https://leetcode.com/problems/web-crawler-multithreaded "多线程网页爬虫") 🔒 | [Go](../problems/web-crawler-multithreaded) | Medium | +| 1243 | [Array Transformation](https://leetcode.com/problems/array-transformation "数组变换") 🔒 | [Go](../problems/array-transformation) | Easy | +| 1244 | [Design A Leaderboard](https://leetcode.com/problems/design-a-leaderboard "力扣排行榜") 🔒 | [Go](../problems/design-a-leaderboard) | Medium | +| 1245 | [Tree Diameter](https://leetcode.com/problems/tree-diameter "树的直径") 🔒 | [Go](../problems/tree-diameter) | Medium | +| 1246 | [Palindrome Removal](https://leetcode.com/problems/palindrome-removal "删除回文子数组") 🔒 | [Go](../problems/palindrome-removal) | Hard | +| 1247 | [Minimum Swaps to Make Strings Equal](https://leetcode.com/problems/minimum-swaps-to-make-strings-equal "交换字符使得字符串相同") | [Go](../problems/minimum-swaps-to-make-strings-equal) | Medium | +| 1248 | [Count Number of Nice Subarrays](https://leetcode.com/problems/count-number-of-nice-subarrays "统计「优美子数组」") | [Go](../problems/count-number-of-nice-subarrays) | Medium | +| 1249 | [Minimum Remove to Make Valid Parentheses](https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses "移除无效的括号") | [Go](../problems/minimum-remove-to-make-valid-parentheses) | Medium | +| 1250 | [Check If It Is a Good Array](https://leetcode.com/problems/check-if-it-is-a-good-array "检查「好数组」") | [Go](../problems/check-if-it-is-a-good-array) | Hard | +| 1251 | [Average Selling Price](https://leetcode.com/problems/average-selling-price "平均售价") 🔒 | [MySQL](../problems/average-selling-price) | Easy | +| 1252 | [Cells with Odd Values in a Matrix](https://leetcode.com/problems/cells-with-odd-values-in-a-matrix "奇数值单元格的数目") | [Go](../problems/cells-with-odd-values-in-a-matrix) | Easy | +| 1253 | [Reconstruct a 2-Row Binary Matrix](https://leetcode.com/problems/reconstruct-a-2-row-binary-matrix "重构 2 行二进制矩阵") | [Go](../problems/reconstruct-a-2-row-binary-matrix) | Medium | +| 1254 | [Number of Closed Islands](https://leetcode.com/problems/number-of-closed-islands "统计封闭岛屿的数目") | [Go](../problems/number-of-closed-islands) | Medium | +| 1255 | [Maximum Score Words Formed by Letters](https://leetcode.com/problems/maximum-score-words-formed-by-letters "得分最高的单词集合") | [Go](../problems/maximum-score-words-formed-by-letters) | Hard | +| 1256 | [Encode Number](https://leetcode.com/problems/encode-number "加密数字") 🔒 | [Go](../problems/encode-number) | Medium | +| 1257 | [Smallest Common Region](https://leetcode.com/problems/smallest-common-region "最小公共区域") 🔒 | [Go](../problems/smallest-common-region) | Medium | +| 1258 | [Synonymous Sentences](https://leetcode.com/problems/synonymous-sentences "近义词句子") 🔒 | [Go](../problems/synonymous-sentences) | Medium | +| 1259 | [Handshakes That Don't Cross](https://leetcode.com/problems/handshakes-that-dont-cross "不相交的握手") 🔒 | [Go](../problems/handshakes-that-dont-cross) | Hard | +| 1260 | [Shift 2D Grid](https://leetcode.com/problems/shift-2d-grid "二维网格迁移") | [Go](../problems/shift-2d-grid) | Easy | +| 1261 | [Find Elements in a Contaminated Binary Tree](https://leetcode.com/problems/find-elements-in-a-contaminated-binary-tree "在受污染的二叉树中查找元素") | [Go](../problems/find-elements-in-a-contaminated-binary-tree) | Medium | +| 1262 | [Greatest Sum Divisible by Three](https://leetcode.com/problems/greatest-sum-divisible-by-three "可被三整除的最大和") | [Go](../problems/greatest-sum-divisible-by-three) | Medium | +| 1263 | [Minimum Moves to Move a Box to Their Target Location](https://leetcode.com/problems/minimum-moves-to-move-a-box-to-their-target-location "推箱子") | [Go](../problems/minimum-moves-to-move-a-box-to-their-target-location) | Hard | +| 1264 | [Page Recommendations](https://leetcode.com/problems/page-recommendations "页面推荐") 🔒 | [MySQL](../problems/page-recommendations) | Medium | +| 1265 | [Print Immutable Linked List in Reverse](https://leetcode.com/problems/print-immutable-linked-list-in-reverse "逆序打印不可变链表") 🔒 | [Go](../problems/print-immutable-linked-list-in-reverse) | Medium | +| 1266 | [Minimum Time Visiting All Points](https://leetcode.com/problems/minimum-time-visiting-all-points "访问所有点的最小时间") | [Go](../problems/minimum-time-visiting-all-points) | Easy | +| 1267 | [Count Servers that Communicate](https://leetcode.com/problems/count-servers-that-communicate "统计参与通信的服务器") | [Go](../problems/count-servers-that-communicate) | Medium | +| 1268 | [Search Suggestions System](https://leetcode.com/problems/search-suggestions-system "搜索推荐系统") | [Go](../problems/search-suggestions-system) | Medium | +| 1269 | [Number of Ways to Stay in the Same Place After Some Steps](https://leetcode.com/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps "停在原地的方案数") | [Go](../problems/number-of-ways-to-stay-in-the-same-place-after-some-steps) | Hard | +| 1270 | [All People Report to the Given Manager](https://leetcode.com/problems/all-people-report-to-the-given-manager "向公司CEO汇报工作的所有人") 🔒 | [MySQL](../problems/all-people-report-to-the-given-manager) | Medium | +| 1271 | [Hexspeak](https://leetcode.com/problems/hexspeak "十六进制魔术数字") 🔒 | [Go](../problems/hexspeak) | Easy | +| 1272 | [Remove Interval](https://leetcode.com/problems/remove-interval "删除区间") 🔒 | [Go](../problems/remove-interval) | Medium | +| 1273 | [Delete Tree Nodes](https://leetcode.com/problems/delete-tree-nodes "删除树节点") 🔒 | [Go](../problems/delete-tree-nodes) | Medium | +| 1274 | [Number of Ships in a Rectangle](https://leetcode.com/problems/number-of-ships-in-a-rectangle "矩形内船只的数目") 🔒 | [Go](../problems/number-of-ships-in-a-rectangle) | Hard | +| 1275 | [Find Winner on a Tic Tac Toe Game](https://leetcode.com/problems/find-winner-on-a-tic-tac-toe-game "找出井字棋的获胜者") | [Go](../problems/find-winner-on-a-tic-tac-toe-game) | Easy | +| 1276 | [Number of Burgers with No Waste of Ingredients](https://leetcode.com/problems/number-of-burgers-with-no-waste-of-ingredients "不浪费原料的汉堡制作方案") | [Go](../problems/number-of-burgers-with-no-waste-of-ingredients) | Medium | +| 1277 | [Count Square Submatrices with All Ones](https://leetcode.com/problems/count-square-submatrices-with-all-ones "统计全为 1 的正方形子矩阵") | [Go](../problems/count-square-submatrices-with-all-ones) | Medium | +| 1278 | [Palindrome Partitioning III](https://leetcode.com/problems/palindrome-partitioning-iii "分割回文串 III") | [Go](../problems/palindrome-partitioning-iii) | Hard | +| 1279 | [Traffic Light Controlled Intersection](https://leetcode.com/problems/traffic-light-controlled-intersection "红绿灯路口") 🔒 | [Go](../problems/traffic-light-controlled-intersection) | Easy | +| 1280 | [Students and Examinations](https://leetcode.com/problems/students-and-examinations "学生们参加各科测试的次数") 🔒 | [MySQL](../problems/students-and-examinations) | Easy | +| 1281 | [Subtract the Product and Sum of Digits of an Integer](https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer "整数的各位积和之差") | [Go](../problems/subtract-the-product-and-sum-of-digits-of-an-integer) | Easy | +| 1282 | [Group the People Given the Group Size They Belong To](https://leetcode.com/problems/group-the-people-given-the-group-size-they-belong-to "用户分组") | [Go](../problems/group-the-people-given-the-group-size-they-belong-to) | Medium | +| 1283 | [Find the Smallest Divisor Given a Threshold](https://leetcode.com/problems/find-the-smallest-divisor-given-a-threshold "使结果不超过阈值的最小除数") | [Go](../problems/find-the-smallest-divisor-given-a-threshold) | Medium | +| 1284 | [Minimum Number of Flips to Convert Binary Matrix to Zero Matrix](https://leetcode.com/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix "转化为全零矩阵的最少反转次数") | [Go](../problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | Hard | +| 1285 | [Find the Start and End Number of Continuous Ranges](https://leetcode.com/problems/find-the-start-and-end-number-of-continuous-ranges "找到连续区间的开始和结束数字") 🔒 | [MySQL](../problems/find-the-start-and-end-number-of-continuous-ranges) | Medium | +| 1286 | [Iterator for Combination](https://leetcode.com/problems/iterator-for-combination "字母组合迭代器") | [Go](../problems/iterator-for-combination) | Medium | +| 1287 | [Element Appearing More Than 25% In Sorted Array](https://leetcode.com/problems/element-appearing-more-than-25-in-sorted-array "有序数组中出现次数超过25%的元素") | [Go](../problems/element-appearing-more-than-25-in-sorted-array) | Easy | +| 1288 | [Remove Covered Intervals](https://leetcode.com/problems/remove-covered-intervals "删除被覆盖区间") | [Go](../problems/remove-covered-intervals) | Medium | +| 1289 | [Minimum Falling Path Sum II](https://leetcode.com/problems/minimum-falling-path-sum-ii "下降路径最小和 II") | [Go](../problems/minimum-falling-path-sum-ii) | Hard | +| 1290 | [Convert Binary Number in a Linked List to Integer](https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer "二进制链表转整数") | [Go](../problems/convert-binary-number-in-a-linked-list-to-integer) | Easy | +| 1291 | [Sequential Digits](https://leetcode.com/problems/sequential-digits "顺次数") | [Go](../problems/sequential-digits) | Medium | +| 1292 | [Maximum Side Length of a Square with Sum Less than or Equal to Threshold](https://leetcode.com/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold "元素和小于等于阈值的正方形的最大边长") | [Go](../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | Medium | +| 1293 | [Shortest Path in a Grid with Obstacles Elimination](https://leetcode.com/problems/shortest-path-in-a-grid-with-obstacles-elimination "网格中的最短路径") | [Go](../problems/shortest-path-in-a-grid-with-obstacles-elimination) | Hard | +| 1294 | [Weather Type in Each Country](https://leetcode.com/problems/weather-type-in-each-country "不同国家的天气类型") 🔒 | [MySQL](../problems/weather-type-in-each-country) | Easy | +| 1295 | [Find Numbers with Even Number of Digits](https://leetcode.com/problems/find-numbers-with-even-number-of-digits "统计位数为偶数的数字") | [Go](../problems/find-numbers-with-even-number-of-digits) | Easy | +| 1296 | [Divide Array in Sets of K Consecutive Numbers](https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers "划分数组为连续数字的集合") | [Go](../problems/divide-array-in-sets-of-k-consecutive-numbers) | Medium | +| 1297 | [Maximum Number of Occurrences of a Substring](https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring "子串的最大出现次数") | [Go](../problems/maximum-number-of-occurrences-of-a-substring) | Medium | +| 1298 | [Maximum Candies You Can Get from Boxes](https://leetcode.com/problems/maximum-candies-you-can-get-from-boxes "你能从盒子里获得的最大糖果数") | [Go](../problems/maximum-candies-you-can-get-from-boxes) | Hard | +| 1299 | [Replace Elements with Greatest Element on Right Side](https://leetcode.com/problems/replace-elements-with-greatest-element-on-right-side "将每个元素替换为右侧最大元素") | [Go](../problems/replace-elements-with-greatest-element-on-right-side) | Easy | +| 1300 | [Sum of Mutated Array Closest to Target](https://leetcode.com/problems/sum-of-mutated-array-closest-to-target "转变数组后最接近目标值的数组和") | [Go](../problems/sum-of-mutated-array-closest-to-target) | Medium | +| 1301 | [Number of Paths with Max Score](https://leetcode.com/problems/number-of-paths-with-max-score "最大得分的路径数目") | [Go](../problems/number-of-paths-with-max-score) | Hard | +| 1302 | [Deepest Leaves Sum](https://leetcode.com/problems/deepest-leaves-sum "层数最深叶子节点的和") | [Go](../problems/deepest-leaves-sum) | Medium | +| 1303 | [Find the Team Size](https://leetcode.com/problems/find-the-team-size "求团队人数") 🔒 | [MySQL](../problems/find-the-team-size) | Easy | +| 1304 | [Find N Unique Integers Sum up to Zero](https://leetcode.com/problems/find-n-unique-integers-sum-up-to-zero "和为零的N个唯一整数") | [Go](../problems/find-n-unique-integers-sum-up-to-zero) | Easy | +| 1305 | [All Elements in Two Binary Search Trees](https://leetcode.com/problems/all-elements-in-two-binary-search-trees "两棵二叉搜索树中的所有元素") | [Go](../problems/all-elements-in-two-binary-search-trees) | Medium | +| 1306 | [Jump Game III](https://leetcode.com/problems/jump-game-iii "跳跃游戏 III") | [Go](../problems/jump-game-iii) | Medium | +| 1307 | [Verbal Arithmetic Puzzle](https://leetcode.com/problems/verbal-arithmetic-puzzle "口算难题") | [Go](../problems/verbal-arithmetic-puzzle) | Hard | +| 1308 | [Running Total for Different Genders](https://leetcode.com/problems/running-total-for-different-genders "不同性别每日分数总计") 🔒 | [MySQL](../problems/running-total-for-different-genders) | Medium | +| 1309 | [Decrypt String from Alphabet to Integer Mapping](https://leetcode.com/problems/decrypt-string-from-alphabet-to-integer-mapping "解码字母到整数映射") | [Go](../problems/decrypt-string-from-alphabet-to-integer-mapping) | Easy | +| 1310 | [XOR Queries of a Subarray](https://leetcode.com/problems/xor-queries-of-a-subarray "子数组异或查询") | [Go](../problems/xor-queries-of-a-subarray) | Medium | +| 1311 | [Get Watched Videos by Your Friends](https://leetcode.com/problems/get-watched-videos-by-your-friends "获取你好友已观看的视频") | [Go](../problems/get-watched-videos-by-your-friends) | Medium | +| 1312 | [Minimum Insertion Steps to Make a String Palindrome](https://leetcode.com/problems/minimum-insertion-steps-to-make-a-string-palindrome "让字符串成为回文串的最少插入次数") | [Go](../problems/minimum-insertion-steps-to-make-a-string-palindrome) | Hard | +| 1313 | [Decompress Run-Length Encoded List](https://leetcode.com/problems/decompress-run-length-encoded-list "解压缩编码列表") | [Go](../problems/decompress-run-length-encoded-list) | Easy | +| 1314 | [Matrix Block Sum](https://leetcode.com/problems/matrix-block-sum "矩阵区域和") | [Go](../problems/matrix-block-sum) | Medium | +| 1315 | [Sum of Nodes with Even-Valued Grandparent](https://leetcode.com/problems/sum-of-nodes-with-even-valued-grandparent "祖父节点值为偶数的节点和") | [Go](../problems/sum-of-nodes-with-even-valued-grandparent) | Medium | +| 1316 | [Distinct Echo Substrings](https://leetcode.com/problems/distinct-echo-substrings "不同的循环子字符串") | [Go](../problems/distinct-echo-substrings) | Hard | +| 1317 | [Convert Integer to the Sum of Two No-Zero Integers](https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers "将整数转换为两个无零整数的和") | [Go](../problems/convert-integer-to-the-sum-of-two-no-zero-integers) | Easy | +| 1318 | [Minimum Flips to Make a OR b Equal to c](https://leetcode.com/problems/minimum-flips-to-make-a-or-b-equal-to-c "或运算的最小翻转次数") | [Go](../problems/minimum-flips-to-make-a-or-b-equal-to-c) | Medium | +| 1319 | [Number of Operations to Make Network Connected](https://leetcode.com/problems/number-of-operations-to-make-network-connected "连通网络的操作次数") | [Go](../problems/number-of-operations-to-make-network-connected) | Medium | +| 1320 | [Minimum Distance to Type a Word Using Two Fingers](https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers "二指输入的的最小距离") | [Go](../problems/minimum-distance-to-type-a-word-using-two-fingers) | Hard | +| 1321 | [Restaurant Growth](https://leetcode.com/problems/restaurant-growth "餐馆营业额变化增长") 🔒 | [MySQL](../problems/restaurant-growth) | Medium | +| 1322 | [Ads Performance](https://leetcode.com/problems/ads-performance "广告效果") 🔒 | [MySQL](../problems/ads-performance) | Easy | +| 1323 | [Maximum 69 Number](https://leetcode.com/problems/maximum-69-number "6 和 9 组成的最大数字") | [Go](../problems/maximum-69-number) | Easy | +| 1324 | [Print Words Vertically](https://leetcode.com/problems/print-words-vertically "竖直打印单词") | [Go](../problems/print-words-vertically) | Medium | +| 1325 | [Delete Leaves With a Given Value](https://leetcode.com/problems/delete-leaves-with-a-given-value "删除给定值的叶子节点") | [Go](../problems/delete-leaves-with-a-given-value) | Medium | +| 1326 | [Minimum Number of Taps to Open to Water a Garden](https://leetcode.com/problems/minimum-number-of-taps-to-open-to-water-a-garden "灌溉花园的最少水龙头数目") | [Go](../problems/minimum-number-of-taps-to-open-to-water-a-garden) | Hard | +| 1327 | [List the Products Ordered in a Period](https://leetcode.com/problems/list-the-products-ordered-in-a-period "列出指定时间段内所有的下单产品") 🔒 | [MySQL](../problems/list-the-products-ordered-in-a-period) | Easy | +| 1328 | [Break a Palindrome](https://leetcode.com/problems/break-a-palindrome "破坏回文串") | [Go](../problems/break-a-palindrome) | Medium | +| 1329 | [Sort the Matrix Diagonally](https://leetcode.com/problems/sort-the-matrix-diagonally "将矩阵按对角线排序") | [Go](../problems/sort-the-matrix-diagonally) | Medium | +| 1330 | [Reverse Subarray To Maximize Array Value](https://leetcode.com/problems/reverse-subarray-to-maximize-array-value "翻转子数组得到最大的数组值") | [Go](../problems/reverse-subarray-to-maximize-array-value) | Hard | +| 1331 | [Rank Transform of an Array](https://leetcode.com/problems/rank-transform-of-an-array "数组序号转换") | [Go](../problems/rank-transform-of-an-array) | Easy | +| 1332 | [Remove Palindromic Subsequences](https://leetcode.com/problems/remove-palindromic-subsequences "删除回文子序列") | [Go](../problems/remove-palindromic-subsequences) | Easy | +| 1333 | [Filter Restaurants by Vegan-Friendly, Price and Distance](https://leetcode.com/problems/filter-restaurants-by-vegan-friendly-price-and-distance "餐厅过滤器") | [Go](../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | Medium | +| 1334 | [Find the City With the Smallest Number of Neighbors at a Threshold Distance](https://leetcode.com/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance "阈值距离内邻居最少的城市") | [Go](../problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | Medium | +| 1335 | [Minimum Difficulty of a Job Schedule](https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule "工作计划的最低难度") | [Go](../problems/minimum-difficulty-of-a-job-schedule) | Hard | +| 1336 | [Number of Transactions per Visit](https://leetcode.com/problems/number-of-transactions-per-visit "每次访问的交易次数") 🔒 | [MySQL](../problems/number-of-transactions-per-visit) | Hard | +| 1337 | [The K Weakest Rows in a Matrix](https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix "矩阵中战斗力最弱的 K 行") | [Go](../problems/the-k-weakest-rows-in-a-matrix) | Easy | +| 1338 | [Reduce Array Size to The Half](https://leetcode.com/problems/reduce-array-size-to-the-half "数组大小减半") | [Go](../problems/reduce-array-size-to-the-half) | Medium | +| 1339 | [Maximum Product of Splitted Binary Tree](https://leetcode.com/problems/maximum-product-of-splitted-binary-tree "分裂二叉树的最大乘积") | [Go](../problems/maximum-product-of-splitted-binary-tree) | Medium | +| 1340 | [Jump Game V](https://leetcode.com/problems/jump-game-v "跳跃游戏 V") | [Go](../problems/jump-game-v) | Hard | +| 1341 | [Movie Rating](https://leetcode.com/problems/movie-rating "电影评分") 🔒 | [MySQL](../problems/movie-rating) | Medium | +| 1342 | [Number of Steps to Reduce a Number to Zero](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero "将数字变成 0 的操作次数") | [Go](../problems/number-of-steps-to-reduce-a-number-to-zero) | Easy | +| 1343 | [Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold](https://leetcode.com/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold "大小为 K 且平均值大于等于阈值的子数组数目") | [Go](../problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold) | Medium | +| 1344 | [Angle Between Hands of a Clock](https://leetcode.com/problems/angle-between-hands-of-a-clock "时钟指针的夹角") | [Go](../problems/angle-between-hands-of-a-clock) | Medium | +| 1345 | [Jump Game IV](https://leetcode.com/problems/jump-game-iv "跳跃游戏 IV") | [Go](../problems/jump-game-iv) | Hard | +| 1346 | [Check If N and Its Double Exist](https://leetcode.com/problems/check-if-n-and-its-double-exist "检查整数及其两倍数是否存在") | [Go](../problems/check-if-n-and-its-double-exist) | Easy | +| 1347 | [Minimum Number of Steps to Make Two Strings Anagram](https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram "制造字母异位词的最小步骤数") | [Go](../problems/minimum-number-of-steps-to-make-two-strings-anagram) | Medium | +| 1348 | [Tweet Counts Per Frequency](https://leetcode.com/problems/tweet-counts-per-frequency "推文计数") | [Go](../problems/tweet-counts-per-frequency) | Medium | +| 1349 | [Maximum Students Taking Exam](https://leetcode.com/problems/maximum-students-taking-exam "参加考试的最大学生数") | [Go](../problems/maximum-students-taking-exam) | Hard | +| 1350 | [Students With Invalid Departments](https://leetcode.com/problems/students-with-invalid-departments "院系无效的学生") 🔒 | [MySQL](../problems/students-with-invalid-departments) | Easy | +| 1351 | [Count Negative Numbers in a Sorted Matrix](https://leetcode.com/problems/count-negative-numbers-in-a-sorted-matrix "统计有序矩阵中的负数") | [Go](../problems/count-negative-numbers-in-a-sorted-matrix) | Easy | +| 1352 | [Product of the Last K Numbers](https://leetcode.com/problems/product-of-the-last-k-numbers "最后 K 个数的乘积") | [Go](../problems/product-of-the-last-k-numbers) | Medium | +| 1353 | [Maximum Number of Events That Can Be Attended](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended "最多可以参加的会议数目") | [Go](../problems/maximum-number-of-events-that-can-be-attended) | Medium | +| 1354 | [Construct Target Array With Multiple Sums](https://leetcode.com/problems/construct-target-array-with-multiple-sums "多次求和构造目标数组") | [Go](../problems/construct-target-array-with-multiple-sums) | Hard | +| 1355 | [Activity Participants](https://leetcode.com/problems/activity-participants "活动参与者") 🔒 | [MySQL](../problems/activity-participants) | Medium | +| 1356 | [Sort Integers by The Number of 1 Bits](https://leetcode.com/problems/sort-integers-by-the-number-of-1-bits "根据数字二进制下 1 的数目排序") | [Go](../problems/sort-integers-by-the-number-of-1-bits) | Easy | +| 1357 | [Apply Discount Every n Orders](https://leetcode.com/problems/apply-discount-every-n-orders "每隔 n 个顾客打折") | [Go](../problems/apply-discount-every-n-orders) | Medium | +| 1358 | [Number of Substrings Containing All Three Characters](https://leetcode.com/problems/number-of-substrings-containing-all-three-characters "包含所有三种字符的子字符串数目") | [Go](../problems/number-of-substrings-containing-all-three-characters) | Medium | +| 1359 | [Count All Valid Pickup and Delivery Options](https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options "有效的快递序列数目") | [Go](../problems/count-all-valid-pickup-and-delivery-options) | Hard | +| 1360 | [Number of Days Between Two Dates](https://leetcode.com/problems/number-of-days-between-two-dates "日期之间隔几天") | [Go](../problems/number-of-days-between-two-dates) | Easy | +| 1361 | [Validate Binary Tree Nodes](https://leetcode.com/problems/validate-binary-tree-nodes "验证二叉树") | [Go](../problems/validate-binary-tree-nodes) | Medium | +| 1362 | [Closest Divisors](https://leetcode.com/problems/closest-divisors "最接近的因数") | [Go](../problems/closest-divisors) | Medium | +| 1363 | [Largest Multiple of Three](https://leetcode.com/problems/largest-multiple-of-three "形成三的最大倍数") | [Go](../problems/largest-multiple-of-three) | Hard | +| 1364 | [Number of Trusted Contacts of a Customer](https://leetcode.com/problems/number-of-trusted-contacts-of-a-customer "顾客的可信联系人数量") 🔒 | [MySQL](../problems/number-of-trusted-contacts-of-a-customer) | Medium | +| 1365 | [How Many Numbers Are Smaller Than the Current Number](https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number "有多少小于当前数字的数字") | [Go](../problems/how-many-numbers-are-smaller-than-the-current-number) | Easy | +| 1366 | [Rank Teams by Votes](https://leetcode.com/problems/rank-teams-by-votes "通过投票对团队排名") | [Go](../problems/rank-teams-by-votes) | Medium | +| 1367 | [Linked List in Binary Tree](https://leetcode.com/problems/linked-list-in-binary-tree "二叉树中的列表") | [Go](../problems/linked-list-in-binary-tree) | Medium | +| 1368 | [Minimum Cost to Make at Least One Valid Path in a Grid](https://leetcode.com/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid "使网格图至少有一条有效路径的最小代价") | [Go](../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | Hard | +| 1369 | [Get the Second Most Recent Activity](https://leetcode.com/problems/get-the-second-most-recent-activity "获取最近第二次的活动") 🔒 | [MySQL](../problems/get-the-second-most-recent-activity) | Hard | +| 1370 | [Increasing Decreasing String](https://leetcode.com/problems/increasing-decreasing-string "上升下降字符串") | [Go](../problems/increasing-decreasing-string) | Easy | +| 1371 | [Find the Longest Substring Containing Vowels in Even Counts](https://leetcode.com/problems/find-the-longest-substring-containing-vowels-in-even-counts "每个元音包含偶数次的最长子字符串") | [Go](../problems/find-the-longest-substring-containing-vowels-in-even-counts) | Medium | +| 1372 | [Longest ZigZag Path in a Binary Tree](https://leetcode.com/problems/longest-zigzag-path-in-a-binary-tree "二叉树中的最长交错路径") | [Go](../problems/longest-zigzag-path-in-a-binary-tree) | Medium | +| 1373 | [Maximum Sum BST in Binary Tree](https://leetcode.com/problems/maximum-sum-bst-in-binary-tree "二叉搜索子树的最大键值和") | [Go](../problems/maximum-sum-bst-in-binary-tree) | Hard | +| 1374 | [Generate a String With Characters That Have Odd Counts](https://leetcode.com/problems/generate-a-string-with-characters-that-have-odd-counts "生成每种字符都是奇数个的字符串") | [Go](../problems/generate-a-string-with-characters-that-have-odd-counts) | Easy | +| 1375 | [Bulb Switcher III](https://leetcode.com/problems/bulb-switcher-iii "灯泡开关 III") | [Go](../problems/bulb-switcher-iii) | Medium | +| 1376 | [Time Needed to Inform All Employees](https://leetcode.com/problems/time-needed-to-inform-all-employees "通知所有员工所需的时间") | [Go](../problems/time-needed-to-inform-all-employees) | Medium | +| 1377 | [Frog Position After T Seconds](https://leetcode.com/problems/frog-position-after-t-seconds "T 秒后青蛙的位置") | [Go](../problems/frog-position-after-t-seconds) | Hard | +| 1378 | [Replace Employee ID With The Unique Identifier](https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier "使用唯一标识码替换员工ID") 🔒 | [MySQL](../problems/replace-employee-id-with-the-unique-identifier) | Easy | +| 1379 | [Find a Corresponding Node of a Binary Tree in a Clone of That Tree](https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree "找出克隆二叉树中的相同节点") | [Go](../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | Medium | +| 1380 | [Lucky Numbers in a Matrix](https://leetcode.com/problems/lucky-numbers-in-a-matrix "矩阵中的幸运数") | [Go](../problems/lucky-numbers-in-a-matrix) | Easy | +| 1381 | [Design a Stack With Increment Operation](https://leetcode.com/problems/design-a-stack-with-increment-operation "设计一个支持增量操作的栈") | [Go](../problems/design-a-stack-with-increment-operation) | Medium | +| 1382 | [Balance a Binary Search Tree](https://leetcode.com/problems/balance-a-binary-search-tree "将二叉搜索树变平衡") | [Go](../problems/balance-a-binary-search-tree) | Medium | +| 1383 | [Maximum Performance of a Team](https://leetcode.com/problems/maximum-performance-of-a-team "最大的团队表现值") | [Go](../problems/maximum-performance-of-a-team) | Hard | +| 1384 | [Total Sales Amount by Year](https://leetcode.com/problems/total-sales-amount-by-year "按年度列出销售总额") 🔒 | [MySQL](../problems/total-sales-amount-by-year) | Hard | +| 1385 | [Find the Distance Value Between Two Arrays](https://leetcode.com/problems/find-the-distance-value-between-two-arrays "两个数组间的距离值") | [Go](../problems/find-the-distance-value-between-two-arrays) | Easy | +| 1386 | [Cinema Seat Allocation](https://leetcode.com/problems/cinema-seat-allocation "安排电影院座位") | [Go](../problems/cinema-seat-allocation) | Medium | +| 1387 | [Sort Integers by The Power Value](https://leetcode.com/problems/sort-integers-by-the-power-value "将整数按权重排序") | [Go](../problems/sort-integers-by-the-power-value) | Medium | +| 1388 | [Pizza With 3n Slices](https://leetcode.com/problems/pizza-with-3n-slices "3n 块披萨") | [Go](../problems/pizza-with-3n-slices) | Hard | +| 1389 | [Create Target Array in the Given Order](https://leetcode.com/problems/create-target-array-in-the-given-order "按既定顺序创建目标数组") | [Go](../problems/create-target-array-in-the-given-order) | Easy | +| 1390 | [Four Divisors](https://leetcode.com/problems/four-divisors "四因数") | [Go](../problems/four-divisors) | Medium | +| 1391 | [Check if There is a Valid Path in a Grid](https://leetcode.com/problems/check-if-there-is-a-valid-path-in-a-grid "检查网格中是否存在有效路径") | [Go](../problems/check-if-there-is-a-valid-path-in-a-grid) | Medium | +| 1392 | [Longest Happy Prefix](https://leetcode.com/problems/longest-happy-prefix "最长快乐前缀") | [Go](../problems/longest-happy-prefix) | Hard | +| 1393 | [Capital Gain/Loss](https://leetcode.com/problems/capital-gainloss "股票的资本损益") 🔒 | [MySQL](../problems/capital-gainloss) | Medium | +| 1394 | [Find Lucky Integer in an Array](https://leetcode.com/problems/find-lucky-integer-in-an-array "找出数组中的幸运数") | [Go](../problems/find-lucky-integer-in-an-array) | Easy | +| 1395 | [Count Number of Teams](https://leetcode.com/problems/count-number-of-teams "统计作战单位数") | [Go](../problems/count-number-of-teams) | Medium | +| 1396 | [Design Underground System](https://leetcode.com/problems/design-underground-system "设计地铁系统") | [Go](../problems/design-underground-system) | Medium | +| 1397 | [Find All Good Strings](https://leetcode.com/problems/find-all-good-strings "找到所有好字符串") | [Go](../problems/find-all-good-strings) | Hard | +| 1398 | [Customers Who Bought Products A and B but Not C](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c "购买了产品 A 和产品 B 却没有购买产品 C 的顾客") 🔒 | [MySQL](../problems/customers-who-bought-products-a-and-b-but-not-c) | Medium | +| 1399 | [Count Largest Group](https://leetcode.com/problems/count-largest-group "统计最大组的数目") | [Go](../problems/count-largest-group) | Easy | +| 1400 | [Construct K Palindrome Strings](https://leetcode.com/problems/construct-k-palindrome-strings "构造 K 个回文字符串") | [Go](../problems/construct-k-palindrome-strings) | Medium | +| 1401 | [Circle and Rectangle Overlapping](https://leetcode.com/problems/circle-and-rectangle-overlapping "圆和矩形是否有重叠") | [Go](../problems/circle-and-rectangle-overlapping) | Medium | +| 1402 | [Reducing Dishes](https://leetcode.com/problems/reducing-dishes "做菜顺序") | [Go](../problems/reducing-dishes) | Hard | +| 1403 | [Minimum Subsequence in Non-Increasing Order](https://leetcode.com/problems/minimum-subsequence-in-non-increasing-order "非递增顺序的最小子序列") | [Go](../problems/minimum-subsequence-in-non-increasing-order) | Easy | +| 1404 | [Number of Steps to Reduce a Number in Binary Representation to One](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one "将二进制表示减到 1 的步骤数") | [Go](../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | Medium | +| 1405 | [Longest Happy String](https://leetcode.com/problems/longest-happy-string "最长快乐字符串") | [Go](../problems/longest-happy-string) | Medium | +| 1406 | [Stone Game III](https://leetcode.com/problems/stone-game-iii "石子游戏 III") | [Go](../problems/stone-game-iii) | Hard | +| 1407 | [Top Travellers](https://leetcode.com/problems/top-travellers "排名靠前的旅行者") 🔒 | [MySQL](../problems/top-travellers) | Easy | +| 1408 | [String Matching in an Array](https://leetcode.com/problems/string-matching-in-an-array "数组中的字符串匹配") | [Go](../problems/string-matching-in-an-array) | Easy | +| 1409 | [Queries on a Permutation With Key](https://leetcode.com/problems/queries-on-a-permutation-with-key "查询带键的排列") | [Go](../problems/queries-on-a-permutation-with-key) | Medium | +| 1410 | [HTML Entity Parser](https://leetcode.com/problems/html-entity-parser "HTML 实体解析器") | [Go](../problems/html-entity-parser) | Medium | +| 1411 | [Number of Ways to Paint N × 3 Grid](https://leetcode.com/problems/number-of-ways-to-paint-n-3-grid "给 N x 3 网格图涂色的方案数") | [Go](../problems/number-of-ways-to-paint-n-3-grid) | Hard | +| 1412 | [Find the Quiet Students in All Exams](https://leetcode.com/problems/find-the-quiet-students-in-all-exams "查找成绩处于中游的学生") 🔒 | [MySQL](../problems/find-the-quiet-students-in-all-exams) | Hard | +| 1413 | [Minimum Value to Get Positive Step by Step Sum](https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum "逐步求和得到正数的最小值") | [Go](../problems/minimum-value-to-get-positive-step-by-step-sum) | Easy | +| 1414 | [Find the Minimum Number of Fibonacci Numbers Whose Sum Is K](https://leetcode.com/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k "和为 K 的最少斐波那契数字数目") | [Go](../problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | Medium | +| 1415 | [The k-th Lexicographical String of All Happy Strings of Length n](https://leetcode.com/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n "长度为 n 的开心字符串中字典序第 k 小的字符串") | [Go](../problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | Medium | +| 1416 | [Restore The Array](https://leetcode.com/problems/restore-the-array "恢复数组") | [Go](../problems/restore-the-array) | Hard | +| 1417 | [Reformat The String](https://leetcode.com/problems/reformat-the-string "重新格式化字符串") | [Go](../problems/reformat-the-string) | Easy | +| 1418 | [Display Table of Food Orders in a Restaurant](https://leetcode.com/problems/display-table-of-food-orders-in-a-restaurant "点菜展示表") | [Go](../problems/display-table-of-food-orders-in-a-restaurant) | Medium | +| 1419 | [Minimum Number of Frogs Croaking](https://leetcode.com/problems/minimum-number-of-frogs-croaking "数青蛙") | [Go](../problems/minimum-number-of-frogs-croaking) | Medium | +| 1420 | [Build Array Where You Can Find The Maximum Exactly K Comparisons](https://leetcode.com/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons "生成数组") | [Go](../problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons) | Hard | +| 1421 | [NPV Queries](https://leetcode.com/problems/npv-queries "净现值查询") 🔒 | [MySQL](../problems/npv-queries) | Medium | +| 1422 | [Maximum Score After Splitting a String](https://leetcode.com/problems/maximum-score-after-splitting-a-string "分割字符串的最大得分") | [Go](../problems/maximum-score-after-splitting-a-string) | Easy | +| 1423 | [Maximum Points You Can Obtain from Cards](https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards "可获得的最大点数") | [Go](../problems/maximum-points-you-can-obtain-from-cards) | Medium | +| 1424 | [Diagonal Traverse II](https://leetcode.com/problems/diagonal-traverse-ii "对角线遍历 II") | [Go](../problems/diagonal-traverse-ii) | Medium | +| 1425 | [Constrained Subsequence Sum](https://leetcode.com/problems/constrained-subsequence-sum "带限制的子序列和") | [Go](../problems/constrained-subsequence-sum) | Hard | +| 1426 | [Counting Elements](https://leetcode.com/problems/counting-elements "数元素") 🔒 | [Go](../problems/counting-elements) | Easy | +| 1427 | [Perform String Shifts](https://leetcode.com/problems/perform-string-shifts "字符串的左右移") 🔒 | [Go](../problems/perform-string-shifts) | Easy | +| 1428 | [Leftmost Column with at Least a One](https://leetcode.com/problems/leftmost-column-with-at-least-a-one "至少有一个 1 的最左端列") 🔒 | [Go](../problems/leftmost-column-with-at-least-a-one) | Medium | +| 1429 | [First Unique Number](https://leetcode.com/problems/first-unique-number "第一个唯一数字") 🔒 | [Go](../problems/first-unique-number) | Medium | +| 1430 | [Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree](https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree "判断给定的序列是否是二叉树从根到叶的路径") 🔒 | [Go](../problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) | Medium | +| 1431 | [Kids With the Greatest Number of Candies](https://leetcode.com/problems/kids-with-the-greatest-number-of-candies "拥有最多糖果的孩子") | [Go](../problems/kids-with-the-greatest-number-of-candies) | Easy | +| 1432 | [Max Difference You Can Get From Changing an Integer](https://leetcode.com/problems/max-difference-you-can-get-from-changing-an-integer "改变一个整数能得到的最大差值") | [Go](../problems/max-difference-you-can-get-from-changing-an-integer) | Medium | +| 1433 | [Check If a String Can Break Another String](https://leetcode.com/problems/check-if-a-string-can-break-another-string "检查一个字符串是否可以打破另一个字符串") | [Go](../problems/check-if-a-string-can-break-another-string) | Medium | +| 1434 | [Number of Ways to Wear Different Hats to Each Other](https://leetcode.com/problems/number-of-ways-to-wear-different-hats-to-each-other "每个人戴不同帽子的方案数") | [Go](../problems/number-of-ways-to-wear-different-hats-to-each-other) | Hard | +| 1435 | [Create a Session Bar Chart](https://leetcode.com/problems/create-a-session-bar-chart "制作会话柱状图") 🔒 | [MySQL](../problems/create-a-session-bar-chart) | Easy | +| 1436 | [Destination City](https://leetcode.com/problems/destination-city "旅行终点站") | [Go](../problems/destination-city) | Easy | +| 1437 | [Check If All 1's Are at Least Length K Places Away](https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away "是否所有 1 都至少相隔 k 个元素") | [Go](../problems/check-if-all-1s-are-at-least-length-k-places-away) | Easy | +| 1438 | [Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit](https://leetcode.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "绝对差不超过限制的最长连续子数组") | [Go](../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | Medium | +| 1439 | [Find the Kth Smallest Sum of a Matrix With Sorted Rows](https://leetcode.com/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows "有序矩阵中的第 k 个最小数组和") | [Go](../problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | Hard | +| 1440 | [Evaluate Boolean Expression](https://leetcode.com/problems/evaluate-boolean-expression "计算布尔表达式的值") 🔒 | [MySQL](../problems/evaluate-boolean-expression) | Medium | +| 1441 | [Build an Array With Stack Operations](https://leetcode.com/problems/build-an-array-with-stack-operations "用栈操作构建数组") | [Go](../problems/build-an-array-with-stack-operations) | Easy | +| 1442 | [Count Triplets That Can Form Two Arrays of Equal XOR](https://leetcode.com/problems/count-triplets-that-can-form-two-arrays-of-equal-xor "形成两个异或相等数组的三元组数目") | [Go](../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | Medium | +| 1443 | [Minimum Time to Collect All Apples in a Tree](https://leetcode.com/problems/minimum-time-to-collect-all-apples-in-a-tree "收集树上所有苹果的最少时间") | [Go](../problems/minimum-time-to-collect-all-apples-in-a-tree) | Medium | +| 1444 | [Number of Ways of Cutting a Pizza](https://leetcode.com/problems/number-of-ways-of-cutting-a-pizza "切披萨的方案数") | [Go](../problems/number-of-ways-of-cutting-a-pizza) | Hard | +| 1445 | [Apples & Oranges](https://leetcode.com/problems/apples-oranges "苹果和桔子") 🔒 | [MySQL](../problems/apples-oranges) | Medium | +| 1446 | [Consecutive Characters](https://leetcode.com/problems/consecutive-characters "连续字符") | [Go](../problems/consecutive-characters) | Easy | +| 1447 | [Simplified Fractions](https://leetcode.com/problems/simplified-fractions "最简分数") | [Go](../problems/simplified-fractions) | Medium | +| 1448 | [Count Good Nodes in Binary Tree](https://leetcode.com/problems/count-good-nodes-in-binary-tree "统计二叉树中好节点的数目") | [Go](../problems/count-good-nodes-in-binary-tree) | Medium | +| 1449 | [Form Largest Integer With Digits That Add up to Target](https://leetcode.com/problems/form-largest-integer-with-digits-that-add-up-to-target "数位成本和为目标值的最大数字") | [Go](../problems/form-largest-integer-with-digits-that-add-up-to-target) | Hard | +| 1450 | [Number of Students Doing Homework at a Given Time](https://leetcode.com/problems/number-of-students-doing-homework-at-a-given-time "在既定时间做作业的学生人数") | [Go](../problems/number-of-students-doing-homework-at-a-given-time) | Easy | +| 1451 | [Rearrange Words in a Sentence](https://leetcode.com/problems/rearrange-words-in-a-sentence "重新排列句子中的单词") | [Go](../problems/rearrange-words-in-a-sentence) | Medium | +| 1452 | [People Whose List of Favorite Companies Is Not a Subset of Another List](https://leetcode.com/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list "收藏清单") | [Go](../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | Medium | +| 1453 | [Maximum Number of Darts Inside of a Circular Dartboard](https://leetcode.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard "圆形靶内的最大飞镖数量") | [Go](../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | Hard | +| 1454 | [Active Users](https://leetcode.com/problems/active-users "活跃用户") 🔒 | [MySQL](../problems/active-users) | Medium | +| 1455 | [Check If a Word Occurs As a Prefix of Any Word in a Sentence](https://leetcode.com/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence "检查单词是否为句中其他单词的前缀") | [Go](../problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | Easy | +| 1456 | [Maximum Number of Vowels in a Substring of Given Length](https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length "定长子串中元音的最大数目") | [Go](../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | Medium | +| 1457 | [Pseudo-Palindromic Paths in a Binary Tree](https://leetcode.com/problems/pseudo-palindromic-paths-in-a-binary-tree "二叉树中的伪回文路径") | [Go](../problems/pseudo-palindromic-paths-in-a-binary-tree) | Medium | +| 1458 | [Max Dot Product of Two Subsequences](https://leetcode.com/problems/max-dot-product-of-two-subsequences "两个子序列的最大点积") | [Go](../problems/max-dot-product-of-two-subsequences) | Hard | +| 1459 | [Rectangles Area](https://leetcode.com/problems/rectangles-area "矩形面积") 🔒 | [MySQL](../problems/rectangles-area) | Medium | +| 1460 | [Make Two Arrays Equal by Reversing Sub-arrays](https://leetcode.com/problems/make-two-arrays-equal-by-reversing-sub-arrays "通过翻转子数组使两个数组相等") | [Go](../problems/make-two-arrays-equal-by-reversing-sub-arrays) | Easy | +| 1461 | [Check If a String Contains All Binary Codes of Size K](https://leetcode.com/problems/check-if-a-string-contains-all-binary-codes-of-size-k "检查一个字符串是否包含所有长度为 K 的二进制子串") | [Go](../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | Medium | +| 1462 | [Course Schedule IV](https://leetcode.com/problems/course-schedule-iv "课程表 IV") | [Go](../problems/course-schedule-iv) | Medium | +| 1463 | [Cherry Pickup II](https://leetcode.com/problems/cherry-pickup-ii "摘樱桃 II") | [Go](../problems/cherry-pickup-ii) | Hard | +| 1464 | [Maximum Product of Two Elements in an Array](https://leetcode.com/problems/maximum-product-of-two-elements-in-an-array "数组中两元素的最大乘积") | [Go](../problems/maximum-product-of-two-elements-in-an-array) | Easy | +| 1465 | [Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts](https://leetcode.com/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts "切割后面积最大的蛋糕") | [Go](../problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts) | Medium | +| 1466 | [Reorder Routes to Make All Paths Lead to the City Zero](https://leetcode.com/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero "重新规划路线") | [Go](../problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | Medium | +| 1467 | [Probability of a Two Boxes Having The Same Number of Distinct Balls](https://leetcode.com/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "两个盒子中球的颜色数相同的概率") | [Go](../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | Hard | +| 1468 | [Calculate Salaries](https://leetcode.com/problems/calculate-salaries "计算税后工资") 🔒 | [MySQL](../problems/calculate-salaries) | Medium | +| 1469 | [Find All The Lonely Nodes](https://leetcode.com/problems/find-all-the-lonely-nodes "寻找所有的独生节点") 🔒 | [Go](../problems/find-all-the-lonely-nodes) | Easy | +| 1470 | [Shuffle the Array](https://leetcode.com/problems/shuffle-the-array "重新排列数组") | [Go](../problems/shuffle-the-array) | Easy | +| 1471 | [The k Strongest Values in an Array](https://leetcode.com/problems/the-k-strongest-values-in-an-array "数组中的 k 个最强值") | [Go](../problems/the-k-strongest-values-in-an-array) | Medium | +| 1472 | [Design Browser History](https://leetcode.com/problems/design-browser-history "设计浏览器历史记录") | [Go](../problems/design-browser-history) | Medium | +| 1473 | [Paint House III](https://leetcode.com/problems/paint-house-iii "粉刷房子 III") | [Go](../problems/paint-house-iii) | Hard | +| 1474 | [Delete N Nodes After M Nodes of a Linked List](https://leetcode.com/problems/delete-n-nodes-after-m-nodes-of-a-linked-list "删除链表 M 个节点之后的 N 个节点") 🔒 | [Go](../problems/delete-n-nodes-after-m-nodes-of-a-linked-list) | Easy | +| 1475 | [Final Prices With a Special Discount in a Shop](https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop "商品折扣后的最终价格") | [Go](../problems/final-prices-with-a-special-discount-in-a-shop) | Easy | +| 1476 | [Subrectangle Queries](https://leetcode.com/problems/subrectangle-queries "子矩形查询") | [Go](../problems/subrectangle-queries) | Medium | +| 1477 | [Find Two Non-overlapping Sub-arrays Each With Target Sum](https://leetcode.com/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum "找两个和为目标值且不重叠的子数组") | [Go](../problems/find-two-non-overlapping-sub-arrays-each-with-target-sum) | Medium | +| 1478 | [Allocate Mailboxes](https://leetcode.com/problems/allocate-mailboxes "安排邮筒") | [Go](../problems/allocate-mailboxes) | Hard | +| 1479 | [Sales by Day of the Week](https://leetcode.com/problems/sales-by-day-of-the-week "周内每天的销售情况") 🔒 | [MySQL](../problems/sales-by-day-of-the-week) | Hard | +| 1480 | [Running Sum of 1d Array](https://leetcode.com/problems/running-sum-of-1d-array "一维数组的动态和") | [Go](../problems/running-sum-of-1d-array) | Easy | +| 1481 | [Least Number of Unique Integers after K Removals](https://leetcode.com/problems/least-number-of-unique-integers-after-k-removals "不同整数的最少数目") | [Go](../problems/least-number-of-unique-integers-after-k-removals) | Medium | +| 1482 | [Minimum Number of Days to Make m Bouquets](https://leetcode.com/problems/minimum-number-of-days-to-make-m-bouquets "制作 m 束花所需的最少天数") | [Go](../problems/minimum-number-of-days-to-make-m-bouquets) | Medium | +| 1483 | [Kth Ancestor of a Tree Node](https://leetcode.com/problems/kth-ancestor-of-a-tree-node "树节点的第 K 个祖先") | [Go](../problems/kth-ancestor-of-a-tree-node) | Hard | +| 1484 | [Group Sold Products By The Date](https://leetcode.com/problems/group-sold-products-by-the-date "按日期分组销售产品") 🔒 | [MySQL](../problems/group-sold-products-by-the-date) | Easy | +| 1485 | [Clone Binary Tree With Random Pointer](https://leetcode.com/problems/clone-binary-tree-with-random-pointer "克隆含随机指针的二叉树") 🔒 | [Go](../problems/clone-binary-tree-with-random-pointer) | Medium | +| 1486 | [XOR Operation in an Array](https://leetcode.com/problems/xor-operation-in-an-array "数组异或操作") | [Go](../problems/xor-operation-in-an-array) | Easy | +| 1487 | [Making File Names Unique](https://leetcode.com/problems/making-file-names-unique "保证文件名唯一") | [Go](../problems/making-file-names-unique) | Medium | +| 1488 | [Avoid Flood in The City](https://leetcode.com/problems/avoid-flood-in-the-city "避免洪水泛滥") | [Go](../problems/avoid-flood-in-the-city) | Medium | +| 1489 | [Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree](https://leetcode.com/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree "找到最小生成树里的关键边和伪关键边") | [Go](../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | Hard | +| 1490 | [Clone N-ary Tree](https://leetcode.com/problems/clone-n-ary-tree "克隆 N 叉树") 🔒 | [Go](../problems/clone-n-ary-tree) | Medium | +| 1491 | [Average Salary Excluding the Minimum and Maximum Salary](https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary "去掉最低工资和最高工资后的工资平均值") | [Go](../problems/average-salary-excluding-the-minimum-and-maximum-salary) | Easy | +| 1492 | [The kth Factor of n](https://leetcode.com/problems/the-kth-factor-of-n "n 的第 k 个因子") | [Go](../problems/the-kth-factor-of-n) | Medium | +| 1493 | [Longest Subarray of 1's After Deleting One Element](https://leetcode.com/problems/longest-subarray-of-1s-after-deleting-one-element "删掉一个元素以后全为 1 的最长子数组") | [Go](../problems/longest-subarray-of-1s-after-deleting-one-element) | Medium | +| 1494 | [Parallel Courses II](https://leetcode.com/problems/parallel-courses-ii "并行课程 II") | [Go](../problems/parallel-courses-ii) | Hard | +| 1495 | [Friendly Movies Streamed Last Month](https://leetcode.com/problems/friendly-movies-streamed-last-month "上月播放的儿童适宜电影") 🔒 | [MySQL](../problems/friendly-movies-streamed-last-month) | Easy | +| 1496 | [Path Crossing](https://leetcode.com/problems/path-crossing "判断路径是否相交") | [Go](../problems/path-crossing) | Easy | +| 1497 | [Check If Array Pairs Are Divisible by k](https://leetcode.com/problems/check-if-array-pairs-are-divisible-by-k "检查数组对是否可以被 k 整除") | [Go](../problems/check-if-array-pairs-are-divisible-by-k) | Medium | +| 1498 | [Number of Subsequences That Satisfy the Given Sum Condition](https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition "满足条件的子序列数目") | [Go](../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | Medium | +| 1499 | [Max Value of Equation](https://leetcode.com/problems/max-value-of-equation "满足不等式的最大值") | [Go](../problems/max-value-of-equation) | Hard | +| 1500 | [Design a File Sharing System](https://leetcode.com/problems/design-a-file-sharing-system "设计文件分享系统") 🔒 | [Go](../problems/design-a-file-sharing-system) | Medium | diff --git a/readme/301-600.md b/readme/301-600.md index bacc496a6..b8b6014d0 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -51,12 +51,12 @@ LeetCode Problems' Solutions [1151-1200] - [1201-1250] - [1251-1300] - [1301-1350] - [1351-1400] - [1401-1450] - [1451-1500] + [1201-1250] + [1251-1300] + [1301-1350] + [1351-1400] + [1401-1450] + [1451-1500] [1501-1550] @@ -66,6 +66,14 @@ LeetCode Problems' Solutions [1701-1750] [1751-1800] + + [1801-1850] + [1851-1900] + [1901-1950] + [1951-2000] + [2001-2050] + [2051-2100] + | # | Title | Solution | Difficulty | diff --git a/readme/601-900.md b/readme/601-900.md index a893646e9..451be2ac1 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -51,12 +51,12 @@ LeetCode Problems' Solutions [1151-1200] - [1201-1250] - [1251-1300] - [1301-1350] - [1351-1400] - [1401-1450] - [1451-1500] + [1201-1250] + [1251-1300] + [1301-1350] + [1351-1400] + [1401-1450] + [1451-1500] [1501-1550] @@ -66,6 +66,14 @@ LeetCode Problems' Solutions [1701-1750] [1751-1800] + + [1801-1850] + [1851-1900] + [1901-1950] + [1951-2000] + [2001-2050] + [2051-2100] + | # | Title | Solution | Difficulty | diff --git a/readme/901-1200.md b/readme/901-1200.md index cdd0dd513..1dbc8639f 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -51,12 +51,12 @@ LeetCode Problems' Solutions [1151-1200] - [1201-1250] - [1251-1300] - [1301-1350] - [1351-1400] - [1401-1450] - [1451-1500] + [1201-1250] + [1251-1300] + [1301-1350] + [1351-1400] + [1401-1450] + [1451-1500] [1501-1550] @@ -66,6 +66,14 @@ LeetCode Problems' Solutions [1701-1750] [1751-1800] + + [1801-1850] + [1851-1900] + [1901-1950] + [1951-2000] + [2001-2050] + [2051-2100] + | # | Title | Solution | Difficulty | diff --git a/tag/README.md b/tag/README.md index d54aea1ae..c51022ce6 100644 --- a/tag/README.md +++ b/tag/README.md @@ -17,8 +17,8 @@ | 11 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | | 15 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | -| 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | -| 19 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 20 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | +| 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | +| 19 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | | 20 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | | 21 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | | 22 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | | 23 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | | 24 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 25 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | diff --git a/tag/array/README.md b/tag/array/README.md index 8dd280a2a..6917adf62 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -314,7 +314,7 @@ | 33 | [搜索旋转排序数组](../../problems/search-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 31 | [下一个排列](../../problems/next-permutation) | [[数组](../array/README.md)] | Medium | | 27 | [移除元素](../../problems/remove-element) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 26 | [删除排序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 26 | [删除有序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 94b8cca71..1f0eaa5fb 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,3 +9,71 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1688 | [比赛中的配对次数](../../problems/count-of-matches-in-tournament) | [[回溯算法](../backtracking/README.md)] | Easy | +| 1681 | [最小不兼容性](../../problems/minimum-incompatibility) | [[贪心算法](../greedy/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[回溯算法](../backtracking/README.md)] | Hard | +| 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[回溯算法](../backtracking/README.md)] | Medium | +| 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1415 | [长度为 n 的开心字符串中字典序第 k 小的字符串](../../problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | [[回溯算法](../backtracking/README.md)] | Medium | +| 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1291 | [顺次数](../../problems/sequential-digits) | [[回溯算法](../backtracking/README.md)] | Medium | +| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1258 | [近义词句子](../../problems/synonymous-sentences) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | +| 1240 | [铺瓷砖](../../problems/tiling-a-rectangle-with-the-fewest-squares) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1239 | [串联字符串的最大长度](../../problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1219 | [黄金矿工](../../problems/path-with-maximum-gold) | [[回溯算法](../backtracking/README.md)] | Medium | +| 1215 | [步进数](../../problems/stepping-numbers) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | +| 1088 | [易混淆数 II](../../problems/confusing-number-ii) 🔒 | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1087 | [花括号展开](../../problems/brace-expansion) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | +| 1079 | [活字印刷](../../problems/letter-tile-possibilities) | [[回溯算法](../backtracking/README.md)] | Medium | +| 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 980 | [不同路径 III](../../problems/unique-paths-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 526 | [优美的排列](../../problems/beautiful-arrangement) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 425 | [单词方块](../../problems/word-squares) 🔒 | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 411 | [最短独占单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 401 | [二进制手表](../../problems/binary-watch) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | +| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 351 | [安卓系统手势解锁](../../problems/android-unlock-patterns) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 306 | [累加数](../../problems/additive-number) | [[回溯算法](../backtracking/README.md)] | Medium | +| 294 | [翻转游戏 II](../../problems/flip-game-ii) 🔒 | [[极小化极大](../minimax/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 291 | [单词规律 II](../../problems/word-pattern-ii) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | +| 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | +| 254 | [因子的组合](../../problems/factor-combinations) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | +| 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 140 | [单词拆分 II](../../problems/word-break-ii) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 93 | [复原 IP 地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 90 | [子集 II](../../problems/subsets-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 89 | [格雷编码](../../problems/gray-code) | [[回溯算法](../backtracking/README.md)] | Medium | +| 79 | [单词搜索](../../problems/word-search) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 77 | [组合](../../problems/combinations) | [[回溯算法](../backtracking/README.md)] | Medium | +| 60 | [排列序列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 52 | [N皇后 II](../../problems/n-queens-ii) | [[回溯算法](../backtracking/README.md)] | Hard | +| 51 | [N 皇后](../../problems/n-queens) | [[回溯算法](../backtracking/README.md)] | Hard | +| 47 | [全排列 II](../../problems/permutations-ii) | [[回溯算法](../backtracking/README.md)] | Medium | +| 46 | [全排列](../../problems/permutations) | [[回溯算法](../backtracking/README.md)] | Medium | +| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 40 | [组合总和 II](../../problems/combination-sum-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 39 | [组合总和](../../problems/combination-sum) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 37 | [解数独](../../problems/sudoku-solver) | [[哈希表](../hash-table/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 66f158290..bb86afc6e 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1802 | [有界数组中指定下标处的最大值](../../problems/maximum-value-at-a-given-index-in-a-bounded-array) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1760 | [袋子里最少数目的球](../../problems/minimum-limit-of-balls-in-a-bag) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1751 | [最多可以参加的会议数目 II](../../problems/maximum-number-of-events-that-can-be-attended-ii) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1739 | [放置盒子](../../problems/building-boxes) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | diff --git a/tag/brainteaser/README.md b/tag/brainteaser/README.md index 64fa3edd0..5c1d0aff4 100644 --- a/tag/brainteaser/README.md +++ b/tag/brainteaser/README.md @@ -9,3 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1503 | [所有蚂蚁掉下来前的最后一刻](../../problems/last-moment-before-all-ants-fall-out-of-a-plank) | [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] | Medium | +| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1033 | [移动石子直到连续](../../problems/moving-stones-until-consecutive) | [[脑筋急转弯](../brainteaser/README.md)] | Easy | +| 777 | [在LR字符串中交换相邻字符](../../problems/swap-adjacent-in-lr-string) | [[脑筋急转弯](../brainteaser/README.md)] | Medium | +| 521 | [最长特殊序列 Ⅰ](../../problems/longest-uncommon-subsequence-i) | [[脑筋急转弯](../brainteaser/README.md)] [[字符串](../string/README.md)] | Easy | +| 319 | [灯泡开关](../../problems/bulb-switcher) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Medium | +| 292 | [Nim 游戏](../../problems/nim-game) | [[脑筋急转弯](../brainteaser/README.md)] [[极小化极大](../minimax/README.md)] | Easy | diff --git a/tag/design/README.md b/tag/design/README.md index 14091cf0c..7af1d3fff 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,3 +9,64 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1797 | [设计一个验证系统](../../problems/design-authentication-manager) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Easy | +| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard | +| 1603 | [设计停车系统](../../problems/design-parking-system) | [[设计](../design/README.md)] | Easy | +| 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[设计](../design/README.md)] | Medium | +| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] | Medium | +| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | +| 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] | Medium | +| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] | Medium | +| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1206 | [设计跳表](../../problems/design-skiplist) | [[设计](../design/README.md)] | Hard | +| 1172 | [餐盘栈](../../problems/dinner-plate-stacks) | [[设计](../design/README.md)] | Hard | +| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 716 | [最大栈](../../problems/max-stack) 🔒 | [[设计](../design/README.md)] | Easy | +| 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy | +| 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Hard | +| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | +| 631 | [设计 Excel 求和公式](../../problems/design-excel-sum-formula) 🔒 | [[设计](../design/README.md)] | Hard | +| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] | Easy | +| 588 | [设计内存文件系统](../../problems/design-in-memory-file-system) 🔒 | [[设计](../design/README.md)] | Hard | +| 460 | [LFU 缓存](../../problems/lfu-cache) | [[设计](../design/README.md)] | Hard | +| 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] | Hard | +| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 362 | [敲击计数器](../../problems/design-hit-counter) 🔒 | [[设计](../design/README.md)] | Medium | +| 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 348 | [设计井字棋](../../problems/design-tic-tac-toe) 🔒 | [[设计](../design/README.md)] | Medium | +| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | +| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | +| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard | +| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard | +| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] | Medium | +| 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] | Medium | +| 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] | Medium | +| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium | +| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index d831e0c26..785185547 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1787 | [使所有区间的异或结果为零](../../problems/make-the-xor-of-all-segments-equal-to-zero) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1771 | [由子序列构造的最长回文串的长度](../../problems/maximize-palindrome-length-from-subsequences) | [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index 5a8521ed2..085448301 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -9,3 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard | +| 1515 | [服务中心的最佳位置](../../problems/best-position-for-a-service-centre) | [[几何](../geometry/README.md)] | Hard | +| 1453 | [圆形靶内的最大飞镖数量](../../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | [[几何](../geometry/README.md)] | Hard | +| 1401 | [圆和矩形是否有重叠](../../problems/circle-and-rectangle-overlapping) | [[几何](../geometry/README.md)] | Medium | +| 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] | Easy | +| 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | +| 892 | [三维形体的表面积](../../problems/surface-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | +| 587 | [安装栅栏](../../problems/erect-the-fence) | [[几何](../geometry/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index b0dee529a..22929b33d 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1791 | [找出星型图的中心节点](../../problems/find-center-of-star-graph) | [[图](../graph/README.md)] | Medium | | 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1782 | [统计点对的数目](../../problems/count-pairs-of-nodes) | [[图](../graph/README.md)] | Hard | | 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 81f982b38..be24a7a70 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,147 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1788 | [Maximize the Beauty of the Garden](../../problems/maximize-the-beauty-of-the-garden) 🔒 | [[贪心算法](../greedy/README.md)] | Hard | -| 1785 | [构成特定和需要添加的最少元素](../../problems/minimum-elements-to-add-to-form-a-given-sum) | [[贪心算法](../greedy/README.md)] | Medium | -| 1784 | [检查二进制字符串字段](../../problems/check-if-binary-string-has-at-most-one-segment-of-ones) | [[贪心算法](../greedy/README.md)] | Easy | -| 1775 | [通过最少操作次数使数组的和相等](../../problems/equal-sum-arrays-with-minimum-number-of-operations) | [[贪心算法](../greedy/README.md)] | Medium | -| 1774 | [最接近目标价格的甜点成本](../../problems/closest-dessert-cost) | [[贪心算法](../greedy/README.md)] | Medium | -| 1769 | [移动所有球到每个盒子所需的最小操作数](../../problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1764 | [通过连接另一个数组的子数组得到一个数组](../../problems/form-array-by-concatenating-subarrays-of-another-array) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1762 | [能看到海景的建筑物](../../problems/buildings-with-an-ocean-view) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | -| 1759 | [统计同构子字符串的数目](../../problems/count-number-of-homogenous-substrings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1758 | [生成交替二进制字符串的最少操作数](../../problems/minimum-changes-to-make-alternating-binary-string) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 1754 | [构造字典序最大的合并字符串](../../problems/largest-merge-of-two-strings) | [[贪心算法](../greedy/README.md)] | Medium | -| 1749 | [任意子数组和的绝对值的最大值](../../problems/maximum-absolute-sum-of-any-subarray) | [[贪心算法](../greedy/README.md)] | Medium | -| 1743 | [从相邻元素对还原数组](../../problems/restore-the-array-from-adjacent-pairs) | [[贪心算法](../greedy/README.md)] | Medium | -| 1737 | [满足三条件之一需改变的最少字符数](../../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1736 | [替换隐藏数字得到的最晚时间](../../problems/latest-time-by-replacing-hidden-digits) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | -| 1733 | [需要教语言的最少人数](../../problems/minimum-number-of-people-to-teach) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1727 | [重新排列后的最大子矩阵](../../problems/largest-submatrix-with-rearrangements) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1725 | [可以形成最大正方形的矩形数目](../../problems/number-of-rectangles-that-can-form-the-largest-square) | [[贪心算法](../greedy/README.md)] | Easy | -| 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[贪心算法](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 1717 | [删除子字符串的最大得分](../../problems/maximum-score-from-removing-substrings) | [[贪心算法](../greedy/README.md)] | Medium | -| 1716 | [计算力扣银行的钱](../../problems/calculate-money-in-leetcode-bank) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Easy | -| 1713 | [得到子序列的最少操作次数](../../problems/minimum-operations-to-make-a-subsequence) | [[贪心算法](../greedy/README.md)] | Hard | -| 1710 | [卡车上的最大单元数](../../problems/maximum-units-on-a-truck) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | -| 1708 | [长度为 K 的最大子数组](../../problems/largest-subarray-length-k) 🔒 | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 1705 | [吃苹果的最大数目](../../problems/maximum-number-of-eaten-apples) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 1702 | [修改后的最大二进制字符串](../../problems/maximum-binary-string-after-change) | [[贪心算法](../greedy/README.md)] | Medium | -| 1689 | [十-二进制数的最少数目](../../problems/partitioning-into-minimum-number-of-deci-binary-numbers) | [[贪心算法](../greedy/README.md)] | Medium | -| 1686 | [石子游戏 VI](../../problems/stone-game-vi) | [[贪心算法](../greedy/README.md)] | Medium | -| 1685 | [有序数组中差绝对值之和](../../problems/sum-of-absolute-differences-in-a-sorted-array) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 1681 | [最小不兼容性](../../problems/minimum-incompatibility) | [[贪心算法](../greedy/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1674 | [使数组互补的最少操作次数](../../problems/minimum-moves-to-make-array-complementary) | [[贪心算法](../greedy/README.md)] | Medium | -| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | -| 1665 | [完成所有任务的最少初始能量](../../problems/minimum-initial-energy-to-finish-tasks) | [[贪心算法](../greedy/README.md)] | Hard | -| 1664 | [生成平衡数组的方案数](../../problems/ways-to-make-a-fair-array) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1663 | [具有给定数值的最小字符串](../../problems/smallest-string-with-a-given-numeric-value) | [[贪心算法](../greedy/README.md)] | Medium | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1657 | [确定两个字符串是否接近](../../problems/determine-if-two-strings-are-close) | [[贪心算法](../greedy/README.md)] | Medium | -| 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | -| 1647 | [字符频次唯一的最小删除次数](../../problems/minimum-deletions-to-make-character-frequencies-unique) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] | Hard | -| 1620 | [网络信号最好的坐标](../../problems/coordinate-with-maximum-network-quality) | [[贪心算法](../greedy/README.md)] | Medium | -| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1605 | [给定行和列的和求可行矩阵](../../problems/find-valid-matrix-given-row-and-column-sums) | [[贪心算法](../greedy/README.md)] | Medium | -| 1599 | [经营摩天轮的最大利润](../../problems/maximum-profit-of-operating-a-centennial-wheel) | [[贪心算法](../greedy/README.md)] | Medium | -| 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1591 | [奇怪的打印机 II](../../problems/strange-printer-ii) | [[贪心算法](../greedy/README.md)] | Hard | -| 1589 | [所有排列中的最大和](../../problems/maximum-sum-obtained-of-any-permutation) | [[贪心算法](../greedy/README.md)] | Medium | -| 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | -| 1580 | [把箱子放进仓库里 II](../../problems/put-boxes-into-the-warehouse-ii) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心算法](../greedy/README.md)] | Medium | -| 1568 | [使陆地分离的最少天数](../../problems/minimum-number-of-days-to-disconnect-island) | [[贪心算法](../greedy/README.md)] | Hard | -| 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心算法](../greedy/README.md)] | Medium | -| 1564 | [把箱子放进仓库里 I](../../problems/put-boxes-into-the-warehouse-i) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | -| 1558 | [得到目标数组的最少函数调用次数](../../problems/minimum-numbers-of-function-calls-to-make-target-array) | [[贪心算法](../greedy/README.md)] | Medium | -| 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心算法](../greedy/README.md)] | Medium | -| 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心算法](../greedy/README.md)] | Hard | -| 1518 | [换酒问题](../../problems/water-bottles) | [[贪心算法](../greedy/README.md)] | Easy | -| 1505 | [最多 K 次交换相邻数位后得到的最小整数](../../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | [[贪心算法](../greedy/README.md)] | Hard | -| 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1414 | [和为 K 的最少斐波那契数字数目](../../problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | -| 1400 | [构造 K 个回文字符串](../../problems/construct-k-palindrome-strings) | [[贪心算法](../greedy/README.md)] | Medium | -| 1386 | [安排电影院座位](../../problems/cinema-seat-allocation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Hard | -| 1354 | [多次求和构造目标数组](../../problems/construct-target-array-with-multiple-sums) | [[贪心算法](../greedy/README.md)] | Hard | -| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | -| 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1326 | [灌溉花园的最少水龙头数目](../../problems/minimum-number-of-taps-to-open-to-water-a-garden) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1282 | [用户分组](../../problems/group-the-people-given-the-group-size-they-belong-to) | [[贪心算法](../greedy/README.md)] | Medium | -| 1276 | [不浪费原料的汉堡制作方案](../../problems/number-of-burgers-with-no-waste-of-ingredients) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 1253 | [重构 2 行二进制矩阵](../../problems/reconstruct-a-2-row-binary-matrix) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 1247 | [交换字符使得字符串相同](../../problems/minimum-swaps-to-make-strings-equal) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1231 | [分享巧克力](../../problems/divide-chocolate) 🔒 | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1221 | [分割平衡字符串](../../problems/split-a-string-in-balanced-strings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | -| 1217 | [玩筹码](../../problems/minimum-cost-to-move-chips-to-the-same-position) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 1196 | [最多可以买到的苹果数量](../../problems/how-many-apples-can-you-put-into-the-basket) 🔒 | [[贪心算法](../greedy/README.md)] | Easy | -| 1167 | [连接棒材的最低费用](../../problems/minimum-cost-to-connect-sticks) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | -| 1111 | [有效括号的嵌套深度](../../problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1094 | [拼车](../../problems/car-pooling) | [[贪心算法](../greedy/README.md)] | Medium | -| 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1057 | [校园自行车分配](../../problems/campus-bikes) 🔒 | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1055 | [形成字符串的最短路径](../../problems/shortest-way-to-form-string) 🔒 | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1053 | [交换一次的先前排列](../../problems/previous-permutation-with-one-swap) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1046 | [最后一块石头的重量](../../problems/last-stone-weight) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Easy | -| 1029 | [两地调度](../../problems/two-city-scheduling) | [[贪心算法](../greedy/README.md)] | Medium | -| 1007 | [行相等的最少多米诺旋转](../../problems/minimum-domino-rotations-for-equal-row) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1005 | [K 次取反后最大化的数组和](../../problems/maximize-sum-of-array-after-k-negations) | [[贪心算法](../greedy/README.md)] | Easy | -| 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[贪心算法](../greedy/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 991 | [坏了的计算器](../../problems/broken-calculator) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 984 | [不含 AAA 或 BBB 的字符串](../../problems/string-without-aaa-or-bbb) | [[贪心算法](../greedy/README.md)] | Medium | -| 955 | [删列造序 II](../../problems/delete-columns-to-make-sorted-ii) | [[贪心算法](../greedy/README.md)] | Medium | -| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 944 | [删列造序](../../problems/delete-columns-to-make-sorted) | [[贪心算法](../greedy/README.md)] | Easy | -| 936 | [戳印序列](../../problems/stamping-the-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | -| 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 921 | [使括号有效的最少添加](../../problems/minimum-add-to-make-parentheses-valid) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 910 | [最小差值 II](../../problems/smallest-range-ii) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 874 | [模拟行走机器人](../../problems/walking-robot-simulation) | [[贪心算法](../greedy/README.md)] | Easy | -| 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 861 | [翻转矩阵后的得分](../../problems/score-after-flipping-matrix) | [[贪心算法](../greedy/README.md)] | Medium | -| 860 | [柠檬水找零](../../problems/lemonade-change) | [[贪心算法](../greedy/README.md)] | Easy | -| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | -| 757 | [设置交集大小至少为2](../../problems/set-intersection-size-at-least-two) | [[贪心算法](../greedy/README.md)] | Hard | -| 738 | [单调递增的数字](../../problems/monotone-increasing-digits) | [[贪心算法](../greedy/README.md)] | Medium | -| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 651 | [4键键盘](../../problems/4-keys-keyboard) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 649 | [Dota2 参议院](../../problems/dota2-senate) | [[贪心算法](../greedy/README.md)] | Medium | -| 630 | [课程表 III](../../problems/course-schedule-iii) | [[贪心算法](../greedy/README.md)] | Hard | -| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | -| 605 | [种花问题](../../problems/can-place-flowers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 502 | [IPO](../../problems/ipo) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | -| 484 | [寻找排列](../../problems/find-permutation) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | -| 455 | [分发饼干](../../problems/assign-cookies) | [[贪心算法](../greedy/README.md)] | Easy | -| 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 435 | [无重叠区间](../../problems/non-overlapping-intervals) | [[贪心算法](../greedy/README.md)] | Medium | -| 406 | [根据身高重建队列](../../problems/queue-reconstruction-by-height) | [[贪心算法](../greedy/README.md)] | Medium | -| 402 | [移掉K位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 330 | [按要求补齐数组](../../problems/patching-array) | [[贪心算法](../greedy/README.md)] | Hard | -| 321 | [拼接最大数](../../problems/create-maximum-number) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 135 | [分发糖果](../../problems/candy) | [[贪心算法](../greedy/README.md)] | Hard | -| 134 | [加油站](../../problems/gas-station) | [[贪心算法](../greedy/README.md)] | Medium | -| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 55 | [跳跃游戏](../../problems/jump-game) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 1adf15714..e059ec8c0 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,3 +9,146 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1797 | [设计一个验证系统](../../problems/design-authentication-manager) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1781 | [所有子字符串美丽值之和](../../problems/sum-of-beauty-of-all-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1772 | [按受欢迎程度排列功能](../../problems/sort-features-by-popularity) 🔒 | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1748 | [唯一元素的和](../../problems/sum-of-unique-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1726 | [同积元组](../../problems/tuple-with-same-product) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1679 | [K 和数对的最大数目](../../problems/max-number-of-k-sum-pairs) | [[哈希表](../hash-table/README.md)] | Medium | +| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1418 | [点菜展示表](../../problems/display-table-of-food-orders-in-a-restaurant) | [[哈希表](../hash-table/README.md)] | Medium | +| 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1224 | [最大相等频率](../../problems/maximum-equal-frequency) | [[哈希表](../hash-table/README.md)] | Hard | +| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1207 | [独一无二的出现次数](../../problems/unique-number-of-occurrences) | [[哈希表](../hash-table/README.md)] | Easy | +| 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1189 | [“气球” 的最大数量](../../problems/maximum-number-of-balloons) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1178 | [猜字谜](../../problems/number-of-valid-words-for-each-puzzle) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1160 | [拼写单词](../../problems/find-words-that-can-be-formed-by-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1138 | [字母板上的路径](../../problems/alphabet-board-path) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1133 | [最大唯一数](../../problems/largest-unique-number) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1078 | [Bigram 分词](../../problems/occurrences-after-bigram) | [[哈希表](../hash-table/README.md)] | Easy | +| 1072 | [按列翻转得到最大值等行数](../../problems/flip-columns-for-maximum-number-of-equal-rows) | [[哈希表](../hash-table/README.md)] | Medium | +| 1048 | [最长字符串链](../../problems/longest-string-chain) | [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1001 | [网格照明](../../problems/grid-illumination) | [[哈希表](../hash-table/README.md)] | Hard | +| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 974 | [和可被 K 整除的子数组](../../problems/subarray-sums-divisible-by-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 970 | [强整数](../../problems/powerful-integers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 961 | [重复 N 次的元素](../../problems/n-repeated-element-in-size-2n-array) | [[哈希表](../hash-table/README.md)] | Easy | +| 957 | [N 天后的牢房](../../problems/prison-cells-after-n-days) | [[哈希表](../hash-table/README.md)] | Medium | +| 954 | [二倍数对数组](../../problems/array-of-doubled-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 953 | [验证外星语词典](../../problems/verifying-an-alien-dictionary) | [[哈希表](../hash-table/README.md)] | Easy | +| 939 | [最小面积矩形](../../problems/minimum-area-rectangle) | [[哈希表](../hash-table/README.md)] | Medium | +| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 884 | [两句话中的不常见单词](../../problems/uncommon-words-from-two-sentences) | [[哈希表](../hash-table/README.md)] | Easy | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[哈希表](../hash-table/README.md)] | Easy | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 771 | [宝石与石头](../../problems/jewels-and-stones) | [[哈希表](../hash-table/README.md)] | Easy | +| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 760 | [找出变位映射](../../problems/find-anagram-mappings) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | +| 748 | [最短补全词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] | Easy | +| 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | +| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[堆](../heap/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 676 | [实现一个魔法字典](../../problems/implement-magic-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 648 | [单词替换](../../problems/replace-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 645 | [错误的集合](../../problems/set-mismatch) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 599 | [两个列表的最小索引总和](../../problems/minimum-index-sum-of-two-lists) | [[哈希表](../hash-table/README.md)] | Easy | +| 594 | [最长和谐子序列](../../problems/longest-harmonious-subsequence) | [[哈希表](../hash-table/README.md)] | Easy | +| 575 | [分糖果](../../problems/distribute-candies) | [[哈希表](../hash-table/README.md)] | Easy | +| 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 554 | [砖墙](../../problems/brick-wall) | [[哈希表](../hash-table/README.md)] | Medium | +| 535 | [TinyURL 的加密与解密](../../problems/encode-and-decode-tinyurl) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 525 | [连续数组](../../problems/contiguous-array) | [[哈希表](../hash-table/README.md)] | Medium | +| 508 | [出现次数最多的子树元素和](../../problems/most-frequent-subtree-sum) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 500 | [键盘行](../../problems/keyboard-row) | [[哈希表](../hash-table/README.md)] | Easy | +| 463 | [岛屿的周长](../../problems/island-perimeter) | [[哈希表](../hash-table/README.md)] | Easy | +| 454 | [四数相加 II](../../problems/4sum-ii) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 447 | [回旋镖的数量](../../problems/number-of-boomerangs) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 438 | [找到字符串中所有字母异位词](../../problems/find-all-anagrams-in-a-string) | [[哈希表](../hash-table/README.md)] | Medium | +| 409 | [最长回文串](../../problems/longest-palindrome) | [[哈希表](../hash-table/README.md)] | Easy | +| 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 356 | [直线镜像](../../problems/line-reflection) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 325 | [和等于 k 的最长子数组长度](../../problems/maximum-size-subarray-sum-equals-k) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | +| 311 | [稀疏矩阵的乘法](../../problems/sparse-matrix-multiplication) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | +| 299 | [猜数字游戏](../../problems/bulls-and-cows) | [[哈希表](../hash-table/README.md)] | Medium | +| 290 | [单词规律](../../problems/word-pattern) | [[哈希表](../hash-table/README.md)] | Easy | +| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 274 | [H 指数](../../problems/h-index) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 266 | [回文排列](../../problems/palindrome-permutation) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | +| 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 246 | [中心对称数](../../problems/strobogrammatic-number) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 242 | [有效的字母异位词](../../problems/valid-anagram) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 219 | [存在重复元素 II](../../problems/contains-duplicate-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 217 | [存在重复元素](../../problems/contains-duplicate) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 205 | [同构字符串](../../problems/isomorphic-strings) | [[哈希表](../hash-table/README.md)] | Easy | +| 204 | [计数质数](../../problems/count-primes) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 202 | [快乐数](../../problems/happy-number) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 187 | [重复的DNA序列](../../problems/repeated-dna-sequences) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 138 | [复制带随机指针的链表](../../problems/copy-list-with-random-pointer) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 136 | [只出现一次的数字](../../problems/single-number) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 37 | [解数独](../../problems/sudoku-solver) | [[哈希表](../hash-table/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 36 | [有效的数独](../../problems/valid-sudoku) | [[哈希表](../hash-table/README.md)] | Medium | +| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1 | [两数之和](../../problems/two-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/heap/README.md b/tag/heap/README.md index 4a7028b71..a51615a33 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 1792 | [最大平均通过率](../../problems/maximum-average-pass-ratio) | [[堆](../heap/README.md)] | Medium | | 1760 | [袋子里最少数目的球](../../problems/minimum-limit-of-balls-in-a-bag) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1753 | [移除石子的最大得分](../../problems/maximum-score-from-removing-stones) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | | 1705 | [吃苹果的最大数目](../../problems/maximum-number-of-eaten-apples) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md index 592ea3e0f..932db1472 100644 --- a/tag/line-sweep/README.md +++ b/tag/line-sweep/README.md @@ -9,3 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | +| 391 | [完美矩形](../../problems/perfect-rectangle) | [[Line Sweep](../line-sweep/README.md)] | Hard | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/math/README.md b/tag/math/README.md index 7b2bfa353..98b0edc3b 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -169,7 +169,7 @@ | 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 367 | [有效的完全平方数](../../problems/valid-perfect-square) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 365 | [水壶问题](../../problems/water-and-jug-problem) | [[数学](../math/README.md)] | Medium | -| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 356 | [直线镜像](../../problems/line-reflection) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 343 | [整数拆分](../../problems/integer-break) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index 85faedb8e..52afd5989 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -9,17 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | -| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 855 | [考场就座](../../problems/exam-room) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 846 | [一手顺子](../../problems/hand-of-straights) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 731 | [我的日程安排表 II](../../problems/my-calendar-ii) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 683 | [K 个关闭的灯泡](../../problems/k-empty-slots) 🔒 | [[Ordered Map](../ordered-map/README.md)] | Hard | -| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index 0c9155aea..8922feba8 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -9,14 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | -| 933 | [最近的请求次数](../../problems/number-of-recent-calls) | [[队列](../queue/README.md)] | Easy | -| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | -| 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | -| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | -| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 42f90d3a9..1989c8da1 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -9,3 +9,42 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[递归](../recursion/README.md)] | Easy | +| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[递归](../recursion/README.md)] | Medium | +| 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | +| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | +| 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | +| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | +| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Easy | +| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/rejection-sampling/README.md b/tag/rejection-sampling/README.md index 8622c93e1..fc2d396f2 100644 --- a/tag/rejection-sampling/README.md +++ b/tag/rejection-sampling/README.md @@ -9,3 +9,5 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | +| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index 469d3f3fb..a49d290d1 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -66,6 +66,7 @@ | 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | | 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/stack/README.md b/tag/stack/README.md index 23154cbab..238b0b4da 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -9,3 +9,67 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1703 | [得到连续 K 个 1 的最少相邻交换次数](../../problems/minimum-adjacent-swaps-for-k-consecutive-ones) | [[栈](../stack/README.md)] | Hard | +| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | +| 1598 | [文件夹操作日志搜集器](../../problems/crawler-log-folder) | [[栈](../stack/README.md)] | Easy | +| 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | +| 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1441 | [用栈操作构建数组](../../problems/build-an-array-with-stack-operations) | [[栈](../stack/README.md)] | Easy | +| 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | +| 1249 | [移除无效的括号](../../problems/minimum-remove-to-make-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1209 | [删除字符串中的所有相邻重复项 II](../../problems/remove-all-adjacent-duplicates-in-string-ii) | [[栈](../stack/README.md)] | Medium | +| 1190 | [反转每对括号间的子串](../../problems/reverse-substrings-between-each-pair-of-parentheses) | [[栈](../stack/README.md)] | Medium | +| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1124 | [表现良好的最长时间段](../../problems/longest-well-performing-interval) | [[栈](../stack/README.md)] | Medium | +| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1063 | [有效子数组的数目](../../problems/number-of-valid-subarrays) 🔒 | [[栈](../stack/README.md)] | Hard | +| 1047 | [删除字符串中的所有相邻重复项](../../problems/remove-all-adjacent-duplicates-in-string) | [[栈](../stack/README.md)] | Easy | +| 1021 | [删除最外层的括号](../../problems/remove-outermost-parentheses) | [[栈](../stack/README.md)] | Easy | +| 1019 | [链表中的下一个更大节点](../../problems/next-greater-node-in-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 1003 | [检查替换后的词是否有效](../../problems/check-if-word-is-valid-after-substitutions) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 946 | [验证栈序列](../../problems/validate-stack-sequences) | [[栈](../stack/README.md)] | Medium | +| 921 | [使括号有效的最少添加](../../problems/minimum-add-to-make-parentheses-valid) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 907 | [子数组的最小值之和](../../problems/sum-of-subarray-minimums) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Medium | +| 901 | [股票价格跨度](../../problems/online-stock-span) | [[栈](../stack/README.md)] | Medium | +| 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 880 | [索引处的解码字符串](../../problems/decoded-string-at-index) | [[栈](../stack/README.md)] | Medium | +| 856 | [括号的分数](../../problems/score-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | +| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 735 | [行星碰撞](../../problems/asteroid-collision) | [[栈](../stack/README.md)] | Medium | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 682 | [棒球比赛](../../problems/baseball-game) | [[栈](../stack/README.md)] | Easy | +| 636 | [函数的独占时间](../../problems/exclusive-time-of-functions) | [[栈](../stack/README.md)] | Medium | +| 591 | [标签验证器](../../problems/tag-validator) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | +| 503 | [下一个更大元素 II](../../problems/next-greater-element-ii) | [[栈](../stack/README.md)] | Medium | +| 496 | [下一个更大元素 I](../../problems/next-greater-element-i) | [[栈](../stack/README.md)] | Easy | +| 456 | [132模式](../../problems/132-pattern) | [[栈](../stack/README.md)] | Medium | +| 439 | [三元表达式解析器](../../problems/ternary-expression-parser) 🔒 | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 402 | [移掉K位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 385 | [迷你语法分析器](../../problems/mini-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | +| 331 | [验证二叉树的前序序列化](../../problems/verify-preorder-serialization-of-a-binary-tree) | [[栈](../stack/README.md)] | Medium | +| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Hard | +| 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | +| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 224 | [基本计算器](../../problems/basic-calculator) | [[栈](../stack/README.md)] [[数学](../math/README.md)] | Hard | +| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] | Medium | +| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | +| 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | +| 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 84 | [柱状图中最大的矩形](../../problems/largest-rectangle-in-histogram) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Hard | +| 71 | [简化路径](../../problems/simplify-path) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 20 | [有效的括号](../../problems/valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | diff --git a/tag/string/README.md b/tag/string/README.md index d7176ade4..dabd214b3 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,224 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1781 | [所有子字符串美丽值之和](../../problems/sum-of-beauty-of-all-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1773 | [统计匹配检索规则的物品数量](../../problems/count-items-matching-a-rule) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | -| 1768 | [交替合并字符串](../../problems/merge-strings-alternately) | [[字符串](../string/README.md)] | Easy | -| 1763 | [最长的美好子字符串](../../problems/longest-nice-substring) | [[字符串](../string/README.md)] | Easy | -| 1759 | [统计同构子字符串的数目](../../problems/count-number-of-homogenous-substrings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1745 | [回文串分割 IV](../../problems/palindrome-partitioning-iv) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1737 | [满足三条件之一需改变的最少字符数](../../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1736 | [替换隐藏数字得到的最晚时间](../../problems/latest-time-by-replacing-hidden-digits) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | -| 1704 | [判断字符串的两半是否相似](../../problems/determine-if-string-halves-are-alike) | [[字符串](../string/README.md)] | Easy | -| 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | -| 1694 | [重新格式化电话号码](../../problems/reformat-phone-number) | [[字符串](../string/README.md)] | Easy | -| 1684 | [统计一致字符串的数目](../../problems/count-the-number-of-consistent-strings) | [[字符串](../string/README.md)] | Easy | -| 1682 | [最长回文子序列 II](../../problems/longest-palindromic-subsequence-ii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1678 | [设计 Goal 解析器](../../problems/goal-parser-interpretation) | [[字符串](../string/README.md)] | Easy | -| 1668 | [最大重复子字符串](../../problems/maximum-repeating-substring) | [[字符串](../string/README.md)] | Easy | -| 1662 | [检查两个字符串数组是否相等](../../problems/check-if-two-string-arrays-are-equivalent) | [[字符串](../string/README.md)] | Easy | -| 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1624 | [两个相同字符之间的最长子字符串](../../problems/largest-substring-between-two-equal-characters) | [[字符串](../string/README.md)] | Easy | -| 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1614 | [括号的最大嵌套深度](../../problems/maximum-nesting-depth-of-the-parentheses) | [[字符串](../string/README.md)] | Easy | -| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | -| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Hard | -| 1592 | [重新排列单词间的空格](../../problems/rearrange-spaces-between-words) | [[字符串](../string/README.md)] | Easy | -| 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | -| 1576 | [替换所有的问号](../../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | [[字符串](../string/README.md)] | Easy | -| 1573 | [分割字符串的方案数](../../problems/number-of-ways-to-split-a-string) | [[字符串](../string/README.md)] | Medium | -| 1556 | [千位分隔数](../../problems/thousand-separator) | [[字符串](../string/README.md)] | Easy | -| 1545 | [找出第 N 个二进制字符串中的第 K 位](../../problems/find-kth-bit-in-nth-binary-string) | [[字符串](../string/README.md)] | Medium | -| 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | -| 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Hard | -| 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[字符串](../string/README.md)] | Medium | -| 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1513 | [仅含 1 的子串数](../../problems/number-of-substrings-with-only-1s) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 1507 | [转变日期格式](../../problems/reformat-date) | [[字符串](../string/README.md)] | Easy | -| 1496 | [判断路径是否相交](../../problems/path-crossing) | [[字符串](../string/README.md)] | Easy | -| 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1455 | [检查单词是否为句中其他单词的前缀](../../problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | [[字符串](../string/README.md)] | Easy | -| 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1446 | [连续字符](../../problems/consecutive-characters) | [[字符串](../string/README.md)] | Easy | -| 1436 | [旅行终点站](../../problems/destination-city) | [[字符串](../string/README.md)] | Easy | -| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1432 | [改变一个整数能得到的最大差值](../../problems/max-difference-you-can-get-from-changing-an-integer) | [[字符串](../string/README.md)] | Medium | -| 1422 | [分割字符串的最大得分](../../problems/maximum-score-after-splitting-a-string) | [[字符串](../string/README.md)] | Easy | -| 1419 | [数青蛙](../../problems/minimum-number-of-frogs-croaking) | [[字符串](../string/README.md)] | Medium | -| 1417 | [重新格式化字符串](../../problems/reformat-the-string) | [[字符串](../string/README.md)] | Easy | -| 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1408 | [数组中的字符串匹配](../../problems/string-matching-in-an-array) | [[字符串](../string/README.md)] | Easy | -| 1404 | [将二进制表示减到 1 的步骤数](../../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1392 | [最长快乐前缀](../../problems/longest-happy-prefix) | [[字符串](../string/README.md)] | Hard | -| 1374 | [生成每种字符都是奇数个的字符串](../../problems/generate-a-string-with-characters-that-have-odd-counts) | [[字符串](../string/README.md)] | Easy | -| 1371 | [每个元音包含偶数次的最长子字符串](../../problems/find-the-longest-substring-containing-vowels-in-even-counts) | [[字符串](../string/README.md)] | Medium | -| 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | -| 1358 | [包含所有三种字符的子字符串数目](../../problems/number-of-substrings-containing-all-three-characters) | [[字符串](../string/README.md)] | Medium | -| 1347 | [制造字母异位词的最小步骤数](../../problems/minimum-number-of-steps-to-make-two-strings-anagram) | [[字符串](../string/README.md)] | Medium | -| 1332 | [删除回文子序列](../../problems/remove-palindromic-subsequences) | [[字符串](../string/README.md)] | Easy | -| 1328 | [破坏回文串](../../problems/break-a-palindrome) | [[字符串](../string/README.md)] | Medium | -| 1324 | [竖直打印单词](../../problems/print-words-vertically) | [[字符串](../string/README.md)] | Medium | -| 1316 | [不同的循环子字符串](../../problems/distinct-echo-substrings) | [[字符串](../string/README.md)] | Hard | -| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1309 | [解码字母到整数映射](../../problems/decrypt-string-from-alphabet-to-integer-mapping) | [[字符串](../string/README.md)] | Easy | -| 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1271 | [十六进制魔术数字](../../problems/hexspeak) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 1268 | [搜索推荐系统](../../problems/search-suggestions-system) | [[字符串](../string/README.md)] | Medium | -| 1249 | [移除无效的括号](../../problems/minimum-remove-to-make-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1247 | [交换字符使得字符串相同](../../problems/minimum-swaps-to-make-strings-equal) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1233 | [删除子文件夹](../../problems/remove-sub-folders-from-the-filesystem) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | -| 1221 | [分割平衡字符串](../../problems/split-a-string-in-balanced-strings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | -| 1216 | [验证回文字符串 III](../../problems/valid-palindrome-iii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1189 | [“气球” 的最大数量](../../problems/maximum-number-of-balloons) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 1181 | [前后拼接](../../problems/before-and-after-puzzle) 🔒 | [[字符串](../string/README.md)] | Medium | -| 1180 | [统计只含单一字母的子串](../../problems/count-substrings-with-only-one-distinct-letter) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 1177 | [构建回文串检测](../../problems/can-make-palindrome-from-substring) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | -| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1169 | [查询无效交易](../../problems/invalid-transactions) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | -| 1165 | [单行键盘](../../problems/single-row-keyboard) 🔒 | [[字符串](../string/README.md)] | Easy | -| 1163 | [按字典序排在最后的子串](../../problems/last-substring-in-lexicographical-order) | [[字符串](../string/README.md)] | Hard | -| 1156 | [单字符重复子串的最大长度](../../problems/swap-for-longest-repeated-character-substring) | [[字符串](../string/README.md)] | Medium | -| 1138 | [字母板上的路径](../../problems/alphabet-board-path) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1119 | [删去字符串中的元音](../../problems/remove-vowels-from-a-string) 🔒 | [[字符串](../string/README.md)] | Easy | -| 1108 | [IP 地址无效化](../../problems/defanging-an-ip-address) | [[字符串](../string/README.md)] | Easy | -| 1106 | [解析布尔表达式](../../problems/parsing-a-boolean-expression) | [[字符串](../string/README.md)] | Hard | -| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1096 | [花括号展开 II](../../problems/brace-expansion-ii) | [[字符串](../string/README.md)] | Hard | -| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1071 | [字符串的最大公因子](../../problems/greatest-common-divisor-of-strings) | [[字符串](../string/README.md)] | Easy | -| 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Easy | -| 1062 | [最长重复子串](../../problems/longest-repeating-substring) 🔒 | [[字符串](../string/README.md)] | Medium | -| 1023 | [驼峰式匹配](../../problems/camelcase-matching) | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | -| 1016 | [子串能表示从 1 到 N 数字的二进制串](../../problems/binary-string-with-substrings-representing-1-to-n) | [[字符串](../string/README.md)] | Medium | -| 1003 | [检查替换后的词是否有效](../../problems/check-if-word-is-valid-after-substitutions) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 937 | [重新排列日志文件](../../problems/reorder-data-in-log-files) | [[字符串](../string/README.md)] | Easy | -| 936 | [戳印序列](../../problems/stamping-the-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | -| 929 | [独特的电子邮件地址](../../problems/unique-email-addresses) | [[字符串](../string/README.md)] | Easy | -| 925 | [长按键入](../../problems/long-pressed-name) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 917 | [仅仅反转字母](../../problems/reverse-only-letters) | [[字符串](../string/README.md)] | Easy | -| 916 | [单词子集](../../problems/word-subsets) | [[字符串](../string/README.md)] | Medium | -| 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[字符串](../string/README.md)] | Easy | -| 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[字符串](../string/README.md)] | Medium | -| 859 | [亲密字符串](../../problems/buddy-strings) | [[字符串](../string/README.md)] | Easy | -| 856 | [括号的分数](../../problems/score-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 848 | [字母移位](../../problems/shifting-letters) | [[字符串](../string/README.md)] | Medium | -| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 833 | [字符串中的查找与替换](../../problems/find-and-replace-in-string) | [[字符串](../string/README.md)] | Medium | -| 831 | [隐藏个人信息](../../problems/masking-personal-information) | [[字符串](../string/README.md)] | Medium | -| 824 | [山羊拉丁文](../../problems/goat-latin) | [[字符串](../string/README.md)] | Easy | -| 819 | [最常见的单词](../../problems/most-common-word) | [[字符串](../string/README.md)] | Easy | -| 816 | [模糊坐标](../../problems/ambiguous-coordinates) | [[字符串](../string/README.md)] | Medium | -| 809 | [情感丰富的文字](../../problems/expressive-words) | [[字符串](../string/README.md)] | Medium | -| 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[字符串](../string/README.md)] | Easy | -| 800 | [相似 RGB 颜色](../../problems/similar-rgb-color) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 791 | [自定义字符串排序](../../problems/custom-sort-string) | [[字符串](../string/README.md)] | Medium | -| 788 | [旋转数字](../../problems/rotated-digits) | [[字符串](../string/README.md)] | Easy | -| 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | -| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | -| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | -| 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字符串](../string/README.md)] | Easy | -| 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[字符串](../string/README.md)] | Hard | -| 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 722 | [删除注释](../../problems/remove-comments) | [[字符串](../string/README.md)] | Medium | -| 709 | [转换成小写字母](../../problems/to-lower-case) | [[字符串](../string/README.md)] | Easy | -| 696 | [计数二进制子串](../../problems/count-binary-substrings) | [[字符串](../string/README.md)] | Easy | -| 686 | [重复叠加字符串匹配](../../problems/repeated-string-match) | [[字符串](../string/README.md)] | Medium | -| 681 | [最近时刻](../../problems/next-closest-time) 🔒 | [[字符串](../string/README.md)] | Medium | -| 680 | [验证回文字符串 Ⅱ](../../problems/valid-palindrome-ii) | [[字符串](../string/README.md)] | Easy | -| 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[字符串](../string/README.md)] | Medium | -| 657 | [机器人能否返回原点](../../problems/robot-return-to-origin) | [[字符串](../string/README.md)] | Easy | -| 647 | [回文子串](../../problems/palindromic-substrings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | -| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 616 | [给字符串添加加粗标签](../../problems/add-bold-tag-in-string) 🔒 | [[字符串](../string/README.md)] | Medium | -| 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 606 | [根据二叉树创建字符串](../../problems/construct-string-from-binary-tree) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Easy | -| 591 | [标签验证器](../../problems/tag-validator) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | -| 583 | [两个字符串的删除操作](../../problems/delete-operation-for-two-strings) | [[字符串](../string/README.md)] | Medium | -| 564 | [寻找最近的回文数](../../problems/find-the-closest-palindrome) | [[字符串](../string/README.md)] | Hard | -| 557 | [反转字符串中的单词 III](../../problems/reverse-words-in-a-string-iii) | [[字符串](../string/README.md)] | Easy | -| 556 | [下一个更大元素 III](../../problems/next-greater-element-iii) | [[字符串](../string/README.md)] | Medium | -| 555 | [分割连接字符串](../../problems/split-concatenated-strings) 🔒 | [[字符串](../string/README.md)] | Medium | -| 553 | [最优除法](../../problems/optimal-division) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 551 | [学生出勤记录 I](../../problems/student-attendance-record-i) | [[字符串](../string/README.md)] | Easy | -| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | -| 541 | [反转字符串 II](../../problems/reverse-string-ii) | [[字符串](../string/README.md)] | Easy | -| 539 | [最小时间差](../../problems/minimum-time-difference) | [[字符串](../string/README.md)] | Medium | -| 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | -| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Hard | -| 522 | [最长特殊序列 II](../../problems/longest-uncommon-subsequence-ii) | [[字符串](../string/README.md)] | Medium | -| 521 | [最长特殊序列 Ⅰ](../../problems/longest-uncommon-subsequence-i) | [[脑筋急转弯](../brainteaser/README.md)] [[字符串](../string/README.md)] | Easy | -| 520 | [检测大写字母](../../problems/detect-capital) | [[字符串](../string/README.md)] | Easy | -| 468 | [验证IP地址](../../problems/validate-ip-address) | [[字符串](../string/README.md)] | Medium | -| 459 | [重复的子字符串](../../problems/repeated-substring-pattern) | [[字符串](../string/README.md)] | Easy | -| 443 | [压缩字符串](../../problems/string-compression) | [[字符串](../string/README.md)] | Medium | -| 434 | [字符串中的单词数](../../problems/number-of-segments-in-a-string) | [[字符串](../string/README.md)] | Easy | -| 415 | [字符串相加](../../problems/add-strings) | [[字符串](../string/README.md)] | Easy | -| 408 | [有效单词缩写](../../problems/valid-word-abbreviation) 🔒 | [[字符串](../string/README.md)] | Easy | -| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 385 | [迷你语法分析器](../../problems/mini-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 383 | [赎金信](../../problems/ransom-note) | [[字符串](../string/README.md)] | Easy | -| 345 | [反转字符串中的元音字母](../../problems/reverse-vowels-of-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 344 | [反转字符串](../../problems/reverse-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | -| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 293 | [翻转游戏](../../problems/flip-game) 🔒 | [[字符串](../string/README.md)] | Easy | -| 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 271 | [字符串的编码与解码](../../problems/encode-and-decode-strings) 🔒 | [[字符串](../string/README.md)] | Medium | -| 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 214 | [最短回文串](../../problems/shortest-palindrome) | [[字符串](../string/README.md)] | Hard | -| 186 | [翻转字符串里的单词 II](../../problems/reverse-words-in-a-string-ii) 🔒 | [[字符串](../string/README.md)] | Medium | -| 165 | [比较版本号](../../problems/compare-version-numbers) | [[字符串](../string/README.md)] | Medium | -| 161 | [相隔为 1 的编辑距离](../../problems/one-edit-distance) 🔒 | [[字符串](../string/README.md)] | Medium | -| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 158 | [用 Read4 读取 N 个字符 II](../../problems/read-n-characters-given-read4-ii-call-multiple-times) 🔒 | [[字符串](../string/README.md)] | Hard | -| 157 | [用 Read4 读取 N 个字符](../../problems/read-n-characters-given-read4) 🔒 | [[字符串](../string/README.md)] | Easy | -| 151 | [翻转字符串里的单词](../../problems/reverse-words-in-a-string) | [[字符串](../string/README.md)] | Medium | -| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 125 | [验证回文串](../../problems/valid-palindrome) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 115 | [不同的子序列](../../problems/distinct-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 93 | [复原 IP 地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 91 | [解码方法](../../problems/decode-ways) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 87 | [扰乱字符串](../../problems/scramble-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 72 | [编辑距离](../../problems/edit-distance) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 71 | [简化路径](../../problems/simplify-path) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 68 | [文本左右对齐](../../problems/text-justification) | [[字符串](../string/README.md)] | Hard | -| 67 | [二进制求和](../../problems/add-binary) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 65 | [有效数字](../../problems/valid-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 58 | [最后一个单词的长度](../../problems/length-of-last-word) | [[字符串](../string/README.md)] | Easy | -| 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 38 | [外观数列](../../problems/count-and-say) | [[字符串](../string/README.md)] | Easy | -| 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 20 | [有效的括号](../../problems/valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | -| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 14 | [最长公共前缀](../../problems/longest-common-prefix) | [[字符串](../string/README.md)] | Easy | -| 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 8 | [字符串转换整数 (atoi)](../../problems/string-to-integer-atoi) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 6 | [Z 字形变换](../../problems/zigzag-conversion) | [[字符串](../string/README.md)] | Medium | -| 5 | [最长回文子串](../../problems/longest-palindromic-substring) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/tags.json b/tag/tags.json index a013ad07a..af38a6919 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -84,16 +84,16 @@ "Slug": "graph", "TranslatedName": "图" }, - { - "Name": "Linked List", - "Slug": "linked-list", - "TranslatedName": "链表" - }, { "Name": "Heap", "Slug": "heap", "TranslatedName": "堆" }, + { + "Name": "Linked List", + "Slug": "linked-list", + "TranslatedName": "链表" + }, { "Name": "Recursion", "Slug": "recursion", diff --git a/tag/topological-sort/README.md b/tag/topological-sort/README.md index 5a051c022..845df9d71 100644 --- a/tag/topological-sort/README.md +++ b/tag/topological-sort/README.md @@ -9,9 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | -| 444 | [序列重建](../../problems/sequence-reconstruction) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | -| 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | -| 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | diff --git a/tag/trie/README.md b/tag/trie/README.md index 1269938dc..7cb89a16a 100644 --- a/tag/trie/README.md +++ b/tag/trie/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1803 | [统计异或值在范围内的数对有多少](../../problems/count-pairs-with-xor-in-a-range) | [[字典树](../trie/README.md)] | Hard | | 1707 | [与数组中元素的最大异或值](../../problems/maximum-xor-with-an-element-from-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Hard | | 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | | 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 869c5d53e..26051df30 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1800 | [最大升序子数组和](../../problems/maximum-ascending-subarray-sum) | [[双指针](../two-pointers/README.md)] | Easy | | 1750 | [删除字符串两端相同字符后的最短长度](../../problems/minimum-length-of-string-after-deleting-similar-ends) | [[双指针](../two-pointers/README.md)] | Medium | | 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | @@ -49,7 +50,7 @@ | 487 | [最大连续1的个数 II](../../problems/max-consecutive-ones-ii) 🔒 | [[双指针](../two-pointers/README.md)] | Medium | | 457 | [环形数组是否存在循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 345 | [反转字符串中的元音字母](../../problems/reverse-vowels-of-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | @@ -75,7 +76,7 @@ | 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | | 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 27 | [移除元素](../../problems/remove-element) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 26 | [删除排序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 26 | [删除有序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 19 | [删除链表的倒数第 N 个结点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | From 284c10f05ab57ffc6c889386045139d51b07aa57 Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 23 Mar 2021 09:39:04 +0800 Subject: [PATCH 125/145] A: tag --- tag/greedy/README.md | 149 ++++++++++++++++++++++ tag/ordered-map/README.md | 14 +++ tag/queue/README.md | 11 ++ tag/string/README.md | 224 +++++++++++++++++++++++++++++++++ tag/topological-sort/README.md | 6 + tag/tree/README.md | 158 +++++++++++++++++++++++ 6 files changed, 562 insertions(+) diff --git a/tag/greedy/README.md b/tag/greedy/README.md index be24a7a70..d7f88e58d 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,3 +9,152 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1802 | [有界数组中指定下标处的最大值](../../problems/maximum-value-at-a-given-index-in-a-bounded-array) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 1798 | [你能构造出连续值的最大数目](../../problems/maximum-number-of-consecutive-values-you-can-make) | [[贪心算法](../greedy/README.md)] | Medium | +| 1794 | [Count Pairs of Equal Substrings With Minimum Difference](../../problems/count-pairs-of-equal-substrings-with-minimum-difference) 🔒 | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[贪心算法](../greedy/README.md)] | Hard | +| 1788 | [Maximize the Beauty of the Garden](../../problems/maximize-the-beauty-of-the-garden) 🔒 | [[贪心算法](../greedy/README.md)] | Hard | +| 1785 | [构成特定和需要添加的最少元素](../../problems/minimum-elements-to-add-to-form-a-given-sum) | [[贪心算法](../greedy/README.md)] | Medium | +| 1784 | [检查二进制字符串字段](../../problems/check-if-binary-string-has-at-most-one-segment-of-ones) | [[贪心算法](../greedy/README.md)] | Easy | +| 1775 | [通过最少操作次数使数组的和相等](../../problems/equal-sum-arrays-with-minimum-number-of-operations) | [[贪心算法](../greedy/README.md)] | Medium | +| 1774 | [最接近目标价格的甜点成本](../../problems/closest-dessert-cost) | [[贪心算法](../greedy/README.md)] | Medium | +| 1769 | [移动所有球到每个盒子所需的最小操作数](../../problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1764 | [通过连接另一个数组的子数组得到一个数组](../../problems/form-array-by-concatenating-subarrays-of-another-array) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1762 | [能看到海景的建筑物](../../problems/buildings-with-an-ocean-view) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | +| 1759 | [统计同构子字符串的数目](../../problems/count-number-of-homogenous-substrings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1758 | [生成交替二进制字符串的最少操作数](../../problems/minimum-changes-to-make-alternating-binary-string) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 1754 | [构造字典序最大的合并字符串](../../problems/largest-merge-of-two-strings) | [[贪心算法](../greedy/README.md)] | Medium | +| 1749 | [任意子数组和的绝对值的最大值](../../problems/maximum-absolute-sum-of-any-subarray) | [[贪心算法](../greedy/README.md)] | Medium | +| 1743 | [从相邻元素对还原数组](../../problems/restore-the-array-from-adjacent-pairs) | [[贪心算法](../greedy/README.md)] | Medium | +| 1737 | [满足三条件之一需改变的最少字符数](../../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1736 | [替换隐藏数字得到的最晚时间](../../problems/latest-time-by-replacing-hidden-digits) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | +| 1733 | [需要教语言的最少人数](../../problems/minimum-number-of-people-to-teach) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1727 | [重新排列后的最大子矩阵](../../problems/largest-submatrix-with-rearrangements) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 1725 | [可以形成最大正方形的矩形数目](../../problems/number-of-rectangles-that-can-form-the-largest-square) | [[贪心算法](../greedy/README.md)] | Easy | +| 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[贪心算法](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 1717 | [删除子字符串的最大得分](../../problems/maximum-score-from-removing-substrings) | [[贪心算法](../greedy/README.md)] | Medium | +| 1716 | [计算力扣银行的钱](../../problems/calculate-money-in-leetcode-bank) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Easy | +| 1713 | [得到子序列的最少操作次数](../../problems/minimum-operations-to-make-a-subsequence) | [[贪心算法](../greedy/README.md)] | Hard | +| 1710 | [卡车上的最大单元数](../../problems/maximum-units-on-a-truck) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | +| 1708 | [长度为 K 的最大子数组](../../problems/largest-subarray-length-k) 🔒 | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 1705 | [吃苹果的最大数目](../../problems/maximum-number-of-eaten-apples) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 1702 | [修改后的最大二进制字符串](../../problems/maximum-binary-string-after-change) | [[贪心算法](../greedy/README.md)] | Medium | +| 1689 | [十-二进制数的最少数目](../../problems/partitioning-into-minimum-number-of-deci-binary-numbers) | [[贪心算法](../greedy/README.md)] | Medium | +| 1686 | [石子游戏 VI](../../problems/stone-game-vi) | [[贪心算法](../greedy/README.md)] | Medium | +| 1685 | [有序数组中差绝对值之和](../../problems/sum-of-absolute-differences-in-a-sorted-array) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 1681 | [最小不兼容性](../../problems/minimum-incompatibility) | [[贪心算法](../greedy/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1674 | [使数组互补的最少操作次数](../../problems/minimum-moves-to-make-array-complementary) | [[贪心算法](../greedy/README.md)] | Medium | +| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | +| 1665 | [完成所有任务的最少初始能量](../../problems/minimum-initial-energy-to-finish-tasks) | [[贪心算法](../greedy/README.md)] | Hard | +| 1664 | [生成平衡数组的方案数](../../problems/ways-to-make-a-fair-array) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1663 | [具有给定数值的最小字符串](../../problems/smallest-string-with-a-given-numeric-value) | [[贪心算法](../greedy/README.md)] | Medium | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1657 | [确定两个字符串是否接近](../../problems/determine-if-two-strings-are-close) | [[贪心算法](../greedy/README.md)] | Medium | +| 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | +| 1647 | [字符频次唯一的最小删除次数](../../problems/minimum-deletions-to-make-character-frequencies-unique) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] | Hard | +| 1620 | [网络信号最好的坐标](../../problems/coordinate-with-maximum-network-quality) | [[贪心算法](../greedy/README.md)] | Medium | +| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1605 | [给定行和列的和求可行矩阵](../../problems/find-valid-matrix-given-row-and-column-sums) | [[贪心算法](../greedy/README.md)] | Medium | +| 1599 | [经营摩天轮的最大利润](../../problems/maximum-profit-of-operating-a-centennial-wheel) | [[贪心算法](../greedy/README.md)] | Medium | +| 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1591 | [奇怪的打印机 II](../../problems/strange-printer-ii) | [[贪心算法](../greedy/README.md)] | Hard | +| 1589 | [所有排列中的最大和](../../problems/maximum-sum-obtained-of-any-permutation) | [[贪心算法](../greedy/README.md)] | Medium | +| 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | +| 1580 | [把箱子放进仓库里 II](../../problems/put-boxes-into-the-warehouse-ii) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | +| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心算法](../greedy/README.md)] | Medium | +| 1568 | [使陆地分离的最少天数](../../problems/minimum-number-of-days-to-disconnect-island) | [[贪心算法](../greedy/README.md)] | Hard | +| 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心算法](../greedy/README.md)] | Medium | +| 1564 | [把箱子放进仓库里 I](../../problems/put-boxes-into-the-warehouse-i) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | +| 1558 | [得到目标数组的最少函数调用次数](../../problems/minimum-numbers-of-function-calls-to-make-target-array) | [[贪心算法](../greedy/README.md)] | Medium | +| 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心算法](../greedy/README.md)] | Medium | +| 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心算法](../greedy/README.md)] | Hard | +| 1518 | [换酒问题](../../problems/water-bottles) | [[贪心算法](../greedy/README.md)] | Easy | +| 1505 | [最多 K 次交换相邻数位后得到的最小整数](../../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | [[贪心算法](../greedy/README.md)] | Hard | +| 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1414 | [和为 K 的最少斐波那契数字数目](../../problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | +| 1400 | [构造 K 个回文字符串](../../problems/construct-k-palindrome-strings) | [[贪心算法](../greedy/README.md)] | Medium | +| 1386 | [安排电影院座位](../../problems/cinema-seat-allocation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Hard | +| 1354 | [多次求和构造目标数组](../../problems/construct-target-array-with-multiple-sums) | [[贪心算法](../greedy/README.md)] | Hard | +| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | +| 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1326 | [灌溉花园的最少水龙头数目](../../problems/minimum-number-of-taps-to-open-to-water-a-garden) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1282 | [用户分组](../../problems/group-the-people-given-the-group-size-they-belong-to) | [[贪心算法](../greedy/README.md)] | Medium | +| 1276 | [不浪费原料的汉堡制作方案](../../problems/number-of-burgers-with-no-waste-of-ingredients) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 1253 | [重构 2 行二进制矩阵](../../problems/reconstruct-a-2-row-binary-matrix) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 1247 | [交换字符使得字符串相同](../../problems/minimum-swaps-to-make-strings-equal) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1231 | [分享巧克力](../../problems/divide-chocolate) 🔒 | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1221 | [分割平衡字符串](../../problems/split-a-string-in-balanced-strings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | +| 1217 | [玩筹码](../../problems/minimum-cost-to-move-chips-to-the-same-position) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1196 | [最多可以买到的苹果数量](../../problems/how-many-apples-can-you-put-into-the-basket) 🔒 | [[贪心算法](../greedy/README.md)] | Easy | +| 1167 | [连接棒材的最低费用](../../problems/minimum-cost-to-connect-sticks) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | +| 1111 | [有效括号的嵌套深度](../../problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1094 | [拼车](../../problems/car-pooling) | [[贪心算法](../greedy/README.md)] | Medium | +| 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1057 | [校园自行车分配](../../problems/campus-bikes) 🔒 | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 1055 | [形成字符串的最短路径](../../problems/shortest-way-to-form-string) 🔒 | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1053 | [交换一次的先前排列](../../problems/previous-permutation-with-one-swap) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1046 | [最后一块石头的重量](../../problems/last-stone-weight) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Easy | +| 1029 | [两地调度](../../problems/two-city-scheduling) | [[贪心算法](../greedy/README.md)] | Medium | +| 1007 | [行相等的最少多米诺旋转](../../problems/minimum-domino-rotations-for-equal-row) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1005 | [K 次取反后最大化的数组和](../../problems/maximize-sum-of-array-after-k-negations) | [[贪心算法](../greedy/README.md)] | Easy | +| 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[贪心算法](../greedy/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 991 | [坏了的计算器](../../problems/broken-calculator) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 984 | [不含 AAA 或 BBB 的字符串](../../problems/string-without-aaa-or-bbb) | [[贪心算法](../greedy/README.md)] | Medium | +| 955 | [删列造序 II](../../problems/delete-columns-to-make-sorted-ii) | [[贪心算法](../greedy/README.md)] | Medium | +| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 944 | [删列造序](../../problems/delete-columns-to-make-sorted) | [[贪心算法](../greedy/README.md)] | Easy | +| 936 | [戳印序列](../../problems/stamping-the-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | +| 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 921 | [使括号有效的最少添加](../../problems/minimum-add-to-make-parentheses-valid) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 910 | [最小差值 II](../../problems/smallest-range-ii) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 874 | [模拟行走机器人](../../problems/walking-robot-simulation) | [[贪心算法](../greedy/README.md)] | Easy | +| 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 861 | [翻转矩阵后的得分](../../problems/score-after-flipping-matrix) | [[贪心算法](../greedy/README.md)] | Medium | +| 860 | [柠檬水找零](../../problems/lemonade-change) | [[贪心算法](../greedy/README.md)] | Easy | +| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | +| 757 | [设置交集大小至少为2](../../problems/set-intersection-size-at-least-two) | [[贪心算法](../greedy/README.md)] | Hard | +| 738 | [单调递增的数字](../../problems/monotone-increasing-digits) | [[贪心算法](../greedy/README.md)] | Medium | +| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 651 | [4键键盘](../../problems/4-keys-keyboard) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 649 | [Dota2 参议院](../../problems/dota2-senate) | [[贪心算法](../greedy/README.md)] | Medium | +| 630 | [课程表 III](../../problems/course-schedule-iii) | [[贪心算法](../greedy/README.md)] | Hard | +| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | +| 605 | [种花问题](../../problems/can-place-flowers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 502 | [IPO](../../problems/ipo) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | +| 484 | [寻找排列](../../problems/find-permutation) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | +| 455 | [分发饼干](../../problems/assign-cookies) | [[贪心算法](../greedy/README.md)] | Easy | +| 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 435 | [无重叠区间](../../problems/non-overlapping-intervals) | [[贪心算法](../greedy/README.md)] | Medium | +| 406 | [根据身高重建队列](../../problems/queue-reconstruction-by-height) | [[贪心算法](../greedy/README.md)] | Medium | +| 402 | [移掉K位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 330 | [按要求补齐数组](../../problems/patching-array) | [[贪心算法](../greedy/README.md)] | Hard | +| 321 | [拼接最大数](../../problems/create-maximum-number) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 135 | [分发糖果](../../problems/candy) | [[贪心算法](../greedy/README.md)] | Hard | +| 134 | [加油站](../../problems/gas-station) | [[贪心算法](../greedy/README.md)] | Medium | +| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 55 | [跳跃游戏](../../problems/jump-game) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index 52afd5989..85faedb8e 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -9,3 +9,17 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | +| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 855 | [考场就座](../../problems/exam-room) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 846 | [一手顺子](../../problems/hand-of-straights) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 731 | [我的日程安排表 II](../../problems/my-calendar-ii) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 683 | [K 个关闭的灯泡](../../problems/k-empty-slots) 🔒 | [[Ordered Map](../ordered-map/README.md)] | Hard | +| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index 8922feba8..0c9155aea 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -9,3 +9,14 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | +| 933 | [最近的请求次数](../../problems/number-of-recent-calls) | [[队列](../queue/README.md)] | Easy | +| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | +| 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | +| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index dabd214b3..49673dbd2 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,3 +9,227 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1796 | [字符串中第二大的数字](../../problems/second-largest-digit-in-a-string) | [[字符串](../string/README.md)] | Easy | +| 1794 | [Count Pairs of Equal Substrings With Minimum Difference](../../problems/count-pairs-of-equal-substrings-with-minimum-difference) 🔒 | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1790 | [仅执行一次字符串交换能否使两个字符串相等](../../problems/check-if-one-string-swap-can-make-strings-equal) | [[字符串](../string/README.md)] | Easy | +| 1781 | [所有子字符串美丽值之和](../../problems/sum-of-beauty-of-all-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1773 | [统计匹配检索规则的物品数量](../../problems/count-items-matching-a-rule) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1768 | [交替合并字符串](../../problems/merge-strings-alternately) | [[字符串](../string/README.md)] | Easy | +| 1763 | [最长的美好子字符串](../../problems/longest-nice-substring) | [[字符串](../string/README.md)] | Easy | +| 1759 | [统计同构子字符串的数目](../../problems/count-number-of-homogenous-substrings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1745 | [回文串分割 IV](../../problems/palindrome-partitioning-iv) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1737 | [满足三条件之一需改变的最少字符数](../../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1736 | [替换隐藏数字得到的最晚时间](../../problems/latest-time-by-replacing-hidden-digits) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | +| 1704 | [判断字符串的两半是否相似](../../problems/determine-if-string-halves-are-alike) | [[字符串](../string/README.md)] | Easy | +| 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | +| 1694 | [重新格式化电话号码](../../problems/reformat-phone-number) | [[字符串](../string/README.md)] | Easy | +| 1684 | [统计一致字符串的数目](../../problems/count-the-number-of-consistent-strings) | [[字符串](../string/README.md)] | Easy | +| 1682 | [最长回文子序列 II](../../problems/longest-palindromic-subsequence-ii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1678 | [设计 Goal 解析器](../../problems/goal-parser-interpretation) | [[字符串](../string/README.md)] | Easy | +| 1668 | [最大重复子字符串](../../problems/maximum-repeating-substring) | [[字符串](../string/README.md)] | Easy | +| 1662 | [检查两个字符串数组是否相等](../../problems/check-if-two-string-arrays-are-equivalent) | [[字符串](../string/README.md)] | Easy | +| 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1624 | [两个相同字符之间的最长子字符串](../../problems/largest-substring-between-two-equal-characters) | [[字符串](../string/README.md)] | Easy | +| 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1614 | [括号的最大嵌套深度](../../problems/maximum-nesting-depth-of-the-parentheses) | [[字符串](../string/README.md)] | Easy | +| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | +| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Hard | +| 1592 | [重新排列单词间的空格](../../problems/rearrange-spaces-between-words) | [[字符串](../string/README.md)] | Easy | +| 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | +| 1576 | [替换所有的问号](../../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | [[字符串](../string/README.md)] | Easy | +| 1573 | [分割字符串的方案数](../../problems/number-of-ways-to-split-a-string) | [[字符串](../string/README.md)] | Medium | +| 1556 | [千位分隔数](../../problems/thousand-separator) | [[字符串](../string/README.md)] | Easy | +| 1545 | [找出第 N 个二进制字符串中的第 K 位](../../problems/find-kth-bit-in-nth-binary-string) | [[字符串](../string/README.md)] | Medium | +| 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | +| 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Hard | +| 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[字符串](../string/README.md)] | Medium | +| 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 1513 | [仅含 1 的子串数](../../problems/number-of-substrings-with-only-1s) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1507 | [转变日期格式](../../problems/reformat-date) | [[字符串](../string/README.md)] | Easy | +| 1496 | [判断路径是否相交](../../problems/path-crossing) | [[字符串](../string/README.md)] | Easy | +| 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1455 | [检查单词是否为句中其他单词的前缀](../../problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | [[字符串](../string/README.md)] | Easy | +| 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1446 | [连续字符](../../problems/consecutive-characters) | [[字符串](../string/README.md)] | Easy | +| 1436 | [旅行终点站](../../problems/destination-city) | [[字符串](../string/README.md)] | Easy | +| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1432 | [改变一个整数能得到的最大差值](../../problems/max-difference-you-can-get-from-changing-an-integer) | [[字符串](../string/README.md)] | Medium | +| 1422 | [分割字符串的最大得分](../../problems/maximum-score-after-splitting-a-string) | [[字符串](../string/README.md)] | Easy | +| 1419 | [数青蛙](../../problems/minimum-number-of-frogs-croaking) | [[字符串](../string/README.md)] | Medium | +| 1417 | [重新格式化字符串](../../problems/reformat-the-string) | [[字符串](../string/README.md)] | Easy | +| 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1408 | [数组中的字符串匹配](../../problems/string-matching-in-an-array) | [[字符串](../string/README.md)] | Easy | +| 1404 | [将二进制表示减到 1 的步骤数](../../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 1392 | [最长快乐前缀](../../problems/longest-happy-prefix) | [[字符串](../string/README.md)] | Hard | +| 1374 | [生成每种字符都是奇数个的字符串](../../problems/generate-a-string-with-characters-that-have-odd-counts) | [[字符串](../string/README.md)] | Easy | +| 1371 | [每个元音包含偶数次的最长子字符串](../../problems/find-the-longest-substring-containing-vowels-in-even-counts) | [[字符串](../string/README.md)] | Medium | +| 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | +| 1358 | [包含所有三种字符的子字符串数目](../../problems/number-of-substrings-containing-all-three-characters) | [[字符串](../string/README.md)] | Medium | +| 1347 | [制造字母异位词的最小步骤数](../../problems/minimum-number-of-steps-to-make-two-strings-anagram) | [[字符串](../string/README.md)] | Medium | +| 1332 | [删除回文子序列](../../problems/remove-palindromic-subsequences) | [[字符串](../string/README.md)] | Easy | +| 1328 | [破坏回文串](../../problems/break-a-palindrome) | [[字符串](../string/README.md)] | Medium | +| 1324 | [竖直打印单词](../../problems/print-words-vertically) | [[字符串](../string/README.md)] | Medium | +| 1316 | [不同的循环子字符串](../../problems/distinct-echo-substrings) | [[字符串](../string/README.md)] | Hard | +| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1309 | [解码字母到整数映射](../../problems/decrypt-string-from-alphabet-to-integer-mapping) | [[字符串](../string/README.md)] | Easy | +| 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 1271 | [十六进制魔术数字](../../problems/hexspeak) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1268 | [搜索推荐系统](../../problems/search-suggestions-system) | [[字符串](../string/README.md)] | Medium | +| 1249 | [移除无效的括号](../../problems/minimum-remove-to-make-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1247 | [交换字符使得字符串相同](../../problems/minimum-swaps-to-make-strings-equal) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1233 | [删除子文件夹](../../problems/remove-sub-folders-from-the-filesystem) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1221 | [分割平衡字符串](../../problems/split-a-string-in-balanced-strings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | +| 1216 | [验证回文字符串 III](../../problems/valid-palindrome-iii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1189 | [“气球” 的最大数量](../../problems/maximum-number-of-balloons) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1181 | [前后拼接](../../problems/before-and-after-puzzle) 🔒 | [[字符串](../string/README.md)] | Medium | +| 1180 | [统计只含单一字母的子串](../../problems/count-substrings-with-only-one-distinct-letter) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1177 | [构建回文串检测](../../problems/can-make-palindrome-from-substring) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1169 | [查询无效交易](../../problems/invalid-transactions) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1165 | [单行键盘](../../problems/single-row-keyboard) 🔒 | [[字符串](../string/README.md)] | Easy | +| 1163 | [按字典序排在最后的子串](../../problems/last-substring-in-lexicographical-order) | [[字符串](../string/README.md)] | Hard | +| 1156 | [单字符重复子串的最大长度](../../problems/swap-for-longest-repeated-character-substring) | [[字符串](../string/README.md)] | Medium | +| 1138 | [字母板上的路径](../../problems/alphabet-board-path) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1119 | [删去字符串中的元音](../../problems/remove-vowels-from-a-string) 🔒 | [[字符串](../string/README.md)] | Easy | +| 1108 | [IP 地址无效化](../../problems/defanging-an-ip-address) | [[字符串](../string/README.md)] | Easy | +| 1106 | [解析布尔表达式](../../problems/parsing-a-boolean-expression) | [[字符串](../string/README.md)] | Hard | +| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1096 | [花括号展开 II](../../problems/brace-expansion-ii) | [[字符串](../string/README.md)] | Hard | +| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1071 | [字符串的最大公因子](../../problems/greatest-common-divisor-of-strings) | [[字符串](../string/README.md)] | Easy | +| 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Easy | +| 1062 | [最长重复子串](../../problems/longest-repeating-substring) 🔒 | [[字符串](../string/README.md)] | Medium | +| 1023 | [驼峰式匹配](../../problems/camelcase-matching) | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | +| 1016 | [子串能表示从 1 到 N 数字的二进制串](../../problems/binary-string-with-substrings-representing-1-to-n) | [[字符串](../string/README.md)] | Medium | +| 1003 | [检查替换后的词是否有效](../../problems/check-if-word-is-valid-after-substitutions) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 937 | [重新排列日志文件](../../problems/reorder-data-in-log-files) | [[字符串](../string/README.md)] | Easy | +| 936 | [戳印序列](../../problems/stamping-the-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | +| 929 | [独特的电子邮件地址](../../problems/unique-email-addresses) | [[字符串](../string/README.md)] | Easy | +| 925 | [长按键入](../../problems/long-pressed-name) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 917 | [仅仅反转字母](../../problems/reverse-only-letters) | [[字符串](../string/README.md)] | Easy | +| 916 | [单词子集](../../problems/word-subsets) | [[字符串](../string/README.md)] | Medium | +| 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[字符串](../string/README.md)] | Easy | +| 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[字符串](../string/README.md)] | Medium | +| 859 | [亲密字符串](../../problems/buddy-strings) | [[字符串](../string/README.md)] | Easy | +| 856 | [括号的分数](../../problems/score-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 848 | [字母移位](../../problems/shifting-letters) | [[字符串](../string/README.md)] | Medium | +| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 833 | [字符串中的查找与替换](../../problems/find-and-replace-in-string) | [[字符串](../string/README.md)] | Medium | +| 831 | [隐藏个人信息](../../problems/masking-personal-information) | [[字符串](../string/README.md)] | Medium | +| 824 | [山羊拉丁文](../../problems/goat-latin) | [[字符串](../string/README.md)] | Easy | +| 819 | [最常见的单词](../../problems/most-common-word) | [[字符串](../string/README.md)] | Easy | +| 816 | [模糊坐标](../../problems/ambiguous-coordinates) | [[字符串](../string/README.md)] | Medium | +| 809 | [情感丰富的文字](../../problems/expressive-words) | [[字符串](../string/README.md)] | Medium | +| 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[字符串](../string/README.md)] | Easy | +| 800 | [相似 RGB 颜色](../../problems/similar-rgb-color) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 791 | [自定义字符串排序](../../problems/custom-sort-string) | [[字符串](../string/README.md)] | Medium | +| 788 | [旋转数字](../../problems/rotated-digits) | [[字符串](../string/README.md)] | Easy | +| 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | +| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | +| 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字符串](../string/README.md)] | Easy | +| 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[字符串](../string/README.md)] | Hard | +| 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 722 | [删除注释](../../problems/remove-comments) | [[字符串](../string/README.md)] | Medium | +| 709 | [转换成小写字母](../../problems/to-lower-case) | [[字符串](../string/README.md)] | Easy | +| 696 | [计数二进制子串](../../problems/count-binary-substrings) | [[字符串](../string/README.md)] | Easy | +| 686 | [重复叠加字符串匹配](../../problems/repeated-string-match) | [[字符串](../string/README.md)] | Medium | +| 681 | [最近时刻](../../problems/next-closest-time) 🔒 | [[字符串](../string/README.md)] | Medium | +| 680 | [验证回文字符串 Ⅱ](../../problems/valid-palindrome-ii) | [[字符串](../string/README.md)] | Easy | +| 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[字符串](../string/README.md)] | Medium | +| 657 | [机器人能否返回原点](../../problems/robot-return-to-origin) | [[字符串](../string/README.md)] | Easy | +| 647 | [回文子串](../../problems/palindromic-substrings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | +| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 616 | [给字符串添加加粗标签](../../problems/add-bold-tag-in-string) 🔒 | [[字符串](../string/README.md)] | Medium | +| 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 606 | [根据二叉树创建字符串](../../problems/construct-string-from-binary-tree) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Easy | +| 591 | [标签验证器](../../problems/tag-validator) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | +| 583 | [两个字符串的删除操作](../../problems/delete-operation-for-two-strings) | [[字符串](../string/README.md)] | Medium | +| 564 | [寻找最近的回文数](../../problems/find-the-closest-palindrome) | [[字符串](../string/README.md)] | Hard | +| 557 | [反转字符串中的单词 III](../../problems/reverse-words-in-a-string-iii) | [[字符串](../string/README.md)] | Easy | +| 556 | [下一个更大元素 III](../../problems/next-greater-element-iii) | [[字符串](../string/README.md)] | Medium | +| 555 | [分割连接字符串](../../problems/split-concatenated-strings) 🔒 | [[字符串](../string/README.md)] | Medium | +| 553 | [最优除法](../../problems/optimal-division) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 551 | [学生出勤记录 I](../../problems/student-attendance-record-i) | [[字符串](../string/README.md)] | Easy | +| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | +| 541 | [反转字符串 II](../../problems/reverse-string-ii) | [[字符串](../string/README.md)] | Easy | +| 539 | [最小时间差](../../problems/minimum-time-difference) | [[字符串](../string/README.md)] | Medium | +| 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | +| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Hard | +| 522 | [最长特殊序列 II](../../problems/longest-uncommon-subsequence-ii) | [[字符串](../string/README.md)] | Medium | +| 521 | [最长特殊序列 Ⅰ](../../problems/longest-uncommon-subsequence-i) | [[脑筋急转弯](../brainteaser/README.md)] [[字符串](../string/README.md)] | Easy | +| 520 | [检测大写字母](../../problems/detect-capital) | [[字符串](../string/README.md)] | Easy | +| 468 | [验证IP地址](../../problems/validate-ip-address) | [[字符串](../string/README.md)] | Medium | +| 459 | [重复的子字符串](../../problems/repeated-substring-pattern) | [[字符串](../string/README.md)] | Easy | +| 443 | [压缩字符串](../../problems/string-compression) | [[字符串](../string/README.md)] | Medium | +| 434 | [字符串中的单词数](../../problems/number-of-segments-in-a-string) | [[字符串](../string/README.md)] | Easy | +| 415 | [字符串相加](../../problems/add-strings) | [[字符串](../string/README.md)] | Easy | +| 408 | [有效单词缩写](../../problems/valid-word-abbreviation) 🔒 | [[字符串](../string/README.md)] | Easy | +| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 385 | [迷你语法分析器](../../problems/mini-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 383 | [赎金信](../../problems/ransom-note) | [[字符串](../string/README.md)] | Easy | +| 345 | [反转字符串中的元音字母](../../problems/reverse-vowels-of-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 344 | [反转字符串](../../problems/reverse-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 293 | [翻转游戏](../../problems/flip-game) 🔒 | [[字符串](../string/README.md)] | Easy | +| 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 271 | [字符串的编码与解码](../../problems/encode-and-decode-strings) 🔒 | [[字符串](../string/README.md)] | Medium | +| 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 214 | [最短回文串](../../problems/shortest-palindrome) | [[字符串](../string/README.md)] | Hard | +| 186 | [翻转字符串里的单词 II](../../problems/reverse-words-in-a-string-ii) 🔒 | [[字符串](../string/README.md)] | Medium | +| 165 | [比较版本号](../../problems/compare-version-numbers) | [[字符串](../string/README.md)] | Medium | +| 161 | [相隔为 1 的编辑距离](../../problems/one-edit-distance) 🔒 | [[字符串](../string/README.md)] | Medium | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 158 | [用 Read4 读取 N 个字符 II](../../problems/read-n-characters-given-read4-ii-call-multiple-times) 🔒 | [[字符串](../string/README.md)] | Hard | +| 157 | [用 Read4 读取 N 个字符](../../problems/read-n-characters-given-read4) 🔒 | [[字符串](../string/README.md)] | Easy | +| 151 | [翻转字符串里的单词](../../problems/reverse-words-in-a-string) | [[字符串](../string/README.md)] | Medium | +| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 125 | [验证回文串](../../problems/valid-palindrome) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 115 | [不同的子序列](../../problems/distinct-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 93 | [复原 IP 地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 91 | [解码方法](../../problems/decode-ways) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 87 | [扰乱字符串](../../problems/scramble-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 72 | [编辑距离](../../problems/edit-distance) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 71 | [简化路径](../../problems/simplify-path) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 68 | [文本左右对齐](../../problems/text-justification) | [[字符串](../string/README.md)] | Hard | +| 67 | [二进制求和](../../problems/add-binary) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 65 | [有效数字](../../problems/valid-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 58 | [最后一个单词的长度](../../problems/length-of-last-word) | [[字符串](../string/README.md)] | Easy | +| 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 38 | [外观数列](../../problems/count-and-say) | [[字符串](../string/README.md)] | Easy | +| 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 20 | [有效的括号](../../problems/valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | +| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 14 | [最长公共前缀](../../problems/longest-common-prefix) | [[字符串](../string/README.md)] | Easy | +| 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 8 | [字符串转换整数 (atoi)](../../problems/string-to-integer-atoi) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 6 | [Z 字形变换](../../problems/zigzag-conversion) | [[字符串](../string/README.md)] | Medium | +| 5 | [最长回文子串](../../problems/longest-palindromic-substring) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/topological-sort/README.md b/tag/topological-sort/README.md index 845df9d71..5a051c022 100644 --- a/tag/topological-sort/README.md +++ b/tag/topological-sort/README.md @@ -9,3 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 444 | [序列重建](../../problems/sequence-reconstruction) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | +| 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | diff --git a/tag/tree/README.md b/tag/tree/README.md index 838c82596..9193d4c43 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,3 +9,161 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | +| 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] | Hard | +| 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1660 | [纠正二叉树](../../problems/correct-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | +| 1650 | [二叉树的最近公共祖先 III](../../problems/lowest-common-ancestor-of-a-binary-tree-iii) 🔒 | [[树](../tree/README.md)] | Medium | +| 1644 | [二叉树的最近公共祖先 II](../../problems/lowest-common-ancestor-of-a-binary-tree-ii) 🔒 | [[树](../tree/README.md)] | Medium | +| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1609 | [奇偶树](../../problems/even-odd-tree) | [[树](../tree/README.md)] | Medium | +| 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Hard | +| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1516 | [移动 N 叉树的子树](../../problems/move-sub-tree-of-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard | +| 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1469 | [寻找所有的独生节点](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 1466 | [重新规划路线](../../problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1430 | [判断给定的序列是否是二叉树从根到叶的路径](../../problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | +| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1325 | [删除给定值的叶子节点](../../problems/delete-leaves-with-a-given-value) | [[树](../tree/README.md)] | Medium | +| 1315 | [祖父节点值为偶数的节点和](../../problems/sum-of-nodes-with-even-valued-grandparent) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[排序](../sort/README.md)] [[树](../tree/README.md)] | Medium | +| 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1257 | [最小公共区域](../../problems/smallest-common-region) 🔒 | [[树](../tree/README.md)] | Medium | +| 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] | Medium | +| 1110 | [删点成林](../../problems/delete-nodes-and-return-forest) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1104 | [二叉树寻路](../../problems/path-in-zigzag-labelled-binary-tree) | [[树](../tree/README.md)] [[数学](../math/README.md)] | Medium | +| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 1026 | [节点与其祖先之间的最大差值](../../problems/maximum-difference-between-node-and-ancestor) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1022 | [从根到叶的二进制数之和](../../problems/sum-of-root-to-leaf-binary-numbers) | [[树](../tree/README.md)] | Easy | +| 1008 | [前序遍历构造二叉搜索树](../../problems/construct-binary-search-tree-from-preorder-traversal) | [[树](../tree/README.md)] | Medium | +| 998 | [最大二叉树 II](../../problems/maximum-binary-tree-ii) | [[树](../tree/README.md)] | Medium | +| 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 988 | [从叶结点开始的最小字符串](../../problems/smallest-string-starting-from-leaf) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 979 | [在二叉树中分配硬币](../../problems/distribute-coins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 971 | [翻转二叉树以匹配先序遍历](../../problems/flip-binary-tree-to-match-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 965 | [单值二叉树](../../problems/univalued-binary-tree) | [[树](../tree/README.md)] | Easy | +| 958 | [二叉树的完全性检验](../../problems/check-completeness-of-a-binary-tree) | [[树](../tree/README.md)] | Medium | +| 951 | [翻转等价二叉树](../../problems/flip-equivalent-binary-trees) | [[树](../tree/README.md)] | Medium | +| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 919 | [完全二叉树插入器](../../problems/complete-binary-tree-inserter) | [[树](../tree/README.md)] | Medium | +| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] | Medium | +| 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 814 | [二叉树剪枝](../../problems/binary-tree-pruning) | [[树](../tree/README.md)] | Medium | +| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 742 | [二叉树最近的叶节点](../../problems/closest-leaf-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | +| 701 | [二叉搜索树中的插入操作](../../problems/insert-into-a-binary-search-tree) | [[树](../tree/README.md)] | Medium | +| 700 | [二叉搜索树中的搜索](../../problems/search-in-a-binary-search-tree) | [[树](../tree/README.md)] | Easy | +| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 684 | [冗余连接](../../problems/redundant-connection) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 671 | [二叉树中第二小的节点](../../problems/second-minimum-node-in-a-binary-tree) | [[树](../tree/README.md)] | Easy | +| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 666 | [路径总和 IV](../../problems/path-sum-iv) 🔒 | [[树](../tree/README.md)] | Medium | +| 663 | [均匀树划分](../../problems/equal-tree-partition) 🔒 | [[树](../tree/README.md)] | Medium | +| 662 | [二叉树最大宽度](../../problems/maximum-width-of-binary-tree) | [[树](../tree/README.md)] | Medium | +| 655 | [输出二叉树](../../problems/print-binary-tree) | [[树](../tree/README.md)] | Medium | +| 654 | [最大二叉树](../../problems/maximum-binary-tree) | [[树](../tree/README.md)] | Medium | +| 653 | [两数之和 IV - 输入 BST](../../problems/two-sum-iv-input-is-a-bst) | [[树](../tree/README.md)] | Easy | +| 652 | [寻找重复的子树](../../problems/find-duplicate-subtrees) | [[树](../tree/README.md)] | Medium | +| 637 | [二叉树的层平均值](../../problems/average-of-levels-in-binary-tree) | [[树](../tree/README.md)] | Easy | +| 623 | [在二叉树中增加一行](../../problems/add-one-row-to-tree) | [[树](../tree/README.md)] | Medium | +| 617 | [合并二叉树](../../problems/merge-two-binary-trees) | [[树](../tree/README.md)] | Easy | +| 606 | [根据二叉树创建字符串](../../problems/construct-string-from-binary-tree) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Easy | +| 590 | [N 叉树的后序遍历](../../problems/n-ary-tree-postorder-traversal) | [[树](../tree/README.md)] | Easy | +| 589 | [N 叉树的前序遍历](../../problems/n-ary-tree-preorder-traversal) | [[树](../tree/README.md)] | Easy | +| 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | +| 572 | [另一个树的子树](../../problems/subtree-of-another-tree) | [[树](../tree/README.md)] | Easy | +| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 559 | [N 叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 549 | [二叉树中最长的连续序列](../../problems/binary-tree-longest-consecutive-sequence-ii) 🔒 | [[树](../tree/README.md)] | Medium | +| 545 | [二叉树的边界](../../problems/boundary-of-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | +| 543 | [二叉树的直径](../../problems/diameter-of-binary-tree) | [[树](../tree/README.md)] | Easy | +| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | +| 530 | [二叉搜索树的最小绝对差](../../problems/minimum-absolute-difference-in-bst) | [[树](../tree/README.md)] | Easy | +| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 510 | [二叉搜索树中的中序后继 II](../../problems/inorder-successor-in-bst-ii) 🔒 | [[树](../tree/README.md)] | Medium | +| 508 | [出现次数最多的子树元素和](../../problems/most-frequent-subtree-sum) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 501 | [二叉搜索树中的众数](../../problems/find-mode-in-binary-search-tree) | [[树](../tree/README.md)] | Easy | +| 450 | [删除二叉搜索树中的节点](../../problems/delete-node-in-a-bst) | [[树](../tree/README.md)] | Medium | +| 449 | [序列化和反序列化二叉搜索树](../../problems/serialize-and-deserialize-bst) | [[树](../tree/README.md)] | Medium | +| 437 | [路径总和 III](../../problems/path-sum-iii) | [[树](../tree/README.md)] | Medium | +| 431 | [将 N 叉树编码为二叉树](../../problems/encode-n-ary-tree-to-binary-tree) 🔒 | [[树](../tree/README.md)] | Hard | +| 429 | [N 叉树的层序遍历](../../problems/n-ary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 428 | [序列化和反序列化 N 叉树](../../problems/serialize-and-deserialize-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard | +| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 404 | [左叶子之和](../../problems/sum-of-left-leaves) | [[树](../tree/README.md)] | Easy | +| 366 | [寻找二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 333 | [最大 BST 子树](../../problems/largest-bst-subtree) 🔒 | [[树](../tree/README.md)] | Medium | +| 298 | [二叉树最长连续序列](../../problems/binary-tree-longest-consecutive-sequence) 🔒 | [[树](../tree/README.md)] | Medium | +| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard | +| 285 | [二叉搜索树中的中序后继](../../problems/inorder-successor-in-bst) 🔒 | [[树](../tree/README.md)] | Medium | +| 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Hard | +| 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | +| 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] | Medium | +| 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] | Medium | +| 235 | [二叉搜索树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-search-tree) | [[树](../tree/README.md)] | Easy | +| 230 | [二叉搜索树中第K小的元素](../../problems/kth-smallest-element-in-a-bst) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 226 | [翻转二叉树](../../problems/invert-binary-tree) | [[树](../tree/README.md)] | Easy | +| 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | +| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 156 | [上下翻转二叉树](../../problems/binary-tree-upside-down) 🔒 | [[树](../tree/README.md)] | Medium | +| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | +| 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | +| 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 102 | [二叉树的层序遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 100 | [相同的树](../../problems/same-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 99 | [恢复二叉搜索树](../../problems/recover-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | From cfe4d202241201761c6dc4d38fa4ea695300c2cb Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 23 Mar 2021 09:39:39 +0800 Subject: [PATCH 126/145] A: v1.6.5 --- internal/version/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/version/version.go b/internal/version/version.go index 4d6bf5511..67e21835c 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -8,7 +8,7 @@ import ( "github.com/openset/leetcode/internal/base" ) -const version = "1.6.4" +const version = "1.6.5" // CmdVersion - version.CmdVersion var CmdVersion = &base.Command{ From d50023a6c0923854838ada06ceb1196c4f454fe3 Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 6 Apr 2021 11:32:05 +0800 Subject: [PATCH 127/145] A: new --- README.md | 16 +++ problems/132-pattern/README.md | 2 +- problems/3sum/README.md | 2 +- problems/ad-free-sessions/README.md | 14 +++ problems/ad-free-sessions/mysql_schemas.sql | 12 +++ problems/add-strings/README.md | 45 +++++++-- .../add-to-array-form-of-integer/README.md | 61 +++++------- problems/candy/README.md | 2 +- problems/combinations/README.md | 2 +- problems/continuous-subarray-sum/README.md | 33 ++++--- .../count-nice-pairs-in-an-array/README.md | 67 +++++++++++++ .../README.md | 22 +++-- .../count-pairs-with-xor-in-a-range/README.md | 2 +- .../README.md | 45 +++++++-- problems/design-twitter/README.md | 67 +++++++------ problems/design-underground-system/README.md | 51 +++++----- .../README.md | 67 +++++++++++++ problems/di-string-match/README.md | 52 ++++------ problems/distinct-subsequences/README.md | 2 +- problems/divisor-game/README.md | 33 +++---- problems/elimination-game/README.md | 46 ++++++--- .../README.md | 97 +++++++++++++++++++ .../README.md | 32 +++--- .../find-duplicate-file-in-system/README.md | 57 +++++------ problems/find-interview-candidates/README.md | 14 +++ .../mysql_schemas.sql | 16 +++ .../find-k-pairs-with-smallest-sums/README.md | 39 +++++--- .../README.md | 70 +++++++++++++ .../README.md | 27 +++--- .../flatten-nested-list-iterator/README.md | 38 +++++--- problems/guess-the-word/README.md | 47 ++++++--- .../implement-trie-ii-prefix-tree/README.md | 34 +++++++ problems/implement-trie-prefix-tree/README.md | 14 +-- problems/interleaving-string/README.md | 7 +- problems/k-closest-points-to-origin/README.md | 4 +- .../README.md | 2 +- problems/kth-smallest-instructions/README.md | 5 +- problems/lexicographical-numbers/README.md | 20 +++- .../README.md | 24 +++-- problems/matrix-block-sum/README.md | 15 ++- .../README.md | 3 +- .../README.md | 72 ++++++++++++++ .../README.md | 67 +++++++++++++ problems/maximum-product-subarray/README.md | 1 + .../README.md | 7 +- problems/mini-parser/README.md | 41 ++++---- .../minimum-absolute-sum-difference/README.md | 82 ++++++++++++++++ .../README.md | 14 +-- .../README.md | 77 +++++++++++++++ .../README.md | 35 +++++++ problems/next-greater-element-ii/README.md | 36 ++++--- .../README.md | 67 +++++++++++++ .../README.md | 77 +++++++++++++++ .../pacific-atlantic-water-flow/README.md | 44 ++++----- problems/path-with-maximum-gold/README.md | 16 +-- problems/perfect-rectangle/README.md | 93 ++++++------------ problems/powx-n/README.md | 2 +- problems/random-pick-index/README.md | 40 +++++--- .../README.md | 41 ++++---- .../README.md | 2 +- problems/reordered-power-of-2/README.md | 47 +++------ problems/reverse-vowels-of-a-string/README.md | 32 +++--- problems/rotate-array/README.md | 17 ++-- problems/rotate-function/README.md | 45 +++++---- problems/russian-doll-envelopes/README.md | 4 +- problems/sentence-similarity-iii/README.md | 73 ++++++++++++++ problems/truncate-sentence/README.md | 74 ++++++++++++++ problems/tweet-counts-per-frequency/README.md | 44 +++++---- problems/utf-8-validation/README.md | 63 ++++++------ problems/vowel-spellchecker/README.md | 29 +++--- problems/water-and-jug-problem/README.md | 34 ++++--- problems/wiggle-subsequence/README.md | 17 ++-- problems/word-search/README.md | 5 +- readme/1-300.md | 4 +- readme/301-600.md | 2 +- tag/README.md | 6 +- tag/array/README.md | 4 +- tag/binary-search/README.md | 1 + tag/depth-first-search/README.md | 1 + tag/design/README.md | 61 ------------ tag/dynamic-programming/README.md | 3 +- tag/graph/README.md | 1 + tag/greedy/README.md | 2 + tag/hash-table/README.md | 3 + tag/heap/README.md | 43 -------- tag/math/README.md | 2 + tag/memoization/README.md | 1 - tag/ordered-map/README.md | 14 --- tag/queue/README.md | 11 --- tag/recursion/README.md | 39 -------- tag/segment-tree/README.md | 16 --- tag/sliding-window/README.md | 27 ------ tag/stack/README.md | 2 +- tag/string/README.md | 8 +- tag/tags.json | 20 ++-- tag/trie/README.md | 1 + tag/two-pointers/README.md | 74 -------------- 97 files changed, 1872 insertions(+), 980 deletions(-) create mode 100644 problems/ad-free-sessions/README.md create mode 100644 problems/ad-free-sessions/mysql_schemas.sql create mode 100644 problems/count-nice-pairs-in-an-array/README.md create mode 100644 problems/determine-color-of-a-chessboard-square/README.md create mode 100644 problems/evaluate-the-bracket-pairs-of-a-string/README.md create mode 100644 problems/find-interview-candidates/README.md create mode 100644 problems/find-interview-candidates/mysql_schemas.sql create mode 100644 problems/finding-the-users-active-minutes/README.md create mode 100644 problems/implement-trie-ii-prefix-tree/README.md create mode 100644 problems/maximize-number-of-nice-divisors/README.md create mode 100644 problems/maximum-number-of-groups-getting-fresh-donuts/README.md create mode 100644 problems/minimum-absolute-sum-difference/README.md create mode 100644 problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md create mode 100644 problems/minimum-path-cost-in-a-hidden-grid/README.md create mode 100644 problems/number-of-different-integers-in-a-string/README.md create mode 100644 problems/number-of-different-subsequences-gcds/README.md create mode 100644 problems/sentence-similarity-iii/README.md create mode 100644 problems/truncate-sentence/README.md diff --git a/README.md b/README.md index e8fc2478e..8808bc253 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,22 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1819 | [Number of Different Subsequences GCDs](https://leetcode.com/problems/number-of-different-subsequences-gcds "序列中不同最大公约数的数目") | [Go](problems/number-of-different-subsequences-gcds) | Hard | +| 1818 | [Minimum Absolute Sum Difference](https://leetcode.com/problems/minimum-absolute-sum-difference "绝对差值和") | [Go](problems/minimum-absolute-sum-difference) | Medium | +| 1817 | [Finding the Users Active Minutes](https://leetcode.com/problems/finding-the-users-active-minutes "查找用户活跃分钟数") | [Go](problems/finding-the-users-active-minutes) | Medium | +| 1816 | [Truncate Sentence](https://leetcode.com/problems/truncate-sentence "截断句子") | [Go](problems/truncate-sentence) | Easy | +| 1815 | [Maximum Number of Groups Getting Fresh Donuts](https://leetcode.com/problems/maximum-number-of-groups-getting-fresh-donuts "得到新鲜甜甜圈的最多组数") | [Go](problems/maximum-number-of-groups-getting-fresh-donuts) | Hard | +| 1814 | [Count Nice Pairs in an Array](https://leetcode.com/problems/count-nice-pairs-in-an-array "统计一个数组中好对子的数目") | [Go](problems/count-nice-pairs-in-an-array) | Medium | +| 1813 | [Sentence Similarity III](https://leetcode.com/problems/sentence-similarity-iii "句子相似性 III") | [Go](problems/sentence-similarity-iii) | Medium | +| 1812 | [Determine Color of a Chessboard Square](https://leetcode.com/problems/determine-color-of-a-chessboard-square "判断国际象棋棋盘中一个格子的颜色") | [Go](problems/determine-color-of-a-chessboard-square) | Easy | +| 1811 | [Find Interview Candidates](https://leetcode.com/problems/find-interview-candidates) 🔒 | [MySQL](problems/find-interview-candidates) | Medium | +| 1810 | [Minimum Path Cost in a Hidden Grid](https://leetcode.com/problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [Go](problems/minimum-path-cost-in-a-hidden-grid) | Medium | +| 1809 | [Ad-Free Sessions](https://leetcode.com/problems/ad-free-sessions) 🔒 | [MySQL](problems/ad-free-sessions) | Easy | +| 1808 | [Maximize Number of Nice Divisors](https://leetcode.com/problems/maximize-number-of-nice-divisors "好因子的最大数目") | [Go](problems/maximize-number-of-nice-divisors) | Hard | +| 1807 | [Evaluate the Bracket Pairs of a String](https://leetcode.com/problems/evaluate-the-bracket-pairs-of-a-string "替换字符串中的括号内容") | [Go](problems/evaluate-the-bracket-pairs-of-a-string) | Medium | +| 1806 | [Minimum Number of Operations to Reinitialize a Permutation](https://leetcode.com/problems/minimum-number-of-operations-to-reinitialize-a-permutation "还原排列的最少操作步数") | [Go](problems/minimum-number-of-operations-to-reinitialize-a-permutation) | Medium | +| 1805 | [Number of Different Integers in a String](https://leetcode.com/problems/number-of-different-integers-in-a-string "字符串中不同整数的数目") | [Go](problems/number-of-different-integers-in-a-string) | Easy | +| 1804 | [Implement Trie II (Prefix Tree)](https://leetcode.com/problems/implement-trie-ii-prefix-tree) 🔒 | [Go](problems/implement-trie-ii-prefix-tree) | Medium | | 1803 | [Count Pairs With XOR in a Range](https://leetcode.com/problems/count-pairs-with-xor-in-a-range "统计异或值在范围内的数对有多少") | [Go](problems/count-pairs-with-xor-in-a-range) | Hard | | 1802 | [Maximum Value at a Given Index in a Bounded Array](https://leetcode.com/problems/maximum-value-at-a-given-index-in-a-bounded-array "有界数组中指定下标处的最大值") | [Go](problems/maximum-value-at-a-given-index-in-a-bounded-array) | Medium | | 1801 | [Number of Orders in the Backlog](https://leetcode.com/problems/number-of-orders-in-the-backlog "积压订单中的订单总数") | [Go](problems/number-of-orders-in-the-backlog) | Medium | diff --git a/problems/132-pattern/README.md b/problems/132-pattern/README.md index 07d1b5481..8b2e5aca9 100644 --- a/problems/132-pattern/README.md +++ b/problems/132-pattern/README.md @@ -9,7 +9,7 @@                  [Next >](../circular-array-loop "Circular Array Loop") -## [456. 132 Pattern (Medium)](https://leetcode.com/problems/132-pattern "132模式") +## [456. 132 Pattern (Medium)](https://leetcode.com/problems/132-pattern "132 模式")

      Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j].

      diff --git a/problems/3sum/README.md b/problems/3sum/README.md index 8d221263a..d22f2f3cf 100644 --- a/problems/3sum/README.md +++ b/problems/3sum/README.md @@ -11,7 +11,7 @@ ## [15. 3Sum (Medium)](https://leetcode.com/problems/3sum "三数之和") -

      Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.

      +

      Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.

      Notice that the solution set must not contain duplicate triplets.

      diff --git a/problems/ad-free-sessions/README.md b/problems/ad-free-sessions/README.md new file mode 100644 index 000000000..4bf3ad017 --- /dev/null +++ b/problems/ad-free-sessions/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../maximize-number-of-nice-divisors "Maximize Number of Nice Divisors") +                 +[Next >](../minimum-path-cost-in-a-hidden-grid "Minimum Path Cost in a Hidden Grid") + +## [1809. Ad-Free Sessions (Easy)](https://leetcode.com/problems/ad-free-sessions "") + + diff --git a/problems/ad-free-sessions/mysql_schemas.sql b/problems/ad-free-sessions/mysql_schemas.sql new file mode 100644 index 000000000..f430ed831 --- /dev/null +++ b/problems/ad-free-sessions/mysql_schemas.sql @@ -0,0 +1,12 @@ +Create table If Not Exists Playback(session_id int,customer_id int,start_time int,end_time int); +Create table If Not Exists Ads (ad_id int, customer_id int, timestamp int); +Truncate table Playback; +insert into Playback (session_id, customer_id, start_time, end_time) values ('1', '1', '1', '5'); +insert into Playback (session_id, customer_id, start_time, end_time) values ('2', '1', '15', '23'); +insert into Playback (session_id, customer_id, start_time, end_time) values ('3', '2', '10', '12'); +insert into Playback (session_id, customer_id, start_time, end_time) values ('4', '2', '17', '28'); +insert into Playback (session_id, customer_id, start_time, end_time) values ('5', '2', '2', '8'); +Truncate table Ads; +insert into Ads (ad_id, customer_id, timestamp) values ('1', '1', '5'); +insert into Ads (ad_id, customer_id, timestamp) values ('2', '2', '17'); +insert into Ads (ad_id, customer_id, timestamp) values ('3', '2', '20'); diff --git a/problems/add-strings/README.md b/problems/add-strings/README.md index f6cabe247..d48d79bcd 100644 --- a/problems/add-strings/README.md +++ b/problems/add-strings/README.md @@ -11,16 +11,41 @@ ## [415. Add Strings (Easy)](https://leetcode.com/problems/add-strings "字符串相加") -

      Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.

      - -

      Note: -

        -
      1. The length of both num1 and num2 is < 5100.
      2. -
      3. Both num1 and num2 contains only digits 0-9.
      4. -
      5. Both num1 and num2 does not contain any leading zero.
      6. -
      7. You must not use any built-in BigInteger library or convert the inputs to integer directly.
      8. -
      -

      +

      Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string.

      + +

       

      +

      Example 1:

      + +
      +Input: num1 = "11", num2 = "123"
      +Output: "134"
      +
      + +

      Example 2:

      + +
      +Input: num1 = "456", num2 = "77"
      +Output: "533"
      +
      + +

      Example 3:

      + +
      +Input: num1 = "0", num2 = "0"
      +Output: "0"
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= num1.length, num2.length <= 104
      • +
      • num1 and num2 consist of only digits.
      • +
      • num1 and num2 don't have any leading zeros except for the zero itself.
      • +
      + +

       

      +

      Follow up: Could you solve it without using any built-in BigInteger library or converting the inputs to integer directly?

      ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/add-to-array-form-of-integer/README.md b/problems/add-to-array-form-of-integer/README.md index eba4e731c..733fc3225 100644 --- a/problems/add-to-array-form-of-integer/README.md +++ b/problems/add-to-array-form-of-integer/README.md @@ -11,65 +11,56 @@ ## [989. Add to Array-Form of Integer (Easy)](https://leetcode.com/problems/add-to-array-form-of-integer "数组形式的整数加法") -

      For a non-negative integer X, the array-form of X is an array of its digits in left to right order.  For example, if X = 1231, then the array form is [1,2,3,1].

      +

      The array-form of an integer num is an array representing its digits in left to right order.

      -

      Given the array-form A of a non-negative integer X, return the array-form of the integer X+K.

      +
        +
      • For example, for num = 1321, the array form is [1,3,2,1].
      • +
      -

       

      - -
        -
      +

      Given num, the array-form of an integer, and an integer k, return the array-form of the integer num + k.

      -
      +

       

      Example 1:

      -Input: A = [1,2,0,0], K = 34
      -Output: [1,2,3,4]
      -Explanation: 1200 + 34 = 1234
      +Input: num = [1,2,0,0], k = 34
      +Output: [1,2,3,4]
      +Explanation: 1200 + 34 = 1234
       
      -

      Example 2:

      -Input: A = [2,7,4], K = 181
      -Output: [4,5,5]
      -Explanation: 274 + 181 = 455
      +Input: num = [2,7,4], k = 181
      +Output: [4,5,5]
      +Explanation: 274 + 181 = 455
       
      -

      Example 3:

      -Input: A = [2,1,5], K = 806
      -Output: [1,0,2,1]
      -Explanation: 215 + 806 = 1021
      +Input: num = [2,1,5], k = 806
      +Output: [1,0,2,1]
      +Explanation: 215 + 806 = 1021
       
      -

      Example 4:

      -Input: A = [9,9,9,9,9,9,9,9,9,9], K = 1
      -Output: [1,0,0,0,0,0,0,0,0,0,0]
      -Explanation: 9999999999 + 1 = 10000000000
      +Input: num = [9,9,9,9,9,9,9,9,9,9], k = 1
      +Output: [1,0,0,0,0,0,0,0,0,0,0]
      +Explanation: 9999999999 + 1 = 10000000000
       

       

      - -

      Note:

      - -
        -
      1. 1 <= A.length <= 10000
      2. -
      3. 0 <= A[i] <= 9
      4. -
      5. 0 <= K <= 10000
      6. -
      7. If A.length > 1, then A[0] != 0
      8. -
      -
      -
      -
      -
      +

      Constraints:

      + +
        +
      • 1 <= num.length <= 104
      • +
      • 0 <= num[i] <= 9
      • +
      • num does not contain any leading zeros except for the zero itself.
      • +
      • 1 <= k <= 104
      • +
      ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/candy/README.md b/problems/candy/README.md index 5edb3f3c1..7096ef687 100644 --- a/problems/candy/README.md +++ b/problems/candy/README.md @@ -46,7 +46,7 @@ The third child gets 1 candy because it satisfies the above two conditions.
      • n == ratings.length
      • 1 <= n <= 2 * 104
      • -
      • 1 <= ratings[i] <= 2 * 104
      • +
      • 0 <= ratings[i] <= 2 * 104
      ### Related Topics diff --git a/problems/combinations/README.md b/problems/combinations/README.md index a3aaa438f..66c8345e0 100644 --- a/problems/combinations/README.md +++ b/problems/combinations/README.md @@ -11,7 +11,7 @@ ## [77. Combinations (Medium)](https://leetcode.com/problems/combinations "组合") -

      Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.

      +

      Given two integers n and k, return all possible combinations of k numbers out of the range [1, n].

      You may return the answer in any order.

      diff --git a/problems/continuous-subarray-sum/README.md b/problems/continuous-subarray-sum/README.md index 55c6d5344..891529a26 100644 --- a/problems/continuous-subarray-sum/README.md +++ b/problems/continuous-subarray-sum/README.md @@ -11,32 +11,43 @@ ## [523. Continuous Subarray Sum (Medium)](https://leetcode.com/problems/continuous-subarray-sum "连续的子数组和") -

      Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to a multiple of k, that is, sums up to n*k where n is also an integer.

      +

      Given an integer array nums and an integer k, return true if nums has a continuous subarray of size at least two whose elements sum up to a multiple of k, or false otherwise.

      + +

      An integer x is a multiple of k if there exists an integer n such that x = n * k. 0 is always a multiple of k.

       

      +

      Example 1:

      + +
      +Input: nums = [23,2,4,6,7], k = 6
      +Output: true
      +Explanation: [2, 4] is a continuous subarray of size 2 whose elements sum up to 6.
      +
      -

      Example 1:

      +

      Example 2:

      -Input: [23, 2, 4, 6, 7],  k=6
      -Output: True
      -Explanation: Because [2, 4] is a continuous subarray of size 2 and sums up to 6.
      +Input: nums = [23,2,6,4,7], k = 6
      +Output: true
      +Explanation: [23, 2, 6, 4, 7] is an continuous subarray of size 5 whose elements sum up to 42.
      +42 is a multiple of 6 because 42 = 7 * 6 and 7 is an integer.
       
      -

      Example 2:

      +

      Example 3:

      -Input: [23, 2, 6, 4, 7],  k=6
      -Output: True
      -Explanation: Because [23, 2, 6, 4, 7] is an continuous subarray of size 5 and sums up to 42.
      +Input: nums = [23,2,6,4,7], k = 13
      +Output: false
       

       

      Constraints:

        -
      • The length of the array won't exceed 10,000.
      • -
      • You may assume the sum of all the numbers is in the range of a signed 32-bit integer.
      • +
      • 1 <= nums.length <= 105
      • +
      • 0 <= nums[i] <= 109
      • +
      • 0 <= sum(nums[i]) <= 231 - 1
      • +
      • 1 <= k <= 231 - 1
      ### Related Topics diff --git a/problems/count-nice-pairs-in-an-array/README.md b/problems/count-nice-pairs-in-an-array/README.md new file mode 100644 index 000000000..b7376c933 --- /dev/null +++ b/problems/count-nice-pairs-in-an-array/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../sentence-similarity-iii "Sentence Similarity III") +                 +[Next >](../maximum-number-of-groups-getting-fresh-donuts "Maximum Number of Groups Getting Fresh Donuts") + +## [1814. Count Nice Pairs in an Array (Medium)](https://leetcode.com/problems/count-nice-pairs-in-an-array "统计一个数组中好对子的数目") + +

      You are given an array nums that consists of non-negative integers. Let us define rev(x) as the reverse of the non-negative integer x. For example, rev(123) = 321, and rev(120) = 21. A pair of indices (i, j) is nice if it satisfies all of the following conditions:

      + +
        +
      • 0 <= i < j < nums.length
      • +
      • nums[i] + rev(nums[j]) == nums[j] + rev(nums[i])
      • +
      + +

      Return the number of nice pairs of indices. Since that number can be too large, return it modulo 109 + 7.

      + +

       

      +

      Example 1:

      + +
      +Input: nums = [42,11,1,97]
      +Output: 2
      +Explanation: The two pairs are:
      + - (0,3) : 42 + rev(97) = 42 + 79 = 121, 97 + rev(42) = 97 + 24 = 121.
      + - (1,2) : 11 + rev(1) = 11 + 1 = 12, 1 + rev(11) = 1 + 11 = 12.
      +
      + +

      Example 2:

      + +
      +Input: nums = [13,10,35,24,76]
      +Output: 4
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= nums.length <= 105
      • +
      • 0 <= nums[i] <= 109
      • +
      + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
      +Hint 1 +The condition can be rearranged to (nums[i] - rev(nums[i])) == (nums[j] - rev(nums[j])). +
      + +
      +Hint 2 +Transform each nums[i] into (nums[i] - rev(nums[i])). Then, count the number of (i, j) pairs that have equal values. +
      + +
      +Hint 3 +Keep a map storing the frequencies of values that you have seen so far. For each i, check if nums[i] is in the map. If it is, then add that count to the overall count. Then, increment the frequency of nums[i]. +
      diff --git a/problems/count-numbers-with-unique-digits/README.md b/problems/count-numbers-with-unique-digits/README.md index 42e4f0f8f..85c0da7f6 100644 --- a/problems/count-numbers-with-unique-digits/README.md +++ b/problems/count-numbers-with-unique-digits/README.md @@ -11,18 +11,24 @@ ## [357. Count Numbers with Unique Digits (Medium)](https://leetcode.com/problems/count-numbers-with-unique-digits "计算各个位数不同的数字个数") -

      Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n.

      +

      Given an integer n, return the count of all numbers with unique digits, x, where 0 <= x < 10n.

      -
      -

      Example:

      +

       

      +

      Example 1:

      + +
      +Input: n = 2
      +Output: 91
      +Explanation: The answer should be the total numbers in the range of 0 ≤ x < 100, excluding 11,22,33,44,55,66,77,88,99
      +
      + +

      Example 2:

      -Input: 2
      -Output: 91 
      -Explanation: The answer should be the total numbers in the range of 0 ≤ x < 100, 
      -             excluding 11,22,33,44,55,66,77,88,99
      +Input: n = 0
      +Output: 1
       
      -
      +

       

      Constraints:

      diff --git a/problems/count-pairs-with-xor-in-a-range/README.md b/problems/count-pairs-with-xor-in-a-range/README.md index fa4fe3c9e..5e982118e 100644 --- a/problems/count-pairs-with-xor-in-a-range/README.md +++ b/problems/count-pairs-with-xor-in-a-range/README.md @@ -7,7 +7,7 @@ [< Previous](../maximum-value-at-a-given-index-in-a-bounded-array "Maximum Value at a Given Index in a Bounded Array")                  -Next > +[Next >](../implement-trie-ii-prefix-tree "Implement Trie II (Prefix Tree)") ## [1803. Count Pairs With XOR in a Range (Hard)](https://leetcode.com/problems/count-pairs-with-xor-in-a-range "统计异或值在范围内的数对有多少") diff --git a/problems/data-stream-as-disjoint-intervals/README.md b/problems/data-stream-as-disjoint-intervals/README.md index 3f9b567ab..85bd84e16 100644 --- a/problems/data-stream-as-disjoint-intervals/README.md +++ b/problems/data-stream-as-disjoint-intervals/README.md @@ -11,23 +11,50 @@ ## [352. Data Stream as Disjoint Intervals (Hard)](https://leetcode.com/problems/data-stream-as-disjoint-intervals "将数据流变为多个不相交区间") -

      Given a data stream input of non-negative integers a1, a2, ..., an, ..., summarize the numbers seen so far as a list of disjoint intervals.

      +

      Given a data stream input of non-negative integers a1, a2, ..., an, summarize the numbers seen so far as a list of disjoint intervals.

      -

      For example, suppose the integers from the data stream are 1, 3, 7, 2, 6, ..., then the summary will be:

      +

      Implement the SummaryRanges class:

      + +
        +
      • SummaryRanges() Initializes the object with an empty stream.
      • +
      • void addNum(int val) Adds the integer val to the stream.
      • +
      • int[][] getIntervals() Returns a summary of the integers in the stream currently as a list of disjoint intervals [starti, endi].
      • +
      + +

       

      +

      Example 1:

      -[1, 1]
      -[1, 1], [3, 3]
      -[1, 1], [3, 3], [7, 7]
      -[1, 3], [7, 7]
      -[1, 3], [6, 7]
      +Input
      +["SummaryRanges", "addNum", "getIntervals", "addNum", "getIntervals", "addNum", "getIntervals", "addNum", "getIntervals", "addNum", "getIntervals"]
      +[[], [1], [], [3], [], [7], [], [2], [], [6], []]
      +Output
      +[null, null, [[1, 1]], null, [[1, 1], [3, 3]], null, [[1, 1], [3, 3], [7, 7]], null, [[1, 3], [7, 7]], null, [[1, 3], [6, 7]]]
      +
      +Explanation
      +SummaryRanges summaryRanges = new SummaryRanges();
      +summaryRanges.addNum(1);      // arr = [1]
      +summaryRanges.getIntervals(); // return [[1, 1]]
      +summaryRanges.addNum(3);      // arr = [1, 3]
      +summaryRanges.getIntervals(); // return [[1, 1], [3, 3]]
      +summaryRanges.addNum(7);      // arr = [1, 3, 7]
      +summaryRanges.getIntervals(); // return [[1, 1], [3, 3], [7, 7]]
      +summaryRanges.addNum(2);      // arr = [1, 2, 3, 7]
      +summaryRanges.getIntervals(); // return [[1, 3], [7, 7]]
      +summaryRanges.addNum(6);      // arr = [1, 2, 3, 6, 7]
      +summaryRanges.getIntervals(); // return [[1, 3], [6, 7]]
       

       

      +

      Constraints:

      -

      Follow up:

      +
        +
      • 0 <= val <= 104
      • +
      • At most 3 * 104 calls will be made to addNum and getIntervals.
      • +
      -

      What if there are lots of merges and the number of disjoint intervals are small compared to the data stream's size?

      +

       

      +

      Follow up: What if there are lots of merges and the number of disjoint intervals is small compared to the size of the data stream?

      ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/design-twitter/README.md b/problems/design-twitter/README.md index c1ad18065..61390d7bd 100644 --- a/problems/design-twitter/README.md +++ b/problems/design-twitter/README.md @@ -11,45 +11,48 @@ ## [355. Design Twitter (Medium)](https://leetcode.com/problems/design-twitter "设计推特") -

      Design a simplified version of Twitter where users can post tweets, follow/unfollow another user and is able to see the 10 most recent tweets in the user's news feed. Your design should support the following methods:

      - -

      -

        -
      1. postTweet(userId, tweetId): Compose a new tweet.
      2. -
      3. getNewsFeed(userId): Retrieve the 10 most recent tweet ids in the user's news feed. Each item in the news feed must be posted by users who the user followed or by the user herself. Tweets must be ordered from most recent to least recent.
      4. -
      5. follow(followerId, followeeId): Follower follows a followee.
      6. -
      7. unfollow(followerId, followeeId): Follower unfollows a followee.
      8. -
      -

      - -

      Example: -

      -Twitter twitter = new Twitter();
      +

      Design a simplified version of Twitter where users can post tweets, follow/unfollow another user, and is able to see the 10 most recent tweets in the user's news feed.

      -// User 1 posts a new tweet (id = 5). -twitter.postTweet(1, 5); +

      Implement the Twitter class:

      -// User 1's news feed should return a list with 1 tweet id -> [5]. -twitter.getNewsFeed(1); +
        +
      • Twitter() Initializes your twitter object.
      • +
      • void postTweet(int userId, int tweetId) Composes a new tweet with ID tweetId by the user userId. Each call to this function will be made with a unique tweetId.
      • +
      • List<Integer> getNewsFeed(int userId) Retrieves the 10 most recent tweet IDs in the user's news feed. Each item in the news feed must be posted by users who the user followed or by the user themself. Tweets must be ordered from most recent to least recent.
      • +
      • void follow(int followerId, int followeeId) The user with ID followerId started following the user with ID followeeId.
      • +
      • void unfollow(int followerId, int followeeId) The user with ID followerId started unfollowing the user with ID followeeId.
      • +
      -// User 1 follows user 2. -twitter.follow(1, 2); +

       

      +

      Example 1:

      -// User 2 posts a new tweet (id = 6). -twitter.postTweet(2, 6); +
      +Input
      +["Twitter", "postTweet", "getNewsFeed", "follow", "postTweet", "getNewsFeed", "unfollow", "getNewsFeed"]
      +[[], [1, 5], [1], [1, 2], [2, 6], [1], [1, 2], [1]]
      +Output
      +[null, null, [5], null, null, [6, 5], null, [5]]
       
      -// User 1's news feed should return a list with 2 tweet ids -> [6, 5].
      -// Tweet id 6 should precede tweet id 5 because it is posted after tweet id 5.
      -twitter.getNewsFeed(1);
      +Explanation
      +Twitter twitter = new Twitter();
      +twitter.postTweet(1, 5); // User 1 posts a new tweet (id = 5).
      +twitter.getNewsFeed(1);  // User 1's news feed should return a list with 1 tweet id -> [5]. return [5]
      +twitter.follow(1, 2);    // User 1 follows user 2.
      +twitter.postTweet(2, 6); // User 2 posts a new tweet (id = 6).
      +twitter.getNewsFeed(1);  // User 1's news feed should return a list with 2 tweet ids -> [6, 5]. Tweet id 6 should precede tweet id 5 because it is posted after tweet id 5.
      +twitter.unfollow(1, 2);  // User 1 unfollows user 2.
      +twitter.getNewsFeed(1);  // User 1's news feed should return a list with 1 tweet id -> [5], since user 1 is no longer following user 2.
      +
      -// User 1 unfollows user 2. -twitter.unfollow(1, 2); +

       

      +

      Constraints:

      -// User 1's news feed should return a list with 1 tweet id -> [5], -// since user 1 is no longer following user 2. -twitter.getNewsFeed(1); -
      -

      +
        +
      • 1 <= userId, followerId, followeeId <= 500
      • +
      • 0 <= tweetId <= 104
      • +
      • All the tweets have unique IDs.
      • +
      • At most 3 * 104 calls will be made to postTweet, getNewsFeed, follow, and unfollow.
      • +
      ### Related Topics [[Heap](../../tag/heap/README.md)] diff --git a/problems/design-underground-system/README.md b/problems/design-underground-system/README.md index ddd1c885f..0528d7977 100644 --- a/problems/design-underground-system/README.md +++ b/problems/design-underground-system/README.md @@ -11,30 +11,33 @@ ## [1396. Design Underground System (Medium)](https://leetcode.com/problems/design-underground-system "设计地铁系统") +

      An underground railway system is keeping track of customer travel times between different stations. They are using this data to calculate the average time it takes to travel from one station to another.

      +

      Implement the UndergroundSystem class:

      • void checkIn(int id, string stationName, int t)
          -
        • A customer with a card id equal to id, gets in the station stationName at time t.
        • +
        • A customer with a card ID equal to id, checks in at the station stationName at time t.
        • A customer can only be checked into one place at a time.
      • void checkOut(int id, string stationName, int t)
          -
        • A customer with a card id equal to id, gets out from the station stationName at time t.
        • +
        • A customer with a card ID equal to id, checks out from the station stationName at time t.
      • double getAverageTime(string startStation, string endStation)
          -
        • Returns the average time to travel between the startStation and the endStation.
        • -
        • The average time is computed from all the previous traveling from startStation to endStation that happened directly.
        • -
        • Call to getAverageTime is always valid.
        • +
        • Returns the average time it takes to travel from startStation to endStation.
        • +
        • The average time is computed from all the previous traveling times from startStation to endStation that happened directly, meaning a check in at startStation followed by a check out from endStation.
        • +
        • The time it takes to travel from startStation to endStation may be different from the time it takes to travel from endStation to startStation.
        • +
        • There will be at least one customer that has traveled from startStation to endStation before getAverageTime is called.
      -

      You can assume all calls to checkIn and checkOut methods are consistent. If a customer gets in at time t1 at some station, they get out at time t2 with t2 > t1. All events happen in chronological order.

      +

      You may assume all calls to the checkIn and checkOut methods are consistent. If a customer checks in at time t1 then checks out at time t2, then t1 < t2. All events happen in chronological order.

       

      Example 1:

      @@ -52,15 +55,15 @@ UndergroundSystem undergroundSystem = new UndergroundSystem(); undergroundSystem.checkIn(45, "Leyton", 3); undergroundSystem.checkIn(32, "Paradise", 8); undergroundSystem.checkIn(27, "Leyton", 10); -undergroundSystem.checkOut(45, "Waterloo", 15); -undergroundSystem.checkOut(27, "Waterloo", 20); -undergroundSystem.checkOut(32, "Cambridge", 22); -undergroundSystem.getAverageTime("Paradise", "Cambridge");       // return 14.00000. There was only one travel from "Paradise" (at time 8) to "Cambridge" (at time 22) -undergroundSystem.getAverageTime("Leyton", "Waterloo");          // return 11.00000. There were two travels from "Leyton" to "Waterloo", a customer with id=45 from time=3 to time=15 and a customer with id=27 from time=10 to time=20. So the average time is ( (15-3) + (20-10) ) / 2 = 11.00000 +undergroundSystem.checkOut(45, "Waterloo", 15); // Customer 45 "Leyton" -> "Waterloo" in 15-3 = 12 +undergroundSystem.checkOut(27, "Waterloo", 20); // Customer 27 "Leyton" -> "Waterloo" in 20-10 = 10 +undergroundSystem.checkOut(32, "Cambridge", 22); // Customer 32 "Paradise" -> "Cambridge" in 22-8 = 14 +undergroundSystem.getAverageTime("Paradise", "Cambridge"); // return 14.00000. One trip "Paradise" -> "Cambridge", (14) / 1 = 14 +undergroundSystem.getAverageTime("Leyton", "Waterloo"); // return 11.00000. Two trips "Leyton" -> "Waterloo", (10 + 12) / 2 = 11 undergroundSystem.checkIn(10, "Leyton", 24); -undergroundSystem.getAverageTime("Leyton", "Waterloo");          // return 11.00000 -undergroundSystem.checkOut(10, "Waterloo", 38); -undergroundSystem.getAverageTime("Leyton", "Waterloo");          // return 12.00000 +undergroundSystem.getAverageTime("Leyton", "Waterloo"); // return 11.00000 +undergroundSystem.checkOut(10, "Waterloo", 38); // Customer 10 "Leyton" -> "Waterloo" in 38-24 = 14 +undergroundSystem.getAverageTime("Leyton", "Waterloo"); // return 12.00000. Three trips "Leyton" -> "Waterloo", (10 + 12 + 14) / 3 = 12

      Example 2:

      @@ -76,25 +79,25 @@ undergroundSystem.getAverageTime("Leyton", "Waterloo"); &nbs Explanation UndergroundSystem undergroundSystem = new UndergroundSystem(); undergroundSystem.checkIn(10, "Leyton", 3); -undergroundSystem.checkOut(10, "Paradise", 8); -undergroundSystem.getAverageTime("Leyton", "Paradise"); // return 5.00000 +undergroundSystem.checkOut(10, "Paradise", 8); // Customer 10 "Leyton" -> "Paradise" in 8-3 = 5 +undergroundSystem.getAverageTime("Leyton", "Paradise"); // return 5.00000, (5) / 1 = 5 undergroundSystem.checkIn(5, "Leyton", 10); -undergroundSystem.checkOut(5, "Paradise", 16); -undergroundSystem.getAverageTime("Leyton", "Paradise"); // return 5.50000 +undergroundSystem.checkOut(5, "Paradise", 16); // Customer 5 "Leyton" -> "Paradise" in 16-10 = 6 +undergroundSystem.getAverageTime("Leyton", "Paradise"); // return 5.50000, (5 + 6) / 2 = 5.5 undergroundSystem.checkIn(2, "Leyton", 21); -undergroundSystem.checkOut(2, "Paradise", 30); -undergroundSystem.getAverageTime("Leyton", "Paradise"); // return 6.66667 +undergroundSystem.checkOut(2, "Paradise", 30); // Customer 2 "Leyton" -> "Paradise" in 30-21 = 9 +undergroundSystem.getAverageTime("Leyton", "Paradise"); // return 6.66667, (5 + 6 + 9) / 3 = 6.66667

       

      Constraints:

        -
      • There will be at most 20000 operations.
      • 1 <= id, t <= 106
      • -
      • All strings consist of uppercase and lowercase English letters, and digits.
      • -
      • 1 <= stationName.length <= 10
      • -
      • Answers within 10-5 of the actual value will be accepted as correct.
      • +
      • 1 <= stationName.length, startStation.length, endStation.length <= 10
      • +
      • All strings consist of uppercase and lowercase English letters and digits.
      • +
      • There will be at most 2 * 104 calls in total to checkIn, checkOut, and getAverageTime.
      • +
      • Answers within 10-5 of the actual value will be accepted.
      ### Related Topics diff --git a/problems/determine-color-of-a-chessboard-square/README.md b/problems/determine-color-of-a-chessboard-square/README.md new file mode 100644 index 000000000..ab5909b0c --- /dev/null +++ b/problems/determine-color-of-a-chessboard-square/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../find-interview-candidates "Find Interview Candidates") +                 +[Next >](../sentence-similarity-iii "Sentence Similarity III") + +## [1812. Determine Color of a Chessboard Square (Easy)](https://leetcode.com/problems/determine-color-of-a-chessboard-square "判断国际象棋棋盘中一个格子的颜色") + +

      You are given coordinates, a string that represents the coordinates of a square of the chessboard. Below is a chessboard for your reference.

      + +

      + +

      Return true if the square is white, and false if the square is black.

      + +

      The coordinate will always represent a valid chessboard square. The coordinate will always have the letter first, and the number second.

      + +

       

      +

      Example 1:

      + +
      +Input: coordinates = "a1"
      +Output: false
      +Explanation: From the chessboard above, the square with coordinates "a1" is black, so return false.
      +
      + +

      Example 2:

      + +
      +Input: coordinates = "h3"
      +Output: true
      +Explanation: From the chessboard above, the square with coordinates "h3" is white, so return true.
      +
      + +

      Example 3:

      + +
      +Input: coordinates = "c7"
      +Output: false
      +
      + +

       

      +

      Constraints:

      + +
        +
      • coordinates.length == 2
      • +
      • 'a' <= coordinates[0] <= 'h'
      • +
      • '1' <= coordinates[1] <= '8'
      • +
      + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
      +Hint 1 +Convert the coordinates to (x, y) - that is, "a1" is (1, 1), "d7" is (4, 7). +
      + +
      +Hint 2 +Try add the numbers together and look for a pattern. +
      diff --git a/problems/di-string-match/README.md b/problems/di-string-match/README.md index 527e1f1d2..deb7c3805 100644 --- a/problems/di-string-match/README.md +++ b/problems/di-string-match/README.md @@ -11,49 +11,33 @@ ## [942. DI String Match (Easy)](https://leetcode.com/problems/di-string-match "增减字符串匹配") -

      Given a string S that only contains "I" (increase) or "D" (decrease), let N = S.length.

      - -

      Return any permutation A of [0, 1, ..., N] such that for all i = 0, ..., N-1:

      +

      A permutation perm of n + 1 integers of all the integers in the range [0, n] can be represented as a string s of length n where:

        -
      • If S[i] == "I", then A[i] < A[i+1]
      • -
      • If S[i] == "D", then A[i] > A[i+1]
      • +
      • s[i] == 'I' if perm[i] < perm[i + 1], and
      • +
      • s[i] == 'D' if perm[i] > perm[i + 1].
      -

       

      +

      Given a string s, reconstruct the permutation perm and return it. If there are multiple valid permutations perm, return any of them.

      +

       

      Example 1:

      - -
      -Input: "IDID"
      -Output: [0,4,1,3,2]
      -
      - -
      -

      Example 2:

      - -
      -Input: "III"
      -Output: [0,1,2,3]
      +
      Input: s = "IDID"
      +Output: [0,4,1,3,2]
      +

      Example 2:

      +
      Input: s = "III"
      +Output: [0,1,2,3]
      +

      Example 3:

      +
      Input: s = "DDI"
      +Output: [3,2,0,1]
       
      - -
      -

      Example 3:

      - -
      -Input: "DDI"
      -Output: [3,2,0,1]
      -
      -
      -

       

      +

      Constraints:

      -

      Note:

      - -
        -
      1. 1 <= S.length <= 10000
      2. -
      3. S only contains characters "I" or "D".
      4. -
      +
        +
      • 1 <= s.length <= 105
      • +
      • s[i] is either 'I' or 'D'.
      • +
      ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/distinct-subsequences/README.md b/problems/distinct-subsequences/README.md index e411aaf39..4dddc80bc 100644 --- a/problems/distinct-subsequences/README.md +++ b/problems/distinct-subsequences/README.md @@ -47,7 +47,7 @@ As shown below, there are 5 ways you can generate "bag" from S.

      Constraints:

        -
      • 0 <= s.length, t.length <= 1000
      • +
      • 1 <= s.length, t.length <= 1000
      • s and t consist of English letters.
      diff --git a/problems/divisor-game/README.md b/problems/divisor-game/README.md index 6b74ac26b..8a5248792 100644 --- a/problems/divisor-game/README.md +++ b/problems/divisor-game/README.md @@ -13,49 +13,40 @@

      Alice and Bob take turns playing a game, with Alice starting first.

      -

      Initially, there is a number N on the chalkboard.  On each player's turn, that player makes a move consisting of:

      +

      Initially, there is a number n on the chalkboard. On each player's turn, that player makes a move consisting of:

        -
      • Choosing any x with 0 < x < N and N % x == 0.
      • -
      • Replacing the number N on the chalkboard with N - x.
      • +
      • Choosing any x with 0 < x < n and n % x == 0.
      • +
      • Replacing the number n on the chalkboard with n - x.

      Also, if a player cannot make a move, they lose the game.

      -

      Return True if and only if Alice wins the game, assuming both players play optimally.

      +

      Return true if and only if Alice wins the game, assuming both players play optimally.

       

      - -
        -
      - -

      Example 1:

      -Input: 2
      -Output: true
      +Input: n = 2
      +Output: true
       Explanation: Alice chooses 1, and Bob has no more moves.
       
      -

      Example 2:

      -Input: 3
      -Output: false
      +Input: n = 3
      +Output: false
       Explanation: Alice chooses 1, Bob chooses 1, and Alice has no more moves.
       

       

      +

      Constraints:

      -

      Note:

      - -
        -
      1. 1 <= N <= 1000
      2. -
      -
      -
      +
        +
      • 1 <= n <= 1000
      • +
      ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/elimination-game/README.md b/problems/elimination-game/README.md index 142b660d0..1b4599caf 100644 --- a/problems/elimination-game/README.md +++ b/problems/elimination-game/README.md @@ -11,25 +11,39 @@ ## [390. Elimination Game (Medium)](https://leetcode.com/problems/elimination-game "消除游戏") -

      -There is a list of sorted integers from 1 to n. Starting from left to right, remove the first number and every other number afterward until you reach the end of the list.

      +

      You have a list arr of all integers in the range [1, n] sorted in a strictly increasing order. Apply the following algorithm on arr:

      -

      Repeat the previous step again, but this time from right to left, remove the right most number and every other number from the remaining numbers.

      +
        +
      • Starting from left to right, remove the first number and every other number afterward until you reach the end of the list.
      • +
      • Repeat the previous step again, but this time from right to left, remove the rightmost number and every other number from the remaining numbers.
      • +
      • Keep repeating the steps again, alternating left to right and right to left, until a single number remains.
      • +
      -

      We keep repeating the steps again, alternating left to right and right to left, until a single number remains.

      +

      Given the integer n, return the last number that remains in arr.

      -

      Find the last number that remains starting with a list of length n.

      +

       

      +

      Example 1:

      -

      Example:

      -Input:
      -n = 9,
      -1 2 3 4 5 6 7 8 9
      -2 4 6 8
      -2 6
      -6
      -
      -Output:
      -6
      +Input: n = 9
      +Output: 6
      +Explanation:
      +arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]
      +arr = [2, 4, 6, 8]
      +arr = [2, 6]
      +arr = [6]
       
      -

      + +

      Example 2:

      + +
      +Input: n = 1
      +Output: 1
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= n <= 109
      • +
      diff --git a/problems/evaluate-the-bracket-pairs-of-a-string/README.md b/problems/evaluate-the-bracket-pairs-of-a-string/README.md new file mode 100644 index 000000000..dcf601460 --- /dev/null +++ b/problems/evaluate-the-bracket-pairs-of-a-string/README.md @@ -0,0 +1,97 @@ + + + + + + + +[< Previous](../minimum-number-of-operations-to-reinitialize-a-permutation "Minimum Number of Operations to Reinitialize a Permutation") +                 +[Next >](../maximize-number-of-nice-divisors "Maximize Number of Nice Divisors") + +## [1807. Evaluate the Bracket Pairs of a String (Medium)](https://leetcode.com/problems/evaluate-the-bracket-pairs-of-a-string "替换字符串中的括号内容") + +

      You are given a string s that contains some bracket pairs, with each pair containing a non-empty key.

      + +
        +
      • For example, in the string "(name)is(age)yearsold", there are two bracket pairs that contain the keys "name" and "age".
      • +
      + +

      You know the values of a wide range of keys. This is represented by a 2D string array knowledge where each knowledge[i] = [keyi, valuei] indicates that key keyi has a value of valuei.

      + +

      You are tasked to evaluate all of the bracket pairs. When you evaluate a bracket pair that contains some key keyi, you will:

      + +
        +
      • Replace keyi and the bracket pair with the key's corresponding valuei.
      • +
      • If you do not know the value of the key, you will replace keyi and the bracket pair with a question mark "?" (without the quotation marks).
      • +
      + +

      Each key will appear at most once in your knowledge. There will not be any nested brackets in s.

      + +

      Return the resulting string after evaluating all of the bracket pairs.

      + +

       

      +

      Example 1:

      + +
      +Input: s = "(name)is(age)yearsold", knowledge = [["name","bob"],["age","two"]]
      +Output: "bobistwoyearsold"
      +Explanation:
      +The key "name" has a value of "bob", so replace "(name)" with "bob".
      +The key "age" has a value of "two", so replace "(age)" with "two".
      +
      + +

      Example 2:

      + +
      +Input: s = "hi(name)", knowledge = [["a","b"]]
      +Output: "hi?"
      +Explanation: As you do not know the value of the key "name", replace "(name)" with "?".
      +
      + +

      Example 3:

      + +
      +Input: s = "(a)(a)(a)aaa", knowledge = [["a","yes"]]
      +Output: "yesyesyesaaa"
      +Explanation: The same key can appear multiple times.
      +The key "a" has a value of "yes", so replace all occurrences of "(a)" with "yes".
      +Notice that the "a"s not in a bracket pair are not evaluated.
      +
      + +

      Example 4:

      + +
      +Input: s = "(a)(b)", knowledge = [["a","b"],["b","a"]]
      +Output: "ba"
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= s.length <= 105
      • +
      • 0 <= knowledge.length <= 105
      • +
      • knowledge[i].length == 2
      • +
      • 1 <= keyi.length, valuei.length <= 10
      • +
      • s consists of lowercase English letters and round brackets '(' and ')'.
      • +
      • Every open bracket '(' in s will have a corresponding close bracket ')'.
      • +
      • The key in each bracket pair of s will be non-empty.
      • +
      • There will not be any nested bracket pairs in s.
      • +
      • keyi and valuei consist of lowercase English letters.
      • +
      • Each keyi in knowledge is unique.
      • +
      + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
      +Hint 1 +Process pairs from right to left to handle repeats +
      + +
      +Hint 2 +Keep track of the current enclosed string using another string +
      diff --git a/problems/find-all-numbers-disappeared-in-an-array/README.md b/problems/find-all-numbers-disappeared-in-an-array/README.md index f1ce976b7..702b5748e 100644 --- a/problems/find-all-numbers-disappeared-in-an-array/README.md +++ b/problems/find-all-numbers-disappeared-in-an-array/README.md @@ -11,21 +11,27 @@ ## [448. Find All Numbers Disappeared in an Array (Easy)](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array "找到所有数组中消失的数字") -

      Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.

      - -

      Find all the elements of [1, n] inclusive that do not appear in this array.

      - -

      Could you do it without extra space and in O(n) runtime? You may assume the returned list does not count as extra space.

      +

      Given an array nums of n integers where nums[i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in nums.

      + +

       

      +

      Example 1:

      +
      Input: nums = [4,3,2,7,8,2,3,1]
      +Output: [5,6]
      +

      Example 2:

      +
      Input: nums = [1,1]
      +Output: [2]
      +
      +

       

      +

      Constraints:

      -

      Example: -

      -Input:
      -[4,3,2,7,8,2,3,1]
      +
        +
      • n == nums.length
      • +
      • 1 <= n <= 105
      • +
      • 1 <= nums[i] <= n
      • +
      -Output: -[5,6] -
      -

      +

       

      +

      Follow up: Could you do it without extra space and in O(n) runtime? You may assume the returned list does not count as extra space.

      ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/find-duplicate-file-in-system/README.md b/problems/find-duplicate-file-in-system/README.md index 07fbeb275..59762cb38 100644 --- a/problems/find-duplicate-file-in-system/README.md +++ b/problems/find-duplicate-file-in-system/README.md @@ -11,51 +11,54 @@ ## [609. Find Duplicate File in System (Medium)](https://leetcode.com/problems/find-duplicate-file-in-system "在系统中查找重复文件") -

      Given a list of directory info including directory path, and all the files with contents in this directory, you need to find out all the groups of duplicate files in the file system in terms of their paths.

      +

      Given a list paths of directory info, including the directory path, and all the files with contents in this directory, return all the duplicate files in the file system in terms of their paths. You may return the answer in any order.

      -

      A group of duplicate files consists of at least two files that have exactly the same content.

      +

      A group of duplicate files consists of at least two files that have the same content.

      -

      A single directory info string in the input list has the following format:

      +

      A single directory info string in the input list has the following format:

      -

      "root/d1/d2/.../dm f1.txt(f1_content) f2.txt(f2_content) ... fn.txt(fn_content)"

      +
        +
      • "root/d1/d2/.../dm f1.txt(f1_content) f2.txt(f2_content) ... fn.txt(fn_content)"
      • +
      -

      It means there are n files (f1.txt, f2.txt ... fn.txt with content f1_content, f2_content ... fn_content, respectively) in directory root/d1/d2/.../dm. Note that n >= 1 and m >= 0. If m = 0, it means the directory is just the root directory.

      +

      It means there are n files (f1.txt, f2.txt ... fn.txt) with content (f1_content, f2_content ... fn_content) respectively in the directory "root/d1/d2/.../dm". Note that n >= 1 and m >= 0. If m = 0, it means the directory is just the root directory.

      -

      The output is a list of group of duplicate file paths. For each group, it contains all the file paths of the files that have the same content. A file path is a string that has the following format:

      +

      The output is a list of groups of duplicate file paths. For each group, it contains all the file paths of the files that have the same content. A file path is a string that has the following format:

      -

      "directory_path/file_name.txt"

      +
        +
      • "directory_path/file_name.txt"
      • +
      -

      Example 1:

      - -
      -Input:
      -["root/a 1.txt(abcd) 2.txt(efgh)", "root/c 3.txt(abcd)", "root/c/d 4.txt(efgh)", "root 4.txt(efgh)"]
      -Output:  
      -[["root/a/2.txt","root/c/d/4.txt","root/4.txt"],["root/a/1.txt","root/c/3.txt"]]
      +

       

      +

      Example 1:

      +
      Input: paths = ["root/a 1.txt(abcd) 2.txt(efgh)","root/c 3.txt(abcd)","root/c/d 4.txt(efgh)","root 4.txt(efgh)"]
      +Output: [["root/a/2.txt","root/c/d/4.txt","root/4.txt"],["root/a/1.txt","root/c/3.txt"]]
      +

      Example 2:

      +
      Input: paths = ["root/a 1.txt(abcd) 2.txt(efgh)","root/c 3.txt(abcd)","root/c/d 4.txt(efgh)"]
      +Output: [["root/a/2.txt","root/c/d/4.txt"],["root/a/1.txt","root/c/3.txt"]]
       
      -

       

      +

      Constraints:

      -

      Note:

      - -
        -
      1. No order is required for the final output.
      2. -
      3. You may assume the directory name, file name and file content only has letters and digits, and the length of file content is in the range of [1,50].
      4. -
      5. The number of files given is in the range of [1,20000].
      6. +
          +
        • 1 <= paths.length <= 2 * 104
        • +
        • 1 <= paths[i].length <= 3000
        • +
        • 1 <= sum(paths[i].length) <= 5 * 105
        • +
        • paths[i] consist of English letters, digits, '/', '.', '(', ')', and ' '.
        • You may assume no files or directories share the same name in the same directory.
        • -
        • You may assume each given directory info represents a unique directory. Directory path and file info are separated by a single blank space.
        • -
      +
    • You may assume each given directory info represents a unique directory. A single blank space separates the directory path and file info.
    • +

     

    -Follow-up beyond contest: +

    Follow up:

    -
      +
      • Imagine you are given a real file system, how will you search files? DFS or BFS?
      • If the file content is very large (GB level), how will you modify your solution?
      • If you can only read the file by 1kb each time, how will you modify your solution?
      • -
      • What is the time complexity of your modified solution? What is the most time-consuming part and memory consuming part of it? How to optimize?
      • +
      • What is the time complexity of your modified solution? What is the most time-consuming part and memory-consuming part of it? How to optimize?
      • How to make sure the duplicated files you find are not false positive?
      • -
    + ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/find-interview-candidates/README.md b/problems/find-interview-candidates/README.md new file mode 100644 index 000000000..65246e114 --- /dev/null +++ b/problems/find-interview-candidates/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../minimum-path-cost-in-a-hidden-grid "Minimum Path Cost in a Hidden Grid") +                 +[Next >](../determine-color-of-a-chessboard-square "Determine Color of a Chessboard Square") + +## [1811. Find Interview Candidates (Medium)](https://leetcode.com/problems/find-interview-candidates "") + + diff --git a/problems/find-interview-candidates/mysql_schemas.sql b/problems/find-interview-candidates/mysql_schemas.sql new file mode 100644 index 000000000..bfd4e69c8 --- /dev/null +++ b/problems/find-interview-candidates/mysql_schemas.sql @@ -0,0 +1,16 @@ +Create table If Not Exists Contests (contest_id int, gold_medal int, silver_medal int, bronze_medal int); +Create table If Not Exists Users (user_id int, mail varchar(50), name varchar(30)); +Truncate table Contests; +insert into Contests (contest_id, gold_medal, silver_medal, bronze_medal) values ('190', '1', '5', '2'); +insert into Contests (contest_id, gold_medal, silver_medal, bronze_medal) values ('191', '2', '3', '5'); +insert into Contests (contest_id, gold_medal, silver_medal, bronze_medal) values ('192', '5', '2', '3'); +insert into Contests (contest_id, gold_medal, silver_medal, bronze_medal) values ('193', '1', '3', '5'); +insert into Contests (contest_id, gold_medal, silver_medal, bronze_medal) values ('194', '4', '5', '2'); +insert into Contests (contest_id, gold_medal, silver_medal, bronze_medal) values ('195', '4', '2', '1'); +insert into Contests (contest_id, gold_medal, silver_medal, bronze_medal) values ('196', '1', '5', '2'); +Truncate table Users; +insert into Users (user_id, mail, name) values ('1', 'sarah@leetcode.com', 'Sarah'); +insert into Users (user_id, mail, name) values ('2', 'bob@leetcode.com', 'Bob'); +insert into Users (user_id, mail, name) values ('3', 'alice@leetcode.com', 'Alice'); +insert into Users (user_id, mail, name) values ('4', 'hercy@leetcode.com', 'Hercy'); +insert into Users (user_id, mail, name) values ('5', 'quarz@leetcode.com', 'Quarz'); diff --git a/problems/find-k-pairs-with-smallest-sums/README.md b/problems/find-k-pairs-with-smallest-sums/README.md index df71879f7..f8cfd0c6e 100644 --- a/problems/find-k-pairs-with-smallest-sums/README.md +++ b/problems/find-k-pairs-with-smallest-sums/README.md @@ -11,36 +11,47 @@ ## [373. Find K Pairs with Smallest Sums (Medium)](https://leetcode.com/problems/find-k-pairs-with-smallest-sums "查找和最小的K对数字") -

    You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k.

    +

    You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k.

    -

    Define a pair (u,v) which consists of one element from the first array and one element from the second array.

    +

    Define a pair (u, v) which consists of one element from the first array and one element from the second array.

    -

    Find the k pairs (u1,v1),(u2,v2) ...(uk,vk) with the smallest sums.

    +

    Return the k pairs (u1, v1), (u2, v2), ..., (uk, vk) with the smallest sums.

    +

     

    Example 1:

    -Input: nums1 = [1,7,11], nums2 = [2,4,6], k = 3
    -Output: [[1,2],[1,4],[1,6]] 
    -Explanation: The first 3 pairs are returned from the sequence: 
    -             [1,2],[1,4],[1,6],[7,2],[7,4],[11,2],[7,6],[11,4],[11,6]
    +Input: nums1 = [1,7,11], nums2 = [2,4,6], k = 3 +Output: [[1,2],[1,4],[1,6]] +Explanation: The first 3 pairs are returned from the sequence: [1,2],[1,4],[1,6],[7,2],[7,4],[11,2],[7,6],[11,4],[11,6] +

    Example 2:

    -Input: nums1 = [1,1,2], nums2 = [1,2,3], k = 2
    -Output: [1,1],[1,1]
    -Explanation: The first 2 pairs are returned from the sequence: 
    -             [1,1],[1,1],[1,2],[2,1],[1,2],[2,2],[1,3],[1,3],[2,3]
    +Input: nums1 = [1,1,2], nums2 = [1,2,3], k = 2 +Output: [[1,1],[1,1]] +Explanation: The first 2 pairs are returned from the sequence: [1,1],[1,1],[1,2],[2,1],[1,2],[2,2],[1,3],[1,3],[2,3] +

    Example 3:

    -Input: nums1 = [1,2], nums2 = [3], k = 3
    -Output: [1,3],[2,3]
    -Explanation: All possible pairs are returned from the sequence: [1,3],[2,3]
    +Input: nums1 = [1,2], nums2 = [3], k = 3
    +Output: [[1,3],[2,3]]
    +Explanation: All possible pairs are returned from the sequence: [1,3],[2,3]
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums1.length, nums2.length <= 104
    • +
    • -109 <= nums1[i], nums2[i] <= 109
    • +
    • nums1 and nums2 both are sorted in ascending order.
    • +
    • 1 <= k <= 1000
    • +
    + ### Related Topics [[Heap](../../tag/heap/README.md)] diff --git a/problems/finding-the-users-active-minutes/README.md b/problems/finding-the-users-active-minutes/README.md new file mode 100644 index 000000000..649880ff5 --- /dev/null +++ b/problems/finding-the-users-active-minutes/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../truncate-sentence "Truncate Sentence") +                 +[Next >](../minimum-absolute-sum-difference "Minimum Absolute Sum Difference") + +## [1817. Finding the Users Active Minutes (Medium)](https://leetcode.com/problems/finding-the-users-active-minutes "查找用户活跃分钟数") + +

    You are given the logs for users' actions on LeetCode, and an integer k. The logs are represented by a 2D integer array logs where each logs[i] = [IDi, timei] indicates that the user with IDi performed an action at the minute timei.

    + +

    Multiple users can perform actions simultaneously, and a single user can perform multiple actions in the same minute.

    + +

    The user active minutes (UAM) for a given user is defined as the number of unique minutes in which the user performed an action on LeetCode. A minute can only be counted once, even if multiple actions occur during it.

    + +

    You are to calculate a 1-indexed array answer of size k such that, for each j (1 <= j <= k), answer[j] is the number of users whose UAM equals j.

    + +

    Return the array answer as described above.

    + +

     

    +

    Example 1:

    + +
    +Input: logs = [[0,5],[1,2],[0,2],[0,5],[1,3]], k = 5
    +Output: [0,2,0,0,0]
    +Explanation:
    +The user with ID=0 performed actions at minutes 5, 2, and 5 again. Hence, they have a UAM of 2 (minute 5 is only counted once).
    +The user with ID=1 performed actions at minutes 2 and 3. Hence, they have a UAM of 2.
    +Since both users have a UAM of 2, answer[2] is 2, and the remaining answer[j] values are 0.
    +
    + +

    Example 2:

    + +
    +Input: logs = [[1,1],[2,2],[2,3]], k = 4
    +Output: [1,1,0,0]
    +Explanation:
    +The user with ID=1 performed a single action at minute 1. Hence, they have a UAM of 1.
    +The user with ID=2 performed actions at minutes 2 and 3. Hence, they have a UAM of 2.
    +There is one user with a UAM of 1 and one with a UAM of 2.
    +Hence, answer[1] = 1, answer[2] = 1, and the remaining values are 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= logs.length <= 104
    • +
    • 0 <= IDi <= 109
    • +
    • 1 <= timei <= 105
    • +
    • k is in the range [The maximum UAM for a user, 105].
    • +
    + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +Try to find the number of different minutes when action happened for each user. +
    + +
    +Hint 2 +For each user increase the value of the answer array index which matches the UAM for this user. +
    diff --git a/problems/first-unique-character-in-a-string/README.md b/problems/first-unique-character-in-a-string/README.md index 8d1f01059..333d0a2da 100644 --- a/problems/first-unique-character-in-a-string/README.md +++ b/problems/first-unique-character-in-a-string/README.md @@ -11,21 +11,26 @@ ## [387. First Unique Character in a String (Easy)](https://leetcode.com/problems/first-unique-character-in-a-string "字符串中的第一个唯一字符") -

    Given a string, find the first non-repeating character in it and return its index. If it doesn't exist, return -1.

    +

    Given a string s, return the first non-repeating character in it and return its index. If it does not exist, return -1.

    -

    Examples:

    - -
    -s = "leetcode"
    -return 0.
    -
    -s = "loveleetcode"
    -return 2.
    +

     

    +

    Example 1:

    +
    Input: s = "leetcode"
    +Output: 0
    +

    Example 2:

    +
    Input: s = "loveleetcode"
    +Output: 2
    +

    Example 3:

    +
    Input: s = "aabb"
    +Output: -1
     
    -

     

    +

    Constraints:

    -

    Note: You may assume the string contains only lowercase English letters.

    +
      +
    • 1 <= s.length <= 105
    • +
    • s consists of only lowercase English letters.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/flatten-nested-list-iterator/README.md b/problems/flatten-nested-list-iterator/README.md index 183c4401a..7d6f8defc 100644 --- a/problems/flatten-nested-list-iterator/README.md +++ b/problems/flatten-nested-list-iterator/README.md @@ -11,30 +11,40 @@ ## [341. Flatten Nested List Iterator (Medium)](https://leetcode.com/problems/flatten-nested-list-iterator "扁平化嵌套列表迭代器") -

    Given a nested list of integers, implement an iterator to flatten it.

    +

    You are given a nested list of integers nestedList. Each element is either an integer or a list whose elements may also be integers or other lists. Implement an iterator to flatten it.

    -

    Each element is either an integer, or a list -- whose elements may also be integers or other lists.

    +

    Implement the NestedIterator class:

    +
      +
    • NestedIterator(List<NestedInteger> nestedList) Initializes the iterator with the nested list nestedList.
    • +
    • int next() Returns the next integer in the nested list.
    • +
    • boolean hasNext() Returns true if there are still some integers in the nested list and false otherwise.
    • +
    + +

     

    Example 1:

    -
    -Input: [[1,1],2,[1,1]]
    -Output: [1,1,2,1,1]
    -Explanation: By calling next repeatedly until hasNext returns false, 
    -             the order of elements returned by next should be: [1,1,2,1,1].
    +Input: nestedList = [[1,1],2,[1,1]] +Output: [1,1,2,1,1] +Explanation: By calling next repeatedly until hasNext returns false, the order of elements returned by next should be: [1,1,2,1,1]. +
    -

    Example 2:

    -Input: [1,[4,[6]]]
    -Output: [1,4,6]
    -Explanation: By calling next repeatedly until hasNext returns false, 
    -             the order of elements returned by next should be: [1,4,6].
    +Input: nestedList = [1,[4,[6]]]
    +Output: [1,4,6]
    +Explanation: By calling next repeatedly until hasNext returns false, the order of elements returned by next should be: [1,4,6].
     
    -
    - + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nestedList.length <= 500
    • +
    • The values of the integers in the nested list is in the range [-106, 106].
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/guess-the-word/README.md b/problems/guess-the-word/README.md index 8e640a233..59805d5c3 100644 --- a/problems/guess-the-word/README.md +++ b/problems/guess-the-word/README.md @@ -11,34 +11,49 @@ ## [843. Guess the Word (Hard)](https://leetcode.com/problems/guess-the-word "猜猜这个单词") -

    This problem is an interactive problem new to the LeetCode platform.

    +

    This is an interactive problem.

    -

    We are given a word list of unique words, each word is 6 letters long, and one word in this list is chosen as secret.

    +

    You are given an array of unique strings wordlist where wordlist[i] is 6 letters long, and one word in this list is chosen as secret.

    -

    You may call master.guess(word) to guess a word.  The guessed word should have type string and must be from the original list with 6 lowercase letters.

    +

    You may call Master.guess(word) to guess a word. The guessed word should have type string and must be from the original list with 6 lowercase letters.

    -

    This function returns an integer type, representing the number of exact matches (value and position) of your guess to the secret word.  Also, if your guess is not in the given wordlist, it will return -1 instead.

    +

    This function returns an integer type, representing the number of exact matches (value and position) of your guess to the secret word. Also, if your guess is not in the given wordlist, it will return -1 instead.

    -

    For each test case, you have 10 guesses to guess the word. At the end of any number of calls, if you have made 10 or less calls to master.guess and at least one of these guesses was the secret, you pass the testcase.

    +

    For each test case, you have exactly 10 guesses to guess the word. At the end of any number of calls, if you have made 10 or fewer calls to Master.guess and at least one of these guesses was secret, then you pass the test case.

    -

    Besides the example test case below, there will be 5 additional test cases, each with 100 words in the word list.  The letters of each word in those testcases were chosen independently at random from 'a' to 'z', such that every word in the given word lists is unique.

    +

     

    +

    Example 1:

    -Example 1:
    -Input: secret = "acckzz", wordlist = ["acckzz","ccbazz","eiowzz","abcczz"]
    -
    +Input: secret = "acckzz", wordlist = ["acckzz","ccbazz","eiowzz","abcczz"], numguesses = 10
    +Output: You guessed the secret word correctly.
     Explanation:
    +master.guess("aaaaaa") returns -1, because "aaaaaa" is not in wordlist.
    +master.guess("acckzz") returns 6, because "acckzz" is secret and has all 6 matches.
    +master.guess("ccbazz") returns 3, because "ccbazz" has 3 matches.
    +master.guess("eiowzz") returns 2, because "eiowzz" has 2 matches.
    +master.guess("abcczz") returns 4, because "abcczz" has 4 matches.
    +We made 5 calls to master.guess and one of them was the secret, so we pass the test case.
    +
    -master.guess("aaaaaa") returns -1, because "aaaaaa" is not in wordlist. -master.guess("acckzz") returns 6, because "acckzz" is secret and has all 6 matches. -master.guess("ccbazz") returns 3, because "ccbazz" has 3 matches. -master.guess("eiowzz") returns 2, because "eiowzz" has 2 matches. -master.guess("abcczz") returns 4, because "abcczz" has 4 matches. +

    Example 2:

    -We made 5 calls to master.guess and one of them was the secret, so we pass the test case. +
    +Input: secret = "hamada", wordlist = ["hamada","khaled"], numguesses = 10
    +Output: You guessed the secret word correctly.
     
    -

    Note:  Any solutions that attempt to circumvent the judge will result in disqualification.

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= wordlist.length <= 100
    • +
    • wordlist[i].length == 6
    • +
    • wordlist[i] consist of lowercase English letters.
    • +
    • All the strings of wordlist are unique.
    • +
    • secret exists in wordlist.
    • +
    • numguesses == 10
    • +
    ### Related Topics [[Minimax](../../tag/minimax/README.md)] diff --git a/problems/implement-trie-ii-prefix-tree/README.md b/problems/implement-trie-ii-prefix-tree/README.md new file mode 100644 index 000000000..ffa615bb8 --- /dev/null +++ b/problems/implement-trie-ii-prefix-tree/README.md @@ -0,0 +1,34 @@ + + + + + + + +[< Previous](../count-pairs-with-xor-in-a-range "Count Pairs With XOR in a Range") +                 +[Next >](../number-of-different-integers-in-a-string "Number of Different Integers in a String") + +## [1804. Implement Trie II (Prefix Tree) (Medium)](https://leetcode.com/problems/implement-trie-ii-prefix-tree "") + + + +### Related Topics + [[Trie](../../tag/trie/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Try to solve the first version first and reuse your code. +
    + +
    +Hint 2 +To implement the delete function, you should delete the trie nodes of the word if they are not shared with other words. +
    + +
    +Hint 3 +You should keep for each trie node a counter of how many words share this node. +
    diff --git a/problems/implement-trie-prefix-tree/README.md b/problems/implement-trie-prefix-tree/README.md index d740026d7..7bd85c9aa 100644 --- a/problems/implement-trie-prefix-tree/README.md +++ b/problems/implement-trie-prefix-tree/README.md @@ -11,15 +11,15 @@ ## [208. Implement Trie (Prefix Tree) (Medium)](https://leetcode.com/problems/implement-trie-prefix-tree "实现 Trie (前缀树)") -

    Trie (we pronounce "try") or prefix tree is a tree data structure used to retrieve a key in a strings dataset. There are various applications of this very efficient data structure, such as autocomplete and spellchecker.

    +

    A trie (pronounced as "try") or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker.

    Implement the Trie class:

      -
    • Trie() initializes the trie object.
    • -
    • void insert(String word) inserts the string word to the trie.
    • -
    • boolean search(String word) returns true if the string word is in the trie (i.e., was inserted before), and false otherwise.
    • -
    • boolean startsWith(String prefix) returns true if there is a previously inserted string word that has the prefix prefix, and false otherwise.
    • +
    • Trie() Initializes the trie object.
    • +
    • void insert(String word) Inserts the string word into the trie.
    • +
    • boolean search(String word) Returns true if the string word is in the trie (i.e., was inserted before), and false otherwise.
    • +
    • boolean startsWith(String prefix) Returns true if there is a previously inserted string word that has the prefix prefix, and false otherwise.

     

    @@ -47,8 +47,8 @@ trie.search("app"); // return True
    • 1 <= word.length, prefix.length <= 2000
    • -
    • word and prefix consist of lowercase English letters.
    • -
    • At most 3 * 104 calls will be made to insert, search, and startsWith.
    • +
    • word and prefix consist only of lowercase English letters.
    • +
    • At most 3 * 104 calls in total will be made to insert, search, and startsWith.
    ### Related Topics diff --git a/problems/interleaving-string/README.md b/problems/interleaving-string/README.md index 81da4c39c..587a957bd 100644 --- a/problems/interleaving-string/README.md +++ b/problems/interleaving-string/README.md @@ -9,7 +9,7 @@                  [Next >](../validate-binary-search-tree "Validate Binary Search Tree") -## [97. Interleaving String (Hard)](https://leetcode.com/problems/interleaving-string "交错字符串") +## [97. Interleaving String (Medium)](https://leetcode.com/problems/interleaving-string "交错字符串")

    Given strings s1, s2, and s3, find whether s3 is formed by an interleaving of s1 and s2.

    @@ -52,9 +52,12 @@
    • 0 <= s1.length, s2.length <= 100
    • 0 <= s3.length <= 200
    • -
    • s1, s2, and s3 consist of lower-case English letters.
    • +
    • s1, s2, and s3 consist of lowercase English letters.
    +

     

    +

    Follow up: Could you solve it using only O(s2.length) additional memory space?

    + ### Related Topics [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/k-closest-points-to-origin/README.md b/problems/k-closest-points-to-origin/README.md index 4f273231d..947804f45 100644 --- a/problems/k-closest-points-to-origin/README.md +++ b/problems/k-closest-points-to-origin/README.md @@ -11,9 +11,9 @@ ## [973. K Closest Points to Origin (Medium)](https://leetcode.com/problems/k-closest-points-to-origin "最接近原点的 K 个点") -

    Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0).

    +

    Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0).

    -

    The distance between two points on the X-Y plane is the Euclidean distance (i.e, √(x1 - x2)2 + (y1 - y2)2).

    +

    The distance between two points on the X-Y plane is the Euclidean distance (i.e., √(x1 - x2)2 + (y1 - y2)2).

    You may return the answer in any order. The answer is guaranteed to be unique (except for the order that it is in).

    diff --git a/problems/kth-smallest-element-in-a-sorted-matrix/README.md b/problems/kth-smallest-element-in-a-sorted-matrix/README.md index 1f2780795..a057f4b6e 100644 --- a/problems/kth-smallest-element-in-a-sorted-matrix/README.md +++ b/problems/kth-smallest-element-in-a-sorted-matrix/README.md @@ -38,7 +38,7 @@
  • n == matrix.length
  • n == matrix[i].length
  • 1 <= n <= 300
  • -
  • -109 <= matrix[i][j] <= -109
  • +
  • -109 <= matrix[i][j] <= 109
  • All the rows and columns of matrix are guaranteed to be sorted in non-degreasing order.
  • 1 <= k <= n2
  • diff --git a/problems/kth-smallest-instructions/README.md b/problems/kth-smallest-instructions/README.md index 72f4e121b..f24a0dcd9 100644 --- a/problems/kth-smallest-instructions/README.md +++ b/problems/kth-smallest-instructions/README.md @@ -22,12 +22,9 @@

    Multiple instructions will lead Bob to destination. For example, if destination is (2, 3), both "HHHVV" and "HVHVH" are valid instructions.

    -
      -
    -

    However, Bob is very picky. Bob has a lucky number k, and he wants the kth lexicographically smallest instructions that will lead him to destination. k is 1-indexed.

    -

    Given an integer array destination and an integer k, return the kth lexicographically smallest instructions that will take Bob to destination.

    +

    Given an integer array destination and an integer k, return the kth lexicographically smallest instructions that will take Bob to destination.

     

    Example 1:

    diff --git a/problems/lexicographical-numbers/README.md b/problems/lexicographical-numbers/README.md index 202709cbe..8d96fd73a 100644 --- a/problems/lexicographical-numbers/README.md +++ b/problems/lexicographical-numbers/README.md @@ -11,8 +11,22 @@ ## [386. Lexicographical Numbers (Medium)](https://leetcode.com/problems/lexicographical-numbers "字典序排数") -

    Given an integer n, return 1 - n in lexicographical order.

    +

    Given an integer n, return all the numbers in the range [1, n] sorted in lexicographical order.

    -

    For example, given 13, return: [1,10,11,12,13,2,3,4,5,6,7,8,9].

    +

     

    +

    Example 1:

    +
    Input: n = 13
    +Output: [1,10,11,12,13,2,3,4,5,6,7,8,9]
    +

    Example 2:

    +
    Input: n = 2
    +Output: [1,2]
    +
    +

     

    +

    Constraints:

    -

    Please optimize your algorithm to use less time and space. The input size may be as large as 5,000,000.

    +
      +
    • 1 <= n <= 5 * 104
    • +
    + +

     

    +

    Follow up: Could you optimize your solution to use O(n) runtime and O(1) space?

    diff --git a/problems/longest-zigzag-path-in-a-binary-tree/README.md b/problems/longest-zigzag-path-in-a-binary-tree/README.md index 24109eba2..5d6327216 100644 --- a/problems/longest-zigzag-path-in-a-binary-tree/README.md +++ b/problems/longest-zigzag-path-in-a-binary-tree/README.md @@ -11,24 +11,24 @@ ## [1372. Longest ZigZag Path in a Binary Tree (Medium)](https://leetcode.com/problems/longest-zigzag-path-in-a-binary-tree "二叉树中的最长交错路径") -

    Given a binary tree root, a ZigZag path for a binary tree is defined as follow:

    +

    You are given the root of a binary tree.

    + +

    A ZigZag path for a binary tree is defined as follow:

    • Choose any node in the binary tree and a direction (right or left).
    • -
    • If the current direction is right then move to the right child of the current node otherwise move to the left child.
    • -
    • Change the direction from right to left or right to left.
    • -
    • Repeat the second and third step until you can't move in the tree.
    • +
    • If the current direction is right, move to the right child of the current node; otherwise, move to the left child.
    • +
    • Change the direction from right to left or from left to right.
    • +
    • Repeat the second and third steps until you can't move in the tree.

    Zigzag length is defined as the number of nodes visited - 1. (A single node has a length of 0).

    -

    Return the longest ZigZag path contained in that tree.

    +

    Return the longest ZigZag path contained in that tree.

     

    Example 1:

    - -

    - +
     Input: root = [1,null,1,1,1,null,null,1,1,null,1,null,null,null,1,null,1]
     Output: 3
    @@ -36,9 +36,7 @@
     

    Example 2:

    - -

    - +
     Input: root = [1,1,1,null,1,null,null,1,1,null,1]
     Output: 4
    @@ -56,8 +54,8 @@
     

    Constraints:

      -
    • Each tree has at most 50000 nodes..
    • -
    • Each node's value is between [1, 100].
    • +
    • The number of nodes in the tree is in the range [1, 5 * 104].
    • +
    • 1 <= Node.val <= 100
    ### Related Topics diff --git a/problems/matrix-block-sum/README.md b/problems/matrix-block-sum/README.md index 177fee58e..2b6c54b20 100644 --- a/problems/matrix-block-sum/README.md +++ b/problems/matrix-block-sum/README.md @@ -11,19 +11,26 @@ ## [1314. Matrix Block Sum (Medium)](https://leetcode.com/problems/matrix-block-sum "矩阵区域和") -Given a m * n matrix mat and an integer K, return a matrix answer where each answer[i][j] is the sum of all elements mat[r][c] for i - K <= r <= i + K, j - K <= c <= j + K, and (r, c) is a valid position in the matrix. +

    Given a m x n matrix mat and an integer k, return a matrix answer where each answer[i][j] is the sum of all elements mat[r][c] for:

    + +
      +
    • i - k <= r <= i + k,
    • +
    • j - k <= c <= j + k, and
    • +
    • (r, c) is a valid position in the matrix.
    • +
    +

     

    Example 1:

    -Input: mat = [[1,2,3],[4,5,6],[7,8,9]], K = 1
    +Input: mat = [[1,2,3],[4,5,6],[7,8,9]], k = 1
     Output: [[12,21,16],[27,45,33],[24,39,28]]
     

    Example 2:

    -Input: mat = [[1,2,3],[4,5,6],[7,8,9]], K = 2
    +Input: mat = [[1,2,3],[4,5,6],[7,8,9]], k = 2
     Output: [[45,45,45],[45,45,45],[45,45,45]]
     
    @@ -33,7 +40,7 @@ Given a m * n matrix mat and an integer
  • m == mat.length
  • n == mat[i].length
  • -
  • 1 <= m, n, K <= 100
  • +
  • 1 <= m, n, k <= 100
  • 1 <= mat[i][j] <= 100
  • diff --git a/problems/max-sum-of-rectangle-no-larger-than-k/README.md b/problems/max-sum-of-rectangle-no-larger-than-k/README.md index 332f0d7ea..9a36b842f 100644 --- a/problems/max-sum-of-rectangle-no-larger-than-k/README.md +++ b/problems/max-sum-of-rectangle-no-larger-than-k/README.md @@ -37,8 +37,7 @@
    • m == matrix.length
    • n == matrix[i].length
    • -
    • 1 <= m, n <= 3000
    • -
    • 1 <= m * n <= 5 * 104
    • +
    • 1 <= m, n <= 100
    • -100 <= matrix[i][j] <= 100
    • -105 <= k <= 105
    diff --git a/problems/maximize-number-of-nice-divisors/README.md b/problems/maximize-number-of-nice-divisors/README.md new file mode 100644 index 000000000..275637e53 --- /dev/null +++ b/problems/maximize-number-of-nice-divisors/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../evaluate-the-bracket-pairs-of-a-string "Evaluate the Bracket Pairs of a String") +                 +[Next >](../ad-free-sessions "Ad-Free Sessions") + +## [1808. Maximize Number of Nice Divisors (Hard)](https://leetcode.com/problems/maximize-number-of-nice-divisors "好因子的最大数目") + +

    You are given a positive integer primeFactors. You are asked to construct a positive integer n that satisfies the following conditions:

    + +
      +
    • The number of prime factors of n (not necessarily distinct) is at most primeFactors.
    • +
    • The number of nice divisors of n is maximized. Note that a divisor of n is nice if it is divisible by every prime factor of n. For example, if n = 12, then its prime factors are [2,2,3], then 6 and 12 are nice divisors, while 3 and 4 are not.
    • +
    + +

    Return the number of nice divisors of n. Since that number can be too large, return it modulo 109 + 7.

    + +

    Note that a prime number is a natural number greater than 1 that is not a product of two smaller natural numbers. The prime factors of a number n is a list of prime numbers such that their product equals n.

    + +

     

    +

    Example 1:

    + +
    +Input: primeFactors = 5
    +Output: 6
    +Explanation: 200 is a valid value of n.
    +It has 5 prime factors: [2,2,2,5,5], and it has 6 nice divisors: [10,20,40,50,100,200].
    +There is not other value of n that has at most 5 prime factors and more nice divisors.
    +
    + +

    Example 2:

    + +
    +Input: primeFactors = 8
    +Output: 18
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= primeFactors <= 109
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +The number of nice divisors is equal to the product of the count of each prime factor. Then the problem is reduced to: given n, find a sequence of numbers whose sum equals n and whose product is maximized. +
    + +
    +Hint 2 +This sequence can have no numbers that are larger than 4. Proof: if it contains a number x that is larger than 4, then you can replace x with floor(x/2) and ceil(x/2), and floor(x/2) * ceil(x/2) > x. You can also replace 4s with two 2s. Hence, there will always be optimal solutions with only 2s and 3s. +
    + +
    +Hint 3 +If there are three 2s, you can replace them with two 3s to get a better product. Hence, you'll never have more than two 2s. +
    + +
    +Hint 4 +Keep adding 3s as long as n ≥ 5. +
    diff --git a/problems/maximum-number-of-groups-getting-fresh-donuts/README.md b/problems/maximum-number-of-groups-getting-fresh-donuts/README.md new file mode 100644 index 000000000..e405a90c5 --- /dev/null +++ b/problems/maximum-number-of-groups-getting-fresh-donuts/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../count-nice-pairs-in-an-array "Count Nice Pairs in an Array") +                 +[Next >](../truncate-sentence "Truncate Sentence") + +## [1815. Maximum Number of Groups Getting Fresh Donuts (Hard)](https://leetcode.com/problems/maximum-number-of-groups-getting-fresh-donuts "得到新鲜甜甜圈的最多组数") + +

    There is a donuts shop that bakes donuts in batches of batchSize. They have a rule where they must serve all of the donuts of a batch before serving any donuts of the next batch. You are given an integer batchSize and an integer array groups, where groups[i] denotes that there is a group of groups[i] customers that will visit the shop. Each customer will get exactly one donut.

    + +

    When a group visits the shop, all customers of the group must be served before serving any of the following groups. A group will be happy if they all get fresh donuts. That is, the first customer of the group does not receive a donut that was left over from the previous group.

    + +

    You can freely rearrange the ordering of the groups. Return the maximum possible number of happy groups after rearranging the groups.

    + +

     

    +

    Example 1:

    + +
    +Input: batchSize = 3, groups = [1,2,3,4,5,6]
    +Output: 4
    +Explanation: You can arrange the groups as [6,2,4,5,1,3]. Then the 1st, 2nd, 4th, and 6th groups will be happy.
    +
    + +

    Example 2:

    + +
    +Input: batchSize = 4, groups = [1,3,2,5,2,2,1,6]
    +Output: 4
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= batchSize <= 9
    • +
    • 1 <= groups.length <= 30
    • +
    • 1 <= groups[i] <= 109
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +The maximum number of happy groups is the maximum number of partitions you can split the groups into such that the sum of group sizes in each partition is 0 mod batchSize. At most one partition is allowed to have a different remainder (the first group will get fresh donuts anyway). +
    + +
    +Hint 2 +Suppose you have an array freq of length k where freq[i] = number of groups of size i mod batchSize. How can you utilize this in a dp solution? +
    + +
    +Hint 3 +Make a DP state dp[freq][r] that represents "the maximum number of partitions you can form given the current freq and current remainder r". You can hash the freq array to store it more easily in the dp table. +
    + +
    +Hint 4 +For each i from 0 to batchSize-1, the next DP state is dp[freq`][(r+i)%batchSize] where freq` is freq but with freq[i] decremented by 1. Take the largest of all of the next states and store it in ans. If r == 0, then return ans+1 (because you can form a new partition), otherwise return ans (continuing the current partition). +
    diff --git a/problems/maximum-product-subarray/README.md b/problems/maximum-product-subarray/README.md index 3125d9fca..e404b0797 100644 --- a/problems/maximum-product-subarray/README.md +++ b/problems/maximum-product-subarray/README.md @@ -40,6 +40,7 @@
    • 1 <= nums.length <= 2 * 104
    • -10 <= nums[i] <= 10
    • +
    • The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.
    ### Related Topics diff --git a/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md b/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md index 0c57bbf23..a3840e9fe 100644 --- a/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md +++ b/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md @@ -11,7 +11,7 @@ ## [1802. Maximum Value at a Given Index in a Bounded Array (Medium)](https://leetcode.com/problems/maximum-value-at-a-given-index-in-a-bounded-array "有界数组中指定下标处的最大值") -

    You are given three positive integers n, index and maxSum. You want to construct an array nums (0-indexed) that satisfies the following conditions:

    +

    You are given three positive integers: n, index, and maxSum. You want to construct an array nums (0-indexed) that satisfies the following conditions:

    • nums.length == n
    • @@ -21,7 +21,7 @@
    • nums[index] is maximized.
    -

    Return nums[index] of the constructed array.

    +

    Return nums[index] of the constructed array.

    Note that abs(x) equals x if x >= 0, and -x otherwise.

    @@ -31,7 +31,8 @@
     Input: n = 4, index = 2,  maxSum = 6
     Output: 2
    -Explanation: The arrays [1,1,2,1] and [1,2,2,1] satisfy all the conditions. There are no other valid arrays with a larger value at the given index.
    +Explanation: nums = [1,2,2,1] is one array that satisfies all the conditions.
    +There are no arrays that satisfy all the conditions and have nums[2] == 3, so 2 is the maximum nums[2].
     

    Example 2:

    diff --git a/problems/mini-parser/README.md b/problems/mini-parser/README.md index 711e765b7..2ab07f484 100644 --- a/problems/mini-parser/README.md +++ b/problems/mini-parser/README.md @@ -11,45 +11,40 @@ ## [385. Mini Parser (Medium)](https://leetcode.com/problems/mini-parser "迷你语法分析器") -

    Given a nested list of integers represented as a string, implement a parser to deserialize it.

    +

    Given a string s represents the serialization of a nested list, implement a parser to deserialize it and return the deserialized NestedInteger.

    -

    Each element is either an integer, or a list -- whose elements may also be integers or other lists.

    - -

    Note: You may assume that the string is well-formed:

    - -
      -
    • String is non-empty.
    • -
    • String does not contain white spaces.
    • -
    • String contains only digits 0-9, [, - ,, ].
    • -
    +

    Each element is either an integer or a list whose elements may also be integers or other lists.

     

    - -

    Example 1:

    +

    Example 1:

    -Given s = "324",
    -
    -You should return a NestedInteger object which contains a single integer 324.
    +Input: s = "324"
    +Output: 324
    +Explanation: You should return a NestedInteger object which contains a single integer 324.
     
    -

     

    - -

    Example 2:

    +

    Example 2:

    -Given s = "[123,[456,[789]]]",
    -
    -Return a NestedInteger object containing a nested list with 2 elements:
    -
    +Input: s = "[123,[456,[789]]]"
    +Output: [123,[456,[789]]]
    +Explanation: Return a NestedInteger object containing a nested list with 2 elements:
     1. An integer containing value 123.
     2. A nested list containing two elements:
         i.  An integer containing value 456.
         ii. A nested list with one element:
    -         a. An integer containing value 789.
    +         a. An integer containing value 789
     

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 5 * 104
    • +
    • s consists of digits, square brackets "[]", negative sign '-', and commas ','.
    • +
    • s is the serialization of valid NestedInteger.
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/minimum-absolute-sum-difference/README.md b/problems/minimum-absolute-sum-difference/README.md new file mode 100644 index 000000000..6c6473f62 --- /dev/null +++ b/problems/minimum-absolute-sum-difference/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../finding-the-users-active-minutes "Finding the Users Active Minutes") +                 +[Next >](../number-of-different-subsequences-gcds "Number of Different Subsequences GCDs") + +## [1818. Minimum Absolute Sum Difference (Medium)](https://leetcode.com/problems/minimum-absolute-sum-difference "绝对差值和") + +

    You are given two positive integer arrays nums1 and nums2, both of length n.

    + +

    The absolute sum difference of arrays nums1 and nums2 is defined as the sum of |nums1[i] - nums2[i]| for each 0 <= i < n (0-indexed).

    + +

    You can replace at most one element of nums1 with any other element in nums1 to minimize the absolute sum difference.

    + +

    Return the minimum absolute sum difference after replacing at most one element in the array nums1. Since the answer may be large, return it modulo 109 + 7.

    + +

    |x| is defined as:

    + +
      +
    • x if x >= 0, or
    • +
    • -x if x < 0.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: nums1 = [1,7,5], nums2 = [2,3,5]
    +Output: 3
    +Explanation: There are two possible optimal solutions:
    +- Replace the second element with the first: [1,7,5] => [1,1,5], or
    +- Replace the second element with the third: [1,7,5] => [1,5,5].
    +Both will yield an absolute sum difference of |1-2| + (|1-3| or |5-3|) + |5-5| = 3.
    +
    + +

    Example 2:

    + +
    +Input: nums1 = [2,4,6,8,10], nums2 = [2,4,6,8,10]
    +Output: 0
    +Explanation: nums1 is equal to nums2 so no replacement is needed. This will result in an 
    +absolute sum difference of 0.
    +
    + +

    Example 3:

    + +
    +Input: nums1 = [1,10,4,4,2,7], nums2 = [9,3,5,1,7,4]
    +Output: 20
    +Explanation: Replace the first element with the second: [1,10,4,4,2,7] => [10,10,4,4,2,7].
    +This yields an absolute sum difference of |10-9| + |10-3| + |4-5| + |4-1| + |2-7| + |7-4| = 20
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums1.length
    • +
    • n == nums2.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= nums1[i], nums2[i] <= 105
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Go through each element and test the optimal replacements. +
    + +
    +Hint 2 +There are only 2 possible replacements for each element (higher and lower) that are optimal. +
    diff --git a/problems/minimum-cost-to-connect-two-groups-of-points/README.md b/problems/minimum-cost-to-connect-two-groups-of-points/README.md index 9be74d9b6..5ffa57040 100644 --- a/problems/minimum-cost-to-connect-two-groups-of-points/README.md +++ b/problems/minimum-cost-to-connect-two-groups-of-points/README.md @@ -11,11 +11,11 @@ ## [1595. Minimum Cost to Connect Two Groups of Points (Hard)](https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points "连通两组点的最小成本") -

    You are given two groups of points where the first group has size1 points, the second group has size2 points, and size1 >= size2.

    +

    You are given two groups of points where the first group has size1 points, the second group has size2 points, and size1 >= size2.

    -

    The cost of the connection between any two points are given in an size1 x size2 matrix where cost[i][j] is the cost of connecting point i of the first group and point j of the second group. The groups are connected if each point in both groups is connected to one or more points in the opposite group. In other words, each point in the first group must be connected to at least one point in the second group, and each point in the second group must be connected to at least one point in the first group.

    +

    The cost of the connection between any two points are given in an size1 x size2 matrix where cost[i][j] is the cost of connecting point i of the first group and point j of the second group. The groups are connected if each point in both groups is connected to one or more points in the opposite group. In other words, each point in the first group must be connected to at least one point in the second group, and each point in the second group must be connected to at least one point in the first group.

    -

    Return the minimum cost it takes to connect the two groups.

    +

    Return the minimum cost it takes to connect the two groups.

     

    Example 1:

    @@ -54,10 +54,10 @@ Note that there are multiple points connected to point 2 in the first group and

    Constraints:

      -
    • size1 == cost.length
    • -
    • size2 == cost[i].length
    • -
    • 1 <= size1, size2 <= 12
    • -
    • size1 >= size2
    • +
    • size1 == cost.length
    • +
    • size2 == cost[i].length
    • +
    • 1 <= size1, size2 <= 12
    • +
    • size1 >= size2
    • 0 <= cost[i][j] <= 100
    diff --git a/problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md b/problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md new file mode 100644 index 000000000..88c831003 --- /dev/null +++ b/problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../number-of-different-integers-in-a-string "Number of Different Integers in a String") +                 +[Next >](../evaluate-the-bracket-pairs-of-a-string "Evaluate the Bracket Pairs of a String") + +## [1806. Minimum Number of Operations to Reinitialize a Permutation (Medium)](https://leetcode.com/problems/minimum-number-of-operations-to-reinitialize-a-permutation "还原排列的最少操作步数") + +

    You are given an even integer n​​​​​​. You initially have a permutation perm of size n​​ where perm[i] == i(0-indexed)​​​​.

    + +

    In one operation, you will create a new array arr, and for each i:

    + +
      +
    • If i % 2 == 0, then arr[i] = perm[i / 2].
    • +
    • If i % 2 == 1, then arr[i] = perm[n / 2 + (i - 1) / 2].
    • +
    + +

    You will then assign arr​​​​ to perm.

    + +

    Return the minimum non-zero number of operations you need to perform on perm to return the permutation to its initial value.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 2
    +Output: 1
    +Explanation: perm = [0,1] initially.
    +After the 1st operation, perm = [0,1]
    +So it takes only 1 operation.
    +
    + +

    Example 2:

    + +
    +Input: n = 4
    +Output: 2
    +Explanation: perm = [0,1,2,3] initially.
    +After the 1st operation, perm = [0,2,1,3]
    +After the 2nd operation, perm = [0,1,2,3]
    +So it takes only 2 operations.
    +
    + +

    Example 3:

    + +
    +Input: n = 6
    +Output: 4
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 1000
    • +
    • n​​​​​​ is even.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +It is safe to assume the number of operations isn't more than n +
    + +
    +Hint 2 +The number is small enough to apply a brute force solution. +
    diff --git a/problems/minimum-path-cost-in-a-hidden-grid/README.md b/problems/minimum-path-cost-in-a-hidden-grid/README.md new file mode 100644 index 000000000..552bd142f --- /dev/null +++ b/problems/minimum-path-cost-in-a-hidden-grid/README.md @@ -0,0 +1,35 @@ + + + + + + + +[< Previous](../ad-free-sessions "Ad-Free Sessions") +                 +[Next >](../find-interview-candidates "Find Interview Candidates") + +## [1810. Minimum Path Cost in a Hidden Grid (Medium)](https://leetcode.com/problems/minimum-path-cost-in-a-hidden-grid "") + + + +### Related Topics + [[Heap](../../tag/heap/README.md)] + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + +### Hints +
    +Hint 1 +The grid is at a maximum 100 x 100, so it is clever to assume that the robot's initial cell is grid[101][101] +
    + +
    +Hint 2 +Run a DFS from the robot's position to make sure that you can reach the target, otherwise you should return -1. +
    + +
    +Hint 3 +Now that you are sure you can reach the target and that you know the grid, run Dijkstra to find the minimum cost. +
    diff --git a/problems/next-greater-element-ii/README.md b/problems/next-greater-element-ii/README.md index 50f96bf30..dcda8cac9 100644 --- a/problems/next-greater-element-ii/README.md +++ b/problems/next-greater-element-ii/README.md @@ -11,21 +11,35 @@ ## [503. Next Greater Element II (Medium)](https://leetcode.com/problems/next-greater-element-ii "下一个更大元素 II") -

    -Given a circular array (the next element of the last element is the first element of the array), print the Next Greater Number for every element. The Next Greater Number of a number x is the first greater number to its traversing-order next in the array, which means you could search circularly to find its next greater number. If it doesn't exist, output -1 for this number. -

    +

    Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), return the next greater number for every element in nums.

    + +

    The next greater number of a number x is the first greater number to its traversing-order next in the array, which means you could search circularly to find its next greater number. If it doesn't exist, return -1 for this number.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: [1,2,1]
    -Output: [2,-1,2]
    -Explanation: The first 1's next greater number is 2; 
    The number 2 can't find next greater number;
    The second 1's next greater number needs to search circularly, which is also 2. +Input: nums = [1,2,1] +Output: [2,-1,2] +Explanation: The first 1's next greater number is 2; +The number 2 can't find next greater number. +The second 1's next greater number needs to search circularly, which is also 2.
    -

    -

    Note: -The length of given array won't exceed 10000. -

    +

    Example 2:

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

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 104
    • +
    • -109 <= nums[i] <= 109
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/number-of-different-integers-in-a-string/README.md b/problems/number-of-different-integers-in-a-string/README.md new file mode 100644 index 000000000..ed632b793 --- /dev/null +++ b/problems/number-of-different-integers-in-a-string/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../implement-trie-ii-prefix-tree "Implement Trie II (Prefix Tree)") +                 +[Next >](../minimum-number-of-operations-to-reinitialize-a-permutation "Minimum Number of Operations to Reinitialize a Permutation") + +## [1805. Number of Different Integers in a String (Easy)](https://leetcode.com/problems/number-of-different-integers-in-a-string "字符串中不同整数的数目") + +

    You are given a string word that consists of digits and lowercase English letters.

    + +

    You will replace every non-digit character with a space. For example, "a123bc34d8ef34" will become " 123  34 8  34". Notice that you are left with some integers that are separated by at least one space: "123", "34", "8", and "34".

    + +

    Return the number of different integers after performing the replacement operations on word.

    + +

    Two integers are considered different if their decimal representations without any leading zeros are different.

    + +

     

    +

    Example 1:

    + +
    +Input: word = "a123bc34d8ef34"
    +Output: 3
    +Explanation: The three different integers are "123", "34", and "8". Notice that "34" is only counted once.
    +
    + +

    Example 2:

    + +
    +Input: word = "leet1234code234"
    +Output: 2
    +
    + +

    Example 3:

    + +
    +Input: word = "a1b01c001"
    +Output: 1
    +Explanation: The three integers "1", "01", and "001" all represent the same integer because
    +the leading zeros are ignored when comparing their decimal values.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= word.length <= 1000
    • +
    • word consists of digits and lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Try to split the string so that each integer is in a different string. +
    + +
    +Hint 2 +Try to remove each integer's leading zeroes and compare the strings to find how many of them are unique. +
    diff --git a/problems/number-of-different-subsequences-gcds/README.md b/problems/number-of-different-subsequences-gcds/README.md new file mode 100644 index 000000000..772562176 --- /dev/null +++ b/problems/number-of-different-subsequences-gcds/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../minimum-absolute-sum-difference "Minimum Absolute Sum Difference") +                 +Next > + +## [1819. Number of Different Subsequences GCDs (Hard)](https://leetcode.com/problems/number-of-different-subsequences-gcds "序列中不同最大公约数的数目") + +

    You are given an array nums that consists of positive integers.

    + +

    The GCD of a sequence of numbers is defined as the greatest integer that divides all the numbers in the sequence evenly.

    + +
      +
    • For example, the GCD of the sequence [4,6,16] is 2.
    • +
    + +

    A subsequence of an array is a sequence that can be formed by removing some elements (possibly none) of the array.

    + +
      +
    • For example, [2,5,10] is a subsequence of [1,2,1,2,4,1,5,10].
    • +
    + +

    Return the number of different GCDs among all non-empty subsequences of nums.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [6,10,3]
    +Output: 5
    +Explanation: The figure shows all the non-empty subsequences and their GCDs.
    +The different GCDs are 6, 10, 3, 2, and 1.
    +
    + +

    Example 2:

    + +
    +Input: nums = [5,15,40,5,6]
    +Output: 7
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 2 * 105
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Think of how to check if a number x is a gcd of a subsequence. +
    + +
    +Hint 2 +If there is such subsequence, then all of it will be divisible by x. Moreover, if you divide each number in the subsequence by x , then the gcd of the resulting numbers will be 1. +
    + +
    +Hint 3 +Adding a number to a subsequence cannot increase its gcd. So, if there is a valid subsequence for x , then the subsequence that contains all multiples of x is a valid one too. +
    + +
    +Hint 4 +Iterate on all possiblex from 1 to 10^5, and check if there is a valid subsequence for x. +
    diff --git a/problems/pacific-atlantic-water-flow/README.md b/problems/pacific-atlantic-water-flow/README.md index 0b253b797..2c5427e2f 100644 --- a/problems/pacific-atlantic-water-flow/README.md +++ b/problems/pacific-atlantic-water-flow/README.md @@ -11,40 +11,36 @@ ## [417. Pacific Atlantic Water Flow (Medium)](https://leetcode.com/problems/pacific-atlantic-water-flow "太平洋大西洋水流问题") -

    Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top edges of the matrix and the "Atlantic ocean" touches the right and bottom edges.

    +

    You are given an m x n integer matrix heights representing the height of each unit cell in a continent. The Pacific ocean touches the continent's left and top edges, and the Atlantic ocean touches the continent's right and bottom edges.

    -

    Water can only flow in four directions (up, down, left, or right) from a cell to another one with height equal or lower.

    +

    Water can only flow in four directions: up, down, left, and right. Water flows from a cell to an adjacent one with an equal or lower height.

    -

    Find the list of grid coordinates where water can flow to both the Pacific and Atlantic ocean.

    - -

    Note:

    - -
      -
    1. The order of returned grid coordinates does not matter.
    2. -
    3. Both m and n are less than 150.
    4. -
    +

    Return a list of grid coordinates where water can flow to both the Pacific and Atlantic oceans.

     

    - -

    Example:

    - +

    Example 1:

    +
    -Given the following 5x5 matrix:
    -
    -  Pacific ~   ~   ~   ~   ~ 
    -       ~  1   2   2   3  (5) *
    -       ~  3   2   3  (4) (4) *
    -       ~  2   4  (5)  3   1  *
    -       ~ (6) (7)  1   4   5  *
    -       ~ (5)  1   1   2   4  *
    -          *   *   *   *   * Atlantic
    +Input: heights = [[1,2,2,3,5],[3,2,3,4,4],[2,4,5,3,1],[6,7,1,4,5],[5,1,1,2,4]]
    +Output: [[0,4],[1,3],[1,4],[2,2],[3,0],[3,1],[4,0]]
    +
    -Return: +

    Example 2:

    -[[0, 4], [1, 3], [1, 4], [2, 2], [3, 0], [3, 1], [4, 0]] (positions with parentheses in above matrix). +
    +Input: heights = [[2,1],[1,2]]
    +Output: [[0,0],[0,1],[1,0],[1,1]]
     

     

    +

    Constraints:

    + +
      +
    • m == heights.length
    • +
    • n == heights[i].length
    • +
    • 1 <= m, n <= 200
    • +
    • 1 <= heights[i][j] <= 105
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/path-with-maximum-gold/README.md b/problems/path-with-maximum-gold/README.md index 451de7d4d..878ff1a12 100644 --- a/problems/path-with-maximum-gold/README.md +++ b/problems/path-with-maximum-gold/README.md @@ -11,16 +11,16 @@ ## [1219. Path with Maximum Gold (Medium)](https://leetcode.com/problems/path-with-maximum-gold "黄金矿工") -

    In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty.

    +

    In a gold mine grid of size m x n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty.

    -

    Return the maximum amount of gold you can collect under the conditions:

    +

    Return the maximum amount of gold you can collect under the conditions:

    • Every time you are located in a cell you will collect all the gold in that cell.
    • -
    • From your position you can walk one step to the left, right, up or down.
    • +
    • From your position, you can walk one step to the left, right, up, or down.
    • You can't visit the same cell more than once.
    • -
    • Never visit a cell with 0 gold.
    • -
    • You can start and stop collecting gold from any position in the grid that has some gold.
    • +
    • Never visit a cell with 0 gold.
    • +
    • You can start and stop collecting gold from any position in the grid that has some gold.

     

    @@ -54,9 +54,11 @@ Path to get the maximum gold, 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7.

    Constraints:

      -
    • 1 <= grid.length, grid[i].length <= 15
    • +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 15
    • 0 <= grid[i][j] <= 100
    • -
    • There are at most 25 cells containing gold.
    • +
    • There are at most 25 cells containing gold.
    ### Related Topics diff --git a/problems/perfect-rectangle/README.md b/problems/perfect-rectangle/README.md index fdfef1386..9947173a2 100644 --- a/problems/perfect-rectangle/README.md +++ b/problems/perfect-rectangle/README.md @@ -11,84 +11,51 @@ ## [391. Perfect Rectangle (Hard)](https://leetcode.com/problems/perfect-rectangle "完美矩形") -

    Given N axis-aligned rectangles where N > 0, determine if they all together form an exact cover of a rectangular region.

    +

    Given an array rectangles where rectangles[i] = [xi, yi, ai, bi] represents an axis-aligned rectangle. The bottom-left point of the rectangle is (xi, yi) and the top-right point of it is (ai, bi).

    -

    Each rectangle is represented as a bottom-left point and a top-right point. For example, a unit square is represented as [1,1,2,2]. (coordinate of bottom-left point is (1, 1) and top-right point is (2, 2)).

    - -
    - -

    Example 1:

    +

    Return true if all the rectangles together form an exact cover of a rectangular region.

    +

     

    +

    Example 1:

    +
    -rectangles = [
    -  [1,1,3,3],
    -  [3,1,4,2],
    -  [3,2,4,4],
    -  [1,3,2,4],
    -  [2,3,3,4]
    -]
    -
    -Return true. All 5 rectangles together form an exact cover of a rectangular region.
    +Input: rectangles = [[1,1,3,3],[3,1,4,2],[3,2,4,4],[1,3,2,4],[2,3,3,4]]
    +Output: true
    +Explanation: All 5 rectangles together form an exact cover of a rectangular region.
     
    -

     

    - -
     
    - -
    - -

    Example 2:

    - +

    Example 2:

    +
    -rectangles = [
    -  [1,1,2,3],
    -  [1,3,2,4],
    -  [3,1,4,2],
    -  [3,2,4,4]
    -]
    -
    -Return false. Because there is a gap between the two rectangular regions.
    +Input: rectangles = [[1,1,2,3],[1,3,2,4],[3,1,4,2],[3,2,4,4]]
    +Output: false
    +Explanation: Because there is a gap between the two rectangular regions.
     
    -

     

    - -
     
    - -
    - -

    Example 3:

    - +

    Example 3:

    +
    -rectangles = [
    -  [1,1,3,3],
    -  [3,1,4,2],
    -  [1,3,2,4],
    -  [3,2,4,4]
    -]
    -
    -Return false. Because there is a gap in the top center.
    +Input: rectangles = [[1,1,3,3],[3,1,4,2],[1,3,2,4],[3,2,4,4]]
    +Output: false
    +Explanation: Because there is a gap in the top center.
     
    -

     

    - -
     
    - -
    - -

    Example 4:

    - +

    Example 4:

    +
    -rectangles = [
    -  [1,1,3,3],
    -  [3,1,4,2],
    -  [1,3,2,4],
    -  [2,2,4,4]
    -]
    -
    -Return false. Because two of the rectangles overlap with each other.
    +Input: rectangles = [[1,1,3,3],[3,1,4,2],[1,3,2,4],[2,2,4,4]]
    +Output: false
    +Explanation: Because two of the rectangles overlap with each other.
     

     

    +

    Constraints:

    + +
      +
    • 1 <= rectangles.length <= 2 * 104
    • +
    • rectangles[i].length == 4
    • +
    • -105 <= xi, yi, ai, bi <= 105
    • +
    ### Related Topics [[Line Sweep](../../tag/line-sweep/README.md)] diff --git a/problems/powx-n/README.md b/problems/powx-n/README.md index 8dee24e5c..d468700a6 100644 --- a/problems/powx-n/README.md +++ b/problems/powx-n/README.md @@ -11,7 +11,7 @@ ## [50. Pow(x, n) (Medium)](https://leetcode.com/problems/powx-n "Pow(x, n)") -

    Implement pow(x, n), which calculates x raised to the power n (i.e. xn).

    +

    Implement pow(x, n), which calculates x raised to the power n (i.e., xn).

     

    Example 1:

    diff --git a/problems/random-pick-index/README.md b/problems/random-pick-index/README.md index 377cef862..0ca6f4c30 100644 --- a/problems/random-pick-index/README.md +++ b/problems/random-pick-index/README.md @@ -11,23 +11,41 @@ ## [398. Random Pick Index (Medium)](https://leetcode.com/problems/random-pick-index "随机数索引") -

    Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array.

    +

    Given an integer array nums with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array.

    -

    Note:
    -The array size can be very large. Solution that uses too much extra space will not pass the judge.

    +

    Implement the Solution class:

    -

    Example:

    +
      +
    • Solution(int[] nums) Initializes the object with the array nums.
    • +
    • int pick(int target) Picks a random index i from nums where nums[i] == target. If there are multiple valid i's, then each index should have an equal probability of returning.
    • +
    + +

     

    +

    Example 1:

    -int[] nums = new int[] {1,2,3,3,3};
    -Solution solution = new Solution(nums);
    +Input
    +["Solution", "pick", "pick", "pick"]
    +[[[1, 2, 3, 3, 3]], [3], [1], [3]]
    +Output
    +[null, 4, 0, 2]
    +
    +Explanation
    +Solution solution = new Solution([1, 2, 3, 3, 3]);
    +solution.pick(3); // It should return either index 2, 3, or 4 randomly. Each index should have equal probability of returning.
    +solution.pick(1); // It should return 0. Since in the array only nums[0] is equal to 1.
    +solution.pick(3); // It should return either index 2, 3, or 4 randomly. Each index should have equal probability of returning.
    +
    -// pick(3) should return either index 2, 3, or 4 randomly. Each index should have equal probability of returning. -solution.pick(3); +

     

    +

    Constraints:

    -// pick(1) should return 0. Since in the array only nums[0] is equal to 1. -solution.pick(1); -
    +
      +
    • 1 <= nums.length <= 2 * 104
    • +
    • -231 <= nums[i] <= 231 - 1
    • +
    • target is an integer from nums.
    • +
    • At most 104 calls will be made to pick.
    • +
    ### Related Topics [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] diff --git a/problems/reconstruct-original-digits-from-english/README.md b/problems/reconstruct-original-digits-from-english/README.md index f4f520891..55fe8967e 100644 --- a/problems/reconstruct-original-digits-from-english/README.md +++ b/problems/reconstruct-original-digits-from-english/README.md @@ -11,31 +11,24 @@ ## [423. Reconstruct Original Digits from English (Medium)](https://leetcode.com/problems/reconstruct-original-digits-from-english "从英文中重建数字") -

    Given a non-empty string containing an out-of-order English representation of digits 0-9, output the digits in ascending order.

    - -

    Note:
    -

      -
    1. Input contains only lowercase English letters.
    2. -
    3. Input is guaranteed to be valid and can be transformed to its original digits. That means invalid inputs such as "abc" or "zerone" are not permitted.
    4. -
    5. Input length is less than 50,000.
    6. -
    -

    - -

    Example 1:
    -

    -Input: "owoztneoer"
    -
    -Output: "012"
    -
    -

    - -

    Example 2:
    -

    -Input: "fviefuro"
    -
    -Output: "45"
    +

    Given a string s containing an out-of-order English representation of digits 0-9, return the digits in ascending order.

    + +

     

    +

    Example 1:

    +
    Input: s = "owoztneoer"
    +Output: "012"
    +

    Example 2:

    +
    Input: s = "fviefuro"
    +Output: "45"
     
    -

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 105
    • +
    • s[i] is one of the characters ["e","g","f","i","h","o","n","s","r","u","t","w","v","x","z"].
    • +
    • s is guaranteed to be valid.
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/remove-duplicates-from-sorted-array-ii/README.md b/problems/remove-duplicates-from-sorted-array-ii/README.md index a6766e6c0..23a6ccc22 100644 --- a/problems/remove-duplicates-from-sorted-array-ii/README.md +++ b/problems/remove-duplicates-from-sorted-array-ii/README.md @@ -9,7 +9,7 @@                  [Next >](../search-in-rotated-sorted-array-ii "Search in Rotated Sorted Array II") -## [80. Remove Duplicates from Sorted Array II (Medium)](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii "删除排序数组中的重复项 II") +## [80. Remove Duplicates from Sorted Array II (Medium)](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii "删除有序数组中的重复项 II")

    Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length.

    diff --git a/problems/reordered-power-of-2/README.md b/problems/reordered-power-of-2/README.md index b3ff34da4..dcc0530d1 100644 --- a/problems/reordered-power-of-2/README.md +++ b/problems/reordered-power-of-2/README.md @@ -11,67 +11,52 @@ ## [869. Reordered Power of 2 (Medium)](https://leetcode.com/problems/reordered-power-of-2 "重新排序得到 2 的幂") -

    Starting with a positive integer N, we reorder the digits in any order (including the original order) such that the leading digit is not zero.

    +

    You are given an integer n. We reorder the digits in any order (including the original order) such that the leading digit is not zero.

    -

    Return true if and only if we can do this in a way such that the resulting number is a power of 2.

    +

    Return true if and only if we can do this so that the resulting number is a power of two.

     

    - -
      -
    - -

    Example 1:

    -Input: 1
    -Output: true
    +Input: n = 1
    +Output: true
     
    -

    Example 2:

    -Input: 10
    -Output: false
    +Input: n = 10
    +Output: false
     
    -

    Example 3:

    -Input: 16
    -Output: true
    +Input: n = 16
    +Output: true
     
    -

    Example 4:

    -Input: 24
    -Output: false
    +Input: n = 24
    +Output: false
     
    -

    Example 5:

    -Input: 46
    -Output: true
    +Input: n = 46
    +Output: true
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= N <= 10^9
    2. -
    -
    -
    -
    -
    -
    +
      +
    • 1 <= n <= 109
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/reverse-vowels-of-a-string/README.md b/problems/reverse-vowels-of-a-string/README.md index 0c017d48e..415304e24 100644 --- a/problems/reverse-vowels-of-a-string/README.md +++ b/problems/reverse-vowels-of-a-string/README.md @@ -11,27 +11,25 @@ ## [345. Reverse Vowels of a String (Easy)](https://leetcode.com/problems/reverse-vowels-of-a-string "反转字符串中的元音字母") -

    Write a function that takes a string as input and reverse only the vowels of a string.

    +

    Given a string s, reverse only all the vowels in the string and return it.

    -

    Example 1:

    +

    The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both cases.

    -
    -Input: "hello"
    -Output: "holle"
    +

     

    +

    Example 1:

    +
    Input: s = "hello"
    +Output: "holle"
    +

    Example 2:

    +
    Input: s = "leetcode"
    +Output: "leotcede"
     
    - -
    -

    Example 2:

    - -
    -Input: "leetcode"
    -Output: "leotcede"
    -
    - -

    Note:
    -The vowels does not include the letter "y".

    -

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 3 * 105
    • +
    • s consist of printable ASCII characters.
    • +
    ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/rotate-array/README.md b/problems/rotate-array/README.md index 5a5bb930d..e7fe7cf82 100644 --- a/problems/rotate-array/README.md +++ b/problems/rotate-array/README.md @@ -11,14 +11,7 @@ ## [189. Rotate Array (Medium)](https://leetcode.com/problems/rotate-array "旋转数组") -

    Given an array, rotate the array to the right by k steps, where k is non-negative.

    - -

    Follow up:

    - -
      -
    • Try to come up as many solutions as you can, there are at least 3 different ways to solve this problem.
    • -
    • Could you do it in-place with O(1) extra space?
    • -
    +

    Given an array, rotate the array to the right by k steps, where k is non-negative.

     

    Example 1:

    @@ -51,6 +44,14 @@ rotate 2 steps to the right: [3,99,-1,-100]
  • 0 <= k <= 105
  • +

     

    +

    Follow up:

    + +
      +
    • Try to come up with as many solutions as you can. There are at least three different ways to solve this problem.
    • +
    • Could you do it in-place with O(1) extra space?
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/rotate-function/README.md b/problems/rotate-function/README.md index e17bd15ca..682e2d0d2 100644 --- a/problems/rotate-function/README.md +++ b/problems/rotate-function/README.md @@ -11,36 +11,45 @@ ## [396. Rotate Function (Medium)](https://leetcode.com/problems/rotate-function "旋转函数") -

    -Given an array of integers A and let n to be its length. -

    +

    You are given an integer array nums of length n.

    -

    -Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we define a "rotation function" F on A as follow: -

    +

    Assume arrk to be an array obtained by rotating nums by k positions clock-wise. We define the rotation function F on nums as follow:

    -

    -F(k) = 0 * Bk[0] + 1 * Bk[1] + ... + (n-1) * Bk[n-1].

    +
      +
    • F(k) = 0 * arrk[0] + 1 * arrk[1] + ... + (n - 1) * arrk[n - 1].
    • +
    -

    Calculate the maximum value of F(0), F(1), ..., F(n-1). -

    +

    Return the maximum value of F(0), F(1), ..., F(n-1).

    -

    Note:
    -n is guaranteed to be less than 105. -

    +

     

    +

    Example 1:

    -

    Example:

    -A = [4, 3, 2, 6]
    -
    +Input: nums = [4,3,2,6]
    +Output: 26
    +Explanation:
     F(0) = (0 * 4) + (1 * 3) + (2 * 2) + (3 * 6) = 0 + 3 + 4 + 18 = 25
     F(1) = (0 * 6) + (1 * 4) + (2 * 3) + (3 * 2) = 0 + 4 + 6 + 6 = 16
     F(2) = (0 * 2) + (1 * 6) + (2 * 4) + (3 * 3) = 0 + 6 + 8 + 9 = 23
     F(3) = (0 * 3) + (1 * 2) + (2 * 6) + (3 * 4) = 0 + 2 + 12 + 12 = 26
    -
     So the maximum value of F(0), F(1), F(2), F(3) is F(3) = 26.
     
    -

    + +

    Example 2:

    + +
    +Input: nums = [1000000007]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= n <= 105
    • +
    • -231 <= nums[i] <= 231 - 1
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/russian-doll-envelopes/README.md b/problems/russian-doll-envelopes/README.md index f2d04ee88..6d74114b1 100644 --- a/problems/russian-doll-envelopes/README.md +++ b/problems/russian-doll-envelopes/README.md @@ -13,9 +13,9 @@

    You are given a 2D array of integers envelopes where envelopes[i] = [wi, hi] represents the width and the height of an envelope.

    -

    One envelope can fit into another if and only if both the width and height of one envelope is greater than the width and height of the other envelope.

    +

    One envelope can fit into another if and only if both the width and height of one envelope are greater than the other envelope's width and height.

    -

    Return the maximum number of envelopes can you Russian doll (i.e., put one inside the other).

    +

    Return the maximum number of envelopes you can Russian doll (i.e., put one inside the other).

    Note: You cannot rotate an envelope.

    diff --git a/problems/sentence-similarity-iii/README.md b/problems/sentence-similarity-iii/README.md new file mode 100644 index 000000000..c31a6332f --- /dev/null +++ b/problems/sentence-similarity-iii/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../determine-color-of-a-chessboard-square "Determine Color of a Chessboard Square") +                 +[Next >](../count-nice-pairs-in-an-array "Count Nice Pairs in an Array") + +## [1813. Sentence Similarity III (Medium)](https://leetcode.com/problems/sentence-similarity-iii "句子相似性 III") + +

    A sentence is a list of words that are separated by a single space with no leading or trailing spaces. For example, "Hello World", "HELLO", "hello world hello world" are all sentences. Words consist of only uppercase and lowercase English letters.

    + +

    Two sentences sentence1 and sentence2 are similar if it is possible to insert an arbitrary sentence (possibly empty) inside one of these sentences such that the two sentences become equal. For example, sentence1 = "Hello my name is Jane" and sentence2 = "Hello Jane" can be made equal by inserting "my name is" between "Hello" and "Jane" in sentence2.

    + +

    Given two sentences sentence1 and sentence2, return true if sentence1 and sentence2 are similar. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: sentence1 = "My name is Haley", sentence2 = "My Haley"
    +Output: true
    +Explanation: sentence2 can be turned to sentence1 by inserting "name is" between "My" and "Haley".
    +
    + +

    Example 2:

    + +
    +Input: sentence1 = "of", sentence2 = "A lot of words"
    +Output: false
    +Explanation: No single sentence can be inserted inside one of the sentences to make it equal to the other.
    +
    + +

    Example 3:

    + +
    +Input: sentence1 = "Eating right now", sentence2 = "Eating"
    +Output: true
    +Explanation: sentence2 can be turned to sentence1 by inserting "right now" at the end of the sentence.
    +
    + +

    Example 4:

    + +
    +Input: sentence1 = "Luky", sentence2 = "Lucccky"
    +Output: false
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= sentence1.length, sentence2.length <= 100
    • +
    • sentence1 and sentence2 consist of lowercase and uppercase English letters and spaces.
    • +
    • The words in sentence1 and sentence2 are separated by a single space.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +One way to look at it is to find one sentence as a concatenation of a prefix and suffix from the other sentence. +
    + +
    +Hint 2 +Get the longest common prefix between them and the longest common suffix. +
    diff --git a/problems/truncate-sentence/README.md b/problems/truncate-sentence/README.md new file mode 100644 index 000000000..facb980f3 --- /dev/null +++ b/problems/truncate-sentence/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../maximum-number-of-groups-getting-fresh-donuts "Maximum Number of Groups Getting Fresh Donuts") +                 +[Next >](../finding-the-users-active-minutes "Finding the Users Active Minutes") + +## [1816. Truncate Sentence (Easy)](https://leetcode.com/problems/truncate-sentence "截断句子") + +

    A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each of the words consists of only uppercase and lowercase English letters (no punctuation).

    + +
      +
    • For example, "Hello World", "HELLO", and "hello world hello world" are all sentences.
    • +
    + +

    You are given a sentence s​​​​​​ and an integer k​​​​​​. You want to truncate s​​​​​​ such that it contains only the first k​​​​​​ words. Return s​​​​​​ after truncating it.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "Hello how are you Contestant", k = 4
    +Output: "Hello how are you"
    +Explanation:
    +The words in s are ["Hello", "how" "are", "you", "Contestant"].
    +The first 4 words are ["Hello", "how", "are", "you"].
    +Hence, you should return "Hello how are you".
    +
    + +

    Example 2:

    + +
    +Input: s = "What is the solution to this problem", k = 4
    +Output: "What is the solution"
    +Explanation:
    +The words in s are ["What", "is" "the", "solution", "to", "this", "problem"].
    +The first 4 words are ["What", "is", "the", "solution"].
    +Hence, you should return "What is the solution".
    + +

    Example 3:

    + +
    +Input: s = "chopper is not a tanuki", k = 5
    +Output: "chopper is not a tanuki"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 500
    • +
    • k is in the range [1, the number of words in s].
    • +
    • s consist of only lowercase and uppercase English letters and spaces.
    • +
    • The words in s are separated by a single space.
    • +
    • There are no leading or trailing spaces.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +It's easier to solve this problem on an array of strings so parse the string to an array of words +
    + +
    +Hint 2 +After return the first k words as a sentence +
    diff --git a/problems/tweet-counts-per-frequency/README.md b/problems/tweet-counts-per-frequency/README.md index 5c1992a42..6fbe1b6ba 100644 --- a/problems/tweet-counts-per-frequency/README.md +++ b/problems/tweet-counts-per-frequency/README.md @@ -11,20 +11,30 @@ ## [1348. Tweet Counts Per Frequency (Medium)](https://leetcode.com/problems/tweet-counts-per-frequency "推文计数") -

    Implement the class TweetCounts that supports two methods:

    +

    A social media company is trying to monitor activity on their site by analyzing the number of tweets that occur in select periods of time. These periods can be partitioned into smaller time chunks based on a certain frequency (every minute, hour, or day).

    -

    1. recordTweet(string tweetName, int time)

    +

    For example, the period [10, 10000] (in seconds) would be partitioned into the following time chunks with these frequencies:

      -
    • Stores the tweetName at the recorded time (in seconds).
    • +
    • Every minute (60-second chunks): [10,69], [70,129], [130,189], ..., [9970,10000]
    • +
    • Every hour (3600-second chunks): [10,3609], [3610,7209], [7210,10000]
    • +
    • Every day (86400-second chunks): [10,10000]
    -

    2. getTweetCountsPerFrequency(string freq, string tweetName, int startTime, int endTime)

    +

    Notice that the last chunk may be shorter than the specified frequency's chunk size and will always end with the end time of the period (10000 in the above example).

    + +

    Design and implement an API to help the company with their analysis.

    + +

    Implement the TweetCounts class:

      -
    • Returns the total number of occurrences for the given tweetName per minute, hour, or day (depending on freq) starting from the startTime (in seconds) and ending at the endTime (in seconds).
    • -
    • freq is always minute, hour or day, representing the time interval to get the total number of occurrences for the given tweetName.
    • -
    • The first time interval always starts from the startTime, so the time intervals are [startTime, startTime + delta*1>,  [startTime + delta*1, startTime + delta*2>, [startTime + delta*2, startTime + delta*3>, ... , [startTime + delta*i, min(startTime + delta*(i+1), endTime + 1)> for some non-negative number i and delta (which depends on freq).  
    • +
    • TweetCounts() Initializes the TweetCounts object.
    • +
    • void recordTweet(String tweetName, int time) Stores the tweetName at the recorded time (in seconds).
    • +
    • List<Integer> getTweetCountsPerFrequency(String freq, String tweetName, int startTime, int endTime) Returns a list of integers representing the number of tweets with tweetName in each time chunk for the given period of time [startTime, endTime] (in seconds) and frequency freq. +
        +
      • freq is one of "minute", "hour", or "day" representing a frequency of every minute, hour, or day respectively.
      • +
      +

     

    @@ -40,22 +50,22 @@ Explanation TweetCounts tweetCounts = new TweetCounts(); -tweetCounts.recordTweet("tweet3", 0); -tweetCounts.recordTweet("tweet3", 60); -tweetCounts.recordTweet("tweet3", 10); // All tweets correspond to "tweet3" with recorded times at 0, 10 and 60. -tweetCounts.getTweetCountsPerFrequency("minute", "tweet3", 0, 59); // return [2]. The frequency is per minute (60 seconds), so there is one interval of time: 1) [0, 60> - > 2 tweets. -tweetCounts.getTweetCountsPerFrequency("minute", "tweet3", 0, 60); // return [2, 1]. The frequency is per minute (60 seconds), so there are two intervals of time: 1) [0, 60> - > 2 tweets, and 2) [60,61> - > 1 tweet. -tweetCounts.recordTweet("tweet3", 120); // All tweets correspond to "tweet3" with recorded times at 0, 10, 60 and 120. -tweetCounts.getTweetCountsPerFrequency("hour", "tweet3", 0, 210); // return [4]. The frequency is per hour (3600 seconds), so there is one interval of time: 1) [0, 211> - > 4 tweets. +tweetCounts.recordTweet("tweet3", 0); // New tweet "tweet3" at time 0 +tweetCounts.recordTweet("tweet3", 60); // New tweet "tweet3" at time 60 +tweetCounts.recordTweet("tweet3", 10); // New tweet "tweet3" at time 10 +tweetCounts.getTweetCountsPerFrequency("minute", "tweet3", 0, 59); // return [2]; chunk [0,59] had 2 tweets +tweetCounts.getTweetCountsPerFrequency("minute", "tweet3", 0, 60); // return [2,1]; chunk [0,59] had 2 tweets, chunk [60,60] had 1 tweet +tweetCounts.recordTweet("tweet3", 120); // New tweet "tweet3" at time 120 +tweetCounts.getTweetCountsPerFrequency("hour", "tweet3", 0, 210); // return [4]; chunk [0,210] had 4 tweets

     

    Constraints:

      -
    • There will be at most 10000 operations considering both recordTweet and getTweetCountsPerFrequency.
    • -
    • 0 <= time, startTime, endTime <= 10^9
    • -
    • 0 <= endTime - startTime <= 10^4
    • +
    • 0 <= time, startTime, endTime <= 109
    • +
    • 0 <= endTime - startTime <= 104
    • +
    • There will be at most 104 calls in total to recordTweet and getTweetCountsPerFrequency.
    ### Related Topics diff --git a/problems/utf-8-validation/README.md b/problems/utf-8-validation/README.md index d02dcde1e..2f1d30269 100644 --- a/problems/utf-8-validation/README.md +++ b/problems/utf-8-validation/README.md @@ -11,50 +11,57 @@ ## [393. UTF-8 Validation (Medium)](https://leetcode.com/problems/utf-8-validation "UTF-8 编码验证") -

    A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules:

    +

    Given an integer array data representing the data, return whether it is a valid UTF-8 encoding.

    + +

    A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules:

    +
      -
    1. For 1-byte character, the first bit is a 0, followed by its unicode code.
    2. -
    3. For n-bytes character, the first n-bits are all one's, the n+1 bit is 0, followed by n-1 bytes with most significant 2 bits being 10.
    4. +
    5. For a 1-byte character, the first bit is a 0, followed by its Unicode code.
    6. +
    7. For an n-bytes character, the first n bits are all one's, the n + 1 bit is 0, followed by n - 1 bytes with the most significant 2 bits being 10.
    +

    This is how the UTF-8 encoding would work:

    -
       Char. number range  |        UTF-8 octet sequence
    +
    +   Char. number range  |        UTF-8 octet sequence
           (hexadecimal)    |              (binary)
        --------------------+---------------------------------------------
        0000 0000-0000 007F | 0xxxxxxx
        0000 0080-0000 07FF | 110xxxxx 10xxxxxx
        0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
    -   0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
    -
    -

    -Given an array of integers representing the data, return whether it is a valid utf-8 encoding. -

    -

    -Note:
    -The input is an array of integers. Only the least significant 8 bits of each integer is used to store the data. This means each integer represents only 1 byte of data. -

    - -

    -Example 1: -

    -data = [197, 130, 1], which represents the octet sequence: 11000101 10000010 00000001.
    +   0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
    +
    + +

    Note: The input is an array of integers. Only the least significant 8 bits of each integer is used to store the data. This means each integer represents only 1 byte of data.

    -Return true. +

     

    +

    Example 1:

    + +
    +Input: data = [197,130,1]
    +Output: true
    +Explanation: data represents the octet sequence: 11000101 10000010 00000001.
     It is a valid utf-8 encoding for a 2-bytes character followed by a 1-byte character.
     
    -

    -

    -Example 2: -

    -data = [235, 140, 4], which represented the octet sequence: 11101011 10001100 00000100.
    +

    Example 2:

    -Return false. -The first 3 bits are all one's and the 4th bit is 0 means it is a 3-bytes character. -The next byte is a continuation byte which starts with 10 and that's correct. +
    +Input: data = [235,140,4]
    +Output: false
    +Explanation: data represented the octet sequence: 11101011 10001100 00000100.
    +The first 3 bits are all one's and the 4th bit is 0 means it is a 3-bytes character.
    +The next byte is a continuation byte which starts with 10 and that's correct.
     But the second continuation byte does not start with 10, so it is invalid.
     
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= data.length <= 2 * 104
    • +
    • 0 <= data[i] <= 255
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/vowel-spellchecker/README.md b/problems/vowel-spellchecker/README.md index fd93b6fab..c8dc8baa3 100644 --- a/problems/vowel-spellchecker/README.md +++ b/problems/vowel-spellchecker/README.md @@ -11,7 +11,7 @@ ## [966. Vowel Spellchecker (Medium)](https://leetcode.com/problems/vowel-spellchecker "元音拼写检查器") -

    Given a wordlist, we want to implement a spellchecker that converts a query word into a correct word.

    +

    Given a wordlist, we want to implement a spellchecker that converts a query word into a correct word.

    For a given query word, the spell checker handles two categories of spelling mistakes:

    @@ -23,7 +23,7 @@
  • Example: wordlist = ["yellow"], query = "yellow": correct = "yellow"
  • -
  • Vowel Errors: If after replacing the vowels ('a', 'e', 'i', 'o', 'u') of the query word with any vowel individually, it matches a word in the wordlist (case-insensitive), then the query word is returned with the same case as the match in the wordlist. +
  • Vowel Errors: If after replacing the vowels ('a', 'e', 'i', 'o', 'u') of the query word with any vowel individually, it matches a word in the wordlist (case-insensitive), then the query word is returned with the same case as the match in the wordlist.
    • Example: wordlist = ["YellOw"], query = "yollow": correct = "YellOw"
    • Example: wordlist = ["YellOw"], query = "yeellow": correct = "" (no match)
    • @@ -41,26 +41,23 @@
    • If the query has no matches in the wordlist, you should return the empty string.
    -

    Given some queries, return a list of words answer, where answer[i] is the correct word for query = queries[i].

    +

    Given some queries, return a list of words answer, where answer[i] is the correct word for query = queries[i].

     

    -

    Example 1:

    - -
    -Input: wordlist = ["KiTe","kite","hare","Hare"], queries = ["kite","Kite","KiTe","Hare","HARE","Hear","hear","keti","keet","keto"]
    -Output: ["kite","KiTe","KiTe","Hare","hare","","","KiTe","","KiTe"]
    - +
    Input: wordlist = ["KiTe","kite","hare","Hare"], queries = ["kite","Kite","KiTe","Hare","HARE","Hear","hear","keti","keet","keto"]
    +Output: ["kite","KiTe","KiTe","Hare","hare","","","KiTe","","KiTe"]
    +

    Example 2:

    +
    Input: wordlist = ["yellow"], queries = ["YellOw"]
    +Output: ["yellow"]
    +

     

    - -

    Note:

    +

    Constraints:

      -
    • 1 <= wordlist.length <= 5000
    • -
    • 1 <= queries.length <= 5000
    • -
    • 1 <= wordlist[i].length <= 7
    • -
    • 1 <= queries[i].length <= 7
    • -
    • All strings in wordlist and queries consist only of english letters.
    • +
    • 1 <= wordlist.length, queries.length <= 5000
    • +
    • 1 <= wordlist[i].length, queries[i].length <= 7
    • +
    • wordlist[i] and queries[i] consist only of only English letters.
    ### Related Topics diff --git a/problems/water-and-jug-problem/README.md b/problems/water-and-jug-problem/README.md index f9ace2243..502c16158 100644 --- a/problems/water-and-jug-problem/README.md +++ b/problems/water-and-jug-problem/README.md @@ -11,38 +11,46 @@ ## [365. Water and Jug Problem (Medium)](https://leetcode.com/problems/water-and-jug-problem "水壶问题") -

    You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to measure exactly z litres using these two jugs.

    +

    You are given two jugs with capacities jug1Capacity and jug2Capacity liters. There is an infinite amount of water supply available. Determine whether it is possible to measure exactly targetCapacity liters using these two jugs.

    -

    If z liters of water is measurable, you must have z liters of water contained within one or both buckets by the end.

    +

    If targetCapacity liters of water are measurable, you must have targetCapacity liters of water contained within one or both buckets by the end.

    Operations allowed:

      -
    • Fill any of the jugs completely with water.
    • +
    • Fill any of the jugs with water.
    • Empty any of the jugs.
    • -
    • Pour water from one jug into another till the other jug is completely full or the first jug itself is empty.
    • +
    • Pour water from one jug into another till the other jug is completely full, or the first jug itself is empty.
    -

    Example 1: (From the famous "Die Hard" example)

    +

     

    +

    Example 1:

    + +
    +Input: jug1Capacity = 3, jug2Capacity = 5, targetCapacity = 4
    +Output: true
    +Explanation: The famous Die Hard example 
    +
    + +

    Example 2:

    -Input: x = 3, y = 5, z = 4
    -Output: True
    +Input: jug1Capacity = 2, jug2Capacity = 6, targetCapacity = 5
    +Output: false
     
    -

    Example 2:

    +

    Example 3:

    -Input: x = 2, y = 6, z = 5
    -Output: False
    +Input: jug1Capacity = 1, jug2Capacity = 2, targetCapacity = 3
    +Output: true
     
    +

     

    Constraints:

      -
    • 0 <= x <= 10^6
    • -
    • 0 <= y <= 10^6
    • -
    • 0 <= z <= 10^6
    • +
    • 1 <= jug1Capacity, jug2Capacity, targetCapacity <= 106
    ### Related Topics diff --git a/problems/wiggle-subsequence/README.md b/problems/wiggle-subsequence/README.md index 73fab926b..6a744d8d1 100644 --- a/problems/wiggle-subsequence/README.md +++ b/problems/wiggle-subsequence/README.md @@ -11,16 +11,16 @@ ## [376. Wiggle Subsequence (Medium)](https://leetcode.com/problems/wiggle-subsequence "摆动序列") -

    Given an integer array nums, return the length of the longest wiggle sequence.

    - -

    A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a wiggle sequence.

    +

    A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with two or fewer elements is trivially a wiggle sequence.

      -
    • For example, [1, 7, 4, 9, 2, 5] is a wiggle sequence because the differences (6, -3, 5, -7, 3) are alternately positive and negative.
    • -
    • In contrast, [1, 4, 7, 2, 5] and [1, 7, 4, 5, 5] are not wiggle sequences, the first because its first two differences are positive and the second because its last difference is zero.
    • +
    • For example, [1, 7, 4, 9, 2, 5] is a wiggle sequence because the differences (6, -3, 5, -7, 3) alternate between positive and negative.
    • +
    • In contrast, [1, 4, 7, 2, 5] and [1, 7, 4, 5, 5] are not wiggle sequences. The first is not because its first two differences are positive, and the second is not because its last difference is zero.
    -

    A subsequence is obtained by deleting some elements (eventually, also zero) from the original sequence, leaving the remaining elements in their original order.

    +

    A subsequence is obtained by deleting some elements (possibly zero) from the original sequence, leaving the remaining elements in their original order.

    + +

    Given an integer array nums, return the length of the longest wiggle subsequence of nums.

     

    Example 1:

    @@ -28,7 +28,7 @@
     Input: nums = [1,7,4,9,2,5]
     Output: 6
    -Explanation: The entire sequence is a wiggle sequence.
    +Explanation: The entire sequence is a wiggle sequence with differences (6, -3, 5, -7, 3).
     

    Example 2:

    @@ -36,7 +36,8 @@
     Input: nums = [1,17,5,10,13,15,10,5,16,8]
     Output: 7
    -Explanation: There are several subsequences that achieve this length. One is [1,17,10,13,10,16,8].
    +Explanation: There are several subsequences that achieve this length.
    +One is [1, 17, 10, 13, 10, 16, 8] with differences (16, -7, 3, -3, 6, -8).
     

    Example 3:

    diff --git a/problems/word-search/README.md b/problems/word-search/README.md index 7d0419bff..5435a6bf0 100644 --- a/problems/word-search/README.md +++ b/problems/word-search/README.md @@ -15,8 +15,6 @@

    The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once.

    -

    Note: There will be some test cases with a board or a word larger than constraints to test if your solution is using pruning.

    -

     

    Example 1:

    @@ -50,6 +48,9 @@
  • board and word consists of only lowercase and uppercase English letters.
  • +

     

    +

    Follow up: Could you use search pruning to make your solution faster with a larger board?

    + ### Related Topics [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] diff --git a/readme/1-300.md b/readme/1-300.md index c557a377e..441dc0d20 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -157,7 +157,7 @@ LeetCode Problems' Solutions | 77 | [Combinations](https://leetcode.com/problems/combinations "组合") | [Go](../problems/combinations) | Medium | | 78 | [Subsets](https://leetcode.com/problems/subsets "子集") | [Go](../problems/subsets) | Medium | | 79 | [Word Search](https://leetcode.com/problems/word-search "单词搜索") | [Go](../problems/word-search) | Medium | -| 80 | [Remove Duplicates from Sorted Array II](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii "删除排序数组中的重复项 II") | [Go](../problems/remove-duplicates-from-sorted-array-ii) | Medium | +| 80 | [Remove Duplicates from Sorted Array II](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii "删除有序数组中的重复项 II") | [Go](../problems/remove-duplicates-from-sorted-array-ii) | Medium | | 81 | [Search in Rotated Sorted Array II](https://leetcode.com/problems/search-in-rotated-sorted-array-ii "搜索旋转排序数组 II") | [Go](../problems/search-in-rotated-sorted-array-ii) | Medium | | 82 | [Remove Duplicates from Sorted List II](https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii "删除排序链表中的重复元素 II") | [Go](../problems/remove-duplicates-from-sorted-list-ii) | Medium | | 83 | [Remove Duplicates from Sorted List](https://leetcode.com/problems/remove-duplicates-from-sorted-list "删除排序链表中的重复元素") | [Go](../problems/remove-duplicates-from-sorted-list) | Easy | @@ -174,7 +174,7 @@ LeetCode Problems' Solutions | 94 | [Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal "二叉树的中序遍历") | [Go](../problems/binary-tree-inorder-traversal) | Medium | | 95 | [Unique Binary Search Trees II](https://leetcode.com/problems/unique-binary-search-trees-ii "不同的二叉搜索树 II") | [Go](../problems/unique-binary-search-trees-ii) | Medium | | 96 | [Unique Binary Search Trees](https://leetcode.com/problems/unique-binary-search-trees "不同的二叉搜索树") | [Go](../problems/unique-binary-search-trees) | Medium | -| 97 | [Interleaving String](https://leetcode.com/problems/interleaving-string "交错字符串") | [Go](../problems/interleaving-string) | Hard | +| 97 | [Interleaving String](https://leetcode.com/problems/interleaving-string "交错字符串") | [Go](../problems/interleaving-string) | Medium | | 98 | [Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree "验证二叉搜索树") | [Go](../problems/validate-binary-search-tree) | Medium | | 99 | [Recover Binary Search Tree](https://leetcode.com/problems/recover-binary-search-tree "恢复二叉搜索树") | [Go](../problems/recover-binary-search-tree) | Hard | | 100 | [Same Tree](https://leetcode.com/problems/same-tree "相同的树") | [Go](../problems/same-tree) | Easy | diff --git a/readme/301-600.md b/readme/301-600.md index b8b6014d0..f0d313bb3 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -233,7 +233,7 @@ LeetCode Problems' Solutions | 453 | [Minimum Moves to Equal Array Elements](https://leetcode.com/problems/minimum-moves-to-equal-array-elements "最小操作次数使数组元素相等") | [Go](../problems/minimum-moves-to-equal-array-elements) | Easy | | 454 | [4Sum II](https://leetcode.com/problems/4sum-ii "四数相加 II") | [Go](../problems/4sum-ii) | Medium | | 455 | [Assign Cookies](https://leetcode.com/problems/assign-cookies "分发饼干") | [Go](../problems/assign-cookies) | Easy | -| 456 | [132 Pattern](https://leetcode.com/problems/132-pattern "132模式") | [Go](../problems/132-pattern) | Medium | +| 456 | [132 Pattern](https://leetcode.com/problems/132-pattern "132 模式") | [Go](../problems/132-pattern) | Medium | | 457 | [Circular Array Loop](https://leetcode.com/problems/circular-array-loop "环形数组是否存在循环") | [Go](../problems/circular-array-loop) | Medium | | 458 | [Poor Pigs](https://leetcode.com/problems/poor-pigs "可怜的小猪") | [Go](../problems/poor-pigs) | Hard | | 459 | [Repeated Substring Pattern](https://leetcode.com/problems/repeated-substring-pattern "重复的子字符串") | [Go](../problems/repeated-substring-pattern) | Easy | diff --git a/tag/README.md b/tag/README.md index c51022ce6..154ccffc3 100644 --- a/tag/README.md +++ b/tag/README.md @@ -16,11 +16,11 @@ | 9 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | | 11 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | -| 15 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | -| 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | +| 15 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 16 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | +| 17 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 18 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 19 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | | 20 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | | 21 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | | 22 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | -| 23 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | | 24 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | +| 23 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | | 25 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | | 27 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | | 29 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | diff --git a/tag/array/README.md b/tag/array/README.md index 6917adf62..598d964a1 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1814 | [统计一个数组中好对子的数目](../../problems/count-nice-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1806 | [还原排列的最少操作步数](../../problems/minimum-number-of-operations-to-reinitialize-a-permutation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1779 | [找到最近的有相同 X 或 Y 坐标的点](../../problems/find-nearest-point-that-has-the-same-x-or-y-coordinate) | [[数组](../array/README.md)] | Easy | | 1773 | [统计匹配检索规则的物品数量](../../problems/count-items-matching-a-rule) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 1769 | [移动所有球到每个盒子所需的最小操作数](../../problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | @@ -287,7 +289,7 @@ | 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 84 | [柱状图中最大的矩形](../../problems/largest-rectangle-in-histogram) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Hard | | 81 | [搜索旋转排序数组 II](../../problems/search-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 80 | [删除排序数组中的重复项 II](../../problems/remove-duplicates-from-sorted-array-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 80 | [删除有序数组中的重复项 II](../../problems/remove-duplicates-from-sorted-array-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 79 | [单词搜索](../../problems/word-search) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index bb86afc6e..981cc07af 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1802 | [有界数组中指定下标处的最大值](../../problems/maximum-value-at-a-given-index-in-a-bounded-array) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1760 | [袋子里最少数目的球](../../problems/minimum-limit-of-balls-in-a-bag) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1751 | [最多可以参加的会议数目 II](../../problems/maximum-number-of-events-that-can-be-attended-ii) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 3f0ef6a26..ab6bf917e 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | | 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index 7af1d3fff..14091cf0c 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,64 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1797 | [设计一个验证系统](../../problems/design-authentication-manager) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | -| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Easy | -| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard | -| 1603 | [设计停车系统](../../problems/design-parking-system) | [[设计](../design/README.md)] | Easy | -| 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | -| 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[设计](../design/README.md)] | Medium | -| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] | Medium | -| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | -| 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] | Medium | -| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | -| 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] | Medium | -| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1206 | [设计跳表](../../problems/design-skiplist) | [[设计](../design/README.md)] | Hard | -| 1172 | [餐盘栈](../../problems/dinner-plate-stacks) | [[设计](../design/README.md)] | Hard | -| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 716 | [最大栈](../../problems/max-stack) 🔒 | [[设计](../design/README.md)] | Easy | -| 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy | -| 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Hard | -| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | -| 631 | [设计 Excel 求和公式](../../problems/design-excel-sum-formula) 🔒 | [[设计](../design/README.md)] | Hard | -| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] | Easy | -| 588 | [设计内存文件系统](../../problems/design-in-memory-file-system) 🔒 | [[设计](../design/README.md)] | Hard | -| 460 | [LFU 缓存](../../problems/lfu-cache) | [[设计](../design/README.md)] | Hard | -| 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] | Hard | -| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 362 | [敲击计数器](../../problems/design-hit-counter) 🔒 | [[设计](../design/README.md)] | Medium | -| 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 348 | [设计井字棋](../../problems/design-tic-tac-toe) 🔒 | [[设计](../design/README.md)] | Medium | -| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | -| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | -| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard | -| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard | -| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] | Medium | -| 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] | Medium | -| 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] | Medium | -| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium | -| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 785185547..0956b9622 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1815 | [得到新鲜甜甜圈的最多组数](../../problems/maximum-number-of-groups-getting-fresh-donuts) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1787 | [使所有区间的异或结果为零](../../problems/make-the-xor-of-all-segments-equal-to-zero) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -244,7 +245,7 @@ | 121 | [买卖股票的最佳时机](../../problems/best-time-to-buy-and-sell-stock) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 120 | [三角形最小路径和](../../problems/triangle) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 115 | [不同的子序列](../../problems/distinct-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 91 | [解码方法](../../problems/decode-ways) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/graph/README.md b/tag/graph/README.md index 22929b33d..089e192cd 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1791 | [找出星型图的中心节点](../../problems/find-center-of-star-graph) | [[图](../graph/README.md)] | Medium | | 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1782 | [统计点对的数目](../../problems/count-pairs-of-nodes) | [[图](../graph/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index d7f88e58d..23e2e9822 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1806 | [还原排列的最少操作步数](../../problems/minimum-number-of-operations-to-reinitialize-a-permutation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1802 | [有界数组中指定下标处的最大值](../../problems/maximum-value-at-a-given-index-in-a-bounded-array) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | | 1798 | [你能构造出连续值的最大数目](../../problems/maximum-number-of-consecutive-values-you-can-make) | [[贪心算法](../greedy/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index e059ec8c0..893f7a670 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1817 | [查找用户活跃分钟数](../../problems/finding-the-users-active-minutes) | [[哈希表](../hash-table/README.md)] | Medium | +| 1814 | [统计一个数组中好对子的数目](../../problems/count-nice-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1807 | [替换字符串中的括号内容](../../problems/evaluate-the-bracket-pairs-of-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1797 | [设计一个验证系统](../../problems/design-authentication-manager) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1781 | [所有子字符串美丽值之和](../../problems/sum-of-beauty-of-all-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1772 | [按受欢迎程度排列功能](../../problems/sort-features-by-popularity) 🔒 | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/heap/README.md b/tag/heap/README.md index a51615a33..39b134930 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -9,46 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 1792 | [最大平均通过率](../../problems/maximum-average-pass-ratio) | [[堆](../heap/README.md)] | Medium | -| 1760 | [袋子里最少数目的球](../../problems/minimum-limit-of-balls-in-a-bag) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1753 | [移除石子的最大得分](../../problems/maximum-score-from-removing-stones) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | -| 1705 | [吃苹果的最大数目](../../problems/maximum-number-of-eaten-apples) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | -| 1642 | [可以到达的最远建筑](../../problems/furthest-building-you-can-reach) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1439 | [有序矩阵中的第 k 个最小数组和](../../problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | [[堆](../heap/README.md)] | Hard | -| 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] | Medium | -| 1046 | [最后一块石头的重量](../../problems/last-stone-weight) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Easy | -| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 882 | [细分图中的可到达结点](../../problems/reachable-nodes-in-subdivided-graph) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 871 | [最低加油次数](../../problems/minimum-number-of-refueling-stops) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 864 | [获取所有钥匙的最短路径](../../problems/shortest-path-to-get-all-keys) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[堆](../heap/README.md)] | Hard | -| 818 | [赛车](../../problems/race-car) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | -| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy | -| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[堆](../heap/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 502 | [IPO](../../problems/ipo) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | -| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 373 | [查找和最小的K对数字](../../problems/find-k-pairs-with-smallest-sums) | [[堆](../heap/README.md)] | Medium | -| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 313 | [超级丑数](../../problems/super-ugly-number) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | -| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard | -| 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | -| 215 | [数组中的第K个最大元素](../../problems/kth-largest-element-in-an-array) | [[堆](../heap/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/math/README.md b/tag/math/README.md index 98b0edc3b..e0413d1ad 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数学](../math/README.md)] | Hard | +| 1808 | [好因子的最大数目](../../problems/maximize-number-of-nice-divisors) | [[数学](../math/README.md)] | Hard | | 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1776 | [车队 II](../../problems/car-fleet-ii) | [[数学](../math/README.md)] | Hard | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/memoization/README.md b/tag/memoization/README.md index 2c6a5dffd..f418d566c 100644 --- a/tag/memoization/README.md +++ b/tag/memoization/README.md @@ -9,4 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index 85faedb8e..52afd5989 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -9,17 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | -| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 855 | [考场就座](../../problems/exam-room) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 846 | [一手顺子](../../problems/hand-of-straights) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 731 | [我的日程安排表 II](../../problems/my-calendar-ii) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 683 | [K 个关闭的灯泡](../../problems/k-empty-slots) 🔒 | [[Ordered Map](../ordered-map/README.md)] | Hard | -| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index 0c9155aea..8922feba8 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -9,14 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | -| 933 | [最近的请求次数](../../problems/number-of-recent-calls) | [[队列](../queue/README.md)] | Easy | -| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | -| 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | -| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | -| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 1989c8da1..42f90d3a9 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -9,42 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[递归](../recursion/README.md)] | Easy | -| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[递归](../recursion/README.md)] | Medium | -| 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | -| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | -| 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | -| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | -| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Easy | -| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index b34d04e3d..bdf264168 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -9,19 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[线段树](../segment-tree/README.md)] | Hard | -| 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | -| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | -| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 308 | [二维区域和检索 - 可变](../../problems/range-sum-query-2d-mutable) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Hard | -| 307 | [区域和检索 - 数组可修改](../../problems/range-sum-query-mutable) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Medium | -| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index ee49220e1..fbbfc5182 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -9,30 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[排序](../sort/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1176 | [健身计划评估](../../problems/diet-plan-performance) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Easy | -| 1151 | [最少交换次数来组合所有的 1](../../problems/minimum-swaps-to-group-all-1s-together) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 1052 | [爱生气的书店老板](../../problems/grumpy-bookstore-owner) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1040 | [移动石子直到连续 II](../../problems/moving-stones-until-consecutive-ii) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[贪心算法](../greedy/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 480 | [滑动窗口中位数](../../problems/sliding-window-median) | [[Sliding Window](../sliding-window/README.md)] | Hard | -| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/stack/README.md b/tag/stack/README.md index 238b0b4da..e86c8bc67 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -47,7 +47,7 @@ | 591 | [标签验证器](../../problems/tag-validator) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | | 503 | [下一个更大元素 II](../../problems/next-greater-element-ii) | [[栈](../stack/README.md)] | Medium | | 496 | [下一个更大元素 I](../../problems/next-greater-element-i) | [[栈](../stack/README.md)] | Easy | -| 456 | [132模式](../../problems/132-pattern) | [[栈](../stack/README.md)] | Medium | +| 456 | [132 模式](../../problems/132-pattern) | [[栈](../stack/README.md)] | Medium | | 439 | [三元表达式解析器](../../problems/ternary-expression-parser) 🔒 | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 402 | [移掉K位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | | 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index 49673dbd2..4be21cb8c 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1816 | [截断句子](../../problems/truncate-sentence) | [[字符串](../string/README.md)] | Easy | +| 1813 | [句子相似性 III](../../problems/sentence-similarity-iii) | [[字符串](../string/README.md)] | Medium | +| 1812 | [判断国际象棋棋盘中一个格子的颜色](../../problems/determine-color-of-a-chessboard-square) | [[字符串](../string/README.md)] | Easy | +| 1807 | [替换字符串中的括号内容](../../problems/evaluate-the-bracket-pairs-of-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1805 | [字符串中不同整数的数目](../../problems/number-of-different-integers-in-a-string) | [[字符串](../string/README.md)] | Easy | +| 1804 | [Implement Trie II (Prefix Tree)](../../problems/implement-trie-ii-prefix-tree) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | | 1796 | [字符串中第二大的数字](../../problems/second-largest-digit-in-a-string) | [[字符串](../string/README.md)] | Easy | | 1794 | [Count Pairs of Equal Substrings With Minimum Difference](../../problems/count-pairs-of-equal-substrings-with-minimum-difference) 🔒 | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1790 | [仅执行一次字符串交换能否使两个字符串相等](../../problems/check-if-one-string-swap-can-make-strings-equal) | [[字符串](../string/README.md)] | Easy | @@ -204,7 +210,7 @@ | 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 125 | [验证回文串](../../problems/valid-palindrome) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 115 | [不同的子序列](../../problems/distinct-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 93 | [复原 IP 地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 91 | [解码方法](../../problems/decode-ways) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 87 | [扰乱字符串](../../problems/scramble-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/tags.json b/tag/tags.json index af38a6919..10fc56aa0 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -74,16 +74,16 @@ "Slug": "design", "TranslatedName": "设计" }, - { - "Name": "Bit Manipulation", - "Slug": "bit-manipulation", - "TranslatedName": "位运算" - }, { "Name": "Graph", "Slug": "graph", "TranslatedName": "图" }, + { + "Name": "Bit Manipulation", + "Slug": "bit-manipulation", + "TranslatedName": "位运算" + }, { "Name": "Heap", "Slug": "heap", @@ -109,16 +109,16 @@ "Slug": "sliding-window", "TranslatedName": "Sliding Window" }, - { - "Name": "Divide and Conquer", - "Slug": "divide-and-conquer", - "TranslatedName": "分治算法" - }, { "Name": "Trie", "Slug": "trie", "TranslatedName": "字典树" }, + { + "Name": "Divide and Conquer", + "Slug": "divide-and-conquer", + "TranslatedName": "分治算法" + }, { "Name": "Segment Tree", "Slug": "segment-tree", diff --git a/tag/trie/README.md b/tag/trie/README.md index 7cb89a16a..1421c18eb 100644 --- a/tag/trie/README.md +++ b/tag/trie/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1804 | [Implement Trie II (Prefix Tree)](../../problems/implement-trie-ii-prefix-tree) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | | 1803 | [统计异或值在范围内的数对有多少](../../problems/count-pairs-with-xor-in-a-range) | [[字典树](../trie/README.md)] | Hard | | 1707 | [与数组中元素的最大异或值](../../problems/maximum-xor-with-an-element-from-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Hard | | 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 26051df30..72d139e04 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,77 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1800 | [最大升序子数组和](../../problems/maximum-ascending-subarray-sum) | [[双指针](../two-pointers/README.md)] | Easy | -| 1750 | [删除字符串两端相同字符后的最短长度](../../problems/minimum-length-of-string-after-deleting-similar-ends) | [[双指针](../two-pointers/README.md)] | Medium | -| 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1695 | [删除子数组的最大得分](../../problems/maximum-erasure-value) | [[双指针](../two-pointers/README.md)] | Medium | -| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard | -| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1248 | [统计「优美子数组」](../../problems/count-number-of-nice-subarrays) | [[双指针](../two-pointers/README.md)] | Medium | -| 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 986 | [区间列表的交集](../../problems/interval-list-intersections) | [[双指针](../two-pointers/README.md)] | Medium | -| 977 | [有序数组的平方](../../problems/squares-of-a-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 925 | [长按键入](../../problems/long-pressed-name) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 923 | [三数之和的多种可能](../../problems/3sum-with-multiplicity) | [[双指针](../two-pointers/README.md)] | Medium | -| 904 | [水果成篮](../../problems/fruit-into-baskets) | [[双指针](../two-pointers/README.md)] | Medium | -| 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 845 | [数组中的最长山脉](../../problems/longest-mountain-in-array) | [[双指针](../two-pointers/README.md)] | Medium | -| 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 828 | [统计子串中的唯一字符](../../problems/count-unique-characters-of-all-substrings-of-a-given-string) | [[双指针](../two-pointers/README.md)] | Hard | -| 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[双指针](../two-pointers/README.md)] | Medium | -| 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 487 | [最大连续1的个数 II](../../problems/max-consecutive-ones-ii) 🔒 | [[双指针](../two-pointers/README.md)] | Medium | -| 457 | [环形数组是否存在循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 345 | [反转字符串中的元音字母](../../problems/reverse-vowels-of-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 344 | [反转字符串](../../problems/reverse-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 234 | [回文链表](../../problems/palindrome-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 141 | [环形链表](../../problems/linked-list-cycle) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 125 | [验证回文串](../../problems/valid-palindrome) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 88 | [合并两个有序数组](../../problems/merge-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 86 | [分隔链表](../../problems/partition-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 80 | [删除排序数组中的重复项 II](../../problems/remove-duplicates-from-sorted-array-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 61 | [旋转链表](../../problems/rotate-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 27 | [移除元素](../../problems/remove-element) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 26 | [删除有序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 19 | [删除链表的倒数第 N 个结点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 11 | [盛最多水的容器](../../problems/container-with-most-water) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | From e984c6b700366125429547c80fc054c4a9111e31 Mon Sep 17 00:00:00 2001 From: Shuo Date: Tue, 6 Apr 2021 11:36:13 +0800 Subject: [PATCH 128/145] A: tag --- tag/design/README.md | 61 +++++++++++++++++++++++++++++ tag/heap/README.md | 44 +++++++++++++++++++++ tag/memoization/README.md | 1 + tag/ordered-map/README.md | 14 +++++++ tag/queue/README.md | 11 ++++++ tag/recursion/README.md | 39 +++++++++++++++++++ tag/segment-tree/README.md | 16 ++++++++ tag/sliding-window/README.md | 27 +++++++++++++ tag/two-pointers/README.md | 74 ++++++++++++++++++++++++++++++++++++ 9 files changed, 287 insertions(+) diff --git a/tag/design/README.md b/tag/design/README.md index 14091cf0c..7af1d3fff 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,3 +9,64 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1797 | [设计一个验证系统](../../problems/design-authentication-manager) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Easy | +| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard | +| 1603 | [设计停车系统](../../problems/design-parking-system) | [[设计](../design/README.md)] | Easy | +| 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[设计](../design/README.md)] | Medium | +| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] | Medium | +| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | +| 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] | Medium | +| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] | Medium | +| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1206 | [设计跳表](../../problems/design-skiplist) | [[设计](../design/README.md)] | Hard | +| 1172 | [餐盘栈](../../problems/dinner-plate-stacks) | [[设计](../design/README.md)] | Hard | +| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 716 | [最大栈](../../problems/max-stack) 🔒 | [[设计](../design/README.md)] | Easy | +| 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy | +| 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Hard | +| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | +| 631 | [设计 Excel 求和公式](../../problems/design-excel-sum-formula) 🔒 | [[设计](../design/README.md)] | Hard | +| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] | Easy | +| 588 | [设计内存文件系统](../../problems/design-in-memory-file-system) 🔒 | [[设计](../design/README.md)] | Hard | +| 460 | [LFU 缓存](../../problems/lfu-cache) | [[设计](../design/README.md)] | Hard | +| 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] | Hard | +| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 362 | [敲击计数器](../../problems/design-hit-counter) 🔒 | [[设计](../design/README.md)] | Medium | +| 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 348 | [设计井字棋](../../problems/design-tic-tac-toe) 🔒 | [[设计](../design/README.md)] | Medium | +| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | +| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | +| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard | +| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard | +| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] | Medium | +| 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] | Medium | +| 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] | Medium | +| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium | +| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | +| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] | Medium | diff --git a/tag/heap/README.md b/tag/heap/README.md index 39b134930..03cd2ce78 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -9,3 +9,47 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 1792 | [最大平均通过率](../../problems/maximum-average-pass-ratio) | [[堆](../heap/README.md)] | Medium | +| 1760 | [袋子里最少数目的球](../../problems/minimum-limit-of-balls-in-a-bag) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1753 | [移除石子的最大得分](../../problems/maximum-score-from-removing-stones) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | +| 1705 | [吃苹果的最大数目](../../problems/maximum-number-of-eaten-apples) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | +| 1642 | [可以到达的最远建筑](../../problems/furthest-building-you-can-reach) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1439 | [有序矩阵中的第 k 个最小数组和](../../problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | [[堆](../heap/README.md)] | Hard | +| 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] | Medium | +| 1046 | [最后一块石头的重量](../../problems/last-stone-weight) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Easy | +| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 882 | [细分图中的可到达结点](../../problems/reachable-nodes-in-subdivided-graph) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 871 | [最低加油次数](../../problems/minimum-number-of-refueling-stops) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 864 | [获取所有钥匙的最短路径](../../problems/shortest-path-to-get-all-keys) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[堆](../heap/README.md)] | Hard | +| 818 | [赛车](../../problems/race-car) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | +| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy | +| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[堆](../heap/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | +| 502 | [IPO](../../problems/ipo) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | +| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 373 | [查找和最小的K对数字](../../problems/find-k-pairs-with-smallest-sums) | [[堆](../heap/README.md)] | Medium | +| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 313 | [超级丑数](../../problems/super-ugly-number) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | +| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard | +| 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | +| 215 | [数组中的第K个最大元素](../../problems/kth-largest-element-in-an-array) | [[堆](../heap/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | +| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/memoization/README.md b/tag/memoization/README.md index f418d566c..2c6a5dffd 100644 --- a/tag/memoization/README.md +++ b/tag/memoization/README.md @@ -9,3 +9,4 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index 52afd5989..85faedb8e 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -9,3 +9,17 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | +| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 855 | [考场就座](../../problems/exam-room) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 846 | [一手顺子](../../problems/hand-of-straights) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 731 | [我的日程安排表 II](../../problems/my-calendar-ii) | [[Ordered Map](../ordered-map/README.md)] | Medium | +| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 683 | [K 个关闭的灯泡](../../problems/k-empty-slots) 🔒 | [[Ordered Map](../ordered-map/README.md)] | Hard | +| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index 8922feba8..0c9155aea 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -9,3 +9,14 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | +| 933 | [最近的请求次数](../../problems/number-of-recent-calls) | [[队列](../queue/README.md)] | Easy | +| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | +| 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | +| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | +| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 42f90d3a9..1989c8da1 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -9,3 +9,42 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[递归](../recursion/README.md)] | Easy | +| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[递归](../recursion/README.md)] | Medium | +| 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | +| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | +| 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | +| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | +| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Easy | +| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index bdf264168..b34d04e3d 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -9,3 +9,19 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[线段树](../segment-tree/README.md)] | Hard | +| 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | +| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | +| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | +| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 308 | [二维区域和检索 - 可变](../../problems/range-sum-query-2d-mutable) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Hard | +| 307 | [区域和检索 - 数组可修改](../../problems/range-sum-query-mutable) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Medium | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index fbbfc5182..ee49220e1 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -9,3 +9,30 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[排序](../sort/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1176 | [健身计划评估](../../problems/diet-plan-performance) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Easy | +| 1151 | [最少交换次数来组合所有的 1](../../problems/minimum-swaps-to-group-all-1s-together) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 1052 | [爱生气的书店老板](../../problems/grumpy-bookstore-owner) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1040 | [移动石子直到连续 II](../../problems/moving-stones-until-consecutive-ii) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[贪心算法](../greedy/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 480 | [滑动窗口中位数](../../problems/sliding-window-median) | [[Sliding Window](../sliding-window/README.md)] | Hard | +| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 72d139e04..80e3c1097 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,3 +9,77 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1800 | [最大升序子数组和](../../problems/maximum-ascending-subarray-sum) | [[双指针](../two-pointers/README.md)] | Easy | +| 1750 | [删除字符串两端相同字符后的最短长度](../../problems/minimum-length-of-string-after-deleting-similar-ends) | [[双指针](../two-pointers/README.md)] | Medium | +| 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1695 | [删除子数组的最大得分](../../problems/maximum-erasure-value) | [[双指针](../two-pointers/README.md)] | Medium | +| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard | +| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1248 | [统计「优美子数组」](../../problems/count-number-of-nice-subarrays) | [[双指针](../two-pointers/README.md)] | Medium | +| 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 986 | [区间列表的交集](../../problems/interval-list-intersections) | [[双指针](../two-pointers/README.md)] | Medium | +| 977 | [有序数组的平方](../../problems/squares-of-a-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 925 | [长按键入](../../problems/long-pressed-name) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 923 | [三数之和的多种可能](../../problems/3sum-with-multiplicity) | [[双指针](../two-pointers/README.md)] | Medium | +| 904 | [水果成篮](../../problems/fruit-into-baskets) | [[双指针](../two-pointers/README.md)] | Medium | +| 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 845 | [数组中的最长山脉](../../problems/longest-mountain-in-array) | [[双指针](../two-pointers/README.md)] | Medium | +| 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 828 | [统计子串中的唯一字符](../../problems/count-unique-characters-of-all-substrings-of-a-given-string) | [[双指针](../two-pointers/README.md)] | Hard | +| 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[双指针](../two-pointers/README.md)] | Medium | +| 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 487 | [最大连续1的个数 II](../../problems/max-consecutive-ones-ii) 🔒 | [[双指针](../two-pointers/README.md)] | Medium | +| 457 | [环形数组是否存在循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 345 | [反转字符串中的元音字母](../../problems/reverse-vowels-of-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 344 | [反转字符串](../../problems/reverse-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 234 | [回文链表](../../problems/palindrome-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 141 | [环形链表](../../problems/linked-list-cycle) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 125 | [验证回文串](../../problems/valid-palindrome) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 88 | [合并两个有序数组](../../problems/merge-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 86 | [分隔链表](../../problems/partition-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 80 | [删除有序数组中的重复项 II](../../problems/remove-duplicates-from-sorted-array-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 61 | [旋转链表](../../problems/rotate-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 27 | [移除元素](../../problems/remove-element) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 26 | [删除有序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 19 | [删除链表的倒数第 N 个结点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 11 | [盛最多水的容器](../../problems/container-with-most-water) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | From 02416532a15fe99d3dbabfac8cfdcba0ee259378 Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 26 Apr 2021 10:08:03 +0800 Subject: [PATCH 129/145] A: new --- README.md | 33 +++++- problems/01-matrix/README.md | 53 ++++----- problems/4sum-ii/README.md | 42 ++++--- problems/4sum/README.md | 27 +++-- problems/add-two-numbers-ii/README.md | 40 +++++-- problems/add-two-numbers/README.md | 2 +- problems/all-oone-data-structure/README.md | 59 +++++++--- .../README.md | 57 ++++++---- problems/arranging-coins/README.md | 43 ++++--- problems/array-nesting/README.md | 2 +- problems/assign-cookies/README.md | 6 +- problems/backspace-string-compare/README.md | 52 ++++----- problems/base-7/README.md | 29 +++-- problems/battleships-in-a-board/README.md | 44 ++++--- problems/beautiful-arrangement-ii/README.md | 44 +++---- problems/binary-watch/README.md | 44 ++++--- problems/brick-wall/README.md | 46 ++++---- problems/buddy-strings/README.md | 6 +- problems/can-i-win/README.md | 6 +- problems/can-place-flowers/README.md | 2 +- .../README.md | 54 +++++++++ problems/coin-change-2/README.md | 44 ++++--- problems/coin-change/README.md | 2 +- .../complex-number-multiplication/README.md | 48 ++++---- problems/contiguous-array/README.md | 32 +++--- .../convert-a-number-to-hexadecimal/README.md | 47 +++----- problems/count-the-repetitions/README.md | 44 ++++--- problems/day-of-the-week/README.md | 2 +- problems/day-of-the-year/README.md | 2 +- problems/destination-city/README.md | 8 +- problems/detect-capital/README.md | 41 +++---- problems/di-string-match/README.md | 2 +- problems/diagonal-traverse/README.md | 36 +++--- .../README.md | 20 +++- problems/employee-importance/README.md | 2 +- problems/erect-the-fence/README.md | 45 ++++---- problems/faulty-sensor/README.md | 33 ++++++ .../find-all-anagrams-in-a-string/README.md | 49 ++++---- .../find-all-duplicates-in-an-array/README.md | 37 +++--- problems/find-all-good-strings/README.md | 4 +- .../README.md | 14 +++ .../mysql_schemas.sql | 9 ++ .../find-the-closest-palindrome/README.md | 38 ++++--- .../README.md | 77 +++++++++++++ .../README.md | 2 +- .../README.md | 8 +- .../README.md | 69 +++++++++++ problems/finding-mk-average/README.md | 83 ++++++++++++++ problems/first-missing-positive/README.md | 2 +- problems/fizz-buzz/README.md | 48 ++++---- problems/freedom-trail/README.md | 46 ++++---- .../README.md | 68 +++++++++++ .../global-and-local-inversions/README.md | 38 +++++-- problems/grand-slam-titles/README.md | 2 +- problems/grid-illumination/README.md | 18 +-- problems/hamming-distance/README.md | 32 ++++-- problems/height-checker/README.md | 22 ++-- .../implement-trie-ii-prefix-tree/README.md | 2 +- .../increasing-order-search-tree/README.md | 2 +- problems/increasing-subsequences/README.md | 21 ++-- problems/ipo/README.md | 61 +++++----- problems/k-diff-pairs-in-an-array/README.md | 7 +- .../README.md | 28 +++-- .../README.md | 41 +++---- .../README.md | 2 +- .../README.md | 34 +++--- problems/largest-palindrome-product/README.md | 27 +++-- problems/leetflex-banned-accounts/README.md | 2 +- problems/license-key-formatting/README.md | 45 ++++---- problems/lonely-pixel-ii/README.md | 1 - problems/longest-common-prefix/README.md | 2 +- .../README.md | 1 + .../README.md | 45 +++----- problems/longest-string-chain/README.md | 4 +- .../README.md | 72 ++++++++++++ .../longest-uncommon-subsequence-i/README.md | 10 +- .../longest-uncommon-subsequence-ii/README.md | 49 ++++---- problems/longest-word-in-dictionary/README.md | 42 +++---- problems/magical-string/README.md | 73 +++++------- problems/matchsticks-to-square/README.md | 40 +++---- problems/max-consecutive-ones-iii/README.md | 40 +++---- problems/max-consecutive-ones/README.md | 30 +++-- problems/maximum-building-height/README.md | 81 +++++++++++++ problems/maximum-ice-cream-bars/README.md | 80 +++++++++++++ .../maximum-length-of-pair-chain/README.md | 45 ++++---- .../README.md | 32 +++--- .../README.md | 33 ++++++ problems/maximum-number-of-balloons/README.md | 6 +- .../maximum-performance-of-a-team/README.md | 17 +-- .../README.md | 2 +- .../README.md | 33 +++--- .../maximum-transaction-each-day/README.md | 14 +++ .../mysql_schemas.sql | 7 ++ problems/maximum-xor-for-each-query/README.md | 78 +++++++++++++ problems/min-cost-climbing-stairs/README.md | 46 ++++---- .../README.md | 37 +++--- .../README.md | 5 +- problems/minimum-genetic-mutation/README.md | 61 +++++----- .../README.md | 36 ++++-- .../README.md | 3 +- .../README.md | 18 +-- .../README.md | 83 ++++++++++++++ .../README.md | 76 +++++++++++++ problems/minimum-sideway-jumps/README.md | 81 +++++++++++++ problems/most-frequent-subtree-sum/README.md | 39 ++++--- problems/nested-list-weight-sum-ii/README.md | 2 +- problems/nested-list-weight-sum/README.md | 2 +- .../README.md | 38 +++++-- problems/non-overlapping-intervals/README.md | 42 ++++--- problems/number-of-boomerangs/README.md | 6 +- .../README.md | 4 +- .../README.md | 2 +- problems/partition-equal-subset-sum/README.md | 2 +- .../README.md | 23 ++-- problems/path-sum-iii/README.md | 42 +++---- problems/permutation-in-string/README.md | 23 ++-- problems/predict-the-winner/README.md | 32 +++--- .../README.md | 2 +- problems/print-in-order/README.md | 30 +++-- .../README.md | 70 ++++++++++++ .../README.md | 12 +- .../README.md | 28 +++++ problems/remove-k-digits/README.md | 49 ++++---- problems/reshape-the-matrix/README.md | 61 ++++------ problems/reverse-pairs/README.md | 41 ++++--- problems/rotate-array/README.md | 2 +- problems/shopping-offers/README.md | 60 +++++----- .../sign-of-the-product-of-an-array/README.md | 71 ++++++++++++ problems/single-threaded-cpu/README.md | 81 +++++++++++++ problems/sliding-window-median/README.md | 50 +++++--- problems/smallest-good-base/README.md | 46 ++++---- problems/sort-an-array/README.md | 4 +- problems/sort-array-by-parity-ii/README.md | 3 + .../sort-characters-by-frequency/README.md | 60 +++++----- problems/stickers-to-spell-word/README.md | 82 +++++++------- problems/sum-of-digits-in-base-k/README.md | 56 +++++++++ problems/sum-of-left-leaves/README.md | 30 +++-- problems/super-ugly-number/README.md | 8 +- problems/super-washing-machines/README.md | 67 ++++++----- problems/tag-validator/README.md | 107 +++++++++--------- problems/target-sum/README.md | 42 ++++--- problems/teemo-attacking/README.md | 41 ++++--- .../README.md | 2 +- problems/top-k-frequent-elements/README.md | 2 +- problems/total-hamming-distance/README.md | 37 +++--- problems/trapping-rain-water-ii/README.md | 41 ++++--- problems/ugly-number-ii/README.md | 6 +- problems/ugly-number-iii/README.md | 4 +- problems/ugly-number/README.md | 8 +- .../README.md | 48 ++++---- problems/valid-square/README.md | 2 +- problems/validate-ip-address/README.md | 10 +- problems/word-ladder-ii/README.md | 4 +- readme/601-900.md | 2 +- tag/README.md | 4 +- tag/array/README.md | 8 +- tag/binary-search/README.md | 1 + tag/bit-manipulation/README.md | 2 + tag/breadth-first-search/README.md | 3 +- tag/depth-first-search/README.md | 5 +- tag/design/README.md | 1 + tag/dynamic-programming/README.md | 4 +- tag/graph/README.md | 1 + tag/greedy/README.md | 3 + tag/heap/README.md | 2 + tag/linked-list/README.md | 1 + tag/math/README.md | 5 + tag/queue/README.md | 1 + tag/recursion/README.md | 2 +- tag/sort/README.md | 1 + tag/string/README.md | 5 +- tag/tags.json | 10 +- tag/tree/README.md | 2 +- tag/trie/README.md | 2 +- tag/two-pointers/README.md | 1 + 175 files changed, 3230 insertions(+), 1680 deletions(-) create mode 100644 problems/check-if-the-sentence-is-pangram/README.md create mode 100644 problems/faulty-sensor/README.md create mode 100644 problems/find-customers-with-positive-revenue-this-year/README.md create mode 100644 problems/find-customers-with-positive-revenue-this-year/mysql_schemas.sql create mode 100644 problems/find-the-winner-of-the-circular-game/README.md create mode 100644 problems/find-xor-sum-of-all-pairs-bitwise-and/README.md create mode 100644 problems/finding-mk-average/README.md create mode 100644 problems/frequency-of-the-most-frequent-element/README.md create mode 100644 problems/longest-substring-of-all-vowels-in-order/README.md create mode 100644 problems/maximum-building-height/README.md create mode 100644 problems/maximum-ice-cream-bars/README.md create mode 100644 problems/maximum-number-of-accepted-invitations/README.md create mode 100644 problems/maximum-transaction-each-day/README.md create mode 100644 problems/maximum-transaction-each-day/mysql_schemas.sql create mode 100644 problems/maximum-xor-for-each-query/README.md create mode 100644 problems/minimum-number-of-operations-to-make-string-sorted/README.md create mode 100644 problems/minimum-operations-to-make-the-array-increasing/README.md create mode 100644 problems/minimum-sideway-jumps/README.md create mode 100644 problems/queries-on-number-of-points-inside-a-circle/README.md create mode 100644 problems/remove-duplicates-from-an-unsorted-linked-list/README.md create mode 100644 problems/sign-of-the-product-of-an-array/README.md create mode 100644 problems/single-threaded-cpu/README.md create mode 100644 problems/sum-of-digits-in-base-k/README.md diff --git a/README.md b/README.md index 8808bc253..f743fa430 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,27 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1840 | [Maximum Building Height](https://leetcode.com/problems/maximum-building-height "最高建筑高度") | [Go](problems/maximum-building-height) | Hard | +| 1839 | [Longest Substring Of All Vowels in Order](https://leetcode.com/problems/longest-substring-of-all-vowels-in-order "所有元音按顺序排布的最长子字符串") | [Go](problems/longest-substring-of-all-vowels-in-order) | Medium | +| 1838 | [Frequency of the Most Frequent Element](https://leetcode.com/problems/frequency-of-the-most-frequent-element "最高频元素的频数") | [Go](problems/frequency-of-the-most-frequent-element) | Medium | +| 1837 | [Sum of Digits in Base K](https://leetcode.com/problems/sum-of-digits-in-base-k "K 进制表示下的各位数字总和") | [Go](problems/sum-of-digits-in-base-k) | Easy | +| 1836 | [Remove Duplicates From an Unsorted Linked List](https://leetcode.com/problems/remove-duplicates-from-an-unsorted-linked-list) 🔒 | [Go](problems/remove-duplicates-from-an-unsorted-linked-list) | Medium | +| 1835 | [Find XOR Sum of All Pairs Bitwise AND](https://leetcode.com/problems/find-xor-sum-of-all-pairs-bitwise-and "所有数对按位与结果的异或和") | [Go](problems/find-xor-sum-of-all-pairs-bitwise-and) | Hard | +| 1834 | [Single-Threaded CPU](https://leetcode.com/problems/single-threaded-cpu "单线程 CPU") | [Go](problems/single-threaded-cpu) | Medium | +| 1833 | [Maximum Ice Cream Bars](https://leetcode.com/problems/maximum-ice-cream-bars "雪糕的最大数量") | [Go](problems/maximum-ice-cream-bars) | Medium | +| 1832 | [Check if the Sentence Is Pangram](https://leetcode.com/problems/check-if-the-sentence-is-pangram "判断句子是否为全字母句") | [Go](problems/check-if-the-sentence-is-pangram) | Easy | +| 1831 | [Maximum Transaction Each Day](https://leetcode.com/problems/maximum-transaction-each-day) 🔒 | [MySQL](problems/maximum-transaction-each-day) | Medium | +| 1830 | [Minimum Number of Operations to Make String Sorted](https://leetcode.com/problems/minimum-number-of-operations-to-make-string-sorted "使字符串有序的最少操作次数") | [Go](problems/minimum-number-of-operations-to-make-string-sorted) | Hard | +| 1829 | [Maximum XOR for Each Query](https://leetcode.com/problems/maximum-xor-for-each-query "每个查询的最大异或值") | [Go](problems/maximum-xor-for-each-query) | Medium | +| 1828 | [Queries on Number of Points Inside a Circle](https://leetcode.com/problems/queries-on-number-of-points-inside-a-circle "统计一个圆中点的数目") | [Go](problems/queries-on-number-of-points-inside-a-circle) | Medium | +| 1827 | [Minimum Operations to Make the Array Increasing](https://leetcode.com/problems/minimum-operations-to-make-the-array-increasing "最少操作使数组递增") | [Go](problems/minimum-operations-to-make-the-array-increasing) | Easy | +| 1826 | [Faulty Sensor](https://leetcode.com/problems/faulty-sensor) 🔒 | [Go](problems/faulty-sensor) | Easy | +| 1825 | [Finding MK Average](https://leetcode.com/problems/finding-mk-average "求出 MK 平均值") | [Go](problems/finding-mk-average) | Hard | +| 1824 | [Minimum Sideway Jumps](https://leetcode.com/problems/minimum-sideway-jumps "最少侧跳次数") | [Go](problems/minimum-sideway-jumps) | Medium | +| 1823 | [Find the Winner of the Circular Game](https://leetcode.com/problems/find-the-winner-of-the-circular-game "找出游戏的获胜者") | [Go](problems/find-the-winner-of-the-circular-game) | Medium | +| 1822 | [Sign of the Product of an Array](https://leetcode.com/problems/sign-of-the-product-of-an-array "数组元素积的符号") | [Go](problems/sign-of-the-product-of-an-array) | Easy | +| 1821 | [Find Customers With Positive Revenue this Year](https://leetcode.com/problems/find-customers-with-positive-revenue-this-year) 🔒 | [MySQL](problems/find-customers-with-positive-revenue-this-year) | Easy | +| 1820 | [Maximum Number of Accepted Invitations](https://leetcode.com/problems/maximum-number-of-accepted-invitations) 🔒 | [Go](problems/maximum-number-of-accepted-invitations) | Medium | | 1819 | [Number of Different Subsequences GCDs](https://leetcode.com/problems/number-of-different-subsequences-gcds "序列中不同最大公约数的数目") | [Go](problems/number-of-different-subsequences-gcds) | Hard | | 1818 | [Minimum Absolute Sum Difference](https://leetcode.com/problems/minimum-absolute-sum-difference "绝对差值和") | [Go](problems/minimum-absolute-sum-difference) | Medium | | 1817 | [Finding the Users Active Minutes](https://leetcode.com/problems/finding-the-users-active-minutes "查找用户活跃分钟数") | [Go](problems/finding-the-users-active-minutes) | Medium | @@ -93,7 +114,7 @@ LeetCode Problems' Solutions | 1807 | [Evaluate the Bracket Pairs of a String](https://leetcode.com/problems/evaluate-the-bracket-pairs-of-a-string "替换字符串中的括号内容") | [Go](problems/evaluate-the-bracket-pairs-of-a-string) | Medium | | 1806 | [Minimum Number of Operations to Reinitialize a Permutation](https://leetcode.com/problems/minimum-number-of-operations-to-reinitialize-a-permutation "还原排列的最少操作步数") | [Go](problems/minimum-number-of-operations-to-reinitialize-a-permutation) | Medium | | 1805 | [Number of Different Integers in a String](https://leetcode.com/problems/number-of-different-integers-in-a-string "字符串中不同整数的数目") | [Go](problems/number-of-different-integers-in-a-string) | Easy | -| 1804 | [Implement Trie II (Prefix Tree)](https://leetcode.com/problems/implement-trie-ii-prefix-tree) 🔒 | [Go](problems/implement-trie-ii-prefix-tree) | Medium | +| 1804 | [Implement Trie II (Prefix Tree)](https://leetcode.com/problems/implement-trie-ii-prefix-tree "实现 Trie (前缀树) II") 🔒 | [Go](problems/implement-trie-ii-prefix-tree) | Medium | | 1803 | [Count Pairs With XOR in a Range](https://leetcode.com/problems/count-pairs-with-xor-in-a-range "统计异或值在范围内的数对有多少") | [Go](problems/count-pairs-with-xor-in-a-range) | Hard | | 1802 | [Maximum Value at a Given Index in a Bounded Array](https://leetcode.com/problems/maximum-value-at-a-given-index-in-a-bounded-array "有界数组中指定下标处的最大值") | [Go](problems/maximum-value-at-a-given-index-in-a-bounded-array) | Medium | | 1801 | [Number of Orders in the Backlog](https://leetcode.com/problems/number-of-orders-in-the-backlog "积压订单中的订单总数") | [Go](problems/number-of-orders-in-the-backlog) | Medium | @@ -114,7 +135,7 @@ LeetCode Problems' Solutions | 1786 | [Number of Restricted Paths From First to Last Node](https://leetcode.com/problems/number-of-restricted-paths-from-first-to-last-node "从第一个节点出发到最后一个节点的受限路径数") | [Go](problems/number-of-restricted-paths-from-first-to-last-node) | Medium | | 1785 | [Minimum Elements to Add to Form a Given Sum](https://leetcode.com/problems/minimum-elements-to-add-to-form-a-given-sum "构成特定和需要添加的最少元素") | [Go](problems/minimum-elements-to-add-to-form-a-given-sum) | Medium | | 1784 | [Check if Binary String Has at Most One Segment of Ones](https://leetcode.com/problems/check-if-binary-string-has-at-most-one-segment-of-ones "检查二进制字符串字段") | [Go](problems/check-if-binary-string-has-at-most-one-segment-of-ones) | Easy | -| 1783 | [Grand Slam Titles](https://leetcode.com/problems/grand-slam-titles) 🔒 | [MySQL](problems/grand-slam-titles) | Medium | +| 1783 | [Grand Slam Titles](https://leetcode.com/problems/grand-slam-titles "大满贯数量") 🔒 | [MySQL](problems/grand-slam-titles) | Medium | | 1782 | [Count Pairs Of Nodes](https://leetcode.com/problems/count-pairs-of-nodes "统计点对的数目") | [Go](problems/count-pairs-of-nodes) | Hard | | 1781 | [Sum of Beauty of All Substrings](https://leetcode.com/problems/sum-of-beauty-of-all-substrings "所有子字符串美丽值之和") | [Go](problems/sum-of-beauty-of-all-substrings) | Medium | | 1780 | [Check if Number is a Sum of Powers of Three](https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three "判断一个数字是否可以表示成三的幂的和") | [Go](problems/check-if-number-is-a-sum-of-powers-of-three) | Medium | @@ -150,13 +171,13 @@ LeetCode Problems' Solutions | 1750 | [Minimum Length of String After Deleting Similar Ends](https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends "删除字符串两端相同字符后的最短长度") | [Go](problems/minimum-length-of-string-after-deleting-similar-ends) | Medium | | 1749 | [Maximum Absolute Sum of Any Subarray](https://leetcode.com/problems/maximum-absolute-sum-of-any-subarray "任意子数组和的绝对值的最大值") | [Go](problems/maximum-absolute-sum-of-any-subarray) | Medium | | 1748 | [Sum of Unique Elements](https://leetcode.com/problems/sum-of-unique-elements "唯一元素的和") | [Go](problems/sum-of-unique-elements) | Easy | -| 1747 | [Leetflex Banned Accounts](https://leetcode.com/problems/leetflex-banned-accounts) 🔒 | [MySQL](problems/leetflex-banned-accounts) | Medium | -| 1746 | [Maximum Subarray Sum After One Operation](https://leetcode.com/problems/maximum-subarray-sum-after-one-operation) 🔒 | [Go](problems/maximum-subarray-sum-after-one-operation) | Medium | +| 1747 | [Leetflex Banned Accounts](https://leetcode.com/problems/leetflex-banned-accounts "应该被禁止的Leetflex账户") 🔒 | [MySQL](problems/leetflex-banned-accounts) | Medium | +| 1746 | [Maximum Subarray Sum After One Operation](https://leetcode.com/problems/maximum-subarray-sum-after-one-operation "经过一次操作后的最大子数组和") 🔒 | [Go](problems/maximum-subarray-sum-after-one-operation) | Medium | | 1745 | [Palindrome Partitioning IV](https://leetcode.com/problems/palindrome-partitioning-iv "回文串分割 IV") | [Go](problems/palindrome-partitioning-iv) | Hard | | 1744 | [Can You Eat Your Favorite Candy on Your Favorite Day?](https://leetcode.com/problems/can-you-eat-your-favorite-candy-on-your-favorite-day "你能在你最喜欢的那天吃到你最喜欢的糖果吗?") | [Go](problems/can-you-eat-your-favorite-candy-on-your-favorite-day) | Medium | | 1743 | [Restore the Array From Adjacent Pairs](https://leetcode.com/problems/restore-the-array-from-adjacent-pairs "从相邻元素对还原数组") | [Go](problems/restore-the-array-from-adjacent-pairs) | Medium | | 1742 | [Maximum Number of Balls in a Box](https://leetcode.com/problems/maximum-number-of-balls-in-a-box "盒子中小球的最大数量") | [Go](problems/maximum-number-of-balls-in-a-box) | Easy | -| 1741 | [Find Total Time Spent by Each Employee](https://leetcode.com/problems/find-total-time-spent-by-each-employee) 🔒 | [MySQL](problems/find-total-time-spent-by-each-employee) | Easy | +| 1741 | [Find Total Time Spent by Each Employee](https://leetcode.com/problems/find-total-time-spent-by-each-employee "查找每个员工花费的总时间") 🔒 | [MySQL](problems/find-total-time-spent-by-each-employee) | Easy | | 1740 | [Find Distance in a Binary Tree](https://leetcode.com/problems/find-distance-in-a-binary-tree "找到二叉树中的距离") 🔒 | [Go](problems/find-distance-in-a-binary-tree) | Medium | | 1739 | [Building Boxes](https://leetcode.com/problems/building-boxes "放置盒子") | [Go](problems/building-boxes) | Hard | | 1738 | [Find Kth Largest XOR Coordinate Value](https://leetcode.com/problems/find-kth-largest-xor-coordinate-value "找出第 K 大的异或坐标值") | [Go](problems/find-kth-largest-xor-coordinate-value) | Medium | @@ -166,7 +187,7 @@ LeetCode Problems' Solutions | 1734 | [Decode XORed Permutation](https://leetcode.com/problems/decode-xored-permutation "解码异或后的排列") | [Go](problems/decode-xored-permutation) | Medium | | 1733 | [Minimum Number of People to Teach](https://leetcode.com/problems/minimum-number-of-people-to-teach "需要教语言的最少人数") | [Go](problems/minimum-number-of-people-to-teach) | Medium | | 1732 | [Find the Highest Altitude](https://leetcode.com/problems/find-the-highest-altitude "找到最高海拔") | [Go](problems/find-the-highest-altitude) | Easy | -| 1731 | [The Number of Employees Which Report to Each Employee](https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee) 🔒 | [MySQL](problems/the-number-of-employees-which-report-to-each-employee) | Easy | +| 1731 | [The Number of Employees Which Report to Each Employee](https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee "每位经理的下属员工数量") 🔒 | [MySQL](problems/the-number-of-employees-which-report-to-each-employee) | Easy | | 1730 | [Shortest Path to Get Food](https://leetcode.com/problems/shortest-path-to-get-food "获取食物的最短路径") 🔒 | [Go](problems/shortest-path-to-get-food) | Medium | | 1729 | [Find Followers Count](https://leetcode.com/problems/find-followers-count "求关注者的数量") 🔒 | [MySQL](problems/find-followers-count) | Easy | | 1728 | [Cat and Mouse II](https://leetcode.com/problems/cat-and-mouse-ii "猫和老鼠 II") | [Go](problems/cat-and-mouse-ii) | Hard | diff --git a/problems/01-matrix/README.md b/problems/01-matrix/README.md index c2ee184af..f8911d729 100644 --- a/problems/01-matrix/README.md +++ b/problems/01-matrix/README.md @@ -11,49 +11,36 @@ ## [542. 01 Matrix (Medium)](https://leetcode.com/problems/01-matrix "01 矩阵") -

    Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell.

    +

    Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell.

    -

    The distance between two adjacent cells is 1.

    +

    The distance between two adjacent cells is 1.

     

    - -

    Example 1:

    - +

    Example 1:

    +
    -Input:
    -[[0,0,0],
    - [0,1,0],
    - [0,0,0]]
    -
    -Output:
    -[[0,0,0],
    - [0,1,0],
    - [0,0,0]]
    +Input: mat = [[0,0,0],[0,1,0],[0,0,0]]
    +Output: [[0,0,0],[0,1,0],[0,0,0]]
     
    -

    Example 2:

    - +

    Example 2:

    +
    -Input:
    -[[0,0,0],
    - [0,1,0],
    - [1,1,1]]
    -
    -Output:
    -[[0,0,0],
    - [0,1,0],
    - [1,2,1]]
    +Input: mat = [[0,0,0],[0,1,0],[1,1,1]]
    +Output: [[0,0,0],[0,1,0],[1,2,1]]
     

     

    - -

    Note:

    - -
      -
    1. The number of elements of the given matrix will not exceed 10,000.
    2. -
    3. There are at least one 0 in the given matrix.
    4. -
    5. The cells are adjacent in only four directions: up, down, left and right.
    6. -
    +

    Constraints:

    + +
      +
    • m == mat.length
    • +
    • n == mat[i].length
    • +
    • 1 <= m, n <= 104
    • +
    • 1 <= m * n <= 104
    • +
    • mat[i][j] is either 0 or 1.
    • +
    • There is at least one 0 in mat.
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/4sum-ii/README.md b/problems/4sum-ii/README.md index c250b1fe6..31270c22a 100644 --- a/problems/4sum-ii/README.md +++ b/problems/4sum-ii/README.md @@ -11,29 +11,43 @@ ## [454. 4Sum II (Medium)](https://leetcode.com/problems/4sum-ii "四数相加 II") -

    Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.

    +

    Given four integer arrays nums1, nums2, nums3, and nums4 all of length n, return the number of tuples (i, j, k, l) such that:

    -

    To make problem a bit easier, all A, B, C, D have same length of N where 0 ≤ N ≤ 500. All integers are in the range of -228 to 228 - 1 and the result is guaranteed to be at most 231 - 1.

    +
      +
    • 0 <= i, j, k, l < n
    • +
    • nums1[i] + nums2[j] + nums3[k] + nums[l] == 0
    • +
    -

    Example:

    +

     

    +

    Example 1:

    -Input:
    -A = [ 1, 2]
    -B = [-2,-1]
    -C = [-1, 2]
    -D = [ 0, 2]
    +Input: nums1 = [1,2], nums2 = [-2,-1], nums3 = [-1,2], nums4 = [0,2]
    +Output: 2
    +Explanation:
    +The two tuples are:
    +1. (0, 0, 0, 1) -> nums1[0] + nums2[0] + nums3[0] + nums4[1] = 1 + (-2) + (-1) + 2 = 0
    +2. (1, 1, 0, 0) -> nums1[1] + nums2[1] + nums3[0] + nums4[0] = 2 + (-1) + (-1) + 0 = 0
    +
    -Output: -2 +

    Example 2:

    -Explanation: -The two tuples are: -1. (0, 0, 0, 1) -> A[0] + B[0] + C[0] + D[1] = 1 + (-2) + (-1) + 2 = 0 -2. (1, 1, 0, 0) -> A[1] + B[1] + C[0] + D[0] = 2 + (-1) + (-1) + 0 = 0 +
    +Input: nums1 = [0], nums2 = [0], nums3 = [0], nums4 = [0]
    +Output: 1
     

     

    +

    Constraints:

    + +
      +
    • n == nums1.length
    • +
    • n == nums2.length
    • +
    • n == nums3.length
    • +
    • n == nums4.length
    • +
    • 1 <= n <= 200
    • +
    • -228 <= nums1[i], nums2[i], nums3[i], nums4[i] <= 228
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/4sum/README.md b/problems/4sum/README.md index ee092982c..050e4a7bf 100644 --- a/problems/4sum/README.md +++ b/problems/4sum/README.md @@ -11,23 +11,36 @@ ## [18. 4Sum (Medium)](https://leetcode.com/problems/4sum "四数之和") -

    Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.

    +

    Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that:

    -

    Notice that the solution set must not contain duplicate quadruplets.

    +
      +
    • 0 <= a, b, c, d < n
    • +
    • a, b, c, and d are distinct.
    • +
    • nums[a] + nums[b] + nums[c] + nums[d] == target
    • +
    + +

    You may return the answer in any order.

     

    Example 1:

    -
    Input: nums = [1,0,-1,0,-2,2], target = 0
    +
    +
    +Input: nums = [1,0,-1,0,-2,2], target = 0
     Output: [[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]]
    -

    Example 2:

    -
    Input: nums = [], target = 0
    -Output: []
     
    + +

    Example 2:

    + +
    +Input: nums = [2,2,2,2,2], target = 8
    +Output: [[2,2,2,2]]
    +
    +

     

    Constraints:

      -
    • 0 <= nums.length <= 200
    • +
    • 1 <= nums.length <= 200
    • -109 <= nums[i] <= 109
    • -109 <= target <= 109
    diff --git a/problems/add-two-numbers-ii/README.md b/problems/add-two-numbers-ii/README.md index 4ea219910..be840079a 100644 --- a/problems/add-two-numbers-ii/README.md +++ b/problems/add-two-numbers-ii/README.md @@ -11,21 +11,43 @@ ## [445. Add Two Numbers II (Medium)](https://leetcode.com/problems/add-two-numbers-ii "两数相加 II") -

    You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

    +

    You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.

    You may assume the two numbers do not contain any leading zero, except the number 0 itself.

    -

    Follow up:
    -What if you cannot modify the input lists? In other words, reversing the lists is not allowed. -

    +

     

    +

    Example 1:

    + +
    +Input: l1 = [7,2,4,3], l2 = [5,6,4]
    +Output: [7,8,0,7]
    +
    + +

    Example 2:

    + +
    +Input: l1 = [2,4,3], l2 = [5,6,4]
    +Output: [8,0,7]
    +
    + +

    Example 3:

    -

    -Example:

    -Input: (7 -> 2 -> 4 -> 3) + (5 -> 6 -> 4)
    -Output: 7 -> 8 -> 0 -> 7
    +Input: l1 = [0], l2 = [0]
    +Output: [0]
     
    -

    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in each linked list is in the range [1, 100].
    • +
    • 0 <= Node.val <= 9
    • +
    • It is guaranteed that the list represents a number that does not have leading zeros.
    • +
    + +

     

    +

    Follow up: Could you solve it without reversing the input lists?

    ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/add-two-numbers/README.md b/problems/add-two-numbers/README.md index 2648e97af..5d07d51cf 100644 --- a/problems/add-two-numbers/README.md +++ b/problems/add-two-numbers/README.md @@ -11,7 +11,7 @@ ## [2. Add Two Numbers (Medium)](https://leetcode.com/problems/add-two-numbers "两数相加") -

    You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.

    +

    You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.

    You may assume the two numbers do not contain any leading zero, except the number 0 itself.

    diff --git a/problems/all-oone-data-structure/README.md b/problems/all-oone-data-structure/README.md index ad1753225..6bec965e2 100644 --- a/problems/all-oone-data-structure/README.md +++ b/problems/all-oone-data-structure/README.md @@ -11,20 +11,51 @@ ## [432. All O`one Data Structure (Hard)](https://leetcode.com/problems/all-oone-data-structure "全 O(1) 的数据结构") -

    Implement a data structure supporting the following operations:

    - -

    -

      -
    1. Inc(Key) - Inserts a new key with value 1. Or increments an existing key by 1. Key is guaranteed to be a non-empty string.
    2. -
    3. Dec(Key) - If Key's value is 1, remove it from the data structure. Otherwise decrements an existing key by 1. If the key does not exist, this function does nothing. Key is guaranteed to be a non-empty string.
    4. -
    5. GetMaxKey() - Returns one of the keys with maximal value. If no element exists, return an empty string "".
    6. -
    7. GetMinKey() - Returns one of the keys with minimal value. If no element exists, return an empty string "".
    8. -
    -

    - -

    -Challenge: Perform all these in O(1) time complexity. -

    +

    Design a data structure to store the strings' count with the ability to return the strings with minimum and maximum counts.

    + +

    Implement the AllOne class:

    + +
      +
    • AllOne() Initializes the object of the data structure.
    • +
    • inc(String key) Increments the count of the string key by 1. If key does not exist in the data structure, insert it with count 1.
    • +
    • dec(String key) Decrements the count of the string key by 1. If the count of key is 0 after the decrement, remove it from the data structure. It is guaranteed that key exists in the data structure before the decrement.
    • +
    • getMaxKey() Returns one of the keys with the maximal count. If no element exists, return an empty string "".
    • +
    • getMinKey() Returns one of the keys with the minimum count. If no element exists, return an empty string "".
    • +
    + +

     

    +

    Example 1:

    + +
    +Input
    +["AllOne", "inc", "inc", "getMaxKey", "getMinKey", "inc", "getMaxKey", "getMinKey"]
    +[[], ["hello"], ["hello"], [], [], ["leet"], [], []]
    +Output
    +[null, null, null, "hello", "hello", null, "hello", "leet"]
    +
    +Explanation
    +AllOne allOne = new AllOne();
    +allOne.inc("hello");
    +allOne.inc("hello");
    +allOne.getMaxKey(); // return "hello"
    +allOne.getMinKey(); // return "hello"
    +allOne.inc("leet");
    +allOne.getMaxKey(); // return "hello"
    +allOne.getMinKey(); // return "leet"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= key.length <= 10
    • +
    • key consists of lowercase English letters.
    • +
    • It is guaranteed that for each call to dec, key is existing in the data structure.
    • +
    • At most 3 * 104 calls will be made to inc, dec, getMaxKey, and getMinKey.
    • +
    + +

     

    +

    Follow up: Could you apply all the operations in O(1) time complexity?

    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/arithmetic-slices-ii-subsequence/README.md b/problems/arithmetic-slices-ii-subsequence/README.md index ade7bc39a..345742eb3 100644 --- a/problems/arithmetic-slices-ii-subsequence/README.md +++ b/problems/arithmetic-slices-ii-subsequence/README.md @@ -11,39 +11,30 @@ ## [446. Arithmetic Slices II - Subsequence (Hard)](https://leetcode.com/problems/arithmetic-slices-ii-subsequence "等差数列划分 II - 子序列") -

    A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.

    +

    Given an integer array nums, return the number of all the arithmetic subsequences of nums.

    -

    For example, these are arithmetic sequences:

    +

    A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.

    -
    -1, 3, 5, 7, 9
    -7, 7, 7, 7
    -3, -1, -5, -9
    - -

    The following sequence is not arithmetic.

    - -
    -1, 1, 2, 5, 7
    -  +
      +
    • For example, [1, 3, 5, 7, 9], [7, 7, 7, 7], and [3, -1, -5, -9] are arithmetic sequences.
    • +
    • For example, [1, 1, 2, 5, 7] is not an arithmetic sequence.
    • +
    -

    A zero-indexed array A consisting of N numbers is given. A subsequence slice of that array is any sequence of integers (P0, P1, ..., Pk) such that 0 ≤ P0 < P1 < ... < Pk < N.

    +

    A subsequence of an array is a sequence that can be formed by removing some elements (possibly none) of the array.

    -

    A subsequence slice (P0, P1, ..., Pk) of array A is called arithmetic if the sequence A[P0], A[P1], ..., A[Pk-1], A[Pk] is arithmetic. In particular, this means that k ≥ 2.

    +
      +
    • For example, [2,5,10] is a subsequence of [1,2,1,2,4,1,5,10].
    • +
    -

    The function should return the number of arithmetic subsequence slices in the array A.

    +

    The answer is guaranteed to fit in 32-bit integer.

    -

    The input contains N integers. Every integer is in the range of -231 and 231-1 and 0 ≤ N ≤ 1000. The output is guaranteed to be less than 231-1.

    -  - -

    Example:

    +

     

    +

    Example 1:

    -Input: [2, 4, 6, 8, 10]
    -
    -Output: 7
    -
    -Explanation:
    -All arithmetic subsequence slices are:
    +Input: nums = [2,4,6,8,10]
    +Output: 7
    +Explanation: All arithmetic subsequence slices are:
     [2,4,6]
     [4,6,8]
     [6,8,10]
    @@ -53,6 +44,22 @@ All arithmetic subsequence slices are:
     [2,6,10]
     
    +

    Example 2:

    + +
    +Input: nums = [7,7,7,7,7]
    +Output: 16
    +Explanation: Any subsequence of this array is arithmetic.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1  <= nums.length <= 1000
    • +
    • -231 <= nums[i] <= 231 - 1
    • +
    + ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/arranging-coins/README.md b/problems/arranging-coins/README.md index 92d356733..0c3efdf6d 100644 --- a/problems/arranging-coins/README.md +++ b/problems/arranging-coins/README.md @@ -11,38 +11,33 @@ ## [441. Arranging Coins (Easy)](https://leetcode.com/problems/arranging-coins "排列硬币") -

    You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins.

    - -

    Given n, find the total number of full staircase rows that can be formed.

    +

    You have n coins and you want to build a staircase with these coins. The staircase consists of k rows where the ith row has exactly i coins. The last row of the staircase may be incomplete.

    -

    n is a non-negative integer and fits within the range of a 32-bit signed integer.

    +

    Given the integer n, return the number of complete rows of the staircase you will build.

    -

    Example 1: +

     

    +

    Example 1:

    +
    -n = 5
    -
    -The coins can form the following rows:
    -¤
    -¤ ¤
    -¤ ¤
    -
    -Because the 3rd row is incomplete, we return 2.
    +Input: n = 5
    +Output: 2
    +Explanation: Because the 3rd row is incomplete, we return 2.
     
    -

    -

    Example 2: +

    Example 2:

    +
    -n = 8
    +Input: n = 8
    +Output: 3
    +Explanation: Because the 4th row is incomplete, we return 3.
    +
    -The coins can form the following rows: -¤ -¤ ¤ -¤ ¤ ¤ -¤ ¤ +

     

    +

    Constraints:

    -Because the 4th row is incomplete, we return 3. -
    -

    +
      +
    • 1 <= n <= 231 - 1
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/array-nesting/README.md b/problems/array-nesting/README.md index eb472d3dd..dc5881bd9 100644 --- a/problems/array-nesting/README.md +++ b/problems/array-nesting/README.md @@ -43,6 +43,6 @@ S[0] = {A[0], A[5], A[6], A[2]} = {5, 6, 2, 0} [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Nested List Weight Sum](../nested-list-weight-sum) (Easy) + 1. [Nested List Weight Sum](../nested-list-weight-sum) (Medium) 1. [Flatten Nested List Iterator](../flatten-nested-list-iterator) (Medium) 1. [Nested List Weight Sum II](../nested-list-weight-sum-ii) (Medium) diff --git a/problems/assign-cookies/README.md b/problems/assign-cookies/README.md index b63510f9f..e8244dc99 100644 --- a/problems/assign-cookies/README.md +++ b/problems/assign-cookies/README.md @@ -13,9 +13,7 @@

    Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie.

    -

    Each child i has a greed factor g[i], which is the minimum size of a cookie that the child will be content with; and each cookie j has a size s[j]. If s[j] >= g[i], we can assign the cookie j to the child i, and the child i will be content. Your goal is to maximize the number of your content children and output the maximum number.

    - -

     

    +

    Each child i has a greed factor g[i], which is the minimum size of a cookie that the child will be content with; and each cookie j has a size s[j]. If s[j] >= g[i], we can assign the cookie j to the child i, and the child i will be content. Your goal is to maximize the number of your content children and output the maximum number.

     

    Example 1:

    @@ -44,7 +42,7 @@ You need to output 2.
    • 1 <= g.length <= 3 * 104
    • 0 <= s.length <= 3 * 104
    • -
    • 1 <= g[i], s[j] <= 231 - 1
    • +
    • 1 <= g[i], s[j] <= 231 - 1
    ### Related Topics diff --git a/problems/backspace-string-compare/README.md b/problems/backspace-string-compare/README.md index 6e263c3aa..bebe4ff50 100644 --- a/problems/backspace-string-compare/README.md +++ b/problems/backspace-string-compare/README.md @@ -11,63 +11,53 @@ ## [844. Backspace String Compare (Easy)](https://leetcode.com/problems/backspace-string-compare "比较含退格的字符串") -

    Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character.

    +

    Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character.

    -

    Note that after backspacing an empty text, the text will continue empty.

    +

    Note that after backspacing an empty text, the text will continue empty.

    -
    +

     

    Example 1:

    -Input: S = "ab#c", T = "ad#c"
    -Output: true
    -Explanation: Both S and T become "ac".
    +Input: s = "ab#c", t = "ad#c"
    +Output: true
    +Explanation: Both s and t become "ac".
     
    -

    Example 2:

    -Input: S = "ab##", T = "c#d#"
    -Output: true
    -Explanation: Both S and T become "".
    +Input: s = "ab##", t = "c#d#"
    +Output: true
    +Explanation: Both s and t become "".
     
    -

    Example 3:

    -Input: S = "a##c", T = "#a#c"
    -Output: true
    -Explanation: Both S and T become "c".
    +Input: s = "a##c", t = "#a#c"
    +Output: true
    +Explanation: Both s and t become "c".
     
    -

    Example 4:

    -Input: S = "a#c", T = "b"
    -Output: false
    -Explanation: S becomes "c" while T becomes "b".
    +Input: s = "a#c", t = "b"
    +Output: false
    +Explanation: s becomes "c" while t becomes "b".
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • 1 <= S.length <= 200
    • -
    • 1 <= T.length <= 200
    • -
    • S and T only contain lowercase letters and '#' characters.
    • +
    • 1 <= s.length, t.length <= 200
    • +
    • s and t only contain lowercase letters and '#' characters.
    -

    Follow up:

    - -
      -
    • Can you solve it in O(N) time and O(1) space?
    • -
    -
    -
    -
    -
    +

     

    +

    Follow up: Can you solve it in O(n) time and O(1) space?

    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/base-7/README.md b/problems/base-7/README.md index a3c89ea91..c99dfd7bf 100644 --- a/problems/base-7/README.md +++ b/problems/base-7/README.md @@ -11,22 +11,19 @@ ## [504. Base 7 (Easy)](https://leetcode.com/problems/base-7 "七进制数") -

    Given an integer, return its base 7 string representation.

    +

    Given an integer num, return a string of its base 7 representation.

    -

    Example 1:
    -

    -Input: 100
    -Output: "202"
    +

     

    +

    Example 1:

    +
    Input: num = 100
    +Output: "202"
    +

    Example 2:

    +
    Input: num = -7
    +Output: "-10"
     
    -

    +

     

    +

    Constraints:

    -

    Example 2:
    -

    -Input: -7
    -Output: "-10"
    -
    -

    - -

    Note: -The input will be in range of [-1e7, 1e7]. -

    +
      +
    • -107 <= num <= 107
    • +
    diff --git a/problems/battleships-in-a-board/README.md b/problems/battleships-in-a-board/README.md index 1dc1ee558..57d085688 100644 --- a/problems/battleships-in-a-board/README.md +++ b/problems/battleships-in-a-board/README.md @@ -11,26 +11,34 @@ ## [419. Battleships in a Board (Medium)](https://leetcode.com/problems/battleships-in-a-board "甲板上的战舰") -Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's, empty slots are represented with '.'s. You may assume the following rules: +

    Given an m x n matrix board where each cell is a battleship 'X' or empty '.', return the number of the battleships on board.

    -
      -
    • You receive a valid board, made of only battleships or empty slots.
    • -
    • Battleships can only be placed horizontally or vertically. In other words, they can only be made of the shape 1xN (1 row, N columns) or Nx1 (N rows, 1 column), where N can be of any size.
    • -
    • At least one horizontal or vertical cell separates between two battleships - there are no adjacent battleships.
    • -
    +

    Battleships can only be placed horizontally or vertically on board. In other words, they can only be made of the shape 1 x k (1 row, k columns) or k x 1 (k rows, 1 column), where k can be of any size. At least one horizontal or vertical cell separates between two battleships (i.e., there are no adjacent battleships).

    -

    Example:
    -

    X..X
    -...X
    -...X
    +

     

    +

    Example 1:

    + +
    +Input: board = [["X",".",".","X"],[".",".",".","X"],[".",".",".","X"]]
    +Output: 2
     
    -In the above board there are 2 battleships. -

    Invalid Example:
    -

    ...X
    -XXXX
    -...X
    +

    Example 2:

    + +
    +Input: board = [["."]]
    +Output: 0
     
    -This is an invalid board that you will not receive - as battleships will always have a cell separating between them. -

    -

    Follow up:
    Could you do it in one-pass, using only O(1) extra memory and without modifying the value of the board?

    + +

     

    +

    Constraints:

    + +
      +
    • m == board.length
    • +
    • n == board[i].length
    • +
    • 1 <= m, n <= 200
    • +
    • board[i][j] is either '.' or 'X'.
    • +
    + +

     

    +

    Follow up: Could you do it in one-pass, using only O(1) extra memory and without modifying the values board?

    diff --git a/problems/beautiful-arrangement-ii/README.md b/problems/beautiful-arrangement-ii/README.md index 52657c08b..1583978ce 100644 --- a/problems/beautiful-arrangement-ii/README.md +++ b/problems/beautiful-arrangement-ii/README.md @@ -11,37 +11,37 @@ ## [667. Beautiful Arrangement II (Medium)](https://leetcode.com/problems/beautiful-arrangement-ii "优美的排列 II") -

    -Given two integers n and k, you need to construct a list which contains n different positive integers ranging from 1 to n and obeys the following requirement:
    +

    Given two integers n and k, construct a list answer that contains n different positive integers ranging from 1 to n and obeys the following requirement:

    -Suppose this list is [a1, a2, a3, ... , an], then the list [|a1 - a2|, |a2 - a3|, |a3 - a4|, ... , |an-1 - an|] has exactly k distinct integers. -

    +
      +
    • Suppose this list is answer = [a1, a2, a3, ... , an], then the list [|a1 - a2|, |a2 - a3|, |a3 - a4|, ... , |an-1 - an|] has exactly k distinct integers.
    • +
    -

    -If there are multiple answers, print any of them. -

    +

    Return the list answer. If there multiple valid answers, return any of them.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: n = 3, k = 1
    -Output: [1, 2, 3]
    -Explanation: The [1, 2, 3] has three different positive integers ranging from 1 to 3, and the [1, 1] has exactly 1 distinct integer: 1.
    +Input: n = 3, k = 1
    +Output: [1,2,3]
    +Explanation: The [1,2,3] has three different positive integers ranging from 1 to 3, and the [1,1] has exactly 1 distinct integer: 1
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: n = 3, k = 2
    -Output: [1, 3, 2]
    -Explanation: The [1, 3, 2] has three different positive integers ranging from 1 to 3, and the [2, 1] has exactly 2 distinct integers: 1 and 2.
    +Input: n = 3, k = 2
    +Output: [1,3,2]
    +Explanation: The [1,3,2] has three different positive integers ranging from 1 to 3, and the [2,1] has exactly 2 distinct integers: 1 and 2.
     
    -

    -

    Note:
    -

      -
    1. The n and k are in the range 1 <= k < n <= 104.
    2. -
    -

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= k < n <= 104
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/binary-watch/README.md b/problems/binary-watch/README.md index 09de949d2..d0157a61c 100644 --- a/problems/binary-watch/README.md +++ b/problems/binary-watch/README.md @@ -11,24 +11,42 @@ ## [401. Binary Watch (Easy)](https://leetcode.com/problems/binary-watch "二进制手表") -

    A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).

    -

    Each LED represents a zero or one, with the least significant bit on the right.

    - -

    For example, the above binary watch reads "3:25".

    +

    A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED represents a zero or one, with the least significant bit on the right.

    -

    Given a non-negative integer n which represents the number of LEDs that are currently on, return all possible times the watch could represent.

    +
      +
    • For example, the below binary watch reads "4:51".
    • +
    + +

    + +

    Given an integer turnedOn which represents the number of LEDs that are currently on, return all possible times the watch could represent. You may return the answer in any order.

    + +

    The hour must not contain a leading zero.

    + +
      +
    • For example, "01:00" is not valid. It should be "1:00".
    • +
    + +

    The minute must be consist of two digits and may contain a leading zero.

    + +
      +
    • For example, "10:2" is not valid. It should be "10:02".
    • +
    -

    Example: -

    Input: n = 1
    Return: ["1:00", "2:00", "4:00", "8:00", "0:01", "0:02", "0:04", "0:08", "0:16", "0:32"]
    -

    +

     

    +

    Example 1:

    +
    Input: turnedOn = 1
    +Output: ["0:01","0:02","0:04","0:08","0:16","0:32","1:00","2:00","4:00","8:00"]
    +

    Example 2:

    +
    Input: turnedOn = 9
    +Output: []
    +
    +

     

    +

    Constraints:

    -

    Note:

      -
    • The order of output does not matter.
    • -
    • The hour must not contain a leading zero, for example "01:00" is not valid, it should be "1:00".
    • -
    • The minute must be consist of two digits and may contain a leading zero, for example "10:2" is not valid, it should be "10:02".
    • +
    • 0 <= turnedOn <= 10
    -

    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/brick-wall/README.md b/problems/brick-wall/README.md index 5714cdb26..6a24f2f4e 100644 --- a/problems/brick-wall/README.md +++ b/problems/brick-wall/README.md @@ -11,40 +11,38 @@ ## [554. Brick Wall (Medium)](https://leetcode.com/problems/brick-wall "砖墙") -

    There is a brick wall in front of you. The wall is rectangular and has several rows of bricks. The bricks have the same height but different width. You want to draw a vertical line from the top to the bottom and cross the least bricks.

    +

    There is a rectangular brick wall in front of you with n rows of bricks. The ith row has some number of bricks each of the same height (i.e., one unit) but they can be of different widths. The total width of each row is the same.

    -

    The brick wall is represented by a list of rows. Each row is a list of integers representing the width of each brick in this row from left to right.

    +

    Draw a vertical line from the top to the bottom and cross the least bricks. If your line goes through the edge of a brick, then the brick is not considered as crossed. You cannot draw a line just along one of the two vertical edges of the wall, in which case the line will obviously cross no bricks.

    -

    If your line go through the edge of a brick, then the brick is not considered as crossed. You need to find out how to draw the line to cross the least bricks and return the number of crossed bricks.

    - -

    You cannot draw a line just along one of the two vertical edges of the wall, in which case the line will obviously cross no bricks.

    +

    Given the 2D array wall that contains the information about the wall, return the minimum number of crossed bricks after drawing such a vertical line.

     

    - -

    Example:

    - +

    Example 1:

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

    Example 2:

    -Explanation: - +
    +Input: wall = [[1],[1],[1]]
    +Output: 3
     

     

    - -

    Note:

    - -
      -
    1. The width sum of bricks in different rows are the same and won't exceed INT_MAX.
    2. -
    3. The number of bricks in each row is in range [1,10,000]. The height of wall is in range [1,10,000]. Total number of bricks of the wall won't exceed 20,000.
    4. -
    +

    Constraints:

    + +
      +
    • n == wall.length
    • +
    • 1 <= n <= 104
    • +
    • 1 <= wall[i].length <= 104
    • +
    • 1 <= sum(wall[i].length) <= 2 * 104
    • +
    • sum(wall[i]) is the same for each row i.
    • +
    • 1 <= wall[i][j] <= 231 - 1
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/buddy-strings/README.md b/problems/buddy-strings/README.md index dff223507..3980f40a5 100644 --- a/problems/buddy-strings/README.md +++ b/problems/buddy-strings/README.md @@ -13,7 +13,11 @@

    Given two strings a and b, return true if you can swap two letters in a so the result is equal to b, otherwise, return false.

    -

    Swapping letters is defined as taking two indices i and j (0-indexed) such that i != j and swapping the characters at a[i] and b[j]. For example, swapping at indices 0 and 2 in "abcd" results in "cbad".

    +

    Swapping letters is defined as taking two indices i and j (0-indexed) such that i != j and swapping the characters at a[i] and a[j].

    + +
      +
    • For example, swapping at indices 0 and 2 in "abcd" results in "cbad".
    • +

     

    Example 1:

    diff --git a/problems/can-i-win/README.md b/problems/can-i-win/README.md index 514ebd380..8f6092574 100644 --- a/problems/can-i-win/README.md +++ b/problems/can-i-win/README.md @@ -17,7 +17,7 @@

    For example, two players might take turns drawing from a common pool of numbers from 1 to 15 without replacement until they reach a total >= 100.

    -

    Given two integers maxChoosableInteger and desiredTotal, return true if the first player to move can force a win, otherwise return false. Assume both players play optimally.

    +

    Given two integers maxChoosableInteger and desiredTotal, return true if the first player to move can force a win, otherwise, return false. Assume both players play optimally.

     

    Example 1:

    @@ -51,8 +51,8 @@ Same with other integers chosen by the first player, the second player will alwa

    Constraints:

      -
    • 1 <= maxChoosableInteger <= 20
    • -
    • 0 <= desiredTotal <= 300
    • +
    • 1 <= maxChoosableInteger <= 20
    • +
    • 0 <= desiredTotal <= 300
    ### Related Topics diff --git a/problems/can-place-flowers/README.md b/problems/can-place-flowers/README.md index a486b01f2..0bc60b921 100644 --- a/problems/can-place-flowers/README.md +++ b/problems/can-place-flowers/README.md @@ -13,7 +13,7 @@

    You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in adjacent plots.

    -

    Given an integer array flowerbed containing 0's and 1's, where 0 means empty and 1 means not empty, and an integer n, return if n new flowers can be planted in the flowerbed without violating the no-adjacent-flowers rule.

    +

    Given an integer array flowerbed containing 0's and 1's, where 0 means empty and 1 means not empty, and an integer n, return if n new flowers can be planted in the flowerbed without violating the no-adjacent-flowers rule.

     

    Example 1:

    diff --git a/problems/check-if-the-sentence-is-pangram/README.md b/problems/check-if-the-sentence-is-pangram/README.md new file mode 100644 index 000000000..230c34058 --- /dev/null +++ b/problems/check-if-the-sentence-is-pangram/README.md @@ -0,0 +1,54 @@ + + + + + + + +[< Previous](../maximum-transaction-each-day "Maximum Transaction Each Day") +                 +[Next >](../maximum-ice-cream-bars "Maximum Ice Cream Bars") + +## [1832. Check if the Sentence Is Pangram (Easy)](https://leetcode.com/problems/check-if-the-sentence-is-pangram "判断句子是否为全字母句") + +

    A pangram is a sentence where every letter of the English alphabet appears at least once.

    + +

    Given a string sentence containing only lowercase English letters, return true if sentence is a pangram, or false otherwise.

    + +

     

    +

    Example 1:

    + +
    +Input: sentence = "thequickbrownfoxjumpsoverthelazydog"
    +Output: true
    +Explanation: sentence contains at least one of every letter of the English alphabet.
    +
    + +

    Example 2:

    + +
    +Input: sentence = "leetcode"
    +Output: false
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= sentence.length <= 1000
    • +
    • sentence consists of lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Iterate over the string and mark each character as found (using a boolean array, bitmask, or any other similar way). +
    + +
    +Hint 2 +Check if the number of found characters equals the alphabet length. +
    diff --git a/problems/coin-change-2/README.md b/problems/coin-change-2/README.md index 8ab989868..5e891c809 100644 --- a/problems/coin-change-2/README.md +++ b/problems/coin-change-2/README.md @@ -11,49 +11,47 @@ ## [518. Coin Change 2 (Medium)](https://leetcode.com/problems/coin-change-2 "零钱兑换 II") -

    You are given coins of different denominations and a total amount of money. Write a function to compute the number of combinations that make up that amount. You may assume that you have infinite number of each kind of coin.

    +

    You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.

    -
      -
    +

    Return the number of combinations that make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.

    -

     

    +

    You may assume that you have an infinite number of each kind of coin.

    -

    Example 1:

    +

    The answer is guaranteed to fit into a signed 32-bit integer.

    + +

     

    +

    Example 1:

    -Input: amount = 5, coins = [1, 2, 5]
    -Output: 4
    -Explanation: there are four ways to make up the amount:
    +Input: amount = 5, coins = [1,2,5]
    +Output: 4
    +Explanation: there are four ways to make up the amount:
     5=5
     5=2+2+1
     5=2+1+1+1
     5=1+1+1+1+1
     
    -

    Example 2:

    +

    Example 2:

    -Input: amount = 3, coins = [2]
    -Output: 0
    -Explanation: the amount of 3 cannot be made up just with coins of 2.
    +Input: amount = 3, coins = [2]
    +Output: 0
    +Explanation: the amount of 3 cannot be made up just with coins of 2.
     
    -

    Example 3:

    +

    Example 3:

    -Input: amount = 10, coins = [10] 
    -Output: 1
    +Input: amount = 10, coins = [10]
    +Output: 1
     

     

    - -

    Note:

    - -

    You can assume that

    +

    Constraints:

      -
    • 0 <= amount <= 5000
    • -
    • 1 <= coin <= 5000
    • -
    • the number of coins is less than 500
    • -
    • the answer is guaranteed to fit into signed 32-bit integer
    • +
    • 1 <= coins.length <= 300
    • +
    • 1 <= coins[i] <= 5000
    • +
    • 0 <= amount <= 5000
    diff --git a/problems/coin-change/README.md b/problems/coin-change/README.md index 689e7a96e..fe8fceb16 100644 --- a/problems/coin-change/README.md +++ b/problems/coin-change/README.md @@ -11,7 +11,7 @@ ## [322. Coin Change (Medium)](https://leetcode.com/problems/coin-change "零钱兑换") -

    You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.

    +

    You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.

    Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.

    diff --git a/problems/complex-number-multiplication/README.md b/problems/complex-number-multiplication/README.md index 327b453c3..900bb5f37 100644 --- a/problems/complex-number-multiplication/README.md +++ b/problems/complex-number-multiplication/README.md @@ -11,35 +11,39 @@ ## [537. Complex Number Multiplication (Medium)](https://leetcode.com/problems/complex-number-multiplication "复数乘法") -

    -Given two strings representing two complex numbers.

    +

    A complex number can be represented as a string on the form "real+imaginaryi" where:

    -

    -You need to return a string representing their multiplication. Note i2 = -1 according to the definition. -

    +
      +
    • real is the real part and is an integer in the range [-100, 100].
    • +
    • imaginary is the imaginary part and is an integer in the range [-100, 100].
    • +
    • i2 == -1.
    • +
    + +

    Given two complex numbers num1 and num2 as strings, return a string of the complex number that represents their multiplications.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: "1+1i", "1+1i"
    -Output: "0+2i"
    -Explanation: (1 + i) * (1 + i) = 1 + i2 + 2 * i = 2i, and you need convert it to the form of 0+2i.
    +Input: num1 = "1+1i", num2 = "1+1i"
    +Output: "0+2i"
    +Explanation: (1 + i) * (1 + i) = 1 + i2 + 2 * i = 2i, and you need convert it to the form of 0+2i.
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: "1+-1i", "1+-1i"
    -Output: "0+-2i"
    -Explanation: (1 - i) * (1 - i) = 1 + i2 - 2 * i = -2i, and you need convert it to the form of 0+-2i.
    +Input: num1 = "1+-1i", num2 = "1+-1i"
    +Output: "0+-2i"
    +Explanation: (1 - i) * (1 - i) = 1 + i2 - 2 * i = -2i, and you need convert it to the form of 0+-2i.
     
    -

    - -

    Note: -

      -
    1. The input strings will not have extra blank.
    2. -
    3. The input strings will be given in the form of a+bi, where the integer a and b will both belong to the range of [-100, 100]. And the output should be also in this form.
    4. -
    -

    + +

     

    +

    Constraints:

    + +
      +
    • num1 and num2 are valid complex numbers.
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/contiguous-array/README.md b/problems/contiguous-array/README.md index 8203bbcef..14742523e 100644 --- a/problems/contiguous-array/README.md +++ b/problems/contiguous-array/README.md @@ -11,28 +11,32 @@ ## [525. Contiguous Array (Medium)](https://leetcode.com/problems/contiguous-array "连续数组") -

    Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1.

    +

    Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1.

    +

     

    +

    Example 1:

    -

    Example 1:

    -Input: [0,1]
    -Output: 2
    -Explanation: [0, 1] is the longest contiguous subarray with equal number of 0 and 1.
    +Input: nums = [0,1]
    +Output: 2
    +Explanation: [0, 1] is the longest contiguous subarray with an equal number of 0 and 1.
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: [0,1,0]
    -Output: 2
    -Explanation: [0, 1] (or [1, 0]) is a longest contiguous subarray with equal number of 0 and 1.
    +Input: nums = [0,1,0]
    +Output: 2
    +Explanation: [0, 1] (or [1, 0]) is a longest contiguous subarray with equal number of 0 and 1.
     
    -

    -

    Note: -The length of the given binary array will not exceed 50,000. -

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • nums[i] is either 0 or 1.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/convert-a-number-to-hexadecimal/README.md b/problems/convert-a-number-to-hexadecimal/README.md index 5e644bf73..696d7a24b 100644 --- a/problems/convert-a-number-to-hexadecimal/README.md +++ b/problems/convert-a-number-to-hexadecimal/README.md @@ -11,38 +11,27 @@ ## [405. Convert a Number to Hexadecimal (Easy)](https://leetcode.com/problems/convert-a-number-to-hexadecimal "数字转换为十六进制数") -

    -Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used. -

    - -

    Note: -

      -
    1. All letters in hexadecimal (a-f) must be in lowercase.
    2. -
    3. The hexadecimal string must not contain extra leading 0s. If the number is zero, it is represented by a single zero character '0'; otherwise, the first character in the hexadecimal string will not be the zero character.
    4. -
    5. The given number is guaranteed to fit within the range of a 32-bit signed integer.
    6. -
    7. You must not use any method provided by the library which converts/formats the number to hex directly.
    8. -
    -

    - -

    Example 1: -

    -Input:
    -26
    -
    -Output:
    -"1a"
    -
    -

    +

    Given an integer num, return a string representing its hexadecimal representation. For negative integers, two’s complement method is used.

    -

    Example 2: -

    -Input:
    --1
    +

    All the letters in the answer string should be lowercase characters, and there should not be any leading zeros in the answer except for the zero itself.

    -Output: -"ffffffff" +

     

    +

    Example 1:

    +
    Input: num = 26
    +Output: "1a"
    +

    Example 2:

    +
    Input: num = -1
    +Output: "ffffffff"
     
    -

    +

     

    +

    Constraints:

    + +
      +
    • -231 <= num <= 231 - 1
    • +
    + +

     

    +

    Follow up: Could you solve it without using any built-in library method?

    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/count-the-repetitions/README.md b/problems/count-the-repetitions/README.md index 3d8983d52..25885478e 100644 --- a/problems/count-the-repetitions/README.md +++ b/problems/count-the-repetitions/README.md @@ -11,20 +11,38 @@ ## [466. Count The Repetitions (Hard)](https://leetcode.com/problems/count-the-repetitions "统计重复个数") -

    Define S = [s,n] as the string S which consists of n connected strings s. For example, ["abc", 3] ="abcabcabc".

    -

    On the other hand, we define that string s1 can be obtained from string s2 if we can remove some characters from s2 such that it becomes s1. For example, “abc” can be obtained from “abdbec” based on our definition, but it can not be obtained from “acbbe”.

    -

    You are given two non-empty strings s1 and s2 (each at most 100 characters long) and two integers 0 ≤ n1 ≤ 106 and 1 ≤ n2 ≤ 106. Now consider the strings S1 and S2, where S1=[s1,n1] and S2=[s2,n2]. Find the maximum integer M such that [S2,M] can be obtained from S1.

    - -

    Example: -

    -Input:
    -s1="acb", n1=4
    -s2="ab", n2=2
    -
    -Return:
    -2
    +

    We define str = [s, n] as the string str which consists of the string s concatenated n times.

    + +
      +
    • For example, str == ["abc", 3] =="abcabcabc".
    • +
    + +

    We define that string s1 can be obtained from string s2 if we can remove some characters from s2 such that it becomes s1.

    + +
      +
    • For example, s1 = "abc" can be obtained from s2 = "abdbec" based on our definition by removing the bolded underlined characters.
    • +
    + +

    You are given two strings s1 and s2 and two integers n1 and n2. You have the two strings str1 = [s1, n1] and str2 = [s2, n2].

    + +

    Return the maximum integer m such that str = [str2, m] can be obtained from str1.

    + +

     

    +

    Example 1:

    +
    Input: s1 = "acb", n1 = 4, s2 = "ab", n2 = 2
    +Output: 2
    +

    Example 2:

    +
    Input: s1 = "acb", n1 = 1, s2 = "acb", n2 = 1
    +Output: 1
     
    -

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= s1.length, s2.length <= 100
    • +
    • s1 and s2 consist of lowercase English letters.
    • +
    • 1 <= n1, n2 <= 106
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/day-of-the-week/README.md b/problems/day-of-the-week/README.md index a5107132f..c4ce778b3 100644 --- a/problems/day-of-the-week/README.md +++ b/problems/day-of-the-week/README.md @@ -43,7 +43,7 @@

    Constraints:

      -
    • The given dates are valid dates between the years 1971 and 2100.
    • +
    • The given dates are valid dates between the years 1971 and 2100.
    ### Related Topics diff --git a/problems/day-of-the-year/README.md b/problems/day-of-the-year/README.md index d023c8209..170b733a6 100644 --- a/problems/day-of-the-year/README.md +++ b/problems/day-of-the-year/README.md @@ -11,7 +11,7 @@ ## [1154. Day of the Year (Easy)](https://leetcode.com/problems/day-of-the-year "一年中的第几天") -

    Given a string date representing a Gregorian calendar date formatted as YYYY-MM-DD, return the day number of the year.

    +

    Given a string date representing a Gregorian calendar date formatted as YYYY-MM-DD, return the day number of the year.

     

    Example 1:

    diff --git a/problems/destination-city/README.md b/problems/destination-city/README.md index 76d0c3b81..b49bec8e3 100644 --- a/problems/destination-city/README.md +++ b/problems/destination-city/README.md @@ -11,7 +11,7 @@ ## [1436. Destination City (Easy)](https://leetcode.com/problems/destination-city "旅行终点站") -

    You are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi. Return the destination city, that is, the city without any path outgoing to another city.

    +

    You are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi. Return the destination city, that is, the city without any path outgoing to another city.

    It is guaranteed that the graph of paths forms a line without any loop, therefore, there will be exactly one destination city.

    @@ -50,9 +50,9 @@ Clearly the destination city is "A".
    • 1 <= paths.length <= 100
    • paths[i].length == 2
    • -
    • 1 <= cityAi.length, cityBi.length <= 10
    • -
    • cityA!= cityBi
    • -
    • All strings consist of lowercase and uppercase English letters and the space character.
    • +
    • 1 <= cityAi.length, cityBi.length <= 10
    • +
    • cityAi != cityBi
    • +
    • All strings consist of lowercase and uppercase English letters and the space character.
    ### Related Topics diff --git a/problems/detect-capital/README.md b/problems/detect-capital/README.md index 4489feff6..203f2448a 100644 --- a/problems/detect-capital/README.md +++ b/problems/detect-capital/README.md @@ -11,38 +11,31 @@ ## [520. Detect Capital (Easy)](https://leetcode.com/problems/detect-capital "检测大写字母") -

    Given a word, you need to judge whether the usage of capitals in it is right or not.

    -

    We define the usage of capitals in a word to be right when one of the following cases holds:

    -
      -
    1. All letters in this word are capitals, like "USA".
    2. -
    3. All letters in this word are not capitals, like "leetcode".
    4. -
    5. Only the first letter in this word is capital, like "Google".
    6. -
    -Otherwise, we define that this word doesn't use capitals in a right way. - -

     

    - -

    Example 1:

    +
      +
    • All letters in this word are capitals, like "USA".
    • +
    • All letters in this word are not capitals, like "leetcode".
    • +
    • Only the first letter in this word is capital, like "Google".
    • +
    -
    -Input: "USA"
    -Output: True
    -
    +

    Given a string word, return true if the usage of capitals in it is right.

     

    - -

    Example 2:

    - -
    -Input: "FlaG"
    -Output: False
    +

    Example 1:

    +
    Input: word = "USA"
    +Output: true
    +

    Example 2:

    +
    Input: word = "FlaG"
    +Output: false
     
    -

     

    +

    Constraints:

    -

    Note: The input will be a non-empty word consisting of uppercase and lowercase latin letters.

    +
      +
    • 1 <= word.length <= 100
    • +
    • word consists of lowercase and uppercase English letters.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/di-string-match/README.md b/problems/di-string-match/README.md index deb7c3805..ccaa97583 100644 --- a/problems/di-string-match/README.md +++ b/problems/di-string-match/README.md @@ -18,7 +18,7 @@
  • s[i] == 'D' if perm[i] > perm[i + 1].
  • -

    Given a string s, reconstruct the permutation perm and return it. If there are multiple valid permutations perm, return any of them.

    +

    Given a string s, reconstruct the permutation perm and return it. If there are multiple valid permutations perm, return any of them.

     

    Example 1:

    diff --git a/problems/diagonal-traverse/README.md b/problems/diagonal-traverse/README.md index 85827a28b..a0053caa0 100644 --- a/problems/diagonal-traverse/README.md +++ b/problems/diagonal-traverse/README.md @@ -11,28 +11,30 @@ ## [498. Diagonal Traverse (Medium)](https://leetcode.com/problems/diagonal-traverse "对角线遍历") -

    Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image.

    +

    Given an m x n matrix mat, return an array of all the elements of the array in a diagonal order.

     

    - -

    Example:

    - +

    Example 1:

    +
    -Input:
    -[
    - [ 1, 2, 3 ],
    - [ 4, 5, 6 ],
    - [ 7, 8, 9 ]
    -]
    +Input: mat = [[1,2,3],[4,5,6],[7,8,9]]
    +Output: [1,2,4,7,5,3,6,8,9]
    +
    -Output: [1,2,4,7,5,3,6,8,9] +

    Example 2:

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

     

    - -

    Note:

    - -

    The total number of elements of the given matrix will not exceed 10,000.

    +

    Constraints:

    + +
      +
    • m == mat.length
    • +
    • n == mat[i].length
    • +
    • 1 <= m, n <= 104
    • +
    • 1 <= m * n <= 104
    • +
    • -105 <= mat[i][j] <= 105
    • +
    diff --git a/problems/element-appearing-more-than-25-in-sorted-array/README.md b/problems/element-appearing-more-than-25-in-sorted-array/README.md index 52bdccd5e..8ed66371b 100644 --- a/problems/element-appearing-more-than-25-in-sorted-array/README.md +++ b/problems/element-appearing-more-than-25-in-sorted-array/README.md @@ -11,21 +11,29 @@ ## [1287. Element Appearing More Than 25% In Sorted Array (Easy)](https://leetcode.com/problems/element-appearing-more-than-25-in-sorted-array "有序数组中出现次数超过25%的元素") -

    Given an integer array sorted in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time.

    - -

    Return that integer.

    +

    Given an integer array sorted in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.

     

    Example 1:

    -
    Input: arr = [1,2,2,6,6,6,6,7,10]
    +
    +
    +Input: arr = [1,2,2,6,6,6,6,7,10]
     Output: 6
     
    + +

    Example 2:

    + +
    +Input: arr = [1,1]
    +Output: 1
    +
    +

     

    Constraints:

      -
    • 1 <= arr.length <= 10^4
    • -
    • 0 <= arr[i] <= 10^5
    • +
    • 1 <= arr.length <= 104
    • +
    • 0 <= arr[i] <= 105
    ### Related Topics diff --git a/problems/employee-importance/README.md b/problems/employee-importance/README.md index 4ff109f56..6e9c218f9 100644 --- a/problems/employee-importance/README.md +++ b/problems/employee-importance/README.md @@ -41,4 +41,4 @@ Employee 1 has importance value 5, and he has two direct subordinates: employee [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions - 1. [Nested List Weight Sum](../nested-list-weight-sum) (Easy) + 1. [Nested List Weight Sum](../nested-list-weight-sum) (Medium) diff --git a/problems/erect-the-fence/README.md b/problems/erect-the-fence/README.md index 4ca2c2779..4f2ac2dc2 100644 --- a/problems/erect-the-fence/README.md +++ b/problems/erect-the-fence/README.md @@ -11,41 +11,36 @@ ## [587. Erect the Fence (Hard)](https://leetcode.com/problems/erect-the-fence "安装栅栏") -

    There are some trees, where each tree is represented by (x,y) coordinate in a two-dimensional garden. Your job is to fence the entire garden using the minimum length of rope as it is expensive. The garden is well fenced only if all the trees are enclosed. Your task is to help find the coordinates of trees which are exactly located on the fence perimeter.

    +

    You are given an array trees where trees[i] = [xi, yi] represents the location of a tree in the garden.

    -

     

    +

    You are asked to fence the entire garden using the minimum length of rope as it is expensive. The garden is well fenced only if all the trees are enclosed.

    -

    Example 1:

    +

    Return the coordinates of trees that are exactly located on the fence perimeter.

    +

     

    +

    Example 1:

    +
    -Input: [[1,1],[2,2],[2,0],[2,4],[3,3],[4,2]]
    -Output: [[1,1],[2,0],[4,2],[3,3],[2,4]]
    -Explanation:
    -
    +Input: points = [[1,1],[2,2],[2,0],[2,4],[3,3],[4,2]]
    +Output: [[1,1],[2,0],[3,3],[2,4],[4,2]]
     
    -

    Example 2:

    - +

    Example 2:

    +
    -Input: [[1,2],[2,2],[4,2]]
    -Output: [[1,2],[2,2],[4,2]]
    -Explanation:
    -
    -Even you only have trees in a line, you need to use rope to enclose them. 
    +Input: points = [[1,2],[2,2],[4,2]]
    +Output: [[4,2],[2,2],[1,2]]
     

     

    - -

    Note:

    - -
      -
    1. All trees should be enclosed together. You cannot cut the rope to enclose trees that will separate them in more than one group.
    2. -
    3. All input integers will range from 0 to 100.
    4. -
    5. The garden has at least one tree.
    6. -
    7. All coordinates are distinct.
    8. -
    9. Input points have NO order. No order required for output.
    10. -
    11. input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.
    12. -
    +

    Constraints:

    + +
      +
    • 1 <= points.length <= 3000
    • +
    • points[i].length == 2
    • +
    • 0 <= xi, yi <= 100
    • +
    • All the given points are unique.
    • +
    ### Related Topics [[Geometry](../../tag/geometry/README.md)] diff --git a/problems/faulty-sensor/README.md b/problems/faulty-sensor/README.md new file mode 100644 index 000000000..99d72b8fc --- /dev/null +++ b/problems/faulty-sensor/README.md @@ -0,0 +1,33 @@ + + + + + + + +[< Previous](../finding-mk-average "Finding MK Average") +                 +[Next >](../minimum-operations-to-make-the-array-increasing "Minimum Operations to Make the Array Increasing") + +## [1826. Faulty Sensor (Easy)](https://leetcode.com/problems/faulty-sensor "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Check for a common prefix of the two arrays. +
    + +
    +Hint 2 +After this common prefix, there should be one array similar to the other but shifted by one. +
    + +
    +Hint 3 +If both arrays can be shifted, return -1. +
    diff --git a/problems/find-all-anagrams-in-a-string/README.md b/problems/find-all-anagrams-in-a-string/README.md index bb7452d0b..c8cca88b0 100644 --- a/problems/find-all-anagrams-in-a-string/README.md +++ b/problems/find-all-anagrams-in-a-string/README.md @@ -11,40 +11,37 @@ ## [438. Find All Anagrams in a String (Medium)](https://leetcode.com/problems/find-all-anagrams-in-a-string "找到字符串中所有字母异位词") -

    Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.

    +

    Given two strings s and p, return an array of all the start indices of p's anagrams in s. You may return the answer in any order.

    -

    Strings consists of lowercase English letters only and the length of both strings s and p will not be larger than 20,100.

    +

     

    +

    Example 1:

    -

    The order of output does not matter.

    - -

    Example 1:

    -Input:
    -s: "cbaebabacd" p: "abc"
    -
    -Output:
    -[0, 6]
    -
    -Explanation:
    -The substring with start index = 0 is "cba", which is an anagram of "abc".
    -The substring with start index = 6 is "bac", which is an anagram of "abc".
    +Input: s = "cbaebabacd", p = "abc"
    +Output: [0,6]
    +Explanation:
    +The substring with start index = 0 is "cba", which is an anagram of "abc".
    +The substring with start index = 6 is "bac", which is an anagram of "abc".
     
    -

    -

    Example 2: +

    Example 2:

    +
    -Input:
    -s: "abab" p: "ab"
    +Input: s = "abab", p = "ab"
    +Output: [0,1,2]
    +Explanation:
    +The substring with start index = 0 is "ab", which is an anagram of "ab".
    +The substring with start index = 1 is "ba", which is an anagram of "ab".
    +The substring with start index = 2 is "ab", which is an anagram of "ab".
    +
    -Output: -[0, 1, 2] +

     

    +

    Constraints:

    -Explanation: -The substring with start index = 0 is "ab", which is an anagram of "ab". -The substring with start index = 1 is "ba", which is an anagram of "ab". -The substring with start index = 2 is "ab", which is an anagram of "ab". -
    -

    +
      +
    • 1 <= s.length, p.length <= 3 * 104
    • +
    • s and p consist of lowercase English letters.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/find-all-duplicates-in-an-array/README.md b/problems/find-all-duplicates-in-an-array/README.md index 9977ff59a..43b541d9d 100644 --- a/problems/find-all-duplicates-in-an-array/README.md +++ b/problems/find-all-duplicates-in-an-array/README.md @@ -11,20 +11,31 @@ ## [442. Find All Duplicates in an Array (Medium)](https://leetcode.com/problems/find-all-duplicates-in-an-array "数组中重复的数据") -

    Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.

    - -

    Find all the elements that appear twice in this array.

    - -

    Could you do it without extra space and in O(n) runtime?

    -

    -

    Example:
    -

    -Input:
    -[4,3,2,7,8,2,3,1]
    -
    -Output:
    -[2,3]
    +

    Given an integer array nums of length n where all the integers of nums are in the range [1, n] and each integer appears once or twice, return an array of all the integers that appears twice.

    + +

     

    +

    Example 1:

    +
    Input: nums = [4,3,2,7,8,2,3,1]
    +Output: [2,3]
    +

    Example 2:

    +
    Input: nums = [1,1,2]
    +Output: [1]
    +

    Example 3:

    +
    Input: nums = [1]
    +Output: []
     
    +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= nums[i] <= n
    • +
    • Each element in nums appears once or twice.
    • +
    + +

     

    +

    Follow up: Could you do it without extra space and in O(n) runtime?

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/find-all-good-strings/README.md b/problems/find-all-good-strings/README.md index d1f1b7e4b..2cf55fc53 100644 --- a/problems/find-all-good-strings/README.md +++ b/problems/find-all-good-strings/README.md @@ -11,9 +11,9 @@ ## [1397. Find All Good Strings (Hard)](https://leetcode.com/problems/find-all-good-strings "找到所有好字符串") -

    Given the strings s1 and s2 of size n, and the string evil. Return the number of good strings.

    +

    Given the strings s1 and s2 of size n and the string evil, return the number of good strings.

    -

    A good string has size n, it is alphabetically greater than or equal to s1, it is alphabetically smaller than or equal to s2, and it does not contain the string evil as a substring. Since the answer can be a huge number, return this modulo 10^9 + 7.

    +

    A good string has size n, it is alphabetically greater than or equal to s1, it is alphabetically smaller than or equal to s2, and it does not contain the string evil as a substring. Since the answer can be a huge number, return this modulo 109 + 7.

     

    Example 1:

    diff --git a/problems/find-customers-with-positive-revenue-this-year/README.md b/problems/find-customers-with-positive-revenue-this-year/README.md new file mode 100644 index 000000000..82eba55cd --- /dev/null +++ b/problems/find-customers-with-positive-revenue-this-year/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../maximum-number-of-accepted-invitations "Maximum Number of Accepted Invitations") +                 +[Next >](../sign-of-the-product-of-an-array "Sign of the Product of an Array") + +## [1821. Find Customers With Positive Revenue this Year (Easy)](https://leetcode.com/problems/find-customers-with-positive-revenue-this-year "") + + diff --git a/problems/find-customers-with-positive-revenue-this-year/mysql_schemas.sql b/problems/find-customers-with-positive-revenue-this-year/mysql_schemas.sql new file mode 100644 index 000000000..3f9c8999d --- /dev/null +++ b/problems/find-customers-with-positive-revenue-this-year/mysql_schemas.sql @@ -0,0 +1,9 @@ +Create table If Not Exists Customers (customer_id int, year int, revenue int); +Truncate table Customers; +insert into Customers (customer_id, year, revenue) values ('1', '2018', '50'); +insert into Customers (customer_id, year, revenue) values ('1', '2021', '30'); +insert into Customers (customer_id, year, revenue) values ('1', '2020', '70'); +insert into Customers (customer_id, year, revenue) values ('2', '2021', '-50'); +insert into Customers (customer_id, year, revenue) values ('3', '2018', '10'); +insert into Customers (customer_id, year, revenue) values ('3', '2016', '50'); +insert into Customers (customer_id, year, revenue) values ('4', '2021', '20'); diff --git a/problems/find-the-closest-palindrome/README.md b/problems/find-the-closest-palindrome/README.md index 8a6121526..66e1f6384 100644 --- a/problems/find-the-closest-palindrome/README.md +++ b/problems/find-the-closest-palindrome/README.md @@ -11,23 +11,35 @@ ## [564. Find the Closest Palindrome (Hard)](https://leetcode.com/problems/find-the-closest-palindrome "寻找最近的回文数") -

    Given an integer n, find the closest integer (not including itself), which is a palindrome.

    +

    Given a string n representing an integer, return the closest integer (not including itself), which is a palindrome. If there is a tie, return the smaller one.

    -

    The 'closest' is defined as absolute difference minimized between two integers.

    +

    The closest is defined as the absolute difference minimized between two integers.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: "123"
    -Output: "121"
    +Input: n = "123"
    +Output: "121"
     
    -

    - -

    Note:
    -

      -
    1. The input n is a positive integer represented by string, whose length will not exceed 18.
    2. -
    3. If there is a tie, return the smaller one as answer.
    4. -
    -

    + +

    Example 2:

    + +
    +Input: n = "1"
    +Output: "0"
    +Explanation: 0 and 2 are the closest palindromes but we return the smallest which is 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n.length <= 18
    • +
    • n consists of only digits.
    • +
    • n does not have leading zeros.
    • +
    • n is representing an integer in the range [1, 1018 - 1].
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/find-the-winner-of-the-circular-game/README.md b/problems/find-the-winner-of-the-circular-game/README.md new file mode 100644 index 000000000..3c844799e --- /dev/null +++ b/problems/find-the-winner-of-the-circular-game/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../sign-of-the-product-of-an-array "Sign of the Product of an Array") +                 +[Next >](../minimum-sideway-jumps "Minimum Sideway Jumps") + +## [1823. Find the Winner of the Circular Game (Medium)](https://leetcode.com/problems/find-the-winner-of-the-circular-game "找出游戏的获胜者") + +

    There are n friends that are playing a game. The friends are sitting in a circle and are numbered from 1 to n in clockwise order. More formally, moving clockwise from the ith friend brings you to the (i+1)th friend for 1 <= i < n, and moving clockwise from the nth friend brings you to the 1st friend.

    + +

    The rules of the game are as follows:

    + +
      +
    1. Start at the 1st friend.
    2. +
    3. Count the next k friends in the clockwise direction including the friend you started at. The counting wraps around the circle and may count some friends more than once.
    4. +
    5. The last friend you counted leaves the circle and loses the game.
    6. +
    7. If there is still more than one friend in the circle, go back to step 2 starting from the friend immediately clockwise of the friend who just lost and repeat.
    8. +
    9. Else, the last friend in the circle wins the game.
    10. +
    + +

    Given the number of friends, n, and an integer k, return the winner of the game.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 5, k = 2
    +Output: 3
    +Explanation: Here are the steps of the game:
    +1) Start at friend 1.
    +2) Count 2 friends clockwise, which are friends 1 and 2.
    +3) Friend 2 leaves the circle. Next start is friend 3.
    +4) Count 2 friends clockwise, which are friends 3 and 4.
    +5) Friend 4 leaves the circle. Next start is friend 5.
    +6) Count 2 friends clockwise, which are friends 5 and 1.
    +7) Friend 1 leaves the circle. Next start is friend 3.
    +8) Count 2 friends clockwise, which are friends 3 and 5.
    +9) Friend 5 leaves the circle. Only friend 3 is left, so they are the winner.
    + +

    Example 2:

    + +
    +Input: n = 6, k = 5
    +Output: 1
    +Explanation: The friends leave in this order: 5, 4, 6, 2, 3. The winner is friend 1.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= n <= 500
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Simulate the process. +
    + +
    +Hint 2 +Maintain in a circular list the people who are still in the circle and the current person you are standing at. +
    + +
    +Hint 3 +In each turn, count k people and remove the last person from the list. +
    diff --git a/problems/find-total-time-spent-by-each-employee/README.md b/problems/find-total-time-spent-by-each-employee/README.md index 3202167f1..6c471c2c2 100644 --- a/problems/find-total-time-spent-by-each-employee/README.md +++ b/problems/find-total-time-spent-by-each-employee/README.md @@ -9,6 +9,6 @@                  [Next >](../maximum-number-of-balls-in-a-box "Maximum Number of Balls in a Box") -## [1741. Find Total Time Spent by Each Employee (Easy)](https://leetcode.com/problems/find-total-time-spent-by-each-employee "") +## [1741. Find Total Time Spent by Each Employee (Easy)](https://leetcode.com/problems/find-total-time-spent-by-each-employee "查找每个员工花费的总时间") diff --git a/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md b/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md index b750a78c1..6a193fa5a 100644 --- a/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md +++ b/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md @@ -13,9 +13,9 @@

    Given an array of integers arr and an integer target.

    -

    You have to find two non-overlapping sub-arrays of arr each with sum equal target. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is minimum.

    +

    You have to find two non-overlapping sub-arrays of arr each with a sum equal target. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is minimum.

    -

    Return the minimum sum of the lengths of the two required sub-arrays, or return -1 if you cannot find such two sub-arrays.

    +

    Return the minimum sum of the lengths of the two required sub-arrays, or return -1 if you cannot find such two sub-arrays.

     

    Example 1:

    @@ -62,9 +62,9 @@

    Constraints:

      -
    • 1 <= arr.length <= 10^5
    • +
    • 1 <= arr.length <= 105
    • 1 <= arr[i] <= 1000
    • -
    • 1 <= target <= 10^8
    • +
    • 1 <= target <= 108
    ### Related Topics diff --git a/problems/find-xor-sum-of-all-pairs-bitwise-and/README.md b/problems/find-xor-sum-of-all-pairs-bitwise-and/README.md new file mode 100644 index 000000000..283ea5573 --- /dev/null +++ b/problems/find-xor-sum-of-all-pairs-bitwise-and/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../single-threaded-cpu "Single-Threaded CPU") +                 +[Next >](../remove-duplicates-from-an-unsorted-linked-list "Remove Duplicates From an Unsorted Linked List") + +## [1835. Find XOR Sum of All Pairs Bitwise AND (Hard)](https://leetcode.com/problems/find-xor-sum-of-all-pairs-bitwise-and "所有数对按位与结果的异或和") + +

    The XOR sum of a list is the bitwise XOR of all its elements. If the list only contains one element, then its XOR sum will be equal to this element.

    + +
      +
    • For example, the XOR sum of [1,2,3,4] is equal to 1 XOR 2 XOR 3 XOR 4 = 4, and the XOR sum of [3] is equal to 3.
    • +
    + +

    You are given two 0-indexed arrays arr1 and arr2 that consist only of non-negative integers.

    + +

    Consider the list containing the result of arr1[i] AND arr2[j] (bitwise AND) for every (i, j) pair where 0 <= i < arr1.length and 0 <= j < arr2.length.

    + +

    Return the XOR sum of the aforementioned list.

    + +

     

    +

    Example 1:

    + +
    +Input: arr1 = [1,2,3], arr2 = [6,5]
    +Output: 0
    +Explanation: The list = [1 AND 6, 1 AND 5, 2 AND 6, 2 AND 5, 3 AND 6, 3 AND 5] = [0,1,2,0,2,1].
    +The XOR sum = 0 XOR 1 XOR 2 XOR 0 XOR 2 XOR 1 = 0.
    +
    + +

    Example 2:

    + +
    +Input: arr1 = [12], arr2 = [4]
    +Output: 4
    +Explanation: The list = [12 AND 4] = [4]. The XOR sum = 4.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr1.length, arr2.length <= 105
    • +
    • 0 <= arr1[i], arr2[j] <= 109
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Think about (a&b) ^ (a&c). Can you simplify this expression? +
    + +
    +Hint 2 +It is equal to a&(b^c). Then, (arr1[i]&arr2[0])^(arr1[i]&arr2[1]).. = arr1[i]&(arr2[0]^arr2[1]^arr[2]...). +
    + +
    +Hint 3 +Let arr2XorSum = (arr2[0]^arr2[1]^arr2[2]...), arr1XorSum = (arr1[0]^arr1[1]^arr1[2]...) so the final answer is (arr2XorSum&arr1[0]) ^ (arr2XorSum&arr1[1]) ^ (arr2XorSum&arr1[2]) ^ ... = arr2XorSum & arr1XorSum. +
    diff --git a/problems/finding-mk-average/README.md b/problems/finding-mk-average/README.md new file mode 100644 index 000000000..2b1fc55c2 --- /dev/null +++ b/problems/finding-mk-average/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../minimum-sideway-jumps "Minimum Sideway Jumps") +                 +[Next >](../faulty-sensor "Faulty Sensor") + +## [1825. Finding MK Average (Hard)](https://leetcode.com/problems/finding-mk-average "求出 MK 平均值") + +

    You are given two integers, m and k, and a stream of integers. You are tasked to implement a data structure that calculates the MKAverage for the stream.

    + +

    The MKAverage can be calculated using these steps:

    + +
      +
    1. If the number of the elements in the stream is less than m you should consider the MKAverage to be -1. Otherwise, copy the last m elements of the stream to a separate container.
    2. +
    3. Remove the smallest k elements and the largest k elements from the container.
    4. +
    5. Calculate the average value for the rest of the elements rounded down to the nearest integer.
    6. +
    + +

    Implement the MKAverage class:

    + +
      +
    • MKAverage(int m, int k) Initializes the MKAverage object with an empty stream and the two integers m and k.
    • +
    • void addElement(int num) Inserts a new element num into the stream.
    • +
    • int calculateMKAverage() Calculates and returns the MKAverage for the current stream rounded down to the nearest integer.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input
    +["MKAverage", "addElement", "addElement", "calculateMKAverage", "addElement", "calculateMKAverage", "addElement", "addElement", "addElement", "calculateMKAverage"]
    +[[3, 1], [3], [1], [], [10], [], [5], [5], [5], []]
    +Output
    +[null, null, null, -1, null, 3, null, null, null, 5]
    +
    +Explanation
    +MKAverage obj = new MKAverage(3, 1); 
    +obj.addElement(3);        // current elements are [3]
    +obj.addElement(1);        // current elements are [3,1]
    +obj.calculateMKAverage(); // return -1, because m = 3 and only 2 elements exist.
    +obj.addElement(10);       // current elements are [3,1,10]
    +obj.calculateMKAverage(); // The last 3 elements are [3,1,10].
    +                          // After removing smallest and largest 1 element the container will be [3].
    +                          // The average of [3] equals 3/1 = 3, return 3
    +obj.addElement(5);        // current elements are [3,1,10,5]
    +obj.addElement(5);        // current elements are [3,1,10,5,5]
    +obj.addElement(5);        // current elements are [3,1,10,5,5,5]
    +obj.calculateMKAverage(); // The last 3 elements are [5,5,5].
    +                          // After removing smallest and largest 1 element the container will be [5].
    +                          // The average of [5] equals 5/1 = 5, return 5
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= m <= 105
    • +
    • 1 <= k*2 < m
    • +
    • 1 <= num <= 105
    • +
    • At most 105 calls will be made to addElement and calculateMKAverage.
    • +
    + +### Related Topics + [[Heap](../../tag/heap/README.md)] + [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] + +### Hints +
    +Hint 1 +At each query, try to save and update the sum of the elements needed to calculate MKAverage. +
    + +
    +Hint 2 +You can use BSTs for fast insertion and deletion of the elements. +
    diff --git a/problems/first-missing-positive/README.md b/problems/first-missing-positive/README.md index 6795f0dd1..9c8ad497b 100644 --- a/problems/first-missing-positive/README.md +++ b/problems/first-missing-positive/README.md @@ -28,7 +28,7 @@

    Constraints:

      -
    • 0 <= nums.length <= 300
    • +
    • 1 <= nums.length <= 300
    • -231 <= nums[i] <= 231 - 1
    diff --git a/problems/fizz-buzz/README.md b/problems/fizz-buzz/README.md index cae237242..1c28531dc 100644 --- a/problems/fizz-buzz/README.md +++ b/problems/fizz-buzz/README.md @@ -11,31 +11,29 @@ ## [412. Fizz Buzz (Easy)](https://leetcode.com/problems/fizz-buzz "Fizz Buzz") -

    Write a program that outputs the string representation of numbers from 1 to n.

    +

    Given an integer n, return a string array answer (1-indexed) where:

    -

    But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”.

    +
      +
    • answer[i] == "FizzBuzz" if i is divisible by 3 and 5.
    • +
    • answer[i] == "Fizz" if i is divisible by 3.
    • +
    • answer[i] == "Buzz" if i is divisible by 5.
    • +
    • answer[i] == i if non of the above conditions are true.
    • +
    -

    Example: -

    -n = 15,
    -
    -Return:
    -[
    -    "1",
    -    "2",
    -    "Fizz",
    -    "4",
    -    "Buzz",
    -    "Fizz",
    -    "7",
    -    "8",
    -    "Fizz",
    -    "Buzz",
    -    "11",
    -    "Fizz",
    -    "13",
    -    "14",
    -    "FizzBuzz"
    -]
    +

     

    +

    Example 1:

    +
    Input: n = 3
    +Output: ["1","2","Fizz"]
    +

    Example 2:

    +
    Input: n = 5
    +Output: ["1","2","Fizz","4","Buzz"]
    +

    Example 3:

    +
    Input: n = 15
    +Output: ["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"]
     
    -

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 104
    • +
    diff --git a/problems/freedom-trail/README.md b/problems/freedom-trail/README.md index f565e1c45..7063a7b2d 100644 --- a/problems/freedom-trail/README.md +++ b/problems/freedom-trail/README.md @@ -11,41 +11,47 @@ ## [514. Freedom Trail (Hard)](https://leetcode.com/problems/freedom-trail "自由之路") -

    In the video game Fallout 4, the quest "Road to Freedom" requires players to reach a metal dial called the "Freedom Trail Ring", and use the dial to spell a specific keyword in order to open the door.

    +

    In the video game Fallout 4, the quest "Road to Freedom" requires players to reach a metal dial called the "Freedom Trail Ring" and use the dial to spell a specific keyword to open the door.

    -

    Given a string ring, which represents the code engraved on the outer ring and another string key, which represents the keyword needs to be spelled. You need to find the minimum number of steps in order to spell all the characters in the keyword.

    +

    Given a string ring that represents the code engraved on the outer ring and another string key that represents the keyword that needs to be spelled, return the minimum number of steps to spell all the characters in the keyword.

    -

    Initially, the first character of the ring is aligned at 12:00 direction. You need to spell all the characters in the string key one by one by rotating the ring clockwise or anticlockwise to make each character of the string key aligned at 12:00 direction and then by pressing the center button.

    +

    Initially, the first character of the ring is aligned at the "12:00" direction. You should spell all the characters in key one by one by rotating ring clockwise or anticlockwise to make each character of the string key aligned at the "12:00" direction and then by pressing the center button.

    -

    At the stage of rotating the ring to spell the key character key[i]:

    +

    At the stage of rotating the ring to spell the key character key[i]:

      -
    1. You can rotate the ring clockwise or anticlockwise one place, which counts as 1 step. The final purpose of the rotation is to align one of the string ring's characters at the 12:00 direction, where this character must equal to the character key[i].
    2. -
    3. If the character key[i] has been aligned at the 12:00 direction, you need to press the center button to spell, which also counts as 1 step. After the pressing, you could begin to spell the next character in the key (next stage), otherwise, you've finished all the spelling.
    4. +
    5. You can rotate the ring clockwise or anticlockwise by one place, which counts as one step. The final purpose of the rotation is to align one of ring's characters at the "12:00" direction, where this character must equal key[i].
    6. +
    7. If the character key[i] has been aligned at the "12:00" direction, press the center button to spell, which also counts as one step. After the pressing, you could begin to spell the next character in the key (next stage). Otherwise, you have finished all the spelling.
    -

    Example:

    - -
    -  - +

     

    +

    Example 1:

    +
    -Input: ring = "godding", key = "gd"
    -Output: 4
    -Explanation:
    +Input: ring = "godding", key = "gd"
    +Output: 4
    +Explanation:
     For the first key character 'g', since it is already in place, we just need 1 step to spell this character. 
     For the second key character 'd', we need to rotate the ring "godding" anticlockwise by two steps to make it become "ddinggo".
     Also, we need 1 more step for spelling.
     So the final output is 4.
     
    -

    Note:

    +

    Example 2:

    -
      -
    1. Length of both ring and key will be in range 1 to 100.
    2. -
    3. There are only lowercase letters in both strings and might be some duplcate characters in both strings.
    4. -
    5. It's guaranteed that string key could always be spelled by rotating the string ring.
    6. -
    +
    +Input: ring = "godding", key = "godding"
    +Output: 13
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= ring.length, key.length <= 100
    • +
    • ring and key consist of only lower case English letters.
    • +
    • It is guaranteed that key could always be spelled by rotating ring.
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/frequency-of-the-most-frequent-element/README.md b/problems/frequency-of-the-most-frequent-element/README.md new file mode 100644 index 000000000..d8ae57fc8 --- /dev/null +++ b/problems/frequency-of-the-most-frequent-element/README.md @@ -0,0 +1,68 @@ + + + + + + + +[< Previous](../sum-of-digits-in-base-k "Sum of Digits in Base K") +                 +[Next >](../longest-substring-of-all-vowels-in-order "Longest Substring Of All Vowels in Order") + +## [1838. Frequency of the Most Frequent Element (Medium)](https://leetcode.com/problems/frequency-of-the-most-frequent-element "最高频元素的频数") + +

    The frequency of an element is the number of times it occurs in an array.

    + +

    You are given an integer array nums and an integer k. In one operation, you can choose an index of nums and increment the element at that index by 1.

    + +

    Return the maximum possible frequency of an element after performing at most k operations.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,4], k = 5
    +Output: 3
    +Explanation: Increment the first element three times and the second element two times to make nums = [4,4,4].
    +4 has a frequency of 3.
    + +

    Example 2:

    + +
    +Input: nums = [1,4,8,13], k = 5
    +Output: 2
    +Explanation: There are multiple optimal solutions:
    +- Increment the first element three times to make nums = [4,4,8,13]. 4 has a frequency of 2.
    +- Increment the second element four times to make nums = [1,8,8,13]. 8 has a frequency of 2.
    +- Increment the third element five times to make nums = [1,4,13,13]. 13 has a frequency of 2.
    +
    + +

    Example 3:

    + +
    +Input: nums = [3,9,6], k = 2
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 105
    • +
    • 1 <= k <= 105
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Note that you can try all values in a brute force manner and find the maximum frequency of that value. +
    + +
    +Hint 2 +To find the maximum frequency of a value consider the biggest elements smaller than or equal to this value +
    diff --git a/problems/global-and-local-inversions/README.md b/problems/global-and-local-inversions/README.md index e30189aff..fed445e65 100644 --- a/problems/global-and-local-inversions/README.md +++ b/problems/global-and-local-inversions/README.md @@ -11,36 +11,50 @@ ## [775. Global and Local Inversions (Medium)](https://leetcode.com/problems/global-and-local-inversions "全局倒置与局部倒置") -

    We have some permutation A of [0, 1, ..., N - 1], where N is the length of A.

    +

    You are given an integer array nums of length n which represents a permutation of all the integers in the range [0, n - 1].

    -

    The number of (global) inversions is the number of i < j with 0 <= i < j < N and A[i] > A[j].

    +

    The number of global inversions is the number of the different pairs (i, j) where:

    -

    The number of local inversions is the number of i with 0 <= i < N and A[i] > A[i+1].

    +
      +
    • 0 <= i < j < n
    • +
    • nums[i] > nums[j]
    • +
    + +

    The number of local inversions is the number of indices i where:

    + +
      +
    • 0 <= i < n - 1
    • +
    • nums[i] > nums[i + 1]
    • +
    -

    Return true if and only if the number of global inversions is equal to the number of local inversions.

    +

    Return true if the number of global inversions is equal to the number of local inversions.

    +

     

    Example 1:

    -Input: A = [1,0,2]
    +Input: nums = [1,0,2]
     Output: true
    -Explanation: There is 1 global inversion, and 1 local inversion.
    +Explanation: There is 1 global inversion and 1 local inversion.
     

    Example 2:

    -Input: A = [1,2,0]
    +Input: nums = [1,2,0]
     Output: false
    -Explanation: There are 2 global inversions, and 1 local inversion.
    +Explanation: There are 2 global inversions and 1 local inversion.
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • A will be a permutation of [0, 1, ..., A.length - 1].
    • -
    • A will have length in range [1, 5000].
    • -
    • The time limit for this problem has been reduced.
    • +
    • n == nums.length
    • +
    • 1 <= n <= 5000
    • +
    • 0 <= nums[i] < n
    • +
    • All the integers of nums are unique.
    • +
    • nums is a permutation of all the numbers in the range [0, n - 1].
    ### Related Topics diff --git a/problems/grand-slam-titles/README.md b/problems/grand-slam-titles/README.md index cb4e14e5b..ca413cf65 100644 --- a/problems/grand-slam-titles/README.md +++ b/problems/grand-slam-titles/README.md @@ -9,6 +9,6 @@                  [Next >](../check-if-binary-string-has-at-most-one-segment-of-ones "Check if Binary String Has at Most One Segment of Ones") -## [1783. Grand Slam Titles (Medium)](https://leetcode.com/problems/grand-slam-titles "") +## [1783. Grand Slam Titles (Medium)](https://leetcode.com/problems/grand-slam-titles "大满贯数量") diff --git a/problems/grid-illumination/README.md b/problems/grid-illumination/README.md index bbf36b197..fc997ff9a 100644 --- a/problems/grid-illumination/README.md +++ b/problems/grid-illumination/README.md @@ -11,13 +11,15 @@ ## [1001. Grid Illumination (Hard)](https://leetcode.com/problems/grid-illumination "网格照明") -

    You are given a grid of size N x N, and each cell of this grid has a lamp that is initially turned off.

    +

    There is a 2D grid of size N x N where each cell of this grid has a lamp that is initially turned off.

    -

    You are also given an array of lamp positions lamps, where lamps[i] = [rowi, coli] indicates that the lamp at grid[rowi][coli] is turned on. When a lamp is turned on, it illuminates its cell and all other cells in the same row, column, or diagonal.

    +

    You are given a 2D array of lamp positions lamps, where lamps[i] = [rowi, coli] indicates that the lamp at grid[rowi][coli] is turned on. Even if the same lamp is listed more than once, it is turned on.

    -

    Finally, you are given a query array queries, where queries[i] = [rowi, coli]. For the ith query, determine whether grid[rowi][coli] is illuminated or not. After answering the ith query, turn off the lamp at grid[rowi][coli] and its 8 adjacent lamps if they exist. A lamp is adjacent if its cell shares either a side or corner with grid[rowi][coli].

    +

    When a lamp is turned on, it illuminates its cell and all other cells in the same row, column, or diagonal.

    -

    Return an array of integers ans, where ans[i] should be 1 if the lamp in the ith query was illuminated, or 0 if the lamp was not.

    +

    You are also given another 2D array queries, where queries[j] = [rowj, colj]. For the jth query, determine whether grid[rowj][colj] is illuminated or not. After answering the jth query, turn off the lamp at grid[rowj][colj] and its 8 adjacent lamps if they exist. A lamp is adjacent if its cell shares either a side or corner with grid[rowj][colj].

    + +

    Return an array of integers ans, where ans[j] should be 1 if the cell in the jth query was illuminated, or 0 if the lamp was not.

     

    Example 1:

    @@ -52,11 +54,11 @@ The 1st query asks if the lamp at grid[1][0] is illuminated or n
    • 1 <= N <= 109
    • 0 <= lamps.length <= 20000
    • -
    • lamps[i].length == 2
    • -
    • 0 <= lamps[i][j] < N
    • 0 <= queries.length <= 20000
    • -
    • queries[i].length == 2
    • -
    • 0 <= queries[i][j] < N
    • +
    • lamps[i].length == 2
    • +
    • 0 <= rowi, coli < N
    • +
    • queries[j].length == 2
    • +
    • 0 <= rowj, colj < N
    ### Related Topics diff --git a/problems/hamming-distance/README.md b/problems/hamming-distance/README.md index 9c1800a39..1e18c1f93 100644 --- a/problems/hamming-distance/README.md +++ b/problems/hamming-distance/README.md @@ -13,26 +13,34 @@

    The Hamming distance between two integers is the number of positions at which the corresponding bits are different.

    -

    Given two integers x and y, calculate the Hamming distance.

    +

    Given two integers x and y, return the Hamming distance between them.

    -

    Note:
    -0 ≤ x, y < 231. -

    +

     

    +

    Example 1:

    -

    Example:

    -Input: x = 1, y = 4
    -
    -Output: 2
    -
    -Explanation:
    +Input: x = 1, y = 4
    +Output: 2
    +Explanation:
     1   (0 0 0 1)
     4   (0 1 0 0)
            ↑   ↑
    -
     The above arrows point to positions where the corresponding bits are different.
     
    -

    + +

    Example 2:

    + +
    +Input: x = 3, y = 1
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= x, y <= 231 - 1
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/height-checker/README.md b/problems/height-checker/README.md index bb3d22b7b..62c046b17 100644 --- a/problems/height-checker/README.md +++ b/problems/height-checker/README.md @@ -11,11 +11,11 @@ ## [1051. Height Checker (Easy)](https://leetcode.com/problems/height-checker "高度检查器") -

    Students are asked to stand in non-decreasing order of heights for an annual photo.

    +

    A school is trying to take an annual photo of all the students. The students are asked to stand in a single file line in non-decreasing order by height. Let this ordering be represented by the integer array expected where expected[i] is the expected height of the ith student in line.

    -

    Return the minimum number of students that must move in order for all students to be standing in non-decreasing order of height.

    +

    You are given an integer array heights representing the current order that the students are standing in. Each heights[i] is the height of the ith student in line (0-indexed).

    -

    Notice that when a group of students is selected they can reorder in any possible way between themselves and the non selected students remain on their seats.

    +

    Return the number of indices where heights[i] != expected[i].

     

    Example 1:

    @@ -24,11 +24,9 @@ Input: heights = [1,1,4,2,1,3] Output: 3 Explanation: -Current array : [1,1,4,2,1,3] -Target array : [1,1,1,2,3,4] -On index 2 (0-based) we have 4 vs 1 so we have to move this student. -On index 4 (0-based) we have 1 vs 3 so we have to move this student. -On index 5 (0-based) we have 3 vs 4 so we have to move this student. +heights: [1,1,4,2,1,3] +expected: [1,1,1,2,3,4] +Indices 2, 4, and 5 do not match.

    Example 2:

    @@ -36,6 +34,10 @@ On index 5 (0-based) we have 3 vs 4 so we have to move this student.
     Input: heights = [5,1,2,3,4]
     Output: 5
    +Explanation:
    +heights:  [5,1,2,3,4]
    +expected: [1,2,3,4,5]
    +All indices do not match.
     

    Example 3:

    @@ -43,6 +45,10 @@ On index 5 (0-based) we have 3 vs 4 so we have to move this student.
     Input: heights = [1,2,3,4,5]
     Output: 0
    +Explanation:
    +heights:  [1,2,3,4,5]
    +expected: [1,2,3,4,5]
    +All indices match.
     

     

    diff --git a/problems/implement-trie-ii-prefix-tree/README.md b/problems/implement-trie-ii-prefix-tree/README.md index ffa615bb8..6faf69b0a 100644 --- a/problems/implement-trie-ii-prefix-tree/README.md +++ b/problems/implement-trie-ii-prefix-tree/README.md @@ -9,7 +9,7 @@                  [Next >](../number-of-different-integers-in-a-string "Number of Different Integers in a String") -## [1804. Implement Trie II (Prefix Tree) (Medium)](https://leetcode.com/problems/implement-trie-ii-prefix-tree "") +## [1804. Implement Trie II (Prefix Tree) (Medium)](https://leetcode.com/problems/implement-trie-ii-prefix-tree "实现 Trie (前缀树) II") diff --git a/problems/increasing-order-search-tree/README.md b/problems/increasing-order-search-tree/README.md index 6969f0f7f..2cd6630ff 100644 --- a/problems/increasing-order-search-tree/README.md +++ b/problems/increasing-order-search-tree/README.md @@ -9,7 +9,7 @@                  [Next >](../bitwise-ors-of-subarrays "Bitwise ORs of Subarrays") -## [897. Increasing Order Search Tree (Easy)](https://leetcode.com/problems/increasing-order-search-tree "递增顺序查找树") +## [897. Increasing Order Search Tree (Easy)](https://leetcode.com/problems/increasing-order-search-tree "递增顺序搜索树")

    Given the root of a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only one right child.

    diff --git a/problems/increasing-subsequences/README.md b/problems/increasing-subsequences/README.md index 37e0adff8..e77ae6c8b 100644 --- a/problems/increasing-subsequences/README.md +++ b/problems/increasing-subsequences/README.md @@ -11,24 +11,31 @@ ## [491. Increasing Subsequences (Medium)](https://leetcode.com/problems/increasing-subsequences "递增子序列") -

    Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increasing subsequence should be at least 2.

    +

    Given an integer array nums, return all the different possible increasing subsequences of the given array with at least two elements. You may return the answer in any order.

    + +

    The given array may contain duplicates, and two equal integers should also be considered a special case of increasing sequence.

     

    +

    Example 1:

    + +
    +Input: nums = [4,6,7,7]
    +Output: [[4,6],[4,6,7],[4,6,7,7],[4,7],[4,7,7],[6,7],[6,7,7],[7,7]]
    +
    -

    Example:

    +

    Example 2:

    -Input: [4, 6, 7, 7]
    -Output: [[4, 6], [4, 7], [4, 6, 7], [4, 6, 7, 7], [6, 7], [6, 7, 7], [7,7], [4,7,7]]
    +Input: nums = [4,4,3,2,1]
    +Output: [[4,4]]
     

     

    Constraints:

      -
    • The length of the given array will not exceed 15.
    • -
    • The range of integer in the given array is [-100,100].
    • -
    • The given array may contain duplicates, and two equal integers should also be considered as a special case of increasing sequence.
    • +
    • 1 <= nums.length <= 15
    • +
    • -100 <= nums[i] <= 100
    ### Related Topics diff --git a/problems/ipo/README.md b/problems/ipo/README.md index 91afc78e3..861bbe9ef 100644 --- a/problems/ipo/README.md +++ b/problems/ipo/README.md @@ -11,39 +11,48 @@ ## [502. IPO (Hard)](https://leetcode.com/problems/ipo "IPO") -

    -Suppose LeetCode will start its IPO soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the IPO. Since it has limited resources, it can only finish at most k distinct projects before the IPO. Help LeetCode design the best way to maximize its total capital after finishing at most k distinct projects. -

    +

    Suppose LeetCode will start its IPO soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the IPO. Since it has limited resources, it can only finish at most k distinct projects before the IPO. Help LeetCode design the best way to maximize its total capital after finishing at most k distinct projects.

    -

    -You are given several projects. For each project i, it has a pure profit Pi and a minimum capital of Ci is needed to start the corresponding project. Initially, you have W capital. When you finish a project, you will obtain its pure profit and the profit will be added to your total capital. -

    +

    You are given n projects where the ith project has a pure profit profits[i] and a minimum capital of capital[i] is needed to start it.

    -

    -To sum up, pick a list of at most k distinct projects from given projects to maximize your final capital, and output your final maximized capital. -

    +

    Initially, you have w capital. When you finish a project, you will obtain its pure profit and the profit will be added to your total capital.

    + +

    Pick a list of at most k distinct projects from given projects to maximize your final capital, and return the final maximized capital.

    + +

    The answer is guaranteed to fit in a 32-bit signed integer.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: k=2, W=0, Profits=[1,2,3], Capital=[0,1,1].
    +Input: k = 2, w = 0, profits = [1,2,3], capital = [0,1,1]
    +Output: 4
    +Explanation: Since your initial capital is 0, you can only start the project indexed 0.
    +After finishing it you will obtain profit 1 and your capital becomes 1.
    +With capital 1, you can either start the project indexed 1 or the project indexed 2.
    +Since you can choose at most 2 projects, you need to finish the project indexed 2 to get the maximum capital.
    +Therefore, output the final maximized capital, which is 0 + 1 + 3 = 4.
    +
    -Output: 4 +

    Example 2:

    -Explanation: Since your initial capital is 0, you can only start the project indexed 0. - After finishing it you will obtain profit 1 and your capital becomes 1. - With capital 1, you can either start the project indexed 1 or the project indexed 2. - Since you can choose at most 2 projects, you need to finish the project indexed 2 to get the maximum capital. - Therefore, output the final maximized capital, which is 0 + 1 + 3 = 4. +
    +Input: k = 3, w = 0, profits = [1,2,3], capital = [0,1,2]
    +Output: 6
     
    -

    - -

    Note:
    -

      -
    1. You may assume all numbers in the input are non-negative integers.
    2. -
    3. The length of Profits array and Capital array will not exceed 50,000.
    4. -
    5. The answer is guaranteed to fit in a 32-bit signed integer.
    6. -
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= 105
    • +
    • 0 <= w <= 109
    • +
    • n == profits.length
    • +
    • n == capital.length
    • +
    • 1 <= n <= 105
    • +
    • 0 <= profits[i] <= 104
    • +
    • 0 <= capital[i] <= 109
    • +
    ### Related Topics [[Heap](../../tag/heap/README.md)] diff --git a/problems/k-diff-pairs-in-an-array/README.md b/problems/k-diff-pairs-in-an-array/README.md index 8b42bc118..3ec759fea 100644 --- a/problems/k-diff-pairs-in-an-array/README.md +++ b/problems/k-diff-pairs-in-an-array/README.md @@ -13,15 +13,14 @@

    Given an array of integers nums and an integer k, return the number of unique k-diff pairs in the array.

    -

    A k-diff pair is an integer pair (nums[i], nums[j]), where the following are true:

    +

    A k-diff pair is an integer pair (nums[i], nums[j]), where the following are true:

      -
    • 0 <= i, j < nums.length
    • -
    • i != j
    • +
    • 0 <= i < j < nums.length
    • |nums[i] - nums[j]| == k
    -

    Notice that |val| denotes the absolute value of val.

    +

    Notice that |val| denotes the absolute value of val.

     

    Example 1:

    diff --git a/problems/k-th-smallest-in-lexicographical-order/README.md b/problems/k-th-smallest-in-lexicographical-order/README.md index 23765647c..4c72d6345 100644 --- a/problems/k-th-smallest-in-lexicographical-order/README.md +++ b/problems/k-th-smallest-in-lexicographical-order/README.md @@ -11,19 +11,27 @@ ## [440. K-th Smallest in Lexicographical Order (Hard)](https://leetcode.com/problems/k-th-smallest-in-lexicographical-order "字典序的第K小数字") -

    Given integers n and k, find the lexicographically k-th smallest integer in the range from 1 to n.

    +

    Given two integers n and k, return the kth lexicographically smallest integer in the range [1, n].

    -

    Note: 1 ≤ k ≤ n ≤ 109.

    +

     

    +

    Example 1:

    -

    Example:

    -Input:
    -n: 13   k: 2
    +Input: n = 13, k = 2
    +Output: 10
    +Explanation: The lexicographical order is [1, 10, 11, 12, 13, 2, 3, 4, 5, 6, 7, 8, 9], so the second smallest number is 10.
    +
    -Output: -10 +

    Example 2:

    -Explanation: -The lexicographical order is [1, 10, 11, 12, 13, 2, 3, 4, 5, 6, 7, 8, 9], so the second smallest number is 10. +
    +Input: n = 1, k = 1
    +Output: 1
     
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= n <= 109
    • +
    diff --git a/problems/knight-probability-in-chessboard/README.md b/problems/knight-probability-in-chessboard/README.md index aa82f4b46..0de237ddb 100644 --- a/problems/knight-probability-in-chessboard/README.md +++ b/problems/knight-probability-in-chessboard/README.md @@ -11,40 +11,41 @@ ## [688. Knight Probability in Chessboard (Medium)](https://leetcode.com/problems/knight-probability-in-chessboard "“马”在棋盘上的概率") -

    On an NxN chessboard, a knight starts at the r-th row and c-th column and attempts to make exactly K moves. The rows and columns are 0 indexed, so the top-left square is (0, 0), and the bottom-right square is (N-1, N-1).

    - -

    A chess knight has 8 possible moves it can make, as illustrated below. Each move is two squares in a cardinal direction, then one square in an orthogonal direction.

    - -

     

    - -

    - -

     

    +

    On an n x n chessboard, a knight starts at the cell (row, column) and attempts to make exactly k moves. The rows and columns are 0-indexed, so the top-left cell is (0, 0), and the bottom-right cell is (n - 1, n - 1).

    +

    A chess knight has eight possible moves it can make, as illustrated below. Each move is two cells in a cardinal direction, then one cell in an orthogonal direction.

    +

    Each time the knight is to move, it chooses one of eight possible moves uniformly at random (even if the piece would go off the chessboard) and moves there.

    -

    The knight continues moving until it has made exactly K moves or has moved off the chessboard. Return the probability that the knight remains on the board after it has stopped moving.

    +

    The knight continues moving until it has made exactly k moves or has moved off the chessboard.

    -

     

    +

    Return the probability that the knight remains on the board after it has stopped moving.

    -

    Example:

    +

     

    +

    Example 1:

    -Input: 3, 2, 0, 0
    -Output: 0.0625
    -Explanation: There are two moves (to (1,2), (2,1)) that will keep the knight on the board.
    +Input: n = 3, k = 2, row = 0, column = 0
    +Output: 0.06250
    +Explanation: There are two moves (to (1,2), (2,1)) that will keep the knight on the board.
     From each of those positions, there are also two moves that will keep the knight on the board.
     The total probability the knight stays on the board is 0.0625.
     
    -

     

    +

    Example 2:

    + +
    +Input: n = 1, k = 0, row = 0, column = 0
    +Output: 1.00000
    +
    -

    Note:

    +

     

    +

    Constraints:

      -
    • N will be between 1 and 25.
    • -
    • K will be between 0 and 100.
    • -
    • The knight always initially starts on the board.
    • +
    • 1 <= n <= 25
    • +
    • 0 <= k <= 100
    • +
    • 0 <= row, column <= n
    ### Related Topics diff --git a/problems/kth-smallest-element-in-a-sorted-matrix/README.md b/problems/kth-smallest-element-in-a-sorted-matrix/README.md index a057f4b6e..9465bfa82 100644 --- a/problems/kth-smallest-element-in-a-sorted-matrix/README.md +++ b/problems/kth-smallest-element-in-a-sorted-matrix/README.md @@ -39,7 +39,7 @@
  • n == matrix[i].length
  • 1 <= n <= 300
  • -109 <= matrix[i][j] <= 109
  • -
  • All the rows and columns of matrix are guaranteed to be sorted in non-degreasing order.
  • +
  • All the rows and columns of matrix are guaranteed to be sorted in non-decreasing order.
  • 1 <= k <= n2
  • diff --git a/problems/largest-number-at-least-twice-of-others/README.md b/problems/largest-number-at-least-twice-of-others/README.md index 83800b4a8..c1511f223 100644 --- a/problems/largest-number-at-least-twice-of-others/README.md +++ b/problems/largest-number-at-least-twice-of-others/README.md @@ -11,41 +11,37 @@ ## [747. Largest Number At Least Twice of Others (Easy)](https://leetcode.com/problems/largest-number-at-least-twice-of-others "至少是其他数字两倍的最大数") -

    In a given integer array nums, there is always exactly one largest element.

    +

    You are given an integer array nums where the largest integer is unique.

    -

    Find whether the largest element in the array is at least twice as much as every other number in the array.

    - -

    If it is, return the index of the largest element, otherwise return -1.

    +

    Find whether the largest element in the array is at least twice as much as every other number in the array. If it is, return the index of the largest element, otherwise, return -1.

    +

     

    Example 1:

    -Input: nums = [3, 6, 1, 0]
    +Input: nums = [3,6,1,0]
     Output: 1
    -Explanation: 6 is the largest integer, and for every other number in the array x,
    -6 is more than twice as big as x.  The index of value 6 is 1, so we return 1.
    +Explanation: 6 is the largest integer and for every other number in the array x,
    +6 is more than twice as big as x.
    +The index of value 6 is 1, so we return 1.
     
    -

     

    -

    Example 2:

    -Input: nums = [1, 2, 3, 4]
    +Input: nums = [1,2,3,4]
     Output: -1
    -Explanation: 4 isn't at least as big as twice the value of 3, so we return -1.
    +Explanation: 4 is not at least as big as twice the value of 3, so we return -1.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. nums will have a length in the range [1, 50].
    2. -
    3. Every nums[i] will be an integer in the range [0, 99].
    4. -
    - -

     

    +
      +
    • 1 <= nums.length <= 50
    • +
    • 0 <= nums[i] <= 100
    • +
    • The largest element in nums is unique.
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/largest-palindrome-product/README.md b/problems/largest-palindrome-product/README.md index c44be8ef6..7d2cc741d 100644 --- a/problems/largest-palindrome-product/README.md +++ b/problems/largest-palindrome-product/README.md @@ -11,22 +11,27 @@ ## [479. Largest Palindrome Product (Hard)](https://leetcode.com/problems/largest-palindrome-product "最大回文数乘积") -

    Find the largest palindrome made from the product of two n-digit numbers.

    - -

    Since the result could be very large, you should return the largest palindrome mod 1337.

    +

    Given an integer n, return the largest palindromic integer that can be represented as the product of two n-digits integers. Since the answer can be very large, return it modulo 1337.

     

    +

    Example 1:

    -

    Example:

    - -

    Input: 2

    +
    +Input: n = 2
    +Output: 987
    +Explanation: 99 x 91 = 9009, 9009 % 1337 = 987
    +
    -

    Output: 987

    +

    Example 2:

    -

    Explanation: 99 x 91 = 9009, 9009 % 1337 = 987

    +
    +Input: n = 1
    +Output: 9
    +

     

    +

    Constraints:

    -

    Note:

    - -

    The range of n is [1,8].

    +
      +
    • 1 <= n <= 8
    • +
    diff --git a/problems/leetflex-banned-accounts/README.md b/problems/leetflex-banned-accounts/README.md index 3efd973fc..82a948046 100644 --- a/problems/leetflex-banned-accounts/README.md +++ b/problems/leetflex-banned-accounts/README.md @@ -9,6 +9,6 @@                  [Next >](../sum-of-unique-elements "Sum of Unique Elements") -## [1747. Leetflex Banned Accounts (Medium)](https://leetcode.com/problems/leetflex-banned-accounts "") +## [1747. Leetflex Banned Accounts (Medium)](https://leetcode.com/problems/leetflex-banned-accounts "应该被禁止的Leetflex账户") diff --git a/problems/license-key-formatting/README.md b/problems/license-key-formatting/README.md index aca195293..44695926c 100644 --- a/problems/license-key-formatting/README.md +++ b/problems/license-key-formatting/README.md @@ -11,38 +11,35 @@ ## [482. License Key Formatting (Easy)](https://leetcode.com/problems/license-key-formatting "密钥格式化") -

    You are given a license key represented as a string S which consists only alphanumeric character and dashes. The string is separated into N+1 groups by N dashes.

    +

    You are given a license key represented as a string s that consists of only alphanumeric characters and dashes. The string is separated into n + 1 groups by n dashes. You are also given an integer k.

    -

    Given a number K, we would want to reformat the strings such that each group contains exactly K characters, except for the first group which could be shorter than K, but still must contain at least one character. Furthermore, there must be a dash inserted between two groups and all lowercase letters should be converted to uppercase.

    +

    We want to reformat the string s such that each group contains exactly k characters, except for the first group, which could be shorter than k but still must contain at least one character. Furthermore, there must be a dash inserted between two groups, and you should convert all lowercase letters to uppercase.

    -

    Given a non-empty string S and a number K, format the string according to the rules described above.

    +

    Return the reformatted license key.

    -

    Example 1:
    -

    -Input: S = "5F3Z-2e-9-w", K = 4
    -
    -Output: "5F3Z-2E9W"
    +

     

    +

    Example 1:

    -Explanation: The string S has been split into two parts, each part has 4 characters. +
    +Input: s = "5F3Z-2e-9-w", k = 4
    +Output: "5F3Z-2E9W"
    +Explanation: The string s has been split into two parts, each part has 4 characters.
     Note that the two extra dashes are not needed and can be removed.
     
    -

    +

    Example 2:

    -

    Example 2:

    -Input: S = "2-5g-3-J", K = 2
    +Input: s = "2-5g-3-J", k = 2
    +Output: "2-5G-3J"
    +Explanation: The string s has been split into three parts, each part has 2 characters except the first part as it could be shorter as mentioned above.
    +
    -Output: "2-5G-3J" +

     

    +

    Constraints:

    -Explanation: The string S has been split into three parts, each part has 2 characters except the first part as it could be shorter as mentioned above. -
    -

    - -

    Note:
    -

      -
    1. The length of string S will not exceed 12,000, and K is a positive integer.
    2. -
    3. String S consists only of alphanumerical characters (a-z and/or A-Z and/or 0-9) and dashes(-).
    4. -
    5. String S is non-empty.
    6. -
    -

    +
      +
    • 1 <= s.length <= 105
    • +
    • s consists of English letters, digits, and dashes '-'.
    • +
    • 1 <= k <= 104
    • +
    diff --git a/problems/lonely-pixel-ii/README.md b/problems/lonely-pixel-ii/README.md index 5d44bbe80..26b769b2c 100644 --- a/problems/lonely-pixel-ii/README.md +++ b/problems/lonely-pixel-ii/README.md @@ -52,7 +52,6 @@ Rule 2, the rows have black pixel at column C = 1 are row 0, row 1 and row 2. Th

    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Array](../../tag/array/README.md)] ### Similar Questions diff --git a/problems/longest-common-prefix/README.md b/problems/longest-common-prefix/README.md index f4b79da9f..9663521b4 100644 --- a/problems/longest-common-prefix/README.md +++ b/problems/longest-common-prefix/README.md @@ -35,7 +35,7 @@

    Constraints:

      -
    • 0 <= strs.length <= 200
    • +
    • 1 <= strs.length <= 200
    • 0 <= strs[i].length <= 200
    • strs[i] consists of only lower-case English letters.
    diff --git a/problems/longest-line-of-consecutive-one-in-matrix/README.md b/problems/longest-line-of-consecutive-one-in-matrix/README.md index 5698e26e0..b91260053 100644 --- a/problems/longest-line-of-consecutive-one-in-matrix/README.md +++ b/problems/longest-line-of-consecutive-one-in-matrix/README.md @@ -30,6 +30,7 @@ The number of elements in the given matrix will not exceed 10,000. ### Related Topics [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/longest-repeating-character-replacement/README.md b/problems/longest-repeating-character-replacement/README.md index 24bd5af8d..a66744435 100644 --- a/problems/longest-repeating-character-replacement/README.md +++ b/problems/longest-repeating-character-replacement/README.md @@ -11,45 +11,36 @@ ## [424. Longest Repeating Character Replacement (Medium)](https://leetcode.com/problems/longest-repeating-character-replacement "替换后的最长重复字符") -

    Given a string s that consists of only uppercase English letters, you can perform at most k operations on that string.

    +

    You are given a string s and an integer k. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at most k times.

    -

    In one operation, you can choose any character of the string and change it to any other uppercase English character.

    +

    Return the length of the longest substring containing the same letter you can get after performing the above operations.

    -

    Find the length of the longest sub-string containing all repeating letters you can get after performing the above operations.

    - -

    Note:
    -Both the string's length and k will not exceed 104.

    - -

    Example 1:

    +

     

    +

    Example 1:

    -Input:
    -s = "ABAB", k = 2
    -
    -Output:
    -4
    -
    -Explanation:
    -Replace the two 'A's with two 'B's or vice versa.
    +Input: s = "ABAB", k = 2
    +Output: 4
    +Explanation: Replace the two 'A's with two 'B's or vice versa.
     
    -

     

    - -

    Example 2:

    +

    Example 2:

    -Input:
    -s = "AABABBA", k = 1
    -
    -Output:
    -4
    -
    -Explanation:
    -Replace the one 'A' in the middle with 'B' and form "AABBBBA".
    +Input: s = "AABABBA", k = 1
    +Output: 4
    +Explanation: Replace the one 'A' in the middle with 'B' and form "AABBBBA".
     The substring "BBBB" has the longest repeating letters, which is 4.
     

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 105
    • +
    • s consists of only uppercase English letters.
    • +
    • 0 <= k <= s.length
    • +
    ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/longest-string-chain/README.md b/problems/longest-string-chain/README.md index 318cfa9b2..72728e724 100644 --- a/problems/longest-string-chain/README.md +++ b/problems/longest-string-chain/README.md @@ -13,9 +13,9 @@

    Given a list of words, each word consists of English lowercase letters.

    -

    Let's say word1 is a predecessor of word2 if and only if we can add exactly one letter anywhere in word1 to make it equal to word2.  For example, "abc" is a predecessor of "abac".

    +

    Let's say word1 is a predecessor of word2 if and only if we can add exactly one letter anywhere in word1 to make it equal to word2. For example, "abc" is a predecessor of "abac".

    -

    A word chain is a sequence of words [word_1, word_2, ..., word_k] with k >= 1, where word_1 is a predecessor of word_2, word_2 is a predecessor of word_3, and so on.

    +

    A word chain is a sequence of words [word_1, word_2, ..., word_k] with k >= 1, where word_1 is a predecessor of word_2, word_2 is a predecessor of word_3, and so on.

    Return the longest possible length of a word chain with words chosen from the given list of words.

    diff --git a/problems/longest-substring-of-all-vowels-in-order/README.md b/problems/longest-substring-of-all-vowels-in-order/README.md new file mode 100644 index 000000000..f8afd8110 --- /dev/null +++ b/problems/longest-substring-of-all-vowels-in-order/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../frequency-of-the-most-frequent-element "Frequency of the Most Frequent Element") +                 +[Next >](../maximum-building-height "Maximum Building Height") + +## [1839. Longest Substring Of All Vowels in Order (Medium)](https://leetcode.com/problems/longest-substring-of-all-vowels-in-order "所有元音按顺序排布的最长子字符串") + +

    A string is considered beautiful if it satisfies the following conditions:

    + +
      +
    • Each of the 5 English vowels ('a', 'e', 'i', 'o', 'u') must appear at least once in it.
    • +
    • The letters must be sorted in alphabetical order (i.e. all 'a's before 'e's, all 'e's before 'i's, etc.).
    • +
    + +

    For example, strings "aeiou" and "aaaaaaeiiiioou" are considered beautiful, but "uaeio", "aeoiu", and "aaaeeeooo" are not beautiful.

    + +

    Given a string word consisting of English vowels, return the length of the longest beautiful substring of word. If no such substring exists, return 0.

    + +

    A substring is a contiguous sequence of characters in a string.

    + +

     

    +

    Example 1:

    + +
    +Input: word = "aeiaaioaaaaeiiiiouuuooaauuaeiu"
    +Output: 13
    +Explanation: The longest beautiful substring in word is "aaaaeiiiiouuu" of length 13.
    + +

    Example 2:

    + +
    +Input: word = "aeeeiiiioooauuuaeiou"
    +Output: 5
    +Explanation: The longest beautiful substring in word is "aeiou" of length 5.
    +
    + +

    Example 3:

    + +
    +Input: word = "a"
    +Output: 0
    +Explanation: There is no beautiful substring, so return 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= word.length <= 5 * 105
    • +
    • word consists of characters 'a', 'e', 'i', 'o', and 'u'.
    • +
    + +### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Start from each 'a' and find the longest beautiful substring starting at that index. +
    + +
    +Hint 2 +Based on the current character decide if you should include the next character in the beautiful substring. +
    diff --git a/problems/longest-uncommon-subsequence-i/README.md b/problems/longest-uncommon-subsequence-i/README.md index 443ce744f..7696934fa 100644 --- a/problems/longest-uncommon-subsequence-i/README.md +++ b/problems/longest-uncommon-subsequence-i/README.md @@ -11,13 +11,15 @@ ## [521. Longest Uncommon Subsequence I (Easy)](https://leetcode.com/problems/longest-uncommon-subsequence-i "最长特殊序列 Ⅰ") -

    Given two strings a and b, find the length of the longest uncommon subsequence between them.

    +

    Given two strings a and b, return the length of the longest uncommon subsequence between a and b. If the longest uncommon subsequence does not exist, return -1.

    -

    subsequence of a string s is a string that can be obtained after deleting any number of characters from s. For example, "abc" is a subsequence of "aebdc" because you can delete the underlined characters in "aebdc" to get "abc". Other subsequences of "aebdc" include "aebdc""aeb", and "" (empty string).

    +

    An uncommon subsequence between two strings is a string that is a subsequence of one but not the other.

    -

    An uncommon subsequence between two strings is a string that is a subsequence of one but not the other.

    +

    A subsequence of a string s is a string that can be obtained after deleting any number of characters from s.

    -

    Return the length of the longest uncommon subsequence between a and b. If the longest uncommon subsequence doesn't exist, return -1.

    +
      +
    • For example, "abc" is a subsequence of "aebdc" because you can delete the underlined characters in "aebdc" to get "abc". Other subsequences of "aebdc" include "aebdc", "aeb", and "" (empty string).
    • +

     

    Example 1:

    diff --git a/problems/longest-uncommon-subsequence-ii/README.md b/problems/longest-uncommon-subsequence-ii/README.md index de2e5f0da..2093570b3 100644 --- a/problems/longest-uncommon-subsequence-ii/README.md +++ b/problems/longest-uncommon-subsequence-ii/README.md @@ -11,31 +11,32 @@ ## [522. Longest Uncommon Subsequence II (Medium)](https://leetcode.com/problems/longest-uncommon-subsequence-ii "最长特殊序列 II") -

    -Given a list of strings, you need to find the longest uncommon subsequence among them. The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequence should not be any subsequence of the other strings. -

    - -

    -A subsequence is a sequence that can be derived from one sequence by deleting some characters without changing the order of the remaining elements. Trivially, any string is a subsequence of itself and an empty string is a subsequence of any string. -

    - -

    -The input will be a list of strings, and the output needs to be the length of the longest uncommon subsequence. If the longest uncommon subsequence doesn't exist, return -1. -

    - -

    Example 1:
    -

    -Input: "aba", "cdc", "eae"
    -Output: 3
    +

    Given an array of strings strs, return the length of the longest uncommon subsequence between them. If the longest uncommon subsequence does not exist, return -1.

    + +

    An uncommon subsequence between an array of strings is a string that is a subsequence of one string but not the others.

    + +

    A subsequence of a string s is a string that can be obtained after deleting any number of characters from s.

    + +
      +
    • For example, "abc" is a subsequence of "aebdc" because you can delete the underlined characters in "aebdc" to get "abc". Other subsequences of "aebdc" include "aebdc", "aeb", and "" (empty string).
    • +
    + +

     

    +

    Example 1:

    +
    Input: strs = ["aba","cdc","eae"]
    +Output: 3
    +

    Example 2:

    +
    Input: strs = ["aaa","aaa","aa"]
    +Output: -1
     
    -

    - -

    Note: -

      -
    1. All the given strings' lengths will not exceed 10.
    2. -
    3. The length of the given list will be in the range of [2, 50].
    4. -
    -

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= strs.length <= 50
    • +
    • 1 <= strs[i].length <= 10
    • +
    • strs[i] consists of lowercase English letters.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/longest-word-in-dictionary/README.md b/problems/longest-word-in-dictionary/README.md index 13945cc3d..803f128bd 100644 --- a/problems/longest-word-in-dictionary/README.md +++ b/problems/longest-word-in-dictionary/README.md @@ -11,33 +11,35 @@ ## [720. Longest Word in Dictionary (Easy)](https://leetcode.com/problems/longest-word-in-dictionary "词典中最长的单词") -

    Given a list of strings words representing an English Dictionary, find the longest word in words that can be built one character at a time by other words in words. If there is more than one possible answer, return the longest word with the smallest lexicographical order.

    If there is no answer, return the empty string. +

    Given an array of strings words representing an English Dictionary, return the longest word in words that can be built one character at a time by other words in words.

    + +

    If there is more than one possible answer, return the longest word with the smallest lexicographical order. If there is no answer, return the empty string.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: 
    -words = ["w","wo","wor","worl", "world"]
    -Output: "world"
    -Explanation: 
    -The word "world" can be built one character at a time by "w", "wo", "wor", and "worl".
    +Input: words = ["w","wo","wor","worl","world"]
    +Output: "world"
    +Explanation: The word "world" can be built one character at a time by "w", "wo", "wor", and "worl".
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: 
    -words = ["a", "banana", "app", "appl", "ap", "apply", "apple"]
    -Output: "apple"
    -Explanation: 
    -Both "apply" and "apple" can be built from other words in the dictionary. However, "apple" is lexicographically smaller than "apply".
    +Input: words = ["a","banana","app","appl","ap","apply","apple"]
    +Output: "apple"
    +Explanation: Both "apply" and "apple" can be built from other words in the dictionary. However, "apple" is lexicographically smaller than "apply".
     
    -

    -

    Note: -

  • All the strings in the input will only contain lowercase letters.
  • -
  • The length of words will be in the range [1, 1000].
  • -
  • The length of words[i] will be in the range [1, 30].
  • -

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 1000
    • +
    • 1 <= words[i].length <= 30
    • +
    • words[i] consists of lowercase English letters.
    • +
    ### Related Topics [[Trie](../../tag/trie/README.md)] diff --git a/problems/magical-string/README.md b/problems/magical-string/README.md index 5a1f060af..a080e985f 100644 --- a/problems/magical-string/README.md +++ b/problems/magical-string/README.md @@ -11,48 +11,35 @@ ## [481. Magical String (Medium)](https://leetcode.com/problems/magical-string "神奇字符串") -

    -A magical string S consists of only '1' and '2' and obeys the following rules: -

    -

    -The string S is magical because concatenating the number of contiguous occurrences of characters '1' and '2' generates the string S itself. -

    - -

    -The first few elements of string S is the following: -S = "1221121221221121122……" -

    - -

    -If we group the consecutive '1's and '2's in S, it will be: -

    -

    -1 22 11 2 1 22 1 22 11 2 11 22 ...... -

    -

    -and the occurrences of '1's or '2's in each group are: -

    -

    -1 2 2 1 1 2 1 2 2 1 2 2 ...... -

    - -

    -You can see that the occurrence sequence above is the S itself. -

    - -

    -Given an integer N as input, return the number of '1's in the first N number in the magical string S. -

    - -

    Note: -N will not exceed 100,000. -

    - - -

    Example 1:
    +

    A magical string s consists of only '1' and '2' and obeys the following rules:

    + +
      +
    • The string s is magical because concatenating the number of contiguous occurrences of characters '1' and '2' generates the string s itself.
    • +
    + +

    The first few elements of s is s = "1221121221221121122……". If we group the consecutive 1's and 2's in s, it will be "1 22 11 2 1 22 1 22 11 2 11 22 ......" and the occurrences of 1's or 2's in each group are "1 2 2 1 1 2 1 2 2 1 2 2 ......". You can see that the occurrence sequence is s itself.

    + +

    Given an integer n, return the number of 1's in the first n number in the magical string s.

    + +

     

    +

    Example 1:

    +
    -Input: 6
    -Output: 3
    -Explanation: The first 6 elements of magical string S is "12211" and it contains three 1's, so return 3.
    +Input: n = 6
    +Output: 3
    +Explanation: The first 6 elements of magical string s is "12211" and it contains three 1's, so return 3.
     
    -

    + +

    Example 2:

    + +
    +Input: n = 1
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 105
    • +
    diff --git a/problems/matchsticks-to-square/README.md b/problems/matchsticks-to-square/README.md index 237257bd4..675b80208 100644 --- a/problems/matchsticks-to-square/README.md +++ b/problems/matchsticks-to-square/README.md @@ -11,34 +11,34 @@ ## [473. Matchsticks to Square (Medium)](https://leetcode.com/problems/matchsticks-to-square "火柴拼正方形") -

    Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match girl has, please find out a way you can make one square by using up all those matchsticks. You should not break any stick, but you can link them up, and each matchstick must be used exactly one time.

    +

    You are given an integer array matchsticks where matchsticks[i] is the length of the ith matchstick. You want to use all the matchsticks to make one square. You should not break any stick, but you can link them up, and each matchstick must be used exactly one time.

    -

    Your input will be several matchsticks the girl has, represented with their stick length. Your output will either be true or false, to represent whether you could make one square using all the matchsticks the little match girl has.

    +

    Return true if you can make this square and false otherwise.

    -

    Example 1:
    +

     

    +

    Example 1:

    +
    -Input: [1,1,2,2,2]
    -Output: true
    -
    -Explanation: You can form a square with length 2, one side of the square came two sticks with length 1.
    +Input: matchsticks = [1,1,2,2,2]
    +Output: true
    +Explanation: You can form a square with length 2, one side of the square came two sticks with length 1.
     
    -

    -

    Example 2:
    -

    -Input: [3,3,3,3,4]
    -Output: false
    +

    Example 2:

    -Explanation: You cannot find a way to form a square with all the matchsticks. +
    +Input: matchsticks = [3,3,3,3,4]
    +Output: false
    +Explanation: You cannot find a way to form a square with all the matchsticks.
     
    -

    -

    Note:
    -

      -
    1. The length sum of the given matchsticks is in the range of 0 to 10^9. -
    2. The length of the given matchstick array will not exceed 15.
    3. -
    -

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= matchsticks.length <= 15
    • +
    • 0 <= matchsticks[i] <= 109
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/max-consecutive-ones-iii/README.md b/problems/max-consecutive-ones-iii/README.md index 4c0876bc1..b4ce4c7a4 100644 --- a/problems/max-consecutive-ones-iii/README.md +++ b/problems/max-consecutive-ones-iii/README.md @@ -11,44 +11,34 @@ ## [1004. Max Consecutive Ones III (Medium)](https://leetcode.com/problems/max-consecutive-ones-iii "最大连续1的个数 III") -

    Given an array A of 0s and 1s, we may change up to K values from 0 to 1.

    - -

    Return the length of the longest (contiguous) subarray that contains only 1s. 

    +

    Given a binary array nums and an integer k, return the maximum number of consecutive 1's in the array if you can flip at most k 0's.

     

    - -

    Example 1:

    -Input: A = [1,1,1,0,0,0,1,1,1,1,0], K = 2
    -Output: 6
    -Explanation: 
    -[1,1,1,0,0,1,1,1,1,1,1]
    -Bolded numbers were flipped from 0 to 1.  The longest subarray is underlined.
    +Input: nums = [1,1,1,0,0,0,1,1,1,1,0], k = 2 +Output: 6 +Explanation: [1,1,1,0,0,1,1,1,1,1,1] +Bolded numbers were flipped from 0 to 1. The longest subarray is underlined.
    -

    Example 2:

    -Input: A = [0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1], K = 3
    -Output: 10
    -Explanation: 
    -[0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1]
    -Bolded numbers were flipped from 0 to 1.  The longest subarray is underlined.
    +Input: nums = [0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1], k = 3
    +Output: 10
    +Explanation: [0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1]
    +Bolded numbers were flipped from 0 to 1. The longest subarray is underlined.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= A.length <= 20000
    2. -
    3. 0 <= K <= A.length
    4. -
    5. A[i] is 0 or 1 
    6. -
    -
    - +
      +
    • 1 <= nums.length <= 105
    • +
    • nums[i] is either 0 or 1.
    • +
    • 0 <= k <= nums.length
    • +
    ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/max-consecutive-ones/README.md b/problems/max-consecutive-ones/README.md index 185c3b257..9ac8a9976 100644 --- a/problems/max-consecutive-ones/README.md +++ b/problems/max-consecutive-ones/README.md @@ -11,23 +11,31 @@ ## [485. Max Consecutive Ones (Easy)](https://leetcode.com/problems/max-consecutive-ones "最大连续 1 的个数") -

    Given a binary array, find the maximum number of consecutive 1s in this array.

    +

    Given a binary array nums, return the maximum number of consecutive 1's in the array.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,1,0,1,1,1]
    +Output: 3
    +Explanation: The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is 3.
    +
    + +

    Example 2:

    -

    Example 1:

    -Input: [1,1,0,1,1,1]
    -Output: 3
    -Explanation: The first two digits or the last three digits are consecutive 1s.
    -    The maximum number of consecutive 1s is 3.
    +Input: nums = [1,0,1,1,0,1]
    +Output: 2
     
    -

    -

    Note: +

     

    +

    Constraints:

    +
      -
    • The input array will only contain 0 and 1.
    • -
    • The length of input array is a positive integer and will not exceed 10,000
    • +
    • 1 <= nums.length <= 105
    • +
    • nums[i] is either 0 or 1.
    -

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/maximum-building-height/README.md b/problems/maximum-building-height/README.md new file mode 100644 index 000000000..8f766fc31 --- /dev/null +++ b/problems/maximum-building-height/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../longest-substring-of-all-vowels-in-order "Longest Substring Of All Vowels in Order") +                 +Next > + +## [1840. Maximum Building Height (Hard)](https://leetcode.com/problems/maximum-building-height "最高建筑高度") + +

    You want to build n new buildings in a city. The new buildings will be built in a line and are labeled from 1 to n.

    + +

    However, there are city restrictions on the heights of the new buildings:

    + +
      +
    • The height of each building must be a non-negative integer.
    • +
    • The height of the first building must be 0.
    • +
    • The height difference between any two adjacent buildings cannot exceed 1.
    • +
    + +

    Additionally, there are city restrictions on the maximum height of specific buildings. These restrictions are given as a 2D integer array restrictions where restrictions[i] = [idi, maxHeighti] indicates that building idi must have a height less than or equal to maxHeighti.

    + +

    It is guaranteed that each building will appear at most once in restrictions, and building 1 will not be in restrictions.

    + +

    Return the maximum possible height of the tallest building.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 5, restrictions = [[2,1],[4,1]]
    +Output: 2
    +Explanation: The green area in the image indicates the maximum allowed height for each building.
    +We can build the buildings with heights [0,1,2,1,2], and the tallest building has a height of 2.
    + +

    Example 2:

    + +
    +Input: n = 6, restrictions = []
    +Output: 5
    +Explanation: The green area in the image indicates the maximum allowed height for each building.
    +We can build the buildings with heights [0,1,2,3,4,5], and the tallest building has a height of 5.
    +
    + +

    Example 3:

    + +
    +Input: n = 10, restrictions = [[5,3],[2,5],[7,4],[10,3]]
    +Output: 5
    +Explanation: The green area in the image indicates the maximum allowed height for each building.
    +We can build the buildings with heights [0,1,2,3,3,4,4,5,4,3], and the tallest building has a height of 5.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 109
    • +
    • 0 <= restrictions.length <= min(n - 1, 105)
    • +
    • 2 <= idi <= n
    • +
    • idi is unique.
    • +
    • 0 <= maxHeighti <= 109
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Is it possible to find the max height if given the height range of a particular building? +
    + +
    +Hint 2 +You can find the height range of a restricted building by doing 2 passes from the left and right. +
    diff --git a/problems/maximum-ice-cream-bars/README.md b/problems/maximum-ice-cream-bars/README.md new file mode 100644 index 000000000..7d4bbd70e --- /dev/null +++ b/problems/maximum-ice-cream-bars/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../check-if-the-sentence-is-pangram "Check if the Sentence Is Pangram") +                 +[Next >](../single-threaded-cpu "Single-Threaded CPU") + +## [1833. Maximum Ice Cream Bars (Medium)](https://leetcode.com/problems/maximum-ice-cream-bars "雪糕的最大数量") + +

    It is a sweltering summer day, and a boy wants to buy some ice cream bars.

    + +

    At the store, there are n ice cream bars. You are given an array costs of length n, where costs[i] is the price of the ith ice cream bar in coins. The boy initially has coins coins to spend, and he wants to buy as many ice cream bars as possible. 

    + +

    Return the maximum number of ice cream bars the boy can buy with coins coins.

    + +

    Note: The boy can buy the ice cream bars in any order.

    + +

     

    +

    Example 1:

    + +
    +Input: costs = [1,3,2,4,1], coins = 7
    +Output: 4
    +Explanation: The boy can buy ice cream bars at indices 0,1,2,4 for a total price of 1 + 3 + 2 + 1 = 7.
    +
    + +

    Example 2:

    + +
    +Input: costs = [10,6,8,7,7,8], coins = 5
    +Output: 0
    +Explanation: The boy cannot afford any of the ice cream bars.
    +
    + +

    Example 3:

    + +
    +Input: costs = [1,6,3,1,2,5], coins = 20
    +Output: 6
    +Explanation: The boy can buy all the ice cream bars for a total price of 1 + 6 + 3 + 1 + 2 + 5 = 18.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • costs.length == n
    • +
    • 1 <= n <= 105
    • +
    • 1 <= costs[i] <= 105
    • +
    • 1 <= coins <= 108
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +It is always optimal to buy the least expensive ice cream bar first. +
    + +
    +Hint 2 +Sort the prices so that the cheapest ice cream bar comes first. +
    + +
    +Hint 3 +It is always optimal to buy the least expensive ice cream bar first. +
    + +
    +Hint 4 +Sort the prices so that the cheapest ice cream bar comes first. +
    diff --git a/problems/maximum-length-of-pair-chain/README.md b/problems/maximum-length-of-pair-chain/README.md index 30e3a7061..a196c411d 100644 --- a/problems/maximum-length-of-pair-chain/README.md +++ b/problems/maximum-length-of-pair-chain/README.md @@ -11,32 +11,39 @@ ## [646. Maximum Length of Pair Chain (Medium)](https://leetcode.com/problems/maximum-length-of-pair-chain "最长数对链") -

    -You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. -

    +

    You are given an array of n pairs pairs where pairs[i] = [lefti, righti] and lefti < righti.

    -

    -Now, we define a pair (c, d) can follow another pair (a, b) if and only if b < c. Chain of pairs can be formed in this fashion. -

    +

    A pair p2 = [c, d] follows a pair p1 = [a, b] if b < c. A chain of pairs can be formed in this fashion.

    -

    -Given a set of pairs, find the length longest chain which can be formed. You needn't use up all the given pairs. You can select pairs in any order. -

    +

    Return the length longest chain which can be formed.

    +

    You do not need to use up all the given intervals. You can select pairs in any order.

    + +

     

    +

    Example 1:

    + +
    +Input: pairs = [[1,2],[2,3],[3,4]]
    +Output: 2
    +Explanation: The longest chain is [1,2] -> [3,4].
    +
    + +

    Example 2:

    -

    Example 1:

    -Input: [[1,2], [2,3], [3,4]]
    -Output: 2
    -Explanation: The longest chain is [1,2] -> [3,4]
    +Input: pairs = [[1,2],[7,8],[4,5]]
    +Output: 3
    +Explanation: The longest chain is [1,2] -> [4,5] -> [7,8].
     
    -

    -

    Note:
    -

      -
    1. The number of given pairs will be in the range [1, 1000].
    2. -
    -

    +

     

    +

    Constraints:

    + +
      +
    • n == pairs.length
    • +
    • 1 <= n <= 1000
    • +
    • -1000 <= lefti < righti < 1000
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/maximum-length-of-repeated-subarray/README.md b/problems/maximum-length-of-repeated-subarray/README.md index efa97c82f..a0cf0aef6 100644 --- a/problems/maximum-length-of-repeated-subarray/README.md +++ b/problems/maximum-length-of-repeated-subarray/README.md @@ -11,29 +11,31 @@ ## [718. Maximum Length of Repeated Subarray (Medium)](https://leetcode.com/problems/maximum-length-of-repeated-subarray "最长重复子数组") -

    Given two integer arrays A and B, return the maximum length of an subarray that appears in both arrays.

    +

    Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays.

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input:
    -A: [1,2,3,2,1]
    -B: [3,2,1,4,7]
    -Output: 3
    -Explanation: 
    -The repeated subarray with maximum length is [3, 2, 1].
    +Input: nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7]
    +Output: 3
    +Explanation: The repeated subarray with maximum length is [3,2,1].
     
    -

     

    - -

    Note:

    +

    Example 2:

    -
      -
    1. 1 <= len(A), len(B) <= 1000
    2. -
    3. 0 <= A[i], B[i] < 100
    4. -
    +
    +Input: nums1 = [0,0,0,0,0], nums2 = [0,0,0,0,0]
    +Output: 5
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums1.length, nums2.length <= 1000
    • +
    • 0 <= nums1[i], nums2[i] <= 100
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/maximum-number-of-accepted-invitations/README.md b/problems/maximum-number-of-accepted-invitations/README.md new file mode 100644 index 000000000..8e8c7f5e5 --- /dev/null +++ b/problems/maximum-number-of-accepted-invitations/README.md @@ -0,0 +1,33 @@ + + + + + + + +[< Previous](../number-of-different-subsequences-gcds "Number of Different Subsequences GCDs") +                 +[Next >](../find-customers-with-positive-revenue-this-year "Find Customers With Positive Revenue this Year") + +## [1820. Maximum Number of Accepted Invitations (Medium)](https://leetcode.com/problems/maximum-number-of-accepted-invitations "") + + + +### Related Topics + [[Graph](../../tag/graph/README.md)] + +### Hints +
    +Hint 1 +We can see that the problem can be represented as a directed graph with an edge from each boy to the girl he invited. +
    + +
    +Hint 2 +We need to choose a set of edges such that no to source points in the graph (i.e., boys) have an edge with the same endpoint (i.e., the same girl). +
    + +
    +Hint 3 +The problem is maximum bipartite matching in the graph. +
    diff --git a/problems/maximum-number-of-balloons/README.md b/problems/maximum-number-of-balloons/README.md index c8548021d..daf127636 100644 --- a/problems/maximum-number-of-balloons/README.md +++ b/problems/maximum-number-of-balloons/README.md @@ -11,7 +11,7 @@ ## [1189. Maximum Number of Balloons (Easy)](https://leetcode.com/problems/maximum-number-of-balloons "“气球” 的最大数量") -

    Given a string text, you want to use the characters of text to form as many instances of the word "balloon" as possible.

    +

    Given a string text, you want to use the characters of text to form as many instances of the word "balloon" as possible.

    You can use each character in text at most once. Return the maximum number of instances that can be formed.

    @@ -45,8 +45,8 @@

    Constraints:

      -
    • 1 <= text.length <= 10^4
    • -
    • text consists of lower case English letters only.
    • +
    • 1 <= text.length <= 104
    • +
    • text consists of lower case English letters only.
    ### Related Topics diff --git a/problems/maximum-performance-of-a-team/README.md b/problems/maximum-performance-of-a-team/README.md index 4743fd9b7..424a9f323 100644 --- a/problems/maximum-performance-of-a-team/README.md +++ b/problems/maximum-performance-of-a-team/README.md @@ -11,9 +11,13 @@ ## [1383. Maximum Performance of a Team (Hard)](https://leetcode.com/problems/maximum-performance-of-a-team "最大的团队表现值") -

    There are n engineers numbered from 1 to n and two arrays: speed and efficiency, where speed[i] and efficiency[i] represent the speed and efficiency for the i-th engineer respectively. Return the maximum performance of a team composed of at most k engineers, since the answer can be a huge number, return this modulo 10^9 + 7.

    +

    You are given two integers n and k and two integer arrays speed and efficiency both of length n. There are n engineers numbered from 1 to n. speed[i] and efficiency[i] represent the speed and efficiency of the ith engineer respectively.

    -

    The performance of a team is the sum of their engineers' speeds multiplied by the minimum efficiency among their engineers. 

    +

    Choose at most k different engineers out of the n engineers to form a team with the maximum performance.

    + +

    The performance of a team is the sum of their engineers' speeds multiplied by the minimum efficiency among their engineers.

    + +

    Return the maximum performance of this team. Since the answer can be a huge number, return it modulo 109 + 7.

     

    Example 1:

    @@ -45,12 +49,11 @@ We have the maximum performance of the team by selecting engineer 2 (with speed=

    Constraints:

      -
    • 1 <= n <= 10^5
    • +
    • 1 <= <= k <= n <= 105
    • speed.length == n
    • efficiency.length == n
    • -
    • 1 <= speed[i] <= 10^5
    • -
    • 1 <= efficiency[i] <= 10^8
    • -
    • 1 <= k <= n
    • +
    • 1 <= speed[i] <= 105
    • +
    • 1 <= efficiency[i] <= 108
    ### Related Topics @@ -65,5 +68,5 @@ Keep track of the engineers by their efficiency in decreasing order.
    Hint 2 -For each engineer's efficiency take the K highest speeds among the engineers previously tracked. +Starting from one engineer, to build a team, it suffices to bring K-1 more engineers who have higher efficiencies as well as high speeds.
    diff --git a/problems/maximum-subarray-sum-after-one-operation/README.md b/problems/maximum-subarray-sum-after-one-operation/README.md index 4a219af0b..4e89083fe 100644 --- a/problems/maximum-subarray-sum-after-one-operation/README.md +++ b/problems/maximum-subarray-sum-after-one-operation/README.md @@ -9,7 +9,7 @@                  [Next >](../leetflex-banned-accounts "Leetflex Banned Accounts") -## [1746. Maximum Subarray Sum After One Operation (Medium)](https://leetcode.com/problems/maximum-subarray-sum-after-one-operation "") +## [1746. Maximum Subarray Sum After One Operation (Medium)](https://leetcode.com/problems/maximum-subarray-sum-after-one-operation "经过一次操作后的最大子数组和") diff --git a/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md b/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md index 1e23d04f4..bc2d40939 100644 --- a/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md +++ b/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md @@ -11,33 +11,36 @@ ## [689. Maximum Sum of 3 Non-Overlapping Subarrays (Hard)](https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays "三个无重叠子数组的最大和") -

    In a given array nums of positive integers, find three non-overlapping subarrays with maximum sum.

    +

    Given an integer array nums and an integer k, find three non-overlapping subarrays of length k with maximum sum and return them.

    -

    Each subarray will be of size k, and we want to maximize the sum of all 3*k entries.

    +

    Return the result as a list of indices representing the starting position of each interval (0-indexed). If there are multiple answers, return the lexicographically smallest one.

    -

    Return the result as a list of indices representing the starting position of each interval (0-indexed). If there are multiple answers, return the lexicographically smallest one.

    - -

    Example:

    +

     

    +

    Example 1:

    -Input: [1,2,1,2,6,7,5,1], 2
    -Output: [0, 3, 5]
    -Explanation: Subarrays [1, 2], [2, 6], [7, 5] correspond to the starting indices [0, 3, 5].
    +Input: nums = [1,2,1,2,6,7,5,1], k = 2
    +Output: [0,3,5]
    +Explanation: Subarrays [1, 2], [2, 6], [7, 5] correspond to the starting indices [0, 3, 5].
     We could have also taken [2, 1], but an answer of [1, 3, 5] would be lexicographically larger.
     
    -

     

    +

    Example 2:

    -

    Note:

    +
    +Input: nums = [1,2,1,2,1,2,1,2,1], k = 2
    +Output: [0,2,4]
    +
    + +

     

    +

    Constraints:

      -
    • nums.length will be between 1 and 20000.
    • -
    • nums[i] will be between 1 and 65535.
    • -
    • k will be between 1 and floor(nums.length / 3).
    • +
    • 1 <= nums.length <= 2 * 104
    • +
    • 1 <= nums[i] < 216
    • +
    • 1 <= k <= floor(nums.length / 3)
    -

     

    - ### Related Topics [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/maximum-transaction-each-day/README.md b/problems/maximum-transaction-each-day/README.md new file mode 100644 index 000000000..19dd5da19 --- /dev/null +++ b/problems/maximum-transaction-each-day/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../minimum-number-of-operations-to-make-string-sorted "Minimum Number of Operations to Make String Sorted") +                 +[Next >](../check-if-the-sentence-is-pangram "Check if the Sentence Is Pangram") + +## [1831. Maximum Transaction Each Day (Medium)](https://leetcode.com/problems/maximum-transaction-each-day "") + + diff --git a/problems/maximum-transaction-each-day/mysql_schemas.sql b/problems/maximum-transaction-each-day/mysql_schemas.sql new file mode 100644 index 000000000..db8df0ca0 --- /dev/null +++ b/problems/maximum-transaction-each-day/mysql_schemas.sql @@ -0,0 +1,7 @@ +Create table If Not Exists Transactions (transaction_id int, day datetime, amount int); +Truncate table Transactions; +insert into Transactions (transaction_id, day, amount) values ('8', '2021-4-3 15:57:28', '57'); +insert into Transactions (transaction_id, day, amount) values ('9', '2021-4-28 08:47:25', '21'); +insert into Transactions (transaction_id, day, amount) values ('1', '2021-4-29 13:28:30', '58'); +insert into Transactions (transaction_id, day, amount) values ('5', '2021-4-28 16:39:59', '40'); +insert into Transactions (transaction_id, day, amount) values ('6', '2021-4-29 23:39:28', '58'); diff --git a/problems/maximum-xor-for-each-query/README.md b/problems/maximum-xor-for-each-query/README.md new file mode 100644 index 000000000..67ceb00fe --- /dev/null +++ b/problems/maximum-xor-for-each-query/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../queries-on-number-of-points-inside-a-circle "Queries on Number of Points Inside a Circle") +                 +[Next >](../minimum-number-of-operations-to-make-string-sorted "Minimum Number of Operations to Make String Sorted") + +## [1829. Maximum XOR for Each Query (Medium)](https://leetcode.com/problems/maximum-xor-for-each-query "每个查询的最大异或值") + +

    You are given a sorted array nums of n non-negative integers and an integer maximumBit. You want to perform the following query n times:

    + +
      +
    1. Find a non-negative integer k < 2maximumBit such that nums[0] XOR nums[1] XOR ... XOR nums[nums.length-1] XOR k is maximized. k is the answer to the ith query.
    2. +
    3. Remove the last element from the current array nums.
    4. +
    + +

    Return an array answer, where answer[i] is the answer to the ith query.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [0,1,1,3], maximumBit = 2
    +Output: [0,3,2,3]
    +Explanation: The queries are answered as follows:
    +1st query: nums = [0,1,1,3], k = 0 since 0 XOR 1 XOR 1 XOR 3 XOR 0 = 3.
    +2nd query: nums = [0,1,1], k = 3 since 0 XOR 1 XOR 1 XOR 3 = 3.
    +3rd query: nums = [0,1], k = 2 since 0 XOR 1 XOR 2 = 3.
    +4th query: nums = [0], k = 3 since 0 XOR 3 = 3.
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,3,4,7], maximumBit = 3
    +Output: [5,2,6,5]
    +Explanation: The queries are answered as follows:
    +1st query: nums = [2,3,4,7], k = 5 since 2 XOR 3 XOR 4 XOR 7 XOR 5 = 7.
    +2nd query: nums = [2,3,4], k = 2 since 2 XOR 3 XOR 4 XOR 2 = 7.
    +3rd query: nums = [2,3], k = 6 since 2 XOR 3 XOR 6 = 7.
    +4th query: nums = [2], k = 5 since 2 XOR 5 = 7.
    +
    + +

    Example 3:

    + +
    +Input: nums = [0,1,2,2,5,7], maximumBit = 3
    +Output: [4,3,6,4,6,7]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • nums.length == n
    • +
    • 1 <= n <= 105
    • +
    • 1 <= maximumBit <= 20
    • +
    • 0 <= nums[i] < 2maximumBit
    • +
    • nums​​​ is sorted in ascending order.
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + +### Hints +
    +Hint 1 +Note that the maximum possible XOR result is always 2^(maximumBit) - 1 +
    + +
    +Hint 2 +So the answer for a prefix is the XOR of that prefix XORed with 2^(maximumBit)-1 +
    diff --git a/problems/min-cost-climbing-stairs/README.md b/problems/min-cost-climbing-stairs/README.md index 1e99f1c43..ebc266e4d 100644 --- a/problems/min-cost-climbing-stairs/README.md +++ b/problems/min-cost-climbing-stairs/README.md @@ -11,34 +11,36 @@ ## [746. Min Cost Climbing Stairs (Easy)](https://leetcode.com/problems/min-cost-climbing-stairs "使用最小花费爬楼梯") -

    -On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). -

    -Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of the floor, and you can either start from the step with index 0, or the step with index 1. -

    +

    You are given an integer array cost where cost[i] is the cost of ith step on a staircase. Once you pay the cost, you can either climb one or two steps.

    + +

    You can either start from the step with index 0, or the step with index 1.

    + +

    Return the minimum cost to reach the top of the floor.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: cost = [10, 15, 20]
    -Output: 15
    -Explanation: Cheapest is start on cost[1], pay that cost and go to the top.
    +Input: cost = [10,15,20]
    +Output: 15
    +Explanation: Cheapest is: start on cost[1], pay that cost, and go to the top.
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: cost = [1, 100, 1, 1, 1, 100, 1, 1, 100, 1]
    -Output: 6
    -Explanation: Cheapest is start on cost[0], and only step on 1s, skipping cost[3].
    +Input: cost = [1,100,1,1,1,100,1,1,100,1]
    +Output: 6
    +Explanation: Cheapest is: start on cost[0], and only step on 1s, skipping cost[3].
     
    -

    - -

    Note:
    -

      -
    1. cost will have a length in the range [2, 1000].
    2. -
    3. Every cost[i] will be an integer in the range [0, 999].
    4. -
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= cost.length <= 1000
    • +
    • 0 <= cost[i] <= 999
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/minimum-absolute-difference-in-bst/README.md b/problems/minimum-absolute-difference-in-bst/README.md index 4bc949173..01b1d0f86 100644 --- a/problems/minimum-absolute-difference-in-bst/README.md +++ b/problems/minimum-absolute-difference-in-bst/README.md @@ -11,35 +11,34 @@ ## [530. Minimum Absolute Difference in BST (Easy)](https://leetcode.com/problems/minimum-absolute-difference-in-bst "二叉搜索树的最小绝对差") -

    Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes.

    - -

    Example:

    +

    Given the root of a Binary Search Tree (BST), return the minimum absolute difference between the values of any two different nodes in the tree.

    +

     

    +

    Example 1:

    +
    -Input:
    -
    -   1
    -    \
    -     3
    -    /
    -   2
    -
    -Output:
    -1
    +Input: root = [4,2,6,1,3]
    +Output: 1
    +
    -Explanation: -The minimum absolute difference is 1, which is the difference between 2 and 1 (or between 2 and 3). +

    Example 2:

    + +
    +Input: root = [1,0,48,null,null,12,49]
    +Output: 1
     

     

    - -

    Note:

    +

    Constraints:

    +

     

    +

    Note: This question is the same as 783: https://leetcode.com/problems/minimum-distance-between-bst-nodes/

    + ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/minimum-distance-between-bst-nodes/README.md b/problems/minimum-distance-between-bst-nodes/README.md index cd41946ba..35d30901a 100644 --- a/problems/minimum-distance-between-bst-nodes/README.md +++ b/problems/minimum-distance-between-bst-nodes/README.md @@ -13,8 +13,6 @@

    Given the root of a Binary Search Tree (BST), return the minimum difference between the values of any two different nodes in the tree.

    -

    Note: This question is the same as 530: https://leetcode.com/problems/minimum-absolute-difference-in-bst/

    -

     

    Example 1:

    @@ -38,6 +36,9 @@
  • 0 <= Node.val <= 105
  • +

     

    +

    Note: This question is the same as 530: https://leetcode.com/problems/minimum-absolute-difference-in-bst/

    + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/minimum-genetic-mutation/README.md b/problems/minimum-genetic-mutation/README.md index 87fca633e..ad49558bf 100644 --- a/problems/minimum-genetic-mutation/README.md +++ b/problems/minimum-genetic-mutation/README.md @@ -11,61 +11,52 @@ ## [433. Minimum Genetic Mutation (Medium)](https://leetcode.com/problems/minimum-genetic-mutation "最小基因变化") -

    A gene string can be represented by an 8-character long string, with choices from "A", "C", "G", "T".

    +

    A gene string can be represented by an 8-character long string, with choices from 'A', 'C', 'G', and 'T'.

    -

    Suppose we need to investigate about a mutation (mutation from "start" to "end"), where ONE mutation is defined as ONE single character changed in the gene string.

    +

    Suppose we need to investigate a mutation from a gene string start to a gene string end where one mutation is defined as one single character changed in the gene string.

    -

    For example, "AACCGGTT" -> "AACCGGTA" is 1 mutation.

    +
      +
    • For example, "AACCGGTT" --> "AACCGGTA" is one mutation.
    • +
    -

    Also, there is a given gene "bank", which records all the valid gene mutations. A gene must be in the bank to make it a valid gene string.

    +

    There is also a gene bank bank that records all the valid gene mutations. A gene must be in bank to make it a valid gene string.

    -

    Now, given 3 things - start, end, bank, your task is to determine what is the minimum number of mutations needed to mutate from "start" to "end". If there is no such a mutation, return -1.

    +

    Given the two gene strings start and end and the gene bank bank, return the minimum number of mutations needed to mutate from start to end. If there is no such a mutation, return -1.

    -

    Note:

    - -
      -
    1. Starting point is assumed to be valid, so it might not be included in the bank.
    2. -
    3. If multiple mutations are needed, all mutations during in the sequence must be valid.
    4. -
    5. You may assume start and end string is not the same.
    6. -
    +

    Note that the starting point is assumed to be valid, so it might not be included in the bank.

     

    - -

    Example 1:

    +

    Example 1:

    -start: "AACCGGTT"
    -end:   "AACCGGTA"
    -bank: ["AACCGGTA"]
    -
    -return: 1
    +Input: start = "AACCGGTT", end = "AACCGGTA", bank = ["AACCGGTA"]
    +Output: 1
     
    -

     

    - -

    Example 2:

    +

    Example 2:

    -start: "AACCGGTT"
    -end:   "AAACGGTA"
    -bank: ["AACCGGTA", "AACCGCTA", "AAACGGTA"]
    -
    -return: 2
    +Input: start = "AACCGGTT", end = "AAACGGTA", bank = ["AACCGGTA","AACCGCTA","AAACGGTA"]
    +Output: 2
     
    -

     

    - -

    Example 3:

    +

    Example 3:

    -start: "AAAAACCC"
    -end:   "AACCCCCC"
    -bank: ["AAAACCCC", "AAACCCCC", "AACCCCCC"]
    -
    -return: 3
    +Input: start = "AAAAACCC", end = "AACCCCCC", bank = ["AAAACCCC","AAACCCCC","AACCCCCC"]
    +Output: 3
     

     

    +

    Constraints:

    + +
      +
    • start.length == 8
    • +
    • end.length == 8
    • +
    • 0 <= bank.length <= 10
    • +
    • bank[i].length == 8
    • +
    • start, end, and bank[i] consist of only the characters ['A', 'C', 'G', 'T'].
    • +
    ### Similar Questions 1. [Word Ladder](../word-ladder) (Hard) diff --git a/problems/minimum-moves-to-equal-array-elements-ii/README.md b/problems/minimum-moves-to-equal-array-elements-ii/README.md index 47179a8ba..e5cd49034 100644 --- a/problems/minimum-moves-to-equal-array-elements-ii/README.md +++ b/problems/minimum-moves-to-equal-array-elements-ii/README.md @@ -11,24 +11,36 @@ ## [462. Minimum Moves to Equal Array Elements II (Medium)](https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii "最少移动次数使数组元素相等 II") -

    Given a non-empty integer array, find the minimum number of moves required to make all array elements equal, where a move is incrementing a selected element by 1 or decrementing a selected element by 1.

    +

    Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal.

    -

    You may assume the array's length is at most 10,000.

    +

    In one move, you can increment or decrement an element of the array by 1.

    -

    Example: -

    -Input:
    -[1,2,3]
    -
    -Output:
    -2
    +

     

    +

    Example 1:

    -Explanation: +
    +Input: nums = [1,2,3]
    +Output: 2
    +Explanation:
     Only two moves are needed (remember each move increments or decrements one element):
    +[1,2,3]  =>  [2,2,3]  =>  [2,2,2]
    +
    -[1,2,3] => [2,2,3] => [2,2,2] +

    Example 2:

    + +
    +Input: nums = [1,10,2,9]
    +Output: 16
     
    -

    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= nums.length <= 105
    • +
    • -109 <= nums[i] <= 109
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/minimum-moves-to-equal-array-elements/README.md b/problems/minimum-moves-to-equal-array-elements/README.md index cb3c5ecc6..2c359c15c 100644 --- a/problems/minimum-moves-to-equal-array-elements/README.md +++ b/problems/minimum-moves-to-equal-array-elements/README.md @@ -37,8 +37,9 @@
    • n == nums.length
    • -
    • 1 <= nums.length <= 104
    • +
    • 1 <= nums.length <= 105
    • -109 <= nums[i] <= 109
    • +
    • The answer is guaranteed to fit in a 32-bit integer.
    ### Related Topics diff --git a/problems/minimum-number-of-arrows-to-burst-balloons/README.md b/problems/minimum-number-of-arrows-to-burst-balloons/README.md index 403cd0ff3..a6d98b10b 100644 --- a/problems/minimum-number-of-arrows-to-burst-balloons/README.md +++ b/problems/minimum-number-of-arrows-to-burst-balloons/README.md @@ -15,7 +15,7 @@

    An arrow can be shot up exactly vertically from different points along the x-axis. A balloon with xstart and xend bursts by an arrow shot at x if xstart ≤ x ≤ xend. There is no limit to the number of arrows that can be shot. An arrow once shot keeps traveling up infinitely.

    -

    Given an array points where points[i] = [xstart, xend], return the minimum number of arrows that must be shot to burst all balloons.

    +

    Given an array points where points[i] = [xstart, xend], return the minimum number of arrows that must be shot to burst all balloons.

     

    Example 1:

    @@ -40,27 +40,13 @@ Output: 2
    -

    Example 4:

    - -
    -Input: points = [[1,2]]
    -Output: 1
    -
    - -

    Example 5:

    - -
    -Input: points = [[2,3],[2,3]]
    -Output: 1
    -
    -

     

    Constraints:

    • 0 <= points.length <= 104
    • points[i].length == 2
    • -
    • -231 <= xstart < xend <= 231 - 1
    • +
    • -231 <= xstart < xend <= 231 - 1
    ### Related Topics diff --git a/problems/minimum-number-of-operations-to-make-string-sorted/README.md b/problems/minimum-number-of-operations-to-make-string-sorted/README.md new file mode 100644 index 000000000..c9e8ca487 --- /dev/null +++ b/problems/minimum-number-of-operations-to-make-string-sorted/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../maximum-xor-for-each-query "Maximum XOR for Each Query") +                 +[Next >](../maximum-transaction-each-day "Maximum Transaction Each Day") + +## [1830. Minimum Number of Operations to Make String Sorted (Hard)](https://leetcode.com/problems/minimum-number-of-operations-to-make-string-sorted "使字符串有序的最少操作次数") + +

    You are given a string s (0-indexed)​​​​​​. You are asked to perform the following operation on s​​​​​​ until you get a sorted string:

    + +
      +
    1. Find the largest index i such that 1 <= i < s.length and s[i] < s[i - 1].
    2. +
    3. Find the largest index j such that i <= j < s.length and s[k] < s[i - 1] for all the possible values of k in the range [i, j] inclusive.
    4. +
    5. Swap the two characters at indices i - 1​​​​ and j​​​​​.
    6. +
    7. Reverse the suffix starting at index i​​​​​​.
    8. +
    + +

    Return the number of operations needed to make the string sorted. Since the answer can be too large, return it modulo 109 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "cba"
    +Output: 5
    +Explanation: The simulation goes as follows:
    +Operation 1: i=2, j=2. Swap s[1] and s[2] to get s="cab", then reverse the suffix starting at 2. Now, s="cab".
    +Operation 2: i=1, j=2. Swap s[0] and s[2] to get s="bac", then reverse the suffix starting at 1. Now, s="bca".
    +Operation 3: i=2, j=2. Swap s[1] and s[2] to get s="bac", then reverse the suffix starting at 2. Now, s="bac".
    +Operation 4: i=1, j=1. Swap s[0] and s[1] to get s="abc", then reverse the suffix starting at 1. Now, s="acb".
    +Operation 5: i=2, j=2. Swap s[1] and s[2] to get s="abc", then reverse the suffix starting at 2. Now, s="abc".
    +
    + +

    Example 2:

    + +
    +Input: s = "aabaa"
    +Output: 2
    +Explanation: The simulation goes as follows:
    +Operation 1: i=3, j=4. Swap s[2] and s[4] to get s="aaaab", then reverse the substring starting at 3. Now, s="aaaba".
    +Operation 2: i=4, j=4. Swap s[3] and s[4] to get s="aaaab", then reverse the substring starting at 4. Now, s="aaaab".
    +
    + +

    Example 3:

    + +
    +Input: s = "cdbea"
    +Output: 63
    + +

    Example 4:

    + +
    +Input: s = "leetcodeleetcodeleetcode"
    +Output: 982157772
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 3000
    • +
    • s​​​​​​ consists only of lowercase English letters.
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Note that the operations given describe getting the previous permutation of s +
    + +
    +Hint 2 +To solve this problem you need to solve every suffix separately +
    diff --git a/problems/minimum-operations-to-make-the-array-increasing/README.md b/problems/minimum-operations-to-make-the-array-increasing/README.md new file mode 100644 index 000000000..e556d5320 --- /dev/null +++ b/problems/minimum-operations-to-make-the-array-increasing/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](../faulty-sensor "Faulty Sensor") +                 +[Next >](../queries-on-number-of-points-inside-a-circle "Queries on Number of Points Inside a Circle") + +## [1827. Minimum Operations to Make the Array Increasing (Easy)](https://leetcode.com/problems/minimum-operations-to-make-the-array-increasing "最少操作使数组递增") + +

    You are given an integer array nums (0-indexed). In one operation, you can choose an element of the array and increment it by 1.

    + +
      +
    • For example, if nums = [1,2,3], you can choose to increment nums[1] to make nums = [1,3,3].
    • +
    + +

    Return the minimum number of operations needed to make nums strictly increasing.

    + +

    An array nums is strictly increasing if nums[i] < nums[i+1] for all 0 <= i < nums.length - 1. An array of length 1 is trivially strictly increasing.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,1,1]
    +Output: 3
    +Explanation: You can do the following operations:
    +1) Increment nums[2], so nums becomes [1,1,2].
    +2) Increment nums[1], so nums becomes [1,2,2].
    +3) Increment nums[2], so nums becomes [1,2,3].
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,5,2,4,1]
    +Output: 14
    +
    + +

    Example 3:

    + +
    +Input: nums = [8]
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 5000
    • +
    • 1 <= nums[i] <= 104
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +nums[i+1] must be at least equal to nums[i] + 1. +
    + +
    +Hint 2 +Think greedily. You don't have to increase nums[i+1] beyond nums[i]+1. +
    + +
    +Hint 3 +Iterate on i and set nums[i] = max(nums[i-1]+1, nums[i]) . +
    diff --git a/problems/minimum-sideway-jumps/README.md b/problems/minimum-sideway-jumps/README.md new file mode 100644 index 000000000..1ac469648 --- /dev/null +++ b/problems/minimum-sideway-jumps/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../find-the-winner-of-the-circular-game "Find the Winner of the Circular Game") +                 +[Next >](../finding-mk-average "Finding MK Average") + +## [1824. Minimum Sideway Jumps (Medium)](https://leetcode.com/problems/minimum-sideway-jumps "最少侧跳次数") + +

    There is a 3 lane road of length n that consists of n + 1 points labeled from 0 to n. A frog starts at point 0 in the second lane and wants to jump to point n. However, there could be obstacles along the way.

    + +

    You are given an array obstacles of length n + 1 where each obstacles[i] (ranging from 0 to 3) describes an obstacle on the lane obstacles[i] at point i. If obstacles[i] == 0, there are no obstacles at point i. There will be at most one obstacle in the 3 lanes at each point.

    + +
      +
    • For example, if obstacles[2] == 1, then there is an obstacle on lane 1 at point 2.
    • +
    + +

    The frog can only travel from point i to point i + 1 on the same lane if there is not an obstacle on the lane at point i + 1. To avoid obstacles, the frog can also perform a side jump to jump to another lane (even if they are not adjacent) at the same point if there is no obstacle on the new lane.

    + +
      +
    • For example, the frog can jump from lane 3 at point 3 to lane 1 at point 3.
    • +
    + +

    Return the minimum number of side jumps the frog needs to reach any lane at point n starting from lane 2 at point 0.

    + +

    Note: There will be no obstacles on points 0 and n.

    + +

     

    +

    Example 1:

    + +
    +Input: obstacles = [0,1,2,3,0]
    +Output: 2 
    +Explanation: The optimal solution is shown by the arrows above. There are 2 side jumps (red arrows).
    +Note that the frog can jump over obstacles only when making side jumps (as shown at point 2).
    +
    + +

    Example 2:

    + +
    +Input: obstacles = [0,1,1,3,3,0]
    +Output: 0
    +Explanation: There are no obstacles on lane 2. No side jumps are required.
    +
    + +

    Example 3:

    + +
    +Input: obstacles = [0,2,1,0,3,0]
    +Output: 2
    +Explanation: The optimal solution is shown by the arrows above. There are 2 side jumps.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • obstacles.length == n + 1
    • +
    • 1 <= n <= 5 * 105
    • +
    • 0 <= obstacles[i] <= 3
    • +
    • obstacles[0] == obstacles[n] == 0
    • +
    + +### Related Topics + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +At a given point, there are only 3 possible states for where the frog can be. +
    + +
    +Hint 2 +Check all the ways to move from one point to the next and update the minimum side jumps for each lane. +
    diff --git a/problems/most-frequent-subtree-sum/README.md b/problems/most-frequent-subtree-sum/README.md index 7fd3f56ba..4f7bd7ae7 100644 --- a/problems/most-frequent-subtree-sum/README.md +++ b/problems/most-frequent-subtree-sum/README.md @@ -11,33 +11,32 @@ ## [508. Most Frequent Subtree Sum (Medium)](https://leetcode.com/problems/most-frequent-subtree-sum "出现次数最多的子树元素和") -

    -Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a node is defined as the sum of all the node values formed by the subtree rooted at that node (including the node itself). So what is the most frequent subtree sum value? If there is a tie, return all the values with the highest frequency in any order. -

    +

    Given the root of a binary tree, return the most frequent subtree sum. If there is a tie, return all the values with the highest frequency in any order.

    -

    Examples 1
    -Input: +

    The subtree sum of a node is defined as the sum of all the node values formed by the subtree rooted at that node (including the node itself).

    + +

     

    +

    Example 1:

    +
    -  5
    - /  \
    -2   -3
    +Input: root = [5,2,-3]
    +Output: [2,-3,4]
     
    -return [2, -3, 4], since all the values happen only once, return all of them in any order. -

    -

    Examples 2
    -Input: +

    Example 2:

    +
    -  5
    - /  \
    -2   -5
    +Input: root = [5,2,-5]
    +Output: [2]
     
    -return [2], since 2 happens twice, however -5 only occur once. -

    -

    Note: -You may assume the sum of values in any subtree is in the range of 32-bit signed integer. -

    +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [1, 104].
    • +
    • -105 <= Node.val <= 105
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/nested-list-weight-sum-ii/README.md b/problems/nested-list-weight-sum-ii/README.md index 7ebb10aa4..b9195be45 100644 --- a/problems/nested-list-weight-sum-ii/README.md +++ b/problems/nested-list-weight-sum-ii/README.md @@ -39,5 +39,5 @@ [[Depth-first Search](../../tag/depth-first-search/README.md)] ### Similar Questions - 1. [Nested List Weight Sum](../nested-list-weight-sum) (Easy) + 1. [Nested List Weight Sum](../nested-list-weight-sum) (Medium) 1. [Array Nesting](../array-nesting) (Medium) diff --git a/problems/nested-list-weight-sum/README.md b/problems/nested-list-weight-sum/README.md index a7de0b83f..70ddb4446 100644 --- a/problems/nested-list-weight-sum/README.md +++ b/problems/nested-list-weight-sum/README.md @@ -9,7 +9,7 @@                  [Next >](../longest-substring-with-at-most-k-distinct-characters "Longest Substring with At Most K Distinct Characters") -## [339. Nested List Weight Sum (Easy)](https://leetcode.com/problems/nested-list-weight-sum "嵌套列表权重和") +## [339. Nested List Weight Sum (Medium)](https://leetcode.com/problems/nested-list-weight-sum "嵌套列表权重和")

    Given a nested list of integers, return the sum of all integers in the list weighted by their depth.

    diff --git a/problems/non-negative-integers-without-consecutive-ones/README.md b/problems/non-negative-integers-without-consecutive-ones/README.md index f5710de52..5d571fa2b 100644 --- a/problems/non-negative-integers-without-consecutive-ones/README.md +++ b/problems/non-negative-integers-without-consecutive-ones/README.md @@ -11,14 +11,16 @@ ## [600. Non-negative Integers without Consecutive Ones (Hard)](https://leetcode.com/problems/non-negative-integers-without-consecutive-ones "不含连续1的非负整数") -

    Given a positive integer n, find the number of non-negative integers less than or equal to n, whose binary representations do NOT contain consecutive ones.

    +

    Given a positive integer n, return the number of the integers in the range [0, n] whose binary representations do not contain consecutive ones.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: 5
    -Output: 5
    -Explanation: 
    -Here are the non-negative integers <= 5 with their corresponding binary representations:
    +Input: n = 5
    +Output: 5
    +Explanation:
    +Here are the non-negative integers <= 5 with their corresponding binary representations:
     0 : 0
     1 : 1
     2 : 10
    @@ -27,11 +29,27 @@ Here are the non-negative integers <= 5 with their corresponding binary represen
     5 : 101
     Among them, only integer 3 disobeys the rule (two consecutive ones) and the other 5 satisfy the rule. 
     
    -

    -

    Note: -1 <= n <= 109 -

    +

    Example 2:

    + +
    +Input: n = 1
    +Output: 2
    +
    + +

    Example 3:

    + +
    +Input: n = 2
    +Output: 3
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 109
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/non-overlapping-intervals/README.md b/problems/non-overlapping-intervals/README.md index c65355f63..fd72c519a 100644 --- a/problems/non-overlapping-intervals/README.md +++ b/problems/non-overlapping-intervals/README.md @@ -11,45 +11,41 @@ ## [435. Non-overlapping Intervals (Medium)](https://leetcode.com/problems/non-overlapping-intervals "无重叠区间") -

    Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.

    - -
      -
    +

    Given an array of intervals intervals where intervals[i] = [starti, endi], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.

     

    - -

    Example 1:

    +

    Example 1:

    -Input: [[1,2],[2,3],[3,4],[1,3]]
    -Output: 1
    -Explanation: [1,3] can be removed and the rest of intervals are non-overlapping.
    +Input: intervals = [[1,2],[2,3],[3,4],[1,3]]
    +Output: 1
    +Explanation: [1,3] can be removed and the rest of the intervals are non-overlapping.
     
    -

    Example 2:

    +

    Example 2:

    -Input: [[1,2],[1,2],[1,2]]
    -Output: 2
    -Explanation: You need to remove two [1,2] to make the rest of intervals non-overlapping.
    +Input: intervals = [[1,2],[1,2],[1,2]]
    +Output: 2
    +Explanation: You need to remove two [1,2] to make the rest of the intervals non-overlapping.
     
    -

    Example 3:

    +

    Example 3:

    -Input: [[1,2],[2,3]]
    -Output: 0
    -Explanation: You don't need to remove any of the intervals since they're already non-overlapping.
    +Input: intervals = [[1,2],[2,3]]
    +Output: 0
    +Explanation: You don't need to remove any of the intervals since they're already non-overlapping.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. You may assume the interval's end point is always bigger than its start point.
    2. -
    3. Intervals like [1,2] and [2,3] have borders "touching" but they don't overlap each other.
    4. -
    +
      +
    • 1 <= intervals.length <= 2 * 104
    • +
    • intervals[i].length == 2
    • +
    • -2 * 104 <= starti < endi <= 2 * 104
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/number-of-boomerangs/README.md b/problems/number-of-boomerangs/README.md index 9c3aea724..3e22c4dd8 100644 --- a/problems/number-of-boomerangs/README.md +++ b/problems/number-of-boomerangs/README.md @@ -11,9 +11,9 @@ ## [447. Number of Boomerangs (Medium)](https://leetcode.com/problems/number-of-boomerangs "回旋镖的数量") -

    You are given n points in the plane that are all distinct, where points[i] = [xi, yi]. A boomerang is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of the tuple matters).

    +

    You are given n points in the plane that are all distinct, where points[i] = [xi, yi]. A boomerang is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of the tuple matters).

    -

    Return the number of boomerangs.

    +

    Return the number of boomerangs.

     

    Example 1:

    @@ -42,7 +42,7 @@

    Constraints:

      -
    • n == points.length
    • +
    • n == points.length
    • 1 <= n <= 500
    • points[i].length == 2
    • -104 <= xi, yi <= 104
    • diff --git a/problems/number-of-dice-rolls-with-target-sum/README.md b/problems/number-of-dice-rolls-with-target-sum/README.md index 8f2e91845..3b711a2ba 100644 --- a/problems/number-of-dice-rolls-with-target-sum/README.md +++ b/problems/number-of-dice-rolls-with-target-sum/README.md @@ -11,9 +11,9 @@ ## [1155. Number of Dice Rolls With Target Sum (Medium)](https://leetcode.com/problems/number-of-dice-rolls-with-target-sum "掷骰子的N种方法") -

      You have d dice, and each die has f faces numbered 1, 2, ..., f.

      +

      You have d dice and each die has f faces numbered 1, 2, ..., f.

      -

      Return the number of possible ways (out of fd total ways) modulo 10^9 + 7 to roll the dice so the sum of the face up numbers equals target.

      +

      Return the number of possible ways (out of fd total ways) modulo 109 + 7 to roll the dice so the sum of the face-up numbers equals target.

       

      Example 1:

      diff --git a/problems/number-of-different-subsequences-gcds/README.md b/problems/number-of-different-subsequences-gcds/README.md index 772562176..37eaa94b7 100644 --- a/problems/number-of-different-subsequences-gcds/README.md +++ b/problems/number-of-different-subsequences-gcds/README.md @@ -7,7 +7,7 @@ [< Previous](../minimum-absolute-sum-difference "Minimum Absolute Sum Difference")                  -Next > +[Next >](../maximum-number-of-accepted-invitations "Maximum Number of Accepted Invitations") ## [1819. Number of Different Subsequences GCDs (Hard)](https://leetcode.com/problems/number-of-different-subsequences-gcds "序列中不同最大公约数的数目") diff --git a/problems/partition-equal-subset-sum/README.md b/problems/partition-equal-subset-sum/README.md index 6654ecd76..c67044ca8 100644 --- a/problems/partition-equal-subset-sum/README.md +++ b/problems/partition-equal-subset-sum/README.md @@ -11,7 +11,7 @@ ## [416. Partition Equal Subset Sum (Medium)](https://leetcode.com/problems/partition-equal-subset-sum "分割等和子集") -

      Given a non-empty array nums containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.

      +

      Given a non-empty array nums containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.

       

      Example 1:

      diff --git a/problems/partition-to-k-equal-sum-subsets/README.md b/problems/partition-to-k-equal-sum-subsets/README.md index 9d06a68ed..7531de7b2 100644 --- a/problems/partition-to-k-equal-sum-subsets/README.md +++ b/problems/partition-to-k-equal-sum-subsets/README.md @@ -11,25 +11,30 @@ ## [698. Partition to K Equal Sum Subsets (Medium)](https://leetcode.com/problems/partition-to-k-equal-sum-subsets "划分为k个相等的子集") -

      Given an array of integers nums and a positive integer k, find whether it's possible to divide this array into k non-empty subsets whose sums are all equal.

      +

      Given an integer array nums and an integer k, return true if it is possible to divide this array into k non-empty subsets whose sums are all equal.

       

      +

      Example 1:

      -

      Example 1:

      +
      +Input: nums = [4,3,2,3,5,2,1], k = 4
      +Output: true
      +Explanation: It's possible to divide it into 4 subsets (5), (1, 4), (2,3), (2,3) with equal sums.
      +
      + +

      Example 2:

      -Input: nums = [4, 3, 2, 3, 5, 2, 1], k = 4
      -Output: True
      -Explanation: It's possible to divide it into 4 subsets (5), (1, 4), (2,3), (2,3) with equal sums.
      +Input: nums = [1,2,3,4], k = 3
      +Output: false
       

       

      - -

      Note:

      +

      Constraints:

        -
      • 1 <= k <= len(nums) <= 16.
      • -
      • 0 < nums[i] < 10000.
      • +
      • 1 <= k <= nums.length <= 16
      • +
      • 0 <= nums[i] <= 104
      ### Related Topics diff --git a/problems/path-sum-iii/README.md b/problems/path-sum-iii/README.md index 73a067462..951ad7f08 100644 --- a/problems/path-sum-iii/README.md +++ b/problems/path-sum-iii/README.md @@ -11,34 +11,34 @@ ## [437. Path Sum III (Medium)](https://leetcode.com/problems/path-sum-iii "路径总和 III") -

      You are given a binary tree in which each node contains an integer value.

      +

      Given the root of a binary tree and an integer targetSum, return the number of paths where the sum of the values along the path equals targetSum.

      -

      Find the number of paths that sum to a given value.

      +

      The path does not need to start or end at the root or a leaf, but it must go downwards (i.e., traveling only from parent nodes to child nodes).

      -

      The path does not need to start or end at the root or a leaf, but it must go downwards -(traveling only from parent nodes to child nodes).

      +

       

      +

      Example 1:

      + +
      +Input: root = [10,5,-3,3,2,null,11,3,-2,null,1], targetSum = 8
      +Output: 3
      +Explanation: The paths that sum to 8 are shown.
      +
      -

      The tree has no more than 1,000 nodes and the values are in the range -1,000,000 to 1,000,000. +

      Example 2:

      -

      Example:

      -root = [10,5,-3,3,2,null,11,3,-2,null,1], sum = 8
      -
      -      10
      -     /  \
      -    5   -3
      -   / \    \
      -  3   2   11
      - / \   \
      -3  -2   1
      +Input: root = [5,4,8,11,null,13,4,7,2,null,null,5,1], targetSum = 22
      +Output: 3
      +
      -Return 3. The paths that sum to 8 are: +

       

      +

      Constraints:

      -1. 5 -> 3 -2. 5 -> 2 -> 1 -3. -3 -> 11 -
    -

    +
      +
    • The number of nodes in the tree is in the range [0, 1000].
    • +
    • -109 <= Node.val <= 109
    • +
    • -1000 <= targetSum <= 1000
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/permutation-in-string/README.md b/problems/permutation-in-string/README.md index 59878437b..315b9f5b9 100644 --- a/problems/permutation-in-string/README.md +++ b/problems/permutation-in-string/README.md @@ -11,31 +11,32 @@ ## [567. Permutation in String (Medium)](https://leetcode.com/problems/permutation-in-string "字符串的排列") -

    Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string's permutations is the substring of the second string.

    +

    Given two strings s1 and s2, return true if s2 contains the permutation of s1.

    -

     

    +

    In other words, one of s1's permutations is the substring of s2.

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input: s1 = "ab" s2 = "eidbaooo"
    -Output: True
    -Explanation: s2 contains one permutation of s1 ("ba").
    +Input: s1 = "ab", s2 = "eidbaooo"
    +Output: true
    +Explanation: s2 contains one permutation of s1 ("ba").
     
    -

    Example 2:

    +

    Example 2:

    -Input:s1= "ab" s2 = "eidboaoo"
    -Output: False
    +Input: s1 = "ab", s2 = "eidboaoo"
    +Output: false
     

     

    Constraints:

      -
    • The input strings only contain lower case letters.
    • -
    • The length of both given strings is in range [1, 10,000].
    • +
    • 1 <= s1.length, s2.length <= 104
    • +
    • s1 and s2 consist of lowercase English letters.
    ### Related Topics diff --git a/problems/predict-the-winner/README.md b/problems/predict-the-winner/README.md index 6d627cf90..a5a8c3097 100644 --- a/problems/predict-the-winner/README.md +++ b/problems/predict-the-winner/README.md @@ -11,29 +11,30 @@ ## [486. Predict the Winner (Medium)](https://leetcode.com/problems/predict-the-winner "预测赢家") -

    Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a player picks a number, that number will not be available for the next player. This continues until all the scores have been chosen. The player with the maximum score wins.

    +

    You are given an integer array nums. Two players are playing a game with this array: player 1 and player 2.

    -

    Given an array of scores, predict whether player 1 is the winner. You can assume each player plays to maximize his score.

    +

    Player 1 and player 2 take turns, with player 1 starting first. Both players start the game with a score of 0. At each turn, the player takes one of the numbers from either end of the array (i.e., nums[0] or nums[nums.length - 1]) which reduces the size of the array by 1. The player adds the chosen number to their score. The game ends when there are no more elements in the array.

    -

    Example 1:

    +

    Return true if Player 1 can win the game. If the scores of both players are equal, then player 1 is still the winner, and you should also return true. You may assume that both players are playing optimally.

    + +

     

    +

    Example 1:

    -Input: [1, 5, 2]
    -Output: False
    -Explanation: Initially, player 1 can choose between 1 and 2. 
    +Input: nums = [1,5,2]
    +Output: false
    +Explanation: Initially, player 1 can choose between 1 and 2. 
     If he chooses 2 (or 1), then player 2 can choose from 1 (or 2) and 5. If player 2 chooses 5, then player 1 will be left with 1 (or 2). 
     So, final score of player 1 is 1 + 2 = 3, and player 2 is 5. 
    -Hence, player 1 will never be the winner and you need to return False.
    +Hence, player 1 will never be the winner and you need to return false.
     
    -

     

    - -

    Example 2:

    +

    Example 2:

    -Input: [1, 5, 233, 7]
    -Output: True
    -Explanation: Player 1 first chooses 1. Then player 2 have to choose between 5 and 7. No matter which number player 2 choose, player 1 can choose 233.
    +Input: nums = [1,5,233,7]
    +Output: true
    +Explanation: Player 1 first chooses 1. Then player 2 has to choose between 5 and 7. No matter which number player 2 choose, player 1 can choose 233.
     Finally, player 1 has more score (234) than player 2 (12), so you need to return True representing player1 can win.
     
    @@ -41,9 +42,8 @@ Finally, player 1 has more score (234) than player 2 (12), so you need to return

    Constraints:

      -
    • 1 <= length of the array <= 20.
    • -
    • Any scores in the given array are non-negative integers and will not exceed 10,000,000.
    • -
    • If the scores of both players are equal, then player 1 is still the winner.
    • +
    • 1 <= nums.length <= 20
    • +
    • 0 <= nums[i] <= 107
    ### Related Topics diff --git a/problems/previous-permutation-with-one-swap/README.md b/problems/previous-permutation-with-one-swap/README.md index 053e6e743..1f1162653 100644 --- a/problems/previous-permutation-with-one-swap/README.md +++ b/problems/previous-permutation-with-one-swap/README.md @@ -11,7 +11,7 @@ ## [1053. Previous Permutation With One Swap (Medium)](https://leetcode.com/problems/previous-permutation-with-one-swap "交换一次的先前排列") -

    Given an array of positive integers arr (not necessarily distinct), return the lexicographically largest permutation that is smaller than arr, that can be made with exactly one swap (A swap exchanges the positions of two numbers arr[i] and arr[j]). If it cannot be done, then return the same array.

    +

    Given an array of positive integers arr (not necessarily distinct), return the lexicographically largest permutation that is smaller than arr, that can be made with exactly one swap (A swap exchanges the positions of two numbers arr[i] and arr[j]). If it cannot be done, then return the same array.

     

    Example 1:

    diff --git a/problems/print-in-order/README.md b/problems/print-in-order/README.md index ee1d4c7e1..270433f83 100644 --- a/problems/print-in-order/README.md +++ b/problems/print-in-order/README.md @@ -15,36 +15,34 @@
     public class Foo {
    -  public void first() { print("first"); }
    -  public void second() { print("second"); }
    -  public void third() { print("third"); }
    +  public void first() { print("first"); }
    +  public void second() { print("second"); }
    +  public void third() { print("third"); }
     }
     
    -

    The same instance of Foo will be passed to three different threads. Thread A will call first(), thread B will call second(), and thread C will call third(). Design a mechanism and modify the program to ensure that second() is executed after first(), and third() is executed after second().

    +

    The same instance of Foo will be passed to three different threads. Thread A will call first(), thread B will call second(), and thread C will call third(). Design a mechanism and modify the program to ensure that second() is executed after first(), and third() is executed after second().

    -

     

    +

    Note:

    + +

    We do not know how the threads will be scheduled in the operating system, even though the numbers in the input seem to imply the ordering. The input format you see is mainly to ensure our tests' comprehensiveness.

    +

     

    Example 1:

    -Input: [1,2,3]
    -Output: "firstsecondthird"
    +Input: nums = [1,2,3]
    +Output: "firstsecondthird"
     Explanation: There are three threads being fired asynchronously. The input [1,2,3] means thread A calls first(), thread B calls second(), and thread C calls third(). "firstsecondthird" is the correct output.
     

    Example 2:

    -Input: [1,3,2]
    -Output: "firstsecondthird"
    -Explanation: The input [1,3,2] means thread A calls first(), thread B calls third(), and thread C calls second(). "firstsecondthird" is the correct output.
    - -

     

    - -

    Note:

    - -

    We do not know how the threads will be scheduled in the operating system, even though the numbers in the input seems to imply the ordering. The input format you see is mainly to ensure our tests' comprehensiveness.

    +Input: nums = [1,3,2] +Output: "firstsecondthird" +Explanation: The input [1,3,2] means thread A calls first(), thread B calls third(), and thread C calls second(). "firstsecondthird" is the correct output. +
    ### Similar Questions 1. [Print FooBar Alternately](../print-foobar-alternately) (Medium) diff --git a/problems/queries-on-number-of-points-inside-a-circle/README.md b/problems/queries-on-number-of-points-inside-a-circle/README.md new file mode 100644 index 000000000..c716702d1 --- /dev/null +++ b/problems/queries-on-number-of-points-inside-a-circle/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../minimum-operations-to-make-the-array-increasing "Minimum Operations to Make the Array Increasing") +                 +[Next >](../maximum-xor-for-each-query "Maximum XOR for Each Query") + +## [1828. Queries on Number of Points Inside a Circle (Medium)](https://leetcode.com/problems/queries-on-number-of-points-inside-a-circle "统计一个圆中点的数目") + +

    You are given an array points where points[i] = [xi, yi] is the coordinates of the ith point on a 2D plane. Multiple points can have the same coordinates.

    + +

    You are also given an array queries where queries[j] = [xj, yj, rj] describes a circle centered at (xj, yj) with a radius of rj.

    + +

    For each query queries[j], compute the number of points inside the jth circle. Points on the border of the circle are considered inside.

    + +

    Return an array answer, where answer[j] is the answer to the jth query.

    + +

     

    +

    Example 1:

    + +
    +Input: points = [[1,3],[3,3],[5,3],[2,2]], queries = [[2,3,1],[4,3,1],[1,1,2]]
    +Output: [3,2,2]
    +Explanation: The points and circles are shown above.
    +queries[0] is the green circle, queries[1] is the red circle, and queries[2] is the blue circle.
    +
    + +

    Example 2:

    + +
    +Input: points = [[1,1],[2,2],[3,3],[4,4],[5,5]], queries = [[1,2,2],[2,2,2],[4,3,2],[4,3,3]]
    +Output: [2,3,2,4]
    +Explanation: The points and circles are shown above.
    +queries[0] is green, queries[1] is red, queries[2] is blue, and queries[3] is purple.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= points.length <= 500
    • +
    • points[i].length == 2
    • +
    • 0 <= x​​​​​​i, y​​​​​​i <= 500
    • +
    • 1 <= queries.length <= 500
    • +
    • queries[j].length == 3
    • +
    • 0 <= xj, yj <= 500
    • +
    • 1 <= rj <= 500
    • +
    • All coordinates are integers.
    • +
    + +

     

    +

    Follow up: Could you find the answer for each query in better complexity than O(n)?

    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +For a point to be inside a circle, the euclidean distance between it and the circle's center needs to be less than or equal to the radius. +
    + +
    +Hint 2 +Brute force for each circle and iterate overall points and find those inside it. +
    diff --git a/problems/remove-all-adjacent-duplicates-in-string-ii/README.md b/problems/remove-all-adjacent-duplicates-in-string-ii/README.md index 206bea2c3..e7b2a3f6d 100644 --- a/problems/remove-all-adjacent-duplicates-in-string-ii/README.md +++ b/problems/remove-all-adjacent-duplicates-in-string-ii/README.md @@ -11,13 +11,11 @@ ## [1209. Remove All Adjacent Duplicates in String II (Medium)](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii "删除字符串中的所有相邻重复项 II") -

    Given a string s, a k duplicate removal consists of choosing k adjacent and equal letters from s and removing them causing the left and the right side of the deleted substring to concatenate together.

    +

    You are given a string s and an integer k, a k duplicate removal consists of choosing k adjacent and equal letters from s and removing them, causing the left and the right side of the deleted substring to concatenate together.

    -

    We repeatedly make k duplicate removals on s until we no longer can.

    +

    We repeatedly make k duplicate removals on s until we no longer can.

    -

    Return the final string after all such duplicate removals have been made.

    - -

    It is guaranteed that the answer is unique.

    +

    Return the final string after all such duplicate removals have been made. It is guaranteed that the answer is unique.

     

    Example 1:

    @@ -48,8 +46,8 @@ Finally delete "ddd", get "aa"

    Constraints:

      -
    • 1 <= s.length <= 10^5
    • -
    • 2 <= k <= 10^4
    • +
    • 1 <= s.length <= 105
    • +
    • 2 <= k <= 104
    • s only contains lower case English letters.
    diff --git a/problems/remove-duplicates-from-an-unsorted-linked-list/README.md b/problems/remove-duplicates-from-an-unsorted-linked-list/README.md new file mode 100644 index 000000000..e2a5719b9 --- /dev/null +++ b/problems/remove-duplicates-from-an-unsorted-linked-list/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../find-xor-sum-of-all-pairs-bitwise-and "Find XOR Sum of All Pairs Bitwise AND") +                 +[Next >](../sum-of-digits-in-base-k "Sum of Digits in Base K") + +## [1836. Remove Duplicates From an Unsorted Linked List (Medium)](https://leetcode.com/problems/remove-duplicates-from-an-unsorted-linked-list "") + + + +### Related Topics + [[Linked List](../../tag/linked-list/README.md)] + +### Hints +
    +Hint 1 +Is there a way we can know beforehand which nodes to delete? +
    + +
    +Hint 2 +Count the number of appearances for each number. +
    diff --git a/problems/remove-k-digits/README.md b/problems/remove-k-digits/README.md index 1444883ab..b6bbd5378 100644 --- a/problems/remove-k-digits/README.md +++ b/problems/remove-k-digits/README.md @@ -11,40 +11,41 @@ ## [402. Remove K Digits (Medium)](https://leetcode.com/problems/remove-k-digits "移掉K位数字") -

    Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. -

    +

    Given string num representing a non-negative integer num, and an integer k, return the smallest possible integer after removing k digits from num.

    -

    Note:
    -

      -
    • The length of num is less than 10002 and will be ≥ k.
    • -
    • The given num does not contain any leading zero.
    • -
    - -

    +

     

    +

    Example 1:

    -

    Example 1:

    -Input: num = "1432219", k = 3
    -Output: "1219"
    -Explanation: Remove the three digits 4, 3, and 2 to form the new number 1219 which is the smallest.
    +Input: num = "1432219", k = 3
    +Output: "1219"
    +Explanation: Remove the three digits 4, 3, and 2 to form the new number 1219 which is the smallest.
     
    -

    -

    Example 2: +

    Example 2:

    +
    -Input: num = "10200", k = 1
    -Output: "200"
    -Explanation: Remove the leading 1 and the number is 200. Note that the output must not contain leading zeroes.
    +Input: num = "10200", k = 1
    +Output: "200"
    +Explanation: Remove the leading 1 and the number is 200. Note that the output must not contain leading zeroes.
     
    -

    -

    Example 3: +

    Example 3:

    +
    -Input: num = "10", k = 2
    -Output: "0"
    -Explanation: Remove all the digits from the number and it is left with nothing which is 0.
    +Input: num = "10", k = 2
    +Output: "0"
    +Explanation: Remove all the digits from the number and it is left with nothing which is 0.
     
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= num.length <= 105
    • +
    • num consists of only digits.
    • +
    • num does not have any leading zeros except for the zero itself.
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/reshape-the-matrix/README.md b/problems/reshape-the-matrix/README.md index 53b4b856d..e929af1ac 100644 --- a/problems/reshape-the-matrix/README.md +++ b/problems/reshape-the-matrix/README.md @@ -11,52 +11,39 @@ ## [566. Reshape the Matrix (Easy)](https://leetcode.com/problems/reshape-the-matrix "重塑矩阵") -

    In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data. -

    +

    In MATLAB, there is a handy function called reshape which can reshape an m x n matrix into a new one with a different size r x c keeping its original data.

    -

    -You're given a matrix represented by a two-dimensional array, and two positive integers r and c representing the row number and column number of the wanted reshaped matrix, respectively.

    +

    You are given an m x n matrix mat and two integers r and c representing the row number and column number of the wanted reshaped matrix.

    -

    The reshaped matrix need to be filled with all the elements of the original matrix in the same row-traversing order as they were. -

    +

    The reshaped matrix should be filled with all the elements of the original matrix in the same row-traversing order as they were.

    -

    -If the 'reshape' operation with given parameters is possible and legal, output the new reshaped matrix; Otherwise, output the original matrix. -

    +

    If the reshape operation with given parameters is possible and legal, output the new reshaped matrix; Otherwise, output the original matrix.

    -

    Example 1:
    +

     

    +

    Example 1:

    +
    -Input: 
    -nums = 
    -[[1,2],
    - [3,4]]
    -r = 1, c = 4
    -Output: 
    -[[1,2,3,4]]
    -Explanation:
    The row-traversing of nums is [1,2,3,4]. The new reshaped matrix is a 1 * 4 matrix, fill it row by row by using the previous list. +Input: mat = [[1,2],[3,4]], r = 1, c = 4 +Output: [[1,2,3,4]]
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: 
    -nums = 
    -[[1,2],
    - [3,4]]
    -r = 2, c = 4
    -Output: 
    -[[1,2],
    - [3,4]]
    -Explanation:
    There is no way to reshape a 2 * 2 matrix to a 2 * 4 matrix. So output the original matrix. +Input: mat = [[1,2],[3,4]], r = 2, c = 4 +Output: [[1,2],[3,4]]
    -

    -

    Note:
    -

      -
    1. The height and width of the given matrix is in range [1, 100].
    2. -
    3. The given r and c are all positive.
    4. -
    -

    +

     

    +

    Constraints:

    + +
      +
    • m == mat.length
    • +
    • n == mat[i].length
    • +
    • 1 <= m, n <= 100
    • +
    • -1000 <= mat[i][j] <= 1000
    • +
    • 1 <= r, c <= 300
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] @@ -81,5 +68,5 @@ Try to use division and modulus to convert 1-d index into 2-d indices.
    Hint 4 -M[i] => M[n/i][n%i] Will it result in right mapping? Take some example and check this formulae. +M[i] => M[i/n][n%i] Will it result in right mapping? Take some example and check this formula.
    diff --git a/problems/reverse-pairs/README.md b/problems/reverse-pairs/README.md index 11f7dd8a4..e1eb7eb2b 100644 --- a/problems/reverse-pairs/README.md +++ b/problems/reverse-pairs/README.md @@ -11,28 +11,25 @@ ## [493. Reverse Pairs (Hard)](https://leetcode.com/problems/reverse-pairs "翻转对") -

    Given an array nums, we call (i, j) an important reverse pair if i < j and nums[i] > 2*nums[j].

    - -

    You need to return the number of important reverse pairs in the given array.

    - -

    Example1: -

    -Input: [1,3,2,3,1]
    -Output: 2
    -

    - -

    Example2: -

    -Input: [2,4,3,5,1]
    -Output: 3
    -

    - -

    Note:
    -

      -
    1. The length of the given array will not exceed 50,000.
    2. -
    3. All the numbers in the input array are in the range of 32-bit integer.
    4. -
    -

    +

    Given an integer array nums, return the number of reverse pairs in the array.

    + +

    A reverse pair is a pair (i, j) where 0 <= i < j < nums.length and nums[i] > 2 * nums[j].

    + +

     

    +

    Example 1:

    +
    Input: nums = [1,3,2,3,1]
    +Output: 2
    +

    Example 2:

    +
    Input: nums = [2,4,3,5,1]
    +Output: 3
    +
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 5 * 104
    • +
    • 231 <= nums[i] <= 231 - 1
    • +
    ### Related Topics [[Sort](../../tag/sort/README.md)] diff --git a/problems/rotate-array/README.md b/problems/rotate-array/README.md index e7fe7cf82..4f0fe02f0 100644 --- a/problems/rotate-array/README.md +++ b/problems/rotate-array/README.md @@ -39,7 +39,7 @@ rotate 2 steps to the right: [3,99,-1,-100]

    Constraints:

      -
    • 1 <= nums.length <= 2 * 104
    • +
    • 1 <= nums.length <= 105
    • -231 <= nums[i] <= 231 - 1
    • 0 <= k <= 105
    diff --git a/problems/shopping-offers/README.md b/problems/shopping-offers/README.md index 029e7fe4e..c23e5bf8f 100644 --- a/problems/shopping-offers/README.md +++ b/problems/shopping-offers/README.md @@ -11,56 +11,50 @@ ## [638. Shopping Offers (Medium)](https://leetcode.com/problems/shopping-offers "大礼包") -

    -In LeetCode Store, there are some kinds of items to sell. Each item has a price. -

    +

    In LeetCode Store, there are n items to sell. Each item has a price. However, there are some special offers, and a special offer consists of one or more different kinds of items with a sale price.

    -

    -However, there are some special offers, and a special offer consists of one or more different kinds of items with a sale price. -

    +

    You are given an integer array price where price[i] is the price of the ith item, and an integer array needs where needs[i] is the number of pieces of the ith item you want to buy.

    -

    -You are given the each item's price, a set of special offers, and the number we need to buy for each item. -The job is to output the lowest price you have to pay for exactly certain items as given, where you could make optimal use of the special offers. -

    +

    You are also given an array special where special[i] is of size n + 1 where special[i][j] is the number of pieces of the jth item in the ith offer and special[i][n] (i.e., the last integer in the array) is the price of the ith offer.

    -

    -Each special offer is represented in the form of an array, the last number represents the price you need to pay for this special offer, other numbers represents how many specific items you could get if you buy this offer. -

    +

    Return the lowest price you have to pay for exactly certain items as given, where you could make optimal use of the special offers. You are not allowed to buy more items than you want, even if that would lower the overall price. You could use any of the special offers as many times as you want.

    -

    You could use any of special offers as many times as you want.

    +

     

    +

    Example 1:

    -

    Example 1:

    -Input: [2,5], [[3,0,5],[1,2,10]], [3,2]
    -Output: 14
    -Explanation: 
    -There are two kinds of items, A and B. Their prices are $2 and $5 respectively. 
    +Input: price = [2,5], special = [[3,0,5],[1,2,10]], needs = [3,2]
    +Output: 14
    +Explanation: There are two kinds of items, A and B. Their prices are $2 and $5 respectively. 
     In special offer 1, you can pay $5 for 3A and 0B
     In special offer 2, you can pay $10 for 1A and 2B. 
     You need to buy 3A and 2B, so you may pay $10 for 1A and 2B (special offer #2), and $4 for 2A.
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: [2,3,4], [[1,1,0,4],[2,2,1,9]], [1,2,1]
    -Output: 11
    -Explanation: 
    -The price of A is $2, and $3 for B, $4 for C. 
    +Input: price = [2,3,4], special = [[1,1,0,4],[2,2,1,9]], needs = [1,2,1]
    +Output: 11
    +Explanation: The price of A is $2, and $3 for B, $4 for C. 
     You may pay $4 for 1A and 1B, and $9 for 2A ,2B and 1C. 
     You need to buy 1A ,2B and 1C, so you may pay $4 for 1A and 1B (special offer #1), and $3 for 1B, $4 for 1C. 
     You cannot add more items, though only $9 for 2A ,2B and 1C.
     
    -

    -

    Note:
    -

      -
    1. There are at most 6 kinds of items, 100 special offers.
    2. -
    3. For each item, you need to buy at most 6 of them.
    4. -
    5. You are not allowed to buy more items than you want, even if that would lower the overall price.
    6. -
    -

    +

     

    +

    Constraints:

    + +
      +
    • n == price.length
    • +
    • n == needs.length
    • +
    • 1 <= n <= 6
    • +
    • 0 <= price[i] <= 10
    • +
    • 0 <= needs[i] <= 10
    • +
    • 1 <= special.length <= 100
    • +
    • special[i].length == n + 1
    • +
    • 0 <= special[i][j] <= 50
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/sign-of-the-product-of-an-array/README.md b/problems/sign-of-the-product-of-an-array/README.md new file mode 100644 index 000000000..9eb5a9e4f --- /dev/null +++ b/problems/sign-of-the-product-of-an-array/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../find-customers-with-positive-revenue-this-year "Find Customers With Positive Revenue this Year") +                 +[Next >](../find-the-winner-of-the-circular-game "Find the Winner of the Circular Game") + +## [1822. Sign of the Product of an Array (Easy)](https://leetcode.com/problems/sign-of-the-product-of-an-array "数组元素积的符号") + +

    There is a function signFunc(x) that returns:

    + +
      +
    • 1 if x is positive.
    • +
    • -1 if x is negative.
    • +
    • 0 if x is equal to 0.
    • +
    + +

    You are given an integer array nums. Let product be the product of all values in the array nums.

    + +

    Return signFunc(product).

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [-1,-2,-3,-4,3,2,1]
    +Output: 1
    +Explanation: The product of all values in the array is 144, and signFunc(144) = 1
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,5,0,2,-3]
    +Output: 0
    +Explanation: The product of all values in the array is 0, and signFunc(0) = 0
    +
    + +

    Example 3:

    + +
    +Input: nums = [-1,1,-1,1,-1]
    +Output: -1
    +Explanation: The product of all values in the array is -1, and signFunc(-1) = -1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • -100 <= nums[i] <= 100
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +If there is a 0 in the array the answer is 0 +
    + +
    +Hint 2 +To avoid overflow make all the negative numbers -1 and all positive numbers 1 and calculate the prod +
    diff --git a/problems/single-threaded-cpu/README.md b/problems/single-threaded-cpu/README.md new file mode 100644 index 000000000..7a83fa3cd --- /dev/null +++ b/problems/single-threaded-cpu/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../maximum-ice-cream-bars "Maximum Ice Cream Bars") +                 +[Next >](../find-xor-sum-of-all-pairs-bitwise-and "Find XOR Sum of All Pairs Bitwise AND") + +## [1834. Single-Threaded CPU (Medium)](https://leetcode.com/problems/single-threaded-cpu "单线程 CPU") + +

    You are given n​​​​​​ tasks labeled from 0 to n - 1 represented by a 2D integer array tasks, where tasks[i] = [enqueueTimei, processingTimei] means that the i​​​​​​th​​​​ task will be available to process at enqueueTimei and will take processingTimei to finish processing.

    + +

    You have a single-threaded CPU that can process at most one task at a time and will act in the following way:

    + +
      +
    • If the CPU is idle and there are no available tasks to process, the CPU remains idle.
    • +
    • If the CPU is idle and there are available tasks, the CPU will choose the one with the shortest processing time. If multiple tasks have the same shortest processing time, it will choose the task with the smallest index.
    • +
    • Once a task is started, the CPU will process the entire task without stopping.
    • +
    • The CPU can finish a task then start a new one instantly.
    • +
    + +

    Return the order in which the CPU will process the tasks.

    + +

     

    +

    Example 1:

    + +
    +Input: tasks = [[1,2],[2,4],[3,2],[4,1]]
    +Output: [0,2,3,1]
    +Explanation: The events go as follows: 
    +- At time = 1, task 0 is available to process. Available tasks = {0}.
    +- Also at time = 1, the idle CPU starts processing task 0. Available tasks = {}.
    +- At time = 2, task 1 is available to process. Available tasks = {1}.
    +- At time = 3, task 2 is available to process. Available tasks = {1, 2}.
    +- Also at time = 3, the CPU finishes task 0 and starts processing task 2 as it is the shortest. Available tasks = {1}.
    +- At time = 4, task 3 is available to process. Available tasks = {1, 3}.
    +- At time = 5, the CPU finishes task 2 and starts processing task 3 as it is the shortest. Available tasks = {1}.
    +- At time = 6, the CPU finishes task 3 and starts processing task 1. Available tasks = {}.
    +- At time = 10, the CPU finishes task 1 and becomes idle.
    +
    + +

    Example 2:

    + +
    +Input: tasks = [[7,10],[7,12],[7,5],[7,4],[7,2]]
    +Output: [4,3,2,0,1]
    +Explanation: The events go as follows:
    +- At time = 7, all the tasks become available. Available tasks = {0,1,2,3,4}.
    +- Also at time = 7, the idle CPU starts processing task 4. Available tasks = {0,1,2,3}.
    +- At time = 9, the CPU finishes task 4 and starts processing task 3. Available tasks = {0,1,2}.
    +- At time = 13, the CPU finishes task 3 and starts processing task 2. Available tasks = {0,1}.
    +- At time = 18, the CPU finishes task 2 and starts processing task 0. Available tasks = {1}.
    +- At time = 28, the CPU finishes task 0 and starts processing task 1. Available tasks = {}.
    +- At time = 40, the CPU finishes task 1 and becomes idle.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • tasks.length == n
    • +
    • 1 <= n <= 105
    • +
    • 1 <= enqueueTimei, processingTimei <= 109
    • +
    + +### Related Topics + [[Heap](../../tag/heap/README.md)] + +### Hints +
    +Hint 1 +To simulate the problem we first need to note that if at any point in time there are no enqueued tasks we need to wait to the smallest enqueue time of a non-processed element +
    + +
    +Hint 2 +We need a data structure like a min-heap to support choosing the task with the smallest processing time from all the enqueued tasks +
    diff --git a/problems/sliding-window-median/README.md b/problems/sliding-window-median/README.md index 86deb00fb..498f08265 100644 --- a/problems/sliding-window-median/README.md +++ b/problems/sliding-window-median/README.md @@ -11,34 +11,48 @@ ## [480. Sliding Window Median (Hard)](https://leetcode.com/problems/sliding-window-median "滑动窗口中位数") -

    Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.

    -Examples: +

    The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle values.

    -

    [2,3,4] , the median is 3

    +
      +
    • For examples, if arr = [2,3,4], the median is 3.
    • +
    • For examples, if arr = [1,2,3,4], the median is (2 + 3) / 2 = 2.5.
    • +
    -

    [2,3], the median is (2 + 3) / 2 = 2.5

    +

    You are given an integer array nums and an integer k. There is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position.

    -

    Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Your job is to output the median array for each window in the original array.

    +

    Return the median array for each window in the original array. Answers within 10-5 of the actual value will be accepted.

    -

    For example,
    -Given nums = [1,3,-1,-3,5,3,6,7], and k = 3.

    +

     

    +

    Example 1:

    +Input: nums = [1,3,-1,-3,5,3,6,7], k = 3
    +Output: [1.00000,-1.00000,-1.00000,3.00000,5.00000,6.00000]
    +Explanation: 
     Window position                Median
    ----------------               -----
    -[1  3  -1] -3  5  3  6  7       1
    - 1 [3  -1  -3] 5  3  6  7       -1
    - 1  3 [-1  -3  5] 3  6  7       -1
    - 1  3  -1 [-3  5  3] 6  7       3
    - 1  3  -1  -3 [5  3  6] 7       5
    - 1  3  -1  -3  5 [3  6  7]      6
    +---------------                -----
    +[1  3  -1] -3  5  3  6  7        1
    + 1 [3  -1  -3] 5  3  6  7       -1
    + 1  3 [-1  -3  5] 3  6  7       -1
    + 1  3  -1 [-3  5  3] 6  7        3
    + 1  3  -1  -3 [5  3  6] 7        5
    + 1  3  -1  -3  5 [3  6  7]       6
     
    -

    Therefore, return the median sliding window as [1,-1,-1,3,5,6].

    +

    Example 2:

    -

    Note:
    -You may assume k is always valid, ie: k is always smaller than input array's size for non-empty array.
    -Answers within 10^-5 of the actual value will be accepted as correct.

    +
    +Input: nums = [1,2,3,4,2,3,1,4,2], k = 3
    +Output: [2.00000,3.00000,3.00000,3.00000,2.00000,3.00000,2.00000]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= nums.length <= 105
    • +
    • 231 <= nums[i] <= 231 - 1
    • +
    ### Related Topics [[Sliding Window](../../tag/sliding-window/README.md)] diff --git a/problems/smallest-good-base/README.md b/problems/smallest-good-base/README.md index 57031804d..99e61b3f4 100644 --- a/problems/smallest-good-base/README.md +++ b/problems/smallest-good-base/README.md @@ -11,48 +11,42 @@ ## [483. Smallest Good Base (Hard)](https://leetcode.com/problems/smallest-good-base "最小好进制") -

    For an integer n, we call k>=2 a good base of n, if all digits of n base k are 1.

    +

    Given an integer n represented as a string, return the smallest good base of n.

    -

    Now given a string representing n, you should return the smallest good base of n in string format.

    +

    We call k >= 2 a good base of n, if all digits of n base k are 1's.

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input: "13"
    -Output: "3"
    -Explanation: 13 base 3 is 111.
    +Input: n = "13"
    +Output: "3"
    +Explanation: 13 base 3 is 111.
     
    -

     

    - -

    Example 2:

    +

    Example 2:

    -Input: "4681"
    -Output: "8"
    -Explanation: 4681 base 8 is 11111.
    +Input: n = "4681"
    +Output: "8"
    +Explanation: 4681 base 8 is 11111.
     
    -

     

    - -

    Example 3:

    +

    Example 3:

    -Input: "1000000000000000000"
    -Output: "999999999999999999"
    -Explanation: 1000000000000000000 base 999999999999999999 is 11.
    +Input: n = "1000000000000000000"
    +Output: "999999999999999999"
    +Explanation: 1000000000000000000 base 999999999999999999 is 11.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. The range of n is [3, 10^18].
    2. -
    3. The string representing n is always valid and will not have leading zeros.
    4. -
    - -

     

    +
      +
    • n is an integer in the range [3, 1018].
    • +
    • n does not contain any leading zeros.
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/sort-an-array/README.md b/problems/sort-an-array/README.md index fb632ec4e..70fb0ae7b 100644 --- a/problems/sort-an-array/README.md +++ b/problems/sort-an-array/README.md @@ -25,6 +25,6 @@

    Constraints:

      -
    • 1 <= nums.length <= 50000
    • -
    • -50000 <= nums[i] <= 50000
    • +
    • 1 <= nums.length <= 5 * 104
    • +
    • -5 * 104 <= nums[i] <= 5 * 104
    diff --git a/problems/sort-array-by-parity-ii/README.md b/problems/sort-array-by-parity-ii/README.md index b09b0298f..dfef11e55 100644 --- a/problems/sort-array-by-parity-ii/README.md +++ b/problems/sort-array-by-parity-ii/README.md @@ -43,6 +43,9 @@
  • 0 <= nums[i] <= 1000
  • +

     

    +

    Follow Up: Could you solve it in-place?

    + ### Related Topics [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] diff --git a/problems/sort-characters-by-frequency/README.md b/problems/sort-characters-by-frequency/README.md index 41923ed44..7dcc66374 100644 --- a/problems/sort-characters-by-frequency/README.md +++ b/problems/sort-characters-by-frequency/README.md @@ -11,49 +11,43 @@ ## [451. Sort Characters By Frequency (Medium)](https://leetcode.com/problems/sort-characters-by-frequency "根据字符出现频率排序") -

    Given a string, sort it in decreasing order based on the frequency of characters.

    +

    Given a string s, sort it in decreasing order based on the frequency of characters, and return the sorted string.

    -

    Example 1: -

    -Input:
    -"tree"
    -
    -Output:
    -"eert"
    +

     

    +

    Example 1:

    -Explanation: -'e' appears twice while 'r' and 't' both appear once. -So 'e' must appear before both 'r' and 't'. Therefore "eetr" is also a valid answer. -
    -

    - -

    Example 2:

    -Input:
    -"cccaaa"
    +Input: s = "tree"
    +Output: "eert"
    +Explanation: 'e' appears twice while 'r' and 't' both appear once.
    +So 'e' must appear before both 'r' and 't'. Therefore "eetr" is also a valid answer.
    +
    -Output: -"cccaaa" +

    Example 2:

    -Explanation: -Both 'c' and 'a' appear three times, so "aaaccc" is also a valid answer. -Note that "cacaca" is incorrect, as the same characters must be together. +
    +Input: s = "cccaaa"
    +Output: "aaaccc"
    +Explanation: Both 'c' and 'a' appear three times, so "aaaccc" is also a valid answer.
    +Note that "cacaca" is incorrect, as the same characters must be together.
     
    -

    -

    Example 3: +

    Example 3:

    +
    -Input:
    -"Aabb"
    +Input: s = "Aabb"
    +Output: "bbAa"
    +Explanation: "bbaA" is also a valid answer, but "Aabb" is incorrect.
    +Note that 'A' and 'a' are treated as two different characters.
    +
    -Output: -"bbAa" +

     

    +

    Constraints:

    -Explanation: -"bbaA" is also a valid answer, but "Aabb" is incorrect. -Note that 'A' and 'a' are treated as two different characters. -
    -

    +
      +
    • 1 <= s.length <= 5 * 105
    • +
    • s consists of English letters and digits.
    • +
    ### Related Topics [[Heap](../../tag/heap/README.md)] diff --git a/problems/stickers-to-spell-word/README.md b/problems/stickers-to-spell-word/README.md index 70c307e12..e08895150 100644 --- a/problems/stickers-to-spell-word/README.md +++ b/problems/stickers-to-spell-word/README.md @@ -11,51 +11,45 @@ ## [691. Stickers to Spell Word (Hard)](https://leetcode.com/problems/stickers-to-spell-word "贴纸拼词") -

    -We are given N different types of stickers. Each sticker has a lowercase English word on it. -

    -You would like to spell out the given target string by cutting individual letters from your collection of stickers and rearranging them. -

    -You can use each sticker more than once if you want, and you have infinite quantities of each sticker. -

    -What is the minimum number of stickers that you need to spell out the target? If the task is impossible, return -1. -

    - -

    Example 1:

    -

    Input:

    -["with", "example", "science"], "thehat"
    -

    - -

    Output:

    -3
    -

    - -

    Explanation:

    -We can use 2 "with" stickers, and 1 "example" sticker.
    -After cutting and rearrange the letters of those stickers, we can form the target "thehat".
    +

    We are given n different types of stickers. Each sticker has a lowercase English word on it.

    + +

    You would like to spell out the given string target by cutting individual letters from your collection of stickers and rearranging them. You can use each sticker more than once if you want, and you have infinite quantities of each sticker.

    + +

    Return the minimum number of stickers that you need to spell out target. If the task is impossible, return -1.

    + +

    Note: In all test cases, all words were chosen randomly from the 1000 most common US English words, and target was chosen as a concatenation of two random words.

    + +

     

    +

    Example 1:

    + +
    +Input: stickers = ["with","example","science"], target = "thehat"
    +Output: 3
    +Explanation:
    +We can use 2 "with" stickers, and 1 "example" sticker.
    +After cutting and rearrange the letters of those stickers, we can form the target "thehat".
     Also, this is the minimum number of stickers necessary to form the target string.
    -

    - -

    Example 2:

    -

    Input:

    -["notice", "possible"], "basicbasic"
    -

    - -

    Output:

    --1
    -

    - -

    Explanation:

    -We can't form the target "basicbasic" from cutting letters from the given stickers.
    -

    - -

    Note: -

  • stickers has length in the range [1, 50].
  • -
  • stickers consists of lowercase English words (without apostrophes).
  • -
  • target has length in the range [1, 15], and consists of lowercase English letters.
  • -
  • In all test cases, all words were chosen randomly from the 1000 most common US English words, and the target was chosen as a concatenation of two random words.
  • -
  • The time limit may be more challenging than usual. It is expected that a 50 sticker test case can be solved within 35ms on average.
  • -

    +
    + +

    Example 2:

    + +
    +Input: stickers = ["notice","possible"], target = "basicbasic"
    +Output: -1
    +Explanation:
    +We cannot form the target "basicbasic" from cutting letters from the given stickers.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == stickers.length
    • +
    • 1 <= n <= 50
    • +
    • 1 <= stickers[i].length <= 10
    • +
    • 1 <= target <= 15
    • +
    • stickers[i] and target consist of lowercase English letters.
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/sum-of-digits-in-base-k/README.md b/problems/sum-of-digits-in-base-k/README.md new file mode 100644 index 000000000..a24e7e415 --- /dev/null +++ b/problems/sum-of-digits-in-base-k/README.md @@ -0,0 +1,56 @@ + + + + + + + +[< Previous](../remove-duplicates-from-an-unsorted-linked-list "Remove Duplicates From an Unsorted Linked List") +                 +[Next >](../frequency-of-the-most-frequent-element "Frequency of the Most Frequent Element") + +## [1837. Sum of Digits in Base K (Easy)](https://leetcode.com/problems/sum-of-digits-in-base-k "K 进制表示下的各位数字总和") + +

    Given an integer n (in base 10) and a base k, return the sum of the digits of n after converting n from base 10 to base k.

    + +

    After converting, each digit should be interpreted as a base 10 number, and the sum should be returned in base 10.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 34, k = 6
    +Output: 9
    +Explanation: 34 (base 10) expressed in base 6 is 54. 5 + 4 = 9.
    +
    + +

    Example 2:

    + +
    +Input: n = 10, k = 10
    +Output: 1
    +Explanation: n is already in base 10. 1 + 0 = 1.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 100
    • +
    • 2 <= k <= 10
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Convert the given number into base k. +
    + +
    +Hint 2 +Use mod-10 to find what each digit is after the conversion and sum the digits. +
    diff --git a/problems/sum-of-left-leaves/README.md b/problems/sum-of-left-leaves/README.md index 350540eef..481e762e5 100644 --- a/problems/sum-of-left-leaves/README.md +++ b/problems/sum-of-left-leaves/README.md @@ -11,19 +11,31 @@ ## [404. Sum of Left Leaves (Easy)](https://leetcode.com/problems/sum-of-left-leaves "左叶子之和") -

    Find the sum of all left leaves in a given binary tree.

    +

    Given the root of a binary tree, return the sum of all left leaves.

    -

    Example: +

     

    +

    Example 1:

    +
    -    3
    -   / \
    -  9  20
    -    /  \
    -   15   7
    +Input: root = [3,9,20,null,null,15,7]
    +Output: 24
    +Explanation: There are two left leaves in the binary tree, with values 9 and 15 respectively.
    +
    + +

    Example 2:

    -There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24. +
    +Input: root = [1]
    +Output: 0
     
    -

    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [1, 1000].
    • +
    • -1000 <= Node.val <= 1000
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/super-ugly-number/README.md b/problems/super-ugly-number/README.md index e12b2ba83..f7e35c9d6 100644 --- a/problems/super-ugly-number/README.md +++ b/problems/super-ugly-number/README.md @@ -11,9 +11,9 @@ ## [313. Super Ugly Number (Medium)](https://leetcode.com/problems/super-ugly-number "超级丑数") -

    Given an integer n and an array of integers primes, return the nth super ugly number.

    +

    A super ugly number is a positive integer whose prime factors are in the array primes.

    -

    Super ugly number is a positive number whose all prime factors are in the array primes.

    +

    Given an integer n and an array of integers primes, return the nth super ugly number.

    The nth super ugly number is guaranteed to fit in a 32-bit signed integer.

    @@ -23,7 +23,7 @@
     Input: n = 12, primes = [2,7,13,19]
     Output: 32
    -Explanation: [1,2,4,7,8,13,14,16,19,26,28,32] is the sequence of the first 12 super ugly numbers given primes == [2,7,13,19].
    +Explanation: [1,2,4,7,8,13,14,16,19,26,28,32] is the sequence of the first 12 super ugly numbers given primes = [2,7,13,19].
     

    Example 2:

    @@ -31,7 +31,7 @@
     Input: n = 1, primes = [2,3,5]
     Output: 1
    -Explanation: 1 is a super ugly number for any given primes.
    +Explanation: 1 has no prime factors, therefore all of its prime factors are in the array primes = [2,3,5].
     

     

    diff --git a/problems/super-washing-machines/README.md b/problems/super-washing-machines/README.md index c0a6b288b..8aa55c55a 100644 --- a/problems/super-washing-machines/README.md +++ b/problems/super-washing-machines/README.md @@ -11,54 +11,51 @@ ## [517. Super Washing Machines (Hard)](https://leetcode.com/problems/super-washing-machines "超级洗衣机") -

    You have n super washing machines on a line. Initially, each washing machine has some dresses or is empty. -

    +

    You have n super washing machines on a line. Initially, each washing machine has some dresses or is empty.

    -

    For each move, you could choose any m (1 ≤ m ≤ n) washing machines, and pass one dress of each washing machine to one of its adjacent washing machines at the same time .

    +

    For each move, you could choose any m (1 <= m <= n) washing machines, and pass one dress of each washing machine to one of its adjacent washing machines at the same time.

    -

    Given an integer array representing the number of dresses in each washing machine from left to right on the line, you should find the minimum number of moves to make all the washing machines have the same number of dresses. If it is not possible to do it, return -1.

    +

    Given an integer array machines representing the number of dresses in each washing machine from left to right on the line, return the minimum number of moves to make all the washing machines have the same number of dresses. If it is not possible to do it, return -1.

    -

    Example1 -

    -Input: [1,0,5]
    -
    -Output: 3
    +

     

    +

    Example 1:

    -Explanation: -1st move: 1 0 <-- 5 => 1 1 4 -2nd move: 1 <-- 1 <-- 4 => 2 1 3 -3rd move: 2 1 <-- 3 => 2 2 2 -
    - -

    Example2

    -Input: [0,3,0]
    -
    -Output: 2
    -
    -Explanation: 
    -1st move:    0 <-- 3     0    =>    1     2     0    
    -2nd move:    1     2 --> 0    =>    1     1     1     
    +Input: machines = [1,0,5]
    +Output: 3
    +Explanation:
    +1st move:    1     0 <-- 5    =>    1     1     4
    +2nd move:    1 <-- 1 <-- 4    =>    2     1     3
    +3rd move:    2     1 <-- 3    =>    2     2     2
     
    -

    Example3 +

    Example 2:

    +
    -Input: [0,2,0]
    +Input: machines = [0,3,0]
    +Output: 2
    +Explanation:
    +1st move:    0 <-- 3     0    =>    1     2     0
    +2nd move:    1     2 --> 0    =>    1     1     1
    +
    -Output: -1 +

    Example 3:

    -Explanation: -It's impossible to make all the three washing machines have the same number of dresses. +
    +Input: machines = [0,2,0]
    +Output: -1
    +Explanation:
    +It's impossible to make all three washing machines have the same number of dresses.
     
    -

    +

     

    +

    Constraints:

    -

    Note:
    -

      -
    1. The range of n is [1, 10000].
    2. -
    3. The range of dresses number in a super washing machine is [0, 1e5].
    4. -
    -

    +
      +
    • n == machines.length
    • +
    • 1 <= n <= 104
    • +
    • 0 <= machines[i] <= 105
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/tag-validator/README.md b/problems/tag-validator/README.md index fba46fb64..ece5590a6 100644 --- a/problems/tag-validator/README.md +++ b/problems/tag-validator/README.md @@ -11,72 +11,73 @@ ## [591. Tag Validator (Hard)](https://leetcode.com/problems/tag-validator "标签验证器") -

    Given a string representing a code snippet, you need to implement a tag validator to parse the code and return whether it is valid. A code snippet is valid if all the following rules hold:

    +

    Given a string representing a code snippet, implement a tag validator to parse the code and return whether it is valid.

    + +

    A code snippet is valid if all the following rules hold:

    +
      -
    1. The code must be wrapped in a valid closed tag. Otherwise, the code is invalid.
    2. -
    3. A closed tag (not necessarily valid) has exactly the following format : <TAG_NAME>TAG_CONTENT</TAG_NAME>. Among them, <TAG_NAME> is the start tag, and </TAG_NAME> is the end tag. The TAG_NAME in start and end tags should be the same. A closed tag is valid if and only if the TAG_NAME and TAG_CONTENT are valid.
    4. -
    5. A valid TAG_NAME only contain upper-case letters, and has length in range [1,9]. Otherwise, the TAG_NAME is invalid.
    6. -
    7. A valid TAG_CONTENT may contain other valid closed tags, cdata and any characters (see note1) EXCEPT unmatched <, unmatched start and end tag, and unmatched or closed tags with invalid TAG_NAME. Otherwise, the TAG_CONTENT is invalid.
    8. -
    9. A start tag is unmatched if no end tag exists with the same TAG_NAME, and vice versa. However, you also need to consider the issue of unbalanced when tags are nested.
    10. -
    11. A < is unmatched if you cannot find a subsequent >. And when you find a < or </, all the subsequent characters until the next > should be parsed as TAG_NAME (not necessarily valid).
    12. -
    13. The cdata has the following format : <![CDATA[CDATA_CONTENT]]>. The range of CDATA_CONTENT is defined as the characters between <![CDATA[ and the first subsequent ]]>.
    14. -
    15. CDATA_CONTENT may contain any characters. The function of cdata is to forbid the validator to parse CDATA_CONTENT, so even it has some characters that can be parsed as tag (no matter valid or invalid), you should treat it as regular characters.
    16. +
    17. The code must be wrapped in a valid closed tag. Otherwise, the code is invalid.
    18. +
    19. A closed tag (not necessarily valid) has exactly the following format : <TAG_NAME>TAG_CONTENT</TAG_NAME>. Among them, <TAG_NAME> is the start tag, and </TAG_NAME> is the end tag. The TAG_NAME in start and end tags should be the same. A closed tag is valid if and only if the TAG_NAME and TAG_CONTENT are valid.
    20. +
    21. A valid TAG_NAME only contain upper-case letters, and has length in range [1,9]. Otherwise, the TAG_NAME is invalid.
    22. +
    23. A valid TAG_CONTENT may contain other valid closed tags, cdata and any characters (see note1) EXCEPT unmatched <, unmatched start and end tag, and unmatched or closed tags with invalid TAG_NAME. Otherwise, the TAG_CONTENT is invalid.
    24. +
    25. A start tag is unmatched if no end tag exists with the same TAG_NAME, and vice versa. However, you also need to consider the issue of unbalanced when tags are nested.
    26. +
    27. A < is unmatched if you cannot find a subsequent >. And when you find a < or </, all the subsequent characters until the next > should be parsed as TAG_NAME (not necessarily valid).
    28. +
    29. The cdata has the following format : <![CDATA[CDATA_CONTENT]]>. The range of CDATA_CONTENT is defined as the characters between <![CDATA[ and the first subsequent ]]>.
    30. +
    31. CDATA_CONTENT may contain any characters. The function of cdata is to forbid the validator to parse CDATA_CONTENT, so even it has some characters that can be parsed as tag (no matter valid or invalid), you should treat it as regular characters.
    -

    Valid Code Examples:
    +

     

    +

    Example 1:

    +
    -Input: "<DIV>This is the first line <![CDATA[<div>]]></DIV>"
    -Output: True
    -Explanation:
    -The code is wrapped in a closed tag : <DIV> and </DIV>.
    -The TAG_NAME is valid, the TAG_CONTENT consists of some characters and cdata.
    -Although CDATA_CONTENT has unmatched start tag with invalid TAG_NAME, it should be considered as plain text, not parsed as tag.
    -So TAG_CONTENT is valid, and then the code is valid. Thus return true.
    - -Input: "<DIV>>> ![cdata[]] <![CDATA[<div>]>]]>]]>>]</DIV>"
    -Output: True
    -Explanation:
    -We first separate the code into : start_tag|tag_content|end_tag.
    -start_tag -> "<DIV>"
    -end_tag -> "</DIV>"
    -tag_content could also be separated into : text1|cdata|text2.
    -text1 -> ">> ![cdata[]] "
    -cdata -> "<![CDATA[<div>]>]]>", where the CDATA_CONTENT is "<div>]>"
    -text2 -> "]]>>]"
    - -The reason why start_tag is NOT "<DIV>>>" is because of the rule 6. -The reason why cdata is NOT "<![CDATA[<div>]>]]>]]>" is because of the rule 7. +Input: code = "<DIV>This is the first line <![CDATA[<div>]]></DIV>" +Output: true +Explanation: +The code is wrapped in a closed tag : <DIV> and </DIV>. +The TAG_NAME is valid, the TAG_CONTENT consists of some characters and cdata. +Although CDATA_CONTENT has an unmatched start tag with invalid TAG_NAME, it should be considered as plain text, not parsed as a tag. +So TAG_CONTENT is valid, and then the code is valid. Thus return true.
    -

    -

    Invalid Code Examples:
    -

    -Input: "<A>  <B> </A>   </B>"
    -Output: False
    -Explanation: Unbalanced. If "<A>" is closed, then "<B>" must be unmatched, and vice versa.
    +

    Example 2:

    -Input: "<DIV> div tag is not closed <DIV>" -Output: False +
    +Input: code = "<DIV>>>  ![cdata[]] <![CDATA[<div>]>]]>]]>>]</DIV>"
    +Output: true
    +Explanation:
    +We first separate the code into : start_tag|tag_content|end_tag.
    +start_tag -> "<DIV>"
    +end_tag -> "</DIV>"
    +tag_content could also be separated into : text1|cdata|text2.
    +text1 -> ">>  ![cdata[]] "
    +cdata -> "<![CDATA[<div>]>]]>", where the CDATA_CONTENT is "<div>]>"
    +text2 -> "]]>>]"
    +The reason why start_tag is NOT "<DIV>>>" is because of the rule 6.
    +The reason why cdata is NOT "<![CDATA[<div>]>]]>]]>" is because of the rule 7.
    +
    -Input: "<DIV> unmatched < </DIV>" -Output: False +

    Example 3:

    -Input: "<DIV> closed tags with invalid tag name <b>123</b> </DIV>" -Output: False +
    +Input: code = "<A>  <B> </A>   </B>"
    +Output: false
    +Explanation: Unbalanced. If "<A>" is closed, then "<B>" must be unmatched, and vice versa.
    +
    -Input: "<DIV> unmatched tags with invalid tag name </1234567890> and <CDATA[[]]> </DIV>" -Output: False +

    Example 4:

    -Input: "<DIV> unmatched start tag <B> and unmatched end tag </C> </DIV>" -Output: False +
    +Input: code = "<DIV>  div tag is not closed  <DIV>"
    +Output: false
     
    -

    -

    Note:
    -

      -
    1. For simplicity, you could assume the input code (including the any characters mentioned above) only contain letters, digits, '<','>','/','!','[',']' and ' '.
    2. -
    -

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= code.length <= 500
    • +
    • code consists of English letters, digits, '<', '>', '/', '!', '[', ']', '.', and ' '.
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/target-sum/README.md b/problems/target-sum/README.md index 4f5398666..739bfbc3f 100644 --- a/problems/target-sum/README.md +++ b/problems/target-sum/README.md @@ -11,33 +11,45 @@ ## [494. Target Sum (Medium)](https://leetcode.com/problems/target-sum "目标和") -

    You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol.

    +

    You are given an integer array nums and an integer target.

    -

    Find out how many ways to assign symbols to make sum of integers equal to target S.

    +

    You want to build an expression out of nums by adding one of the symbols '+' and '-' before each integer in nums and then concatenate all the integers.

    -

    Example 1:

    +
      +
    • For example, if nums = [2, 1], you can add a '+' before 2 and a '-' before 1 and concatenate them to build the expression "+2-1".
    • +
    + +

    Return the number of different expressions that you can build, which evaluates to target.

    + +

     

    +

    Example 1:

    -Input: nums is [1, 1, 1, 1, 1], S is 3. 
    -Output: 5
    -Explanation: 
    +Input: nums = [1,1,1,1,1], target = 3
    +Output: 5
    +Explanation: There are 5 ways to assign symbols to make the sum of nums be target 3.
    +-1 + 1 + 1 + 1 + 1 = 3
    ++1 - 1 + 1 + 1 + 1 = 3
    ++1 + 1 - 1 + 1 + 1 = 3
    ++1 + 1 + 1 - 1 + 1 = 3
    ++1 + 1 + 1 + 1 - 1 = 3
    +
    --1+1+1+1+1 = 3 -+1-1+1+1+1 = 3 -+1+1-1+1+1 = 3 -+1+1+1-1+1 = 3 -+1+1+1+1-1 = 3 +

    Example 2:

    -There are 5 ways to assign symbols to make the sum of nums be target 3. +
    +Input: nums = [1], target = 1
    +Output: 1
     

     

    Constraints:

      -
    • The length of the given array is positive and will not exceed 20.
    • -
    • The sum of elements in the given array will not exceed 1000.
    • -
    • Your output answer is guaranteed to be fitted in a 32-bit integer.
    • +
    • 1 <= nums.length <= 20
    • +
    • 0 <= nums[i] <= 1000
    • +
    • 0 <= sum(nums[i]) <= 1000
    • +
    • -1000 <= target <= 1000
    ### Related Topics diff --git a/problems/teemo-attacking/README.md b/problems/teemo-attacking/README.md index fbbd70e3e..f7908fff3 100644 --- a/problems/teemo-attacking/README.md +++ b/problems/teemo-attacking/README.md @@ -11,45 +11,42 @@ ## [495. Teemo Attacking (Medium)](https://leetcode.com/problems/teemo-attacking "提莫攻击") -

    In LOL world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attacking ascending time series towards Ashe and the poisoning time duration per Teemo's attacking, you need to output the total time that Ashe is in poisoned condition.

    +

    You are given an integer array timeSeries and an integer duration. Our hero Teemo has attacked an enemy where the ith attack was done at the timeSeries[i]. When Teemo attacks their enemy, the enemy gets poisoned for duration time (i.e., the enemy is poisoned for the time interval [timeSeries[i], timeSeries[i] + duration - 1] inclusive).

    -

    You may assume that Teemo attacks at the very beginning of a specific time point, and makes Ashe be in poisoned condition immediately.

    +

    Return the total time that the enemy is in a poisoned condition.

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input: [1,4], 2
    -Output: 4
    -Explanation: At time point 1, Teemo starts attacking Ashe and makes Ashe be poisoned immediately. 
    +Input: timeSeries = [1,4], duration = 2
    +Output: 4
    +Explanation: At time point 1, Teemo starts attacking the enemy and makes them be poisoned immediately. 
     This poisoned status will last 2 seconds until the end of time point 2. 
    -And at time point 4, Teemo attacks Ashe again, and causes Ashe to be in poisoned status for another 2 seconds. 
    +And at time point 4, Teemo attacks the enemy again and causes them to be in poisoned status for another 2 seconds. 
     So you finally need to output 4.
     
    -

     

    - -

    Example 2:

    +

    Example 2:

    -Input: [1,2], 2
    -Output: 3
    -Explanation: At time point 1, Teemo starts attacking Ashe and makes Ashe be poisoned. 
    +Input: timeSeries = [1,2], duration = 2
    +Output: 3
    +Explanation: At time point 1, Teemo starts attacking the enemy and makes them be poisoned. 
     This poisoned status will last 2 seconds until the end of time point 2. 
    -However, at the beginning of time point 2, Teemo attacks Ashe again who is already in poisoned status. 
    +However, at the beginning of time point 2, Teemo attacks the enemy again who is already in poisoned status. 
     Since the poisoned status won't add up together, though the second poisoning attack will still work at time point 2, it will stop at the end of time point 3. 
     So you finally need to output 3.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. You may assume the length of given time series array won't exceed 10000.
    2. -
    3. You may assume the numbers in the Teemo's attacking time series and his poisoning time duration per attacking are non-negative integers, which won't exceed 10,000,000.
    4. -
    - -

     

    +
      +
    • 1 <= timeSeries.length <= 104
    • +
    • 0 <= timeSeries[i], duration <= 107
    • +
    • timeSeries is sorted in non-decreasing order.
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/the-number-of-employees-which-report-to-each-employee/README.md b/problems/the-number-of-employees-which-report-to-each-employee/README.md index 593e0015c..290bbfb6c 100644 --- a/problems/the-number-of-employees-which-report-to-each-employee/README.md +++ b/problems/the-number-of-employees-which-report-to-each-employee/README.md @@ -9,6 +9,6 @@                  [Next >](../find-the-highest-altitude "Find the Highest Altitude") -## [1731. The Number of Employees Which Report to Each Employee (Easy)](https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee "") +## [1731. The Number of Employees Which Report to Each Employee (Easy)](https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee "每位经理的下属员工数量") diff --git a/problems/top-k-frequent-elements/README.md b/problems/top-k-frequent-elements/README.md index d54678f47..c27e248aa 100644 --- a/problems/top-k-frequent-elements/README.md +++ b/problems/top-k-frequent-elements/README.md @@ -25,7 +25,7 @@

    Constraints:

      -
    • 1 <= nums.legth <= 105
    • +
    • 1 <= nums.length <= 105
    • k is in the range [1, the number of unique elements in the array].
    • It is guaranteed that the answer is unique.
    diff --git a/problems/total-hamming-distance/README.md b/problems/total-hamming-distance/README.md index b233c8d30..cee36ec35 100644 --- a/problems/total-hamming-distance/README.md +++ b/problems/total-hamming-distance/README.md @@ -13,27 +13,34 @@

    The Hamming distance between two integers is the number of positions at which the corresponding bits are different.

    -

    Now your job is to find the total Hamming distance between all pairs of the given numbers. +

    Given an integer array nums, return the sum of Hamming distances between all the pairs of the integers in nums.

    +

     

    +

    Example 1:

    -

    Example:

    -Input: 4, 14, 2
    +Input: nums = [4,14,2]
    +Output: 6
    +Explanation: In binary representation, the 4 is 0100, 14 is 1110, and 2 is 0010 (just
    +showing the four bits relevant in this case).
    +The answer will be:
    +HammingDistance(4, 14) + HammingDistance(4, 2) + HammingDistance(14, 2) = 2 + 2 + 2 = 6.
    +
    -Output: 6 +

    Example 2:

    -Explanation: In binary representation, the 4 is 0100, 14 is 1110, and 2 is 0010 (just -showing the four bits relevant in this case). So the answer will be: -HammingDistance(4, 14) + HammingDistance(4, 2) + HammingDistance(14, 2) = 2 + 2 + 2 = 6. +
    +Input: nums = [4,14,4]
    +Output: 4
     
    -

    - -

    Note:
    -

      -
    1. Elements of the given array are in the range of 0 to 10^9 -
    2. Length of the array will not exceed 10^4.
    3. -
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 0 <= nums[i] <= 109
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/trapping-rain-water-ii/README.md b/problems/trapping-rain-water-ii/README.md index 50abc3d39..7e2950b97 100644 --- a/problems/trapping-rain-water-ii/README.md +++ b/problems/trapping-rain-water-ii/README.md @@ -11,37 +11,34 @@ ## [407. Trapping Rain Water II (Hard)](https://leetcode.com/problems/trapping-rain-water-ii "接雨水 II") -

    Given an m x n matrix of positive integers representing the height of each unit cell in a 2D elevation map, compute the volume of water it is able to trap after raining.

    - -

    Example:

    +

    Given an m x n integer matrix heightMap representing the height of each unit cell in a 2D elevation map, return the volume of water it can trap after raining.

    +

     

    +

    Example 1:

    +
    -Given the following 3x6 height map:
    -[
    -  [1,4,3,1,3,2],
    -  [3,2,1,3,2,4],
    -  [2,3,3,2,3,1]
    -]
    -
    -Return 4.
    +Input: heightMap = [[1,4,3,1,3,2],[3,2,1,3,2,4],[2,3,3,2,3,1]]
    +Output: 4
    +Explanation: After the rain, water is trapped between the blocks.
    +We have two small pounds 1 and 3 units trapped.
    +The total volume of water trapped is 4.
     
    -

    - -

    The above image represents the elevation map [[1,4,3,1,3,2],[3,2,1,3,2,4],[2,3,3,2,3,1]] before the rain.

    - -

     

    - -

    - -

    After the rain, water is trapped between the blocks. The total volume of water trapped is 4.

    +

    Example 2:

    + +
    +Input: heightMap = [[3,3,3,3,3],[3,2,2,2,3],[3,2,1,2,3],[3,2,2,2,3],[3,3,3,3,3]]
    +Output: 10
    +

     

    Constraints:

      -
    • 1 <= m, n <= 110
    • -
    • 0 <= heightMap[i][j] <= 20000
    • +
    • m == heightMap.length
    • +
    • n == heightMap[i].length
    • +
    • 1 <= m, n <= 200
    • +
    • 0 <= heightMap[i][j] <= 2 * 104
    ### Related Topics diff --git a/problems/ugly-number-ii/README.md b/problems/ugly-number-ii/README.md index 3ae2905dd..edc46d6a0 100644 --- a/problems/ugly-number-ii/README.md +++ b/problems/ugly-number-ii/README.md @@ -11,9 +11,9 @@ ## [264. Ugly Number II (Medium)](https://leetcode.com/problems/ugly-number-ii "丑数 II") -

    Given an integer n, return the nth ugly number.

    +

    An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5.

    -

    Ugly number is a positive number whose prime factors only include 2, 3, and/or 5.

    +

    Given an integer n, return the nth ugly number.

     

    Example 1:

    @@ -29,7 +29,7 @@
     Input: n = 1
     Output: 1
    -Explanation: 1 is typically treated as an ugly number.
    +Explanation: 1 has no prime factors, therefore all of its prime factors are limited to 2, 3, and 5.
     

     

    diff --git a/problems/ugly-number-iii/README.md b/problems/ugly-number-iii/README.md index 72cbe62de..2b5350514 100644 --- a/problems/ugly-number-iii/README.md +++ b/problems/ugly-number-iii/README.md @@ -11,9 +11,9 @@ ## [1201. Ugly Number III (Medium)](https://leetcode.com/problems/ugly-number-iii "丑数 III") -

    Given four integers n, a, b, and c, return the nth ugly number.

    +

    An ugly number is a positive integer that is divisible by a, b, or c.

    -

    Ugly numbers are positive integers that are divisible by a, b, or c.

    +

    Given four integers n, a, b, and c, return the nth ugly number.

     

    Example 1:

    diff --git a/problems/ugly-number/README.md b/problems/ugly-number/README.md index 42513d22b..1a30c5d48 100644 --- a/problems/ugly-number/README.md +++ b/problems/ugly-number/README.md @@ -11,9 +11,9 @@ ## [263. Ugly Number (Easy)](https://leetcode.com/problems/ugly-number "丑数") -

    Given an integer n, return true if n is an ugly number.

    +

    An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5.

    -

    Ugly number is a positive number whose prime factors only include 2, 3, and/or 5.

    +

    Given an integer n, return true if n is an ugly number.

     

    Example 1:

    @@ -36,7 +36,7 @@
     Input: n = 14
     Output: false
    -Explanation: 14 is not ugly since it includes another prime factor 7.
    +Explanation: 14 is not ugly since it includes the prime factor 7.
     

    Example 4:

    @@ -44,7 +44,7 @@
     Input: n = 1
     Output: true
    -Explanation: 1 is typically treated as an ugly number.
    +Explanation: 1 has no prime factors, therefore all of its prime factors are limited to 2, 3, and 5.
     

     

    diff --git a/problems/unique-substrings-in-wraparound-string/README.md b/problems/unique-substrings-in-wraparound-string/README.md index 2436acd6e..af0cabc08 100644 --- a/problems/unique-substrings-in-wraparound-string/README.md +++ b/problems/unique-substrings-in-wraparound-string/README.md @@ -11,36 +11,46 @@ ## [467. Unique Substrings in Wraparound String (Medium)](https://leetcode.com/problems/unique-substrings-in-wraparound-string "环绕字符串中唯一的子字符串") -

    Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so s will look like this: "...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....".

    +

    We define the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so s will look like this:

    -

    Now we have another string p. Your job is to find out how many unique non-empty substrings of p are present in s. In particular, your input is the string p and you need to output the number of different non-empty substrings of p in the string s.

    +
      +
    • "...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....".
    • +
    -

    Note: p consists of only lowercase English letters and the size of p might be over 10000.

    +

    Given a string p, return the number of unique non-empty substrings of p are present in s.

    -

    Example 1:
    -

    -Input: "a"
    -Output: 1
    +

     

    +

    Example 1:

    -Explanation: Only the substring "a" of string "a" is in the string s. +
    +Input: p = "a"
    +Output: 1
    +Explanation: Only the substring "a" of p is in s.
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: "cac"
    -Output: 2
    -Explanation: There are two substrings "a", "c" of string "cac" in the string s.
    +Input: p = "cac"
    +Output: 2
    +Explanation: There are two substrings ("a", "c") of p in s.
     
    -

    -

    Example 3:
    +

    Example 3:

    +
    -Input: "zab"
    -Output: 6
    -Explanation: There are six substrings "z", "a", "b", "za", "ab", "zab" of string "zab" in the string s.
    +Input: p = "zab"
    +Output: 6
    +Explanation: There are six substrings ("z", "a", "b", "za", "ab", and "zab") of p in s.
     
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= p.length <= 105
    • +
    • p consists of lowercase English letters.
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/valid-square/README.md b/problems/valid-square/README.md index 175432ba5..0eb2d3b7b 100644 --- a/problems/valid-square/README.md +++ b/problems/valid-square/README.md @@ -11,7 +11,7 @@ ## [593. Valid Square (Medium)](https://leetcode.com/problems/valid-square "有效的正方形") -

    Given the coordinates of four points in 2D space p1, p2, p3 and p4, return true if the four points construct a square.

    +

    Given the coordinates of four points in 2D space p1, p2, p3 and p4, return true if the four points construct a square.

    The coordinate of a point pi is represented as [xi, yi]. The input is not given in any order.

    diff --git a/problems/validate-ip-address/README.md b/problems/validate-ip-address/README.md index 7fe511ecf..484430283 100644 --- a/problems/validate-ip-address/README.md +++ b/problems/validate-ip-address/README.md @@ -11,19 +11,19 @@ ## [468. Validate IP Address (Medium)](https://leetcode.com/problems/validate-ip-address "验证IP地址") -

    Given a string IP, return "IPv4" if IP is a valid IPv4 address, "IPv6" if IP is a valid IPv6 address or "Neither" if IP is not a correct IP of any type.

    +

    Given a string IP, return "IPv4" if IP is a valid IPv4 address, "IPv6" if IP is a valid IPv6 address or "Neither" if IP is not a correct IP of any type.

    -

    A valid IPv4 address is an IP in the form "x1.x2.x3.x4" where 0 <= xi <= 255 and xi cannot contain leading zeros. For example, "192.168.1.1" and "192.168.1.0" are valid IPv4 addresses but "192.168.01.1", while "192.168.1.00" and "192.168@1.1" are invalid IPv4 addresses.

    +

    A valid IPv4 address is an IP in the form "x1.x2.x3.x4" where 0 <= xi <= 255 and xi cannot contain leading zeros. For example, "192.168.1.1" and "192.168.1.0" are valid IPv4 addresses but "192.168.01.1", while "192.168.1.00" and "192.168@1.1" are invalid IPv4 addresses.

    -

    A valid IPv6 address is an IP in the form "x1:x2:x3:x4:x5:x6:x7:x8" where:

    +

    A valid IPv6 address is an IP in the form "x1:x2:x3:x4:x5:x6:x7:x8" where:

    • 1 <= xi.length <= 4
    • -
    • xi is a hexadecimal string which may contain digits, lower-case English letter ('a' to 'f') and upper-case English letters ('A' to 'F').
    • +
    • xi is a hexadecimal string which may contain digits, lower-case English letter ('a' to 'f') and upper-case English letters ('A' to 'F').
    • Leading zeros are allowed in xi.
    -

    For example, "2001:0db8:85a3:0000:0000:8a2e:0370:7334" and "2001:db8:85a3:0:0:8A2E:0370:7334" are valid IPv6 addresses, while "2001:0db8:85a3::8A2E:037j:7334" and "02001:0db8:85a3:0000:0000:8a2e:0370:7334" are invalid IPv6 addresses.

    +

    For example, "2001:0db8:85a3:0000:0000:8a2e:0370:7334" and "2001:db8:85a3:0:0:8A2E:0370:7334" are valid IPv6 addresses, while "2001:0db8:85a3::8A2E:037j:7334" and "02001:0db8:85a3:0000:0000:8a2e:0370:7334" are invalid IPv6 addresses.

     

    Example 1:

    diff --git a/problems/word-ladder-ii/README.md b/problems/word-ladder-ii/README.md index cfa5eac50..a0813c7a3 100644 --- a/problems/word-ladder-ii/README.md +++ b/problems/word-ladder-ii/README.md @@ -44,9 +44,9 @@

    Constraints:

      -
    • 1 <= beginWord.length <= 10
    • +
    • 1 <= beginWord.length <= 5
    • endWord.length == beginWord.length
    • -
    • 1 <= wordList.length <= 5000
    • +
    • 1 <= wordList.length <= 1000
    • wordList[i].length == beginWord.length
    • beginWord, endWord, and wordList[i] consist of lowercase English letters.
    • beginWord != endWord
    • diff --git a/readme/601-900.md b/readme/601-900.md index 451be2ac1..381873bdd 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -374,7 +374,7 @@ LeetCode Problems' Solutions | 894 | [All Possible Full Binary Trees](https://leetcode.com/problems/all-possible-full-binary-trees "所有可能的满二叉树") | [Go](../problems/all-possible-full-binary-trees) | Medium | | 895 | [Maximum Frequency Stack](https://leetcode.com/problems/maximum-frequency-stack "最大频率栈") | [Go](../problems/maximum-frequency-stack) | Hard | | 896 | [Monotonic Array](https://leetcode.com/problems/monotonic-array "单调数列") | [Go](../problems/monotonic-array) | Easy | -| 897 | [Increasing Order Search Tree](https://leetcode.com/problems/increasing-order-search-tree "递增顺序查找树") | [Go](../problems/increasing-order-search-tree) | Easy | +| 897 | [Increasing Order Search Tree](https://leetcode.com/problems/increasing-order-search-tree "递增顺序搜索树") | [Go](../problems/increasing-order-search-tree) | Easy | | 898 | [Bitwise ORs of Subarrays](https://leetcode.com/problems/bitwise-ors-of-subarrays "子数组按位或操作") | [Go](../problems/bitwise-ors-of-subarrays) | Medium | | 899 | [Orderly Queue](https://leetcode.com/problems/orderly-queue "有序队列") | [Go](../problems/orderly-queue) | Hard | | 900 | [RLE Iterator](https://leetcode.com/problems/rle-iterator "RLE 迭代器") | [Go](../problems/rle-iterator) | Medium | diff --git a/tag/README.md b/tag/README.md index 154ccffc3..e858b6a0b 100644 --- a/tag/README.md +++ b/tag/README.md @@ -16,8 +16,8 @@ | 9 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | | 11 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | -| 15 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 16 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | -| 17 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 18 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | +| 15 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | +| 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 19 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | | 20 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | | 21 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | | 22 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | | 23 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | diff --git a/tag/array/README.md b/tag/array/README.md index 598d964a1..33c19bbae 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1833 | [雪糕的最大数量](../../problems/maximum-ice-cream-bars) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1827 | [最少操作使数组递增](../../problems/minimum-operations-to-make-the-array-increasing) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 1826 | [Faulty Sensor](../../problems/faulty-sensor) 🔒 | [[数组](../array/README.md)] | Easy | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[数组](../array/README.md)] | Medium | | 1814 | [统计一个数组中好对子的数目](../../problems/count-nice-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1806 | [还原排列的最少操作步数](../../problems/minimum-number-of-operations-to-reinitialize-a-permutation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1779 | [找到最近的有相同 X 或 Y 坐标的点](../../problems/find-nearest-point-that-has-the-same-x-or-y-coordinate) | [[数组](../array/README.md)] | Easy | @@ -233,11 +237,11 @@ | 581 | [最短无序连续子数组](../../problems/shortest-unsorted-continuous-subarray) | [[数组](../array/README.md)] | Medium | | 566 | [重塑矩阵](../../problems/reshape-the-matrix) | [[数组](../array/README.md)] | Easy | | 565 | [数组嵌套](../../problems/array-nesting) | [[数组](../array/README.md)] | Medium | -| 562 | [矩阵中最长的连续1线段](../../problems/longest-line-of-consecutive-one-in-matrix) 🔒 | [[数组](../array/README.md)] | Medium | +| 562 | [矩阵中最长的连续1线段](../../problems/longest-line-of-consecutive-one-in-matrix) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 561 | [数组拆分 I](../../problems/array-partition-i) | [[数组](../array/README.md)] | Easy | | 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 548 | [将数组分割成和相等的子数组](../../problems/split-array-with-equal-sum) 🔒 | [[数组](../array/README.md)] | Medium | -| 533 | [孤独像素 II](../../problems/lonely-pixel-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 533 | [孤独像素 II](../../problems/lonely-pixel-ii) 🔒 | [[数组](../array/README.md)] | Medium | | 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 531 | [孤独像素 I](../../problems/lonely-pixel-i) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 509 | [斐波那契数](../../problems/fibonacci-number) | [[数组](../array/README.md)] | Easy | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 981cc07af..bd40a61e6 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1840 | [最高建筑高度](../../problems/maximum-building-height) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1802 | [有界数组中指定下标处的最大值](../../problems/maximum-value-at-a-given-index-in-a-bounded-array) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1760 | [袋子里最少数目的球](../../problems/minimum-limit-of-balls-in-a-bag) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 51e2e5675..ec9ec8f71 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1837 | [K 进制表示下的各位数字总和](../../problems/sum-of-digits-in-base-k) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | +| 1829 | [每个查询的最大异或值](../../problems/maximum-xor-for-each-query) | [[位运算](../bit-manipulation/README.md)] | Medium | | 1734 | [解码异或后的排列](../../problems/decode-xored-permutation) | [[位运算](../bit-manipulation/README.md)] | Medium | | 1720 | [解码异或后的数组](../../problems/decode-xored-array) | [[位运算](../bit-manipulation/README.md)] | Easy | | 1707 | [与数组中元素的最大异或值](../../problems/maximum-xor-with-an-element-from-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Hard | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index e1ebf1d82..b6c2ed5bd 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1824 | [最少侧跳次数](../../problems/minimum-sideway-jumps) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | | 1765 | [地图中的最高点](../../problems/map-of-highest-peak) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | @@ -73,7 +74,7 @@ | 429 | [N 叉树的层序遍历](../../problems/n-ary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 417 | [太平洋大西洋水流问题](../../problems/pacific-atlantic-water-flow) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 339 | [嵌套列表权重和](../../problems/nested-list-weight-sum) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 339 | [嵌套列表权重和](../../problems/nested-list-weight-sum) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 317 | [离建筑物最近的距离](../../problems/shortest-distance-from-all-buildings) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index ab6bf917e..e404b2816 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -71,7 +71,7 @@ | 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 924 | [尽量减少恶意软件的传播](../../problems/minimize-malware-spread) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | -| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 897 | [递增顺序搜索树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | @@ -108,7 +108,6 @@ | 546 | [移除盒子](../../problems/remove-boxes) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 542 | [01 矩阵](../../problems/01-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 533 | [孤独像素 II](../../problems/lonely-pixel-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 531 | [孤独像素 I](../../problems/lonely-pixel-i) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 529 | [扫雷游戏](../../problems/minesweeper) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 526 | [优美的排列](../../problems/beautiful-arrangement) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | @@ -130,7 +129,7 @@ | 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 366 | [寻找二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 364 | [加权嵌套序列和 II](../../problems/nested-list-weight-sum-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 339 | [嵌套列表权重和](../../problems/nested-list-weight-sum) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 339 | [嵌套列表权重和](../../problems/nested-list-weight-sum) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | diff --git a/tag/design/README.md b/tag/design/README.md index 7af1d3fff..815f9c359 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] | Hard | | 1797 | [设计一个验证系统](../../problems/design-authentication-manager) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 0956b9622..422cc9e7d 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1824 | [最少侧跳次数](../../problems/minimum-sideway-jumps) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1815 | [得到新鲜甜甜圈的最多组数](../../problems/maximum-number-of-groups-getting-fresh-donuts) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1787 | [使所有区间的异或结果为零](../../problems/make-the-xor-of-all-segments-equal-to-zero) | [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -16,7 +17,7 @@ | 1771 | [由子序列构造的最长回文串的长度](../../problems/maximize-palindrome-length-from-subsequences) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1770 | [执行乘法运算的最大分数](../../problems/maximum-score-from-performing-multiplication-operations) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1751 | [最多可以参加的会议数目 II](../../problems/maximum-number-of-events-that-can-be-attended-ii) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1746 | [Maximum Subarray Sum After One Operation](../../problems/maximum-subarray-sum-after-one-operation) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1746 | [经过一次操作后的最大子数组和](../../problems/maximum-subarray-sum-after-one-operation) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1745 | [回文串分割 IV](../../problems/palindrome-partitioning-iv) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1728 | [猫和老鼠 II](../../problems/cat-and-mouse-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1724 | [检查边长度限制的路径是否存在 II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -186,6 +187,7 @@ | 600 | [不含连续1的非负整数](../../problems/non-negative-integers-without-consecutive-ones) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 576 | [出界的路径数](../../problems/out-of-boundary-paths) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 568 | [最大休假天数](../../problems/maximum-vacation-days) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 562 | [矩阵中最长的连续1线段](../../problems/longest-line-of-consecutive-one-in-matrix) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 552 | [学生出勤记录 II](../../problems/student-attendance-record-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 546 | [移除盒子](../../problems/remove-boxes) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 523 | [连续的子数组和](../../problems/continuous-subarray-sum) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/graph/README.md b/tag/graph/README.md index 089e192cd..51e44a4a4 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1820 | [Maximum Number of Accepted Invitations](../../problems/maximum-number-of-accepted-invitations) 🔒 | [[图](../graph/README.md)] | Medium | | 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1791 | [找出星型图的中心节点](../../problems/find-center-of-star-graph) | [[图](../graph/README.md)] | Medium | | 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 23e2e9822..8900f7b80 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1840 | [最高建筑高度](../../problems/maximum-building-height) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1838 | [最高频元素的频数](../../problems/frequency-of-the-most-frequent-element) | [[贪心算法](../greedy/README.md)] | Medium | +| 1827 | [最少操作使数组递增](../../problems/minimum-operations-to-make-the-array-increasing) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1806 | [还原排列的最少操作步数](../../problems/minimum-number-of-operations-to-reinitialize-a-permutation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1802 | [有界数组中指定下标处的最大值](../../problems/maximum-value-at-a-given-index-in-a-bounded-array) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/heap/README.md b/tag/heap/README.md index 03cd2ce78..8a8b2c284 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1834 | [单线程 CPU](../../problems/single-threaded-cpu) | [[堆](../heap/README.md)] | Medium | +| 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] | Hard | | 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | | 1792 | [最大平均通过率](../../problems/maximum-average-pass-ratio) | [[堆](../heap/README.md)] | Medium | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index 8103f6eff..408e55d1d 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1836 | [Remove Duplicates From an Unsorted Linked List](../../problems/remove-duplicates-from-an-unsorted-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Medium | | 1721 | [交换链表中的节点](../../problems/swapping-nodes-in-a-linked-list) | [[链表](../linked-list/README.md)] | Medium | | 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | | 1669 | [合并两个链表](../../problems/merge-in-between-linked-lists) | [[链表](../linked-list/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index e0413d1ad..a495a3463 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1837 | [K 进制表示下的各位数字总和](../../problems/sum-of-digits-in-base-k) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | +| 1835 | [所有数对按位与结果的异或和](../../problems/find-xor-sum-of-all-pairs-bitwise-and) | [[数学](../math/README.md)] | Hard | +| 1830 | [使字符串有序的最少操作次数](../../problems/minimum-number-of-operations-to-make-string-sorted) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 1828 | [统计一个圆中点的数目](../../problems/queries-on-number-of-points-inside-a-circle) | [[数学](../math/README.md)] | Medium | +| 1822 | [数组元素积的符号](../../problems/sign-of-the-product-of-an-array) | [[数学](../math/README.md)] | Easy | | 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数学](../math/README.md)] | Hard | | 1808 | [好因子的最大数目](../../problems/maximize-number-of-nice-divisors) | [[数学](../math/README.md)] | Hard | | 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index 0c9155aea..b8e465631 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] | Hard | | 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | | 933 | [最近的请求次数](../../problems/number-of-recent-calls) | [[队列](../queue/README.md)] | Easy | | 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 1989c8da1..b846c366c 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -19,7 +19,7 @@ | 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 897 | [递增顺序搜索树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | | 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index a49d290d1..64c2693ca 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1833 | [雪糕的最大数量](../../problems/maximum-ice-cream-bars) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1772 | [按受欢迎程度排列功能](../../problems/sort-features-by-popularity) 🔒 | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1727 | [重新排列后的最大子矩阵](../../problems/largest-submatrix-with-rearrangements) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | | 1710 | [卡车上的最大单元数](../../problems/maximum-units-on-a-truck) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | diff --git a/tag/string/README.md b/tag/string/README.md index 4be21cb8c..e6da153c9 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,12 +9,15 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1839 | [所有元音按顺序排布的最长子字符串](../../problems/longest-substring-of-all-vowels-in-order) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1832 | [判断句子是否为全字母句](../../problems/check-if-the-sentence-is-pangram) | [[字符串](../string/README.md)] | Easy | +| 1830 | [使字符串有序的最少操作次数](../../problems/minimum-number-of-operations-to-make-string-sorted) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | | 1816 | [截断句子](../../problems/truncate-sentence) | [[字符串](../string/README.md)] | Easy | | 1813 | [句子相似性 III](../../problems/sentence-similarity-iii) | [[字符串](../string/README.md)] | Medium | | 1812 | [判断国际象棋棋盘中一个格子的颜色](../../problems/determine-color-of-a-chessboard-square) | [[字符串](../string/README.md)] | Easy | | 1807 | [替换字符串中的括号内容](../../problems/evaluate-the-bracket-pairs-of-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1805 | [字符串中不同整数的数目](../../problems/number-of-different-integers-in-a-string) | [[字符串](../string/README.md)] | Easy | -| 1804 | [Implement Trie II (Prefix Tree)](../../problems/implement-trie-ii-prefix-tree) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | +| 1804 | [实现 Trie (前缀树) II](../../problems/implement-trie-ii-prefix-tree) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | | 1796 | [字符串中第二大的数字](../../problems/second-largest-digit-in-a-string) | [[字符串](../string/README.md)] | Easy | | 1794 | [Count Pairs of Equal Substrings With Minimum Difference](../../problems/count-pairs-of-equal-substrings-with-minimum-difference) 🔒 | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1790 | [仅执行一次字符串交换能否使两个字符串相等](../../problems/check-if-one-string-swap-can-make-strings-equal) | [[字符串](../string/README.md)] | Easy | diff --git a/tag/tags.json b/tag/tags.json index 10fc56aa0..c35051296 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -74,16 +74,16 @@ "Slug": "design", "TranslatedName": "设计" }, - { - "Name": "Graph", - "Slug": "graph", - "TranslatedName": "图" - }, { "Name": "Bit Manipulation", "Slug": "bit-manipulation", "TranslatedName": "位运算" }, + { + "Name": "Graph", + "Slug": "graph", + "TranslatedName": "图" + }, { "Name": "Heap", "Slug": "heap", diff --git a/tag/tree/README.md b/tag/tree/README.md index 9193d4c43..a7857ae07 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -69,7 +69,7 @@ | 951 | [翻转等价二叉树](../../problems/flip-equivalent-binary-trees) | [[树](../tree/README.md)] | Medium | | 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 919 | [完全二叉树插入器](../../problems/complete-binary-tree-inserter) | [[树](../tree/README.md)] | Medium | -| 897 | [递增顺序查找树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 897 | [递增顺序搜索树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | | 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | | 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] | Medium | | 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | diff --git a/tag/trie/README.md b/tag/trie/README.md index 1421c18eb..4b38e751a 100644 --- a/tag/trie/README.md +++ b/tag/trie/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1804 | [Implement Trie II (Prefix Tree)](../../problems/implement-trie-ii-prefix-tree) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | +| 1804 | [实现 Trie (前缀树) II](../../problems/implement-trie-ii-prefix-tree) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | | 1803 | [统计异或值在范围内的数对有多少](../../problems/count-pairs-with-xor-in-a-range) | [[字典树](../trie/README.md)] | Hard | | 1707 | [与数组中元素的最大异或值](../../problems/maximum-xor-with-an-element-from-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Hard | | 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 80e3c1097..f8bd3404f 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1839 | [所有元音按顺序排布的最长子字符串](../../problems/longest-substring-of-all-vowels-in-order) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1800 | [最大升序子数组和](../../problems/maximum-ascending-subarray-sum) | [[双指针](../two-pointers/README.md)] | Easy | | 1750 | [删除字符串两端相同字符后的最短长度](../../problems/minimum-length-of-string-after-deleting-similar-ends) | [[双指针](../two-pointers/README.md)] | Medium | | 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | From 8fcaa42885e392757bd66e6c99c4129f18854b0b Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 13 May 2021 17:06:38 +0800 Subject: [PATCH 130/145] A: new --- README.md | 19 +++- problems/2-keys-keyboard/README.md | 44 ++++----- problems/24-game/README.md | 62 ++++++++----- problems/4sum-ii/README.md | 2 +- problems/add-strings/README.md | 5 +- problems/advantage-shuffle/README.md | 14 +-- .../README.md | 8 +- problems/ambiguous-coordinates/README.md | 14 +-- problems/array-nesting/README.md | 46 ++++++---- problems/bag-of-tokens/README.md | 10 +- problems/basic-calculator-ii/README.md | 2 + problems/basic-calculator/README.md | 2 + problems/beautiful-array/README.md | 12 +-- .../binary-search-tree-iterator/README.md | 2 +- problems/binary-subarrays-with-sum/README.md | 10 +- .../binary-tree-inorder-traversal/README.md | 11 +-- .../binary-tree-postorder-traversal/README.md | 11 +-- .../binary-tree-preorder-traversal/README.md | 2 +- problems/broken-calculator/README.md | 16 ++-- problems/bulb-switcher-ii/README.md | 53 +++++------ problems/bulb-switcher-iv/README.md | 18 ++-- .../README.md | 6 +- .../README.md | 2 +- .../cheapest-flights-within-k-stops/README.md | 47 +++++----- problems/clone-graph/README.md | 14 +-- .../README.md | 2 +- problems/closest-room/README.md | 74 +++++++++++++++ problems/coin-change-2/README.md | 2 +- problems/concatenated-words/README.md | 2 +- problems/consecutive-numbers-sum/README.md | 10 +- .../README.md | 45 +++++---- .../README.md | 16 ++-- .../convert-a-number-to-hexadecimal/README.md | 5 +- .../README.md | 2 +- problems/convert-date-format/README.md | 14 +++ .../convert-date-format/mysql_schemas.sql | 5 + .../README.md | 2 +- problems/count-binary-substrings/README.md | 40 ++++---- problems/count-complete-tree-nodes/README.md | 5 +- .../README.md | 44 ++++----- problems/count-of-range-sum/README.md | 6 +- .../README.md | 2 +- problems/course-schedule-ii/README.md | 16 ++-- problems/course-schedule-iii/README.md | 48 ++++++---- problems/course-schedule-iv/README.md | 53 ++++------- .../README.md | 11 ++- problems/custom-sort-string/README.md | 22 ++--- problems/daily-temperatures/README.md | 15 +-- problems/decoded-string-at-index/README.md | 22 ++--- problems/delete-and-earn/README.md | 2 +- problems/design-circular-queue/README.md | 5 +- .../README.md | 35 +++++++ problems/distinct-subsequences-ii/README.md | 14 +-- problems/domino-and-tromino-tiling/README.md | 7 +- problems/dota2-senate/README.md | 63 ++++++------- problems/encode-and-decode-tinyurl/README.md | 33 ++++++- problems/exam-room/README.md | 10 +- problems/expressive-words/README.md | 10 +- problems/fair-candy-swap/README.md | 18 ++-- problems/falling-squares/README.md | 58 ++++++------ .../find-all-duplicates-in-an-array/README.md | 5 +- problems/find-and-replace-in-string/README.md | 26 +++--- .../README.md | 2 +- .../README.md | 2 + problems/find-peak-element/README.md | 5 +- problems/find-the-duplicate-number/README.md | 2 +- problems/find-the-town-judge/README.md | 45 ++++++--- problems/first-missing-positive/README.md | 7 +- .../README.md | 14 +-- .../README.md | 58 ++++++------ .../furthest-building-you-can-reach/README.md | 2 +- .../global-and-local-inversions/README.md | 2 +- problems/goat-latin/README.md | 12 +-- .../README.md | 26 +++--- problems/h-index-ii/README.md | 5 +- problems/hand-of-straights/README.md | 10 +- problems/image-smoother/README.md | 53 ++++++----- problems/inorder-successor-in-bst/README.md | 2 +- problems/k-inverse-pairs-array/README.md | 39 ++++---- problems/k-th-symbol-in-grammar/README.md | 14 +-- .../kth-smallest-element-in-a-bst/README.md | 2 +- .../README.md | 53 ++++------- .../README.md | 68 ++++++++++++++ .../README.md | 16 ++-- .../README.md | 15 ++- problems/largest-plus-sign/README.md | 56 ++++++----- problems/largest-sum-of-averages/README.md | 20 ++-- .../largest-time-for-given-digits/README.md | 8 +- problems/league-statistics/README.md | 14 +++ problems/league-statistics/mysql_schemas.sql | 11 +++ problems/letter-case-permutation/README.md | 14 +-- problems/linked-list-components/README.md | 16 ++-- .../README.md | 2 +- problems/longest-happy-prefix/README.md | 8 +- .../masking-personal-information/README.md | 12 +-- problems/max-area-of-island/README.md | 38 ++++---- problems/maximum-average-subarray-i/README.md | 32 ++++--- problems/maximum-building-height/README.md | 2 +- .../README.md | 82 +++++++++++++++++ .../README.md | 84 +++++++++++++++++ problems/maximum-ice-cream-bars/README.md | 10 -- problems/maximum-population-year/README.md | 58 ++++++++++++ .../maximum-subarray-min-product/README.md | 78 ++++++++++++++++ .../maximum-sum-circular-subarray/README.md | 20 ++-- problems/maximum-swap/README.md | 37 ++++---- .../maximum-width-of-binary-tree/README.md | 79 ++++++---------- problems/maximum-width-ramp/README.md | 16 ++-- .../median-of-two-sorted-arrays/README.md | 5 +- problems/merge-sorted-array/README.md | 3 + problems/minesweeper/README.md | 92 ++++++++----------- .../README.md | 14 +-- .../README.md | 87 ++++++++++++++++++ .../minimum-cost-to-hire-k-workers/README.md | 12 +-- .../README.md | 2 +- .../README.md | 67 ++++++++++++++ .../README.md | 12 +-- .../README.md | 68 ++++++++++++++ .../README.md | 2 +- .../README.md | 17 ++-- .../README.md | 22 ++--- .../README.md | 18 ++-- problems/minimum-window-substring/README.md | 8 +- problems/monotone-increasing-digits/README.md | 30 +++--- problems/monotonic-array/README.md | 18 ++-- .../n-ary-tree-postorder-traversal/README.md | 2 +- .../README.md | 16 ++-- problems/new-21-game/README.md | 43 +++++---- .../README.md | 28 ++++++ problems/number-of-distinct-islands/README.md | 1 + problems/number-of-music-playlists/README.md | 14 +-- problems/number-of-squareful-arrays/README.md | 12 +-- .../README.md | 16 ++-- problems/optimal-division/README.md | 57 ++++++++---- problems/orderly-queue/README.md | 12 +-- problems/out-of-boundary-paths/README.md | 41 ++++----- problems/palindromic-substrings/README.md | 37 ++++---- .../partition-array-for-maximum-sum/README.md | 4 +- .../README.md | 12 +-- problems/partition-labels/README.md | 10 +- problems/path-crossing/README.md | 16 ++-- .../README.md | 8 +- problems/possible-bipartition/README.md | 12 +-- problems/prefix-and-suffix-search/README.md | 6 +- .../README.md | 12 +-- .../README.md | 60 ++++++------ problems/prime-palindrome/README.md | 12 +-- problems/print-binary-tree/README.md | 84 +++++++---------- .../product-of-array-except-self/README.md | 9 +- problems/race-car/README.md | 45 +++++---- problems/random-pick-with-blacklist/README.md | 10 +- problems/range-sum-of-bst/README.md | 4 +- .../range-sum-query-2d-immutable/README.md | 16 ++-- problems/range-sum-query-immutable/README.md | 16 ++-- problems/range-sum-query-mutable/README.md | 19 ++-- problems/ransom-note/README.md | 7 +- problems/rectangle-area/README.md | 12 +-- problems/redundant-connection-ii/README.md | 1 + problems/redundant-connection/README.md | 64 ++++++------- .../README.md | 33 ++++--- problems/reorganize-string/README.md | 8 +- .../README.md | 69 ++++++++++++++ problems/reverse-nodes-in-k-group/README.md | 10 +- problems/reverse-only-letters/README.md | 14 +-- problems/reverse-pairs/README.md | 2 +- problems/rle-iterator/README.md | 12 +-- problems/robot-bounded-in-circle/README.md | 2 +- problems/rotate-string/README.md | 10 +- problems/rotated-digits/README.md | 6 +- .../score-after-flipping-matrix/README.md | 10 +- problems/score-of-parentheses/README.md | 30 +++--- .../search-in-rotated-sorted-array/README.md | 5 +- problems/search-insert-position/README.md | 2 + problems/seat-reservation-manager/README.md | 75 +++++++++++++++ problems/shifting-letters/README.md | 10 +- problems/shortest-bridge/README.md | 27 ++++-- .../README.md | 44 +++++---- .../README.md | 16 ++-- problems/single-number-ii/README.md | 5 +- problems/single-number-iii/README.md | 2 +- problems/single-number/README.md | 2 +- problems/smallest-range-i/README.md | 24 ++--- problems/smallest-range-ii/README.md | 24 ++--- .../README.md | 28 +++--- problems/solve-the-equation/README.md | 75 ++++++--------- problems/sort-array-by-parity/README.md | 8 +- problems/sort-colors/README.md | 9 +- problems/soup-servings/README.md | 20 ++-- problems/special-binary-string/README.md | 42 +++++---- problems/spiral-matrix-iii/README.md | 16 ++-- .../README.md | 18 ++-- .../README.md | 84 +++++++++++++++++ problems/strange-printer/README.md | 44 ++++----- problems/string-compression/README.md | 6 +- .../subarray-sums-divisible-by-k/README.md | 12 +-- .../README.md | 14 +-- problems/subtree-of-another-tree/README.md | 53 ++++------- problems/sum-of-distances-in-tree/README.md | 6 +- .../README.md | 22 ++--- .../README.md | 6 +- problems/sum-of-subsequence-widths/README.md | 14 +-- problems/sum-root-to-leaf-numbers/README.md | 2 +- problems/super-palindromes/README.md | 2 +- problems/suspicious-bank-accounts/README.md | 14 +++ .../mysql_schemas.sql | 16 ++++ problems/swap-nodes-in-pairs/README.md | 5 +- .../README.md | 16 ++-- .../README.md | 12 +-- problems/valid-palindrome-ii/README.md | 45 +++++---- .../README.md | 16 ++-- problems/valid-triangle-number/README.md | 36 +++++--- .../validate-binary-search-tree/README.md | 2 +- problems/wiggle-subsequence/README.md | 2 +- problems/word-subsets/README.md | 24 ++--- readme/1-300.md | 6 +- readme/601-900.md | 2 +- tag/README.md | 12 +-- tag/array/README.md | 3 + tag/backtracking/README.md | 1 + tag/binary-search/README.md | 3 + tag/breadth-first-search/README.md | 1 + tag/depth-first-search/README.md | 2 +- tag/design/README.md | 1 + tag/dynamic-programming/README.md | 4 +- tag/greedy/README.md | 6 +- tag/hash-table/README.md | 5 +- tag/heap/README.md | 1 + tag/line-sweep/README.md | 2 + tag/queue/README.md | 1 + tag/recursion/README.md | 1 + tag/sort/README.md | 3 + tag/stack/README.md | 4 +- tag/string/README.md | 5 +- tag/tags.json | 36 ++++---- tag/topological-sort/README.md | 1 + tag/tree/README.md | 4 +- tag/two-pointers/README.md | 1 + tag/union-find/README.md | 1 + 237 files changed, 2919 insertions(+), 1825 deletions(-) create mode 100644 problems/closest-room/README.md create mode 100644 problems/convert-date-format/README.md create mode 100644 problems/convert-date-format/mysql_schemas.sql create mode 100644 problems/distinct-numbers-in-each-subarray/README.md create mode 100644 problems/largest-color-value-in-a-directed-graph/README.md create mode 100644 problems/league-statistics/README.md create mode 100644 problems/league-statistics/mysql_schemas.sql create mode 100644 problems/maximum-distance-between-a-pair-of-values/README.md create mode 100644 problems/maximum-element-after-decreasing-and-rearranging/README.md create mode 100644 problems/maximum-population-year/README.md create mode 100644 problems/maximum-subarray-min-product/README.md create mode 100644 problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/README.md create mode 100644 problems/minimum-distance-to-the-target-element/README.md create mode 100644 problems/minimum-interval-to-include-each-query/README.md create mode 100644 problems/next-palindrome-using-same-digits/README.md create mode 100644 problems/replace-all-digits-with-characters/README.md create mode 100644 problems/seat-reservation-manager/README.md create mode 100644 problems/splitting-a-string-into-descending-consecutive-values/README.md create mode 100644 problems/suspicious-bank-accounts/README.md create mode 100644 problems/suspicious-bank-accounts/mysql_schemas.sql diff --git a/README.md b/README.md index f743fa430..35034100f 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,23 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1857 | [Largest Color Value in a Directed Graph](https://leetcode.com/problems/largest-color-value-in-a-directed-graph "有向图中最大颜色值") | [Go](problems/largest-color-value-in-a-directed-graph) | Hard | +| 1856 | [Maximum Subarray Min-Product](https://leetcode.com/problems/maximum-subarray-min-product "子数组最小乘积的最大值") | [Go](problems/maximum-subarray-min-product) | Medium | +| 1855 | [Maximum Distance Between a Pair of Values](https://leetcode.com/problems/maximum-distance-between-a-pair-of-values "下标对中的最大距离") | [Go](problems/maximum-distance-between-a-pair-of-values) | Medium | +| 1854 | [Maximum Population Year](https://leetcode.com/problems/maximum-population-year "人口最多的年份") | [Go](problems/maximum-population-year) | Easy | +| 1853 | [Convert Date Format](https://leetcode.com/problems/convert-date-format) 🔒 | [MySQL](problems/convert-date-format) | Easy | +| 1852 | [Distinct Numbers in Each Subarray](https://leetcode.com/problems/distinct-numbers-in-each-subarray) 🔒 | [Go](problems/distinct-numbers-in-each-subarray) | Medium | +| 1851 | [Minimum Interval to Include Each Query](https://leetcode.com/problems/minimum-interval-to-include-each-query "包含每个查询的最小区间") | [Go](problems/minimum-interval-to-include-each-query) | Hard | +| 1850 | [Minimum Adjacent Swaps to Reach the Kth Smallest Number](https://leetcode.com/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number "邻位交换的最小次数") | [Go](problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number) | Medium | +| 1849 | [Splitting a String Into Descending Consecutive Values](https://leetcode.com/problems/splitting-a-string-into-descending-consecutive-values "将字符串拆分为递减的连续值") | [Go](problems/splitting-a-string-into-descending-consecutive-values) | Medium | +| 1848 | [Minimum Distance to the Target Element](https://leetcode.com/problems/minimum-distance-to-the-target-element "到目标元素的最小距离") | [Go](problems/minimum-distance-to-the-target-element) | Easy | +| 1847 | [Closest Room](https://leetcode.com/problems/closest-room "最近的房间") | [Go](problems/closest-room) | Hard | +| 1846 | [Maximum Element After Decreasing and Rearranging](https://leetcode.com/problems/maximum-element-after-decreasing-and-rearranging "减小和重新排列数组后的最大元素") | [Go](problems/maximum-element-after-decreasing-and-rearranging) | Medium | +| 1845 | [Seat Reservation Manager](https://leetcode.com/problems/seat-reservation-manager "座位预约管理系统") | [Go](problems/seat-reservation-manager) | Medium | +| 1844 | [Replace All Digits with Characters](https://leetcode.com/problems/replace-all-digits-with-characters "将所有数字用字符替换") | [Go](problems/replace-all-digits-with-characters) | Easy | +| 1843 | [Suspicious Bank Accounts](https://leetcode.com/problems/suspicious-bank-accounts) 🔒 | [MySQL](problems/suspicious-bank-accounts) | Medium | +| 1842 | [Next Palindrome Using Same Digits](https://leetcode.com/problems/next-palindrome-using-same-digits) 🔒 | [Go](problems/next-palindrome-using-same-digits) | Hard | +| 1841 | [League Statistics](https://leetcode.com/problems/league-statistics) 🔒 | [MySQL](problems/league-statistics) | Medium | | 1840 | [Maximum Building Height](https://leetcode.com/problems/maximum-building-height "最高建筑高度") | [Go](problems/maximum-building-height) | Hard | | 1839 | [Longest Substring Of All Vowels in Order](https://leetcode.com/problems/longest-substring-of-all-vowels-in-order "所有元音按顺序排布的最长子字符串") | [Go](problems/longest-substring-of-all-vowels-in-order) | Medium | | 1838 | [Frequency of the Most Frequent Element](https://leetcode.com/problems/frequency-of-the-most-frequent-element "最高频元素的频数") | [Go](problems/frequency-of-the-most-frequent-element) | Medium | @@ -124,7 +141,7 @@ LeetCode Problems' Solutions | 1797 | [Design Authentication Manager](https://leetcode.com/problems/design-authentication-manager "设计一个验证系统") | [Go](problems/design-authentication-manager) | Medium | | 1796 | [Second Largest Digit in a String](https://leetcode.com/problems/second-largest-digit-in-a-string "字符串中第二大的数字") | [Go](problems/second-largest-digit-in-a-string) | Easy | | 1795 | [Rearrange Products Table](https://leetcode.com/problems/rearrange-products-table) 🔒 | [MySQL](problems/rearrange-products-table) | Easy | -| 1794 | [Count Pairs of Equal Substrings With Minimum Difference](https://leetcode.com/problems/count-pairs-of-equal-substrings-with-minimum-difference) 🔒 | [Go](problems/count-pairs-of-equal-substrings-with-minimum-difference) | Medium | +| 1794 | [Count Pairs of Equal Substrings With Minimum Difference](https://leetcode.com/problems/count-pairs-of-equal-substrings-with-minimum-difference "统计距离最小的子串对个数") 🔒 | [Go](problems/count-pairs-of-equal-substrings-with-minimum-difference) | Medium | | 1793 | [Maximum Score of a Good Subarray](https://leetcode.com/problems/maximum-score-of-a-good-subarray "好子数组的最大分数") | [Go](problems/maximum-score-of-a-good-subarray) | Hard | | 1792 | [Maximum Average Pass Ratio](https://leetcode.com/problems/maximum-average-pass-ratio "最大平均通过率") | [Go](problems/maximum-average-pass-ratio) | Medium | | 1791 | [Find Center of Star Graph](https://leetcode.com/problems/find-center-of-star-graph "找出星型图的中心节点") | [Go](problems/find-center-of-star-graph) | Medium | diff --git a/problems/2-keys-keyboard/README.md b/problems/2-keys-keyboard/README.md index 618540934..0573f3c6f 100644 --- a/problems/2-keys-keyboard/README.md +++ b/problems/2-keys-keyboard/README.md @@ -11,38 +11,40 @@ ## [650. 2 Keys Keyboard (Medium)](https://leetcode.com/problems/2-keys-keyboard "只有两个键的键盘") -

      Initially on a notepad only one character 'A' is present. You can perform two operations on this notepad for each step:

      +

      There is only one character 'A' on the screen of a notepad. You can perform two operations on this notepad for each step:

      -
        -
      1. Copy All: You can copy all the characters present on the notepad (partial copy is not allowed).
      2. -
      3. Paste: You can paste the characters which are copied last time.
      4. -
      +
        +
      • Copy All: You can copy all the characters present on the screen (a partial copy is not allowed).
      • +
      • Paste: You can paste the characters which are copied last time.
      • +
      + +

      Given an integer n, return the minimum number of operations to get the character 'A' exactly n times on the screen.

       

      +

      Example 1:

      -

      Given a number n. You have to get exactly n 'A' on the notepad by performing the minimum number of steps permitted. Output the minimum number of steps to get n 'A'.

      +
      +Input: n = 3
      +Output: 3
      +Explanation: Intitally, we have one character 'A'.
      +In step 1, we use Copy All operation.
      +In step 2, we use Paste operation to get 'AA'.
      +In step 3, we use Paste operation to get 'AAA'.
      +
      -

      Example 1:

      +

      Example 2:

      -Input: 3
      -Output: 3
      -Explanation:
      -Intitally, we have one character 'A'.
      -In step 1, we use Copy All operation.
      -In step 2, we use Paste operation to get 'AA'.
      -In step 3, we use Paste operation to get 'AAA'.
      +Input: n = 1
      +Output: 0
       

       

      +

      Constraints:

      -

      Note:

      - -
        -
      1. The n will be in the range [1, 1000].
      2. -
      - -

       

      +
        +
      • 1 <= n <= 1000
      • +
      ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/24-game/README.md b/problems/24-game/README.md index d5d1487e8..41c12cd16 100644 --- a/problems/24-game/README.md +++ b/problems/24-game/README.md @@ -11,33 +11,53 @@ ## [679. 24 Game (Hard)](https://leetcode.com/problems/24-game "24 点游戏") -

      -You have 4 cards each containing a number from 1 to 9. You need to judge whether they could operated through *, /, +, -, (, ) to get the value of 24. -

      +

      You are given an integer array cards of length 4. You have four cards, each containing a number in the range [1, 9]. You should arrange the numbers on these cards in a mathematical expression using the operators ['+', '-', '*', '/'] and the parentheses '(' and ')' to get the value 24.

      + +

      You are restricted with the following rules:

      + +
        +
      • The division operator '/' represents real division, not integer division. +
          +
        • For example, 4 / (1 - 2 / 3) = 4 / (1 / 3) = 12.
        • +
        +
      • +
      • Every operation done is between two numbers. In particular, we cannot use '-' as a unary operator. +
          +
        • For example, if cards = [1, 1, 1, 1], the expression "-1 - 1 - 1 - 1" is not allowed.
        • +
        +
      • +
      • You cannot concatenate numbers together +
          +
        • For example, if cards = [1, 2, 1, 2], the expression "12 + 12" is not valid.
        • +
        +
      • +
      + +

      Return true if you can get such expression that evaluates to 24, and false otherwise.

      + +

       

      +

      Example 1:

      -

      Example 1:

      -Input: [4, 1, 8, 7]
      -Output: True
      -Explanation: (8-4) * (7-1) = 24
      +Input: cards = [4,1,8,7]
      +Output: true
      +Explanation: (8-4) * (7-1) = 24
       
      -

      -

      Example 2:
      +

      Example 2:

      +
      -Input: [1, 2, 1, 2]
      -Output: False
      +Input: cards = [1,2,1,2]
      +Output: false
       
      -

      - -

      Note:
      -

        -
      1. The division operator / represents real division, not integer division. For example, 4 / (1 - 2/3) = 12.
      2. -
      3. Every operation done is between two numbers. In particular, we cannot use - as a unary operator. For example, with [1, 1, 1, 1] as input, the expression -1 - 1 - 1 - 1 is not allowed.
      4. -
      5. You cannot concatenate numbers together. For example, if the input is [1, 2, 1, 2], we cannot write this as 12 + 12.
      6. -
      -

      -

      + +

       

      +

      Constraints:

      + +
        +
      • cards.length == 4
      • +
      • 1 <= cards[i] <= 9
      • +
      ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/4sum-ii/README.md b/problems/4sum-ii/README.md index 31270c22a..40c4f7837 100644 --- a/problems/4sum-ii/README.md +++ b/problems/4sum-ii/README.md @@ -15,7 +15,7 @@
      • 0 <= i, j, k, l < n
      • -
      • nums1[i] + nums2[j] + nums3[k] + nums[l] == 0
      • +
      • nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0

       

      diff --git a/problems/add-strings/README.md b/problems/add-strings/README.md index d48d79bcd..79bc5117f 100644 --- a/problems/add-strings/README.md +++ b/problems/add-strings/README.md @@ -13,6 +13,8 @@

      Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string.

      +

      You must solve the problem without using any built-in library for handling large integers (such as BigInteger). You must also not convert the inputs to integers directly.

      +

       

      Example 1:

      @@ -44,9 +46,6 @@
    • num1 and num2 don't have any leading zeros except for the zero itself.
    -

     

    -

    Follow up: Could you solve it without using any built-in BigInteger library or converting the inputs to integer directly?

    - ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/advantage-shuffle/README.md b/problems/advantage-shuffle/README.md index 4e521fc07..5d39d89ec 100644 --- a/problems/advantage-shuffle/README.md +++ b/problems/advantage-shuffle/README.md @@ -11,9 +11,9 @@ ## [870. Advantage Shuffle (Medium)](https://leetcode.com/problems/advantage-shuffle "优势洗牌") -

    Given two arrays A and B of equal size, the advantage of A with respect to B is the number of indices i for which A[i] > B[i].

    +

    Given two arrays nums1 and nums2 of equal size, the advantage of nums1 with respect to nums2 is the number of indices i for which nums1[i] > nums2[i].

    -

    Return any permutation of A that maximizes its advantage with respect to B.

    +

    Return any permutation of nums1 that maximizes its advantage with respect to nums2.

     

    @@ -21,7 +21,7 @@

    Example 1:

    -Input: A = [2,7,11,15], B = [1,10,4,11]
    +Input: nums1 = [2,7,11,15], nums2 = [1,10,4,11]
     Output: [2,11,7,15]
     
    @@ -29,7 +29,7 @@

    Example 2:

    -Input: A = [12,24,8,32], B = [13,25,32,11]
    +Input: nums1 = [12,24,8,32], nums2 = [13,25,32,11]
     Output: [24,32,8,12]
     
    @@ -38,9 +38,9 @@

    Note:

      -
    1. 1 <= A.length = B.length <= 10000
    2. -
    3. 0 <= A[i] <= 10^9
    4. -
    5. 0 <= B[i] <= 10^9
    6. +
    7. 1 <= nums1.length = nums2.length <= 10000
    8. +
    9. 0 <= nums1[i] <= 109
    10. +
    11. 0 <= nums2[i] <= 109
    diff --git a/problems/all-nodes-distance-k-in-binary-tree/README.md b/problems/all-nodes-distance-k-in-binary-tree/README.md index 6fd3d78fb..7c37d9609 100644 --- a/problems/all-nodes-distance-k-in-binary-tree/README.md +++ b/problems/all-nodes-distance-k-in-binary-tree/README.md @@ -11,9 +11,9 @@ ## [863. All Nodes Distance K in Binary Tree (Medium)](https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree "二叉树中所有距离为 K 的结点") -

    We are given a binary tree (with root node root), a target node, and an integer value K.

    +

    We are given a binary tree (with root node root), a target node, and an integer value k.

    -

    Return a list of the values of all nodes that have a distance K from the target node.  The answer can be returned in any order.

    +

    Return a list of the values of all nodes that have a distance k from the target node.  The answer can be returned in any order.

     

    @@ -24,7 +24,7 @@

    Example 1:

    -Input: root = [3,5,1,6,2,0,8,null,null,7,4], target = 5, K = 2
    +Input: root = [3,5,1,6,2,0,8,null,null,7,4], target = 5, k = 2
     
     Output: [7,4,1]
     
    @@ -46,7 +46,7 @@ The descriptions of the inputs above are just serializations of these objects.
     	
  • The given tree is non-empty.
  • Each node in the tree has unique values 0 <= node.val <= 500.
  • The target node is a node in the tree.
  • -
  • 0 <= K <= 1000.
  • +
  • 0 <= k <= 1000.
  • diff --git a/problems/ambiguous-coordinates/README.md b/problems/ambiguous-coordinates/README.md index a0f719e6e..8a5cbacd8 100644 --- a/problems/ambiguous-coordinates/README.md +++ b/problems/ambiguous-coordinates/README.md @@ -11,7 +11,7 @@ ## [816. Ambiguous Coordinates (Medium)](https://leetcode.com/problems/ambiguous-coordinates "模糊坐标") -

    We had some 2-dimensional coordinates, like "(1, 3)" or "(2, 0.5)".  Then, we removed all commas, decimal points, and spaces, and ended up with the string S.  Return a list of strings representing all possibilities for what our original coordinates could have been.

    +

    We had some 2-dimensional coordinates, like "(1, 3)" or "(2, 0.5)".  Then, we removed all commas, decimal points, and spaces, and ended up with the string s.  Return a list of strings representing all possibilities for what our original coordinates could have been.

    Our original representation never had extraneous zeroes, so we never started with numbers like "00", "0.0", "0.00", "1.0", "001", "00.01", or any other number that can be represented with less digits.  Also, a decimal point within a number never occurs without at least one digit occuring before it, so we never started with numbers like ".1".

    @@ -19,13 +19,13 @@
     Example 1:
    -Input: "(123)"
    +Input: s = "(123)"
     Output: ["(1, 23)", "(12, 3)", "(1.2, 3)", "(1, 2.3)"]
     
     Example 2:
    -Input: "(00011)"
    +Input: s = "(00011)"
     Output:  ["(0.001, 1)", "(0, 0.011)"]
     Explanation: 
     0.0, 00, 0001 or 00.01 are not allowed.
    @@ -33,13 +33,13 @@
     
     
     Example 3:
    -Input: "(0123)"
    +Input: s = "(0123)"
     Output: ["(0, 123)", "(0, 12.3)", "(0, 1.23)", "(0.1, 23)", "(0.1, 2.3)", "(0.12, 3)"]
     
     Example 4:
    -Input: "(100)"
    +Input: s = "(100)"
     Output: [(10, 0)]
     Explanation: 
     1.0 is not allowed.
    @@ -50,8 +50,8 @@
     

    Note:

      -
    • 4 <= S.length <= 12.
    • -
    • S[0] = "(", S[S.length - 1] = ")", and the other elements in S are digits.
    • +
    • 4 <= s.length <= 12.
    • +
    • s[0] = "(", s[s.length - 1] = ")", and the other elements in s are digits.

     

    diff --git a/problems/array-nesting/README.md b/problems/array-nesting/README.md index dc5881bd9..013bd69e1 100644 --- a/problems/array-nesting/README.md +++ b/problems/array-nesting/README.md @@ -11,33 +11,45 @@ ## [565. Array Nesting (Medium)](https://leetcode.com/problems/array-nesting "数组嵌套") -

    A zero-indexed array A of length N contains all integers from 0 to N-1. Find and return the longest length of set S, where S[i] = {A[i], A[A[i]], A[A[A[i]]], ... } subjected to the rule below.

    +

    You are given an integer array nums of length n where nums is a permutation of the numbers in the range [0, n - 1].

    -

    Suppose the first element in S starts with the selection of element A[i] of index = i, the next element in S should be A[A[i]], and then A[A[A[i]]]… By that analogy, we stop adding right before a duplicate element occurs in S.

    +

    You should build a set s[k] = {nums[k], nums[nums[i]], nums[nums[nums[k]]], ... } subjected to the following rule:

    -

     

    +
      +
    • The first element in s[k] starts with the selection of the element nums[k] of index = k.
    • +
    • The next element in s[k] should be nums[nums[k]], and then nums[nums[nums[k]]], and so on.
    • +
    • We stop adding right before a duplicate element occurs in s[k].
    • +
    + +

    Return the longest length of a set s[k].

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input: A = [5,4,0,3,1,6,2]
    -Output: 4
    -Explanation: 
    -A[0] = 5, A[1] = 4, A[2] = 0, A[3] = 3, A[4] = 1, A[5] = 6, A[6] = 2.
    +Input: nums = [5,4,0,3,1,6,2]
    +Output: 4
    +Explanation: 
    +nums[0] = 5, nums[1] = 4, nums[2] = 0, nums[3] = 3, nums[4] = 1, nums[5] = 6, nums[6] = 2.
    +One of the longest sets s[k]:
    +s[0] = {nums[0], nums[5], nums[6], nums[2]} = {5, 6, 2, 0}
    +
    -One of the longest S[K]: -S[0] = {A[0], A[5], A[6], A[2]} = {5, 6, 2, 0} +

    Example 2:

    + +
    +Input: nums = [0,1,2]
    +Output: 1
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. N is an integer within the range [1, 20,000].
    2. -
    3. The elements of A are all distinct.
    4. -
    5. Each element of A is an integer within the range [0, N-1].
    6. -
    +
      +
    • 1 <= nums.length <= 105
    • +
    • 0 <= nums[i] < nums.length
    • +
    • All the values of nums are unique.
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/bag-of-tokens/README.md b/problems/bag-of-tokens/README.md index beadcd680..aae003d9f 100644 --- a/problems/bag-of-tokens/README.md +++ b/problems/bag-of-tokens/README.md @@ -11,7 +11,7 @@ ## [948. Bag of Tokens (Medium)](https://leetcode.com/problems/bag-of-tokens "令牌放置") -

    You have an initial power of P, an initial score of 0, and a bag of tokens where tokens[i] is the value of the ith token (0-indexed).

    +

    You have an initial power of power, an initial score of 0, and a bag of tokens where tokens[i] is the value of the ith token (0-indexed).

    Your goal is to maximize your total score by potentially playing each token in one of two ways:

    @@ -28,7 +28,7 @@

    Example 1:

    -Input: tokens = [100], P = 50
    +Input: tokens = [100], power = 50
     Output: 0
     Explanation: Playing the only token in the bag is impossible because you either have too little power or too little score.
     
    @@ -36,7 +36,7 @@

    Example 2:

    -Input: tokens = [100,200], P = 150
    +Input: tokens = [100,200], power = 150
     Output: 1
     Explanation: Play the 0th token (100) face up, your power becomes 50 and score becomes 1.
     There is no need to play the 1st token since you cannot play it face up to add to your score.
    @@ -45,7 +45,7 @@ There is no need to play the 1st token since you cannot play it face
     

    Example 3:

    -Input: tokens = [100,200,300,400], P = 200
    +Input: tokens = [100,200,300,400], power = 200
     Output: 2
     Explanation: Play the tokens in this order to get a score of 2:
     1. Play the 0th token (100) face up, your power becomes 100 and score becomes 1.
    @@ -59,7 +59,7 @@ There is no need to play the 1st token since you cannot play it face
     
     
    • 0 <= tokens.length <= 1000
    • -
    • 0 <= tokens[i], P < 104
    • +
    • 0 <= tokens[i], power < 104
    ### Related Topics diff --git a/problems/basic-calculator-ii/README.md b/problems/basic-calculator-ii/README.md index 2528f927b..16dd1392a 100644 --- a/problems/basic-calculator-ii/README.md +++ b/problems/basic-calculator-ii/README.md @@ -15,6 +15,8 @@

    The integer division should truncate toward zero.

    +

    Note: You are not allowed to use any built-in function which evaluates strings as mathematical expressions, such as eval().

    +

     

    Example 1:

    Input: s = "3+2*2"
    diff --git a/problems/basic-calculator/README.md b/problems/basic-calculator/README.md
    index aec611066..f28d6243d 100644
    --- a/problems/basic-calculator/README.md
    +++ b/problems/basic-calculator/README.md
    @@ -13,6 +13,8 @@
     
     

    Given a string s representing an expression, implement a basic calculator to evaluate it.

    +

    Note: You are not allowed to use any built-in function which evaluates strings as mathematical expressions, such as eval().

    +

     

    Example 1:

    diff --git a/problems/beautiful-array/README.md b/problems/beautiful-array/README.md index 3d8ca7a50..7164c7187 100644 --- a/problems/beautiful-array/README.md +++ b/problems/beautiful-array/README.md @@ -11,18 +11,18 @@ ## [932. Beautiful Array (Medium)](https://leetcode.com/problems/beautiful-array "漂亮数组") -

    For some fixed N, an array A is beautiful if it is a permutation of the integers 1, 2, ..., N, such that:

    +

    For some fixed n, an array nums is beautiful if it is a permutation of the integers 1, 2, ..., n, such that:

    -

    For every i < j, there is no k with i < k < j such that A[k] * 2 = A[i] + A[j].

    +

    For every i < j, there is no k with i < k < j such that nums[k] * 2 = nums[i] + nums[j].

    -

    Given N, return any beautiful array A.  (It is guaranteed that one exists.)

    +

    Given n, return any beautiful array nums.  (It is guaranteed that one exists.)

     

    Example 1:

    -Input: 4
    +Input: n = 4
     Output: [2,1,4,3]
     
    @@ -30,7 +30,7 @@

    Example 2:

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

     

    @@ -39,7 +39,7 @@

    Note:

      -
    • 1 <= N <= 1000
    • +
    • 1 <= n <= 1000
    diff --git a/problems/binary-search-tree-iterator/README.md b/problems/binary-search-tree-iterator/README.md index aaac3d2a1..f6ba38bbc 100644 --- a/problems/binary-search-tree-iterator/README.md +++ b/problems/binary-search-tree-iterator/README.md @@ -68,7 +68,7 @@ bSTIterator.hasNext(); // return False [[Design](../../tag/design/README.md)] ### Similar Questions - 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Medium) + 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Easy) 1. [Flatten 2D Vector](../flatten-2d-vector) (Medium) 1. [Zigzag Iterator](../zigzag-iterator) (Medium) 1. [Peeking Iterator](../peeking-iterator) (Medium) diff --git a/problems/binary-subarrays-with-sum/README.md b/problems/binary-subarrays-with-sum/README.md index 530b9e980..50524cd97 100644 --- a/problems/binary-subarrays-with-sum/README.md +++ b/problems/binary-subarrays-with-sum/README.md @@ -11,14 +11,14 @@ ## [930. Binary Subarrays With Sum (Medium)](https://leetcode.com/problems/binary-subarrays-with-sum "和相同的二元子数组") -

    In an array A of 0s and 1s, how many non-empty subarrays have sum S?

    +

    In an array nums of 0s and 1s, how many non-empty subarrays have sum goal?

     

    Example 1:

    -Input: A = [1,0,1,0,1], S = 2
    +Input: nums = [1,0,1,0,1], goal = 2
     Output: 4
     Explanation: 
     The 4 subarrays are bolded below:
    @@ -33,9 +33,9 @@ The 4 subarrays are bolded below:
     

    Note:

      -
    1. A.length <= 30000
    2. -
    3. 0 <= S <= A.length
    4. -
    5. A[i] is either 0 or 1.
    6. +
    7. nums.length <= 30000
    8. +
    9. 0 <= goal <= nums.length
    10. +
    11. nums[i] is either 0 or 1.
    ### Related Topics diff --git a/problems/binary-tree-inorder-traversal/README.md b/problems/binary-tree-inorder-traversal/README.md index d85b65b80..31cc4eb71 100644 --- a/problems/binary-tree-inorder-traversal/README.md +++ b/problems/binary-tree-inorder-traversal/README.md @@ -9,7 +9,7 @@                  [Next >](../unique-binary-search-trees-ii "Unique Binary Search Trees II") -## [94. Binary Tree Inorder Traversal (Medium)](https://leetcode.com/problems/binary-tree-inorder-traversal "二叉树的中序遍历") +## [94. Binary Tree Inorder Traversal (Easy)](https://leetcode.com/problems/binary-tree-inorder-traversal "二叉树的中序遍历")

    Given the root of a binary tree, return the inorder traversal of its nodes' values.

    @@ -58,12 +58,7 @@

     

    - -

    Follow up:

    - -

    Recursive solution is trivial, could you do it iteratively?

    - -

     

    +Follow up: Recursive solution is trivial, could you do it iteratively? ### Related Topics [[Stack](../../tag/stack/README.md)] @@ -73,7 +68,7 @@ ### Similar Questions 1. [Validate Binary Search Tree](../validate-binary-search-tree) (Medium) 1. [Binary Tree Preorder Traversal](../binary-tree-preorder-traversal) (Medium) - 1. [Binary Tree Postorder Traversal](../binary-tree-postorder-traversal) (Medium) + 1. [Binary Tree Postorder Traversal](../binary-tree-postorder-traversal) (Easy) 1. [Binary Search Tree Iterator](../binary-search-tree-iterator) (Medium) 1. [Kth Smallest Element in a BST](../kth-smallest-element-in-a-bst) (Medium) 1. [Closest Binary Search Tree Value II](../closest-binary-search-tree-value-ii) (Hard) diff --git a/problems/binary-tree-postorder-traversal/README.md b/problems/binary-tree-postorder-traversal/README.md index 0b46dcb03..029693b66 100644 --- a/problems/binary-tree-postorder-traversal/README.md +++ b/problems/binary-tree-postorder-traversal/README.md @@ -9,7 +9,7 @@                  [Next >](../lru-cache "LRU Cache") -## [145. Binary Tree Postorder Traversal (Medium)](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历") +## [145. Binary Tree Postorder Traversal (Easy)](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历")

    Given the root of a binary tree, return the postorder traversal of its nodes' values.

    @@ -58,17 +58,12 @@

     

    - -

    Follow up:

    - -

    Recursive solution is trivial, could you do it iteratively?

    - -

     

    +Follow up: Recursive solution is trivial, could you do it iteratively? ### Related Topics [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Medium) + 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Easy) 1. [N-ary Tree Postorder Traversal](../n-ary-tree-postorder-traversal) (Easy) diff --git a/problems/binary-tree-preorder-traversal/README.md b/problems/binary-tree-preorder-traversal/README.md index e3638d691..51b865612 100644 --- a/problems/binary-tree-preorder-traversal/README.md +++ b/problems/binary-tree-preorder-traversal/README.md @@ -65,6 +65,6 @@ [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Medium) + 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Easy) 1. [Verify Preorder Sequence in Binary Search Tree](../verify-preorder-sequence-in-binary-search-tree) (Medium) 1. [N-ary Tree Preorder Traversal](../n-ary-tree-preorder-traversal) (Easy) diff --git a/problems/broken-calculator/README.md b/problems/broken-calculator/README.md index a452afcbb..ef2434b74 100644 --- a/problems/broken-calculator/README.md +++ b/problems/broken-calculator/README.md @@ -18,16 +18,16 @@
  • Decrement: Subtract 1 from the number on the display.
  • -

    Initially, the calculator is displaying the number X.

    +

    Initially, the calculator is displaying the number x.

    -

    Return the minimum number of operations needed to display the number Y.

    +

    Return the minimum number of operations needed to display the number y.

     

    Example 1:

    -Input: X = 2, Y = 3
    +Input: x = 2, y = 3
     Output: 2
     Explanation: Use double operation and then decrement operation {2 -> 4 -> 3}.
     
    @@ -35,7 +35,7 @@

    Example 2:

    -Input: X = 5, Y = 8
    +Input: x = 5, y = 8
     Output: 2
     Explanation: Use decrement and then double {5 -> 4 -> 8}.
     
    @@ -43,7 +43,7 @@

    Example 3:

    -Input: X = 3, Y = 10
    +Input: x = 3, y = 10
     Output: 3
     Explanation:  Use double, decrement and double {3 -> 6 -> 5 -> 10}.
     
    @@ -51,7 +51,7 @@

    Example 4:

    -Input: X = 1024, Y = 1
    +Input: x = 1024, y = 1
     Output: 1023
     Explanation: Use decrement operations 1023 times.
     
    @@ -61,8 +61,8 @@

    Note:

      -
    1. 1 <= X <= 10^9
    2. -
    3. 1 <= Y <= 10^9
    4. +
    5. 1 <= x <= 109
    6. +
    7. 1 <= y <= 109
    ### Related Topics diff --git a/problems/bulb-switcher-ii/README.md b/problems/bulb-switcher-ii/README.md index 2e641f981..04192eb83 100644 --- a/problems/bulb-switcher-ii/README.md +++ b/problems/bulb-switcher-ii/README.md @@ -11,50 +11,51 @@ ## [672. Bulb Switcher II (Medium)](https://leetcode.com/problems/bulb-switcher-ii "灯泡开关 Ⅱ") -

    There is a room with n lights which are turned on initially and 4 buttons on the wall. After performing exactly m unknown operations towards buttons, you need to return how many different kinds of status of the n lights could be.

    +

    There is a room with n bulbs labeled from 1 to n that all are turned on initially, and four buttons on the wall. Each of the four buttons has a different functionality where:

    -

    Suppose n lights are labeled as number [1, 2, 3 ..., n], function of these 4 buttons are given below:

    +
      +
    • Button 1: Flips the status of all the bulbs.
    • +
    • Button 2: Flips the status of all the bulbs with even labels (i.e., 2, 4, ...).
    • +
    • Button 3: Flips the status of all the bulbs with odd labels (i.e., 1, 3, ...).
    • +
    • Button 4: Flips the status of all the bulbs with a label j = 3k + 1 where k = 0, 1, 2, ... (i.e., 1, 4, 7, 10, ...).
    • +
    -
      -
    1. Flip all the lights.
    2. -
    3. Flip lights with even numbers.
    4. -
    5. Flip lights with odd numbers.
    6. -
    7. Flip lights with (3k + 1) numbers, k = 0, 1, 2, ...
    8. -
    +

    You will press one of the four mentioned buttons exactly presses times.

    -

     

    +

    Given the two integers n and presses, return the number of different statuses after pressing the four buttons exactly presses times.

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input: n = 1, m = 1.
    -Output: 2
    -Explanation: Status can be: [on], [off]
    +Input: n = 1, presses = 1
    +Output: 2
    +Explanation: Status can be: [on], [off].
     
    -

     

    - -

    Example 2:

    +

    Example 2:

    -Input: n = 2, m = 1.
    -Output: 3
    -Explanation: Status can be: [on, off], [off, on], [off, off]
    +Input: n = 2, presses = 1
    +Output: 3
    +Explanation: Status can be: [on, off], [off, on], [off, off].
     
    -

     

    - -

    Example 3:

    +

    Example 3:

    -Input: n = 3, m = 1.
    -Output: 4
    -Explanation: Status can be: [off, on, off], [on, off, on], [off, off, off], [off, on, on].
    +Input: n = 3, presses = 1
    +Output: 4
    +Explanation: Status can be: [off, on, off], [on, off, on], [off, off, off], [off, on, on].
     

     

    +

    Constraints:

    -

    Note: n and m both fit in range [0, 1000].

    +
      +
    • 1 <= n <= 1000
    • +
    • 0 <= presses <= 1000
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/bulb-switcher-iv/README.md b/problems/bulb-switcher-iv/README.md index d6b7b9e7e..bd64bc80e 100644 --- a/problems/bulb-switcher-iv/README.md +++ b/problems/bulb-switcher-iv/README.md @@ -11,20 +11,20 @@ ## [1529. Bulb Switcher IV (Medium)](https://leetcode.com/problems/bulb-switcher-iv "灯泡开关 IV") -

    There is a room with n bulbs, numbered from 0 to n-1, arranged in a row from left to right. Initially all the bulbs are turned off.

    +

    There is a room with n bulbs, numbered from 0 to n - 1, arranged in a row from left to right. Initially, all the bulbs are turned off.

    -

    Your task is to obtain the configuration represented by target where target[i] is '1' if the i-th bulb is turned on and is '0' if it is turned off.

    +

    Your task is to obtain the configuration represented by target where target[i] is '1' if the ith bulb is turned on and is '0' if it is turned off.

    -

    You have a switch to flip the state of the bulb, a flip operation is defined as follows:

    +

    You have a switch to flip the state of the bulb, a flip operation is defined as follows:

      -
    • Choose any bulb (index i) of your current configuration.
    • -
    • Flip each bulb from index i to n-1.
    • +
    • Choose any bulb (index i) of your current configuration.
    • +
    • Flip each bulb from index i to index n - 1.
    -

    When any bulb is flipped it means that if it is 0 it changes to 1 and if it is 1 it changes to 0.

    +

    When any bulb is flipped it means that if it is '0' it changes to '1' and if it is '1' it changes to '0'.

    -

    Return the minimum number of flips required to form target.

    +

    Return the minimum number of flips required to form target.

     

    Example 1:

    @@ -64,8 +64,8 @@ We need at least 3 flip operations to form target.

    Constraints:

      -
    • 1 <= target.length <= 10^5
    • -
    • target[i] == '0' or target[i] == '1'
    • +
    • 1 <= target.length <= 105
    • +
    • target[i] is either '0' or '1'.
    ### Related Topics diff --git a/problems/can-make-arithmetic-progression-from-sequence/README.md b/problems/can-make-arithmetic-progression-from-sequence/README.md index 345961092..2bab2cf72 100644 --- a/problems/can-make-arithmetic-progression-from-sequence/README.md +++ b/problems/can-make-arithmetic-progression-from-sequence/README.md @@ -11,9 +11,9 @@ ## [1502. Can Make Arithmetic Progression From Sequence (Easy)](https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence "判断能否形成等差数列") -

    Given an array of numbers arr. A sequence of numbers is called an arithmetic progression if the difference between any two consecutive elements is the same.

    +

    A sequence of numbers is called an arithmetic progression if the difference between any two consecutive elements is the same.

    -

    Return true if the array can be rearranged to form an arithmetic progression, otherwise, return false.

    +

    Given an array of numbers arr, return true if the array can be rearranged to form an arithmetic progression. Otherwise, return false.

     

    Example 1:

    @@ -37,7 +37,7 @@
    • 2 <= arr.length <= 1000
    • -
    • -10^6 <= arr[i] <= 10^6
    • +
    • -106 <= arr[i] <= 106
    ### Related Topics diff --git a/problems/capacity-to-ship-packages-within-d-days/README.md b/problems/capacity-to-ship-packages-within-d-days/README.md index 6832bd250..1ed51797e 100644 --- a/problems/capacity-to-ship-packages-within-d-days/README.md +++ b/problems/capacity-to-ship-packages-within-d-days/README.md @@ -13,7 +13,7 @@

    A conveyor belt has packages that must be shipped from one port to another within D days.

    -

    The ith package on the conveyor belt has a weight of weights[i]. Each day, we load the ship with packages on the conveyor belt (in the order given by weights). We may not load more weight than the maximum weight capacity of the ship.

    +

    The ith package on the conveyor belt has a weight of weights[i]. Each day, we load the ship with packages on the conveyor belt (in the order given by weights). We may not load more weight than the maximum weight capacity of the ship.

    Return the least weight capacity of the ship that will result in all the packages on the conveyor belt being shipped within D days.

    diff --git a/problems/cheapest-flights-within-k-stops/README.md b/problems/cheapest-flights-within-k-stops/README.md index a0bb47ed5..a67f28bb4 100644 --- a/problems/cheapest-flights-within-k-stops/README.md +++ b/problems/cheapest-flights-within-k-stops/README.md @@ -11,32 +11,26 @@ ## [787. Cheapest Flights Within K Stops (Medium)](https://leetcode.com/problems/cheapest-flights-within-k-stops "K 站中转内最便宜的航班") -

    There are n cities connected by m flights. Each flight starts from city u and arrives at v with a price w.

    +

    There are n cities connected by some number of flights. You are given an array flights where flights[i] = [fromi, toi, pricei] indicates that there is a flight from city fromi to city toi with cost pricei.

    -

    Now given all the cities and flights, together with starting city src and the destination dst, your task is to find the cheapest price from src to dst with up to k stops. If there is no such route, output -1.

    +

    You are also given three integers src, dst, and k, return the cheapest price from src to dst with at most k stops. If there is no such route, return -1.

    +

     

    +

    Example 1:

    +
    -Example 1:
    -Input: 
    -n = 3, edges = [[0,1,100],[1,2,100],[0,2,500]]
    -src = 0, dst = 2, k = 1
    +Input: n = 3, flights = [[0,1,100],[1,2,100],[0,2,500]], src = 0, dst = 2, k = 1
     Output: 200
    -Explanation: 
    -The graph looks like this:
    -
    -
    -The cheapest price from city 0 to city 2 with at most 1 stop costs 200, as marked red in the picture.
    +Explanation: The graph is shown. +The cheapest price from city 0 to city 2 with at most 1 stop costs 200, as marked red in the picture. +
    +

    Example 2:

    +
    -Example 2:
    -Input: 
    -n = 3, edges = [[0,1,100],[1,2,100],[0,2,500]]
    -src = 0, dst = 2, k = 0
    +Input: n = 3, flights = [[0,1,100],[1,2,100],[0,2,500]], src = 0, dst = 2, k = 0
     Output: 500
    -Explanation: 
    -The graph looks like this:
    -
    -
    +Explanation: The graph is shown.
     The cheapest price from city 0 to city 2 with at most 0 stop costs 500, as marked blue in the picture.
     
    @@ -44,12 +38,15 @@ The cheapest price from city 0 to city 2 with at most

    Constraints:

      -
    • The number of nodes n will be in range [1, 100], with nodes labeled from 0 to n - 1.
    • -
    • The size of flights will be in range [0, n * (n - 1) / 2].
    • -
    • The format of each flight will be (src, dst, price).
    • -
    • The price of each flight will be in the range [1, 10000].
    • -
    • k is in the range of [0, n - 1].
    • -
    • There will not be any duplicated flights or self cycles.
    • +
    • 1 <= n <= 100
    • +
    • 0 <= flights.length <= (n * (n - 1) / 2)
    • +
    • flights[i].length == 3
    • +
    • 0 <= fromi, toi < n
    • +
    • fromi != toi
    • +
    • 1 <= pricei <= 104
    • +
    • There will not be any multiple flights between two cities.
    • +
    • 0 <= src, dst, k < n
    • +
    • src != dst
    ### Related Topics diff --git a/problems/clone-graph/README.md b/problems/clone-graph/README.md index e80992258..7a7b6a3f6 100644 --- a/problems/clone-graph/README.md +++ b/problems/clone-graph/README.md @@ -11,11 +11,11 @@ ## [133. Clone Graph (Medium)](https://leetcode.com/problems/clone-graph "克隆图") -

    Given a reference of a node in a connected undirected graph.

    +

    Given a reference of a node in a connected undirected graph.

    Return a deep copy (clone) of the graph.

    -

    Each node in the graph contains a val (int) and a list (List[Node]) of its neighbors.

    +

    Each node in the graph contains a value (int) and a list (List[Node]) of its neighbors.

     class Node {
    @@ -28,11 +28,11 @@ class Node {
     
     

    Test case format:

    -

    For simplicity sake, each node's value is the same as the node's index (1-indexed). For example, the first node with val = 1, the second node with val = 2, and so on. The graph is represented in the test case using an adjacency list.

    +

    For simplicity, each node's value is the same as the node's index (1-indexed). For example, the first node with val == 1, the second node with val == 2, and so on. The graph is represented in the test case using an adjacency list.

    -

    Adjacency list is a collection of unordered lists used to represent a finite graph. Each list describes the set of neighbors of a node in the graph.

    +

    An adjacency list is a collection of unordered lists used to represent a finite graph. Each list describes the set of neighbors of a node in the graph.

    -

    The given node will always be the first node with val = 1. You must return the copy of the given node as a reference to the cloned graph.

    +

    The given node will always be the first node with val = 1. You must return the copy of the given node as a reference to the cloned graph.

     

    Example 1:

    @@ -74,10 +74,10 @@ class Node {

    Constraints:

      +
    • The number of nodes in the graph is in the range [0, 100].
    • 1 <= Node.val <= 100
    • Node.val is unique for each node.
    • -
    • Number of Nodes will not exceed 100.
    • -
    • There is no repeated edges and no self-loops in the graph.
    • +
    • There are no repeated edges and no self-loops in the graph.
    • The Graph is connected and all nodes can be visited starting from the given node.
    diff --git a/problems/closest-binary-search-tree-value-ii/README.md b/problems/closest-binary-search-tree-value-ii/README.md index b7fc0e007..a25f2f48c 100644 --- a/problems/closest-binary-search-tree-value-ii/README.md +++ b/problems/closest-binary-search-tree-value-ii/README.md @@ -42,7 +42,7 @@ Assume that the BST is balanced, could you solve it in less than O(n + + + + + + +[< Previous](../maximum-element-after-decreasing-and-rearranging "Maximum Element After Decreasing and Rearranging") +                 +[Next >](../minimum-distance-to-the-target-element "Minimum Distance to the Target Element") + +## [1847. Closest Room (Hard)](https://leetcode.com/problems/closest-room "最近的房间") + +

    There is a hotel with n rooms. The rooms are represented by a 2D integer array rooms where rooms[i] = [roomIdi, sizei] denotes that there is a room with room number roomIdi and size equal to sizei. Each roomIdi is guaranteed to be unique.

    + +

    You are also given k queries in a 2D array queries where queries[j] = [preferredj, minSizej]. The answer to the jth query is the room number id of a room such that:

    + +
      +
    • The room has a size of at least minSizej, and
    • +
    • abs(id - preferredj) is minimized, where abs(x) is the absolute value of x.
    • +
    + +

    If there is a tie in the absolute difference, then use the room with the smallest such id. If there is no such room, the answer is -1.

    + +

    Return an array answer of length k where answer[j] contains the answer to the jth query.

    + +

     

    +

    Example 1:

    + +
    +Input: rooms = [[2,2],[1,2],[3,2]], queries = [[3,1],[3,3],[5,2]]
    +Output: [3,-1,3]
    +Explanation: The answers to the queries are as follows:
    +Query = [3,1]: Room number 3 is the closest as abs(3 - 3) = 0, and its size of 2 is at least 1. The answer is 3.
    +Query = [3,3]: There are no rooms with a size of at least 3, so the answer is -1.
    +Query = [5,2]: Room number 3 is the closest as abs(3 - 5) = 2, and its size of 2 is at least 2. The answer is 3.
    + +

    Example 2:

    + +
    +Input: rooms = [[1,4],[2,3],[3,5],[4,1],[5,2]], queries = [[2,3],[2,4],[2,5]]
    +Output: [2,1,3]
    +Explanation: The answers to the queries are as follows:
    +Query = [2,3]: Room number 2 is the closest as abs(2 - 2) = 0, and its size of 3 is at least 3. The answer is 2.
    +Query = [2,4]: Room numbers 1 and 3 both have sizes of at least 4. The answer is 1 since it is smaller.
    +Query = [2,5]: Room number 3 is the only room with a size of at least 5. The answer is 3.
    + +

     

    +

    Constraints:

    + +
      +
    • n == rooms.length
    • +
    • 1 <= n <= 105
    • +
    • k == queries.length
    • +
    • 1 <= k <= 104
    • +
    • 1 <= roomIdi, preferredj <= 107
    • +
    • 1 <= sizei, minSizej <= 107
    • +
    •  
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Is there a way to sort the queries so it's easier to search the closest room larger than the size? +
    + +
    +Hint 2 +Use binary search to speed up the search time. +
    diff --git a/problems/coin-change-2/README.md b/problems/coin-change-2/README.md index 5e891c809..ec2375819 100644 --- a/problems/coin-change-2/README.md +++ b/problems/coin-change-2/README.md @@ -13,7 +13,7 @@

    You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.

    -

    Return the number of combinations that make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.

    +

    Return the number of combinations that make up that amount. If that amount of money cannot be made up by any combination of the coins, return 0.

    You may assume that you have an infinite number of each kind of coin.

    diff --git a/problems/concatenated-words/README.md b/problems/concatenated-words/README.md index e3404100e..02ac9fb56 100644 --- a/problems/concatenated-words/README.md +++ b/problems/concatenated-words/README.md @@ -39,7 +39,7 @@
  • 1 <= words.length <= 104
  • 0 <= words[i].length <= 1000
  • words[i] consists of only lowercase English letters.
  • -
  • 0 <= sum(words[i].length) <= 6 * 105
  • +
  • 0 <= sum(words[i].length) <= 105
  • ### Related Topics diff --git a/problems/consecutive-numbers-sum/README.md b/problems/consecutive-numbers-sum/README.md index 919abaae0..9bf87d3f2 100644 --- a/problems/consecutive-numbers-sum/README.md +++ b/problems/consecutive-numbers-sum/README.md @@ -11,30 +11,30 @@ ## [829. Consecutive Numbers Sum (Hard)](https://leetcode.com/problems/consecutive-numbers-sum "连续整数求和") -

    Given a positive integer N, how many ways can we write it as a sum of consecutive positive integers?

    +

    Given a positive integer n, how many ways can we write it as a sum of consecutive positive integers?

    Example 1:

    -Input: 5
    +Input: n = 5
     Output: 2
     Explanation: 5 = 5 = 2 + 3

    Example 2:

    -Input: 9
    +Input: n = 9
     Output: 3
     Explanation: 9 = 9 = 4 + 5 = 2 + 3 + 4

    Example 3:

    -Input: 15
    +Input: n = 15
     Output: 4
     Explanation: 15 = 15 = 8 + 7 = 4 + 5 + 6 = 1 + 2 + 3 + 4 + 5
    -

    Note: 1 <= N <= 10 ^ 9.

    +

    Note: 1 <= n <= 10 ^ 9.

    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/construct-string-from-binary-tree/README.md b/problems/construct-string-from-binary-tree/README.md index c1eb73f7f..0151402d5 100644 --- a/problems/construct-string-from-binary-tree/README.md +++ b/problems/construct-string-from-binary-tree/README.md @@ -11,37 +11,34 @@ ## [606. Construct String from Binary Tree (Easy)](https://leetcode.com/problems/construct-string-from-binary-tree "根据二叉树创建字符串") -

    You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way.

    +

    Given the root of a binary tree, construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way, and return it.

    -

    The null node needs to be represented by empty parenthesis pair "()". And you need to omit all the empty parenthesis pairs that don't affect the one-to-one mapping relationship between the string and the original binary tree.

    +

    Omit all the empty parenthesis pairs that do not affect the one-to-one mapping relationship between the string and the original binary tree.

    -

    Example 1:
    +

     

    +

    Example 1:

    +
    -Input: Binary tree: [1,2,3,4]
    -       1
    -     /   \
    -    2     3
    -   /    
    -  4     
    -
    -Output: "1(2(4))(3)"
    -
    Explanation: Originallay it needs to be "1(2(4)())(3()())",
    but you need to omit all the unnecessary empty parenthesis pairs.
    And it will be "1(2(4))(3)". +Input: root = [1,2,3,4] +Output: "1(2(4))(3)" +Explanation: Originallay it needs to be "1(2(4)())(3()())", but you need to omit all the unnecessary empty parenthesis pairs. And it will be "1(2(4))(3)"
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: Binary tree: [1,2,3,null,4]
    -       1
    -     /   \
    -    2     3
    -     \  
    -      4 
    -
    -Output: "1(2()(4))(3)"
    -
    Explanation: Almost the same as the first example,
    except we can't omit the first parenthesis pair to break the one-to-one mapping relationship between the input and the output. +Input: root = [1,2,3,null,4] +Output: "1(2()(4))(3)" +Explanation: Almost the same as the first example, except we cannot omit the first parenthesis pair to break the one-to-one mapping relationship between the input and the output.
    -

    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [1, 104].
    • +
    • -1000 <= Node.val <= 1000
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/construct-target-array-with-multiple-sums/README.md b/problems/construct-target-array-with-multiple-sums/README.md index 08f6155d4..2885cfea1 100644 --- a/problems/construct-target-array-with-multiple-sums/README.md +++ b/problems/construct-target-array-with-multiple-sums/README.md @@ -11,15 +11,15 @@ ## [1354. Construct Target Array With Multiple Sums (Hard)](https://leetcode.com/problems/construct-target-array-with-multiple-sums "多次求和构造目标数组") -

    Given an array of integers target. From a starting array, A consisting of all 1's, you may perform the following procedure :

    +

    You are given an array target of n integers. From a starting array arr consisting of n 1's, you may perform the following procedure :

    • let x be the sum of all elements currently in your array.
    • -
    • choose index i, such that 0 <= i < target.size and set the value of A at index i to x.
    • -
    • You may repeat this procedure as many times as needed.
    • +
    • choose index i, such that 0 <= i < n and set the value of arr at index i to x.
    • +
    • You may repeat this procedure as many times as needed.
    -

    Return True if it is possible to construct the target array from A otherwise return False.

    +

    Return true if it is possible to construct the target array from arr, otherwise, return false.

     

    Example 1:

    @@ -27,7 +27,7 @@
     Input: target = [9,3,5]
     Output: true
    -Explanation: Start with [1, 1, 1] 
    +Explanation: Start with arr = [1, 1, 1] 
     [1, 1, 1], sum = 3 choose index 1
     [1, 3, 1], sum = 5 choose index 2
     [1, 3, 5], sum = 9 choose index 0
    @@ -53,9 +53,9 @@
     

    Constraints:

      -
    • N == target.length
    • -
    • 1 <= target.length <= 5 * 10^4
    • -
    • 1 <= target[i] <= 10^9
    • +
    • n == target.length
    • +
    • 1 <= n <= 5 * 104
    • +
    • 1 <= target[i] <= 109
    ### Related Topics diff --git a/problems/convert-a-number-to-hexadecimal/README.md b/problems/convert-a-number-to-hexadecimal/README.md index 696d7a24b..82e70838b 100644 --- a/problems/convert-a-number-to-hexadecimal/README.md +++ b/problems/convert-a-number-to-hexadecimal/README.md @@ -15,6 +15,8 @@

    All the letters in the answer string should be lowercase characters, and there should not be any leading zeros in the answer except for the zero itself.

    +

    Note: You are not allowed to use any built-in library method to directly solve this problem.

    +

     

    Example 1:

    Input: num = 26
    @@ -30,8 +32,5 @@
     	
  • -231 <= num <= 231 - 1
  • -

     

    -

    Follow up: Could you solve it without using any built-in library method?

    - ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md b/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md index 9769c0b64..13fee785c 100644 --- a/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md +++ b/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md @@ -40,4 +40,4 @@ [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions - 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Medium) + 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Easy) diff --git a/problems/convert-date-format/README.md b/problems/convert-date-format/README.md new file mode 100644 index 000000000..c68c0ea98 --- /dev/null +++ b/problems/convert-date-format/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../distinct-numbers-in-each-subarray "Distinct Numbers in Each Subarray") +                 +[Next >](../maximum-population-year "Maximum Population Year") + +## [1853. Convert Date Format (Easy)](https://leetcode.com/problems/convert-date-format "") + + diff --git a/problems/convert-date-format/mysql_schemas.sql b/problems/convert-date-format/mysql_schemas.sql new file mode 100644 index 000000000..774d3d900 --- /dev/null +++ b/problems/convert-date-format/mysql_schemas.sql @@ -0,0 +1,5 @@ +Create table If Not Exists Days (day date); +Truncate table Days; +insert into Days (day) values ('2022-04-12'); +insert into Days (day) values ('2021-08-09'); +insert into Days (day) values ('2020-06-26'); diff --git a/problems/convert-sorted-list-to-binary-search-tree/README.md b/problems/convert-sorted-list-to-binary-search-tree/README.md index 32e4d8d78..8feef8265 100644 --- a/problems/convert-sorted-list-to-binary-search-tree/README.md +++ b/problems/convert-sorted-list-to-binary-search-tree/README.md @@ -50,7 +50,7 @@
    • The number of nodes in head is in the range [0, 2 * 104].
    • -
    • -10^5 <= Node.val <= 10^5
    • +
    • -105 <= Node.val <= 105
    ### Related Topics diff --git a/problems/count-binary-substrings/README.md b/problems/count-binary-substrings/README.md index 983f09f4d..1bd0475b2 100644 --- a/problems/count-binary-substrings/README.md +++ b/problems/count-binary-substrings/README.md @@ -11,32 +11,36 @@ ## [696. Count Binary Substrings (Easy)](https://leetcode.com/problems/count-binary-substrings "计数二进制子串") -

    Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutively. -

    +

    Give a binary string s, return the number of non-empty substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutively.

    +

    Substrings that occur multiple times are counted the number of times they occur.

    -

    Example 1:
    +

     

    +

    Example 1:

    +
    -Input: "00110011"
    -Output: 6
    -Explanation: There are 6 substrings that have equal number of consecutive 1's and 0's: "0011", "01", "1100", "10", "0011", and "01".
    -
    Notice that some of these substrings repeat and are counted the number of times they occur. -
    Also, "00110011" is not a valid substring because all the 0's (and 1's) are not grouped together. +Input: s = "00110011" +Output: 6 +Explanation: There are 6 substrings that have equal number of consecutive 1's and 0's: "0011", "01", "1100", "10", "0011", and "01". +Notice that some of these substrings repeat and are counted the number of times they occur. +Also, "00110011" is not a valid substring because all the 0's (and 1's) are not grouped together.
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: "10101"
    -Output: 4
    -Explanation: There are 4 substrings: "10", "01", "10", "01" that have equal number of consecutive 1's and 0's.
    +Input: s = "10101"
    +Output: 4
    +Explanation: There are 4 substrings: "10", "01", "10", "01" that have equal number of consecutive 1's and 0's.
     
    -

    -

    Note: -

  • s.length will be between 1 and 50,000.
  • -
  • s will only consist of "0" or "1" characters.
  • -

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 105
    • +
    • s[i] is either '0' or '1'.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/count-complete-tree-nodes/README.md b/problems/count-complete-tree-nodes/README.md index ae2d96bfb..b1a505453 100644 --- a/problems/count-complete-tree-nodes/README.md +++ b/problems/count-complete-tree-nodes/README.md @@ -15,6 +15,8 @@

    According to Wikipedia, every level, except possibly the last, is completely filled in a complete binary tree, and all nodes in the last level are as far left as possible. It can have between 1 and 2h nodes inclusive at the last level h.

    +

    Design an algorithm that runs in less than O(n) time complexity.

    +

     

    Example 1:

    @@ -46,9 +48,6 @@
  • The tree is guaranteed to be complete.
  • -

     

    -Follow up: Traversing the tree to count the number of nodes in the tree is an easy solution but with O(n) complexity. Could you find a faster algorithm? - ### Related Topics [[Tree](../../tag/tree/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/count-different-palindromic-subsequences/README.md b/problems/count-different-palindromic-subsequences/README.md index 4ca9e550b..1c3b901b2 100644 --- a/problems/count-different-palindromic-subsequences/README.md +++ b/problems/count-different-palindromic-subsequences/README.md @@ -11,41 +11,41 @@ ## [730. Count Different Palindromic Subsequences (Hard)](https://leetcode.com/problems/count-different-palindromic-subsequences "统计不同回文子序列") -

    -Given a string S, find the number of different non-empty palindromic subsequences in S, and return that number modulo 10^9 + 7. -

    -A subsequence of a string S is obtained by deleting 0 or more characters from S. -

    -A sequence is palindromic if it is equal to the sequence reversed. -

    -Two sequences A_1, A_2, ... and B_1, B_2, ... are different if there is some i for which A_i != B_i. -

    - -

    Example 1:
    +

    Given a string s, find the number of different non-empty palindromic subsequences in s, and return that number modulo 10^9 + 7.

    + +

    A subsequence of a string s is obtained by deleting 0 or more characters from s.

    + +

    A sequence is palindromic if it is equal to the sequence reversed.

    + +

    Two sequences A_1, A_2, ... and B_1, B_2, ... are different if there is some i for which A_i != B_i.

    + +

    Example 1:

    +
     Input: 
    -S = 'bccb'
    +s = 'bccb'
     Output: 6
     Explanation: 
    -The 6 different non-empty palindromic subsequences are 'b', 'c', 'bb', 'cc', 'bcb', 'bccb'.
    -Note that 'bcb' is counted only once, even though it occurs twice.
    +The 6 different non-empty palindromic subsequences are 'b', 'c', 'bb', 'cc', 'bcb', 'bccb'.
    +Note that 'bcb' is counted only once, even though it occurs twice.
     
    -

    -

    Example 2:
    +

    Example 2:

    +
     Input: 
    -S = 'abcdabcdabcdabcdabcdabcdabcdabcddcbadcbadcbadcbadcbadcbadcbadcba'
    +s = 'abcdabcdabcdabcdabcdabcdabcdabcddcbadcbadcbadcbadcbadcbadcbadcba'
     Output: 104860361
     Explanation: 
     There are 3104860382 different non-empty palindromic subsequences, which is 104860361 modulo 10^9 + 7.
     
    -

    -

    Note: -

  • The length of S will be in the range [1, 1000].
  • -
  • Each character S[i] will be in the set {'a', 'b', 'c', 'd'}.
  • -

    +

    Note:

    + +
      +
    • The length of s will be in the range [1, 1000].
    • +
    • Each character s[i] will be in the set {'a', 'b', 'c', 'd'}.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/count-of-range-sum/README.md b/problems/count-of-range-sum/README.md index 74429591c..81b106aa5 100644 --- a/problems/count-of-range-sum/README.md +++ b/problems/count-of-range-sum/README.md @@ -37,12 +37,10 @@
    • 1 <= nums.length <= 104
    • -231 <= nums[i] <= 231 - 1
    • -
    • -3 * 104 <= lower <= upper <= 3 * 104
    • +
    • -105 <= lower <= upper <= 105
    • +
    • The answer is guaranteed to fit in a 32-bit integer.
    -

     

    -Follow up: A naive algorithm of O(n2) is trivial, Could you do better than that? - ### Related Topics [[Sort](../../tag/sort/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] diff --git a/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md b/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md index 5b5b4c518..8e4a0b97b 100644 --- a/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md +++ b/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md @@ -9,7 +9,7 @@                  [Next >](../rearrange-products-table "Rearrange Products Table") -## [1794. Count Pairs of Equal Substrings With Minimum Difference (Medium)](https://leetcode.com/problems/count-pairs-of-equal-substrings-with-minimum-difference "") +## [1794. Count Pairs of Equal Substrings With Minimum Difference (Medium)](https://leetcode.com/problems/count-pairs-of-equal-substrings-with-minimum-difference "统计距离最小的子串对个数") diff --git a/problems/course-schedule-ii/README.md b/problems/course-schedule-ii/README.md index 6bd7f93e8..fb7ab2659 100644 --- a/problems/course-schedule-ii/README.md +++ b/problems/course-schedule-ii/README.md @@ -11,13 +11,13 @@ ## [210. Course Schedule II (Medium)](https://leetcode.com/problems/course-schedule-ii "课程表 II") -

    There are a total of n courses you have to take labelled from 0 to n - 1.

    +

    There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi first if you want to take course ai.

    -

    Some courses may have prerequisites, for example, if prerequisites[i] = [ai, bi] this means you must take the course bi before the course ai.

    - -

    Given the total number of courses numCourses and a list of the prerequisite pairs, return the ordering of courses you should take to finish all courses.

    +
      +
    • For example, the pair [0, 1], indicates that to take course 0 you have to first take course 1.
    • +
    -

    If there are many valid answers, return any of them. If it is impossible to finish all courses, return an empty array.

    +

    Return the ordering of courses you should take to finish all courses. If there are many valid answers, return any of them. If it is impossible to finish all courses, return an empty array.

     

    Example 1:

    @@ -49,10 +49,10 @@ So one correct course order is [0,1,2,3]. Another correct ordering is [0,2,1,3].
    • 1 <= numCourses <= 2000
    • -
    • 0 <= prerequisites.length <= numCourses * (numCourses - 1)
    • +
    • 0 <= prerequisites.length <= numCourses * (numCourses - 1)
    • prerequisites[i].length == 2
    • -
    • 0 <= ai, bi < numCourses
    • -
    • ai != bi
    • +
    • 0 <= ai, bi < numCourses
    • +
    • ai != bi
    • All the pairs [ai, bi] are distinct.
    diff --git a/problems/course-schedule-iii/README.md b/problems/course-schedule-iii/README.md index bf2960faf..c37916891 100644 --- a/problems/course-schedule-iii/README.md +++ b/problems/course-schedule-iii/README.md @@ -11,33 +11,47 @@ ## [630. Course Schedule III (Hard)](https://leetcode.com/problems/course-schedule-iii "课程表 III") -

    There are n different online courses numbered from 1 to n. Each course has some duration(course length) t and closed on dth day. A course should be taken continuously for t days and must be finished before or on the dth day. You will start at the 1st day.

    +

    There are n different online courses numbered from 1 to n. You are given an array courses where courses[i] = [durationi, lastDayi] indicate that the ith course should be taken continuously for durationi days and must be finished before or on lastDayi.

    -

    Given n online courses represented by pairs (t,d), your task is to find the maximal number of courses that can be taken.

    +

    You will start on the 1st day and you cannot take two or more courses simultaneously.

    -

    Example:

    +

    Return the maximum number of courses that you can take.

    + +

     

    +

    Example 1:

    -Input: [[100, 200], [200, 1300], [1000, 1250], [2000, 3200]]
    -Output: 3
    -Explanation: 
    -There're totally 4 courses, but you can take 3 courses at most:
    -First, take the 1st course, it costs 100 days so you will finish it on the 100th day, and ready to take the next course on the 101st day.
    -Second, take the 3rd course, it costs 1000 days so you will finish it on the 1100th day, and ready to take the next course on the 1101st day. 
    -Third, take the 2nd course, it costs 200 days so you will finish it on the 1300th day. 
    -The 4th course cannot be taken now, since you will finish it on the 3300th day, which exceeds the closed date.
    +Input: courses = [[100,200],[200,1300],[1000,1250],[2000,3200]]
    +Output: 3
    +Explanation: 
    +There are totally 4 courses, but you can take 3 courses at most:
    +First, take the 1st course, it costs 100 days so you will finish it on the 100th day, and ready to take the next course on the 101st day.
    +Second, take the 3rd course, it costs 1000 days so you will finish it on the 1100th day, and ready to take the next course on the 1101st day. 
    +Third, take the 2nd course, it costs 200 days so you will finish it on the 1300th day. 
    +The 4th course cannot be taken now, since you will finish it on the 3300th day, which exceeds the closed date.
     
    -

     

    +

    Example 2:

    -

    Note:

    +
    +Input: courses = [[1,2]]
    +Output: 1
    +
    -
      -
    1. The integer 1 <= d, t, n <= 10,000.
    2. -
    3. You can't take two courses simultaneously.
    4. -
    +

    Example 3:

    + +
    +Input: courses = [[3,2],[4,3]]
    +Output: 0
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= courses.length <= 104
    • +
    • 1 <= durationi, lastDayi <= 104
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/course-schedule-iv/README.md b/problems/course-schedule-iv/README.md index 73fe187bb..956c3c9d1 100644 --- a/problems/course-schedule-iv/README.md +++ b/problems/course-schedule-iv/README.md @@ -11,23 +11,21 @@ ## [1462. Course Schedule IV (Medium)](https://leetcode.com/problems/course-schedule-iv "课程表 IV") -

    There are a total of n courses you have to take, labeled from 0 to n-1.

    +

    There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi first if you want to take course ai.

    -

    Some courses may have direct prerequisites, for example, to take course 0 you have first to take course 1, which is expressed as a pair: [1,0]

    - -

    Given the total number of courses n, a list of direct prerequisite pairs and a list of queries pairs.

    - -

    You should answer for each queries[i] whether the course queries[i][0] is a prerequisite of the course queries[i][1] or not.

    +
      +
    • For example, the pair [0, 1], indicates that to take course 0 you have to first take course 1.
    • +
    -

    Return a list of boolean, the answers to the given queries.

    +

    You are also given an array queries where queries[j] = [uj, vj]. For the jth query, you should answer whether the course uj is a prerequisite of the course vj or not. Note that if course a is a prerequisite of course b and course b is a prerequisite of course c, then, course a is a prerequisite of course c.

    -

    Please note that if course a is a prerequisite of course b and course b is a prerequisite of course c, then, course a is a prerequisite of course c.

    +

    Return a boolean array answer, where answer[j] is the answer of the jth query.

     

    Example 1:

    - +
    -Input: n = 2, prerequisites = [[1,0]], queries = [[0,1],[1,0]]
    +Input: numCourses = 2, prerequisites = [[1,0]], queries = [[0,1],[1,0]]
     Output: [false,true]
     Explanation: course 0 is not a prerequisite of course 1 but the opposite is true.
     
    @@ -35,44 +33,31 @@

    Example 2:

    -Input: n = 2, prerequisites = [], queries = [[1,0],[0,1]]
    +Input: numCourses = 2, prerequisites = [], queries = [[1,0],[0,1]]
     Output: [false,false]
     Explanation: There are no prerequisites and each course is independent.
     

    Example 3:

    - +
    -Input: n = 3, prerequisites = [[1,2],[1,0],[2,0]], queries = [[1,0],[1,2]]
    +Input: numCourses = 3, prerequisites = [[1,2],[1,0],[2,0]], queries = [[1,0],[1,2]]
     Output: [true,true]
     
    -

    Example 4:

    - -
    -Input: n = 3, prerequisites = [[1,0],[2,0]], queries = [[0,1],[2,0]]
    -Output: [false,true]
    -
    - -

    Example 5:

    - -
    -Input: n = 5, prerequisites = [[0,1],[1,2],[2,3],[3,4]], queries = [[0,4],[4,0],[1,3],[3,0]]
    -Output: [true,false,true,false]
    -
    -

     

    Constraints:

      -
    • 2 <= n <= 100
    • -
    • 0 <= prerequisite.length <= (n * (n - 1) / 2)
    • -
    • 0 <= prerequisite[i][0], prerequisite[i][1] < n
    • -
    • prerequisite[i][0] != prerequisite[i][1]
    • +
    • 2 <= numCourses <= 100
    • +
    • 0 <= prerequisite.length <= (numCourses * (numCourses - 1) / 2)
    • +
    • 0 <= ai, bi < n
    • +
    • ai != bi
    • +
    • All the pairs [ai, bi] are unique.
    • The prerequisites graph has no cycles.
    • -
    • The prerequisites graph has no repeated edges.
    • -
    • 1 <= queries.length <= 10^4
    • -
    • queries[i][0] != queries[i][1]
    • +
    • 1 <= queries.length <= 104
    • +
    • 0 <= ui, vi < n
    • +
    • ui != vi
    ### Related Topics diff --git a/problems/critical-connections-in-a-network/README.md b/problems/critical-connections-in-a-network/README.md index ec7b89a84..6d7c2ecb1 100644 --- a/problems/critical-connections-in-a-network/README.md +++ b/problems/critical-connections-in-a-network/README.md @@ -11,9 +11,9 @@ ## [1192. Critical Connections in a Network (Hard)](https://leetcode.com/problems/critical-connections-in-a-network "查找集群内的「关键连接」") -

    There are n servers numbered from 0 to n-1 connected by undirected server-to-server connections forming a network where connections[i] = [a, b] represents a connection between servers a and b. Any server can reach any other server directly or indirectly through the network.

    +

    There are n servers numbered from 0 to n - 1 connected by undirected server-to-server connections forming a network where connections[i] = [ai, bi] represents a connection between servers ai and bi. Any server can reach other servers directly or indirectly through the network.

    -

    A critical connection is a connection that, if removed, will make some server unable to reach some other server.

    +

    A critical connection is a connection that, if removed, will make some servers unable to reach some other server.

    Return all critical connections in the network in any order.

    @@ -32,9 +32,10 @@

    Constraints:

      -
    • 1 <= n <= 10^5
    • -
    • n-1 <= connections.length <= 10^5
    • -
    • connections[i][0] != connections[i][1]
    • +
    • 2 <= n <= 105
    • +
    • n - 1 <= connections.length <= 105
    • +
    • 0 <= ai, bi <= n - 1
    • +
    • ai != bi
    • There are no repeated connections.
    diff --git a/problems/custom-sort-string/README.md b/problems/custom-sort-string/README.md index 45c2502b9..75d92e963 100644 --- a/problems/custom-sort-string/README.md +++ b/problems/custom-sort-string/README.md @@ -11,21 +11,21 @@ ## [791. Custom Sort String (Medium)](https://leetcode.com/problems/custom-sort-string "自定义字符串排序") -

    S and T are strings composed of lowercase letters. In S, no letter occurs more than once.

    +

    order and str are strings composed of lowercase letters. In order, no letter occurs more than once.

    -

    S was sorted in some custom order previously. We want to permute the characters of T so that they match the order that S was sorted. More specifically, if x occurs before y in S, then x should occur before y in the returned string.

    +

    order was sorted in some custom order previously. We want to permute the characters of str so that they match the order that order was sorted. More specifically, if x occurs before y in order, then x should occur before y in the returned string.

    -

    Return any permutation of T (as a string) that satisfies this property.

    +

    Return any permutation of str (as a string) that satisfies this property.

    -Example :
    +Example:
     Input: 
    -S = "cba"
    -T = "abcd"
    +order = "cba"
    +str = "abcd"
     Output: "cbad"
     Explanation: 
    -"a", "b", "c" appear in S, so the order of "a", "b", "c" should be "c", "b", and "a". 
    -Since "d" does not appear in S, it can be at any position in T. "dcba", "cdba", "cbda" are also valid outputs.
    +"a", "b", "c" appear in order, so the order of "a", "b", "c" should be "c", "b", and "a". 
    +Since "d" does not appear in order, it can be at any position in the returned string. "dcba", "cdba", "cbda" are also valid outputs.
     

     

    @@ -33,9 +33,9 @@ Since "d" does not appear in S, it can be at any position in T. "

    Note:

      -
    • S has length at most 26, and no character is repeated in S.
    • -
    • T has length at most 200.
    • -
    • S and T consist of lowercase letters only.
    • +
    • order has length at most 26, and no character is repeated in order.
    • +
    • str has length at most 200.
    • +
    • order and str consist of lowercase letters only.
    ### Related Topics diff --git a/problems/daily-temperatures/README.md b/problems/daily-temperatures/README.md index 2b44915b5..43f4abac1 100644 --- a/problems/daily-temperatures/README.md +++ b/problems/daily-temperatures/README.md @@ -11,16 +11,11 @@ ## [739. Daily Temperatures (Medium)](https://leetcode.com/problems/daily-temperatures "每日温度") -

    -Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead. -

    -For example, given the list of temperatures T = [73, 74, 75, 71, 69, 72, 76, 73], your output should be [1, 1, 4, 2, 1, 1, 0, 0]. -

    - -

    Note: -The length of temperatures will be in the range [1, 30000]. -Each temperature will be an integer in the range [30, 100]. -

    +

    Given a list of daily temperatures temperatures, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead.

    + +

    For example, given the list of temperatures temperatures = [73, 74, 75, 71, 69, 72, 76, 73], your output should be [1, 1, 4, 2, 1, 1, 0, 0].

    + +

    Note: The length of temperatures will be in the range [1, 30000]. Each temperature will be an integer in the range [30, 100].

    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/decoded-string-at-index/README.md b/problems/decoded-string-at-index/README.md index 6098ee17f..de0ff896c 100644 --- a/problems/decoded-string-at-index/README.md +++ b/problems/decoded-string-at-index/README.md @@ -11,14 +11,14 @@ ## [880. Decoded String at Index (Medium)](https://leetcode.com/problems/decoded-string-at-index "索引处的解码字符串") -

    An encoded string S is given.  To find and write the decoded string to a tape, the encoded string is read one character at a time and the following steps are taken:

    +

    An encoded string s is given.  To find and write the decoded string to a tape, the encoded string is read one character at a time and the following steps are taken:

    • If the character read is a letter, that letter is written onto the tape.
    • If the character read is a digit (say d), the entire current tape is repeatedly written d-1 more times in total.
    -

    Now for some encoded string S, and an index K, find and return the K-th letter (1 indexed) in the decoded string.

    +

    Now for some encoded string s, and an index k, find and return the k-th letter (1 indexed) in the decoded string.

     

    @@ -26,7 +26,7 @@

    Example 1:

    -Input: S = "leet2code3", K = 10
    +Input: s = "leet2code3", k = 10
     Output: "o"
     Explanation: 
     The decoded string is "leetleetcodeleetleetcodeleetleetcode".
    @@ -37,7 +37,7 @@ The 10th letter in the string is "o".
     

    Example 2:

    -Input: S = "ha22", K = 5
    +Input: s = "ha22", k = 5
     Output: "h"
     Explanation: 
     The decoded string is "hahahaha".  The 5th letter is "h".
    @@ -47,7 +47,7 @@ The decoded string is "hahahaha".  The 5th letter is "h".
     

    Example 3:

    -Input: S = "a2345678999999999999999", K = 1
    +Input: s = "a2345678999999999999999", k = 1
     Output: "a"
     Explanation: 
     The decoded string is "a" repeated 8301530446056247680 times.  The 1st letter is "a".
    @@ -60,12 +60,12 @@ The decoded string is "a" repeated 8301530446056247680 times.  The 1st
     

    Constraints:

      -
    • 2 <= S.length <= 100
    • -
    • S will only contain lowercase letters and digits 2 through 9.
    • -
    • S starts with a letter.
    • -
    • 1 <= K <= 10^9
    • -
    • It's guaranteed that K is less than or equal to the length of the decoded string.
    • -
    • The decoded string is guaranteed to have less than 2^63 letters.
    • +
    • 2 <= s.length <= 100
    • +
    • s will only contain lowercase letters and digits 2 through 9.
    • +
    • s starts with a letter.
    • +
    • 1 <= k <= 109
    • +
    • It's guaranteed that k is less than or equal to the length of the decoded string.
    • +
    • The decoded string is guaranteed to have less than 263 letters.
    ### Related Topics diff --git a/problems/delete-and-earn/README.md b/problems/delete-and-earn/README.md index ef46a1e37..6683d8300 100644 --- a/problems/delete-and-earn/README.md +++ b/problems/delete-and-earn/README.md @@ -9,7 +9,7 @@                  [Next >](../cherry-pickup "Cherry Pickup") -## [740. Delete and Earn (Medium)](https://leetcode.com/problems/delete-and-earn "删除与获得点数") +## [740. Delete and Earn (Medium)](https://leetcode.com/problems/delete-and-earn "删除并获得点数")

    Given an array nums of integers, you can perform operations on the array.

    diff --git a/problems/design-circular-queue/README.md b/problems/design-circular-queue/README.md index fd4ce3cc6..00d2500b7 100644 --- a/problems/design-circular-queue/README.md +++ b/problems/design-circular-queue/README.md @@ -27,6 +27,8 @@
  • boolean isFull() Checks whether the circular queue is full or not.
  • +

    You must solve the problem without using the built-in queue data structure in your programming language. 

    +

     

    Example 1:

    @@ -59,9 +61,6 @@ myCircularQueue.Rear(); // return 4
  • At most 3000 calls will be made to enQueue, deQueueFrontRearisEmpty, and isFull.
  • -

     

    -Follow up: Could you solve the problem without using the built-in queue?  - ### Related Topics [[Design](../../tag/design/README.md)] [[Queue](../../tag/queue/README.md)] diff --git a/problems/distinct-numbers-in-each-subarray/README.md b/problems/distinct-numbers-in-each-subarray/README.md new file mode 100644 index 000000000..6b3c88185 --- /dev/null +++ b/problems/distinct-numbers-in-each-subarray/README.md @@ -0,0 +1,35 @@ + + + + + + + +[< Previous](../minimum-interval-to-include-each-query "Minimum Interval to Include Each Query") +                 +[Next >](../convert-date-format "Convert Date Format") + +## [1852. Distinct Numbers in Each Subarray (Medium)](https://leetcode.com/problems/distinct-numbers-in-each-subarray "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Line Sweep](../../tag/line-sweep/README.md)] + +### Hints +
    +Hint 1 +Keep a frequency map of the elements in each window. +
    + +
    +Hint 2 +When the frequency of the element is 0, remove it from the map. +
    + +
    +Hint 3 +The answer to each window is the size of the map. +
    diff --git a/problems/distinct-subsequences-ii/README.md b/problems/distinct-subsequences-ii/README.md index 5ae9d2f70..d04dc661a 100644 --- a/problems/distinct-subsequences-ii/README.md +++ b/problems/distinct-subsequences-ii/README.md @@ -11,16 +11,16 @@ ## [940. Distinct Subsequences II (Hard)](https://leetcode.com/problems/distinct-subsequences-ii "不同的子序列 II") -

    Given a string S, count the number of distinct, non-empty subsequences of S .

    +

    Given a string s, count the number of distinct, non-empty subsequences of s .

    -

    Since the result may be large, return the answer modulo 10^9 + 7.

    +

    Since the result may be large, return the answer modulo 109 + 7.

     

    Example 1:

    -Input: "abc"
    +Input: s = "abc"
     Output: 7
     Explanation: The 7 distinct subsequences are "a", "b", "c", "ab", "ac", "bc", and "abc".
     
    @@ -29,7 +29,7 @@

    Example 2:

    -Input: "aba"
    +Input: s = "aba"
     Output: 6
     Explanation: The 6 distinct subsequences are "a", "b", "ab", "ba", "aa" and "aba".
     
    @@ -38,7 +38,7 @@

    Example 3:

    -Input: "aaa"
    +Input: s = "aaa"
     Output: 3
     Explanation: The 3 distinct subsequences are "a", "aa" and "aaa".
     
    @@ -52,8 +52,8 @@

    Note:

      -
    1. S contains only lowercase letters.
    2. -
    3. 1 <= S.length <= 2000
    4. +
    5. s contains only lowercase letters.
    6. +
    7. 1 <= s.length <= 2000
    diff --git a/problems/domino-and-tromino-tiling/README.md b/problems/domino-and-tromino-tiling/README.md index b469cb085..d2972acf4 100644 --- a/problems/domino-and-tromino-tiling/README.md +++ b/problems/domino-and-tromino-tiling/README.md @@ -20,14 +20,13 @@ XX <- "L" tromino X
    -

    Given N, how many ways are there to tile a 2 x N board? Return your answer modulo 10^9 + 7.

    +

    Given n, how many ways are there to tile a 2 x n board? Return your answer modulo 109 + 7.

    (In a tiling, every square must be covered by a tile. Two tilings are different if and only if there are two 4-directionally adjacent cells on the board such that exactly one of the tilings has both squares occupied by a tile.)

    -
     Example:
    -Input: 3
    +Input: n = 3
     Output: 5
     Explanation: 
     The five different ways are listed below, different letters indicates different tiles:
    @@ -37,7 +36,7 @@ XYZ YYZ XZZ XYY XXY

    Note:

      -
    • N  will be in range [1, 1000].
    • +
    • n will be in range [1, 1000].

     

    diff --git a/problems/dota2-senate/README.md b/problems/dota2-senate/README.md index f0bf806cb..3531ea942 100644 --- a/problems/dota2-senate/README.md +++ b/problems/dota2-senate/README.md @@ -11,58 +11,53 @@ ## [649. Dota2 Senate (Medium)](https://leetcode.com/problems/dota2-senate "Dota2 参议院") -

    In the world of Dota2, there are two parties: the Radiant and the Dire.

    +

    In the world of Dota2, there are two parties: the Radiant and the Dire.

    -

    The Dota2 senate consists of senators coming from two parties. Now the senate wants to make a decision about a change in the Dota2 game. The voting for this change is a round-based procedure. In each round, each senator can exercise one of the two rights:

    +

    The Dota2 senate consists of senators coming from two parties. Now the Senate wants to decide on a change in the Dota2 game. The voting for this change is a round-based procedure. In each round, each senator can exercise one of the two rights:

    -
      -
    1. Ban one senator's right:
      - A senator can make another senator lose all his rights in this and all the following rounds.
    2. -
    3. Announce the victory:
      - If this senator found the senators who still have rights to vote are all from the same party, he can announce the victory and make the decision about the change in the game.
    4. -
    +
      +
    • Ban one senator's right: A senator can make another senator lose all his rights in this and all the following rounds.
    • +
    • Announce the victory: If this senator found the senators who still have rights to vote are all from the same party, he can announce the victory and decide on the change in the game.
    • +
    -

     

    - -

    Given a string representing each senator's party belonging. The character 'R' and 'D' represent the Radiant party and the Dire party respectively. Then if there are n senators, the size of the given string will be n.

    +

    Given a string senate representing each senator's party belonging. The character 'R' and 'D' represent the Radiant party and the Dire party. Then if there are n senators, the size of the given string will be n.

    The round-based procedure starts from the first senator to the last senator in the given order. This procedure will last until the end of voting. All the senators who have lost their rights will be skipped during the procedure.

    -

    Suppose every senator is smart enough and will play the best strategy for his own party, you need to predict which party will finally announce the victory and make the change in the Dota2 game. The output should be Radiant or Dire.

    +

    Suppose every senator is smart enough and will play the best strategy for his own party. Predict which party will finally announce the victory and change the Dota2 game. The output should be "Radiant" or "Dire".

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input: "RD"
    -Output: "Radiant"
    -Explanation: The first senator comes from Radiant and he can just ban the next senator's right in the round 1. 
    -And the second senator can't exercise any rights any more since his right has been banned. 
    -And in the round 2, the first senator can just announce the victory since he is the only guy in the senate who can vote.
    +Input: senate = "RD"
    +Output: "Radiant"
    +Explanation: 
    +The first senator comes from Radiant and he can just ban the next senator's right in round 1. 
    +And the second senator can't exercise any rights anymore since his right has been banned. 
    +And in round 2, the first senator can just announce the victory since he is the only guy in the senate who can vote.
     
    -

     

    - -

    Example 2:

    +

    Example 2:

    -Input: "RDD"
    -Output: "Dire"
    -Explanation: 
    -The first senator comes from Radiant and he can just ban the next senator's right in the round 1. 
    +Input: senate = "RDD"
    +Output: "Dire"
    +Explanation: 
    +The first senator comes from Radiant and he can just ban the next senator's right in round 1. 
     And the second senator can't exercise any rights anymore since his right has been banned. 
    -And the third senator comes from Dire and he can ban the first senator's right in the round 1. 
    -And in the round 2, the third senator can just announce the victory since he is the only guy in the senate who can vote.
    +And the third senator comes from Dire and he can ban the first senator's right in round 1. 
    +And in round 2, the third senator can just announce the victory since he is the only guy in the senate who can vote.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. The length of the given string will in the range [1, 10,000].
    2. -
    - -

     

    +
      +
    • n == senate.length
    • +
    • 1 <= n <= 104
    • +
    • senate[i] is either 'R' or 'D'.
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/encode-and-decode-tinyurl/README.md b/problems/encode-and-decode-tinyurl/README.md index 209c602d6..c8a3505e3 100644 --- a/problems/encode-and-decode-tinyurl/README.md +++ b/problems/encode-and-decode-tinyurl/README.md @@ -13,9 +13,38 @@
    Note: This is a companion problem to the System Design problem: Design TinyURL.
    -

    TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-tinyurl and it returns a short URL such as http://tinyurl.com/4e9iAk.

    +

    TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-tinyurl and it returns a short URL such as http://tinyurl.com/4e9iAk. Design a class to encode a URL and decode a tiny URL.

    -

    Design the encode and decode methods for the TinyURL service. There is no restriction on how your encode/decode algorithm should work. You just need to ensure that a URL can be encoded to a tiny URL and the tiny URL can be decoded to the original URL.

    +

    There is no restriction on how your encode/decode algorithm should work. You just need to ensure that a URL can be encoded to a tiny URL and the tiny URL can be decoded to the original URL.

    + +

    Implement the Solution class:

    + +
      +
    • Solution() Initializes the object of the system.
    • +
    • String encode(String longUrl) Returns a tiny URL for the given longUrl.
    • +
    • String decode(String shortUrl) Returns the original long URL for the given shortUrl. It is guaranteed that the given shortUrl was encoded by the same object.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: url = "https://leetcode.com/problems/design-tinyurl"
    +Output: "https://leetcode.com/problems/design-tinyurl"
    +
    +Explanation:
    +Solution obj = new Solution();
    +string tiny = obj.encode(url); // returns the encoded tiny url.
    +string ans = obj.decode(tiny); // returns the original url after deconding it.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= url.length <= 104
    • +
    • url is guranteed to be a valid URL.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/exam-room/README.md b/problems/exam-room/README.md index 320a72046..38f4a4145 100644 --- a/problems/exam-room/README.md +++ b/problems/exam-room/README.md @@ -11,11 +11,11 @@ ## [855. Exam Room (Medium)](https://leetcode.com/problems/exam-room "考场就座") -

    In an exam room, there are N seats in a single row, numbered 0, 1, 2, ..., N-1.

    +

    In an exam room, there are n seats in a single row, numbered 0, 1, 2, ..., n-1.

    When a student enters the room, they must sit in the seat that maximizes the distance to the closest person.  If there are multiple such seats, they sit in the seat with the lowest number.  (Also, if no one is in the room, then the student sits at seat number 0.)

    -

    Return a class ExamRoom(int N) that exposes two functions: ExamRoom.seat() returning an int representing what seat the student sat in, and ExamRoom.leave(int p) representing that the student in seat number p now leaves the room.  It is guaranteed that any calls to ExamRoom.leave(p) have a student sitting in seat p.

    +

    Return a class ExamRoom(int n) that exposes two functions: ExamRoom.seat() returning an int representing what seat the student sat in, and ExamRoom.leave(int p) representing that the student in seat number p now leaves the room.  It is guaranteed that any calls to ExamRoom.leave(p) have a student sitting in seat p.

     

    @@ -34,13 +34,13 @@ leave(4) -> null seat() -> 5, the student sits at the last seat number 5.
    -

    ​​​​​​​

    +

     

    Note:

      -
    1. 1 <= N <= 10^9
    2. -
    3. ExamRoom.seat() and ExamRoom.leave() will be called at most 10^4 times across all test cases.
    4. +
    5. 1 <= n <= 109
    6. +
    7. ExamRoom.seat() and ExamRoom.leave() will be called at most 104 times across all test cases.
    8. Calls to ExamRoom.leave(p) are guaranteed to have a student currently sitting in seat number p.
    diff --git a/problems/expressive-words/README.md b/problems/expressive-words/README.md index 1a7716570..969a7cdeb 100644 --- a/problems/expressive-words/README.md +++ b/problems/expressive-words/README.md @@ -13,9 +13,9 @@

    Sometimes people repeat letters to represent extra feeling, such as "hello" -> "heeellooo", "hi" -> "hiiii".  In these strings like "heeellooo", we have groups of adjacent letters that are all the same:  "h", "eee", "ll", "ooo".

    -

    For some given string S, a query word is stretchy if it can be made to be equal to S by any number of applications of the following extension operation: choose a group consisting of characters c, and add some number of characters c to the group so that the size of the group is 3 or more.

    +

    For some given string s, a query word is stretchy if it can be made to be equal to s by any number of applications of the following extension operation: choose a group consisting of characters c, and add some number of characters c to the group so that the size of the group is 3 or more.

    -

    For example, starting with "hello", we could do an extension on the group "o" to get "hellooo", but we cannot get "helloo" since the group "oo" has size less than 3.  Also, we could do another extension like "ll" -> "lllll" to get "helllllooo".  If S = "helllllooo", then the query word "hello" would be stretchy because of these two extension operations: query = "hello" -> "hellooo" -> "helllllooo" = S.

    +

    For example, starting with "hello", we could do an extension on the group "o" to get "hellooo", but we cannot get "helloo" since the group "oo" has size less than 3.  Also, we could do another extension like "ll" -> "lllll" to get "helllllooo".  If s = "helllllooo", then the query word "hello" would be stretchy because of these two extension operations: query = "hello" -> "hellooo" -> "helllllooo" = s.

    Given a list of query words, return the number of words that are stretchy. 

    @@ -24,7 +24,7 @@
     Example:
     Input: 
    -S = "heeellooo"
    +s = "heeellooo"
     words = ["hello", "hi", "helo"]
     Output: 1
     Explanation: 
    @@ -36,10 +36,10 @@ We can't extend "helo" to get "heeellooo" because the gr
     

    Constraints:

      -
    • 0 <= len(S) <= 100.
    • +
    • 0 <= len(s) <= 100.
    • 0 <= len(words) <= 100.
    • 0 <= len(words[i]) <= 100.
    • -
    • S and all words in words consist only of lowercase letters
    • +
    • s and all words in words consist only of lowercase letters
    ### Related Topics diff --git a/problems/fair-candy-swap/README.md b/problems/fair-candy-swap/README.md index e78ae571e..22b065080 100644 --- a/problems/fair-candy-swap/README.md +++ b/problems/fair-candy-swap/README.md @@ -11,7 +11,7 @@ ## [888. Fair Candy Swap (Easy)](https://leetcode.com/problems/fair-candy-swap "公平的糖果棒交换") -

    Alice and Bob have candy bars of different sizes: A[i] is the size of the i-th bar of candy that Alice has, and B[j] is the size of the j-th bar of candy that Bob has.

    +

    Alice and Bob have candy bars of different sizes: aliceSizes[i] is the size of the i-th bar of candy that Alice has, and bobSizes[j] is the size of the j-th bar of candy that Bob has.

    Since they are friends, they would like to exchange one candy bar each so that after the exchange, they both have the same total amount of candy.  (The total amount of candy a person has is the sum of the sizes of candy bars they have.)

    @@ -25,7 +25,7 @@

    Example 1:

    -Input: A = [1,1], B = [2,2]
    +Input: aliceSizes = [1,1], bobSizes = [2,2]
     Output: [1,2]
     
    @@ -33,7 +33,7 @@

    Example 2:

    -Input: A = [1,2], B = [2,3]
    +Input: aliceSizes = [1,2], bobSizes = [2,3]
     Output: [1,2]
     
    @@ -41,7 +41,7 @@

    Example 3:

    -Input: A = [2], B = [1,3]
    +Input: aliceSizes = [2], bobSizes = [1,3]
     Output: [2,3]
     
    @@ -49,7 +49,7 @@

    Example 4:

    -Input: A = [1,2,5], B = [2,4]
    +Input: aliceSizes = [1,2,5], bobSizes = [2,4]
     Output: [5,4]
     
    @@ -58,10 +58,10 @@

    Note:

      -
    • 1 <= A.length <= 10000
    • -
    • 1 <= B.length <= 10000
    • -
    • 1 <= A[i] <= 100000
    • -
    • 1 <= B[i] <= 100000
    • +
    • 1 <= aliceSizes.length <= 10000
    • +
    • 1 <= bobSizes.length <= 10000
    • +
    • 1 <= aliceSizes[i] <= 100000
    • +
    • 1 <= bobSizes[i] <= 100000
    • It is guaranteed that Alice and Bob have different total amounts of candy.
    • It is guaranteed there exists an answer.
    diff --git a/problems/falling-squares/README.md b/problems/falling-squares/README.md index d9209d82b..3b49a50ed 100644 --- a/problems/falling-squares/README.md +++ b/problems/falling-squares/README.md @@ -11,54 +11,50 @@ ## [699. Falling Squares (Hard)](https://leetcode.com/problems/falling-squares "掉落的方块") -

    On an infinite number line (x-axis), we drop given squares in the order they are given.

    +

    There are several squares being dropped onto the X-axis of a 2D plane.

    -

    The i-th square dropped (positions[i] = (left, side_length)) is a square with the left-most point being positions[i][0] and sidelength positions[i][1].

    +

    You are given a 2D integer array positions where positions[i] = [lefti, sideLengthi] represents the ith square with a side length of sideLengthi that is dropped with its left edge aligned with X-coordinate lefti.

    -

    The square is dropped with the bottom edge parallel to the number line, and from a higher height than all currently landed squares. We wait for each square to stick before dropping the next.

    +

    Each square is dropped one at a time from a height above any landed squares. It then falls downward (negative Y direction) until it either lands on the top side of another square or on the X-axis. A square brushing the left/right side of another square does not count as landing on it. Once it lands, it freezes in place and cannot be moved.

    -

    The squares are infinitely sticky on their bottom edge, and will remain fixed to any positive length surface they touch (either the number line or another square). Squares dropped adjacent to each other will not stick together prematurely.

    -  +

    After each square is dropped, you must record the height of the current tallest stack of squares.

    -

    Return a list ans of heights. Each height ans[i] represents the current highest height of any square we have dropped, after dropping squares represented by positions[0], positions[1], ..., positions[i].

    - -

    Example 1:

    +

    Return an integer array ans where ans[i] represents the height described above after dropping the ith square.

    +

     

    +

    Example 1:

    +
    -Input: [[1, 2], [2, 3], [6, 1]]
    -Output: [2, 5, 5]
    -Explanation:
    +Input: positions = [[1,2],[2,3],[6,1]]
    +Output: [2,5,5]
    +Explanation:
    +After the first drop, the tallest stack is square 1 with a height of 2.
    +After the second drop, the tallest stack is squares 1 and 2 with a height of 5.
    +After the third drop, the tallest stack is still squares 1 and 2 with a height of 5.
    +Thus, we return an answer of [2, 5, 5].
     
    -

    After the first drop of positions[0] = [1, 2]: _aa _aa ------- The maximum height of any square is 2.

    - -

    After the second drop of positions[1] = [2, 3]: __aaa __aaa __aaa _aa__ _aa__ -------------- The maximum height of any square is 5. The larger square stays on top of the smaller square despite where its center of gravity is, because squares are infinitely sticky on their bottom edge.

    - -

    After the third drop of positions[1] = [6, 1]: __aaa __aaa __aaa _aa _aa___a -------------- The maximum height of any square is still 5. Thus, we return an answer of [2, 5, 5].

    - -

     

    -  - -

    Example 2:

    +

    Example 2:

    -Input: [[100, 100], [200, 100]]
    -Output: [100, 100]
    -Explanation: Adjacent squares don't get stuck prematurely - only their bottom edge can stick to surfaces.
    +Input: positions = [[100,100],[200,100]]
    +Output: [100,100]
    +Explanation:
    +After the first drop, the tallest stack is square 1 with a height of 100.
    +After the second drop, the tallest stack is either square 1 or square 2, both with heights of 100.
    +Thus, we return an answer of [100, 100].
    +Note that square 2 only brushes the right side of square 1, which does not count as landing on it.
     

     

    - -

    Note:

    +

    Constraints:

      -
    • 1 <= positions.length <= 1000.
    • -
    • 1 <= positions[i][0] <= 10^8.
    • -
    • 1 <= positions[i][1] <= 10^6.
    • +
    • 1 <= positions.length <= 1000
    • +
    • 1 <= lefti <= 108
    • +
    • 1 <= sideLengthi <= 106
    -

     

    - ### Related Topics [[Segment Tree](../../tag/segment-tree/README.md)] [[Ordered Map](../../tag/ordered-map/README.md)] diff --git a/problems/find-all-duplicates-in-an-array/README.md b/problems/find-all-duplicates-in-an-array/README.md index 43b541d9d..fbeb421d2 100644 --- a/problems/find-all-duplicates-in-an-array/README.md +++ b/problems/find-all-duplicates-in-an-array/README.md @@ -13,6 +13,8 @@

    Given an integer array nums of length n where all the integers of nums are in the range [1, n] and each integer appears once or twice, return an array of all the integers that appears twice.

    +

    You must write an algorithm that runs in O(n) time and uses only constant extra space.

    +

     

    Example 1:

    Input: nums = [4,3,2,7,8,2,3,1]
    @@ -34,9 +36,6 @@
     	
  • Each element in nums appears once or twice.
  • -

     

    -

    Follow up: Could you do it without extra space and in O(n) runtime?

    - ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/find-and-replace-in-string/README.md b/problems/find-and-replace-in-string/README.md index d2640535e..d6551b0b7 100644 --- a/problems/find-and-replace-in-string/README.md +++ b/problems/find-and-replace-in-string/README.md @@ -11,45 +11,45 @@ ## [833. Find And Replace in String (Medium)](https://leetcode.com/problems/find-and-replace-in-string "字符串中的查找与替换") -

    To some string S, we will perform some replacement operations that replace groups of letters with new ones (not necessarily the same size).

    +

    To some string s, we will perform some replacement operations that replace groups of letters with new ones (not necessarily the same size).

    Each replacement operation has 3 parameters: a starting index i, a source word x and a target word y.  The rule is that if x starts at position i in the original string S, then we will replace that occurrence of x with y.  If not, we do nothing.

    -

    For example, if we have S = "abcd" and we have some replacement operation i = 2, x = "cd", y = "ffff", then because "cd" starts at position 2 in the original string S, we will replace it with "ffff".

    +

    For example, if we have s = "abcd" and we have some replacement operation i = 2, x = "cd", y = "ffff", then because "cd" starts at position 2 in the original string s, we will replace it with "ffff".

    -

    Using another example on S = "abcd", if we have both the replacement operation i = 0, x = "ab", y = "eee", as well as another replacement operation i = 2, x = "ec", y = "ffff", this second operation does nothing because in the original string S[2] = 'c', which doesn't match x[0] = 'e'.

    +

    Using another example on s = "abcd", if we have both the replacement operation i = 0, x = "ab", y = "eee", as well as another replacement operation i = 2, x = "ec", y = "ffff", this second operation does nothing because in the original string s[2] = 'c', which doesn't match x[0] = 'e'.

    -

    All these operations occur simultaneously.  It's guaranteed that there won't be any overlap in replacement: for example, S = "abc", indexes = [0, 1], sources = ["ab","bc"] is not a valid test case.

    +

    All these operations occur simultaneously.  It's guaranteed that there won't be any overlap in replacement: for example, s = "abc", indexes = [0, 1], sources = ["ab","bc"] is not a valid test case.

     

    Example 1:

    -Input: S = "abcd", indexes = [0, 2], sources = ["a", "cd"], targets = ["eee", "ffff"]
    +Input: s = "abcd", indexes = [0, 2], sources = ["a", "cd"], targets = ["eee", "ffff"]
     Output: "eeebffff"
     Explanation:
    -"a" starts at index 0 in S, so it's replaced by "eee".
    -"cd" starts at index 2 in S, so it's replaced by "ffff".
    +"a" starts at index 0 in s, so it's replaced by "eee".
    +"cd" starts at index 2 in s, so it's replaced by "ffff".
     

    Example 2:

    -Input: S = "abcd", indexes = [0, 2], sources = ["ab","ec"], targets = ["eee","ffff"]
    +Input: s = "abcd", indexes = [0, 2], sources = ["ab","ec"], targets = ["eee","ffff"]
     Output: "eeecd"
     Explanation:
    -"ab" starts at index 0 in S, so it's replaced by "eee".
    -"ec" doesn't starts at index 2 in the original S, so we do nothing.
    +"ab" starts at index 0 in s, so it's replaced by "eee".
    +"ec" doesn't starts at index 2 in the original s, so we do nothing.
     

     

    Constraints:

      -
    • 0 <= S.length <= 1000
    • -
    • S consists of only lowercase English letters.
    • +
    • 0 <= s.length <= 1000
    • +
    • s consists of only lowercase English letters.
    • 0 <= indexes.length <= 100
    • -
    • 0 <= indexes[i] < S.length
    • +
    • 0 <= indexes[i] < s.length
    • sources.length == indexes.length
    • targets.length == indexes.length
    • 1 <= sources[i].length, targets[i].length <= 50
    • diff --git a/problems/find-first-and-last-position-of-element-in-sorted-array/README.md b/problems/find-first-and-last-position-of-element-in-sorted-array/README.md index 1cb56b127..fd35bab24 100644 --- a/problems/find-first-and-last-position-of-element-in-sorted-array/README.md +++ b/problems/find-first-and-last-position-of-element-in-sorted-array/README.md @@ -15,7 +15,7 @@

      If target is not found in the array, return [-1, -1].

      -

      Follow up: Could you write an algorithm with O(log n) runtime complexity?

      +

      You must write an algorithm with O(log n) runtime complexity.

       

      Example 1:

      diff --git a/problems/find-minimum-in-rotated-sorted-array/README.md b/problems/find-minimum-in-rotated-sorted-array/README.md index aade6faf9..b0b96b8c4 100644 --- a/problems/find-minimum-in-rotated-sorted-array/README.md +++ b/problems/find-minimum-in-rotated-sorted-array/README.md @@ -22,6 +22,8 @@

      Given the sorted rotated array nums of unique elements, return the minimum element of this array.

      +

      You must write an algorithm that runs in O(log n) time.

      +

       

      Example 1:

      diff --git a/problems/find-peak-element/README.md b/problems/find-peak-element/README.md index a2dc1edef..d3fb50e52 100644 --- a/problems/find-peak-element/README.md +++ b/problems/find-peak-element/README.md @@ -17,6 +17,8 @@

      You may imagine that nums[-1] = nums[n] = -∞.

      +

      You must write an algorithm that runs in O(log n) time.

      +

       

      Example 1:

      @@ -41,9 +43,6 @@
    • nums[i] != nums[i + 1] for all valid i.
    -

     

    -Follow up: Could you implement a solution with logarithmic complexity? - ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/find-the-duplicate-number/README.md b/problems/find-the-duplicate-number/README.md index ebf2a8044..2d04bd989 100644 --- a/problems/find-the-duplicate-number/README.md +++ b/problems/find-the-duplicate-number/README.md @@ -33,7 +33,7 @@

    Constraints:

      -
    • 2 <= n <= 3 * 104
    • +
    • 2 <= n <= 105
    • nums.length == n + 1
    • 1 <= nums[i] <= n
    • All the integers in nums appear only once except for precisely one integer which appears two or more times.
    • diff --git a/problems/find-the-town-judge/README.md b/problems/find-the-town-judge/README.md index a49a80b9f..d45495418 100644 --- a/problems/find-the-town-judge/README.md +++ b/problems/find-the-town-judge/README.md @@ -11,7 +11,7 @@ ## [997. Find the Town Judge (Easy)](https://leetcode.com/problems/find-the-town-judge "找到小镇的法官") -

      In a town, there are N people labelled from 1 to N.  There is a rumor that one of these people is secretly the town judge.

      +

      In a town, there are n people labelled from 1 to n.  There is a rumor that one of these people is secretly the town judge.

      If the town judge exists, then:

      @@ -27,31 +27,50 @@

       

      Example 1:

      -
      Input: N = 2, trust = [[1,2]]
      +
      +
      +Input: n = 2, trust = [[1,2]]
       Output: 2
      -

      Example 2:

      -
      Input: N = 3, trust = [[1,3],[2,3]]
      +
      + +

      Example 2:

      + +
      +Input: n = 3, trust = [[1,3],[2,3]]
       Output: 3
      -

      Example 3:

      -
      Input: N = 3, trust = [[1,3],[2,3],[3,1]]
      +
      + +

      Example 3:

      + +
      +Input: n = 3, trust = [[1,3],[2,3],[3,1]]
       Output: -1
      -

      Example 4:

      -
      Input: N = 3, trust = [[1,2],[2,3]]
      +
      + +

      Example 4:

      + +
      +Input: n = 3, trust = [[1,2],[2,3]]
       Output: -1
      -

      Example 5:

      -
      Input: N = 4, trust = [[1,3],[1,4],[2,3],[2,4],[4,3]]
      +
      + +

      Example 5:

      + +
      +Input: n = 4, trust = [[1,3],[1,4],[2,3],[2,4],[4,3]]
       Output: 3
       
      +

       

      Constraints:

        -
      • 1 <= N <= 1000
      • -
      • 0 <= trust.length <= 10^4
      • +
      • 1 <= n <= 1000
      • +
      • 0 <= trust.length <= 104
      • trust[i].length == 2
      • trust[i] are all different
      • trust[i][0] != trust[i][1]
      • -
      • 1 <= trust[i][0], trust[i][1] <= N
      • +
      • 1 <= trust[i][0], trust[i][1] <= n
      ### Related Topics diff --git a/problems/first-missing-positive/README.md b/problems/first-missing-positive/README.md index 9c8ad497b..070243466 100644 --- a/problems/first-missing-positive/README.md +++ b/problems/first-missing-positive/README.md @@ -13,6 +13,8 @@

      Given an unsorted integer array nums, find the smallest missing positive integer.

      +

      You must implement an algorithm that runs in O(n) time and uses constant extra space.

      +

       

      Example 1:

      Input: nums = [1,2,0]
      @@ -28,13 +30,10 @@
       

      Constraints:

        -
      • 1 <= nums.length <= 300
      • +
      • 1 <= nums.length <= 5 * 105
      • -231 <= nums[i] <= 231 - 1
      -

       

      -

      Follow up: Could you implement an algorithm that runs in O(n) time and uses constant extra space?

      - ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/flip-string-to-monotone-increasing/README.md b/problems/flip-string-to-monotone-increasing/README.md index 23cf18547..cbd4407c6 100644 --- a/problems/flip-string-to-monotone-increasing/README.md +++ b/problems/flip-string-to-monotone-increasing/README.md @@ -13,9 +13,9 @@

      A string of '0's and '1's is monotone increasing if it consists of some number of '0's (possibly 0), followed by some number of '1's (also possibly 0.)

      -

      We are given a string S of '0's and '1's, and we may flip any '0' to a '1' or a '1' to a '0'.

      +

      We are given a string s of '0's and '1's, and we may flip any '0' to a '1' or a '1' to a '0'.

      -

      Return the minimum number of flips to make S monotone increasing.

      +

      Return the minimum number of flips to make s monotone increasing.

       

      @@ -23,7 +23,7 @@

      Example 1:

      -Input: "00110"
      +Input: s = "00110"
       Output: 1
       Explanation: We flip the last digit to get 00111.
       
      @@ -32,7 +32,7 @@

      Example 2:

      -Input: "010110"
      +Input: s = "010110"
       Output: 2
       Explanation: We flip to get 011111, or alternatively 000111.
       
      @@ -41,7 +41,7 @@

      Example 3:

      -Input: "00011000"
      +Input: s = "00011000"
       Output: 2
       Explanation: We flip to get 00000000.
       
      @@ -51,8 +51,8 @@

      Note:

        -
      1. 1 <= S.length <= 20000
      2. -
      3. S only consists of '0' and '1' characters.
      4. +
      5. 1 <= s.length <= 20000
      6. +
      7. s only consists of '0' and '1' characters.
      diff --git a/problems/fraction-addition-and-subtraction/README.md b/problems/fraction-addition-and-subtraction/README.md index 1009fe831..704e9ff44 100644 --- a/problems/fraction-addition-and-subtraction/README.md +++ b/problems/fraction-addition-and-subtraction/README.md @@ -11,45 +11,49 @@ ## [592. Fraction Addition and Subtraction (Medium)](https://leetcode.com/problems/fraction-addition-and-subtraction "分数加减运算") -

      Given a string representing an expression of fraction addition and subtraction, you need to return the calculation result in string format. The final result should be irreducible fraction. If your final result is an integer, say 2, you need to change it to the format of fraction that has denominator 1. So in this case, 2 should be converted to 2/1.

      +

      Given a string expression representing an expression of fraction addition and subtraction, return the calculation result in string format.

      + +

      The final result should be an irreducible fraction. If your final result is an integer, say 2, you need to change it to the format of a fraction that has a denominator 1. So in this case, 2 should be converted to 2/1.

      + +

       

      +

      Example 1:

      -

      Example 1:

      -Input:"-1/2+1/2"
      -Output: "0/1"
      +Input: expression = "-1/2+1/2"
      +Output: "0/1"
       
      -

      -

      Example 2:
      +

      Example 2:

      +
      -Input:"-1/2+1/2+1/3"
      -Output: "1/3"
      +Input: expression = "-1/2+1/2+1/3"
      +Output: "1/3"
       
      -

      -

      Example 3:
      +

      Example 3:

      +
      -Input:"1/3-1/2"
      -Output: "-1/6"
      +Input: expression = "1/3-1/2"
      +Output: "-1/6"
       
      -

      -

      Example 4:
      +

      Example 4:

      +
      -Input:"5/3+1/3"
      -Output: "2/1"
      +Input: expression = "5/3+1/3"
      +Output: "2/1"
       
      -

      - -

      Note:
      -

        -
      1. The input string only contains '0' to '9', '/', '+' and '-'. So does the output.
      2. -
      3. Each fraction (input and output) has format ±numerator/denominator. If the first input fraction or the output is positive, then '+' will be omitted.
      4. -
      5. The input only contains valid irreducible fractions, where the numerator and denominator of each fraction will always be in the range [1,10]. If the denominator is 1, it means this fraction is actually an integer in a fraction format defined above.
      6. -
      7. The number of given fractions will be in the range [1,10].
      8. -
      9. The numerator and denominator of the final result are guaranteed to be valid and in the range of 32-bit int.
      10. -
      -

      + +

       

      +

      Constraints:

      + +
        +
      • The input string only contains '0' to '9', '/', '+' and '-'. So does the output.
      • +
      • Each fraction (input and output) has the format ±numerator/denominator. If the first input fraction or the output is positive, then '+' will be omitted.
      • +
      • The input only contains valid irreducible fractions, where the numerator and denominator of each fraction will always be in the range [1, 10]. If the denominator is 1, it means this fraction is actually an integer in a fraction format defined above.
      • +
      • The number of given fractions will be in the range [1, 10].
      • +
      • The numerator and denominator of the final result are guaranteed to be valid and in the range of 32-bit int.
      • +
      ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/furthest-building-you-can-reach/README.md b/problems/furthest-building-you-can-reach/README.md index e7aa08934..7b41b7eed 100644 --- a/problems/furthest-building-you-can-reach/README.md +++ b/problems/furthest-building-you-can-reach/README.md @@ -74,7 +74,7 @@ Assume the problem is to check whether you can reach the last building or not.
      Hint 2 -You'll have to do a set of jumps, and choose for each one whether to do it using a rope or bricks. It's always optimal to use ropes in the largest jumps. +You'll have to do a set of jumps, and choose for each one whether to do it using a ladder or bricks. It's always optimal to use ladders in the largest jumps.
      diff --git a/problems/global-and-local-inversions/README.md b/problems/global-and-local-inversions/README.md index fed445e65..fcf250992 100644 --- a/problems/global-and-local-inversions/README.md +++ b/problems/global-and-local-inversions/README.md @@ -51,7 +51,7 @@
      • n == nums.length
      • -
      • 1 <= n <= 5000
      • +
      • 1 <= n <= 105
      • 0 <= nums[i] < n
      • All the integers of nums are unique.
      • nums is a permutation of all the numbers in the range [0, n - 1].
      • diff --git a/problems/goat-latin/README.md b/problems/goat-latin/README.md index 2e54aee6b..a3d5b9389 100644 --- a/problems/goat-latin/README.md +++ b/problems/goat-latin/README.md @@ -11,7 +11,7 @@ ## [824. Goat Latin (Easy)](https://leetcode.com/problems/goat-latin "山羊拉丁文") -

        A sentence S is given, composed of words separated by spaces. Each word consists of lowercase and uppercase letters only.

        +

        A sentence sentence is given, composed of words separated by spaces. Each word consists of lowercase and uppercase letters only.

        We would like to convert the sentence to "Goat Latin" (a made-up language similar to Pig Latin.)

        @@ -28,21 +28,21 @@ For example, the first word gets "a" added to the end, the second word gets "aa" added to the end and so on.
      -

      Return the final sentence representing the conversion from S to Goat Latin. 

      +

      Return the final sentence representing the conversion from sentence to Goat Latin. 

       

      Example 1:

      -Input: "I speak Goat Latin"
      +Input: sentence = "I speak Goat Latin"
       Output: "Imaa peaksmaaa oatGmaaaa atinLmaaaaa"
       

      Example 2:

      -Input: "The quick brown fox jumped over the lazy dog"
      +Input: sentence = "The quick brown fox jumped over the lazy dog"
       Output: "heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpedjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa"
       
      @@ -51,8 +51,8 @@

      Notes:

        -
      • S contains only uppercase, lowercase and spaces. Exactly one space between each word.
      • -
      • 1 <= S.length <= 150.
      • +
      • sentence contains only uppercase, lowercase and spaces. Exactly one space between each word.
      • +
      • 1 <= sentence.length <= 150.
      ### Related Topics diff --git a/problems/groups-of-special-equivalent-strings/README.md b/problems/groups-of-special-equivalent-strings/README.md index c2a4c5ec0..60a6435a3 100644 --- a/problems/groups-of-special-equivalent-strings/README.md +++ b/problems/groups-of-special-equivalent-strings/README.md @@ -11,22 +11,22 @@ ## [893. Groups of Special-Equivalent Strings (Easy)](https://leetcode.com/problems/groups-of-special-equivalent-strings "特殊等价字符串组") -

      You are given an array A of strings.

      +

      You are given an array words of strings.

      -

      A move onto S consists of swapping any two even indexed characters of S, or any two odd indexed characters of S.

      +

      A move onto s consists of swapping any two even indexed characters of s, or any two odd indexed characters of s.

      -

      Two strings S and T are special-equivalent if after any number of moves onto S, S == T.

      +

      Two strings s and t are special-equivalent if after any number of moves onto s, s == t.

      -

      For example, S = "zzxy" and T = "xyzz" are special-equivalent because we may make the moves "zzxy" -> "xzzy" -> "xyzz" that swap S[0] and S[2], then S[1] and S[3].

      +

      For example, s = "zzxy" and t = "xyzz" are special-equivalent because we may make the moves "zzxy" -> "xzzy" -> "xyzz" that swap s[0] and s[2], then s[1] and s[3].

      -

      Now, a group of special-equivalent strings from A is a non-empty subset of A such that:

      +

      Now, a group of special-equivalent strings from words is a non-empty subset of words such that:

      1. Every pair of strings in the group are special equivalent, and;
      2. -
      3. The group is the largest size possible (ie., there isn't a string S not in the group such that S is special equivalent to every string in the group)
      4. +
      5. The group is the largest size possible (ie., there isn't a string s not in the group such that s is special equivalent to every string in the group)
      -

      Return the number of groups of special-equivalent strings from A.

      +

      Return the number of groups of special-equivalent strings from words.

       
      @@ -34,7 +34,7 @@

      Example 1:

      -Input: ["abcd","cdab","cbad","xyzz","zzxy","zzyx"]
      +Input: words = ["abcd","cdab","cbad","xyzz","zzxy","zzyx"]
       Output: 3
       Explanation: 
       One group is ["abcd", "cdab", "cbad"], since they are all pairwise special equivalent, and none of the other strings are all pairwise special equivalent to these.
      @@ -46,7 +46,7 @@ The other two groups are ["xyzz", "zzxy"] and ["zzyx&qu
       

      Example 2:

      -Input: ["abc","acb","bac","bca","cab","cba"]
      +Input: words = ["abc","acb","bac","bca","cab","cba"]
       Output: 3

       

      @@ -60,10 +60,10 @@ The other two groups are ["xyzz", "zzxy"] and ["zzyx&qu

      Note:

        -
      • 1 <= A.length <= 1000
      • -
      • 1 <= A[i].length <= 20
      • -
      • All A[i] have the same length.
      • -
      • All A[i] consist of only lowercase letters.
      • +
      • 1 <= words.length <= 1000
      • +
      • 1 <= words[i].length <= 20
      • +
      • All words[i] have the same length.
      • +
      • All words[i] consist of only lowercase letters.
      diff --git a/problems/h-index-ii/README.md b/problems/h-index-ii/README.md index 8ee35fcd2..1fee0f5fe 100644 --- a/problems/h-index-ii/README.md +++ b/problems/h-index-ii/README.md @@ -17,6 +17,8 @@

      If there are several possible values for h, the maximum one is taken as the h-index.

      +

      You must write an algorithm that runs in logarithmic time.

      +

       

      Example 1:

      @@ -44,9 +46,6 @@ Since the researcher has 3 papers with at least 3 citations each and the remaini
    • citations is sorted in ascending order.
    -

     

    -

    Follow up: Could you solve it in logarithmic time complexity?

    - ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/hand-of-straights/README.md b/problems/hand-of-straights/README.md index 5d08bff8f..cf45aea65 100644 --- a/problems/hand-of-straights/README.md +++ b/problems/hand-of-straights/README.md @@ -13,7 +13,7 @@

    Alice has a hand of cards, given as an array of integers.

    -

    Now she wants to rearrange the cards into groups so that each group is size W, and consists of W consecutive cards.

    +

    Now she wants to rearrange the cards into groups so that each group is size groupSize, and consists of groupSize consecutive cards.

    Return true if and only if she can.

    @@ -23,7 +23,7 @@

    Example 1:

    -Input: hand = [1,2,3,6,2,3,4,7,8], W = 3
    +Input: hand = [1,2,3,6,2,3,4,7,8], groupSize = 3
     Output: true
     Explanation: Alice's hand can be rearranged as [1,2,3],[2,3,4],[6,7,8]
     
    @@ -31,7 +31,7 @@

    Example 2:

    -Input: hand = [1,2,3,4,5], W = 4
    +Input: hand = [1,2,3,4,5], groupSize = 4
     Output: false
     Explanation: Alice's hand can't be rearranged into groups of 4.
     
    @@ -42,8 +42,8 @@
     
     
    • 1 <= hand.length <= 10000
    • -
    • 0 <= hand[i] <= 10^9
    • -
    • 1 <= W <= hand.length
    • +
    • 0 <= hand[i] <= 109
    • +
    • 1 <= groupSize <= hand.length
    ### Related Topics diff --git a/problems/image-smoother/README.md b/problems/image-smoother/README.md index cad378159..85205416a 100644 --- a/problems/image-smoother/README.md +++ b/problems/image-smoother/README.md @@ -11,31 +11,42 @@ ## [661. Image Smoother (Easy)](https://leetcode.com/problems/image-smoother "图片平滑器") -

    Given a 2D integer matrix M representing the gray scale of an image, you need to design a smoother to make the gray scale of each cell becomes the average gray scale (rounding down) of all the 8 surrounding cells and itself. If a cell has less than 8 surrounding cells, then use as many as you can.

    +

    An image smoother is a filter of the size 3 x 3 that can be applied to each cell of an image by rounding down the average of the cell and the eight surrounding cells (i.e., the average of the nine cells in the blue smoother). If one or more of the surrounding cells of a cell is not present, we do not consider it in the average (i.e., the average of the four cells in the red smoother).

    + +

    Given an m x n integer matrix img representing the grayscale of an image, return the image after applying the smoother on each cell of it.

    -

    Example 1:
    +

     

    +

    Example 1:

    +
    -Input:
    -[[1,1,1],
    - [1,0,1],
    - [1,1,1]]
    -Output:
    -[[0, 0, 0],
    - [0, 0, 0],
    - [0, 0, 0]]
    -Explanation:
    -For the point (0,0), (0,2), (2,0), (2,2): floor(3/4) = floor(0.75) = 0
    -For the point (0,1), (1,0), (1,2), (2,1): floor(5/6) = floor(0.83333333) = 0
    +Input: img = [[1,1,1],[1,0,1],[1,1,1]]
    +Output: [[0,0,0],[0,0,0],[0,0,0]]
    +Explanation:
    +For the points (0,0), (0,2), (2,0), (2,2): floor(3/4) = floor(0.75) = 0
    +For the points (0,1), (1,0), (1,2), (2,1): floor(5/6) = floor(0.83333333) = 0
     For the point (1,1): floor(8/9) = floor(0.88888889) = 0
     
    -

    - -

    Note:
    -

      -
    1. The value in the given matrix is in the range of [0, 255].
    2. -
    3. The length and width of the given matrix are in the range of [1, 150].
    4. -
    -

    + +

    Example 2:

    + +
    +Input: img = [[100,200,100],[200,50,200],[100,200,100]]
    +Output: [[137,141,137],[141,138,141],[137,141,137]]
    +Explanation:
    +For the points (0,0), (0,2), (2,0), (2,2): floor((100+200+200+50)/4) = floor(137.5) = 137
    +For the points (0,1), (1,0), (1,2), (2,1): floor((200+200+50+200+100+100)/6) = floor(141.666667) = 141
    +For the point (1,1): floor((50+200+200+200+200+100+100+100+100)/9) = floor(138.888889) = 138
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == img.length
    • +
    • n == img[i].length
    • +
    • 1 <= m, n <= 200
    • +
    • 0 <= img[i][j] <= 255
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/inorder-successor-in-bst/README.md b/problems/inorder-successor-in-bst/README.md index 11fc3ef36..b39c2f6d5 100644 --- a/problems/inorder-successor-in-bst/README.md +++ b/problems/inorder-successor-in-bst/README.md @@ -44,6 +44,6 @@ [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Medium) + 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Easy) 1. [Binary Search Tree Iterator](../binary-search-tree-iterator) (Medium) 1. [Inorder Successor in BST II](../inorder-successor-in-bst-ii) (Medium) diff --git a/problems/k-inverse-pairs-array/README.md b/problems/k-inverse-pairs-array/README.md index e1c7a717d..e3078c854 100644 --- a/problems/k-inverse-pairs-array/README.md +++ b/problems/k-inverse-pairs-array/README.md @@ -11,41 +11,34 @@ ## [629. K Inverse Pairs Array (Hard)](https://leetcode.com/problems/k-inverse-pairs-array "K个逆序对数组") -

    Given two integers n and k, find how many different arrays consist of numbers from 1 to n such that there are exactly k inverse pairs.

    +

    For an integer array nums, an inverse pair is a pair of integers [i, j] where 0 <= i < j < nums.length and nums[i] > nums[j].

    -

    We define an inverse pair as following: For ith and jth element in the array, if i < j and a[i] > a[j] then it's an inverse pair; Otherwise, it's not.

    +

    Given two integers n and k, return the number of different arrays consist of numbers from 1 to n such that there are exactly k inverse pairs. Since the answer can be huge, return it modulo 109 + 7.

    -

    Since the answer may be very large, the answer should be modulo 109 + 7.

    - -

    Example 1:

    +

     

    +

    Example 1:

    -Input: n = 3, k = 0
    -Output: 1
    -Explanation: 
    -Only the array [1,2,3] which consists of numbers from 1 to 3 has exactly 0 inverse pair.
    +Input: n = 3, k = 0
    +Output: 1
    +Explanation: Only the array [1,2,3] which consists of numbers from 1 to 3 has exactly 0 inverse pairs.
     
    -

     

    - -

    Example 2:

    +

    Example 2:

    -Input: n = 3, k = 1
    -Output: 2
    -Explanation: 
    -The array [1,3,2] and [2,1,3] have exactly 1 inverse pair.
    +Input: n = 3, k = 1
    +Output: 2
    +Explanation: The array [1,3,2] and [2,1,3] have exactly 1 inverse pair.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. The integer n is in the range [1, 1000] and k is in the range [0, 1000].
    2. -
    - -

     

    +
      +
    • 1 <= n <= 1000
    • +
    • 0 <= k <= 1000
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/k-th-symbol-in-grammar/README.md b/problems/k-th-symbol-in-grammar/README.md index d358592df..55448e681 100644 --- a/problems/k-th-symbol-in-grammar/README.md +++ b/problems/k-th-symbol-in-grammar/README.md @@ -13,20 +13,20 @@

    On the first row, we write a 0. Now in every subsequent row, we look at the previous row and replace each occurrence of 0 with 01, and each occurrence of 1 with 10.

    -

    Given row N and index K, return the K-th indexed symbol in row N. (The values of K are 1-indexed.) (1 indexed).

    +

    Given row n and index k, return the kth indexed symbol in row n. (The values of k are 1-indexed.) (1 indexed).

     Examples:
    -Input: N = 1, K = 1
    +Input: n = 1, k = 1
     Output: 0
     
    -Input: N = 2, K = 1
    +Input: n = 2, k = 1
     Output: 0
     
    -Input: N = 2, K = 2
    +Input: n = 2, k = 2
     Output: 1
     
    -Input: N = 4, K = 5
    +Input: n = 4, k = 5
     Output: 1
     
     Explanation:
    @@ -39,8 +39,8 @@ row 4: 01101001
     

    Note:

      -
    1. N will be an integer in the range [1, 30].
    2. -
    3. K will be an integer in the range [1, 2^(N-1)].
    4. +
    5. n will be an integer in the range [1, 30].
    6. +
    7. k will be an integer in the range [1, 2n-1].
    ### Related Topics diff --git a/problems/kth-smallest-element-in-a-bst/README.md b/problems/kth-smallest-element-in-a-bst/README.md index c36d3271e..333a700df 100644 --- a/problems/kth-smallest-element-in-a-bst/README.md +++ b/problems/kth-smallest-element-in-a-bst/README.md @@ -45,7 +45,7 @@ [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Medium) + 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Easy) 1. [Second Minimum Node In a Binary Tree](../second-minimum-node-in-a-binary-tree) (Easy) ### Hints diff --git a/problems/kth-smallest-number-in-multiplication-table/README.md b/problems/kth-smallest-number-in-multiplication-table/README.md index c8243b0af..cda7f63f4 100644 --- a/problems/kth-smallest-number-in-multiplication-table/README.md +++ b/problems/kth-smallest-number-in-multiplication-table/README.md @@ -11,49 +11,34 @@ ## [668. Kth Smallest Number in Multiplication Table (Hard)](https://leetcode.com/problems/kth-smallest-number-in-multiplication-table "乘法表中第k小的数") -

    -Nearly every one have used the Multiplication Table. But could you find out the k-th smallest number quickly from the multiplication table? -

    +

    Nearly everyone has used the Multiplication Table. The multiplication table of size m x n is an integer matrix mat where mat[i][j] == i * j (1-indexed).

    -

    -Given the height m and the length n of a m * n Multiplication Table, and a positive integer k, you need to return the k-th smallest number in this table. -

    +

    Given three integers m, n, and k, return the kth smallest element in the m x n multiplication table.

    -

    Example 1:
    +

     

    +

    Example 1:

    +
    -Input: m = 3, n = 3, k = 5
    -Output: 
    -Explanation: 
    -The Multiplication Table:
    -1	2	3
    -2	4	6
    -3	6	9
    -
    -The 5-th smallest number is 3 (1, 2, 2, 3, 3).
    +Input: m = 3, n = 3, k = 5
    +Output: 3
    +Explanation: The 5th smallest number is 3.
     
    -

    - -

    Example 2:
    +

    Example 2:

    +
    -Input: m = 2, n = 3, k = 6
    -Output: 
    -Explanation: 
    -The Multiplication Table:
    -1	2	3
    -2	4	6
    -
    -The 6-th smallest number is 6 (1, 2, 2, 3, 4, 6).
    +Input: m = 2, n = 3, k = 6
    +Output: 6
    +Explanation: The 6th smallest number is 6.
     
    -

    +

     

    +

    Constraints:

    -

    Note:
    -

      -
    1. The m and n will be in the range [1, 30000].
    2. -
    3. The k will be in the range [1, m * n]
    4. -
    -

    +
      +
    • 1 <= m, n <= 3 * 104
    • +
    • 1 <= k <= m * n
    • +
    ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/largest-color-value-in-a-directed-graph/README.md b/problems/largest-color-value-in-a-directed-graph/README.md new file mode 100644 index 000000000..afcb8bd3f --- /dev/null +++ b/problems/largest-color-value-in-a-directed-graph/README.md @@ -0,0 +1,68 @@ + + + + + + + +[< Previous](../maximum-subarray-min-product "Maximum Subarray Min-Product") +                 +Next > + +## [1857. Largest Color Value in a Directed Graph (Hard)](https://leetcode.com/problems/largest-color-value-in-a-directed-graph "有向图中最大颜色值") + +

    There is a directed graph of n colored nodes and m edges. The nodes are numbered from 0 to n - 1.

    + +

    You are given a string colors where colors[i] is a lowercase English letter representing the color of the ith node in this graph (0-indexed). You are also given a 2D array edges where edges[j] = [aj, bj] indicates that there is a directed edge from node aj to node bj.

    + +

    A valid path in the graph is a sequence of nodes x1 -> x2 -> x3 -> ... -> xk such that there is a directed edge from xi to xi+1 for every 1 <= i < k. The color value of the path is the number of nodes that are colored the most frequently occurring color along that path.

    + +

    Return the largest color value of any valid path in the given graph, or -1 if the graph contains a cycle.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: colors = "abaca", edges = [[0,1],[0,2],[2,3],[3,4]]
    +Output: 3
    +Explanation: The path 0 -> 2 -> 3 -> 4 contains 3 nodes that are colored "a" (red in the above image).
    +
    + +

    Example 2:

    + +

    + +
    +Input: colors = "a", edges = [[0,0]]
    +Output: -1
    +Explanation: There is a cycle from 0 to 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == colors.length
    • +
    • m == edges.length
    • +
    • 1 <= n <= 105
    • +
    • 0 <= m <= 105
    • +
    • colors consists of lowercase English letters.
    • +
    • 0 <= aj, bj < n
    • +
    + +### Related Topics + [[Topological Sort](../../tag/topological-sort/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Use topological sort. +
    + +
    +Hint 2 +let dp[u][c] := the maximum count of vertices with color c of any path starting from vertex u. (by JerryJin2905) +
    diff --git a/problems/largest-component-size-by-common-factor/README.md b/problems/largest-component-size-by-common-factor/README.md index b163c0f50..af312f5c6 100644 --- a/problems/largest-component-size-by-common-factor/README.md +++ b/problems/largest-component-size-by-common-factor/README.md @@ -11,11 +11,11 @@ ## [952. Largest Component Size by Common Factor (Hard)](https://leetcode.com/problems/largest-component-size-by-common-factor "按公因数计算最大组件大小") -

    Given a non-empty array of unique positive integers A, consider the following graph:

    +

    Given a non-empty array of unique positive integers nums, consider the following graph:

      -
    • There are A.length nodes, labelled A[0] to A[A.length - 1];
    • -
    • There is an edge between A[i] and A[j] if and only if A[i] and A[j] share a common factor greater than 1.
    • +
    • There are nums.length nodes, labelled nums[0] to nums[nums.length - 1];
    • +
    • There is an edge between nums[i] and nums[j] if and only if nums[i] and nums[j] share a common factor greater than 1.

    Return the size of the largest connected component in the graph.

    @@ -29,7 +29,7 @@

    Example 1:

    -Input: [4,6,15,35]
    +Input: nums = [4,6,15,35]
     Output: 4
     
     
    @@ -38,7 +38,7 @@

    Example 2:

    -Input: [20,50,9,63]
    +Input: nums = [20,50,9,63]
     Output: 2
     
     
    @@ -47,7 +47,7 @@

    Example 3:

    -Input: [2,3,6,7,4,12,21,39]
    +Input: nums = [2,3,6,7,4,12,21,39]
     Output: 8
     
     
    @@ -55,8 +55,8 @@

    Note:

      -
    1. 1 <= A.length <= 20000
    2. -
    3. 1 <= A[i] <= 100000
    4. +
    5. 1 <= nums.length <= 20000
    6. +
    7. 1 <= nums[i] <= 100000
    diff --git a/problems/largest-number-at-least-twice-of-others/README.md b/problems/largest-number-at-least-twice-of-others/README.md index c1511f223..cbaf796ef 100644 --- a/problems/largest-number-at-least-twice-of-others/README.md +++ b/problems/largest-number-at-least-twice-of-others/README.md @@ -13,7 +13,7 @@

    You are given an integer array nums where the largest integer is unique.

    -

    Find whether the largest element in the array is at least twice as much as every other number in the array. If it is, return the index of the largest element, otherwise, return -1.

    +

    Determine whether the largest element in the array is at least twice as much as every other number in the array. If it is, return the index of the largest element, or return -1 otherwise.

     

    Example 1:

    @@ -21,8 +21,8 @@
     Input: nums = [3,6,1,0]
     Output: 1
    -Explanation: 6 is the largest integer and for every other number in the array x,
    -6 is more than twice as big as x.
    +Explanation: 6 is the largest integer.
    +For every other number in the array x, 6 is at least twice as big as x.
     The index of value 6 is 1, so we return 1.
     
    @@ -31,7 +31,14 @@ The index of value 6 is 1, so we return 1.
     Input: nums = [1,2,3,4]
     Output: -1
    -Explanation: 4 is not at least as big as twice the value of 3, so we return -1.
    +Explanation: 4 is less than twice the value of 3, so we return -1.
    + +

    Example 3:

    + +
    +Input: nums = [1]
    +Output: 0
    +Explanation: 1 is trivially at least twice the value as any other number because there are no other numbers.
     

     

    diff --git a/problems/largest-plus-sign/README.md b/problems/largest-plus-sign/README.md index cdb692979..b7eac9098 100644 --- a/problems/largest-plus-sign/README.md +++ b/problems/largest-plus-sign/README.md @@ -11,13 +11,13 @@ ## [764. Largest Plus Sign (Medium)](https://leetcode.com/problems/largest-plus-sign "最大加号标志") -

    -In a 2D grid from (0, 0) to (N-1, N-1), every cell contains a 1, except those cells in the given list mines which are 0. What is the largest axis-aligned plus sign of 1s contained in the grid? Return the order of the plus sign. If there is none, return 0. -

    -An "axis-aligned plus sign of 1s of order k" has some center grid[x][y] = 1 along with 4 arms of length k-1 going up, down, left, and right, and made of 1s. This is demonstrated in the diagrams below. Note that there could be 0s or 1s beyond the arms of the plus sign, only the relevant area of the plus sign is checked for 1s. -

    +

    In a 2D grid from (0, 0) to (n-1, n-1), every cell contains a 1, except those cells in the given list mines which are 0. What is the largest axis-aligned plus sign of 1s contained in the grid? Return the order of the plus sign. If there is none, return 0.

    -

    Examples of Axis-Aligned Plus Signs of Order k:

    +

    An "axis-aligned plus sign of 1s of order k" has some center grid[x][y] = 1 along with 4 arms of length k-1 going up, down, left, and right, and made of 1s. This is demonstrated in the diagrams below. Note that there could be 0s or 1s beyond the arms of the plus sign, only the relevant area of the plus sign is checked for 1s.

    + +

    Examples of Axis-Aligned Plus Signs of Order k:

    + +
     Order 1:
     000
     010
    @@ -38,10 +38,12 @@ Order 3:
     0001000
     0001000
     0000000
    -

    +
    -

    Example 1:

    -Input: N = 5, mines = [[4, 2]]
    +

    Example 1:

    + +
    +Input: n = 5, mines = [[4, 2]]
     Output: 2
     Explanation:
     11111
    @@ -50,28 +52,36 @@ Order 3:
     11111
     11011
     In the above grid, the largest plus sign can only be order 2.  One of them is marked in bold.
    -

    +
    + +

    Example 2:

    -

    Example 2:

    -Input: N = 2, mines = []
    +
    +Input: n = 2, mines = []
     Output: 1
     Explanation:
     There is no plus sign of order 2, but there is of order 1.
    -

    +
    -

    Example 3:

    -Input: N = 1, mines = [[0, 0]]
    +

    Example 3:

    + +
    +Input: n = 1, mines = [[0, 0]]
     Output: 0
     Explanation:
     There is no plus sign, so return 0.
    -

    - -

    Note:

      -
    1. N will be an integer in the range [1, 500].
    2. -
    3. mines will have length at most 5000.
    4. -
    5. mines[i] will be length 2 and consist of integers in the range [0, N-1].
    6. -
    7. (Additionally, programs submitted in C, C++, or C# will be judged with a slightly smaller time limit.)
    8. -

    +
    + +

    Note:

    + +
      +
    1. n will be an integer in the range [1, 500].
    2. +
    3. mines will have length at most 5000.
    4. +
    5. mines[i] will be length 2 and consist of integers in the range [0, n-1].
    6. +
    7. (Additionally, programs submitted in C, C++, or C# will be judged with a slightly smaller time limit.)
    8. +
    + +

     

    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/largest-sum-of-averages/README.md b/problems/largest-sum-of-averages/README.md index 8ce2f1d71..1df8fa879 100644 --- a/problems/largest-sum-of-averages/README.md +++ b/problems/largest-sum-of-averages/README.md @@ -11,19 +11,19 @@ ## [813. Largest Sum of Averages (Medium)](https://leetcode.com/problems/largest-sum-of-averages "最大平均值和的分组") -

    We partition a row of numbers A into at most K adjacent (non-empty) groups, then our score is the sum of the average of each group. What is the largest score we can achieve?

    +

    We partition a row of numbers nums into at most k adjacent (non-empty) groups, then our score is the sum of the average of each group. What is the largest score we can achieve?

    -

    Note that our partition must use every number in A, and that scores are not necessarily integers.

    +

    Note that our partition must use every number in nums, and that scores are not necessarily integers.

     Example:
     Input: 
    -A = [9,1,2,3,9]
    -K = 3
    +nums = [9,1,2,3,9]
    +k = 3
     Output: 20
     Explanation: 
    -The best choice is to partition A into [9], [1, 2, 3], [9]. The answer is 9 + (1 + 2 + 3) / 3 + 9 = 20.
    -We could have also partitioned A into [9, 1], [2], [3, 9], for example.
    +The best choice is to partition nums into [9], [1, 2, 3], [9]. The answer is 9 + (1 + 2 + 3) / 3 + 9 = 20.
    +We could have also partitioned nums into [9, 1], [2], [3, 9], for example.
     That partition would lead to a score of 5 + 2 + 6 = 13, which is worse.
     
    @@ -32,10 +32,10 @@ That partition would lead to a score of 5 + 2 + 6 = 13, which is worse.

    Note:

      -
    • 1 <= A.length <= 100.
    • -
    • 1 <= A[i] <= 10000.
    • -
    • 1 <= K <= A.length.
    • -
    • Answers within 10^-6 of the correct answer will be accepted as correct.
    • +
    • 1 <= nums.length <= 100.
    • +
    • 1 <= nums[i] <= 10000.
    • +
    • 1 <= k <= nums.length.
    • +
    • Answers within 10-6 of the correct answer will be accepted as correct.
    ### Related Topics diff --git a/problems/largest-time-for-given-digits/README.md b/problems/largest-time-for-given-digits/README.md index 4642458a4..cad630633 100644 --- a/problems/largest-time-for-given-digits/README.md +++ b/problems/largest-time-for-given-digits/README.md @@ -21,7 +21,7 @@

    Example 1:

    -Input: A = [1,2,3,4]
    +Input: arr = [1,2,3,4]
     Output: "23:41"
     Explanation: The valid 24-hour times are "12:34", "12:43", "13:24", "13:42", "14:23", "14:32", "21:34", "21:43", "23:14", and "23:41". Of these times, "23:41" is the latest.
     
    @@ -29,7 +29,7 @@

    Example 2:

    -Input: A = [5,5,5,5]
    +Input: arr = [5,5,5,5]
     Output: ""
     Explanation: There are no valid 24-hour times as "55:55" is not valid.
     
    @@ -37,14 +37,14 @@

    Example 3:

    -Input: A = [0,0,0,0]
    +Input: arr = [0,0,0,0]
     Output: "00:00"
     

    Example 4:

    -Input: A = [0,0,1,0]
    +Input: arr = [0,0,1,0]
     Output: "10:00"
     
    diff --git a/problems/league-statistics/README.md b/problems/league-statistics/README.md new file mode 100644 index 000000000..a7d3585ce --- /dev/null +++ b/problems/league-statistics/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../maximum-building-height "Maximum Building Height") +                 +[Next >](../next-palindrome-using-same-digits "Next Palindrome Using Same Digits") + +## [1841. League Statistics (Medium)](https://leetcode.com/problems/league-statistics "") + + diff --git a/problems/league-statistics/mysql_schemas.sql b/problems/league-statistics/mysql_schemas.sql new file mode 100644 index 000000000..0f6c35b2b --- /dev/null +++ b/problems/league-statistics/mysql_schemas.sql @@ -0,0 +1,11 @@ +Create table If Not Exists Teams (team_id int, team_name varchar(20)); +Create table If Not Exists Matches (home_team_id int, away_team_id int, home_team_goals int, away_team_goals int); +Truncate table Teams; +insert into Teams (team_id, team_name) values ('1', 'Ajax'); +insert into Teams (team_id, team_name) values ('4', 'Dortmund'); +insert into Teams (team_id, team_name) values ('6', 'Arsenal'); +Truncate table Matches; +insert into Matches (home_team_id, away_team_id, home_team_goals, away_team_goals) values ('1', '4', '0', '1'); +insert into Matches (home_team_id, away_team_id, home_team_goals, away_team_goals) values ('1', '6', '3', '3'); +insert into Matches (home_team_id, away_team_id, home_team_goals, away_team_goals) values ('4', '1', '5', '2'); +insert into Matches (home_team_id, away_team_id, home_team_goals, away_team_goals) values ('6', '1', '0', '0'); diff --git a/problems/letter-case-permutation/README.md b/problems/letter-case-permutation/README.md index 019ff72c8..178842e5c 100644 --- a/problems/letter-case-permutation/README.md +++ b/problems/letter-case-permutation/README.md @@ -11,7 +11,7 @@ ## [784. Letter Case Permutation (Medium)](https://leetcode.com/problems/letter-case-permutation "字母大小写全排列") -

    Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string.

    +

    Given a string s, we can transform every letter individually to be lowercase or uppercase to create another string.

    Return a list of all possible strings we could create. You can return the output in any order.

    @@ -19,28 +19,28 @@

    Example 1:

    -Input: S = "a1b2"
    +Input: s = "a1b2"
     Output: ["a1b2","a1B2","A1b2","A1B2"]
     

    Example 2:

    -Input: S = "3z4"
    +Input: s = "3z4"
     Output: ["3z4","3Z4"]
     

    Example 3:

    -Input: S = "12345"
    +Input: s = "12345"
     Output: ["12345"]
     

    Example 4:

    -Input: S = "0"
    +Input: s = "0"
     Output: ["0"]
     
    @@ -48,8 +48,8 @@

    Constraints:

      -
    • S will be a string with length between 1 and 12.
    • -
    • S will consist only of letters or digits.
    • +
    • s will be a string with length between 1 and 12.
    • +
    • s will consist only of letters or digits.
    ### Related Topics diff --git a/problems/linked-list-components/README.md b/problems/linked-list-components/README.md index 03075fdf2..3d59372f8 100644 --- a/problems/linked-list-components/README.md +++ b/problems/linked-list-components/README.md @@ -13,16 +13,16 @@

    We are given head, the head node of a linked list containing unique integer values.

    -

    We are also given the list G, a subset of the values in the linked list.

    +

    We are also given the list nums, a subset of the values in the linked list.

    -

    Return the number of connected components in G, where two values are connected if they appear consecutively in the linked list.

    +

    Return the number of connected components in nums, where two values are connected if they appear consecutively in the linked list.

    Example 1:

     Input: 
     head: 0->1->2->3
    -G = [0, 1, 3]
    +nums = [0, 1, 3]
     Output: 2
     Explanation: 
     0 and 1 are connected, so [0, 1] and [3] are the two connected components.
    @@ -33,7 +33,7 @@ G = [0, 1, 3]
     
     Input: 
     head: 0->1->2->3->4
    -G = [0, 3, 1, 4]
    +nums = [0, 3, 1, 4]
     Output: 2
     Explanation: 
     0 and 1 are connected, 3 and 4 are connected, so [0, 1] and [3, 4] are the two connected components.
    @@ -42,10 +42,10 @@ G = [0, 3, 1, 4]
     

    Note:

      -
    • If N is the length of the linked list given by head1 <= N <= 10000.
    • -
    • The value of each node in the linked list will be in the range [0, N - 1].
    • -
    • 1 <= G.length <= 10000.
    • -
    • G is a subset of all values in the linked list.
    • +
    • If n is the length of the linked list given by head1 <= n <= 10000.
    • +
    • The value of each node in the linked list will be in the range [0, n - 1].
    • +
    • 1 <= nums.length <= 10000.
    • +
    • nums is a subset of all values in the linked list.
    ### Related Topics diff --git a/problems/longest-continuous-increasing-subsequence/README.md b/problems/longest-continuous-increasing-subsequence/README.md index 54f55fc08..dd958afd2 100644 --- a/problems/longest-continuous-increasing-subsequence/README.md +++ b/problems/longest-continuous-increasing-subsequence/README.md @@ -39,7 +39,7 @@ increasing.

    Constraints:

      -
    • 0 <= nums.length <= 104
    • +
    • 1 <= nums.length <= 104
    • -109 <= nums[i] <= 109
    diff --git a/problems/longest-happy-prefix/README.md b/problems/longest-happy-prefix/README.md index dcfffa076..234415620 100644 --- a/problems/longest-happy-prefix/README.md +++ b/problems/longest-happy-prefix/README.md @@ -11,11 +11,9 @@ ## [1392. Longest Happy Prefix (Hard)](https://leetcode.com/problems/longest-happy-prefix "最长快乐前缀") -

    A string is called a happy prefix if is a non-empty prefix which is also a suffix (excluding itself).

    +

    A string is called a happy prefix if is a non-empty prefix which is also a suffix (excluding itself).

    -

    Given a string s. Return the longest happy prefix of s .

    - -

    Return an empty string if no such prefix exists.

    +

    Given a string s, return the longest happy prefix of s. Return an empty string "" if no such prefix exists.

     

    Example 1:

    @@ -52,7 +50,7 @@

    Constraints:

      -
    • 1 <= s.length <= 10^5
    • +
    • 1 <= s.length <= 105
    • s contains only lowercase English letters.
    diff --git a/problems/masking-personal-information/README.md b/problems/masking-personal-information/README.md index 0e1e348f6..08d083bc7 100644 --- a/problems/masking-personal-information/README.md +++ b/problems/masking-personal-information/README.md @@ -11,7 +11,7 @@ ## [831. Masking Personal Information (Medium)](https://leetcode.com/problems/masking-personal-information "隐藏个人信息") -

    We are given a personal information string S, which may represent either an email address or a phone number.

    +

    We are given a personal information string s, which may represent either an email address or a phone number.

    We would like to mask this personal information according to the following rules:

    @@ -48,7 +48,7 @@

    Example 1:

    -Input: "LeetCode@LeetCode.com"
    +Input: s = "LeetCode@LeetCode.com"
     Output: "l*****e@leetcode.com"
     Explanation: All names are converted to lowercase, and the letters between the
                  first and last letter of the first name is replaced by 5 asterisks.
    @@ -58,7 +58,7 @@
     

    Example 2:

    -Input: "AB@qq.com"
    +Input: s = "AB@qq.com"
     Output: "a*****b@qq.com"
     Explanation: There must be 5 asterisks between the first and last letter 
                  of the first name "ab". Therefore, "ab" -> "a*****b".
    @@ -67,7 +67,7 @@
     

    Example 3:

    -Input: "1(234)567-890"
    +Input: s = "1(234)567-890"
     Output: "***-***-7890"
     Explanation: 10 digits in the phone number, which means all digits make up the local number.
     
    @@ -75,7 +75,7 @@

    Example 4:

    -Input: "86-(10)12345678"
    +Input: s = "86-(10)12345678"
     Output: "+**-***-***-5678"
     Explanation: 12 digits, 2 digits for country code and 10 digits for local number. 
     
    @@ -83,7 +83,7 @@

    Notes:

      -
    1. S.length <= 40.
    2. +
    3. s.length <= 40.
    4. Emails have length at least 8.
    5. Phone numbers have length at least 10.
    diff --git a/problems/max-area-of-island/README.md b/problems/max-area-of-island/README.md index da1c96128..cabb43f50 100644 --- a/problems/max-area-of-island/README.md +++ b/problems/max-area-of-island/README.md @@ -11,31 +11,37 @@ ## [695. Max Area of Island (Medium)](https://leetcode.com/problems/max-area-of-island "岛屿的最大面积") -

    Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.

    +

    You are given an m x n binary matrix grid. An island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.

    -

    Find the maximum area of an island in the given 2D array. (If there is no island, the maximum area is 0.)

    +

    The area of an island is the number of cells with a value 1 in the island.

    -

    Example 1:

    +

    Return the maximum area of an island in grid. If there is no island, return 0.

    +

     

    +

    Example 1:

    +
    -[[0,0,1,0,0,0,0,1,0,0,0,0,0],
    - [0,0,0,0,0,0,0,1,1,1,0,0,0],
    - [0,1,1,0,1,0,0,0,0,0,0,0,0],
    - [0,1,0,0,1,1,0,0,1,0,1,0,0],
    - [0,1,0,0,1,1,0,0,1,1,1,0,0],
    - [0,0,0,0,0,0,0,0,0,0,1,0,0],
    - [0,0,0,0,0,0,0,1,1,1,0,0,0],
    - [0,0,0,0,0,0,0,1,1,0,0,0,0]]
    +Input: grid = [[0,0,1,0,0,0,0,1,0,0,0,0,0],[0,0,0,0,0,0,0,1,1,1,0,0,0],[0,1,1,0,1,0,0,0,0,0,0,0,0],[0,1,0,0,1,1,0,0,1,0,1,0,0],[0,1,0,0,1,1,0,0,1,1,1,0,0],[0,0,0,0,0,0,0,0,0,0,1,0,0],[0,0,0,0,0,0,0,1,1,1,0,0,0],[0,0,0,0,0,0,0,1,1,0,0,0,0]]
    +Output: 6
    +Explanation: The answer is not 11, because the island must be connected 4-directionally.
     
    -Given the above grid, return 6. Note the answer is not 11, because the island must be connected 4-directionally. -

    Example 2:

    +

    Example 2:

    -[[0,0,0,0,0,0,0,0]]
    -Given the above grid, return 0. +Input: grid = [[0,0,0,0,0,0,0,0]] +Output: 0 +
    + +

     

    +

    Constraints:

    -

    Note: The length of each dimension in the given grid does not exceed 50.

    +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 50
    • +
    • grid[i][j] is either 0 or 1.
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/maximum-average-subarray-i/README.md b/problems/maximum-average-subarray-i/README.md index b44fcb666..e0d134101 100644 --- a/problems/maximum-average-subarray-i/README.md +++ b/problems/maximum-average-subarray-i/README.md @@ -11,26 +11,34 @@ ## [643. Maximum Average Subarray I (Easy)](https://leetcode.com/problems/maximum-average-subarray-i "子数组最大平均数 I") -

    Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the maximum average value.

    +

    You are given an integer array nums consisting of n elements, and an integer k.

    -

    Example 1:

    +

    Find a contiguous subarray whose length is equal to k that has the maximum average value and return this value. Any answer with a calculation error less than 10-5 will be accepted.

    + +

     

    +

    Example 1:

    -Input: [1,12,-5,-6,50,3], k = 4
    -Output: 12.75
    -Explanation: Maximum average is (12-5-6+50)/4 = 51/4 = 12.75
    +Input: nums = [1,12,-5,-6,50,3], k = 4
    +Output: 12.75000
    +Explanation: Maximum average is (12 - 5 - 6 + 50) / 4 = 51 / 4 = 12.75
     
    -

     

    - -

    Note:

    +

    Example 2:

    -
      -
    1. 1 <= k <= n <= 30,000.
    2. -
    3. Elements of the given array will be in the range [-10,000, 10,000].
    4. -
    +
    +Input: nums = [5], k = 1
    +Output: 5.00000
    +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= k <= n <= 105
    • +
    • -104 <= nums[i] <= 104
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/maximum-building-height/README.md b/problems/maximum-building-height/README.md index 8f766fc31..3e5156108 100644 --- a/problems/maximum-building-height/README.md +++ b/problems/maximum-building-height/README.md @@ -7,7 +7,7 @@ [< Previous](../longest-substring-of-all-vowels-in-order "Longest Substring Of All Vowels in Order")                  -Next > +[Next >](../league-statistics "League Statistics") ## [1840. Maximum Building Height (Hard)](https://leetcode.com/problems/maximum-building-height "最高建筑高度") diff --git a/problems/maximum-distance-between-a-pair-of-values/README.md b/problems/maximum-distance-between-a-pair-of-values/README.md new file mode 100644 index 000000000..db796b767 --- /dev/null +++ b/problems/maximum-distance-between-a-pair-of-values/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../maximum-population-year "Maximum Population Year") +                 +[Next >](../maximum-subarray-min-product "Maximum Subarray Min-Product") + +## [1855. Maximum Distance Between a Pair of Values (Medium)](https://leetcode.com/problems/maximum-distance-between-a-pair-of-values "下标对中的最大距离") + +

    You are given two non-increasing 0-indexed integer arrays nums1​​​​​​ and nums2​​​​​​.

    + +

    A pair of indices (i, j), where 0 <= i < nums1.length and 0 <= j < nums2.length, is valid if both i <= j and nums1[i] <= nums2[j]. The distance of the pair is j - i​​​​.

    + +

    Return the maximum distance of any valid pair (i, j). If there are no valid pairs, return 0.

    + +

    An array arr is non-increasing if arr[i-1] >= arr[i] for every 1 <= i < arr.length.

    + +

     

    +

    Example 1:

    + +
    +Input: nums1 = [55,30,5,4,2], nums2 = [100,20,10,10,5]
    +Output: 2
    +Explanation: The valid pairs are (0,0), (2,2), (2,3), (2,4), (3,3), (3,4), and (4,4).
    +The maximum distance is 2 with pair (2,4).
    +
    + +

    Example 2:

    + +
    +Input: nums1 = [2,2,2], nums2 = [10,10,1]
    +Output: 1
    +Explanation: The valid pairs are (0,0), (0,1), and (1,1).
    +The maximum distance is 1 with pair (0,1).
    +
    + +

    Example 3:

    + +
    +Input: nums1 = [30,29,19,5], nums2 = [25,25,25,25,25]
    +Output: 2
    +Explanation: The valid pairs are (2,2), (2,3), (2,4), (3,3), and (3,4).
    +The maximum distance is 2 with pair (2,4).
    +
    + +

    Example 4:

    + +
    +Input: nums1 = [5,4], nums2 = [3,2]
    +Output: 0
    +Explanation: There are no valid pairs, so return 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums1.length <= 105
    • +
    • 1 <= nums2.length <= 105
    • +
    • 1 <= nums1[i], nums2[j] <= 105
    • +
    • Both nums1 and nums2 are non-increasing.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Since both arrays are sorted in a non-increasing way this means that for each value in the first array. We can find the farthest value smaller than it using binary search. +
    + +
    +Hint 2 +There is another solution using a two pointers approach since the first array is non-increasing the farthest j such that nums2[j] ≥ nums1[i] is at least as far as the farthest j such that nums2[j] ≥ nums1[i-1] +
    diff --git a/problems/maximum-element-after-decreasing-and-rearranging/README.md b/problems/maximum-element-after-decreasing-and-rearranging/README.md new file mode 100644 index 000000000..8728b6e79 --- /dev/null +++ b/problems/maximum-element-after-decreasing-and-rearranging/README.md @@ -0,0 +1,84 @@ + + + + + + + +[< Previous](../seat-reservation-manager "Seat Reservation Manager") +                 +[Next >](../closest-room "Closest Room") + +## [1846. Maximum Element After Decreasing and Rearranging (Medium)](https://leetcode.com/problems/maximum-element-after-decreasing-and-rearranging "减小和重新排列数组后的最大元素") + +

    You are given an array of positive integers arr. Perform some operations (possibly none) on arr so that it satisfies these conditions:

    + +
      +
    • The value of the first element in arr must be 1.
    • +
    • The absolute difference between any 2 adjacent elements must be less than or equal to 1. In other words, abs(arr[i] - arr[i - 1]) <= 1 for each i where 1 <= i < arr.length (0-indexed). abs(x) is the absolute value of x.
    • +
    + +

    There are 2 types of operations that you can perform any number of times:

    + +
      +
    • Decrease the value of any element of arr to a smaller positive integer.
    • +
    • Rearrange the elements of arr to be in any order.
    • +
    + +

    Return the maximum possible value of an element in arr after performing the operations to satisfy the conditions.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [2,2,1,2,1]
    +Output: 2
    +Explanation: 
    +We can satisfy the conditions by rearranging arr so it becomes [1,2,2,2,1].
    +The largest element in arr is 2.
    +
    + +

    Example 2:

    + +
    +Input: arr = [100,1,1000]
    +Output: 3
    +Explanation: 
    +One possible way to satisfy the conditions is by doing the following:
    +1. Rearrange arr so it becomes [1,100,1000].
    +2. Decrease the value of the second element to 2.
    +3. Decrease the value of the third element to 3.
    +Now arr = [1,2,3], which satisfies the conditions.
    +The largest element in arr is 3.
    +
    + +

    Example 3:

    + +
    +Input: arr = [1,2,3,4,5]
    +Output: 5
    +Explanation: The array already satisfies the conditions, and the largest element is 5.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 105
    • +
    • 1 <= arr[i] <= 109
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Sort](../../tag/sort/README.md)] + +### Hints +
    +Hint 1 +Sort the Array. +
    + +
    +Hint 2 +Decrement each element to the largest integer that satisfies the conditions. +
    diff --git a/problems/maximum-ice-cream-bars/README.md b/problems/maximum-ice-cream-bars/README.md index 7d4bbd70e..7dda570d1 100644 --- a/problems/maximum-ice-cream-bars/README.md +++ b/problems/maximum-ice-cream-bars/README.md @@ -68,13 +68,3 @@ It is always optimal to buy the least expensive ice cream bar first. Hint 2 Sort the prices so that the cheapest ice cream bar comes first.
    - -
    -Hint 3 -It is always optimal to buy the least expensive ice cream bar first. -
    - -
    -Hint 4 -Sort the prices so that the cheapest ice cream bar comes first. -
    diff --git a/problems/maximum-population-year/README.md b/problems/maximum-population-year/README.md new file mode 100644 index 000000000..2d173f3a6 --- /dev/null +++ b/problems/maximum-population-year/README.md @@ -0,0 +1,58 @@ + + + + + + + +[< Previous](../convert-date-format "Convert Date Format") +                 +[Next >](../maximum-distance-between-a-pair-of-values "Maximum Distance Between a Pair of Values") + +## [1854. Maximum Population Year (Easy)](https://leetcode.com/problems/maximum-population-year "人口最多的年份") + +

    You are given a 2D integer array logs where each logs[i] = [birthi, deathi] indicates the birth and death years of the ith person.

    + +

    The population of some year x is the number of people alive during that year. The ith person is counted in year x's population if x is in the inclusive range [birthi, deathi - 1]. Note that the person is not counted in the year that they die.

    + +

    Return the earliest year with the maximum population.

    + +

     

    +

    Example 1:

    + +
    +Input: logs = [[1993,1999],[2000,2010]]
    +Output: 1993
    +Explanation: The maximum population is 1, and 1993 is the earliest year with this population.
    +
    + +

    Example 2:

    + +
    +Input: logs = [[1950,1961],[1960,1971],[1970,1981]]
    +Output: 1960
    +Explanation: 
    +The maximum population is 2, and it had happened in years 1960 and 1970.
    +The earlier year between them is 1960.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= logs.length <= 100
    • +
    • 1950 <= birthi < deathi <= 2050
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +For each year find the number of people whose birth_i ≤ year and death_i > year. +
    + +
    +Hint 2 +Find the maximum value between all years. +
    diff --git a/problems/maximum-subarray-min-product/README.md b/problems/maximum-subarray-min-product/README.md new file mode 100644 index 000000000..89892e4b5 --- /dev/null +++ b/problems/maximum-subarray-min-product/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../maximum-distance-between-a-pair-of-values "Maximum Distance Between a Pair of Values") +                 +[Next >](../largest-color-value-in-a-directed-graph "Largest Color Value in a Directed Graph") + +## [1856. Maximum Subarray Min-Product (Medium)](https://leetcode.com/problems/maximum-subarray-min-product "子数组最小乘积的最大值") + +

    The min-product of an array is equal to the minimum value in the array multiplied by the array's sum.

    + +
      +
    • For example, the array [3,2,5] (minimum value is 2) has a min-product of 2 * (3+2+5) = 2 * 10 = 20.
    • +
    + +

    Given an array of integers nums, return the maximum min-product of any non-empty subarray of nums. Since the answer may be large, return it modulo 109 + 7.

    + +

    Note that the min-product should be maximized before performing the modulo operation. Testcases are generated such that the maximum min-product without modulo will fit in a 64-bit signed integer.

    + +

    A subarray is a contiguous part of an array.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3,2]
    +Output: 14
    +Explanation: The maximum min-product is achieved with the subarray [2,3,2] (minimum value is 2).
    +2 * (2+3+2) = 2 * 7 = 14.
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,3,3,1,2]
    +Output: 18
    +Explanation: The maximum min-product is achieved with the subarray [3,3] (minimum value is 3).
    +3 * (3+3) = 3 * 6 = 18.
    +
    + +

    Example 3:

    + +
    +Input: nums = [3,1,5,6,4,2]
    +Output: 60
    +Explanation: The maximum min-product is achieved with the subarray [5,6,4] (minimum value is 4).
    +4 * (5+6+4) = 4 * 15 = 60.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 107
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Queue](../../tag/queue/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Is there a way we can sort the elements to simplify the problem? +
    + +
    +Hint 2 +Can we find the maximum min-product for every value in the array? +
    diff --git a/problems/maximum-sum-circular-subarray/README.md b/problems/maximum-sum-circular-subarray/README.md index 333658c86..4e4e9bf59 100644 --- a/problems/maximum-sum-circular-subarray/README.md +++ b/problems/maximum-sum-circular-subarray/README.md @@ -11,11 +11,11 @@ ## [918. Maximum Sum Circular Subarray (Medium)](https://leetcode.com/problems/maximum-sum-circular-subarray "环形子数组的最大和") -

    Given a circular array C of integers represented by A, find the maximum possible sum of a non-empty subarray of C.

    +

    Given a circular array circ of integers represented by nums, find the maximum possible sum of a non-empty subarray of circ.

    -

    Here, a circular array means the end of the array connects to the beginning of the array.  (Formally, C[i] = A[i] when 0 <= i < A.length, and C[i+A.length] = C[i] when i >= 0.)

    +

    Here, a circular array means the end of the array connects to the beginning of the array.  (Formally, circ[i] = nums[i] when 0 <= i < nums.length, and circ[i+nums.length] = circ[i] when i >= 0.)

    -

    Also, a subarray may only include each element of the fixed buffer A at most once.  (Formally, for a subarray C[i], C[i+1], ..., C[j], there does not exist i <= k1, k2 <= j with k1 % A.length = k2 % A.length.)

    +

    Also, a subarray may only include each element of the fixed buffer nums at most once.  (Formally, for a subarray circ[i], circ[i+1], ..., circ[j], there does not exist i <= k1, k2 <= j with k1 % nums.length = k2 % nums.length.)

     

    @@ -23,7 +23,7 @@

    Example 1:

    -Input: [1,-2,3,-2]
    +Input: nums = [1,-2,3,-2]
     Output: 3
     Explanation: Subarray [3] has maximum sum 3
     
    @@ -32,7 +32,7 @@

    Example 2:

    -Input: [5,-3,5]
    +Input: nums = [5,-3,5]
     Output: 10
     Explanation: Subarray [5,5] has maximum sum 5 + 5 = 10
     
    @@ -41,7 +41,7 @@

    Example 3:

    -Input: [3,-1,2,-1]
    +Input: nums = [3,-1,2,-1]
     Output: 4
     Explanation: Subarray [2,-1,3] has maximum sum 2 + (-1) + 3 = 4
     
    @@ -50,7 +50,7 @@

    Example 4:

    -Input: [3,-2,2,-3]
    +Input: nums = [3,-2,2,-3]
     Output: 3
     Explanation: Subarray [3] and [3,-2,2] both have maximum sum 3
     
    @@ -58,7 +58,7 @@

    Example 5:

    -Input: [-2,-3,-1]
    +Input: nums = [-2,-3,-1]
     Output: -1
     Explanation: Subarray [-1] has maximum sum -1
     
    @@ -68,8 +68,8 @@

    Note:

      -
    1. -30000 <= A[i] <= 30000
    2. -
    3. 1 <= A.length <= 30000
    4. +
    5. -30000 <= nums[i] <= 30000
    6. +
    7. 1 <= nums.length <= 30000
    diff --git a/problems/maximum-swap/README.md b/problems/maximum-swap/README.md index 4ad9961e3..5abaf0719 100644 --- a/problems/maximum-swap/README.md +++ b/problems/maximum-swap/README.md @@ -11,32 +11,33 @@ ## [670. Maximum Swap (Medium)](https://leetcode.com/problems/maximum-swap "最大交换") -

    -Given a non-negative integer, you could swap two digits at most once to get the maximum valued number. Return the maximum valued number you could get. -

    +

    You are given an integer num. You can swap two digits at most once to get the maximum valued number.

    + +

    Return the maximum valued number you can get.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: 2736
    -Output: 7236
    -Explanation: Swap the number 2 and the number 7.
    +Input: num = 2736
    +Output: 7236
    +Explanation: Swap the number 2 and the number 7.
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: 9973
    -Output: 9973
    -Explanation: No swap.
    +Input: num = 9973
    +Output: 9973
    +Explanation: No swap.
     
    -

    +

     

    +

    Constraints:

    -

    Note:
    -

      -
    1. The given number is in the range [0, 108]
    2. -
    -

    +
      +
    • 0 <= num <= 108
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/maximum-width-of-binary-tree/README.md b/problems/maximum-width-of-binary-tree/README.md index 90401c065..66158a27b 100644 --- a/problems/maximum-width-of-binary-tree/README.md +++ b/problems/maximum-width-of-binary-tree/README.md @@ -11,78 +11,53 @@ ## [662. Maximum Width of Binary Tree (Medium)](https://leetcode.com/problems/maximum-width-of-binary-tree "二叉树最大宽度") -

    Given a binary tree, write a function to get the maximum width of the given tree. The maximum width of a tree is the maximum width among all levels.

    +

    Given the root of a binary tree, return the maximum width of the given tree.

    -

    The width of one level is defined as the length between the end-nodes (the leftmost and right most non-null nodes in the level, where the null nodes between the end-nodes are also counted into the length calculation.

    +

    The maximum width of a tree is the maximum width among all levels.

    -

    It is guaranteed that the answer will in the range of 32-bit signed integer.

    +

    The width of one level is defined as the length between the end-nodes (the leftmost and rightmost non-null nodes), where the null nodes between the end-nodes are also counted into the length calculation.

    -

    Example 1:

    +

    It is guaranteed that the answer will in the range of 32-bit signed integer.

    +

     

    +

    Example 1:

    +
    -Input: 
    -
    -           1
    -         /   \
    -        3     2
    -       / \     \  
    -      5   3     9 
    -
    -Output: 4
    -Explanation: The maximum width existing in the third level with the length 4 (5,3,null,9).
    +Input: root = [1,3,2,5,3,null,9]
    +Output: 4
    +Explanation: The maximum width existing in the third level with the length 4 (5,3,null,9).
     
    -

    Example 2:

    - +

    Example 2:

    +
    -Input: 
    -
    -          1
    -         /  
    -        3    
    -       / \       
    -      5   3     
    -
    -Output: 2
    -Explanation: The maximum width existing in the third level with the length 2 (5,3).
    +Input: root = [1,3,null,5,3]
    +Output: 2
    +Explanation: The maximum width existing in the third level with the length 2 (5,3).
     
    -

    Example 3:

    - +

    Example 3:

    +
    -Input: 
    -
    -          1
    -         / \
    -        3   2 
    -       /        
    -      5      
    -
    -Output: 2
    -Explanation: The maximum width existing in the second level with the length 2 (3,2).
    +Input: root = [1,3,2,5]
    +Output: 2
    +Explanation: The maximum width existing in the second level with the length 2 (3,2).
     
    -

    Example 4:

    - +

    Example 4:

    +
    -Input: 
    -
    -          1
    -         / \
    -        3   2
    -       /     \  
    -      5       9 
    -     /         \
    -    6           7
    -Output: 8
    -Explanation:The maximum width existing in the fourth level with the length 8 (6,null,null,null,null,null,null,7).
    +Input: root = [1,3,2,5,null,null,9,6,null,null,7]
    +Output: 8
    +Explanation: The maximum width existing in the fourth level with the length 8 (6,null,null,null,null,null,null,7).
     

     

    Constraints:

      -
    • The given binary tree will have between 1 and 3000 nodes.
    • +
    • The number of nodes in the tree is in the range [1, 3000].
    • +
    • -100 <= Node.val <= 100
    ### Related Topics diff --git a/problems/maximum-width-ramp/README.md b/problems/maximum-width-ramp/README.md index 9710ac3e8..6ceef3e0b 100644 --- a/problems/maximum-width-ramp/README.md +++ b/problems/maximum-width-ramp/README.md @@ -11,29 +11,29 @@ ## [962. Maximum Width Ramp (Medium)](https://leetcode.com/problems/maximum-width-ramp "最大宽度坡") -

    Given an array A of integers, a ramp is a tuple (i, j) for which i < j and A[i] <= A[j].  The width of such a ramp is j - i.

    +

    Given an array nums of integers, a ramp is a tuple (i, j) for which i < j and nums[i] <= nums[j].  The width of such a ramp is j - i.

    -

    Find the maximum width of a ramp in A.  If one doesn't exist, return 0.

    +

    Find the maximum width of a ramp in nums.  If one doesn't exist, return 0.

     

    Example 1:

    -Input: [6,0,8,2,1,5]
    +Input: nums = [6,0,8,2,1,5]
     Output: 4
     Explanation: 
    -The maximum width ramp is achieved at (i, j) = (1, 5): A[1] = 0 and A[5] = 5.
    +The maximum width ramp is achieved at (i, j) = (1, 5): nums[1] = 0 and nums[5] = 5.
     

    Example 2:

    -Input: [9,8,1,0,1,9,4,0,4,1]
    +Input: nums = [9,8,1,0,1,9,4,0,4,1]
     Output: 7
     Explanation: 
    -The maximum width ramp is achieved at (i, j) = (2, 9): A[2] = 1 and A[9] = 1.
    +The maximum width ramp is achieved at (i, j) = (2, 9): nums[2] = 1 and nums[9] = 1.
     
    @@ -44,8 +44,8 @@ The maximum width ramp is achieved at (i, j) = (2, 9): A[2] = 1 and A[9] = 1.

    Note:

      -
    1. 2 <= A.length <= 50000
    2. -
    3. 0 <= A[i] <= 50000
    4. +
    5. 2 <= nums.length <= 50000
    6. +
    7. 0 <= nums[i] <= 50000
    diff --git a/problems/median-of-two-sorted-arrays/README.md b/problems/median-of-two-sorted-arrays/README.md index 9dcdd1d4b..d7d9731fd 100644 --- a/problems/median-of-two-sorted-arrays/README.md +++ b/problems/median-of-two-sorted-arrays/README.md @@ -13,6 +13,8 @@

    Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.

    +

    The overall run time complexity should be O(log (m+n)).

    +

     

    Example 1:

    @@ -63,9 +65,6 @@
  • -106 <= nums1[i], nums2[i] <= 106
  • -

     

    -Follow up: The overall run time complexity should be O(log (m+n)). - ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/merge-sorted-array/README.md b/problems/merge-sorted-array/README.md index 92c40344e..95e0e9a6c 100644 --- a/problems/merge-sorted-array/README.md +++ b/problems/merge-sorted-array/README.md @@ -34,6 +34,9 @@
  • -109 <= nums1[i], nums2[i] <= 109
  • +

     

    +Follow up: Can you come up with an algorithm that runs in O(m + n) time? + ### Related Topics [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/minesweeper/README.md b/problems/minesweeper/README.md index 079809c35..d52162746 100644 --- a/problems/minesweeper/README.md +++ b/problems/minesweeper/README.md @@ -11,77 +11,57 @@ ## [529. Minesweeper (Medium)](https://leetcode.com/problems/minesweeper "扫雷游戏") -

    Let's play the minesweeper game (Wikipedia, online game)!

    +

    Let's play the minesweeper game (Wikipedia, online game)!

    -

    You are given a 2D char matrix representing the game board. 'M' represents an unrevealed mine, 'E' represents an unrevealed empty square, 'B' represents a revealed blank square that has no adjacent (above, below, left, right, and all 4 diagonals) mines, digit ('1' to '8') represents how many mines are adjacent to this revealed square, and finally 'X' represents a revealed mine.

    +

    You are given an m x n char matrix board representing the game board where:

    -

    Now given the next click position (row and column indices) among all the unrevealed squares ('M' or 'E'), return the board after revealing this position according to the following rules:

    +
      +
    • 'M' represents an unrevealed mine,
    • +
    • 'E' represents an unrevealed empty square,
    • +
    • 'B' represents a revealed blank square that has no adjacent mines (i.e., above, below, left, right, and all 4 diagonals),
    • +
    • digit ('1' to '8') represents how many mines are adjacent to this revealed square, and
    • +
    • 'X' represents a revealed mine.
    • +
    + +

    You are also given an integer array click where click = [clickr, clickc] represents the next click position among all the unrevealed squares ('M' or 'E').

    + +

    Return the board after revealing this position according to the following rules:

      -
    1. If a mine ('M') is revealed, then the game is over - change it to 'X'.
    2. -
    3. If an empty square ('E') with no adjacent mines is revealed, then change it to revealed blank ('B') and all of its adjacent unrevealed squares should be revealed recursively.
    4. -
    5. If an empty square ('E') with at least one adjacent mine is revealed, then change it to a digit ('1' to '8') representing the number of adjacent mines.
    6. +
    7. If a mine 'M' is revealed, then the game is over. You should change it to 'X'.
    8. +
    9. If an empty square 'E' with no adjacent mines is revealed, then change it to a revealed blank 'B' and all of its adjacent unrevealed squares should be revealed recursively.
    10. +
    11. If an empty square 'E' with at least one adjacent mine is revealed, then change it to a digit ('1' to '8') representing the number of adjacent mines.
    12. Return the board when no more squares will be revealed.

     

    - -

    Example 1:

    - +

    Example 1:

    +
    -Input: 
    -
    -[['E', 'E', 'E', 'E', 'E'],
    - ['E', 'E', 'M', 'E', 'E'],
    - ['E', 'E', 'E', 'E', 'E'],
    - ['E', 'E', 'E', 'E', 'E']]
    -
    -Click : [3,0]
    -
    -Output: 
    -
    -[['B', '1', 'E', '1', 'B'],
    - ['B', '1', 'M', '1', 'B'],
    - ['B', '1', '1', '1', 'B'],
    - ['B', 'B', 'B', 'B', 'B']]
    -
    -Explanation:
    -
    +Input: board = [["E","E","E","E","E"],["E","E","M","E","E"],["E","E","E","E","E"],["E","E","E","E","E"]], click = [3,0]
    +Output: [["B","1","E","1","B"],["B","1","M","1","B"],["B","1","1","1","B"],["B","B","B","B","B"]]
     
    -

    Example 2:

    - +

    Example 2:

    +
    -Input: 
    -
    -[['B', '1', 'E', '1', 'B'],
    - ['B', '1', 'M', '1', 'B'],
    - ['B', '1', '1', '1', 'B'],
    - ['B', 'B', 'B', 'B', 'B']]
    -
    -Click : [1,2]
    -
    -Output: 
    -
    -[['B', '1', 'E', '1', 'B'],
    - ['B', '1', 'X', '1', 'B'],
    - ['B', '1', '1', '1', 'B'],
    - ['B', 'B', 'B', 'B', 'B']]
    -
    -Explanation:
    -
    +Input: board = [["B","1","E","1","B"],["B","1","M","1","B"],["B","1","1","1","B"],["B","B","B","B","B"]], click = [1,2]
    +Output: [["B","1","E","1","B"],["B","1","X","1","B"],["B","1","1","1","B"],["B","B","B","B","B"]]
     

     

    - -

    Note:

    - -
      -
    1. The range of the input matrix's height and width is [1,50].
    2. -
    3. The click position will only be an unrevealed square ('M' or 'E'), which also means the input board contains at least one clickable square.
    4. -
    5. The input board won't be a stage when game is over (some mines have been revealed).
    6. -
    7. For simplicity, not mentioned rules should be ignored in this problem. For example, you don't need to reveal all the unrevealed mines when the game is over, consider any cases that you will win the game or flag any squares.
    8. -
    +

    Constraints:

    + +
      +
    • m == board.length
    • +
    • n == board[i].length
    • +
    • 1 <= m, n <= 50
    • +
    • board[i][j] is either 'M', 'E', 'B', or a digit from '1' to '8'.
    • +
    • click.length == 2
    • +
    • 0 <= clickr <= m
    • +
    • 0 <= clickc <= n
    • +
    • board[clickr][clickc] is either 'M' or 'E'.
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/minimum-add-to-make-parentheses-valid/README.md b/problems/minimum-add-to-make-parentheses-valid/README.md index 986a5f5cb..f233fc353 100644 --- a/problems/minimum-add-to-make-parentheses-valid/README.md +++ b/problems/minimum-add-to-make-parentheses-valid/README.md @@ -11,7 +11,7 @@ ## [921. Minimum Add to Make Parentheses Valid (Medium)](https://leetcode.com/problems/minimum-add-to-make-parentheses-valid "使括号有效的最少添加") -

    Given a string S of '(' and ')' parentheses, we add the minimum number of parentheses ( '(' or ')', and in any positions ) so that the resulting parentheses string is valid.

    +

    Given a string s of '(' and ')' parentheses, we add the minimum number of parentheses ( '(' or ')', and in any positions ) so that the resulting parentheses string is valid.

    Formally, a parentheses string is valid if and only if:

    @@ -28,7 +28,7 @@

    Example 1:

    -Input: "())"
    +Input: s = "())"
     Output: 1
     
    @@ -36,7 +36,7 @@

    Example 2:

    -Input: "((("
    +Input: s = "((("
     Output: 3
     
    @@ -44,7 +44,7 @@

    Example 3:

    -Input: "()"
    +Input: s = "()"
     Output: 0
     
    @@ -52,7 +52,7 @@

    Example 4:

    -Input: "()))(("
    +Input: s = "()))(("
     Output: 4

     

    @@ -63,8 +63,8 @@

    Note:

      -
    1. S.length <= 1000
    2. -
    3. S only consists of '(' and ')' characters.
    4. +
    5. s.length <= 1000
    6. +
    7. s only consists of '(' and ')' characters.
    diff --git a/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/README.md b/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/README.md new file mode 100644 index 000000000..c84211f22 --- /dev/null +++ b/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../splitting-a-string-into-descending-consecutive-values "Splitting a String Into Descending Consecutive Values") +                 +[Next >](../minimum-interval-to-include-each-query "Minimum Interval to Include Each Query") + +## [1850. Minimum Adjacent Swaps to Reach the Kth Smallest Number (Medium)](https://leetcode.com/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number "邻位交换的最小次数") + +

    You are given a string num, representing a large integer, and an integer k.

    + +

    We call some integer wonderful if it is a permutation of the digits in num and is greater in value than num. There can be many wonderful integers. However, we only care about the smallest-valued ones.

    + +
      +
    • For example, when num = "5489355142": +
        +
      • The 1st smallest wonderful integer is "5489355214".
      • +
      • The 2nd smallest wonderful integer is "5489355241".
      • +
      • The 3rd smallest wonderful integer is "5489355412".
      • +
      • The 4th smallest wonderful integer is "5489355421".
      • +
      +
    • +
    + +

    Return the minimum number of adjacent digit swaps that needs to be applied to num to reach the kth smallest wonderful integer.

    + +

    The tests are generated in such a way that kth smallest wonderful integer exists.

    + +

     

    +

    Example 1:

    + +
    +Input: num = "5489355142", k = 4
    +Output: 2
    +Explanation: The 4th smallest wonderful number is "5489355421". To get this number:
    +- Swap index 7 with index 8: "5489355142" -> "5489355412"
    +- Swap index 8 with index 9: "5489355412" -> "5489355421"
    +
    + +

    Example 2:

    + +
    +Input: num = "11112", k = 4
    +Output: 4
    +Explanation: The 4th smallest wonderful number is "21111". To get this number:
    +- Swap index 3 with index 4: "11112" -> "11121"
    +- Swap index 2 with index 3: "11121" -> "11211"
    +- Swap index 1 with index 2: "11211" -> "12111"
    +- Swap index 0 with index 1: "12111" -> "21111"
    +
    + +

    Example 3:

    + +
    +Input: num = "00123", k = 1
    +Output: 1
    +Explanation: The 1st smallest wonderful number is "00132". To get this number:
    +- Swap index 3 with index 4: "00123" -> "00132"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= num.length <= 1000
    • +
    • 1 <= k <= 1000
    • +
    • num only consists of digits.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Find the next permutation of the given string k times. +
    + +
    +Hint 2 +Try to move each element to its correct position and calculate the number of steps. +
    diff --git a/problems/minimum-cost-to-hire-k-workers/README.md b/problems/minimum-cost-to-hire-k-workers/README.md index 20dcf52f7..c8a10cea3 100644 --- a/problems/minimum-cost-to-hire-k-workers/README.md +++ b/problems/minimum-cost-to-hire-k-workers/README.md @@ -11,9 +11,9 @@ ## [857. Minimum Cost to Hire K Workers (Hard)](https://leetcode.com/problems/minimum-cost-to-hire-k-workers "雇佣 K 名工人的最低成本") -

    There are N workers.  The i-th worker has a quality[i] and a minimum wage expectation wage[i].

    +

    There are n workers.  The i-th worker has a quality[i] and a minimum wage expectation wage[i].

    -

    Now we want to hire exactly K workers to form a paid group.  When hiring a group of K workers, we must pay them according to the following rules:

    +

    Now we want to hire exactly k workers to form a paid group.  When hiring a group of k workers, we must pay them according to the following rules:

    1. Every worker in the paid group should be paid in the ratio of their quality compared to other workers in the paid group.
    2. @@ -31,7 +31,7 @@

      Example 1:

      -Input: quality = [10,20,5], wage = [70,50,30], K = 2
      +Input: quality = [10,20,5], wage = [70,50,30], k = 2
       Output: 105.00000
       Explanation: We pay 70 to 0-th worker and 35 to 2-th worker.
       
      @@ -40,7 +40,7 @@

      Example 2:

      -Input: quality = [3,1,10,10,1], wage = [4,8,2,2,7], K = 3
      +Input: quality = [3,1,10,10,1], wage = [4,8,2,2,7], k = 3
       Output: 30.66667
       Explanation: We pay 4 to 0-th worker, 13.33333 to 2-th and 3-th workers seperately. 
       
      @@ -50,10 +50,10 @@

      Note:

        -
      1. 1 <= K <= N <= 10000, where N = quality.length = wage.length
      2. +
      3. 1 <= k <= n <= 10000, where n = quality.length = wage.length
      4. 1 <= quality[i] <= 10000
      5. 1 <= wage[i] <= 10000
      6. -
      7. Answers within 10^-5 of the correct answer will be considered correct.
      8. +
      9. Answers within 10-5 of the correct answer will be considered correct.
    diff --git a/problems/minimum-distance-between-bst-nodes/README.md b/problems/minimum-distance-between-bst-nodes/README.md index 35d30901a..8e90bc13f 100644 --- a/problems/minimum-distance-between-bst-nodes/README.md +++ b/problems/minimum-distance-between-bst-nodes/README.md @@ -45,4 +45,4 @@ [[Recursion](../../tag/recursion/README.md)] ### Similar Questions - 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Medium) + 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Easy) diff --git a/problems/minimum-distance-to-the-target-element/README.md b/problems/minimum-distance-to-the-target-element/README.md new file mode 100644 index 000000000..184725e67 --- /dev/null +++ b/problems/minimum-distance-to-the-target-element/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../closest-room "Closest Room") +                 +[Next >](../splitting-a-string-into-descending-consecutive-values "Splitting a String Into Descending Consecutive Values") + +## [1848. Minimum Distance to the Target Element (Easy)](https://leetcode.com/problems/minimum-distance-to-the-target-element "到目标元素的最小距离") + +

    Given an integer array nums (0-indexed) and two integers target and start, find an index i such that nums[i] == target and abs(i - start) is minimized. Note that abs(x) is the absolute value of x.

    + +

    Return abs(i - start).

    + +

    It is guaranteed that target exists in nums.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3,4,5], target = 5, start = 3
    +Output: 1
    +Explanation: nums[4] = 5 is the only value equal to target, so the answer is abs(4 - 3) = 1.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1], target = 1, start = 0
    +Output: 0
    +Explanation: nums[0] = 1 is the only value equal to target, so the answer is abs(0 - 0) = 0.
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,1,1,1,1,1,1,1,1,1], target = 1, start = 0
    +Output: 0
    +Explanation: Every value of nums is 1, but nums[0] minimizes abs(i - start), which is abs(0 - 0) = 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • 1 <= nums[i] <= 104
    • +
    • 0 <= start < nums.length
    • +
    • target is in nums.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Loop in both directions until you find the target element. +
    + +
    +Hint 2 +For each index i such that nums[i] == target calculate abs(i - start). +
    diff --git a/problems/minimum-increment-to-make-array-unique/README.md b/problems/minimum-increment-to-make-array-unique/README.md index dbdd57096..df253ad32 100644 --- a/problems/minimum-increment-to-make-array-unique/README.md +++ b/problems/minimum-increment-to-make-array-unique/README.md @@ -11,16 +11,16 @@ ## [945. Minimum Increment to Make Array Unique (Medium)](https://leetcode.com/problems/minimum-increment-to-make-array-unique "使数组唯一的最小增量") -

    Given an array of integers A, a move consists of choosing any A[i], and incrementing it by 1.

    +

    Given an array of integers nums, a move consists of choosing any nums[i], and incrementing it by 1.

    -

    Return the least number of moves to make every value in A unique.

    +

    Return the least number of moves to make every value in nums unique.

     

    Example 1:

    -Input: [1,2,2]
    +Input: nums = [1,2,2]
     Output: 1
     Explanation:  After 1 move, the array could be [1, 2, 3].
     
    @@ -29,7 +29,7 @@

    Example 2:

    -Input: [3,2,1,2,1,7]
    +Input: nums = [3,2,1,2,1,7]
     Output: 6
     Explanation:  After 6 moves, the array could be [3, 4, 1, 2, 5, 7].
     It can be shown with 5 or less moves that it is impossible for the array to have all unique values.
    @@ -41,8 +41,8 @@ It can be shown with 5 or less moves that it is impossible for the array to have
     

    Note:

      -
    1. 0 <= A.length <= 40000
    2. -
    3. 0 <= A[i] < 40000
    4. +
    5. 0 <= nums.length <= 40000
    6. +
    7. 0 <= nums[i] < 40000
    diff --git a/problems/minimum-interval-to-include-each-query/README.md b/problems/minimum-interval-to-include-each-query/README.md new file mode 100644 index 000000000..051d04d73 --- /dev/null +++ b/problems/minimum-interval-to-include-each-query/README.md @@ -0,0 +1,68 @@ + + + + + + + +[< Previous](../minimum-adjacent-swaps-to-reach-the-kth-smallest-number "Minimum Adjacent Swaps to Reach the Kth Smallest Number") +                 +[Next >](../distinct-numbers-in-each-subarray "Distinct Numbers in Each Subarray") + +## [1851. Minimum Interval to Include Each Query (Hard)](https://leetcode.com/problems/minimum-interval-to-include-each-query "包含每个查询的最小区间") + +

    You are given a 2D integer array intervals, where intervals[i] = [lefti, righti] describes the ith interval starting at lefti and ending at righti (inclusive). The size of an interval is defined as the number of integers it contains, or more formally righti - lefti + 1.

    + +

    You are also given an integer array queries. The answer to the jth query is the size of the smallest interval i such that lefti <= queries[j] <= righti. If no such interval exists, the answer is -1.

    + +

    Return an array containing the answers to the queries.

    + +

     

    +

    Example 1:

    + +
    +Input: intervals = [[1,4],[2,4],[3,6],[4,4]], queries = [2,3,4,5]
    +Output: [3,3,1,4]
    +Explanation: The queries are processed as follows:
    +- Query = 2: The interval [2,4] is the smallest interval containing 2. The answer is 4 - 2 + 1 = 3.
    +- Query = 3: The interval [2,4] is the smallest interval containing 3. The answer is 4 - 2 + 1 = 3.
    +- Query = 4: The interval [4,4] is the smallest interval containing 4. The answer is 4 - 4 + 1 = 1.
    +- Query = 5: The interval [3,6] is the smallest interval containing 5. The answer is 6 - 3 + 1 = 4.
    +
    + +

    Example 2:

    + +
    +Input: intervals = [[2,3],[2,5],[1,8],[20,25]], queries = [2,19,5,22]
    +Output: [2,-1,4,6]
    +Explanation: The queries are processed as follows:
    +- Query = 2: The interval [2,3] is the smallest interval containing 2. The answer is 3 - 2 + 1 = 2.
    +- Query = 19: None of the intervals contain 19. The answer is -1.
    +- Query = 5: The interval [2,5] is the smallest interval containing 5. The answer is 5 - 2 + 1 = 4.
    +- Query = 22: The interval [20,25] is the smallest interval containing 22. The answer is 25 - 20 + 1 = 6.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= intervals.length <= 105
    • +
    • 1 <= queries.length <= 105
    • +
    • intervals[i].length == 2
    • +
    • 1 <= lefti <= righti <= 107
    • +
    • 1 <= queries[j] <= 107
    • +
    + +### Related Topics + [[Line Sweep](../../tag/line-sweep/README.md)] + +### Hints +
    +Hint 1 +Is there a way to order the intervals and queries such that it takes less time to query? +
    + +
    +Hint 2 +Is there a way to add and remove intervals by going from the smallest query to the largest query to find the minimum size? +
    diff --git a/problems/minimum-number-of-arrows-to-burst-balloons/README.md b/problems/minimum-number-of-arrows-to-burst-balloons/README.md index a6d98b10b..3777c4115 100644 --- a/problems/minimum-number-of-arrows-to-burst-balloons/README.md +++ b/problems/minimum-number-of-arrows-to-burst-balloons/README.md @@ -44,7 +44,7 @@

    Constraints:

      -
    • 0 <= points.length <= 104
    • +
    • 1 <= points.length <= 104
    • points[i].length == 2
    • -231 <= xstart < xend <= 231 - 1
    diff --git a/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md b/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md index f9be56862..4f4f6c114 100644 --- a/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md +++ b/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md @@ -11,13 +11,13 @@ ## [1284. Minimum Number of Flips to Convert Binary Matrix to Zero Matrix (Hard)](https://leetcode.com/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix "转化为全零矩阵的最少反转次数") -

    Given a m x n binary matrix mat. In one step, you can choose one cell and flip it and all the four neighbours of it if they exist (Flip is changing 1 to 0 and 0 to 1). A pair of cells are called neighboors if they share one edge.

    +

    Given a m x n binary matrix mat. In one step, you can choose one cell and flip it and all the four neighbors of it if they exist (Flip is changing 1 to 0 and 0 to 1). A pair of cells are called neighbors if they share one edge.

    -

    Return the minimum number of steps required to convert mat to a zero matrix or -1 if you cannot.

    +

    Return the minimum number of steps required to convert mat to a zero matrix or -1 if you cannot.

    -

    Binary matrix is a matrix with all cells equal to 0 or 1 only.

    +

    A binary matrix is a matrix with all cells equal to 0 or 1 only.

    -

    Zero matrix is a matrix with all cells equal to 0.

    +

    A zero matrix is a matrix with all cells equal to 0.

     

    Example 1:

    @@ -55,11 +55,10 @@

    Constraints:

      -
    • m == mat.length
    • -
    • n == mat[0].length
    • -
    • 1 <= m <= 3
    • -
    • 1 <= n <= 3
    • -
    • mat[i][j] is 0 or 1.
    • +
    • m == mat.length
    • +
    • n == mat[i].length
    • +
    • 1 <= m, n <= 3
    • +
    • mat[i][j] is either 0 or 1.
    ### Related Topics diff --git a/problems/minimum-number-of-k-consecutive-bit-flips/README.md b/problems/minimum-number-of-k-consecutive-bit-flips/README.md index 3367943f7..d9dc21cf7 100644 --- a/problems/minimum-number-of-k-consecutive-bit-flips/README.md +++ b/problems/minimum-number-of-k-consecutive-bit-flips/README.md @@ -11,25 +11,25 @@ ## [995. Minimum Number of K Consecutive Bit Flips (Hard)](https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips "K 连续位的最小翻转次数") -

    In an array A containing only 0s and 1s, a K-bit flip consists of choosing a (contiguous) subarray of length K and simultaneously changing every 0 in the subarray to 1, and every 1 in the subarray to 0.

    +

    In an array nums containing only 0s and 1s, a k-bit flip consists of choosing a (contiguous) subarray of length k and simultaneously changing every 0 in the subarray to 1, and every 1 in the subarray to 0.

    -

    Return the minimum number of K-bit flips required so that there is no 0 in the array.  If it is not possible, return -1.

    +

    Return the minimum number of k-bit flips required so that there is no 0 in the array.  If it is not possible, return -1.

     

    Example 1:

    -Input: A = [0,1,0], K = 1
    +Input: nums = [0,1,0], k = 1
     Output: 2
    -Explanation: Flip A[0], then flip A[2].
    +Explanation: Flip nums[0], then flip nums[2].
     

    Example 2:

    -Input: A = [1,1,0], K = 2
    +Input: nums = [1,1,0], k = 2
     Output: -1
     Explanation: No matter how we flip subarrays of size 2, we can't make the array become [1,1,1].
     
    @@ -38,12 +38,12 @@

    Example 3:

    -Input: A = [0,0,0,1,0,1,1,0], K = 3
    +Input: nums = [0,0,0,1,0,1,1,0], k = 3
     Output: 3
     Explanation:
    -Flip A[0],A[1],A[2]: A becomes [1,1,1,1,0,1,1,0]
    -Flip A[4],A[5],A[6]: A becomes [1,1,1,1,1,0,0,0]
    -Flip A[5],A[6],A[7]: A becomes [1,1,1,1,1,1,1,1]
    +Flip nums[0],nums[1],nums[2]: nums becomes [1,1,1,1,0,1,1,0]
    +Flip nums[4],nums[5],nums[6]: nums becomes [1,1,1,1,1,0,0,0]
    +Flip nums[5],nums[6],nums[7]: nums becomes [1,1,1,1,1,1,1,1]
     

     

    @@ -53,8 +53,8 @@ Flip A[5],A[6],A[7]: A becomes [1,1,1,1,1,1,1,1]

    Note:

      -
    1. 1 <= A.length <= 30000
    2. -
    3. 1 <= K <= A.length
    4. +
    5. 1 <= nums.length <= 30000
    6. +
    7. 1 <= k <= nums.length
    ### Related Topics diff --git a/problems/minimum-swaps-to-make-sequences-increasing/README.md b/problems/minimum-swaps-to-make-sequences-increasing/README.md index 4f22e38ab..eec42a970 100644 --- a/problems/minimum-swaps-to-make-sequences-increasing/README.md +++ b/problems/minimum-swaps-to-make-sequences-increasing/README.md @@ -11,29 +11,29 @@ ## [801. Minimum Swaps To Make Sequences Increasing (Medium)](https://leetcode.com/problems/minimum-swaps-to-make-sequences-increasing "使序列递增的最小交换次数") -

    We have two integer sequences A and B of the same non-zero length.

    +

    We have two integer sequences nums1 and nums2 of the same non-zero length.

    -

    We are allowed to swap elements A[i] and B[i].  Note that both elements are in the same index position in their respective sequences.

    +

    We are allowed to swap elements nums1[i] and nums2[i]. Note that both elements are in the same index position in their respective sequences.

    -

    At the end of some number of swaps, A and B are both strictly increasing.  (A sequence is strictly increasing if and only if A[0] < A[1] < A[2] < ... < A[A.length - 1].)

    +

    At the end of some number of swaps, nums1 and nums2 are both strictly increasing. (An array A is strictly increasing if and only if A[0] < A[1] < A[2] < ... < A[A.length - 1].)

    -

    Given A and B, return the minimum number of swaps to make both sequences strictly increasing.  It is guaranteed that the given input always makes it possible.

    +

    Given nums1 and nums2, return the minimum number of swaps to make both sequences strictly increasing. It is guaranteed that the given input always makes it possible.

     Example:
    -Input: A = [1,3,5,4], B = [1,2,3,7]
    +Input: nums1 = [1,3,5,4], nums2 = [1,2,3,7]
     Output: 1
     Explanation: 
    -Swap A[3] and B[3].  Then the sequences are:
    -A = [1, 3, 5, 7] and B = [1, 2, 3, 4]
    +Swap nums1[3] and nums2[3].  Then the sequences are:
    +nums1 = [1, 3, 5, 7] and nums2 = [1, 2, 3, 4]
     which are both strictly increasing.
     

    Note:

      -
    • A, B are arrays with the same length, and that length will be in the range [1, 1000].
    • -
    • A[i], B[i] are integer values in the range [0, 2000].
    • +
    • nums1, nums2 are arrays with the same length, and that length will be in the range [1, 1000].
    • +
    • nums1[i], nums2[i] are integer values in the range [0, 2000].
    ### Related Topics diff --git a/problems/minimum-window-substring/README.md b/problems/minimum-window-substring/README.md index 12f62672f..a617f117b 100644 --- a/problems/minimum-window-substring/README.md +++ b/problems/minimum-window-substring/README.md @@ -11,7 +11,7 @@ ## [76. Minimum Window Substring (Hard)](https://leetcode.com/problems/minimum-window-substring "最小覆盖子串") -

    Given two strings s and t, return the minimum window in s which will contain all the characters in t. If there is no such window in s that covers all characters in t, return the empty string "".

    +

    Given two strings s and t of lengths m and n respectively, return the minimum window in s which will contain all the characters in t. If there is no such window in s that covers all characters in t, return the empty string "".

    Note that If there is such a window, it is guaranteed that there will always be only one unique minimum window in s.

    @@ -27,12 +27,14 @@

    Constraints:

      -
    • 1 <= s.length, t.length <= 105
    • +
    • m == s.length
    • +
    • n == t.length
    • +
    • 1 <= m, n <= 105
    • s and t consist of English letters.

     

    -Follow up: Could you find an algorithm that runs in O(n) time? +Follow up: Could you find an algorithm that runs in O(m + n) time? ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/monotone-increasing-digits/README.md b/problems/monotone-increasing-digits/README.md index 6e9accb6d..5edcbb4b2 100644 --- a/problems/monotone-increasing-digits/README.md +++ b/problems/monotone-increasing-digits/README.md @@ -11,36 +11,32 @@ ## [738. Monotone Increasing Digits (Medium)](https://leetcode.com/problems/monotone-increasing-digits "单调递增的数字") -

    -Given a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits. -

    -(Recall that an integer has monotone increasing digits if and only if each pair of adjacent digits x and y satisfy x <= y.) -

    +

    Given a non-negative integer n, find the largest number that is less than or equal to n with monotone increasing digits.

    + +

    (Recall that an integer has monotone increasing digits if and only if each pair of adjacent digits x and y satisfy x <= y.)

    + +

    Example 1:

    -

    Example 1:

    -Input: N = 10
    +Input: n = 10
     Output: 9
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: N = 1234
    +Input: n = 1234
     Output: 1234
     
    -

    -

    Example 3:
    +

    Example 3:

    +
    -Input: N = 332
    +Input: n = 332
     Output: 299
     
    -

    -

    Note: -N is an integer in the range [0, 10^9]. -

    +

    Note: n is an integer in the range [0, 10^9].

    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/monotonic-array/README.md b/problems/monotonic-array/README.md index 000420821..3915d8277 100644 --- a/problems/monotonic-array/README.md +++ b/problems/monotonic-array/README.md @@ -13,9 +13,9 @@

    An array is monotonic if it is either monotone increasing or monotone decreasing.

    -

    An array A is monotone increasing if for all i <= j, A[i] <= A[j].  An array A is monotone decreasing if for all i <= j, A[i] >= A[j].

    +

    An array nums is monotone increasing if for all i <= j, nums[i] <= nums[j].  An array nums is monotone decreasing if for all i <= j, nums[i] >= nums[j].

    -

    Return true if and only if the given array A is monotonic.

    +

    Return true if and only if the given array nums is monotonic.

     

    @@ -26,7 +26,7 @@

    Example 1:

    -Input: [1,2,2,3]
    +Input: nums = [1,2,2,3]
     Output: true
     
    @@ -34,7 +34,7 @@

    Example 2:

    -Input: [6,5,4,4]
    +Input: nums = [6,5,4,4]
     Output: true
     
    @@ -42,7 +42,7 @@

    Example 3:

    -Input: [1,3,2]
    +Input: nums = [1,3,2]
     Output: false
     
    @@ -50,7 +50,7 @@

    Example 4:

    -Input: [1,2,4,5]
    +Input: nums = [1,2,4,5]
     Output: true
     
    @@ -58,7 +58,7 @@

    Example 5:

    -Input: [1,1,1]
    +Input: nums = [1,1,1]
     Output: true
     
    @@ -67,8 +67,8 @@

    Note:

      -
    1. 1 <= A.length <= 50000
    2. -
    3. -100000 <= A[i] <= 100000
    4. +
    5. 1 <= nums.length <= 50000
    6. +
    7. -100000 <= nums[i] <= 100000
    diff --git a/problems/n-ary-tree-postorder-traversal/README.md b/problems/n-ary-tree-postorder-traversal/README.md index f0984b32d..356270897 100644 --- a/problems/n-ary-tree-postorder-traversal/README.md +++ b/problems/n-ary-tree-postorder-traversal/README.md @@ -46,6 +46,6 @@ [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Binary Tree Postorder Traversal](../binary-tree-postorder-traversal) (Medium) + 1. [Binary Tree Postorder Traversal](../binary-tree-postorder-traversal) (Easy) 1. [N-ary Tree Level Order Traversal](../n-ary-tree-level-order-traversal) (Medium) 1. [N-ary Tree Preorder Traversal](../n-ary-tree-preorder-traversal) (Easy) diff --git a/problems/n-repeated-element-in-size-2n-array/README.md b/problems/n-repeated-element-in-size-2n-array/README.md index ed9d656f3..42d478b21 100644 --- a/problems/n-repeated-element-in-size-2n-array/README.md +++ b/problems/n-repeated-element-in-size-2n-array/README.md @@ -11,9 +11,9 @@ ## [961. N-Repeated Element in Size 2N Array (Easy)](https://leetcode.com/problems/n-repeated-element-in-size-2n-array "重复 N 次的元素") -

    In a array A of size 2N, there are N+1 unique elements, and exactly one of these elements is repeated N times.

    +

    In a array nums of size 2 * n, there are n + 1 unique elements, and exactly one of these elements is repeated n times.

    -

    Return the element repeated N times.

    +

    Return the element repeated n times.

     

    @@ -24,7 +24,7 @@

    Example 1:

    -Input: [1,2,3,3]
    +Input: nums[1,2,3,3]
     Output: 3
     
    @@ -32,7 +32,7 @@

    Example 2:

    -Input: [2,1,2,5,3,2]
    +Input: nums[2,1,2,5,3,2]
     Output: 2
     
    @@ -40,7 +40,7 @@

    Example 3:

    -Input: [5,1,5,2,5,3,5,4]
    +Input: nums[5,1,5,2,5,3,5,4]
     Output: 5
     
    @@ -49,9 +49,9 @@

    Note:

      -
    • 4 <= A.length <= 10000
    • -
    • 0 <= A[i] < 10000
    • -
    • A.length is even
    • +
    • 4 <= nums.length <= 10000
    • +
    • 0 <= nums[i] < 10000
    • +
    • nums.length is even
    diff --git a/problems/new-21-game/README.md b/problems/new-21-game/README.md index e6b258219..9b5fd46cf 100644 --- a/problems/new-21-game/README.md +++ b/problems/new-21-game/README.md @@ -11,43 +11,48 @@ ## [837. New 21 Game (Medium)](https://leetcode.com/problems/new-21-game "新21点") -

    Alice plays the following game, loosely based on the card game "21".

    +

    Alice plays the following game, loosely based on the card game "21".

    -

    Alice starts with 0 points, and draws numbers while she has less than K points.  During each draw, she gains an integer number of points randomly from the range [1, W], where W is an integer.  Each draw is independent and the outcomes have equal probabilities.

    +

    Alice starts with 0 points and draws numbers while she has less than k points. During each draw, she gains an integer number of points randomly from the range [1, maxPts], where maxPts is an integer. Each draw is independent and the outcomes have equal probabilities.

    -

    Alice stops drawing numbers when she gets K or more points.  What is the probability that she has N or less points?

    +

    Alice stops drawing numbers when she gets k or more points.

    +

    Return the probability that Alice has n or fewer points.

    + +

    Answers within 10-5 of the actual answer are considered accepted.

    + +

     

    Example 1:

    -Input: N = 10, K = 1, W = 10
    -Output: 1.00000
    -Explanation:  Alice gets a single card, then stops.
    +Input: n = 10, k = 1, maxPts = 10
    +Output: 1.00000
    +Explanation: Alice gets a single card, then stops.
     

    Example 2:

    -Input: N = 6, K = 1, W = 10
    -Output: 0.60000
    -Explanation:  Alice gets a single card, then stops.
    -In 6 out of W = 10 possibilities, she is at or below N = 6 points.
    +Input: n = 6, k = 1, maxPts = 10
    +Output: 0.60000
    +Explanation: Alice gets a single card, then stops.
    +In 6 out of 10 possibilities, she is at or below 6 points.
     

    Example 3:

    -Input: N = 21, K = 17, W = 10
    -Output: 0.73278
    +Input: n = 21, k = 17, maxPts = 10 +Output: 0.73278 +
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. 0 <= K <= N <= 10000
    2. -
    3. 1 <= W <= 10000
    4. -
    5. Answers will be accepted as correct if they are within 10^-5 of the correct answer.
    6. -
    7. The judging time limit has been reduced for this question.
    8. -
    +
      +
    • 0 <= k <= n <= 104
    • +
    • 1 <= maxPts <= 104
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/next-palindrome-using-same-digits/README.md b/problems/next-palindrome-using-same-digits/README.md new file mode 100644 index 000000000..8ccfec3cc --- /dev/null +++ b/problems/next-palindrome-using-same-digits/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../league-statistics "League Statistics") +                 +[Next >](../suspicious-bank-accounts "Suspicious Bank Accounts") + +## [1842. Next Palindrome Using Same Digits (Hard)](https://leetcode.com/problems/next-palindrome-using-same-digits "") + + + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Is it possible to swap one character in the first half of the palindrome to make the next one? +
    + +
    +Hint 2 +Are there different cases for when the length is odd and even? +
    diff --git a/problems/number-of-distinct-islands/README.md b/problems/number-of-distinct-islands/README.md index 5148275d5..f3988ddb0 100644 --- a/problems/number-of-distinct-islands/README.md +++ b/problems/number-of-distinct-islands/README.md @@ -50,6 +50,7 @@ The length of each dimension in the given grid does not exceed 50. ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions diff --git a/problems/number-of-music-playlists/README.md b/problems/number-of-music-playlists/README.md index 03d3874e3..15f82633b 100644 --- a/problems/number-of-music-playlists/README.md +++ b/problems/number-of-music-playlists/README.md @@ -11,14 +11,14 @@ ## [920. Number of Music Playlists (Hard)](https://leetcode.com/problems/number-of-music-playlists "播放列表的数量") -

    Your music player contains N different songs and she wants to listen to L (not necessarily different) songs during your trip.  You create a playlist so that:

    +

    Your music player contains n different songs and she wants to listen to goal (not necessarily different) songs during your trip.  You create a playlist so that:

    • Every song is played at least once
    • -
    • A song can only be played again only if K other songs have been played
    • +
    • A song can only be played again only if k other songs have been played
    -

    Return the number of possible playlists.  As the answer can be very large, return it modulo 10^9 + 7.

    +

    Return the number of possible playlists.  As the answer can be very large, return it modulo 109 + 7.

     

    @@ -28,7 +28,7 @@

    Example 1:

    -Input: N = 3, L = 3, K = 1
    +Input: n = 3, goal = 3, k = 1
     Output: 6
     Explanation: There are 6 possible playlists. [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1].
     
    @@ -37,7 +37,7 @@

    Example 2:

    -Input: N = 2, L = 3, K = 0
    +Input: n = 2, goal = 3, k = 0
     Output: 6
     Explanation: There are 6 possible playlists. [1, 1, 2], [1, 2, 1], [2, 1, 1], [2, 2, 1], [2, 1, 2], [1, 2, 2]
     
    @@ -46,7 +46,7 @@

    Example 3:

    -Input: N = 2, L = 3, K = 1
    +Input: n = 2, goal = 3, k = 1
     Output: 2
     Explanation: There are 2 possible playlists. [1, 2, 1], [2, 1, 2]
     
    @@ -58,7 +58,7 @@

    Note:

      -
    1. 0 <= K < N <= L <= 100
    2. +
    3. 0 <= k < n <= goal <= 100
    diff --git a/problems/number-of-squareful-arrays/README.md b/problems/number-of-squareful-arrays/README.md index d405b7b41..8457dde14 100644 --- a/problems/number-of-squareful-arrays/README.md +++ b/problems/number-of-squareful-arrays/README.md @@ -11,16 +11,16 @@ ## [996. Number of Squareful Arrays (Hard)](https://leetcode.com/problems/number-of-squareful-arrays "正方形数组的数目") -

    Given an array A of non-negative integers, the array is squareful if for every pair of adjacent elements, their sum is a perfect square.

    +

    Given an array nums of non-negative integers, the array is squareful if for every pair of adjacent elements, their sum is a perfect square.

    -

    Return the number of permutations of A that are squareful.  Two permutations A1 and A2 differ if and only if there is some index i such that A1[i] != A2[i].

    +

    Return the number of permutations of nums that are squareful.  Two permutations perm1 and perm2 differ if and only if there is some index i such that perm1[i] != perm2[i].

     

    Example 1:

    -Input: [1,17,8]
    +Input: nums = [1,17,8]
     Output: 2
     Explanation: 
     [1,8,17] and [17,8,1] are the valid permutations.
    @@ -29,7 +29,7 @@
     

    Example 2:

    -Input: [2,2,2]
    +Input: nums = [2,2,2]
     Output: 1
     
    @@ -38,8 +38,8 @@

    Note:

      -
    1. 1 <= A.length <= 12
    2. -
    3. 0 <= A[i] <= 1e9
    4. +
    5. 1 <= nums.length <= 12
    6. +
    7. 0 <= nums[i] <= 109
    ### Related Topics diff --git a/problems/number-of-subarrays-with-bounded-maximum/README.md b/problems/number-of-subarrays-with-bounded-maximum/README.md index 47f6125cd..ad4fda974 100644 --- a/problems/number-of-subarrays-with-bounded-maximum/README.md +++ b/problems/number-of-subarrays-with-bounded-maximum/README.md @@ -11,16 +11,16 @@ ## [795. Number of Subarrays with Bounded Maximum (Medium)](https://leetcode.com/problems/number-of-subarrays-with-bounded-maximum "区间子数组个数") -

    We are given an array A of positive integers, and two positive integers L and R (L <= R).

    +

    We are given an array nums of positive integers, and two positive integers left and right (left <= right).

    -

    Return the number of (contiguous, non-empty) subarrays such that the value of the maximum array element in that subarray is at least L and at most R.

    +

    Return the number of (contiguous, non-empty) subarrays such that the value of the maximum array element in that subarray is at least left and at most right.

    -Example :
    +Example:
     Input: 
    -A = [2, 1, 4, 3]
    -L = 2
    -R = 3
    +nums = [2, 1, 4, 3]
    +left = 2
    +right = 3
     Output: 3
     Explanation: There are three subarrays that meet the requirements: [2], [2, 1], [3].
     
    @@ -28,8 +28,8 @@ R = 3

    Note:

      -
    • L, R  and A[i] will be an integer in the range [0, 10^9].
    • -
    • The length of A will be in the range of [1, 50000].
    • +
    • left, right, and nums[i] will be an integer in the range [0, 109].
    • +
    • The length of nums will be in the range of [1, 50000].
    ### Related Topics diff --git a/problems/optimal-division/README.md b/problems/optimal-division/README.md index 3dd845203..b0a03ae83 100644 --- a/problems/optimal-division/README.md +++ b/problems/optimal-division/README.md @@ -11,33 +11,56 @@ ## [553. Optimal Division (Medium)](https://leetcode.com/problems/optimal-division "最优除法") -

    Given a list of positive integers, the adjacent integers will perform the float division. For example, [2,3,4] -> 2 / 3 / 4.

    +

    You are given an integer array nums. The adjacent integers in nums will perform the float division.

    -

    However, you can add any number of parenthesis at any position to change the priority of operations. You should find out how to add parenthesis to get the maximum result, and return the corresponding expression in string format. Your expression should NOT contain redundant parenthesis.

    +
      +
    • For example, for nums = [2,3,4], we will evaluate the expression "2/3/4".
    • +
    + +

    However, you can add any number of parenthesis at any position to change the priority of operations. You want to add these parentheses such the value of the expression after the evaluation is maximum.

    + +

    Return the corresponding expression that has the maximum value in string format.

    + +

    Note: your expression should not contain redundant parenthesis.

    + +

     

    +

    Example 1:

    -

    Example:

    -Input: [1000,100,10,2]
    -Output: "1000/(100/10/2)"
    -Explanation:
    +Input: nums = [1000,100,10,2]
    +Output: "1000/(100/10/2)"
    +Explanation:
     1000/(100/10/2) = 1000/((100/10)/2) = 200
    -However, the bold parenthesis in "1000/((100/10)/2)" are redundant, 
    since they don't influence the operation priority. So you should return "1000/(100/10/2)". - +However, the bold parenthesis in "1000/((100/10)/2)" are redundant, since they don't influence the operation priority. So you should return "1000/(100/10/2)". Other cases: 1000/(100/10)/2 = 50 1000/(100/(10/2)) = 50 1000/100/10/2 = 0.5 1000/100/(10/2) = 2
    -

    - -

    Note: -

      -
    1. The length of the input array is [1, 10].
    2. -
    3. Elements in the given array will be in range [2, 1000].
    4. -
    5. There is only one optimal division for each test case.
    6. -
    -

    + +

    Example 2:

    + +
    +Input: nums = [2,3,4]
    +Output: "2/(3/4)"
    +
    + +

    Example 3:

    + +
    +Input: nums = [2]
    +Output: "2"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 10
    • +
    • 2 <= nums[i] <= 1000
    • +
    • There is only one optimal division for the given iput.
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/orderly-queue/README.md b/problems/orderly-queue/README.md index f245fb700..3d2ae9f57 100644 --- a/problems/orderly-queue/README.md +++ b/problems/orderly-queue/README.md @@ -11,9 +11,9 @@ ## [899. Orderly Queue (Hard)](https://leetcode.com/problems/orderly-queue "有序队列") -

    A string S of lowercase letters is given.  Then, we may make any number of moves.

    +

    A string s of lowercase letters is given.  Then, we may make any number of moves.

    -

    In each move, we choose one of the first K letters (starting from the left), remove it, and place it at the end of the string.

    +

    In each move, we choose one of the first k letters (starting from the left), remove it, and place it at the end of the string.

    Return the lexicographically smallest string we could have after any number of moves.

    @@ -23,7 +23,7 @@

    Example 1:

    -Input: S = "cba", K = 1
    +Input: s = "cba", k = 1
     Output: "acb"
     Explanation: 
     In the first move, we move the 1st character ("c") to the end, obtaining the string "bac".
    @@ -34,7 +34,7 @@ In the second move, we move the 1st character ("b") to the end, obtain
     

    Example 2:

    -Input: S = "baaca", K = 3
    +Input: s = "baaca", k = 3
     Output: "aaabc"
     Explanation: 
     In the first move, we move the 1st character ("b") to the end, obtaining the string "aacab".
    @@ -46,8 +46,8 @@ In the second move, we move the 3rd character ("c") to the end, obtain
     

    Note:

      -
    1. 1 <= K <= S.length <= 1000
    2. -
    3. S consists of lowercase letters only.
    4. +
    5. 1 <= k <= s.length <= 1000
    6. +
    7. s consists of lowercase letters only.
    diff --git a/problems/out-of-boundary-paths/README.md b/problems/out-of-boundary-paths/README.md index 31811361b..d8d7d46e1 100644 --- a/problems/out-of-boundary-paths/README.md +++ b/problems/out-of-boundary-paths/README.md @@ -11,37 +11,34 @@ ## [576. Out of Boundary Paths (Medium)](https://leetcode.com/problems/out-of-boundary-paths "出界的路径数") -

    There is an m by n grid with a ball. Given the start coordinate (i,j) of the ball, you can move the ball to adjacent cell or cross the grid boundary in four directions (up, down, left, right). However, you can at most move N times. Find out the number of paths to move the ball out of grid boundary. The answer may be very large, return it after mod 109 + 7.

    +

    There is an m x n grid with a ball. The ball is initially at the position [startRow, startColumn]. You are allowed to move the ball to one of the four adjacent four cells in the grid (possibly out of the grid crossing the grid boundary). You can apply at most maxMove moves to the ball.

    -

     

    - -

    Example 1:

    +

    Given the five integers m, n, maxMove, startRow, startColumn, return the number of paths to move the ball out of the grid boundary. Since the answer can be very large, return it modulo 109 + 7.

    +

     

    +

    Example 1:

    +
    -Input: m = 2, n = 2, N = 2, i = 0, j = 0
    -Output: 6
    -Explanation:
    -
    +Input: m = 2, n = 2, maxMove = 2, startRow = 0, startColumn = 0
    +Output: 6
     
    -

    Example 2:

    - +

    Example 2:

    +
    -Input: m = 1, n = 3, N = 3, i = 0, j = 1
    -Output: 12
    -Explanation:
    -
    +Input: m = 1, n = 3, maxMove = 3, startRow = 0, startColumn = 1
    +Output: 12
     

     

    - -

    Note:

    - -
      -
    1. Once you move the ball out of boundary, you cannot move it back.
    2. -
    3. The length and height of the grid is in range [1,50].
    4. -
    5. N is in range [0,50].
    6. -
    +

    Constraints:

    + +
      +
    • 1 <= m, n <= 50
    • +
    • 0 <= maxMove <= 50
    • +
    • 0 <= startRow <= m
    • +
    • 0 <= startColumn <= n
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/palindromic-substrings/README.md b/problems/palindromic-substrings/README.md index 05e2e21f5..7d549d549 100644 --- a/problems/palindromic-substrings/README.md +++ b/problems/palindromic-substrings/README.md @@ -11,37 +11,36 @@ ## [647. Palindromic Substrings (Medium)](https://leetcode.com/problems/palindromic-substrings "回文子串") -

    Given a string, your task is to count how many palindromic substrings in this string.

    +

    Given a string s, return the number of palindromic substrings in it.

    -

    The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters.

    +

    A string is a palindrome when it reads the same backward as forward.

    -

    Example 1:

    +

    A substring is a contiguous sequence of characters within the string.

    + +

     

    +

    Example 1:

    -Input: "abc"
    -Output: 3
    -Explanation: Three palindromic strings: "a", "b", "c".
    +Input: s = "abc"
    +Output: 3
    +Explanation: Three palindromic strings: "a", "b", "c".
     
    -

     

    - -

    Example 2:

    +

    Example 2:

    -Input: "aaa"
    -Output: 6
    -Explanation: Six palindromic strings: "a", "a", "a", "aa", "aa", "aaa".
    +Input: s = "aaa"
    +Output: 6
    +Explanation: Six palindromic strings: "a", "a", "a", "aa", "aa", "aaa".
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. The input string length won't exceed 1000.
    2. -
    - -

     

    +
      +
    • 1 <= s.length <= 1000
    • +
    • s consists of lowercase English letters.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/partition-array-for-maximum-sum/README.md b/problems/partition-array-for-maximum-sum/README.md index 6358fac36..996870cfb 100644 --- a/problems/partition-array-for-maximum-sum/README.md +++ b/problems/partition-array-for-maximum-sum/README.md @@ -11,9 +11,9 @@ ## [1043. Partition Array for Maximum Sum (Medium)](https://leetcode.com/problems/partition-array-for-maximum-sum "分隔数组以得到最大和") -

    Given an integer array arr, you should partition the array into (contiguous) subarrays of length at most k. After partitioning, each subarray has their values changed to become the maximum value of that subarray.

    +

    Given an integer array arr, partition the array into (contiguous) subarrays of length at most k. After partitioning, each subarray has their values changed to become the maximum value of that subarray.

    -

    Return the largest sum of the given array after partitioning.

    +

    Return the largest sum of the given array after partitioning. Test cases are generated so that the answer fits in a 32-bit integer.

     

    Example 1:

    diff --git a/problems/partition-array-into-disjoint-intervals/README.md b/problems/partition-array-into-disjoint-intervals/README.md index 28bb1ce3f..6f9349413 100644 --- a/problems/partition-array-into-disjoint-intervals/README.md +++ b/problems/partition-array-into-disjoint-intervals/README.md @@ -11,7 +11,7 @@ ## [915. Partition Array into Disjoint Intervals (Medium)](https://leetcode.com/problems/partition-array-into-disjoint-intervals "分割数组") -

    Given an array A, partition it into two (contiguous) subarrays left and right so that:

    +

    Given an array nums, partition it into two (contiguous) subarrays left and right so that:

    • Every element in left is less than or equal to every element in right.
    • @@ -26,7 +26,7 @@

      Example 1:

      -Input: [5,0,3,8,6]
      +Input: nums = [5,0,3,8,6]
       Output: 3
       Explanation: left = [5,0,3], right = [8,6]
       
      @@ -35,7 +35,7 @@

      Example 2:

      -Input: [1,1,1,0,6,12]
      +Input: nums = [1,1,1,0,6,12]
       Output: 4
       Explanation: left = [1,1,1,0], right = [6,12]
       
      @@ -46,9 +46,9 @@

      Note:

        -
      1. 2 <= A.length <= 30000
      2. -
      3. 0 <= A[i] <= 10^6
      4. -
      5. It is guaranteed there is at least one way to partition A as described.
      6. +
      7. 2 <= nums.length <= 30000
      8. +
      9. 0 <= nums[i] <= 106
      10. +
      11. It is guaranteed there is at least one way to partition nums as described.
      diff --git a/problems/partition-labels/README.md b/problems/partition-labels/README.md index b635ead5e..f2199f2a7 100644 --- a/problems/partition-labels/README.md +++ b/problems/partition-labels/README.md @@ -11,19 +11,19 @@ ## [763. Partition Labels (Medium)](https://leetcode.com/problems/partition-labels "划分字母区间") -

      A string S of lowercase English letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing the size of these parts.

      +

      A string s of lowercase English letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing the size of these parts.

       

      Example 1:

      -Input: S = "ababcbacadefegdehijhklij"
      +Input: s = "ababcbacadefegdehijhklij"
       Output: [9,7,8]
       Explanation:
       The partition is "ababcbaca", "defegde", "hijhklij".
       This is a partition so that each letter appears in at most one part.
      -A partition like "ababcbacadefegde", "hijhklij" is incorrect, because it splits S into less parts.
      +A partition like "ababcbacadefegde", "hijhklij" is incorrect, because it splits s into less parts.
       

       

      @@ -31,8 +31,8 @@ A partition like "ababcbacadefegde", "hijhklij" is incorrect

      Note:

        -
      • S will have length in range [1, 500].
      • -
      • S will consist of lowercase English letters ('a' to 'z') only.
      • +
      • s will have length in range [1, 500].
      • +
      • s will consist of lowercase English letters ('a' to 'z') only.

       

      diff --git a/problems/path-crossing/README.md b/problems/path-crossing/README.md index 8899d515d..59a783cad 100644 --- a/problems/path-crossing/README.md +++ b/problems/path-crossing/README.md @@ -11,15 +11,13 @@ ## [1496. Path Crossing (Easy)](https://leetcode.com/problems/path-crossing "判断路径是否相交") -

      Given a string path, where path[i] = 'N', 'S', 'E' or 'W', each representing moving one unit north, south, east, or west, respectively. You start at the origin (0, 0) on a 2D plane and walk on the path specified by path.

      +

      Given a string path, where path[i] = 'N', 'S', 'E' or 'W', each representing moving one unit north, south, east, or west, respectively. You start at the origin (0, 0) on a 2D plane and walk on the path specified by path.

      -

      Return True if the path crosses itself at any point, that is, if at any time you are on a location you've previously visited. Return False otherwise.

      +

      Return true if the path crosses itself at any point, that is, if at any time you are on a location you have previously visited. Return false otherwise.

       

      Example 1:

      - -

      - +
       Input: path = "NES"
       Output: false 
      @@ -27,9 +25,7 @@
       

      Example 2:

      - -

      - +
       Input: path = "NESWW"
       Output: true
      @@ -39,8 +35,8 @@
       

      Constraints:

        -
      • 1 <= path.length <= 10^4
      • -
      • path will only consist of characters in {'N', 'S', 'E', 'W}
      • +
      • 1 <= path.length <= 104
      • +
      • path[i] is either 'N', 'S', 'E', or 'W'.
      ### Related Topics diff --git a/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md b/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md index 9e3302460..d10ea4d3c 100644 --- a/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md +++ b/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md @@ -13,7 +13,7 @@

      Given the array favoriteCompanies where favoriteCompanies[i] is the list of favorites companies for the ith person (indexed from 0).

      -

      Return the indices of people whose list of favorite companies is not a subset of any other list of favorites companies. You must return the indices in increasing order.

      +

      Return the indices of people whose list of favorite companies is not a subset of any other list of favorites companies. You must return the indices in increasing order.

       

      Example 1:

      @@ -46,9 +46,9 @@ Other lists of favorite companies are not a subset of another list, therefore, t

      Constraints:

        -
      • 1 <= favoriteCompanies.length <= 100
      • -
      • 1 <= favoriteCompanies[i].length <= 500
      • -
      • 1 <= favoriteCompanies[i][j].length <= 20
      • +
      • 1 <= favoriteCompanies.length <= 100
      • +
      • 1 <= favoriteCompanies[i].length <= 500
      • +
      • 1 <= favoriteCompanies[i][j].length <= 20
      • All strings in favoriteCompanies[i] are distinct.
      • All lists of favorite companies are distinct, that is, If we sort alphabetically each list then favoriteCompanies[i] != favoriteCompanies[j].
      • All strings consist of lowercase English letters only.
      • diff --git a/problems/possible-bipartition/README.md b/problems/possible-bipartition/README.md index 998f93166..42180c352 100644 --- a/problems/possible-bipartition/README.md +++ b/problems/possible-bipartition/README.md @@ -11,7 +11,7 @@ ## [886. Possible Bipartition (Medium)](https://leetcode.com/problems/possible-bipartition "可能的二分法") -

        Given a set of N people (numbered 1, 2, ..., N), we would like to split everyone into two groups of any size.

        +

        Given a set of n people (numbered 1, 2, ..., n), we would like to split everyone into two groups of any size.

        Each person may dislike some other people, and they should not go into the same group. 

        @@ -32,7 +32,7 @@

        Example 1:

        -Input: N = 4, dislikes = [[1,2],[1,3],[2,4]]
        +Input: n = 4, dislikes = [[1,2],[1,3],[2,4]]
         Output: true
         Explanation: group1 [1,4], group2 [2,3]
         
        @@ -41,7 +41,7 @@

        Example 2:

        -Input: N = 3, dislikes = [[1,2],[1,3],[2,3]]
        +Input: n = 3, dislikes = [[1,2],[1,3],[2,3]]
         Output: false
         
        @@ -49,7 +49,7 @@

        Example 3:

        -Input: N = 5, dislikes = [[1,2],[2,3],[3,4],[4,5],[1,5]]
        +Input: n = 5, dislikes = [[1,2],[2,3],[3,4],[4,5],[1,5]]
         Output: false
         
      @@ -60,10 +60,10 @@

      Constraints:

        -
      • 1 <= N <= 2000
      • +
      • 1 <= n <= 2000
      • 0 <= dislikes.length <= 10000
      • dislikes[i].length == 2
      • -
      • 1 <= dislikes[i][j] <= N
      • +
      • 1 <= dislikes[i][j] <= n
      • dislikes[i][0] < dislikes[i][1]
      • There does not exist i != j for which dislikes[i] == dislikes[j].
      diff --git a/problems/prefix-and-suffix-search/README.md b/problems/prefix-and-suffix-search/README.md index 1b09db9e2..bad5c6e7d 100644 --- a/problems/prefix-and-suffix-search/README.md +++ b/problems/prefix-and-suffix-search/README.md @@ -11,13 +11,13 @@ ## [745. Prefix and Suffix Search (Hard)](https://leetcode.com/problems/prefix-and-suffix-search "前缀和后缀搜索") -

      Design a special dictionary which has some words and allows you to search the words in it by a prefix and a suffix.

      +

      Design a special dictionary with some words that searchs the words in it by a prefix and a suffix.

      Implement the WordFilter class:

      • WordFilter(string[] words) Initializes the object with the words in the dictionary.
      • -
      • f(string prefix, string suffix) Returns the index of the word in the dictionary which has the prefix prefix and the suffix suffix. If there is more than one valid index, return the largest of them. If there is no such word in the dictionary, return -1.
      • +
      • f(string prefix, string suffix) Returns the index of the word in the dictionary, which has the prefix prefix and the suffix suffix. If there is more than one valid index, return the largest of them. If there is no such word in the dictionary, return -1.

       

      @@ -41,7 +41,7 @@ wordFilter.f("a", "e"); // return 0, because the word at ind
      • 1 <= words.length <= 15000
      • 1 <= words[i].length <= 10
      • -
      • 1 <= prefix.length, suffix.length <= 10
      • +
      • 1 <= prefix.length, suffix.length <= 10
      • words[i], prefix and suffix consist of lower-case English letters only.
      • At most 15000 calls will be made to the function f.
      diff --git a/problems/preimage-size-of-factorial-zeroes-function/README.md b/problems/preimage-size-of-factorial-zeroes-function/README.md index 2362656ce..d28c888a4 100644 --- a/problems/preimage-size-of-factorial-zeroes-function/README.md +++ b/problems/preimage-size-of-factorial-zeroes-function/README.md @@ -13,24 +13,24 @@

      Let f(x) be the number of zeroes at the end of x!. (Recall that x! = 1 * 2 * 3 * ... * x, and by convention, 0! = 1.)

      -

      For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has 2 zeroes at the end. Given K, find how many non-negative integers x have the property that f(x) = K.

      +

      For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has 2 zeroes at the end. Given k, find how many non-negative integers x have the property that f(x) = k.

       Example 1:
      -Input: K = 0
      +Input: k = 0
       Output: 5
      -Explanation: 0!, 1!, 2!, 3!, and 4! end with K = 0 zeroes.
      +Explanation: 0!, 1!, 2!, 3!, and 4! end with k = 0 zeroes.
       
       Example 2:
      -Input: K = 5
      +Input: k = 5
       Output: 0
      -Explanation: There is no x such that x! ends in K = 5 zeroes.
      +Explanation: There is no x such that x! ends in k = 5 zeroes.
       

      Note:

        -
      • K will be an integer in the range [0, 10^9].
      • +
      • k will be an integer in the range [0, 109].
      ### Related Topics diff --git a/problems/prime-number-of-set-bits-in-binary-representation/README.md b/problems/prime-number-of-set-bits-in-binary-representation/README.md index 6baa890be..8000228fe 100644 --- a/problems/prime-number-of-set-bits-in-binary-representation/README.md +++ b/problems/prime-number-of-set-bits-in-binary-representation/README.md @@ -11,38 +11,42 @@ ## [762. Prime Number of Set Bits in Binary Representation (Easy)](https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation "二进制表示中质数个计算置位") -

      -Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary representation. -

      -(Recall that the number of set bits an integer has is the number of 1s present when written in binary. For example, 21 written in binary is 10101 which has 3 set bits. Also, 1 is not a prime.) -

      - -

      Example 1:

      -Input: L = 6, R = 10
      +

      Given two integers left and right, find the count of numbers in the range [left, right] (inclusive) having a prime number of set bits in their binary representation.

      + +

      (Recall that the number of set bits an integer has is the number of 1s present when written in binary. For example, 21 written in binary is 10101 which has 3 set bits. Also, 1 is not a prime.)

      + +

      Example 1:

      + +
      +Input: left = 6, right = 10
       Output: 4
       Explanation:
      -6 -> 110 (2 set bits, 2 is prime)
      -7 -> 111 (3 set bits, 3 is prime)
      -9 -> 1001 (2 set bits , 2 is prime)
      -10->1010 (2 set bits , 2 is prime)
      -

      - -

      Example 2:

      -Input: L = 10, R = 15
      +6 -> 110 (2 set bits, 2 is prime)
      +7 -> 111 (3 set bits, 3 is prime)
      +9 -> 1001 (2 set bits , 2 is prime)
      +10->1010 (2 set bits , 2 is prime)
      +
      + +

      Example 2:

      + +
      +Input: left = 10, right = 15
       Output: 5
       Explanation:
      -10 -> 1010 (2 set bits, 2 is prime)
      -11 -> 1011 (3 set bits, 3 is prime)
      -12 -> 1100 (2 set bits, 2 is prime)
      -13 -> 1101 (3 set bits, 3 is prime)
      -14 -> 1110 (3 set bits, 3 is prime)
      -15 -> 1111 (4 set bits, 4 is not prime)
      -

      - -

      Note:

        -
      1. L, R will be integers L <= R in the range [1, 10^6].
      2. -
      3. R - L will be at most 10000.
      4. -

      +10 -> 1010 (2 set bits, 2 is prime) +11 -> 1011 (3 set bits, 3 is prime) +12 -> 1100 (2 set bits, 2 is prime) +13 -> 1101 (3 set bits, 3 is prime) +14 -> 1110 (3 set bits, 3 is prime) +15 -> 1111 (4 set bits, 4 is not prime) +
      + +

      Note:

      + +
        +
      1. left, right will be integers left <= right in the range [1, 10^6].
      2. +
      3. right - left will be at most 10000.
      4. +
      ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/prime-palindrome/README.md b/problems/prime-palindrome/README.md index a5b7dfaa6..0bb6264d7 100644 --- a/problems/prime-palindrome/README.md +++ b/problems/prime-palindrome/README.md @@ -11,7 +11,7 @@ ## [866. Prime Palindrome (Medium)](https://leetcode.com/problems/prime-palindrome "回文素数") -

      Find the smallest prime palindrome greater than or equal to N.

      +

      Find the smallest prime palindrome greater than or equal to n.

      Recall that a number is prime if it's only divisors are 1 and itself, and it is greater than 1. 

      @@ -27,7 +27,7 @@

      Example 1:

      -Input: 6
      +Input: n = 6
       Output: 7
       
      @@ -35,7 +35,7 @@

      Example 2:

      -Input: 8
      +Input: n = 8
       Output: 11
       
      @@ -43,7 +43,7 @@

      Example 3:

      -Input: 13
      +Input: n = 13
       Output: 101
      @@ -54,8 +54,8 @@

      Note:

        -
      • 1 <= N <= 10^8
      • -
      • The answer is guaranteed to exist and be less than 2 * 10^8.
      • +
      • 1 <= n <= 108
      • +
      • The answer is guaranteed to exist and be less than 2 * 108.
      ### Related Topics diff --git a/problems/print-binary-tree/README.md b/problems/print-binary-tree/README.md index c313e3106..803337b09 100644 --- a/problems/print-binary-tree/README.md +++ b/problems/print-binary-tree/README.md @@ -11,66 +11,44 @@ ## [655. Print Binary Tree (Medium)](https://leetcode.com/problems/print-binary-tree "输出二叉树") -

      Print a binary tree in an m*n 2D string array following these rules:

      - -
        -
      1. The row number m should be equal to the height of the given binary tree.
      2. -
      3. The column number n should always be an odd number.
      4. -
      5. The root node's value (in string format) should be put in the exactly middle of the first row it can be put. The column and the row where the root node belongs will separate the rest space into two parts (left-bottom part and right-bottom part). You should print the left subtree in the left-bottom part and print the right subtree in the right-bottom part. The left-bottom part and the right-bottom part should have the same size. Even if one subtree is none while the other is not, you don't need to print anything for the none subtree but still need to leave the space as large as that for the other subtree. However, if two subtrees are none, then you don't need to leave space for both of them.
      6. -
      7. Each unused space should contain an empty string "".
      8. -
      9. Print the subtrees following the same rules.
      10. -
      - -

      Example 1:
      +

      Print a binary tree in an m x n 2D string array following these rules:

      + +
        +
      • The row numbers m should be equal to the height of the given binary tree.
      • +
      • The column number n should always be an odd number.
      • +
      • The root node's value (in string format) should be put in the exact middle of the first row it can be put. The column and the row where the root node belongs will separate the rest space into two parts (left-bottom part and right-bottom part). You should print the left subtree in the left-bottom part and print the right subtree in the right-bottom part. The left-bottom part and the right-bottom part should have the same size. Even if one subtree is none while the other is not, you don't need to print anything for the none subtree but still need to leave the space as large as that for the other subtree. However, if two subtrees are none, then you don't need to leave space for both of them.
      • +
      • Each unused space should contain an empty string "".
      • +
      • Print the subtrees following the same rules.
      • +
      + +

       

      +

      Example 1:

      +
      -Input:
      -     1
      -    /
      -   2
      -Output:
      -[["", "1", ""],
      - ["2", "", ""]]
      +Input: root = [1,2]
      +Output: 
      +[["","1",""],
      + ["2","",""]]
       
      -

      - -

      Example 2:
      +

      Example 2:

      +
      -Input:
      -     1
      -    / \
      -   2   3
      -    \
      -     4
      -Output:
      -[["", "", "", "1", "", "", ""],
      - ["", "2", "", "", "", "3", ""],
      - ["", "", "4", "", "", "", ""]]
      +Input: root = [1,2,3,null,4]
      +Output: 
      +[["","","","1","","",""],
      + ["","2","","","","3",""],
      + ["","","4","","","",""]]
       
      -

      -

      Example 3:
      -

      -Input:
      -      1
      -     / \
      -    2   5
      -   / 
      -  3 
      - / 
      -4 
      -Output:
      -
      -[["",  "",  "", "",  "", "", "", "1", "",  "",  "",  "",  "", "", ""]
      - ["",  "",  "", "2", "", "", "", "",  "",  "",  "",  "5", "", "", ""]
      - ["",  "3", "", "",  "", "", "", "",  "",  "",  "",  "",  "", "", ""]
      - ["4", "",  "", "",  "", "", "", "",  "",  "",  "",  "",  "", "", ""]]
      -
      -

      +

       

      +

      Constraints:

      -

      Note: -The height of binary tree is in the range of [1, 10]. -

      +
        +
      • The number of nodes in the tree is in the range [1, 210].
      • +
      • -99 <= Node.val <= 99
      • +
      • The depth of the tree will be in the range [1, 10].
      • +
      ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/product-of-array-except-self/README.md b/problems/product-of-array-except-self/README.md index 722405440..a78fdf05c 100644 --- a/problems/product-of-array-except-self/README.md +++ b/problems/product-of-array-except-self/README.md @@ -15,6 +15,8 @@

      The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.

      +

      You must write an algorithm that runs in O(n) time and without using the division operation.

      +

       

      Example 1:

      Input: nums = [1,2,3,4]
      @@ -33,12 +35,7 @@
       

     

    -

    Follow up:

    - -
      -
    • Could you solve it in O(n) time complexity and without using division?
    • -
    • Could you solve it with O(1) constant space complexity? (The output array does not count as extra space for space complexity analysis.)
    • -
    +

    Follow up: Can you solve the problem in O(1) extra space complexity? (The output array does not count as extra space for space complexity analysis.)

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/race-car/README.md b/problems/race-car/README.md index 036b3d397..65ab13f54 100644 --- a/problems/race-car/README.md +++ b/problems/race-car/README.md @@ -11,44 +11,53 @@ ## [818. Race Car (Hard)](https://leetcode.com/problems/race-car "赛车") -

    Your car starts at position 0 and speed +1 on an infinite number line.  (Your car can go into negative positions.)

    +

    Your car starts at position 0 and speed +1 on an infinite number line. Your car can go into negative positions. Your car drives automatically according to a sequence of instructions 'A' (accelerate) and 'R' (reverse):

    -

    Your car drives automatically according to a sequence of instructions A (accelerate) and R (reverse).

    - -

    When you get an instruction "A", your car does the following: position += speed, speed *= 2.

    +
      +
    • When you get an instruction 'A', your car does the following: +
        +
      • position += speed
      • +
      • speed *= 2
      • +
      +
    • +
    • When you get an instruction 'R', your car does the following: +
        +
      • If your speed is positive then speed = -1
      • +
      • otherwise speed = 1
      • +
      + Your position stays the same.
    • +
    -

    When you get an instruction "R", your car does the following: if your speed is positive then speed = -1 , otherwise speed = 1.  (Your position stays the same.)

    +

    For example, after commands "AAR", your car goes to positions 0 --> 1 --> 3 --> 3, and your speed goes to 1 --> 2 --> 4 --> -1.

    -

    For example, after commands "AAR", your car goes to positions 0->1->3->3, and your speed goes to 1->2->4->-1.

    +

    Given a target position target, return the length of the shortest sequence of instructions to get there.

    -

    Now for some target position, say the length of the shortest sequence of instructions to get there.

    +

     

    +

    Example 1:

    -Example 1:
    -Input: 
    -target = 3
    +Input: target = 3
     Output: 2
     Explanation: 
     The shortest instruction sequence is "AA".
    -Your position goes from 0->1->3.
    +Your position goes from 0 --> 1 --> 3.
     
    +

    Example 2:

    +
    -Example 2:
    -Input: 
    -target = 6
    +Input: target = 6
     Output: 5
     Explanation: 
     The shortest instruction sequence is "AAARA".
    -Your position goes from 0->1->3->7->7->6.
    +Your position goes from 0 --> 1 --> 3 --> 7 --> 7 --> 6.
     

     

    - -

    Note:

    +

    Constraints:

      -
    • 1 <= target <= 10000.
    • +
    • 1 <= target <= 104
    ### Related Topics diff --git a/problems/random-pick-with-blacklist/README.md b/problems/random-pick-with-blacklist/README.md index f1bbf992c..ceb631c75 100644 --- a/problems/random-pick-with-blacklist/README.md +++ b/problems/random-pick-with-blacklist/README.md @@ -11,16 +11,16 @@ ## [710. Random Pick with Blacklist (Hard)](https://leetcode.com/problems/random-pick-with-blacklist "黑名单中的随机数") -

    Given a blacklist B containing unique integers from [0, N), write a function to return a uniform random integer from [0, N) which is NOT in B.

    +

    Given a blacklist blacklist containing unique integers from [0, n), write a function to return a uniform random integer from [0, n) which is NOT in blacklist.

    Optimize it such that it minimizes the call to system’s Math.random().

    Note:

      -
    1. 1 <= N <= 1000000000
    2. -
    3. 0 <= B.length < min(100000, N)
    4. -
    5. [0, N) does NOT include N. See interval notation.
    6. +
    7. 1 <= n <= 1000000000
    8. +
    9. 0 <= blacklist.length < min(100000, n)
    10. +
    11. [0, n) does NOT include n. See interval notation.

    Example 1:

    @@ -61,7 +61,7 @@

    Explanation of Input Syntax:

    -

    The input is two lists: the subroutines called and their arguments. Solution's constructor has two arguments, N and the blacklist B. pick has no arguments. Arguments are always wrapped with a list, even if there aren't any.

    +

    The input is two lists: the subroutines called and their arguments. Solution's constructor has two arguments, n and the blacklist blacklist. pick has no arguments. Arguments are always wrapped with a list, even if there aren't any.

    ### Related Topics [[Sort](../../tag/sort/README.md)] diff --git a/problems/range-sum-of-bst/README.md b/problems/range-sum-of-bst/README.md index be003f447..5639ef0aa 100644 --- a/problems/range-sum-of-bst/README.md +++ b/problems/range-sum-of-bst/README.md @@ -11,7 +11,7 @@ ## [938. Range Sum of BST (Easy)](https://leetcode.com/problems/range-sum-of-bst "二叉搜索树的范围和") -

    Given the root node of a binary search tree, return the sum of values of all nodes with a value in the range [low, high].

    +

    Given the root node of a binary search tree and two integers low and high, return the sum of values of all nodes with a value in the inclusive range [low, high].

     

    Example 1:

    @@ -19,6 +19,7 @@
     Input: root = [10,5,15,3,7,null,18], low = 7, high = 15
     Output: 32
    +Explanation: Nodes 7, 10, and 15 are in the range [7, 15]. 7 + 10 + 15 = 32.
     

    Example 2:

    @@ -26,6 +27,7 @@
     Input: root = [10,5,15,3,7,13,18,1,null,6], low = 6, high = 10
     Output: 23
    +Explanation: Nodes 6, 7, and 10 are in the range [6, 10]. 6 + 7 + 10 = 23.
     

     

    diff --git a/problems/range-sum-query-2d-immutable/README.md b/problems/range-sum-query-2d-immutable/README.md index 43fb0ece6..4e85d22e3 100644 --- a/problems/range-sum-query-2d-immutable/README.md +++ b/problems/range-sum-query-2d-immutable/README.md @@ -11,13 +11,17 @@ ## [304. Range Sum Query 2D - Immutable (Medium)](https://leetcode.com/problems/range-sum-query-2d-immutable "二维区域和检索 - 矩阵不可变") -

    Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).

    +

    Given a 2D matrix matrix, handle multiple queries of the following type:

    + +
      +
    1. Calculate the sum of the elements of matrix inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).
    2. +

    Implement the NumMatrix class:

      -
    • NumMatrix(int[][] matrix) initializes the object with the integer matrix matrix.
    • -
    • int sumRegion(int row1, int col1, int row2, int col2) returns the sum of the elements of the matrix array inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).
    • +
    • NumMatrix(int[][] matrix) Initializes the object with the integer matrix matrix.
    • +
    • int sumRegion(int row1, int col1, int row2, int col2) Returns the sum of the elements of matrix inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).

     

    @@ -32,9 +36,9 @@ Explanation NumMatrix numMatrix = new NumMatrix([[3, 0, 1, 4, 2], [5, 6, 3, 2, 1], [1, 2, 0, 1, 5], [4, 1, 0, 1, 7], [1, 0, 3, 0, 5]]); -numMatrix.sumRegion(2, 1, 4, 3); // return 8 (i.e sum of the red rectangele). -numMatrix.sumRegion(1, 1, 2, 2); // return 11 (i.e sum of the green rectangele). -numMatrix.sumRegion(1, 2, 2, 4); // return 12 (i.e sum of the blue rectangele). +numMatrix.sumRegion(2, 1, 4, 3); // return 8 (i.e sum of the red rectangle) +numMatrix.sumRegion(1, 1, 2, 2); // return 11 (i.e sum of the green rectangle) +numMatrix.sumRegion(1, 2, 2, 4); // return 12 (i.e sum of the blue rectangle)

     

    diff --git a/problems/range-sum-query-immutable/README.md b/problems/range-sum-query-immutable/README.md index e175b5c73..a6028bd65 100644 --- a/problems/range-sum-query-immutable/README.md +++ b/problems/range-sum-query-immutable/README.md @@ -11,13 +11,17 @@ ## [303. Range Sum Query - Immutable (Easy)](https://leetcode.com/problems/range-sum-query-immutable "区域和检索 - 数组不可变") -

    Given an integer array nums, find the sum of the elements between indices left and right inclusive, where (left <= right).

    +

    Given an integer array nums, handle multiple queries of the following type:

    + +
      +
    1. Calculate the sum of the elements of nums between indices left and right inclusive where left <= right.
    2. +

    Implement the NumArray class:

      -
    • NumArray(int[] nums) initializes the object with the integer array nums.
    • -
    • int sumRange(int left, int right) returns the sum of the elements of the nums array in the range [left, right] inclusive (i.e., sum(nums[left], nums[left + 1], ... , nums[right])).
    • +
    • NumArray(int[] nums) Initializes the object with the integer array nums.
    • +
    • int sumRange(int left, int right) Returns the sum of the elements of nums between indices left and right inclusive (i.e. nums[left] + nums[left + 1] + ... + nums[right]).

     

    @@ -32,9 +36,9 @@ Explanation NumArray numArray = new NumArray([-2, 0, 3, -5, 2, -1]); -numArray.sumRange(0, 2); // return 1 ((-2) + 0 + 3) -numArray.sumRange(2, 5); // return -1 (3 + (-5) + 2 + (-1)) -numArray.sumRange(0, 5); // return -3 ((-2) + 0 + 3 + (-5) + 2 + (-1)) +numArray.sumRange(0, 2); // return (-2) + 0 + 3 = 1 +numArray.sumRange(2, 5); // return 3 + (-5) + 2 + (-1) = -1 +numArray.sumRange(0, 5); // return (-2) + 0 + 3 + (-5) + 2 + (-1) = -3

     

    diff --git a/problems/range-sum-query-mutable/README.md b/problems/range-sum-query-mutable/README.md index 10c0e3c8c..0c1cba909 100644 --- a/problems/range-sum-query-mutable/README.md +++ b/problems/range-sum-query-mutable/README.md @@ -11,14 +11,19 @@ ## [307. Range Sum Query - Mutable (Medium)](https://leetcode.com/problems/range-sum-query-mutable "区域和检索 - 数组可修改") -

    Given an array nums and two types of queries where you should update the value of an index in the array, and retrieve the sum of a range in the array.

    +

    Given an integer array nums, handle multiple queries of the following types:

    + +
      +
    1. Update the value of an element in nums.
    2. +
    3. Calculate the sum of the elements of nums between indices left and right inclusive where left <= right.
    4. +

    Implement the NumArray class:

      -
    • NumArray(int[] nums) initializes the object with the integer array nums.
    • -
    • void update(int index, int val) updates the value of nums[index] to be val.
    • -
    • int sumRange(int left, int right) returns the sum of the subarray nums[left, right] (i.e., nums[left] + nums[left + 1], ..., nums[right]).
    • +
    • NumArray(int[] nums) Initializes the object with the integer array nums.
    • +
    • void update(int index, int val) Updates the value of nums[index] to be val.
    • +
    • int sumRange(int left, int right) Returns the sum of the elements of nums between indices left and right inclusive (i.e. nums[left] + nums[left + 1] + ... + nums[right]).

     

    @@ -33,9 +38,9 @@ Explanation NumArray numArray = new NumArray([1, 3, 5]); -numArray.sumRange(0, 2); // return 9 = sum([1,3,5]) -numArray.update(1, 2); // nums = [1,2,5] -numArray.sumRange(0, 2); // return 8 = sum([1,2,5]) +numArray.sumRange(0, 2); // return 1 + 3 + 5 = 9 +numArray.update(1, 2); // nums = [1, 2, 5] +numArray.sumRange(0, 2); // return 1 + 2 + 5 = 8

     

    diff --git a/problems/ransom-note/README.md b/problems/ransom-note/README.md index d6a177735..7660c27b8 100644 --- a/problems/ransom-note/README.md +++ b/problems/ransom-note/README.md @@ -11,9 +11,9 @@ ## [383. Ransom Note (Easy)](https://leetcode.com/problems/ransom-note "赎金信") -

    Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; otherwise, it will return false.

    +

    Given two stings ransomNote and magazine, return true if ransomNote can be constructed from magazine and false otherwise.

    -

    Each letter in the magazine string can only be used once in your ransom note.

    +

    Each letter in magazine can only be used once in ransomNote.

     

    Example 1:

    @@ -30,7 +30,8 @@

    Constraints:

      -
    • You may assume that both strings contain only lowercase letters.
    • +
    • 1 <= ransomNote.length, magazine.length <= 105
    • +
    • ransomNote and magazine consist of lowercase English letters.
    ### Related Topics diff --git a/problems/rectangle-area/README.md b/problems/rectangle-area/README.md index 851d6c112..07a5d9e12 100644 --- a/problems/rectangle-area/README.md +++ b/problems/rectangle-area/README.md @@ -13,22 +13,22 @@

    Given the coordinates of two rectilinear rectangles in a 2D plane, return the total area covered by the two rectangles.

    -

    The first rectangle is defined by its bottom-left corner (A, B) and its top-right corner (C, D).

    +

    The first rectangle is defined by its bottom-left corner (ax1, ay1) and its top-right corner (ax2, ay2).

    -

    The second rectangle is defined by its bottom-left corner (E, F) and its top-right corner (G, H).

    +

    The second rectangle is defined by its bottom-left corner (bx1, by1) and its top-right corner (bx2, by2).

     

    Example 1:

    -Rectangle Area +Rectangle Area
    -Input: A = -3, B = 0, C = 3, D = 4, E = 0, F = -1, G = 9, H = 2
    +Input: ax1 = -3, ay1 = 0, ax2 = 3, ay2 = 4, bx1 = 0, by1 = -1, bx2 = 9, by2 = 2
     Output: 45
     

    Example 2:

    -Input: A = -2, B = -2, C = 2, D = 2, E = -2, F = -2, G = 2, H = 2
    +Input: ax1 = -2, ay1 = -2, ax2 = 2, ay2 = 2, bx1 = -2, by1 = -2, bx2 = 2, by2 = 2
     Output: 16
     
    @@ -36,7 +36,7 @@

    Constraints:

      -
    • -104 <= A, B, C, D, E, F, G, H <= 104
    • +
    • -104 <= ax1, ay1, ax2, ay2, bx1, by1, bx2, by2 <= 104
    ### Related Topics diff --git a/problems/redundant-connection-ii/README.md b/problems/redundant-connection-ii/README.md index 493b91de8..aa0487b64 100644 --- a/problems/redundant-connection-ii/README.md +++ b/problems/redundant-connection-ii/README.md @@ -42,6 +42,7 @@
  • 3 <= n <= 1000
  • edges[i].length == 2
  • 1 <= ui, vi <= n
  • +
  • ui != vi
  • ### Related Topics diff --git a/problems/redundant-connection/README.md b/problems/redundant-connection/README.md index 6d8db4840..e678298b6 100644 --- a/problems/redundant-connection/README.md +++ b/problems/redundant-connection/README.md @@ -11,45 +11,39 @@ ## [684. Redundant Connection (Medium)](https://leetcode.com/problems/redundant-connection "冗余连接") -

    -In this problem, a tree is an undirected graph that is connected and has no cycles. -

    -The given input is a graph that started as a tree with N nodes (with distinct values 1, 2, ..., N), with one additional edge added. The added edge has two different vertices chosen from 1 to N, and was not an edge that already existed. -

    -The resulting graph is given as a 2D-array of edges. Each element of edges is a pair [u, v] with u < v, that represents an undirected edge connecting nodes u and v. -

    -Return an edge that can be removed so that the resulting graph is a tree of N nodes. If there are multiple answers, return the answer that occurs last in the given 2D-array. The answer edge [u, v] should be in the same format, with u < v. -

    Example 1:
    +

    In this problem, a tree is an undirected graph that is connected and has no cycles.

    + +

    You are given a graph that started as a tree with n nodes labeled from 1 to n, with one additional edge added. The added edge has two different vertices chosen from 1 to n, and was not an edge that already existed. The graph is represented as an array edges of length n where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the graph.

    + +

    Return an edge that can be removed so that the resulting graph is a tree of n nodes. If there are multiple answers, return the answer that occurs last in the input.

    + +

     

    +

    Example 1:

    +
    -Input: [[1,2], [1,3], [2,3]]
    -Output: [2,3]
    -Explanation: The given undirected graph will be like this:
    -  1
    - / \
    -2 - 3
    +Input: edges = [[1,2],[1,3],[2,3]]
    +Output: [2,3]
     
    -

    -

    Example 2:
    + +

    Example 2:

    +
    -Input: [[1,2], [2,3], [3,4], [1,4], [1,5]]
    -Output: [1,4]
    -Explanation: The given undirected graph will be like this:
    -5 - 1 - 2
    -    |   |
    -    4 - 3
    +Input: edges = [[1,2],[2,3],[3,4],[1,4],[1,5]]
    +Output: [1,4]
     
    -

    -

    Note:
    -

  • The size of the input 2D-array will be between 3 and 1000.
  • -
  • Every integer represented in the 2D-array will be between 1 and N, where N is the size of the input array.
  • -

    - -
    - -

    -Update (2017-09-26):
    -We have overhauled the problem description + test cases and specified clearly the graph is an undirected graph. For the directed graph follow up please see Redundant Connection II). We apologize for any inconvenience caused. -

    + +

     

    +

    Constraints:

    + +
      +
    • n == edges.length
    • +
    • 3 <= n <= 1000
    • +
    • edges[i].length == 2
    • +
    • 1 <= ai < bi <= edges.length
    • +
    • ai != bi
    • +
    • There are no repeated edges.
    • +
    • The given graph is connected.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/remove-all-adjacent-duplicates-in-string/README.md b/problems/remove-all-adjacent-duplicates-in-string/README.md index 2ec524ed2..de76aaf58 100644 --- a/problems/remove-all-adjacent-duplicates-in-string/README.md +++ b/problems/remove-all-adjacent-duplicates-in-string/README.md @@ -11,31 +11,36 @@ ## [1047. Remove All Adjacent Duplicates In String (Easy)](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string "删除字符串中的所有相邻重复项") -

    Given a string S of lowercase letters, a duplicate removal consists of choosing two adjacent and equal letters, and removing them.

    +

    You are given a string s. A duplicate removal consists of choosing two adjacent and equal letters and removing them.

    -

    We repeatedly make duplicate removals on S until we no longer can.

    +

    We repeatedly make duplicate removals on s until we no longer can.

    -

    Return the final string after all such duplicate removals have been made.  It is guaranteed the answer is unique.

    +

    Return the final string after all such duplicate removals have been made. It is guaranteed the answer is unique.

     

    -

    Example 1:

    -Input: "abbaca"
    -Output: "ca"
    -Explanation: 
    -For example, in "abbaca" we could remove "bb" since the letters are adjacent and equal, and this is the only possible move.  The result of this move is that the string is "aaca", of which only "aa" is possible, so the final string is "ca".
    +Input: s = "abbaca"
    +Output: "ca"
    +Explanation: 
    +For example, in "abbaca" we could remove "bb" since the letters are adjacent and equal, and this is the only possible move.  The result of this move is that the string is "aaca", of which only "aa" is possible, so the final string is "ca".
     
    -

     

    +

    Example 2:

    + +
    +Input: s = "azxxzy"
    +Output: "ay"
    +
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. 1 <= S.length <= 20000
    2. -
    3. S consists only of English lowercase letters.
    4. -
    +
      +
    • 1 <= s.length <= 105
    • +
    • s consists of lowercase English letters.
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/reorganize-string/README.md b/problems/reorganize-string/README.md index b5d3857ad..4b7088fac 100644 --- a/problems/reorganize-string/README.md +++ b/problems/reorganize-string/README.md @@ -11,28 +11,28 @@ ## [767. Reorganize String (Medium)](https://leetcode.com/problems/reorganize-string "重构字符串") -

    Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.

    +

    Given a string s, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.

    If possible, output any possible result.  If not possible, return the empty string.

    Example 1:

    -Input: S = "aab"
    +Input: s = "aab"
     Output: "aba"
     

    Example 2:

    -Input: S = "aaab"
    +Input: s = "aaab"
     Output: ""
     

    Note:

      -
    • S will consist of lowercase letters and have length in range [1, 500].
    • +
    • s will consist of lowercase letters and have length in range [1, 500].

     

    diff --git a/problems/replace-all-digits-with-characters/README.md b/problems/replace-all-digits-with-characters/README.md new file mode 100644 index 000000000..931c1dc3a --- /dev/null +++ b/problems/replace-all-digits-with-characters/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../suspicious-bank-accounts "Suspicious Bank Accounts") +                 +[Next >](../seat-reservation-manager "Seat Reservation Manager") + +## [1844. Replace All Digits with Characters (Easy)](https://leetcode.com/problems/replace-all-digits-with-characters "将所有数字用字符替换") + +

    You are given a 0-indexed string s that has lowercase English letters in its even indices and digits in its odd indices.

    + +

    There is a function shift(c, x), where c is a character and x is a digit, that returns the xth character after c.

    + +
      +
    • For example, shift('a', 5) = 'f' and shift('x', 0) = 'x'.
    • +
    + +

    For every odd index i, you want to replace the digit s[i] with shift(s[i-1], s[i]).

    + +

    Return s after replacing all digits. It is guaranteed that shift(s[i-1], s[i]) will never exceed 'z'.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "a1c1e1"
    +Output: "abcdef"
    +Explanation: The digits are replaced as follows:
    +- s[1] -> shift('a',1) = 'b'
    +- s[3] -> shift('c',1) = 'd'
    +- s[5] -> shift('e',1) = 'f'
    + +

    Example 2:

    + +
    +Input: s = "a1b2c3d4e"
    +Output: "abbdcfdhe"
    +Explanation: The digits are replaced as follows:
    +- s[1] -> shift('a',1) = 'b'
    +- s[3] -> shift('b',2) = 'd'
    +- s[5] -> shift('c',3) = 'f'
    +- s[7] -> shift('d',4) = 'h'
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 100
    • +
    • s consists only of lowercase English letters and digits.
    • +
    • shift(s[i-1], s[i]) <= 'z' for all odd indices i.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +We just need to replace every even positioned character with the character s[i] positions ahead of the character preceding it +
    + +
    +Hint 2 +Get the position of the preceeding character in alphabet then advance it s[i] positions and get the character at that position +
    diff --git a/problems/reverse-nodes-in-k-group/README.md b/problems/reverse-nodes-in-k-group/README.md index 6e316eddf..50019805f 100644 --- a/problems/reverse-nodes-in-k-group/README.md +++ b/problems/reverse-nodes-in-k-group/README.md @@ -15,12 +15,7 @@

    k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes, in the end, should remain as it is.

    -

    Follow up:

    - -
      -
    • Could you solve the problem in O(1) extra memory space?
    • -
    • You may not alter the values in the list's nodes, only nodes itself may be changed.
    • -
    +

    You may not alter the values in the list's nodes, only nodes themselves may be changed.

     

    Example 1:

    @@ -61,6 +56,9 @@
  • 1 <= k <= sz
  • +

     

    +Follow-up: Can you solve the problem in O(1) extra memory space? + ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/reverse-only-letters/README.md b/problems/reverse-only-letters/README.md index 466e3b271..4dfb5e8c2 100644 --- a/problems/reverse-only-letters/README.md +++ b/problems/reverse-only-letters/README.md @@ -11,7 +11,7 @@ ## [917. Reverse Only Letters (Easy)](https://leetcode.com/problems/reverse-only-letters "仅仅反转字母") -

    Given a string S, return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their positions.

    +

    Given a string s, return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their positions.

     

    @@ -28,7 +28,7 @@

    Example 1:

    -Input: "ab-cd"
    +Input: s = "ab-cd"
     Output: "dc-ba"
     
    @@ -36,7 +36,7 @@

    Example 2:

    -Input: "a-bC-dEf-ghIj"
    +Input: s = "a-bC-dEf-ghIj"
     Output: "j-Ih-gfE-dCba"
     
    @@ -44,7 +44,7 @@

    Example 3:

    -Input: "Test1ng-Leet=code-Q!"
    +Input: s = "Test1ng-Leet=code-Q!"
     Output: "Qedo1ct-eeLg=ntse-T!"
     
    @@ -54,9 +54,9 @@

    Note:

      -
    1. S.length <= 100
    2. -
    3. 33 <= S[i].ASCIIcode <= 122 
    4. -
    5. S doesn't contain \ or "
    6. +
    7. s.length <= 100
    8. +
    9. 33 <= s[i].ASCIIcode <= 122 
    10. +
    11. s doesn't contain \ or "
    diff --git a/problems/reverse-pairs/README.md b/problems/reverse-pairs/README.md index e1eb7eb2b..cd4dfb895 100644 --- a/problems/reverse-pairs/README.md +++ b/problems/reverse-pairs/README.md @@ -28,7 +28,7 @@
    • 1 <= nums.length <= 5 * 104
    • -
    • 231 <= nums[i] <= 231 - 1
    • +
    • -231 <= nums[i] <= 231 - 1
    ### Related Topics diff --git a/problems/rle-iterator/README.md b/problems/rle-iterator/README.md index a79cd7989..272eb72d3 100644 --- a/problems/rle-iterator/README.md +++ b/problems/rle-iterator/README.md @@ -13,11 +13,11 @@

    Write an iterator that iterates through a run-length encoded sequence.

    -

    The iterator is initialized by RLEIterator(int[] A), where A is a run-length encoding of some sequence.  More specifically, for all even iA[i] tells us the number of times that the non-negative integer value A[i+1] is repeated in the sequence.

    +

    The iterator is initialized by RLEIterator(int[] encoding), where encoding is a run-length encoding of some sequence.  More specifically, for all even iencoding[i] tells us the number of times that the non-negative integer value encoding[i+1] is repeated in the sequence.

    The iterator supports one function: next(int n), which exhausts the next n elements (n >= 1) and returns the last element exhausted in this way.  If there is no element left to exhaust, next returns -1 instead.

    -

    For example, we start with A = [3,8,0,9,2,5], which is a run-length encoding of the sequence [8,8,8,5,5].  This is because the sequence can be read as "three eights, zero nines, two fives".

    +

    For example, we start with encoding = [3,8,0,9,2,5], which is a run-length encoding of the sequence [8,8,8,5,5].  This is because the sequence can be read as "three eights, zero nines, two fives".

     

    @@ -45,11 +45,11 @@ but the second term did not exist. Since the last term exhausted does not exist

    Note:

      -
    1. 0 <= A.length <= 1000
    2. -
    3. A.length is an even integer.
    4. -
    5. 0 <= A[i] <= 10^9
    6. +
    7. 0 <= encoding.length <= 1000
    8. +
    9. encoding.length is an even integer.
    10. +
    11. 0 <= encoding[i] <= 109
    12. There are at most 1000 calls to RLEIterator.next(int n) per test case.
    13. -
    14. Each call to RLEIterator.next(int n) will have 1 <= n <= 10^9.
    15. +
    16. Each call to RLEIterator.next(int n) will have 1 <= n <= 109.
    ### Related Topics diff --git a/problems/robot-bounded-in-circle/README.md b/problems/robot-bounded-in-circle/README.md index 31aad4ab0..8cac50e8a 100644 --- a/problems/robot-bounded-in-circle/README.md +++ b/problems/robot-bounded-in-circle/README.md @@ -51,7 +51,7 @@ When repeating these instructions, the robot remains in the circle of radius 2 c
    • 1 <= instructions.length <= 100
    • -
    • instructions[i] is 'G', 'L' or, 'R'.
    • +
    • instructions[i] is 'G', 'L' or, 'R'.
    ### Related Topics diff --git a/problems/rotate-string/README.md b/problems/rotate-string/README.md index 439e626a3..cc8877deb 100644 --- a/problems/rotate-string/README.md +++ b/problems/rotate-string/README.md @@ -11,22 +11,22 @@ ## [796. Rotate String (Easy)](https://leetcode.com/problems/rotate-string "旋转字符串") -

    We are given two strings, A and B.

    +

    We are given two strings, s and goal.

    -

    A shift on A consists of taking string A and moving the leftmost character to the rightmost position. For example, if A = 'abcde', then it will be 'bcdea' after one shift on A. Return True if and only if A can become B after some number of shifts on A.

    +

    A shift on s consists of taking string s and moving the leftmost character to the rightmost position. For example, if s = 'abcde', then it will be 'bcdea' after one shift on s. Return true if and only if s can become goal after some number of shifts on s.

     Example 1:
    -Input: A = 'abcde', B = 'cdeab'
    +Input: s = 'abcde', goal = 'cdeab'
     Output: true
     
     Example 2:
    -Input: A = 'abcde', B = 'abced'
    +Input: s = 'abcde', goal = 'abced'
     Output: false
     

    Note:

      -
    • A and B will have length at most 100.
    • +
    • s and goal will have length at most 100.
    diff --git a/problems/rotated-digits/README.md b/problems/rotated-digits/README.md index de4d05002..48fa45468 100644 --- a/problems/rotated-digits/README.md +++ b/problems/rotated-digits/README.md @@ -11,11 +11,11 @@ ## [788. Rotated Digits (Easy)](https://leetcode.com/problems/rotated-digits "旋转数字") -

    X is a good number if after rotating each digit individually by 180 degrees, we get a valid number that is different from X.  Each digit must be rotated - we cannot choose to leave it alone.

    +

    x is a good number if after rotating each digit individually by 180 degrees, we get a valid number that is different from x. Each digit must be rotated - we cannot choose to leave it alone.

    A number is valid if each digit remains a digit after rotation. 0, 1, and 8 rotate to themselves; 2 and 5 rotate to each other (on this case they are rotated in a different direction, in other words 2 or 5 gets mirrored); 6 and 9 rotate to each other, and the rest of the numbers do not rotate to any other number and become invalid.

    -

    Now given a positive number N, how many numbers X from 1 to N are good?

    +

    Now given a positive number n, how many numbers x from 1 to n are good?

     Example:
    @@ -29,7 +29,7 @@ Note that 1 and 10 are not good numbers, since they remain unchanged after rotat
     

    Note:

      -
    • N  will be in range [1, 10000].
    • +
    • n will be in range [1, 10000].
    ### Related Topics diff --git a/problems/score-after-flipping-matrix/README.md b/problems/score-after-flipping-matrix/README.md index 12aa610f2..37284c982 100644 --- a/problems/score-after-flipping-matrix/README.md +++ b/problems/score-after-flipping-matrix/README.md @@ -11,7 +11,7 @@ ## [861. Score After Flipping Matrix (Medium)](https://leetcode.com/problems/score-after-flipping-matrix "翻转矩阵后的得分") -

    We have a two dimensional matrix A where each value is 0 or 1.

    +

    We have a two dimensional matrix grid where each value is 0 or 1.

    A move consists of choosing any row or column, and toggling each value in that row or column: changing all 0s to 1s, and all 1s to 0s.

    @@ -28,7 +28,7 @@

    Example 1:

    -Input: [[0,0,1,1],[1,0,1,0],[1,1,0,0]]
    +Input: grid = [[0,0,1,1],[1,0,1,0],[1,1,0,0]]
     Output: 39
     Explanation:
     Toggled to [[1,1,1,1],[1,0,0,1],[1,1,1,1]].
    @@ -39,9 +39,9 @@
     

    Note:

      -
    1. 1 <= A.length <= 20
    2. -
    3. 1 <= A[0].length <= 20
    4. -
    5. A[i][j] is 0 or 1.
    6. +
    7. 1 <= grid.length <= 20
    8. +
    9. 1 <= grid[0].length <= 20
    10. +
    11. grid[i][j] is 0 or 1.
    diff --git a/problems/score-of-parentheses/README.md b/problems/score-of-parentheses/README.md index eea7cdcf7..94ee29ad6 100644 --- a/problems/score-of-parentheses/README.md +++ b/problems/score-of-parentheses/README.md @@ -11,7 +11,7 @@ ## [856. Score of Parentheses (Medium)](https://leetcode.com/problems/score-of-parentheses "括号的分数") -

    Given a balanced parentheses string S, compute the score of the string based on the following rule:

    +

    Given a balanced parentheses string s, compute the score of the string based on the following rule:

    • () has score 1
    • @@ -21,36 +21,32 @@

       

      -

      Example 1:

      -Input: "()"
      -Output: 1
      +Input: s = "()"
      +Output: 1
       
      -

      Example 2:

      -Input: "(())"
      -Output: 2
      +Input: s = "(())"
      +Output: 2
       
      -

      Example 3:

      -Input: "()()"
      -Output: 2
      +Input: s = "()()"
      +Output: 2
       
      -

      Example 4:

      -Input: "(()(()))"
      -Output: 6
      +Input: s = "(()(()))"
      +Output: 6
       

       

      @@ -58,13 +54,9 @@

      Note:

        -
      1. S is a balanced parentheses string, containing only ( and ).
      2. -
      3. 2 <= S.length <= 50
      4. +
      5. s is a balanced parentheses string, containing only ( and ).
      6. +
      7. 2 <= s.length <= 50
      -
      -
      -
      -
      ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/search-in-rotated-sorted-array/README.md b/problems/search-in-rotated-sorted-array/README.md index b299214e8..1fe16bcb6 100644 --- a/problems/search-in-rotated-sorted-array/README.md +++ b/problems/search-in-rotated-sorted-array/README.md @@ -17,6 +17,8 @@

      Given the array nums after the rotation and an integer target, return the index of target if it is in nums, or -1 if it is not in nums.

      +

      You must write an algorithm with O(log n) runtime complexity.

      +

       

      Example 1:

      Input: nums = [4,5,6,7,0,1,2], target = 0
      @@ -39,9 +41,6 @@
       	
    • -104 <= target <= 104
    -

     

    -Follow up: Can you achieve this in O(log n) time complexity? - ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/search-insert-position/README.md b/problems/search-insert-position/README.md index 834581031..b94c0636a 100644 --- a/problems/search-insert-position/README.md +++ b/problems/search-insert-position/README.md @@ -13,6 +13,8 @@

    Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.

    +

    You must write an algorithm with O(log n) runtime complexity.

    +

     

    Example 1:

    Input: nums = [1,3,5,6], target = 5
    diff --git a/problems/seat-reservation-manager/README.md b/problems/seat-reservation-manager/README.md
    new file mode 100644
    index 000000000..506b4453a
    --- /dev/null
    +++ b/problems/seat-reservation-manager/README.md
    @@ -0,0 +1,75 @@
    +
    +
    +
    +
    +
    +
    +
    +[< Previous](../replace-all-digits-with-characters "Replace All Digits with Characters")
    +                
    +[Next >](../maximum-element-after-decreasing-and-rearranging "Maximum Element After Decreasing and Rearranging")
    +
    +## [1845. Seat Reservation Manager (Medium)](https://leetcode.com/problems/seat-reservation-manager "座位预约管理系统")
    +
    +

    Design a system that manages the reservation state of n seats that are numbered from 1 to n.

    + +

    Implement the SeatManager class:

    + +
      +
    • SeatManager(int n) Initializes a SeatManager object that will manage n seats numbered from 1 to n. All seats are initially available.
    • +
    • int reserve() Fetches the smallest-numbered unreserved seat, reserves it, and returns its number.
    • +
    • void unreserve(int seatNumber) Unreserves the seat with the given seatNumber.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input
    +["SeatManager", "reserve", "reserve", "unreserve", "reserve", "reserve", "reserve", "reserve", "unreserve"]
    +[[5], [], [], [2], [], [], [], [], [5]]
    +Output
    +[null, 1, 2, null, 2, 3, 4, 5, null]
    +
    +Explanation
    +SeatManager seatManager = new SeatManager(5); // Initializes a SeatManager with 5 seats.
    +seatManager.reserve();    // All seats are available, so return the lowest numbered seat, which is 1.
    +seatManager.reserve();    // The available seats are [2,3,4,5], so return the lowest of them, which is 2.
    +seatManager.unreserve(2); // Unreserve seat 2, so now the available seats are [2,3,4,5].
    +seatManager.reserve();    // The available seats are [2,3,4,5], so return the lowest of them, which is 2.
    +seatManager.reserve();    // The available seats are [3,4,5], so return the lowest of them, which is 3.
    +seatManager.reserve();    // The available seats are [4,5], so return the lowest of them, which is 4.
    +seatManager.reserve();    // The only available seat is seat 5, so return 5.
    +seatManager.unreserve(5); // Unreserve seat 5, so now the available seats are [5].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 105
    • +
    • 1 <= seatNumber <= n
    • +
    • For each call to reserve, it is guaranteed that there will be at least one unreserved seat.
    • +
    • For each call to unreserve, it is guaranteed that seatNumber will be reserved.
    • +
    • At most 105 calls in total will be made to reserve and unreserve.
    • +
    + +### Related Topics + [[Heap](../../tag/heap/README.md)] + [[Design](../../tag/design/README.md)] + +### Hints +
    +Hint 1 +You need a data structure that maintains the states of the seats. This data structure should also allow you to get the first available seat and flip the state of a seat in a reasonable time. +
    + +
    +Hint 2 +You can let the data structure contain the available seats. Then you want to be able to get the lowest element and erase an element, in a reasonable time. +
    + +
    +Hint 3 +Ordered sets support these operations. +
    diff --git a/problems/shifting-letters/README.md b/problems/shifting-letters/README.md index e33117192..11bd34211 100644 --- a/problems/shifting-letters/README.md +++ b/problems/shifting-letters/README.md @@ -11,7 +11,7 @@ ## [848. Shifting Letters (Medium)](https://leetcode.com/problems/shifting-letters "字母移位") -

    We have a string S of lowercase letters, and an integer array shifts.

    +

    We have a string s of lowercase letters, and an integer array shifts.

    Call the shift of a letter, the next letter in the alphabet, (wrapping around so that 'z' becomes 'a'). 

    @@ -19,12 +19,12 @@

    Now for each shifts[i] = x, we want to shift the first i+1 letters of S, x times.

    -

    Return the final string after all such shifts to S are applied.

    +

    Return the final string after all such shifts to s are applied.

    Example 1:

    -Input: S = "abc", shifts = [3,5,9]
    +Input: s = "abc", shifts = [3,5,9]
     Output: "rpl"
     Explanation: 
     We start with "abc".
    @@ -36,8 +36,8 @@ After shifting the first 3 letters of S by 9, we have "rpl", the answe
     

    Note:

      -
    1. 1 <= S.length = shifts.length <= 20000
    2. -
    3. 0 <= shifts[i] <= 10 ^ 9
    4. +
    5. 1 <= s.length = shifts.length <= 20000
    6. +
    7. 0 <= shifts[i] <= 109
    ### Related Topics diff --git a/problems/shortest-bridge/README.md b/problems/shortest-bridge/README.md index 9c4479453..73e3b5ec4 100644 --- a/problems/shortest-bridge/README.md +++ b/problems/shortest-bridge/README.md @@ -11,7 +11,7 @@ ## [934. Shortest Bridge (Medium)](https://leetcode.com/problems/shortest-bridge "最短的桥") -

    In a given 2D binary array A, there are two islands.  (An island is a 4-directionally connected group of 1s not connected to any other 1s.)

    +

    In a given 2D binary array grid, there are two islands.  (An island is a 4-directionally connected group of 1s not connected to any other 1s.)

    Now, we may change 0s to 1s so as to connect the two islands together to form 1 island.

    @@ -19,21 +19,32 @@

     

    Example 1:

    -
    Input: A = [[0,1],[1,0]]
    +
    +
    +Input: grid = [[0,1],[1,0]]
     Output: 1
    -

    Example 2:

    -
    Input: A = [[0,1,0],[0,0,0],[0,0,1]]
    +
    + +

    Example 2:

    + +
    +Input: grid = [[0,1,0],[0,0,0],[0,0,1]]
     Output: 2
    -

    Example 3:

    -
    Input: A = [[1,1,1,1,1],[1,0,0,0,1],[1,0,1,0,1],[1,0,0,0,1],[1,1,1,1,1]]
    +
    + +

    Example 3:

    + +
    +Input: grid = [[1,1,1,1,1],[1,0,0,0,1],[1,0,1,0,1],[1,0,0,0,1],[1,1,1,1,1]]
     Output: 1
     
    +

     

    Constraints:

      -
    • 2 <= A.length == A[0].length <= 100
    • -
    • A[i][j] == 0 or A[i][j] == 1
    • +
    • 2 <= grid.length == grid[0].length <= 100
    • +
    • grid[i][j] == 0 or grid[i][j] == 1
    ### Related Topics diff --git a/problems/shortest-path-visiting-all-nodes/README.md b/problems/shortest-path-visiting-all-nodes/README.md index 9cbcc6800..656f55960 100644 --- a/problems/shortest-path-visiting-all-nodes/README.md +++ b/problems/shortest-path-visiting-all-nodes/README.md @@ -11,40 +11,38 @@ ## [847. Shortest Path Visiting All Nodes (Hard)](https://leetcode.com/problems/shortest-path-visiting-all-nodes "访问所有节点的最短路径") -

    An undirected, connected graph of N nodes (labeled 0, 1, 2, ..., N-1) is given as graph.

    +

    You have an undirected, connected graph of n nodes labeled from 0 to n - 1. You are given an array graph where graph[i] is a list of all the nodes connected with node i by an edge.

    -

    graph.length = N, and j != i is in the list graph[i] exactly once, if and only if nodes i and j are connected.

    - -

    Return the length of the shortest path that visits every node. You may start and stop at any node, you may revisit nodes multiple times, and you may reuse edges.

    +

    Return the length of the shortest path that visits every node. You may start and stop at any node, you may revisit nodes multiple times, and you may reuse edges.

     

    - -
      -
    -

    Example 1:

    - +
    -Input: [[1,2,3],[0],[0],[0]]
    -Output: 4
    -Explanation: One possible path is [1,0,2,0,3]
    +Input: graph = [[1,2,3],[0],[0],[0]] +Output: 4 +Explanation: One possible path is [1,0,2,0,3] +

    Example 2:

    - +
    -Input: [[1],[0,2,4],[1,3,4],[2],[1,2]]
    -Output: 4
    -Explanation: One possible path is [0,1,4,2,3]
    +Input: graph = [[1],[0,2,4],[1,3,4],[2],[1,2]]
    +Output: 4
    +Explanation: One possible path is [0,1,4,2,3]
     

     

    - -

    Note:

    - -
      -
    1. 1 <= graph.length <= 12
    2. -
    3. 0 <= graph[i].length < graph.length
    4. -
    +

    Constraints:

    + +
      +
    • n == graph.length
    • +
    • 1 <= n <= 12
    • +
    • 0 <= graph[i].length < n
    • +
    • graph[i] does not contain i.
    • +
    • If graph[a] contains b, then graph[b] contains a.
    • +
    • The input graph is always connected.
    • +
    ### Related Topics [[Breadth-first Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/shortest-subarray-with-sum-at-least-k/README.md b/problems/shortest-subarray-with-sum-at-least-k/README.md index 8864d9c5d..05bd036de 100644 --- a/problems/shortest-subarray-with-sum-at-least-k/README.md +++ b/problems/shortest-subarray-with-sum-at-least-k/README.md @@ -11,9 +11,9 @@ ## [862. Shortest Subarray with Sum at Least K (Hard)](https://leetcode.com/problems/shortest-subarray-with-sum-at-least-k "和至少为 K 的最短子数组") -

    Return the length of the shortest, non-empty, contiguous subarray of A with sum at least K.

    +

    Return the length of the shortest, non-empty, contiguous subarray of nums with sum at least k.

    -

    If there is no non-empty subarray with sum at least K, return -1.

    +

    If there is no non-empty subarray with sum at least k, return -1.

     

    @@ -24,7 +24,7 @@

    Example 1:

    -Input: A = [1], K = 1
    +Input: nums = [1], k = 1
     Output: 1
     
    @@ -32,7 +32,7 @@

    Example 2:

    -Input: A = [1,2], K = 4
    +Input: nums = [1,2], k = 4
     Output: -1
     
    @@ -40,7 +40,7 @@

    Example 3:

    -Input: A = [2,-1,2], K = 3
    +Input: nums = [2,-1,2], k = 3
     Output: 3
     
    @@ -49,9 +49,9 @@

    Note:

      -
    1. 1 <= A.length <= 50000
    2. -
    3. -10 ^ 5 <= A[i] <= 10 ^ 5
    4. -
    5. 1 <= K <= 10 ^ 9
    6. +
    7. 1 <= nums.length <= 50000
    8. +
    9. -105 <= nums[i] <= 105
    10. +
    11. 1 <= k <= 109
    diff --git a/problems/single-number-ii/README.md b/problems/single-number-ii/README.md index a59956112..fcee4c20a 100644 --- a/problems/single-number-ii/README.md +++ b/problems/single-number-ii/README.md @@ -13,6 +13,8 @@

    Given an integer array nums where every element appears three times except for one, which appears exactly once. Find the single element and return it.

    +

    You must implement a solution with a linear runtime complexity and use only constant extra space.

    +

     

    Example 1:

    Input: nums = [2,2,3,2]
    @@ -30,9 +32,6 @@
     	
  • Each element in nums appears exactly three times except for one element which appears once.
  • -

     

    -

    Follow up: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?

    - ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/single-number-iii/README.md b/problems/single-number-iii/README.md index 8ff056aa4..b0c846afe 100644 --- a/problems/single-number-iii/README.md +++ b/problems/single-number-iii/README.md @@ -13,7 +13,7 @@

    Given an integer array nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. You can return the answer in any order.

    -

    Follow up: Your algorithm should run in linear runtime complexity. Could you implement it using only constant space complexity?

    +

    You must write an algorithm that runs in linear runtime complexity and uses only constant extra space.

     

    Example 1:

    diff --git a/problems/single-number/README.md b/problems/single-number/README.md index 9f34cd764..b7b329f5c 100644 --- a/problems/single-number/README.md +++ b/problems/single-number/README.md @@ -13,7 +13,7 @@

    Given a non-empty array of integers nums, every element appears twice except for one. Find that single one.

    -

    Follow up: Could you implement a solution with a linear runtime complexity and without using extra memory?

    +

    You must implement a solution with a linear runtime complexity and use only constant extra space.

     

    Example 1:

    diff --git a/problems/smallest-range-i/README.md b/problems/smallest-range-i/README.md index 410fbc31f..ff6556910 100644 --- a/problems/smallest-range-i/README.md +++ b/problems/smallest-range-i/README.md @@ -11,11 +11,11 @@ ## [908. Smallest Range I (Easy)](https://leetcode.com/problems/smallest-range-i "最小差值 I") -

    Given an array A of integers, for each integer A[i] we may choose any x with -K <= x <= K, and add x to A[i].

    +

    Given an array nums of integers, for each integer nums[i] we may choose any x with -k <= x <= k, and add x to nums[i].

    -

    After this process, we have some array B.

    +

    After this process, we have some array result.

    -

    Return the smallest possible difference between the maximum value of B and the minimum value of B.

    +

    Return the smallest possible difference between the maximum value of result and the minimum value of result.

     

    @@ -26,27 +26,27 @@

    Example 1:

    -Input: A = [1], K = 0
    +Input: nums = [1], k = 0
     Output: 0
    -Explanation: B = [1]
    +Explanation: result = [1]
     

    Example 2:

    -Input: A = [0,10], K = 2
    +Input: nums = [0,10], k = 2
     Output: 6
    -Explanation: B = [2,8]
    +Explanation: result = [2,8]
     

    Example 3:

    -Input: A = [1,3,6], K = 3
    +Input: nums = [1,3,6], k = 3
     Output: 0
    -Explanation: B = [3,3,3] or B = [4,4,4]
    +Explanation: result = [3,3,3] or result = [4,4,4]
     

     

    @@ -54,9 +54,9 @@

    Note:

      -
    1. 1 <= A.length <= 10000
    2. -
    3. 0 <= A[i] <= 10000
    4. -
    5. 0 <= K <= 10000
    6. +
    7. 1 <= nums.length <= 10000
    8. +
    9. 0 <= nums[i] <= 10000
    10. +
    11. 0 <= k <= 10000
    diff --git a/problems/smallest-range-ii/README.md b/problems/smallest-range-ii/README.md index cae7abe56..82398defe 100644 --- a/problems/smallest-range-ii/README.md +++ b/problems/smallest-range-ii/README.md @@ -11,11 +11,11 @@ ## [910. Smallest Range II (Medium)](https://leetcode.com/problems/smallest-range-ii "最小差值 II") -

    Given an array A of integers, for each integer A[i] we need to choose either x = -K or x = K, and add x to A[i] (only once).

    +

    Given an array nums of integers, for each integer nums[i] we need to choose either x = -k or x = k, and add x to nums[i] (only once).

    -

    After this process, we have some array B.

    +

    After this process, we have some array result.

    -

    Return the smallest possible difference between the maximum value of B and the minimum value of B.

    +

    Return the smallest possible difference between the maximum value of result and the minimum value of result.

     

    @@ -26,27 +26,27 @@

    Example 1:

    -Input: A = [1], K = 0
    +Input: nums = [1], k = 0
     Output: 0
    -Explanation: B = [1]
    +Explanation: result = [1]
     

    Example 2:

    -Input: A = [0,10], K = 2
    +Input: nums = [0,10], k = 2
     Output: 6
    -Explanation: B = [2,8]
    +Explanation: result = [2,8]
     

    Example 3:

    -Input: A = [1,3,6], K = 3
    +Input: nums = [1,3,6], k = 3
     Output: 3
    -Explanation: B = [4,6,3]
    +Explanation: result = [4,6,3]
     

     

    @@ -54,9 +54,9 @@

    Note:

      -
    1. 1 <= A.length <= 10000
    2. -
    3. 0 <= A[i] <= 10000
    4. -
    5. 0 <= K <= 10000
    6. +
    7. 1 <= nums.length <= 10000
    8. +
    9. 0 <= nums[i] <= 10000
    10. +
    11. 0 <= k <= 10000
    diff --git a/problems/smallest-rotation-with-highest-score/README.md b/problems/smallest-rotation-with-highest-score/README.md index 618c5dff0..f836ef9e5 100644 --- a/problems/smallest-rotation-with-highest-score/README.md +++ b/problems/smallest-rotation-with-highest-score/README.md @@ -11,26 +11,26 @@ ## [798. Smallest Rotation with Highest Score (Hard)](https://leetcode.com/problems/smallest-rotation-with-highest-score "得分最高的最小轮调") -

     Given an array A, we may rotate it by a non-negative integer K so that the array becomes A[K], A[K+1], A{K+2], ... A[A.length - 1], A[0], A[1], ..., A[K-1].  Afterward, any entries that are less than or equal to their index are worth 1 point. 

    +

    Given an array nums, we may rotate it by a non-negative integer k so that the array becomes nums[k], nums[k+1], nums[k+2], ... nums[nums.length - 1], nums[0], nums[1], ..., nums[k-1].  Afterward, any entries that are less than or equal to their index are worth 1 point.

    -

    For example, if we have [2, 4, 1, 3, 0], and we rotate by K = 2, it becomes [1, 3, 0, 2, 4].  This is worth 3 points because 1 > 0 [no points], 3 > 1 [no points], 0 <= 2 [one point], 2 <= 3 [one point], 4 <= 4 [one point].

    +

    For example, if we have [2, 4, 1, 3, 0], and we rotate by k = 2, it becomes [1, 3, 0, 2, 4]. This is worth 3 points because 1 > 0 [no points], 3 > 1 [no points], 0 <= 2 [one point], 2 <= 3 [one point], 4 <= 4 [one point].

    -

    Over all possible rotations, return the rotation index K that corresponds to the highest score we could receive.  If there are multiple answers, return the smallest such index K.

    +

    Over all possible rotations, return the rotation index k that corresponds to the highest score we could receive. If there are multiple answers, return the smallest such index k.

     Example 1:
     Input: [2, 3, 1, 4, 0]
     Output: 3
     Explanation:  
    -Scores for each K are listed below: 
    -K = 0,  A = [2,3,1,4,0],    score 2
    -K = 1,  A = [3,1,4,0,2],    score 3
    -K = 2,  A = [1,4,0,2,3],    score 3
    -K = 3,  A = [4,0,2,3,1],    score 4
    -K = 4,  A = [0,2,3,1,4],    score 3
    +Scores for each k are listed below: 
    +k = 0,  nums = [2,3,1,4,0],    score 2
    +k = 1,  nums = [3,1,4,0,2],    score 3
    +k = 2,  nums = [1,4,0,2,3],    score 3
    +k = 3,  nums = [4,0,2,3,1],    score 4
    +k = 4,  nums = [0,2,3,1,4],    score 3
     
    -

    So we should choose K = 3, which has the highest score.

    +

    So we should choose k = 3, which has the highest score.

     

    @@ -38,13 +38,13 @@ K = 4, A = [0,2,3,1,4], score 3 Example 2: Input: [1, 3, 0, 2, 4] Output: 0 -Explanation: A will always have 3 points no matter how it shifts. -So we will choose the smallest K, which is 0. +Explanation: nums will always have 3 points no matter how it shifts. +So we will choose the smallest k, which is 0.

    Note:

      -
    • A will have length at most 20000.
    • -
    • A[i] will be in the range [0, A.length].
    • +
    • nums will have length at most 20000.
    • +
    • nums[i] will be in the range [0, nums.length].
    diff --git a/problems/solve-the-equation/README.md b/problems/solve-the-equation/README.md index e825bc691..29d39be6e 100644 --- a/problems/solve-the-equation/README.md +++ b/problems/solve-the-equation/README.md @@ -11,54 +11,35 @@ ## [640. Solve the Equation (Medium)](https://leetcode.com/problems/solve-the-equation "求解方程") -

    -Solve a given equation and return the value of x in the form of string "x=#value". The equation contains only '+', '-' operation, the variable x and its coefficient. -

    - -

    -If there is no solution for the equation, return "No solution". -

    -

    -If there are infinite solutions for the equation, return "Infinite solutions". -

    -

    -If there is exactly one solution for the equation, we ensure that the value of x is an integer. -

    - -

    Example 1:
    -

    -Input: "x+5-3+x=6+x-2"
    -Output: "x=2"
    -
    -

    - -

    Example 2:
    -

    -Input: "x=x"
    -Output: "Infinite solutions"
    -
    -

    - -

    Example 3:
    -

    -Input: "2x=x"
    -Output: "x=0"
    -
    -

    - -

    Example 4:
    -

    -Input: "2x+3x-6x=x+2"
    -Output: "x=-1"
    -
    -

    - -

    Example 5:
    -

    -Input: "x=x+2"
    -Output: "No solution"
    +

    Solve a given equation and return the value of 'x' in the form of a string "x=#value". The equation contains only '+', '-' operation, the variable 'x' and its coefficient. You should return "No solution" if there is no solution for the equation, or "Infinite solutions" if there are infinite solutions for the equation.

    + +

    If there is exactly one solution for the equation, we ensure that the value of 'x' is an integer.

    + +

     

    +

    Example 1:

    +
    Input: equation = "x+5-3+x=6+x-2"
    +Output: "x=2"
    +

    Example 2:

    +
    Input: equation = "x=x"
    +Output: "Infinite solutions"
    +

    Example 3:

    +
    Input: equation = "2x=x"
    +Output: "x=0"
    +

    Example 4:

    +
    Input: equation = "2x+3x-6x=x+2"
    +Output: "x=-1"
    +

    Example 5:

    +
    Input: equation = "x=x+2"
    +Output: "No solution"
     
    -

    +

     

    +

    Constraints:

    + +
      +
    • 3 <= equation.length <= 1000
    • +
    • equation has exactly one '='.
    • +
    • equation consists of integers with an absolute value in the range [0, 100] without any leading zeros, and the variable 'x'.
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/sort-array-by-parity/README.md b/problems/sort-array-by-parity/README.md index 81a47709a..c5803bf8a 100644 --- a/problems/sort-array-by-parity/README.md +++ b/problems/sort-array-by-parity/README.md @@ -11,7 +11,7 @@ ## [905. Sort Array By Parity (Easy)](https://leetcode.com/problems/sort-array-by-parity "按奇偶排序数组") -

    Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A.

    +

    Given an array nums of non-negative integers, return an array consisting of all the even elements of nums, followed by all the odd elements of nums.

    You may return any answer array that satisfies this condition.

    @@ -21,7 +21,7 @@

    Example 1:

    -Input: [3,1,2,4]
    +Input: nums = [3,1,2,4]
     Output: [2,4,3,1]
     The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be accepted.
     
    @@ -31,8 +31,8 @@ The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be accepted.

    Note:

      -
    1. 1 <= A.length <= 5000
    2. -
    3. 0 <= A[i] <= 5000
    4. +
    5. 1 <= nums.length <= 5000
    6. +
    7. 0 <= nums[i] <= 5000
    diff --git a/problems/sort-colors/README.md b/problems/sort-colors/README.md index c48d94b28..63d40821c 100644 --- a/problems/sort-colors/README.md +++ b/problems/sort-colors/README.md @@ -15,6 +15,8 @@

    We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively.

    +

    You must solve this problem without using the library's sort function.

    +

     

    Example 1:

    Input: nums = [2,0,2,1,1,0]
    @@ -39,12 +41,7 @@
     
     
     

     

    -

    Follow up:

    - -
      -
    • Could you solve this problem without using the library's sort function?
    • -
    • Could you come up with a one-pass algorithm using only O(1) constant space?
    • -
    +

    Follow up: Could you come up with a one-pass algorithm using only constant extra space?

    ### Related Topics [[Sort](../../tag/sort/README.md)] diff --git a/problems/soup-servings/README.md b/problems/soup-servings/README.md index 7a5dbb405..836692716 100644 --- a/problems/soup-servings/README.md +++ b/problems/soup-servings/README.md @@ -11,37 +11,37 @@ ## [808. Soup Servings (Medium)](https://leetcode.com/problems/soup-servings "分汤") -

    There are two types of soup: type A and type B. Initially we have N ml of each type of soup. There are four kinds of operations:

    +

    There are two types of soup: type A and type B. Initially we have n ml of each type of soup. There are four kinds of operations:

      -
    1. Serve 100 ml of soup A and 0 ml of soup B
    2. -
    3. Serve 75 ml of soup A and 25 ml of soup B
    4. +
    5. Serve 100 ml of soup A and 0 ml of soup B
    6. +
    7. Serve 75 ml of soup A and 25 ml of soup B
    8. Serve 50 ml of soup A and 50 ml of soup B
    9. Serve 25 ml of soup A and 75 ml of soup B
    -

    When we serve some soup, we give it to someone and we no longer have it.  Each turn, we will choose from the four operations with equal probability 0.25. If the remaining volume of soup is not enough to complete the operation, we will serve as much as we can.  We stop once we no longer have some quantity of both types of soup.

    +

    When we serve some soup, we give it to someone and we no longer have it. Each turn, we will choose from the four operations with equal probability 0.25. If the remaining volume of soup is not enough to complete the operation, we will serve as much as we can. We stop once we no longer have some quantity of both types of soup.

    -

    Note that we do not have the operation where all 100 ml's of soup B are used first.  

    +

    Note that we do not have the operation where all 100 ml's of soup B are used first.

    -

    Return the probability that soup A will be empty first, plus half the probability that A and B become empty at the same time.

    +

    Return the probability that soup A will be empty first, plus half the probability that A and B become empty at the same time.

     

     Example:
    -Input: N = 50
    +Input: n = 50
     Output: 0.625
     Explanation: 
     If we choose the first two operations, A will become empty first. For the third operation, A and B will become empty at the same time. For the fourth operation, B will become empty first. So the total probability of A becoming empty first plus half the probability that A and B become empty at the same time, is 0.25 * (1 + 1 + 0.5 + 0) = 0.625.
     
     
    -

    Notes:

    +

    Notes:

      -
    • 0 <= N <= 10^9
    • -
    • Answers within 10^-6 of the true value will be accepted as correct.
    • +
    • 0 <= n <= 109.
    • +
    • Answers within 10-6 of the true value will be accepted as correct.
    ### Related Topics diff --git a/problems/special-binary-string/README.md b/problems/special-binary-string/README.md index da6f20953..6edfe9061 100644 --- a/problems/special-binary-string/README.md +++ b/problems/special-binary-string/README.md @@ -11,31 +11,33 @@ ## [761. Special Binary String (Hard)](https://leetcode.com/problems/special-binary-string "特殊的二进制序列") -

    -Special binary strings are binary strings with the following two properties: -

    -

  • The number of 0's is equal to the number of 1's.
  • -
  • Every prefix of the binary string has at least as many 1's as 0's.
  • -

    -Given a special string S, a move consists of choosing two consecutive, non-empty, special substrings of S, and swapping them. (Two strings are consecutive if the last character of the first string is exactly one index before the first character of the second string.) -

    -At the end of any number of moves, what is the lexicographically largest resulting string possible? -

    - -

    Example 1:
    +

    Special binary strings are binary strings with the following two properties:

    + +
      +
    • The number of 0's is equal to the number of 1's.
    • +
    • Every prefix of the binary string has at least as many 1's as 0's.
    • +
    + +

    Given a special string s, a move consists of choosing two consecutive, non-empty, special substrings of s, and swapping them. (Two strings are consecutive if the last character of the first string is exactly one index before the first character of the second string.)

    + +

    At the end of any number of moves, what is the lexicographically largest resulting string possible?

    + +

    Example 1:

    +
    -Input: S = "11011000"
    -Output: "11100100"
    +Input: s = "11011000"
    +Output: "11100100"
     Explanation:
    -The strings "10" [occuring at S[1]] and "1100" [at S[3]] are swapped.
    +The strings "10" [occuring at s[1]] and "1100" [at s[3]] are swapped.
     This is the lexicographically largest string possible after some number of swaps.
     
    -

    -

    Note:

      -
    1. S has length at most 50.
    2. -
    3. S is guaranteed to be a special binary string as defined above.
    4. -

    +

    Note:

    + +
      +
    1. s has length at most 50.
    2. +
    3. s is guaranteed to be a special binary string as defined above.
    4. +
    ### Related Topics [[Recursion](../../tag/recursion/README.md)] diff --git a/problems/spiral-matrix-iii/README.md b/problems/spiral-matrix-iii/README.md index 640c62380..63b639891 100644 --- a/problems/spiral-matrix-iii/README.md +++ b/problems/spiral-matrix-iii/README.md @@ -11,7 +11,7 @@ ## [885. Spiral Matrix III (Medium)](https://leetcode.com/problems/spiral-matrix-iii "螺旋矩阵 III") -

    On a 2 dimensional grid with R rows and C columns, we start at (r0, c0) facing east.

    +

    On a 2 dimensional grid with rows rows and cols columns, we start at (rStart, cStart) facing east.

    Here, the north-west corner of the grid is at the first row and column, and the south-east corner of the grid is at the last row and column.

    @@ -19,7 +19,7 @@

    Whenever we would move outside the boundary of the grid, we continue our walk outside the grid (but may return to the grid boundary later.) 

    -

    Eventually, we reach all R * C spaces of the grid.

    +

    Eventually, we reach all rows * cols spaces of the grid.

    Return a list of coordinates representing the positions of the grid in the order they were visited.

    @@ -28,7 +28,7 @@

    Example 1:

    -Input: R = 1, C = 4, r0 = 0, c0 = 0
    +Input: rows = 1, cols = 4, rStart = 0, cStart = 0
     Output: [[0,0],[0,1],[0,2],[0,3]]
     
     
    @@ -39,7 +39,7 @@
     

    Example 2:

    -Input: R = 5, C = 6, r0 = 1, c0 = 4
    +Input: rows = 5, cols = 6, rStart = 1, cStart = 4
     Output: [[1,4],[1,5],[2,5],[2,4],[2,3],[1,3],[0,3],[0,4],[0,5],[3,5],[3,4],[3,3],[3,2],[2,2],[1,2],[0,2],[4,5],[4,4],[4,3],[4,2],[4,1],[3,1],[2,1],[1,1],[0,1],[4,0],[3,0],[2,0],[1,0],[0,0]]
     
     
    @@ -52,10 +52,10 @@
     

    Note:

      -
    1. 1 <= R <= 100
    2. -
    3. 1 <= C <= 100
    4. -
    5. 0 <= r0 < R
    6. -
    7. 0 <= c0 < C
    8. +
    9. 1 <= rows <= 100
    10. +
    11. 1 <= cols <= 100
    12. +
    13. 0 <= rStart < rows
    14. +
    15. 0 <= cStart < cols
    diff --git a/problems/split-array-into-fibonacci-sequence/README.md b/problems/split-array-into-fibonacci-sequence/README.md index 81a7dc0f8..249a895a3 100644 --- a/problems/split-array-into-fibonacci-sequence/README.md +++ b/problems/split-array-into-fibonacci-sequence/README.md @@ -11,7 +11,7 @@ ## [842. Split Array into Fibonacci Sequence (Medium)](https://leetcode.com/problems/split-array-into-fibonacci-sequence "将数组拆分成斐波那契序列") -

    Given a string S of digits, such as S = "123456579", we can split it into a Fibonacci-like sequence [123, 456, 579].

    +

    Given a string num of digits, such as num = "123456579", we can split it into a Fibonacci-like sequence [123, 456, 579].

    Formally, a Fibonacci-like sequence is a list F of non-negative integers such that:

    @@ -23,26 +23,26 @@

    Also, note that when splitting the string into pieces, each piece must not have extra leading zeroes, except if the piece is the number 0 itself.

    -

    Return any Fibonacci-like sequence split from S, or return [] if it cannot be done.

    +

    Return any Fibonacci-like sequence split from num, or return [] if it cannot be done.

    Example 1:

    -Input: "123456579"
    +Input: num = "123456579"
     Output: [123,456,579]
     

    Example 2:

    -Input: "11235813"
    +Input: num = "11235813"
     Output: [1,1,2,3,5,8,13]
     

    Example 3:

    -Input: "112358130"
    +Input: num = "112358130"
     Output: []
     Explanation: The task is impossible.
     
    @@ -50,7 +50,7 @@

    Example 4:

    -Input: "0123"
    +Input: num = "0123"
     Output: []
     Explanation: Leading zeroes are not allowed, so "01", "2", "3" is not valid.
     
    @@ -58,7 +58,7 @@

    Example 5:

    -Input: "1101111"
    +Input: num = "1101111"
     Output: [110, 1, 111]
     Explanation: The output [11, 0, 11, 11] would also be accepted.
     
    @@ -66,8 +66,8 @@

    Note:

      -
    1. 1 <= S.length <= 200
    2. -
    3. S contains only digits.
    4. +
    5. 1 <= num.length <= 200
    6. +
    7. num contains only digits.
    ### Related Topics diff --git a/problems/splitting-a-string-into-descending-consecutive-values/README.md b/problems/splitting-a-string-into-descending-consecutive-values/README.md new file mode 100644 index 000000000..bf1697775 --- /dev/null +++ b/problems/splitting-a-string-into-descending-consecutive-values/README.md @@ -0,0 +1,84 @@ + + + + + + + +[< Previous](../minimum-distance-to-the-target-element "Minimum Distance to the Target Element") +                 +[Next >](../minimum-adjacent-swaps-to-reach-the-kth-smallest-number "Minimum Adjacent Swaps to Reach the Kth Smallest Number") + +## [1849. Splitting a String Into Descending Consecutive Values (Medium)](https://leetcode.com/problems/splitting-a-string-into-descending-consecutive-values "将字符串拆分为递减的连续值") + +

    You are given a string s that consists of only digits.

    + +

    Check if we can split s into two or more non-empty substrings such that the numerical values of the substrings are in descending order and the difference between numerical values of every two adjacent substrings is equal to 1.

    + +
      +
    • For example, the string s = "0090089" can be split into ["0090", "089"] with numerical values [90,89]. The values are in descending order and adjacent values differ by 1, so this way is valid.
    • +
    • Another example, the string s = "001" can be split into ["0", "01"], ["00", "1"], or ["0", "0", "1"]. However all the ways are invalid because they have numerical values [0,1], [0,1], and [0,0,1] respectively, all of which are not in descending order.
    • +
    + +

    Return true if it is possible to split s​​​​​​ as described above, or false otherwise.

    + +

    A substring is a contiguous sequence of characters in a string.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "1234"
    +Output: false
    +Explanation: There is no valid way to split s.
    +
    + +

    Example 2:

    + +
    +Input: s = "050043"
    +Output: true
    +Explanation: s can be split into ["05", "004", "3"] with numerical values [5,4,3].
    +The values are in descending order with adjacent values differing by 1.
    +
    + +

    Example 3:

    + +
    +Input: s = "9080701"
    +Output: false
    +Explanation: There is no valid way to split s.
    +
    + +

    Example 4:

    + +
    +Input: s = "10009998"
    +Output: true
    +Explanation: s can be split into ["100", "099", "98"] with numerical values [100,99,98].
    +The values are in descending order with adjacent values differing by 1.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 20
    • +
    • s only consists of digits.
    • +
    + +### Related Topics + [[Recursion](../../tag/recursion/README.md)] + [[String](../../tag/string/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
    +Hint 1 +One solution is to try all possible splits using backtrack +
    + +
    +Hint 2 +Look out for trailing zeros in string +
    diff --git a/problems/strange-printer/README.md b/problems/strange-printer/README.md index 06520e782..f0eb9992d 100644 --- a/problems/strange-printer/README.md +++ b/problems/strange-printer/README.md @@ -11,37 +11,39 @@ ## [664. Strange Printer (Hard)](https://leetcode.com/problems/strange-printer "奇怪的打印机") -

    -There is a strange printer with the following two special requirements: +

    There is a strange printer with the following two special properties:

    -
      -
    1. The printer can only print a sequence of the same character each time.
    2. -
    3. At each turn, the printer can print new characters starting from and ending at any places, and will cover the original existing characters.
    4. -
    +
      +
    • The printer can only print a sequence of the same character each time.
    • +
    • At each turn, the printer can print new characters starting from and ending at any place and will cover the original existing characters.
    • +
    -

    +

    Given a string s, return the minimum number of turns the printer needed to print it.

    -

    -Given a string consists of lower English letters only, your job is to count the minimum number of turns the printer needed in order to print it. -

    +

     

    +

    Example 1:

    -

    Example 1:

    -Input: "aaabbb"
    -Output: 2
    -Explanation: Print "aaa" first and then print "bbb".
    +Input: s = "aaabbb"
    +Output: 2
    +Explanation: Print "aaa" first and then print "bbb".
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: "aba"
    -Output: 2
    -Explanation: Print "aaa" first and then print "b" from the second place of the string, which will cover the existing character 'a'.
    +Input: s = "aba"
    +Output: 2
    +Explanation: Print "aaa" first and then print "b" from the second place of the string, which will cover the existing character 'a'.
     
    -

    -

    Hint: Length of the given string will not exceed 100.

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 100
    • +
    • s consists of lowercase English letters.
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/string-compression/README.md b/problems/string-compression/README.md index 70c339043..ccaefde00 100644 --- a/problems/string-compression/README.md +++ b/problems/string-compression/README.md @@ -23,11 +23,7 @@

    The compressed string s should not be returned separately, but instead be stored in the input character array chars. Note that group lengths that are 10 or longer will be split into multiple characters in chars.

    After you are done modifying the input array, return the new length of the array.

    -  - -

    Follow up:
    -Could you solve it using only O(1) extra space?

    - +You must write an algorithm that uses only constant extra space.

     

    Example 1:

    diff --git a/problems/subarray-sums-divisible-by-k/README.md b/problems/subarray-sums-divisible-by-k/README.md index 3e42f6a1c..9db2e729c 100644 --- a/problems/subarray-sums-divisible-by-k/README.md +++ b/problems/subarray-sums-divisible-by-k/README.md @@ -11,7 +11,7 @@ ## [974. Subarray Sums Divisible by K (Medium)](https://leetcode.com/problems/subarray-sums-divisible-by-k "和可被 K 整除的子数组") -

    Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by K.

    +

    Given an array nums of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by k.

     

    @@ -19,9 +19,9 @@

    Example 1:

    -Input: A = [4,5,0,-2,-3,1], K = 5
    +Input: nums = [4,5,0,-2,-3,1], k = 5
     Output: 7
    -Explanation: There are 7 subarrays with a sum divisible by K = 5:
    +Explanation: There are 7 subarrays with a sum divisible by k = 5:
     [4, 5, 0, -2, -3, 1], [5], [5, 0], [5, 0, -2, -3], [0], [0, -2, -3], [-2, -3]
     
    @@ -30,9 +30,9 @@

    Note:

      -
    1. 1 <= A.length <= 30000
    2. -
    3. -10000 <= A[i] <= 10000
    4. -
    5. 2 <= K <= 10000
    6. +
    7. 1 <= nums.length <= 30000
    8. +
    9. -10000 <= nums[i] <= 10000
    10. +
    11. 2 <= k <= 10000
    diff --git a/problems/subarrays-with-k-different-integers/README.md b/problems/subarrays-with-k-different-integers/README.md index baa2312b3..a611f9055 100644 --- a/problems/subarrays-with-k-different-integers/README.md +++ b/problems/subarrays-with-k-different-integers/README.md @@ -11,18 +11,18 @@ ## [992. Subarrays with K Different Integers (Hard)](https://leetcode.com/problems/subarrays-with-k-different-integers "K 个不同整数的子数组") -

    Given an array A of positive integers, call a (contiguous, not necessarily distinct) subarray of A good if the number of different integers in that subarray is exactly K.

    +

    Given an array nums of positive integers, call a (contiguous, not necessarily distinct) subarray of nums good if the number of different integers in that subarray is exactly k.

    (For example, [1,2,3,1,2] has 3 different integers: 1, 2, and 3.)

    -

    Return the number of good subarrays of A.

    +

    Return the number of good subarrays of nums.

     

    Example 1:

    -Input: A = [1,2,1,2,3], K = 2
    +Input: nums = [1,2,1,2,3], k = 2
     Output: 7
     Explanation: Subarrays formed with exactly 2 different integers: [1,2], [2,1], [1,2], [2,3], [1,2,1], [2,1,2], [1,2,1,2].
     
    @@ -30,7 +30,7 @@

    Example 2:

    -Input: A = [1,2,1,3,4], K = 3
    +Input: nums = [1,2,1,3,4], k = 3
     Output: 3
     Explanation: Subarrays formed with exactly 3 different integers: [1,2,1,3], [2,1,3], [1,3,4].
     
    @@ -40,9 +40,9 @@

    Note:

      -
    1. 1 <= A.length <= 20000
    2. -
    3. 1 <= A[i] <= A.length
    4. -
    5. 1 <= K <= A.length
    6. +
    7. 1 <= nums.length <= 20000
    8. +
    9. 1 <= nums[i] <= nums.length
    10. +
    11. 1 <= k <= nums.length
    ### Related Topics diff --git a/problems/subtree-of-another-tree/README.md b/problems/subtree-of-another-tree/README.md index de3ec8219..18dc89855 100644 --- a/problems/subtree-of-another-tree/README.md +++ b/problems/subtree-of-another-tree/README.md @@ -11,51 +11,34 @@ ## [572. Subtree of Another Tree (Easy)](https://leetcode.com/problems/subtree-of-another-tree "另一个树的子树") -

    Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree consists of a node in s and all of this node's descendants. The tree s could also be considered as a subtree of itself.

    +

    Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise.

    -

    Example 1:
    -Given tree s:

    - -
    -     3
    -    / \
    -   4   5
    -  / \
    - 1   2
    -
    -Given tree t: - -
    -   4 
    -  / \
    - 1   2
    -
    -Return true, because t has the same structure and node values with a subtree of s. +

    A subtree of a binary tree tree is a tree that consists of a node in tree and all of this node's descendants. The tree tree could also be considered as a subtree of itself.

     

    - -

    Example 2:
    -Given tree s:

    - +

    Example 1:

    +
    -     3
    -    / \
    -   4   5
    -  / \
    - 1   2
    -    /
    -   0
    +Input: root = [3,4,5,1,2], subRoot = [4,1,2]
    +Output: true
     
    -Given tree t: +

    Example 2:

    +
    -   4
    -  / \
    - 1   2
    +Input: root = [3,4,5,1,2,null,null,0], subRoot = [4,1,2]
    +Output: false
     
    -Return false.

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the root tree is in the range [1, 2000].
    • +
    • The number of nodes in the subRoot tree is in the range [1, 1000].
    • +
    • -104 <= root.val <= 104
    • +
    • -104 <= subRoot.val <= 104
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/sum-of-distances-in-tree/README.md b/problems/sum-of-distances-in-tree/README.md index 9798110da..c850d868d 100644 --- a/problems/sum-of-distances-in-tree/README.md +++ b/problems/sum-of-distances-in-tree/README.md @@ -11,7 +11,7 @@ ## [834. Sum of Distances in Tree (Hard)](https://leetcode.com/problems/sum-of-distances-in-tree "树中距离之和") -

    An undirected, connected tree with N nodes labelled 0...N-1 and N-1 edges are given.

    +

    An undirected, connected tree with n nodes labelled 0...n-1 and n-1 edges are given.

    The ith edge connects nodes edges[i][0] and edges[i][1] together.

    @@ -20,7 +20,7 @@

    Example 1:

    -Input: N = 6, edges = [[0,1],[0,2],[2,3],[2,4],[2,5]]
    +Input: n = 6, edges = [[0,1],[0,2],[2,3],[2,4],[2,5]]
     Output: [8,12,6,10,10,10]
     Explanation: 
     Here is a diagram of the given tree:
    @@ -33,7 +33,7 @@ We can see that dist(0,1) + dist(0,2) + dist(0,3) + dist(0,4) + dist(0,5)
     equals 1 + 1 + 2 + 2 + 2 = 8.  Hence, answer[0] = 8, and so on.
     
    -

    Note: 1 <= N <= 10000

    +

    Note: 1 <= n <= 10000

    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/sum-of-even-numbers-after-queries/README.md b/problems/sum-of-even-numbers-after-queries/README.md index ba86d4305..a415fb7c6 100644 --- a/problems/sum-of-even-numbers-after-queries/README.md +++ b/problems/sum-of-even-numbers-after-queries/README.md @@ -11,11 +11,11 @@ ## [985. Sum of Even Numbers After Queries (Easy)](https://leetcode.com/problems/sum-of-even-numbers-after-queries "查询后的偶数和") -

    We have an array A of integers, and an array queries of queries.

    +

    We have an array nums of integers, and an array queries of queries.

    -

    For the i-th query val = queries[i][0], index = queries[i][1], we add val to A[index].  Then, the answer to the i-th query is the sum of the even values of A.

    +

    For the i-th query val = queries[i][0], index = queries[i][1], we add val to nums[index].  Then, the answer to the i-th query is the sum of the even values of A.

    -

    (Here, the given index = queries[i][1] is a 0-based index, and each query permanently modifies the array A.)

    +

    (Here, the given index = queries[i][1] is a 0-based index, and each query permanently modifies the array nums.)

    Return the answer to all queries.  Your answer array should have answer[i] as the answer to the i-th query.

    @@ -24,14 +24,14 @@

    Example 1:

    -Input: A = [1,2,3,4], queries = [[1,0],[-3,1],[-4,0],[2,3]]
    +Input: nums = [1,2,3,4], queries = [[1,0],[-3,1],[-4,0],[2,3]]
     Output: [8,6,2,4]
     Explanation: 
     At the beginning, the array is [1,2,3,4].
    -After adding 1 to A[0], the array is [2,2,3,4], and the sum of even values is 2 + 2 + 4 = 8.
    -After adding -3 to A[1], the array is [2,-1,3,4], and the sum of even values is 2 + 4 = 6.
    -After adding -4 to A[0], the array is [-2,-1,3,4], and the sum of even values is -2 + 4 = 2.
    -After adding 2 to A[3], the array is [-2,-1,3,6], and the sum of even values is -2 + 6 = 4.
    +After adding 1 to nums[0], the array is [2,2,3,4], and the sum of even values is 2 + 2 + 4 = 8.
    +After adding -3 to nums[1], the array is [2,-1,3,4], and the sum of even values is 2 + 4 = 6.
    +After adding -4 to nums[0], the array is [-2,-1,3,4], and the sum of even values is -2 + 4 = 2.
    +After adding 2 to nums[3], the array is [-2,-1,3,6], and the sum of even values is -2 + 6 = 4.
     

     

    @@ -39,11 +39,11 @@ After adding 2 to A[3], the array is [-2,-1,3,6], and the sum of even values is

    Note:

      -
    1. 1 <= A.length <= 10000
    2. -
    3. -10000 <= A[i] <= 10000
    4. +
    5. 1 <= nums.length <= 10000
    6. +
    7. -10000 <= nums[i] <= 10000
    8. 1 <= queries.length <= 10000
    9. -10000 <= queries[i][0] <= 10000
    10. -
    11. 0 <= queries[i][1] < A.length
    12. +
    13. 0 <= queries[i][1] < nums.length
    ### Related Topics diff --git a/problems/sum-of-mutated-array-closest-to-target/README.md b/problems/sum-of-mutated-array-closest-to-target/README.md index f7ef1d2f2..041e20f21 100644 --- a/problems/sum-of-mutated-array-closest-to-target/README.md +++ b/problems/sum-of-mutated-array-closest-to-target/README.md @@ -11,7 +11,7 @@ ## [1300. Sum of Mutated Array Closest to Target (Medium)](https://leetcode.com/problems/sum-of-mutated-array-closest-to-target "转变数组后最接近目标值的数组和") -

    Given an integer array arr and a target value target, return the integer value such that when we change all the integers larger than value in the given array to be equal to value, the sum of the array gets as close as possible (in absolute difference) to target.

    +

    Given an integer array arr and a target value target, return the integer value such that when we change all the integers larger than value in the given array to be equal to value, the sum of the array gets as close as possible (in absolute difference) to target.

    In case of a tie, return the minimum such integer.

    @@ -44,8 +44,8 @@

    Constraints:

      -
    • 1 <= arr.length <= 10^4
    • -
    • 1 <= arr[i], target <= 10^5
    • +
    • 1 <= arr.length <= 104
    • +
    • 1 <= arr[i], target <= 105
    ### Related Topics diff --git a/problems/sum-of-subsequence-widths/README.md b/problems/sum-of-subsequence-widths/README.md index 84cb22159..e0026b055 100644 --- a/problems/sum-of-subsequence-widths/README.md +++ b/problems/sum-of-subsequence-widths/README.md @@ -11,13 +11,13 @@ ## [891. Sum of Subsequence Widths (Hard)](https://leetcode.com/problems/sum-of-subsequence-widths "子序列宽度之和") -

    Given an array of integers A, consider all non-empty subsequences of A.

    +

    Given an array of integers nums, consider all non-empty subsequences of nums.

    -

    For any sequence S, let the width of S be the difference between the maximum and minimum element of S.

    +

    For any sequence seq, let the width of seq be the difference between the maximum and minimum element of seq.

    -

    Return the sum of the widths of all subsequences of A. 

    +

    Return the sum of the widths of all subsequences of nums

    -

    As the answer may be very large, return the answer modulo 10^9 + 7.

    +

    As the answer may be very large, return the answer modulo 109 + 7.

     

    @@ -25,7 +25,7 @@

    Example 1:

    -Input: [2,1,3]
    +Input: nums = [2,1,3]
     Output: 6
     Explanation:
     Subsequences are [1], [2], [3], [2,1], [2,3], [1,3], [2,1,3].
    @@ -38,8 +38,8 @@ The sum of these widths is 6.
     

    Note:

      -
    • 1 <= A.length <= 20000
    • -
    • 1 <= A[i] <= 20000
    • +
    • 1 <= nums.length <= 20000
    • +
    • 1 <= nums[i] <= 20000
    diff --git a/problems/sum-root-to-leaf-numbers/README.md b/problems/sum-root-to-leaf-numbers/README.md index 86cd2f79e..dff689f8b 100644 --- a/problems/sum-root-to-leaf-numbers/README.md +++ b/problems/sum-root-to-leaf-numbers/README.md @@ -19,7 +19,7 @@
  • For example, the root-to-leaf path 1 -> 2 -> 3 represents the number 123.
  • -

    Return the total sum of all root-to-leaf numbers.

    +

    Return the total sum of all root-to-leaf numbers. Test cases are generated so that the answer will fit in a 32-bit integer.

    A leaf node is a node with no children.

    diff --git a/problems/super-palindromes/README.md b/problems/super-palindromes/README.md index b0abe0157..3f2fa6191 100644 --- a/problems/super-palindromes/README.md +++ b/problems/super-palindromes/README.md @@ -39,7 +39,7 @@ Note that 676 is not a superpalindrome: 26 * 26 = 676, but 26 is not a palindrom
  • 1 <= left.length, right.length <= 18
  • left and right consist of only digits.
  • left and right cannot have leading zeros.
  • -
  • left and right represent integers in the range [1, 1018].
  • +
  • left and right represent integers in the range [1, 1018 - 1].
  • left is less than or equal to right.
  • diff --git a/problems/suspicious-bank-accounts/README.md b/problems/suspicious-bank-accounts/README.md new file mode 100644 index 000000000..7a04a8b35 --- /dev/null +++ b/problems/suspicious-bank-accounts/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../next-palindrome-using-same-digits "Next Palindrome Using Same Digits") +                 +[Next >](../replace-all-digits-with-characters "Replace All Digits with Characters") + +## [1843. Suspicious Bank Accounts (Medium)](https://leetcode.com/problems/suspicious-bank-accounts "") + + diff --git a/problems/suspicious-bank-accounts/mysql_schemas.sql b/problems/suspicious-bank-accounts/mysql_schemas.sql new file mode 100644 index 000000000..d93ddcc38 --- /dev/null +++ b/problems/suspicious-bank-accounts/mysql_schemas.sql @@ -0,0 +1,16 @@ +Create table If Not Exists Accounts (account_id int, max_income int); +Create table If Not Exists Transactions (transaction_id int, account_id int, type ENUM('creditor', 'debtor'), amount int, day datetime); +Truncate table Accounts; +insert into Accounts (account_id, max_income) values ('3', '21000'); +insert into Accounts (account_id, max_income) values ('4', '10400'); +Truncate table Transactions; +insert into Transactions (transaction_id, account_id, type, amount, day) values ('2', '3', 'Creditor', '107100', '2021-06-02 11:38:14'); +insert into Transactions (transaction_id, account_id, type, amount, day) values ('4', '4', 'Creditor', '10400', '2021-06-20 12:39:18'); +insert into Transactions (transaction_id, account_id, type, amount, day) values ('11', '4', 'Debtor', '58800', '2021-07-23 12:41:55'); +insert into Transactions (transaction_id, account_id, type, amount, day) values ('1', '4', 'Creditor', '49300', '2021-05-03 16:11:04'); +insert into Transactions (transaction_id, account_id, type, amount, day) values ('15', '3', 'Debtor', '75500', '2021-05-23 14:40:20'); +insert into Transactions (transaction_id, account_id, type, amount, day) values ('10', '3', 'Creditor', '102100', '2021-06-15 10:37:16'); +insert into Transactions (transaction_id, account_id, type, amount, day) values ('14', '4', 'Creditor', '56300', '2021-07-21 12:12:25'); +insert into Transactions (transaction_id, account_id, type, amount, day) values ('19', '4', 'Debtor', '101100', '2021-05-09 15:21:49'); +insert into Transactions (transaction_id, account_id, type, amount, day) values ('8', '3', 'Creditor', '64900', '2021-07-26 15:09:56'); +insert into Transactions (transaction_id, account_id, type, amount, day) values ('7', '3', 'Creditor', '90900', '2021-06-14 11:23:07'); diff --git a/problems/swap-nodes-in-pairs/README.md b/problems/swap-nodes-in-pairs/README.md index 12e7ad620..698a6f723 100644 --- a/problems/swap-nodes-in-pairs/README.md +++ b/problems/swap-nodes-in-pairs/README.md @@ -11,7 +11,7 @@ ## [24. Swap Nodes in Pairs (Medium)](https://leetcode.com/problems/swap-nodes-in-pairs "两两交换链表中的节点") -

    Given a linked list, swap every two adjacent nodes and return its head.

    +

    Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.)

     

    Example 1:

    @@ -43,9 +43,6 @@
  • 0 <= Node.val <= 100
  • -

     

    -Follow up: Can you solve the problem without modifying the values in the list's nodes? (i.e., Only nodes themselves may be changed.) - ### Related Topics [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/triples-with-bitwise-and-equal-to-zero/README.md b/problems/triples-with-bitwise-and-equal-to-zero/README.md index 062d98753..c2fffb1e2 100644 --- a/problems/triples-with-bitwise-and-equal-to-zero/README.md +++ b/problems/triples-with-bitwise-and-equal-to-zero/README.md @@ -11,13 +11,13 @@ ## [982. Triples with Bitwise AND Equal To Zero (Hard)](https://leetcode.com/problems/triples-with-bitwise-and-equal-to-zero "按位与为零的三元组") -

    Given an array of integers A, find the number of triples of indices (i, j, k) such that:

    +

    Given an array of integers nums, find the number of triples of indices (i, j, k) such that:

      -
    • 0 <= i < A.length
    • -
    • 0 <= j < A.length
    • -
    • 0 <= k < A.length
    • -
    • A[i] & A[j] & A[k] == 0, where & represents the bitwise-AND operator.
    • +
    • 0 <= i < nums.length
    • +
    • 0 <= j < nums.length
    • +
    • 0 <= k < nums.length
    • +
    • nums[i] & nums[j] & nums[k] == 0, where & represents the bitwise-AND operator.

     

    @@ -25,7 +25,7 @@

    Example 1:

    -Input: [2,1,3]
    +Input: nums = [2,1,3]
     Output: 12
     Explanation: We could choose the following i, j, k triples:
     (i=0, j=0, k=1) : 2 & 2 & 1
    @@ -47,8 +47,8 @@
     

    Note:

      -
    1. 1 <= A.length <= 1000
    2. -
    3. 0 <= A[i] < 2^16
    4. +
    5. 1 <= nums.length <= 1000
    6. +
    7. 0 <= nums[i] < 216
    ### Related Topics diff --git a/problems/uncommon-words-from-two-sentences/README.md b/problems/uncommon-words-from-two-sentences/README.md index bfa063930..01b9a51bd 100644 --- a/problems/uncommon-words-from-two-sentences/README.md +++ b/problems/uncommon-words-from-two-sentences/README.md @@ -11,7 +11,7 @@ ## [884. Uncommon Words from Two Sentences (Easy)](https://leetcode.com/problems/uncommon-words-from-two-sentences "两句话中的不常见单词") -

    We are given two sentences A and B.  (A sentence is a string of space separated words.  Each word consists only of lowercase letters.)

    +

    We are given two sentences s1 and s2.  (A sentence is a string of space separated words.  Each word consists only of lowercase letters.)

    A word is uncommon if it appears exactly once in one of the sentences, and does not appear in the other sentence.

    @@ -28,7 +28,7 @@

    Example 1:

    -Input: A = "this apple is sweet", B = "this apple is sour"
    +Input: s1 = "this apple is sweet", s2 = "this apple is sour"
     Output: ["sweet","sour"]
     
    @@ -36,7 +36,7 @@

    Example 2:

    -Input: A = "apple apple", B = "banana"
    +Input: s1 = "apple apple", s2 = "banana"
     Output: ["banana"]
     
    @@ -45,9 +45,9 @@

    Note:

      -
    1. 0 <= A.length <= 200
    2. -
    3. 0 <= B.length <= 200
    4. -
    5. A and B both contain only spaces and lowercase letters.
    6. +
    7. 0 <= s1.length <= 200
    8. +
    9. 0 <= s2.length <= 200
    10. +
    11. s1 and s2 both contain only spaces and lowercase letters.
    diff --git a/problems/valid-palindrome-ii/README.md b/problems/valid-palindrome-ii/README.md index 2ec0816d3..4effb8af5 100644 --- a/problems/valid-palindrome-ii/README.md +++ b/problems/valid-palindrome-ii/README.md @@ -11,31 +11,38 @@ ## [680. Valid Palindrome II (Easy)](https://leetcode.com/problems/valid-palindrome-ii "验证回文字符串 Ⅱ") -

    -Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. -

    +

    Given a string s, return true if the s can be palindrome after deleting at most one character from it.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "aba"
    +Output: true
    +
    + +

    Example 2:

    -

    Example 1:

    -Input: "aba"
    -Output: True
    +Input: s = "abca"
    +Output: true
    +Explanation: You could delete the character 'c'.
     
    -

    -

    Example 2:
    +

    Example 3:

    +
    -Input: "abca"
    -Output: True
    -Explanation: You could delete the character 'c'.
    +Input: s = "abc"
    +Output: false
     
    -

    - -

    Note:
    -

      -
    1. The string will only contain lowercase characters a-z. -The maximum length of the string is 50000.
    2. -
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 105
    • +
    • s consists of lowercase English letters.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/valid-permutations-for-di-sequence/README.md b/problems/valid-permutations-for-di-sequence/README.md index 60b5b26a1..02ebbaa50 100644 --- a/problems/valid-permutations-for-di-sequence/README.md +++ b/problems/valid-permutations-for-di-sequence/README.md @@ -11,23 +11,23 @@ ## [903. Valid Permutations for DI Sequence (Hard)](https://leetcode.com/problems/valid-permutations-for-di-sequence "DI 序列的有效排列") -

    We are given S, a length n string of characters from the set {'D', 'I'}. (These letters stand for "decreasing" and "increasing".)

    +

    We are given s, a length n string of characters from the set {'D', 'I'}. (These letters stand for "decreasing" and "increasing".)

    -

    valid permutation is a permutation P[0], P[1], ..., P[n] of integers {0, 1, ..., n}, such that for all i:

    +

    valid permutation is a permutation p[0], p[1], ..., p[n] of integers {0, 1, ..., n}, such that for all i:

      -
    • If S[i] == 'D', then P[i] > P[i+1], and;
    • -
    • If S[i] == 'I', then P[i] < P[i+1].
    • +
    • If s[i] == 'D', then p[i] > p[i+1], and;
    • +
    • If s[i] == 'I', then p[i] < p[i+1].
    -

    How many valid permutations are there?  Since the answer may be large, return your answer modulo 10^9 + 7.

    +

    How many valid permutations are there?  Since the answer may be large, return your answer modulo 109 + 7.

     

    Example 1:

    -Input: "DID"
    +Input: s = "DID"
     Output: 5
     Explanation: 
     The 5 valid permutations of (0, 1, 2, 3) are:
    @@ -43,8 +43,8 @@ The 5 valid permutations of (0, 1, 2, 3) are:
     

    Note:

      -
    1. 1 <= S.length <= 200
    2. -
    3. S consists only of characters from the set {'D', 'I'}.
    4. +
    5. 1 <= s.length <= 200
    6. +
    7. s consists only of characters from the set {'D', 'I'}.
    diff --git a/problems/valid-triangle-number/README.md b/problems/valid-triangle-number/README.md index 67ba0dc61..32b59e907 100644 --- a/problems/valid-triangle-number/README.md +++ b/problems/valid-triangle-number/README.md @@ -11,26 +11,34 @@ ## [611. Valid Triangle Number (Medium)](https://leetcode.com/problems/valid-triangle-number "有效三角形的个数") -Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle. +

    Given an integer array nums, return the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: [2,2,3,4]
    -Output: 3
    -Explanation:
    -Valid combinations are: 
    +Input: nums = [2,2,3,4]
    +Output: 3
    +Explanation: Valid combinations are: 
     2,3,4 (using the first 2)
     2,3,4 (using the second 2)
     2,2,3
     
    -

    - -

    Note:
    -

      -
    1. The length of the given array won't exceed 1000.
    2. -
    3. The integers in the given array are in the range of [0, 1000].
    4. -
    -

    + +

    Example 2:

    + +
    +Input: nums = [4,2,3,4]
    +Output: 4
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • 0 <= nums[i] <= 1000
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/validate-binary-search-tree/README.md b/problems/validate-binary-search-tree/README.md index e0feda0ec..2ca27ef61 100644 --- a/problems/validate-binary-search-tree/README.md +++ b/problems/validate-binary-search-tree/README.md @@ -51,5 +51,5 @@ [[Recursion](../../tag/recursion/README.md)] ### Similar Questions - 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Medium) + 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Easy) 1. [Find Mode in Binary Search Tree](../find-mode-in-binary-search-tree) (Easy) diff --git a/problems/wiggle-subsequence/README.md b/problems/wiggle-subsequence/README.md index 6a744d8d1..a1beb4adc 100644 --- a/problems/wiggle-subsequence/README.md +++ b/problems/wiggle-subsequence/README.md @@ -11,7 +11,7 @@ ## [376. Wiggle Subsequence (Medium)](https://leetcode.com/problems/wiggle-subsequence "摆动序列") -

    A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with two or fewer elements is trivially a wiggle sequence.

    +

    A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with one element and a sequence with two non-equal elements are trivially wiggle sequences.

    • For example, [1, 7, 4, 9, 2, 5] is a wiggle sequence because the differences (6, -3, 5, -7, 3) alternate between positive and negative.
    • diff --git a/problems/word-subsets/README.md b/problems/word-subsets/README.md index 9a557652d..485f7cdf5 100644 --- a/problems/word-subsets/README.md +++ b/problems/word-subsets/README.md @@ -11,13 +11,13 @@ ## [916. Word Subsets (Medium)](https://leetcode.com/problems/word-subsets "单词子集") -

      We are given two arrays A and B of words.  Each word is a string of lowercase letters.

      +

      We are given two arrays words1 and words2 of words.  Each word is a string of lowercase letters.

      Now, say that word b is a subset of word a if every letter in b occurs in a, including multiplicity.  For example, "wrr" is a subset of "warrior", but is not a subset of "world".

      -

      Now say a word a from A is universal if for every b in B, b is a subset of a

      +

      Now say a word a from words1 is universal if for every b in words2, b is a subset of a

      -

      Return a list of all universal words in A.  You can return the words in any order.

      +

      Return a list of all universal words in words1.  You can return the words in any order.

       

      @@ -28,7 +28,7 @@

      Example 1:

      -Input: A = ["amazon","apple","facebook","google","leetcode"], B = ["e","o"]
      +Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","o"]
       Output: ["facebook","google","leetcode"]
       
      @@ -36,7 +36,7 @@

      Example 2:

      -Input: A = ["amazon","apple","facebook","google","leetcode"], B = ["l","e"]
      +Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["l","e"]
       Output: ["apple","google","leetcode"]
       
      @@ -44,7 +44,7 @@

      Example 3:

      -Input: A = ["amazon","apple","facebook","google","leetcode"], B = ["e","oo"]
      +Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","oo"]
       Output: ["facebook","google"]
       
      @@ -52,7 +52,7 @@

      Example 4:

      -Input: A = ["amazon","apple","facebook","google","leetcode"], B = ["lo","eo"]
      +Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["lo","eo"]
       Output: ["google","leetcode"]
       
      @@ -60,7 +60,7 @@

      Example 5:

      -Input: A = ["amazon","apple","facebook","google","leetcode"], B = ["ec","oc","ceo"]
      +Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["ec","oc","ceo"]
       Output: ["facebook","leetcode"]
       
      @@ -69,10 +69,10 @@

      Note:

        -
      1. 1 <= A.length, B.length <= 10000
      2. -
      3. 1 <= A[i].length, B[i].length <= 10
      4. -
      5. A[i] and B[i] consist only of lowercase letters.
      6. -
      7. All words in A[i] are unique: there isn't i != j with A[i] == A[j].
      8. +
      9. 1 <= words1.length, words2.length <= 10000
      10. +
      11. 1 <= words1[i].length, words2[i].length <= 10
      12. +
      13. words1[i] and words2[i] consist only of lowercase letters.
      14. +
      15. All words in words1[i] are unique: there isn't i != j with words1[i] == words1[j].
    diff --git a/readme/1-300.md b/readme/1-300.md index 441dc0d20..ca7f91ed4 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -171,7 +171,7 @@ LeetCode Problems' Solutions | 91 | [Decode Ways](https://leetcode.com/problems/decode-ways "解码方法") | [Go](../problems/decode-ways) | Medium | | 92 | [Reverse Linked List II](https://leetcode.com/problems/reverse-linked-list-ii "反转链表 II") | [Go](../problems/reverse-linked-list-ii) | Medium | | 93 | [Restore IP Addresses](https://leetcode.com/problems/restore-ip-addresses "复原 IP 地址") | [Go](../problems/restore-ip-addresses) | Medium | -| 94 | [Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal "二叉树的中序遍历") | [Go](../problems/binary-tree-inorder-traversal) | Medium | +| 94 | [Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal "二叉树的中序遍历") | [Go](../problems/binary-tree-inorder-traversal) | Easy | | 95 | [Unique Binary Search Trees II](https://leetcode.com/problems/unique-binary-search-trees-ii "不同的二叉搜索树 II") | [Go](../problems/unique-binary-search-trees-ii) | Medium | | 96 | [Unique Binary Search Trees](https://leetcode.com/problems/unique-binary-search-trees "不同的二叉搜索树") | [Go](../problems/unique-binary-search-trees) | Medium | | 97 | [Interleaving String](https://leetcode.com/problems/interleaving-string "交错字符串") | [Go](../problems/interleaving-string) | Medium | @@ -221,8 +221,8 @@ LeetCode Problems' Solutions | 141 | [Linked List Cycle](https://leetcode.com/problems/linked-list-cycle "环形链表") | [Go](../problems/linked-list-cycle) | Easy | | 142 | [Linked List Cycle II](https://leetcode.com/problems/linked-list-cycle-ii "环形链表 II") | [Go](../problems/linked-list-cycle-ii) | Medium | | 143 | [Reorder List](https://leetcode.com/problems/reorder-list "重排链表") | [Go](../problems/reorder-list) | Medium | -| 144 | [Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal "二叉树的前序遍历") | [Go](../problems/binary-tree-preorder-traversal) | Medium | -| 145 | [Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历") | [Go](../problems/binary-tree-postorder-traversal) | Medium | +| 144 | [Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal "二叉树的前序遍历") | [Go](../problems/binary-tree-preorder-traversal) | Easy | +| 145 | [Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历") | [Go](../problems/binary-tree-postorder-traversal) | Easy | | 146 | [LRU Cache](https://leetcode.com/problems/lru-cache "LRU 缓存机制") | [Go](../problems/lru-cache) | Medium | | 147 | [Insertion Sort List](https://leetcode.com/problems/insertion-sort-list "对链表进行插入排序") | [Go](../problems/insertion-sort-list) | Medium | | 148 | [Sort List](https://leetcode.com/problems/sort-list "排序链表") | [Go](../problems/sort-list) | Medium | diff --git a/readme/601-900.md b/readme/601-900.md index 381873bdd..29b14e0aa 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -217,7 +217,7 @@ LeetCode Problems' Solutions | 737 | [Sentence Similarity II](https://leetcode.com/problems/sentence-similarity-ii "句子相似性 II") 🔒 | [Go](../problems/sentence-similarity-ii) | Medium | | 738 | [Monotone Increasing Digits](https://leetcode.com/problems/monotone-increasing-digits "单调递增的数字") | [Go](../problems/monotone-increasing-digits) | Medium | | 739 | [Daily Temperatures](https://leetcode.com/problems/daily-temperatures "每日温度") | [Go](../problems/daily-temperatures) | Medium | -| 740 | [Delete and Earn](https://leetcode.com/problems/delete-and-earn "删除与获得点数") | [Go](../problems/delete-and-earn) | Medium | +| 740 | [Delete and Earn](https://leetcode.com/problems/delete-and-earn "删除并获得点数") | [Go](../problems/delete-and-earn) | Medium | | 741 | [Cherry Pickup](https://leetcode.com/problems/cherry-pickup "摘樱桃") | [Go](../problems/cherry-pickup) | Hard | | 742 | [Closest Leaf in a Binary Tree](https://leetcode.com/problems/closest-leaf-in-a-binary-tree "二叉树最近的叶节点") 🔒 | [Go](../problems/closest-leaf-in-a-binary-tree) | Medium | | 743 | [Network Delay Time](https://leetcode.com/problems/network-delay-time "网络延迟时间") | [Go](../problems/network-delay-time) | Medium | diff --git a/tag/README.md b/tag/README.md index e858b6a0b..8dd94dc0a 100644 --- a/tag/README.md +++ b/tag/README.md @@ -11,8 +11,8 @@ | :-: | - | :-: | - | :-: | - | :-: | | 1 | [Array](array/README.md) | [数组](https://openset.github.io/tags/array/) | | 2 | [Dynamic Programming](dynamic-programming/README.md) | [动态规划](https://openset.github.io/tags/dynamic-programming/) | | 3 | [String](string/README.md) | [字符串](https://openset.github.io/tags/string/) | | 4 | [Math](math/README.md) | [数学](https://openset.github.io/tags/math/) | -| 5 | [Tree](tree/README.md) | [树](https://openset.github.io/tags/tree/) | | 6 | [Depth-first Search](depth-first-search/README.md) | [深度优先搜索](https://openset.github.io/tags/depth-first-search/) | -| 7 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 8 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | +| 5 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 6 | [Tree](tree/README.md) | [树](https://openset.github.io/tags/tree/) | +| 7 | [Depth-first Search](depth-first-search/README.md) | [深度优先搜索](https://openset.github.io/tags/depth-first-search/) | | 8 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | | 9 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | | 11 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | | 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | @@ -23,10 +23,10 @@ | 23 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | | 25 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | | 27 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | -| 29 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | -| 31 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 32 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | -| 33 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 34 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | -| 35 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 36 | [Dequeue](dequeue/README.md) | [Dequeue](https://openset.github.io/tags/dequeue/) | +| 29 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | | 30 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | +| 31 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 32 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | +| 33 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | | 34 | [Dequeue](dequeue/README.md) | [Dequeue](https://openset.github.io/tags/dequeue/) | +| 35 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 36 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 37 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | | 38 | [Suffix Array](suffix-array/README.md) | [Suffix Array](https://openset.github.io/tags/suffix-array/) | | 39 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | | 40 | [Reservoir Sampling](reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | | 41 | [Meet In The Middle](meet-in-the-middle/README.md) | [Meet In The Middle](https://openset.github.io/tags/meet-in-the-middle/) | | 42 | [Memoization](memoization/README.md) | [记忆化](https://openset.github.io/tags/memoization/) | diff --git a/tag/array/README.md b/tag/array/README.md index 33c19bbae..2673a153a 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1854 | [人口最多的年份](../../problems/maximum-population-year) | [[数组](../array/README.md)] | Easy | +| 1852 | [Distinct Numbers in Each Subarray](../../problems/distinct-numbers-in-each-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1848 | [到目标元素的最小距离](../../problems/minimum-distance-to-the-target-element) | [[数组](../array/README.md)] | Easy | | 1833 | [雪糕的最大数量](../../problems/maximum-ice-cream-bars) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1827 | [最少操作使数组递增](../../problems/minimum-operations-to-make-the-array-increasing) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 1826 | [Faulty Sensor](../../problems/faulty-sensor) 🔒 | [[数组](../array/README.md)] | Easy | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 1f0eaa5fb..4ae003998 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1849 | [将字符串拆分为递减的连续值](../../problems/splitting-a-string-into-descending-consecutive-values) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index bd40a61e6..102b33019 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1855 | [下标对中的最大距离](../../problems/maximum-distance-between-a-pair-of-values) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1847 | [最近的房间](../../problems/closest-room) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1840 | [最高建筑高度](../../problems/maximum-building-height) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1802 | [有界数组中指定下标处的最大值](../../problems/maximum-value-at-a-given-index-in-a-bounded-array) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index b6c2ed5bd..26c91c7d2 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -61,6 +61,7 @@ | 773 | [滑动谜题](../../problems/sliding-puzzle) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 675 | [为高尔夫比赛砍树](../../problems/cut-off-trees-for-golf-event) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | | 559 | [N 叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index e404b2816..29421748c 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -95,7 +95,7 @@ | 721 | [账户合并](../../problems/accounts-merge) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 695 | [岛屿的最大面积](../../problems/max-area-of-island) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 679 | [24 点游戏](../../problems/24-game) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | diff --git a/tag/design/README.md b/tag/design/README.md index 815f9c359..58be112e6 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1845 | [座位预约管理系统](../../problems/seat-reservation-manager) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Medium | | 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] | Hard | | 1797 | [设计一个验证系统](../../problems/design-authentication-manager) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 422cc9e7d..7aee962cb 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1824 | [最少侧跳次数](../../problems/minimum-sideway-jumps) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1815 | [得到新鲜甜甜圈的最多组数](../../problems/maximum-number-of-groups-getting-fresh-donuts) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | @@ -164,7 +166,7 @@ | 750 | [角矩形的数量](../../problems/number-of-corner-rectangles) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | | 746 | [使用最小花费爬楼梯](../../problems/min-cost-climbing-stairs) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 741 | [摘樱桃](../../problems/cherry-pickup) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 740 | [删除与获得点数](../../problems/delete-and-earn) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 740 | [删除并获得点数](../../problems/delete-and-earn) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 8900f7b80..1dac21df8 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1855 | [下标对中的最大距离](../../problems/maximum-distance-between-a-pair-of-values) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1850 | [邻位交换的最小次数](../../problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1846 | [减小和重新排列数组后的最大元素](../../problems/maximum-element-after-decreasing-and-rearranging) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 1842 | [Next Palindrome Using Same Digits](../../problems/next-palindrome-using-same-digits) | [[贪心算法](../greedy/README.md)] | Hard | | 1840 | [最高建筑高度](../../problems/maximum-building-height) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1838 | [最高频元素的频数](../../problems/frequency-of-the-most-frequent-element) | [[贪心算法](../greedy/README.md)] | Medium | | 1827 | [最少操作使数组递增](../../problems/minimum-operations-to-make-the-array-increasing) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | @@ -17,7 +21,7 @@ | 1802 | [有界数组中指定下标处的最大值](../../problems/maximum-value-at-a-given-index-in-a-bounded-array) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | | 1798 | [你能构造出连续值的最大数目](../../problems/maximum-number-of-consecutive-values-you-can-make) | [[贪心算法](../greedy/README.md)] | Medium | -| 1794 | [Count Pairs of Equal Substrings With Minimum Difference](../../problems/count-pairs-of-equal-substrings-with-minimum-difference) 🔒 | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1794 | [统计距离最小的子串对个数](../../problems/count-pairs-of-equal-substrings-with-minimum-difference) 🔒 | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[贪心算法](../greedy/README.md)] | Hard | | 1788 | [Maximize the Beauty of the Garden](../../problems/maximize-the-beauty-of-the-garden) 🔒 | [[贪心算法](../greedy/README.md)] | Hard | | 1785 | [构成特定和需要添加的最少元素](../../problems/minimum-elements-to-add-to-form-a-given-sum) | [[贪心算法](../greedy/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 893f7a670..63b421b13 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1852 | [Distinct Numbers in Each Subarray](../../problems/distinct-numbers-in-each-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | | 1817 | [查找用户活跃分钟数](../../problems/finding-the-users-active-minutes) | [[哈希表](../hash-table/README.md)] | Medium | | 1814 | [统计一个数组中好对子的数目](../../problems/count-nice-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1807 | [替换字符串中的括号内容](../../problems/evaluate-the-bracket-pairs-of-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | @@ -85,7 +86,7 @@ | 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | | 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[堆](../heap/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 676 | [实现一个魔法字典](../../problems/implement-magic-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | @@ -145,7 +146,7 @@ | 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | | 138 | [复制带随机指针的链表](../../problems/copy-list-with-random-pointer) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | | 136 | [只出现一次的数字](../../problems/single-number) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | | 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/heap/README.md b/tag/heap/README.md index 8a8b2c284..191a96216 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1845 | [座位预约管理系统](../../problems/seat-reservation-manager) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Medium | | 1834 | [单线程 CPU](../../problems/single-threaded-cpu) | [[堆](../heap/README.md)] | Medium | | 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] | Hard | | 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md index 932db1472..ce913f3d2 100644 --- a/tag/line-sweep/README.md +++ b/tag/line-sweep/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1852 | [Distinct Numbers in Each Subarray](../../problems/distinct-numbers-in-each-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1851 | [包含每个查询的最小区间](../../problems/minimum-interval-to-include-each-query) | [[Line Sweep](../line-sweep/README.md)] | Hard | | 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | | 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | | 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index b8e465631..f0540afe0 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] | Hard | | 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | | 933 | [最近的请求次数](../../problems/number-of-recent-calls) | [[队列](../queue/README.md)] | Easy | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index b846c366c..f6c72681c 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1849 | [将字符串拆分为递减的连续值](../../problems/splitting-a-string-into-descending-consecutive-values) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | diff --git a/tag/sort/README.md b/tag/sort/README.md index 64c2693ca..496fec772 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1847 | [最近的房间](../../problems/closest-room) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1846 | [减小和重新排列数组后的最大元素](../../problems/maximum-element-after-decreasing-and-rearranging) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | | 1833 | [雪糕的最大数量](../../problems/maximum-ice-cream-bars) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1772 | [按受欢迎程度排列功能](../../problems/sort-features-by-popularity) 🔒 | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1727 | [重新排列后的最大子矩阵](../../problems/largest-submatrix-with-rearrangements) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | diff --git a/tag/stack/README.md b/tag/stack/README.md index e86c8bc67..19f1a0b2a 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -64,10 +64,10 @@ | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | | 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] | Medium | -| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | +| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Easy | | 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | | 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 84 | [柱状图中最大的矩形](../../problems/largest-rectangle-in-histogram) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Hard | | 71 | [简化路径](../../problems/simplify-path) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index e6da153c9..b8cc2bf66 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1850 | [邻位交换的最小次数](../../problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1849 | [将字符串拆分为递减的连续值](../../problems/splitting-a-string-into-descending-consecutive-values) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1844 | [将所有数字用字符替换](../../problems/replace-all-digits-with-characters) | [[字符串](../string/README.md)] | Easy | | 1839 | [所有元音按顺序排布的最长子字符串](../../problems/longest-substring-of-all-vowels-in-order) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1832 | [判断句子是否为全字母句](../../problems/check-if-the-sentence-is-pangram) | [[字符串](../string/README.md)] | Easy | | 1830 | [使字符串有序的最少操作次数](../../problems/minimum-number-of-operations-to-make-string-sorted) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | @@ -19,7 +22,7 @@ | 1805 | [字符串中不同整数的数目](../../problems/number-of-different-integers-in-a-string) | [[字符串](../string/README.md)] | Easy | | 1804 | [实现 Trie (前缀树) II](../../problems/implement-trie-ii-prefix-tree) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | | 1796 | [字符串中第二大的数字](../../problems/second-largest-digit-in-a-string) | [[字符串](../string/README.md)] | Easy | -| 1794 | [Count Pairs of Equal Substrings With Minimum Difference](../../problems/count-pairs-of-equal-substrings-with-minimum-difference) 🔒 | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1794 | [统计距离最小的子串对个数](../../problems/count-pairs-of-equal-substrings-with-minimum-difference) 🔒 | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1790 | [仅执行一次字符串交换能否使两个字符串相等](../../problems/check-if-one-string-swap-can-make-strings-equal) | [[字符串](../string/README.md)] | Easy | | 1781 | [所有子字符串美丽值之和](../../problems/sum-of-beauty-of-all-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1773 | [统计匹配检索规则的物品数量](../../problems/count-items-matching-a-rule) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | diff --git a/tag/tags.json b/tag/tags.json index c35051296..4e2d3ff55 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -19,6 +19,11 @@ "Slug": "math", "TranslatedName": "数学" }, + { + "Name": "Greedy", + "Slug": "greedy", + "TranslatedName": "贪心算法" + }, { "Name": "Tree", "Slug": "tree", @@ -29,11 +34,6 @@ "Slug": "depth-first-search", "TranslatedName": "深度优先搜索" }, - { - "Name": "Greedy", - "Slug": "greedy", - "TranslatedName": "贪心算法" - }, { "Name": "Hash Table", "Slug": "hash-table", @@ -139,6 +139,11 @@ "Slug": "geometry", "TranslatedName": "几何" }, + { + "Name": "Line Sweep", + "Slug": "line-sweep", + "TranslatedName": "Line Sweep" + }, { "Name": "Minimax", "Slug": "minimax", @@ -155,30 +160,25 @@ "TranslatedName": "脑筋急转弯" }, { - "Name": "Line Sweep", - "Slug": "line-sweep", - "TranslatedName": "Line Sweep" + "Name": "Topological Sort", + "Slug": "topological-sort", + "TranslatedName": "拓扑排序" + }, + { + "Name": "Dequeue", + "Slug": "dequeue", + "TranslatedName": "Dequeue" }, { "Name": "Random", "Slug": "random", "TranslatedName": "Random" }, - { - "Name": "Topological Sort", - "Slug": "topological-sort", - "TranslatedName": "拓扑排序" - }, { "Name": "Binary Search Tree", "Slug": "binary-search-tree", "TranslatedName": "二叉搜索树" }, - { - "Name": "Dequeue", - "Slug": "dequeue", - "TranslatedName": "Dequeue" - }, { "Name": "Rolling Hash", "Slug": "rolling-hash", diff --git a/tag/topological-sort/README.md b/tag/topological-sort/README.md index 5a051c022..ec0d2b8df 100644 --- a/tag/topological-sort/README.md +++ b/tag/topological-sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | | 444 | [序列重建](../../problems/sequence-reconstruction) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | | 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | diff --git a/tag/tree/README.md b/tag/tree/README.md index a7857ae07..0f5ca9d2a 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -142,7 +142,7 @@ | 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 156 | [上下翻转二叉树](../../problems/binary-tree-upside-down) 🔒 | [[树](../tree/README.md)] | Medium | -| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | +| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Easy | | 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | | 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | @@ -166,4 +166,4 @@ | 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | | 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index f8bd3404f..b46fa02ce 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1855 | [下标对中的最大距离](../../problems/maximum-distance-between-a-pair-of-values) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1839 | [所有元音按顺序排布的最长子字符串](../../problems/longest-substring-of-all-vowels-in-order) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1800 | [最大升序子数组和](../../problems/maximum-ascending-subarray-sum) | [[双指针](../two-pointers/README.md)] | Easy | | 1750 | [删除字符串两端相同字符后的最短长度](../../problems/minimum-length-of-string-after-deleting-similar-ends) | [[双指针](../two-pointers/README.md)] | Medium | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index 2a1a9e85a..dd99db7bc 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1724 | [检查边长度限制的路径是否存在 II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[贪心算法](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 1697 | [检查边长度限制的路径是否存在](../../problems/checking-existence-of-edge-length-limited-paths) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] | Hard | From d96227e939952056ddbce16bbcd16c1eed76dc82 Mon Sep 17 00:00:00 2001 From: Shuo Date: Fri, 4 Jun 2021 14:26:47 +0800 Subject: [PATCH 131/145] A: new --- README.md | 40 +++++-- problems/1-bit-and-2-bit-characters/README.md | 47 ++++---- problems/132-pattern/README.md | 4 +- problems/ad-free-sessions/README.md | 2 +- problems/ambiguous-coordinates/README.md | 53 +++++---- problems/array-nesting/README.md | 2 +- problems/asteroid-collision/README.md | 2 +- problems/basic-calculator/README.md | 13 ++- .../binary-prefix-divisible-by-5/README.md | 16 +-- problems/binary-search/README.md | 2 + .../README.md | 10 +- problems/binary-subarrays-with-sum/README.md | 38 ++++--- problems/binary-tree-cameras/README.md | 35 +++--- .../binary-tree-inorder-traversal/README.md | 2 +- .../README.md | 2 +- .../binary-tree-preorder-traversal/README.md | 2 +- problems/binary-tree-pruning/README.md | 44 ++++---- problems/bold-words-in-string/README.md | 2 +- problems/buddy-strings/README.md | 22 ++-- problems/calculate-special-bonus/README.md | 14 +++ .../calculate-special-bonus/mysql_schemas.sql | 7 ++ problems/can-place-flowers/README.md | 2 +- .../README.md | 12 +- .../README.md | 83 ++++++++++++++ problems/clumsy-factorial/README.md | 10 +- problems/coin-change-2/README.md | 1 + .../complement-of-base-10-integer/README.md | 12 +- problems/contain-virus/README.md | 88 +++++++-------- problems/convert-to-base-2/README.md | 10 +- problems/count-and-say/README.md | 2 +- .../README.md | 34 +++--- problems/count-of-range-sum/README.md | 2 +- .../count-pairs-with-xor-in-a-range/README.md | 2 +- problems/counting-bits/README.md | 13 +-- problems/daily-temperatures/README.md | 25 ++++- .../department-top-three-salaries/README.md | 78 +++++++++---- problems/design-hashmap/README.md | 3 - problems/design-hashset/README.md | 3 - .../distribute-coins-in-binary-tree/README.md | 18 +-- problems/dota2-senate/README.md | 2 +- problems/employee-importance/README.md | 48 +++++--- problems/encode-and-decode-strings/README.md | 2 +- problems/faulty-sensor/README.md | 2 +- problems/find-and-replace-in-string/README.md | 12 +- problems/find-and-replace-pattern/README.md | 35 +++--- problems/find-common-characters/README.md | 8 +- .../README.md | 2 +- .../README.md | 58 ++++++---- .../README.md | 6 +- .../README.md | 95 ++++++++-------- problems/find-the-duplicate-number/README.md | 8 +- .../README.md | 2 +- .../README.md | 78 +++++++++++++ .../flatten-nested-list-iterator/README.md | 12 ++ problems/flood-fill/README.md | 58 +++++----- .../README.md | 76 +++++++++++++ problems/gray-code/README.md | 31 ++++-- problems/grid-illumination/README.md | 14 +-- .../README.md | 14 +++ .../mysql_schemas.sql | 7 ++ problems/grumpy-bookstore-owner/README.md | 6 +- .../increasing-triplet-subsequence/README.md | 2 +- problems/incremental-memory-leak/README.md | 65 +++++++++++ problems/insert-delete-getrandom-o1/README.md | 2 +- problems/ip-to-cidr/README.md | 2 +- problems/is-subsequence/README.md | 8 +- problems/jump-game-ii/README.md | 4 +- problems/jump-game-vii/README.md | 65 +++++++++++ problems/jump-game/README.md | 2 +- problems/k-th-symbol-in-grammar/README.md | 48 ++++++-- .../README.md | 2 +- .../README.md | 8 +- problems/lexicographical-numbers/README.md | 5 +- .../README.md | 77 +++++++++++++ .../longest-arithmetic-subsequence/README.md | 14 +-- .../longest-consecutive-sequence/README.md | 9 +- .../longest-increasing-subsequence/README.md | 7 +- problems/longest-string-chain/README.md | 26 ++++- .../longest-word-with-all-prefixes/README.md | 30 +++++ .../matrix-cells-in-distance-order/README.md | 26 ++--- problems/max-value-of-equation/README.md | 21 ++-- .../README.md | 20 ++-- .../maximum-depth-of-n-ary-tree/README.md | 4 +- problems/maximum-gap/README.md | 5 +- .../README.md | 2 +- .../README.md | 6 +- .../maximum-sum-circular-subarray/README.md | 57 ++++------ .../README.md | 22 ++-- .../maximum-value-after-insertion/README.md | 70 ++++++++++++ .../README.md | 6 +- problems/merge-intervals/README.md | 2 +- problems/merge-sorted-array/README.md | 37 +++++-- .../README.md | 71 ++++++++++++ .../README.md | 28 +++++ .../README.md | 43 ++++---- problems/minimum-cost-for-tickets/README.md | 46 ++++---- .../minimum-cost-to-merge-stones/README.md | 43 +++----- .../README.md | 18 +-- .../README.md | 2 + .../README.md | 65 +++++++++++ .../README.md | 83 ++++++++++++++ .../minimum-speed-to-arrive-on-time/README.md | 83 ++++++++++++++ problems/minimum-window-substring/README.md | 36 ++++-- .../minimum-xor-sum-of-two-arrays/README.md | 67 ++++++++++++ problems/monotone-increasing-digits/README.md | 30 +++-- .../README.md | 4 +- .../n-ary-tree-preorder-traversal/README.md | 2 +- problems/n-queens/README.md | 2 +- problems/not-boring-movies/README.md | 63 +++++++---- problems/number-of-1-bits/README.md | 2 +- .../README.md | 69 ++++++++++++ .../README.md | 8 +- .../numbers-with-repeated-digits/README.md | 10 +- problems/occurrences-after-bigram/README.md | 34 ++---- .../README.md | 14 +++ .../mysql_schemas.sql | 16 +++ .../pacific-atlantic-water-flow/README.md | 2 +- problems/parallel-courses-ii/README.md | 27 +++-- .../README.md | 3 +- problems/power-of-two/README.md | 2 +- .../README.md | 2 +- problems/print-binary-tree/README.md | 15 ++- .../process-tasks-using-servers/README.md | 79 ++++++++++++++ .../README.md | 28 +++++ problems/rearrange-products-table/README.md | 2 +- .../README.md | 8 +- problems/regions-cut-by-slashes/README.md | 103 +++++------------- .../README.md | 4 +- .../README.md | 5 +- .../remove-outermost-parentheses/README.md | 18 +-- .../README.md | 32 +++--- problems/restore-ip-addresses/README.md | 2 +- .../README.md | 8 +- problems/rle-iterator/README.md | 60 +++++----- problems/rotate-function/README.md | 2 +- problems/rotate-image/README.md | 2 +- problems/rotating-the-box/README.md | 92 ++++++++++++++++ .../README.md | 4 +- problems/self-crossing/README.md | 7 +- problems/self-dividing-numbers/README.md | 40 ++++--- .../smallest-integer-divisible-by-k/README.md | 20 ++-- problems/sorting-the-sentence/README.md | 65 +++++++++++ .../README.md | 30 +++-- .../README.md | 48 ++++---- problems/sqrtx/README.md | 2 + problems/stone-game-viii/README.md | 87 +++++++++++++++ problems/string-compression/README.md | 2 +- .../subarray-product-less-than-k/README.md | 35 ++++-- .../README.md | 56 ++++++++++ problems/subtree-of-another-tree/README.md | 2 +- .../sum-of-all-subset-xor-totals/README.md | 86 +++++++++++++++ problems/sum-of-floored-pairs/README.md | 60 ++++++++++ problems/teemo-attacking/README.md | 28 ++--- problems/to-lower-case/README.md | 29 ++--- .../README.md | 10 +- problems/two-sum/README.md | 5 +- problems/uncrossed-lines/README.md | 20 ++-- problems/valid-number/README.md | 8 +- problems/valid-tic-tac-toe-state/README.md | 51 +++++---- problems/validate-ip-address/README.md | 2 +- .../README.md | 2 +- .../README.md | 5 +- problems/video-stitching/README.md | 44 ++++---- readme/1-300.md | 6 +- readme/301-600.md | 6 +- readme/601-900.md | 2 +- tag/README.md | 14 +-- tag/array/README.md | 13 ++- tag/backtracking/README.md | 1 + tag/binary-search/README.md | 2 + tag/bit-manipulation/README.md | 7 +- tag/breadth-first-search/README.md | 1 + tag/depth-first-search/README.md | 1 + tag/design/README.md | 3 +- tag/dynamic-programming/README.md | 9 +- tag/greedy/README.md | 7 +- tag/hash-table/README.md | 6 +- tag/heap/README.md | 1 + tag/line-sweep/README.md | 3 +- tag/math/README.md | 7 +- tag/ordered-map/README.md | 1 + tag/recursion/README.md | 1 + tag/sort/README.md | 2 + tag/stack/README.md | 2 +- tag/string/README.md | 7 +- tag/tags.json | 40 +++---- tag/tree/README.md | 2 +- tag/trie/README.md | 1 + tag/two-pointers/README.md | 3 + tag/union-find/README.md | 2 +- 190 files changed, 3061 insertions(+), 1159 deletions(-) create mode 100644 problems/calculate-special-bonus/README.md create mode 100644 problems/calculate-special-bonus/mysql_schemas.sql create mode 100644 problems/check-if-word-equals-summation-of-two-words/README.md create mode 100644 problems/finding-pairs-with-a-certain-sum/README.md create mode 100644 problems/get-biggest-three-rhombus-sums-in-a-grid/README.md create mode 100644 problems/group-employees-of-the-same-salary/README.md create mode 100644 problems/group-employees-of-the-same-salary/mysql_schemas.sql create mode 100644 problems/incremental-memory-leak/README.md create mode 100644 problems/jump-game-vii/README.md create mode 100644 problems/longer-contiguous-segments-of-ones-than-zeros/README.md create mode 100644 problems/longest-word-with-all-prefixes/README.md create mode 100644 problems/maximum-value-after-insertion/README.md create mode 100644 problems/minimize-maximum-pair-sum-in-array/README.md create mode 100644 problems/minimize-product-sum-of-two-arrays/README.md create mode 100644 problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md create mode 100644 problems/minimum-skips-to-arrive-at-meeting-on-time/README.md create mode 100644 problems/minimum-speed-to-arrive-on-time/README.md create mode 100644 problems/minimum-xor-sum-of-two-arrays/README.md create mode 100644 problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible/README.md create mode 100644 problems/orders-with-maximum-quantity-above-average/README.md create mode 100644 problems/orders-with-maximum-quantity-above-average/mysql_schemas.sql create mode 100644 problems/process-tasks-using-servers/README.md create mode 100644 problems/product-of-two-run-length-encoded-arrays/README.md create mode 100644 problems/rotating-the-box/README.md create mode 100644 problems/sorting-the-sentence/README.md create mode 100644 problems/stone-game-viii/README.md create mode 100644 problems/substrings-of-size-three-with-distinct-characters/README.md create mode 100644 problems/sum-of-all-subset-xor-totals/README.md create mode 100644 problems/sum-of-floored-pairs/README.md diff --git a/README.md b/README.md index 35034100f..49cee62ab 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,32 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1883 | [Minimum Skips to Arrive at Meeting On Time](https://leetcode.com/problems/minimum-skips-to-arrive-at-meeting-on-time "准时抵达会议现场的最小跳过休息次数") | [Go](problems/minimum-skips-to-arrive-at-meeting-on-time) | Hard | +| 1882 | [Process Tasks Using Servers](https://leetcode.com/problems/process-tasks-using-servers "使用服务器处理任务") | [Go](problems/process-tasks-using-servers) | Medium | +| 1881 | [Maximum Value after Insertion](https://leetcode.com/problems/maximum-value-after-insertion "插入后的最大值") | [Go](problems/maximum-value-after-insertion) | Medium | +| 1880 | [Check if Word Equals Summation of Two Words](https://leetcode.com/problems/check-if-word-equals-summation-of-two-words "检查某单词是否等于两单词之和") | [Go](problems/check-if-word-equals-summation-of-two-words) | Easy | +| 1879 | [Minimum XOR Sum of Two Arrays](https://leetcode.com/problems/minimum-xor-sum-of-two-arrays "两个数组最小的异或值之和") | [Go](problems/minimum-xor-sum-of-two-arrays) | Hard | +| 1878 | [Get Biggest Three Rhombus Sums in a Grid](https://leetcode.com/problems/get-biggest-three-rhombus-sums-in-a-grid "矩阵中最大的三个菱形和") | [Go](problems/get-biggest-three-rhombus-sums-in-a-grid) | Medium | +| 1877 | [Minimize Maximum Pair Sum in Array](https://leetcode.com/problems/minimize-maximum-pair-sum-in-array "数组中最大数对和的最小值") | [Go](problems/minimize-maximum-pair-sum-in-array) | Medium | +| 1876 | [Substrings of Size Three with Distinct Characters](https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters "长度为三且各字符不同的子字符串") | [Go](problems/substrings-of-size-three-with-distinct-characters) | Easy | +| 1875 | [Group Employees of the Same Salary](https://leetcode.com/problems/group-employees-of-the-same-salary) 🔒 | [MySQL](problems/group-employees-of-the-same-salary) | Medium | +| 1874 | [Minimize Product Sum of Two Arrays](https://leetcode.com/problems/minimize-product-sum-of-two-arrays) 🔒 | [Go](problems/minimize-product-sum-of-two-arrays) | Medium | +| 1873 | [Calculate Special Bonus](https://leetcode.com/problems/calculate-special-bonus) 🔒 | [MySQL](problems/calculate-special-bonus) | Easy | +| 1872 | [Stone Game VIII](https://leetcode.com/problems/stone-game-viii "石子游戏 VIII") | [Go](problems/stone-game-viii) | Hard | +| 1871 | [Jump Game VII](https://leetcode.com/problems/jump-game-vii "跳跃游戏 VII") | [Go](problems/jump-game-vii) | Medium | +| 1870 | [Minimum Speed to Arrive on Time](https://leetcode.com/problems/minimum-speed-to-arrive-on-time "准时到达的列车最小时速") | [Go](problems/minimum-speed-to-arrive-on-time) | Medium | +| 1869 | [Longer Contiguous Segments of Ones than Zeros](https://leetcode.com/problems/longer-contiguous-segments-of-ones-than-zeros "哪种连续子字符串更长") | [Go](problems/longer-contiguous-segments-of-ones-than-zeros) | Easy | +| 1868 | [Product of Two Run-Length Encoded Arrays](https://leetcode.com/problems/product-of-two-run-length-encoded-arrays) 🔒 | [Go](problems/product-of-two-run-length-encoded-arrays) | Medium | +| 1867 | [Orders With Maximum Quantity Above Average](https://leetcode.com/problems/orders-with-maximum-quantity-above-average) 🔒 | [MySQL](problems/orders-with-maximum-quantity-above-average) | Medium | +| 1866 | [Number of Ways to Rearrange Sticks With K Sticks Visible](https://leetcode.com/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible "恰有 K 根木棍可以看到的排列数目") | [Go](problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible) | Hard | +| 1865 | [Finding Pairs With a Certain Sum](https://leetcode.com/problems/finding-pairs-with-a-certain-sum "找出和为指定值的下标对") | [Go](problems/finding-pairs-with-a-certain-sum) | Medium | +| 1864 | [Minimum Number of Swaps to Make the Binary String Alternating](https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating "构成交替字符串需要的最小交换次数") | [Go](problems/minimum-number-of-swaps-to-make-the-binary-string-alternating) | Medium | +| 1863 | [Sum of All Subset XOR Totals](https://leetcode.com/problems/sum-of-all-subset-xor-totals "找出所有子集的异或总和再求和") | [Go](problems/sum-of-all-subset-xor-totals) | Easy | +| 1862 | [Sum of Floored Pairs](https://leetcode.com/problems/sum-of-floored-pairs "向下取整数对和") | [Go](problems/sum-of-floored-pairs) | Hard | +| 1861 | [Rotating the Box](https://leetcode.com/problems/rotating-the-box "旋转盒子") | [Go](problems/rotating-the-box) | Medium | +| 1860 | [Incremental Memory Leak](https://leetcode.com/problems/incremental-memory-leak "增长的内存泄露") | [Go](problems/incremental-memory-leak) | Medium | +| 1859 | [Sorting the Sentence](https://leetcode.com/problems/sorting-the-sentence "将句子排序") | [Go](problems/sorting-the-sentence) | Easy | +| 1858 | [Longest Word With All Prefixes](https://leetcode.com/problems/longest-word-with-all-prefixes) 🔒 | [Go](problems/longest-word-with-all-prefixes) | Medium | | 1857 | [Largest Color Value in a Directed Graph](https://leetcode.com/problems/largest-color-value-in-a-directed-graph "有向图中最大颜色值") | [Go](problems/largest-color-value-in-a-directed-graph) | Hard | | 1856 | [Maximum Subarray Min-Product](https://leetcode.com/problems/maximum-subarray-min-product "子数组最小乘积的最大值") | [Go](problems/maximum-subarray-min-product) | Medium | | 1855 | [Maximum Distance Between a Pair of Values](https://leetcode.com/problems/maximum-distance-between-a-pair-of-values "下标对中的最大距离") | [Go](problems/maximum-distance-between-a-pair-of-values) | Medium | @@ -109,12 +135,12 @@ LeetCode Problems' Solutions | 1829 | [Maximum XOR for Each Query](https://leetcode.com/problems/maximum-xor-for-each-query "每个查询的最大异或值") | [Go](problems/maximum-xor-for-each-query) | Medium | | 1828 | [Queries on Number of Points Inside a Circle](https://leetcode.com/problems/queries-on-number-of-points-inside-a-circle "统计一个圆中点的数目") | [Go](problems/queries-on-number-of-points-inside-a-circle) | Medium | | 1827 | [Minimum Operations to Make the Array Increasing](https://leetcode.com/problems/minimum-operations-to-make-the-array-increasing "最少操作使数组递增") | [Go](problems/minimum-operations-to-make-the-array-increasing) | Easy | -| 1826 | [Faulty Sensor](https://leetcode.com/problems/faulty-sensor) 🔒 | [Go](problems/faulty-sensor) | Easy | +| 1826 | [Faulty Sensor](https://leetcode.com/problems/faulty-sensor "有缺陷的传感器") 🔒 | [Go](problems/faulty-sensor) | Easy | | 1825 | [Finding MK Average](https://leetcode.com/problems/finding-mk-average "求出 MK 平均值") | [Go](problems/finding-mk-average) | Hard | | 1824 | [Minimum Sideway Jumps](https://leetcode.com/problems/minimum-sideway-jumps "最少侧跳次数") | [Go](problems/minimum-sideway-jumps) | Medium | | 1823 | [Find the Winner of the Circular Game](https://leetcode.com/problems/find-the-winner-of-the-circular-game "找出游戏的获胜者") | [Go](problems/find-the-winner-of-the-circular-game) | Medium | | 1822 | [Sign of the Product of an Array](https://leetcode.com/problems/sign-of-the-product-of-an-array "数组元素积的符号") | [Go](problems/sign-of-the-product-of-an-array) | Easy | -| 1821 | [Find Customers With Positive Revenue this Year](https://leetcode.com/problems/find-customers-with-positive-revenue-this-year) 🔒 | [MySQL](problems/find-customers-with-positive-revenue-this-year) | Easy | +| 1821 | [Find Customers With Positive Revenue this Year](https://leetcode.com/problems/find-customers-with-positive-revenue-this-year "寻找今年具有正收入的客户") 🔒 | [MySQL](problems/find-customers-with-positive-revenue-this-year) | Easy | | 1820 | [Maximum Number of Accepted Invitations](https://leetcode.com/problems/maximum-number-of-accepted-invitations) 🔒 | [Go](problems/maximum-number-of-accepted-invitations) | Medium | | 1819 | [Number of Different Subsequences GCDs](https://leetcode.com/problems/number-of-different-subsequences-gcds "序列中不同最大公约数的数目") | [Go](problems/number-of-different-subsequences-gcds) | Hard | | 1818 | [Minimum Absolute Sum Difference](https://leetcode.com/problems/minimum-absolute-sum-difference "绝对差值和") | [Go](problems/minimum-absolute-sum-difference) | Medium | @@ -126,7 +152,7 @@ LeetCode Problems' Solutions | 1812 | [Determine Color of a Chessboard Square](https://leetcode.com/problems/determine-color-of-a-chessboard-square "判断国际象棋棋盘中一个格子的颜色") | [Go](problems/determine-color-of-a-chessboard-square) | Easy | | 1811 | [Find Interview Candidates](https://leetcode.com/problems/find-interview-candidates) 🔒 | [MySQL](problems/find-interview-candidates) | Medium | | 1810 | [Minimum Path Cost in a Hidden Grid](https://leetcode.com/problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [Go](problems/minimum-path-cost-in-a-hidden-grid) | Medium | -| 1809 | [Ad-Free Sessions](https://leetcode.com/problems/ad-free-sessions) 🔒 | [MySQL](problems/ad-free-sessions) | Easy | +| 1809 | [Ad-Free Sessions](https://leetcode.com/problems/ad-free-sessions "没有广告的剧集") 🔒 | [MySQL](problems/ad-free-sessions) | Easy | | 1808 | [Maximize Number of Nice Divisors](https://leetcode.com/problems/maximize-number-of-nice-divisors "好因子的最大数目") | [Go](problems/maximize-number-of-nice-divisors) | Hard | | 1807 | [Evaluate the Bracket Pairs of a String](https://leetcode.com/problems/evaluate-the-bracket-pairs-of-a-string "替换字符串中的括号内容") | [Go](problems/evaluate-the-bracket-pairs-of-a-string) | Medium | | 1806 | [Minimum Number of Operations to Reinitialize a Permutation](https://leetcode.com/problems/minimum-number-of-operations-to-reinitialize-a-permutation "还原排列的最少操作步数") | [Go](problems/minimum-number-of-operations-to-reinitialize-a-permutation) | Medium | @@ -140,13 +166,13 @@ LeetCode Problems' Solutions | 1798 | [Maximum Number of Consecutive Values You Can Make](https://leetcode.com/problems/maximum-number-of-consecutive-values-you-can-make "你能构造出连续值的最大数目") | [Go](problems/maximum-number-of-consecutive-values-you-can-make) | Medium | | 1797 | [Design Authentication Manager](https://leetcode.com/problems/design-authentication-manager "设计一个验证系统") | [Go](problems/design-authentication-manager) | Medium | | 1796 | [Second Largest Digit in a String](https://leetcode.com/problems/second-largest-digit-in-a-string "字符串中第二大的数字") | [Go](problems/second-largest-digit-in-a-string) | Easy | -| 1795 | [Rearrange Products Table](https://leetcode.com/problems/rearrange-products-table) 🔒 | [MySQL](problems/rearrange-products-table) | Easy | +| 1795 | [Rearrange Products Table](https://leetcode.com/problems/rearrange-products-table "每个产品在不同商店的价格") 🔒 | [MySQL](problems/rearrange-products-table) | Easy | | 1794 | [Count Pairs of Equal Substrings With Minimum Difference](https://leetcode.com/problems/count-pairs-of-equal-substrings-with-minimum-difference "统计距离最小的子串对个数") 🔒 | [Go](problems/count-pairs-of-equal-substrings-with-minimum-difference) | Medium | | 1793 | [Maximum Score of a Good Subarray](https://leetcode.com/problems/maximum-score-of-a-good-subarray "好子数组的最大分数") | [Go](problems/maximum-score-of-a-good-subarray) | Hard | | 1792 | [Maximum Average Pass Ratio](https://leetcode.com/problems/maximum-average-pass-ratio "最大平均通过率") | [Go](problems/maximum-average-pass-ratio) | Medium | | 1791 | [Find Center of Star Graph](https://leetcode.com/problems/find-center-of-star-graph "找出星型图的中心节点") | [Go](problems/find-center-of-star-graph) | Medium | | 1790 | [Check if One String Swap Can Make Strings Equal](https://leetcode.com/problems/check-if-one-string-swap-can-make-strings-equal "仅执行一次字符串交换能否使两个字符串相等") | [Go](problems/check-if-one-string-swap-can-make-strings-equal) | Easy | -| 1789 | [Primary Department for Each Employee](https://leetcode.com/problems/primary-department-for-each-employee) 🔒 | [MySQL](problems/primary-department-for-each-employee) | Easy | +| 1789 | [Primary Department for Each Employee](https://leetcode.com/problems/primary-department-for-each-employee "员工的直属部门") 🔒 | [MySQL](problems/primary-department-for-each-employee) | Easy | | 1788 | [Maximize the Beauty of the Garden](https://leetcode.com/problems/maximize-the-beauty-of-the-garden) 🔒 | [Go](problems/maximize-the-beauty-of-the-garden) | Hard | | 1787 | [Make the XOR of All Segments Equal to Zero](https://leetcode.com/problems/make-the-xor-of-all-segments-equal-to-zero "使所有区间的异或结果为零") | [Go](problems/make-the-xor-of-all-segments-equal-to-zero) | Hard | | 1786 | [Number of Restricted Paths From First to Last Node](https://leetcode.com/problems/number-of-restricted-paths-from-first-to-last-node "从第一个节点出发到最后一个节点的受限路径数") | [Go](problems/number-of-restricted-paths-from-first-to-last-node) | Medium | @@ -168,7 +194,7 @@ LeetCode Problems' Solutions | 1770 | [Maximum Score from Performing Multiplication Operations](https://leetcode.com/problems/maximum-score-from-performing-multiplication-operations "执行乘法运算的最大分数") | [Go](problems/maximum-score-from-performing-multiplication-operations) | Medium | | 1769 | [Minimum Number of Operations to Move All Balls to Each Box](https://leetcode.com/problems/minimum-number-of-operations-to-move-all-balls-to-each-box "移动所有球到每个盒子所需的最小操作数") | [Go](problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | Medium | | 1768 | [Merge Strings Alternately](https://leetcode.com/problems/merge-strings-alternately "交替合并字符串") | [Go](problems/merge-strings-alternately) | Easy | -| 1767 | [Find the Subtasks That Did Not Execute](https://leetcode.com/problems/find-the-subtasks-that-did-not-execute) 🔒 | [MySQL](problems/find-the-subtasks-that-did-not-execute) | Hard | +| 1767 | [Find the Subtasks That Did Not Execute](https://leetcode.com/problems/find-the-subtasks-that-did-not-execute "寻找没有被执行的任务对") 🔒 | [MySQL](problems/find-the-subtasks-that-did-not-execute) | Hard | | 1766 | [Tree of Coprimes](https://leetcode.com/problems/tree-of-coprimes "互质树") | [Go](problems/tree-of-coprimes) | Hard | | 1765 | [Map of Highest Peak](https://leetcode.com/problems/map-of-highest-peak "地图中的最高点") | [Go](problems/map-of-highest-peak) | Medium | | 1764 | [Form Array by Concatenating Subarrays of Another Array](https://leetcode.com/problems/form-array-by-concatenating-subarrays-of-another-array "通过连接另一个数组的子数组得到一个数组") | [Go](problems/form-array-by-concatenating-subarrays-of-another-array) | Medium | @@ -389,7 +415,7 @@ LeetCode Problems' Solutions | 1549 | [The Most Recent Orders for Each Product](https://leetcode.com/problems/the-most-recent-orders-for-each-product "每件商品的最新订单") 🔒 | [MySQL](problems/the-most-recent-orders-for-each-product) | Medium | | 1548 | [The Most Similar Path in a Graph](https://leetcode.com/problems/the-most-similar-path-in-a-graph "图中最相似的路径") 🔒 | [Go](problems/the-most-similar-path-in-a-graph) | Hard | | 1547 | [Minimum Cost to Cut a Stick](https://leetcode.com/problems/minimum-cost-to-cut-a-stick "切棍子的最小成本") | [Go](problems/minimum-cost-to-cut-a-stick) | Hard | -| 1546 | [Maximum Number of Non-Overlapping Subarrays With Sum Equals Target](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值的最大数目不重叠非空子数组数目") | [Go](problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | Medium | +| 1546 | [Maximum Number of Non-Overlapping Subarrays With Sum Equals Target](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值且不重叠的非空子数组的最大数目") | [Go](problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | Medium | | 1545 | [Find Kth Bit in Nth Binary String](https://leetcode.com/problems/find-kth-bit-in-nth-binary-string "找出第 N 个二进制字符串中的第 K 位") | [Go](problems/find-kth-bit-in-nth-binary-string) | Medium | | 1544 | [Make The String Great](https://leetcode.com/problems/make-the-string-great "整理字符串") | [Go](problems/make-the-string-great) | Easy | | 1543 | [Fix Product Name Format](https://leetcode.com/problems/fix-product-name-format "产品名称格式修复") 🔒 | [MySQL](problems/fix-product-name-format) | Easy | diff --git a/problems/1-bit-and-2-bit-characters/README.md b/problems/1-bit-and-2-bit-characters/README.md index 5c6032fa3..8a4f4ecb9 100644 --- a/problems/1-bit-and-2-bit-characters/README.md +++ b/problems/1-bit-and-2-bit-characters/README.md @@ -11,34 +11,41 @@ ## [717. 1-bit and 2-bit Characters (Easy)](https://leetcode.com/problems/1-bit-and-2-bit-characters "1比特与2比特字符") -

    We have two special characters. The first character can be represented by one bit 0. The second character can be represented by two bits (10 or 11).

    +

    We have two special characters:

    -

    Now given a string represented by several bits. Return whether the last character must be a one-bit character or not. The given string will always end with a zero.

    +
      +
    • The first character can be represented by one bit 0.
    • +
    • The second character can be represented by two bits (10 or 11).
    • +
    + +

    Given a binary array bits that ends with 0, return true if the last character must be a one-bit character.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: 
    -bits = [1, 0, 0]
    -Output: True
    -Explanation: 
    -The only way to decode it is two-bit character and one-bit character. So the last character is one-bit character.
    +Input: bits = [1,0,0]
    +Output: true
    +Explanation: The only way to decode it is two-bit character and one-bit character.
    +So the last character is one-bit character.
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: 
    -bits = [1, 1, 1, 0]
    -Output: False
    -Explanation: 
    -The only way to decode it is two-bit character and two-bit character. So the last character is NOT one-bit character.
    +Input: bits = [1,1,1,0]
    +Output: false
    +Explanation: The only way to decode it is two-bit character and two-bit character.
    +So the last character is not one-bit character.
     
    -

    -

    Note: -

  • 1 <= len(bits) <= 1000.
  • -
  • bits[i] is always 0 or 1.
  • -

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= bits.length <= 1000
    • +
    • bits[i] is either 0 or 1.
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/132-pattern/README.md b/problems/132-pattern/README.md index 8b2e5aca9..63d65a631 100644 --- a/problems/132-pattern/README.md +++ b/problems/132-pattern/README.md @@ -15,8 +15,6 @@

    Return true if there is a 132 pattern in nums, otherwise, return false.

    -

    Follow up: The O(n^2) is trivial, could you come up with the O(n logn) or the O(n) solution?

    -

     

    Example 1:

    @@ -47,7 +45,7 @@
    • n == nums.length
    • -
    • 1 <= n <= 104
    • +
    • 1 <= n <= 2 * 105
    • -109 <= nums[i] <= 109
    diff --git a/problems/ad-free-sessions/README.md b/problems/ad-free-sessions/README.md index 4bf3ad017..9f37290fc 100644 --- a/problems/ad-free-sessions/README.md +++ b/problems/ad-free-sessions/README.md @@ -9,6 +9,6 @@                  [Next >](../minimum-path-cost-in-a-hidden-grid "Minimum Path Cost in a Hidden Grid") -## [1809. Ad-Free Sessions (Easy)](https://leetcode.com/problems/ad-free-sessions "") +## [1809. Ad-Free Sessions (Easy)](https://leetcode.com/problems/ad-free-sessions "没有广告的剧集") diff --git a/problems/ambiguous-coordinates/README.md b/problems/ambiguous-coordinates/README.md index 8a5cbacd8..7d32f3ffa 100644 --- a/problems/ambiguous-coordinates/README.md +++ b/problems/ambiguous-coordinates/README.md @@ -11,50 +11,57 @@ ## [816. Ambiguous Coordinates (Medium)](https://leetcode.com/problems/ambiguous-coordinates "模糊坐标") -

    We had some 2-dimensional coordinates, like "(1, 3)" or "(2, 0.5)".  Then, we removed all commas, decimal points, and spaces, and ended up with the string s.  Return a list of strings representing all possibilities for what our original coordinates could have been.

    +

    We had some 2-dimensional coordinates, like "(1, 3)" or "(2, 0.5)". Then, we removed all commas, decimal points, and spaces and ended up with the string s.

    -

    Our original representation never had extraneous zeroes, so we never started with numbers like "00", "0.0", "0.00", "1.0", "001", "00.01", or any other number that can be represented with less digits.  Also, a decimal point within a number never occurs without at least one digit occuring before it, so we never started with numbers like ".1".

    +
      +
    • For example, "(1, 3)" becomes s = "(13)" and "(2, 0.5)" becomes s = "(205)".
    • +
    + +

    Return a list of strings representing all possibilities for what our original coordinates could have been.

    + +

    Our original representation never had extraneous zeroes, so we never started with numbers like "00", "0.0", "0.00", "1.0", "001", "00.01", or any other number that can be represented with fewer digits. Also, a decimal point within a number never occurs without at least one digit occurring before it, so we never started with numbers like ".1".

    -

    The final answer list can be returned in any order.  Also note that all coordinates in the final answer have exactly one space between them (occurring after the comma.)

    +

    The final answer list can be returned in any order. All coordinates in the final answer have exactly one space between them (occurring after the comma.)

    + +

     

    +

    Example 1:

    -Example 1:
     Input: s = "(123)"
    -Output: ["(1, 23)", "(12, 3)", "(1.2, 3)", "(1, 2.3)"]
    +Output: ["(1, 2.3)","(1, 23)","(1.2, 3)","(12, 3)"]
     
    +

    Example 2:

    +
    -Example 2:
    -Input: s = "(00011)"
    -Output:  ["(0.001, 1)", "(0, 0.011)"]
    -Explanation: 
    -0.0, 00, 0001 or 00.01 are not allowed.
    +Input: s = "(0123)"
    +Output: ["(0, 1.23)","(0, 12.3)","(0, 123)","(0.1, 2.3)","(0.1, 23)","(0.12, 3)"]
    +Explanation: 0.0, 00, 0001 or 00.01 are not allowed.
     
    +

    Example 3:

    +
    -Example 3:
    -Input: s = "(0123)"
    -Output: ["(0, 123)", "(0, 12.3)", "(0, 1.23)", "(0.1, 23)", "(0.1, 2.3)", "(0.12, 3)"]
    +Input: s = "(00011)"
    +Output: ["(0, 0.011)","(0.001, 1)"]
     
    +

    Example 4:

    +
    -Example 4:
     Input: s = "(100)"
    -Output: [(10, 0)]
    -Explanation: 
    -1.0 is not allowed.
    +Output: ["(10, 0)"]
    +Explanation: 1.0 is not allowed.
     

     

    - -

    Note:

    +

    Constraints:

      -
    • 4 <= s.length <= 12.
    • -
    • s[0] = "(", s[s.length - 1] = ")", and the other elements in s are digits.
    • +
    • 4 <= s.length <= 12
    • +
    • s[0] == '(' and s[s.length - 1] == ')'.
    • +
    • The rest of s are digits.
    -

     

    - ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/array-nesting/README.md b/problems/array-nesting/README.md index 013bd69e1..938bd27cb 100644 --- a/problems/array-nesting/README.md +++ b/problems/array-nesting/README.md @@ -13,7 +13,7 @@

    You are given an integer array nums of length n where nums is a permutation of the numbers in the range [0, n - 1].

    -

    You should build a set s[k] = {nums[k], nums[nums[i]], nums[nums[nums[k]]], ... } subjected to the following rule:

    +

    You should build a set s[k] = {nums[k], nums[nums[k]], nums[nums[nums[k]]], ... } subjected to the following rule:

    • The first element in s[k] starts with the selection of the element nums[k] of index = k.
    • diff --git a/problems/asteroid-collision/README.md b/problems/asteroid-collision/README.md index 96f1b8384..d031d448f 100644 --- a/problems/asteroid-collision/README.md +++ b/problems/asteroid-collision/README.md @@ -54,7 +54,7 @@

      Constraints:

        -
      • 2 <= asteroids.length <= 104
      • +
      • 2 <= asteroids.length <= 104
      • -1000 <= asteroids[i] <= 1000
      • asteroids[i] != 0
      diff --git a/problems/basic-calculator/README.md b/problems/basic-calculator/README.md index f28d6243d..20d1f3ef6 100644 --- a/problems/basic-calculator/README.md +++ b/problems/basic-calculator/README.md @@ -11,9 +11,9 @@ ## [224. Basic Calculator (Hard)](https://leetcode.com/problems/basic-calculator "基本计算器") -

      Given a string s representing an expression, implement a basic calculator to evaluate it.

      +

      Given a string s representing a valid expression, implement a basic calculator to evaluate it, and return the result of the evaluation.

      -

      Note: You are not allowed to use any built-in function which evaluates strings as mathematical expressions, such as eval().

      +

      Note: You are not allowed to use any built-in function which evaluates strings as mathematical expressions, such as eval().

       

      Example 1:

      @@ -37,6 +37,14 @@ Output: 23
    +

    Example 4:

    + +
    +Input: s = "+48 + -48"
    +Output: 0
    +Explanation: Numbers can have multiple digits and start with +/-.
    +
    +

     

    Constraints:

    @@ -44,6 +52,7 @@
  • 1 <= s.length <= 3 * 105
  • s consists of digits, '+', '-', '(', ')', and ' '.
  • s represents a valid expression.
  • +
  • Every number and running calculation will fit in a signed 32-bit integer.
  • ### Related Topics diff --git a/problems/binary-prefix-divisible-by-5/README.md b/problems/binary-prefix-divisible-by-5/README.md index d1ee3b80a..0afdae95f 100644 --- a/problems/binary-prefix-divisible-by-5/README.md +++ b/problems/binary-prefix-divisible-by-5/README.md @@ -11,14 +11,14 @@ ## [1018. Binary Prefix Divisible By 5 (Easy)](https://leetcode.com/problems/binary-prefix-divisible-by-5 "可被 5 整除的二进制前缀") -

    Given an array A of 0s and 1s, consider N_i: the i-th subarray from A[0] to A[i] interpreted as a binary number (from most-significant-bit to least-significant-bit.)

    +

    Given an array nums of 0s and 1s, consider xi: the i-th subarray from nums[0] to nums[i] interpreted as a binary number (from most-significant-bit to least-significant-bit.)

    -

    Return a list of booleans answer, where answer[i] is true if and only if N_i is divisible by 5.

    +

    Return a list of booleans answer, where answer[i] is true if and only if xi is divisible by 5.

    Example 1:

    -Input: [0,1,1]
    +Input: nums = [0,1,1]
     Output: [true,false,false]
     Explanation: 
     The input numbers in binary are 0, 01, 011; which are 0, 1, and 3 in base-10.  Only the first number is divisible by 5, so answer[0] is true.
    @@ -27,21 +27,21 @@ The input numbers in binary are 0, 01, 011; which are 0, 1, and 3 in base-10.  O
     

    Example 2:

    -Input: [1,1,1]
    +Input: nums = [1,1,1]
     Output: [false,false,false]
     

    Example 3:

    -Input: [0,1,1,1,1,1]
    +Input: nums = [0,1,1,1,1,1]
     Output: [true,false,false,false,true,false]
     

    Example 4:

    -Input: [1,1,1,0,1]
    +Input: nums = [1,1,1,0,1]
     Output: [false,false,false,false,false]
     
    @@ -50,8 +50,8 @@ The input numbers in binary are 0, 01, 011; which are 0, 1, and 3 in base-10. O

    Note:

      -
    1. 1 <= A.length <= 30000
    2. -
    3. A[i] is 0 or 1
    4. +
    5. 1 <= nums.length <= 30000
    6. +
    7. nums[i] is 0 or 1
    ### Related Topics diff --git a/problems/binary-search/README.md b/problems/binary-search/README.md index 01078452d..86af03434 100644 --- a/problems/binary-search/README.md +++ b/problems/binary-search/README.md @@ -13,6 +13,8 @@

    Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1.

    +

    You must write an algorithm with O(log n) runtime complexity.

    +

     

    Example 1:

    diff --git a/problems/binary-string-with-substrings-representing-1-to-n/README.md b/problems/binary-string-with-substrings-representing-1-to-n/README.md index ee354f5bf..9d41ab3c5 100644 --- a/problems/binary-string-with-substrings-representing-1-to-n/README.md +++ b/problems/binary-string-with-substrings-representing-1-to-n/README.md @@ -11,21 +11,21 @@ ## [1016. Binary String With Substrings Representing 1 To N (Medium)](https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n "子串能表示从 1 到 N 数字的二进制串") -

    Given a binary string S (a string consisting only of '0' and '1's) and a positive integer N, return true if and only if for every integer X from 1 to N, the binary representation of X is a substring of S.

    +

    Given a binary string s (a string consisting only of '0' and '1's) and a positive integer n, return true if and only if for every integer x from 1 to n, the binary representation of x is a substring of s.

     

    Example 1:

    -Input: S = "0110", N = 3
    +Input: s = "0110", n = 3
     Output: true
     

    Example 2:

    -Input: S = "0110", N = 4
    +Input: s = "0110", n = 4
     Output: false
     
    @@ -34,8 +34,8 @@

    Note:

      -
    1. 1 <= S.length <= 1000
    2. -
    3. 1 <= N <= 10^9
    4. +
    5. 1 <= s.length <= 1000
    6. +
    7. 1 <= n <= 109
    ### Related Topics diff --git a/problems/binary-subarrays-with-sum/README.md b/problems/binary-subarrays-with-sum/README.md index 50524cd97..cc30e8af5 100644 --- a/problems/binary-subarrays-with-sum/README.md +++ b/problems/binary-subarrays-with-sum/README.md @@ -11,32 +11,38 @@ ## [930. Binary Subarrays With Sum (Medium)](https://leetcode.com/problems/binary-subarrays-with-sum "和相同的二元子数组") -

    In an array nums of 0s and 1s, how many non-empty subarrays have sum goal?

    +

    Given a binary array nums and an integer goal, return the number of non-empty subarrays with a sum goal.

    -

     

    +

    A subarray is a contiguous part of the array.

    +

     

    Example 1:

    -Input: nums = [1,0,1,0,1], goal = 2
    -Output: 4
    -Explanation: 
    -The 4 subarrays are bolded below:
    -[1,0,1,0,1]
    -[1,0,1,0,1]
    -[1,0,1,0,1]
    -[1,0,1,0,1]
    +Input: nums = [1,0,1,0,1], goal = 2
    +Output: 4
    +Explanation: The 4 subarrays are bolded and underlined below:
    +[1,0,1,0,1]
    +[1,0,1,0,1]
    +[1,0,1,0,1]
    +[1,0,1,0,1]
     
    -

     

    +

    Example 2:

    -

    Note:

    +
    +Input: nums = [0,0,0,0,0], goal = 0
    +Output: 15
    +
    + +

     

    +

    Constraints:

    -
      -
    1. nums.length <= 30000
    2. +
        +
      • 1 <= nums.length <= 3 * 104
      • +
      • nums[i] is either 0 or 1.
      • 0 <= goal <= nums.length
      • -
      • nums[i] is either 0 or 1.
      • -
    + ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/binary-tree-cameras/README.md b/problems/binary-tree-cameras/README.md index dc265c0a0..bebbe1d3e 100644 --- a/problems/binary-tree-cameras/README.md +++ b/problems/binary-tree-cameras/README.md @@ -11,41 +11,34 @@ ## [968. Binary Tree Cameras (Hard)](https://leetcode.com/problems/binary-tree-cameras "监控二叉树") -

    Given a binary tree, we install cameras on the nodes of the tree. 

    +

    You are given the root of a binary tree. We install cameras on the tree nodes where each camera at a node can monitor its parent, itself, and its immediate children.

    -

    Each camera at a node can monitor its parent, itself, and its immediate children.

    - -

    Calculate the minimum number of cameras needed to monitor all nodes of the tree.

    +

    Return the minimum number of cameras needed to monitor all nodes of the tree.

     

    -

    Example 1:

    -
    -Input: [0,0,null,0,0]
    -Output: 1
    -Explanation: One camera is enough to monitor all nodes if placed as shown.
    +Input: root = [0,0,null,0,0]
    +Output: 1
    +Explanation: One camera is enough to monitor all nodes if placed as shown.
     
    -

    Example 2:

    -Input: [0,0,null,0,null,0,null,null,0]
    -Output: 2
    -Explanation: At least two cameras are needed to monitor all nodes of the tree. The above image shows one of the valid configurations of camera placement.
    +Input: root = [0,0,null,0,null,0,null,null,0]
    +Output: 2
    +Explanation: At least two cameras are needed to monitor all nodes of the tree. The above image shows one of the valid configurations of camera placement.
     
    -


    -Note:

    +

     

    +

    Constraints:

    -
      -
    1. The number of nodes in the given tree will be in the range [1, 1000].
    2. -
    3. Every node has value 0.
    4. -
    -
    -
    +
      +
    • The number of nodes in the tree is in the range [1, 1000].
    • +
    • Node.val == 0
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/binary-tree-inorder-traversal/README.md b/problems/binary-tree-inorder-traversal/README.md index 31cc4eb71..34b7744fe 100644 --- a/problems/binary-tree-inorder-traversal/README.md +++ b/problems/binary-tree-inorder-traversal/README.md @@ -67,7 +67,7 @@ ### Similar Questions 1. [Validate Binary Search Tree](../validate-binary-search-tree) (Medium) - 1. [Binary Tree Preorder Traversal](../binary-tree-preorder-traversal) (Medium) + 1. [Binary Tree Preorder Traversal](../binary-tree-preorder-traversal) (Easy) 1. [Binary Tree Postorder Traversal](../binary-tree-postorder-traversal) (Easy) 1. [Binary Search Tree Iterator](../binary-search-tree-iterator) (Medium) 1. [Kth Smallest Element in a BST](../kth-smallest-element-in-a-bst) (Medium) diff --git a/problems/binary-tree-longest-consecutive-sequence/README.md b/problems/binary-tree-longest-consecutive-sequence/README.md index 1c6bfa49b..f7aca22d7 100644 --- a/problems/binary-tree-longest-consecutive-sequence/README.md +++ b/problems/binary-tree-longest-consecutive-sequence/README.md @@ -53,5 +53,5 @@ Explanation: Longest consecutive sequence path is 2-3](../binary-tree-postorder-traversal "Binary Tree Postorder Traversal") -## [144. Binary Tree Preorder Traversal (Medium)](https://leetcode.com/problems/binary-tree-preorder-traversal "二叉树的前序遍历") +## [144. Binary Tree Preorder Traversal (Easy)](https://leetcode.com/problems/binary-tree-preorder-traversal "二叉树的前序遍历")

    Given the root of a binary tree, return the preorder traversal of its nodes' values.

    diff --git a/problems/binary-tree-pruning/README.md b/problems/binary-tree-pruning/README.md index ab437fa41..ee3e48c9e 100644 --- a/problems/binary-tree-pruning/README.md +++ b/problems/binary-tree-pruning/README.md @@ -11,47 +11,41 @@ ## [814. Binary Tree Pruning (Medium)](https://leetcode.com/problems/binary-tree-pruning "二叉树剪枝") -

    We are given the head node root of a binary tree, where additionally every node's value is either a 0 or a 1.

    +

    Given the root of a binary tree, return the same tree where every subtree (of the given tree) not containing a 1 has been removed.

    -

    Return the same tree where every subtree (of the given tree) not containing a 1 has been removed.

    - -

    (Recall that the subtree of a node X is X, plus every node that is a descendant of X.)

    +

    A subtree of a node node is node plus every node that is a descendant of node.

    +

     

    +

    Example 1:

    +
    -Example 1:
    -Input: [1,null,0,0,1]
    -Output: [1,null,0,null,1]
    - 
    +Input: root = [1,null,0,0,1]
    +Output: [1,null,0,null,1]
     Explanation: 
     Only the red nodes satisfy the property "every subtree not containing a 1".
     The diagram on the right represents the answer.
    -
    -
     
    +

    Example 2:

    +
    -Example 2:
    -Input: [1,0,1,0,0,0,1]
    -Output: [1,null,1,null,1]
    -
    -
    -
    +Input: root = [1,0,1,0,0,0,1]
    +Output: [1,null,1,null,1]
     
    +

    Example 3:

    +
    -Example 3:
    -Input: [1,1,0,1,1,0,1,0]
    -Output: [1,1,0,1,1,null,1]
    -
    -
    -
    +Input: root = [1,1,0,1,1,0,1,0]
    +Output: [1,1,0,1,1,null,1]
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • The binary tree will have at most 200 nodes.
    • -
    • The value of each node will only be 0 or 1.
    • +
    • The number of nodes in the tree is in the range [1, 200].
    • +
    • Node.val is either 0 or 1.
    ### Related Topics diff --git a/problems/bold-words-in-string/README.md b/problems/bold-words-in-string/README.md index bee582ca3..7235b2a54 100644 --- a/problems/bold-words-in-string/README.md +++ b/problems/bold-words-in-string/README.md @@ -9,7 +9,7 @@                  [Next >](../employee-free-time "Employee Free Time") -## [758. Bold Words in String (Easy)](https://leetcode.com/problems/bold-words-in-string "字符串中的加粗单词") +## [758. Bold Words in String (Medium)](https://leetcode.com/problems/bold-words-in-string "字符串中的加粗单词")

    Given a set of keywords words and a string S, make all appearances of all keywords in S bold. Any letters between <b> and </b> tags become bold. diff --git a/problems/buddy-strings/README.md b/problems/buddy-strings/README.md index 3980f40a5..91ee10f90 100644 --- a/problems/buddy-strings/README.md +++ b/problems/buddy-strings/README.md @@ -11,9 +11,9 @@ ## [859. Buddy Strings (Easy)](https://leetcode.com/problems/buddy-strings "亲密字符串") -

    Given two strings a and b, return true if you can swap two letters in a so the result is equal to b, otherwise, return false.

    +

    Given two strings s and goal, return true if you can swap two letters in s so the result is equal to goal, otherwise, return false.

    -

    Swapping letters is defined as taking two indices i and j (0-indexed) such that i != j and swapping the characters at a[i] and a[j].

    +

    Swapping letters is defined as taking two indices i and j (0-indexed) such that i != j and swapping the characters at s[i] and s[j].

    • For example, swapping at indices 0 and 2 in "abcd" results in "cbad".
    • @@ -23,31 +23,31 @@

      Example 1:

      -Input: a = "ab", b = "ba"
      +Input: s = "ab", goal = "ba"
       Output: true
      -Explanation: You can swap a[0] = 'a' and a[1] = 'b' to get "ba", which is equal to b.
      +Explanation: You can swap s[0] = 'a' and s[1] = 'b' to get "ba", which is equal to goal.
       

      Example 2:

      -Input: a = "ab", b = "ab"
      +Input: s = "ab", goal = "ab"
       Output: false
      -Explanation: The only letters you can swap are a[0] = 'a' and a[1] = 'b', which results in "ba" != b.
      +Explanation: The only letters you can swap are s[0] = 'a' and s[1] = 'b', which results in "ba" != goal.
       

      Example 3:

      -Input: a = "aa", b = "aa"
      +Input: s = "aa", goal = "aa"
       Output: true
      -Explanation: You can swap a[0] = 'a' and a[1] = 'a' to get "aa", which is equal to b.
      +Explanation: You can swap s[0] = 'a' and s[1] = 'a' to get "aa", which is equal to goal.
       

      Example 4:

      -Input: a = "aaaaaaabc", b = "aaaaaaacb"
      +Input: s = "aaaaaaabc", goal = "aaaaaaacb"
       Output: true
       
      @@ -55,8 +55,8 @@

      Constraints:

        -
      • 1 <= a.length, b.length <= 2 * 104
      • -
      • a and b consist of lowercase letters.
      • +
      • 1 <= s.length, goal.length <= 2 * 104
      • +
      • s and goal consist of lowercase letters.
      ### Related Topics diff --git a/problems/calculate-special-bonus/README.md b/problems/calculate-special-bonus/README.md new file mode 100644 index 000000000..6c2b05712 --- /dev/null +++ b/problems/calculate-special-bonus/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../stone-game-viii "Stone Game VIII") +                 +[Next >](../minimize-product-sum-of-two-arrays "Minimize Product Sum of Two Arrays") + +## [1873. Calculate Special Bonus (Easy)](https://leetcode.com/problems/calculate-special-bonus "") + + diff --git a/problems/calculate-special-bonus/mysql_schemas.sql b/problems/calculate-special-bonus/mysql_schemas.sql new file mode 100644 index 000000000..d5d505e6f --- /dev/null +++ b/problems/calculate-special-bonus/mysql_schemas.sql @@ -0,0 +1,7 @@ +Create table If Not Exists Employees (employee_id int, name varchar(30), salary int); +Truncate table Employees; +insert into Employees (employee_id, name, salary) values ('2', 'Meir', '3000'); +insert into Employees (employee_id, name, salary) values ('3', 'Michael', '3800'); +insert into Employees (employee_id, name, salary) values ('7', 'Addilyn', '7400'); +insert into Employees (employee_id, name, salary) values ('8', 'Juan', '6100'); +insert into Employees (employee_id, name, salary) values ('9', 'Kannon', '7700'); diff --git a/problems/can-place-flowers/README.md b/problems/can-place-flowers/README.md index 0bc60b921..c50dd2ae1 100644 --- a/problems/can-place-flowers/README.md +++ b/problems/can-place-flowers/README.md @@ -38,5 +38,5 @@ [[Array](../../tag/array/README.md)] ### Similar Questions - 1. [Teemo Attacking](../teemo-attacking) (Medium) + 1. [Teemo Attacking](../teemo-attacking) (Easy) 1. [Asteroid Collision](../asteroid-collision) (Medium) diff --git a/problems/capacity-to-ship-packages-within-d-days/README.md b/problems/capacity-to-ship-packages-within-d-days/README.md index 1ed51797e..6927e812e 100644 --- a/problems/capacity-to-ship-packages-within-d-days/README.md +++ b/problems/capacity-to-ship-packages-within-d-days/README.md @@ -11,17 +11,17 @@ ## [1011. Capacity To Ship Packages Within D Days (Medium)](https://leetcode.com/problems/capacity-to-ship-packages-within-d-days "在 D 天内送达包裹的能力") -

      A conveyor belt has packages that must be shipped from one port to another within D days.

      +

      A conveyor belt has packages that must be shipped from one port to another within days days.

      The ith package on the conveyor belt has a weight of weights[i]. Each day, we load the ship with packages on the conveyor belt (in the order given by weights). We may not load more weight than the maximum weight capacity of the ship.

      -

      Return the least weight capacity of the ship that will result in all the packages on the conveyor belt being shipped within D days.

      +

      Return the least weight capacity of the ship that will result in all the packages on the conveyor belt being shipped within days days.

       

      Example 1:

      -Input: weights = [1,2,3,4,5,6,7,8,9,10], D = 5
      +Input: weights = [1,2,3,4,5,6,7,8,9,10], days = 5
       Output: 15
       Explanation: A ship capacity of 15 is the minimum to ship all the packages in 5 days like this:
       1st day: 1, 2, 3, 4, 5
      @@ -36,7 +36,7 @@ Note that the cargo must be shipped in the order given, so using a ship of capac
       

      Example 2:

      -Input: weights = [3,2,2,4,1,4], D = 3
      +Input: weights = [3,2,2,4,1,4], days = 3
       Output: 6
       Explanation: A ship capacity of 6 is the minimum to ship all the packages in 3 days like this:
       1st day: 3, 2
      @@ -47,7 +47,7 @@ Note that the cargo must be shipped in the order given, so using a ship of capac
       

      Example 3:

      -Input: weights = [1,2,3,1,1], D = 4
      +Input: weights = [1,2,3,1,1], days = 4
       Output: 3
       Explanation:
       1st day: 1
      @@ -60,7 +60,7 @@ Note that the cargo must be shipped in the order given, so using a ship of capac
       

      Constraints:

        -
      • 1 <= D <= weights.length <= 5 * 104
      • +
      • 1 <= days <= weights.length <= 5 * 104
      • 1 <= weights[i] <= 500
      diff --git a/problems/check-if-word-equals-summation-of-two-words/README.md b/problems/check-if-word-equals-summation-of-two-words/README.md new file mode 100644 index 000000000..72644c446 --- /dev/null +++ b/problems/check-if-word-equals-summation-of-two-words/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../minimum-xor-sum-of-two-arrays "Minimum XOR Sum of Two Arrays") +                 +[Next >](../maximum-value-after-insertion "Maximum Value after Insertion") + +## [1880. Check if Word Equals Summation of Two Words (Easy)](https://leetcode.com/problems/check-if-word-equals-summation-of-two-words "检查某单词是否等于两单词之和") + +

      The letter value of a letter is its position in the alphabet starting from 0 (i.e. 'a' -> 0, 'b' -> 1, 'c' -> 2, etc.).

      + +

      The numerical value of some string of lowercase English letters s is the concatenation of the letter values of each letter in s, which is then converted into an integer.

      + +
        +
      • For example, if s = "acb", we concatenate each letter's letter value, resulting in "021". After converting it, we get 21.
      • +
      + +

      You are given three strings firstWord, secondWord, and targetWord, each consisting of lowercase English letters 'a' through 'j' inclusive.

      + +

      Return true if the summation of the numerical values of firstWord and secondWord equals the numerical value of targetWord, or false otherwise.

      + +

       

      +

      Example 1:

      + +
      +Input: firstWord = "acb", secondWord = "cba", targetWord = "cdb"
      +Output: true
      +Explanation:
      +The numerical value of firstWord is "acb" -> "021" -> 21.
      +The numerical value of secondWord is "cba" -> "210" -> 210.
      +The numerical value of targetWord is "cdb" -> "231" -> 231.
      +We return true because 21 + 210 == 231.
      +
      + +

      Example 2:

      + +
      +Input: firstWord = "aaa", secondWord = "a", targetWord = "aab"
      +Output: false
      +Explanation: 
      +The numerical value of firstWord is "aaa" -> "000" -> 0.
      +The numerical value of secondWord is "a" -> "0" -> 0.
      +The numerical value of targetWord is "aab" -> "001" -> 1.
      +We return false because 0 + 0 != 1.
      +
      + +

      Example 3:

      + +
      +Input: firstWord = "aaa", secondWord = "a", targetWord = "aaaa"
      +Output: true
      +Explanation: 
      +The numerical value of firstWord is "aaa" -> "000" -> 0.
      +The numerical value of secondWord is "a" -> "0" -> 0.
      +The numerical value of targetWord is "aaaa" -> "0000" -> 0.
      +We return true because 0 + 0 == 0.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= firstWord.length, secondWord.length, targetWord.length <= 8
      • +
      • firstWord, secondWord, and targetWord consist of lowercase English letters from 'a' to 'j' inclusive.
      • +
      + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
      +Hint 1 +Convert each character of each word to its numerical value. +
      + +
      +Hint 2 +Check if the numerical values satisfies the condition. +
      diff --git a/problems/clumsy-factorial/README.md b/problems/clumsy-factorial/README.md index dcd08ce1b..08c1965fd 100644 --- a/problems/clumsy-factorial/README.md +++ b/problems/clumsy-factorial/README.md @@ -19,14 +19,14 @@

      Additionally, the division that we use is floor division such that 10 * 9 / 8 equals 11.  This guarantees the result is an integer.

      -

      Implement the clumsy function as defined above: given an integer N, it returns the clumsy factorial of N.

      +

      Implement the clumsy function as defined above: given an integer n, it returns the clumsy factorial of n.

       

      Example 1:

      -Input: 4
      +Input: n = 4
       Output: 7
       Explanation: 7 = 4 * 3 / 2 + 1
       
      @@ -34,7 +34,7 @@

      Example 2:

      -Input: 10
      +Input: n = 10
       Output: 12
       Explanation: 12 = 10 * 9 / 8 + 7 - 6 * 5 / 4 + 3 - 2 * 1
       
      @@ -44,8 +44,8 @@

      Note:

        -
      1. 1 <= N <= 10000
      2. -
      3. -2^31 <= answer <= 2^31 - 1  (The answer is guaranteed to fit within a 32-bit integer.)
      4. +
      5. 1 <= n <= 10000
      6. +
      7. -231 <= answer <= 231 - 1  (The answer is guaranteed to fit within a 32-bit integer.)
      ### Related Topics diff --git a/problems/coin-change-2/README.md b/problems/coin-change-2/README.md index ec2375819..399f02f46 100644 --- a/problems/coin-change-2/README.md +++ b/problems/coin-change-2/README.md @@ -53,5 +53,6 @@
      • 1 <= coins.length <= 300
      • 1 <= coins[i] <= 5000
      • +
      • All the values of coins are unique.
      • 0 <= amount <= 5000
      diff --git a/problems/complement-of-base-10-integer/README.md b/problems/complement-of-base-10-integer/README.md index 910c3dc2a..e9dc0e2d3 100644 --- a/problems/complement-of-base-10-integer/README.md +++ b/problems/complement-of-base-10-integer/README.md @@ -11,11 +11,11 @@ ## [1009. Complement of Base 10 Integer (Easy)](https://leetcode.com/problems/complement-of-base-10-integer "十进制整数的反码") -

      Every non-negative integer N has a binary representation.  For example, 5 can be represented as "101" in binary, 11 as "1011" in binary, and so on.  Note that except for N = 0, there are no leading zeroes in any binary representation.

      +

      Every non-negative integer n has a binary representation.  For example, 5 can be represented as "101" in binary, 11 as "1011" in binary, and so on.  Note that except for n = 0, there are no leading zeroes in any binary representation.

      The complement of a binary representation is the number in binary you get when changing every 1 to a 0 and 0 to a 1.  For example, the complement of "101" in binary is "010" in binary.

      -

      For a given number N in base-10, return the complement of it's binary representation as a base-10 integer.

      +

      For a given number n in base-10, return the complement of it's binary representation as a base-10 integer.

       

      @@ -26,7 +26,7 @@

      Example 1:

      -Input: 5
      +Input: n = 5
       Output: 2
       Explanation: 5 is "101" in binary, with complement "010" in binary, which is 2 in base-10.
       
      @@ -35,7 +35,7 @@

      Example 2:

      -Input: 7
      +Input: n = 7
       Output: 0
       Explanation: 7 is "111" in binary, with complement "000" in binary, which is 0 in base-10.
       
      @@ -44,7 +44,7 @@

      Example 3:

      -Input: 10
      +Input: n = 10
       Output: 5
       Explanation: 10 is "1010" in binary, with complement "0101" in binary, which is 5 in base-10.
       
      @@ -54,7 +54,7 @@

      Note:

        -
      1. 0 <= N < 10^9
      2. +
      3. 0 <= n < 109
      4. This question is the same as 476: https://leetcode.com/problems/number-complement/
      diff --git a/problems/contain-virus/README.md b/problems/contain-virus/README.md index a296f5966..c47c33ae2 100644 --- a/problems/contain-virus/README.md +++ b/problems/contain-virus/README.md @@ -11,68 +11,54 @@ ## [749. Contain Virus (Hard)](https://leetcode.com/problems/contain-virus "隔离病毒") -

      -A virus is spreading rapidly, and your task is to quarantine the infected area by installing walls. -

      -The world is modeled as a 2-D array of cells, where 0 represents uninfected cells, and 1 represents cells contaminated with the virus. A wall (and only one wall) can be installed between any two 4-directionally adjacent cells, on the shared boundary. -

      -Every night, the virus spreads to all neighboring cells in all four directions unless blocked by a wall. -Resources are limited. Each day, you can install walls around only one region -- the affected area (continuous block of infected cells) that threatens the most uninfected cells the following night. There will never be a tie. -

      -Can you save the day? If so, what is the number of walls required? If not, and the world becomes fully infected, return the number of walls used. -

      - -

      Example 1:
      -

      -Input: grid = 
      -[[0,1,0,0,0,0,0,1],
      - [0,1,0,0,0,0,0,1],
      - [0,0,0,0,0,0,0,1],
      - [0,0,0,0,0,0,0,0]]
      -Output: 10
      -Explanation:
      -There are 2 contaminated regions.
      -On the first day, add 5 walls to quarantine the viral region on the left. The board after the virus spreads is:
      +

      A virus is spreading rapidly, and your task is to quarantine the infected area by installing walls.

      + +

      The world is modeled as an m x n binary grid isInfected, where isInfected[i][j] == 0 represents uninfected cells, and isInfected[i][j] == 1 represents cells contaminated with the virus. A wall (and only one wall) can be installed between any two 4-directionally adjacent cells, on the shared boundary.

      -[[0,1,0,0,0,0,1,1], - [0,1,0,0,0,0,1,1], - [0,0,0,0,0,0,1,1], - [0,0,0,0,0,0,0,1]] +

      Every night, the virus spreads to all neighboring cells in all four directions unless blocked by a wall. Resources are limited. Each day, you can install walls around only one region (i.e., the affected area (continuous block of infected cells) that threatens the most uninfected cells the following night). There will never be a tie.

      +

      Return the number of walls used to quarantine all the infected regions. If the world will become fully infected, return the number of walls used.

      + +

       

      +

      Example 1:

      + +
      +Input: isInfected = [[0,1,0,0,0,0,0,1],[0,1,0,0,0,0,0,1],[0,0,0,0,0,0,0,1],[0,0,0,0,0,0,0,0]]
      +Output: 10
      +Explanation: There are 2 contaminated regions.
      +On the first day, add 5 walls to quarantine the viral region on the left. The board after the virus spreads is:
      +
       On the second day, add 5 walls to quarantine the viral region on the right. The virus is fully contained.
      +
       
      -

      -

      Example 2:
      +

      Example 2:

      +
      -Input: grid = 
      -[[1,1,1],
      - [1,0,1],
      - [1,1,1]]
      -Output: 4
      -Explanation: Even though there is only one cell saved, there are 4 walls built.
      +Input: isInfected = [[1,1,1],[1,0,1],[1,1,1]]
      +Output: 4
      +Explanation: Even though there is only one cell saved, there are 4 walls built.
       Notice that walls are only built on the shared boundary of two different cells.
       
      -

      -

      Example 3:
      +

      Example 3:

      +
      -Input: grid = 
      -[[1,1,1,0,0,0,0,0,0],
      - [1,0,1,0,1,1,1,1,1],
      - [1,1,1,0,0,0,0,0,0]]
      -Output: 13
      -Explanation: The region on the left only builds two new walls.
      +Input: isInfected = [[1,1,1,0,0,0,0,0,0],[1,0,1,0,1,1,1,1,1],[1,1,1,0,0,0,0,0,0]]
      +Output: 13
      +Explanation: The region on the left only builds two new walls.
       
      -

      - -

      Note:
      -

        -
      1. The number of rows and columns of grid will each be in the range [1, 50].
      2. -
      3. Each grid[i][j] will be either 0 or 1.
      4. -
      5. Throughout the described process, there is always a contiguous viral region that will infect strictly more uncontaminated squares in the next round.
      6. -
      -

      + +

       

      +

      Constraints:

      + +
        +
      • m == isInfected.length
      • +
      • n == isInfected[i].length
      • +
      • 1 <= m, n <= 50
      • +
      • isInfected[i][j] is either 0 or 1.
      • +
      • There is always a contiguous viral region throughout the described process that will infect strictly more uncontaminated squares in the next round.
      • +
      ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/convert-to-base-2/README.md b/problems/convert-to-base-2/README.md index 4efbc5543..b6f198691 100644 --- a/problems/convert-to-base-2/README.md +++ b/problems/convert-to-base-2/README.md @@ -11,7 +11,7 @@ ## [1017. Convert to Base -2 (Medium)](https://leetcode.com/problems/convert-to-base-2 "负二进制转换") -

      Given a number N, return a string consisting of "0"s and "1"s that represents its value in base -2 (negative two).

      +

      Given a number n, return a string consisting of "0"s and "1"s that represents its value in base -2 (negative two).

      The returned string must have no leading zeroes, unless the string is "0".

      @@ -21,7 +21,7 @@

      Example 1:

      -Input: 2
      +Input: n = 2
       Output: "110"
       Explantion: (-2) ^ 2 + (-2) ^ 1 = 2
       
      @@ -30,7 +30,7 @@

      Example 2:

      -Input: 3
      +Input: n = 3
       Output: "111"
       Explantion: (-2) ^ 2 + (-2) ^ 1 + (-2) ^ 0 = 3
       
      @@ -39,7 +39,7 @@

      Example 3:

      -Input: 4
      +Input: n = 4
       Output: "100"
       Explantion: (-2) ^ 2 = 4
       
      @@ -49,7 +49,7 @@

      Note:

        -
      1. 0 <= N <= 10^9
      2. +
      3. 0 <= n <= 109
      diff --git a/problems/count-and-say/README.md b/problems/count-and-say/README.md index 6efc35cad..4ed8226bb 100644 --- a/problems/count-and-say/README.md +++ b/problems/count-and-say/README.md @@ -9,7 +9,7 @@                  [Next >](../combination-sum "Combination Sum") -## [38. Count and Say (Easy)](https://leetcode.com/problems/count-and-say "外观数列") +## [38. Count and Say (Medium)](https://leetcode.com/problems/count-and-say "外观数列")

      The count-and-say sequence is a sequence of digit strings defined by the recursive formula:

      diff --git a/problems/count-different-palindromic-subsequences/README.md b/problems/count-different-palindromic-subsequences/README.md index 1c3b901b2..ffc4a31e6 100644 --- a/problems/count-different-palindromic-subsequences/README.md +++ b/problems/count-different-palindromic-subsequences/README.md @@ -11,40 +11,38 @@ ## [730. Count Different Palindromic Subsequences (Hard)](https://leetcode.com/problems/count-different-palindromic-subsequences "统计不同回文子序列") -

      Given a string s, find the number of different non-empty palindromic subsequences in s, and return that number modulo 10^9 + 7.

      +

      Given a string s, return the number of different non-empty palindromic subsequences in s. Since the answer may be very large, return it modulo 109 + 7.

      -

      A subsequence of a string s is obtained by deleting 0 or more characters from s.

      +

      A subsequence of a string is obtained by deleting zero or more characters from the string.

      A sequence is palindromic if it is equal to the sequence reversed.

      -

      Two sequences A_1, A_2, ... and B_1, B_2, ... are different if there is some i for which A_i != B_i.

      +

      Two sequences a1, a2, ... and b1, b2, ... are different if there is some i for which ai != bi.

      -

      Example 1:

      +

       

      +

      Example 1:

      -Input: 
      -s = 'bccb'
      -Output: 6
      -Explanation: 
      -The 6 different non-empty palindromic subsequences are 'b', 'c', 'bb', 'cc', 'bcb', 'bccb'.
      +Input: s = "bccb"
      +Output: 6
      +Explanation: The 6 different non-empty palindromic subsequences are 'b', 'c', 'bb', 'cc', 'bcb', 'bccb'.
       Note that 'bcb' is counted only once, even though it occurs twice.
       
      -

      Example 2:

      +

      Example 2:

      -Input: 
      -s = 'abcdabcdabcdabcdabcdabcdabcdabcddcbadcbadcbadcbadcbadcbadcbadcba'
      -Output: 104860361
      -Explanation: 
      -There are 3104860382 different non-empty palindromic subsequences, which is 104860361 modulo 10^9 + 7.
      +Input: s = "abcdabcdabcdabcdabcdabcdabcdabcddcbadcbadcbadcbadcbadcbadcbadcba"
      +Output: 104860361
      +Explanation: There are 3104860382 different non-empty palindromic subsequences, which is 104860361 modulo 109 + 7.
       
      -

      Note:

      +

       

      +

      Constraints:

        -
      • The length of s will be in the range [1, 1000].
      • -
      • Each character s[i] will be in the set {'a', 'b', 'c', 'd'}.
      • +
      • 1 <= s.length <= 1000
      • +
      • s[i] is either 'a', 'b', 'c', or 'd'.
      ### Related Topics diff --git a/problems/count-of-range-sum/README.md b/problems/count-of-range-sum/README.md index 81b106aa5..385abcbcd 100644 --- a/problems/count-of-range-sum/README.md +++ b/problems/count-of-range-sum/README.md @@ -35,7 +35,7 @@

      Constraints:

        -
      • 1 <= nums.length <= 104
      • +
      • 1 <= nums.length <= 105
      • -231 <= nums[i] <= 231 - 1
      • -105 <= lower <= upper <= 105
      • The answer is guaranteed to fit in a 32-bit integer.
      • diff --git a/problems/count-pairs-with-xor-in-a-range/README.md b/problems/count-pairs-with-xor-in-a-range/README.md index 5e982118e..43f3520d3 100644 --- a/problems/count-pairs-with-xor-in-a-range/README.md +++ b/problems/count-pairs-with-xor-in-a-range/README.md @@ -60,7 +60,7 @@ ### Hints
        Hint 1 -Let's note that we can count all pairs with XOR ≤ K, so the answer would be to subtract the number of pairs with XOR ≤ high from the number of pairs withs XOR < low. +Let's note that we can count all pairs with XOR ≤ K, so the answer would be to subtract the number of pairs withs XOR < low from the number of pairs with XOR ≤ high.
        diff --git a/problems/counting-bits/README.md b/problems/counting-bits/README.md index e226ac9f9..52e02d477 100644 --- a/problems/counting-bits/README.md +++ b/problems/counting-bits/README.md @@ -9,15 +9,15 @@                  [Next >](../nested-list-weight-sum "Nested List Weight Sum") -## [338. Counting Bits (Medium)](https://leetcode.com/problems/counting-bits "比特位计数") +## [338. Counting Bits (Easy)](https://leetcode.com/problems/counting-bits "比特位计数") -

        Given an integer num, return an array of the number of 1's in the binary representation of every number in the range [0, num].

        +

        Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1's in the binary representation of i.

         

        Example 1:

        -Input: num = 2
        +Input: n = 2
         Output: [0,1,1]
         Explanation:
         0 --> 0
        @@ -28,7 +28,7 @@
         

        Example 2:

        -Input: num = 5
        +Input: n = 5
         Output: [0,1,1,2,1,2]
         Explanation:
         0 --> 0
        @@ -43,15 +43,14 @@
         

        Constraints:

          -
        • 0 <= num <= 105
        • +
        • 0 <= n <= 105

         

        Follow up:

          -
        • It is very easy to come up with a solution with run time O(32n). Can you do it in linear time O(n) and possibly in a single pass?
        • -
        • Could you solve it in O(n) space complexity?
        • +
        • It is very easy to come up with a solution with a runtime of O(n log n). Can you do it in linear time O(n) and possibly in a single pass?
        • Can you do it without using any built-in function (i.e., like __builtin_popcount in C++)?
        diff --git a/problems/daily-temperatures/README.md b/problems/daily-temperatures/README.md index 43f4abac1..ad6eba77e 100644 --- a/problems/daily-temperatures/README.md +++ b/problems/daily-temperatures/README.md @@ -11,11 +11,26 @@ ## [739. Daily Temperatures (Medium)](https://leetcode.com/problems/daily-temperatures "每日温度") -

        Given a list of daily temperatures temperatures, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead.

        - -

        For example, given the list of temperatures temperatures = [73, 74, 75, 71, 69, 72, 76, 73], your output should be [1, 1, 4, 2, 1, 1, 0, 0].

        - -

        Note: The length of temperatures will be in the range [1, 30000]. Each temperature will be an integer in the range [30, 100].

        +

        Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0 instead.

        + +

         

        +

        Example 1:

        +
        Input: temperatures = [73,74,75,71,69,72,76,73]
        +Output: [1,1,4,2,1,1,0,0]
        +

        Example 2:

        +
        Input: temperatures = [30,40,50,60]
        +Output: [1,1,1,0]
        +

        Example 3:

        +
        Input: temperatures = [30,60,90]
        +Output: [1,1,0]
        +
        +

         

        +

        Constraints:

        + +
          +
        • 1 <= temperatures.length <= 105
        • +
        • 30 <= temperatures[i] <= 100
        • +
        ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/department-top-three-salaries/README.md b/problems/department-top-three-salaries/README.md index bf38afcb1..f6d885fe7 100644 --- a/problems/department-top-three-salaries/README.md +++ b/problems/department-top-three-salaries/README.md @@ -11,9 +11,50 @@ ## [185. Department Top Three Salaries (Hard)](https://leetcode.com/problems/department-top-three-salaries "部门工资前三高的所有员工") -

        The Employee table holds all employees. Every employee has an Id, and there is also a column for the department Id.

        +

        Table: Employee

        ++--------------+---------+
        +| Column Name  | Type    |
        ++--------------+---------+
        +| Id           | int     |
        +| Name         | varchar |
        +| Salary       | int     |
        +| DepartmentId | int     |
        ++--------------+---------+
        +Id is the primary key for this table.
        +Each row contains the ID, name, salary, and department of one employee.
        +
        + +

         

        + +

        Table: Department

        + +
        ++-------------+---------+
        +| Column Name | Type    |
        ++-------------+---------+
        +| Id          | int     |
        +| Name        | varchar |
        ++-------------+---------+
        +Id is the primary key for this table.
        +Each row contains the ID and the name of one department.
        +
        + +

         

        + +

        A company's executives are interested in seeing who earns the most money in each of the company's departments. A high earner in a department is an employee who has a salary in the top three unique salaries for that department.

        + +

        Write an SQL query to find the employees who are high earners in each of the departments.

        + +

        Return the result table in any order.

        + +

        The query result format is in the following example:

        + +

         

        + +
        +Employee table:
         +----+-------+--------+--------------+
         | Id | Name  | Salary | DepartmentId |
         +----+-------+--------+--------------+
        @@ -25,34 +66,33 @@
         | 6  | Randy | 85000  | 1            |
         | 7  | Will  | 70000  | 1            |
         +----+-------+--------+--------------+
        -
        -

        The Department table holds all departments of the company.

        - -
        -+----+----------+
        -| Id | Name     |
        -+----+----------+
        -| 1  | IT       |
        -| 2  | Sales    |
        -+----+----------+
        -
        +Department table: ++----+-------+ +| Id | Name | ++----+-------+ +| 1 | IT | +| 2 | Sales | ++----+-------+ -

        Write a SQL query to find employees who earn the top three salaries in each of the department. For the above tables, your SQL query should return the following rows (order of rows does not matter).

        - -
        +Result table:
         +------------+----------+--------+
         | Department | Employee | Salary |
         +------------+----------+--------+
         | IT         | Max      | 90000  |
        -| IT         | Randy    | 85000  |
         | IT         | Joe      | 85000  |
        +| IT         | Randy    | 85000  |
         | IT         | Will     | 70000  |
         | Sales      | Henry    | 80000  |
         | Sales      | Sam      | 60000  |
         +------------+----------+--------+
        -
        -

        Explanation:

        +In the IT department: +- Max earns the highest unique salary +- Both Randy and Joe earn the second-highest unique salary +- Will earns the third-highest unique salary -

        In IT department, Max earns the highest salary, both Randy and Joe earn the second highest salary, and Will earns the third highest salary. There are only two employees in the Sales department, Henry earns the highest salary while Sam earns the second highest salary.

        +In the Sales department: +- Henry earns the highest salary +- Sam earns the second-highest salary +- There is no third-highest salary as there are only two employees
        diff --git a/problems/design-hashmap/README.md b/problems/design-hashmap/README.md index d4234bdf2..249925e46 100644 --- a/problems/design-hashmap/README.md +++ b/problems/design-hashmap/README.md @@ -52,9 +52,6 @@ myHashMap.get(2); // return -1 (i.e., not found), The map is now [[1,1]]
      • At most 104 calls will be made to put, get, and remove.
      -

       

      -

      Follow up: Please do not use the built-in HashMap library.

      - ### Related Topics [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/design-hashset/README.md b/problems/design-hashset/README.md index c073a3e73..33cc69073 100644 --- a/problems/design-hashset/README.md +++ b/problems/design-hashset/README.md @@ -50,9 +50,6 @@ myHashSet.contains(2); // return False, (already removed)
    • At most 104 calls will be made to add, remove, and contains.
    -

     

    -Follow up: Could you solve the problem without using the built-in HashSet library? - ### Related Topics [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/distribute-coins-in-binary-tree/README.md b/problems/distribute-coins-in-binary-tree/README.md index f58dc8a7c..6035b24d6 100644 --- a/problems/distribute-coins-in-binary-tree/README.md +++ b/problems/distribute-coins-in-binary-tree/README.md @@ -11,15 +11,15 @@ ## [979. Distribute Coins in Binary Tree (Medium)](https://leetcode.com/problems/distribute-coins-in-binary-tree "在二叉树中分配硬币") -

    You are given the root of a binary tree with n nodes where each node in the tree has node.val coins and there are n coins total.

    +

    You are given the root of a binary tree with n nodes where each node in the tree has node.val coins. There are n coins in total throughout the whole tree.

    -

    In one move, we may choose two adjacent nodes and move one coin from one node to another. (A move may be from parent to child, or from child to parent.)

    +

    In one move, we may choose two adjacent nodes and move one coin from one node to another. A move may be from parent to child, or from child to parent.

    -

    Return the number of moves required to make every node have exactly one coin.

    +

    Return the minimum number of moves required to make every node have exactly one coin.

     

    Example 1:

    - +
     Input: root = [3,0,0]
     Output: 2
    @@ -27,22 +27,22 @@
     

    Example 2:

    - +
     Input: root = [0,3,0]
     Output: 3
    -Explanation: From the left child of the root, we move two coins to the root [taking two moves].  Then, we move one coin from the root of the tree to the right child.
    +Explanation: From the left child of the root, we move two coins to the root [taking two moves]. Then, we move one coin from the root of the tree to the right child.
     

    Example 3:

    - +
     Input: root = [1,0,2]
     Output: 2
     

    Example 4:

    - +
     Input: root = [1,0,0,null,3]
     Output: 4
    @@ -55,7 +55,7 @@
     	
  • The number of nodes in the tree is n.
  • 1 <= n <= 100
  • 0 <= Node.val <= n
  • -
  • The sum of Node.val is n.
  • +
  • The sum of all Node.val is n.
  • ### Related Topics diff --git a/problems/dota2-senate/README.md b/problems/dota2-senate/README.md index 3531ea942..a5bf579de 100644 --- a/problems/dota2-senate/README.md +++ b/problems/dota2-senate/README.md @@ -63,4 +63,4 @@ And in round 2, the third senator can just announce the victory since he is the [[Greedy](../../tag/greedy/README.md)] ### Similar Questions - 1. [Teemo Attacking](../teemo-attacking) (Medium) + 1. [Teemo Attacking](../teemo-attacking) (Easy) diff --git a/problems/employee-importance/README.md b/problems/employee-importance/README.md index 6e9c218f9..be6955b53 100644 --- a/problems/employee-importance/README.md +++ b/problems/employee-importance/README.md @@ -11,29 +11,47 @@ ## [690. Employee Importance (Easy)](https://leetcode.com/problems/employee-importance "员工的重要性") -

    You are given a data structure of employee information, which includes the employee's unique id, their importance value and their direct subordinates' id.

    +

    You have a data structure of employee information, which includes the employee's unique id, their importance value, and their direct subordinates' id.

    -

    For example, employee 1 is the leader of employee 2, and employee 2 is the leader of employee 3. They have importance value 15, 10 and 5, respectively. Then employee 1 has a data structure like [1, 15, [2]], and employee 2 has [2, 10, [3]], and employee 3 has [3, 5, []]. Note that although employee 3 is also a subordinate of employee 1, the relationship is not direct.

    +

    You are given an array of employees employees where:

    -

    Now given the employee information of a company, and an employee id, you need to return the total importance value of this employee and all their subordinates.

    +
      +
    • employees[i].id is the ID of the ith employee.
    • +
    • employees[i].importance is the importance value of the ith employee.
    • +
    • employees[i].subordinates is a list of the IDs of the subordinates of the ith employee.
    • +
    -

    Example 1:

    +

    Given an integer id that represents the ID of an employee, return the total importance value of this employee and all their subordinates.

    +

     

    +

    Example 1:

    +
    -Input: [[1, 5, [2, 3]], [2, 3, []], [3, 3, []]], 1
    -Output: 11
    -Explanation:
    -Employee 1 has importance value 5, and he has two direct subordinates: employee 2 and employee 3. They both have importance value 3. So the total importance value of employee 1 is 5 + 3 + 3 = 11.
    +Input: employees = [[1,5,[2,3]],[2,3,[]],[3,3,[]]], id = 1
    +Output: 11
    +Explanation: Employee 1 has importance value 5, and he has two direct subordinates: employee 2 and employee 3.
    +They both have importance value 3.
    +So the total importance value of employee 1 is 5 + 3 + 3 = 11.
     
    -

     

    - -

    Note:

    +

    Example 2:

    + +
    +Input: employees = [[1,2,[5]],[5,-3,[]]], id = 5
    +Output: -3
    +
    -
      -
    1. One employee has at most one direct leader and may have several subordinates.
    2. -
    3. The maximum number of employees won't exceed 2000.
    4. -
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= employees.length <= 2000
    • +
    • 1 <= employees[i].id <= 2000
    • +
    • All employees[i].id are unique.
    • +
    • -100 <= employees[i].importance <= 100
    • +
    • One employee has at most one direct leader and may have several subordinates.
    • +
    • id is guaranteed to be a valid employee id.
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/encode-and-decode-strings/README.md b/problems/encode-and-decode-strings/README.md index e8ebd0074..336bfc67d 100644 --- a/problems/encode-and-decode-strings/README.md +++ b/problems/encode-and-decode-strings/README.md @@ -59,7 +59,7 @@ vector<string> strs2 = decode(encoded_string); [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Count and Say](../count-and-say) (Easy) + 1. [Count and Say](../count-and-say) (Medium) 1. [Serialize and Deserialize Binary Tree](../serialize-and-deserialize-binary-tree) (Hard) 1. [String Compression](../string-compression) (Medium) 1. [Count Binary Substrings](../count-binary-substrings) (Easy) diff --git a/problems/faulty-sensor/README.md b/problems/faulty-sensor/README.md index 99d72b8fc..e7e277c0b 100644 --- a/problems/faulty-sensor/README.md +++ b/problems/faulty-sensor/README.md @@ -9,7 +9,7 @@                  [Next >](../minimum-operations-to-make-the-array-increasing "Minimum Operations to Make the Array Increasing") -## [1826. Faulty Sensor (Easy)](https://leetcode.com/problems/faulty-sensor "") +## [1826. Faulty Sensor (Easy)](https://leetcode.com/problems/faulty-sensor "有缺陷的传感器") diff --git a/problems/find-and-replace-in-string/README.md b/problems/find-and-replace-in-string/README.md index d6551b0b7..8bdebbbee 100644 --- a/problems/find-and-replace-in-string/README.md +++ b/problems/find-and-replace-in-string/README.md @@ -11,15 +11,15 @@ ## [833. Find And Replace in String (Medium)](https://leetcode.com/problems/find-and-replace-in-string "字符串中的查找与替换") -

    To some string s, we will perform some replacement operations that replace groups of letters with new ones (not necessarily the same size).

    +

    To some string s, we will perform some replacement operations that replace groups of letters with new ones (not necessarily the same size).

    -

    Each replacement operation has 3 parameters: a starting index i, a source word x and a target word y.  The rule is that if x starts at position i in the original string S, then we will replace that occurrence of x with y.  If not, we do nothing.

    +

    Each replacement operation has 3 parameters: a starting index i, a source word x and a target word y. The rule is that if x starts at position i in the original string S, then we will replace that occurrence of x with y. If not, we do nothing.

    -

    For example, if we have s = "abcd" and we have some replacement operation i = 2, x = "cd", y = "ffff", then because "cd" starts at position 2 in the original string s, we will replace it with "ffff".

    +

    For example, if we have s = "abcd" and we have some replacement operation i = 2, x = "cd", y = "ffff", then because "cd" starts at position 2 in the original string s, we will replace it with "ffff".

    -

    Using another example on s = "abcd", if we have both the replacement operation i = 0, x = "ab", y = "eee", as well as another replacement operation i = 2, x = "ec", y = "ffff", this second operation does nothing because in the original string s[2] = 'c', which doesn't match x[0] = 'e'.

    +

    Using another example on s = "abcd", if we have both the replacement operation i = 0, x = "ab", y = "eee", as well as another replacement operation i = 2, x = "ec", y = "ffff", this second operation does nothing because in the original string s[2] = 'c', which doesn't match x[0] = 'e'.

    -

    All these operations occur simultaneously.  It's guaranteed that there won't be any overlap in replacement: for example, s = "abc", indexes = [0, 1], sources = ["ab","bc"] is not a valid test case.

    +

    All these operations occur simultaneously. It's guaranteed that there won't be any overlap in replacement: for example, s = "abc", indexes = [0, 1], sources = ["ab","bc"] is not a valid test case.

     

    Example 1:

    @@ -53,7 +53,7 @@
  • sources.length == indexes.length
  • targets.length == indexes.length
  • 1 <= sources[i].length, targets[i].length <= 50
  • -
  • sources[i] and targets[i] consist of only lowercase English letters.
  • +
  • sources[i] and targets[i] consist of only lowercase English letters.
  • ### Related Topics diff --git a/problems/find-and-replace-pattern/README.md b/problems/find-and-replace-pattern/README.md index 3b4b4f1e6..3955bacda 100644 --- a/problems/find-and-replace-pattern/README.md +++ b/problems/find-and-replace-pattern/README.md @@ -11,37 +11,38 @@ ## [890. Find and Replace Pattern (Medium)](https://leetcode.com/problems/find-and-replace-pattern "查找和替换模式") -

    You have a list of words and a pattern, and you want to know which words in words matches the pattern.

    +

    Given a list of strings words and a string pattern, return a list of words[i] that match pattern. You may return the answer in any order.

    A word matches the pattern if there exists a permutation of letters p so that after replacing every letter x in the pattern with p(x), we get the desired word.

    -

    (Recall that a permutation of letters is a bijection from letters to letters: every letter maps to another letter, and no two letters map to the same letter.)

    - -

    Return a list of the words in words that match the given pattern. 

    - -

    You may return the answer in any order.

    +

    Recall that a permutation of letters is a bijection from letters to letters: every letter maps to another letter, and no two letters map to the same letter.

     

    - -

    Example 1:

    -Input: words = ["abc","deq","mee","aqq","dkd","ccc"], pattern = "abb"
    -Output: ["mee","aqq"]
    -Explanation: "mee" matches the pattern because there is a permutation {a -> m, b -> e, ...}. 
    -"ccc" does not match the pattern because {a -> c, b -> c, ...} is not a permutation,
    -since a and b map to the same letter.
    +Input: words = ["abc","deq","mee","aqq","dkd","ccc"], pattern = "abb" +Output: ["mee","aqq"] +Explanation: "mee" matches the pattern because there is a permutation {a -> m, b -> e, ...}. +"ccc" does not match the pattern because {a -> c, b -> c, ...} is not a permutation, since a and b map to the same letter. +
    -

     

    +

    Example 2:

    -

    Note:

    +
    +Input: words = ["a","b","c"], pattern = "a"
    +Output: ["a","b","c"]
    +
    + +

     

    +

    Constraints:

      +
    • 1 <= pattern.length <= 20
    • 1 <= words.length <= 50
    • -
    • 1 <= pattern.length = words[i].length <= 20
    • +
    • words[i].length == pattern.length
    • +
    • pattern and words[i] are lowercase English letters.
    - ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/find-common-characters/README.md b/problems/find-common-characters/README.md index 6160447c6..6bcd0be94 100644 --- a/problems/find-common-characters/README.md +++ b/problems/find-common-characters/README.md @@ -11,7 +11,7 @@ ## [1002. Find Common Characters (Easy)](https://leetcode.com/problems/find-common-characters "查找常用字符") -

    Given an array A of strings made only from lowercase letters, return a list of all characters that show up in all strings within the list (including duplicates).  For example, if a character occurs 3 times in all strings but not 4 times, you need to include that character three times in the final answer.

    +

    Given an array words of strings made only from lowercase letters, return a list of all characters that show up in all strings within the list (including duplicates).  For example, if a character occurs 3 times in all strings but not 4 times, you need to include that character three times in the final answer.

    You may return the answer in any order.

    @@ -38,9 +38,9 @@

    Note:

      -
    1. 1 <= A.length <= 100
    2. -
    3. 1 <= A[i].length <= 100
    4. -
    5. A[i][j] is a lowercase letter
    6. +
    7. 1 <= words.length <= 100
    8. +
    9. 1 <= words[i].length <= 100
    10. +
    11. words[i] consists of lowercase English letters.
    diff --git a/problems/find-customers-with-positive-revenue-this-year/README.md b/problems/find-customers-with-positive-revenue-this-year/README.md index 82eba55cd..45c148b96 100644 --- a/problems/find-customers-with-positive-revenue-this-year/README.md +++ b/problems/find-customers-with-positive-revenue-this-year/README.md @@ -9,6 +9,6 @@                  [Next >](../sign-of-the-product-of-an-array "Sign of the Product of an Array") -## [1821. Find Customers With Positive Revenue this Year (Easy)](https://leetcode.com/problems/find-customers-with-positive-revenue-this-year "") +## [1821. Find Customers With Positive Revenue this Year (Easy)](https://leetcode.com/problems/find-customers-with-positive-revenue-this-year "寻找今年具有正收入的客户") diff --git a/problems/find-k-th-smallest-pair-distance/README.md b/problems/find-k-th-smallest-pair-distance/README.md index b977ec166..27ecd15c6 100644 --- a/problems/find-k-th-smallest-pair-distance/README.md +++ b/problems/find-k-th-smallest-pair-distance/README.md @@ -11,30 +11,46 @@ ## [719. Find K-th Smallest Pair Distance (Hard)](https://leetcode.com/problems/find-k-th-smallest-pair-distance "找出第 k 小的距离对") -

    Given an integer array, return the k-th smallest distance among all the pairs. The distance of a pair (A, B) is defined as the absolute difference between A and B.

    +

    The distance of a pair of integers a and b is defined as the absolute difference between a and b.

    + +

    Given an integer array nums and an integer k, return the kth smallest distance among all the pairs nums[i] and nums[j] where 0 <= i < j < nums.length.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,3,1], k = 1
    +Output: 0
    +Explanation: Here are all the pairs:
    +(1,3) -> 2
    +(1,1) -> 0
    +(3,1) -> 2
    +Then the 1st smallest distance pair is (1,1), and its distance is 0.
    +
    + +

    Example 2:

    -

    Example 1:

    -Input:
    -nums = [1,3,1]
    -k = 1
    -Output: 0 
    -Explanation:
    -Here are all the pairs:
    -(1,3) -> 2
    -(1,1) -> 0
    -(3,1) -> 2
    -Then the 1st smallest distance pair is (1,1), and its distance is 0.
    +Input: nums = [1,1,1], k = 2
    +Output: 0
     
    -

    - -

    Note:
    -

      -
    1. 2 <= len(nums) <= 10000.
    2. -
    3. 0 <= nums[i] < 1000000.
    4. -
    5. 1 <= k <= len(nums) * (len(nums) - 1) / 2.
    6. -
    -

    + +

    Example 3:

    + +
    +Input: nums = [1,6,1], k = 3
    +Output: 5
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 2 <= n <= 104
    • +
    • 0 <= nums[i] <= 106
    • +
    • 1 <= k <= n * (n - 1) / 2
    • +
    ### Related Topics [[Heap](../../tag/heap/README.md)] diff --git a/problems/find-minimum-in-rotated-sorted-array-ii/README.md b/problems/find-minimum-in-rotated-sorted-array-ii/README.md index 97759c93e..d9cf6cda9 100644 --- a/problems/find-minimum-in-rotated-sorted-array-ii/README.md +++ b/problems/find-minimum-in-rotated-sorted-array-ii/README.md @@ -22,6 +22,8 @@

    Given the sorted rotated array nums that may contain duplicates, return the minimum element of this array.

    +

    You must decrease the overall operation steps as much as possible.

    +

     

    Example 1:

    Input: nums = [1,3,5]
    @@ -41,7 +43,9 @@
     
     
     

     

    -Follow up: This is the same as Find Minimum in Rotated Sorted Array but with duplicates. Would allow duplicates affect the run-time complexity? How and why? +

    Follow up: This problem is similar to Find Minimum in Rotated Sorted Array, but nums may contain duplicates. Would this affect the runtime complexity? How and why?

    + +

     

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/find-smallest-letter-greater-than-target/README.md b/problems/find-smallest-letter-greater-than-target/README.md index c308f8ce4..590b9cc02 100644 --- a/problems/find-smallest-letter-greater-than-target/README.md +++ b/problems/find-smallest-letter-greater-than-target/README.md @@ -11,53 +11,60 @@ ## [744. Find Smallest Letter Greater Than Target (Easy)](https://leetcode.com/problems/find-smallest-letter-greater-than-target "寻找比目标字母大的最小字母") -

    -Given a list of sorted characters letters containing only lowercase letters, and given a target letter target, find the smallest element in the list that is larger than the given target. -

    -Letters also wrap around. For example, if the target is target = 'z' and letters = ['a', 'b'], the answer is 'a'. -

    +

    Given a characters array letters that is sorted in non-decreasing order and a character target, return the smallest character in the array that is larger than target.

    + +

    Note that the letters wrap around.

    + +
      +
    • For example, if target == 'z' and letters == ['a', 'b'], the answer is 'a'.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: letters = ["c","f","j"], target = "a"
    +Output: "c"
    +
    + +

    Example 2:

    + +
    +Input: letters = ["c","f","j"], target = "c"
    +Output: "f"
    +
    + +

    Example 3:

    -

    Examples:

    -Input:
    -letters = ["c", "f", "j"]
    -target = "a"
    -Output: "c"
    -
    -Input:
    -letters = ["c", "f", "j"]
    -target = "c"
    -Output: "f"
    -
    -Input:
    -letters = ["c", "f", "j"]
    -target = "d"
    -Output: "f"
    -
    -Input:
    -letters = ["c", "f", "j"]
    -target = "g"
    -Output: "j"
    -
    -Input:
    -letters = ["c", "f", "j"]
    -target = "j"
    -Output: "c"
    -
    -Input:
    -letters = ["c", "f", "j"]
    -target = "k"
    -Output: "c"
    +Input: letters = ["c","f","j"], target = "d"
    +Output: "f"
     
    -

    - -

    Note:
    -

      -
    1. letters has a length in range [2, 10000].
    2. -
    3. letters consists of lowercase letters, and contains at least 2 unique letters.
    4. -
    5. target is a lowercase letter.
    6. -
    -

    + +

    Example 4:

    + +
    +Input: letters = ["c","f","j"], target = "g"
    +Output: "j"
    +
    + +

    Example 5:

    + +
    +Input: letters = ["c","f","j"], target = "j"
    +Output: "c"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= letters.length <= 104
    • +
    • letters[i] is a lowercase English letter.
    • +
    • letters is sorted in non-decreasing order.
    • +
    • letters contains at least two different characters.
    • +
    • target is a lowercase English letter.
    • +
    ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/find-the-duplicate-number/README.md b/problems/find-the-duplicate-number/README.md index 2d04bd989..66ea72faa 100644 --- a/problems/find-the-duplicate-number/README.md +++ b/problems/find-the-duplicate-number/README.md @@ -15,6 +15,8 @@

    There is only one repeated number in nums, return this repeated number.

    +

    You must solve the problem without modifying the array nums and uses only constant extra space.

    +

     

    Example 1:

    Input: nums = [1,3,4,2,2]
    @@ -33,7 +35,7 @@
     

    Constraints:

      -
    • 2 <= n <= 105
    • +
    • 1 <= n <= 105
    • nums.length == n + 1
    • 1 <= nums[i] <= n
    • All the integers in nums appear only once except for precisely one integer which appears two or more times.
    • @@ -44,9 +46,7 @@
      • How can we prove that at least one duplicate number must exist in nums?
      • -
      • Can you solve the problem without modifying the array nums?
      • -
      • Can you solve the problem using only constant, O(1) extra space?
      • -
      • Can you solve the problem with runtime complexity less than O(n2)?
      • +
      • Can you solve the problem in linear runtime complexity?
      ### Related Topics diff --git a/problems/find-the-subtasks-that-did-not-execute/README.md b/problems/find-the-subtasks-that-did-not-execute/README.md index 98fd0f448..789fd731c 100644 --- a/problems/find-the-subtasks-that-did-not-execute/README.md +++ b/problems/find-the-subtasks-that-did-not-execute/README.md @@ -9,6 +9,6 @@                  [Next >](../merge-strings-alternately "Merge Strings Alternately") -## [1767. Find the Subtasks That Did Not Execute (Hard)](https://leetcode.com/problems/find-the-subtasks-that-did-not-execute "") +## [1767. Find the Subtasks That Did Not Execute (Hard)](https://leetcode.com/problems/find-the-subtasks-that-did-not-execute "寻找没有被执行的任务对") diff --git a/problems/finding-pairs-with-a-certain-sum/README.md b/problems/finding-pairs-with-a-certain-sum/README.md new file mode 100644 index 000000000..f6da1c307 --- /dev/null +++ b/problems/finding-pairs-with-a-certain-sum/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../minimum-number-of-swaps-to-make-the-binary-string-alternating "Minimum Number of Swaps to Make the Binary String Alternating") +                 +[Next >](../number-of-ways-to-rearrange-sticks-with-k-sticks-visible "Number of Ways to Rearrange Sticks With K Sticks Visible") + +## [1865. Finding Pairs With a Certain Sum (Medium)](https://leetcode.com/problems/finding-pairs-with-a-certain-sum "找出和为指定值的下标对") + +

      You are given two integer arrays nums1 and nums2. You are tasked to implement a data structure that supports queries of two types:

      + +
        +
      1. Add a positive integer to an element of a given index in the array nums2.
      2. +
      3. Count the number of pairs (i, j) such that nums1[i] + nums2[j] equals a given value (0 <= i < nums1.length and 0 <= j < nums2.length).
      4. +
      + +

      Implement the FindSumPairs class:

      + +
        +
      • FindSumPairs(int[] nums1, int[] nums2) Initializes the FindSumPairs object with two integer arrays nums1 and nums2.
      • +
      • void add(int index, int val) Adds val to nums2[index], i.e., apply nums2[index] += val.
      • +
      • int count(int tot) Returns the number of pairs (i, j) such that nums1[i] + nums2[j] == tot.
      • +
      + +

       

      +

      Example 1:

      + +
      +Input
      +["FindSumPairs", "count", "add", "count", "count", "add", "add", "count"]
      +[[[1, 1, 2, 2, 2, 3], [1, 4, 5, 2, 5, 4]], [7], [3, 2], [8], [4], [0, 1], [1, 1], [7]]
      +Output
      +[null, 8, null, 2, 1, null, null, 11]
      +
      +Explanation
      +FindSumPairs findSumPairs = new FindSumPairs([1, 1, 2, 2, 2, 3], [1, 4, 5, 2, 5, 4]);
      +findSumPairs.count(7);  // return 8; pairs (2,2), (3,2), (4,2), (2,4), (3,4), (4,4) make 2 + 5 and pairs (5,1), (5,5) make 3 + 4
      +findSumPairs.add(3, 2); // now nums2 = [1,4,5,4,5,4]
      +findSumPairs.count(8);  // return 2; pairs (5,2), (5,4) make 3 + 5
      +findSumPairs.count(4);  // return 1; pair (5,0) makes 3 + 1
      +findSumPairs.add(0, 1); // now nums2 = [2,4,5,4,5,4]
      +findSumPairs.add(1, 1); // now nums2 = [2,5,5,4,5,4]
      +findSumPairs.count(7);  // return 11; pairs (2,1), (2,2), (2,4), (3,1), (3,2), (3,4), (4,1), (4,2), (4,4) make 2 + 5 and pairs (5,3), (5,5) make 3 + 4
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= nums1.length <= 1000
      • +
      • 1 <= nums2.length <= 105
      • +
      • 1 <= nums1[i] <= 109
      • +
      • 1 <= nums2[i] <= 105
      • +
      • 0 <= index < nums2.length
      • +
      • 1 <= val <= 105
      • +
      • 1 <= tot <= 109
      • +
      • At most 1000 calls are made to add and count each.
      • +
      + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Ordered Map](../../tag/ordered-map/README.md)] + +### Hints +
      +Hint 1 +The length of nums1 is small in comparison to that of nums2 +
      + +
      +Hint 2 +If we iterate over elements of nums1 we just need to find the count of tot - element for all elements in nums1 +
      diff --git a/problems/flatten-nested-list-iterator/README.md b/problems/flatten-nested-list-iterator/README.md index 7d6f8defc..e4ef83b9d 100644 --- a/problems/flatten-nested-list-iterator/README.md +++ b/problems/flatten-nested-list-iterator/README.md @@ -21,6 +21,18 @@
    • boolean hasNext() Returns true if there are still some integers in the nested list and false otherwise.
    +

    Your code will be tested with the following pseudocode:

    + +
    +initialize iterator with nestedList
    +res = []
    +while iterator.hasNext()
    +    append iterator.next() to the end of res
    +return res
    +
    + +

    If res matches the expected flattened list, then your code will be judged as correct.

    +

     

    Example 1:

    diff --git a/problems/flood-fill/README.md b/problems/flood-fill/README.md index 2b88dd868..cb7e45206 100644 --- a/problems/flood-fill/README.md +++ b/problems/flood-fill/README.md @@ -11,34 +11,42 @@ ## [733. Flood Fill (Easy)](https://leetcode.com/problems/flood-fill "图像渲染") -

    -An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535). -

    -Given a coordinate (sr, sc) representing the starting pixel (row and column) of the flood fill, and a pixel value newColor, "flood fill" the image. -

    -To perform a "flood fill", consider the starting pixel, plus any pixels connected 4-directionally to the starting pixel of the same color as the starting pixel, plus any pixels connected 4-directionally to those pixels (also with the same color as the starting pixel), and so on. Replace the color of all of the aforementioned pixels with the newColor. -

    -At the end, return the modified image. -

    -

    Example 1:
    +

    An image is represented by an m x n integer grid image where image[i][j] represents the pixel value of the image.

    + +

    You are also given three integers sr, sc, and newColor. You should perform a flood fill on the image starting from the pixel image[sr][sc].

    + +

    To perform a flood fill, consider the starting pixel, plus any pixels connected 4-directionally to the starting pixel of the same color as the starting pixel, plus any pixels connected 4-directionally to those pixels (also with the same color), and so on. Replace the color of all of the aforementioned pixels with newColor.

    + +

    Return the modified image after performing the flood fill.

    + +

     

    +

    Example 1:

    +
    -Input: 
    -image = [[1,1,1],[1,1,0],[1,0,1]]
    -sr = 1, sc = 1, newColor = 2
    -Output: [[2,2,2],[2,2,0],[2,0,1]]
    -Explanation: 
    -From the center of the image (with position (sr, sc) = (1, 1)), all pixels connected 
    -by a path of the same color as the starting pixel are colored with the new color.
    -Note the bottom corner is not colored 2, because it is not 4-directionally connected
    -to the starting pixel.
    +Input: image = [[1,1,1],[1,1,0],[1,0,1]], sr = 1, sc = 1, newColor = 2
    +Output: [[2,2,2],[2,2,0],[2,0,1]]
    +Explanation: From the center of the image with position (sr, sc) = (1, 1) (i.e., the red pixel), all pixels connected by a path of the same color as the starting pixel (i.e., the blue pixels) are colored with the new color.
    +Note the bottom corner is not colored 2, because it is not 4-directionally connected to the starting pixel.
     
    -

    -

    Note: -

  • The length of image and image[0] will be in the range [1, 50].
  • -
  • The given starting pixel will satisfy 0 <= sr < image.length and 0 <= sc < image[0].length.
  • -
  • The value of each color in image[i][j] and newColor will be an integer in [0, 65535].
  • -

    +

    Example 2:

    + +
    +Input: image = [[0,0,0],[0,0,0]], sr = 0, sc = 0, newColor = 2
    +Output: [[2,2,2],[2,2,2]]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == image.length
    • +
    • n == image[i].length
    • +
    • 1 <= m, n <= 50
    • +
    • 0 <= image[i][j], newColor < 216
    • +
    • 0 <= sr <= m
    • +
    • 0 <= sc <= n
    • +
    ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/get-biggest-three-rhombus-sums-in-a-grid/README.md b/problems/get-biggest-three-rhombus-sums-in-a-grid/README.md new file mode 100644 index 000000000..701bedaeb --- /dev/null +++ b/problems/get-biggest-three-rhombus-sums-in-a-grid/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](../minimize-maximum-pair-sum-in-array "Minimize Maximum Pair Sum in Array") +                 +[Next >](../minimum-xor-sum-of-two-arrays "Minimum XOR Sum of Two Arrays") + +## [1878. Get Biggest Three Rhombus Sums in a Grid (Medium)](https://leetcode.com/problems/get-biggest-three-rhombus-sums-in-a-grid "矩阵中最大的三个菱形和") + +

    You are given an m x n integer matrix grid​​​.

    + +

    A rhombus sum is the sum of the elements that form the border of a regular rhombus shape in grid​​​. The rhombus must have the shape of a square rotated 45 degrees with each of the corners centered in a grid cell. Below is an image of four valid rhombus shapes with the corresponding colored cells that should be included in each rhombus sum:

    + +

    Note that the rhombus can have an area of 0, which is depicted by the purple rhombus in the bottom right corner.

    + +

    Return the biggest three distinct rhombus sums in the grid in descending order. If there are less than three distinct values, return all of them.

    + +

     

    +

    Example 1:

    + +
    +Input: grid = [[3,4,5,1,3],[3,3,4,2,3],[20,30,200,40,10],[1,5,5,4,1],[4,3,2,2,5]]
    +Output: [228,216,211]
    +Explanation: The rhombus shapes for the three biggest distinct rhombus sums are depicted above.
    +- Blue: 20 + 3 + 200 + 5 = 228
    +- Red: 200 + 2 + 10 + 4 = 216
    +- Green: 5 + 200 + 4 + 2 = 211
    +
    + +

    Example 2:

    + +
    +Input: grid = [[1,2,3],[4,5,6],[7,8,9]]
    +Output: [20,9,8]
    +Explanation: The rhombus shapes for the three biggest distinct rhombus sums are depicted above.
    +- Blue: 4 + 2 + 6 + 8 = 20
    +- Red: 9 (area 0 rhombus in the bottom right corner)
    +- Green: 8 (area 0 rhombus in the bottom middle)
    +
    + +

    Example 3:

    + +
    +Input: grid = [[7,7,7]]
    +Output: [7]
    +Explanation: All three possible rhombus sums are the same, so return [7].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 50
    • +
    • 1 <= grid[i][j] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +You need to maintain only the biggest 3 distinct sums +
    + +
    +Hint 2 +The limits are small enough for you to iterate over all rhombus sizes then iterate over all possible borders to get the sums +
    diff --git a/problems/gray-code/README.md b/problems/gray-code/README.md index 59eb1aaf0..f44dd4687 100644 --- a/problems/gray-code/README.md +++ b/problems/gray-code/README.md @@ -11,11 +11,17 @@ ## [89. Gray Code (Medium)](https://leetcode.com/problems/gray-code "格雷编码") -

    The gray code is a binary numeral system where two successive values differ in only one bit.

    +

    An n-bit gray code sequence is a sequence of 2n integers where:

    -

    Given an integer n representing the total number of bits in the code, return any sequence of gray code.

    +
      +
    • Every integer is in the inclusive range [0, 2n - 1],
    • +
    • The first integer is 0,
    • +
    • An integer appears no more than once in the sequence,
    • +
    • The binary representation of every pair of adjacent integers differs by exactly one bit, and
    • +
    • The binary representation of the first and last integers differs by exactly one bit.
    • +
    -

    A gray code sequence must begin with 0.

    +

    Given an integer n, return any valid n-bit gray code sequence.

     

    Example 1:

    @@ -24,15 +30,16 @@ Input: n = 2 Output: [0,1,3,2] Explanation: -00 - 0 -01 - 1 -11 - 3 -10 - 2 -[0,2,3,1] is also a valid gray code sequence. -00 - 0 -10 - 2 -11 - 3 -01 - 1 +The binary representation of [0,1,3,2] is [00,01,11,10]. +- 00 and 01 differ by one bit +- 01 and 11 differ by one bit +- 11 and 10 differ by one bit +- 10 and 00 differ by one bit +[0,2,3,1] is also a valid gray code sequence, whose binary representation is [00,10,11,01]. +- 00 and 10 differ by one bit +- 10 and 11 differ by one bit +- 11 and 01 differ by one bit +- 01 and 00 differ by one bit

    Example 2:

    diff --git a/problems/grid-illumination/README.md b/problems/grid-illumination/README.md index fc997ff9a..56d12503b 100644 --- a/problems/grid-illumination/README.md +++ b/problems/grid-illumination/README.md @@ -11,7 +11,7 @@ ## [1001. Grid Illumination (Hard)](https://leetcode.com/problems/grid-illumination "网格照明") -

    There is a 2D grid of size N x N where each cell of this grid has a lamp that is initially turned off.

    +

    There is a 2D grid of size n x n where each cell of this grid has a lamp that is initially turned off.

    You are given a 2D array of lamp positions lamps, where lamps[i] = [rowi, coli] indicates that the lamp at grid[rowi][coli] is turned on. Even if the same lamp is listed more than once, it is turned on.

    @@ -25,7 +25,7 @@

    Example 1:

    -Input: N = 5, lamps = [[0,0],[4,4]], queries = [[1,1],[1,0]]
    +Input: n = 5, lamps = [[0,0],[4,4]], queries = [[1,1],[1,0]]
     Output: [1,0]
     Explanation: We have the initial grid with all lamps turned off. In the above picture we see the grid after turning on the lamp at grid[0][0] then turning on the lamp at grid[4][4].
     The 0th query asks if the lamp at grid[1][1] is illuminated or not (the blue square). It is illuminated, so set ans[0] = 1. Then, we turn off all lamps in the red square.
    @@ -37,14 +37,14 @@ The 1st query asks if the lamp at grid[1][0] is illuminated or n
     

    Example 2:

    -Input: N = 5, lamps = [[0,0],[4,4]], queries = [[1,1],[1,1]]
    +Input: n = 5, lamps = [[0,0],[4,4]], queries = [[1,1],[1,1]]
     Output: [1,1]
     

    Example 3:

    -Input: N = 5, lamps = [[0,0],[0,4]], queries = [[0,4],[0,1],[1,4]]
    +Input: n = 5, lamps = [[0,0],[0,4]], queries = [[0,4],[0,1],[1,4]]
     Output: [1,1,0]
     
    @@ -52,13 +52,13 @@ The 1st query asks if the lamp at grid[1][0] is illuminated or n

    Constraints:

      -
    • 1 <= N <= 109
    • +
    • 1 <= n <= 109
    • 0 <= lamps.length <= 20000
    • 0 <= queries.length <= 20000
    • lamps[i].length == 2
    • -
    • 0 <= rowi, coli < N
    • +
    • 0 <= rowi, coli < n
    • queries[j].length == 2
    • -
    • 0 <= rowj, colj < N
    • +
    • 0 <= rowj, colj < n
    ### Related Topics diff --git a/problems/group-employees-of-the-same-salary/README.md b/problems/group-employees-of-the-same-salary/README.md new file mode 100644 index 000000000..58116a74e --- /dev/null +++ b/problems/group-employees-of-the-same-salary/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../minimize-product-sum-of-two-arrays "Minimize Product Sum of Two Arrays") +                 +[Next >](../substrings-of-size-three-with-distinct-characters "Substrings of Size Three with Distinct Characters") + +## [1875. Group Employees of the Same Salary (Medium)](https://leetcode.com/problems/group-employees-of-the-same-salary "") + + diff --git a/problems/group-employees-of-the-same-salary/mysql_schemas.sql b/problems/group-employees-of-the-same-salary/mysql_schemas.sql new file mode 100644 index 000000000..9a2f41471 --- /dev/null +++ b/problems/group-employees-of-the-same-salary/mysql_schemas.sql @@ -0,0 +1,7 @@ +Create table If Not Exists Employees (employee_id int, name varchar(30), salary int); +Truncate table Employees; +insert into Employees (employee_id, name, salary) values ('2', 'Meir', '3000'); +insert into Employees (employee_id, name, salary) values ('3', 'Michael', '3000'); +insert into Employees (employee_id, name, salary) values ('7', 'Addilyn', '7400'); +insert into Employees (employee_id, name, salary) values ('8', 'Juan', '6100'); +insert into Employees (employee_id, name, salary) values ('9', 'Kannon', '7400'); diff --git a/problems/grumpy-bookstore-owner/README.md b/problems/grumpy-bookstore-owner/README.md index 0982db199..e18f02973 100644 --- a/problems/grumpy-bookstore-owner/README.md +++ b/problems/grumpy-bookstore-owner/README.md @@ -15,7 +15,7 @@

    On some minutes, the bookstore owner is grumpy.  If the bookstore owner is grumpy on the i-th minute, grumpy[i] = 1, otherwise grumpy[i] = 0.  When the bookstore owner is grumpy, the customers of that minute are not satisfied, otherwise they are satisfied.

    -

    The bookstore owner knows a secret technique to keep themselves not grumpy for X minutes straight, but can only use it once.

    +

    The bookstore owner knows a secret technique to keep themselves not grumpy for minutes minutes straight, but can only use it once.

    Return the maximum number of customers that can be satisfied throughout the day.

    @@ -24,7 +24,7 @@

    Example 1:

    -Input: customers = [1,0,1,2,1,1,7,5], grumpy = [0,1,0,1,0,1,0,1], X = 3
    +Input: customers = [1,0,1,2,1,1,7,5], grumpy = [0,1,0,1,0,1,0,1], minutes = 3
     Output: 16
     Explanation: The bookstore owner keeps themselves not grumpy for the last 3 minutes. 
     The maximum number of customers that can be satisfied = 1 + 1 + 1 + 1 + 7 + 5 = 16.
    @@ -35,7 +35,7 @@ The maximum number of customers that can be satisfied = 1 + 1 + 1 + 1 + 7 + 5 =
     

    Note:

      -
    • 1 <= X <= customers.length == grumpy.length <= 20000
    • +
    • 1 <= minutes <= customers.length == grumpy.length <= 20000
    • 0 <= customers[i] <= 1000
    • 0 <= grumpy[i] <= 1
    diff --git a/problems/increasing-triplet-subsequence/README.md b/problems/increasing-triplet-subsequence/README.md index fb3e9d238..7b1e6a55b 100644 --- a/problems/increasing-triplet-subsequence/README.md +++ b/problems/increasing-triplet-subsequence/README.md @@ -42,7 +42,7 @@

    Constraints:

      -
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums.length <= 5 * 105
    • -231 <= nums[i] <= 231 - 1
    diff --git a/problems/incremental-memory-leak/README.md b/problems/incremental-memory-leak/README.md new file mode 100644 index 000000000..16250838d --- /dev/null +++ b/problems/incremental-memory-leak/README.md @@ -0,0 +1,65 @@ + + + + + + + +[< Previous](../sorting-the-sentence "Sorting the Sentence") +                 +[Next >](../rotating-the-box "Rotating the Box") + +## [1860. Incremental Memory Leak (Medium)](https://leetcode.com/problems/incremental-memory-leak "增长的内存泄露") + +

    You are given two integers memory1 and memory2 representing the available memory in bits on two memory sticks. There is currently a faulty program running that consumes an increasing amount of memory every second.

    + +

    At the ith second (starting from 1), i bits of memory are allocated to the stick with more available memory (or from the first memory stick if both have the same available memory). If neither stick has at least i bits of available memory, the program crashes.

    + +

    Return an array containing [crashTime, memory1crash, memory2crash], where crashTime is the time (in seconds) when the program crashed and memory1crash and memory2crash are the available bits of memory in the first and second sticks respectively.

    + +

     

    +

    Example 1:

    + +
    +Input: memory1 = 2, memory2 = 2
    +Output: [3,1,0]
    +Explanation: The memory is allocated as follows:
    +- At the 1st second, 1 bit of memory is allocated to stick 1. The first stick now has 1 bit of available memory.
    +- At the 2nd second, 2 bits of memory are allocated to stick 2. The second stick now has 0 bits of available memory.
    +- At the 3rd second, the program crashes. The sticks have 1 and 0 bits available respectively.
    +
    + +

    Example 2:

    + +
    +Input: memory1 = 8, memory2 = 11
    +Output: [6,0,4]
    +Explanation: The memory is allocated as follows:
    +- At the 1st second, 1 bit of memory is allocated to stick 2. The second stick now has 10 bit of available memory.
    +- At the 2nd second, 2 bits of memory are allocated to stick 2. The second stick now has 8 bits of available memory.
    +- At the 3rd second, 3 bits of memory are allocated to stick 1. The first stick now has 5 bits of available memory.
    +- At the 4th second, 4 bits of memory are allocated to stick 2. The second stick now has 4 bits of available memory.
    +- At the 5th second, 5 bits of memory are allocated to stick 1. The first stick now has 0 bits of available memory.
    +- At the 6th second, the program crashes. The sticks have 0 and 4 bits available respectively.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= memory1, memory2 <= 231 - 1
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +What is the upper bound for the number of seconds? +
    + +
    +Hint 2 +Simulate the process of allocating memory. +
    diff --git a/problems/insert-delete-getrandom-o1/README.md b/problems/insert-delete-getrandom-o1/README.md index d41ed0818..3fb6ec3ae 100644 --- a/problems/insert-delete-getrandom-o1/README.md +++ b/problems/insert-delete-getrandom-o1/README.md @@ -9,7 +9,7 @@                  [Next >](../insert-delete-getrandom-o1-duplicates-allowed "Insert Delete GetRandom O(1) - Duplicates allowed") -## [380. Insert Delete GetRandom O(1) (Medium)](https://leetcode.com/problems/insert-delete-getrandom-o1 "常数时间插入、删除和获取随机元素") +## [380. Insert Delete GetRandom O(1) (Medium)](https://leetcode.com/problems/insert-delete-getrandom-o1 "O(1) 时间插入、删除和获取随机元素")

    Implement the RandomizedSet class:

    diff --git a/problems/ip-to-cidr/README.md b/problems/ip-to-cidr/README.md index 4d421dba8..6e0ddeb26 100644 --- a/problems/ip-to-cidr/README.md +++ b/problems/ip-to-cidr/README.md @@ -9,7 +9,7 @@                  [Next >](../open-the-lock "Open the Lock") -## [751. IP to CIDR (Easy)](https://leetcode.com/problems/ip-to-cidr "IP 到 CIDR") +## [751. IP to CIDR (Medium)](https://leetcode.com/problems/ip-to-cidr "IP 到 CIDR")

    Given a start IP address ip and a number of ips we need to cover n, return a representation of the range as a list (of smallest possible length) of CIDR blocks. diff --git a/problems/is-subsequence/README.md b/problems/is-subsequence/README.md index 7675c6b1e..2069b926d 100644 --- a/problems/is-subsequence/README.md +++ b/problems/is-subsequence/README.md @@ -11,9 +11,9 @@ ## [392. Is Subsequence (Easy)](https://leetcode.com/problems/is-subsequence "判断子序列") -

    Given two strings s and t, check if s is a subsequence of t.

    +

    Given two strings s and t, return true if s is a subsequence of t, or false otherwise.

    -

    A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ace" is a subsequence of "abcde" while "aec" is not).

    +

    A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ace" is a subsequence of "abcde" while "aec" is not).

     

    Example 1:

    @@ -29,11 +29,11 @@
    • 0 <= s.length <= 100
    • 0 <= t.length <= 104
    • -
    • s and t consist only of lowercase English letters.
    • +
    • s and t consist only of lowercase English letters.

     

    -Follow up: If there are lots of incoming s, say s1, s2, ..., sk where k >= 109, and you want to check one by one to see if t has its subsequence. In this scenario, how would you change your code? +Follow up: Suppose there are lots of incoming s, say s1, s2, ..., sk where k >= 109, and you want to check one by one to see if t has its subsequence. In this scenario, how would you change your code? ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/jump-game-ii/README.md b/problems/jump-game-ii/README.md index ac0e0385c..a6f6dffcd 100644 --- a/problems/jump-game-ii/README.md +++ b/problems/jump-game-ii/README.md @@ -39,8 +39,8 @@

    Constraints:

      -
    • 1 <= nums.length <= 1000
    • -
    • 0 <= nums[i] <= 105
    • +
    • 1 <= nums.length <= 104
    • +
    • 0 <= nums[i] <= 1000
    ### Related Topics diff --git a/problems/jump-game-vii/README.md b/problems/jump-game-vii/README.md new file mode 100644 index 000000000..4bc3869a4 --- /dev/null +++ b/problems/jump-game-vii/README.md @@ -0,0 +1,65 @@ + + + + + + + +[< Previous](../minimum-speed-to-arrive-on-time "Minimum Speed to Arrive on Time") +                 +[Next >](../stone-game-viii "Stone Game VIII") + +## [1871. Jump Game VII (Medium)](https://leetcode.com/problems/jump-game-vii "跳跃游戏 VII") + +

    You are given a 0-indexed binary string s and two integers minJump and maxJump. In the beginning, you are standing at index 0, which is equal to '0'. You can move from index i to index j if the following conditions are fulfilled:

    + +
      +
    • i + minJump <= j <= min(i + maxJump, s.length - 1), and
    • +
    • s[j] == '0'.
    • +
    + +

    Return true if you can reach index s.length - 1 in s, or false otherwise.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "011010", minJump = 2, maxJump = 3
    +Output: true
    +Explanation:
    +In the first step, move from index 0 to index 3. 
    +In the second step, move from index 3 to index 5.
    +
    + +

    Example 2:

    + +
    +Input: s = "01101110", minJump = 2, maxJump = 3
    +Output: false
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= s.length <= 105
    • +
    • s[i] is either '0' or '1'.
    • +
    • s[0] == '0'
    • +
    • 1 <= minJump <= maxJump < s.length
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Line Sweep](../../tag/line-sweep/README.md)] + +### Hints +
    +Hint 1 +Consider for each reachable index i the interval [i + a, i + b]. +
    + +
    +Hint 2 +Use partial sums to mark the intervals as reachable. +
    diff --git a/problems/jump-game/README.md b/problems/jump-game/README.md index 391a3b615..6c566bd95 100644 --- a/problems/jump-game/README.md +++ b/problems/jump-game/README.md @@ -38,7 +38,7 @@

    Constraints:

      -
    • 1 <= nums.length <= 3 * 104
    • +
    • 1 <= nums.length <= 104
    • 0 <= nums[i] <= 105
    diff --git a/problems/k-th-symbol-in-grammar/README.md b/problems/k-th-symbol-in-grammar/README.md index 55448e681..81c8792b7 100644 --- a/problems/k-th-symbol-in-grammar/README.md +++ b/problems/k-th-symbol-in-grammar/README.md @@ -11,37 +11,61 @@ ## [779. K-th Symbol in Grammar (Medium)](https://leetcode.com/problems/k-th-symbol-in-grammar "第K个语法符号") -

    On the first row, we write a 0. Now in every subsequent row, we look at the previous row and replace each occurrence of 0 with 01, and each occurrence of 1 with 10.

    +

    We build a table of n rows (1-indexed). We start by writing 0 in the 1st row. Now in every subsequent row, we look at the previous row and replace each occurrence of 0 with 01, and each occurrence of 1 with 10.

    -

    Given row n and index k, return the kth indexed symbol in row n. (The values of k are 1-indexed.) (1 indexed).

    +
      +
    • For example, for n = 3, the 1st row is 0, the 2nd row is 01, and the 3rd row is 0110.
    • +
    + +

    Given two integer n and k, return the kth (1-indexed) symbol in the nth row of a table of n rows.

    + +

     

    +

    Example 1:

    -Examples:
     Input: n = 1, k = 1
     Output: 0
    +Explanation: row 1: 0
    +
    + +

    Example 2:

    +
     Input: n = 2, k = 1
     Output: 0
    +Explanation:
    +row 1: 0
    +row 2: 01
    +
    +

    Example 3:

    + +
     Input: n = 2, k = 2
     Output: 1
    +Explanation:
    +row 1: 0
    +row 2: 01
    +
    -Input: n = 4, k = 5 -Output: 1 +

    Example 4:

    +
    +Input: n = 3, k = 1
    +Output: 0
     Explanation:
     row 1: 0
     row 2: 01
    -row 3: 0110
    -row 4: 01101001
    +row 3: 0110
     
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. n will be an integer in the range [1, 30].
    2. -
    3. k will be an integer in the range [1, 2n-1].
    4. -
    +
      +
    • 1 <= n <= 30
    • +
    • 1 <= k <= 2n - 1
    • +
    ### Related Topics [[Recursion](../../tag/recursion/README.md)] diff --git a/problems/largest-color-value-in-a-directed-graph/README.md b/problems/largest-color-value-in-a-directed-graph/README.md index afcb8bd3f..99c359dee 100644 --- a/problems/largest-color-value-in-a-directed-graph/README.md +++ b/problems/largest-color-value-in-a-directed-graph/README.md @@ -7,7 +7,7 @@ [< Previous](../maximum-subarray-min-product "Maximum Subarray Min-Product")                  -Next > +[Next >](../longest-word-with-all-prefixes "Longest Word With All Prefixes") ## [1857. Largest Color Value in a Directed Graph (Hard)](https://leetcode.com/problems/largest-color-value-in-a-directed-graph "有向图中最大颜色值") diff --git a/problems/length-of-longest-fibonacci-subsequence/README.md b/problems/length-of-longest-fibonacci-subsequence/README.md index 2d0bb2b6b..6fe4be3c3 100644 --- a/problems/length-of-longest-fibonacci-subsequence/README.md +++ b/problems/length-of-longest-fibonacci-subsequence/README.md @@ -11,16 +11,16 @@ ## [873. Length of Longest Fibonacci Subsequence (Medium)](https://leetcode.com/problems/length-of-longest-fibonacci-subsequence "最长的斐波那契子序列的长度") -

    A sequence X1, X2, ..., Xn is Fibonacci-like if:

    +

    A sequence x1, x2, ..., xn is Fibonacci-like if:

    • n >= 3
    • -
    • Xi + Xi+1 = Xi+2 for all i + 2 <= n
    • +
    • xi + xi+1 == xi+2 for all i + 2 <= n
    -

    Given a strictly increasing array arr of positive integers forming a sequence, return the length of the longest Fibonacci-like subsequence of arr. If one does not exist, return 0.

    +

    Given a strictly increasing array arr of positive integers forming a sequence, return the length of the longest Fibonacci-like subsequence of arr. If one does not exist, return 0.

    -

    A subsequence is derived from another sequence arr by deleting any number of elements (including none) from arr, without changing the order of the remaining elements. For example, [3, 5, 8] is a subsequence of [3, 4, 5, 6, 7, 8].

    +

    A subsequence is derived from another sequence arr by deleting any number of elements (including none) from arr, without changing the order of the remaining elements. For example, [3, 5, 8] is a subsequence of [3, 4, 5, 6, 7, 8].

     

    Example 1:

    diff --git a/problems/lexicographical-numbers/README.md b/problems/lexicographical-numbers/README.md index 8d96fd73a..f8fabfcc2 100644 --- a/problems/lexicographical-numbers/README.md +++ b/problems/lexicographical-numbers/README.md @@ -13,6 +13,8 @@

    Given an integer n, return all the numbers in the range [1, n] sorted in lexicographical order.

    +

    You must write an algorithm that runs in O(n) time and uses O(1) extra space. 

    +

     

    Example 1:

    Input: n = 13
    @@ -27,6 +29,3 @@
     
    • 1 <= n <= 5 * 104
    - -

     

    -

    Follow up: Could you optimize your solution to use O(n) runtime and O(1) space?

    diff --git a/problems/longer-contiguous-segments-of-ones-than-zeros/README.md b/problems/longer-contiguous-segments-of-ones-than-zeros/README.md new file mode 100644 index 000000000..76519407c --- /dev/null +++ b/problems/longer-contiguous-segments-of-ones-than-zeros/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../product-of-two-run-length-encoded-arrays "Product of Two Run-Length Encoded Arrays") +                 +[Next >](../minimum-speed-to-arrive-on-time "Minimum Speed to Arrive on Time") + +## [1869. Longer Contiguous Segments of Ones than Zeros (Easy)](https://leetcode.com/problems/longer-contiguous-segments-of-ones-than-zeros "哪种连续子字符串更长") + +

    Given a binary string s, return true if the longest contiguous segment of 1s is strictly longer than the longest contiguous segment of 0s in s. Return false otherwise.

    + +
      +
    • For example, in s = "110100010" the longest contiguous segment of 1s has length 2, and the longest contiguous segment of 0s has length 3.
    • +
    + +

    Note that if there are no 0s, then the longest contiguous segment of 0s is considered to have length 0. The same applies if there are no 1s.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "1101"
    +Output: true
    +Explanation:
    +The longest contiguous segment of 1s has length 2: "1101"
    +The longest contiguous segment of 0s has length 1: "1101"
    +The segment of 1s is longer, so return true.
    +
    + +

    Example 2:

    + +
    +Input: s = "111000"
    +Output: false
    +Explanation:
    +The longest contiguous segment of 1s has length 3: "111000"
    +The longest contiguous segment of 0s has length 3: "111000"
    +The segment of 1s is not longer, so return false.
    +
    + +

    Example 3:

    + +
    +Input: s = "110100010"
    +Output: false
    +Explanation:
    +The longest contiguous segment of 1s has length 2: "110100010"
    +The longest contiguous segment of 0s has length 3: "110100010"
    +The segment of 1s is not longer, so return false.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 100
    • +
    • s[i] is either '0' or '1'.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + +### Hints +
    +Hint 1 +Check every possible segment of 0s and 1s. +
    + +
    +Hint 2 +Is there a way to iterate through the string to keep track of the current character and its count? +
    diff --git a/problems/longest-arithmetic-subsequence/README.md b/problems/longest-arithmetic-subsequence/README.md index 7d417a079..0a52b3dbc 100644 --- a/problems/longest-arithmetic-subsequence/README.md +++ b/problems/longest-arithmetic-subsequence/README.md @@ -11,15 +11,15 @@ ## [1027. Longest Arithmetic Subsequence (Medium)](https://leetcode.com/problems/longest-arithmetic-subsequence "最长等差数列") -

    Given an array A of integers, return the length of the longest arithmetic subsequence in A.

    +

    Given an array nums of integers, return the length of the longest arithmetic subsequence in nums.

    -

    Recall that a subsequence of A is a list A[i_1], A[i_2], ..., A[i_k] with 0 <= i_1 < i_2 < ... < i_k <= A.length - 1, and that a sequence B is arithmetic if B[i+1] - B[i] are all the same value (for 0 <= i < B.length - 1).

    +

    Recall that a subsequence of an array nums is a list nums[i1], nums[i2], ..., nums[ik] with 0 <= i1 < i2 < ... < ik <= nums.length - 1, and that a sequence seq is arithmetic if seq[i+1] - seq[i] are all the same value (for 0 <= i < seq.length - 1).

     

    Example 1:

    -Input: A = [3,6,9,12]
    +Input: nums = [3,6,9,12]
     Output: 4
     Explanation: 
     The whole array is an arithmetic sequence with steps of length = 3.
    @@ -28,7 +28,7 @@ The whole array is an arithmetic sequence with steps of length = 3.
     

    Example 2:

    -Input: A = [9,4,7,2,10]
    +Input: nums = [9,4,7,2,10]
     Output: 3
     Explanation: 
     The longest arithmetic subsequence is [4,7,10].
    @@ -37,7 +37,7 @@ The longest arithmetic subsequence is [4,7,10].
     

    Example 3:

    -Input: A = [20,1,15,3,10,5,8]
    +Input: nums = [20,1,15,3,10,5,8]
     Output: 4
     Explanation: 
     The longest arithmetic subsequence is [20,15,10,5].
    @@ -47,8 +47,8 @@ The longest arithmetic subsequence is [20,15,10,5].
     

    Constraints:

      -
    • 2 <= A.length <= 1000
    • -
    • 0 <= A[i] <= 500
    • +
    • 2 <= nums.length <= 1000
    • +
    • 0 <= nums[i] <= 500
    ### Related Topics diff --git a/problems/longest-consecutive-sequence/README.md b/problems/longest-consecutive-sequence/README.md index 2c7ab18a4..b9b243dd9 100644 --- a/problems/longest-consecutive-sequence/README.md +++ b/problems/longest-consecutive-sequence/README.md @@ -9,10 +9,12 @@                  [Next >](../sum-root-to-leaf-numbers "Sum Root to Leaf Numbers") -## [128. Longest Consecutive Sequence (Hard)](https://leetcode.com/problems/longest-consecutive-sequence "最长连续序列") +## [128. Longest Consecutive Sequence (Medium)](https://leetcode.com/problems/longest-consecutive-sequence "最长连续序列")

    Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.

    +

    You must write an algorithm that runs in O(n) time.

    +

     

    Example 1:

    @@ -33,13 +35,10 @@

    Constraints:

      -
    • 0 <= nums.length <= 104
    • +
    • 0 <= nums.length <= 105
    • -109 <= nums[i] <= 109
    -

     

    -Follow up: Could you implement the O(n) solution? - ### Related Topics [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] diff --git a/problems/longest-increasing-subsequence/README.md b/problems/longest-increasing-subsequence/README.md index 47fd7b3f7..f81399903 100644 --- a/problems/longest-increasing-subsequence/README.md +++ b/problems/longest-increasing-subsequence/README.md @@ -47,12 +47,7 @@

     

    -

    Follow up:

    - -
      -
    • Could you come up with the O(n2) solution?
    • -
    • Could you improve it to O(n log(n)) time complexity?
    • -
    +

    Follow up: Can you come up with an algorithm that runs in O(n log(n)) time complexity?

    ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/longest-string-chain/README.md b/problems/longest-string-chain/README.md index 72728e724..eca9bb45b 100644 --- a/problems/longest-string-chain/README.md +++ b/problems/longest-string-chain/README.md @@ -11,13 +11,17 @@ ## [1048. Longest String Chain (Medium)](https://leetcode.com/problems/longest-string-chain "最长字符串链") -

    Given a list of words, each word consists of English lowercase letters.

    +

    You are given an array of words where each word consists of lowercase English letters.

    -

    Let's say word1 is a predecessor of word2 if and only if we can add exactly one letter anywhere in word1 to make it equal to word2. For example, "abc" is a predecessor of "abac".

    +

    wordA is a predecessor of wordB if and only if we can insert exactly one letter anywhere in wordA without changing the order of the other characters to make it equal to wordB.

    -

    A word chain is a sequence of words [word_1, word_2, ..., word_k] with k >= 1, where word_1 is a predecessor of word_2, word_2 is a predecessor of word_3, and so on.

    +
      +
    • For example, "abc" is a predecessor of "abac", while "cba" is not a predecessor of "bcad".
    • +
    -

    Return the longest possible length of a word chain with words chosen from the given list of words.

    +

    A word chain is a sequence of words [word1, word2, ..., wordk] with k >= 1, where word1 is a predecessor of word2, word2 is a predecessor of word3, and so on. A single word is trivially a word chain with k == 1.

    + +

    Return the length of the longest possible word chain with words chosen from the given list of words.

     

    Example 1:

    @@ -25,7 +29,7 @@
     Input: words = ["a","b","ba","bca","bda","bdca"]
     Output: 4
    -Explanation: One of the longest word chain is "a","ba","bda","bdca".
    +Explanation: One of the longest word chains is ["a","ba","bda","bdca"].
     

    Example 2:

    @@ -33,6 +37,16 @@
     Input: words = ["xbc","pcxbcf","xb","cxbc","pcxbc"]
     Output: 5
    +Explanation: All the words can be put in a word chain ["xb", "xbc", "cxbc", "pcxbc", "pcxbcf"].
    +
    + +

    Example 3:

    + +
    +Input: words = ["abcd","dbqca"]
    +Output: 1
    +Explanation: The trivial word chain ["abcd"] is one of the longest word chains.
    +["abcd","dbqca"] is not a valid word chain because the ordering of the letters is changed.
     

     

    @@ -41,7 +55,7 @@
    • 1 <= words.length <= 1000
    • 1 <= words[i].length <= 16
    • -
    • words[i] only consists of English lowercase letters.
    • +
    • words[i] only consists of lowercase English letters.
    ### Related Topics diff --git a/problems/longest-word-with-all-prefixes/README.md b/problems/longest-word-with-all-prefixes/README.md new file mode 100644 index 000000000..01bf52f39 --- /dev/null +++ b/problems/longest-word-with-all-prefixes/README.md @@ -0,0 +1,30 @@ + + + + + + + +[< Previous](../largest-color-value-in-a-directed-graph "Largest Color Value in a Directed Graph") +                 +[Next >](../sorting-the-sentence "Sorting the Sentence") + +## [1858. Longest Word With All Prefixes (Medium)](https://leetcode.com/problems/longest-word-with-all-prefixes "") + + + +### Related Topics + [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +Add all the words to a trie. +
    + +
    +Hint 2 +Check the longest path where all the nodes are words. +
    diff --git a/problems/matrix-cells-in-distance-order/README.md b/problems/matrix-cells-in-distance-order/README.md index 03b0443b0..eb0171092 100644 --- a/problems/matrix-cells-in-distance-order/README.md +++ b/problems/matrix-cells-in-distance-order/README.md @@ -11,11 +11,11 @@ ## [1030. Matrix Cells in Distance Order (Easy)](https://leetcode.com/problems/matrix-cells-in-distance-order "距离顺序排列矩阵单元格") -

    We are given a matrix with R rows and C columns has cells with integer coordinates (r, c), where 0 <= r < R and 0 <= c < C.

    +

    We are given a matrix with rows rows and cols columns has cells with integer coordinates (r, c), where 0 <= r < rows and 0 <= c < cols.

    -

    Additionally, we are given a cell in that matrix with coordinates (r0, c0).

    +

    Additionally, we are given a cell in that matrix with coordinates (rCenter, cCenter).

    -

    Return the coordinates of all cells in the matrix, sorted by their distance from (r0, c0) from smallest distance to largest distance.  Here, the distance between two cells (r1, c1) and (r2, c2) is the Manhattan distance, |r1 - r2| + |c1 - c2|.  (You may return the answer in any order that satisfies this condition.)

    +

    Return the coordinates of all cells in the matrix, sorted by their distance from (rCenter, cCenter) from smallest distance to largest distance.  Here, the distance between two cells (r1, c1) and (r2, c2) is the Manhattan distance, |r1 - r2| + |c1 - c2|.  (You may return the answer in any order that satisfies this condition.)

     

    @@ -23,18 +23,18 @@

    Example 1:

    -Input: R = 1, C = 2, r0 = 0, c0 = 0
    +Input: rows = 1, cols = 2, rCenter = 0, cCenter = 0
     Output: [[0,0],[0,1]]
    -Explanation: The distances from (r0, c0) to other cells are: [0,1]
    +Explanation: The distances from (0, 0) to other cells are: [0,1]
     

    Example 2:

    -Input: R = 2, C = 2, r0 = 0, c0 = 1
    +Input: rows = 2, cols = 2, rCenter = 0, cCenter = 1
     Output: [[0,1],[0,0],[1,1],[1,0]]
    -Explanation: The distances from (r0, c0) to other cells are: [0,1,1,2]
    +Explanation: The distances from (0, 1) to other cells are: [0,1,1,2]
     The answer [[0,1],[1,1],[0,0],[1,0]] would also be accepted as correct.
     
    @@ -42,9 +42,9 @@ The answer [[0,1],[1,1],[0,0],[1,0]] would also be accepted as correct.

    Example 3:

    -Input: R = 2, C = 3, r0 = 1, c0 = 2
    +Input: rows = 2, cols = 3, rCenter = 1, cCenter = 2
     Output: [[1,2],[0,2],[1,1],[0,1],[1,0],[0,0]]
    -Explanation: The distances from (r0, c0) to other cells are: [0,1,1,2,2,3]
    +Explanation: The distances from (1, 2) to other cells are: [0,1,1,2,2,3]
     There are other answers that would also be accepted as correct, such as [[1,2],[1,1],[0,2],[1,0],[0,1],[0,0]].
     
    @@ -53,10 +53,10 @@ There are other answers that would also be accepted as correct, such as [[1,2],[

    Note:

      -
    1. 1 <= R <= 100
    2. -
    3. 1 <= C <= 100
    4. -
    5. 0 <= r0 < R
    6. -
    7. 0 <= c0 < C
    8. +
    9. 1 <= rows <= 100
    10. +
    11. 1 <= cols <= 100
    12. +
    13. 0 <= rCenter < rows
    14. +
    15. 0 <= cCenter < cols
    diff --git a/problems/max-value-of-equation/README.md b/problems/max-value-of-equation/README.md index 09b036ff5..e60b3d438 100644 --- a/problems/max-value-of-equation/README.md +++ b/problems/max-value-of-equation/README.md @@ -11,9 +11,11 @@ ## [1499. Max Value of Equation (Hard)](https://leetcode.com/problems/max-value-of-equation "满足不等式的最大值") -

    Given an array points containing the coordinates of points on a 2D plane, sorted by the x-values, where points[i] = [xi, yi] such that xi < xj for all 1 <= i < j <= points.length. You are also given an integer k.

    +

    You are given an array points containing the coordinates of points on a 2D plane, sorted by the x-values, where points[i] = [xi, yi] such that xi < xj for all 1 <= i < j <= points.length. You are also given an integer k.

    -

    Find the maximum value of the equation yi + yj + |xi - xj| where |xi - xj| <= k and 1 <= i < j <= points.length. It is guaranteed that there exists at least one pair of points that satisfy the constraint |xi - xj| <= k.

    +

    Return the maximum value of the equation yi + yj + |xi - xj| where |xi - xj| <= k and 1 <= i < j <= points.length.

    + +

    It is guaranteed that there exists at least one pair of points that satisfy the constraint |xi - xj| <= k.

     

    Example 1:

    @@ -21,8 +23,9 @@
     Input: points = [[1,3],[2,0],[5,10],[6,-10]], k = 1
     Output: 4
    -Explanation: The first two points satisfy the condition |xi - xj| <= 1 and if we calculate the equation we get 3 + 0 + |1 - 2| = 4. Third and fourth points also satisfy the condition and give a value of 10 + -10 + |5 - 6| = 1.
    -No other pairs satisfy the condition, so we return the max of 4 and 1.
    +Explanation: The first two points satisfy the condition |xi - xj| <= 1 and if we calculate the equation we get 3 + 0 + |1 - 2| = 4. Third and fourth points also satisfy the condition and give a value of 10 + -10 + |5 - 6| = 1. +No other pairs satisfy the condition, so we return the max of 4 and 1. +

    Example 2:

    @@ -36,12 +39,12 @@ No other pairs satisfy the condition, so we return the max of 4 and 1.

    Constraints:

      -
    • 2 <= points.length <= 10^5
    • +
    • 2 <= points.length <= 105
    • points[i].length == 2
    • -
    • -10^8 <= points[i][0], points[i][1] <= 10^8
    • -
    • 0 <= k <= 2 * 10^8
    • -
    • points[i][0] < points[j][0] for all 1 <= i < j <= points.length
    • -
    • xi form a strictly increasing sequence.
    • +
    • -108 <= xi, yi <= 108
    • +
    • 0 <= k <= 2 * 108
    • +
    • xi < xj for all 1 <= i < j <= points.length
    • +
    • xi form a strictly increasing sequence.
    ### Related Topics diff --git a/problems/maximize-sum-of-array-after-k-negations/README.md b/problems/maximize-sum-of-array-after-k-negations/README.md index 59af8a1bf..7c562f826 100644 --- a/problems/maximize-sum-of-array-after-k-negations/README.md +++ b/problems/maximize-sum-of-array-after-k-negations/README.md @@ -11,7 +11,7 @@ ## [1005. Maximize Sum Of Array After K Negations (Easy)](https://leetcode.com/problems/maximize-sum-of-array-after-k-negations "K 次取反后最大化的数组和") -

    Given an array A of integers, we must modify the array in the following way: we choose an i and replace A[i] with -A[i], and we repeat this process K times in total.  (We may choose the same index i multiple times.)

    +

    Given an array nums of integers, we must modify the array in the following way: we choose an i and replace nums[i] with -nums[i], and we repeat this process k times in total.  (We may choose the same index i multiple times.)

    Return the largest possible sum of the array after modifying it in this way.

    @@ -20,27 +20,27 @@

    Example 1:

    -Input: A = [4,2,3], K = 1
    +Input: nums = [4,2,3], k = 1
     Output: 5
    -Explanation: Choose indices (1,) and A becomes [4,-2,3].
    +Explanation: Choose indices (1,) and nums becomes [4,-2,3].
     

    Example 2:

    -Input: A = [3,-1,0,2], K = 3
    +Input: nums = [3,-1,0,2], k = 3
     Output: 6
    -Explanation: Choose indices (1, 2, 2) and A becomes [3,1,0,2].
    +Explanation: Choose indices (1, 2, 2) and nums becomes [3,1,0,2].
     

    Example 3:

    -Input: A = [2,-3,-1,5,-4], K = 2
    +Input: nums = [2,-3,-1,5,-4], k = 2
     Output: 13
    -Explanation: Choose indices (1, 4) and A becomes [2,3,-1,5,4].
    +Explanation: Choose indices (1, 4) and nums becomes [2,3,-1,5,4].
     
    @@ -50,9 +50,9 @@

    Note:

      -
    1. 1 <= A.length <= 10000
    2. -
    3. 1 <= K <= 10000
    4. -
    5. -100 <= A[i] <= 100
    6. +
    7. 1 <= nums.length <= 10000
    8. +
    9. 1 <= k <= 10000
    10. +
    11. -100 <= nums[i] <= 100
    ### Related Topics diff --git a/problems/maximum-depth-of-n-ary-tree/README.md b/problems/maximum-depth-of-n-ary-tree/README.md index 921bb5083..1702bafe4 100644 --- a/problems/maximum-depth-of-n-ary-tree/README.md +++ b/problems/maximum-depth-of-n-ary-tree/README.md @@ -15,7 +15,7 @@

    The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

    -

    Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples).

    +

    Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples).

     

    Example 1:

    @@ -41,7 +41,7 @@
    • The depth of the n-ary tree is less than or equal to 1000.
    • -
    • The total number of nodes is between [0, 104].
    • +
    • The total number of nodes is between [0, 104].
    ### Related Topics diff --git a/problems/maximum-gap/README.md b/problems/maximum-gap/README.md index 38be7a47a..268892541 100644 --- a/problems/maximum-gap/README.md +++ b/problems/maximum-gap/README.md @@ -13,6 +13,8 @@

    Given an integer array nums, return the maximum difference between two successive elements in its sorted form. If the array contains less than two elements, return 0.

    +

    You must write an algorithm that runs in linear time and uses linear extra space.

    +

     

    Example 1:

    @@ -38,8 +40,5 @@
  • 0 <= nums[i] <= 109
  • -

     

    -Follow up: Could you solve it in linear time/space? - ### Related Topics [[Sort](../../tag/sort/README.md)] diff --git a/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md b/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md index ee1fefba8..ba8d02b14 100644 --- a/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md +++ b/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md @@ -9,7 +9,7 @@                  [Next >](../minimum-cost-to-cut-a-stick "Minimum Cost to Cut a Stick") -## [1546. Maximum Number of Non-Overlapping Subarrays With Sum Equals Target (Medium)](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值的最大数目不重叠非空子数组数目") +## [1546. Maximum Number of Non-Overlapping Subarrays With Sum Equals Target (Medium)](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值且不重叠的非空子数组的最大数目")

    Given an array nums and an integer target.

    diff --git a/problems/maximum-points-you-can-obtain-from-cards/README.md b/problems/maximum-points-you-can-obtain-from-cards/README.md index 586217ad0..7ecc05c49 100644 --- a/problems/maximum-points-you-can-obtain-from-cards/README.md +++ b/problems/maximum-points-you-can-obtain-from-cards/README.md @@ -11,7 +11,7 @@ ## [1423. Maximum Points You Can Obtain from Cards (Medium)](https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards "可获得的最大点数") -

    There are several cards arranged in a row, and each card has an associated number of points The points are given in the integer array cardPoints.

    +

    There are several cards arranged in a row, and each card has an associated number of points. The points are given in the integer array cardPoints.

    In one step, you can take one card from the beginning or from the end of the row. You have to take exactly k cards.

    @@ -63,8 +63,8 @@

    Constraints:

      -
    • 1 <= cardPoints.length <= 10^5
    • -
    • 1 <= cardPoints[i] <= 10^4
    • +
    • 1 <= cardPoints.length <= 105
    • +
    • 1 <= cardPoints[i] <= 104
    • 1 <= k <= cardPoints.length
    diff --git a/problems/maximum-sum-circular-subarray/README.md b/problems/maximum-sum-circular-subarray/README.md index 4e4e9bf59..6351fd614 100644 --- a/problems/maximum-sum-circular-subarray/README.md +++ b/problems/maximum-sum-circular-subarray/README.md @@ -11,70 +11,61 @@ ## [918. Maximum Sum Circular Subarray (Medium)](https://leetcode.com/problems/maximum-sum-circular-subarray "环形子数组的最大和") -

    Given a circular array circ of integers represented by nums, find the maximum possible sum of a non-empty subarray of circ.

    +

    Given a circular integer array nums of length n, return the maximum possible sum of a non-empty subarray of nums.

    -

    Here, a circular array means the end of the array connects to the beginning of the array.  (Formally, circ[i] = nums[i] when 0 <= i < nums.length, and circ[i+nums.length] = circ[i] when i >= 0.)

    +

    A circular array means the end of the array connects to the beginning of the array. Formally, the next element of nums[i] is nums[(i + 1) % n] and the previous element of nums[i] is nums[(i - 1 + n) % n].

    -

    Also, a subarray may only include each element of the fixed buffer nums at most once.  (Formally, for a subarray circ[i], circ[i+1], ..., circ[j], there does not exist i <= k1, k2 <= j with k1 % nums.length = k2 % nums.length.)

    +

    A subarray may only include each element of the fixed buffer nums at most once. Formally, for a subarray nums[i], nums[i + 1], ..., nums[j], there does not exist i <= k1, k2 <= j with k1 % n == k2 % n.

     

    - -

    Example 1:

    -Input: nums = [1,-2,3,-2]
    -Output: 3
    -Explanation: Subarray [3] has maximum sum 3
    +Input: nums = [1,-2,3,-2]
    +Output: 3
    +Explanation: Subarray [3] has maximum sum 3
     
    -

    Example 2:

    -Input: nums = [5,-3,5]
    -Output: 10
    -Explanation: Subarray [5,5] has maximum sum 5 + 5 = 10
    +Input: nums = [5,-3,5]
    +Output: 10
    +Explanation: Subarray [5,5] has maximum sum 5 + 5 = 10
     
    -

    Example 3:

    -Input: nums = [3,-1,2,-1]
    -Output: 4
    -Explanation: Subarray [2,-1,3] has maximum sum 2 + (-1) + 3 = 4
    +Input: nums = [3,-1,2,-1]
    +Output: 4
    +Explanation: Subarray [2,-1,3] has maximum sum 2 + (-1) + 3 = 4
     
    -

    Example 4:

    -Input: nums = [3,-2,2,-3]
    -Output: 3
    -Explanation: Subarray [3] and [3,-2,2] both have maximum sum 3
    +Input: nums = [3,-2,2,-3]
    +Output: 3
    +Explanation: Subarray [3] and [3,-2,2] both have maximum sum 3
     

    Example 5:

    -Input: nums = [-2,-3,-1]
    -Output: -1
    -Explanation: Subarray [-1] has maximum sum -1
    +Input: nums = [-2,-3,-1]
    +Output: -1
    +Explanation: Subarray [-1] has maximum sum -1
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. -30000 <= nums[i] <= 30000
    2. -
    3. 1 <= nums.length <= 30000
    4. -
    -
    -
    -
    -
    +
      +
    • n == nums.length
    • +
    • 1 <= n <= 3 * 104
    • +
    • -3 * 104 <= nums[i] <= 3 * 104
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/maximum-sum-of-two-non-overlapping-subarrays/README.md b/problems/maximum-sum-of-two-non-overlapping-subarrays/README.md index a21696936..4eddf187b 100644 --- a/problems/maximum-sum-of-two-non-overlapping-subarrays/README.md +++ b/problems/maximum-sum-of-two-non-overlapping-subarrays/README.md @@ -11,13 +11,13 @@ ## [1031. Maximum Sum of Two Non-Overlapping Subarrays (Medium)](https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays "两个非重叠子数组的最大和") -

    Given an array A of non-negative integers, return the maximum sum of elements in two non-overlapping (contiguous) subarrays, which have lengths L and M.  (For clarification, the L-length subarray could occur before or after the M-length subarray.)

    +

    Given an array nums of non-negative integers, return the maximum sum of elements in two non-overlapping (contiguous) subarrays, which have lengths firstLen and secondLen.  (For clarification, the firstLen-length subarray could occur before or after the secondLen-length subarray.)

    -

    Formally, return the largest V for which V = (A[i] + A[i+1] + ... + A[i+L-1]) + (A[j] + A[j+1] + ... + A[j+M-1]) and either:

    +

    Formally, return the largest V for which V = (nums[i] + nums[i+1] + ... + nums[i+firstLen-1]) + (nums[j] + nums[j+1] + ... + nums[j+secondLen-1]) and either:

      -
    • 0 <= i < i + L - 1 < j < j + M - 1 < A.length, or
    • -
    • 0 <= j < j + M - 1 < i < i + L - 1 < A.length.
    • +
    • 0 <= i < i + firstLen - 1 < j < j + secondLen - 1 < nums.length, or
    • +
    • 0 <= j < j + secondLen - 1 < i < i + firstLen - 1 < nums.length.

     

    @@ -29,7 +29,7 @@

    Example 1:

    -Input: A = [0,6,5,2,2,5,1,9,4], L = 1, M = 2
    +Input: nums = [0,6,5,2,2,5,1,9,4], firstLen = 1, secondLen = 2
     Output: 20
     Explanation: One choice of subarrays is [9] with length 1, and [6,5] with length 2.
     
    @@ -38,7 +38,7 @@

    Example 2:

    -Input: A = [3,8,1,3,2,1,8,9,0], L = 3, M = 2
    +Input: nums = [3,8,1,3,2,1,8,9,0], firstLen = 3, secondLen = 2
     Output: 29
     Explanation: One choice of subarrays is [3,8,1] with length 3, and [8,9] with length 2.
     
    @@ -47,7 +47,7 @@

    Example 3:

    -Input: A = [2,1,5,6,0,9,5,0,3,8], L = 4, M = 3
    +Input: nums = [2,1,5,6,0,9,5,0,3,8], firstLen = 4, secondLen = 3
     Output: 31
     Explanation: One choice of subarrays is [5,6,0,9] with length 4, and [3,8] with length 3.
     
    @@ -57,10 +57,10 @@

    Note:

      -
    1. L >= 1
    2. -
    3. M >= 1
    4. -
    5. L + M <= A.length <= 1000
    6. -
    7. 0 <= A[i] <= 1000
    8. +
    9. firstLen >= 1
    10. +
    11. secondLen >= 1
    12. +
    13. firstLen + secondLen <= nums.length <= 1000
    14. +
    15. 0 <= nums[i] <= 1000
    diff --git a/problems/maximum-value-after-insertion/README.md b/problems/maximum-value-after-insertion/README.md new file mode 100644 index 000000000..b8c19bb1f --- /dev/null +++ b/problems/maximum-value-after-insertion/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../check-if-word-equals-summation-of-two-words "Check if Word Equals Summation of Two Words") +                 +[Next >](../process-tasks-using-servers "Process Tasks Using Servers") + +## [1881. Maximum Value after Insertion (Medium)](https://leetcode.com/problems/maximum-value-after-insertion "插入后的最大值") + +

    You are given a very large integer n, represented as a string,​​​​​​ and an integer digit x. The digits in n and the digit x are in the inclusive range [1, 9], and n may represent a negative number.

    + +

    You want to maximize n's numerical value by inserting x anywhere in the decimal representation of n​​​​​​. You cannot insert x to the left of the negative sign.

    + +
      +
    • For example, if n = 73 and x = 6, it would be best to insert it between 7 and 3, making n = 763.
    • +
    • If n = -55 and x = 2, it would be best to insert it before the first 5, making n = -255.
    • +
    + +

    Return a string representing the maximum value of n​​​​​​ after the insertion.

    + +

     

    +

    Example 1:

    + +
    +Input: n = "99", x = 9
    +Output: "999"
    +Explanation: The result is the same regardless of where you insert 9.
    +
    + +

    Example 2:

    + +
    +Input: n = "-13", x = 2
    +Output: "-123"
    +Explanation: You can make n one of {-213, -123, -132}, and the largest of those three is -123.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n.length <= 105
    • +
    • 1 <= x <= 9
    • +
    • The digits in n​​​ are in the range [1, 9].
    • +
    • n is a valid representation of an integer.
    • +
    • In the case of a negative n,​​​​​​ it will begin with '-'.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Note that if the number is negative it's the same as positive but you look for the minimum instead. +
    + +
    +Hint 2 +In the case of maximum, if s[i] < x it's optimal that x is put before s[i]. +
    + +
    +Hint 3 +In the case of minimum, if s[i] > x it's optimal that x is put before s[i]. +
    diff --git a/problems/maximum-xor-of-two-numbers-in-an-array/README.md b/problems/maximum-xor-of-two-numbers-in-an-array/README.md index fccd0eb82..210c6453a 100644 --- a/problems/maximum-xor-of-two-numbers-in-an-array/README.md +++ b/problems/maximum-xor-of-two-numbers-in-an-array/README.md @@ -11,9 +11,7 @@ ## [421. Maximum XOR of Two Numbers in an Array (Medium)](https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array "数组中两个数的最大异或值") -

    Given an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 ≤ i ≤ j < n.

    - -

    Follow up: Could you do this in O(n) runtime?

    +

    Given an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n.

     

    Example 1:

    @@ -55,7 +53,7 @@

    Constraints:

      -
    • 1 <= nums.length <= 2 * 104
    • +
    • 1 <= nums.length <= 2 * 105
    • 0 <= nums[i] <= 231 - 1
    diff --git a/problems/merge-intervals/README.md b/problems/merge-intervals/README.md index 364a16562..587507d88 100644 --- a/problems/merge-intervals/README.md +++ b/problems/merge-intervals/README.md @@ -47,7 +47,7 @@ 1. [Insert Interval](../insert-interval) (Medium) 1. [Meeting Rooms](../meeting-rooms) (Easy) 1. [Meeting Rooms II](../meeting-rooms-ii) (Medium) - 1. [Teemo Attacking](../teemo-attacking) (Medium) + 1. [Teemo Attacking](../teemo-attacking) (Easy) 1. [Add Bold Tag in String](../add-bold-tag-in-string) (Medium) 1. [Range Module](../range-module) (Hard) 1. [Employee Free Time](../employee-free-time) (Hard) diff --git a/problems/merge-sorted-array/README.md b/problems/merge-sorted-array/README.md index 95e0e9a6c..4389541cf 100644 --- a/problems/merge-sorted-array/README.md +++ b/problems/merge-sorted-array/README.md @@ -11,18 +11,41 @@ ## [88. Merge Sorted Array (Easy)](https://leetcode.com/problems/merge-sorted-array "合并两个有序数组") -

    Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.

    +

    You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively.

    -

    The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has a size equal to m + n such that it has enough space to hold additional elements from nums2.

    +

    Merge nums1 and nums2 into a single array sorted in non-decreasing order.

    + +

    The final sorted array should not be returned by the function, but instead be stored inside the array nums1. To accommodate this, nums1 has a length of m + n, where the first m elements denote the elements that should be merged, and the last n elements are set to 0 and should be ignored. nums2 has a length of n.

     

    Example 1:

    -
    Input: nums1 = [1,2,3,0,0,0], m = 3, nums2 = [2,5,6], n = 3
    +
    +
    +Input: nums1 = [1,2,3,0,0,0], m = 3, nums2 = [2,5,6], n = 3
     Output: [1,2,2,3,5,6]
    -

    Example 2:

    -
    Input: nums1 = [1], m = 1, nums2 = [], n = 0
    +Explanation: The arrays we are merging are [1,2,3] and [2,5,6].
    +The result of the merge is [1,2,2,3,5,6] with the underlined elements coming from nums1.
    +
    + +

    Example 2:

    + +
    +Input: nums1 = [1], m = 1, nums2 = [], n = 0
     Output: [1]
    +Explanation: The arrays we are merging are [1] and [].
    +The result of the merge is [1].
     
    + +

    Example 3:

    + +
    +Input: nums1 = [0], m = 0, nums2 = [1], n = 1
    +Output: [1]
    +Explanation: The arrays we are merging are [] and [1].
    +The result of the merge is [1].
    +Note that because m = 0, there are no elements in nums1. The 0 is only there to ensure the merge result can fit in nums1.
    +
    +

     

    Constraints:

    @@ -31,11 +54,11 @@
  • nums2.length == n
  • 0 <= m, n <= 200
  • 1 <= m + n <= 200
  • -
  • -109 <= nums1[i], nums2[i] <= 109
  • +
  • -109 <= nums1[i], nums2[j] <= 109
  •  

    -Follow up: Can you come up with an algorithm that runs in O(m + n) time? +

    Follow up: Can you come up with an algorithm that runs in O(m + n) time?

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/minimize-maximum-pair-sum-in-array/README.md b/problems/minimize-maximum-pair-sum-in-array/README.md new file mode 100644 index 000000000..174d6d3d6 --- /dev/null +++ b/problems/minimize-maximum-pair-sum-in-array/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../substrings-of-size-three-with-distinct-characters "Substrings of Size Three with Distinct Characters") +                 +[Next >](../get-biggest-three-rhombus-sums-in-a-grid "Get Biggest Three Rhombus Sums in a Grid") + +## [1877. Minimize Maximum Pair Sum in Array (Medium)](https://leetcode.com/problems/minimize-maximum-pair-sum-in-array "数组中最大数对和的最小值") + +

    The pair sum of a pair (a,b) is equal to a + b. The maximum pair sum is the largest pair sum in a list of pairs.

    + +
      +
    • For example, if we have pairs (1,5), (2,3), and (4,4), the maximum pair sum would be max(1+5, 2+3, 4+4) = max(6, 5, 8) = 8.
    • +
    + +

    Given an array nums of even length n, pair up the elements of nums into n / 2 pairs such that:

    + +
      +
    • Each element of nums is in exactly one pair, and
    • +
    • The maximum pair sum is minimized.
    • +
    + +

    Return the minimized maximum pair sum after optimally pairing up the elements.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [3,5,2,3]
    +Output: 7
    +Explanation: The elements can be paired up into pairs (3,3) and (5,2).
    +The maximum pair sum is max(3+3, 5+2) = max(6, 7) = 7.
    +
    + +

    Example 2:

    + +
    +Input: nums = [3,5,4,2,4,6]
    +Output: 8
    +Explanation: The elements can be paired up into pairs (3,5), (4,4), and (6,2).
    +The maximum pair sum is max(3+5, 4+4, 6+2) = max(8, 8, 8) = 8.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 2 <= n <= 105
    • +
    • n is even.
    • +
    • 1 <= nums[i] <= 105
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Sort](../../tag/sort/README.md)] + +### Hints +
    +Hint 1 +Would sorting help find the optimal order? +
    + +
    +Hint 2 +Given a specific element, how would you minimize its specific pairwise sum? +
    diff --git a/problems/minimize-product-sum-of-two-arrays/README.md b/problems/minimize-product-sum-of-two-arrays/README.md new file mode 100644 index 000000000..5610cec02 --- /dev/null +++ b/problems/minimize-product-sum-of-two-arrays/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../calculate-special-bonus "Calculate Special Bonus") +                 +[Next >](../group-employees-of-the-same-salary "Group Employees of the Same Salary") + +## [1874. Minimize Product Sum of Two Arrays (Medium)](https://leetcode.com/problems/minimize-product-sum-of-two-arrays "") + + + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Is there a particular way we should order the arrays such that the product sum is minimized? +
    + +
    +Hint 2 +Would you want to multiply two numbers that are closer to one another or further? +
    diff --git a/problems/minimum-ascii-delete-sum-for-two-strings/README.md b/problems/minimum-ascii-delete-sum-for-two-strings/README.md index 3418ad60f..824a2cba9 100644 --- a/problems/minimum-ascii-delete-sum-for-two-strings/README.md +++ b/problems/minimum-ascii-delete-sum-for-two-strings/README.md @@ -11,33 +11,38 @@ ## [712. Minimum ASCII Delete Sum for Two Strings (Medium)](https://leetcode.com/problems/minimum-ascii-delete-sum-for-two-strings "两个字符串的最小ASCII删除和") -

    Given two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal.

    +

    Given two strings s1 and s2, return the lowest ASCII sum of deleted characters to make two strings equal.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: s1 = "sea", s2 = "eat"
    -Output: 231
    -Explanation: Deleting "s" from "sea" adds the ASCII value of "s" (115) to the sum.
    -Deleting "t" from "eat" adds 116 to the sum.
    +Input: s1 = "sea", s2 = "eat"
    +Output: 231
    +Explanation: Deleting "s" from "sea" adds the ASCII value of "s" (115) to the sum.
    +Deleting "t" from "eat" adds 116 to the sum.
     At the end, both strings are equal, and 115 + 116 = 231 is the minimum sum possible to achieve this.
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: s1 = "delete", s2 = "leet"
    -Output: 403
    -Explanation: Deleting "dee" from "delete" to turn the string into "let",
    -adds 100[d]+101[e]+101[e] to the sum.  Deleting "e" from "leet" adds 101[e] to the sum.
    -At the end, both strings are equal to "let", and the answer is 100+101+101+101 = 403.
    -If instead we turned both strings into "lee" or "eet", we would get answers of 433 or 417, which are higher.
    +Input: s1 = "delete", s2 = "leet"
    +Output: 403
    +Explanation: Deleting "dee" from "delete" to turn the string into "let",
    +adds 100[d] + 101[e] + 101[e] to the sum.
    +Deleting "e" from "leet" adds 101[e] to the sum.
    +At the end, both strings are equal to "let", and the answer is 100+101+101+101 = 403.
    +If instead we turned both strings into "lee" or "eet", we would get answers of 433 or 417, which are higher.
     
    -

    -

    Note: -

  • 0 < s1.length, s2.length <= 1000.
  • -
  • All elements of each string will have an ASCII value in [97, 122].
  • -

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= s1.length, s2.length <= 1000
    • +
    • s1 and s2 consist of lowercase English letters.
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/minimum-cost-for-tickets/README.md b/problems/minimum-cost-for-tickets/README.md index ef7d3fdc9..9e6b5bfb8 100644 --- a/problems/minimum-cost-for-tickets/README.md +++ b/problems/minimum-cost-for-tickets/README.md @@ -11,60 +11,58 @@ ## [983. Minimum Cost For Tickets (Medium)](https://leetcode.com/problems/minimum-cost-for-tickets "最低票价") -

    In a country popular for train travel, you have planned some train travelling one year in advance.  The days of the year that you will travel is given as an array days.  Each day is an integer from 1 to 365.

    +

    You have planned some train traveling one year in advance. The days of the year in which you will travel are given as an integer array days. Each day is an integer from 1 to 365.

    -

    Train tickets are sold in 3 different ways:

    +

    Train tickets are sold in three different ways:

      -
    • a 1-day pass is sold for costs[0] dollars;
    • -
    • a 7-day pass is sold for costs[1] dollars;
    • -
    • a 30-day pass is sold for costs[2] dollars.
    • +
    • a 1-day pass is sold for costs[0] dollars,
    • +
    • a 7-day pass is sold for costs[1] dollars, and
    • +
    • a 30-day pass is sold for costs[2] dollars.
    -

    The passes allow that many days of consecutive travel.  For example, if we get a 7-day pass on day 2, then we can travel for 7 days: day 2, 3, 4, 5, 6, 7, and 8.

    +

    The passes allow that many days of consecutive travel.

    -

    Return the minimum number of dollars you need to travel every day in the given list of days.

    +
      +
    • For example, if we get a 7-day pass on day 2, then we can travel for 7 days: 2, 3, 4, 5, 6, 7, and 8.
    • +
    -

     

    +

    Return the minimum number of dollars you need to travel every day in the given list of days.

    +

     

    Example 1:

    -Input: days = [1,4,6,7,8,20], costs = [2,7,15]
    -Output: 11
    -Explanation: 
    -For example, here is one way to buy passes that lets you travel your travel plan:
    +Input: days = [1,4,6,7,8,20], costs = [2,7,15]
    +Output: 11
    +Explanation: For example, here is one way to buy passes that lets you travel your travel plan:
     On day 1, you bought a 1-day pass for costs[0] = $2, which covered day 1.
     On day 3, you bought a 7-day pass for costs[1] = $7, which covered days 3, 4, ..., 9.
     On day 20, you bought a 1-day pass for costs[0] = $2, which covered day 20.
    -In total you spent $11 and covered all the days of your travel.
    +In total, you spent $11 and covered all the days of your travel.
     
    -

    Example 2:

    -Input: days = [1,2,3,4,5,6,7,8,9,10,30,31], costs = [2,7,15]
    -Output: 17
    -Explanation: 
    -For example, here is one way to buy passes that lets you travel your travel plan:
    +Input: days = [1,2,3,4,5,6,7,8,9,10,30,31], costs = [2,7,15]
    +Output: 17
    +Explanation: For example, here is one way to buy passes that lets you travel your travel plan:
     On day 1, you bought a 30-day pass for costs[2] = $15 which covered days 1, 2, ..., 30.
     On day 31, you bought a 1-day pass for costs[0] = $2 which covered day 31.
    -In total you spent $17 and covered all the days of your travel.
    +In total, you spent $17 and covered all the days of your travel.
     

     

    -
    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= days.length <= 365
      • 1 <= days[i] <= 365
      • days is in strictly increasing order.
      • costs.length == 3
      • 1 <= costs[i] <= 1000
      • -
    + ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/minimum-cost-to-merge-stones/README.md b/problems/minimum-cost-to-merge-stones/README.md index f249cea94..72606513c 100644 --- a/problems/minimum-cost-to-merge-stones/README.md +++ b/problems/minimum-cost-to-merge-stones/README.md @@ -11,62 +11,53 @@ ## [1000. Minimum Cost to Merge Stones (Hard)](https://leetcode.com/problems/minimum-cost-to-merge-stones "合并石头的最低成本") -

    There are N piles of stones arranged in a row.  The i-th pile has stones[i] stones.

    +

    There are n piles of stones arranged in a row. The ith pile has stones[i] stones.

    -

    A move consists of merging exactly K consecutive piles into one pile, and the cost of this move is equal to the total number of stones in these K piles.

    +

    A move consists of merging exactly k consecutive piles into one pile, and the cost of this move is equal to the total number of stones in these k piles.

    -

    Find the minimum cost to merge all piles of stones into one pile.  If it is impossible, return -1.

    +

    Return the minimum cost to merge all piles of stones into one pile. If it is impossible, return -1.

     

    - -

    Example 1:

    -Input: stones = [3,2,4,1], K = 2
    -Output: 20
    -Explanation: 
    -We start with [3, 2, 4, 1].
    +Input: stones = [3,2,4,1], k = 2
    +Output: 20
    +Explanation: We start with [3, 2, 4, 1].
     We merge [3, 2] for a cost of 5, and we are left with [5, 4, 1].
     We merge [4, 1] for a cost of 5, and we are left with [5, 5].
     We merge [5, 5] for a cost of 10, and we are left with [10].
     The total cost was 20, and this is the minimum possible.
     
    -

    Example 2:

    -Input: stones = [3,2,4,1], K = 3
    -Output: -1
    -Explanation: After any merge operation, there are 2 piles left, and we can't merge anymore.  So the task is impossible.
    +Input: stones = [3,2,4,1], k = 3
    +Output: -1
    +Explanation: After any merge operation, there are 2 piles left, and we can't merge anymore.  So the task is impossible.
     
    -

    Example 3:

    -Input: stones = [3,5,1,2,6], K = 3
    -Output: 25
    -Explanation: 
    -We start with [3, 5, 1, 2, 6].
    +Input: stones = [3,5,1,2,6], k = 3
    +Output: 25
    +Explanation: We start with [3, 5, 1, 2, 6].
     We merge [5, 1, 2] for a cost of 8, and we are left with [3, 8, 6].
     We merge [3, 8, 6] for a cost of 17, and we are left with [17].
     The total cost was 25, and this is the minimum possible.
     

     

    - -

    Note:

    +

    Constraints:

      -
    • 1 <= stones.length <= 30
    • -
    • 2 <= K <= 30
    • -
    • 1 <= stones[i] <= 100
    • +
    • n == stones.length
    • +
    • 1 <= n <= 30
    • +
    • 1 <= stones[i] <= 100
    • +
    • 2 <= k <= 30
    -
    -
    -
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/minimum-domino-rotations-for-equal-row/README.md b/problems/minimum-domino-rotations-for-equal-row/README.md index 6ab0f456d..bd4dc0815 100644 --- a/problems/minimum-domino-rotations-for-equal-row/README.md +++ b/problems/minimum-domino-rotations-for-equal-row/README.md @@ -11,29 +11,29 @@ ## [1007. Minimum Domino Rotations For Equal Row (Medium)](https://leetcode.com/problems/minimum-domino-rotations-for-equal-row "行相等的最少多米诺旋转") -

    In a row of dominoes, A[i] and B[i] represent the top and bottom halves of the ith domino.  (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.)

    +

    In a row of dominoes, tops[i] and bottoms[i] represent the top and bottom halves of the ith domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.)

    -

    We may rotate the ith domino, so that A[i] and B[i] swap values.

    +

    We may rotate the ith domino, so that tops[i] and bottoms[i] swap values.

    -

    Return the minimum number of rotations so that all the values in A are the same, or all the values in B are the same.

    +

    Return the minimum number of rotations so that all the values in tops are the same, or all the values in bottoms are the same.

    If it cannot be done, return -1.

     

    Example 1:

    - +
    -Input: A = [2,1,2,4,2,2], B = [5,2,6,2,3,2]
    +Input: tops = [2,1,2,4,2,2], bottoms = [5,2,6,2,3,2]
     Output: 2
     Explanation: 
    -The first figure represents the dominoes as given by A and B: before we do any rotations.
    +The first figure represents the dominoes as given by tops and bottoms: before we do any rotations.
     If we rotate the second and fourth dominoes, we can make every value in the top row equal to 2, as indicated by the second figure.
     

    Example 2:

    -Input: A = [3,5,1,2,3], B = [3,6,3,3,4]
    +Input: tops = [3,5,1,2,3], bottoms = [3,6,3,3,4]
     Output: -1
     Explanation: 
     In this case, it is not possible to rotate the dominoes to make one row of values equal.
    @@ -43,8 +43,8 @@ In this case, it is not possible to rotate the dominoes to make one row of value
     

    Constraints:

      -
    • 2 <= A.length == B.length <= 2 * 104
    • -
    • 1 <= A[i], B[i] <= 6
    • +
    • 2 <= tops.length == bottoms.length <= 2 * 104
    • +
    • 1 <= tops[i], bottoms[i] <= 6
    ### Related Topics diff --git a/problems/minimum-moves-to-equal-array-elements-ii/README.md b/problems/minimum-moves-to-equal-array-elements-ii/README.md index e5cd49034..341e6ac9b 100644 --- a/problems/minimum-moves-to-equal-array-elements-ii/README.md +++ b/problems/minimum-moves-to-equal-array-elements-ii/README.md @@ -15,6 +15,8 @@

    In one move, you can increment or decrement an element of the array by 1.

    +

    Test cases are designed so that the answer will fit in a 32-bit integer.

    +

     

    Example 1:

    diff --git a/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md b/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md new file mode 100644 index 000000000..3b23c6a24 --- /dev/null +++ b/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md @@ -0,0 +1,65 @@ + + + + + + + +[< Previous](../sum-of-all-subset-xor-totals "Sum of All Subset XOR Totals") +                 +[Next >](../finding-pairs-with-a-certain-sum "Finding Pairs With a Certain Sum") + +## [1864. Minimum Number of Swaps to Make the Binary String Alternating (Medium)](https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating "构成交替字符串需要的最小交换次数") + +

    Given a binary string s, return the minimum number of character swaps to make it alternating, or -1 if it is impossible.

    + +

    The string is called alternating if no two adjacent characters are equal. For example, the strings "010" and "1010" are alternating, while the string "0100" is not.

    + +

    Any two characters may be swapped, even if they are not adjacent.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "111000"
    +Output: 1
    +Explanation: Swap positions 1 and 4: "111000" -> "101010"
    +The string is now alternating.
    +
    + +

    Example 2:

    + +
    +Input: s = "010"
    +Output: 0
    +Explanation: The string is already alternating, no swaps are needed.
    +
    + +

    Example 3:

    + +
    +Input: s = "1110"
    +Output: -1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 1000
    • +
    • s[i] is either '0' or '1'.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Think about all valid strings of length n. +
    + +
    +Hint 2 +Try to count the mismatched positions with each valid string of length n. +
    diff --git a/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md b/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md new file mode 100644 index 000000000..266aff6ac --- /dev/null +++ b/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../process-tasks-using-servers "Process Tasks Using Servers") +                 +Next > + +## [1883. Minimum Skips to Arrive at Meeting On Time (Hard)](https://leetcode.com/problems/minimum-skips-to-arrive-at-meeting-on-time "准时抵达会议现场的最小跳过休息次数") + +

    You are given an integer hoursBefore, the number of hours you have to travel to your meeting. To arrive at your meeting, you have to travel through n roads. The road lengths are given as an integer array dist of length n, where dist[i] describes the length of the ith road in kilometers. In addition, you are given an integer speed, which is the speed (in km/h) you will travel at.

    + +

    After you travel road i, you must rest and wait for the next integer hour before you can begin traveling on the next road. Note that you do not have to rest after traveling the last road because you are already at the meeting.

    + +
      +
    • For example, if traveling a road takes 1.4 hours, you must wait until the 2 hour mark before traveling the next road. If traveling a road takes exactly 2 hours, you do not need to wait.
    • +
    + +

    However, you are allowed to skip some rests to be able to arrive on time, meaning you do not need to wait for the next integer hour. Note that this means you may finish traveling future roads at different hour marks.

    + +
      +
    • For example, suppose traveling the first road takes 1.4 hours and traveling the second road takes 0.6 hours. Skipping the rest after the first road will mean you finish traveling the second road right at the 2 hour mark, letting you start traveling the third road immediately.
    • +
    + +

    Return the minimum number of skips required to arrive at the meeting on time, or -1 if it is impossible.

    + +

     

    +

    Example 1:

    + +
    +Input: dist = [1,3,2], speed = 4, hoursBefore = 2
    +Output: 1
    +Explanation:
    +Without skipping any rests, you will arrive in (1/4 + 3/4) + (3/4 + 1/4) + (2/4) = 2.5 hours.
    +You can skip the first rest to arrive in ((1/4 + 0) + (3/4 + 0)) + (2/4) = 1.5 hours.
    +Note that the second rest is shortened because you finish traveling the second road at an integer hour due to skipping the first rest.
    +
    + +

    Example 2:

    + +
    +Input: dist = [7,3,5,5], speed = 2, hoursBefore = 10
    +Output: 2
    +Explanation:
    +Without skipping any rests, you will arrive in (7/2 + 1/2) + (3/2 + 1/2) + (5/2 + 1/2) + (5/2) = 11.5 hours.
    +You can skip the first and third rest to arrive in ((7/2 + 0) + (3/2 + 0)) + ((5/2 + 0) + (5/2)) = 10 hours.
    +
    + +

    Example 3:

    + +
    +Input: dist = [7,3,5,5], speed = 1, hoursBefore = 10
    +Output: -1
    +Explanation: It is impossible to arrive at the meeting on time even if you skip all the rests.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == dist.length
    • +
    • 1 <= n <= 1000
    • +
    • 1 <= dist[i] <= 105
    • +
    • 1 <= speed <= 106
    • +
    • 1 <= hoursBefore <= 107
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Is there something you can keep track of from one road to another? +
    + +
    +Hint 2 +How would knowing the start time for each state help us solve the problem? +
    diff --git a/problems/minimum-speed-to-arrive-on-time/README.md b/problems/minimum-speed-to-arrive-on-time/README.md new file mode 100644 index 000000000..a0ad00e1f --- /dev/null +++ b/problems/minimum-speed-to-arrive-on-time/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../longer-contiguous-segments-of-ones-than-zeros "Longer Contiguous Segments of Ones than Zeros") +                 +[Next >](../jump-game-vii "Jump Game VII") + +## [1870. Minimum Speed to Arrive on Time (Medium)](https://leetcode.com/problems/minimum-speed-to-arrive-on-time "准时到达的列车最小时速") + +

    You are given a floating-point number hour, representing the amount of time you have to reach the office. To commute to the office, you must take n trains in sequential order. You are also given an integer array dist of length n, where dist[i] describes the distance (in kilometers) of the ith train ride.

    + +

    Each train can only depart at an integer hour, so you may need to wait in between each train ride.

    + +
      +
    • For example, if the 1st train ride takes 1.5 hours, you must wait for an additional 0.5 hours before you can depart on the 2nd train ride at the 2 hour mark.
    • +
    + +

    Return the minimum positive integer speed (in kilometers per hour) that all the trains must travel at for you to reach the office on time, or -1 if it is impossible to be on time.

    + +

    Tests are generated such that the answer will not exceed 107 and hour will have at most two digits after the decimal point.

    + +

     

    +

    Example 1:

    + +
    +Input: dist = [1,3,2], hour = 6
    +Output: 1
    +Explanation: At speed 1:
    +- The first train ride takes 1/1 = 1 hour.
    +- Since we are already at an integer hour, we depart immediately at the 1 hour mark. The second train takes 3/1 = 3 hours.
    +- Since we are already at an integer hour, we depart immediately at the 4 hour mark. The third train takes 2/1 = 2 hours.
    +- You will arrive at exactly the 6 hour mark.
    +
    + +

    Example 2:

    + +
    +Input: dist = [1,3,2], hour = 2.7
    +Output: 3
    +Explanation: At speed 3:
    +- The first train ride takes 1/3 = 0.33333 hours.
    +- Since we are not at an integer hour, we wait until the 1 hour mark to depart. The second train ride takes 3/3 = 1 hour.
    +- Since we are already at an integer hour, we depart immediately at the 2 hour mark. The third train takes 2/3 = 0.66667 hours.
    +- You will arrive at the 2.66667 hour mark.
    +
    + +

    Example 3:

    + +
    +Input: dist = [1,3,2], hour = 1.9
    +Output: -1
    +Explanation: It is impossible because the earliest the third train can depart is at the 2 hour mark.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == dist.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= dist[i] <= 105
    • +
    • 1 <= hour <= 109
    • +
    • There will be at most two digits after the decimal point in hour.
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Given the speed the trains are traveling at, can you find the total time it takes for you to arrive? +
    + +
    +Hint 2 +Is there a cutoff where any speeds larger will always allow you to arrive on time? +
    diff --git a/problems/minimum-window-substring/README.md b/problems/minimum-window-substring/README.md index a617f117b..2fd6fdceb 100644 --- a/problems/minimum-window-substring/README.md +++ b/problems/minimum-window-substring/README.md @@ -11,18 +11,38 @@ ## [76. Minimum Window Substring (Hard)](https://leetcode.com/problems/minimum-window-substring "最小覆盖子串") -

    Given two strings s and t of lengths m and n respectively, return the minimum window in s which will contain all the characters in t. If there is no such window in s that covers all characters in t, return the empty string "".

    +

    Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicates) is included in the window. If there is no such substring, return the empty string "".

    -

    Note that If there is such a window, it is guaranteed that there will always be only one unique minimum window in s.

    +

    The testcases will be generated such that the answer is unique.

    + +

    A substring is a contiguous sequence of characters within the string.

     

    Example 1:

    -
    Input: s = "ADOBECODEBANC", t = "ABC"
    -Output: "BANC"
    -

    Example 2:

    -
    Input: s = "a", t = "a"
    -Output: "a"
    +
    +
    +Input: s = "ADOBECODEBANC", t = "ABC"
    +Output: "BANC"
    +Explanation: The minimum window substring "BANC" includes 'A', 'B', and 'C' from string t.
    +
    + +

    Example 2:

    + +
    +Input: s = "a", t = "a"
    +Output: "a"
    +Explanation: The entire string s is the minimum window.
    +
    + +

    Example 3:

    + +
    +Input: s = "a", t = "aa"
    +Output: ""
    +Explanation: Both 'a's from t must be included in the window.
    +Since the largest window of s only has one 'a', return empty string.
     
    +

     

    Constraints:

    @@ -30,7 +50,7 @@
  • m == s.length
  • n == t.length
  • 1 <= m, n <= 105
  • -
  • s and t consist of English letters.
  • +
  • s and t consist of uppercase and lowercase English letters.
  •  

    diff --git a/problems/minimum-xor-sum-of-two-arrays/README.md b/problems/minimum-xor-sum-of-two-arrays/README.md new file mode 100644 index 000000000..a61323281 --- /dev/null +++ b/problems/minimum-xor-sum-of-two-arrays/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../get-biggest-three-rhombus-sums-in-a-grid "Get Biggest Three Rhombus Sums in a Grid") +                 +[Next >](../check-if-word-equals-summation-of-two-words "Check if Word Equals Summation of Two Words") + +## [1879. Minimum XOR Sum of Two Arrays (Hard)](https://leetcode.com/problems/minimum-xor-sum-of-two-arrays "两个数组最小的异或值之和") + +

    You are given two integer arrays nums1 and nums2 of length n.

    + +

    The XOR sum of the two integer arrays is (nums1[0] XOR nums2[0]) + (nums1[1] XOR nums2[1]) + ... + (nums1[n - 1] XOR nums2[n - 1]) (0-indexed).

    + +
      +
    • For example, the XOR sum of [1,2,3] and [3,2,1] is equal to (1 XOR 3) + (2 XOR 2) + (3 XOR 1) = 2 + 0 + 2 = 4.
    • +
    + +

    Rearrange the elements of nums2 such that the resulting XOR sum is minimized.

    + +

    Return the XOR sum after the rearrangement.

    + +

     

    +

    Example 1:

    + +
    +Input: nums1 = [1,2], nums2 = [2,3]
    +Output: 2
    +Explanation: Rearrange nums2 so that it becomes [3,2].
    +The XOR sum is (1 XOR 3) + (2 XOR 2) = 2 + 0 = 2.
    + +

    Example 2:

    + +
    +Input: nums1 = [1,0,3], nums2 = [5,3,4]
    +Output: 8
    +Explanation: Rearrange nums2 so that it becomes [5,4,3]. 
    +The XOR sum is (1 XOR 5) + (0 XOR 4) + (3 XOR 3) = 4 + 4 + 0 = 8.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums1.length
    • +
    • n == nums2.length
    • +
    • 1 <= n <= 14
    • +
    • 0 <= nums1[i], nums2[i] <= 107
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Since n <= 14, we can consider every subset of nums2. +
    + +
    +Hint 2 +We can represent every subset of nums2 using bitmasks. +
    diff --git a/problems/monotone-increasing-digits/README.md b/problems/monotone-increasing-digits/README.md index 5edcbb4b2..dc313c2d3 100644 --- a/problems/monotone-increasing-digits/README.md +++ b/problems/monotone-increasing-digits/README.md @@ -11,32 +11,38 @@ ## [738. Monotone Increasing Digits (Medium)](https://leetcode.com/problems/monotone-increasing-digits "单调递增的数字") -

    Given a non-negative integer n, find the largest number that is less than or equal to n with monotone increasing digits.

    +

    An integer has monotone increasing digits if and only if each pair of adjacent digits x and y satisfy x <= y.

    -

    (Recall that an integer has monotone increasing digits if and only if each pair of adjacent digits x and y satisfy x <= y.)

    +

    Given an integer n, return the largest number that is less than or equal to n with monotone increasing digits.

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input: n = 10
    -Output: 9
    +Input: n = 10
    +Output: 9
     
    -

    Example 2:

    +

    Example 2:

    -Input: n = 1234
    -Output: 1234
    +Input: n = 1234
    +Output: 1234
     
    -

    Example 3:

    +

    Example 3:

    -Input: n = 332
    -Output: 299
    +Input: n = 332
    +Output: 299
     
    -

    Note: n is an integer in the range [0, 10^9].

    +

     

    +

    Constraints:

    + +
      +
    • 0 <= n <= 109
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/n-ary-tree-level-order-traversal/README.md b/problems/n-ary-tree-level-order-traversal/README.md index 3a518f52e..13928cd40 100644 --- a/problems/n-ary-tree-level-order-traversal/README.md +++ b/problems/n-ary-tree-level-order-traversal/README.md @@ -11,9 +11,9 @@ ## [429. N-ary Tree Level Order Traversal (Medium)](https://leetcode.com/problems/n-ary-tree-level-order-traversal "N 叉树的层序遍历") -

    Given an n-ary tree, return the level order traversal of its nodes' values.

    +

    Given an n-ary tree, return the level order traversal of its nodes' values.

    -

    Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples).

    +

    Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples).

     

    Example 1:

    diff --git a/problems/n-ary-tree-preorder-traversal/README.md b/problems/n-ary-tree-preorder-traversal/README.md index ce13ab0d0..cfefd3582 100644 --- a/problems/n-ary-tree-preorder-traversal/README.md +++ b/problems/n-ary-tree-preorder-traversal/README.md @@ -50,6 +50,6 @@ [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Binary Tree Preorder Traversal](../binary-tree-preorder-traversal) (Medium) + 1. [Binary Tree Preorder Traversal](../binary-tree-preorder-traversal) (Easy) 1. [N-ary Tree Level Order Traversal](../n-ary-tree-level-order-traversal) (Medium) 1. [N-ary Tree Postorder Traversal](../n-ary-tree-postorder-traversal) (Easy) diff --git a/problems/n-queens/README.md b/problems/n-queens/README.md index f11283afb..d7813ecb5 100644 --- a/problems/n-queens/README.md +++ b/problems/n-queens/README.md @@ -13,7 +13,7 @@

    The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other.

    -

    Given an integer n, return all distinct solutions to the n-queens puzzle.

    +

    Given an integer n, return all distinct solutions to the n-queens puzzle. You may return the answer in any order.

    Each solution contains a distinct board configuration of the n-queens' placement, where 'Q' and '.' both indicate a queen and an empty space, respectively.

    diff --git a/problems/not-boring-movies/README.md b/problems/not-boring-movies/README.md index abdd6c9ba..03bf934fa 100644 --- a/problems/not-boring-movies/README.md +++ b/problems/not-boring-movies/README.md @@ -11,33 +11,50 @@ ## [620. Not Boring Movies (Easy)](https://leetcode.com/problems/not-boring-movies "有趣的电影") -X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descriptions. -

    Please write a SQL query to output movies with an odd numbered ID and a description that is not 'boring'. Order the result by rating.

    +

    Table: Cinema

    + +
    ++----------------+----------+
    +| Column Name    | Type     |
    ++----------------+----------+
    +| id             | int      |
    +| movie          | varchar  |
    +| description    | varchar  |
    +| rating         | float    |
    ++----------------+----------+
    +id is the primary key for this table.
    +Each row contains information about the name of a movie, its genre, and its rating.
    +rating is a 2 decimal places float in the range [0, 10]
    +

     

    -

    For example, table cinema:

    +

    Write an SQL query to report the movies with an odd-numbered ID and a description that is not "boring".

    -
    -+---------+-----------+--------------+-----------+
    -|   id    | movie     |  description |  rating   |
    -+---------+-----------+--------------+-----------+
    -|   1     | War       |   great 3D   |   8.9     |
    -|   2     | Science   |   fiction    |   8.5     |
    -|   3     | irish     |   boring     |   6.2     |
    -|   4     | Ice song  |   Fantacy    |   8.6     |
    -|   5     | House card|   Interesting|   9.1     |
    -+---------+-----------+--------------+-----------+
    -
    -For the example above, the output should be: +

    Return the result table in descending order by rating.

    -
    -+---------+-----------+--------------+-----------+
    -|   id    | movie     |  description |  rating   |
    -+---------+-----------+--------------+-----------+
    -|   5     | House card|   Interesting|   9.1     |
    -|   1     | War       |   great 3D   |   8.9     |
    -+---------+-----------+--------------+-----------+
    -
    +

    The query result format is in the following example:

     

    + +
    +Cinema table:
    ++----+------------+-------------+--------+
    +| id | movie      | description | rating |
    ++----+------------+-------------+--------+
    +| 1  | War        | great 3D    | 8.9    |
    +| 2  | Science    | fiction     | 8.5    |
    +| 3  | irish      | boring      | 6.2    |
    +| 4  | Ice song   | Fantacy     | 8.6    |
    +| 5  | House card | Interesting | 9.1    |
    ++----+------------+-------------+--------+
    +
    +Result table:
    ++----+------------+-------------+--------+
    +| id | movie      | description | rating |
    ++----+------------+-------------+--------+
    +| 5  | House card | Interesting | 9.1    |
    +| 1  | War        | great 3D    | 8.9    |
    ++----+------------+-------------+--------+
    +
    +We have three movies with odd-numbered ID: 1, 3, and 5. The movie with ID = 3 is boring so we don't include it in the answer.
    diff --git a/problems/number-of-1-bits/README.md b/problems/number-of-1-bits/README.md index c5a399386..dc25d62d8 100644 --- a/problems/number-of-1-bits/README.md +++ b/problems/number-of-1-bits/README.md @@ -61,7 +61,7 @@ ### Similar Questions 1. [Reverse Bits](../reverse-bits) (Easy) 1. [Power of Two](../power-of-two) (Easy) - 1. [Counting Bits](../counting-bits) (Medium) + 1. [Counting Bits](../counting-bits) (Easy) 1. [Binary Watch](../binary-watch) (Easy) 1. [Hamming Distance](../hamming-distance) (Easy) 1. [Binary Number with Alternating Bits](../binary-number-with-alternating-bits) (Easy) diff --git a/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible/README.md b/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible/README.md new file mode 100644 index 000000000..6bcd7d6c8 --- /dev/null +++ b/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../finding-pairs-with-a-certain-sum "Finding Pairs With a Certain Sum") +                 +[Next >](../orders-with-maximum-quantity-above-average "Orders With Maximum Quantity Above Average") + +## [1866. Number of Ways to Rearrange Sticks With K Sticks Visible (Hard)](https://leetcode.com/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible "恰有 K 根木棍可以看到的排列数目") + +

    There are n uniquely-sized sticks whose lengths are integers from 1 to n. You want to arrange the sticks such that exactly k sticks are visible from the left. A stick is visible from the left if there are no longer sticks to the left of it.

    + +
      +
    • For example, if the sticks are arranged [1,3,2,5,4], then the sticks with lengths 1, 3, and 5 are visible from the left.
    • +
    + +

    Given n and k, return the number of such arrangements. Since the answer may be large, return it modulo 109 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 3, k = 2
    +Output: 3
    +Explanation: [1,3,2], [2,3,1], and [2,1,3] are the only arrangements such that exactly 2 sticks are visible.
    +The visible sticks are underlined.
    +
    + +

    Example 2:

    + +
    +Input: n = 5, k = 5
    +Output: 1
    +Explanation: [1,2,3,4,5] is the only arrangement such that all 5 sticks are visible.
    +The visible sticks are underlined.
    +
    + +

    Example 3:

    + +
    +Input: n = 20, k = 11
    +Output: 647427950
    +Explanation: There are 647427950 (mod 109 + 7) ways to rearrange the sticks such that exactly 11 sticks are visible.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 1000
    • +
    • 1 <= k <= n
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Is there a way to build the solution from a base case? +
    + +
    +Hint 2 +How many ways are there if we fix the position of one stick? +
    diff --git a/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/README.md b/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/README.md index 0ab7b4892..2c012417f 100644 --- a/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/README.md +++ b/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/README.md @@ -11,11 +11,9 @@ ## [1269. Number of Ways to Stay in the Same Place After Some Steps (Hard)](https://leetcode.com/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps "停在原地的方案数") -

    You have a pointer at index 0 in an array of size arrLen. At each step, you can move 1 position to the left, 1 position to the right in the array or stay in the same place  (The pointer should not be placed outside the array at any time).

    +

    You have a pointer at index 0 in an array of size arrLen. At each step, you can move 1 position to the left, 1 position to the right in the array, or stay in the same place (The pointer should not be placed outside the array at any time).

    -

    Given two integers steps and arrLen, return the number of ways such that your pointer still at index 0 after exactly steps steps.

    - -

    Since the answer may be too large, return it modulo 10^9 + 7.

    +

    Given two integers steps and arrLen, return the number of ways such that your pointer still at index 0 after exactly steps steps. Since the answer may be too large, return it modulo 109 + 7.

     

    Example 1:

    @@ -52,7 +50,7 @@ Stay, Stay
    • 1 <= steps <= 500
    • -
    • 1 <= arrLen <= 10^6
    • +
    • 1 <= arrLen <= 106
    ### Related Topics diff --git a/problems/numbers-with-repeated-digits/README.md b/problems/numbers-with-repeated-digits/README.md index 72bbbd957..9de73cb4d 100644 --- a/problems/numbers-with-repeated-digits/README.md +++ b/problems/numbers-with-repeated-digits/README.md @@ -11,7 +11,7 @@ ## [1012. Numbers With Repeated Digits (Hard)](https://leetcode.com/problems/numbers-with-repeated-digits "至少有 1 位重复的数字") -

    Given a positive integer N, return the number of positive integers less than or equal to N that have at least 1 repeated digit.

    +

    Given a positive integer n, return the number of positive integers less than or equal to n that have at least 1 repeated digit.

     

    @@ -19,7 +19,7 @@

    Example 1:

    -Input: 20
    +Input: n = 20
     Output: 1
     Explanation: The only positive number (<= 20) with at least 1 repeated digit is 11.
     
    @@ -28,7 +28,7 @@

    Example 2:

    -Input: 100
    +Input: n = 100
     Output: 10
     Explanation: The positive numbers (<= 100) with atleast 1 repeated digit are 11, 22, 33, 44, 55, 66, 77, 88, 99, and 100.
     
    @@ -37,7 +37,7 @@

    Example 3:

    -Input: 1000
    +Input: n = 1000
     Output: 262
     
    @@ -47,7 +47,7 @@

    Note:

      -
    1. 1 <= N <= 10^9
    2. +
    3. 1 <= n <= 109
    diff --git a/problems/occurrences-after-bigram/README.md b/problems/occurrences-after-bigram/README.md index 71a72d9a5..36e01ea30 100644 --- a/problems/occurrences-after-bigram/README.md +++ b/problems/occurrences-after-bigram/README.md @@ -11,38 +11,28 @@ ## [1078. Occurrences After Bigram (Easy)](https://leetcode.com/problems/occurrences-after-bigram "Bigram 分词") -

    Given words first and second, consider occurrences in some text of the form "first second third", where second comes immediately after first, and third comes immediately after second.

    +

    Given two strings first and second, consider occurrences in some text of the form "first second third", where second comes immediately after first, and third comes immediately after second.

    -

    For each such occurrence, add "third" to the answer, and return the answer.

    +

    Return an array of all the words third for each occurrence of "first second third".

     

    -

    Example 1:

    - -
    -Input: text = "alice is a good girl she is a good student", first = "a", second = "good"
    -Output: ["girl","student"]
    +
    Input: text = "alice is a good girl she is a good student", first = "a", second = "good"
    +Output: ["girl","student"]
    +

    Example 2:

    +
    Input: text = "we will we will rock you", first = "we", second = "will"
    +Output: ["we","rock"]
     
    - -
    -

    Example 2:

    - -
    -Input: text = "we will we will rock you", first = "we", second = "will"
    -Output: ["we","rock"]
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= text.length <= 1000
      • -
      • text consists of space separated words, where each word consists of lowercase English letters.
      • +
      • text consists of lowercase English letters and spaces.
      • +
      • All the words in text a separated by a single space.
      • 1 <= first.length, second.length <= 10
      • first and second consist of lowercase English letters.
      • -
    -
    + ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/orders-with-maximum-quantity-above-average/README.md b/problems/orders-with-maximum-quantity-above-average/README.md new file mode 100644 index 000000000..393ca3884 --- /dev/null +++ b/problems/orders-with-maximum-quantity-above-average/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../number-of-ways-to-rearrange-sticks-with-k-sticks-visible "Number of Ways to Rearrange Sticks With K Sticks Visible") +                 +[Next >](../product-of-two-run-length-encoded-arrays "Product of Two Run-Length Encoded Arrays") + +## [1867. Orders With Maximum Quantity Above Average (Medium)](https://leetcode.com/problems/orders-with-maximum-quantity-above-average "") + + diff --git a/problems/orders-with-maximum-quantity-above-average/mysql_schemas.sql b/problems/orders-with-maximum-quantity-above-average/mysql_schemas.sql new file mode 100644 index 000000000..1e84558f9 --- /dev/null +++ b/problems/orders-with-maximum-quantity-above-average/mysql_schemas.sql @@ -0,0 +1,16 @@ +Create table If Not Exists OrdersDetails (order_id int, product_id int, quantity int); +Truncate table OrdersDetails; +insert into OrdersDetails (order_id, product_id, quantity) values ('1', '1', '12'); +insert into OrdersDetails (order_id, product_id, quantity) values ('1', '2', '10'); +insert into OrdersDetails (order_id, product_id, quantity) values ('1', '3', '15'); +insert into OrdersDetails (order_id, product_id, quantity) values ('2', '1', '8'); +insert into OrdersDetails (order_id, product_id, quantity) values ('2', '4', '4'); +insert into OrdersDetails (order_id, product_id, quantity) values ('2', '5', '6'); +insert into OrdersDetails (order_id, product_id, quantity) values ('3', '3', '5'); +insert into OrdersDetails (order_id, product_id, quantity) values ('3', '4', '18'); +insert into OrdersDetails (order_id, product_id, quantity) values ('4', '5', '2'); +insert into OrdersDetails (order_id, product_id, quantity) values ('4', '6', '8'); +insert into OrdersDetails (order_id, product_id, quantity) values ('5', '7', '9'); +insert into OrdersDetails (order_id, product_id, quantity) values ('5', '8', '9'); +insert into OrdersDetails (order_id, product_id, quantity) values ('3', '9', '20'); +insert into OrdersDetails (order_id, product_id, quantity) values ('2', '9', '4'); diff --git a/problems/pacific-atlantic-water-flow/README.md b/problems/pacific-atlantic-water-flow/README.md index 2c5427e2f..e886a0a69 100644 --- a/problems/pacific-atlantic-water-flow/README.md +++ b/problems/pacific-atlantic-water-flow/README.md @@ -39,7 +39,7 @@
  • m == heights.length
  • n == heights[i].length
  • 1 <= m, n <= 200
  • -
  • 1 <= heights[i][j] <= 105
  • +
  • 0 <= heights[i][j] <= 105
  • ### Related Topics diff --git a/problems/parallel-courses-ii/README.md b/problems/parallel-courses-ii/README.md index 247da8ad5..3fb710e9e 100644 --- a/problems/parallel-courses-ii/README.md +++ b/problems/parallel-courses-ii/README.md @@ -11,11 +11,11 @@ ## [1494. Parallel Courses II (Hard)](https://leetcode.com/problems/parallel-courses-ii "并行课程 II") -

    Given the integer n representing the number of courses at some university labeled from 1 to n, and the array dependencies where dependencies[i] = [xi, yi] represents a prerequisite relationship, that is, the course xi must be taken before the course yi. Also, you are given the integer k.

    +

    You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given an array relations where relations[i] = [prevCoursei, nextCoursei], representing a prerequisite relationship between course prevCoursei and course nextCoursei: course prevCoursei has to be taken before course nextCoursei. Also, you are given the integer k.

    -

    In one semester you can take at most k courses as long as you have taken all the prerequisites for the courses you are taking.

    +

    In one semester, you can take at most k courses as long as you have taken all the prerequisites in the previous semester for the courses you are taking.

    -

    Return the minimum number of semesters to take all courses. It is guaranteed that you can take all courses in some way.

    +

    Return the minimum number of semesters needed to take all courses. The testcases will be generated such that it is possible to take every course.

     

    Example 1:

    @@ -25,7 +25,10 @@
     Input: n = 4, dependencies = [[2,1],[3,1],[1,4]], k = 2
     Output: 3 
    -Explanation: The figure above represents the given graph. In this case we can take courses 2 and 3 in the first semester, then take course 1 in the second semester and finally take course 4 in the third semester.
    +Explanation: The figure above represents the given graph.
    +In the first semester, you can take courses 2 and 3.
    +In the second semester, you can take course 1.
    +In the third semester, you can take course 4.
     

    Example 2:

    @@ -35,7 +38,11 @@
     Input: n = 5, dependencies = [[2,1],[3,1],[4,1],[1,5]], k = 2
     Output: 4 
    -Explanation: The figure above represents the given graph. In this case one optimal way to take all courses is: take courses 2 and 3 in the first semester and take course 4 in the second semester, then take course 1 in the third semester and finally take course 5 in the fourth semester.
    +Explanation: The figure above represents the given graph.
    +In the first semester, you can take courses 2 and 3 only since you cannot take more than two per semester.
    +In the second semester, you can take course 4.
    +In the third semester, you can take course 1.
    +In the fourth semester, you can take course 5.
     

    Example 3:

    @@ -51,11 +58,11 @@
    • 1 <= n <= 15
    • 1 <= k <= n
    • -
    • 0 <= dependencies.length <= n * (n-1) / 2
    • -
    • dependencies[i].length == 2
    • -
    • 1 <= xi, yi <= n
    • -
    • xi != yi
    • -
    • All prerequisite relationships are distinct, that is, dependencies[i] != dependencies[j].
    • +
    • 0 <= relations.length <= n * (n-1) / 2
    • +
    • relations[i].length == 2
    • +
    • 1 <= prevCoursei, nextCoursei <= n
    • +
    • prevCoursei != nextCoursei
    • +
    • All the pairs [prevCoursei, nextCoursei] are unique.
    • The given graph is a directed acyclic graph.
    diff --git a/problems/partition-to-k-equal-sum-subsets/README.md b/problems/partition-to-k-equal-sum-subsets/README.md index 7531de7b2..6ed708539 100644 --- a/problems/partition-to-k-equal-sum-subsets/README.md +++ b/problems/partition-to-k-equal-sum-subsets/README.md @@ -34,7 +34,8 @@
    • 1 <= k <= nums.length <= 16
    • -
    • 0 <= nums[i] <= 104
    • +
    • 1 <= nums[i] <= 104
    • +
    • The frequency of each element is in the range [1, 4].
    ### Related Topics diff --git a/problems/power-of-two/README.md b/problems/power-of-two/README.md index 6ad9597ee..671d41d3f 100644 --- a/problems/power-of-two/README.md +++ b/problems/power-of-two/README.md @@ -9,7 +9,7 @@                  [Next >](../implement-queue-using-stacks "Implement Queue using Stacks") -## [231. Power of Two (Easy)](https://leetcode.com/problems/power-of-two "2的幂") +## [231. Power of Two (Easy)](https://leetcode.com/problems/power-of-two "2 的幂")

    Given an integer n, return true if it is a power of two. Otherwise, return false.

    diff --git a/problems/primary-department-for-each-employee/README.md b/problems/primary-department-for-each-employee/README.md index 6a4594d23..ad2dc5ab6 100644 --- a/problems/primary-department-for-each-employee/README.md +++ b/problems/primary-department-for-each-employee/README.md @@ -9,6 +9,6 @@                  [Next >](../check-if-one-string-swap-can-make-strings-equal "Check if One String Swap Can Make Strings Equal") -## [1789. Primary Department for Each Employee (Easy)](https://leetcode.com/problems/primary-department-for-each-employee "") +## [1789. Primary Department for Each Employee (Easy)](https://leetcode.com/problems/primary-department-for-each-employee "员工的直属部门") diff --git a/problems/print-binary-tree/README.md b/problems/print-binary-tree/README.md index 803337b09..4a624859a 100644 --- a/problems/print-binary-tree/README.md +++ b/problems/print-binary-tree/README.md @@ -11,16 +11,19 @@ ## [655. Print Binary Tree (Medium)](https://leetcode.com/problems/print-binary-tree "输出二叉树") -

    Print a binary tree in an m x n 2D string array following these rules:

    +

    Given the root of a binary tree, construct a 0-indexed m x n string matrix res that represents a formatted layout of the tree. The formatted layout matrix should be constructed using the following rules:

      -
    • The row numbers m should be equal to the height of the given binary tree.
    • -
    • The column number n should always be an odd number.
    • -
    • The root node's value (in string format) should be put in the exact middle of the first row it can be put. The column and the row where the root node belongs will separate the rest space into two parts (left-bottom part and right-bottom part). You should print the left subtree in the left-bottom part and print the right subtree in the right-bottom part. The left-bottom part and the right-bottom part should have the same size. Even if one subtree is none while the other is not, you don't need to print anything for the none subtree but still need to leave the space as large as that for the other subtree. However, if two subtrees are none, then you don't need to leave space for both of them.
    • -
    • Each unused space should contain an empty string "".
    • -
    • Print the subtrees following the same rules.
    • +
    • The height of the tree is height and the number of rows m should be equal to height + 1.
    • +
    • The number of columns n should be equal to 2height+1 - 1.
    • +
    • Place the root node in the middle of the top row (more formally, at location res[0][(n-1)/2]).
    • +
    • For each node that has been placed in the matrix at position res[r][c], place its left child at res[r+1][c-2height-r-1] and its right child at res[r+1][c+2height-r-1].
    • +
    • Continue this process until all the nodes in the tree have been placed.
    • +
    • Any empty cells should contain the empty string "".
    +

    Return the constructed matrix res.

    +

     

    Example 1:

    diff --git a/problems/process-tasks-using-servers/README.md b/problems/process-tasks-using-servers/README.md new file mode 100644 index 000000000..affb20c16 --- /dev/null +++ b/problems/process-tasks-using-servers/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../maximum-value-after-insertion "Maximum Value after Insertion") +                 +[Next >](../minimum-skips-to-arrive-at-meeting-on-time "Minimum Skips to Arrive at Meeting On Time") + +## [1882. Process Tasks Using Servers (Medium)](https://leetcode.com/problems/process-tasks-using-servers "使用服务器处理任务") + +

    You are given two 0-indexed integer arrays servers and tasks of lengths n​​​​​​ and m​​​​​​ respectively. servers[i] is the weight of the i​​​​​​th​​​​ server, and tasks[j] is the time needed to process the j​​​​​​th​​​​ task in seconds.

    + +

    Tasks are assigned to the servers using a task queue. Initially, all servers are free, and the queue is empty.

    + +

    At second j, the jth task is inserted into the queue (starting with the 0th task being inserted at second 0). As long as there are free servers and the queue is not empty, the task in the front of the queue will be assigned to a free server with the smallest weight, and in case of a tie, it is assigned to a free server with the smallest index.

    + +

    If there are no free servers and the queue is not empty, we wait until a server becomes free and immediately assign the next task. If multiple servers become free at the same time, then multiple tasks from the queue will be assigned in order of insertion following the weight and index priorities above.

    + +

    A server that is assigned task j at second t will be free again at second t + tasks[j].

    + +

    Build an array ans​​​​ of length m, where ans[j] is the index of the server the j​​​​​​th task will be assigned to.

    + +

    Return the array ans​​​​.

    + +

     

    +

    Example 1:

    + +
    +Input: servers = [3,3,2], tasks = [1,2,3,2,1,2]
    +Output: [2,2,0,2,1,2]
    +Explanation: Events in chronological order go as follows:
    +- At second 0, task 0 is added and processed using server 2 until second 1.
    +- At second 1, server 2 becomes free. Task 1 is added and processed using server 2 until second 3.
    +- At second 2, task 2 is added and processed using server 0 until second 5.
    +- At second 3, server 2 becomes free. Task 3 is added and processed using server 2 until second 5.
    +- At second 4, task 4 is added and processed using server 1 until second 5.
    +- At second 5, all servers become free. Task 5 is added and processed using server 2 until second 7.
    + +

    Example 2:

    + +
    +Input: servers = [5,1,4,3,2], tasks = [2,1,2,4,5,2,1]
    +Output: [1,4,1,4,1,3,2]
    +Explanation: Events in chronological order go as follows: 
    +- At second 0, task 0 is added and processed using server 1 until second 2.
    +- At second 1, task 1 is added and processed using server 4 until second 2.
    +- At second 2, servers 1 and 4 become free. Task 2 is added and processed using server 1 until second 4. 
    +- At second 3, task 3 is added and processed using server 4 until second 7.
    +- At second 4, server 1 becomes free. Task 4 is added and processed using server 1 until second 9. 
    +- At second 5, task 5 is added and processed using server 3 until second 7.
    +- At second 6, task 6 is added and processed using server 2 until second 7.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • servers.length == n
    • +
    • tasks.length == m
    • +
    • 1 <= n, m <= 2 * 105
    • +
    • 1 <= servers[i], tasks[j] <= 2 * 105
    • +
    + +### Related Topics + [[Heap](../../tag/heap/README.md)] + +### Hints +
    +Hint 1 +You can maintain a Heap of available Servers and a Heap of unavailable servers +
    + +
    +Hint 2 +Note that the tasks will be processed in the input order so you just need to find the x-th server that will be available according to the rules +
    diff --git a/problems/product-of-two-run-length-encoded-arrays/README.md b/problems/product-of-two-run-length-encoded-arrays/README.md new file mode 100644 index 000000000..ddaf7a428 --- /dev/null +++ b/problems/product-of-two-run-length-encoded-arrays/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../orders-with-maximum-quantity-above-average "Orders With Maximum Quantity Above Average") +                 +[Next >](../longer-contiguous-segments-of-ones-than-zeros "Longer Contiguous Segments of Ones than Zeros") + +## [1868. Product of Two Run-Length Encoded Arrays (Medium)](https://leetcode.com/problems/product-of-two-run-length-encoded-arrays "") + + + +### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] + +### Hints +
    +Hint 1 +Keep track of the indices on both RLE arrays and join the parts together. +
    + +
    +Hint 2 +What is the maximum number of segments if we took the minimum number of elements left on both the current segments every time? +
    diff --git a/problems/rearrange-products-table/README.md b/problems/rearrange-products-table/README.md index 160e6e193..9c5ff4cb9 100644 --- a/problems/rearrange-products-table/README.md +++ b/problems/rearrange-products-table/README.md @@ -9,6 +9,6 @@                  [Next >](../second-largest-digit-in-a-string "Second Largest Digit in a String") -## [1795. Rearrange Products Table (Easy)](https://leetcode.com/problems/rearrange-products-table "") +## [1795. Rearrange Products Table (Easy)](https://leetcode.com/problems/rearrange-products-table "每个产品在不同商店的价格") diff --git a/problems/recover-a-tree-from-preorder-traversal/README.md b/problems/recover-a-tree-from-preorder-traversal/README.md index f0b7fabef..9e5bbb461 100644 --- a/problems/recover-a-tree-from-preorder-traversal/README.md +++ b/problems/recover-a-tree-from-preorder-traversal/README.md @@ -17,27 +17,27 @@

    If a node has only one child, that child is guaranteed to be the left child.

    -

    Given the output S of this traversal, recover the tree and return its root.

    +

    Given the output traversal of this traversal, recover the tree and return its root.

     

    Example 1:

    -Input: S = "1-2--3--4-5--6--7"
    +Input: traversal = "1-2--3--4-5--6--7"
     Output: [1,2,5,3,4,6,7]
     

    Example 2:

    -Input: S = "1-2--3---4-5--6---7"
    +Input: traversal = "1-2--3---4-5--6---7"
     Output: [1,2,5,3,null,6,null,4,null,7]
     

    Example 3:

    -Input: S = "1-401--349---90--88"
    +Input: traversal = "1-401--349---90--88"
     Output: [1,401,null,349,88,90]
     
    diff --git a/problems/regions-cut-by-slashes/README.md b/problems/regions-cut-by-slashes/README.md index 920a4ff39..310bbcee9 100644 --- a/problems/regions-cut-by-slashes/README.md +++ b/problems/regions-cut-by-slashes/README.md @@ -11,112 +11,59 @@ ## [959. Regions Cut By Slashes (Medium)](https://leetcode.com/problems/regions-cut-by-slashes "由斜杠划分区域") -

    In a N x N grid composed of 1 x 1 squares, each 1 x 1 square consists of a /, \, or blank space.  These characters divide the square into contiguous regions.

    +

    An n x n grid is composed of 1 x 1 squares where each 1 x 1 square consists of a '/', '\', or blank space ' '. These characters divide the square into contiguous regions.

    -

    (Note that backslash characters are escaped, so a \ is represented as "\\".)

    +

    Given the grid grid represented as a string array, return the number of regions.

    -

    Return the number of regions.

    +

    Note that backslash characters are escaped, so a '\' is represented as '\\'.

     

    - -
    -
    -
    -
    -
    -
      -
    -
    -
    -
    -
    -
    - -

    Example 1:

    - +
    -Input:
    -[
    -  " /",
    -  "/ "
    -]
    -Output: 2
    -Explanation: The 2x2 grid is as follows:
    -
    +Input: grid = [" /","/ "]
    +Output: 2
     
    -

    Example 2:

    - +
    -Input:
    -[
    -  " /",
    -  "  "
    -]
    -Output: 1
    -Explanation: The 2x2 grid is as follows:
    -
    +Input: grid = [" /","  "]
    +Output: 1
     
    -

    Example 3:

    - +
    -Input:
    -[
    -  "\\/",
    -  "/\\"
    -]
    -Output: 4
    +Input: grid = ["\\/","/\\"]
    +Output: 4
     Explanation: (Recall that because \ characters are escaped, "\\/" refers to \/, and "/\\" refers to /\.)
    -The 2x2 grid is as follows:
    -
     
    -

    Example 4:

    - +
    -Input:
    -[
    -  "/\\",
    -  "\\/"
    -]
    -Output: 5
    -Explanation: (Recall that because \ characters are escaped, "/\\" refers to /\, and "\\/" refers to \/.)
    -The 2x2 grid is as follows:
    -
    +Input: grid = ["/\\","\\/"]
    +Output: 5
    +Explanation: (Recall that because \ characters are escaped, "\\/" refers to \/, and "/\\" refers to /\.)
     
    -

    Example 5:

    - +
    -Input:
    -[
    -  "//",
    -  "/ "
    -]
    -Output: 3
    -Explanation: The 2x2 grid is as follows:
    -
    +Input: grid = ["//","/ "]
    +Output: 3
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= grid.length == grid[0].length <= 30
    2. +
        +
      • n == grid.length
      • +
      • n == grid[i].length
      • +
      • 1 <= n <= 30
      • grid[i][j] is either '/', '\', or ' '.
      • -
    -
    -
    -
    -
    -
    + ### Related Topics [[Depth-first Search](../../tag/depth-first-search/README.md)] diff --git a/problems/remove-all-adjacent-duplicates-in-string/README.md b/problems/remove-all-adjacent-duplicates-in-string/README.md index de76aaf58..70c5a36af 100644 --- a/problems/remove-all-adjacent-duplicates-in-string/README.md +++ b/problems/remove-all-adjacent-duplicates-in-string/README.md @@ -11,11 +11,11 @@ ## [1047. Remove All Adjacent Duplicates In String (Easy)](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string "删除字符串中的所有相邻重复项") -

    You are given a string s. A duplicate removal consists of choosing two adjacent and equal letters and removing them.

    +

    You are given a string s consisting of lowercase English letters. A duplicate removal consists of choosing two adjacent and equal letters and removing them.

    We repeatedly make duplicate removals on s until we no longer can.

    -

    Return the final string after all such duplicate removals have been made. It is guaranteed the answer is unique.

    +

    Return the final string after all such duplicate removals have been made. It can be proven that the answer is unique.

     

    Example 1:

    diff --git a/problems/remove-duplicates-from-sorted-array/README.md b/problems/remove-duplicates-from-sorted-array/README.md index 461920620..47d098adc 100644 --- a/problems/remove-duplicates-from-sorted-array/README.md +++ b/problems/remove-duplicates-from-sorted-array/README.md @@ -30,8 +30,9 @@ int len = removeDuplicates(nums); // any modification to nums in your function would be known by the caller. // using the length returned by your function, it prints the first len elements. for (int i = 0; i < len; i++) { -    print(nums[i]); -}
    + print(nums[i]); +} +

     

    Example 1:

    diff --git a/problems/remove-outermost-parentheses/README.md b/problems/remove-outermost-parentheses/README.md index c087df718..72901c984 100644 --- a/problems/remove-outermost-parentheses/README.md +++ b/problems/remove-outermost-parentheses/README.md @@ -13,18 +13,18 @@

    A valid parentheses string is either empty (""), "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatenation.  For example, "", "()", "(())()", and "(()(()))" are all valid parentheses strings.

    -

    A valid parentheses string S is primitive if it is nonempty, and there does not exist a way to split it into S = A+B, with A and B nonempty valid parentheses strings.

    +

    A valid parentheses string s is primitive if it is nonempty, and there does not exist a way to split it into s = A+B, with A and B nonempty valid parentheses strings.

    -

    Given a valid parentheses string S, consider its primitive decomposition: S = P_1 + P_2 + ... + P_k, where P_i are primitive valid parentheses strings.

    +

    Given a valid parentheses string s, consider its primitive decomposition: s = P_1 + P_2 + ... + P_k, where P_i are primitive valid parentheses strings.

    -

    Return S after removing the outermost parentheses of every primitive string in the primitive decomposition of S.

    +

    Return s after removing the outermost parentheses of every primitive string in the primitive decomposition of S.

     

    Example 1:

    -Input: "(()())(())"
    +Input: s = "(()())(())"
     Output: "()()()"
     Explanation: 
     The input string is "(()())(())", with primitive decomposition "(()())" + "(())".
    @@ -35,7 +35,7 @@ After removing outer parentheses of each part, this is "()()" + "
     

    Example 2:

    -Input: "(()())(())(()(()))"
    +Input: s = "(()())(())(()(()))"
     Output: "()()()()(())"
     Explanation: 
     The input string is "(()())(())(()(()))", with primitive decomposition "(()())" + "(())" + "(()(()))".
    @@ -46,7 +46,7 @@ After removing outer parentheses of each part, this is "()()" + "
     

    Example 3:

    -Input: "()()"
    +Input: s = "()()"
     Output: ""
     Explanation: 
     The input string is "()()", with primitive decomposition "()" + "()".
    @@ -60,9 +60,9 @@ After removing outer parentheses of each part, this is "" + "&quo
     

    Note:

      -
    1. S.length <= 10000
    2. -
    3. S[i] is "(" or ")"
    4. -
    5. S is a valid parentheses string
    6. +
    7. s.length <= 10000
    8. +
    9. s[i] is "(" or ")"
    10. +
    11. s is a valid parentheses string
    diff --git a/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md b/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md index 8740e846e..23a90d09d 100644 --- a/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md +++ b/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md @@ -11,34 +11,32 @@ ## [1466. Reorder Routes to Make All Paths Lead to the City Zero (Medium)](https://leetcode.com/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero "重新规划路线") -

    There are n cities numbered from 0 to n-1 and n-1 roads such that there is only one way to travel between two different cities (this network form a tree). Last year, The ministry of transport decided to orient the roads in one direction because they are too narrow.

    +

    There are n cities numbered from 0 to n - 1 and n - 1 roads such that there is only one way to travel between two different cities (this network form a tree). Last year, The ministry of transport decided to orient the roads in one direction because they are too narrow.

    -

    Roads are represented by connections where connections[i] = [a, b] represents a road from city a to b.

    +

    Roads are represented by connections where connections[i] = [ai, bi] represents a road from city ai to city bi.

    -

    This year, there will be a big event in the capital (city 0), and many people want to travel to this city.

    +

    This year, there will be a big event in the capital (city 0), and many people want to travel to this city.

    -

    Your task consists of reorienting some roads such that each city can visit the city 0. Return the minimum number of edges changed.

    +

    Your task consists of reorienting some roads such that each city can visit the city 0. Return the minimum number of edges changed.

    -

    It's guaranteed that each city can reach the city 0 after reorder.

    +

    It's guaranteed that each city can reach city 0 after reorder.

     

    Example 1:

    - -

    - +
     Input: n = 6, connections = [[0,1],[1,3],[2,3],[4,0],[4,5]]
     Output: 3
    -Explanation: Change the direction of edges show in red such that each node can reach the node 0 (capital).
    +Explanation: Change the direction of edges show in red such that each node can reach the node 0 (capital). +

    Example 2:

    - -

    - +
     Input: n = 5, connections = [[1,0],[1,2],[3,2],[3,4]]
     Output: 2
    -Explanation: Change the direction of edges show in red such that each node can reach the node 0 (capital).
    +Explanation: Change the direction of edges show in red such that each node can reach the node 0 (capital). +

    Example 3:

    @@ -51,11 +49,11 @@

    Constraints:

      -
    • 2 <= n <= 5 * 10^4
    • -
    • connections.length == n-1
    • +
    • 2 <= n <= 5 * 104
    • +
    • connections.length == n - 1
    • connections[i].length == 2
    • -
    • 0 <= connections[i][0], connections[i][1] <= n-1
    • -
    • connections[i][0] != connections[i][1]
    • +
    • 0 <= ai, bi <= n - 1
    • +
    • ai != bi
    ### Related Topics diff --git a/problems/restore-ip-addresses/README.md b/problems/restore-ip-addresses/README.md index cb6a583eb..e236a5367 100644 --- a/problems/restore-ip-addresses/README.md +++ b/problems/restore-ip-addresses/README.md @@ -45,4 +45,4 @@ [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions - 1. [IP to CIDR](../ip-to-cidr) (Easy) + 1. [IP to CIDR](../ip-to-cidr) (Medium) diff --git a/problems/reveal-cards-in-increasing-order/README.md b/problems/reveal-cards-in-increasing-order/README.md index 91b50b6a2..b4783978a 100644 --- a/problems/reveal-cards-in-increasing-order/README.md +++ b/problems/reveal-cards-in-increasing-order/README.md @@ -36,7 +36,7 @@ Input: [17,13,11,2,3,5,7] Output: [2,13,3,11,5,17,7] Explanation: -We get the deck in the order [17,13,11,2,3,5,7] (this order doesn't matter), and reorder it. +We get the deck in the order [17,13,11,2,3,5,7] (this order doesn't matter), and reorder it. After reordering, the deck starts as [2,13,3,11,5,17,7], where 2 is the top of the deck. We reveal 2, and move 13 to the bottom. The deck is now [3,11,5,17,7,13]. We reveal 3, and move 11 to the bottom. The deck is now [5,17,7,13,11]. @@ -54,9 +54,9 @@ Since all the cards revealed are in increasing order, the answer is correct.

    Note:

      -
    1. 1 <= A.length <= 1000
    2. -
    3. 1 <= A[i] <= 10^6
    4. -
    5. A[i] != A[j] for all i != j
    6. +
    7. 1 <= deck.length <= 1000
    8. +
    9. 1 <= deck[i] <= 10^6
    10. +
    11. deck[i] != deck[j] for all i != j
    diff --git a/problems/rle-iterator/README.md b/problems/rle-iterator/README.md index 272eb72d3..8533fc735 100644 --- a/problems/rle-iterator/README.md +++ b/problems/rle-iterator/README.md @@ -11,46 +11,50 @@ ## [900. RLE Iterator (Medium)](https://leetcode.com/problems/rle-iterator "RLE 迭代器") -

    Write an iterator that iterates through a run-length encoded sequence.

    +

    We can use run-length encoding (i.e., RLE) to encode a sequence of integers. In a run-length encoded array of even length encoding (0-indexed), for all even i, encoding[i] tells us the number of times that the non-negative integer value encoding[i + 1] is repeated in the sequence.

    -

    The iterator is initialized by RLEIterator(int[] encoding), where encoding is a run-length encoding of some sequence.  More specifically, for all even iencoding[i] tells us the number of times that the non-negative integer value encoding[i+1] is repeated in the sequence.

    +
      +
    • For example, the sequence arr = [8,8,8,5,5] can be encoded to be encoding = [3,8,2,5]. encoding = [3,8,0,9,2,5] and encoding = [2,8,1,8,2,5] are also valid RLE of arr.
    • +
    -

    The iterator supports one function: next(int n), which exhausts the next n elements (n >= 1) and returns the last element exhausted in this way.  If there is no element left to exhaust, next returns -1 instead.

    +

    Given a run-length encoded array, design an iterator that iterates through it.

    -

    For example, we start with encoding = [3,8,0,9,2,5], which is a run-length encoding of the sequence [8,8,8,5,5].  This is because the sequence can be read as "three eights, zero nines, two fives".

    +

    Implement the RLEIterator class:

    -

     

    +
      +
    • RLEIterator(int[] encoded) Initializes the object with the encoded array encoded.
    • +
    • int next(int n) Exhausts the next n elements and returns the last element exhausted in this way. If there is no element left to exhaust, return -1 instead.
    • +
    +

     

    Example 1:

    -Input: ["RLEIterator","next","next","next","next"], [[[3,8,0,9,2,5]],[2],[1],[1],[2]]
    -Output: [null,8,8,5,-1]
    -Explanation: 
    -RLEIterator is initialized with RLEIterator([3,8,0,9,2,5]).
    -This maps to the sequence [8,8,8,5,5].
    -RLEIterator.next is then called 4 times:
    -
    -.next(2) exhausts 2 terms of the sequence, returning 8.  The remaining sequence is now [8, 5, 5].
    -
    -.next(1) exhausts 1 term of the sequence, returning 8.  The remaining sequence is now [5, 5].
    -
    -.next(1) exhausts 1 term of the sequence, returning 5.  The remaining sequence is now [5].
    -
    -.next(2) exhausts 2 terms, returning -1.  This is because the first term exhausted was 5,
    -but the second term did not exist.  Since the last term exhausted does not exist, we return -1.
    -
    +Input
    +["RLEIterator", "next", "next", "next", "next"]
    +[[[3, 8, 0, 9, 2, 5]], [2], [1], [1], [2]]
    +Output
    +[null, 8, 8, 5, -1]
    +
    +Explanation
    +RLEIterator rLEIterator = new RLEIterator([3, 8, 0, 9, 2, 5]); // This maps to the sequence [8,8,8,5,5].
    +rLEIterator.next(2); // exhausts 2 terms of the sequence, returning 8. The remaining sequence is now [8, 5, 5].
    +rLEIterator.next(1); // exhausts 1 term of the sequence, returning 8. The remaining sequence is now [5, 5].
    +rLEIterator.next(1); // exhausts 1 term of the sequence, returning 5. The remaining sequence is now [5].
    +rLEIterator.next(2); // exhausts 2 terms, returning -1. This is because the first term exhausted was 5,
    +but the second term did not exist. Since the last term exhausted does not exist, we return -1.
     
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. 0 <= encoding.length <= 1000
    2. -
    3. encoding.length is an even integer.
    4. +
        +
      • 2 <= encoding.length <= 1000
      • +
      • encoding.length is even.
      • 0 <= encoding[i] <= 109
      • -
      • There are at most 1000 calls to RLEIterator.next(int n) per test case.
      • -
      • Each call to RLEIterator.next(int n) will have 1 <= n <= 109.
      • -
    +
  • 1 <= n <= 109
  • +
  • At most 1000 calls will be made to next.
  • + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/rotate-function/README.md b/problems/rotate-function/README.md index 682e2d0d2..4d60b8e7a 100644 --- a/problems/rotate-function/README.md +++ b/problems/rotate-function/README.md @@ -47,7 +47,7 @@ So the maximum value of F(0), F(1), F(2), F(3) is F(3) = 26.
    • n == nums.length
    • -
    • 1 <= n <= 105
    • +
    • 1 <= n <= 3 * 104
    • -231 <= nums[i] <= 231 - 1
    diff --git a/problems/rotate-image/README.md b/problems/rotate-image/README.md index 3c20d79da..c238417ab 100644 --- a/problems/rotate-image/README.md +++ b/problems/rotate-image/README.md @@ -11,7 +11,7 @@ ## [48. Rotate Image (Medium)](https://leetcode.com/problems/rotate-image "旋转图像") -

    You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise).

    +

    You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise).

    You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.

    diff --git a/problems/rotating-the-box/README.md b/problems/rotating-the-box/README.md new file mode 100644 index 000000000..a086e537e --- /dev/null +++ b/problems/rotating-the-box/README.md @@ -0,0 +1,92 @@ + + + + + + + +[< Previous](../incremental-memory-leak "Incremental Memory Leak") +                 +[Next >](../sum-of-floored-pairs "Sum of Floored Pairs") + +## [1861. Rotating the Box (Medium)](https://leetcode.com/problems/rotating-the-box "旋转盒子") + +

    You are given an m x n matrix of characters box representing a side-view of a box. Each cell of the box is one of the following:

    + +
      +
    • A stone '#'
    • +
    • A stationary obstacle '*'
    • +
    • Empty '.'
    • +
    + +

    The box is rotated 90 degrees clockwise, causing some of the stones to fall due to gravity. Each stone falls down until it lands on an obstacle, another stone, or the bottom of the box. Gravity does not affect the obstacles' positions, and the inertia from the box's rotation does not affect the stones' horizontal positions.

    + +

    It is guaranteed that each stone in box rests on an obstacle, another stone, or the bottom of the box.

    + +

    Return an n x m matrix representing the box after the rotation described above.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: box = [["#",".","#"]]
    +Output: [["."],
    +         ["#"],
    +         ["#"]]
    +
    + +

    Example 2:

    + +

    + +
    +Input: box = [["#",".","*","."],
    +              ["#","#","*","."]]
    +Output: [["#","."],
    +         ["#","#"],
    +         ["*","*"],
    +         [".","."]]
    +
    + +

    Example 3:

    + +

    + +
    +Input: box = [["#","#","*",".","*","."],
    +              ["#","#","#","*",".","."],
    +              ["#","#","#",".","#","."]]
    +Output: [[".","#","#"],
    +         [".","#","#"],
    +         ["#","#","*"],
    +         ["#","*","."],
    +         ["#",".","*"],
    +         ["#",".","."]]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == box.length
    • +
    • n == box[i].length
    • +
    • 1 <= m, n <= 500
    • +
    • box[i][j] is either '#', '*', or '.'.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + +### Hints +
    +Hint 1 +Rotate the box using the relation rotatedBox[i][j] = box[m - 1 - j][i]. +
    + +
    +Hint 2 +Start iterating from the bottom of the box and for each empty cell check if there is any stone above it with no obstacles between them. +
    diff --git a/problems/search-in-rotated-sorted-array-ii/README.md b/problems/search-in-rotated-sorted-array-ii/README.md index c1d27b58c..5e54861d2 100644 --- a/problems/search-in-rotated-sorted-array-ii/README.md +++ b/problems/search-in-rotated-sorted-array-ii/README.md @@ -17,6 +17,8 @@

    Given the array nums after the rotation and an integer target, return true if target is in nums, or false if it is not in nums.

    +

    You must decrease the overall operation steps as much as possible.

    +

     

    Example 1:

    Input: nums = [2,5,6,0,0,1,2], target = 0
    @@ -36,7 +38,7 @@
     
     
     

     

    -Follow up: This problem is the same as Search in Rotated Sorted Array, where nums may contain duplicates. Would this affect the runtime complexity? How and why? +

    Follow up: This problem is similar to Search in Rotated Sorted Array, but nums may contain duplicates. Would this affect the runtime complexity? How and why?

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/self-crossing/README.md b/problems/self-crossing/README.md index 1540d2e0c..d05b7ca32 100644 --- a/problems/self-crossing/README.md +++ b/problems/self-crossing/README.md @@ -43,12 +43,9 @@

    Constraints:

      -
    • 1 <= distance.length <= 500
    • -
    • 1 <= distance[i] <= 500
    • +
    • 1 <= distance.length <= 105
    • +
    • 1 <= distance[i] <= 105
    -

     

    -

    Follow up: Could you write a one-pass algorithm with O(1) extra space?

    - ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/self-dividing-numbers/README.md b/problems/self-dividing-numbers/README.md index 06a6d454a..8f26c17e0 100644 --- a/problems/self-dividing-numbers/README.md +++ b/problems/self-dividing-numbers/README.md @@ -11,26 +11,30 @@ ## [728. Self Dividing Numbers (Easy)](https://leetcode.com/problems/self-dividing-numbers "自除数") -

    -A self-dividing number is a number that is divisible by every digit it contains. -

    -For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0. -

    -Also, a self-dividing number is not allowed to contain the digit zero. -

    -Given a lower and upper number bound, output a list of every possible self dividing number, including the bounds if possible. -

    -

    Example 1:
    -

    -Input: 
    -left = 1, right = 22
    -Output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]
    +

    A self-dividing number is a number that is divisible by every digit it contains.

    + +
      +
    • For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0.
    • +
    + +

    A self-dividing number is not allowed to contain the digit zero.

    + +

    Given two integers left and right, return a list of all the self-dividing numbers in the range [left, right].

    + +

     

    +

    Example 1:

    +
    Input: left = 1, right = 22
    +Output: [1,2,3,4,5,6,7,8,9,11,12,15,22]
    +

    Example 2:

    +
    Input: left = 47, right = 85
    +Output: [48,55,66,77]
     
    -

    +

     

    +

    Constraints:

    -

    Note: -

  • The boundaries of each input argument are 1 <= left <= right <= 10000.
  • -

    +
      +
    • 1 <= left <= right <= 104
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/smallest-integer-divisible-by-k/README.md b/problems/smallest-integer-divisible-by-k/README.md index 54898a3ea..8c9942fa2 100644 --- a/problems/smallest-integer-divisible-by-k/README.md +++ b/problems/smallest-integer-divisible-by-k/README.md @@ -11,42 +11,42 @@ ## [1015. Smallest Integer Divisible by K (Medium)](https://leetcode.com/problems/smallest-integer-divisible-by-k "可被 K 整除的最小整数") -

    Given a positive integer K, you need to find the length of the smallest positive integer N such that N is divisible by K, and N only contains the digit 1.

    +

    Given a positive integer k, you need to find the length of the smallest positive integer n such that n is divisible by k, and n only contains the digit 1.

    -

    Return the length of N. If there is no such N, return -1.

    +

    Return the length of n. If there is no such n, return -1.

    -

    Note: N may not fit in a 64-bit signed integer.

    +

    Note: n may not fit in a 64-bit signed integer.

     

    Example 1:

    -Input: K = 1
    +Input: k = 1
     Output: 1
    -Explanation: The smallest answer is N = 1, which has length 1.
    +Explanation: The smallest answer is n = 1, which has length 1.
     

    Example 2:

    -Input: K = 2
    +Input: k = 2
     Output: -1
    -Explanation: There is no such positive integer N divisible by 2.
    +Explanation: There is no such positive integer n divisible by 2.
     

    Example 3:

    -Input: K = 3
    +Input: k = 3
     Output: 3
    -Explanation: The smallest answer is N = 111, which has length 3.
    +Explanation: The smallest answer is n = 111, which has length 3.
     

     

    Constraints:

      -
    • 1 <= K <= 105
    • +
    • 1 <= k <= 105
    ### Related Topics diff --git a/problems/sorting-the-sentence/README.md b/problems/sorting-the-sentence/README.md new file mode 100644 index 000000000..e6c2f41a6 --- /dev/null +++ b/problems/sorting-the-sentence/README.md @@ -0,0 +1,65 @@ + + + + + + + +[< Previous](../longest-word-with-all-prefixes "Longest Word With All Prefixes") +                 +[Next >](../incremental-memory-leak "Incremental Memory Leak") + +## [1859. Sorting the Sentence (Easy)](https://leetcode.com/problems/sorting-the-sentence "将句子排序") + +

    A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of lowercase and uppercase English letters.

    + +

    A sentence can be shuffled by appending the 1-indexed word position to each word then rearranging the words in the sentence.

    + +
      +
    • For example, the sentence "This is a sentence" can be shuffled as "sentence4 a3 is2 This1" or "is2 sentence4 This1 a3".
    • +
    + +

    Given a shuffled sentence s containing no more than 9 words, reconstruct and return the original sentence.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "is2 sentence4 This1 a3"
    +Output: "This is a sentence"
    +Explanation: Sort the words in s to their original positions "This1 is2 a3 sentence4", then remove the numbers.
    +
    + +

    Example 2:

    + +
    +Input: s = "Myself2 Me1 I4 and3"
    +Output: "Me Myself and I"
    +Explanation: Sort the words in s to their original positions "Me1 Myself2 and3 I4", then remove the numbers.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= s.length <= 200
    • +
    • s consists of lowercase and uppercase English letters, spaces, and digits from 1 to 9.
    • +
    • The number of words in s is between 1 and 9.
    • +
    • The words in s are separated by a single space.
    • +
    • s contains no leading or trailing spaces.
    • +
    + +### Related Topics + [[Sort](../../tag/sort/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Divide the string into the words as an array of strings +
    + +
    +Hint 2 +Sort the words by removing the last character from each word and sorting according to it +
    diff --git a/problems/split-array-into-consecutive-subsequences/README.md b/problems/split-array-into-consecutive-subsequences/README.md index a54202f42..ceb62306b 100644 --- a/problems/split-array-into-consecutive-subsequences/README.md +++ b/problems/split-array-into-consecutive-subsequences/README.md @@ -11,7 +11,18 @@ ## [659. Split Array into Consecutive Subsequences (Medium)](https://leetcode.com/problems/split-array-into-consecutive-subsequences "分割数组为连续子序列") -

    Given an integer array nums that is sorted in ascending order, return true if and only if you can split it into one or more subsequences such that each subsequence consists of consecutive integers and has a length of at least 3.

    +

    You are given an integer array nums that is sorted in non-decreasing order.

    + +

    Determine if it is possible to split nums into one or more subsequences such that both of the following conditions are true:

    + +
      +
    • Each subsequence is a consecutive increasing sequence (i.e. each integer is exactly one more than the previous integer).
    • +
    • All subsequences have a length of 3 or more.
    • +
    + +

    Return true if you can split nums according to the above conditions, or false otherwise.

    + +

    A subsequence of an array is a new array that is formed from the original array by deleting some (can be none) of the elements without disturbing the relative positions of the remaining elements. (i.e., [1,3,5] is a subsequence of [1,2,3,4,5] while [1,3,2] is not).

     

    Example 1:

    @@ -19,10 +30,9 @@
     Input: nums = [1,2,3,3,4,5]
     Output: true
    -Explanation:
    -You can split them into two consecutive subsequences : 
    -1, 2, 3
    -3, 4, 5
    +Explanation: nums can be split into the following subsequences:
    +[1,2,3,3,4,5] --> 1, 2, 3
    +[1,2,3,3,4,5] --> 3, 4, 5
     

    Example 2:

    @@ -30,10 +40,9 @@ You can split them into two consecutive subsequences :
     Input: nums = [1,2,3,3,4,4,5,5]
     Output: true
    -Explanation:
    -You can split them into two consecutive subsequences : 
    -1, 2, 3, 4, 5
    -3, 4, 5
    +Explanation: nums can be split into the following subsequences:
    +[1,2,3,3,4,4,5,5] --> 1, 2, 3, 4, 5
    +[1,2,3,3,4,4,5,5] --> 3, 4, 5
     

    Example 3:

    @@ -41,6 +50,7 @@ You can split them into two consecutive subsequences :
     Input: nums = [1,2,3,4,4,5]
     Output: false
    +Explanation: It is impossible to split nums into consecutive increasing subsequences of length 3 or more.
     

     

    @@ -49,7 +59,7 @@ You can split them into two consecutive subsequences :
    • 1 <= nums.length <= 104
    • -1000 <= nums[i] <= 1000
    • -
    • nums is sorted in an ascending order.
    • +
    • nums is sorted in non-decreasing order.
    ### Related Topics diff --git a/problems/split-array-into-fibonacci-sequence/README.md b/problems/split-array-into-fibonacci-sequence/README.md index 249a895a3..c94dadbf1 100644 --- a/problems/split-array-into-fibonacci-sequence/README.md +++ b/problems/split-array-into-fibonacci-sequence/README.md @@ -11,64 +11,66 @@ ## [842. Split Array into Fibonacci Sequence (Medium)](https://leetcode.com/problems/split-array-into-fibonacci-sequence "将数组拆分成斐波那契序列") -

    Given a string num of digits, such as num = "123456579", we can split it into a Fibonacci-like sequence [123, 456, 579].

    +

    You are given a string of digits num, such as "123456579". We can split it into a Fibonacci-like sequence [123, 456, 579].

    -

    Formally, a Fibonacci-like sequence is a list F of non-negative integers such that:

    +

    Formally, a Fibonacci-like sequence is a list f of non-negative integers such that:

      -
    • 0 <= F[i] <= 2^31 - 1, (that is, each integer fits a 32-bit signed integer type);
    • -
    • F.length >= 3;
    • -
    • and F[i] + F[i+1] = F[i+2] for all 0 <= i < F.length - 2.
    • +
    • 0 <= f[i] < 231, (that is, each integer fits in a 32-bit signed integer type),
    • +
    • f.length >= 3, and
    • +
    • f[i] + f[i + 1] == f[i + 2] for all 0 <= i < f.length - 2.
    -

    Also, note that when splitting the string into pieces, each piece must not have extra leading zeroes, except if the piece is the number 0 itself.

    +

    Note that when splitting the string into pieces, each piece must not have extra leading zeroes, except if the piece is the number 0 itself.

    Return any Fibonacci-like sequence split from num, or return [] if it cannot be done.

    +

     

    Example 1:

    -Input: num = "123456579"
    -Output: [123,456,579]
    +Input: num = "123456579"
    +Output: [123,456,579]
     

    Example 2:

    -Input: num = "11235813"
    -Output: [1,1,2,3,5,8,13]
    +Input: num = "11235813"
    +Output: [1,1,2,3,5,8,13]
     

    Example 3:

    -Input: num = "112358130"
    -Output: []
    -Explanation: The task is impossible.
    +Input: num = "112358130"
    +Output: []
    +Explanation: The task is impossible.
     

    Example 4:

    -Input: num = "0123"
    -Output: []
    -Explanation: Leading zeroes are not allowed, so "01", "2", "3" is not valid.
    +Input: num = "0123"
    +Output: []
    +Explanation: Leading zeroes are not allowed, so "01", "2", "3" is not valid.
     

    Example 5:

    -Input: num = "1101111"
    -Output: [110, 1, 111]
    -Explanation: The output [11, 0, 11, 11] would also be accepted.
    +Input: num = "1101111"
    +Output: [11,0,11,11]
    +Explanation: The output [11, 0, 11, 11] would also be accepted.
     
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. 1 <= num.length <= 200
    2. +
        +
      • 1 <= num.length <= 200
      • num contains only digits.
      • -
    + ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/sqrtx/README.md b/problems/sqrtx/README.md index 2920d7969..6fb4dff4a 100644 --- a/problems/sqrtx/README.md +++ b/problems/sqrtx/README.md @@ -15,6 +15,8 @@

    Since the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned.

    +

    Note: You are not allowed to use any built-in exponent function or operator, such as pow(x, 0.5) or x ** 0.5.

    +

     

    Example 1:

    diff --git a/problems/stone-game-viii/README.md b/problems/stone-game-viii/README.md new file mode 100644 index 000000000..9d33ad575 --- /dev/null +++ b/problems/stone-game-viii/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../jump-game-vii "Jump Game VII") +                 +[Next >](../calculate-special-bonus "Calculate Special Bonus") + +## [1872. Stone Game VIII (Hard)](https://leetcode.com/problems/stone-game-viii "石子游戏 VIII") + +

    Alice and Bob take turns playing a game, with Alice starting first.

    + +

    There are n stones arranged in a row. On each player's turn, while the number of stones is more than one, they will do the following:

    + +
      +
    1. Choose an integer x > 1, and remove the leftmost x stones from the row.
    2. +
    3. Add the sum of the removed stones' values to the player's score.
    4. +
    5. Place a new stone, whose value is equal to that sum, on the left side of the row.
    6. +
    + +

    The game stops when only one stone is left in the row.

    + +

    The score difference between Alice and Bob is (Alice's score - Bob's score). Alice's goal is to maximize the score difference, and Bob's goal is the minimize the score difference.

    + +

    Given an integer array stones of length n where stones[i] represents the value of the ith stone from the left, return the score difference between Alice and Bob if they both play optimally.

    + +

     

    +

    Example 1:

    + +
    +Input: stones = [-1,2,-3,4,-5]
    +Output: 5
    +Explanation:
    +- Alice removes the first 4 stones, adds (-1) + 2 + (-3) + 4 = 2 to her score, and places a stone of
    +  value 2 on the left. stones = [2,-5].
    +- Bob removes the first 2 stones, adds 2 + (-5) = -3 to his score, and places a stone of value -3 on
    +  the left. stones = [-3].
    +The difference between their scores is 2 - (-3) = 5.
    +
    + +

    Example 2:

    + +
    +Input: stones = [7,-6,5,10,5,-2,-6]
    +Output: 13
    +Explanation:
    +- Alice removes all stones, adds 7 + (-6) + 5 + 10 + 5 + (-2) + (-6) = 13 to her score, and places a
    +  stone of value 13 on the left. stones = [13].
    +The difference between their scores is 13 - 0 = 13.
    +
    + +

    Example 3:

    + +
    +Input: stones = [-10,-12]
    +Output: -22
    +Explanation:
    +- Alice can only make one move, which is to remove both stones. She adds (-10) + (-12) = -22 to her
    +  score and places a stone of value -22 on the left. stones = [-22].
    +The difference between their scores is (-22) - 0 = -22.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == stones.length
    • +
    • 2 <= n <= 105
    • +
    • -104 <= stones[i] <= 104
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Let's note that the only thing that matters is how many stones were removed so we can maintain dp[numberOfRemovedStones] +
    + +
    +Hint 2 +dp[x] = max(sum of all elements up to y - dp[y]) for all y > x +
    diff --git a/problems/string-compression/README.md b/problems/string-compression/README.md index ccaefde00..44ad46086 100644 --- a/problems/string-compression/README.md +++ b/problems/string-compression/README.md @@ -68,7 +68,7 @@ You must write an algorithm that uses only constant extra space. [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Count and Say](../count-and-say) (Easy) + 1. [Count and Say](../count-and-say) (Medium) 1. [Encode and Decode Strings](../encode-and-decode-strings) (Medium) 1. [Design Compressed String Iterator](../design-compressed-string-iterator) (Easy) diff --git a/problems/subarray-product-less-than-k/README.md b/problems/subarray-product-less-than-k/README.md index 8c3cb96a0..409a463ac 100644 --- a/problems/subarray-product-less-than-k/README.md +++ b/problems/subarray-product-less-than-k/README.md @@ -11,23 +11,34 @@ ## [713. Subarray Product Less Than K (Medium)](https://leetcode.com/problems/subarray-product-less-than-k "乘积小于K的子数组") -

    Your are given an array of positive integers nums.

    -

    Count and print the number of (contiguous) subarrays where the product of all the elements in the subarray is less than k.

    +

    Given an array of integers nums and an integer k, return the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than k.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: nums = [10, 5, 2, 6], k = 100
    -Output: 8
    -Explanation: The 8 subarrays that have product less than 100 are: [10], [5], [2], [6], [10, 5], [5, 2], [2, 6], [5, 2, 6].
    +Input: nums = [10,5,2,6], k = 100
    +Output: 8
    +Explanation: The 8 subarrays that have product less than 100 are:
    +[10], [5], [2], [6], [10, 5], [5, 2], [2, 6], [5, 2, 6]
     Note that [10, 5, 2] is not included as the product of 100 is not strictly less than k.
     
    -

    -

    Note: -

  • 0 < nums.length <= 50000.
  • -
  • 0 < nums[i] < 1000.
  • -
  • 0 <= k < 10^6.
  • -

    +

    Example 2:

    + +
    +Input: nums = [1,2,3], k = 0
    +Output: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 0 <= nums[i] < 1000
    • +
    • 0 <= k < 106
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/substrings-of-size-three-with-distinct-characters/README.md b/problems/substrings-of-size-three-with-distinct-characters/README.md new file mode 100644 index 000000000..e19e6757d --- /dev/null +++ b/problems/substrings-of-size-three-with-distinct-characters/README.md @@ -0,0 +1,56 @@ + + + + + + + +[< Previous](../group-employees-of-the-same-salary "Group Employees of the Same Salary") +                 +[Next >](../minimize-maximum-pair-sum-in-array "Minimize Maximum Pair Sum in Array") + +## [1876. Substrings of Size Three with Distinct Characters (Easy)](https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters "长度为三且各字符不同的子字符串") + +

    A string is good if there are no repeated characters.

    + +

    Given a string s​​​​​, return the number of good substrings of length three in s​​​​​​.

    + +

    Note that if there are multiple occurrences of the same substring, every occurrence should be counted.

    + +

    A substring is a contiguous sequence of characters in a string.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "xyzzaz"
    +Output: 1
    +Explanation: There are 4 substrings of size 3: "xyz", "yzz", "zza", and "zaz". 
    +The only good substring of length 3 is "xyz".
    +
    + +

    Example 2:

    + +
    +Input: s = "aababcabc"
    +Output: 4
    +Explanation: There are 7 substrings of size 3: "aab", "aba", "bab", "abc", "bca", "cab", and "abc".
    +The good substrings are "abc", "bca", "cab", and "abc".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 100
    • +
    • s​​​​​​ consists of lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Try using a set to find out the number of distinct characters in a substring. +
    diff --git a/problems/subtree-of-another-tree/README.md b/problems/subtree-of-another-tree/README.md index 18dc89855..8c5c5a478 100644 --- a/problems/subtree-of-another-tree/README.md +++ b/problems/subtree-of-another-tree/README.md @@ -26,7 +26,7 @@

    Example 2:

    -Input: root = [3,4,5,1,2,null,null,0], subRoot = [4,1,2]
    +Input: root = [3,4,5,1,2,null,null,null,null,0], subRoot = [4,1,2]
     Output: false
     
    diff --git a/problems/sum-of-all-subset-xor-totals/README.md b/problems/sum-of-all-subset-xor-totals/README.md new file mode 100644 index 000000000..a017f0ec1 --- /dev/null +++ b/problems/sum-of-all-subset-xor-totals/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../sum-of-floored-pairs "Sum of Floored Pairs") +                 +[Next >](../minimum-number-of-swaps-to-make-the-binary-string-alternating "Minimum Number of Swaps to Make the Binary String Alternating") + +## [1863. Sum of All Subset XOR Totals (Easy)](https://leetcode.com/problems/sum-of-all-subset-xor-totals "找出所有子集的异或总和再求和") + +

    The XOR total of an array is defined as the bitwise XOR of all its elements, or 0 if the array is empty.

    + +
      +
    • For example, the XOR total of the array [2,5,6] is 2 XOR 5 XOR 6 = 1.
    • +
    + +

    Given an array nums, return the sum of all XOR totals for every subset of nums

    + +

    Note: Subsets with the same elements should be counted multiple times.

    + +

    An array a is a subset of an array b if a can be obtained from b by deleting some (possibly zero) elements of b.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,3]
    +Output: 6
    +Explanation: The 4 subsets of [1,3] are:
    +- The empty subset has an XOR total of 0.
    +- [1] has an XOR total of 1.
    +- [3] has an XOR total of 3.
    +- [1,3] has an XOR total of 1 XOR 3 = 2.
    +0 + 1 + 3 + 2 = 6
    +
    + +

    Example 2:

    + +
    +Input: nums = [5,1,6]
    +Output: 28
    +Explanation: The 8 subsets of [5,1,6] are:
    +- The empty subset has an XOR total of 0.
    +- [5] has an XOR total of 5.
    +- [1] has an XOR total of 1.
    +- [6] has an XOR total of 6.
    +- [5,1] has an XOR total of 5 XOR 1 = 4.
    +- [5,6] has an XOR total of 5 XOR 6 = 3.
    +- [1,6] has an XOR total of 1 XOR 6 = 7.
    +- [5,1,6] has an XOR total of 5 XOR 1 XOR 6 = 2.
    +0 + 5 + 1 + 6 + 4 + 3 + 7 + 2 = 28
    +
    + +

    Example 3:

    + +
    +Input: nums = [3,4,5,6,7,8]
    +Output: 480
    +Explanation: The sum of all XOR totals for every subset is 480.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 12
    • +
    • 1 <= nums[i] <= 20
    • +
    + +### Related Topics + [[Recursion](../../tag/recursion/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
    +Hint 1 +Is there a way to iterate through all the subsets of the array? +
    + +
    +Hint 2 +Can we use recursion to efficiently iterate through all the subsets? +
    diff --git a/problems/sum-of-floored-pairs/README.md b/problems/sum-of-floored-pairs/README.md new file mode 100644 index 000000000..b152a4003 --- /dev/null +++ b/problems/sum-of-floored-pairs/README.md @@ -0,0 +1,60 @@ + + + + + + + +[< Previous](../rotating-the-box "Rotating the Box") +                 +[Next >](../sum-of-all-subset-xor-totals "Sum of All Subset XOR Totals") + +## [1862. Sum of Floored Pairs (Hard)](https://leetcode.com/problems/sum-of-floored-pairs "向下取整数对和") + +

    Given an integer array nums, return the sum of floor(nums[i] / nums[j]) for all pairs of indices 0 <= i, j < nums.length in the array. Since the answer may be too large, return it modulo 109 + 7.

    + +

    The floor() function returns the integer part of the division.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [2,5,9]
    +Output: 10
    +Explanation:
    +floor(2 / 5) = floor(2 / 9) = floor(5 / 9) = 0
    +floor(2 / 2) = floor(5 / 5) = floor(9 / 9) = 1
    +floor(5 / 2) = 2
    +floor(9 / 2) = 4
    +floor(9 / 5) = 1
    +We calculate the floor of the division for every pair of indices in the array then sum them up.
    +
    + +

    Example 2:

    + +
    +Input: nums = [7,7,7,7,7,7,7]
    +Output: 49
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 105
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Find the frequency (number of occurrences) of all elements in the array. +
    + +
    +Hint 2 +For each element, iterate through its multiples and multiply frequencies to find the answer. +
    diff --git a/problems/teemo-attacking/README.md b/problems/teemo-attacking/README.md index f7908fff3..fe46ccef2 100644 --- a/problems/teemo-attacking/README.md +++ b/problems/teemo-attacking/README.md @@ -9,11 +9,13 @@                  [Next >](../next-greater-element-i "Next Greater Element I") -## [495. Teemo Attacking (Medium)](https://leetcode.com/problems/teemo-attacking "提莫攻击") +## [495. Teemo Attacking (Easy)](https://leetcode.com/problems/teemo-attacking "提莫攻击") -

    You are given an integer array timeSeries and an integer duration. Our hero Teemo has attacked an enemy where the ith attack was done at the timeSeries[i]. When Teemo attacks their enemy, the enemy gets poisoned for duration time (i.e., the enemy is poisoned for the time interval [timeSeries[i], timeSeries[i] + duration - 1] inclusive).

    +

    Our hero Teemo is attacking an enemy Ashe with poison attacks! When Teemo attacks Ashe, Ashe gets poisoned for a exactly duration seconds. More formally, an attack at second t will mean Ashe is poisoned during the inclusive time interval [t, t + duration - 1]. If Teemo attacks again before the poison effect ends, the timer for it is reset, and the poison effect will end duration seconds after the new attack.

    -

    Return the total time that the enemy is in a poisoned condition.

    +

    You are given a non-decreasing integer array timeSeries, where timeSeries[i] denotes that Teemo attacks Ashe at second timeSeries[i], and an integer duration.

    + +

    Return the total number of seconds that Ashe is poisoned.

     

    Example 1:

    @@ -21,10 +23,10 @@
     Input: timeSeries = [1,4], duration = 2
     Output: 4
    -Explanation: At time point 1, Teemo starts attacking the enemy and makes them be poisoned immediately. 
    -This poisoned status will last 2 seconds until the end of time point 2. 
    -And at time point 4, Teemo attacks the enemy again and causes them to be in poisoned status for another 2 seconds. 
    -So you finally need to output 4.
    +Explanation: Teemo's attacks on Ashe go as follows:
    +- At second 1, Teemo attacks, and Ashe is poisoned for seconds 1 and 2.
    +- At second 4, Teemo attacks, and Ashe is poisoned for seconds 4 and 5.
    +Ashe is poisoned for seconds 1, 2, 4, and 5, which is 4 seconds in total.
     

    Example 2:

    @@ -32,12 +34,10 @@ So you finally need to output 4.
     Input: timeSeries = [1,2], duration = 2
     Output: 3
    -Explanation: At time point 1, Teemo starts attacking the enemy and makes them be poisoned. 
    -This poisoned status will last 2 seconds until the end of time point 2. 
    -However, at the beginning of time point 2, Teemo attacks the enemy again who is already in poisoned status. 
    -Since the poisoned status won't add up together, though the second poisoning attack will still work at time point 2, it will stop at the end of time point 3. 
    -So you finally need to output 3.
    -
    +Explanation: Teemo's attacks on Ashe go as follows: +- At second 1, Teemo attacks, and Ashe is poisoned for seconds 1 and 2. +- At second 2 however, Teemo attacks again and resets the poison timer. Ashe is poisoned for seconds 2 and 3. +Ashe is poisoned for seconds 1, 2, and 3, which is 3 seconds in total.

     

    Constraints:

    @@ -45,7 +45,7 @@ So you finally need to output 3.
    • 1 <= timeSeries.length <= 104
    • 0 <= timeSeries[i], duration <= 107
    • -
    • timeSeries is sorted in non-decreasing order.
    • +
    • timeSeries is sorted in non-decreasing order.
    ### Related Topics diff --git a/problems/to-lower-case/README.md b/problems/to-lower-case/README.md index de7ab7125..16573fc70 100644 --- a/problems/to-lower-case/README.md +++ b/problems/to-lower-case/README.md @@ -11,36 +11,37 @@ ## [709. To Lower Case (Easy)](https://leetcode.com/problems/to-lower-case "转换成小写字母") -

    Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.

    +

    Given a string s, return the string after replacing every uppercase letter with the same lowercase letter.

     

    - -

    Example 1:

    -Input: "Hello"
    -Output: "hello"
    +Input: s = "Hello"
    +Output: "hello"
     
    -

    Example 2:

    -Input: "here"
    -Output: "here"
    +Input: s = "here"
    +Output: "here"
     
    -

    Example 3:

    -Input: "LOVELY"
    -Output: "lovely"
    +Input: s = "LOVELY"
    +Output: "lovely"
     
    -
    -
    -
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 100
    • +
    • s consists of printable ASCII characters.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/two-sum-ii-input-array-is-sorted/README.md b/problems/two-sum-ii-input-array-is-sorted/README.md index cbbdebf3f..40afa44a6 100644 --- a/problems/two-sum-ii-input-array-is-sorted/README.md +++ b/problems/two-sum-ii-input-array-is-sorted/README.md @@ -11,11 +11,11 @@ ## [167. Two Sum II - Input array is sorted (Easy)](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted "两数之和 II - 输入有序数组") -

    Given an array of integers numbers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.

    +

    Given an array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number.

    -

    Return the indices of the two numbers (1-indexed) as an integer array answer of size 2, where 1 <= answer[0] < answer[1] <= numbers.length.

    +

    Return the indices of the two numbers (1-indexed) as an integer array answer of size 2, where 1 <= answer[0] < answer[1] <= numbers.length.

    -

    You may assume that each input would have exactly one solution and you may not use the same element twice.

    +

    The tests are generated such that there is exactly one solution. You may not use the same element twice.

     

    Example 1:

    @@ -46,9 +46,9 @@
    • 2 <= numbers.length <= 3 * 104
    • -1000 <= numbers[i] <= 1000
    • -
    • numbers is sorted in increasing order.
    • +
    • numbers is sorted in non-decreasing order.
    • -1000 <= target <= 1000
    • -
    • Only one valid answer exists.
    • +
    • The tests are generated such that there is exactly one solution.
    ### Related Topics diff --git a/problems/two-sum/README.md b/problems/two-sum/README.md index 3a518e534..447a249c4 100644 --- a/problems/two-sum/README.md +++ b/problems/two-sum/README.md @@ -44,12 +44,15 @@

    Constraints:

      -
    • 2 <= nums.length <= 103
    • +
    • 2 <= nums.length <= 104
    • -109 <= nums[i] <= 109
    • -109 <= target <= 109
    • Only one valid answer exists.
    +

     

    +Follow-up: Can you come up with an algorithm that is less than O(n2time complexity? + ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/uncrossed-lines/README.md b/problems/uncrossed-lines/README.md index 8d9366fb0..036421171 100644 --- a/problems/uncrossed-lines/README.md +++ b/problems/uncrossed-lines/README.md @@ -11,12 +11,12 @@ ## [1035. Uncrossed Lines (Medium)](https://leetcode.com/problems/uncrossed-lines "不相交的线") -

    We write the integers of A and B (in the order they are given) on two separate horizontal lines.

    +

    We write the integers of nums1 and nums2 (in the order they are given) on two separate horizontal lines.

    -

    Now, we may draw connecting lines: a straight line connecting two numbers A[i] and B[j] such that:

    +

    Now, we may draw connecting lines: a straight line connecting two numbers nums1[i] and nums2[j] such that:

      -
    • A[i] == B[j];
    • +
    • nums1[i] == nums2[j];
    • The line we draw does not intersect any other connecting (non-horizontal) line.
    @@ -29,17 +29,17 @@

    Example 1:

    -Input: A = [1,4,2], B = [1,2,4]
    +Input: nums1 = [1,4,2], nums2 = [1,2,4]
     Output: 2
     Explanation: We can draw 2 uncrossed lines as in the diagram.
    -We cannot draw 3 uncrossed lines, because the line from A[1]=4 to B[2]=4 will intersect the line from A[2]=2 to B[1]=2.
    +We cannot draw 3 uncrossed lines, because the line from nums1[1]=4 to nums2[2]=4 will intersect the line from nums1[2]=2 to nums2[1]=2.
     

    Example 2:

    -Input: A = [2,5,1,2,5], B = [10,5,2,1,5,2]
    +Input: nums1 = [2,5,1,2,5], nums2 = [10,5,2,1,5,2]
     Output: 3
     
    @@ -47,7 +47,7 @@ We cannot draw 3 uncrossed lines, because the line from A[1]=4 to B[2]=4 will in

    Example 3:

    -Input: A = [1,3,7,1,7,5], B = [1,9,2,5,1]
    +Input: nums1 = [1,3,7,1,7,5], nums2 = [1,9,2,5,1]
     Output: 2

     

    @@ -57,9 +57,9 @@ We cannot draw 3 uncrossed lines, because the line from A[1]=4 to B[2]=4 will in

    Note:

      -
    1. 1 <= A.length <= 500
    2. -
    3. 1 <= B.length <= 500
    4. -
    5. 1 <= A[i], B[i] <= 2000
    6. +
    7. 1 <= nums1.length <= 500
    8. +
    9. 1 <= nums2.length <= 500
    10. +
    11. 1 <= nums1[i], nums2[i] <= 2000
    ### Related Topics diff --git a/problems/valid-number/README.md b/problems/valid-number/README.md index 3425706a8..785f5bd06 100644 --- a/problems/valid-number/README.md +++ b/problems/valid-number/README.md @@ -24,9 +24,9 @@
  • (Optional) A sign character (either '+' or '-').
  • One of the following formats:
      -
    1. At least one digit, followed by a dot '.'.
    2. -
    3. At least one digit, followed by a dot '.', followed by at least one digit.
    4. -
    5. A dot '.', followed by at least one digit.
    6. +
    7. One or more digits, followed by a dot '.'.
    8. +
    9. One or more digits, followed by a dot '.', followed by one or more digits.
    10. +
    11. A dot '.', followed by one or more digits.
  • @@ -35,7 +35,7 @@
    1. (Optional) A sign character (either '+' or '-').
    2. -
    3. At least one digit.
    4. +
    5. One or more digits.

    For example, all the following are valid numbers: ["2", "0089", "-0.1", "+3.14", "4.", "-.9", "2e10", "-90E3", "3e+7", "+6e-1", "53.5e93", "-123.456e789"], while the following are not valid numbers: ["abc", "1a", "1e", "e3", "99e2.5", "--6", "-+3", "95a54e53"].

    diff --git a/problems/valid-tic-tac-toe-state/README.md b/problems/valid-tic-tac-toe-state/README.md index 2a2676003..6915be247 100644 --- a/problems/valid-tic-tac-toe-state/README.md +++ b/problems/valid-tic-tac-toe-state/README.md @@ -11,46 +11,59 @@ ## [794. Valid Tic-Tac-Toe State (Medium)](https://leetcode.com/problems/valid-tic-tac-toe-state "有效的井字游戏") -

    A Tic-Tac-Toe board is given as a string array board. Return True if and only if it is possible to reach this board position during the course of a valid tic-tac-toe game.

    +

    Given a Tic-Tac-Toe board as a string array board, return true if and only if it is possible to reach this board position during the course of a valid tic-tac-toe game.

    -

    The board is a 3 x 3 array, and consists of characters " ", "X", and "O".  The " " character represents an empty square.

    +

    The board is a 3 x 3 array that consists of characters ' ', 'X', and 'O'. The ' ' character represents an empty square.

    Here are the rules of Tic-Tac-Toe:

      -
    • Players take turns placing characters into empty squares (" ").
    • -
    • The first player always places "X" characters, while the second player always places "O" characters.
    • -
    • "X" and "O" characters are always placed into empty squares, never filled ones.
    • -
    • The game ends when there are 3 of the same (non-empty) character filling any row, column, or diagonal.
    • +
    • Players take turns placing characters into empty squares ' '.
    • +
    • The first player always places 'X' characters, while the second player always places 'O' characters.
    • +
    • 'X' and 'O' characters are always placed into empty squares, never filled ones.
    • +
    • The game ends when there are three of the same (non-empty) character filling any row, column, or diagonal.
    • The game also ends if all squares are non-empty.
    • No more moves can be played if the game is over.
    +

     

    +

    Example 1:

    +
    -Example 1:
    -Input: board = ["O  ", "   ", "   "]
    +Input: board = ["O  ","   ","   "]
     Output: false
    -Explanation: The first player always plays "X".
    +Explanation: The first player always plays "X".
    +
    -Example 2: -Input: board = ["XOX", " X ", " "] +

    Example 2:

    + +
    +Input: board = ["XOX"," X ","   "]
     Output: false
    -Explanation: Players take turns making moves.
    +Explanation: Players take turns making moves.
    +
    -Example 3: -Input: board = ["XXX", " ", "OOO"] +

    Example 3:

    + +
    +Input: board = ["XXX","   ","OOO"]
     Output: false
    +
    -Example 4: -Input: board = ["XOX", "O O", "XOX"] +

    Example 4:

    + +
    +Input: board = ["XOX","O O","XOX"]
     Output: true
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • board is a length-3 array of strings, where each string board[i] has length 3.
    • -
    • Each board[i][j] is a character in the set {" ", "X", "O"}.
    • +
    • board.length == 3
    • +
    • board[i].length == 3
    • +
    • board[i][j] is either 'X', 'O', or ' '.
    ### Related Topics diff --git a/problems/validate-ip-address/README.md b/problems/validate-ip-address/README.md index 484430283..9b8f41bc6 100644 --- a/problems/validate-ip-address/README.md +++ b/problems/validate-ip-address/README.md @@ -75,4 +75,4 @@ [[String](../../tag/string/README.md)] ### Similar Questions - 1. [IP to CIDR](../ip-to-cidr) (Easy) + 1. [IP to CIDR](../ip-to-cidr) (Medium) diff --git a/problems/verify-preorder-sequence-in-binary-search-tree/README.md b/problems/verify-preorder-sequence-in-binary-search-tree/README.md index d9506fe3c..fbcd2f24c 100644 --- a/problems/verify-preorder-sequence-in-binary-search-tree/README.md +++ b/problems/verify-preorder-sequence-in-binary-search-tree/README.md @@ -44,4 +44,4 @@ Could you do it using only constant space complexity?

    [[Tree](../../tag/tree/README.md)] ### Similar Questions - 1. [Binary Tree Preorder Traversal](../binary-tree-preorder-traversal) (Medium) + 1. [Binary Tree Preorder Traversal](../binary-tree-preorder-traversal) (Easy) diff --git a/problems/verify-preorder-serialization-of-a-binary-tree/README.md b/problems/verify-preorder-serialization-of-a-binary-tree/README.md index 871ee6ad3..c968d575a 100644 --- a/problems/verify-preorder-serialization-of-a-binary-tree/README.md +++ b/problems/verify-preorder-serialization-of-a-binary-tree/README.md @@ -25,6 +25,8 @@
  • For example, it could never contain two consecutive commas, such as "1,,3".
  • +

    Note: You are not allowed to reconstruct the tree.

    +

     

    Example 1:

    Input: preorder = "9,3,4,#,#,1,#,#,2,#,6,#,#"
    @@ -44,8 +46,5 @@
     	
  • preoder consist of integers in the range [0, 100] and '#' separated by commas ','.
  • -

     

    -

    Follow up: Find an algorithm without reconstructing the tree.

    - ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/video-stitching/README.md b/problems/video-stitching/README.md index 5e0050992..79bb66793 100644 --- a/problems/video-stitching/README.md +++ b/problems/video-stitching/README.md @@ -11,20 +11,25 @@ ## [1024. Video Stitching (Medium)](https://leetcode.com/problems/video-stitching "视频拼接") -

    You are given a series of video clips from a sporting event that lasted T seconds.  These video clips can be overlapping with each other and have varied lengths.

    +

    You are given a series of video clips from a sporting event that lasted time seconds. These video clips can be overlapping with each other and have varying lengths.

    -

    Each video clip clips[i] is an interval: it starts at time clips[i][0] and ends at time clips[i][1].  We can cut these clips into segments freely: for example, a clip [0, 7] can be cut into segments [0, 1] + [1, 3] + [3, 7].

    +

    Each video clip is described by an array clips where clips[i] = [starti, endi] indicates that the ith clip started at starti and ended at endi.

    -

    Return the minimum number of clips needed so that we can cut the clips into segments that cover the entire sporting event ([0, T]).  If the task is impossible, return -1.

    +

    We can cut these clips into segments freely.

    -

     

    +
      +
    • For example, a clip [0, 7] can be cut into segments [0, 1] + [1, 3] + [3, 7].
    • +
    +

    Return the minimum number of clips needed so that we can cut the clips into segments that cover the entire sporting event [0, time]. If the task is impossible, return -1.

    + +

     

    Example 1:

    -Input: clips = [[0,2],[4,6],[8,10],[1,9],[1,5],[5,9]], T = 10
    -Output: 3
    -Explanation: 
    +Input: clips = [[0,2],[4,6],[8,10],[1,9],[1,5],[5,9]], time = 10
    +Output: 3
    +Explanation: 
     We take the clips [0,2], [8,10], [1,9]; a total of 3 clips.
     Then, we can reconstruct the sporting event as follows:
     We cut [1,9] into segments [1,2] + [2,8] + [8,9].
    @@ -34,28 +39,25 @@ Now we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 1
     

    Example 2:

    -Input: clips = [[0,1],[1,2]], T = 5
    -Output: -1
    -Explanation: 
    -We can't cover [0,5] with only [0,1] and [1,2].
    +Input: clips = [[0,1],[1,2]], time = 5
    +Output: -1
    +Explanation: We can't cover [0,5] with only [0,1] and [1,2].
     

    Example 3:

    -Input: clips = [[0,1],[6,8],[0,2],[5,6],[0,4],[0,3],[6,7],[1,3],[4,7],[1,4],[2,5],[2,6],[3,4],[4,5],[5,7],[6,9]], T = 9
    -Output: 3
    -Explanation: 
    -We can take clips [0,4], [4,7], and [6,9].
    +Input: clips = [[0,1],[6,8],[0,2],[5,6],[0,4],[0,3],[6,7],[1,3],[4,7],[1,4],[2,5],[2,6],[3,4],[4,5],[5,7],[6,9]], time = 9
    +Output: 3
    +Explanation: We can take clips [0,4], [4,7], and [6,9].
     

    Example 4:

    -Input: clips = [[0,4],[2,8]], T = 5
    -Output: 2
    -Explanation: 
    -Notice you can have extra video after the event ends.
    +Input: clips = [[0,4],[2,8]], time = 5
    +Output: 2
    +Explanation: Notice you can have extra video after the event ends.
     

     

    @@ -63,8 +65,8 @@ Notice you can have extra video after the event ends.
    • 1 <= clips.length <= 100
    • -
    • 0 <= clips[i][0] <= clips[i][1] <= 100
    • -
    • 0 <= T <= 100
    • +
    • 0 <= clips[i][0] <= clips[i][1] <= 100
    • +
    • 1 <= time <= 100
    ### Related Topics diff --git a/readme/1-300.md b/readme/1-300.md index ca7f91ed4..e172e48be 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -176,7 +176,7 @@ LeetCode Problems' Solutions | 96 | [Unique Binary Search Trees](https://leetcode.com/problems/unique-binary-search-trees "不同的二叉搜索树") | [Go](../problems/unique-binary-search-trees) | Medium | | 97 | [Interleaving String](https://leetcode.com/problems/interleaving-string "交错字符串") | [Go](../problems/interleaving-string) | Medium | | 98 | [Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree "验证二叉搜索树") | [Go](../problems/validate-binary-search-tree) | Medium | -| 99 | [Recover Binary Search Tree](https://leetcode.com/problems/recover-binary-search-tree "恢复二叉搜索树") | [Go](../problems/recover-binary-search-tree) | Hard | +| 99 | [Recover Binary Search Tree](https://leetcode.com/problems/recover-binary-search-tree "恢复二叉搜索树") | [Go](../problems/recover-binary-search-tree) | Medium | | 100 | [Same Tree](https://leetcode.com/problems/same-tree "相同的树") | [Go](../problems/same-tree) | Easy | | 101 | [Symmetric Tree](https://leetcode.com/problems/symmetric-tree "对称二叉树") | [Go](../problems/symmetric-tree) | Easy | | 102 | [Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal "二叉树的层序遍历") | [Go](../problems/binary-tree-level-order-traversal) | Medium | @@ -205,7 +205,7 @@ LeetCode Problems' Solutions | 125 | [Valid Palindrome](https://leetcode.com/problems/valid-palindrome "验证回文串") | [Go](../problems/valid-palindrome) | Easy | | 126 | [Word Ladder II](https://leetcode.com/problems/word-ladder-ii "单词接龙 II") | [Go](../problems/word-ladder-ii) | Hard | | 127 | [Word Ladder](https://leetcode.com/problems/word-ladder "单词接龙") | [Go](../problems/word-ladder) | Hard | -| 128 | [Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence "最长连续序列") | [Go](../problems/longest-consecutive-sequence) | Hard | +| 128 | [Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence "最长连续序列") | [Go](../problems/longest-consecutive-sequence) | Medium | | 129 | [Sum Root to Leaf Numbers](https://leetcode.com/problems/sum-root-to-leaf-numbers "求根节点到叶节点数字之和") | [Go](../problems/sum-root-to-leaf-numbers) | Medium | | 130 | [Surrounded Regions](https://leetcode.com/problems/surrounded-regions "被围绕的区域") | [Go](../problems/surrounded-regions) | Medium | | 131 | [Palindrome Partitioning](https://leetcode.com/problems/palindrome-partitioning "分割回文串") | [Go](../problems/palindrome-partitioning) | Medium | @@ -308,7 +308,7 @@ LeetCode Problems' Solutions | 228 | [Summary Ranges](https://leetcode.com/problems/summary-ranges "汇总区间") | [Go](../problems/summary-ranges) | Easy | | 229 | [Majority Element II](https://leetcode.com/problems/majority-element-ii "求众数 II") | [Go](../problems/majority-element-ii) | Medium | | 230 | [Kth Smallest Element in a BST](https://leetcode.com/problems/kth-smallest-element-in-a-bst "二叉搜索树中第K小的元素") | [Go](../problems/kth-smallest-element-in-a-bst) | Medium | -| 231 | [Power of Two](https://leetcode.com/problems/power-of-two "2的幂") | [Go](../problems/power-of-two) | Easy | +| 231 | [Power of Two](https://leetcode.com/problems/power-of-two "2 的幂") | [Go](../problems/power-of-two) | Easy | | 232 | [Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks "用栈实现队列") | [Go](../problems/implement-queue-using-stacks) | Easy | | 233 | [Number of Digit One](https://leetcode.com/problems/number-of-digit-one "数字 1 的个数") | [Go](../problems/number-of-digit-one) | Hard | | 234 | [Palindrome Linked List](https://leetcode.com/problems/palindrome-linked-list "回文链表") | [Go](../problems/palindrome-linked-list) | Easy | diff --git a/readme/301-600.md b/readme/301-600.md index f0d313bb3..6a4c990ab 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -115,7 +115,7 @@ LeetCode Problems' Solutions | 335 | [Self Crossing](https://leetcode.com/problems/self-crossing "路径交叉") | [Go](../problems/self-crossing) | Hard | | 336 | [Palindrome Pairs](https://leetcode.com/problems/palindrome-pairs "回文对") | [Go](../problems/palindrome-pairs) | Hard | | 337 | [House Robber III](https://leetcode.com/problems/house-robber-iii "打家劫舍 III") | [Go](../problems/house-robber-iii) | Medium | -| 338 | [Counting Bits](https://leetcode.com/problems/counting-bits "比特位计数") | [Go](../problems/counting-bits) | Medium | +| 338 | [Counting Bits](https://leetcode.com/problems/counting-bits "比特位计数") | [Go](../problems/counting-bits) | Easy | | 339 | [Nested List Weight Sum](https://leetcode.com/problems/nested-list-weight-sum "嵌套列表权重和") 🔒 | [Go](../problems/nested-list-weight-sum) | Medium | | 340 | [Longest Substring with At Most K Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters "至多包含 K 个不同字符的最长子串") 🔒 | [Go](../problems/longest-substring-with-at-most-k-distinct-characters) | Medium | | 341 | [Flatten Nested List Iterator](https://leetcode.com/problems/flatten-nested-list-iterator "扁平化嵌套列表迭代器") | [Go](../problems/flatten-nested-list-iterator) | Medium | @@ -157,7 +157,7 @@ LeetCode Problems' Solutions | 377 | [Combination Sum IV](https://leetcode.com/problems/combination-sum-iv "组合总和 Ⅳ") | [Go](../problems/combination-sum-iv) | Medium | | 378 | [Kth Smallest Element in a Sorted Matrix](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix "有序矩阵中第 K 小的元素") | [Go](../problems/kth-smallest-element-in-a-sorted-matrix) | Medium | | 379 | [Design Phone Directory](https://leetcode.com/problems/design-phone-directory "电话目录管理系统") 🔒 | [Go](../problems/design-phone-directory) | Medium | -| 380 | [Insert Delete GetRandom O(1)](https://leetcode.com/problems/insert-delete-getrandom-o1 "常数时间插入、删除和获取随机元素") | [Go](../problems/insert-delete-getrandom-o1) | Medium | +| 380 | [Insert Delete GetRandom O(1)](https://leetcode.com/problems/insert-delete-getrandom-o1 "O(1) 时间插入、删除和获取随机元素") | [Go](../problems/insert-delete-getrandom-o1) | Medium | | 381 | [Insert Delete GetRandom O(1) - Duplicates allowed](https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed "O(1) 时间插入、删除和获取随机元素 - 允许重复") | [Go](../problems/insert-delete-getrandom-o1-duplicates-allowed) | Hard | | 382 | [Linked List Random Node](https://leetcode.com/problems/linked-list-random-node "链表随机节点") | [Go](../problems/linked-list-random-node) | Medium | | 383 | [Ransom Note](https://leetcode.com/problems/ransom-note "赎金信") | [Go](../problems/ransom-note) | Easy | @@ -272,7 +272,7 @@ LeetCode Problems' Solutions | 492 | [Construct the Rectangle](https://leetcode.com/problems/construct-the-rectangle "构造矩形") | [Go](../problems/construct-the-rectangle) | Easy | | 493 | [Reverse Pairs](https://leetcode.com/problems/reverse-pairs "翻转对") | [Go](../problems/reverse-pairs) | Hard | | 494 | [Target Sum](https://leetcode.com/problems/target-sum "目标和") | [Go](../problems/target-sum) | Medium | -| 495 | [Teemo Attacking](https://leetcode.com/problems/teemo-attacking "提莫攻击") | [Go](../problems/teemo-attacking) | Medium | +| 495 | [Teemo Attacking](https://leetcode.com/problems/teemo-attacking "提莫攻击") | [Go](../problems/teemo-attacking) | Easy | | 496 | [Next Greater Element I](https://leetcode.com/problems/next-greater-element-i "下一个更大元素 I") | [Go](../problems/next-greater-element-i) | Easy | | 497 | [Random Point in Non-overlapping Rectangles](https://leetcode.com/problems/random-point-in-non-overlapping-rectangles "非重叠矩形中的随机点") | [Go](../problems/random-point-in-non-overlapping-rectangles) | Medium | | 498 | [Diagonal Traverse](https://leetcode.com/problems/diagonal-traverse "对角线遍历") | [Go](../problems/diagonal-traverse) | Medium | diff --git a/readme/601-900.md b/readme/601-900.md index 29b14e0aa..224e1fdc0 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -235,7 +235,7 @@ LeetCode Problems' Solutions | 755 | [Pour Water](https://leetcode.com/problems/pour-water "倒水") 🔒 | [Go](../problems/pour-water) | Medium | | 756 | [Pyramid Transition Matrix](https://leetcode.com/problems/pyramid-transition-matrix "金字塔转换矩阵") | [Go](../problems/pyramid-transition-matrix) | Medium | | 757 | [Set Intersection Size At Least Two](https://leetcode.com/problems/set-intersection-size-at-least-two "设置交集大小至少为2") | [Go](../problems/set-intersection-size-at-least-two) | Hard | -| 758 | [Bold Words in String](https://leetcode.com/problems/bold-words-in-string "字符串中的加粗单词") 🔒 | [Go](../problems/bold-words-in-string) | Easy | +| 758 | [Bold Words in String](https://leetcode.com/problems/bold-words-in-string "字符串中的加粗单词") 🔒 | [Go](../problems/bold-words-in-string) | Medium | | 759 | [Employee Free Time](https://leetcode.com/problems/employee-free-time "员工空闲时间") 🔒 | [Go](../problems/employee-free-time) | Hard | | 760 | [Find Anagram Mappings](https://leetcode.com/problems/find-anagram-mappings "找出变位映射") 🔒 | [Go](../problems/find-anagram-mappings) | Easy | | 761 | [Special Binary String](https://leetcode.com/problems/special-binary-string "特殊的二进制序列") | [Go](../problems/special-binary-string) | Hard | diff --git a/tag/README.md b/tag/README.md index 8dd94dc0a..2b803ccaa 100644 --- a/tag/README.md +++ b/tag/README.md @@ -11,20 +11,20 @@ | :-: | - | :-: | - | :-: | - | :-: | | 1 | [Array](array/README.md) | [数组](https://openset.github.io/tags/array/) | | 2 | [Dynamic Programming](dynamic-programming/README.md) | [动态规划](https://openset.github.io/tags/dynamic-programming/) | | 3 | [String](string/README.md) | [字符串](https://openset.github.io/tags/string/) | | 4 | [Math](math/README.md) | [数学](https://openset.github.io/tags/math/) | -| 5 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 6 | [Tree](tree/README.md) | [树](https://openset.github.io/tags/tree/) | -| 7 | [Depth-first Search](depth-first-search/README.md) | [深度优先搜索](https://openset.github.io/tags/depth-first-search/) | | 8 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | +| 5 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 6 | [Depth-first Search](depth-first-search/README.md) | [深度优先搜索](https://openset.github.io/tags/depth-first-search/) | +| 7 | [Tree](tree/README.md) | [树](https://openset.github.io/tags/tree/) | | 8 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | | 9 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | | 11 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | -| 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | -| 15 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | +| 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | +| 15 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 19 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | | 20 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | | 21 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | | 22 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | | 23 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | -| 25 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 26 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | +| 25 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | | 26 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 27 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | -| 29 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | | 30 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | -| 31 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 32 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | +| 29 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | +| 31 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 32 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 33 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | | 34 | [Dequeue](dequeue/README.md) | [Dequeue](https://openset.github.io/tags/dequeue/) | | 35 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 36 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | | 37 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | | 38 | [Suffix Array](suffix-array/README.md) | [Suffix Array](https://openset.github.io/tags/suffix-array/) | diff --git a/tag/array/README.md b/tag/array/README.md index 2673a153a..62a5fd5d4 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,12 +9,15 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1878 | [矩阵中最大的三个菱形和](../../problems/get-biggest-three-rhombus-sums-in-a-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1869 | [哪种连续子字符串更长](../../problems/longer-contiguous-segments-of-ones-than-zeros) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1861 | [旋转盒子](../../problems/rotating-the-box) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1854 | [人口最多的年份](../../problems/maximum-population-year) | [[数组](../array/README.md)] | Easy | -| 1852 | [Distinct Numbers in Each Subarray](../../problems/distinct-numbers-in-each-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1852 | [Distinct Numbers in Each Subarray](../../problems/distinct-numbers-in-each-subarray) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | | 1848 | [到目标元素的最小距离](../../problems/minimum-distance-to-the-target-element) | [[数组](../array/README.md)] | Easy | | 1833 | [雪糕的最大数量](../../problems/maximum-ice-cream-bars) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | | 1827 | [最少操作使数组递增](../../problems/minimum-operations-to-make-the-array-increasing) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 1826 | [Faulty Sensor](../../problems/faulty-sensor) 🔒 | [[数组](../array/README.md)] | Easy | +| 1826 | [有缺陷的传感器](../../problems/faulty-sensor) 🔒 | [[数组](../array/README.md)] | Easy | | 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[数组](../array/README.md)] | Medium | | 1814 | [统计一个数组中好对子的数目](../../problems/count-nice-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1806 | [还原排列的最少操作步数](../../problems/minimum-number-of-operations-to-reinitialize-a-permutation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | @@ -248,14 +251,14 @@ | 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 531 | [孤独像素 I](../../problems/lonely-pixel-i) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 509 | [斐波那契数](../../problems/fibonacci-number) | [[数组](../array/README.md)] | Easy | -| 495 | [提莫攻击](../../problems/teemo-attacking) | [[数组](../array/README.md)] | Medium | +| 495 | [提莫攻击](../../problems/teemo-attacking) | [[数组](../array/README.md)] | Easy | | 485 | [最大连续 1 的个数](../../problems/max-consecutive-ones) | [[数组](../array/README.md)] | Easy | | 457 | [环形数组是否存在循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 448 | [找到所有数组中消失的数字](../../problems/find-all-numbers-disappeared-in-an-array) | [[数组](../array/README.md)] | Easy | | 442 | [数组中重复的数据](../../problems/find-all-duplicates-in-an-array) | [[数组](../array/README.md)] | Medium | | 414 | [第三大的数](../../problems/third-maximum-number) | [[数组](../array/README.md)] | Easy | | 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 380 | [O(1) 时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 370 | [区间加法](../../problems/range-addition) 🔒 | [[数组](../array/README.md)] | Medium | | 289 | [生命游戏](../../problems/game-of-life) | [[数组](../array/README.md)] | Medium | | 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -281,7 +284,7 @@ | 154 | [寻找旋转排序数组中的最小值 II](../../problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 152 | [乘积最大子数组](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 128 | [最长连续序列](../../problems/longest-consecutive-sequence) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Hard | +| 128 | [最长连续序列](../../problems/longest-consecutive-sequence) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | | 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 123 | [买卖股票的最佳时机 III](../../problems/best-time-to-buy-and-sell-stock-iii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 4ae003998..72edab524 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1863 | [找出所有子集的异或总和再求和](../../problems/sum-of-all-subset-xor-totals) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | | 1849 | [将字符串拆分为递减的连续值](../../problems/splitting-a-string-into-descending-consecutive-values) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 102b33019..f5ffd28c2 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1884 | [鸡蛋掉落-两枚鸡蛋](../../problems/egg-drop-with-2-eggs-and-n-floors) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1870 | [准时到达的列车最小时速](../../problems/minimum-speed-to-arrive-on-time) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1855 | [下标对中的最大距离](../../problems/maximum-distance-between-a-pair-of-values) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1847 | [最近的房间](../../problems/closest-room) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] | Hard | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index ec9ec8f71..bb2ef92f5 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1879 | [两个数组最小的异或值之和](../../problems/minimum-xor-sum-of-two-arrays) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1837 | [K 进制表示下的各位数字总和](../../problems/sum-of-digits-in-base-k) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | | 1829 | [每个查询的最大异或值](../../problems/maximum-xor-for-each-query) | [[位运算](../bit-manipulation/README.md)] | Medium | | 1734 | [解码异或后的排列](../../problems/decode-xored-permutation) | [[位运算](../bit-manipulation/README.md)] | Medium | @@ -40,7 +41,7 @@ | 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 762 | [二进制表示中质数个计算置位](../../problems/prime-number-of-set-bits-in-binary-representation) | [[位运算](../bit-manipulation/README.md)] | Easy | | 756 | [金字塔转换矩阵](../../problems/pyramid-transition-matrix) | [[位运算](../bit-manipulation/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 751 | [IP 到 CIDR](../../problems/ip-to-cidr) 🔒 | [[位运算](../bit-manipulation/README.md)] | Easy | +| 751 | [IP 到 CIDR](../../problems/ip-to-cidr) 🔒 | [[位运算](../bit-manipulation/README.md)] | Medium | | 693 | [交替位二进制数](../../problems/binary-number-with-alternating-bits) | [[位运算](../bit-manipulation/README.md)] | Easy | | 477 | [汉明距离总和](../../problems/total-hamming-distance) | [[位运算](../bit-manipulation/README.md)] | Medium | | 476 | [数字的补数](../../problems/number-complement) | [[位运算](../bit-manipulation/README.md)] | Easy | @@ -54,12 +55,12 @@ | 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 371 | [两整数之和](../../problems/sum-of-two-integers) | [[位运算](../bit-manipulation/README.md)] | Medium | | 342 | [4的幂](../../problems/power-of-four) | [[位运算](../bit-manipulation/README.md)] | Easy | -| 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 318 | [最大单词长度乘积](../../problems/maximum-product-of-word-lengths) | [[位运算](../bit-manipulation/README.md)] | Medium | | 268 | [丢失的数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 260 | [只出现一次的数字 III](../../problems/single-number-iii) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 231 | [2的幂](../../problems/power-of-two) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | +| 231 | [2 的幂](../../problems/power-of-two) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | | 201 | [数字范围按位与](../../problems/bitwise-and-of-numbers-range) | [[位运算](../bit-manipulation/README.md)] | Medium | | 191 | [位1的个数](../../problems/number-of-1-bits) | [[位运算](../bit-manipulation/README.md)] | Easy | | 190 | [颠倒二进制位](../../problems/reverse-bits) | [[位运算](../bit-manipulation/README.md)] | Easy | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 26c91c7d2..1cba20a33 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1871 | [跳跃游戏 VII](../../problems/jump-game-vii) | [[贪心算法](../greedy/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | | 1824 | [最少侧跳次数](../../problems/minimum-sideway-jumps) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 29421748c..e49a070f6 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1858 | [Longest Word With All Prefixes](../../problems/longest-word-with-all-prefixes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/design/README.md b/tag/design/README.md index 58be112e6..eb84527c3 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1865 | [找出和为指定值的下标对](../../problems/finding-pairs-with-a-certain-sum) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | | 1845 | [座位预约管理系统](../../problems/seat-reservation-manager) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Medium | | 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] | Hard | | 1797 | [设计一个验证系统](../../problems/design-authentication-manager) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | @@ -48,7 +49,7 @@ | 460 | [LFU 缓存](../../problems/lfu-cache) | [[设计](../design/README.md)] | Hard | | 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] | Hard | | 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 380 | [O(1) 时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | | 362 | [敲击计数器](../../problems/design-hit-counter) 🔒 | [[设计](../design/README.md)] | Medium | | 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 7aee962cb..81d350e32 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1884 | [鸡蛋掉落-两枚鸡蛋](../../problems/egg-drop-with-2-eggs-and-n-floors) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1883 | [准时抵达会议现场的最小跳过休息次数](../../problems/minimum-skips-to-arrive-at-meeting-on-time) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1879 | [两个数组最小的异或值之和](../../problems/minimum-xor-sum-of-two-arrays) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1872 | [石子游戏 VIII](../../problems/stone-game-viii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1866 | [恰有 K 根木棍可以看到的排列数目](../../problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1824 | [最少侧跳次数](../../problems/minimum-sideway-jumps) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -49,7 +54,7 @@ | 1553 | [吃掉 N 个橘子的最少天数](../../problems/minimum-number-of-days-to-eat-n-oranges) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1548 | [图中最相似的路径](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1547 | [切棍子的最小成本](../../problems/minimum-cost-to-cut-a-stick) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1546 | [和为目标值的最大数目不重叠非空子数组数目](../../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1546 | [和为目标值且不重叠的非空子数组的最大数目](../../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 1537 | [最大得分](../../problems/get-the-maximum-score) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1510 | [石子游戏 IV](../../problems/stone-game-iv) | [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -221,7 +226,7 @@ | 354 | [俄罗斯套娃信封问题](../../problems/russian-doll-envelopes) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 351 | [安卓系统手势解锁](../../problems/android-unlock-patterns) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 343 | [整数拆分](../../problems/integer-break) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 322 | [零钱兑换](../../problems/coin-change) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 321 | [拼接最大数](../../problems/create-maximum-number) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 1dac21df8..6b460c9ed 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,10 +9,15 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1881 | [插入后的最大值](../../problems/maximum-value-after-insertion) | [[贪心算法](../greedy/README.md)] | Medium | +| 1877 | [数组中最大数对和的最小值](../../problems/minimize-maximum-pair-sum-in-array) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 1874 | [Minimize Product Sum of Two Arrays](../../problems/minimize-product-sum-of-two-arrays) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | +| 1871 | [跳跃游戏 VII](../../problems/jump-game-vii) | [[贪心算法](../greedy/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1864 | [构成交替字符串需要的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-binary-string-alternating) | [[贪心算法](../greedy/README.md)] | Medium | | 1855 | [下标对中的最大距离](../../problems/maximum-distance-between-a-pair-of-values) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1850 | [邻位交换的最小次数](../../problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1846 | [减小和重新排列数组后的最大元素](../../problems/maximum-element-after-decreasing-and-rearranging) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1842 | [Next Palindrome Using Same Digits](../../problems/next-palindrome-using-same-digits) | [[贪心算法](../greedy/README.md)] | Hard | +| 1842 | [Next Palindrome Using Same Digits](../../problems/next-palindrome-using-same-digits) 🔒 | [[贪心算法](../greedy/README.md)] | Hard | | 1840 | [最高建筑高度](../../problems/maximum-building-height) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1838 | [最高频元素的频数](../../problems/frequency-of-the-most-frequent-element) | [[贪心算法](../greedy/README.md)] | Medium | | 1827 | [最少操作使数组递增](../../problems/minimum-operations-to-make-the-array-increasing) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 63b421b13..4dd7bbed7 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,7 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1852 | [Distinct Numbers in Each Subarray](../../problems/distinct-numbers-in-each-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1865 | [找出和为指定值的下标对](../../problems/finding-pairs-with-a-certain-sum) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | +| 1858 | [Longest Word With All Prefixes](../../problems/longest-word-with-all-prefixes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1852 | [Distinct Numbers in Each Subarray](../../problems/distinct-numbers-in-each-subarray) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | | 1817 | [查找用户活跃分钟数](../../problems/finding-the-users-active-minutes) | [[哈希表](../hash-table/README.md)] | Medium | | 1814 | [统计一个数组中好对子的数目](../../problems/count-nice-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1807 | [替换字符串中的括号内容](../../problems/evaluate-the-bracket-pairs-of-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | @@ -113,7 +115,7 @@ | 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 380 | [常数时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 380 | [O(1) 时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 356 | [直线镜像](../../problems/line-reflection) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/heap/README.md b/tag/heap/README.md index 191a96216..64eee7cc0 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1882 | [使用服务器处理任务](../../problems/process-tasks-using-servers) | [[堆](../heap/README.md)] | Medium | | 1845 | [座位预约管理系统](../../problems/seat-reservation-manager) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Medium | | 1834 | [单线程 CPU](../../problems/single-threaded-cpu) | [[堆](../heap/README.md)] | Medium | | 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] | Hard | diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md index ce913f3d2..3d3455b3b 100644 --- a/tag/line-sweep/README.md +++ b/tag/line-sweep/README.md @@ -9,7 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1852 | [Distinct Numbers in Each Subarray](../../problems/distinct-numbers-in-each-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1871 | [跳跃游戏 VII](../../problems/jump-game-vii) | [[贪心算法](../greedy/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1852 | [Distinct Numbers in Each Subarray](../../problems/distinct-numbers-in-each-subarray) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | | 1851 | [包含每个查询的最小区间](../../problems/minimum-interval-to-include-each-query) | [[Line Sweep](../line-sweep/README.md)] | Hard | | 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | | 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index a495a3463..848b07aa2 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1884 | [鸡蛋掉落-两枚鸡蛋](../../problems/egg-drop-with-2-eggs-and-n-floors) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1878 | [矩阵中最大的三个菱形和](../../problems/get-biggest-three-rhombus-sums-in-a-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1870 | [准时到达的列车最小时速](../../problems/minimum-speed-to-arrive-on-time) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1862 | [向下取整数对和](../../problems/sum-of-floored-pairs) | [[数学](../math/README.md)] | Hard | +| 1860 | [增长的内存泄露](../../problems/incremental-memory-leak) | [[数学](../math/README.md)] | Medium | | 1837 | [K 进制表示下的各位数字总和](../../problems/sum-of-digits-in-base-k) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | | 1835 | [所有数对按位与结果的异或和](../../problems/find-xor-sum-of-all-pairs-bitwise-and) | [[数学](../math/README.md)] | Hard | | 1830 | [使字符串有序的最少操作次数](../../problems/minimum-number-of-operations-to-make-string-sorted) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | @@ -195,7 +200,7 @@ | 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 246 | [中心对称数](../../problems/strobogrammatic-number) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | | 233 | [数字 1 的个数](../../problems/number-of-digit-one) | [[数学](../math/README.md)] | Hard | -| 231 | [2的幂](../../problems/power-of-two) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | +| 231 | [2 的幂](../../problems/power-of-two) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | | 224 | [基本计算器](../../problems/basic-calculator) | [[栈](../stack/README.md)] [[数学](../math/README.md)] | Hard | | 223 | [矩形面积](../../problems/rectangle-area) | [[数学](../math/README.md)] | Medium | | 204 | [计数质数](../../problems/count-primes) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index 85faedb8e..86e7c7355 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1865 | [找出和为指定值的下标对](../../problems/finding-pairs-with-a-certain-sum) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | | 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | | 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[Ordered Map](../ordered-map/README.md)] | Hard | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index f6c72681c..8951347fc 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1863 | [找出所有子集的异或总和再求和](../../problems/sum-of-all-subset-xor-totals) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | | 1849 | [将字符串拆分为递减的连续值](../../problems/splitting-a-string-into-descending-consecutive-values) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index 496fec772..ea6946cac 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1877 | [数组中最大数对和的最小值](../../problems/minimize-maximum-pair-sum-in-array) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | +| 1859 | [将句子排序](../../problems/sorting-the-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | | 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1847 | [最近的房间](../../problems/closest-room) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1846 | [减小和重新排列数组后的最大元素](../../problems/maximum-element-after-decreasing-and-rearranging) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | diff --git a/tag/stack/README.md b/tag/stack/README.md index 19f1a0b2a..b1b3ae826 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -65,7 +65,7 @@ | 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | | 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] | Medium | | 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Easy | -| 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | +| 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Easy | | 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/string/README.md b/tag/string/README.md index b8cc2bf66..913077bf0 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1880 | [检查某单词是否等于两单词之和](../../problems/check-if-word-equals-summation-of-two-words) | [[字符串](../string/README.md)] | Easy | +| 1876 | [长度为三且各字符不同的子字符串](../../problems/substrings-of-size-three-with-distinct-characters) | [[字符串](../string/README.md)] | Easy | +| 1859 | [将句子排序](../../problems/sorting-the-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | | 1850 | [邻位交换的最小次数](../../problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1849 | [将字符串拆分为递减的连续值](../../problems/splitting-a-string-into-descending-consecutive-values) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | | 1844 | [将所有数字用字符替换](../../problems/replace-all-digits-with-characters) | [[字符串](../string/README.md)] | Easy | @@ -152,7 +155,7 @@ | 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | | 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | -| 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字符串](../string/README.md)] | Easy | +| 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字符串](../string/README.md)] | Medium | | 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[字符串](../string/README.md)] | Hard | | 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 722 | [删除注释](../../problems/remove-comments) | [[字符串](../string/README.md)] | Medium | @@ -230,7 +233,7 @@ | 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | | 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 38 | [外观数列](../../problems/count-and-say) | [[字符串](../string/README.md)] | Easy | +| 38 | [外观数列](../../problems/count-and-say) | [[字符串](../string/README.md)] | Medium | | 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | | 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | diff --git a/tag/tags.json b/tag/tags.json index 4e2d3ff55..98bc0a798 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -24,16 +24,16 @@ "Slug": "greedy", "TranslatedName": "贪心算法" }, - { - "Name": "Tree", - "Slug": "tree", - "TranslatedName": "树" - }, { "Name": "Depth-first Search", "Slug": "depth-first-search", "TranslatedName": "深度优先搜索" }, + { + "Name": "Tree", + "Slug": "tree", + "TranslatedName": "树" + }, { "Name": "Hash Table", "Slug": "hash-table", @@ -64,16 +64,16 @@ "Slug": "backtracking", "TranslatedName": "回溯算法" }, - { - "Name": "Stack", - "Slug": "stack", - "TranslatedName": "栈" - }, { "Name": "Design", "Slug": "design", "TranslatedName": "设计" }, + { + "Name": "Stack", + "Slug": "stack", + "TranslatedName": "栈" + }, { "Name": "Bit Manipulation", "Slug": "bit-manipulation", @@ -119,16 +119,16 @@ "Slug": "divide-and-conquer", "TranslatedName": "分治算法" }, - { - "Name": "Segment Tree", - "Slug": "segment-tree", - "TranslatedName": "线段树" - }, { "Name": "Ordered Map", "Slug": "ordered-map", "TranslatedName": "Ordered Map" }, + { + "Name": "Segment Tree", + "Slug": "segment-tree", + "TranslatedName": "线段树" + }, { "Name": "Queue", "Slug": "queue", @@ -144,16 +144,16 @@ "Slug": "line-sweep", "TranslatedName": "Line Sweep" }, - { - "Name": "Minimax", - "Slug": "minimax", - "TranslatedName": "极小化极大" - }, { "Name": "Binary Indexed Tree", "Slug": "binary-indexed-tree", "TranslatedName": "树状数组" }, + { + "Name": "Minimax", + "Slug": "minimax", + "TranslatedName": "极小化极大" + }, { "Name": "Brainteaser", "Slug": "brainteaser", diff --git a/tag/tree/README.md b/tag/tree/README.md index 0f5ca9d2a..ee23e51bc 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -143,7 +143,7 @@ | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | | 156 | [上下翻转二叉树](../../problems/binary-tree-upside-down) 🔒 | [[树](../tree/README.md)] | Medium | | 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Easy | -| 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | +| 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Easy | | 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | | 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | diff --git a/tag/trie/README.md b/tag/trie/README.md index 4b38e751a..0f017a498 100644 --- a/tag/trie/README.md +++ b/tag/trie/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1858 | [Longest Word With All Prefixes](../../problems/longest-word-with-all-prefixes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1804 | [实现 Trie (前缀树) II](../../problems/implement-trie-ii-prefix-tree) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | | 1803 | [统计异或值在范围内的数对有多少](../../problems/count-pairs-with-xor-in-a-range) | [[字典树](../trie/README.md)] | Hard | | 1707 | [与数组中元素的最大异或值](../../problems/maximum-xor-with-an-element-from-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Hard | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index b46fa02ce..d08d0bcd0 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1869 | [哪种连续子字符串更长](../../problems/longer-contiguous-segments-of-ones-than-zeros) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1868 | [Product of Two Run-Length Encoded Arrays](../../problems/product-of-two-run-length-encoded-arrays) 🔒 | [[双指针](../two-pointers/README.md)] | Medium | +| 1861 | [旋转盒子](../../problems/rotating-the-box) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1855 | [下标对中的最大距离](../../problems/maximum-distance-between-a-pair-of-values) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1839 | [所有元音按顺序排布的最长子字符串](../../problems/longest-substring-of-all-vowels-in-order) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1800 | [最大升序子数组和](../../problems/maximum-ascending-subarray-sum) | [[双指针](../two-pointers/README.md)] | Easy | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index dd99db7bc..12680f716 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -47,4 +47,4 @@ | 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | | 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 128 | [最长连续序列](../../problems/longest-consecutive-sequence) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Hard | +| 128 | [最长连续序列](../../problems/longest-consecutive-sequence) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | From 62f1dece0566ce32e8d421880092643af944dc6a Mon Sep 17 00:00:00 2001 From: Shuo Date: Sat, 10 Jul 2021 11:12:58 +0800 Subject: [PATCH 132/145] A: new --- README.md | 67 +- problems/01-matrix/README.md | 6 +- problems/132-pattern/README.md | 4 + problems/2-keys-keyboard/README.md | 1 + problems/24-game/README.md | 4 +- problems/3sum-closest/README.md | 1 + problems/3sum-smaller/README.md | 14 +- problems/3sum-with-multiplicity/README.md | 4 + problems/3sum/README.md | 1 + problems/4-keys-keyboard/README.md | 35 - problems/4sum-ii/README.md | 2 +- problems/4sum/README.md | 2 +- problems/accounts-merge/README.md | 5 +- problems/active-businesses/README.md | 43 +- problems/active-users/README.md | 3 + problems/activity-participants/README.md | 65 +- .../README.md | 41 +- problems/ad-free-sessions/README.md | 3 + problems/add-binary/README.md | 2 + problems/add-bold-tag-in-string/README.md | 31 +- problems/add-digits/README.md | 2 + problems/add-one-row-to-tree/README.md | 3 + problems/add-strings/README.md | 2 + .../add-to-array-form-of-integer/README.md | 1 + problems/add-two-numbers-ii/README.md | 2 + .../README.md | 2 + .../adding-two-negabinary-numbers/README.md | 1 + problems/additive-number/README.md | 1 + problems/ads-performance/README.md | 57 +- problems/advantage-shuffle/README.md | 1 + .../README.md | 1 + .../README.md | 4 +- problems/alien-dictionary/README.md | 55 +- .../README.md | 5 +- .../README.md | 5 +- problems/all-oone-data-structure/README.md | 8 +- .../README.md | 75 +- .../all-paths-from-source-to-target/README.md | 3 +- .../README.md | 52 +- .../all-possible-full-binary-trees/README.md | 3 + .../README.md | 3 + problems/allocate-mailboxes/README.md | 2 + problems/ambiguous-coordinates/README.md | 1 + .../README.md | 46 +- problems/android-unlock-patterns/README.md | 47 - problems/apples-oranges/README.md | 3 + .../apply-discount-every-n-orders/README.md | 2 + .../README.md | 1 + problems/arithmetic-slices/README.md | 2 +- problems/arithmetic-subarrays/README.md | 3 +- problems/armstrong-number/README.md | 30 - problems/array-nesting/README.md | 1 + problems/array-of-doubled-pairs/README.md | 2 + problems/array-partition-i/README.md | 3 + problems/array-transformation/README.md | 41 +- problems/article-views-i/README.md | 43 +- problems/article-views-ii/README.md | 43 +- .../as-far-from-land-as-possible/README.md | 6 +- problems/assign-cookies/README.md | 2 + problems/asteroid-collision/README.md | 1 + .../available-captures-for-rook/README.md | 2 + .../README.md | 3 + .../README.md | 59 +- .../README.md | 2 +- problems/average-selling-price/README.md | 72 +- .../README.md | 3 + problems/average-waiting-time/README.md | 1 + problems/avoid-flood-in-the-city/README.md | 3 + problems/backspace-string-compare/README.md | 2 + problems/bag-of-tokens/README.md | 3 +- .../balance-a-binary-search-tree/README.md | 5 + problems/balanced-binary-tree/README.md | 4 +- problems/bank-account-summary-ii/README.md | 3 + problems/bank-account-summary/README.md | 3 + problems/base-7/README.md | 3 + problems/baseball-game/README.md | 2 + problems/basic-calculator-ii/README.md | 1 + problems/basic-calculator-iii/README.md | 21 +- problems/basic-calculator-iv/README.md | 76 +- problems/basic-calculator/README.md | 2 + problems/battleships-in-a-board/README.md | 5 + problems/beautiful-arrangement-ii/README.md | 1 + problems/beautiful-arrangement/README.md | 5 +- problems/beautiful-array/README.md | 2 + problems/before-and-after-puzzle/README.md | 53 +- problems/best-meeting-point/README.md | 21 +- .../README.md | 2 + problems/best-sightseeing-pair/README.md | 1 + .../best-team-with-no-conflicts/README.md | 2 + .../README.md | 1 + .../README.md | 1 + .../README.md | 1 + problems/big-countries/README.md | 3 + problems/biggest-single-number/README.md | 28 +- .../biggest-window-between-visits/README.md | 3 + problems/binary-gap/README.md | 1 + .../binary-prefix-divisible-by-5/README.md | 42 +- .../binary-search-tree-iterator-ii/README.md | 4 + .../binary-search-tree-iterator/README.md | 3 + .../README.md | 4 +- problems/binary-search/README.md | 7 +- problems/binary-subarrays-with-sum/README.md | 4 +- problems/binary-tree-cameras/README.md | 3 +- problems/binary-tree-coloring-game/README.md | 3 +- .../binary-tree-inorder-traversal/README.md | 3 +- .../README.md | 3 +- .../README.md | 3 +- .../README.md | 32 +- .../README.md | 38 +- .../binary-tree-maximum-path-sum/README.md | 5 +- problems/binary-tree-paths/README.md | 4 +- .../binary-tree-postorder-traversal/README.md | 2 + .../binary-tree-preorder-traversal/README.md | 2 + problems/binary-tree-pruning/README.md | 2 + .../binary-tree-right-side-view/README.md | 7 +- problems/binary-tree-tilt/README.md | 4 +- problems/binary-tree-upside-down/README.md | 42 +- .../README.md | 83 +- .../README.md | 4 +- problems/binary-trees-with-factors/README.md | 5 + problems/bitwise-ors-of-subarrays/README.md | 1 + problems/boats-to-save-people/README.md | 2 + problems/bold-words-in-string/README.md | 18 +- problems/bomb-enemy/README.md | 19 +- problems/boundary-of-binary-tree/README.md | 54 +- problems/brace-expansion-ii/README.md | 41 +- problems/brace-expansion/README.md | 34 +- problems/break-a-palindrome/README.md | 1 + problems/brick-wall/README.md | 1 + problems/bricks-falling-when-hit/README.md | 2 + problems/buddy-strings/README.md | 1 + .../README.md | 2 + .../build-array-from-permutation/README.md | 64 + .../README.md | 2 + problems/building-boxes/README.md | 1 + problems/building-h2o/README.md | 3 + .../buildings-with-an-ocean-view/README.md | 4 +- problems/bulb-switcher-ii/README.md | 3 + problems/bulb-switcher-iv/README.md | 1 + problems/bulls-and-cows/README.md | 2 + problems/bus-routes/README.md | 4 +- .../README.md | 1 - problems/calculate-salaries/README.md | 3 + problems/calculate-special-bonus/README.md | 5 +- problems/camelcase-matching/README.md | 2 + problems/campus-bikes-ii/README.md | 43 +- problems/campus-bikes/README.md | 43 +- .../can-convert-string-in-k-moves/README.md | 2 +- problems/can-i-win/README.md | 6 +- .../README.md | 2 +- .../README.md | 4 +- .../README.md | 3 +- problems/candy-crush/README.md | 39 +- problems/candy/README.md | 1 + .../README.md | 1 + problems/capital-gainloss/README.md | 53 +- problems/car-fleet-ii/README.md | 4 + problems/car-fleet/README.md | 3 +- problems/car-pooling/README.md | 6 +- problems/card-flipping-game/README.md | 4 + problems/cat-and-mouse-ii/README.md | 5 + problems/cat-and-mouse/README.md | 8 +- .../README.md | 2 + problems/chalkboard-xor-game/README.md | 4 + .../README.md | 4 +- .../README.md | 3 +- .../cheapest-flights-within-k-stops/README.md | 7 +- .../README.md | 1 - .../README.md | 2 + .../README.md | 34 - .../README.md | 1 + .../README.md | 3 + .../README.md | 3 + .../README.md | 1 + .../README.md | 63 + .../README.md | 4 +- .../README.md | 2 +- .../check-if-it-is-a-good-array/README.md | 2 + .../check-if-n-and-its-double-exist/README.md | 4 + .../README.md | 2 - .../README.md | 2 + .../README.md | 1 + .../README.md | 1 + .../README.md | 7 +- .../README.md | 3 +- .../README.md | 1 + .../README.md | 2 +- .../README.md | 4 +- problems/cherry-pickup-ii/README.md | 2 + problems/cherry-pickup/README.md | 2 + problems/cinema-seat-allocation/README.md | 2 + .../README.md | 1 + problems/circular-array-loop/README.md | 1 + .../README.md | 2 + .../classes-more-than-5-students/README.md | 3 + problems/climbing-stairs/README.md | 2 + .../README.md | 5 +- problems/clone-graph/README.md | 5 +- problems/clone-n-ary-tree/README.md | 4 +- .../README.md | 29 +- .../README.md | 24 +- problems/closest-dessert-cost/README.md | 4 +- .../closest-leaf-in-a-binary-tree/README.md | 61 +- problems/closest-room/README.md | 3 +- problems/closest-subsequence-sum/README.md | 6 +- problems/clumsy-factorial/README.md | 2 + problems/coin-change-2/README.md | 4 + problems/coin-change/README.md | 2 + problems/coin-path/README.md | 36 +- problems/coloring-a-border/README.md | 5 +- problems/combination-sum-iii/README.md | 5 +- problems/combination-sum-iv/README.md | 1 + problems/combinations/README.md | 1 + problems/combine-two-tables/README.md | 3 + .../README.md | 2 + problems/compare-version-numbers/README.md | 1 + .../complement-of-base-10-integer/README.md | 2 +- .../complete-binary-tree-inserter/README.md | 3 + .../complex-number-multiplication/README.md | 1 + problems/concatenated-words/README.md | 3 +- .../README.md | 2 + problems/confusing-number-ii/README.md | 38 - problems/confusing-number/README.md | 57 - .../README.md | 42 +- .../consecutive-available-seats/README.md | 30 +- problems/consecutive-numbers-sum/README.md | 1 + problems/consecutive-numbers/README.md | 3 + .../constrained-subsequence-sum/README.md | 5 + .../README.md | 5 + .../README.md | 4 +- .../README.md | 4 +- .../README.md | 4 + .../README.md | 26 +- .../construct-k-palindrome-strings/README.md | 3 + problems/construct-quad-tree/README.md | 6 + .../README.md | 2 + .../README.md | 3 +- .../README.md | 2 +- problems/contain-virus/README.md | 6 +- problems/container-with-most-water/README.md | 1 + problems/contains-duplicate-ii/README.md | 1 + problems/contains-duplicate-iii/README.md | 7 +- problems/contains-duplicate/README.md | 1 + problems/contiguous-array/README.md | 2 + problems/continuous-subarray-sum/README.md | 4 +- .../convert-a-number-to-hexadecimal/README.md | 1 + .../README.md | 2 +- .../README.md | 27 +- .../convert-bst-to-greater-tree/README.md | 4 +- problems/convert-date-format/README.md | 5 +- .../README.md | 5 +- .../README.md | 5 +- problems/convex-polygon/README.md | 33 +- .../README.md | 3 +- problems/corporate-flight-bookings/README.md | 2 +- problems/correct-a-binary-tree/README.md | 4 + problems/count-all-possible-routes/README.md | 2 + .../README.md | 1 + problems/count-apples-and-oranges/README.md | 3 + problems/count-binary-substrings/README.md | 1 + problems/count-complete-tree-nodes/README.md | 2 + problems/count-good-meals/README.md | 1 - .../count-good-nodes-in-binary-tree/README.md | 4 +- problems/count-good-numbers/README.md | 67 + problems/count-good-triplets/README.md | 1 + problems/count-largest-group/README.md | 3 +- .../README.md | 1 + .../count-nice-pairs-in-an-array/README.md | 2 + .../README.md | 2 +- .../count-number-of-nice-subarrays/README.md | 5 +- problems/count-number-of-teams/README.md | 2 + .../count-of-matches-in-tournament/README.md | 3 +- problems/count-of-range-sum/README.md | 4 +- .../README.md | 4 +- problems/count-pairs-in-two-arrays/README.md | 40 + .../README.md | 1 + problems/count-pairs-of-nodes/README.md | 21 +- .../count-pairs-with-xor-in-a-range/README.md | 2 + problems/count-primes/README.md | 4 +- problems/count-salary-categories/README.md | 17 + .../count-salary-categories/mysql_schemas.sql | 6 + .../count-servers-that-communicate/README.md | 6 +- problems/count-sorted-vowel-strings/README.md | 2 - .../README.md | 1 + .../README.md | 60 +- problems/count-sub-islands/README.md | 65 + .../count-submatrices-with-all-ones/README.md | 4 + .../README.md | 2 +- .../README.md | 31 +- .../README.md | 6 +- .../README.md | 3 + problems/count-the-repetitions/README.md | 1 + .../README.md | 2 + problems/count-unhappy-friends/README.md | 1 + .../README.md | 19 +- problems/count-univalue-subtrees/README.md | 17 +- .../README.md | 78 ++ .../README.md | 2 + problems/counting-elements/README.md | 1 + .../README.md | 3 + problems/couples-holding-hands/README.md | 60 +- problems/course-schedule-ii/README.md | 4 +- problems/course-schedule-iii/README.md | 2 + problems/course-schedule-iv/README.md | 3 + problems/course-schedule/README.md | 4 +- problems/cousins-in-binary-tree/README.md | 4 +- problems/cracking-the-safe/README.md | 47 +- problems/crawler-log-folder/README.md | 2 + problems/create-a-session-bar-chart/README.md | 3 + problems/create-maximum-number/README.md | 6 +- .../README.md | 5 +- .../README.md | 1 + .../README.md | 4 +- problems/custom-sort-string/README.md | 2 + problems/customer-order-frequency/README.md | 3 + .../README.md | 45 +- .../README.md | 3 + .../README.md | 58 +- .../README.md | 65 +- problems/customers-who-never-order/README.md | 3 + .../cut-off-trees-for-golf-event/README.md | 5 +- problems/cutting-ribbons/README.md | 29 + problems/cyclically-rotating-a-grid/README.md | 68 + problems/daily-leads-and-partners/README.md | 3 + problems/daily-temperatures/README.md | 3 +- .../README.md | 3 +- problems/day-of-the-week/README.md | 2 +- problems/day-of-the-year/README.md | 1 + problems/decode-string/README.md | 3 +- problems/decode-ways-ii/README.md | 1 + problems/decode-xored-array/README.md | 1 + problems/decode-xored-permutation/README.md | 1 + problems/decoded-string-at-index/README.md | 1 + .../README.md | 1 + problems/deepest-leaves-sum/README.md | 4 +- problems/degree-of-an-array/README.md | 1 + problems/delete-and-earn/README.md | 26 +- .../README.md | 2 + .../README.md | 2 + .../delete-columns-to-make-sorted/README.md | 3 +- problems/delete-duplicate-emails/README.md | 3 + .../README.md | 4 + .../README.md | 6 + problems/delete-node-in-a-bst/README.md | 2 + .../delete-nodes-and-return-forest/README.md | 3 +- .../README.md | 1 + problems/delete-tree-nodes/README.md | 35 +- .../README.md | 5 +- problems/department-highest-salary/README.md | 3 + .../department-top-three-salaries/README.md | 3 + .../README.md | 31 + .../design-a-file-sharing-system/README.md | 4 +- problems/design-a-leaderboard/README.md | 44 +- .../README.md | 1 + .../README.md | 4 +- .../README.md | 3 + problems/design-an-ordered-stream/README.md | 2 + .../design-bounded-blocking-queue/README.md | 74 +- problems/design-browser-history/README.md | 5 + problems/design-circular-deque/README.md | 2 + problems/design-circular-queue/README.md | 2 + .../README.md | 39 +- problems/design-excel-sum-formula/README.md | 58 +- problems/design-file-system/README.md | 58 +- .../design-front-middle-back-queue/README.md | 3 + problems/design-hashmap/README.md | 3 + problems/design-hashset/README.md | 3 + problems/design-hit-counter/README.md | 38 +- .../design-in-memory-file-system/README.md | 36 +- problems/design-log-storage-system/README.md | 26 +- .../design-most-recently-used-queue/README.md | 3 + problems/design-movie-rental-system/README.md | 87 ++ problems/design-parking-system/README.md | 2 + problems/design-phone-directory/README.md | 39 +- .../README.md | 61 +- problems/design-skiplist/README.md | 49 +- problems/design-snake-game/README.md | 50 +- problems/design-tic-tac-toe/README.md | 59 +- problems/design-twitter/README.md | 3 +- problems/design-underground-system/README.md | 2 + problems/destination-city/README.md | 1 + problems/detect-cycles-in-2d-grid/README.md | 6 +- .../README.md | 1 + .../README.md | 1 + .../README.md | 1 + .../README.md | 4 +- .../README.md | 64 + problems/di-string-match/README.md | 4 + problems/diagonal-traverse-ii/README.md | 3 +- problems/diagonal-traverse/README.md | 5 + problems/diameter-of-binary-tree/README.md | 2 + problems/diameter-of-n-ary-tree/README.md | 4 + problems/dice-roll-simulation/README.md | 3 +- problems/diet-plan-performance/README.md | 43 - .../README.md | 6 +- problems/digit-count-in-range/README.md | 30 - problems/dinner-plate-stacks/README.md | 56 +- .../README.md | 4 + problems/distant-barcodes/README.md | 8 +- problems/distinct-echo-substrings/README.md | 5 + .../README.md | 4 +- problems/distinct-subsequences-ii/README.md | 1 + .../distribute-candies-to-people/README.md | 1 + problems/distribute-candies/README.md | 1 + .../distribute-coins-in-binary-tree/README.md | 3 +- .../distribute-repeating-integers/README.md | 3 + .../README.md | 2 + .../README.md | 33 +- problems/divide-chocolate/README.md | 41 +- problems/divide-two-integers/README.md | 2 +- problems/divisor-game/README.md | 2 + .../README.md | 1 + problems/dota2-senate/README.md | 2 + problems/dungeon-game/README.md | 3 +- problems/duplicate-emails/README.md | 3 + problems/duplicate-zeros/README.md | 1 + .../README.md | 70 ++ .../README.md | 80 ++ problems/elimination-game/README.md | 3 + problems/employee-bonus/README.md | 39 +- problems/employee-free-time/README.md | 46 +- problems/employee-importance/README.md | 4 +- .../README.md | 3 + problems/encode-and-decode-strings/README.md | 44 +- problems/encode-and-decode-tinyurl/README.md | 4 +- .../README.md | 23 +- problems/encode-number/README.md | 27 +- .../README.md | 63 +- problems/equal-rational-numbers/README.md | 1 + .../README.md | 3 + problems/equal-tree-partition/README.md | 49 +- problems/erect-the-fence-ii/README.md | 25 + problems/erect-the-fence/README.md | 2 + problems/escape-a-large-maze/README.md | 5 +- problems/escape-the-ghosts/README.md | 1 + .../evaluate-boolean-expression/README.md | 3 + problems/evaluate-division/README.md | 4 + .../README.md | 2 + .../README.md | 1 + problems/even-odd-tree/README.md | 2 + problems/exam-room/README.md | 3 +- problems/excel-sheet-column-number/README.md | 1 + problems/excel-sheet-column-title/README.md | 1 + problems/exchange-seats/README.md | 3 + .../exclusive-time-of-functions/README.md | 1 + problems/expression-add-operators/README.md | 4 +- problems/expressive-words/README.md | 2 + problems/factor-combinations/README.md | 54 +- problems/fair-candy-swap/README.md | 3 + problems/falling-squares/README.md | 3 +- problems/fancy-sequence/README.md | 1 + problems/faulty-sensor/README.md | 1 + problems/fibonacci-number/README.md | 5 +- problems/filling-bookcase-shelves/README.md | 1 + .../README.md | 2 +- .../README.md | 2 + .../README.md | 6 +- problems/find-a-peak-element-ii/README.md | 89 ++ .../README.md | 1 + .../find-all-anagrams-in-a-string/README.md | 2 + .../find-all-duplicates-in-an-array/README.md | 1 + problems/find-all-good-strings/README.md | 2 + .../README.md | 1 + problems/find-all-the-lonely-nodes/README.md | 4 +- problems/find-anagram-mappings/README.md | 28 +- problems/find-and-replace-in-string/README.md | 49 +- problems/find-and-replace-pattern/README.md | 2 + .../find-bottom-left-tree-value/README.md | 5 +- problems/find-center-of-star-graph/README.md | 2 +- problems/find-common-characters/README.md | 1 + .../README.md | 5 +- .../README.md | 68 +- problems/find-customer-referee/README.md | 29 +- .../README.md | 3 + .../find-distance-in-a-binary-tree/README.md | 6 +- .../find-duplicate-file-in-system/README.md | 1 + problems/find-duplicate-subtrees/README.md | 3 + .../README.md | 33 +- problems/find-eventual-safe-states/README.md | 6 +- problems/find-followers-count/README.md | 3 + problems/find-in-mountain-array/README.md | 2 + problems/find-interview-candidates/README.md | 5 +- problems/find-k-closest-elements/README.md | 4 + .../README.md | 31 +- .../find-k-pairs-with-smallest-sums/README.md | 3 +- .../README.md | 3 +- .../README.md | 1 + .../README.md | 6 + .../README.md | 5 +- .../find-latest-group-of-size-m/README.md | 2 + problems/find-leaves-of-binary-tree/README.md | 47 +- .../find-longest-awesome-substring/README.md | 1 + .../find-lucky-integer-in-an-array/README.md | 2 + .../find-median-from-data-stream/README.md | 5 +- .../README.md | 24 +- .../README.md | 5 +- .../find-mode-in-binary-search-tree/README.md | 3 + .../README.md | 1 + .../README.md | 3 +- problems/find-permutation/README.md | 27 +- problems/find-pivot-index/README.md | 1 + .../README.md | 2 + problems/find-right-interval/README.md | 2 + problems/find-root-of-n-ary-tree/README.md | 6 + .../README.md | 5 +- .../README.md | 20 +- .../README.md | 1 + problems/find-the-celebrity/README.md | 44 +- .../README.md | 2 + .../find-the-closest-palindrome/README.md | 1 + .../README.md | 23 +- problems/find-the-difference/README.md | 2 + .../README.md | 3 + problems/find-the-duplicate-number/README.md | 1 + problems/find-the-highest-altitude/README.md | 1 + .../README.md | 2 + .../README.md | 5 +- .../README.md | 3 + .../README.md | 1 - problems/find-the-missing-ids/README.md | 3 + .../README.md | 4 +- .../README.md | 3 + .../find-the-shortest-superstring/README.md | 4 + .../README.md | 1 + .../README.md | 44 +- .../README.md | 78 ++ .../README.md | 3 + problems/find-the-team-size/README.md | 44 +- problems/find-the-town-judge/README.md | 2 + .../README.md | 1 + .../README.md | 3 + .../README.md | 3 + .../README.md | 4 + .../find-users-with-valid-e-mails/README.md | 3 + .../README.md | 2 + .../README.md | 3 + .../README.md | 1 + .../README.md | 2 + problems/finding-mk-average/README.md | 3 +- .../README.md | 2 +- .../README.md | 1 + problems/first-bad-version/README.md | 1 + problems/first-missing-positive/README.md | 1 + .../README.md | 4 +- problems/first-unique-number/README.md | 3 + problems/fix-names-in-a-table/README.md | 3 + problems/fix-product-name-format/README.md | 3 + problems/fixed-point/README.md | 38 - problems/fizz-buzz-multithreaded/README.md | 67 +- problems/fizz-buzz/README.md | 5 + problems/flatten-2d-vector/README.md | 34 +- .../README.md | 3 +- .../README.md | 5 +- .../flatten-nested-list-iterator/README.md | 4 + .../README.md | 3 +- .../README.md | 2 + .../flip-equivalent-binary-trees/README.md | 2 + problems/flip-game-ii/README.md | 18 +- problems/flip-game/README.md | 16 - .../README.md | 3 +- problems/flipping-an-image/README.md | 3 + problems/flood-fill/README.md | 9 +- .../README.md | 2 + .../README.md | 1 + .../README.md | 2 +- problems/four-divisors/README.md | 1 + .../README.md | 2 + .../fraction-to-recurring-decimal/README.md | 1 + problems/freedom-trail/README.md | 5 +- .../README.md | 5 +- .../README.md | 60 +- .../README.md | 41 +- .../README.md | 3 + .../friends-of-appropriate-ages/README.md | 3 + problems/frog-jump/README.md | 1 + .../frog-position-after-t-seconds/README.md | 5 +- problems/fruit-into-baskets/README.md | 70 +- .../furthest-building-you-can-reach/README.md | 5 +- problems/game-of-life/README.md | 2 + problems/game-of-nim/README.md | 28 + problems/game-play-analysis-i/README.md | 43 +- problems/game-play-analysis-ii/README.md | 42 +- problems/game-play-analysis-iii/README.md | 48 +- problems/game-play-analysis-iv/README.md | 42 +- problems/game-play-analysis-v/README.md | 48 +- problems/gas-station/README.md | 1 + problems/generalized-abbreviation/README.md | 13 +- problems/generate-parentheses/README.md | 1 + .../README.md | 3 +- .../README.md | 4 + .../README.md | 4 +- .../README.md | 34 +- .../get-maximum-in-generated-array/README.md | 2 + problems/get-the-maximum-score/README.md | 3 + .../README.md | 45 +- .../README.md | 5 +- problems/grand-slam-titles/README.md | 3 + .../README.md | 1 + problems/graph-valid-tree/README.md | 18 +- problems/gray-code/README.md | 2 + .../README.md | 1 + .../greatest-sum-divisible-by-three/README.md | 2 + problems/grid-illumination/README.md | 1 + problems/group-anagrams/README.md | 1 + .../README.md | 3 + problems/group-shifted-strings/README.md | 19 +- .../group-sold-products-by-the-date/README.md | 3 + .../README.md | 3 +- .../README.md | 2 + .../guess-number-higher-or-lower-ii/README.md | 3 +- .../guess-number-higher-or-lower/README.md | 1 + .../README.md | 5 + problems/guess-the-word/README.md | 6 +- problems/h-index-ii/README.md | 1 + problems/h-index/README.md | 5 +- problems/hand-of-straights/README.md | 5 +- problems/handshakes-that-dont-cross/README.md | 46 - problems/happy-number/README.md | 1 + problems/heaters/README.md | 2 + problems/height-checker/README.md | 2 + problems/hexspeak/README.md | 27 - problems/high-five/README.md | 28 +- .../highest-grade-for-each-student/README.md | 41 +- problems/hopper-company-queries-i/README.md | 3 + problems/hopper-company-queries-ii/README.md | 3 + problems/hopper-company-queries-iii/README.md | 3 + problems/house-robber-ii/README.md | 1 + problems/house-robber-iii/README.md | 3 +- problems/house-robber/README.md | 1 + .../README.md | 29 +- .../README.md | 2 + problems/html-entity-parser/README.md | 2 +- problems/human-traffic-of-stadium/README.md | 3 + problems/image-overlap/README.md | 1 + problems/image-smoother/README.md | 1 + problems/immediate-food-delivery-i/README.md | 44 +- problems/immediate-food-delivery-ii/README.md | 51 +- problems/implement-magic-dictionary/README.md | 2 + .../implement-queue-using-stacks/README.md | 1 + .../implement-rand10-using-rand7/README.md | 4 +- .../implement-stack-using-queues/README.md | 9 +- problems/implement-strstr/README.md | 1 + .../implement-trie-ii-prefix-tree/README.md | 2 + problems/implement-trie-prefix-tree/README.md | 2 + .../increasing-decreasing-string/README.md | 3 +- .../increasing-order-search-tree/README.md | 6 +- problems/increasing-subsequences/README.md | 5 +- .../increasing-triplet-subsequence/README.md | 4 + problems/incremental-memory-leak/README.md | 2 +- problems/index-pairs-of-a-string/README.md | 33 +- .../inorder-successor-in-bst-ii/README.md | 62 +- problems/inorder-successor-in-bst/README.md | 30 +- .../README.md | 9 +- problems/insert-delete-getrandom-o1/README.md | 9 +- problems/insert-interval/README.md | 1 - .../README.md | 2 + .../README.md | 18 - problems/insertion-sort-list/README.md | 2 +- .../README.md | 4 +- problems/integer-replacement/README.md | 3 +- problems/integer-to-english-words/README.md | 1 + problems/integer-to-roman/README.md | 1 + .../README.md | 21 +- .../intersection-of-two-arrays-ii/README.md | 3 +- problems/intersection-of-two-arrays/README.md | 3 +- .../README.md | 2 + .../interval-list-intersections/README.md | 1 + problems/invalid-transactions/README.md | 2 + problems/invalid-tweets/README.md | 3 + problems/invert-binary-tree/README.md | 3 + problems/investments-in-2016/README.md | 52 +- problems/ip-to-cidr/README.md | 50 +- problems/ipo/README.md | 4 +- problems/is-graph-bipartite/README.md | 5 +- problems/is-subsequence/README.md | 4 +- problems/island-perimeter/README.md | 5 +- problems/isomorphic-strings/README.md | 1 + problems/iterator-for-combination/README.md | 2 + problems/jewels-and-stones/README.md | 1 + problems/jump-game-ii/README.md | 1 + problems/jump-game-iii/README.md | 6 +- problems/jump-game-iv/README.md | 4 +- problems/jump-game-v/README.md | 2 + problems/jump-game-vi/README.md | 16 +- problems/jump-game-vii/README.md | 6 +- problems/jump-game/README.md | 1 + problems/k-closest-points-to-origin/README.md | 9 +- .../k-concatenation-maximum-sum/README.md | 1 + problems/k-diff-pairs-in-an-array/README.md | 3 + problems/k-empty-slots/README.md | 47 +- problems/k-similar-strings/README.md | 4 +- .../README.md | 3 + .../k-th-smallest-prime-fraction/README.md | 3 +- problems/k-th-symbol-in-grammar/README.md | 2 + problems/keyboard-row/README.md | 2 + problems/keys-and-rooms/README.md | 3 +- problems/kill-process/README.md | 34 +- problems/koko-eating-bananas/README.md | 1 + .../kth-ancestor-of-a-tree-node/README.md | 53 +- .../kth-largest-element-in-a-stream/README.md | 6 +- .../kth-largest-element-in-an-array/README.md | 5 +- .../kth-missing-positive-number/README.md | 2 +- .../kth-smallest-element-in-a-bst/README.md | 4 +- .../README.md | 5 +- problems/kth-smallest-instructions/README.md | 3 + problems/kth-smallest-subarray-sum/README.md | 30 + problems/largest-1-bordered-square/README.md | 2 + problems/largest-bst-subtree/README.md | 26 +- .../README.md | 4 + .../README.md | 1 + problems/largest-divisible-subset/README.md | 2 + problems/largest-magic-square/README.md | 57 + .../largest-merge-of-two-strings/README.md | 2 + problems/largest-multiple-of-three/README.md | 3 +- .../README.md | 1 + problems/largest-number/README.md | 4 +- .../largest-odd-number-in-string/README.md | 65 + problems/largest-palindrome-product/README.md | 3 + problems/largest-perimeter-triangle/README.md | 4 +- problems/largest-plus-sign/README.md | 84 +- .../largest-rectangle-in-histogram/README.md | 1 + .../README.md | 4 +- .../README.md | 1 + problems/largest-sum-of-averages/README.md | 1 + .../largest-time-for-given-digits/README.md | 3 +- problems/largest-triangle-area/README.md | 2 + problems/largest-unique-number/README.md | 32 +- problems/largest-values-from-labels/README.md | 3 + .../README.md | 1 + .../last-person-to-fit-in-the-bus/README.md | 17 + .../mysql_schemas.sql | 8 + problems/last-stone-weight-ii/README.md | 1 + problems/last-stone-weight/README.md | 4 +- .../README.md | 1 + .../README.md | 1 - problems/leaf-similar-trees/README.md | 3 +- problems/league-statistics/README.md | 3 + .../README.md | 5 +- .../README.md | 17 + .../mysql_schemas.sql | 20 + problems/leetcodify-similar-friends/README.md | 14 + .../mysql_schemas.sql | 22 + problems/leetflex-banned-accounts/README.md | 3 + .../README.md | 3 + problems/lemonade-change/README.md | 1 + .../README.md | 1 + problems/letter-case-permutation/README.md | 1 + .../README.md | 3 +- problems/letter-tile-possibilities/README.md | 1 + problems/lexicographical-numbers/README.md | 4 + .../README.md | 50 +- .../README.md | 4 +- problems/lfu-cache/README.md | 13 +- problems/license-key-formatting/README.md | 3 + problems/line-reflection/README.md | 15 +- problems/linked-list-components/README.md | 1 + problems/linked-list-cycle-ii/README.md | 1 + problems/linked-list-cycle/README.md | 1 + problems/linked-list-in-binary-tree/README.md | 4 +- problems/linked-list-random-node/README.md | 3 + .../README.md | 77 +- problems/logger-rate-limiter/README.md | 28 - .../README.md | 4 + problems/lonely-pixel-i/README.md | 25 +- problems/lonely-pixel-ii/README.md | 40 +- .../README.md | 3 +- problems/longest-absolute-file-path/README.md | 5 + .../README.md | 2 +- .../longest-arithmetic-subsequence/README.md | 3 + .../README.md | 5 + problems/longest-common-subpath/README.md | 82 ++ problems/longest-common-subsequence/README.md | 1 + .../longest-consecutive-sequence/README.md | 1 + .../README.md | 4 + .../longest-duplicate-substring/README.md | 6 +- problems/longest-happy-prefix/README.md | 3 + problems/longest-happy-string/README.md | 3 +- .../longest-harmonious-subsequence/README.md | 2 + .../README.md | 5 +- .../longest-increasing-subsequence/README.md | 1 + .../README.md | 18 +- problems/longest-mountain-in-array/README.md | 3 + problems/longest-nice-substring/README.md | 3 + problems/longest-palindrome/README.md | 2 + .../longest-palindromic-subsequence/README.md | 1 + .../README.md | 3 +- .../longest-repeating-substring/README.md | 48 +- problems/longest-string-chain/README.md | 3 + .../README.md | 4 +- .../README.md | 2 +- .../README.md | 3 +- .../README.md | 18 - .../README.md | 15 - .../README.md | 1 - .../longest-uncommon-subsequence-i/README.md | 1 - .../longest-uncommon-subsequence-ii/README.md | 4 + problems/longest-univalue-path/README.md | 3 +- problems/longest-valid-parentheses/README.md | 1 + .../README.md | 4 + .../README.md | 4 +- problems/longest-word-in-dictionary/README.md | 3 + .../longest-word-with-all-prefixes/README.md | 5 +- .../README.md | 2 + problems/loud-and-rich/README.md | 5 +- .../README.md | 3 + .../README.md | 2 + .../README.md | 2 + .../README.md | 3 +- .../README.md | 2 + .../README.md | 5 +- problems/lru-cache/README.md | 12 +- problems/lucky-numbers-in-a-matrix/README.md | 1 + problems/magic-squares-in-grid/README.md | 2 + problems/magical-string/README.md | 4 + .../README.md | 1 + problems/majority-element-ii/README.md | 3 + problems/majority-element/README.md | 4 +- .../make-array-strictly-increasing/README.md | 2 + problems/make-sum-divisible-by-p/README.md | 3 +- .../README.md | 2 + .../README.md | 2 + problems/making-a-large-island/README.md | 7 +- problems/making-file-names-unique/README.md | 1 + .../README.md | 31 +- problems/map-of-highest-peak/README.md | 5 +- problems/map-sum-pairs/README.md | 3 + problems/market-analysis-i/README.md | 91 +- problems/market-analysis-ii/README.md | 96 +- problems/matchsticks-to-square/README.md | 8 +- problems/matrix-block-sum/README.md | 4 +- .../matrix-cells-in-distance-order/README.md | 6 +- problems/matrix-diagonal-sum/README.md | 1 + problems/max-area-of-island/README.md | 5 +- .../max-chunks-to-make-sorted-ii/README.md | 22 +- problems/max-chunks-to-make-sorted/README.md | 22 +- problems/max-consecutive-ones-ii/README.md | 26 +- problems/max-consecutive-ones-iii/README.md | 4 +- .../README.md | 3 +- .../README.md | 1 + .../README.md | 47 +- problems/max-number-of-k-sum-pairs/README.md | 3 + problems/max-points-on-a-line/README.md | 1 + problems/max-stack/README.md | 37 +- .../README.md | 4 +- problems/max-value-of-equation/README.md | 3 + problems/maximal-rectangle/README.md | 3 +- problems/maximal-square/README.md | 2 + problems/maximize-grid-happiness/README.md | 4 +- .../README.md | 1 + .../README.md | 1 + .../README.md | 6 +- .../README.md | 2 + .../README.md | 4 +- problems/maximum-69-number/README.md | 1 + .../README.md | 3 +- .../README.md | 73 ++ .../README.md | 33 +- .../maximum-ascending-subarray-sum/README.md | 2 +- problems/maximum-average-pass-ratio/README.md | 4 +- problems/maximum-average-subarray-i/README.md | 1 + .../maximum-average-subarray-ii/README.md | 23 - problems/maximum-average-subtree/README.md | 30 +- .../README.md | 1 + problems/maximum-binary-tree-ii/README.md | 1 + problems/maximum-binary-tree/README.md | 5 + problems/maximum-building-height/README.md | 4 +- .../README.md | 3 +- .../maximum-depth-of-binary-tree/README.md | 5 +- .../maximum-depth-of-n-ary-tree/README.md | 4 +- .../README.md | 3 +- .../README.md | 1 + problems/maximum-distance-in-arrays/README.md | 23 +- .../README.md | 3 +- problems/maximum-equal-frequency/README.md | 1 + problems/maximum-erasure-value/README.md | 4 +- .../README.md | 2 + problems/maximum-frequency-stack/README.md | 2 + problems/maximum-gap/README.md | 7 +- .../README.md | 3 +- problems/maximum-ice-cream-bars/README.md | 3 +- .../README.md | 2 + .../maximum-length-of-pair-chain/README.md | 3 + .../README.md | 4 +- .../README.md | 2 + .../README.md | 3 +- .../README.md | 1 + .../README.md | 4 +- .../README.md | 3 +- .../README.md | 6 +- .../README.md | 3 +- problems/maximum-number-of-balloons/README.md | 1 + .../README.md | 4 +- .../README.md | 6 +- .../README.md | 1 + .../README.md | 2 + .../maximum-number-of-eaten-apples/README.md | 3 +- .../README.md | 1 + .../README.md | 4 +- .../README.md | 4 + .../README.md | 5 +- .../README.md | 1 + .../README.md | 3 +- problems/maximum-number-of-ones/README.md | 40 +- .../README.md | 77 ++ .../README.md | 5 +- .../README.md | 2 +- .../maximum-performance-of-a-team/README.md | 6 +- .../README.md | 2 +- problems/maximum-population-year/README.md | 1 + .../README.md | 64 + .../README.md | 3 +- .../README.md | 1 + .../README.md | 2 + .../maximum-product-of-word-lengths/README.md | 2 + .../README.md | 3 +- .../README.md | 3 +- .../maximum-repeating-substring/README.md | 1 + .../README.md | 5 +- .../README.md | 3 +- .../README.md | 2 + .../README.md | 5 +- .../README.md | 5 + .../README.md | 2 + .../README.md | 22 +- .../maximum-students-taking-exam/README.md | 4 + .../maximum-subarray-min-product/README.md | 9 +- .../README.md | 1 + .../README.md | 1 + .../maximum-sum-bst-in-binary-tree/README.md | 3 + .../maximum-sum-circular-subarray/README.md | 4 + .../README.md | 3 + .../README.md | 2 + problems/maximum-swap/README.md | 2 +- .../maximum-transaction-each-day/README.md | 5 +- problems/maximum-units-on-a-truck/README.md | 3 +- problems/maximum-vacation-days/README.md | 60 +- .../maximum-value-after-insertion/README.md | 1 + .../maximum-width-of-binary-tree/README.md | 3 + problems/maximum-width-ramp/README.md | 2 + problems/maximum-xor-for-each-query/README.md | 2 + .../README.md | 2 + .../README.md | 1 + .../README.md | 1 + problems/median-employee-salary/README.md | 39 +- problems/meeting-rooms-ii/README.md | 20 +- problems/meeting-rooms/README.md | 19 +- problems/meeting-scheduler/README.md | 37 +- problems/merge-intervals/README.md | 2 +- problems/merge-k-sorted-lists/README.md | 3 +- problems/merge-sorted-array/README.md | 1 + problems/merge-strings-alternately/README.md | 1 + .../README.md | 88 ++ problems/merge-two-binary-trees/README.md | 3 + problems/middle-of-the-linked-list/README.md | 1 + .../min-cost-to-connect-all-points/README.md | 2 + problems/minesweeper/README.md | 10 +- problems/mini-parser/README.md | 1 + .../minimize-deviation-in-array/README.md | 6 +- .../README.md | 4 +- problems/minimize-malware-spread-ii/README.md | 6 +- problems/minimize-malware-spread/README.md | 5 +- .../README.md | 21 +- .../README.md | 4 +- .../README.md | 4 +- .../README.md | 35 +- .../README.md | 4 + .../README.md | 82 ++ .../minimum-absolute-difference/README.md | 1 + .../minimum-absolute-sum-difference/README.md | 2 + .../README.md | 1 + .../README.md | 5 +- .../README.md | 1 + problems/minimum-area-rectangle-ii/README.md | 1 + problems/minimum-area-rectangle/README.md | 4 + .../README.md | 1 + .../README.md | 3 +- problems/minimum-cost-for-tickets/README.md | 1 + .../README.md | 89 ++ .../minimum-cost-to-connect-sticks/README.md | 22 +- .../README.md | 5 +- .../minimum-cost-to-cut-a-stick/README.md | 1 + .../minimum-cost-to-hire-k-workers/README.md | 5 +- .../README.md | 7 +- .../minimum-cost-to-merge-stones/README.md | 1 + .../README.md | 3 +- .../README.md | 3 + .../README.md | 3 +- .../README.md | 3 +- .../minimum-depth-of-binary-tree/README.md | 5 +- .../README.md | 3 +- .../README.md | 1 + .../README.md | 6 +- .../README.md | 1 + .../README.md | 1 + problems/minimum-factorization/README.md | 22 +- .../minimum-falling-path-sum-ii/README.md | 2 + problems/minimum-falling-path-sum/README.md | 2 + problems/minimum-genetic-mutation/README.md | 5 + problems/minimum-height-trees/README.md | 4 +- problems/minimum-incompatibility/README.md | 6 +- .../README.md | 3 + .../minimum-index-sum-of-two-lists/README.md | 2 + .../README.md | 2 + .../README.md | 1 + .../README.md | 1 + .../README.md | 4 + .../minimum-jumps-to-reach-home/README.md | 3 +- problems/minimum-knight-moves/README.md | 32 +- .../README.md | 1 + .../minimum-limit-of-balls-in-a-bag/README.md | 2 +- .../README.md | 2 + .../README.md | 1 + .../README.md | 4 +- .../README.md | 5 +- .../README.md | 4 +- .../README.md | 3 +- .../README.md | 6 +- .../README.md | 1 + .../README.md | 5 +- .../README.md | 76 ++ .../README.md | 1 + .../README.md | 6 +- .../README.md | 4 +- .../README.md | 1 + .../README.md | 2 +- .../README.md | 52 +- .../README.md | 3 + .../README.md | 1 + .../README.md | 1 + .../README.md | 1 + .../README.md | 1 + .../README.md | 1 + .../README.md | 3 + .../README.md | 7 +- .../README.md | 6 +- problems/minimum-path-sum/README.md | 1 + .../README.md | 3 + .../README.md | 1 + problems/minimum-sideway-jumps/README.md | 3 +- problems/minimum-size-subarray-sum/README.md | 3 +- .../README.md | 3 +- .../README.md | 83 ++ .../minimum-speed-to-arrive-on-time/README.md | 2 +- .../README.md | 3 +- .../README.md | 2 + .../README.md | 42 - .../README.md | 36 +- .../README.md | 1 + problems/minimum-time-difference/README.md | 3 + .../minimum-time-to-build-blocks/README.md | 47 +- .../README.md | 4 +- .../README.md | 1 + .../README.md | 23 +- .../README.md | 1 + problems/minimum-window-subsequence/README.md | 26 +- problems/minimum-window-substring/README.md | 1 - .../minimum-xor-sum-of-two-arrays/README.md | 2 + problems/mirror-reflection/README.md | 1 + .../missing-element-in-sorted-array/README.md | 40 +- .../README.md | 29 +- problems/missing-number/README.md | 2 + problems/missing-ranges/README.md | 7 - problems/monotone-increasing-digits/README.md | 1 + problems/monthly-transactions-i/README.md | 43 +- problems/monthly-transactions-ii/README.md | 70 +- problems/most-common-word/README.md | 1 + problems/most-frequent-subtree-sum/README.md | 2 + problems/most-profit-assigning-work/README.md | 4 + .../README.md | 3 +- .../README.md | 1 + .../move-sub-tree-of-n-ary-tree/README.md | 1 + problems/movie-rating/README.md | 93 +- .../moving-average-from-data-stream/README.md | 14 +- .../README.md | 4 +- .../moving-stones-until-consecutive/README.md | 1 + problems/multiply-strings/README.md | 1 + problems/my-calendar-i/README.md | 49 +- problems/my-calendar-ii/README.md | 57 +- problems/my-calendar-iii/README.md | 3 +- .../README.md | 2 +- .../n-ary-tree-postorder-traversal/README.md | 2 + .../n-ary-tree-preorder-traversal/README.md | 2 + problems/n-queens/README.md | 1 + .../README.md | 1 + problems/n-th-tribonacci-number/README.md | 4 +- problems/nested-list-weight-sum-ii/README.md | 26 +- problems/nested-list-weight-sum/README.md | 22 +- problems/network-delay-time/README.md | 7 +- problems/new-21-game/README.md | 3 + problems/new-users-daily-count/README.md | 52 +- problems/next-closest-time/README.md | 19 +- problems/next-greater-element-i/README.md | 27 +- problems/next-greater-element-ii/README.md | 2 + problems/next-greater-element-iii/README.md | 2 + .../README.md | 2 + .../README.md | 5 +- problems/next-permutation/README.md | 1 + problems/nim-game/README.md | 3 +- problems/non-decreasing-array/README.md | 2 +- problems/non-overlapping-intervals/README.md | 3 + problems/not-boring-movies/README.md | 3 + problems/npv-queries/README.md | 3 + problems/nth-digit/README.md | 1 + problems/nth-highest-salary/README.md | 3 + problems/number-of-atoms/README.md | 25 +- problems/number-of-boomerangs/README.md | 1 + .../README.md | 1 - .../README.md | 3 + problems/number-of-closed-islands/README.md | 6 +- .../number-of-comments-per-post/README.md | 57 +- .../README.md | 31 +- .../number-of-corner-rectangles/README.md | 55 +- .../README.md | 4 + problems/number-of-days-in-a-month/README.md | 33 +- .../README.md | 1 + .../README.md | 3 + problems/number-of-digit-one/README.md | 4 +- .../number-of-distinct-islands-ii/README.md | 65 +- problems/number-of-distinct-islands/README.md | 41 +- .../README.md | 3 + problems/number-of-enclaves/README.md | 6 +- .../README.md | 2 + .../number-of-good-leaf-nodes-pairs/README.md | 3 +- problems/number-of-good-pairs/README.md | 1 + .../README.md | 1 + problems/number-of-islands-ii/README.md | 54 +- problems/number-of-islands/README.md | 6 +- .../number-of-lines-to-write-string/README.md | 4 + .../README.md | 3 + .../number-of-matching-subsequences/README.md | 5 +- problems/number-of-music-playlists/README.md | 2 + .../README.md | 5 +- .../README.md | 5 +- .../number-of-orders-in-the-backlog/README.md | 5 +- .../number-of-paths-with-max-score/README.md | 2 + problems/number-of-provinces/README.md | 4 +- problems/number-of-recent-calls/README.md | 2 + .../README.md | 2 +- .../README.md | 3 + .../README.md | 1 + .../number-of-ships-in-a-rectangle/README.md | 31 +- problems/number-of-squareful-arrays/README.md | 5 +- .../README.md | 1 + .../README.md | 3 + .../README.md | 1 + .../README.md | 2 + .../README.md | 29 +- .../README.md | 5 +- .../README.md | 6 +- .../README.md | 2 + .../README.md | 81 +- .../README.md | 98 +- problems/number-of-valid-subarrays/README.md | 39 +- .../README.md | 3 + .../README.md | 3 + .../README.md | 2 + .../README.md | 2 + .../README.md | 1 + .../README.md | 9 + .../README.md | 1 + .../README.md | 2 + .../README.md | 2 + .../number-of-wonderful-substrings/README.md | 87 ++ .../README.md | 2 + .../README.md | 4 +- problems/occurrences-after-bigram/README.md | 2 +- problems/odd-even-jump/README.md | 4 +- problems/odd-even-linked-list/README.md | 8 +- problems/one-edit-distance/README.md | 30 +- problems/ones-and-zeroes/README.md | 2 + problems/online-election/README.md | 3 + .../README.md | 48 +- problems/online-stock-span/README.md | 3 + problems/open-the-lock/README.md | 5 +- problems/optimal-account-balancing/README.md | 45 +- problems/optimal-division/README.md | 3 +- .../README.md | 31 +- problems/orderly-queue/README.md | 1 + .../README.md | 3 + problems/out-of-boundary-paths/README.md | 15 +- problems/output-contest-matches/README.md | 43 +- .../pacific-atlantic-water-flow/README.md | 20 +- problems/page-recommendations-ii/README.md | 17 + .../page-recommendations-ii/mysql_schemas.sql | 20 + problems/page-recommendations/README.md | 73 +- problems/paint-fence/README.md | 24 - problems/paint-house-ii/README.md | 18 +- problems/paint-house-iii/README.md | 1 + problems/paint-house/README.md | 15 +- .../README.md | 2 + problems/palindrome-linked-list/README.md | 2 + problems/palindrome-pairs/README.md | 1 + problems/palindrome-partitioning-ii/README.md | 1 + .../palindrome-partitioning-iii/README.md | 11 +- problems/palindrome-partitioning/README.md | 2 +- problems/palindrome-permutation-ii/README.md | 12 +- problems/palindrome-permutation/README.md | 17 +- problems/palindrome-removal/README.md | 27 +- problems/pancake-sorting/README.md | 4 +- problems/parallel-courses-ii/README.md | 3 + problems/parallel-courses/README.md | 44 +- problems/parse-lisp-expression/README.md | 106 +- .../parsing-a-boolean-expression/README.md | 2 + .../partition-array-for-maximum-sum/README.md | 1 + .../README.md | 1 + problems/partition-equal-subset-sum/README.md | 1 + problems/partition-labels/README.md | 31 +- .../README.md | 6 +- .../README.md | 1 + problems/pascals-triangle-ii/README.md | 1 + problems/pascals-triangle/README.md | 1 + problems/patching-array/README.md | 1 + problems/path-crossing/README.md | 1 + .../README.md | 1 + problems/path-sum-ii/README.md | 4 +- problems/path-sum-iii/README.md | 2 + problems/path-sum-iv/README.md | 45 +- problems/path-sum/README.md | 3 +- problems/path-with-maximum-gold/README.md | 2 + .../path-with-maximum-minimum-value/README.md | 49 +- .../path-with-maximum-probability/README.md | 2 + problems/path-with-minimum-effort/README.md | 7 +- problems/patients-with-a-condition/README.md | 3 + .../peak-index-in-a-mountain-array/README.md | 1 + problems/peeking-iterator/README.md | 2 + .../README.md | 3 +- .../README.md | 3 + problems/perfect-rectangle/README.md | 1 + problems/perfect-squares/README.md | 2 +- problems/perform-string-shifts/README.md | 1 + problems/permutation-in-string/README.md | 2 + problems/permutation-sequence/README.md | 2 +- problems/permutations-ii/README.md | 1 + problems/permutations/README.md | 1 + problems/pizza-with-3n-slices/README.md | 3 + problems/plus-one-linked-list/README.md | 14 +- problems/plus-one/README.md | 1 + problems/poor-pigs/README.md | 2 + .../README.md | 4 +- .../README.md | 5 +- problems/positions-of-large-groups/README.md | 2 +- problems/possible-bipartition/README.md | 4 +- problems/pour-water/README.md | 123 +- problems/power-of-four/README.md | 2 + problems/power-of-three/README.md | 1 + problems/power-of-two/README.md | 1 + problems/powx-n/README.md | 2 +- problems/predict-the-winner/README.md | 5 +- problems/prefix-and-suffix-search/README.md | 2 + .../README.md | 1 + .../README.md | 3 + .../README.md | 37 +- problems/print-binary-tree/README.md | 3 + problems/print-foobar-alternately/README.md | 3 + .../README.md | 41 +- problems/print-in-order/README.md | 3 + problems/print-words-vertically/README.md | 2 + problems/print-zero-even-odd/README.md | 59 +- problems/prison-cells-after-n-days/README.md | 3 + .../README.md | 3 + .../process-tasks-using-servers/README.md | 3 +- .../product-of-array-except-self/README.md | 1 + .../product-of-the-last-k-numbers/README.md | 5 +- .../README.md | 3 +- .../product-price-at-a-given-date/README.md | 41 +- problems/product-sales-analysis-i/README.md | 63 +- problems/product-sales-analysis-ii/README.md | 61 +- problems/product-sales-analysis-iii/README.md | 62 +- .../products-price-for-each-store/README.md | 3 + .../products-worth-over-invoices/README.md | 3 + problems/profitable-schemes/README.md | 1 + problems/project-employees-i/README.md | 63 +- problems/project-employees-ii/README.md | 61 +- problems/project-employees-iii/README.md | 63 +- .../projection-area-of-3d-shapes/README.md | 3 + .../README.md | 4 +- problems/push-dominoes/README.md | 1 + .../put-boxes-into-the-warehouse-i/README.md | 2 + .../put-boxes-into-the-warehouse-ii/README.md | 2 + problems/pyramid-transition-matrix/README.md | 3 +- .../queens-that-can-attack-the-king/README.md | 2 + .../README.md | 2 + .../README.md | 2 + .../queries-quality-and-percentage/README.md | 64 +- .../queue-reconstruction-by-height/README.md | 2 + problems/rabbits-in-forest/README.md | 33 +- problems/race-car/README.md | 1 - problems/random-flip-matrix/README.md | 5 +- problems/random-pick-index/README.md | 3 + problems/random-pick-with-blacklist/README.md | 5 +- problems/random-pick-with-weight/README.md | 4 +- .../README.md | 6 +- problems/range-addition-ii/README.md | 1 + problems/range-addition/README.md | 28 +- problems/range-module/README.md | 59 +- problems/range-sum-of-bst/README.md | 5 +- .../README.md | 14 +- .../range-sum-query-2d-immutable/README.md | 5 +- problems/range-sum-query-2d-mutable/README.md | 32 +- problems/range-sum-query-immutable/README.md | 4 +- problems/range-sum-query-mutable/README.md | 2 + problems/rank-scores/README.md | 3 + problems/rank-teams-by-votes/README.md | 8 +- problems/rank-transform-of-a-matrix/README.md | 4 + problems/rank-transform-of-an-array/README.md | 2 + problems/ransom-note/README.md | 2 + problems/reach-a-number/README.md | 56 +- .../README.md | 5 +- problems/reaching-points/README.md | 28 +- .../README.md | 82 +- .../read-n-characters-given-read4/README.md | 92 +- problems/rearrange-products-table/README.md | 3 + .../README.md | 34 +- .../rearrange-words-in-a-sentence/README.md | 2 +- .../README.md | 3 +- problems/reconstruct-itinerary/README.md | 3 +- .../README.md | 2 + .../README.md | 4 +- problems/recover-binary-search-tree/README.md | 6 +- problems/rectangle-area-ii/README.md | 2 + problems/rectangle-area/README.md | 1 + problems/rectangle-overlap/README.md | 4 +- problems/rectangles-area/README.md | 3 + .../recyclable-and-low-fat-products/README.md | 3 + .../README.md | 62 + .../reduce-array-size-to-the-half/README.md | 11 +- problems/reducing-dishes/README.md | 3 + .../README.md | 77 ++ problems/redundant-connection-ii/README.md | 4 +- problems/redundant-connection/README.md | 3 +- problems/reformat-department-table/README.md | 3 + problems/regions-cut-by-slashes/README.md | 3 +- .../regular-expression-matching/README.md | 2 +- problems/relative-ranks/README.md | 5 + problems/relative-sort-array/README.md | 4 +- problems/remove-9/README.md | 14 - .../README.md | 1 + .../README.md | 1 + .../README.md | 71 ++ problems/remove-boxes/README.md | 3 +- problems/remove-comments/README.md | 104 +- problems/remove-covered-intervals/README.md | 5 +- problems/remove-duplicate-letters/README.md | 6 +- .../README.md | 3 +- .../README.md | 39 +- .../README.md | 41 +- .../README.md | 1 + problems/remove-element/README.md | 47 +- problems/remove-interval/README.md | 23 +- problems/remove-invalid-parentheses/README.md | 5 +- problems/remove-k-digits/README.md | 4 +- .../remove-linked-list-elements/README.md | 3 +- .../README.md | 1 + .../README.md | 5 +- .../README.md | 77 ++ .../remove-outermost-parentheses/README.md | 55 +- .../remove-palindromic-subsequences/README.md | 1 + .../README.md | 1 + .../remove-vowels-from-a-string/README.md | 25 - .../README.md | 1 + problems/reorder-data-in-log-files/README.md | 2 + problems/reorder-list/README.md | 3 + .../README.md | 5 +- problems/reordered-power-of-2/README.md | 3 + problems/reorganize-string/README.md | 36 +- problems/repeated-dna-sequences/README.md | 4 + problems/repeated-string-match/README.md | 1 + problems/repeated-substring-pattern/README.md | 1 + .../README.md | 66 +- .../README.md | 2 +- problems/replace-words/README.md | 2 + problems/report-contiguous-dates/README.md | 74 +- problems/reported-posts-ii/README.md | 73 +- problems/reported-posts/README.md | 50 +- problems/reshape-the-matrix/README.md | 10 +- problems/restaurant-growth/README.md | 59 +- .../README.md | 3 +- problems/restore-the-array/README.md | 1 + .../README.md | 3 + problems/reverse-bits/README.md | 1 + problems/reverse-linked-list/README.md | 1 + problems/reverse-nodes-in-k-group/README.md | 1 + problems/reverse-only-letters/README.md | 1 + problems/reverse-pairs/README.md | 4 +- problems/reverse-string-ii/README.md | 1 + problems/reverse-string/README.md | 1 + .../README.md | 1 + .../README.md | 1 + .../reverse-words-in-a-string-ii/README.md | 17 +- .../reverse-words-in-a-string-iii/README.md | 1 + problems/reverse-words-in-a-string/README.md | 3 +- problems/richest-customer-wealth/README.md | 1 + problems/rising-temperature/README.md | 3 + problems/rle-iterator/README.md | 3 + problems/robot-bounded-in-circle/README.md | 2 + problems/robot-return-to-origin/README.md | 1 + problems/robot-room-cleaner/README.md | 57 +- problems/roman-to-integer/README.md | 1 + problems/rotate-array/README.md | 2 + problems/rotate-function/README.md | 7 +- problems/rotate-image/README.md | 2 + problems/rotate-string/README.md | 4 + problems/rotated-digits/README.md | 3 +- problems/rotating-the-box/README.md | 1 + problems/rotting-oranges/README.md | 4 +- problems/running-sum-of-1d-array/README.md | 1 + .../README.md | 62 +- problems/russian-doll-envelopes/README.md | 2 + problems/sales-analysis-i/README.md | 64 +- problems/sales-analysis-ii/README.md | 63 +- problems/sales-analysis-iii/README.md | 63 +- problems/sales-by-day-of-the-week/README.md | 3 + problems/sales-person/README.md | 67 +- problems/same-tree/README.md | 4 +- .../README.md | 2 + .../score-after-flipping-matrix/README.md | 3 + problems/search-a-2d-matrix-ii/README.md | 2 + problems/search-a-2d-matrix/README.md | 1 + .../search-in-a-binary-search-tree/README.md | 2 + .../README.md | 28 +- problems/search-suggestions-system/README.md | 2 + problems/seat-reservation-manager/README.md | 2 +- problems/second-degree-follower/README.md | 35 +- problems/second-highest-salary/README.md | 3 + .../README.md | 1 + .../README.md | 2 + problems/self-crossing/README.md | 2 + .../README.md | 5 +- problems/sellers-with-no-sales/README.md | 3 + problems/sentence-screen-fitting/README.md | 67 +- problems/sentence-similarity-ii/README.md | 27 +- problems/sentence-similarity-iii/README.md | 2 + problems/sentence-similarity/README.md | 23 +- problems/sequence-reconstruction/README.md | 55 +- problems/sequential-digits/README.md | 2 +- .../README.md | 4 + .../serialize-and-deserialize-bst/README.md | 6 + .../README.md | 24 +- .../README.md | 2 + problems/set-matrix-zeroes/README.md | 21 +- problems/set-mismatch/README.md | 4 +- problems/shift-2d-grid/README.md | 2 + problems/shifting-letters/README.md | 1 + problems/shopping-offers/README.md | 6 +- problems/short-encoding-of-words/README.md | 6 + problems/shortest-bridge/README.md | 6 +- .../shortest-common-supersequence/README.md | 1 + problems/shortest-completing-word/README.md | 1 + .../README.md | 30 +- .../shortest-distance-in-a-line/README.md | 32 +- .../shortest-distance-in-a-plane/README.md | 29 +- .../README.md | 5 + .../README.md | 36 +- problems/shortest-palindrome/README.md | 3 + .../README.md | 4 +- .../shortest-path-in-a-hidden-grid/README.md | 5 +- .../shortest-path-in-binary-matrix/README.md | 4 +- .../shortest-path-to-get-all-keys/README.md | 4 +- problems/shortest-path-to-get-food/README.md | 6 +- .../README.md | 5 +- .../README.md | 2 +- .../README.md | 3 + .../README.md | 5 + .../README.md | 5 + .../shortest-way-to-form-string/README.md | 38 +- problems/shortest-word-distance-ii/README.md | 16 +- problems/shortest-word-distance-iii/README.md | 19 +- problems/shortest-word-distance/README.md | 17 +- problems/shuffle-an-array/README.md | 13 +- problems/shuffle-string/README.md | 3 +- .../sign-of-the-product-of-an-array/README.md | 1 + problems/similar-rgb-color/README.md | 25 +- problems/similar-string-groups/README.md | 5 +- .../README.md | 1 + problems/single-number-ii/README.md | 1 + problems/single-number-iii/README.md | 1 + problems/single-number/README.md | 2 +- problems/single-row-keyboard/README.md | 32 +- problems/single-threaded-cpu/README.md | 4 +- problems/sliding-puzzle/README.md | 32 +- problems/sliding-window-maximum/README.md | 5 +- problems/sliding-window-median/README.md | 3 + problems/slowest-key/README.md | 1 + problems/smallest-common-region/README.md | 37 +- .../smallest-integer-divisible-by-k/README.md | 1 + .../README.md | 7 +- problems/smallest-range-i/README.md | 1 + problems/smallest-range-ii/README.md | 2 + .../README.md | 18 +- .../README.md | 4 + .../README.md | 4 +- .../README.md | 1 + problems/smallest-string-with-swaps/README.md | 5 +- .../README.md | 1 + .../README.md | 7 +- problems/smallest-sufficient-team/README.md | 2 + problems/snakes-and-ladders/README.md | 76 +- problems/snapshot-array/README.md | 3 + problems/solve-the-equation/README.md | 2 + problems/sort-an-array/README.md | 10 + .../README.md | 3 +- problems/sort-array-by-parity-ii/README.md | 3 +- problems/sort-array-by-parity/README.md | 2 + .../sort-characters-by-frequency/README.md | 6 +- problems/sort-colors/README.md | 2 +- .../sort-features-by-popularity/README.md | 4 +- .../README.md | 4 +- .../README.md | 5 +- .../README.md | 5 +- problems/sort-list/README.md | 5 +- problems/sort-the-matrix-diagonally/README.md | 3 +- problems/sort-transformed-array/README.md | 23 +- problems/sorting-the-sentence/README.md | 2 +- problems/soup-servings/README.md | 2 + .../sparse-matrix-multiplication/README.md | 27 +- .../README.md | 2 + problems/special-binary-string/README.md | 41 +- .../README.md | 1 + problems/spiral-matrix-ii/README.md | 2 + problems/spiral-matrix-iii/README.md | 4 +- problems/spiral-matrix/README.md | 2 + .../README.md | 1 + .../README.md | 2 + .../README.md | 4 +- .../README.md | 1 - problems/split-array-largest-sum/README.md | 2 + problems/split-array-with-equal-sum/README.md | 27 +- .../split-array-with-same-average/README.md | 4 + problems/split-bst/README.md | 38 +- problems/split-concatenated-strings/README.md | 27 +- problems/split-linked-list-in-parts/README.md | 63 +- .../README.md | 1 - problems/squares-of-a-sorted-array/README.md | 1 + problems/stamping-the-sequence/README.md | 2 + .../statistics-from-a-large-sample/README.md | 1 + problems/stepping-numbers/README.md | 15 +- problems/stickers-to-spell-word/README.md | 2 + problems/stone-game-ii/README.md | 3 + problems/stone-game-iii/README.md | 7 +- problems/stone-game-iv/README.md | 2 + problems/stone-game-v/README.md | 3 + problems/stone-game-vi/README.md | 5 + problems/stone-game-vii/README.md | 3 + problems/stone-game-viii/README.md | 4 + problems/stone-game/README.md | 3 +- problems/strange-printer-ii/README.md | 5 +- problems/strange-printer/README.md | 2 +- problems/stream-of-characters/README.md | 4 + problems/string-compression/README.md | 1 + .../string-matching-in-an-array/README.md | 1 + problems/string-to-integer-atoi/README.md | 1 - .../README.md | 34 +- problems/string-without-aaa-or-bbb/README.md | 1 + .../strings-differ-by-one-character/README.md | 6 + problems/strobogrammatic-number-ii/README.md | 12 +- problems/strobogrammatic-number-iii/README.md | 15 +- problems/strobogrammatic-number/README.md | 24 +- problems/strong-password-checker/README.md | 5 + problems/students-and-examinations/README.md | 98 +- .../students-report-by-geography/README.md | 31 +- .../README.md | 68 +- .../subarray-product-less-than-k/README.md | 8 +- problems/subarray-sum-equals-k/README.md | 1 + .../subarray-sums-divisible-by-k/README.md | 1 + .../README.md | 3 +- problems/subdomain-visit-count/README.md | 2 + problems/subrectangle-queries/README.md | 2 + problems/subsets-ii/README.md | 1 + .../README.md | 2 +- .../README.md | 3 + problems/subtree-of-another-tree/README.md | 4 + problems/sudoku-solver/README.md | 3 +- .../README.md | 3 +- .../sum-of-all-odd-length-subarrays/README.md | 1 + .../sum-of-all-subset-xor-totals/README.md | 3 +- .../sum-of-beauty-of-all-substrings/README.md | 1 + problems/sum-of-digits-in-base-k/README.md | 1 - .../README.md | 32 +- problems/sum-of-distances-in-tree/README.md | 4 +- .../README.md | 1 + problems/sum-of-floored-pairs/README.md | 3 + problems/sum-of-left-leaves/README.md | 3 + .../README.md | 1 + .../README.md | 4 +- .../README.md | 2 + .../README.md | 4 + problems/sum-of-square-numbers/README.md | 2 + problems/sum-of-subarray-minimums/README.md | 2 + problems/sum-of-subsequence-widths/README.md | 1 + problems/sum-of-two-integers/README.md | 1 + problems/sum-of-unique-elements/README.md | 1 + problems/sum-root-to-leaf-numbers/README.md | 3 +- problems/super-palindromes/README.md | 1 + problems/super-pow/README.md | 1 + problems/super-ugly-number/README.md | 5 +- problems/super-washing-machines/README.md | 4 +- problems/surface-area-of-3d-shapes/README.md | 2 + problems/surrounded-regions/README.md | 6 +- problems/suspicious-bank-accounts/README.md | 3 + problems/swap-adjacent-in-lr-string/README.md | 3 +- .../README.md | 1 + problems/swap-salary/README.md | 3 + .../swapping-nodes-in-a-linked-list/README.md | 1 + problems/swim-in-rising-water/README.md | 54 +- problems/symmetric-tree/README.md | 5 +- problems/synonymous-sentences/README.md | 32 +- problems/tallest-billboard/README.md | 1 + problems/target-sum/README.md | 3 +- problems/task-scheduler/README.md | 5 +- .../README.md | 77 +- problems/teemo-attacking/README.md | 1 + problems/tenth-line/README.md | 3 + problems/ternary-expression-parser/README.md | 54 +- problems/text-justification/README.md | 1 + problems/the-dining-philosophers/README.md | 3 + .../README.md | 82 ++ .../README.md | 39 +- .../README.md | 3 +- .../README.md | 1 + .../the-k-weakest-rows-in-a-matrix/README.md | 3 + problems/the-latest-login-in-2020/README.md | 17 + .../mysql_schemas.sql | 11 + problems/the-maze-ii/README.md | 63 +- problems/the-maze-iii/README.md | 67 +- problems/the-maze/README.md | 60 +- .../README.md | 3 + .../README.md | 3 + .../the-most-recent-three-orders/README.md | 3 + .../README.md | 3 + .../README.md | 77 ++ problems/the-skyline-problem/README.md | 4 +- problems/third-maximum-number/README.md | 1 + problems/three-equal-parts/README.md | 3 +- problems/throne-inheritance/README.md | 2 + problems/time-based-key-value-store/README.md | 72 +- .../README.md | 4 +- problems/toeplitz-matrix/README.md | 1 + problems/top-k-frequent-elements/README.md | 8 +- problems/top-k-frequent-words/README.md | 6 +- problems/top-travellers/README.md | 75 +- problems/toss-strange-coins/README.md | 23 +- problems/total-hamming-distance/README.md | 2 + problems/total-sales-amount-by-year/README.md | 67 +- problems/tournament-winners/README.md | 75 +- .../README.md | 60 +- problems/transform-to-chessboard/README.md | 53 +- problems/transpose-file/README.md | 3 + problems/transpose-matrix/README.md | 2 + problems/trapping-rain-water-ii/README.md | 6 +- problems/trapping-rain-water/README.md | 1 + problems/tree-diameter/README.md | 39 +- problems/tree-node/README.md | 62 +- problems/tree-of-coprimes/README.md | 4 +- problems/triangle-judgement/README.md | 23 +- problems/trim-a-binary-search-tree/README.md | 4 +- .../README.md | 4 +- problems/trips-and-users/README.md | 3 + problems/truncate-sentence/README.md | 1 + problems/tweet-counts-per-frequency/README.md | 4 + problems/two-city-scheduling/README.md | 2 + problems/two-sum-bsts/README.md | 37 +- .../README.md | 21 +- problems/two-sum-iv-input-is-a-bst/README.md | 6 + problems/two-sum-less-than-k/README.md | 33 +- problems/ugly-number-ii/README.md | 3 +- problems/ugly-number-iii/README.md | 1 + .../README.md | 48 +- problems/uncrossed-lines/README.md | 1 + .../unique-binary-search-trees-ii/README.md | 3 + problems/unique-binary-search-trees/README.md | 3 + problems/unique-email-addresses/README.md | 2 + problems/unique-morse-code-words/README.md | 2 + .../unique-number-of-occurrences/README.md | 1 + .../README.md | 3 + problems/unique-paths-ii/README.md | 1 + problems/unique-paths-iii/README.md | 4 +- problems/unique-paths/README.md | 3 +- .../README.md | 1 + problems/unique-word-abbreviation/README.md | 33 +- problems/univalued-binary-tree/README.md | 3 + problems/unpopular-books/README.md | 68 +- .../README.md | 50 +- .../README.md | 50 +- problems/user-purchase-platform/README.md | 46 +- problems/utf-8-validation/README.md | 1 + problems/valid-anagram/README.md | 3 +- problems/valid-boomerang/README.md | 1 + problems/valid-number/README.md | 1 - problems/valid-palindrome-ii/README.md | 2 + problems/valid-palindrome-iii/README.md | 20 - problems/valid-parenthesis-string/README.md | 3 + .../README.md | 1 - problems/valid-phone-numbers/README.md | 3 + problems/valid-square/README.md | 1 + problems/valid-sudoku/README.md | 2 + problems/valid-tic-tac-toe-state/README.md | 4 +- problems/valid-triangle-number/README.md | 4 + problems/valid-word-abbreviation/README.md | 30 +- problems/valid-word-square/README.md | 78 +- .../validate-binary-search-tree/README.md | 5 +- problems/validate-binary-tree-nodes/README.md | 5 + problems/validate-stack-sequences/README.md | 2 + problems/verbal-arithmetic-puzzle/README.md | 2 + .../README.md | 30 +- .../README.md | 3 + .../verifying-an-alien-dictionary/README.md | 2 + .../README.md | 5 +- problems/video-stitching/README.md | 2 + problems/vowel-spellchecker/README.md | 1 + problems/walking-robot-simulation/README.md | 3 +- problems/walls-and-gates/README.md | 32 +- problems/warehouse-manager/README.md | 3 + problems/water-and-jug-problem/README.md | 2 + problems/water-bottles/README.md | 3 +- problems/ways-to-make-a-fair-array/README.md | 2 +- .../README.md | 2 + .../weather-type-in-each-country/README.md | 83 +- problems/web-crawler-multithreaded/README.md | 97 +- problems/web-crawler/README.md | 85 +- problems/where-will-the-ball-fall/README.md | 4 + .../README.md | 3 +- problems/wiggle-sort-ii/README.md | 5 +- problems/wiggle-sort/README.md | 9 +- problems/wiggle-subsequence/README.md | 1 + problems/wildcard-matching/README.md | 2 +- problems/winning-candidate/README.md | 47 +- problems/word-abbreviation/README.md | 27 +- problems/word-break-ii/README.md | 4 + problems/word-break/README.md | 4 + problems/word-frequency/README.md | 3 + problems/word-ladder-ii/README.md | 4 +- problems/word-ladder/README.md | 4 +- problems/word-pattern-ii/README.md | 26 +- problems/word-pattern/README.md | 1 + problems/word-search-ii/README.md | 3 + problems/word-search/README.md | 1 + problems/word-squares/README.md | 70 +- problems/word-subsets/README.md | 2 + .../x-of-a-kind-in-a-deck-of-cards/README.md | 3 + problems/xor-operation-in-an-array/README.md | 2 +- problems/xor-queries-of-a-subarray/README.md | 2 + problems/zigzag-iterator/README.md | 29 +- problems/zuma-game/README.md | 48 +- readme/1201-1500.md | 2 +- readme/301-600.md | 2 +- readme/601-900.md | 4 +- tag/array/README.md | 1117 +++++++++++++---- tag/backtracking/README.md | 148 +-- tag/binary-indexed-tree/README.md | 20 +- tag/binary-search-tree/README.md | 44 +- tag/binary-search/README.md | 217 ++-- tag/bit-manipulation/README.md | 158 ++- tag/brainteaser/README.md | 13 +- tag/breadth-first-search/README.md | 242 ++-- tag/depth-first-search/README.md | 360 +++--- tag/design/README.md | 153 ++- tag/divide-and-conquer/README.md | 55 +- tag/dynamic-programming/README.md | 498 ++++---- tag/geometry/README.md | 31 +- tag/graph/README.md | 112 +- tag/greedy/README.md | 352 +++--- tag/hash-table/README.md | 455 ++++--- tag/heap/README.md | 48 - tag/line-sweep/README.md | 13 +- tag/linked-list/README.md | 70 +- tag/math/README.md | 436 ++++--- tag/memoization/README.md | 27 +- tag/minimax/README.md | 8 - tag/ordered-map/README.md | 15 - tag/queue/README.md | 41 +- tag/random/README.md | 6 - tag/recursion/README.md | 74 +- tag/rejection-sampling/README.md | 4 +- tag/reservoir-sampling/README.md | 6 +- tag/rolling-hash/README.md | 12 + tag/segment-tree/README.md | 35 +- tag/sliding-window/README.md | 88 +- tag/sort/README.md | 83 -- tag/stack/README.md | 157 ++- tag/string/README.md | 574 ++++++--- tag/suffix-array/README.md | 4 + tag/tags.json | 194 ++- tag/topological-sort/README.md | 21 +- tag/tree/README.md | 325 ++--- tag/trie/README.md | 60 +- tag/two-pointers/README.md | 190 ++- tag/union-find/README.md | 88 +- 1787 files changed, 11988 insertions(+), 15819 deletions(-) create mode 100644 problems/build-array-from-permutation/README.md create mode 100644 problems/check-if-all-the-integers-in-a-range-are-covered/README.md create mode 100644 problems/count-good-numbers/README.md create mode 100644 problems/count-pairs-in-two-arrays/README.md create mode 100644 problems/count-salary-categories/README.md create mode 100644 problems/count-salary-categories/mysql_schemas.sql create mode 100644 problems/count-sub-islands/README.md create mode 100644 problems/count-ways-to-build-rooms-in-an-ant-colony/README.md create mode 100644 problems/cutting-ribbons/README.md create mode 100644 problems/cyclically-rotating-a-grid/README.md create mode 100644 problems/depth-of-bst-given-insertion-order/README.md create mode 100644 problems/design-movie-rental-system/README.md create mode 100644 problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md create mode 100644 problems/egg-drop-with-2-eggs-and-n-floors/README.md create mode 100644 problems/eliminate-maximum-number-of-monsters/README.md create mode 100644 problems/erect-the-fence-ii/README.md create mode 100644 problems/find-a-peak-element-ii/README.md create mode 100644 problems/find-the-student-that-will-replace-the-chalk/README.md create mode 100644 problems/game-of-nim/README.md create mode 100644 problems/kth-smallest-subarray-sum/README.md create mode 100644 problems/largest-magic-square/README.md create mode 100644 problems/largest-odd-number-in-string/README.md create mode 100644 problems/last-person-to-fit-in-the-bus/README.md create mode 100644 problems/last-person-to-fit-in-the-bus/mysql_schemas.sql create mode 100644 problems/leetcodify-friends-recommendations/README.md create mode 100644 problems/leetcodify-friends-recommendations/mysql_schemas.sql create mode 100644 problems/leetcodify-similar-friends/README.md create mode 100644 problems/leetcodify-similar-friends/mysql_schemas.sql create mode 100644 problems/longest-common-subpath/README.md create mode 100644 problems/maximum-alternating-subsequence-sum/README.md create mode 100644 problems/maximum-number-of-removable-characters/README.md create mode 100644 problems/maximum-product-difference-between-two-pairs/README.md create mode 100644 problems/merge-triplets-to-form-target-triplet/README.md create mode 100644 problems/minimum-absolute-difference-queries/README.md create mode 100644 problems/minimum-cost-to-change-the-final-value-of-expression/README.md create mode 100644 problems/minimum-number-of-flips-to-make-the-binary-string-alternating/README.md create mode 100644 problems/minimum-space-wasted-from-packaging/README.md create mode 100644 problems/number-of-wonderful-substrings/README.md create mode 100644 problems/page-recommendations-ii/README.md create mode 100644 problems/page-recommendations-ii/mysql_schemas.sql create mode 100644 problems/redistribute-characters-to-make-all-strings-equal/README.md create mode 100644 problems/reduction-operations-to-make-the-array-elements-equal/README.md create mode 100644 problems/remove-all-occurrences-of-a-substring/README.md create mode 100644 problems/remove-one-element-to-make-the-array-strictly-increasing/README.md create mode 100644 problems/the-earliest-and-latest-rounds-where-players-compete/README.md create mode 100644 problems/the-latest-login-in-2020/README.md create mode 100644 problems/the-latest-login-in-2020/mysql_schemas.sql create mode 100644 problems/the-number-of-full-rounds-you-have-played/README.md diff --git a/README.md b/README.md index 49cee62ab..a67ad251b 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,47 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1924 | [Erect the Fence II](https://leetcode.com/problems/erect-the-fence-ii) 🔒 | [Go](problems/erect-the-fence-ii) | Hard | +| 1923 | [Longest Common Subpath](https://leetcode.com/problems/longest-common-subpath "最长公共子路径") | [Go](problems/longest-common-subpath) | Hard | +| 1922 | [Count Good Numbers](https://leetcode.com/problems/count-good-numbers "统计好数字的数目") | [Go](problems/count-good-numbers) | Medium | +| 1921 | [Eliminate Maximum Number of Monsters](https://leetcode.com/problems/eliminate-maximum-number-of-monsters "消灭怪物的最大数量") | [Go](problems/eliminate-maximum-number-of-monsters) | Medium | +| 1920 | [Build Array from Permutation](https://leetcode.com/problems/build-array-from-permutation "基于排列构建数组") | [Go](problems/build-array-from-permutation) | Easy | +| 1919 | [Leetcodify Similar Friends](https://leetcode.com/problems/leetcodify-similar-friends) 🔒 | [MySQL](problems/leetcodify-similar-friends) | Hard | +| 1918 | [Kth Smallest Subarray Sum](https://leetcode.com/problems/kth-smallest-subarray-sum) 🔒 | [Go](problems/kth-smallest-subarray-sum) | Medium | +| 1917 | [Leetcodify Friends Recommendations](https://leetcode.com/problems/leetcodify-friends-recommendations) 🔒 | [MySQL](problems/leetcodify-friends-recommendations) | Hard | +| 1916 | [Count Ways to Build Rooms in an Ant Colony](https://leetcode.com/problems/count-ways-to-build-rooms-in-an-ant-colony "统计为蚁群构筑房间的不同顺序") | [Go](problems/count-ways-to-build-rooms-in-an-ant-colony) | Hard | +| 1915 | [Number of Wonderful Substrings](https://leetcode.com/problems/number-of-wonderful-substrings "最美子字符串的数目") | [Go](problems/number-of-wonderful-substrings) | Medium | +| 1914 | [Cyclically Rotating a Grid](https://leetcode.com/problems/cyclically-rotating-a-grid "循环轮转矩阵") | [Go](problems/cyclically-rotating-a-grid) | Medium | +| 1913 | [Maximum Product Difference Between Two Pairs](https://leetcode.com/problems/maximum-product-difference-between-two-pairs "两个数对之间的最大乘积差") | [Go](problems/maximum-product-difference-between-two-pairs) | Easy | +| 1912 | [Design Movie Rental System](https://leetcode.com/problems/design-movie-rental-system "设计电影租借系统") | [Go](problems/design-movie-rental-system) | Hard | +| 1911 | [Maximum Alternating Subsequence Sum](https://leetcode.com/problems/maximum-alternating-subsequence-sum "最大子序列交替和") | [Go](problems/maximum-alternating-subsequence-sum) | Medium | +| 1910 | [Remove All Occurrences of a Substring](https://leetcode.com/problems/remove-all-occurrences-of-a-substring "删除一个字符串中所有出现的给定子字符串") | [Go](problems/remove-all-occurrences-of-a-substring) | Medium | +| 1909 | [Remove One Element to Make the Array Strictly Increasing](https://leetcode.com/problems/remove-one-element-to-make-the-array-strictly-increasing "删除一个元素使数组严格递增") | [Go](problems/remove-one-element-to-make-the-array-strictly-increasing) | Easy | +| 1908 | [Game of Nim](https://leetcode.com/problems/game-of-nim) 🔒 | [Go](problems/game-of-nim) | Medium | +| 1907 | [Count Salary Categories](https://leetcode.com/problems/count-salary-categories "按分类统计薪水") 🔒 | [MySQL](problems/count-salary-categories) | Medium | +| 1906 | [Minimum Absolute Difference Queries](https://leetcode.com/problems/minimum-absolute-difference-queries "查询差绝对值的最小值") | [Go](problems/minimum-absolute-difference-queries) | Medium | +| 1905 | [Count Sub Islands](https://leetcode.com/problems/count-sub-islands "统计子岛屿") | [Go](problems/count-sub-islands) | Medium | +| 1904 | [The Number of Full Rounds You Have Played](https://leetcode.com/problems/the-number-of-full-rounds-you-have-played "你完成的完整对局数") | [Go](problems/the-number-of-full-rounds-you-have-played) | Medium | +| 1903 | [Largest Odd Number in String](https://leetcode.com/problems/largest-odd-number-in-string "字符串中的最大奇数") | [Go](problems/largest-odd-number-in-string) | Easy | +| 1902 | [Depth of BST Given Insertion Order](https://leetcode.com/problems/depth-of-bst-given-insertion-order) 🔒 | [Go](problems/depth-of-bst-given-insertion-order) | Medium | +| 1901 | [Find a Peak Element II](https://leetcode.com/problems/find-a-peak-element-ii "找出顶峰元素 II") | [Go](problems/find-a-peak-element-ii) | Medium | +| 1900 | [The Earliest and Latest Rounds Where Players Compete](https://leetcode.com/problems/the-earliest-and-latest-rounds-where-players-compete "最佳运动员的比拼回合") | [Go](problems/the-earliest-and-latest-rounds-where-players-compete) | Hard | +| 1899 | [Merge Triplets to Form Target Triplet](https://leetcode.com/problems/merge-triplets-to-form-target-triplet "合并若干三元组以形成目标三元组") | [Go](problems/merge-triplets-to-form-target-triplet) | Medium | +| 1898 | [Maximum Number of Removable Characters](https://leetcode.com/problems/maximum-number-of-removable-characters "可移除字符的最大数目") | [Go](problems/maximum-number-of-removable-characters) | Medium | +| 1897 | [Redistribute Characters to Make All Strings Equal](https://leetcode.com/problems/redistribute-characters-to-make-all-strings-equal "重新分配字符使所有字符串都相等") | [Go](problems/redistribute-characters-to-make-all-strings-equal) | Easy | +| 1896 | [Minimum Cost to Change the Final Value of Expression](https://leetcode.com/problems/minimum-cost-to-change-the-final-value-of-expression "反转表达式值的最少操作次数") | [Go](problems/minimum-cost-to-change-the-final-value-of-expression) | Hard | +| 1895 | [Largest Magic Square](https://leetcode.com/problems/largest-magic-square "最大的幻方") | [Go](problems/largest-magic-square) | Medium | +| 1894 | [Find the Student that Will Replace the Chalk](https://leetcode.com/problems/find-the-student-that-will-replace-the-chalk "找到需要补充粉笔的学生编号") | [Go](problems/find-the-student-that-will-replace-the-chalk) | Medium | +| 1893 | [Check if All the Integers in a Range Are Covered](https://leetcode.com/problems/check-if-all-the-integers-in-a-range-are-covered "检查是否区域内所有整数都被覆盖") | [Go](problems/check-if-all-the-integers-in-a-range-are-covered) | Easy | +| 1892 | [Page Recommendations II](https://leetcode.com/problems/page-recommendations-ii "页面推荐Ⅱ") 🔒 | [MySQL](problems/page-recommendations-ii) | Hard | +| 1891 | [Cutting Ribbons](https://leetcode.com/problems/cutting-ribbons "割绳子") 🔒 | [Go](problems/cutting-ribbons) | Medium | +| 1890 | [The Latest Login in 2020](https://leetcode.com/problems/the-latest-login-in-2020 "2020年最后一次登录") 🔒 | [MySQL](problems/the-latest-login-in-2020) | Easy | +| 1889 | [Minimum Space Wasted From Packaging](https://leetcode.com/problems/minimum-space-wasted-from-packaging "装包裹的最小浪费空间") | [Go](problems/minimum-space-wasted-from-packaging) | Hard | +| 1888 | [Minimum Number of Flips to Make the Binary String Alternating](https://leetcode.com/problems/minimum-number-of-flips-to-make-the-binary-string-alternating "使二进制字符串字符交替的最少反转次数") | [Go](problems/minimum-number-of-flips-to-make-the-binary-string-alternating) | Medium | +| 1887 | [Reduction Operations to Make the Array Elements Equal](https://leetcode.com/problems/reduction-operations-to-make-the-array-elements-equal "使数组元素相等的减少操作次数") | [Go](problems/reduction-operations-to-make-the-array-elements-equal) | Medium | +| 1886 | [Determine Whether Matrix Can Be Obtained By Rotation](https://leetcode.com/problems/determine-whether-matrix-can-be-obtained-by-rotation "判断矩阵经轮转后是否一致") | [Go](problems/determine-whether-matrix-can-be-obtained-by-rotation) | Easy | +| 1885 | [Count Pairs in Two Arrays](https://leetcode.com/problems/count-pairs-in-two-arrays) 🔒 | [Go](problems/count-pairs-in-two-arrays) | Medium | +| 1884 | [Egg Drop With 2 Eggs and N Floors](https://leetcode.com/problems/egg-drop-with-2-eggs-and-n-floors "鸡蛋掉落-两枚鸡蛋") | [Go](problems/egg-drop-with-2-eggs-and-n-floors) | Medium | | 1883 | [Minimum Skips to Arrive at Meeting On Time](https://leetcode.com/problems/minimum-skips-to-arrive-at-meeting-on-time "准时抵达会议现场的最小跳过休息次数") | [Go](problems/minimum-skips-to-arrive-at-meeting-on-time) | Hard | | 1882 | [Process Tasks Using Servers](https://leetcode.com/problems/process-tasks-using-servers "使用服务器处理任务") | [Go](problems/process-tasks-using-servers) | Medium | | 1881 | [Maximum Value after Insertion](https://leetcode.com/problems/maximum-value-after-insertion "插入后的最大值") | [Go](problems/maximum-value-after-insertion) | Medium | @@ -87,13 +128,13 @@ LeetCode Problems' Solutions | 1877 | [Minimize Maximum Pair Sum in Array](https://leetcode.com/problems/minimize-maximum-pair-sum-in-array "数组中最大数对和的最小值") | [Go](problems/minimize-maximum-pair-sum-in-array) | Medium | | 1876 | [Substrings of Size Three with Distinct Characters](https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters "长度为三且各字符不同的子字符串") | [Go](problems/substrings-of-size-three-with-distinct-characters) | Easy | | 1875 | [Group Employees of the Same Salary](https://leetcode.com/problems/group-employees-of-the-same-salary) 🔒 | [MySQL](problems/group-employees-of-the-same-salary) | Medium | -| 1874 | [Minimize Product Sum of Two Arrays](https://leetcode.com/problems/minimize-product-sum-of-two-arrays) 🔒 | [Go](problems/minimize-product-sum-of-two-arrays) | Medium | -| 1873 | [Calculate Special Bonus](https://leetcode.com/problems/calculate-special-bonus) 🔒 | [MySQL](problems/calculate-special-bonus) | Easy | +| 1874 | [Minimize Product Sum of Two Arrays](https://leetcode.com/problems/minimize-product-sum-of-two-arrays "两个数组的最小乘积和") 🔒 | [Go](problems/minimize-product-sum-of-two-arrays) | Medium | +| 1873 | [Calculate Special Bonus](https://leetcode.com/problems/calculate-special-bonus "计算特殊奖金") 🔒 | [MySQL](problems/calculate-special-bonus) | Easy | | 1872 | [Stone Game VIII](https://leetcode.com/problems/stone-game-viii "石子游戏 VIII") | [Go](problems/stone-game-viii) | Hard | | 1871 | [Jump Game VII](https://leetcode.com/problems/jump-game-vii "跳跃游戏 VII") | [Go](problems/jump-game-vii) | Medium | | 1870 | [Minimum Speed to Arrive on Time](https://leetcode.com/problems/minimum-speed-to-arrive-on-time "准时到达的列车最小时速") | [Go](problems/minimum-speed-to-arrive-on-time) | Medium | | 1869 | [Longer Contiguous Segments of Ones than Zeros](https://leetcode.com/problems/longer-contiguous-segments-of-ones-than-zeros "哪种连续子字符串更长") | [Go](problems/longer-contiguous-segments-of-ones-than-zeros) | Easy | -| 1868 | [Product of Two Run-Length Encoded Arrays](https://leetcode.com/problems/product-of-two-run-length-encoded-arrays) 🔒 | [Go](problems/product-of-two-run-length-encoded-arrays) | Medium | +| 1868 | [Product of Two Run-Length Encoded Arrays](https://leetcode.com/problems/product-of-two-run-length-encoded-arrays "两个行程编码数组的积") 🔒 | [Go](problems/product-of-two-run-length-encoded-arrays) | Medium | | 1867 | [Orders With Maximum Quantity Above Average](https://leetcode.com/problems/orders-with-maximum-quantity-above-average) 🔒 | [MySQL](problems/orders-with-maximum-quantity-above-average) | Medium | | 1866 | [Number of Ways to Rearrange Sticks With K Sticks Visible](https://leetcode.com/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible "恰有 K 根木棍可以看到的排列数目") | [Go](problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible) | Hard | | 1865 | [Finding Pairs With a Certain Sum](https://leetcode.com/problems/finding-pairs-with-a-certain-sum "找出和为指定值的下标对") | [Go](problems/finding-pairs-with-a-certain-sum) | Medium | @@ -103,13 +144,13 @@ LeetCode Problems' Solutions | 1861 | [Rotating the Box](https://leetcode.com/problems/rotating-the-box "旋转盒子") | [Go](problems/rotating-the-box) | Medium | | 1860 | [Incremental Memory Leak](https://leetcode.com/problems/incremental-memory-leak "增长的内存泄露") | [Go](problems/incremental-memory-leak) | Medium | | 1859 | [Sorting the Sentence](https://leetcode.com/problems/sorting-the-sentence "将句子排序") | [Go](problems/sorting-the-sentence) | Easy | -| 1858 | [Longest Word With All Prefixes](https://leetcode.com/problems/longest-word-with-all-prefixes) 🔒 | [Go](problems/longest-word-with-all-prefixes) | Medium | +| 1858 | [Longest Word With All Prefixes](https://leetcode.com/problems/longest-word-with-all-prefixes "包含所有前缀的最长单词") 🔒 | [Go](problems/longest-word-with-all-prefixes) | Medium | | 1857 | [Largest Color Value in a Directed Graph](https://leetcode.com/problems/largest-color-value-in-a-directed-graph "有向图中最大颜色值") | [Go](problems/largest-color-value-in-a-directed-graph) | Hard | | 1856 | [Maximum Subarray Min-Product](https://leetcode.com/problems/maximum-subarray-min-product "子数组最小乘积的最大值") | [Go](problems/maximum-subarray-min-product) | Medium | | 1855 | [Maximum Distance Between a Pair of Values](https://leetcode.com/problems/maximum-distance-between-a-pair-of-values "下标对中的最大距离") | [Go](problems/maximum-distance-between-a-pair-of-values) | Medium | | 1854 | [Maximum Population Year](https://leetcode.com/problems/maximum-population-year "人口最多的年份") | [Go](problems/maximum-population-year) | Easy | -| 1853 | [Convert Date Format](https://leetcode.com/problems/convert-date-format) 🔒 | [MySQL](problems/convert-date-format) | Easy | -| 1852 | [Distinct Numbers in Each Subarray](https://leetcode.com/problems/distinct-numbers-in-each-subarray) 🔒 | [Go](problems/distinct-numbers-in-each-subarray) | Medium | +| 1853 | [Convert Date Format](https://leetcode.com/problems/convert-date-format "转换日期格式") 🔒 | [MySQL](problems/convert-date-format) | Easy | +| 1852 | [Distinct Numbers in Each Subarray](https://leetcode.com/problems/distinct-numbers-in-each-subarray "每个子数组的数字种类数") 🔒 | [Go](problems/distinct-numbers-in-each-subarray) | Medium | | 1851 | [Minimum Interval to Include Each Query](https://leetcode.com/problems/minimum-interval-to-include-each-query "包含每个查询的最小区间") | [Go](problems/minimum-interval-to-include-each-query) | Hard | | 1850 | [Minimum Adjacent Swaps to Reach the Kth Smallest Number](https://leetcode.com/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number "邻位交换的最小次数") | [Go](problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number) | Medium | | 1849 | [Splitting a String Into Descending Consecutive Values](https://leetcode.com/problems/splitting-a-string-into-descending-consecutive-values "将字符串拆分为递减的连续值") | [Go](problems/splitting-a-string-into-descending-consecutive-values) | Medium | @@ -119,18 +160,18 @@ LeetCode Problems' Solutions | 1845 | [Seat Reservation Manager](https://leetcode.com/problems/seat-reservation-manager "座位预约管理系统") | [Go](problems/seat-reservation-manager) | Medium | | 1844 | [Replace All Digits with Characters](https://leetcode.com/problems/replace-all-digits-with-characters "将所有数字用字符替换") | [Go](problems/replace-all-digits-with-characters) | Easy | | 1843 | [Suspicious Bank Accounts](https://leetcode.com/problems/suspicious-bank-accounts) 🔒 | [MySQL](problems/suspicious-bank-accounts) | Medium | -| 1842 | [Next Palindrome Using Same Digits](https://leetcode.com/problems/next-palindrome-using-same-digits) 🔒 | [Go](problems/next-palindrome-using-same-digits) | Hard | +| 1842 | [Next Palindrome Using Same Digits](https://leetcode.com/problems/next-palindrome-using-same-digits "下个由相同数字构成的回文串") 🔒 | [Go](problems/next-palindrome-using-same-digits) | Hard | | 1841 | [League Statistics](https://leetcode.com/problems/league-statistics) 🔒 | [MySQL](problems/league-statistics) | Medium | | 1840 | [Maximum Building Height](https://leetcode.com/problems/maximum-building-height "最高建筑高度") | [Go](problems/maximum-building-height) | Hard | | 1839 | [Longest Substring Of All Vowels in Order](https://leetcode.com/problems/longest-substring-of-all-vowels-in-order "所有元音按顺序排布的最长子字符串") | [Go](problems/longest-substring-of-all-vowels-in-order) | Medium | | 1838 | [Frequency of the Most Frequent Element](https://leetcode.com/problems/frequency-of-the-most-frequent-element "最高频元素的频数") | [Go](problems/frequency-of-the-most-frequent-element) | Medium | | 1837 | [Sum of Digits in Base K](https://leetcode.com/problems/sum-of-digits-in-base-k "K 进制表示下的各位数字总和") | [Go](problems/sum-of-digits-in-base-k) | Easy | -| 1836 | [Remove Duplicates From an Unsorted Linked List](https://leetcode.com/problems/remove-duplicates-from-an-unsorted-linked-list) 🔒 | [Go](problems/remove-duplicates-from-an-unsorted-linked-list) | Medium | +| 1836 | [Remove Duplicates From an Unsorted Linked List](https://leetcode.com/problems/remove-duplicates-from-an-unsorted-linked-list "从未排序的链表中移除重复元素") 🔒 | [Go](problems/remove-duplicates-from-an-unsorted-linked-list) | Medium | | 1835 | [Find XOR Sum of All Pairs Bitwise AND](https://leetcode.com/problems/find-xor-sum-of-all-pairs-bitwise-and "所有数对按位与结果的异或和") | [Go](problems/find-xor-sum-of-all-pairs-bitwise-and) | Hard | | 1834 | [Single-Threaded CPU](https://leetcode.com/problems/single-threaded-cpu "单线程 CPU") | [Go](problems/single-threaded-cpu) | Medium | | 1833 | [Maximum Ice Cream Bars](https://leetcode.com/problems/maximum-ice-cream-bars "雪糕的最大数量") | [Go](problems/maximum-ice-cream-bars) | Medium | | 1832 | [Check if the Sentence Is Pangram](https://leetcode.com/problems/check-if-the-sentence-is-pangram "判断句子是否为全字母句") | [Go](problems/check-if-the-sentence-is-pangram) | Easy | -| 1831 | [Maximum Transaction Each Day](https://leetcode.com/problems/maximum-transaction-each-day) 🔒 | [MySQL](problems/maximum-transaction-each-day) | Medium | +| 1831 | [Maximum Transaction Each Day](https://leetcode.com/problems/maximum-transaction-each-day "每天的最大交易") 🔒 | [MySQL](problems/maximum-transaction-each-day) | Medium | | 1830 | [Minimum Number of Operations to Make String Sorted](https://leetcode.com/problems/minimum-number-of-operations-to-make-string-sorted "使字符串有序的最少操作次数") | [Go](problems/minimum-number-of-operations-to-make-string-sorted) | Hard | | 1829 | [Maximum XOR for Each Query](https://leetcode.com/problems/maximum-xor-for-each-query "每个查询的最大异或值") | [Go](problems/maximum-xor-for-each-query) | Medium | | 1828 | [Queries on Number of Points Inside a Circle](https://leetcode.com/problems/queries-on-number-of-points-inside-a-circle "统计一个圆中点的数目") | [Go](problems/queries-on-number-of-points-inside-a-circle) | Medium | @@ -141,7 +182,7 @@ LeetCode Problems' Solutions | 1823 | [Find the Winner of the Circular Game](https://leetcode.com/problems/find-the-winner-of-the-circular-game "找出游戏的获胜者") | [Go](problems/find-the-winner-of-the-circular-game) | Medium | | 1822 | [Sign of the Product of an Array](https://leetcode.com/problems/sign-of-the-product-of-an-array "数组元素积的符号") | [Go](problems/sign-of-the-product-of-an-array) | Easy | | 1821 | [Find Customers With Positive Revenue this Year](https://leetcode.com/problems/find-customers-with-positive-revenue-this-year "寻找今年具有正收入的客户") 🔒 | [MySQL](problems/find-customers-with-positive-revenue-this-year) | Easy | -| 1820 | [Maximum Number of Accepted Invitations](https://leetcode.com/problems/maximum-number-of-accepted-invitations) 🔒 | [Go](problems/maximum-number-of-accepted-invitations) | Medium | +| 1820 | [Maximum Number of Accepted Invitations](https://leetcode.com/problems/maximum-number-of-accepted-invitations "最多邀请的个数") 🔒 | [Go](problems/maximum-number-of-accepted-invitations) | Medium | | 1819 | [Number of Different Subsequences GCDs](https://leetcode.com/problems/number-of-different-subsequences-gcds "序列中不同最大公约数的数目") | [Go](problems/number-of-different-subsequences-gcds) | Hard | | 1818 | [Minimum Absolute Sum Difference](https://leetcode.com/problems/minimum-absolute-sum-difference "绝对差值和") | [Go](problems/minimum-absolute-sum-difference) | Medium | | 1817 | [Finding the Users Active Minutes](https://leetcode.com/problems/finding-the-users-active-minutes "查找用户活跃分钟数") | [Go](problems/finding-the-users-active-minutes) | Medium | @@ -150,7 +191,7 @@ LeetCode Problems' Solutions | 1814 | [Count Nice Pairs in an Array](https://leetcode.com/problems/count-nice-pairs-in-an-array "统计一个数组中好对子的数目") | [Go](problems/count-nice-pairs-in-an-array) | Medium | | 1813 | [Sentence Similarity III](https://leetcode.com/problems/sentence-similarity-iii "句子相似性 III") | [Go](problems/sentence-similarity-iii) | Medium | | 1812 | [Determine Color of a Chessboard Square](https://leetcode.com/problems/determine-color-of-a-chessboard-square "判断国际象棋棋盘中一个格子的颜色") | [Go](problems/determine-color-of-a-chessboard-square) | Easy | -| 1811 | [Find Interview Candidates](https://leetcode.com/problems/find-interview-candidates) 🔒 | [MySQL](problems/find-interview-candidates) | Medium | +| 1811 | [Find Interview Candidates](https://leetcode.com/problems/find-interview-candidates "寻找面试候选人") 🔒 | [MySQL](problems/find-interview-candidates) | Medium | | 1810 | [Minimum Path Cost in a Hidden Grid](https://leetcode.com/problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [Go](problems/minimum-path-cost-in-a-hidden-grid) | Medium | | 1809 | [Ad-Free Sessions](https://leetcode.com/problems/ad-free-sessions "没有广告的剧集") 🔒 | [MySQL](problems/ad-free-sessions) | Easy | | 1808 | [Maximize Number of Nice Divisors](https://leetcode.com/problems/maximize-number-of-nice-divisors "好因子的最大数目") | [Go](problems/maximize-number-of-nice-divisors) | Hard | @@ -170,10 +211,10 @@ LeetCode Problems' Solutions | 1794 | [Count Pairs of Equal Substrings With Minimum Difference](https://leetcode.com/problems/count-pairs-of-equal-substrings-with-minimum-difference "统计距离最小的子串对个数") 🔒 | [Go](problems/count-pairs-of-equal-substrings-with-minimum-difference) | Medium | | 1793 | [Maximum Score of a Good Subarray](https://leetcode.com/problems/maximum-score-of-a-good-subarray "好子数组的最大分数") | [Go](problems/maximum-score-of-a-good-subarray) | Hard | | 1792 | [Maximum Average Pass Ratio](https://leetcode.com/problems/maximum-average-pass-ratio "最大平均通过率") | [Go](problems/maximum-average-pass-ratio) | Medium | -| 1791 | [Find Center of Star Graph](https://leetcode.com/problems/find-center-of-star-graph "找出星型图的中心节点") | [Go](problems/find-center-of-star-graph) | Medium | +| 1791 | [Find Center of Star Graph](https://leetcode.com/problems/find-center-of-star-graph "找出星型图的中心节点") | [Go](problems/find-center-of-star-graph) | Easy | | 1790 | [Check if One String Swap Can Make Strings Equal](https://leetcode.com/problems/check-if-one-string-swap-can-make-strings-equal "仅执行一次字符串交换能否使两个字符串相等") | [Go](problems/check-if-one-string-swap-can-make-strings-equal) | Easy | | 1789 | [Primary Department for Each Employee](https://leetcode.com/problems/primary-department-for-each-employee "员工的直属部门") 🔒 | [MySQL](problems/primary-department-for-each-employee) | Easy | -| 1788 | [Maximize the Beauty of the Garden](https://leetcode.com/problems/maximize-the-beauty-of-the-garden) 🔒 | [Go](problems/maximize-the-beauty-of-the-garden) | Hard | +| 1788 | [Maximize the Beauty of the Garden](https://leetcode.com/problems/maximize-the-beauty-of-the-garden "最大化花园的美观度") 🔒 | [Go](problems/maximize-the-beauty-of-the-garden) | Hard | | 1787 | [Make the XOR of All Segments Equal to Zero](https://leetcode.com/problems/make-the-xor-of-all-segments-equal-to-zero "使所有区间的异或结果为零") | [Go](problems/make-the-xor-of-all-segments-equal-to-zero) | Hard | | 1786 | [Number of Restricted Paths From First to Last Node](https://leetcode.com/problems/number-of-restricted-paths-from-first-to-last-node "从第一个节点出发到最后一个节点的受限路径数") | [Go](problems/number-of-restricted-paths-from-first-to-last-node) | Medium | | 1785 | [Minimum Elements to Add to Form a Given Sum](https://leetcode.com/problems/minimum-elements-to-add-to-form-a-given-sum "构成特定和需要添加的最少元素") | [Go](problems/minimum-elements-to-add-to-form-a-given-sum) | Medium | diff --git a/problems/01-matrix/README.md b/problems/01-matrix/README.md index f8911d729..35b6ca3e1 100644 --- a/problems/01-matrix/README.md +++ b/problems/01-matrix/README.md @@ -43,5 +43,7 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/132-pattern/README.md b/problems/132-pattern/README.md index 63d65a631..3adc70a27 100644 --- a/problems/132-pattern/README.md +++ b/problems/132-pattern/README.md @@ -51,3 +51,7 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] diff --git a/problems/2-keys-keyboard/README.md b/problems/2-keys-keyboard/README.md index 0573f3c6f..10bd85b1e 100644 --- a/problems/2-keys-keyboard/README.md +++ b/problems/2-keys-keyboard/README.md @@ -47,6 +47,7 @@ In step 3, we use Paste operation to get 'AAA'. ### Related Topics + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/24-game/README.md b/problems/24-game/README.md index 41c12cd16..bd52440e6 100644 --- a/problems/24-game/README.md +++ b/problems/24-game/README.md @@ -60,4 +60,6 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/3sum-closest/README.md b/problems/3sum-closest/README.md index d73441b68..e615ead82 100644 --- a/problems/3sum-closest/README.md +++ b/problems/3sum-closest/README.md @@ -34,6 +34,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [3Sum](../3sum) (Medium) diff --git a/problems/3sum-smaller/README.md b/problems/3sum-smaller/README.md index d9215a65f..dfffe1c28 100644 --- a/problems/3sum-smaller/README.md +++ b/problems/3sum-smaller/README.md @@ -11,23 +11,13 @@ ## [259. 3Sum Smaller (Medium)](https://leetcode.com/problems/3sum-smaller "较小的三数之和") -

    Given an array of n integers nums and a target, find the number of index triplets i, j, k with 0 <= i < j < k < n that satisfy the condition nums[i] + nums[j] + nums[k] < target.

    -

    Example:

    - -
    -Input: nums = [-2,0,1,3], and target = 2
    -Output: 2 
    -Explanation: Because there are two triplets which sums are less than 2:
    -             [-2,0,1]
    -             [-2,0,3]
    -
    - -

    Follow up: Could you solve it in O(n2) runtime?

    ### Related Topics [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [3Sum](../3sum) (Medium) diff --git a/problems/3sum-with-multiplicity/README.md b/problems/3sum-with-multiplicity/README.md index 1f7a1230c..d7bdf95a0 100644 --- a/problems/3sum-with-multiplicity/README.md +++ b/problems/3sum-with-multiplicity/README.md @@ -50,4 +50,8 @@ and two 2s from [2,2,2,2] in 6 ways. ### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/3sum/README.md b/problems/3sum/README.md index d22f2f3cf..f707b18e9 100644 --- a/problems/3sum/README.md +++ b/problems/3sum/README.md @@ -37,6 +37,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Two Sum](../two-sum) (Easy) diff --git a/problems/4-keys-keyboard/README.md b/problems/4-keys-keyboard/README.md index c8aab92a6..a93312593 100644 --- a/problems/4-keys-keyboard/README.md +++ b/problems/4-keys-keyboard/README.md @@ -11,44 +11,9 @@ ## [651. 4 Keys Keyboard (Medium)](https://leetcode.com/problems/4-keys-keyboard "4键键盘") -

    Imagine you have a special keyboard with the following keys:

    -

    Key 1: (A): Print one 'A' on screen.

    -

    Key 2: (Ctrl-A): Select the whole screen.

    -

    Key 3: (Ctrl-C): Copy selection to buffer.

    -

    Key 4: (Ctrl-V): Print buffer on screen appending it after what has already been printed.

    - -

    Now, you can only press the keyboard for N times (with the above four keys), find out the maximum numbers of 'A' you can print on screen.

    - - -

    Example 1:
    -

    Input: N = 3
    -Output: 3
    -Explanation: 
    -We can at most get 3 A's on screen by pressing following key sequence:
    -A, A, A
    -
    -

    - -

    Example 2:
    -

    Input: N = 7
    -Output: 9
    -Explanation: 
    -We can at most get 9 A's on screen by pressing following key sequence:
    -A, A, A, Ctrl A, Ctrl C, Ctrl V, Ctrl V
    -
    -

    - -

    Note:
    -

      -
    1. 1 <= N <= 50
    2. -
    3. Answers will be in the range of 32-bit signed integer.
    4. -
    -

    - ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/4sum-ii/README.md b/problems/4sum-ii/README.md index 40c4f7837..b2fcdb145 100644 --- a/problems/4sum-ii/README.md +++ b/problems/4sum-ii/README.md @@ -50,8 +50,8 @@ The two tuples are: ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions 1. [4Sum](../4sum) (Medium) diff --git a/problems/4sum/README.md b/problems/4sum/README.md index 050e4a7bf..cfc05f039 100644 --- a/problems/4sum/README.md +++ b/problems/4sum/README.md @@ -47,8 +47,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Two Sum](../two-sum) (Easy) diff --git a/problems/accounts-merge/README.md b/problems/accounts-merge/README.md index 4d02996c1..939f314ea 100644 --- a/problems/accounts-merge/README.md +++ b/problems/accounts-merge/README.md @@ -49,8 +49,11 @@ We could return these lists in any order, for example the answer [['Mary' ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Redundant Connection](../redundant-connection) (Medium) diff --git a/problems/active-businesses/README.md b/problems/active-businesses/README.md index e5f157e4d..c5ef5beeb 100644 --- a/problems/active-businesses/README.md +++ b/problems/active-businesses/README.md @@ -11,46 +11,7 @@ ## [1126. Active Businesses (Medium)](https://leetcode.com/problems/active-businesses "查询活跃业务") -

    Table: Events

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| business_id   | int     |
    -| event_type    | varchar |
    -| occurences    | int     | 
    -+---------------+---------+
    -(business_id, event_type) is the primary key of this table.
    -Each row in the table logs the info that an event of some type occured at some business for a number of times.
    -

     

    - -

    Write an SQL query to find all active businesses.

    - -

    An active business is a business that has more than one event type with occurences greater than the average occurences of that event type among all businesses.

    - -

    The query result format is in the following example:

    - -
    -Events table:
    -+-------------+------------+------------+
    -| business_id | event_type | occurences |
    -+-------------+------------+------------+
    -| 1           | reviews    | 7          |
    -| 3           | reviews    | 3          |
    -| 1           | ads        | 11         |
    -| 2           | ads        | 7          |
    -| 3           | ads        | 6          |
    -| 1           | page views | 3          |
    -| 2           | page views | 12         |
    -+-------------+------------+------------+
    -
    -Result table:
    -+-------------+
    -| business_id |
    -+-------------+
    -| 1           |
    -+-------------+ 
    -Average for 'reviews', 'ads' and 'page views' are (7+3)/2=5, (11+7+6)/3=8, (3+12)/2=7.5 respectively.
    -Business with id 1 has 7 'reviews' events (more than 5) and 11 'ads' events (more than 8) so it is an active business.
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/active-users/README.md b/problems/active-users/README.md index 209e911b4..ba0038306 100644 --- a/problems/active-users/README.md +++ b/problems/active-users/README.md @@ -12,3 +12,6 @@ ## [1454. Active Users (Medium)](https://leetcode.com/problems/active-users "活跃用户") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/activity-participants/README.md b/problems/activity-participants/README.md index 59e05000d..c02acedb9 100644 --- a/problems/activity-participants/README.md +++ b/problems/activity-participants/README.md @@ -11,68 +11,7 @@ ## [1355. Activity Participants (Medium)](https://leetcode.com/problems/activity-participants "活动参与者") -

    Table: Friends

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| id            | int     |
    -| name          | varchar |
    -| activity      | varchar |
    -+---------------+---------+
    -id is the id of the friend and primary key for this table.
    -name is the name of the friend.
    -activity is the name of the activity which the friend takes part in.
    -
    -

    Table: Activities

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| id            | int     |
    -| name          | varchar |
    -+---------------+---------+
    -id is the primary key for this table.
    -name is the name of the activity.
    -
    - -Write an SQL query to find the names of all the activities with neither maximum, nor minimum number of participants. -Return the result table in any order. Each activity in table Activities is performed by any person in the table Friends. - -The query result format is in the following example: - -Friends table: -
    -+------+--------------+---------------+
    -| id   | name         | activity      |
    -+------+--------------+---------------+
    -| 1    | Jonathan D.  | Eating        |
    -| 2    | Jade W.      | Singing       |
    -| 3    | Victor J.    | Singing       |
    -| 4    | Elvis Q.     | Eating        |
    -| 5    | Daniel A.    | Eating        |
    -| 6    | Bob B.       | Horse Riding  |
    -+------+--------------+---------------+
    -
    -Activities table:
    -+------+--------------+
    -| id   | name         |
    -+------+--------------+
    -| 1    | Eating       |
    -| 2    | Singing      |
    -| 3    | Horse Riding |
    -+------+--------------+
    -
    -Result table:
    -+--------------+
    -| results      |
    -+--------------+
    -| Singing      |
    -+--------------+
    -
    -Eating activity is performed by 3 friends, maximum number of participants, (Jonathan D. , Elvis Q. and Daniel A.)
    -Horse Riding activity is performed by 1 friend, minimum number of participants, (Bob B.)
    -Singing is performed by 2 friends (Victor J. and Jade W.)
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md b/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md index ae617b27c..579f1765c 100644 --- a/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md +++ b/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md @@ -11,44 +11,7 @@ ## [1050. Actors and Directors Who Cooperated At Least Three Times (Easy)](https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times "合作过至少三次的演员和导演") -

    Table: ActorDirector

    -
    -+-------------+---------+
    -| Column Name | Type    |
    -+-------------+---------+
    -| actor_id    | int     |
    -| director_id | int     |
    -| timestamp   | int     |
    -+-------------+---------+
    -timestamp is the primary key column for this table.
    -
    -

     

    - -

    Write a SQL query for a report that provides the pairs (actor_id, director_id) where the actor have cooperated with the director at least 3 times.

    - -

    Example:

    - -
    -ActorDirector table:
    -+-------------+-------------+-------------+
    -| actor_id    | director_id | timestamp   |
    -+-------------+-------------+-------------+
    -| 1           | 1           | 0           |
    -| 1           | 1           | 1           |
    -| 1           | 1           | 2           |
    -| 1           | 2           | 3           |
    -| 1           | 2           | 4           |
    -| 2           | 1           | 5           |
    -| 2           | 1           | 6           |
    -+-------------+-------------+-------------+
    -
    -Result table:
    -+-------------+-------------+
    -| actor_id    | director_id |
    -+-------------+-------------+
    -| 1           | 1           |
    -+-------------+-------------+
    -The only pair is (1, 1) where they cooperated exactly 3 times.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/ad-free-sessions/README.md b/problems/ad-free-sessions/README.md index 9f37290fc..c65a46fb3 100644 --- a/problems/ad-free-sessions/README.md +++ b/problems/ad-free-sessions/README.md @@ -12,3 +12,6 @@ ## [1809. Ad-Free Sessions (Easy)](https://leetcode.com/problems/ad-free-sessions "没有广告的剧集") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/add-binary/README.md b/problems/add-binary/README.md index 5ea213e32..a8eaa0db1 100644 --- a/problems/add-binary/README.md +++ b/problems/add-binary/README.md @@ -31,8 +31,10 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Similar Questions 1. [Add Two Numbers](../add-two-numbers) (Medium) diff --git a/problems/add-bold-tag-in-string/README.md b/problems/add-bold-tag-in-string/README.md index 9ef927d3d..0622eb91d 100644 --- a/problems/add-bold-tag-in-string/README.md +++ b/problems/add-bold-tag-in-string/README.md @@ -11,37 +11,14 @@ ## [616. Add Bold Tag in String (Medium)](https://leetcode.com/problems/add-bold-tag-in-string "给字符串添加加粗标签") -Given a string s and a list of strings dict, you need to add a closed pair of bold tag <b> and </b> to wrap the substrings in s that exist in dict. If two such substrings overlap, you need to wrap them together by only one pair of closed bold tag. Also, if two substrings wrapped by bold tags are consecutive, you need to combine them. -

    Example 1:
    -

    -Input: 
    -s = "abcxyz123"
    -dict = ["abc","123"]
    -Output:
    -"<b>abc</b>xyz<b>123</b>"
    -
    -

    - -

    Example 2:
    -

    -Input: 
    -s = "aaabbcc"
    -dict = ["aaa","aab","bc"]
    -Output:
    -"<b>aaabbc</b>c"
    -
    -

    - -

    Note:
    -

      -
    1. The given dict won't contain duplicates, and its length won't exceed 100.
    2. -
    3. All the strings in input have length in range [1, 1000].
    4. -
    -

    ### Related Topics + [[Trie](../../tag/trie/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[String Matching](../../tag/string-matching/README.md)] ### Similar Questions 1. [Merge Intervals](../merge-intervals) (Medium) diff --git a/problems/add-digits/README.md b/problems/add-digits/README.md index e97ef4737..46101290e 100644 --- a/problems/add-digits/README.md +++ b/problems/add-digits/README.md @@ -44,6 +44,8 @@ Since 2 has only one digit, return it. ### Related Topics [[Math](../../tag/math/README.md)] + [[Number Theory](../../tag/number-theory/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Similar Questions 1. [Happy Number](../happy-number) (Easy) diff --git a/problems/add-one-row-to-tree/README.md b/problems/add-one-row-to-tree/README.md index b0ef4d18a..8a98e1d21 100644 --- a/problems/add-one-row-to-tree/README.md +++ b/problems/add-one-row-to-tree/README.md @@ -52,3 +52,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/add-strings/README.md b/problems/add-strings/README.md index 79bc5117f..165bbe5c5 100644 --- a/problems/add-strings/README.md +++ b/problems/add-strings/README.md @@ -47,7 +47,9 @@ ### Related Topics + [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Similar Questions 1. [Add Two Numbers](../add-two-numbers) (Medium) diff --git a/problems/add-to-array-form-of-integer/README.md b/problems/add-to-array-form-of-integer/README.md index 733fc3225..db5ec4798 100644 --- a/problems/add-to-array-form-of-integer/README.md +++ b/problems/add-to-array-form-of-integer/README.md @@ -64,6 +64,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Add Two Numbers](../add-two-numbers) (Medium) diff --git a/problems/add-two-numbers-ii/README.md b/problems/add-two-numbers-ii/README.md index be840079a..8a1ffe7ee 100644 --- a/problems/add-two-numbers-ii/README.md +++ b/problems/add-two-numbers-ii/README.md @@ -50,7 +50,9 @@

    Follow up: Could you solve it without reversing the input lists?

    ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Add Two Numbers](../add-two-numbers) (Medium) diff --git a/problems/add-two-polynomials-represented-as-linked-lists/README.md b/problems/add-two-polynomials-represented-as-linked-lists/README.md index 6bccb2b37..0b7574ebc 100644 --- a/problems/add-two-polynomials-represented-as-linked-lists/README.md +++ b/problems/add-two-polynomials-represented-as-linked-lists/README.md @@ -15,6 +15,8 @@ ### Related Topics [[Linked List](../../tag/linked-list/README.md)] + [[Math](../../tag/math/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Hints
    diff --git a/problems/adding-two-negabinary-numbers/README.md b/problems/adding-two-negabinary-numbers/README.md index 9b56b123f..f7f8a4c72 100644 --- a/problems/adding-two-negabinary-numbers/README.md +++ b/problems/adding-two-negabinary-numbers/README.md @@ -50,6 +50,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] ### Hints diff --git a/problems/additive-number/README.md b/problems/additive-number/README.md index ae071b96f..dc51c75c0 100644 --- a/problems/additive-number/README.md +++ b/problems/additive-number/README.md @@ -50,6 +50,7 @@ How would you handle overflow for very large input integers?

    ### Related Topics + [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions diff --git a/problems/ads-performance/README.md b/problems/ads-performance/README.md index 91befe0f6..6452b89b7 100644 --- a/problems/ads-performance/README.md +++ b/problems/ads-performance/README.md @@ -11,60 +11,7 @@ ## [1322. Ads Performance (Easy)](https://leetcode.com/problems/ads-performance "广告效果") -

    Table: Ads

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| ad_id         | int     |
    -| user_id       | int     |
    -| action        | enum    |
    -+---------------+---------+
    -(ad_id, user_id) is the primary key for this table.
    -Each row of this table contains the ID of an Ad, the ID of a user and the action taken by this user regarding this Ad.
    -The action column is an ENUM type of ('Clicked', 'Viewed', 'Ignored').
    -
    - -A company is running Ads and wants to calculate the performance of each Ad. -Performance of the Ad is measured using Click-Through Rate (CTR) where: -[[image-blog:Leetcode: Ads Performance][https://raw.githubusercontent.com/dennyzhang/code.dennyzhang.com/master/problems/ads-performance/ctrformula.png]] - -Write an SQL query to find the ctr of each Ad. - -Round ctr to 2 decimal points. Order the result table by ctr in descending order and by ad_id in ascending order in case of a tie. - -The query result format is in the following example: -
    -Ads table:
    -+-------+---------+---------+
    -| ad_id | user_id | action  |
    -+-------+---------+---------+
    -| 1     | 1       | Clicked |
    -| 2     | 2       | Clicked |
    -| 3     | 3       | Viewed  |
    -| 5     | 5       | Ignored |
    -| 1     | 7       | Ignored |
    -| 2     | 7       | Viewed  |
    -| 3     | 5       | Clicked |
    -| 1     | 4       | Viewed  |
    -| 2     | 11      | Viewed  |
    -| 1     | 2       | Clicked |
    -+-------+---------+---------+
    -Result table:
    -+-------+-------+
    -| ad_id | ctr   |
    -+-------+-------+
    -| 1     | 66.67 |
    -| 3     | 50.00 |
    -| 2     | 33.33 |
    -| 5     | 0.00  |
    -+-------+-------+
    -for ad_id = 1, ctr = (2/(2+1)) * 100 = 66.67
    -for ad_id = 2, ctr = (1/(1+2)) * 100 = 33.33
    -for ad_id = 3, ctr = (1/(1+1)) * 100 = 50.00
    -for ad_id = 5, ctr = 0.00, Note that ad_id has no clicks or views.
    -Note that we don't care about Ignored Ads.
    -Result table is ordered by the ctr. in case of a tie we order them by ad_id
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/advantage-shuffle/README.md b/problems/advantage-shuffle/README.md index 5d39d89ec..2416071a4 100644 --- a/problems/advantage-shuffle/README.md +++ b/problems/advantage-shuffle/README.md @@ -48,3 +48,4 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/airplane-seat-assignment-probability/README.md b/problems/airplane-seat-assignment-probability/README.md index 9d9f33ae7..7c3ce83cd 100644 --- a/problems/airplane-seat-assignment-probability/README.md +++ b/problems/airplane-seat-assignment-probability/README.md @@ -47,6 +47,7 @@ [[Brainteaser](../../tag/brainteaser/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Probability and Statistics](../../tag/probability-and-statistics/README.md)] ### Hints
    diff --git a/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md b/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md index c7a00f797..e225d4dce 100644 --- a/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md +++ b/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md @@ -65,8 +65,10 @@ ### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Ordered Map](../../tag/ordered-map/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/alien-dictionary/README.md b/problems/alien-dictionary/README.md index e22b338d5..87cb564d4 100644 --- a/problems/alien-dictionary/README.md +++ b/problems/alien-dictionary/README.md @@ -11,62 +11,15 @@ ## [269. Alien Dictionary (Hard)](https://leetcode.com/problems/alien-dictionary "火星词典") -

    There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. You receive a list of non-empty words from the dictionary, where words are sorted lexicographically by the rules of this new language. Derive the order of letters in this language.

    -

    Example 1:

    - -
    -Input:
    -[
    -  "wrt",
    -  "wrf",
    -  "er",
    -  "ett",
    -  "rftt"
    -]
    -
    -Output: "wertf"
    -
    - -

    Example 2:

    - -
    -Input:
    -[
    -  "z",
    -  "x"
    -]
    -
    -Output: "zx"
    -
    - -

    Example 3:

    - -
    -Input:
    -[
    -  "z",
    -  "x",
    -  "z"
    -] 
    -
    -Output: "" 
    -
    -Explanation: The order is invalid, so return "".
    -
    - -

    Note:

    - -
      -
    1. You may assume all letters are in lowercase.
    2. -
    3. You may assume that if a is a prefix of b, then a must appear before b in the given dictionary.
    4. -
    5. If the order is invalid, return an empty string.
    6. -
    7. There may be multiple valid order of letters, return any one of them is fine.
    8. -
    ### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Course Schedule II](../course-schedule-ii) (Medium) diff --git a/problems/all-elements-in-two-binary-search-trees/README.md b/problems/all-elements-in-two-binary-search-trees/README.md index af291ed84..7f3b1cadd 100644 --- a/problems/all-elements-in-two-binary-search-trees/README.md +++ b/problems/all-elements-in-two-binary-search-trees/README.md @@ -60,8 +60,11 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/all-nodes-distance-k-in-binary-tree/README.md b/problems/all-nodes-distance-k-in-binary-tree/README.md index 7c37d9609..3877dc425 100644 --- a/problems/all-nodes-distance-k-in-binary-tree/README.md +++ b/problems/all-nodes-distance-k-in-binary-tree/README.md @@ -52,5 +52,6 @@ The descriptions of the inputs above are just serializations of these objects. ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/all-oone-data-structure/README.md b/problems/all-oone-data-structure/README.md index 6bec965e2..c4c565fc7 100644 --- a/problems/all-oone-data-structure/README.md +++ b/problems/all-oone-data-structure/README.md @@ -51,11 +51,11 @@ allOne.getMinKey(); // return "leet"
  • 1 <= key.length <= 10
  • key consists of lowercase English letters.
  • It is guaranteed that for each call to dec, key is existing in the data structure.
  • -
  • At most 3 * 104 calls will be made to inc, dec, getMaxKey, and getMinKey.
  • +
  • At most 5 * 104 calls will be made to inc, dec, getMaxKey, and getMinKey.
  • -

     

    -

    Follow up: Could you apply all the operations in O(1) time complexity?

    - ### Related Topics [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Doubly-Linked List](../../tag/doubly-linked-list/README.md)] diff --git a/problems/all-paths-from-source-lead-to-destination/README.md b/problems/all-paths-from-source-lead-to-destination/README.md index 1d060ff6f..9d11be5be 100644 --- a/problems/all-paths-from-source-lead-to-destination/README.md +++ b/problems/all-paths-from-source-lead-to-destination/README.md @@ -11,83 +11,10 @@ ## [1059. All Paths from Source Lead to Destination (Medium)](https://leetcode.com/problems/all-paths-from-source-lead-to-destination "从始点到终点的所有路径") -

    Given the edges of a directed graph, and two nodes source and destination of this graph, determine whether or not all paths starting from source eventually end at destination, that is:

    -
      -
    • At least one path exists from the source node to the destination node
    • -
    • If a path exists from the source node to a node with no outgoing edges, then that node is equal to destination.
    • -
    • The number of possible paths from source to destination is a finite number.
    • -
    - -

    Return true if and only if all roads from source lead to destination.

    - -

     

    - -

    Example 1:

    - -

    - -
    -Input: n = 3, edges = [[0,1],[0,2]], source = 0, destination = 2
    -Output: false
    -Explanation: It is possible to reach and get stuck on both node 1 and node 2.
    -
    - -

    Example 2:

    - -

    - -
    -Input: n = 4, edges = [[0,1],[0,3],[1,2],[2,1]], source = 0, destination = 3
    -Output: false
    -Explanation: We have two possibilities: to end at node 3, or to loop over node 1 and node 2 indefinitely.
    -
    - -

    Example 3:

    - -

    - -
    -Input: n = 4, edges = [[0,1],[0,2],[1,3],[2,3]], source = 0, destination = 3
    -Output: true
    -
    - -

    Example 4:

    - -

    - -
    -Input: n = 3, edges = [[0,1],[1,1],[1,2]], source = 0, destination = 2
    -Output: false
    -Explanation: All paths from the source node end at the destination node, but there are an infinite number of paths, such as 0-1-2, 0-1-1-2, 0-1-1-1-2, 0-1-1-1-1-2, and so on.
    -
    - -

    Example 5:

    - -

    - -
    -Input: n = 2, edges = [[0,1],[1,1]], source = 0, destination = 1
    -Output: false
    -Explanation: There is infinite self-loop at destination node.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. The given graph may have self loops and parallel edges.
    2. -
    3. The number of nodes n in the graph is between 1 and 10000
    4. -
    5. The number of edges in the graph is between 0 and 10000
    6. -
    7. 0 <= edges.length <= 10000
    8. -
    9. edges[i].length == 2
    10. -
    11. 0 <= source <= n - 1
    12. -
    13. 0 <= destination <= n - 1
    14. -
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] ### Hints diff --git a/problems/all-paths-from-source-to-target/README.md b/problems/all-paths-from-source-to-target/README.md index 29187f2d3..012aa928a 100644 --- a/problems/all-paths-from-source-to-target/README.md +++ b/problems/all-paths-from-source-to-target/README.md @@ -64,6 +64,7 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/all-people-report-to-the-given-manager/README.md b/problems/all-people-report-to-the-given-manager/README.md index ccad4e619..f6c743ee3 100644 --- a/problems/all-people-report-to-the-given-manager/README.md +++ b/problems/all-people-report-to-the-given-manager/README.md @@ -11,55 +11,7 @@ ## [1270. All People Report to the Given Manager (Medium)](https://leetcode.com/problems/all-people-report-to-the-given-manager "向公司CEO汇报工作的所有人") -

    Table: Employees

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| employee_id   | int     |
    -| employee_name | varchar |
    -| manager_id    | int     |
    -+---------------+---------+
    -employee_id is the primary key for this table.
    -Each row of this table indicates that the employee with ID employee_id and name employee_name reports his work to his/her direct manager with manager_id
    -The head of the company is the employee with employee_id = 1.
    -
    -Write an SQL query to find employee_id of all employees that directly or indirectly report their work to the head of the company. -The indirect relation between managers will not exceed 3 managers as the company is small. - -Return result table in any order without duplicates. - -The query result format is in the following example: -
    -Employees table:
    -+-------------+---------------+------------+
    -| employee_id | employee_name | manager_id |
    -+-------------+---------------+------------+
    -| 1           | Boss          | 1          |
    -| 3           | Alice         | 3          |
    -| 2           | Bob           | 1          |
    -| 4           | Daniel        | 2          |
    -| 7           | Luis          | 4          |
    -| 8           | Jhon          | 3          |
    -| 9           | Angela        | 8          |
    -| 77          | Robert        | 1          |
    -+-------------+---------------+------------+
    -
    -Result table:
    -+-------------+
    -| employee_id |
    -+-------------+
    -| 2           |
    -| 77          |
    -| 4           |
    -| 7           |
    -+-------------+
    -
    -The head of the company is the employee with employee_id 1.
    -The employees with employee_id 2 and 77 report their work directly to the head of the company.
    -The employee with employee_id 4 report his work indirectly to the head of the company 4 --> 2 --> 1. 
    -The employee with employee_id 7 report his work indirectly to the head of the company 7 --> 4 --> 2 --> 1.
    -The employees with employee_id 3, 8 and 9 don't report their work to head of company directly or indirectly. 
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/all-possible-full-binary-trees/README.md b/problems/all-possible-full-binary-trees/README.md index b9d4707df..2ace2a85a 100644 --- a/problems/all-possible-full-binary-trees/README.md +++ b/problems/all-possible-full-binary-trees/README.md @@ -42,3 +42,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] [[Recursion](../../tag/recursion/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/all-valid-triplets-that-can-represent-a-country/README.md b/problems/all-valid-triplets-that-can-represent-a-country/README.md index 3cdc8904c..ced73e063 100644 --- a/problems/all-valid-triplets-that-can-represent-a-country/README.md +++ b/problems/all-valid-triplets-that-can-represent-a-country/README.md @@ -12,3 +12,6 @@ ## [1623. All Valid Triplets That Can Represent a Country (Easy)](https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country "三人国家代表队") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/allocate-mailboxes/README.md b/problems/allocate-mailboxes/README.md index f8b3ac88b..5d982f082 100644 --- a/problems/allocate-mailboxes/README.md +++ b/problems/allocate-mailboxes/README.md @@ -66,8 +66,10 @@ Minimum total distance from each houses to nearest mailboxes is |2-3| + |3-3| + ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/ambiguous-coordinates/README.md b/problems/ambiguous-coordinates/README.md index 7d32f3ffa..9b197c55a 100644 --- a/problems/ambiguous-coordinates/README.md +++ b/problems/ambiguous-coordinates/README.md @@ -65,3 +65,4 @@ ### Related Topics [[String](../../tag/string/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/analyze-user-website-visit-pattern/README.md b/problems/analyze-user-website-visit-pattern/README.md index 3781f2f65..9fc0be7bc 100644 --- a/problems/analyze-user-website-visit-pattern/README.md +++ b/problems/analyze-user-website-visit-pattern/README.md @@ -11,56 +11,12 @@ ## [1152. Analyze User Website Visit Pattern (Medium)](https://leetcode.com/problems/analyze-user-website-visit-pattern "用户网站访问行为分析") -

    We are given some website visits: the user with name username[i] visited the website website[i] at time timestamp[i].

    -

    A 3-sequence is a list of websites of length 3 sorted in ascending order by the time of their visits.  (The websites in a 3-sequence are not necessarily distinct.)

    - -

    Find the 3-sequence visited by the largest number of users. If there is more than one solution, return the lexicographically smallest such 3-sequence.

    - -

     

    - -

    Example 1:

    - -
    -Input: username = ["joe","joe","joe","james","james","james","james","mary","mary","mary"], timestamp = [1,2,3,4,5,6,7,8,9,10], website = ["home","about","career","home","cart","maps","home","home","about","career"]
    -Output: ["home","about","career"]
    -Explanation: 
    -The tuples in this example are:
    -["joe", 1, "home"]
    -["joe", 2, "about"]
    -["joe", 3, "career"]
    -["james", 4, "home"]
    -["james", 5, "cart"]
    -["james", 6, "maps"]
    -["james", 7, "home"]
    -["mary", 8, "home"]
    -["mary", 9, "about"]
    -["mary", 10, "career"]
    -The 3-sequence ("home", "about", "career") was visited at least once by 2 users.
    -The 3-sequence ("home", "cart", "maps") was visited at least once by 1 user.
    -The 3-sequence ("home", "cart", "home") was visited at least once by 1 user.
    -The 3-sequence ("home", "maps", "home") was visited at least once by 1 user.
    -The 3-sequence ("cart", "maps", "home") was visited at least once by 1 user.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 3 <= N = username.length = timestamp.length = website.length <= 50
    2. -
    3. 1 <= username[i].length <= 10
    4. -
    5. 0 <= timestamp[i] <= 10^9
    6. -
    7. 1 <= website[i].length <= 10
    8. -
    9. Both username[i] and website[i] contain only lowercase characters.
    10. -
    11. It is guaranteed that there is at least one user who visited at least 3 websites.
    12. -
    13. No user visits two websites at the same time.
    14. -
    ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/android-unlock-patterns/README.md b/problems/android-unlock-patterns/README.md index 9d96cd889..af8d16623 100644 --- a/problems/android-unlock-patterns/README.md +++ b/problems/android-unlock-patterns/README.md @@ -11,54 +11,7 @@ ## [351. Android Unlock Patterns (Medium)](https://leetcode.com/problems/android-unlock-patterns "安卓系统手势解锁") -

    Given an Android 3x3 key lock screen and two integers m and n, where 1 ≤ m ≤ n ≤ 9, count the total number of unlock patterns of the Android lock screen, which consist of minimum of m keys and maximum n keys.

    -

     

    - -

    Rules for a valid pattern:

    - -
      -
    1. Each pattern must connect at least m keys and at most n keys.
    2. -
    3. All the keys must be distinct.
    4. -
    5. If the line connecting two consecutive keys in the pattern passes through any other keys, the other keys must have previously selected in the pattern. No jumps through non selected key is allowed.
    6. -
    7. The order of keys used matters.
    8. -
    - -

     

    - -
    -
    - -

     

    - -

    Explanation:

    - -
    -| 1 | 2 | 3 |
    -| 4 | 5 | 6 |
    -| 7 | 8 | 9 |
    - -

    Invalid move: 4 - 1 - 3 - 6
    -Line 1 - 3 passes through key 2 which had not been selected in the pattern.

    - -

    Invalid move: 4 - 1 - 9 - 2
    -Line 1 - 9 passes through key 5 which had not been selected in the pattern.

    - -

    Valid move: 2 - 4 - 1 - 3 - 6
    -Line 1 - 3 is valid because it passes through key 2, which had been selected in the pattern

    - -

    Valid move: 6 - 5 - 4 - 1 - 9 - 2
    -Line 1 - 9 is valid because it passes through key 5, which had been selected in the pattern.

    - -

     

    - -

    Example:

    - -
    -
    -Input: m = 1, n = 1
    -Output: 9
    -
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/apples-oranges/README.md b/problems/apples-oranges/README.md index 6d592e273..be80dd0cb 100644 --- a/problems/apples-oranges/README.md +++ b/problems/apples-oranges/README.md @@ -12,3 +12,6 @@ ## [1445. Apples & Oranges (Medium)](https://leetcode.com/problems/apples-oranges "苹果和桔子") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/apply-discount-every-n-orders/README.md b/problems/apply-discount-every-n-orders/README.md index 44802160d..0ca34f047 100644 --- a/problems/apply-discount-every-n-orders/README.md +++ b/problems/apply-discount-every-n-orders/README.md @@ -64,6 +64,8 @@ cashier.getBill([2,3,5],[5,3,2]); // return 2500.0 ### Related Topics [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/arithmetic-slices-ii-subsequence/README.md b/problems/arithmetic-slices-ii-subsequence/README.md index 345742eb3..d068568ef 100644 --- a/problems/arithmetic-slices-ii-subsequence/README.md +++ b/problems/arithmetic-slices-ii-subsequence/README.md @@ -61,6 +61,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/arithmetic-slices/README.md b/problems/arithmetic-slices/README.md index 75d5d0a70..eaed04793 100644 --- a/problems/arithmetic-slices/README.md +++ b/problems/arithmetic-slices/README.md @@ -46,7 +46,7 @@ ### Related Topics - [[Math](../../tag/math/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/arithmetic-subarrays/README.md b/problems/arithmetic-subarrays/README.md index 840bdd39a..f2b1ee7f4 100644 --- a/problems/arithmetic-subarrays/README.md +++ b/problems/arithmetic-subarrays/README.md @@ -61,7 +61,8 @@ In the 2nd query, the subarray is [5,9,3,7]. This can be ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/armstrong-number/README.md b/problems/armstrong-number/README.md index 2a5aef613..d7e65b07d 100644 --- a/problems/armstrong-number/README.md +++ b/problems/armstrong-number/README.md @@ -11,37 +11,7 @@ ## [1134. Armstrong Number (Easy)](https://leetcode.com/problems/armstrong-number "阿姆斯特朗数") -

    The k-digit number N is an Armstrong number if and only if the k-th power of each digit sums to N.

    -

    Given a positive integer N, return true if and only if it is an Armstrong number.

    - -

     

    - -

    Example 1:

    - -
    -Input: 153
    -Output: true
    -Explanation: 
    -153 is a 3-digit number, and 153 = 1^3 + 5^3 + 3^3.
    -
    - -

    Example 2:

    - -
    -Input: 123
    -Output: false
    -Explanation: 
    -123 is a 3-digit number, and 123 != 1^3 + 2^3 + 3^3 = 36.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= N <= 10^8
    2. -
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/array-nesting/README.md b/problems/array-nesting/README.md index 938bd27cb..977d14105 100644 --- a/problems/array-nesting/README.md +++ b/problems/array-nesting/README.md @@ -52,6 +52,7 @@ s[0] = {nums[0], nums[5], nums[6], nums[2]} = {5, 6, 2, 0} ### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Array](../../tag/array/README.md)] ### Similar Questions diff --git a/problems/array-of-doubled-pairs/README.md b/problems/array-of-doubled-pairs/README.md index 9385c0569..9a6b6ba2a 100644 --- a/problems/array-of-doubled-pairs/README.md +++ b/problems/array-of-doubled-pairs/README.md @@ -53,5 +53,7 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/array-partition-i/README.md b/problems/array-partition-i/README.md index 6a558e5b1..bf1e259b2 100644 --- a/problems/array-partition-i/README.md +++ b/problems/array-partition-i/README.md @@ -43,7 +43,10 @@ So the maximum possible sum is 4.
    ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Counting Sort](../../tag/counting-sort/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/array-transformation/README.md b/problems/array-transformation/README.md index 4cccdf1d6..0dcd0d0ea 100644 --- a/problems/array-transformation/README.md +++ b/problems/array-transformation/README.md @@ -11,50 +11,11 @@ ## [1243. Array Transformation (Easy)](https://leetcode.com/problems/array-transformation "数组变换") -

    Given an initial array arr, every day you produce a new array using the array of the previous day.

    -

    On the i-th day, you do the following operations on the array of day i-1 to produce the array of day i:

    - -
      -
    1. If an element is smaller than both its left neighbor and its right neighbor, then this element is incremented.
    2. -
    3. If an element is bigger than both its left neighbor and its right neighbor, then this element is decremented.
    4. -
    5. The first and last elements never change.
    6. -
    - -

    After some days, the array does not change. Return that final array.

    - -

     

    -

    Example 1:

    - -
    -Input: arr = [6,2,3,4]
    -Output: [6,3,3,4]
    -Explanation: 
    -On the first day, the array is changed from [6,2,3,4] to [6,3,3,4].
    -No more operations can be done to this array.
    -
    - -

    Example 2:

    - -
    -Input: arr = [1,6,3,4,3,5]
    -Output: [1,4,4,4,4,5]
    -Explanation: 
    -On the first day, the array is changed from [1,6,3,4,3,5] to [1,5,4,3,4,5].
    -On the second day, the array is changed from [1,5,4,3,4,5] to [1,4,4,4,4,5].
    -No more operations can be done to this array.
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= arr.length <= 100
    • -
    • 1 <= arr[i] <= 100
    • -
    ### Related Topics [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/article-views-i/README.md b/problems/article-views-i/README.md index 2fe77f6d6..f2ffc14f7 100644 --- a/problems/article-views-i/README.md +++ b/problems/article-views-i/README.md @@ -11,46 +11,7 @@ ## [1148. Article Views I (Easy)](https://leetcode.com/problems/article-views-i "文章浏览 I") -

    Table: Views

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| article_id    | int     |
    -| author_id     | int     |
    -| viewer_id     | int     |
    -| view_date     | date    |
    -+---------------+---------+
    -There is no primary key for this table, it may have duplicate rows.
    -Each row of this table indicates that some viewer viewed an article (written by some author) on some date. 
    -Note that equal author_id and viewer_id indicate the same person.
    -

     

    - -

    Write an SQL query to find all the authors that viewed at least one of their own articles, sorted in ascending order by their id.

    - -

    The query result format is in the following example:

    - -
    -Views table:
    -+------------+-----------+-----------+------------+
    -| article_id | author_id | viewer_id | view_date  |
    -+------------+-----------+-----------+------------+
    -| 1          | 3         | 5         | 2019-08-01 |
    -| 1          | 3         | 6         | 2019-08-02 |
    -| 2          | 7         | 7         | 2019-08-01 |
    -| 2          | 7         | 6         | 2019-08-02 |
    -| 4          | 7         | 1         | 2019-07-22 |
    -| 3          | 4         | 4         | 2019-07-21 |
    -| 3          | 4         | 4         | 2019-07-21 |
    -+------------+-----------+-----------+------------+
    -
    -Result table:
    -+------+
    -| id   |
    -+------+
    -| 4    |
    -| 7    |
    -+------+
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/article-views-ii/README.md b/problems/article-views-ii/README.md index d10a5bd6f..6de4a276d 100644 --- a/problems/article-views-ii/README.md +++ b/problems/article-views-ii/README.md @@ -11,46 +11,7 @@ ## [1149. Article Views II (Medium)](https://leetcode.com/problems/article-views-ii "文章浏览 II") -

    Table: Views

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| article_id    | int     |
    -| author_id     | int     |
    -| viewer_id     | int     |
    -| view_date     | date    |
    -+---------------+---------+
    -There is no primary key for this table, it may have duplicate rows.
    -Each row of this table indicates that some viewer viewed an article (written by some author) on some date. 
    -Note that equal author_id and viewer_id indicate the same person.
    -

     

    - -

    Write an SQL query to find all the people who viewed more than one article on the same date, sorted in ascending order by their id.

    - -

    The query result format is in the following example:

    - -
    -Views table:
    -+------------+-----------+-----------+------------+
    -| article_id | author_id | viewer_id | view_date  |
    -+------------+-----------+-----------+------------+
    -| 1          | 3         | 5         | 2019-08-01 |
    -| 3          | 4         | 5         | 2019-08-01 |
    -| 1          | 3         | 6         | 2019-08-02 |
    -| 2          | 7         | 7         | 2019-08-01 |
    -| 2          | 7         | 6         | 2019-08-02 |
    -| 4          | 7         | 1         | 2019-07-22 |
    -| 3          | 4         | 4         | 2019-07-21 |
    -| 3          | 4         | 4         | 2019-07-21 |
    -+------------+-----------+-----------+------------+
    -
    -Result table:
    -+------+
    -| id   |
    -+------+
    -| 5    |
    -| 6    |
    -+------+
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/as-far-from-land-as-possible/README.md b/problems/as-far-from-land-as-possible/README.md index ea5e33b61..904d2bf2a 100644 --- a/problems/as-far-from-land-as-possible/README.md +++ b/problems/as-far-from-land-as-possible/README.md @@ -43,8 +43,10 @@ ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] - [[Graph](../../tag/graph/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Shortest Distance from All Buildings](../shortest-distance-from-all-buildings) (Hard) diff --git a/problems/assign-cookies/README.md b/problems/assign-cookies/README.md index e8244dc99..15111acc7 100644 --- a/problems/assign-cookies/README.md +++ b/problems/assign-cookies/README.md @@ -47,3 +47,5 @@ You need to output 2. ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/asteroid-collision/README.md b/problems/asteroid-collision/README.md index d031d448f..d86b379f9 100644 --- a/problems/asteroid-collision/README.md +++ b/problems/asteroid-collision/README.md @@ -61,6 +61,7 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions 1. [Can Place Flowers](../can-place-flowers) (Easy) diff --git a/problems/available-captures-for-rook/README.md b/problems/available-captures-for-rook/README.md index 3e5962fd5..6c4c5b748 100644 --- a/problems/available-captures-for-rook/README.md +++ b/problems/available-captures-for-rook/README.md @@ -54,3 +54,5 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/average-of-levels-in-binary-tree/README.md b/problems/average-of-levels-in-binary-tree/README.md index 98c382d1f..3c9aebacb 100644 --- a/problems/average-of-levels-in-binary-tree/README.md +++ b/problems/average-of-levels-in-binary-tree/README.md @@ -39,6 +39,9 @@ Hence return [3, 14.5, 11]. ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Binary Tree Level Order Traversal](../binary-tree-level-order-traversal) (Medium) diff --git a/problems/average-salary-departments-vs-company/README.md b/problems/average-salary-departments-vs-company/README.md index 6374e1e70..426ec7a09 100644 --- a/problems/average-salary-departments-vs-company/README.md +++ b/problems/average-salary-departments-vs-company/README.md @@ -11,61 +11,10 @@ ## [615. Average Salary: Departments VS Company (Hard)](https://leetcode.com/problems/average-salary-departments-vs-company "平均工资:部门与公司比较") -Given two tables as below, write a query to display the comparison result (higher/lower/same) of the average salary of employees in a department to the company's average salary. -

     

    -Table: salary -
    -| id | employee_id | amount | pay_date   |
    -|----|-------------|--------|------------|
    -| 1  | 1           | 9000   | 2017-03-31 |
    -| 2  | 2           | 6000   | 2017-03-31 |
    -| 3  | 3           | 10000  | 2017-03-31 |
    -| 4  | 1           | 7000   | 2017-02-28 |
    -| 5  | 2           | 6000   | 2017-02-28 |
    -| 6  | 3           | 8000   | 2017-02-28 |
    -
    -

     

    -The employee_id column refers to the employee_id in the following table employee. +### Related Topics + [[Database](../../tag/database/README.md)] -

     

    - -
    -| employee_id | department_id |
    -|-------------|---------------|
    -| 1           | 1             |
    -| 2           | 2             |
    -| 3           | 2             |
    -
    - -

     

    -So for the sample data above, the result is: - -

     

    - -
    -| pay_month | department_id | comparison  |
    -|-----------|---------------|-------------|
    -| 2017-03   | 1             | higher      |
    -| 2017-03   | 2             | lower       |
    -| 2017-02   | 1             | same        |
    -| 2017-02   | 2             | same        |
    -
    - -

     

    -Explanation - -

     

    -In March, the company's average salary is (9000+6000+10000)/3 = 8333.33... - -

     

    -The average salary for department '1' is 9000, which is the salary of employee_id '1' since there is only one employee in this department. So the comparison result is 'higher' since 9000 > 8333.33 obviously. - -

     

    -The average salary of department '2' is (6000 + 10000)/2 = 8000, which is the average of employee_id '2' and '3'. So the comparison result is 'lower' since 8000 < 8333.33. - -

     

    -With he same formula for the average salary comparison in February, the result is 'same' since both the department '1' and '2' have the same average salary with the company, which is 7000. - -

     

    +### Similar Questions + 1. [Countries You Can Safely Invest In](../countries-you-can-safely-invest-in) (Medium) diff --git a/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md b/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md index 7315b3fe6..1dcd53d41 100644 --- a/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md +++ b/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md @@ -59,8 +59,8 @@ Average salary excluding minimum and maximum salary is (2000)/1= 2000 ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/average-selling-price/README.md b/problems/average-selling-price/README.md index 8eee2ff1e..f5163ddd3 100644 --- a/problems/average-selling-price/README.md +++ b/problems/average-selling-price/README.md @@ -11,75 +11,7 @@ ## [1251. Average Selling Price (Easy)](https://leetcode.com/problems/average-selling-price "平均售价") -

    Table: Prices

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| product_id    | int     |
    -| start_date    | date    |
    -| end_date      | date    |
    -| price         | int     |
    -+---------------+---------+
    -(product_id, start_date, end_date) is the primary key for this table.
    -Each row of this table indicates the price of the product_id in the period from start_date to end_date.
    -For each product_id there will be no two overlapping periods. That means there will be no two intersecting periods for the same product_id.
    -
    -

     

    - -

    Table: UnitsSold

    - -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| product_id    | int     |
    -| purchase_date | date    |
    -| units         | int     |
    -+---------------+---------+
    -There is no primary key for this table, it may contain duplicates.
    -Each row of this table indicates the date, units and product_id of each product sold. 
    -
    - -

     

    - -

    Write an SQL query to find the average selling price for each product.

    - -

    average_price should be rounded to 2 decimal places.

    - -

    The query result format is in the following example:

    - -
    -Prices table:
    -+------------+------------+------------+--------+
    -| product_id | start_date | end_date   | price  |
    -+------------+------------+------------+--------+
    -| 1          | 2019-02-17 | 2019-02-28 | 5      |
    -| 1          | 2019-03-01 | 2019-03-22 | 20     |
    -| 2          | 2019-02-01 | 2019-02-20 | 15     |
    -| 2          | 2019-02-21 | 2019-03-31 | 30     |
    -+------------+------------+------------+--------+
    - 
    -UnitsSold table:
    -+------------+---------------+-------+
    -| product_id | purchase_date | units |
    -+------------+---------------+-------+
    -| 1          | 2019-02-25    | 100   |
    -| 1          | 2019-03-01    | 15    |
    -| 2          | 2019-02-10    | 200   |
    -| 2          | 2019-03-22    | 30    |
    -+------------+---------------+-------+
    -
    -Result table:
    -+------------+---------------+
    -| product_id | average_price |
    -+------------+---------------+
    -| 1          | 6.96          |
    -| 2          | 16.96         |
    -+------------+---------------+
    -Average selling price = Total Price of Product / Number of products sold.
    -Average selling price for product 1 = ((100 * 5) + (15 * 20)) / 115 = 6.96
    -Average selling price for product 2 = ((200 * 15) + (30 * 30)) / 230 = 16.96
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/average-time-of-process-per-machine/README.md b/problems/average-time-of-process-per-machine/README.md index f2f9aa0bc..ded7eb2f7 100644 --- a/problems/average-time-of-process-per-machine/README.md +++ b/problems/average-time-of-process-per-machine/README.md @@ -12,3 +12,6 @@ ## [1661. Average Time of Process per Machine (Easy)](https://leetcode.com/problems/average-time-of-process-per-machine "每台机器的进程平均运行时间") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/average-waiting-time/README.md b/problems/average-waiting-time/README.md index 464b5a9ec..e176a9e09 100644 --- a/problems/average-waiting-time/README.md +++ b/problems/average-waiting-time/README.md @@ -59,6 +59,7 @@ So the average waiting time = (2 + 6 + 4 + 1) / 4 = 3.25. ### Related Topics [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/avoid-flood-in-the-city/README.md b/problems/avoid-flood-in-the-city/README.md index 2bb9eba1d..3226de883 100644 --- a/problems/avoid-flood-in-the-city/README.md +++ b/problems/avoid-flood-in-the-city/README.md @@ -93,8 +93,11 @@ After that, it will rain over lakes [1,2]. It's easy to prove that no matter ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/backspace-string-compare/README.md b/problems/backspace-string-compare/README.md index bebe4ff50..af13e23c9 100644 --- a/problems/backspace-string-compare/README.md +++ b/problems/backspace-string-compare/README.md @@ -62,3 +62,5 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/bag-of-tokens/README.md b/problems/bag-of-tokens/README.md index aae003d9f..8b1f6e747 100644 --- a/problems/bag-of-tokens/README.md +++ b/problems/bag-of-tokens/README.md @@ -64,5 +64,6 @@ There is no need to play the 1st token since you cannot play it face ### Related Topics [[Greedy](../../tag/greedy/README.md)] - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/balance-a-binary-search-tree/README.md b/problems/balance-a-binary-search-tree/README.md index 4820ce264..e271036c2 100644 --- a/problems/balance-a-binary-search-tree/README.md +++ b/problems/balance-a-binary-search-tree/README.md @@ -37,7 +37,12 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/balanced-binary-tree/README.md b/problems/balanced-binary-tree/README.md index cd36c5406..26e6aced1 100644 --- a/problems/balanced-binary-tree/README.md +++ b/problems/balanced-binary-tree/README.md @@ -51,8 +51,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Recursion](../../tag/recursion/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Maximum Depth of Binary Tree](../maximum-depth-of-binary-tree) (Easy) diff --git a/problems/bank-account-summary-ii/README.md b/problems/bank-account-summary-ii/README.md index 8556dea06..07e5acb2a 100644 --- a/problems/bank-account-summary-ii/README.md +++ b/problems/bank-account-summary-ii/README.md @@ -12,3 +12,6 @@ ## [1587. Bank Account Summary II (Easy)](https://leetcode.com/problems/bank-account-summary-ii "银行账户概要 II") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/bank-account-summary/README.md b/problems/bank-account-summary/README.md index 541695d7c..3c9ca5b4e 100644 --- a/problems/bank-account-summary/README.md +++ b/problems/bank-account-summary/README.md @@ -12,3 +12,6 @@ ## [1555. Bank Account Summary (Medium)](https://leetcode.com/problems/bank-account-summary "银行账户概要") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/base-7/README.md b/problems/base-7/README.md index c99dfd7bf..9d65ffe95 100644 --- a/problems/base-7/README.md +++ b/problems/base-7/README.md @@ -27,3 +27,6 @@
    • -107 <= num <= 107
    + +### Related Topics + [[Math](../../tag/math/README.md)] diff --git a/problems/baseball-game/README.md b/problems/baseball-game/README.md index ebebcb1ec..27f41d025 100644 --- a/problems/baseball-game/README.md +++ b/problems/baseball-game/README.md @@ -75,3 +75,5 @@ The total sum is 5 + -2 + -4 + 9 + 5 + 14 = 27. ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/basic-calculator-ii/README.md b/problems/basic-calculator-ii/README.md index 16dd1392a..9f1386925 100644 --- a/problems/basic-calculator-ii/README.md +++ b/problems/basic-calculator-ii/README.md @@ -41,6 +41,7 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/basic-calculator-iii/README.md b/problems/basic-calculator-iii/README.md index 2cb1dd8ba..a68a15b09 100644 --- a/problems/basic-calculator-iii/README.md +++ b/problems/basic-calculator-iii/README.md @@ -11,29 +11,12 @@ ## [772. Basic Calculator III (Hard)](https://leetcode.com/problems/basic-calculator-iii "基本计算器 III") -

    Implement a basic calculator to evaluate a simple expression string.

    -

    The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty spaces .

    - -

    The expression string contains only non-negative integers, +, -, *, / operators , open ( and closing parentheses ) and empty spaces . The integer division should truncate toward zero.

    - -

    You may assume that the given expression is always valid. All intermediate results will be in the range of [-2147483648, 2147483647].

    - -

    Some examples:

    - -
    -"1 + 1" = 2
    -" 6-4 / 2 " = 4
    -"2*(5+5*2)/3+(6/2+8)" = 21
    -"(2+6* 3+5- (3*14/7+2)*5)+3"=-12
    -
    - -

     

    - -

    Note: Do not use the eval built-in library function.

    ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/basic-calculator-iv/README.md b/problems/basic-calculator-iv/README.md index e4b997d41..6645b7aa6 100644 --- a/problems/basic-calculator-iv/README.md +++ b/problems/basic-calculator-iv/README.md @@ -11,7 +11,7 @@ ## [770. Basic Calculator IV (Hard)](https://leetcode.com/problems/basic-calculator-iv "基本计算器 IV") -

    Given an expression such as expression = "e + 8 - a + 5" and an evaluation map such as {"e": 1} (given in terms of evalvars = ["e"] and evalints = [1]), return a list of tokens representing the simplified expression, such as ["-1*a","14"]

    +

    Given an expression such as expression = "e + 8 - a + 5" and an evaluation map such as {"e": 1} (given in terms of evalvars = ["e"] and evalints = [1]), return a list of tokens representing the simplified expression, such as ["-1*a","14"]

    • An expression alternates chunks and symbols, with a space separating each chunk and symbol.
    • @@ -19,52 +19,90 @@
    • A variable is a string of lowercase letters (not including digits.) Note that variables can be multiple letters, and note that variables never have a leading coefficient or unary operator like "2x" or "-x".
    -

    Expressions are evaluated in the usual order: brackets first, then multiplication, then addition and subtraction. For example, expression = "1 + 2 * 3" has an answer of ["7"].

    +

    Expressions are evaluated in the usual order: brackets first, then multiplication, then addition and subtraction.

    + +
      +
    • For example, expression = "1 + 2 * 3" has an answer of ["7"].
    • +

    The format of the output is as follows:

      -
    • For each term of free variables with non-zero coefficient, we write the free variables within a term in sorted order lexicographically. For example, we would never write a term like "b*a*c", only "a*b*c".
    • -
    • Terms have degree equal to the number of free variables being multiplied, counting multiplicity. (For example, "a*a*b*c" has degree 4.) We write the largest degree terms of our answer first, breaking ties by lexicographic order ignoring the leading coefficient of the term.
    • -
    • The leading coefficient of the term is placed directly to the left with an asterisk separating it from the variables (if they exist.)  A leading coefficient of 1 is still printed.
    • -
    • An example of a well formatted answer is ["-2*a*a*a", "3*a*a*b", "3*b*b", "4*a", "5*c", "-6"] 
    • -
    • Terms (including constant terms) with coefficient 0 are not included.  For example, an expression of "0" has an output of [].
    • +
    • For each term of free variables with a non-zero coefficient, we write the free variables within a term in sorted order lexicographically. +
        +
      • For example, we would never write a term like "b*a*c", only "a*b*c".
      • +
      +
    • +
    • Terms have degrees equal to the number of free variables being multiplied, counting multiplicity. We write the largest degree terms of our answer first, breaking ties by lexicographic order ignoring the leading coefficient of the term. +
        +
      • For example, "a*a*b*c" has degree 4.
      • +
      +
    • +
    • The leading coefficient of the term is placed directly to the left with an asterisk separating it from the variables (if they exist.) A leading coefficient of 1 is still printed.
    • +
    • An example of a well-formatted answer is ["-2*a*a*a", "3*a*a*b", "3*b*b", "4*a", "5*c", "-6"].
    • +
    • Terms (including constant terms) with coefficient 0 are not included. +
        +
      • For example, an expression of "0" has an output of [].
      • +
      +
    -

    Examples:

    +

     

    +

    Example 1:

     Input: expression = "e + 8 - a + 5", evalvars = ["e"], evalints = [1]
     Output: ["-1*a","14"]
    +
    -Input: expression = "e - 8 + temperature - pressure", -evalvars = ["e", "temperature"], evalints = [1, 12] +

    Example 2:

    + +
    +Input: expression = "e - 8 + temperature - pressure", evalvars = ["e", "temperature"], evalints = [1, 12]
     Output: ["-1*pressure","5"]
    +
    + +

    Example 3:

    +
     Input: expression = "(e + 8) * (e - 8)", evalvars = [], evalints = []
     Output: ["1*e*e","-64"]
    +
    -Input: expression = "7 - 7", evalvars = [], evalints = [] -Output: [] +

    Example 4:

    +
     Input: expression = "a * b * c + b * a * c * 4", evalvars = [], evalints = []
     Output: ["5*a*b*c"]
    +
    -Input: expression = "((a - b) * (b - c) + (c - a)) * ((a - b) + (b - c) * (c - a))", -evalvars = [], evalints = [] +

    Example 5:

    + +
    +Input: expression = "((a - b) * (b - c) + (c - a)) * ((a - b) + (b - c) * (c - a))", evalvars = [], evalints = []
     Output: ["-1*a*a*b*b","2*a*a*b*c","-1*a*a*c*c","1*a*b*b*b","-1*a*b*b*c","-1*a*b*c*c","1*a*c*c*c","-1*b*b*b*c","2*b*b*c*c","-1*b*c*c*c","2*a*a*b","-2*a*a*c","-2*a*b*b","2*a*c*c","1*b*b*b","-1*b*b*c","1*b*c*c","-1*c*c*c","-1*a*a","1*a*b","1*a*c","-1*b*c"]
     
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. expression will have length in range [1, 250].
    2. -
    3. evalvars, evalints will have equal lengths in range [0, 100].
    4. -
    +
      +
    • 1 <= expression.length <= 250
    • +
    • expression consists of lowercase English letters, digits, '+', '-', '*', '(', ')', ' '.
    • +
    • expression does not contain any leading or trailing spaces.
    • +
    • All the tokens in expression are separated by a single space.
    • +
    • 0 <= evalvars.length <= 100
    • +
    • 1 <= evalvars[i].length <= 20
    • +
    • evalvars[i] consists of lowercase English letters.
    • +
    • evalints.length == evalvars.length
    • +
    • -100 <= evalints[i] <= 100
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Recursion](../../tag/recursion/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/basic-calculator/README.md b/problems/basic-calculator/README.md index 20d1f3ef6..6eaa01ff9 100644 --- a/problems/basic-calculator/README.md +++ b/problems/basic-calculator/README.md @@ -57,7 +57,9 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Recursion](../../tag/recursion/README.md)] [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Evaluate Reverse Polish Notation](../evaluate-reverse-polish-notation) (Medium) diff --git a/problems/battleships-in-a-board/README.md b/problems/battleships-in-a-board/README.md index 57d085688..4fd781d03 100644 --- a/problems/battleships-in-a-board/README.md +++ b/problems/battleships-in-a-board/README.md @@ -42,3 +42,8 @@

     

    Follow up: Could you do it in one-pass, using only O(1) extra memory and without modifying the values board?

    + +### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/beautiful-arrangement-ii/README.md b/problems/beautiful-arrangement-ii/README.md index 1583978ce..2b4e92760 100644 --- a/problems/beautiful-arrangement-ii/README.md +++ b/problems/beautiful-arrangement-ii/README.md @@ -45,6 +45,7 @@ Explanation: The [1,3,2] has three different positive integers ranging from 1 to ### Related Topics [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Beautiful Arrangement](../beautiful-arrangement) (Medium) diff --git a/problems/beautiful-arrangement/README.md b/problems/beautiful-arrangement/README.md index fa70246ff..71b7abe0f 100644 --- a/problems/beautiful-arrangement/README.md +++ b/problems/beautiful-arrangement/README.md @@ -50,8 +50,11 @@ The second beautiful arrangement is [2,1]: ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Similar Questions 1. [Beautiful Arrangement II](../beautiful-arrangement-ii) (Medium) diff --git a/problems/beautiful-array/README.md b/problems/beautiful-array/README.md index 7164c7187..f5af73d91 100644 --- a/problems/beautiful-array/README.md +++ b/problems/beautiful-array/README.md @@ -47,4 +47,6 @@
    ### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] diff --git a/problems/before-and-after-puzzle/README.md b/problems/before-and-after-puzzle/README.md index d11a38180..4c1aa70cf 100644 --- a/problems/before-and-after-puzzle/README.md +++ b/problems/before-and-after-puzzle/README.md @@ -11,60 +11,13 @@ ## [1181. Before and After Puzzle (Medium)](https://leetcode.com/problems/before-and-after-puzzle "前后拼接") -

    Given a list of phrases, generate a list of Before and After puzzles.

    -

    A phrase is a string that consists of lowercase English letters and spaces only. No space appears in the start or the end of a phrase. There are no consecutive spaces in a phrase.

    - -

    Before and After puzzles are phrases that are formed by merging two phrases where the last word of the first phrase is the same as the first word of the second phrase.

    - -

    Return the Before and After puzzles that can be formed by every two phrases phrases[i] and phrases[j] where i != j. Note that the order of matching two phrases matters, we want to consider both orders.

    - -

    You should return a list of distinct strings sorted lexicographically.

    - -

     

    -

    Example 1:

    - -
    -Input: phrases = ["writing code","code rocks"]
    -Output: ["writing code rocks"]
    -
    - -

    Example 2:

    - -
    -Input: phrases = ["mission statement",
    -                  "a quick bite to eat",
    -                  "a chip off the old block",
    -                  "chocolate bar",
    -                  "mission impossible",
    -                  "a man on a mission",
    -                  "block party",
    -                  "eat my words",
    -                  "bar of soap"]
    -Output: ["a chip off the old block party",
    -         "a man on a mission impossible",
    -         "a man on a mission statement",
    -         "a quick bite to eat my words",
    -         "chocolate bar of soap"]
    -
    - -

    Example 3:

    - -
    -Input: phrases = ["a","b","a"]
    -Output: ["a"]
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= phrases.length <= 100
    • -
    • 1 <= phrases[i].length <= 100
    • -
    ### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/best-meeting-point/README.md b/problems/best-meeting-point/README.md index bb2a41eb3..84cc36cbc 100644 --- a/problems/best-meeting-point/README.md +++ b/problems/best-meeting-point/README.md @@ -11,28 +11,13 @@ ## [296. Best Meeting Point (Hard)](https://leetcode.com/problems/best-meeting-point "最佳的碰头地点") -

    A group of two or more people wants to meet and minimize the total travel distance. You are given a 2D grid of values 0 or 1, where each 1 marks the home of someone in the group. The distance is calculated using Manhattan Distance, where distance(p1, p2) = |p2.x - p1.x| + |p2.y - p1.y|.

    -

    Example:

    - -
    -Input: 
    -
    -1 - 0 - 0 - 0 - 1
    -|   |   |   |   |
    -0 - 0 - 0 - 0 - 0
    -|   |   |   |   |
    -0 - 0 - 1 - 0 - 0
    -
    -Output: 6 
    -
    -Explanation: Given three people living at (0,0), (0,4), and (2,2):
    -             The point (0,2) is an ideal meeting point, as the total travel distance 
    -             of 2+2+2=6 is minimal. So return 6.
    ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Shortest Distance from All Buildings](../shortest-distance-from-all-buildings) (Hard) diff --git a/problems/best-position-for-a-service-centre/README.md b/problems/best-position-for-a-service-centre/README.md index 068e39a02..43f17ed8d 100644 --- a/problems/best-position-for-a-service-centre/README.md +++ b/problems/best-position-for-a-service-centre/README.md @@ -72,6 +72,8 @@ Be careful with the precision! ### Related Topics [[Geometry](../../tag/geometry/README.md)] + [[Math](../../tag/math/README.md)] + [[Randomized](../../tag/randomized/README.md)] ### Hints
    diff --git a/problems/best-sightseeing-pair/README.md b/problems/best-sightseeing-pair/README.md index 25ba93e5d..da2981efc 100644 --- a/problems/best-sightseeing-pair/README.md +++ b/problems/best-sightseeing-pair/README.md @@ -43,6 +43,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/best-team-with-no-conflicts/README.md b/problems/best-team-with-no-conflicts/README.md index fda2227b6..ec9b2440d 100644 --- a/problems/best-team-with-no-conflicts/README.md +++ b/problems/best-team-with-no-conflicts/README.md @@ -53,7 +53,9 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/best-time-to-buy-and-sell-stock-ii/README.md b/problems/best-time-to-buy-and-sell-stock-ii/README.md index 8052d1e8b..a7a81fda5 100644 --- a/problems/best-time-to-buy-and-sell-stock-ii/README.md +++ b/problems/best-time-to-buy-and-sell-stock-ii/README.md @@ -55,6 +55,7 @@ Note that you cannot buy on day 1, buy on day 2 and sell them later, as you are ### Related Topics [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Best Time to Buy and Sell Stock](../best-time-to-buy-and-sell-stock) (Easy) diff --git a/problems/best-time-to-buy-and-sell-stock-iv/README.md b/problems/best-time-to-buy-and-sell-stock-iv/README.md index 5683ae33f..85facb4d4 100644 --- a/problems/best-time-to-buy-and-sell-stock-iv/README.md +++ b/problems/best-time-to-buy-and-sell-stock-iv/README.md @@ -44,6 +44,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md b/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md index 98b415a4f..b4d4bd417 100644 --- a/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md +++ b/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md @@ -46,6 +46,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/big-countries/README.md b/problems/big-countries/README.md index 433c5c428..ff5363393 100644 --- a/problems/big-countries/README.md +++ b/problems/big-countries/README.md @@ -41,3 +41,6 @@

     

    + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/biggest-single-number/README.md b/problems/biggest-single-number/README.md index 71435f4ab..23a0f8647 100644 --- a/problems/biggest-single-number/README.md +++ b/problems/biggest-single-number/README.md @@ -11,31 +11,7 @@ ## [619. Biggest Single Number (Easy)](https://leetcode.com/problems/biggest-single-number "只出现一次的最大数字") -

    Table my_numbers contains many numbers in column num including duplicated ones.
    -Can you write a SQL query to find the biggest number, which only appears once.

    -
    -+---+
    -|num|
    -+---+
    -| 8 |
    -| 8 |
    -| 3 |
    -| 3 |
    -| 1 |
    -| 4 |
    -| 5 |
    -| 6 | 
    -
    -For the sample data above, your query should return the following result: -
    -+---+
    -|num|
    -+---+
    -| 6 |
    -
    -Note:
    -If there is no such number, just output null. - -

     

    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/biggest-window-between-visits/README.md b/problems/biggest-window-between-visits/README.md index ab2a55cb3..1403336f8 100644 --- a/problems/biggest-window-between-visits/README.md +++ b/problems/biggest-window-between-visits/README.md @@ -12,3 +12,6 @@ ## [1709. Biggest Window Between Visits (Medium)](https://leetcode.com/problems/biggest-window-between-visits "访问日期之间最大的空档期") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/binary-gap/README.md b/problems/binary-gap/README.md index c87e63388..ba1264dc0 100644 --- a/problems/binary-gap/README.md +++ b/problems/binary-gap/README.md @@ -68,4 +68,5 @@ There aren't any adjacent pairs of 1's in the binary representation of 8 ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/binary-prefix-divisible-by-5/README.md b/problems/binary-prefix-divisible-by-5/README.md index 0afdae95f..05535257d 100644 --- a/problems/binary-prefix-divisible-by-5/README.md +++ b/problems/binary-prefix-divisible-by-5/README.md @@ -11,48 +11,54 @@ ## [1018. Binary Prefix Divisible By 5 (Easy)](https://leetcode.com/problems/binary-prefix-divisible-by-5 "可被 5 整除的二进制前缀") -

    Given an array nums of 0s and 1s, consider xi: the i-th subarray from nums[0] to nums[i] interpreted as a binary number (from most-significant-bit to least-significant-bit.)

    +

    You are given a binary array nums (0-indexed).

    -

    Return a list of booleans answer, where answer[i] is true if and only if xi is divisible by 5.

    +

    We define xi as the number whose binary representation is the subarray nums[0..i] (from most-significant-bit to least-significant-bit).

    +
      +
    • For example, if nums = [1,0,1], then x0 = 1, x1 = 2, and x2 = 5.
    • +
    + +

    Return an array of booleans answer where answer[i] is true if xi is divisible by 5.

    + +

     

    Example 1:

    -Input: nums = [0,1,1]
    -Output: [true,false,false]
    -Explanation: 
    -The input numbers in binary are 0, 01, 011; which are 0, 1, and 3 in base-10.  Only the first number is divisible by 5, so answer[0] is true.
    +Input: nums = [0,1,1]
    +Output: [true,false,false]
    +Explanation: The input numbers in binary are 0, 01, 011; which are 0, 1, and 3 in base-10.
    +Only the first number is divisible by 5, so answer[0] is true.
     

    Example 2:

    -Input: nums = [1,1,1]
    -Output: [false,false,false]
    +Input: nums = [1,1,1]
    +Output: [false,false,false]
     

    Example 3:

    -Input: nums = [0,1,1,1,1,1]
    -Output: [true,false,false,false,true,false]
    +Input: nums = [0,1,1,1,1,1]
    +Output: [true,false,false,false,true,false]
     

    Example 4:

    -Input: nums = [1,1,1,0,1]
    -Output: [false,false,false,false,false]
    +Input: nums = [1,1,1,0,1]
    +Output: [false,false,false,false,false]
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= nums.length <= 30000
    2. -
    3. nums[i] is 0 or 1
    4. -
    +
      +
    • 1 <= nums.length <= 105
    • +
    • nums[i] is 0 or 1.
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/binary-search-tree-iterator-ii/README.md b/problems/binary-search-tree-iterator-ii/README.md index 0a5c2d50d..de7bcc43e 100644 --- a/problems/binary-search-tree-iterator-ii/README.md +++ b/problems/binary-search-tree-iterator-ii/README.md @@ -14,8 +14,12 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] [[Design](../../tag/design/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] + [[Iterator](../../tag/iterator/README.md)] ### Hints
    diff --git a/problems/binary-search-tree-iterator/README.md b/problems/binary-search-tree-iterator/README.md index f6ba38bbc..cbac9f23f 100644 --- a/problems/binary-search-tree-iterator/README.md +++ b/problems/binary-search-tree-iterator/README.md @@ -66,6 +66,9 @@ bSTIterator.hasNext(); // return False [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] [[Design](../../tag/design/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] + [[Iterator](../../tag/iterator/README.md)] ### Similar Questions 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Easy) diff --git a/problems/binary-search-tree-to-greater-sum-tree/README.md b/problems/binary-search-tree-to-greater-sum-tree/README.md index d0ef4fb73..1ce358b4e 100644 --- a/problems/binary-search-tree-to-greater-sum-tree/README.md +++ b/problems/binary-search-tree-to-greater-sum-tree/README.md @@ -64,9 +64,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] - [[Recursion](../../tag/recursion/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/binary-search/README.md b/problems/binary-search/README.md index 86af03434..551d40e5b 100644 --- a/problems/binary-search/README.md +++ b/problems/binary-search/README.md @@ -13,7 +13,7 @@

    Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1.

    -

    You must write an algorithm with O(log n) runtime complexity.

    +

    You must write an algorithm with O(log n) runtime complexity.

     

    Example 1:

    @@ -37,12 +37,13 @@
    • 1 <= nums.length <= 104
    • -
    • -9999 <= nums[i], target <= 9999
    • +
    • -104 < nums[i], target < 104
    • All the integers in nums are unique.
    • -
    • nums is sorted in an ascending order.
    • +
    • nums is sorted in ascending order.
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions diff --git a/problems/binary-subarrays-with-sum/README.md b/problems/binary-subarrays-with-sum/README.md index cc30e8af5..e68171cd9 100644 --- a/problems/binary-subarrays-with-sum/README.md +++ b/problems/binary-subarrays-with-sum/README.md @@ -45,5 +45,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] diff --git a/problems/binary-tree-cameras/README.md b/problems/binary-tree-cameras/README.md index bebbe1d3e..effd99d34 100644 --- a/problems/binary-tree-cameras/README.md +++ b/problems/binary-tree-cameras/README.md @@ -42,8 +42,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Distribute Coins in Binary Tree](../distribute-coins-in-binary-tree) (Medium) diff --git a/problems/binary-tree-coloring-game/README.md b/problems/binary-tree-coloring-game/README.md index ee44c1142..243581a7b 100644 --- a/problems/binary-tree-coloring-game/README.md +++ b/problems/binary-tree-coloring-game/README.md @@ -41,7 +41,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/binary-tree-inorder-traversal/README.md b/problems/binary-tree-inorder-traversal/README.md index 34b7744fe..a64db82ed 100644 --- a/problems/binary-tree-inorder-traversal/README.md +++ b/problems/binary-tree-inorder-traversal/README.md @@ -63,7 +63,8 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Validate Binary Search Tree](../validate-binary-search-tree) (Medium) diff --git a/problems/binary-tree-level-order-traversal-ii/README.md b/problems/binary-tree-level-order-traversal-ii/README.md index 8affa67ef..0bd7a20bc 100644 --- a/problems/binary-tree-level-order-traversal-ii/README.md +++ b/problems/binary-tree-level-order-traversal-ii/README.md @@ -45,7 +45,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Binary Tree Level Order Traversal](../binary-tree-level-order-traversal) (Medium) diff --git a/problems/binary-tree-level-order-traversal/README.md b/problems/binary-tree-level-order-traversal/README.md index 14a022f14..31bcd1c24 100644 --- a/problems/binary-tree-level-order-traversal/README.md +++ b/problems/binary-tree-level-order-traversal/README.md @@ -45,7 +45,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Binary Tree Zigzag Level Order Traversal](../binary-tree-zigzag-level-order-traversal) (Medium) diff --git a/problems/binary-tree-longest-consecutive-sequence-ii/README.md b/problems/binary-tree-longest-consecutive-sequence-ii/README.md index 8347fe2f1..48a539084 100644 --- a/problems/binary-tree-longest-consecutive-sequence-ii/README.md +++ b/problems/binary-tree-longest-consecutive-sequence-ii/README.md @@ -11,40 +11,12 @@ ## [549. Binary Tree Longest Consecutive Sequence II (Medium)](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence-ii "二叉树中最长的连续序列") -

    Given a binary tree, you need to find the length of Longest Consecutive Path in Binary Tree.

    -

    Especially, this path can be either increasing or decreasing. For example, [1,2,3,4] and [4,3,2,1] are both considered valid, but the path [1,2,4,3] is not valid. On the other hand, the path can be in the child-Parent-child order, where not necessarily be parent-child order.

    - -

    Example 1:

    - -
    -Input:
    -        1
    -       / \
    -      2   3
    -Output: 2
    -Explanation: The longest consecutive path is [1, 2] or [2, 1].
    -
    - -

     

    - -

    Example 2:

    - -
    -Input:
    -        2
    -       / \
    -      1   3
    -Output: 3
    -Explanation: The longest consecutive path is [1, 2, 3] or [3, 2, 1].
    -
    - -

     

    - -

    Note: All the values of tree nodes are in the range of [-1e7, 1e7].

    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Binary Tree Longest Consecutive Sequence](../binary-tree-longest-consecutive-sequence) (Medium) diff --git a/problems/binary-tree-longest-consecutive-sequence/README.md b/problems/binary-tree-longest-consecutive-sequence/README.md index f7aca22d7..b42983f61 100644 --- a/problems/binary-tree-longest-consecutive-sequence/README.md +++ b/problems/binary-tree-longest-consecutive-sequence/README.md @@ -11,46 +11,12 @@ ## [298. Binary Tree Longest Consecutive Sequence (Medium)](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence "二叉树最长连续序列") -

    Given a binary tree, find the length of the longest consecutive sequence path.

    -

    The path refers to any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The longest consecutive path need to be from parent to child (cannot be the reverse).

    - -

    Example 1:

    - -
    -Input:
    -
    -   1
    -    \
    -     3
    -    / \
    -   2   4
    -        \
    -         5
    -
    -Output: 3
    -
    -Explanation: Longest consecutive sequence path is 3-4-5, so return 3.
    - -

    Example 2:

    - -
    -Input:
    -
    -   2
    -    \
    -     3
    -    / 
    -   2    
    -  / 
    - 1
    -
    -Output: 2 
    -
    -Explanation: Longest consecutive sequence path is 2-3, not 3-2-1, so return 2.
    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Longest Consecutive Sequence](../longest-consecutive-sequence) (Medium) diff --git a/problems/binary-tree-maximum-path-sum/README.md b/problems/binary-tree-maximum-path-sum/README.md index e77db851b..f964f3ee9 100644 --- a/problems/binary-tree-maximum-path-sum/README.md +++ b/problems/binary-tree-maximum-path-sum/README.md @@ -44,8 +44,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Recursion](../../tag/recursion/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Path Sum](../path-sum) (Easy) diff --git a/problems/binary-tree-paths/README.md b/problems/binary-tree-paths/README.md index 83f4c5226..d91fa309d 100644 --- a/problems/binary-tree-paths/README.md +++ b/problems/binary-tree-paths/README.md @@ -40,7 +40,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[String](../../tag/string/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Path Sum II](../path-sum-ii) (Medium) diff --git a/problems/binary-tree-postorder-traversal/README.md b/problems/binary-tree-postorder-traversal/README.md index 029693b66..0828461f3 100644 --- a/problems/binary-tree-postorder-traversal/README.md +++ b/problems/binary-tree-postorder-traversal/README.md @@ -63,6 +63,8 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Easy) diff --git a/problems/binary-tree-preorder-traversal/README.md b/problems/binary-tree-preorder-traversal/README.md index 156ffc22e..e0333b39e 100644 --- a/problems/binary-tree-preorder-traversal/README.md +++ b/problems/binary-tree-preorder-traversal/README.md @@ -63,6 +63,8 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Easy) diff --git a/problems/binary-tree-pruning/README.md b/problems/binary-tree-pruning/README.md index ee3e48c9e..316f3dc32 100644 --- a/problems/binary-tree-pruning/README.md +++ b/problems/binary-tree-pruning/README.md @@ -50,3 +50,5 @@ The diagram on the right represents the answer. ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/binary-tree-right-side-view/README.md b/problems/binary-tree-right-side-view/README.md index 22244fcf6..792501a62 100644 --- a/problems/binary-tree-right-side-view/README.md +++ b/problems/binary-tree-right-side-view/README.md @@ -45,10 +45,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] - [[Recursion](../../tag/recursion/README.md)] - [[Queue](../../tag/queue/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Populating Next Right Pointers in Each Node](../populating-next-right-pointers-in-each-node) (Medium) diff --git a/problems/binary-tree-tilt/README.md b/problems/binary-tree-tilt/README.md index 508eecacf..39e9371ae 100644 --- a/problems/binary-tree-tilt/README.md +++ b/problems/binary-tree-tilt/README.md @@ -60,8 +60,8 @@ Sum of every tilt : 0 + 0 + 0 + 2 + 7 + 6 = 15 ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Recursion](../../tag/recursion/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/binary-tree-upside-down/README.md b/problems/binary-tree-upside-down/README.md index 5a034ea82..2fe055baa 100644 --- a/problems/binary-tree-upside-down/README.md +++ b/problems/binary-tree-upside-down/README.md @@ -11,50 +11,12 @@ ## [156. Binary Tree Upside Down (Medium)](https://leetcode.com/problems/binary-tree-upside-down "上下翻转二叉树") -

    Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty, flip it upside down and turn it into a tree where the original right nodes turned into left leaf nodes. Return the new root.

    -

    Example:

    - -
    -Input: [1,2,3,4,5]
    -
    -    1
    -   / \
    -  2   3
    - / \
    -4   5
    -
    -Output: return the root of the binary tree [4,5,2,#,#,3,1]
    -
    -   4
    -  / \
    - 5   2
    -    / \
    -   3   1  
    -
    - -

    Clarification:

    - -

    Confused what [4,5,2,#,#,3,1] means? Read more below on how binary tree is serialized on OJ.

    - -

    The serialization of a binary tree follows a level order traversal, where '#' signifies a path terminator where no node exists below.

    - -

    Here's an example:

    - -
    -   1
    -  / \
    - 2   3
    -    /
    -   4
    -    \
    -     5
    -
    - -

    The above binary tree is serialized as [1,2,3,#,#,4,#,#,5].

    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Reverse Linked List](../reverse-linked-list) (Easy) diff --git a/problems/binary-tree-vertical-order-traversal/README.md b/problems/binary-tree-vertical-order-traversal/README.md index 90197094e..b26f1dbd7 100644 --- a/problems/binary-tree-vertical-order-traversal/README.md +++ b/problems/binary-tree-vertical-order-traversal/README.md @@ -11,87 +11,14 @@ ## [314. Binary Tree Vertical Order Traversal (Medium)](https://leetcode.com/problems/binary-tree-vertical-order-traversal "二叉树的垂直遍历") -

    Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column).

    -

    If two nodes are in the same row and column, the order should be from left to right.

    - -

    Examples 1:

    - -
    -Input: [3,9,20,null,null,15,7]
    -
    -   3
    -  /\
    - /  \
    - 9  20
    -    /\
    -   /  \
    -  15   7 
    -
    -Output:
    -
    -[
    -  [9],
    -  [3,15],
    -  [20],
    -  [7]
    -]
    -
    - -

    Examples 2:

    - -
    -Input: [3,9,8,4,0,1,7]
    -
    -     3
    -    /\
    -   /  \
    -   9   8
    -  /\  /\
    - /  \/  \
    - 4  01   7 
    -
    -Output:
    -
    -[
    -  [4],
    -  [9],
    -  [3,0,1],
    -  [8],
    -  [7]
    -]
    -
    - -

    Examples 3:

    - -
    -Input: [3,9,8,4,0,1,7,null,null,null,2,5] (0's right child is 2 and 1's left child is 5)
    -
    -     3
    -    /\
    -   /  \
    -   9   8
    -  /\  /\
    - /  \/  \
    - 4  01   7
    -    /\
    -   /  \
    -   5   2
    -
    -Output:
    -
    -[
    -  [4],
    -  [9,5],
    -  [3,0,1],
    -  [8,2],
    -  [7]
    -]
    -
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Binary Tree Level Order Traversal](../binary-tree-level-order-traversal) (Medium) diff --git a/problems/binary-tree-zigzag-level-order-traversal/README.md b/problems/binary-tree-zigzag-level-order-traversal/README.md index fee5e1949..b5819034d 100644 --- a/problems/binary-tree-zigzag-level-order-traversal/README.md +++ b/problems/binary-tree-zigzag-level-order-traversal/README.md @@ -44,9 +44,9 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Binary Tree Level Order Traversal](../binary-tree-level-order-traversal) (Medium) diff --git a/problems/binary-trees-with-factors/README.md b/problems/binary-trees-with-factors/README.md index 48ecd79c9..c944e4364 100644 --- a/problems/binary-trees-with-factors/README.md +++ b/problems/binary-trees-with-factors/README.md @@ -40,3 +40,8 @@
  • 2 <= arr[i] <= 109
  • All the values of arr are unique.
  • + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/bitwise-ors-of-subarrays/README.md b/problems/bitwise-ors-of-subarrays/README.md index f9fadacdc..b86c8a8a0 100644 --- a/problems/bitwise-ors-of-subarrays/README.md +++ b/problems/bitwise-ors-of-subarrays/README.md @@ -54,4 +54,5 @@ There are 3 unique values, so the answer is 3. ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/boats-to-save-people/README.md b/problems/boats-to-save-people/README.md index 0c7d5be79..e28fa8897 100644 --- a/problems/boats-to-save-people/README.md +++ b/problems/boats-to-save-people/README.md @@ -50,4 +50,6 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/bold-words-in-string/README.md b/problems/bold-words-in-string/README.md index 7235b2a54..ffbdaa36d 100644 --- a/problems/bold-words-in-string/README.md +++ b/problems/bold-words-in-string/README.md @@ -11,24 +11,14 @@ ## [758. Bold Words in String (Medium)](https://leetcode.com/problems/bold-words-in-string "字符串中的加粗单词") -

    -Given a set of keywords words and a string S, make all appearances of all keywords in S bold. Any letters between <b> and </b> tags become bold. -

    -The returned string should use the least number of tags possible, and of course the tags should form a valid combination. -

    -

    -For example, given that words = ["ab", "bc"] and S = "aabcd", we should return "a<b>abc</b>d". Note that returning "a<b>a<b>b</b>c</b>d" would use more tags, so it is incorrect. -

    -

    Note:

      -
    1. words has length in range [0, 50].
    2. -
    3. words[i] has length in range [1, 10].
    4. -
    5. S has length in range [0, 500].
    6. -
    7. All characters in words[i] and S are lowercase letters.
    8. -

    ### Related Topics + [[Trie](../../tag/trie/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[String Matching](../../tag/string-matching/README.md)] ### Hints
    diff --git a/problems/bomb-enemy/README.md b/problems/bomb-enemy/README.md index 635b337f8..454322602 100644 --- a/problems/bomb-enemy/README.md +++ b/problems/bomb-enemy/README.md @@ -11,24 +11,9 @@ ## [361. Bomb Enemy (Medium)](https://leetcode.com/problems/bomb-enemy "轰炸敌人") -

    Given a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero), return the maximum enemies you can kill using one bomb.
    -The bomb kills all the enemies in the same row and column from the planted point until it hits the wall since the wall is too strong to be destroyed.
    -Note: You can only put the bomb at an empty cell.

    -

    Example:

    - -
    -
    -Input: [["0","E","0","0"],["E","0","W","E"],["0","E","0","0"]]
    -Output: 3 
    -Explanation: For the given grid,
    -
    -0 E 0 0 
    -E 0 W E 
    -0 E 0 0
    -
    -Placing a bomb at (1,1) kills 3 enemies.
    -
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/boundary-of-binary-tree/README.md b/problems/boundary-of-binary-tree/README.md index 42239e8f7..73b39ad56 100644 --- a/problems/boundary-of-binary-tree/README.md +++ b/problems/boundary-of-binary-tree/README.md @@ -11,62 +11,12 @@ ## [545. Boundary of Binary Tree (Medium)](https://leetcode.com/problems/boundary-of-binary-tree "二叉树的边界") -

    Given a binary tree, return the values of its boundary in anti-clockwise direction starting from root. Boundary includes left boundary, leaves, and right boundary in order without duplicate nodes.  (The values of the nodes may still be duplicates.)

    -

    Left boundary is defined as the path from root to the left-most node. Right boundary is defined as the path from root to the right-most node. If the root doesn't have left subtree or right subtree, then the root itself is left boundary or right boundary. Note this definition only applies to the input binary tree, and not applies to any subtrees.

    - -

    The left-most node is defined as a leaf node you could reach when you always firstly travel to the left subtree if exists. If not, travel to the right subtree. Repeat until you reach a leaf node.

    - -

    The right-most node is also defined by the same way with left and right exchanged.

    - -

    Example 1

    - -
    -Input:
    -  1
    -   \
    -    2
    -   / \
    -  3   4
    -
    -Ouput:
    -[1, 3, 4, 2]
    -
    -Explanation:
    -The root doesn't have left subtree, so the root itself is left boundary.
    -The leaves are node 3 and 4.
    -The right boundary are node 1,2,4. Note the anti-clockwise direction means you should output reversed right boundary.
    -So order them in anti-clockwise without duplicates and we have [1,3,4,2].
    -
    - -

     

    - -

    Example 2

    - -
    -Input:
    -    ____1_____
    -   /          \
    -  2            3
    - / \          / 
    -4   5        6   
    -   / \      / \
    -  7   8    9  10  
    -       
    -Ouput:
    -[1,2,4,7,8,9,10,6,3]
    -
    -Explanation:
    -The left boundary are node 1,2,4. (4 is the left-most node according to definition)
    -The leaves are node 4,7,8,9,10.
    -The right boundary are node 1,3,6,10. (10 is the right-most node).
    -So order them in anti-clockwise without duplicate nodes we have [1,2,4,7,8,9,10,6,3].
    -
    - -

     

    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Binary Tree Right Side View](../binary-tree-right-side-view) (Medium) diff --git a/problems/brace-expansion-ii/README.md b/problems/brace-expansion-ii/README.md index e8691c186..fa56a935b 100644 --- a/problems/brace-expansion-ii/README.md +++ b/problems/brace-expansion-ii/README.md @@ -11,7 +11,7 @@ ## [1096. Brace Expansion II (Hard)](https://leetcode.com/problems/brace-expansion-ii "花括号展开 II") -

    Under a grammar given below, strings can represent a set of lowercase words.  Let's use R(expr) to denote the set of words the expression represents.

    +

    Under the grammar given below, strings can represent a set of lowercase words. Let's use R(expr) to denote the set of words the expression represents.

    Grammar can best be understood through simple examples:

    @@ -22,63 +22,60 @@
  • R("w") = {"w"}
  • -
  • When we take a comma delimited list of 2 or more expressions, we take the union of possibilities. +
  • When we take a comma-delimited list of two or more expressions, we take the union of possibilities.
    • R("{a,b,c}") = {"a","b","c"}
    • -
    • R("{{a,b},{b,c}}") = {"a","b","c"} (notice the final set only contains each word at most once)
    • +
    • R("{{a,b},{b,c}}") = {"a","b","c"} (notice the final set only contains each word at most once)
  • When we concatenate two expressions, we take the set of possible concatenations between two words where the first word comes from the first expression and the second word comes from the second expression.
    • R("{a,b}{c,d}") = {"ac","ad","bc","bd"}
    • -
    • R("a{b,c}{d,e}f{g,h}") = {"abdfg", "abdfh", "abefg", "abefh", "acdfg", "acdfh", "acefg", "acefh"}
    • +
    • R("a{b,c}{d,e}f{g,h}") = {"abdfg", "abdfh", "abefg", "abefh", "acdfg", "acdfh", "acefg", "acefh"}
  • -

    Formally, the 3 rules for our grammar:

    +

    Formally, the three rules for our grammar:

      -
    • For every lowercase letter x, we have R(x) = {x}
    • -
    • For expressions e_1, e_2, ... , e_k with k >= 2, we have R({e_1,e_2,...}) = R(e_1) ∪ R(e_2) ∪ ...
    • -
    • For expressions e_1 and e_2, we have R(e_1 + e_2) = {a + b for (a, b) in R(e_1) × R(e_2)}, where + denotes concatenation, and × denotes the cartesian product.
    • +
    • For every lowercase letter x, we have R(x) = {x}.
    • +
    • For expressions e1, e2, ... , ek with k >= 2, we have R({e1, e2, ...}) = R(e1) ∪ R(e2) ∪ ...
    • +
    • For expressions e1 and e2, we have R(e1 + e2) = {a + b for (a, b) in R(e1) × R(e2)}, where + denotes concatenation, and × denotes the cartesian product.
    -

    Given an expression representing a set of words under the given grammar, return the sorted list of words that the expression represents.

    +

    Given an expression representing a set of words under the given grammar, return the sorted list of words that the expression represents.

     

    - -

    Example 1:

    -Input: "{a,b}{c,{d,e}}"
    -Output: ["ac","ad","ae","bc","bd","be"]
    +Input: expression = "{a,b}{c,{d,e}}"
    +Output: ["ac","ad","ae","bc","bd","be"]
     
    -

    Example 2:

    -Input: "{{a,z},a{b,c},{ab,z}}"
    -Output: ["a","ab","ac","z"]
    -Explanation: Each distinct word is written only once in the final answer.
    +Input: expression = "{{a,z},a{b,c},{ab,z}}"
    +Output: ["a","ab","ac","z"]
    +Explanation: Each distinct word is written only once in the final answer.
     

     

    -

    Constraints:

    -
      +
      • 1 <= expression.length <= 60
      • expression[i] consists of '{', '}', ','or lowercase English letters.
      • The given expression represents a set of words based on the grammar given in the description.
      • -
    -
    -
    + ### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[String](../../tag/string/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions 1. [Brace Expansion](../brace-expansion) (Medium) diff --git a/problems/brace-expansion/README.md b/problems/brace-expansion/README.md index 67cf74d3b..b215da2c5 100644 --- a/problems/brace-expansion/README.md +++ b/problems/brace-expansion/README.md @@ -11,41 +11,11 @@ ## [1087. Brace Expansion (Medium)](https://leetcode.com/problems/brace-expansion "花括号展开") -

    A string S represents a list of words.

    -

    Each letter in the word has 1 or more options.  If there is one option, the letter is represented as is.  If there is more than one option, then curly braces delimit the options.  For example, "{a,b,c}" represents options ["a", "b", "c"].

    - -

    For example, "{a,b,c}d{e,f}" represents the list ["ade", "adf", "bde", "bdf", "cde", "cdf"].

    - -

    Return all words that can be formed in this manner, in lexicographical order.

    - -

     

    - -

    Example 1:

    - -
    -Input: "{a,b}c{d,e}f"
    -Output: ["acdf","acef","bcdf","bcef"]
    -
    - -

    Example 2:

    - -
    -Input: "abcd"
    -Output: ["abcd"]
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= S.length <= 50
    2. -
    3. There are no nested curly brackets.
    4. -
    5. All characters inside a pair of consecutive opening and ending curly brackets are different.
    6. -
    ### Related Topics + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions diff --git a/problems/break-a-palindrome/README.md b/problems/break-a-palindrome/README.md index 062474487..da9de05c1 100644 --- a/problems/break-a-palindrome/README.md +++ b/problems/break-a-palindrome/README.md @@ -57,6 +57,7 @@ Of all the ways, "aaccba" is the lexicographically smallest. ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/brick-wall/README.md b/problems/brick-wall/README.md index 6a24f2f4e..350f76c73 100644 --- a/problems/brick-wall/README.md +++ b/problems/brick-wall/README.md @@ -45,4 +45,5 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/bricks-falling-when-hit/README.md b/problems/bricks-falling-when-hit/README.md index 49c4d99d3..cc73a4f95 100644 --- a/problems/bricks-falling-when-hit/README.md +++ b/problems/bricks-falling-when-hit/README.md @@ -80,3 +80,5 @@ Hence the result is [0,0]. ### Related Topics [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/buddy-strings/README.md b/problems/buddy-strings/README.md index 91ee10f90..ebe14bc06 100644 --- a/problems/buddy-strings/README.md +++ b/problems/buddy-strings/README.md @@ -60,4 +60,5 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/build-an-array-with-stack-operations/README.md b/problems/build-an-array-with-stack-operations/README.md index 4fdc98a70..60dd71263 100644 --- a/problems/build-an-array-with-stack-operations/README.md +++ b/problems/build-an-array-with-stack-operations/README.md @@ -69,6 +69,8 @@ Read number 3 and automatically push in the array -> [1,3] ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/build-array-from-permutation/README.md b/problems/build-array-from-permutation/README.md new file mode 100644 index 000000000..9216a4a8d --- /dev/null +++ b/problems/build-array-from-permutation/README.md @@ -0,0 +1,64 @@ + + + + + + + +[< Previous](../leetcodify-similar-friends "Leetcodify Similar Friends") +                 +[Next >](../eliminate-maximum-number-of-monsters "Eliminate Maximum Number of Monsters") + +## [1920. Build Array from Permutation (Easy)](https://leetcode.com/problems/build-array-from-permutation "基于排列构建数组") + +

    Given a zero-based permutation nums (0-indexed), build an array ans of the same length where ans[i] = nums[nums[i]] for each 0 <= i < nums.length and return it.

    + +

    A zero-based permutation nums is an array of distinct integers from 0 to nums.length - 1 (inclusive).

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [0,2,1,5,3,4]
    +Output: [0,1,2,4,5,3]
    +Explanation: The array ans is built as follows: 
    +ans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]]
    +    = [nums[0], nums[2], nums[1], nums[5], nums[3], nums[4]]
    +    = [0,1,2,4,5,3]
    + +

    Example 2:

    + +
    +Input: nums = [5,0,1,2,3,4]
    +Output: [4,5,0,1,2,3]
    +Explanation: The array ans is built as follows:
    +ans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]]
    +    = [nums[5], nums[0], nums[1], nums[2], nums[3], nums[4]]
    +    = [4,5,0,1,2,3]
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • 0 <= nums[i] < nums.length
    • +
    • The elements in nums are distinct.
    • +
    + +

     

    +

    Follow-up: Can you solve it without using an extra space (i.e., O(1) memory)?

    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Just apply what's said in the statement. +
    + +
    +Hint 2 +Notice that you can't apply it on the same array directly since some elements will change after application +
    diff --git a/problems/build-binary-expression-tree-from-infix-expression/README.md b/problems/build-binary-expression-tree-from-infix-expression/README.md index e848a4bbd..7a5f902f0 100644 --- a/problems/build-binary-expression-tree-from-infix-expression/README.md +++ b/problems/build-binary-expression-tree-from-infix-expression/README.md @@ -14,8 +14,10 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] [[String](../../tag/string/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/building-boxes/README.md b/problems/building-boxes/README.md index f9ca91771..dfbb7aae7 100644 --- a/problems/building-boxes/README.md +++ b/problems/building-boxes/README.md @@ -61,6 +61,7 @@ These boxes are placed in the corner of the room, where the corner is on the bac ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/building-h2o/README.md b/problems/building-h2o/README.md index 969d84da0..4d1c74db5 100644 --- a/problems/building-h2o/README.md +++ b/problems/building-h2o/README.md @@ -56,3 +56,6 @@
  • Total number of H will be 2n in the input string.
  • Total number of O will be n in the input string.
  • + +### Related Topics + [[Concurrency](../../tag/concurrency/README.md)] diff --git a/problems/buildings-with-an-ocean-view/README.md b/problems/buildings-with-an-ocean-view/README.md index 694bb1f42..1f3707e3f 100644 --- a/problems/buildings-with-an-ocean-view/README.md +++ b/problems/buildings-with-an-ocean-view/README.md @@ -14,7 +14,9 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints
    diff --git a/problems/bulb-switcher-ii/README.md b/problems/bulb-switcher-ii/README.md index 04192eb83..48862a5f5 100644 --- a/problems/bulb-switcher-ii/README.md +++ b/problems/bulb-switcher-ii/README.md @@ -58,6 +58,9 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Math](../../tag/math/README.md)] ### Similar Questions diff --git a/problems/bulb-switcher-iv/README.md b/problems/bulb-switcher-iv/README.md index bd64bc80e..61722d446 100644 --- a/problems/bulb-switcher-iv/README.md +++ b/problems/bulb-switcher-iv/README.md @@ -69,6 +69,7 @@ We need at least 3 flip operations to form target.
    ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/bulls-and-cows/README.md b/problems/bulls-and-cows/README.md index a5343cd48..5705946a0 100644 --- a/problems/bulls-and-cows/README.md +++ b/problems/bulls-and-cows/README.md @@ -72,3 +72,5 @@ Note that only one of the two unmatched 1s is counted as a cow since the non-bul ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] diff --git a/problems/bus-routes/README.md b/problems/bus-routes/README.md index 467f27925..547aa9852 100644 --- a/problems/bus-routes/README.md +++ b/problems/bus-routes/README.md @@ -50,4 +50,6 @@ ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/calculate-money-in-leetcode-bank/README.md b/problems/calculate-money-in-leetcode-bank/README.md index 4232e2cdc..625ae8730 100644 --- a/problems/calculate-money-in-leetcode-bank/README.md +++ b/problems/calculate-money-in-leetcode-bank/README.md @@ -50,7 +50,6 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] ### Hints diff --git a/problems/calculate-salaries/README.md b/problems/calculate-salaries/README.md index 23877d36e..23f8246eb 100644 --- a/problems/calculate-salaries/README.md +++ b/problems/calculate-salaries/README.md @@ -12,3 +12,6 @@ ## [1468. Calculate Salaries (Medium)](https://leetcode.com/problems/calculate-salaries "计算税后工资") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/calculate-special-bonus/README.md b/problems/calculate-special-bonus/README.md index 6c2b05712..40fc4b72f 100644 --- a/problems/calculate-special-bonus/README.md +++ b/problems/calculate-special-bonus/README.md @@ -9,6 +9,9 @@                  [Next >](../minimize-product-sum-of-two-arrays "Minimize Product Sum of Two Arrays") -## [1873. Calculate Special Bonus (Easy)](https://leetcode.com/problems/calculate-special-bonus "") +## [1873. Calculate Special Bonus (Easy)](https://leetcode.com/problems/calculate-special-bonus "计算特殊奖金") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/camelcase-matching/README.md b/problems/camelcase-matching/README.md index 6144214e6..b28104baf 100644 --- a/problems/camelcase-matching/README.md +++ b/problems/camelcase-matching/README.md @@ -59,7 +59,9 @@ ### Related Topics [[Trie](../../tag/trie/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] + [[String Matching](../../tag/string-matching/README.md)] ### Hints
    diff --git a/problems/campus-bikes-ii/README.md b/problems/campus-bikes-ii/README.md index 644d66f84..a46ba70f2 100644 --- a/problems/campus-bikes-ii/README.md +++ b/problems/campus-bikes-ii/README.md @@ -11,51 +11,14 @@ ## [1066. Campus Bikes II (Medium)](https://leetcode.com/problems/campus-bikes-ii "校园自行车分配 II") -

    On a campus represented as a 2D grid, there are N workers and M bikes, with N <= M. Each worker and bike is a 2D coordinate on this grid.

    -

    We assign one unique bike to each worker so that the sum of the Manhattan distances between each worker and their assigned bike is minimized.

    - -

    The Manhattan distance between two points p1 and p2 is Manhattan(p1, p2) = |p1.x - p2.x| + |p1.y - p2.y|.

    - -

    Return the minimum possible sum of Manhattan distances between each worker and their assigned bike.

    - -

     

    - -

    Example 1:

    - -

    - -
    -Input: workers = [[0,0],[2,1]], bikes = [[1,2],[3,3]]
    -Output: 6
    -Explanation: 
    -We assign bike 0 to worker 0, bike 1 to worker 1. The Manhattan distance of both assignments is 3, so the output is 6.
    -
    - -

    Example 2:

    - -

    - -
    -Input: workers = [[0,0],[1,1],[2,0]], bikes = [[1,0],[2,2],[2,1]]
    -Output: 4
    -Explanation: 
    -We first assign bike 0 to worker 0, then assign bike 1 to worker 1 or worker 2, bike 2 to worker 2 or worker 1. Both assignments lead to sum of the Manhattan distances as 4.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 0 <= workers[i][0], workers[i][1], bikes[i][0], bikes[i][1] < 1000
    2. -
    3. All worker and bike locations are distinct.
    4. -
    5. 1 <= workers.length <= bikes.length <= 10
    6. -
    ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Similar Questions 1. [Campus Bikes](../campus-bikes) (Medium) diff --git a/problems/campus-bikes/README.md b/problems/campus-bikes/README.md index 04a8de88c..3badcb77d 100644 --- a/problems/campus-bikes/README.md +++ b/problems/campus-bikes/README.md @@ -11,51 +11,12 @@ ## [1057. Campus Bikes (Medium)](https://leetcode.com/problems/campus-bikes "校园自行车分配") -

    On a campus represented as a 2D grid, there are N workers and M bikes, with N <= M. Each worker and bike is a 2D coordinate on this grid.

    -

    Our goal is to assign a bike to each worker. Among the available bikes and workers, we choose the (worker, bike) pair with the shortest Manhattan distance between each other, and assign the bike to that worker. (If there are multiple (worker, bike) pairs with the same shortest Manhattan distance, we choose the pair with the smallest worker index; if there are multiple ways to do that, we choose the pair with the smallest bike index). We repeat this process until there are no available workers.

    - -

    The Manhattan distance between two points p1 and p2 is Manhattan(p1, p2) = |p1.x - p2.x| + |p1.y - p2.y|.

    - -

    Return a vector ans of length N, where ans[i] is the index (0-indexed) of the bike that the i-th worker is assigned to.

    - -

     

    - -

    Example 1:

    - -

    - -
    -Input: workers = [[0,0],[2,1]], bikes = [[1,2],[3,3]]
    -Output: [1,0]
    -Explanation: 
    -Worker 1 grabs Bike 0 as they are closest (without ties), and Worker 0 is assigned Bike 1. So the output is [1, 0].
    -
    - -

    Example 2:

    - -

    - -
    -Input: workers = [[0,0],[1,1],[2,0]], bikes = [[1,0],[2,2],[2,1]]
    -Output: [0,2,1]
    -Explanation: 
    -Worker 0 grabs Bike 0 at first. Worker 1 and Worker 2 share the same distance to Bike 2, thus Worker 1 is assigned to Bike 2, and Worker 2 will take Bike 1. So the output is [0,2,1].
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 0 <= workers[i][j], bikes[i][j] < 1000
    2. -
    3. All worker and bike locations are distinct.
    4. -
    5. 1 <= workers.length <= bikes.length <= 1000
    6. -
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Campus Bikes II](../campus-bikes-ii) (Medium) diff --git a/problems/can-convert-string-in-k-moves/README.md b/problems/can-convert-string-in-k-moves/README.md index 90b7b02e6..a30659677 100644 --- a/problems/can-convert-string-in-k-moves/README.md +++ b/problems/can-convert-string-in-k-moves/README.md @@ -61,7 +61,7 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/can-i-win/README.md b/problems/can-i-win/README.md index 8f6092574..dd4163c8a 100644 --- a/problems/can-i-win/README.md +++ b/problems/can-i-win/README.md @@ -56,8 +56,12 @@ Same with other integers chosen by the first player, the second player will alwa ### Related Topics - [[Minimax](../../tag/minimax/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] ### Similar Questions 1. [Flip Game II](../flip-game-ii) (Medium) diff --git a/problems/can-make-arithmetic-progression-from-sequence/README.md b/problems/can-make-arithmetic-progression-from-sequence/README.md index 2bab2cf72..3a893b278 100644 --- a/problems/can-make-arithmetic-progression-from-sequence/README.md +++ b/problems/can-make-arithmetic-progression-from-sequence/README.md @@ -41,8 +41,8 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/can-make-palindrome-from-substring/README.md b/problems/can-make-palindrome-from-substring/README.md index d3949c81a..765d4dd92 100644 --- a/problems/can-make-palindrome-from-substring/README.md +++ b/problems/can-make-palindrome-from-substring/README.md @@ -46,8 +46,10 @@ queries[4] : substring = "abcda", could be changed to " ### Related Topics - [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/README.md b/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/README.md index d2bdf53a8..8aeb288b6 100644 --- a/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/README.md +++ b/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/README.md @@ -60,7 +60,8 @@ ### Related Topics - [[Math](../../tag/math/README.md)] + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/candy-crush/README.md b/problems/candy-crush/README.md index c5f04453d..f3326e416 100644 --- a/problems/candy-crush/README.md +++ b/problems/candy-crush/README.md @@ -11,48 +11,13 @@ ## [723. Candy Crush (Medium)](https://leetcode.com/problems/candy-crush "粉碎糖果") -

    This question is about implementing a basic elimination algorithm for Candy Crush.

    -

    Given a 2D integer array board representing the grid of candy, different positive integers board[i][j] represent different types of candies. A value of board[i][j] = 0 represents that the cell at position (i, j) is empty. The given board represents the state of the game following the player's move. Now, you need to restore the board to a stable state by crushing candies according to the following rules:

    - -
      -
    1. If three or more candies of the same type are adjacent vertically or horizontally, "crush" them all at the same time - these positions become empty.
    2. -
    3. After crushing all candies simultaneously, if an empty space on the board has candies on top of itself, then these candies will drop until they hit a candy or bottom at the same time. (No new candies will drop outside the top boundary.)
    4. -
    5. After the above steps, there may exist more candies that can be crushed. If so, you need to repeat the above steps.
    6. -
    7. If there does not exist more candies that can be crushed (ie. the board is stable), then return the current board.
    8. -
    - -

    You need to perform the above rules until the board becomes stable, then return the current board.

    - -

     

    - -

    Example:

    - -
    -Input:
    -board = 
    -[[110,5,112,113,114],[210,211,5,213,214],[310,311,3,313,314],[410,411,412,5,414],[5,1,512,3,3],[610,4,1,613,614],[710,1,2,713,714],[810,1,2,1,1],[1,1,2,2,2],[4,1,4,4,1014]]
    -
    -Output:
    -[[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[110,0,0,0,114],[210,0,0,0,214],[310,0,0,113,314],[410,0,0,213,414],[610,211,112,313,614],[710,311,412,613,714],[810,411,512,713,1014]]
    -
    -Explanation: 
    -
    -
    - -

     

    - -

    Note:

    - -
      -
    1. The length of board will be in the range [3, 50].
    2. -
    3. The length of board[i] will be in the range [3, 50].
    4. -
    5. Each board[i][j] will initially start as an integer in the range [1, 2000].
    6. -
    ### Related Topics [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/candy/README.md b/problems/candy/README.md index 7096ef687..870b0d873 100644 --- a/problems/candy/README.md +++ b/problems/candy/README.md @@ -51,3 +51,4 @@ The third child gets 1 candy because it satisfies the above two conditions. ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/capacity-to-ship-packages-within-d-days/README.md b/problems/capacity-to-ship-packages-within-d-days/README.md index 6927e812e..68f6563bb 100644 --- a/problems/capacity-to-ship-packages-within-d-days/README.md +++ b/problems/capacity-to-ship-packages-within-d-days/README.md @@ -65,6 +65,7 @@ Note that the cargo must be shipped in the order given, so using a ship of capac ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/capital-gainloss/README.md b/problems/capital-gainloss/README.md index 990cd2437..2dd75d662 100644 --- a/problems/capital-gainloss/README.md +++ b/problems/capital-gainloss/README.md @@ -11,56 +11,7 @@ ## [1393. Capital Gain/Loss (Medium)](https://leetcode.com/problems/capital-gainloss "股票的资本损益") -

    Table: Stocks

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| stock_name    | varchar |
    -| operation     | enum    |
    -| operation_day | int     |
    -| price         | int     |
    -+---------------+---------+
    -(stock_name, day) is the primary key for this table.
    -The operation column is an ENUM of type ('Sell', 'Buy')
    -Each row of this table indicates that the stock which has stock_name had an operation on the day operation_day with the price.
    -It is guaranteed that each 'Sell' operation for a stock has a corresponding 'Buy' operation in a previous day.
    -
    - -Write an SQL query to report the Capital gain/loss for each stock. -The capital gain/loss of a stock is total gain or loss after buying and selling the stock one or many times. -Return the result table in any order. - -The query result format is in the following example: - -
    -Stocks table:
    -+---------------+-----------+---------------+--------+
    -| stock_name    | operation | operation_day | price  |
    -+---------------+-----------+---------------+--------+
    -| Leetcode      | Buy       | 1             | 1000   |
    -| Corona Masks  | Buy       | 2             | 10     |
    -| Leetcode      | Sell      | 5             | 9000   |
    -| Handbags      | Buy       | 17            | 30000  |
    -| Corona Masks  | Sell      | 3             | 1010   |
    -| Corona Masks  | Buy       | 4             | 1000   |
    -| Corona Masks  | Sell      | 5             | 500    |
    -| Corona Masks  | Buy       | 6             | 1000   |
    -| Handbags      | Sell      | 29            | 7000   |
    -| Corona Masks  | Sell      | 10            | 10000  |
    -+---------------+-----------+---------------+--------+
    -
    -Result table:
    -+---------------+-------------------+
    -| stock_name    | capital_gain_loss |
    -+---------------+-------------------+
    -| Corona Masks  | 9500              |
    -| Leetcode      | 8000              |
    -| Handbags      | -23000            |
    -+---------------+-------------------+
    -Leetcode stock was bought at day 1 for 1000$ and was sold at day 5 for 9000$. Capital gain = 9000 - 1000 = 8000$.
    -Handbags stock was bought at day 17 for 30000$ and was sold at day 29 for 7000$. Capital loss = 7000 - 30000 = -23000$.
    -Corona Masks stock was bought at day 1 for 10$ and was sold at day 3 for 1010$. It was bought again at day 4 for 1000$ and was sold at day 5 for 500$. At last, it was bought at day 6 for 1000$ and was sold at day 10 for 10000$. Capital gain/loss is the sum of capital gains/losses for each ('Buy' --> 'Sell') operation = (1010 - 10) + (500 - 1000) + (10000 - 1000) = 1000 - 500 + 9000 = 9500$.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/car-fleet-ii/README.md b/problems/car-fleet-ii/README.md index 3ea5843a2..e1c563772 100644 --- a/problems/car-fleet-ii/README.md +++ b/problems/car-fleet-ii/README.md @@ -48,7 +48,11 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/car-fleet/README.md b/problems/car-fleet/README.md index e507d9452..5045fa2d5 100644 --- a/problems/car-fleet/README.md +++ b/problems/car-fleet/README.md @@ -52,4 +52,5 @@ Note that no other cars meet these fleets before the destination, so the answer ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/car-pooling/README.md b/problems/car-pooling/README.md index c7788244d..ddf9275d2 100644 --- a/problems/car-pooling/README.md +++ b/problems/car-pooling/README.md @@ -73,7 +73,11 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Simulation](../../tag/simulation/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Meeting Rooms II](../meeting-rooms-ii) (Medium) diff --git a/problems/card-flipping-game/README.md b/problems/card-flipping-game/README.md index ab4b3a66b..13ff1163c 100644 --- a/problems/card-flipping-game/README.md +++ b/problems/card-flipping-game/README.md @@ -40,3 +40,7 @@ We choose the second card, which has number 2 on the back, and it isn't on t
  • 1 <= fronts[i] <= 2000.
  • 1 <= backs[i] <= 2000.
  • + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/cat-and-mouse-ii/README.md b/problems/cat-and-mouse-ii/README.md index 711a42f2b..7935c07ae 100644 --- a/problems/cat-and-mouse-ii/README.md +++ b/problems/cat-and-mouse-ii/README.md @@ -98,7 +98,12 @@ ### Related Topics + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] ### Hints
    diff --git a/problems/cat-and-mouse/README.md b/problems/cat-and-mouse/README.md index 2654f1174..20304f04b 100644 --- a/problems/cat-and-mouse/README.md +++ b/problems/cat-and-mouse/README.md @@ -65,5 +65,9 @@ ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] - [[Minimax](../../tag/minimax/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] diff --git a/problems/cells-with-odd-values-in-a-matrix/README.md b/problems/cells-with-odd-values-in-a-matrix/README.md index fa60d5807..3b170b034 100644 --- a/problems/cells-with-odd-values-in-a-matrix/README.md +++ b/problems/cells-with-odd-values-in-a-matrix/README.md @@ -56,6 +56,8 @@ The final matrix is [[1,3,1],[1,3,1]], which contains 6 odd numbers. ### Related Topics [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/chalkboard-xor-game/README.md b/problems/chalkboard-xor-game/README.md index 26d614dcb..893554c2e 100644 --- a/problems/chalkboard-xor-game/README.md +++ b/problems/chalkboard-xor-game/README.md @@ -38,4 +38,8 @@ If Alice erases 2 first, now nums becomes [1, 1]. The bitwise XOR of all the ele

     

    ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Brainteaser](../../tag/brainteaser/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] diff --git a/problems/change-minimum-characters-to-satisfy-one-of-three-conditions/README.md b/problems/change-minimum-characters-to-satisfy-one-of-three-conditions/README.md index 0c02683b5..1782e05bd 100644 --- a/problems/change-minimum-characters-to-satisfy-one-of-three-conditions/README.md +++ b/problems/change-minimum-characters-to-satisfy-one-of-three-conditions/README.md @@ -53,8 +53,10 @@ The best way was done in 2 operations (either condition 1 or condition 3). ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/change-the-root-of-a-binary-tree/README.md b/problems/change-the-root-of-a-binary-tree/README.md index 647535119..abde09cc9 100644 --- a/problems/change-the-root-of-a-binary-tree/README.md +++ b/problems/change-the-root-of-a-binary-tree/README.md @@ -15,7 +15,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/cheapest-flights-within-k-stops/README.md b/problems/cheapest-flights-within-k-stops/README.md index a67f28bb4..b2cd7e7b3 100644 --- a/problems/cheapest-flights-within-k-stops/README.md +++ b/problems/cheapest-flights-within-k-stops/README.md @@ -50,9 +50,12 @@ The cheapest price from city 0 to city 2 with at most ### Related Topics - [[Heap](../../tag/heap/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Maximum Vacation Days](../maximum-vacation-days) (Hard) diff --git a/problems/check-array-formation-through-concatenation/README.md b/problems/check-array-formation-through-concatenation/README.md index c6b5bb6b5..26c5480c2 100644 --- a/problems/check-array-formation-through-concatenation/README.md +++ b/problems/check-array-formation-through-concatenation/README.md @@ -66,7 +66,6 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/check-completeness-of-a-binary-tree/README.md b/problems/check-completeness-of-a-binary-tree/README.md index 2ca969e95..d4f4f8b39 100644 --- a/problems/check-completeness-of-a-binary-tree/README.md +++ b/problems/check-completeness-of-a-binary-tree/README.md @@ -42,3 +42,5 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/check-if-a-number-is-majority-element-in-a-sorted-array/README.md b/problems/check-if-a-number-is-majority-element-in-a-sorted-array/README.md index ca9cb277e..51c072b64 100644 --- a/problems/check-if-a-number-is-majority-element-in-a-sorted-array/README.md +++ b/problems/check-if-a-number-is-majority-element-in-a-sorted-array/README.md @@ -11,41 +11,7 @@ ## [1150. Check If a Number Is Majority Element in a Sorted Array (Easy)](https://leetcode.com/problems/check-if-a-number-is-majority-element-in-a-sorted-array "检查一个数是否在数组中占绝大多数") -

    Given an array nums sorted in non-decreasing order, and a number target, return True if and only if target is a majority element.

    -

    A majority element is an element that appears more than N/2 times in an array of length N.

    - -

     

    - -

    Example 1:

    - -
    -Input: nums = [2,4,5,5,5,5,5,6,6], target = 5
    -Output: true
    -Explanation: 
    -The value 5 appears 5 times and the length of the array is 9.
    -Thus, 5 is a majority element because 5 > 9/2 is true.
    -
    - -

    Example 2:

    - -
    -Input: nums = [10,100,101,101], target = 101
    -Output: false
    -Explanation: 
    -The value 101 appears 2 times and the length of the array is 4.
    -Thus, 101 is not a majority element because 2 > 4/2 is false.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= nums.length <= 1000
    2. -
    3. 1 <= nums[i] <= 10^9
    4. -
    5. 1 <= target <= 10^9
    6. -
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/check-if-a-string-can-break-another-string/README.md b/problems/check-if-a-string-can-break-another-string/README.md index d6b4e8723..47a04fa96 100644 --- a/problems/check-if-a-string-can-break-another-string/README.md +++ b/problems/check-if-a-string-can-break-another-string/README.md @@ -52,6 +52,7 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md b/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md index 243ca260e..9a2188d97 100644 --- a/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md +++ b/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md @@ -65,7 +65,10 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/README.md b/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/README.md index 68a6243c9..82be2ec2f 100644 --- a/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/README.md +++ b/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/README.md @@ -15,6 +15,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md b/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md index 9d216a1e5..c7ec6341b 100644 --- a/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md +++ b/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md @@ -72,6 +72,7 @@ ### Related Topics [[String](../../tag/string/README.md)] + [[String Matching](../../tag/string-matching/README.md)] ### Hints
    diff --git a/problems/check-if-all-the-integers-in-a-range-are-covered/README.md b/problems/check-if-all-the-integers-in-a-range-are-covered/README.md new file mode 100644 index 000000000..b8d20d0f6 --- /dev/null +++ b/problems/check-if-all-the-integers-in-a-range-are-covered/README.md @@ -0,0 +1,63 @@ + + + + + + + +[< Previous](../page-recommendations-ii "Page Recommendations II") +                 +[Next >](../find-the-student-that-will-replace-the-chalk "Find the Student that Will Replace the Chalk") + +## [1893. Check if All the Integers in a Range Are Covered (Easy)](https://leetcode.com/problems/check-if-all-the-integers-in-a-range-are-covered "检查是否区域内所有整数都被覆盖") + +

    You are given a 2D integer array ranges and two integers left and right. Each ranges[i] = [starti, endi] represents an inclusive interval between starti and endi.

    + +

    Return true if each integer in the inclusive range [left, right] is covered by at least one interval in ranges. Return false otherwise.

    + +

    An integer x is covered by an interval ranges[i] = [starti, endi] if starti <= x <= endi.

    + +

     

    +

    Example 1:

    + +
    +Input: ranges = [[1,2],[3,4],[5,6]], left = 2, right = 5
    +Output: true
    +Explanation: Every integer between 2 and 5 is covered:
    +- 2 is covered by the first range.
    +- 3 and 4 are covered by the second range.
    +- 5 is covered by the third range.
    +
    + +

    Example 2:

    + +
    +Input: ranges = [[1,10],[10,20]], left = 21, right = 21
    +Output: false
    +Explanation: 21 is not covered by any range.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= ranges.length <= 50
    • +
    • 1 <= starti <= endi <= 50
    • +
    • 1 <= left <= right <= 50
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +Iterate over every integer point in the range [left, right]. +
    + +
    +Hint 2 +For each of these points check if it is included in one of the ranges. +
    diff --git a/problems/check-if-array-pairs-are-divisible-by-k/README.md b/problems/check-if-array-pairs-are-divisible-by-k/README.md index 273b50fc4..a904e7a19 100644 --- a/problems/check-if-array-pairs-are-divisible-by-k/README.md +++ b/problems/check-if-array-pairs-are-divisible-by-k/README.md @@ -68,9 +68,9 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] - [[Math](../../tag/math/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md b/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md index 315722b60..d2e2de0b9 100644 --- a/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md +++ b/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md @@ -38,7 +38,7 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/check-if-it-is-a-good-array/README.md b/problems/check-if-it-is-a-good-array/README.md index 862b5b1c0..c25acbf33 100644 --- a/problems/check-if-it-is-a-good-array/README.md +++ b/problems/check-if-it-is-a-good-array/README.md @@ -50,7 +50,9 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Number Theory](../../tag/number-theory/README.md)] ### Hints
    diff --git a/problems/check-if-n-and-its-double-exist/README.md b/problems/check-if-n-and-its-double-exist/README.md index f0125d228..5eead7909 100644 --- a/problems/check-if-n-and-its-double-exist/README.md +++ b/problems/check-if-n-and-its-double-exist/README.md @@ -56,6 +56,10 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/check-if-number-is-a-sum-of-powers-of-three/README.md b/problems/check-if-number-is-a-sum-of-powers-of-three/README.md index 3ae982ed7..49f9a0f36 100644 --- a/problems/check-if-number-is-a-sum-of-powers-of-three/README.md +++ b/problems/check-if-number-is-a-sum-of-powers-of-three/README.md @@ -47,9 +47,7 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Math](../../tag/math/README.md)] - [[Backtracking](../../tag/backtracking/README.md)] ### Hints
    diff --git a/problems/check-if-one-string-swap-can-make-strings-equal/README.md b/problems/check-if-one-string-swap-can-make-strings-equal/README.md index 128fee8f7..ec504c532 100644 --- a/problems/check-if-one-string-swap-can-make-strings-equal/README.md +++ b/problems/check-if-one-string-swap-can-make-strings-equal/README.md @@ -57,7 +57,9 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md b/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md index eff4fd096..1b332b52c 100644 --- a/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md +++ b/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md @@ -70,6 +70,7 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/check-if-the-sentence-is-pangram/README.md b/problems/check-if-the-sentence-is-pangram/README.md index 230c34058..21b9fe963 100644 --- a/problems/check-if-the-sentence-is-pangram/README.md +++ b/problems/check-if-the-sentence-is-pangram/README.md @@ -40,6 +40,7 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/check-if-there-is-a-valid-path-in-a-grid/README.md b/problems/check-if-there-is-a-valid-path-in-a-grid/README.md index a6ccd766b..1efa3602a 100644 --- a/problems/check-if-there-is-a-valid-path-in-a-grid/README.md +++ b/problems/check-if-there-is-a-valid-path-in-a-grid/README.md @@ -79,8 +79,11 @@ Given a m x n grid. Each cell of the grid ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/check-if-two-expression-trees-are-equivalent/README.md b/problems/check-if-two-expression-trees-are-equivalent/README.md index 6733f508c..7b0b251b7 100644 --- a/problems/check-if-two-expression-trees-are-equivalent/README.md +++ b/problems/check-if-two-expression-trees-are-equivalent/README.md @@ -15,7 +15,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/check-if-two-string-arrays-are-equivalent/README.md b/problems/check-if-two-string-arrays-are-equivalent/README.md index 77589443f..55153a000 100644 --- a/problems/check-if-two-string-arrays-are-equivalent/README.md +++ b/problems/check-if-two-string-arrays-are-equivalent/README.md @@ -51,6 +51,7 @@ The strings are the same, so return true.
    ### Related Topics + [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/checking-existence-of-edge-length-limited-paths-ii/README.md b/problems/checking-existence-of-edge-length-limited-paths-ii/README.md index af6e21d25..b97a129ae 100644 --- a/problems/checking-existence-of-edge-length-limited-paths-ii/README.md +++ b/problems/checking-existence-of-edge-length-limited-paths-ii/README.md @@ -16,7 +16,7 @@ ### Related Topics [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] ### Hints
    diff --git a/problems/checking-existence-of-edge-length-limited-paths/README.md b/problems/checking-existence-of-edge-length-limited-paths/README.md index 1365ed803..a7972ea78 100644 --- a/problems/checking-existence-of-edge-length-limited-paths/README.md +++ b/problems/checking-existence-of-edge-length-limited-paths/README.md @@ -52,8 +52,10 @@ For the second query, there is a path (0 -> 1 -> 2) of two edges with dist ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/cherry-pickup-ii/README.md b/problems/cherry-pickup-ii/README.md index d3eb098d8..647727cdc 100644 --- a/problems/cherry-pickup-ii/README.md +++ b/problems/cherry-pickup-ii/README.md @@ -77,7 +77,9 @@ Total of cherries: 17 + 11 = 28. ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/cherry-pickup/README.md b/problems/cherry-pickup/README.md index bda881439..25337a3d5 100644 --- a/problems/cherry-pickup/README.md +++ b/problems/cherry-pickup/README.md @@ -60,7 +60,9 @@ The total number of cherries picked up is 5, and this is the maximum possible. ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Minimum Path Sum](../minimum-path-sum) (Medium) diff --git a/problems/cinema-seat-allocation/README.md b/problems/cinema-seat-allocation/README.md index b3cfc5d7a..39d2387c6 100644 --- a/problems/cinema-seat-allocation/README.md +++ b/problems/cinema-seat-allocation/README.md @@ -58,7 +58,9 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/circle-and-rectangle-overlapping/README.md b/problems/circle-and-rectangle-overlapping/README.md index 405cf2a7e..13ebd99f8 100644 --- a/problems/circle-and-rectangle-overlapping/README.md +++ b/problems/circle-and-rectangle-overlapping/README.md @@ -65,6 +65,7 @@ ### Related Topics [[Geometry](../../tag/geometry/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/circular-array-loop/README.md b/problems/circular-array-loop/README.md index ae64092e9..3d67613c6 100644 --- a/problems/circular-array-loop/README.md +++ b/problems/circular-array-loop/README.md @@ -75,4 +75,5 @@ Every nums[seq[j]] must be either all positive or all negative. ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/circular-permutation-in-binary-representation/README.md b/problems/circular-permutation-in-binary-representation/README.md index db853bdb9..d3daea1bf 100644 --- a/problems/circular-permutation-in-binary-representation/README.md +++ b/problems/circular-permutation-in-binary-representation/README.md @@ -46,7 +46,9 @@ All the adjacent element differ by one bit. Another valid permutation is [3,1,0, ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Hints
    diff --git a/problems/classes-more-than-5-students/README.md b/problems/classes-more-than-5-students/README.md index caf9e3dd3..f2c545b0c 100644 --- a/problems/classes-more-than-5-students/README.md +++ b/problems/classes-more-than-5-students/README.md @@ -47,3 +47,6 @@

    Note:
    The students should not be counted duplicate in each course.

    + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/climbing-stairs/README.md b/problems/climbing-stairs/README.md index 28cbb8904..09fbeff5f 100644 --- a/problems/climbing-stairs/README.md +++ b/problems/climbing-stairs/README.md @@ -45,6 +45,8 @@ ### Related Topics + [[Memoization](../../tag/memoization/README.md)] + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/clone-binary-tree-with-random-pointer/README.md b/problems/clone-binary-tree-with-random-pointer/README.md index 13690a8cd..3d1ee0e30 100644 --- a/problems/clone-binary-tree-with-random-pointer/README.md +++ b/problems/clone-binary-tree-with-random-pointer/README.md @@ -15,7 +15,10 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/clone-graph/README.md b/problems/clone-graph/README.md index 7a7b6a3f6..39acebb91 100644 --- a/problems/clone-graph/README.md +++ b/problems/clone-graph/README.md @@ -82,9 +82,10 @@ class Node { ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions 1. [Copy List with Random Pointer](../copy-list-with-random-pointer) (Medium) diff --git a/problems/clone-n-ary-tree/README.md b/problems/clone-n-ary-tree/README.md index 35df14008..1416e47f6 100644 --- a/problems/clone-n-ary-tree/README.md +++ b/problems/clone-n-ary-tree/README.md @@ -15,8 +15,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Hash Table](../../tag/hash-table/README.md)] ### Hints diff --git a/problems/closest-binary-search-tree-value-ii/README.md b/problems/closest-binary-search-tree-value-ii/README.md index a25f2f48c..ab9b44389 100644 --- a/problems/closest-binary-search-tree-value-ii/README.md +++ b/problems/closest-binary-search-tree-value-ii/README.md @@ -11,35 +11,16 @@ ## [272. Closest Binary Search Tree Value II (Hard)](https://leetcode.com/problems/closest-binary-search-tree-value-ii "最接近的二叉搜索树值 II") -

    Given a non-empty binary search tree and a target value, find k values in the BST that are closest to the target.

    -

    Note:

    - -
      -
    • Given target value is a floating point.
    • -
    • You may assume k is always valid, that is: k ≤ total nodes.
    • -
    • You are guaranteed to have only one unique set of k values in the BST that are closest to the target.
    • -
    - -

    Example:

    - -
    -Input: root = [4,2,5,1,3], target = 3.714286, and k = 2
    -
    -    4
    -   / \
    -  2   5
    - / \
    -1   3
    -
    -Output: [4,3]
    - -

    Follow up:
    -Assume that the BST is balanced, could you solve it in less than O(n) runtime (where n = total nodes)?

    ### Related Topics [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Easy) diff --git a/problems/closest-binary-search-tree-value/README.md b/problems/closest-binary-search-tree-value/README.md index 8351a1bbd..7bb4a4843 100644 --- a/problems/closest-binary-search-tree-value/README.md +++ b/problems/closest-binary-search-tree-value/README.md @@ -11,32 +11,14 @@ ## [270. Closest Binary Search Tree Value (Easy)](https://leetcode.com/problems/closest-binary-search-tree-value "最接近的二叉搜索树值") -

    Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target.

    -

    Note:

    - -
      -
    • Given target value is a floating point.
    • -
    • You are guaranteed to have only one unique value in the BST that is closest to the target.
    • -
    - -

    Example:

    - -
    -Input: root = [4,2,5,1,3], target = 3.714286
    -
    -    4
    -   / \
    -  2   5
    - / \
    -1   3
    -
    -Output: 4
    -
    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Count Complete Tree Nodes](../count-complete-tree-nodes) (Medium) diff --git a/problems/closest-dessert-cost/README.md b/problems/closest-dessert-cost/README.md index 89dcc5878..e3526bff9 100644 --- a/problems/closest-dessert-cost/README.md +++ b/problems/closest-dessert-cost/README.md @@ -84,7 +84,9 @@ Total: 3 + 4 + 10 + 0 = 17. You cannot make a dessert with a total cost of 18. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Hints
    diff --git a/problems/closest-leaf-in-a-binary-tree/README.md b/problems/closest-leaf-in-a-binary-tree/README.md index ae9ad07e2..df23839a3 100644 --- a/problems/closest-leaf-in-a-binary-tree/README.md +++ b/problems/closest-leaf-in-a-binary-tree/README.md @@ -11,68 +11,13 @@ ## [742. Closest Leaf in a Binary Tree (Medium)](https://leetcode.com/problems/closest-leaf-in-a-binary-tree "二叉树最近的叶节点") -

    Given a binary tree where every node has a unique value, and a target key k, find the value of the nearest leaf node to target k in the tree. -

    -Here, nearest to a leaf means the least number of edges travelled on the binary tree to reach any leaf of the tree. Also, a node is called a leaf if it has no children. -

    -In the following examples, the input tree is represented in flattened form row by row. -The actual root tree given will be a TreeNode object. -

    -Example 1: -

    -Input:
    -root = [1, 3, 2], k = 1
    -Diagram of binary tree:
    -          1
    -         / \
    -        3   2
     
    -Output: 2 (or 3)
    -
    -Explanation: Either 2 or 3 is the nearest leaf node to the target of 1.
    -
    -

    -Example 2: -

    -Input:
    -root = [1], k = 1
    -Output: 1
    -
    -Explanation: The nearest leaf node is the root node itself.
    -
    -

    - -

    -Example 3: -

    -Input:
    -root = [1,2,3,4,null,null,null,5,null,6], k = 2
    -Diagram of binary tree:
    -             1
    -            / \
    -           2   3
    -          /
    -         4
    -        /
    -       5
    -      /
    -     6
    -
    -Output: 3
    -Explanation: The leaf node with value 3 (and not the leaf node with value 6) is nearest to the node with value 2.
    -
    -

    - -

    Note:
    -

      -
    1. root represents a binary tree with at least 1 node and at most 1000 nodes.
    2. -
    3. Every node has a unique node.val in range [1, 1000].
    4. -
    5. There exists some node in the given binary tree for which node.val == k.
    6. -
    -

    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/closest-room/README.md b/problems/closest-room/README.md index bf337fc72..41f31a572 100644 --- a/problems/closest-room/README.md +++ b/problems/closest-room/README.md @@ -59,8 +59,9 @@ Query = [2,5]: Room number 3 is the only room with a size of at least 5. The ans ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/closest-subsequence-sum/README.md b/problems/closest-subsequence-sum/README.md index 5ba810908..a0bb7ed0a 100644 --- a/problems/closest-subsequence-sum/README.md +++ b/problems/closest-subsequence-sum/README.md @@ -55,7 +55,11 @@ The absolute difference is abs(-4 - (-5)) = abs(1) = 1, which is the minimum. ### Related Topics - [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/clumsy-factorial/README.md b/problems/clumsy-factorial/README.md index 08c1965fd..e946867c2 100644 --- a/problems/clumsy-factorial/README.md +++ b/problems/clumsy-factorial/README.md @@ -49,4 +49,6 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Math](../../tag/math/README.md)] + [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/coin-change-2/README.md b/problems/coin-change-2/README.md index 399f02f46..3a3054672 100644 --- a/problems/coin-change-2/README.md +++ b/problems/coin-change-2/README.md @@ -56,3 +56,7 @@
  • All the values of coins are unique.
  • 0 <= amount <= 5000
  • + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/coin-change/README.md b/problems/coin-change/README.md index fe8fceb16..f04cc4b62 100644 --- a/problems/coin-change/README.md +++ b/problems/coin-change/README.md @@ -64,6 +64,8 @@ ### Related Topics + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/coin-path/README.md b/problems/coin-path/README.md index 4bc08d280..911c1b488 100644 --- a/problems/coin-path/README.md +++ b/problems/coin-path/README.md @@ -11,44 +11,10 @@ ## [656. Coin Path (Hard)](https://leetcode.com/problems/coin-path "金币路径") -

    Given an array A (index starts at 1) consisting of N integers: A1, A2, ..., AN and an integer B. The integer B denotes that from any place (suppose the index is i) in the array A, you can jump to any one of the place in the array A indexed i+1, i+2, …, i+B if this place can be jumped to. Also, if you step on the index i, you have to pay Ai coins. If Ai is -1, it means you can’t jump to the place indexed i in the array.

    -

    Now, you start from the place indexed 1 in the array A, and your aim is to reach the place indexed N using the minimum coins. You need to return the path of indexes (starting from 1 to N) in the array you should take to get to the place indexed N using minimum coins.

    - -

    If there are multiple paths with the same cost, return the lexicographically smallest such path.

    - -

    If it's not possible to reach the place indexed N then you need to return an empty array.

    - -

    Example 1:

    - -
    -Input: [1,2,4,-1,2], 2
    -Output: [1,3,5]
    -
    - -

     

    - -

    Example 2:

    - -
    -Input: [1,2,4,-1,2], 1
    -Output: []
    -
    - -

     

    - -

    Note:

    - -
      -
    1. Path Pa1, Pa2, ..., Pan is lexicographically smaller than Pb1, Pb2, ..., Pbm, if and only if at the first i where Pai and Pbi differ, Pai < Pbi; when no such i exists, then n < m.
    2. -
    3. A1 >= 0. A2, ..., AN (if exist) will in the range of [-1, 100].
    4. -
    5. Length of A is in the range of [1, 1000].
    6. -
    7. B is in the range of [1, 100].
    8. -
    - -

     

    ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/coloring-a-border/README.md b/problems/coloring-a-border/README.md index 21f04e19a..159d3e8d9 100644 --- a/problems/coloring-a-border/README.md +++ b/problems/coloring-a-border/README.md @@ -59,7 +59,10 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Island Perimeter](../island-perimeter) (Easy) diff --git a/problems/combination-sum-iii/README.md b/problems/combination-sum-iii/README.md index 7a0d8c1f9..1a42716e4 100644 --- a/problems/combination-sum-iii/README.md +++ b/problems/combination-sum-iii/README.md @@ -47,7 +47,8 @@ There are no other valid combinations.
     Input: k = 4, n = 1
     Output: []
    -Explanation: There are no valid combinations. [1,2,1] is not valid because 1 is used twice.
    +Explanation: There are no valid combinations.
    +Using 4 different numbers in the range [1,9], the smallest sum we can get is 1+2+3+4 = 10 and since 10 > 1, there are no valid combination.
     

    Example 4:

    @@ -65,7 +66,7 @@ There are no other valid combinations. Output: [[1,2,3,4,5,6,7,8,9]] Explanation: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 = 45 -​​​​​​​There are no other valid combinations. +There are no other valid combinations.

     

    diff --git a/problems/combination-sum-iv/README.md b/problems/combination-sum-iv/README.md index 6931fa619..f9e3e5393 100644 --- a/problems/combination-sum-iv/README.md +++ b/problems/combination-sum-iv/README.md @@ -54,6 +54,7 @@ Note that different sequences are counted as different combinations.

    Follow up: What if negative numbers are allowed in the given array? How does it change the problem? What limitation we need to add to the question to allow negative numbers?

    ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/combinations/README.md b/problems/combinations/README.md index 66c8345e0..5fefaef75 100644 --- a/problems/combinations/README.md +++ b/problems/combinations/README.md @@ -47,6 +47,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions diff --git a/problems/combine-two-tables/README.md b/problems/combine-two-tables/README.md index c86061faa..a1e43602f 100644 --- a/problems/combine-two-tables/README.md +++ b/problems/combine-two-tables/README.md @@ -46,5 +46,8 @@ AddressId is the primary key column for this table. FirstName, LastName, City, State
    +### Related Topics + [[Database](../../tag/database/README.md)] + ### Similar Questions 1. [Employee Bonus](../employee-bonus) (Easy) diff --git a/problems/compare-strings-by-frequency-of-the-smallest-character/README.md b/problems/compare-strings-by-frequency-of-the-smallest-character/README.md index 6741914e6..2be2ea622 100644 --- a/problems/compare-strings-by-frequency-of-the-smallest-character/README.md +++ b/problems/compare-strings-by-frequency-of-the-smallest-character/README.md @@ -46,8 +46,10 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/compare-version-numbers/README.md b/problems/compare-version-numbers/README.md index 48ae604a0..3a5f430e5 100644 --- a/problems/compare-version-numbers/README.md +++ b/problems/compare-version-numbers/README.md @@ -78,4 +78,5 @@ ### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/complement-of-base-10-integer/README.md b/problems/complement-of-base-10-integer/README.md index e9dc0e2d3..57fd323be 100644 --- a/problems/complement-of-base-10-integer/README.md +++ b/problems/complement-of-base-10-integer/README.md @@ -62,7 +62,7 @@ ### Related Topics - [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/complete-binary-tree-inserter/README.md b/problems/complete-binary-tree-inserter/README.md index 3b690771a..88a69dde3 100644 --- a/problems/complete-binary-tree-inserter/README.md +++ b/problems/complete-binary-tree-inserter/README.md @@ -63,3 +63,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Design](../../tag/design/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/complex-number-multiplication/README.md b/problems/complex-number-multiplication/README.md index 900bb5f37..7c224f346 100644 --- a/problems/complex-number-multiplication/README.md +++ b/problems/complex-number-multiplication/README.md @@ -48,3 +48,4 @@ ### Related Topics [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/concatenated-words/README.md b/problems/concatenated-words/README.md index 02ac9fb56..eb3519814 100644 --- a/problems/concatenated-words/README.md +++ b/problems/concatenated-words/README.md @@ -43,8 +43,9 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Trie](../../tag/trie/README.md)] + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/concatenation-of-consecutive-binary-numbers/README.md b/problems/concatenation-of-consecutive-binary-numbers/README.md index c60ace665..abe11247d 100644 --- a/problems/concatenation-of-consecutive-binary-numbers/README.md +++ b/problems/concatenation-of-consecutive-binary-numbers/README.md @@ -49,7 +49,9 @@ After modulo 109 + 7, the result is 505379714. ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/confusing-number-ii/README.md b/problems/confusing-number-ii/README.md index 22064adde..a6cfce917 100644 --- a/problems/confusing-number-ii/README.md +++ b/problems/confusing-number-ii/README.md @@ -11,45 +11,7 @@ ## [1088. Confusing Number II (Hard)](https://leetcode.com/problems/confusing-number-ii "易混淆数 II") -

    We can rotate digits by 180 degrees to form new digits. When 0, 1, 6, 8, 9 are rotated 180 degrees, they become 0, 1, 9, 8, 6 respectively. When 2, 3, 4, 5 and 7 are rotated 180 degrees, they become invalid.

    -

    A confusing number is a number that when rotated 180 degrees becomes a different number with each digit valid.(Note that the rotated number can be greater than the original number.)

    - -

    Given a positive integer N, return the number of confusing numbers between 1 and N inclusive.

    - -

     

    - -

    Example 1:

    - -
    -Input: 20
    -Output: 6
    -Explanation: 
    -The confusing numbers are [6,9,10,16,18,19].
    -6 converts to 9.
    -9 converts to 6.
    -10 converts to 01 which is just 1.
    -16 converts to 91.
    -18 converts to 81.
    -19 converts to 61.
    -
    - -

    Example 2:

    - -
    -Input: 100
    -Output: 19
    -Explanation: 
    -The confusing numbers are [6,9,10,16,18,19,60,61,66,68,80,81,86,89,90,91,98,99,100].
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= N <= 10^9
    2. -
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/confusing-number/README.md b/problems/confusing-number/README.md index 63070cfc9..ddea65d43 100644 --- a/problems/confusing-number/README.md +++ b/problems/confusing-number/README.md @@ -11,64 +11,7 @@ ## [1056. Confusing Number (Easy)](https://leetcode.com/problems/confusing-number "易混淆数") -

    Given a number N, return true if and only if it is a confusing number, which satisfies the following condition:

    -

    We can rotate digits by 180 degrees to form new digits. When 0, 1, 6, 8, 9 are rotated 180 degrees, they become 0, 1, 9, 8, 6 respectively. When 2, 3, 4, 5 and 7 are rotated 180 degrees, they become invalid. A confusing number is a number that when rotated 180 degrees becomes a different number with each digit valid.

    - -

     

    - -

    Example 1:

    - -

    - -
    -Input: 6
    -Output: true
    -Explanation: 
    -We get 9 after rotating 6, 9 is a valid number and 9!=6.
    -
    - -

    Example 2:

    - -

    - -
    -Input: 89
    -Output: true
    -Explanation: 
    -We get 68 after rotating 89, 86 is a valid number and 86!=89.
    -
    - -

    Example 3:

    - -

    - -
    -Input: 11
    -Output: false
    -Explanation: 
    -We get 11 after rotating 11, 11 is a valid number but the value remains the same, thus 11 is not a confusing number.
    -
    - -

    Example 4:

    - -

    - -
    -Input: 25
    -Output: false
    -Explanation: 
    -We get an invalid number after rotating 25.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 0 <= N <= 10^9
    2. -
    3. After the rotation we can ignore leading zeros, for example if after rotation we have 0008 then this number is considered as just 8.
    4. -
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/connecting-cities-with-minimum-cost/README.md b/problems/connecting-cities-with-minimum-cost/README.md index 8809b7075..0b04218ee 100644 --- a/problems/connecting-cities-with-minimum-cost/README.md +++ b/problems/connecting-cities-with-minimum-cost/README.md @@ -11,51 +11,13 @@ ## [1135. Connecting Cities With Minimum Cost (Medium)](https://leetcode.com/problems/connecting-cities-with-minimum-cost "最低成本联通所有城市") -

    There are N cities numbered from 1 to N.

    -

    You are given connections, where each connections[i] = [city1, city2, cost] represents the cost to connect city1 and city2 together.  (A connection is bidirectional: connecting city1 and city2 is the same as connecting city2 and city1.)

    - -

    Return the minimum cost so that for every pair of cities, there exists a path of connections (possibly of length 1) that connects those two cities together.  The cost is the sum of the connection costs used. If the task is impossible, return -1.

    - -

     

    - -

    Example 1:

    - -

    - -
    -Input: N = 3, connections = [[1,2,5],[1,3,6],[2,3,1]]
    -Output: 6
    -Explanation: 
    -Choosing any 2 edges will connect all cities so we choose the minimum 2.
    -
    - -

    Example 2:

    - -

    - -
    -Input: N = 4, connections = [[1,2,3],[3,4,4]]
    -Output: -1
    -Explanation: 
    -There is no way to connect all cities even if all edges are used.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= N <= 10000
    2. -
    3. 1 <= connections.length <= 10000
    4. -
    5. 1 <= connections[i][0], connections[i][1] <= N
    6. -
    7. 0 <= connections[i][2] <= 10^5
    8. -
    9. connections[i][0] != connections[i][1]
    10. -
    ### Related Topics [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] + [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/consecutive-available-seats/README.md b/problems/consecutive-available-seats/README.md index 30ecfa1fb..789dcc170 100644 --- a/problems/consecutive-available-seats/README.md +++ b/problems/consecutive-available-seats/README.md @@ -11,33 +11,7 @@ ## [603. Consecutive Available Seats (Easy)](https://leetcode.com/problems/consecutive-available-seats "连续空余座位") -Several friends at a cinema ticket office would like to reserve consecutive available seats.
    -Can you help to query all the consecutive available seats order by the seat_id using the following cinema table? -
    -| seat_id | free |
    -|---------|------|
    -| 1       | 1    |
    -| 2       | 0    |
    -| 3       | 1    |
    -| 4       | 1    |
    -| 5       | 1    |
    -
    -

     

    -Your query should return the following result for the sample case above. -

     

    - -
    -| seat_id |
    -|---------|
    -| 3       |
    -| 4       |
    -| 5       |
    -
    -Note: - -
      -
    • The seat_id is an auto increment int, and free is bool ('1' means free, and '0' means occupied.).
    • -
    • Consecutive available seats are more than 2(inclusive) seats consecutively available.
    • -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/consecutive-numbers-sum/README.md b/problems/consecutive-numbers-sum/README.md index 9bf87d3f2..2ab62927b 100644 --- a/problems/consecutive-numbers-sum/README.md +++ b/problems/consecutive-numbers-sum/README.md @@ -38,3 +38,4 @@ ### Related Topics [[Math](../../tag/math/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] diff --git a/problems/consecutive-numbers/README.md b/problems/consecutive-numbers/README.md index 2944d265c..5e2dc3f26 100644 --- a/problems/consecutive-numbers/README.md +++ b/problems/consecutive-numbers/README.md @@ -55,3 +55,6 @@ Result table: +-----------------+ 1 is the only number that appears consecutively for at least three times.
    + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/constrained-subsequence-sum/README.md b/problems/constrained-subsequence-sum/README.md index 1854b10ec..d11ec6674 100644 --- a/problems/constrained-subsequence-sum/README.md +++ b/problems/constrained-subsequence-sum/README.md @@ -49,7 +49,12 @@ ### Related Topics + [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/construct-binary-search-tree-from-preorder-traversal/README.md b/problems/construct-binary-search-tree-from-preorder-traversal/README.md index 9e0f5594e..b05d0daa9 100644 --- a/problems/construct-binary-search-tree-from-preorder-traversal/README.md +++ b/problems/construct-binary-search-tree-from-preorder-traversal/README.md @@ -44,4 +44,9 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] diff --git a/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md b/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md index 79443f274..5271b0d6f 100644 --- a/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md +++ b/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md @@ -43,8 +43,10 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Construct Binary Tree from Preorder and Inorder Traversal](../construct-binary-tree-from-preorder-and-inorder-traversal) (Medium) diff --git a/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md b/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md index 8e1ffa01e..d810e669d 100644 --- a/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md +++ b/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md @@ -43,8 +43,10 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Construct Binary Tree from Inorder and Postorder Traversal](../construct-binary-tree-from-inorder-and-postorder-traversal) (Medium) diff --git a/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md b/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md index c73628d7f..f4912d732 100644 --- a/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md +++ b/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md @@ -38,3 +38,7 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/construct-binary-tree-from-string/README.md b/problems/construct-binary-tree-from-string/README.md index 36efbb74b..00e11b181 100644 --- a/problems/construct-binary-tree-from-string/README.md +++ b/problems/construct-binary-tree-from-string/README.md @@ -11,35 +11,13 @@ ## [536. Construct Binary Tree from String (Medium)](https://leetcode.com/problems/construct-binary-tree-from-string "从字符串生成二叉树") -

    You need to construct a binary tree from a string consisting of parenthesis and integers.

    -

    The whole input represents a binary tree. It contains an integer followed by zero, one or two pairs of parenthesis. The integer represents the root's value and a pair of parenthesis contains a child binary tree with the same structure.

    - -

    You always start to construct the left child node of the parent first if it exists.

    - -

    Example:
    -

    -Input: "4(2(3)(1))(6(5))"
    -Output: return the tree root node representing the following tree:
    -
    -       4
    -     /   \
    -    2     6
    -   / \   / 
    -  3   1 5   
    -
    -

    - -

    Note:
    -

      -
    1. There will only be '(', ')', '-' and '0' ~ '9' in the input string.
    2. -
    3. An empty tree is represented by "" instead of "()".
    4. -
    -

    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[String](../../tag/string/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Construct String from Binary Tree](../construct-string-from-binary-tree) (Easy) diff --git a/problems/construct-k-palindrome-strings/README.md b/problems/construct-k-palindrome-strings/README.md index da1e88f7c..b899f1598 100644 --- a/problems/construct-k-palindrome-strings/README.md +++ b/problems/construct-k-palindrome-strings/README.md @@ -68,6 +68,9 @@ Some possible constructions "anna" + "elble", "anbna&qu ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/construct-quad-tree/README.md b/problems/construct-quad-tree/README.md index 9384b2ea8..955215f0e 100644 --- a/problems/construct-quad-tree/README.md +++ b/problems/construct-quad-tree/README.md @@ -105,3 +105,9 @@ Explanation is shown in the photo below:
  • n == grid.length == grid[i].length
  • n == 2^x where 0 <= x <= 6
  • + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/construct-string-from-binary-tree/README.md b/problems/construct-string-from-binary-tree/README.md index 0151402d5..da920e8d0 100644 --- a/problems/construct-string-from-binary-tree/README.md +++ b/problems/construct-string-from-binary-tree/README.md @@ -42,7 +42,9 @@ Explanation: Almost the same as the first example, except we cannot omit the fir ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[String](../../tag/string/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Construct Binary Tree from String](../construct-binary-tree-from-string) (Medium) diff --git a/problems/construct-target-array-with-multiple-sums/README.md b/problems/construct-target-array-with-multiple-sums/README.md index 2885cfea1..3f029a70f 100644 --- a/problems/construct-target-array-with-multiple-sums/README.md +++ b/problems/construct-target-array-with-multiple-sums/README.md @@ -59,7 +59,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/construct-the-lexicographically-largest-valid-sequence/README.md b/problems/construct-the-lexicographically-largest-valid-sequence/README.md index 2efa1c694..c922c5bf7 100644 --- a/problems/construct-the-lexicographically-largest-valid-sequence/README.md +++ b/problems/construct-the-lexicographically-largest-valid-sequence/README.md @@ -49,7 +49,7 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] + [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Hints diff --git a/problems/contain-virus/README.md b/problems/contain-virus/README.md index c47c33ae2..5dfaf0c02 100644 --- a/problems/contain-virus/README.md +++ b/problems/contain-virus/README.md @@ -61,7 +61,11 @@ Notice that walls are only built on the shared boundary of two different cells. ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/container-with-most-water/README.md b/problems/container-with-most-water/README.md index dfdce6ead..783c10827 100644 --- a/problems/container-with-most-water/README.md +++ b/problems/container-with-most-water/README.md @@ -55,6 +55,7 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/contains-duplicate-ii/README.md b/problems/contains-duplicate-ii/README.md index 0ccf3af4d..540b57fcb 100644 --- a/problems/contains-duplicate-ii/README.md +++ b/problems/contains-duplicate-ii/README.md @@ -47,6 +47,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions 1. [Contains Duplicate](../contains-duplicate) (Easy) diff --git a/problems/contains-duplicate-iii/README.md b/problems/contains-duplicate-iii/README.md index 03b136785..6ce24574c 100644 --- a/problems/contains-duplicate-iii/README.md +++ b/problems/contains-duplicate-iii/README.md @@ -35,8 +35,11 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] - [[Ordered Map](../../tag/ordered-map/README.md)] + [[Array](../../tag/array/README.md)] + [[Bucket Sort](../../tag/bucket-sort/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions 1. [Contains Duplicate](../contains-duplicate) (Easy) diff --git a/problems/contains-duplicate/README.md b/problems/contains-duplicate/README.md index 423ccf0e8..82e2e2365 100644 --- a/problems/contains-duplicate/README.md +++ b/problems/contains-duplicate/README.md @@ -35,6 +35,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Contains Duplicate II](../contains-duplicate-ii) (Easy) diff --git a/problems/contiguous-array/README.md b/problems/contiguous-array/README.md index 14742523e..b0b4dbc33 100644 --- a/problems/contiguous-array/README.md +++ b/problems/contiguous-array/README.md @@ -39,7 +39,9 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Similar Questions 1. [Maximum Size Subarray Sum Equals k](../maximum-size-subarray-sum-equals-k) (Medium) diff --git a/problems/continuous-subarray-sum/README.md b/problems/continuous-subarray-sum/README.md index 891529a26..b70633b7c 100644 --- a/problems/continuous-subarray-sum/README.md +++ b/problems/continuous-subarray-sum/README.md @@ -51,8 +51,10 @@ ### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Similar Questions 1. [Subarray Sum Equals K](../subarray-sum-equals-k) (Medium) diff --git a/problems/convert-a-number-to-hexadecimal/README.md b/problems/convert-a-number-to-hexadecimal/README.md index 82e70838b..955b7b2d3 100644 --- a/problems/convert-a-number-to-hexadecimal/README.md +++ b/problems/convert-a-number-to-hexadecimal/README.md @@ -34,3 +34,4 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/convert-binary-number-in-a-linked-list-to-integer/README.md b/problems/convert-binary-number-in-a-linked-list-to-integer/README.md index 8d35ca70e..33427834a 100644 --- a/problems/convert-binary-number-in-a-linked-list-to-integer/README.md +++ b/problems/convert-binary-number-in-a-linked-list-to-integer/README.md @@ -62,8 +62,8 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md b/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md index 13fee785c..6068a9ec4 100644 --- a/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md +++ b/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md @@ -11,33 +11,16 @@ ## [426. Convert Binary Search Tree to Sorted Doubly Linked List (Medium)](https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list "将二叉搜索树转化为排序的双向链表") -

    Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right pointers as synonymous to the previous and next pointers in a doubly-linked list.

    -

    Let's take the following BST as an example, it may help you understand the problem better:

    -  - -

    -  - -

    We want to transform this BST into a circular doubly linked list. Each node in a doubly linked list has a predecessor and successor. For a circular doubly linked list, the predecessor of the first element is the last element, and the successor of the last element is the first element.

    - -

    The figure below shows the circular doubly linked list for the BST above. The "head" symbol means the node it points to is the smallest element of the linked list.

    -  - -

    -  - -

    Specifically, we want to do the transformation in place. After the transformation, the left pointer of the tree node should point to its predecessor, and the right pointer should point to its successor. We should return the pointer to the first element of the linked list.

    - -

    The figure below shows the transformed BST. The solid line indicates the successor relationship, while the dashed line means the predecessor relationship.

    -  - -

    ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Linked List](../../tag/linked-list/README.md)] - [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] + [[Doubly-Linked List](../../tag/doubly-linked-list/README.md)] ### Similar Questions 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Easy) diff --git a/problems/convert-bst-to-greater-tree/README.md b/problems/convert-bst-to-greater-tree/README.md index 0bfe66e87..65d919826 100644 --- a/problems/convert-bst-to-greater-tree/README.md +++ b/problems/convert-bst-to-greater-tree/README.md @@ -64,6 +64,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] - [[Recursion](../../tag/recursion/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/convert-date-format/README.md b/problems/convert-date-format/README.md index c68c0ea98..18ad540b6 100644 --- a/problems/convert-date-format/README.md +++ b/problems/convert-date-format/README.md @@ -9,6 +9,9 @@                  [Next >](../maximum-population-year "Maximum Population Year") -## [1853. Convert Date Format (Easy)](https://leetcode.com/problems/convert-date-format "") +## [1853. Convert Date Format (Easy)](https://leetcode.com/problems/convert-date-format "转换日期格式") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/convert-sorted-array-to-binary-search-tree/README.md b/problems/convert-sorted-array-to-binary-search-tree/README.md index 2fe1439c5..1a7403853 100644 --- a/problems/convert-sorted-array-to-binary-search-tree/README.md +++ b/problems/convert-sorted-array-to-binary-search-tree/README.md @@ -44,7 +44,10 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Convert Sorted List to Binary Search Tree](../convert-sorted-list-to-binary-search-tree) (Medium) diff --git a/problems/convert-sorted-list-to-binary-search-tree/README.md b/problems/convert-sorted-list-to-binary-search-tree/README.md index 8feef8265..e3261f6d8 100644 --- a/problems/convert-sorted-list-to-binary-search-tree/README.md +++ b/problems/convert-sorted-list-to-binary-search-tree/README.md @@ -54,8 +54,11 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Convert Sorted Array to Binary Search Tree](../convert-sorted-array-to-binary-search-tree) (Easy) diff --git a/problems/convex-polygon/README.md b/problems/convex-polygon/README.md index f70b00492..676fbb8fb 100644 --- a/problems/convex-polygon/README.md +++ b/problems/convex-polygon/README.md @@ -11,39 +11,8 @@ ## [469. Convex Polygon (Medium)](https://leetcode.com/problems/convex-polygon "凸多边形") -

    Given a list of points that form a polygon when joined sequentially, find if this polygon is convex (Convex polygon definition).

    -

     

    - -

    Note:

    - -
      -
    1. There are at least 3 and at most 10,000 points.
    2. -
    3. Coordinates are in the range -10,000 to 10,000.
    4. -
    5. You may assume the polygon formed by given points is always a simple polygon (Simple polygon definition). In other words, we ensure that exactly two edges intersect at each vertex, and that edges otherwise don't intersect each other.
    6. -
    - -

     

    - -

    Example 1:

    - -
    -[[0,0],[0,1],[1,1],[1,0]]
    -
    -Answer: True
    -
    -Explanation:
    -
    - -

    Example 2:

    - -
    -[[0,0],[0,10],[10,10],[10,0],[5,5]]
    -
    -Answer: False
    -
    -Explanation:
    -
    ### Related Topics + [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/coordinate-with-maximum-network-quality/README.md b/problems/coordinate-with-maximum-network-quality/README.md index b5f457ff0..f9e1f72bd 100644 --- a/problems/coordinate-with-maximum-network-quality/README.md +++ b/problems/coordinate-with-maximum-network-quality/README.md @@ -72,7 +72,8 @@ No other coordinate has higher quality.
    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] ### Hints
    diff --git a/problems/corporate-flight-bookings/README.md b/problems/corporate-flight-bookings/README.md index ecc1f3221..e48e88b45 100644 --- a/problems/corporate-flight-bookings/README.md +++ b/problems/corporate-flight-bookings/README.md @@ -59,4 +59,4 @@ Hence, answer = [10,25] ### Related Topics [[Array](../../tag/array/README.md)] - [[Math](../../tag/math/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] diff --git a/problems/correct-a-binary-tree/README.md b/problems/correct-a-binary-tree/README.md index 17e19bdd5..67651be4f 100644 --- a/problems/correct-a-binary-tree/README.md +++ b/problems/correct-a-binary-tree/README.md @@ -15,6 +15,10 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/count-all-possible-routes/README.md b/problems/count-all-possible-routes/README.md index 1227b3dd0..979194249 100644 --- a/problems/count-all-possible-routes/README.md +++ b/problems/count-all-possible-routes/README.md @@ -81,6 +81,8 @@ ### Related Topics + [[Memoization](../../tag/memoization/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/count-all-valid-pickup-and-delivery-options/README.md b/problems/count-all-valid-pickup-and-delivery-options/README.md index 664cb1b10..2ff24eb41 100644 --- a/problems/count-all-valid-pickup-and-delivery-options/README.md +++ b/problems/count-all-valid-pickup-and-delivery-options/README.md @@ -53,6 +53,7 @@ This is an invalid order (P1,D2,P2,D1) because Pickup 2 is after of Delivery 2. ### Related Topics [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Combinatorics](../../tag/combinatorics/README.md)] ### Hints
    diff --git a/problems/count-apples-and-oranges/README.md b/problems/count-apples-and-oranges/README.md index dd5692422..b37077c6d 100644 --- a/problems/count-apples-and-oranges/README.md +++ b/problems/count-apples-and-oranges/README.md @@ -12,3 +12,6 @@ ## [1715. Count Apples and Oranges (Medium)](https://leetcode.com/problems/count-apples-and-oranges "苹果和橘子的个数") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/count-binary-substrings/README.md b/problems/count-binary-substrings/README.md index 1bd0475b2..42e1f4151 100644 --- a/problems/count-binary-substrings/README.md +++ b/problems/count-binary-substrings/README.md @@ -43,6 +43,7 @@ Also, "00110011" is not a valid substring because all the 0's (and ### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/count-complete-tree-nodes/README.md b/problems/count-complete-tree-nodes/README.md index b1a505453..3770c14e4 100644 --- a/problems/count-complete-tree-nodes/README.md +++ b/problems/count-complete-tree-nodes/README.md @@ -50,7 +50,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Closest Binary Search Tree Value](../closest-binary-search-tree-value) (Easy) diff --git a/problems/count-good-meals/README.md b/problems/count-good-meals/README.md index e341e4284..5331d246a 100644 --- a/problems/count-good-meals/README.md +++ b/problems/count-good-meals/README.md @@ -47,7 +47,6 @@ Their respective sums are 4, 8, 8, and 16, all of which are powers of 2. ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] ### Hints
    diff --git a/problems/count-good-nodes-in-binary-tree/README.md b/problems/count-good-nodes-in-binary-tree/README.md index 29231eb0b..acab1defb 100644 --- a/problems/count-good-nodes-in-binary-tree/README.md +++ b/problems/count-good-nodes-in-binary-tree/README.md @@ -55,7 +55,9 @@ Node 3 -> (3,1,3) is the maximum value in the path.
    ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/count-good-numbers/README.md b/problems/count-good-numbers/README.md new file mode 100644 index 000000000..58b46f11f --- /dev/null +++ b/problems/count-good-numbers/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../eliminate-maximum-number-of-monsters "Eliminate Maximum Number of Monsters") +                 +[Next >](../longest-common-subpath "Longest Common Subpath") + +## [1922. Count Good Numbers (Medium)](https://leetcode.com/problems/count-good-numbers "统计好数字的数目") + +

    A digit string is good if the digits (0-indexed) at even indices are even and the digits at odd indices are prime (2, 3, 5, or 7).

    + +
      +
    • For example, "2582" is good because the digits (2 and 8) at even positions are even and the digits (5 and 2) at odd positions are prime. However, "3245" is not good because 3 is at an even index but is not even.
    • +
    + +

    Given an integer n, return the total number of good digit strings of length n. Since the answer may be large, return it modulo 109 + 7.

    + +

    A digit string is a string consisting of digits 0 through 9 that may contain leading zeros.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 1
    +Output: 5
    +Explanation: The good numbers of length 1 are "0", "2", "4", "6", "8".
    +
    + +

    Example 2:

    + +
    +Input: n = 4
    +Output: 400
    +
    + +

    Example 3:

    + +
    +Input: n = 50
    +Output: 564908303
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 1015
    • +
    + +### Related Topics + [[Recursion](../../tag/recursion/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Is there a formula we can use to find the count of all the good numbers? +
    + +
    +Hint 2 +Exponentiation can be done very fast if we looked at the binary bits of n. +
    diff --git a/problems/count-good-triplets/README.md b/problems/count-good-triplets/README.md index 2170a4cf6..8971656d9 100644 --- a/problems/count-good-triplets/README.md +++ b/problems/count-good-triplets/README.md @@ -54,6 +54,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] ### Hints
    diff --git a/problems/count-largest-group/README.md b/problems/count-largest-group/README.md index 9035e595d..4f3aaf3a2 100644 --- a/problems/count-largest-group/README.md +++ b/problems/count-largest-group/README.md @@ -55,7 +55,8 @@ ### Related Topics - [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/count-negative-numbers-in-a-sorted-matrix/README.md b/problems/count-negative-numbers-in-a-sorted-matrix/README.md index 24742bd45..11c98a5ff 100644 --- a/problems/count-negative-numbers-in-a-sorted-matrix/README.md +++ b/problems/count-negative-numbers-in-a-sorted-matrix/README.md @@ -59,6 +59,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/count-nice-pairs-in-an-array/README.md b/problems/count-nice-pairs-in-an-array/README.md index b7376c933..6aed91e6a 100644 --- a/problems/count-nice-pairs-in-an-array/README.md +++ b/problems/count-nice-pairs-in-an-array/README.md @@ -49,6 +49,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/count-number-of-homogenous-substrings/README.md b/problems/count-number-of-homogenous-substrings/README.md index 517f518d7..6259c34f8 100644 --- a/problems/count-number-of-homogenous-substrings/README.md +++ b/problems/count-number-of-homogenous-substrings/README.md @@ -56,7 +56,7 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/count-number-of-nice-subarrays/README.md b/problems/count-number-of-nice-subarrays/README.md index 5cf5c0d3d..ad11c6a23 100644 --- a/problems/count-number-of-nice-subarrays/README.md +++ b/problems/count-number-of-nice-subarrays/README.md @@ -49,7 +49,10 @@ ### Related Topics - [[Two Pointers](../../tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/count-number-of-teams/README.md b/problems/count-number-of-teams/README.md index 81fb7b979..6ee99a555 100644 --- a/problems/count-number-of-teams/README.md +++ b/problems/count-number-of-teams/README.md @@ -57,7 +57,9 @@ ### Related Topics + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/count-of-matches-in-tournament/README.md b/problems/count-of-matches-in-tournament/README.md index d981d3783..39e36fa7a 100644 --- a/problems/count-of-matches-in-tournament/README.md +++ b/problems/count-of-matches-in-tournament/README.md @@ -54,7 +54,8 @@ Total number of matches = 7 + 3 + 2 + 1 = 13. ### Related Topics - [[Backtracking](../../tag/backtracking/README.md)] + [[Math](../../tag/math/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/count-of-range-sum/README.md b/problems/count-of-range-sum/README.md index 385abcbcd..5e070bfde 100644 --- a/problems/count-of-range-sum/README.md +++ b/problems/count-of-range-sum/README.md @@ -42,11 +42,13 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Merge Sort](../../tag/merge-sort/README.md)] ### Similar Questions 1. [Count of Smaller Numbers After Self](../count-of-smaller-numbers-after-self) (Hard) diff --git a/problems/count-of-smaller-numbers-after-self/README.md b/problems/count-of-smaller-numbers-after-self/README.md index d6731f452..81dd24885 100644 --- a/problems/count-of-smaller-numbers-after-self/README.md +++ b/problems/count-of-smaller-numbers-after-self/README.md @@ -49,11 +49,13 @@ To the right of 1 there is 0 smaller element. ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Merge Sort](../../tag/merge-sort/README.md)] ### Similar Questions 1. [Count of Range Sum](../count-of-range-sum) (Hard) diff --git a/problems/count-pairs-in-two-arrays/README.md b/problems/count-pairs-in-two-arrays/README.md new file mode 100644 index 000000000..315548881 --- /dev/null +++ b/problems/count-pairs-in-two-arrays/README.md @@ -0,0 +1,40 @@ + + + + + + + +[< Previous](../egg-drop-with-2-eggs-and-n-floors "Egg Drop With 2 Eggs and N Floors") +                 +[Next >](../determine-whether-matrix-can-be-obtained-by-rotation "Determine Whether Matrix Can Be Obtained By Rotation") + +## [1885. Count Pairs in Two Arrays (Medium)](https://leetcode.com/problems/count-pairs-in-two-arrays "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +We can write it as nums1[i] - nums2[i] > nums2[j] - nums1[j] instead of nums1[i] + nums1[j] > nums2[i] + nums2[j]. +
    + +
    +Hint 2 +Store nums1[idx] - nums2[idx] in a data structure. +
    + +
    +Hint 3 +Store nums2[idx] - nums1[idx] in a different data structure. +
    + +
    +Hint 4 +For each integer in the first data structure, count the number of the strictly smaller integers in the second data structure with a larger index in the original array. +
    diff --git a/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md b/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md index 8e4a0b97b..9a8db9c5d 100644 --- a/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md +++ b/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md @@ -15,6 +15,7 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/count-pairs-of-nodes/README.md b/problems/count-pairs-of-nodes/README.md index a6cc82f6b..125c28307 100644 --- a/problems/count-pairs-of-nodes/README.md +++ b/problems/count-pairs-of-nodes/README.md @@ -11,26 +11,31 @@ ## [1782. Count Pairs Of Nodes (Hard)](https://leetcode.com/problems/count-pairs-of-nodes "统计点对的数目") -

    You are given an undirected graph represented by an integer n, which is the number of nodes, and edges, where edges[i] = [ui, vi] which indicates that there is an undirected edge between ui and vi. You are also given an integer array queries.

    +

    You are given an undirected graph defined by an integer n, the number of nodes, and a 2D integer array edges, the edges in the graph, where edges[i] = [ui, vi] indicates that there is an undirected edge between ui and vi. You are also given an integer array queries.

    -

    The answer to the jth query is the number of pairs of nodes (a, b) that satisfy the following conditions:

    +

    Let incident(a, b) be defined as the number of edges that are connected to either node a or b.

    + +

    The answer to the jth query is the number of pairs of nodes (a, b) that satisfy both of the following conditions:

    • a < b
    • -
    • cnt is strictly greater than queries[j], where cnt is the number of edges incident to a or b.
    • +
    • incident(a, b) > queries[j]
    -

    Return an array answers such that answers.length == queries.length and answers[j] is the answer of the jth query.

    +

    Return an array answers such that answers.length == queries.length and answers[j] is the answer of the jth query.

    -

    Note that there can be repeated edges.

    +

    Note that there can be multiple edges between the same two nodes.

     

    Example 1:

    - +
     Input: n = 4, edges = [[1,2],[2,4],[1,3],[2,3],[2,1]], queries = [2,3]
     Output: [6,5]
    -Explanation: The number of edges incident to at least one of each pair is shown above.
    +Explanation: The calculations for incident(a, b) are shown in the table above.
    +The answers for each of the queries are as follows:
    +- answers[0] = 6. All the pairs have an incident(a, b) value greater than 2.
    +- answers[1] = 5. All the pairs except (3, 4) have an incident(a, b) value greater than 3.
     

    Example 2:

    @@ -54,6 +59,8 @@ ### Related Topics [[Graph](../../tag/graph/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
    diff --git a/problems/count-pairs-with-xor-in-a-range/README.md b/problems/count-pairs-with-xor-in-a-range/README.md index 43f3520d3..35ec7bfce 100644 --- a/problems/count-pairs-with-xor-in-a-range/README.md +++ b/problems/count-pairs-with-xor-in-a-range/README.md @@ -55,7 +55,9 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Trie](../../tag/trie/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/count-primes/README.md b/problems/count-primes/README.md index 9ecaffa2b..ca4a98cc0 100644 --- a/problems/count-primes/README.md +++ b/problems/count-primes/README.md @@ -44,8 +44,10 @@ ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + [[Number Theory](../../tag/number-theory/README.md)] ### Similar Questions 1. [Ugly Number](../ugly-number) (Easy) diff --git a/problems/count-salary-categories/README.md b/problems/count-salary-categories/README.md new file mode 100644 index 000000000..503298df1 --- /dev/null +++ b/problems/count-salary-categories/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../minimum-absolute-difference-queries "Minimum Absolute Difference Queries") +                 +[Next >](../game-of-nim "Game of Nim") + +## [1907. Count Salary Categories (Medium)](https://leetcode.com/problems/count-salary-categories "按分类统计薪水") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/count-salary-categories/mysql_schemas.sql b/problems/count-salary-categories/mysql_schemas.sql new file mode 100644 index 000000000..bca4a8114 --- /dev/null +++ b/problems/count-salary-categories/mysql_schemas.sql @@ -0,0 +1,6 @@ +Create table If Not Exists Accounts (account_id int, income int); +Truncate table Accounts; +insert into Accounts (account_id, income) values ('3', '108939'); +insert into Accounts (account_id, income) values ('2', '12747'); +insert into Accounts (account_id, income) values ('8', '87709'); +insert into Accounts (account_id, income) values ('6', '91796'); diff --git a/problems/count-servers-that-communicate/README.md b/problems/count-servers-that-communicate/README.md index 4a6de5bd0..7789405cf 100644 --- a/problems/count-servers-that-communicate/README.md +++ b/problems/count-servers-that-communicate/README.md @@ -57,8 +57,12 @@ Return the number of servers that communicate with any other server.

    ### Related Topics - [[Graph](../../tag/graph/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/count-sorted-vowel-strings/README.md b/problems/count-sorted-vowel-strings/README.md index 6ddf5b2b8..d65e1dafe 100644 --- a/problems/count-sorted-vowel-strings/README.md +++ b/problems/count-sorted-vowel-strings/README.md @@ -49,9 +49,7 @@ Note that "ea" is not a valid string since 'e' comes after  ### Related Topics - [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Backtracking](../../tag/backtracking/README.md)] ### Hints
    diff --git a/problems/count-square-submatrices-with-all-ones/README.md b/problems/count-square-submatrices-with-all-ones/README.md index 4ad175457..cf2e3ec9e 100644 --- a/problems/count-square-submatrices-with-all-ones/README.md +++ b/problems/count-square-submatrices-with-all-ones/README.md @@ -59,6 +59,7 @@ Total number of squares = 6 + 1 = 7. ### Related Topics [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/count-student-number-in-departments/README.md b/problems/count-student-number-in-departments/README.md index 5291ffe31..ebfa9bb92 100644 --- a/problems/count-student-number-in-departments/README.md +++ b/problems/count-student-number-in-departments/README.md @@ -11,66 +11,10 @@ ## [580. Count Student Number in Departments (Medium)](https://leetcode.com/problems/count-student-number-in-departments "统计各专业学生人数") -

    A university uses 2 data tables, student and department, to store data about its students and the departments associated with each major.

    -

    Write a query to print the respective department name and number of students majoring in each department for all departments in the department table (even ones with no current students).

    -

    Sort your results by descending number of students; if two or more departments have the same number of students, then sort those departments alphabetically by department name.

    - -

    The student is described as follow:

    - -
    -| Column Name  | Type      |
    -|--------------|-----------|
    -| student_id   | Integer   |
    -| student_name | String    |
    -| gender       | Character |
    -| dept_id      | Integer   |
    -
    - -

    where student_id is the student's ID number, student_name is the student's name, gender is their gender, and dept_id is the department ID associated with their declared major.

    - -

    And the department table is described as below:

    - -
    -| Column Name | Type    |
    -|-------------|---------|
    -| dept_id     | Integer |
    -| dept_name   | String  |
    -
    - -

    where dept_id is the department's ID number and dept_name is the department name.

    - -

    Here is an example input:
    -student table:

    - -
    -| student_id | student_name | gender | dept_id |
    -|------------|--------------|--------|---------|
    -| 1          | Jack         | M      | 1       |
    -| 2          | Jane         | F      | 1       |
    -| 3          | Mark         | M      | 2       |
    -
    - -

    department table:

    - -
    -| dept_id | dept_name   |
    -|---------|-------------|
    -| 1       | Engineering |
    -| 2       | Science     |
    -| 3       | Law         |
    -
    - -

    The Output should be:

    - -
    -| dept_name   | student_number |
    -|-------------|----------------|
    -| Engineering | 2              |
    -| Science     | 1              |
    -| Law         | 0              |
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] ### Hints
    diff --git a/problems/count-sub-islands/README.md b/problems/count-sub-islands/README.md new file mode 100644 index 000000000..11d21ca47 --- /dev/null +++ b/problems/count-sub-islands/README.md @@ -0,0 +1,65 @@ + + + + + + + +[< Previous](../the-number-of-full-rounds-you-have-played "The Number of Full Rounds You Have Played") +                 +[Next >](../minimum-absolute-difference-queries "Minimum Absolute Difference Queries") + +## [1905. Count Sub Islands (Medium)](https://leetcode.com/problems/count-sub-islands "统计子岛屿") + +

    You are given two m x n binary matrices grid1 and grid2 containing only 0's (representing water) and 1's (representing land). An island is a group of 1's connected 4-directionally (horizontal or vertical). Any cells outside of the grid are considered water cells.

    + +

    An island in grid2 is considered a sub-island if there is an island in grid1 that contains all the cells that make up this island in grid2.

    + +

    Return the number of islands in grid2 that are considered sub-islands.

    + +

     

    +

    Example 1:

    + +
    +Input: grid1 = [[1,1,1,0,0],[0,1,1,1,1],[0,0,0,0,0],[1,0,0,0,0],[1,1,0,1,1]], grid2 = [[1,1,1,0,0],[0,0,1,1,1],[0,1,0,0,0],[1,0,1,1,0],[0,1,0,1,0]]
    +Output: 3
    +Explanation: In the picture above, the grid on the left is grid1 and the grid on the right is grid2.
    +The 1s colored red in grid2 are those considered to be part of a sub-island. There are three sub-islands.
    +
    + +

    Example 2:

    + +
    +Input: grid1 = [[1,0,1,0,1],[1,1,1,1,1],[0,0,0,0,0],[1,1,1,1,1],[1,0,1,0,1]], grid2 = [[0,0,0,0,0],[1,1,1,1,1],[0,1,0,1,0],[0,1,0,1,0],[1,0,0,0,1]]
    +Output: 2 
    +Explanation: In the picture above, the grid on the left is grid1 and the grid on the right is grid2.
    +The 1s colored red in grid2 are those considered to be part of a sub-island. There are two sub-islands.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == grid1.length == grid2.length
    • +
    • n == grid1[i].length == grid2[i].length
    • +
    • 1 <= m, n <= 500
    • +
    • grid1[i][j] and grid2[i][j] are either 0 or 1.
    • +
    + +### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Let's use floodfill to iterate over the islands of the second grid +
    + +
    +Hint 2 +Let's note that if all the cells in an island in the second grid if they are represented by land in the first grid then they are connected hence making that island a sub-island +
    diff --git a/problems/count-submatrices-with-all-ones/README.md b/problems/count-submatrices-with-all-ones/README.md index a6a872b36..7487dfdd9 100644 --- a/problems/count-submatrices-with-all-ones/README.md +++ b/problems/count-submatrices-with-all-ones/README.md @@ -72,7 +72,11 @@ Total number of rectangles = 8 + 5 + 2 + 4 + 2 + 2 + 1 = 24. ### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints
    diff --git a/problems/count-substrings-that-differ-by-one-character/README.md b/problems/count-substrings-that-differ-by-one-character/README.md index 5c97929d6..b69935728 100644 --- a/problems/count-substrings-that-differ-by-one-character/README.md +++ b/problems/count-substrings-that-differ-by-one-character/README.md @@ -68,9 +68,9 @@ The underlined portions are the substrings that are chosen from s and t. ### Related Topics - [[Trie](../../tag/trie/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/count-substrings-with-only-one-distinct-letter/README.md b/problems/count-substrings-with-only-one-distinct-letter/README.md index 4636959fc..d43163150 100644 --- a/problems/count-substrings-with-only-one-distinct-letter/README.md +++ b/problems/count-substrings-with-only-one-distinct-letter/README.md @@ -11,36 +11,7 @@ ## [1180. Count Substrings with Only One Distinct Letter (Easy)](https://leetcode.com/problems/count-substrings-with-only-one-distinct-letter "统计只含单一字母的子串") -

    Given a string S, return the number of substrings that have only one distinct letter.

    - -

     

    -

    Example 1:

    - -
    -Input: S = "aaaba"
    -Output: 8
    -Explanation: The substrings with one distinct letter are "aaa", "aa", "a", "b".
    -"aaa" occurs 1 time.
    -"aa" occurs 2 times.
    -"a" occurs 4 times.
    -"b" occurs 1 time.
    -So the answer is 1 + 2 + 4 + 1 = 8.
    -
    - -

    Example 2:

    - -
    -Input: S = "aaaaaaaaaa"
    -Output: 55
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= S.length <= 1000
    • -
    • S[i] consists of only lowercase English letters.
    • -
    + ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/count-subtrees-with-max-distance-between-cities/README.md b/problems/count-subtrees-with-max-distance-between-cities/README.md index d3c9184f2..ce23fc9b5 100644 --- a/problems/count-subtrees-with-max-distance-between-cities/README.md +++ b/problems/count-subtrees-with-max-distance-between-cities/README.md @@ -61,7 +61,11 @@ No subtree has two nodes where the max distance between them is 3. ### Related Topics - [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] ### Hints
    diff --git a/problems/count-the-number-of-consistent-strings/README.md b/problems/count-the-number-of-consistent-strings/README.md index ac8713c98..c48a70fcf 100644 --- a/problems/count-the-number-of-consistent-strings/README.md +++ b/problems/count-the-number-of-consistent-strings/README.md @@ -52,6 +52,9 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/count-the-repetitions/README.md b/problems/count-the-repetitions/README.md index 25885478e..7c6d44a5e 100644 --- a/problems/count-the-repetitions/README.md +++ b/problems/count-the-repetitions/README.md @@ -45,4 +45,5 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md b/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md index f73d02316..30c9275c0 100644 --- a/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md +++ b/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md @@ -74,7 +74,9 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/count-unhappy-friends/README.md b/problems/count-unhappy-friends/README.md index 9f5bdc72d..15d272ff7 100644 --- a/problems/count-unhappy-friends/README.md +++ b/problems/count-unhappy-friends/README.md @@ -77,6 +77,7 @@ Friends 0 and 2 are happy. ### Related Topics [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/count-unique-characters-of-all-substrings-of-a-given-string/README.md b/problems/count-unique-characters-of-all-substrings-of-a-given-string/README.md index 26680d401..cd6f99d95 100644 --- a/problems/count-unique-characters-of-all-substrings-of-a-given-string/README.md +++ b/problems/count-unique-characters-of-all-substrings-of-a-given-string/README.md @@ -11,11 +11,15 @@ ## [828. Count Unique Characters of All Substrings of a Given String (Hard)](https://leetcode.com/problems/count-unique-characters-of-all-substrings-of-a-given-string "统计子串中的唯一字符") -

    Let's define a function countUniqueChars(s) that returns the number of unique characters on s, for example if s = "LEETCODE" then "L", "T","C","O","D" are the unique characters since they appear only once in s, therefore countUniqueChars(s) = 5.
    -
    -On this problem given a string s we need to return the sum of countUniqueChars(t) where t is a substring of s. Notice that some substrings can be repeated so on this case you have to count the repeated ones too.

    +

    Let's define a function countUniqueChars(s) that returns the number of unique characters on s.

    -

    Since the answer can be very large, return the answer modulo 10 ^ 9 + 7.

    +
      +
    • For example if s = "LEETCODE" then "L", "T", "C", "O", "D" are the unique characters since they appear only once in s, therefore countUniqueChars(s) = 5.
    • +
    + +

    Given a string s, return the sum of countUniqueChars(t) where t is a substring of s.

    + +

    Notice that some substrings can be repeated so in this case you have to count the repeated ones too.

     

    Example 1:

    @@ -47,9 +51,10 @@ Sum of lengths of all substring is 1 + 1 + 1 + 2 + 2 + 3 = 10

    Constraints:

      -
    • 0 <= s.length <= 10^4
    • -
    • s contain upper-case English letters only.
    • +
    • 1 <= s.length <= 105
    • +
    • s consists of uppercase English letters only.
    ### Related Topics - [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/count-univalue-subtrees/README.md b/problems/count-univalue-subtrees/README.md index d90a0644d..4f8832484 100644 --- a/problems/count-univalue-subtrees/README.md +++ b/problems/count-univalue-subtrees/README.md @@ -11,25 +11,12 @@ ## [250. Count Univalue Subtrees (Medium)](https://leetcode.com/problems/count-univalue-subtrees "统计同值子树") -

    Given a binary tree, count the number of uni-value subtrees.

    -

    A Uni-value subtree means all nodes of the subtree have the same value.

    - -

    Example :

    - -
    Input:  root = [5,1,5,5,5,null,5]
    -
    -              5
    -             / \
    -            1   5
    -           / \   \
    -          5   5   5
    -
    -Output: 4
    -
    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Subtree of Another Tree](../subtree-of-another-tree) (Easy) diff --git a/problems/count-ways-to-build-rooms-in-an-ant-colony/README.md b/problems/count-ways-to-build-rooms-in-an-ant-colony/README.md new file mode 100644 index 000000000..14dfe8447 --- /dev/null +++ b/problems/count-ways-to-build-rooms-in-an-ant-colony/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../number-of-wonderful-substrings "Number of Wonderful Substrings") +                 +[Next >](../leetcodify-friends-recommendations "Leetcodify Friends Recommendations") + +## [1916. Count Ways to Build Rooms in an Ant Colony (Hard)](https://leetcode.com/problems/count-ways-to-build-rooms-in-an-ant-colony "统计为蚁群构筑房间的不同顺序") + +

    You are an ant tasked with adding n new rooms numbered 0 to n-1 to your colony. You are given the expansion plan as a 0-indexed integer array of length n, prevRoom, where prevRoom[i] indicates that you must build room prevRoom[i] before building room i, and these two rooms must be connected directly. Room 0 is already built, so prevRoom[0] = -1. The expansion plan is given such that once all the rooms are built, every room will be reachable from room 0.

    + +

    You can only build one room at a time, and you can travel freely between rooms you have already built only if they are connected. You can choose to build any room as long as its previous room is already built.

    + +

    Return the number of different orders you can build all the rooms in. Since the answer may be large, return it modulo 109 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: prevRoom = [-1,0,1]
    +Output: 1
    +Explanation: There is only one way to build the additional rooms: 0 → 1 → 2
    +
    + +

    Example 2:

    + + +
    +Input: prevRoom = [-1,0,0,1,2]
    +Output: 6
    +Explanation:
    +The 6 ways are:
    +0 → 1 → 3 → 2 → 4
    +0 → 2 → 4 → 1 → 3
    +0 → 1 → 2 → 3 → 4
    +0 → 1 → 2 → 4 → 3
    +0 → 2 → 1 → 3 → 4
    +0 → 2 → 1 → 4 → 3
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == prevRoom.length
    • +
    • 2 <= n <= 105
    • +
    • prevRoom[0] == -1
    • +
    • 0 <= prevRoom[i] < n for all 1 <= i < n
    • +
    • Every room is reachable from room 0 once all the rooms are built.
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Combinatorics](../../tag/combinatorics/README.md)] + +### Hints +
    +Hint 1 +Use dynamic programming. +
    + +
    +Hint 2 +Let dp[i] be the number of ways to solve the problem for the subtree of node i. +
    + +
    +Hint 3 +Imagine you are trying to fill an array with the order of traversal, dp[i] equals the multiplications of the number of ways to distribute the subtrees of the children of i on the array using combinatorics, multiplied bu their dp values. +
    diff --git a/problems/count-ways-to-make-array-with-product/README.md b/problems/count-ways-to-make-array-with-product/README.md index c2db3b12b..52c4da44f 100644 --- a/problems/count-ways-to-make-array-with-product/README.md +++ b/problems/count-ways-to-make-array-with-product/README.md @@ -43,7 +43,9 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/counting-elements/README.md b/problems/counting-elements/README.md index ee43f6c68..11326dfda 100644 --- a/problems/counting-elements/README.md +++ b/problems/counting-elements/README.md @@ -15,6 +15,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/countries-you-can-safely-invest-in/README.md b/problems/countries-you-can-safely-invest-in/README.md index 2f8e86b4e..eac2822ed 100644 --- a/problems/countries-you-can-safely-invest-in/README.md +++ b/problems/countries-you-can-safely-invest-in/README.md @@ -12,3 +12,6 @@ ## [1501. Countries You Can Safely Invest In (Medium)](https://leetcode.com/problems/countries-you-can-safely-invest-in "可以放心投资的国家") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/couples-holding-hands/README.md b/problems/couples-holding-hands/README.md index b86d0e446..517465e5d 100644 --- a/problems/couples-holding-hands/README.md +++ b/problems/couples-holding-hands/README.md @@ -11,34 +11,44 @@ ## [765. Couples Holding Hands (Hard)](https://leetcode.com/problems/couples-holding-hands "情侣牵手") -

    -N couples sit in 2N seats arranged in a row and want to hold hands. We want to know the minimum number of swaps so that every couple is sitting side by side. A swap consists of choosing any two people, then they stand up and switch seats. -

    -The people and seats are represented by an integer from 0 to 2N-1, the couples are numbered in order, the first couple being (0, 1), the second couple being (2, 3), and so on with the last couple being (2N-2, 2N-1). -

    -The couples' initial seating is given by row[i] being the value of the person who is initially sitting in the i-th seat. - -

    Example 1:

    -Input: row = [0, 2, 1, 3]
    -Output: 1
    -Explanation: We only need to swap the second (row[1]) and third (row[2]) person.
    -

    - -

    Example 2:

    -Input: row = [3, 2, 0, 1]
    -Output: 0
    -Explanation: All couples are already seated side by side.
    -

    - -

    -Note: -

      -
    1. len(row) is even and in the range of [4, 60].
    2. -
    3. row is guaranteed to be a permutation of 0...len(row)-1.
    4. -
    +

    There are n couples sitting in 2n seats arranged in a row and want to hold hands.

    + +

    The people and seats are represented by an integer array row where row[i] is the ID of the person sitting in the ith seat. The couples are numbered in order, the first couple being (0, 1), the second couple being (2, 3), and so on with the last couple being (2n - 2, 2n - 1).

    + +

    Return the minimum number of swaps so that every couple is sitting side by side. A swap consists of choosing any two people, then they stand up and switch seats.

    + +

     

    +

    Example 1:

    + +
    +Input: row = [0,2,1,3]
    +Output: 1
    +Explanation: We only need to swap the second (row[1]) and third (row[2]) person.
    +
    + +

    Example 2:

    + +
    +Input: row = [3,2,0,1]
    +Output: 0
    +Explanation: All couples are already seated side by side.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2n == row.length
    • +
    • 2 <= n <= 30
    • +
    • n is even.
    • +
    • 0 <= row[i] < 2n
    • +
    • All the elements of row are unique.
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] diff --git a/problems/course-schedule-ii/README.md b/problems/course-schedule-ii/README.md index fb7ab2659..877d068c6 100644 --- a/problems/course-schedule-ii/README.md +++ b/problems/course-schedule-ii/README.md @@ -57,8 +57,8 @@ So one correct course order is [0,1,2,3]. Another correct ordering is [0,2,1,3]. ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] diff --git a/problems/course-schedule-iii/README.md b/problems/course-schedule-iii/README.md index c37916891..577881318 100644 --- a/problems/course-schedule-iii/README.md +++ b/problems/course-schedule-iii/README.md @@ -55,6 +55,8 @@ The 4th course cannot be taken now, since you will finish it on the 3 ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Course Schedule](../course-schedule) (Medium) diff --git a/problems/course-schedule-iv/README.md b/problems/course-schedule-iv/README.md index 956c3c9d1..359a55d75 100644 --- a/problems/course-schedule-iv/README.md +++ b/problems/course-schedule-iv/README.md @@ -61,7 +61,10 @@ ### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] ### Hints
    diff --git a/problems/course-schedule/README.md b/problems/course-schedule/README.md index f701a0b2e..974381397 100644 --- a/problems/course-schedule/README.md +++ b/problems/course-schedule/README.md @@ -50,8 +50,8 @@ To take course 1 you should have finished course 0, and to take course 0 you sho ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] diff --git a/problems/cousins-in-binary-tree/README.md b/problems/cousins-in-binary-tree/README.md index 47666787e..8caccae10 100644 --- a/problems/cousins-in-binary-tree/README.md +++ b/problems/cousins-in-binary-tree/README.md @@ -60,7 +60,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Binary Tree Level Order Traversal](../binary-tree-level-order-traversal) (Medium) diff --git a/problems/cracking-the-safe/README.md b/problems/cracking-the-safe/README.md index fc3957601..67b8cac1e 100644 --- a/problems/cracking-the-safe/README.md +++ b/problems/cracking-the-safe/README.md @@ -11,47 +11,46 @@ ## [753. Cracking the Safe (Hard)](https://leetcode.com/problems/cracking-the-safe "破解保险箱") -

    There is a box protected by a password. The password is a sequence of n digits where each digit can be one of the first k digits 0, 1, ..., k-1.

    +

    There is a box protected by a password. The password is a sequence of n digits where each digit can be in the range [0, k - 1].

    -

    While entering a password, the last n digits entered will automatically be matched against the correct password.

    +

    While entering a password, the last n digits entered will automatically be matched against the correct password.

    -

    For example, assuming the correct password is "345", if you type "012345", the box will open because the correct password matches the suffix of the entered password.

    +
      +
    • For example, assuming the correct password is "345", if you type "012345", the box will open because the correct password matches the suffix of the entered password.
    • +
    -

    Return any password of minimum length that is guaranteed to open the box at some point of entering it.

    +

    Return any password of minimum length that is guaranteed to open the box at some point of entering it.

     

    - -

    Example 1:

    +

    Example 1:

    -Input: n = 1, k = 2
    -Output: "01"
    -Note: "10" will be accepted too.
    +Input: n = 1, k = 2
    +Output: "10"
    +Explanation: "01" will be accepted too.
     
    -

    Example 2:

    +

    Example 2:

    -Input: n = 2, k = 2
    -Output: "00110"
    -Note: "01100", "10011", "11001" will be accepted too.
    +Input: n = 2, k = 2
    +Output: "01100"
    +Explanation: "01100", "10011", "11001" will be accepted too.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. n will be in the range [1, 4].
    2. -
    3. k will be in the range [1, 10].
    4. -
    5. k^n will be at most 4096.
    6. -
    - -

     

    +
      +
    • 1 <= n <= 4
    • +
    • 1 <= k <= 10
    • +
    • 1 <= kn <= 4096
    • +
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Math](../../tag/math/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Eulerian Circuit](../../tag/eulerian-circuit/README.md)] ### Hints
    diff --git a/problems/crawler-log-folder/README.md b/problems/crawler-log-folder/README.md index 5b134cae2..3cc230641 100644 --- a/problems/crawler-log-folder/README.md +++ b/problems/crawler-log-folder/README.md @@ -67,6 +67,8 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/create-a-session-bar-chart/README.md b/problems/create-a-session-bar-chart/README.md index c47d9fbcd..373135897 100644 --- a/problems/create-a-session-bar-chart/README.md +++ b/problems/create-a-session-bar-chart/README.md @@ -12,3 +12,6 @@ ## [1435. Create a Session Bar Chart (Easy)](https://leetcode.com/problems/create-a-session-bar-chart "制作会话柱状图") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/create-maximum-number/README.md b/problems/create-maximum-number/README.md index 426415cac..6b7047a53 100644 --- a/problems/create-maximum-number/README.md +++ b/problems/create-maximum-number/README.md @@ -50,12 +50,10 @@
  • 1 <= k <= m + n
  • -

     

    -

    Follow up: Try to optimize your time and space complexity.

    - ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Similar Questions 1. [Remove K Digits](../remove-k-digits) (Medium) diff --git a/problems/create-sorted-array-through-instructions/README.md b/problems/create-sorted-array-through-instructions/README.md index 6b9553bf1..d91cd5108 100644 --- a/problems/create-sorted-array-through-instructions/README.md +++ b/problems/create-sorted-array-through-instructions/README.md @@ -79,8 +79,11 @@ The total cost is 0 + 0 + 0 + 0 + 1 + 0 + 1 + 0 + 2 = 4. ### Related Topics [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Ordered Map](../../tag/ordered-map/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Merge Sort](../../tag/merge-sort/README.md)] ### Hints
    diff --git a/problems/create-target-array-in-the-given-order/README.md b/problems/create-target-array-in-the-given-order/README.md index 0e4cdc0d9..26cc2be14 100644 --- a/problems/create-target-array-in-the-given-order/README.md +++ b/problems/create-target-array-in-the-given-order/README.md @@ -71,6 +71,7 @@ nums index target ### Related Topics [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/critical-connections-in-a-network/README.md b/problems/critical-connections-in-a-network/README.md index 6d7c2ecb1..d8e2dc613 100644 --- a/problems/critical-connections-in-a-network/README.md +++ b/problems/critical-connections-in-a-network/README.md @@ -40,7 +40,9 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Biconnected Component](../../tag/biconnected-component/README.md)] ### Hints
    diff --git a/problems/custom-sort-string/README.md b/problems/custom-sort-string/README.md index 75d92e963..90d65f2d6 100644 --- a/problems/custom-sort-string/README.md +++ b/problems/custom-sort-string/README.md @@ -39,4 +39,6 @@ Since "d" does not appear in order, it can be at any position in the r ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/customer-order-frequency/README.md b/problems/customer-order-frequency/README.md index e4487f01e..866f4d346 100644 --- a/problems/customer-order-frequency/README.md +++ b/problems/customer-order-frequency/README.md @@ -12,3 +12,6 @@ ## [1511. Customer Order Frequency (Easy)](https://leetcode.com/problems/customer-order-frequency "消费者下单频率") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/customer-placing-the-largest-number-of-orders/README.md b/problems/customer-placing-the-largest-number-of-orders/README.md index e4537c3f7..3c5f5fc3c 100644 --- a/problems/customer-placing-the-largest-number-of-orders/README.md +++ b/problems/customer-placing-the-largest-number-of-orders/README.md @@ -11,51 +11,10 @@ ## [586. Customer Placing the Largest Number of Orders (Easy)](https://leetcode.com/problems/customer-placing-the-largest-number-of-orders "订单最多的客户") -

    Query the customer_number from the orders table for the customer who has placed the largest number of orders.

    -

    It is guaranteed that exactly one customer will have placed more orders than any other customer.

    -

    The orders table is defined as follows:

    - -
    -| Column            | Type      |
    -|-------------------|-----------|
    -| order_number (PK) | int       |
    -| customer_number   | int       |
    -| order_date        | date      |
    -| required_date     | date      |
    -| shipped_date      | date      |
    -| status            | char(15)  |
    -| comment           | char(200) |
    -
    - -

    Sample Input

    - -
    -| order_number | customer_number | order_date | required_date | shipped_date | status | comment |
    -|--------------|-----------------|------------|---------------|--------------|--------|---------|
    -| 1            | 1               | 2017-04-09 | 2017-04-13    | 2017-04-12   | Closed |         |
    -| 2            | 2               | 2017-04-15 | 2017-04-20    | 2017-04-18   | Closed |         |
    -| 3            | 3               | 2017-04-16 | 2017-04-25    | 2017-04-20   | Closed |         |
    -| 4            | 3               | 2017-04-18 | 2017-04-28    | 2017-04-25   | Closed |         |
    -
    - -

    Sample Output

    - -
    -| customer_number |
    -|-----------------|
    -| 3               |
    -
    - -

    Explanation

    - -
    -The customer with number '3' has two orders, which is greater than either customer '1' or '2' because each of them  only has one order. 
    -So the result is customer_number '3'.
    -
    - -

    Follow up: What if more than one customer have the largest number of orders, can you find all the customer_number in this case?

    +### Related Topics + [[Database](../../tag/database/README.md)] ### Hints
    diff --git a/problems/customer-who-visited-but-did-not-make-any-transactions/README.md b/problems/customer-who-visited-but-did-not-make-any-transactions/README.md index 868f8d122..7d9a80b24 100644 --- a/problems/customer-who-visited-but-did-not-make-any-transactions/README.md +++ b/problems/customer-who-visited-but-did-not-make-any-transactions/README.md @@ -12,3 +12,6 @@ ## [1581. Customer Who Visited but Did Not Make Any Transactions (Easy)](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的顾客") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/customers-who-bought-all-products/README.md b/problems/customers-who-bought-all-products/README.md index 55613c05d..860b4e563 100644 --- a/problems/customers-who-bought-all-products/README.md +++ b/problems/customers-who-bought-all-products/README.md @@ -11,61 +11,7 @@ ## [1045. Customers Who Bought All Products (Medium)](https://leetcode.com/problems/customers-who-bought-all-products "买下所有产品的客户") -

    Table: Customer

    -
    -+-------------+---------+
    -| Column Name | Type    |
    -+-------------+---------+
    -| customer_id | int     |
    -| product_key | int     |
    -+-------------+---------+
    -product_key is a foreign key to Product table.
    -
    -

    Table: Product

    - -
    -+-------------+---------+
    -| Column Name | Type    |
    -+-------------+---------+
    -| product_key | int     |
    -+-------------+---------+
    -product_key is the primary key column for this table.
    -
    - -

     

    - -

    Write an SQL query for a report that provides the customer ids from the Customer table that bought all the products in the Product table.

    - -

    For example:

    - -
    -Customer table:
    -+-------------+-------------+
    -| customer_id | product_key |
    -+-------------+-------------+
    -| 1           | 5           |
    -| 2           | 6           |
    -| 3           | 5           |
    -| 3           | 6           |
    -| 1           | 6           |
    -+-------------+-------------+
    -
    -Product table:
    -+-------------+
    -| product_key |
    -+-------------+
    -| 5           |
    -| 6           |
    -+-------------+
    -
    -Result table:
    -+-------------+
    -| customer_id |
    -+-------------+
    -| 1           |
    -| 3           |
    -+-------------+
    -The customers who bought all the products (5 and 6) are customers with id 1 and 3.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/customers-who-bought-products-a-and-b-but-not-c/README.md b/problems/customers-who-bought-products-a-and-b-but-not-c/README.md index ad22327ae..d8a181f24 100644 --- a/problems/customers-who-bought-products-a-and-b-but-not-c/README.md +++ b/problems/customers-who-bought-products-a-and-b-but-not-c/README.md @@ -11,68 +11,7 @@ ## [1398. Customers Who Bought Products A and B but Not C (Medium)](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c "购买了产品 A 和产品 B 却没有购买产品 C 的顾客") -

    Table: Customers

    -
    -+---------------------+---------+
    -| Column Name         | Type    |
    -+---------------------+---------+
    -| customer_id         | int     |
    -| customer_name       | varchar |
    -+---------------------+---------+
    -customer_id is the primary key for this table.
    -customer_name is the name of the customer.
    -
    - -

    Table: Orders

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| order_id      | int     |
    -| customer_id   | int     |
    -| product_name  | varchar |
    -+---------------+---------+
    -order_id is the primary key for this table.
    -customer_id is the id of the customer who bought the product "product_name".
    -
    - -Write an SQL query to report the customer_id and customer_name of customers who bought products "A", "B" but did not buy the product "C" since we want to recommend them buy this product. -Return the result table ordered by customer_id. -The query result format is in the following example. - -
    -Customers table:
    -+-------------+---------------+
    -| customer_id | customer_name |
    -+-------------+---------------+
    -| 1           | Daniel        |
    -| 2           | Diana         |
    -| 3           | Elizabeth     |
    -| 4           | Jhon          |
    -+-------------+---------------+
    -
    -Orders table:
    -+------------+--------------+---------------+
    -| order_id   | customer_id  | product_name  |
    -+------------+--------------+---------------+
    -| 10         |     1        |     A         |
    -| 20         |     1        |     B         |
    -| 30         |     1        |     D         |
    -| 40         |     1        |     C         |
    -| 50         |     2        |     A         |
    -| 60         |     3        |     A         |
    -| 70         |     3        |     B         |
    -| 80         |     3        |     D         |
    -| 90         |     4        |     C         |
    -+------------+--------------+---------------+
    -
    -Result table:
    -+-------------+---------------+
    -| customer_id | customer_name |
    -+-------------+---------------+
    -| 3           | Elizabeth     |
    -+-------------+---------------+
    -Only the customer_id with id 3 bought the product A and B but not the product C.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/customers-who-never-order/README.md b/problems/customers-who-never-order/README.md index abb7f3491..8940d8b39 100644 --- a/problems/customers-who-never-order/README.md +++ b/problems/customers-who-never-order/README.md @@ -47,3 +47,6 @@ | Max | +-----------+
    + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/cut-off-trees-for-golf-event/README.md b/problems/cut-off-trees-for-golf-event/README.md index 4f8b85117..355e1a9d3 100644 --- a/problems/cut-off-trees-for-golf-event/README.md +++ b/problems/cut-off-trees-for-golf-event/README.md @@ -64,4 +64,7 @@ Note that you can cut off the first tree at (0, 0) before making any steps. ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/cutting-ribbons/README.md b/problems/cutting-ribbons/README.md new file mode 100644 index 000000000..f9032d076 --- /dev/null +++ b/problems/cutting-ribbons/README.md @@ -0,0 +1,29 @@ + + + + + + + +[< Previous](../the-latest-login-in-2020 "The Latest Login in 2020") +                 +[Next >](../page-recommendations-ii "Page Recommendations II") + +## [1891. Cutting Ribbons (Medium)](https://leetcode.com/problems/cutting-ribbons "割绳子") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Use binary search on the answer. +
    + +
    +Hint 2 +You can get l/m branches of length m from a branch with length l. +
    diff --git a/problems/cyclically-rotating-a-grid/README.md b/problems/cyclically-rotating-a-grid/README.md new file mode 100644 index 000000000..827d5058b --- /dev/null +++ b/problems/cyclically-rotating-a-grid/README.md @@ -0,0 +1,68 @@ + + + + + + + +[< Previous](../maximum-product-difference-between-two-pairs "Maximum Product Difference Between Two Pairs") +                 +[Next >](../number-of-wonderful-substrings "Number of Wonderful Substrings") + +## [1914. Cyclically Rotating a Grid (Medium)](https://leetcode.com/problems/cyclically-rotating-a-grid "循环轮转矩阵") + +

    You are given an m x n integer matrix grid​​​, where m and n are both even integers, and an integer k.

    + +

    The matrix is composed of several layers, which is shown in the below image, where each color is its own layer:

    + +

    + +

    A cyclic rotation of the matrix is done by cyclically rotating each layer in the matrix. To cyclically rotate a layer once, each element in the layer will take the place of the adjacent element in the counter-clockwise direction. An example rotation is shown below:

    + +

    Return the matrix after applying k cyclic rotations to it.

    + +

     

    +

    Example 1:

    + +
    +Input: grid = [[40,10],[30,20]], k = 1
    +Output: [[10,20],[40,30]]
    +Explanation: The figures above represent the grid at every state.
    +
    + +

    Example 2:

    + + +
    +Input: grid = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]], k = 2
    +Output: [[3,4,8,12],[2,11,10,16],[1,7,6,15],[5,9,13,14]]
    +Explanation: The figures above represent the grid at every state.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 2 <= m, n <= 50
    • +
    • Both m and n are even integers.
    • +
    • 1 <= grid[i][j] <= 5000
    • +
    • 1 <= k <= 109
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +First, you need to consider each layer separately as an array. +
    + +
    +Hint 2 +Just cycle this array and then re-assign it. +
    diff --git a/problems/daily-leads-and-partners/README.md b/problems/daily-leads-and-partners/README.md index d8ce6f166..68f708978 100644 --- a/problems/daily-leads-and-partners/README.md +++ b/problems/daily-leads-and-partners/README.md @@ -12,3 +12,6 @@ ## [1693. Daily Leads and Partners (Easy)](https://leetcode.com/problems/daily-leads-and-partners "每天的领导和合伙人") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/daily-temperatures/README.md b/problems/daily-temperatures/README.md index ad6eba77e..a4c1b1ee8 100644 --- a/problems/daily-temperatures/README.md +++ b/problems/daily-temperatures/README.md @@ -34,7 +34,8 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] + [[Array](../../tag/array/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Similar Questions 1. [Next Greater Element I](../next-greater-element-i) (Easy) diff --git a/problems/data-stream-as-disjoint-intervals/README.md b/problems/data-stream-as-disjoint-intervals/README.md index 85bd84e16..13b5b4ef5 100644 --- a/problems/data-stream-as-disjoint-intervals/README.md +++ b/problems/data-stream-as-disjoint-intervals/README.md @@ -57,8 +57,9 @@ summaryRanges.getIntervals(); // return [[1, 3], [6, 7]]

    Follow up: What if there are lots of merges and the number of disjoint intervals is small compared to the size of the data stream?

    ### Related Topics + [[Design](../../tag/design/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Ordered Map](../../tag/ordered-map/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions 1. [Summary Ranges](../summary-ranges) (Easy) diff --git a/problems/day-of-the-week/README.md b/problems/day-of-the-week/README.md index c4ce778b3..f582f978c 100644 --- a/problems/day-of-the-week/README.md +++ b/problems/day-of-the-week/README.md @@ -47,7 +47,7 @@ ### Related Topics - [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/day-of-the-year/README.md b/problems/day-of-the-year/README.md index 170b733a6..3f08074a0 100644 --- a/problems/day-of-the-year/README.md +++ b/problems/day-of-the-year/README.md @@ -54,6 +54,7 @@ ### Related Topics [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/decode-string/README.md b/problems/decode-string/README.md index b791ba287..340d924ee 100644 --- a/problems/decode-string/README.md +++ b/problems/decode-string/README.md @@ -45,7 +45,8 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Encode String with Shortest Length](../encode-string-with-shortest-length) (Hard) diff --git a/problems/decode-ways-ii/README.md b/problems/decode-ways-ii/README.md index 01d69c8a7..c3b4ad0c9 100644 --- a/problems/decode-ways-ii/README.md +++ b/problems/decode-ways-ii/README.md @@ -75,6 +75,7 @@ Hence, there are a total of (6 * 2) + (3 * 1) = 12 + 3 = 15 ways to decode " ### Related Topics + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/decode-xored-array/README.md b/problems/decode-xored-array/README.md index 92381b873..9a3191419 100644 --- a/problems/decode-xored-array/README.md +++ b/problems/decode-xored-array/README.md @@ -47,6 +47,7 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/decode-xored-permutation/README.md b/problems/decode-xored-permutation/README.md index ca6f80de0..acf817fd1 100644 --- a/problems/decode-xored-permutation/README.md +++ b/problems/decode-xored-permutation/README.md @@ -44,6 +44,7 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/decoded-string-at-index/README.md b/problems/decoded-string-at-index/README.md index de0ff896c..324f84689 100644 --- a/problems/decoded-string-at-index/README.md +++ b/problems/decoded-string-at-index/README.md @@ -70,3 +70,4 @@ The decoded string is "a" repeated 8301530446056247680 times. The 1st ### Related Topics [[Stack](../../tag/stack/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/decrease-elements-to-make-array-zigzag/README.md b/problems/decrease-elements-to-make-array-zigzag/README.md index a03fae69f..66c9ddb1e 100644 --- a/problems/decrease-elements-to-make-array-zigzag/README.md +++ b/problems/decrease-elements-to-make-array-zigzag/README.md @@ -47,6 +47,7 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] ### Hints diff --git a/problems/deepest-leaves-sum/README.md b/problems/deepest-leaves-sum/README.md index bd3d01c5a..91cae7c59 100644 --- a/problems/deepest-leaves-sum/README.md +++ b/problems/deepest-leaves-sum/README.md @@ -37,7 +37,9 @@ Given the root of a binary tree, return the sum of values of it ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/degree-of-an-array/README.md b/problems/degree-of-an-array/README.md index 33f6ab25b..691229adc 100644 --- a/problems/degree-of-an-array/README.md +++ b/problems/degree-of-an-array/README.md @@ -48,6 +48,7 @@ So [2,2,3,1,4,2] is the shortest subarray, therefore returning 6. ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions 1. [Maximum Subarray](../maximum-subarray) (Easy) diff --git a/problems/delete-and-earn/README.md b/problems/delete-and-earn/README.md index 6683d8300..a76cd1977 100644 --- a/problems/delete-and-earn/README.md +++ b/problems/delete-and-earn/README.md @@ -11,11 +11,13 @@ ## [740. Delete and Earn (Medium)](https://leetcode.com/problems/delete-and-earn "删除并获得点数") -

    Given an array nums of integers, you can perform operations on the array.

    +

    You are given an integer array nums. You want to maximize the number of points you get by performing the following operation any number of times:

    -

    In each operation, you pick any nums[i] and delete it to earn nums[i] points. After, you must delete every element equal to nums[i] - 1 or nums[i] + 1.

    +
      +
    • Pick any nums[i] and delete it to earn nums[i] points. Afterwards, you must delete every element equal to nums[i] - 1 and every element equal to nums[i] + 1.
    • +
    -

    You start with 0 points. Return the maximum number of points you can earn by applying such operations.

    +

    Return the maximum number of points you can earn by applying the above operation some number of times.

     

    Example 1:

    @@ -23,9 +25,10 @@
     Input: nums = [3,4,2]
     Output: 6
    -Explanation: Delete 4 to earn 4 points, consequently 3 is also deleted.
    -Then, delete 2 to earn 2 points.
    -6 total points are earned.
    +Explanation: You can perform the following operations:
    +- Delete 4 to earn 4 points. Consequently, 3 is also deleted. nums = [2].
    +- Delete 2 to earn 2 points. nums = [].
    +You earn a total of 6 points.
     

    Example 2:

    @@ -33,10 +36,11 @@ Then, delete 2 to earn 2 points.
     Input: nums = [2,2,3,3,3,4]
     Output: 9
    -Explanation: Delete 3 to earn 3 points, deleting both 2's and the 4.
    -Then, delete 3 again to earn 3 points, and 3 again to earn 3 points.
    -9 total points are earned.
    -
    +Explanation: You can perform the following operations: +- Delete a 3 to earn 3 points. All 2's and 4's are also deleted. nums = [3,3]. +- Delete a 3 again to earn 3 points. nums = [3]. +- Delete a 3 once more to earn 3 points. nums = []. +You earn a total of 9 points.

     

    Constraints:

    @@ -47,6 +51,8 @@ Then, delete 3 again to earn 3 points, and 3 again to earn 3 points. ### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/delete-columns-to-make-sorted-ii/README.md b/problems/delete-columns-to-make-sorted-ii/README.md index cb6976940..6ead9d1b4 100644 --- a/problems/delete-columns-to-make-sorted-ii/README.md +++ b/problems/delete-columns-to-make-sorted-ii/README.md @@ -62,3 +62,5 @@ i.e., it is NOT necessarily true that (strs[0][0] <= strs[0][1] <= ...) ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/delete-columns-to-make-sorted-iii/README.md b/problems/delete-columns-to-make-sorted-iii/README.md index 310256a9c..59d134d37 100644 --- a/problems/delete-columns-to-make-sorted-iii/README.md +++ b/problems/delete-columns-to-make-sorted-iii/README.md @@ -60,4 +60,6 @@ Note that strs[0] > strs[1] - the array strs is not necessarily in lexicograp ### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/delete-columns-to-make-sorted/README.md b/problems/delete-columns-to-make-sorted/README.md index 3e91311c1..4586eece7 100644 --- a/problems/delete-columns-to-make-sorted/README.md +++ b/problems/delete-columns-to-make-sorted/README.md @@ -72,4 +72,5 @@ All 3 columns are not sorted, so you will delete all 3. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/delete-duplicate-emails/README.md b/problems/delete-duplicate-emails/README.md index 43a4a9fda..b3669d52c 100644 --- a/problems/delete-duplicate-emails/README.md +++ b/problems/delete-duplicate-emails/README.md @@ -38,3 +38,6 @@ Id is the primary key column for this table.

    Note:

    Your output is the whole Person table after executing your sql. Use delete statement.

    + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/delete-leaves-with-a-given-value/README.md b/problems/delete-leaves-with-a-given-value/README.md index 12c7fb813..8367ef269 100644 --- a/problems/delete-leaves-with-a-given-value/README.md +++ b/problems/delete-leaves-with-a-given-value/README.md @@ -71,6 +71,10 @@ After removing, new nodes become leaf nodes with value (target = 2) (Picture in ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md b/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md index 2260751eb..e73b8b5f1 100644 --- a/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md +++ b/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md @@ -15,3 +15,9 @@ ### Related Topics [[Linked List](../../tag/linked-list/README.md)] + +### Hints +
    +Hint 1 +Traverse the Linked List, each time you need to delete the next n nodes connect the nodes previous deleting with the next node after deleting. +
    diff --git a/problems/delete-node-in-a-bst/README.md b/problems/delete-node-in-a-bst/README.md index 1b03a99e8..1bc5f32c5 100644 --- a/problems/delete-node-in-a-bst/README.md +++ b/problems/delete-node-in-a-bst/README.md @@ -62,6 +62,8 @@ Please notice that another valid answer is [5,2,6,null,4,null,7] and it's al ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Split BST](../split-bst) (Medium) diff --git a/problems/delete-nodes-and-return-forest/README.md b/problems/delete-nodes-and-return-forest/README.md index a75659640..9d7a41d13 100644 --- a/problems/delete-nodes-and-return-forest/README.md +++ b/problems/delete-nodes-and-return-forest/README.md @@ -44,4 +44,5 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/delete-operation-for-two-strings/README.md b/problems/delete-operation-for-two-strings/README.md index a10bb31c4..56fb975e9 100644 --- a/problems/delete-operation-for-two-strings/README.md +++ b/problems/delete-operation-for-two-strings/README.md @@ -41,6 +41,7 @@ ### Related Topics [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Edit Distance](../edit-distance) (Hard) diff --git a/problems/delete-tree-nodes/README.md b/problems/delete-tree-nodes/README.md index 010ab41e2..37f521961 100644 --- a/problems/delete-tree-nodes/README.md +++ b/problems/delete-tree-nodes/README.md @@ -11,41 +11,12 @@ ## [1273. Delete Tree Nodes (Medium)](https://leetcode.com/problems/delete-tree-nodes "删除树节点") -

    A tree rooted at node 0 is given as follows:

    -
      -
    • The number of nodes is nodes;
    • -
    • The value of the i-th node is value[i];
    • -
    • The parent of the i-th node is parent[i].
    • -
    - -

    Remove every subtree whose sum of values of nodes is zero.

    - -

    After doing so, return the number of nodes remaining in the tree.

    - -

     

    -

    Example 1:

    - -

    - -
    -Input: nodes = 7, parent = [-1,0,0,1,2,2,2], value = [1,-2,4,0,-2,-1,-1]
    -Output: 2
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= nodes <= 10^4
    • -
    • -10^5 <= value[i] <= 10^5
    • -
    • parent.length == nodes
    • -
    • parent[0] == -1 which indicates that 0 is the root.
    • -
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Hints
    diff --git a/problems/delivering-boxes-from-storage-to-ports/README.md b/problems/delivering-boxes-from-storage-to-ports/README.md index 7d8a1ba48..a47b58504 100644 --- a/problems/delivering-boxes-from-storage-to-ports/README.md +++ b/problems/delivering-boxes-from-storage-to-ports/README.md @@ -96,8 +96,11 @@ So the total number of trips is 2 + 2 + 2 + 2 + 3 + 3 = 14. ### Related Topics [[Segment Tree](../../tag/segment-tree/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] + [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/department-highest-salary/README.md b/problems/department-highest-salary/README.md index f96e6c0e6..69ef35b24 100644 --- a/problems/department-highest-salary/README.md +++ b/problems/department-highest-salary/README.md @@ -51,3 +51,6 @@

    Explanation:

    Max and Jim both have the highest salary in the IT department and Henry has the highest salary in the Sales department.

    + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/department-top-three-salaries/README.md b/problems/department-top-three-salaries/README.md index f6d885fe7..171d4fbb1 100644 --- a/problems/department-top-three-salaries/README.md +++ b/problems/department-top-three-salaries/README.md @@ -96,3 +96,6 @@ In the Sales department: - Henry earns the highest salary - Sam earns the second-highest salary - There is no third-highest salary as there are only two employees
    + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/depth-of-bst-given-insertion-order/README.md b/problems/depth-of-bst-given-insertion-order/README.md new file mode 100644 index 000000000..f7279a921 --- /dev/null +++ b/problems/depth-of-bst-given-insertion-order/README.md @@ -0,0 +1,31 @@ + + + + + + + +[< Previous](../find-a-peak-element-ii "Find a Peak Element II") +                 +[Next >](../largest-odd-number-in-string "Largest Odd Number in String") + +## [1902. Depth of BST Given Insertion Order (Medium)](https://leetcode.com/problems/depth-of-bst-given-insertion-order "") + + + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + +### Hints +
    +Hint 1 +There are at most 2 possible places where a new node can be inserted? +
    + +
    +Hint 2 +How can we keep track of the depth of each node? +
    diff --git a/problems/design-a-file-sharing-system/README.md b/problems/design-a-file-sharing-system/README.md index 4ef206913..f4f4e80f6 100644 --- a/problems/design-a-file-sharing-system/README.md +++ b/problems/design-a-file-sharing-system/README.md @@ -15,7 +15,9 @@ ### Related Topics [[Design](../../tag/design/README.md)] - [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/design-a-leaderboard/README.md b/problems/design-a-leaderboard/README.md index d00c749ae..ec31dc37d 100644 --- a/problems/design-a-leaderboard/README.md +++ b/problems/design-a-leaderboard/README.md @@ -11,54 +11,12 @@ ## [1244. Design A Leaderboard (Medium)](https://leetcode.com/problems/design-a-leaderboard "力扣排行榜") -

    Design a Leaderboard class, which has 3 functions:

    -
      -
    1. addScore(playerId, score): Update the leaderboard by adding score to the given player's score. If there is no player with such id in the leaderboard, add him to the leaderboard with the given score.
    2. -
    3. top(K): Return the score sum of the top K players.
    4. -
    5. reset(playerId): Reset the score of the player with the given id to 0. It is guaranteed that the player was added to the leaderboard before calling this function.
    6. -
    - -

    Initially, the leaderboard is empty.

    - -

     

    -

    Example 1:

    - -
    -Input: 
    -["Leaderboard","addScore","addScore","addScore","addScore","addScore","top","reset","reset","addScore","top"]
    -[[],[1,73],[2,56],[3,39],[4,51],[5,4],[1],[1],[2],[2,51],[3]]
    -Output: 
    -[null,null,null,null,null,null,73,null,null,null,141]
    -
    -Explanation: 
    -Leaderboard leaderboard = new Leaderboard ();
    -leaderboard.addScore(1,73);   // leaderboard = [[1,73]];
    -leaderboard.addScore(2,56);   // leaderboard = [[1,73],[2,56]];
    -leaderboard.addScore(3,39);   // leaderboard = [[1,73],[2,56],[3,39]];
    -leaderboard.addScore(4,51);   // leaderboard = [[1,73],[2,56],[3,39],[4,51]];
    -leaderboard.addScore(5,4);    // leaderboard = [[1,73],[2,56],[3,39],[4,51],[5,4]];
    -leaderboard.top(1);           // returns 73;
    -leaderboard.reset(1);         // leaderboard = [[2,56],[3,39],[4,51],[5,4]];
    -leaderboard.reset(2);         // leaderboard = [[3,39],[4,51],[5,4]];
    -leaderboard.addScore(2,51);   // leaderboard = [[2,51],[3,39],[4,51],[5,4]];
    -leaderboard.top(3);           // returns 141 = 51 + 51 + 39;
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= playerId, K <= 10000
    • -
    • It's guaranteed that K is less than or equal to the current number of players.
    • -
    • 1 <= score <= 100
    • -
    • There will be at most 1000 function calls.
    • -
    ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/design-a-stack-with-increment-operation/README.md b/problems/design-a-stack-with-increment-operation/README.md index 0328198d4..e12ffe054 100644 --- a/problems/design-a-stack-with-increment-operation/README.md +++ b/problems/design-a-stack-with-increment-operation/README.md @@ -61,6 +61,7 @@ customStack.pop(); // return -1 --> Stack is empty ### Related Topics [[Stack](../../tag/stack/README.md)] [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/design-add-and-search-words-data-structure/README.md b/problems/design-add-and-search-words-data-structure/README.md index 29acf55cb..a80b5d8e6 100644 --- a/problems/design-add-and-search-words-data-structure/README.md +++ b/problems/design-add-and-search-words-data-structure/README.md @@ -53,10 +53,10 @@ wordDictionary.search("b.."); // return True ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Design](../../tag/design/README.md)] [[Trie](../../tag/trie/README.md)] - [[Backtracking](../../tag/backtracking/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Implement Trie (Prefix Tree)](../implement-trie-prefix-tree) (Medium) diff --git a/problems/design-an-expression-tree-with-evaluate-function/README.md b/problems/design-an-expression-tree-with-evaluate-function/README.md index 9a51695ea..64a08db2e 100644 --- a/problems/design-an-expression-tree-with-evaluate-function/README.md +++ b/problems/design-an-expression-tree-with-evaluate-function/README.md @@ -14,8 +14,11 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] [[Design](../../tag/design/README.md)] + [[Math](../../tag/math/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/design-an-ordered-stream/README.md b/problems/design-an-ordered-stream/README.md index b80e3bace..4b55be2b0 100644 --- a/problems/design-an-ordered-stream/README.md +++ b/problems/design-an-ordered-stream/README.md @@ -62,6 +62,8 @@ os.insert(4, "ddddd"); // Inserts (4, "ddddd"), returns [&qu ### Related Topics [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] ### Hints
    diff --git a/problems/design-bounded-blocking-queue/README.md b/problems/design-bounded-blocking-queue/README.md index 8c53985e3..95fa6abb3 100644 --- a/problems/design-bounded-blocking-queue/README.md +++ b/problems/design-bounded-blocking-queue/README.md @@ -11,77 +11,7 @@ ## [1188. Design Bounded Blocking Queue (Medium)](https://leetcode.com/problems/design-bounded-blocking-queue "设计有限阻塞队列") -

    Implement a thread safe bounded blocking queue that has the following methods:

    -
      -
    • BoundedBlockingQueue(int capacity) The constructor initializes the queue with a maximum capacity.
    • -
    • void enqueue(int element) Adds an element to the front of the queue. If the queue is full, the calling thread is blocked until the queue is no longer full.
    • -
    • int dequeue() Returns the element at the rear of the queue and removes it. If the queue is empty, the calling thread is blocked until the queue is no longer empty.
    • -
    • int size() Returns the number of elements currently in the queue.
    • -
    -

    Your implementation will be tested using multiple threads at the same time. Each thread will either be a producer thread that only makes calls to the enqueue method or a consumer thread that only makes calls to the dequeue method. The size method will be called after every test case.

    - -

    Please do not use built-in implementations of bounded blocking queue as this will not be accepted in an interview.

    - -

     

    - -

    Example 1:

    - -
    -Input:
    -1
    -1
    -["BoundedBlockingQueue","enqueue","dequeue","dequeue","enqueue","enqueue","enqueue","enqueue","dequeue"]
    -[[2],[1],[],[],[0],[2],[3],[4],[]]
    -
    -Output:
    -[1,0,2,2]
    -
    -Explanation:
    -Number of producer threads = 1
    -Number of consumer threads = 1
    -
    -BoundedBlockingQueue queue = new BoundedBlockingQueue(2);   // initialize the queue with capacity = 2.
    -
    -queue.enqueue(1);   // The producer thread enqueues 1 to the queue.
    -queue.dequeue();    // The consumer thread calls dequeue and returns 1 from the queue.
    -queue.dequeue();    // Since the queue is empty, the consumer thread is blocked.
    -queue.enqueue(0);   // The producer thread enqueues 0 to the queue. The consumer thread is unblocked and returns 0 from the queue.
    -queue.enqueue(2);   // The producer thread enqueues 2 to the queue.
    -queue.enqueue(3);   // The producer thread enqueues 3 to the queue.
    -queue.enqueue(4);   // The producer thread is blocked because the queue's capacity (2) is reached.
    -queue.dequeue();    // The consumer thread returns 2 from the queue. The producer thread is unblocked and enqueues 4 to the queue.
    -queue.size();       // 2 elements remaining in the queue. size() is always called at the end of each test case.
    -
    - -

     

    - -

    Example 2:

    - -
    -Input:
    -3
    -4
    -["BoundedBlockingQueue","enqueue","enqueue","enqueue","dequeue","dequeue","dequeue","enqueue"]
    -[[3],[1],[0],[2],[],[],[],[3]]
    -
    -Output:
    -[1,0,2,1]
    -
    -Explanation:
    -Number of producer threads = 3
    -Number of consumer threads = 4
    -
    -BoundedBlockingQueue queue = new BoundedBlockingQueue(3);   // initialize the queue with capacity = 3.
    -
    -queue.enqueue(1);   // Producer thread P1 enqueues 1 to the queue.
    -queue.enqueue(0);   // Producer thread P2 enqueues 0 to the queue.
    -queue.enqueue(2);   // Producer thread P3 enqueues 2 to the queue.
    -queue.dequeue();    // Consumer thread C1 calls dequeue.
    -queue.dequeue();    // Consumer thread C2 calls dequeue.
    -queue.dequeue();    // Consumer thread C3 calls dequeue.
    -queue.enqueue(3);   // One of the producer threads enqueues 3 to the queue.
    -queue.size();       // 1 element remaining in the queue.
    -
    -Since the number of threads for producer/consumer is greater than 1, we do not know how the threads will be scheduled in the operating system, even though the input seems to imply the ordering. Therefore, any of the output [1,0,2] or [1,2,0] or [0,1,2] or [0,2,1] or [2,0,1] or [2,1,0] will be accepted.
    +### Related Topics + [[Concurrency](../../tag/concurrency/README.md)] diff --git a/problems/design-browser-history/README.md b/problems/design-browser-history/README.md index da706143f..9a8ea0750 100644 --- a/problems/design-browser-history/README.md +++ b/problems/design-browser-history/README.md @@ -58,7 +58,12 @@ browserHistory.back(7); // You are in "google.com", ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] + [[Doubly-Linked List](../../tag/doubly-linked-list/README.md)] ### Hints
    diff --git a/problems/design-circular-deque/README.md b/problems/design-circular-deque/README.md index 82da33739..667c1883c 100644 --- a/problems/design-circular-deque/README.md +++ b/problems/design-circular-deque/README.md @@ -57,6 +57,8 @@ circularDeque.getFront(); // return 4 ### Related Topics [[Design](../../tag/design/README.md)] [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions 1. [Design Circular Queue](../design-circular-queue) (Medium) diff --git a/problems/design-circular-queue/README.md b/problems/design-circular-queue/README.md index 00d2500b7..06ee8a6a0 100644 --- a/problems/design-circular-queue/README.md +++ b/problems/design-circular-queue/README.md @@ -64,6 +64,8 @@ myCircularQueue.Rear(); // return 4 ### Related Topics [[Design](../../tag/design/README.md)] [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions 1. [Design Circular Deque](../design-circular-deque) (Medium) diff --git a/problems/design-compressed-string-iterator/README.md b/problems/design-compressed-string-iterator/README.md index 9d573923b..087f3818d 100644 --- a/problems/design-compressed-string-iterator/README.md +++ b/problems/design-compressed-string-iterator/README.md @@ -11,45 +11,14 @@ ## [604. Design Compressed String Iterator (Easy)](https://leetcode.com/problems/design-compressed-string-iterator "迭代压缩字符串") -

    -Design and implement a data structure for a compressed string iterator. It should support the following operations: next and hasNext. -

    -

    -The given compressed string will be in the form of each letter followed by a positive integer representing the number of this letter existing in the original uncompressed string. -

    - -

    -next() - if the original string still has uncompressed characters, return the next letter; Otherwise return a white space.
    -hasNext() - Judge whether there is any letter needs to be uncompressed. -

    - -

    -Note:
    -Please remember to RESET your class variables declared in StringIterator, as static/class variables are persisted across multiple test cases. Please see here for more details. -

    - - -

    Example: -

    -StringIterator iterator = new StringIterator("L1e2t1C1o1d1e1");
    -
    -iterator.next(); // return 'L'
    -iterator.next(); // return 'e'
    -iterator.next(); // return 'e'
    -iterator.next(); // return 't'
    -iterator.next(); // return 'C'
    -iterator.next(); // return 'o'
    -iterator.next(); // return 'd'
    -iterator.hasNext(); // return true
    -iterator.next(); // return 'e'
    -iterator.hasNext(); // return false
    -iterator.next(); // return ' '
    -
    -

    ### Related Topics [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Iterator](../../tag/iterator/README.md)] ### Similar Questions 1. [LRU Cache](../lru-cache) (Medium) diff --git a/problems/design-excel-sum-formula/README.md b/problems/design-excel-sum-formula/README.md index e307a1d0a..0cd3ef4a3 100644 --- a/problems/design-excel-sum-formula/README.md +++ b/problems/design-excel-sum-formula/README.md @@ -11,63 +11,9 @@ ## [631. Design Excel Sum Formula (Hard)](https://leetcode.com/problems/design-excel-sum-formula "设计 Excel 求和公式") -

    Your task is to design the basic function of Excel and implement the function of sum formula. Specifically, you need to implement the following functions:

    - -

    Excel(int H, char W): This is the constructor. The inputs represents the height and width of the Excel form. H is a positive integer, range from 1 to 26. It represents the height. W is a character range from 'A' to 'Z'. It represents that the width is the number of characters from 'A' to W. The Excel form content is represented by a height * width 2D integer array C, it should be initialized to zero. You should assume that the first row of C starts from 1, and the first column of C starts from 'A'.

    - -
    - -

    void Set(int row, char column, int val): Change the value at C(row, column) to be val.

    -
    -

    int Get(int row, char column): Return the value at C(row, column).

    -
    -

    int Sum(int row, char column, List of Strings : numbers): This function calculate and set the value at C(row, column), where the value should be the sum of cells represented by numbers. This function return the sum result at C(row, column). This sum formula should exist until this cell is overlapped by another value or another sum formula.

    - -

    numbers is a list of strings that each string represent a cell or a range of cells. If the string represent a single cell, then it has the following format : ColRow. For example, "F7" represents the cell at (7, F).

    - -

    If the string represent a range of cells, then it has the following format : ColRow1:ColRow2. The range will always be a rectangle, and ColRow1 represent the position of the top-left cell, and ColRow2 represents the position of the bottom-right cell.

    -
    -

    Example 1:
    -

    -Excel(3,"C"); 
    -// construct a 3*3 2D array with all zero.
    -//   A B C
    -// 1 0 0 0
    -// 2 0 0 0
    -// 3 0 0 0
    -
    -Set(1, "A", 2);
    -// set C(1,"A") to be 2.
    -//   A B C
    -// 1 2 0 0
    -// 2 0 0 0
    -// 3 0 0 0
    -
    -Sum(3, "C", ["A1", "A1:B2"]);
    -// set C(3,"C") to be the sum of value at C(1,"A") and the values sum of the rectangle range whose top-left cell is C(1,"A") and bottom-right cell is C(2,"B"). Return 4. 
    -//   A B C
    -// 1 2 0 0
    -// 2 0 0 0
    -// 3 0 0 4
    -
    -Set(2, "B", 2);
    -// set C(2,"B") to be 2. Note C(3, "C") should also be changed.
    -//   A B C
    -// 1 2 0 0
    -// 2 0 2 0
    -// 3 0 0 6
    -
    -

    - -

    Note:
    -

      -
    1. You could assume that there won't be any circular sum reference. For example, A1 = sum(B1) and B1 = sum(A1).
    2. -
    3. The test cases are using double-quotes to represent a character.
    4. -
    5. Please remember to RESET your class variables declared in class Excel, as static/class variables are persisted across multiple test cases. Please see here for more details.
    6. -
    -

    - ### Related Topics + [[Graph](../../tag/graph/README.md)] [[Design](../../tag/design/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] diff --git a/problems/design-file-system/README.md b/problems/design-file-system/README.md index 7f00a7862..768154b01 100644 --- a/problems/design-file-system/README.md +++ b/problems/design-file-system/README.md @@ -11,67 +11,13 @@ ## [1166. Design File System (Medium)](https://leetcode.com/problems/design-file-system "设计文件系统") -

    You are asked to design a file system which provides two functions:

    -
      -
    • createPath(path, value): Creates a new path and associates a value to it if possible and returns True. Returns False if the path already exists or its parent path doesn't exist.
    • -
    • get(path): Returns the value associated with a path or returns -1 if the path doesn't exist.
    • -
    - -

    The format of a path is one or more concatenated strings of the form: / followed by one or more lowercase English letters. For example, /leetcode and /leetcode/problems are valid paths while an empty string and / are not.

    - -

    Implement the two functions.

    - -

    Please refer to the examples for clarifications.

    - -

     

    -

    Example 1:

    - -
    -Input: 
    -["FileSystem","createPath","get"]
    -[[],["/a",1],["/a"]]
    -Output: 
    -[null,true,1]
    -Explanation: 
    -FileSystem fileSystem = new FileSystem();
    -
    -fileSystem.createPath("/a", 1); // return true
    -fileSystem.get("/a"); // return 1
    -
    - -

    Example 2:

    - -
    -Input: 
    -["FileSystem","createPath","createPath","get","createPath","get"]
    -[[],["/leet",1],["/leet/code",2],["/leet/code"],["/c/d",1],["/c"]]
    -Output: 
    -[null,true,true,2,false,-1]
    -Explanation: 
    -FileSystem fileSystem = new FileSystem();
    -
    -fileSystem.createPath("/leet", 1); // return true
    -fileSystem.createPath("/leet/code", 2); // return true
    -fileSystem.get("/leet/code"); // return 2
    -fileSystem.createPath("/c/d", 1); // return false because the parent path "/c" doesn't exist.
    -fileSystem.get("/c"); // return -1 because this path doesn't exist.
    -
    - -

     

    -

    Constraints:

    - -
      -
    • The number of calls to the two functions is less than or equal to 10^4 in total.
    • -
    • 2 <= path.length <= 100
    • -
    • 1 <= value <= 10^9
    • -
    - -

    NOTE: create method has been changed on August 29, 2019 to createPath. Please reset to default code definition to get new method signature.

    ### Related Topics [[Design](../../tag/design/README.md)] + [[Trie](../../tag/trie/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/design-front-middle-back-queue/README.md b/problems/design-front-middle-back-queue/README.md index de831172d..b3a498d9f 100644 --- a/problems/design-front-middle-back-queue/README.md +++ b/problems/design-front-middle-back-queue/README.md @@ -65,7 +65,10 @@ q.popFront(); // return -1 -> [] (The queue is empty) ### Related Topics [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] ### Hints
    diff --git a/problems/design-hashmap/README.md b/problems/design-hashmap/README.md index 249925e46..14ef975d5 100644 --- a/problems/design-hashmap/README.md +++ b/problems/design-hashmap/README.md @@ -54,7 +54,10 @@ myHashMap.get(2); // return -1 (i.e., not found), The map is now [[1,1]] ### Related Topics [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Similar Questions 1. [Design HashSet](../design-hashset) (Easy) diff --git a/problems/design-hashset/README.md b/problems/design-hashset/README.md index 33cc69073..bd2bd2926 100644 --- a/problems/design-hashset/README.md +++ b/problems/design-hashset/README.md @@ -52,7 +52,10 @@ myHashSet.contains(2); // return False, (already removed)
    ### Related Topics [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Similar Questions 1. [Design HashMap](../design-hashmap) (Easy) diff --git a/problems/design-hit-counter/README.md b/problems/design-hit-counter/README.md index d7eff4a9f..153d04bcb 100644 --- a/problems/design-hit-counter/README.md +++ b/problems/design-hit-counter/README.md @@ -11,44 +11,14 @@ ## [362. Design Hit Counter (Medium)](https://leetcode.com/problems/design-hit-counter "敲击计数器") -

    Design a hit counter which counts the number of hits received in the past 5 minutes.

    -

    Each function accepts a timestamp parameter (in seconds granularity) and you may assume that calls are being made to the system in chronological order (ie, the timestamp is monotonically increasing). You may assume that the earliest timestamp starts at 1.

    - -

    It is possible that several hits arrive roughly at the same time.

    - -

    Example:

    - -
    -HitCounter counter = new HitCounter();
    -
    -// hit at timestamp 1.
    -counter.hit(1);
    -
    -// hit at timestamp 2.
    -counter.hit(2);
    -
    -// hit at timestamp 3.
    -counter.hit(3);
    -
    -// get hits at timestamp 4, should return 3.
    -counter.getHits(4);
    -
    -// hit at timestamp 300.
    -counter.hit(300);
    -
    -// get hits at timestamp 300, should return 4.
    -counter.getHits(300);
    -
    -// get hits at timestamp 301, should return 3.
    -counter.getHits(301); 
    -
    - -

    Follow up:
    -What if the number of hits per second could be very large? Does your design scale?

    ### Related Topics [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions 1. [Logger Rate Limiter](../logger-rate-limiter) (Easy) diff --git a/problems/design-in-memory-file-system/README.md b/problems/design-in-memory-file-system/README.md index c9e5b7e6a..688dc21e7 100644 --- a/problems/design-in-memory-file-system/README.md +++ b/problems/design-in-memory-file-system/README.md @@ -11,43 +11,13 @@ ## [588. Design In-Memory File System (Hard)](https://leetcode.com/problems/design-in-memory-file-system "设计内存文件系统") -

    Design an in-memory file system to simulate the following functions:

    -

    ls: Given a path in string format. If it is a file path, return a list that only contains this file's name. If it is a directory path, return the list of file and directory names in this directory. Your output (file and directory names together) should in lexicographic order.

    - -

    mkdir: Given a directory path that does not exist, you should make a new directory according to the path. If the middle directories in the path don't exist either, you should create them as well. This function has void return type.

    - -

    addContentToFile: Given a file path and file content in string format. If the file doesn't exist, you need to create that file containing given content. If the file already exists, you need to append given content to original content. This function has void return type.

    - -

    readContentFromFile: Given a file path, return its content in string format.

    - -

     

    - -

    Example:

    - -
    Input: 
    -["FileSystem","ls","mkdir","addContentToFile","ls","readContentFromFile"]
    -[[],["/"],["/a/b/c"],["/a/b/c/d","hello"],["/"],["/a/b/c/d"]]
    -
    -Output:
    -[null,[],null,null,["a"],"hello"]
    -
    -Explanation:
    -filesystem
    -
    - -

     

    - -

    Note:

    - -
      -
    1. You can assume all file or directory paths are absolute paths which begin with / and do not end with / except that the path is just "/".
    2. -
    3. You can assume that all operations will be passed valid parameters and users will not attempt to retrieve file content or list a directory or file that does not exist.
    4. -
    5. You can assume that all directory names and file names only contain lower-case letters, and same names won't exist in the same directory.
    6. -
    ### Related Topics [[Design](../../tag/design/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [LRU Cache](../lru-cache) (Medium) diff --git a/problems/design-log-storage-system/README.md b/problems/design-log-storage-system/README.md index 811050b29..973648e3f 100644 --- a/problems/design-log-storage-system/README.md +++ b/problems/design-log-storage-system/README.md @@ -11,35 +11,13 @@ ## [635. Design Log Storage System (Medium)](https://leetcode.com/problems/design-log-storage-system "设计日志存储系统") -

    You are given several logs that each log contains a unique id and timestamp. Timestamp is a string that has the following format: Year:Month:Day:Hour:Minute:Second, for example, 2017:01:01:23:59:59. All domains are zero-padded decimal numbers.

    -

    Design a log storage system to implement the following functions:

    - -

    void Put(int id, string timestamp): Given a log's unique id and timestamp, store the log in your storage system.

    -
    -

    int[] Retrieve(String start, String end, String granularity): Return the id of logs whose timestamps are within the range from start to end. Start and end all have the same format as timestamp. However, granularity means the time level for consideration. For example, start = "2017:01:01:23:59:59", end = "2017:01:02:23:59:59", granularity = "Day", it means that we need to find the logs within the range from Jan. 1st 2017 to Jan. 2nd 2017.

    - -

    Example 1:
    -

    -put(1, "2017:01:01:23:59:59");
    -put(2, "2017:01:01:22:59:59");
    -put(3, "2016:01:01:00:00:00");
    -retrieve("2016:01:01:01:01:01","2017:01:01:23:00:00","Year"); // return [1,2,3], because you need to return all logs within 2016 and 2017.
    -retrieve("2016:01:01:01:01:01","2017:01:01:23:00:00","Hour"); // return [1,2], because you need to return all logs start from 2016:01:01:01 to 2017:01:01:23, where log 3 is left outside the range.
    -
    -

    - -

    Note:
    -

      -
    1. There will be at most 300 operations of Put or Retrieve.
    2. -
    3. Year ranges from [2000,2017]. Hour ranges from [00,23].
    4. -
    5. Output for Retrieve has no order required.
    6. -
    -

    ### Related Topics [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions 1. [Design In-Memory File System](../design-in-memory-file-system) (Hard) diff --git a/problems/design-most-recently-used-queue/README.md b/problems/design-most-recently-used-queue/README.md index 636c3c229..8cd6c64aa 100644 --- a/problems/design-most-recently-used-queue/README.md +++ b/problems/design-most-recently-used-queue/README.md @@ -14,8 +14,11 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Hints
    diff --git a/problems/design-movie-rental-system/README.md b/problems/design-movie-rental-system/README.md new file mode 100644 index 000000000..bb43f98e6 --- /dev/null +++ b/problems/design-movie-rental-system/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../maximum-alternating-subsequence-sum "Maximum Alternating Subsequence Sum") +                 +[Next >](../maximum-product-difference-between-two-pairs "Maximum Product Difference Between Two Pairs") + +## [1912. Design Movie Rental System (Hard)](https://leetcode.com/problems/design-movie-rental-system "设计电影租借系统") + +

    You have a movie renting company consisting of n shops. You want to implement a renting system that supports searching for, booking, and returning movies. The system should also support generating a report of the currently rented movies.

    + +

    Each movie is given as a 2D integer array entries where entries[i] = [shopi, moviei, pricei] indicates that there is a copy of movie moviei at shop shopi with a rental price of pricei. Each shop carries at most one copy of a movie moviei.

    + +

    The system should support the following functions:

    + +
      +
    • Search: Finds the cheapest 5 shops that have an unrented copy of a given movie. The shops should be sorted by price in ascending order, and in case of a tie, the one with the smaller shopi should appear first. If there are less than 5 matching shops, then all of them should be returned. If no shop has an unrented copy, then an empty list should be returned.
    • +
    • Rent: Rents an unrented copy of a given movie from a given shop.
    • +
    • Drop: Drops off a previously rented copy of a given movie at a given shop.
    • +
    • Report: Returns the cheapest 5 rented movies (possibly of the same movie ID) as a 2D list res where res[j] = [shopj, moviej] describes that the jth cheapest rented movie moviej was rented from the shop shopj. The movies in res should be sorted by price in ascending order, and in case of a tie, the one with the smaller shopj should appear first, and if there is still tie, the one with the smaller moviej should appear first. If there are fewer than 5 rented movies, then all of them should be returned. If no movies are currently being rented, then an empty list should be returned.
    • +
    + +

    Implement the MovieRentingSystem class:

    + +
      +
    • MovieRentingSystem(int n, int[][] entries) Initializes the MovieRentingSystem object with n shops and the movies in entries.
    • +
    • List<Integer> search(int movie) Returns a list of shops that have an unrented copy of the given movie as described above.
    • +
    • void rent(int shop, int movie) Rents the given movie from the given shop.
    • +
    • void drop(int shop, int movie) Drops off a previously rented movie at the given shop.
    • +
    • List<List<Integer>> report() Returns a list of cheapest rented movies as described above.
    • +
    + +

    Note: The test cases will be generated such that rent will only be called if the shop has an unrented copy of the movie, and drop will only be called if the shop had previously rented out the movie.

    + +

     

    +

    Example 1:

    + +
    +Input
    +["MovieRentingSystem", "search", "rent", "rent", "report", "drop", "search"]
    +[[3, [[0, 1, 5], [0, 2, 6], [0, 3, 7], [1, 1, 4], [1, 2, 7], [2, 1, 5]]], [1], [0, 1], [1, 2], [], [1, 2], [2]]
    +Output
    +[null, [1, 0, 2], null, null, [[0, 1], [1, 2]], null, [0, 1]]
    +
    +Explanation
    +MovieRentingSystem movieRentingSystem = new MovieRentingSystem(3, [[0, 1, 5], [0, 2, 6], [0, 3, 7], [1, 1, 4], [1, 2, 7], [2, 1, 5]]);
    +movieRentingSystem.search(1);  // return [1, 0, 2], Movies of ID 1 are unrented at shops 1, 0, and 2. Shop 1 is cheapest; shop 0 and 2 are the same price, so order by shop number.
    +movieRentingSystem.rent(0, 1); // Rent movie 1 from shop 0. Unrented movies at shop 0 are now [2,3].
    +movieRentingSystem.rent(1, 2); // Rent movie 2 from shop 1. Unrented movies at shop 1 are now [1].
    +movieRentingSystem.report();   // return [[0, 1], [1, 2]]. Movie 1 from shop 0 is cheapest, followed by movie 2 from shop 1.
    +movieRentingSystem.drop(1, 2); // Drop off movie 2 at shop 1. Unrented movies at shop 1 are now [1,2].
    +movieRentingSystem.search(2);  // return [0, 1]. Movies of ID 2 are unrented at shops 0 and 1. Shop 0 is cheapest, followed by shop 1.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 3 * 105
    • +
    • 1 <= entries.length <= 105
    • +
    • 0 <= shopi < n
    • +
    • 1 <= moviei, pricei <= 104
    • +
    • Each shop carries at most one copy of a movie moviei.
    • +
    • At most 105 calls in total will be made to search, rent, drop and report.
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +You need to maintain a sorted list for each movie and a sorted list for rented movies +
    + +
    +Hint 2 +When renting a movie remove it from its movies sorted list and added it to the rented list and vice versa in the case of dropping a movie +
    diff --git a/problems/design-parking-system/README.md b/problems/design-parking-system/README.md index 79b48982d..ae59f5976 100644 --- a/problems/design-parking-system/README.md +++ b/problems/design-parking-system/README.md @@ -49,6 +49,8 @@ parkingSystem.addCar(1); // return false because there is no available slot for ### Related Topics [[Design](../../tag/design/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/design-phone-directory/README.md b/problems/design-phone-directory/README.md index 399850809..61e396728 100644 --- a/problems/design-phone-directory/README.md +++ b/problems/design-phone-directory/README.md @@ -11,44 +11,11 @@ ## [379. Design Phone Directory (Medium)](https://leetcode.com/problems/design-phone-directory "电话目录管理系统") -

    Design a Phone Directory which supports the following operations:

    -

    -

      -
    1. get: Provide a number which is not assigned to anyone.
    2. -
    3. check: Check if a number is available or not.
    4. -
    5. release: Recycle or release a number.
    6. -
    -

    - -

    Example: -

    -// Init a phone directory containing a total of 3 numbers: 0, 1, and 2.
    -PhoneDirectory directory = new PhoneDirectory(3);
    -
    -// It can return any available phone number. Here we assume it returns 0.
    -directory.get();
    -
    -// Assume it returns 1.
    -directory.get();
    -
    -// The number 2 is available, so return true.
    -directory.check(2);
    -
    -// It returns 2, the only number that is left.
    -directory.get();
    -
    -// The number 2 is no longer available, so return false.
    -directory.check(2);
    -
    -// Release number 2 back to the pool.
    -directory.release(2);
    -
    -// Number 2 is available again, return true.
    -directory.check(2);
    -
    -

    ### Related Topics [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/design-search-autocomplete-system/README.md b/problems/design-search-autocomplete-system/README.md index d15189b63..8b5640771 100644 --- a/problems/design-search-autocomplete-system/README.md +++ b/problems/design-search-autocomplete-system/README.md @@ -11,70 +11,13 @@ ## [642. Design Search Autocomplete System (Hard)](https://leetcode.com/problems/design-search-autocomplete-system "设计搜索自动补全系统") -

    Design a search autocomplete system for a search engine. Users may input a sentence (at least one word and end with a special character '#'). For each character they type except '#', you need to return the top 3 historical hot sentences that have prefix the same as the part of sentence already typed. Here are the specific rules:

    -
      -
    1. The hot degree for a sentence is defined as the number of times a user typed the exactly same sentence before.
    2. -
    3. The returned top 3 hot sentences should be sorted by hot degree (The first is the hottest one). If several sentences have the same degree of hot, you need to use ASCII-code order (smaller one appears first).
    4. -
    5. If less than 3 hot sentences exist, then just return as many as you can.
    6. -
    7. When the input is a special character, it means the sentence ends, and in this case, you need to return an empty list.
    8. -
    - -

    Your job is to implement the following functions:

    - -

    The constructor function:

    - -

    AutocompleteSystem(String[] sentences, int[] times): This is the constructor. The input is historical data. Sentences is a string array consists of previously typed sentences. Times is the corresponding times a sentence has been typed. Your system should record these historical data.

    - -

    Now, the user wants to input a new sentence. The following function will provide the next character the user types:

    - -

    List<String> input(char c): The input c is the next character typed by the user. The character will only be lower-case letters ('a' to 'z'), blank space (' ') or a special character ('#'). Also, the previously typed sentence should be recorded in your system. The output will be the top 3 historical hot sentences that have prefix the same as the part of sentence already typed.

    -  - -

    Example:
    -Operation: AutocompleteSystem(["i love you", "island","ironman", "i love leetcode"], [5,3,2,2])
    -The system have already tracked down the following sentences and their corresponding times:
    -"i love you" : 5 times
    -"island" : 3 times
    -"ironman" : 2 times
    -"i love leetcode" : 2 times
    -Now, the user begins another search:
    -
    -Operation: input('i')
    -Output: ["i love you", "island","i love leetcode"]
    -Explanation:
    -There are four sentences that have prefix "i". Among them, "ironman" and "i love leetcode" have same hot degree. Since ' ' has ASCII code 32 and 'r' has ASCII code 114, "i love leetcode" should be in front of "ironman". Also we only need to output top 3 hot sentences, so "ironman" will be ignored.
    -
    -Operation: input(' ')
    -Output: ["i love you","i love leetcode"]
    -Explanation:
    -There are only two sentences that have prefix "i ".
    -
    -Operation: input('a')
    -Output: []
    -Explanation:
    -There are no sentences that have prefix "i a".
    -
    -Operation: input('#')
    -Output: []
    -Explanation:
    -The user finished the input, the sentence "i a" should be saved as a historical sentence in system. And the following input will be counted as a new search.

    -  - -

    Note:

    - -
      -
    1. The input sentence will always start with a letter and end with '#', and only one blank space will exist between two words.
    2. -
    3. The number of complete sentences that to be searched won't exceed 100. The length of each sentence including those in the historical data won't exceed 100.
    4. -
    5. Please use double-quote instead of single-quote when you write test cases even for a character input.
    6. -
    7. Please remember to RESET your class variables declared in class AutocompleteSystem, as static/class variables are persisted across multiple test cases. Please see here for more details.
    8. -
    - -

     

    ### Related Topics [[Design](../../tag/design/README.md)] [[Trie](../../tag/trie/README.md)] + [[String](../../tag/string/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] ### Similar Questions 1. [Implement Trie (Prefix Tree)](../implement-trie-prefix-tree) (Medium) diff --git a/problems/design-skiplist/README.md b/problems/design-skiplist/README.md index dc479dc8d..44185a46f 100644 --- a/problems/design-skiplist/README.md +++ b/problems/design-skiplist/README.md @@ -11,53 +11,60 @@ ## [1206. Design Skiplist (Hard)](https://leetcode.com/problems/design-skiplist "设计跳表") -

    Design a Skiplist without using any built-in libraries.

    +

    Design a Skiplist without using any built-in libraries.

    -

    A Skiplist is a data structure that takes O(log(n)) time to add, erase and search. Comparing with treap and red-black tree which has the same function and performance, the code length of Skiplist can be comparatively short and the idea behind Skiplists are just simple linked lists.

    +

    A skiplist is a data structure that takes O(log(n)) time to add, erase and search. Comparing with treap and red-black tree which has the same function and performance, the code length of Skiplist can be comparatively short and the idea behind Skiplists is just simple linked lists.

    -

    For example: we have a Skiplist containing [30,40,50,60,70,90] and we want to add 80 and 45 into it. The Skiplist works this way:

    +

    For example, we have a Skiplist containing [30,40,50,60,70,90] and we want to add 80 and 45 into it. The Skiplist works this way:

    -


    +


    Artyom Kalinin [CC BY-SA 3.0], via Wikimedia Commons

    -

    You can see there are many layers in the Skiplist. Each layer is a sorted linked list. With the help of the top layers, add , erase and search can be faster than O(n). It can be proven that the average time complexity for each operation is O(log(n)) and space complexity is O(n).

    +

    You can see there are many layers in the Skiplist. Each layer is a sorted linked list. With the help of the top layers, add, erase and search can be faster than O(n). It can be proven that the average time complexity for each operation is O(log(n)) and space complexity is O(n).

    -

    To be specific, your design should include these functions:

    +

    See more about Skiplist: https://en.wikipedia.org/wiki/Skip_list

    + +

    Implement the Skiplist class:

      -
    • bool search(int target) : Return whether the target exists in the Skiplist or not.
    • -
    • void add(int num): Insert a value into the SkipList. 
    • -
    • bool erase(int num): Remove a value in the Skiplist. If num does not exist in the Skiplist, do nothing and return false. If there exists multiple num values, removing any one of them is fine.
    • +
    • Skiplist() Initializes the object of the skiplist.
    • +
    • bool search(int target) Returns true if the integer target exists in the Skiplist or false otherwise.
    • +
    • void add(int num) Inserts the value num into the SkipList.
    • +
    • bool erase(int num) Removes the value num from the Skiplist and returns true. If num does not exist in the Skiplist, do nothing and return false. If there exist multiple num values, removing any one of them is fine.
    -

    See more about Skiplist : https://en.wikipedia.org/wiki/Skip_list

    -

    Note that duplicates may exist in the Skiplist, your code needs to handle this situation.

     

    - -

    Example:

    +

    Example 1:

    -Skiplist skiplist = new Skiplist();
    +Input
    +["Skiplist", "add", "add", "add", "search", "add", "search", "erase", "erase", "search"]
    +[[], [1], [2], [3], [0], [4], [1], [0], [1], [1]]
    +Output
    +[null, null, null, null, false, null, true, false, true, false]
     
    +Explanation
    +Skiplist skiplist = new Skiplist();
     skiplist.add(1);
     skiplist.add(2);
     skiplist.add(3);
    -skiplist.search(0);   // return false.
    +skiplist.search(0); // return False
     skiplist.add(4);
    -skiplist.search(1);   // return true.
    -skiplist.erase(0);    // return false, 0 is not in skiplist.
    -skiplist.erase(1);    // return true.
    -skiplist.search(1);   // return false, 1 has already been erased.
    +skiplist.search(1); // return True +skiplist.erase(0); // return False, 0 is not in skiplist. +skiplist.erase(1); // return True +skiplist.search(1); // return False, 1 has already been erased.

     

    Constraints:

      -
    • 0 <= num, target <= 20000
    • -
    • At most 50000 calls will be made to search, add, and erase.
    • +
    • 0 <= num, target <= 2 * 104
    • +
    • At most 5 * 104 calls will be made to search, add, and erase.
    ### Related Topics [[Design](../../tag/design/README.md)] + [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/design-snake-game/README.md b/problems/design-snake-game/README.md index 521e549f0..46198163e 100644 --- a/problems/design-snake-game/README.md +++ b/problems/design-snake-game/README.md @@ -11,56 +11,10 @@ ## [353. Design Snake Game (Medium)](https://leetcode.com/problems/design-snake-game "贪吃蛇") -

    Design a Snake game that is played on a device with screen size = width x height. Play the game online if you are not familiar with the game.

    -

    The snake is initially positioned at the top left corner (0,0) with length = 1 unit.

    - -

    You are given a list of food's positions in row-column order. When a snake eats the food, its length and the game's score both increase by 1.

    - -

    Each food appears one by one on the screen. For example, the second food will not appear until the first food was eaten by the snake.

    - -

    When a food does appear on the screen, it is guaranteed that it will not appear on a block occupied by the snake.

    - -

    Example:

    - -
    -Given width = 3, height = 2, and food = [[1,2],[0,1]].
    -
    -Snake snake = new Snake(width, height, food);
    -
    -Initially the snake appears at position (0,0) and the food at (1,2).
    -
    -|S| | |
    -| | |F|
    -
    -snake.move("R"); -> Returns 0
    -
    -| |S| |
    -| | |F|
    -
    -snake.move("D"); -> Returns 0
    -
    -| | | |
    -| |S|F|
    -
    -snake.move("R"); -> Returns 1 (Snake eats the first food and right after that, the second food appears at (0,1) )
    -
    -| |F| |
    -| |S|S|
    -
    -snake.move("U"); -> Returns 1
    -
    -| |F|S|
    -| | |S|
    -
    -snake.move("L"); -> Returns 2 (Snake eats the second food)
    -
    -| |S|S|
    -| | |S|
    -
    -snake.move("U"); -> Returns -1 (Game over because snake collides with border)
    -
    ### Related Topics [[Design](../../tag/design/README.md)] [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/design-tic-tac-toe/README.md b/problems/design-tic-tac-toe/README.md index 7d822d9fb..1a423fa56 100644 --- a/problems/design-tic-tac-toe/README.md +++ b/problems/design-tic-tac-toe/README.md @@ -11,66 +11,13 @@ ## [348. Design Tic-Tac-Toe (Medium)](https://leetcode.com/problems/design-tic-tac-toe "设计井字棋") -

    Design a Tic-tac-toe game that is played between two players on a n x n grid. -

    -

    You may assume the following rules: -

      -
    1. A move is guaranteed to be valid and is placed on an empty block.
    2. -
    3. Once a winning condition is reached, no more moves is allowed.
    4. -
    5. A player who succeeds in placing n of their marks in a horizontal, vertical, or diagonal row wins the game.
    6. -
    -

    - -

    Example:
    -

    -Given n = 3, assume that player 1 is "X" and player 2 is "O" in the board.
    -
    -TicTacToe toe = new TicTacToe(3);
    -
    -toe.move(0, 0, 1); -> Returns 0 (no one wins)
    -|X| | |
    -| | | |    // Player 1 makes a move at (0, 0).
    -| | | |
    -
    -toe.move(0, 2, 2); -> Returns 0 (no one wins)
    -|X| |O|
    -| | | |    // Player 2 makes a move at (0, 2).
    -| | | |
    -
    -toe.move(2, 2, 1); -> Returns 0 (no one wins)
    -|X| |O|
    -| | | |    // Player 1 makes a move at (2, 2).
    -| | |X|
    -
    -toe.move(1, 1, 2); -> Returns 0 (no one wins)
    -|X| |O|
    -| |O| |    // Player 2 makes a move at (1, 1).
    -| | |X|
    -
    -toe.move(2, 0, 1); -> Returns 0 (no one wins)
    -|X| |O|
    -| |O| |    // Player 1 makes a move at (2, 0).
    -|X| |X|
    -
    -toe.move(1, 0, 2); -> Returns 0 (no one wins)
    -|X| |O|
    -|O|O| |    // Player 2 makes a move at (1, 0).
    -|X| |X|
    -
    -toe.move(2, 1, 1); -> Returns 1 (player 1 wins)
    -|X| |O|
    -|O|O| |    // Player 1 makes a move at (2, 1).
    -|X|X|X|
    -
    -

    - -

    Follow up:
    -Could you do better than O(n2) per move() operation? -

    ### Related Topics [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Valid Tic-Tac-Toe State](../valid-tic-tac-toe-state) (Medium) diff --git a/problems/design-twitter/README.md b/problems/design-twitter/README.md index 61390d7bd..3a8f47caf 100644 --- a/problems/design-twitter/README.md +++ b/problems/design-twitter/README.md @@ -55,6 +55,7 @@ twitter.getNewsFeed(1); // User 1's news feed should return a list with 1 t ### Related Topics - [[Heap](../../tag/heap/README.md)] [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/design-underground-system/README.md b/problems/design-underground-system/README.md index 0528d7977..ad50b7a3d 100644 --- a/problems/design-underground-system/README.md +++ b/problems/design-underground-system/README.md @@ -102,6 +102,8 @@ undergroundSystem.getAverageTime("Leyton", "Paradise"); // r ### Related Topics [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/destination-city/README.md b/problems/destination-city/README.md index b49bec8e3..9bf4e8971 100644 --- a/problems/destination-city/README.md +++ b/problems/destination-city/README.md @@ -56,6 +56,7 @@ Clearly the destination city is "A". ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/detect-cycles-in-2d-grid/README.md b/problems/detect-cycles-in-2d-grid/README.md index 10af34343..f8e3b6169 100644 --- a/problems/detect-cycles-in-2d-grid/README.md +++ b/problems/detect-cycles-in-2d-grid/README.md @@ -63,7 +63,11 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md b/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md index 16d50f6f0..012a4246e 100644 --- a/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md +++ b/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md @@ -70,6 +70,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] ### Hints
    diff --git a/problems/determine-color-of-a-chessboard-square/README.md b/problems/determine-color-of-a-chessboard-square/README.md index ab5909b0c..dfe83e935 100644 --- a/problems/determine-color-of-a-chessboard-square/README.md +++ b/problems/determine-color-of-a-chessboard-square/README.md @@ -53,6 +53,7 @@ ### Related Topics + [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/determine-if-string-halves-are-alike/README.md b/problems/determine-if-string-halves-are-alike/README.md index 52fddc049..c087e409a 100644 --- a/problems/determine-if-string-halves-are-alike/README.md +++ b/problems/determine-if-string-halves-are-alike/README.md @@ -60,6 +60,7 @@ Notice that the vowel o is counted twice. ### Related Topics [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/determine-if-two-strings-are-close/README.md b/problems/determine-if-two-strings-are-close/README.md index 88f533583..05e1a68f6 100644 --- a/problems/determine-if-two-strings-are-close/README.md +++ b/problems/determine-if-two-strings-are-close/README.md @@ -77,7 +77,9 @@ Apply Operation 2: "baaccc" -> "abbccc" ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md b/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md new file mode 100644 index 000000000..552837e15 --- /dev/null +++ b/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md @@ -0,0 +1,64 @@ + + + + + + + +[< Previous](../count-pairs-in-two-arrays "Count Pairs in Two Arrays") +                 +[Next >](../reduction-operations-to-make-the-array-elements-equal "Reduction Operations to Make the Array Elements Equal") + +## [1886. Determine Whether Matrix Can Be Obtained By Rotation (Easy)](https://leetcode.com/problems/determine-whether-matrix-can-be-obtained-by-rotation "判断矩阵经轮转后是否一致") + +

    Given two n x n binary matrices mat and target, return true if it is possible to make mat equal to target by rotating mat in 90-degree increments, or false otherwise.

    + +

     

    +

    Example 1:

    + +
    +Input: mat = [[0,1],[1,0]], target = [[1,0],[0,1]]
    +Output: true
    +Explanation: We can rotate mat 90 degrees clockwise to make mat equal target.
    +
    + +

    Example 2:

    + +
    +Input: mat = [[0,1],[1,1]], target = [[1,0],[0,1]]
    +Output: false
    +Explanation: It is impossible to make mat equal to target by rotating mat.
    +
    + +

    Example 3:

    + +
    +Input: mat = [[0,0,0],[0,1,0],[1,1,1]], target = [[1,1,1],[0,1,0],[0,0,0]]
    +Output: true
    +Explanation: We can rotate mat 90 degrees clockwise two times to make mat equal target.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == mat.length == target.length
    • +
    • n == mat[i].length == target[i].length
    • +
    • 1 <= n <= 10
    • +
    • mat[i][j] and target[i][j] are either 0 or 1.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +What is the maximum number of rotations you have to check? +
    + +
    +Hint 2 +Is there a formula you can use to rotate a matrix 90 degrees? +
    diff --git a/problems/di-string-match/README.md b/problems/di-string-match/README.md index ccaa97583..178ccec19 100644 --- a/problems/di-string-match/README.md +++ b/problems/di-string-match/README.md @@ -40,4 +40,8 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/diagonal-traverse-ii/README.md b/problems/diagonal-traverse-ii/README.md index 74b730804..e05a840e1 100644 --- a/problems/diagonal-traverse-ii/README.md +++ b/problems/diagonal-traverse-ii/README.md @@ -56,8 +56,9 @@ Given a list of lists of integers, nums, return all eleme ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/diagonal-traverse/README.md b/problems/diagonal-traverse/README.md index a0053caa0..47dfd76a5 100644 --- a/problems/diagonal-traverse/README.md +++ b/problems/diagonal-traverse/README.md @@ -38,3 +38,8 @@
  • 1 <= m * n <= 104
  • -105 <= mat[i][j] <= 105
  • + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/diameter-of-binary-tree/README.md b/problems/diameter-of-binary-tree/README.md index d4bbeb038..751c76f4b 100644 --- a/problems/diameter-of-binary-tree/README.md +++ b/problems/diameter-of-binary-tree/README.md @@ -43,3 +43,5 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/diameter-of-n-ary-tree/README.md b/problems/diameter-of-n-ary-tree/README.md index eb5b75419..71983e003 100644 --- a/problems/diameter-of-n-ary-tree/README.md +++ b/problems/diameter-of-n-ary-tree/README.md @@ -13,6 +13,10 @@ +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + ### Hints
    Hint 1 diff --git a/problems/dice-roll-simulation/README.md b/problems/dice-roll-simulation/README.md index f85ae8d84..ccafc484f 100644 --- a/problems/dice-roll-simulation/README.md +++ b/problems/dice-roll-simulation/README.md @@ -9,7 +9,7 @@                  [Next >](../maximum-equal-frequency "Maximum Equal Frequency") -## [1223. Dice Roll Simulation (Medium)](https://leetcode.com/problems/dice-roll-simulation "掷骰子模拟") +## [1223. Dice Roll Simulation (Hard)](https://leetcode.com/problems/dice-roll-simulation "掷骰子模拟")

    A die simulator generates a random number from 1 to 6 for each roll. You introduced a constraint to the generator such that it cannot roll the number i more than rollMax[i] (1-indexed) consecutive times. 

    @@ -50,6 +50,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/diet-plan-performance/README.md b/problems/diet-plan-performance/README.md index e13b90c53..78b3c6ba0 100644 --- a/problems/diet-plan-performance/README.md +++ b/problems/diet-plan-performance/README.md @@ -11,50 +11,7 @@ ## [1176. Diet Plan Performance (Easy)](https://leetcode.com/problems/diet-plan-performance "健身计划评估") -

    A dieter consumes calories[i] calories on the i-th day.  For every consecutive sequence of k days, they look at T, the total calories consumed during that sequence of k days:

    -
      -
    • If T < lower, they performed poorly on their diet and lose 1 point; 
    • -
    • If T > upper, they performed well on their diet and gain 1 point;
    • -
    • Otherwise, they performed normally and there is no change in points.
    • -
    - -

    Return the total number of points the dieter has after all calories.length days.

    - -

    Note that: The total points could be negative.

    - -

     

    -

    Example 1:

    - -
    -Input: calories = [1,2,3,4,5], k = 1, lower = 3, upper = 3
    -Output: 0
    -Explaination: calories[0], calories[1] < lower and calories[3], calories[4] > upper, total points = 0.
    - -

    Example 2:

    - -
    -Input: calories = [3,2], k = 2, lower = 0, upper = 1
    -Output: 1
    -Explaination: calories[0] + calories[1] > upper, total points = 1.
    -
    - -

    Example 3:

    - -
    -Input: calories = [6,5,0,0], k = 2, lower = 1, upper = 5
    -Output: 0
    -Explaination: calories[0] + calories[1] > upper, lower <= calories[1] + calories[2] <= upper, calories[2] + calories[3] < lower, total points = 0.
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= k <= calories.length <= 10^5
    • -
    • 0 <= calories[i] <= 20000
    • -
    • 0 <= lower <= upper
    • -
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/different-ways-to-add-parentheses/README.md b/problems/different-ways-to-add-parentheses/README.md index 2a66d7389..03c5d8952 100644 --- a/problems/different-ways-to-add-parentheses/README.md +++ b/problems/different-ways-to-add-parentheses/README.md @@ -46,7 +46,11 @@ ### Related Topics - [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Unique Binary Search Trees II](../unique-binary-search-trees-ii) (Medium) diff --git a/problems/digit-count-in-range/README.md b/problems/digit-count-in-range/README.md index 144467f1b..86079c016 100644 --- a/problems/digit-count-in-range/README.md +++ b/problems/digit-count-in-range/README.md @@ -11,37 +11,7 @@ ## [1067. Digit Count in Range (Hard)](https://leetcode.com/problems/digit-count-in-range "范围内的数字计数") -Given an integer d between 0 and 9, and two positive integers low and high as lower and upper bounds, respectively. Return the number of times that d occurs as a digit in all integers between low and high, including the bounds low and high. -

     

    -

    Example 1:

    - -
    -Input: d = 1, low = 1, high = 13
    -Output: 6
    -Explanation: 
    -The digit d=1 occurs 6 times in 1,10,11,12,13. Note that the digit d=1 occurs twice in the number 11.
    -
    - -
    -

    Example 2:

    - -
    -Input: d = 3, low = 100, high = 250
    -Output: 35
    -Explanation: 
    -The digit d=3 occurs 35 times in 103,113,123,130,131,...,238,239,243.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 0 <= d <= 9
    2. -
    3. 1 <= low <= high <= 2×10^8
    4. -
    -
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/dinner-plate-stacks/README.md b/problems/dinner-plate-stacks/README.md index 139745b76..538937cca 100644 --- a/problems/dinner-plate-stacks/README.md +++ b/problems/dinner-plate-stacks/README.md @@ -11,54 +11,55 @@ ## [1172. Dinner Plate Stacks (Hard)](https://leetcode.com/problems/dinner-plate-stacks "餐盘栈") -

    You have an infinite number of stacks arranged in a row and numbered (left to right) from 0, each of the stacks has the same maximum capacity.

    +

    You have an infinite number of stacks arranged in a row and numbered (left to right) from 0, each of the stacks has the same maximum capacity.

    Implement the DinnerPlates class:

      -
    • DinnerPlates(int capacity) Initializes the object with the maximum capacity of the stacks.
    • -
    • void push(int val) Pushes the given positive integer val into the leftmost stack with size less than capacity.
    • -
    • int pop() Returns the value at the top of the rightmost non-empty stack and removes it from that stack, and returns -1 if all stacks are empty.
    • -
    • int popAtStack(int index) Returns the value at the top of the stack with the given index and removes it from that stack, and returns -1 if the stack with that given index is empty.
    • +
    • DinnerPlates(int capacity) Initializes the object with the maximum capacity of the stacks capacity.
    • +
    • void push(int val) Pushes the given integer val into the leftmost stack with a size less than capacity.
    • +
    • int pop() Returns the value at the top of the rightmost non-empty stack and removes it from that stack, and returns -1 if all the stacks are empty.
    • +
    • int popAtStack(int index) Returns the value at the top of the stack with the given index index and removes it from that stack or returns -1 if the stack with that given index is empty.
    -

    Example:

    +

     

    +

    Example 1:

    -Input: 
    -["DinnerPlates","push","push","push","push","push","popAtStack","push","push","popAtStack","popAtStack","pop","pop","pop","pop","pop"]
    -[[2],[1],[2],[3],[4],[5],[0],[20],[21],[0],[2],[],[],[],[],[]]
    -Output: 
    -[null,null,null,null,null,null,2,null,null,20,21,5,4,3,1,-1]
    +Input
    +["DinnerPlates", "push", "push", "push", "push", "push", "popAtStack", "push", "push", "popAtStack", "popAtStack", "pop", "pop", "pop", "pop", "pop"]
    +[[2], [1], [2], [3], [4], [5], [0], [20], [21], [0], [2], [], [], [], [], []]
    +Output
    +[null, null, null, null, null, null, 2, null, null, 20, 21, 5, 4, 3, 1, -1]
     
    -Explanation: 
    +Explanation: 
     DinnerPlates D = DinnerPlates(2);  // Initialize with capacity = 2
     D.push(1);
     D.push(2);
     D.push(3);
     D.push(4);
    -D.push(5);         // The stacks are now:  2  4
    -                                           1  3  5
    +D.push(5);         // The stacks are now:  2  4
    +                                           1  3  5
                                                ﹈ ﹈ ﹈
    -D.popAtStack(0);   // Returns 2.  The stacks are now:     4
    -                                                       1  3  5
    +D.popAtStack(0);   // Returns 2.  The stacks are now:     4
    +                                                       1  3  5
                                                            ﹈ ﹈ ﹈
     D.push(20);        // The stacks are now: 20  4
    -                                           1  3  5
    +                                           1  3  5
                                                ﹈ ﹈ ﹈
     D.push(21);        // The stacks are now: 20  4 21
    -                                           1  3  5
    +                                           1  3  5
                                                ﹈ ﹈ ﹈
     D.popAtStack(0);   // Returns 20.  The stacks are now:     4 21
    -                                                        1  3  5
    +                                                        1  3  5
                                                             ﹈ ﹈ ﹈
     D.popAtStack(2);   // Returns 21.  The stacks are now:     4
    -                                                        1  3  5
    +                                                        1  3  5
                                                             ﹈ ﹈ ﹈ 
     D.pop()            // Returns 5.  The stacks are now:      4
    -                                                        1  3 
    +                                                        1  3 
                                                             ﹈ ﹈  
    -D.pop()            // Returns 4.  The stacks are now:   1  3 
    +D.pop()            // Returns 4.  The stacks are now:   1  3 
                                                             ﹈ ﹈   
     D.pop()            // Returns 3.  The stacks are now:   1 
                                                             ﹈   
    @@ -70,14 +71,17 @@ D.pop()            // Returns -1.  There are still no stacks.
     

    Constraints:

      -
    • 1 <= capacity <= 20000
    • -
    • 1 <= val <= 20000
    • -
    • 0 <= index <= 100000
    • -
    • At most 200000 calls will be made to push, pop, and popAtStack.
    • +
    • 1 <= capacity <= 2 * 104
    • +
    • 1 <= val <= 2 * 104
    • +
    • 0 <= index <= 105
    • +
    • At most 2 * 105 calls will be made to push, pop, and popAtStack.
    ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/display-table-of-food-orders-in-a-restaurant/README.md b/problems/display-table-of-food-orders-in-a-restaurant/README.md index 31295dfe2..6ea038fe2 100644 --- a/problems/display-table-of-food-orders-in-a-restaurant/README.md +++ b/problems/display-table-of-food-orders-in-a-restaurant/README.md @@ -61,7 +61,11 @@ For the table 12: James, Ratesh and Amadeus order "Fried Chicken". ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/distant-barcodes/README.md b/problems/distant-barcodes/README.md index 18ae20f69..2915f6b4b 100644 --- a/problems/distant-barcodes/README.md +++ b/problems/distant-barcodes/README.md @@ -32,8 +32,12 @@ ### Related Topics - [[Heap](../../tag/heap/README.md)] - [[Sort](../../tag/sort/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/distinct-echo-substrings/README.md b/problems/distinct-echo-substrings/README.md index 2d3d3f53a..1bb6f7a33 100644 --- a/problems/distinct-echo-substrings/README.md +++ b/problems/distinct-echo-substrings/README.md @@ -39,7 +39,12 @@ ### Related Topics + [[Trie](../../tag/trie/README.md)] [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/distinct-numbers-in-each-subarray/README.md b/problems/distinct-numbers-in-each-subarray/README.md index 6b3c88185..a6e1ecaf6 100644 --- a/problems/distinct-numbers-in-each-subarray/README.md +++ b/problems/distinct-numbers-in-each-subarray/README.md @@ -9,14 +9,14 @@                  [Next >](../convert-date-format "Convert Date Format") -## [1852. Distinct Numbers in Each Subarray (Medium)](https://leetcode.com/problems/distinct-numbers-in-each-subarray "") +## [1852. Distinct Numbers in Each Subarray (Medium)](https://leetcode.com/problems/distinct-numbers-in-each-subarray "每个子数组的数字种类数") ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Line Sweep](../../tag/line-sweep/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/distinct-subsequences-ii/README.md b/problems/distinct-subsequences-ii/README.md index d04dc661a..1deced85a 100644 --- a/problems/distinct-subsequences-ii/README.md +++ b/problems/distinct-subsequences-ii/README.md @@ -65,4 +65,5 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/distribute-candies-to-people/README.md b/problems/distribute-candies-to-people/README.md index 7ee31f1d3..27495dffc 100644 --- a/problems/distribute-candies-to-people/README.md +++ b/problems/distribute-candies-to-people/README.md @@ -56,6 +56,7 @@ On the fourth turn, ans[0] += 4, and the final array is [5,2,3]. ### Related Topics [[Math](../../tag/math/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/distribute-candies/README.md b/problems/distribute-candies/README.md index e59aecc31..5d133bdfc 100644 --- a/problems/distribute-candies/README.md +++ b/problems/distribute-candies/README.md @@ -53,6 +53,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] ### Hints diff --git a/problems/distribute-coins-in-binary-tree/README.md b/problems/distribute-coins-in-binary-tree/README.md index 6035b24d6..82f360eb4 100644 --- a/problems/distribute-coins-in-binary-tree/README.md +++ b/problems/distribute-coins-in-binary-tree/README.md @@ -60,7 +60,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Sum of Distances in Tree](../sum-of-distances-in-tree) (Hard) diff --git a/problems/distribute-repeating-integers/README.md b/problems/distribute-repeating-integers/README.md index 497d9a6b3..0c1f43ecf 100644 --- a/problems/distribute-repeating-integers/README.md +++ b/problems/distribute-repeating-integers/README.md @@ -75,8 +75,11 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md b/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md index 1f1029eef..7872ac1cc 100644 --- a/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md +++ b/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md @@ -60,6 +60,8 @@ Return True if it is possible. Otherwise, return < ### Related Topics [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/divide-array-into-increasing-sequences/README.md b/problems/divide-array-into-increasing-sequences/README.md index b8e16c7d3..374547e12 100644 --- a/problems/divide-array-into-increasing-sequences/README.md +++ b/problems/divide-array-into-increasing-sequences/README.md @@ -11,40 +11,11 @@ ## [1121. Divide Array Into Increasing Sequences (Hard)](https://leetcode.com/problems/divide-array-into-increasing-sequences "将数组分成几个递增序列") -

    Given a non-decreasing array of positive integers nums and an integer K, find out if this array can be divided into one or more disjoint increasing subsequences of length at least K.

    -

     

    - -

    Example 1:

    - -
    -Input: nums = [1,2,2,3,3,4,4], K = 3
    -Output: true
    -Explanation: 
    -The array can be divided into the two subsequences [1,2,3,4] and [2,3,4] with lengths at least 3 each.
    -
    - -

    Example 2:

    - -
    -Input: nums = [5,6,6,7,8], K = 3
    -Output: false
    -Explanation: 
    -There is no way to divide the array using the conditions required.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= nums.length <= 10^5
    2. -
    3. 1 <= K <= nums.length
    4. -
    5. 1 <= nums[i] <= 10^5
    6. -
    ### Related Topics - [[Math](../../tag/math/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/divide-chocolate/README.md b/problems/divide-chocolate/README.md index b60367c17..4e6cb9423 100644 --- a/problems/divide-chocolate/README.md +++ b/problems/divide-chocolate/README.md @@ -11,49 +11,10 @@ ## [1231. Divide Chocolate (Hard)](https://leetcode.com/problems/divide-chocolate "分享巧克力") -

    You have one chocolate bar that consists of some chunks. Each chunk has its own sweetness given by the array sweetness.

    -

    You want to share the chocolate with your K friends so you start cutting the chocolate bar into K+1 pieces using K cuts, each piece consists of some consecutive chunks.

    - -

    Being generous, you will eat the piece with the minimum total sweetness and give the other pieces to your friends.

    - -

    Find the maximum total sweetness of the piece you can get by cutting the chocolate bar optimally.

    - -

     

    -

    Example 1:

    - -
    -Input: sweetness = [1,2,3,4,5,6,7,8,9], K = 5
    -Output: 6
    -Explanation: You can divide the chocolate to [1,2,3], [4,5], [6], [7], [8], [9]
    -
    - -

    Example 2:

    - -
    -Input: sweetness = [5,6,7,8,9,1,2,3,4], K = 8
    -Output: 1
    -Explanation: There is only one way to cut the bar into 9 pieces.
    -
    - -

    Example 3:

    - -
    -Input: sweetness = [1,2,2,1,2,2,1,2,2], K = 2
    -Output: 5
    -Explanation: You can divide the chocolate to [1,2,2], [1,2,2], [1,2,2]
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 0 <= K < sweetness.length <= 10^4
    • -
    • 1 <= sweetness[i] <= 10^5
    • -
    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] ### Hints diff --git a/problems/divide-two-integers/README.md b/problems/divide-two-integers/README.md index 590405578..54a10c62f 100644 --- a/problems/divide-two-integers/README.md +++ b/problems/divide-two-integers/README.md @@ -59,5 +59,5 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/divisor-game/README.md b/problems/divisor-game/README.md index 8a5248792..c6f148423 100644 --- a/problems/divisor-game/README.md +++ b/problems/divisor-game/README.md @@ -49,8 +49,10 @@ ### Related Topics + [[Brainteaser](../../tag/brainteaser/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] ### Hints
    diff --git a/problems/dot-product-of-two-sparse-vectors/README.md b/problems/dot-product-of-two-sparse-vectors/README.md index fcfcfec67..043048d51 100644 --- a/problems/dot-product-of-two-sparse-vectors/README.md +++ b/problems/dot-product-of-two-sparse-vectors/README.md @@ -14,6 +14,7 @@ ### Related Topics + [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/dota2-senate/README.md b/problems/dota2-senate/README.md index a5bf579de..b1c725bee 100644 --- a/problems/dota2-senate/README.md +++ b/problems/dota2-senate/README.md @@ -61,6 +61,8 @@ And in round 2, the third senator can just announce the victory since he is the ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Queue](../../tag/queue/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Teemo Attacking](../teemo-attacking) (Easy) diff --git a/problems/dungeon-game/README.md b/problems/dungeon-game/README.md index 59f3657da..a1ad87bb9 100644 --- a/problems/dungeon-game/README.md +++ b/problems/dungeon-game/README.md @@ -50,8 +50,9 @@ ### Related Topics - [[Binary Search](../../tag/binary-search/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Unique Paths](../unique-paths) (Medium) diff --git a/problems/duplicate-emails/README.md b/problems/duplicate-emails/README.md index 3b3247fdc..bae40f1a3 100644 --- a/problems/duplicate-emails/README.md +++ b/problems/duplicate-emails/README.md @@ -34,3 +34,6 @@

    Note: All emails are in lowercase.

    + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/duplicate-zeros/README.md b/problems/duplicate-zeros/README.md index 4799ee5dd..b905a4601 100644 --- a/problems/duplicate-zeros/README.md +++ b/problems/duplicate-zeros/README.md @@ -46,6 +46,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Hints
    diff --git a/problems/egg-drop-with-2-eggs-and-n-floors/README.md b/problems/egg-drop-with-2-eggs-and-n-floors/README.md new file mode 100644 index 000000000..9c72cf70b --- /dev/null +++ b/problems/egg-drop-with-2-eggs-and-n-floors/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../minimum-skips-to-arrive-at-meeting-on-time "Minimum Skips to Arrive at Meeting On Time") +                 +[Next >](../count-pairs-in-two-arrays "Count Pairs in Two Arrays") + +## [1884. Egg Drop With 2 Eggs and N Floors (Medium)](https://leetcode.com/problems/egg-drop-with-2-eggs-and-n-floors "鸡蛋掉落-两枚鸡蛋") + +

    You are given two identical eggs and you have access to a building with n floors labeled from 1 to n.

    + +

    You know that there exists a floor f where 0 <= f <= n such that any egg dropped at a floor higher than f will break, and any egg dropped at or below floor f will not break.

    + +

    In each move, you may take an unbroken egg and drop it from any floor x (where 1 <= x <= n). If the egg breaks, you can no longer use it. However, if the egg does not break, you may reuse it in future moves.

    + +

    Return the minimum number of moves that you need to determine with certainty what the value of f is.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 2
    +Output: 2
    +Explanation: We can drop the first egg from floor 1 and the second egg from floor 2.
    +If the first egg breaks, we know that f = 0.
    +If the second egg breaks but the first egg didn't, we know that f = 1.
    +Otherwise, if both eggs survive, we know that f = 2.
    +
    + +

    Example 2:

    + +
    +Input: n = 100
    +Output: 14
    +Explanation: One optimal strategy is:
    +- Drop the 1st egg at floor 9. If it breaks, we know f is between 0 and 8. Drop the 2nd egg starting
    +  from floor 1 and going up one at a time to find f within 7 more drops. Total drops is 1 + 7 = 8.
    +- If the 1st egg does not break, drop the 1st egg again at floor 22. If it breaks, we know f is between 9
    +  and 21. Drop the 2nd egg starting from floor 10 and going up one at a time to find f within 12 more
    +  drops. Total drops is 2 + 12 = 14.
    +- If the 1st egg does not break again, follow a similar process dropping the 1st egg from floors 34, 45,
    +  55, 64, 72, 79, 85, 90, 94, 97, 99, and 100.
    +Regardless of the outcome, it takes at most 14 drops to determine f.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 1000
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Is it really optimal to always drop the egg on the middle floor for each move? +
    + +
    +Hint 2 +Can we create states based on the number of unbroken eggs and floors to build our solution? +
    diff --git a/problems/eliminate-maximum-number-of-monsters/README.md b/problems/eliminate-maximum-number-of-monsters/README.md new file mode 100644 index 000000000..8f472dff7 --- /dev/null +++ b/problems/eliminate-maximum-number-of-monsters/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../build-array-from-permutation "Build Array from Permutation") +                 +[Next >](../count-good-numbers "Count Good Numbers") + +## [1921. Eliminate Maximum Number of Monsters (Medium)](https://leetcode.com/problems/eliminate-maximum-number-of-monsters "消灭怪物的最大数量") + +

    You are playing a video game where you are defending your city from a group of n monsters. You are given a 0-indexed integer array dist of size n, where dist[i] is the initial distance in meters of the ith monster from the city.

    + +

    The monsters walk toward the city at a constant speed. The speed of each monster is given to you in an integer array speed of size n, where speed[i] is the speed of the ith monster in meters per minute.

    + +

    The monsters start moving at minute 0. You have a weapon that you can choose to use at the start of every minute, including minute 0. You cannot use the weapon in the middle of a minute. The weapon can eliminate any monster that is still alive. You lose when any monster reaches your city. If a monster reaches the city exactly at the start of a minute, it counts as a loss, and the game ends before you can use your weapon in that minute.

    + +

    Return the maximum number of monsters that you can eliminate before you lose, or n if you can eliminate all the monsters before they reach the city.

    + +

     

    +

    Example 1:

    + +
    +Input: dist = [1,3,4], speed = [1,1,1]
    +Output: 3
    +Explanation:
    +At the start of minute 0, the distances of the monsters are [1,3,4], you eliminate the first monster.
    +At the start of minute 1, the distances of the monsters are [X,2,3], you don't do anything.
    +At the start of minute 2, the distances of the monsters are [X,1,2], you eliminate the second monster.
    +At the start of minute 3, the distances of the monsters are [X,X,1], you eliminate the third monster.
    +All 3 monsters can be eliminated.
    + +

    Example 2:

    + +
    +Input: dist = [1,1,2,3], speed = [1,1,1,1]
    +Output: 1
    +Explanation:
    +At the start of minute 0, the distances of the monsters are [1,1,2,3], you eliminate the first monster.
    +At the start of minute 1, the distances of the monsters are [X,0,1,2], so you lose.
    +You can only eliminate 1 monster.
    +
    + +

    Example 3:

    + +
    +Input: dist = [3,2,4], speed = [5,3,2]
    +Output: 1
    +Explanation:
    +At the start of minute 0, the distances of the monsters are [3,2,4], you eliminate the first monster.
    +At the start of minute 1, the distances of the monsters are [X,0,2], so you lose.
    +You can only eliminate 1 monster.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == dist.length == speed.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= dist[i], speed[i] <= 105
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Find the amount of time it takes each monster to arrive. +
    + +
    +Hint 2 +Find the order in which the monsters will arrive. +
    diff --git a/problems/elimination-game/README.md b/problems/elimination-game/README.md index 1b4599caf..276a8e60b 100644 --- a/problems/elimination-game/README.md +++ b/problems/elimination-game/README.md @@ -47,3 +47,6 @@ arr = [6]
    • 1 <= n <= 109
    + +### Related Topics + [[Math](../../tag/math/README.md)] diff --git a/problems/employee-bonus/README.md b/problems/employee-bonus/README.md index da6fb333b..9b43bb34f 100644 --- a/problems/employee-bonus/README.md +++ b/problems/employee-bonus/README.md @@ -11,45 +11,10 @@ ## [577. Employee Bonus (Easy)](https://leetcode.com/problems/employee-bonus "员工奖金") -

    Select all employee's name and bonus whose bonus is < 1000.

    -

    Table:Employee

    -
    -+-------+--------+-----------+--------+
    -| empId |  name  | supervisor| salary |
    -+-------+--------+-----------+--------+
    -|   1   | John   |  3        | 1000   |
    -|   2   | Dan    |  3        | 2000   |
    -|   3   | Brad   |  null     | 4000   |
    -|   4   | Thomas |  3        | 4000   |
    -+-------+--------+-----------+--------+
    -empId is the primary key column for this table.
    -
    - -

    Table: Bonus

    - -
    -+-------+-------+
    -| empId | bonus |
    -+-------+-------+
    -| 2     | 500   |
    -| 4     | 2000  |
    -+-------+-------+
    -empId is the primary key column for this table.
    -
    - -

    Example ouput:

    - -
    -+-------+-------+
    -| name  | bonus |
    -+-------+-------+
    -| John  | null  |
    -| Dan   | 500   |
    -| Brad  | null  |
    -+-------+-------+
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] ### Similar Questions 1. [Combine Two Tables](../combine-two-tables) (Easy) diff --git a/problems/employee-free-time/README.md b/problems/employee-free-time/README.md index 8cb019ef3..ef6c65a75 100644 --- a/problems/employee-free-time/README.md +++ b/problems/employee-free-time/README.md @@ -11,52 +11,12 @@ ## [759. Employee Free Time (Hard)](https://leetcode.com/problems/employee-free-time "员工空闲时间") -

    We are given a list schedule of employees, which represents the working time for each employee.

    -

    Each employee has a list of non-overlapping Intervals, and these intervals are in sorted order.

    - -

    Return the list of finite intervals representing common, positive-length free time for all employees, also in sorted order.

    - -

    Example 1:

    - -
    -Input: schedule = [[[1,2],[5,6]],[[1,3]],[[4,10]]]
    -Output: [[3,4]]
    -Explanation:
    -There are a total of three employees, and all common
    -free time intervals would be [-inf, 1], [3, 4], [10, inf].
    -We discard any intervals that contain inf as they aren't finite.
    -
    - -

     

    - -

    Example 2:

    - -
    -Input: schedule = [[[1,3],[6,7]],[[2,4]],[[2,5],[9,12]]]
    -Output: [[5,6],[7,9]]
    -
    - -

     

    - -

    (Even though we are representing Intervals in the form [x, y], the objects inside are Intervals, not lists or arrays. For example, schedule[0][0].start = 1, schedule[0][0].end = 2, and schedule[0][0][0] is not defined.)

    - -

    Also, we wouldn't include intervals like [5, 5] in our answer, as they have zero length.

    - -

    Note:

    - -
      -
    1. schedule and schedule[i] are lists with lengths in range [1, 50].
    2. -
    3. 0 <= schedule[i].start < schedule[i].end <= 10^8.
    4. -
    - -

    NOTE: input types have been changed on June 17, 2019. Please reset to default code definition to get new method signature.

    - -

     

    ### Related Topics - [[Heap](../../tag/heap/README.md)] - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Merge Intervals](../merge-intervals) (Medium) diff --git a/problems/employee-importance/README.md b/problems/employee-importance/README.md index be6955b53..36b679fd9 100644 --- a/problems/employee-importance/README.md +++ b/problems/employee-importance/README.md @@ -54,8 +54,8 @@ So the total importance value of employee 1 is 5 + 3 + 3 = 11. ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions diff --git a/problems/employees-earning-more-than-their-managers/README.md b/problems/employees-earning-more-than-their-managers/README.md index d775a4709..b6a723096 100644 --- a/problems/employees-earning-more-than-their-managers/README.md +++ b/problems/employees-earning-more-than-their-managers/README.md @@ -33,3 +33,6 @@ | Joe | +----------+
    + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/encode-and-decode-strings/README.md b/problems/encode-and-decode-strings/README.md index 336bfc67d..f66440f9d 100644 --- a/problems/encode-and-decode-strings/README.md +++ b/problems/encode-and-decode-strings/README.md @@ -11,51 +11,11 @@ ## [271. Encode and Decode Strings (Medium)](https://leetcode.com/problems/encode-and-decode-strings "字符串的编码与解码") -

    Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings.

    -

    Machine 1 (sender) has the function:

    - -
    -string encode(vector<string> strs) {
    -  // ... your code
    -  return encoded_string;
    -}
    -Machine 2 (receiver) has the function: - -
    -vector<string> decode(string s) {
    -  //... your code
    -  return strs;
    -}
    -
    - -

    So Machine 1 does:

    - -
    -string encoded_string = encode(strs);
    -
    - -

    and Machine 2 does:

    - -
    -vector<string> strs2 = decode(encoded_string);
    -
    - -

    strs2 in Machine 2 should be the same as strs in Machine 1.

    - -

    Implement the encode and decode methods.

    - -

     

    - -

    Note:

    - -
      -
    • The string may contain any possible characters out of 256 valid ascii characters. Your algorithm should be generalized enough to work on any possible characters.
    • -
    • Do not use class member/global/static variables to store states. Your encode and decode algorithms should be stateless.
    • -
    • Do not rely on any library method such as eval or serialize methods. You should implement your own encode/decode algorithm.
    • -
    ### Related Topics + [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/encode-and-decode-tinyurl/README.md b/problems/encode-and-decode-tinyurl/README.md index c8a3505e3..878e6d0aa 100644 --- a/problems/encode-and-decode-tinyurl/README.md +++ b/problems/encode-and-decode-tinyurl/README.md @@ -47,5 +47,7 @@ string ans = obj.decode(tiny); // returns the original url after deconding it. ### Related Topics + [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] diff --git a/problems/encode-n-ary-tree-to-binary-tree/README.md b/problems/encode-n-ary-tree-to-binary-tree/README.md index e2895bbe5..57ece564a 100644 --- a/problems/encode-n-ary-tree-to-binary-tree/README.md +++ b/problems/encode-n-ary-tree-to-binary-tree/README.md @@ -11,29 +11,14 @@ ## [431. Encode N-ary Tree to Binary Tree (Hard)](https://leetcode.com/problems/encode-n-ary-tree-to-binary-tree "将 N 叉树编码为二叉树") -

    Design an algorithm to encode an N-ary tree into a binary tree and decode the binary tree to get the original N-ary tree. An N-ary tree is a rooted tree in which each node has no more than N children. Similarly, a binary tree is a rooted tree in which each node has no more than 2 children. There is no restriction on how your encode/decode algorithm should work. You just need to ensure that an N-ary tree can be encoded to a binary tree and this binary tree can be decoded to the original N-nary tree structure.

    -

    For example, you may encode the following 3-ary tree to a binary tree in this way:

    - -

     

    - -

    - -

     

    - -

    Note that the above is just an example which might or might not work. You do not necessarily need to follow this format, so please be creative and come up with different approaches yourself.

    - -

     

    - -

    Note:

    - -
      -
    1. N is in the range of [1, 1000]
    2. -
    3. Do not use class member/global/static variables to store states. Your encode and decode algorithms should be stateless.
    4. -
    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Design](../../tag/design/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Serialize and Deserialize N-ary Tree](../serialize-and-deserialize-n-ary-tree) (Hard) diff --git a/problems/encode-number/README.md b/problems/encode-number/README.md index 31691e5a7..fda27aa58 100644 --- a/problems/encode-number/README.md +++ b/problems/encode-number/README.md @@ -11,37 +11,12 @@ ## [1256. Encode Number (Medium)](https://leetcode.com/problems/encode-number "加密数字") -

    Given a non-negative integer num, Return its encoding string.

    -

    The encoding is done by converting the integer to a string using a secret function that you should deduce from the following table:

    - -

    - -

     

    -

    Example 1:

    - -
    -Input: num = 23
    -Output: "1000"
    -
    - -

    Example 2:

    - -
    -Input: num = 107
    -Output: "101100"
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 0 <= num <= 10^9
    • -
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Convert to Base -2](../convert-to-base-2) (Medium) diff --git a/problems/encode-string-with-shortest-length/README.md b/problems/encode-string-with-shortest-length/README.md index f30975bf9..81f00d96e 100644 --- a/problems/encode-string-with-shortest-length/README.md +++ b/problems/encode-string-with-shortest-length/README.md @@ -11,71 +11,10 @@ ## [471. Encode String with Shortest Length (Hard)](https://leetcode.com/problems/encode-string-with-shortest-length "编码最短长度的字符串") -

    Given a non-empty string, encode the string such that its encoded length is the shortest.

    -

    The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times.

    - -

    Note:

    - -
      -
    1. k will be a positive integer and encoded string will not be empty or have extra space.
    2. -
    3. You may assume that the input string contains only lowercase English letters. The string's length is at most 160.
    4. -
    5. If an encoding process does not make the string shorter, then do not encode it. If there are several solutions, return any of them is fine.
    6. -
    - -

     

    - -

    Example 1:

    - -
    -Input: "aaa"
    -Output: "aaa"
    -Explanation: There is no way to encode it such that it is shorter than the input string, so we do not encode it.
    -
    - -

     

    - -

    Example 2:

    - -
    -Input: "aaaaa"
    -Output: "5[a]"
    -Explanation: "5[a]" is shorter than "aaaaa" by 1 character.
    -
    - -

     

    - -

    Example 3:

    - -
    -Input: "aaaaaaaaaa"
    -Output: "10[a]"
    -Explanation: "a9[a]" or "9[a]a" are also valid solutions, both of them have the same length = 5, which is the same as "10[a]".
    -
    - -

     

    - -

    Example 4:

    - -
    -Input: "aabcaabcd"
    -Output: "2[aabc]d"
    -Explanation: "aabc" occurs twice, so one answer can be "2[aabc]d".
    -
    - -

     

    - -

    Example 5:

    - -
    -Input: "abbbabbbcabbbabbbc"
    -Output: "2[2[abbb]c]"
    -Explanation: "abbbabbbc" occurs twice, but "abbbabbbc" can also be encoded to "2[abbb]c", so one answer can be "2[2[abbb]c]".
    -
    - -

     

    ### Related Topics + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/equal-rational-numbers/README.md b/problems/equal-rational-numbers/README.md index 7013c6e0b..6bf83eb5e 100644 --- a/problems/equal-rational-numbers/README.md +++ b/problems/equal-rational-numbers/README.md @@ -77,3 +77,4 @@ ### Related Topics [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/equal-sum-arrays-with-minimum-number-of-operations/README.md b/problems/equal-sum-arrays-with-minimum-number-of-operations/README.md index 56b3bea92..30b2a8af9 100644 --- a/problems/equal-sum-arrays-with-minimum-number-of-operations/README.md +++ b/problems/equal-sum-arrays-with-minimum-number-of-operations/README.md @@ -58,6 +58,9 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/equal-tree-partition/README.md b/problems/equal-tree-partition/README.md index c6edb8c86..84c903e84 100644 --- a/problems/equal-tree-partition/README.md +++ b/problems/equal-tree-partition/README.md @@ -11,54 +11,9 @@ ## [663. Equal Tree Partition (Medium)](https://leetcode.com/problems/equal-tree-partition "均匀树划分") -

    -Given a binary tree with n nodes, your task is to check if it's possible to partition the tree to two trees which have the equal sum of values after removing exactly one edge on the original tree. -

    -

    Example 1:
    -

    Input:     
    -    5
    -   / \
    -  10 10
    -    /  \
    -   2   3
    -
    -Output: True
    -Explanation: 
    -    5
    -   / 
    -  10
    -      
    -Sum: 15
    -
    -   10
    -  /  \
    - 2    3
    -
    -Sum: 15
    -
    -

    - - -

    Example 2:
    -

    Input:     
    -    1
    -   / \
    -  2  10
    -    /  \
    -   2   20
    -
    -Output: False
    -Explanation: You can't split the tree into two trees with equal sum after removing exactly one edge on the tree.
    -
    -

    - -

    Note:
    -

      -
    1. The range of tree node value is in the range of [-100000, 100000].
    2. -
    3. 1 <= n <= 10000
    4. -
    -

    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/erect-the-fence-ii/README.md b/problems/erect-the-fence-ii/README.md new file mode 100644 index 000000000..d0f1ff737 --- /dev/null +++ b/problems/erect-the-fence-ii/README.md @@ -0,0 +1,25 @@ + + + + + + + +[< Previous](../longest-common-subpath "Longest Common Subpath") +                 +Next > + +## [1924. Erect the Fence II (Hard)](https://leetcode.com/problems/erect-the-fence-ii "") + + + +### Hints +
    +Hint 1 +First, we need to note that this is a classic problem given n points you need to find the minimum enclosing circle to bind them +
    + +
    +Hint 2 +Second, we need to apply a well known algorithm called welzls algorithm to help us find the minimum enclosing circle +
    diff --git a/problems/erect-the-fence/README.md b/problems/erect-the-fence/README.md index 4f2ac2dc2..29da91e7a 100644 --- a/problems/erect-the-fence/README.md +++ b/problems/erect-the-fence/README.md @@ -44,3 +44,5 @@ ### Related Topics [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/escape-a-large-maze/README.md b/problems/escape-a-large-maze/README.md index 8eb48d84f..50cdd6178 100644 --- a/problems/escape-a-large-maze/README.md +++ b/problems/escape-a-large-maze/README.md @@ -52,7 +52,10 @@ We cannot move south or west because we cannot go outside of the grid. ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/escape-the-ghosts/README.md b/problems/escape-the-ghosts/README.md index b30a9439c..971ab7c90 100644 --- a/problems/escape-the-ghosts/README.md +++ b/problems/escape-the-ghosts/README.md @@ -71,4 +71,5 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/evaluate-boolean-expression/README.md b/problems/evaluate-boolean-expression/README.md index c2f7c6614..a5787ff4f 100644 --- a/problems/evaluate-boolean-expression/README.md +++ b/problems/evaluate-boolean-expression/README.md @@ -12,3 +12,6 @@ ## [1440. Evaluate Boolean Expression (Medium)](https://leetcode.com/problems/evaluate-boolean-expression "计算布尔表达式的值") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/evaluate-division/README.md b/problems/evaluate-division/README.md index 3212317f2..c5ec62174 100644 --- a/problems/evaluate-division/README.md +++ b/problems/evaluate-division/README.md @@ -61,8 +61,12 @@ return: [6.0, 0.5, -1.0, 1.0, -1.0 ] ### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] ### Hints
    diff --git a/problems/evaluate-reverse-polish-notation/README.md b/problems/evaluate-reverse-polish-notation/README.md index 15146320e..37780b31e 100644 --- a/problems/evaluate-reverse-polish-notation/README.md +++ b/problems/evaluate-reverse-polish-notation/README.md @@ -60,6 +60,8 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Basic Calculator](../basic-calculator) (Hard) diff --git a/problems/evaluate-the-bracket-pairs-of-a-string/README.md b/problems/evaluate-the-bracket-pairs-of-a-string/README.md index dcf601460..75f157112 100644 --- a/problems/evaluate-the-bracket-pairs-of-a-string/README.md +++ b/problems/evaluate-the-bracket-pairs-of-a-string/README.md @@ -82,6 +82,7 @@ Notice that the "a"s not in a bracket pair are not evaluated. ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/even-odd-tree/README.md b/problems/even-odd-tree/README.md index 4d373f08a..e38eac346 100644 --- a/problems/even-odd-tree/README.md +++ b/problems/even-odd-tree/README.md @@ -85,6 +85,8 @@ Node values in the level 2 must be in strictly increasing order, so the tree is ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/exam-room/README.md b/problems/exam-room/README.md index 38f4a4145..803c6be58 100644 --- a/problems/exam-room/README.md +++ b/problems/exam-room/README.md @@ -45,7 +45,8 @@ seat() -> 5, the student sits at the last seat number 5. ### Related Topics - [[Ordered Map](../../tag/ordered-map/README.md)] + [[Design](../../tag/design/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions 1. [Maximize Distance to Closest Person](../maximize-distance-to-closest-person) (Medium) diff --git a/problems/excel-sheet-column-number/README.md b/problems/excel-sheet-column-number/README.md index 9700b3966..7be69848f 100644 --- a/problems/excel-sheet-column-number/README.md +++ b/problems/excel-sheet-column-number/README.md @@ -66,6 +66,7 @@ AB -> 28 ### Related Topics [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Excel Sheet Column Title](../excel-sheet-column-title) (Easy) diff --git a/problems/excel-sheet-column-title/README.md b/problems/excel-sheet-column-title/README.md index afe10387f..1314f666f 100644 --- a/problems/excel-sheet-column-title/README.md +++ b/problems/excel-sheet-column-title/README.md @@ -64,6 +64,7 @@ AB -> 28 ### Related Topics [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Excel Sheet Column Number](../excel-sheet-column-number) (Easy) diff --git a/problems/exchange-seats/README.md b/problems/exchange-seats/README.md index f05ac0931..67215c08b 100644 --- a/problems/exchange-seats/README.md +++ b/problems/exchange-seats/README.md @@ -50,3 +50,6 @@

    Note:

    If the number of students is odd, there is no need to change the last one's seat.

    + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/exclusive-time-of-functions/README.md b/problems/exclusive-time-of-functions/README.md index 2138a21ef..01008e61c 100644 --- a/problems/exclusive-time-of-functions/README.md +++ b/problems/exclusive-time-of-functions/README.md @@ -91,3 +91,4 @@ So function 0 spends 2 + 4 + 1 = 7 units of total time executing, and function 1 ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/expression-add-operators/README.md b/problems/expression-add-operators/README.md index 8a93fea11..83b2f4331 100644 --- a/problems/expression-add-operators/README.md +++ b/problems/expression-add-operators/README.md @@ -40,7 +40,9 @@ ### Related Topics - [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions 1. [Evaluate Reverse Polish Notation](../evaluate-reverse-polish-notation) (Medium) diff --git a/problems/expressive-words/README.md b/problems/expressive-words/README.md index 969a7cdeb..d55c8837c 100644 --- a/problems/expressive-words/README.md +++ b/problems/expressive-words/README.md @@ -43,4 +43,6 @@ We can't extend "helo" to get "heeellooo" because the gr ### Related Topics + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/factor-combinations/README.md b/problems/factor-combinations/README.md index 89ab53fba..ba043174e 100644 --- a/problems/factor-combinations/README.md +++ b/problems/factor-combinations/README.md @@ -11,62 +11,10 @@ ## [254. Factor Combinations (Medium)](https://leetcode.com/problems/factor-combinations "因子的组合") -

    Numbers can be regarded as product of its factors. For example,

    -
    -8 = 2 x 2 x 2;
    -  = 2 x 4.
    -
    - -

    Write a function that takes an integer n and return all possible combinations of its factors.

    - -

    Note:

    - -
      -
    1. You may assume that n is always positive.
    2. -
    3. Factors should be greater than 1 and less than n.
    4. -
    - -

    Example 1:

    - -
    -Input: 1
    -Output: []
    -
    - -

    Example 2:

    - -
    -Input: 37
    -Output:[]
    - -

    Example 3:

    - -
    -Input: 12
    -Output:
    -[
    -  [2, 6],
    -  [2, 2, 3],
    -  [3, 4]
    -]
    - -

    Example 4:

    - -
    -Input: 32
    -Output:
    -[
    -  [2, 16],
    -  [2, 2, 8],
    -  [2, 2, 2, 4],
    -  [2, 2, 2, 2, 2],
    -  [2, 4, 4],
    -  [4, 8]
    -]
    -
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions diff --git a/problems/fair-candy-swap/README.md b/problems/fair-candy-swap/README.md index 22b065080..8512c6b38 100644 --- a/problems/fair-candy-swap/README.md +++ b/problems/fair-candy-swap/README.md @@ -72,3 +72,6 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/falling-squares/README.md b/problems/falling-squares/README.md index 3b49a50ed..050aa9122 100644 --- a/problems/falling-squares/README.md +++ b/problems/falling-squares/README.md @@ -57,7 +57,8 @@ Note that square 2 only brushes the right side of square 1, which does not count ### Related Topics [[Segment Tree](../../tag/segment-tree/README.md)] - [[Ordered Map](../../tag/ordered-map/README.md)] + [[Array](../../tag/array/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions 1. [The Skyline Problem](../the-skyline-problem) (Hard) diff --git a/problems/fancy-sequence/README.md b/problems/fancy-sequence/README.md index d5bb7af8b..4e0845e90 100644 --- a/problems/fancy-sequence/README.md +++ b/problems/fancy-sequence/README.md @@ -59,6 +59,7 @@ fancy.getIndex(2); // return 20 ### Related Topics [[Design](../../tag/design/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] [[Math](../../tag/math/README.md)] ### Hints diff --git a/problems/faulty-sensor/README.md b/problems/faulty-sensor/README.md index e7e277c0b..3025254b5 100644 --- a/problems/faulty-sensor/README.md +++ b/problems/faulty-sensor/README.md @@ -15,6 +15,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Hints
    diff --git a/problems/fibonacci-number/README.md b/problems/fibonacci-number/README.md index 667678df2..1f3969905 100644 --- a/problems/fibonacci-number/README.md +++ b/problems/fibonacci-number/README.md @@ -53,7 +53,10 @@ F(n) = F(n - 1) + F(n - 2), for n > 1. ### Related Topics - [[Array](../../tag/array/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Climbing Stairs](../climbing-stairs) (Easy) diff --git a/problems/filling-bookcase-shelves/README.md b/problems/filling-bookcase-shelves/README.md index 5d223c77d..096adb2b1 100644 --- a/problems/filling-bookcase-shelves/README.md +++ b/problems/filling-bookcase-shelves/README.md @@ -42,6 +42,7 @@ Notice that book number 2 does not have to be on the first shelf. ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/filter-restaurants-by-vegan-friendly-price-and-distance/README.md b/problems/filter-restaurants-by-vegan-friendly-price-and-distance/README.md index 9ae2a5248..352e8bb21 100644 --- a/problems/filter-restaurants-by-vegan-friendly-price-and-distance/README.md +++ b/problems/filter-restaurants-by-vegan-friendly-price-and-distance/README.md @@ -61,8 +61,8 @@ After filter restaurants with veganFriendly = 1, maxPrice = 50 and maxDistance = ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/final-prices-with-a-special-discount-in-a-shop/README.md b/problems/final-prices-with-a-special-discount-in-a-shop/README.md index 845ca88e6..25c0fa2da 100644 --- a/problems/final-prices-with-a-special-discount-in-a-shop/README.md +++ b/problems/final-prices-with-a-special-discount-in-a-shop/README.md @@ -52,7 +52,9 @@ For items 3 and 4 you will not receive any discount at all. ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints
    diff --git a/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md b/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md index aecbaee7d..3a44dd643 100644 --- a/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md +++ b/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md @@ -69,6 +69,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] - [[Recursion](../../tag/recursion/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/find-a-peak-element-ii/README.md b/problems/find-a-peak-element-ii/README.md new file mode 100644 index 000000000..6f59efabd --- /dev/null +++ b/problems/find-a-peak-element-ii/README.md @@ -0,0 +1,89 @@ + + + + + + + +[< Previous](../the-earliest-and-latest-rounds-where-players-compete "The Earliest and Latest Rounds Where Players Compete") +                 +[Next >](../depth-of-bst-given-insertion-order "Depth of BST Given Insertion Order") + +## [1901. Find a Peak Element II (Medium)](https://leetcode.com/problems/find-a-peak-element-ii "找出顶峰元素 II") + +

    A peak element in a 2D grid is an element that is strictly greater than all of its adjacent neighbors to the left, right, top, and bottom.

    + +

    Given a 0-indexed m x n matrix mat where no two adjacent cells are equal, find any peak element mat[i][j] and return the length 2 array [i,j].

    + +

    You may assume that the entire matrix is surrounded by an outer perimeter with the value -1 in each cell.

    + +

    You must write an algorithm that runs in O(m log(n)) or O(n log(m)) time.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: mat = [[1,4],[3,2]]
    +Output: [0,1]
    +Explanation: Both 3 and 4 are peak elements so [1,0] and [0,1] are both acceptable answers.
    +
    + +

    Example 2:

    + +

    + +
    +Input: mat = [[10,20,15],[21,30,14],[7,16,32]]
    +Output: [1,1]
    +Explanation: Both 30 and 32 are peak elements so [1,1] and [2,2] are both acceptable answers.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == mat.length
    • +
    • n == mat[i].length
    • +
    • 1 <= m, n <= 500
    • +
    • 1 <= mat[i][j] <= 105
    • +
    • No two adjacent cells are equal.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Let's assume that the width of the array is bigger than the height, otherwise, we will split in another direction. +
    + +
    +Hint 2 +Split the array into three parts: central column left side and right side. +
    + +
    +Hint 3 +Go through the central column and two neighbor columns and look for maximum. +
    + +
    +Hint 4 +If it's in the central column - this is our peak. +
    + +
    +Hint 5 +If it's on the left side, run this algorithm on subarray left_side + central_column. +
    + +
    +Hint 6 +If it's on the right side, run this algorithm on subarray right_side + central_column +
    diff --git a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md index 5b6881e14..d9e42c73b 100644 --- a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md +++ b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md @@ -55,6 +55,7 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] ### Hints diff --git a/problems/find-all-anagrams-in-a-string/README.md b/problems/find-all-anagrams-in-a-string/README.md index c8cca88b0..3f48bf74e 100644 --- a/problems/find-all-anagrams-in-a-string/README.md +++ b/problems/find-all-anagrams-in-a-string/README.md @@ -45,6 +45,8 @@ The substring with start index = 2 is "ab", which is an anagram of &qu ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions 1. [Valid Anagram](../valid-anagram) (Easy) diff --git a/problems/find-all-duplicates-in-an-array/README.md b/problems/find-all-duplicates-in-an-array/README.md index fbeb421d2..c3651b409 100644 --- a/problems/find-all-duplicates-in-an-array/README.md +++ b/problems/find-all-duplicates-in-an-array/README.md @@ -38,6 +38,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions 1. [Find All Numbers Disappeared in an Array](../find-all-numbers-disappeared-in-an-array) (Easy) diff --git a/problems/find-all-good-strings/README.md b/problems/find-all-good-strings/README.md index 2cf55fc53..fbad6ebbf 100644 --- a/problems/find-all-good-strings/README.md +++ b/problems/find-all-good-strings/README.md @@ -52,7 +52,9 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[String Matching](../../tag/string-matching/README.md)] ### Hints
    diff --git a/problems/find-all-numbers-disappeared-in-an-array/README.md b/problems/find-all-numbers-disappeared-in-an-array/README.md index 702b5748e..a303d22e0 100644 --- a/problems/find-all-numbers-disappeared-in-an-array/README.md +++ b/problems/find-all-numbers-disappeared-in-an-array/README.md @@ -35,6 +35,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions 1. [First Missing Positive](../first-missing-positive) (Hard) diff --git a/problems/find-all-the-lonely-nodes/README.md b/problems/find-all-the-lonely-nodes/README.md index 5739fd8b6..8201c7126 100644 --- a/problems/find-all-the-lonely-nodes/README.md +++ b/problems/find-all-the-lonely-nodes/README.md @@ -15,7 +15,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/find-anagram-mappings/README.md b/problems/find-anagram-mappings/README.md index c86ee417c..18e2f9012 100644 --- a/problems/find-anagram-mappings/README.md +++ b/problems/find-anagram-mappings/README.md @@ -11,36 +11,10 @@ ## [760. Find Anagram Mappings (Easy)](https://leetcode.com/problems/find-anagram-mappings "找出变位映射") -

    -Given two lists Aand B, and B is an anagram of A. B is an anagram of A means B is made by randomizing the order of the elements in A. -

    -We want to find an index mapping P, from A to B. A mapping P[i] = j means the ith element in A appears in B at index j. -

    -These lists A and B may contain duplicates. If there are multiple answers, output any of them. -

    -

    -For example, given -

    -A = [12, 28, 46, 32, 50]
    -B = [50, 12, 32, 46, 28]
    -
    -

    -We should return -
    -[1, 4, 3, 2, 0]
    -
    -as P[0] = 1 because the 0th element of A appears at B[1], -and P[1] = 4 because the 1st element of A appears at B[4], -and so on. -

    - -

    Note:

      -
    1. A, B have equal lengths in range [1, 100].
    2. -
    3. A[i], B[i] are integers in range [0, 10^5].
    4. -

    ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] ### Hints diff --git a/problems/find-and-replace-in-string/README.md b/problems/find-and-replace-in-string/README.md index 8bdebbbee..a7f371184 100644 --- a/problems/find-and-replace-in-string/README.md +++ b/problems/find-and-replace-in-string/README.md @@ -11,50 +11,63 @@ ## [833. Find And Replace in String (Medium)](https://leetcode.com/problems/find-and-replace-in-string "字符串中的查找与替换") -

    To some string s, we will perform some replacement operations that replace groups of letters with new ones (not necessarily the same size).

    +

    You are given a 0-indexed string s that you must perform k replacement operations on. The replacement operations are given as three 0-indexed parallel arrays, indices, sources, and targets, all of length k.

    -

    Each replacement operation has 3 parameters: a starting index i, a source word x and a target word y. The rule is that if x starts at position i in the original string S, then we will replace that occurrence of x with y. If not, we do nothing.

    +

    To complete the ith replacement operation:

    -

    For example, if we have s = "abcd" and we have some replacement operation i = 2, x = "cd", y = "ffff", then because "cd" starts at position 2 in the original string s, we will replace it with "ffff".

    +
      +
    1. Check if the substring sources[i] occurs at index indices[i] in the original string s.
    2. +
    3. If it does not occur, do nothing.
    4. +
    5. Otherwise if it does occur, replace that substring with targets[i].
    6. +
    -

    Using another example on s = "abcd", if we have both the replacement operation i = 0, x = "ab", y = "eee", as well as another replacement operation i = 2, x = "ec", y = "ffff", this second operation does nothing because in the original string s[2] = 'c', which doesn't match x[0] = 'e'.

    +

    For example, if s = "abcd", indices[i] = 0, sources[i] = "ab", and targets[i] = "eee", then the result of this replacement will be "eeecd".

    -

    All these operations occur simultaneously. It's guaranteed that there won't be any overlap in replacement: for example, s = "abc", indexes = [0, 1], sources = ["ab","bc"] is not a valid test case.

    +

    All replacement operations must occur simultaneously, meaning the replacement operations should not affect the indexing of each other. The testcases will be generated such that the replacements will not overlap.

    + +
      +
    • For example, a testcase with s = "abc", indices = [0, 1], and sources = ["ab","bc"] will not be generated because the "ab" and "bc" replacements overlap.
    • +
    + +

    Return the resulting string after performing all replacement operations on s.

    + +

    A substring is a contiguous sequence of characters in a string.

     

    Example 1:

    - +
    -Input: s = "abcd", indexes = [0, 2], sources = ["a", "cd"], targets = ["eee", "ffff"]
    +Input: s = "abcd", indices = [0, 2], sources = ["a", "cd"], targets = ["eee", "ffff"]
     Output: "eeebffff"
     Explanation:
    -"a" starts at index 0 in s, so it's replaced by "eee".
    -"cd" starts at index 2 in s, so it's replaced by "ffff".
    +"a" occurs at index 0 in s, so we replace it with "eee".
    +"cd" occurs at index 2 in s, so we replace it with "ffff".
     

    Example 2:

    - +
    -Input: s = "abcd", indexes = [0, 2], sources = ["ab","ec"], targets = ["eee","ffff"]
    +Input: s = "abcd", indices = [0, 2], sources = ["ab","ec"], targets = ["eee","ffff"]
     Output: "eeecd"
     Explanation:
    -"ab" starts at index 0 in s, so it's replaced by "eee".
    -"ec" doesn't starts at index 2 in the original s, so we do nothing.
    +"ab" occurs at index 0 in s, so we replace it with "eee".
    +"ec" does not occur at index 2 in s, so we do nothing.
     

     

    Constraints:

      -
    • 0 <= s.length <= 1000
    • -
    • s consists of only lowercase English letters.
    • -
    • 0 <= indexes.length <= 100
    • +
    • 1 <= s.length <= 1000
    • +
    • k == indices.length == sources.length == targets.length
    • +
    • 1 <= k <= 100
    • 0 <= indexes[i] < s.length
    • -
    • sources.length == indexes.length
    • -
    • targets.length == indexes.length
    • 1 <= sources[i].length, targets[i].length <= 50
    • +
    • s consists of only lowercase English letters.
    • sources[i] and targets[i] consist of only lowercase English letters.
    ### Related Topics + [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/find-and-replace-pattern/README.md b/problems/find-and-replace-pattern/README.md index 3955bacda..f1d5c8d67 100644 --- a/problems/find-and-replace-pattern/README.md +++ b/problems/find-and-replace-pattern/README.md @@ -45,4 +45,6 @@ ### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/find-bottom-left-tree-value/README.md b/problems/find-bottom-left-tree-value/README.md index eda7a540a..6a72e27bc 100644 --- a/problems/find-bottom-left-tree-value/README.md +++ b/problems/find-bottom-left-tree-value/README.md @@ -38,5 +38,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/find-center-of-star-graph/README.md b/problems/find-center-of-star-graph/README.md index 5a95710f0..bdbc51763 100644 --- a/problems/find-center-of-star-graph/README.md +++ b/problems/find-center-of-star-graph/README.md @@ -9,7 +9,7 @@                  [Next >](../maximum-average-pass-ratio "Maximum Average Pass Ratio") -## [1791. Find Center of Star Graph (Medium)](https://leetcode.com/problems/find-center-of-star-graph "找出星型图的中心节点") +## [1791. Find Center of Star Graph (Easy)](https://leetcode.com/problems/find-center-of-star-graph "找出星型图的中心节点")

    There is an undirected star graph consisting of n nodes labeled from 1 to n. A star graph is a graph where there is one center node and exactly n - 1 edges that connect the center node with every other node.

    diff --git a/problems/find-common-characters/README.md b/problems/find-common-characters/README.md index 6bcd0be94..117a7e7a1 100644 --- a/problems/find-common-characters/README.md +++ b/problems/find-common-characters/README.md @@ -48,6 +48,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Intersection of Two Arrays II](../intersection-of-two-arrays-ii) (Easy) diff --git a/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md b/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md index dafa8151a..82bd85787 100644 --- a/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md +++ b/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md @@ -55,8 +55,11 @@ The edges 2, 3, 4, and 5 are only part of some MSTs, therefore they are consider ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Strongly Connected Component](../../tag/strongly-connected-component/README.md)] ### Hints
    diff --git a/problems/find-cumulative-salary-of-an-employee/README.md b/problems/find-cumulative-salary-of-an-employee/README.md index 83a85c4ab..0e8376da5 100644 --- a/problems/find-cumulative-salary-of-an-employee/README.md +++ b/problems/find-cumulative-salary-of-an-employee/README.md @@ -11,74 +11,10 @@ ## [579. Find Cumulative Salary of an Employee (Hard)](https://leetcode.com/problems/find-cumulative-salary-of-an-employee "查询员工的累计薪水") -

    The Employee table holds the salary information in a year.

    -

    Write a SQL to get the cumulative sum of an employee's salary over a period of 3 months but exclude the most recent month.

    -

    The result should be displayed by 'Id' ascending, and then by 'Month' descending.

    - -

    Example
    -Input

    - -
    -| Id | Month | Salary |
    -|----|-------|--------|
    -| 1  | 1     | 20     |
    -| 2  | 1     | 20     |
    -| 1  | 2     | 30     |
    -| 2  | 2     | 30     |
    -| 3  | 2     | 40     |
    -| 1  | 3     | 40     |
    -| 3  | 3     | 60     |
    -| 1  | 4     | 60     |
    -| 3  | 4     | 70     |
    -
    -Output - -
    -
    -| Id | Month | Salary |
    -|----|-------|--------|
    -| 1  | 3     | 90     |
    -| 1  | 2     | 50     |
    -| 1  | 1     | 20     |
    -| 2  | 1     | 20     |
    -| 3  | 3     | 100    |
    -| 3  | 2     | 40     |
    -
    - -

     

    -Explanation - -

    Employee '1' has 3 salary records for the following 3 months except the most recent month '4': salary 40 for month '3', 30 for month '2' and 20 for month '1'
    -So the cumulative sum of salary of this employee over 3 months is 90(40+30+20), 50(30+20) and 20 respectively.

    - -
    -| Id | Month | Salary |
    -|----|-------|--------|
    -| 1  | 3     | 90     |
    -| 1  | 2     | 50     |
    -| 1  | 1     | 20     |
    -
    -Employee '2' only has one salary record (month '1') except its most recent month '2'. - -
    -| Id | Month | Salary |
    -|----|-------|--------|
    -| 2  | 1     | 20     |
    -
    - -

     

    -Employ '3' has two salary records except its most recent pay month '4': month '3' with 60 and month '2' with 40. So the cumulative salary is as following. - -
    -| Id | Month | Salary |
    -|----|-------|--------|
    -| 3  | 3     | 100    |
    -| 3  | 2     | 40     |
    -
    - -

     

    +### Related Topics + [[Database](../../tag/database/README.md)] ### Hints
    diff --git a/problems/find-customer-referee/README.md b/problems/find-customer-referee/README.md index 5f0fe373a..8d626e3ee 100644 --- a/problems/find-customer-referee/README.md +++ b/problems/find-customer-referee/README.md @@ -11,35 +11,10 @@ ## [584. Find Customer Referee (Easy)](https://leetcode.com/problems/find-customer-referee "寻找用户推荐人") -

    Given a table customer holding customers information and the referee.

    -
    -+------+------+-----------+
    -| id   | name | referee_id|
    -+------+------+-----------+
    -|    1 | Will |      NULL |
    -|    2 | Jane |      NULL |
    -|    3 | Alex |         2 |
    -|    4 | Bill |      NULL |
    -|    5 | Zack |         1 |
    -|    6 | Mark |         2 |
    -+------+------+-----------+
    -
    -

    Write a query to return the list of customers NOT referred by the person with id '2'.

    - -

    For the sample data above, the result is:

    - -
    -+------+
    -| name |
    -+------+
    -| Will |
    -| Jane |
    -| Bill |
    -| Zack |
    -+------+
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] ### Hints
    diff --git a/problems/find-customers-with-positive-revenue-this-year/README.md b/problems/find-customers-with-positive-revenue-this-year/README.md index 45c148b96..4f5d7a5ba 100644 --- a/problems/find-customers-with-positive-revenue-this-year/README.md +++ b/problems/find-customers-with-positive-revenue-this-year/README.md @@ -12,3 +12,6 @@ ## [1821. Find Customers With Positive Revenue this Year (Easy)](https://leetcode.com/problems/find-customers-with-positive-revenue-this-year "寻找今年具有正收入的客户") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/find-distance-in-a-binary-tree/README.md b/problems/find-distance-in-a-binary-tree/README.md index 400efb227..e7f24cae8 100644 --- a/problems/find-distance-in-a-binary-tree/README.md +++ b/problems/find-distance-in-a-binary-tree/README.md @@ -15,8 +15,10 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/find-duplicate-file-in-system/README.md b/problems/find-duplicate-file-in-system/README.md index 59762cb38..b3a3d45c5 100644 --- a/problems/find-duplicate-file-in-system/README.md +++ b/problems/find-duplicate-file-in-system/README.md @@ -61,5 +61,6 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/find-duplicate-subtrees/README.md b/problems/find-duplicate-subtrees/README.md index 05d1c580c..2d9d022d3 100644 --- a/problems/find-duplicate-subtrees/README.md +++ b/problems/find-duplicate-subtrees/README.md @@ -49,6 +49,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Serialize and Deserialize Binary Tree](../serialize-and-deserialize-binary-tree) (Hard) diff --git a/problems/find-elements-in-a-contaminated-binary-tree/README.md b/problems/find-elements-in-a-contaminated-binary-tree/README.md index a3a516d28..bfd81d4c5 100644 --- a/problems/find-elements-in-a-contaminated-binary-tree/README.md +++ b/problems/find-elements-in-a-contaminated-binary-tree/README.md @@ -11,7 +11,7 @@ ## [1261. Find Elements in a Contaminated Binary Tree (Medium)](https://leetcode.com/problems/find-elements-in-a-contaminated-binary-tree "在受污染的二叉树中查找元素") -

    Given a binary tree with the following rules:

    +

    Given a binary tree with the following rules:

    1. root.val == 0
    2. @@ -19,20 +19,18 @@
    3. If treeNode.val == x and treeNode.right != null, then treeNode.right.val == 2 * x + 2
    -

    Now the binary tree is contaminated, which means all treeNode.val have been changed to -1.

    +

    Now the binary tree is contaminated, which means all treeNode.val have been changed to -1.

    -

    You need to first recover the binary tree and then implement the FindElements class:

    +

    Implement the FindElements class:

      -
    • FindElements(TreeNode* root) Initializes the object with a contamined binary tree, you need to recover it first.
    • -
    • bool find(int target) Return if the target value exists in the recovered binary tree.
    • +
    • FindElements(TreeNode* root) Initializes the object with a contaminated binary tree and recovers it.
    • +
    • bool find(int target) Returns true if the target value exists in the recovered binary tree.

     

    Example 1:

    - -

    - +
     Input
     ["FindElements","find","find"]
    @@ -45,9 +43,7 @@ findElements.find(1); // return False
     findElements.find(2); // return True 

    Example 2:

    - -

    - +
     Input
     ["FindElements","find","find","find"]
    @@ -61,9 +57,7 @@ findElements.find(3); // return True
     findElements.find(5); // return False

    Example 3:

    - -

    - +
     Input
     ["FindElements","find","find","find","find"]
    @@ -84,14 +78,17 @@ findElements.find(5); // return True
     
    • TreeNode.val == -1
    • The height of the binary tree is less than or equal to 20
    • -
    • The total number of nodes is between [1, 10^4]
    • -
    • Total calls of find() is between [1, 10^4]
    • -
    • 0 <= target <= 10^6
    • +
    • The total number of nodes is between [1, 104]
    • +
    • Total calls of find() is between [1, 104]
    • +
    • 0 <= target <= 106
    ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Design](../../tag/design/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/find-eventual-safe-states/README.md b/problems/find-eventual-safe-states/README.md index cad2aa1c7..a71acd8a5 100644 --- a/problems/find-eventual-safe-states/README.md +++ b/problems/find-eventual-safe-states/README.md @@ -41,12 +41,14 @@
    • n == graph.length
    • 1 <= n <= 104
    • -
    • 0 <= graph[i].legnth <= n
    • +
    • 0 <= graph[i].length <= n
    • graph[i] is sorted in a strictly increasing order.
    • The graph may contain self-loops.
    • The number of edges in the graph will be in the range [1, 4 * 104].
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] diff --git a/problems/find-followers-count/README.md b/problems/find-followers-count/README.md index 3b4dde38c..19b344c7c 100644 --- a/problems/find-followers-count/README.md +++ b/problems/find-followers-count/README.md @@ -12,3 +12,6 @@ ## [1729. Find Followers Count (Easy)](https://leetcode.com/problems/find-followers-count "求关注者的数量") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/find-in-mountain-array/README.md b/problems/find-in-mountain-array/README.md index 9d531ae4d..c4c73ab6b 100644 --- a/problems/find-in-mountain-array/README.md +++ b/problems/find-in-mountain-array/README.md @@ -65,7 +65,9 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Interactive](../../tag/interactive/README.md)] ### Hints
    diff --git a/problems/find-interview-candidates/README.md b/problems/find-interview-candidates/README.md index 65246e114..c7e04117a 100644 --- a/problems/find-interview-candidates/README.md +++ b/problems/find-interview-candidates/README.md @@ -9,6 +9,9 @@                  [Next >](../determine-color-of-a-chessboard-square "Determine Color of a Chessboard Square") -## [1811. Find Interview Candidates (Medium)](https://leetcode.com/problems/find-interview-candidates "") +## [1811. Find Interview Candidates (Medium)](https://leetcode.com/problems/find-interview-candidates "寻找面试候选人") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/find-k-closest-elements/README.md b/problems/find-k-closest-elements/README.md index 7a62a8d2a..db3d6d94d 100644 --- a/problems/find-k-closest-elements/README.md +++ b/problems/find-k-closest-elements/README.md @@ -39,7 +39,11 @@ ### Related Topics + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Guess Number Higher or Lower](../guess-number-higher-or-lower) (Easy) diff --git a/problems/find-k-length-substrings-with-no-repeated-characters/README.md b/problems/find-k-length-substrings-with-no-repeated-characters/README.md index effcba5f7..785708801 100644 --- a/problems/find-k-length-substrings-with-no-repeated-characters/README.md +++ b/problems/find-k-length-substrings-with-no-repeated-characters/README.md @@ -11,39 +11,10 @@ ## [1100. Find K-Length Substrings With No Repeated Characters (Medium)](https://leetcode.com/problems/find-k-length-substrings-with-no-repeated-characters "长度为 K 的无重复字符子串") -

    Given a string S, return the number of substrings of length K with no repeated characters.

    -

     

    - -

    Example 1:

    - -
    -Input: S = "havefunonleetcode", K = 5
    -Output: 6
    -Explanation: 
    -There are 6 substrings they are : 'havef','avefu','vefun','efuno','etcod','tcode'.
    -
    - -

    Example 2:

    - -
    -Input: S = "home", K = 5
    -Output: 0
    -Explanation: 
    -Notice K can be larger than the length of S. In this case is not possible to find any substring.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= S.length <= 10^4
    2. -
    3. All characters of S are lowercase English letters.
    4. -
    5. 1 <= K <= 10^4
    6. -
    ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] diff --git a/problems/find-k-pairs-with-smallest-sums/README.md b/problems/find-k-pairs-with-smallest-sums/README.md index f8cfd0c6e..8fcf41fab 100644 --- a/problems/find-k-pairs-with-smallest-sums/README.md +++ b/problems/find-k-pairs-with-smallest-sums/README.md @@ -53,7 +53,8 @@ ### Related Topics - [[Heap](../../tag/heap/README.md)] + [[Array](../../tag/array/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Kth Smallest Element in a Sorted Matrix](../kth-smallest-element-in-a-sorted-matrix) (Medium) diff --git a/problems/find-k-th-smallest-pair-distance/README.md b/problems/find-k-th-smallest-pair-distance/README.md index 27ecd15c6..7edbcfaf5 100644 --- a/problems/find-k-th-smallest-pair-distance/README.md +++ b/problems/find-k-th-smallest-pair-distance/README.md @@ -53,9 +53,10 @@ Then the 1st smallest distance pair is (1,1), and its distance is 0. ### Related Topics - [[Heap](../../tag/heap/README.md)] [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Find K Pairs with Smallest Sums](../find-k-pairs-with-smallest-sums) (Medium) diff --git a/problems/find-kth-bit-in-nth-binary-string/README.md b/problems/find-kth-bit-in-nth-binary-string/README.md index 4b2c310c8..472812324 100644 --- a/problems/find-kth-bit-in-nth-binary-string/README.md +++ b/problems/find-kth-bit-in-nth-binary-string/README.md @@ -71,6 +71,7 @@ ### Related Topics + [[Recursion](../../tag/recursion/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/find-kth-largest-xor-coordinate-value/README.md b/problems/find-kth-largest-xor-coordinate-value/README.md index 9f4c9e140..f69f71c83 100644 --- a/problems/find-kth-largest-xor-coordinate-value/README.md +++ b/problems/find-kth-largest-xor-coordinate-value/README.md @@ -58,7 +58,13 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Quickselect](../../tag/quickselect/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/find-largest-value-in-each-tree-row/README.md b/problems/find-largest-value-in-each-tree-row/README.md index 00f25719f..4ef0b9546 100644 --- a/problems/find-largest-value-in-each-tree-row/README.md +++ b/problems/find-largest-value-in-each-tree-row/README.md @@ -61,5 +61,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/find-latest-group-of-size-m/README.md b/problems/find-latest-group-of-size-m/README.md index 81cb52486..5251c6beb 100644 --- a/problems/find-latest-group-of-size-m/README.md +++ b/problems/find-latest-group-of-size-m/README.md @@ -71,7 +71,9 @@ No group of size 2 exists during any step. ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/find-leaves-of-binary-tree/README.md b/problems/find-leaves-of-binary-tree/README.md index a60428896..efc38ec48 100644 --- a/problems/find-leaves-of-binary-tree/README.md +++ b/problems/find-leaves-of-binary-tree/README.md @@ -11,52 +11,9 @@ ## [366. Find Leaves of Binary Tree (Medium)](https://leetcode.com/problems/find-leaves-of-binary-tree "寻找二叉树的叶子节点") -

    Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all leaves, repeat until the tree is empty.

    -

     

    - -

    Example:

    - -
    -Input: [1,2,3,4,5]
    -  
    -          1
    -         / \
    -        2   3
    -       / \     
    -      4   5    
    -
    -Output: [[4,5,3],[2],[1]]
    -
    - -

     

    - -

    Explanation:

    - -

    1. Removing the leaves [4,5,3] would result in this tree:

    - -
    -          1
    -         / 
    -        2          
    -
    - -

     

    - -

    2. Now removing the leaf [2] would result in this tree:

    - -
    -          1          
    -
    - -

     

    - -

    3. Now removing the leaf [1] would result in the empty tree:

    - -
    -          []         
    -
    ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/find-longest-awesome-substring/README.md b/problems/find-longest-awesome-substring/README.md index 79d3b034a..51ee2950c 100644 --- a/problems/find-longest-awesome-substring/README.md +++ b/problems/find-longest-awesome-substring/README.md @@ -56,6 +56,7 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/find-lucky-integer-in-an-array/README.md b/problems/find-lucky-integer-in-an-array/README.md index 099a8ba85..7f5d812a1 100644 --- a/problems/find-lucky-integer-in-an-array/README.md +++ b/problems/find-lucky-integer-in-an-array/README.md @@ -64,6 +64,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/find-median-from-data-stream/README.md b/problems/find-median-from-data-stream/README.md index d6c753979..3d281767d 100644 --- a/problems/find-median-from-data-stream/README.md +++ b/problems/find-median-from-data-stream/README.md @@ -63,8 +63,11 @@ medianFinder.findMedian(); // return 2.0 ### Related Topics - [[Heap](../../tag/heap/README.md)] [[Design](../../tag/design/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Sliding Window Median](../sliding-window-median) (Hard) diff --git a/problems/find-median-given-frequency-of-numbers/README.md b/problems/find-median-given-frequency-of-numbers/README.md index 85b17693e..19dd85bf2 100644 --- a/problems/find-median-given-frequency-of-numbers/README.md +++ b/problems/find-median-given-frequency-of-numbers/README.md @@ -11,30 +11,10 @@ ## [571. Find Median Given Frequency of Numbers (Hard)](https://leetcode.com/problems/find-median-given-frequency-of-numbers "给定数字的频率查询中位数") -

    The Numbers table keeps the value of number and its frequency.

    -
    -+----------+-------------+
    -|  Number  |  Frequency  |
    -+----------+-------------|
    -|  0       |  7          |
    -|  1       |  1          |
    -|  2       |  3          |
    -|  3       |  1          |
    -+----------+-------------+
    -
    -

    In this table, the numbers are 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 3, so the median is (0 + 0) / 2 = 0.

    - -
    -+--------+
    -| median |
    -+--------|
    -| 0.0000 |
    -+--------+
    -
    - -

    Write a query to find the median of all numbers and name the result as median.

    +### Related Topics + [[Database](../../tag/database/README.md)] ### Similar Questions 1. [Median Employee Salary](../median-employee-salary) (Hard) diff --git a/problems/find-minimum-time-to-finish-all-jobs/README.md b/problems/find-minimum-time-to-finish-all-jobs/README.md index 03362e8ee..092bf7ddc 100644 --- a/problems/find-minimum-time-to-finish-all-jobs/README.md +++ b/problems/find-minimum-time-to-finish-all-jobs/README.md @@ -45,8 +45,11 @@ The maximum working time is 11.
    ### Related Topics - [[Recursion](../../tag/recursion/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/find-mode-in-binary-search-tree/README.md b/problems/find-mode-in-binary-search-tree/README.md index ca3e6d056..854f06464 100644 --- a/problems/find-mode-in-binary-search-tree/README.md +++ b/problems/find-mode-in-binary-search-tree/README.md @@ -51,6 +51,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Validate Binary Search Tree](../validate-binary-search-tree) (Medium) diff --git a/problems/find-n-unique-integers-sum-up-to-zero/README.md b/problems/find-n-unique-integers-sum-up-to-zero/README.md index 2251d1fbc..f7bf6803a 100644 --- a/problems/find-n-unique-integers-sum-up-to-zero/README.md +++ b/problems/find-n-unique-integers-sum-up-to-zero/README.md @@ -45,6 +45,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/find-nearest-right-node-in-binary-tree/README.md b/problems/find-nearest-right-node-in-binary-tree/README.md index 6f60b3690..2da65c22e 100644 --- a/problems/find-nearest-right-node-in-binary-tree/README.md +++ b/problems/find-nearest-right-node-in-binary-tree/README.md @@ -15,7 +15,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/find-permutation/README.md b/problems/find-permutation/README.md index bfa918ff8..f98bd441b 100644 --- a/problems/find-permutation/README.md +++ b/problems/find-permutation/README.md @@ -11,32 +11,9 @@ ## [484. Find Permutation (Medium)](https://leetcode.com/problems/find-permutation "寻找排列") -

    -By now, you are given a secret signature consisting of character 'D' and 'I'. 'D' represents a decreasing relationship between two numbers, 'I' represents an increasing relationship between two numbers. And our secret signature was constructed by a special integer array, which contains uniquely all the different number from 1 to n (n is the length of the secret signature plus 1). For example, the secret signature "DI" can be constructed by array [2,1,3] or [3,1,2], but won't be constructed by array [3,2,4] or [2,1,3,4], which are both illegal constructing special string that can't represent the "DI" secret signature. -

    -

    -On the other hand, now your job is to find the lexicographically smallest permutation of [1, 2, ... n] could refer to the given secret signature in the input. -

    - -

    Example 1:
    -

    Input: "I"
    -Output: [1,2]
    -Explanation: [1,2] is the only legal initial spectial string can construct secret signature "I", where the number 1 and 2 construct an increasing relationship.
    -
    -

    - -

    Example 2:
    -

    Input: "DI"
    -Output: [2,1,3]
    -Explanation: Both [2,1,3] and [3,1,2] can construct the secret signature "DI", 
    but since we want to find the one with the smallest lexicographical permutation, you need to output [2,1,3] -
    -

    - -

    Note: -

  • The input string will only contain the character 'D' and 'I'.
  • -
  • The length of input string is a positive integer and will not exceed 10,000
  • -

    ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/find-pivot-index/README.md b/problems/find-pivot-index/README.md index 9774506f1..25296cf14 100644 --- a/problems/find-pivot-index/README.md +++ b/problems/find-pivot-index/README.md @@ -60,6 +60,7 @@ Right sum = nums[1] + nums[2] = 1 + -1 = 0 ### Related Topics [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Similar Questions 1. [Subarray Sum Equals K](../subarray-sum-equals-k) (Medium) diff --git a/problems/find-positive-integer-solution-for-a-given-equation/README.md b/problems/find-positive-integer-solution-for-a-given-equation/README.md index 71355c3fa..4c7eabb44 100644 --- a/problems/find-positive-integer-solution-for-a-given-equation/README.md +++ b/problems/find-positive-integer-solution-for-a-given-equation/README.md @@ -76,7 +76,9 @@ x=5, y=1 -> f(5, 1) = 5 * 1 = 5. ### Related Topics [[Math](../../tag/math/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Interactive](../../tag/interactive/README.md)] ### Hints
    diff --git a/problems/find-right-interval/README.md b/problems/find-right-interval/README.md index 663344584..629b32340 100644 --- a/problems/find-right-interval/README.md +++ b/problems/find-right-interval/README.md @@ -56,7 +56,9 @@ The right interval for [2,3] is [3,4] since start2 = 3 is the smalles ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Data Stream as Disjoint Intervals](../data-stream-as-disjoint-intervals) (Hard) diff --git a/problems/find-root-of-n-ary-tree/README.md b/problems/find-root-of-n-ary-tree/README.md index 37b8828b1..2c7f07dae 100644 --- a/problems/find-root-of-n-ary-tree/README.md +++ b/problems/find-root-of-n-ary-tree/README.md @@ -13,6 +13,12 @@ +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + ### Hints
    Hint 1 diff --git a/problems/find-servers-that-handled-most-number-of-requests/README.md b/problems/find-servers-that-handled-most-number-of-requests/README.md index 751e8ed32..237d5cb81 100644 --- a/problems/find-servers-that-handled-most-number-of-requests/README.md +++ b/problems/find-servers-that-handled-most-number-of-requests/README.md @@ -83,7 +83,10 @@ Server 0 handled two requests, while servers 1 and 2 handled one request each. H ### Related Topics - [[Ordered Map](../../tag/ordered-map/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/find-smallest-common-element-in-all-rows/README.md b/problems/find-smallest-common-element-in-all-rows/README.md index 8bf0613d1..df0fbcb08 100644 --- a/problems/find-smallest-common-element-in-all-rows/README.md +++ b/problems/find-smallest-common-element-in-all-rows/README.md @@ -11,28 +11,14 @@ ## [1198. Find Smallest Common Element in All Rows (Medium)](https://leetcode.com/problems/find-smallest-common-element-in-all-rows "找出所有行中最小公共元素") -

    Given a matrix mat where every row is sorted in increasing order, return the smallest common element in all rows.

    -

    If there is no common element, return -1.

    - - -

     

    -

    Example 1:

    -
    Input: mat = [[1,2,3,4,5],[2,4,5,8,10],[3,5,7,9,11],[1,3,5,7,9]]
    -Output: 5
    -
    -

     

    -

    Constraints:

    - -
      -
    • 1 <= mat.length, mat[i].length <= 500
    • -
    • 1 <= mat[i][j] <= 10^4
    • -
    • mat[i] is sorted in increasing order.
    • -
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/find-smallest-letter-greater-than-target/README.md b/problems/find-smallest-letter-greater-than-target/README.md index 590b9cc02..ddcaa5c62 100644 --- a/problems/find-smallest-letter-greater-than-target/README.md +++ b/problems/find-smallest-letter-greater-than-target/README.md @@ -67,6 +67,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] ### Hints diff --git a/problems/find-the-celebrity/README.md b/problems/find-the-celebrity/README.md index 1cf1be1e1..77fbabb77 100644 --- a/problems/find-the-celebrity/README.md +++ b/problems/find-the-celebrity/README.md @@ -11,49 +11,13 @@ ## [277. Find the Celebrity (Medium)](https://leetcode.com/problems/find-the-celebrity "搜寻名人") -

    Suppose you are at a party with n people (labeled from 0 to n - 1) and among them, there may exist one celebrity. The definition of a celebrity is that all the other n - 1 people know him/her but he/she does not know any of them.

    -

    Now you want to find out who the celebrity is or verify that there is not one. The only thing you are allowed to do is to ask questions like: "Hi, A. Do you know B?" to get information of whether A knows B. You need to find out the celebrity (or verify there is not one) by asking as few questions as possible (in the asymptotic sense).

    - -

    You are given a helper function bool knows(a, b) which tells you whether A knows B. Implement a function int findCelebrity(n). There will be exactly one celebrity if he/she is in the party. Return the celebrity's label if there is a celebrity in the party. If there is no celebrity, return -1.

    - -

     

    - -

    Example 1:

    - -
    -Input: graph = [
    -  [1,1,0],
    -  [0,1,0],
    -  [1,1,1]
    -]
    -Output: 1
    -Explanation: There are three persons labeled with 0, 1 and 2. graph[i][j] = 1 means person i knows person j, otherwise graph[i][j] = 0 means person i does not know person j. The celebrity is the person labeled as 1 because both 0 and 2 know him but 1 does not know anybody.
    -
    - -

    Example 2:

    - -
    -Input: graph = [
    -  [1,0,1],
    -  [1,1,0],
    -  [0,1,1]
    -]
    -Output: -1
    -Explanation: There is no celebrity.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. The directed graph is represented as an adjacency matrix, which is an n x n matrix where a[i][j] = 1 means person i knows person j while a[i][j] = 0 means the contrary.
    2. -
    3. Remember that you won't have direct access to the adjacency matrix.
    4. -
    ### Related Topics - [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Interactive](../../tag/interactive/README.md)] ### Similar Questions 1. [Find the Town Judge](../find-the-town-judge) (Easy) diff --git a/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md b/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md index 33aa491a9..8a56a7c1b 100644 --- a/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md +++ b/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md @@ -61,6 +61,8 @@ The city 0 has 1 neighboring city at a distanceThreshold = 2. ### Related Topics [[Graph](../../tag/graph/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] ### Hints
    diff --git a/problems/find-the-closest-palindrome/README.md b/problems/find-the-closest-palindrome/README.md index 66e1f6384..712140264 100644 --- a/problems/find-the-closest-palindrome/README.md +++ b/problems/find-the-closest-palindrome/README.md @@ -42,6 +42,7 @@ ### Related Topics + [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/find-the-derangement-of-an-array/README.md b/problems/find-the-derangement-of-an-array/README.md index 4274d7cf9..376017482 100644 --- a/problems/find-the-derangement-of-an-array/README.md +++ b/problems/find-the-derangement-of-an-array/README.md @@ -11,29 +11,8 @@ ## [634. Find the Derangement of An Array (Medium)](https://leetcode.com/problems/find-the-derangement-of-an-array "寻找数组的错位排列") -

    -In combinatorial mathematics, a derangement is a permutation of the elements of a set, such that no element appears in its original position. -

    -

    -There's originally an array consisting of n integers from 1 to n in ascending order, you need to find the number of derangement it can generate. -

    - -

    -Also, since the answer may be very large, you should return the output mod 109 + 7. -

    - -

    Example 1:
    -

    -Input: 3
    -Output: 2
    -Explanation: The original array is [1,2,3]. The two derangements are [2,3,1] and [3,1,2].
    -
    -

    - -

    Note:
    -n is in the range of [1, 106]. -

    ### Related Topics [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/find-the-difference/README.md b/problems/find-the-difference/README.md index ce602c5ec..4f2cd24a5 100644 --- a/problems/find-the-difference/README.md +++ b/problems/find-the-difference/README.md @@ -59,6 +59,8 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Single Number](../single-number) (Easy) diff --git a/problems/find-the-distance-value-between-two-arrays/README.md b/problems/find-the-distance-value-between-two-arrays/README.md index b1ec13c0d..862061d4c 100644 --- a/problems/find-the-distance-value-between-two-arrays/README.md +++ b/problems/find-the-distance-value-between-two-arrays/README.md @@ -64,6 +64,9 @@ For arr1[2]=8 we have: ### Related Topics [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/find-the-duplicate-number/README.md b/problems/find-the-duplicate-number/README.md index 66ea72faa..963570c1e 100644 --- a/problems/find-the-duplicate-number/README.md +++ b/problems/find-the-duplicate-number/README.md @@ -50,6 +50,7 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/find-the-highest-altitude/README.md b/problems/find-the-highest-altitude/README.md index d2c7c859d..b67880b44 100644 --- a/problems/find-the-highest-altitude/README.md +++ b/problems/find-the-highest-altitude/README.md @@ -43,6 +43,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/find-the-index-of-the-large-integer/README.md b/problems/find-the-index-of-the-large-integer/README.md index ba1049221..64e335f8f 100644 --- a/problems/find-the-index-of-the-large-integer/README.md +++ b/problems/find-the-index-of-the-large-integer/README.md @@ -14,7 +14,9 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Interactive](../../tag/interactive/README.md)] ### Hints
    diff --git a/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md index 0b694d57e..f115bd5f2 100644 --- a/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md +++ b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md @@ -60,7 +60,10 @@ ### Related Topics - [[Heap](../../tag/heap/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/find-the-longest-substring-containing-vowels-in-even-counts/README.md b/problems/find-the-longest-substring-containing-vowels-in-even-counts/README.md index d0832f0a3..686360ad1 100644 --- a/problems/find-the-longest-substring-containing-vowels-in-even-counts/README.md +++ b/problems/find-the-longest-substring-containing-vowels-in-even-counts/README.md @@ -47,7 +47,10 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md b/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md index 1e62f99b4..5503561a2 100644 --- a/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md +++ b/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md @@ -55,7 +55,6 @@ For k = 7 we can use 2 + 5 = 7.
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] - [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/find-the-missing-ids/README.md b/problems/find-the-missing-ids/README.md index c98123659..f3802ddc8 100644 --- a/problems/find-the-missing-ids/README.md +++ b/problems/find-the-missing-ids/README.md @@ -12,3 +12,6 @@ ## [1613. Find the Missing IDs (Medium)](https://leetcode.com/problems/find-the-missing-ids "找到遗失的ID") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/find-the-most-competitive-subsequence/README.md b/problems/find-the-most-competitive-subsequence/README.md index 1672cf137..2a2156173 100644 --- a/problems/find-the-most-competitive-subsequence/README.md +++ b/problems/find-the-most-competitive-subsequence/README.md @@ -44,9 +44,9 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] - [[Heap](../../tag/heap/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints
    diff --git a/problems/find-the-quiet-students-in-all-exams/README.md b/problems/find-the-quiet-students-in-all-exams/README.md index 7ad2fd8bf..74d7ae0dd 100644 --- a/problems/find-the-quiet-students-in-all-exams/README.md +++ b/problems/find-the-quiet-students-in-all-exams/README.md @@ -12,3 +12,6 @@ ## [1412. Find the Quiet Students in All Exams (Hard)](https://leetcode.com/problems/find-the-quiet-students-in-all-exams "查找成绩处于中游的学生") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/find-the-shortest-superstring/README.md b/problems/find-the-shortest-superstring/README.md index 40948a115..970d892fd 100644 --- a/problems/find-the-shortest-superstring/README.md +++ b/problems/find-the-shortest-superstring/README.md @@ -42,4 +42,8 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] diff --git a/problems/find-the-smallest-divisor-given-a-threshold/README.md b/problems/find-the-smallest-divisor-given-a-threshold/README.md index 71534f890..b8d22252c 100644 --- a/problems/find-the-smallest-divisor-given-a-threshold/README.md +++ b/problems/find-the-smallest-divisor-given-a-threshold/README.md @@ -58,6 +58,7 @@ If the divisor is 4 we can get a sum of 7 (1+1+2+3) and if the divisor is 5 the ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] ### Hints diff --git a/problems/find-the-start-and-end-number-of-continuous-ranges/README.md b/problems/find-the-start-and-end-number-of-continuous-ranges/README.md index cc874b923..824130f86 100644 --- a/problems/find-the-start-and-end-number-of-continuous-ranges/README.md +++ b/problems/find-the-start-and-end-number-of-continuous-ranges/README.md @@ -11,47 +11,7 @@ ## [1285. Find the Start and End Number of Continuous Ranges (Medium)](https://leetcode.com/problems/find-the-start-and-end-number-of-continuous-ranges "找到连续区间的开始和结束数字") -

    Table: Logs

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| log_id        | int     |
    -+---------------+---------+
    -id is the primary key for this table.
    -Each row of this table contains the ID in a log Table.
    -
    -Since some IDs have been removed from Logs. Write an SQL query to find the start and end number of continuous ranges in table Logs. -Order the result table by start_id. - -The query result format is in the following example: -
    -Logs table:
    -+------------+
    -| log_id     |
    -+------------+
    -| 1          |
    -| 2          |
    -| 3          |
    -| 7          |
    -| 8          |
    -| 10         |
    -+------------+
    -
    -Result table:
    -+------------+--------------+
    -| start_id   | end_id       |
    -+------------+--------------+
    -| 1          | 3            |
    -| 7          | 8            |
    -| 10         | 10           |
    -+------------+--------------+
    -The result table should contain all ranges in table Logs.
    -From 1 to 3 is contained in the table.
    -From 4 to 6 is missing in the table
    -From 7 to 8 is contained in the table.
    -Number 9 is missing in the table.
    -Number 10 is contained in the table.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/find-the-student-that-will-replace-the-chalk/README.md b/problems/find-the-student-that-will-replace-the-chalk/README.md new file mode 100644 index 000000000..e86b38815 --- /dev/null +++ b/problems/find-the-student-that-will-replace-the-chalk/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../check-if-all-the-integers-in-a-range-are-covered "Check if All the Integers in a Range Are Covered") +                 +[Next >](../largest-magic-square "Largest Magic Square") + +## [1894. Find the Student that Will Replace the Chalk (Medium)](https://leetcode.com/problems/find-the-student-that-will-replace-the-chalk "找到需要补充粉笔的学生编号") + +

    There are n students in a class numbered from 0 to n - 1. The teacher will give each student a problem starting with the student number 0, then the student number 1, and so on until the teacher reaches the student number n - 1. After that, the teacher will restart the process, starting with the student number 0 again.

    + +

    You are given a 0-indexed integer array chalk and an integer k. There are initially k pieces of chalk. When the student number i is given a problem to solve, they will use chalk[i] pieces of chalk to solve that problem. However, if the current number of chalk pieces is strictly less than chalk[i], then the student number i will be asked to replace the chalk.

    + +

    Return the index of the student that will replace the chalk.

    + +

     

    +

    Example 1:

    + +
    +Input: chalk = [5,1,5], k = 22
    +Output: 0
    +Explanation: The students go in turns as follows:
    +- Student number 0 uses 5 chalk, so k = 17.
    +- Student number 1 uses 1 chalk, so k = 16.
    +- Student number 2 uses 5 chalk, so k = 11.
    +- Student number 0 uses 5 chalk, so k = 6.
    +- Student number 1 uses 1 chalk, so k = 5.
    +- Student number 2 uses 5 chalk, so k = 0.
    +Student number 0 does not have enough chalk, so they will have to replace it.
    + +

    Example 2:

    + +
    +Input: chalk = [3,4,1,2], k = 25
    +Output: 1
    +Explanation: The students go in turns as follows:
    +- Student number 0 uses 3 chalk so k = 22.
    +- Student number 1 uses 4 chalk so k = 18.
    +- Student number 2 uses 1 chalk so k = 17.
    +- Student number 3 uses 2 chalk so k = 15.
    +- Student number 0 uses 3 chalk so k = 12.
    +- Student number 1 uses 4 chalk so k = 8.
    +- Student number 2 uses 1 chalk so k = 7.
    +- Student number 3 uses 2 chalk so k = 5.
    +- Student number 0 uses 3 chalk so k = 2.
    +Student number 1 does not have enough chalk, so they will have to replace it.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • chalk.length == n
    • +
    • 1 <= n <= 105
    • +
    • 1 <= chalk[i] <= 105
    • +
    • 1 <= k <= 109
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Subtract the sum of chalk[i] from k until k is less than that sum +
    + +
    +Hint 2 +Now just iterate over the array if chalk[i] is less thank k this is your answer otherwise this i is the answer +
    diff --git a/problems/find-the-subtasks-that-did-not-execute/README.md b/problems/find-the-subtasks-that-did-not-execute/README.md index 789fd731c..92270fe9b 100644 --- a/problems/find-the-subtasks-that-did-not-execute/README.md +++ b/problems/find-the-subtasks-that-did-not-execute/README.md @@ -12,3 +12,6 @@ ## [1767. Find the Subtasks That Did Not Execute (Hard)](https://leetcode.com/problems/find-the-subtasks-that-did-not-execute "寻找没有被执行的任务对") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/find-the-team-size/README.md b/problems/find-the-team-size/README.md index 8c56cf681..a85c4abf3 100644 --- a/problems/find-the-team-size/README.md +++ b/problems/find-the-team-size/README.md @@ -11,47 +11,7 @@ ## [1303. Find the Team Size (Easy)](https://leetcode.com/problems/find-the-team-size "求团队人数") -

    Table: Employee

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| employee_id   | int     |
    -| team_id       | int     |
    -+---------------+---------+
    -employee_id is the primary key for this table.
    -Each row of this table contains the ID of each employee and their respective team.
    -
    -Write an SQL query to find the team size of each of the employees. -Return result table in any order. - -The query result format is in the following example: -
    -Employee Table:
    -+-------------+------------+
    -| employee_id | team_id    |
    -+-------------+------------+
    -|     1       |     8      |
    -|     2       |     8      |
    -|     3       |     8      |
    -|     4       |     7      |
    -|     5       |     9      |
    -|     6       |     9      |
    -+-------------+------------+
    -Result table:
    -+-------------+------------+
    -| employee_id | team_size  |
    -+-------------+------------+
    -|     1       |     3      |
    -|     2       |     3      |
    -|     3       |     3      |
    -|     4       |     1      |
    -|     5       |     2      |
    -|     6       |     2      |
    -+-------------+------------+
    -Employees with Id 1,2,3 are part of a team with team_id = 8.
    -Employees with Id 4 is part of a team with team_id = 7.
    -Employees with Id 5,6 are part of a team with team_id = 9.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/find-the-town-judge/README.md b/problems/find-the-town-judge/README.md index d45495418..fa9e63116 100644 --- a/problems/find-the-town-judge/README.md +++ b/problems/find-the-town-judge/README.md @@ -75,6 +75,8 @@ ### Related Topics [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions 1. [Find the Celebrity](../find-the-celebrity) (Medium) diff --git a/problems/find-the-winner-of-an-array-game/README.md b/problems/find-the-winner-of-an-array-game/README.md index 9d5feff5a..e8e735030 100644 --- a/problems/find-the-winner-of-an-array-game/README.md +++ b/problems/find-the-winner-of-an-array-game/README.md @@ -68,6 +68,7 @@ So we can see that 4 rounds will be played and 5 is the winner because it wins 2 ### Related Topics [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/find-the-winner-of-the-circular-game/README.md b/problems/find-the-winner-of-the-circular-game/README.md index 3c844799e..383ef9c03 100644 --- a/problems/find-the-winner-of-the-circular-game/README.md +++ b/problems/find-the-winner-of-the-circular-game/README.md @@ -58,7 +58,10 @@ ### Related Topics + [[Recursion](../../tag/recursion/README.md)] [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/find-total-time-spent-by-each-employee/README.md b/problems/find-total-time-spent-by-each-employee/README.md index 6c471c2c2..f0f8b247f 100644 --- a/problems/find-total-time-spent-by-each-employee/README.md +++ b/problems/find-total-time-spent-by-each-employee/README.md @@ -12,3 +12,6 @@ ## [1741. Find Total Time Spent by Each Employee (Easy)](https://leetcode.com/problems/find-total-time-spent-by-each-employee "查找每个员工花费的总时间") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md b/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md index 6a193fa5a..028421234 100644 --- a/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md +++ b/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md @@ -68,7 +68,11 @@ ### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/find-users-with-valid-e-mails/README.md b/problems/find-users-with-valid-e-mails/README.md index 40adfeae3..a7378ffad 100644 --- a/problems/find-users-with-valid-e-mails/README.md +++ b/problems/find-users-with-valid-e-mails/README.md @@ -12,3 +12,6 @@ ## [1517. Find Users With Valid E-Mails (Easy)](https://leetcode.com/problems/find-users-with-valid-e-mails "查找拥有有效邮箱的用户") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/find-valid-matrix-given-row-and-column-sums/README.md b/problems/find-valid-matrix-given-row-and-column-sums/README.md index f2970cfeb..ac285d0b9 100644 --- a/problems/find-valid-matrix-given-row-and-column-sums/README.md +++ b/problems/find-valid-matrix-given-row-and-column-sums/README.md @@ -77,6 +77,8 @@ Another possible matrix is: [[1,2], ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/find-winner-on-a-tic-tac-toe-game/README.md b/problems/find-winner-on-a-tic-tac-toe-game/README.md index 25d232e87..c8d6f3722 100644 --- a/problems/find-winner-on-a-tic-tac-toe-game/README.md +++ b/problems/find-winner-on-a-tic-tac-toe-game/README.md @@ -88,6 +88,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/find-words-that-can-be-formed-by-characters/README.md b/problems/find-words-that-can-be-formed-by-characters/README.md index 331d274a2..d3422c5c4 100644 --- a/problems/find-words-that-can-be-formed-by-characters/README.md +++ b/problems/find-words-that-can-be-formed-by-characters/README.md @@ -50,6 +50,7 @@ The strings that can be formed are "hello" and "world" so th ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/find-xor-sum-of-all-pairs-bitwise-and/README.md b/problems/find-xor-sum-of-all-pairs-bitwise-and/README.md index 283ea5573..8eae2dff9 100644 --- a/problems/find-xor-sum-of-all-pairs-bitwise-and/README.md +++ b/problems/find-xor-sum-of-all-pairs-bitwise-and/README.md @@ -50,6 +50,8 @@ The XOR sum = 0 XOR 1 XOR 2 XOR 0 XOR 2 XOR 1 = 0. ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] ### Hints diff --git a/problems/finding-mk-average/README.md b/problems/finding-mk-average/README.md index 2b1fc55c2..0600c9f54 100644 --- a/problems/finding-mk-average/README.md +++ b/problems/finding-mk-average/README.md @@ -67,9 +67,10 @@ obj.calculateMKAverage(); // The last 3 elements are [5,5,5]. ### Related Topics - [[Heap](../../tag/heap/README.md)] [[Design](../../tag/design/README.md)] [[Queue](../../tag/queue/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/finding-pairs-with-a-certain-sum/README.md b/problems/finding-pairs-with-a-certain-sum/README.md index f6da1c307..eec73339b 100644 --- a/problems/finding-pairs-with-a-certain-sum/README.md +++ b/problems/finding-pairs-with-a-certain-sum/README.md @@ -63,8 +63,8 @@ findSumPairs.count(7); // return 11; pairs (2,1), (2,2), (2,4), (3,1), (3,2), ( ### Related Topics [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Ordered Map](../../tag/ordered-map/README.md)] ### Hints
    diff --git a/problems/finding-the-users-active-minutes/README.md b/problems/finding-the-users-active-minutes/README.md index 649880ff5..6d76694ed 100644 --- a/problems/finding-the-users-active-minutes/README.md +++ b/problems/finding-the-users-active-minutes/README.md @@ -56,6 +56,7 @@ Hence, answer[1] = 1, answer[2] = 1, and the remaining values are 0. ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] ### Hints diff --git a/problems/first-bad-version/README.md b/problems/first-bad-version/README.md index 1d83ec73a..86a060793 100644 --- a/problems/first-bad-version/README.md +++ b/problems/first-bad-version/README.md @@ -46,6 +46,7 @@ Then 4 is the first bad version. ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] + [[Interactive](../../tag/interactive/README.md)] ### Similar Questions 1. [Find First and Last Position of Element in Sorted Array](../find-first-and-last-position-of-element-in-sorted-array) (Medium) diff --git a/problems/first-missing-positive/README.md b/problems/first-missing-positive/README.md index 070243466..ba04ceb3b 100644 --- a/problems/first-missing-positive/README.md +++ b/problems/first-missing-positive/README.md @@ -36,6 +36,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions 1. [Missing Number](../missing-number) (Easy) diff --git a/problems/first-unique-character-in-a-string/README.md b/problems/first-unique-character-in-a-string/README.md index 333d0a2da..c58d7222c 100644 --- a/problems/first-unique-character-in-a-string/README.md +++ b/problems/first-unique-character-in-a-string/README.md @@ -11,7 +11,7 @@ ## [387. First Unique Character in a String (Easy)](https://leetcode.com/problems/first-unique-character-in-a-string "字符串中的第一个唯一字符") -

    Given a string s, return the first non-repeating character in it and return its index. If it does not exist, return -1.

    +

    Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1.

     

    Example 1:

    @@ -33,8 +33,10 @@ ### Related Topics + [[Queue](../../tag/queue/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] ### Similar Questions 1. [Sort Characters By Frequency](../sort-characters-by-frequency) (Medium) diff --git a/problems/first-unique-number/README.md b/problems/first-unique-number/README.md index 2f0e27ccc..fca55d778 100644 --- a/problems/first-unique-number/README.md +++ b/problems/first-unique-number/README.md @@ -15,7 +15,10 @@ ### Related Topics [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] ### Hints
    diff --git a/problems/fix-names-in-a-table/README.md b/problems/fix-names-in-a-table/README.md index e7f1521dc..838558462 100644 --- a/problems/fix-names-in-a-table/README.md +++ b/problems/fix-names-in-a-table/README.md @@ -12,3 +12,6 @@ ## [1667. Fix Names in a Table (Easy)](https://leetcode.com/problems/fix-names-in-a-table "修复表中的名字") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/fix-product-name-format/README.md b/problems/fix-product-name-format/README.md index fe5827009..6393a7cc7 100644 --- a/problems/fix-product-name-format/README.md +++ b/problems/fix-product-name-format/README.md @@ -12,3 +12,6 @@ ## [1543. Fix Product Name Format (Easy)](https://leetcode.com/problems/fix-product-name-format "产品名称格式修复") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/fixed-point/README.md b/problems/fixed-point/README.md index d3983ae1a..aed962a45 100644 --- a/problems/fixed-point/README.md +++ b/problems/fixed-point/README.md @@ -11,45 +11,7 @@ ## [1064. Fixed Point (Easy)](https://leetcode.com/problems/fixed-point "不动点") -

    Given an array A of distinct integers sorted in ascending order, return the smallest index i that satisfies A[i] == i.  Return -1 if no such i exists.

    -

     

    - -

    Example 1:

    - -
    -Input: [-10,-5,0,3,7]
    -Output: 3
    -Explanation: 
    -For the given array, A[0] = -10, A[1] = -5, A[2] = 0, A[3] = 3, thus the output is 3.
    -
    - -

    Example 2:

    - -
    -Input: [0,2,5,8,17]
    -Output: 0
    -Explanation: 
    -A[0] = 0, thus the output is 0.
    -
    - -

    Example 3:

    - -
    -Input: [-10,-5,3,4,7,9]
    -Output: -1
    -Explanation: 
    -There is no such i that A[i] = i, thus the output is -1.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= A.length < 10^4
    2. -
    3. -10^9 <= A[i] <= 10^9
    4. -
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/fizz-buzz-multithreaded/README.md b/problems/fizz-buzz-multithreaded/README.md index 0f3ef15ab..e73fb106d 100644 --- a/problems/fizz-buzz-multithreaded/README.md +++ b/problems/fizz-buzz-multithreaded/README.md @@ -11,32 +11,57 @@ ## [1195. Fizz Buzz Multithreaded (Medium)](https://leetcode.com/problems/fizz-buzz-multithreaded "交替打印字符串") -

    Write a program that outputs the string representation of numbers from 1 to n, however:

    +

    You have the four functions:

      -
    • If the number is divisible by 3, output "fizz".
    • -
    • If the number is divisible by 5, output "buzz".
    • -
    • If the number is divisible by both 3 and 5, output "fizzbuzz".
    • +
    • printFizz that prints the word "Fizz" to the console,
    • +
    • printBuzz that prints the word "Buzz" to the console,
    • +
    • printFizzBuzz that prints the word "FizzBuzz" to the console, and
    • +
    • printNumber that prints a given integer to the console.
    -

    For example, for n = 15, we output: 1, 2, fizz, 4, buzz, fizz, 7, 8, fizz, buzz, 11, fizz, 13, 14, fizzbuzz.

    +

    You are given an instance of the class FizzBuzz that has four functions: fizz, buzz, fizzbuzz and number. The same instance of FizzBuzz will be passed to four different threads:

    -

    Suppose you are given the following code:

    +
      +
    • Thread A: calls fizz() that should output the word "Fizz".
    • +
    • Thread B: calls buzz() that should output the word "Buzz".
    • +
    • Thread C: calls fizzbuzz() that should output the word "FizzBuzz".
    • +
    • Thread D: calls number() that should only output the integers.
    • +
    + +

    Modify the given class to output the series [1, 2, "Fizz", 4, "Buzz", ...] where the ith token (1-indexed) of the series is:

    + +
      +
    • "FizzBuzz" if i is divisible by 3 and 5,
    • +
    • "Fizz" if i is divisible by 3 and not 5,
    • +
    • "Buzz" if i is divisible by 5 and not 3, or
    • +
    • i if i is not divisible by 3 or 5.
    • +
    -
    -class FizzBuzz {
    -  public FizzBuzz(int n) { ... }               // constructor
    -  public void fizz(printFizz) { ... }          // only output "fizz"
    -  public void buzz(printBuzz) { ... }          // only output "buzz"
    -  public void fizzbuzz(printFizzBuzz) { ... }  // only output "fizzbuzz"
    -  public void number(printNumber) { ... }      // only output the numbers
    -}
    +

    Implement the FizzBuzz class:

    -

    Implement a multithreaded version of FizzBuzz with four threads. The same instance of FizzBuzz will be passed to four different threads:

    +
      +
    • FizzBuzz(int n) Initializes the object with the number n that represents the length of the sequence that should be printed.
    • +
    • void fizz(printFizz) Calls printFizz to output "Fizz".
    • +
    • void buzz(printBuzz) Calls printBuzz to output "Buzz".
    • +
    • void fizzbuzz(printFizzBuzz) Calls printFizzBuzz to output "FizzBuzz".
    • +
    • void number(printNumber) Calls printnumber to output the numbers.
    • +
    + +

     

    +

    Example 1:

    +
    Input: n = 15
    +Output: [1,2,"fizz",4,"buzz","fizz",7,8,"fizz","buzz",11,"fizz",13,14,"fizzbuzz"]
    +

    Example 2:

    +
    Input: n = 5
    +Output: [1,2,"fizz",4,"buzz"]
    +
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 50
    • +
    -
      -
    1. Thread A will call fizz() to check for divisibility of 3 and outputs fizz.
    2. -
    3. Thread B will call buzz() to check for divisibility of 5 and outputs buzz.
    4. -
    5. Thread C will call fizzbuzz() to check for divisibility of 3 and 5 and outputs fizzbuzz.
    6. -
    7. Thread D will call number() which should only output the numbers.
    8. -
    +### Related Topics + [[Concurrency](../../tag/concurrency/README.md)] diff --git a/problems/fizz-buzz/README.md b/problems/fizz-buzz/README.md index 1c28531dc..228f0fff1 100644 --- a/problems/fizz-buzz/README.md +++ b/problems/fizz-buzz/README.md @@ -37,3 +37,8 @@
    • 1 <= n <= 104
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/flatten-2d-vector/README.md b/problems/flatten-2d-vector/README.md index 7a8917757..c653eda1c 100644 --- a/problems/flatten-2d-vector/README.md +++ b/problems/flatten-2d-vector/README.md @@ -11,41 +11,13 @@ ## [251. Flatten 2D Vector (Medium)](https://leetcode.com/problems/flatten-2d-vector "展开二维向量") -

    Design and implement an iterator to flatten a 2d vector. It should support the following operations: next and hasNext.

    -

     

    - -

    Example:

    - -
    -Vector2D iterator = new Vector2D([[1,2],[3],[4]]);
    -
    -iterator.next(); // return 1
    -iterator.next(); // return 2
    -iterator.next(); // return 3
    -iterator.hasNext(); // return true
    -iterator.hasNext(); // return true
    -iterator.next(); // return 4
    -iterator.hasNext(); // return false
    -
    - -

     

    - -

    Notes:

    - -
      -
    1. Please remember to RESET your class variables declared in Vector2D, as static/class variables are persisted across multiple test cases. Please see here for more details.
    2. -
    3. You may assume that next() call will always be valid, that is, there will be at least a next element in the 2d vector when next() is called.
    4. -
    - -

     

    - -

    Follow up:

    - -

    As an added challenge, try to code it using only iterators in C++ or iterators in Java.

    ### Related Topics [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Iterator](../../tag/iterator/README.md)] ### Similar Questions 1. [Binary Search Tree Iterator](../binary-search-tree-iterator) (Medium) diff --git a/problems/flatten-a-multilevel-doubly-linked-list/README.md b/problems/flatten-a-multilevel-doubly-linked-list/README.md index cf1171c63..9bcd39aa9 100644 --- a/problems/flatten-a-multilevel-doubly-linked-list/README.md +++ b/problems/flatten-a-multilevel-doubly-linked-list/README.md @@ -96,8 +96,9 @@ After flattening the multilevel linked list it becomes: ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Doubly-Linked List](../../tag/doubly-linked-list/README.md)] ### Similar Questions 1. [Flatten Binary Tree to Linked List](../flatten-binary-tree-to-linked-list) (Medium) diff --git a/problems/flatten-binary-tree-to-linked-list/README.md b/problems/flatten-binary-tree-to-linked-list/README.md index 7613f1785..2fed5e2d1 100644 --- a/problems/flatten-binary-tree-to-linked-list/README.md +++ b/problems/flatten-binary-tree-to-linked-list/README.md @@ -52,8 +52,11 @@ Follow up: Can you flatten the tree in-place (with O(1) extra space)? ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Flatten a Multilevel Doubly Linked List](../flatten-a-multilevel-doubly-linked-list) (Medium) diff --git a/problems/flatten-nested-list-iterator/README.md b/problems/flatten-nested-list-iterator/README.md index e4ef83b9d..703ee263e 100644 --- a/problems/flatten-nested-list-iterator/README.md +++ b/problems/flatten-nested-list-iterator/README.md @@ -60,7 +60,11 @@ return res ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] + [[Iterator](../../tag/iterator/README.md)] ### Similar Questions 1. [Flatten 2D Vector](../flatten-2d-vector) (Medium) diff --git a/problems/flip-binary-tree-to-match-preorder-traversal/README.md b/problems/flip-binary-tree-to-match-preorder-traversal/README.md index f5288b36a..a1fb9274b 100644 --- a/problems/flip-binary-tree-to-match-preorder-traversal/README.md +++ b/problems/flip-binary-tree-to-match-preorder-traversal/README.md @@ -57,4 +57,5 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/flip-columns-for-maximum-number-of-equal-rows/README.md b/problems/flip-columns-for-maximum-number-of-equal-rows/README.md index 836d48166..3e99da15b 100644 --- a/problems/flip-columns-for-maximum-number-of-equal-rows/README.md +++ b/problems/flip-columns-for-maximum-number-of-equal-rows/README.md @@ -53,7 +53,9 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/flip-equivalent-binary-trees/README.md b/problems/flip-equivalent-binary-trees/README.md index 556a2d7d6..ee433b677 100644 --- a/problems/flip-equivalent-binary-trees/README.md +++ b/problems/flip-equivalent-binary-trees/README.md @@ -64,3 +64,5 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/flip-game-ii/README.md b/problems/flip-game-ii/README.md index b35d2be9a..c4f1e6136 100644 --- a/problems/flip-game-ii/README.md +++ b/problems/flip-game-ii/README.md @@ -11,24 +11,14 @@ ## [294. Flip Game II (Medium)](https://leetcode.com/problems/flip-game-ii "翻转游戏 II") -

    You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip two consecutive "++" into "--". The game ends when a person can no longer make a move and therefore the other person will be the winner.

    -

    Write a function to determine if the starting player can guarantee a win.

    - -

    Example:

    - -
    -Input: s = "++++"
    -Output: true 
    -Explanation: The starting player can guarantee a win by flipping the middle "++" to become "+--+".
    -
    - -

    Follow up:
    -Derive your algorithm's runtime complexity.

    ### Related Topics - [[Minimax](../../tag/minimax/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] ### Similar Questions 1. [Nim Game](../nim-game) (Easy) diff --git a/problems/flip-game/README.md b/problems/flip-game/README.md index 5a155f02b..84ef9580a 100644 --- a/problems/flip-game/README.md +++ b/problems/flip-game/README.md @@ -11,23 +11,7 @@ ## [293. Flip Game (Easy)](https://leetcode.com/problems/flip-game "翻转游戏") -

    You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip two consecutive "++" into "--". The game ends when a person can no longer make a move and therefore the other person will be the winner.

    -

    Write a function to compute all possible states of the string after one valid move.

    - -

    Example:

    - -
    -Input: s = "++++"
    -Output: 
    -[
    -  "--++",
    -  "+--+",
    -  "++--"
    -]
    -
    - -

    Note: If there is no valid move, return an empty list [].

    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/flip-string-to-monotone-increasing/README.md b/problems/flip-string-to-monotone-increasing/README.md index cbd4407c6..4cb102280 100644 --- a/problems/flip-string-to-monotone-increasing/README.md +++ b/problems/flip-string-to-monotone-increasing/README.md @@ -59,4 +59,5 @@ ### Related Topics - [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/flipping-an-image/README.md b/problems/flipping-an-image/README.md index 5bf0dcf57..dee216608 100644 --- a/problems/flipping-an-image/README.md +++ b/problems/flipping-an-image/README.md @@ -56,3 +56,6 @@ Then invert the image: [[1,1,0,0],[0,1,1,0],[0,0,0,1],[1,0,1,0]] ### Related Topics [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/flood-fill/README.md b/problems/flood-fill/README.md index cb7e45206..19f075b6b 100644 --- a/problems/flood-fill/README.md +++ b/problems/flood-fill/README.md @@ -44,12 +44,15 @@ Note the bottom corner is not colored 2, because it is not 4-directionally conne
  • n == image[i].length
  • 1 <= m, n <= 50
  • 0 <= image[i][j], newColor < 216
  • -
  • 0 <= sr <= m
  • -
  • 0 <= sc <= n
  • +
  • 0 <= sr < m
  • +
  • 0 <= sc < n
  • ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Island Perimeter](../island-perimeter) (Easy) diff --git a/problems/flower-planting-with-no-adjacent/README.md b/problems/flower-planting-with-no-adjacent/README.md index 633e1d140..18eb5ebdd 100644 --- a/problems/flower-planting-with-no-adjacent/README.md +++ b/problems/flower-planting-with-no-adjacent/README.md @@ -59,6 +59,8 @@ Hence, [1,2,3] is a valid answer. Other valid answers include [1,2,4], [1,4,2], ### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] ### Hints diff --git a/problems/form-array-by-concatenating-subarrays-of-another-array/README.md b/problems/form-array-by-concatenating-subarrays-of-another-array/README.md index 70d5d05e6..2130761a9 100644 --- a/problems/form-array-by-concatenating-subarrays-of-another-array/README.md +++ b/problems/form-array-by-concatenating-subarrays-of-another-array/README.md @@ -61,6 +61,7 @@ They share a common elements nums[4] (0-indexed). ### Related Topics [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[String Matching](../../tag/string-matching/README.md)] ### Hints
    diff --git a/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md b/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md index 957fe3cef..64067ce77 100644 --- a/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md +++ b/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md @@ -75,7 +75,7 @@ ### Related Topics - [[String](../../tag/string/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/four-divisors/README.md b/problems/four-divisors/README.md index 72d2bfa49..f6da14c3f 100644 --- a/problems/four-divisors/README.md +++ b/problems/four-divisors/README.md @@ -37,6 +37,7 @@ The answer is the sum of divisors of 21 only. ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] ### Hints diff --git a/problems/fraction-addition-and-subtraction/README.md b/problems/fraction-addition-and-subtraction/README.md index 704e9ff44..1c8149557 100644 --- a/problems/fraction-addition-and-subtraction/README.md +++ b/problems/fraction-addition-and-subtraction/README.md @@ -57,6 +57,8 @@ ### Related Topics [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Similar Questions 1. [Solve the Equation](../solve-the-equation) (Medium) diff --git a/problems/fraction-to-recurring-decimal/README.md b/problems/fraction-to-recurring-decimal/README.md index d465cc7ea..d038a73c0 100644 --- a/problems/fraction-to-recurring-decimal/README.md +++ b/problems/fraction-to-recurring-decimal/README.md @@ -47,6 +47,7 @@ ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/freedom-trail/README.md b/problems/freedom-trail/README.md index 7063a7b2d..e88bcb965 100644 --- a/problems/freedom-trail/README.md +++ b/problems/freedom-trail/README.md @@ -54,6 +54,7 @@ So the final output is 4. ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/frequency-of-the-most-frequent-element/README.md b/problems/frequency-of-the-most-frequent-element/README.md index d8ae57fc8..31f99ec46 100644 --- a/problems/frequency-of-the-most-frequent-element/README.md +++ b/problems/frequency-of-the-most-frequent-element/README.md @@ -54,7 +54,10 @@ Explanation: Increment the first element three times and the second ele ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/friend-requests-i-overall-acceptance-rate/README.md b/problems/friend-requests-i-overall-acceptance-rate/README.md index ea607c203..c5e128e9b 100644 --- a/problems/friend-requests-i-overall-acceptance-rate/README.md +++ b/problems/friend-requests-i-overall-acceptance-rate/README.md @@ -11,66 +11,10 @@ ## [597. Friend Requests I: Overall Acceptance Rate (Easy)](https://leetcode.com/problems/friend-requests-i-overall-acceptance-rate "好友申请 I:总体通过率") -In social network like Facebook or Twitter, people send friend requests and accept others’ requests as well. Now given two tables as below: -

     

    -Table: friend_request -
    -| sender_id | send_to_id |request_date|
    -|-----------|------------|------------|
    -| 1         | 2          | 2016_06-01 |
    -| 1         | 3          | 2016_06-01 |
    -| 1         | 4          | 2016_06-01 |
    -| 2         | 3          | 2016_06-02 |
    -| 3         | 4          | 2016-06-09 |
    -
    -

     

    -Table: request_accepted - -
    -| requester_id | accepter_id |accept_date |
    -|--------------|-------------|------------|
    -| 1            | 2           | 2016_06-03 |
    -| 1            | 3           | 2016-06-08 |
    -| 2            | 3           | 2016-06-08 |
    -| 3            | 4           | 2016-06-09 |
    -| 3            | 4           | 2016-06-10 |
    -
    - -

     

    -Write a query to find the overall acceptance rate of requests rounded to 2 decimals, which is the number of acceptance divide the number of requests. - -

     

    -For the sample data above, your query should return the following result. - -

     

    - -
    -|accept_rate|
    -|-----------|
    -|       0.80|
    -
    - -

     

    -Note: - -
      -
    • The accepted requests are not necessarily from the table friend_request. In this case, you just need to simply count the total accepted requests (no matter whether they are in the original requests), and divide it by the number of requests to get the acceptance rate.
    • -
    • It is possible that a sender sends multiple requests to the same receiver, and a request could be accepted more than once. In this case, the ‘duplicated’ requests or acceptances are only counted once.
    • -
    • If there is no requests at all, you should return 0.00 as the accept_rate.
    • -
    - -

     

    -Explanation: There are 4 unique accepted requests, and there are 5 requests in total. So the rate is 0.80. - -

     

    -Follow-up: - -
      -
    • Can you write a query to return the accept rate but for every month?
    • -
    • How about the cumulative accept rate for every day?
    • -
    +### Related Topics + [[Database](../../tag/database/README.md)] ### Hints
    diff --git a/problems/friend-requests-ii-who-has-the-most-friends/README.md b/problems/friend-requests-ii-who-has-the-most-friends/README.md index 64f9ceb5d..6f4e8426d 100644 --- a/problems/friend-requests-ii-who-has-the-most-friends/README.md +++ b/problems/friend-requests-ii-who-has-the-most-friends/README.md @@ -11,47 +11,10 @@ ## [602. Friend Requests II: Who Has the Most Friends (Medium)](https://leetcode.com/problems/friend-requests-ii-who-has-the-most-friends "好友申请 II :谁有最多的好友") -

    In social network like Facebook or Twitter, people send friend requests and accept others' requests as well.

    -

     

    -

    Table request_accepted

    - -
    -+--------------+-------------+------------+
    -| requester_id | accepter_id | accept_date|
    -|--------------|-------------|------------|
    -| 1            | 2           | 2016_06-03 |
    -| 1            | 3           | 2016-06-08 |
    -| 2            | 3           | 2016-06-08 |
    -| 3            | 4           | 2016-06-09 |
    -+--------------+-------------+------------+
    -This table holds the data of friend acceptance, while requester_id and accepter_id both are the id of a person.
    -
    - -

     

    - -

    Write a query to find the the people who has most friends and the most friends number under the following rules:

    - -
      -
    • It is guaranteed there is only 1 people having the most friends.
    • -
    • The friend request could only been accepted once, which mean there is no multiple records with the same requester_id and accepter_id value.
    • -
    - -

    For the sample data above, the result is:

    - -
    -Result table:
    -+------+------+
    -| id   | num  |
    -|------|------|
    -| 3    | 3    |
    -+------+------+
    -The person with id '3' is a friend of people '1', '2' and '4', so he has 3 friends in total, which is the most number than any others.
    -
    - -

    Follow-up:
    -In the real world, multiple people could have the same most number of friends, can you find all these people in this case?

    +### Related Topics + [[Database](../../tag/database/README.md)] ### Hints
    diff --git a/problems/friendly-movies-streamed-last-month/README.md b/problems/friendly-movies-streamed-last-month/README.md index 02ce09af0..be49a97f7 100644 --- a/problems/friendly-movies-streamed-last-month/README.md +++ b/problems/friendly-movies-streamed-last-month/README.md @@ -12,3 +12,6 @@ ## [1495. Friendly Movies Streamed Last Month (Easy)](https://leetcode.com/problems/friendly-movies-streamed-last-month "上月播放的儿童适宜电影") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/friends-of-appropriate-ages/README.md b/problems/friends-of-appropriate-ages/README.md index 477679d99..e86686482 100644 --- a/problems/friends-of-appropriate-ages/README.md +++ b/problems/friends-of-appropriate-ages/README.md @@ -61,3 +61,6 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/frog-jump/README.md b/problems/frog-jump/README.md index 82971c829..1debc319b 100644 --- a/problems/frog-jump/README.md +++ b/problems/frog-jump/README.md @@ -44,4 +44,5 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/frog-position-after-t-seconds/README.md b/problems/frog-position-after-t-seconds/README.md index a546fd343..e65bc3e3d 100644 --- a/problems/frog-position-after-t-seconds/README.md +++ b/problems/frog-position-after-t-seconds/README.md @@ -59,7 +59,10 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] ### Hints
    diff --git a/problems/fruit-into-baskets/README.md b/problems/fruit-into-baskets/README.md index a42a0ee11..658ca0fad 100644 --- a/problems/fruit-into-baskets/README.md +++ b/problems/fruit-into-baskets/README.md @@ -11,72 +11,62 @@ ## [904. Fruit Into Baskets (Medium)](https://leetcode.com/problems/fruit-into-baskets "水果成篮") -

    In a row of trees, the i-th tree produces fruit with type tree[i].

    +

    You are visiting a farm that has a single row of fruit trees arranged from left to right. The trees are represented by an integer array fruits where fruits[i] is the type of fruit the ith tree produces.

    -

    You start at any tree of your choice, then repeatedly perform the following steps:

    +

    You want to collect as much fruit as possible. However, the owner has some strict rules that you must follow:

    -
      -
    1. Add one piece of fruit from this tree to your baskets.  If you cannot, stop.
    2. -
    3. Move to the next tree to the right of the current tree.  If there is no tree to the right, stop.
    4. -
    +
      +
    • You only have two baskets, and each basket can only hold a single type of fruit. There is no limit on the amount of fruit each basket can hold.
    • +
    • Starting from any tree of your choice, you must pick exactly one fruit from every tree (including the start tree) while moving to the right. The picked fruits must fit in one of your baskets.
    • +
    • Once you reach a tree with fruit that cannot fit in your baskets, you must stop.
    • +
    -

    Note that you do not have any choice after the initial choice of starting tree: you must perform step 1, then step 2, then back to step 1, then step 2, and so on until you stop.

    - -

    You have two baskets, and each basket can carry any quantity of fruit, but you want each basket to only carry one type of fruit each.

    - -

    What is the total amount of fruit you can collect with this procedure?

    +

    Given the integer array fruits, return the maximum number of fruits you can pick.

     

    -

    Example 1:

    -Input: [1,2,1]
    -Output: 3
    -Explanation: We can collect [1,2,1].
    +Input: fruits = [1,2,1]
    +Output: 3
    +Explanation: We can pick from all 3 trees.
     
    -

    Example 2:

    -Input: [0,1,2,2]
    -Output: 3
    -Explanation: We can collect [1,2,2].
    -If we started at the first tree, we would only collect [0, 1].
    +Input: fruits = [0,1,2,2]
    +Output: 3
    +Explanation: We can pick from trees [1,2,2].
    +If we had started at the first tree, we would only pick from trees [0,1].
     
    -

    Example 3:

    -Input: [1,2,3,2,2]
    -Output: 4
    -Explanation: We can collect [2,3,2,2].
    -If we started at the first tree, we would only collect [1, 2].
    +Input: fruits = [1,2,3,2,2]
    +Output: 4
    +Explanation: We can pick from trees [2,3,2,2].
    +If we had started at the first tree, we would only pick from trees [1,2].
     
    -

    Example 4:

    -Input: [3,3,3,1,2,1,1,2,3,3,4]
    -Output: 5
    -Explanation: We can collect [1,2,1,1,2].
    -If we started at the first tree or the eighth tree, we would only collect 4 fruits.
    +Input: fruits = [3,3,3,1,2,1,1,2,3,3,4]
    +Output: 5
    +Explanation: We can pick from trees [1,2,1,1,2].
     

     

    -
    -
    -
    - -

    Note:

    +

    Constraints:

    -
      -
    1. 1 <= tree.length <= 40000
    2. -
    3. 0 <= tree[i] < tree.length
    4. -
    +
      +
    • 1 <= fruits.length <= 105
    • +
    • 0 <= fruits[i] < fruits.length
    • +
    ### Related Topics - [[Two Pointers](../../tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] diff --git a/problems/furthest-building-you-can-reach/README.md b/problems/furthest-building-you-can-reach/README.md index 7b41b7eed..a1caf89c8 100644 --- a/problems/furthest-building-you-can-reach/README.md +++ b/problems/furthest-building-you-can-reach/README.md @@ -63,8 +63,9 @@ It is impossible to go beyond building 4 because you do not have any more bricks ### Related Topics - [[Heap](../../tag/heap/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/game-of-life/README.md b/problems/game-of-life/README.md index 3ad025edb..1353108f0 100644 --- a/problems/game-of-life/README.md +++ b/problems/game-of-life/README.md @@ -59,6 +59,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Similar Questions 1. [Set Matrix Zeroes](../set-matrix-zeroes) (Medium) diff --git a/problems/game-of-nim/README.md b/problems/game-of-nim/README.md new file mode 100644 index 000000000..49664953b --- /dev/null +++ b/problems/game-of-nim/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../count-salary-categories "Count Salary Categories") +                 +[Next >](../remove-one-element-to-make-the-array-strictly-increasing "Remove One Element to Make the Array Strictly Increasing") + +## [1908. Game of Nim (Medium)](https://leetcode.com/problems/game-of-nim "") + + + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Brainteaser](../../tag/brainteaser/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] + +### Hints +
    +Hint 1 +Simulate the game and try all possible moves for each player. +
    diff --git a/problems/game-play-analysis-i/README.md b/problems/game-play-analysis-i/README.md index a736f72a2..c2e5f6bc2 100644 --- a/problems/game-play-analysis-i/README.md +++ b/problems/game-play-analysis-i/README.md @@ -11,49 +11,10 @@ ## [511. Game Play Analysis I (Easy)](https://leetcode.com/problems/game-play-analysis-i "游戏玩法分析 I") -

    Table: Activity

    -
    -+--------------+---------+
    -| Column Name  | Type    |
    -+--------------+---------+
    -| player_id    | int     |
    -| device_id    | int     |
    -| event_date   | date    |
    -| games_played | int     |
    -+--------------+---------+
    -(player_id, event_date) is the primary key of this table.
    -This table shows the activity of players of some game.
    -Each row is a record of a player who logged in and played a number of games (possibly 0) before logging out on some day using some device.
    -
    -

     

    - -

    Write an SQL query that reports the first login date for each player.

    - -

    The query result format is in the following example:

    - -
    -Activity table:
    -+-----------+-----------+------------+--------------+
    -| player_id | device_id | event_date | games_played |
    -+-----------+-----------+------------+--------------+
    -| 1         | 2         | 2016-03-01 | 5            |
    -| 1         | 2         | 2016-05-02 | 6            |
    -| 2         | 3         | 2017-06-25 | 1            |
    -| 3         | 1         | 2016-03-02 | 0            |
    -| 3         | 4         | 2018-07-03 | 5            |
    -+-----------+-----------+------------+--------------+
    -
    -Result table:
    -+-----------+-------------+
    -| player_id | first_login |
    -+-----------+-------------+
    -| 1         | 2016-03-01  |
    -| 2         | 2017-06-25  |
    -| 3         | 2016-03-02  |
    -+-----------+-------------+
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] ### Similar Questions 1. [Game Play Analysis II](../game-play-analysis-ii) (Easy) diff --git a/problems/game-play-analysis-ii/README.md b/problems/game-play-analysis-ii/README.md index 7db8badb0..95be22933 100644 --- a/problems/game-play-analysis-ii/README.md +++ b/problems/game-play-analysis-ii/README.md @@ -11,48 +11,10 @@ ## [512. Game Play Analysis II (Easy)](https://leetcode.com/problems/game-play-analysis-ii "游戏玩法分析 II") -

    Table: Activity

    -
    -+--------------+---------+
    -| Column Name  | Type    |
    -+--------------+---------+
    -| player_id    | int     |
    -| device_id    | int     |
    -| event_date   | date    |
    -| games_played | int     |
    -+--------------+---------+
    -(player_id, event_date) is the primary key of this table.
    -This table shows the activity of players of some game.
    -Each row is a record of a player who logged in and played a number of games (possibly 0) before logging out on some day using some device.
    -
    -

     

    - -

    Write a SQL query that reports the device that is first logged in for each player.

    - -

    The query result format is in the following example:

    - -
    -Activity table:
    -+-----------+-----------+------------+--------------+
    -| player_id | device_id | event_date | games_played |
    -+-----------+-----------+------------+--------------+
    -| 1         | 2         | 2016-03-01 | 5            |
    -| 1         | 2         | 2016-05-02 | 6            |
    -| 2         | 3         | 2017-06-25 | 1            |
    -| 3         | 1         | 2016-03-02 | 0            |
    -| 3         | 4         | 2018-07-03 | 5            |
    -+-----------+-----------+------------+--------------+
    -
    -Result table:
    -+-----------+-----------+
    -| player_id | device_id |
    -+-----------+-----------+
    -| 1         | 2         |
    -| 2         | 3         |
    -| 3         | 1         |
    -+-----------+-----------+
    +### Related Topics + [[Database](../../tag/database/README.md)] ### Similar Questions 1. [Game Play Analysis I](../game-play-analysis-i) (Easy) diff --git a/problems/game-play-analysis-iii/README.md b/problems/game-play-analysis-iii/README.md index 555eb3114..837877b2e 100644 --- a/problems/game-play-analysis-iii/README.md +++ b/problems/game-play-analysis-iii/README.md @@ -11,54 +11,10 @@ ## [534. Game Play Analysis III (Medium)](https://leetcode.com/problems/game-play-analysis-iii "游戏玩法分析 III") -

    Table: Activity

    -
    -+--------------+---------+
    -| Column Name  | Type    |
    -+--------------+---------+
    -| player_id    | int     |
    -| device_id    | int     |
    -| event_date   | date    |
    -| games_played | int     |
    -+--------------+---------+
    -(player_id, event_date) is the primary key of this table.
    -This table shows the activity of players of some game.
    -Each row is a record of a player who logged in and played a number of games (possibly 0) before logging out on some day using some device.
    -
    -

     

    - -

    Write an SQL query that reports for each player and date, how many games played so far by the player. That is, the total number of games played by the player until that date. Check the example for clarity.

    - -

    The query result format is in the following example:

    - -
    -Activity table:
    -+-----------+-----------+------------+--------------+
    -| player_id | device_id | event_date | games_played |
    -+-----------+-----------+------------+--------------+
    -| 1         | 2         | 2016-03-01 | 5            |
    -| 1         | 2         | 2016-05-02 | 6            |
    -| 1         | 3         | 2017-06-25 | 1            |
    -| 3         | 1         | 2016-03-02 | 0            |
    -| 3         | 4         | 2018-07-03 | 5            |
    -+-----------+-----------+------------+--------------+
    -
    -Result table:
    -+-----------+------------+---------------------+
    -| player_id | event_date | games_played_so_far |
    -+-----------+------------+---------------------+
    -| 1         | 2016-03-01 | 5                   |
    -| 1         | 2016-05-02 | 11                  |
    -| 1         | 2017-06-25 | 12                  |
    -| 3         | 2016-03-02 | 0                   |
    -| 3         | 2018-07-03 | 5                   |
    -+-----------+------------+---------------------+
    -For the player with id 1, 5 + 6 = 11 games played by 2016-05-02, and 5 + 6 + 1 = 12 games played by 2017-06-25.
    -For the player with id 3, 0 + 5 = 5 games played by 2018-07-03.
    -Note that for each player we only care about the days when the player logged in.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] ### Similar Questions 1. [Game Play Analysis II](../game-play-analysis-ii) (Easy) diff --git a/problems/game-play-analysis-iv/README.md b/problems/game-play-analysis-iv/README.md index d77b91fa4..21801972a 100644 --- a/problems/game-play-analysis-iv/README.md +++ b/problems/game-play-analysis-iv/README.md @@ -11,48 +11,10 @@ ## [550. Game Play Analysis IV (Medium)](https://leetcode.com/problems/game-play-analysis-iv "游戏玩法分析 IV") -

    Table: Activity

    -
    -+--------------+---------+
    -| Column Name  | Type    |
    -+--------------+---------+
    -| player_id    | int     |
    -| device_id    | int     |
    -| event_date   | date    |
    -| games_played | int     |
    -+--------------+---------+
    -(player_id, event_date) is the primary key of this table.
    -This table shows the activity of players of some game.
    -Each row is a record of a player who logged in and played a number of games (possibly 0) before logging out on some day using some device.
    -
    -

     

    - -

    Write an SQL query that reports the fraction of players that logged in again on the day after the day they first logged in, rounded to 2 decimal places. In other words, you need to count the number of players that logged in for at least two consecutive days starting from their first login date, then divide that number by the total number of players.

    - -

    The query result format is in the following example:

    - -
    -Activity table:
    -+-----------+-----------+------------+--------------+
    -| player_id | device_id | event_date | games_played |
    -+-----------+-----------+------------+--------------+
    -| 1         | 2         | 2016-03-01 | 5            |
    -| 1         | 2         | 2016-03-02 | 6            |
    -| 2         | 3         | 2017-06-25 | 1            |
    -| 3         | 1         | 2016-03-02 | 0            |
    -| 3         | 4         | 2018-07-03 | 5            |
    -+-----------+-----------+------------+--------------+
    -
    -Result table:
    -+-----------+
    -| fraction  |
    -+-----------+
    -| 0.33      |
    -+-----------+
    -Only the player with id 1 logged back in after the first day he had logged in so the answer is 1/3 = 0.33
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] ### Similar Questions 1. [Game Play Analysis III](../game-play-analysis-iii) (Medium) diff --git a/problems/game-play-analysis-v/README.md b/problems/game-play-analysis-v/README.md index 956b97d1e..720923be6 100644 --- a/problems/game-play-analysis-v/README.md +++ b/problems/game-play-analysis-v/README.md @@ -11,54 +11,10 @@ ## [1097. Game Play Analysis V (Hard)](https://leetcode.com/problems/game-play-analysis-v "游戏玩法分析 V") -

    Table: Activity

    -
    -+--------------+---------+
    -| Column Name  | Type    |
    -+--------------+---------+
    -| player_id    | int     |
    -| device_id    | int     |
    -| event_date   | date    |
    -| games_played | int     |
    -+--------------+---------+
    -(player_id, event_date) is the primary key of this table.
    -This table shows the activity of players of some game.
    -Each row is a record of a player who logged in and played a number of games (possibly 0) before logging out on some day using some device.
    -
    -

     

    - -

    We define the install date of a player to be the first login day of that player.

    - -

    We also define day 1 retention of some date X to be the number of players whose install date is X and they logged back in on the day right after X, divided by the number of players whose install date is X, rounded to 2 decimal places.

    - -

    Write an SQL query that reports for each install date, the number of players that installed the game on that day and the day 1 retention.

    - -

    The query result format is in the following example:

    - -
    -Activity table:
    -+-----------+-----------+------------+--------------+
    -| player_id | device_id | event_date | games_played |
    -+-----------+-----------+------------+--------------+
    -| 1         | 2         | 2016-03-01 | 5            |
    -| 1         | 2         | 2016-03-02 | 6            |
    -| 2         | 3         | 2017-06-25 | 1            |
    -| 3         | 1         | 2016-03-01 | 0            |
    -| 3         | 4         | 2016-07-03 | 5            |
    -+-----------+-----------+------------+--------------+
    -
    -Result table:
    -+------------+----------+----------------+
    -| install_dt | installs | Day1_retention |
    -+------------+----------+----------------+
    -| 2016-03-01 | 2        | 0.50           |
    -| 2017-06-25 | 1        | 0.00           |
    -+------------+----------+----------------+
    -Player 1 and 3 installed the game on 2016-03-01 but only player 1 logged back in on 2016-03-02 so the day 1 retention of 2016-03-01 is 1 / 2 = 0.50
    -Player 2 installed the game on 2017-06-25 but didn't log back in on 2017-06-26 so the day 1 retention of 2017-06-25 is 0 / 1 = 0.00
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] ### Similar Questions 1. [Game Play Analysis IV](../game-play-analysis-iv) (Medium) diff --git a/problems/gas-station/README.md b/problems/gas-station/README.md index 25ccdd190..9a4c1432b 100644 --- a/problems/gas-station/README.md +++ b/problems/gas-station/README.md @@ -59,3 +59,4 @@ Therefore, you can't travel around the circuit once no matter where you star ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/generalized-abbreviation/README.md b/problems/generalized-abbreviation/README.md index 2756ddefe..142fbcdfd 100644 --- a/problems/generalized-abbreviation/README.md +++ b/problems/generalized-abbreviation/README.md @@ -11,22 +11,11 @@ ## [320. Generalized Abbreviation (Medium)](https://leetcode.com/problems/generalized-abbreviation "列举单词的全部缩写") -

    Write a function to generate the generalized abbreviations of a word. 

    -

    Note: The order of the output does not matter.

    - -

    Example:

    - -
    -Input: "word"
    -Output:
    -["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"]
    -
    - -

     

    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions diff --git a/problems/generate-parentheses/README.md b/problems/generate-parentheses/README.md index 518c9789f..733a36aa0 100644 --- a/problems/generate-parentheses/README.md +++ b/problems/generate-parentheses/README.md @@ -30,6 +30,7 @@ ### Related Topics [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions diff --git a/problems/generate-random-point-in-a-circle/README.md b/problems/generate-random-point-in-a-circle/README.md index ed1d71d2c..701e687e8 100644 --- a/problems/generate-random-point-in-a-circle/README.md +++ b/problems/generate-random-point-in-a-circle/README.md @@ -47,9 +47,10 @@ solution.randPoint(); // return [0.36572, 0.17248] ### Related Topics + [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] - [[Random](../../tag/random/README.md)] [[Rejection Sampling](../../tag/rejection-sampling/README.md)] + [[Randomized](../../tag/randomized/README.md)] ### Similar Questions 1. [Random Point in Non-overlapping Rectangles](../random-point-in-non-overlapping-rectangles) (Medium) diff --git a/problems/get-biggest-three-rhombus-sums-in-a-grid/README.md b/problems/get-biggest-three-rhombus-sums-in-a-grid/README.md index 701bedaeb..ca48ac971 100644 --- a/problems/get-biggest-three-rhombus-sums-in-a-grid/README.md +++ b/problems/get-biggest-three-rhombus-sums-in-a-grid/README.md @@ -63,6 +63,10 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/get-equal-substrings-within-budget/README.md b/problems/get-equal-substrings-within-budget/README.md index d2cbf28f0..c7e278c2c 100644 --- a/problems/get-equal-substrings-within-budget/README.md +++ b/problems/get-equal-substrings-within-budget/README.md @@ -53,7 +53,9 @@ ### Related Topics - [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints diff --git a/problems/get-highest-answer-rate-question/README.md b/problems/get-highest-answer-rate-question/README.md index 4683e1aa4..2a605e8bf 100644 --- a/problems/get-highest-answer-rate-question/README.md +++ b/problems/get-highest-answer-rate-question/README.md @@ -11,36 +11,10 @@ ## [578. Get Highest Answer Rate Question (Medium)](https://leetcode.com/problems/get-highest-answer-rate-question "查询回答率最高的问题") -

    Get the highest answer rate question from a table survey_log with these columns: uid, action, question_id, answer_id, q_num, timestamp.

    - -

    uid means user id; action has these kind of values: "show", "answer", "skip"; answer_id is not null when action column is "answer", while is null for "show" and "skip"; q_num is the numeral order of the question in current session.

    - -

    Write a sql query to identify the question which has the highest answer rate.

    - -

    Example:

    - -
    Input:
    -+------+-----------+--------------+------------+-----------+------------+
    -| uid  | action    | question_id  | answer_id  | q_num     | timestamp  |
    -+------+-----------+--------------+------------+-----------+------------+
    -| 5    | show      | 285          | null       | 1         | 123        |
    -| 5    | answer    | 285          | 124124     | 1         | 124        |
    -| 5    | show      | 369          | null       | 2         | 125        |
    -| 5    | skip      | 369          | null       | 2         | 126        |
    -+------+-----------+--------------+------------+-----------+------------+
    -Output:
    -+-------------+
    -| survey_log  |
    -+-------------+
    -|    285      |
    -+-------------+
    -Explanation:
    -question 285 has answer rate 1/1, while question 369 has 0/1 answer rate, so output 285.
    -
    - -

     

    - -

    Note: The highest answer rate meaning is: answer number's ratio in show number in the same question.

    + + +### Related Topics + [[Database](../../tag/database/README.md)] ### Hints
    diff --git a/problems/get-maximum-in-generated-array/README.md b/problems/get-maximum-in-generated-array/README.md index 0635621da..7fbcf4414 100644 --- a/problems/get-maximum-in-generated-array/README.md +++ b/problems/get-maximum-in-generated-array/README.md @@ -65,6 +65,8 @@ Hence, nums = [0,1,1,2,1,3,2,3], and the maximum is 3. ### Related Topics [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/get-the-maximum-score/README.md b/problems/get-the-maximum-score/README.md index 6154f35d4..d3b8f3baa 100644 --- a/problems/get-the-maximum-score/README.md +++ b/problems/get-the-maximum-score/README.md @@ -76,6 +76,9 @@ Maximum sum is obtained with the path [6,7,8,9,10]. ### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/get-the-second-most-recent-activity/README.md b/problems/get-the-second-most-recent-activity/README.md index a98a5e3d4..5e4a07ea4 100644 --- a/problems/get-the-second-most-recent-activity/README.md +++ b/problems/get-the-second-most-recent-activity/README.md @@ -11,48 +11,7 @@ ## [1369. Get the Second Most Recent Activity (Hard)](https://leetcode.com/problems/get-the-second-most-recent-activity "获取最近第二次的活动") -SQL Schema -

    Table: UserActivity

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| username      | varchar |
    -| activity      | varchar |
    -| startDate     | Date    |
    -| endDate       | Date    |
    -+---------------+---------+
    -This table does not contain primary key.
    -This table contain information about the activity performed of each user in a period of time.
    -A person with username performed a activity from startDate to endDate.
    -
    -Write an SQL query to show the second most recent activity of each user. -If the user only has one activity, return that one. - -A user can't perform more than one activity at the same time. Return the result table in any order. - -The query result format is in the following example: -
    -UserActivity table:
    -+------------+--------------+-------------+-------------+
    -| username   | activity     | startDate   | endDate     |
    -+------------+--------------+-------------+-------------+
    -| Alice      | Travel       | 2020-02-12  | 2020-02-20  |
    -| Alice      | Dancing      | 2020-02-21  | 2020-02-23  |
    -| Alice      | Travel       | 2020-02-24  | 2020-02-28  |
    -| Bob        | Travel       | 2020-02-11  | 2020-02-18  |
    -+------------+--------------+-------------+-------------+
    -
    -Result table:
    -+------------+--------------+-------------+-------------+
    -| username   | activity     | startDate   | endDate     |
    -+------------+--------------+-------------+-------------+
    -| Alice      | Dancing      | 2020-02-21  | 2020-02-23  |
    -| Bob        | Travel       | 2020-02-11  | 2020-02-18  |
    -+------------+--------------+-------------+-------------+
    -
    -The most recent activity of Alice is Travel from 2020-02-24 to 2020-02-28, before that she was dancing from 2020-02-21 to 2020-02-23.
    -Bob only has one record, we just take that one.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/get-watched-videos-by-your-friends/README.md b/problems/get-watched-videos-by-your-friends/README.md index fbaddab8c..749aa190b 100644 --- a/problems/get-watched-videos-by-your-friends/README.md +++ b/problems/get-watched-videos-by-your-friends/README.md @@ -59,9 +59,10 @@ You have id = 0 (green color in the figure) and the only friend of your friends ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/grand-slam-titles/README.md b/problems/grand-slam-titles/README.md index ca413cf65..a5325d294 100644 --- a/problems/grand-slam-titles/README.md +++ b/problems/grand-slam-titles/README.md @@ -12,3 +12,6 @@ ## [1783. Grand Slam Titles (Medium)](https://leetcode.com/problems/grand-slam-titles "大满贯数量") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/graph-connectivity-with-threshold/README.md b/problems/graph-connectivity-with-threshold/README.md index d06698eea..d471d5221 100644 --- a/problems/graph-connectivity-with-threshold/README.md +++ b/problems/graph-connectivity-with-threshold/README.md @@ -75,6 +75,7 @@ Please notice that there can be multiple queries for the same pair of nodes [x, ### Related Topics [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] ### Hints diff --git a/problems/graph-valid-tree/README.md b/problems/graph-valid-tree/README.md index fa7a72d39..0d597d720 100644 --- a/problems/graph-valid-tree/README.md +++ b/problems/graph-valid-tree/README.md @@ -11,25 +11,11 @@ ## [261. Graph Valid Tree (Medium)](https://leetcode.com/problems/graph-valid-tree "以图判树") -

    Given n nodes labeled from 0 to n-1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree.

    -

    Example 1:

    - -
    -Input: n = 5, and edges = [[0,1], [0,2], [0,3], [1,4]]
    -Output: true
    - -

    Example 2:

    - -
    -Input: n = 5, and edges = [[0,1], [1,2], [2,3], [1,3], [1,4]]
    -Output: false
    - -

    Note: you can assume that no duplicate edges will appear in edges. Since all edges are undirected, [0,1] is the same as [1,0] and thus will not appear together in edges.

    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] diff --git a/problems/gray-code/README.md b/problems/gray-code/README.md index f44dd4687..31ab2c962 100644 --- a/problems/gray-code/README.md +++ b/problems/gray-code/README.md @@ -57,6 +57,8 @@ The binary representation of [0,1,3,2] is [00,01,11,10]. ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Math](../../tag/math/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions diff --git a/problems/greatest-common-divisor-of-strings/README.md b/problems/greatest-common-divisor-of-strings/README.md index b1384f1ba..313d29097 100644 --- a/problems/greatest-common-divisor-of-strings/README.md +++ b/problems/greatest-common-divisor-of-strings/README.md @@ -39,6 +39,7 @@ ### Related Topics + [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/greatest-sum-divisible-by-three/README.md b/problems/greatest-sum-divisible-by-three/README.md index da02d3620..229e2df13 100644 --- a/problems/greatest-sum-divisible-by-three/README.md +++ b/problems/greatest-sum-divisible-by-three/README.md @@ -49,6 +49,8 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/grid-illumination/README.md b/problems/grid-illumination/README.md index 56d12503b..d0d90ef95 100644 --- a/problems/grid-illumination/README.md +++ b/problems/grid-illumination/README.md @@ -62,6 +62,7 @@ The 1st query asks if the lamp at grid[1][0] is illuminated or n ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions diff --git a/problems/group-anagrams/README.md b/problems/group-anagrams/README.md index 94de2d95c..d44c87b44 100644 --- a/problems/group-anagrams/README.md +++ b/problems/group-anagrams/README.md @@ -38,6 +38,7 @@ ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Valid Anagram](../valid-anagram) (Easy) diff --git a/problems/group-employees-of-the-same-salary/README.md b/problems/group-employees-of-the-same-salary/README.md index 58116a74e..c6e8894fe 100644 --- a/problems/group-employees-of-the-same-salary/README.md +++ b/problems/group-employees-of-the-same-salary/README.md @@ -12,3 +12,6 @@ ## [1875. Group Employees of the Same Salary (Medium)](https://leetcode.com/problems/group-employees-of-the-same-salary "") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/group-shifted-strings/README.md b/problems/group-shifted-strings/README.md index 00b649435..686e7ed28 100644 --- a/problems/group-shifted-strings/README.md +++ b/problems/group-shifted-strings/README.md @@ -11,27 +11,10 @@ ## [249. Group Shifted Strings (Medium)](https://leetcode.com/problems/group-shifted-strings "移位字符串分组") -

    Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequence:

    -
    -"abc" -> "bcd" -> ... -> "xyz"
    - -

    Given a list of strings which contains only lowercase alphabets, group all strings that belong to the same shifting sequence.

    - -

    Example:

    - -
    -Input: ["abc", "bcd", "acef", "xyz", "az", "ba", "a", "z"],
    -Output: 
    -[
    -  ["abc","bcd","xyz"],
    -  ["az","ba"],
    -  ["acef"],
    -  ["a","z"]
    -]
    -
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/group-sold-products-by-the-date/README.md b/problems/group-sold-products-by-the-date/README.md index 27d8ca750..f107e9cdc 100644 --- a/problems/group-sold-products-by-the-date/README.md +++ b/problems/group-sold-products-by-the-date/README.md @@ -12,3 +12,6 @@ ## [1484. Group Sold Products By The Date (Easy)](https://leetcode.com/problems/group-sold-products-by-the-date "按日期分组销售产品") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/group-the-people-given-the-group-size-they-belong-to/README.md b/problems/group-the-people-given-the-group-size-they-belong-to/README.md index 416f68e8d..9626d08e9 100644 --- a/problems/group-the-people-given-the-group-size-they-belong-to/README.md +++ b/problems/group-the-people-given-the-group-size-they-belong-to/README.md @@ -49,7 +49,8 @@ Other possible solutions are [[2,1,6],[5],[0,4,3]] and [[5],[0,6,2],[4,3,1]]. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/groups-of-special-equivalent-strings/README.md b/problems/groups-of-special-equivalent-strings/README.md index 60a6435a3..c017096d3 100644 --- a/problems/groups-of-special-equivalent-strings/README.md +++ b/problems/groups-of-special-equivalent-strings/README.md @@ -71,4 +71,6 @@ The other two groups are ["xyzz", "zzxy"] and ["zzyx&qu ### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/guess-number-higher-or-lower-ii/README.md b/problems/guess-number-higher-or-lower-ii/README.md index 4e8146494..26a48172e 100644 --- a/problems/guess-number-higher-or-lower-ii/README.md +++ b/problems/guess-number-higher-or-lower-ii/README.md @@ -76,8 +76,9 @@ The worst case is that you pay $1. ### Related Topics - [[Minimax](../../tag/minimax/README.md)] + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] ### Similar Questions 1. [Flip Game II](../flip-game-ii) (Medium) diff --git a/problems/guess-number-higher-or-lower/README.md b/problems/guess-number-higher-or-lower/README.md index f80d41dda..c09647967 100644 --- a/problems/guess-number-higher-or-lower/README.md +++ b/problems/guess-number-higher-or-lower/README.md @@ -51,6 +51,7 @@ ### Related Topics [[Binary Search](../../tag/binary-search/README.md)] + [[Interactive](../../tag/interactive/README.md)] ### Similar Questions 1. [First Bad Version](../first-bad-version) (Easy) diff --git a/problems/guess-the-majority-in-a-hidden-array/README.md b/problems/guess-the-majority-in-a-hidden-array/README.md index 5e043746a..b04070742 100644 --- a/problems/guess-the-majority-in-a-hidden-array/README.md +++ b/problems/guess-the-majority-in-a-hidden-array/README.md @@ -13,6 +13,11 @@ +### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Interactive](../../tag/interactive/README.md)] + ### Hints
    Hint 1 diff --git a/problems/guess-the-word/README.md b/problems/guess-the-word/README.md index 59805d5c3..91e225d77 100644 --- a/problems/guess-the-word/README.md +++ b/problems/guess-the-word/README.md @@ -56,4 +56,8 @@ We made 5 calls to master.guess and one of them was the secret, so we pass the t ### Related Topics - [[Minimax](../../tag/minimax/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] + [[Interactive](../../tag/interactive/README.md)] diff --git a/problems/h-index-ii/README.md b/problems/h-index-ii/README.md index 1fee0f5fe..c569b3fab 100644 --- a/problems/h-index-ii/README.md +++ b/problems/h-index-ii/README.md @@ -47,6 +47,7 @@ Since the researcher has 3 papers with at least 3 citations each and the remaini ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions diff --git a/problems/h-index/README.md b/problems/h-index/README.md index fde6daec3..7bb1f9d82 100644 --- a/problems/h-index/README.md +++ b/problems/h-index/README.md @@ -44,8 +44,9 @@ Since the researcher has 3 papers with at least 3 citations each and the remaini ### Related Topics - [[Sort](../../tag/sort/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] + [[Array](../../tag/array/README.md)] + [[Counting Sort](../../tag/counting-sort/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [H-Index II](../h-index-ii) (Medium) diff --git a/problems/hand-of-straights/README.md b/problems/hand-of-straights/README.md index cf45aea65..68e245c5a 100644 --- a/problems/hand-of-straights/README.md +++ b/problems/hand-of-straights/README.md @@ -47,4 +47,7 @@ ### Related Topics - [[Ordered Map](../../tag/ordered-map/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/handshakes-that-dont-cross/README.md b/problems/handshakes-that-dont-cross/README.md index 3817221f4..18045f577 100644 --- a/problems/handshakes-that-dont-cross/README.md +++ b/problems/handshakes-that-dont-cross/README.md @@ -11,53 +11,7 @@ ## [1259. Handshakes That Don't Cross (Hard)](https://leetcode.com/problems/handshakes-that-dont-cross "不相交的握手") -

    You are given an even number of people num_people that stand around a circle and each person shakes hands with someone else, so that there are num_people / 2 handshakes total.

    -

    Return the number of ways these handshakes could occur such that none of the handshakes cross.

    - -

    Since this number could be very big, return the answer mod 10^9 + 7

    - -

     

    -

    Example 1:

    - -
    -Input: num_people = 2
    -Output: 1
    -
    - -

    Example 2:

    - -

    - -
    -Input: num_people = 4
    -Output: 2
    -Explanation: There are two ways to do it, the first way is [(1,2),(3,4)] and the second one is [(2,3),(4,1)].
    -
    - -

    Example 3:

    - -

    - -
    -Input: num_people = 6
    -Output: 5
    -
    - -

    Example 4:

    - -
    -Input: num_people = 8
    -Output: 14
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 2 <= num_people <= 1000
    • -
    • num_people % 2 == 0
    • -
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/happy-number/README.md b/problems/happy-number/README.md index 8240a0ad8..3f683e060 100644 --- a/problems/happy-number/README.md +++ b/problems/happy-number/README.md @@ -53,6 +53,7 @@ ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions 1. [Linked List Cycle](../linked-list-cycle) (Easy) diff --git a/problems/heaters/README.md b/problems/heaters/README.md index 4ac78658c..c5b3d4d06 100644 --- a/problems/heaters/README.md +++ b/problems/heaters/README.md @@ -52,4 +52,6 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/height-checker/README.md b/problems/height-checker/README.md index 62c046b17..a0eebcf67 100644 --- a/problems/height-checker/README.md +++ b/problems/height-checker/README.md @@ -61,6 +61,8 @@ All indices match. ### Related Topics [[Array](../../tag/array/README.md)] + [[Counting Sort](../../tag/counting-sort/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/hexspeak/README.md b/problems/hexspeak/README.md index 9813d663b..b9aaa6089 100644 --- a/problems/hexspeak/README.md +++ b/problems/hexspeak/README.md @@ -11,34 +11,7 @@ ## [1271. Hexspeak (Easy)](https://leetcode.com/problems/hexspeak "十六进制魔术数字") -

    A decimal number can be converted to its Hexspeak representation by first converting it to an uppercase hexadecimal string, then replacing all occurrences of the digit 0 with the letter O, and the digit 1 with the letter I.  Such a representation is valid if and only if it consists only of the letters in the set {"A", "B", "C", "D", "E", "F", "I", "O"}.

    -

    Given a string num representing a decimal integer N, return the Hexspeak representation of N if it is valid, otherwise return "ERROR".

    - -

     

    -

    Example 1:

    - -
    -Input: num = "257"
    -Output: "IOI"
    -Explanation:  257 is 101 in hexadecimal.
    -
    - -

    Example 2:

    - -
    -Input: num = "3"
    -Output: "ERROR"
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= N <= 10^12
    • -
    • There are no leading zeros in the given string.
    • -
    • All answers must be in uppercase letters.
    • -
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/high-five/README.md b/problems/high-five/README.md index dfc3770d5..fb1bf84cc 100644 --- a/problems/high-five/README.md +++ b/problems/high-five/README.md @@ -11,38 +11,12 @@ ## [1086. High Five (Easy)](https://leetcode.com/problems/high-five "前五科的均分") -

    Given a list of scores of different students, return the average score of each student's top five scores in the order of each student's id.

    -

    Each entry items[i] has items[i][0] the student's id, and items[i][1] the student's score.  The average score is calculated using integer division.

    - -

     

    - -

    Example 1:

    - -
    -Input: [[1,91],[1,92],[2,93],[2,97],[1,60],[2,77],[1,65],[1,87],[1,100],[2,100],[2,76]]
    -Output: [[1,87],[2,88]]
    -Explanation: 
    -The average of the student with id = 1 is 87.
    -The average of the student with id = 2 is 88.6. But with integer division their average converts to 88.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= items.length <= 1000
    2. -
    3. items[i].length == 2
    4. -
    5. The IDs of the students is between 1 to 1000
    6. -
    7. The score of the students is between 1 to 100
    8. -
    9. For each student, there are at least 5 scores
    10. -
    ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/highest-grade-for-each-student/README.md b/problems/highest-grade-for-each-student/README.md index 509bc1cef..c92959f85 100644 --- a/problems/highest-grade-for-each-student/README.md +++ b/problems/highest-grade-for-each-student/README.md @@ -11,44 +11,7 @@ ## [1112. Highest Grade For Each Student (Medium)](https://leetcode.com/problems/highest-grade-for-each-student "每位学生的最高成绩") -

    Table: Enrollments

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| student_id    | int     |
    -| course_id     | int     |
    -| grade         | int     |
    -+---------------+---------+
    -(student_id, course_id) is the primary key of this table.
     
    -
    - -

    Write a SQL query to find the highest grade with its corresponding course for each student. In case of a tie, you should find the course with the smallest course_id. The output must be sorted by increasing student_id.

    - -

    The query result format is in the following example:

    - -
    -Enrollments table:
    -+------------+-------------------+
    -| student_id | course_id | grade |
    -+------------+-----------+-------+
    -| 2          | 2         | 95    |
    -| 2          | 3         | 95    |
    -| 1          | 1         | 90    |
    -| 1          | 2         | 99    |
    -| 3          | 1         | 80    |
    -| 3          | 2         | 75    |
    -| 3          | 3         | 82    |
    -+------------+-----------+-------+
    -
    -Result table:
    -+------------+-------------------+
    -| student_id | course_id | grade |
    -+------------+-----------+-------+
    -| 1          | 2         | 99    |
    -| 2          | 2         | 95    |
    -| 3          | 3         | 82    |
    -+------------+-----------+-------+
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/hopper-company-queries-i/README.md b/problems/hopper-company-queries-i/README.md index 64e586468..7656d5e8c 100644 --- a/problems/hopper-company-queries-i/README.md +++ b/problems/hopper-company-queries-i/README.md @@ -12,3 +12,6 @@ ## [1635. Hopper Company Queries I (Hard)](https://leetcode.com/problems/hopper-company-queries-i "Hopper 公司查询 I") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/hopper-company-queries-ii/README.md b/problems/hopper-company-queries-ii/README.md index b5e721c20..19fa94092 100644 --- a/problems/hopper-company-queries-ii/README.md +++ b/problems/hopper-company-queries-ii/README.md @@ -12,3 +12,6 @@ ## [1645. Hopper Company Queries II (Hard)](https://leetcode.com/problems/hopper-company-queries-ii "") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/hopper-company-queries-iii/README.md b/problems/hopper-company-queries-iii/README.md index 5fc4b1c56..9f6fd1489 100644 --- a/problems/hopper-company-queries-iii/README.md +++ b/problems/hopper-company-queries-iii/README.md @@ -12,3 +12,6 @@ ## [1651. Hopper Company Queries III (Hard)](https://leetcode.com/problems/hopper-company-queries-iii "") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/house-robber-ii/README.md b/problems/house-robber-ii/README.md index 0ce16fcf6..6500d13fb 100644 --- a/problems/house-robber-ii/README.md +++ b/problems/house-robber-ii/README.md @@ -49,6 +49,7 @@ Total amount you can rob = 1 + 3 = 4. ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/house-robber-iii/README.md b/problems/house-robber-iii/README.md index 32cd66c87..1eb529b55 100644 --- a/problems/house-robber-iii/README.md +++ b/problems/house-robber-iii/README.md @@ -44,8 +44,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [House Robber](../house-robber) (Medium) diff --git a/problems/house-robber/README.md b/problems/house-robber/README.md index c44764161..572ab037c 100644 --- a/problems/house-robber/README.md +++ b/problems/house-robber/README.md @@ -43,6 +43,7 @@ Total amount you can rob = 2 + 9 + 1 = 12. ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/how-many-apples-can-you-put-into-the-basket/README.md b/problems/how-many-apples-can-you-put-into-the-basket/README.md index db663b1de..a66ee896e 100644 --- a/problems/how-many-apples-can-you-put-into-the-basket/README.md +++ b/problems/how-many-apples-can-you-put-into-the-basket/README.md @@ -11,37 +11,12 @@ ## [1196. How Many Apples Can You Put into the Basket (Easy)](https://leetcode.com/problems/how-many-apples-can-you-put-into-the-basket "最多可以买到的苹果数量") -

    You have some apples, where arr[i] is the weight of the i-th apple.  You also have a basket that can carry up to 5000 units of weight.

    -

    Return the maximum number of apples you can put in the basket.

    - -

     

    -

    Example 1:

    - -
    -Input: arr = [100,200,150,1000]
    -Output: 4
    -Explanation: All 4 apples can be carried by the basket since their sum of weights is 1450.
    -
    - -

    Example 2:

    - -
    -Input: arr = [900,950,800,1000,700,800]
    -Output: 5
    -Explanation: The sum of weights of the 6 apples exceeds 5000 so we choose any 5 of them.
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= arr.length <= 10^3
    • -
    • 1 <= arr[i] <= 10^3
    • -
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/how-many-numbers-are-smaller-than-the-current-number/README.md b/problems/how-many-numbers-are-smaller-than-the-current-number/README.md index 9f8056258..28aa14d74 100644 --- a/problems/how-many-numbers-are-smaller-than-the-current-number/README.md +++ b/problems/how-many-numbers-are-smaller-than-the-current-number/README.md @@ -54,6 +54,8 @@ For nums[4]=3 there exist three smaller numbers than it (1, 2 and 2). ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/html-entity-parser/README.md b/problems/html-entity-parser/README.md index 580a68168..87d42149e 100644 --- a/problems/html-entity-parser/README.md +++ b/problems/html-entity-parser/README.md @@ -74,7 +74,7 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/human-traffic-of-stadium/README.md b/problems/human-traffic-of-stadium/README.md index 30440bda9..c12bb4e60 100644 --- a/problems/human-traffic-of-stadium/README.md +++ b/problems/human-traffic-of-stadium/README.md @@ -62,3 +62,6 @@ Result table: +------+------------+-----------+ The four rows with ids 5, 6, 7, and 8 have consecutive ids and each of them has >= 100 people attended. Note that row 8 was included even though the visit_date was not the next day after row 7. The rows with ids 2 and 3 are not included because we need at least three consecutive ids.
    + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/image-overlap/README.md b/problems/image-overlap/README.md index d22d9bd37..898fb828d 100644 --- a/problems/image-overlap/README.md +++ b/problems/image-overlap/README.md @@ -60,3 +60,4 @@ The number of positions that have a 1 in both images is 3. (Shown in red) ### Related Topics [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/image-smoother/README.md b/problems/image-smoother/README.md index 85205416a..a664dcfbe 100644 --- a/problems/image-smoother/README.md +++ b/problems/image-smoother/README.md @@ -50,3 +50,4 @@ For the point (1,1): floor((50+200+200+200+200+100+100+100+100)/9) = floor(138.8 ### Related Topics [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/immediate-food-delivery-i/README.md b/problems/immediate-food-delivery-i/README.md index 39a2a918a..e6e8a4d3b 100644 --- a/problems/immediate-food-delivery-i/README.md +++ b/problems/immediate-food-delivery-i/README.md @@ -11,47 +11,7 @@ ## [1173. Immediate Food Delivery I (Easy)](https://leetcode.com/problems/immediate-food-delivery-i "即时食物配送 I") -

    Table: Delivery

    -
    -+-----------------------------+---------+
    -| Column Name                 | Type    |
    -+-----------------------------+---------+
    -| delivery_id                 | int     |
    -| customer_id                 | int     |
    -| order_date                  | date    |
    -| customer_pref_delivery_date | date    |
    -+-----------------------------+---------+
    -delivery_id is the primary key of this table.
    -The table holds information about food delivery to customers that make orders at some date and specify a preferred delivery date (on the same order date or after it).
    -
    -

     

    - -

    If the preferred delivery date of the customer is the same as the order date then the order is called immediate otherwise it's called scheduled.

    - -

    Write an SQL query to find the percentage of immediate orders in the table, rounded to 2 decimal places.

    - -

    The query result format is in the following example:

    - -
    -Delivery table:
    -+-------------+-------------+------------+-----------------------------+
    -| delivery_id | customer_id | order_date | customer_pref_delivery_date |
    -+-------------+-------------+------------+-----------------------------+
    -| 1           | 1           | 2019-08-01 | 2019-08-02                  |
    -| 2           | 5           | 2019-08-02 | 2019-08-02                  |
    -| 3           | 1           | 2019-08-11 | 2019-08-11                  |
    -| 4           | 3           | 2019-08-24 | 2019-08-26                  |
    -| 5           | 4           | 2019-08-21 | 2019-08-22                  |
    -| 6           | 2           | 2019-08-11 | 2019-08-13                  |
    -+-------------+-------------+------------+-----------------------------+
    -
    -Result table:
    -+----------------------+
    -| immediate_percentage |
    -+----------------------+
    -| 33.33                |
    -+----------------------+
    -The orders with delivery id 2 and 3 are immediate while the others are scheduled.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/immediate-food-delivery-ii/README.md b/problems/immediate-food-delivery-ii/README.md index a860cff02..f455cf19e 100644 --- a/problems/immediate-food-delivery-ii/README.md +++ b/problems/immediate-food-delivery-ii/README.md @@ -11,54 +11,7 @@ ## [1174. Immediate Food Delivery II (Medium)](https://leetcode.com/problems/immediate-food-delivery-ii "即时食物配送 II") -

    Table: Delivery

    -
    -+-----------------------------+---------+
    -| Column Name                 | Type    |
    -+-----------------------------+---------+
    -| delivery_id                 | int     |
    -| customer_id                 | int     |
    -| order_date                  | date    |
    -| customer_pref_delivery_date | date    |
    -+-----------------------------+---------+
    -delivery_id is the primary key of this table.
    -The table holds information about food delivery to customers that make orders at some date and specify a preferred delivery date (on the same order date or after it).
    -
    -

     

    - -

    If the preferred delivery date of the customer is the same as the order date then the order is called immediate otherwise it's called scheduled.

    - -

    The first order of a customer is the order with the earliest order date that customer made. It is guaranteed that a customer has exactly one first order.

    - -

    Write an SQL query to find the percentage of immediate orders in the first orders of all customers, rounded to 2 decimal places.

    - -

    The query result format is in the following example:

    - -
    -Delivery table:
    -+-------------+-------------+------------+-----------------------------+
    -| delivery_id | customer_id | order_date | customer_pref_delivery_date |
    -+-------------+-------------+------------+-----------------------------+
    -| 1           | 1           | 2019-08-01 | 2019-08-02                  |
    -| 2           | 2           | 2019-08-02 | 2019-08-02                  |
    -| 3           | 1           | 2019-08-11 | 2019-08-12                  |
    -| 4           | 3           | 2019-08-24 | 2019-08-24                  |
    -| 5           | 3           | 2019-08-21 | 2019-08-22                  |
    -| 6           | 2           | 2019-08-11 | 2019-08-13                  |
    -| 7           | 4           | 2019-08-09 | 2019-08-09                  |
    -+-------------+-------------+------------+-----------------------------+
    -
    -Result table:
    -+----------------------+
    -| immediate_percentage |
    -+----------------------+
    -| 50.00                |
    -+----------------------+
    -The customer id 1 has a first order with delivery id 1 and it is scheduled.
    -The customer id 2 has a first order with delivery id 2 and it is immediate.
    -The customer id 3 has a first order with delivery id 5 and it is scheduled.
    -The customer id 4 has a first order with delivery id 7 and it is immediate.
    -Hence, half the customers have immediate first orders.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/implement-magic-dictionary/README.md b/problems/implement-magic-dictionary/README.md index 334552aee..7237ddd01 100644 --- a/problems/implement-magic-dictionary/README.md +++ b/problems/implement-magic-dictionary/README.md @@ -55,8 +55,10 @@ magicDictionary.search("leetcoded"); // return False ### Related Topics + [[Design](../../tag/design/README.md)] [[Trie](../../tag/trie/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Implement Trie (Prefix Tree)](../implement-trie-prefix-tree) (Medium) diff --git a/problems/implement-queue-using-stacks/README.md b/problems/implement-queue-using-stacks/README.md index d9d00e0cd..d0f72ee16 100644 --- a/problems/implement-queue-using-stacks/README.md +++ b/problems/implement-queue-using-stacks/README.md @@ -62,6 +62,7 @@ myQueue.empty(); // return false ### Related Topics [[Stack](../../tag/stack/README.md)] [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] ### Similar Questions 1. [Implement Stack using Queues](../implement-stack-using-queues) (Easy) diff --git a/problems/implement-rand10-using-rand7/README.md b/problems/implement-rand10-using-rand7/README.md index a29c1c155..f7caf2300 100644 --- a/problems/implement-rand10-using-rand7/README.md +++ b/problems/implement-rand10-using-rand7/README.md @@ -41,5 +41,7 @@ ### Related Topics - [[Random](../../tag/random/README.md)] + [[Math](../../tag/math/README.md)] [[Rejection Sampling](../../tag/rejection-sampling/README.md)] + [[Probability and Statistics](../../tag/probability-and-statistics/README.md)] + [[Randomized](../../tag/randomized/README.md)] diff --git a/problems/implement-stack-using-queues/README.md b/problems/implement-stack-using-queues/README.md index 43fb91a44..995ea9b60 100644 --- a/problems/implement-stack-using-queues/README.md +++ b/problems/implement-stack-using-queues/README.md @@ -11,7 +11,7 @@ ## [225. Implement Stack using Queues (Easy)](https://leetcode.com/problems/implement-stack-using-queues "用队列实现栈") -

    Implement a last in first out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal queue (push, top, pop, and empty).

    +

    Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (push, top, pop, and empty).

    Implement the MyStack class:

    @@ -25,8 +25,8 @@

    Notes:

      -
    • You must use only standard operations of a queue, which means only push to back, peek/pop from front, size, and is empty operations are valid.
    • -
    • Depending on your language, the queue may not be supported natively. You may simulate a queue using a list or deque (double-ended queue), as long as you use only a queue's standard operations.
    • +
    • You must use only standard operations of a queue, which means that only push to back, peek/pop from front, size and is empty operations are valid.
    • +
    • Depending on your language, the queue may not be supported natively. You may simulate a queue using a list or deque (double-ended queue) as long as you use only a queue's standard operations.

     

    @@ -58,11 +58,12 @@ myStack.empty(); // return False

     

    -

    Follow-up: Can you implement the stack such that each operation is amortized O(1) time complexity? In other words, performing n operations will take overall O(n) time even if one of those operations may take longer. You can use more than two queues.

    +

    Follow-up: Can you implement the stack using only one queue?

    ### Related Topics [[Stack](../../tag/stack/README.md)] [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] ### Similar Questions 1. [Implement Queue using Stacks](../implement-queue-using-stacks) (Easy) diff --git a/problems/implement-strstr/README.md b/problems/implement-strstr/README.md index 87474f101..eaaae77cc 100644 --- a/problems/implement-strstr/README.md +++ b/problems/implement-strstr/README.md @@ -43,6 +43,7 @@ ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] + [[String Matching](../../tag/string-matching/README.md)] ### Similar Questions 1. [Shortest Palindrome](../shortest-palindrome) (Hard) diff --git a/problems/implement-trie-ii-prefix-tree/README.md b/problems/implement-trie-ii-prefix-tree/README.md index 6faf69b0a..a4db81819 100644 --- a/problems/implement-trie-ii-prefix-tree/README.md +++ b/problems/implement-trie-ii-prefix-tree/README.md @@ -14,7 +14,9 @@ ### Related Topics + [[Design](../../tag/design/README.md)] [[Trie](../../tag/trie/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/implement-trie-prefix-tree/README.md b/problems/implement-trie-prefix-tree/README.md index 7bd85c9aa..50d2495c9 100644 --- a/problems/implement-trie-prefix-tree/README.md +++ b/problems/implement-trie-prefix-tree/README.md @@ -54,6 +54,8 @@ trie.search("app"); // return True ### Related Topics [[Design](../../tag/design/README.md)] [[Trie](../../tag/trie/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Design Add and Search Words Data Structure](../design-add-and-search-words-data-structure) (Medium) diff --git a/problems/increasing-decreasing-string/README.md b/problems/increasing-decreasing-string/README.md index 98d45e933..a64f532bd 100644 --- a/problems/increasing-decreasing-string/README.md +++ b/problems/increasing-decreasing-string/README.md @@ -78,8 +78,9 @@ After steps 4, 5 and 6 of the second iteration, result = "abccbaabccba" ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/increasing-order-search-tree/README.md b/problems/increasing-order-search-tree/README.md index 2cd6630ff..166decb16 100644 --- a/problems/increasing-order-search-tree/README.md +++ b/problems/increasing-order-search-tree/README.md @@ -37,6 +37,8 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Recursion](../../tag/recursion/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/increasing-subsequences/README.md b/problems/increasing-subsequences/README.md index e77ae6c8b..5001010d5 100644 --- a/problems/increasing-subsequences/README.md +++ b/problems/increasing-subsequences/README.md @@ -39,7 +39,10 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions 1. [Maximum Length of Pair Chain](../maximum-length-of-pair-chain) (Medium) diff --git a/problems/increasing-triplet-subsequence/README.md b/problems/increasing-triplet-subsequence/README.md index 7b1e6a55b..232b97085 100644 --- a/problems/increasing-triplet-subsequence/README.md +++ b/problems/increasing-triplet-subsequence/README.md @@ -49,5 +49,9 @@

     

    Follow up: Could you implement a solution that runs in O(n) time complexity and O(1) space complexity? +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + ### Similar Questions 1. [Longest Increasing Subsequence](../longest-increasing-subsequence) (Medium) diff --git a/problems/incremental-memory-leak/README.md b/problems/incremental-memory-leak/README.md index 16250838d..d2ca85d65 100644 --- a/problems/incremental-memory-leak/README.md +++ b/problems/incremental-memory-leak/README.md @@ -51,7 +51,7 @@ ### Related Topics - [[Math](../../tag/math/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/index-pairs-of-a-string/README.md b/problems/index-pairs-of-a-string/README.md index 0c71f38f4..7f4c1ee64 100644 --- a/problems/index-pairs-of-a-string/README.md +++ b/problems/index-pairs-of-a-string/README.md @@ -11,42 +11,13 @@ ## [1065. Index Pairs of a String (Easy)](https://leetcode.com/problems/index-pairs-of-a-string "字符串的索引对") -

    Given a text string and words (a list of strings), return all index pairs [i, j] so that the substring text[i]...text[j] is in the list of words.

    -

     

    - -

    Example 1:

    - -
    -Input: text = "thestoryofleetcodeandme", words = ["story","fleet","leetcode"]
    -Output: [[3,7],[9,13],[10,17]]
    -
    - -

    Example 2:

    - -
    -Input: text = "ababa", words = ["aba","ab"]
    -Output: [[0,1],[0,2],[2,3],[2,4]]
    -Explanation: 
    -Notice that matches can overlap, see "aba" is found in [0,2] and [2,4].
    -
    - -

     

    - -

    Note:

    - -
      -
    1. All strings contains only lowercase English letters.
    2. -
    3. It's guaranteed that all strings in words are different.
    4. -
    5. 1 <= text.length <= 100
    6. -
    7. 1 <= words.length <= 20
    8. -
    9. 1 <= words[i].length <= 50
    10. -
    11. Return the pairs [i,j] in sorted order (i.e. sort them by their first coordinate in case of ties sort them by their second coordinate).
    12. -
    ### Related Topics [[Trie](../../tag/trie/README.md)] + [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/inorder-successor-in-bst-ii/README.md b/problems/inorder-successor-in-bst-ii/README.md index a9fc233de..b99a07000 100644 --- a/problems/inorder-successor-in-bst-ii/README.md +++ b/problems/inorder-successor-in-bst-ii/README.md @@ -11,70 +11,12 @@ ## [510. Inorder Successor in BST II (Medium)](https://leetcode.com/problems/inorder-successor-in-bst-ii "二叉搜索树中的中序后继 II") -

    Given a binary search tree and a node in it, find the in-order successor of that node in the BST.

    -

    The successor of a node p is the node with the smallest key greater than p.val.

    - -

    You will have direct access to the node but not to the root of the tree. Each node will have a reference to its parent node.

    - -

     

    - -

    Example 1:

    - -
    -Input: 
    -root = {"$id":"1","left":{"$id":"2","left":null,"parent":{"$ref":"1"},"right":null,"val":1},"parent":null,"right":{"$id":"3","left":null,"parent":{"$ref":"1"},"right":null,"val":3},"val":2}
    -p = 1
    -Output: 2
    -Explanation: 1's in-order successor node is 2. Note that both p and the return value is of Node type.
    -
    - -

    Example 2:

    - -
    -Input: 
    -root = {"$id":"1","left":{"$id":"2","left":{"$id":"3","left":{"$id":"4","left":null,"parent":{"$ref":"3"},"right":null,"val":1},"parent":{"$ref":"2"},"right":null,"val":2},"parent":{"$ref":"1"},"right":{"$id":"5","left":null,"parent":{"$ref":"2"},"right":null,"val":4},"val":3},"parent":null,"right":{"$id":"6","left":null,"parent":{"$ref":"1"},"right":null,"val":6},"val":5}
    -p = 6
    -Output: null
    -Explanation: There is no in-order successor of the current node, so the answer is null.
    -
    - -

    Example 3:

    - -
    -Input: 
    -root = {"$id":"1","left":{"$id":"2","left":{"$id":"3","left":{"$id":"4","left":null,"parent":{"$ref":"3"},"right":null,"val":2},"parent":{"$ref":"2"},"right":{"$id":"5","left":null,"parent":{"$ref":"3"},"right":null,"val":4},"val":3},"parent":{"$ref":"1"},"right":{"$id":"6","left":null,"parent":{"$ref":"2"},"right":{"$id":"7","left":{"$id":"8","left":null,"parent":{"$ref":"7"},"right":null,"val":9},"parent":{"$ref":"6"},"right":null,"val":13},"val":7},"val":6},"parent":null,"right":{"$id":"9","left":{"$id":"10","left":null,"parent":{"$ref":"9"},"right":null,"val":17},"parent":{"$ref":"1"},"right":{"$id":"11","left":null,"parent":{"$ref":"9"},"right":null,"val":20},"val":18},"val":15}
    -p = 15
    -Output: 17
    -
    - -

    Example 4:

    - -
    -Input: 
    -root = {"$id":"1","left":{"$id":"2","left":{"$id":"3","left":{"$id":"4","left":null,"parent":{"$ref":"3"},"right":null,"val":2},"parent":{"$ref":"2"},"right":{"$id":"5","left":null,"parent":{"$ref":"3"},"right":null,"val":4},"val":3},"parent":{"$ref":"1"},"right":{"$id":"6","left":null,"parent":{"$ref":"2"},"right":{"$id":"7","left":{"$id":"8","left":null,"parent":{"$ref":"7"},"right":null,"val":9},"parent":{"$ref":"6"},"right":null,"val":13},"val":7},"val":6},"parent":null,"right":{"$id":"9","left":{"$id":"10","left":null,"parent":{"$ref":"9"},"right":null,"val":17},"parent":{"$ref":"1"},"right":{"$id":"11","left":null,"parent":{"$ref":"9"},"right":null,"val":20},"val":18},"val":15}
    -p = 13
    -Output: 15
    -
    - -

     

    - -

    Note:

    - -
      -
    1. If the given node has no in-order successor in the tree, return null.
    2. -
    3. It's guaranteed that the values of the tree are unique.
    4. -
    5. Remember that we are using the Node type instead of TreeNode type so their string representation are different.
    6. -
    - -

     

    - -

    Follow up:

    - -

    Could you solve it without looking up any of the node's values?

    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Inorder Successor in BST](../inorder-successor-in-bst) (Medium) diff --git a/problems/inorder-successor-in-bst/README.md b/problems/inorder-successor-in-bst/README.md index b39c2f6d5..a887f7f83 100644 --- a/problems/inorder-successor-in-bst/README.md +++ b/problems/inorder-successor-in-bst/README.md @@ -11,37 +11,13 @@ ## [285. Inorder Successor in BST (Medium)](https://leetcode.com/problems/inorder-successor-in-bst "二叉搜索树中的中序后继") -

    Given a binary search tree and a node in it, find the in-order successor of that node in the BST.

    -

    The successor of a node p is the node with the smallest key greater than p.val.

    - -

     

    - -

    Example 1:

    - -
    Input: root = [2,1,3], p = 1
    -Output: 2
    -Explanation: 1's in-order successor node is 2. Note that both p and the return value is of TreeNode type.
    -
    - -

    Example 2:

    - -
    Input: root = [5,3,6,2,4,null,null,1], p = 6
    -Output: null
    -Explanation: There is no in-order successor of the current node, so the answer is null.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. If the given node has no in-order successor in the tree, return null.
    2. -
    3. It's guaranteed that the values of the tree are unique.
    4. -
    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Easy) diff --git a/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md b/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md index d8c4574fc..d18b37a19 100644 --- a/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md +++ b/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md @@ -20,6 +20,8 @@
  • int getRandom() Returns a random element from the current multiset of elements (it's guaranteed that at least one element exists when this method is called). The probability of each element being returned is linearly related to the number of same values the multiset contains.
  • +

    You must implement the functions of the class such that each function works in average O(1) time complexity.

    +

     

    Example 1:

    @@ -45,17 +47,16 @@ randomizedCollection.getRandom(); // getRandom should return 1 and 2 both equall
    • -231 <= val <= 231 - 1
    • -
    • At most 105 calls will be made to insert, remove, and getRandom.
    • +
    • At most 2 * 105  calls will be made to insert, remove, and getRandom.
    • There will be at least one element in the data structure when getRandom is called.
    -

     

    -Follow up: Could you implement the functions of the class with each function works in average O(1) time? - ### Related Topics [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] + [[Randomized](../../tag/randomized/README.md)] ### Similar Questions 1. [Insert Delete GetRandom O(1)](../insert-delete-getrandom-o1) (Medium) diff --git a/problems/insert-delete-getrandom-o1/README.md b/problems/insert-delete-getrandom-o1/README.md index 3fb6ec3ae..0dd514659 100644 --- a/problems/insert-delete-getrandom-o1/README.md +++ b/problems/insert-delete-getrandom-o1/README.md @@ -20,6 +20,8 @@
  • int getRandom() Returns a random element from the current set of elements (it's guaranteed that at least one element exists when this method is called). Each element must have the same probability of being returned.
  • +

    You must implement the functions of the class such that each function works in average O(1) time complexity.

    +

     

    Example 1:

    @@ -46,17 +48,16 @@ randomizedSet.getRandom(); // Since 2 is the only number in the set, getRandom()
    • -231 <= val <= 231 - 1
    • -
    • At most 105 calls will be made to insert, remove, and getRandom.
    • +
    • At most 2 * 105 calls will be made to insert, remove, and getRandom.
    • There will be at least one element in the data structure when getRandom is called.
    -

     

    -Follow up: Could you implement the functions of the class with each function works in average O(1) time? - ### Related Topics [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] + [[Randomized](../../tag/randomized/README.md)] ### Similar Questions 1. [Insert Delete GetRandom O(1) - Duplicates allowed](../insert-delete-getrandom-o1-duplicates-allowed) (Hard) diff --git a/problems/insert-interval/README.md b/problems/insert-interval/README.md index 2937fb262..5a1964746 100644 --- a/problems/insert-interval/README.md +++ b/problems/insert-interval/README.md @@ -64,7 +64,6 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] ### Similar Questions diff --git a/problems/insert-into-a-binary-search-tree/README.md b/problems/insert-into-a-binary-search-tree/README.md index cdbffad90..c502641dd 100644 --- a/problems/insert-into-a-binary-search-tree/README.md +++ b/problems/insert-into-a-binary-search-tree/README.md @@ -52,6 +52,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Search in a Binary Search Tree](../search-in-a-binary-search-tree) (Easy) diff --git a/problems/insert-into-a-sorted-circular-linked-list/README.md b/problems/insert-into-a-sorted-circular-linked-list/README.md index d1c4bc30b..cedb2874d 100644 --- a/problems/insert-into-a-sorted-circular-linked-list/README.md +++ b/problems/insert-into-a-sorted-circular-linked-list/README.md @@ -11,25 +11,7 @@ ## [708. Insert into a Sorted Circular Linked List (Medium)](https://leetcode.com/problems/insert-into-a-sorted-circular-linked-list "循环有序列表的插入") -

    Given a node from a cyclic linked list which is sorted in ascending order, write a function to insert a value into the list such that it remains a cyclic sorted list. The given node can be a reference to any single node in the list, and may not be necessarily the smallest value in the cyclic list.

    -

    If there are multiple suitable places for insertion, you may choose any place to insert the new value. After the insertion, the cyclic list should remain sorted.

    - -

    If the list is empty (i.e., given node is null), you should create a new single cyclic list and return the reference to that single node. Otherwise, you should return the original given node.

    - -

    The following example may help you understand the problem better:

    - -

     

    - -


    -
    -In the figure above, there is a cyclic sorted list of three elements. You are given a reference to the node with value 3, and we need to insert 2 into the list.

    - -

     

    - -


    -
    -The new node should insert between node 1 and node 3. After the insertion, the list should look like this, and we should still return node 3.

    ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/insertion-sort-list/README.md b/problems/insertion-sort-list/README.md index 2de949f40..0f772bb2b 100644 --- a/problems/insertion-sort-list/README.md +++ b/problems/insertion-sort-list/README.md @@ -47,8 +47,8 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Sort List](../sort-list) (Medium) diff --git a/problems/insufficient-nodes-in-root-to-leaf-paths/README.md b/problems/insufficient-nodes-in-root-to-leaf-paths/README.md index 5b7fe7400..19af8bdb1 100644 --- a/problems/insufficient-nodes-in-root-to-leaf-paths/README.md +++ b/problems/insufficient-nodes-in-root-to-leaf-paths/README.md @@ -63,7 +63,9 @@ Output: [1,null,-3,4]
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/integer-replacement/README.md b/problems/integer-replacement/README.md index 905a5d312..3acb44928 100644 --- a/problems/integer-replacement/README.md +++ b/problems/integer-replacement/README.md @@ -54,4 +54,5 @@ or 7 -> 6 -> 3 -> 2 -> 1 ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] - [[Math](../../tag/math/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/integer-to-english-words/README.md b/problems/integer-to-english-words/README.md index a64ce0e0d..a79d587c3 100644 --- a/problems/integer-to-english-words/README.md +++ b/problems/integer-to-english-words/README.md @@ -35,6 +35,7 @@ ### Related Topics + [[Recursion](../../tag/recursion/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/integer-to-roman/README.md b/problems/integer-to-roman/README.md index ddba6b7db..e923416cd 100644 --- a/problems/integer-to-roman/README.md +++ b/problems/integer-to-roman/README.md @@ -81,6 +81,7 @@ M 1000
    ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/intersection-of-three-sorted-arrays/README.md b/problems/intersection-of-three-sorted-arrays/README.md index 0b5787a5e..7bb10c5b9 100644 --- a/problems/intersection-of-three-sorted-arrays/README.md +++ b/problems/intersection-of-three-sorted-arrays/README.md @@ -11,28 +11,13 @@ ## [1213. Intersection of Three Sorted Arrays (Easy)](https://leetcode.com/problems/intersection-of-three-sorted-arrays "三个有序数组的交集") -

    Given three integer arrays arr1, arr2 and arr3 sorted in strictly increasing order, return a sorted array of only the integers that appeared in all three arrays.

    -

     

    -

    Example 1:

    - -
    -Input: arr1 = [1,2,3,4,5], arr2 = [1,2,5,7,9], arr3 = [1,3,4,5,8]
    -Output: [1,5]
    -Explanation: Only 1 and 5 appeared in the three arrays.
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= arr1.length, arr2.length, arr3.length <= 1000
    • -
    • 1 <= arr1[i], arr2[i], arr3[i] <= 2000
    • -
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Counting](../../tag/counting/README.md)] ### Similar Questions 1. [Intersection of Two Arrays](../intersection-of-two-arrays) (Easy) diff --git a/problems/intersection-of-two-arrays-ii/README.md b/problems/intersection-of-two-arrays-ii/README.md index bc912348b..d20f01b10 100644 --- a/problems/intersection-of-two-arrays-ii/README.md +++ b/problems/intersection-of-two-arrays-ii/README.md @@ -47,10 +47,11 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Intersection of Two Arrays](../intersection-of-two-arrays) (Easy) diff --git a/problems/intersection-of-two-arrays/README.md b/problems/intersection-of-two-arrays/README.md index f694a017f..a18b5bb08 100644 --- a/problems/intersection-of-two-arrays/README.md +++ b/problems/intersection-of-two-arrays/README.md @@ -38,10 +38,11 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Intersection of Two Arrays II](../intersection-of-two-arrays-ii) (Easy) diff --git a/problems/intersection-of-two-linked-lists/README.md b/problems/intersection-of-two-linked-lists/README.md index 1a31b9d34..d4b432ee3 100644 --- a/problems/intersection-of-two-linked-lists/README.md +++ b/problems/intersection-of-two-linked-lists/README.md @@ -65,7 +65,9 @@ Explanation: The two lists do not intersect, so return null. Follow up: Could you write a solution that runs in O(n) time and use only O(1) memory? ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions 1. [Minimum Index Sum of Two Lists](../minimum-index-sum-of-two-lists) (Easy) diff --git a/problems/interval-list-intersections/README.md b/problems/interval-list-intersections/README.md index 52e4f92ad..5218c2a65 100644 --- a/problems/interval-list-intersections/README.md +++ b/problems/interval-list-intersections/README.md @@ -61,6 +61,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions diff --git a/problems/invalid-transactions/README.md b/problems/invalid-transactions/README.md index 3e0997baf..0a84ff410 100644 --- a/problems/invalid-transactions/README.md +++ b/problems/invalid-transactions/README.md @@ -57,7 +57,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/invalid-tweets/README.md b/problems/invalid-tweets/README.md index 501bb631a..098ac36fe 100644 --- a/problems/invalid-tweets/README.md +++ b/problems/invalid-tweets/README.md @@ -12,3 +12,6 @@ ## [1683. Invalid Tweets (Easy)](https://leetcode.com/problems/invalid-tweets "无效的推文") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/invert-binary-tree/README.md b/problems/invert-binary-tree/README.md index 6f779a293..3f0f28c55 100644 --- a/problems/invert-binary-tree/README.md +++ b/problems/invert-binary-tree/README.md @@ -45,3 +45,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/investments-in-2016/README.md b/problems/investments-in-2016/README.md index 5544d5ff1..afa8207af 100644 --- a/problems/investments-in-2016/README.md +++ b/problems/investments-in-2016/README.md @@ -11,58 +11,10 @@ ## [585. Investments in 2016 (Medium)](https://leetcode.com/problems/investments-in-2016 "2016年的投资") -

    Write a query to print the sum of all total investment values in 2016 (TIV_2016), to a scale of 2 decimal places, for all policy holders who meet the following criteria:

    -
      -
    1. Have the same TIV_2015 value as one or more other policyholders.
    2. -
    3. Are not located in the same city as any other policyholder (i.e.: the (latitude, longitude) attribute pairs must be unique).
    4. -
    -

    Input Format:
    -The insurance table is described as follows:

    - -
    -| Column Name | Type          |
    -|-------------|---------------|
    -| PID         | INTEGER(11)   |
    -| TIV_2015    | NUMERIC(15,2) |
    -| TIV_2016    | NUMERIC(15,2) |
    -| LAT         | NUMERIC(5,2)  |
    -| LON         | NUMERIC(5,2)  |
    -
    - -

    where PID is the policyholder's policy ID, TIV_2015 is the total investment value in 2015, TIV_2016 is the total investment value in 2016, LAT is the latitude of the policy holder's city, and LON is the longitude of the policy holder's city.

    - -

    Sample Input

    - -
    -| PID | TIV_2015 | TIV_2016 | LAT | LON |
    -|-----|----------|----------|-----|-----|
    -| 1   | 10       | 5        | 10  | 10  |
    -| 2   | 20       | 20       | 20  | 20  |
    -| 3   | 10       | 30       | 20  | 20  |
    -| 4   | 10       | 40       | 40  | 40  |
    -
    - -

    Sample Output

    - -
    -| TIV_2016 |
    -|----------|
    -| 45.00    |
    -
    - -

    Explanation

    - -
    -The first record in the table, like the last record, meets both of the two criteria.
    -The TIV_2015 value '10' is as the same as the third and forth record, and its location unique.
    -
    -The second record does not meet any of the two criteria. Its TIV_2015 is not like any other policyholders.
    -
    -And its location is the same with the third record, which makes the third record fail, too.
    -
    -So, the result is the sum of TIV_2016 of the first and last record, which is 45.
    +### Related Topics + [[Database](../../tag/database/README.md)] ### Hints
    diff --git a/problems/ip-to-cidr/README.md b/problems/ip-to-cidr/README.md index 6e0ddeb26..3ae4f69e8 100644 --- a/problems/ip-to-cidr/README.md +++ b/problems/ip-to-cidr/README.md @@ -11,59 +11,11 @@ ## [751. IP to CIDR (Medium)](https://leetcode.com/problems/ip-to-cidr "IP 到 CIDR") -

    -Given a start IP address ip and a number of ips we need to cover n, return a representation of the range as a list (of smallest possible length) of CIDR blocks. -

    -A CIDR block is a string consisting of an IP, followed by a slash, and then the prefix length. For example: "123.45.67.89/20". That prefix length "20" represents the number of common prefix bits in the specified range. -

    -

    Example 1:
    -

    -Input: ip = "255.0.0.7", n = 10
    -Output: ["255.0.0.7/32","255.0.0.8/29","255.0.0.16/32"]
    -Explanation:
    -The initial ip address, when converted to binary, looks like this (spaces added for clarity):
    -255.0.0.7 -> 11111111 00000000 00000000 00000111
    -The address "255.0.0.7/32" specifies all addresses with a common prefix of 32 bits to the given address,
    -ie. just this one address.
    -
    -The address "255.0.0.8/29" specifies all addresses with a common prefix of 29 bits to the given address:
    -255.0.0.8 -> 11111111 00000000 00000000 00001000
    -Addresses with common prefix of 29 bits are:
    -11111111 00000000 00000000 00001000
    -11111111 00000000 00000000 00001001
    -11111111 00000000 00000000 00001010
    -11111111 00000000 00000000 00001011
    -11111111 00000000 00000000 00001100
    -11111111 00000000 00000000 00001101
    -11111111 00000000 00000000 00001110
    -11111111 00000000 00000000 00001111
    -
    -The address "255.0.0.16/32" specifies all addresses with a common prefix of 32 bits to the given address,
    -ie. just 11111111 00000000 00000000 00010000.
    -
    -In total, the answer specifies the range of 10 ips starting with the address 255.0.0.7 .
    -
    -There were other representations, such as:
    -["255.0.0.7/32","255.0.0.8/30", "255.0.0.12/30", "255.0.0.16/32"],
    -but our answer was the shortest possible.
    -
    -Also note that a representation beginning with say, "255.0.0.7/30" would be incorrect,
    -because it includes addresses like 255.0.0.4 = 11111111 00000000 00000000 00000100 
    -that are outside the specified range.
    -
    -

    - -

    Note:
    -

      -
    1. ip will be a valid IPv4 address.
    2. -
    3. Every implied address ip + x (for x < n) will be a valid IPv4 address.
    4. -
    5. n will be an integer in the range [1, 1000].
    6. -
    -

    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Restore IP Addresses](../restore-ip-addresses) (Medium) diff --git a/problems/ipo/README.md b/problems/ipo/README.md index 861bbe9ef..902487817 100644 --- a/problems/ipo/README.md +++ b/problems/ipo/README.md @@ -55,5 +55,7 @@ Therefore, output the final maximized capital, which is 0 + 1 + 3 = 4. ### Related Topics - [[Heap](../../tag/heap/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/is-graph-bipartite/README.md b/problems/is-graph-bipartite/README.md index d5f24efcd..dd7928a28 100644 --- a/problems/is-graph-bipartite/README.md +++ b/problems/is-graph-bipartite/README.md @@ -53,6 +53,7 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] diff --git a/problems/is-subsequence/README.md b/problems/is-subsequence/README.md index 2069b926d..64a0597ae 100644 --- a/problems/is-subsequence/README.md +++ b/problems/is-subsequence/README.md @@ -36,8 +36,8 @@ Follow up: Suppose there are lots of incoming s, say s1, s2, ..., sk where k >= 109, and you want to check one by one to see if t has its subsequence. In this scenario, how would you change your code? ### Related Topics - [[Greedy](../../tag/greedy/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/island-perimeter/README.md b/problems/island-perimeter/README.md index b2190d723..b33418489 100644 --- a/problems/island-perimeter/README.md +++ b/problems/island-perimeter/README.md @@ -51,7 +51,10 @@ ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Max Area of Island](../max-area-of-island) (Medium) diff --git a/problems/isomorphic-strings/README.md b/problems/isomorphic-strings/README.md index 9d2609d9b..db81a33c6 100644 --- a/problems/isomorphic-strings/README.md +++ b/problems/isomorphic-strings/README.md @@ -39,6 +39,7 @@ ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Word Pattern](../word-pattern) (Easy) diff --git a/problems/iterator-for-combination/README.md b/problems/iterator-for-combination/README.md index 366387cee..90a89c48e 100644 --- a/problems/iterator-for-combination/README.md +++ b/problems/iterator-for-combination/README.md @@ -51,7 +51,9 @@ itr.hasNext(); // return False ### Related Topics [[Design](../../tag/design/README.md)] + [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Iterator](../../tag/iterator/README.md)] ### Hints
    diff --git a/problems/jewels-and-stones/README.md b/problems/jewels-and-stones/README.md index 04d02219c..03f1ca5a9 100644 --- a/problems/jewels-and-stones/README.md +++ b/problems/jewels-and-stones/README.md @@ -34,6 +34,7 @@ ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/jump-game-ii/README.md b/problems/jump-game-ii/README.md index a6f6dffcd..7a13e8b1d 100644 --- a/problems/jump-game-ii/README.md +++ b/problems/jump-game-ii/README.md @@ -46,6 +46,7 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Jump Game](../jump-game) (Medium) diff --git a/problems/jump-game-iii/README.md b/problems/jump-game-iii/README.md index 4b5109f5d..bded9080e 100644 --- a/problems/jump-game-iii/README.md +++ b/problems/jump-game-iii/README.md @@ -55,9 +55,9 @@ index 0 -> index 4 -> index 1 -> index 3 ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] - [[Recursion](../../tag/recursion/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/jump-game-iv/README.md b/problems/jump-game-iv/README.md index 01391e5fd..8305870b7 100644 --- a/problems/jump-game-iv/README.md +++ b/problems/jump-game-iv/README.md @@ -73,7 +73,9 @@ ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/jump-game-v/README.md b/problems/jump-game-v/README.md index 177bf0404..8193310c6 100644 --- a/problems/jump-game-v/README.md +++ b/problems/jump-game-v/README.md @@ -75,7 +75,9 @@ Similarly You cannot jump from index 3 to index 2 or index 1. ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/jump-game-vi/README.md b/problems/jump-game-vi/README.md index 2e41a72ec..7a6eecb5a 100644 --- a/problems/jump-game-vi/README.md +++ b/problems/jump-game-vi/README.md @@ -47,17 +47,25 @@

    Constraints:

      -
    •  1 <= nums.length, k <= 105
    • -
    • -104 <= nums[i] <= 104
    • +
    • 1 <= nums.length, k <= 105
    • +
    • -104 <= nums[i] <= 104
    +### Related Topics + [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + ### Hints
    Hint 1 -Let dp[i] be "the maximum score to reach the end starting at index i". The answer for dp[i] is nums[i] + min{dp[i+j]} for 1 <= j <= k. That gives an O(n*k) solution. +Let dp[i] be "the maximum score to reach the end starting at index i". The answer for dp[i] is nums[i] + max{dp[i+j]} for 1 <= j <= k. That gives an O(n*k) solution.
    Hint 2 -Instead of checking every j for every i, keep track of the smallest dp[i] values in a heap and calculate dp[i] from right to left. When the smallest value in the heap is out of bounds of the current index, remove it and keep checking. +Instead of checking every j for every i, keep track of the largest dp[i] values in a heap and calculate dp[i] from right to left. When the largest value in the heap is out of bounds of the current index, remove it and keep checking.
    diff --git a/problems/jump-game-vii/README.md b/problems/jump-game-vii/README.md index 4bc3869a4..68a2bd819 100644 --- a/problems/jump-game-vii/README.md +++ b/problems/jump-game-vii/README.md @@ -49,9 +49,9 @@ In the second step, move from index 3 to index 5. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] - [[Line Sweep](../../tag/line-sweep/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/jump-game/README.md b/problems/jump-game/README.md index 6c566bd95..d98c78317 100644 --- a/problems/jump-game/README.md +++ b/problems/jump-game/README.md @@ -45,6 +45,7 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Jump Game II](../jump-game-ii) (Medium) diff --git a/problems/k-closest-points-to-origin/README.md b/problems/k-closest-points-to-origin/README.md index 947804f45..543ae3548 100644 --- a/problems/k-closest-points-to-origin/README.md +++ b/problems/k-closest-points-to-origin/README.md @@ -47,11 +47,16 @@ We only want the closest k = 1 points from the origin, so the answer is just [[- ### Related Topics - [[Heap](../../tag/heap/README.md)] - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Geometry](../../tag/geometry/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Quickselect](../../tag/quickselect/README.md)] ### Similar Questions 1. [Kth Largest Element in an Array](../kth-largest-element-in-an-array) (Medium) 1. [Top K Frequent Elements](../top-k-frequent-elements) (Medium) 1. [Top K Frequent Words](../top-k-frequent-words) (Medium) + 1. [Find Nearest Point That Has the Same X or Y Coordinate](../find-nearest-point-that-has-the-same-x-or-y-coordinate) (Easy) diff --git a/problems/k-concatenation-maximum-sum/README.md b/problems/k-concatenation-maximum-sum/README.md index a42ff6462..7217df2cb 100644 --- a/problems/k-concatenation-maximum-sum/README.md +++ b/problems/k-concatenation-maximum-sum/README.md @@ -51,6 +51,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/k-diff-pairs-in-an-array/README.md b/problems/k-diff-pairs-in-an-array/README.md index 3ec759fea..dbfcab6fe 100644 --- a/problems/k-diff-pairs-in-an-array/README.md +++ b/problems/k-diff-pairs-in-an-array/README.md @@ -73,7 +73,10 @@ Although we have two 1s in the input, we should only return the number of You have N bulbs in a row numbered from 1 to N. Initially, all the bulbs are turned off. We turn on exactly one bulb everyday until all bulbs are on after N days.

    -

    You are given an array bulbs of length N where bulbs[i] = x means that on the (i+1)th day, we will turn on the bulb at position x where i is 0-indexed and x is 1-indexed.

    - -

    Given an integer K, find out the minimum day number such that there exists two turned on bulbs that have exactly K bulbs between them that are all turned off.

    - -

    If there isn't such day, return -1.

    - -

     

    - -

    Example 1:

    - -
    -Input: 
    -bulbs: [1,3,2]
    -K: 1
    -Output: 2
    -Explanation:
    -On the first day: bulbs[0] = 1, first bulb is turned on: [1,0,0]
    -On the second day: bulbs[1] = 3, third bulb is turned on: [1,0,1]
    -On the third day: bulbs[2] = 2, second bulb is turned on: [1,1,1]
    -We return 2 because on the second day, there were two on bulbs with one off bulb between them.
    -
    - -

    Example 2:

    - -
    -Input: 
    -bulbs: [1,2,3]
    -K: 1
    -Output: -1
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= N <= 20000
    2. -
    3. 1 <= bulbs[i] <= N
    4. -
    5. bulbs is a permutation of numbers from 1 to N.
    6. -
    7. 0 <= K <= 20000
    8. -
    ### Related Topics - [[Ordered Map](../../tag/ordered-map/README.md)] + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] diff --git a/problems/k-similar-strings/README.md b/problems/k-similar-strings/README.md index c510bbcc9..3f7d7d074 100644 --- a/problems/k-similar-strings/README.md +++ b/problems/k-similar-strings/README.md @@ -40,8 +40,8 @@ ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] - [[Graph](../../tag/graph/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Couples Holding Hands](../couples-holding-hands) (Hard) diff --git a/problems/k-th-smallest-in-lexicographical-order/README.md b/problems/k-th-smallest-in-lexicographical-order/README.md index 4c72d6345..00ede0949 100644 --- a/problems/k-th-smallest-in-lexicographical-order/README.md +++ b/problems/k-th-smallest-in-lexicographical-order/README.md @@ -35,3 +35,6 @@
    • 1 <= k <= n <= 109
    + +### Related Topics + [[Trie](../../tag/trie/README.md)] diff --git a/problems/k-th-smallest-prime-fraction/README.md b/problems/k-th-smallest-prime-fraction/README.md index 2b091d885..4a7f6f0c0 100644 --- a/problems/k-th-smallest-prime-fraction/README.md +++ b/problems/k-th-smallest-prime-fraction/README.md @@ -48,8 +48,9 @@ The third fraction is 2/5. ### Related Topics - [[Heap](../../tag/heap/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Kth Smallest Element in a Sorted Matrix](../kth-smallest-element-in-a-sorted-matrix) (Medium) diff --git a/problems/k-th-symbol-in-grammar/README.md b/problems/k-th-symbol-in-grammar/README.md index 81c8792b7..3830d8866 100644 --- a/problems/k-th-symbol-in-grammar/README.md +++ b/problems/k-th-symbol-in-grammar/README.md @@ -68,7 +68,9 @@ row 3: 0110 ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Recursion](../../tag/recursion/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/keyboard-row/README.md b/problems/keyboard-row/README.md index 140f7649a..eb993a5b6 100644 --- a/problems/keyboard-row/README.md +++ b/problems/keyboard-row/README.md @@ -53,4 +53,6 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/keys-and-rooms/README.md b/problems/keys-and-rooms/README.md index b229c3f06..0573ae24c 100644 --- a/problems/keys-and-rooms/README.md +++ b/problems/keys-and-rooms/README.md @@ -53,5 +53,6 @@ We then go to room 3. Since we were able to go to every room, we return true. ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] diff --git a/problems/kill-process/README.md b/problems/kill-process/README.md index fc8bf6ef2..cb9b796f2 100644 --- a/problems/kill-process/README.md +++ b/problems/kill-process/README.md @@ -11,37 +11,11 @@ ## [582. Kill Process (Medium)](https://leetcode.com/problems/kill-process "杀掉进程") -

    Given n processes, each process has a unique PID (process id) and its PPID (parent process id). -

    Each process only has one parent process, but may have one or more children processes. This is just like a tree structure. Only one process has PPID that is 0, which means this process has no parent process. All the PIDs will be distinct positive integers.

    - -

    We use two list of integers to represent a list of processes, where the first list contains PID for each process and the second list contains the corresponding PPID.

    - -

    Now given the two lists, and a PID representing a process you want to kill, return a list of PIDs of processes that will be killed in the end. You should assume that when a process is killed, all its children processes will be killed. No order is required for the final answer.

    - -

    Example 1:
    -

    Input: 
    -pid =  [1, 3, 10, 5]
    -ppid = [3, 0, 5, 3]
    -kill = 5
    -Output: [5,10]
    -Explanation: 
    -           3
    -         /   \
    -        1     5
    -             /
    -            10
    -Kill 5 will also kill 10.
    -
    -

    - -

    Note:
    -

      -
    1. The given kill id is guaranteed to be one of the given PIDs.
    2. -
    3. n >= 1.
    4. -
    -

    ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Queue](../../tag/queue/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/koko-eating-bananas/README.md b/problems/koko-eating-bananas/README.md index f9bf79576..43eeda9ad 100644 --- a/problems/koko-eating-bananas/README.md +++ b/problems/koko-eating-bananas/README.md @@ -51,6 +51,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions diff --git a/problems/kth-ancestor-of-a-tree-node/README.md b/problems/kth-ancestor-of-a-tree-node/README.md index 5981636cb..45fab111e 100644 --- a/problems/kth-ancestor-of-a-tree-node/README.md +++ b/problems/kth-ancestor-of-a-tree-node/README.md @@ -11,46 +11,51 @@ ## [1483. Kth Ancestor of a Tree Node (Hard)](https://leetcode.com/problems/kth-ancestor-of-a-tree-node "树节点的第 K 个祖先") -

    You are given a tree with n nodes numbered from 0 to n-1 in the form of a parent array where parent[i] is the parent of node i. The root of the tree is node 0.

    +

    You are given a tree with n nodes numbered from 0 to n - 1 in the form of a parent array parent where parent[i] is the parent of ith node. The root of the tree is node 0. Find the kth ancestor of a given node.

    -

    Implement the function getKthAncestor(int node, int k) to return the k-th ancestor of the given node. If there is no such ancestor, return -1.

    +

    The kth ancestor of a tree node is the kth node in the path from that node to the root node.

    -

    The k-th ancestor of a tree node is the k-th node in the path from that node to the root.

    +

    Implement the TreeAncestor class:

    -

     

    - -

    Example:

    - -

    +
      +
    • TreeAncestor(int n, int[] parent) Initializes the object with the number of nodes in the tree and the parent array.
    • +
    • int getKthAncestor(int node, int k) return the kth ancestor of the given node node. If there is no such ancestor, return -1.
    • +
    +

     

    +

    Example 1:

    +
    -Input:
    -["TreeAncestor","getKthAncestor","getKthAncestor","getKthAncestor"]
    -[[7,[-1,0,0,1,1,2,2]],[3,1],[5,2],[6,3]]
    +Input
    +["TreeAncestor", "getKthAncestor", "getKthAncestor", "getKthAncestor"]
    +[[7, [-1, 0, 0, 1, 1, 2, 2]], [3, 1], [5, 2], [6, 3]]
    +Output
    +[null, 1, 0, -1]
     
    -Output:
    -[null,1,0,-1]
    -
    -Explanation:
    +Explanation
     TreeAncestor treeAncestor = new TreeAncestor(7, [-1, 0, 0, 1, 1, 2, 2]);
    -
    -treeAncestor.getKthAncestor(3, 1);  // returns 1 which is the parent of 3
    -treeAncestor.getKthAncestor(5, 2);  // returns 0 which is the grandparent of 5
    -treeAncestor.getKthAncestor(6, 3);  // returns -1 because there is no such ancestor
    -
    +treeAncestor.getKthAncestor(3, 1); // returns 1 which is the parent of 3 +treeAncestor.getKthAncestor(5, 2); // returns 0 which is the grandparent of 5 +treeAncestor.getKthAncestor(6, 3); // returns -1 because there is no such ancestor

     

    Constraints:

      -
    • 1 <= k <= n <= 5*10^4
    • -
    • parent[0] == -1 indicating that 0 is the root node.
    • -
    • 0 <= parent[i] < n for all 0 < i < n
    • +
    • 1 <= k <= n <= 5 * 104
    • +
    • parent.length == n
    • +
    • parent[0] == -1
    • +
    • 0 <= parent[i] < n for all 0 < i < n
    • 0 <= node < n
    • -
    • There will be at most 5*10^4 queries.
    • +
    • There will be at most 5 * 104 queries.
    ### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Design](../../tag/design/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/kth-largest-element-in-a-stream/README.md b/problems/kth-largest-element-in-a-stream/README.md index 105c37968..762b4da3d 100644 --- a/problems/kth-largest-element-in-a-stream/README.md +++ b/problems/kth-largest-element-in-a-stream/README.md @@ -52,8 +52,12 @@ kthLargest.add(4); // return 8 ### Related Topics - [[Heap](../../tag/heap/README.md)] + [[Tree](../../tag/tree/README.md)] [[Design](../../tag/design/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Kth Largest Element in an Array](../kth-largest-element-in-an-array) (Medium) diff --git a/problems/kth-largest-element-in-an-array/README.md b/problems/kth-largest-element-in-an-array/README.md index 1545efc36..d96cba83e 100644 --- a/problems/kth-largest-element-in-an-array/README.md +++ b/problems/kth-largest-element-in-an-array/README.md @@ -32,8 +32,11 @@ ### Related Topics - [[Heap](../../tag/heap/README.md)] + [[Array](../../tag/array/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Quickselect](../../tag/quickselect/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Wiggle Sort II](../wiggle-sort-ii) (Medium) diff --git a/problems/kth-missing-positive-number/README.md b/problems/kth-missing-positive-number/README.md index 714febe8d..63e8ab069 100644 --- a/problems/kth-missing-positive-number/README.md +++ b/problems/kth-missing-positive-number/README.md @@ -44,7 +44,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
    diff --git a/problems/kth-smallest-element-in-a-bst/README.md b/problems/kth-smallest-element-in-a-bst/README.md index 333a700df..f8eda47d2 100644 --- a/problems/kth-smallest-element-in-a-bst/README.md +++ b/problems/kth-smallest-element-in-a-bst/README.md @@ -42,7 +42,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Easy) diff --git a/problems/kth-smallest-element-in-a-sorted-matrix/README.md b/problems/kth-smallest-element-in-a-sorted-matrix/README.md index 9465bfa82..acc313d66 100644 --- a/problems/kth-smallest-element-in-a-sorted-matrix/README.md +++ b/problems/kth-smallest-element-in-a-sorted-matrix/README.md @@ -44,8 +44,11 @@ ### Related Topics - [[Heap](../../tag/heap/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Find K Pairs with Smallest Sums](../find-k-pairs-with-smallest-sums) (Medium) diff --git a/problems/kth-smallest-instructions/README.md b/problems/kth-smallest-instructions/README.md index f24a0dcd9..43d8a7e9e 100644 --- a/problems/kth-smallest-instructions/README.md +++ b/problems/kth-smallest-instructions/README.md @@ -66,7 +66,10 @@ ### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Combinatorics](../../tag/combinatorics/README.md)] ### Hints
    diff --git a/problems/kth-smallest-subarray-sum/README.md b/problems/kth-smallest-subarray-sum/README.md new file mode 100644 index 000000000..334a0c5d0 --- /dev/null +++ b/problems/kth-smallest-subarray-sum/README.md @@ -0,0 +1,30 @@ + + + + + + + +[< Previous](../leetcodify-friends-recommendations "Leetcodify Friends Recommendations") +                 +[Next >](../leetcodify-similar-friends "Leetcodify Similar Friends") + +## [1918. Kth Smallest Subarray Sum (Medium)](https://leetcode.com/problems/kth-smallest-subarray-sum "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
    +Hint 1 +How can you compute the number of subarrays with a sum less than a given value? +
    + +
    +Hint 2 +Can we use binary search to help find the answer? +
    diff --git a/problems/largest-1-bordered-square/README.md b/problems/largest-1-bordered-square/README.md index be8fb3820..35359c6e7 100644 --- a/problems/largest-1-bordered-square/README.md +++ b/problems/largest-1-bordered-square/README.md @@ -38,7 +38,9 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/largest-bst-subtree/README.md b/problems/largest-bst-subtree/README.md index b2905ff2b..42bd7d77b 100644 --- a/problems/largest-bst-subtree/README.md +++ b/problems/largest-bst-subtree/README.md @@ -11,32 +11,14 @@ ## [333. Largest BST Subtree (Medium)](https://leetcode.com/problems/largest-bst-subtree "最大 BST 子树") -

    Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest means subtree with largest number of nodes in it.

    -

    Note:
    -A subtree must include all of its descendants.

    - -

    Example:

    - -
    -Input: [10,5,15,1,8,null,7]
    -
    -   10 
    -   / \ 
    -  5  15 
    - / \   \ 
    -1   8   7
    -
    -Output: 3
    -Explanation: The Largest BST Subtree in this case is the highlighted one.
    -             The return value is the subtree's size, which is 3.
    -
    - -

    Follow up:
    -Can you figure out ways to solve it with O(n) time complexity?

    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/largest-color-value-in-a-directed-graph/README.md b/problems/largest-color-value-in-a-directed-graph/README.md index 99c359dee..57ca403d2 100644 --- a/problems/largest-color-value-in-a-directed-graph/README.md +++ b/problems/largest-color-value-in-a-directed-graph/README.md @@ -53,8 +53,12 @@ ### Related Topics + [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/largest-component-size-by-common-factor/README.md b/problems/largest-component-size-by-common-factor/README.md index af312f5c6..4f8032059 100644 --- a/problems/largest-component-size-by-common-factor/README.md +++ b/problems/largest-component-size-by-common-factor/README.md @@ -64,4 +64,5 @@ ### Related Topics [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/largest-divisible-subset/README.md b/problems/largest-divisible-subset/README.md index 09476e7d5..0f9a2ebe3 100644 --- a/problems/largest-divisible-subset/README.md +++ b/problems/largest-divisible-subset/README.md @@ -46,5 +46,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/largest-magic-square/README.md b/problems/largest-magic-square/README.md new file mode 100644 index 000000000..59cda4a50 --- /dev/null +++ b/problems/largest-magic-square/README.md @@ -0,0 +1,57 @@ + + + + + + + +[< Previous](../find-the-student-that-will-replace-the-chalk "Find the Student that Will Replace the Chalk") +                 +[Next >](../minimum-cost-to-change-the-final-value-of-expression "Minimum Cost to Change the Final Value of Expression") + +## [1895. Largest Magic Square (Medium)](https://leetcode.com/problems/largest-magic-square "最大的幻方") + +

    A k x k magic square is a k x k grid filled with integers such that every row sum, every column sum, and both diagonal sums are all equal. The integers in the magic square do not have to be distinct. Every 1 x 1 grid is trivially a magic square.

    + +

    Given an m x n integer grid, return the size (i.e., the side length k) of the largest magic square that can be found within this grid.

    + +

     

    +

    Example 1:

    + +
    +Input: grid = [[7,1,4,5,6],[2,5,1,6,4],[1,5,4,3,2],[1,2,7,3,4]]
    +Output: 3
    +Explanation: The largest magic square has a size of 3.
    +Every row sum, column sum, and diagonal sum of this magic square is equal to 12.
    +- Row sums: 5+1+6 = 5+4+3 = 2+7+3 = 12
    +- Column sums: 5+5+2 = 1+4+7 = 6+3+3 = 12
    +- Diagonal sums: 5+4+3 = 6+4+2 = 12
    +
    + +

    Example 2:

    + +
    +Input: grid = [[5,1,3,1],[9,3,3,1],[1,3,3,8]]
    +Output: 2
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 50
    • +
    • 1 <= grid[i][j] <= 106
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +Check all squares in the matrix and find the largest one. +
    diff --git a/problems/largest-merge-of-two-strings/README.md b/problems/largest-merge-of-two-strings/README.md index 0892bf50e..d0e7b18d9 100644 --- a/problems/largest-merge-of-two-strings/README.md +++ b/problems/largest-merge-of-two-strings/README.md @@ -62,6 +62,8 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/largest-multiple-of-three/README.md b/problems/largest-multiple-of-three/README.md index 72e8b52e2..83727e4c6 100644 --- a/problems/largest-multiple-of-three/README.md +++ b/problems/largest-multiple-of-three/README.md @@ -56,7 +56,8 @@ ### Related Topics - [[Math](../../tag/math/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/largest-number-at-least-twice-of-others/README.md b/problems/largest-number-at-least-twice-of-others/README.md index cbaf796ef..3c2ffe674 100644 --- a/problems/largest-number-at-least-twice-of-others/README.md +++ b/problems/largest-number-at-least-twice-of-others/README.md @@ -52,6 +52,7 @@ The index of value 6 is 1, so we return 1. ### Related Topics [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/largest-number/README.md b/problems/largest-number/README.md index b434066ef..14e6b65ba 100644 --- a/problems/largest-number/README.md +++ b/problems/largest-number/README.md @@ -53,4 +53,6 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/largest-odd-number-in-string/README.md b/problems/largest-odd-number-in-string/README.md new file mode 100644 index 000000000..791077f0c --- /dev/null +++ b/problems/largest-odd-number-in-string/README.md @@ -0,0 +1,65 @@ + + + + + + + +[< Previous](../depth-of-bst-given-insertion-order "Depth of BST Given Insertion Order") +                 +[Next >](../the-number-of-full-rounds-you-have-played "The Number of Full Rounds You Have Played") + +## [1903. Largest Odd Number in String (Easy)](https://leetcode.com/problems/largest-odd-number-in-string "字符串中的最大奇数") + +

    You are given a string num, representing a large integer. Return the largest-valued odd integer (as a string) that is a non-empty substring of num, or an empty string "" if no odd integer exists.

    + +

    A substring is a contiguous sequence of characters within a string.

    + +

     

    +

    Example 1:

    + +
    +Input: num = "52"
    +Output: "5"
    +Explanation: The only non-empty substrings are "5", "2", and "52". "5" is the only odd number.
    +
    + +

    Example 2:

    + +
    +Input: num = "4206"
    +Output: ""
    +Explanation: There are no odd numbers in "4206".
    +
    + +

    Example 3:

    + +
    +Input: num = "35427"
    +Output: "35427"
    +Explanation: "35427" is already an odd number.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= num.length <= 105
    • +
    • num only consists of digits and does not contain any leading zeros.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +In what order should you iterate through the digits? +
    + +
    +Hint 2 +If an odd number exists, where must the number start from? +
    diff --git a/problems/largest-palindrome-product/README.md b/problems/largest-palindrome-product/README.md index 7d2cc741d..b46bed414 100644 --- a/problems/largest-palindrome-product/README.md +++ b/problems/largest-palindrome-product/README.md @@ -35,3 +35,6 @@ Explanation: 99 x 91 = 9009, 9009 % 1337 = 987
    • 1 <= n <= 8
    + +### Related Topics + [[Math](../../tag/math/README.md)] diff --git a/problems/largest-perimeter-triangle/README.md b/problems/largest-perimeter-triangle/README.md index 41478ee1d..924d7001a 100644 --- a/problems/largest-perimeter-triangle/README.md +++ b/problems/largest-perimeter-triangle/README.md @@ -36,8 +36,10 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Largest Triangle Area](../largest-triangle-area) (Easy) diff --git a/problems/largest-plus-sign/README.md b/problems/largest-plus-sign/README.md index b7eac9098..16767ccb8 100644 --- a/problems/largest-plus-sign/README.md +++ b/problems/largest-plus-sign/README.md @@ -11,79 +11,41 @@ ## [764. Largest Plus Sign (Medium)](https://leetcode.com/problems/largest-plus-sign "最大加号标志") -

    In a 2D grid from (0, 0) to (n-1, n-1), every cell contains a 1, except those cells in the given list mines which are 0. What is the largest axis-aligned plus sign of 1s contained in the grid? Return the order of the plus sign. If there is none, return 0.

    +

    You are given an integer n. You have an n x n binary grid grid with all values initially 1's except for some indices given in the array mines. The ith element of the array mines is defined as mines[i] = [xi, yi] where grid[xi][yi] == 0.

    -

    An "axis-aligned plus sign of 1s of order k" has some center grid[x][y] = 1 along with 4 arms of length k-1 going up, down, left, and right, and made of 1s. This is demonstrated in the diagrams below. Note that there could be 0s or 1s beyond the arms of the plus sign, only the relevant area of the plus sign is checked for 1s.

    +

    Return the order of the largest axis-aligned plus sign of 1's contained in grid. If there is none, return 0.

    -

    Examples of Axis-Aligned Plus Signs of Order k:

    - -
    -Order 1:
    -000
    -010
    -000
    -
    -Order 2:
    -00000
    -00100
    -01110
    -00100
    -00000
    -
    -Order 3:
    -0000000
    -0001000
    -0001000
    -0111110
    -0001000
    -0001000
    -0000000
    -
    - -

    Example 1:

    - -
    -Input: n = 5, mines = [[4, 2]]
    -Output: 2
    -Explanation:
    -11111
    -11111
    -11111
    -11111
    -11011
    -In the above grid, the largest plus sign can only be order 2.  One of them is marked in bold.
    -
    - -

    Example 2:

    +

    An axis-aligned plus sign of 1's of order k has some center grid[r][c] == 1 along with four arms of length k - 1 going up, down, left, and right, and made of 1's. Note that there could be 0's or 1's beyond the arms of the plus sign, only the relevant area of the plus sign is checked for 1's.

    +

     

    +

    Example 1:

    +
    -Input: n = 2, mines = []
    -Output: 1
    -Explanation:
    -There is no plus sign of order 2, but there is of order 1.
    +Input: n = 5, mines = [[4,2]]
    +Output: 2
    +Explanation: In the above grid, the largest plus sign can only be of order 2. One of them is shown.
     
    -

    Example 3:

    - +

    Example 2:

    +
    -Input: n = 1, mines = [[0, 0]]
    -Output: 0
    -Explanation:
    -There is no plus sign, so return 0.
    +Input: n = 1, mines = [[0,0]]
    +Output: 0
    +Explanation: There is no plus sign, so return 0.
     
    -

    Note:

    - -
      -
    1. n will be an integer in the range [1, 500].
    2. -
    3. mines will have length at most 5000.
    4. -
    5. mines[i] will be length 2 and consist of integers in the range [0, n-1].
    6. -
    7. (Additionally, programs submitted in C, C++, or C# will be judged with a slightly smaller time limit.)
    8. -
    -

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 500
    • +
    • 1 <= mines.length <= 5000
    • +
    • 0 <= xi, yi < n
    • +
    • All the pairs (xi, yi) are unique.
    • +
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/largest-rectangle-in-histogram/README.md b/problems/largest-rectangle-in-histogram/README.md index a944c55db..8c39df842 100644 --- a/problems/largest-rectangle-in-histogram/README.md +++ b/problems/largest-rectangle-in-histogram/README.md @@ -41,6 +41,7 @@ The largest rectangle is shown in the red area, which has an area = 10 units. ### Related Topics [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Similar Questions 1. [Maximal Rectangle](../maximal-rectangle) (Hard) diff --git a/problems/largest-submatrix-with-rearrangements/README.md b/problems/largest-submatrix-with-rearrangements/README.md index 0a91dc32b..7c6e765e0 100644 --- a/problems/largest-submatrix-with-rearrangements/README.md +++ b/problems/largest-submatrix-with-rearrangements/README.md @@ -64,7 +64,9 @@ The largest submatrix of 1s, in bold, has an area of 3. ### Related Topics [[Greedy](../../tag/greedy/README.md)] - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/largest-substring-between-two-equal-characters/README.md b/problems/largest-substring-between-two-equal-characters/README.md index 5ace94ab1..69dbaf3e6 100644 --- a/problems/largest-substring-between-two-equal-characters/README.md +++ b/problems/largest-substring-between-two-equal-characters/README.md @@ -56,6 +56,7 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/largest-sum-of-averages/README.md b/problems/largest-sum-of-averages/README.md index 1df8fa879..19f91e79a 100644 --- a/problems/largest-sum-of-averages/README.md +++ b/problems/largest-sum-of-averages/README.md @@ -39,4 +39,5 @@ That partition would lead to a score of 5 + 2 + 6 = 13, which is worse. ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/largest-time-for-given-digits/README.md b/problems/largest-time-for-given-digits/README.md index cad630633..ba0573dd8 100644 --- a/problems/largest-time-for-given-digits/README.md +++ b/problems/largest-time-for-given-digits/README.md @@ -57,4 +57,5 @@ ### Related Topics - [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] diff --git a/problems/largest-triangle-area/README.md b/problems/largest-triangle-area/README.md index e03102598..0d7e61ae6 100644 --- a/problems/largest-triangle-area/README.md +++ b/problems/largest-triangle-area/README.md @@ -35,6 +35,8 @@ The five points are show in the figure below. The red triangle is the largest.

     

    ### Related Topics + [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] ### Similar Questions diff --git a/problems/largest-unique-number/README.md b/problems/largest-unique-number/README.md index bef0cfe4d..51efc5857 100644 --- a/problems/largest-unique-number/README.md +++ b/problems/largest-unique-number/README.md @@ -11,42 +11,12 @@ ## [1133. Largest Unique Number (Easy)](https://leetcode.com/problems/largest-unique-number "最大唯一数") -

    Given an array of integers A, return the largest integer that only occurs once.

    -

    If no integer occurs once, return -1.

    - -

     

    - -

    Example 1:

    - -
    -Input: [5,7,3,9,4,9,8,3,1]
    -Output: 8
    -Explanation: 
    -The maximum integer in the array is 9 but it is repeated. The number 8 occurs only once, so it's the answer.
    -
    - -

    Example 2:

    - -
    -Input: [9,9,8,8]
    -Output: -1
    -Explanation: 
    -There is no number that occurs only once.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= A.length <= 2000
    2. -
    3. 0 <= A[i] <= 1000
    4. -
    ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/largest-values-from-labels/README.md b/problems/largest-values-from-labels/README.md index a71b155d7..dac3364d0 100644 --- a/problems/largest-values-from-labels/README.md +++ b/problems/largest-values-from-labels/README.md @@ -76,7 +76,10 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md b/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md index e1b5c38bb..f68c40999 100644 --- a/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md +++ b/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md @@ -80,6 +80,7 @@ Note that the last moment when an ant was on the plank is t = 4 second, after th ### Related Topics [[Brainteaser](../../tag/brainteaser/README.md)] [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/last-person-to-fit-in-the-bus/README.md b/problems/last-person-to-fit-in-the-bus/README.md new file mode 100644 index 000000000..f2795f8aa --- /dev/null +++ b/problems/last-person-to-fit-in-the-bus/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../sort-items-by-groups-respecting-dependencies "Sort Items by Groups Respecting Dependencies") +                 +[Next >](../monthly-transactions-ii "Monthly Transactions II") + +## [1204. Last Person to Fit in the Bus (Medium)](https://leetcode.com/problems/last-person-to-fit-in-the-bus "最后一个能进入电梯的人") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/last-person-to-fit-in-the-bus/mysql_schemas.sql b/problems/last-person-to-fit-in-the-bus/mysql_schemas.sql new file mode 100644 index 000000000..fe75f3b5b --- /dev/null +++ b/problems/last-person-to-fit-in-the-bus/mysql_schemas.sql @@ -0,0 +1,8 @@ +Create table If Not Exists Queue (person_id int, person_name varchar(30), weight int, turn int); +Truncate table Queue; +insert into Queue (person_id, person_name, weight, turn) values ('5', 'Alice', '250', '1'); +insert into Queue (person_id, person_name, weight, turn) values ('4', 'Bob', '175', '5'); +insert into Queue (person_id, person_name, weight, turn) values ('3', 'Alex', '350', '2'); +insert into Queue (person_id, person_name, weight, turn) values ('6', 'John Cena', '400', '3'); +insert into Queue (person_id, person_name, weight, turn) values ('1', 'Winston', '500', '6'); +insert into Queue (person_id, person_name, weight, turn) values ('2', 'Marie', '200', '4'); diff --git a/problems/last-stone-weight-ii/README.md b/problems/last-stone-weight-ii/README.md index 11c649299..011157ea3 100644 --- a/problems/last-stone-weight-ii/README.md +++ b/problems/last-stone-weight-ii/README.md @@ -60,6 +60,7 @@ we can combine 1 and 1 to get 0, so the array converts to [1], then that's t ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/last-stone-weight/README.md b/problems/last-stone-weight/README.md index 06263254a..65dade789 100644 --- a/problems/last-stone-weight/README.md +++ b/problems/last-stone-weight/README.md @@ -45,8 +45,8 @@ we combine 1 and 1 to get 0 so the array converts to [1] then that's the val ### Related Topics - [[Heap](../../tag/heap/README.md)] - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/last-substring-in-lexicographical-order/README.md b/problems/last-substring-in-lexicographical-order/README.md index 4767d05ab..59cc6eebd 100644 --- a/problems/last-substring-in-lexicographical-order/README.md +++ b/problems/last-substring-in-lexicographical-order/README.md @@ -38,6 +38,7 @@ ### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/latest-time-by-replacing-hidden-digits/README.md b/problems/latest-time-by-replacing-hidden-digits/README.md index 518bb1569..cb8487ada 100644 --- a/problems/latest-time-by-replacing-hidden-digits/README.md +++ b/problems/latest-time-by-replacing-hidden-digits/README.md @@ -49,7 +49,6 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/leaf-similar-trees/README.md b/problems/leaf-similar-trees/README.md index 29f5ad7f4..38ce2a321 100644 --- a/problems/leaf-similar-trees/README.md +++ b/problems/leaf-similar-trees/README.md @@ -67,4 +67,5 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/league-statistics/README.md b/problems/league-statistics/README.md index a7d3585ce..1484b9fe0 100644 --- a/problems/league-statistics/README.md +++ b/problems/league-statistics/README.md @@ -12,3 +12,6 @@ ## [1841. League Statistics (Medium)](https://leetcode.com/problems/league-statistics "") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/least-number-of-unique-integers-after-k-removals/README.md b/problems/least-number-of-unique-integers-after-k-removals/README.md index 9a244fddf..5e8afd7db 100644 --- a/problems/least-number-of-unique-integers-after-k-removals/README.md +++ b/problems/least-number-of-unique-integers-after-k-removals/README.md @@ -41,8 +41,11 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/leetcodify-friends-recommendations/README.md b/problems/leetcodify-friends-recommendations/README.md new file mode 100644 index 000000000..1ea2a6933 --- /dev/null +++ b/problems/leetcodify-friends-recommendations/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../count-ways-to-build-rooms-in-an-ant-colony "Count Ways to Build Rooms in an Ant Colony") +                 +[Next >](../kth-smallest-subarray-sum "Kth Smallest Subarray Sum") + +## [1917. Leetcodify Friends Recommendations (Hard)](https://leetcode.com/problems/leetcodify-friends-recommendations "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/leetcodify-friends-recommendations/mysql_schemas.sql b/problems/leetcodify-friends-recommendations/mysql_schemas.sql new file mode 100644 index 000000000..d991fe675 --- /dev/null +++ b/problems/leetcodify-friends-recommendations/mysql_schemas.sql @@ -0,0 +1,20 @@ +Create table If Not Exists Listens (user_id int, song_id int, day date); +Create table If Not Exists Friendship (user1_id int, user2_id int); +Truncate table Listens; +insert into Listens (user_id, song_id, day) values ('1', '10', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('1', '11', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('1', '12', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('2', '10', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('2', '11', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('2', '12', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('3', '10', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('3', '11', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('3', '12', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('4', '10', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('4', '11', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('4', '13', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('5', '10', '2021-03-16'); +insert into Listens (user_id, song_id, day) values ('5', '11', '2021-03-16'); +insert into Listens (user_id, song_id, day) values ('5', '12', '2021-03-16'); +Truncate table Friendship; +insert into Friendship (user1_id, user2_id) values ('1', '2'); diff --git a/problems/leetcodify-similar-friends/README.md b/problems/leetcodify-similar-friends/README.md new file mode 100644 index 000000000..c15d350c5 --- /dev/null +++ b/problems/leetcodify-similar-friends/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../kth-smallest-subarray-sum "Kth Smallest Subarray Sum") +                 +[Next >](../build-array-from-permutation "Build Array from Permutation") + +## [1919. Leetcodify Similar Friends (Hard)](https://leetcode.com/problems/leetcodify-similar-friends "") + + diff --git a/problems/leetcodify-similar-friends/mysql_schemas.sql b/problems/leetcodify-similar-friends/mysql_schemas.sql new file mode 100644 index 000000000..a1c1de591 --- /dev/null +++ b/problems/leetcodify-similar-friends/mysql_schemas.sql @@ -0,0 +1,22 @@ +Create table If Not Exists Listens (user_id int, song_id int, day date); +Create table If Not Exists Friendship (user1_id int, user2_id int); +Truncate table Listens; +insert into Listens (user_id, song_id, day) values ('1', '10', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('1', '11', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('1', '12', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('2', '10', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('2', '11', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('2', '12', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('3', '10', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('3', '11', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('3', '12', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('4', '10', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('4', '11', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('4', '13', '2021-03-15'); +insert into Listens (user_id, song_id, day) values ('5', '10', '2021-03-16'); +insert into Listens (user_id, song_id, day) values ('5', '11', '2021-03-16'); +insert into Listens (user_id, song_id, day) values ('5', '12', '2021-03-16'); +Truncate table Friendship; +insert into Friendship (user1_id, user2_id) values ('1', '2'); +insert into Friendship (user1_id, user2_id) values ('2', '4'); +insert into Friendship (user1_id, user2_id) values ('2', '5'); diff --git a/problems/leetflex-banned-accounts/README.md b/problems/leetflex-banned-accounts/README.md index 82a948046..9abe49cd9 100644 --- a/problems/leetflex-banned-accounts/README.md +++ b/problems/leetflex-banned-accounts/README.md @@ -12,3 +12,6 @@ ## [1747. Leetflex Banned Accounts (Medium)](https://leetcode.com/problems/leetflex-banned-accounts "应该被禁止的Leetflex账户") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/leftmost-column-with-at-least-a-one/README.md b/problems/leftmost-column-with-at-least-a-one/README.md index 75c48d336..52434c5cc 100644 --- a/problems/leftmost-column-with-at-least-a-one/README.md +++ b/problems/leftmost-column-with-at-least-a-one/README.md @@ -15,6 +15,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Interactive](../../tag/interactive/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/lemonade-change/README.md b/problems/lemonade-change/README.md index 0abf8e839..6dff3b59c 100644 --- a/problems/lemonade-change/README.md +++ b/problems/lemonade-change/README.md @@ -80,3 +80,4 @@ Since not every customer received correct change, the answer is false. ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/length-of-longest-fibonacci-subsequence/README.md b/problems/length-of-longest-fibonacci-subsequence/README.md index 6fe4be3c3..fb769902d 100644 --- a/problems/length-of-longest-fibonacci-subsequence/README.md +++ b/problems/length-of-longest-fibonacci-subsequence/README.md @@ -47,6 +47,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/letter-case-permutation/README.md b/problems/letter-case-permutation/README.md index 178842e5c..2b66690bb 100644 --- a/problems/letter-case-permutation/README.md +++ b/problems/letter-case-permutation/README.md @@ -54,6 +54,7 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions diff --git a/problems/letter-combinations-of-a-phone-number/README.md b/problems/letter-combinations-of-a-phone-number/README.md index c8f86c688..6a7642720 100644 --- a/problems/letter-combinations-of-a-phone-number/README.md +++ b/problems/letter-combinations-of-a-phone-number/README.md @@ -48,8 +48,7 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Recursion](../../tag/recursion/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/letter-tile-possibilities/README.md b/problems/letter-tile-possibilities/README.md index f72cd0874..1b0f83163 100644 --- a/problems/letter-tile-possibilities/README.md +++ b/problems/letter-tile-possibilities/README.md @@ -47,6 +47,7 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Hints diff --git a/problems/lexicographical-numbers/README.md b/problems/lexicographical-numbers/README.md index f8fabfcc2..54b4ad933 100644 --- a/problems/lexicographical-numbers/README.md +++ b/problems/lexicographical-numbers/README.md @@ -29,3 +29,7 @@
    • 1 <= n <= 5 * 104
    + +### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Trie](../../tag/trie/README.md)] diff --git a/problems/lexicographically-smallest-equivalent-string/README.md b/problems/lexicographically-smallest-equivalent-string/README.md index 273d83928..e3907ccdd 100644 --- a/problems/lexicographically-smallest-equivalent-string/README.md +++ b/problems/lexicographically-smallest-equivalent-string/README.md @@ -11,59 +11,11 @@ ## [1061. Lexicographically Smallest Equivalent String (Medium)](https://leetcode.com/problems/lexicographically-smallest-equivalent-string "按字典序排列最小的等效字符串") -

    Given strings A and B of the same length, we say A[i] and B[i] are equivalent characters. For example, if A = "abc" and B = "cde", then we have 'a' == 'c', 'b' == 'd', 'c' == 'e'.

    -

    Equivalent characters follow the usual rules of any equivalence relation:

    - -
      -
    • Reflexivity: 'a' == 'a'
    • -
    • Symmetry: 'a' == 'b' implies 'b' == 'a'
    • -
    • Transitivity: 'a' == 'b' and 'b' == 'c' implies 'a' == 'c'
    • -
    - -

    For example, given the equivalency information from A and B above, S = "eed", "acd", and "aab" are equivalent strings, and "aab" is the lexicographically smallest equivalent string of S.

    - -

    Return the lexicographically smallest equivalent string of S by using the equivalency information from A and B.

    - -

     

    - -

    Example 1:

    - -
    -Input: A = "parker", B = "morris", S = "parser"
    -Output: "makkek"
    -Explanation: Based on the equivalency information in A and B, we can group their characters as [m,p], [a,o], [k,r,s], [e,i]. The characters in each group are equivalent and sorted in lexicographical order. So the answer is "makkek".
    -
    - -

    Example 2:

    - -
    -Input: A = "hello", B = "world", S = "hold"
    -Output: "hdld"
    -Explanation:  Based on the equivalency information in A and B, we can group their characters as [h,w], [d,e,o], [l,r]. So only the second letter 'o' in S is changed to 'd', the answer is "hdld".
    -
    - -

    Example 3:

    - -
    -Input: A = "leetcode", B = "programs", S = "sourcecode"
    -Output: "aauaaaaada"
    -Explanation:  We group the equivalent characters in A and B as [a,o,e,r,s,c], [l,p], [g,t] and [d,m], thus all letters in S except 'u' and 'd' are transformed to 'a', the answer is "aauaaaaada".
    -
    - -

     

    - -

    Note:

    - -
      -
    1. String A, B and S consist of only lowercase English letters from 'a' - 'z'.
    2. -
    3. The lengths of string A, B and S are between 1 and 1000.
    4. -
    5. String A and B are of the same length.
    6. -
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/lexicographically-smallest-string-after-applying-operations/README.md b/problems/lexicographically-smallest-string-after-applying-operations/README.md index 849dd3b78..5b989496f 100644 --- a/problems/lexicographically-smallest-string-after-applying-operations/README.md +++ b/problems/lexicographically-smallest-string-after-applying-operations/README.md @@ -83,8 +83,8 @@ There is no way to obtain a string that is lexicographically smaller then " ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/lfu-cache/README.md b/problems/lfu-cache/README.md index 94c9f70ca..fd420a0ad 100644 --- a/problems/lfu-cache/README.md +++ b/problems/lfu-cache/README.md @@ -25,6 +25,8 @@

    When a key is first inserted into the cache, its use counter is set to 1 (due to the put operation). The use counter for a key in the cache is incremented either a get or put operation is called on it.

    +

    The functions get and put must each run in O(1) average time complexity.

    +

     

    Example 1:

    @@ -61,15 +63,20 @@ lfu.get(4); // return 4

    Constraints:

      -
    • 0 <= capacity, key, value <= 104
    • -
    • At most 105 calls will be made to get and put.
    • +
    • 0 <= capacity <= 104
    • +
    • 0 <= key <= 105
    • +
    • 0 <= value <= 109
    • +
    • At most 2 * 105 calls will be made to get and put.

     

    -Follow up: Could you do both operations in O(1) time complexity?  +  ### Related Topics [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Doubly-Linked List](../../tag/doubly-linked-list/README.md)] ### Similar Questions 1. [LRU Cache](../lru-cache) (Medium) diff --git a/problems/license-key-formatting/README.md b/problems/license-key-formatting/README.md index 44695926c..3e4e7ef5e 100644 --- a/problems/license-key-formatting/README.md +++ b/problems/license-key-formatting/README.md @@ -43,3 +43,6 @@ Note that the two extra dashes are not needed and can be removed.
  • s consists of English letters, digits, and dashes '-'.
  • 1 <= k <= 104
  • + +### Related Topics + [[String](../../tag/string/README.md)] diff --git a/problems/line-reflection/README.md b/problems/line-reflection/README.md index aac011c2a..e7e84c1b2 100644 --- a/problems/line-reflection/README.md +++ b/problems/line-reflection/README.md @@ -11,23 +11,10 @@ ## [356. Line Reflection (Medium)](https://leetcode.com/problems/line-reflection "直线镜像") -

    Given n points on a 2D plane, find if there is such a line parallel to y-axis that reflect the given points.

    -

    Example 1:

    - -
    -Input: [[1,1],[-1,1]]
    -Output: true
    -
    - -
    -

    Example 2:

    - -
    -Input: [[1,1],[-1,-1]]
    -Output: false
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/linked-list-components/README.md b/problems/linked-list-components/README.md index 3d59372f8..d4f1a7f33 100644 --- a/problems/linked-list-components/README.md +++ b/problems/linked-list-components/README.md @@ -49,4 +49,5 @@ nums = [0, 3, 1, 4] ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/linked-list-cycle-ii/README.md b/problems/linked-list-cycle-ii/README.md index df02b7928..91c2b1471 100644 --- a/problems/linked-list-cycle-ii/README.md +++ b/problems/linked-list-cycle-ii/README.md @@ -55,6 +55,7 @@

    Follow up: Can you solve it using O(1) (i.e. constant) memory?

    ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/linked-list-cycle/README.md b/problems/linked-list-cycle/README.md index 0546e3174..1f86ca6c2 100644 --- a/problems/linked-list-cycle/README.md +++ b/problems/linked-list-cycle/README.md @@ -55,6 +55,7 @@

    Follow up: Can you solve it using O(1) (i.e. constant) memory?

    ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/linked-list-in-binary-tree/README.md b/problems/linked-list-in-binary-tree/README.md index 72731a9b8..332d65103 100644 --- a/problems/linked-list-in-binary-tree/README.md +++ b/problems/linked-list-in-binary-tree/README.md @@ -56,8 +56,10 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Linked List](../../tag/linked-list/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/linked-list-random-node/README.md b/problems/linked-list-random-node/README.md index 960499cef..84cabbd11 100644 --- a/problems/linked-list-random-node/README.md +++ b/problems/linked-list-random-node/README.md @@ -52,6 +52,9 @@ solution.getRandom(); // return 3 ### Related Topics [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Math](../../tag/math/README.md)] + [[Randomized](../../tag/randomized/README.md)] ### Similar Questions 1. [Random Pick Index](../random-pick-index) (Medium) diff --git a/problems/list-the-products-ordered-in-a-period/README.md b/problems/list-the-products-ordered-in-a-period/README.md index 26471f8b5..3e3989858 100644 --- a/problems/list-the-products-ordered-in-a-period/README.md +++ b/problems/list-the-products-ordered-in-a-period/README.md @@ -11,80 +11,7 @@ ## [1327. List the Products Ordered in a Period (Easy)](https://leetcode.com/problems/list-the-products-ordered-in-a-period "列出指定时间段内所有的下单产品") -SQL Schema -

    Table: Products

    -
    -+------------------+---------+
    -| Column Name      | Type    |
    -+------------------+---------+
    -| product_id       | int     |
    -| product_name     | varchar |
    -| product_category | varchar |
    -+------------------+---------+
    -product_id is the primary key for this table.
    -This table contains data about the company's products.
    -
    -

    Table: Orders

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| product_id    | int     |
    -| order_date    | date    |
    -| unit          | int     |
    -+---------------+---------+
    -There is no primary key for this table. It may have duplicate rows.
    -product_id is a foreign key to Products table.
    -unit is the number of products ordered in order_date.
    -
    - -Write an SQL query to get the names of products with greater than or equal to 100 units ordered in February 2020 and their amount. -Return result table in any order. - -The query result format is in the following example: -
    -Products table:
    -+-------------+-----------------------+------------------+
    -| product_id  | product_name          | product_category |
    -+-------------+-----------------------+------------------+
    -| 1           | Leetcode Solutions    | Book             |
    -| 2           | Jewels of Stringology | Book             |
    -| 3           | HP                    | Laptop           |
    -| 4           | Lenovo                | Laptop           |
    -| 5           | Leetcode Kit          | T-shirt          |
    -+-------------+-----------------------+------------------+
    -
    -Orders table:
    -+--------------+--------------+----------+
    -| product_id   | order_date   | unit     |
    -+--------------+--------------+----------+
    -| 1            | 2020-02-05   | 60       |
    -| 1            | 2020-02-10   | 70       |
    -| 2            | 2020-01-18   | 30       |
    -| 2            | 2020-02-11   | 80       |
    -| 3            | 2020-02-17   | 2        |
    -| 3            | 2020-02-24   | 3        |
    -| 4            | 2020-03-01   | 20       |
    -| 4            | 2020-03-04   | 30       |
    -| 4            | 2020-03-04   | 60       |
    -| 5            | 2020-02-25   | 50       |
    -| 5            | 2020-02-27   | 50       |
    -| 5            | 2020-03-01   | 50       |
    -+--------------+--------------+----------+
    -
    -Result table:
    -+--------------------+---------+
    -| product_name       | unit    |
    -+--------------------+---------+
    -| Leetcode Solutions | 130     |
    -| Leetcode Kit       | 100     |
    -+--------------------+---------+
    -
    -Products with product_id = 1 is ordered in February a total of (60 + 70) = 130.
    -Products with product_id = 2 is ordered in February a total of 80.
    -Products with product_id = 3 is ordered in February a total of (2 + 3) = 5.
    -Products with product_id = 4 was not ordered in February 2020.
    -Products with product_id = 5 is ordered in February a total of (50 + 50) = 100.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/logger-rate-limiter/README.md b/problems/logger-rate-limiter/README.md index 20267a79e..5ad10c83f 100644 --- a/problems/logger-rate-limiter/README.md +++ b/problems/logger-rate-limiter/README.md @@ -11,35 +11,7 @@ ## [359. Logger Rate Limiter (Easy)](https://leetcode.com/problems/logger-rate-limiter "日志速率限制器") -

    Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it is not printed in the last 10 seconds.

    -

    Given a message and a timestamp (in seconds granularity), return true if the message should be printed in the given timestamp, otherwise returns false.

    - -

    It is possible that several messages arrive roughly at the same time.

    - -

    Example:

    - -
    -Logger logger = new Logger();
    -
    -// logging string "foo" at timestamp 1
    -logger.shouldPrintMessage(1, "foo"); returns true; 
    -
    -// logging string "bar" at timestamp 2
    -logger.shouldPrintMessage(2,"bar"); returns true;
    -
    -// logging string "foo" at timestamp 3
    -logger.shouldPrintMessage(3,"foo"); returns false;
    -
    -// logging string "bar" at timestamp 8
    -logger.shouldPrintMessage(8,"bar"); returns false;
    -
    -// logging string "foo" at timestamp 10
    -logger.shouldPrintMessage(10,"foo"); returns false;
    -
    -// logging string "foo" at timestamp 11
    -logger.shouldPrintMessage(11,"foo"); returns true;
    -
    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/logical-or-of-two-binary-grids-represented-as-quad-trees/README.md b/problems/logical-or-of-two-binary-grids-represented-as-quad-trees/README.md index b1e9e6126..75241cb78 100644 --- a/problems/logical-or-of-two-binary-grids-represented-as-quad-trees/README.md +++ b/problems/logical-or-of-two-binary-grids-represented-as-quad-trees/README.md @@ -108,3 +108,7 @@ The resulting matrix is of size 1*1 with also zero.
  • quadTree1 and quadTree2 are both valid Quad-Trees each representing a n * n grid.
  • n == 2^x where 0 <= x <= 9.
  • + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] diff --git a/problems/lonely-pixel-i/README.md b/problems/lonely-pixel-i/README.md index 8e95a9dd8..ef8e91e88 100644 --- a/problems/lonely-pixel-i/README.md +++ b/problems/lonely-pixel-i/README.md @@ -11,33 +11,12 @@ ## [531. Lonely Pixel I (Medium)](https://leetcode.com/problems/lonely-pixel-i "孤独像素 I") -

    Given a picture consisting of black and white pixels, find the number of black lonely pixels.

    -

    The picture is represented by a 2D char array consisting of 'B' and 'W', which means black and white pixels respectively.

    - -

    A black lonely pixel is character 'B' that located at a specific position where the same row and same column don't have any other black pixels.

    - -

    Example:
    -

    -Input: 
    -[['W', 'W', 'B'],
    - ['W', 'B', 'W'],
    - ['B', 'W', 'W']]
    -
    -Output: 3
    -Explanation: All the three 'B's are black lonely pixels.
    -
    -

    - -

    Note:
    -

      -
    1. The range of width and height of the input 2D array is [1,500].
    2. -
    -

    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Lonely Pixel II](../lonely-pixel-ii) (Medium) diff --git a/problems/lonely-pixel-ii/README.md b/problems/lonely-pixel-ii/README.md index 26b769b2c..8859e8fdf 100644 --- a/problems/lonely-pixel-ii/README.md +++ b/problems/lonely-pixel-ii/README.md @@ -11,48 +11,12 @@ ## [533. Lonely Pixel II (Medium)](https://leetcode.com/problems/lonely-pixel-ii "孤独像素 II") -

    Given a picture consisting of black and white pixels, and a positive integer N, find the number of black pixels located at some specific row R and column C that align with all the following rules:

    -
      -
    1. Row R and column C both contain exactly N black pixels.
    2. -
    3. For all rows that have a black pixel at column C, they should be exactly the same as row R
    4. -
    - -

    The picture is represented by a 2D char array consisting of 'B' and 'W', which means black and white pixels respectively.

    - -

    Example:
    -

    -Input:                                            
    -[['W', 'B', 'W', 'B', 'B', 'W'],    
    - ['W', 'B', 'W', 'B', 'B', 'W'],    
    - ['W', 'B', 'W', 'B', 'B', 'W'],    
    - ['W', 'W', 'B', 'W', 'B', 'W']] 
    -
    -N = 3
    -Output: 6
    -Explanation: All the bold 'B' are the black pixels we need (all 'B's at column 1 and 3).
    -        0    1    2    3    4    5         column index                                            
    -0    [['W', 'B', 'W', 'B', 'B', 'W'],    
    -1     ['W', 'B', 'W', 'B', 'B', 'W'],    
    -2     ['W', 'B', 'W', 'B', 'B', 'W'],    
    -3     ['W', 'W', 'B', 'W', 'B', 'W']]    
    -row index
    -
    -Take 'B' at row R = 0 and column C = 1 as an example:
    -Rule 1, row R = 0 and column C = 1 both have exactly N = 3 black pixels. 
    -Rule 2, the rows have black pixel at column C = 1 are row 0, row 1 and row 2. They are exactly the same as row R = 0.
    -
    -
    -

    - -

    Note:
    -

      -
    1. The range of width and height of the input 2D array is [1,200].
    2. -
    -

    ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Lonely Pixel I](../lonely-pixel-i) (Medium) diff --git a/problems/longer-contiguous-segments-of-ones-than-zeros/README.md b/problems/longer-contiguous-segments-of-ones-than-zeros/README.md index 76519407c..e10a4a1e4 100644 --- a/problems/longer-contiguous-segments-of-ones-than-zeros/README.md +++ b/problems/longer-contiguous-segments-of-ones-than-zeros/README.md @@ -62,8 +62,7 @@ The segment of 1s is not longer, so return false. ### Related Topics - [[Array](../../tag/array/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/longest-absolute-file-path/README.md b/problems/longest-absolute-file-path/README.md index 2db2fda1a..2d20db2af 100644 --- a/problems/longest-absolute-file-path/README.md +++ b/problems/longest-absolute-file-path/README.md @@ -79,3 +79,8 @@ Since the absolute path for anything at the root directory is just the name itse
  • 1 <= input.length <= 104
  • input may contain lowercase or uppercase English letters, a new line character '\n', a tab character '\t', a dot '.', a space ' ', and digits.
  • + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/longest-arithmetic-subsequence-of-given-difference/README.md b/problems/longest-arithmetic-subsequence-of-given-difference/README.md index bfd9c439d..4158fbe84 100644 --- a/problems/longest-arithmetic-subsequence-of-given-difference/README.md +++ b/problems/longest-arithmetic-subsequence-of-given-difference/README.md @@ -48,8 +48,8 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/longest-arithmetic-subsequence/README.md b/problems/longest-arithmetic-subsequence/README.md index 0a52b3dbc..a11e3f40c 100644 --- a/problems/longest-arithmetic-subsequence/README.md +++ b/problems/longest-arithmetic-subsequence/README.md @@ -52,4 +52,7 @@ The longest arithmetic subsequence is [20,15,10,5]. ### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/longest-chunked-palindrome-decomposition/README.md b/problems/longest-chunked-palindrome-decomposition/README.md index af24912aa..9efadd596 100644 --- a/problems/longest-chunked-palindrome-decomposition/README.md +++ b/problems/longest-chunked-palindrome-decomposition/README.md @@ -63,7 +63,12 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/longest-common-subpath/README.md b/problems/longest-common-subpath/README.md new file mode 100644 index 000000000..d0905f5ff --- /dev/null +++ b/problems/longest-common-subpath/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../count-good-numbers "Count Good Numbers") +                 +[Next >](../erect-the-fence-ii "Erect the Fence II") + +## [1923. Longest Common Subpath (Hard)](https://leetcode.com/problems/longest-common-subpath "最长公共子路径") + +

    There is a country of n cities numbered from 0 to n - 1. In this country, there is a road connecting every pair of cities.

    + +

    There are m friends numbered from 0 to m - 1 who are traveling through the country. Each one of them will take a path consisting of some cities. Each path is represented by an integer array that contains the visited cities in order. The path may contain a city more than once, but the same city will not be listed consecutively.

    + +

    Given an integer n and a 2D integer array paths where paths[i] is an integer array representing the path of the ith friend, return the length of the longest common subpath that is shared by every friend's path, or 0 if there is no common subpath at all.

    + +

    A subpath of a path is a contiguous sequence of cities within that path.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 5, paths = [[0,1,2,3,4],
    +                       [2,3,4],
    +                       [4,0,1,2,3]]
    +Output: 2
    +Explanation: The longest common subpath is [2,3].
    +
    + +

    Example 2:

    + +
    +Input: n = 3, paths = [[0],[1],[2]]
    +Output: 0
    +Explanation: There is no common subpath shared by the three paths.
    +
    + +

    Example 3:

    + +
    +Input: n = 5, paths = [[0,1,2,3,4],
    +                       [4,3,2,1,0]]
    +Output: 1
    +Explanation: The possible longest common subpaths are [0], [1], [2], [3], and [4]. All have a length of 1.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 105
    • +
    • m == paths.length
    • +
    • 2 <= m <= 105
    • +
    • sum(paths[i].length) <= 105
    • +
    • 0 <= paths[i][j] < n
    • +
    • The same city is not listed multiple times consecutively in paths[i].
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Suffix Array](../../tag/suffix-array/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] + +### Hints +
    +Hint 1 +If there is a common path with length x, there is for sure a common path of length y where y < x. +
    + +
    +Hint 2 +We can use binary search over the answer with the range [0, min(path[i].length)]. +
    + +
    +Hint 3 +Using binary search, we want to verify if we have a common path of length m. We can achieve this using hashing. +
    diff --git a/problems/longest-common-subsequence/README.md b/problems/longest-common-subsequence/README.md index a62f8c0bc..25057631a 100644 --- a/problems/longest-common-subsequence/README.md +++ b/problems/longest-common-subsequence/README.md @@ -55,6 +55,7 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/longest-consecutive-sequence/README.md b/problems/longest-consecutive-sequence/README.md index b9b243dd9..a02d62dc8 100644 --- a/problems/longest-consecutive-sequence/README.md +++ b/problems/longest-consecutive-sequence/README.md @@ -42,6 +42,7 @@ ### Related Topics [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions 1. [Binary Tree Longest Consecutive Sequence](../binary-tree-longest-consecutive-sequence) (Medium) diff --git a/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md index cb8ef9108..66c810ef5 100644 --- a/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md +++ b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md @@ -58,8 +58,12 @@ Therefore, the size of the longest subarray is 2. ### Related Topics + [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/longest-duplicate-substring/README.md b/problems/longest-duplicate-substring/README.md index 5be37fe61..b40016fef 100644 --- a/problems/longest-duplicate-substring/README.md +++ b/problems/longest-duplicate-substring/README.md @@ -32,8 +32,12 @@ ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Suffix Array](../../tag/suffix-array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/longest-happy-prefix/README.md b/problems/longest-happy-prefix/README.md index 234415620..e9dc543d9 100644 --- a/problems/longest-happy-prefix/README.md +++ b/problems/longest-happy-prefix/README.md @@ -56,6 +56,9 @@ ### Related Topics [[String](../../tag/string/README.md)] + [[String Matching](../../tag/string-matching/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/longest-happy-string/README.md b/problems/longest-happy-string/README.md index 6d94a5f68..f678998ac 100644 --- a/problems/longest-happy-string/README.md +++ b/problems/longest-happy-string/README.md @@ -57,7 +57,8 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[String](../../tag/string/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/longest-harmonious-subsequence/README.md b/problems/longest-harmonious-subsequence/README.md index 6d54e8055..61d1605f2 100644 --- a/problems/longest-harmonious-subsequence/README.md +++ b/problems/longest-harmonious-subsequence/README.md @@ -49,4 +49,6 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/longest-increasing-path-in-a-matrix/README.md b/problems/longest-increasing-path-in-a-matrix/README.md index c00d9c570..e180b85d2 100644 --- a/problems/longest-increasing-path-in-a-matrix/README.md +++ b/problems/longest-increasing-path-in-a-matrix/README.md @@ -50,6 +50,9 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] [[Memoization](../../tag/memoization/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/longest-increasing-subsequence/README.md b/problems/longest-increasing-subsequence/README.md index f81399903..671123113 100644 --- a/problems/longest-increasing-subsequence/README.md +++ b/problems/longest-increasing-subsequence/README.md @@ -50,6 +50,7 @@

    Follow up: Can you come up with an algorithm that runs in O(n log(n)) time complexity?

    ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/longest-line-of-consecutive-one-in-matrix/README.md b/problems/longest-line-of-consecutive-one-in-matrix/README.md index b91260053..14d45d99d 100644 --- a/problems/longest-line-of-consecutive-one-in-matrix/README.md +++ b/problems/longest-line-of-consecutive-one-in-matrix/README.md @@ -11,26 +11,12 @@ ## [562. Longest Line of Consecutive One in Matrix (Medium)](https://leetcode.com/problems/longest-line-of-consecutive-one-in-matrix "矩阵中最长的连续1线段") -Given a 01 matrix M, find the longest line of consecutive one in the matrix. The line could be horizontal, vertical, diagonal or anti-diagonal. - -

    Example:
    -

    -Input:
    -[[0,1,1,0],
    - [0,1,1,0],
    - [0,0,0,1]]
    -Output: 3
    -
    -

    - -

    -Hint: -The number of elements in the given matrix will not exceed 10,000. -

    + ### Related Topics [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/longest-mountain-in-array/README.md b/problems/longest-mountain-in-array/README.md index a0b388aff..48a4c05de 100644 --- a/problems/longest-mountain-in-array/README.md +++ b/problems/longest-mountain-in-array/README.md @@ -59,4 +59,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] diff --git a/problems/longest-nice-substring/README.md b/problems/longest-nice-substring/README.md index deefb52e2..a51c01026 100644 --- a/problems/longest-nice-substring/README.md +++ b/problems/longest-nice-substring/README.md @@ -56,7 +56,10 @@ As there are multiple longest nice substrings, return "dD" since it oc ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/longest-palindrome/README.md b/problems/longest-palindrome/README.md index 7839ec9e3..3081419ec 100644 --- a/problems/longest-palindrome/README.md +++ b/problems/longest-palindrome/README.md @@ -48,7 +48,9 @@ One longest palindrome that can be built is "dccaccd", whose length is ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Palindrome Permutation](../palindrome-permutation) (Easy) diff --git a/problems/longest-palindromic-subsequence/README.md b/problems/longest-palindromic-subsequence/README.md index a75e0a99b..0a73ec183 100644 --- a/problems/longest-palindromic-subsequence/README.md +++ b/problems/longest-palindromic-subsequence/README.md @@ -41,6 +41,7 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/longest-repeating-character-replacement/README.md b/problems/longest-repeating-character-replacement/README.md index a66744435..0d29b5e1a 100644 --- a/problems/longest-repeating-character-replacement/README.md +++ b/problems/longest-repeating-character-replacement/README.md @@ -43,7 +43,8 @@ The substring "BBBB" has the longest repeating letters, which is 4. ### Related Topics - [[Two Pointers](../../tag/two-pointers/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions diff --git a/problems/longest-repeating-substring/README.md b/problems/longest-repeating-substring/README.md index 74d0ab9e0..807de6bda 100644 --- a/problems/longest-repeating-substring/README.md +++ b/problems/longest-repeating-substring/README.md @@ -11,53 +11,15 @@ ## [1062. Longest Repeating Substring (Medium)](https://leetcode.com/problems/longest-repeating-substring "最长重复子串") -

    Given a string S, find out the length of the longest repeating substring(s). Return 0 if no repeating substring exists.

    -

     

    - -

    Example 1:

    - -
    -Input: "abcd"
    -Output: 0
    -Explanation: There is no repeating substring.
    -
    - -

    Example 2:

    - -
    -Input: "abbaba"
    -Output: 2
    -Explanation: The longest repeating substrings are "ab" and "ba", each of which occurs twice.
    -
    - -

    Example 3:

    - -
    -Input: "aabcaabdaab"
    -Output: 3
    -Explanation: The longest repeating substring is "aab", which occurs 3 times.
    -
    - -

    Example 4:

    - -
    -Input: "aaaaa"
    -Output: 4
    -Explanation: The longest repeating substring is "aaaa", which occurs twice.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. The string S consists of only lowercase English letters from 'a' - 'z'.
    2. -
    3. 1 <= S.length <= 1500
    4. -
    ### Related Topics [[String](../../tag/string/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Suffix Array](../../tag/suffix-array/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/longest-string-chain/README.md b/problems/longest-string-chain/README.md index eca9bb45b..1aeb2e1e1 100644 --- a/problems/longest-string-chain/README.md +++ b/problems/longest-string-chain/README.md @@ -59,7 +59,10 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/longest-subarray-of-1s-after-deleting-one-element/README.md b/problems/longest-subarray-of-1s-after-deleting-one-element/README.md index ea9f442f5..63b411339 100644 --- a/problems/longest-subarray-of-1s-after-deleting-one-element/README.md +++ b/problems/longest-subarray-of-1s-after-deleting-one-element/README.md @@ -62,7 +62,9 @@ ### Related Topics - [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/longest-substring-of-all-vowels-in-order/README.md b/problems/longest-substring-of-all-vowels-in-order/README.md index f8afd8110..19e072052 100644 --- a/problems/longest-substring-of-all-vowels-in-order/README.md +++ b/problems/longest-substring-of-all-vowels-in-order/README.md @@ -57,8 +57,8 @@ ### Related Topics - [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/longest-substring-with-at-least-k-repeating-characters/README.md b/problems/longest-substring-with-at-least-k-repeating-characters/README.md index 00017f565..2429b4075 100644 --- a/problems/longest-substring-with-at-least-k-repeating-characters/README.md +++ b/problems/longest-substring-with-at-least-k-repeating-characters/README.md @@ -40,6 +40,7 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] diff --git a/problems/longest-substring-with-at-most-k-distinct-characters/README.md b/problems/longest-substring-with-at-most-k-distinct-characters/README.md index 8c2122c1d..e4d82ba65 100644 --- a/problems/longest-substring-with-at-most-k-distinct-characters/README.md +++ b/problems/longest-substring-with-at-most-k-distinct-characters/README.md @@ -11,28 +11,10 @@ ## [340. Longest Substring with At Most K Distinct Characters (Medium)](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters "至多包含 K 个不同字符的最长子串") -

    Given a string, find the length of the longest substring T that contains at most k distinct characters.

    -

    Example 1:

    - -
    -
    -Input: s = "eceba", k = 2
    -Output: 3
    -Explanation: T is "ece" which its length is 3.
    - -
    -

    Example 2:

    - -
    -Input: s = "aa", k = 1
    -Output: 2
    -Explanation: T is "aa" which its length is 2.
    -
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] diff --git a/problems/longest-substring-with-at-most-two-distinct-characters/README.md b/problems/longest-substring-with-at-most-two-distinct-characters/README.md index f7fc0adc4..cf45ffa44 100644 --- a/problems/longest-substring-with-at-most-two-distinct-characters/README.md +++ b/problems/longest-substring-with-at-most-two-distinct-characters/README.md @@ -11,25 +11,10 @@ ## [159. Longest Substring with At Most Two Distinct Characters (Medium)](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters "至多包含两个不同字符的最长子串") -

    Given a string s , find the length of the longest substring t  that contains at most 2 distinct characters.

    -

    Example 1:

    - -
    Input: "eceba"
    -Output: 3
    -Explanation: t is "ece" which its length is 3.
    -
    - -

    Example 2:

    - -
    Input: "ccaabbb"
    -Output: 5
    -Explanation: t is "aabbb" which its length is 5.
    -
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] diff --git a/problems/longest-substring-without-repeating-characters/README.md b/problems/longest-substring-without-repeating-characters/README.md index 1eeb9dc6c..a1ce2b5d4 100644 --- a/problems/longest-substring-without-repeating-characters/README.md +++ b/problems/longest-substring-without-repeating-characters/README.md @@ -56,7 +56,6 @@ Notice that the answer must be a substring, "pwke" is a subsequence an ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] diff --git a/problems/longest-uncommon-subsequence-i/README.md b/problems/longest-uncommon-subsequence-i/README.md index 7696934fa..604a89b0e 100644 --- a/problems/longest-uncommon-subsequence-i/README.md +++ b/problems/longest-uncommon-subsequence-i/README.md @@ -56,7 +56,6 @@ Note that "cdc" is also a longest uncommon subsequence. ### Related Topics - [[Brainteaser](../../tag/brainteaser/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/longest-uncommon-subsequence-ii/README.md b/problems/longest-uncommon-subsequence-ii/README.md index 2093570b3..41698819e 100644 --- a/problems/longest-uncommon-subsequence-ii/README.md +++ b/problems/longest-uncommon-subsequence-ii/README.md @@ -39,7 +39,11 @@ ### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Longest Uncommon Subsequence I](../longest-uncommon-subsequence-i) (Easy) diff --git a/problems/longest-univalue-path/README.md b/problems/longest-univalue-path/README.md index a00baf2f6..de2efc274 100644 --- a/problems/longest-univalue-path/README.md +++ b/problems/longest-univalue-path/README.md @@ -41,7 +41,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Recursion](../../tag/recursion/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Binary Tree Maximum Path Sum](../binary-tree-maximum-path-sum) (Hard) diff --git a/problems/longest-valid-parentheses/README.md b/problems/longest-valid-parentheses/README.md index 3fde54d09..b4b9e1f9f 100644 --- a/problems/longest-valid-parentheses/README.md +++ b/problems/longest-valid-parentheses/README.md @@ -46,6 +46,7 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/longest-well-performing-interval/README.md b/problems/longest-well-performing-interval/README.md index f146b8769..b4040fc96 100644 --- a/problems/longest-well-performing-interval/README.md +++ b/problems/longest-well-performing-interval/README.md @@ -38,6 +38,10 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints
    diff --git a/problems/longest-word-in-dictionary-through-deleting/README.md b/problems/longest-word-in-dictionary-through-deleting/README.md index d3283512a..2a5c3657c 100644 --- a/problems/longest-word-in-dictionary-through-deleting/README.md +++ b/problems/longest-word-in-dictionary-through-deleting/README.md @@ -39,8 +39,10 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Longest Word in Dictionary](../longest-word-in-dictionary) (Easy) diff --git a/problems/longest-word-in-dictionary/README.md b/problems/longest-word-in-dictionary/README.md index 803f128bd..b7d6e76d6 100644 --- a/problems/longest-word-in-dictionary/README.md +++ b/problems/longest-word-in-dictionary/README.md @@ -43,7 +43,10 @@ ### Related Topics [[Trie](../../tag/trie/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Longest Word in Dictionary through Deleting](../longest-word-in-dictionary-through-deleting) (Medium) diff --git a/problems/longest-word-with-all-prefixes/README.md b/problems/longest-word-with-all-prefixes/README.md index 01bf52f39..7dfc2a6ba 100644 --- a/problems/longest-word-with-all-prefixes/README.md +++ b/problems/longest-word-with-all-prefixes/README.md @@ -9,14 +9,13 @@                  [Next >](../sorting-the-sentence "Sorting the Sentence") -## [1858. Longest Word With All Prefixes (Medium)](https://leetcode.com/problems/longest-word-with-all-prefixes "") +## [1858. Longest Word With All Prefixes (Medium)](https://leetcode.com/problems/longest-word-with-all-prefixes "包含所有前缀的最长单词") ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Trie](../../tag/trie/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/longest-zigzag-path-in-a-binary-tree/README.md b/problems/longest-zigzag-path-in-a-binary-tree/README.md index 5d6327216..be005d7d9 100644 --- a/problems/longest-zigzag-path-in-a-binary-tree/README.md +++ b/problems/longest-zigzag-path-in-a-binary-tree/README.md @@ -60,7 +60,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/loud-and-rich/README.md b/problems/loud-and-rich/README.md index f10fc3568..47338f113 100644 --- a/problems/loud-and-rich/README.md +++ b/problems/loud-and-rich/README.md @@ -57,4 +57,7 @@ The other answers can be filled out with similar reasoning. ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md b/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md index b272602b6..ec0abe1e0 100644 --- a/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-search-tree/README.md @@ -52,6 +52,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Lowest Common Ancestor of a Binary Tree](../lowest-common-ancestor-of-a-binary-tree) (Medium) diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md index 21d5ff7b0..d4d4f6ea0 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md @@ -15,6 +15,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md index fbe2cad0c..f0cf11398 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md @@ -15,6 +15,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md index 4700d6b76..bd96ddd5d 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md @@ -15,7 +15,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/lowest-common-ancestor-of-a-binary-tree/README.md b/problems/lowest-common-ancestor-of-a-binary-tree/README.md index 477a0c0f9..6baf04ac6 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree/README.md @@ -52,6 +52,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Lowest Common Ancestor of a Binary Search Tree](../lowest-common-ancestor-of-a-binary-search-tree) (Easy) diff --git a/problems/lowest-common-ancestor-of-deepest-leaves/README.md b/problems/lowest-common-ancestor-of-deepest-leaves/README.md index aa5600a03..4abc2574d 100644 --- a/problems/lowest-common-ancestor-of-deepest-leaves/README.md +++ b/problems/lowest-common-ancestor-of-deepest-leaves/README.md @@ -60,7 +60,10 @@ Note that nodes 6, 0, and 8 are also leaf nodes, but the depth of them is 2, but ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/lru-cache/README.md b/problems/lru-cache/README.md index 89199a8cb..3a5672fc3 100644 --- a/problems/lru-cache/README.md +++ b/problems/lru-cache/README.md @@ -21,8 +21,7 @@
  • void put(int key, int value) Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used key.
  • -

    Follow up:
    -Could you do get and put in O(1) time complexity?

    +

    The functions get and put must each run in O(1) average time complexity.

     

    Example 1:

    @@ -52,13 +51,16 @@ lRUCache.get(4); // return 4
    • 1 <= capacity <= 3000
    • -
    • 0 <= key <= 3000
    • -
    • 0 <= value <= 104
    • -
    • At most 3 * 104 calls will be made to get and put.
    • +
    • 0 <= key <= 104
    • +
    • 0 <= value <= 105
    • +
    • At most 2 * 105 calls will be made to get and put.
    ### Related Topics [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Doubly-Linked List](../../tag/doubly-linked-list/README.md)] ### Similar Questions 1. [LFU Cache](../lfu-cache) (Hard) diff --git a/problems/lucky-numbers-in-a-matrix/README.md b/problems/lucky-numbers-in-a-matrix/README.md index f5d7023e8..bd873c29d 100644 --- a/problems/lucky-numbers-in-a-matrix/README.md +++ b/problems/lucky-numbers-in-a-matrix/README.md @@ -52,6 +52,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/magic-squares-in-grid/README.md b/problems/magic-squares-in-grid/README.md index c1a79a576..64e497d1a 100644 --- a/problems/magic-squares-in-grid/README.md +++ b/problems/magic-squares-in-grid/README.md @@ -62,3 +62,5 @@ In total, there is only one magic square inside the given grid. ### Related Topics [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/magical-string/README.md b/problems/magical-string/README.md index a080e985f..18b7d6dd6 100644 --- a/problems/magical-string/README.md +++ b/problems/magical-string/README.md @@ -43,3 +43,7 @@
    • 1 <= n <= 105
    + +### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/magnetic-force-between-two-balls/README.md b/problems/magnetic-force-between-two-balls/README.md index 661e4bb9d..7d0cb6355 100644 --- a/problems/magnetic-force-between-two-balls/README.md +++ b/problems/magnetic-force-between-two-balls/README.md @@ -48,6 +48,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/majority-element-ii/README.md b/problems/majority-element-ii/README.md index b58da0ccb..8fe8073d6 100644 --- a/problems/majority-element-ii/README.md +++ b/problems/majority-element-ii/README.md @@ -47,6 +47,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Majority Element](../majority-element) (Easy) diff --git a/problems/majority-element/README.md b/problems/majority-element/README.md index 12478b008..ae8eb9d3d 100644 --- a/problems/majority-element/README.md +++ b/problems/majority-element/README.md @@ -36,9 +36,11 @@ Follow-up: Could you solve the problem in linear time and in O(1) space? ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Majority Element II](../majority-element-ii) (Medium) diff --git a/problems/make-array-strictly-increasing/README.md b/problems/make-array-strictly-increasing/README.md index b8462c7ad..42344907a 100644 --- a/problems/make-array-strictly-increasing/README.md +++ b/problems/make-array-strictly-increasing/README.md @@ -52,6 +52,8 @@

     

    ### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/make-sum-divisible-by-p/README.md b/problems/make-sum-divisible-by-p/README.md index 69cfad339..d20c220ff 100644 --- a/problems/make-sum-divisible-by-p/README.md +++ b/problems/make-sum-divisible-by-p/README.md @@ -69,8 +69,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Math](../../tag/math/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/make-the-xor-of-all-segments-equal-to-zero/README.md b/problems/make-the-xor-of-all-segments-equal-to-zero/README.md index 7dbe899d4..5a2d02c40 100644 --- a/problems/make-the-xor-of-all-segments-equal-to-zero/README.md +++ b/problems/make-the-xor-of-all-segments-equal-to-zero/README.md @@ -48,6 +48,8 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md b/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md index 2ec259377..7ccaa9fe5 100644 --- a/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md +++ b/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md @@ -72,6 +72,8 @@ There are multiple ways to convert arr to target, this is not the only way to do ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/making-a-large-island/README.md b/problems/making-a-large-island/README.md index f92380080..ecb878491 100644 --- a/problems/making-a-large-island/README.md +++ b/problems/making-a-large-island/README.md @@ -52,5 +52,8 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/making-file-names-unique/README.md b/problems/making-file-names-unique/README.md index 2e0f911f5..52a57457b 100644 --- a/problems/making-file-names-unique/README.md +++ b/problems/making-file-names-unique/README.md @@ -76,6 +76,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/managers-with-at-least-5-direct-reports/README.md b/problems/managers-with-at-least-5-direct-reports/README.md index f386177bb..5b6eaf68b 100644 --- a/problems/managers-with-at-least-5-direct-reports/README.md +++ b/problems/managers-with-at-least-5-direct-reports/README.md @@ -11,33 +11,10 @@ ## [570. Managers with at Least 5 Direct Reports (Medium)](https://leetcode.com/problems/managers-with-at-least-5-direct-reports "至少有5名直接下属的经理") -

    The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.

    - -
    -+------+----------+-----------+----------+
    -|Id    |Name 	  |Department |ManagerId |
    -+------+----------+-----------+----------+
    -|101   |John 	  |A 	      |null      |
    -|102   |Dan 	  |A 	      |101       |
    -|103   |James 	  |A 	      |101       |
    -|104   |Amy 	  |A 	      |101       |
    -|105   |Anne 	  |A 	      |101       |
    -|106   |Ron 	  |B 	      |101       |
    -+------+----------+-----------+----------+
    -
    - -

    Given the Employee table, write a SQL query that finds out managers with at least 5 direct report. For the above table, your SQL query should return:

    - -
    -+-------+
    -| Name  |
    -+-------+
    -| John  |
    -+-------+
    -
    - -

    Note:
    -No one would report to himself.

    + + +### Related Topics + [[Database](../../tag/database/README.md)] ### Hints
    diff --git a/problems/map-of-highest-peak/README.md b/problems/map-of-highest-peak/README.md index 2b8cfaa18..52e0c84f2 100644 --- a/problems/map-of-highest-peak/README.md +++ b/problems/map-of-highest-peak/README.md @@ -65,8 +65,9 @@ Any height assignment that has a maximum height of 2 while still meeting the rul ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] - [[Graph](../../tag/graph/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/map-sum-pairs/README.md b/problems/map-sum-pairs/README.md index 50e3ff828..e9ee0fc46 100644 --- a/problems/map-sum-pairs/README.md +++ b/problems/map-sum-pairs/README.md @@ -48,4 +48,7 @@ mapSum.sum("ap"); // return 5 (apple + app = 3 ### Related Topics + [[Design](../../tag/design/README.md)] [[Trie](../../tag/trie/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/market-analysis-i/README.md b/problems/market-analysis-i/README.md index 16d679b4c..aaeda6ebf 100644 --- a/problems/market-analysis-i/README.md +++ b/problems/market-analysis-i/README.md @@ -11,94 +11,7 @@ ## [1158. Market Analysis I (Medium)](https://leetcode.com/problems/market-analysis-i "市场分析 I") -

    Table: Users

    -
    -+----------------+---------+
    -| Column Name    | Type    |
    -+----------------+---------+
    -| user_id        | int     |
    -| join_date      | date    |
    -| favorite_brand | varchar |
    -+----------------+---------+
    -user_id is the primary key of this table.
    -This table has the info of the users of an online shopping website where users can sell and buy items.
    -

    Table: Orders

    - -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| order_id      | int     |
    -| order_date    | date    |
    -| item_id       | int     |
    -| buyer_id      | int     |
    -| seller_id     | int     |
    -+---------------+---------+
    -order_id is the primary key of this table.
    -item_id is a foreign key to the Items table.
    -buyer_id and seller_id are foreign keys to the Users table.
    -
    - -

    Table: Items

    - -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| item_id       | int     |
    -| item_brand    | varchar |
    -+---------------+---------+
    -item_id is the primary key of this table.
    -
    - -

     

    - -

    Write an SQL query to find for each user, the join date and the number of orders they made as a buyer in 2019.

    - -

    The query result format is in the following example:

    - -
    -Users table:
    -+---------+------------+----------------+
    -| user_id | join_date  | favorite_brand |
    -+---------+------------+----------------+
    -| 1       | 2018-01-01 | Lenovo         |
    -| 2       | 2018-02-09 | Samsung        |
    -| 3       | 2018-01-19 | LG             |
    -| 4       | 2018-05-21 | HP             |
    -+---------+------------+----------------+
    -
    -Orders table:
    -+----------+------------+---------+----------+-----------+
    -| order_id | order_date | item_id | buyer_id | seller_id |
    -+----------+------------+---------+----------+-----------+
    -| 1        | 2019-08-01 | 4       | 1        | 2         |
    -| 2        | 2018-08-02 | 2       | 1        | 3         |
    -| 3        | 2019-08-03 | 3       | 2        | 3         |
    -| 4        | 2018-08-04 | 1       | 4        | 2         |
    -| 5        | 2018-08-04 | 1       | 3        | 4         |
    -| 6        | 2019-08-05 | 2       | 2        | 4         |
    -+----------+------------+---------+----------+-----------+
    -
    -Items table:
    -+---------+------------+
    -| item_id | item_brand |
    -+---------+------------+
    -| 1       | Samsung    |
    -| 2       | Lenovo     |
    -| 3       | LG         |
    -| 4       | HP         |
    -+---------+------------+
    -
    -Result table:
    -+-----------+------------+----------------+
    -| buyer_id  | join_date  | orders_in_2019 |
    -+-----------+------------+----------------+
    -| 1         | 2018-01-01 | 1              |
    -| 2         | 2018-02-09 | 2              |
    -| 3         | 2018-01-19 | 0              |
    -| 4         | 2018-05-21 | 0              |
    -+-----------+------------+----------------+
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/market-analysis-ii/README.md b/problems/market-analysis-ii/README.md index 84e817704..eb6171338 100644 --- a/problems/market-analysis-ii/README.md +++ b/problems/market-analysis-ii/README.md @@ -11,99 +11,7 @@ ## [1159. Market Analysis II (Hard)](https://leetcode.com/problems/market-analysis-ii "市场分析 II") -

    Table: Users

    -
    -+----------------+---------+
    -| Column Name    | Type    |
    -+----------------+---------+
    -| user_id        | int     |
    -| join_date      | date    |
    -| favorite_brand | varchar |
    -+----------------+---------+
    -user_id is the primary key of this table.
    -This table has the info of the users of an online shopping website where users can sell and buy items.
    -

    Table: Orders

    - -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| order_id      | int     |
    -| order_date    | date    |
    -| item_id       | int     |
    -| buyer_id      | int     |
    -| seller_id     | int     |
    -+---------------+---------+
    -order_id is the primary key of this table.
    -item_id is a foreign key to the Items table.
    -buyer_id and seller_id are foreign keys to the Users table.
    -
    - -

    Table: Items

    - -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| item_id       | int     |
    -| item_brand    | varchar |
    -+---------------+---------+
    -item_id is the primary key of this table.
    -
    - -

     

    - -

    Write an SQL query to find for each user, whether the brand of the second item (by date) they sold is their favorite brand. If a user sold less than two items, report the answer for that user as no.

    - -

    It is guaranteed that no seller sold more than one item on a day.

    - -

    The query result format is in the following example:

    - -
    -Users table:
    -+---------+------------+----------------+
    -| user_id | join_date  | favorite_brand |
    -+---------+------------+----------------+
    -| 1       | 2019-01-01 | Lenovo         |
    -| 2       | 2019-02-09 | Samsung        |
    -| 3       | 2019-01-19 | LG             |
    -| 4       | 2019-05-21 | HP             |
    -+---------+------------+----------------+
    -
    -Orders table:
    -+----------+------------+---------+----------+-----------+
    -| order_id | order_date | item_id | buyer_id | seller_id |
    -+----------+------------+---------+----------+-----------+
    -| 1        | 2019-08-01 | 4       | 1        | 2         |
    -| 2        | 2019-08-02 | 2       | 1        | 3         |
    -| 3        | 2019-08-03 | 3       | 2        | 3         |
    -| 4        | 2019-08-04 | 1       | 4        | 2         |
    -| 5        | 2019-08-04 | 1       | 3        | 4         |
    -| 6        | 2019-08-05 | 2       | 2        | 4         |
    -+----------+------------+---------+----------+-----------+
    -
    -Items table:
    -+---------+------------+
    -| item_id | item_brand |
    -+---------+------------+
    -| 1       | Samsung    |
    -| 2       | Lenovo     |
    -| 3       | LG         |
    -| 4       | HP         |
    -+---------+------------+
    -
    -Result table:
    -+-----------+--------------------+
    -| seller_id | 2nd_item_fav_brand |
    -+-----------+--------------------+
    -| 1         | no                 |
    -| 2         | yes                |
    -| 3         | yes                |
    -| 4         | no                 |
    -+-----------+--------------------+
    -
    -The answer for the user with id 1 is no because they sold nothing.
    -The answer for the users with id 2 and 3 is yes because the brands of their second sold items are their favorite brands.
    -The answer for the user with id 4 is no because the brand of their second sold item is not their favorite brand.
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/matchsticks-to-square/README.md b/problems/matchsticks-to-square/README.md index 675b80208..2b7ec49a7 100644 --- a/problems/matchsticks-to-square/README.md +++ b/problems/matchsticks-to-square/README.md @@ -37,11 +37,15 @@
    • 1 <= matchsticks.length <= 15
    • -
    • 0 <= matchsticks[i] <= 109
    • +
    • 1 <= matchsticks[i] <= 108
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/matrix-block-sum/README.md b/problems/matrix-block-sum/README.md index 2b6c54b20..91ae8977a 100644 --- a/problems/matrix-block-sum/README.md +++ b/problems/matrix-block-sum/README.md @@ -45,7 +45,9 @@ ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/matrix-cells-in-distance-order/README.md b/problems/matrix-cells-in-distance-order/README.md index eb0171092..aa62bc666 100644 --- a/problems/matrix-cells-in-distance-order/README.md +++ b/problems/matrix-cells-in-distance-order/README.md @@ -63,4 +63,8 @@ There are other answers that would also be accepted as correct, such as [[1,2],[
    ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/matrix-diagonal-sum/README.md b/problems/matrix-diagonal-sum/README.md index 11e07ad2d..36266ded8 100644 --- a/problems/matrix-diagonal-sum/README.md +++ b/problems/matrix-diagonal-sum/README.md @@ -55,6 +55,7 @@ Notice that element mat[1][1] = 5 is counted only once. ### Related Topics [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/max-area-of-island/README.md b/problems/max-area-of-island/README.md index cabb43f50..fdc129b02 100644 --- a/problems/max-area-of-island/README.md +++ b/problems/max-area-of-island/README.md @@ -44,8 +44,11 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Number of Islands](../number-of-islands) (Medium) diff --git a/problems/max-chunks-to-make-sorted-ii/README.md b/problems/max-chunks-to-make-sorted-ii/README.md index 001a70daa..577755e36 100644 --- a/problems/max-chunks-to-make-sorted-ii/README.md +++ b/problems/max-chunks-to-make-sorted-ii/README.md @@ -11,14 +11,13 @@ ## [768. Max Chunks To Make Sorted II (Hard)](https://leetcode.com/problems/max-chunks-to-make-sorted-ii "最多能完成排序的块 II") -

    This question is the same as "Max Chunks to Make Sorted" except the integers of the given array are not necessarily distinct, the input array could be up to length 2000, and the elements could be up to 10**8.

    +

    You are given an integer array arr.

    -
    +

    We split arr into some number of chunks (i.e., partitions), and individually sort each chunk. After concatenating them, the result should equal the sorted array.

    -

    Given an array arr of integers (not necessarily distinct), we split the array into some number of "chunks" (partitions), and individually sort each chunk.  After concatenating them, the result equals the sorted array.

    - -

    What is the most number of chunks we could have made?

    +

    Return the largest number of chunks we can make to sort the array.

    +

     

    Example 1:

    @@ -39,17 +38,20 @@ We can split into two chunks, such as [2, 1], [3, 4, 4].
     However, splitting into [2, 1], [3], [4], [4] is the highest number of chunks possible.
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • arr will have length in range [1, 2000].
    • -
    • arr[i] will be an integer in range [0, 10**8].
    • +
    • 1 <= arr.length <= 2000
    • +
    • 0 <= arr[i] <= 108
    -

     

    - ### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Similar Questions 1. [Max Chunks To Make Sorted](../max-chunks-to-make-sorted) (Medium) diff --git a/problems/max-chunks-to-make-sorted/README.md b/problems/max-chunks-to-make-sorted/README.md index 646b94548..f83c459f5 100644 --- a/problems/max-chunks-to-make-sorted/README.md +++ b/problems/max-chunks-to-make-sorted/README.md @@ -11,10 +11,13 @@ ## [769. Max Chunks To Make Sorted (Medium)](https://leetcode.com/problems/max-chunks-to-make-sorted "最多能完成排序的块") -

    Given an array arr that is a permutation of [0, 1, ..., arr.length - 1], we split the array into some number of "chunks" (partitions), and individually sort each chunk.  After concatenating them, the result equals the sorted array.

    +

    You are given an integer array arr of length n that represents a permutation of the integers in the range [0, n - 1].

    -

    What is the most number of chunks we could have made?

    +

    We split arr into some number of chunks (i.e., partitions), and individually sort each chunk. After concatenating them, the result should equal the sorted array.

    +

    Return the largest number of chunks we can make to sort the array.

    + +

     

    Example 1:

    @@ -35,17 +38,22 @@ We can split into two chunks, such as [1, 0], [2, 3, 4].
     However, splitting into [1, 0], [2], [3], [4] is the highest number of chunks possible.
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • arr will have length in range [1, 10].
    • -
    • arr[i] will be a permutation of [0, 1, ..., arr.length - 1].
    • +
    • n == arr.length
    • +
    • 1 <= n <= 10
    • +
    • 0 <= arr[i] < n
    • +
    • All the elements of arr are unique.
    -

     

    - ### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Similar Questions 1. [Max Chunks To Make Sorted II](../max-chunks-to-make-sorted-ii) (Hard) diff --git a/problems/max-consecutive-ones-ii/README.md b/problems/max-consecutive-ones-ii/README.md index 33099eacf..edfc9e4a2 100644 --- a/problems/max-consecutive-ones-ii/README.md +++ b/problems/max-consecutive-ones-ii/README.md @@ -11,32 +11,12 @@ ## [487. Max Consecutive Ones II (Medium)](https://leetcode.com/problems/max-consecutive-ones-ii "最大连续1的个数 II") -

    -Given a binary array, find the maximum number of consecutive 1s in this array if you can flip at most one 0. -

    -

    Example 1:
    -

    -Input: [1,0,1,1,0]
    -Output: 4
    -Explanation: Flip the first zero will get the the maximum number of consecutive 1s.
    -    After flipping, the maximum number of consecutive 1s is 4.
    -
    -

    - -

    Note: -

      -
    • The input array will only contain 0 and 1.
    • -
    • The length of input array is a positive integer and will not exceed 10,000
    • -
    -

    - -

    Follow up:
    -What if the input numbers come in one by one as an infinite stream? In other words, you can't store all numbers coming from the stream as it's too large to hold in memory. Could you solve it efficiently? -

    ### Related Topics - [[Two Pointers](../../tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions 1. [Max Consecutive Ones](../max-consecutive-ones) (Easy) diff --git a/problems/max-consecutive-ones-iii/README.md b/problems/max-consecutive-ones-iii/README.md index b4ce4c7a4..3192f47e3 100644 --- a/problems/max-consecutive-ones-iii/README.md +++ b/problems/max-consecutive-ones-iii/README.md @@ -41,7 +41,9 @@ Bolded numbers were flipped from 0 to 1. The longest subarray is underlined. ### Related Topics - [[Two Pointers](../../tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions diff --git a/problems/max-difference-you-can-get-from-changing-an-integer/README.md b/problems/max-difference-you-can-get-from-changing-an-integer/README.md index 3c1901b55..1643c22e9 100644 --- a/problems/max-difference-you-can-get-from-changing-an-integer/README.md +++ b/problems/max-difference-you-can-get-from-changing-an-integer/README.md @@ -74,7 +74,8 @@ We have now a = 9 and b = 1 and max difference = 8 ### Related Topics - [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/max-dot-product-of-two-subsequences/README.md b/problems/max-dot-product-of-two-subsequences/README.md index a756469e9..7e4087e25 100644 --- a/problems/max-dot-product-of-two-subsequences/README.md +++ b/problems/max-dot-product-of-two-subsequences/README.md @@ -51,6 +51,7 @@ Their dot product is -1. ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/max-increase-to-keep-city-skyline/README.md b/problems/max-increase-to-keep-city-skyline/README.md index 74a6a85e5..272f8486a 100644 --- a/problems/max-increase-to-keep-city-skyline/README.md +++ b/problems/max-increase-to-keep-city-skyline/README.md @@ -11,39 +11,48 @@ ## [807. Max Increase to Keep City Skyline (Medium)](https://leetcode.com/problems/max-increase-to-keep-city-skyline "保持城市天际线") -

    In a 2 dimensional array grid, each value grid[i][j] represents the height of a building located there. We are allowed to increase the height of any number of buildings, by any amount (the amounts can be different for different buildings). Height 0 is considered to be a building as well. 

    +

    There is a city composed of n x n blocks, where each block contains a single building shaped like a vertical square prism. You are given a 0-indexed n x n integer matrix grid where grid[r][c] represents the height of the building located in the block at row r and column c.

    -

    At the end, the "skyline" when viewed from all four directions of the grid, i.e. top, bottom, left, and right, must be the same as the skyline of the original grid. A city's skyline is the outer contour of the rectangles formed by all the buildings when viewed from a distance. See the following example.

    +

    A city's skyline is the the outer contour formed by all the building when viewing the side of the city from a distance. The skyline from each cardinal direction north, east, south, and west may be different.

    -

    What is the maximum total sum that the height of the buildings can be increased?

    +

    We are allowed to increase the height of any number of buildings by any amount (the amount can be different per building). The height of a 0-height building can also be increased. However, increasing the height of a building should not affect the city's skyline from any cardinal direction.

    +

    Return the maximum total sum that the height of the buildings can be increased by without changing the city's skyline from any cardinal direction.

    + +

     

    +

    Example 1:

    +
    -Example:
     Input: grid = [[3,0,8,4],[2,4,5,7],[9,2,6,3],[0,3,1,0]]
     Output: 35
    -Explanation: 
    -The grid is:
    -[ [3, 0, 8, 4], 
    -  [2, 4, 5, 7],
    -  [9, 2, 6, 3],
    -  [0, 3, 1, 0] ]
    -
    -The skyline viewed from top or bottom is: [9, 4, 8, 7]
    -The skyline viewed from left or right is: [8, 7, 9, 3]
    -
    +Explanation: The building heights are shown in the center of the above image.
    +The skylines when viewed from each cardinal direction are drawn in red.
     The grid after increasing the height of buildings without affecting skylines is:
    -
     gridNew = [ [8, 4, 8, 7],
                 [7, 4, 7, 7],
                 [9, 4, 8, 7],
                 [3, 3, 3, 3] ]
    +
    + +

    Example 2:

    +
    +Input: grid = [[0,0,0],[0,0,0],[0,0,0]]
    +Output: 0
    +Explanation: Increasing the height of any building will result in the skyline changing.
     
    -

    Notes:

    +

     

    +

    Constraints:

      -
    • 1 < grid.length = grid[0].length <= 50.
    • -
    • All heights grid[i][j] are in the range [0, 100].
    • -
    • All buildings in grid[i][j] occupy the entire grid cell: that is, they are a 1 x 1 x grid[i][j] rectangular prism.
    • +
    • n == grid.length
    • +
    • n == grid[r].length
    • +
    • 2 <= n <= 50
    • +
    • 0 <= grid[r][c] <= 100
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/max-number-of-k-sum-pairs/README.md b/problems/max-number-of-k-sum-pairs/README.md index e798423d7..f52bd07bd 100644 --- a/problems/max-number-of-k-sum-pairs/README.md +++ b/problems/max-number-of-k-sum-pairs/README.md @@ -47,7 +47,10 @@ There are no more pairs that sum up to 6, hence a total of 1 operation. ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/max-points-on-a-line/README.md b/problems/max-points-on-a-line/README.md index a9537e7fb..2dab44ae2 100644 --- a/problems/max-points-on-a-line/README.md +++ b/problems/max-points-on-a-line/README.md @@ -39,6 +39,7 @@ ### Related Topics + [[Geometry](../../tag/geometry/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/max-stack/README.md b/problems/max-stack/README.md index 1f23c43b2..41c4fb872 100644 --- a/problems/max-stack/README.md +++ b/problems/max-stack/README.md @@ -11,43 +11,14 @@ ## [716. Max Stack (Easy)](https://leetcode.com/problems/max-stack "最大栈") -

    Design a max stack that supports push, pop, top, peekMax and popMax.

    -

    -

      -
    1. push(x) -- Push element x onto stack.
    2. -
    3. pop() -- Remove the element on top of the stack and return it.
    4. -
    5. top() -- Get the element on the top.
    6. -
    7. peekMax() -- Retrieve the maximum element in the stack.
    8. -
    9. popMax() -- Retrieve the maximum element in the stack, and remove it. If you find more than one maximum elements, only remove the top-most one.
    10. -
    -

    - -

    Example 1:
    -

    -MaxStack stack = new MaxStack();
    -stack.push(5); 
    -stack.push(1);
    -stack.push(5);
    -stack.top(); -> 5
    -stack.popMax(); -> 5
    -stack.top(); -> 1
    -stack.peekMax(); -> 5
    -stack.pop(); -> 1
    -stack.top(); -> 5
    -
    -

    - -

    Note:
    -

      -
    1. -1e7 <= x <= 1e7
    2. -
    3. Number of operations won't exceed 10000.
    4. -
    5. The last four operations won't be called when stack is empty.
    6. -
    -

    ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Design](../../tag/design/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Doubly-Linked List](../../tag/doubly-linked-list/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions 1. [Min Stack](../min-stack) (Easy) diff --git a/problems/max-sum-of-rectangle-no-larger-than-k/README.md b/problems/max-sum-of-rectangle-no-larger-than-k/README.md index 9a36b842f..6ecd97fc0 100644 --- a/problems/max-sum-of-rectangle-no-larger-than-k/README.md +++ b/problems/max-sum-of-rectangle-no-larger-than-k/README.md @@ -46,6 +46,8 @@

    Follow up: What if the number of rows is much larger than the number of columns?

    ### Related Topics - [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] diff --git a/problems/max-value-of-equation/README.md b/problems/max-value-of-equation/README.md index e60b3d438..3feae3e3e 100644 --- a/problems/max-value-of-equation/README.md +++ b/problems/max-value-of-equation/README.md @@ -48,8 +48,11 @@ No other pairs satisfy the condition, so we return the max of 4 and 1. ### Related Topics + [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/maximal-rectangle/README.md b/problems/maximal-rectangle/README.md index 3d2c84181..4f3f25908 100644 --- a/problems/maximal-rectangle/README.md +++ b/problems/maximal-rectangle/README.md @@ -63,8 +63,9 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Similar Questions 1. [Largest Rectangle in Histogram](../largest-rectangle-in-histogram) (Hard) diff --git a/problems/maximal-square/README.md b/problems/maximal-square/README.md index de050fead..354993505 100644 --- a/problems/maximal-square/README.md +++ b/problems/maximal-square/README.md @@ -46,7 +46,9 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Maximal Rectangle](../maximal-rectangle) (Hard) diff --git a/problems/maximize-grid-happiness/README.md b/problems/maximize-grid-happiness/README.md index fe10923f6..b06fc1fe4 100644 --- a/problems/maximize-grid-happiness/README.md +++ b/problems/maximize-grid-happiness/README.md @@ -69,8 +69,10 @@ The grid happiness is 90 + 80 + 90 = 260. ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Memoization](../../tag/memoization/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Backtracking](../../tag/backtracking/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/maximize-number-of-nice-divisors/README.md b/problems/maximize-number-of-nice-divisors/README.md index 275637e53..cd91cb86b 100644 --- a/problems/maximize-number-of-nice-divisors/README.md +++ b/problems/maximize-number-of-nice-divisors/README.md @@ -48,6 +48,7 @@ There is not other value of n that has at most 5 prime factors and more nice div ### Related Topics + [[Recursion](../../tag/recursion/README.md)] [[Math](../../tag/math/README.md)] ### Hints diff --git a/problems/maximize-palindrome-length-from-subsequences/README.md b/problems/maximize-palindrome-length-from-subsequences/README.md index 3652abf10..2eefe38e1 100644 --- a/problems/maximize-palindrome-length-from-subsequences/README.md +++ b/problems/maximize-palindrome-length-from-subsequences/README.md @@ -56,6 +56,7 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/maximize-score-after-n-operations/README.md b/problems/maximize-score-after-n-operations/README.md index 92149c733..15161e2ff 100644 --- a/problems/maximize-score-after-n-operations/README.md +++ b/problems/maximize-score-after-n-operations/README.md @@ -63,9 +63,13 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] + [[Number Theory](../../tag/number-theory/README.md)] ### Hints
    diff --git a/problems/maximize-sum-of-array-after-k-negations/README.md b/problems/maximize-sum-of-array-after-k-negations/README.md index 7c562f826..b82451d17 100644 --- a/problems/maximize-sum-of-array-after-k-negations/README.md +++ b/problems/maximize-sum-of-array-after-k-negations/README.md @@ -57,3 +57,5 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/maximize-the-beauty-of-the-garden/README.md b/problems/maximize-the-beauty-of-the-garden/README.md index 9c9894cfe..5e094774d 100644 --- a/problems/maximize-the-beauty-of-the-garden/README.md +++ b/problems/maximize-the-beauty-of-the-garden/README.md @@ -9,12 +9,14 @@                  [Next >](../primary-department-for-each-employee "Primary Department for Each Employee") -## [1788. Maximize the Beauty of the Garden (Hard)](https://leetcode.com/problems/maximize-the-beauty-of-the-garden "") +## [1788. Maximize the Beauty of the Garden (Hard)](https://leetcode.com/problems/maximize-the-beauty-of-the-garden "最大化花园的美观度") ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/maximum-69-number/README.md b/problems/maximum-69-number/README.md index 002a3340a..c03dda068 100644 --- a/problems/maximum-69-number/README.md +++ b/problems/maximum-69-number/README.md @@ -52,6 +52,7 @@ The maximum number is 9969. ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] ### Hints diff --git a/problems/maximum-absolute-sum-of-any-subarray/README.md b/problems/maximum-absolute-sum-of-any-subarray/README.md index 201f7ff7e..7a8fd35f0 100644 --- a/problems/maximum-absolute-sum-of-any-subarray/README.md +++ b/problems/maximum-absolute-sum-of-any-subarray/README.md @@ -48,7 +48,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/maximum-alternating-subsequence-sum/README.md b/problems/maximum-alternating-subsequence-sum/README.md new file mode 100644 index 000000000..93376d6f3 --- /dev/null +++ b/problems/maximum-alternating-subsequence-sum/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../remove-all-occurrences-of-a-substring "Remove All Occurrences of a Substring") +                 +[Next >](../design-movie-rental-system "Design Movie Rental System") + +## [1911. Maximum Alternating Subsequence Sum (Medium)](https://leetcode.com/problems/maximum-alternating-subsequence-sum "最大子序列交替和") + +

    The alternating sum of a 0-indexed array is defined as the sum of the elements at even indices minus the sum of the elements at odd indices.

    + +
      +
    • For example, the alternating sum of [4,2,5,3] is (4 + 5) - (2 + 3) = 4.
    • +
    + +

    Given an array nums, return the maximum alternating sum of any subsequence of nums (after reindexing the elements of the subsequence).

    + +
      +
    + +

    A subsequence of an array is a new array generated from the original array by deleting some elements (possibly none) without changing the remaining elements' relative order. For example, [2,7,4] is a subsequence of [4,2,3,7,2,1,4] (the underlined elements), while [2,4,2] is not.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [4,2,5,3]
    +Output: 7
    +Explanation: It is optimal to choose the subsequence [4,2,5] with alternating sum (4 + 5) - 2 = 7.
    +
    + +

    Example 2:

    + +
    +Input: nums = [5,6,7,8]
    +Output: 8
    +Explanation: It is optimal to choose the subsequence [8] with alternating sum 8.
    +
    + +

    Example 3:

    + +
    +Input: nums = [6,2,1,2,4,5]
    +Output: 10
    +Explanation: It is optimal to choose the subsequence [6,1,5] with alternating sum (6 + 5) - 1 = 10.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Is only tracking a single sum enough to solve the problem? +
    + +
    +Hint 2 +How does tracking an odd sum and an even sum reduce the number of states? +
    diff --git a/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md b/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md index 188966c7f..c1efb356e 100644 --- a/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md +++ b/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md @@ -11,15 +11,18 @@ ## [1465. Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts (Medium)](https://leetcode.com/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts "切割后面积最大的蛋糕") -

    Given a rectangular cake with height h and width w, and two arrays of integers horizontalCuts and verticalCuts where horizontalCuts[i] is the distance from the top of the rectangular cake to the ith horizontal cut and similarly, verticalCuts[j] is the distance from the left of the rectangular cake to the jth vertical cut.

    +

    You are given a rectangular cake of size h x w and two arrays of integers horizontalCuts and verticalCuts where:

    -

    Return the maximum area of a piece of cake after you cut at each horizontal and vertical position provided in the arrays horizontalCuts and verticalCutsSince the answer can be a huge number, return this modulo 10^9 + 7.

    +
      +
    • horizontalCuts[i] is the distance from the top of the rectangular cake to the ith horizontal cut and similarly, and
    • +
    • verticalCuts[j] is the distance from the left of the rectangular cake to the jth vertical cut.
    • +
    + +

    Return the maximum area of a piece of cake after you cut at each horizontal and vertical position provided in the arrays horizontalCuts and verticalCuts. Since the answer can be a large number, return this modulo 109 + 7.

     

    Example 1:

    - -

    - +
     Input: h = 5, w = 4, horizontalCuts = [1,2,4], verticalCuts = [1,3]
     Output: 4 
    @@ -27,9 +30,7 @@
     

    Example 2:

    - -

    - +
     Input: h = 5, w = 4, horizontalCuts = [3,1], verticalCuts = [1]
     Output: 6
    @@ -47,17 +48,19 @@
     

    Constraints:

      -
    • 2 <= h, w <= 10^9
    • -
    • 1 <= horizontalCuts.length < min(h, 10^5)
    • -
    • 1 <= verticalCuts.length < min(w, 10^5)
    • -
    • 1 <= horizontalCuts[i] < h
    • -
    • 1 <= verticalCuts[i] < w
    • -
    • It is guaranteed that all elements in horizontalCuts are distinct.
    • -
    • It is guaranteed that all elements in verticalCuts are distinct.
    • +
    • 2 <= h, w <= 109
    • +
    • 1 <= horizontalCuts.length <= min(h - 1, 105)
    • +
    • 1 <= verticalCuts.length <= min(w - 1, 105)
    • +
    • 1 <= horizontalCuts[i] < h
    • +
    • 1 <= verticalCuts[i] < w
    • +
    • All the elements in horizontalCuts are distinct.
    • +
    • All the elements in verticalCuts are distinct.
    ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/maximum-ascending-subarray-sum/README.md b/problems/maximum-ascending-subarray-sum/README.md index a324c3026..01261c083 100644 --- a/problems/maximum-ascending-subarray-sum/README.md +++ b/problems/maximum-ascending-subarray-sum/README.md @@ -58,7 +58,7 @@ ### Related Topics - [[Two Pointers](../../tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/maximum-average-pass-ratio/README.md b/problems/maximum-average-pass-ratio/README.md index be407aae5..7ff7c691a 100644 --- a/problems/maximum-average-pass-ratio/README.md +++ b/problems/maximum-average-pass-ratio/README.md @@ -46,7 +46,9 @@ ### Related Topics - [[Heap](../../tag/heap/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/maximum-average-subarray-i/README.md b/problems/maximum-average-subarray-i/README.md index e0d134101..46233ffdc 100644 --- a/problems/maximum-average-subarray-i/README.md +++ b/problems/maximum-average-subarray-i/README.md @@ -42,6 +42,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions 1. [Maximum Average Subarray II](../maximum-average-subarray-ii) (Hard) diff --git a/problems/maximum-average-subarray-ii/README.md b/problems/maximum-average-subarray-ii/README.md index 30b24b8d5..da5eb5464 100644 --- a/problems/maximum-average-subarray-ii/README.md +++ b/problems/maximum-average-subarray-ii/README.md @@ -11,31 +11,8 @@ ## [644. Maximum Average Subarray II (Hard)](https://leetcode.com/problems/maximum-average-subarray-ii "子数组最大平均数 II") -

    -Given an array consisting of n integers, find the contiguous subarray whose length is greater than or equal to k that has the maximum average value. And you need to output the maximum average value. -

    -

    Example 1:
    -

    -Input: [1,12,-5,-6,50,3], k = 4
    -Output: 12.75
    -Explanation:
    -when length is 5, maximum average value is 10.8,
    -when length is 6, maximum average value is 9.16667.
    -Thus return 12.75.
    -
    -

    - - -

    Note:
    -

      -
    1. 1 <= k <= n <= 10,000.
    2. -
    3. Elements of the given array will be in range [-10,000, 10,000].
    4. -
    5. The answer with the calculation error less than 10-5 will be accepted.
    6. -
    -

    - ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/maximum-average-subtree/README.md b/problems/maximum-average-subtree/README.md index 93cadd773..6c76109a0 100644 --- a/problems/maximum-average-subtree/README.md +++ b/problems/maximum-average-subtree/README.md @@ -11,38 +11,12 @@ ## [1120. Maximum Average Subtree (Medium)](https://leetcode.com/problems/maximum-average-subtree "子树的最大平均值") -

    Given the root of a binary tree, find the maximum average value of any subtree of that tree.

    -

    (A subtree of a tree is any node of that tree plus all its descendants. The average value of a tree is the sum of its values, divided by the number of nodes.)

    - -

     

    - -

    Example 1:

    - -

    - -
    -Input: [5,6,1]
    -Output: 6.00000
    -Explanation: 
    -For the node with value = 5 we have an average of (5 + 6 + 1) / 3 = 4.
    -For the node with value = 6 we have an average of 6 / 1 = 6.
    -For the node with value = 1 we have an average of 1 / 1 = 1.
    -So the answer is 6 which is the maximum.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. The number of nodes in the tree is between 1 and 5000.
    2. -
    3. Each node will have a value between 0 and 100000.
    4. -
    5. Answers will be accepted as correct if they are within 10^-5 of the correct answer.
    6. -
    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/maximum-binary-string-after-change/README.md b/problems/maximum-binary-string-after-change/README.md index c12ef6abb..ba26d20c5 100644 --- a/problems/maximum-binary-string-after-change/README.md +++ b/problems/maximum-binary-string-after-change/README.md @@ -60,6 +60,7 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/maximum-binary-tree-ii/README.md b/problems/maximum-binary-tree-ii/README.md index 0f0d7833d..e550fe95d 100644 --- a/problems/maximum-binary-tree-ii/README.md +++ b/problems/maximum-binary-tree-ii/README.md @@ -69,6 +69,7 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Maximum Binary Tree](../maximum-binary-tree) (Medium) diff --git a/problems/maximum-binary-tree/README.md b/problems/maximum-binary-tree/README.md index 7c8044cd2..a3e73213f 100644 --- a/problems/maximum-binary-tree/README.md +++ b/problems/maximum-binary-tree/README.md @@ -56,7 +56,12 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Similar Questions 1. [Maximum Binary Tree II](../maximum-binary-tree-ii) (Medium) diff --git a/problems/maximum-building-height/README.md b/problems/maximum-building-height/README.md index 3e5156108..011a85a98 100644 --- a/problems/maximum-building-height/README.md +++ b/problems/maximum-building-height/README.md @@ -66,8 +66,8 @@ We can build the buildings with heights [0,1,2,3,3,4,4,5,4,3], and the tallest b ### Related Topics - [[Greedy](../../tag/greedy/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/maximum-candies-you-can-get-from-boxes/README.md b/problems/maximum-candies-you-can-get-from-boxes/README.md index fec63de89..97727578b 100644 --- a/problems/maximum-candies-you-can-get-from-boxes/README.md +++ b/problems/maximum-candies-you-can-get-from-boxes/README.md @@ -84,7 +84,8 @@ Total number of candies collected = 7 + 4 + 5 = 16 candy. ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/maximum-depth-of-binary-tree/README.md b/problems/maximum-depth-of-binary-tree/README.md index 727699e57..4fef9e41f 100644 --- a/problems/maximum-depth-of-binary-tree/README.md +++ b/problems/maximum-depth-of-binary-tree/README.md @@ -54,8 +54,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Recursion](../../tag/recursion/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Balanced Binary Tree](../balanced-binary-tree) (Easy) diff --git a/problems/maximum-depth-of-n-ary-tree/README.md b/problems/maximum-depth-of-n-ary-tree/README.md index 1702bafe4..478fe7ee2 100644 --- a/problems/maximum-depth-of-n-ary-tree/README.md +++ b/problems/maximum-depth-of-n-ary-tree/README.md @@ -46,8 +46,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Similar Questions 1. [Maximum Depth of Binary Tree](../maximum-depth-of-binary-tree) (Easy) diff --git a/problems/maximum-difference-between-node-and-ancestor/README.md b/problems/maximum-difference-between-node-and-ancestor/README.md index 205a684e7..eab3e459c 100644 --- a/problems/maximum-difference-between-node-and-ancestor/README.md +++ b/problems/maximum-difference-between-node-and-ancestor/README.md @@ -45,7 +45,8 @@ Among all possible differences, the maximum value of 7 is obtained by |8 - 1| = ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/maximum-distance-between-a-pair-of-values/README.md b/problems/maximum-distance-between-a-pair-of-values/README.md index db796b767..0ea83b677 100644 --- a/problems/maximum-distance-between-a-pair-of-values/README.md +++ b/problems/maximum-distance-between-a-pair-of-values/README.md @@ -67,6 +67,7 @@ The maximum distance is 2 with pair (2,4). ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/maximum-distance-in-arrays/README.md b/problems/maximum-distance-in-arrays/README.md index 1ca07307e..09b43d3c0 100644 --- a/problems/maximum-distance-in-arrays/README.md +++ b/problems/maximum-distance-in-arrays/README.md @@ -11,29 +11,8 @@ ## [624. Maximum Distance in Arrays (Medium)](https://leetcode.com/problems/maximum-distance-in-arrays "数组列表中的最大距离") -

    -Given m arrays, and each array is sorted in ascending order. Now you can pick up two integers from two different arrays (each array picks one) and calculate the distance. We define the distance between two integers a and b to be their absolute difference |a-b|. Your task is to find the maximum distance. -

    -

    Example 1:
    -

    Input: 
    -[[1,2,3],
    - [4,5],
    - [1,2,3]]
    -Output: 4
    -Explanation: 
    -One way to reach the maximum distance 4 is to pick 1 in the first or third array and pick 5 in the second array.
    -
    -

    - -

    Note:
    -

      -
    1. Each given array will have at least 1 number. There will be at least two non-empty arrays.
    2. -
    3. The total number of the integers in all the m arrays will be in the range of [2, 10000].
    4. -
    5. The integers in the m arrays will be in the range of [-10000, 10000].
    6. -
    -

    ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/maximum-element-after-decreasing-and-rearranging/README.md b/problems/maximum-element-after-decreasing-and-rearranging/README.md index 8728b6e79..cb31b4cfe 100644 --- a/problems/maximum-element-after-decreasing-and-rearranging/README.md +++ b/problems/maximum-element-after-decreasing-and-rearranging/README.md @@ -70,7 +70,8 @@ The largest element in arr is 3. ### Related Topics [[Greedy](../../tag/greedy/README.md)] - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/maximum-equal-frequency/README.md b/problems/maximum-equal-frequency/README.md index a8bbb691a..790dae684 100644 --- a/problems/maximum-equal-frequency/README.md +++ b/problems/maximum-equal-frequency/README.md @@ -54,6 +54,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] ### Hints diff --git a/problems/maximum-erasure-value/README.md b/problems/maximum-erasure-value/README.md index 688835a6e..949d2a397 100644 --- a/problems/maximum-erasure-value/README.md +++ b/problems/maximum-erasure-value/README.md @@ -43,7 +43,9 @@ ### Related Topics - [[Two Pointers](../../tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/maximum-font-to-fit-a-sentence-in-a-screen/README.md b/problems/maximum-font-to-fit-a-sentence-in-a-screen/README.md index 5ff4fa928..e7e5e1380 100644 --- a/problems/maximum-font-to-fit-a-sentence-in-a-screen/README.md +++ b/problems/maximum-font-to-fit-a-sentence-in-a-screen/README.md @@ -14,8 +14,10 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Interactive](../../tag/interactive/README.md)] ### Hints
    diff --git a/problems/maximum-frequency-stack/README.md b/problems/maximum-frequency-stack/README.md index 37a7d0dda..03b442b2d 100644 --- a/problems/maximum-frequency-stack/README.md +++ b/problems/maximum-frequency-stack/README.md @@ -60,4 +60,6 @@ freqStack.pop(); // return 4, as 4, 5 and 7 is the most frequent, but 4 is clo ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] diff --git a/problems/maximum-gap/README.md b/problems/maximum-gap/README.md index 268892541..a099a38f9 100644 --- a/problems/maximum-gap/README.md +++ b/problems/maximum-gap/README.md @@ -36,9 +36,12 @@

    Constraints:

      -
    • 1 <= nums.length <= 104
    • +
    • 1 <= nums.length <= 105
    • 0 <= nums[i] <= 109
    ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Bucket Sort](../../tag/bucket-sort/README.md)] + [[Radix Sort](../../tag/radix-sort/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/maximum-height-by-stacking-cuboids/README.md b/problems/maximum-height-by-stacking-cuboids/README.md index 1d77d2dec..3fefb2f9d 100644 --- a/problems/maximum-height-by-stacking-cuboids/README.md +++ b/problems/maximum-height-by-stacking-cuboids/README.md @@ -63,8 +63,9 @@ The maximum height of stacked cuboids is 6 * 17 = 102. ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/maximum-ice-cream-bars/README.md b/problems/maximum-ice-cream-bars/README.md index 7dda570d1..548ec3514 100644 --- a/problems/maximum-ice-cream-bars/README.md +++ b/problems/maximum-ice-cream-bars/README.md @@ -55,8 +55,9 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md b/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md index 95138ca76..15228dd77 100644 --- a/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md +++ b/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md @@ -51,6 +51,8 @@ Maximum length is 4. ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Hints diff --git a/problems/maximum-length-of-pair-chain/README.md b/problems/maximum-length-of-pair-chain/README.md index a196c411d..821eaff92 100644 --- a/problems/maximum-length-of-pair-chain/README.md +++ b/problems/maximum-length-of-pair-chain/README.md @@ -46,7 +46,10 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Longest Increasing Subsequence](../longest-increasing-subsequence) (Medium) diff --git a/problems/maximum-length-of-repeated-subarray/README.md b/problems/maximum-length-of-repeated-subarray/README.md index a0cf0aef6..71dabf33b 100644 --- a/problems/maximum-length-of-repeated-subarray/README.md +++ b/problems/maximum-length-of-repeated-subarray/README.md @@ -39,9 +39,11 @@ ### Related Topics [[Array](../../tag/array/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Similar Questions 1. [Minimum Size Subarray Sum](../minimum-size-subarray-sum) (Medium) diff --git a/problems/maximum-length-of-subarray-with-positive-product/README.md b/problems/maximum-length-of-subarray-with-positive-product/README.md index 4c3f1c5af..a3e9e707b 100644 --- a/problems/maximum-length-of-subarray-with-positive-product/README.md +++ b/problems/maximum-length-of-subarray-with-positive-product/README.md @@ -66,6 +66,8 @@ Notice that we cannot include 0 in the subarray since that'll make the produ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/maximum-level-sum-of-a-binary-tree/README.md b/problems/maximum-level-sum-of-a-binary-tree/README.md index caea5dfc4..f91184c27 100644 --- a/problems/maximum-level-sum-of-a-binary-tree/README.md +++ b/problems/maximum-level-sum-of-a-binary-tree/README.md @@ -45,7 +45,8 @@ So we return the level with the maximum sum which is level 2. ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/maximum-nesting-depth-of-the-parentheses/README.md b/problems/maximum-nesting-depth-of-the-parentheses/README.md index dc1655b0c..b1ae9a2e3 100644 --- a/problems/maximum-nesting-depth-of-the-parentheses/README.md +++ b/problems/maximum-nesting-depth-of-the-parentheses/README.md @@ -72,6 +72,7 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/README.md b/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/README.md index fcd02181e..adff7103c 100644 --- a/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/README.md +++ b/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/README.md @@ -60,5 +60,5 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] + [[Stack](../../tag/stack/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/maximum-non-negative-product-in-a-matrix/README.md b/problems/maximum-non-negative-product-in-a-matrix/README.md index 000ec041a..29be70abf 100644 --- a/problems/maximum-non-negative-product-in-a-matrix/README.md +++ b/problems/maximum-non-negative-product-in-a-matrix/README.md @@ -68,8 +68,9 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-accepted-invitations/README.md b/problems/maximum-number-of-accepted-invitations/README.md index 8e8c7f5e5..b46d29238 100644 --- a/problems/maximum-number-of-accepted-invitations/README.md +++ b/problems/maximum-number-of-accepted-invitations/README.md @@ -9,12 +9,14 @@                  [Next >](../find-customers-with-positive-revenue-this-year "Find Customers With Positive Revenue this Year") -## [1820. Maximum Number of Accepted Invitations (Medium)](https://leetcode.com/problems/maximum-number-of-accepted-invitations "") +## [1820. Maximum Number of Accepted Invitations (Medium)](https://leetcode.com/problems/maximum-number-of-accepted-invitations "最多邀请的个数") ### Related Topics - [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-achievable-transfer-requests/README.md b/problems/maximum-number-of-achievable-transfer-requests/README.md index f5ba90777..8e0396600 100644 --- a/problems/maximum-number-of-achievable-transfer-requests/README.md +++ b/problems/maximum-number-of-achievable-transfer-requests/README.md @@ -64,7 +64,8 @@ We can achieve all the requests.
    ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-balloons/README.md b/problems/maximum-number-of-balloons/README.md index daf127636..12d3bbfe9 100644 --- a/problems/maximum-number-of-balloons/README.md +++ b/problems/maximum-number-of-balloons/README.md @@ -52,6 +52,7 @@ ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-balls-in-a-box/README.md b/problems/maximum-number-of-balls-in-a-box/README.md index 2d9649821..da67222e1 100644 --- a/problems/maximum-number-of-balls-in-a-box/README.md +++ b/problems/maximum-number-of-balls-in-a-box/README.md @@ -58,7 +58,9 @@ Box 10 has the most number of balls with 2 balls. ### Related Topics - [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-coins-you-can-get/README.md b/problems/maximum-number-of-coins-you-can-get/README.md index 0edf8365b..310a9960b 100644 --- a/problems/maximum-number-of-coins-you-can-get/README.md +++ b/problems/maximum-number-of-coins-you-can-get/README.md @@ -61,7 +61,11 @@ On the other hand if we choose this arrangement (1, 2, 8), (2, ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-consecutive-values-you-can-make/README.md b/problems/maximum-number-of-consecutive-values-you-can-make/README.md index 34b7ad472..684b0035e 100644 --- a/problems/maximum-number-of-consecutive-values-you-can-make/README.md +++ b/problems/maximum-number-of-consecutive-values-you-can-make/README.md @@ -61,6 +61,7 @@ You can make 8 consecutive integer values starting from 0. ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md b/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md index 972f9f534..a757781c4 100644 --- a/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md +++ b/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md @@ -62,6 +62,8 @@ ### Related Topics [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-eaten-apples/README.md b/problems/maximum-number-of-eaten-apples/README.md index 0c47a6301..31499bb00 100644 --- a/problems/maximum-number-of-eaten-apples/README.md +++ b/problems/maximum-number-of-eaten-apples/README.md @@ -53,8 +53,9 @@ ### Related Topics - [[Heap](../../tag/heap/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-events-that-can-be-attended-ii/README.md b/problems/maximum-number-of-events-that-can-be-attended-ii/README.md index f61651cc9..0b0bc2903 100644 --- a/problems/maximum-number-of-events-that-can-be-attended-ii/README.md +++ b/problems/maximum-number-of-events-that-can-be-attended-ii/README.md @@ -57,6 +57,7 @@ Notice that you cannot attend any other event as they overlap, and that you do < ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/maximum-number-of-events-that-can-be-attended/README.md b/problems/maximum-number-of-events-that-can-be-attended/README.md index afabbfcba..905c5f0a6 100644 --- a/problems/maximum-number-of-events-that-can-be-attended/README.md +++ b/problems/maximum-number-of-events-that-can-be-attended/README.md @@ -69,8 +69,8 @@ Attend the third event on day 3. ### Related Topics [[Greedy](../../tag/greedy/README.md)] - [[Sort](../../tag/sort/README.md)] - [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-groups-getting-fresh-donuts/README.md b/problems/maximum-number-of-groups-getting-fresh-donuts/README.md index e405a90c5..e4ab76574 100644 --- a/problems/maximum-number-of-groups-getting-fresh-donuts/README.md +++ b/problems/maximum-number-of-groups-getting-fresh-donuts/README.md @@ -43,7 +43,11 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md b/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md index ba8d02b14..2e107370c 100644 --- a/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md +++ b/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md @@ -56,7 +56,10 @@ ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-non-overlapping-substrings/README.md b/problems/maximum-number-of-non-overlapping-substrings/README.md index 9adf76d92..93e3be684 100644 --- a/problems/maximum-number-of-non-overlapping-substrings/README.md +++ b/problems/maximum-number-of-non-overlapping-substrings/README.md @@ -58,6 +58,7 @@ If we choose the first string, we cannot choose anything else and we'd get o ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-occurrences-of-a-substring/README.md b/problems/maximum-number-of-occurrences-of-a-substring/README.md index 2716510ab..39e7f1bd0 100644 --- a/problems/maximum-number-of-occurrences-of-a-substring/README.md +++ b/problems/maximum-number-of-occurrences-of-a-substring/README.md @@ -61,8 +61,9 @@ It satisfies the conditions, 2 unique letters and size 3 (between minSize and ma ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-ones/README.md b/problems/maximum-number-of-ones/README.md index 5445b73ec..e354c8c8e 100644 --- a/problems/maximum-number-of-ones/README.md +++ b/problems/maximum-number-of-ones/README.md @@ -11,47 +11,11 @@ ## [1183. Maximum Number of Ones (Hard)](https://leetcode.com/problems/maximum-number-of-ones "矩阵中 1 的最大数量") -

    Consider a matrix M with dimensions width * height, such that every cell has value 0 or 1, and any square sub-matrix of M of size sideLength * sideLength has at most maxOnes ones.

    -

    Return the maximum possible number of ones that the matrix M can have.

    - -

     

    -

    Example 1:

    - -
    -Input: width = 3, height = 3, sideLength = 2, maxOnes = 1
    -Output: 4
    -Explanation:
    -In a 3*3 matrix, no 2*2 sub-matrix can have more than 1 one.
    -The best solution that has 4 ones is:
    -[1,0,1]
    -[0,0,0]
    -[1,0,1]
    -
    - -

    Example 2:

    - -
    -Input: width = 3, height = 3, sideLength = 2, maxOnes = 2
    -Output: 6
    -Explanation:
    -[1,0,1]
    -[1,0,1]
    -[1,0,1]
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= width, height <= 100
    • -
    • 1 <= sideLength <= width, height
    • -
    • 0 <= maxOnes <= sideLength * sideLength
    • -
    ### Related Topics - [[Sort](../../tag/sort/README.md)] - [[Math](../../tag/math/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-removable-characters/README.md b/problems/maximum-number-of-removable-characters/README.md new file mode 100644 index 000000000..f8996cff2 --- /dev/null +++ b/problems/maximum-number-of-removable-characters/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../redistribute-characters-to-make-all-strings-equal "Redistribute Characters to Make All Strings Equal") +                 +[Next >](../merge-triplets-to-form-target-triplet "Merge Triplets to Form Target Triplet") + +## [1898. Maximum Number of Removable Characters (Medium)](https://leetcode.com/problems/maximum-number-of-removable-characters "可移除字符的最大数目") + +

    You are given two strings s and p where p is a subsequence of s. You are also given a distinct 0-indexed integer array removable containing a subset of indices of s (s is also 0-indexed).

    + +

    You want to choose an integer k (0 <= k <= removable.length) such that, after removing k characters from s using the first k indices in removable, p is still a subsequence of s. More formally, you will mark the character at s[removable[i]] for each 0 <= i < k, then remove all marked characters and check if p is still a subsequence.

    + +

    Return the maximum k you can choose such that p is still a subsequence of s after the removals.

    + +

    A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "abcacb", p = "ab", removable = [3,1,0]
    +Output: 2
    +Explanation: After removing the characters at indices 3 and 1, "abcacb" becomes "accb".
    +"ab" is a subsequence of "accb".
    +If we remove the characters at indices 3, 1, and 0, "abcacb" becomes "ccb", and "ab" is no longer a subsequence.
    +Hence, the maximum k is 2.
    +
    + +

    Example 2:

    + +
    +Input: s = "abcbddddd", p = "abcd", removable = [3,2,1,4,5,6]
    +Output: 1
    +Explanation: After removing the character at index 3, "abcbddddd" becomes "abcddddd".
    +"abcd" is a subsequence of "abcddddd".
    +
    + +

    Example 3:

    + +
    +Input: s = "abcab", p = "abc", removable = [0,1,2,3,4]
    +Output: 0
    +Explanation: If you remove the first index in the array removable, "abc" is no longer a subsequence.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= p.length <= s.length <= 105
    • +
    • 0 <= removable.length < s.length
    • +
    • 0 <= removable[i] < s.length
    • +
    • p is a subsequence of s.
    • +
    • s and p both consist of lowercase English letters.
    • +
    • The elements in removable are distinct.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +First, we need to think about solving an easier problem, If we remove a set of indices from the string does P exist in S as a subsequence +
    + +
    +Hint 2 +We can binary search the K and check by solving the above problem. +
    diff --git a/problems/maximum-number-of-visible-points/README.md b/problems/maximum-number-of-visible-points/README.md index 4f0326cf0..fdf1f0654 100644 --- a/problems/maximum-number-of-visible-points/README.md +++ b/problems/maximum-number-of-visible-points/README.md @@ -63,7 +63,10 @@ ### Related Topics [[Geometry](../../tag/geometry/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/maximum-of-absolute-value-expression/README.md b/problems/maximum-of-absolute-value-expression/README.md index 80a75c955..b89071148 100644 --- a/problems/maximum-of-absolute-value-expression/README.md +++ b/problems/maximum-of-absolute-value-expression/README.md @@ -41,7 +41,7 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] ### Hints diff --git a/problems/maximum-performance-of-a-team/README.md b/problems/maximum-performance-of-a-team/README.md index 424a9f323..b3d6167e8 100644 --- a/problems/maximum-performance-of-a-team/README.md +++ b/problems/maximum-performance-of-a-team/README.md @@ -49,7 +49,7 @@ We have the maximum performance of the team by selecting engineer 2 (with speed=

    Constraints:

      -
    • 1 <= <= k <= n <= 105
    • +
    • 1 <= k <= n <= 105
    • speed.length == n
    • efficiency.length == n
    • 1 <= speed[i] <= 105
    • @@ -58,7 +58,9 @@ We have the maximum performance of the team by selecting engineer 2 (with speed= ### Related Topics [[Greedy](../../tag/greedy/README.md)] - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
      diff --git a/problems/maximum-points-you-can-obtain-from-cards/README.md b/problems/maximum-points-you-can-obtain-from-cards/README.md index 7ecc05c49..69ddfcb04 100644 --- a/problems/maximum-points-you-can-obtain-from-cards/README.md +++ b/problems/maximum-points-you-can-obtain-from-cards/README.md @@ -70,7 +70,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints diff --git a/problems/maximum-population-year/README.md b/problems/maximum-population-year/README.md index 2d173f3a6..ebe6e3ffe 100644 --- a/problems/maximum-population-year/README.md +++ b/problems/maximum-population-year/README.md @@ -45,6 +45,7 @@ The earlier year between them is 1960. ### Related Topics [[Array](../../tag/array/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
      diff --git a/problems/maximum-product-difference-between-two-pairs/README.md b/problems/maximum-product-difference-between-two-pairs/README.md new file mode 100644 index 000000000..62728115c --- /dev/null +++ b/problems/maximum-product-difference-between-two-pairs/README.md @@ -0,0 +1,64 @@ + + + + + + + +[< Previous](../design-movie-rental-system "Design Movie Rental System") +                 +[Next >](../cyclically-rotating-a-grid "Cyclically Rotating a Grid") + +## [1913. Maximum Product Difference Between Two Pairs (Easy)](https://leetcode.com/problems/maximum-product-difference-between-two-pairs "两个数对之间的最大乘积差") + +

      The product difference between two pairs (a, b) and (c, d) is defined as (a * b) - (c * d).

      + +
        +
      • For example, the product difference between (5, 6) and (2, 7) is (5 * 6) - (2 * 7) = 16.
      • +
      + +

      Given an integer array nums, choose four distinct indices w, x, y, and z such that the product difference between pairs (nums[w], nums[x]) and (nums[y], nums[z]) is maximized.

      + +

      Return the maximum such product difference.

      + +

       

      +

      Example 1:

      + +
      +Input: nums = [5,6,2,7,4]
      +Output: 34
      +Explanation: We can choose indices 1 and 3 for the first pair (6, 7) and indices 2 and 4 for the second pair (2, 4).
      +The product difference is (6 * 7) - (2 * 4) = 34.
      +
      + +

      Example 2:

      + +
      +Input: nums = [4,2,5,9,7,4,8]
      +Output: 64
      +Explanation: We can choose indices 3 and 6 for the first pair (9, 8) and indices 1 and 5 for the second pair (2, 4).
      +The product difference is (9 * 8) - (2 * 4) = 64.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 4 <= nums.length <= 104
      • +
      • 1 <= nums[i] <= 104
      • +
      + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
      +Hint 1 +If you only had to find the maximum product of 2 numbers in an array, which 2 numbers should you choose? +
      + +
      +Hint 2 +We only need to worry about 4 numbers in the array. +
      diff --git a/problems/maximum-product-of-splitted-binary-tree/README.md b/problems/maximum-product-of-splitted-binary-tree/README.md index fbe9b425e..e82c128a5 100644 --- a/problems/maximum-product-of-splitted-binary-tree/README.md +++ b/problems/maximum-product-of-splitted-binary-tree/README.md @@ -60,7 +60,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
      diff --git a/problems/maximum-product-of-three-numbers/README.md b/problems/maximum-product-of-three-numbers/README.md index 706b42890..66da498b6 100644 --- a/problems/maximum-product-of-three-numbers/README.md +++ b/problems/maximum-product-of-three-numbers/README.md @@ -35,6 +35,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Maximum Product Subarray](../maximum-product-subarray) (Medium) diff --git a/problems/maximum-product-of-two-elements-in-an-array/README.md b/problems/maximum-product-of-two-elements-in-an-array/README.md index f343dba97..e13c8b8ea 100644 --- a/problems/maximum-product-of-two-elements-in-an-array/README.md +++ b/problems/maximum-product-of-two-elements-in-an-array/README.md @@ -46,6 +46,8 @@ Given the array of integers nums, you will choose two different ind ### Related Topics [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
      diff --git a/problems/maximum-product-of-word-lengths/README.md b/problems/maximum-product-of-word-lengths/README.md index cbd9bea69..32a3e74c8 100644 --- a/problems/maximum-product-of-word-lengths/README.md +++ b/problems/maximum-product-of-word-lengths/README.md @@ -49,3 +49,5 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/maximum-profit-in-job-scheduling/README.md b/problems/maximum-profit-in-job-scheduling/README.md index dc099fba5..3c4b4a932 100644 --- a/problems/maximum-profit-in-job-scheduling/README.md +++ b/problems/maximum-profit-in-job-scheduling/README.md @@ -59,9 +59,10 @@ Profit obtained 150 = 20 + 70 + 60.
    ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/maximum-profit-of-operating-a-centennial-wheel/README.md b/problems/maximum-profit-of-operating-a-centennial-wheel/README.md index 3a5ec0be3..29ba62fb4 100644 --- a/problems/maximum-profit-of-operating-a-centennial-wheel/README.md +++ b/problems/maximum-profit-of-operating-a-centennial-wheel/README.md @@ -92,7 +92,8 @@ The highest profit was $36 after rotating the wheel 9 times. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/maximum-repeating-substring/README.md b/problems/maximum-repeating-substring/README.md index e9924de65..4a6ecdf62 100644 --- a/problems/maximum-repeating-substring/README.md +++ b/problems/maximum-repeating-substring/README.md @@ -51,6 +51,7 @@ ### Related Topics [[String](../../tag/string/README.md)] + [[String Matching](../../tag/string-matching/README.md)] ### Hints
    diff --git a/problems/maximum-score-from-performing-multiplication-operations/README.md b/problems/maximum-score-from-performing-multiplication-operations/README.md index 097d29180..c4deff3bb 100644 --- a/problems/maximum-score-from-performing-multiplication-operations/README.md +++ b/problems/maximum-score-from-performing-multiplication-operations/README.md @@ -61,12 +61,13 @@ The total score is 50 + 15 - 9 + 4 + 42 = 102. ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    Hint 1 -At first glance, the solution seems to be greedy, but if you try to greedily take the largest value from the begging or the end, this will not be optimal. +At first glance, the solution seems to be greedy, but if you try to greedily take the largest value from the beginning or the end, this will not be optimal.
    @@ -76,5 +77,5 @@ You should try all scenarios but this will be costy.
    Hint 3 -Memoizing the pre-visited states while trying all the possible scenarios will reduce the complexity, and hence dp is the perfect choice here. +Memoizing the pre-visited states while trying all the possible scenarios will reduce the complexity, and hence dp is a perfect choice here.
    diff --git a/problems/maximum-score-from-removing-stones/README.md b/problems/maximum-score-from-removing-stones/README.md index dd2d1cc49..1c3587b37 100644 --- a/problems/maximum-score-from-removing-stones/README.md +++ b/problems/maximum-score-from-removing-stones/README.md @@ -64,8 +64,9 @@ After that, there are fewer than two non-empty piles, so the game ends. ### Related Topics - [[Heap](../../tag/heap/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/maximum-score-from-removing-substrings/README.md b/problems/maximum-score-from-removing-substrings/README.md index a6738ec97..194104d20 100644 --- a/problems/maximum-score-from-removing-substrings/README.md +++ b/problems/maximum-score-from-removing-substrings/README.md @@ -58,7 +58,9 @@ Total score = 5 + 4 + 5 + 5 = 19. ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/maximum-score-of-a-good-subarray/README.md b/problems/maximum-score-of-a-good-subarray/README.md index 289c998b4..99f408d43 100644 --- a/problems/maximum-score-of-a-good-subarray/README.md +++ b/problems/maximum-score-of-a-good-subarray/README.md @@ -44,7 +44,10 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints
    diff --git a/problems/maximum-score-words-formed-by-letters/README.md b/problems/maximum-score-words-formed-by-letters/README.md index 1ca66233a..4423384c4 100644 --- a/problems/maximum-score-words-formed-by-letters/README.md +++ b/problems/maximum-score-words-formed-by-letters/README.md @@ -61,6 +61,11 @@ Letter "e" can only be used once. ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md b/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md index b989ac737..9b67293a2 100644 --- a/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md +++ b/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md @@ -57,6 +57,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/maximum-size-subarray-sum-equals-k/README.md b/problems/maximum-size-subarray-sum-equals-k/README.md index e963bfaec..f290e5b3d 100644 --- a/problems/maximum-size-subarray-sum-equals-k/README.md +++ b/problems/maximum-size-subarray-sum-equals-k/README.md @@ -11,30 +11,10 @@ ## [325. Maximum Size Subarray Sum Equals k (Medium)](https://leetcode.com/problems/maximum-size-subarray-sum-equals-k "和等于 k 的最长子数组长度") -

    Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn't one, return 0 instead.

    -

    Note:
    -The sum of the entire nums array is guaranteed to fit within the 32-bit signed integer range.

    - -

    Example 1:

    - -
    -Input: nums = [1, -1, 5, -2, 3], k = 3
    -Output: 4 
    -Explanation: The subarray [1, -1, 5, -2] sums to 3 and is the longest.
    -
    - -

    Example 2:

    - -
    -Input: nums = [-2, -1, 2, 1], k = 1
    -Output: 2 
    -Explanation: The subarray [-1, 2] sums to 1 and is the longest.
    - -

    Follow Up:
    -Can you do it in O(n) time?

    ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions diff --git a/problems/maximum-students-taking-exam/README.md b/problems/maximum-students-taking-exam/README.md index 6776e572c..c47343171 100644 --- a/problems/maximum-students-taking-exam/README.md +++ b/problems/maximum-students-taking-exam/README.md @@ -65,7 +65,11 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/maximum-subarray-min-product/README.md b/problems/maximum-subarray-min-product/README.md index 89892e4b5..16ec5c983 100644 --- a/problems/maximum-subarray-min-product/README.md +++ b/problems/maximum-subarray-min-product/README.md @@ -60,11 +60,10 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] - [[Union Find](../../tag/union-find/README.md)] - [[Queue](../../tag/queue/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints
    diff --git a/problems/maximum-subarray-sum-after-one-operation/README.md b/problems/maximum-subarray-sum-after-one-operation/README.md index 4e89083fe..0c2afea07 100644 --- a/problems/maximum-subarray-sum-after-one-operation/README.md +++ b/problems/maximum-subarray-sum-after-one-operation/README.md @@ -14,6 +14,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/maximum-subarray-sum-with-one-deletion/README.md b/problems/maximum-subarray-sum-with-one-deletion/README.md index 417f93f04..3c9286232 100644 --- a/problems/maximum-subarray-sum-with-one-deletion/README.md +++ b/problems/maximum-subarray-sum-with-one-deletion/README.md @@ -48,6 +48,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/maximum-sum-bst-in-binary-tree/README.md b/problems/maximum-sum-bst-in-binary-tree/README.md index fe33f295a..a102ef922 100644 --- a/problems/maximum-sum-bst-in-binary-tree/README.md +++ b/problems/maximum-sum-bst-in-binary-tree/README.md @@ -73,8 +73,11 @@ ### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/maximum-sum-circular-subarray/README.md b/problems/maximum-sum-circular-subarray/README.md index 6351fd614..d0207e9ad 100644 --- a/problems/maximum-sum-circular-subarray/README.md +++ b/problems/maximum-sum-circular-subarray/README.md @@ -68,7 +68,11 @@ ### Related Topics + [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] ### Hints
    diff --git a/problems/maximum-sum-obtained-of-any-permutation/README.md b/problems/maximum-sum-obtained-of-any-permutation/README.md index 1aff347b1..dcb1c3861 100644 --- a/problems/maximum-sum-obtained-of-any-permutation/README.md +++ b/problems/maximum-sum-obtained-of-any-permutation/README.md @@ -61,6 +61,9 @@ Total sum: 11 + 8 = 19, which is the best that you can do. ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/maximum-sum-of-two-non-overlapping-subarrays/README.md b/problems/maximum-sum-of-two-non-overlapping-subarrays/README.md index 4eddf187b..5210c6872 100644 --- a/problems/maximum-sum-of-two-non-overlapping-subarrays/README.md +++ b/problems/maximum-sum-of-two-non-overlapping-subarrays/README.md @@ -68,6 +68,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/maximum-swap/README.md b/problems/maximum-swap/README.md index 5abaf0719..5e5f6da0c 100644 --- a/problems/maximum-swap/README.md +++ b/problems/maximum-swap/README.md @@ -40,7 +40,7 @@ ### Related Topics - [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] ### Similar Questions diff --git a/problems/maximum-transaction-each-day/README.md b/problems/maximum-transaction-each-day/README.md index 19dd5da19..1931be985 100644 --- a/problems/maximum-transaction-each-day/README.md +++ b/problems/maximum-transaction-each-day/README.md @@ -9,6 +9,9 @@                  [Next >](../check-if-the-sentence-is-pangram "Check if the Sentence Is Pangram") -## [1831. Maximum Transaction Each Day (Medium)](https://leetcode.com/problems/maximum-transaction-each-day "") +## [1831. Maximum Transaction Each Day (Medium)](https://leetcode.com/problems/maximum-transaction-each-day "每天的最大交易") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/maximum-units-on-a-truck/README.md b/problems/maximum-units-on-a-truck/README.md index da2814007..5cd68b096 100644 --- a/problems/maximum-units-on-a-truck/README.md +++ b/problems/maximum-units-on-a-truck/README.md @@ -54,7 +54,8 @@ The total number of units will be = (1 * 3) + (2 * 2) + (1 * 1) = 8. ### Related Topics [[Greedy](../../tag/greedy/README.md)] - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/maximum-vacation-days/README.md b/problems/maximum-vacation-days/README.md index 4868ce70c..124506545 100644 --- a/problems/maximum-vacation-days/README.md +++ b/problems/maximum-vacation-days/README.md @@ -11,68 +11,12 @@ ## [568. Maximum Vacation Days (Hard)](https://leetcode.com/problems/maximum-vacation-days "最大休假天数") -

    -LeetCode wants to give one of its best employees the option to travel among N cities to collect algorithm problems. But all work and no play makes Jack a dull boy, you could take vacations in some particular cities and weeks. Your job is to schedule the traveling to maximize the number of vacation days you could take, but there are certain rules and restrictions you need to follow. -

    -

    Rules and restrictions:
    -

      -
    1. You can only travel among N cities, represented by indexes from 0 to N-1. Initially, you are in the city indexed 0 on Monday.
    2. -
    3. The cities are connected by flights. The flights are represented as a N*N matrix (not necessary symmetrical), called flights representing the airline status from the city i to the city j. If there is no flight from the city i to the city j, flights[i][j] = 0; Otherwise, flights[i][j] = 1. Also, flights[i][i] = 0 for all i.
    4. -
    5. You totally have K weeks (each week has 7 days) to travel. You can only take flights at most once per day and can only take flights on each week's Monday morning. Since flight time is so short, we don't consider the impact of flight time.
    6. -
    7. For each city, you can only have restricted vacation days in different weeks, given an N*K matrix called days representing this relationship. For the value of days[i][j], it represents the maximum days you could take vacation in the city i in the week j.
    8. -
    -

    - -

    You're given the flights matrix and days matrix, and you need to output the maximum vacation days you could take during K weeks.

    - -

    Example 1:
    -

    -Input:flights = [[0,1,1],[1,0,1],[1,1,0]], days = [[1,3,1],[6,0,3],[3,3,3]]
    -Output: 12
    -Explanation: 
    Ans = 6 + 3 + 3 = 12.
    -One of the best strategies is: -1st week : fly from city 0 to city 1 on Monday, and play 6 days and work 1 day.
    (Although you start at city 0, we could also fly to and start at other cities since it is Monday.) -2nd week : fly from city 1 to city 2 on Monday, and play 3 days and work 4 days. -3rd week : stay at city 2, and play 3 days and work 4 days. -
    -

    - -

    Example 2:
    -

    -Input:flights = [[0,0,0],[0,0,0],[0,0,0]], days = [[1,1,1],[7,7,7],[7,7,7]]
    -Output: 3
    -Explanation: 
    Ans = 1 + 1 + 1 = 3.
    -Since there is no flights enable you to move to another city, you have to stay at city 0 for the whole 3 weeks.
    For each week, you only have one day to play and six days to work.
    So the maximum number of vacation days is 3. -
    -

    - -

    Example 3:
    -

    -Input:flights = [[0,1,1],[1,0,1],[1,1,0]], days = [[7,0,0],[0,7,0],[0,0,7]]
    -Output: 21
    -Explanation:
    Ans = 7 + 7 + 7 = 21
    -One of the best strategies is: -1st week : stay at city 0, and play 7 days. -2nd week : fly from city 0 to city 1 on Monday, and play 7 days. -3rd week : fly from city 1 to city 2 on Monday, and play 7 days. -
    -

    - - -

    Note:
    -

      -
    1. N and K are positive integers, which are in the range of [1, 100].
    2. -
    3. In the matrix flights, all the values are integers in the range of [0, 1].
    4. -
    5. In the matrix days, all the values are integers in the range [0, 7].
    6. -
    7. You could stay at a city beyond the number of vacation days, but you should work on the extra days, which won't be counted as vacation days.
    8. -
    9. If you fly from the city A to the city B and take the vacation on that day, the deduction towards vacation days will count towards the vacation days of city B in that week.
    10. -
    11. We don't consider the impact of flight hours towards the calculation of vacation days.
    12. -
    -

    ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Cheapest Flights Within K Stops](../cheapest-flights-within-k-stops) (Medium) diff --git a/problems/maximum-value-after-insertion/README.md b/problems/maximum-value-after-insertion/README.md index b8c19bb1f..c643ca1ad 100644 --- a/problems/maximum-value-after-insertion/README.md +++ b/problems/maximum-value-after-insertion/README.md @@ -52,6 +52,7 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/maximum-width-of-binary-tree/README.md b/problems/maximum-width-of-binary-tree/README.md index 66158a27b..4678761e5 100644 --- a/problems/maximum-width-of-binary-tree/README.md +++ b/problems/maximum-width-of-binary-tree/README.md @@ -62,3 +62,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/maximum-width-ramp/README.md b/problems/maximum-width-ramp/README.md index 6ceef3e0b..0e5b438b2 100644 --- a/problems/maximum-width-ramp/README.md +++ b/problems/maximum-width-ramp/README.md @@ -55,4 +55,6 @@ The maximum width ramp is achieved at (i, j) = (2, 9): nums[2] = 1 and nums[9] =
    ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] diff --git a/problems/maximum-xor-for-each-query/README.md b/problems/maximum-xor-for-each-query/README.md index 67ceb00fe..c2d67f4c1 100644 --- a/problems/maximum-xor-for-each-query/README.md +++ b/problems/maximum-xor-for-each-query/README.md @@ -65,6 +65,8 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/maximum-xor-of-two-numbers-in-an-array/README.md b/problems/maximum-xor-of-two-numbers-in-an-array/README.md index 210c6453a..92757b424 100644 --- a/problems/maximum-xor-of-two-numbers-in-an-array/README.md +++ b/problems/maximum-xor-of-two-numbers-in-an-array/README.md @@ -60,3 +60,5 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Trie](../../tag/trie/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/maximum-xor-with-an-element-from-array/README.md b/problems/maximum-xor-with-an-element-from-array/README.md index 8c7b78eaf..aaef703f0 100644 --- a/problems/maximum-xor-with-an-element-from-array/README.md +++ b/problems/maximum-xor-with-an-element-from-array/README.md @@ -48,6 +48,7 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Trie](../../tag/trie/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/mean-of-array-after-removing-some-elements/README.md b/problems/mean-of-array-after-removing-some-elements/README.md index 35f9d41da..f87020608 100644 --- a/problems/mean-of-array-after-removing-some-elements/README.md +++ b/problems/mean-of-array-after-removing-some-elements/README.md @@ -63,6 +63,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/median-employee-salary/README.md b/problems/median-employee-salary/README.md index 67da590a3..e1416c6fb 100644 --- a/problems/median-employee-salary/README.md +++ b/problems/median-employee-salary/README.md @@ -11,45 +11,10 @@ ## [569. Median Employee Salary (Hard)](https://leetcode.com/problems/median-employee-salary "员工薪水中位数") -

    The Employee table holds all employees. The employee table has three columns: Employee Id, Company Name, and Salary.

    -
    -+-----+------------+--------+
    -|Id   | Company    | Salary |
    -+-----+------------+--------+
    -|1    | A          | 2341   |
    -|2    | A          | 341    |
    -|3    | A          | 15     |
    -|4    | A          | 15314  |
    -|5    | A          | 451    |
    -|6    | A          | 513    |
    -|7    | B          | 15     |
    -|8    | B          | 13     |
    -|9    | B          | 1154   |
    -|10   | B          | 1345   |
    -|11   | B          | 1221   |
    -|12   | B          | 234    |
    -|13   | C          | 2345   |
    -|14   | C          | 2645   |
    -|15   | C          | 2645   |
    -|16   | C          | 2652   |
    -|17   | C          | 65     |
    -+-----+------------+--------+
    -
    -

    Write a SQL query to find the median salary of each company. Bonus points if you can solve it without using any built-in SQL functions.

    - -
    -+-----+------------+--------+
    -|Id   | Company    | Salary |
    -+-----+------------+--------+
    -|5    | A          | 451    |
    -|6    | A          | 513    |
    -|12   | B          | 234    |
    -|9    | B          | 1154   |
    -|14   | C          | 2645   |
    -+-----+------------+--------+
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] ### Similar Questions 1. [Find Median Given Frequency of Numbers](../find-median-given-frequency-of-numbers) (Hard) diff --git a/problems/meeting-rooms-ii/README.md b/problems/meeting-rooms-ii/README.md index 4070e9afe..9010f4931 100644 --- a/problems/meeting-rooms-ii/README.md +++ b/problems/meeting-rooms-ii/README.md @@ -11,26 +11,14 @@ ## [253. Meeting Rooms II (Medium)](https://leetcode.com/problems/meeting-rooms-ii "会议室 II") -

    Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), find the minimum number of conference rooms required.

    -

    Example 1:

    - -
    -Input: [[0, 30],[5, 10],[15, 20]]
    -Output: 2
    - -

    Example 2:

    - -
    -Input: [[7,10],[2,4]]
    -Output: 1
    - -

    NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

    ### Related Topics - [[Heap](../../tag/heap/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Merge Intervals](../merge-intervals) (Medium) diff --git a/problems/meeting-rooms/README.md b/problems/meeting-rooms/README.md index c6a566afe..bcbfc704b 100644 --- a/problems/meeting-rooms/README.md +++ b/problems/meeting-rooms/README.md @@ -11,26 +11,11 @@ ## [252. Meeting Rooms (Easy)](https://leetcode.com/problems/meeting-rooms "会议室") -

    Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all meetings.

    -

    Example 1:

    - -
    -Input: [[0,30],[5,10],[15,20]]
    -Output: false
    -
    - -

    Example 2:

    - -
    -Input: [[7,10],[2,4]]
    -Output: true
    -
    - -

    NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

    ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Merge Intervals](../merge-intervals) (Medium) diff --git a/problems/meeting-scheduler/README.md b/problems/meeting-scheduler/README.md index 1bc07e1e8..7f8766aaf 100644 --- a/problems/meeting-scheduler/README.md +++ b/problems/meeting-scheduler/README.md @@ -11,45 +11,12 @@ ## [1229. Meeting Scheduler (Medium)](https://leetcode.com/problems/meeting-scheduler "安排会议日程") -

    Given the availability time slots arrays slots1 and slots2 of two people and a meeting duration duration, return the earliest time slot that works for both of them and is of duration duration.

    -

    If there is no common time slot that satisfies the requirements, return an empty array.

    - -

    The format of a time slot is an array of two elements [start, end] representing an inclusive time range from start to end.  

    - -

    It is guaranteed that no two availability slots of the same person intersect with each other. That is, for any two time slots [start1, end1] and [start2, end2] of the same person, either start1 > end2 or start2 > end1.

    - -

     

    -

    Example 1:

    - -
    -Input: slots1 = [[10,50],[60,120],[140,210]], slots2 = [[0,15],[60,70]], duration = 8
    -Output: [60,68]
    -
    - -

    Example 2:

    - -
    -Input: slots1 = [[10,50],[60,120],[140,210]], slots2 = [[0,15],[60,70]], duration = 12
    -Output: []
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= slots1.length, slots2.length <= 10^4
    • -
    • slots1[i].length, slots2[i].length == 2
    • -
    • slots1[i][0] < slots1[i][1]
    • -
    • slots2[i][0] < slots2[i][1]
    • -
    • 0 <= slots1[i][j], slots2[i][j] <= 10^9
    • -
    • 1 <= duration <= 10^6 
    • -
    ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] - [[Line Sweep](../../tag/line-sweep/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/merge-intervals/README.md b/problems/merge-intervals/README.md index 587507d88..38bf97a47 100644 --- a/problems/merge-intervals/README.md +++ b/problems/merge-intervals/README.md @@ -40,8 +40,8 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Insert Interval](../insert-interval) (Medium) diff --git a/problems/merge-k-sorted-lists/README.md b/problems/merge-k-sorted-lists/README.md index ea4200897..9f1521f9e 100644 --- a/problems/merge-k-sorted-lists/README.md +++ b/problems/merge-k-sorted-lists/README.md @@ -58,9 +58,10 @@ merging them into one sorted list: ### Related Topics - [[Heap](../../tag/heap/README.md)] [[Linked List](../../tag/linked-list/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Merge Sort](../../tag/merge-sort/README.md)] ### Similar Questions 1. [Merge Two Sorted Lists](../merge-two-sorted-lists) (Easy) diff --git a/problems/merge-sorted-array/README.md b/problems/merge-sorted-array/README.md index 4389541cf..8c50685d3 100644 --- a/problems/merge-sorted-array/README.md +++ b/problems/merge-sorted-array/README.md @@ -63,6 +63,7 @@ Note that because m = 0, there are no elements in nums1. The 0 is only there to ### Related Topics [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Merge Two Sorted Lists](../merge-two-sorted-lists) (Easy) diff --git a/problems/merge-strings-alternately/README.md b/problems/merge-strings-alternately/README.md index 649329a07..dc54e2d06 100644 --- a/problems/merge-strings-alternately/README.md +++ b/problems/merge-strings-alternately/README.md @@ -58,6 +58,7 @@ merged: a p b q c d ### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/merge-triplets-to-form-target-triplet/README.md b/problems/merge-triplets-to-form-target-triplet/README.md new file mode 100644 index 000000000..510475f65 --- /dev/null +++ b/problems/merge-triplets-to-form-target-triplet/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../maximum-number-of-removable-characters "Maximum Number of Removable Characters") +                 +[Next >](../the-earliest-and-latest-rounds-where-players-compete "The Earliest and Latest Rounds Where Players Compete") + +## [1899. Merge Triplets to Form Target Triplet (Medium)](https://leetcode.com/problems/merge-triplets-to-form-target-triplet "合并若干三元组以形成目标三元组") + +

    A triplet is an array of three integers. You are given a 2D integer array triplets, where triplets[i] = [ai, bi, ci] describes the ith triplet. You are also given an integer array target = [x, y, z] that describes the triplet you want to obtain.

    + +

    To obtain target, you may apply the following operation on triplets any number of times (possibly zero):

    + +
      +
    • Choose two indices (0-indexed) i and j (i != j) and update triplets[j] to become [max(ai, aj), max(bi, bj), max(ci, cj)]. +
        +
      • For example, if triplets[i] = [2, 5, 3] and triplets[j] = [1, 7, 5], triplets[j] will be updated to [max(2, 1), max(5, 7), max(3, 5)] = [2, 7, 5].
      • +
      +
    • +
    + +

    Return true if it is possible to obtain the target triplet [x, y, z] as an element of triplets, or false otherwise.

    + +

     

    +

    Example 1:

    + +
    +Input: triplets = [[2,5,3],[1,8,4],[1,7,5]], target = [2,7,5]
    +Output: true
    +Explanation: Perform the following operations:
    +- Choose the first and last triplets [[2,5,3],[1,8,4],[1,7,5]]. Update the last triplet to be [max(2,1), max(5,7), max(3,5)] = [2,7,5]. triplets = [[2,5,3],[1,8,4],[2,7,5]]
    +The target triplet [2,7,5] is now an element of triplets.
    +
    + +

    Example 2:

    + +
    +Input: triplets = [[1,3,4],[2,5,8]], target = [2,5,8]
    +Output: true
    +Explanation: The target triplet [2,5,8] is already an element of triplets.
    +
    + +

    Example 3:

    + +
    +Input: triplets = [[2,5,3],[2,3,4],[1,2,5],[5,2,3]], target = [5,5,5]
    +Output: true
    +Explanation: Perform the following operations:
    +- Choose the first and third triplets [[2,5,3],[2,3,4],[1,2,5],[5,2,3]]. Update the third triplet to be [max(2,1), max(5,2), max(3,5)] = [2,5,5]. triplets = [[2,5,3],[2,3,4],[2,5,5],[5,2,3]].
    +- Choose the third and fourth triplets [[2,5,3],[2,3,4],[2,5,5],[5,2,3]]. Update the fourth triplet to be [max(2,5), max(5,2), max(5,3)] = [5,5,5]. triplets = [[2,5,3],[2,3,4],[2,5,5],[5,5,5]].
    +The target triplet [5,5,5] is now an element of triplets.
    +
    + +

    Example 4:

    + +
    +Input: triplets = [[3,4,5],[4,5,6]], target = [3,2,5]
    +Output: false
    +Explanation: It is impossible to have [3,2,5] as an element because there is no 2 in any of the triplets.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= triplets.length <= 105
    • +
    • triplets[i].length == target.length == 3
    • +
    • 1 <= ai, bi, ci, x, y, z <= 1000
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Which triplets do you actually care about? +
    + +
    +Hint 2 +What property of max can you use to solve the problem? +
    diff --git a/problems/merge-two-binary-trees/README.md b/problems/merge-two-binary-trees/README.md index c90fcfc5e..3419dd720 100644 --- a/problems/merge-two-binary-trees/README.md +++ b/problems/merge-two-binary-trees/README.md @@ -44,3 +44,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/middle-of-the-linked-list/README.md b/problems/middle-of-the-linked-list/README.md index 6b2f44165..3ac935c09 100644 --- a/problems/middle-of-the-linked-list/README.md +++ b/problems/middle-of-the-linked-list/README.md @@ -49,3 +49,4 @@ Since the list has two middle nodes with values 3 and 4, we return the second on ### Related Topics [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/min-cost-to-connect-all-points/README.md b/problems/min-cost-to-connect-all-points/README.md index 37856ebc4..9000431ca 100644 --- a/problems/min-cost-to-connect-all-points/README.md +++ b/problems/min-cost-to-connect-all-points/README.md @@ -70,6 +70,8 @@ Notice that there is a unique path between every pair of points. ### Related Topics [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] + [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] ### Hints
    diff --git a/problems/minesweeper/README.md b/problems/minesweeper/README.md index d52162746..9b7ee8f6a 100644 --- a/problems/minesweeper/README.md +++ b/problems/minesweeper/README.md @@ -58,11 +58,13 @@
  • 1 <= m, n <= 50
  • board[i][j] is either 'M', 'E', 'B', or a digit from '1' to '8'.
  • click.length == 2
  • -
  • 0 <= clickr <= m
  • -
  • 0 <= clickc <= n
  • +
  • 0 <= clickr < m
  • +
  • 0 <= clickc < n
  • board[clickr][clickc] is either 'M' or 'E'.
  • ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/mini-parser/README.md b/problems/mini-parser/README.md index 2ab07f484..02e680462 100644 --- a/problems/mini-parser/README.md +++ b/problems/mini-parser/README.md @@ -48,6 +48,7 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/minimize-deviation-in-array/README.md b/problems/minimize-deviation-in-array/README.md index 92c4cd234..59de5ccf4 100644 --- a/problems/minimize-deviation-in-array/README.md +++ b/problems/minimize-deviation-in-array/README.md @@ -66,8 +66,10 @@ ### Related Topics - [[Heap](../../tag/heap/README.md)] - [[Ordered Map](../../tag/ordered-map/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/minimize-hamming-distance-after-swap-operations/README.md b/problems/minimize-hamming-distance-after-swap-operations/README.md index 8149d9665..2e92aaeec 100644 --- a/problems/minimize-hamming-distance-after-swap-operations/README.md +++ b/problems/minimize-hamming-distance-after-swap-operations/README.md @@ -59,9 +59,9 @@ The Hamming distance of source and target is 2 as they differ in 2 positions: in ### Related Topics - [[Greedy](../../tag/greedy/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/minimize-malware-spread-ii/README.md b/problems/minimize-malware-spread-ii/README.md index f150f2105..47e6e4f6d 100644 --- a/problems/minimize-malware-spread-ii/README.md +++ b/problems/minimize-malware-spread-ii/README.md @@ -48,6 +48,8 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/minimize-malware-spread/README.md b/problems/minimize-malware-spread/README.md index b55400056..d2c1090d5 100644 --- a/problems/minimize-malware-spread/README.md +++ b/problems/minimize-malware-spread/README.md @@ -48,5 +48,8 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/minimize-max-distance-to-gas-station/README.md b/problems/minimize-max-distance-to-gas-station/README.md index d2187464a..919914c78 100644 --- a/problems/minimize-max-distance-to-gas-station/README.md +++ b/problems/minimize-max-distance-to-gas-station/README.md @@ -11,29 +11,10 @@ ## [774. Minimize Max Distance to Gas Station (Hard)](https://leetcode.com/problems/minimize-max-distance-to-gas-station "最小化去加油站的最大距离") -

    On a horizontal number line, we have gas stations at positions stations[0], stations[1], ..., stations[N-1], where N = stations.length.

    -

    Now, we add K more gas stations so that D, the maximum distance between adjacent gas stations, is minimized.

    - -

    Return the smallest possible value of D.

    - -

    Example:

    - -
    -Input: stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], K = 9
    -Output: 0.500000
    -
    - -

    Note:

    - -
      -
    1. stations.length will be an integer in range [10, 2000].
    2. -
    3. stations[i] will be an integer in range [0, 10^8].
    4. -
    5. K will be an integer in range [1, 10^6].
    6. -
    7. Answers within 10^-6 of the true value will be accepted as correct.
    8. -
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions diff --git a/problems/minimize-maximum-pair-sum-in-array/README.md b/problems/minimize-maximum-pair-sum-in-array/README.md index 174d6d3d6..8722e266c 100644 --- a/problems/minimize-maximum-pair-sum-in-array/README.md +++ b/problems/minimize-maximum-pair-sum-in-array/README.md @@ -57,7 +57,9 @@ The maximum pair sum is max(3+5, 4+4, 6+2) = max(8, 8, 8) = 8. ### Related Topics [[Greedy](../../tag/greedy/README.md)] - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/minimize-product-sum-of-two-arrays/README.md b/problems/minimize-product-sum-of-two-arrays/README.md index 5610cec02..1cd2fb9c5 100644 --- a/problems/minimize-product-sum-of-two-arrays/README.md +++ b/problems/minimize-product-sum-of-two-arrays/README.md @@ -9,12 +9,14 @@                  [Next >](../group-employees-of-the-same-salary "Group Employees of the Same Salary") -## [1874. Minimize Product Sum of Two Arrays (Medium)](https://leetcode.com/problems/minimize-product-sum-of-two-arrays "") +## [1874. Minimize Product Sum of Two Arrays (Medium)](https://leetcode.com/problems/minimize-product-sum-of-two-arrays "两个数组的最小乘积和") ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/minimize-rounding-error-to-meet-target/README.md b/problems/minimize-rounding-error-to-meet-target/README.md index 1fa02d885..39df68727 100644 --- a/problems/minimize-rounding-error-to-meet-target/README.md +++ b/problems/minimize-rounding-error-to-meet-target/README.md @@ -11,44 +11,13 @@ ## [1058. Minimize Rounding Error to Meet Target (Medium)](https://leetcode.com/problems/minimize-rounding-error-to-meet-target "最小化舍入误差以满足目标") -

    Given an array of prices [p1,p2...,pn] and a target, round each price pi to Roundi(pi) so that the rounded array [Round1(p1),Round2(p2)...,Roundn(pn)] sums to the given target. Each operation Roundi(pi) could be either Floor(pi) or Ceil(pi).

    -

    Return the string "-1" if the rounded array is impossible to sum to target. Otherwise, return the smallest rounding error, which is defined as Σ |Roundi(pi) - (pi)| for i from 1 to n, as a string with three places after the decimal.

    - -

     

    - -

    Example 1:

    - -
    -Input: prices = ["0.700","2.800","4.900"], target = 8
    -Output: "1.000"
    -Explanation: 
    -Use Floor, Ceil and Ceil operations to get (0.7 - 0) + (3 - 2.8) + (5 - 4.9) = 0.7 + 0.2 + 0.1 = 1.0 .
    -
    - -

    Example 2:

    - -
    -Input: prices = ["1.500","2.500","3.500"], target = 10
    -Output: "-1"
    -Explanation: 
    -It is impossible to meet the target.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= prices.length <= 500.
    2. -
    3. Each string of prices prices[i] represents a real number which is between 0 and 1000 and has exactly 3 decimal places.
    4. -
    5. target is between 0 and 1000000.
    6. -
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/minimum-absolute-difference-in-bst/README.md b/problems/minimum-absolute-difference-in-bst/README.md index 01b1d0f86..ea4f41eb3 100644 --- a/problems/minimum-absolute-difference-in-bst/README.md +++ b/problems/minimum-absolute-difference-in-bst/README.md @@ -41,6 +41,10 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [K-diff Pairs in an Array](../k-diff-pairs-in-an-array) (Medium) diff --git a/problems/minimum-absolute-difference-queries/README.md b/problems/minimum-absolute-difference-queries/README.md new file mode 100644 index 000000000..e7ef7ed6a --- /dev/null +++ b/problems/minimum-absolute-difference-queries/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../count-sub-islands "Count Sub Islands") +                 +[Next >](../count-salary-categories "Count Salary Categories") + +## [1906. Minimum Absolute Difference Queries (Medium)](https://leetcode.com/problems/minimum-absolute-difference-queries "查询差绝对值的最小值") + +

    The minimum absolute difference of an array a is defined as the minimum value of |a[i] - a[j]|, where 0 <= i < j < a.length and a[i] != a[j]. If all elements of a are the same, the minimum absolute difference is -1.

    + +
      +
    • For example, the minimum absolute difference of the array [5,2,3,7,2] is |2 - 3| = 1. Note that it is not 0 because a[i] and a[j] must be different.
    • +
    + +

    You are given an integer array nums and the array queries where queries[i] = [li, ri]. For each query i, compute the minimum absolute difference of the subarray nums[li...ri] containing the elements of nums between the 0-based indices li and ri (inclusive).

    + +

    Return an array ans where ans[i] is the answer to the ith query.

    + +

    A subarray is a contiguous sequence of elements in an array.

    + +

    The value of |x| is defined as:

    + +
      +
    • x if x >= 0.
    • +
    • -x if x < 0.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,3,4,8], queries = [[0,1],[1,2],[2,3],[0,3]]
    +Output: [2,1,4,1]
    +Explanation: The queries are processed as follows:
    +- queries[0] = [0,1]: The subarray is [1,3] and the minimum absolute difference is |1-3| = 2.
    +- queries[1] = [1,2]: The subarray is [3,4] and the minimum absolute difference is |3-4| = 1.
    +- queries[2] = [2,3]: The subarray is [4,8] and the minimum absolute difference is |4-8| = 4.
    +- queries[3] = [0,3]: The subarray is [1,3,4,8] and the minimum absolute difference is |3-4| = 1.
    +
    + +

    Example 2:

    + +
    +Input: nums = [4,5,2,2,7,10], queries = [[2,3],[0,2],[0,5],[3,5]]
    +Output: [-1,1,1,3]
    +Explanation: The queries are processed as follows:
    +- queries[0] = [2,3]: The subarray is [2,2] and the minimum absolute difference is -1 because all the
    +  elements are the same.
    +- queries[1] = [0,2]: The subarray is [4,5,2] and the minimum absolute difference is |4-5| = 1.
    +- queries[2] = [0,5]: The subarray is [4,5,2,2,7,10] and the minimum absolute difference is |4-5| = 1.
    +- queries[3] = [3,5]: The subarray is [2,7,10] and the minimum absolute difference is |7-10| = 3.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 100
    • +
    • 1 <= queries.length <= 2 * 104
    • +
    • 0 <= li < ri < nums.length
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +How does the maximum value being 100 help us? +
    + +
    +Hint 2 +How can we tell if a number exists in a given range? +
    diff --git a/problems/minimum-absolute-difference/README.md b/problems/minimum-absolute-difference/README.md index 316cff22b..58e0d2f6b 100644 --- a/problems/minimum-absolute-difference/README.md +++ b/problems/minimum-absolute-difference/README.md @@ -53,6 +53,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/minimum-absolute-sum-difference/README.md b/problems/minimum-absolute-sum-difference/README.md index 6c6473f62..561cb0971 100644 --- a/problems/minimum-absolute-sum-difference/README.md +++ b/problems/minimum-absolute-sum-difference/README.md @@ -68,7 +68,9 @@ This yields an absolute sum difference of |10-9| + |10-3| + |4-5| + |4-1| ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Hints
    diff --git a/problems/minimum-add-to-make-parentheses-valid/README.md b/problems/minimum-add-to-make-parentheses-valid/README.md index f233fc353..792dae379 100644 --- a/problems/minimum-add-to-make-parentheses-valid/README.md +++ b/problems/minimum-add-to-make-parentheses-valid/README.md @@ -78,3 +78,4 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md b/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md index 41faceb26..860cd1ae1 100644 --- a/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md +++ b/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md @@ -50,7 +50,10 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/README.md b/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/README.md index c84211f22..5866154fc 100644 --- a/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/README.md +++ b/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/README.md @@ -73,6 +73,7 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/minimum-area-rectangle-ii/README.md b/problems/minimum-area-rectangle-ii/README.md index add0abfb5..56f0bbfab 100644 --- a/problems/minimum-area-rectangle-ii/README.md +++ b/problems/minimum-area-rectangle-ii/README.md @@ -77,4 +77,5 @@ ### Related Topics [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/minimum-area-rectangle/README.md b/problems/minimum-area-rectangle/README.md index cba1ba034..b82ae1d30 100644 --- a/problems/minimum-area-rectangle/README.md +++ b/problems/minimum-area-rectangle/README.md @@ -47,4 +47,8 @@
    ### Related Topics + [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/minimum-ascii-delete-sum-for-two-strings/README.md b/problems/minimum-ascii-delete-sum-for-two-strings/README.md index 824a2cba9..715c4728e 100644 --- a/problems/minimum-ascii-delete-sum-for-two-strings/README.md +++ b/problems/minimum-ascii-delete-sum-for-two-strings/README.md @@ -45,6 +45,7 @@ If instead we turned both strings into "lee" or "eet", we wo ### Related Topics + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/minimum-changes-to-make-alternating-binary-string/README.md b/problems/minimum-changes-to-make-alternating-binary-string/README.md index b5c8bb806..af16901e6 100644 --- a/problems/minimum-changes-to-make-alternating-binary-string/README.md +++ b/problems/minimum-changes-to-make-alternating-binary-string/README.md @@ -51,8 +51,7 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] - [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/minimum-cost-for-tickets/README.md b/problems/minimum-cost-for-tickets/README.md index 9e6b5bfb8..6e7b201c6 100644 --- a/problems/minimum-cost-for-tickets/README.md +++ b/problems/minimum-cost-for-tickets/README.md @@ -65,6 +65,7 @@ In total, you spent $17 and covered all the days of your travel. ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/minimum-cost-to-change-the-final-value-of-expression/README.md b/problems/minimum-cost-to-change-the-final-value-of-expression/README.md new file mode 100644 index 000000000..6cc6f3d6c --- /dev/null +++ b/problems/minimum-cost-to-change-the-final-value-of-expression/README.md @@ -0,0 +1,89 @@ + + + + + + + +[< Previous](../largest-magic-square "Largest Magic Square") +                 +[Next >](../redistribute-characters-to-make-all-strings-equal "Redistribute Characters to Make All Strings Equal") + +## [1896. Minimum Cost to Change the Final Value of Expression (Hard)](https://leetcode.com/problems/minimum-cost-to-change-the-final-value-of-expression "反转表达式值的最少操作次数") + +

    You are given a valid boolean expression as a string expression consisting of the characters '1','0','&' (bitwise AND operator),'|' (bitwise OR operator),'(', and ')'.

    + +
      +
    • For example, "()1|1" and "(1)&()" are not valid while "1", "(((1))|(0))", and "1|(0&(1))" are valid expressions.
    • +
    + +

    Return the minimum cost to change the final value of the expression.

    + +
      +
    • For example, if expression = "1|1|(0&0)&1", its value is 1|1|(0&0)&1 = 1|1|0&1 = 1|0&1 = 1&1 = 1. We want to apply operations so that the new expression evaluates to 0.
    • +
    + +

    The cost of changing the final value of an expression is the number of operations performed on the expression. The types of operations are described as follows:

    + +
      +
    • Turn a '1' into a '0'.
    • +
    • Turn a '0' into a '1'.
    • +
    • Turn a '&' into a '|'.
    • +
    • Turn a '|' into a '&'.
    • +
    + +

    Note: '&' does not take precedence over '|' in the order of calculation. Evaluate parentheses first, then in left-to-right order.

    + +

     

    +

    Example 1:

    + +
    +Input: expression = "1&(0|1)"
    +Output: 1
    +Explanation: We can turn "1&(0|1)" into "1&(0&1)" by changing the '|' to a '&' using 1 operation.
    +The new expression evaluates to 0. 
    +
    + +

    Example 2:

    + +
    +Input: expression = "(0&0)&(0&0&0)"
    +Output: 3
    +Explanation: We can turn "(0&0)&(0&0&0)" into "(0|1)|(0&0&0)" using 3 operations.
    +The new expression evaluates to 1.
    +
    + +

    Example 3:

    + +
    +Input: expression = "(0|(1|0&1))"
    +Output: 1
    +Explanation: We can turn "(0|(1|0&1))" into "(0|(0|0&1))" using 1 operation.
    +The new expression evaluates to 0.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= expression.length <= 105
    • +
    • expression only contains '1','0','&','|','(', and ')'
    • +
    • All parentheses are properly matched.
    • +
    • There will be no empty parentheses (i.e: "()" is not a substring of expression).
    • +
    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +How many possible states are there for a given expression? +
    + +
    +Hint 2 +Is there a data structure that we can use to solve the problem optimally? +
    diff --git a/problems/minimum-cost-to-connect-sticks/README.md b/problems/minimum-cost-to-connect-sticks/README.md index eb1202625..49b7b3a65 100644 --- a/problems/minimum-cost-to-connect-sticks/README.md +++ b/problems/minimum-cost-to-connect-sticks/README.md @@ -11,30 +11,12 @@ ## [1167. Minimum Cost to Connect Sticks (Medium)](https://leetcode.com/problems/minimum-cost-to-connect-sticks "连接棒材的最低费用") -

    You have some sticks with positive integer lengths.

    -

    You can connect any two sticks of lengths X and Y into one stick by paying a cost of X + Y.  You perform this action until there is one stick remaining.

    - -

    Return the minimum cost of connecting all the given sticks into one stick in this way.

    - -

     

    -

    Example 1:

    -
    Input: sticks = [2,4,3]
    -Output: 14
    -

    Example 2:

    -
    Input: sticks = [1,8,3,5]
    -Output: 30
    -
    -

     

    -

    Constraints:

    - -
      -
    • 1 <= sticks.length <= 10^4
    • -
    • 1 <= sticks[i] <= 10^4
    • -
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Minimum Cost to Merge Stones](../minimum-cost-to-merge-stones) (Hard) diff --git a/problems/minimum-cost-to-connect-two-groups-of-points/README.md b/problems/minimum-cost-to-connect-two-groups-of-points/README.md index 5ffa57040..cc6a19f95 100644 --- a/problems/minimum-cost-to-connect-two-groups-of-points/README.md +++ b/problems/minimum-cost-to-connect-two-groups-of-points/README.md @@ -62,8 +62,11 @@ Note that there are multiple points connected to point 2 in the first group and ### Related Topics - [[Graph](../../tag/graph/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/minimum-cost-to-cut-a-stick/README.md b/problems/minimum-cost-to-cut-a-stick/README.md index fee9eddb9..2c0ac95df 100644 --- a/problems/minimum-cost-to-cut-a-stick/README.md +++ b/problems/minimum-cost-to-cut-a-stick/README.md @@ -52,6 +52,7 @@ There are much ordering with total cost <= 25, for example, the order [4, 6, ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/minimum-cost-to-hire-k-workers/README.md b/problems/minimum-cost-to-hire-k-workers/README.md index c8a10cea3..8514710a9 100644 --- a/problems/minimum-cost-to-hire-k-workers/README.md +++ b/problems/minimum-cost-to-hire-k-workers/README.md @@ -59,4 +59,7 @@ ### Related Topics - [[Heap](../../tag/heap/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/README.md b/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/README.md index 86f4c2a97..3a3ecc6b7 100644 --- a/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/README.md +++ b/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/README.md @@ -77,7 +77,12 @@ The total cost = 3. ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/minimum-cost-to-merge-stones/README.md b/problems/minimum-cost-to-merge-stones/README.md index 72606513c..da1b34bf4 100644 --- a/problems/minimum-cost-to-merge-stones/README.md +++ b/problems/minimum-cost-to-merge-stones/README.md @@ -60,6 +60,7 @@ The total cost was 25, and this is the minimum possible. ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/minimum-cost-tree-from-leaf-values/README.md b/problems/minimum-cost-tree-from-leaf-values/README.md index 620805ee6..1360f4ad5 100644 --- a/problems/minimum-cost-tree-from-leaf-values/README.md +++ b/problems/minimum-cost-tree-from-leaf-values/README.md @@ -48,8 +48,9 @@ There are two possible trees. The first has non-leaf node sum 36, and the secon ### Related Topics [[Stack](../../tag/stack/README.md)] - [[Tree](../../tag/tree/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints
    diff --git a/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md b/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md index 1f031cedb..8f02e64a0 100644 --- a/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md +++ b/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md @@ -54,6 +54,9 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/minimum-deletions-to-make-character-frequencies-unique/README.md b/problems/minimum-deletions-to-make-character-frequencies-unique/README.md index e73019275..c1ab8ee8a 100644 --- a/problems/minimum-deletions-to-make-character-frequencies-unique/README.md +++ b/problems/minimum-deletions-to-make-character-frequencies-unique/README.md @@ -53,7 +53,8 @@ Note that we only care about characters that are still in the string at the end ### Related Topics [[Greedy](../../tag/greedy/README.md)] - [[Sort](../../tag/sort/README.md)] + [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/minimum-deletions-to-make-string-balanced/README.md b/problems/minimum-deletions-to-make-string-balanced/README.md index 3a1f549b6..8db9ec049 100644 --- a/problems/minimum-deletions-to-make-string-balanced/README.md +++ b/problems/minimum-deletions-to-make-string-balanced/README.md @@ -45,8 +45,9 @@ Delete the characters at 0-indexed positions 3 and 6 ("aababba ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Stack](../../tag/stack/README.md)] [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/minimum-depth-of-binary-tree/README.md b/problems/minimum-depth-of-binary-tree/README.md index 8f8be211b..e24eb7705 100644 --- a/problems/minimum-depth-of-binary-tree/README.md +++ b/problems/minimum-depth-of-binary-tree/README.md @@ -42,8 +42,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Binary Tree Level Order Traversal](../binary-tree-level-order-traversal) (Medium) diff --git a/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md b/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md index 3e96564df..c97912c97 100644 --- a/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md +++ b/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md @@ -56,8 +56,9 @@ The difference between the maximum and minimum is 1-0 = 1. ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/minimum-difficulty-of-a-job-schedule/README.md b/problems/minimum-difficulty-of-a-job-schedule/README.md index d45e64349..d017de816 100644 --- a/problems/minimum-difficulty-of-a-job-schedule/README.md +++ b/problems/minimum-difficulty-of-a-job-schedule/README.md @@ -70,6 +70,7 @@ The difficulty of the schedule = 6 + 1 = 7 ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/minimum-distance-between-bst-nodes/README.md b/problems/minimum-distance-between-bst-nodes/README.md index 8e90bc13f..04b89d3e6 100644 --- a/problems/minimum-distance-between-bst-nodes/README.md +++ b/problems/minimum-distance-between-bst-nodes/README.md @@ -41,8 +41,10 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Recursion](../../tag/recursion/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Easy) diff --git a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md index eb6bc852e..5c177ce01 100644 --- a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md +++ b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md @@ -72,6 +72,7 @@ Total distance = 6 ### Related Topics + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/minimum-elements-to-add-to-form-a-given-sum/README.md b/problems/minimum-elements-to-add-to-form-a-given-sum/README.md index 2bf45ea82..cb2567cc7 100644 --- a/problems/minimum-elements-to-add-to-form-a-given-sum/README.md +++ b/problems/minimum-elements-to-add-to-form-a-given-sum/README.md @@ -45,6 +45,7 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/minimum-factorization/README.md b/problems/minimum-factorization/README.md index 86bb32c98..bb838c730 100644 --- a/problems/minimum-factorization/README.md +++ b/problems/minimum-factorization/README.md @@ -11,28 +11,8 @@ ## [625. Minimum Factorization (Medium)](https://leetcode.com/problems/minimum-factorization "最小因式分解") -

    Given a positive integer a, find the smallest positive integer b whose multiplication of each digit equals to a.

    -

    -If there is no answer or the answer is not fit in 32-bit signed integer, then return 0.

    - -

    -Example 1
    -Input: -

    48 
    -Output: -
    68
    -

    - -

    -Example 2
    -Input: -

    15
    - -Output: -
    35
    -

    ### Related Topics - [[Recursion](../../tag/recursion/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/minimum-falling-path-sum-ii/README.md b/problems/minimum-falling-path-sum-ii/README.md index 8c006aab0..02940f388 100644 --- a/problems/minimum-falling-path-sum-ii/README.md +++ b/problems/minimum-falling-path-sum-ii/README.md @@ -38,7 +38,9 @@ The falling path with the smallest sum is [1,5,7], so the answer is 13 ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/minimum-falling-path-sum/README.md b/problems/minimum-falling-path-sum/README.md index 61ac1658f..9b36ac783 100644 --- a/problems/minimum-falling-path-sum/README.md +++ b/problems/minimum-falling-path-sum/README.md @@ -55,4 +55,6 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/minimum-genetic-mutation/README.md b/problems/minimum-genetic-mutation/README.md index ad49558bf..906685cc7 100644 --- a/problems/minimum-genetic-mutation/README.md +++ b/problems/minimum-genetic-mutation/README.md @@ -58,5 +58,10 @@
  • start, end, and bank[i] consist of only the characters ['A', 'C', 'G', 'T'].
  • +### Related Topics + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + ### Similar Questions 1. [Word Ladder](../word-ladder) (Hard) diff --git a/problems/minimum-height-trees/README.md b/problems/minimum-height-trees/README.md index 633678fcb..0a7354288 100644 --- a/problems/minimum-height-trees/README.md +++ b/problems/minimum-height-trees/README.md @@ -62,8 +62,10 @@ ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] ### Similar Questions 1. [Course Schedule](../course-schedule) (Medium) diff --git a/problems/minimum-incompatibility/README.md b/problems/minimum-incompatibility/README.md index b947ec41c..7dbfed95f 100644 --- a/problems/minimum-incompatibility/README.md +++ b/problems/minimum-incompatibility/README.md @@ -56,8 +56,10 @@ The incompatibility is (2-1) + (3-2) + (8-6) + (3-1) = 6. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] - [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/minimum-increment-to-make-array-unique/README.md b/problems/minimum-increment-to-make-array-unique/README.md index df253ad32..c14fba412 100644 --- a/problems/minimum-increment-to-make-array-unique/README.md +++ b/problems/minimum-increment-to-make-array-unique/README.md @@ -50,4 +50,7 @@ It can be shown with 5 or less moves that it is impossible for the array to have ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/minimum-index-sum-of-two-lists/README.md b/problems/minimum-index-sum-of-two-lists/README.md index 92c64dbd8..c8c570aa8 100644 --- a/problems/minimum-index-sum-of-two-lists/README.md +++ b/problems/minimum-index-sum-of-two-lists/README.md @@ -65,7 +65,9 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Intersection of Two Linked Lists](../intersection-of-two-linked-lists) (Easy) diff --git a/problems/minimum-initial-energy-to-finish-tasks/README.md b/problems/minimum-initial-energy-to-finish-tasks/README.md index 7c836fbe7..ee29ca74f 100644 --- a/problems/minimum-initial-energy-to-finish-tasks/README.md +++ b/problems/minimum-initial-energy-to-finish-tasks/README.md @@ -75,6 +75,8 @@ Starting with 27 energy, we finish the tasks in the following order: ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md b/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md index 2dfd15089..03ff464ad 100644 --- a/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md +++ b/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md @@ -65,6 +65,7 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/minimum-insertions-to-balance-a-parentheses-string/README.md b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md index 5a740a59e..540c98995 100644 --- a/problems/minimum-insertions-to-balance-a-parentheses-string/README.md +++ b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md @@ -77,6 +77,7 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/minimum-interval-to-include-each-query/README.md b/problems/minimum-interval-to-include-each-query/README.md index 051d04d73..df5948a15 100644 --- a/problems/minimum-interval-to-include-each-query/README.md +++ b/problems/minimum-interval-to-include-each-query/README.md @@ -54,7 +54,11 @@ ### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] [[Line Sweep](../../tag/line-sweep/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/minimum-jumps-to-reach-home/README.md b/problems/minimum-jumps-to-reach-home/README.md index a1f96b45a..86c939c0f 100644 --- a/problems/minimum-jumps-to-reach-home/README.md +++ b/problems/minimum-jumps-to-reach-home/README.md @@ -62,7 +62,8 @@ ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/minimum-knight-moves/README.md b/problems/minimum-knight-moves/README.md index 0b43fe231..36b8ed532 100644 --- a/problems/minimum-knight-moves/README.md +++ b/problems/minimum-knight-moves/README.md @@ -11,40 +11,10 @@ ## [1197. Minimum Knight Moves (Medium)](https://leetcode.com/problems/minimum-knight-moves "进击的骑士") -

    In an infinite chess board with coordinates from -infinity to +infinity, you have a knight at square [0, 0].

    -

    A knight has 8 possible moves it can make, as illustrated below. Each move is two squares in a cardinal direction, then one square in an orthogonal direction.

    - -

    - -

    Return the minimum number of steps needed to move the knight to the square [x, y].  It is guaranteed the answer exists.

    - -

     

    -

    Example 1:

    - -
    -Input: x = 2, y = 1
    -Output: 1
    -Explanation: [0, 0] → [2, 1]
    -
    - -

    Example 2:

    - -
    -Input: x = 5, y = 5
    -Output: 4
    -Explanation: [0, 0] → [2, 1] → [4, 2] → [3, 4] → [5, 5]
    -
    - -

     

    -

    Constraints:

    - -
      -
    • |x| + |y| <= 300
    • -
    ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Hints
    diff --git a/problems/minimum-length-of-string-after-deleting-similar-ends/README.md b/problems/minimum-length-of-string-after-deleting-similar-ends/README.md index 9778661bb..6bad2b22e 100644 --- a/problems/minimum-length-of-string-after-deleting-similar-ends/README.md +++ b/problems/minimum-length-of-string-after-deleting-similar-ends/README.md @@ -63,6 +63,7 @@ ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/minimum-limit-of-balls-in-a-bag/README.md b/problems/minimum-limit-of-balls-in-a-bag/README.md index bfeefb85f..166ebf7fe 100644 --- a/problems/minimum-limit-of-balls-in-a-bag/README.md +++ b/problems/minimum-limit-of-balls-in-a-bag/README.md @@ -68,7 +68,7 @@ The bag with the most number of balls has 2 balls, so your penalty is 2 an you s ### Related Topics - [[Heap](../../tag/heap/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] ### Hints diff --git a/problems/minimum-moves-to-equal-array-elements-ii/README.md b/problems/minimum-moves-to-equal-array-elements-ii/README.md index 341e6ac9b..6b7d83e00 100644 --- a/problems/minimum-moves-to-equal-array-elements-ii/README.md +++ b/problems/minimum-moves-to-equal-array-elements-ii/README.md @@ -45,7 +45,9 @@ Only two moves are needed (remember each move increments or decrements one eleme ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Best Meeting Point](../best-meeting-point) (Hard) diff --git a/problems/minimum-moves-to-equal-array-elements/README.md b/problems/minimum-moves-to-equal-array-elements/README.md index 2c359c15c..c1d2c38a3 100644 --- a/problems/minimum-moves-to-equal-array-elements/README.md +++ b/problems/minimum-moves-to-equal-array-elements/README.md @@ -43,6 +43,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] ### Similar Questions diff --git a/problems/minimum-moves-to-make-array-complementary/README.md b/problems/minimum-moves-to-make-array-complementary/README.md index 64677afeb..23c4443a6 100644 --- a/problems/minimum-moves-to-make-array-complementary/README.md +++ b/problems/minimum-moves-to-make-array-complementary/README.md @@ -58,7 +58,9 @@ Therefore, nums[i] + nums[n-1-i] = 4 for every i, so nums is complementary. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md b/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md index 0937eb1f3..a49c6f701 100644 --- a/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md +++ b/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md @@ -90,7 +90,10 @@ ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/minimum-moves-to-reach-target-with-rotations/README.md b/problems/minimum-moves-to-reach-target-with-rotations/README.md index ca126f85c..afdb6a02c 100644 --- a/problems/minimum-moves-to-reach-target-with-rotations/README.md +++ b/problems/minimum-moves-to-reach-target-with-rotations/README.md @@ -67,7 +67,9 @@ ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/minimum-number-of-arrows-to-burst-balloons/README.md b/problems/minimum-number-of-arrows-to-burst-balloons/README.md index 3777c4115..71946c8d5 100644 --- a/problems/minimum-number-of-arrows-to-burst-balloons/README.md +++ b/problems/minimum-number-of-arrows-to-burst-balloons/README.md @@ -51,7 +51,8 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Meeting Rooms II](../meeting-rooms-ii) (Medium) diff --git a/problems/minimum-number-of-days-to-disconnect-island/README.md b/problems/minimum-number-of-days-to-disconnect-island/README.md index a08336a51..0031b010e 100644 --- a/problems/minimum-number-of-days-to-disconnect-island/README.md +++ b/problems/minimum-number-of-days-to-disconnect-island/README.md @@ -75,7 +75,11 @@ Change land grid[1][1] and grid[0][2] to water and get 2 disconnected island. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Strongly Connected Component](../../tag/strongly-connected-component/README.md)] ### Hints
    diff --git a/problems/minimum-number-of-days-to-eat-n-oranges/README.md b/problems/minimum-number-of-days-to-eat-n-oranges/README.md index 6718a052c..60db7f364 100644 --- a/problems/minimum-number-of-days-to-eat-n-oranges/README.md +++ b/problems/minimum-number-of-days-to-eat-n-oranges/README.md @@ -71,6 +71,7 @@ You need at least 3 days to eat the 6 oranges. ### Related Topics + [[Memoization](../../tag/memoization/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md b/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md index 4f4f6c114..6eee1afbf 100644 --- a/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md +++ b/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md @@ -62,7 +62,10 @@ ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/minimum-number-of-flips-to-make-the-binary-string-alternating/README.md b/problems/minimum-number-of-flips-to-make-the-binary-string-alternating/README.md new file mode 100644 index 000000000..5f1ca62a4 --- /dev/null +++ b/problems/minimum-number-of-flips-to-make-the-binary-string-alternating/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](../reduction-operations-to-make-the-array-elements-equal "Reduction Operations to Make the Array Elements Equal") +                 +[Next >](../minimum-space-wasted-from-packaging "Minimum Space Wasted From Packaging") + +## [1888. Minimum Number of Flips to Make the Binary String Alternating (Medium)](https://leetcode.com/problems/minimum-number-of-flips-to-make-the-binary-string-alternating "使二进制字符串字符交替的最少反转次数") + +

    You are given a binary string s. You are allowed to perform two types of operations on the string in any sequence:

    + +
      +
    • Type-1: Remove the character at the start of the string s and append it to the end of the string.
    • +
    • Type-2: Pick any character in s and flip its value, i.e., if its value is '0' it becomes '1' and vice-versa.
    • +
    + +

    Return the minimum number of type-2 operations you need to perform such that s becomes alternating.

    + +

    The string is called alternating if no two adjacent characters are equal.

    + +
      +
    • For example, the strings "010" and "1010" are alternating, while the string "0100" is not.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: s = "111000"
    +Output: 2
    +Explanation: Use the first operation two times to make s = "100011".
    +Then, use the second operation on the third and sixth elements to make s = "101010".
    +
    + +

    Example 2:

    + +
    +Input: s = "010"
    +Output: 0
    +Explanation: The string is already alternating.
    +
    + +

    Example 3:

    + +
    +Input: s = "1110"
    +Output: 1
    +Explanation: Use the second operation on the second element to make s = "1010".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 105
    • +
    • s[i] is either '0' or '1'.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Note what actually matters is how many 0s and 1s are in odd and even positions +
    + +
    +Hint 2 +For every cyclic shift we need to count how many 0s and 1s are at each parity and convert the minimum between them for each parity +
    diff --git a/problems/minimum-number-of-frogs-croaking/README.md b/problems/minimum-number-of-frogs-croaking/README.md index 94050c6c7..493964769 100644 --- a/problems/minimum-number-of-frogs-croaking/README.md +++ b/problems/minimum-number-of-frogs-croaking/README.md @@ -59,6 +59,7 @@ The second frog could yell later "crcoakroak diff --git a/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md b/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md index 5903de105..56541581e 100644 --- a/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md +++ b/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md @@ -65,7 +65,11 @@ The answer is guaranteed to fit within the range of a 32-bit signed integer. ### Related Topics - [[Segment Tree](../../tag/segment-tree/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints
    diff --git a/problems/minimum-number-of-k-consecutive-bit-flips/README.md b/problems/minimum-number-of-k-consecutive-bit-flips/README.md index d9dc21cf7..868f36388 100644 --- a/problems/minimum-number-of-k-consecutive-bit-flips/README.md +++ b/problems/minimum-number-of-k-consecutive-bit-flips/README.md @@ -58,7 +58,9 @@ Flip nums[5],nums[6],nums[7]: nums becomes [1,1,1,1,1,1,1,1] ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions diff --git a/problems/minimum-number-of-operations-to-make-string-sorted/README.md b/problems/minimum-number-of-operations-to-make-string-sorted/README.md index c9e8ca487..8d1e43c2e 100644 --- a/problems/minimum-number-of-operations-to-make-string-sorted/README.md +++ b/problems/minimum-number-of-operations-to-make-string-sorted/README.md @@ -70,6 +70,7 @@ Operation 2: i=4, j=4. Swap s[3] and s[4] to get s="aaaab", then rever ### Related Topics [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Combinatorics](../../tag/combinatorics/README.md)] ### Hints
    diff --git a/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md b/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md index 4947d0761..60ff1d8f5 100644 --- a/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md +++ b/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md @@ -47,8 +47,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/minimum-number-of-refueling-stops/README.md b/problems/minimum-number-of-refueling-stops/README.md index fc29e86d9..c990e21b1 100644 --- a/problems/minimum-number-of-refueling-stops/README.md +++ b/problems/minimum-number-of-refueling-stops/README.md @@ -13,44 +13,37 @@

    A car travels from a starting position to a destination which is target miles east of the starting position.

    -

    Along the way, there are gas stations.  Each station[i] represents a gas station that is station[i][0] miles east of the starting position, and has station[i][1] liters of gas.

    +

    There are gas stations along the way. The gas stations are represented as an array stations where stations[i] = [positioni, fueli] indicates that the ith gas station is positioni miles east of the starting position and has fueli liters of gas.

    -

    The car starts with an infinite tank of gas, which initially has startFuel liters of fuel in it.  It uses 1 liter of gas per 1 mile that it drives.

    +

    The car starts with an infinite tank of gas, which initially has startFuel liters of fuel in it. It uses one liter of gas per one mile that it drives. When the car reaches a gas station, it may stop and refuel, transferring all the gas from the station into the car.

    -

    When the car reaches a gas station, it may stop and refuel, transferring all the gas from the station into the car.

    +

    Return the minimum number of refueling stops the car must make in order to reach its destination. If it cannot reach the destination, return -1.

    -

    What is the least number of refueling stops the car must make in order to reach its destination?  If it cannot reach the destination, return -1.

    - -

    Note that if the car reaches a gas station with 0 fuel left, the car can still refuel there.  If the car reaches the destination with 0 fuel left, it is still considered to have arrived.

    +

    Note that if the car reaches a gas station with 0 fuel left, the car can still refuel there. If the car reaches the destination with 0 fuel left, it is still considered to have arrived.

     

    - -

    Example 1:

    -Input: target = 1, startFuel = 1, stations = []
    -Output: 0
    -Explanation: We can reach the target without refueling.
    +Input: target = 1, startFuel = 1, stations = []
    +Output: 0
    +Explanation: We can reach the target without refueling.
     
    -

    Example 2:

    -Input: target = 100, startFuel = 1, stations = [[10,100]]
    -Output: -1
    -Explanation: We can't reach the target (or even the first gas station).
    +Input: target = 100, startFuel = 1, stations = [[10,100]]
    +Output: -1
    +Explanation: We can not reach the target (or even the first gas station).
     
    -

    Example 3:

    -Input: target = 100, startFuel = 10, stations = [[10,60],[20,30],[30,30],[60,40]]
    -Output: 2
    -Explanation: 
    -We start with 10 liters of fuel.
    +Input: target = 100, startFuel = 10, stations = [[10,60],[20,30],[30,30],[60,40]]
    +Output: 2
    +Explanation: We start with 10 liters of fuel.
     We drive to position 10, expending 10 liters of fuel.  We refuel from 0 liters to 60 liters of gas.
     Then, we drive from position 10 to position 60 (expending 50 liters of fuel),
     and refuel from 10 liters to 50 liters of gas.  We then drive to and reach the target.
    @@ -58,18 +51,17 @@ We made 2 refueling stops along the way, so we return 2.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= target, startFuel, stations[i][1] <= 10^9
    2. +
        +
      • 1 <= target, startFuel <= 109
      • 0 <= stations.length <= 500
      • -
      • 0 < stations[0][0] < stations[1][0] < ... < stations[stations.length-1][0] < target
      • -
    -
    -
    -
    +
  • 0 <= positioni <= positioni+1 < target
  • +
  • 1 <= fueli < 109
  • + ### Related Topics - [[Heap](../../tag/heap/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/minimum-number-of-removals-to-make-mountain-array/README.md b/problems/minimum-number-of-removals-to-make-mountain-array/README.md index 3c0470c55..f9ab29ddf 100644 --- a/problems/minimum-number-of-removals-to-make-mountain-array/README.md +++ b/problems/minimum-number-of-removals-to-make-mountain-array/README.md @@ -66,6 +66,9 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md b/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md index 6923d359f..fdf8008a6 100644 --- a/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md +++ b/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md @@ -66,6 +66,7 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md b/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md index 3b23c6a24..6100faa01 100644 --- a/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md +++ b/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md @@ -52,6 +52,7 @@ The string is now alternating. ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md b/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md index b3fbccb97..2f642e058 100644 --- a/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md +++ b/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md @@ -74,6 +74,7 @@ Opening Only the second tap will water the whole garden [0,5] ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md b/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md index 5b294bc57..21ee9a594 100644 --- a/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md +++ b/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md @@ -73,6 +73,7 @@ Total of operations: 2 + 1 = 3. ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/minimum-one-bit-operations-to-make-integers-zero/README.md b/problems/minimum-one-bit-operations-to-make-integers-zero/README.md index c93f87704..b04d7fdaf 100644 --- a/problems/minimum-one-bit-operations-to-make-integers-zero/README.md +++ b/problems/minimum-one-bit-operations-to-make-integers-zero/README.md @@ -73,6 +73,7 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Memoization](../../tag/memoization/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/minimum-operations-to-make-a-subsequence/README.md b/problems/minimum-operations-to-make-a-subsequence/README.md index 4f9931e34..c805ac2d5 100644 --- a/problems/minimum-operations-to-make-a-subsequence/README.md +++ b/problems/minimum-operations-to-make-a-subsequence/README.md @@ -46,6 +46,9 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
    diff --git a/problems/minimum-operations-to-reduce-x-to-zero/README.md b/problems/minimum-operations-to-reduce-x-to-zero/README.md index 034a45d1d..165d04ab2 100644 --- a/problems/minimum-operations-to-reduce-x-to-zero/README.md +++ b/problems/minimum-operations-to-reduce-x-to-zero/README.md @@ -13,7 +13,7 @@

    You are given an integer array nums and an integer x. In one operation, you can either remove the leftmost or the rightmost element from the array nums and subtract its value from x. Note that this modifies the array for future operations.

    -

    Return the minimum number of operations to reduce x to exactly 0 if it's possible, otherwise, return -1.

    +

    Return the minimum number of operations to reduce x to exactly 0 if it is possible, otherwise, return -1.

     

    Example 1:

    @@ -49,10 +49,11 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/minimum-path-cost-in-a-hidden-grid/README.md b/problems/minimum-path-cost-in-a-hidden-grid/README.md index 552bd142f..3fbd24266 100644 --- a/problems/minimum-path-cost-in-a-hidden-grid/README.md +++ b/problems/minimum-path-cost-in-a-hidden-grid/README.md @@ -14,9 +14,11 @@ ### Related Topics - [[Heap](../../tag/heap/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] + [[Interactive](../../tag/interactive/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/minimum-path-sum/README.md b/problems/minimum-path-sum/README.md index bb6cd5a44..082231679 100644 --- a/problems/minimum-path-sum/README.md +++ b/problems/minimum-path-sum/README.md @@ -44,6 +44,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Unique Paths](../unique-paths) (Medium) diff --git a/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md b/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md index 1d21de056..364006cb0 100644 --- a/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md +++ b/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md @@ -67,6 +67,9 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/minimum-score-triangulation-of-polygon/README.md b/problems/minimum-score-triangulation-of-polygon/README.md index b6e17a52d..66ec63aa7 100644 --- a/problems/minimum-score-triangulation-of-polygon/README.md +++ b/problems/minimum-score-triangulation-of-polygon/README.md @@ -53,6 +53,7 @@ The minimum score is 144. ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/minimum-sideway-jumps/README.md b/problems/minimum-sideway-jumps/README.md index 1ac469648..56fe5ea6c 100644 --- a/problems/minimum-sideway-jumps/README.md +++ b/problems/minimum-sideway-jumps/README.md @@ -66,7 +66,8 @@ Note that the frog can jump over obstacles only when making side jumps (as shown ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/minimum-size-subarray-sum/README.md b/problems/minimum-size-subarray-sum/README.md index d24b88532..8d4323693 100644 --- a/problems/minimum-size-subarray-sum/README.md +++ b/problems/minimum-size-subarray-sum/README.md @@ -50,8 +50,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions 1. [Minimum Window Substring](../minimum-window-substring) (Hard) diff --git a/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md b/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md index 266aff6ac..b40cb1c74 100644 --- a/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md +++ b/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md @@ -7,7 +7,7 @@ [< Previous](../process-tasks-using-servers "Process Tasks Using Servers")                  -Next > +[Next >](../egg-drop-with-2-eggs-and-n-floors "Egg Drop With 2 Eggs and N Floors") ## [1883. Minimum Skips to Arrive at Meeting On Time (Hard)](https://leetcode.com/problems/minimum-skips-to-arrive-at-meeting-on-time "准时抵达会议现场的最小跳过休息次数") @@ -69,6 +69,7 @@ You can skip the first and third rest to arrive in ((7/2 + 0) + (3/2 + 0) ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/minimum-space-wasted-from-packaging/README.md b/problems/minimum-space-wasted-from-packaging/README.md new file mode 100644 index 000000000..28578d552 --- /dev/null +++ b/problems/minimum-space-wasted-from-packaging/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../minimum-number-of-flips-to-make-the-binary-string-alternating "Minimum Number of Flips to Make the Binary String Alternating") +                 +[Next >](../the-latest-login-in-2020 "The Latest Login in 2020") + +## [1889. Minimum Space Wasted From Packaging (Hard)](https://leetcode.com/problems/minimum-space-wasted-from-packaging "装包裹的最小浪费空间") + +

    You have n packages that you are trying to place in boxes, one package in each box. There are m suppliers that each produce boxes of different sizes (with infinite supply). A package can be placed in a box if the size of the package is less than or equal to the size of the box.

    + +

    The package sizes are given as an integer array packages, where packages[i] is the size of the ith package. The suppliers are given as a 2D integer array boxes, where boxes[j] is an array of box sizes that the jth supplier produces.

    + +

    You want to choose a single supplier and use boxes from them such that the total wasted space is minimized. For each package in a box, we define the space wasted to be size of the box - size of the package. The total wasted space is the sum of the space wasted in all the boxes.

    + +
      +
    • For example, if you have to fit packages with sizes [2,3,5] and the supplier offers boxes of sizes [4,8], you can fit the packages of size-2 and size-3 into two boxes of size-4 and the package with size-5 into a box of size-8. This would result in a waste of (4-2) + (4-3) + (8-5) = 6.
    • +
    + +

    Return the minimum total wasted space by choosing the box supplier optimally, or -1 if it is impossible to fit all the packages inside boxes. Since the answer may be large, return it modulo 109 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: packages = [2,3,5], boxes = [[4,8],[2,8]]
    +Output: 6
    +Explanation: It is optimal to choose the first supplier, using two size-4 boxes and one size-8 box.
    +The total waste is (4-2) + (4-3) + (8-5) = 6.
    +
    + +

    Example 2:

    + +
    +Input: packages = [2,3,5], boxes = [[1,4],[2,3],[3,4]]
    +Output: -1
    +Explanation: There is no box that the package of size 5 can fit in.
    +
    + +

    Example 3:

    + +
    +Input: packages = [3,5,8,10,11,12], boxes = [[12],[11,9],[10,5,14]]
    +Output: 9
    +Explanation: It is optimal to choose the third supplier, using two size-5 boxes, two size-10 boxes, and two size-14 boxes.
    +The total waste is (5-3) + (5-5) + (10-8) + (10-10) + (14-11) + (14-12) = 9.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == packages.length
    • +
    • m == boxes.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= m <= 105
    • +
    • 1 <= packages[i] <= 105
    • +
    • 1 <= boxes[j].length <= 105
    • +
    • 1 <= boxes[j][k] <= 105
    • +
    • sum(boxes[j].length) <= 105
    • +
    • The elements in boxes[j] are distinct.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Given a fixed size box, is there a way to quickly query which packages (i.e., count and sizes) should end up in that box size? +
    + +
    +Hint 2 +Do we have to order the boxes a certain way to allow us to answer the query quickly? +
    diff --git a/problems/minimum-speed-to-arrive-on-time/README.md b/problems/minimum-speed-to-arrive-on-time/README.md index a0ad00e1f..adcbdfe4d 100644 --- a/problems/minimum-speed-to-arrive-on-time/README.md +++ b/problems/minimum-speed-to-arrive-on-time/README.md @@ -68,7 +68,7 @@ ### Related Topics - [[Math](../../tag/math/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] ### Hints diff --git a/problems/minimum-subsequence-in-non-increasing-order/README.md b/problems/minimum-subsequence-in-non-increasing-order/README.md index 93bfcbbba..1f88685e9 100644 --- a/problems/minimum-subsequence-in-non-increasing-order/README.md +++ b/problems/minimum-subsequence-in-non-increasing-order/README.md @@ -51,7 +51,8 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/minimum-swaps-to-arrange-a-binary-grid/README.md b/problems/minimum-swaps-to-arrange-a-binary-grid/README.md index fb45468ea..dd28d43d6 100644 --- a/problems/minimum-swaps-to-arrange-a-binary-grid/README.md +++ b/problems/minimum-swaps-to-arrange-a-binary-grid/README.md @@ -54,6 +54,8 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/minimum-swaps-to-group-all-1s-together/README.md b/problems/minimum-swaps-to-group-all-1s-together/README.md index 4035377a3..d2ea84521 100644 --- a/problems/minimum-swaps-to-group-all-1s-together/README.md +++ b/problems/minimum-swaps-to-group-all-1s-together/README.md @@ -11,49 +11,7 @@ ## [1151. Minimum Swaps to Group All 1's Together (Medium)](https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together "最少交换次数来组合所有的 1") -

    Given a binary array data, return the minimum number of swaps required to group all 1’s present in the array together in any place in the array.

    -

     

    - -

    Example 1:

    - -
    -Input: [1,0,1,0,1]
    -Output: 1
    -Explanation: 
    -There are 3 ways to group all 1's together:
    -[1,1,1,0,0] using 1 swap.
    -[0,1,1,1,0] using 2 swaps.
    -[0,0,1,1,1] using 1 swap.
    -The minimum is 1.
    -
    - -

    Example 2:

    - -
    -Input: [0,0,0,1,0]
    -Output: 0
    -Explanation: 
    -Since there is only one 1 in the array, no swaps needed.
    -
    - -

    Example 3:

    - -
    -Input: [1,0,1,0,1,0,0,1,1,0,1]
    -Output: 3
    -Explanation: 
    -One possible solution that uses 3 swaps is [0,0,0,0,0,1,1,1,1,1,1].
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= data.length <= 10^5
    2. -
    3. 0 <= data[i] <= 1
    4. -
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/minimum-swaps-to-make-sequences-increasing/README.md b/problems/minimum-swaps-to-make-sequences-increasing/README.md index eec42a970..40e16413e 100644 --- a/problems/minimum-swaps-to-make-sequences-increasing/README.md +++ b/problems/minimum-swaps-to-make-sequences-increasing/README.md @@ -9,32 +9,46 @@                  [Next >](../find-eventual-safe-states "Find Eventual Safe States") -## [801. Minimum Swaps To Make Sequences Increasing (Medium)](https://leetcode.com/problems/minimum-swaps-to-make-sequences-increasing "使序列递增的最小交换次数") +## [801. Minimum Swaps To Make Sequences Increasing (Hard)](https://leetcode.com/problems/minimum-swaps-to-make-sequences-increasing "使序列递增的最小交换次数") -

    We have two integer sequences nums1 and nums2 of the same non-zero length.

    +

    You are given two integer arrays of the same length nums1 and nums2. In one operation, you are allowed to swap nums1[i] with nums2[i].

    -

    We are allowed to swap elements nums1[i] and nums2[i]. Note that both elements are in the same index position in their respective sequences.

    +
      +
    • For example, if nums1 = [1,2,3,8], and nums2 = [5,6,7,4], you can swap the element at i = 3 to obtain nums1 = [1,2,3,4] and nums2 = [5,6,7,8].
    • +
    -

    At the end of some number of swaps, nums1 and nums2 are both strictly increasing. (An array A is strictly increasing if and only if A[0] < A[1] < A[2] < ... < A[A.length - 1].)

    +

    Return the minimum number of needed operations to make nums1 and nums2 strictly increasing. The test cases are generated so that the given input always makes it possible.

    -

    Given nums1 and nums2, return the minimum number of swaps to make both sequences strictly increasing. It is guaranteed that the given input always makes it possible.

    +

    An array arr is strictly increasing if and only if arr[0] < arr[1] < arr[2] < ... < arr[arr.length - 1].

    + +

     

    +

    Example 1:

    -Example:
     Input: nums1 = [1,3,5,4], nums2 = [1,2,3,7]
     Output: 1
    -Explanation: 
    -Swap nums1[3] and nums2[3].  Then the sequences are:
    +Explanation: 
    +Swap nums1[3] and nums2[3]. Then the sequences are:
     nums1 = [1, 3, 5, 7] and nums2 = [1, 2, 3, 4]
     which are both strictly increasing.
     
    -

    Note:

    +

    Example 2:

    + +
    +Input: nums1 = [0,3,5,8,9], nums2 = [2,1,4,6,9]
    +Output: 1
    +
    + +

     

    +

    Constraints:

      -
    • nums1, nums2 are arrays with the same length, and that length will be in the range [1, 1000].
    • -
    • nums1[i], nums2[i] are integer values in the range [0, 2000].
    • +
    • 2 <= nums1.length <= 105
    • +
    • nums2.length == nums1.length
    • +
    • 0 <= nums1[i], nums2[i] <= 2 * 105
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/minimum-swaps-to-make-strings-equal/README.md b/problems/minimum-swaps-to-make-strings-equal/README.md index 420c6a2bd..93d4e667a 100644 --- a/problems/minimum-swaps-to-make-strings-equal/README.md +++ b/problems/minimum-swaps-to-make-strings-equal/README.md @@ -58,6 +58,7 @@ Note that you can't swap s1[0] and s1[1] to make s1 equal to "yx", ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/minimum-time-difference/README.md b/problems/minimum-time-difference/README.md index fa9891305..de160e58a 100644 --- a/problems/minimum-time-difference/README.md +++ b/problems/minimum-time-difference/README.md @@ -29,4 +29,7 @@ Given a list of 24-hour clock time points in "HH:MM" ### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/minimum-time-to-build-blocks/README.md b/problems/minimum-time-to-build-blocks/README.md index b8c54d002..7a69e6506 100644 --- a/problems/minimum-time-to-build-blocks/README.md +++ b/problems/minimum-time-to-build-blocks/README.md @@ -11,55 +11,12 @@ ## [1199. Minimum Time to Build Blocks (Hard)](https://leetcode.com/problems/minimum-time-to-build-blocks "建造街区的最短时间") -

    You are given a list of blocks, where blocks[i] = t means that the i-th block needs t units of time to be built. A block can only be built by exactly one worker.

    -

    A worker can either split into two workers (number of workers increases by one) or build a block then go home. Both decisions cost some time.

    - -

    The time cost of spliting one worker into two workers is given as an integer split. Note that if two workers split at the same time, they split in parallel so the cost would be split.

    - -

    Output the minimum time needed to build all blocks.

    - -

    Initially, there is only one worker.

    - -

     

    -

    Example 1:

    - -
    -Input: blocks = [1], split = 1
    -Output: 1
    -Explanation: We use 1 worker to build 1 block in 1 time unit.
    -
    - -

    Example 2:

    - -
    -Input: blocks = [1,2], split = 5
    -Output: 7
    -Explanation: We split the worker into 2 workers in 5 time units then assign each of them to a block so the cost is 5 + max(1, 2) = 7.
    -
    - -

    Example 3:

    - -
    -Input: blocks = [1,2,3], split = 1
    -Output: 4
    -Explanation: Split 1 worker into 2, then assign the first worker to the last block and split the second worker into 2.
    -Then, use the two unassigned workers to build the first two blocks.
    -The cost is 1 + max(3, 1 + max(1, 2)) = 4.
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= blocks.length <= 1000
    • -
    • 1 <= blocks[i] <= 10^5
    • -
    • 1 <= split <= 100
    • -
    ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md b/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md index 7c687c37a..2ba788cc4 100644 --- a/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md +++ b/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md @@ -57,7 +57,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/minimum-time-visiting-all-points/README.md b/problems/minimum-time-visiting-all-points/README.md index b50308ecf..f66a2fe95 100644 --- a/problems/minimum-time-visiting-all-points/README.md +++ b/problems/minimum-time-visiting-all-points/README.md @@ -58,6 +58,7 @@ Total time = 7 seconds ### Related Topics [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/minimum-unique-word-abbreviation/README.md b/problems/minimum-unique-word-abbreviation/README.md index 355b569bb..b86431952 100644 --- a/problems/minimum-unique-word-abbreviation/README.md +++ b/problems/minimum-unique-word-abbreviation/README.md @@ -11,32 +11,11 @@ ## [411. Minimum Unique Word Abbreviation (Hard)](https://leetcode.com/problems/minimum-unique-word-abbreviation "最短独占单词缩写") -

    A string such as "word" contains the following abbreviations:

    -
    ["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"]
    -
    - -

    Given a target string and a set of strings in a dictionary, find an abbreviation of this target string with the smallest possible length such that it does not conflict with abbreviations of the strings in the dictionary.

    - -

    Each number or letter in the abbreviation is considered length = 1. For example, the abbreviation "a32bc" has length = 4.

    - -

    Note:
    -

      -
    • In the case of multiple answers as shown in the second example below, you may return any one of them.
    • -
    • Assume length of target string = m, and dictionary size = n. You may assume that m ≤ 21, n ≤ 1000, and log2(n) + m ≤ 20.
    • -
    -

    - -

    Examples:
    -

    -"apple", ["blade"] -> "a4" (because "5" or "4e" conflicts with "blade")
    -
    -"apple", ["plain", "amber", "blade"] -> "1p3" (other valid answers include "ap3", "a3e", "2p2", "3le", "3l1").
    -
    -

    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions diff --git a/problems/minimum-value-to-get-positive-step-by-step-sum/README.md b/problems/minimum-value-to-get-positive-step-by-step-sum/README.md index e4b21a71e..97ef9c6ee 100644 --- a/problems/minimum-value-to-get-positive-step-by-step-sum/README.md +++ b/problems/minimum-value-to-get-positive-step-by-step-sum/README.md @@ -58,6 +58,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/minimum-window-subsequence/README.md b/problems/minimum-window-subsequence/README.md index ce91c1346..fd152167e 100644 --- a/problems/minimum-window-subsequence/README.md +++ b/problems/minimum-window-subsequence/README.md @@ -11,34 +11,10 @@ ## [727. Minimum Window Subsequence (Hard)](https://leetcode.com/problems/minimum-window-subsequence "最小窗口子序列") -

    Given strings S and T, find the minimum (contiguous) substring W of S, so that T is a subsequence of W.

    -

    If there is no such window in S that covers all characters in T, return the empty string "". If there are multiple such minimum-length windows, return the one with the left-most starting index.

    - -

    Example 1:

    - -
    -Input: 
    -S = "abcdebdde", T = "bde"
    -Output: "bcde"
    -Explanation: 
    -"bcde" is the answer because it occurs before "bdde" which has the same length.
    -"deb" is not a smaller window because the elements of T in the window must occur in order.
    -
    - -

     

    - -

    Note:

    - -
      -
    • All the strings in the input will only contain lowercase letters.
    • -
    • The length of S will be in the range [1, 20000].
    • -
    • The length of T will be in the range [1, 100].
    • -
    - -

     

    ### Related Topics + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] diff --git a/problems/minimum-window-substring/README.md b/problems/minimum-window-substring/README.md index 2fd6fdceb..0135d2e32 100644 --- a/problems/minimum-window-substring/README.md +++ b/problems/minimum-window-substring/README.md @@ -58,7 +58,6 @@ Since the largest window of s only has one 'a', return empty string. ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] diff --git a/problems/minimum-xor-sum-of-two-arrays/README.md b/problems/minimum-xor-sum-of-two-arrays/README.md index a61323281..1b1ab001c 100644 --- a/problems/minimum-xor-sum-of-two-arrays/README.md +++ b/problems/minimum-xor-sum-of-two-arrays/README.md @@ -53,7 +53,9 @@ The XOR sum is (1 XOR 5) + (0 XOR 4) + (3 XOR 3) = 4 + 4 + 0 = 8. ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/mirror-reflection/README.md b/problems/mirror-reflection/README.md index 25adeb8d7..1e1814439 100644 --- a/problems/mirror-reflection/README.md +++ b/problems/mirror-reflection/README.md @@ -38,4 +38,5 @@ ### Related Topics + [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/missing-element-in-sorted-array/README.md b/problems/missing-element-in-sorted-array/README.md index 35b3c3c4b..de0c294b6 100644 --- a/problems/missing-element-in-sorted-array/README.md +++ b/problems/missing-element-in-sorted-array/README.md @@ -11,48 +11,10 @@ ## [1060. Missing Element in Sorted Array (Medium)](https://leetcode.com/problems/missing-element-in-sorted-array "有序数组中的缺失元素") -

    Given a sorted array A of unique numbers, find the K-th missing number starting from the leftmost number of the array.

    -

     

    - -

    Example 1:

    - -
    -Input: A = [4,7,9,10], K = 1
    -Output: 5
    -Explanation: 
    -The first missing number is 5.
    -
    - -

    Example 2:

    - -
    -Input: A = [4,7,9,10], K = 3
    -Output: 8
    -Explanation: 
    -The missing numbers are [5,6,8,...], hence the third missing number is 8.
    -
    - -

    Example 3:

    - -
    -Input: A = [1,2,4], K = 3
    -Output: 6
    -Explanation: 
    -The missing numbers are [3,5,6,7,...], hence the third missing number is 6.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= A.length <= 50000
    2. -
    3. 1 <= A[i] <= 1e7
    4. -
    5. 1 <= K <= 1e8
    6. -
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] ### Hints diff --git a/problems/missing-number-in-arithmetic-progression/README.md b/problems/missing-number-in-arithmetic-progression/README.md index 24b33ae4b..b81744d4b 100644 --- a/problems/missing-number-in-arithmetic-progression/README.md +++ b/problems/missing-number-in-arithmetic-progression/README.md @@ -11,37 +11,10 @@ ## [1228. Missing Number In Arithmetic Progression (Easy)](https://leetcode.com/problems/missing-number-in-arithmetic-progression "等差数列中缺失的数字") -

    In some array arr, the values were in arithmetic progression: the values arr[i+1] - arr[i] are all equal for every 0 <= i < arr.length - 1.

    -

    Then, a value from arr was removed that was not the first or last value in the array.

    - -

    Return the removed value.

    - -

     

    -

    Example 1:

    - -
    -Input: arr = [5,7,11,13]
    -Output: 9
    -Explanation: The previous array was [5,7,9,11,13].
    -
    - -

    Example 2:

    - -
    -Input: arr = [15,13,12]
    -Output: 14
    -Explanation: The previous array was [15,14,13,12].
    - -

     

    -

    Constraints:

    - -
      -
    • 3 <= arr.length <= 1000
    • -
    • 0 <= arr[i] <= 10^5
    • -
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] ### Hints diff --git a/problems/missing-number/README.md b/problems/missing-number/README.md index 92573152f..2e382e59f 100644 --- a/problems/missing-number/README.md +++ b/problems/missing-number/README.md @@ -61,7 +61,9 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [First Missing Positive](../first-missing-positive) (Hard) diff --git a/problems/missing-ranges/README.md b/problems/missing-ranges/README.md index 0b127da34..aea52d801 100644 --- a/problems/missing-ranges/README.md +++ b/problems/missing-ranges/README.md @@ -11,14 +11,7 @@ ## [163. Missing Ranges (Easy)](https://leetcode.com/problems/missing-ranges "缺失的区间") -

    Given a sorted integer array nums, where the range of elements are in the inclusive range [lower, upper], return its missing ranges.

    -

    Example:

    - -
    -Input: nums = [0, 1, 3, 50, 75], lower = 0 and upper = 99,
    -Output: ["2", "4->49", "51->74", "76->99"]
    -
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/monotone-increasing-digits/README.md b/problems/monotone-increasing-digits/README.md index dc313c2d3..acec2dd07 100644 --- a/problems/monotone-increasing-digits/README.md +++ b/problems/monotone-increasing-digits/README.md @@ -46,6 +46,7 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Remove K Digits](../remove-k-digits) (Medium) diff --git a/problems/monthly-transactions-i/README.md b/problems/monthly-transactions-i/README.md index d98080073..b27b9add0 100644 --- a/problems/monthly-transactions-i/README.md +++ b/problems/monthly-transactions-i/README.md @@ -11,46 +11,7 @@ ## [1193. Monthly Transactions I (Medium)](https://leetcode.com/problems/monthly-transactions-i "每月交易 I") -

    Table: Transactions

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| id            | int     |
    -| country       | varchar |
    -| state         | enum    |
    -| amount        | int     |
    -| trans_date    | date    |
    -+---------------+---------+
    -id is the primary key of this table.
    -The table has information about incoming transactions.
    -The state column is an enum of type ["approved", "declined"].
    -
    -

     

    - -

    Write an SQL query to find for each month and country, the number of transactions and their total amount, the number of approved transactions and their total amount.

    - -

    The query result format is in the following example:

    - -
    -Transactions table:
    -+------+---------+----------+--------+------------+
    -| id   | country | state    | amount | trans_date |
    -+------+---------+----------+--------+------------+
    -| 121  | US      | approved | 1000   | 2018-12-18 |
    -| 122  | US      | declined | 2000   | 2018-12-19 |
    -| 123  | US      | approved | 2000   | 2019-01-01 |
    -| 124  | DE      | approved | 2000   | 2019-01-07 |
    -+------+---------+----------+--------+------------+
    -
    -Result table:
    -+----------+---------+-------------+----------------+--------------------+-----------------------+
    -| month    | country | trans_count | approved_count | trans_total_amount | approved_total_amount |
    -+----------+---------+-------------+----------------+--------------------+-----------------------+
    -| 2018-12  | US      | 2           | 1              | 3000               | 1000                  |
    -| 2019-01  | US      | 1           | 1              | 2000               | 2000                  |
    -| 2019-01  | DE      | 1           | 1              | 2000               | 2000                  |
    -+----------+---------+-------------+----------------+--------------------+-----------------------+
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/monthly-transactions-ii/README.md b/problems/monthly-transactions-ii/README.md index a8c1b1b5c..bdca05b96 100644 --- a/problems/monthly-transactions-ii/README.md +++ b/problems/monthly-transactions-ii/README.md @@ -5,77 +5,13 @@ -[< Previous](../last-person-to-fit-in-the-elevator "Last Person to Fit in the Elevator") +[< Previous](../last-person-to-fit-in-the-bus "Last Person to Fit in the Bus")                  [Next >](../design-skiplist "Design Skiplist") ## [1205. Monthly Transactions II (Medium)](https://leetcode.com/problems/monthly-transactions-ii "每月交易II") -

    Table: Transactions

    -
    -+----------------+---------+
    -| Column Name    | Type    |
    -+----------------+---------+
    -| id             | int     |
    -| country        | varchar |
    -| state          | enum    |
    -| amount         | int     |
    -| trans_date     | date    |
    -+----------------+---------+
    -id is the primary key of this table.
    -The table has information about incoming transactions.
    -The state column is an enum of type ["approved", "declined"].
    -
    -

    Table: Chargebacks

    - -
    -+----------------+---------+
    -| Column Name    | Type    |
    -+----------------+---------+
    -| trans_id       | int     |
    -| charge_date    | date    |
    -+----------------+---------+
    -Chargebacks contains basic information regarding incoming chargebacks from some transactions placed in Transactions table.
    -trans_id is a foreign key to the id column of Transactions table.
    -Each chargeback corresponds to a transaction made previously even if they were not approved.
    - -

     

    - -

    Write an SQL query to find for each month and country, the number of approved transactions and their total amount, the number of chargebacks and their total amount.

    - -

    Note: In your query, given the month and country, ignore rows with all zeros.

    - -

    The query result format is in the following example:

    - -
    -Transactions table:
    -+------+---------+----------+--------+------------+
    -| id   | country | state    | amount | trans_date |
    -+------+---------+----------+--------+------------+
    -| 101  | US      | approved | 1000   | 2019-05-18 |
    -| 102  | US      | declined | 2000   | 2019-05-19 |
    -| 103  | US      | approved | 3000   | 2019-06-10 |
    -| 104  | US      | approved | 4000   | 2019-06-13 |
    -| 105  | US      | approved | 5000   | 2019-06-15 |
    -+------+---------+----------+--------+------------+
    -
    -Chargebacks table:
    -+------------+------------+
    -| trans_id   | trans_date |
    -+------------+------------+
    -| 102        | 2019-05-29 |
    -| 101        | 2019-06-30 |
    -| 105        | 2019-09-18 |
    -+------------+------------+
    -
    -Result table:
    -+----------+---------+----------------+-----------------+-------------------+--------------------+
    -| month    | country | approved_count | approved_amount | chargeback_count  | chargeback_amount  |
    -+----------+---------+----------------+-----------------+-------------------+--------------------+
    -| 2019-05  | US      | 1              | 1000            | 1                 | 2000               |
    -| 2019-06  | US      | 3              | 12000           | 1                 | 1000               |
    -| 2019-09  | US      | 0              | 0               | 1                 | 5000               |
    -+----------+---------+----------------+-----------------+-------------------+--------------------+
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/most-common-word/README.md b/problems/most-common-word/README.md index 3a96dcf61..2d6aeb918 100644 --- a/problems/most-common-word/README.md +++ b/problems/most-common-word/README.md @@ -48,4 +48,5 @@ and that "hit" isn't the answer even though it occurs more because ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/most-frequent-subtree-sum/README.md b/problems/most-frequent-subtree-sum/README.md index 4f7bd7ae7..f6c8d73d9 100644 --- a/problems/most-frequent-subtree-sum/README.md +++ b/problems/most-frequent-subtree-sum/README.md @@ -40,7 +40,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Subtree of Another Tree](../subtree-of-another-tree) (Easy) diff --git a/problems/most-profit-assigning-work/README.md b/problems/most-profit-assigning-work/README.md index 9f990e5aa..fcb4fe052 100644 --- a/problems/most-profit-assigning-work/README.md +++ b/problems/most-profit-assigning-work/README.md @@ -37,4 +37,8 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/most-stones-removed-with-same-row-or-column/README.md b/problems/most-stones-removed-with-same-row-or-column/README.md index 49ec708e4..8a44c6396 100644 --- a/problems/most-stones-removed-with-same-row-or-column/README.md +++ b/problems/most-stones-removed-with-same-row-or-column/README.md @@ -62,5 +62,6 @@ Stones [0,0] and [1,1] cannot be removed since they do not share a row/column wi ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] diff --git a/problems/most-visited-sector-in-a-circular-track/README.md b/problems/most-visited-sector-in-a-circular-track/README.md index f7518226e..aeadb51fb 100644 --- a/problems/most-visited-sector-in-a-circular-track/README.md +++ b/problems/most-visited-sector-in-a-circular-track/README.md @@ -54,6 +54,7 @@ We can see that both sectors 1 and 2 are visited twice and they are the most vis ### Related Topics [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/move-sub-tree-of-n-ary-tree/README.md b/problems/move-sub-tree-of-n-ary-tree/README.md index 9e0e67911..7b3f55ebd 100644 --- a/problems/move-sub-tree-of-n-ary-tree/README.md +++ b/problems/move-sub-tree-of-n-ary-tree/README.md @@ -15,6 +15,7 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] ### Hints
    diff --git a/problems/movie-rating/README.md b/problems/movie-rating/README.md index 6f65cba68..5b4e1b0f3 100644 --- a/problems/movie-rating/README.md +++ b/problems/movie-rating/README.md @@ -11,96 +11,7 @@ ## [1341. Movie Rating (Medium)](https://leetcode.com/problems/movie-rating "电影评分") -

    Table: Movies

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| movie_id      | int     |
    -| title         | varchar |
    -+---------------+---------+
    -movie_id is the primary key for this table.
    -title is the name of the movie.
    -
    -

    Table: Users

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| user_id       | int     |
    -| name          | varchar |
    -+---------------+---------+
    -user_id is the primary key for this table.
    -
    -

    Table: Movie_Rating

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| movie_id      | int     |
    -| user_id       | int     |
    -| rating        | int     |
    -| created_at    | date    |
    -+---------------+---------+
    -(movie_id, user_id) is the primary key for this table.
    -This table contains the rating of a movie by a user in their review.
    -created_at is the user's review date. 
    -
    - -Write the following SQL query: - -- Find the name of the user who has rated the greatest number of the movies. - In case of a tie, return lexicographically smaller user name. - -- Find the movie name with the highest average rating as of Feb 2020. - In case of a tie, return lexicographically smaller movie name.. - -Query is returned in 2 rows, the query result format is in the folowing example: -
    -Movie table:
    -+-------------+--------------+
    -| movie_id    |  title       |
    -+-------------+--------------+
    -| 1           | Avengers     |
    -| 2           | Frozen 2     |
    -| 3           | Joker        |
    -+-------------+--------------+
    -
    -Users table:
    -+-------------+--------------+
    -| user_id     |  name        |
    -+-------------+--------------+
    -| 1           | Daniel       |
    -| 2           | Monica       |
    -| 3           | Maria        |
    -| 4           | James        |
    -+-------------+--------------+
    -
    -Movie_Rating table:
    -+-------------+--------------+--------------+-------------+
    -| movie_id    | user_id      | rating       | created_at  |
    -+-------------+--------------+--------------+-------------+
    -| 1           | 1            | 3            | 2020-01-12  |
    -| 1           | 2            | 4            | 2020-02-11  |
    -| 1           | 3            | 2            | 2020-02-12  |
    -| 1           | 4            | 1            | 2020-01-01  |
    -| 2           | 1            | 5            | 2020-02-17  | 
    -| 2           | 2            | 2            | 2020-02-01  | 
    -| 2           | 3            | 2            | 2020-03-01  |
    -| 3           | 1            | 3            | 2020-02-22  | 
    -| 3           | 2            | 4            | 2020-02-25  | 
    -+-------------+--------------+--------------+-------------+
    -
    -Result table:
    -+--------------+
    -| results      |
    -+--------------+
    -| Daniel       |
    -| Frozen 2     |
    -+--------------+
    -
    -Daniel and Maria have rated 3 movies ("Avengers", "Frozen 2" and "Joker") but Daniel is smaller lexicographically.
    -Frozen 2 and Joker have a rating average of 3.5 in February but Frozen 2 is smaller lexicographically.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/moving-average-from-data-stream/README.md b/problems/moving-average-from-data-stream/README.md index 36caea0c6..5a78eaa0c 100644 --- a/problems/moving-average-from-data-stream/README.md +++ b/problems/moving-average-from-data-stream/README.md @@ -11,20 +11,10 @@ ## [346. Moving Average from Data Stream (Easy)](https://leetcode.com/problems/moving-average-from-data-stream "数据流中的移动平均值") -

    Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window.

    -

    Example:

    - -
    -MovingAverage m = new MovingAverage(3);
    -m.next(1) = 1
    -m.next(10) = (1 + 10) / 2
    -m.next(3) = (1 + 10 + 3) / 3
    -m.next(5) = (10 + 3 + 5) / 3
    -
    - -

     

    ### Related Topics [[Design](../../tag/design/README.md)] [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] diff --git a/problems/moving-stones-until-consecutive-ii/README.md b/problems/moving-stones-until-consecutive-ii/README.md index 28c71a038..2867980e0 100644 --- a/problems/moving-stones-until-consecutive-ii/README.md +++ b/problems/moving-stones-until-consecutive-ii/README.md @@ -71,7 +71,9 @@ Notice we cannot move 10 -> 2 to finish the game, because that would be an il ### Related Topics [[Array](../../tag/array/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] + [[Math](../../tag/math/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/moving-stones-until-consecutive/README.md b/problems/moving-stones-until-consecutive/README.md index 9f8c452b1..a8c92eb18 100644 --- a/problems/moving-stones-until-consecutive/README.md +++ b/problems/moving-stones-until-consecutive/README.md @@ -70,6 +70,7 @@ ### Related Topics [[Brainteaser](../../tag/brainteaser/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/multiply-strings/README.md b/problems/multiply-strings/README.md index 2903e95ad..5de23a000 100644 --- a/problems/multiply-strings/README.md +++ b/problems/multiply-strings/README.md @@ -35,6 +35,7 @@ ### Related Topics [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Similar Questions 1. [Add Two Numbers](../add-two-numbers) (Medium) diff --git a/problems/my-calendar-i/README.md b/problems/my-calendar-i/README.md index 52c0248f7..11c307265 100644 --- a/problems/my-calendar-i/README.md +++ b/problems/my-calendar-i/README.md @@ -11,40 +11,47 @@ ## [729. My Calendar I (Medium)](https://leetcode.com/problems/my-calendar-i "我的日程安排表 I") -

    Implement a MyCalendar class to store your events. A new event can be added if adding the event will not cause a double booking.

    +

    You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a double booking.

    -

    Your class will have the method, book(int start, int end). Formally, this represents a booking on the half open interval [start, end), the range of real numbers x such that start <= x < end.

    +

    A double booking happens when two events have some non-empty intersection (i.e., some moment is common to both events.).

    -

    A double booking happens when two events have some non-empty intersection (ie., there is some time that is common to both events.)

    +

    The event can be represented as a pair of integers start and end that represents a booking on the half-open interval [start, end), the range of real numbers x such that start <= x < end.

    -

    For each call to the method MyCalendar.book, return true if the event can be added to the calendar successfully without causing a double booking. Otherwise, return false and do not add the event to the calendar.

    -Your class will be called like this: MyCalendar cal = new MyCalendar(); MyCalendar.book(start, end) +

    Implement the MyCalendar class:

    -

    Example 1:

    +
      +
    • MyCalendar() Initializes the calendar object.
    • +
    • boolean book(int start, int end) Returns true if the event can be added to the calendar successfully without causing a double booking. Otherwise, return false and do not add the event to the calendar.
    • +
    + +

     

    +

    Example 1:

    -MyCalendar();
    -MyCalendar.book(10, 20); // returns true
    -MyCalendar.book(15, 25); // returns false
    -MyCalendar.book(20, 30); // returns true
    -Explanation: 
    -The first event can be booked.  The second can't because time 15 is already booked by another event.
    -The third event can be booked, as the first event takes every time less than 20, but not including 20.
    -
    +Input +["MyCalendar", "book", "book", "book"] +[[], [10, 20], [15, 25], [20, 30]] +Output +[null, true, false, true] -

     

    +Explanation +MyCalendar myCalendar = new MyCalendar(); +myCalendar.book(10, 20); // return True +myCalendar.book(15, 25); // return False, It can not be booked because time 15 is already booked by another event. +myCalendar.book(20, 30); // return True, The event can be booked, as the first event takes every time less than 20, but not including 20. -

    Note:

    +

     

    +

    Constraints:

      -
    • The number of calls to MyCalendar.book per test case will be at most 1000.
    • -
    • In calls to MyCalendar.book(start, end), start and end are integers in the range [0, 10^9].
    • +
    • 0 <= start < end <= 109
    • +
    • At most 1000 calls will be made to book.
    -

     

    - ### Related Topics - [[Array](../../tag/array/README.md)] + [[Design](../../tag/design/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions 1. [My Calendar II](../my-calendar-ii) (Medium) diff --git a/problems/my-calendar-ii/README.md b/problems/my-calendar-ii/README.md index e062b2ad1..ff37dee7b 100644 --- a/problems/my-calendar-ii/README.md +++ b/problems/my-calendar-ii/README.md @@ -11,46 +11,51 @@ ## [731. My Calendar II (Medium)](https://leetcode.com/problems/my-calendar-ii "我的日程安排表 II") -

    Implement a MyCalendarTwo class to store your events. A new event can be added if adding the event will not cause a triple booking.

    +

    You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a triple booking.

    -

    Your class will have one method, book(int start, int end). Formally, this represents a booking on the half open interval [start, end), the range of real numbers x such that start <= x < end.

    +

    A triple booking happens when three events have some non-empty intersection (i.e., some moment is common to all the three events.).

    -

    A triple booking happens when three events have some non-empty intersection (ie., there is some time that is common to all 3 events.)

    +

    The event can be represented as a pair of integers start and end that represents a booking on the half-open interval [start, end), the range of real numbers x such that start <= x < end.

    -

    For each call to the method MyCalendar.book, return true if the event can be added to the calendar successfully without causing a triple booking. Otherwise, return false and do not add the event to the calendar.

    -Your class will be called like this: MyCalendar cal = new MyCalendar(); MyCalendar.book(start, end) +

    Implement the MyCalendarTwo class:

    -

    Example 1:

    +
      +
    • MyCalendarTwo() Initializes the calendar object.
    • +
    • boolean book(int start, int end) Returns true if the event can be added to the calendar successfully without causing a triple booking. Otherwise, return false and do not add the event to the calendar.
    • +
    + +

     

    +

    Example 1:

    -MyCalendar();
    -MyCalendar.book(10, 20); // returns true
    -MyCalendar.book(50, 60); // returns true
    -MyCalendar.book(10, 40); // returns true
    -MyCalendar.book(5, 15); // returns false
    -MyCalendar.book(5, 10); // returns true
    -MyCalendar.book(25, 55); // returns true
    -Explanation: 
    -The first two events can be booked.  The third event can be double booked.
    -The fourth event (5, 15) can't be booked, because it would result in a triple booking.
    -The fifth event (5, 10) can be booked, as it does not use time 10 which is already double booked.
    -The sixth event (25, 55) can be booked, as the time in [25, 40) will be double booked with the third event;
    -the time [40, 50) will be single booked, and the time [50, 55) will be double booked with the second event.
    +Input
    +["MyCalendarTwo", "book", "book", "book", "book", "book", "book"]
    +[[], [10, 20], [50, 60], [10, 40], [5, 15], [5, 10], [25, 55]]
    +Output
    +[null, true, true, true, false, true, true]
    +
    +Explanation
    +MyCalendarTwo myCalendarTwo = new MyCalendarTwo();
    +myCalendarTwo.book(10, 20); // return True, The event can be booked. 
    +myCalendarTwo.book(50, 60); // return True, The event can be booked. 
    +myCalendarTwo.book(10, 40); // return True, The event can be double booked. 
    +myCalendarTwo.book(5, 15);  // return False, The event ca not be booked, because it would result in a triple booking.
    +myCalendarTwo.book(5, 10); // return True, The event can be booked, as it does not use time 10 which is already double booked.
    +myCalendarTwo.book(25, 55); // return True, The event can be booked, as the time in [25, 40) will be double booked with the third event, the time [40, 50) will be single booked, and the time [50, 55) will be double booked with the second event.
     

     

    - -

    Note:

    +

    Constraints:

      -
    • The number of calls to MyCalendar.book per test case will be at most 1000.
    • -
    • In calls to MyCalendar.book(start, end), start and end are integers in the range [0, 10^9].
    • +
    • 0 <= start < end <= 109
    • +
    • At most 1000 calls will be made to book.
    -

     

    - ### Related Topics - [[Ordered Map](../../tag/ordered-map/README.md)] + [[Design](../../tag/design/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions 1. [My Calendar I](../my-calendar-i) (Medium) diff --git a/problems/my-calendar-iii/README.md b/problems/my-calendar-iii/README.md index 5e21e5204..16d2e1309 100644 --- a/problems/my-calendar-iii/README.md +++ b/problems/my-calendar-iii/README.md @@ -51,8 +51,9 @@ myCalendarThree.book(25, 55); // return 3 ### Related Topics + [[Design](../../tag/design/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] - [[Ordered Map](../../tag/ordered-map/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions 1. [My Calendar I](../my-calendar-i) (Medium) diff --git a/problems/n-ary-tree-level-order-traversal/README.md b/problems/n-ary-tree-level-order-traversal/README.md index 13928cd40..b98d1f2b6 100644 --- a/problems/n-ary-tree-level-order-traversal/README.md +++ b/problems/n-ary-tree-level-order-traversal/README.md @@ -44,7 +44,7 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Similar Questions 1. [Binary Tree Level Order Traversal](../binary-tree-level-order-traversal) (Medium) diff --git a/problems/n-ary-tree-postorder-traversal/README.md b/problems/n-ary-tree-postorder-traversal/README.md index 356270897..6fb7c1ada 100644 --- a/problems/n-ary-tree-postorder-traversal/README.md +++ b/problems/n-ary-tree-postorder-traversal/README.md @@ -43,7 +43,9 @@

    Follow up: Recursive solution is trivial, could you do it iteratively?

    ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] ### Similar Questions 1. [Binary Tree Postorder Traversal](../binary-tree-postorder-traversal) (Easy) diff --git a/problems/n-ary-tree-preorder-traversal/README.md b/problems/n-ary-tree-preorder-traversal/README.md index cfefd3582..748911d67 100644 --- a/problems/n-ary-tree-preorder-traversal/README.md +++ b/problems/n-ary-tree-preorder-traversal/README.md @@ -47,7 +47,9 @@

    Follow up: Recursive solution is trivial, could you do it iteratively?

    ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] ### Similar Questions 1. [Binary Tree Preorder Traversal](../binary-tree-preorder-traversal) (Easy) diff --git a/problems/n-queens/README.md b/problems/n-queens/README.md index d7813ecb5..866757347 100644 --- a/problems/n-queens/README.md +++ b/problems/n-queens/README.md @@ -41,6 +41,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions diff --git a/problems/n-repeated-element-in-size-2n-array/README.md b/problems/n-repeated-element-in-size-2n-array/README.md index 42d478b21..fd63c7d55 100644 --- a/problems/n-repeated-element-in-size-2n-array/README.md +++ b/problems/n-repeated-element-in-size-2n-array/README.md @@ -58,4 +58,5 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/n-th-tribonacci-number/README.md b/problems/n-th-tribonacci-number/README.md index be7bd369e..43b0b3b94 100644 --- a/problems/n-th-tribonacci-number/README.md +++ b/problems/n-th-tribonacci-number/README.md @@ -44,7 +44,9 @@ T_4 = 1 + 1 + 2 = 4 ### Related Topics - [[Recursion](../../tag/recursion/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Climbing Stairs](../climbing-stairs) (Easy) diff --git a/problems/nested-list-weight-sum-ii/README.md b/problems/nested-list-weight-sum-ii/README.md index b9195be45..c03e789de 100644 --- a/problems/nested-list-weight-sum-ii/README.md +++ b/problems/nested-list-weight-sum-ii/README.md @@ -11,32 +11,12 @@ ## [364. Nested List Weight Sum II (Medium)](https://leetcode.com/problems/nested-list-weight-sum-ii "加权嵌套序列和 II") -

    Given a nested list of integers, return the sum of all integers in the list weighted by their depth.

    -

    Each element is either an integer, or a list -- whose elements may also be integers or other lists.

    - -

    Different from the previous question where weight is increasing from root to leaf, now the weight is defined from bottom up. i.e., the leaf level integers have weight 1, and the root level integers have the largest weight.

    - -

    Example 1:

    - -
    -
    -Input: [[1,1],2,[1,1]]
    -Output: 8 
    -Explanation: Four 1's at depth 1, one 2 at depth 2.
    -
    - -
    -

    Example 2:

    - -
    -Input: [1,[4,[6]]]
    -Output: 17 
    -Explanation: One 1 at depth 3, one 4 at depth 2, and one 6 at depth 1; 1*3 + 4*2 + 6*1 = 17.
    -
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Similar Questions 1. [Nested List Weight Sum](../nested-list-weight-sum) (Medium) diff --git a/problems/nested-list-weight-sum/README.md b/problems/nested-list-weight-sum/README.md index 70ddb4446..74e265612 100644 --- a/problems/nested-list-weight-sum/README.md +++ b/problems/nested-list-weight-sum/README.md @@ -11,29 +11,11 @@ ## [339. Nested List Weight Sum (Medium)](https://leetcode.com/problems/nested-list-weight-sum "嵌套列表权重和") -

    Given a nested list of integers, return the sum of all integers in the list weighted by their depth.

    -

    Each element is either an integer, or a list -- whose elements may also be integers or other lists.

    - -
    -

    Example 1:

    - -
    -Input: [[1,1],2,[1,1]]
    -Output: 10 
    -Explanation: Four 1's at depth 2, one 2 at depth 1.
    - -
    -

    Example 2:

    - -
    -Input: [1,[4,[6]]]
    -Output: 27 
    -Explanation: One 1 at depth 1, one 4 at depth 2, and one 6 at depth 3; 1 + 4*2 + 6*3 = 27.
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Similar Questions 1. [Nested List Weight Sum II](../nested-list-weight-sum-ii) (Medium) diff --git a/problems/network-delay-time/README.md b/problems/network-delay-time/README.md index f99307e18..92e5036af 100644 --- a/problems/network-delay-time/README.md +++ b/problems/network-delay-time/README.md @@ -51,10 +51,11 @@ ### Related Topics - [[Heap](../../tag/heap/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/new-21-game/README.md b/problems/new-21-game/README.md index 9b5fd46cf..a1643a0c3 100644 --- a/problems/new-21-game/README.md +++ b/problems/new-21-game/README.md @@ -55,4 +55,7 @@ In 6 out of 10 possibilities, she is at or below 6 points. ### Related Topics + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + [[Probability and Statistics](../../tag/probability-and-statistics/README.md)] diff --git a/problems/new-users-daily-count/README.md b/problems/new-users-daily-count/README.md index 01c9e4357..09c92851f 100644 --- a/problems/new-users-daily-count/README.md +++ b/problems/new-users-daily-count/README.md @@ -11,55 +11,7 @@ ## [1107. New Users Daily Count (Medium)](https://leetcode.com/problems/new-users-daily-count "每日新用户统计") -

    Table: Traffic

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| user_id       | int     |
    -| activity      | enum    |
    -| activity_date | date    |
    -+---------------+---------+
    -There is no primary key for this table, it may have duplicate rows.
    -The activity column is an ENUM type of ('login', 'logout', 'jobs', 'groups', 'homepage').
    -
    -

     

    - -

    Write an SQL query that reports for every date within at most 90 days from today, the number of users that logged in for the first time on that date. Assume today is 2019-06-30.

    - -

    The query result format is in the following example:

    - -
    -Traffic table:
    -+---------+----------+---------------+
    -| user_id | activity | activity_date |
    -+---------+----------+---------------+
    -| 1       | login    | 2019-05-01    |
    -| 1       | homepage | 2019-05-01    |
    -| 1       | logout   | 2019-05-01    |
    -| 2       | login    | 2019-06-21    |
    -| 2       | logout   | 2019-06-21    |
    -| 3       | login    | 2019-01-01    |
    -| 3       | jobs     | 2019-01-01    |
    -| 3       | logout   | 2019-01-01    |
    -| 4       | login    | 2019-06-21    |
    -| 4       | groups   | 2019-06-21    |
    -| 4       | logout   | 2019-06-21    |
    -| 5       | login    | 2019-03-01    |
    -| 5       | logout   | 2019-03-01    |
    -| 5       | login    | 2019-06-21    |
    -| 5       | logout   | 2019-06-21    |
    -+---------+----------+---------------+
    -
    -Result table:
    -+------------+-------------+
    -| login_date | user_count  |
    -+------------+-------------+
    -| 2019-05-01 | 1           |
    -| 2019-06-21 | 2           |
    -+------------+-------------+
    -Note that we only care about dates with non zero user count.
    -The user with id 5 first logged in on 2019-03-01 so he's not counted on 2019-06-21.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/next-closest-time/README.md b/problems/next-closest-time/README.md index 2971f096b..216e64318 100644 --- a/problems/next-closest-time/README.md +++ b/problems/next-closest-time/README.md @@ -11,25 +11,8 @@ ## [681. Next Closest Time (Medium)](https://leetcode.com/problems/next-closest-time "最近时刻") -

    Given a time represented in the format "HH:MM", form the next closest time by reusing the current digits. There is no limit on how many times a digit can be reused.

    -

    You may assume the given input string is always valid. For example, "01:34", "12:09" are all valid. "1:34", "12:9" are all invalid.

    - -

    Example 1: -

    -Input: "19:34"
    -Output: "19:39"
    -Explanation: The next closest time choosing from digits 1, 9, 3, 4, is 19:39, which occurs 5 minutes later.  It is not 19:33, because this occurs 23 hours and 59 minutes later.
    -
    -

    - -

    Example 2: -

    -Input: "23:59"
    -Output: "22:22"
    -Explanation: The next closest time choosing from digits 2, 3, 5, 9, is 22:22. It may be assumed that the returned time is next day's time since it is smaller than the input time numerically.
    -
    -

    ### Related Topics [[String](../../tag/string/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] diff --git a/problems/next-greater-element-i/README.md b/problems/next-greater-element-i/README.md index 261f7079b..834144f2f 100644 --- a/problems/next-greater-element-i/README.md +++ b/problems/next-greater-element-i/README.md @@ -11,11 +11,13 @@ ## [496. Next Greater Element I (Easy)](https://leetcode.com/problems/next-greater-element-i "下一个更大元素 I") -

    You are given two integer arrays nums1 and nums2 both of unique elements, where nums1 is a subset of nums2.

    +

    The next greater element of some element x in an array is the first greater element that is to the right of x in the same array.

    -

    Find all the next greater numbers for nums1's elements in the corresponding places of nums2.

    +

    You are given two distinct 0-indexed integer arrays nums1 and nums2, where nums1 is a subset of nums2.

    -

    The Next Greater Number of a number x in nums1 is the first greater number to its right in nums2. If it does not exist, return -1 for this number.

    +

    For each 0 <= i < nums1.length, find the index j such that nums1[i] == nums2[j] and determine the next greater element of nums2[j] in nums2. If there is no next greater element, then the answer for this query is -1.

    + +

    Return an array ans of length nums1.length such that ans[i] is the next greater element as described above.

     

    Example 1:

    @@ -23,19 +25,21 @@
     Input: nums1 = [4,1,2], nums2 = [1,3,4,2]
     Output: [-1,3,-1]
    -Explanation:
    -For number 4 in the first array, you cannot find the next greater number for it in the second array, so output -1.
    -For number 1 in the first array, the next greater number for it in the second array is 3.
    -For number 2 in the first array, there is no next greater number for it in the second array, so output -1.
    +Explanation: The next greater element for each value of nums1 is as follows: +- 4 is underlined in nums2 = [1,3,4,2]. There is no next greater element, so the answer is -1. +- 1 is underlined in nums2 = [1,3,4,2]. The next greater element is 3. +- 2 is underlined in nums2 = [1,3,4,2]. There is no next greater element, so the answer is -1. +

    Example 2:

     Input: nums1 = [2,4], nums2 = [1,2,3,4]
     Output: [3,-1]
    -Explanation:
    -For number 2 in the first array, the next greater number for it in the second array is 3.
    -For number 4 in the first array, there is no next greater number for it in the second array, so output -1.
    +Explanation: The next greater element for each value of nums1 is as follows: +- 2 is underlined in nums2 = [1,2,3,4]. The next greater element is 3. +- 4 is underlined in nums2 = [1,2,3,4]. There is no next greater element, so the answer is -1. +

     

    Constraints:

    @@ -52,6 +56,9 @@ For number 4 in the first array, there is no next greater number for it in the s ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Similar Questions 1. [Next Greater Element II](../next-greater-element-ii) (Medium) diff --git a/problems/next-greater-element-ii/README.md b/problems/next-greater-element-ii/README.md index dcda8cac9..1007b9d8a 100644 --- a/problems/next-greater-element-ii/README.md +++ b/problems/next-greater-element-ii/README.md @@ -43,6 +43,8 @@ The second 1's next greater number needs to search circularly, which is also ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Similar Questions 1. [Next Greater Element I](../next-greater-element-i) (Easy) diff --git a/problems/next-greater-element-iii/README.md b/problems/next-greater-element-iii/README.md index ca7c28805..a5dfc606b 100644 --- a/problems/next-greater-element-iii/README.md +++ b/problems/next-greater-element-iii/README.md @@ -31,6 +31,8 @@ ### Related Topics + [[Math](../../tag/math/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/next-greater-node-in-linked-list/README.md b/problems/next-greater-node-in-linked-list/README.md index 0e9acc0b4..4b574aeab 100644 --- a/problems/next-greater-node-in-linked-list/README.md +++ b/problems/next-greater-node-in-linked-list/README.md @@ -59,7 +59,9 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints
    diff --git a/problems/next-palindrome-using-same-digits/README.md b/problems/next-palindrome-using-same-digits/README.md index 8ccfec3cc..53bbc8357 100644 --- a/problems/next-palindrome-using-same-digits/README.md +++ b/problems/next-palindrome-using-same-digits/README.md @@ -9,12 +9,13 @@                  [Next >](../suspicious-bank-accounts "Suspicious Bank Accounts") -## [1842. Next Palindrome Using Same Digits (Hard)](https://leetcode.com/problems/next-palindrome-using-same-digits "") +## [1842. Next Palindrome Using Same Digits (Hard)](https://leetcode.com/problems/next-palindrome-using-same-digits "下个由相同数字构成的回文串") ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/next-permutation/README.md b/problems/next-permutation/README.md index ea584cb89..b85f403e3 100644 --- a/problems/next-permutation/README.md +++ b/problems/next-permutation/README.md @@ -41,6 +41,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions 1. [Permutations](../permutations) (Medium) diff --git a/problems/nim-game/README.md b/problems/nim-game/README.md index f4aa57c9e..777bf5b83 100644 --- a/problems/nim-game/README.md +++ b/problems/nim-game/README.md @@ -58,7 +58,8 @@ In all outcomes, your friend wins. ### Related Topics [[Brainteaser](../../tag/brainteaser/README.md)] - [[Minimax](../../tag/minimax/README.md)] + [[Math](../../tag/math/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] ### Similar Questions 1. [Flip Game II](../flip-game-ii) (Medium) diff --git a/problems/non-decreasing-array/README.md b/problems/non-decreasing-array/README.md index 2978ce872..de826c401 100644 --- a/problems/non-decreasing-array/README.md +++ b/problems/non-decreasing-array/README.md @@ -9,7 +9,7 @@                  [Next >](../path-sum-iv "Path Sum IV") -## [665. Non-decreasing Array (Easy)](https://leetcode.com/problems/non-decreasing-array "非递减数列") +## [665. Non-decreasing Array (Medium)](https://leetcode.com/problems/non-decreasing-array "非递减数列")

    Given an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most one element.

    diff --git a/problems/non-overlapping-intervals/README.md b/problems/non-overlapping-intervals/README.md index fd72c519a..e01a5b9a7 100644 --- a/problems/non-overlapping-intervals/README.md +++ b/problems/non-overlapping-intervals/README.md @@ -49,6 +49,9 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Minimum Number of Arrows to Burst Balloons](../minimum-number-of-arrows-to-burst-balloons) (Medium) diff --git a/problems/not-boring-movies/README.md b/problems/not-boring-movies/README.md index 03bf934fa..7af6c6351 100644 --- a/problems/not-boring-movies/README.md +++ b/problems/not-boring-movies/README.md @@ -58,3 +58,6 @@ Result table: +----+------------+-------------+--------+ We have three movies with odd-numbered ID: 1, 3, and 5. The movie with ID = 3 is boring so we don't include it in the answer. + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/npv-queries/README.md b/problems/npv-queries/README.md index 91c34c7b9..70c027462 100644 --- a/problems/npv-queries/README.md +++ b/problems/npv-queries/README.md @@ -12,3 +12,6 @@ ## [1421. NPV Queries (Medium)](https://leetcode.com/problems/npv-queries "净现值查询") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/nth-digit/README.md b/problems/nth-digit/README.md index 401d46f96..2edcbf0c7 100644 --- a/problems/nth-digit/README.md +++ b/problems/nth-digit/README.md @@ -38,3 +38,4 @@ ### Related Topics [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/nth-highest-salary/README.md b/problems/nth-highest-salary/README.md index 98fac1c6c..ece613a10 100644 --- a/problems/nth-highest-salary/README.md +++ b/problems/nth-highest-salary/README.md @@ -32,3 +32,6 @@ | 200 | +------------------------+ + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/number-of-atoms/README.md b/problems/number-of-atoms/README.md index 3103dce90..0019c59b2 100644 --- a/problems/number-of-atoms/README.md +++ b/problems/number-of-atoms/README.md @@ -11,19 +11,29 @@ ## [726. Number of Atoms (Hard)](https://leetcode.com/problems/number-of-atoms "原子的数量") -

    Given a chemical formula (given as a string), return the count of each atom.

    +

    Given a string formula representing a chemical formula, return the count of each atom.

    The atomic element always starts with an uppercase character, then zero or more lowercase letters, representing the name.

    -

    One or more digits representing that element's count may follow if the count is greater than 1. If the count is 1, no digits will follow. For example, H2O and H2O2 are possible, but H1O2 is impossible.

    +

    One or more digits representing that element's count may follow if the count is greater than 1. If the count is 1, no digits will follow.

    -

    Two formulas concatenated together to produce another formula. For example, H2O2He3Mg4 is also a formula.

    +
      +
    • For example, "H2O" and "H2O2" are possible, but "H1O2" is impossible.
    • +
    -

    A formula placed in parentheses, and a count (optionally added) is also a formula. For example, (H2O2) and (H2O2)3 are formulas.

    +

    Two formulas are concatenated together to produce another formula.

    -

    Given a formula, return the count of all elements as a string in the following form: the first name (in sorted order), followed by its count (if that count is more than 1), followed by the second name (in sorted order), followed by its count (if that count is more than 1), and so on.

    +
      +
    • For example, "H2O2He3Mg4" is also a formula.
    • +
    -

     

    +

    A formula placed in parentheses, and a count (optionally added) is also a formula.

    + +
      +
    • For example, "(H2O2)" and "(H2O2)3" are formulas.
    • +
    + +

    Return the count of all elements as a string in the following form: the first name (in sorted order), followed by its count (if that count is more than 1), followed by the second name (in sorted order), followed by its count (if that count is more than 1), and so on.

     

    Example 1:

    @@ -64,12 +74,13 @@
  • 1 <= formula.length <= 1000
  • formula consists of English letters, digits, '(', and ')'.
  • formula is always valid.
  • +
  • All the values in the output will fit in a 32-bit integer.
  • ### Related Topics [[Stack](../../tag/stack/README.md)] - [[Recursion](../../tag/recursion/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Decode String](../decode-string) (Medium) diff --git a/problems/number-of-boomerangs/README.md b/problems/number-of-boomerangs/README.md index 3e22c4dd8..09da47c42 100644 --- a/problems/number-of-boomerangs/README.md +++ b/problems/number-of-boomerangs/README.md @@ -50,6 +50,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/number-of-burgers-with-no-waste-of-ingredients/README.md b/problems/number-of-burgers-with-no-waste-of-ingredients/README.md index b2ab77f09..2d56fac68 100644 --- a/problems/number-of-burgers-with-no-waste-of-ingredients/README.md +++ b/problems/number-of-burgers-with-no-waste-of-ingredients/README.md @@ -68,7 +68,6 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] ### Hints diff --git a/problems/number-of-calls-between-two-persons/README.md b/problems/number-of-calls-between-two-persons/README.md index 383969902..431f2c375 100644 --- a/problems/number-of-calls-between-two-persons/README.md +++ b/problems/number-of-calls-between-two-persons/README.md @@ -12,3 +12,6 @@ ## [1699. Number of Calls Between Two Persons (Medium)](https://leetcode.com/problems/number-of-calls-between-two-persons "两人之间的通话次数") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/number-of-closed-islands/README.md b/problems/number-of-closed-islands/README.md index f959a2ae7..01c2cafea 100644 --- a/problems/number-of-closed-islands/README.md +++ b/problems/number-of-closed-islands/README.md @@ -57,7 +57,11 @@ Islands in gray are closed because they are completely surrounded by water (grou ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/number-of-comments-per-post/README.md b/problems/number-of-comments-per-post/README.md index af1169aa8..6864513c4 100644 --- a/problems/number-of-comments-per-post/README.md +++ b/problems/number-of-comments-per-post/README.md @@ -11,60 +11,7 @@ ## [1241. Number of Comments per Post (Easy)](https://leetcode.com/problems/number-of-comments-per-post "每个帖子的评论数") -

    Table: Submissions

    -
    +---------------+----------+
    -| Column Name   | Type     |
    -+---------------+----------+
    -| sub_id        | int      |
    -| parent_id     | int      |
    -+---------------+----------+
    -There is no primary key for this table, it may have duplicate rows.
    -Each row can be a post or comment on the post.
    -parent_id is null for posts.
    -parent_id for comments is sub_id for another post in the table.
    -
    -

     

    - -

    Write an SQL query to find number of comments per each post.

    - -

    Result table should contain post_id and its corresponding number_of_comments, and must be sorted by post_id in ascending order.

    - -

    Submissions may contain duplicate comments. You should count the number of unique comments per post.

    - -

    Submissions may contain duplicate posts. You should treat them as one post.

    - -

    The query result format is in the following example:

    - -
    Submissions table:
    -+---------+------------+
    -| sub_id  | parent_id  |
    -+---------+------------+
    -| 1       | Null       |
    -| 2       | Null       |
    -| 1       | Null       |
    -| 12      | Null       |
    -| 3       | 1          |
    -| 5       | 2          |
    -| 3       | 1          |
    -| 4       | 1          |
    -| 9       | 1          |
    -| 10      | 2          |
    -| 6       | 7          |
    -+---------+------------+
    -
    -Result table:
    -+---------+--------------------+
    -| post_id | number_of_comments |
    -+---------+--------------------+
    -| 1       | 3                  |
    -| 2       | 2                  |
    -| 12      | 0                  |
    -+---------+--------------------+
    -
    -The post with id 1 has three comments in the table with id 3, 4 and 9. The comment with id 3 is repeated in the table, we counted it only once.
    -The post with id 2 has two comments in the table with id 5 and 10.
    -The post with id 12 has no comments in the table.
    -The comment with id 6 is a comment on a deleted post with id 7 so we ignored it.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/number-of-connected-components-in-an-undirected-graph/README.md b/problems/number-of-connected-components-in-an-undirected-graph/README.md index e2b2c8bfa..c8b38432b 100644 --- a/problems/number-of-connected-components-in-an-undirected-graph/README.md +++ b/problems/number-of-connected-components-in-an-undirected-graph/README.md @@ -11,38 +11,11 @@ ## [323. Number of Connected Components in an Undirected Graph (Medium)](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph "无向图中连通分量的数目") -

    Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected components in an undirected graph.

    -

    Example 1:

    - -
    -Input: n = 5 and edges = [[0, 1], [1, 2], [3, 4]]
    -
    -     0          3
    -     |          |
    -     1 --- 2    4 
    -
    -Output: 2
    -
    - -

    Example 2:

    - -
    -Input: n = 5 and edges = [[0, 1], [1, 2], [2, 3], [3, 4]]
    -
    -     0           4
    -     |           |
    -     1 --- 2 --- 3
    -
    -Output:  1
    -
    - -

    Note:
    -You can assume that no duplicate edges will appear in edges. Since all edges are undirected, [0, 1] is the same as [1, 0] and thus will not appear together in edges.

    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] diff --git a/problems/number-of-corner-rectangles/README.md b/problems/number-of-corner-rectangles/README.md index 3daba39d4..33e7c5d45 100644 --- a/problems/number-of-corner-rectangles/README.md +++ b/problems/number-of-corner-rectangles/README.md @@ -11,62 +11,13 @@ ## [750. Number Of Corner Rectangles (Medium)](https://leetcode.com/problems/number-of-corner-rectangles "角矩形的数量") -

    Given a grid where each entry is only 0 or 1, find the number of corner rectangles.

    -

    A corner rectangle is 4 distinct 1s on the grid that form an axis-aligned rectangle. Note that only the corners need to have the value 1. Also, all four 1s used must be distinct.

    - -

     

    - -

    Example 1:

    - -
    -Input: grid = 
    -[[1, 0, 0, 1, 0],
    - [0, 0, 1, 0, 1],
    - [0, 0, 0, 1, 0],
    - [1, 0, 1, 0, 1]]
    -Output: 1
    -Explanation: There is only one corner rectangle, with corners grid[1][2], grid[1][4], grid[3][2], grid[3][4].
    -
    - -

     

    - -

    Example 2:

    - -
    -Input: grid = 
    -[[1, 1, 1],
    - [1, 1, 1],
    - [1, 1, 1]]
    -Output: 9
    -Explanation: There are four 2x2 rectangles, four 2x3 and 3x2 rectangles, and one 3x3 rectangle.
    -
    - -

     

    - -

    Example 3:

    - -
    -Input: grid = 
    -[[1, 1, 1, 1]]
    -Output: 0
    -Explanation: Rectangles must have four distinct corners.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. The number of rows and columns of grid will each be in the range [1, 200].
    2. -
    3. Each grid[i][j] will be either 0 or 1.
    4. -
    5. The number of 1s in the grid will be at most 6000.
    6. -
    - -

     

    ### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/number-of-days-between-two-dates/README.md b/problems/number-of-days-between-two-dates/README.md index ebc0d0775..ade5f0f63 100644 --- a/problems/number-of-days-between-two-dates/README.md +++ b/problems/number-of-days-between-two-dates/README.md @@ -30,6 +30,10 @@
  • The given dates are valid dates between the years 1971 and 2100.
  • +### Related Topics + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + ### Hints
    Hint 1 diff --git a/problems/number-of-days-in-a-month/README.md b/problems/number-of-days-in-a-month/README.md index 749631781..4dad06f61 100644 --- a/problems/number-of-days-in-a-month/README.md +++ b/problems/number-of-days-in-a-month/README.md @@ -11,39 +11,10 @@ ## [1118. Number of Days in a Month (Easy)](https://leetcode.com/problems/number-of-days-in-a-month "一月有多少天") -

    Given a year Y and a month M, return how many days there are in that month.

    -

     

    -

    Example 1:

    - -
    -Input: Y = 1992, M = 7
    -Output: 31
    -
    - -

    Example 2:

    - -
    -Input: Y = 2000, M = 2
    -Output: 29
    -
    - -

    Example 3:

    - -
    -Input: Y = 1900, M = 2
    -Output: 28
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1583 <= Y <= 2100
    2. -
    3. 1 <= M <= 12
    4. -
    +### Related Topics + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/number-of-different-integers-in-a-string/README.md b/problems/number-of-different-integers-in-a-string/README.md index ed632b793..ef92569f3 100644 --- a/problems/number-of-different-integers-in-a-string/README.md +++ b/problems/number-of-different-integers-in-a-string/README.md @@ -53,6 +53,7 @@ the leading zeros are ignored when comparing their decimal values. ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/number-of-different-subsequences-gcds/README.md b/problems/number-of-different-subsequences-gcds/README.md index 37eaa94b7..e2b2407fc 100644 --- a/problems/number-of-different-subsequences-gcds/README.md +++ b/problems/number-of-different-subsequences-gcds/README.md @@ -53,7 +53,10 @@ The different GCDs are 6, 10, 3, 2, and 1. ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Number Theory](../../tag/number-theory/README.md)] ### Hints
    diff --git a/problems/number-of-digit-one/README.md b/problems/number-of-digit-one/README.md index 7c3ca78c1..79ca7fbd5 100644 --- a/problems/number-of-digit-one/README.md +++ b/problems/number-of-digit-one/README.md @@ -32,11 +32,13 @@

    Constraints:

      -
    • 0 <= n <= 2 * 109
    • +
    • 0 <= n <= 109
    ### Related Topics + [[Recursion](../../tag/recursion/README.md)] [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Factorial Trailing Zeroes](../factorial-trailing-zeroes) (Easy) diff --git a/problems/number-of-distinct-islands-ii/README.md b/problems/number-of-distinct-islands-ii/README.md index 16b2f586f..b1c05b730 100644 --- a/problems/number-of-distinct-islands-ii/README.md +++ b/problems/number-of-distinct-islands-ii/README.md @@ -11,71 +11,14 @@ ## [711. Number of Distinct Islands II (Hard)](https://leetcode.com/problems/number-of-distinct-islands-ii "不同岛屿的数量 II") -

    Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.

    -

    Count the number of distinct islands. An island is considered to be the same as another if they have the same shape, or have the same shape after rotation (90, 180, or 270 degrees only) or reflection (left/right direction or up/down direction).

    - -

    Example 1:
    -

    -11000
    -10000
    -00001
    -00011
    -
    -Given the above grid map, return 1. -

    -Notice that: -
    -11
    -1
    -
    -and -
    - 1
    -11
    -
    -are considered same island shapes. Because if we make a 180 degrees clockwise rotation on the first island, then two islands will have the same shapes. -

    - -

    Example 2:
    -

    -11100
    -10001
    -01001
    -01110
    -Given the above grid map, return 2.
    -
    -Here are the two distinct islands: -
    -111
    -1
    -
    -and -
    -1
    -1
    -
    -
    -Notice that: -
    -111
    -1
    -
    -and -
    -1
    -111
    -
    -are considered same island shapes. Because if we flip the first array in the up/down direction, then they have the same shapes. -

    - -

    Note: -The length of each dimension in the given grid does not exceed 50. -

    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Similar Questions 1. [Number of Distinct Islands](../number-of-distinct-islands) (Medium) diff --git a/problems/number-of-distinct-islands/README.md b/problems/number-of-distinct-islands/README.md index f3988ddb0..f48650134 100644 --- a/problems/number-of-distinct-islands/README.md +++ b/problems/number-of-distinct-islands/README.md @@ -11,47 +11,14 @@ ## [694. Number of Distinct Islands (Medium)](https://leetcode.com/problems/number-of-distinct-islands "不同岛屿的数量") -

    Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.

    -

    Count the number of distinct islands. An island is considered to be the same as another if and only if one island can be translated (and not rotated or reflected) to equal the other.

    - -

    Example 1:
    -

    -11000
    -11000
    -00011
    -00011
    -
    -Given the above grid map, return 1. -

    - -

    Example 2:
    -

    11011
    -10000
    -00001
    -11011
    -Given the above grid map, return 3.

    -Notice that: -
    -11
    -1
    -
    -and -
    - 1
    -11
    -
    -are considered different island shapes, because we do not consider reflection / rotation. -

    - -

    Note: -The length of each dimension in the given grid does not exceed 50. -

    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Similar Questions 1. [Number of Islands](../number-of-islands) (Medium) diff --git a/problems/number-of-distinct-substrings-in-a-string/README.md b/problems/number-of-distinct-substrings-in-a-string/README.md index 02c8eb32f..ed9bc0d15 100644 --- a/problems/number-of-distinct-substrings-in-a-string/README.md +++ b/problems/number-of-distinct-substrings-in-a-string/README.md @@ -16,6 +16,9 @@ ### Related Topics [[Trie](../../tag/trie/README.md)] [[String](../../tag/string/README.md)] + [[Suffix Array](../../tag/suffix-array/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/number-of-enclaves/README.md b/problems/number-of-enclaves/README.md index 8efe7a5cf..7a7d21404 100644 --- a/problems/number-of-enclaves/README.md +++ b/problems/number-of-enclaves/README.md @@ -45,7 +45,11 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/number-of-equivalent-domino-pairs/README.md b/problems/number-of-equivalent-domino-pairs/README.md index 822b0b648..28796636b 100644 --- a/problems/number-of-equivalent-domino-pairs/README.md +++ b/problems/number-of-equivalent-domino-pairs/README.md @@ -30,6 +30,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/number-of-good-leaf-nodes-pairs/README.md b/problems/number-of-good-leaf-nodes-pairs/README.md index b8110dc2e..36b330f20 100644 --- a/problems/number-of-good-leaf-nodes-pairs/README.md +++ b/problems/number-of-good-leaf-nodes-pairs/README.md @@ -65,7 +65,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/number-of-good-pairs/README.md b/problems/number-of-good-pairs/README.md index 25ba13da7..4040f598b 100644 --- a/problems/number-of-good-pairs/README.md +++ b/problems/number-of-good-pairs/README.md @@ -53,6 +53,7 @@ [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/number-of-good-ways-to-split-a-string/README.md b/problems/number-of-good-ways-to-split-a-string/README.md index a858f007b..2001e985a 100644 --- a/problems/number-of-good-ways-to-split-a-string/README.md +++ b/problems/number-of-good-ways-to-split-a-string/README.md @@ -62,6 +62,7 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/number-of-islands-ii/README.md b/problems/number-of-islands-ii/README.md index 3c9b2b9fd..4229231a6 100644 --- a/problems/number-of-islands-ii/README.md +++ b/problems/number-of-islands-ii/README.md @@ -11,63 +11,11 @@ ## [305. Number of Islands II (Hard)](https://leetcode.com/problems/number-of-islands-ii "岛屿数量 II") -

    A 2d grid map of m rows and n columns is initially filled with water. We may perform an addLand operation which turns the water at position (row, col) into a land. Given a list of positions to operate, count the number of islands after each addLand operation. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.

    -

    Example:

    - -
    -Input: m = 3, n = 3, positions = [[0,0], [0,1], [1,2], [2,1]]
    -Output: [1,1,2,3]
    -
    - -

    Explanation:

    - -

    Initially, the 2d grid grid is filled with water. (Assume 0 represents water and 1 represents land).

    - -
    -0 0 0
    -0 0 0
    -0 0 0
    -
    - -

    Operation #1: addLand(0, 0) turns the water at grid[0][0] into a land.

    - -
    -1 0 0
    -0 0 0   Number of islands = 1
    -0 0 0
    -
    - -

    Operation #2: addLand(0, 1) turns the water at grid[0][1] into a land.

    - -
    -1 1 0
    -0 0 0   Number of islands = 1
    -0 0 0
    -
    - -

    Operation #3: addLand(1, 2) turns the water at grid[1][2] into a land.

    - -
    -1 1 0
    -0 0 1   Number of islands = 2
    -0 0 0
    -
    - -

    Operation #4: addLand(2, 1) turns the water at grid[2][1] into a land.

    - -
    -1 1 0
    -0 0 1   Number of islands = 3
    -0 1 0
    -
    - -

    Follow up:

    - -

    Can you do it in time complexity O(k log mn), where k is the length of the positions?

    ### Related Topics [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions 1. [Number of Islands](../number-of-islands) (Medium) diff --git a/problems/number-of-islands/README.md b/problems/number-of-islands/README.md index e39630a2b..4b45db33a 100644 --- a/problems/number-of-islands/README.md +++ b/problems/number-of-islands/README.md @@ -51,9 +51,11 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Surrounded Regions](../surrounded-regions) (Medium) diff --git a/problems/number-of-lines-to-write-string/README.md b/problems/number-of-lines-to-write-string/README.md index df7454057..bff49cf49 100644 --- a/problems/number-of-lines-to-write-string/README.md +++ b/problems/number-of-lines-to-write-string/README.md @@ -53,3 +53,7 @@ There are a total of 2 lines, and the last line is 4 pixels wide.
  • 1 <= s.length <= 1000
  • s contains only lowercase English letters.
  • + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/number-of-longest-increasing-subsequence/README.md b/problems/number-of-longest-increasing-subsequence/README.md index 452a7bc8e..cb26b44e1 100644 --- a/problems/number-of-longest-increasing-subsequence/README.md +++ b/problems/number-of-longest-increasing-subsequence/README.md @@ -42,6 +42,9 @@ ### Related Topics + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/number-of-matching-subsequences/README.md b/problems/number-of-matching-subsequences/README.md index 383d1cc65..b9a9e5cd2 100644 --- a/problems/number-of-matching-subsequences/README.md +++ b/problems/number-of-matching-subsequences/README.md @@ -46,7 +46,10 @@ ### Related Topics - [[Array](../../tag/array/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Is Subsequence](../is-subsequence) (Easy) diff --git a/problems/number-of-music-playlists/README.md b/problems/number-of-music-playlists/README.md index 15f82633b..4f5626237 100644 --- a/problems/number-of-music-playlists/README.md +++ b/problems/number-of-music-playlists/README.md @@ -65,4 +65,6 @@
    ### Related Topics + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Combinatorics](../../tag/combinatorics/README.md)] diff --git a/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md b/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md index db85cd18a..b689df9f5 100644 --- a/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md +++ b/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md @@ -75,8 +75,9 @@ The sub-tree of node 0 contains nodes 0, 1, 2 and 3, all with label 'b', ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Hints
    diff --git a/problems/number-of-operations-to-make-network-connected/README.md b/problems/number-of-operations-to-make-network-connected/README.md index b7c2144ba..68f9686b0 100644 --- a/problems/number-of-operations-to-make-network-connected/README.md +++ b/problems/number-of-operations-to-make-network-connected/README.md @@ -64,9 +64,10 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] ### Hints
    diff --git a/problems/number-of-orders-in-the-backlog/README.md b/problems/number-of-orders-in-the-backlog/README.md index 36a25dd1d..3a917b5d9 100644 --- a/problems/number-of-orders-in-the-backlog/README.md +++ b/problems/number-of-orders-in-the-backlog/README.md @@ -67,8 +67,9 @@ Finally, the backlog has (1000000000-3) sell orders with price 7, and (999999995 ### Related Topics - [[Heap](../../tag/heap/README.md)] - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/number-of-paths-with-max-score/README.md b/problems/number-of-paths-with-max-score/README.md index b6d1d5790..b18be23d3 100644 --- a/problems/number-of-paths-with-max-score/README.md +++ b/problems/number-of-paths-with-max-score/README.md @@ -38,7 +38,9 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/number-of-provinces/README.md b/problems/number-of-provinces/README.md index cd0364d15..e55fc5326 100644 --- a/problems/number-of-provinces/README.md +++ b/problems/number-of-provinces/README.md @@ -47,8 +47,10 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] ### Similar Questions 1. [Number of Connected Components in an Undirected Graph](../number-of-connected-components-in-an-undirected-graph) (Medium) diff --git a/problems/number-of-recent-calls/README.md b/problems/number-of-recent-calls/README.md index 9fedfb406..5725fbc5e 100644 --- a/problems/number-of-recent-calls/README.md +++ b/problems/number-of-recent-calls/README.md @@ -50,4 +50,6 @@ recentCounter.ping(3002); // requests = [1, 100, 3001, 3002 ### Related Topics + [[Design](../../tag/design/README.md)] [[Queue](../../tag/queue/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] diff --git a/problems/number-of-rectangles-that-can-form-the-largest-square/README.md b/problems/number-of-rectangles-that-can-form-the-largest-square/README.md index 282ba3127..f478cd3a1 100644 --- a/problems/number-of-rectangles-that-can-form-the-largest-square/README.md +++ b/problems/number-of-rectangles-that-can-form-the-largest-square/README.md @@ -47,7 +47,7 @@ The largest possible square is of length 5, and you can get it out of 3 rectangl ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/number-of-restricted-paths-from-first-to-last-node/README.md b/problems/number-of-restricted-paths-from-first-to-last-node/README.md index 17d6a7a58..6482427e7 100644 --- a/problems/number-of-restricted-paths-from-first-to-last-node/README.md +++ b/problems/number-of-restricted-paths-from-first-to-last-node/README.md @@ -55,7 +55,10 @@ ### Related Topics [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md b/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md index 506692891..449b22cf6 100644 --- a/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md +++ b/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md @@ -63,6 +63,7 @@ The image above shows the 5 different ways {(0,2),(2,3)}, {(0,1),(1,3)}, {(0,1), ### Related Topics + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/number-of-ships-in-a-rectangle/README.md b/problems/number-of-ships-in-a-rectangle/README.md index 3e3c6bf7a..50ffdb7a4 100644 --- a/problems/number-of-ships-in-a-rectangle/README.md +++ b/problems/number-of-ships-in-a-rectangle/README.md @@ -11,39 +11,12 @@ ## [1274. Number of Ships in a Rectangle (Hard)](https://leetcode.com/problems/number-of-ships-in-a-rectangle "矩形内船只的数目") -

    (This problem is an interactive problem.)

    -

    On the sea represented by a cartesian plane, each ship is located at an integer point, and each integer point may contain at most 1 ship.

    - -

    You have a function Sea.hasShips(topRight, bottomLeft) which takes two points as arguments and returns true if and only if there is at least one ship in the rectangle represented by the two points, including on the boundary.

    - -

    Given two points, which are the top right and bottom left corners of a rectangle, return the number of ships present in that rectangle.  It is guaranteed that there are at most 10 ships in that rectangle.

    - -

    Submissions making more than 400 calls to hasShips will be judged Wrong Answer.  Also, any solutions that attempt to circumvent the judge will result in disqualification.

    - -

     

    -

    Example :

    - -

    - -
    -Input: 
    -ships = [[1,1],[2,2],[3,3],[5,5]], topRight = [4,4], bottomLeft = [0,0]
    -Output: 3
    -Explanation: From [0,0] to [4,4] we can count 3 ships within the range.
    -
    - -

     

    -

    Constraints:

    - -
      -
    • On the input ships is only given to initialize the map internally. You must solve this problem "blindfolded". In other words, you must find the answer using the given hasShips API, without knowing the ships position.
    • -
    • 0 <= bottomLeft[0] <= topRight[0] <= 1000
    • -
    • 0 <= bottomLeft[1] <= topRight[1] <= 1000
    • -
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Interactive](../../tag/interactive/README.md)] ### Hints
    diff --git a/problems/number-of-squareful-arrays/README.md b/problems/number-of-squareful-arrays/README.md index 8457dde14..5e8390b3d 100644 --- a/problems/number-of-squareful-arrays/README.md +++ b/problems/number-of-squareful-arrays/README.md @@ -43,9 +43,12 @@ ### Related Topics - [[Graph](../../tag/graph/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Similar Questions 1. [Permutations II](../permutations-ii) (Medium) diff --git a/problems/number-of-steps-to-reduce-a-number-to-zero/README.md b/problems/number-of-steps-to-reduce-a-number-to-zero/README.md index e32d8d282..9b1594ff3 100644 --- a/problems/number-of-steps-to-reduce-a-number-to-zero/README.md +++ b/problems/number-of-steps-to-reduce-a-number-to-zero/README.md @@ -56,6 +56,7 @@ Step 4) 1 is odd; subtract 1 and obtain 0. ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/number-of-students-unable-to-eat-lunch/README.md b/problems/number-of-students-unable-to-eat-lunch/README.md index 8e0012d46..eb9a4f00d 100644 --- a/problems/number-of-students-unable-to-eat-lunch/README.md +++ b/problems/number-of-students-unable-to-eat-lunch/README.md @@ -60,7 +60,10 @@ Hence all students are able to eat. ### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md b/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md index 8049a016c..0f6665efe 100644 --- a/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md +++ b/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md @@ -65,6 +65,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/number-of-sub-arrays-with-odd-sum/README.md b/problems/number-of-sub-arrays-with-odd-sum/README.md index 719fd3b66..fcc492d90 100644 --- a/problems/number-of-sub-arrays-with-odd-sum/README.md +++ b/problems/number-of-sub-arrays-with-odd-sum/README.md @@ -68,6 +68,8 @@ All sub-arrays have even sum and the answer is 0. ### Related Topics [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/number-of-subarrays-with-bounded-maximum/README.md b/problems/number-of-subarrays-with-bounded-maximum/README.md index ad4fda974..24d460568 100644 --- a/problems/number-of-subarrays-with-bounded-maximum/README.md +++ b/problems/number-of-subarrays-with-bounded-maximum/README.md @@ -11,26 +11,35 @@ ## [795. Number of Subarrays with Bounded Maximum (Medium)](https://leetcode.com/problems/number-of-subarrays-with-bounded-maximum "区间子数组个数") -

    We are given an array nums of positive integers, and two positive integers left and right (left <= right).

    +

    Given an integer array nums and two integers left and right, return the number of contiguous non-empty subarrays such that the value of the maximum array element in that subarray is in the range [left, right].

    -

    Return the number of (contiguous, non-empty) subarrays such that the value of the maximum array element in that subarray is at least left and at most right.

    +

    The test cases are generated so that the answer will fit in a 32-bit integer.

    + +

     

    +

    Example 1:

    -Example:
    -Input: 
    -nums = [2, 1, 4, 3]
    -left = 2
    -right = 3
    +Input: nums = [2,1,4,3], left = 2, right = 3
     Output: 3
     Explanation: There are three subarrays that meet the requirements: [2], [2, 1], [3].
     
    -

    Note:

    +

    Example 2:

    + +
    +Input: nums = [2,9,2,5,6], left = 2, right = 8
    +Output: 7
    +
    + +

     

    +

    Constraints:

      -
    • left, right, and nums[i] will be an integer in the range [0, 109].
    • -
    • The length of nums will be in the range of [1, 50000].
    • +
    • 1 <= nums.length <= 105
    • +
    • 0 <= nums[i] <= 109
    • +
    • 0 <= left <= right <= 109
    ### Related Topics [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/number-of-submatrices-that-sum-to-target/README.md b/problems/number-of-submatrices-that-sum-to-target/README.md index df3becaef..b9b2aebe9 100644 --- a/problems/number-of-submatrices-that-sum-to-target/README.md +++ b/problems/number-of-submatrices-that-sum-to-target/README.md @@ -53,8 +53,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md b/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md index 930c50e72..d049a56a9 100644 --- a/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md +++ b/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md @@ -62,8 +62,10 @@ Number of valid subsequences (63 - 2 = 61). ### Related Topics - [[Sort](../../tag/sort/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/number-of-substrings-containing-all-three-characters/README.md b/problems/number-of-substrings-containing-all-three-characters/README.md index 2dffce2c5..06af64589 100644 --- a/problems/number-of-substrings-containing-all-three-characters/README.md +++ b/problems/number-of-substrings-containing-all-three-characters/README.md @@ -48,7 +48,9 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/number-of-transactions-per-visit/README.md b/problems/number-of-transactions-per-visit/README.md index 61e8f63b9..43fc1b21b 100644 --- a/problems/number-of-transactions-per-visit/README.md +++ b/problems/number-of-transactions-per-visit/README.md @@ -11,84 +11,7 @@ ## [1336. Number of Transactions per Visit (Hard)](https://leetcode.com/problems/number-of-transactions-per-visit "每次访问的交易次数") -

    Table: Visits

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| user_id       | int     |
    -| visit_date    | date    |
    -+---------------+---------+
    -(user_id, visit_date) is the primary key for this table.
    -Each row of this table indicates that user_id has visited the bank in visit_date.
    -
    -

    Table: Transactions

    -
    -+------------------+---------+
    -| Column Name      | Type    |
    -+------------------+---------+
    -| user_id          | int     |
    -| transaction_date | date    |
    -| amount           | int     |
    -+------------------+---------+
    -There is no primary key for this table, it may contain duplicates.
    -Each row of this table indicates that user_id has done a transaction of amount in transaction_date.
    -It is guaranteed that the user has visited the bank in the transaction_date.(i.e The Visits table contains (user_id, transaction_date) in one row)
    -
    - -Write an SQL query to find how many users visited the bank and didn't do any transactions, how many visited the bank and did one transaction and so on. -The result table will contain two columns transactions_count which is the number of transactions done in one visit and visits_count which is the corresponding number of users who did transactions_count in one visit to the bank. transactions_count should take all values from 0 to max(transactions_count) done by one or more users. - -Order the result table by transactions_count. - -The query result format is in the following example: - -
    -Visits table:
    -+---------+------------+
    -| user_id | visit_date |
    -+---------+------------+
    -| 1       | 2020-01-01 |
    -| 2       | 2020-01-02 |
    -| 12      | 2020-01-01 |
    -| 19      | 2020-01-03 |
    -| 1       | 2020-01-02 |
    -| 2       | 2020-01-03 |
    -| 1       | 2020-01-04 |
    -| 7       | 2020-01-11 |
    -| 9       | 2020-01-25 |
    -| 8       | 2020-01-28 |
    -+---------+------------+
    -Transactions table:
    -+---------+------------------+--------+
    -| user_id | transaction_date | amount |
    -+---------+------------------+--------+
    -| 1       | 2020-01-02       | 120    |
    -| 2       | 2020-01-03       | 22     |
    -| 7       | 2020-01-11       | 232    |
    -| 1       | 2020-01-04       | 7      |
    -| 9       | 2020-01-25       | 33     |
    -| 9       | 2020-01-25       | 66     |
    -| 8       | 2020-01-28       | 1      |
    -| 9       | 2020-01-25       | 99     |
    -+---------+------------------+--------+
    -Result table:
    -+--------------------+--------------+
    -| transactions_count | visits_count |
    -+--------------------+--------------+
    -| 0                  | 4            |
    -| 1                  | 5            |
    -| 2                  | 0            |
    -| 3                  | 1            |
    -+--------------------+--------------+
    -Users 1, 2, 12 and 19 visited the bank in 2020-01-01, 2020-01-02, 2020-01-01 and 2020-01-03 respectively, and didn't do any transactions.
    -So we have visits_count = 4 for transactions_count = 0.
    -Users 2, 7 and 8 visited the bank in 2020-01-03, 2020-01-11 and 2020-01-28 respectively, and did one transaction.
    -User 1 Also visited the bank in 2020-01-02 and 2020-01-04 and did one transaction each day.
    -So we have total visits_count = 5 for transactions_count = 1.
    -For transactions_count = 2 we don't have any users who visited the bank and did two transactions.
    -For transactions_count = 3 we have user 9 who visited the bank in 2020-01-25 and did three transactions.
    -Note that we stopped at transactions_count = 3 as this is the maximum number of transactions done by one user in one visit to the bank.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/number-of-trusted-contacts-of-a-customer/README.md b/problems/number-of-trusted-contacts-of-a-customer/README.md index 4a8e8df5d..bb23bf2cd 100644 --- a/problems/number-of-trusted-contacts-of-a-customer/README.md +++ b/problems/number-of-trusted-contacts-of-a-customer/README.md @@ -11,101 +11,7 @@ ## [1364. Number of Trusted Contacts of a Customer (Medium)](https://leetcode.com/problems/number-of-trusted-contacts-of-a-customer "顾客的可信联系人数量") -

    Table: Customers

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| customer_id   | int     |
    -| customer_name | varchar |
    -| email         | varchar |
    -+---------------+---------+
    -customer_id is the primary key for this table.
    -Each row of this table contains the name and the email of a customer of an online shop.
    -
    - -

    Table: Contacts

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| user_id       | id      |
    -| contact_name  | varchar |
    -| contact_email | varchar |
    -+---------------+---------+
    -(user_id, contact_email) is the primary key for this table.
    -Each row of this table contains the name and email of one contact of customer with user_id.
    -This table contains information about people each customer trust. The contact may or may not exist in the Customers table.
    -
    -

    Table: Invoices

    -
    -+--------------+---------+
    -| Column Name  | Type    |
    -+--------------+---------+
    -| invoice_id   | int     |
    -| price        | int     |
    -| user_id      | int     |
    -+--------------+---------+
    -invoice_id is the primary key for this table.
    -Each row of this table indicates that user_id has an invoice with invoice_id and a price.
    -
    - -Write an SQL query to find the following for each invoice_id: -- customer_name: The name of the customer the invoice is related to. -- price: The price of the invoice. -- contacts_cnt: The number of contacts related to the customer. -- trusted_contacts_cnt: The number of contacts related to the customer and at the same time they are customers to the shop. (i.e His/Her email exists in the Customers table.) - -Order the result table by invoice_id. - -The query result format is in the following example: -
    -Customers table:
    -+-------------+---------------+--------------------+
    -| customer_id | customer_name | email              |
    -+-------------+---------------+--------------------+
    -| 1           | Alice         | alice@leetcode.com |
    -| 2           | Bob           | bob@leetcode.com   |
    -| 13          | John          | john@leetcode.com  |
    -| 6           | Alex          | alex@leetcode.com  |
    -+-------------+---------------+--------------------+
    -Contacts table:
    -+-------------+--------------+--------------------+
    -| user_id     | contact_name | contact_email      |
    -+-------------+--------------+--------------------+
    -| 1           | Bob          | bob@leetcode.com   |
    -| 1           | John         | john@leetcode.com  |
    -| 1           | Jal          | jal@leetcode.com   |
    -| 2           | Omar         | omar@leetcode.com  |
    -| 2           | Meir         | meir@leetcode.com  |
    -| 6           | Alice        | alice@leetcode.com |
    -+-------------+--------------+--------------------+
    -Invoices table:
    -+------------+-------+---------+
    -| invoice_id | price | user_id |
    -+------------+-------+---------+
    -| 77         | 100   | 1       |
    -| 88         | 200   | 1       |
    -| 99         | 300   | 2       |
    -| 66         | 400   | 2       |
    -| 55         | 500   | 13      |
    -| 44         | 60    | 6       |
    -+------------+-------+---------+
    -Result table:
    -+------------+---------------+-------+--------------+----------------------+
    -| invoice_id | customer_name | price | contacts_cnt | trusted_contacts_cnt |
    -+------------+---------------+-------+--------------+----------------------+
    -| 44         | Alex          | 60    | 1            | 1                    |
    -| 55         | John          | 500   | 0            | 0                    |
    -| 66         | Bob           | 400   | 2            | 0                    |
    -| 77         | Alice         | 100   | 3            | 2                    |
    -| 88         | Alice         | 200   | 3            | 2                    |
    -| 99         | Bob           | 300   | 2            | 0                    |
    -+------------+---------------+-------+--------------+----------------------+
    -Alice has three contacts, two of them are trusted contacts (Bob and John).
    -Bob has two contacts, none of them is a trusted contact.
    -Alex has one contact and it is a trusted contact (Alice).
    -John doesn't have any contacts.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/number-of-valid-subarrays/README.md b/problems/number-of-valid-subarrays/README.md index 3e0cb7181..d4fbbf89b 100644 --- a/problems/number-of-valid-subarrays/README.md +++ b/problems/number-of-valid-subarrays/README.md @@ -11,47 +11,12 @@ ## [1063. Number of Valid Subarrays (Hard)](https://leetcode.com/problems/number-of-valid-subarrays "有效子数组的数目") -

    Given an array A of integers, return the number of non-empty continuous subarrays that satisfy the following condition:

    -

    The leftmost element of the subarray is not larger than other elements in the subarray.

    - -

     

    - -

    Example 1:

    - -
    -Input: [1,4,2,5,3]
    -Output: 11
    -Explanation: There are 11 valid subarrays: [1],[4],[2],[5],[3],[1,4],[2,5],[1,4,2],[2,5,3],[1,4,2,5],[1,4,2,5,3].
    -
    - -

    Example 2:

    - -
    -Input: [3,2,1]
    -Output: 3
    -Explanation: The 3 valid subarrays are: [3],[2],[1].
    -
    - -

    Example 3:

    - -
    -Input: [2,2,2]
    -Output: 6
    -Explanation: There are 6 valid subarrays: [2],[2],[2],[2,2],[2,2],[2,2,2].
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= A.length <= 50000
    2. -
    3. 0 <= A[i] <= 100000
    4. -
    ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints
    diff --git a/problems/number-of-valid-words-for-each-puzzle/README.md b/problems/number-of-valid-words-for-each-puzzle/README.md index e6a98be57..87ac1ffdf 100644 --- a/problems/number-of-valid-words-for-each-puzzle/README.md +++ b/problems/number-of-valid-words-for-each-puzzle/README.md @@ -49,7 +49,10 @@ There're no valid words for "gaswxyz" cause none of the ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/number-of-ways-of-cutting-a-pizza/README.md b/problems/number-of-ways-of-cutting-a-pizza/README.md index 0d831de8c..13058d42d 100644 --- a/problems/number-of-ways-of-cutting-a-pizza/README.md +++ b/problems/number-of-ways-of-cutting-a-pizza/README.md @@ -54,7 +54,10 @@ ### Related Topics + [[Memoization](../../tag/memoization/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md b/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md index f0d78492d..10c784b2b 100644 --- a/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md +++ b/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md @@ -79,6 +79,8 @@ ### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible/README.md b/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible/README.md index 6bcd7d6c8..4baf6cb24 100644 --- a/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible/README.md +++ b/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible/README.md @@ -55,7 +55,9 @@ The visible sticks are underlined. ### Related Topics + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Combinatorics](../../tag/combinatorics/README.md)] ### Hints
    diff --git a/problems/number-of-ways-to-reconstruct-a-tree/README.md b/problems/number-of-ways-to-reconstruct-a-tree/README.md index 422e6d038..6596cef38 100644 --- a/problems/number-of-ways-to-reconstruct-a-tree/README.md +++ b/problems/number-of-ways-to-reconstruct-a-tree/README.md @@ -76,6 +76,7 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] ### Hints
    diff --git a/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md b/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md index 3ae435352..b6ad2d6f1 100644 --- a/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md +++ b/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md @@ -82,7 +82,16 @@ ### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] + [[Combinatorics](../../tag/combinatorics/README.md)] ### Hints
    diff --git a/problems/number-of-ways-to-split-a-string/README.md b/problems/number-of-ways-to-split-a-string/README.md index e1c13b965..5d6b30520 100644 --- a/problems/number-of-ways-to-split-a-string/README.md +++ b/problems/number-of-ways-to-split-a-string/README.md @@ -64,6 +64,7 @@ ### Related Topics + [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md b/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md index 802f61ba6..b9db71387 100644 --- a/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md +++ b/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md @@ -66,7 +66,9 @@ Number of Permutations of (1,2,3,4) = 24. ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md b/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md index d1f18496a..5a33eb775 100644 --- a/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md +++ b/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md @@ -64,8 +64,10 @@ Type 2: (3,0,1). nums2[3]^2 = nums1[0] * nums1[1]. ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Hints
    diff --git a/problems/number-of-wonderful-substrings/README.md b/problems/number-of-wonderful-substrings/README.md new file mode 100644 index 000000000..ec22793d8 --- /dev/null +++ b/problems/number-of-wonderful-substrings/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../cyclically-rotating-a-grid "Cyclically Rotating a Grid") +                 +[Next >](../count-ways-to-build-rooms-in-an-ant-colony "Count Ways to Build Rooms in an Ant Colony") + +## [1915. Number of Wonderful Substrings (Medium)](https://leetcode.com/problems/number-of-wonderful-substrings "最美子字符串的数目") + +

    A wonderful string is a string where at most one letter appears an odd number of times.

    + +
      +
    • For example, "ccjjc" and "abab" are wonderful, but "ab" is not.
    • +
    + +

    Given a string word that consists of the first ten lowercase English letters ('a' through 'j'), return the number of wonderful non-empty substrings in word. If the same substring appears multiple times in word, then count each occurrence separately.

    + +

    A substring is a contiguous sequence of characters in a string.

    + +

     

    +

    Example 1:

    + +
    +Input: word = "aba"
    +Output: 4
    +Explanation: The four wonderful substrings are underlined below:
    +- "aba" -> "a"
    +- "aba" -> "b"
    +- "aba" -> "a"
    +- "aba" -> "aba"
    +
    + +

    Example 2:

    + +
    +Input: word = "aabb"
    +Output: 9
    +Explanation: The nine wonderful substrings are underlined below:
    +- "aabb" -> "a"
    +- "aabb" -> "aa"
    +- "aabb" -> "aab"
    +- "aabb" -> "aabb"
    +- "aabb" -> "a"
    +- "aabb" -> "abb"
    +- "aabb" -> "b"
    +- "aabb" -> "bb"
    +- "aabb" -> "b"
    +
    + +

    Example 3:

    + +
    +Input: word = "he"
    +Output: 2
    +Explanation: The two wonderful substrings are underlined below:
    +- "he" -> "h"
    +- "he" -> "e"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= word.length <= 105
    • +
    • word consists of lowercase English letters from 'a' to 'j'.
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +For each prefix of the string, check which characters are of even frequency and which are not and represent it by a bitmask. +
    + +
    +Hint 2 +Find the other prefixes whose masks differs from the current prefix mask by at most one bit. +
    diff --git a/problems/numbers-at-most-n-given-digit-set/README.md b/problems/numbers-at-most-n-given-digit-set/README.md index 4dc7a830c..fd2f7a8ae 100644 --- a/problems/numbers-at-most-n-given-digit-set/README.md +++ b/problems/numbers-at-most-n-given-digit-set/README.md @@ -58,5 +58,7 @@ In total, this is 29523 integers that can be written using the digits array. ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/numbers-with-same-consecutive-differences/README.md b/problems/numbers-with-same-consecutive-differences/README.md index 5bb16a766..0b47b74d0 100644 --- a/problems/numbers-with-same-consecutive-differences/README.md +++ b/problems/numbers-with-same-consecutive-differences/README.md @@ -56,7 +56,5 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] - [[Recursion](../../tag/recursion/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/occurrences-after-bigram/README.md b/problems/occurrences-after-bigram/README.md index 36e01ea30..7bf9b45af 100644 --- a/problems/occurrences-after-bigram/README.md +++ b/problems/occurrences-after-bigram/README.md @@ -35,7 +35,7 @@ ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/odd-even-jump/README.md b/problems/odd-even-jump/README.md index 85822e3bd..09b3df687 100644 --- a/problems/odd-even-jump/README.md +++ b/problems/odd-even-jump/README.md @@ -78,5 +78,7 @@ number of jumps. ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Ordered Map](../../tag/ordered-map/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] diff --git a/problems/odd-even-linked-list/README.md b/problems/odd-even-linked-list/README.md index b936534d1..ddd2c354e 100644 --- a/problems/odd-even-linked-list/README.md +++ b/problems/odd-even-linked-list/README.md @@ -17,6 +17,8 @@

    Note that the relative order inside both the even and odd groups should remain as it was in the input.

    +

    You must solve the problem in O(1) extra space complexity and O(n) time complexity.

    +

     

    Example 1:

    @@ -36,13 +38,11 @@

    Constraints:

      -
    • The number of nodes in the linked list is in the range [0, 104].
    • +
    • n == number of nodes in the linked list
    • +
    • 0 <= n <= 104
    • -106 <= Node.val <= 106
    -

     

    -Follow up: Could you solve it in O(1) space complexity and O(nodes) time complexity? - ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/one-edit-distance/README.md b/problems/one-edit-distance/README.md index 1237b5476..c7c5cb310 100644 --- a/problems/one-edit-distance/README.md +++ b/problems/one-edit-distance/README.md @@ -11,38 +11,10 @@ ## [161. One Edit Distance (Medium)](https://leetcode.com/problems/one-edit-distance "相隔为 1 的编辑距离") -

    Given two strings s and t, determine if they are both one edit distance apart.

    -

    Note: 

    - -

    There are 3 possiblities to satisify one edit distance apart:

    - -
      -
    1. Insert a character into s to get t
    2. -
    3. Delete a character from s to get t
    4. -
    5. Replace a character of s to get t
    6. -
    - -

    Example 1:

    - -
    Input: s = "ab", t = "acb"
    -Output: true
    -Explanation: We can insert 'c' into s to get t.
    -
    - -

    Example 2:

    - -
    Input: s = "cab", t = "ad"
    -Output: false
    -Explanation: We cannot get t from s by only one step.
    - -

    Example 3:

    - -
    Input: s = "1203", t = "1213"
    -Output: true
    -Explanation: We can replace '0' with '1' to get t.
    ### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/ones-and-zeroes/README.md b/problems/ones-and-zeroes/README.md index abfb5155f..04e698b54 100644 --- a/problems/ones-and-zeroes/README.md +++ b/problems/ones-and-zeroes/README.md @@ -47,6 +47,8 @@ Other valid but smaller subsets include {"0001", "1"} and {& ### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/online-election/README.md b/problems/online-election/README.md index de4117996..171ea2423 100644 --- a/problems/online-election/README.md +++ b/problems/online-election/README.md @@ -46,4 +46,7 @@ This continues for 3 more queries at time 15, 24, and 8.
    ### Related Topics + [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/online-majority-element-in-subarray/README.md b/problems/online-majority-element-in-subarray/README.md index 550e63118..bd81dbbcf 100644 --- a/problems/online-majority-element-in-subarray/README.md +++ b/problems/online-majority-element-in-subarray/README.md @@ -11,43 +11,49 @@ ## [1157. Online Majority Element In Subarray (Hard)](https://leetcode.com/problems/online-majority-element-in-subarray "子数组中占绝大多数的元素") -

    Implementing the class MajorityChecker, which has the following API:

    +

    Design a data structure that efficiently finds the majority element of a given subarray.

    + +

    The majority element of a subarray is an element that occurs threshold times or more in the subarray.

    + +

    Implementing the MajorityChecker class:

      -
    • MajorityChecker(int[] arr) constructs an instance of MajorityChecker with the given array arr;
    • -
    • int query(int left, int right, int threshold) has arguments such that: -
        -
      • 0 <= left <= right < arr.length representing a subarray of arr;
      • -
      • 2 * threshold > right - left + 1, ie. the threshold is always a strict majority of the length of the subarray
      • -
      -
    • +
    • MajorityChecker(int[] arr) Initializes the instance of the class with the given array arr.
    • +
    • int query(int left, int right, int threshold) returns the element in the subarray arr[left...right] that occurs at least threshold times, or -1 if no such element exists.
    -

    Each query(...) returns the element in arr[left], arr[left+1], ..., arr[right] that occurs at least threshold times, or -1 if no such element exists.

    -

     

    - -

    Example:

    +

    Example 1:

    -MajorityChecker majorityChecker = new MajorityChecker([1,1,2,2,1,1]);
    -majorityChecker.query(0,5,4); // returns 1
    -majorityChecker.query(0,3,3); // returns -1
    -majorityChecker.query(2,3,2); // returns 2
    +Input
    +["MajorityChecker", "query", "query", "query"]
    +[[[1, 1, 2, 2, 1, 1]], [0, 5, 4], [0, 3, 3], [2, 3, 2]]
    +Output
    +[null, 1, -1, 2]
    +
    +Explanation
    +MajorityChecker majorityChecker = new MajorityChecker([1, 1, 2, 2, 1, 1]);
    +majorityChecker.query(0, 5, 4); // return 1
    +majorityChecker.query(0, 3, 3); // return -1
    +majorityChecker.query(2, 3, 2); // return 2
     

     

    Constraints:

      -
    • 1 <= arr.length <= 20000
    • -
    • 1 <= arr[i] <= 20000
    • -
    • For each query, 0 <= left <= right < len(arr)
    • -
    • For each query, 2 * threshold > right - left + 1
    • -
    • The number of queries is at most 10000
    • +
    • 1 <= arr.length <= 2 * 104
    • +
    • 1 <= arr[i] <= 2 * 104
    • +
    • 0 <= left <= right < arr.length
    • +
    • threshold <= right - left + 1
    • +
    • 2 * threshold > right - left + 1
    • +
    • At most 104 calls will be made to query.
    ### Related Topics + [[Design](../../tag/design/README.md)] + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/online-stock-span/README.md b/problems/online-stock-span/README.md index 9a8c473ca..16d6ba897 100644 --- a/problems/online-stock-span/README.md +++ b/problems/online-stock-span/README.md @@ -53,3 +53,6 @@ Note that (for example) S.next(75) returned 4, because the last 4 prices ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Design](../../tag/design/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] diff --git a/problems/open-the-lock/README.md b/problems/open-the-lock/README.md index fd1e13cea..ea5d76e20 100644 --- a/problems/open-the-lock/README.md +++ b/problems/open-the-lock/README.md @@ -68,7 +68,10 @@ We can't reach the target without getting stuck. ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/optimal-account-balancing/README.md b/problems/optimal-account-balancing/README.md index 0bb3b3b4f..f68f8160c 100644 --- a/problems/optimal-account-balancing/README.md +++ b/problems/optimal-account-balancing/README.md @@ -11,47 +11,8 @@ ## [465. Optimal Account Balancing (Hard)](https://leetcode.com/problems/optimal-account-balancing "最优账单平衡") -

    A group of friends went on holiday and sometimes lent each other money. For example, Alice paid for Bill's lunch for $10. Then later Chris gave Alice $5 for a taxi ride. We can model each transaction as a tuple (x, y, z) which means person x gave person y $z. Assuming Alice, Bill, and Chris are person 0, 1, and 2 respectively (0, 1, 2 are the person's ID), the transactions can be represented as [[0, 1, 10], [2, 0, 5]].

    -

    Given a list of transactions between a group of people, return the minimum number of transactions required to settle the debt.

    -

    Note: -

      -
    1. A transaction will be given as a tuple (x, y, z). Note that x ≠ y and z > 0.
    2. -
    3. Person's IDs may not be linear, e.g. we could have the persons 0, 1, 2 or we could also have the persons 0, 2, 6.
    4. -
    -

    - -

    Example 1: -

    -Input:
    -[[0,1,10], [2,0,5]]
    -
    -Output:
    -2
    -
    -Explanation:
    -Person #0 gave person #1 $10.
    -Person #2 gave person #0 $5.
    -
    -Two transactions are needed. One way to settle the debt is person #1 pays person #0 and #2 $5 each.
    -
    -

    - -

    Example 2: -

    -Input:
    -[[0,1,10], [1,0,1], [1,2,5], [2,0,5]]
    -
    -Output:
    -1
    -
    -Explanation:
    -Person #0 gave person #1 $10.
    -Person #1 gave person #0 $1.
    -Person #1 gave person #2 $5.
    -Person #2 gave person #0 $5.
    -
    -Therefore, person #1 only need to give person #0 $4, and all debt is settled.
    -
    -

    +### Related Topics + [[Array](../../tag/array/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/optimal-division/README.md b/problems/optimal-division/README.md index b0a03ae83..7b4611e58 100644 --- a/problems/optimal-division/README.md +++ b/problems/optimal-division/README.md @@ -63,5 +63,6 @@ Other cases: ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/optimize-water-distribution-in-a-village/README.md b/problems/optimize-water-distribution-in-a-village/README.md index 2c9ea50d0..6eaf6ae41 100644 --- a/problems/optimize-water-distribution-in-a-village/README.md +++ b/problems/optimize-water-distribution-in-a-village/README.md @@ -11,41 +11,12 @@ ## [1168. Optimize Water Distribution in a Village (Hard)](https://leetcode.com/problems/optimize-water-distribution-in-a-village "水资源分配优化") -

    There are n houses in a village. We want to supply water for all the houses by building wells and laying pipes.

    -

    For each house i, we can either build a well inside it directly with cost wells[i], or pipe in water from another well to it. The costs to lay pipes between houses are given by the array pipes, where each pipes[i] = [house1, house2, cost] represents the cost to connect house1 and house2 together using a pipe. Connections are bidirectional.

    - -

    Find the minimum total cost to supply water to all houses.

    - -

     

    -

    Example 1:

    - -

    - -
    -Input: n = 3, wells = [1,2,2], pipes = [[1,2,1],[2,3,1]]
    -Output: 3
    -Explanation: 
    -The image shows the costs of connecting houses using pipes.
    -The best strategy is to build a well in the first house with cost 1 and connect the other houses to it with cost 2 so the total cost is 3.
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= n <= 10000
    • -
    • wells.length == n
    • -
    • 0 <= wells[i] <= 10^5
    • -
    • 1 <= pipes.length <= 10000
    • -
    • 1 <= pipes[i][0], pipes[i][1] <= n
    • -
    • 0 <= pipes[i][2] <= 10^5
    • -
    • pipes[i][0] != pipes[i][1]
    • -
    ### Related Topics [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] + [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] ### Hints
    diff --git a/problems/orderly-queue/README.md b/problems/orderly-queue/README.md index 3d2ae9f57..30bd525e2 100644 --- a/problems/orderly-queue/README.md +++ b/problems/orderly-queue/README.md @@ -55,3 +55,4 @@ In the second move, we move the 3rd character ("c") to the end, obtain ### Related Topics [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/orders-with-maximum-quantity-above-average/README.md b/problems/orders-with-maximum-quantity-above-average/README.md index 393ca3884..fcef76c7e 100644 --- a/problems/orders-with-maximum-quantity-above-average/README.md +++ b/problems/orders-with-maximum-quantity-above-average/README.md @@ -12,3 +12,6 @@ ## [1867. Orders With Maximum Quantity Above Average (Medium)](https://leetcode.com/problems/orders-with-maximum-quantity-above-average "") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/out-of-boundary-paths/README.md b/problems/out-of-boundary-paths/README.md index d8d7d46e1..72d8d9cc6 100644 --- a/problems/out-of-boundary-paths/README.md +++ b/problems/out-of-boundary-paths/README.md @@ -11,7 +11,7 @@ ## [576. Out of Boundary Paths (Medium)](https://leetcode.com/problems/out-of-boundary-paths "出界的路径数") -

    There is an m x n grid with a ball. The ball is initially at the position [startRow, startColumn]. You are allowed to move the ball to one of the four adjacent four cells in the grid (possibly out of the grid crossing the grid boundary). You can apply at most maxMove moves to the ball.

    +

    There is an m x n grid with a ball. The ball is initially at the position [startRow, startColumn]. You are allowed to move the ball to one of the four adjacent cells in the grid (possibly out of the grid crossing the grid boundary). You can apply at most maxMove moves to the ball.

    Given the five integers m, n, maxMove, startRow, startColumn, return the number of paths to move the ball out of the grid boundary. Since the answer can be very large, return it modulo 109 + 7.

    @@ -36,12 +36,11 @@
    • 1 <= m, n <= 50
    • 0 <= maxMove <= 50
    • -
    • 0 <= startRow <= m
    • -
    • 0 <= startColumn <= n
    • +
    • 0 <= startRow < m
    • +
    • 0 <= startColumn < n
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions @@ -50,15 +49,17 @@ ### Hints
    Hint 1 -WIll traversing every path is fesaible? There are many possible paths for a small matrix. Try to optimize it. +Is traversing every path feasible? There are many possible paths for a small matrix. Try to optimize it.
    Hint 2 -Can we use some space to store the number of paths and updating them after every move? +Can we use some space to store the number of paths and update them after every move?
    Hint 3 -One obvious thing: ball will go out of boundary only by crossing it. Also, there is only one possible way ball can go out of boundary from boundary cell except corner cells. From corner cell ball can go out in two different ways. Can you use this thing to solve the problem? +One obvious thing: the ball will go out of the boundary only by crossing it. Also, there is only one possible way the ball can go out of the boundary from the boundary cell except for corner cells. From the corner cell, the ball can go out in two different ways. + +Can you use this thing to solve the problem?
    diff --git a/problems/output-contest-matches/README.md b/problems/output-contest-matches/README.md index 784571272..536b90648 100644 --- a/problems/output-contest-matches/README.md +++ b/problems/output-contest-matches/README.md @@ -11,50 +11,9 @@ ## [544. Output Contest Matches (Medium)](https://leetcode.com/problems/output-contest-matches "输出比赛匹配对") -

    -During the NBA playoffs, we always arrange the rather strong team to play with the rather weak team, like make the rank 1 team play with the rank nth team, which is a good strategy to make the contest more interesting. Now, you're given n teams, you need to output their final contest matches in the form of a string. -

    -

    The n teams are given in the form of positive integers from 1 to n, which represents their initial rank. (Rank 1 is the strongest team and Rank n is the weakest team.) We'll use parentheses('(', ')') and commas(',') to represent the contest team pairing - parentheses('(' , ')') for pairing and commas(',') for partition. During the pairing process in each round, you always need to follow the strategy of making the rather strong one pair with the rather weak one.

    - -

    Example 1:
    -

    Input: 2
    -Output: (1,2)
    -Explanation: 
    -Initially, we have the team 1 and the team 2, placed like: 1,2.
    -Then we pair the team (1,2) together with '(', ')' and ',', which is the final answer.
    -
    -

    - -

    Example 2:
    -

    Input: 4
    -Output: ((1,4),(2,3))
    -Explanation: 
    -In the first round, we pair the team 1 and 4, the team 2 and 3 together, as we need to make the strong team and weak team together.
    -And we got (1,4),(2,3).
    -In the second round, the winners of (1,4) and (2,3) need to play again to generate the final winner, so you need to add the paratheses outside them.
    -And we got the final answer ((1,4),(2,3)).
    -
    -

    - -

    Example 3:
    -

    Input: 8
    -Output: (((1,8),(4,5)),((2,7),(3,6)))
    -Explanation: 
    -First round: (1,8),(2,7),(3,6),(4,5)
    -Second round: ((1,8),(4,5)),((2,7),(3,6))
    -Third round: (((1,8),(4,5)),((2,7),(3,6)))
    -Since the third round will generate the final winner, you need to output the answer (((1,8),(4,5)),((2,7),(3,6))).
    -
    -

    - -

    Note:
    -

      -
    1. The n is in range [2, 212].
    2. -
    3. We ensure that the input n can be converted into the form 2k, where k is a positive integer.
    4. -
    -

    ### Related Topics [[Recursion](../../tag/recursion/README.md)] [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/pacific-atlantic-water-flow/README.md b/problems/pacific-atlantic-water-flow/README.md index e886a0a69..207dcce39 100644 --- a/problems/pacific-atlantic-water-flow/README.md +++ b/problems/pacific-atlantic-water-flow/README.md @@ -11,15 +11,17 @@ ## [417. Pacific Atlantic Water Flow (Medium)](https://leetcode.com/problems/pacific-atlantic-water-flow "太平洋大西洋水流问题") -

    You are given an m x n integer matrix heights representing the height of each unit cell in a continent. The Pacific ocean touches the continent's left and top edges, and the Atlantic ocean touches the continent's right and bottom edges.

    +

    There is an m x n rectangular island that borders both the Pacific Ocean and Atlantic Ocean. The Pacific Ocean touches the island's left and top edges, and the Atlantic Ocean touches the island's right and bottom edges.

    -

    Water can only flow in four directions: up, down, left, and right. Water flows from a cell to an adjacent one with an equal or lower height.

    +

    The island is partitioned into a grid of square cells. You are given an m x n integer matrix heights where heights[r][c] represents the height above sea level of the cell at coordinate (r, c).

    -

    Return a list of grid coordinates where water can flow to both the Pacific and Atlantic oceans.

    +

    The island receives a lot of rain, and the rain water can flow to neighboring cells directly north, south, east, and west if the neighboring cell's height is less than or equal to the current cell's height. Water can flow from any cell adjacent to an ocean into the ocean.

    + +

    Return a 2D list of grid coordinates result where result[i] = [ri, ci] denotes that rain water can flow from cell (ri, ci) to both the Pacific and Atlantic oceans.

     

    Example 1:

    - +
     Input: heights = [[1,2,2,3,5],[3,2,3,4,4],[2,4,5,3,1],[6,7,1,4,5],[5,1,1,2,4]]
     Output: [[0,4],[1,3],[1,4],[2,2],[3,0],[3,1],[4,0]]
    @@ -37,11 +39,13 @@
     
     
    • m == heights.length
    • -
    • n == heights[i].length
    • +
    • n == heights[r].length
    • 1 <= m, n <= 200
    • -
    • 0 <= heights[i][j] <= 105
    • +
    • 0 <= heights[r][c] <= 105
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/page-recommendations-ii/README.md b/problems/page-recommendations-ii/README.md new file mode 100644 index 000000000..42de505c3 --- /dev/null +++ b/problems/page-recommendations-ii/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../cutting-ribbons "Cutting Ribbons") +                 +[Next >](../check-if-all-the-integers-in-a-range-are-covered "Check if All the Integers in a Range Are Covered") + +## [1892. Page Recommendations II (Hard)](https://leetcode.com/problems/page-recommendations-ii "页面推荐Ⅱ") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/page-recommendations-ii/mysql_schemas.sql b/problems/page-recommendations-ii/mysql_schemas.sql new file mode 100644 index 000000000..d7b0e4af6 --- /dev/null +++ b/problems/page-recommendations-ii/mysql_schemas.sql @@ -0,0 +1,20 @@ +Create table If Not Exists Friendship (user1_id int, user2_id int); +Create table If Not Exists Likes (user_id int, page_id int); +Truncate table Friendship; +insert into Friendship (user1_id, user2_id) values ('1', '2'); +insert into Friendship (user1_id, user2_id) values ('1', '3'); +insert into Friendship (user1_id, user2_id) values ('1', '4'); +insert into Friendship (user1_id, user2_id) values ('2', '3'); +insert into Friendship (user1_id, user2_id) values ('2', '4'); +insert into Friendship (user1_id, user2_id) values ('2', '5'); +insert into Friendship (user1_id, user2_id) values ('6', '1'); +Truncate table Likes; +insert into Likes (user_id, page_id) values ('1', '88'); +insert into Likes (user_id, page_id) values ('2', '23'); +insert into Likes (user_id, page_id) values ('3', '24'); +insert into Likes (user_id, page_id) values ('4', '56'); +insert into Likes (user_id, page_id) values ('5', '11'); +insert into Likes (user_id, page_id) values ('6', '33'); +insert into Likes (user_id, page_id) values ('2', '77'); +insert into Likes (user_id, page_id) values ('3', '77'); +insert into Likes (user_id, page_id) values ('6', '88'); diff --git a/problems/page-recommendations/README.md b/problems/page-recommendations/README.md index e90b60e6c..cf501ba71 100644 --- a/problems/page-recommendations/README.md +++ b/problems/page-recommendations/README.md @@ -11,76 +11,7 @@ ## [1264. Page Recommendations (Medium)](https://leetcode.com/problems/page-recommendations "页面推荐") -

    Table: Friendship

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| user1_id      | int     |
    -| user2_id      | int     |
    -+---------------+---------+
    -(user1_id, user2_id) is the primary key for this table.
    -Each row of this table indicates that there is a friendship relation between user1_id and user2_id.
    -
    - -

    Table: Likes

    -
    -+-------------+---------+
    -| Column Name | Type    |
    -+-------------+---------+
    -| user_id     | int     |
    -| page_id     | int     |
    -+-------------+---------+
    -(user_id, page_id) is the primary key for this table.
    -Each row of this table indicates that user_id likes page_id.
    -
    - -Write an SQL query to recommend pages to the user with user_id = 1 using the pages that your friends liked. It should not recommend pages you already liked. -Return result table in any order without duplicates. -The query result format is in the following example: -
    -Friendship table:
    -+----------+----------+
    -| user1_id | user2_id |
    -+----------+----------+
    -| 1        | 2        |
    -| 1        | 3        |
    -| 1        | 4        |
    -| 2        | 3        |
    -| 2        | 4        |
    -| 2        | 5        |
    -| 6        | 1        |
    -+----------+----------+
    - 
    -Likes table:
    -+---------+---------+
    -| user_id | page_id |
    -+---------+---------+
    -| 1       | 88      |
    -| 2       | 23      |
    -| 3       | 24      |
    -| 4       | 56      |
    -| 5       | 11      |
    -| 6       | 33      |
    -| 2       | 77      |
    -| 3       | 77      |
    -| 6       | 88      |
    -+---------+---------+
    -
    -Result table:
    -+------------------+
    -| recommended_page |
    -+------------------+
    -| 23               |
    -| 24               |
    -| 56               |
    -| 33               |
    -| 77               |
    -+------------------+
    -User one is friend with users 2, 3, 4 and 6.
    -Suggested pages are 23 from user 2, 24 from user 3, 56 from user 3 and 33 from user 6.
    -Page 77 is suggested from both user 2 and user 3.
    -Page 88 is not suggested because user 1 already likes it.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/paint-fence/README.md b/problems/paint-fence/README.md index 3317001f8..0e3f951db 100644 --- a/problems/paint-fence/README.md +++ b/problems/paint-fence/README.md @@ -11,31 +11,7 @@ ## [276. Paint Fence (Medium)](https://leetcode.com/problems/paint-fence "栅栏涂色") -

    There is a fence with n posts, each post can be painted with one of the k colors.

    -

    You have to paint all the posts such that no more than two adjacent fence posts have the same color.

    - -

    Return the total number of ways you can paint the fence.

    - -

    Note:
    -n and k are non-negative integers.

    - -

    Example:

    - -
    -Input: n = 3, k = 2
    -Output: 6
    -Explanation: Take c1 as color 1, c2 as color 2. All possible ways are:
    -
    -            post1  post2  post3      
    - -----      -----  -----  -----       
    -   1         c1     c1     c2 
    -   2         c1     c2     c1 
    -   3         c1     c2     c2 
    -   4         c2     c1     c1  
    -   5         c2     c1     c2
    -   6         c2     c2     c1
    -
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/paint-house-ii/README.md b/problems/paint-house-ii/README.md index 847316443..3345b2eca 100644 --- a/problems/paint-house-ii/README.md +++ b/problems/paint-house-ii/README.md @@ -11,26 +11,10 @@ ## [265. Paint House II (Hard)](https://leetcode.com/problems/paint-house-ii "粉刷房子 II") -

    There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.

    -

    The cost of painting each house with a certain color is represented by a n x k cost matrix. For example, costs[0][0] is the cost of painting house 0 with color 0; costs[1][2] is the cost of painting house 1 with color 2, and so on... Find the minimum cost to paint all houses.

    - -

    Note:
    -All costs are positive integers.

    - -

    Example:

    - -
    -Input: [[1,5,3],[2,9,4]]
    -Output: 5
    -Explanation: Paint house 0 into color 0, paint house 1 into color 2. Minimum cost: 1 + 4 = 5; 
    -             Or paint house 0 into color 2, paint house 1 into color 0. Minimum cost: 3 + 2 = 5. 
    -
    - -

    Follow up:
    -Could you solve it in O(nk) runtime?

    ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/paint-house-iii/README.md b/problems/paint-house-iii/README.md index 51bbcb835..71f75b642 100644 --- a/problems/paint-house-iii/README.md +++ b/problems/paint-house-iii/README.md @@ -78,6 +78,7 @@ Cost of paint the first and last house (10 + 1) = 11. ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/paint-house/README.md b/problems/paint-house/README.md index 7867156c2..d841c5389 100644 --- a/problems/paint-house/README.md +++ b/problems/paint-house/README.md @@ -11,23 +11,10 @@ ## [256. Paint House (Medium)](https://leetcode.com/problems/paint-house "粉刷房子") -

    There are a row of n houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.

    -

    The cost of painting each house with a certain color is represented by a n x 3 cost matrix. For example, costs[0][0] is the cost of painting house 0 with color red; costs[1][2] is the cost of painting house 1 with color green, and so on... Find the minimum cost to paint all houses.

    - -

    Note:
    -All costs are positive integers.

    - -

    Example:

    - -
    -Input: [[17,2,17],[16,16,5],[14,3,19]]
    -Output: 10
    -Explanation: Paint house 0 into blue, paint house 1 into green, paint house 2 into blue. 
    -             Minimum cost: 2 + 5 + 3 = 10.
    -
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/pairs-of-songs-with-total-durations-divisible-by-60/README.md b/problems/pairs-of-songs-with-total-durations-divisible-by-60/README.md index 3a9795fa6..f2a3f7713 100644 --- a/problems/pairs-of-songs-with-total-durations-divisible-by-60/README.md +++ b/problems/pairs-of-songs-with-total-durations-divisible-by-60/README.md @@ -45,6 +45,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/palindrome-linked-list/README.md b/problems/palindrome-linked-list/README.md index f18a0ee0a..3baebf8c4 100644 --- a/problems/palindrome-linked-list/README.md +++ b/problems/palindrome-linked-list/README.md @@ -40,6 +40,8 @@ Follow up: Could you do it in O(n) time and O(1) space? ### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/palindrome-pairs/README.md b/problems/palindrome-pairs/README.md index d128b81f4..797531cba 100644 --- a/problems/palindrome-pairs/README.md +++ b/problems/palindrome-pairs/README.md @@ -48,6 +48,7 @@ ### Related Topics [[Trie](../../tag/trie/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/palindrome-partitioning-ii/README.md b/problems/palindrome-partitioning-ii/README.md index c84c2a044..aef95045d 100644 --- a/problems/palindrome-partitioning-ii/README.md +++ b/problems/palindrome-partitioning-ii/README.md @@ -47,6 +47,7 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/palindrome-partitioning-iii/README.md b/problems/palindrome-partitioning-iii/README.md index 0dc5381f5..c64722b83 100644 --- a/problems/palindrome-partitioning-iii/README.md +++ b/problems/palindrome-partitioning-iii/README.md @@ -11,14 +11,14 @@ ## [1278. Palindrome Partitioning III (Hard)](https://leetcode.com/problems/palindrome-partitioning-iii "分割回文串 III") -

    You are given a string s containing lowercase letters and an integer k. You need to :

    +

    You are given a string s containing lowercase letters and an integer k. You need to :

      -
    • First, change some characters of s to other lowercase English letters.
    • -
    • Then divide s into k non-empty disjoint substrings such that each substring is palindrome.
    • +
    • First, change some characters of s to other lowercase English letters.
    • +
    • Then divide s into k non-empty disjoint substrings such that each substring is a palindrome.
    -

    Return the minimal number of characters that you need to change to divide the string.

    +

    Return the minimal number of characters that you need to change to divide the string.

     

    Example 1:

    @@ -48,10 +48,11 @@
    • 1 <= k <= s.length <= 100.
    • -
    • s only contains lowercase English letters.
    • +
    • s only contains lowercase English letters.
    ### Related Topics + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/palindrome-partitioning/README.md b/problems/palindrome-partitioning/README.md index 87c7cca47..22a3c6719 100644 --- a/problems/palindrome-partitioning/README.md +++ b/problems/palindrome-partitioning/README.md @@ -32,7 +32,7 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/palindrome-permutation-ii/README.md b/problems/palindrome-permutation-ii/README.md index 955fa468f..b63151147 100644 --- a/problems/palindrome-permutation-ii/README.md +++ b/problems/palindrome-permutation-ii/README.md @@ -11,19 +11,11 @@ ## [267. Palindrome Permutation II (Medium)](https://leetcode.com/problems/palindrome-permutation-ii "回文排列 II") -

    Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could be form.

    -

    Example 1:

    - -
    Input: "aabb"
    -Output: ["abba", "baab"]
    - -

    Example 2:

    - -
    Input: "abc"
    -Output: []
    ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions diff --git a/problems/palindrome-permutation/README.md b/problems/palindrome-permutation/README.md index 865215b59..8b9999282 100644 --- a/problems/palindrome-permutation/README.md +++ b/problems/palindrome-permutation/README.md @@ -11,25 +11,12 @@ ## [266. Palindrome Permutation (Easy)](https://leetcode.com/problems/palindrome-permutation "回文排列") -

    Given a string, determine if a permutation of the string could form a palindrome.

    -

    Example 1:

    - -
    Input: "code"
    -Output: false
    - -

    Example 2:

    - -
    Input: "aab"
    -Output: true
    - -

    Example 3:

    - -
    Input: "carerac"
    -Output: true
    ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Longest Palindromic Substring](../longest-palindromic-substring) (Medium) diff --git a/problems/palindrome-removal/README.md b/problems/palindrome-removal/README.md index 30cd1b25d..65c8de011 100644 --- a/problems/palindrome-removal/README.md +++ b/problems/palindrome-removal/README.md @@ -11,35 +11,10 @@ ## [1246. Palindrome Removal (Hard)](https://leetcode.com/problems/palindrome-removal "删除回文子数组") -

    Given an integer array arr, in one move you can select a palindromic subarray arr[i], arr[i+1], ..., arr[j] where i <= j, and remove that subarray from the given array. Note that after removing a subarray, the elements on the left and on the right of that subarray move to fill the gap left by the removal.

    -

    Return the minimum number of moves needed to remove all numbers from the array.

    - -

     

    -

    Example 1:

    - -
    -Input: arr = [1,2]
    -Output: 2
    -
    - -

    Example 2:

    - -
    -Input: arr = [1,3,4,1,5]
    -Output: 3
    -Explanation: Remove [4] then remove [1,3,1] then remove [5].
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= arr.length <= 100
    • -
    • 1 <= arr[i] <= 20
    • -
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/pancake-sorting/README.md b/problems/pancake-sorting/README.md index da75550b4..7db0dd175 100644 --- a/problems/pancake-sorting/README.md +++ b/problems/pancake-sorting/README.md @@ -58,5 +58,7 @@ Note that other answers, such as [3, 3], would also be accepted. ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/parallel-courses-ii/README.md b/problems/parallel-courses-ii/README.md index 3fb710e9e..279d413f8 100644 --- a/problems/parallel-courses-ii/README.md +++ b/problems/parallel-courses-ii/README.md @@ -67,7 +67,10 @@ In the fourth semester, you can take course 5. ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Graph](../../tag/graph/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/parallel-courses/README.md b/problems/parallel-courses/README.md index b2eda5f2d..bcf5b1eb5 100644 --- a/problems/parallel-courses/README.md +++ b/problems/parallel-courses/README.md @@ -11,53 +11,11 @@ ## [1136. Parallel Courses (Medium)](https://leetcode.com/problems/parallel-courses "平行课程") -

    There are N courses, labelled from 1 to N.

    -

    We are given relations[i] = [X, Y], representing a prerequisite relationship between course X and course Y: course X has to be studied before course Y.

    - -

    In one semester you can study any number of courses as long as you have studied all the prerequisites for the course you are studying.

    - -

    Return the minimum number of semesters needed to study all courses.  If there is no way to study all the courses, return -1.

    - -

     

    - -

    Example 1:

    - -

    - -
    -Input: N = 3, relations = [[1,3],[2,3]]
    -Output: 2
    -Explanation: 
    -In the first semester, courses 1 and 2 are studied. In the second semester, course 3 is studied.
    -
    - -

    Example 2:

    - -

    - -
    -Input: N = 3, relations = [[1,2],[2,3],[3,1]]
    -Output: -1
    -Explanation: 
    -No course can be studied because they depend on each other.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= N <= 5000
    2. -
    3. 1 <= relations.length <= 5000
    4. -
    5. relations[i][0] != relations[i][1]
    6. -
    7. There are no repeated relations in the input.
    8. -
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] ### Hints
    diff --git a/problems/parse-lisp-expression/README.md b/problems/parse-lisp-expression/README.md index a90237542..e75e66ef0 100644 --- a/problems/parse-lisp-expression/README.md +++ b/problems/parse-lisp-expression/README.md @@ -11,70 +11,80 @@ ## [736. Parse Lisp Expression (Hard)](https://leetcode.com/problems/parse-lisp-expression "Lisp 语法解析") -

    -You are given a string expression representing a Lisp-like expression to return the integer value of. -

    -The syntax for these expressions is given as follows. -

    -

  • An expression is either an integer, a let-expression, an add-expression, a mult-expression, or an assigned variable. Expressions always evaluate to a single integer.
  • -

    -

  • (An integer could be positive or negative.)
  • -

    -

  • A let-expression takes the form (let v1 e1 v2 e2 ... vn en expr), where let is always the string "let", then there are 1 or more pairs of alternating variables and expressions, meaning that the first variable v1 is assigned the value of the expression e1, the second variable v2 is assigned the value of the expression e2, and so on sequentially; and then the value of this let-expression is the value of the expression expr.
  • -

    -

  • An add-expression takes the form (add e1 e2) where add is always the string "add", there are always two expressions e1, e2, and this expression evaluates to the addition of the evaluation of e1 and the evaluation of e2.
  • -

    -

  • A mult-expression takes the form (mult e1 e2) where mult is always the string "mult", there are always two expressions e1, e2, and this expression evaluates to the multiplication of the evaluation of e1 and the evaluation of e2.
  • -

    -

  • For the purposes of this question, we will use a smaller subset of variable names. A variable starts with a lowercase letter, then zero or more lowercase letters or digits. Additionally for your convenience, the names "add", "let", or "mult" are protected and will never be used as variable names.
  • -

    -

  • Finally, there is the concept of scope. When an expression of a variable name is evaluated, within the context of that evaluation, the innermost scope (in terms of parentheses) is checked first for the value of that variable, and then outer scopes are checked sequentially. It is guaranteed that every expression is legal. Please see the examples for more details on scope.
  • -

    - -

    Evaluation Examples:
    -

    -Input: (add 1 2)
    -Output: 3
    +

    You are given a string expression representing a Lisp-like expression to return the integer value of.

    + +

    The syntax for these expressions is given as follows.

    -Input: (mult 3 (add 2 3)) -Output: 15 +
      +
    • An expression is either an integer, let expression, add expression, mult expression, or an assigned variable. Expressions always evaluate to a single integer.
    • +
    • (An integer could be positive or negative.)
    • +
    • A let expression takes the form "(let v1 e1 v2 e2 ... vn en expr)", where let is always the string "let", then there are one or more pairs of alternating variables and expressions, meaning that the first variable v1 is assigned the value of the expression e1, the second variable v2 is assigned the value of the expression e2, and so on sequentially; and then the value of this let expression is the value of the expression expr.
    • +
    • An add expression takes the form "(add e1 e2)" where add is always the string "add", there are always two expressions e1, e2 and the result is the addition of the evaluation of e1 and the evaluation of e2.
    • +
    • A mult expression takes the form "(mult e1 e2)" where mult is always the string "mult", there are always two expressions e1, e2 and the result is the multiplication of the evaluation of e1 and the evaluation of e2.
    • +
    • For this question, we will use a smaller subset of variable names. A variable starts with a lowercase letter, then zero or more lowercase letters or digits. Additionally, for your convenience, the names "add", "let", and "mult" are protected and will never be used as variable names.
    • +
    • Finally, there is the concept of scope. When an expression of a variable name is evaluated, within the context of that evaluation, the innermost scope (in terms of parentheses) is checked first for the value of that variable, and then outer scopes are checked sequentially. It is guaranteed that every expression is legal. Please see the examples for more details on the scope.
    • +
    -Input: (let x 2 (mult x 5)) -Output: 10 +

     

    +

    Example 1:

    -Input: (let x 2 (mult x (let x 3 y 4 (add x y)))) -Output: 14 -Explanation: In the expression (add x y), when checking for the value of the variable x, +
    +Input: expression = "(let x 2 (mult x (let x 3 y 4 (add x y))))"
    +Output: 14
    +Explanation: In the expression (add x y), when checking for the value of the variable x,
     we check from the innermost scope to the outermost in the context of the variable we are trying to evaluate.
     Since x = 3 is found first, the value of x is 3.
    +
    + +

    Example 2:

    + +
    +Input: expression = "(let x 3 x 2 x)"
    +Output: 2
    +Explanation: Assignment in let statements is processed sequentially.
    +
    -Input: (let x 3 x 2 x) -Output: 2 -Explanation: Assignment in let statements is processed sequentially. +

    Example 3:

    -Input: (let x 1 y 2 x (add x y) (add x y)) -Output: 5 -Explanation: The first (add x y) evaluates as 3, and is assigned to x. +
    +Input: expression = "(let x 1 y 2 x (add x y) (add x y))"
    +Output: 5
    +Explanation: The first (add x y) evaluates as 3, and is assigned to x.
     The second (add x y) evaluates as 3+2 = 5.
    +
    -Input: (let x 2 (add (let x 3 (let x 4 x)) x)) -Output: 6 -Explanation: Even though (let x 4 x) has a deeper scope, it is outside the context +

    Example 4:

    + +
    +Input: expression = "(let x 2 (add (let x 3 (let x 4 x)) x))"
    +Output: 6
    +Explanation: Even though (let x 4 x) has a deeper scope, it is outside the context
     of the final x in the add-expression.  That final x will equal 2.
    +
    -Input: (let a1 3 b2 (add a1 1) b2) -Output 4 -Explanation: Variable names can contain digits after the first character. +

    Example 5:

    +
    +Input: expression = "(let a1 3 b2 (add a1 1) b2)"
    +Output: 4
    +Explanation: Variable names can contain digits after the first character.
     
    -

    Note: -

  • The given string expression is well formatted: There are no leading or trailing spaces, there is only a single space separating different components of the string, and no space between adjacent parentheses. The expression is guaranteed to be legal and evaluate to an integer.
  • -
  • The length of expression is at most 2000. (It is also non-empty, as that would not be a legal expression.)
  • -
  • The answer and all intermediate calculations of that answer are guaranteed to fit in a 32-bit integer.
  • -

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= expression.length <= 2000
    • +
    • There are no leading or trailing spaces in exprssion.
    • +
    • All tokens are separated by a single space in expressoin.
    • +
    • The answer and all intermediate calculations of that answer are guaranteed to fit in a 32-bit integer.
    • +
    • The expression is guaranteed to be legal and evaluate to an integer.
    • +
    ### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/parsing-a-boolean-expression/README.md b/problems/parsing-a-boolean-expression/README.md index 227146bce..540f3d48f 100644 --- a/problems/parsing-a-boolean-expression/README.md +++ b/problems/parsing-a-boolean-expression/README.md @@ -62,6 +62,8 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Recursion](../../tag/recursion/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/partition-array-for-maximum-sum/README.md b/problems/partition-array-for-maximum-sum/README.md index 996870cfb..0822d49cc 100644 --- a/problems/partition-array-for-maximum-sum/README.md +++ b/problems/partition-array-for-maximum-sum/README.md @@ -48,6 +48,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/partition-array-into-three-parts-with-equal-sum/README.md b/problems/partition-array-into-three-parts-with-equal-sum/README.md index 44cc8fba4..9a728e44c 100644 --- a/problems/partition-array-into-three-parts-with-equal-sum/README.md +++ b/problems/partition-array-into-three-parts-with-equal-sum/README.md @@ -48,6 +48,7 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] ### Hints diff --git a/problems/partition-equal-subset-sum/README.md b/problems/partition-equal-subset-sum/README.md index c67044ca8..691f51958 100644 --- a/problems/partition-equal-subset-sum/README.md +++ b/problems/partition-equal-subset-sum/README.md @@ -39,6 +39,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/partition-labels/README.md b/problems/partition-labels/README.md index f2199f2a7..760ae0cf3 100644 --- a/problems/partition-labels/README.md +++ b/problems/partition-labels/README.md @@ -11,35 +11,42 @@ ## [763. Partition Labels (Medium)](https://leetcode.com/problems/partition-labels "划分字母区间") -

    A string s of lowercase English letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing the size of these parts.

    +

    You are given a string s. We want to partition the string into as many parts as possible so that each letter appears in at most one part.

    -

     

    +

    Return a list of integers representing the size of these parts.

    -

    Example 1:

    +

     

    +

    Example 1:

    -Input: s = "ababcbacadefegdehijhklij"
    -Output: [9,7,8]
    -Explanation:
    +Input: s = "ababcbacadefegdehijhklij"
    +Output: [9,7,8]
    +Explanation:
     The partition is "ababcbaca", "defegde", "hijhklij".
     This is a partition so that each letter appears in at most one part.
     A partition like "ababcbacadefegde", "hijhklij" is incorrect, because it splits s into less parts.
     
    -

     

    +

    Example 2:

    -

    Note:

    +
    +Input: s = "eccbbbbdec"
    +Output: [10]
    +
    + +

     

    +

    Constraints:

      -
    • s will have length in range [1, 500].
    • -
    • s will consist of lowercase English letters ('a' to 'z') only.
    • +
    • 1 <= s.length <= 500
    • +
    • s consists of lowercase English letters.
    -

     

    - ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Merge Intervals](../merge-intervals) (Medium) diff --git a/problems/partition-to-k-equal-sum-subsets/README.md b/problems/partition-to-k-equal-sum-subsets/README.md index 6ed708539..3d047fd41 100644 --- a/problems/partition-to-k-equal-sum-subsets/README.md +++ b/problems/partition-to-k-equal-sum-subsets/README.md @@ -39,8 +39,12 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Similar Questions 1. [Partition Equal Subset Sum](../partition-equal-subset-sum) (Medium) diff --git a/problems/partitioning-into-minimum-number-of-deci-binary-numbers/README.md b/problems/partitioning-into-minimum-number-of-deci-binary-numbers/README.md index f9df751b4..382809959 100644 --- a/problems/partitioning-into-minimum-number-of-deci-binary-numbers/README.md +++ b/problems/partitioning-into-minimum-number-of-deci-binary-numbers/README.md @@ -49,6 +49,7 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/pascals-triangle-ii/README.md b/problems/pascals-triangle-ii/README.md index 485894bde..8817e0ce5 100644 --- a/problems/pascals-triangle-ii/README.md +++ b/problems/pascals-triangle-ii/README.md @@ -38,6 +38,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Pascal's Triangle](../pascals-triangle) (Easy) diff --git a/problems/pascals-triangle/README.md b/problems/pascals-triangle/README.md index 05cfa20e7..bab942839 100644 --- a/problems/pascals-triangle/README.md +++ b/problems/pascals-triangle/README.md @@ -32,6 +32,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Pascal's Triangle II](../pascals-triangle-ii) (Easy) diff --git a/problems/patching-array/README.md b/problems/patching-array/README.md index 5848e733c..8bc118c52 100644 --- a/problems/patching-array/README.md +++ b/problems/patching-array/README.md @@ -55,3 +55,4 @@ Explanation: The two patches can be [2, 4]. ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/path-crossing/README.md b/problems/path-crossing/README.md index 59a783cad..7ad9cf22a 100644 --- a/problems/path-crossing/README.md +++ b/problems/path-crossing/README.md @@ -40,6 +40,7 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/path-in-zigzag-labelled-binary-tree/README.md b/problems/path-in-zigzag-labelled-binary-tree/README.md index c32c25e76..30164fa54 100644 --- a/problems/path-in-zigzag-labelled-binary-tree/README.md +++ b/problems/path-in-zigzag-labelled-binary-tree/README.md @@ -44,6 +44,7 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] [[Math](../../tag/math/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/path-sum-ii/README.md b/problems/path-sum-ii/README.md index bcb94c932..adce85256 100644 --- a/problems/path-sum-ii/README.md +++ b/problems/path-sum-ii/README.md @@ -48,7 +48,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Path Sum](../path-sum) (Easy) diff --git a/problems/path-sum-iii/README.md b/problems/path-sum-iii/README.md index 951ad7f08..88f5690c5 100644 --- a/problems/path-sum-iii/README.md +++ b/problems/path-sum-iii/README.md @@ -42,6 +42,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Path Sum](../path-sum) (Easy) diff --git a/problems/path-sum-iv/README.md b/problems/path-sum-iv/README.md index 3218705e0..eee284b9e 100644 --- a/problems/path-sum-iv/README.md +++ b/problems/path-sum-iv/README.md @@ -11,52 +11,13 @@ ## [666. Path Sum IV (Medium)](https://leetcode.com/problems/path-sum-iv "路径总和 IV") -

    If the depth of a tree is smaller than 5, then this tree can be represented by a list of three-digits integers.

    -

    For each integer in this list:

    - -
      -
    1. The hundreds digit represents the depth D of this node, 1 <= D <= 4.
    2. -
    3. The tens digit represents the position P of this node in the level it belongs to, 1 <= P <= 8. The position is the same as that in a full binary tree.
    4. -
    5. The units digit represents the value V of this node, 0 <= V <= 9.
    6. -
    - -

     

    - -

    Given a list of ascending three-digits integers representing a binary tree with the depth smaller than 5, you need to return the sum of all paths from the root towards the leaves.

    - -

    Example 1:

    - -
    Input: [113, 215, 221]
    -Output: 12
    -Explanation: 
    -The tree that the list represents is:
    -    3
    -   / \
    -  5   1
    -
    -The path sum is (3 + 5) + (3 + 1) = 12.
    -
    - -

     

    - -

    Example 2:

    - -
    Input: [113, 221]
    -Output: 4
    -Explanation: 
    -The tree that the list represents is: 
    -    3
    -     \
    -      1
    -
    -The path sum is (3 + 1) = 4.
    -
    - -

     

    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Path Sum](../path-sum) (Easy) diff --git a/problems/path-sum/README.md b/problems/path-sum/README.md index 231679a08..db538a498 100644 --- a/problems/path-sum/README.md +++ b/problems/path-sum/README.md @@ -48,7 +48,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Path Sum II](../path-sum-ii) (Medium) diff --git a/problems/path-with-maximum-gold/README.md b/problems/path-with-maximum-gold/README.md index 878ff1a12..b21af4df4 100644 --- a/problems/path-with-maximum-gold/README.md +++ b/problems/path-with-maximum-gold/README.md @@ -62,7 +62,9 @@ Path to get the maximum gold, 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7. ### Related Topics + [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/path-with-maximum-minimum-value/README.md b/problems/path-with-maximum-minimum-value/README.md index 3a1a7ed12..0f0174ec9 100644 --- a/problems/path-with-maximum-minimum-value/README.md +++ b/problems/path-with-maximum-minimum-value/README.md @@ -11,54 +11,15 @@ ## [1102. Path With Maximum Minimum Value (Medium)](https://leetcode.com/problems/path-with-maximum-minimum-value "得分最高的路径") -

    Given a matrix of integers A with R rows and C columns, find the maximum score of a path starting at [0,0] and ending at [R-1,C-1].

    -

    The score of a path is the minimum value in that path.  For example, the value of the path 8 →  4 →  5 →  9 is 4.

    - -

    A path moves some number of times from one visited cell to any neighbouring unvisited cell in one of the 4 cardinal directions (north, east, west, south).

    - -

     

    - -

    Example 1:

    - -

    - -
    -Input: [[5,4,5],[1,2,6],[7,4,6]]
    -Output: 4
    -Explanation: 
    -The path with the maximum score is highlighted in yellow. 
    -
    - -

    Example 2:

    - -

    - -
    -Input: [[2,2,1,2,2,2],[1,2,2,2,1,2]]
    -Output: 2
    - -

    Example 3:

    - -

    - -
    -Input: [[3,4,6,3,4],[0,2,1,1,7],[8,8,3,2,7],[3,2,4,9,8],[4,1,2,0,0],[4,6,5,4,3]]
    -Output: 3
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= R, C <= 100
    2. -
    3. 0 <= A[i][j] <= 10^9
    4. -
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/path-with-maximum-probability/README.md b/problems/path-with-maximum-probability/README.md index 3ff6d6fce..ba83dc8d4 100644 --- a/problems/path-with-maximum-probability/README.md +++ b/problems/path-with-maximum-probability/README.md @@ -63,6 +63,8 @@ ### Related Topics [[Graph](../../tag/graph/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/path-with-minimum-effort/README.md b/problems/path-with-minimum-effort/README.md index 1b0bbd4e9..f86467458 100644 --- a/problems/path-with-minimum-effort/README.md +++ b/problems/path-with-minimum-effort/README.md @@ -58,10 +58,13 @@ This is better than the route of [1,2,2,2,5], where the maximum absolute differe ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/patients-with-a-condition/README.md b/problems/patients-with-a-condition/README.md index 74001dd54..12471e948 100644 --- a/problems/patients-with-a-condition/README.md +++ b/problems/patients-with-a-condition/README.md @@ -12,3 +12,6 @@ ## [1527. Patients With a Condition (Easy)](https://leetcode.com/problems/patients-with-a-condition "患某种疾病的患者") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/peak-index-in-a-mountain-array/README.md b/problems/peak-index-in-a-mountain-array/README.md index 019cb1b84..05758a2dc 100644 --- a/problems/peak-index-in-a-mountain-array/README.md +++ b/problems/peak-index-in-a-mountain-array/README.md @@ -55,6 +55,7 @@ Follow up: Finding the O(n) is straightforward, could you find an O(log(n)) solution? ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions diff --git a/problems/peeking-iterator/README.md b/problems/peeking-iterator/README.md index 19c92cdea..f3c71d542 100644 --- a/problems/peeking-iterator/README.md +++ b/problems/peeking-iterator/README.md @@ -56,6 +56,8 @@ peekingIterator.hasNext(); // return False ### Related Topics [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + [[Iterator](../../tag/iterator/README.md)] ### Similar Questions 1. [Binary Search Tree Iterator](../binary-search-tree-iterator) (Medium) diff --git a/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md b/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md index d10ea4d3c..86fdbf260 100644 --- a/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md +++ b/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md @@ -55,7 +55,8 @@ Other lists of favorite companies are not a subset of another list, therefore, t ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/percentage-of-users-attended-a-contest/README.md b/problems/percentage-of-users-attended-a-contest/README.md index 98bffa828..ed363bcbd 100644 --- a/problems/percentage-of-users-attended-a-contest/README.md +++ b/problems/percentage-of-users-attended-a-contest/README.md @@ -12,3 +12,6 @@ ## [1633. Percentage of Users Attended a Contest (Easy)](https://leetcode.com/problems/percentage-of-users-attended-a-contest "各赛事的用户注册率") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/perfect-rectangle/README.md b/problems/perfect-rectangle/README.md index 9947173a2..7967cfa49 100644 --- a/problems/perfect-rectangle/README.md +++ b/problems/perfect-rectangle/README.md @@ -58,4 +58,5 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Line Sweep](../../tag/line-sweep/README.md)] diff --git a/problems/perfect-squares/README.md b/problems/perfect-squares/README.md index 2a32572c3..e87e71299 100644 --- a/problems/perfect-squares/README.md +++ b/problems/perfect-squares/README.md @@ -40,7 +40,7 @@ ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/perform-string-shifts/README.md b/problems/perform-string-shifts/README.md index 46b6ad61d..87f73a5e4 100644 --- a/problems/perform-string-shifts/README.md +++ b/problems/perform-string-shifts/README.md @@ -16,6 +16,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/permutation-in-string/README.md b/problems/permutation-in-string/README.md index 315b9f5b9..345a95944 100644 --- a/problems/permutation-in-string/README.md +++ b/problems/permutation-in-string/README.md @@ -40,7 +40,9 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions diff --git a/problems/permutation-sequence/README.md b/problems/permutation-sequence/README.md index 57ba1e116..6fd641631 100644 --- a/problems/permutation-sequence/README.md +++ b/problems/permutation-sequence/README.md @@ -46,8 +46,8 @@ ### Related Topics + [[Recursion](../../tag/recursion/README.md)] [[Math](../../tag/math/README.md)] - [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions 1. [Next Permutation](../next-permutation) (Medium) diff --git a/problems/permutations-ii/README.md b/problems/permutations-ii/README.md index e5a4f804b..e4d819dcf 100644 --- a/problems/permutations-ii/README.md +++ b/problems/permutations-ii/README.md @@ -40,6 +40,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions diff --git a/problems/permutations/README.md b/problems/permutations/README.md index b550c55a1..6e8ecca6b 100644 --- a/problems/permutations/README.md +++ b/problems/permutations/README.md @@ -34,6 +34,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions diff --git a/problems/pizza-with-3n-slices/README.md b/problems/pizza-with-3n-slices/README.md index ead6248cd..3c34d91e4 100644 --- a/problems/pizza-with-3n-slices/README.md +++ b/problems/pizza-with-3n-slices/README.md @@ -69,7 +69,10 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/plus-one-linked-list/README.md b/problems/plus-one-linked-list/README.md index a75d14325..d20fb17e5 100644 --- a/problems/plus-one-linked-list/README.md +++ b/problems/plus-one-linked-list/README.md @@ -11,23 +11,11 @@ ## [369. Plus One Linked List (Medium)](https://leetcode.com/problems/plus-one-linked-list "给单链表加一") -

    Given a non-negative integer represented as non-empty a singly linked list of digits, plus one to the integer.

    -

    You may assume the integer do not contain any leading zero, except the number 0 itself.

    - -

    The digits are stored such that the most significant digit is at the head of the list.

    - -
    -

    Example :

    - -
    -Input: [1,2,3]
    -Output: [1,2,4]
    -
    ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Plus One](../plus-one) (Easy) diff --git a/problems/plus-one/README.md b/problems/plus-one/README.md index af79ddd64..5fdd553d4 100644 --- a/problems/plus-one/README.md +++ b/problems/plus-one/README.md @@ -51,6 +51,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Multiply Strings](../multiply-strings) (Medium) diff --git a/problems/poor-pigs/README.md b/problems/poor-pigs/README.md index ec051e9d2..a63d6d81b 100644 --- a/problems/poor-pigs/README.md +++ b/problems/poor-pigs/README.md @@ -46,6 +46,8 @@ ### Related Topics [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Combinatorics](../../tag/combinatorics/README.md)] ### Hints
    diff --git a/problems/populating-next-right-pointers-in-each-node-ii/README.md b/problems/populating-next-right-pointers-in-each-node-ii/README.md index fa85e4142..8b15d1f52 100644 --- a/problems/populating-next-right-pointers-in-each-node-ii/README.md +++ b/problems/populating-next-right-pointers-in-each-node-ii/README.md @@ -56,7 +56,9 @@ struct Node { ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Populating Next Right Pointers in Each Node](../populating-next-right-pointers-in-each-node) (Medium) diff --git a/problems/populating-next-right-pointers-in-each-node/README.md b/problems/populating-next-right-pointers-in-each-node/README.md index 24f5ca19a..8e3b5a4af 100644 --- a/problems/populating-next-right-pointers-in-each-node/README.md +++ b/problems/populating-next-right-pointers-in-each-node/README.md @@ -56,8 +56,9 @@ struct Node { ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Populating Next Right Pointers in Each Node II](../populating-next-right-pointers-in-each-node-ii) (Medium) diff --git a/problems/positions-of-large-groups/README.md b/problems/positions-of-large-groups/README.md index a1473233e..6431b0375 100644 --- a/problems/positions-of-large-groups/README.md +++ b/problems/positions-of-large-groups/README.md @@ -62,4 +62,4 @@ ### Related Topics - [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/possible-bipartition/README.md b/problems/possible-bipartition/README.md index 42180c352..fc7878def 100644 --- a/problems/possible-bipartition/README.md +++ b/problems/possible-bipartition/README.md @@ -69,5 +69,7 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] diff --git a/problems/pour-water/README.md b/problems/pour-water/README.md index cf4184a63..c3b6d4d6b 100644 --- a/problems/pour-water/README.md +++ b/problems/pour-water/README.md @@ -11,132 +11,11 @@ ## [755. Pour Water (Medium)](https://leetcode.com/problems/pour-water "倒水") -

    -We are given an elevation map, heights[i] representing the height of the terrain at that index. The width at each index is 1. After V units of water fall at index K, how much water is at each index? -

    -Water first drops at index K and rests on top of the highest terrain or water at that index. Then, it flows according to the following rules: -

  • If the droplet would eventually fall by moving left, then move left.
  • -
  • Otherwise, if the droplet would eventually fall by moving right, then move right.
  • -
  • Otherwise, rise at it's current position.
  • -Here, "eventually fall" means that the droplet will eventually be at a lower level if it moves in that direction. -Also, "level" means the height of the terrain plus any water in that column. -

    -We can assume there's infinitely high terrain on the two sides out of bounds of the array. Also, there could not be partial water being spread out evenly on more than 1 grid block - each unit of water has to be in exactly one block. -

    -

    Example 1:
    -

    -Input: heights = [2,1,1,2,1,2,2], V = 4, K = 3
    -Output: [2,2,2,3,2,2,2]
    -Explanation:
    -#       #
    -#       #
    -##  # ###
    -#########
    - 0123456    <- index
    -
    -The first drop of water lands at index K = 3:
    -
    -#       #
    -#   w   #
    -##  # ###
    -#########
    - 0123456    
    -
    -When moving left or right, the water can only move to the same level or a lower level.
    -(By level, we mean the total height of the terrain plus any water in that column.)
    -Since moving left will eventually make it fall, it moves left.
    -(A droplet "made to fall" means go to a lower height than it was at previously.)
    -
    -#       #
    -#       #
    -## w# ###
    -#########
    - 0123456    
    -
    -Since moving left will not make it fall, it stays in place.  The next droplet falls:
    -
    -#       #
    -#   w   #
    -## w# ###
    -#########
    - 0123456  
    -
    -Since the new droplet moving left will eventually make it fall, it moves left.
    -Notice that the droplet still preferred to move left,
    -even though it could move right (and moving right makes it fall quicker.)
    -
    -#       #
    -#  w    #
    -## w# ###
    -#########
    - 0123456  
    -
    -#       #
    -#       #
    -##ww# ###
    -#########
    - 0123456  
    -
    -After those steps, the third droplet falls.
    -Since moving left would not eventually make it fall, it tries to move right.
    -Since moving right would eventually make it fall, it moves right.
    -
    -#       #
    -#   w   #
    -##ww# ###
    -#########
    - 0123456  
    -
    -#       #
    -#       #
    -##ww#w###
    -#########
    - 0123456  
    -
    -Finally, the fourth droplet falls.
    -Since moving left would not eventually make it fall, it tries to move right.
    -Since moving right would not eventually make it fall, it stays in place:
    -
    -#       #
    -#   w   #
    -##ww#w###
    -#########
    - 0123456  
    -
    -The final answer is [2,2,2,3,2,2,2]:
    -
    -    #    
    - ####### 
    - ####### 
    - 0123456 
    -
    -

    - -

    Example 2:
    -

    -Input: heights = [1,2,3,4], V = 2, K = 2
    -Output: [2,3,3,4]
    -Explanation:
    -The last droplet settles at index 1, since moving further left would not cause it to eventually fall to a lower height.
    -
    -

    - -

    Example 3:
    -

    -Input: heights = [3,1,3], V = 5, K = 1
    -Output: [4,4,4]
    -
    -

    - -

    Note:

      -
    1. heights will have length in [1, 100] and contain integers in [0, 99].
    2. -
    3. V will be in range [0, 2000].
    4. -
    5. K will be in range [0, heights.length - 1].
    6. -

    ### Related Topics [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Similar Questions 1. [Trapping Rain Water](../trapping-rain-water) (Hard) diff --git a/problems/power-of-four/README.md b/problems/power-of-four/README.md index 360567d24..ce79b5a6d 100644 --- a/problems/power-of-four/README.md +++ b/problems/power-of-four/README.md @@ -38,6 +38,8 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Power of Two](../power-of-two) (Easy) diff --git a/problems/power-of-three/README.md b/problems/power-of-three/README.md index 8be2c0ac1..e9bd83b14 100644 --- a/problems/power-of-three/README.md +++ b/problems/power-of-three/README.md @@ -40,6 +40,7 @@ Follow up: Could you solve it without loops/recursion? ### Related Topics + [[Recursion](../../tag/recursion/README.md)] [[Math](../../tag/math/README.md)] ### Similar Questions diff --git a/problems/power-of-two/README.md b/problems/power-of-two/README.md index 671d41d3f..7ac540a2a 100644 --- a/problems/power-of-two/README.md +++ b/problems/power-of-two/README.md @@ -65,6 +65,7 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Recursion](../../tag/recursion/README.md)] [[Math](../../tag/math/README.md)] ### Similar Questions diff --git a/problems/powx-n/README.md b/problems/powx-n/README.md index d468700a6..89d9cf803 100644 --- a/problems/powx-n/README.md +++ b/problems/powx-n/README.md @@ -46,8 +46,8 @@ ### Related Topics + [[Recursion](../../tag/recursion/README.md)] [[Math](../../tag/math/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions 1. [Sqrt(x)](../sqrtx) (Easy) diff --git a/problems/predict-the-winner/README.md b/problems/predict-the-winner/README.md index a5a8c3097..58f951db9 100644 --- a/problems/predict-the-winner/README.md +++ b/problems/predict-the-winner/README.md @@ -47,8 +47,11 @@ Finally, player 1 has more score (234) than player 2 (12), so you need to return ### Related Topics - [[Minimax](../../tag/minimax/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] ### Similar Questions 1. [Can I Win](../can-i-win) (Medium) diff --git a/problems/prefix-and-suffix-search/README.md b/problems/prefix-and-suffix-search/README.md index bad5c6e7d..e420268da 100644 --- a/problems/prefix-and-suffix-search/README.md +++ b/problems/prefix-and-suffix-search/README.md @@ -47,7 +47,9 @@ wordFilter.f("a", "e"); // return 0, because the word at ind ### Related Topics + [[Design](../../tag/design/README.md)] [[Trie](../../tag/trie/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Design Add and Search Words Data Structure](../design-add-and-search-words-data-structure) (Medium) diff --git a/problems/preimage-size-of-factorial-zeroes-function/README.md b/problems/preimage-size-of-factorial-zeroes-function/README.md index d28c888a4..0e624d4ff 100644 --- a/problems/preimage-size-of-factorial-zeroes-function/README.md +++ b/problems/preimage-size-of-factorial-zeroes-function/README.md @@ -34,6 +34,7 @@ ### Related Topics + [[Math](../../tag/math/README.md)] [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions diff --git a/problems/primary-department-for-each-employee/README.md b/problems/primary-department-for-each-employee/README.md index ad2dc5ab6..0d304e075 100644 --- a/problems/primary-department-for-each-employee/README.md +++ b/problems/primary-department-for-each-employee/README.md @@ -12,3 +12,6 @@ ## [1789. Primary Department for Each Employee (Easy)](https://leetcode.com/problems/primary-department-for-each-employee "员工的直属部门") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/prime-number-of-set-bits-in-binary-representation/README.md b/problems/prime-number-of-set-bits-in-binary-representation/README.md index 8000228fe..13d7f9159 100644 --- a/problems/prime-number-of-set-bits-in-binary-representation/README.md +++ b/problems/prime-number-of-set-bits-in-binary-representation/README.md @@ -11,28 +11,33 @@ ## [762. Prime Number of Set Bits in Binary Representation (Easy)](https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation "二进制表示中质数个计算置位") -

    Given two integers left and right, find the count of numbers in the range [left, right] (inclusive) having a prime number of set bits in their binary representation.

    +

    Given two integers left and right, return the count of numbers in the inclusive range [left, right] having a prime number of set bits in their binary representation.

    -

    (Recall that the number of set bits an integer has is the number of 1s present when written in binary. For example, 21 written in binary is 10101 which has 3 set bits. Also, 1 is not a prime.)

    +

    Recall that the number of set bits an integer has is the number of 1's present when written in binary.

    -

    Example 1:

    +
      +
    • For example, 21 written in binary is 10101 which has 3 set bits.
    • +
    + +

     

    +

    Example 1:

    -Input: left = 6, right = 10
    -Output: 4
    -Explanation:
    +Input: left = 6, right = 10
    +Output: 4
    +Explanation:
     6 -> 110 (2 set bits, 2 is prime)
     7 -> 111 (3 set bits, 3 is prime)
     9 -> 1001 (2 set bits , 2 is prime)
     10->1010 (2 set bits , 2 is prime)
     
    -

    Example 2:

    +

    Example 2:

    -Input: left = 10, right = 15
    -Output: 5
    -Explanation:
    +Input: left = 10, right = 15
    +Output: 5
    +Explanation:
     10 -> 1010 (2 set bits, 2 is prime)
     11 -> 1011 (3 set bits, 3 is prime)
     12 -> 1100 (2 set bits, 2 is prime)
    @@ -41,15 +46,17 @@
     15 -> 1111 (4 set bits, 4 is not prime)
     
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. left, right will be integers left <= right in the range [1, 10^6].
    2. -
    3. right - left will be at most 10000.
    4. -
    +
      +
    • 1 <= left <= right <= 106
    • +
    • 0 <= right - left <= 104
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Number of 1 Bits](../number-of-1-bits) (Easy) diff --git a/problems/print-binary-tree/README.md b/problems/print-binary-tree/README.md index 4a624859a..76ac13314 100644 --- a/problems/print-binary-tree/README.md +++ b/problems/print-binary-tree/README.md @@ -55,3 +55,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/print-foobar-alternately/README.md b/problems/print-foobar-alternately/README.md index 04d558ad2..871c2b934 100644 --- a/problems/print-foobar-alternately/README.md +++ b/problems/print-foobar-alternately/README.md @@ -49,6 +49,9 @@ class FooBar { Explanation: "foobar" is being output 2 times.
    +### Related Topics + [[Concurrency](../../tag/concurrency/README.md)] + ### Similar Questions 1. [Print in Order](../print-in-order) (Easy) 1. [Print Zero Even Odd](../print-zero-even-odd) (Medium) diff --git a/problems/print-immutable-linked-list-in-reverse/README.md b/problems/print-immutable-linked-list-in-reverse/README.md index 74fabefa4..70120f8cb 100644 --- a/problems/print-immutable-linked-list-in-reverse/README.md +++ b/problems/print-immutable-linked-list-in-reverse/README.md @@ -11,41 +11,10 @@ ## [1265. Print Immutable Linked List in Reverse (Medium)](https://leetcode.com/problems/print-immutable-linked-list-in-reverse "逆序打印不可变链表") -You are given an immutable linked list, print out all values of each node in reverse with the help of the following interface: -- ImmutableListNode: An interface of immutable linked list, you are given the head of the list. -You need to use the following functions to access the linked list (you can't access the ImmutableListNode directly): -- ImmutableListNode.printValue(): Print value of the current node. -- ImmutableListNode.getNext(): Return the next node. -The input is only given to initialize the linked list internally. You must solve this problem without modifying the linked list. In other words, you must operate the linked list using only the mentioned APIs. - -Follow up: - -Could you solve this problem in: - -- Constant space complexity? -- Linear time complexity and less than linear space complexity? - -

    Example 1:

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

    Example 2:

    -
    -Input: head = [0,-4,-1,3,-5]
    -Output: [-5,3,-1,-4,0]
    -
    - -

    Example 3:

    -
    -Input: head = [-2,0,6,4,4,-6]
    -Output: [-6,4,4,6,0,-2]
    -
    - -Constraints: - -- The length of the linked list is between [1, 1000]. -- The value of each node in the linked list is between [-1000, 1000]. +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/print-in-order/README.md b/problems/print-in-order/README.md index 270433f83..f1d1f274e 100644 --- a/problems/print-in-order/README.md +++ b/problems/print-in-order/README.md @@ -44,5 +44,8 @@ public class Foo { Explanation: The input [1,3,2] means thread A calls first(), thread B calls third(), and thread C calls second(). "firstsecondthird" is the correct output.
    +### Related Topics + [[Concurrency](../../tag/concurrency/README.md)] + ### Similar Questions 1. [Print FooBar Alternately](../print-foobar-alternately) (Medium) diff --git a/problems/print-words-vertically/README.md b/problems/print-words-vertically/README.md index ca42eb973..9a5204cdf 100644 --- a/problems/print-words-vertically/README.md +++ b/problems/print-words-vertically/README.md @@ -55,7 +55,9 @@ Each word would be put on only one column and that in one column there will be o ### Related Topics + [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/print-zero-even-odd/README.md b/problems/print-zero-even-odd/README.md index 7ab4b9e8b..69bd1ec94 100644 --- a/problems/print-zero-even-odd/README.md +++ b/problems/print-zero-even-odd/README.md @@ -11,43 +11,58 @@ ## [1116. Print Zero Even Odd (Medium)](https://leetcode.com/problems/print-zero-even-odd "打印零与奇偶数") -

    Suppose you are given the following code:

    +

    You have a function printNumber that can be called with an integer parameter and prints it to the console.

    -
    -class ZeroEvenOdd {
    -  public ZeroEvenOdd(int n) { ... }      // constructor
    -  public void zero(printNumber) { ... }  // only output 0's
    -  public void even(printNumber) { ... }  // only output even numbers
    -  public void odd(printNumber) { ... }   // only output odd numbers
    -}
    -
    +
      +
    • For example, calling printNumber(7) prints 7 to the console.
    • +
    -

    The same instance of ZeroEvenOdd will be passed to three different threads:

    +

    You are given an instance of the class ZeroEvenOdd that has three functions: zero, even, and odd. The same instance of ZeroEvenOdd will be passed to three different threads:

    -
      -
    1. Thread A will call zero() which should only output 0's.
    2. -
    3. Thread B will call even() which should only ouput even numbers.
    4. -
    5. Thread C will call odd() which should only output odd numbers.
    6. -
    +
      +
    • Thread A: calls zero() that should only output 0's.
    • +
    • Thread B: calls even() that should only output even numbers.
    • +
    • Thread C: calls odd() that should only output odd numbers.
    • +
    -

    Each of the threads is given a printNumber method to output an integer. Modify the given program to output the series 010203040506... where the length of the series must be 2n.

    +

    Modify the given class to output the series "010203040506..." where the length of the series must be 2n.

    -

     

    +

    Implement the ZeroEvenOdd class:

    +
      +
    • ZeroEvenOdd(int n) Initializes the object with the number n that represents the numbers that should be printed.
    • +
    • void zero(printNumber) Calls printNumber to output one zero.
    • +
    • void even(printNumber) Calls printNumber to output one even number.
    • +
    • void odd(printNumber) Calls printNumber to output one odd number.
    • +
    + +

     

    Example 1:

    -Input: n = 2
    -Output: "0102"
    -Explanation: There are three threads being fired asynchronously. One of them calls zero(), the other calls even(), and the last one calls odd(). "0102" is the correct output.
    +Input: n = 2
    +Output: "0102"
    +Explanation: There are three threads being fired asynchronously.
    +One of them calls zero(), the other calls even(), and the last one calls odd().
    +"0102" is the correct output.
     

    Example 2:

    -Input: n = 5
    -Output: "0102030405"
    +Input: n = 5
    +Output: "0102030405"
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 1000
    • +
    + +### Related Topics + [[Concurrency](../../tag/concurrency/README.md)] + ### Similar Questions 1. [Print FooBar Alternately](../print-foobar-alternately) (Medium) diff --git a/problems/prison-cells-after-n-days/README.md b/problems/prison-cells-after-n-days/README.md index ddcee25c5..fe203b401 100644 --- a/problems/prison-cells-after-n-days/README.md +++ b/problems/prison-cells-after-n-days/README.md @@ -60,4 +60,7 @@ Day 7: [0, 0, 1, 1, 0, 0, 0, 0] ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md b/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md index b51e1e54b..fd3525ed7 100644 --- a/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md +++ b/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md @@ -81,7 +81,10 @@ Probability = 18 / 60 = 0.3 ### Related Topics [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Combinatorics](../../tag/combinatorics/README.md)] + [[Probability and Statistics](../../tag/probability-and-statistics/README.md)] ### Hints
    diff --git a/problems/process-tasks-using-servers/README.md b/problems/process-tasks-using-servers/README.md index affb20c16..5bd75a390 100644 --- a/problems/process-tasks-using-servers/README.md +++ b/problems/process-tasks-using-servers/README.md @@ -65,7 +65,8 @@ ### Related Topics - [[Heap](../../tag/heap/README.md)] + [[Array](../../tag/array/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/product-of-array-except-self/README.md b/problems/product-of-array-except-self/README.md index a78fdf05c..665cd7199 100644 --- a/problems/product-of-array-except-self/README.md +++ b/problems/product-of-array-except-self/README.md @@ -39,6 +39,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Similar Questions 1. [Trapping Rain Water](../trapping-rain-water) (Hard) diff --git a/problems/product-of-the-last-k-numbers/README.md b/problems/product-of-the-last-k-numbers/README.md index 799a75cc8..d33a5cccc 100644 --- a/problems/product-of-the-last-k-numbers/README.md +++ b/problems/product-of-the-last-k-numbers/README.md @@ -63,8 +63,11 @@ productOfNumbers.getProduct(2); // return 32. The product of the last 2 numbers ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] ### Hints
    diff --git a/problems/product-of-two-run-length-encoded-arrays/README.md b/problems/product-of-two-run-length-encoded-arrays/README.md index ddaf7a428..9968ca9dd 100644 --- a/problems/product-of-two-run-length-encoded-arrays/README.md +++ b/problems/product-of-two-run-length-encoded-arrays/README.md @@ -9,11 +9,12 @@                  [Next >](../longer-contiguous-segments-of-ones-than-zeros "Longer Contiguous Segments of Ones than Zeros") -## [1868. Product of Two Run-Length Encoded Arrays (Medium)](https://leetcode.com/problems/product-of-two-run-length-encoded-arrays "") +## [1868. Product of Two Run-Length Encoded Arrays (Medium)](https://leetcode.com/problems/product-of-two-run-length-encoded-arrays "两个行程编码数组的积") ### Related Topics + [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] ### Hints diff --git a/problems/product-price-at-a-given-date/README.md b/problems/product-price-at-a-given-date/README.md index f1a5121e4..45f6e78c0 100644 --- a/problems/product-price-at-a-given-date/README.md +++ b/problems/product-price-at-a-given-date/README.md @@ -11,44 +11,7 @@ ## [1164. Product Price at a Given Date (Medium)](https://leetcode.com/problems/product-price-at-a-given-date "指定日期的产品价格") -

    Table: Products

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| product_id    | int     |
    -| new_price     | int     |
    -| change_date   | date    |
    -+---------------+---------+
    -(product_id, change_date) is the primary key of this table.
    -Each row of this table indicates that the price of some product was changed to a new price at some date.
    -

     

    - -

    Write an SQL query to find the prices of all products on 2019-08-16. Assume the price of all products before any change is 10.

    - -

    The query result format is in the following example:

    - -
    -Products table:
    -+------------+-----------+-------------+
    -| product_id | new_price | change_date |
    -+------------+-----------+-------------+
    -| 1          | 20        | 2019-08-14  |
    -| 2          | 50        | 2019-08-14  |
    -| 1          | 30        | 2019-08-15  |
    -| 1          | 35        | 2019-08-16  |
    -| 2          | 65        | 2019-08-17  |
    -| 3          | 20        | 2019-08-18  |
    -+------------+-----------+-------------+
    -
    -Result table:
    -+------------+-------+
    -| product_id | price |
    -+------------+-------+
    -| 2          | 50    |
    -| 1          | 35    |
    -| 3          | 10    |
    -+------------+-------+
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/product-sales-analysis-i/README.md b/problems/product-sales-analysis-i/README.md index 791ae7179..bc27e631d 100644 --- a/problems/product-sales-analysis-i/README.md +++ b/problems/product-sales-analysis-i/README.md @@ -11,66 +11,7 @@ ## [1068. Product Sales Analysis I (Easy)](https://leetcode.com/problems/product-sales-analysis-i "产品销售分析 I") -

    Table: Sales

    -
    -+-------------+-------+
    -| Column Name | Type  |
    -+-------------+-------+
    -| sale_id     | int   |
    -| product_id  | int   |
    -| year        | int   |
    -| quantity    | int   |
    -| price       | int   |
    -+-------------+-------+
    -(sale_id, year) is the primary key of this table.
    -product_id is a foreign key to Product table.
    -Note that the price is per unit.
    -
    -

    Table: Product

    - -
    -+--------------+---------+
    -| Column Name  | Type    |
    -+--------------+---------+
    -| product_id   | int     |
    -| product_name | varchar |
    -+--------------+---------+
    -product_id is the primary key of this table.
    -
    - -

     

    - -

    Write an SQL query that reports all product names of the products in the Sales table along with their selling year and price.

    - -

    For example:

    - -
    -Sales table:
    -+---------+------------+------+----------+-------+
    -| sale_id | product_id | year | quantity | price |
    -+---------+------------+------+----------+-------+ 
    -| 1       | 100        | 2008 | 10       | 5000  |
    -| 2       | 100        | 2009 | 12       | 5000  |
    -| 7       | 200        | 2011 | 15       | 9000  |
    -+---------+------------+------+----------+-------+
    -
    -Product table:
    -+------------+--------------+
    -| product_id | product_name |
    -+------------+--------------+
    -| 100        | Nokia        |
    -| 200        | Apple        |
    -| 300        | Samsung      |
    -+------------+--------------+
    -
    -Result table:
    -+--------------+-------+-------+
    -| product_name | year  | price |
    -+--------------+-------+-------+
    -| Nokia        | 2008  | 5000  |
    -| Nokia        | 2009  | 5000  |
    -| Apple        | 2011  | 9000  |
    -+--------------+-------+-------+
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/product-sales-analysis-ii/README.md b/problems/product-sales-analysis-ii/README.md index e0c5912a7..3dacdaeef 100644 --- a/problems/product-sales-analysis-ii/README.md +++ b/problems/product-sales-analysis-ii/README.md @@ -11,64 +11,7 @@ ## [1069. Product Sales Analysis II (Easy)](https://leetcode.com/problems/product-sales-analysis-ii "产品销售分析 II") -

    Table: Sales

    -
    -+-------------+-------+
    -| Column Name | Type  |
    -+-------------+-------+
    -| sale_id     | int   |
    -| product_id  | int   |
    -| year        | int   |
    -| quantity    | int   |
    -| price       | int   |
    -+-------------+-------+
    -sale_id is the primary key of this table.
    -product_id is a foreign key to Product table.
    -Note that the price is per unit.
    -
    -

    Table: Product

    - -
    -+--------------+---------+
    -| Column Name  | Type    |
    -+--------------+---------+
    -| product_id   | int     |
    -| product_name | varchar |
    -+--------------+---------+
    -product_id is the primary key of this table.
    -
    - -

     

    - -

    Write an SQL query that reports the total quantity sold for every product id.

    - -

    The query result format is in the following example:

    - -
    -Sales table:
    -+---------+------------+------+----------+-------+
    -| sale_id | product_id | year | quantity | price |
    -+---------+------------+------+----------+-------+ 
    -| 1       | 100        | 2008 | 10       | 5000  |
    -| 2       | 100        | 2009 | 12       | 5000  |
    -| 7       | 200        | 2011 | 15       | 9000  |
    -+---------+------------+------+----------+-------+
    -
    -Product table:
    -+------------+--------------+
    -| product_id | product_name |
    -+------------+--------------+
    -| 100        | Nokia        |
    -| 200        | Apple        |
    -| 300        | Samsung      |
    -+------------+--------------+
    -
    -Result table:
    -+--------------+----------------+
    -| product_id   | total_quantity |
    -+--------------+----------------+
    -| 100          | 22             |
    -| 200          | 15             |
    -+--------------+----------------+
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/product-sales-analysis-iii/README.md b/problems/product-sales-analysis-iii/README.md index 611a1157b..452616894 100644 --- a/problems/product-sales-analysis-iii/README.md +++ b/problems/product-sales-analysis-iii/README.md @@ -11,65 +11,7 @@ ## [1070. Product Sales Analysis III (Medium)](https://leetcode.com/problems/product-sales-analysis-iii "产品销售分析 III") -

    Table: Sales

    -
    -+-------------+-------+
    -| Column Name | Type  |
    -+-------------+-------+
    -| sale_id     | int   |
    -| product_id  | int   |
    -| year        | int   |
    -| quantity    | int   |
    -| price       | int   |
    -+-------------+-------+
    -sale_id is the primary key of this table.
    -product_id is a foreign key to Product table.
    -Note that the price is per unit.
    -
    -

    Table: Product

    - -
    -+--------------+---------+
    -| Column Name  | Type    |
    -+--------------+---------+
    -| product_id   | int     |
    -| product_name | varchar |
    -+--------------+---------+
    -product_id is the primary key of this table.
    -
    - -

     

    - -

    Write an SQL query that selects the product id, year, quantity, and price for the first year of every product sold.

    - -

    The query result format is in the following example:

    - -
    -Sales table:
    -+---------+------------+------+----------+-------+
    -| sale_id | product_id | year | quantity | price |
    -+---------+------------+------+----------+-------+ 
    -| 1       | 100        | 2008 | 10       | 5000  |
    -| 2       | 100        | 2009 | 12       | 5000  |
    -| 7       | 200        | 2011 | 15       | 9000  |
    -+---------+------------+------+----------+-------+
    -
    -Product table:
    -+------------+--------------+
    -| product_id | product_name |
    -+------------+--------------+
    -| 100        | Nokia        |
    -| 200        | Apple        |
    -| 300        | Samsung      |
    -+------------+--------------+
    -
    -Result table:
    -+------------+------------+----------+-------+
    -| product_id | first_year | quantity | price |
    -+------------+------------+----------+-------+ 
    -| 100        | 2008       | 10       | 5000  |
    -| 200        | 2011       | 15       | 9000  |
    -+------------+------------+----------+-------+
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/products-price-for-each-store/README.md b/problems/products-price-for-each-store/README.md index 2cf997444..c71de0528 100644 --- a/problems/products-price-for-each-store/README.md +++ b/problems/products-price-for-each-store/README.md @@ -12,3 +12,6 @@ ## [1777. Product's Price for Each Store (Easy)](https://leetcode.com/problems/products-price-for-each-store "每家商店的产品价格") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/products-worth-over-invoices/README.md b/problems/products-worth-over-invoices/README.md index 175170405..1524ab49b 100644 --- a/problems/products-worth-over-invoices/README.md +++ b/problems/products-worth-over-invoices/README.md @@ -12,3 +12,6 @@ ## [1677. Product's Worth Over Invoices (Easy)](https://leetcode.com/problems/products-worth-over-invoices "发票中的产品金额") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/profitable-schemes/README.md b/problems/profitable-schemes/README.md index bfb99ea9b..5573231e3 100644 --- a/problems/profitable-schemes/README.md +++ b/problems/profitable-schemes/README.md @@ -47,4 +47,5 @@ There are 7 possible schemes: (0), (1), (2), (0,1), (0,2), (1,2), and (0,1,2). ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/project-employees-i/README.md b/problems/project-employees-i/README.md index ddd837561..809adbe71 100644 --- a/problems/project-employees-i/README.md +++ b/problems/project-employees-i/README.md @@ -11,66 +11,7 @@ ## [1075. Project Employees I (Easy)](https://leetcode.com/problems/project-employees-i "项目员工 I") -

    Table: Project

    -
    -+-------------+---------+
    -| Column Name | Type    |
    -+-------------+---------+
    -| project_id  | int     |
    -| employee_id | int     |
    -+-------------+---------+
    -(project_id, employee_id) is the primary key of this table.
    -employee_id is a foreign key to Employee table.
    -
    -

    Table: Employee

    - -
    -+------------------+---------+
    -| Column Name      | Type    |
    -+------------------+---------+
    -| employee_id      | int     |
    -| name             | varchar |
    -| experience_years | int     |
    -+------------------+---------+
    -employee_id is the primary key of this table.
    -
    - -

     

    - -

    Write an SQL query that reports the average experience years of all the employees for each project, rounded to 2 digits.

    - -

    The query result format is in the following example:

    - -
    -Project table:
    -+-------------+-------------+
    -| project_id  | employee_id |
    -+-------------+-------------+
    -| 1           | 1           |
    -| 1           | 2           |
    -| 1           | 3           |
    -| 2           | 1           |
    -| 2           | 4           |
    -+-------------+-------------+
    -
    -Employee table:
    -+-------------+--------+------------------+
    -| employee_id | name   | experience_years |
    -+-------------+--------+------------------+
    -| 1           | Khaled | 3                |
    -| 2           | Ali    | 2                |
    -| 3           | John   | 1                |
    -| 4           | Doe    | 2                |
    -+-------------+--------+------------------+
    -
    -Result table:
    -+-------------+---------------+
    -| project_id  | average_years |
    -+-------------+---------------+
    -| 1           | 2.00          |
    -| 2           | 2.50          |
    -+-------------+---------------+
    -The average experience years for the first project is (3 + 2 + 1) / 3 = 2.00 and for the second project is (3 + 2) / 2 = 2.50
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/project-employees-ii/README.md b/problems/project-employees-ii/README.md index d8f033adc..740494b48 100644 --- a/problems/project-employees-ii/README.md +++ b/problems/project-employees-ii/README.md @@ -11,64 +11,7 @@ ## [1076. Project Employees II (Easy)](https://leetcode.com/problems/project-employees-ii "项目员工II") -

    Table: Project

    -
    -+-------------+---------+
    -| Column Name | Type    |
    -+-------------+---------+
    -| project_id  | int     |
    -| employee_id | int     |
    -+-------------+---------+
    -(project_id, employee_id) is the primary key of this table.
    -employee_id is a foreign key to Employee table.
    -
    -

    Table: Employee

    - -
    -+------------------+---------+
    -| Column Name      | Type    |
    -+------------------+---------+
    -| employee_id      | int     |
    -| name             | varchar |
    -| experience_years | int     |
    -+------------------+---------+
    -employee_id is the primary key of this table.
    -
    - -

     

    - -

    Write an SQL query that reports all the projects that have the most employees.

    - -

    The query result format is in the following example:

    - -
    -Project table:
    -+-------------+-------------+
    -| project_id  | employee_id |
    -+-------------+-------------+
    -| 1           | 1           |
    -| 1           | 2           |
    -| 1           | 3           |
    -| 2           | 1           |
    -| 2           | 4           |
    -+-------------+-------------+
    -
    -Employee table:
    -+-------------+--------+------------------+
    -| employee_id | name   | experience_years |
    -+-------------+--------+------------------+
    -| 1           | Khaled | 3                |
    -| 2           | Ali    | 2                |
    -| 3           | John   | 1                |
    -| 4           | Doe    | 2                |
    -+-------------+--------+------------------+
    -
    -Result table:
    -+-------------+
    -| project_id  |
    -+-------------+
    -| 1           |
    -+-------------+
    -The first project has 3 employees while the second one has 2.
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/project-employees-iii/README.md b/problems/project-employees-iii/README.md index 7e6f0c7bd..205f55327 100644 --- a/problems/project-employees-iii/README.md +++ b/problems/project-employees-iii/README.md @@ -11,66 +11,7 @@ ## [1077. Project Employees III (Medium)](https://leetcode.com/problems/project-employees-iii "项目员工 III") -

    Table: Project

    -
    -+-------------+---------+
    -| Column Name | Type    |
    -+-------------+---------+
    -| project_id  | int     |
    -| employee_id | int     |
    -+-------------+---------+
    -(project_id, employee_id) is the primary key of this table.
    -employee_id is a foreign key to Employee table.
    -
    -

    Table: Employee

    - -
    -+------------------+---------+
    -| Column Name      | Type    |
    -+------------------+---------+
    -| employee_id      | int     |
    -| name             | varchar |
    -| experience_years | int     |
    -+------------------+---------+
    -employee_id is the primary key of this table.
    -
    - -

     

    - -

    Write an SQL query that reports the most experienced employees in each project. In case of a tie, report all employees with the maximum number of experience years.

    - -

    The query result format is in the following example:

    - -
    -Project table:
    -+-------------+-------------+
    -| project_id  | employee_id |
    -+-------------+-------------+
    -| 1           | 1           |
    -| 1           | 2           |
    -| 1           | 3           |
    -| 2           | 1           |
    -| 2           | 4           |
    -+-------------+-------------+
    -
    -Employee table:
    -+-------------+--------+------------------+
    -| employee_id | name   | experience_years |
    -+-------------+--------+------------------+
    -| 1           | Khaled | 3                |
    -| 2           | Ali    | 2                |
    -| 3           | John   | 3                |
    -| 4           | Doe    | 2                |
    -+-------------+--------+------------------+
    -
    -Result table:
    -+-------------+---------------+
    -| project_id  | employee_id   |
    -+-------------+---------------+
    -| 1           | 1             |
    -| 1           | 3             |
    -| 2           | 1             |
    -+-------------+---------------+
    -Both employees with id 1 and 3 have the most experience among the employees of the first project. For the second project, the employee with id 1 has the most experience.
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/projection-area-of-3d-shapes/README.md b/problems/projection-area-of-3d-shapes/README.md index 0bd685f7e..5d23f8dbe 100644 --- a/problems/projection-area-of-3d-shapes/README.md +++ b/problems/projection-area-of-3d-shapes/README.md @@ -69,4 +69,7 @@ ### Related Topics + [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md b/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md index 0b14c5012..074c5ea1c 100644 --- a/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md +++ b/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md @@ -54,7 +54,9 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/push-dominoes/README.md b/problems/push-dominoes/README.md index b846d55ec..fed3b8908 100644 --- a/problems/push-dominoes/README.md +++ b/problems/push-dominoes/README.md @@ -53,4 +53,5 @@ ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/put-boxes-into-the-warehouse-i/README.md b/problems/put-boxes-into-the-warehouse-i/README.md index d35fb933c..b285a7652 100644 --- a/problems/put-boxes-into-the-warehouse-i/README.md +++ b/problems/put-boxes-into-the-warehouse-i/README.md @@ -15,6 +15,8 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/put-boxes-into-the-warehouse-ii/README.md b/problems/put-boxes-into-the-warehouse-ii/README.md index f0226fc91..0783da49d 100644 --- a/problems/put-boxes-into-the-warehouse-ii/README.md +++ b/problems/put-boxes-into-the-warehouse-ii/README.md @@ -15,6 +15,8 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/pyramid-transition-matrix/README.md b/problems/pyramid-transition-matrix/README.md index 69faa941a..e40f94020 100644 --- a/problems/pyramid-transition-matrix/README.md +++ b/problems/pyramid-transition-matrix/README.md @@ -58,4 +58,5 @@ Note that there could be allowed triples (A, B, C) and (A, B, D) with C != D. ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/queens-that-can-attack-the-king/README.md b/problems/queens-that-can-attack-the-king/README.md index d10e1a712..bb2c5afe0 100644 --- a/problems/queens-that-can-attack-the-king/README.md +++ b/problems/queens-that-can-attack-the-king/README.md @@ -62,6 +62,8 @@ The queen at [2,4] can't attack the king cause it's not in the same row/ ### Related Topics [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/queries-on-a-permutation-with-key/README.md b/problems/queries-on-a-permutation-with-key/README.md index 7db1e71a3..60eb9a5fb 100644 --- a/problems/queries-on-a-permutation-with-key/README.md +++ b/problems/queries-on-a-permutation-with-key/README.md @@ -58,7 +58,9 @@ Therefore, the array containing the result is [2,1,2,1]. ### Related Topics + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/queries-on-number-of-points-inside-a-circle/README.md b/problems/queries-on-number-of-points-inside-a-circle/README.md index c716702d1..ccef067ca 100644 --- a/problems/queries-on-number-of-points-inside-a-circle/README.md +++ b/problems/queries-on-number-of-points-inside-a-circle/README.md @@ -56,6 +56,8 @@ queries[0] is green, queries[1] is red, queries[2] is blue, and queries[3] is pu

    Follow up: Could you find the answer for each query in better complexity than O(n)?

    ### Related Topics + [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] ### Hints diff --git a/problems/queries-quality-and-percentage/README.md b/problems/queries-quality-and-percentage/README.md index 8d7f56944..14ca53a4c 100644 --- a/problems/queries-quality-and-percentage/README.md +++ b/problems/queries-quality-and-percentage/README.md @@ -11,67 +11,7 @@ ## [1211. Queries Quality and Percentage (Easy)](https://leetcode.com/problems/queries-quality-and-percentage "查询结果的质量和占比") -

    Table: Queries

    -
    -+-------------+---------+
    -| Column Name | Type    |
    -+-------------+---------+
    -| query_name  | varchar |
    -| result      | varchar |
    -| position    | int     |
    -| rating      | int     |
    -+-------------+---------+
    -There is no primary key for this table, it may have duplicate rows.
    -This table contains information collected from some queries on a database.
    -The position column has a value from 1 to 500.
    -The rating column has a value from 1 to 5. Query with rating less than 3 is a poor query.
    -
    -

     

    - -

    We define query quality as:

    - -
    -

    The average of the ratio between query rating and its position.

    -
    - -

    We also define poor query percentage as:

    - -
    -

    The percentage of all queries with rating less than 3.

    -
    - -

    Write an SQL query to find each query_name, the quality and poor_query_percentage.

    - -

    Both quality and poor_query_percentage should be rounded to 2 decimal places.

    - -

    The query result format is in the following example:

    - -
    -Queries table:
    -+------------+-------------------+----------+--------+
    -| query_name | result            | position | rating |
    -+------------+-------------------+----------+--------+
    -| Dog        | Golden Retriever  | 1        | 5      |
    -| Dog        | German Shepherd   | 2        | 5      |
    -| Dog        | Mule              | 200      | 1      |
    -| Cat        | Shirazi           | 5        | 2      |
    -| Cat        | Siamese           | 3        | 3      |
    -| Cat        | Sphynx            | 7        | 4      |
    -+------------+-------------------+----------+--------+
    -
    -Result table:
    -+------------+---------+-----------------------+
    -| query_name | quality | poor_query_percentage |
    -+------------+---------+-----------------------+
    -| Dog        | 2.50    | 33.33                 |
    -| Cat        | 0.66    | 33.33                 |
    -+------------+---------+-----------------------+
    -
    -Dog queries quality is ((5 / 1) + (5 / 2) + (1 / 200)) / 3 = 2.50
    -Dog queries poor_ query_percentage is (1 / 3) * 100 = 33.33
    -
    -Cat queries quality equals ((2 / 5) + (3 / 3) + (4 / 7)) / 3 = 0.66
    -Cat queries poor_ query_percentage is (1 / 3) * 100 = 33.33
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/queue-reconstruction-by-height/README.md b/problems/queue-reconstruction-by-height/README.md index 44686b402..e06f59238 100644 --- a/problems/queue-reconstruction-by-height/README.md +++ b/problems/queue-reconstruction-by-height/README.md @@ -50,6 +50,8 @@ Hence [[5,0],[7,0],[5,2],[6,1],[4,4],[7,1]] is the reconstructed queue. ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Count of Smaller Numbers After Self](../count-of-smaller-numbers-after-self) (Hard) diff --git a/problems/rabbits-in-forest/README.md b/problems/rabbits-in-forest/README.md index 1f8153873..5e6e5e227 100644 --- a/problems/rabbits-in-forest/README.md +++ b/problems/rabbits-in-forest/README.md @@ -11,35 +11,40 @@ ## [781. Rabbits in Forest (Medium)](https://leetcode.com/problems/rabbits-in-forest "森林中的兔子") -

    In a forest, each rabbit has some color. Some subset of rabbits (possibly all of them) tell you how many other rabbits have the same color as them. Those answers are placed in an array.

    +

    There is a forest with an unknown number of rabbits. We asked n rabbits "How many rabbits have the same color as you?" and collected the answers in an integer array answers where answers[i] is the answer of the ith rabbit.

    -

    Return the minimum number of rabbits that could be in the forest.

    +

    Given the array answers, return the minimum number of rabbits that could be in the forest.

    + +

     

    +

    Example 1:

    -Examples:
    -Input: answers = [1, 1, 2]
    +Input: answers = [1,1,2]
     Output: 5
     Explanation:
     The two rabbits that answered "1" could both be the same color, say red.
    -The rabbit than answered "2" can't be red or the answers would be inconsistent.
    +The rabbit that answered "2" can't be red or the answers would be inconsistent.
     Say the rabbit that answered "2" was blue.
     Then there should be 2 other blue rabbits in the forest that didn't answer into the array.
     The smallest possible number of rabbits in the forest is therefore 5: 3 that answered plus 2 that didn't.
    +
    -Input: answers = [10, 10, 10] -Output: 11 +

    Example 2:

    -Input: answers = [] -Output: 0 +
    +Input: answers = [10,10,10]
    +Output: 11
     
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. answers will have length at most 1000.
    2. -
    3. Each answers[i] will be an integer in the range [0, 999].
    4. -
    +
      +
    • 1 <= answers.length <= 1000
    • +
    • 0 <= answers[i] < 1000
    • +
    ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/race-car/README.md b/problems/race-car/README.md index 65ab13f54..bbb7c6451 100644 --- a/problems/race-car/README.md +++ b/problems/race-car/README.md @@ -61,5 +61,4 @@ Your position goes from 0 --> 1 --> 3 --> 7 --> 7 --> 6. ### Related Topics - [[Heap](../../tag/heap/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/random-flip-matrix/README.md b/problems/random-flip-matrix/README.md index 7ab9fdd9b..f85606dbf 100644 --- a/problems/random-flip-matrix/README.md +++ b/problems/random-flip-matrix/README.md @@ -46,4 +46,7 @@

    The input is two lists: the subroutines called and their arguments. Solution's constructor has two arguments, n_rows and n_colsflip and reset have no arguments. Arguments are always wrapped with a list, even if there aren't any.

    ### Related Topics - [[Random](../../tag/random/README.md)] + [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] + [[Randomized](../../tag/randomized/README.md)] diff --git a/problems/random-pick-index/README.md b/problems/random-pick-index/README.md index 0ca6f4c30..01f9412be 100644 --- a/problems/random-pick-index/README.md +++ b/problems/random-pick-index/README.md @@ -49,6 +49,9 @@ solution.pick(3); // It should return either index 2, 3, or 4 randomly. Each ind ### Related Topics [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] + [[Randomized](../../tag/randomized/README.md)] ### Similar Questions 1. [Linked List Random Node](../linked-list-random-node) (Medium) diff --git a/problems/random-pick-with-blacklist/README.md b/problems/random-pick-with-blacklist/README.md index ceb631c75..610d14199 100644 --- a/problems/random-pick-with-blacklist/README.md +++ b/problems/random-pick-with-blacklist/README.md @@ -64,10 +64,11 @@

    The input is two lists: the subroutines called and their arguments. Solution's constructor has two arguments, n and the blacklist blacklist. pick has no arguments. Arguments are always wrapped with a list, even if there aren't any.

    ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Random](../../tag/random/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Randomized](../../tag/randomized/README.md)] ### Similar Questions 1. [Random Pick Index](../random-pick-index) (Medium) diff --git a/problems/random-pick-with-weight/README.md b/problems/random-pick-with-weight/README.md index ec1328c8e..a9dd6b22b 100644 --- a/problems/random-pick-with-weight/README.md +++ b/problems/random-pick-with-weight/README.md @@ -69,8 +69,10 @@ and so on. ### Related Topics + [[Math](../../tag/math/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Random](../../tag/random/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Randomized](../../tag/randomized/README.md)] ### Similar Questions 1. [Random Pick Index](../random-pick-index) (Medium) diff --git a/problems/random-point-in-non-overlapping-rectangles/README.md b/problems/random-point-in-non-overlapping-rectangles/README.md index 9631b5baa..8cbb74788 100644 --- a/problems/random-point-in-non-overlapping-rectangles/README.md +++ b/problems/random-point-in-non-overlapping-rectangles/README.md @@ -59,8 +59,12 @@
    ### Related Topics + [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] + [[Math](../../tag/math/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Random](../../tag/random/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Randomized](../../tag/randomized/README.md)] ### Similar Questions 1. [Random Pick with Weight](../random-pick-with-weight) (Medium) diff --git a/problems/range-addition-ii/README.md b/problems/range-addition-ii/README.md index 6ef6fca3a..95f4f4aa2 100644 --- a/problems/range-addition-ii/README.md +++ b/problems/range-addition-ii/README.md @@ -50,6 +50,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] ### Similar Questions diff --git a/problems/range-addition/README.md b/problems/range-addition/README.md index f15faa682..5b7248bc6 100644 --- a/problems/range-addition/README.md +++ b/problems/range-addition/README.md @@ -11,37 +11,11 @@ ## [370. Range Addition (Medium)](https://leetcode.com/problems/range-addition "区间加法") -

    Assume you have an array of length n initialized with all 0's and are given k update operations.

    -

    Each operation is represented as a triplet: [startIndex, endIndex, inc] which increments each element of subarray A[startIndex ... endIndex] (startIndex and endIndex inclusive) with inc.

    - -

    Return the modified array after all k operations were executed.

    - -

    Example:

    - -
    -Input: length = 5, updates = [[1,3,2],[2,4,3],[0,2,-2]]
    -Output: [-2,0,3,5,3]
    -
    - -

    Explanation:

    - -
    -Initial state:
    -[0,0,0,0,0]
    -
    -After applying operation [1,3,2]:
    -[0,2,2,2,0]
    -
    -After applying operation [2,4,3]:
    -[0,2,5,5,3]
    -
    -After applying operation [0,2,-2]:
    -[-2,0,3,5,3]
    -
    ### Related Topics [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Similar Questions 1. [Range Addition II](../range-addition-ii) (Easy) diff --git a/problems/range-module/README.md b/problems/range-module/README.md index ceec5b9fd..b75b4a945 100644 --- a/problems/range-module/README.md +++ b/problems/range-module/README.md @@ -11,37 +11,56 @@ ## [715. Range Module (Hard)](https://leetcode.com/problems/range-module "Range 模块") -

    A Range Module is a module that tracks ranges of numbers. Your task is to design and implement the following interfaces in an efficient manner.

    +

    A Range Module is a module that tracks ranges of numbers. Design a data structure to track the ranges represented as half-open intervals and query about them.

    -

  • addRange(int left, int right) Adds the half-open interval [left, right), tracking every real number in that interval. Adding an interval that partially overlaps with currently tracked numbers should add any numbers in the interval [left, right) that are not already tracked.
  • +

    A half-open interval [left, right) denotes all the real numbers x where left <= x < right.

    -

  • queryRange(int left, int right) Returns true if and only if every real number in the interval [left, right) - is currently being tracked.
  • +

    Implement the RangeModule class:

    -

  • removeRange(int left, int right) Stops tracking every real number currently being tracked in the interval [left, right).
  • +
      +
    • RangeModule() Initializes the object of the data structure.
    • +
    • void addRange(int left, int right) Adds the half-open interval [left, right), tracking every real number in that interval. Adding an interval that partially overlaps with currently tracked numbers should add any numbers in the interval [left, right) that are not already tracked.
    • +
    + +
      +
    • boolean queryRange(int left, int right) Returns true if every real number in the interval [left, right) is currently being tracked, and false otherwise.
    • +
    + +
      +
    • void removeRange(int left, int right) Stops tracking every real number currently being tracked in the half-open interval [left, right).
    • +
    + +

     

    +

    Example 1:

    -

    Example 1:

    -addRange(10, 20): null
    -removeRange(14, 16): null
    -queryRange(10, 14): true (Every number in [10, 14) is being tracked)
    -queryRange(13, 15): false (Numbers like 14, 14.03, 14.17 in [13, 15) are not being tracked)
    -queryRange(16, 17): true (The number 16 in [16, 17) is still being tracked, despite the remove operation)
    +Input
    +["RangeModule", "addRange", "removeRange", "queryRange", "queryRange", "queryRange"]
    +[[], [10, 20], [14, 16], [10, 14], [13, 15], [16, 17]]
    +Output
    +[null, null, null, true, false, true]
    +
    +Explanation
    +RangeModule rangeModule = new RangeModule();
    +rangeModule.addRange(10, 20);
    +rangeModule.removeRange(14, 16);
    +rangeModule.queryRange(10, 14); // return True,(Every number in [10, 14) is being tracked)
    +rangeModule.queryRange(13, 15); // return False,(Numbers like 14, 14.03, 14.17 in [13, 15) are not being tracked)
    +rangeModule.queryRange(16, 17); // return True, (The number 16 in [16, 17) is still being tracked, despite the remove operation)
     
    -

    -

    Note: -

  • A half open interval [left, right) denotes all real numbers left <= x < right.
  • +

     

    +

    Constraints:

    -
  • 0 < left < right < 10^9 in all calls to addRange, queryRange, removeRange.
  • -
  • The total number of calls to addRange in a single test case is at most 1000.
  • -
  • The total number of calls to queryRange in a single test case is at most 5000.
  • -
  • The total number of calls to removeRange in a single test case is at most 1000.
  • -

    +
      +
    • 1 <= left < right <= 109
    • +
    • At most 104 calls will be made to addRange, queryRange, and removeRange.
    • +
    ### Related Topics + [[Design](../../tag/design/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] - [[Ordered Map](../../tag/ordered-map/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions 1. [Merge Intervals](../merge-intervals) (Medium) diff --git a/problems/range-sum-of-bst/README.md b/problems/range-sum-of-bst/README.md index 5639ef0aa..0f677dbe8 100644 --- a/problems/range-sum-of-bst/README.md +++ b/problems/range-sum-of-bst/README.md @@ -42,5 +42,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Recursion](../../tag/recursion/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/range-sum-of-sorted-subarray-sums/README.md b/problems/range-sum-of-sorted-subarray-sums/README.md index 0efde7a1c..cb299d5ef 100644 --- a/problems/range-sum-of-sorted-subarray-sums/README.md +++ b/problems/range-sum-of-sorted-subarray-sums/README.md @@ -11,9 +11,9 @@ ## [1508. Range Sum of Sorted Subarray Sums (Medium)](https://leetcode.com/problems/range-sum-of-sorted-subarray-sums "子数组和排序后的区间和") -

    Given the array nums consisting of n positive integers. You computed the sum of all non-empty continous subarrays from the array and then sort them in non-decreasing order, creating a new array of n * (n + 1) / 2 numbers.

    +

    You are given the array nums consisting of n positive integers. You computed the sum of all non-empty continuous subarrays from the array and then sorted them in non-decreasing order, creating a new array of n * (n + 1) / 2 numbers.

    -

    Return the sum of the numbers from index left to index right (indexed from 1), inclusive, in the new array. Since the answer can be a huge number return it modulo 10^9 + 7.

    +

    Return the sum of the numbers from index left to index right (indexed from 1), inclusive, in the new array. Since the answer can be a huge number return it modulo 109 + 7.

     

    Example 1:

    @@ -43,15 +43,17 @@

    Constraints:

      -
    • 1 <= nums.length <= 10^3
    • -
    • nums.length == n
    • +
    • n == nums.length
    • +
    • 1 <= nums.length <= 1000
    • 1 <= nums[i] <= 100
    • -
    • 1 <= left <= right <= n * (n + 1) / 2
    • +
    • 1 <= left <= right <= n * (n + 1) / 2
    ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/range-sum-query-2d-immutable/README.md b/problems/range-sum-query-2d-immutable/README.md index 4e85d22e3..00f1ce3f4 100644 --- a/problems/range-sum-query-2d-immutable/README.md +++ b/problems/range-sum-query-2d-immutable/README.md @@ -55,7 +55,10 @@ numMatrix.sumRegion(1, 2, 2, 4); // return 12 (i.e sum of the blue rectangle) ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Similar Questions 1. [Range Sum Query - Immutable](../range-sum-query-immutable) (Easy) diff --git a/problems/range-sum-query-2d-mutable/README.md b/problems/range-sum-query-2d-mutable/README.md index d52fb6950..d3c48125f 100644 --- a/problems/range-sum-query-2d-mutable/README.md +++ b/problems/range-sum-query-2d-mutable/README.md @@ -11,40 +11,14 @@ ## [308. Range Sum Query 2D - Mutable (Hard)](https://leetcode.com/problems/range-sum-query-2d-mutable "二维区域和检索 - 可变") -

    Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).

    -

    -Range Sum Query 2D
    -The above rectangle (with the red border) is defined by (row1, col1) = (2, 1) and (row2, col2) = (4, 3), which contains sum = 8. -

    - -

    Example:
    -

    -Given matrix = [
    -  [3, 0, 1, 4, 2],
    -  [5, 6, 3, 2, 1],
    -  [1, 2, 0, 1, 5],
    -  [4, 1, 0, 1, 7],
    -  [1, 0, 3, 0, 5]
    -]
    -
    -sumRegion(2, 1, 4, 3) -> 8
    -update(3, 2, 2)
    -sumRegion(2, 1, 4, 3) -> 10
    -
    -

    - -

    Note:
    -

      -
    1. The matrix is only modifiable by the update function.
    2. -
    3. You may assume the number of calls to update and sumRegion function is distributed evenly.
    4. -
    5. You may assume that row1 ≤ row2 and col1 ≤ col2.
    6. -
    -

    ### Related Topics + [[Design](../../tag/design/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Range Sum Query 2D - Immutable](../range-sum-query-2d-immutable) (Medium) diff --git a/problems/range-sum-query-immutable/README.md b/problems/range-sum-query-immutable/README.md index a6028bd65..87424afbe 100644 --- a/problems/range-sum-query-immutable/README.md +++ b/problems/range-sum-query-immutable/README.md @@ -52,7 +52,9 @@ numArray.sumRange(0, 5); // return (-2) + 0 + 3 + (-5) + 2 + (-1) = -3 ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Similar Questions 1. [Range Sum Query 2D - Immutable](../range-sum-query-2d-immutable) (Medium) diff --git a/problems/range-sum-query-mutable/README.md b/problems/range-sum-query-mutable/README.md index 0c1cba909..8dd88dfdd 100644 --- a/problems/range-sum-query-mutable/README.md +++ b/problems/range-sum-query-mutable/README.md @@ -56,8 +56,10 @@ numArray.sumRange(0, 2); // return 1 + 2 + 5 = 8 ### Related Topics + [[Design](../../tag/design/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions 1. [Range Sum Query - Immutable](../range-sum-query-immutable) (Easy) diff --git a/problems/rank-scores/README.md b/problems/rank-scores/README.md index 7f9cd7f57..4ac52c02c 100644 --- a/problems/rank-scores/README.md +++ b/problems/rank-scores/README.md @@ -42,3 +42,6 @@

    Important Note: For MySQL solutions, to escape reserved words used as column names, you can use an apostrophe before and after the keyword. For example `Rank`.

    + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/rank-teams-by-votes/README.md b/problems/rank-teams-by-votes/README.md index f041f7c56..1a25fb7a8 100644 --- a/problems/rank-teams-by-votes/README.md +++ b/problems/rank-teams-by-votes/README.md @@ -80,8 +80,14 @@ There is a tie and we rank teams ascending by their IDs. ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Similar Questions + 1. [Online Election](../online-election) (Medium) ### Hints
    diff --git a/problems/rank-transform-of-a-matrix/README.md b/problems/rank-transform-of-a-matrix/README.md index f3ff32117..5ae4ddfcf 100644 --- a/problems/rank-transform-of-a-matrix/README.md +++ b/problems/rank-transform-of-a-matrix/README.md @@ -76,6 +76,10 @@ The rank of matrix[1][1] is 3 because matrix[1][1] > matrix[0][1], matrix[1][ ### Related Topics [[Greedy](../../tag/greedy/README.md)] [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/rank-transform-of-an-array/README.md b/problems/rank-transform-of-an-array/README.md index 0d8e92a8f..acf600fb2 100644 --- a/problems/rank-transform-of-an-array/README.md +++ b/problems/rank-transform-of-an-array/README.md @@ -54,6 +54,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/ransom-note/README.md b/problems/ransom-note/README.md index 7660c27b8..f917eded4 100644 --- a/problems/ransom-note/README.md +++ b/problems/ransom-note/README.md @@ -35,7 +35,9 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] ### Similar Questions 1. [Stickers to Spell Word](../stickers-to-spell-word) (Hard) diff --git a/problems/reach-a-number/README.md b/problems/reach-a-number/README.md index 85e70c34a..5afb83cf4 100644 --- a/problems/reach-a-number/README.md +++ b/problems/reach-a-number/README.md @@ -11,38 +11,42 @@ ## [754. Reach a Number (Medium)](https://leetcode.com/problems/reach-a-number "到达终点数字") -

    -You are standing at position 0 on an infinite number line. There is a goal at position target. -

    -On each move, you can either go left or right. During the n-th move (starting from 1), you take n steps. -

    -Return the minimum number of steps required to reach the destination. -

    - -

    Example 1:
    +

    You are standing at position 0 on an infinite number line. There is a goal at position target.

    + +

    On each move, you can either go left or right. During the nth move (starting from n == 1), you take n steps.

    + +

    Return the minimum number of steps required to reach the destination.

    + +

     

    +

    Example 1:

    +
    -Input: target = 3
    -Output: 2
    -Explanation:
    -On the first move we step from 0 to 1.
    -On the second step we step from 1 to 3.
    +Input: target = 2
    +Output: 3
    +Explanation:
    +On the first move, we step from 0 to 1.
    +On the second move, we step  from 1 to -1.
    +On the third move, we step from -1 to 2.
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: target = 2
    -Output: 3
    -Explanation:
    -On the first move we step from 0 to 1.
    -On the second move we step  from 1 to -1.
    -On the third move we step from -1 to 2.
    +Input: target = 3
    +Output: 2
    +Explanation:
    +On the first move, we step from 0 to 1.
    +On the second step, we step from 1 to 3.
     
    -

    -

    Note:
    -

  • target will be a non-zero integer in the range [-10^9, 10^9].
  • -

    +

     

    +

    Constraints:

    + +
      +
    • -109 <= target <= 109
    • +
    • target != 0
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/reachable-nodes-in-subdivided-graph/README.md b/problems/reachable-nodes-in-subdivided-graph/README.md index 8a03d37f9..a47afe276 100644 --- a/problems/reachable-nodes-in-subdivided-graph/README.md +++ b/problems/reachable-nodes-in-subdivided-graph/README.md @@ -60,5 +60,6 @@ The nodes that are reachable are highlighted in yellow. ### Related Topics - [[Heap](../../tag/heap/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/reaching-points/README.md b/problems/reaching-points/README.md index 989d99986..4ee9f7625 100644 --- a/problems/reaching-points/README.md +++ b/problems/reaching-points/README.md @@ -11,32 +11,42 @@ ## [780. Reaching Points (Hard)](https://leetcode.com/problems/reaching-points "到达终点") -

    A move consists of taking a point (x, y) and transforming it to either (x, x+y) or (x+y, y).

    +

    Given four integers sx, sy, tx, and ty, return true if it is possible to convert the point (sx, sy) to the point (tx, ty) through some operations, or false otherwise.

    -

    Given a starting point (sx, sy) and a target point (tx, ty), return True if and only if a sequence of moves exists to transform the point (sx, sy) to (tx, ty). Otherwise, return False.

    +

    The allowed operation on some point (x, y) is to convert it to either (x, x + y) or (x + y, y).

    + +

     

    +

    Example 1:

    -Examples:
     Input: sx = 1, sy = 1, tx = 3, ty = 5
    -Output: True
    +Output: true
     Explanation:
     One series of moves that transforms the starting point to the target is:
     (1, 1) -> (1, 2)
     (1, 2) -> (3, 2)
     (3, 2) -> (3, 5)
    +
    +

    Example 2:

    + +
     Input: sx = 1, sy = 1, tx = 2, ty = 2
    -Output: False
    +Output: false
    +
    -Input: sx = 1, sy = 1, tx = 1, ty = 1 -Output: True +

    Example 3:

    +
    +Input: sx = 1, sy = 1, tx = 1, ty = 1
    +Output: true
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • sx, sy, tx, ty will all be integers in the range [1, 10^9].
    • +
    • 1 <= sx, sy, tx, ty <= 109
    ### Related Topics diff --git a/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md b/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md index 366605e89..1d250b80f 100644 --- a/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md +++ b/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md @@ -11,90 +11,12 @@ ## [158. Read N Characters Given Read4 II - Call multiple times (Hard)](https://leetcode.com/problems/read-n-characters-given-read4-ii-call-multiple-times "用 Read4 读取 N 个字符 II") -

    Given a file and assume that you can only read the file using a given method read4, implement a method read to read n characters. Your method read may be called multiple times.

    -

     

    - -

    Method read4:

    - -

    The API read4 reads 4 consecutive characters from the file, then writes those characters into the buffer array buf.

    - -

    The return value is the number of actual characters read.

    - -

    Note that read4() has its own file pointer, much like FILE *fp in C.

    - -

    Definition of read4:

    - -
    -    Parameter:  char[] buf
    -    Returns:    int
    -
    -Note: buf[] is destination not source, the results from read4 will be copied to buf[]
    -
    - -

    Below is a high level example of how read4 works:

    - -
    -File file("abcdefghijk"); // File is "abcdefghijk", initially file pointer (fp) points to 'a'
    -char[] buf = new char[4]; // Create buffer with enough space to store characters
    -read4(buf); // read4 returns 4. Now buf = "abcd", fp points to 'e'
    -read4(buf); // read4 returns 4. Now buf = "efgh", fp points to 'i'
    -read4(buf); // read4 returns 3. Now buf = "ijk", fp points to end of file
    -
    - -

     

    - -

    Method read:

    - -

    By using the read4 method, implement the method read that reads n characters from the file and store it in the buffer array buf. Consider that you cannot manipulate the file directly.

    - -

    The return value is the number of actual characters read.

    - -

    Definition of read:

    - -
    -    Parameters:	char[] buf, int n
    -    Returns:	int
    -
    -Note: buf[] is destination not source, you will need to write the results to buf[]
    -
    - -

     

    - -

    Example 1:

    - -
    -File file("abc");
    -Solution sol;
    -// Assume buf is allocated and guaranteed to have enough space for storing all characters from the file.
    -sol.read(buf, 1); // After calling your read method, buf should contain "a". We read a total of 1 character from the file, so return 1.
    -sol.read(buf, 2); // Now buf should contain "bc". We read a total of 2 characters from the file, so return 2.
    -sol.read(buf, 1); // We have reached the end of file, no more characters can be read. So return 0.
    -
    - -

    Example 2:

    - -
    -File file("abc");
    -Solution sol;
    -sol.read(buf, 4); // After calling your read method, buf should contain "abc". We read a total of 3 characters from the file, so return 3.
    -sol.read(buf, 1); // We have reached the end of file, no more characters can be read. So return 0.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. Consider that you cannot manipulate the file directly, the file is only accesible for read4 but not for read.
    2. -
    3. The read function may be called multiple times.
    4. -
    5. Please remember to RESET your class variables declared in Solution, as static/class variables are persisted across multiple test cases. Please see here for more details.
    6. -
    7. You may assume the destination buffer array, buf, is guaranteed to have enough space for storing n characters.
    8. -
    9. It is guaranteed that in a given test case the same buffer buf is called by read.
    10. -
    ### Related Topics [[String](../../tag/string/README.md)] + [[Interactive](../../tag/interactive/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Similar Questions 1. [Read N Characters Given Read4](../read-n-characters-given-read4) (Easy) diff --git a/problems/read-n-characters-given-read4/README.md b/problems/read-n-characters-given-read4/README.md index ec9cf5d10..d1992d9e0 100644 --- a/problems/read-n-characters-given-read4/README.md +++ b/problems/read-n-characters-given-read4/README.md @@ -11,100 +11,12 @@ ## [157. Read N Characters Given Read4 (Easy)](https://leetcode.com/problems/read-n-characters-given-read4 "用 Read4 读取 N 个字符") -

    Given a file and assume that you can only read the file using a given method read4, implement a method to read n characters.

    -

     

    - -

    Method read4:

    - -

    The API read4 reads 4 consecutive characters from the file, then writes those characters into the buffer array buf.

    - -

    The return value is the number of actual characters read.

    - -

    Note that read4() has its own file pointer, much like FILE *fp in C.

    - -

    Definition of read4:

    - -
    -    Parameter:  char[] buf
    -    Returns:    int
    -
    -Note: buf[] is destination not source, the results from read4 will be copied to buf[]
    -
    - -

    Below is a high level example of how read4 works:

    - -
    -File file("abcdefghijk"); // File is "abcdefghijk", initially file pointer (fp) points to 'a'
    -char[] buf = new char[4]; // Create buffer with enough space to store characters
    -read4(buf); // read4 returns 4. Now buf = "abcd", fp points to 'e'
    -read4(buf); // read4 returns 4. Now buf = "efgh", fp points to 'i'
    -read4(buf); // read4 returns 3. Now buf = "ijk", fp points to end of file
    -
    - -

     

    - -

    Method read:

    - -

    By using the read4 method, implement the method read that reads n characters from the file and store it in the buffer array buf. Consider that you cannot manipulate the file directly.

    - -

    The return value is the number of actual characters read.

    - -

    Definition of read:

    - -
    -    Parameters:	char[] buf, int n
    -    Returns:	int
    -
    -Note: buf[] is destination not source, you will need to write the results to buf[]
    -
    - -

     

    - -

    Example 1:

    - -
    -Input: file = "abc", n = 4
    -Output: 3
    -Explanation: After calling your read method, buf should contain "abc". We read a total of 3 characters from the file, so return 3. Note that "abc" is the file's content, not buf. buf is the destination buffer that you will have to write the results to.
    -
    - -

    Example 2:

    - -
    -Input: file = "abcde", n = 5
    -Output: 5
    -Explanation: After calling your read method, buf should contain "abcde". We read a total of 5 characters from the file, so return 5.
    -
    - -

    Example 3:

    - -
    -Input: file = "abcdABCD1234", n = 12
    -Output: 12
    -Explanation: After calling your read method, buf should contain "abcdABCD1234". We read a total of 12 characters from the file, so return 12.
    -
    - -

    Example 4:

    - -
    -Input: file = "leetcode", n = 5
    -Output: 5
    -Explanation: After calling your read method, buf should contain "leetc". We read a total of 5 characters from the file, so return 5.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. Consider that you cannot manipulate the file directly, the file is only accesible for read4 but not for read.
    2. -
    3. The read function will only be called once for each test case.
    4. -
    5. You may assume the destination buffer array, buf, is guaranteed to have enough space for storing n characters.
    6. -
    ### Related Topics [[String](../../tag/string/README.md)] + [[Interactive](../../tag/interactive/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Similar Questions 1. [Read N Characters Given Read4 II - Call multiple times](../read-n-characters-given-read4-ii-call-multiple-times) (Hard) diff --git a/problems/rearrange-products-table/README.md b/problems/rearrange-products-table/README.md index 9c5ff4cb9..dc9fa1f5a 100644 --- a/problems/rearrange-products-table/README.md +++ b/problems/rearrange-products-table/README.md @@ -12,3 +12,6 @@ ## [1795. Rearrange Products Table (Easy)](https://leetcode.com/problems/rearrange-products-table "每个产品在不同商店的价格") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/rearrange-string-k-distance-apart/README.md b/problems/rearrange-string-k-distance-apart/README.md index 8ab0f8b6e..c6930f952 100644 --- a/problems/rearrange-string-k-distance-apart/README.md +++ b/problems/rearrange-string-k-distance-apart/README.md @@ -11,41 +11,15 @@ ## [358. Rearrange String k Distance Apart (Hard)](https://leetcode.com/problems/rearrange-string-k-distance-apart "K 距离间隔重排字符串") -

    Given a non-empty string s and an integer k, rearrange the string such that the same characters are at least distance k from each other.

    -

    All input strings are given in lowercase letters. If it is not possible to rearrange the string, return an empty string "".

    - -

    Example 1:

    - -
    -
    -Input: s = "aabbcc", k = 3
    -Output: "abcabc" 
    -Explanation: The same letters are at least distance 3 from each other.
    -
    - -
    -

    Example 2:

    - -
    -Input: s = "aaabc", k = 3
    -Output: "" 
    -Explanation: It is not possible to rearrange the string.
    -
    - -
    -

    Example 3:

    - -
    -Input: s = "aaadbbcc", k = 2
    -Output: "abacabcd"
    -Explanation: The same letters are at least distance 2 from each other.
    -
    ### Related Topics - [[Heap](../../tag/heap/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Task Scheduler](../task-scheduler) (Medium) diff --git a/problems/rearrange-words-in-a-sentence/README.md b/problems/rearrange-words-in-a-sentence/README.md index 2abdf219e..5a62d6e06 100644 --- a/problems/rearrange-words-in-a-sentence/README.md +++ b/problems/rearrange-words-in-a-sentence/README.md @@ -61,8 +61,8 @@ Output is ordered by length and the new first word starts with capital letter. ### Related Topics - [[Sort](../../tag/sort/README.md)] [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/reconstruct-a-2-row-binary-matrix/README.md b/problems/reconstruct-a-2-row-binary-matrix/README.md index 05e21c189..06655f5a4 100644 --- a/problems/reconstruct-a-2-row-binary-matrix/README.md +++ b/problems/reconstruct-a-2-row-binary-matrix/README.md @@ -62,7 +62,8 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] - [[Math](../../tag/math/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/reconstruct-itinerary/README.md b/problems/reconstruct-itinerary/README.md index bba68f27a..39017661d 100644 --- a/problems/reconstruct-itinerary/README.md +++ b/problems/reconstruct-itinerary/README.md @@ -50,5 +50,6 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] + [[Eulerian Circuit](../../tag/eulerian-circuit/README.md)] diff --git a/problems/reconstruct-original-digits-from-english/README.md b/problems/reconstruct-original-digits-from-english/README.md index 55fe8967e..84bd5fed4 100644 --- a/problems/reconstruct-original-digits-from-english/README.md +++ b/problems/reconstruct-original-digits-from-english/README.md @@ -31,4 +31,6 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/recover-a-tree-from-preorder-traversal/README.md b/problems/recover-a-tree-from-preorder-traversal/README.md index 9e5bbb461..9b6e11135 100644 --- a/problems/recover-a-tree-from-preorder-traversal/README.md +++ b/problems/recover-a-tree-from-preorder-traversal/README.md @@ -51,7 +51,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[String](../../tag/string/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/recover-binary-search-tree/README.md b/problems/recover-binary-search-tree/README.md index 340e554f7..9d10760b4 100644 --- a/problems/recover-binary-search-tree/README.md +++ b/problems/recover-binary-search-tree/README.md @@ -9,7 +9,7 @@                  [Next >](../same-tree "Same Tree") -## [99. Recover Binary Search Tree (Hard)](https://leetcode.com/problems/recover-binary-search-tree "恢复二叉搜索树") +## [99. Recover Binary Search Tree (Medium)](https://leetcode.com/problems/recover-binary-search-tree "恢复二叉搜索树")

    You are given the root of a binary search tree (BST), where exactly two nodes of the tree were swapped by mistake. Recover the tree without changing its structure.

    @@ -42,4 +42,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/rectangle-area-ii/README.md b/problems/rectangle-area-ii/README.md index d96646f5c..b21a412dc 100644 --- a/problems/rectangle-area-ii/README.md +++ b/problems/rectangle-area-ii/README.md @@ -44,4 +44,6 @@ ### Related Topics [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] [[Line Sweep](../../tag/line-sweep/README.md)] diff --git a/problems/rectangle-area/README.md b/problems/rectangle-area/README.md index 07a5d9e12..8f428eab9 100644 --- a/problems/rectangle-area/README.md +++ b/problems/rectangle-area/README.md @@ -40,6 +40,7 @@ ### Related Topics + [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] ### Similar Questions diff --git a/problems/rectangle-overlap/README.md b/problems/rectangle-overlap/README.md index 97f645c86..00ff72825 100644 --- a/problems/rectangle-overlap/README.md +++ b/problems/rectangle-overlap/README.md @@ -35,11 +35,11 @@
  • rect1.length == 4
  • rect2.length == 4
  • -109 <= rec1[i], rec2[i] <= 109
  • -
  • rec1[0] <= rec1[2] and rec1[1] <= rec1[3]
  • -
  • rec2[0] <= rec2[2] and rec2[1] <= rec2[3]
  • +
  • rec1 and rec2 represent a valid rectangle with a non-zero area.
  • ### Related Topics + [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] ### Similar Questions diff --git a/problems/rectangles-area/README.md b/problems/rectangles-area/README.md index f2a2e02b6..f63085a0a 100644 --- a/problems/rectangles-area/README.md +++ b/problems/rectangles-area/README.md @@ -12,3 +12,6 @@ ## [1459. Rectangles Area (Medium)](https://leetcode.com/problems/rectangles-area "矩形面积") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/recyclable-and-low-fat-products/README.md b/problems/recyclable-and-low-fat-products/README.md index 7a6203f4b..ed3399698 100644 --- a/problems/recyclable-and-low-fat-products/README.md +++ b/problems/recyclable-and-low-fat-products/README.md @@ -12,3 +12,6 @@ ## [1757. Recyclable and Low Fat Products (Easy)](https://leetcode.com/problems/recyclable-and-low-fat-products "可回收且低脂的产品") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/redistribute-characters-to-make-all-strings-equal/README.md b/problems/redistribute-characters-to-make-all-strings-equal/README.md new file mode 100644 index 000000000..2534847db --- /dev/null +++ b/problems/redistribute-characters-to-make-all-strings-equal/README.md @@ -0,0 +1,62 @@ + + + + + + + +[< Previous](../minimum-cost-to-change-the-final-value-of-expression "Minimum Cost to Change the Final Value of Expression") +                 +[Next >](../maximum-number-of-removable-characters "Maximum Number of Removable Characters") + +## [1897. Redistribute Characters to Make All Strings Equal (Easy)](https://leetcode.com/problems/redistribute-characters-to-make-all-strings-equal "重新分配字符使所有字符串都相等") + +

    You are given an array of strings words (0-indexed).

    + +

    In one operation, pick two distinct indices i and j, where words[i] is a non-empty string, and move any character from words[i] to any position in words[j].

    + +

    Return true if you can make every string in words equal using any number of operations, and false otherwise.

    + +

     

    +

    Example 1:

    + +
    +Input: words = ["abc","aabc","bc"]
    +Output: true
    +Explanation: Move the first 'a' in words[1] to the front of words[2],
    +to make words[1] = "abc" and words[2] = "abc".
    +All the strings are now equal to "abc", so return true.
    +
    + +

    Example 2:

    + +
    +Input: words = ["ab","a"]
    +Output: false
    +Explanation: It is impossible to make all the strings equal using the operation.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 100
    • +
    • 1 <= words[i].length <= 100
    • +
    • words[i] consists of lowercase English letters.
    • +
    + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Hints +
    +Hint 1 +Characters are independent—only the frequency of characters matters. +
    + +
    +Hint 2 +It is possible to distribute characters if all characters can be divided equally among all strings. +
    diff --git a/problems/reduce-array-size-to-the-half/README.md b/problems/reduce-array-size-to-the-half/README.md index 954a94437..a5ff65836 100644 --- a/problems/reduce-array-size-to-the-half/README.md +++ b/problems/reduce-array-size-to-the-half/README.md @@ -11,9 +11,9 @@ ## [1338. Reduce Array Size to The Half (Medium)](https://leetcode.com/problems/reduce-array-size-to-the-half "数组大小减半") -

    Given an array arr.  You can choose a set of integers and remove all the occurrences of these integers in the array.

    +

    You are given an integer array arr. You can choose a set of integers and remove all the occurrences of these integers in the array.

    -

    Return the minimum size of the set so that at least half of the integers of the array are removed.

    +

    Return the minimum size of the set so that at least half of the integers of the array are removed.

     

    Example 1:

    @@ -59,14 +59,17 @@ Choosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5]

    Constraints:

      -
    • 1 <= arr.length <= 10^5
    • +
    • 1 <= arr.length <= 105
    • arr.length is even.
    • -
    • 1 <= arr[i] <= 10^5
    • +
    • 1 <= arr[i] <= 105
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/reducing-dishes/README.md b/problems/reducing-dishes/README.md index 318b14ce1..9f770ebbe 100644 --- a/problems/reducing-dishes/README.md +++ b/problems/reducing-dishes/README.md @@ -60,7 +60,10 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/reduction-operations-to-make-the-array-elements-equal/README.md b/problems/reduction-operations-to-make-the-array-elements-equal/README.md new file mode 100644 index 000000000..033de883b --- /dev/null +++ b/problems/reduction-operations-to-make-the-array-elements-equal/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../determine-whether-matrix-can-be-obtained-by-rotation "Determine Whether Matrix Can Be Obtained By Rotation") +                 +[Next >](../minimum-number-of-flips-to-make-the-binary-string-alternating "Minimum Number of Flips to Make the Binary String Alternating") + +## [1887. Reduction Operations to Make the Array Elements Equal (Medium)](https://leetcode.com/problems/reduction-operations-to-make-the-array-elements-equal "使数组元素相等的减少操作次数") + +

    Given an integer array nums, your goal is to make all elements in nums equal. To complete one operation, follow these steps:

    + +
      +
    1. Find the largest value in nums. Let its index be i (0-indexed) and its value be largest. If there are multiple elements with the largest value, pick the smallest i.
    2. +
    3. Find the next largest value in nums strictly smaller than largest. Let its value be nextLargest.
    4. +
    5. Reduce nums[i] to nextLargest.
    6. +
    + +

    Return the number of operations to make all elements in nums equal.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [5,1,3]
    +Output: 3
    +Explanation: It takes 3 operations to make all elements in nums equal:
    +1. largest = 5 at index 0. nextLargest = 3. Reduce nums[0] to 3. nums = [3,1,3].
    +2. largest = 3 at index 0. nextLargest = 1. Reduce nums[0] to 1. nums = [1,1,3].
    +3. largest = 3 at index 2. nextLargest = 1. Reduce nums[2] to 1. nums = [1,1,1].
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,1,1]
    +Output: 0
    +Explanation: All elements in nums are already equal.
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,1,2,2,3]
    +Output: 4
    +Explanation: It takes 4 operations to make all elements in nums equal:
    +1. largest = 3 at index 4. nextLargest = 2. Reduce nums[4] to 2. nums = [1,1,2,2,2].
    +2. largest = 2 at index 2. nextLargest = 1. Reduce nums[2] to 1. nums = [1,1,1,2,2].
    +3. largest = 2 at index 3. nextLargest = 1. Reduce nums[3] to 1. nums = [1,1,1,1,2].
    +4. largest = 2 at index 4. nextLargest = 1. Reduce nums[4] to 1. nums = [1,1,1,1,1].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 5 * 104
    • +
    • 1 <= nums[i] <= 5 * 104
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Sort the array. +
    + +
    +Hint 2 +Try to reduce all elements with maximum value to the next maximum value in one operation. +
    diff --git a/problems/redundant-connection-ii/README.md b/problems/redundant-connection-ii/README.md index aa0487b64..5d2839c69 100644 --- a/problems/redundant-connection-ii/README.md +++ b/problems/redundant-connection-ii/README.md @@ -46,8 +46,8 @@ ### Related Topics - [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] diff --git a/problems/redundant-connection/README.md b/problems/redundant-connection/README.md index e678298b6..4835b8bf1 100644 --- a/problems/redundant-connection/README.md +++ b/problems/redundant-connection/README.md @@ -46,7 +46,8 @@ ### Related Topics - [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] diff --git a/problems/reformat-department-table/README.md b/problems/reformat-department-table/README.md index dbbf71b3a..4d2225d89 100644 --- a/problems/reformat-department-table/README.md +++ b/problems/reformat-department-table/README.md @@ -55,3 +55,6 @@ Result table: Note that the result table has 13 columns (1 for the department id + 12 for the months). + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/regions-cut-by-slashes/README.md b/problems/regions-cut-by-slashes/README.md index 310bbcee9..a92996173 100644 --- a/problems/regions-cut-by-slashes/README.md +++ b/problems/regions-cut-by-slashes/README.md @@ -66,6 +66,7 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] diff --git a/problems/regular-expression-matching/README.md b/problems/regular-expression-matching/README.md index 5412bf285..7e6a7837d 100644 --- a/problems/regular-expression-matching/README.md +++ b/problems/regular-expression-matching/README.md @@ -72,9 +72,9 @@ ### Related Topics + [[Recursion](../../tag/recursion/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions 1. [Wildcard Matching](../wildcard-matching) (Hard) diff --git a/problems/relative-ranks/README.md b/problems/relative-ranks/README.md index 4e61c6bbc..15a17adc8 100644 --- a/problems/relative-ranks/README.md +++ b/problems/relative-ranks/README.md @@ -50,3 +50,8 @@
  • 0 <= score[i] <= 106
  • All the values in score are unique.
  • + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/relative-sort-array/README.md b/problems/relative-sort-array/README.md index bb842c717..cdc2c3d74 100644 --- a/problems/relative-sort-array/README.md +++ b/problems/relative-sort-array/README.md @@ -31,8 +31,10 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting Sort](../../tag/counting-sort/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/remove-9/README.md b/problems/remove-9/README.md index c186217f6..fef5853dd 100644 --- a/problems/remove-9/README.md +++ b/problems/remove-9/README.md @@ -11,21 +11,7 @@ ## [660. Remove 9 (Hard)](https://leetcode.com/problems/remove-9 "移除 9") -

    Start from integer 1, remove any integer that contains 9 such as 9, 19, 29...

    -

    So now, you will have a new integer sequence: 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, ...

    - -

    Given a positive integer n, you need to return the n-th integer after removing. Note that 1 will be the first integer.

    - -

    Example 1:
    -

    Input: 9
    -Output: 10
    -
    -

    - -

    - Hint: n will not exceed 9 x 10^8. -

    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/remove-all-adjacent-duplicates-in-string-ii/README.md b/problems/remove-all-adjacent-duplicates-in-string-ii/README.md index e7b2a3f6d..cafcb86af 100644 --- a/problems/remove-all-adjacent-duplicates-in-string-ii/README.md +++ b/problems/remove-all-adjacent-duplicates-in-string-ii/README.md @@ -53,6 +53,7 @@ Finally delete "ddd", get "aa" ### Related Topics [[Stack](../../tag/stack/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/remove-all-adjacent-duplicates-in-string/README.md b/problems/remove-all-adjacent-duplicates-in-string/README.md index 70c5a36af..897bb8aad 100644 --- a/problems/remove-all-adjacent-duplicates-in-string/README.md +++ b/problems/remove-all-adjacent-duplicates-in-string/README.md @@ -44,6 +44,7 @@ For example, in "abbaca" we could remove "bb" since the lett ### Related Topics [[Stack](../../tag/stack/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/remove-all-occurrences-of-a-substring/README.md b/problems/remove-all-occurrences-of-a-substring/README.md new file mode 100644 index 000000000..107f284fc --- /dev/null +++ b/problems/remove-all-occurrences-of-a-substring/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../remove-one-element-to-make-the-array-strictly-increasing "Remove One Element to Make the Array Strictly Increasing") +                 +[Next >](../maximum-alternating-subsequence-sum "Maximum Alternating Subsequence Sum") + +## [1910. Remove All Occurrences of a Substring (Medium)](https://leetcode.com/problems/remove-all-occurrences-of-a-substring "删除一个字符串中所有出现的给定子字符串") + +

    Given two strings s and part, perform the following operation on s until all occurrences of the substring part are removed:

    + +
      +
    • Find the leftmost occurrence of the substring part and remove it from s.
    • +
    + +

    Return s after removing all occurrences of part.

    + +

    A substring is a contiguous sequence of characters in a string.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "daabcbaabcbc", part = "abc"
    +Output: "dab"
    +Explanation: The following operations are done:
    +- s = "daabcbaabcbc", remove "abc" starting at index 2, so s = "dabaabcbc".
    +- s = "dabaabcbc", remove "abc" starting at index 4, so s = "dababc".
    +- s = "dababc", remove "abc" starting at index 3, so s = "dab".
    +Now s has no occurrences of "abc".
    +
    + +

    Example 2:

    + +
    +Input: s = "axxxxyyyyb", part = "xy"
    +Output: "ab"
    +Explanation: The following operations are done:
    +- s = "axxxxyyyyb", remove "xy" starting at index 4 so s = "axxxyyyb".
    +- s = "axxxyyyb", remove "xy" starting at index 3 so s = "axxyyb".
    +- s = "axxyyb", remove "xy" starting at index 2 so s = "axyb".
    +- s = "axyb", remove "xy" starting at index 1 so s = "ab".
    +Now s has no occurrences of "xy".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 1000
    • +
    • 1 <= part.length <= 1000
    • +
    • s​​​​​​ and part consists of lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Note that a new occurrence of pattern can appear if you remove an old one, For example, s = "ababcc" and pattern = "abc". +
    + +
    +Hint 2 +You can maintain a stack of characters and if the last character of the pattern size in the stack match the pattern remove them +
    diff --git a/problems/remove-boxes/README.md b/problems/remove-boxes/README.md index 77230a971..6f4679bc2 100644 --- a/problems/remove-boxes/README.md +++ b/problems/remove-boxes/README.md @@ -54,7 +54,8 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/remove-comments/README.md b/problems/remove-comments/README.md index 08ced295f..49f4c74c0 100644 --- a/problems/remove-comments/README.md +++ b/problems/remove-comments/README.md @@ -11,33 +11,45 @@ ## [722. Remove Comments (Medium)](https://leetcode.com/problems/remove-comments "删除注释") -

    Given a C++ program, remove comments from it. The program source is an array where source[i] is the i-th line of the source code. This represents the result of splitting the original source code string by the newline character \n.

    +

    Given a C++ program, remove comments from it. The program source is an array of strings source where source[i] is the ith line of the source code. This represents the result of splitting the original source code string by the newline character '\n'.

    In C++, there are two types of comments, line comments, and block comments.

    -

    -The string // denotes a line comment, which represents that it and rest of the characters to the right of it in the same line should be ignored. -

    -The string /* denotes a block comment, which represents that all characters until the next (non-overlapping) occurrence of */ should be ignored. (Here, occurrences happen in reading order: line by line from left to right.) To be clear, the string /*/ does not yet end the block comment, as the ending would be overlapping the beginning. -

    -The first effective comment takes precedence over others: if the string // occurs in a block comment, it is ignored. Similarly, if the string /* occurs in a line or block comment, it is also ignored. -

    -If a certain line of code is empty after removing comments, you must not output that line: each string in the answer list will be non-empty. -

    -There will be no control characters, single quote, or double quote characters. For example, source = "string s = "/* Not a comment. */";" will not be a test case. (Also, nothing else such as defines or macros will interfere with the comments.) -

    -It is guaranteed that every open block comment will eventually be closed, so /* outside of a line or block comment always starts a new comment. -

    -Finally, implicit newline characters can be deleted by block comments. Please see the examples below for details. -

    - -

    After removing the comments from the source code, return the source code in the same format.

    - -

    Example 1:
    -

    -Input: 
    -source = ["/*Test program */", "int main()", "{ ", "  // variable declaration ", "int a, b, c;", "/* This is a test", "   multiline  ", "   comment for ", "   testing */", "a = b + c;", "}"]
    -
    -The line by line code is visualized as below:
    +
    +
      +
    • The string "//" denotes a line comment, which represents that it and the rest of the characters to the right of it in the same line should be ignored.
    • +
    • The string "/*" denotes a block comment, which represents that all characters until the next (non-overlapping) occurrence of "*/" should be ignored. (Here, occurrences happen in reading order: line by line from left to right.) To be clear, the string "/*/" does not yet end the block comment, as the ending would be overlapping the beginning.
    • +
    + +

    The first effective comment takes precedence over others.

    + +
      +
    • For example, if the string "//" occurs in a block comment, it is ignored.
    • +
    • Similarly, if the string "/*" occurs in a line or block comment, it is also ignored.
    • +
    + +

    If a certain line of code is empty after removing comments, you must not output that line: each string in the answer list will be non-empty.

    + +

    There will be no control characters, single quote, or double quote characters.

    + +
      +
    • For example, source = "string s = "/* Not a comment. */";" will not be a test case.
    • +
    + +

    Also, nothing else such as defines or macros will interfere with the comments.

    + +

    It is guaranteed that every open block comment will eventually be closed, so "/*" outside of a line or block comment always starts a new comment.

    + +

    Finally, implicit newline characters can be deleted by block comments. Please see the examples below for details.

    + +

    After removing the comments from the source code, return the source code in the same format.

    + +

     

    +

    Example 1:

    + +
    +Input: source = ["/*Test program */", "int main()", "{ ", "  // variable declaration ", "int a, b, c;", "/* This is a test", "   multiline  ", "   comment for ", "   testing */", "a = b + c;", "}"]
    +Output: ["int main()","{ ","  ","int a, b, c;","a = b + c;","}"]
    +Explanation: The line by line code is visualized as below:
     /*Test program */
     int main()
     { 
    @@ -49,39 +61,37 @@ int a, b, c;
        testing */
     a = b + c;
     }
    -
    -Output: ["int main()","{ ","  ","int a, b, c;","a = b + c;","}"]
    -
    -The line by line code is visualized as below:
    +The string /* denotes a block comment, including line 1 and lines 6-9. The string // denotes line 4 as comments.
    +The line by line output code is visualized as below:
     int main()
     { 
       
     int a, b, c;
     a = b + c;
     }
    -
    -Explanation: 
    -The string /* denotes a block comment, including line 1 and lines 6-9. The string // denotes line 4 as comments.
     
    -

    - -

    Example 2:
    -

    -Input: 
    -source = ["a/*comment", "line", "more_comment*/b"]
    -Output: ["ab"]
    -Explanation: The original source string is "a/*comment\nline\nmore_comment*/b", where we have bolded the newline characters.  After deletion, the implicit newline characters are deleted, leaving the string "ab", which when delimited by newline characters becomes ["ab"].
    +
    +

    Example 2:

    + +
    +Input: source = ["a/*comment", "line", "more_comment*/b"]
    +Output: ["ab"]
    +Explanation: The original source string is "a/*comment\nline\nmore_comment*/b", where we have bolded the newline characters.  After deletion, the implicit newline characters are deleted, leaving the string "ab", which when delimited by newline characters becomes ["ab"].
     
    -

    -

    Note: -

  • The length of source is in the range [1, 100].
  • -
  • The length of source[i] is in the range [0, 80].
  • -
  • Every open block comment is eventually closed.
  • -
  • There are no single-quote, double-quote, or control characters in the source code.
  • -

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= source.length <= 100
    • +
    • 0 <= source[i].length <= 80
    • +
    • source[i] consists of printable ASCII characters.
    • +
    • Every open block comment is eventually closed.
    • +
    • There are no single-quote or double-quote in the input.
    • +
    ### Related Topics + [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/remove-covered-intervals/README.md b/problems/remove-covered-intervals/README.md index c7b2705d9..3bfa0205d 100644 --- a/problems/remove-covered-intervals/README.md +++ b/problems/remove-covered-intervals/README.md @@ -65,9 +65,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] - [[Sort](../../tag/sort/README.md)] - [[Line Sweep](../../tag/line-sweep/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/remove-duplicate-letters/README.md b/problems/remove-duplicate-letters/README.md index 90a2726dd..d25ddda31 100644 --- a/problems/remove-duplicate-letters/README.md +++ b/problems/remove-duplicate-letters/README.md @@ -13,8 +13,6 @@

    Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.

    -

    Note: This question is the same as 1081: https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/

    -

     

    Example 1:

    @@ -38,10 +36,14 @@
  • s consists of lowercase English letters.
  • +

     

    +

    Note: This question is the same as 1081: https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/

    + ### Related Topics [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints
    diff --git a/problems/remove-duplicates-from-an-unsorted-linked-list/README.md b/problems/remove-duplicates-from-an-unsorted-linked-list/README.md index e2a5719b9..527659931 100644 --- a/problems/remove-duplicates-from-an-unsorted-linked-list/README.md +++ b/problems/remove-duplicates-from-an-unsorted-linked-list/README.md @@ -9,11 +9,12 @@                  [Next >](../sum-of-digits-in-base-k "Sum of Digits in Base K") -## [1836. Remove Duplicates From an Unsorted Linked List (Medium)](https://leetcode.com/problems/remove-duplicates-from-an-unsorted-linked-list "") +## [1836. Remove Duplicates From an Unsorted Linked List (Medium)](https://leetcode.com/problems/remove-duplicates-from-an-unsorted-linked-list "从未排序的链表中移除重复元素") ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] ### Hints diff --git a/problems/remove-duplicates-from-sorted-array-ii/README.md b/problems/remove-duplicates-from-sorted-array-ii/README.md index 23a6ccc22..3a62a0ac8 100644 --- a/problems/remove-duplicates-from-sorted-array-ii/README.md +++ b/problems/remove-duplicates-from-sorted-array-ii/README.md @@ -11,44 +11,49 @@ ## [80. Remove Duplicates from Sorted Array II (Medium)](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii "删除有序数组中的重复项 II") -

    Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length.

    +

    Given an integer array nums sorted in non-decreasing order, remove some duplicates in-place such that each unique element appears at most twice. The relative order of the elements should be kept the same.

    -

    Do not allocate extra space for another array; you must do this by modifying the input array in-place with O(1) extra memory.

    +

    Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the first part of the array nums. More formally, if there are k elements after removing the duplicates, then the first k elements of nums should hold the final result. It does not matter what you leave beyond the first k elements.

    -

    Clarification:

    +

    Return k after placing the final result in the first k slots of nums.

    -

    Confused why the returned value is an integer, but your answer is an array?

    +

    Do not allocate extra space for another array. You must do this by modifying the input array in-place with O(1) extra memory.

    -

    Note that the input array is passed in by reference, which means a modification to the input array will be known to the caller.

    +

    Custom Judge:

    -

    Internally you can think of this:

    +

    The judge will test your solution with the following code:

    -// nums is passed in by reference. (i.e., without making a copy)
    -int len = removeDuplicates(nums);
    +int[] nums = [...]; // Input array
    +int[] expectedNums = [...]; // The expected answer with correct length
     
    -// any modification to nums in your function would be known by the caller.
    -// using the length returned by your function, it prints the first len elements.
    -for (int i = 0; i < len; i++) {
    -    print(nums[i]);
    +int k = removeDuplicates(nums); // Calls your implementation
    +
    +assert k == expectedNums.length;
    +for (int i = 0; i < k; i++) {
    +    assert nums[i] == expectedNums[i];
     }
     
    +

    If all assertions pass, then your solution will be accepted.

    +

     

    Example 1:

     Input: nums = [1,1,1,2,2,3]
    -Output: 5, nums = [1,1,2,2,3]
    -Explanation: Your function should return length = 5, with the first five elements of nums being 1, 1, 2, 2 and 3 respectively. It doesn't matter what you leave beyond the returned length.
    +Output: 5, nums = [1,1,2,2,3,_]
    +Explanation: Your function should return k = 5, with the first five elements of nums being 1, 1, 2, 2 and 3 respectively.
    +It does not matter what you leave beyond the returned k (hence they are underscores).
     

    Example 2:

     Input: nums = [0,0,1,1,1,1,2,3,3]
    -Output: 7, nums = [0,0,1,1,2,3,3]
    -Explanation: Your function should return length = 7, with the first seven elements of nums being modified to 0, 0, 1, 1, 2, 3 and 3 respectively. It doesn't matter what values are set beyond the returned length.
    +Output: 7, nums = [0,0,1,1,2,3,3,_,_]
    +Explanation: Your function should return k = 7, with the first seven elements of nums being 0, 0, 1, 1, 2, 3 and 3 respectively.
    +It does not matter what you leave beyond the returned k (hence they are underscores).
     

     

    @@ -57,7 +62,7 @@ for (int i = 0; i < len; i++) {
    • 1 <= nums.length <= 3 * 104
    • -104 <= nums[i] <= 104
    • -
    • nums is sorted in ascending order.
    • +
    • nums is sorted in non-decreasing order.
    ### Related Topics diff --git a/problems/remove-duplicates-from-sorted-array/README.md b/problems/remove-duplicates-from-sorted-array/README.md index 47d098adc..293709445 100644 --- a/problems/remove-duplicates-from-sorted-array/README.md +++ b/problems/remove-duplicates-from-sorted-array/README.md @@ -11,44 +11,49 @@ ## [26. Remove Duplicates from Sorted Array (Easy)](https://leetcode.com/problems/remove-duplicates-from-sorted-array "删除有序数组中的重复项") -

    Given a sorted array nums, remove the duplicates in-place such that each element appears only once and returns the new length.

    +

    Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same.

    -

    Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.

    +

    Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the first part of the array nums. More formally, if there are k elements after removing the duplicates, then the first k elements of nums should hold the final result. It does not matter what you leave beyond the first k elements.

    -

    Clarification:

    +

    Return k after placing the final result in the first k slots of nums.

    -

    Confused why the returned value is an integer but your answer is an array?

    +

    Do not allocate extra space for another array. You must do this by modifying the input array in-place with O(1) extra memory.

    -

    Note that the input array is passed in by reference, which means a modification to the input array will be known to the caller as well.

    +

    Custom Judge:

    -

    Internally you can think of this:

    +

    The judge will test your solution with the following code:

    -// nums is passed in by reference. (i.e., without making a copy)
    -int len = removeDuplicates(nums);
    +int[] nums = [...]; // Input array
    +int[] expectedNums = [...]; // The expected answer with correct length
     
    -// any modification to nums in your function would be known by the caller.
    -// using the length returned by your function, it prints the first len elements.
    -for (int i = 0; i < len; i++) {
    -    print(nums[i]);
    +int k = removeDuplicates(nums); // Calls your implementation
    +
    +assert k == expectedNums.length;
    +for (int i = 0; i < k; i++) {
    +    assert nums[i] == expectedNums[i];
     }
     
    +

    If all assertions pass, then your solution will be accepted.

    +

     

    Example 1:

     Input: nums = [1,1,2]
    -Output: 2, nums = [1,2]
    -Explanation: Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively. It doesn't matter what you leave beyond the returned length.
    +Output: 2, nums = [1,2,_]
    +Explanation: Your function should return k = 2, with the first two elements of nums being 1 and 2 respectively.
    +It does not matter what you leave beyond the returned k (hence they are underscores).
     

    Example 2:

     Input: nums = [0,0,1,1,1,2,2,3,3,4]
    -Output: 5, nums = [0,1,2,3,4]
    -Explanation: Your function should return length = 5, with the first five elements of nums being modified to 0, 1, 2, 3, and 4 respectively. It doesn't matter what values are set beyond the returned length.
    +Output: 5, nums = [0,1,2,3,4,_,_,_,_,_]
    +Explanation: Your function should return k = 5, with the first five elements of nums being 0, 1, 2, 3, and 4 respectively.
    +It does not matter what you leave beyond the returned k (hence they are underscores).
     

     

    @@ -56,8 +61,8 @@ for (int i = 0; i < len; i++) {
    • 0 <= nums.length <= 3 * 104
    • -
    • -104 <= nums[i] <= 104
    • -
    • nums is sorted in ascending order.
    • +
    • -100 <= nums[i] <= 100
    • +
    • nums is sorted in non-decreasing order.
    ### Related Topics diff --git a/problems/remove-duplicates-from-sorted-list-ii/README.md b/problems/remove-duplicates-from-sorted-list-ii/README.md index 15a05034f..23c18038d 100644 --- a/problems/remove-duplicates-from-sorted-list-ii/README.md +++ b/problems/remove-duplicates-from-sorted-list-ii/README.md @@ -39,6 +39,7 @@ ### Related Topics [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions 1. [Remove Duplicates from Sorted List](../remove-duplicates-from-sorted-list) (Easy) diff --git a/problems/remove-element/README.md b/problems/remove-element/README.md index f9d2427bd..bf7c534e0 100644 --- a/problems/remove-element/README.md +++ b/problems/remove-element/README.md @@ -11,46 +11,53 @@ ## [27. Remove Element (Easy)](https://leetcode.com/problems/remove-element "移除元素") -

    Given an array nums and a value val, remove all instances of that value in-place and return the new length.

    +

    Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The relative order of the elements may be changed.

    -

    Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.

    +

    Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the first part of the array nums. More formally, if there are k elements after removing the duplicates, then the first k elements of nums should hold the final result. It does not matter what you leave beyond the first k elements.

    -

    The order of elements can be changed. It doesn't matter what you leave beyond the new length.

    +

    Return k after placing the final result in the first k slots of nums.

    -

    Clarification:

    +

    Do not allocate extra space for another array. You must do this by modifying the input array in-place with O(1) extra memory.

    -

    Confused why the returned value is an integer but your answer is an array?

    +

    Custom Judge:

    -

    Note that the input array is passed in by reference, which means a modification to the input array will be known to the caller as well.

    - -

    Internally you can think of this:

    +

    The judge will test your solution with the following code:

    -// nums is passed in by reference. (i.e., without making a copy)
    -int len = removeElement(nums, val);
    +int[] nums = [...]; // Input array
    +int val = ...; // Value to remove
    +int[] expectedNums = [...]; // The expected answer with correct length.
    +                            // It is sorted with no values equaling val.
    +
    +int k = removeElement(nums, val); // Calls your implementation
    +
    +assert k == expectedNums.length;
    +sort(nums, 0, k); // Sort the first k elements of nums
    +for (int i = 0; i < actualLength; i++) {
    +    assert nums[i] == expectedNums[i];
    +}
    +
    -// any modification to nums in your function would be known by the caller. -// using the length returned by your function, it prints the first len elements. -for (int i = 0; i < len; i++) { -    print(nums[i]); -}
    +

    If all assertions pass, then your solution will be accepted.

     

    Example 1:

     Input: nums = [3,2,2,3], val = 3
    -Output: 2, nums = [2,2]
    -Explanation: Your function should return length = 2, with the first two elements of nums being 2.
    -It doesn't matter what you leave beyond the returned length. For example if you return 2 with nums = [2,2,3,3] or nums = [2,2,0,0], your answer will be accepted.
    +Output: 2, nums = [2,2,_,_]
    +Explanation: Your function should return k = 2, with the first two elements of nums being 2.
    +It does not matter what you leave beyond the returned k (hence they are underscores).
     

    Example 2:

     Input: nums = [0,1,2,2,3,0,4,2], val = 2
    -Output: 5, nums = [0,1,4,0,3]
    -Explanation: Your function should return length = 5, with the first five elements of nums containing 0, 1, 3, 0, and 4. Note that the order of those five elements can be arbitrary. It doesn't matter what values are set beyond the returned length.
    +Output: 5, nums = [0,1,4,0,3,_,_,_]
    +Explanation: Your function should return k = 5, with the first five elements of nums containing 0, 0, 1, 3, and 4.
    +Note that the five elements can be returned in any order.
    +It does not matter what you leave beyond the returned k (hence they are underscores).
     

     

    diff --git a/problems/remove-interval/README.md b/problems/remove-interval/README.md index 437aef451..8ba741477 100644 --- a/problems/remove-interval/README.md +++ b/problems/remove-interval/README.md @@ -11,31 +11,10 @@ ## [1272. Remove Interval (Medium)](https://leetcode.com/problems/remove-interval "删除区间") -

    Given a sorted list of disjoint intervals, each interval intervals[i] = [a, b] represents the set of real numbers x such that a <= x < b.

    -

    We remove the intersections between any interval in intervals and the interval toBeRemoved.

    - -

    Return a sorted list of intervals after all such removals.

    - -

     

    -

    Example 1:

    -
    Input: intervals = [[0,2],[3,4],[5,7]], toBeRemoved = [1,6]
    -Output: [[0,1],[6,7]]
    -

    Example 2:

    -
    Input: intervals = [[0,5]], toBeRemoved = [2,3]
    -Output: [[0,2],[3,5]]
    -
    -

     

    -

    Constraints:

    - -
      -
    • 1 <= intervals.length <= 10^4
    • -
    • -10^9 <= intervals[i][0] < intervals[i][1] <= 10^9
    • -
    ### Related Topics - [[Math](../../tag/math/README.md)] - [[Line Sweep](../../tag/line-sweep/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/remove-invalid-parentheses/README.md b/problems/remove-invalid-parentheses/README.md index 7007597fa..cf2197412 100644 --- a/problems/remove-invalid-parentheses/README.md +++ b/problems/remove-invalid-parentheses/README.md @@ -47,8 +47,9 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[String](../../tag/string/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions 1. [Valid Parentheses](../valid-parentheses) (Easy) diff --git a/problems/remove-k-digits/README.md b/problems/remove-k-digits/README.md index b6bbd5378..c382758d4 100644 --- a/problems/remove-k-digits/README.md +++ b/problems/remove-k-digits/README.md @@ -9,7 +9,7 @@                  [Next >](../frog-jump "Frog Jump") -## [402. Remove K Digits (Medium)](https://leetcode.com/problems/remove-k-digits "移掉K位数字") +## [402. Remove K Digits (Medium)](https://leetcode.com/problems/remove-k-digits "移掉 K 位数字")

    Given string num representing a non-negative integer num, and an integer k, return the smallest possible integer after removing k digits from num.

    @@ -50,6 +50,8 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Similar Questions 1. [Create Maximum Number](../create-maximum-number) (Hard) diff --git a/problems/remove-linked-list-elements/README.md b/problems/remove-linked-list-elements/README.md index 4ef36a677..dc2467d0b 100644 --- a/problems/remove-linked-list-elements/README.md +++ b/problems/remove-linked-list-elements/README.md @@ -41,10 +41,11 @@
    • The number of nodes in the list is in the range [0, 104].
    • 1 <= Node.val <= 50
    • -
    • 0 <= k <= 50
    • +
    • 0 <= val <= 50
    ### Related Topics + [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions diff --git a/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md b/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md index 77c108011..1b68f02c6 100644 --- a/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md +++ b/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md @@ -69,6 +69,7 @@ ### Related Topics [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] ### Hints
    diff --git a/problems/remove-nth-node-from-end-of-list/README.md b/problems/remove-nth-node-from-end-of-list/README.md index 451a0a8e4..908f284b4 100644 --- a/problems/remove-nth-node-from-end-of-list/README.md +++ b/problems/remove-nth-node-from-end-of-list/README.md @@ -13,8 +13,6 @@

    Given the head of a linked list, remove the nth node from the end of the list and return its head.

    -

    Follow up: Could you do this in one pass?

    -

     

    Example 1:

    @@ -47,6 +45,9 @@
  • 1 <= n <= sz
  • +

     

    +

    Follow up: Could you do this in one pass?

    + ### Related Topics [[Linked List](../../tag/linked-list/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md b/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md new file mode 100644 index 000000000..b10d2d94e --- /dev/null +++ b/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../game-of-nim "Game of Nim") +                 +[Next >](../remove-all-occurrences-of-a-substring "Remove All Occurrences of a Substring") + +## [1909. Remove One Element to Make the Array Strictly Increasing (Easy)](https://leetcode.com/problems/remove-one-element-to-make-the-array-strictly-increasing "删除一个元素使数组严格递增") + +

    Given a 0-indexed integer array nums, return true if it can be made strictly increasing after removing exactly one element, or false otherwise. If the array is already strictly increasing, return true.

    + +

    The array nums is strictly increasing if nums[i - 1] < nums[i] for each index (1 <= i < nums.length).

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,10,5,7]
    +Output: true
    +Explanation: By removing 10 at index 2 from nums, it becomes [1,2,5,7].
    +[1,2,5,7] is strictly increasing, so return true.
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,3,1,2]
    +Output: false
    +Explanation:
    +[3,1,2] is the result of removing the element at index 0.
    +[2,1,2] is the result of removing the element at index 1.
    +[2,3,2] is the result of removing the element at index 2.
    +[2,3,1] is the result of removing the element at index 3.
    +No resulting array is strictly increasing, so return false.
    + +

    Example 3:

    + +
    +Input: nums = [1,1,1]
    +Output: false
    +Explanation: The result of removing any element is [1,1].
    +[1,1] is not strictly increasing, so return false.
    +
    + +

    Example 4:

    + +
    +Input: nums = [1,2,3]
    +Output: true
    +Explanation: [1,2,3] is already strictly increasing, so return true.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= nums.length <= 1000
    • +
    • 1 <= nums[i] <= 1000
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +For each index i in nums remove this index. +
    + +
    +Hint 2 +If the array becomes sorted return true, otherwise revert to the original array and try different index. +
    diff --git a/problems/remove-outermost-parentheses/README.md b/problems/remove-outermost-parentheses/README.md index 72901c984..50cf3f963 100644 --- a/problems/remove-outermost-parentheses/README.md +++ b/problems/remove-outermost-parentheses/README.md @@ -11,68 +11,61 @@ ## [1021. Remove Outermost Parentheses (Easy)](https://leetcode.com/problems/remove-outermost-parentheses "删除最外层的括号") -

    A valid parentheses string is either empty (""), "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatenation.  For example, "", "()", "(())()", and "(()(()))" are all valid parentheses strings.

    +

    A valid parentheses string is either empty "", "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatenation.

    -

    A valid parentheses string s is primitive if it is nonempty, and there does not exist a way to split it into s = A+B, with A and B nonempty valid parentheses strings.

    +
      +
    • For example, "", "()", "(())()", and "(()(()))" are all valid parentheses strings.
    • +
    -

    Given a valid parentheses string s, consider its primitive decomposition: s = P_1 + P_2 + ... + P_k, where P_i are primitive valid parentheses strings.

    +

    A valid parentheses string s is primitive if it is nonempty, and there does not exist a way to split it into s = A + B, with A and B nonempty valid parentheses strings.

    -

    Return s after removing the outermost parentheses of every primitive string in the primitive decomposition of S.

    +

    Given a valid parentheses string s, consider its primitive decomposition: s = P1 + P2 + ... + Pk, where Pi are primitive valid parentheses strings.

    -

     

    +

    Return s after removing the outermost parentheses of every primitive string in the primitive decomposition of s.

    +

     

    Example 1:

    -Input: s = "(()())(())"
    -Output: "()()()"
    -Explanation: 
    +Input: s = "(()())(())"
    +Output: "()()()"
    +Explanation: 
     The input string is "(()())(())", with primitive decomposition "(()())" + "(())".
     After removing outer parentheses of each part, this is "()()" + "()" = "()()()".
     
    -

    Example 2:

    -Input: s = "(()())(())(()(()))"
    -Output: "()()()()(())"
    -Explanation: 
    +Input: s = "(()())(())(()(()))"
    +Output: "()()()()(())"
    +Explanation: 
     The input string is "(()())(())(()(()))", with primitive decomposition "(()())" + "(())" + "(()(()))".
     After removing outer parentheses of each part, this is "()()" + "()" + "()(())" = "()()()()(())".
     
    -

    Example 3:

    -Input: s = "()()"
    -Output: ""
    -Explanation: 
    +Input: s = "()()"
    +Output: ""
    +Explanation: 
     The input string is "()()", with primitive decomposition "()" + "()".
     After removing outer parentheses of each part, this is "" + "" = "".
     

     

    -
    -
    - -

    Note:

    - -
      -
    1. s.length <= 10000
    2. -
    3. s[i] is "(" or ")"
    4. -
    5. s is a valid parentheses string
    6. -
    +

    Constraints:

    -
    -
    -
     
    -
    -
    +
      +
    • 1 <= s.length <= 105
    • +
    • s[i] is either '(' or ')'.
    • +
    • s is a valid parentheses string.
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/remove-palindromic-subsequences/README.md b/problems/remove-palindromic-subsequences/README.md index ce888c06c..9b302fce5 100644 --- a/problems/remove-palindromic-subsequences/README.md +++ b/problems/remove-palindromic-subsequences/README.md @@ -55,6 +55,7 @@ Remove palindromic subsequence "baab" then "b". ### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/remove-sub-folders-from-the-filesystem/README.md b/problems/remove-sub-folders-from-the-filesystem/README.md index 0a43455d8..01d6c85ed 100644 --- a/problems/remove-sub-folders-from-the-filesystem/README.md +++ b/problems/remove-sub-folders-from-the-filesystem/README.md @@ -53,6 +53,7 @@ ### Related Topics + [[Trie](../../tag/trie/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/remove-vowels-from-a-string/README.md b/problems/remove-vowels-from-a-string/README.md index ac8433ad8..9f69c6768 100644 --- a/problems/remove-vowels-from-a-string/README.md +++ b/problems/remove-vowels-from-a-string/README.md @@ -11,32 +11,7 @@ ## [1119. Remove Vowels from a String (Easy)](https://leetcode.com/problems/remove-vowels-from-a-string "删去字符串中的元音") -

    Given a string S, remove the vowels 'a', 'e', 'i', 'o', and 'u' from it, and return the new string.

    -

     

    - -

    Example 1:

    - -
    -Input: "leetcodeisacommunityforcoders"
    -Output: "ltcdscmmntyfrcdrs"
    -
    - -

    Example 2:

    - -
    -Input: "aeiou"
    -Output: ""
    -
    - -

     

    - -

    Note:

    - -
      -
    1. S consists of lowercase English letters only.
    2. -
    3. 1 <= S.length <= 1000
    4. -
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md b/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md index dbab2e02f..407e2f7e7 100644 --- a/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md +++ b/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md @@ -49,6 +49,7 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] ### Hints diff --git a/problems/reorder-data-in-log-files/README.md b/problems/reorder-data-in-log-files/README.md index 4da6b2ed1..be87a55e4 100644 --- a/problems/reorder-data-in-log-files/README.md +++ b/problems/reorder-data-in-log-files/README.md @@ -59,4 +59,6 @@ The digit-logs have a relative order of "dig1 8 1 5 1", "dig2 3 6 ### Related Topics + [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/reorder-list/README.md b/problems/reorder-list/README.md index 15cbbc4ec..7cd75f27e 100644 --- a/problems/reorder-list/README.md +++ b/problems/reorder-list/README.md @@ -49,4 +49,7 @@ L0 → Ln → L1 → Ln - 1 ### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md b/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md index 23a90d09d..192f235ee 100644 --- a/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md +++ b/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md @@ -57,8 +57,9 @@ ### Related Topics - [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] ### Hints
    diff --git a/problems/reordered-power-of-2/README.md b/problems/reordered-power-of-2/README.md index dcc0530d1..de7e05839 100644 --- a/problems/reordered-power-of-2/README.md +++ b/problems/reordered-power-of-2/README.md @@ -60,3 +60,6 @@ ### Related Topics [[Math](../../tag/math/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/reorganize-string/README.md b/problems/reorganize-string/README.md index 4b7088fac..bcb52bdbf 100644 --- a/problems/reorganize-string/README.md +++ b/problems/reorganize-string/README.md @@ -11,37 +11,33 @@ ## [767. Reorganize String (Medium)](https://leetcode.com/problems/reorganize-string "重构字符串") -

    Given a string s, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.

    +

    Given a string s, rearrange the characters of s so that any two adjacent characters are not the same.

    -

    If possible, output any possible result.  If not possible, return the empty string.

    +

    Return any possible rearrangement of s or return "" if not possible.

    +

     

    Example 1:

    - -
    -Input: s = "aab"
    -Output: "aba"
    -
    - -

    Example 2:

    - -
    -Input: s = "aaab"
    -Output: ""
    +
    Input: s = "aab"
    +Output: "aba"
    +

    Example 2:

    +
    Input: s = "aaab"
    +Output: ""
     
    - -

    Note:

    +

     

    +

    Constraints:

      -
    • s will consist of lowercase letters and have length in range [1, 500].
    • +
    • 1 <= s.length <= 500
    • +
    • s consists of lowercase English letters.
    -

     

    - ### Related Topics - [[Heap](../../tag/heap/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[Sort](../../tag/sort/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Rearrange String k Distance Apart](../rearrange-string-k-distance-apart) (Hard) diff --git a/problems/repeated-dna-sequences/README.md b/problems/repeated-dna-sequences/README.md index 2e352da8d..634d93c7f 100644 --- a/problems/repeated-dna-sequences/README.md +++ b/problems/repeated-dna-sequences/README.md @@ -40,3 +40,7 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] diff --git a/problems/repeated-string-match/README.md b/problems/repeated-string-match/README.md index 457d2a20b..8c8b15b2e 100644 --- a/problems/repeated-string-match/README.md +++ b/problems/repeated-string-match/README.md @@ -56,6 +56,7 @@ ### Related Topics [[String](../../tag/string/README.md)] + [[String Matching](../../tag/string-matching/README.md)] ### Similar Questions 1. [Repeated Substring Pattern](../repeated-substring-pattern) (Easy) diff --git a/problems/repeated-substring-pattern/README.md b/problems/repeated-substring-pattern/README.md index d5cf1a1d3..0d1fe46bf 100644 --- a/problems/repeated-substring-pattern/README.md +++ b/problems/repeated-substring-pattern/README.md @@ -47,6 +47,7 @@ ### Related Topics [[String](../../tag/string/README.md)] + [[String Matching](../../tag/string-matching/README.md)] ### Similar Questions 1. [Implement strStr()](../implement-strstr) (Easy) diff --git a/problems/replace-employee-id-with-the-unique-identifier/README.md b/problems/replace-employee-id-with-the-unique-identifier/README.md index ae92f57d0..26fefe712 100644 --- a/problems/replace-employee-id-with-the-unique-identifier/README.md +++ b/problems/replace-employee-id-with-the-unique-identifier/README.md @@ -11,69 +11,7 @@ ## [1378. Replace Employee ID With The Unique Identifier (Easy)](https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier "使用唯一标识码替换员工ID") -

    Table: Employees

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| id            | int     |
    -| name          | varchar |
    -+---------------+---------+
    -id is the primary key for this table.
    -Each row of this table contains the id and the name of an employee in a company.
    -
    - -

    Table: EmployeeUNI

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| id            | int     |
    -| unique_id     | int     |
    -+---------------+---------+
    -(id, unique_id) is the primary key for this table.
    -Each row of this table contains the id and the corresponding unique id of an employee in the company.
    -
    - -Write an SQL query to show the unique ID of each user, If a user doesn't have a unique ID replace just show null. -Return the result table in any order. -The query result format is in the following example: -
    -Employees table:
    -+----+----------+
    -| id | name     |
    -+----+----------+
    -| 1  | Alice    |
    -| 7  | Bob      |
    -| 11 | Meir     |
    -| 90 | Winston  |
    -| 3  | Jonathan |
    -+----+----------+
    -
    -EmployeeUNI table:
    -+----+-----------+
    -| id | unique_id |
    -+----+-----------+
    -| 3  | 1         |
    -| 11 | 2         |
    -| 90 | 3         |
    -+----+-----------+
    -
    -EmployeeUNI table:
    -+-----------+----------+
    -| unique_id | name     |
    -+-----------+----------+
    -| null      | Alice    |
    -| null      | Bob      |
    -| 2         | Meir     |
    -| 3         | Winston  |
    -| 1         | Jonathan |
    -+-----------+----------+
    -
    -Alice and Bob don't have a unique ID, We will show null instead.
    -The unique ID of Meir is 2.
    -The unique ID of Winston is 3.
    -The unique ID of Jonathan is 1.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/replace-the-substring-for-balanced-string/README.md b/problems/replace-the-substring-for-balanced-string/README.md index 21ef59f4b..1697262d2 100644 --- a/problems/replace-the-substring-for-balanced-string/README.md +++ b/problems/replace-the-substring-for-balanced-string/README.md @@ -61,8 +61,8 @@ ### Related Topics - [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/replace-words/README.md b/problems/replace-words/README.md index 940a66dca..2b09cd90d 100644 --- a/problems/replace-words/README.md +++ b/problems/replace-words/README.md @@ -51,7 +51,9 @@ ### Related Topics [[Trie](../../tag/trie/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Implement Trie (Prefix Tree)](../implement-trie-prefix-tree) (Medium) diff --git a/problems/report-contiguous-dates/README.md b/problems/report-contiguous-dates/README.md index 11fe64ece..b69926f2b 100644 --- a/problems/report-contiguous-dates/README.md +++ b/problems/report-contiguous-dates/README.md @@ -11,77 +11,7 @@ ## [1225. Report Contiguous Dates (Hard)](https://leetcode.com/problems/report-contiguous-dates "报告系统状态的连续日期") -

    Table: Failed

    -
    -+--------------+---------+
    -| Column Name  | Type    |
    -+--------------+---------+
    -| fail_date    | date    |
    -+--------------+---------+
    -Primary key for this table is fail_date.
    -Failed table contains the days of failed tasks.
    -
    -

    Table: Succeeded

    - -
    -+--------------+---------+
    -| Column Name  | Type    |
    -+--------------+---------+
    -| success_date | date    |
    -+--------------+---------+
    -Primary key for this table is success_date.
    -Succeeded table contains the days of succeeded tasks.
    -
    - -

     

    - -

    A system is running one task every day. Every task is independent of the previous tasks. The tasks can fail or succeed.

    - -

    Write an SQL query to generate a report of period_state for each continuous interval of days in the period from 2019-01-01 to 2019-12-31.

    - -

    period_state is 'failed' if tasks in this interval failed or 'succeeded' if tasks in this interval succeeded. Interval of days are retrieved as start_date and end_date.

    - -

    Order result by start_date.

    - -

    The query result format is in the following example:

    - -
    -Failed table:
    -+-------------------+
    -| fail_date         |
    -+-------------------+
    -| 2018-12-28        |
    -| 2018-12-29        |
    -| 2019-01-04        |
    -| 2019-01-05        |
    -+-------------------+
    -
    -Succeeded table:
    -+-------------------+
    -| success_date      |
    -+-------------------+
    -| 2018-12-30        |
    -| 2018-12-31        |
    -| 2019-01-01        |
    -| 2019-01-02        |
    -| 2019-01-03        |
    -| 2019-01-06        |
    -+-------------------+
    -
    -
    -Result table:
    -+--------------+--------------+--------------+
    -| period_state | start date   | end date     |
    -+--------------+--------------+--------------+
    -| present      | 2019-01-01   | 2019-01-03   |
    -| missing      | 2019-01-04   | 2019-01-05   |
    -| present      | 2019-01-06   | 2019-01-06   |
    -+--------------+--------------+--------------+
    -
    -The report ignored the system state in 2018 as we care about the system in the period 2019-01-01 to 2019-12-31.
    -From 2019-01-01 to 2019-01-03 all tasks succeeded and the system state was "present".
    -From 2019-01-04 to 2019-01-05 all tasks failed and system state was "missing".
    -From 2019-01-06 to 2019-01-06 all tasks succeeded and system state was "present".
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/reported-posts-ii/README.md b/problems/reported-posts-ii/README.md index 164ef4413..6012b984d 100644 --- a/problems/reported-posts-ii/README.md +++ b/problems/reported-posts-ii/README.md @@ -11,76 +11,7 @@ ## [1132. Reported Posts II (Medium)](https://leetcode.com/problems/reported-posts-ii "报告的记录 II") -

    Table: Actions

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| user_id       | int     |
    -| post_id       | int     |
    -| action_date   | date    |
    -| action        | enum    |
    -| extra         | varchar |
    -+---------------+---------+
    -There is no primary key for this table, it may have duplicate rows.
    -The action column is an ENUM type of ('view', 'like', 'reaction', 'comment', 'report', 'share').
    -The extra column has optional information about the action such as a reason for report or a type of reaction. 
    -

    Table: Removals

    - -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| post_id       | int     |
    -| remove_date   | date    | 
    -+---------------+---------+
    -post_id is the primary key of this table.
    -Each row in this table indicates that some post was removed as a result of being reported or as a result of an admin review.
    -
    - -

     

    - -

    Write an SQL query to find the average for daily percentage of posts that got removed after being reported as spam, rounded to 2 decimal places.

    - -

    The query result format is in the following example:

    - -
    -Actions table:
    -+---------+---------+-------------+--------+--------+
    -| user_id | post_id | action_date | action | extra  |
    -+---------+---------+-------------+--------+--------+
    -| 1       | 1       | 2019-07-01  | view   | null   |
    -| 1       | 1       | 2019-07-01  | like   | null   |
    -| 1       | 1       | 2019-07-01  | share  | null   |
    -| 2       | 2       | 2019-07-04  | view   | null   |
    -| 2       | 2       | 2019-07-04  | report | spam   |
    -| 3       | 4       | 2019-07-04  | view   | null   |
    -| 3       | 4       | 2019-07-04  | report | spam   |
    -| 4       | 3       | 2019-07-02  | view   | null   |
    -| 4       | 3       | 2019-07-02  | report | spam   |
    -| 5       | 2       | 2019-07-03  | view   | null   |
    -| 5       | 2       | 2019-07-03  | report | racism |
    -| 5       | 5       | 2019-07-03  | view   | null   |
    -| 5       | 5       | 2019-07-03  | report | racism |
    -+---------+---------+-------------+--------+--------+
    -
    -Removals table:
    -+---------+-------------+
    -| post_id | remove_date |
    -+---------+-------------+
    -| 2       | 2019-07-20  |
    -| 3       | 2019-07-18  |
    -+---------+-------------+
    -
    -Result table:
    -+-----------------------+
    -| average_daily_percent |
    -+-----------------------+
    -| 75.00                 |
    -+-----------------------+
    -The percentage for 2019-07-04 is 50% because only one post of two spam reported posts was removed.
    -The percentage for 2019-07-02 is 100% because one post was reported as spam and it was removed.
    -The other days had no spam reports so the average is (50 + 100) / 2 = 75%
    -Note that the output is only one number and that we do not care about the remove dates.
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/reported-posts/README.md b/problems/reported-posts/README.md index 029c248ed..ccc05d369 100644 --- a/problems/reported-posts/README.md +++ b/problems/reported-posts/README.md @@ -11,53 +11,7 @@ ## [1113. Reported Posts (Easy)](https://leetcode.com/problems/reported-posts "报告的记录") -

    Table: Actions

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| user_id       | int     |
    -| post_id       | int     |
    -| action_date   | date    | 
    -| action        | enum    |
    -| extra         | varchar |
    -+---------------+---------+
    -There is no primary key for this table, it may have duplicate rows.
    -The action column is an ENUM type of ('view', 'like', 'reaction', 'comment', 'report', 'share').
    -The extra column has optional information about the action such as a reason for report or a type of reaction. 
    -

     

    - -

    Write an SQL query that reports the number of posts reported yesterday for each report reason. Assume today is 2019-07-05.

    - -

    The query result format is in the following example:

    - -
    -Actions table:
    -+---------+---------+-------------+--------+--------+
    -| user_id | post_id | action_date | action | extra  |
    -+---------+---------+-------------+--------+--------+
    -| 1       | 1       | 2019-07-01  | view   | null   |
    -| 1       | 1       | 2019-07-01  | like   | null   |
    -| 1       | 1       | 2019-07-01  | share  | null   |
    -| 2       | 4       | 2019-07-04  | view   | null   |
    -| 2       | 4       | 2019-07-04  | report | spam   |
    -| 3       | 4       | 2019-07-04  | view   | null   |
    -| 3       | 4       | 2019-07-04  | report | spam   |
    -| 4       | 3       | 2019-07-02  | view   | null   |
    -| 4       | 3       | 2019-07-02  | report | spam   |
    -| 5       | 2       | 2019-07-04  | view   | null   |
    -| 5       | 2       | 2019-07-04  | report | racism |
    -| 5       | 5       | 2019-07-04  | view   | null   |
    -| 5       | 5       | 2019-07-04  | report | racism |
    -+---------+---------+-------------+--------+--------+
    -
    -Result table:
    -+---------------+--------------+
    -| report_reason | report_count |
    -+---------------+--------------+
    -| spam          | 1            |
    -| racism        | 2            |
    -+---------------+--------------+ 
    -Note that we only care about report reasons with non zero number of reports.
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/reshape-the-matrix/README.md b/problems/reshape-the-matrix/README.md index e929af1ac..786d327de 100644 --- a/problems/reshape-the-matrix/README.md +++ b/problems/reshape-the-matrix/README.md @@ -11,13 +11,13 @@ ## [566. Reshape the Matrix (Easy)](https://leetcode.com/problems/reshape-the-matrix "重塑矩阵") -

    In MATLAB, there is a handy function called reshape which can reshape an m x n matrix into a new one with a different size r x c keeping its original data.

    +

    In MATLAB, there is a handy function called reshape which can reshape an m x n matrix into a new one with a different size r x c keeping its original data.

    -

    You are given an m x n matrix mat and two integers r and c representing the row number and column number of the wanted reshaped matrix.

    +

    You are given an m x n matrix mat and two integers r and c representing the number of rows and the number of columns of the wanted reshaped matrix.

    The reshaped matrix should be filled with all the elements of the original matrix in the same row-traversing order as they were.

    -

    If the reshape operation with given parameters is possible and legal, output the new reshaped matrix; Otherwise, output the original matrix.

    +

    If the reshape operation with given parameters is possible and legal, output the new reshaped matrix; Otherwise, output the original matrix.

     

    Example 1:

    @@ -47,6 +47,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    @@ -68,5 +70,5 @@ Try to use division and modulus to convert 1-d index into 2-d indices.
    Hint 4 -M[i] => M[i/n][n%i] Will it result in right mapping? Take some example and check this formula. +M[i] => M[i/n][i%n] Will it result in right mapping? Take some example and check this formula.
    diff --git a/problems/restaurant-growth/README.md b/problems/restaurant-growth/README.md index 4f767373e..fe2838ad0 100644 --- a/problems/restaurant-growth/README.md +++ b/problems/restaurant-growth/README.md @@ -11,62 +11,7 @@ ## [1321. Restaurant Growth (Medium)](https://leetcode.com/problems/restaurant-growth "餐馆营业额变化增长") -

    Table: Customer

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| customer_id   | int     |
    -| name          | varchar |
    -| visited_on    | date    |
    -| amount        | int     |
    -+---------------+---------+
    -(customer_id, visited_on) is the primary key for this table.
    -This table contains data about customer transactions in a restaurant.
    -visited_on is the date on which the customer with ID (customer_id) have visited the restaurant.
    -amount is the total paid by a customer.
    -
    -You are the restaurant owner and you want to analyze a possible expansion (there will be at least one customer every day). -Write an SQL query to compute moving average of how much customer paid in a 7 days window (current day + 6 days before) . - -The query result format is in the following example: - -Return result table ordered by visited_on. - -average_amount should be rounded to 2 decimal places, all dates are in the format ('YYYY-MM-DD'). - -
    -Customer table:
    -+-------------+--------------+--------------+-------------+
    -| customer_id | name         | visited_on   | amount      |
    -+-------------+--------------+--------------+-------------+
    -| 1           | Jhon         | 2019-01-01   | 100         |
    -| 2           | Daniel       | 2019-01-02   | 110         |
    -| 3           | Jade         | 2019-01-03   | 120         |
    -| 4           | Khaled       | 2019-01-04   | 130         |
    -| 5           | Winston      | 2019-01-05   | 110         | 
    -| 6           | Elvis        | 2019-01-06   | 140         | 
    -| 7           | Anna         | 2019-01-07   | 150         |
    -| 8           | Maria        | 2019-01-08   | 80          |
    -| 9           | Jaze         | 2019-01-09   | 110         | 
    -| 1           | Jhon         | 2019-01-10   | 130         | 
    -| 3           | Jade         | 2019-01-10   | 150         | 
    -+-------------+--------------+--------------+-------------+
    -
    -Result table:
    -+--------------+--------------+----------------+
    -| visited_on   | amount       | average_amount |
    -+--------------+--------------+----------------+
    -| 2019-01-07   | 860          | 122.86         |
    -| 2019-01-08   | 840          | 120            |
    -| 2019-01-09   | 840          | 120            |
    -| 2019-01-10   | 1000         | 142.86         |
    -+--------------+--------------+----------------+
    -
    -1st moving average from 2019-01-01 to 2019-01-07 has an average_amount of (100 + 110 + 120 + 130 + 110 + 140 + 150)/7 = 122.86
    -2nd moving average from 2019-01-02 to 2019-01-08 has an average_amount of (110 + 120 + 130 + 110 + 140 + 150 + 80)/7 = 120
    -3rd moving average from 2019-01-03 to 2019-01-09 has an average_amount of (120 + 130 + 110 + 140 + 150 + 80 + 110)/7 = 120
    -4th moving average from 2019-01-04 to 2019-01-10 has an average_amount of (130 + 110 + 140 + 150 + 80 + 110 + 130 + 150)/7 = 142.86
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/restore-the-array-from-adjacent-pairs/README.md b/problems/restore-the-array-from-adjacent-pairs/README.md index 2e6e2c38a..6e2e7ab50 100644 --- a/problems/restore-the-array-from-adjacent-pairs/README.md +++ b/problems/restore-the-array-from-adjacent-pairs/README.md @@ -58,7 +58,8 @@ Another solution is [-3,1,4,-2], which would also be accepted. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/restore-the-array/README.md b/problems/restore-the-array/README.md index 3276f9838..8a6bf34db 100644 --- a/problems/restore-the-array/README.md +++ b/problems/restore-the-array/README.md @@ -69,6 +69,7 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/reveal-cards-in-increasing-order/README.md b/problems/reveal-cards-in-increasing-order/README.md index b4783978a..e236bcd08 100644 --- a/problems/reveal-cards-in-increasing-order/README.md +++ b/problems/reveal-cards-in-increasing-order/README.md @@ -62,4 +62,7 @@ Since all the cards revealed are in increasing order, the answer is correct.
    ### Related Topics + [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/reverse-bits/README.md b/problems/reverse-bits/README.md index 2170049d8..9547d3ebb 100644 --- a/problems/reverse-bits/README.md +++ b/problems/reverse-bits/README.md @@ -50,6 +50,7 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions 1. [Reverse Integer](../reverse-integer) (Easy) diff --git a/problems/reverse-linked-list/README.md b/problems/reverse-linked-list/README.md index d03c625ab..393cdb8d1 100644 --- a/problems/reverse-linked-list/README.md +++ b/problems/reverse-linked-list/README.md @@ -47,6 +47,7 @@

    Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both?

    ### Related Topics + [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions diff --git a/problems/reverse-nodes-in-k-group/README.md b/problems/reverse-nodes-in-k-group/README.md index 50019805f..7ad436a04 100644 --- a/problems/reverse-nodes-in-k-group/README.md +++ b/problems/reverse-nodes-in-k-group/README.md @@ -60,6 +60,7 @@ Follow-up: Can you solve the problem in O(1) extra memory space? ### Related Topics + [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] ### Similar Questions diff --git a/problems/reverse-only-letters/README.md b/problems/reverse-only-letters/README.md index 4dfb5e8c2..b96d23220 100644 --- a/problems/reverse-only-letters/README.md +++ b/problems/reverse-only-letters/README.md @@ -64,6 +64,7 @@
    ### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/reverse-pairs/README.md b/problems/reverse-pairs/README.md index cd4dfb895..ad153a41e 100644 --- a/problems/reverse-pairs/README.md +++ b/problems/reverse-pairs/README.md @@ -32,11 +32,13 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Merge Sort](../../tag/merge-sort/README.md)] ### Similar Questions 1. [Count of Smaller Numbers After Self](../count-of-smaller-numbers-after-self) (Hard) diff --git a/problems/reverse-string-ii/README.md b/problems/reverse-string-ii/README.md index a7f75c867..4700b4759 100644 --- a/problems/reverse-string-ii/README.md +++ b/problems/reverse-string-ii/README.md @@ -33,6 +33,7 @@ ### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/reverse-string/README.md b/problems/reverse-string/README.md index 916361916..cdbb71fcb 100644 --- a/problems/reverse-string/README.md +++ b/problems/reverse-string/README.md @@ -33,6 +33,7 @@

    Follow up: Do not allocate extra space for another array. You must do this by modifying the input array in-place with O(1) extra memory.

    ### Related Topics + [[Recursion](../../tag/recursion/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/reverse-subarray-to-maximize-array-value/README.md b/problems/reverse-subarray-to-maximize-array-value/README.md index 697eb0f3c..22437b25e 100644 --- a/problems/reverse-subarray-to-maximize-array-value/README.md +++ b/problems/reverse-subarray-to-maximize-array-value/README.md @@ -42,6 +42,7 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/reverse-substrings-between-each-pair-of-parentheses/README.md b/problems/reverse-substrings-between-each-pair-of-parentheses/README.md index d02500b91..822cda347 100644 --- a/problems/reverse-substrings-between-each-pair-of-parentheses/README.md +++ b/problems/reverse-substrings-between-each-pair-of-parentheses/README.md @@ -59,6 +59,7 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/reverse-words-in-a-string-ii/README.md b/problems/reverse-words-in-a-string-ii/README.md index 5a6b559af..99bec2cd9 100644 --- a/problems/reverse-words-in-a-string-ii/README.md +++ b/problems/reverse-words-in-a-string-ii/README.md @@ -11,25 +11,10 @@ ## [186. Reverse Words in a String II (Medium)](https://leetcode.com/problems/reverse-words-in-a-string-ii "翻转字符串里的单词 II") -

    Given an input string , reverse the string word by word. 

    -

    Example:

    - -
    -Input:  ["t","h","e"," ","s","k","y"," ","i","s"," ","b","l","u","e"]
    -Output: ["b","l","u","e"," ","i","s"," ","s","k","y"," ","t","h","e"]
    - -

    Note: 

    - -
      -
    • A word is defined as a sequence of non-space characters.
    • -
    • The input string does not contain leading or trailing spaces.
    • -
    • The words are always separated by a single space.
    • -
    - -

    Follow up: Could you do it in-place without allocating extra space?

    ### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/reverse-words-in-a-string-iii/README.md b/problems/reverse-words-in-a-string-iii/README.md index 033cce7e8..c0be62ca8 100644 --- a/problems/reverse-words-in-a-string-iii/README.md +++ b/problems/reverse-words-in-a-string-iii/README.md @@ -33,6 +33,7 @@ ### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/reverse-words-in-a-string/README.md b/problems/reverse-words-in-a-string/README.md index c83eac0e6..a42fabf98 100644 --- a/problems/reverse-words-in-a-string/README.md +++ b/problems/reverse-words-in-a-string/README.md @@ -67,9 +67,10 @@

     

    -

    Follow up: Could you solve it in-place with O(1) extra space?

    +

    Follow-up: If the string data type is mutable in your language, can you solve it in-place with O(1) extra space?

    ### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/richest-customer-wealth/README.md b/problems/richest-customer-wealth/README.md index 48a1f107e..05169133b 100644 --- a/problems/richest-customer-wealth/README.md +++ b/problems/richest-customer-wealth/README.md @@ -57,6 +57,7 @@ The 2nd customer is the richest with a wealth of 10. ### Related Topics [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/rising-temperature/README.md b/problems/rising-temperature/README.md index 87eccc276..8ec7df841 100644 --- a/problems/rising-temperature/README.md +++ b/problems/rising-temperature/README.md @@ -54,3 +54,6 @@ Result table: In 2015-01-02, temperature was higher than the previous day (10 -> 25). In 2015-01-04, temperature was higher than the previous day (20 -> 30). + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/rle-iterator/README.md b/problems/rle-iterator/README.md index 8533fc735..2a5a2eb27 100644 --- a/problems/rle-iterator/README.md +++ b/problems/rle-iterator/README.md @@ -57,4 +57,7 @@ but the second term did not exist. Since the last term exhausted does not exist, ### Related Topics + [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Iterator](../../tag/iterator/README.md)] diff --git a/problems/robot-bounded-in-circle/README.md b/problems/robot-bounded-in-circle/README.md index 8cac50e8a..7c7c71507 100644 --- a/problems/robot-bounded-in-circle/README.md +++ b/problems/robot-bounded-in-circle/README.md @@ -56,6 +56,8 @@ When repeating these instructions, the robot remains in the circle of radius 2 c ### Related Topics [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/robot-return-to-origin/README.md b/problems/robot-return-to-origin/README.md index 3d67fa8d2..5228217a6 100644 --- a/problems/robot-return-to-origin/README.md +++ b/problems/robot-return-to-origin/README.md @@ -58,6 +58,7 @@ ### Related Topics [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Similar Questions 1. [Number of Provinces](../number-of-provinces) (Medium) diff --git a/problems/robot-room-cleaner/README.md b/problems/robot-room-cleaner/README.md index 4f9fd0399..2967c2fb1 100644 --- a/problems/robot-room-cleaner/README.md +++ b/problems/robot-room-cleaner/README.md @@ -11,64 +11,11 @@ ## [489. Robot Room Cleaner (Hard)](https://leetcode.com/problems/robot-room-cleaner "扫地机器人") -

    Given a robot cleaner in a room modeled as a grid.

    -

    Each cell in the grid can be empty or blocked.

    - -

    The robot cleaner with 4 given APIs can move forward, turn left or turn right. Each turn it made is 90 degrees.

    - -

    When it tries to move into a blocked cell, its bumper sensor detects the obstacle and it stays on the current cell.

    - -

    Design an algorithm to clean the entire room using only the 4 given APIs shown below.

    - -
    -interface Robot {
    -  // returns true if next cell is open and robot moves into the cell.
    -  // returns false if next cell is obstacle and robot stays on the current cell.
    -  boolean move();
    -
    -  // Robot will stay on the same cell after calling turnLeft/turnRight.
    -  // Each turn will be 90 degrees.
    -  void turnLeft();
    -  void turnRight();
    -
    -  // Clean the current cell.
    -  void clean();
    -}
    -
    - -

    Example:

    - -
    Input:
    -room = [
    -  [1,1,1,1,1,0,1,1],
    -  [1,1,1,1,1,0,1,1],
    -  [1,0,1,1,1,1,1,1],
    -  [0,0,0,1,0,0,0,0],
    -  [1,1,1,1,1,1,1,1]
    -],
    -row = 1,
    -col = 3
    -
    -Explanation:
    -All grids in the room are marked by either 0 or 1.
    -0 means the cell is blocked, while 1 means the cell is accessible.
    -The robot initially starts at the position of row=1, col=3.
    -From the top left corner, its position is one row below and three columns right.
    -
    - -

    Notes:

    - -
      -
    1. The input is only given to initialize the room and the robot's position internally. You must solve this problem "blindfolded". In other words, you must control the robot using only the mentioned 4 APIs, without knowing the room layout and the initial robot's position.
    2. -
    3. The robot's initial position will always be in an accessible cell.
    4. -
    5. The initial direction of the robot will be facing up.
    6. -
    7. All accessible cells are connected, which means the all cells marked as 1 will be accessible by the robot.
    8. -
    9. Assume all four edges of the grid are all surrounded by wall.
    10. -
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Interactive](../../tag/interactive/README.md)] ### Similar Questions 1. [Walls and Gates](../walls-and-gates) (Medium) diff --git a/problems/roman-to-integer/README.md b/problems/roman-to-integer/README.md index a8386bbd3..16486d247 100644 --- a/problems/roman-to-integer/README.md +++ b/problems/roman-to-integer/README.md @@ -83,6 +83,7 @@ M 1000 ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/rotate-array/README.md b/problems/rotate-array/README.md index 4f0fe02f0..cf4d0ec51 100644 --- a/problems/rotate-array/README.md +++ b/problems/rotate-array/README.md @@ -54,6 +54,8 @@ rotate 2 steps to the right: [3,99,-1,-100] ### Related Topics [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Similar Questions 1. [Rotate List](../rotate-list) (Medium) diff --git a/problems/rotate-function/README.md b/problems/rotate-function/README.md index 4d60b8e7a..bf753ce68 100644 --- a/problems/rotate-function/README.md +++ b/problems/rotate-function/README.md @@ -21,6 +21,8 @@

    Return the maximum value of F(0), F(1), ..., F(n-1).

    +

    The test cases are generated so that the answer fits in a 32-bit integer.

    +

     

    Example 1:

    @@ -47,9 +49,10 @@ So the maximum value of F(0), F(1), F(2), F(3) is F(3) = 26.
    • n == nums.length
    • -
    • 1 <= n <= 3 * 104
    • -
    • -231 <= nums[i] <= 231 - 1
    • +
    • 1 <= n <= 105
    • +
    • -100 <= nums[i] <= 100
    ### Related Topics [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/rotate-image/README.md b/problems/rotate-image/README.md index c238417ab..8f50d1f36 100644 --- a/problems/rotate-image/README.md +++ b/problems/rotate-image/README.md @@ -56,3 +56,5 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/rotate-string/README.md b/problems/rotate-string/README.md index cc8877deb..49209f019 100644 --- a/problems/rotate-string/README.md +++ b/problems/rotate-string/README.md @@ -30,3 +30,7 @@
    • s and goal will have length at most 100.
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[String Matching](../../tag/string-matching/README.md)] diff --git a/problems/rotated-digits/README.md b/problems/rotated-digits/README.md index 48fa45468..90e1e9cdb 100644 --- a/problems/rotated-digits/README.md +++ b/problems/rotated-digits/README.md @@ -33,4 +33,5 @@ Note that 1 and 10 are not good numbers, since they remain unchanged after rotat ### Related Topics - [[String](../../tag/string/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/rotating-the-box/README.md b/problems/rotating-the-box/README.md index a086e537e..0d115c323 100644 --- a/problems/rotating-the-box/README.md +++ b/problems/rotating-the-box/README.md @@ -79,6 +79,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/rotting-oranges/README.md b/problems/rotting-oranges/README.md index 812af76c4..d1b38db31 100644 --- a/problems/rotting-oranges/README.md +++ b/problems/rotting-oranges/README.md @@ -58,7 +58,9 @@ ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Walls and Gates](../walls-and-gates) (Medium) diff --git a/problems/running-sum-of-1d-array/README.md b/problems/running-sum-of-1d-array/README.md index a0699df2a..14417c0f0 100644 --- a/problems/running-sum-of-1d-array/README.md +++ b/problems/running-sum-of-1d-array/README.md @@ -47,6 +47,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/running-total-for-different-genders/README.md b/problems/running-total-for-different-genders/README.md index 9d0db8e7d..5d8b3fb00 100644 --- a/problems/running-total-for-different-genders/README.md +++ b/problems/running-total-for-different-genders/README.md @@ -11,65 +11,7 @@ ## [1308. Running Total for Different Genders (Medium)](https://leetcode.com/problems/running-total-for-different-genders "不同性别每日分数总计") -

    Table: Scores

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| player_name   | varchar |
    -| gender        | varchar |
    -| day           | date    |
    -| score_points  | int     |
    -+---------------+---------+
    -(gender, day) is the primary key for this table.
    -A competition is held between females team and males team.
    -Each row of this table indicates that a player_name and with gender has scored score_point in someday.
    -Gender is 'F' if the player is in females team and 'M' if the player is in males team.
    - 
    -Write an SQL query to find the total score for each gender at each day. -Order the result table by gender and day - -The query result format is in the following example: -
    -Scores table:
    -+-------------+--------+------------+--------------+
    -| player_name | gender | day        | score_points |
    -+-------------+--------+------------+--------------+
    -| Aron        | F      | 2020-01-01 | 17           |
    -| Alice       | F      | 2020-01-07 | 23           |
    -| Bajrang     | M      | 2020-01-07 | 7            |
    -| Khali       | M      | 2019-12-25 | 11           |
    -| Slaman      | M      | 2019-12-30 | 13           |
    -| Joe         | M      | 2019-12-31 | 3            |
    -| Jose        | M      | 2019-12-18 | 2            |
    -| Priya       | F      | 2019-12-31 | 23           |
    -| Priyanka    | F      | 2019-12-30 | 17           |
    -+-------------+--------+------------+--------------+
    -Result table:
    -+--------+------------+-------+
    -| gender | day        | total |
    -+--------+------------+-------+
    -| F      | 2019-12-30 | 17    |
    -| F      | 2019-12-31 | 40    |
    -| F      | 2020-01-01 | 57    |
    -| F      | 2020-01-07 | 80    |
    -| M      | 2019-12-18 | 2     |
    -| M      | 2019-12-25 | 13    |
    -| M      | 2019-12-30 | 26    |
    -| M      | 2019-12-31 | 29    |
    -| M      | 2020-01-07 | 36    |
    -+--------+------------+-------+
    -For females team:
    -First day is 2019-12-30, Priyanka scored 17 points and the total score for the team is 17.
    -Second day is 2019-12-31, Priya scored 23 points and the total score for the team is 40.
    -Third day is 2020-01-01, Aron scored 17 points and the total score for the team is 57.
    -Fourth day is 2020-01-07, Alice scored 23 points and the total score for the team is 80.
    -For males team:
    -First day is 2019-12-18, Jose scored 2 points and the total score for the team is 2.
    -Second day is 2019-12-25, Khali scored 11 points and the total score for the team is 13.
    -Third day is 2019-12-30, Slaman scored 13 points and the total score for the team is 26.
    -Fourth day is 2019-12-31, Joe scored 3 points and the total score for the team is 29.
    -Fifth day is 2020-01-07, Bajrang scored 7 points and the total score for the team is 36.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/russian-doll-envelopes/README.md b/problems/russian-doll-envelopes/README.md index 6d74114b1..6da9f5234 100644 --- a/problems/russian-doll-envelopes/README.md +++ b/problems/russian-doll-envelopes/README.md @@ -45,8 +45,10 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Longest Increasing Subsequence](../longest-increasing-subsequence) (Medium) diff --git a/problems/sales-analysis-i/README.md b/problems/sales-analysis-i/README.md index 0a1194fca..e7a29796b 100644 --- a/problems/sales-analysis-i/README.md +++ b/problems/sales-analysis-i/README.md @@ -11,67 +11,7 @@ ## [1082. Sales Analysis I (Easy)](https://leetcode.com/problems/sales-analysis-i "销售分析 I ") -

    Table: Product

    -
    -+--------------+---------+
    -| Column Name  | Type    |
    -+--------------+---------+
    -| product_id   | int     |
    -| product_name | varchar |
    -| unit_price   | int     |
    -+--------------+---------+
    -product_id is the primary key of this table.
    -
    -

    Table: Sales

    - -
    -+-------------+---------+
    -| Column Name | Type    |
    -+-------------+---------+
    -| seller_id   | int     |
    -| product_id  | int     |
    -| buyer_id    | int     |
    -| sale_date   | date    |
    -| quantity    | int     |
    -| price       | int     |
    -+------ ------+---------+
    -This table has no primary key, it can have repeated rows.
    -product_id is a foreign key to Product table.
    -
    - -

     

    - -

    Write an SQL query that reports the best seller by total sales price, If there is a tie, report them all.

    - -

    The query result format is in the following example:

    - -
    -Product table:
    -+------------+--------------+------------+
    -| product_id | product_name | unit_price |
    -+------------+--------------+------------+
    -| 1          | S8           | 1000       |
    -| 2          | G4           | 800        |
    -| 3          | iPhone       | 1400       |
    -+------------+--------------+------------+
    -
    -Sales table:
    -+-----------+------------+----------+------------+----------+-------+
    -| seller_id | product_id | buyer_id | sale_date  | quantity | price |
    -+-----------+------------+----------+------------+----------+-------+
    -| 1         | 1          | 1        | 2019-01-21 | 2        | 2000  |
    -| 1         | 2          | 2        | 2019-02-17 | 1        | 800   |
    -| 2         | 2          | 3        | 2019-06-02 | 1        | 800   |
    -| 3         | 3          | 4        | 2019-05-13 | 2        | 2800  |
    -+-----------+------------+----------+------------+----------+-------+
    -
    -Result table:
    -+-------------+
    -| seller_id   |
    -+-------------+
    -| 1           |
    -| 3           |
    -+-------------+
    -Both sellers with id 1 and 3 sold products with the most total price of 2800.
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/sales-analysis-ii/README.md b/problems/sales-analysis-ii/README.md index fc8aa1986..a466fdd68 100644 --- a/problems/sales-analysis-ii/README.md +++ b/problems/sales-analysis-ii/README.md @@ -11,66 +11,7 @@ ## [1083. Sales Analysis II (Easy)](https://leetcode.com/problems/sales-analysis-ii "销售分析 II") -

    Table: Product

    -
    -+--------------+---------+
    -| Column Name  | Type    |
    -+--------------+---------+
    -| product_id   | int     |
    -| product_name | varchar |
    -| unit_price   | int     |
    -+--------------+---------+
    -product_id is the primary key of this table.
    -
    -

    Table: Sales

    - -
    -+-------------+---------+
    -| Column Name | Type    |
    -+-------------+---------+
    -| seller_id   | int     |
    -| product_id  | int     |
    -| buyer_id    | int     |
    -| sale_date   | date    |
    -| quantity    | int     |
    -| price       | int     |
    -+------ ------+---------+
    -This table has no primary key, it can have repeated rows.
    -product_id is a foreign key to Product table.
    -
    - -

     

    - -

    Write an SQL query that reports the buyers who have bought S8 but not iPhone. Note that S8 and iPhone are products present in the Product table.

    - -

    The query result format is in the following example:

    - -
    -Product table:
    -+------------+--------------+------------+
    -| product_id | product_name | unit_price |
    -+------------+--------------+------------+
    -| 1          | S8           | 1000       |
    -| 2          | G4           | 800        |
    -| 3          | iPhone       | 1400       |
    -+------------+--------------+------------+
    -
    -Sales table:
    -+-----------+------------+----------+------------+----------+-------+
    -| seller_id | product_id | buyer_id | sale_date  | quantity | price |
    -+-----------+------------+----------+------------+----------+-------+
    -| 1         | 1          | 1        | 2019-01-21 | 2        | 2000  |
    -| 1         | 2          | 2        | 2019-02-17 | 1        | 800   |
    -| 2         | 1          | 3        | 2019-06-02 | 1        | 800   |
    -| 3         | 3          | 3        | 2019-05-13 | 2        | 2800  |
    -+-----------+------------+----------+------------+----------+-------+
    -
    -Result table:
    -+-------------+
    -| buyer_id    |
    -+-------------+
    -| 1           |
    -+-------------+
    -The buyer with id 1 bought an S8 but didn't buy an iPhone. The buyer with id 3 bought both.
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/sales-analysis-iii/README.md b/problems/sales-analysis-iii/README.md index dd4265cf4..fd9448d44 100644 --- a/problems/sales-analysis-iii/README.md +++ b/problems/sales-analysis-iii/README.md @@ -11,66 +11,7 @@ ## [1084. Sales Analysis III (Easy)](https://leetcode.com/problems/sales-analysis-iii "销售分析III") -

    Table: Product

    -
    -+--------------+---------+
    -| Column Name  | Type    |
    -+--------------+---------+
    -| product_id   | int     |
    -| product_name | varchar |
    -| unit_price   | int     |
    -+--------------+---------+
    -product_id is the primary key of this table.
    -
    -

    Table: Sales

    - -
    -+-------------+---------+
    -| Column Name | Type    |
    -+-------------+---------+
    -| seller_id   | int     |
    -| product_id  | int     |
    -| buyer_id    | int     |
    -| sale_date   | date    |
    -| quantity    | int     |
    -| price       | int     |
    -+------ ------+---------+
    -This table has no primary key, it can have repeated rows.
    -product_id is a foreign key to Product table.
    -
    - -

     

    - -

    Write an SQL query that reports the products that were only sold in spring 2019. That is, between 2019-01-01 and 2019-03-31 inclusive.

    - -

    The query result format is in the following example:

    - -
    -Product table:
    -+------------+--------------+------------+
    -| product_id | product_name | unit_price |
    -+------------+--------------+------------+
    -| 1          | S8           | 1000       |
    -| 2          | G4           | 800        |
    -| 3          | iPhone       | 1400       |
    -+------------+--------------+------------+
    -
    -Sales table:
    -+-----------+------------+----------+------------+----------+-------+
    -| seller_id | product_id | buyer_id | sale_date  | quantity | price |
    -+-----------+------------+----------+------------+----------+-------+
    -| 1         | 1          | 1        | 2019-01-21 | 2        | 2000  |
    -| 1         | 2          | 2        | 2019-02-17 | 1        | 800   |
    -| 2         | 2          | 3        | 2019-06-02 | 1        | 800   |
    -| 3         | 3          | 4        | 2019-05-13 | 2        | 2800  |
    -+-----------+------------+----------+------------+----------+-------+
    -
    -Result table:
    -+-------------+--------------+
    -| product_id  | product_name |
    -+-------------+--------------+
    -| 1           | S8           |
    -+-------------+--------------+
    -The product with id 1 was only sold in spring 2019 while the other two were sold after.
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/sales-by-day-of-the-week/README.md b/problems/sales-by-day-of-the-week/README.md index 28d94b922..dcc18624a 100644 --- a/problems/sales-by-day-of-the-week/README.md +++ b/problems/sales-by-day-of-the-week/README.md @@ -12,3 +12,6 @@ ## [1479. Sales by Day of the Week (Hard)](https://leetcode.com/problems/sales-by-day-of-the-week "周内每天的销售情况") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/sales-person/README.md b/problems/sales-person/README.md index 3cdb5eca4..16f0dcb9d 100644 --- a/problems/sales-person/README.md +++ b/problems/sales-person/README.md @@ -11,73 +11,10 @@ ## [607. Sales Person (Easy)](https://leetcode.com/problems/sales-person "销售员") -

    Description

    -

    Given three tables: salesperson, company, orders.
    -Output all the names in the table salesperson, who didn’t have sales to company 'RED'.

    -

    Example
    -Input

    - -

    Table: salesperson

    - -
    -+----------+------+--------+-----------------+-----------+
    -| sales_id | name | salary | commission_rate | hire_date |
    -+----------+------+--------+-----------------+-----------+
    -|   1      | John | 100000 |     6           | 4/1/2006  |
    -|   2      | Amy  | 120000 |     5           | 5/1/2010  |
    -|   3      | Mark | 65000  |     12          | 12/25/2008|
    -|   4      | Pam  | 25000  |     25          | 1/1/2005  |
    -|   5      | Alex | 50000  |     10          | 2/3/2007  |
    -+----------+------+--------+-----------------+-----------+
    -
    -The table salesperson holds the salesperson information. Every salesperson has a sales_id and a name. - -

    Table: company

    - -
    -+---------+--------+------------+
    -| com_id  |  name  |    city    |
    -+---------+--------+------------+
    -|   1     |  RED   |   Boston   |
    -|   2     | ORANGE |   New York |
    -|   3     | YELLOW |   Boston   |
    -|   4     | GREEN  |   Austin   |
    -+---------+--------+------------+
    -
    -The table company holds the company information. Every company has a com_id and a name. - -

    Table: orders

    - -
    -+----------+------------+---------+----------+--------+
    -| order_id | order_date | com_id  | sales_id | amount |
    -+----------+------------+---------+----------+--------+
    -| 1        |   1/1/2014 |    3    |    4     | 100000 |
    -| 2        |   2/1/2014 |    4    |    5     | 5000   |
    -| 3        |   3/1/2014 |    1    |    1     | 50000  |
    -| 4        |   4/1/2014 |    1    |    4     | 25000  |
    -+----------+----------+---------+----------+--------+
    -
    -The table orders holds the sales record information, salesperson and customer company are represented by sales_id and com_id. - -

    output

    - -
    -+------+
    -| name | 
    -+------+
    -| Amy  | 
    -| Mark | 
    -| Alex |
    -+------+
    -
    - -

    Explanation

    - -

    According to order '3' and '4' in table orders, it is easy to tell only salesperson 'John' and 'Alex' have sales to company 'RED',
    -so we need to output all the other names in table salesperson.

    +### Related Topics + [[Database](../../tag/database/README.md)] ### Hints
    diff --git a/problems/same-tree/README.md b/problems/same-tree/README.md index 63caeb36f..9f6006314 100644 --- a/problems/same-tree/README.md +++ b/problems/same-tree/README.md @@ -47,4 +47,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/satisfiability-of-equality-equations/README.md b/problems/satisfiability-of-equality-equations/README.md index 254462d3e..8f02fc549 100644 --- a/problems/satisfiability-of-equality-equations/README.md +++ b/problems/satisfiability-of-equality-equations/README.md @@ -82,3 +82,5 @@ ### Related Topics [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/score-after-flipping-matrix/README.md b/problems/score-after-flipping-matrix/README.md index 37284c982..b40ba1d2f 100644 --- a/problems/score-after-flipping-matrix/README.md +++ b/problems/score-after-flipping-matrix/README.md @@ -47,3 +47,6 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/search-a-2d-matrix-ii/README.md b/problems/search-a-2d-matrix-ii/README.md index 270c208cc..2cc3e859c 100644 --- a/problems/search-a-2d-matrix-ii/README.md +++ b/problems/search-a-2d-matrix-ii/README.md @@ -47,8 +47,10 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Search a 2D Matrix](../search-a-2d-matrix) (Medium) diff --git a/problems/search-a-2d-matrix/README.md b/problems/search-a-2d-matrix/README.md index a17dcd2f6..35e2e654e 100644 --- a/problems/search-a-2d-matrix/README.md +++ b/problems/search-a-2d-matrix/README.md @@ -46,6 +46,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Search a 2D Matrix II](../search-a-2d-matrix-ii) (Medium) diff --git a/problems/search-in-a-binary-search-tree/README.md b/problems/search-in-a-binary-search-tree/README.md index 8baa90f04..68060b3b2 100644 --- a/problems/search-in-a-binary-search-tree/README.md +++ b/problems/search-in-a-binary-search-tree/README.md @@ -42,6 +42,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Closest Binary Search Tree Value](../closest-binary-search-tree-value) (Easy) diff --git a/problems/search-in-a-sorted-array-of-unknown-size/README.md b/problems/search-in-a-sorted-array-of-unknown-size/README.md index ae427a39c..772893597 100644 --- a/problems/search-in-a-sorted-array-of-unknown-size/README.md +++ b/problems/search-in-a-sorted-array-of-unknown-size/README.md @@ -11,36 +11,12 @@ ## [702. Search in a Sorted Array of Unknown Size (Medium)](https://leetcode.com/problems/search-in-a-sorted-array-of-unknown-size "搜索长度未知的有序数组") -

    Given an integer array sorted in ascending order, write a function to search target in nums.  If target exists, then return its index, otherwise return -1. However, the array size is unknown to you. You may only access the array using an ArrayReader interface, where ArrayReader.get(k) returns the element of the array at index k (0-indexed).

    -

    You may assume all integers in the array are less than 10000, and if you access the array out of bounds, ArrayReader.get will return 2147483647.

    - -

     

    - -

    Example 1:

    - -
    Input: array = [-1,0,3,5,9,12], target = 9
    -Output: 4
    -Explanation: 9 exists in nums and its index is 4
    -
    - -

    Example 2:

    - -
    Input: array = [-1,0,3,5,9,12], target = 2
    -Output: -1
    -Explanation: 2 does not exist in nums so return -1
    - -

     

    - -

    Note:

    - -
      -
    1. You may assume that all elements in the array are unique.
    2. -
    3. The value of each element in the array will be in the range [-9999, 9999].
    4. -
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Interactive](../../tag/interactive/README.md)] ### Similar Questions 1. [Binary Search](../binary-search) (Easy) diff --git a/problems/search-suggestions-system/README.md b/problems/search-suggestions-system/README.md index 649512134..6190a1717 100644 --- a/problems/search-suggestions-system/README.md +++ b/problems/search-suggestions-system/README.md @@ -66,6 +66,8 @@ After typing mou, mous and mouse the system suggests ["mouse","mo ### Related Topics + [[Trie](../../tag/trie/README.md)] + [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/seat-reservation-manager/README.md b/problems/seat-reservation-manager/README.md index 506b4453a..44c1ac1ab 100644 --- a/problems/seat-reservation-manager/README.md +++ b/problems/seat-reservation-manager/README.md @@ -55,8 +55,8 @@ seatManager.unreserve(5); // Unreserve seat 5, so now the available seats are [5 ### Related Topics - [[Heap](../../tag/heap/README.md)] [[Design](../../tag/design/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/second-degree-follower/README.md b/problems/second-degree-follower/README.md index f8169a52a..010c65f7e 100644 --- a/problems/second-degree-follower/README.md +++ b/problems/second-degree-follower/README.md @@ -11,38 +11,7 @@ ## [614. Second Degree Follower (Medium)](https://leetcode.com/problems/second-degree-follower "二级关注者") -

    In facebook, there is a follow table with two columns: followee, follower.

    -

    Please write a sql query to get the amount of each follower’s follower if he/she has one.

    -

    For example:

    - -
    -+-------------+------------+
    -| followee    | follower   |
    -+-------------+------------+
    -|     A       |     B      |
    -|     B       |     C      |
    -|     B       |     D      |
    -|     D       |     E      |
    -+-------------+------------+
    -
    -should output: - -
    -+-------------+------------+
    -| follower    | num        |
    -+-------------+------------+
    -|     B       |  2         |
    -|     D       |  1         |
    -+-------------+------------+
    -
    -Explaination:
    -Both B and D exist in the follower list, when as a followee, B's follower is C and D, and D's follower is E. A does not exist in follower list. -

     

    - -

     

    -Note:
    -Followee would not follow himself/herself in all cases.
    -Please display the result in follower's alphabet order. -

     

    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/second-highest-salary/README.md b/problems/second-highest-salary/README.md index 110115975..6f9a61f07 100644 --- a/problems/second-highest-salary/README.md +++ b/problems/second-highest-salary/README.md @@ -32,3 +32,6 @@ | 200 | +---------------------+ + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/second-largest-digit-in-a-string/README.md b/problems/second-largest-digit-in-a-string/README.md index a25119347..458d94a57 100644 --- a/problems/second-largest-digit-in-a-string/README.md +++ b/problems/second-largest-digit-in-a-string/README.md @@ -41,6 +41,7 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/second-minimum-node-in-a-binary-tree/README.md b/problems/second-minimum-node-in-a-binary-tree/README.md index db820fa4f..7118b46e6 100644 --- a/problems/second-minimum-node-in-a-binary-tree/README.md +++ b/problems/second-minimum-node-in-a-binary-tree/README.md @@ -47,6 +47,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Kth Smallest Element in a BST](../kth-smallest-element-in-a-bst) (Medium) diff --git a/problems/self-crossing/README.md b/problems/self-crossing/README.md index d05b7ca32..fdf7c5d0b 100644 --- a/problems/self-crossing/README.md +++ b/problems/self-crossing/README.md @@ -48,4 +48,6 @@ ### Related Topics + [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/sell-diminishing-valued-colored-balls/README.md b/problems/sell-diminishing-valued-colored-balls/README.md index ae1042150..cfcb4112b 100644 --- a/problems/sell-diminishing-valued-colored-balls/README.md +++ b/problems/sell-diminishing-valued-colored-balls/README.md @@ -64,8 +64,11 @@ The maximum total value is 3 + 2 + 5 + 4 + 3 + 2 = 19. ### Related Topics [[Greedy](../../tag/greedy/README.md)] - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/sellers-with-no-sales/README.md b/problems/sellers-with-no-sales/README.md index 474ea37d3..a8c20c883 100644 --- a/problems/sellers-with-no-sales/README.md +++ b/problems/sellers-with-no-sales/README.md @@ -12,3 +12,6 @@ ## [1607. Sellers With No Sales (Easy)](https://leetcode.com/problems/sellers-with-no-sales "没有卖出的卖家") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/sentence-screen-fitting/README.md b/problems/sentence-screen-fitting/README.md index e1f7c07d7..7f7fafc94 100644 --- a/problems/sentence-screen-fitting/README.md +++ b/problems/sentence-screen-fitting/README.md @@ -11,73 +11,8 @@ ## [418. Sentence Screen Fitting (Medium)](https://leetcode.com/problems/sentence-screen-fitting "屏幕可显示句子的数量") -

    Given a rows x cols screen and a sentence represented by a list of non-empty words, find how many times the given sentence can be fitted on the screen. -

    -

    Note: -

      -
    1. A word cannot be split into two lines.
    2. -
    3. The order of words in the sentence must remain unchanged.
    4. -
    5. Two consecutive words in a line must be separated by a single space.
    6. -
    7. Total words in the sentence won't exceed 100.
    8. -
    9. Length of each word is greater than 0 and won't exceed 10.
    10. -
    11. 1 ≤ rows, cols ≤ 20,000.
    12. -
    -

    - -

    -Example 1: -

    -Input:
    -rows = 2, cols = 8, sentence = ["hello", "world"]
    -
    -Output: 
    -1
    -
    -Explanation:
    -hello---
    -world---
    -
    -The character '-' signifies an empty space on the screen.
    -
    -

    - -

    -Example 2: -

    -Input:
    -rows = 3, cols = 6, sentence = ["a", "bcd", "e"]
    -
    -Output: 
    -2
    -
    -Explanation:
    -a-bcd- 
    -e-a---
    -bcd-e-
    -
    -The character '-' signifies an empty space on the screen.
    -
    -

    - -

    -Example 3: -

    -Input:
    -rows = 4, cols = 5, sentence = ["I", "had", "apple", "pie"]
    -
    -Output: 
    -1
    -
    -Explanation:
    -I-had
    -apple
    -pie-I
    -had--
    -
    -The character '-' signifies an empty space on the screen.
    -
    -

    ### Related Topics + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/sentence-similarity-ii/README.md b/problems/sentence-similarity-ii/README.md index 3ff5d9691..3defd9027 100644 --- a/problems/sentence-similarity-ii/README.md +++ b/problems/sentence-similarity-ii/README.md @@ -11,32 +11,15 @@ ## [737. Sentence Similarity II (Medium)](https://leetcode.com/problems/sentence-similarity-ii "句子相似性 II") -

    Given two sentences words1, words2 (each represented as an array of strings), and a list of similar word pairs pairs, determine if two sentences are similar.

    -

    For example, words1 = ["great", "acting", "skills"] and words2 = ["fine", "drama", "talent"] are similar, if the similar word pairs are pairs = [["great", "good"], ["fine", "good"], ["acting","drama"], ["skills","talent"]].

    - -

    Note that the similarity relation is transitive. For example, if "great" and "good" are similar, and "fine" and "good" are similar, then "great" and "fine" are similar.

    - -

    Similarity is also symmetric. For example, "great" and "fine" being similar is the same as "fine" and "great" being similar.

    - -

    Also, a word is always similar with itself. For example, the sentences words1 = ["great"], words2 = ["great"], pairs = [] are similar, even though there are no specified similar word pairs.

    - -

    Finally, sentences can only be similar if they have the same number of words. So a sentence like words1 = ["great"] can never be similar to words2 = ["doubleplus","good"].

    - -

    Note:

    - -
      -
    • The length of words1 and words2 will not exceed 1000.
    • -
    • The length of pairs will not exceed 2000.
    • -
    • The length of each pairs[i] will be 2.
    • -
    • The length of each words[i] and pairs[i][j] will be in the range [1, 20].
    • -
    - -

     

    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Number of Provinces](../number-of-provinces) (Medium) diff --git a/problems/sentence-similarity-iii/README.md b/problems/sentence-similarity-iii/README.md index c31a6332f..1adf040d6 100644 --- a/problems/sentence-similarity-iii/README.md +++ b/problems/sentence-similarity-iii/README.md @@ -59,6 +59,8 @@ ### Related Topics + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/sentence-similarity/README.md b/problems/sentence-similarity/README.md index 4b4c47156..d01463178 100644 --- a/problems/sentence-similarity/README.md +++ b/problems/sentence-similarity/README.md @@ -11,31 +11,12 @@ ## [734. Sentence Similarity (Easy)](https://leetcode.com/problems/sentence-similarity "句子相似性") -

    Given two sentences words1, words2 (each represented as an array of strings), and a list of similar word pairs pairs, determine if two sentences are similar.

    -

    For example, "great acting skills" and "fine drama talent" are similar, if the similar word pairs are pairs = [["great", "fine"], ["acting","drama"], ["skills","talent"]].

    - -

    Note that the similarity relation is not transitive. For example, if "great" and "fine" are similar, and "fine" and "good" are similar, "great" and "good" are not necessarily similar.

    - -

    However, similarity is symmetric. For example, "great" and "fine" being similar is the same as "fine" and "great" being similar.

    - -

    Also, a word is always similar with itself. For example, the sentences words1 = ["great"], words2 = ["great"], pairs = [] are similar, even though there are no specified similar word pairs.

    - -

    Finally, sentences can only be similar if they have the same number of words. So a sentence like words1 = ["great"] can never be similar to words2 = ["doubleplus","good"].

    - -

    Note:

    - -
      -
    • The length of words1 and words2 will not exceed 1000.
    • -
    • The length of pairs will not exceed 2000.
    • -
    • The length of each pairs[i] will be 2.
    • -
    • The length of each words[i] and pairs[i][j] will be in the range [1, 20].
    • -
    - -

     

    ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Number of Provinces](../number-of-provinces) (Medium) diff --git a/problems/sequence-reconstruction/README.md b/problems/sequence-reconstruction/README.md index e7af72214..b8f1627ad 100644 --- a/problems/sequence-reconstruction/README.md +++ b/problems/sequence-reconstruction/README.md @@ -11,65 +11,12 @@ ## [444. Sequence Reconstruction (Medium)](https://leetcode.com/problems/sequence-reconstruction "序列重建") -

    Check whether the original sequence org can be uniquely reconstructed from the sequences in seqs. The org sequence is a permutation of the integers from 1 to n, with 1 ≤ n ≤ 104. Reconstruction means building a shortest common supersequence of the sequences in seqs (i.e., a shortest sequence so that all sequences in seqs are subsequences of it). Determine whether there is only one sequence that can be reconstructed from seqs and it is the org sequence.

    -

    Example 1: -

    -Input:
    -org: [1,2,3], seqs: [[1,2],[1,3]]
    -
    -Output:
    -false
    -
    -Explanation:
    -[1,2,3] is not the only one sequence that can be reconstructed, because [1,3,2] is also a valid sequence that can be reconstructed.
    -
    -

    - -

    Example 2: -

    -Input:
    -org: [1,2,3], seqs: [[1,2]]
    -
    -Output:
    -false
    -
    -Explanation:
    -The reconstructed sequence can only be [1,2].
    -
    -

    - -

    Example 3: -

    -Input:
    -org: [1,2,3], seqs: [[1,2],[1,3],[2,3]]
    -
    -Output:
    -true
    -
    -Explanation:
    -The sequences [1,2], [1,3], and [2,3] can uniquely reconstruct the original sequence [1,2,3].
    -
    -

    - -

    Example 4: -

    -Input:
    -org: [4,1,5,2,6,3], seqs: [[5,2,6,3],[4,1,5,2]]
    -
    -Output:
    -true
    -
    -

    - -

    -UPDATE (2017/1/8):
    -The seqs parameter had been changed to a list of list of strings (instead of a 2d array of strings). Please reload the code definition to get the latest changes. -

    ### Related Topics [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions 1. [Course Schedule II](../course-schedule-ii) (Medium) diff --git a/problems/sequential-digits/README.md b/problems/sequential-digits/README.md index e3d92686a..079552bd4 100644 --- a/problems/sequential-digits/README.md +++ b/problems/sequential-digits/README.md @@ -31,7 +31,7 @@ ### Related Topics - [[Backtracking](../../tag/backtracking/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] ### Hints
    diff --git a/problems/serialize-and-deserialize-binary-tree/README.md b/problems/serialize-and-deserialize-binary-tree/README.md index ad5e175a0..8e0772a1f 100644 --- a/problems/serialize-and-deserialize-binary-tree/README.md +++ b/problems/serialize-and-deserialize-binary-tree/README.md @@ -56,7 +56,11 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Design](../../tag/design/README.md)] + [[String](../../tag/string/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Encode and Decode Strings](../encode-and-decode-strings) (Medium) diff --git a/problems/serialize-and-deserialize-bst/README.md b/problems/serialize-and-deserialize-bst/README.md index 0615a42a6..806fb28dd 100644 --- a/problems/serialize-and-deserialize-bst/README.md +++ b/problems/serialize-and-deserialize-bst/README.md @@ -36,6 +36,12 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Design](../../tag/design/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[String](../../tag/string/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Serialize and Deserialize Binary Tree](../serialize-and-deserialize-binary-tree) (Hard) diff --git a/problems/serialize-and-deserialize-n-ary-tree/README.md b/problems/serialize-and-deserialize-n-ary-tree/README.md index cb66a80a8..b2fea9d5d 100644 --- a/problems/serialize-and-deserialize-n-ary-tree/README.md +++ b/problems/serialize-and-deserialize-n-ary-tree/README.md @@ -11,31 +11,13 @@ ## [428. Serialize and Deserialize N-ary Tree (Hard)](https://leetcode.com/problems/serialize-and-deserialize-n-ary-tree "序列化和反序列化 N 叉树") -

    Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment.

    -

    Design an algorithm to serialize and deserialize an N-ary tree. An N-ary tree is a rooted tree in which each node has no more than N children. There is no restriction on how your serialization/deserialization algorithm should work. You just need to ensure that an N-ary tree can be serialized to a string and this string can be deserialized to the original tree structure.

    - -

    For example, you may serialize the following 3-ary tree

    - -

     

    - -

    - -

     

    - -

    as [1 [3[5 6] 2 4]]. You do not necessarily need to follow this format, so please be creative and come up with different approaches yourself.

    - -

     

    - -

    Note:

    - -
      -
    1. N is in the range of [1, 1000]
    2. -
    3. Do not use class member/global/static variables to store states. Your serialize and deserialize algorithms should be stateless.
    4. -
    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Serialize and Deserialize Binary Tree](../serialize-and-deserialize-binary-tree) (Hard) diff --git a/problems/set-intersection-size-at-least-two/README.md b/problems/set-intersection-size-at-least-two/README.md index 384ab268f..948d7ff0a 100644 --- a/problems/set-intersection-size-at-least-two/README.md +++ b/problems/set-intersection-size-at-least-two/README.md @@ -45,3 +45,5 @@ Thus, we output the size of this set, which is 3. ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/set-matrix-zeroes/README.md b/problems/set-matrix-zeroes/README.md index b49f3ce85..23d6d68ea 100644 --- a/problems/set-matrix-zeroes/README.md +++ b/problems/set-matrix-zeroes/README.md @@ -11,15 +11,9 @@ ## [73. Set Matrix Zeroes (Medium)](https://leetcode.com/problems/set-matrix-zeroes "矩阵置零") -

    Given an m x n matrix. If an element is 0, set its entire row and column to 0. Do it in-place.

    +

    Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's, and return the matrix.

    -

    Follow up:

    - -
      -
    • A straight forward solution using O(mn) space is probably a bad idea.
    • -
    • A simple improvement uses O(m + n) space, but still not the best solution.
    • -
    • Could you devise a constant space solution?
    • -
    +

    You must do it in place.

     

    Example 1:

    @@ -46,8 +40,19 @@
  • -231 <= matrix[i][j] <= 231 - 1
  • +

     

    +

    Follow up:

    + +
      +
    • A straight forward solution using O(mn) space is probably a bad idea.
    • +
    • A simple improvement uses O(m + n) space, but still not the best solution.
    • +
    • Could you devise a constant space solution?
    • +
    + ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Game of Life](../game-of-life) (Medium) diff --git a/problems/set-mismatch/README.md b/problems/set-mismatch/README.md index 9b96464a9..1186eb92f 100644 --- a/problems/set-mismatch/README.md +++ b/problems/set-mismatch/README.md @@ -34,8 +34,10 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Math](../../tag/math/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Find the Duplicate Number](../find-the-duplicate-number) (Medium) diff --git a/problems/shift-2d-grid/README.md b/problems/shift-2d-grid/README.md index 5d3f2674d..2e724740e 100644 --- a/problems/shift-2d-grid/README.md +++ b/problems/shift-2d-grid/README.md @@ -59,6 +59,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/shifting-letters/README.md b/problems/shifting-letters/README.md index 11bd34211..6698b4f2c 100644 --- a/problems/shifting-letters/README.md +++ b/problems/shifting-letters/README.md @@ -41,4 +41,5 @@ After shifting the first 3 letters of S by 9, we have "rpl", the answe ### Related Topics + [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/shopping-offers/README.md b/problems/shopping-offers/README.md index c23e5bf8f..4eb605968 100644 --- a/problems/shopping-offers/README.md +++ b/problems/shopping-offers/README.md @@ -57,5 +57,9 @@ You cannot add more items, though only $9 for 2A ,2B and 1C. ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] diff --git a/problems/short-encoding-of-words/README.md b/problems/short-encoding-of-words/README.md index 319b94133..5ef2d5a74 100644 --- a/problems/short-encoding-of-words/README.md +++ b/problems/short-encoding-of-words/README.md @@ -49,3 +49,9 @@ words[2] = "bell", the substring of s starting from indices[2] = 5 to
  • 1 <= words[i].length <= 7
  • words[i] consists of only lowercase letters.
  • + +### Related Topics + [[Trie](../../tag/trie/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/shortest-bridge/README.md b/problems/shortest-bridge/README.md index 73e3b5ec4..c99a6492f 100644 --- a/problems/shortest-bridge/README.md +++ b/problems/shortest-bridge/README.md @@ -48,5 +48,7 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/shortest-common-supersequence/README.md b/problems/shortest-common-supersequence/README.md index 21f17617a..9449b1ef7 100644 --- a/problems/shortest-common-supersequence/README.md +++ b/problems/shortest-common-supersequence/README.md @@ -38,6 +38,7 @@ The answer provided is the shortest such string that satisfies these properties. ### Related Topics + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/shortest-completing-word/README.md b/problems/shortest-completing-word/README.md index 133d351f9..11e367461 100644 --- a/problems/shortest-completing-word/README.md +++ b/problems/shortest-completing-word/README.md @@ -75,6 +75,7 @@ Since "steps" is the only word containing all the letters, that is the ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/shortest-distance-from-all-buildings/README.md b/problems/shortest-distance-from-all-buildings/README.md index fc39bd92a..0a986a223 100644 --- a/problems/shortest-distance-from-all-buildings/README.md +++ b/problems/shortest-distance-from-all-buildings/README.md @@ -11,36 +11,12 @@ ## [317. Shortest Distance from All Buildings (Hard)](https://leetcode.com/problems/shortest-distance-from-all-buildings "离建筑物最近的距离") -

    You want to build a house on an empty land which reaches all buildings in the shortest amount of distance. You can only move up, down, left and right. You are given a 2D grid of values 0, 1 or 2, where:

    -
      -
    • Each 0 marks an empty land which you can pass by freely.
    • -
    • Each 1 marks a building which you cannot pass through.
    • -
    • Each 2 marks an obstacle which you cannot pass through.
    • -
    - -

    Example:

    - -
    -Input: [[1,0,2,0,1],[0,0,0,0,0],[0,0,1,0,0]]
    -
    -1 - 0 - 2 - 0 - 1
    -|   |   |   |   |
    -0 - 0 - 0 - 0 - 0
    -|   |   |   |   |
    -0 - 0 - 1 - 0 - 0
    -
    -Output: 7 
    -
    -Explanation: Given three buildings at (0,0), (0,4), (2,2), and an obstacle at (0,2),
    -             the point (1,2) is an ideal empty land to build a house, as the total 
    -             travel distance of 3+3+1=7 is minimal. So return 7.
    - -

    Note:
    -There will be at least one building. If it is not possible to build such house according to the above rules, return -1.

    ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Walls and Gates](../walls-and-gates) (Medium) diff --git a/problems/shortest-distance-in-a-line/README.md b/problems/shortest-distance-in-a-line/README.md index e81181f78..fb0d985d0 100644 --- a/problems/shortest-distance-in-a-line/README.md +++ b/problems/shortest-distance-in-a-line/README.md @@ -11,35 +11,7 @@ ## [613. Shortest Distance in a Line (Easy)](https://leetcode.com/problems/shortest-distance-in-a-line "直线上的最近距离") -Table point holds the x coordinate of some points on x-axis in a plane, which are all integers. -

     

    -Write a query to find the shortest distance between two points in these points. -

     

    -
    -| x   |
    -|-----|
    -| -1  |
    -| 0   |
    -| 2   |
    -
    - -

     

    -The shortest distance is '1' obviously, which is from point '-1' to '0'. So the output is as below: - -

     

    - -
    -| shortest|
    -|---------|
    -| 1       |
    -
    - -

     

    -Note: Every point is unique, which means there is no duplicates in table point. - -

     

    -Follow-up: What if all these points have an id and are arranged from the left most to the right most of x axis? - -

     

    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/shortest-distance-in-a-plane/README.md b/problems/shortest-distance-in-a-plane/README.md index aabfdb2ba..f5ba847a6 100644 --- a/problems/shortest-distance-in-a-plane/README.md +++ b/problems/shortest-distance-in-a-plane/README.md @@ -11,32 +11,7 @@ ## [612. Shortest Distance in a Plane (Medium)](https://leetcode.com/problems/shortest-distance-in-a-plane "平面上的最近距离") -Table point_2d holds the coordinates (x,y) of some unique points (more than two) in a plane. -

     

    -Write a query to find the shortest distance between these points rounded to 2 decimals. -

     

    -
    -| x  | y  |
    -|----|----|
    -| -1 | -1 |
    -| 0  | 0  |
    -| -1 | -2 |
    -
    - -

     

    -The shortest distance is 1.00 from point (-1,-1) to (-1,2). So the output should be: - -

     

    - -
    -| shortest |
    -|----------|
    -| 1.00     |
    -
    - -

     

    -Note: The longest distance among all the points are less than 10000. - -

     

    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/shortest-distance-to-a-character/README.md b/problems/shortest-distance-to-a-character/README.md index 0406ae171..c02b2d68d 100644 --- a/problems/shortest-distance-to-a-character/README.md +++ b/problems/shortest-distance-to-a-character/README.md @@ -43,3 +43,8 @@ The closest occurrence of 'e' for index 8 is at index 6, so the distance
  • s[i] and c are lowercase English letters.
  • It is guaranteed that c occurs at least once in s.
  • + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/shortest-distance-to-target-color/README.md b/problems/shortest-distance-to-target-color/README.md index dc9d88932..1d77abc52 100644 --- a/problems/shortest-distance-to-target-color/README.md +++ b/problems/shortest-distance-to-target-color/README.md @@ -11,44 +11,12 @@ ## [1182. Shortest Distance to Target Color (Medium)](https://leetcode.com/problems/shortest-distance-to-target-color "与目标颜色间的最短距离") -

    You are given an array colors, in which there are three colors: 1, 2 and 3.

    -

    You are also given some queries. Each query consists of two integers i and c, return the shortest distance between the given index i and the target color c. If there is no solution return -1.

    - -

     

    -

    Example 1:

    - -
    -Input: colors = [1,1,2,1,3,2,2,3,3], queries = [[1,3],[2,2],[6,1]]
    -Output: [3,0,3]
    -Explanation: 
    -The nearest 3 from index 1 is at index 4 (3 steps away).
    -The nearest 2 from index 2 is at index 2 itself (0 steps away).
    -The nearest 1 from index 6 is at index 3 (3 steps away).
    -
    - -

    Example 2:

    - -
    -Input: colors = [1,2], queries = [[0,3]]
    -Output: [-1]
    -Explanation: There is no 3 in the array.
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= colors.length <= 5*10^4
    • -
    • 1 <= colors[i] <= 3
    • -
    • 1 <= queries.length <= 5*10^4
    • -
    • queries[i].length == 2
    • -
    • 0 <= queries[i][0] < colors.length
    • -
    • 1 <= queries[i][1] <= 3
    • -
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/shortest-palindrome/README.md b/problems/shortest-palindrome/README.md index fdb318268..28f4df0e1 100644 --- a/problems/shortest-palindrome/README.md +++ b/problems/shortest-palindrome/README.md @@ -33,6 +33,9 @@ ### Related Topics [[String](../../tag/string/README.md)] + [[String Matching](../../tag/string-matching/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Similar Questions 1. [Longest Palindromic Substring](../longest-palindromic-substring) (Medium) diff --git a/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md b/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md index 8b4f60995..4b5240fc3 100644 --- a/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md +++ b/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md @@ -62,7 +62,9 @@ k = 1 ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/shortest-path-in-a-hidden-grid/README.md b/problems/shortest-path-in-a-hidden-grid/README.md index 791e8ad3f..71950dd1b 100644 --- a/problems/shortest-path-in-a-hidden-grid/README.md +++ b/problems/shortest-path-in-a-hidden-grid/README.md @@ -14,9 +14,10 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] + [[Interactive](../../tag/interactive/README.md)] ### Hints
    diff --git a/problems/shortest-path-in-binary-matrix/README.md b/problems/shortest-path-in-binary-matrix/README.md index 2ebb3f0e8..45bb40cc7 100644 --- a/problems/shortest-path-in-binary-matrix/README.md +++ b/problems/shortest-path-in-binary-matrix/README.md @@ -55,7 +55,9 @@ ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/shortest-path-to-get-all-keys/README.md b/problems/shortest-path-to-get-all-keys/README.md index cd6411533..8cd4067e8 100644 --- a/problems/shortest-path-to-get-all-keys/README.md +++ b/problems/shortest-path-to-get-all-keys/README.md @@ -51,5 +51,5 @@
    ### Related Topics - [[Heap](../../tag/heap/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/shortest-path-to-get-food/README.md b/problems/shortest-path-to-get-food/README.md index 770c6f720..602173318 100644 --- a/problems/shortest-path-to-get-food/README.md +++ b/problems/shortest-path-to-get-food/README.md @@ -14,9 +14,9 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] - [[Graph](../../tag/graph/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/shortest-path-visiting-all-nodes/README.md b/problems/shortest-path-visiting-all-nodes/README.md index 656f55960..77c4a02d2 100644 --- a/problems/shortest-path-visiting-all-nodes/README.md +++ b/problems/shortest-path-visiting-all-nodes/README.md @@ -45,5 +45,8 @@ ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] diff --git a/problems/shortest-path-with-alternating-colors/README.md b/problems/shortest-path-with-alternating-colors/README.md index 1d43b3d73..3c2ac776e 100644 --- a/problems/shortest-path-with-alternating-colors/README.md +++ b/problems/shortest-path-with-alternating-colors/README.md @@ -46,7 +46,7 @@ ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] ### Hints diff --git a/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md b/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md index 837fb5589..f16fe056d 100644 --- a/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md +++ b/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md @@ -58,8 +58,11 @@ Another correct solution is to remove the subarray [3,10,4]. ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints
    diff --git a/problems/shortest-subarray-with-sum-at-least-k/README.md b/problems/shortest-subarray-with-sum-at-least-k/README.md index 05bd036de..5a99e0dc5 100644 --- a/problems/shortest-subarray-with-sum-at-least-k/README.md +++ b/problems/shortest-subarray-with-sum-at-least-k/README.md @@ -59,4 +59,9 @@ ### Related Topics [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/shortest-unsorted-continuous-subarray/README.md b/problems/shortest-unsorted-continuous-subarray/README.md index 3bf01a5d0..0d387f824 100644 --- a/problems/shortest-unsorted-continuous-subarray/README.md +++ b/problems/shortest-unsorted-continuous-subarray/README.md @@ -50,4 +50,9 @@ Follow up: Can you solve it in O(n) time complexity? ### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] diff --git a/problems/shortest-way-to-form-string/README.md b/problems/shortest-way-to-form-string/README.md index 592d2ca7e..87df1c3dd 100644 --- a/problems/shortest-way-to-form-string/README.md +++ b/problems/shortest-way-to-form-string/README.md @@ -11,47 +11,11 @@ ## [1055. Shortest Way to Form String (Medium)](https://leetcode.com/problems/shortest-way-to-form-string "形成字符串的最短路径") -

    From any string, we can form a subsequence of that string by deleting some number of characters (possibly no deletions).

    -

    Given two strings source and target, return the minimum number of subsequences of source such that their concatenation equals target. If the task is impossible, return -1.

    - -

     

    - -

    Example 1:

    - -
    -Input: source = "abc", target = "abcbc"
    -Output: 2
    -Explanation: The target "abcbc" can be formed by "abc" and "bc", which are subsequences of source "abc".
    -
    - -

    Example 2:

    - -
    -Input: source = "abc", target = "acdbc"
    -Output: -1
    -Explanation: The target string cannot be constructed from the subsequences of source string due to the character "d" in target string.
    -
    - -

    Example 3:

    - -
    -Input: source = "xyz", target = "xzyxz"
    -Output: 3
    -Explanation: The target string can be constructed as follows "xz" + "y" + "xz".
    -
    - -

     

    - -

    Note:

    - -
      -
    1. Both the source and target strings consist of only lowercase English letters from "a"-"z".
    2. -
    3. The lengths of source and target string are between 1 and 1000.
    4. -
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/shortest-word-distance-ii/README.md b/problems/shortest-word-distance-ii/README.md index ece760c67..84ef2aea5 100644 --- a/problems/shortest-word-distance-ii/README.md +++ b/problems/shortest-word-distance-ii/README.md @@ -11,24 +11,14 @@ ## [244. Shortest Word Distance II (Medium)](https://leetcode.com/problems/shortest-word-distance-ii "最短单词距离 II") -

    Design a class which receives a list of words in the constructor, and implements a method that takes two words word1 and word2 and return the shortest distance between these two words in the list. Your method will be called repeatedly many times with different parameters. 

    -

    Example:
    -Assume that words = ["practice", "makes", "perfect", "coding", "makes"].

    - -
    Input: word1 = “coding”, word2 = “practice”
    -Output: 3
    -
    - -
    Input: word1 = "makes", word2 = "coding"
    -Output: 1
    - -

    Note:
    -You may assume that word1 does not equal to word2, and word1 and word2 are both in the list.

    ### Related Topics [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Merge Two Sorted Lists](../merge-two-sorted-lists) (Easy) diff --git a/problems/shortest-word-distance-iii/README.md b/problems/shortest-word-distance-iii/README.md index de413094c..8b1ecc47f 100644 --- a/problems/shortest-word-distance-iii/README.md +++ b/problems/shortest-word-distance-iii/README.md @@ -11,28 +11,11 @@ ## [245. Shortest Word Distance III (Medium)](https://leetcode.com/problems/shortest-word-distance-iii "最短单词距离 III") -

    Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.

    -

    word1 and word2 may be the same and they represent two individual words in the list.

    - -

    Example:
    -Assume that words = ["practice", "makes", "perfect", "coding", "makes"].

    - -
    -Input: word1 = “makes”, word2 = “coding”
    -Output: 1
    -
    - -
    -Input: word1 = "makes", word2 = "makes"
    -Output: 3
    -
    - -

    Note:
    -You may assume word1 and word2 are both in the list.

    ### Related Topics [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Shortest Word Distance](../shortest-word-distance) (Easy) diff --git a/problems/shortest-word-distance/README.md b/problems/shortest-word-distance/README.md index 5523931ee..f394887b6 100644 --- a/problems/shortest-word-distance/README.md +++ b/problems/shortest-word-distance/README.md @@ -11,26 +11,11 @@ ## [243. Shortest Word Distance (Easy)](https://leetcode.com/problems/shortest-word-distance "最短单词距离") -

    Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.

    -

    Example:
    -Assume that words = ["practice", "makes", "perfect", "coding", "makes"].

    - -
    -Input: word1 = “coding”, word2 = “practice”
    -Output: 3
    -
    - -
    -Input: word1 = "makes", word2 = "coding"
    -Output: 1
    -
    - -

    Note:
    -You may assume that word1 does not equal to word2, and word1 and word2 are both in the list.

    ### Related Topics [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Shortest Word Distance II](../shortest-word-distance-ii) (Medium) diff --git a/problems/shuffle-an-array/README.md b/problems/shuffle-an-array/README.md index b8383b48c..88c5dd8b1 100644 --- a/problems/shuffle-an-array/README.md +++ b/problems/shuffle-an-array/README.md @@ -11,7 +11,7 @@ ## [384. Shuffle an Array (Medium)](https://leetcode.com/problems/shuffle-an-array "打乱数组") -

    Given an integer array nums, design an algorithm to randomly shuffle the array.

    +

    Given an integer array nums, design an algorithm to randomly shuffle the array. All permutations of the array should be equally likely as a result of the shuffling.

    Implement the Solution class:

    @@ -33,7 +33,9 @@ Explanation Solution solution = new Solution([1, 2, 3]); -solution.shuffle(); // Shuffle the array [1,2,3] and return its result. Any permutation of [1,2,3] must be equally likely to be returned. Example: return [3, 1, 2] +solution.shuffle(); // Shuffle the array [1,2,3] and return its result. + // Any permutation of [1,2,3] must be equally likely to be returned. + // Example: return [3, 1, 2] solution.reset(); // Resets the array back to its original configuration [1,2,3]. Return [1, 2, 3] solution.shuffle(); // Returns the random shuffling of array [1,2,3]. Example: return [1, 3, 2] @@ -46,9 +48,14 @@ solution.shuffle(); // Returns the random shuffling of array [1,2,3]. Example
  • 1 <= nums.length <= 200
  • -106 <= nums[i] <= 106
  • All the elements of nums are unique.
  • -
  • At most 5 * 104 calls will be made to reset and shuffle.
  • +
  • At most 5 * 104 calls in total will be made to reset and shuffle.
  • +### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Randomized](../../tag/randomized/README.md)] + ### Hints
    Hint 1 diff --git a/problems/shuffle-string/README.md b/problems/shuffle-string/README.md index 135df9d15..197004674 100644 --- a/problems/shuffle-string/README.md +++ b/problems/shuffle-string/README.md @@ -67,7 +67,8 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/sign-of-the-product-of-an-array/README.md b/problems/sign-of-the-product-of-an-array/README.md index 9eb5a9e4f..6091454dd 100644 --- a/problems/sign-of-the-product-of-an-array/README.md +++ b/problems/sign-of-the-product-of-an-array/README.md @@ -57,6 +57,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] ### Hints diff --git a/problems/similar-rgb-color/README.md b/problems/similar-rgb-color/README.md index a70381508..f4e0110e7 100644 --- a/problems/similar-rgb-color/README.md +++ b/problems/similar-rgb-color/README.md @@ -11,32 +11,9 @@ ## [800. Similar RGB Color (Easy)](https://leetcode.com/problems/similar-rgb-color "相似 RGB 颜色") -

    In the following, every capital letter represents some hexadecimal digit from 0 to f.

    -

    The red-green-blue color "#AABBCC" can be written as "#ABC" in shorthand.  For example, "#15c" is shorthand for the color "#1155cc".

    - -

    Now, say the similarity between two colors "#ABCDEF" and "#UVWXYZ" is -(AB - UV)^2 - (CD - WX)^2 - (EF - YZ)^2.

    - -

    Given the color "#ABCDEF", return a 7 character color that is most similar to #ABCDEF, and has a shorthand (that is, it can be represented as some "#XYZ"

    - -
    -Example 1:
    -Input: color = "#09f166"
    -Output: "#11ee66"
    -Explanation:  
    -The similarity is -(0x09 - 0x11)^2 -(0xf1 - 0xee)^2 - (0x66 - 0x66)^2 = -64 -9 -0 = -73.
    -This is the highest among any shorthand color.
    -
    - -

    Note:

    - -
      -
    • color is a string of length 7.
    • -
    • color is a valid RGB color: for i > 0, color[i] is a hexadecimal digit from 0 to f
    • -
    • Any answer which has the same (highest) similarity as the best answer will be accepted.
    • -
    • All inputs and outputs should use lowercase letters, and the output is 7 characters.
    • -
    ### Related Topics [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] diff --git a/problems/similar-string-groups/README.md b/problems/similar-string-groups/README.md index 845237a23..a0c747ba5 100644 --- a/problems/similar-string-groups/README.md +++ b/problems/similar-string-groups/README.md @@ -45,6 +45,7 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Graph](../../tag/graph/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/single-element-in-a-sorted-array/README.md b/problems/single-element-in-a-sorted-array/README.md index a18a0b9db..19496af4f 100644 --- a/problems/single-element-in-a-sorted-array/README.md +++ b/problems/single-element-in-a-sorted-array/README.md @@ -32,4 +32,5 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/single-number-ii/README.md b/problems/single-number-ii/README.md index fcee4c20a..fa41c7517 100644 --- a/problems/single-number-ii/README.md +++ b/problems/single-number-ii/README.md @@ -34,6 +34,7 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions 1. [Single Number](../single-number) (Easy) diff --git a/problems/single-number-iii/README.md b/problems/single-number-iii/README.md index b0c846afe..e7daefd72 100644 --- a/problems/single-number-iii/README.md +++ b/problems/single-number-iii/README.md @@ -49,6 +49,7 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions 1. [Single Number](../single-number) (Easy) diff --git a/problems/single-number/README.md b/problems/single-number/README.md index b7b329f5c..29a154736 100644 --- a/problems/single-number/README.md +++ b/problems/single-number/README.md @@ -37,7 +37,7 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions 1. [Single Number II](../single-number-ii) (Medium) diff --git a/problems/single-row-keyboard/README.md b/problems/single-row-keyboard/README.md index d54f02d4d..ee579d29d 100644 --- a/problems/single-row-keyboard/README.md +++ b/problems/single-row-keyboard/README.md @@ -11,40 +11,10 @@ ## [1165. Single-Row Keyboard (Easy)](https://leetcode.com/problems/single-row-keyboard "单行键盘") -

    There is a special keyboard with all keys in a single row.

    -

    Given a string keyboard of length 26 indicating the layout of the keyboard (indexed from 0 to 25), initially your finger is at index 0. To type a character, you have to move your finger to the index of the desired character. The time taken to move your finger from index i to index j is |i - j|.

    - -

    You want to type a string word. Write a function to calculate how much time it takes to type it with one finger.

    - -

     

    -

    Example 1:

    - -
    -Input: keyboard = "abcdefghijklmnopqrstuvwxyz", word = "cba"
    -Output: 4
    -Explanation: The index moves from 0 to 2 to write 'c' then to 1 to write 'b' then to 0 again to write 'a'.
    -Total time = 2 + 1 + 1 = 4. 
    -
    - -

    Example 2:

    - -
    -Input: keyboard = "pqrstuvwxyzabcdefghijklmno", word = "leetcode"
    -Output: 73
    -
    - -

     

    -

    Constraints:

    - -
      -
    • keyboard.length == 26
    • -
    • keyboard contains each English lowercase letter exactly once in some order.
    • -
    • 1 <= word.length <= 10^4
    • -
    • word[i] is an English lowercase letter.
    • -
    ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/single-threaded-cpu/README.md b/problems/single-threaded-cpu/README.md index 7a83fa3cd..57b8e7761 100644 --- a/problems/single-threaded-cpu/README.md +++ b/problems/single-threaded-cpu/README.md @@ -67,7 +67,9 @@ ### Related Topics - [[Heap](../../tag/heap/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/sliding-puzzle/README.md b/problems/sliding-puzzle/README.md index f27971d81..d635f66ae 100644 --- a/problems/sliding-puzzle/README.md +++ b/problems/sliding-puzzle/README.md @@ -11,28 +11,31 @@ ## [773. Sliding Puzzle (Hard)](https://leetcode.com/problems/sliding-puzzle "滑动谜题") -

    On a 2x3 board, there are 5 tiles represented by the integers 1 through 5, and an empty square represented by 0.

    +

    On an 2 x 3 board, there are five tiles labeled from 1 to 5, and an empty square represented by 0. A move consists of choosing 0 and a 4-directionally adjacent number and swapping it.

    -

    A move consists of choosing 0 and a 4-directionally adjacent number and swapping it.

    +

    The state of the board is solved if and only if the board is [[1,2,3],[4,5,0]].

    -

    The state of the board is solved if and only if the board is [[1,2,3],[4,5,0]].

    - -

    Given a puzzle board, return the least number of moves required so that the state of the board is solved. If it is impossible for the state of the board to be solved, return -1.

    - -

    Examples:

    +

    Given the puzzle board board, return the least number of moves required so that the state of the board is solved. If it is impossible for the state of the board to be solved, return -1.

    +

     

    +

    Example 1:

    +
     Input: board = [[1,2,3],[4,0,5]]
     Output: 1
     Explanation: Swap the 0 and the 5 in one move.
     
    +

    Example 2:

    +
     Input: board = [[1,2,3],[5,4,0]]
     Output: -1
     Explanation: No number of moves will make the board solved.
     
    +

    Example 3:

    +
     Input: board = [[4,1,2],[5,0,3]]
     Output: 5
    @@ -46,20 +49,27 @@ After move 4: [[1,2,0],[4,5,3]]
     After move 5: [[1,2,3],[4,5,0]]
     
    +

    Example 4:

    +
     Input: board = [[3,2,4],[1,5,0]]
     Output: 14
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • board will be a 2 x 3 array as described above.
    • -
    • board[i][j] will be a permutation of [0, 1, 2, 3, 4, 5].
    • +
    • board.length == 2
    • +
    • board[i].length == 3
    • +
    • 0 <= board[i][j] <= 5
    • +
    • Each value board[i][j] is unique.
    ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/sliding-window-maximum/README.md b/problems/sliding-window-maximum/README.md index e454d6621..8958f8c30 100644 --- a/problems/sliding-window-maximum/README.md +++ b/problems/sliding-window-maximum/README.md @@ -70,8 +70,11 @@ Window position Max ### Related Topics - [[Heap](../../tag/heap/README.md)] + [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Minimum Window Substring](../minimum-window-substring) (Hard) diff --git a/problems/sliding-window-median/README.md b/problems/sliding-window-median/README.md index 498f08265..3b6027df7 100644 --- a/problems/sliding-window-median/README.md +++ b/problems/sliding-window-median/README.md @@ -55,7 +55,10 @@ Window position Median ### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Find Median from Data Stream](../find-median-from-data-stream) (Hard) diff --git a/problems/slowest-key/README.md b/problems/slowest-key/README.md index 42f86f821..a40c8a33e 100644 --- a/problems/slowest-key/README.md +++ b/problems/slowest-key/README.md @@ -63,6 +63,7 @@ The longest of these was the keypress for 'a' with duration 16. ### Related Topics [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/smallest-common-region/README.md b/problems/smallest-common-region/README.md index 065a79db2..a853c14b1 100644 --- a/problems/smallest-common-region/README.md +++ b/problems/smallest-common-region/README.md @@ -11,42 +11,15 @@ ## [1257. Smallest Common Region (Medium)](https://leetcode.com/problems/smallest-common-region "最小公共区域") -

    You are given some lists of regions where the first region of each list includes all other regions in that list.

    -

    Naturally, if a region X contains another region Y then X is bigger than Y.

    - -

    Given two regions region1, region2, find out the smallest region that contains both of them.

    - -

    If you are given regions r1, r2 and r3 such that r1 includes r3, it is guaranteed there is no r2 such that r2 includes r3.
    -
    -It's guaranteed the smallest region exists.

    - -

     

    -

    Example 1:

    - -
    -Input:
    -regions = [["Earth","North America","South America"],
    -["North America","United States","Canada"],
    -["United States","New York","Boston"],
    -["Canada","Ontario","Quebec"],
    -["South America","Brazil"]],
    -region1 = "Quebec",
    -region2 = "New York"
    -Output: "North America"
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 2 <= regions.length <= 10^4
    • -
    • region1 != region2
    • -
    • All strings consist of English letters and spaces with at most 20 letters.
    • -
    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Lowest Common Ancestor of a Binary Search Tree](../lowest-common-ancestor-of-a-binary-search-tree) (Easy) diff --git a/problems/smallest-integer-divisible-by-k/README.md b/problems/smallest-integer-divisible-by-k/README.md index 8c9942fa2..6c044bdf0 100644 --- a/problems/smallest-integer-divisible-by-k/README.md +++ b/problems/smallest-integer-divisible-by-k/README.md @@ -50,6 +50,7 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] ### Hints diff --git a/problems/smallest-range-covering-elements-from-k-lists/README.md b/problems/smallest-range-covering-elements-from-k-lists/README.md index 854759a9e..f0eef6e1d 100644 --- a/problems/smallest-range-covering-elements-from-k-lists/README.md +++ b/problems/smallest-range-covering-elements-from-k-lists/README.md @@ -67,6 +67,9 @@ List 3: [5, 18, 22, 30], 22 is in range [20,24]. ### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] - [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/smallest-range-i/README.md b/problems/smallest-range-i/README.md index ff6556910..39315189e 100644 --- a/problems/smallest-range-i/README.md +++ b/problems/smallest-range-i/README.md @@ -63,4 +63,5 @@
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/smallest-range-ii/README.md b/problems/smallest-range-ii/README.md index 82398defe..412b355ad 100644 --- a/problems/smallest-range-ii/README.md +++ b/problems/smallest-range-ii/README.md @@ -64,4 +64,6 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/smallest-rectangle-enclosing-black-pixels/README.md b/problems/smallest-rectangle-enclosing-black-pixels/README.md index 14d52bda0..c66c5abe9 100644 --- a/problems/smallest-rectangle-enclosing-black-pixels/README.md +++ b/problems/smallest-rectangle-enclosing-black-pixels/README.md @@ -11,21 +11,11 @@ ## [302. Smallest Rectangle Enclosing Black Pixels (Hard)](https://leetcode.com/problems/smallest-rectangle-enclosing-black-pixels "包含全部黑色像素的最小矩形") -

    An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black pixels are connected, i.e., there is only one black region. Pixels are connected horizontally and vertically. Given the location (x, y) of one of the black pixels, return the area of the smallest (axis-aligned) rectangle that encloses all black pixels.

    -

    Example:

    - -
    -Input:
    -[
    -  "0010",
    -  "0110",
    -  "0100"
    -]
    -and x = 0, y = 2
    -
    -Output: 6
    -
    ### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/smallest-rotation-with-highest-score/README.md b/problems/smallest-rotation-with-highest-score/README.md index f836ef9e5..7a586d48b 100644 --- a/problems/smallest-rotation-with-highest-score/README.md +++ b/problems/smallest-rotation-with-highest-score/README.md @@ -48,3 +48,7 @@ So we will choose the smallest k, which is 0.
  • nums will have length at most 20000.
  • nums[i] will be in the range [0, nums.length].
  • + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] diff --git a/problems/smallest-string-starting-from-leaf/README.md b/problems/smallest-string-starting-from-leaf/README.md index f50c6dcc5..0aad28275 100644 --- a/problems/smallest-string-starting-from-leaf/README.md +++ b/problems/smallest-string-starting-from-leaf/README.md @@ -70,7 +70,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[String](../../tag/string/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Sum Root to Leaf Numbers](../sum-root-to-leaf-numbers) (Medium) diff --git a/problems/smallest-string-with-a-given-numeric-value/README.md b/problems/smallest-string-with-a-given-numeric-value/README.md index de4f941b0..8763258c3 100644 --- a/problems/smallest-string-with-a-given-numeric-value/README.md +++ b/problems/smallest-string-with-a-given-numeric-value/README.md @@ -45,6 +45,7 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/smallest-string-with-swaps/README.md b/problems/smallest-string-with-swaps/README.md index b71a874f4..c137301b4 100644 --- a/problems/smallest-string-with-swaps/README.md +++ b/problems/smallest-string-with-swaps/README.md @@ -60,8 +60,11 @@ Swap s[0] and s[1], s = "abc" ### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/smallest-subsequence-of-distinct-characters/README.md b/problems/smallest-subsequence-of-distinct-characters/README.md index 9edaced6f..43c0c4660 100644 --- a/problems/smallest-subsequence-of-distinct-characters/README.md +++ b/problems/smallest-subsequence-of-distinct-characters/README.md @@ -42,6 +42,7 @@ [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints
    diff --git a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md index c12facba0..8c29362be 100644 --- a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md +++ b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md @@ -59,6 +59,7 @@ Notice that nodes 5, 3 and 2 contain the deepest nodes in the tree but node 2 is ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] - [[Recursion](../../tag/recursion/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/smallest-sufficient-team/README.md b/problems/smallest-sufficient-team/README.md index 57d33f517..cf1bd21ec 100644 --- a/problems/smallest-sufficient-team/README.md +++ b/problems/smallest-sufficient-team/README.md @@ -50,7 +50,9 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/snakes-and-ladders/README.md b/problems/snakes-and-ladders/README.md index 29051ae1d..ec54e4fac 100644 --- a/problems/snakes-and-ladders/README.md +++ b/problems/snakes-and-ladders/README.md @@ -11,57 +11,63 @@ ## [909. Snakes and Ladders (Medium)](https://leetcode.com/problems/snakes-and-ladders "蛇梯棋") -

    On an N x N board, the numbers from 1 to N*N are written boustrophedonically starting from the bottom left of the board, and alternating direction each row.  For example, for a 6 x 6 board, the numbers are written as follows:

    +

    You are given an n x n integer matrix board where the cells are labeled from 1 to n2 in a Boustrophedon style starting from the bottom left of the board (i.e. board[n - 1][0]) and alternating direction each row.

    -
    -
    -
    - -

    You start on square 1 of the board (which is always in the last row and first column).  Each move, starting from square x, consists of the following:

    +

    You start on square 1 of the board. In each move, starting from square curr, do the following:

      -
    • You choose a destination square S with number x+1, x+2, x+3, x+4, x+5, or x+6, provided this number is <= N*N. +
    • Choose a destination square next with a label in the range [curr + 1, min(curr + 6, n2)].
        -
      • (This choice simulates the result of a standard 6-sided die roll: ie., there are always at most 6 destinations, regardless of the size of the board.)
      • +
      • This choice simulates the result of a standard 6-sided die roll: i.e., there are always at most 6 destinations, regardless of the size of the board.
    • -
    • If S has a snake or ladder, you move to the destination of that snake or ladder.  Otherwise, you move to S.
    • +
    • If next has a snake or ladder, you must move to the destination of that snake or ladder. Otherwise, you move to next.
    • +
    • The game ends when you reach the square n2.
    -

    A board square on row r and column c has a "snake or ladder" if board[r][c] != -1.  The destination of that snake or ladder is board[r][c].

    +

    A board square on row r and column c has a snake or ladder if board[r][c] != -1. The destination of that snake or ladder is board[r][c]. Squares 1 and n2 do not have a snake or ladder.

    -

    Note that you only take a snake or ladder at most once per move: if the destination to a snake or ladder is the start of another snake or ladder, you do not continue moving.  (For example, if the board is `[[4,-1],[-1,3]]`, and on the first move your destination square is `2`, then you finish your first move at `3`, because you do not continue moving to `4`.)

    +

    Note that you only take a snake or ladder at most once per move. If the destination to a snake or ladder is the start of another snake or ladder, you do not follow the subsequent snake or ladder.

    -

    Return the least number of moves required to reach square N*N.  If it is not possible, return -1.

    +
      +
    • For example, suppose the board is [[-1,4],[-1,3]], and on the first move, your destination square is 2. You follow the ladder to square 3, but do not follow the subsequent ladder to 4.
    • +
    -

    Example 1:

    +

    Return the least number of moves required to reach the square n2. If it is not possible to reach the square, return -1.

    +

     

    +

    Example 1:

    +
    -Input: [
    -[-1,-1,-1,-1,-1,-1],
    -[-1,-1,-1,-1,-1,-1],
    -[-1,-1,-1,-1,-1,-1],
    -[-1,35,-1,-1,13,-1],
    -[-1,-1,-1,-1,-1,-1],
    -[-1,15,-1,-1,-1,-1]]
    -Output: 4
    -Explanation: 
    -At the beginning, you start at square 1 [at row 5, column 0].
    -You decide to move to square 2, and must take the ladder to square 15.
    -You then decide to move to square 17 (row 3, column 5), and must take the snake to square 13.
    -You then decide to move to square 14, and must take the ladder to square 35.
    +Input: board = [[-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1],[-1,35,-1,-1,13,-1],[-1,-1,-1,-1,-1,-1],[-1,15,-1,-1,-1,-1]]
    +Output: 4
    +Explanation: 
    +In the beginning, you start at square 1 (at row 5, column 0).
    +You decide to move to square 2 and must take the ladder to square 15.
    +You then decide to move to square 17 and must take the snake to square 13.
    +You then decide to move to square 14 and must take the ladder to square 35.
     You then decide to move to square 36, ending the game.
    -It can be shown that you need at least 4 moves to reach the N*N-th square, so the answer is 4.
    +This is the lowest possible number of moves to reach the last square, so return 4.
     
    -

    Note:

    +

    Example 2:

    -
      -
    1. 2 <= board.length = board[0].length <= 20
    2. -
    3. board[i][j] is between 1 and N*N or is equal to -1.
    4. -
    5. The board square with number 1 has no snake or ladder.
    6. -
    7. The board square with number N*N has no snake or ladder.
    8. -
    +
    +Input: board = [[-1,-1],[-1,3]]
    +Output: 1
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == board.length == board[i].length
    • +
    • 2 <= n <= 20
    • +
    • grid[i][j] is either -1 or in the range [1, n2].
    • +
    • The squares labeled 1 and n2 do not have any ladders or snakes.
    • +
    ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/snapshot-array/README.md b/problems/snapshot-array/README.md index 1dce59d35..b754c70a6 100644 --- a/problems/snapshot-array/README.md +++ b/problems/snapshot-array/README.md @@ -46,7 +46,10 @@ snapshotArr.get(0,0); // Get the value of array[0] with snap_id = 0, return 5 ### Related Topics + [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
    diff --git a/problems/solve-the-equation/README.md b/problems/solve-the-equation/README.md index 29d39be6e..15c84e9ab 100644 --- a/problems/solve-the-equation/README.md +++ b/problems/solve-the-equation/README.md @@ -43,6 +43,8 @@ ### Related Topics [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Similar Questions 1. [Fraction Addition and Subtraction](../fraction-addition-and-subtraction) (Medium) diff --git a/problems/sort-an-array/README.md b/problems/sort-an-array/README.md index 70fb0ae7b..defec3b25 100644 --- a/problems/sort-an-array/README.md +++ b/problems/sort-an-array/README.md @@ -28,3 +28,13 @@
  • 1 <= nums.length <= 5 * 104
  • -5 * 104 <= nums[i] <= 5 * 104
  • + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Bucket Sort](../../tag/bucket-sort/README.md)] + [[Counting Sort](../../tag/counting-sort/README.md)] + [[Radix Sort](../../tag/radix-sort/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Merge Sort](../../tag/merge-sort/README.md)] diff --git a/problems/sort-array-by-increasing-frequency/README.md b/problems/sort-array-by-increasing-frequency/README.md index 82ede2513..9c21983ff 100644 --- a/problems/sort-array-by-increasing-frequency/README.md +++ b/problems/sort-array-by-increasing-frequency/README.md @@ -47,8 +47,9 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/sort-array-by-parity-ii/README.md b/problems/sort-array-by-parity-ii/README.md index dfef11e55..4e89da7b4 100644 --- a/problems/sort-array-by-parity-ii/README.md +++ b/problems/sort-array-by-parity-ii/README.md @@ -47,5 +47,6 @@

    Follow Up: Could you solve it in-place?

    ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/sort-array-by-parity/README.md b/problems/sort-array-by-parity/README.md index c5803bf8a..deccd3bdc 100644 --- a/problems/sort-array-by-parity/README.md +++ b/problems/sort-array-by-parity/README.md @@ -38,3 +38,5 @@ The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be accepted. ### Related Topics [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/sort-characters-by-frequency/README.md b/problems/sort-characters-by-frequency/README.md index 7dcc66374..e33d946c7 100644 --- a/problems/sort-characters-by-frequency/README.md +++ b/problems/sort-characters-by-frequency/README.md @@ -50,8 +50,12 @@ Note that 'A' and 'a' are treated as two different characters. ### Related Topics - [[Heap](../../tag/heap/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Bucket Sort](../../tag/bucket-sort/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Top K Frequent Elements](../top-k-frequent-elements) (Medium) diff --git a/problems/sort-colors/README.md b/problems/sort-colors/README.md index 63d40821c..b5aed8325 100644 --- a/problems/sort-colors/README.md +++ b/problems/sort-colors/README.md @@ -44,9 +44,9 @@

    Follow up: Could you come up with a one-pass algorithm using only constant extra space?

    ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Sort List](../sort-list) (Medium) diff --git a/problems/sort-features-by-popularity/README.md b/problems/sort-features-by-popularity/README.md index e322bd8f1..fd38ba169 100644 --- a/problems/sort-features-by-popularity/README.md +++ b/problems/sort-features-by-popularity/README.md @@ -14,8 +14,10 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/sort-integers-by-the-number-of-1-bits/README.md b/problems/sort-integers-by-the-number-of-1-bits/README.md index b53b087bb..d9bca208a 100644 --- a/problems/sort-integers-by-the-number-of-1-bits/README.md +++ b/problems/sort-integers-by-the-number-of-1-bits/README.md @@ -66,8 +66,10 @@ The sorted array by bits is [0,1,2,4,8,3,5,6,7] ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/sort-integers-by-the-power-value/README.md b/problems/sort-integers-by-the-power-value/README.md index 2ef8484e8..5e0e1b88f 100644 --- a/problems/sort-integers-by-the-power-value/README.md +++ b/problems/sort-integers-by-the-power-value/README.md @@ -80,8 +80,9 @@ The fourth number in the sorted array is 7. ### Related Topics - [[Sort](../../tag/sort/README.md)] - [[Graph](../../tag/graph/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/sort-items-by-groups-respecting-dependencies/README.md b/problems/sort-items-by-groups-respecting-dependencies/README.md index c3b398a6b..b82eaa3cf 100644 --- a/problems/sort-items-by-groups-respecting-dependencies/README.md +++ b/problems/sort-items-by-groups-respecting-dependencies/README.md @@ -7,7 +7,7 @@ [< Previous](../smallest-string-with-swaps "Smallest String With Swaps")                  -[Next >](../last-person-to-fit-in-the-elevator "Last Person to Fit in the Elevator") +[Next >](../last-person-to-fit-in-the-bus "Last Person to Fit in the Bus") ## [1203. Sort Items by Groups Respecting Dependencies (Hard)](https://leetcode.com/problems/sort-items-by-groups-respecting-dependencies "项目管理") @@ -54,7 +54,8 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] diff --git a/problems/sort-list/README.md b/problems/sort-list/README.md index 799e978b5..123c2e962 100644 --- a/problems/sort-list/README.md +++ b/problems/sort-list/README.md @@ -46,8 +46,11 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Merge Sort](../../tag/merge-sort/README.md)] ### Similar Questions 1. [Merge Two Sorted Lists](../merge-two-sorted-lists) (Easy) diff --git a/problems/sort-the-matrix-diagonally/README.md b/problems/sort-the-matrix-diagonally/README.md index 00118b71e..de6bdde4e 100644 --- a/problems/sort-the-matrix-diagonally/README.md +++ b/problems/sort-the-matrix-diagonally/README.md @@ -41,8 +41,9 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/sort-transformed-array/README.md b/problems/sort-transformed-array/README.md index 5693c762d..d6c13c3e6 100644 --- a/problems/sort-transformed-array/README.md +++ b/problems/sort-transformed-array/README.md @@ -11,32 +11,13 @@ ## [360. Sort Transformed Array (Medium)](https://leetcode.com/problems/sort-transformed-array "有序转化数组") -

    Given a sorted array of integers nums and integer values a, b and c. Apply a quadratic function of the form f(x) = ax2 + bx + c to each element x in the array.

    -

    The returned array must be in sorted order.

    - -

    Expected time complexity: O(n)

    - -
    -

    Example 1:

    - -
    -Input: nums = [-4,-2,2,4], a = 1, b = 3, c = 5
    -Output: [3,9,15,33]
    -
    - -
    -

    Example 2:

    - -
    -Input: nums = [-4,-2,2,4], a = -1, b = 3, c = 5
    -Output: [-23,-5,1,7]
    -
    ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Squares of a Sorted Array](../squares-of-a-sorted-array) (Easy) diff --git a/problems/sorting-the-sentence/README.md b/problems/sorting-the-sentence/README.md index e6c2f41a6..5a48c1d7e 100644 --- a/problems/sorting-the-sentence/README.md +++ b/problems/sorting-the-sentence/README.md @@ -50,8 +50,8 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/soup-servings/README.md b/problems/soup-servings/README.md index 836692716..6d127ce38 100644 --- a/problems/soup-servings/README.md +++ b/problems/soup-servings/README.md @@ -45,4 +45,6 @@ If we choose the first two operations, A will become empty first. For the third ### Related Topics + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Probability and Statistics](../../tag/probability-and-statistics/README.md)] diff --git a/problems/sparse-matrix-multiplication/README.md b/problems/sparse-matrix-multiplication/README.md index 1cb5568f1..8060d4074 100644 --- a/problems/sparse-matrix-multiplication/README.md +++ b/problems/sparse-matrix-multiplication/README.md @@ -11,32 +11,9 @@ ## [311. Sparse Matrix Multiplication (Medium)](https://leetcode.com/problems/sparse-matrix-multiplication "稀疏矩阵的乘法") -

    Given two sparse matrices A and B, return the result of AB.

    -

    You may assume that A's column number is equal to B's row number.

    - -

    Example:

    - -
    -Input:
    -
    -A = [
    -  [ 1, 0, 0],
    -  [-1, 0, 3]
    -]
    -
    -B = [
    -  [ 7, 0, 0 ],
    -  [ 0, 0, 0 ],
    -  [ 0, 0, 1 ]
    -]
    -
    -Output:
    -
    -     |  1 0 0 |   | 7 0 0 |   |  7 0 0 |
    -AB = | -1 0 3 | x | 0 0 0 | = | -7 0 3 |
    -                  | 0 0 1 |
    -
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md b/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md index 9c6d14092..ee02ba5e1 100644 --- a/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md +++ b/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md @@ -63,6 +63,8 @@ x cannot be greater since there are only 2 numbers in nums. ### Related Topics [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/special-binary-string/README.md b/problems/special-binary-string/README.md index 6edfe9061..e28a06e4e 100644 --- a/problems/special-binary-string/README.md +++ b/problems/special-binary-string/README.md @@ -11,33 +11,44 @@ ## [761. Special Binary String (Hard)](https://leetcode.com/problems/special-binary-string "特殊的二进制序列") -

    Special binary strings are binary strings with the following two properties:

    +

    Special binary strings are binary strings with the following two properties:

      -
    • The number of 0's is equal to the number of 1's.
    • -
    • Every prefix of the binary string has at least as many 1's as 0's.
    • +
    • The number of 0's is equal to the number of 1's.
    • +
    • Every prefix of the binary string has at least as many 1's as 0's.
    -

    Given a special string s, a move consists of choosing two consecutive, non-empty, special substrings of s, and swapping them. (Two strings are consecutive if the last character of the first string is exactly one index before the first character of the second string.)

    +

    You are given a special binary string s.

    -

    At the end of any number of moves, what is the lexicographically largest resulting string possible?

    +

    A move consists of choosing two consecutive, non-empty, special substrings of s, and swapping them. Two strings are consecutive if the last character of the first string is exactly one index before the first character of the second string.

    -

    Example 1:

    +

    Return the lexicographically largest resulting string possible after applying the mentioned operations on the string.

    + +

     

    +

    Example 1:

    -Input: s = "11011000"
    -Output: "11100100"
    -Explanation:
    -The strings "10" [occuring at s[1]] and "1100" [at s[3]] are swapped.
    +Input: s = "11011000"
    +Output: "11100100"
    +Explanation: The strings "10" [occuring at s[1]] and "1100" [at s[3]] are swapped.
     This is the lexicographically largest string possible after some number of swaps.
     
    -

    Note:

    +

    Example 2:

    + +
    +Input: s = "10"
    +Output: "10"
    +
    -
      -
    1. s has length at most 50.
    2. -
    3. s is guaranteed to be a special binary string as defined above.
    4. -
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 50
    • +
    • s[i] is either '0' or '1'.
    • +
    • s is a special binary string.
    • +
    ### Related Topics [[Recursion](../../tag/recursion/README.md)] diff --git a/problems/special-positions-in-a-binary-matrix/README.md b/problems/special-positions-in-a-binary-matrix/README.md index 4e67d67bf..36f6711a1 100644 --- a/problems/special-positions-in-a-binary-matrix/README.md +++ b/problems/special-positions-in-a-binary-matrix/README.md @@ -69,6 +69,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/spiral-matrix-ii/README.md b/problems/spiral-matrix-ii/README.md index 8713bb82e..a9f9ed6c2 100644 --- a/problems/spiral-matrix-ii/README.md +++ b/problems/spiral-matrix-ii/README.md @@ -37,6 +37,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Similar Questions 1. [Spiral Matrix](../spiral-matrix) (Medium) diff --git a/problems/spiral-matrix-iii/README.md b/problems/spiral-matrix-iii/README.md index 63b639891..dc0d2556d 100644 --- a/problems/spiral-matrix-iii/README.md +++ b/problems/spiral-matrix-iii/README.md @@ -61,4 +61,6 @@
    ### Related Topics - [[Math](../../tag/math/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/spiral-matrix/README.md b/problems/spiral-matrix/README.md index 1deb730ef..ce34e4c08 100644 --- a/problems/spiral-matrix/README.md +++ b/problems/spiral-matrix/README.md @@ -40,6 +40,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Similar Questions 1. [Spiral Matrix II](../spiral-matrix-ii) (Medium) diff --git a/problems/split-a-string-in-balanced-strings/README.md b/problems/split-a-string-in-balanced-strings/README.md index 8e47d9c37..949a4f46d 100644 --- a/problems/split-a-string-in-balanced-strings/README.md +++ b/problems/split-a-string-in-balanced-strings/README.md @@ -62,6 +62,7 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/split-a-string-into-the-max-number-of-unique-substrings/README.md b/problems/split-a-string-into-the-max-number-of-unique-substrings/README.md index f95a420d7..0006e7742 100644 --- a/problems/split-a-string-into-the-max-number-of-unique-substrings/README.md +++ b/problems/split-a-string-into-the-max-number-of-unique-substrings/README.md @@ -55,6 +55,8 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Hints diff --git a/problems/split-array-into-consecutive-subsequences/README.md b/problems/split-array-into-consecutive-subsequences/README.md index ceb62306b..7487fd286 100644 --- a/problems/split-array-into-consecutive-subsequences/README.md +++ b/problems/split-array-into-consecutive-subsequences/README.md @@ -63,8 +63,10 @@ ### Related Topics - [[Heap](../../tag/heap/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Top K Frequent Elements](../top-k-frequent-elements) (Medium) diff --git a/problems/split-array-into-fibonacci-sequence/README.md b/problems/split-array-into-fibonacci-sequence/README.md index c94dadbf1..8e3310bea 100644 --- a/problems/split-array-into-fibonacci-sequence/README.md +++ b/problems/split-array-into-fibonacci-sequence/README.md @@ -73,7 +73,6 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/split-array-largest-sum/README.md b/problems/split-array-largest-sum/README.md index db339b0b2..7a6494418 100644 --- a/problems/split-array-largest-sum/README.md +++ b/problems/split-array-largest-sum/README.md @@ -51,5 +51,7 @@ where the largest sum among the two subarrays is only 18. ### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/split-array-with-equal-sum/README.md b/problems/split-array-with-equal-sum/README.md index 8873b82e1..78ed17ac5 100644 --- a/problems/split-array-with-equal-sum/README.md +++ b/problems/split-array-with-equal-sum/README.md @@ -11,33 +11,8 @@ ## [548. Split Array with Equal Sum (Medium)](https://leetcode.com/problems/split-array-with-equal-sum "将数组分割成和相等的子数组") -

    -Given an array with n integers, you need to find if there are triplets (i, j, k) which satisfies following conditions: -

      -
    1. 0 < i, i + 1 < j, j + 1 < k < n - 1
    2. -
    3. Sum of subarrays (0, i - 1), (i + 1, j - 1), (j + 1, k - 1) and (k + 1, n - 1) should be equal.
    4. -
    -where we define that subarray (L, R) represents a slice of the original array starting from the element indexed L to the element indexed R. -

    -

    Example:
    -

    -Input: [1,2,1,2,1,2,1]
    -Output: True
    -Explanation:
    -i = 1, j = 3, k = 5. 
    -sum(0, i - 1) = sum(0, 0) = 1
    -sum(i + 1, j - 1) = sum(2, 2) = 1
    -sum(j + 1, k - 1) = sum(4, 4) = 1
    -sum(k + 1, n - 1) = sum(6, 6) = 1
    -
    -

    - -Note: -
      -
    1. 1 <= n <= 2000.
    2. -
    3. Elements in the given array will be in range [-1,000,000, 1,000,000].
    4. -
    ### Related Topics [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] diff --git a/problems/split-array-with-same-average/README.md b/problems/split-array-with-same-average/README.md index 93d92b82d..248dac471 100644 --- a/problems/split-array-with-same-average/README.md +++ b/problems/split-array-with-same-average/README.md @@ -44,4 +44,8 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] diff --git a/problems/split-bst/README.md b/problems/split-bst/README.md index 49e6a9ae1..7e5836f2e 100644 --- a/problems/split-bst/README.md +++ b/problems/split-bst/README.md @@ -11,47 +11,13 @@ ## [776. Split BST (Medium)](https://leetcode.com/problems/split-bst "拆分二叉搜索树") -

    Given a Binary Search Tree (BST) with root node root, and a target value V, split the tree into two subtrees where one subtree has nodes that are all smaller or equal to the target value, while the other subtree has all nodes that are greater than the target value.  It's not necessarily the case that the tree contains a node with value V.

    -

    Additionally, most of the structure of the original tree should remain.  Formally, for any child C with parent P in the original tree, if they are both in the same subtree after the split, then node C should still have the parent P.

    - -

    You should output the root TreeNode of both subtrees after splitting, in any order.

    - -

    Example 1:

    - -
    -Input: root = [4,2,6,1,3,5,7], V = 2
    -Output: [[2,1],[4,3,6,null,null,5,7]]
    -Explanation:
    -Note that root, output[0], and output[1] are TreeNode objects, not arrays.
    -
    -The given tree [4,2,6,1,3,5,7] is represented by the following diagram:
    -
    -          4
    -        /   \
    -      2      6
    -     / \    / \
    -    1   3  5   7
    -
    -while the diagrams for the outputs are:
    -
    -          4
    -        /   \
    -      3      6      and    2
    -            / \           /
    -           5   7         1
    -
    - -

    Note:

    - -
      -
    1. The size of the BST will not exceed 50.
    2. -
    3. The BST is always valid and each node's value is different.
    4. -
    ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Recursion](../../tag/recursion/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Delete Node in a BST](../delete-node-in-a-bst) (Medium) diff --git a/problems/split-concatenated-strings/README.md b/problems/split-concatenated-strings/README.md index 3121c5af8..a999bca1a 100644 --- a/problems/split-concatenated-strings/README.md +++ b/problems/split-concatenated-strings/README.md @@ -11,32 +11,9 @@ ## [555. Split Concatenated Strings (Medium)](https://leetcode.com/problems/split-concatenated-strings "分割连接字符串") -

    Given a list of strings, you could concatenate these strings together into a loop, where for each string you could choose to reverse it or not. Among all the possible loops, you need to find the lexicographically biggest string after cutting the loop, which will make the looped string into a regular one.

    -

    Specifically, to find the lexicographically biggest string, you need to experience two phases: -

      -
    1. Concatenate all the strings into a loop, where you can reverse some strings or not and connect them in the same order as given.
    2. -
    3. Cut and make one breakpoint in any place of the loop, which will make the looped string into a regular one starting from the character at the cutpoint.
    4. -
    -

    - -

    And your job is to find the lexicographically biggest one among all the possible regular strings.

    - - -

    Example:
    -

    -Input: "abc", "xyz"
    -Output: "zyxcba"
    -Explanation: You can get the looped string "-abcxyz-", "-abczyx-", "-cbaxyz-", "-cbazyx-", 
    where '-' represents the looped status.
    The answer string came from the fourth looped one,
    where you could cut from the middle character 'a' and get "zyxcba". -
    -

    - -

    Note:
    -

      -
    1. The input strings will only contain lowercase letters.
    2. -
    3. The total length of all the strings will not over 1,000.
    4. -
    -

    ### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/split-linked-list-in-parts/README.md b/problems/split-linked-list-in-parts/README.md index 350cb53d9..ab8deab44 100644 --- a/problems/split-linked-list-in-parts/README.md +++ b/problems/split-linked-list-in-parts/README.md @@ -11,51 +11,42 @@ ## [725. Split Linked List in Parts (Medium)](https://leetcode.com/problems/split-linked-list-in-parts "分隔链表") -

    Given a (singly) linked list with head node root, write a function to split the linked list into k consecutive linked list "parts". -

    -The length of each part should be as equal as possible: no two parts should have a size differing by more than 1. This may lead to some parts being null. -

    -The parts should be in order of occurrence in the input list, and parts occurring earlier should always have a size greater than or equal parts occurring later. -

    -Return a List of ListNode's representing the linked list parts that are formed. -

    +

    Given the head of a singly linked list and an integer k, split the linked list into k consecutive linked list parts.

    -Examples -1->2->3->4, k = 5 // 5 equal parts -[ [1], -[2], -[3], -[4], -null ] +

    The length of each part should be as equal as possible: no two parts should have a size differing by more than one. This may lead to some parts being null.

    -

    Example 1:
    -

    -Input: 
    -root = [1, 2, 3], k = 5
    -Output: [[1],[2],[3],[],[]]
    -Explanation:
    -The input and each element of the output are ListNodes, not arrays.
    -For example, the input root has root.val = 1, root.next.val = 2, \root.next.next.val = 3, and root.next.next.next = null.
    +

    The parts should be in the order of occurrence in the input list, and parts occurring earlier should always have a size greater than or equal to parts occurring later.

    + +

    Return an array of the k parts.

    + +

     

    +

    Example 1:

    + +
    +Input: head = [1,2,3], k = 5
    +Output: [[1],[2],[3],[],[]]
    +Explanation:
     The first element output[0] has output[0].val = 1, output[0].next = null.
    -The last element output[4] is null, but it's string representation as a ListNode is [].
    +The last element output[4] is null, but its string representation as a ListNode is [].
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: 
    -root = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k = 3
    -Output: [[1, 2, 3, 4], [5, 6, 7], [8, 9, 10]]
    -Explanation:
    +Input: head = [1,2,3,4,5,6,7,8,9,10], k = 3
    +Output: [[1,2,3,4],[5,6,7],[8,9,10]]
    +Explanation:
     The input has been split into consecutive parts with size difference at most 1, and earlier parts are a larger size than the later parts.
     
    -

    -

    Note: -

  • The length of root will be in the range [0, 1000].
  • -
  • Each value of a node in the input will be an integer in the range [0, 999].
  • -
  • k will be an integer in the range [1, 50].
  • -

    +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is in the range [0, 1000].
    • +
    • 0 <= Node.val <= 1000
    • +
    • 1 <= k <= 50
    • +
    ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/splitting-a-string-into-descending-consecutive-values/README.md b/problems/splitting-a-string-into-descending-consecutive-values/README.md index bf1697775..a371b2796 100644 --- a/problems/splitting-a-string-into-descending-consecutive-values/README.md +++ b/problems/splitting-a-string-into-descending-consecutive-values/README.md @@ -68,7 +68,6 @@ The values are in descending order with adjacent values differing by 1. ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/squares-of-a-sorted-array/README.md b/problems/squares-of-a-sorted-array/README.md index 2efc259bd..db487bee4 100644 --- a/problems/squares-of-a-sorted-array/README.md +++ b/problems/squares-of-a-sorted-array/README.md @@ -45,6 +45,7 @@ After sorting, it becomes [0,1,9,16,100]. ### Related Topics [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Merge Sorted Array](../merge-sorted-array) (Easy) diff --git a/problems/stamping-the-sequence/README.md b/problems/stamping-the-sequence/README.md index 3217f2fab..2f0b9552b 100644 --- a/problems/stamping-the-sequence/README.md +++ b/problems/stamping-the-sequence/README.md @@ -56,5 +56,7 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Queue](../../tag/queue/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/statistics-from-a-large-sample/README.md b/problems/statistics-from-a-large-sample/README.md index 531cba012..bb2f741e1 100644 --- a/problems/statistics-from-a-large-sample/README.md +++ b/problems/statistics-from-a-large-sample/README.md @@ -68,6 +68,7 @@ The mode is 1 as it appears the most in the sample. ### Related Topics [[Math](../../tag/math/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Probability and Statistics](../../tag/probability-and-statistics/README.md)] ### Hints
    diff --git a/problems/stepping-numbers/README.md b/problems/stepping-numbers/README.md index c2b338c34..ad8a8f1ec 100644 --- a/problems/stepping-numbers/README.md +++ b/problems/stepping-numbers/README.md @@ -11,23 +11,10 @@ ## [1215. Stepping Numbers (Medium)](https://leetcode.com/problems/stepping-numbers "步进数") -

    A Stepping Number is an integer such that all of its adjacent digits have an absolute difference of exactly 1. For example, 321 is a Stepping Number while 421 is not.

    -

    Given two integers low and high, find and return a sorted list of all the Stepping Numbers in the range [low, high] inclusive.

    - -

     

    -

    Example 1:

    -
    Input: low = 0, high = 21
    -Output: [0,1,2,3,4,5,6,7,8,9,10,12,21]
    -
    -

     

    -

    Constraints:

    - -
      -
    • 0 <= low <= high <= 2 * 10^9
    • -
    ### Related Topics + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Hints diff --git a/problems/stickers-to-spell-word/README.md b/problems/stickers-to-spell-word/README.md index e08895150..4612eabd5 100644 --- a/problems/stickers-to-spell-word/README.md +++ b/problems/stickers-to-spell-word/README.md @@ -52,8 +52,10 @@ We cannot form the target "basicbasic" from cutting letters from the g ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Similar Questions 1. [Ransom Note](../ransom-note) (Easy) diff --git a/problems/stone-game-ii/README.md b/problems/stone-game-ii/README.md index bf299632e..61c60a903 100644 --- a/problems/stone-game-ii/README.md +++ b/problems/stone-game-ii/README.md @@ -46,7 +46,10 @@ ### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] ### Hints
    diff --git a/problems/stone-game-iii/README.md b/problems/stone-game-iii/README.md index f57b22440..e0f6523b3 100644 --- a/problems/stone-game-iii/README.md +++ b/problems/stone-game-iii/README.md @@ -74,15 +74,18 @@ Remember that both play optimally so here Alice will choose the scenario that ma ### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] ### Hints
    Hint 1 -The game can be mapped to minmax game. Alex tries to maximize the total score and Lee tries to minimize it. +The game can be mapped to minmax game. Alice tries to maximize the total score and Bob tries to minimize it.
    Hint 2 -Use dynamic programming to simulate the game. If the total score was 0 the game is "Tie", and if it has positive value then "Alex" wins, otherwise "Lee" wins. +Use dynamic programming to simulate the game. If the total score was 0 the game is "Tie", and if it has positive value then "Alice" wins, otherwise "Bob" wins.
    diff --git a/problems/stone-game-iv/README.md b/problems/stone-game-iv/README.md index 54f27145f..5777800a0 100644 --- a/problems/stone-game-iv/README.md +++ b/problems/stone-game-iv/README.md @@ -67,7 +67,9 @@ If Alice starts removing 1 stone, Bob will remove 4 stones then Alice only can r ### Related Topics + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] ### Hints
    diff --git a/problems/stone-game-v/README.md b/problems/stone-game-v/README.md index 967c5c847..018a99134 100644 --- a/problems/stone-game-v/README.md +++ b/problems/stone-game-v/README.md @@ -53,7 +53,10 @@ The last round Alice has only one choice to divide the row which is [2], [3]. Bo ### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] ### Hints
    diff --git a/problems/stone-game-vi/README.md b/problems/stone-game-vi/README.md index 62f6a7854..ea21b157d 100644 --- a/problems/stone-game-vi/README.md +++ b/problems/stone-game-vi/README.md @@ -71,6 +71,11 @@ Bob wins. ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/stone-game-vii/README.md b/problems/stone-game-vii/README.md index 74a93ef48..c2614f1d6 100644 --- a/problems/stone-game-vii/README.md +++ b/problems/stone-game-vii/README.md @@ -50,7 +50,10 @@ The score difference is 18 - 12 = 6. ### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] ### Hints
    diff --git a/problems/stone-game-viii/README.md b/problems/stone-game-viii/README.md index 9d33ad575..45ec75bbc 100644 --- a/problems/stone-game-viii/README.md +++ b/problems/stone-game-viii/README.md @@ -73,7 +73,11 @@ The difference between their scores is (-22) - 0 = -22. ### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/stone-game/README.md b/problems/stone-game/README.md index 3ed729a0e..f0ffae5da 100644 --- a/problems/stone-game/README.md +++ b/problems/stone-game/README.md @@ -44,6 +44,7 @@ This demonstrated that taking the first 5 was a winning move for Alex, so we ret ### Related Topics - [[Minimax](../../tag/minimax/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] diff --git a/problems/strange-printer-ii/README.md b/problems/strange-printer-ii/README.md index 6327fb0b5..d352ac2dd 100644 --- a/problems/strange-printer-ii/README.md +++ b/problems/strange-printer-ii/README.md @@ -66,7 +66,10 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/strange-printer/README.md b/problems/strange-printer/README.md index f0eb9992d..2d6df9e37 100644 --- a/problems/strange-printer/README.md +++ b/problems/strange-printer/README.md @@ -46,7 +46,7 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/stream-of-characters/README.md b/problems/stream-of-characters/README.md index bdc0b8a07..314c6eb67 100644 --- a/problems/stream-of-characters/README.md +++ b/problems/stream-of-characters/README.md @@ -51,7 +51,11 @@ streamChecker.query('l'); // return true, because 'kl' ### Related Topics + [[Design](../../tag/design/README.md)] [[Trie](../../tag/trie/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] ### Hints
    diff --git a/problems/string-compression/README.md b/problems/string-compression/README.md index 44ad46086..1b8dde388 100644 --- a/problems/string-compression/README.md +++ b/problems/string-compression/README.md @@ -65,6 +65,7 @@ You must write an algorithm that uses only constant extra space. ### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/string-matching-in-an-array/README.md b/problems/string-matching-in-an-array/README.md index 5f341db53..39e81221c 100644 --- a/problems/string-matching-in-an-array/README.md +++ b/problems/string-matching-in-an-array/README.md @@ -52,6 +52,7 @@ ### Related Topics [[String](../../tag/string/README.md)] + [[String Matching](../../tag/string-matching/README.md)] ### Hints
    diff --git a/problems/string-to-integer-atoi/README.md b/problems/string-to-integer-atoi/README.md index 4d1cda325..c7a84a2e0 100644 --- a/problems/string-to-integer-atoi/README.md +++ b/problems/string-to-integer-atoi/README.md @@ -121,7 +121,6 @@ Since -91283472332 is less than the lower bound of the range [-231, 2 ### Related Topics - [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/string-transforms-into-another-string/README.md b/problems/string-transforms-into-another-string/README.md index dd1510145..5ed7f6f1c 100644 --- a/problems/string-transforms-into-another-string/README.md +++ b/problems/string-transforms-into-another-string/README.md @@ -11,41 +11,11 @@ ## [1153. String Transforms Into Another String (Hard)](https://leetcode.com/problems/string-transforms-into-another-string "字符串转化") -

    Given two strings str1 and str2 of the same length, determine whether you can transform str1 into str2 by doing zero or more conversions.

    -

    In one conversion you can convert all occurrences of one character in str1 to any other lowercase English character.

    - -

    Return true if and only if you can transform str1 into str2.

    - -

     

    - -

    Example 1:

    - -
    -Input: str1 = "aabcc", str2 = "ccdee"
    -Output: true
    -Explanation: Convert 'c' to 'e' then 'b' to 'd' then 'a' to 'c'. Note that the order of conversions matter.
    -
    - -

    Example 2:

    - -
    -Input: str1 = "leetcode", str2 = "codeleet"
    -Output: false
    -Explanation: There is no way to transform str1 to str2.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= str1.length == str2.length <= 10^4
    2. -
    3. Both str1 and str2 contain only lowercase English letters.
    4. -
    ### Related Topics - [[Graph](../../tag/graph/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/string-without-aaa-or-bbb/README.md b/problems/string-without-aaa-or-bbb/README.md index 6be32faa8..1c7037275 100644 --- a/problems/string-without-aaa-or-bbb/README.md +++ b/problems/string-without-aaa-or-bbb/README.md @@ -45,3 +45,4 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/strings-differ-by-one-character/README.md b/problems/strings-differ-by-one-character/README.md index e3c1d8902..6fea70d9f 100644 --- a/problems/strings-differ-by-one-character/README.md +++ b/problems/strings-differ-by-one-character/README.md @@ -13,6 +13,12 @@ +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] + ### Hints
    Hint 1 diff --git a/problems/strobogrammatic-number-ii/README.md b/problems/strobogrammatic-number-ii/README.md index 0cda2663c..bde7e29ae 100644 --- a/problems/strobogrammatic-number-ii/README.md +++ b/problems/strobogrammatic-number-ii/README.md @@ -11,20 +11,12 @@ ## [247. Strobogrammatic Number II (Medium)](https://leetcode.com/problems/strobogrammatic-number-ii "中心对称数 II") -

    A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).

    -

    Find all strobogrammatic numbers that are of length = n.

    - -

    Example:

    - -
    -Input:  n = 2
    -Output: ["11","69","88","96"]
    -
    ### Related Topics [[Recursion](../../tag/recursion/README.md)] - [[Math](../../tag/math/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Strobogrammatic Number](../strobogrammatic-number) (Easy) diff --git a/problems/strobogrammatic-number-iii/README.md b/problems/strobogrammatic-number-iii/README.md index 2372b682c..db270752d 100644 --- a/problems/strobogrammatic-number-iii/README.md +++ b/problems/strobogrammatic-number-iii/README.md @@ -11,23 +11,12 @@ ## [248. Strobogrammatic Number III (Hard)](https://leetcode.com/problems/strobogrammatic-number-iii "中心对称数 III") -

    A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).

    -

    Write a function to count the total strobogrammatic numbers that exist in the range of low <= num <= high.

    - -

    Example:

    - -
    -Input: low = "50", high = "100"
    -Output: 3 
    -Explanation: 69, 88, and 96 are three strobogrammatic numbers.
    - -

    Note:
    -Because the range might be a large number, the low and high numbers are represented as string.

    ### Related Topics [[Recursion](../../tag/recursion/README.md)] - [[Math](../../tag/math/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Strobogrammatic Number](../strobogrammatic-number) (Easy) diff --git a/problems/strobogrammatic-number/README.md b/problems/strobogrammatic-number/README.md index 4784cec6a..eda04becb 100644 --- a/problems/strobogrammatic-number/README.md +++ b/problems/strobogrammatic-number/README.md @@ -11,32 +11,12 @@ ## [246. Strobogrammatic Number (Easy)](https://leetcode.com/problems/strobogrammatic-number "中心对称数") -

    A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).

    -

    Write a function to determine if a number is strobogrammatic. The number is represented as a string.

    - -

    Example 1:

    - -
    -Input:  "69"
    -Output: true
    -
    - -

    Example 2:

    - -
    -Input:  "88"
    -Output: true
    - -

    Example 3:

    - -
    -Input:  "962"
    -Output: false
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] - [[Math](../../tag/math/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Strobogrammatic Number II](../strobogrammatic-number-ii) (Medium) diff --git a/problems/strong-password-checker/README.md b/problems/strong-password-checker/README.md index 0a85c673f..5bcd0b817 100644 --- a/problems/strong-password-checker/README.md +++ b/problems/strong-password-checker/README.md @@ -47,3 +47,8 @@
  • 1 <= password.length <= 50
  • password consists of letters, digits, dot '.' or exclamation mark '!'.
  • + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/students-and-examinations/README.md b/problems/students-and-examinations/README.md index bb99c2475..6b8d2228c 100644 --- a/problems/students-and-examinations/README.md +++ b/problems/students-and-examinations/README.md @@ -11,101 +11,7 @@ ## [1280. Students and Examinations (Easy)](https://leetcode.com/problems/students-and-examinations "学生们参加各科测试的次数") -

    Table: Students

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| student_id    | int     |
    -| student_name  | varchar |
    -+---------------+---------+
    -student_id is the primary key for this table.
    -Each row of this table contains the ID and the name of one student in the school.
    -
    - -

    Table: Subjects

    -
    -+--------------+---------+
    -| Column Name  | Type    |
    -+--------------+---------+
    -| subject_name | varchar |
    -+--------------+---------+
    -subject_name is the primary key for this table.
    -Each row of this table contains a name of one subject in the school.
    -
    - -

    Table: Examinations

    -
    -+--------------+---------+
    -| Column Name  | Type    |
    -+--------------+---------+
    -| student_id   | int     |
    -| subject_name | varchar |
    -+--------------+---------+
    -There is no primary key for this table. It may contain duplicates.
    -Each student from Students table takes every course from Subjects table.
    -Each row of this table indicates that a student with ID student_id attended the exam of subject_name.
    -
    - -Write an SQL query to find the number of times each student attended each exam. -Order the result table by student_id and subject_name. -The query result format is in the following example: -
    -Students table:
    -+------------+--------------+
    -| student_id | student_name |
    -+------------+--------------+
    -| 1          | Alice        |
    -| 2          | Bob          |
    -| 13         | John         |
    -| 6          | Alex         |
    -+------------+--------------+
    -Subjects table:
    -+--------------+
    -| subject_name |
    -+--------------+
    -| Math         |
    -| Physics      |
    -| Programming  |
    -+--------------+
    -Examinations table:
    -+------------+--------------+
    -| student_id | subject_name |
    -+------------+--------------+
    -| 1          | Math         |
    -| 1          | Physics      |
    -| 1          | Programming  |
    -| 2          | Programming  |
    -| 1          | Physics      |
    -| 1          | Math         |
    -| 13         | Math         |
    -| 13         | Programming  |
    -| 13         | Physics      |
    -| 2          | Math         |
    -| 1          | Math         |
    -+------------+--------------+
    -Result table:
    -+------------+--------------+--------------+----------------+
    -| student_id | student_name | subject_name | attended_exams |
    -+------------+--------------+--------------+----------------+
    -| 1          | Alice        | Math         | 3              |
    -| 1          | Alice        | Physics      | 2              |
    -| 1          | Alice        | Programming  | 1              |
    -| 2          | Bob          | Math         | 1              |
    -| 2          | Bob          | Physics      | 0              |
    -| 2          | Bob          | Programming  | 1              |
    -| 6          | Alex         | Math         | 0              |
    -| 6          | Alex         | Physics      | 0              |
    -| 6          | Alex         | Programming  | 0              |
    -| 13         | John         | Math         | 1              |
    -| 13         | John         | Physics      | 1              |
    -| 13         | John         | Programming  | 1              |
    -+------------+--------------+--------------+----------------+
    -The result table should contain all students and all subjects.
    -Alice attended Math exam 3 times, Physics exam 2 times and Programming exam 1 time.
    -Bob attended Math exam 1 time, Programming exam 1 time and didn't attend the Physics exam.
    -Alex didn't attend any exam.
    -John attended Math exam 1 time, Physics exam 1 time and Programming exam 1 time.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/students-report-by-geography/README.md b/problems/students-report-by-geography/README.md index c7562dcd4..4ce16b51e 100644 --- a/problems/students-report-by-geography/README.md +++ b/problems/students-report-by-geography/README.md @@ -11,34 +11,7 @@ ## [618. Students Report By Geography (Hard)](https://leetcode.com/problems/students-report-by-geography "学生地理信息报告") -A U.S graduate school has students from Asia, Europe and America. The students' location information are stored in table student as below. -

     

    -
    -| name   | continent |
    -|--------|-----------|
    -| Jack   | America   |
    -| Pascal | Europe    |
    -| Xi     | Asia      |
    -| Jane   | America   |
    -
    -

     

    - Pivot the continent column in this table so that each name is sorted alphabetically and displayed underneath its corresponding continent. The output headers should be America, Asia and Europe respectively. It is guaranteed that the student number from America is no less than either Asia or Europe. - -

     

    -For the sample input, the output is: - -

     

    - -
    -| America | Asia | Europe |
    -|---------|------|--------|
    -| Jack    | Xi   | Pascal |
    -| Jane    |      |        |
    -
    - -

     

    -Follow-up: If it is unknown which continent has the most students, can you write a query to generate the student report? - -

     

    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/students-with-invalid-departments/README.md b/problems/students-with-invalid-departments/README.md index b696a87a5..18fd03bac 100644 --- a/problems/students-with-invalid-departments/README.md +++ b/problems/students-with-invalid-departments/README.md @@ -11,71 +11,7 @@ ## [1350. Students With Invalid Departments (Easy)](https://leetcode.com/problems/students-with-invalid-departments "院系无效的学生") -

    Table: Departments

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| id            | int     |
    -| name          | varchar |
    -+---------------+---------+
    -id is the primary key of this table.
    -The table has information about the id of each department of a university.
    -
    - -

    Table: Students

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| id            | int     |
    -| name          | varchar |
    -| department_id | int     |
    -+---------------+---------+
    -id is the primary key of this table.
    -The table has information about the id of each student at a university and the id of the department he/she studies at.
    -
    - -Write an SQL query to find the id and the name of all students who are enrolled in departments that no longer exists. -Return the result table in any order. -The query result format is in the following example: -
    -Departments table:
    -+------+--------------------------+
    -| id   | name                     |
    -+------+--------------------------+
    -| 1    | Electrical Engineering   |
    -| 7    | Computer Engineering     |
    -| 13   | Bussiness Administration |
    -+------+--------------------------+
    -
    -Students table:
    -+------+----------+---------------+
    -| id   | name     | department_id |
    -+------+----------+---------------+
    -| 23   | Alice    | 1             |
    -| 1    | Bob      | 7             |
    -| 5    | Jennifer | 13            |
    -| 2    | John     | 14            |
    -| 4    | Jasmine  | 77            |
    -| 3    | Steve    | 74            |
    -| 6    | Luis     | 1             |
    -| 8    | Jonathan | 7             |
    -| 7    | Daiana   | 33            |
    -| 11   | Madelynn | 1             |
    -+------+----------+---------------+
    -
    -Result table:
    -+------+----------+
    -| id   | name     |
    -+------+----------+
    -| 2    | John     |
    -| 7    | Daiana   |
    -| 4    | Jasmine  |
    -| 3    | Steve    |
    -+------+----------+
    -
    -John, Daiana, Steve and Jasmine are enrolled in departments 14, 33, 74 and 77 respectively. department 14, 33, 74 and 77 doesn't exist in the Departments table.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/subarray-product-less-than-k/README.md b/problems/subarray-product-less-than-k/README.md index 409a463ac..3597aca60 100644 --- a/problems/subarray-product-less-than-k/README.md +++ b/problems/subarray-product-less-than-k/README.md @@ -35,14 +35,14 @@ Note that [10, 5, 2] is not included as the product of 100 is not strictly less

    Constraints:

      -
    • 1 <= nums.length <= 105
    • -
    • 0 <= nums[i] < 1000
    • -
    • 0 <= k < 106
    • +
    • 1 <= nums.length <= 3 * 104
    • +
    • 1 <= nums[i] <= 1000
    • +
    • 0 <= k <= 106
    ### Related Topics [[Array](../../tag/array/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions 1. [Maximum Product Subarray](../maximum-product-subarray) (Medium) diff --git a/problems/subarray-sum-equals-k/README.md b/problems/subarray-sum-equals-k/README.md index 0b90f720e..ade722bf9 100644 --- a/problems/subarray-sum-equals-k/README.md +++ b/problems/subarray-sum-equals-k/README.md @@ -33,6 +33,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Similar Questions 1. [Two Sum](../two-sum) (Easy) diff --git a/problems/subarray-sums-divisible-by-k/README.md b/problems/subarray-sums-divisible-by-k/README.md index 9db2e729c..358aecf01 100644 --- a/problems/subarray-sums-divisible-by-k/README.md +++ b/problems/subarray-sums-divisible-by-k/README.md @@ -39,6 +39,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Similar Questions 1. [Subarray Sum Equals K](../subarray-sum-equals-k) (Medium) diff --git a/problems/subarrays-with-k-different-integers/README.md b/problems/subarrays-with-k-different-integers/README.md index a611f9055..9baba425b 100644 --- a/problems/subarrays-with-k-different-integers/README.md +++ b/problems/subarrays-with-k-different-integers/README.md @@ -46,8 +46,9 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] + [[Counting](../../tag/counting/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions diff --git a/problems/subdomain-visit-count/README.md b/problems/subdomain-visit-count/README.md index 171f9bd4f..21ff1974f 100644 --- a/problems/subdomain-visit-count/README.md +++ b/problems/subdomain-visit-count/README.md @@ -50,4 +50,6 @@ We will visit "google.mail.com" 900 times, "yahoo.com" 50 ti ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/subrectangle-queries/README.md b/problems/subrectangle-queries/README.md index 0fcd080a7..0166968e1 100644 --- a/problems/subrectangle-queries/README.md +++ b/problems/subrectangle-queries/README.md @@ -94,7 +94,9 @@ subrectangleQueries.getValue(2, 2); // return 20 ### Related Topics + [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/subsets-ii/README.md b/problems/subsets-ii/README.md index 212b49a70..1f182abfd 100644 --- a/problems/subsets-ii/README.md +++ b/problems/subsets-ii/README.md @@ -32,6 +32,7 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/substring-with-concatenation-of-all-words/README.md b/problems/substring-with-concatenation-of-all-words/README.md index 2de03a46c..29eca0990 100644 --- a/problems/substring-with-concatenation-of-all-words/README.md +++ b/problems/substring-with-concatenation-of-all-words/README.md @@ -52,8 +52,8 @@ The output order does not matter, returning [9,0] is fine too. ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions 1. [Minimum Window Substring](../minimum-window-substring) (Hard) diff --git a/problems/substrings-of-size-three-with-distinct-characters/README.md b/problems/substrings-of-size-three-with-distinct-characters/README.md index e19e6757d..84a9ab14d 100644 --- a/problems/substrings-of-size-three-with-distinct-characters/README.md +++ b/problems/substrings-of-size-three-with-distinct-characters/README.md @@ -47,7 +47,10 @@ The good substrings are "abc", "bca", "cab", and & ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/subtree-of-another-tree/README.md b/problems/subtree-of-another-tree/README.md index 8c5c5a478..b7a7318f3 100644 --- a/problems/subtree-of-another-tree/README.md +++ b/problems/subtree-of-another-tree/README.md @@ -42,6 +42,10 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] + [[String Matching](../../tag/string-matching/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Similar Questions 1. [Count Univalue Subtrees](../count-univalue-subtrees) (Medium) diff --git a/problems/sudoku-solver/README.md b/problems/sudoku-solver/README.md index b1f0b8ad1..34c89651e 100644 --- a/problems/sudoku-solver/README.md +++ b/problems/sudoku-solver/README.md @@ -45,8 +45,9 @@ ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] + [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Valid Sudoku](../valid-sudoku) (Medium) diff --git a/problems/sum-of-absolute-differences-in-a-sorted-array/README.md b/problems/sum-of-absolute-differences-in-a-sorted-array/README.md index a73fc0b62..203d0d8ac 100644 --- a/problems/sum-of-absolute-differences-in-a-sorted-array/README.md +++ b/problems/sum-of-absolute-differences-in-a-sorted-array/README.md @@ -45,8 +45,9 @@ result[2] = |5-2| + |5-3| + |5-5| = 3 + 2 + 0 = 5. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/sum-of-all-odd-length-subarrays/README.md b/problems/sum-of-all-odd-length-subarrays/README.md index b69281e2d..ffc585067 100644 --- a/problems/sum-of-all-odd-length-subarrays/README.md +++ b/problems/sum-of-all-odd-length-subarrays/README.md @@ -59,6 +59,7 @@ If we add all these together we get 1 + 4 + 2 + 5 + 3 + 7 + 11 + 10 + 15 = 58

    diff --git a/problems/sum-of-all-subset-xor-totals/README.md b/problems/sum-of-all-subset-xor-totals/README.md index a017f0ec1..21dfba198 100644 --- a/problems/sum-of-all-subset-xor-totals/README.md +++ b/problems/sum-of-all-subset-xor-totals/README.md @@ -71,7 +71,8 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Hints diff --git a/problems/sum-of-beauty-of-all-substrings/README.md b/problems/sum-of-beauty-of-all-substrings/README.md index 3f91dbd23..1d2667a17 100644 --- a/problems/sum-of-beauty-of-all-substrings/README.md +++ b/problems/sum-of-beauty-of-all-substrings/README.md @@ -45,6 +45,7 @@ ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/sum-of-digits-in-base-k/README.md b/problems/sum-of-digits-in-base-k/README.md index a24e7e415..709e3d543 100644 --- a/problems/sum-of-digits-in-base-k/README.md +++ b/problems/sum-of-digits-in-base-k/README.md @@ -41,7 +41,6 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] ### Hints diff --git a/problems/sum-of-digits-in-the-minimum-number/README.md b/problems/sum-of-digits-in-the-minimum-number/README.md index 3fd20a926..6c5ae3e3a 100644 --- a/problems/sum-of-digits-in-the-minimum-number/README.md +++ b/problems/sum-of-digits-in-the-minimum-number/README.md @@ -11,41 +11,11 @@ ## [1085. Sum of Digits in the Minimum Number (Easy)](https://leetcode.com/problems/sum-of-digits-in-the-minimum-number "最小元素各数位之和") -

    Given an array A of positive integers, let S be the sum of the digits of the minimal element of A.

    -

    Return 0 if S is odd, otherwise return 1.

    - -

     

    - -

    Example 1:

    - -
    -Input: [34,23,1,24,75,33,54,8]
    -Output: 0
    -Explanation: 
    -The minimal element is 1, and the sum of those digits is S = 1 which is odd, so the answer is 0.
    -
    - -

    Example 2:

    - -
    -Input: [99,77,33,66,55]
    -Output: 1
    -Explanation: 
    -The minimal element is 33, and the sum of those digits is S = 3 + 3 = 6 which is even, so the answer is 1.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= A.length <= 100
    2. -
    3. 1 <= A[i].length <= 100
    4. -
    ### Related Topics [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Add Digits](../add-digits) (Easy) diff --git a/problems/sum-of-distances-in-tree/README.md b/problems/sum-of-distances-in-tree/README.md index c850d868d..9a6701e17 100644 --- a/problems/sum-of-distances-in-tree/README.md +++ b/problems/sum-of-distances-in-tree/README.md @@ -37,7 +37,9 @@ equals 1 + 1 + 2 + 2 + 2 = 8. Hence, answer[0] = 8, and so on. ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Distribute Coins in Binary Tree](../distribute-coins-in-binary-tree) (Medium) diff --git a/problems/sum-of-even-numbers-after-queries/README.md b/problems/sum-of-even-numbers-after-queries/README.md index a415fb7c6..9ef74b88d 100644 --- a/problems/sum-of-even-numbers-after-queries/README.md +++ b/problems/sum-of-even-numbers-after-queries/README.md @@ -48,3 +48,4 @@ After adding 2 to nums[3], the array is [-2,-1,3,6], and the sum of even values ### Related Topics [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/sum-of-floored-pairs/README.md b/problems/sum-of-floored-pairs/README.md index b152a4003..84a0bad5d 100644 --- a/problems/sum-of-floored-pairs/README.md +++ b/problems/sum-of-floored-pairs/README.md @@ -46,7 +46,10 @@ We calculate the floor of the division for every pair of indices in the array th ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/sum-of-left-leaves/README.md b/problems/sum-of-left-leaves/README.md index 481e762e5..232f68a07 100644 --- a/problems/sum-of-left-leaves/README.md +++ b/problems/sum-of-left-leaves/README.md @@ -39,3 +39,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/sum-of-mutated-array-closest-to-target/README.md b/problems/sum-of-mutated-array-closest-to-target/README.md index 041e20f21..140b8fb86 100644 --- a/problems/sum-of-mutated-array-closest-to-target/README.md +++ b/problems/sum-of-mutated-array-closest-to-target/README.md @@ -51,6 +51,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/sum-of-nodes-with-even-valued-grandparent/README.md b/problems/sum-of-nodes-with-even-valued-grandparent/README.md index 758aa7a6b..6048d8e67 100644 --- a/problems/sum-of-nodes-with-even-valued-grandparent/README.md +++ b/problems/sum-of-nodes-with-even-valued-grandparent/README.md @@ -36,7 +36,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/sum-of-root-to-leaf-binary-numbers/README.md b/problems/sum-of-root-to-leaf-binary-numbers/README.md index 3da4b3899..8ea2c7e73 100644 --- a/problems/sum-of-root-to-leaf-binary-numbers/README.md +++ b/problems/sum-of-root-to-leaf-binary-numbers/README.md @@ -57,6 +57,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/sum-of-special-evenly-spaced-elements-in-array/README.md b/problems/sum-of-special-evenly-spaced-elements-in-array/README.md index a79e00668..8ce6a2aaf 100644 --- a/problems/sum-of-special-evenly-spaced-elements-in-array/README.md +++ b/problems/sum-of-special-evenly-spaced-elements-in-array/README.md @@ -13,6 +13,10 @@ +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + ### Hints
    Hint 1 diff --git a/problems/sum-of-square-numbers/README.md b/problems/sum-of-square-numbers/README.md index c481746b5..f4a3e2a16 100644 --- a/problems/sum-of-square-numbers/README.md +++ b/problems/sum-of-square-numbers/README.md @@ -59,6 +59,8 @@ ### Related Topics [[Math](../../tag/math/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions 1. [Valid Perfect Square](../valid-perfect-square) (Easy) diff --git a/problems/sum-of-subarray-minimums/README.md b/problems/sum-of-subarray-minimums/README.md index a34173d2a..bb47a9d74 100644 --- a/problems/sum-of-subarray-minimums/README.md +++ b/problems/sum-of-subarray-minimums/README.md @@ -43,3 +43,5 @@ Sum is 17. ### Related Topics [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] diff --git a/problems/sum-of-subsequence-widths/README.md b/problems/sum-of-subsequence-widths/README.md index e0026b055..900b0678f 100644 --- a/problems/sum-of-subsequence-widths/README.md +++ b/problems/sum-of-subsequence-widths/README.md @@ -46,3 +46,4 @@ The sum of these widths is 6. ### Related Topics [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/sum-of-two-integers/README.md b/problems/sum-of-two-integers/README.md index e28244e2c..e697240ee 100644 --- a/problems/sum-of-two-integers/README.md +++ b/problems/sum-of-two-integers/README.md @@ -30,6 +30,7 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Add Two Numbers](../add-two-numbers) (Medium) diff --git a/problems/sum-of-unique-elements/README.md b/problems/sum-of-unique-elements/README.md index 067d9813a..869dd2a26 100644 --- a/problems/sum-of-unique-elements/README.md +++ b/problems/sum-of-unique-elements/README.md @@ -51,6 +51,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/sum-root-to-leaf-numbers/README.md b/problems/sum-root-to-leaf-numbers/README.md index dff689f8b..5421831d0 100644 --- a/problems/sum-root-to-leaf-numbers/README.md +++ b/problems/sum-root-to-leaf-numbers/README.md @@ -58,7 +58,8 @@ Therefore, sum = 495 + 491 + 40 = 1026. ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Path Sum](../path-sum) (Easy) diff --git a/problems/super-palindromes/README.md b/problems/super-palindromes/README.md index 3f2fa6191..e48447ffa 100644 --- a/problems/super-palindromes/README.md +++ b/problems/super-palindromes/README.md @@ -45,3 +45,4 @@ Note that 676 is not a superpalindrome: 26 * 26 = 676, but 26 is not a palindrom ### Related Topics [[Math](../../tag/math/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] diff --git a/problems/super-pow/README.md b/problems/super-pow/README.md index 3eb705bce..084186323 100644 --- a/problems/super-pow/README.md +++ b/problems/super-pow/README.md @@ -39,6 +39,7 @@ ### Related Topics [[Math](../../tag/math/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions 1. [Pow(x, n)](../powx-n) (Medium) diff --git a/problems/super-ugly-number/README.md b/problems/super-ugly-number/README.md index f7e35c9d6..2e149110e 100644 --- a/problems/super-ugly-number/README.md +++ b/problems/super-ugly-number/README.md @@ -46,8 +46,11 @@ ### Related Topics - [[Heap](../../tag/heap/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Ugly Number II](../ugly-number-ii) (Medium) diff --git a/problems/super-washing-machines/README.md b/problems/super-washing-machines/README.md index 8aa55c55a..27d42a2d7 100644 --- a/problems/super-washing-machines/README.md +++ b/problems/super-washing-machines/README.md @@ -58,5 +58,5 @@ It's impossible to make all three washing machines have the same number of d ### Related Topics - [[Math](../../tag/math/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/surface-area-of-3d-shapes/README.md b/problems/surface-area-of-3d-shapes/README.md index f8544c12a..cc90f7bea 100644 --- a/problems/surface-area-of-3d-shapes/README.md +++ b/problems/surface-area-of-3d-shapes/README.md @@ -67,4 +67,6 @@ ### Related Topics [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/surrounded-regions/README.md b/problems/surrounded-regions/README.md index f0434e8fd..31e7f3500 100644 --- a/problems/surrounded-regions/README.md +++ b/problems/surrounded-regions/README.md @@ -42,9 +42,11 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Number of Islands](../number-of-islands) (Medium) diff --git a/problems/suspicious-bank-accounts/README.md b/problems/suspicious-bank-accounts/README.md index 7a04a8b35..e76384a0c 100644 --- a/problems/suspicious-bank-accounts/README.md +++ b/problems/suspicious-bank-accounts/README.md @@ -12,3 +12,6 @@ ## [1843. Suspicious Bank Accounts (Medium)](https://leetcode.com/problems/suspicious-bank-accounts "") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/swap-adjacent-in-lr-string/README.md b/problems/swap-adjacent-in-lr-string/README.md index 2f569c5f1..ae714477d 100644 --- a/problems/swap-adjacent-in-lr-string/README.md +++ b/problems/swap-adjacent-in-lr-string/README.md @@ -65,7 +65,8 @@ XRLXXRRLX ### Related Topics - [[Brainteaser](../../tag/brainteaser/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/swap-for-longest-repeated-character-substring/README.md b/problems/swap-for-longest-repeated-character-substring/README.md index 45c14c636..4eb980009 100644 --- a/problems/swap-for-longest-repeated-character-substring/README.md +++ b/problems/swap-for-longest-repeated-character-substring/README.md @@ -62,6 +62,7 @@ ### Related Topics [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/swap-salary/README.md b/problems/swap-salary/README.md index 920f9aafe..d81d80e0c 100644 --- a/problems/swap-salary/README.md +++ b/problems/swap-salary/README.md @@ -60,3 +60,6 @@ Result table: (1, A) and (3, C) were changed from 'm' to 'f'. (2, B) and (4, D) were changed from 'f' to 'm'.
    + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/swapping-nodes-in-a-linked-list/README.md b/problems/swapping-nodes-in-a-linked-list/README.md index 22814398a..c5d03018f 100644 --- a/problems/swapping-nodes-in-a-linked-list/README.md +++ b/problems/swapping-nodes-in-a-linked-list/README.md @@ -62,6 +62,7 @@ ### Related Topics [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] ### Hints
    diff --git a/problems/swim-in-rising-water/README.md b/problems/swim-in-rising-water/README.md index cb0e65a99..549f5e0da 100644 --- a/problems/swim-in-rising-water/README.md +++ b/problems/swim-in-rising-water/README.md @@ -11,53 +11,53 @@ ## [778. Swim in Rising Water (Hard)](https://leetcode.com/problems/swim-in-rising-water "水位上升的泳池中游泳") -

    On an N x N grid, each square grid[i][j] represents the elevation at that point (i,j).

    +

    You are given an n x n integer matrix grid where each value grid[i][j] represents the elevation at that point (i, j).

    -

    Now rain starts to fall. At time t, the depth of the water everywhere is t. You can swim from a square to another 4-directionally adjacent square if and only if the elevation of both squares individually are at most t. You can swim infinite distance in zero time. Of course, you must stay within the boundaries of the grid during your swim.

    +

    The rain starts to fall. At time t, the depth of the water everywhere is t. You can swim from a square to another 4-directionally adjacent square if and only if the elevation of both squares individually are at most t. You can swim infinite distances in zero time. Of course, you must stay within the boundaries of the grid during your swim.

    -

    You start at the top left square (0, 0). What is the least time until you can reach the bottom right square (N-1, N-1)?

    +

    Return the least time until you can reach the bottom right square (n - 1, n - 1) if you start at the top left square (0, 0).

    +

     

    Example 1:

    - +
    -Input: [[0,2],[1,3]]
    +Input: grid = [[0,2],[1,3]]
     Output: 3
    -Explanation:
    -At time 0, you are in grid location (0, 0).
    +Explanation:
    +At time 0, you are in grid location (0, 0).
     You cannot go anywhere else because 4-directionally adjacent neighbors have a higher elevation than t = 0.
    -
    -You cannot reach point (1, 1) until time 3.
    -When the depth of water is 3, we can swim anywhere inside the grid.
    +You cannot reach point (1, 1) until time 3.
    +When the depth of water is 3, we can swim anywhere inside the grid.
     

    Example 2:

    - +
    -Input: [[0,1,2,3,4],[24,23,22,21,5],[12,13,14,15,16],[11,17,18,19,20],[10,9,8,7,6]]
    +Input: grid = [[0,1,2,3,4],[24,23,22,21,5],[12,13,14,15,16],[11,17,18,19,20],[10,9,8,7,6]]
     Output: 16
    -Explanation:
    - 0  1  2  3  4
    -24 23 22 21  5
    -12 13 14 15 16
    -11 17 18 19 20
    -10  9  8  7  6
    -
    -The final route is marked in bold.
    +Explanation: The final route is shown.
     We need to wait until time 16 so that (0, 0) and (4, 4) are connected.
     
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. 2 <= N <= 50.
    2. -
    3. grid[i][j] is a permutation of [0, ..., N*N - 1].
    4. -
    +
      +
    • n == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= n <= 50
    • +
    • 0 <= grid[i][j] < n2
    • +
    • Each value grid[i][j] is unique.
    • +
    ### Related Topics - [[Heap](../../tag/heap/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/symmetric-tree/README.md b/problems/symmetric-tree/README.md index b63ee43fe..b10b5a489 100644 --- a/problems/symmetric-tree/README.md +++ b/problems/symmetric-tree/README.md @@ -41,5 +41,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/synonymous-sentences/README.md b/problems/synonymous-sentences/README.md index 43d71fe59..ab863fcb1 100644 --- a/problems/synonymous-sentences/README.md +++ b/problems/synonymous-sentences/README.md @@ -11,35 +11,13 @@ ## [1258. Synonymous Sentences (Medium)](https://leetcode.com/problems/synonymous-sentences "近义词句子") -Given a list of pairs of equivalent words synonyms and a sentence text, Return all possible synonymous sentences sorted lexicographically. -

     

    -

    Example 1:

    - -
    -Input:
    -synonyms = [["happy","joy"],["sad","sorrow"],["joy","cheerful"]],
    -text = "I am happy today but was sad yesterday"
    -Output:
    -["I am cheerful today but was sad yesterday",
    -​​​​​​​"I am cheerful today but was sorrow yesterday",
    -"I am happy today but was sad yesterday",
    -"I am happy today but was sorrow yesterday",
    -"I am joy today but was sad yesterday",
    -"I am joy today but was sorrow yesterday"]
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 0 <= synonyms.length <= 10
    • -
    • synonyms[i].length == 2
    • -
    • synonyms[0] != synonyms[1]
    • -
    • All words consist of at most 10 English letters only.
    • -
    • text is a single space separated sentence of at most 10 words.
    • -
    + ### Related Topics + [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Hints diff --git a/problems/tallest-billboard/README.md b/problems/tallest-billboard/README.md index 16b069a1e..3d3e7c94a 100644 --- a/problems/tallest-billboard/README.md +++ b/problems/tallest-billboard/README.md @@ -52,4 +52,5 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/target-sum/README.md b/problems/target-sum/README.md index 739bfbc3f..e1998bc26 100644 --- a/problems/target-sum/README.md +++ b/problems/target-sum/README.md @@ -53,8 +53,9 @@ ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions 1. [Expression Add Operators](../expression-add-operators) (Hard) diff --git a/problems/task-scheduler/README.md b/problems/task-scheduler/README.md index b07e0577e..ee36c01df 100644 --- a/problems/task-scheduler/README.md +++ b/problems/task-scheduler/README.md @@ -62,8 +62,11 @@ A -> B -> C -> A -> D -> E -> A -> F -> G -> A -> ### Related Topics [[Greedy](../../tag/greedy/README.md)] - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Rearrange String k Distance Apart](../rearrange-string-k-distance-apart) (Hard) diff --git a/problems/team-scores-in-football-tournament/README.md b/problems/team-scores-in-football-tournament/README.md index 003c3bc81..c21414e96 100644 --- a/problems/team-scores-in-football-tournament/README.md +++ b/problems/team-scores-in-football-tournament/README.md @@ -11,80 +11,7 @@ ## [1212. Team Scores in Football Tournament (Medium)](https://leetcode.com/problems/team-scores-in-football-tournament "查询球队积分") -

    Table: Teams

    -
    -+---------------+----------+
    -| Column Name   | Type     |
    -+---------------+----------+
    -| team_id       | int      |
    -| team_name     | varchar  |
    -+---------------+----------+
    -team_id is the primary key of this table.
    -Each row of this table represents a single football team.
    -
    -

    Table: Matches

    - -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| match_id      | int     |
    -| host_team     | int     |
    -| guest_team    | int     | 
    -| host_goals    | int     |
    -| guest_goals   | int     |
    -+---------------+---------+
    -match_id is the primary key of this table.
    -Each row is a record of a finished match between two different teams. 
    -Teams host_team and guest_team are represented by their IDs in the teams table (team_id) and they scored host_goals and guest_goals goals respectively.
    -
    - -

     

    -You would like to compute the scores of all teams after all matches. Points are awarded as follows: - -
      -
    • A team receives three points if they win a match (Score strictly more goals than the opponent team).
    • -
    • A team receives one point if they draw a match (Same number of goals as the opponent team).
    • -
    • A team receives no points if they lose a match (Score less goals than the opponent team).
    • -
    - -

    Write an SQL query that selects the team_id, team_name and num_points of each team in the tournament after all described matches. Result table should be ordered by num_points (decreasing order). In case of a tie, order the records by team_id (increasing order).

    - -

    The query result format is in the following example:

    - -
    -Teams table:
    -+-----------+--------------+
    -| team_id   | team_name    |
    -+-----------+--------------+
    -| 10        | Leetcode FC  |
    -| 20        | NewYork FC   |
    -| 30        | Atlanta FC   |
    -| 40        | Chicago FC   |
    -| 50        | Toronto FC   |
    -+-----------+--------------+
    -
    -Matches table:
    -+------------+--------------+---------------+-------------+--------------+
    -| match_id   | host_team    | guest_team    | host_goals  | guest_goals  |
    -+------------+--------------+---------------+-------------+--------------+
    -| 1          | 10           | 20            | 3           | 0            |
    -| 2          | 30           | 10            | 2           | 2            |
    -| 3          | 10           | 50            | 5           | 1            |
    -| 4          | 20           | 30            | 1           | 0            |
    -| 5          | 50           | 30            | 1           | 0            |
    -+------------+--------------+---------------+-------------+--------------+
    -
    -Result table:
    -+------------+--------------+---------------+
    -| team_id    | team_name    | num_points    |
    -+------------+--------------+---------------+
    -| 10         | Leetcode FC  | 7             |
    -| 20         | NewYork FC   | 3             |
    -| 50         | Toronto FC   | 3             |
    -| 30         | Atlanta FC   | 1             |
    -| 40         | Chicago FC   | 0             |
    -+------------+--------------+---------------+
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/teemo-attacking/README.md b/problems/teemo-attacking/README.md index fe46ccef2..96399dae9 100644 --- a/problems/teemo-attacking/README.md +++ b/problems/teemo-attacking/README.md @@ -50,6 +50,7 @@ Ashe is poisoned for seconds 1, 2, and 3, which is 3 seconds in total. ### Related Topics [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Similar Questions 1. [Merge Intervals](../merge-intervals) (Medium) diff --git a/problems/tenth-line/README.md b/problems/tenth-line/README.md index 3b07a0e65..ef6093c1d 100644 --- a/problems/tenth-line/README.md +++ b/problems/tenth-line/README.md @@ -39,3 +39,6 @@ Line 10
    Note:
    1. If the file contains less than 10 lines, what should you output?
    2. There's at least three different solutions. Try to explore all possibilities.
    + +### Related Topics + [[Shell](../../tag/shell/README.md)] diff --git a/problems/ternary-expression-parser/README.md b/problems/ternary-expression-parser/README.md index 2a4a1a0fd..e1706988a 100644 --- a/problems/ternary-expression-parser/README.md +++ b/problems/ternary-expression-parser/README.md @@ -11,62 +11,12 @@ ## [439. Ternary Expression Parser (Medium)](https://leetcode.com/problems/ternary-expression-parser "三元表达式解析器") -

    Given a string representing arbitrarily nested ternary expressions, calculate the result of the expression. You can always assume that the given expression is valid and only consists of digits 0-9, ?, :, T and F (T and F represent True and False respectively). -

    Note: -

      -
    1. The length of the given string is ≤ 10000.
    2. -
    3. Each number will contain only one digit.
    4. -
    5. The conditional expressions group right-to-left (as usual in most languages).
    6. -
    7. The condition will always be either T or F. That is, the condition will never be a digit.
    8. -
    9. The result of the expression will always evaluate to either a digit 0-9, T or F.
    10. -
    -

    - -

    -Example 1: -

    -Input: "T?2:3"
    -
    -Output: "2"
    -
    -Explanation: If true, then result is 2; otherwise result is 3.
    -
    -

    - -

    -Example 2: -

    -Input: "F?1:T?4:5"
    -
    -Output: "4"
    -
    -Explanation: The conditional expressions group right-to-left. Using parenthesis, it is read/evaluated as:
    -
    -             "(F ? 1 : (T ? 4 : 5))"                   "(F ? 1 : (T ? 4 : 5))"
    -          -> "(F ? 1 : 4)"                 or       -> "(T ? 4 : 5)"
    -          -> "4"                                    -> "4"
    -
    -

    - -

    -Example 3: -

    -Input: "T?T?F:5:3"
    -
    -Output: "F"
    -
    -Explanation: The conditional expressions group right-to-left. Using parenthesis, it is read/evaluated as:
    -
    -             "(T ? (T ? F : 5) : 3)"                   "(T ? (T ? F : 5) : 3)"
    -          -> "(T ? F : 3)"                 or       -> "(T ? F : 5)"
    -          -> "F"                                    -> "F"
    -
    -

    ### Related Topics [[Stack](../../tag/stack/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Mini Parser](../mini-parser) (Medium) diff --git a/problems/text-justification/README.md b/problems/text-justification/README.md index e0aa410b7..775a3c692 100644 --- a/problems/text-justification/README.md +++ b/problems/text-justification/README.md @@ -79,3 +79,4 @@ Note that the second line is also left-justified becase it contains only one wor ### Related Topics [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/the-dining-philosophers/README.md b/problems/the-dining-philosophers/README.md index 297fcfa94..7736dfd1b 100644 --- a/problems/the-dining-philosophers/README.md +++ b/problems/the-dining-philosophers/README.md @@ -57,3 +57,6 @@ output[i] = [a, b, c] (three integers)
    • 1 <= n <= 60
    + +### Related Topics + [[Concurrency](../../tag/concurrency/README.md)] diff --git a/problems/the-earliest-and-latest-rounds-where-players-compete/README.md b/problems/the-earliest-and-latest-rounds-where-players-compete/README.md new file mode 100644 index 000000000..3ac0a467c --- /dev/null +++ b/problems/the-earliest-and-latest-rounds-where-players-compete/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../merge-triplets-to-form-target-triplet "Merge Triplets to Form Target Triplet") +                 +[Next >](../find-a-peak-element-ii "Find a Peak Element II") + +## [1900. The Earliest and Latest Rounds Where Players Compete (Hard)](https://leetcode.com/problems/the-earliest-and-latest-rounds-where-players-compete "最佳运动员的比拼回合") + +

    There is a tournament where n players are participating. The players are standing in a single row and are numbered from 1 to n based on their initial standing position (player 1 is the first player in the row, player 2 is the second player in the row, etc.).

    + +

    The tournament consists of multiple rounds (starting from round number 1). In each round, the ith player from the front of the row competes against the ith player from the end of the row, and the winner advances to the next round. When the number of players is odd for the current round, the player in the middle automatically advances to the next round.

    + +
      +
    • For example, if the row consists of players 1, 2, 4, 6, 7 +
        +
      • Player 1 competes against player 7.
      • +
      • Player 2 competes against player 6.
      • +
      • Player 4 automatically advances to the next round.
      • +
      +
    • +
    + +

    After each round is over, the winners are lined back up in the row based on the original ordering assigned to them initially (ascending order).

    + +

    The players numbered firstPlayer and secondPlayer are the best in the tournament. They can win against any other player before they compete against each other. If any two other players compete against each other, either of them might win, and thus you may choose the outcome of this round.

    + +

    Given the integers n, firstPlayer, and secondPlayer, return an integer array containing two values, the earliest possible round number and the latest possible round number in which these two players will compete against each other, respectively.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 11, firstPlayer = 2, secondPlayer = 4
    +Output: [3,4]
    +Explanation:
    +One possible scenario which leads to the earliest round number:
    +First round: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
    +Second round: 2, 3, 4, 5, 6, 11
    +Third round: 2, 3, 4
    +One possible scenario which leads to the latest round number:
    +First round: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
    +Second round: 1, 2, 3, 4, 5, 6
    +Third round: 1, 2, 4
    +Fourth round: 2, 4
    +
    + +

    Example 2:

    + +
    +Input: n = 5, firstPlayer = 1, secondPlayer = 5
    +Output: [1,1]
    +Explanation: The players numbered 1 and 5 compete in the first round.
    +There is no way to make them compete in any other round.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 28
    • +
    • 1 <= firstPlayer < secondPlayer <= n
    • +
    + +### Related Topics + [[Memoization](../../tag/memoization/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Brute force using bitmasks and simulate the rounds. +
    + +
    +Hint 2 +Calculate each state one time and save its solution. +
    diff --git a/problems/the-earliest-moment-when-everyone-become-friends/README.md b/problems/the-earliest-moment-when-everyone-become-friends/README.md index 1d17ee123..25a50004f 100644 --- a/problems/the-earliest-moment-when-everyone-become-friends/README.md +++ b/problems/the-earliest-moment-when-everyone-become-friends/README.md @@ -11,48 +11,11 @@ ## [1101. The Earliest Moment When Everyone Become Friends (Medium)](https://leetcode.com/problems/the-earliest-moment-when-everyone-become-friends "彼此熟识的最早时间") -

    In a social group, there are N people, with unique integer ids from 0 to N-1.

    -

    We have a list of logs, where each logs[i] = [timestamp, id_A, id_B] contains a non-negative integer timestamp, and the ids of two different people.

    - -

    Each log represents the time in which two different people became friends.  Friendship is symmetric: if A is friends with B, then B is friends with A.

    - -

    Let's say that person A is acquainted with person B if A is friends with B, or A is a friend of someone acquainted with B.

    - -

    Return the earliest time for which every person became acquainted with every other person. Return -1 if there is no such earliest time.

    - -

     

    - -

    Example 1:

    - -
    -Input: logs = [[20190101,0,1],[20190104,3,4],[20190107,2,3],[20190211,1,5],[20190224,2,4],[20190301,0,3],[20190312,1,2],[20190322,4,5]], N = 6
    -Output: 20190301
    -Explanation: 
    -The first event occurs at timestamp = 20190101 and after 0 and 1 become friends we have the following friendship groups [0,1], [2], [3], [4], [5].
    -The second event occurs at timestamp = 20190104 and after 3 and 4 become friends we have the following friendship groups [0,1], [2], [3,4], [5].
    -The third event occurs at timestamp = 20190107 and after 2 and 3 become friends we have the following friendship groups [0,1], [2,3,4], [5].
    -The fourth event occurs at timestamp = 20190211 and after 1 and 5 become friends we have the following friendship groups [0,1,5], [2,3,4].
    -The fifth event occurs at timestamp = 20190224 and as 2 and 4 are already friend anything happens.
    -The sixth event occurs at timestamp = 20190301 and after 0 and 3 become friends we have that all become friends.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= N <= 100
    2. -
    3. 1 <= logs.length <= 10^4
    4. -
    5. 0 <= logs[i][0] <= 10^9
    6. -
    7. 0 <= logs[i][1], logs[i][2] <= N - 1
    8. -
    9. It's guaranteed that all timestamps in logs[i][0] are different.
    10. -
    11. Logs are not necessarily ordered by some criteria.
    12. -
    13. logs[i][1] != logs[i][2]
    14. -
    ### Related Topics [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions 1. [Number of Provinces](../number-of-provinces) (Medium) diff --git a/problems/the-k-strongest-values-in-an-array/README.md b/problems/the-k-strongest-values-in-an-array/README.md index 8ff4ad6ae..944e8d4cd 100644 --- a/problems/the-k-strongest-values-in-an-array/README.md +++ b/problems/the-k-strongest-values-in-an-array/README.md @@ -76,8 +76,9 @@ Any permutation of [11,8,6,6,7] is accepted. ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/README.md b/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/README.md index 391b6fcfd..b65772ab3 100644 --- a/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/README.md +++ b/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/README.md @@ -74,6 +74,7 @@
     
    ### Related Topics + [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Hints diff --git a/problems/the-k-weakest-rows-in-a-matrix/README.md b/problems/the-k-weakest-rows-in-a-matrix/README.md index 0ce7840ee..7b28b9018 100644 --- a/problems/the-k-weakest-rows-in-a-matrix/README.md +++ b/problems/the-k-weakest-rows-in-a-matrix/README.md @@ -77,6 +77,9 @@ The rows ordered from weakest to strongest are [0,2,3,1]. ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/the-latest-login-in-2020/README.md b/problems/the-latest-login-in-2020/README.md new file mode 100644 index 000000000..eb9ffbf02 --- /dev/null +++ b/problems/the-latest-login-in-2020/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../minimum-space-wasted-from-packaging "Minimum Space Wasted From Packaging") +                 +[Next >](../cutting-ribbons "Cutting Ribbons") + +## [1890. The Latest Login in 2020 (Easy)](https://leetcode.com/problems/the-latest-login-in-2020 "2020年最后一次登录") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/the-latest-login-in-2020/mysql_schemas.sql b/problems/the-latest-login-in-2020/mysql_schemas.sql new file mode 100644 index 000000000..feda94477 --- /dev/null +++ b/problems/the-latest-login-in-2020/mysql_schemas.sql @@ -0,0 +1,11 @@ +Create table If Not Exists Logins (user_id int, time_stamp datetime); +Truncate table Logins; +insert into Logins (user_id, time_stamp) values ('6', '2020-06-30 15:06:07'); +insert into Logins (user_id, time_stamp) values ('6', '2021-04-21 14:06:06'); +insert into Logins (user_id, time_stamp) values ('6', '2019-03-07 00:18:15'); +insert into Logins (user_id, time_stamp) values ('8', '2020-02-01 05:10:53'); +insert into Logins (user_id, time_stamp) values ('8', '2020-12-30 00:46:50'); +insert into Logins (user_id, time_stamp) values ('2', '2020-01-16 02:49:50'); +insert into Logins (user_id, time_stamp) values ('2', '2019-08-25 07:59:08'); +insert into Logins (user_id, time_stamp) values ('14', '2019-07-14 09:00:00'); +insert into Logins (user_id, time_stamp) values ('14', '2021-01-06 11:59:59'); diff --git a/problems/the-maze-ii/README.md b/problems/the-maze-ii/README.md index 9f26c256a..79d9ed0f7 100644 --- a/problems/the-maze-ii/README.md +++ b/problems/the-maze-ii/README.md @@ -11,67 +11,14 @@ ## [505. The Maze II (Medium)](https://leetcode.com/problems/the-maze-ii "迷宫 II") -

    There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up, down, left or right, but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction.

    -

    Given the ball's start position, the destination and the maze, find the shortest distance for the ball to stop at the destination. The distance is defined by the number of empty spaces traveled by the ball from the start position (excluded) to the destination (included). If the ball cannot stop at the destination, return -1.

    - -

    The maze is represented by a binary 2D array. 1 means the wall and 0 means the empty space. You may assume that the borders of the maze are all walls. The start and destination coordinates are represented by row and column indexes.

    - -

     

    - -

    Example 1:

    - -
    Input 1: a maze represented by a 2D array
    -
    -0 0 1 0 0
    -0 0 0 0 0
    -0 0 0 1 0
    -1 1 0 1 1
    -0 0 0 0 0
    -
    -Input 2: start coordinate (rowStart, colStart) = (0, 4)
    -Input 3: destination coordinate (rowDest, colDest) = (4, 4)
    -
    -Output: 12
    -
    -Explanation: One shortest way is : left -> down -> left -> down -> right -> down -> right.
    -             The total distance is 1 + 1 + 3 + 1 + 2 + 2 + 2 = 12.
    -
    -
    - -

    Example 2:

    - -
    Input 1: a maze represented by a 2D array
    -
    -0 0 1 0 0
    -0 0 0 0 0
    -0 0 0 1 0
    -1 1 0 1 1
    -0 0 0 0 0
    -
    -Input 2: start coordinate (rowStart, colStart) = (0, 4)
    -Input 3: destination coordinate (rowDest, colDest) = (3, 2)
    -
    -Output: -1
    -
    -Explanation: There is no way for the ball to stop at the destination.
    -
    -
    - -

     

    - -

    Note:

    - -
      -
    1. There is only one ball and one destination in the maze.
    2. -
    3. Both the ball and the destination exist on an empty space, and they will not be at the same position initially.
    4. -
    5. The given maze does not contain border (like the red rectangle in the example pictures), but you could assume the border of the maze are all walls.
    6. -
    7. The maze contains at least 2 empty spaces, and both the width and height of the maze won't exceed 100.
    8. -
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [The Maze](../the-maze) (Medium) diff --git a/problems/the-maze-iii/README.md b/problems/the-maze-iii/README.md index 7be1d3db1..3cedf2c18 100644 --- a/problems/the-maze-iii/README.md +++ b/problems/the-maze-iii/README.md @@ -11,71 +11,14 @@ ## [499. The Maze III (Hard)](https://leetcode.com/problems/the-maze-iii "迷宫 III") -

    There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up (u), down (d), left (l) or right (r), but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction. There is also a hole in this maze. The ball will drop into the hole if it rolls on to the hole.

    -

    Given the ball position, the hole position and the maze, find out how the ball could drop into the hole by moving the shortest distance. The distance is defined by the number of empty spaces traveled by the ball from the start position (excluded) to the hole (included). Output the moving directions by using 'u', 'd', 'l' and 'r'. Since there could be several different shortest ways, you should output the lexicographically smallest way. If the ball cannot reach the hole, output "impossible".

    - -

    The maze is represented by a binary 2D array. 1 means the wall and 0 means the empty space. You may assume that the borders of the maze are all walls. The ball and the hole coordinates are represented by row and column indexes.

    - -

     

    - -

    Example 1:

    - -
    -Input 1: a maze represented by a 2D array
    -
    -0 0 0 0 0
    -1 1 0 0 1
    -0 0 0 0 0
    -0 1 0 0 1
    -0 1 0 0 0
    -
    -Input 2: ball coordinate (rowBall, colBall) = (4, 3)
    -Input 3: hole coordinate (rowHole, colHole) = (0, 1)
    -
    -Output: "lul"
    -
    -Explanation: There are two shortest ways for the ball to drop into the hole.
    -The first way is left -> up -> left, represented by "lul".
    -The second way is up -> left, represented by 'ul'.
    -Both ways have shortest distance 6, but the first way is lexicographically smaller because 'l' < 'u'. So the output is "lul".
    -
    -
    - -

    Example 2:

    - -
    -Input 1: a maze represented by a 2D array
    -
    -0 0 0 0 0
    -1 1 0 0 1
    -0 0 0 0 0
    -0 1 0 0 1
    -0 1 0 0 0
    -
    -Input 2: ball coordinate (rowBall, colBall) = (4, 3)
    -Input 3: hole coordinate (rowHole, colHole) = (3, 0)
    -
    -Output: "impossible"
    -
    -Explanation: The ball cannot reach the hole.
    -
    -
    - -

     

    - -

    Note:

    - -
      -
    1. There is only one ball and one hole in the maze.
    2. -
    3. Both the ball and hole exist on an empty space, and they will not be at the same position initially.
    4. -
    5. The given maze does not contain border (like the red rectangle in the example pictures), but you could assume the border of the maze are all walls.
    6. -
    7. The maze contains at least 2 empty spaces, and the width and the height of the maze won't exceed 30.
    8. -
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [The Maze](../the-maze) (Medium) diff --git a/problems/the-maze/README.md b/problems/the-maze/README.md index 2086ae8c2..0b56c410d 100644 --- a/problems/the-maze/README.md +++ b/problems/the-maze/README.md @@ -11,66 +11,12 @@ ## [490. The Maze (Medium)](https://leetcode.com/problems/the-maze "迷宫") -

    There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up, down, left or right, but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction.

    -

    Given the ball's start position, the destination and the maze, determine whether the ball could stop at the destination.

    - -

    The maze is represented by a binary 2D array. 1 means the wall and 0 means the empty space. You may assume that the borders of the maze are all walls. The start and destination coordinates are represented by row and column indexes.

    - -

     

    - -

    Example 1:

    - -
    Input 1: a maze represented by a 2D array
    -
    -0 0 1 0 0
    -0 0 0 0 0
    -0 0 0 1 0
    -1 1 0 1 1
    -0 0 0 0 0
    -
    -Input 2: start coordinate (rowStart, colStart) = (0, 4)
    -Input 3: destination coordinate (rowDest, colDest) = (4, 4)
    -
    -Output: true
    -
    -Explanation: One possible way is : left -> down -> left -> down -> right -> down -> right.
    -
    -
    - -

    Example 2:

    - -
    Input 1: a maze represented by a 2D array
    -
    -0 0 1 0 0
    -0 0 0 0 0
    -0 0 0 1 0
    -1 1 0 1 1
    -0 0 0 0 0
    -
    -Input 2: start coordinate (rowStart, colStart) = (0, 4)
    -Input 3: destination coordinate (rowDest, colDest) = (3, 2)
    -
    -Output: false
    -
    -Explanation: There is no way for the ball to stop at the destination.
    -
    -
    - -

     

    - -

    Note:

    - -
      -
    1. There is only one ball and one destination in the maze.
    2. -
    3. Both the ball and the destination exist on an empty space, and they will not be at the same position initially.
    4. -
    5. The given maze does not contain border (like the red rectangle in the example pictures), but you could assume the border of the maze are all walls.
    6. -
    7. The maze contains at least 2 empty spaces, and both the width and height of the maze won't exceed 100.
    8. -
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] ### Similar Questions 1. [The Maze III](../the-maze-iii) (Hard) diff --git a/problems/the-most-frequently-ordered-products-for-each-customer/README.md b/problems/the-most-frequently-ordered-products-for-each-customer/README.md index 7098dc503..dce0cb341 100644 --- a/problems/the-most-frequently-ordered-products-for-each-customer/README.md +++ b/problems/the-most-frequently-ordered-products-for-each-customer/README.md @@ -12,3 +12,6 @@ ## [1596. The Most Frequently Ordered Products for Each Customer (Medium)](https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer "每位顾客最经常订购的商品") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/the-most-recent-orders-for-each-product/README.md b/problems/the-most-recent-orders-for-each-product/README.md index c1fff2051..0510140e3 100644 --- a/problems/the-most-recent-orders-for-each-product/README.md +++ b/problems/the-most-recent-orders-for-each-product/README.md @@ -12,3 +12,6 @@ ## [1549. The Most Recent Orders for Each Product (Medium)](https://leetcode.com/problems/the-most-recent-orders-for-each-product "每件商品的最新订单") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/the-most-recent-three-orders/README.md b/problems/the-most-recent-three-orders/README.md index 4beb62cb8..6aac9ec6b 100644 --- a/problems/the-most-recent-three-orders/README.md +++ b/problems/the-most-recent-three-orders/README.md @@ -12,3 +12,6 @@ ## [1532. The Most Recent Three Orders (Medium)](https://leetcode.com/problems/the-most-recent-three-orders "最近的三笔订单") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/the-number-of-employees-which-report-to-each-employee/README.md b/problems/the-number-of-employees-which-report-to-each-employee/README.md index 290bbfb6c..7900b68ce 100644 --- a/problems/the-number-of-employees-which-report-to-each-employee/README.md +++ b/problems/the-number-of-employees-which-report-to-each-employee/README.md @@ -12,3 +12,6 @@ ## [1731. The Number of Employees Which Report to Each Employee (Easy)](https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee "每位经理的下属员工数量") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/the-number-of-full-rounds-you-have-played/README.md b/problems/the-number-of-full-rounds-you-have-played/README.md new file mode 100644 index 000000000..fc09fbe71 --- /dev/null +++ b/problems/the-number-of-full-rounds-you-have-played/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../largest-odd-number-in-string "Largest Odd Number in String") +                 +[Next >](../count-sub-islands "Count Sub Islands") + +## [1904. The Number of Full Rounds You Have Played (Medium)](https://leetcode.com/problems/the-number-of-full-rounds-you-have-played "你完成的完整对局数") + +

    A new online video game has been released, and in this video game, there are 15-minute rounds scheduled every quarter-hour period. This means that at HH:00, HH:15, HH:30 and HH:45, a new round starts, where HH represents an integer number from 00 to 23. A 24-hour clock is used, so the earliest time in the day is 00:00 and the latest is 23:59.

    + +

    Given two strings startTime and finishTime in the format "HH:MM" representing the exact time you started and finished playing the game, respectively, calculate the number of full rounds that you played during your game session.

    + +
      +
    • For example, if startTime = "05:20" and finishTime = "05:59" this means you played only one full round from 05:30 to 05:45. You did not play the full round from 05:15 to 05:30 because you started after the round began, and you did not play the full round from 05:45 to 06:00 because you stopped before the round ended.
    • +
    + +

    If finishTime is earlier than startTime, this means you have played overnight (from startTime to the midnight and from midnight to finishTime).

    + +

    Return the number of full rounds that you have played if you had started playing at startTime and finished at finishTime.

    + +

     

    +

    Example 1:

    + +
    +Input: startTime = "12:01", finishTime = "12:44"
    +Output: 1
    +Explanation: You played one full round from 12:15 to 12:30.
    +You did not play the full round from 12:00 to 12:15 because you started playing at 12:01 after it began.
    +You did not play the full round from 12:30 to 12:45 because you stopped playing at 12:44 before it ended.
    +
    + +

    Example 2:

    + +
    +Input: startTime = "20:00", finishTime = "06:00"
    +Output: 40
    +Explanation: You played 16 full rounds from 20:00 to 00:00 and 24 full rounds from 00:00 to 06:00.
    +16 + 24 = 40.
    +
    + +

    Example 3:

    + +
    +Input: startTime = "00:00", finishTime = "23:59"
    +Output: 95
    +Explanation: You played 4 full rounds each hour except for the last hour where you played 3 full rounds.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • startTime and finishTime are in the format HH:MM.
    • +
    • 00 <= HH <= 23
    • +
    • 00 <= MM <= 59
    • +
    • startTime and finishTime are not equal.
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Consider the day as 48 hours instead of 24. +
    + +
    +Hint 2 +For each round check if you were playing. +
    diff --git a/problems/the-skyline-problem/README.md b/problems/the-skyline-problem/README.md index 23d15b9c8..80dc279c6 100644 --- a/problems/the-skyline-problem/README.md +++ b/problems/the-skyline-problem/README.md @@ -56,11 +56,13 @@ Figure B shows the skyline formed by those buildings. The red points in figure B ### Related Topics - [[Heap](../../tag/heap/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] [[Line Sweep](../../tag/line-sweep/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Falling Squares](../falling-squares) (Hard) diff --git a/problems/third-maximum-number/README.md b/problems/third-maximum-number/README.md index 8f5da7966..a5e43960b 100644 --- a/problems/third-maximum-number/README.md +++ b/problems/third-maximum-number/README.md @@ -52,6 +52,7 @@ Both numbers with value 2 are both considered as second maximum. ### Related Topics [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Kth Largest Element in an Array](../kth-largest-element-in-an-array) (Medium) diff --git a/problems/three-equal-parts/README.md b/problems/three-equal-parts/README.md index 93e627f70..847224192 100644 --- a/problems/three-equal-parts/README.md +++ b/problems/three-equal-parts/README.md @@ -46,6 +46,5 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/throne-inheritance/README.md b/problems/throne-inheritance/README.md index d19545da8..ac0c68e26 100644 --- a/problems/throne-inheritance/README.md +++ b/problems/throne-inheritance/README.md @@ -82,7 +82,9 @@ t.getInheritanceOrder(); // return ["king", "andy", "ma ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/time-based-key-value-store/README.md b/problems/time-based-key-value-store/README.md index bb0d03f42..e931d5f10 100644 --- a/problems/time-based-key-value-store/README.md +++ b/problems/time-based-key-value-store/README.md @@ -11,63 +11,49 @@ ## [981. Time Based Key-Value Store (Medium)](https://leetcode.com/problems/time-based-key-value-store "基于时间的键值存储") -

    Create a timebased key-value store class TimeMap, that supports two operations.

    +

    Design a time-based key-value data structure that can store multiple values for the same key at different time stamps and retrieve the key's value at a certain timestamp.

    -

    1. set(string key, string value, int timestamp)

    +

    Implement the TimeMap class:

      -
    • Stores the key and value, along with the given timestamp.
    • -
    - -

    2. get(string key, int timestamp)

    - -
      -
    • Returns a value such that set(key, value, timestamp_prev) was called previously, with timestamp_prev <= timestamp.
    • -
    • If there are multiple such values, it returns the one with the largest timestamp_prev.
    • -
    • If there are no values, it returns the empty string ("").
    • +
    • TimeMap() Initializes the object of the data structure.
    • +
    • void set(String key, String value, int timestamp) Stores the key key with the value value at the given time timestamp.
    • +
    • String get(String key, int timestamp) Returns a value such that set was called previously, with timestamp_prev <= timestamp. If there are multiple such values, it returns the value associated with the largest timestamp_prev. If there are no values, it returns "".

     

    - -

    Example 1:

    -Input: inputs = ["TimeMap","set","get","get","set","get","get"], inputs = [[],["foo","bar",1],["foo",1],["foo",3],["foo","bar2",4],["foo",4],["foo",5]]
    -Output: [null,null,"bar","bar",null,"bar2","bar2"]
    -Explanation:   
    -TimeMap kv;   
    -kv.set("foo", "bar", 1); // store the key "foo" and value "bar" along with timestamp = 1   
    -kv.get("foo", 1);  // output "bar"   
    -kv.get("foo", 3); // output "bar" since there is no value corresponding to foo at timestamp 3 and timestamp 2, then the only value is at timestamp 1 ie "bar"   
    -kv.set("foo", "bar2", 4);   
    -kv.get("foo", 4); // output "bar2"   
    -kv.get("foo", 5); //output "bar2"   
    -
    -
    - -
    -

    Example 2:

    - -
    -Input: inputs = ["TimeMap","set","set","get","get","get","get","get"], inputs = [[],["love","high",10],["love","low",20],["love",5],["love",10],["love",15],["love",20],["love",25]]
    -Output: [null,null,null,"","high","high","low","low"]
    +Input
    +["TimeMap", "set", "get", "get", "set", "get", "get"]
    +[[], ["foo", "bar", 1], ["foo", 1], ["foo", 3], ["foo", "bar2", 4], ["foo", 4], ["foo", 5]]
    +Output
    +[null, null, "bar", "bar", null, "bar2", "bar2"]
    +
    +Explanation
    +TimeMap timeMap = new TimeMap();
    +timeMap.set("foo", "bar", 1);  // store the key "foo" and value "bar" along with timestamp = 1.
    +timeMap.get("foo", 1);         // return "bar"
    +timeMap.get("foo", 3);         // return "bar", since there is no value corresponding to foo at timestamp 3 and timestamp 2, then the only value is at timestamp 1 is "bar".
    +timeMap.set("foo", "bar2", 4); // store the key "foo" and value "ba2r" along with timestamp = 4.
    +timeMap.get("foo", 4);         // return "bar2"
    +timeMap.get("foo", 5);         // return "bar2"
     
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. All key/value strings are lowercase.
    2. -
    3. All key/value strings have length in the range [1, 100]
    4. -
    5. The timestamps for all TimeMap.set operations are strictly increasing.
    6. -
    7. 1 <= timestamp <= 10^7
    8. -
    9. TimeMap.set and TimeMap.get functions will be called a total of 120000 times (combined) per test case.
    10. -
    +
      +
    • 1 <= key.length, value.length <= 100
    • +
    • key and value consist of lowercase English letters and digits.
    • +
    • 1 <= timestamp <= 107
    • +
    • All the timestamps timestamp of set are strictly increasing.
    • +
    • At most 2 * 105 calls will be made to set and get.
    • +
    ### Related Topics + [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/time-needed-to-inform-all-employees/README.md b/problems/time-needed-to-inform-all-employees/README.md index 9877175c0..c7127d925 100644 --- a/problems/time-needed-to-inform-all-employees/README.md +++ b/problems/time-needed-to-inform-all-employees/README.md @@ -86,7 +86,9 @@ The third minute they will inform the rest of employees. ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Hints
    diff --git a/problems/toeplitz-matrix/README.md b/problems/toeplitz-matrix/README.md index d1f65f188..65ec493f2 100644 --- a/problems/toeplitz-matrix/README.md +++ b/problems/toeplitz-matrix/README.md @@ -56,6 +56,7 @@ The diagonal "[1, 2]" has different elements. ### Related Topics [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Valid Word Square](../valid-word-square) (Easy) diff --git a/problems/top-k-frequent-elements/README.md b/problems/top-k-frequent-elements/README.md index c27e248aa..ac17ea0c6 100644 --- a/problems/top-k-frequent-elements/README.md +++ b/problems/top-k-frequent-elements/README.md @@ -34,8 +34,14 @@

    Follow up: Your algorithm's time complexity must be better than O(n log n), where n is the array's size.

    ### Related Topics - [[Heap](../../tag/heap/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Bucket Sort](../../tag/bucket-sort/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Quickselect](../../tag/quickselect/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Word Frequency](../word-frequency) (Medium) diff --git a/problems/top-k-frequent-words/README.md b/problems/top-k-frequent-words/README.md index 6cf53e341..db4cbf356 100644 --- a/problems/top-k-frequent-words/README.md +++ b/problems/top-k-frequent-words/README.md @@ -46,9 +46,13 @@

    ### Related Topics - [[Heap](../../tag/heap/README.md)] [[Trie](../../tag/trie/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Bucket Sort](../../tag/bucket-sort/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Top K Frequent Elements](../top-k-frequent-elements) (Medium) diff --git a/problems/top-travellers/README.md b/problems/top-travellers/README.md index f5041022a..bd370a2a9 100644 --- a/problems/top-travellers/README.md +++ b/problems/top-travellers/README.md @@ -11,78 +11,7 @@ ## [1407. Top Travellers (Easy)](https://leetcode.com/problems/top-travellers "排名靠前的旅行者") -

    Table: Users

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| id            | int     |
    -| name          | varchar |
    -+---------------+---------+
    -id is the primary key for this table.
    -name is the name of the user.
    -
    - -

    Table: Rides

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| id            | int     |
    -| user_id       | int     |
    -| distance      | int     |
    -+---------------+---------+
    -id is the primary key for this table.
    -city_id is the id of the city who bought the product "product_name".
    -
    - -Write an SQL query to report the distance travelled by each user. -Return the result table ordered by travelled_distance in descending order, if two or more users travelled the same distance, order them by their name in ascending order. -The query result format is in the following example. -
    -Users table:
    -+------+-----------+
    -| id   | name      |
    -+------+-----------+
    -| 1    | Alice     |
    -| 2    | Bob       |
    -| 3    | Alex      |
    -| 4    | Donald    |
    -| 7    | Lee       |
    -| 13   | Jonathan  |
    -| 19   | Elvis     |
    -+------+-----------+
    -
    -Rides table:
    -+------+----------+----------+
    -| id   | user_id  | distance |
    -+------+----------+----------+
    -| 1    | 1        | 120      |
    -| 2    | 2        | 317      |
    -| 3    | 3        | 222      |
    -| 4    | 7        | 100      |
    -| 5    | 13       | 312      |
    -| 6    | 19       | 50       |
    -| 7    | 7        | 120      |
    -| 8    | 19       | 400      |
    -| 9    | 7        | 230      |
    -+------+----------+----------+
    -
    -Result table:
    -+----------+--------------------+
    -| name     | travelled_distance |
    -+----------+--------------------+
    -| Elvis    | 450                |
    -| Lee      | 450                |
    -| Bob      | 317                |
    -| Jonathan | 312                |
    -| Alex     | 222                |
    -| Alice    | 120                |
    -| Donald   | 0                  |
    -+----------+--------------------+
    -Elvis and Lee travelled 450 miles, Elvis is the top traveller as his name is alphabetically smaller than Lee.
    -Bob, Jonathan, Alex and Alice have only one ride and we just order them by the total distances of the ride.
    -Donald didn't have any rides, the distance travelled by him is 0.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/toss-strange-coins/README.md b/problems/toss-strange-coins/README.md index 2960a6347..1def74644 100644 --- a/problems/toss-strange-coins/README.md +++ b/problems/toss-strange-coins/README.md @@ -11,31 +11,12 @@ ## [1230. Toss Strange Coins (Medium)](https://leetcode.com/problems/toss-strange-coins "抛掷硬币") -

    You have some coins.  The i-th coin has a probability prob[i] of facing heads when tossed.

    - -

    Return the probability that the number of coins facing heads equals target if you toss every coin exactly once.

    - -

     

    -

    Example 1:

    -
    Input: prob = [0.4], target = 1
    -Output: 0.40000
    -

    Example 2:

    -
    Input: prob = [0.5,0.5,0.5,0.5,0.5], target = 0
    -Output: 0.03125
    -
    -

     

    -

    Constraints:

    - -
      -
    • 1 <= prob.length <= 1000
    • -
    • 0 <= prob[i] <= 1
    • -
    • 0 <= target <= prob.length
    • -
    • Answers will be accepted as correct if they are within 10^-5 of the correct answer.
    • -
    + ### Related Topics [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Probability and Statistics](../../tag/probability-and-statistics/README.md)] ### Hints
    diff --git a/problems/total-hamming-distance/README.md b/problems/total-hamming-distance/README.md index cee36ec35..10ba9cf7d 100644 --- a/problems/total-hamming-distance/README.md +++ b/problems/total-hamming-distance/README.md @@ -44,6 +44,8 @@ HammingDistance(4, 14) + HammingDistance(4, 2) + HammingDistance(14, 2) = 2 + 2 ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Hamming Distance](../hamming-distance) (Easy) diff --git a/problems/total-sales-amount-by-year/README.md b/problems/total-sales-amount-by-year/README.md index 87ed722ca..67ca7eee6 100644 --- a/problems/total-sales-amount-by-year/README.md +++ b/problems/total-sales-amount-by-year/README.md @@ -11,70 +11,7 @@ ## [1384. Total Sales Amount by Year (Hard)](https://leetcode.com/problems/total-sales-amount-by-year "按年度列出销售总额") -

    Table: Product

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| product_id    | int     |
    -| product_name  | varchar |
    -+---------------+---------+
    -product_id is the primary key for this table.
    -product_name is the name of the product.
    -
    - -

    Table: Sales

    -
    -+---------------------+---------+
    -| Column Name         | Type    |
    -+---------------------+---------+
    -| product_id          | int     |
    -| period_start        | varchar |
    -| period_end          | date    |
    -| average_daily_sales | int     |
    -+---------------------+---------+
    -product_id is the primary key for this table. 
    -period_start and period_end indicates the start and end date for sales period, both dates are inclusive.
    -The average_daily_sales column holds the average daily sales amount of the items for the period.
    -
    -Write an SQL query to report the Total sales amount of each item for each year, with corresponding product name, product_id, product_name and report_year. -Dates of the sales years are between 2018 to 2020. Return the result table ordered by product_id and report_year. - -The query result format is in the following example: - -
    -Product table:
    -+------------+--------------+
    -| product_id | product_name |
    -+------------+--------------+
    -| 1          | LC Phone     |
    -| 2          | LC T-Shirt   |
    -| 3          | LC Keychain  |
    -+------------+--------------+
    -
    -Sales table:
    -+------------+--------------+-------------+---------------------+
    -| product_id | period_start | period_end  | average_daily_sales |
    -+------------+--------------+-------------+---------------------+
    -| 1          | 2019-01-25   | 2019-02-28  | 100                 |
    -| 2          | 2018-12-01   | 2020-01-01  | 10                  |
    -| 3          | 2019-12-01   | 2020-01-31  | 1                   |
    -+------------+--------------+-------------+---------------------+
    -
    -Result table:
    -+------------+--------------+-------------+--------------+
    -| product_id | product_name | report_year | total_amount |
    -+------------+--------------+-------------+--------------+
    -| 1          | LC Phone     |    2019     | 3500         |
    -| 2          | LC T-Shirt   |    2018     | 310          |
    -| 2          | LC T-Shirt   |    2019     | 3650         |
    -| 2          | LC T-Shirt   |    2020     | 10           |
    -| 3          | LC Keychain  |    2019     | 31           |
    -| 3          | LC Keychain  |    2020     | 31           |
    -+------------+--------------+-------------+--------------+
    -LC Phone was sold for the period of 2019-01-25 to 2019-02-28, and there are 35 days for this period. Total amount 35*100 = 3500. 
    -LC T-shirt was sold for the period of 2018-12-01 to 2020-01-01, and there are 31, 365, 1 days for years 2018, 2019 and 2020 respectively.
    -LC Keychain was sold for the period of 2019-12-01 to 2020-01-31, and there are 31, 31 days for years 2019 and 2020 respectively.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/tournament-winners/README.md b/problems/tournament-winners/README.md index d7c5485cd..d41452330 100644 --- a/problems/tournament-winners/README.md +++ b/problems/tournament-winners/README.md @@ -11,78 +11,7 @@ ## [1194. Tournament Winners (Hard)](https://leetcode.com/problems/tournament-winners "锦标赛优胜者") -

    Table: Players

    -
    -+-------------+-------+
    -| Column Name | Type  |
    -+-------------+-------+
    -| player_id   | int   |
    -| group_id    | int   |
    -+-------------+-------+
    -player_id is the primary key of this table.
    -Each row of this table indicates the group of each player.
    -
    -

    Table: Matches

    - -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| match_id      | int     |
    -| first_player  | int     |
    -| second_player | int     | 
    -| first_score   | int     |
    -| second_score  | int     |
    -+---------------+---------+
    -match_id is the primary key of this table.
    -Each row is a record of a match, first_player and second_player contain the player_id of each match.
    -first_score and second_score contain the number of points of the first_player and second_player respectively.
    -You may assume that, in each match, players belongs to the same group.
    -
    - -

     

    - -

    The winner in each group is the player who scored the maximum total points within the group. In the case of a tie, the lowest player_id wins.

    - -

    Write an SQL query to find the winner in each group.

    - -

    The query result format is in the following example:

    - -
    -Players table:
    -+-----------+------------+
    -| player_id | group_id   |
    -+-----------+------------+
    -| 15        | 1          |
    -| 25        | 1          |
    -| 30        | 1          |
    -| 45        | 1          |
    -| 10        | 2          |
    -| 35        | 2          |
    -| 50        | 2          |
    -| 20        | 3          |
    -| 40        | 3          |
    -+-----------+------------+
    -
    -Matches table:
    -+------------+--------------+---------------+-------------+--------------+
    -| match_id   | first_player | second_player | first_score | second_score |
    -+------------+--------------+---------------+-------------+--------------+
    -| 1          | 15           | 45            | 3           | 0            |
    -| 2          | 30           | 25            | 1           | 2            |
    -| 3          | 30           | 15            | 2           | 0            |
    -| 4          | 40           | 20            | 5           | 2            |
    -| 5          | 35           | 50            | 1           | 1            |
    -+------------+--------------+---------------+-------------+--------------+
    -
    -Result table:
    -+-----------+------------+
    -| group_id  | player_id  |
    -+-----------+------------+ 
    -| 1         | 15         |
    -| 2         | 35         |
    -| 3         | 40         |
    -+-----------+------------+
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/traffic-light-controlled-intersection/README.md b/problems/traffic-light-controlled-intersection/README.md index e27e50ea7..3ceebb3e1 100644 --- a/problems/traffic-light-controlled-intersection/README.md +++ b/problems/traffic-light-controlled-intersection/README.md @@ -11,63 +11,7 @@ ## [1279. Traffic Light Controlled Intersection (Easy)](https://leetcode.com/problems/traffic-light-controlled-intersection "红绿灯路口") -There is an intersection of two roads. First road is road A where cars travel from North to South in direction 1 and from South to North in direction 2. Second road is road B where cars travel from West to East in direction 3 and from East to West in direction 4. -There is a traffic light located on each road before the intersection. A traffic light can either be green or red. -1. Green means cars can cross the intersection in both directions of the road. -- Red means cars in both directions cannot cross the intersection and must wait until the light turns green. - -The traffic lights cannot be green on both roads at the same time. That means when the light is green on road A, it is red on road B and when the light is green on road B, it is red on road A. - -Initially, the traffic light is green on road A and red on road B. When the light is green on one road, all cars can cross the intersection in both directions until the light becomes green on the other road. No two cars traveling on different roads should cross at the same time. - -Design a deadlock-free traffic light controlled system at this intersection. - -Implement the function void carArrived(carId, roadId, direction, turnGreen, crossCar) where: - -- carId is the id of the car that arrived. -- roadId is the id of the road that the car travels on. -- direction is the direction of the car. -- turnGreen is a function you can call to turn the traffic light to green on the current road. -- crossCar is a function you can call to let the current car cross the intersection. - -Your answer is considered correct if it avoids cars deadlock in the intersection. Turning the light green on a road when it was already green is considered a wrong answer. - -

    Example 1:

    -
    -Input: cars = [1,3,5,2,4], directions = [2,1,2,4,3], arrivalTimes = [10,20,30,40,50]
    -Output: [
    -"Car 1 Has Passed Road A In Direction 2",    // Traffic light on road A is green, car 1 can cross the intersection.
    -"Car 3 Has Passed Road A In Direction 1",    // Car 3 crosses the intersection as the light is still green.
    -"Car 5 Has Passed Road A In Direction 2",    // Car 5 crosses the intersection as the light is still green.
    -"Traffic Light On Road B Is Green",          // Car 2 requests green light for road B.
    -"Car 2 Has Passed Road B In Direction 4",    // Car 2 crosses as the light is green on road B now.
    -"Car 4 Has Passed Road B In Direction 3"     // Car 4 crosses the intersection as the light is still green.
    -]
    -
    - -

    Example 2:

    -
    -Input: cars = [1,2,3,4,5], directions = [2,4,3,3,1], arrivalTimes = [10,20,30,40,40]
    -Output: [
    -"Car 1 Has Passed Road A In Direction 2",    // Traffic light on road A is green, car 1 can cross the intersection.
    -"Traffic Light On Road B Is Green",          // Car 2 requests green light for road B.
    -"Car 2 Has Passed Road B In Direction 4",    // Car 2 crosses as the light is green on road B now.
    -"Car 3 Has Passed Road B In Direction 3",    // Car 3 crosses as the light is green on road B now.
    -"Traffic Light On Road A Is Green",          // Car 5 requests green light for road A.
    -"Car 5 Has Passed Road A In Direction 1",    // Car 5 crosses as the light is green on road A now.
    -"Traffic Light On Road B Is Green",          // Car 4 requests green light for road B. Car 4 blocked until car 5 crosses and then traffic light is green on road B.
    -"Car 4 Has Passed Road B In Direction 3"     // Car 4 crosses as the light is green on road B now.
    -]
    -Explanation: This is a dead-lock free scenario. Note that the scenario when car 4 crosses before turning light into green on road A and allowing car 5 to pass is also correct and Accepted scenario.
    -
    - -Constraints: - -- 1 <= cars.length <= 20 -- cars.length = directions.length -- cars.length = arrivalTimes.length -- All values of cars are unique -- 1 <= directions[i] <= 4 -- arrivalTimes is non-decreasing +### Related Topics + [[Concurrency](../../tag/concurrency/README.md)] diff --git a/problems/transform-to-chessboard/README.md b/problems/transform-to-chessboard/README.md index 2b0a8f71b..4230baade 100644 --- a/problems/transform-to-chessboard/README.md +++ b/problems/transform-to-chessboard/README.md @@ -11,48 +11,51 @@ ## [782. Transform to Chessboard (Hard)](https://leetcode.com/problems/transform-to-chessboard "变为棋盘") -

    An N x N board contains only 0s and 1s. In each move, you can swap any 2 rows with each other, or any 2 columns with each other.

    +

    You are given an n x n binary grid board. In each move, you can swap any two rows with each other, or any two columns with each other.

    -

    What is the minimum number of moves to transform the board into a "chessboard" - a board where no 0s and no 1s are 4-directionally adjacent? If the task is impossible, return -1.

    +

    Return the minimum number of moves to transform the board into a chessboard board. If the task is impossible, return -1.

    +

    A chessboard board is a board where no 0's and no 1's are 4-directionally adjacent.

    + +

     

    +

    Example 1:

    +
    -Examples:
     Input: board = [[0,1,1,0],[0,1,1,0],[1,0,0,1],[1,0,0,1]]
     Output: 2
    -Explanation:
    -One potential sequence of moves is shown below, from left to right:
    -
    -0110     1010     1010
    -0110 --> 1010 --> 0101
    -1001     0101     1010
    -1001     0101     0101
    -
    +Explanation: One potential sequence of moves is shown.
     The first move swaps the first and second column.
     The second move swaps the second and third row.
    +
    - -Input: board = [[0, 1], [1, 0]] +

    Example 2:

    + +
    +Input: board = [[0,1],[1,0]]
     Output: 0
    -Explanation:
    -Also note that the board with 0 in the top left corner,
    -01
    -10
    -
    -is also a valid chessboard.
    +Explanation: Also note that the board with 0 in the top left corner, is also a valid chessboard.
    +
    -Input: board = [[1, 0], [1, 0]] +

    Example 3:

    + +
    +Input: board = [[1,0],[1,0]]
     Output: -1
    -Explanation:
    -No matter what sequence of moves you make, you cannot end with a valid chessboard.
    +Explanation: No matter what sequence of moves you make, you cannot end with a valid chessboard.
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • board will have the same number of rows and columns, a number in the range [2, 30].
    • -
    • board[i][j] will be only 0s or 1s.
    • +
    • n == board.length
    • +
    • n == board[i].length
    • +
    • 2 <= n <= 30
    • +
    • board[i][j] is either 0 or 1.
    ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/transpose-file/README.md b/problems/transpose-file/README.md index 7c56747f8..dfc56ba85 100644 --- a/problems/transpose-file/README.md +++ b/problems/transpose-file/README.md @@ -31,3 +31,6 @@ ryan 30 name alice ryan age 21 30 + +### Related Topics + [[Shell](../../tag/shell/README.md)] diff --git a/problems/transpose-matrix/README.md b/problems/transpose-matrix/README.md index adbc9403d..1afcf2daa 100644 --- a/problems/transpose-matrix/README.md +++ b/problems/transpose-matrix/README.md @@ -45,6 +45,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/trapping-rain-water-ii/README.md b/problems/trapping-rain-water-ii/README.md index 7e2950b97..a3c0155fd 100644 --- a/problems/trapping-rain-water-ii/README.md +++ b/problems/trapping-rain-water-ii/README.md @@ -42,8 +42,10 @@ The total volume of water trapped is 4. ### Related Topics - [[Heap](../../tag/heap/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Trapping Rain Water](../trapping-rain-water) (Hard) diff --git a/problems/trapping-rain-water/README.md b/problems/trapping-rain-water/README.md index eebeecd03..17ea35c4e 100644 --- a/problems/trapping-rain-water/README.md +++ b/problems/trapping-rain-water/README.md @@ -43,6 +43,7 @@ [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Similar Questions 1. [Container With Most Water](../container-with-most-water) (Medium) diff --git a/problems/tree-diameter/README.md b/problems/tree-diameter/README.md index d3956a758..d927e855f 100644 --- a/problems/tree-diameter/README.md +++ b/problems/tree-diameter/README.md @@ -11,47 +11,12 @@ ## [1245. Tree Diameter (Medium)](https://leetcode.com/problems/tree-diameter "树的直径") -

    Given an undirected tree, return its diameter: the number of edges in a longest path in that tree.

    -

    The tree is given as an array of edges where edges[i] = [u, v] is a bidirectional edge between nodes u and v.  Each node has labels in the set {0, 1, ..., edges.length}.

    - -

     

    -

    Example 1:

    - -

    - -
    -Input: edges = [[0,1],[0,2]]
    -Output: 2
    -Explanation: 
    -A longest path of the tree is the path 1 - 0 - 2.
    -
    - -

    Example 2:

    - -

    - -
    -Input: edges = [[0,1],[1,2],[2,3],[1,4],[4,5]]
    -Output: 4
    -Explanation: 
    -A longest path of the tree is the path 3 - 2 - 1 - 4 - 5.
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 0 <= edges.length < 10^4
    • -
    • edges[i][0] != edges[i][1]
    • -
    • 0 <= edges[i][j] <= edges.length
    • -
    • The given edges form an undirected tree.
    • -
    ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Hints
    diff --git a/problems/tree-node/README.md b/problems/tree-node/README.md index 287a26c57..b0d94d495 100644 --- a/problems/tree-node/README.md +++ b/problems/tree-node/README.md @@ -11,68 +11,10 @@ ## [608. Tree Node (Medium)](https://leetcode.com/problems/tree-node "树节点") -

    Given a table tree, id is identifier of the tree node and p_id is its parent node's id.

    -
    -+----+------+
    -| id | p_id |
    -+----+------+
    -| 1  | null |
    -| 2  | 1    |
    -| 3  | 1    |
    -| 4  | 2    |
    -| 5  | 2    |
    -+----+------+
    -
    -Each node in the tree can be one of three types: -
      -
    • Leaf: if the node is a leaf node.
    • -
    • Root: if the node is the root of the tree.
    • -
    • Inner: If the node is neither a leaf node nor a root node.
    • -
    - -

     

    -Write a query to print the node id and the type of the node. Sort your output by the node id. The result for the above sample is: - -

     

    - -
    -+----+------+
    -| id | Type |
    -+----+------+
    -| 1  | Root |
    -| 2  | Inner|
    -| 3  | Leaf |
    -| 4  | Leaf |
    -| 5  | Leaf |
    -+----+------+
    -
    - -

     

    - -

    Explanation

    - -

     

    - -
      -
    • Node '1' is root node, because its parent node is NULL and it has child node '2' and '3'.
    • -
    • Node '2' is inner node, because it has parent node '1' and child node '4' and '5'.
    • -
    • Node '3', '4' and '5' is Leaf node, because they have parent node and they don't have child node.
    • -
      -
    • And here is the image of the sample tree as below: -

       

      -
      -			  1
      -			/   \
      -                      2       3
      -                    /   \
      -                  4       5
      -
      -

      Note

      -

      If there is only one node on the tree, you only need to output its root attributes.

      -
    • -
    +### Related Topics + [[Database](../../tag/database/README.md)] ### Hints
    diff --git a/problems/tree-of-coprimes/README.md b/problems/tree-of-coprimes/README.md index 5939557a2..d1a8325d0 100644 --- a/problems/tree-of-coprimes/README.md +++ b/problems/tree-of-coprimes/README.md @@ -62,8 +62,8 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Math](../../tag/math/README.md)] ### Hints diff --git a/problems/triangle-judgement/README.md b/problems/triangle-judgement/README.md index 481277048..38b9fa8fc 100644 --- a/problems/triangle-judgement/README.md +++ b/problems/triangle-judgement/README.md @@ -11,26 +11,7 @@ ## [610. Triangle Judgement (Easy)](https://leetcode.com/problems/triangle-judgement "判断三角形") -A pupil Tim gets homework to identify whether three line segments could possibly form a triangle. -

     

    -However, this assignment is very heavy because there are hundreds of records to calculate. -

     

    -Could you help Tim by writing a query to judge whether these three sides can form a triangle, assuming table triangle holds the length of the three sides x, y and z. -

     

    - -
    -| x  | y  | z  |
    -|----|----|----|
    -| 13 | 15 | 30 |
    -| 10 | 20 | 15 |
    -
    -For the sample data above, your query should return the follow result: - -
    -| x  | y  | z  | triangle |
    -|----|----|----|----------|
    -| 13 | 15 | 30 | No       |
    -| 10 | 20 | 15 | Yes      |
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/trim-a-binary-search-tree/README.md b/problems/trim-a-binary-search-tree/README.md index cbeb41662..1062536dd 100644 --- a/problems/trim-a-binary-search-tree/README.md +++ b/problems/trim-a-binary-search-tree/README.md @@ -64,4 +64,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Recursion](../../tag/recursion/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/triples-with-bitwise-and-equal-to-zero/README.md b/problems/triples-with-bitwise-and-equal-to-zero/README.md index c2fffb1e2..70d948809 100644 --- a/problems/triples-with-bitwise-and-equal-to-zero/README.md +++ b/problems/triples-with-bitwise-and-equal-to-zero/README.md @@ -52,4 +52,6 @@ ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/trips-and-users/README.md b/problems/trips-and-users/README.md index 742673df0..51d276090 100644 --- a/problems/trips-and-users/README.md +++ b/problems/trips-and-users/README.md @@ -114,3 +114,6 @@ On 2013-10-03: - Hence there are 2 unbanned request in total, 1 of which were canceled. - The Cancellation Rate is (1 / 2) = 0.50 + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/truncate-sentence/README.md b/problems/truncate-sentence/README.md index facb980f3..73f173b14 100644 --- a/problems/truncate-sentence/README.md +++ b/problems/truncate-sentence/README.md @@ -60,6 +60,7 @@ Hence, you should return "What is the solution". ### Related Topics + [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] ### Hints diff --git a/problems/tweet-counts-per-frequency/README.md b/problems/tweet-counts-per-frequency/README.md index 6fbe1b6ba..f928815fb 100644 --- a/problems/tweet-counts-per-frequency/README.md +++ b/problems/tweet-counts-per-frequency/README.md @@ -70,3 +70,7 @@ tweetCounts.getTweetCountsPerFrequency("hour", "tweet3", 0, ### Related Topics [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/two-city-scheduling/README.md b/problems/two-city-scheduling/README.md index 949c11d5d..840a932d5 100644 --- a/problems/two-city-scheduling/README.md +++ b/problems/two-city-scheduling/README.md @@ -56,3 +56,5 @@ The total minimum cost is 10 + 30 + 50 + 20 = 110 to have half the people interv ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/two-sum-bsts/README.md b/problems/two-sum-bsts/README.md index 85389f582..a3b009268 100644 --- a/problems/two-sum-bsts/README.md +++ b/problems/two-sum-bsts/README.md @@ -11,41 +11,16 @@ ## [1214. Two Sum BSTs (Medium)](https://leetcode.com/problems/two-sum-bsts "查找两棵二叉搜索树之和") -

    Given two binary search trees, return True if and only if there is a node in the first tree and a node in the second tree whose values sum up to a given integer target.

    -

     

    - -

    Example 1:

    - -

    - -
    -Input: root1 = [2,1,4], root2 = [1,0,3], target = 5
    -Output: true
    -Explanation: 2 and 3 sum up to 5.
    -
    - -
    -

    Example 2:

    - -

    - -
    -Input: root1 = [0,-10,10], root2 = [5,1,7,0,2], target = 18
    -Output: false
    -
    - -

     

    - -

    Note:

    - -
      -
    1. Each tree has at most 5000 nodes.
    2. -
    3. -10^9 <= target, node.val <= 10^9
    4. -
    ### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Two Sum IV - Input is a BST](../two-sum-iv-input-is-a-bst) (Easy) diff --git a/problems/two-sum-iii-data-structure-design/README.md b/problems/two-sum-iii-data-structure-design/README.md index 6f9ad83c8..c0bf033b3 100644 --- a/problems/two-sum-iii-data-structure-design/README.md +++ b/problems/two-sum-iii-data-structure-design/README.md @@ -11,29 +11,14 @@ ## [170. Two Sum III - Data structure design (Easy)](https://leetcode.com/problems/two-sum-iii-data-structure-design "两数之和 III - 数据结构设计") -

    Design and implement a TwoSum class. It should support the following operations: add and find.

    -

    add - Add the number to an internal data structure.
    -find - Find if there exists any pair of numbers which sum is equal to the value.

    - -

    Example 1:

    - -
    -add(1); add(3); add(5);
    -find(4) -> true
    -find(7) -> false
    -
    - -

    Example 2:

    - -
    -add(3); add(1); add(2);
    -find(3) -> true
    -find(6) -> false
    ### Related Topics [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] ### Similar Questions 1. [Two Sum](../two-sum) (Easy) diff --git a/problems/two-sum-iv-input-is-a-bst/README.md b/problems/two-sum-iv-input-is-a-bst/README.md index cb1473fad..4f5748895 100644 --- a/problems/two-sum-iv-input-is-a-bst/README.md +++ b/problems/two-sum-iv-input-is-a-bst/README.md @@ -61,6 +61,12 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Two Sum](../two-sum) (Easy) diff --git a/problems/two-sum-less-than-k/README.md b/problems/two-sum-less-than-k/README.md index 0c8c8d768..02e621696 100644 --- a/problems/two-sum-less-than-k/README.md +++ b/problems/two-sum-less-than-k/README.md @@ -11,42 +11,13 @@ ## [1099. Two Sum Less Than K (Easy)](https://leetcode.com/problems/two-sum-less-than-k "小于 K 的两数之和") -

    Given an array A of integers and integer K, return the maximum S such that there exists i < j with A[i] + A[j] = S and S < K. If no i, j exist satisfying this equation, return -1.

    -

     

    - -

    Example 1:

    - -
    -Input: A = [34,23,1,24,75,33,54,8], K = 60
    -Output: 58
    -Explanation: 
    -We can use 34 and 24 to sum 58 which is less than 60.
    -
    - -

    Example 2:

    - -
    -Input: A = [10,20,30], K = 15
    -Output: -1
    -Explanation: 
    -In this case it's not possible to get a pair sum less that 15.
    -
    - -

     

    - -

    Note:

    - -
      -
    1. 1 <= A.length <= 100
    2. -
    3. 1 <= A[i] <= 1000
    4. -
    5. 1 <= K <= 2000
    6. -
    ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Two Sum](../two-sum) (Easy) diff --git a/problems/ugly-number-ii/README.md b/problems/ugly-number-ii/README.md index edc46d6a0..0b62a037d 100644 --- a/problems/ugly-number-ii/README.md +++ b/problems/ugly-number-ii/README.md @@ -40,9 +40,10 @@ ### Related Topics - [[Heap](../../tag/heap/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Merge k Sorted Lists](../merge-k-sorted-lists) (Hard) diff --git a/problems/ugly-number-iii/README.md b/problems/ugly-number-iii/README.md index 2b5350514..b08dd80e8 100644 --- a/problems/ugly-number-iii/README.md +++ b/problems/ugly-number-iii/README.md @@ -59,6 +59,7 @@ ### Related Topics [[Math](../../tag/math/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Number Theory](../../tag/number-theory/README.md)] ### Hints
    diff --git a/problems/uncommon-words-from-two-sentences/README.md b/problems/uncommon-words-from-two-sentences/README.md index 01b9a51bd..f94135705 100644 --- a/problems/uncommon-words-from-two-sentences/README.md +++ b/problems/uncommon-words-from-two-sentences/README.md @@ -11,46 +11,30 @@ ## [884. Uncommon Words from Two Sentences (Easy)](https://leetcode.com/problems/uncommon-words-from-two-sentences "两句话中的不常见单词") -

    We are given two sentences s1 and s2.  (A sentence is a string of space separated words.  Each word consists only of lowercase letters.)

    +

    A sentence is a string of single-space separated words where each word consists only of lowercase letters.

    -

    A word is uncommon if it appears exactly once in one of the sentences, and does not appear in the other sentence.

    +

    A word is uncommon if it appears exactly once in one of the sentences, and does not appear in the other sentence.

    -

    Return a list of all uncommon words. 

    - -

    You may return the list in any order.

    +

    Given two sentences s1 and s2, return a list of all the uncommon words. You may return the answer in any order.

     

    - -
      -
    - -

    Example 1:

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

    Example 2:

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

    Example 2:

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

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 0 <= s1.length <= 200
    2. -
    3. 0 <= s2.length <= 200
    4. -
    5. s1 and s2 both contain only spaces and lowercase letters.
    6. -
    -
    -
    +
      +
    • 1 <= s1.length, s2.length <= 200
    • +
    • s1 and s2 consist of lowercase English letters and spaces.
    • +
    • s1 and s2 do not have leading or trailing spaces.
    • +
    • All the words in s1 and s2 are separated by a single space.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/uncrossed-lines/README.md b/problems/uncrossed-lines/README.md index 036421171..a76b32605 100644 --- a/problems/uncrossed-lines/README.md +++ b/problems/uncrossed-lines/README.md @@ -64,6 +64,7 @@ We cannot draw 3 uncrossed lines, because the line from nums1[1]=4 to nums2[2]=4 ### Related Topics [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Edit Distance](../edit-distance) (Hard) diff --git a/problems/unique-binary-search-trees-ii/README.md b/problems/unique-binary-search-trees-ii/README.md index b4b0445f3..8fcad49b8 100644 --- a/problems/unique-binary-search-trees-ii/README.md +++ b/problems/unique-binary-search-trees-ii/README.md @@ -37,7 +37,10 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Unique Binary Search Trees](../unique-binary-search-trees) (Medium) diff --git a/problems/unique-binary-search-trees/README.md b/problems/unique-binary-search-trees/README.md index ab550f3e7..a4a346d4b 100644 --- a/problems/unique-binary-search-trees/README.md +++ b/problems/unique-binary-search-trees/README.md @@ -37,7 +37,10 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Unique Binary Search Trees II](../unique-binary-search-trees-ii) (Medium) diff --git a/problems/unique-email-addresses/README.md b/problems/unique-email-addresses/README.md index 736b95979..06949920b 100644 --- a/problems/unique-email-addresses/README.md +++ b/problems/unique-email-addresses/README.md @@ -62,4 +62,6 @@ ### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/unique-morse-code-words/README.md b/problems/unique-morse-code-words/README.md index 8e1e415dc..7d9e9758b 100644 --- a/problems/unique-morse-code-words/README.md +++ b/problems/unique-morse-code-words/README.md @@ -45,4 +45,6 @@ There are 2 different transformations, "--...-." and "--...--.&qu ### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/unique-number-of-occurrences/README.md b/problems/unique-number-of-occurrences/README.md index 76f5b3b37..ba609788c 100644 --- a/problems/unique-number-of-occurrences/README.md +++ b/problems/unique-number-of-occurrences/README.md @@ -44,6 +44,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] ### Hints diff --git a/problems/unique-orders-and-customers-per-month/README.md b/problems/unique-orders-and-customers-per-month/README.md index d45872da8..3bf932182 100644 --- a/problems/unique-orders-and-customers-per-month/README.md +++ b/problems/unique-orders-and-customers-per-month/README.md @@ -12,3 +12,6 @@ ## [1565. Unique Orders and Customers Per Month (Easy)](https://leetcode.com/problems/unique-orders-and-customers-per-month "按月统计订单数与顾客数") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/unique-paths-ii/README.md b/problems/unique-paths-ii/README.md index c3a8fee74..7ebd71fff 100644 --- a/problems/unique-paths-ii/README.md +++ b/problems/unique-paths-ii/README.md @@ -51,6 +51,7 @@ There are two ways to reach the bottom-right corner: ### Related Topics [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Unique Paths](../unique-paths) (Medium) diff --git a/problems/unique-paths-iii/README.md b/problems/unique-paths-iii/README.md index 8b7cb2be0..0f64c0b7d 100644 --- a/problems/unique-paths-iii/README.md +++ b/problems/unique-paths-iii/README.md @@ -69,8 +69,10 @@ Note that the starting and ending square can be anywhere in the grid. ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Sudoku Solver](../sudoku-solver) (Hard) diff --git a/problems/unique-paths/README.md b/problems/unique-paths/README.md index c120d1906..8aaef9e07 100644 --- a/problems/unique-paths/README.md +++ b/problems/unique-paths/README.md @@ -60,8 +60,9 @@ From the top-left corner, there are a total of 3 ways to reach the bottom-right ### Related Topics - [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Combinatorics](../../tag/combinatorics/README.md)] ### Similar Questions 1. [Unique Paths II](../unique-paths-ii) (Medium) diff --git a/problems/unique-substrings-in-wraparound-string/README.md b/problems/unique-substrings-in-wraparound-string/README.md index af0cabc08..e9ff09c60 100644 --- a/problems/unique-substrings-in-wraparound-string/README.md +++ b/problems/unique-substrings-in-wraparound-string/README.md @@ -53,6 +53,7 @@ Explanation: Only the substring "a" of p is in s. ### Related Topics + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/unique-word-abbreviation/README.md b/problems/unique-word-abbreviation/README.md index 1320ace22..6c43bb1ba 100644 --- a/problems/unique-word-abbreviation/README.md +++ b/problems/unique-word-abbreviation/README.md @@ -11,42 +11,13 @@ ## [288. Unique Word Abbreviation (Medium)](https://leetcode.com/problems/unique-word-abbreviation "单词的唯一缩写") -

    An abbreviation of a word follows the form <first letter><number><last letter>. Below are some examples of word abbreviations:

    -
    -a) it                      --> it    (no abbreviation)
    -
    -     1
    -     ↓
    -b) d|o|g                   --> d1g
    -
    -              1    1  1
    -     1---5----0----5--8
    -     ↓   ↓    ↓    ↓  ↓    
    -c) i|nternationalizatio|n  --> i18n
    -
    -              1
    -     1---5----0
    -     ↓   ↓    ↓
    -d) l|ocalizatio|n          --> l10n
    -
    - -

    Assume you have a dictionary and given a word, find whether its abbreviation is unique in the dictionary. A word's abbreviation is unique if no other word from the dictionary has the same abbreviation.

    - -

    Example:

    - -
    -Given dictionary = [ "deer", "door", "cake", "card" ]
    -
    -isUnique("dear") -> false
    -isUnique("cart") -> true
    -isUnique("cane") -> false
    -isUnique("make") -> true
    -
    ### Related Topics [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Two Sum III - Data structure design](../two-sum-iii-data-structure-design) (Easy) diff --git a/problems/univalued-binary-tree/README.md b/problems/univalued-binary-tree/README.md index 4a371806e..178433960 100644 --- a/problems/univalued-binary-tree/README.md +++ b/problems/univalued-binary-tree/README.md @@ -44,3 +44,6 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/unpopular-books/README.md b/problems/unpopular-books/README.md index afc51d30b..21a3899ce 100644 --- a/problems/unpopular-books/README.md +++ b/problems/unpopular-books/README.md @@ -11,71 +11,7 @@ ## [1098. Unpopular Books (Medium)](https://leetcode.com/problems/unpopular-books "小众书籍") -

    Table: Books

    -
    -+----------------+---------+
    -| Column Name    | Type    |
    -+----------------+---------+
    -| book_id        | int     |
    -| name           | varchar |
    -| available_from | date    |
    -+----------------+---------+
    -book_id is the primary key of this table.
    -
    -

    Table: Orders

    - -
    -+----------------+---------+
    -| Column Name    | Type    |
    -+----------------+---------+
    -| order_id       | int     |
    -| book_id        | int     |
    -| quantity       | int     |
    -| dispatch_date  | date    |
    -+----------------+---------+
    -order_id is the primary key of this table.
    -book_id is a foreign key to the Books table.
    -
    - -

     

    - -

    Write an SQL query that reports the books that have sold less than 10 copies in the last year, excluding books that have been available for less than 1 month from today. Assume today is 2019-06-23.

    - -

    The query result format is in the following example:

    - -
    -Books table:
    -+---------+--------------------+----------------+
    -| book_id | name               | available_from |
    -+---------+--------------------+----------------+
    -| 1       | "Kalila And Demna" | 2010-01-01     |
    -| 2       | "28 Letters"       | 2012-05-12     |
    -| 3       | "The Hobbit"       | 2019-06-10     |
    -| 4       | "13 Reasons Why"   | 2019-06-01     |
    -| 5       | "The Hunger Games" | 2008-09-21     |
    -+---------+--------------------+----------------+
    -
    -Orders table:
    -+----------+---------+----------+---------------+
    -| order_id | book_id | quantity | dispatch_date |
    -+----------+---------+----------+---------------+
    -| 1        | 1       | 2        | 2018-07-26    |
    -| 2        | 1       | 1        | 2018-11-05    |
    -| 3        | 3       | 8        | 2019-06-11    |
    -| 4        | 4       | 6        | 2019-06-05    |
    -| 5        | 4       | 5        | 2019-06-20    |
    -| 6        | 5       | 9        | 2009-02-02    |
    -| 7        | 5       | 8        | 2010-04-13    |
    -+----------+---------+----------+---------------+
    -
    -Result table:
    -+-----------+--------------------+
    -| book_id   | name               |
    -+-----------+--------------------+
    -| 1         | "Kalila And Demna" |
    -| 2         | "28 Letters"       |
    -| 5         | "The Hunger Games" |
    -+-----------+--------------------+
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/user-activity-for-the-past-30-days-i/README.md b/problems/user-activity-for-the-past-30-days-i/README.md index 083444f4f..95792cb0e 100644 --- a/problems/user-activity-for-the-past-30-days-i/README.md +++ b/problems/user-activity-for-the-past-30-days-i/README.md @@ -11,53 +11,7 @@ ## [1141. User Activity for the Past 30 Days I (Easy)](https://leetcode.com/problems/user-activity-for-the-past-30-days-i "查询近30天活跃用户数") -

    Table: Activity

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| user_id       | int     |
    -| session_id    | int     |
    -| activity_date | date    |
    -| activity_type | enum    |
    -+---------------+---------+
    -There is no primary key for this table, it may have duplicate rows.
    -The activity_type column is an ENUM of type ('open_session', 'end_session', 'scroll_down', 'send_message').
    -The table shows the user activities for a social media website. 
    -Note that each session belongs to exactly one user.
    -
    -

     

    - -

    Write an SQL query to find the daily active user count for a period of 30 days ending 2019-07-27 inclusively. A user was active on some day if he/she made at least one activity on that day.

    - -

    The query result format is in the following example:

    - -
    -Activity table:
    -+---------+------------+---------------+---------------+
    -| user_id | session_id | activity_date | activity_type |
    -+---------+------------+---------------+---------------+
    -| 1       | 1          | 2019-07-20    | open_session  |
    -| 1       | 1          | 2019-07-20    | scroll_down   |
    -| 1       | 1          | 2019-07-20    | end_session   |
    -| 2       | 4          | 2019-07-20    | open_session  |
    -| 2       | 4          | 2019-07-21    | send_message  |
    -| 2       | 4          | 2019-07-21    | end_session   |
    -| 3       | 2          | 2019-07-21    | open_session  |
    -| 3       | 2          | 2019-07-21    | send_message  |
    -| 3       | 2          | 2019-07-21    | end_session   |
    -| 4       | 3          | 2019-06-25    | open_session  |
    -| 4       | 3          | 2019-06-25    | end_session   |
    -+---------+------------+---------------+---------------+
    -
    -Result table:
    -+------------+--------------+ 
    -| day        | active_users |
    -+------------+--------------+ 
    -| 2019-07-20 | 2            |
    -| 2019-07-21 | 2            |
    -+------------+--------------+ 
    -Note that we do not care about days with zero active users.
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/user-activity-for-the-past-30-days-ii/README.md b/problems/user-activity-for-the-past-30-days-ii/README.md index c24c48957..6205e3968 100644 --- a/problems/user-activity-for-the-past-30-days-ii/README.md +++ b/problems/user-activity-for-the-past-30-days-ii/README.md @@ -11,53 +11,7 @@ ## [1142. User Activity for the Past 30 Days II (Easy)](https://leetcode.com/problems/user-activity-for-the-past-30-days-ii "过去30天的用户活动 II") -

    Table: Activity

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| user_id       | int     |
    -| session_id    | int     |
    -| activity_date | date    |
    -| activity_type | enum    |
    -+---------------+---------+
    -There is no primary key for this table, it may have duplicate rows.
    -The activity_type column is an ENUM of type ('open_session', 'end_session', 'scroll_down', 'send_message').
    -The table shows the user activities for a social media website.
    -Note that each session belongs to exactly one user.
    -

     

    - -

    Write an SQL query to find the average number of sessions per user for a period of 30 days ending 2019-07-27 inclusively, rounded to 2 decimal places. The sessions we want to count for a user are those with at least one activity in that time period.

    - -

    The query result format is in the following example:

    - -
    -Activity table:
    -+---------+------------+---------------+---------------+
    -| user_id | session_id | activity_date | activity_type |
    -+---------+------------+---------------+---------------+
    -| 1       | 1          | 2019-07-20    | open_session  |
    -| 1       | 1          | 2019-07-20    | scroll_down   |
    -| 1       | 1          | 2019-07-20    | end_session   |
    -| 2       | 4          | 2019-07-20    | open_session  |
    -| 2       | 4          | 2019-07-21    | send_message  |
    -| 2       | 4          | 2019-07-21    | end_session   |
    -| 3       | 2          | 2019-07-21    | open_session  |
    -| 3       | 2          | 2019-07-21    | send_message  |
    -| 3       | 2          | 2019-07-21    | end_session   |
    -| 3       | 5          | 2019-07-21    | open_session  |
    -| 3       | 5          | 2019-07-21    | scroll_down   |
    -| 3       | 5          | 2019-07-21    | end_session   |
    -| 4       | 3          | 2019-06-25    | open_session  |
    -| 4       | 3          | 2019-06-25    | end_session   |
    -+---------+------------+---------------+---------------+
    -
    -Result table:
    -+---------------------------+ 
    -| average_sessions_per_user |
    -+---------------------------+ 
    -| 1.33                      |
    -+---------------------------+ 
    -User 1 and 2 each had 1 session in the past 30 days while user 3 had 2 sessions so the average is (1 + 1 + 2) / 3 = 1.33.
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/user-purchase-platform/README.md b/problems/user-purchase-platform/README.md index 74e191305..fa18b2dc4 100644 --- a/problems/user-purchase-platform/README.md +++ b/problems/user-purchase-platform/README.md @@ -11,49 +11,7 @@ ## [1127. User Purchase Platform (Hard)](https://leetcode.com/problems/user-purchase-platform "用户购买平台") -

    Table: Spending

    -
    -+-------------+---------+
    -| Column Name | Type    |
    -+-------------+---------+
    -| user_id     | int     |
    -| spend_date  | date    |
    -| platform    | enum    | 
    -| amount      | int     |
    -+-------------+---------+
    -The table logs the spendings history of users that make purchases from an online shopping website which has a desktop and a mobile application.
    -(user_id, spend_date, platform) is the primary key of this table.
    -The platform column is an ENUM type of ('desktop', 'mobile').
    -
    -

    Write an SQL query to find the total number of users and the total amount spent using mobile only, desktop only and both mobile and desktop together for each date.

    - -

    The query result format is in the following example:

    - -
    -Spending table:
    -+---------+------------+----------+--------+
    -| user_id | spend_date | platform | amount |
    -+---------+------------+----------+--------+
    -| 1       | 2019-07-01 | mobile   | 100    |
    -| 1       | 2019-07-01 | desktop  | 100    |
    -| 2       | 2019-07-01 | mobile   | 100    |
    -| 2       | 2019-07-02 | mobile   | 100    |
    -| 3       | 2019-07-01 | desktop  | 100    |
    -| 3       | 2019-07-02 | desktop  | 100    |
    -+---------+------------+----------+--------+
    -
    -Result table:
    -+------------+----------+--------------+-------------+
    -| spend_date | platform | total_amount | total_users |
    -+------------+----------+--------------+-------------+
    -| 2019-07-01 | desktop  | 100          | 1           |
    -| 2019-07-01 | mobile   | 100          | 1           |
    -| 2019-07-01 | both     | 200          | 1           |
    -| 2019-07-02 | desktop  | 100          | 1           |
    -| 2019-07-02 | mobile   | 100          | 1           |
    -| 2019-07-02 | both     | 0            | 0           |
    -+------------+----------+--------------+-------------+ 
    -On 2019-07-01, user 1 purchased using both desktop and mobile, user 2 purchased using mobile only and user 3 purchased using desktop only.
    -On 2019-07-02, user 2 purchased using mobile only, user 3 purchased using desktop only and no one purchased using both platforms.
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/utf-8-validation/README.md b/problems/utf-8-validation/README.md index 2f1d30269..c8677b9f1 100644 --- a/problems/utf-8-validation/README.md +++ b/problems/utf-8-validation/README.md @@ -65,6 +65,7 @@ But the second continuation byte does not start with 10, so it is invalid. ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/valid-anagram/README.md b/problems/valid-anagram/README.md index cc14f2c77..f4b1d90dd 100644 --- a/problems/valid-anagram/README.md +++ b/problems/valid-anagram/README.md @@ -33,8 +33,9 @@

    Follow up: What if the inputs contain Unicode characters? How would you adapt your solution to such a case?

    ### Related Topics - [[Sort](../../tag/sort/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Group Anagrams](../group-anagrams) (Medium) diff --git a/problems/valid-boomerang/README.md b/problems/valid-boomerang/README.md index a1275f407..f7e813c3d 100644 --- a/problems/valid-boomerang/README.md +++ b/problems/valid-boomerang/README.md @@ -33,6 +33,7 @@ ### Related Topics + [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] ### Hints diff --git a/problems/valid-number/README.md b/problems/valid-number/README.md index 785f5bd06..8b6567a68 100644 --- a/problems/valid-number/README.md +++ b/problems/valid-number/README.md @@ -80,7 +80,6 @@ ### Related Topics - [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/valid-palindrome-ii/README.md b/problems/valid-palindrome-ii/README.md index 4effb8af5..192d58d64 100644 --- a/problems/valid-palindrome-ii/README.md +++ b/problems/valid-palindrome-ii/README.md @@ -45,6 +45,8 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/valid-palindrome-iii/README.md b/problems/valid-palindrome-iii/README.md index b9c826790..05e6993f6 100644 --- a/problems/valid-palindrome-iii/README.md +++ b/problems/valid-palindrome-iii/README.md @@ -11,27 +11,7 @@ ## [1216. Valid Palindrome III (Hard)](https://leetcode.com/problems/valid-palindrome-iii "验证回文字符串 III") -

    Given a string s and an integer k, find out if the given string is a K-Palindrome or not.

    -

    A string is K-Palindrome if it can be transformed into a palindrome by removing at most k characters from it.

    - -

     

    -

    Example 1:

    - -
    -Input: s = "abcdeca", k = 2
    -Output: true
    -Explanation: Remove 'b' and 'e' characters.
    -
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= s.length <= 1000
    • -
    • s has only lowercase English letters.
    • -
    • 1 <= k <= s.length
    • -
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/valid-parenthesis-string/README.md b/problems/valid-parenthesis-string/README.md index 93260c4b9..403d3c274 100644 --- a/problems/valid-parenthesis-string/README.md +++ b/problems/valid-parenthesis-string/README.md @@ -42,7 +42,10 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Special Binary String](../special-binary-string) (Hard) diff --git a/problems/valid-permutations-for-di-sequence/README.md b/problems/valid-permutations-for-di-sequence/README.md index 02ebbaa50..78b2eaf4d 100644 --- a/problems/valid-permutations-for-di-sequence/README.md +++ b/problems/valid-permutations-for-di-sequence/README.md @@ -52,5 +52,4 @@ The 5 valid permutations of (0, 1, 2, 3) are:
    ### Related Topics - [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/valid-phone-numbers/README.md b/problems/valid-phone-numbers/README.md index bb41929e2..e12d2952a 100644 --- a/problems/valid-phone-numbers/README.md +++ b/problems/valid-phone-numbers/README.md @@ -33,3 +33,6 @@ 987-123-4567 (123) 456-7890 + +### Related Topics + [[Shell](../../tag/shell/README.md)] diff --git a/problems/valid-square/README.md b/problems/valid-square/README.md index 0eb2d3b7b..b3ff9993f 100644 --- a/problems/valid-square/README.md +++ b/problems/valid-square/README.md @@ -48,4 +48,5 @@ ### Related Topics + [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/valid-sudoku/README.md b/problems/valid-sudoku/README.md index ab5eb36a0..cd18755de 100644 --- a/problems/valid-sudoku/README.md +++ b/problems/valid-sudoku/README.md @@ -70,7 +70,9 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Sudoku Solver](../sudoku-solver) (Hard) diff --git a/problems/valid-tic-tac-toe-state/README.md b/problems/valid-tic-tac-toe-state/README.md index 6915be247..e9993467e 100644 --- a/problems/valid-tic-tac-toe-state/README.md +++ b/problems/valid-tic-tac-toe-state/README.md @@ -67,8 +67,8 @@ Explanation: Players take turns making moves. ### Related Topics - [[Recursion](../../tag/recursion/README.md)] - [[Math](../../tag/math/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Design Tic-Tac-Toe](../design-tic-tac-toe) (Medium) diff --git a/problems/valid-triangle-number/README.md b/problems/valid-triangle-number/README.md index 32b59e907..925813973 100644 --- a/problems/valid-triangle-number/README.md +++ b/problems/valid-triangle-number/README.md @@ -41,7 +41,11 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [3Sum Smaller](../3sum-smaller) (Medium) diff --git a/problems/valid-word-abbreviation/README.md b/problems/valid-word-abbreviation/README.md index b617cabb4..fd25d6922 100644 --- a/problems/valid-word-abbreviation/README.md +++ b/problems/valid-word-abbreviation/README.md @@ -11,38 +11,10 @@ ## [408. Valid Word Abbreviation (Easy)](https://leetcode.com/problems/valid-word-abbreviation "有效单词缩写") -

    -Given a non-empty string s and an abbreviation abbr, return whether the string matches with the given abbreviation. -

    -

    A string such as "word" contains only the following valid abbreviations:

    - -
    ["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"]
    -
    - -

    Notice that only the above abbreviations are valid abbreviations of the string "word". Any other string is not a valid abbreviation of "word".

    - -

    Note:
    -Assume s contains only lowercase letters and abbr contains only lowercase letters and digits. -

    - -

    Example 1:
    -

    -Given s = "internationalization", abbr = "i12iz4n":
    -
    -Return true.
    -
    -

    - -

    Example 2:
    -

    -Given s = "apple", abbr = "a2e":
    -
    -Return false.
    -
    -

    ### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] ### Similar Questions diff --git a/problems/valid-word-square/README.md b/problems/valid-word-square/README.md index 66fd21971..036eceb8f 100644 --- a/problems/valid-word-square/README.md +++ b/problems/valid-word-square/README.md @@ -11,83 +11,11 @@ ## [422. Valid Word Square (Easy)](https://leetcode.com/problems/valid-word-square "有效的单词方块") -

    Given a sequence of words, check whether it forms a valid word square.

    -

    A sequence of words forms a valid word square if the kth row and column read the exact same string, where 0 ≤ k < max(numRows, numColumns).

    -

    Note:
    -

      -
    1. The number of words given is at least 1 and does not exceed 500.
    2. -
    3. Word length will be at least 1 and does not exceed 500.
    4. -
    5. Each word contains only lowercase English alphabet a-z.
    6. -
    -

    - -

    Example 1: -

    -Input:
    -[
    -  "abcd",
    -  "bnrt",
    -  "crmy",
    -  "dtye"
    -]
    -
    -Output:
    -true
    -
    -Explanation:
    -The first row and first column both read "abcd".
    -The second row and second column both read "bnrt".
    -The third row and third column both read "crmy".
    -The fourth row and fourth column both read "dtye".
    -
    -Therefore, it is a valid word square.
    -
    -

    - -

    Example 2: -

    -Input:
    -[
    -  "abcd",
    -  "bnrt",
    -  "crm",
    -  "dt"
    -]
    -
    -Output:
    -true
    -
    -Explanation:
    -The first row and first column both read "abcd".
    -The second row and second column both read "bnrt".
    -The third row and third column both read "crm".
    -The fourth row and fourth column both read "dt".
    -
    -Therefore, it is a valid word square.
    -
    -

    - -

    Example 3: -

    -Input:
    -[
    -  "ball",
    -  "area",
    -  "read",
    -  "lady"
    -]
    -
    -Output:
    -false
    -
    -Explanation:
    -The third row reads "read" while the third column reads "lead".
    -
    -Therefore, it is NOT a valid word square.
    -
    -

    +### Related Topics + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Word Squares](../word-squares) (Hard) diff --git a/problems/validate-binary-search-tree/README.md b/problems/validate-binary-search-tree/README.md index 2ca27ef61..47b796017 100644 --- a/problems/validate-binary-search-tree/README.md +++ b/problems/validate-binary-search-tree/README.md @@ -47,8 +47,9 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Recursion](../../tag/recursion/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Binary Tree Inorder Traversal](../binary-tree-inorder-traversal) (Easy) diff --git a/problems/validate-binary-tree-nodes/README.md b/problems/validate-binary-tree-nodes/README.md index e09236345..c6ad1fd5a 100644 --- a/problems/validate-binary-tree-nodes/README.md +++ b/problems/validate-binary-tree-nodes/README.md @@ -56,7 +56,12 @@ ### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/validate-stack-sequences/README.md b/problems/validate-stack-sequences/README.md index 260c3aa5a..6d2b0d91b 100644 --- a/problems/validate-stack-sequences/README.md +++ b/problems/validate-stack-sequences/README.md @@ -49,3 +49,5 @@ push(5), pop() -> 5, pop() -> 3, pop() -> 2, pop() -> 1 ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/verbal-arithmetic-puzzle/README.md b/problems/verbal-arithmetic-puzzle/README.md index bdf37791c..a3b625841 100644 --- a/problems/verbal-arithmetic-puzzle/README.md +++ b/problems/verbal-arithmetic-puzzle/README.md @@ -66,7 +66,9 @@ Such that: "SIX" + "SEVEN" + "SEVEN" = "TWENT ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Hints diff --git a/problems/verify-preorder-sequence-in-binary-search-tree/README.md b/problems/verify-preorder-sequence-in-binary-search-tree/README.md index fbcd2f24c..e68fbc9ae 100644 --- a/problems/verify-preorder-sequence-in-binary-search-tree/README.md +++ b/problems/verify-preorder-sequence-in-binary-search-tree/README.md @@ -11,37 +11,15 @@ ## [255. Verify Preorder Sequence in Binary Search Tree (Medium)](https://leetcode.com/problems/verify-preorder-sequence-in-binary-search-tree "验证前序遍历序列二叉搜索树") -

    Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary search tree.

    -

    You may assume each number in the sequence is unique.

    - -

    Consider the following binary search tree: 

    - -
    -     5
    -    / \
    -   2   6
    -  / \
    - 1   3
    - -

    Example 1:

    - -
    -Input: [5,2,6,1,3]
    -Output: false
    - -

    Example 2:

    - -
    -Input: [5,2,1,3,6]
    -Output: true
    - -

    Follow up:
    -Could you do it using only constant space complexity?

    ### Related Topics [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Similar Questions 1. [Binary Tree Preorder Traversal](../binary-tree-preorder-traversal) (Easy) diff --git a/problems/verify-preorder-serialization-of-a-binary-tree/README.md b/problems/verify-preorder-serialization-of-a-binary-tree/README.md index c968d575a..09e94745a 100644 --- a/problems/verify-preorder-serialization-of-a-binary-tree/README.md +++ b/problems/verify-preorder-serialization-of-a-binary-tree/README.md @@ -48,3 +48,6 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] + [[Tree](../../tag/tree/README.md)] + [[String](../../tag/string/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/verifying-an-alien-dictionary/README.md b/problems/verifying-an-alien-dictionary/README.md index 34c022512..76908eabe 100644 --- a/problems/verifying-an-alien-dictionary/README.md +++ b/problems/verifying-an-alien-dictionary/README.md @@ -50,4 +50,6 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] diff --git a/problems/vertical-order-traversal-of-a-binary-tree/README.md b/problems/vertical-order-traversal-of-a-binary-tree/README.md index 10516fbe2..9c6cd7974 100644 --- a/problems/vertical-order-traversal-of-a-binary-tree/README.md +++ b/problems/vertical-order-traversal-of-a-binary-tree/README.md @@ -66,6 +66,7 @@ Note that the solution remains the same since 5 and 6 are in the same location a ### Related Topics [[Tree](../../tag/tree/README.md)] - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/video-stitching/README.md b/problems/video-stitching/README.md index 79bb66793..687a03680 100644 --- a/problems/video-stitching/README.md +++ b/problems/video-stitching/README.md @@ -70,6 +70,8 @@ Now we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 1 ### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/vowel-spellchecker/README.md b/problems/vowel-spellchecker/README.md index c8dc8baa3..b63489799 100644 --- a/problems/vowel-spellchecker/README.md +++ b/problems/vowel-spellchecker/README.md @@ -61,5 +61,6 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/walking-robot-simulation/README.md b/problems/walking-robot-simulation/README.md index 7a8a80243..d73a44053 100644 --- a/problems/walking-robot-simulation/README.md +++ b/problems/walking-robot-simulation/README.md @@ -73,4 +73,5 @@ The furthest point away from the origin is (1, 8), which is 12 + 8 ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/walls-and-gates/README.md b/problems/walls-and-gates/README.md index 3cdb5f5cd..3eac1befe 100644 --- a/problems/walls-and-gates/README.md +++ b/problems/walls-and-gates/README.md @@ -11,38 +11,12 @@ ## [286. Walls and Gates (Medium)](https://leetcode.com/problems/walls-and-gates "墙与门") -

    You are given a m x n 2D grid initialized with these three possible values.

    -
      -
    1. -1 - A wall or an obstacle.
    2. -
    3. 0 - A gate.
    4. -
    5. INF - Infinity means an empty room. We use the value 231 - 1 = 2147483647 to represent INF as you may assume that the distance to a gate is less than 2147483647.
    6. -
    - -

    Fill each empty room with the distance to its nearest gate. If it is impossible to reach a gate, it should be filled with INF.

    - -

    Example: 

    - -

    Given the 2D grid:

    - -
    -INF  -1  0  INF
    -INF INF INF  -1
    -INF  -1 INF  -1
    -  0  -1 INF INF
    -
    - -

    After running your function, the 2D grid should be:

    - -
    -  3  -1   0   1
    -  2   2   1  -1
    -  1  -1   2  -1
    -  0  -1   3   4
    -
    ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Surrounded Regions](../surrounded-regions) (Medium) diff --git a/problems/warehouse-manager/README.md b/problems/warehouse-manager/README.md index 8447ac8ca..33d84cfec 100644 --- a/problems/warehouse-manager/README.md +++ b/problems/warehouse-manager/README.md @@ -12,3 +12,6 @@ ## [1571. Warehouse Manager (Easy)](https://leetcode.com/problems/warehouse-manager "仓库经理") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/water-and-jug-problem/README.md b/problems/water-and-jug-problem/README.md index 502c16158..c9fd6768f 100644 --- a/problems/water-and-jug-problem/README.md +++ b/problems/water-and-jug-problem/README.md @@ -54,4 +54,6 @@ ### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/water-bottles/README.md b/problems/water-bottles/README.md index cdee2ce27..5df550788 100644 --- a/problems/water-bottles/README.md +++ b/problems/water-bottles/README.md @@ -63,7 +63,8 @@ Number of water bottles you can drink: 15 + 3 + 1 = 19. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/ways-to-make-a-fair-array/README.md b/problems/ways-to-make-a-fair-array/README.md index da30e10e4..6915c63e6 100644 --- a/problems/ways-to-make-a-fair-array/README.md +++ b/problems/ways-to-make-a-fair-array/README.md @@ -64,7 +64,7 @@ There is 1 index that you can remove to make nums fair. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints diff --git a/problems/ways-to-split-array-into-three-subarrays/README.md b/problems/ways-to-split-array-into-three-subarrays/README.md index 2f3ca03c7..79d91c75e 100644 --- a/problems/ways-to-split-array-into-three-subarrays/README.md +++ b/problems/ways-to-split-array-into-three-subarrays/README.md @@ -55,8 +55,10 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/weather-type-in-each-country/README.md b/problems/weather-type-in-each-country/README.md index 5af755cf5..e519d5604 100644 --- a/problems/weather-type-in-each-country/README.md +++ b/problems/weather-type-in-each-country/README.md @@ -11,86 +11,7 @@ ## [1294. Weather Type in Each Country (Easy)](https://leetcode.com/problems/weather-type-in-each-country "不同国家的天气类型") -

    Table: Countries

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| country_id    | int     |
    -| country_name  | varchar |
    -+---------------+---------+
    -country_id is the primary key for this table.
    -Each row of this table contains the ID and the name of one country.
    -
    - -

    Table: Weather

    -
    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| country_id    | int     |
    -| weather_state | varchar |
    -| day           | date    |
    -+---------------+---------+
    -(country_id, day) is the primary key for this table.
    -Each row of this table indicates the weather state in a country for one day.
    -
    - -Write an SQL query to find the type of weather in each country for November 2019. -The type of weather is Cold if the average weather_state is less than or equal 15, Hot if the average weather_state is greater than or equal 25 and Warm otherwise. -Return result table in any order. - -The query result format is in the following example: -
    -Countries table:
    -+------------+--------------+
    -| country_id | country_name |
    -+------------+--------------+
    -| 2          | USA          |
    -| 3          | Australia    |
    -| 7          | Peru         |
    -| 5          | China        |
    -| 8          | Morocco      |
    -| 9          | Spain        |
    -+------------+--------------+
    -Weather table:
    -+------------+---------------+------------+
    -| country_id | weather_state | day        |
    -+------------+---------------+------------+
    -| 2          | 15            | 2019-11-01 |
    -| 2          | 12            | 2019-10-28 |
    -| 2          | 12            | 2019-10-27 |
    -| 3          | -2            | 2019-11-10 |
    -| 3          | 0             | 2019-11-11 |
    -| 3          | 3             | 2019-11-12 |
    -| 5          | 16            | 2019-11-07 |
    -| 5          | 18            | 2019-11-09 |
    -| 5          | 21            | 2019-11-23 |
    -| 7          | 25            | 2019-11-28 |
    -| 7          | 22            | 2019-12-01 |
    -| 7          | 20            | 2019-12-02 |
    -| 8          | 25            | 2019-11-05 |
    -| 8          | 27            | 2019-11-15 |
    -| 8          | 31            | 2019-11-25 |
    -| 9          | 7             | 2019-10-23 |
    -| 9          | 3             | 2019-12-23 |
    -+------------+---------------+------------+
    -Result table:
    -+--------------+--------------+
    -| country_name | weather_type |
    -+--------------+--------------+
    -| USA          | Cold         |
    -| Austraila    | Cold         |
    -| Peru         | Hot          |
    -| China        | Warm         |
    -| Morocco      | Hot          |
    -+--------------+--------------+
    -Average weather_state in USA in November is (15) / 1 = 15 so weather type is Cold.
    -Average weather_state in Austraila in November is (-2 + 0 + 3) / 3 = 0.333 so weather type is Cold.
    -Average weather_state in Peru in November is (25) / 1 = 25 so weather type is Hot.
    -Average weather_state in China in November is (16 + 18 + 21) / 3 = 18.333 so weather type is Warm.
    -Average weather_state in Morocco in November is (25 + 27 + 31) / 3 = 27.667 so weather type is Hot.
    -We know nothing about average weather_state in Spain in November so we don't include it in the result table. 
    -
    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/web-crawler-multithreaded/README.md b/problems/web-crawler-multithreaded/README.md index a0cf51d9b..b32fcdcc7 100644 --- a/problems/web-crawler-multithreaded/README.md +++ b/problems/web-crawler-multithreaded/README.md @@ -11,100 +11,9 @@ ## [1242. Web Crawler Multithreaded (Medium)](https://leetcode.com/problems/web-crawler-multithreaded "多线程网页爬虫") -

    Given a url startUrl and an interface HtmlParser, implement a Multi-threaded web crawler to crawl all links that are under the same hostname as startUrl

    -

    Return all urls obtained by your web crawler in any order.

    - -

    Your crawler should:

    - -
      -
    • Start from the page: startUrl
    • -
    • Call HtmlParser.getUrls(url) to get all urls from a webpage of given url.
    • -
    • Do not crawl the same link twice.
    • -
    • Explore only the links that are under the same hostname as startUrl.
    • -
    - -

    - -

    As shown in the example url above, the hostname is example.org. For simplicity sake, you may assume all urls use http protocol without any port specified. For example, the urls http://leetcode.com/problems and http://leetcode.com/contest are under the same hostname, while urls http://example.org/test and http://example.com/abc are not under the same hostname.

    - -

    The HtmlParser interface is defined as such: 

    - -
    -interface HtmlParser {
    -  // Return a list of all urls from a webpage of given url.
    -  // This is a blocking call, that means it will do HTTP request and return when this request is finished.
    -  public List<String> getUrls(String url);
    -}
    - -

    Note that getUrls(String url) simulates performing a HTTP request. You can treat it as a blocking function call which waits for a HTTP request to finish. It is guaranteed that getUrls(String url) will return the urls within 15ms.  Single-threaded solutions will exceed the time limit so, can your multi-threaded web crawler do better?

    - -

    Below are two examples explaining the functionality of the problem, for custom testing purposes you'll have three variables urlsedges and startUrl. Notice that you will only have access to startUrl in your code, while urls and edges are not directly accessible to you in code.

    - -

     

    - -

    Follow up:

    - -
      -
    1. Assume we have 10,000 nodes and 1 billion URLs to crawl. We will deploy the same software onto each node. The software can know about all the nodes. We have to minimize communication between machines and make sure each node does equal amount of work. How would your web crawler design change?
    2. -
    3. What if one node fails or does not work?
    4. -
    5. How do you know when the crawler is done?
    6. -
    - -

     

    -

    Example 1:

    - -

    - -
    -Input:
    -urls = [
    -  "http://news.yahoo.com",
    -  "http://news.yahoo.com/news",
    -  "http://news.yahoo.com/news/topics/",
    -  "http://news.google.com",
    -  "http://news.yahoo.com/us"
    -]
    -edges = [[2,0],[2,1],[3,2],[3,1],[0,4]]
    -startUrl = "http://news.yahoo.com/news/topics/"
    -Output: [
    -  "http://news.yahoo.com",
    -  "http://news.yahoo.com/news",
    -  "http://news.yahoo.com/news/topics/",
    -  "http://news.yahoo.com/us"
    -]
    -
    - -

    Example 2:

    - -

    - -
    -Input: 
    -urls = [
    -  "http://news.yahoo.com",
    -  "http://news.yahoo.com/news",
    -  "http://news.yahoo.com/news/topics/",
    -  "http://news.google.com"
    -]
    -edges = [[0,2],[2,1],[3,2],[3,1],[3,0]]
    -startUrl = "http://news.google.com"
    -Output: ["http://news.google.com"]
    -Explanation: The startUrl links to all other pages that do not share the same hostname.
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= urls.length <= 1000
    • -
    • 1 <= urls[i].length <= 300
    • -
    • startUrl is one of the urls.
    • -
    • Hostname label must be from 1 to 63 characters long, including the dots, may contain only the ASCII letters from 'a' to 'z', digits from '0' to '9' and the hyphen-minus character ('-').
    • -
    • The hostname may not start or end with the hyphen-minus character ('-'). 
    • -
    • See:  https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_hostnames
    • -
    • You may assume there're no duplicates in url library.
    • -
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Concurrency](../../tag/concurrency/README.md)] diff --git a/problems/web-crawler/README.md b/problems/web-crawler/README.md index bbec735a2..60d631889 100644 --- a/problems/web-crawler/README.md +++ b/problems/web-crawler/README.md @@ -11,90 +11,13 @@ ## [1236. Web Crawler (Medium)](https://leetcode.com/problems/web-crawler "网络爬虫") -

    Given a url startUrl and an interface HtmlParser, implement a web crawler to crawl all links that are under the same hostname as startUrl

    -

    Return all urls obtained by your web crawler in any order.

    - -

    Your crawler should:

    - -
      -
    • Start from the page: startUrl
    • -
    • Call HtmlParser.getUrls(url) to get all urls from a webpage of given url.
    • -
    • Do not crawl the same link twice.
    • -
    • Explore only the links that are under the same hostname as startUrl.
    • -
    - -

    - -

    As shown in the example url above, the hostname is example.org. For simplicity sake, you may assume all urls use http protocol without any port specified. For example, the urls http://leetcode.com/problems and http://leetcode.com/contest are under the same hostname, while urls http://example.org/test and http://example.com/abc are not under the same hostname.

    - -

    The HtmlParser interface is defined as such: 

    - -
    -interface HtmlParser {
    -  // Return a list of all urls from a webpage of given url.
    -  public List<String> getUrls(String url);
    -}
    - -

    Below are two examples explaining the functionality of the problem, for custom testing purposes you'll have three variables urlsedges and startUrl. Notice that you will only have access to startUrl in your code, while urls and edges are not directly accessible to you in code.

    - -

     

    -

    Example 1:

    - -

    - -
    -Input:
    -urls = [
    -  "http://news.yahoo.com",
    -  "http://news.yahoo.com/news",
    -  "http://news.yahoo.com/news/topics/",
    -  "http://news.google.com",
    -  "http://news.yahoo.com/us"
    -]
    -edges = [[2,0],[2,1],[3,2],[3,1],[0,4]]
    -startUrl = "http://news.yahoo.com/news/topics/"
    -Output: [
    -  "http://news.yahoo.com",
    -  "http://news.yahoo.com/news",
    -  "http://news.yahoo.com/news/topics/",
    -  "http://news.yahoo.com/us"
    -]
    -
    - -

    Example 2:

    - -

    - -
    -Input: 
    -urls = [
    -  "http://news.yahoo.com",
    -  "http://news.yahoo.com/news",
    -  "http://news.yahoo.com/news/topics/",
    -  "http://news.google.com"
    -]
    -edges = [[0,2],[2,1],[3,2],[3,1],[3,0]]
    -startUrl = "http://news.google.com"
    -Output: ["http://news.google.com"]
    -Explanation: The startUrl links to all other pages that do not share the same hostname.
    - -

     

    -

    Constraints:

    - -
      -
    • 1 <= urls.length <= 1000
    • -
    • 1 <= urls[i].length <= 300
    • -
    • startUrl is one of the urls.
    • -
    • Hostname label must be from 1 to 63 characters long, including the dots, may contain only the ASCII letters from 'a' to 'z', digits  from '0' to '9' and the hyphen-minus character ('-').
    • -
    • The hostname may not start or end with the hyphen-minus character ('-'). 
    • -
    • See:  https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_hostnames
    • -
    • You may assume there're no duplicates in url library.
    • -
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[String](../../tag/string/README.md)] + [[Interactive](../../tag/interactive/README.md)] ### Hints
    diff --git a/problems/where-will-the-ball-fall/README.md b/problems/where-will-the-ball-fall/README.md index dd4891085..130043f1b 100644 --- a/problems/where-will-the-ball-fall/README.md +++ b/problems/where-will-the-ball-fall/README.md @@ -66,7 +66,11 @@ Ball b4 is dropped at column 4 and will get stuck on the box between column 2 an ### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/widest-vertical-area-between-two-points-containing-no-points/README.md b/problems/widest-vertical-area-between-two-points-containing-no-points/README.md index 83b343754..6f79021ca 100644 --- a/problems/widest-vertical-area-between-two-points-containing-no-points/README.md +++ b/problems/widest-vertical-area-between-two-points-containing-no-points/README.md @@ -44,7 +44,8 @@ ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/wiggle-sort-ii/README.md b/problems/wiggle-sort-ii/README.md index 78a401a1b..93083cdda 100644 --- a/problems/wiggle-sort-ii/README.md +++ b/problems/wiggle-sort-ii/README.md @@ -44,7 +44,10 @@ Follow Up: Can you do it in O(n) time and/or in-place with O(1) extra space? ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Quickselect](../../tag/quickselect/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Sort Colors](../sort-colors) (Medium) diff --git a/problems/wiggle-sort/README.md b/problems/wiggle-sort/README.md index 847a6c2c5..ed9bc8a68 100644 --- a/problems/wiggle-sort/README.md +++ b/problems/wiggle-sort/README.md @@ -11,17 +11,12 @@ ## [280. Wiggle Sort (Medium)](https://leetcode.com/problems/wiggle-sort "摆动排序") -

    Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3]....

    -

    Example:

    - -
    -Input: nums = [3,5,2,1,6,4]
    -Output: One possible answer is [3,5,1,6,2,4]
    ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Sort Colors](../sort-colors) (Medium) diff --git a/problems/wiggle-subsequence/README.md b/problems/wiggle-subsequence/README.md index a1beb4adc..1f0439667 100644 --- a/problems/wiggle-subsequence/README.md +++ b/problems/wiggle-subsequence/README.md @@ -60,4 +60,5 @@ One is [1, 17, 10, 13, 10, 16, 8] with differences (16, -7, 3, -3, 6, -8). ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/wildcard-matching/README.md b/problems/wildcard-matching/README.md index a6bc7923c..e5cebeb0e 100644 --- a/problems/wildcard-matching/README.md +++ b/problems/wildcard-matching/README.md @@ -71,9 +71,9 @@ ### Related Topics [[Greedy](../../tag/greedy/README.md)] + [[Recursion](../../tag/recursion/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions 1. [Regular Expression Matching](../regular-expression-matching) (Hard) diff --git a/problems/winning-candidate/README.md b/problems/winning-candidate/README.md index ccdb959c5..6e7bfaf1c 100644 --- a/problems/winning-candidate/README.md +++ b/problems/winning-candidate/README.md @@ -11,50 +11,7 @@ ## [574. Winning Candidate (Medium)](https://leetcode.com/problems/winning-candidate "当选者") -

    Table: Candidate

    -
    -+-----+---------+
    -| id  | Name    |
    -+-----+---------+
    -| 1   | A       |
    -| 2   | B       |
    -| 3   | C       |
    -| 4   | D       |
    -| 5   | E       |
    -+-----+---------+  
    -
    -

    Table: Vote

    - -
    -+-----+--------------+
    -| id  | CandidateId  |
    -+-----+--------------+
    -| 1   |     2        |
    -| 2   |     4        |
    -| 3   |     3        |
    -| 4   |     2        |
    -| 5   |     5        |
    -+-----+--------------+
    -id is the auto-increment primary key,
    -CandidateId is the id appeared in Candidate table.
    -
    - -

    Write a sql to find the name of the winning candidate, the above example will return the winner B.

    - -
    -+------+
    -| Name |
    -+------+
    -| B    |
    -+------+
    -
    - -

    Notes:

    - -
      -
    1. You may assume there is no tie, in other words there will be only one winning candidate.
    2. -
    - -

     

    +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/word-abbreviation/README.md b/problems/word-abbreviation/README.md index c6ee708e0..c51fc4418 100644 --- a/problems/word-abbreviation/README.md +++ b/problems/word-abbreviation/README.md @@ -11,33 +11,14 @@ ## [527. Word Abbreviation (Hard)](https://leetcode.com/problems/word-abbreviation "单词缩写") -

    Given an array of n distinct non-empty strings, you need to generate minimal possible abbreviations for every word following rules below.

    -
      -
    1. Begin with the first character and then the number of characters abbreviated, which followed by the last character.
    2. -
    3. If there are any conflict, that is more than one words share the same abbreviation, a longer prefix is used instead of only the first character until making the map from word to abbreviation become unique. In other words, a final abbreviation cannot map to more than one original words.
    4. -
    5. If the abbreviation doesn't make the word shorter, then keep it as original.
    6. -
    - -

    Example:
    -

    -Input: ["like", "god", "internal", "me", "internet", "interval", "intension", "face", "intrusion"]
    -Output: ["l2e","god","internal","me","i6t","interval","inte4n","f2e","intr4n"]
    -
    -

    - - -Note: -
      -
    1. Both n and the length of each word will not exceed 400.
    2. -
    3. The length of each word is greater than 1.
    4. -
    5. The words consist of lowercase English letters only.
    6. -
    7. The return answers should be in the same order as the original array.
    8. -
    ### Related Topics - [[Sort](../../tag/sort/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [Valid Word Abbreviation](../valid-word-abbreviation) (Easy) diff --git a/problems/word-break-ii/README.md b/problems/word-break-ii/README.md index 56c94652b..7cb8189ef 100644 --- a/problems/word-break-ii/README.md +++ b/problems/word-break-ii/README.md @@ -50,6 +50,10 @@ ### Related Topics + [[Trie](../../tag/trie/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/word-break/README.md b/problems/word-break/README.md index b061997e4..1f1e3d229 100644 --- a/problems/word-break/README.md +++ b/problems/word-break/README.md @@ -52,6 +52,10 @@ Note that you are allowed to reuse a dictionary word. ### Related Topics + [[Trie](../../tag/trie/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/word-frequency/README.md b/problems/word-frequency/README.md index a8b0447ab..4ffb16244 100644 --- a/problems/word-frequency/README.md +++ b/problems/word-frequency/README.md @@ -46,5 +46,8 @@ day 1
  • Could you write it in one-line using Unix pipes?
  • +### Related Topics + [[Shell](../../tag/shell/README.md)] + ### Similar Questions 1. [Top K Frequent Elements](../top-k-frequent-elements) (Medium) diff --git a/problems/word-ladder-ii/README.md b/problems/word-ladder-ii/README.md index a0813c7a3..947eec7f7 100644 --- a/problems/word-ladder-ii/README.md +++ b/problems/word-ladder-ii/README.md @@ -54,8 +54,8 @@ ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] - [[Array](../../tag/array/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/word-ladder/README.md b/problems/word-ladder/README.md index 3464ba32d..8a1932b13 100644 --- a/problems/word-ladder/README.md +++ b/problems/word-ladder/README.md @@ -52,7 +52,9 @@ ### Related Topics - [[Breadth-first Search](../../tag/breadth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Word Ladder II](../word-ladder-ii) (Hard) diff --git a/problems/word-pattern-ii/README.md b/problems/word-pattern-ii/README.md index 5e9c20a60..0577b1b73 100644 --- a/problems/word-pattern-ii/README.md +++ b/problems/word-pattern-ii/README.md @@ -11,33 +11,11 @@ ## [291. Word Pattern II (Medium)](https://leetcode.com/problems/word-pattern-ii "单词规律 II") -

    Given a pattern and a string str, find if str follows the same pattern.

    -

    Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty substring in str.

    - -

    Example 1:

    - -
    -Input: pattern = "abab", str = "redblueredblue"
    -Output: true
    - -

    Example 2:

    - -
    -Input: pattern = pattern = "aaaa", str = "asdasdasdasd"
    -Output: true
    - -

    Example 3:

    - -
    -Input: pattern = "aabb", str = "xyzabcxzyabc"
    -Output: false
    -
    - -

    Notes:
    -You may assume both pattern and str contains only lowercase letters.

    ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions diff --git a/problems/word-pattern/README.md b/problems/word-pattern/README.md index f5da65655..043632042 100644 --- a/problems/word-pattern/README.md +++ b/problems/word-pattern/README.md @@ -58,6 +58,7 @@ ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Isomorphic Strings](../isomorphic-strings) (Easy) diff --git a/problems/word-search-ii/README.md b/problems/word-search-ii/README.md index 87cf5d135..10b6d62b4 100644 --- a/problems/word-search-ii/README.md +++ b/problems/word-search-ii/README.md @@ -46,7 +46,10 @@ ### Related Topics [[Trie](../../tag/trie/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Word Search](../word-search) (Medium) diff --git a/problems/word-search/README.md b/problems/word-search/README.md index 5435a6bf0..743c2ff89 100644 --- a/problems/word-search/README.md +++ b/problems/word-search/README.md @@ -54,6 +54,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Word Search II](../word-search-ii) (Hard) diff --git a/problems/word-squares/README.md b/problems/word-squares/README.md index c5a53380b..5277596be 100644 --- a/problems/word-squares/README.md +++ b/problems/word-squares/README.md @@ -11,78 +11,12 @@ ## [425. Word Squares (Hard)](https://leetcode.com/problems/word-squares "单词方块") -

    Given a set of words (without duplicates), find all word squares you can build from them.

    -

    A sequence of words forms a valid word square if the kth row and column read the exact same string, where 0 ≤ k < max(numRows, numColumns).

    - -

    For example, the word sequence ["ball","area","lead","lady"] forms a word square because each word reads the same both horizontally and vertically.

    - -
    -b a l l
    -a r e a
    -l e a d
    -l a d y
    -
    - -

    Note:
    -

      -
    1. There are at least 1 and at most 1000 words.
    2. -
    3. All words will have the exact same length.
    4. -
    5. Word length is at least 1 and at most 5.
    6. -
    7. Each word contains only lowercase English alphabet a-z.
    8. -
    -

    - -

    Example 1: -

    -Input:
    -["area","lead","wall","lady","ball"]
    -
    -Output:
    -[
    -  [ "wall",
    -    "area",
    -    "lead",
    -    "lady"
    -  ],
    -  [ "ball",
    -    "area",
    -    "lead",
    -    "lady"
    -  ]
    -]
    -
    -Explanation:
    -The output consists of two word squares. The order of output does not matter (just the order of words in each word square matters).
    -
    -

    - -

    Example 2: -

    -Input:
    -["abat","baba","atan","atal"]
    -
    -Output:
    -[
    -  [ "baba",
    -    "abat",
    -    "baba",
    -    "atan"
    -  ],
    -  [ "baba",
    -    "abat",
    -    "baba",
    -    "atal"
    -  ]
    -]
    -
    -Explanation:
    -The output consists of two word squares. The order of output does not matter (just the order of words in each word square matters).
    -
    -

    ### Related Topics [[Trie](../../tag/trie/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] ### Similar Questions diff --git a/problems/word-subsets/README.md b/problems/word-subsets/README.md index 485f7cdf5..a170c34a3 100644 --- a/problems/word-subsets/README.md +++ b/problems/word-subsets/README.md @@ -81,4 +81,6 @@ ### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/x-of-a-kind-in-a-deck-of-cards/README.md b/problems/x-of-a-kind-in-a-deck-of-cards/README.md index 6c076aa73..153a9b56a 100644 --- a/problems/x-of-a-kind-in-a-deck-of-cards/README.md +++ b/problems/x-of-a-kind-in-a-deck-of-cards/README.md @@ -71,4 +71,7 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Number Theory](../../tag/number-theory/README.md)] diff --git a/problems/xor-operation-in-an-array/README.md b/problems/xor-operation-in-an-array/README.md index 2385c4411..fb190c246 100644 --- a/problems/xor-operation-in-an-array/README.md +++ b/problems/xor-operation-in-an-array/README.md @@ -59,7 +59,7 @@ Where "^" corresponds to bitwise XOR operator. ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] - [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/xor-queries-of-a-subarray/README.md b/problems/xor-queries-of-a-subarray/README.md index cad1478f7..e8898071e 100644 --- a/problems/xor-queries-of-a-subarray/README.md +++ b/problems/xor-queries-of-a-subarray/README.md @@ -51,6 +51,8 @@ The XOR values for queries are: ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/zigzag-iterator/README.md b/problems/zigzag-iterator/README.md index 7c86e928a..a2477e502 100644 --- a/problems/zigzag-iterator/README.md +++ b/problems/zigzag-iterator/README.md @@ -11,36 +11,13 @@ ## [281. Zigzag Iterator (Medium)](https://leetcode.com/problems/zigzag-iterator "锯齿迭代器") -

    Given two 1d vectors, implement an iterator to return their elements alternately.

    -

    Example:

    - -
    -Input:
    -v1 = [1,2]
    -v2 = [3,4,5,6] 
    -
    -Output: [1,3,2,4,5,6]
    -
    -Explanation: By calling next repeatedly until hasNext returns false, 
    -             the order of elements returned by next should be: [1,3,2,4,5,6].
    - -

    Follow up: What if you are given k 1d vectors? How well can your code be extended to such cases?

    - -

    Clarification for the follow up question:
    -The "Zigzag" order is not clearly defined and is ambiguous for k > 2 cases. If "Zigzag" does not look right to you, replace "Zigzag" with "Cyclic". For example:

    - -
    -Input:
    -[1,2,3]
    -[4,5,6,7]
    -[8,9]
    -
    -Output: [1,4,8,2,5,9,3,6,7].
    -
    ### Related Topics [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Iterator](../../tag/iterator/README.md)] ### Similar Questions 1. [Binary Search Tree Iterator](../binary-search-tree-iterator) (Medium) diff --git a/problems/zuma-game/README.md b/problems/zuma-game/README.md index 1508f7e9c..d05daca25 100644 --- a/problems/zuma-game/README.md +++ b/problems/zuma-game/README.md @@ -11,11 +11,24 @@ ## [488. Zuma Game (Hard)](https://leetcode.com/problems/zuma-game "祖玛游戏") -

    Think about Zuma Game. You have a row of balls on the table, colored red(R), yellow(Y), blue(B), green(G), and white(W). You also have several balls in your hand.

    +

    You are playing a variation of the game Zuma.

    -

    Each time, you may choose a ball in your hand, and insert it into the row (including the leftmost place and rightmost place). Then, if there is a group of 3 or more balls in the same color touching, remove these balls. Keep doing this until no more balls can be removed.

    +

    In this variation of Zuma, there is a single row of colored balls on a board, where each ball can be colored red 'R', yellow 'Y', blue 'B', green 'G', or white 'W'. You also have several colored balls in your hand.

    -

    Find the minimal balls you have to insert to remove all the balls on the table. If you cannot remove all the balls, output -1.

    +

    Your goal is to clear all of the balls from the board. On each turn:

    + +
      +
    • Pick any ball from your hand and insert it in between two balls in the row or on either end of the row.
    • +
    • If there is a group of three or more consecutive balls of the same color, remove the group of balls from the board. +
        +
      • If this removal causes more groups of three or more of the same color to form, then continue removing each group until there are none left.
      • +
      +
    • +
    • If there are no more balls on the board, then you win the game.
    • +
    • Repeat this process until you either win or do not have any more balls in your hand.
    • +
    + +

    Given a string board, representing the row of balls on the board, and a string hand, representing the balls in your hand, return the minimum number of balls you have to insert to clear all the balls from the board. If you cannot clear all the balls from the board using the balls in your hand, return -1.

     

    Example 1:

    @@ -23,15 +36,20 @@
     Input: board = "WRRBBW", hand = "RB"
     Output: -1
    -Explanation: WRRBBW -> WRR[R]BBW -> WBBW -> WBB[B]W -> WW
    -
    +Explanation: It is impossible to clear all the balls. The best you can do is: +- Insert 'R' so the board becomes WRRRBBW. WRRRBBW -> WBBW. +- Insert 'B' so the board becomes WBBBW. WBBBW -> WW. +There are still balls remaining on the board, and you are out of balls to insert.

    Example 2:

     Input: board = "WWRRBBWW", hand = "WRBRW"
     Output: 2
    -Explanation: WWRRBBWW -> WWRR[R]BBWW -> WWBBWW -> WWBB[B]WW -> WWWW -> empty
    +Explanation: To make the board empty:
    +- Insert 'R' so the board becomes WWRRRBBWW. WWRRRBBWW -> WWBBWW.
    +- Insert 'B' so the board becomes WWBBBWW. WWBBBWW -> WWWW -> empty.
    +2 balls from your hand were needed to clear the board.
     

    Example 3:

    @@ -39,7 +57,10 @@
     Input: board = "G", hand = "GGGGG"
     Output: 2
    -Explanation: G -> G[G] -> GG[G] -> empty 
    +Explanation: To make the board empty:
    +- Insert 'G' so the board becomes GG.
    +- Insert 'G' so the board becomes GGG. GGG -> empty.
    +2 balls from your hand were needed to clear the board.
     

    Example 4:

    @@ -47,18 +68,23 @@
     Input: board = "RBYYBBRRB", hand = "YRBGB"
     Output: 3
    -Explanation: RBYYBBRRB -> RBYY[Y]BBRRB -> RBBBRRB -> RRRB -> B -> B[B] -> BB[B] -> empty 
    +Explanation: To make the board empty:
    +- Insert 'Y' so the board becomes RBYYYBBRRB. RBYYYBBRRB -> RBBBRRB -> RRRB -> B.
    +- Insert 'B' so the board becomes BB.
    +- Insert 'B' so the board becomes BBB. BBB -> empty.
    +3 balls from your hand were needed to clear the board.
     

     

    Constraints:

      -
    • You may assume that the initial row of balls on the table won’t have any 3 or more consecutive balls with the same color.
    • 1 <= board.length <= 16
    • 1 <= hand.length <= 5
    • -
    • Both input strings will be non-empty and only contain characters 'R','Y','B','G','W'.
    • +
    • board and hand consist of the characters 'R', 'Y', 'B', 'G', and 'W'.
    • +
    • The initial row of balls on the board will not have any groups of three or more consecutive balls of the same color.
    ### Related Topics - [[Depth-first Search](../../tag/depth-first-search/README.md)] + [[String](../../tag/string/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] diff --git a/readme/1201-1500.md b/readme/1201-1500.md index d1b3a3d29..2df0492eb 100644 --- a/readme/1201-1500.md +++ b/readme/1201-1500.md @@ -81,7 +81,7 @@ LeetCode Problems' Solutions | 1201 | [Ugly Number III](https://leetcode.com/problems/ugly-number-iii "丑数 III") | [Go](../problems/ugly-number-iii) | Medium | | 1202 | [Smallest String With Swaps](https://leetcode.com/problems/smallest-string-with-swaps "交换字符串中的元素") | [Go](../problems/smallest-string-with-swaps) | Medium | | 1203 | [Sort Items by Groups Respecting Dependencies](https://leetcode.com/problems/sort-items-by-groups-respecting-dependencies "项目管理") | [Go](../problems/sort-items-by-groups-respecting-dependencies) | Hard | -| 1204 | [Last Person to Fit in the Elevator](https://leetcode.com/problems/last-person-to-fit-in-the-elevator "最后一个能进入电梯的人") 🔒 | [MySQL](../problems/last-person-to-fit-in-the-elevator) | Medium | +| 1204 | [Last Person to Fit in the Bus](https://leetcode.com/problems/last-person-to-fit-in-the-bus "最后一个能进入电梯的人") 🔒 | [MySQL](../problems/last-person-to-fit-in-the-bus) | Medium | | 1205 | [Monthly Transactions II](https://leetcode.com/problems/monthly-transactions-ii "每月交易II") 🔒 | [MySQL](../problems/monthly-transactions-ii) | Medium | | 1206 | [Design Skiplist](https://leetcode.com/problems/design-skiplist "设计跳表") | [Go](../problems/design-skiplist) | Hard | | 1207 | [Unique Number of Occurrences](https://leetcode.com/problems/unique-number-of-occurrences "独一无二的出现次数") | [Go](../problems/unique-number-of-occurrences) | Easy | diff --git a/readme/301-600.md b/readme/301-600.md index 6a4c990ab..7a4595be6 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -179,7 +179,7 @@ LeetCode Problems' Solutions | 399 | [Evaluate Division](https://leetcode.com/problems/evaluate-division "除法求值") | [Go](../problems/evaluate-division) | Medium | | 400 | [Nth Digit](https://leetcode.com/problems/nth-digit "第 N 位数字") | [Go](../problems/nth-digit) | Medium | | 401 | [Binary Watch](https://leetcode.com/problems/binary-watch "二进制手表") | [Go](../problems/binary-watch) | Easy | -| 402 | [Remove K Digits](https://leetcode.com/problems/remove-k-digits "移掉K位数字") | [Go](../problems/remove-k-digits) | Medium | +| 402 | [Remove K Digits](https://leetcode.com/problems/remove-k-digits "移掉 K 位数字") | [Go](../problems/remove-k-digits) | Medium | | 403 | [Frog Jump](https://leetcode.com/problems/frog-jump "青蛙过河") | [Go](../problems/frog-jump) | Hard | | 404 | [Sum of Left Leaves](https://leetcode.com/problems/sum-of-left-leaves "左叶子之和") | [Go](../problems/sum-of-left-leaves) | Easy | | 405 | [Convert a Number to Hexadecimal](https://leetcode.com/problems/convert-a-number-to-hexadecimal "数字转换为十六进制数") | [Go](../problems/convert-a-number-to-hexadecimal) | Easy | diff --git a/readme/601-900.md b/readme/601-900.md index 224e1fdc0..d04f80016 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -197,7 +197,7 @@ LeetCode Problems' Solutions | 717 | [1-bit and 2-bit Characters](https://leetcode.com/problems/1-bit-and-2-bit-characters "1比特与2比特字符") | [Go](../problems/1-bit-and-2-bit-characters) | Easy | | 718 | [Maximum Length of Repeated Subarray](https://leetcode.com/problems/maximum-length-of-repeated-subarray "最长重复子数组") | [Go](../problems/maximum-length-of-repeated-subarray) | Medium | | 719 | [Find K-th Smallest Pair Distance](https://leetcode.com/problems/find-k-th-smallest-pair-distance "找出第 k 小的距离对") | [Go](../problems/find-k-th-smallest-pair-distance) | Hard | -| 720 | [Longest Word in Dictionary](https://leetcode.com/problems/longest-word-in-dictionary "词典中最长的单词") | [Go](../problems/longest-word-in-dictionary) | Easy | +| 720 | [Longest Word in Dictionary](https://leetcode.com/problems/longest-word-in-dictionary "词典中最长的单词") | [Go](../problems/longest-word-in-dictionary) | Medium | | 721 | [Accounts Merge](https://leetcode.com/problems/accounts-merge "账户合并") | [Go](../problems/accounts-merge) | Medium | | 722 | [Remove Comments](https://leetcode.com/problems/remove-comments "删除注释") | [Go](../problems/remove-comments) | Medium | | 723 | [Candy Crush](https://leetcode.com/problems/candy-crush "粉碎糖果") 🔒 | [Go](../problems/candy-crush) | Medium | @@ -278,7 +278,7 @@ LeetCode Problems' Solutions | 798 | [Smallest Rotation with Highest Score](https://leetcode.com/problems/smallest-rotation-with-highest-score "得分最高的最小轮调") | [Go](../problems/smallest-rotation-with-highest-score) | Hard | | 799 | [Champagne Tower](https://leetcode.com/problems/champagne-tower "香槟塔") | [Go](../problems/champagne-tower) | Medium | | 800 | [Similar RGB Color](https://leetcode.com/problems/similar-rgb-color "相似 RGB 颜色") 🔒 | [Go](../problems/similar-rgb-color) | Easy | -| 801 | [Minimum Swaps To Make Sequences Increasing](https://leetcode.com/problems/minimum-swaps-to-make-sequences-increasing "使序列递增的最小交换次数") | [Go](../problems/minimum-swaps-to-make-sequences-increasing) | Medium | +| 801 | [Minimum Swaps To Make Sequences Increasing](https://leetcode.com/problems/minimum-swaps-to-make-sequences-increasing "使序列递增的最小交换次数") | [Go](../problems/minimum-swaps-to-make-sequences-increasing) | Hard | | 802 | [Find Eventual Safe States](https://leetcode.com/problems/find-eventual-safe-states "找到最终的安全状态") | [Go](../problems/find-eventual-safe-states) | Medium | | 803 | [Bricks Falling When Hit](https://leetcode.com/problems/bricks-falling-when-hit "打砖块") | [Go](../problems/bricks-falling-when-hit) | Hard | | 804 | [Unique Morse Code Words](https://leetcode.com/problems/unique-morse-code-words "唯一摩尔斯密码词") | [Go](../problems/unique-morse-code-words) | Easy | diff --git a/tag/array/README.md b/tag/array/README.md index 62a5fd5d4..0a93eae00 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,327 +9,900 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1878 | [矩阵中最大的三个菱形和](../../problems/get-biggest-three-rhombus-sums-in-a-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1869 | [哪种连续子字符串更长](../../problems/longer-contiguous-segments-of-ones-than-zeros) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 1861 | [旋转盒子](../../problems/rotating-the-box) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1854 | [人口最多的年份](../../problems/maximum-population-year) | [[数组](../array/README.md)] | Easy | -| 1852 | [Distinct Numbers in Each Subarray](../../problems/distinct-numbers-in-each-subarray) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1920 | [基于排列构建数组](../../problems/build-array-from-permutation) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1918 | [Kth Smallest Subarray Sum](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1914 | [循环轮转矩阵](../../problems/cyclically-rotating-a-grid) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1913 | [两个数对之间的最大乘积差](../../problems/maximum-product-difference-between-two-pairs) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1911 | [最大子序列交替和](../../problems/maximum-alternating-subsequence-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1909 | [删除一个元素使数组严格递增](../../problems/remove-one-element-to-make-the-array-strictly-increasing) | [[数组](../array/README.md)] | Easy | +| 1908 | [Game of Nim](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1906 | [查询差绝对值的最小值](../../problems/minimum-absolute-difference-queries) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1901 | [找出顶峰元素 II](../../problems/find-a-peak-element-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1899 | [合并若干三元组以形成目标三元组](../../problems/merge-triplets-to-form-target-triplet) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1898 | [可移除字符的最大数目](../../problems/maximum-number-of-removable-characters) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1895 | [最大的幻方](../../problems/largest-magic-square) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1894 | [找到需要补充粉笔的学生编号](../../problems/find-the-student-that-will-replace-the-chalk) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1893 | [检查是否区域内所有整数都被覆盖](../../problems/check-if-all-the-integers-in-a-range-are-covered) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | +| 1891 | [割绳子](../../problems/cutting-ribbons) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1889 | [装包裹的最小浪费空间](../../problems/minimum-space-wasted-from-packaging) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1887 | [使数组元素相等的减少操作次数](../../problems/reduction-operations-to-make-the-array-elements-equal) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1886 | [判断矩阵经轮转后是否一致](../../problems/determine-whether-matrix-can-be-obtained-by-rotation) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 1885 | [Count Pairs in Two Arrays](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1883 | [准时抵达会议现场的最小跳过休息次数](../../problems/minimum-skips-to-arrive-at-meeting-on-time) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1882 | [使用服务器处理任务](../../problems/process-tasks-using-servers) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1879 | [两个数组最小的异或值之和](../../problems/minimum-xor-sum-of-two-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1878 | [矩阵中最大的三个菱形和](../../problems/get-biggest-three-rhombus-sums-in-a-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1877 | [数组中最大数对和的最小值](../../problems/minimize-maximum-pair-sum-in-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1874 | [两个数组的最小乘积和](../../problems/minimize-product-sum-of-two-arrays) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1872 | [石子游戏 VIII](../../problems/stone-game-viii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 1870 | [准时到达的列车最小时速](../../problems/minimum-speed-to-arrive-on-time) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1868 | [两个行程编码数组的积](../../problems/product-of-two-run-length-encoded-arrays) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1865 | [找出和为指定值的下标对](../../problems/finding-pairs-with-a-certain-sum) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1863 | [找出所有子集的异或总和再求和](../../problems/sum-of-all-subset-xor-totals) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Easy | +| 1862 | [向下取整数对和](../../problems/sum-of-floored-pairs) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 1861 | [旋转盒子](../../problems/rotating-the-box) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1855 | [下标对中的最大距离](../../problems/maximum-distance-between-a-pair-of-values) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1854 | [人口最多的年份](../../problems/maximum-population-year) | [[数组](../array/README.md)] [[计数](../counting/README.md)] | Easy | +| 1852 | [每个子数组的数字种类数](../../problems/distinct-numbers-in-each-subarray) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1851 | [包含每个查询的最小区间](../../problems/minimum-interval-to-include-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[扫描线](../line-sweep/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1848 | [到目标元素的最小距离](../../problems/minimum-distance-to-the-target-element) | [[数组](../array/README.md)] | Easy | -| 1833 | [雪糕的最大数量](../../problems/maximum-ice-cream-bars) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1827 | [最少操作使数组递增](../../problems/minimum-operations-to-make-the-array-increasing) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 1826 | [有缺陷的传感器](../../problems/faulty-sensor) 🔒 | [[数组](../array/README.md)] | Easy | -| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[数组](../array/README.md)] | Medium | -| 1814 | [统计一个数组中好对子的数目](../../problems/count-nice-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1806 | [还原排列的最少操作步数](../../problems/minimum-number-of-operations-to-reinitialize-a-permutation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1847 | [最近的房间](../../problems/closest-room) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1846 | [减小和重新排列数组后的最大元素](../../problems/maximum-element-after-decreasing-and-rearranging) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1840 | [最高建筑高度](../../problems/maximum-building-height) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1838 | [最高频元素的频数](../../problems/frequency-of-the-most-frequent-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1835 | [所有数对按位与结果的异或和](../../problems/find-xor-sum-of-all-pairs-bitwise-and) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1834 | [单线程 CPU](../../problems/single-threaded-cpu) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1833 | [雪糕的最大数量](../../problems/maximum-ice-cream-bars) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1829 | [每个查询的最大异或值](../../problems/maximum-xor-for-each-query) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1828 | [统计一个圆中点的数目](../../problems/queries-on-number-of-points-inside-a-circle) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1827 | [最少操作使数组递增](../../problems/minimum-operations-to-make-the-array-increasing) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 1826 | [有缺陷的传感器](../../problems/faulty-sensor) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1824 | [最少侧跳次数](../../problems/minimum-sideway-jumps) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1822 | [数组元素积的符号](../../problems/sign-of-the-product-of-an-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1820 | [最多邀请的个数](../../problems/maximum-number-of-accepted-invitations) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Hard | +| 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1817 | [查找用户活跃分钟数](../../problems/finding-the-users-active-minutes) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1816 | [截断句子](../../problems/truncate-sentence) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1815 | [得到新鲜甜甜圈的最多组数](../../problems/maximum-number-of-groups-getting-fresh-donuts) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1814 | [统计一个数组中好对子的数目](../../problems/count-nice-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] | Medium | +| 1813 | [句子相似性 III](../../problems/sentence-similarity-iii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1807 | [替换字符串中的括号内容](../../problems/evaluate-the-bracket-pairs-of-a-string) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1806 | [还原排列的最少操作步数](../../problems/minimum-number-of-operations-to-reinitialize-a-permutation) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1803 | [统计异或值在范围内的数对有多少](../../problems/count-pairs-with-xor-in-a-range) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] | Hard | +| 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1800 | [最大升序子数组和](../../problems/maximum-ascending-subarray-sum) | [[数组](../array/README.md)] | Easy | +| 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] [[数论](../number-theory/README.md)] | Hard | +| 1798 | [你能构造出连续值的最大数目](../../problems/maximum-number-of-consecutive-values-you-can-make) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 1792 | [最大平均通过率](../../problems/maximum-average-pass-ratio) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1788 | [最大化花园的美观度](../../problems/maximize-the-beauty-of-the-garden) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 1787 | [使所有区间的异或结果为零](../../problems/make-the-xor-of-all-segments-equal-to-zero) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1785 | [构成特定和需要添加的最少元素](../../problems/minimum-elements-to-add-to-form-a-given-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1779 | [找到最近的有相同 X 或 Y 坐标的点](../../problems/find-nearest-point-that-has-the-same-x-or-y-coordinate) | [[数组](../array/README.md)] | Easy | +| 1776 | [车队 II](../../problems/car-fleet-ii) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[单调栈](../monotonic-stack/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1775 | [通过最少操作次数使数组的和相等](../../problems/equal-sum-arrays-with-minimum-number-of-operations) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 1774 | [最接近目标价格的甜点成本](../../problems/closest-dessert-cost) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1773 | [统计匹配检索规则的物品数量](../../problems/count-items-matching-a-rule) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | -| 1769 | [移动所有球到每个盒子所需的最小操作数](../../problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1764 | [通过连接另一个数组的子数组得到一个数组](../../problems/form-array-by-concatenating-subarrays-of-another-array) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1758 | [生成交替二进制字符串的最少操作数](../../problems/minimum-changes-to-make-alternating-binary-string) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1772 | [按受欢迎程度排列功能](../../problems/sort-features-by-popularity) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1770 | [执行乘法运算的最大分数](../../problems/maximum-score-from-performing-multiplication-operations) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1769 | [移动所有球到每个盒子所需的最小操作数](../../problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1765 | [地图中的最高点](../../problems/map-of-highest-peak) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1764 | [通过连接另一个数组的子数组得到一个数组](../../problems/form-array-by-concatenating-subarrays-of-another-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 1762 | [能看到海景的建筑物](../../problems/buildings-with-an-ocean-view) 🔒 | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1760 | [袋子里最少数目的球](../../problems/minimum-limit-of-balls-in-a-bag) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1755 | [最接近目标值的子序列和](../../problems/closest-subsequence-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1752 | [检查数组是否经排序和轮转得到](../../problems/check-if-array-is-sorted-and-rotated) | [[数组](../array/README.md)] | Easy | -| 1748 | [唯一元素的和](../../problems/sum-of-unique-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1742 | [盒子中小球的最大数量](../../problems/maximum-number-of-balls-in-a-box) | [[数组](../array/README.md)] | Easy | -| 1738 | [找出第 K 大的异或坐标值](../../problems/find-kth-largest-xor-coordinate-value) | [[数组](../array/README.md)] | Medium | -| 1733 | [需要教语言的最少人数](../../problems/minimum-number-of-people-to-teach) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1732 | [找到最高海拔](../../problems/find-the-highest-altitude) | [[数组](../array/README.md)] | Easy | +| 1751 | [最多可以参加的会议数目 II](../../problems/maximum-number-of-events-that-can-be-attended-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1749 | [任意子数组和的绝对值的最大值](../../problems/maximum-absolute-sum-of-any-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1748 | [唯一元素的和](../../problems/sum-of-unique-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | +| 1746 | [经过一次操作后的最大子数组和](../../problems/maximum-subarray-sum-after-one-operation) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1744 | [你能在你最喜欢的那天吃到你最喜欢的糖果吗?](../../problems/can-you-eat-your-favorite-candy-on-your-favorite-day) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1743 | [从相邻元素对还原数组](../../problems/restore-the-array-from-adjacent-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1738 | [找出第 K 大的异或坐标值](../../problems/find-kth-largest-xor-coordinate-value) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[快速选择](../quickselect/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1735 | [生成乘积数组的方案数](../../problems/count-ways-to-make-array-with-product) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1734 | [解码异或后的排列](../../problems/decode-xored-permutation) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Medium | +| 1733 | [需要教语言的最少人数](../../problems/minimum-number-of-people-to-teach) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1732 | [找到最高海拔](../../problems/find-the-highest-altitude) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | +| 1730 | [获取食物的最短路径](../../problems/shortest-path-to-get-food) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1727 | [重新排列后的最大子矩阵](../../problems/largest-submatrix-with-rearrangements) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | | 1726 | [同积元组](../../problems/tuple-with-same-product) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1708 | [长度为 K 的最大子数组](../../problems/largest-subarray-length-k) 🔒 | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 1701 | [平均等待时间](../../problems/average-waiting-time) | [[数组](../array/README.md)] | Medium | -| 1700 | [无法吃午餐的学生数量](../../problems/number-of-students-unable-to-eat-lunch) | [[数组](../array/README.md)] | Easy | -| 1672 | [最富有客户的资产总量](../../problems/richest-customer-wealth) | [[数组](../array/README.md)] | Easy | -| 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Easy | +| 1725 | [可以形成最大正方形的矩形数目](../../problems/number-of-rectangles-that-can-form-the-largest-square) | [[数组](../array/README.md)] | Easy | +| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | +| 1720 | [解码异或后的数组](../../problems/decode-xored-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | +| 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1714 | [数组中特殊等间距元素的和](../../problems/sum-of-special-evenly-spaced-elements-in-array) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1713 | [得到子序列的最少操作次数](../../problems/minimum-operations-to-make-a-subsequence) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1710 | [卡车上的最大单元数](../../problems/maximum-units-on-a-truck) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1708 | [长度为 K 的最大子数组](../../problems/largest-subarray-length-k) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 1707 | [与数组中元素的最大异或值](../../problems/maximum-xor-with-an-element-from-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] | Hard | +| 1706 | [球会落何处](../../problems/where-will-the-ball-fall) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1705 | [吃苹果的最大数目](../../problems/maximum-number-of-eaten-apples) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1703 | [得到连续 K 个 1 的最少相邻交换次数](../../problems/minimum-adjacent-swaps-for-k-consecutive-ones) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 1701 | [平均等待时间](../../problems/average-waiting-time) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1700 | [无法吃午餐的学生数量](../../problems/number-of-students-unable-to-eat-lunch) | [[栈](../stack/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1697 | [检查边长度限制的路径是否存在](../../problems/checking-existence-of-edge-length-limited-paths) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1696 | [跳跃游戏 VI](../../problems/jump-game-vi) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1695 | [删除子数组的最大得分](../../problems/maximum-erasure-value) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1691 | [堆叠长方体的最大高度](../../problems/maximum-height-by-stacking-cuboids) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1690 | [石子游戏 VII](../../problems/stone-game-vii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1686 | [石子游戏 VI](../../problems/stone-game-vi) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1685 | [有序数组中差绝对值之和](../../problems/sum-of-absolute-differences-in-a-sorted-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1684 | [统计一致字符串的数目](../../problems/count-the-number-of-consistent-strings) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1681 | [最小不兼容性](../../problems/minimum-incompatibility) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1679 | [K 和数对的最大数目](../../problems/max-number-of-k-sum-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1674 | [使数组互补的最少操作次数](../../problems/minimum-moves-to-make-array-complementary) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1672 | [最富有客户的资产总量](../../problems/richest-customer-wealth) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 1671 | [得到山形数组的最少删除次数](../../problems/minimum-number-of-removals-to-make-mountain-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] | Medium | +| 1665 | [完成所有任务的最少初始能量](../../problems/minimum-initial-energy-to-finish-tasks) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1664 | [生成平衡数组的方案数](../../problems/ways-to-make-a-fair-array) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1662 | [检查两个字符串数组是否相等](../../problems/check-if-two-string-arrays-are-equivalent) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] | Easy | +| 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1654 | [到家的最少跳跃次数](../../problems/minimum-jumps-to-reach-home) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1652 | [拆炸弹](../../problems/defuse-the-bomb) | [[数组](../array/README.md)] | Easy | -| 1646 | [获取生成数组中的最大值](../../problems/get-maximum-in-generated-array) | [[数组](../array/README.md)] | Easy | -| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1636 | [按照频率将数组升序排序](../../problems/sort-array-by-increasing-frequency) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1629 | [按键持续时间最长的键](../../problems/slowest-key) | [[数组](../array/README.md)] | Easy | -| 1619 | [删除某些元素后的数组均值](../../problems/mean-of-array-after-removing-some-elements) | [[数组](../array/README.md)] | Easy | -| 1608 | [特殊数组的特征值](../../problems/special-array-with-x-elements-greater-than-or-equal-x) | [[数组](../array/README.md)] | Easy | -| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1588 | [所有奇数长度子数组的和](../../problems/sum-of-all-odd-length-subarrays) | [[数组](../array/README.md)] | Easy | -| 1583 | [统计不开心的朋友](../../problems/count-unhappy-friends) | [[数组](../array/README.md)] | Medium | -| 1582 | [二进制矩阵中的特殊位置](../../problems/special-positions-in-a-binary-matrix) | [[数组](../array/README.md)] | Easy | -| 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1572 | [矩阵对角线元素的和](../../problems/matrix-diagonal-sum) | [[数组](../array/README.md)] | Easy | -| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1566 | [重复至少 K 次且长度为 M 的模式](../../problems/detect-pattern-of-length-m-repeated-k-or-more-times) | [[数组](../array/README.md)] | Easy | -| 1560 | [圆形赛道上经过次数最多的扇区](../../problems/most-visited-sector-in-a-circular-track) | [[数组](../array/README.md)] | Easy | -| 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1646 | [获取生成数组中的最大值](../../problems/get-maximum-in-generated-array) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1643 | [第 K 条最小指令](../../problems/kth-smallest-instructions) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1642 | [可以到达的最远建筑](../../problems/furthest-building-you-can-reach) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1639 | [通过给定词典构造目标字符串的方案数](../../problems/number-of-ways-to-form-a-target-string-given-a-dictionary) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1637 | [两点之间不包含任何点的最宽垂直面积](../../problems/widest-vertical-area-between-two-points-containing-no-points) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1636 | [按照频率将数组升序排序](../../problems/sort-array-by-increasing-frequency) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1630 | [等差子数组](../../problems/arithmetic-subarrays) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1629 | [按键持续时间最长的键](../../problems/slowest-key) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1627 | [带阈值的图连通性](../../problems/graph-connectivity-with-threshold) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1626 | [无矛盾的最佳球队](../../problems/best-team-with-no-conflicts) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1620 | [网络信号最好的坐标](../../problems/coordinate-with-maximum-network-quality) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Medium | +| 1619 | [删除某些元素后的数组均值](../../problems/mean-of-array-after-removing-some-elements) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 1608 | [特殊数组的特征值](../../problems/special-array-with-x-elements-greater-than-or-equal-x) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1605 | [给定行和列的和求可行矩阵](../../problems/find-valid-matrix-given-row-and-column-sums) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1599 | [经营摩天轮的最大利润](../../problems/maximum-profit-of-operating-a-centennial-wheel) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1598 | [文件夹操作日志搜集器](../../problems/crawler-log-folder) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1591 | [奇怪的打印机 II](../../problems/strange-printer-ii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1589 | [所有排列中的最大和](../../problems/maximum-sum-obtained-of-any-permutation) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1588 | [所有奇数长度子数组的和](../../problems/sum-of-all-odd-length-subarrays) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | +| 1584 | [连接所有点的最小费用](../../problems/min-cost-to-connect-all-points) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] | Medium | +| 1583 | [统计不开心的朋友](../../problems/count-unhappy-friends) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1582 | [二进制矩阵中的特殊位置](../../problems/special-positions-in-a-binary-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 1580 | [把箱子放进仓库里 II](../../problems/put-boxes-into-the-warehouse-ii) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1572 | [矩阵对角线元素的和](../../problems/matrix-diagonal-sum) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1568 | [使陆地分离的最少天数](../../problems/minimum-number-of-days-to-disconnect-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[强连通分量](../strongly-connected-component/README.md)] | Hard | +| 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1566 | [重复至少 K 次且长度为 M 的模式](../../problems/detect-pattern-of-length-m-repeated-k-or-more-times) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Easy | +| 1564 | [把箱子放进仓库里 I](../../problems/put-boxes-into-the-warehouse-i) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1563 | [石子游戏 V](../../problems/stone-game-v) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 1562 | [查找大小为 M 的最新分组](../../problems/find-latest-group-of-size-m) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1561 | [你可以获得的最大硬币数目](../../problems/maximum-number-of-coins-you-can-get) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1560 | [圆形赛道上经过次数最多的扇区](../../problems/most-visited-sector-in-a-circular-track) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1558 | [得到目标数组的最少函数调用次数](../../problems/minimum-numbers-of-function-calls-to-make-target-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 1550 | [存在连续三个奇数的数组](../../problems/three-consecutive-odds) | [[数组](../array/README.md)] | Easy | -| 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1535 | [找出数组游戏的赢家](../../problems/find-the-winner-of-an-array-game) | [[数组](../array/README.md)] | Medium | -| 1534 | [统计好三元组](../../problems/count-good-triplets) | [[数组](../array/README.md)] | Easy | -| 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1503 | [所有蚂蚁掉下来前的最后一刻](../../problems/last-moment-before-all-ants-fall-out-of-a-plank) | [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] | Medium | -| 1502 | [判断能否形成等差数列](../../problems/can-make-arithmetic-progression-from-sequence) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | -| 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1493 | [删掉一个元素以后全为 1 的最长子数组](../../problems/longest-subarray-of-1s-after-deleting-one-element) | [[数组](../array/README.md)] | Medium | -| 1491 | [去掉最低工资和最高工资后的工资平均值](../../problems/average-salary-excluding-the-minimum-and-maximum-salary) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1486 | [数组异或操作](../../problems/xor-operation-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | +| 1547 | [切棍子的最小成本](../../problems/minimum-cost-to-cut-a-stick) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1546 | [和为目标值且不重叠的非空子数组的最大数目](../../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1538 | [找出隐藏数组中出现次数最多的元素](../../problems/guess-the-majority-in-a-hidden-array) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1537 | [最大得分](../../problems/get-the-maximum-score) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1535 | [找出数组游戏的赢家](../../problems/find-the-winner-of-an-array-game) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1534 | [统计好三元组](../../problems/count-good-triplets) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Easy | +| 1533 | [找到最大整数的索引](../../problems/find-the-index-of-the-large-integer) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1528 | [重新排列字符串](../../problems/shuffle-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] | Easy | +| 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1504 | [统计全 1 子矩形](../../problems/count-submatrices-with-all-ones) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1503 | [所有蚂蚁掉下来前的最后一刻](../../problems/last-moment-before-all-ants-fall-out-of-a-plank) | [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1502 | [判断能否形成等差数列](../../problems/can-make-arithmetic-progression-from-sequence) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 1491 | [去掉最低工资和最高工资后的工资平均值](../../problems/average-salary-excluding-the-minimum-and-maximum-salary) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1482 | [制作 m 束花所需的最少天数](../../problems/minimum-number-of-days-to-make-m-bouquets) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1481 | [不同整数的最少数目](../../problems/least-number-of-unique-integers-after-k-removals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1480 | [一维数组的动态和](../../problems/running-sum-of-1d-array) | [[数组](../array/README.md)] | Easy | -| 1476 | [子矩形查询](../../problems/subrectangle-queries) | [[数组](../array/README.md)] | Medium | -| 1475 | [商品折扣后的最终价格](../../problems/final-prices-with-a-special-discount-in-a-shop) | [[数组](../array/README.md)] | Easy | -| 1471 | [数组中的 k 个最强值](../../problems/the-k-strongest-values-in-an-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1481 | [不同整数的最少数目](../../problems/least-number-of-unique-integers-after-k-removals) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1480 | [一维数组的动态和](../../problems/running-sum-of-1d-array) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | +| 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1477 | [找两个和为目标值且不重叠的子数组](../../problems/find-two-non-overlapping-sub-arrays-each-with-target-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1476 | [子矩形查询](../../problems/subrectangle-queries) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1475 | [商品折扣后的最终价格](../../problems/final-prices-with-a-special-discount-in-a-shop) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Easy | +| 1473 | [粉刷房子 III](../../problems/paint-house-iii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 1471 | [数组中的 k 个最强值](../../problems/the-k-strongest-values-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 1470 | [重新排列数组](../../problems/shuffle-the-array) | [[数组](../array/README.md)] | Easy | -| 1465 | [切割后面积最大的蛋糕](../../problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts) | [[数组](../array/README.md)] | Medium | -| 1464 | [数组中两元素的最大乘积](../../problems/maximum-product-of-two-elements-in-an-array) | [[数组](../array/README.md)] | Easy | -| 1460 | [通过翻转子数组使两个数组相等](../../problems/make-two-arrays-equal-by-reversing-sub-arrays) | [[数组](../array/README.md)] | Easy | +| 1465 | [切割后面积最大的蛋糕](../../problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1464 | [数组中两元素的最大乘积](../../problems/maximum-product-of-two-elements-in-an-array) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 1463 | [摘樱桃 II](../../problems/cherry-pickup-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1460 | [通过翻转子数组使两个数组相等](../../problems/make-two-arrays-equal-by-reversing-sub-arrays) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1458 | [两个子序列的最大点积](../../problems/max-dot-product-of-two-subsequences) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1453 | [圆形靶内的最大飞镖数量](../../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1450 | [在既定时间做作业的学生人数](../../problems/number-of-students-doing-homework-at-a-given-time) | [[数组](../array/README.md)] | Easy | -| 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1444 | [切披萨的方案数](../../problems/number-of-ways-of-cutting-a-pizza) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1441 | [用栈操作构建数组](../../problems/build-an-array-with-stack-operations) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1439 | [有序矩阵中的第 k 个最小数组和](../../problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1437 | [是否所有 1 都至少相隔 k 个元素](../../problems/check-if-all-1s-are-at-least-length-k-places-away) | [[数组](../array/README.md)] | Easy | +| 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1431 | [拥有最多糖果的孩子](../../problems/kids-with-the-greatest-number-of-candies) | [[数组](../array/README.md)] | Easy | -| 1428 | [至少有一个 1 的最左端列](../../problems/leftmost-column-with-at-least-a-one) 🔒 | [[数组](../array/README.md)] | Medium | -| 1427 | [字符串的左右移](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 1426 | [数元素](../../problems/counting-elements) 🔒 | [[数组](../array/README.md)] | Easy | -| 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1414 | [和为 K 的最少斐波那契数字数目](../../problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1413 | [逐步求和得到正数的最小值](../../problems/minimum-value-to-get-positive-step-by-step-sum) | [[数组](../array/README.md)] | Easy | -| 1409 | [查询带键的排列](../../problems/queries-on-a-permutation-with-key) | [[数组](../array/README.md)] | Medium | -| 1399 | [统计最大组的数目](../../problems/count-largest-group) | [[数组](../array/README.md)] | Easy | -| 1395 | [统计作战单位数](../../problems/count-number-of-teams) | [[数组](../array/README.md)] | Medium | -| 1394 | [找出数组中的幸运数](../../problems/find-lucky-integer-in-an-array) | [[数组](../array/README.md)] | Easy | -| 1389 | [按既定顺序创建目标数组](../../problems/create-target-array-in-the-given-order) | [[数组](../array/README.md)] | Easy | -| 1386 | [安排电影院座位](../../problems/cinema-seat-allocation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1385 | [两个数组间的距离值](../../problems/find-the-distance-value-between-two-arrays) | [[数组](../array/README.md)] | Easy | -| 1380 | [矩阵中的幸运数](../../problems/lucky-numbers-in-a-matrix) | [[数组](../array/README.md)] | Easy | +| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] | Medium | +| 1428 | [至少有一个 1 的最左端列](../../problems/leftmost-column-with-at-least-a-one) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1427 | [字符串的左右移](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1426 | [数元素](../../problems/counting-elements) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1425 | [带限制的子序列和](../../problems/constrained-subsequence-sum) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1418 | [点菜展示表](../../problems/display-table-of-food-orders-in-a-restaurant) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1413 | [逐步求和得到正数的最小值](../../problems/minimum-value-to-get-positive-step-by-step-sum) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | +| 1409 | [查询带键的排列](../../problems/queries-on-a-permutation-with-key) | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1406 | [石子游戏 III](../../problems/stone-game-iii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1402 | [做菜顺序](../../problems/reducing-dishes) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1395 | [统计作战单位数](../../problems/count-number-of-teams) | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1394 | [找出数组中的幸运数](../../problems/find-lucky-integer-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | +| 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1390 | [四因数](../../problems/four-divisors) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1389 | [按既定顺序创建目标数组](../../problems/create-target-array-in-the-given-order) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1388 | [3n 块披萨](../../problems/pizza-with-3n-slices) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1386 | [安排电影院座位](../../problems/cinema-seat-allocation) | [[贪心](../greedy/README.md)] [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1385 | [两个数组间的距离值](../../problems/find-the-distance-value-between-two-arrays) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1380 | [矩阵中的幸运数](../../problems/lucky-numbers-in-a-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | | 1375 | [灯泡开关 III](../../problems/bulb-switcher-iii) | [[数组](../array/README.md)] | Medium | -| 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | -| 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1346 | [检查整数及其两倍数是否存在](../../problems/check-if-n-and-its-double-exist) | [[数组](../array/README.md)] | Easy | -| 1343 | [大小为 K 且平均值大于等于阈值的子数组数目](../../problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold) | [[数组](../array/README.md)] | Medium | -| 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1337 | [矩阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1333 | [餐厅过滤器](../../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1331 | [数组序号转换](../../problems/rank-transform-of-an-array) | [[数组](../array/README.md)] | Easy | -| 1330 | [翻转子数组得到最大的数组值](../../problems/reverse-subarray-to-maximize-array-value) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | -| 1329 | [将矩阵按对角线排序](../../problems/sort-the-matrix-diagonally) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | +| 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1354 | [多次求和构造目标数组](../../problems/construct-target-array-with-multiple-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[数据流](../data-stream/README.md)] | Medium | +| 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 1349 | [参加考试的最大学生数](../../problems/maximum-students-taking-exam) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1346 | [检查整数及其两倍数是否存在](../../problems/check-if-n-and-its-double-exist) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1345 | [跳跃游戏 IV](../../problems/jump-game-iv) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 1343 | [大小为 K 且平均值大于等于阈值的子数组数目](../../problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1340 | [跳跃游戏 V](../../problems/jump-game-v) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1337 | [矩阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 1335 | [工作计划的最低难度](../../problems/minimum-difficulty-of-a-job-schedule) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1333 | [餐厅过滤器](../../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1331 | [数组序号转换](../../problems/rank-transform-of-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1330 | [翻转子数组得到最大的数组值](../../problems/reverse-subarray-to-maximize-array-value) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1329 | [将矩阵按对角线排序](../../problems/sort-the-matrix-diagonally) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1326 | [灌溉花园的最少水龙头数目](../../problems/minimum-number-of-taps-to-open-to-water-a-garden) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1324 | [竖直打印单词](../../problems/print-words-vertically) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1314 | [矩阵区域和](../../problems/matrix-block-sum) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1313 | [解压缩编码列表](../../problems/decompress-run-length-encoded-list) | [[数组](../array/README.md)] | Easy | -| 1304 | [和为零的N个唯一整数](../../problems/find-n-unique-integers-sum-up-to-zero) | [[数组](../array/README.md)] | Easy | -| 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1310 | [子数组异或查询](../../problems/xor-queries-of-a-subarray) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 1304 | [和为零的N个唯一整数](../../problems/find-n-unique-integers-sum-up-to-zero) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1301 | [最大得分的路径数目](../../problems/number-of-paths-with-max-score) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 1299 | [将每个元素替换为右侧最大元素](../../problems/replace-elements-with-greatest-element-on-right-side) | [[数组](../array/README.md)] | Easy | -| 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1298 | [你能从盒子里获得的最大糖果数](../../problems/maximum-candies-you-can-get-from-boxes) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] | Hard | +| 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | | 1295 | [统计位数为偶数的数字](../../problems/find-numbers-with-even-number-of-digits) | [[数组](../array/README.md)] | Easy | -| 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1293 | [网格中的最短路径](../../problems/shortest-path-in-a-grid-with-obstacles-elimination) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1289 | [下降路径最小和 II](../../problems/minimum-falling-path-sum-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1287 | [有序数组中出现次数超过25%的元素](../../problems/element-appearing-more-than-25-in-sorted-array) | [[数组](../array/README.md)] | Easy | -| 1277 | [统计全为 1 的正方形子矩阵](../../problems/count-square-submatrices-with-all-ones) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1275 | [找出井字棋的获胜者](../../problems/find-winner-on-a-tic-tac-toe-game) | [[数组](../array/README.md)] | Easy | -| 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | -| 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] | Easy | -| 1260 | [二维网格迁移](../../problems/shift-2d-grid) | [[数组](../array/README.md)] | Easy | -| 1252 | [奇数值单元格的数目](../../problems/cells-with-odd-values-in-a-matrix) | [[数组](../array/README.md)] | Easy | -| 1243 | [数组变换](../../problems/array-transformation) 🔒 | [[数组](../array/README.md)] | Easy | -| 1233 | [删除子文件夹](../../problems/remove-sub-folders-from-the-filesystem) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1284 | [转化为全零矩阵的最少反转次数](../../problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | [[位运算](../bit-manipulation/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1283 | [使结果不超过阈值的最小除数](../../problems/find-the-smallest-divisor-given-a-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1282 | [用户分组](../../problems/group-the-people-given-the-group-size-they-belong-to) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1277 | [统计全为 1 的正方形子矩阵](../../problems/count-square-submatrices-with-all-ones) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1275 | [找出井字棋的获胜者](../../problems/find-winner-on-a-tic-tac-toe-game) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1274 | [矩形内船只的数目](../../problems/number-of-ships-in-a-rectangle) 🔒 | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[交互](../interactive/README.md)] | Hard | +| 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数组](../array/README.md)] | Medium | +| 1268 | [搜索推荐系统](../../problems/search-suggestions-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1263 | [推箱子](../../problems/minimum-moves-to-move-a-box-to-their-target-location) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1262 | [可被三整除的最大和](../../problems/greatest-sum-divisible-by-three) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1260 | [二维网格迁移](../../problems/shift-2d-grid) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1258 | [近义词句子](../../problems/synonymous-sentences) 🔒 | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1257 | [最小公共区域](../../problems/smallest-common-region) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1255 | [得分最高的单词集合](../../problems/maximum-score-words-formed-by-letters) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1254 | [统计封闭岛屿的数目](../../problems/number-of-closed-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1253 | [重构 2 行二进制矩阵](../../problems/reconstruct-a-2-row-binary-matrix) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1252 | [奇数值单元格的数目](../../problems/cells-with-odd-values-in-a-matrix) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1250 | [检查「好数组」](../../problems/check-if-it-is-a-good-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[数论](../number-theory/README.md)] | Hard | +| 1248 | [统计「优美子数组」](../../problems/count-number-of-nice-subarrays) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1246 | [删除回文子数组](../../problems/palindrome-removal) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1243 | [数组变换](../../problems/array-transformation) 🔒 | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1239 | [串联字符串的最大长度](../../problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1233 | [删除子文件夹](../../problems/remove-sub-folders-from-the-filesystem) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 1222 | [可以攻击国王的皇后](../../problems/queens-that-can-attack-the-king) | [[数组](../array/README.md)] | Medium | -| 1217 | [玩筹码](../../problems/minimum-cost-to-move-chips-to-the-same-position) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | -| 1200 | [最小绝对差](../../problems/minimum-absolute-difference) | [[数组](../array/README.md)] | Easy | -| 1185 | [一周中的第几天](../../problems/day-of-the-week) | [[数组](../array/README.md)] | Easy | +| 1231 | [分享巧克力](../../problems/divide-chocolate) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1228 | [等差数列中缺失的数字](../../problems/missing-number-in-arithmetic-progression) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1224 | [最大相等频率](../../problems/maximum-equal-frequency) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 1223 | [掷骰子模拟](../../problems/dice-roll-simulation) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1222 | [可以攻击国王的皇后](../../problems/queens-that-can-attack-the-king) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1219 | [黄金矿工](../../problems/path-with-maximum-gold) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1217 | [玩筹码](../../problems/minimum-cost-to-move-chips-to-the-same-position) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[计数](../counting/README.md)] | Easy | +| 1210 | [穿过迷宫的最少移动次数](../../problems/minimum-moves-to-reach-target-with-rotations) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1207 | [独一无二的出现次数](../../problems/unique-number-of-occurrences) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1200 | [最小绝对差](../../problems/minimum-absolute-difference) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[计数](../counting/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1196 | [最多可以买到的苹果数量](../../problems/how-many-apples-can-you-put-into-the-basket) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1191 | [K 次串联后最大子数组之和](../../problems/k-concatenation-maximum-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1187 | [使数组严格递增](../../problems/make-array-strictly-increasing) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1186 | [删除一次得到子数组最大和](../../problems/maximum-subarray-sum-with-one-deletion) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1184 | [公交站间的距离](../../problems/distance-between-bus-stops) | [[数组](../array/README.md)] | Easy | -| 1177 | [构建回文串检测](../../problems/can-make-palindrome-from-substring) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | -| 1176 | [健身计划评估](../../problems/diet-plan-performance) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Easy | -| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1169 | [查询无效交易](../../problems/invalid-transactions) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | -| 1160 | [拼写单词](../../problems/find-words-that-can-be-formed-by-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1151 | [最少交换次数来组合所有的 1](../../problems/minimum-swaps-to-group-all-1s-together) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1182 | [与目标颜色间的最短距离](../../problems/shortest-distance-to-target-color) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1181 | [前后拼接](../../problems/before-and-after-puzzle) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1178 | [猜字谜](../../problems/number-of-valid-words-for-each-puzzle) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 1176 | [健身计划评估](../../problems/diet-plan-performance) 🔒 | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | +| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1169 | [查询无效交易](../../problems/invalid-transactions) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1167 | [连接棒材的最低费用](../../problems/minimum-cost-to-connect-sticks) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1160 | [拼写单词](../../problems/find-words-that-can-be-formed-by-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1151 | [最少交换次数来组合所有的 1](../../problems/minimum-swaps-to-group-all-1s-together) 🔒 | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1150 | [检查一个数是否在数组中占绝大多数](../../problems/check-if-a-number-is-majority-element-in-a-sorted-array) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1146 | [快照数组](../../problems/snapshot-array) | [[数组](../array/README.md)] | Medium | -| 1144 | [递减元素使数组呈锯齿状](../../problems/decrease-elements-to-make-array-zigzag) | [[数组](../array/README.md)] | Medium | -| 1133 | [最大唯一数](../../problems/largest-unique-number) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1128 | [等价多米诺骨牌对的数量](../../problems/number-of-equivalent-domino-pairs) | [[数组](../array/README.md)] | Easy | -| 1122 | [数组的相对排序](../../problems/relative-sort-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1109 | [航班预订统计](../../problems/corporate-flight-bookings) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 1089 | [复写零](../../problems/duplicate-zeros) | [[数组](../array/README.md)] | Easy | -| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1085 | [最小元素各数位之和](../../problems/sum-of-digits-in-the-minimum-number) 🔒 | [[数组](../array/README.md)] | Easy | -| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 1146 | [快照数组](../../problems/snapshot-array) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1144 | [递减元素使数组呈锯齿状](../../problems/decrease-elements-to-make-array-zigzag) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1140 | [石子游戏 II](../../problems/stone-game-ii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1139 | [最大的以 1 为边界的正方形](../../problems/largest-1-bordered-square) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1133 | [最大唯一数](../../problems/largest-unique-number) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1131 | [绝对值表达式的最大值](../../problems/maximum-of-absolute-value-expression) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1128 | [等价多米诺骨牌对的数量](../../problems/number-of-equivalent-domino-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | +| 1125 | [最小的必要团队](../../problems/smallest-sufficient-team) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1124 | [表现良好的最长时间段](../../problems/longest-well-performing-interval) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1122 | [数组的相对排序](../../problems/relative-sort-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数排序](../counting-sort/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1121 | [将数组分成几个递增序列](../../problems/divide-array-into-increasing-sequences) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Hard | +| 1109 | [航班预订统计](../../problems/corporate-flight-bookings) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1105 | [填充书架](../../problems/filling-bookcase-shelves) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1101 | [彼此熟识的最早时间](../../problems/the-earliest-moment-when-everyone-become-friends) 🔒 | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | +| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1095 | [山脉数组中查找目标值](../../problems/find-in-mountain-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Hard | +| 1094 | [拼车](../../problems/car-pooling) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1091 | [二进制矩阵中的最短路径](../../problems/shortest-path-in-binary-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1089 | [复写零](../../problems/duplicate-zeros) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1085 | [最小元素各数位之和](../../problems/sum-of-digits-in-the-minimum-number) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 1073 | [负二进制数相加](../../problems/adding-two-negabinary-numbers) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1072 | [按列翻转得到最大值等行数](../../problems/flip-columns-for-maximum-number-of-equal-rows) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | | 1064 | [不动点](../../problems/fixed-point) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1053 | [交换一次的先前排列](../../problems/previous-permutation-with-one-swap) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1052 | [爱生气的书店老板](../../problems/grumpy-bookstore-owner) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1051 | [高度检查器](../../problems/height-checker) | [[数组](../array/README.md)] | Easy | -| 1040 | [移动石子直到连续 II](../../problems/moving-stones-until-consecutive-ii) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1035 | [不相交的线](../../problems/uncrossed-lines) | [[数组](../array/README.md)] | Medium | -| 1031 | [两个非重叠子数组的最大和](../../problems/maximum-sum-of-two-non-overlapping-subarrays) | [[数组](../array/README.md)] | Medium | +| 1063 | [有效子数组的数目](../../problems/number-of-valid-subarrays) 🔒 | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 1060 | [有序数组中的缺失元素](../../problems/missing-element-in-sorted-array) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1057 | [校园自行车分配](../../problems/campus-bikes) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1053 | [交换一次的先前排列](../../problems/previous-permutation-with-one-swap) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1052 | [爱生气的书店老板](../../problems/grumpy-bookstore-owner) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1051 | [高度检查器](../../problems/height-checker) | [[数组](../array/README.md)] [[计数排序](../counting-sort/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1049 | [最后一块石头的重量 II](../../problems/last-stone-weight-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1048 | [最长字符串链](../../problems/longest-string-chain) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1046 | [最后一块石头的重量](../../problems/last-stone-weight) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 1043 | [分隔数组以得到最大和](../../problems/partition-array-for-maximum-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1040 | [移动石子直到连续 II](../../problems/moving-stones-until-consecutive-ii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1039 | [多边形三角剖分的最低得分](../../problems/minimum-score-triangulation-of-polygon) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 1035 | [不相交的线](../../problems/uncrossed-lines) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1032 | [字符流](../../problems/stream-of-characters) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[数据流](../data-stream/README.md)] | Hard | +| 1031 | [两个非重叠子数组的最大和](../../problems/maximum-sum-of-two-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1029 | [两地调度](../../problems/two-city-scheduling) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1027 | [最长等差数列](../../problems/longest-arithmetic-subsequence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1024 | [视频拼接](../../problems/video-stitching) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1020 | [飞地的数量](../../problems/number-of-enclaves) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1019 | [链表中的下一个更大节点](../../problems/next-greater-node-in-linked-list) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1018 | [可被 5 整除的二进制前缀](../../problems/binary-prefix-divisible-by-5) | [[数组](../array/README.md)] | Easy | -| 1014 | [最佳观光组合](../../problems/best-sightseeing-pair) | [[数组](../array/README.md)] | Medium | -| 1013 | [将数组分成和相等的三个部分](../../problems/partition-array-into-three-parts-with-equal-sum) | [[数组](../array/README.md)] | Easy | -| 1011 | [在 D 天内送达包裹的能力](../../problems/capacity-to-ship-packages-within-d-days) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1010 | [总持续时间可被 60 整除的歌曲](../../problems/pairs-of-songs-with-total-durations-divisible-by-60) | [[数组](../array/README.md)] | Medium | -| 1007 | [行相等的最少多米诺旋转](../../problems/minimum-domino-rotations-for-equal-row) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 999 | [可以被一步捕获的棋子数](../../problems/available-captures-for-rook) | [[数组](../array/README.md)] | Easy | -| 989 | [数组形式的整数加法](../../problems/add-to-array-form-of-integer) | [[数组](../array/README.md)] | Easy | -| 985 | [查询后的偶数和](../../problems/sum-of-even-numbers-after-queries) | [[数组](../array/README.md)] | Easy | -| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 977 | [有序数组的平方](../../problems/squares-of-a-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 974 | [和可被 K 整除的子数组](../../problems/subarray-sums-divisible-by-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 969 | [煎饼排序](../../problems/pancake-sorting) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 962 | [最大宽度坡](../../problems/maximum-width-ramp) | [[数组](../array/README.md)] | Medium | -| 954 | [二倍数对数组](../../problems/array-of-doubled-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 950 | [按递增顺序显示卡牌](../../problems/reveal-cards-in-increasing-order) | [[数组](../array/README.md)] | Medium | -| 945 | [使数组唯一的最小增量](../../problems/minimum-increment-to-make-array-unique) | [[数组](../array/README.md)] | Medium | +| 1014 | [最佳观光组合](../../problems/best-sightseeing-pair) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1013 | [将数组分成和相等的三个部分](../../problems/partition-array-into-three-parts-with-equal-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 1011 | [在 D 天内送达包裹的能力](../../problems/capacity-to-ship-packages-within-d-days) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1010 | [总持续时间可被 60 整除的歌曲](../../problems/pairs-of-songs-with-total-durations-divisible-by-60) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 1008 | [前序遍历构造二叉搜索树](../../problems/construct-binary-search-tree-from-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1007 | [行相等的最少多米诺旋转](../../problems/minimum-domino-rotations-for-equal-row) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1005 | [K 次取反后最大化的数组和](../../problems/maximize-sum-of-array-after-k-negations) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1001 | [网格照明](../../problems/grid-illumination) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 1000 | [合并石头的最低成本](../../problems/minimum-cost-to-merge-stones) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 999 | [可以被一步捕获的棋子数](../../problems/available-captures-for-rook) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 997 | [找到小镇的法官](../../problems/find-the-town-judge) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 994 | [腐烂的橘子](../../problems/rotting-oranges) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 990 | [等式方程的可满足性](../../problems/satisfiability-of-equality-equations) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 989 | [数组形式的整数加法](../../problems/add-to-array-form-of-integer) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 986 | [区间列表的交集](../../problems/interval-list-intersections) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 985 | [查询后的偶数和](../../problems/sum-of-even-numbers-after-queries) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 983 | [最低票价](../../problems/minimum-cost-for-tickets) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 982 | [按位与为零的三元组](../../problems/triples-with-bitwise-and-equal-to-zero) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 980 | [不同路径 III](../../problems/unique-paths-iii) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 977 | [有序数组的平方](../../problems/squares-of-a-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Easy | +| 976 | [三角形的最大周长](../../problems/largest-perimeter-triangle) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[有序集合](../ordered-set/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 974 | [和可被 K 整除的子数组](../../problems/subarray-sums-divisible-by-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 969 | [煎饼排序](../../problems/pancake-sorting) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 962 | [最大宽度坡](../../problems/maximum-width-ramp) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 961 | [重复 N 次的元素](../../problems/n-repeated-element-in-size-2n-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 960 | [删列造序 III](../../problems/delete-columns-to-make-sorted-iii) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 957 | [N 天后的牢房](../../problems/prison-cells-after-n-days) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 956 | [最高的广告牌](../../problems/tallest-billboard) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 955 | [删列造序 II](../../problems/delete-columns-to-make-sorted-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 954 | [二倍数对数组](../../problems/array-of-doubled-pairs) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 953 | [验证外星语词典](../../problems/verifying-an-alien-dictionary) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 952 | [按公因数计算最大组件大小](../../problems/largest-component-size-by-common-factor) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 950 | [按递增顺序显示卡牌](../../problems/reveal-cards-in-increasing-order) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 946 | [验证栈序列](../../problems/validate-stack-sequences) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 945 | [使数组唯一的最小增量](../../problems/minimum-increment-to-make-array-unique) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 944 | [删列造序](../../problems/delete-columns-to-make-sorted) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 943 | [最短超级串](../../problems/find-the-shortest-superstring) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 942 | [增减字符串匹配](../../problems/di-string-match) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 941 | [有效的山脉数组](../../problems/valid-mountain-array) | [[数组](../array/README.md)] | Easy | -| 926 | [将字符串翻转到单调递增](../../problems/flip-string-to-monotone-increasing) | [[数组](../array/README.md)] | Medium | -| 922 | [按奇偶排序数组 II](../../problems/sort-array-by-parity-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 918 | [环形子数组的最大和](../../problems/maximum-sum-circular-subarray) | [[数组](../array/README.md)] | Medium | +| 939 | [最小面积矩形](../../problems/minimum-area-rectangle) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 937 | [重新排列日志文件](../../problems/reorder-data-in-log-files) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 932 | [漂亮数组](../../problems/beautiful-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] | Medium | +| 931 | [下降路径最小和](../../problems/minimum-falling-path-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 929 | [独特的电子邮件地址](../../problems/unique-email-addresses) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 927 | [三等分](../../problems/three-equal-parts) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 924 | [尽量减少恶意软件的传播](../../problems/minimize-malware-spread) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 923 | [三数之和的多种可能](../../problems/3sum-with-multiplicity) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 922 | [按奇偶排序数组 II](../../problems/sort-array-by-parity-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Easy | +| 918 | [环形子数组的最大和](../../problems/maximum-sum-circular-subarray) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] | Medium | +| 916 | [单词子集](../../problems/word-subsets) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 915 | [分割数组](../../problems/partition-array-into-disjoint-intervals) | [[数组](../array/README.md)] | Medium | -| 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 907 | [子数组的最小值之和](../../problems/sum-of-subarray-minimums) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Medium | -| 905 | [按奇偶排序数组](../../problems/sort-array-by-parity) | [[数组](../array/README.md)] | Easy | -| 900 | [RLE 迭代器](../../problems/rle-iterator) | [[数组](../array/README.md)] | Medium | +| 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Easy | +| 912 | [排序数组](../../problems/sort-an-array) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数排序](../counting-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 911 | [在线选举](../../problems/online-election) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 910 | [最小差值 II](../../problems/smallest-range-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 909 | [蛇梯棋](../../problems/snakes-and-ladders) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 908 | [最小差值 I](../../problems/smallest-range-i) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 907 | [子数组的最小值之和](../../problems/sum-of-subarray-minimums) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 905 | [按奇偶排序数组](../../problems/sort-array-by-parity) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Easy | +| 904 | [水果成篮](../../problems/fruit-into-baskets) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 902 | [最大为 N 的数字组合](../../problems/numbers-at-most-n-given-digit-set) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 900 | [RLE 迭代器](../../problems/rle-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 898 | [子数组按位或操作](../../problems/bitwise-ors-of-subarrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 896 | [单调数列](../../problems/monotonic-array) | [[数组](../array/README.md)] | Easy | -| 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | -| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] | Easy | -| 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 867 | [转置矩阵](../../problems/transpose-matrix) | [[数组](../array/README.md)] | Easy | +| 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 892 | [三维形体的表面积](../../problems/surface-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | +| 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 885 | [螺旋矩阵 III](../../problems/spiral-matrix-iii) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 883 | [三维形体投影面积](../../problems/projection-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 879 | [盈利计划](../../problems/profitable-schemes) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 877 | [石子游戏](../../problems/stone-game) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 875 | [爱吃香蕉的珂珂](../../problems/koko-eating-bananas) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 874 | [模拟行走机器人](../../problems/walking-robot-simulation) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 871 | [最低加油次数](../../problems/minimum-number-of-refueling-stops) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 867 | [转置矩阵](../../problems/transpose-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 861 | [翻转矩阵后的得分](../../problems/score-after-flipping-matrix) | [[贪心](../greedy/README.md)] [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 860 | [柠檬水找零](../../problems/lemonade-change) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 853 | [车队](../../problems/car-fleet) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 852 | [山脉数组的峰顶索引](../../problems/peak-index-in-a-mountain-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 851 | [喧闹和富有](../../problems/loud-and-rich) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] | Medium | +| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[扫描线](../line-sweep/README.md)] | Hard | | 849 | [到最近的人的最大距离](../../problems/maximize-distance-to-closest-person) | [[数组](../array/README.md)] | Medium | -| 840 | [矩阵中的幻方](../../problems/magic-squares-in-grid) | [[数组](../array/README.md)] | Medium | -| 835 | [图像重叠](../../problems/image-overlap) | [[数组](../array/README.md)] | Medium | -| 832 | [翻转图像](../../problems/flipping-an-image) | [[数组](../array/README.md)] | Easy | -| 830 | [较大分组的位置](../../problems/positions-of-large-groups) | [[数组](../array/README.md)] | Easy | -| 825 | [适龄的朋友](../../problems/friends-of-appropriate-ages) | [[数组](../array/README.md)] | Medium | -| 795 | [区间子数组个数](../../problems/number-of-subarrays-with-bounded-maximum) | [[数组](../array/README.md)] | Medium | -| 792 | [匹配子序列的单词数](../../problems/number-of-matching-subsequences) | [[数组](../array/README.md)] | Medium | -| 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 848 | [字母移位](../../problems/shifting-letters) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 846 | [一手顺子](../../problems/hand-of-straights) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 845 | [数组中的最长山脉](../../problems/longest-mountain-in-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[枚举](../enumeration/README.md)] | Medium | +| 843 | [猜猜这个单词](../../problems/guess-the-word) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] [[交互](../interactive/README.md)] | Hard | +| 840 | [矩阵中的幻方](../../problems/magic-squares-in-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 835 | [图像重叠](../../problems/image-overlap) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 833 | [字符串中的查找与替换](../../problems/find-and-replace-in-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 832 | [翻转图像](../../problems/flipping-an-image) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 827 | [最大人工岛](../../problems/making-a-large-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 825 | [适龄的朋友](../../problems/friends-of-appropriate-ages) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 823 | [带因子的二叉树](../../problems/binary-trees-with-factors) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 822 | [翻转卡片游戏](../../problems/card-flipping-game) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 821 | [字符的最短距离](../../problems/shortest-distance-to-a-character) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 820 | [单词的压缩编码](../../problems/short-encoding-of-words) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 813 | [最大平均值和的分组](../../problems/largest-sum-of-averages) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 812 | [最大三角形面积](../../problems/largest-triangle-area) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 810 | [黑板异或游戏](../../problems/chalkboard-xor-game) | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 809 | [情感丰富的文字](../../problems/expressive-words) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 807 | [保持城市天际线](../../problems/max-increase-to-keep-city-skyline) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 806 | [写字符串需要的行数](../../problems/number-of-lines-to-write-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 805 | [数组的均值分割](../../problems/split-array-with-same-average) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 803 | [打砖块](../../problems/bricks-falling-when-hit) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 801 | [使序列递增的最小交换次数](../../problems/minimum-swaps-to-make-sequences-increasing) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 798 | [得分最高的最小轮调](../../problems/smallest-rotation-with-highest-score) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 795 | [区间子数组个数](../../problems/number-of-subarrays-with-bounded-maximum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 789 | [逃脱阻碍者](../../problems/escape-the-ghosts) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 775 | [全局倒置与局部倒置](../../problems/global-and-local-inversions) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 769 | [最多能完成排序的块](../../problems/max-chunks-to-make-sorted) | [[数组](../array/README.md)] | Medium | -| 768 | [最多能完成排序的块 II](../../problems/max-chunks-to-make-sorted-ii) | [[数组](../array/README.md)] | Hard | -| 766 | [托普利茨矩阵](../../problems/toeplitz-matrix) | [[数组](../array/README.md)] | Easy | -| 755 | [倒水](../../problems/pour-water) 🔒 | [[数组](../array/README.md)] | Medium | -| 747 | [至少是其他数字两倍的最大数](../../problems/largest-number-at-least-twice-of-others) | [[数组](../array/README.md)] | Easy | +| 774 | [最小化去加油站的最大距离](../../problems/minimize-max-distance-to-gas-station) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 773 | [滑动谜题](../../problems/sliding-puzzle) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 769 | [最多能完成排序的块](../../problems/max-chunks-to-make-sorted) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 768 | [最多能完成排序的块 II](../../problems/max-chunks-to-make-sorted-ii) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 766 | [托普利茨矩阵](../../problems/toeplitz-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 764 | [最大加号标志](../../problems/largest-plus-sign) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 760 | [找出变位映射](../../problems/find-anagram-mappings) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 757 | [设置交集大小至少为2](../../problems/set-intersection-size-at-least-two) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 755 | [倒水](../../problems/pour-water) 🔒 | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 750 | [角矩形的数量](../../problems/number-of-corner-rectangles) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 749 | [隔离病毒](../../problems/contain-virus) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Hard | +| 747 | [至少是其他数字两倍的最大数](../../problems/largest-number-at-least-twice-of-others) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 746 | [使用最小花费爬楼梯](../../problems/min-cost-climbing-stairs) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 729 | [我的日程安排表 I](../../problems/my-calendar-i) | [[数组](../array/README.md)] | Medium | -| 724 | [寻找数组的中心下标](../../problems/find-pivot-index) | [[数组](../array/README.md)] | Easy | -| 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 744 | [寻找比目标字母大的最小字母](../../problems/find-smallest-letter-greater-than-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 741 | [摘樱桃](../../problems/cherry-pickup) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 740 | [删除并获得点数](../../problems/delete-and-earn) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 735 | [行星碰撞](../../problems/asteroid-collision) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Medium | +| 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 733 | [图像渲染](../../problems/flood-fill) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 724 | [寻找数组的中心下标](../../problems/find-pivot-index) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | +| 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 722 | [删除注释](../../problems/remove-comments) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 721 | [账户合并](../../problems/accounts-merge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | | 717 | [1比特与2比特字符](../../problems/1-bit-and-2-bit-characters) | [[数组](../array/README.md)] | Easy | -| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 697 | [数组的度](../../problems/degree-of-an-array) | [[数组](../array/README.md)] | Easy | -| 695 | [岛屿的最大面积](../../problems/max-area-of-island) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | +| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | +| 704 | [二分查找](../../problems/binary-search) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 702 | [搜索长度未知的有序数组](../../problems/search-in-a-sorted-array-of-unknown-size) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Medium | +| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 697 | [数组的度](../../problems/degree-of-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 695 | [岛屿的最大面积](../../problems/max-area-of-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 689 | [三个无重叠子数组的最大和](../../problems/maximum-sum-of-3-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 683 | [K 个关闭的灯泡](../../problems/k-empty-slots) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 682 | [棒球比赛](../../problems/baseball-game) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 679 | [24 点游戏](../../problems/24-game) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 675 | [为高尔夫比赛砍树](../../problems/cut-off-trees-for-golf-event) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 674 | [最长连续递增序列](../../problems/longest-continuous-increasing-subsequence) | [[数组](../array/README.md)] | Easy | -| 670 | [最大交换](../../problems/maximum-swap) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 667 | [优美的排列 II](../../problems/beautiful-arrangement-ii) | [[数组](../array/README.md)] | Medium | -| 665 | [非递减数列](../../problems/non-decreasing-array) | [[数组](../array/README.md)] | Easy | -| 661 | [图片平滑器](../../problems/image-smoother) | [[数组](../array/README.md)] | Easy | +| 673 | [最长递增子序列的个数](../../problems/number-of-longest-increasing-subsequence) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 667 | [优美的排列 II](../../problems/beautiful-arrangement-ii) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 666 | [路径总和 IV](../../problems/path-sum-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 665 | [非递减数列](../../problems/non-decreasing-array) | [[数组](../array/README.md)] | Medium | +| 661 | [图片平滑器](../../problems/image-smoother) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 658 | [找到 K 个最接近的元素](../../problems/find-k-closest-elements) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 656 | [金币路径](../../problems/coin-path) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 654 | [最大二叉树](../../problems/maximum-binary-tree) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 648 | [单词替换](../../problems/replace-words) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 646 | [最长数对链](../../problems/maximum-length-of-pair-chain) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 645 | [错误的集合](../../problems/set-mismatch) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | | 644 | [子数组最大平均数 II](../../problems/maximum-average-subarray-ii) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 643 | [子数组最大平均数 I](../../problems/maximum-average-subarray-i) | [[数组](../array/README.md)] | Easy | -| 628 | [三个数的最大乘积](../../problems/maximum-product-of-three-numbers) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | -| 611 | [有效三角形的个数](../../problems/valid-triangle-number) | [[数组](../array/README.md)] | Medium | -| 605 | [种花问题](../../problems/can-place-flowers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 581 | [最短无序连续子数组](../../problems/shortest-unsorted-continuous-subarray) | [[数组](../array/README.md)] | Medium | -| 566 | [重塑矩阵](../../problems/reshape-the-matrix) | [[数组](../array/README.md)] | Easy | -| 565 | [数组嵌套](../../problems/array-nesting) | [[数组](../array/README.md)] | Medium | -| 562 | [矩阵中最长的连续1线段](../../problems/longest-line-of-consecutive-one-in-matrix) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 561 | [数组拆分 I](../../problems/array-partition-i) | [[数组](../array/README.md)] | Easy | -| 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 548 | [将数组分割成和相等的子数组](../../problems/split-array-with-equal-sum) 🔒 | [[数组](../array/README.md)] | Medium | -| 533 | [孤独像素 II](../../problems/lonely-pixel-ii) 🔒 | [[数组](../array/README.md)] | Medium | -| 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 531 | [孤独像素 I](../../problems/lonely-pixel-i) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 509 | [斐波那契数](../../problems/fibonacci-number) | [[数组](../array/README.md)] | Easy | -| 495 | [提莫攻击](../../problems/teemo-attacking) | [[数组](../array/README.md)] | Easy | +| 643 | [子数组最大平均数 I](../../problems/maximum-average-subarray-i) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | +| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 638 | [大礼包](../../problems/shopping-offers) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 636 | [函数的独占时间](../../problems/exclusive-time-of-functions) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Medium | +| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 630 | [课程表 III](../../problems/course-schedule-iii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 628 | [三个数的最大乘积](../../problems/maximum-product-of-three-numbers) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 616 | [给字符串添加加粗标签](../../problems/add-bold-tag-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 611 | [有效三角形的个数](../../problems/valid-triangle-number) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 605 | [种花问题](../../problems/can-place-flowers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[迭代器](../iterator/README.md)] | Easy | +| 599 | [两个列表的最小索引总和](../../problems/minimum-index-sum-of-two-lists) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 598 | [范围求和 II](../../problems/range-addition-ii) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 594 | [最长和谐子序列](../../problems/longest-harmonious-subsequence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 587 | [安装栅栏](../../problems/erect-the-fence) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 581 | [最短无序连续子数组](../../problems/shortest-unsorted-continuous-subarray) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 575 | [分糖果](../../problems/distribute-candies) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 573 | [松鼠模拟](../../problems/squirrel-simulation) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 568 | [最大休假天数](../../problems/maximum-vacation-days) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 566 | [重塑矩阵](../../problems/reshape-the-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 565 | [数组嵌套](../../problems/array-nesting) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 562 | [矩阵中最长的连续1线段](../../problems/longest-line-of-consecutive-one-in-matrix) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 561 | [数组拆分 I](../../problems/array-partition-i) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[计数排序](../counting-sort/README.md)] [[排序](../sorting/README.md)] | Easy | +| 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 555 | [分割连接字符串](../../problems/split-concatenated-strings) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 554 | [砖墙](../../problems/brick-wall) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 553 | [最优除法](../../problems/optimal-division) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 548 | [将数组分割成和相等的子数组](../../problems/split-array-with-equal-sum) 🔒 | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 546 | [移除盒子](../../problems/remove-boxes) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 542 | [01 矩阵](../../problems/01-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 540 | [有序数组中的单一元素](../../problems/single-element-in-a-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 539 | [最小时间差](../../problems/minimum-time-difference) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 533 | [孤独像素 II](../../problems/lonely-pixel-ii) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 531 | [孤独像素 I](../../problems/lonely-pixel-i) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 529 | [扫雷游戏](../../problems/minesweeper) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[贪心](../greedy/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | +| 526 | [优美的排列](../../problems/beautiful-arrangement) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 525 | [连续数组](../../problems/contiguous-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 523 | [连续的子数组和](../../problems/continuous-subarray-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 522 | [最长特殊序列 II](../../problems/longest-uncommon-subsequence-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 518 | [零钱兑换 II](../../problems/coin-change-2) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 517 | [超级洗衣机](../../problems/super-washing-machines) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Hard | +| 506 | [相对名次](../../problems/relative-ranks) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 503 | [下一个更大元素 II](../../problems/next-greater-element-ii) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 502 | [IPO](../../problems/ipo) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 500 | [键盘行](../../problems/keyboard-row) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 498 | [对角线遍历](../../problems/diagonal-traverse) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 496 | [下一个更大元素 I](../../problems/next-greater-element-i) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[单调栈](../monotonic-stack/README.md)] | Easy | +| 495 | [提莫攻击](../../problems/teemo-attacking) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 494 | [目标和](../../problems/target-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 493 | [翻转对](../../problems/reverse-pairs) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 491 | [递增子序列](../../problems/increasing-subsequences) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 487 | [最大连续1的个数 II](../../problems/max-consecutive-ones-ii) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 486 | [预测赢家](../../problems/predict-the-winner) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 485 | [最大连续 1 的个数](../../problems/max-consecutive-ones) | [[数组](../array/README.md)] | Easy | -| 457 | [环形数组是否存在循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 448 | [找到所有数组中消失的数字](../../problems/find-all-numbers-disappeared-in-an-array) | [[数组](../array/README.md)] | Easy | -| 442 | [数组中重复的数据](../../problems/find-all-duplicates-in-an-array) | [[数组](../array/README.md)] | Medium | -| 414 | [第三大的数](../../problems/third-maximum-number) | [[数组](../array/README.md)] | Easy | -| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 380 | [O(1) 时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 370 | [区间加法](../../problems/range-addition) 🔒 | [[数组](../array/README.md)] | Medium | -| 289 | [生命游戏](../../problems/game-of-life) | [[数组](../array/README.md)] | Medium | -| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 484 | [寻找排列](../../problems/find-permutation) 🔒 | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 480 | [滑动窗口中位数](../../problems/sliding-window-median) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 477 | [汉明距离总和](../../problems/total-hamming-distance) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 475 | [供暖器](../../problems/heaters) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 474 | [一和零](../../problems/ones-and-zeroes) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 473 | [火柴拼正方形](../../problems/matchsticks-to-square) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 465 | [最优账单平衡](../../problems/optimal-account-balancing) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 463 | [岛屿的周长](../../problems/island-perimeter) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 462 | [最少移动次数使数组元素相等 II](../../problems/minimum-moves-to-equal-array-elements-ii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 457 | [环形数组是否存在循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 456 | [132 模式](../../problems/132-pattern) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 455 | [分发饼干](../../problems/assign-cookies) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 454 | [四数相加 II](../../problems/4sum-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 453 | [最小操作次数使数组元素相等](../../problems/minimum-moves-to-equal-array-elements) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 448 | [找到所有数组中消失的数字](../../problems/find-all-numbers-disappeared-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 447 | [回旋镖的数量](../../problems/number-of-boomerangs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 446 | [等差数列划分 II - 子序列](../../problems/arithmetic-slices-ii-subsequence) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 444 | [序列重建](../../problems/sequence-reconstruction) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] | Medium | +| 442 | [数组中重复的数据](../../problems/find-all-duplicates-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 436 | [寻找右区间](../../problems/find-right-interval) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 435 | [无重叠区间](../../problems/non-overlapping-intervals) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 427 | [建立四叉树](../../problems/construct-quad-tree) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 425 | [单词方块](../../problems/word-squares) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 422 | [有效的单词方块](../../problems/valid-word-square) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 421 | [数组中两个数的最大异或值](../../problems/maximum-xor-of-two-numbers-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 419 | [甲板上的战舰](../../problems/battleships-in-a-board) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 417 | [太平洋大西洋水流问题](../../problems/pacific-atlantic-water-flow) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 416 | [分割等和子集](../../problems/partition-equal-subset-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 414 | [第三大的数](../../problems/third-maximum-number) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 406 | [根据身高重建队列](../../problems/queue-reconstruction-by-height) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 403 | [青蛙过河](../../problems/frog-jump) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 399 | [除法求值](../../problems/evaluate-division) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Medium | +| 393 | [UTF-8 编码验证](../../problems/utf-8-validation) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Medium | +| 391 | [完美矩形](../../problems/perfect-rectangle) | [[数组](../array/README.md)] [[扫描线](../line-sweep/README.md)] | Hard | +| 384 | [打乱数组](../../problems/shuffle-an-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Hard | +| 380 | [O(1) 时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 377 | [组合总和 Ⅳ](../../problems/combination-sum-iv) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 373 | [查找和最小的K对数字](../../problems/find-k-pairs-with-smallest-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 370 | [区间加法](../../problems/range-addition) 🔒 | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 362 | [敲击计数器](../../problems/design-hit-counter) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 361 | [轰炸敌人](../../problems/bomb-enemy) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 356 | [直线镜像](../../problems/line-reflection) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 354 | [俄罗斯套娃信封问题](../../problems/russian-doll-envelopes) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 348 | [设计井字棋](../../problems/design-tic-tac-toe) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数据流](../data-stream/README.md)] | Easy | +| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 335 | [路径交叉](../../problems/self-crossing) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 334 | [递增的三元子序列](../../problems/increasing-triplet-subsequence) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 330 | [按要求补齐数组](../../problems/patching-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Hard | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 325 | [和等于 k 的最长子数组长度](../../problems/maximum-size-subarray-sum-equals-k) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 324 | [摆动排序 II](../../problems/wiggle-sort-ii) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] | Medium | +| 322 | [零钱兑换](../../problems/coin-change) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 318 | [最大单词长度乘积](../../problems/maximum-product-of-word-lengths) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 317 | [离建筑物最近的距离](../../problems/shortest-distance-from-all-buildings) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 313 | [超级丑数](../../problems/super-ugly-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 312 | [戳气球](../../problems/burst-balloons) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 311 | [稀疏矩阵的乘法](../../problems/sparse-matrix-multiplication) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 309 | [最佳买卖股票时机含冷冻期](../../problems/best-time-to-buy-and-sell-stock-with-cooldown) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 308 | [二维区域和检索 - 可变](../../problems/range-sum-query-2d-mutable) 🔒 | [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 307 | [区域和检索 - 数组可修改](../../problems/range-sum-query-mutable) | [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] | Medium | +| 305 | [岛屿数量 II](../../problems/number-of-islands-ii) 🔒 | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Hard | +| 304 | [二维区域和检索 - 矩阵不可变](../../problems/range-sum-query-2d-immutable) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 303 | [区域和检索 - 数组不可变](../../problems/range-sum-query-immutable) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | +| 302 | [包含全部黑色像素的最小矩形](../../problems/smallest-rectangle-enclosing-black-pixels) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 300 | [最长递增子序列](../../problems/longest-increasing-subsequence) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Hard | +| 289 | [生命游戏](../../problems/game-of-life) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 286 | [墙与门](../../problems/walls-and-gates) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 277 | [搜寻名人](../../problems/find-the-celebrity) 🔒 | [[数组](../array/README.md)] | Medium | -| 268 | [丢失的数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 245 | [最短单词距离 III](../../problems/shortest-word-distance-iii) 🔒 | [[数组](../array/README.md)] | Medium | -| 243 | [最短单词距离](../../problems/shortest-word-distance) 🔒 | [[数组](../array/README.md)] | Easy | -| 238 | [除自身以外数组的乘积](../../problems/product-of-array-except-self) | [[数组](../array/README.md)] | Medium | -| 229 | [求众数 II](../../problems/majority-element-ii) | [[数组](../array/README.md)] | Medium | +| 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 275 | [H 指数 II](../../problems/h-index-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 274 | [H 指数](../../problems/h-index) | [[数组](../array/README.md)] [[计数排序](../counting-sort/README.md)] [[排序](../sorting/README.md)] | Medium | +| 271 | [字符串的编码与解码](../../problems/encode-and-decode-strings) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | +| 268 | [丢失的数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 265 | [粉刷房子 II](../../problems/paint-house-ii) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 260 | [只出现一次的数字 III](../../problems/single-number-iii) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Medium | +| 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 256 | [粉刷房子](../../problems/paint-house) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 254 | [因子的组合](../../problems/factor-combinations) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 252 | [会议室](../../problems/meeting-rooms) 🔒 | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | +| 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 245 | [最短单词距离 III](../../problems/shortest-word-distance-iii) 🔒 | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 243 | [最短单词距离](../../problems/shortest-word-distance) 🔒 | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 238 | [除自身以外数组的乘积](../../problems/product-of-array-except-self) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 229 | [求众数 II](../../problems/majority-element-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | | 228 | [汇总区间](../../problems/summary-ranges) | [[数组](../array/README.md)] | Easy | -| 219 | [存在重复元素 II](../../problems/contains-duplicate-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 217 | [存在重复元素](../../problems/contains-duplicate) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 189 | [旋转数组](../../problems/rotate-array) | [[数组](../array/README.md)] | Medium | -| 169 | [多数元素](../../problems/majority-element) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Easy | +| 221 | [最大正方形](../../problems/maximal-square) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[数组](../array/README.md)] [[桶排序](../bucket-sort/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 219 | [存在重复元素 II](../../problems/contains-duplicate-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[扫描线](../line-sweep/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 217 | [存在重复元素](../../problems/contains-duplicate) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 215 | [数组中的第K个最大元素](../../problems/kth-largest-element-in-an-array) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 213 | [打家劫舍 II](../../problems/house-robber-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 204 | [计数质数](../../problems/count-primes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] [[数论](../number-theory/README.md)] | Easy | +| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 198 | [打家劫舍](../../problems/house-robber) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 189 | [旋转数组](../../problems/rotate-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 188 | [买卖股票的最佳时机 IV](../../problems/best-time-to-buy-and-sell-stock-iv) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 174 | [地下城游戏](../../problems/dungeon-game) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | +| 169 | [多数元素](../../problems/majority-element) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | | 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 164 | [最大间距](../../problems/maximum-gap) | [[数组](../array/README.md)] [[桶排序](../bucket-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] | Hard | | 163 | [缺失的区间](../../problems/missing-ranges) 🔒 | [[数组](../array/README.md)] | Easy | | 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 154 | [寻找旋转排序数组中的最小值 II](../../problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 152 | [乘积最大子数组](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 128 | [最长连续序列](../../problems/longest-consecutive-sequence) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | -| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 137 | [只出现一次的数字 II](../../problems/single-number-ii) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Medium | +| 136 | [只出现一次的数字](../../problems/single-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | +| 135 | [分发糖果](../../problems/candy) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Hard | +| 134 | [加油站](../../problems/gas-station) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 128 | [最长连续序列](../../problems/longest-consecutive-sequence) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 123 | [买卖股票的最佳时机 III](../../problems/best-time-to-buy-and-sell-stock-iii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 121 | [买卖股票的最佳时机](../../problems/best-time-to-buy-and-sell-stock) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 120 | [三角形最小路径和](../../problems/triangle) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 119 | [杨辉三角 II](../../problems/pascals-triangle-ii) | [[数组](../array/README.md)] | Easy | -| 118 | [杨辉三角](../../problems/pascals-triangle) | [[数组](../array/README.md)] | Easy | -| 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 90 | [子集 II](../../problems/subsets-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 88 | [合并两个有序数组](../../problems/merge-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 84 | [柱状图中最大的矩形](../../problems/largest-rectangle-in-histogram) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Hard | +| 119 | [杨辉三角 II](../../problems/pascals-triangle-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 118 | [杨辉三角](../../problems/pascals-triangle) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 90 | [子集 II](../../problems/subsets-ii) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 88 | [合并两个有序数组](../../problems/merge-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Easy | +| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 84 | [柱状图中最大的矩形](../../problems/largest-rectangle-in-histogram) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 81 | [搜索旋转排序数组 II](../../problems/search-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 80 | [删除有序数组中的重复项 II](../../problems/remove-duplicates-from-sorted-array-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 79 | [单词搜索](../../problems/word-search) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 74 | [搜索二维矩阵](../../problems/search-a-2d-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 73 | [矩阵置零](../../problems/set-matrix-zeroes) | [[数组](../array/README.md)] | Medium | -| 66 | [加一](../../problems/plus-one) | [[数组](../array/README.md)] | Easy | -| 64 | [最小路径和](../../problems/minimum-path-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 63 | [不同路径 II](../../problems/unique-paths-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 62 | [不同路径](../../problems/unique-paths) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 59 | [螺旋矩阵 II](../../problems/spiral-matrix-ii) | [[数组](../array/README.md)] | Medium | -| 57 | [插入区间](../../problems/insert-interval) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 56 | [合并区间](../../problems/merge-intervals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 55 | [跳跃游戏](../../problems/jump-game) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 54 | [螺旋矩阵](../../problems/spiral-matrix) | [[数组](../array/README.md)] | Medium | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 48 | [旋转图像](../../problems/rotate-image) | [[数组](../array/README.md)] | Medium | -| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 41 | [缺失的第一个正数](../../problems/first-missing-positive) | [[数组](../array/README.md)] | Hard | -| 40 | [组合总和 II](../../problems/combination-sum-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 39 | [组合总和](../../problems/combination-sum) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 79 | [单词搜索](../../problems/word-search) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 77 | [组合](../../problems/combinations) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 75 | [颜色分类](../../problems/sort-colors) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 74 | [搜索二维矩阵](../../problems/search-a-2d-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 73 | [矩阵置零](../../problems/set-matrix-zeroes) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 66 | [加一](../../problems/plus-one) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 64 | [最小路径和](../../problems/minimum-path-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 63 | [不同路径 II](../../problems/unique-paths-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 59 | [螺旋矩阵 II](../../problems/spiral-matrix-ii) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 57 | [插入区间](../../problems/insert-interval) | [[数组](../array/README.md)] | Medium | +| 56 | [合并区间](../../problems/merge-intervals) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 55 | [跳跃游戏](../../problems/jump-game) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 54 | [螺旋矩阵](../../problems/spiral-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 51 | [N 皇后](../../problems/n-queens) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 48 | [旋转图像](../../problems/rotate-image) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 47 | [全排列 II](../../problems/permutations-ii) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 46 | [全排列](../../problems/permutations) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 41 | [缺失的第一个正数](../../problems/first-missing-positive) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 40 | [组合总和 II](../../problems/combination-sum-ii) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 39 | [组合总和](../../problems/combination-sum) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 37 | [解数独](../../problems/sudoku-solver) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 36 | [有效的数独](../../problems/valid-sudoku) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 35 | [搜索插入位置](../../problems/search-insert-position) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 34 | [在排序数组中查找元素的第一个和最后一个位置](../../problems/find-first-and-last-position-of-element-in-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 33 | [搜索旋转排序数组](../../problems/search-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 31 | [下一个排列](../../problems/next-permutation) | [[数组](../array/README.md)] | Medium | +| 31 | [下一个排列](../../problems/next-permutation) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 27 | [移除元素](../../problems/remove-element) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 26 | [删除有序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 11 | [盛最多水的容器](../../problems/container-with-most-water) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 4 | [寻找两个正序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 11 | [盛最多水的容器](../../problems/container-with-most-water) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 4 | [寻找两个正序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] | Hard | | 1 | [两数之和](../../problems/two-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 72edab524..9a4cc1442 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,73 +9,81 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1863 | [找出所有子集的异或总和再求和](../../problems/sum-of-all-subset-xor-totals) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | -| 1849 | [将字符串拆分为递减的连续值](../../problems/splitting-a-string-into-descending-consecutive-values) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1688 | [比赛中的配对次数](../../problems/count-of-matches-in-tournament) | [[回溯算法](../backtracking/README.md)] | Easy | -| 1681 | [最小不兼容性](../../problems/minimum-incompatibility) | [[贪心算法](../greedy/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[回溯算法](../backtracking/README.md)] | Hard | -| 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[回溯算法](../backtracking/README.md)] | Medium | -| 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1415 | [长度为 n 的开心字符串中字典序第 k 小的字符串](../../problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | [[回溯算法](../backtracking/README.md)] | Medium | -| 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1291 | [顺次数](../../problems/sequential-digits) | [[回溯算法](../backtracking/README.md)] | Medium | -| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1258 | [近义词句子](../../problems/synonymous-sentences) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | -| 1240 | [铺瓷砖](../../problems/tiling-a-rectangle-with-the-fewest-squares) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1239 | [串联字符串的最大长度](../../problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1219 | [黄金矿工](../../problems/path-with-maximum-gold) | [[回溯算法](../backtracking/README.md)] | Medium | -| 1215 | [步进数](../../problems/stepping-numbers) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | -| 1088 | [易混淆数 II](../../problems/confusing-number-ii) 🔒 | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1087 | [花括号展开](../../problems/brace-expansion) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | -| 1079 | [活字印刷](../../problems/letter-tile-possibilities) | [[回溯算法](../backtracking/README.md)] | Medium | -| 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 980 | [不同路径 III](../../problems/unique-paths-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 526 | [优美的排列](../../problems/beautiful-arrangement) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 425 | [单词方块](../../problems/word-squares) 🔒 | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 411 | [最短独占单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 401 | [二进制手表](../../problems/binary-watch) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | -| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 351 | [安卓系统手势解锁](../../problems/android-unlock-patterns) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 306 | [累加数](../../problems/additive-number) | [[回溯算法](../backtracking/README.md)] | Medium | -| 294 | [翻转游戏 II](../../problems/flip-game-ii) 🔒 | [[极小化极大](../minimax/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 291 | [单词规律 II](../../problems/word-pattern-ii) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | -| 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | -| 254 | [因子的组合](../../problems/factor-combinations) 🔒 | [[回溯算法](../backtracking/README.md)] | Medium | -| 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 140 | [单词拆分 II](../../problems/word-break-ii) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 93 | [复原 IP 地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 90 | [子集 II](../../problems/subsets-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 89 | [格雷编码](../../problems/gray-code) | [[回溯算法](../backtracking/README.md)] | Medium | -| 79 | [单词搜索](../../problems/word-search) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 77 | [组合](../../problems/combinations) | [[回溯算法](../backtracking/README.md)] | Medium | -| 60 | [排列序列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 52 | [N皇后 II](../../problems/n-queens-ii) | [[回溯算法](../backtracking/README.md)] | Hard | -| 51 | [N 皇后](../../problems/n-queens) | [[回溯算法](../backtracking/README.md)] | Hard | -| 47 | [全排列 II](../../problems/permutations-ii) | [[回溯算法](../backtracking/README.md)] | Medium | -| 46 | [全排列](../../problems/permutations) | [[回溯算法](../backtracking/README.md)] | Medium | -| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 40 | [组合总和 II](../../problems/combination-sum-ii) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 39 | [组合总和](../../problems/combination-sum) | [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 37 | [解数独](../../problems/sudoku-solver) | [[哈希表](../hash-table/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1863 | [找出所有子集的异或总和再求和](../../problems/sum-of-all-subset-xor-totals) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Easy | +| 1849 | [将字符串拆分为递减的连续值](../../problems/splitting-a-string-into-descending-consecutive-values) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1820 | [最多邀请的个数](../../problems/maximum-number-of-accepted-invitations) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] [[数论](../number-theory/README.md)] | Hard | +| 1774 | [最接近目标价格的甜点成本](../../problems/closest-dessert-cost) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[组合数学](../combinatorics/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Hard | +| 1415 | [长度为 n 的开心字符串中字典序第 k 小的字符串](../../problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 1258 | [近义词句子](../../problems/synonymous-sentences) 🔒 | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1255 | [得分最高的单词集合](../../problems/maximum-score-words-formed-by-letters) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1240 | [铺瓷砖](../../problems/tiling-a-rectangle-with-the-fewest-squares) | [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 1239 | [串联字符串的最大长度](../../problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1238 | [循环码排列](../../problems/circular-permutation-in-binary-representation) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1219 | [黄金矿工](../../problems/path-with-maximum-gold) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1215 | [步进数](../../problems/stepping-numbers) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1096 | [花括号展开 II](../../problems/brace-expansion-ii) | [[栈](../stack/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 1088 | [易混淆数 II](../../problems/confusing-number-ii) 🔒 | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 1087 | [花括号展开](../../problems/brace-expansion) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1079 | [活字印刷](../../problems/letter-tile-possibilities) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 980 | [不同路径 III](../../problems/unique-paths-iii) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[广度优先搜索](../breadth-first-search/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 816 | [模糊坐标](../../problems/ambiguous-coordinates) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 679 | [24 点游戏](../../problems/24-game) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 638 | [大礼包](../../problems/shopping-offers) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 526 | [优美的排列](../../problems/beautiful-arrangement) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 494 | [目标和](../../problems/target-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 491 | [递增子序列](../../problems/increasing-subsequences) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 489 | [扫地机器人](../../problems/robot-room-cleaner) 🔒 | [[回溯](../backtracking/README.md)] [[交互](../interactive/README.md)] | Hard | +| 488 | [祖玛游戏](../../problems/zuma-game) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 473 | [火柴拼正方形](../../problems/matchsticks-to-square) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 465 | [最优账单平衡](../../problems/optimal-account-balancing) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 425 | [单词方块](../../problems/word-squares) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 411 | [最短独占单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 401 | [二进制手表](../../problems/binary-watch) | [[位运算](../bit-manipulation/README.md)] [[回溯](../backtracking/README.md)] | Easy | +| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 351 | [安卓系统手势解锁](../../problems/android-unlock-patterns) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 306 | [累加数](../../problems/additive-number) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 301 | [删除无效的括号](../../problems/remove-invalid-parentheses) | [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 294 | [翻转游戏 II](../../problems/flip-game-ii) 🔒 | [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 291 | [单词规律 II](../../problems/word-pattern-ii) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 282 | [给表达式添加运算符](../../problems/expression-add-operators) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 254 | [因子的组合](../../problems/factor-combinations) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 140 | [单词拆分 II](../../problems/word-break-ii) | [[字典树](../trie/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 93 | [复原 IP 地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 90 | [子集 II](../../problems/subsets-ii) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 89 | [格雷编码](../../problems/gray-code) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 79 | [单词搜索](../../problems/word-search) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 77 | [组合](../../problems/combinations) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 52 | [N皇后 II](../../problems/n-queens-ii) | [[回溯](../backtracking/README.md)] | Hard | +| 51 | [N 皇后](../../problems/n-queens) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 47 | [全排列 II](../../problems/permutations-ii) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 46 | [全排列](../../problems/permutations) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 40 | [组合总和 II](../../problems/combination-sum-ii) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 39 | [组合总和](../../problems/combination-sum) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 37 | [解数独](../../problems/sudoku-solver) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | diff --git a/tag/binary-indexed-tree/README.md b/tag/binary-indexed-tree/README.md index 0beece97f..35a88ea73 100644 --- a/tag/binary-indexed-tree/README.md +++ b/tag/binary-indexed-tree/README.md @@ -9,10 +9,16 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 308 | [二维区域和检索 - 可变](../../problems/range-sum-query-2d-mutable) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Hard | -| 307 | [区域和检索 - 数组可修改](../../problems/range-sum-query-mutable) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Medium | -| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 1505 | [最多 K 次交换相邻数位后得到的最小整数](../../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | [[贪心](../greedy/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[字符串](../string/README.md)] | Hard | +| 1409 | [查询带键的排列](../../problems/queries-on-a-permutation-with-key) | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1395 | [统计作战单位数](../../problems/count-number-of-teams) | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 683 | [K 个关闭的灯泡](../../problems/k-empty-slots) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 673 | [最长递增子序列的个数](../../problems/number-of-longest-increasing-subsequence) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 493 | [翻转对](../../problems/reverse-pairs) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 308 | [二维区域和检索 - 可变](../../problems/range-sum-query-2d-mutable) 🔒 | [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 307 | [区域和检索 - 数组可修改](../../problems/range-sum-query-mutable) | [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] | Medium | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[扫描线](../line-sweep/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | diff --git a/tag/binary-search-tree/README.md b/tag/binary-search-tree/README.md index a95cd2821..7960c1f8f 100644 --- a/tag/binary-search-tree/README.md +++ b/tag/binary-search-tree/README.md @@ -9,8 +9,42 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1382 | [将二叉搜索树变平衡](../../problems/balance-a-binary-search-tree) | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | -| 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[二叉搜索树](../binary-search-tree/README.md)] | Medium | -| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1382 | [将二叉搜索树变平衡](../../problems/balance-a-binary-search-tree) | [[贪心](../greedy/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1008 | [前序遍历构造二叉搜索树](../../problems/construct-binary-search-tree-from-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 897 | [递增顺序搜索树](../../problems/increasing-order-search-tree) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[数据流](../data-stream/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 701 | [二叉搜索树中的插入操作](../../problems/insert-into-a-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 700 | [二叉搜索树中的搜索](../../problems/search-in-a-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 653 | [两数之和 IV - 输入 BST](../../problems/two-sum-iv-input-is-a-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 530 | [二叉搜索树的最小绝对差](../../problems/minimum-absolute-difference-in-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 510 | [二叉搜索树中的中序后继 II](../../problems/inorder-successor-in-bst-ii) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 501 | [二叉搜索树中的众数](../../problems/find-mode-in-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 450 | [删除二叉搜索树中的节点](../../problems/delete-node-in-a-bst) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 449 | [序列化和反序列化二叉搜索树](../../problems/serialize-and-deserialize-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 333 | [最大 BST 子树](../../problems/largest-bst-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 285 | [二叉搜索树中的中序后继](../../problems/inorder-successor-in-bst) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 235 | [二叉搜索树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 230 | [二叉搜索树中第K小的元素](../../problems/kth-smallest-element-in-a-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 99 | [恢复二叉搜索树](../../problems/recover-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index f5ffd28c2..d4f690c92 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,113 +9,148 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1884 | [鸡蛋掉落-两枚鸡蛋](../../problems/egg-drop-with-2-eggs-and-n-floors) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1870 | [准时到达的列车最小时速](../../problems/minimum-speed-to-arrive-on-time) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1855 | [下标对中的最大距离](../../problems/maximum-distance-between-a-pair-of-values) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1847 | [最近的房间](../../problems/closest-room) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1840 | [最高建筑高度](../../problems/maximum-building-height) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1802 | [有界数组中指定下标处的最大值](../../problems/maximum-value-at-a-given-index-in-a-bounded-array) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1760 | [袋子里最少数目的球](../../problems/minimum-limit-of-balls-in-a-bag) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1751 | [最多可以参加的会议数目 II](../../problems/maximum-number-of-events-that-can-be-attended-ii) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1739 | [放置盒子](../../problems/building-boxes) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1642 | [可以到达的最远建筑](../../problems/furthest-building-you-can-reach) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1562 | [查找大小为 M 的最新分组](../../problems/find-latest-group-of-size-m) | [[二分查找](../binary-search/README.md)] | Medium | -| 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1533 | [找到最大整数的索引](../../problems/find-the-index-of-the-large-integer) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | -| 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1918 | [Kth Smallest Subarray Sum](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1901 | [找出顶峰元素 II](../../problems/find-a-peak-element-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1898 | [可移除字符的最大数目](../../problems/maximum-number-of-removable-characters) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1894 | [找到需要补充粉笔的学生编号](../../problems/find-the-student-that-will-replace-the-chalk) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1891 | [割绳子](../../problems/cutting-ribbons) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1889 | [装包裹的最小浪费空间](../../problems/minimum-space-wasted-from-packaging) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1885 | [Count Pairs in Two Arrays](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1870 | [准时到达的列车最小时速](../../problems/minimum-speed-to-arrive-on-time) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1862 | [向下取整数对和](../../problems/sum-of-floored-pairs) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 1855 | [下标对中的最大距离](../../problems/maximum-distance-between-a-pair-of-values) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1851 | [包含每个查询的最小区间](../../problems/minimum-interval-to-include-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[扫描线](../line-sweep/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1847 | [最近的房间](../../problems/closest-room) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1838 | [最高频元素的频数](../../problems/frequency-of-the-most-frequent-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1802 | [有界数组中指定下标处的最大值](../../problems/maximum-value-at-a-given-index-in-a-bounded-array) | [[贪心](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1782 | [统计点对的数目](../../problems/count-pairs-of-nodes) | [[图](../graph/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1760 | [袋子里最少数目的球](../../problems/minimum-limit-of-balls-in-a-bag) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1751 | [最多可以参加的会议数目 II](../../problems/maximum-number-of-events-that-can-be-attended-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1739 | [放置盒子](../../problems/building-boxes) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1713 | [得到子序列的最少操作次数](../../problems/minimum-operations-to-make-a-subsequence) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1671 | [得到山形数组的最少删除次数](../../problems/minimum-number-of-removals-to-make-mountain-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1608 | [特殊数组的特征值](../../problems/special-array-with-x-elements-greater-than-or-equal-x) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1562 | [查找大小为 M 的最新分组](../../problems/find-latest-group-of-size-m) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 1533 | [找到最大整数的索引](../../problems/find-the-index-of-the-large-integer) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1483 | [树节点的第 K 个祖先](../../problems/kth-ancestor-of-a-tree-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1482 | [制作 m 束花所需的最少天数](../../problems/minimum-number-of-days-to-make-m-bouquets) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1337 | [矩阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1283 | [使结果不超过阈值的最小除数](../../problems/find-the-smallest-divisor-given-a-threshold) | [[二分查找](../binary-search/README.md)] | Medium | -| 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1231 | [分享巧克力](../../problems/divide-chocolate) 🔒 | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1182 | [与目标颜色间的最短距离](../../problems/shortest-distance-to-target-color) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | -| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1477 | [找两个和为目标值且不重叠的子数组](../../problems/find-two-non-overlapping-sub-arrays-each-with-target-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1439 | [有序矩阵中的第 k 个最小数组和](../../problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1428 | [至少有一个 1 的最左端列](../../problems/leftmost-column-with-at-least-a-one) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1385 | [两个数组间的距离值](../../problems/find-the-distance-value-between-two-arrays) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1346 | [检查整数及其两倍数是否存在](../../problems/check-if-n-and-its-double-exist) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1337 | [矩阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1283 | [使结果不超过阈值的最小除数](../../problems/find-the-smallest-divisor-given-a-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1231 | [分享巧克力](../../problems/divide-chocolate) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[计数](../counting/README.md)] | Easy | +| 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[数论](../number-theory/README.md)] | Medium | +| 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[计数](../counting/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1187 | [使数组严格递增](../../problems/make-array-strictly-increasing) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1182 | [与目标颜色间的最短距离](../../problems/shortest-distance-to-target-color) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1150 | [检查一个数是否在数组中占绝大多数](../../problems/check-if-a-number-is-majority-element-in-a-sorted-array) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1111 | [有效括号的嵌套深度](../../problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1095 | [山脉数组中查找目标值](../../problems/find-in-mountain-array) | [[二分查找](../binary-search/README.md)] | Hard | +| 1146 | [快照数组](../../problems/snapshot-array) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1095 | [山脉数组中查找目标值](../../problems/find-in-mountain-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Hard | | 1064 | [不动点](../../problems/fixed-point) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 1060 | [有序数组中的缺失元素](../../problems/missing-element-in-sorted-array) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | -| 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1011 | [在 D 天内送达包裹的能力](../../problems/capacity-to-ship-packages-within-d-days) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 911 | [在线选举](../../problems/online-election) | [[二分查找](../binary-search/README.md)] | Medium | +| 1062 | [最长重复子串](../../problems/longest-repeating-substring) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1060 | [有序数组中的缺失元素](../../problems/missing-element-in-sorted-array) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1027 | [最长等差数列](../../problems/longest-arithmetic-subsequence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1011 | [在 D 天内送达包裹的能力](../../problems/capacity-to-ship-packages-within-d-days) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 911 | [在线选举](../../problems/online-election) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 902 | [最大为 N 的数字组合](../../problems/numbers-at-most-n-given-digit-set) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 878 | [第 N 个神奇数字](../../problems/nth-magical-number) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 875 | [爱吃香蕉的珂珂](../../problems/koko-eating-bananas) | [[二分查找](../binary-search/README.md)] | Medium | -| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 852 | [山脉数组的峰顶索引](../../problems/peak-index-in-a-mountain-array) | [[二分查找](../binary-search/README.md)] | Easy | -| 793 | [阶乘函数后 K 个零](../../problems/preimage-size-of-factorial-zeroes-function) | [[二分查找](../binary-search/README.md)] | Hard | -| 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 774 | [最小化去加油站的最大距离](../../problems/minimize-max-distance-to-gas-station) 🔒 | [[二分查找](../binary-search/README.md)] | Hard | -| 744 | [寻找比目标字母大的最小字母](../../problems/find-smallest-letter-greater-than-target) | [[二分查找](../binary-search/README.md)] | Easy | -| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | -| 704 | [二分查找](../../problems/binary-search) | [[二分查找](../binary-search/README.md)] | Easy | -| 702 | [搜索长度未知的有序数组](../../problems/search-in-a-sorted-array-of-unknown-size) 🔒 | [[二分查找](../binary-search/README.md)] | Medium | +| 875 | [爱吃香蕉的珂珂](../../problems/koko-eating-bananas) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 852 | [山脉数组的峰顶索引](../../problems/peak-index-in-a-mountain-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 825 | [适龄的朋友](../../problems/friends-of-appropriate-ages) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 793 | [阶乘函数后 K 个零](../../problems/preimage-size-of-factorial-zeroes-function) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 774 | [最小化去加油站的最大距离](../../problems/minimize-max-distance-to-gas-station) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 754 | [到达终点数字](../../problems/reach-a-number) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 744 | [寻找比目标字母大的最小字母](../../problems/find-smallest-letter-greater-than-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[随机化](../randomized/README.md)] | Hard | +| 704 | [二分查找](../../problems/binary-search) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 702 | [搜索长度未知的有序数组](../../problems/search-in-a-sorted-array-of-unknown-size) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Medium | | 668 | [乘法表中第k小的数](../../problems/kth-smallest-number-in-multiplication-table) | [[二分查找](../binary-search/README.md)] | Hard | -| 658 | [找到 K 个最接近的元素](../../problems/find-k-closest-elements) | [[二分查找](../binary-search/README.md)] | Medium | +| 658 | [找到 K 个最接近的元素](../../problems/find-k-closest-elements) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 644 | [子数组最大平均数 II](../../problems/maximum-average-subarray-ii) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 540 | [有序数组中的单一元素](../../problems/single-element-in-a-sorted-array) | [[二分查找](../binary-search/README.md)] | Medium | -| 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | -| 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | -| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 633 | [平方数之和](../../problems/sum-of-square-numbers) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 611 | [有效三角形的个数](../../problems/valid-triangle-number) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 540 | [有序数组中的单一元素](../../problems/single-element-in-a-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[水塘抽样](../reservoir-sampling/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 493 | [翻转对](../../problems/reverse-pairs) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 483 | [最小好进制](../../problems/smallest-good-base) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 475 | [供暖器](../../problems/heaters) | [[二分查找](../binary-search/README.md)] | Medium | -| 454 | [四数相加 II](../../problems/4sum-ii) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 475 | [供暖器](../../problems/heaters) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 456 | [132 模式](../../problems/132-pattern) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 441 | [排列硬币](../../problems/arranging-coins) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 436 | [寻找右区间](../../problems/find-right-interval) | [[二分查找](../binary-search/README.md)] | Medium | -| 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 374 | [猜数字大小](../../problems/guess-number-higher-or-lower) | [[二分查找](../binary-search/README.md)] | Easy | +| 436 | [寻找右区间](../../problems/find-right-interval) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 400 | [第 N 位数字](../../problems/nth-digit) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 374 | [猜数字大小](../../problems/guess-number-higher-or-lower) | [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Easy | | 367 | [有效的完全平方数](../../problems/valid-perfect-square) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 354 | [俄罗斯套娃信封问题](../../problems/russian-doll-envelopes) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 302 | [包含全部黑色像素的最小矩形](../../problems/smallest-rectangle-enclosing-black-pixels) 🔒 | [[二分查找](../binary-search/README.md)] | Hard | -| 300 | [最长递增子序列](../../problems/longest-increasing-subsequence) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 278 | [第一个错误的版本](../../problems/first-bad-version) | [[二分查找](../binary-search/README.md)] | Easy | -| 275 | [H 指数 II](../../problems/h-index-ii) | [[二分查找](../binary-search/README.md)] | Medium | -| 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 230 | [二叉搜索树中第K小的元素](../../problems/kth-smallest-element-in-a-bst) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 174 | [地下城游戏](../../problems/dungeon-game) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 362 | [敲击计数器](../../problems/design-hit-counter) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 354 | [俄罗斯套娃信封问题](../../problems/russian-doll-envelopes) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[设计](../design/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 302 | [包含全部黑色像素的最小矩形](../../problems/smallest-rectangle-enclosing-black-pixels) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 300 | [最长递增子序列](../../problems/longest-increasing-subsequence) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 278 | [第一个错误的版本](../../problems/first-bad-version) | [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Easy | +| 275 | [H 指数 II](../../problems/h-index-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 154 | [寻找旋转排序数组中的最小值 II](../../problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 81 | [搜索旋转排序数组 II](../../problems/search-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 74 | [搜索二维矩阵](../../problems/search-a-2d-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 74 | [搜索二维矩阵](../../problems/search-a-2d-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 69 | [x 的平方根](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 50 | [Pow(x, n)](../../problems/powx-n) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 35 | [搜索插入位置](../../problems/search-insert-position) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 34 | [在排序数组中查找元素的第一个和最后一个位置](../../problems/find-first-and-last-position-of-element-in-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 33 | [搜索旋转排序数组](../../problems/search-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 29 | [两数相除](../../problems/divide-two-integers) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 4 | [寻找两个正序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 4 | [寻找两个正序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index bb2ef92f5..ad7787aac 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,63 +9,117 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1879 | [两个数组最小的异或值之和](../../problems/minimum-xor-sum-of-two-arrays) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1837 | [K 进制表示下的各位数字总和](../../problems/sum-of-digits-in-base-k) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | -| 1829 | [每个查询的最大异或值](../../problems/maximum-xor-for-each-query) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 1734 | [解码异或后的排列](../../problems/decode-xored-permutation) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 1720 | [解码异或后的数组](../../problems/decode-xored-array) | [[位运算](../bit-manipulation/README.md)] | Easy | -| 1707 | [与数组中元素的最大异或值](../../problems/maximum-xor-with-an-element-from-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Hard | -| 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Hard | -| 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1486 | [数组异或操作](../../problems/xor-operation-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | -| 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1915 | [最美子字符串的数目](../../problems/number-of-wonderful-substrings) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1908 | [Game of Nim](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1879 | [两个数组最小的异或值之和](../../problems/minimum-xor-sum-of-two-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1863 | [找出所有子集的异或总和再求和](../../problems/sum-of-all-subset-xor-totals) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Easy | +| 1835 | [所有数对按位与结果的异或和](../../problems/find-xor-sum-of-all-pairs-bitwise-and) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1829 | [每个查询的最大异或值](../../problems/maximum-xor-for-each-query) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1815 | [得到新鲜甜甜圈的最多组数](../../problems/maximum-number-of-groups-getting-fresh-donuts) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1803 | [统计异或值在范围内的数对有多少](../../problems/count-pairs-with-xor-in-a-range) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] | Hard | +| 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] [[数论](../number-theory/README.md)] | Hard | +| 1787 | [使所有区间的异或结果为零](../../problems/make-the-xor-of-all-segments-equal-to-zero) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1763 | [最长的美好子字符串](../../problems/longest-nice-substring) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | +| 1755 | [最接近目标值的子序列和](../../problems/closest-subsequence-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1738 | [找出第 K 大的异或坐标值](../../problems/find-kth-largest-xor-coordinate-value) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[快速选择](../quickselect/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1734 | [解码异或后的排列](../../problems/decode-xored-permutation) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Medium | +| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1720 | [解码异或后的数组](../../problems/decode-xored-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | +| 1707 | [与数组中元素的最大异或值](../../problems/maximum-xor-with-an-element-from-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] | Hard | +| 1684 | [统计一致字符串的数目](../../problems/count-the-number-of-consistent-strings) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1681 | [最小不兼容性](../../problems/minimum-incompatibility) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1680 | [连接连续二进制数字](../../problems/concatenation-of-consecutive-binary-numbers) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1506 | [找到 N 叉树的根节点](../../problems/find-root-of-n-ary-tree) 🔒 | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1494 | [并行课程 II](../../problems/parallel-courses-ii) | [[位运算](../bit-manipulation/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1486 | [数组异或操作](../../problems/xor-operation-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | +| 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1404 | [将二进制表示减到 1 的步骤数](../../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[排序](../sort/README.md)] [[位运算](../bit-manipulation/README.md)] | Easy | -| 1342 | [将数字变成 0 的操作次数](../../problems/number-of-steps-to-reduce-a-number-to-zero) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 1386 | [安排电影院座位](../../problems/cinema-seat-allocation) | [[贪心](../greedy/README.md)] [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1371 | [每个元音包含偶数次的最长子字符串](../../problems/find-the-longest-substring-containing-vowels-in-even-counts) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1349 | [参加考试的最大学生数](../../problems/maximum-students-taking-exam) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1342 | [将数字变成 0 的操作次数](../../problems/number-of-steps-to-reduce-a-number-to-zero) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | | 1318 | [或运算的最小翻转次数](../../problems/minimum-flips-to-make-a-or-b-equal-to-c) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 1310 | [子数组异或查询](../../problems/xor-queries-of-a-subarray) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)] | Easy | -| 1256 | [加密数字](../../problems/encode-number) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | -| 1255 | [得分最高的单词集合](../../problems/maximum-score-words-formed-by-letters) | [[位运算](../bit-manipulation/README.md)] | Hard | -| 1239 | [串联字符串的最大长度](../../problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1178 | [猜字谜](../../problems/number-of-valid-words-for-each-puzzle) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 1131 | [绝对值表达式的最大值](../../problems/maximum-of-absolute-value-expression) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | -| 1125 | [最小的必要团队](../../problems/smallest-sufficient-team) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 898 | [子数组按位或操作](../../problems/bitwise-ors-of-subarrays) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 762 | [二进制表示中质数个计算置位](../../problems/prime-number-of-set-bits-in-binary-representation) | [[位运算](../bit-manipulation/README.md)] | Easy | -| 756 | [金字塔转换矩阵](../../problems/pyramid-transition-matrix) | [[位运算](../bit-manipulation/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 751 | [IP 到 CIDR](../../problems/ip-to-cidr) 🔒 | [[位运算](../bit-manipulation/README.md)] | Medium | +| 1310 | [子数组异或查询](../../problems/xor-queries-of-a-subarray) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1284 | [转化为全零矩阵的最少反转次数](../../problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | [[位运算](../bit-manipulation/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1256 | [加密数字](../../problems/encode-number) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1255 | [得分最高的单词集合](../../problems/maximum-score-words-formed-by-letters) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1239 | [串联字符串的最大长度](../../problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1238 | [循环码排列](../../problems/circular-permutation-in-binary-representation) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1178 | [猜字谜](../../problems/number-of-valid-words-for-each-puzzle) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 1177 | [构建回文串检测](../../problems/can-make-palindrome-from-substring) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1125 | [最小的必要团队](../../problems/smallest-sufficient-team) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 1009 | [十进制整数的反码](../../problems/complement-of-base-10-integer) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 982 | [按位与为零的三元组](../../problems/triples-with-bitwise-and-equal-to-zero) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 980 | [不同路径 III](../../problems/unique-paths-iii) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 957 | [N 天后的牢房](../../problems/prison-cells-after-n-days) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 943 | [最短超级串](../../problems/find-the-shortest-superstring) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 898 | [子数组按位或操作](../../problems/bitwise-ors-of-subarrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 868 | [二进制间距](../../problems/binary-gap) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | +| 864 | [获取所有钥匙的最短路径](../../problems/shortest-path-to-get-all-keys) | [[位运算](../bit-manipulation/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 861 | [翻转矩阵后的得分](../../problems/score-after-flipping-matrix) | [[贪心](../greedy/README.md)] [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[位运算](../bit-manipulation/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 810 | [黑板异或游戏](../../problems/chalkboard-xor-game) | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 805 | [数组的均值分割](../../problems/split-array-with-same-average) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 762 | [二进制表示中质数个计算置位](../../problems/prime-number-of-set-bits-in-binary-representation) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | +| 756 | [金字塔转换矩阵](../../problems/pyramid-transition-matrix) | [[位运算](../bit-manipulation/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 751 | [IP 到 CIDR](../../problems/ip-to-cidr) 🔒 | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 693 | [交替位二进制数](../../problems/binary-number-with-alternating-bits) | [[位运算](../bit-manipulation/README.md)] | Easy | -| 477 | [汉明距离总和](../../problems/total-hamming-distance) | [[位运算](../bit-manipulation/README.md)] | Medium | +| 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 672 | [灯泡开关 Ⅱ](../../problems/bulb-switcher-ii) | [[位运算](../bit-manipulation/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Medium | +| 645 | [错误的集合](../../problems/set-mismatch) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 638 | [大礼包](../../problems/shopping-offers) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 526 | [优美的排列](../../problems/beautiful-arrangement) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 491 | [递增子序列](../../problems/increasing-subsequences) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 477 | [汉明距离总和](../../problems/total-hamming-distance) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 476 | [数字的补数](../../problems/number-complement) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 473 | [火柴拼正方形](../../problems/matchsticks-to-square) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 464 | [我能赢吗](../../problems/can-i-win) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 461 | [汉明距离](../../problems/hamming-distance) | [[位运算](../bit-manipulation/README.md)] | Easy | -| 421 | [数组中两个数的最大异或值](../../problems/maximum-xor-of-two-numbers-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Medium | -| 411 | [最短独占单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 405 | [数字转换为十六进制数](../../problems/convert-a-number-to-hexadecimal) | [[位运算](../bit-manipulation/README.md)] | Easy | -| 401 | [二进制手表](../../problems/binary-watch) | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | -| 397 | [整数替换](../../problems/integer-replacement) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | -| 393 | [UTF-8 编码验证](../../problems/utf-8-validation) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 371 | [两整数之和](../../problems/sum-of-two-integers) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 342 | [4的幂](../../problems/power-of-four) | [[位运算](../bit-manipulation/README.md)] | Easy | +| 421 | [数组中两个数的最大异或值](../../problems/maximum-xor-of-two-numbers-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 411 | [最短独占单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 405 | [数字转换为十六进制数](../../problems/convert-a-number-to-hexadecimal) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | +| 401 | [二进制手表](../../problems/binary-watch) | [[位运算](../bit-manipulation/README.md)] [[回溯](../backtracking/README.md)] | Easy | +| 397 | [整数替换](../../problems/integer-replacement) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 393 | [UTF-8 编码验证](../../problems/utf-8-validation) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Medium | +| 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 371 | [两整数之和](../../problems/sum-of-two-integers) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | +| 342 | [4的幂](../../problems/power-of-four) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | | 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 318 | [最大单词长度乘积](../../problems/maximum-product-of-word-lengths) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 268 | [丢失的数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 260 | [只出现一次的数字 III](../../problems/single-number-iii) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 231 | [2 的幂](../../problems/power-of-two) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | +| 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 318 | [最大单词长度乘积](../../problems/maximum-product-of-word-lengths) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 268 | [丢失的数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 266 | [回文排列](../../problems/palindrome-permutation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 260 | [只出现一次的数字 III](../../problems/single-number-iii) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Medium | +| 231 | [2 的幂](../../problems/power-of-two) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | | 201 | [数字范围按位与](../../problems/bitwise-and-of-numbers-range) | [[位运算](../bit-manipulation/README.md)] | Medium | | 191 | [位1的个数](../../problems/number-of-1-bits) | [[位运算](../bit-manipulation/README.md)] | Easy | -| 190 | [颠倒二进制位](../../problems/reverse-bits) | [[位运算](../bit-manipulation/README.md)] | Easy | -| 187 | [重复的DNA序列](../../problems/repeated-dna-sequences) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 169 | [多数元素](../../problems/majority-element) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Easy | -| 137 | [只出现一次的数字 II](../../problems/single-number-ii) | [[位运算](../bit-manipulation/README.md)] | Medium | -| 136 | [只出现一次的数字](../../problems/single-number) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 190 | [颠倒二进制位](../../problems/reverse-bits) | [[位运算](../bit-manipulation/README.md)] [[分治](../divide-and-conquer/README.md)] | Easy | +| 187 | [重复的DNA序列](../../problems/repeated-dna-sequences) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 137 | [只出现一次的数字 II](../../problems/single-number-ii) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Medium | +| 136 | [只出现一次的数字](../../problems/single-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | +| 90 | [子集 II](../../problems/subsets-ii) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 89 | [格雷编码](../../problems/gray-code) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 78 | [子集](../../problems/subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 67 | [二进制求和](../../problems/add-binary) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 29 | [两数相除](../../problems/divide-two-integers) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/brainteaser/README.md b/tag/brainteaser/README.md index 5c1d0aff4..ac468154c 100644 --- a/tag/brainteaser/README.md +++ b/tag/brainteaser/README.md @@ -9,10 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1503 | [所有蚂蚁掉下来前的最后一刻](../../problems/last-moment-before-all-ants-fall-out-of-a-plank) | [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] | Medium | -| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1033 | [移动石子直到连续](../../problems/moving-stones-until-consecutive) | [[脑筋急转弯](../brainteaser/README.md)] | Easy | -| 777 | [在LR字符串中交换相邻字符](../../problems/swap-adjacent-in-lr-string) | [[脑筋急转弯](../brainteaser/README.md)] | Medium | -| 521 | [最长特殊序列 Ⅰ](../../problems/longest-uncommon-subsequence-i) | [[脑筋急转弯](../brainteaser/README.md)] [[字符串](../string/README.md)] | Easy | +| 1908 | [Game of Nim](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1503 | [所有蚂蚁掉下来前的最后一刻](../../problems/last-moment-before-all-ants-fall-out-of-a-plank) | [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 1033 | [移动石子直到连续](../../problems/moving-stones-until-consecutive) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Easy | +| 1025 | [除数博弈](../../problems/divisor-game) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Easy | +| 810 | [黑板异或游戏](../../problems/chalkboard-xor-game) | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Hard | | 319 | [灯泡开关](../../problems/bulb-switcher) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Medium | -| 292 | [Nim 游戏](../../problems/nim-game) | [[脑筋急转弯](../brainteaser/README.md)] [[极小化极大](../minimax/README.md)] | Easy | +| 292 | [Nim 游戏](../../problems/nim-game) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Easy | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 1cba20a33..2eadcd8ce 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,93 +9,183 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1871 | [跳跃游戏 VII](../../problems/jump-game-vii) | [[贪心算法](../greedy/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1824 | [最少侧跳次数](../../problems/minimum-sideway-jumps) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] | Medium | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | -| 1765 | [地图中的最高点](../../problems/map-of-highest-peak) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1730 | [获取食物的最短路径](../../problems/shortest-path-to-get-food) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1654 | [到家的最少跳跃次数](../../problems/minimum-jumps-to-reach-home) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1625 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1765 | [地图中的最高点](../../problems/map-of-highest-peak) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1730 | [获取食物的最短路径](../../problems/shortest-path-to-get-food) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1728 | [猫和老鼠 II](../../problems/cat-and-mouse-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 1660 | [纠正二叉树](../../problems/correct-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1654 | [到家的最少跳跃次数](../../problems/minimum-jumps-to-reach-home) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1625 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] | Medium | +| 1609 | [奇偶树](../../problems/even-odd-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1568 | [使陆地分离的最少天数](../../problems/minimum-number-of-days-to-disconnect-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[强连通分量](../strongly-connected-component/README.md)] | Hard | +| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1345 | [跳跃游戏 IV](../../problems/jump-game-iv) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1298 | [你能从盒子里获得的最大糖果数](../../problems/maximum-candies-you-can-get-from-boxes) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1293 | [网格中的最短路径](../../problems/shortest-path-in-a-grid-with-obstacles-elimination) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1284 | [转化为全零矩阵的最少反转次数](../../problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 1263 | [推箱子](../../problems/minimum-moves-to-move-a-box-to-their-target-location) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1483 | [树节点的第 K 个祖先](../../problems/kth-ancestor-of-a-tree-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1469 | [寻找所有的独生节点](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 1466 | [重新规划路线](../../problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1462 | [课程表 IV](../../problems/course-schedule-iv) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1430 | [判断给定的序列是否是二叉树从根到叶的路径](../../problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1377 | [T 秒后青蛙的位置](../../problems/frog-position-after-t-seconds) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Hard | +| 1376 | [通知所有员工所需的时间](../../problems/time-needed-to-inform-all-employees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1361 | [验证二叉树](../../problems/validate-binary-tree-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1345 | [跳跃游戏 IV](../../problems/jump-game-iv) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 1325 | [删除给定值的叶子节点](../../problems/delete-leaves-with-a-given-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 1315 | [祖父节点值为偶数的节点和](../../problems/sum-of-nodes-with-even-valued-grandparent) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1298 | [你能从盒子里获得的最大糖果数](../../problems/maximum-candies-you-can-get-from-boxes) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] | Hard | +| 1293 | [网格中的最短路径](../../problems/shortest-path-in-a-grid-with-obstacles-elimination) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1284 | [转化为全零矩阵的最少反转次数](../../problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | [[位运算](../bit-manipulation/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1273 | [删除树节点](../../problems/delete-tree-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1263 | [推箱子](../../problems/minimum-moves-to-move-a-box-to-their-target-location) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1257 | [最小公共区域](../../problems/smallest-common-region) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1254 | [统计封闭岛屿的数目](../../problems/number-of-closed-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1242 | [多线程网页爬虫](../../problems/web-crawler-multithreaded) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1236 | [网络爬虫](../../problems/web-crawler) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1210 | [穿过迷宫的最少移动次数](../../problems/minimum-moves-to-reach-target-with-rotations) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 1242 | [多线程网页爬虫](../../problems/web-crawler-multithreaded) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[多线程](../concurrency/README.md)] | Medium | +| 1236 | [网络爬虫](../../problems/web-crawler) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1215 | [步进数](../../problems/stepping-numbers) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1210 | [穿过迷宫的最少移动次数](../../problems/minimum-moves-to-reach-target-with-rotations) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1197 | [进击的骑士](../../problems/minimum-knight-moves) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1091 | [二进制矩阵中的最短路径](../../problems/shortest-path-in-binary-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 994 | [腐烂的橘子](../../problems/rotting-oranges) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[极小化极大](../minimax/README.md)] | Hard | -| 909 | [蛇梯棋](../../problems/snakes-and-ladders) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 882 | [细分图中的可到达结点](../../problems/reachable-nodes-in-subdivided-graph) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 864 | [获取所有钥匙的最短路径](../../problems/shortest-path-to-get-all-keys) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 854 | [相似度为 K 的字符串](../../problems/k-similar-strings) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Hard | -| 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 827 | [最大人工岛](../../problems/making-a-large-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 773 | [滑动谜题](../../problems/sliding-puzzle) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1096 | [花括号展开 II](../../problems/brace-expansion-ii) | [[栈](../stack/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 1091 | [二进制矩阵中的最短路径](../../problems/shortest-path-in-binary-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1087 | [花括号展开](../../problems/brace-expansion) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1020 | [飞地的数量](../../problems/number-of-enclaves) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 994 | [腐烂的橘子](../../problems/rotting-oranges) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[广度优先搜索](../breadth-first-search/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 965 | [单值二叉树](../../problems/univalued-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 958 | [二叉树的完全性检验](../../problems/check-completeness-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 924 | [尽量减少恶意软件的传播](../../problems/minimize-malware-spread) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 919 | [完全二叉树插入器](../../problems/complete-binary-tree-inserter) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 909 | [蛇梯棋](../../problems/snakes-and-ladders) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 864 | [获取所有钥匙的最短路径](../../problems/shortest-path-to-get-all-keys) | [[位运算](../bit-manipulation/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 854 | [相似度为 K 的字符串](../../problems/k-similar-strings) | [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] | Hard | +| 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[位运算](../bit-manipulation/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 841 | [钥匙和房间](../../problems/keys-and-rooms) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[字符串](../string/README.md)] | Hard | +| 827 | [最大人工岛](../../problems/making-a-large-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 802 | [找到最终的安全状态](../../problems/find-eventual-safe-states) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 773 | [滑动谜题](../../problems/sliding-puzzle) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 756 | [金字塔转换矩阵](../../problems/pyramid-transition-matrix) | [[位运算](../bit-manipulation/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 749 | [隔离病毒](../../problems/contain-virus) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Hard | +| 743 | [网络延迟时间](../../problems/network-delay-time) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 742 | [二叉树最近的叶节点](../../problems/closest-leaf-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 733 | [图像渲染](../../problems/flood-fill) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 721 | [账户合并](../../problems/accounts-merge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | +| 695 | [岛屿的最大面积](../../problems/max-area-of-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Medium | | 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 675 | [为高尔夫比赛砍树](../../problems/cut-off-trees-for-golf-event) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 684 | [冗余连接](../../problems/redundant-connection) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 675 | [为高尔夫比赛砍树](../../problems/cut-off-trees-for-golf-event) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 672 | [灯泡开关 Ⅱ](../../problems/bulb-switcher-ii) | [[位运算](../bit-manipulation/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Medium | +| 662 | [二叉树最大宽度](../../problems/maximum-width-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 655 | [输出二叉树](../../problems/print-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 653 | [两数之和 IV - 输入 BST](../../problems/two-sum-iv-input-is-a-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 652 | [寻找重复的子树](../../problems/find-duplicate-subtrees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 637 | [二叉树的层平均值](../../problems/average-of-levels-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 623 | [在二叉树中增加一行](../../problems/add-one-row-to-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 617 | [合并二叉树](../../problems/merge-two-binary-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 559 | [N 叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 542 | [01 矩阵](../../problems/01-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 529 | [扫雷游戏](../../problems/minesweeper) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 505 | [迷宫 II](../../problems/the-maze-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 499 | [迷宫 III](../../problems/the-maze-iii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 490 | [迷宫](../../problems/the-maze) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 547 | [省份数量](../../problems/number-of-provinces) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 542 | [01 矩阵](../../problems/01-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 530 | [二叉搜索树的最小绝对差](../../problems/minimum-absolute-difference-in-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 529 | [扫雷游戏](../../problems/minesweeper) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 505 | [迷宫 II](../../problems/the-maze-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 499 | [迷宫 III](../../problems/the-maze-iii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 490 | [迷宫](../../problems/the-maze) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 463 | [岛屿的周长](../../problems/island-perimeter) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 449 | [序列化和反序列化二叉搜索树](../../problems/serialize-and-deserialize-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 433 | [最小基因变化](../../problems/minimum-genetic-mutation) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 431 | [将 N 叉树编码为二叉树](../../problems/encode-n-ary-tree-to-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 429 | [N 叉树的层序遍历](../../problems/n-ary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 417 | [太平洋大西洋水流问题](../../problems/pacific-atlantic-water-flow) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 428 | [序列化和反序列化 N 叉树](../../problems/serialize-and-deserialize-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] | Hard | +| 417 | [太平洋大西洋水流问题](../../problems/pacific-atlantic-water-flow) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 404 | [左叶子之和](../../problems/sum-of-left-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 399 | [除法求值](../../problems/evaluate-division) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Medium | +| 365 | [水壶问题](../../problems/water-and-jug-problem) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Medium | +| 364 | [加权嵌套序列和 II](../../problems/nested-list-weight-sum-ii) 🔒 | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 339 | [嵌套列表权重和](../../problems/nested-list-weight-sum) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 317 | [离建筑物最近的距离](../../problems/shortest-distance-from-all-buildings) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 310 | [最小高度树](../../problems/minimum-height-trees) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 301 | [删除无效的括号](../../problems/remove-invalid-parentheses) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 286 | [墙与门](../../problems/walls-and-gates) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 322 | [零钱兑换](../../problems/coin-change) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 317 | [离建筑物最近的距离](../../problems/shortest-distance-from-all-buildings) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 310 | [最小高度树](../../problems/minimum-height-trees) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 302 | [包含全部黑色像素的最小矩形](../../problems/smallest-rectangle-enclosing-black-pixels) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 301 | [删除无效的括号](../../problems/remove-invalid-parentheses) | [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 286 | [墙与门](../../problems/walls-and-gates) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | | 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 226 | [翻转二叉树](../../problems/invert-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | | 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | -| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 127 | [单词接龙](../../problems/word-ladder) | [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 102 | [二叉树的层序遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | +| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 127 | [单词接龙](../../problems/word-ladder) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 102 | [二叉树的层序遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 100 | [相同的树](../../problems/same-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index e49a070f6..c52bc2ec7 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,160 +9,228 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1858 | [Longest Word With All Prefixes](../../problems/longest-word-with-all-prefixes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1858 | [包含所有前缀的最长单词](../../problems/longest-word-with-all-prefixes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] | Medium | +| 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] | Medium | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | -| 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1730 | [获取食物的最短路径](../../problems/shortest-path-to-get-food) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[贪心算法](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1625 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | +| 1706 | [球会落何处](../../problems/where-will-the-ball-fall) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1660 | [纠正二叉树](../../problems/correct-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1644 | [二叉树的最近公共祖先 II](../../problems/lowest-common-ancestor-of-a-binary-tree-ii) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1568 | [使陆地分离的最少天数](../../problems/minimum-number-of-days-to-disconnect-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[强连通分量](../strongly-connected-component/README.md)] | Hard | +| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1522 | [N 叉树的直径](../../problems/diameter-of-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1516 | [移动 N 叉树的子树](../../problems/move-sub-tree-of-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 1506 | [找到 N 叉树的根节点](../../problems/find-root-of-n-ary-tree) 🔒 | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | -| 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1469 | [寻找所有的独生节点](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 1466 | [重新规划路线](../../problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1377 | [T 秒后青蛙的位置](../../problems/frog-position-after-t-seconds) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 1376 | [通知所有员工所需的时间](../../problems/time-needed-to-inform-all-employees) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 1315 | [祖父节点值为偶数的节点和](../../problems/sum-of-nodes-with-even-valued-grandparent) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1273 | [删除树节点](../../problems/delete-tree-nodes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1254 | [统计封闭岛屿的数目](../../problems/number-of-closed-islands) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1483 | [树节点的第 K 个祖先](../../problems/kth-ancestor-of-a-tree-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1469 | [寻找所有的独生节点](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 1466 | [重新规划路线](../../problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1462 | [课程表 IV](../../problems/course-schedule-iv) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1430 | [判断给定的序列是否是二叉树从根到叶的路径](../../problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1382 | [将二叉搜索树变平衡](../../problems/balance-a-binary-search-tree) | [[贪心](../greedy/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1377 | [T 秒后青蛙的位置](../../problems/frog-position-after-t-seconds) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Hard | +| 1376 | [通知所有员工所需的时间](../../problems/time-needed-to-inform-all-employees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1361 | [验证二叉树](../../problems/validate-binary-tree-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1325 | [删除给定值的叶子节点](../../problems/delete-leaves-with-a-given-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 1315 | [祖父节点值为偶数的节点和](../../problems/sum-of-nodes-with-even-valued-grandparent) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1273 | [删除树节点](../../problems/delete-tree-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1257 | [最小公共区域](../../problems/smallest-common-region) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1254 | [统计封闭岛屿的数目](../../problems/number-of-closed-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1242 | [多线程网页爬虫](../../problems/web-crawler-multithreaded) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1236 | [网络爬虫](../../problems/web-crawler) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | -| 1192 | [查找集群内的「关键连接」](../../problems/critical-connections-in-a-network) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1110 | [删点成林](../../problems/delete-nodes-and-return-forest) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 1080 | [根到叶路径上的不足节点](../../problems/insufficient-nodes-in-root-to-leaf-paths) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1061 | [按字典序排列最小的等效字符串](../../problems/lexicographically-smallest-equivalent-string) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | +| 1242 | [多线程网页爬虫](../../problems/web-crawler-multithreaded) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[多线程](../concurrency/README.md)] | Medium | +| 1236 | [网络爬虫](../../problems/web-crawler) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1192 | [查找集群内的「关键连接」](../../problems/critical-connections-in-a-network) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[双连通分量](../biconnected-component/README.md)] | Hard | +| 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1110 | [删点成林](../../problems/delete-nodes-and-return-forest) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1080 | [根到叶路径上的不足节点](../../problems/insufficient-nodes-in-root-to-leaf-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1059 | [从始点到终点的所有路径](../../problems/all-paths-from-source-lead-to-destination) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 1026 | [节点与其祖先之间的最大差值](../../problems/maximum-difference-between-node-and-ancestor) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1020 | [飞地的数量](../../problems/number-of-enclaves) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 988 | [从叶结点开始的最小字符串](../../problems/smallest-string-starting-from-leaf) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 980 | [不同路径 III](../../problems/unique-paths-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 979 | [在二叉树中分配硬币](../../problems/distribute-coins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 971 | [翻转二叉树以匹配先序遍历](../../problems/flip-binary-tree-to-match-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 947 | [移除最多的同行或同列石头](../../problems/most-stones-removed-with-same-row-or-column) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 924 | [尽量减少恶意软件的传播](../../problems/minimize-malware-spread) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | -| 897 | [递增顺序搜索树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 851 | [喧闹和富有](../../problems/loud-and-rich) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 841 | [钥匙和房间](../../problems/keys-and-rooms) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 827 | [最大人工岛](../../problems/making-a-large-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 802 | [找到最终的安全状态](../../problems/find-eventual-safe-states) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 756 | [金字塔转换矩阵](../../problems/pyramid-transition-matrix) | [[位运算](../bit-manipulation/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 753 | [破解保险箱](../../problems/cracking-the-safe) | [[深度优先搜索](../depth-first-search/README.md)] [[数学](../math/README.md)] | Hard | -| 749 | [隔离病毒](../../problems/contain-virus) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 733 | [图像渲染](../../problems/flood-fill) | [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 721 | [账户合并](../../problems/accounts-merge) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 695 | [岛屿的最大面积](../../problems/max-area-of-island) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 1026 | [节点与其祖先之间的最大差值](../../problems/maximum-difference-between-node-and-ancestor) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1022 | [从根到叶的二进制数之和](../../problems/sum-of-root-to-leaf-binary-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 1020 | [飞地的数量](../../problems/number-of-enclaves) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 988 | [从叶结点开始的最小字符串](../../problems/smallest-string-starting-from-leaf) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 979 | [在二叉树中分配硬币](../../problems/distribute-coins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 971 | [翻转二叉树以匹配先序遍历](../../problems/flip-binary-tree-to-match-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 965 | [单值二叉树](../../problems/univalued-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 951 | [翻转等价二叉树](../../problems/flip-equivalent-binary-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 947 | [移除最多的同行或同列石头](../../problems/most-stones-removed-with-same-row-or-column) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 924 | [尽量减少恶意软件的传播](../../problems/minimize-malware-spread) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 897 | [递增顺序搜索树](../../problems/increasing-order-search-tree) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 851 | [喧闹和富有](../../problems/loud-and-rich) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] | Medium | +| 841 | [钥匙和房间](../../problems/keys-and-rooms) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[字符串](../string/README.md)] | Hard | +| 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 827 | [最大人工岛](../../problems/making-a-large-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 814 | [二叉树剪枝](../../problems/binary-tree-pruning) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 802 | [找到最终的安全状态](../../problems/find-eventual-safe-states) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 756 | [金字塔转换矩阵](../../problems/pyramid-transition-matrix) | [[位运算](../bit-manipulation/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 753 | [破解保险箱](../../problems/cracking-the-safe) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | +| 749 | [隔离病毒](../../problems/contain-virus) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Hard | +| 743 | [网络延迟时间](../../problems/network-delay-time) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 742 | [二叉树最近的叶节点](../../problems/closest-leaf-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 733 | [图像渲染](../../problems/flood-fill) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 721 | [账户合并](../../problems/accounts-merge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | +| 695 | [岛屿的最大面积](../../problems/max-area-of-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Medium | | 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 679 | [24 点游戏](../../problems/24-game) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 664 | [奇怪的打印机](../../problems/strange-printer) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 638 | [大礼包](../../problems/shopping-offers) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 576 | [出界的路径数](../../problems/out-of-boundary-paths) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 684 | [冗余连接](../../problems/redundant-connection) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 672 | [灯泡开关 Ⅱ](../../problems/bulb-switcher-ii) | [[位运算](../bit-manipulation/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Medium | +| 671 | [二叉树中第二小的节点](../../problems/second-minimum-node-in-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 666 | [路径总和 IV](../../problems/path-sum-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 663 | [均匀树划分](../../problems/equal-tree-partition) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 662 | [二叉树最大宽度](../../problems/maximum-width-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 655 | [输出二叉树](../../problems/print-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 653 | [两数之和 IV - 输入 BST](../../problems/two-sum-iv-input-is-a-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 652 | [寻找重复的子树](../../problems/find-duplicate-subtrees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 637 | [二叉树的层平均值](../../problems/average-of-levels-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 623 | [在二叉树中增加一行](../../problems/add-one-row-to-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 617 | [合并二叉树](../../problems/merge-two-binary-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 606 | [根据二叉树创建字符串](../../problems/construct-string-from-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 590 | [N 叉树的后序遍历](../../problems/n-ary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 589 | [N 叉树的前序遍历](../../problems/n-ary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 572 | [另一个树的子树](../../problems/subtree-of-another-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] [[字符串匹配](../string-matching/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | +| 565 | [数组嵌套](../../problems/array-nesting) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 559 | [N 叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 547 | [省份数量](../../problems/number-of-provinces) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 546 | [移除盒子](../../problems/remove-boxes) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 542 | [01 矩阵](../../problems/01-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 531 | [孤独像素 I](../../problems/lonely-pixel-i) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 529 | [扫雷游戏](../../problems/minesweeper) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 526 | [优美的排列](../../problems/beautiful-arrangement) | [[深度优先搜索](../depth-first-search/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 505 | [迷宫 II](../../problems/the-maze-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 499 | [迷宫 III](../../problems/the-maze-iii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 494 | [目标和](../../problems/target-sum) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 491 | [递增子序列](../../problems/increasing-subsequences) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 490 | [迷宫](../../problems/the-maze) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 489 | [扫地机器人](../../problems/robot-room-cleaner) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 488 | [祖玛游戏](../../problems/zuma-game) | [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 473 | [火柴拼正方形](../../problems/matchsticks-to-square) | [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 439 | [三元表达式解析器](../../problems/ternary-expression-parser) 🔒 | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 430 | [扁平化多级双向链表](../../problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 417 | [太平洋大西洋水流问题](../../problems/pacific-atlantic-water-flow) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 366 | [寻找二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 364 | [加权嵌套序列和 II](../../problems/nested-list-weight-sum-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 549 | [二叉树中最长的连续序列](../../problems/binary-tree-longest-consecutive-sequence-ii) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 547 | [省份数量](../../problems/number-of-provinces) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 545 | [二叉树的边界](../../problems/boundary-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 543 | [二叉树的直径](../../problems/diameter-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 530 | [二叉搜索树的最小绝对差](../../problems/minimum-absolute-difference-in-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 529 | [扫雷游戏](../../problems/minesweeper) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 508 | [出现次数最多的子树元素和](../../problems/most-frequent-subtree-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 505 | [迷宫 II](../../problems/the-maze-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 501 | [二叉搜索树中的众数](../../problems/find-mode-in-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 499 | [迷宫 III](../../problems/the-maze-iii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 490 | [迷宫](../../problems/the-maze) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 463 | [岛屿的周长](../../problems/island-perimeter) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 449 | [序列化和反序列化二叉搜索树](../../problems/serialize-and-deserialize-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 437 | [路径总和 III](../../problems/path-sum-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 431 | [将 N 叉树编码为二叉树](../../problems/encode-n-ary-tree-to-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 430 | [扁平化多级双向链表](../../problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 428 | [序列化和反序列化 N 叉树](../../problems/serialize-and-deserialize-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] | Hard | +| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 419 | [甲板上的战舰](../../problems/battleships-in-a-board) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 417 | [太平洋大西洋水流问题](../../problems/pacific-atlantic-water-flow) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 404 | [左叶子之和](../../problems/sum-of-left-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 399 | [除法求值](../../problems/evaluate-division) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Medium | +| 388 | [文件的最长绝对路径](../../problems/longest-absolute-file-path) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] | Medium | +| 386 | [字典序排数](../../problems/lexicographical-numbers) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] | Medium | +| 385 | [迷你语法分析器](../../problems/mini-parser) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] | Medium | +| 366 | [寻找二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 365 | [水壶问题](../../problems/water-and-jug-problem) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Medium | +| 364 | [加权嵌套序列和 II](../../problems/nested-list-weight-sum-ii) 🔒 | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 339 | [嵌套列表权重和](../../problems/nested-list-weight-sum) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | +| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 333 | [最大 BST 子树](../../problems/largest-bst-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Medium | +| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 301 | [删除无效的括号](../../problems/remove-invalid-parentheses) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | +| 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 310 | [最小高度树](../../problems/minimum-height-trees) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 302 | [包含全部黑色像素的最小矩形](../../problems/smallest-rectangle-enclosing-black-pixels) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 298 | [二叉树最长连续序列](../../problems/binary-tree-longest-consecutive-sequence) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 285 | [二叉搜索树中的中序后继](../../problems/inorder-successor-in-bst) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | | 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 235 | [二叉搜索树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 230 | [二叉搜索树中第K小的元素](../../problems/kth-smallest-element-in-a-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 226 | [翻转二叉树](../../problems/invert-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | | 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | | 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | -| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 100 | [相同的树](../../problems/same-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 99 | [恢复二叉搜索树](../../problems/recover-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 156 | [上下翻转二叉树](../../problems/binary-tree-upside-down) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 100 | [相同的树](../../problems/same-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 99 | [恢复二叉搜索树](../../problems/recover-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | diff --git a/tag/design/README.md b/tag/design/README.md index eb84527c3..57928895b 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,67 +9,100 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1865 | [找出和为指定值的下标对](../../problems/finding-pairs-with-a-certain-sum) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | -| 1845 | [座位预约管理系统](../../problems/seat-reservation-manager) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Medium | -| 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] | Hard | +| 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1865 | [找出和为指定值的下标对](../../problems/finding-pairs-with-a-certain-sum) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1845 | [座位预约管理系统](../../problems/seat-reservation-manager) | [[设计](../design/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1804 | [实现 Trie (前缀树) II](../../problems/implement-trie-ii-prefix-tree) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1797 | [设计一个验证系统](../../problems/design-authentication-manager) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | -| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Easy | -| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard | -| 1603 | [设计停车系统](../../problems/design-parking-system) | [[设计](../design/README.md)] | Easy | -| 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | -| 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[设计](../design/README.md)] | Medium | -| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] | Medium | -| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | -| 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] | Medium | -| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | -| 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] | Medium | -| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1206 | [设计跳表](../../problems/design-skiplist) | [[设计](../design/README.md)] | Hard | -| 1172 | [餐盘栈](../../problems/dinner-plate-stacks) | [[设计](../design/README.md)] | Hard | -| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 716 | [最大栈](../../problems/max-stack) 🔒 | [[设计](../design/README.md)] | Easy | +| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] | Medium | +| 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] | Easy | +| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[数学](../math/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数学](../math/README.md)] | Hard | +| 1603 | [设计停车系统](../../problems/design-parking-system) | [[设计](../design/README.md)] [[计数](../counting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1483 | [树节点的第 K 个祖先](../../problems/kth-ancestor-of-a-tree-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1476 | [子矩形查询](../../problems/subrectangle-queries) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] | Medium | +| 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[数据流](../data-stream/README.md)] | Medium | +| 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1206 | [设计跳表](../../problems/design-skiplist) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Hard | +| 1172 | [餐盘栈](../../problems/dinner-plate-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1146 | [快照数组](../../problems/snapshot-array) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1032 | [字符流](../../problems/stream-of-characters) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[数据流](../data-stream/README.md)] | Hard | +| 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 933 | [最近的请求次数](../../problems/number-of-recent-calls) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数据流](../data-stream/README.md)] | Easy | +| 919 | [完全二叉树插入器](../../problems/complete-binary-tree-inserter) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 911 | [在线选举](../../problems/online-election) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 901 | [股票价格跨度](../../problems/online-stock-span) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 900 | [RLE 迭代器](../../problems/rle-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 855 | [考场就座](../../problems/exam-room) | [[设计](../design/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 745 | [前缀和后缀搜索](../../problems/prefix-and-suffix-search) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Hard | +| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 731 | [我的日程安排表 II](../../problems/my-calendar-ii) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 729 | [我的日程安排表 I](../../problems/my-calendar-i) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 716 | [最大栈](../../problems/max-stack) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] [[有序集合](../ordered-set/README.md)] | Easy | +| 715 | [Range 模块](../../problems/range-module) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy | -| 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Hard | -| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | -| 631 | [设计 Excel 求和公式](../../problems/design-excel-sum-formula) 🔒 | [[设计](../design/README.md)] | Hard | -| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] | Easy | -| 588 | [设计内存文件系统](../../problems/design-in-memory-file-system) 🔒 | [[设计](../design/README.md)] | Hard | -| 460 | [LFU 缓存](../../problems/lfu-cache) | [[设计](../design/README.md)] | Hard | -| 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] | Hard | -| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 380 | [O(1) 时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 362 | [敲击计数器](../../problems/design-hit-counter) 🔒 | [[设计](../design/README.md)] | Medium | +| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | +| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | +| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[数据流](../data-stream/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 677 | [键值映射](../../problems/map-sum-pairs) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 676 | [实现一个魔法字典](../../problems/implement-magic-dictionary) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[数据流](../data-stream/README.md)] | Hard | +| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 631 | [设计 Excel 求和公式](../../problems/design-excel-sum-formula) 🔒 | [[图](../graph/README.md)] [[设计](../design/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[迭代器](../iterator/README.md)] | Easy | +| 588 | [设计内存文件系统](../../problems/design-in-memory-file-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 535 | [TinyURL 的加密与解密](../../problems/encode-and-decode-tinyurl) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Medium | +| 460 | [LFU 缓存](../../problems/lfu-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Hard | +| 449 | [序列化和反序列化二叉搜索树](../../problems/serialize-and-deserialize-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Hard | +| 431 | [将 N 叉树编码为二叉树](../../problems/encode-n-ary-tree-to-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Hard | +| 380 | [O(1) 时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 362 | [敲击计数器](../../problems/design-hit-counter) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 348 | [设计井字棋](../../problems/design-tic-tac-toe) 🔒 | [[设计](../design/README.md)] | Medium | -| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | -| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | -| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard | -| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard | -| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] | Medium | -| 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] | Medium | -| 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] | Medium | -| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium | -| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 355 | [设计推特](../../problems/design-twitter) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[设计](../design/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 348 | [设计井字棋](../../problems/design-tic-tac-toe) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数据流](../data-stream/README.md)] | Easy | +| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 308 | [二维区域和检索 - 可变](../../problems/range-sum-query-2d-mutable) 🔒 | [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 307 | [区域和检索 - 数组可修改](../../problems/range-sum-query-mutable) | [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] | Medium | +| 304 | [二维区域和检索 - 矩阵不可变](../../problems/range-sum-query-2d-immutable) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 303 | [区域和检索 - 数组不可变](../../problems/range-sum-query-immutable) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | +| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[设计](../design/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 271 | [字符串的编码与解码](../../problems/encode-and-decode-strings) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | +| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | +| 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | | 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] | Medium | +| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index 279bfab7a..72756360b 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -9,24 +9,37 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1755 | [最接近目标值的子序列和](../../problems/closest-subsequence-sum) | [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 1274 | [矩形内船只的数目](../../problems/number-of-ships-in-a-rectangle) 🔒 | [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 932 | [漂亮数组](../../problems/beautiful-array) | [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 903 | [DI 序列的有效排列](../../problems/valid-permutations-for-di-sequence) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 312 | [戳气球](../../problems/burst-balloons) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 282 | [给表达式添加运算符](../../problems/expression-add-operators) | [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 241 | [为运算表达式设计优先级](../../problems/different-ways-to-add-parentheses) | [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | -| 215 | [数组中的第K个最大元素](../../problems/kth-largest-element-in-an-array) | [[堆](../heap/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 169 | [多数元素](../../problems/majority-element) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Easy | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 4 | [寻找两个正序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 1901 | [找出顶峰元素 II](../../problems/find-a-peak-element-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1738 | [找出第 K 大的异或坐标值](../../problems/find-kth-largest-xor-coordinate-value) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[快速选择](../quickselect/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1382 | [将二叉搜索树变平衡](../../problems/balance-a-binary-search-tree) | [[贪心](../greedy/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1274 | [矩形内船只的数目](../../problems/number-of-ships-in-a-rectangle) 🔒 | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[交互](../interactive/README.md)] | Hard | +| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 932 | [漂亮数组](../../problems/beautiful-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] | Medium | +| 918 | [环形子数组的最大和](../../problems/maximum-sum-circular-subarray) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] | Medium | +| 912 | [排序数组](../../problems/sort-an-array) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数排序](../counting-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 654 | [最大二叉树](../../problems/maximum-binary-tree) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 558 | [四叉树交集](../../problems/logical-or-of-two-binary-grids-represented-as-quad-trees) | [[树](../tree/README.md)] [[分治](../divide-and-conquer/README.md)] | Medium | +| 493 | [翻转对](../../problems/reverse-pairs) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 427 | [建立四叉树](../../problems/construct-quad-tree) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 372 | [超级次方](../../problems/super-pow) | [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] | Medium | +| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 324 | [摆动排序 II](../../problems/wiggle-sort-ii) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] | Medium | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[扫描线](../line-sweep/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 215 | [数组中的第K个最大元素](../../problems/kth-largest-element-in-an-array) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 190 | [颠倒二进制位](../../problems/reverse-bits) | [[位运算](../bit-manipulation/README.md)] [[分治](../divide-and-conquer/README.md)] | Easy | +| 169 | [多数元素](../../problems/majority-element) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | +| 148 | [排序链表](../../problems/sort-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[分治](../divide-and-conquer/README.md)] [[排序](../sorting/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 4 | [寻找两个正序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 81d350e32..667cc789c 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,265 +9,321 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1884 | [鸡蛋掉落-两枚鸡蛋](../../problems/egg-drop-with-2-eggs-and-n-floors) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1883 | [准时抵达会议现场的最小跳过休息次数](../../problems/minimum-skips-to-arrive-at-meeting-on-time) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1879 | [两个数组最小的异或值之和](../../problems/minimum-xor-sum-of-two-arrays) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1872 | [石子游戏 VIII](../../problems/stone-game-viii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1866 | [恰有 K 根木棍可以看到的排列数目](../../problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1824 | [最少侧跳次数](../../problems/minimum-sideway-jumps) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1815 | [得到新鲜甜甜圈的最多组数](../../problems/maximum-number-of-groups-getting-fresh-donuts) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1787 | [使所有区间的异或结果为零](../../problems/make-the-xor-of-all-segments-equal-to-zero) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1771 | [由子序列构造的最长回文串的长度](../../problems/maximize-palindrome-length-from-subsequences) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1770 | [执行乘法运算的最大分数](../../problems/maximum-score-from-performing-multiplication-operations) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1751 | [最多可以参加的会议数目 II](../../problems/maximum-number-of-events-that-can-be-attended-ii) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1746 | [经过一次操作后的最大子数组和](../../problems/maximum-subarray-sum-after-one-operation) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1911 | [最大子序列交替和](../../problems/maximum-alternating-subsequence-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1908 | [Game of Nim](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1900 | [最佳运动员的比拼回合](../../problems/the-earliest-and-latest-rounds-where-players-compete) | [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1896 | [反转表达式值的最少操作次数](../../problems/minimum-cost-to-change-the-final-value-of-expression) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1884 | [鸡蛋掉落-两枚鸡蛋](../../problems/egg-drop-with-2-eggs-and-n-floors) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1883 | [准时抵达会议现场的最小跳过休息次数](../../problems/minimum-skips-to-arrive-at-meeting-on-time) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1879 | [两个数组最小的异或值之和](../../problems/minimum-xor-sum-of-two-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1872 | [石子游戏 VIII](../../problems/stone-game-viii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 1866 | [恰有 K 根木棍可以看到的排列数目](../../problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] [[计数](../counting/README.md)] | Hard | +| 1824 | [最少侧跳次数](../../problems/minimum-sideway-jumps) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1815 | [得到新鲜甜甜圈的最多组数](../../problems/maximum-number-of-groups-getting-fresh-donuts) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] [[数论](../number-theory/README.md)] | Hard | +| 1787 | [使所有区间的异或结果为零](../../problems/make-the-xor-of-all-segments-equal-to-zero) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1774 | [最接近目标价格的甜点成本](../../problems/closest-dessert-cost) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1771 | [由子序列构造的最长回文串的长度](../../problems/maximize-palindrome-length-from-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1770 | [执行乘法运算的最大分数](../../problems/maximum-score-from-performing-multiplication-operations) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1755 | [最接近目标值的子序列和](../../problems/closest-subsequence-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1751 | [最多可以参加的会议数目 II](../../problems/maximum-number-of-events-that-can-be-attended-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1749 | [任意子数组和的绝对值的最大值](../../problems/maximum-absolute-sum-of-any-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1746 | [经过一次操作后的最大子数组和](../../problems/maximum-subarray-sum-after-one-operation) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1745 | [回文串分割 IV](../../problems/palindrome-partitioning-iv) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1728 | [猫和老鼠 II](../../problems/cat-and-mouse-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1724 | [检查边长度限制的路径是否存在 II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1706 | [球会落何处](../../problems/where-will-the-ball-fall) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1735 | [生成乘积数组的方案数](../../problems/count-ways-to-make-array-with-product) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1728 | [猫和老鼠 II](../../problems/cat-and-mouse-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1714 | [数组中特殊等间距元素的和](../../problems/sum-of-special-evenly-spaced-elements-in-array) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1706 | [球会落何处](../../problems/where-will-the-ball-fall) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1696 | [跳跃游戏 VI](../../problems/jump-game-vi) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1692 | [计算分配糖果的不同方式](../../problems/count-ways-to-distribute-candies) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1691 | [堆叠长方体的最大高度](../../problems/maximum-height-by-stacking-cuboids) | [[排序](../sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1690 | [石子游戏 VII](../../problems/stone-game-vii) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1691 | [堆叠长方体的最大高度](../../problems/maximum-height-by-stacking-cuboids) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1690 | [石子游戏 VII](../../problems/stone-game-vii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1682 | [最长回文子序列 II](../../problems/longest-palindromic-subsequence-ii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1671 | [得到山形数组的最少删除次数](../../problems/minimum-number-of-removals-to-make-mountain-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1664 | [生成平衡数组的方案数](../../problems/ways-to-make-a-fair-array) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1654 | [到家的最少跳跃次数](../../problems/minimum-jumps-to-reach-home) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1643 | [第 K 条最小指令](../../problems/kth-smallest-instructions) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1639 | [通过给定词典构造目标字符串的方案数](../../problems/number-of-ways-to-form-a-target-string-given-a-dictionary) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1626 | [无矛盾的最佳球队](../../problems/best-team-with-no-conflicts) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1621 | [大小为 K 的不重叠线段的数目](../../problems/number-of-sets-of-k-non-overlapping-line-segments) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1563 | [石子游戏 V](../../problems/stone-game-v) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1553 | [吃掉 N 个橘子的最少天数](../../problems/minimum-number-of-days-to-eat-n-oranges) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1681 | [最小不兼容性](../../problems/minimum-incompatibility) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1671 | [得到山形数组的最少删除次数](../../problems/minimum-number-of-removals-to-make-mountain-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1664 | [生成平衡数组的方案数](../../problems/ways-to-make-a-fair-array) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1654 | [到家的最少跳跃次数](../../problems/minimum-jumps-to-reach-home) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1646 | [获取生成数组中的最大值](../../problems/get-maximum-in-generated-array) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1643 | [第 K 条最小指令](../../problems/kth-smallest-instructions) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1639 | [通过给定词典构造目标字符串的方案数](../../problems/number-of-ways-to-form-a-target-string-given-a-dictionary) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1626 | [无矛盾的最佳球队](../../problems/best-team-with-no-conflicts) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1621 | [大小为 K 的不重叠线段的数目](../../problems/number-of-sets-of-k-non-overlapping-line-segments) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1563 | [石子游戏 V](../../problems/stone-game-v) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 1553 | [吃掉 N 个橘子的最少天数](../../problems/minimum-number-of-days-to-eat-n-oranges) | [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1548 | [图中最相似的路径](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1547 | [切棍子的最小成本](../../problems/minimum-cost-to-cut-a-stick) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1546 | [和为目标值且不重叠的非空子数组的最大数目](../../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1537 | [最大得分](../../problems/get-the-maximum-score) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1547 | [切棍子的最小成本](../../problems/minimum-cost-to-cut-a-stick) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1537 | [最大得分](../../problems/get-the-maximum-score) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1510 | [石子游戏 IV](../../problems/stone-game-iv) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1504 | [统计全 1 子矩形](../../problems/count-submatrices-with-all-ones) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1483 | [树节点的第 K 个祖先](../../problems/kth-ancestor-of-a-tree-node) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1477 | [找两个和为目标值且不重叠的子数组](../../problems/find-two-non-overlapping-sub-arrays-each-with-target-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1473 | [粉刷房子 III](../../problems/paint-house-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1463 | [摘樱桃 II](../../problems/cherry-pickup-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1458 | [两个子序列的最大点积](../../problems/max-dot-product-of-two-subsequences) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1444 | [切披萨的方案数](../../problems/number-of-ways-of-cutting-a-pizza) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1425 | [带限制的子序列和](../../problems/constrained-subsequence-sum) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1510 | [石子游戏 IV](../../problems/stone-game-iv) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 1504 | [统计全 1 子矩形](../../problems/count-submatrices-with-all-ones) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1494 | [并行课程 II](../../problems/parallel-courses-ii) | [[位运算](../bit-manipulation/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1493 | [删掉一个元素以后全为 1 的最长子数组](../../problems/longest-subarray-of-1s-after-deleting-one-element) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1483 | [树节点的第 K 个祖先](../../problems/kth-ancestor-of-a-tree-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1477 | [找两个和为目标值且不重叠的子数组](../../problems/find-two-non-overlapping-sub-arrays-each-with-target-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1473 | [粉刷房子 III](../../problems/paint-house-iii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[组合数学](../combinatorics/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Hard | +| 1463 | [摘樱桃 II](../../problems/cherry-pickup-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1458 | [两个子序列的最大点积](../../problems/max-dot-product-of-two-subsequences) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1444 | [切披萨的方案数](../../problems/number-of-ways-of-cutting-a-pizza) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1425 | [带限制的子序列和](../../problems/constrained-subsequence-sum) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1420 | [生成数组](../../problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1416 | [恢复数组](../../problems/restore-the-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1416 | [恢复数组](../../problems/restore-the-array) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1411 | [给 N x 3 网格图涂色的方案数](../../problems/number-of-ways-to-paint-n-3-grid) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1406 | [石子游戏 III](../../problems/stone-game-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1402 | [做菜顺序](../../problems/reducing-dishes) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1397 | [找到所有好字符串](../../problems/find-all-good-strings) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1388 | [3n 块披萨](../../problems/pizza-with-3n-slices) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1359 | [有效的快递序列数目](../../problems/count-all-valid-pickup-and-delivery-options) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1349 | [参加考试的最大学生数](../../problems/maximum-students-taking-exam) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1340 | [跳跃游戏 V](../../problems/jump-game-v) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1335 | [工作计划的最低难度](../../problems/minimum-difficulty-of-a-job-schedule) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1326 | [灌溉花园的最少水龙头数目](../../problems/minimum-number-of-taps-to-open-to-water-a-garden) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1320 | [二指输入的的最小距离](../../problems/minimum-distance-to-type-a-word-using-two-fingers) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1314 | [矩阵区域和](../../problems/matrix-block-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1312 | [让字符串成为回文串的最少插入次数](../../problems/minimum-insertion-steps-to-make-a-string-palindrome) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1301 | [最大得分的路径数目](../../problems/number-of-paths-with-max-score) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1289 | [下降路径最小和 II](../../problems/minimum-falling-path-sum-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1278 | [分割回文串 III](../../problems/palindrome-partitioning-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1277 | [统计全为 1 的正方形子矩阵](../../problems/count-square-submatrices-with-all-ones) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1273 | [删除树节点](../../problems/delete-tree-nodes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1406 | [石子游戏 III](../../problems/stone-game-iii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 1402 | [做菜顺序](../../problems/reducing-dishes) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1397 | [找到所有好字符串](../../problems/find-all-good-strings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[字符串匹配](../string-matching/README.md)] | Hard | +| 1395 | [统计作战单位数](../../problems/count-number-of-teams) | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1388 | [3n 块披萨](../../problems/pizza-with-3n-slices) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1359 | [有效的快递序列数目](../../problems/count-all-valid-pickup-and-delivery-options) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1349 | [参加考试的最大学生数](../../problems/maximum-students-taking-exam) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1340 | [跳跃游戏 V](../../problems/jump-game-v) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1335 | [工作计划的最低难度](../../problems/minimum-difficulty-of-a-job-schedule) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1334 | [阈值距离内邻居最少的城市](../../problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | +| 1326 | [灌溉花园的最少水龙头数目](../../problems/minimum-number-of-taps-to-open-to-water-a-garden) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1320 | [二指输入的的最小距离](../../problems/minimum-distance-to-type-a-word-using-two-fingers) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1316 | [不同的循环子字符串](../../problems/distinct-echo-substrings) | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1312 | [让字符串成为回文串的最少插入次数](../../problems/minimum-insertion-steps-to-make-a-string-palindrome) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1301 | [最大得分的路径数目](../../problems/number-of-paths-with-max-score) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1289 | [下降路径最小和 II](../../problems/minimum-falling-path-sum-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1278 | [分割回文串 III](../../problems/palindrome-partitioning-iii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1277 | [统计全为 1 的正方形子矩阵](../../problems/count-square-submatrices-with-all-ones) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1269 | [停在原地的方案数](../../problems/number-of-ways-to-stay-in-the-same-place-after-some-steps) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1262 | [可被三整除的最大和](../../problems/greatest-sum-divisible-by-three) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1262 | [可被三整除的最大和](../../problems/greatest-sum-divisible-by-three) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1259 | [不相交的握手](../../problems/handshakes-that-dont-cross) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1246 | [删除回文子数组](../../problems/palindrome-removal) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1240 | [铺瓷砖](../../problems/tiling-a-rectangle-with-the-fewest-squares) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1230 | [抛掷硬币](../../problems/toss-strange-coins) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1223 | [掷骰子模拟](../../problems/dice-roll-simulation) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1255 | [得分最高的单词集合](../../problems/maximum-score-words-formed-by-letters) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1246 | [删除回文子数组](../../problems/palindrome-removal) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1240 | [铺瓷砖](../../problems/tiling-a-rectangle-with-the-fewest-squares) | [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1230 | [抛掷硬币](../../problems/toss-strange-coins) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 1223 | [掷骰子模拟](../../problems/dice-roll-simulation) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1220 | [统计元音字母序列的数目](../../problems/count-vowels-permutation) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1216 | [验证回文字符串 III](../../problems/valid-palindrome-iii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1199 | [建造街区的最短时间](../../problems/minimum-time-to-build-blocks) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1191 | [K 次串联后最大子数组之和](../../problems/k-concatenation-maximum-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1187 | [使数组严格递增](../../problems/make-array-strictly-increasing) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1186 | [删除一次得到子数组最大和](../../problems/maximum-subarray-sum-with-one-deletion) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1191 | [K 次串联后最大子数组之和](../../problems/k-concatenation-maximum-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1187 | [使数组严格递增](../../problems/make-array-strictly-increasing) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1186 | [删除一次得到子数组最大和](../../problems/maximum-subarray-sum-with-one-deletion) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1182 | [与目标颜色间的最短距离](../../problems/shortest-distance-to-target-color) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1155 | [掷骰子的N种方法](../../problems/number-of-dice-rolls-with-target-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1147 | [段式回文](../../problems/longest-chunked-palindrome-decomposition) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1143 | [最长公共子序列](../../problems/longest-common-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1140 | [石子游戏 II](../../problems/stone-game-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1139 | [最大的以 1 为边界的正方形](../../problems/largest-1-bordered-square) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1125 | [最小的必要团队](../../problems/smallest-sufficient-team) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1105 | [填充书架](../../problems/filling-bookcase-shelves) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1092 | [最短公共超序列](../../problems/shortest-common-supersequence) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 1147 | [段式回文](../../problems/longest-chunked-palindrome-decomposition) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1143 | [最长公共子序列](../../problems/longest-common-subsequence) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1140 | [石子游戏 II](../../problems/stone-game-ii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1139 | [最大的以 1 为边界的正方形](../../problems/largest-1-bordered-square) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1125 | [最小的必要团队](../../problems/smallest-sufficient-team) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1105 | [填充书架](../../problems/filling-bookcase-shelves) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1092 | [最短公共超序列](../../problems/shortest-common-supersequence) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1067 | [范围内的数字计数](../../problems/digit-count-in-range) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1055 | [形成字符串的最短路径](../../problems/shortest-way-to-form-string) 🔒 | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1049 | [最后一块石头的重量 II](../../problems/last-stone-weight-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1048 | [最长字符串链](../../problems/longest-string-chain) | [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1043 | [分隔数组以得到最大和](../../problems/partition-array-for-maximum-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1039 | [多边形三角剖分的最低得分](../../problems/minimum-score-triangulation-of-polygon) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1027 | [最长等差数列](../../problems/longest-arithmetic-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1025 | [除数博弈](../../problems/divisor-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 1024 | [视频拼接](../../problems/video-stitching) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 1062 | [最长重复子串](../../problems/longest-repeating-substring) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1055 | [形成字符串的最短路径](../../problems/shortest-way-to-form-string) 🔒 | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1049 | [最后一块石头的重量 II](../../problems/last-stone-weight-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1048 | [最长字符串链](../../problems/longest-string-chain) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1043 | [分隔数组以得到最大和](../../problems/partition-array-for-maximum-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1039 | [多边形三角剖分的最低得分](../../problems/minimum-score-triangulation-of-polygon) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1035 | [不相交的线](../../problems/uncrossed-lines) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1031 | [两个非重叠子数组的最大和](../../problems/maximum-sum-of-two-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1027 | [最长等差数列](../../problems/longest-arithmetic-subsequence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1025 | [除数博弈](../../problems/divisor-game) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Easy | +| 1024 | [视频拼接](../../problems/video-stitching) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1014 | [最佳观光组合](../../problems/best-sightseeing-pair) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1012 | [至少有 1 位重复的数字](../../problems/numbers-with-repeated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1000 | [合并石头的最低成本](../../problems/minimum-cost-to-merge-stones) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 983 | [最低票价](../../problems/minimum-cost-for-tickets) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 982 | [按位与为零的三元组](../../problems/triples-with-bitwise-and-equal-to-zero) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1000 | [合并石头的最低成本](../../problems/minimum-cost-to-merge-stones) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 983 | [最低票价](../../problems/minimum-cost-for-tickets) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[有序集合](../ordered-set/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 964 | [表示数字的最少运算符](../../problems/least-operators-to-express-number) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 960 | [删列造序 III](../../problems/delete-columns-to-make-sorted-iii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 956 | [最高的广告牌](../../problems/tallest-billboard) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 943 | [最短超级串](../../problems/find-the-shortest-superstring) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 940 | [不同的子序列 II](../../problems/distinct-subsequences-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 960 | [删列造序 III](../../problems/delete-columns-to-make-sorted-iii) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 956 | [最高的广告牌](../../problems/tallest-billboard) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 943 | [最短超级串](../../problems/find-the-shortest-superstring) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 940 | [不同的子序列 II](../../problems/distinct-subsequences-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 935 | [骑士拨号器](../../problems/knight-dialer) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 931 | [下降路径最小和](../../problems/minimum-falling-path-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 920 | [播放列表的数量](../../problems/number-of-music-playlists) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 903 | [DI 序列的有效排列](../../problems/valid-permutations-for-di-sequence) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 902 | [最大为 N 的数字组合](../../problems/numbers-at-most-n-given-digit-set) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 898 | [子数组按位或操作](../../problems/bitwise-ors-of-subarrays) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 931 | [下降路径最小和](../../problems/minimum-falling-path-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 926 | [将字符串翻转到单调递增](../../problems/flip-string-to-monotone-increasing) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 920 | [播放列表的数量](../../problems/number-of-music-playlists) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 918 | [环形子数组的最大和](../../problems/maximum-sum-circular-subarray) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] | Medium | +| 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 907 | [子数组的最小值之和](../../problems/sum-of-subarray-minimums) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 903 | [DI 序列的有效排列](../../problems/valid-permutations-for-di-sequence) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 902 | [最大为 N 的数字组合](../../problems/numbers-at-most-n-given-digit-set) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 898 | [子数组按位或操作](../../problems/bitwise-ors-of-subarrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 879 | [盈利计划](../../problems/profitable-schemes) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 877 | [石子游戏](../../problems/stone-game) | [[极小化极大](../minimax/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 871 | [最低加油次数](../../problems/minimum-number-of-refueling-stops) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 837 | [新21点](../../problems/new-21-game) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 818 | [赛车](../../problems/race-car) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 813 | [最大平均值和的分组](../../problems/largest-sum-of-averages) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 808 | [分汤](../../problems/soup-servings) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 801 | [使序列递增的最小交换次数](../../problems/minimum-swaps-to-make-sequences-increasing) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 879 | [盈利计划](../../problems/profitable-schemes) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 877 | [石子游戏](../../problems/stone-game) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 871 | [最低加油次数](../../problems/minimum-number-of-refueling-stops) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[位运算](../bit-manipulation/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 845 | [数组中的最长山脉](../../problems/longest-mountain-in-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[枚举](../enumeration/README.md)] | Medium | +| 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 837 | [新21点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 828 | [统计子串中的唯一字符](../../problems/count-unique-characters-of-all-substrings-of-a-given-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 823 | [带因子的二叉树](../../problems/binary-trees-with-factors) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 818 | [赛车](../../problems/race-car) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 813 | [最大平均值和的分组](../../problems/largest-sum-of-averages) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 808 | [分汤](../../problems/soup-servings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 805 | [数组的均值分割](../../problems/split-array-with-same-average) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 801 | [使序列递增的最小交换次数](../../problems/minimum-swaps-to-make-sequences-increasing) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 799 | [香槟塔](../../problems/champagne-tower) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 790 | [多米诺和托米诺平铺](../../problems/domino-and-tromino-tiling) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 764 | [最大加号标志](../../problems/largest-plus-sign) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 750 | [角矩形的数量](../../problems/number-of-corner-rectangles) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 788 | [旋转数字](../../problems/rotated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 764 | [最大加号标志](../../problems/largest-plus-sign) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 750 | [角矩形的数量](../../problems/number-of-corner-rectangles) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 746 | [使用最小花费爬楼梯](../../problems/min-cost-climbing-stairs) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 741 | [摘樱桃](../../problems/cherry-pickup) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 740 | [删除并获得点数](../../problems/delete-and-earn) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 741 | [摘樱桃](../../problems/cherry-pickup) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 740 | [删除并获得点数](../../problems/delete-and-earn) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 712 | [两个字符串的最小ASCII删除和](../../problems/minimum-ascii-delete-sum-for-two-strings) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 712 | [两个字符串的最小ASCII删除和](../../problems/minimum-ascii-delete-sum-for-two-strings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 689 | [三个无重叠子数组的最大和](../../problems/maximum-sum-of-3-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 688 | [“马”在棋盘上的概率](../../problems/knight-probability-in-chessboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 673 | [最长递增子序列的个数](../../problems/number-of-longest-increasing-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 664 | [奇怪的打印机](../../problems/strange-printer) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 656 | [金币路径](../../problems/coin-path) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 651 | [4键键盘](../../problems/4-keys-keyboard) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 650 | [只有两个键的键盘](../../problems/2-keys-keyboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 673 | [最长递增子序列的个数](../../problems/number-of-longest-increasing-subsequence) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 664 | [奇怪的打印机](../../problems/strange-printer) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 656 | [金币路径](../../problems/coin-path) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 651 | [4键键盘](../../problems/4-keys-keyboard) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 650 | [只有两个键的键盘](../../problems/2-keys-keyboard) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 647 | [回文子串](../../problems/palindromic-substrings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 646 | [最长数对链](../../problems/maximum-length-of-pair-chain) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 639 | [解码方法 II](../../problems/decode-ways-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 638 | [大礼包](../../problems/shopping-offers) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 646 | [最长数对链](../../problems/maximum-length-of-pair-chain) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 639 | [解码方法 II](../../problems/decode-ways-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 638 | [大礼包](../../problems/shopping-offers) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 634 | [寻找数组的错位排列](../../problems/find-the-derangement-of-an-array) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 629 | [K个逆序对数组](../../problems/k-inverse-pairs-array) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 600 | [不含连续1的非负整数](../../problems/non-negative-integers-without-consecutive-ones) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 576 | [出界的路径数](../../problems/out-of-boundary-paths) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 568 | [最大休假天数](../../problems/maximum-vacation-days) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 562 | [矩阵中最长的连续1线段](../../problems/longest-line-of-consecutive-one-in-matrix) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 583 | [两个字符串的删除操作](../../problems/delete-operation-for-two-strings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 576 | [出界的路径数](../../problems/out-of-boundary-paths) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 568 | [最大休假天数](../../problems/maximum-vacation-days) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 562 | [矩阵中最长的连续1线段](../../problems/longest-line-of-consecutive-one-in-matrix) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 553 | [最优除法](../../problems/optimal-division) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 552 | [学生出勤记录 II](../../problems/student-attendance-record-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 546 | [移除盒子](../../problems/remove-boxes) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 523 | [连续的子数组和](../../problems/continuous-subarray-sum) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 517 | [超级洗衣机](../../problems/super-washing-machines) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 516 | [最长回文子序列](../../problems/longest-palindromic-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 494 | [目标和](../../problems/target-sum) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 486 | [预测赢家](../../problems/predict-the-winner) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 474 | [一和零](../../problems/ones-and-zeroes) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 471 | [编码最短长度的字符串](../../problems/encode-string-with-shortest-length) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 467 | [环绕字符串中唯一的子字符串](../../problems/unique-substrings-in-wraparound-string) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 466 | [统计重复个数](../../problems/count-the-repetitions) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 464 | [我能赢吗](../../problems/can-i-win) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 446 | [等差数列划分 II - 子序列](../../problems/arithmetic-slices-ii-subsequence) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 416 | [分割等和子集](../../problems/partition-equal-subset-sum) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 403 | [青蛙过河](../../problems/frog-jump) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 377 | [组合总和 Ⅳ](../../problems/combination-sum-iv) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 375 | [猜数字大小 II](../../problems/guess-number-higher-or-lower-ii) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 361 | [轰炸敌人](../../problems/bomb-enemy) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 354 | [俄罗斯套娃信封问题](../../problems/russian-doll-envelopes) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 351 | [安卓系统手势解锁](../../problems/android-unlock-patterns) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 546 | [移除盒子](../../problems/remove-boxes) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 542 | [01 矩阵](../../problems/01-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 526 | [优美的排列](../../problems/beautiful-arrangement) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 518 | [零钱兑换 II](../../problems/coin-change-2) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 516 | [最长回文子序列](../../problems/longest-palindromic-subsequence) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 509 | [斐波那契数](../../problems/fibonacci-number) | [[递归](../recursion/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 494 | [目标和](../../problems/target-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 487 | [最大连续1的个数 II](../../problems/max-consecutive-ones-ii) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 486 | [预测赢家](../../problems/predict-the-winner) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 474 | [一和零](../../problems/ones-and-zeroes) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 473 | [火柴拼正方形](../../problems/matchsticks-to-square) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 471 | [编码最短长度的字符串](../../problems/encode-string-with-shortest-length) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 467 | [环绕字符串中唯一的子字符串](../../problems/unique-substrings-in-wraparound-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 466 | [统计重复个数](../../problems/count-the-repetitions) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 464 | [我能赢吗](../../problems/can-i-win) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 458 | [可怜的小猪](../../problems/poor-pigs) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 446 | [等差数列划分 II - 子序列](../../problems/arithmetic-slices-ii-subsequence) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 435 | [无重叠区间](../../problems/non-overlapping-intervals) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 416 | [分割等和子集](../../problems/partition-equal-subset-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 403 | [青蛙过河](../../problems/frog-jump) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 397 | [整数替换](../../problems/integer-replacement) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 396 | [旋转函数](../../problems/rotate-function) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 392 | [判断子序列](../../problems/is-subsequence) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 377 | [组合总和 Ⅳ](../../problems/combination-sum-iv) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 375 | [猜数字大小 II](../../problems/guess-number-higher-or-lower-ii) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 361 | [轰炸敌人](../../problems/bomb-enemy) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 354 | [俄罗斯套娃信封问题](../../problems/russian-doll-envelopes) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 351 | [安卓系统手势解锁](../../problems/android-unlock-patterns) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 343 | [整数拆分](../../problems/integer-break) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 338 | [比特位计数](../../problems/counting-bits) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 322 | [零钱兑换](../../problems/coin-change) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 321 | [拼接最大数](../../problems/create-maximum-number) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 312 | [戳气球](../../problems/burst-balloons) | [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 309 | [最佳买卖股票时机含冷冻期](../../problems/best-time-to-buy-and-sell-stock-with-cooldown) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 304 | [二维区域和检索 - 矩阵不可变](../../problems/range-sum-query-2d-immutable) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 303 | [区域和检索 - 数组不可变](../../problems/range-sum-query-immutable) | [[动态规划](../dynamic-programming/README.md)] | Easy | -| 300 | [最长递增子序列](../../problems/longest-increasing-subsequence) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 333 | [最大 BST 子树](../../problems/largest-bst-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 322 | [零钱兑换](../../problems/coin-change) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 313 | [超级丑数](../../problems/super-ugly-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 312 | [戳气球](../../problems/burst-balloons) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 309 | [最佳买卖股票时机含冷冻期](../../problems/best-time-to-buy-and-sell-stock-with-cooldown) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 300 | [最长递增子序列](../../problems/longest-increasing-subsequence) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 294 | [翻转游戏 II](../../problems/flip-game-ii) 🔒 | [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 276 | [栅栏涂色](../../problems/paint-fence) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 265 | [粉刷房子 II](../../problems/paint-house-ii) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 256 | [粉刷房子](../../problems/paint-house) 🔒 | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 221 | [最大正方形](../../problems/maximal-square) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 213 | [打家劫舍 II](../../problems/house-robber-ii) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 198 | [打家劫舍](../../problems/house-robber) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 188 | [买卖股票的最佳时机 IV](../../problems/best-time-to-buy-and-sell-stock-iv) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 174 | [地下城游戏](../../problems/dungeon-game) | [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 265 | [粉刷房子 II](../../problems/paint-house-ii) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 264 | [丑数 II](../../problems/ugly-number-ii) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 256 | [粉刷房子](../../problems/paint-house) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 241 | [为运算表达式设计优先级](../../problems/different-ways-to-add-parentheses) | [[递归](../recursion/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 233 | [数字 1 的个数](../../problems/number-of-digit-one) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 221 | [最大正方形](../../problems/maximal-square) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 213 | [打家劫舍 II](../../problems/house-robber-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 198 | [打家劫舍](../../problems/house-robber) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 188 | [买卖股票的最佳时机 IV](../../problems/best-time-to-buy-and-sell-stock-iv) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 174 | [地下城游戏](../../problems/dungeon-game) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 152 | [乘积最大子数组](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 140 | [单词拆分 II](../../problems/word-break-ii) | [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 139 | [单词拆分](../../problems/word-break) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 132 | [分割回文串 II](../../problems/palindrome-partitioning-ii) | [[动态规划](../dynamic-programming/README.md)] | Hard | -| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 140 | [单词拆分 II](../../problems/word-break-ii) | [[字典树](../trie/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 139 | [单词拆分](../../problems/word-break) | [[字典树](../trie/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 132 | [分割回文串 II](../../problems/palindrome-partitioning-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 123 | [买卖股票的最佳时机 III](../../problems/best-time-to-buy-and-sell-stock-iii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 121 | [买卖股票的最佳时机](../../problems/best-time-to-buy-and-sell-stock) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 120 | [三角形最小路径和](../../problems/triangle) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 119 | [杨辉三角 II](../../problems/pascals-triangle-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 118 | [杨辉三角](../../problems/pascals-triangle) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 115 | [不同的子序列](../../problems/distinct-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 91 | [解码方法](../../problems/decode-ways) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 87 | [扰乱字符串](../../problems/scramble-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 72 | [编辑距离](../../problems/edit-distance) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 70 | [爬楼梯](../../problems/climbing-stairs) | [[动态规划](../dynamic-programming/README.md)] | Easy | -| 64 | [最小路径和](../../problems/minimum-path-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 63 | [不同路径 II](../../problems/unique-paths-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 62 | [不同路径](../../problems/unique-paths) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 70 | [爬楼梯](../../problems/climbing-stairs) | [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 64 | [最小路径和](../../problems/minimum-path-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 63 | [不同路径 II](../../problems/unique-paths-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 62 | [不同路径](../../problems/unique-paths) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | +| 55 | [跳跃游戏](../../problems/jump-game) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 5 | [最长回文子串](../../problems/longest-palindromic-substring) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index 085448301..a9dcf8e41 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -9,12 +9,27 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard | -| 1515 | [服务中心的最佳位置](../../problems/best-position-for-a-service-centre) | [[几何](../geometry/README.md)] | Hard | -| 1453 | [圆形靶内的最大飞镖数量](../../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | [[几何](../geometry/README.md)] | Hard | -| 1401 | [圆和矩形是否有重叠](../../problems/circle-and-rectangle-overlapping) | [[几何](../geometry/README.md)] | Medium | -| 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] | Easy | +| 1828 | [统计一个圆中点的数目](../../problems/queries-on-number-of-points-inside-a-circle) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 1515 | [服务中心的最佳位置](../../problems/best-position-for-a-service-centre) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Hard | +| 1453 | [圆形靶内的最大飞镖数量](../../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1401 | [圆和矩形是否有重叠](../../problems/circle-and-rectangle-overlapping) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | +| 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | -| 892 | [三维形体的表面积](../../problems/surface-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | -| 587 | [安装栅栏](../../problems/erect-the-fence) | [[几何](../geometry/README.md)] | Hard | +| 1037 | [有效的回旋镖](../../problems/valid-boomerang) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | +| 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Easy | +| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 939 | [最小面积矩形](../../problems/minimum-area-rectangle) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 892 | [三维形体的表面积](../../problems/surface-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 883 | [三维形体投影面积](../../problems/projection-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 858 | [镜面反射](../../problems/mirror-reflection) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | +| 836 | [矩形重叠](../../problems/rectangle-overlap) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | +| 812 | [最大三角形面积](../../problems/largest-triangle-area) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 593 | [有效的正方形](../../problems/valid-square) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | +| 587 | [安装栅栏](../../problems/erect-the-fence) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] [[拒绝采样](../rejection-sampling/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 469 | [凸多边形](../../problems/convex-polygon) 🔒 | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | +| 335 | [路径交叉](../../problems/self-crossing) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 223 | [矩形面积](../../problems/rectangle-area) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index 51e44a4a4..82fb6b4a0 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,62 +9,76 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1820 | [Maximum Number of Accepted Invitations](../../problems/maximum-number-of-accepted-invitations) 🔒 | [[图](../graph/README.md)] | Medium | -| 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1791 | [找出星型图的中心节点](../../problems/find-center-of-star-graph) | [[图](../graph/README.md)] | Medium | -| 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1782 | [统计点对的数目](../../problems/count-pairs-of-nodes) | [[图](../graph/README.md)] | Hard | -| 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1765 | [地图中的最高点](../../problems/map-of-highest-peak) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] [[计数](../counting/README.md)] | Hard | +| 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1791 | [找出星型图的中心节点](../../problems/find-center-of-star-graph) | [[图](../graph/README.md)] | Easy | +| 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1782 | [统计点对的数目](../../problems/count-pairs-of-nodes) | [[图](../graph/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] | Medium | | 1761 | [一个图中连通三元组的最小度数](../../problems/minimum-degree-of-a-connected-trio-in-a-graph) | [[图](../graph/README.md)] | Hard | -| 1730 | [获取食物的最短路径](../../problems/shortest-path-to-get-food) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1724 | [检查边长度限制的路径是否存在 II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] | Hard | -| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1728 | [猫和老鼠 II](../../problems/cat-and-mouse-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 1724 | [检查边长度限制的路径是否存在 II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] | Hard | +| 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 1697 | [检查边长度限制的路径是否存在](../../problems/checking-existence-of-edge-length-limited-paths) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1615 | [最大网络秩](../../problems/maximal-network-rank) | [[图](../graph/README.md)] | Medium | -| 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1591 | [奇怪的打印机 II](../../problems/strange-printer-ii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1579 | [保证图可完全遍历](../../problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 1557 | [可以到达所有点的最少点数目](../../problems/minimum-number-of-vertices-to-reach-all-nodes) | [[图](../graph/README.md)] | Medium | | 1548 | [图中最相似的路径](../../problems/the-most-similar-path-in-a-graph) 🔒 | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] | Medium | -| 1494 | [并行课程 II](../../problems/parallel-courses-ii) | [[图](../graph/README.md)] | Hard | -| 1462 | [课程表 IV](../../problems/course-schedule-iv) | [[图](../graph/README.md)] | Medium | -| 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | -| 1361 | [验证二叉树](../../problems/validate-binary-tree-nodes) | [[图](../graph/README.md)] | Medium | -| 1334 | [阈值距离内邻居最少的城市](../../problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | [[图](../graph/README.md)] | Medium | -| 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | -| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | -| 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1153 | [字符串转化](../../problems/string-transforms-into-another-string) 🔒 | [[图](../graph/README.md)] | Hard | -| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1135 | [最低成本联通所有城市](../../problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1494 | [并行课程 II](../../problems/parallel-courses-ii) | [[位运算](../bit-manipulation/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] [[排序](../sorting/README.md)] [[强连通分量](../strongly-connected-component/README.md)] | Hard | +| 1466 | [重新规划路线](../../problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1462 | [课程表 IV](../../problems/course-schedule-iv) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 1377 | [T 秒后青蛙的位置](../../problems/frog-position-after-t-seconds) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Hard | +| 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1361 | [验证二叉树](../../problems/validate-binary-tree-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1334 | [阈值距离内邻居最少的城市](../../problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | +| 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 1192 | [查找集群内的「关键连接」](../../problems/critical-connections-in-a-network) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[双连通分量](../biconnected-component/README.md)] | Hard | +| 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] | Hard | +| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 1135 | [最低成本联通所有城市](../../problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 1059 | [从始点到终点的所有路径](../../problems/all-paths-from-source-lead-to-destination) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[图](../graph/README.md)] | Medium | -| 997 | [找到小镇的法官](../../problems/find-the-town-judge) | [[图](../graph/README.md)] | Easy | -| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 990 | [等式方程的可满足性](../../problems/satisfiability-of-equality-equations) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 854 | [相似度为 K 的字符串](../../problems/k-similar-strings) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Hard | -| 841 | [钥匙和房间](../../problems/keys-and-rooms) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 802 | [找到最终的安全状态](../../problems/find-eventual-safe-states) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 684 | [冗余连接](../../problems/redundant-connection) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 444 | [序列重建](../../problems/sequence-reconstruction) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 399 | [除法求值](../../problems/evaluate-division) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 997 | [找到小镇的法官](../../problems/find-the-town-judge) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 990 | [等式方程的可满足性](../../problems/satisfiability-of-equality-equations) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 947 | [移除最多的同行或同列石头](../../problems/most-stones-removed-with-same-row-or-column) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 882 | [细分图中的可到达结点](../../problems/reachable-nodes-in-subdivided-graph) | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 851 | [喧闹和富有](../../problems/loud-and-rich) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] | Medium | +| 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[位运算](../bit-manipulation/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 841 | [钥匙和房间](../../problems/keys-and-rooms) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 802 | [找到最终的安全状态](../../problems/find-eventual-safe-states) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 797 | [所有可能的路径](../../problems/all-paths-from-source-to-target) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 753 | [破解保险箱](../../problems/cracking-the-safe) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | +| 743 | [网络延迟时间](../../problems/network-delay-time) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 684 | [冗余连接](../../problems/redundant-connection) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 631 | [设计 Excel 求和公式](../../problems/design-excel-sum-formula) 🔒 | [[图](../graph/README.md)] [[设计](../design/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 547 | [省份数量](../../problems/number-of-provinces) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 505 | [迷宫 II](../../problems/the-maze-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 499 | [迷宫 III](../../problems/the-maze-iii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 490 | [迷宫](../../problems/the-maze) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 444 | [序列重建](../../problems/sequence-reconstruction) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] | Medium | +| 399 | [除法求值](../../problems/evaluate-division) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Medium | +| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Medium | +| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 310 | [最小高度树](../../problems/minimum-height-trees) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 310 | [最小高度树](../../problems/minimum-height-trees) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 277 | [搜寻名人](../../problems/find-the-celebrity) 🔒 | [[贪心](../greedy/README.md)] [[图](../graph/README.md)] [[双指针](../two-pointers/README.md)] [[交互](../interactive/README.md)] | Medium | +| 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | | 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | | 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 6b460c9ed..85f9d22cc 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,166 +9,192 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1881 | [插入后的最大值](../../problems/maximum-value-after-insertion) | [[贪心算法](../greedy/README.md)] | Medium | -| 1877 | [数组中最大数对和的最小值](../../problems/minimize-maximum-pair-sum-in-array) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1874 | [Minimize Product Sum of Two Arrays](../../problems/minimize-product-sum-of-two-arrays) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | -| 1871 | [跳跃游戏 VII](../../problems/jump-game-vii) | [[贪心算法](../greedy/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1864 | [构成交替字符串需要的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-binary-string-alternating) | [[贪心算法](../greedy/README.md)] | Medium | -| 1855 | [下标对中的最大距离](../../problems/maximum-distance-between-a-pair-of-values) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1850 | [邻位交换的最小次数](../../problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1846 | [减小和重新排列数组后的最大元素](../../problems/maximum-element-after-decreasing-and-rearranging) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1842 | [Next Palindrome Using Same Digits](../../problems/next-palindrome-using-same-digits) 🔒 | [[贪心算法](../greedy/README.md)] | Hard | -| 1840 | [最高建筑高度](../../problems/maximum-building-height) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1838 | [最高频元素的频数](../../problems/frequency-of-the-most-frequent-element) | [[贪心算法](../greedy/README.md)] | Medium | -| 1827 | [最少操作使数组递增](../../problems/minimum-operations-to-make-the-array-increasing) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1806 | [还原排列的最少操作步数](../../problems/minimum-number-of-operations-to-reinitialize-a-permutation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1802 | [有界数组中指定下标处的最大值](../../problems/maximum-value-at-a-given-index-in-a-bounded-array) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 1798 | [你能构造出连续值的最大数目](../../problems/maximum-number-of-consecutive-values-you-can-make) | [[贪心算法](../greedy/README.md)] | Medium | -| 1794 | [统计距离最小的子串对个数](../../problems/count-pairs-of-equal-substrings-with-minimum-difference) 🔒 | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[贪心算法](../greedy/README.md)] | Hard | -| 1788 | [Maximize the Beauty of the Garden](../../problems/maximize-the-beauty-of-the-garden) 🔒 | [[贪心算法](../greedy/README.md)] | Hard | -| 1785 | [构成特定和需要添加的最少元素](../../problems/minimum-elements-to-add-to-form-a-given-sum) | [[贪心算法](../greedy/README.md)] | Medium | -| 1784 | [检查二进制字符串字段](../../problems/check-if-binary-string-has-at-most-one-segment-of-ones) | [[贪心算法](../greedy/README.md)] | Easy | -| 1775 | [通过最少操作次数使数组的和相等](../../problems/equal-sum-arrays-with-minimum-number-of-operations) | [[贪心算法](../greedy/README.md)] | Medium | -| 1774 | [最接近目标价格的甜点成本](../../problems/closest-dessert-cost) | [[贪心算法](../greedy/README.md)] | Medium | -| 1769 | [移动所有球到每个盒子所需的最小操作数](../../problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1764 | [通过连接另一个数组的子数组得到一个数组](../../problems/form-array-by-concatenating-subarrays-of-another-array) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1762 | [能看到海景的建筑物](../../problems/buildings-with-an-ocean-view) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | -| 1759 | [统计同构子字符串的数目](../../problems/count-number-of-homogenous-substrings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1758 | [生成交替二进制字符串的最少操作数](../../problems/minimum-changes-to-make-alternating-binary-string) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 1754 | [构造字典序最大的合并字符串](../../problems/largest-merge-of-two-strings) | [[贪心算法](../greedy/README.md)] | Medium | -| 1749 | [任意子数组和的绝对值的最大值](../../problems/maximum-absolute-sum-of-any-subarray) | [[贪心算法](../greedy/README.md)] | Medium | -| 1743 | [从相邻元素对还原数组](../../problems/restore-the-array-from-adjacent-pairs) | [[贪心算法](../greedy/README.md)] | Medium | -| 1737 | [满足三条件之一需改变的最少字符数](../../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1736 | [替换隐藏数字得到的最晚时间](../../problems/latest-time-by-replacing-hidden-digits) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | -| 1733 | [需要教语言的最少人数](../../problems/minimum-number-of-people-to-teach) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1727 | [重新排列后的最大子矩阵](../../problems/largest-submatrix-with-rearrangements) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1725 | [可以形成最大正方形的矩形数目](../../problems/number-of-rectangles-that-can-form-the-largest-square) | [[贪心算法](../greedy/README.md)] | Easy | -| 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[贪心算法](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 1717 | [删除子字符串的最大得分](../../problems/maximum-score-from-removing-substrings) | [[贪心算法](../greedy/README.md)] | Medium | -| 1716 | [计算力扣银行的钱](../../problems/calculate-money-in-leetcode-bank) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Easy | -| 1713 | [得到子序列的最少操作次数](../../problems/minimum-operations-to-make-a-subsequence) | [[贪心算法](../greedy/README.md)] | Hard | -| 1710 | [卡车上的最大单元数](../../problems/maximum-units-on-a-truck) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | -| 1708 | [长度为 K 的最大子数组](../../problems/largest-subarray-length-k) 🔒 | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 1705 | [吃苹果的最大数目](../../problems/maximum-number-of-eaten-apples) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 1702 | [修改后的最大二进制字符串](../../problems/maximum-binary-string-after-change) | [[贪心算法](../greedy/README.md)] | Medium | -| 1689 | [十-二进制数的最少数目](../../problems/partitioning-into-minimum-number-of-deci-binary-numbers) | [[贪心算法](../greedy/README.md)] | Medium | -| 1686 | [石子游戏 VI](../../problems/stone-game-vi) | [[贪心算法](../greedy/README.md)] | Medium | -| 1685 | [有序数组中差绝对值之和](../../problems/sum-of-absolute-differences-in-a-sorted-array) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 1681 | [最小不兼容性](../../problems/minimum-incompatibility) | [[贪心算法](../greedy/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1674 | [使数组互补的最少操作次数](../../problems/minimum-moves-to-make-array-complementary) | [[贪心算法](../greedy/README.md)] | Medium | -| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | -| 1665 | [完成所有任务的最少初始能量](../../problems/minimum-initial-energy-to-finish-tasks) | [[贪心算法](../greedy/README.md)] | Hard | -| 1664 | [生成平衡数组的方案数](../../problems/ways-to-make-a-fair-array) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1663 | [具有给定数值的最小字符串](../../problems/smallest-string-with-a-given-numeric-value) | [[贪心算法](../greedy/README.md)] | Medium | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1657 | [确定两个字符串是否接近](../../problems/determine-if-two-strings-are-close) | [[贪心算法](../greedy/README.md)] | Medium | -| 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | -| 1647 | [字符频次唯一的最小删除次数](../../problems/minimum-deletions-to-make-character-frequencies-unique) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] | Hard | -| 1620 | [网络信号最好的坐标](../../problems/coordinate-with-maximum-network-quality) | [[贪心算法](../greedy/README.md)] | Medium | -| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1605 | [给定行和列的和求可行矩阵](../../problems/find-valid-matrix-given-row-and-column-sums) | [[贪心算法](../greedy/README.md)] | Medium | -| 1599 | [经营摩天轮的最大利润](../../problems/maximum-profit-of-operating-a-centennial-wheel) | [[贪心算法](../greedy/README.md)] | Medium | -| 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1591 | [奇怪的打印机 II](../../problems/strange-printer-ii) | [[贪心算法](../greedy/README.md)] | Hard | -| 1589 | [所有排列中的最大和](../../problems/maximum-sum-obtained-of-any-permutation) | [[贪心算法](../greedy/README.md)] | Medium | -| 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | -| 1580 | [把箱子放进仓库里 II](../../problems/put-boxes-into-the-warehouse-ii) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心算法](../greedy/README.md)] | Medium | -| 1568 | [使陆地分离的最少天数](../../problems/minimum-number-of-days-to-disconnect-island) | [[贪心算法](../greedy/README.md)] | Hard | -| 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心算法](../greedy/README.md)] | Medium | -| 1564 | [把箱子放进仓库里 I](../../problems/put-boxes-into-the-warehouse-i) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | -| 1558 | [得到目标数组的最少函数调用次数](../../problems/minimum-numbers-of-function-calls-to-make-target-array) | [[贪心算法](../greedy/README.md)] | Medium | -| 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心算法](../greedy/README.md)] | Medium | -| 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心算法](../greedy/README.md)] | Hard | -| 1518 | [换酒问题](../../problems/water-bottles) | [[贪心算法](../greedy/README.md)] | Easy | -| 1505 | [最多 K 次交换相邻数位后得到的最小整数](../../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | [[贪心算法](../greedy/README.md)] | Hard | -| 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1414 | [和为 K 的最少斐波那契数字数目](../../problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | -| 1400 | [构造 K 个回文字符串](../../problems/construct-k-palindrome-strings) | [[贪心算法](../greedy/README.md)] | Medium | -| 1386 | [安排电影院座位](../../problems/cinema-seat-allocation) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Hard | -| 1354 | [多次求和构造目标数组](../../problems/construct-target-array-with-multiple-sums) | [[贪心算法](../greedy/README.md)] | Hard | -| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | -| 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1326 | [灌溉花园的最少水龙头数目](../../problems/minimum-number-of-taps-to-open-to-water-a-garden) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1282 | [用户分组](../../problems/group-the-people-given-the-group-size-they-belong-to) | [[贪心算法](../greedy/README.md)] | Medium | -| 1276 | [不浪费原料的汉堡制作方案](../../problems/number-of-burgers-with-no-waste-of-ingredients) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 1253 | [重构 2 行二进制矩阵](../../problems/reconstruct-a-2-row-binary-matrix) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 1247 | [交换字符使得字符串相同](../../problems/minimum-swaps-to-make-strings-equal) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1231 | [分享巧克力](../../problems/divide-chocolate) 🔒 | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1221 | [分割平衡字符串](../../problems/split-a-string-in-balanced-strings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | -| 1217 | [玩筹码](../../problems/minimum-cost-to-move-chips-to-the-same-position) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 1196 | [最多可以买到的苹果数量](../../problems/how-many-apples-can-you-put-into-the-basket) 🔒 | [[贪心算法](../greedy/README.md)] | Easy | -| 1167 | [连接棒材的最低费用](../../problems/minimum-cost-to-connect-sticks) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | -| 1111 | [有效括号的嵌套深度](../../problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1094 | [拼车](../../problems/car-pooling) | [[贪心算法](../greedy/README.md)] | Medium | -| 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1057 | [校园自行车分配](../../problems/campus-bikes) 🔒 | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1055 | [形成字符串的最短路径](../../problems/shortest-way-to-form-string) 🔒 | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1053 | [交换一次的先前排列](../../problems/previous-permutation-with-one-swap) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1046 | [最后一块石头的重量](../../problems/last-stone-weight) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Easy | -| 1029 | [两地调度](../../problems/two-city-scheduling) | [[贪心算法](../greedy/README.md)] | Medium | -| 1007 | [行相等的最少多米诺旋转](../../problems/minimum-domino-rotations-for-equal-row) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1005 | [K 次取反后最大化的数组和](../../problems/maximize-sum-of-array-after-k-negations) | [[贪心算法](../greedy/README.md)] | Easy | -| 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[贪心算法](../greedy/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 991 | [坏了的计算器](../../problems/broken-calculator) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 984 | [不含 AAA 或 BBB 的字符串](../../problems/string-without-aaa-or-bbb) | [[贪心算法](../greedy/README.md)] | Medium | -| 955 | [删列造序 II](../../problems/delete-columns-to-make-sorted-ii) | [[贪心算法](../greedy/README.md)] | Medium | -| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 944 | [删列造序](../../problems/delete-columns-to-make-sorted) | [[贪心算法](../greedy/README.md)] | Easy | -| 936 | [戳印序列](../../problems/stamping-the-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | -| 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 921 | [使括号有效的最少添加](../../problems/minimum-add-to-make-parentheses-valid) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 910 | [最小差值 II](../../problems/smallest-range-ii) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 874 | [模拟行走机器人](../../problems/walking-robot-simulation) | [[贪心算法](../greedy/README.md)] | Easy | -| 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 861 | [翻转矩阵后的得分](../../problems/score-after-flipping-matrix) | [[贪心算法](../greedy/README.md)] | Medium | -| 860 | [柠檬水找零](../../problems/lemonade-change) | [[贪心算法](../greedy/README.md)] | Easy | -| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | -| 757 | [设置交集大小至少为2](../../problems/set-intersection-size-at-least-two) | [[贪心算法](../greedy/README.md)] | Hard | -| 738 | [单调递增的数字](../../problems/monotone-increasing-digits) | [[贪心算法](../greedy/README.md)] | Medium | -| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 651 | [4键键盘](../../problems/4-keys-keyboard) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 649 | [Dota2 参议院](../../problems/dota2-senate) | [[贪心算法](../greedy/README.md)] | Medium | -| 630 | [课程表 III](../../problems/course-schedule-iii) | [[贪心算法](../greedy/README.md)] | Hard | -| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | -| 605 | [种花问题](../../problems/can-place-flowers) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 502 | [IPO](../../problems/ipo) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | -| 484 | [寻找排列](../../problems/find-permutation) 🔒 | [[贪心算法](../greedy/README.md)] | Medium | -| 455 | [分发饼干](../../problems/assign-cookies) | [[贪心算法](../greedy/README.md)] | Easy | -| 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 435 | [无重叠区间](../../problems/non-overlapping-intervals) | [[贪心算法](../greedy/README.md)] | Medium | -| 406 | [根据身高重建队列](../../problems/queue-reconstruction-by-height) | [[贪心算法](../greedy/README.md)] | Medium | -| 402 | [移掉K位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 392 | [判断子序列](../../problems/is-subsequence) | [[贪心算法](../greedy/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 330 | [按要求补齐数组](../../problems/patching-array) | [[贪心算法](../greedy/README.md)] | Hard | -| 321 | [拼接最大数](../../problems/create-maximum-number) | [[贪心算法](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 135 | [分发糖果](../../problems/candy) | [[贪心算法](../greedy/README.md)] | Hard | -| 134 | [加油站](../../problems/gas-station) | [[贪心算法](../greedy/README.md)] | Medium | -| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Easy | -| 55 | [跳跃游戏](../../problems/jump-game) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1903 | [字符串中的最大奇数](../../problems/largest-odd-number-in-string) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1899 | [合并若干三元组以形成目标三元组](../../problems/merge-triplets-to-form-target-triplet) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1888 | [使二进制字符串字符交替的最少反转次数](../../problems/minimum-number-of-flips-to-make-the-binary-string-alternating) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1881 | [插入后的最大值](../../problems/maximum-value-after-insertion) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1877 | [数组中最大数对和的最小值](../../problems/minimize-maximum-pair-sum-in-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1874 | [两个数组的最小乘积和](../../problems/minimize-product-sum-of-two-arrays) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1864 | [构成交替字符串需要的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-binary-string-alternating) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1855 | [下标对中的最大距离](../../problems/maximum-distance-between-a-pair-of-values) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1850 | [邻位交换的最小次数](../../problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1846 | [减小和重新排列数组后的最大元素](../../problems/maximum-element-after-decreasing-and-rearranging) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1833 | [雪糕的最大数量](../../problems/maximum-ice-cream-bars) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1827 | [最少操作使数组递增](../../problems/minimum-operations-to-make-the-array-increasing) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 1824 | [最少侧跳次数](../../problems/minimum-sideway-jumps) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1802 | [有界数组中指定下标处的最大值](../../problems/maximum-value-at-a-given-index-in-a-bounded-array) | [[贪心](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1798 | [你能构造出连续值的最大数目](../../problems/maximum-number-of-consecutive-values-you-can-make) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1794 | [统计距离最小的子串对个数](../../problems/count-pairs-of-equal-substrings-with-minimum-difference) 🔒 | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1792 | [最大平均通过率](../../problems/maximum-average-pass-ratio) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1788 | [最大化花园的美观度](../../problems/maximize-the-beauty-of-the-garden) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 1785 | [构成特定和需要添加的最少元素](../../problems/minimum-elements-to-add-to-form-a-given-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1775 | [通过最少操作次数使数组的和相等](../../problems/equal-sum-arrays-with-minimum-number-of-operations) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 1764 | [通过连接另一个数组的子数组得到一个数组](../../problems/form-array-by-concatenating-subarrays-of-another-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 1754 | [构造字典序最大的合并字符串](../../problems/largest-merge-of-two-strings) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1753 | [移除石子的最大得分](../../problems/maximum-score-from-removing-stones) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1739 | [放置盒子](../../problems/building-boxes) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1733 | [需要教语言的最少人数](../../problems/minimum-number-of-people-to-teach) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1727 | [重新排列后的最大子矩阵](../../problems/largest-submatrix-with-rearrangements) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1717 | [删除子字符串的最大得分](../../problems/maximum-score-from-removing-substrings) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1713 | [得到子序列的最少操作次数](../../problems/minimum-operations-to-make-a-subsequence) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1710 | [卡车上的最大单元数](../../problems/maximum-units-on-a-truck) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1708 | [长度为 K 的最大子数组](../../problems/largest-subarray-length-k) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 1705 | [吃苹果的最大数目](../../problems/maximum-number-of-eaten-apples) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1703 | [得到连续 K 个 1 的最少相邻交换次数](../../problems/minimum-adjacent-swaps-for-k-consecutive-ones) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 1702 | [修改后的最大二进制字符串](../../problems/maximum-binary-string-after-change) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1689 | [十-二进制数的最少数目](../../problems/partitioning-into-minimum-number-of-deci-binary-numbers) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1686 | [石子游戏 VI](../../problems/stone-game-vi) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1671 | [得到山形数组的最少删除次数](../../problems/minimum-number-of-removals-to-make-mountain-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1665 | [完成所有任务的最少初始能量](../../problems/minimum-initial-energy-to-finish-tasks) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1663 | [具有给定数值的最小字符串](../../problems/smallest-string-with-a-given-numeric-value) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1647 | [字符频次唯一的最小删除次数](../../problems/minimum-deletions-to-make-character-frequencies-unique) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1642 | [可以到达的最远建筑](../../problems/furthest-building-you-can-reach) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1605 | [给定行和列的和求可行矩阵](../../problems/find-valid-matrix-given-row-and-column-sums) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1589 | [所有排列中的最大和](../../problems/maximum-sum-obtained-of-any-permutation) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1580 | [把箱子放进仓库里 II](../../problems/put-boxes-into-the-warehouse-ii) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1564 | [把箱子放进仓库里 I](../../problems/put-boxes-into-the-warehouse-i) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1561 | [你可以获得的最大硬币数目](../../problems/maximum-number-of-coins-you-can-get) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1558 | [得到目标数组的最少函数调用次数](../../problems/minimum-numbers-of-function-calls-to-make-target-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1546 | [和为目标值且不重叠的非空子数组的最大数目](../../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1537 | [最大得分](../../problems/get-the-maximum-score) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | +| 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1505 | [最多 K 次交换相邻数位后得到的最小整数](../../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | [[贪心](../greedy/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[字符串](../string/README.md)] | Hard | +| 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1481 | [不同整数的最少数目](../../problems/least-number-of-unique-integers-after-k-removals) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1465 | [切割后面积最大的蛋糕](../../problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1432 | [改变一个整数能得到的最大差值](../../problems/max-difference-you-can-get-from-changing-an-integer) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 1414 | [和为 K 的最少斐波那契数字数目](../../problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | [[贪心](../greedy/README.md)] | Medium | +| 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1402 | [做菜顺序](../../problems/reducing-dishes) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1400 | [构造 K 个回文字符串](../../problems/construct-k-palindrome-strings) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 1388 | [3n 块披萨](../../problems/pizza-with-3n-slices) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1386 | [安排电影院座位](../../problems/cinema-seat-allocation) | [[贪心](../greedy/README.md)] [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1382 | [将二叉搜索树变平衡](../../problems/balance-a-binary-search-tree) | [[贪心](../greedy/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1330 | [翻转子数组得到最大的数组值](../../problems/reverse-subarray-to-maximize-array-value) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1328 | [破坏回文串](../../problems/break-a-palindrome) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1326 | [灌溉花园的最少水龙头数目](../../problems/minimum-number-of-taps-to-open-to-water-a-garden) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1323 | [6 和 9 组成的最大数字](../../problems/maximum-69-number) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Easy | +| 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1262 | [可被三整除的最大和](../../problems/greatest-sum-divisible-by-three) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1253 | [重构 2 行二进制矩阵](../../problems/reconstruct-a-2-row-binary-matrix) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1247 | [交换字符使得字符串相同](../../problems/minimum-swaps-to-make-strings-equal) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1221 | [分割平衡字符串](../../problems/split-a-string-in-balanced-strings) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1217 | [玩筹码](../../problems/minimum-cost-to-move-chips-to-the-same-position) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1199 | [建造街区的最短时间](../../problems/minimum-time-to-build-blocks) 🔒 | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1196 | [最多可以买到的苹果数量](../../problems/how-many-apples-can-you-put-into-the-basket) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1183 | [矩阵中 1 的最大数量](../../problems/maximum-number-of-ones) 🔒 | [[贪心](../greedy/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1167 | [连接棒材的最低费用](../../problems/minimum-cost-to-connect-sticks) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1147 | [段式回文](../../problems/longest-chunked-palindrome-decomposition) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1144 | [递减元素使数组呈锯齿状](../../problems/decrease-elements-to-make-array-zigzag) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1121 | [将数组分成几个递增序列](../../problems/divide-array-into-increasing-sequences) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Hard | +| 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1057 | [校园自行车分配](../../problems/campus-bikes) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1055 | [形成字符串的最短路径](../../problems/shortest-way-to-form-string) 🔒 | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1053 | [交换一次的先前排列](../../problems/previous-permutation-with-one-swap) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1029 | [两地调度](../../problems/two-city-scheduling) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1024 | [视频拼接](../../problems/video-stitching) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1013 | [将数组分成和相等的三个部分](../../problems/partition-array-into-three-parts-with-equal-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 1011 | [在 D 天内送达包裹的能力](../../problems/capacity-to-ship-packages-within-d-days) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1007 | [行相等的最少多米诺旋转](../../problems/minimum-domino-rotations-for-equal-row) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1005 | [K 次取反后最大化的数组和](../../problems/maximize-sum-of-array-after-k-negations) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 991 | [坏了的计算器](../../problems/broken-calculator) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 984 | [不含 AAA 或 BBB 的字符串](../../problems/string-without-aaa-or-bbb) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 976 | [三角形的最大周长](../../problems/largest-perimeter-triangle) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 969 | [煎饼排序](../../problems/pancake-sorting) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 955 | [删列造序 II](../../problems/delete-columns-to-make-sorted-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 954 | [二倍数对数组](../../problems/array-of-doubled-pairs) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 945 | [使数组唯一的最小增量](../../problems/minimum-increment-to-make-array-unique) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 942 | [增减字符串匹配](../../problems/di-string-match) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 936 | [戳印序列](../../problems/stamping-the-sequence) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[字符串](../string/README.md)] | Hard | +| 921 | [使括号有效的最少添加](../../problems/minimum-add-to-make-parentheses-valid) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 910 | [最小差值 II](../../problems/smallest-range-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 871 | [最低加油次数](../../problems/minimum-number-of-refueling-stops) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 861 | [翻转矩阵后的得分](../../problems/score-after-flipping-matrix) | [[贪心](../greedy/README.md)] [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 860 | [柠檬水找零](../../problems/lemonade-change) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 846 | [一手顺子](../../problems/hand-of-straights) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 807 | [保持城市天际线](../../problems/max-increase-to-keep-city-skyline) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 769 | [最多能完成排序的块](../../problems/max-chunks-to-make-sorted) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 768 | [最多能完成排序的块 II](../../problems/max-chunks-to-make-sorted-ii) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 767 | [重构字符串](../../problems/reorganize-string) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 763 | [划分字母区间](../../problems/partition-labels) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 757 | [设置交集大小至少为2](../../problems/set-intersection-size-at-least-two) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 738 | [单调递增的数字](../../problems/monotone-increasing-digits) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 714 | [买卖股票的最佳时机含手续费](../../problems/best-time-to-buy-and-sell-stock-with-transaction-fee) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 680 | [验证回文字符串 Ⅱ](../../problems/valid-palindrome-ii) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 670 | [最大交换](../../problems/maximum-swap) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 649 | [Dota2 参议院](../../problems/dota2-senate) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[字符串](../string/README.md)] | Medium | +| 646 | [最长数对链](../../problems/maximum-length-of-pair-chain) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 630 | [课程表 III](../../problems/course-schedule-iii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 611 | [有效三角形的个数](../../problems/valid-triangle-number) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 605 | [种花问题](../../problems/can-place-flowers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | +| 581 | [最短无序连续子数组](../../problems/shortest-unsorted-continuous-subarray) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 561 | [数组拆分 I](../../problems/array-partition-i) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[计数排序](../counting-sort/README.md)] [[排序](../sorting/README.md)] | Easy | +| 555 | [分割连接字符串](../../problems/split-concatenated-strings) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[贪心](../greedy/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | +| 517 | [超级洗衣机](../../problems/super-washing-machines) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Hard | +| 502 | [IPO](../../problems/ipo) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 484 | [寻找排列](../../problems/find-permutation) 🔒 | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 455 | [分发饼干](../../problems/assign-cookies) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 435 | [无重叠区间](../../problems/non-overlapping-intervals) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 420 | [强密码检验器](../../problems/strong-password-checker) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 409 | [最长回文串](../../problems/longest-palindrome) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 406 | [根据身高重建队列](../../problems/queue-reconstruction-by-height) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 402 | [移掉 K 位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 334 | [递增的三元子序列](../../problems/increasing-triplet-subsequence) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 330 | [按要求补齐数组](../../problems/patching-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Hard | +| 321 | [拼接最大数](../../problems/create-maximum-number) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 277 | [搜寻名人](../../problems/find-the-celebrity) 🔒 | [[贪心](../greedy/README.md)] [[图](../graph/README.md)] [[双指针](../two-pointers/README.md)] [[交互](../interactive/README.md)] | Medium | +| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 179 | [最大数](../../problems/largest-number) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 135 | [分发糖果](../../problems/candy) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Hard | +| 134 | [加油站](../../problems/gas-station) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 55 | [跳跃游戏](../../problems/jump-game) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 11 | [盛最多水的容器](../../problems/container-with-most-water) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 4dd7bbed7..38e4d93f0 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,152 +9,327 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1865 | [找出和为指定值的下标对](../../problems/finding-pairs-with-a-certain-sum) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | -| 1858 | [Longest Word With All Prefixes](../../problems/longest-word-with-all-prefixes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1852 | [Distinct Numbers in Each Subarray](../../problems/distinct-numbers-in-each-subarray) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1817 | [查找用户活跃分钟数](../../problems/finding-the-users-active-minutes) | [[哈希表](../hash-table/README.md)] | Medium | -| 1814 | [统计一个数组中好对子的数目](../../problems/count-nice-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1807 | [替换字符串中的括号内容](../../problems/evaluate-the-bracket-pairs-of-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1915 | [最美子字符串的数目](../../problems/number-of-wonderful-substrings) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1906 | [查询差绝对值的最小值](../../problems/minimum-absolute-difference-queries) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1897 | [重新分配字符使所有字符串都相等](../../problems/redistribute-characters-to-make-all-strings-equal) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1893 | [检查是否区域内所有整数都被覆盖](../../problems/check-if-all-the-integers-in-a-range-are-covered) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | +| 1876 | [长度为三且各字符不同的子字符串](../../problems/substrings-of-size-three-with-distinct-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | +| 1865 | [找出和为指定值的下标对](../../problems/finding-pairs-with-a-certain-sum) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] [[计数](../counting/README.md)] | Hard | +| 1852 | [每个子数组的数字种类数](../../problems/distinct-numbers-in-each-subarray) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1836 | [从未排序的链表中移除重复元素](../../problems/remove-duplicates-from-an-unsorted-linked-list) 🔒 | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 1832 | [判断句子是否为全字母句](../../problems/check-if-the-sentence-is-pangram) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1817 | [查找用户活跃分钟数](../../problems/finding-the-users-active-minutes) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1814 | [统计一个数组中好对子的数目](../../problems/count-nice-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] | Medium | +| 1807 | [替换字符串中的括号内容](../../problems/evaluate-the-bracket-pairs-of-a-string) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1805 | [字符串中不同整数的数目](../../problems/number-of-different-integers-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1804 | [实现 Trie (前缀树) II](../../problems/implement-trie-ii-prefix-tree) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1797 | [设计一个验证系统](../../problems/design-authentication-manager) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1781 | [所有子字符串美丽值之和](../../problems/sum-of-beauty-of-all-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1772 | [按受欢迎程度排列功能](../../problems/sort-features-by-popularity) 🔒 | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1748 | [唯一元素的和](../../problems/sum-of-unique-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1796 | [字符串中第二大的数字](../../problems/second-largest-digit-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1794 | [统计距离最小的子串对个数](../../problems/count-pairs-of-equal-substrings-with-minimum-difference) 🔒 | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1790 | [仅执行一次字符串交换能否使两个字符串相等](../../problems/check-if-one-string-swap-can-make-strings-equal) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1781 | [所有子字符串美丽值之和](../../problems/sum-of-beauty-of-all-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 1775 | [通过最少操作次数使数组的和相等](../../problems/equal-sum-arrays-with-minimum-number-of-operations) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 1772 | [按受欢迎程度排列功能](../../problems/sort-features-by-popularity) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1763 | [最长的美好子字符串](../../problems/longest-nice-substring) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | +| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1748 | [唯一元素的和](../../problems/sum-of-unique-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | +| 1743 | [从相邻元素对还原数组](../../problems/restore-the-array-from-adjacent-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1742 | [盒子中小球的最大数量](../../problems/maximum-number-of-balls-in-a-box) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] | Easy | +| 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1737 | [满足三条件之一需改变的最少字符数](../../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1726 | [同积元组](../../problems/tuple-with-same-product) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1679 | [K 和数对的最大数目](../../problems/max-number-of-k-sum-pairs) | [[哈希表](../hash-table/README.md)] | Medium | -| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1539 | [第 k 个缺失的正整数](../../problems/kth-missing-positive-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 1713 | [得到子序列的最少操作次数](../../problems/minimum-operations-to-make-a-subsequence) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1695 | [删除子数组的最大得分](../../problems/maximum-erasure-value) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1684 | [统计一致字符串的数目](../../problems/count-the-number-of-consistent-strings) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1679 | [K 和数对的最大数目](../../problems/max-number-of-k-sum-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1674 | [使数组互补的最少操作次数](../../problems/minimum-moves-to-make-array-complementary) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1660 | [纠正二叉树](../../problems/correct-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1657 | [确定两个字符串是否接近](../../problems/determine-if-two-strings-are-close) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] | Easy | +| 1650 | [二叉树的最近公共祖先 III](../../problems/lowest-common-ancestor-of-a-binary-tree-iii) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1636 | [按照频率将数组升序排序](../../problems/sort-array-by-increasing-frequency) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1624 | [两个相同字符之间的最长子字符串](../../problems/largest-substring-between-two-equal-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1554 | [只有一个不同字符的字符串](../../problems/strings-differ-by-one-character) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1546 | [和为目标值且不重叠的非空子数组的最大数目](../../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] | Easy | +| 1506 | [找到 N 叉树的根节点](../../problems/find-root-of-n-ary-tree) 🔒 | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 1496 | [判断路径是否相交](../../problems/path-crossing) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1418 | [点菜展示表](../../problems/display-table-of-food-orders-in-a-restaurant) | [[哈希表](../hash-table/README.md)] | Medium | -| 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1224 | [最大相等频率](../../problems/maximum-equal-frequency) | [[哈希表](../hash-table/README.md)] | Hard | -| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 1207 | [独一无二的出现次数](../../problems/unique-number-of-occurrences) | [[哈希表](../hash-table/README.md)] | Easy | -| 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1189 | [“气球” 的最大数量](../../problems/maximum-number-of-balloons) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 1178 | [猜字谜](../../problems/number-of-valid-words-for-each-puzzle) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1160 | [拼写单词](../../problems/find-words-that-can-be-formed-by-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1481 | [不同整数的最少数目](../../problems/least-number-of-unique-integers-after-k-removals) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1477 | [找两个和为目标值且不重叠的子数组](../../problems/find-two-non-overlapping-sub-arrays-each-with-target-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1460 | [通过翻转子数组使两个数组相等](../../problems/make-two-arrays-equal-by-reversing-sub-arrays) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1436 | [旅行终点站](../../problems/destination-city) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] | Medium | +| 1426 | [数元素](../../problems/counting-elements) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1418 | [点菜展示表](../../problems/display-table-of-food-orders-in-a-restaurant) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1400 | [构造 K 个回文字符串](../../problems/construct-k-palindrome-strings) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 1399 | [统计最大组的数目](../../problems/count-largest-group) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1394 | [找出数组中的幸运数](../../problems/find-lucky-integer-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | +| 1386 | [安排电影院座位](../../problems/cinema-seat-allocation) | [[贪心](../greedy/README.md)] [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1371 | [每个元音包含偶数次的最长子字符串](../../problems/find-the-longest-substring-containing-vowels-in-even-counts) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1358 | [包含所有三种字符的子字符串数目](../../problems/number-of-substrings-containing-all-three-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1357 | [每隔 n 个顾客打折](../../problems/apply-discount-every-n-orders) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1347 | [制造字母异位词的最小步骤数](../../problems/minimum-number-of-steps-to-make-two-strings-anagram) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1346 | [检查整数及其两倍数是否存在](../../problems/check-if-n-and-its-double-exist) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1345 | [跳跃游戏 IV](../../problems/jump-game-iv) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1331 | [数组序号转换](../../problems/rank-transform-of-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1325 | [删除给定值的叶子节点](../../problems/delete-leaves-with-a-given-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1282 | [用户分组](../../problems/group-the-people-given-the-group-size-they-belong-to) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1275 | [找出井字棋的获胜者](../../problems/find-winner-on-a-tic-tac-toe-game) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1258 | [近义词句子](../../problems/synonymous-sentences) 🔒 | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1257 | [最小公共区域](../../problems/smallest-common-region) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1248 | [统计「优美子数组」](../../problems/count-number-of-nice-subarrays) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1224 | [最大相等频率](../../problems/maximum-equal-frequency) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[计数](../counting/README.md)] | Easy | +| 1207 | [独一无二的出现次数](../../problems/unique-number-of-occurrences) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[计数](../counting/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1189 | [“气球” 的最大数量](../../problems/maximum-number-of-balloons) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1181 | [前后拼接](../../problems/before-and-after-puzzle) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1178 | [猜字谜](../../problems/number-of-valid-words-for-each-puzzle) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 1177 | [构建回文串检测](../../problems/can-make-palindrome-from-substring) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1172 | [餐盘栈](../../problems/dinner-plate-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1171 | [从链表中删去总和值为零的连续节点](../../problems/remove-zero-sum-consecutive-nodes-from-linked-list) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1169 | [查询无效交易](../../problems/invalid-transactions) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1165 | [单行键盘](../../problems/single-row-keyboard) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1160 | [拼写单词](../../problems/find-words-that-can-be-formed-by-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1153 | [字符串转化](../../problems/string-transforms-into-another-string) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1146 | [快照数组](../../problems/snapshot-array) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1138 | [字母板上的路径](../../problems/alphabet-board-path) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1133 | [最大唯一数](../../problems/largest-unique-number) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1078 | [Bigram 分词](../../problems/occurrences-after-bigram) | [[哈希表](../hash-table/README.md)] | Easy | -| 1072 | [按列翻转得到最大值等行数](../../problems/flip-columns-for-maximum-number-of-equal-rows) | [[哈希表](../hash-table/README.md)] | Medium | -| 1048 | [最长字符串链](../../problems/longest-string-chain) | [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1001 | [网格照明](../../problems/grid-illumination) | [[哈希表](../hash-table/README.md)] | Hard | -| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 974 | [和可被 K 整除的子数组](../../problems/subarray-sums-divisible-by-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1133 | [最大唯一数](../../problems/largest-unique-number) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1128 | [等价多米诺骨牌对的数量](../../problems/number-of-equivalent-domino-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | +| 1124 | [表现良好的最长时间段](../../problems/longest-well-performing-interval) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1122 | [数组的相对排序](../../problems/relative-sort-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数排序](../counting-sort/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 1072 | [按列翻转得到最大值等行数](../../problems/flip-columns-for-maximum-number-of-equal-rows) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1048 | [最长字符串链](../../problems/longest-string-chain) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 1027 | [最长等差数列](../../problems/longest-arithmetic-subsequence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1015 | [可被 K 整除的最小整数](../../problems/smallest-integer-divisible-by-k) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 1010 | [总持续时间可被 60 整除的歌曲](../../problems/pairs-of-songs-with-total-durations-divisible-by-60) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1001 | [网格照明](../../problems/grid-illumination) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 997 | [找到小镇的法官](../../problems/find-the-town-judge) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 982 | [按位与为零的三元组](../../problems/triples-with-bitwise-and-equal-to-zero) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 974 | [和可被 K 整除的子数组](../../problems/subarray-sums-divisible-by-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 970 | [强整数](../../problems/powerful-integers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 961 | [重复 N 次的元素](../../problems/n-repeated-element-in-size-2n-array) | [[哈希表](../hash-table/README.md)] | Easy | -| 957 | [N 天后的牢房](../../problems/prison-cells-after-n-days) | [[哈希表](../hash-table/README.md)] | Medium | -| 954 | [二倍数对数组](../../problems/array-of-doubled-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 953 | [验证外星语词典](../../problems/verifying-an-alien-dictionary) | [[哈希表](../hash-table/README.md)] | Easy | -| 939 | [最小面积矩形](../../problems/minimum-area-rectangle) | [[哈希表](../hash-table/README.md)] | Medium | -| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 884 | [两句话中的不常见单词](../../problems/uncommon-words-from-two-sentences) | [[哈希表](../hash-table/README.md)] | Easy | -| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[哈希表](../hash-table/README.md)] | Easy | -| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 771 | [宝石与石头](../../problems/jewels-and-stones) | [[哈希表](../hash-table/README.md)] | Easy | -| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | -| 760 | [找出变位映射](../../problems/find-anagram-mappings) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | -| 748 | [最短补全词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] | Easy | -| 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | -| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[堆](../heap/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 961 | [重复 N 次的元素](../../problems/n-repeated-element-in-size-2n-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 957 | [N 天后的牢房](../../problems/prison-cells-after-n-days) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 954 | [二倍数对数组](../../problems/array-of-doubled-pairs) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 953 | [验证外星语词典](../../problems/verifying-an-alien-dictionary) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 939 | [最小面积矩形](../../problems/minimum-area-rectangle) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 929 | [独特的电子邮件地址](../../problems/unique-email-addresses) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 923 | [三数之和的多种可能](../../problems/3sum-with-multiplicity) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 916 | [单词子集](../../problems/word-subsets) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Easy | +| 911 | [在线选举](../../problems/online-election) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 904 | [水果成篮](../../problems/fruit-into-baskets) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 884 | [两句话中的不常见单词](../../problems/uncommon-words-from-two-sentences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 859 | [亲密字符串](../../problems/buddy-strings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 846 | [一手顺子](../../problems/hand-of-straights) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 823 | [带因子的二叉树](../../problems/binary-trees-with-factors) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 822 | [翻转卡片游戏](../../problems/card-flipping-game) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 820 | [单词的压缩编码](../../problems/short-encoding-of-words) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 819 | [最常见的单词](../../problems/most-common-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 817 | [链表组件](../../problems/linked-list-components) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 792 | [匹配子序列的单词数](../../problems/number-of-matching-subsequences) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 791 | [自定义字符串排序](../../problems/custom-sort-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 771 | [宝石与石头](../../problems/jewels-and-stones) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 767 | [重构字符串](../../problems/reorganize-string) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 763 | [划分字母区间](../../problems/partition-labels) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 760 | [找出变位映射](../../problems/find-anagram-mappings) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 748 | [最短补全词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 740 | [删除并获得点数](../../problems/delete-and-earn) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | +| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[随机化](../randomized/README.md)] | Hard | +| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | +| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | +| 697 | [数组的度](../../problems/degree-of-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Medium | +| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 676 | [实现一个魔法字典](../../problems/implement-magic-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 648 | [单词替换](../../problems/replace-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 645 | [错误的集合](../../problems/set-mismatch) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 624 | [数组列表中的最大距离](../../problems/maximum-distance-in-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 599 | [两个列表的最小索引总和](../../problems/minimum-index-sum-of-two-lists) | [[哈希表](../hash-table/README.md)] | Easy | -| 594 | [最长和谐子序列](../../problems/longest-harmonious-subsequence) | [[哈希表](../hash-table/README.md)] | Easy | -| 575 | [分糖果](../../problems/distribute-candies) | [[哈希表](../hash-table/README.md)] | Easy | -| 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 554 | [砖墙](../../problems/brick-wall) | [[哈希表](../hash-table/README.md)] | Medium | -| 535 | [TinyURL 的加密与解密](../../problems/encode-and-decode-tinyurl) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 525 | [连续数组](../../problems/contiguous-array) | [[哈希表](../hash-table/README.md)] | Medium | -| 508 | [出现次数最多的子树元素和](../../problems/most-frequent-subtree-sum) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 500 | [键盘行](../../problems/keyboard-row) | [[哈希表](../hash-table/README.md)] | Easy | -| 463 | [岛屿的周长](../../problems/island-perimeter) | [[哈希表](../hash-table/README.md)] | Easy | -| 454 | [四数相加 II](../../problems/4sum-ii) | [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 447 | [回旋镖的数量](../../problems/number-of-boomerangs) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 438 | [找到字符串中所有字母异位词](../../problems/find-all-anagrams-in-a-string) | [[哈希表](../hash-table/README.md)] | Medium | -| 409 | [最长回文串](../../problems/longest-palindrome) | [[哈希表](../hash-table/README.md)] | Easy | -| 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 380 | [O(1) 时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 677 | [键值映射](../../problems/map-sum-pairs) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 676 | [实现一个魔法字典](../../problems/implement-magic-dictionary) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 653 | [两数之和 IV - 输入 BST](../../problems/two-sum-iv-input-is-a-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 648 | [单词替换](../../problems/replace-words) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 645 | [错误的集合](../../problems/set-mismatch) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 616 | [给字符串添加加粗标签](../../problems/add-bold-tag-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[迭代器](../iterator/README.md)] | Easy | +| 599 | [两个列表的最小索引总和](../../problems/minimum-index-sum-of-two-lists) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 594 | [最长和谐子序列](../../problems/longest-harmonious-subsequence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 588 | [设计内存文件系统](../../problems/design-in-memory-file-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 575 | [分糖果](../../problems/distribute-candies) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 567 | [字符串的排列](../../problems/permutation-in-string) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 554 | [砖墙](../../problems/brick-wall) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 535 | [TinyURL 的加密与解密](../../problems/encode-and-decode-tinyurl) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Medium | +| 533 | [孤独像素 II](../../problems/lonely-pixel-ii) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 531 | [孤独像素 I](../../problems/lonely-pixel-i) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 525 | [连续数组](../../problems/contiguous-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 523 | [连续的子数组和](../../problems/continuous-subarray-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 522 | [最长特殊序列 II](../../problems/longest-uncommon-subsequence-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 519 | [随机翻转矩阵](../../problems/random-flip-matrix) | [[水塘抽样](../reservoir-sampling/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 508 | [出现次数最多的子树元素和](../../problems/most-frequent-subtree-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 500 | [键盘行](../../problems/keyboard-row) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 496 | [下一个更大元素 I](../../problems/next-greater-element-i) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[单调栈](../monotonic-stack/README.md)] | Easy | +| 491 | [递增子序列](../../problems/increasing-subsequences) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 480 | [滑动窗口中位数](../../problems/sliding-window-median) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 460 | [LFU 缓存](../../problems/lfu-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Hard | +| 457 | [环形数组是否存在循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 454 | [四数相加 II](../../problems/4sum-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 448 | [找到所有数组中消失的数字](../../problems/find-all-numbers-disappeared-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 447 | [回旋镖的数量](../../problems/number-of-boomerangs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 442 | [数组中重复的数据](../../problems/find-all-duplicates-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 438 | [找到字符串中所有字母异位词](../../problems/find-all-anagrams-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 433 | [最小基因变化](../../problems/minimum-genetic-mutation) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Hard | +| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 423 | [从英文中重建数字](../../problems/reconstruct-original-digits-from-english) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 421 | [数组中两个数的最大异或值](../../problems/maximum-xor-of-two-numbers-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 409 | [最长回文串](../../problems/longest-palindrome) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 398 | [随机数索引](../../problems/random-pick-index) | [[水塘抽样](../reservoir-sampling/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[队列](../queue/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 383 | [赎金信](../../problems/ransom-note) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Hard | +| 380 | [O(1) 时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 362 | [敲击计数器](../../problems/design-hit-counter) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 359 | [日志速率限制器](../../problems/logger-rate-limiter) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 356 | [直线镜像](../../problems/line-reflection) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | -| 325 | [和等于 k 的最长子数组长度](../../problems/maximum-size-subarray-sum-equals-k) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | -| 311 | [稀疏矩阵的乘法](../../problems/sparse-matrix-multiplication) 🔒 | [[哈希表](../hash-table/README.md)] | Medium | -| 299 | [猜数字游戏](../../problems/bulls-and-cows) | [[哈希表](../hash-table/README.md)] | Medium | -| 290 | [单词规律](../../problems/word-pattern) | [[哈希表](../hash-table/README.md)] | Easy | -| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 274 | [H 指数](../../problems/h-index) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 266 | [回文排列](../../problems/palindrome-permutation) 🔒 | [[哈希表](../hash-table/README.md)] | Easy | -| 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 246 | [中心对称数](../../problems/strobogrammatic-number) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 242 | [有效的字母异位词](../../problems/valid-anagram) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 219 | [存在重复元素 II](../../problems/contains-duplicate-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 217 | [存在重复元素](../../problems/contains-duplicate) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 205 | [同构字符串](../../problems/isomorphic-strings) | [[哈希表](../hash-table/README.md)] | Easy | -| 204 | [计数质数](../../problems/count-primes) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 202 | [快乐数](../../problems/happy-number) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 187 | [重复的DNA序列](../../problems/repeated-dna-sequences) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 356 | [直线镜像](../../problems/line-reflection) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 355 | [设计推特](../../problems/design-twitter) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 348 | [设计井字棋](../../problems/design-tic-tac-toe) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 325 | [和等于 k 的最长子数组长度](../../problems/maximum-size-subarray-sum-equals-k) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 313 | [超级丑数](../../problems/super-ugly-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 311 | [稀疏矩阵的乘法](../../problems/sparse-matrix-multiplication) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 299 | [猜数字游戏](../../problems/bulls-and-cows) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 291 | [单词规律 II](../../problems/word-pattern-ii) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 290 | [单词规律](../../problems/word-pattern) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 268 | [丢失的数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 266 | [回文排列](../../problems/palindrome-permutation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 264 | [丑数 II](../../problems/ugly-number-ii) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 246 | [中心对称数](../../problems/strobogrammatic-number) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 242 | [有效的字母异位词](../../problems/valid-anagram) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 229 | [求众数 II](../../problems/majority-element-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 219 | [存在重复元素 II](../../problems/contains-duplicate-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | +| 217 | [存在重复元素](../../problems/contains-duplicate) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 205 | [同构字符串](../../problems/isomorphic-strings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 202 | [快乐数](../../problems/happy-number) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 187 | [重复的DNA序列](../../problems/repeated-dna-sequences) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | +| 169 | [多数元素](../../problems/majority-element) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | +| 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 141 | [环形链表](../../problems/linked-list-cycle) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 140 | [单词拆分 II](../../problems/word-break-ii) | [[字典树](../trie/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 139 | [单词拆分](../../problems/word-break) | [[字典树](../trie/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 138 | [复制带随机指针的链表](../../problems/copy-list-with-random-pointer) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 136 | [只出现一次的数字](../../problems/single-number) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 37 | [解数独](../../problems/sudoku-solver) | [[哈希表](../hash-table/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 36 | [有效的数独](../../problems/valid-sudoku) | [[哈希表](../hash-table/README.md)] | Medium | -| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 133 | [克隆图](../../problems/clone-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 128 | [最长连续序列](../../problems/longest-consecutive-sequence) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 127 | [单词接龙](../../problems/word-ladder) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 73 | [矩阵置零](../../problems/set-matrix-zeroes) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 41 | [缺失的第一个正数](../../problems/first-missing-positive) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | +| 36 | [有效的数独](../../problems/valid-sudoku) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1 | [两数之和](../../problems/two-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | diff --git a/tag/heap/README.md b/tag/heap/README.md index 64eee7cc0..39b134930 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -9,51 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1882 | [使用服务器处理任务](../../problems/process-tasks-using-servers) | [[堆](../heap/README.md)] | Medium | -| 1845 | [座位预约管理系统](../../problems/seat-reservation-manager) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Medium | -| 1834 | [单线程 CPU](../../problems/single-threaded-cpu) | [[堆](../heap/README.md)] | Medium | -| 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] | Hard | -| 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 1792 | [最大平均通过率](../../problems/maximum-average-pass-ratio) | [[堆](../heap/README.md)] | Medium | -| 1760 | [袋子里最少数目的球](../../problems/minimum-limit-of-balls-in-a-bag) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1753 | [移除石子的最大得分](../../problems/maximum-score-from-removing-stones) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | -| 1705 | [吃苹果的最大数目](../../problems/maximum-number-of-eaten-apples) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | -| 1642 | [可以到达的最远建筑](../../problems/furthest-building-you-can-reach) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1439 | [有序矩阵中的第 k 个最小数组和](../../problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | [[堆](../heap/README.md)] | Hard | -| 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] | Medium | -| 1046 | [最后一块石头的重量](../../problems/last-stone-weight) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Easy | -| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 882 | [细分图中的可到达结点](../../problems/reachable-nodes-in-subdivided-graph) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 871 | [最低加油次数](../../problems/minimum-number-of-refueling-stops) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 864 | [获取所有钥匙的最短路径](../../problems/shortest-path-to-get-all-keys) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[堆](../heap/README.md)] | Hard | -| 818 | [赛车](../../problems/race-car) | [[堆](../heap/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | -| 743 | [网络延迟时间](../../problems/network-delay-time) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[堆](../heap/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Easy | -| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[堆](../heap/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 502 | [IPO](../../problems/ipo) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] | Hard | -| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[堆](../heap/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Hard | -| 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[堆](../heap/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 373 | [查找和最小的K对数字](../../problems/find-k-pairs-with-smallest-sums) | [[堆](../heap/README.md)] | Medium | -| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 355 | [设计推特](../../problems/design-twitter) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[堆](../heap/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 313 | [超级丑数](../../problems/super-ugly-number) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | -| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[堆](../heap/README.md)] [[设计](../design/README.md)] | Hard | -| 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | -| 215 | [数组中的第K个最大元素](../../problems/kth-largest-element-in-an-array) | [[堆](../heap/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md index 3d3455b3b..35972eeea 100644 --- a/tag/line-sweep/README.md +++ b/tag/line-sweep/README.md @@ -9,12 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1871 | [跳跃游戏 VII](../../problems/jump-game-vii) | [[贪心算法](../greedy/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1852 | [Distinct Numbers in Each Subarray](../../problems/distinct-numbers-in-each-subarray) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1851 | [包含每个查询的最小区间](../../problems/minimum-interval-to-include-each-query) | [[Line Sweep](../line-sweep/README.md)] | Hard | -| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | -| 391 | [完美矩形](../../problems/perfect-rectangle) | [[Line Sweep](../line-sweep/README.md)] | Hard | -| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | +| 1851 | [包含每个查询的最小区间](../../problems/minimum-interval-to-include-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[扫描线](../line-sweep/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[扫描线](../line-sweep/README.md)] | Hard | +| 391 | [完美矩形](../../problems/perfect-rectangle) | [[数组](../array/README.md)] [[扫描线](../line-sweep/README.md)] | Hard | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[扫描线](../line-sweep/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index 408e55d1d..0bfa59a4d 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -9,47 +9,61 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1836 | [Remove Duplicates From an Unsorted Linked List](../../problems/remove-duplicates-from-an-unsorted-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Medium | -| 1721 | [交换链表中的节点](../../problems/swapping-nodes-in-a-linked-list) | [[链表](../linked-list/README.md)] | Medium | -| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 1836 | [从未排序的链表中移除重复元素](../../problems/remove-duplicates-from-an-unsorted-linked-list) 🔒 | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 1721 | [交换链表中的节点](../../problems/swapping-nodes-in-a-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] | Medium | | 1669 | [合并两个链表](../../problems/merge-in-between-linked-lists) | [[链表](../linked-list/README.md)] | Medium | -| 1634 | [求两个多项式链表的和](../../problems/add-two-polynomials-represented-as-linked-lists) 🔒 | [[链表](../linked-list/README.md)] | Medium | +| 1634 | [求两个多项式链表的和](../../problems/add-two-polynomials-represented-as-linked-lists) 🔒 | [[链表](../linked-list/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1474 | [删除链表 M 个节点之后的 N 个节点](../../problems/delete-n-nodes-after-m-nodes-of-a-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Easy | -| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[位运算](../bit-manipulation/README.md)] [[链表](../linked-list/README.md)] | Easy | -| 1171 | [从链表中删去总和值为零的连续节点](../../problems/remove-zero-sum-consecutive-nodes-from-linked-list) | [[链表](../linked-list/README.md)] | Medium | -| 1019 | [链表中的下一个更大节点](../../problems/next-greater-node-in-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 876 | [链表的中间结点](../../problems/middle-of-the-linked-list) | [[链表](../linked-list/README.md)] | Easy | -| 817 | [链表组件](../../problems/linked-list-components) | [[链表](../linked-list/README.md)] | Medium | +| 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Easy | +| 1265 | [逆序打印不可变链表](../../problems/print-immutable-linked-list-in-reverse) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1206 | [设计跳表](../../problems/design-skiplist) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Hard | +| 1171 | [从链表中删去总和值为零的连续节点](../../problems/remove-zero-sum-consecutive-nodes-from-linked-list) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 1019 | [链表中的下一个更大节点](../../problems/next-greater-node-in-linked-list) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 876 | [链表的中间结点](../../problems/middle-of-the-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 817 | [链表组件](../../problems/linked-list-components) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | | 725 | [分隔链表](../../problems/split-linked-list-in-parts) | [[链表](../linked-list/README.md)] | Medium | +| 716 | [最大栈](../../problems/max-stack) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] [[有序集合](../ordered-set/README.md)] | Easy | | 708 | [循环有序列表的插入](../../problems/insert-into-a-sorted-circular-linked-list) 🔒 | [[链表](../linked-list/README.md)] | Medium | | 707 | [设计链表](../../problems/design-linked-list) | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 445 | [两数相加 II](../../problems/add-two-numbers-ii) | [[链表](../linked-list/README.md)] | Medium | -| 430 | [扁平化多级双向链表](../../problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | +| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | +| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 460 | [LFU 缓存](../../problems/lfu-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Hard | +| 445 | [两数相加 II](../../problems/add-two-numbers-ii) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | +| 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Hard | +| 430 | [扁平化多级双向链表](../../problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 382 | [链表随机节点](../../problems/linked-list-random-node) | [[水塘抽样](../reservoir-sampling/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | +| 355 | [设计推特](../../problems/design-twitter) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 328 | [奇偶链表](../../problems/odd-even-linked-list) | [[链表](../linked-list/README.md)] | Medium | | 237 | [删除链表中的节点](../../problems/delete-node-in-a-linked-list) | [[链表](../linked-list/README.md)] | Easy | -| 234 | [回文链表](../../problems/palindrome-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 206 | [反转链表](../../problems/reverse-linked-list) | [[链表](../linked-list/README.md)] | Easy | -| 203 | [移除链表元素](../../problems/remove-linked-list-elements) | [[链表](../linked-list/README.md)] | Easy | -| 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[链表](../linked-list/README.md)] | Easy | -| 148 | [排序链表](../../problems/sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 143 | [重排链表](../../problems/reorder-list) | [[链表](../linked-list/README.md)] | Medium | -| 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 141 | [环形链表](../../problems/linked-list-cycle) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 234 | [回文链表](../../problems/palindrome-linked-list) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 206 | [反转链表](../../problems/reverse-linked-list) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Easy | +| 203 | [移除链表元素](../../problems/remove-linked-list-elements) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Easy | +| 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 148 | [排序链表](../../problems/sort-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[分治](../divide-and-conquer/README.md)] [[排序](../sorting/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[链表](../linked-list/README.md)] [[排序](../sorting/README.md)] | Medium | +| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 143 | [重排链表](../../problems/reorder-list) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 141 | [环形链表](../../problems/linked-list-cycle) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 138 | [复制带随机指针的链表](../../problems/copy-list-with-random-pointer) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 92 | [反转链表 II](../../problems/reverse-linked-list-ii) | [[链表](../linked-list/README.md)] | Medium | | 86 | [分隔链表](../../problems/partition-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 83 | [删除排序链表中的重复元素](../../problems/remove-duplicates-from-sorted-list) | [[链表](../linked-list/README.md)] | Easy | -| 82 | [删除排序链表中的重复元素 II](../../problems/remove-duplicates-from-sorted-list-ii) | [[链表](../linked-list/README.md)] | Medium | +| 82 | [删除排序链表中的重复元素 II](../../problems/remove-duplicates-from-sorted-list-ii) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 61 | [旋转链表](../../problems/rotate-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 25 | [K 个一组翻转链表](../../problems/reverse-nodes-in-k-group) | [[链表](../linked-list/README.md)] | Hard | +| 25 | [K 个一组翻转链表](../../problems/reverse-nodes-in-k-group) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Hard | | 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[堆](../heap/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | +| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Easy | | 19 | [删除链表的倒数第 N 个结点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 848b07aa2..e7888d8a3 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,217 +9,311 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1884 | [鸡蛋掉落-两枚鸡蛋](../../problems/egg-drop-with-2-eggs-and-n-floors) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1878 | [矩阵中最大的三个菱形和](../../problems/get-biggest-three-rhombus-sums-in-a-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1870 | [准时到达的列车最小时速](../../problems/minimum-speed-to-arrive-on-time) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1862 | [向下取整数对和](../../problems/sum-of-floored-pairs) | [[数学](../math/README.md)] | Hard | -| 1860 | [增长的内存泄露](../../problems/incremental-memory-leak) | [[数学](../math/README.md)] | Medium | -| 1837 | [K 进制表示下的各位数字总和](../../problems/sum-of-digits-in-base-k) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | -| 1835 | [所有数对按位与结果的异或和](../../problems/find-xor-sum-of-all-pairs-bitwise-and) | [[数学](../math/README.md)] | Hard | -| 1830 | [使字符串有序的最少操作次数](../../problems/minimum-number-of-operations-to-make-string-sorted) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 1828 | [统计一个圆中点的数目](../../problems/queries-on-number-of-points-inside-a-circle) | [[数学](../math/README.md)] | Medium | -| 1822 | [数组元素积的符号](../../problems/sign-of-the-product-of-an-array) | [[数学](../math/README.md)] | Easy | -| 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数学](../math/README.md)] | Hard | -| 1808 | [好因子的最大数目](../../problems/maximize-number-of-nice-divisors) | [[数学](../math/README.md)] | Hard | -| 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1776 | [车队 II](../../problems/car-fleet-ii) | [[数学](../math/README.md)] | Hard | +| 1922 | [统计好数字的数目](../../problems/count-good-numbers) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1908 | [Game of Nim](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1904 | [你完成的完整对局数](../../problems/the-number-of-full-rounds-you-have-played) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1903 | [字符串中的最大奇数](../../problems/largest-odd-number-in-string) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1896 | [反转表达式值的最少操作次数](../../problems/minimum-cost-to-change-the-final-value-of-expression) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1884 | [鸡蛋掉落-两枚鸡蛋](../../problems/egg-drop-with-2-eggs-and-n-floors) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1878 | [矩阵中最大的三个菱形和](../../problems/get-biggest-three-rhombus-sums-in-a-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1872 | [石子游戏 VIII](../../problems/stone-game-viii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 1866 | [恰有 K 根木棍可以看到的排列数目](../../problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1862 | [向下取整数对和](../../problems/sum-of-floored-pairs) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 1840 | [最高建筑高度](../../problems/maximum-building-height) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1837 | [K 进制表示下的各位数字总和](../../problems/sum-of-digits-in-base-k) | [[数学](../math/README.md)] | Easy | +| 1835 | [所有数对按位与结果的异或和](../../problems/find-xor-sum-of-all-pairs-bitwise-and) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1830 | [使字符串有序的最少操作次数](../../problems/minimum-number-of-operations-to-make-string-sorted) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1828 | [统计一个圆中点的数目](../../problems/queries-on-number-of-points-inside-a-circle) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1822 | [数组元素积的符号](../../problems/sign-of-the-product-of-an-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Hard | +| 1814 | [统计一个数组中好对子的数目](../../problems/count-nice-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] | Medium | +| 1812 | [判断国际象棋棋盘中一个格子的颜色](../../problems/determine-color-of-a-chessboard-square) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1808 | [好因子的最大数目](../../problems/maximize-number-of-nice-divisors) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | +| 1806 | [还原排列的最少操作步数](../../problems/minimum-number-of-operations-to-reinitialize-a-permutation) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] [[数论](../number-theory/README.md)] | Hard | +| 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[数学](../math/README.md)] | Medium | +| 1776 | [车队 II](../../problems/car-fleet-ii) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[单调栈](../monotonic-stack/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | -| 1753 | [移除石子的最大得分](../../problems/maximum-score-from-removing-stones) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | -| 1744 | [你能在你最喜欢的那天吃到你最喜欢的糖果吗?](../../problems/can-you-eat-your-favorite-candy-on-your-favorite-day) | [[数学](../math/README.md)] | Medium | -| 1739 | [放置盒子](../../problems/building-boxes) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1735 | [生成乘积数组的方案数](../../problems/count-ways-to-make-array-with-product) | [[数学](../math/README.md)] | Hard | -| 1716 | [计算力扣银行的钱](../../problems/calculate-money-in-leetcode-bank) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Easy | -| 1685 | [有序数组中差绝对值之和](../../problems/sum-of-absolute-differences-in-a-sorted-array) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 1680 | [连接连续二进制数字](../../problems/concatenation-of-consecutive-binary-numbers) | [[数学](../math/README.md)] | Medium | -| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | -| 1641 | [统计字典序元音字符串的数目](../../problems/count-sorted-vowel-strings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1627 | [带阈值的图连通性](../../problems/graph-connectivity-with-threshold) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | -| 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[数学](../math/README.md)] | Hard | -| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 1759 | [统计同构子字符串的数目](../../problems/count-number-of-homogenous-substrings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1753 | [移除石子的最大得分](../../problems/maximum-score-from-removing-stones) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1742 | [盒子中小球的最大数量](../../problems/maximum-number-of-balls-in-a-box) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] | Easy | +| 1739 | [放置盒子](../../problems/building-boxes) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1735 | [生成乘积数组的方案数](../../problems/count-ways-to-make-array-with-product) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1728 | [猫和老鼠 II](../../problems/cat-and-mouse-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 1716 | [计算力扣银行的钱](../../problems/calculate-money-in-leetcode-bank) | [[数学](../math/README.md)] | Easy | +| 1690 | [石子游戏 VII](../../problems/stone-game-vii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1688 | [比赛中的配对次数](../../problems/count-of-matches-in-tournament) | [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1686 | [石子游戏 VI](../../problems/stone-game-vi) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1685 | [有序数组中差绝对值之和](../../problems/sum-of-absolute-differences-in-a-sorted-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1680 | [连接连续二进制数字](../../problems/concatenation-of-consecutive-binary-numbers) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1643 | [第 K 条最小指令](../../problems/kth-smallest-instructions) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1634 | [求两个多项式链表的和](../../problems/add-two-polynomials-represented-as-linked-lists) 🔒 | [[链表](../linked-list/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[数学](../math/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1627 | [带阈值的图连通性](../../problems/graph-connectivity-with-threshold) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数学](../math/README.md)] | Hard | +| 1621 | [大小为 K 的不重叠线段的数目](../../problems/number-of-sets-of-k-non-overlapping-line-segments) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1573 | [分割字符串的方案数](../../problems/number-of-ways-to-split-a-string) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1563 | [石子游戏 V](../../problems/stone-game-v) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 1561 | [你可以获得的最大硬币数目](../../problems/maximum-number-of-coins-you-can-get) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] [[排序](../sorting/README.md)] | Medium | | 1551 | [使数组中所有元素相等的最小操作数](../../problems/minimum-operations-to-make-array-equal) | [[数学](../math/README.md)] | Medium | -| 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1538 | [找出隐藏数组中出现次数最多的元素](../../problems/guess-the-majority-in-a-hidden-array) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1523 | [在区间范围内统计奇数数目](../../problems/count-odd-numbers-in-an-interval-range) | [[数学](../math/README.md)] | Easy | +| 1518 | [换酒问题](../../problems/water-bottles) | [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1515 | [服务中心的最佳位置](../../problems/best-position-for-a-service-centre) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Hard | | 1513 | [仅含 1 的子串数](../../problems/number-of-substrings-with-only-1s) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] | Easy | +| 1510 | [石子游戏 IV](../../problems/stone-game-iv) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 1493 | [删掉一个元素以后全为 1 的最长子数组](../../problems/longest-subarray-of-1s-after-deleting-one-element) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1492 | [n 的第 k 个因子](../../problems/the-kth-factor-of-n) | [[数学](../math/README.md)] | Medium | -| 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1486 | [数组异或操作](../../problems/xor-operation-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | +| 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[组合数学](../combinatorics/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Hard | +| 1453 | [圆形靶内的最大飞镖数量](../../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] | Medium | -| 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1427 | [字符串的左右移](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 1390 | [四因数](../../problems/four-divisors) | [[数学](../math/README.md)] | Medium | -| 1363 | [形成三的最大倍数](../../problems/largest-multiple-of-three) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1432 | [改变一个整数能得到的最大差值](../../problems/max-difference-you-can-get-from-changing-an-integer) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 1427 | [字符串的左右移](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1406 | [石子游戏 III](../../problems/stone-game-iii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 1401 | [圆和矩形是否有重叠](../../problems/circle-and-rectangle-overlapping) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | +| 1399 | [统计最大组的数目](../../problems/count-largest-group) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 1390 | [四因数](../../problems/four-divisors) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1362 | [最接近的因数](../../problems/closest-divisors) | [[数学](../math/README.md)] | Medium | -| 1359 | [有效的快递序列数目](../../problems/count-all-valid-pickup-and-delivery-options) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1360 | [日期之间隔几天](../../problems/number-of-days-between-two-dates) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1359 | [有效的快递序列数目](../../problems/count-all-valid-pickup-and-delivery-options) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[数据流](../data-stream/README.md)] | Medium | | 1344 | [时钟指针的夹角](../../problems/angle-between-hands-of-a-clock) | [[数学](../math/README.md)] | Medium | -| 1330 | [翻转子数组得到最大的数组值](../../problems/reverse-subarray-to-maximize-array-value) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | -| 1323 | [6 和 9 组成的最大数字](../../problems/maximum-69-number) | [[数学](../math/README.md)] | Easy | +| 1342 | [将数字变成 0 的操作次数](../../problems/number-of-steps-to-reduce-a-number-to-zero) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | +| 1330 | [翻转子数组得到最大的数组值](../../problems/reverse-subarray-to-maximize-array-value) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1323 | [6 和 9 组成的最大数字](../../problems/maximum-69-number) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Easy | | 1317 | [将整数转换为两个无零整数的和](../../problems/convert-integer-to-the-sum-of-two-no-zero-integers) | [[数学](../math/README.md)] | Easy | -| 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 1304 | [和为零的N个唯一整数](../../problems/find-n-unique-integers-sum-up-to-zero) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1290 | [二进制链表转整数](../../problems/convert-binary-number-in-a-linked-list-to-integer) | [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Easy | | 1281 | [整数的各位积和之差](../../problems/subtract-the-product-and-sum-of-digits-of-an-integer) | [[数学](../math/README.md)] | Easy | -| 1276 | [不浪费原料的汉堡制作方案](../../problems/number-of-burgers-with-no-waste-of-ingredients) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 1272 | [删除区间](../../problems/remove-interval) 🔒 | [[数学](../math/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | +| 1276 | [不浪费原料的汉堡制作方案](../../problems/number-of-burgers-with-no-waste-of-ingredients) | [[数学](../math/README.md)] | Medium | | 1271 | [十六进制魔术数字](../../problems/hexspeak) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1266 | [访问所有点的最小时间](../../problems/minimum-time-visiting-all-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1259 | [不相交的握手](../../problems/handshakes-that-dont-cross) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1256 | [加密数字](../../problems/encode-number) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | -| 1253 | [重构 2 行二进制矩阵](../../problems/reconstruct-a-2-row-binary-matrix) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 1250 | [检查「好数组」](../../problems/check-if-it-is-a-good-array) | [[数学](../math/README.md)] | Hard | -| 1238 | [循环码排列](../../problems/circular-permutation-in-binary-representation) | [[数学](../math/README.md)] | Medium | -| 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1256 | [加密数字](../../problems/encode-number) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1252 | [奇数值单元格的数目](../../problems/cells-with-odd-values-in-a-matrix) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1250 | [检查「好数组」](../../problems/check-if-it-is-a-good-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[数论](../number-theory/README.md)] | Hard | +| 1248 | [统计「优美子数组」](../../problems/count-number-of-nice-subarrays) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1247 | [交换字符使得字符串相同](../../problems/minimum-swaps-to-make-strings-equal) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1238 | [循环码排列](../../problems/circular-permutation-in-binary-representation) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Medium | | 1232 | [缀点成线](../../problems/check-if-it-is-a-straight-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 1230 | [抛掷硬币](../../problems/toss-strange-coins) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1228 | [等差数列中缺失的数字](../../problems/missing-number-in-arithmetic-progression) 🔒 | [[数学](../math/README.md)] | Easy | -| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1218 | [最长定差子序列](../../problems/longest-arithmetic-subsequence-of-given-difference) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1217 | [玩筹码](../../problems/minimum-cost-to-move-chips-to-the-same-position) | [[贪心算法](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1199 | [建造街区的最短时间](../../problems/minimum-time-to-build-blocks) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1183 | [矩阵中 1 的最大数量](../../problems/maximum-number-of-ones) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | +| 1230 | [抛掷硬币](../../problems/toss-strange-coins) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 1228 | [等差数列中缺失的数字](../../problems/missing-number-in-arithmetic-progression) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 1217 | [玩筹码](../../problems/minimum-cost-to-move-chips-to-the-same-position) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[数论](../number-theory/README.md)] | Medium | +| 1199 | [建造街区的最短时间](../../problems/minimum-time-to-build-blocks) 🔒 | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1185 | [一周中的第几天](../../problems/day-of-the-week) | [[数学](../math/README.md)] | Easy | | 1180 | [统计只含单一字母的子串](../../problems/count-substrings-with-only-one-distinct-letter) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 1175 | [质数排列](../../problems/prime-arrangements) | [[数学](../math/README.md)] | Easy | -| 1154 | [一年中的第几天](../../problems/day-of-the-year) | [[数学](../math/README.md)] | Easy | +| 1154 | [一年中的第几天](../../problems/day-of-the-year) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1140 | [石子游戏 II](../../problems/stone-game-ii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 1134 | [阿姆斯特朗数](../../problems/armstrong-number) 🔒 | [[数学](../math/README.md)] | Easy | -| 1131 | [绝对值表达式的最大值](../../problems/maximum-of-absolute-value-expression) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | -| 1121 | [将数组分成几个递增序列](../../problems/divide-array-into-increasing-sequences) 🔒 | [[数学](../math/README.md)] | Hard | -| 1109 | [航班预订统计](../../problems/corporate-flight-bookings) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1104 | [二叉树寻路](../../problems/path-in-zigzag-labelled-binary-tree) | [[树](../tree/README.md)] [[数学](../math/README.md)] | Medium | -| 1103 | [分糖果 II](../../problems/distribute-candies-to-people) | [[数学](../math/README.md)] | Easy | -| 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1088 | [易混淆数 II](../../problems/confusing-number-ii) 🔒 | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1073 | [负二进制数相加](../../problems/adding-two-negabinary-numbers) | [[数学](../math/README.md)] | Medium | +| 1131 | [绝对值表达式的最大值](../../problems/maximum-of-absolute-value-expression) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1118 | [一月有多少天](../../problems/number-of-days-in-a-month) 🔒 | [[数学](../math/README.md)] | Easy | +| 1104 | [二叉树寻路](../../problems/path-in-zigzag-labelled-binary-tree) | [[树](../tree/README.md)] [[数学](../math/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1103 | [分糖果 II](../../problems/distribute-candies-to-people) | [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 1088 | [易混淆数 II](../../problems/confusing-number-ii) 🔒 | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 1085 | [最小元素各数位之和](../../problems/sum-of-digits-in-the-minimum-number) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1073 | [负二进制数相加](../../problems/adding-two-negabinary-numbers) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 1071 | [字符串的最大公因子](../../problems/greatest-common-divisor-of-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 1067 | [范围内的数字计数](../../problems/digit-count-in-range) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 1056 | [易混淆数](../../problems/confusing-number) 🔒 | [[数学](../math/README.md)] | Easy | -| 1041 | [困于环中的机器人](../../problems/robot-bounded-in-circle) | [[数学](../math/README.md)] | Medium | -| 1037 | [有效的回旋镖](../../problems/valid-boomerang) | [[数学](../math/README.md)] | Easy | -| 1025 | [除数博弈](../../problems/divisor-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 1041 | [困于环中的机器人](../../problems/robot-bounded-in-circle) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1040 | [移动石子直到连续 II](../../problems/moving-stones-until-consecutive-ii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1037 | [有效的回旋镖](../../problems/valid-boomerang) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | +| 1033 | [移动石子直到连续](../../problems/moving-stones-until-consecutive) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Easy | +| 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1025 | [除数博弈](../../problems/divisor-game) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Easy | | 1017 | [负二进制转换](../../problems/convert-to-base-2) | [[数学](../math/README.md)] | Medium | -| 1015 | [可被 K 整除的最小整数](../../problems/smallest-integer-divisible-by-k) | [[数学](../math/README.md)] | Medium | +| 1015 | [可被 K 整除的最小整数](../../problems/smallest-integer-divisible-by-k) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 1012 | [至少有 1 位重复的数字](../../problems/numbers-with-repeated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1009 | [十进制整数的反码](../../problems/complement-of-base-10-integer) | [[数学](../math/README.md)] | Easy | -| 1006 | [笨阶乘](../../problems/clumsy-factorial) | [[数学](../math/README.md)] | Medium | -| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[图](../graph/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 991 | [坏了的计算器](../../problems/broken-calculator) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 976 | [三角形的最大周长](../../problems/largest-perimeter-triangle) | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Easy | -| 972 | [相等的有理数](../../problems/equal-rational-numbers) | [[数学](../math/README.md)] | Hard | +| 1006 | [笨阶乘](../../problems/clumsy-factorial) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 991 | [坏了的计算器](../../problems/broken-calculator) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 989 | [数组形式的整数加法](../../problems/add-to-array-form-of-integer) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 976 | [三角形的最大周长](../../problems/largest-perimeter-triangle) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 972 | [相等的有理数](../../problems/equal-rational-numbers) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | | 970 | [强整数](../../problems/powerful-integers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 964 | [表示数字的最少运算符](../../problems/least-operators-to-express-number) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | -| 952 | [按公因数计算最大组件大小](../../problems/largest-component-size-by-common-factor) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | -| 949 | [给定数字能组成的最大时间](../../problems/largest-time-for-given-digits) | [[数学](../math/README.md)] | Medium | -| 942 | [增减字符串匹配](../../problems/di-string-match) | [[数学](../math/README.md)] | Easy | -| 927 | [三等分](../../problems/three-equal-parts) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 910 | [最小差值 II](../../problems/smallest-range-ii) | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] | Medium | -| 908 | [最小差值 I](../../problems/smallest-range-i) | [[数学](../math/README.md)] | Easy | -| 906 | [超级回文数](../../problems/super-palindromes) | [[数学](../math/README.md)] | Hard | -| 902 | [最大为 N 的数字组合](../../problems/numbers-at-most-n-given-digit-set) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 892 | [三维形体的表面积](../../problems/surface-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | -| 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 957 | [N 天后的牢房](../../problems/prison-cells-after-n-days) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 952 | [按公因数计算最大组件大小](../../problems/largest-component-size-by-common-factor) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 942 | [增减字符串匹配](../../problems/di-string-match) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 939 | [最小面积矩形](../../problems/minimum-area-rectangle) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 932 | [漂亮数组](../../problems/beautiful-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] | Medium | +| 927 | [三等分](../../problems/three-equal-parts) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 920 | [播放列表的数量](../../problems/number-of-music-playlists) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Easy | +| 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 910 | [最小差值 II](../../problems/smallest-range-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 908 | [最小差值 I](../../problems/smallest-range-i) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 906 | [超级回文数](../../problems/super-palindromes) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 902 | [最大为 N 的数字组合](../../problems/numbers-at-most-n-given-digit-set) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | +| 892 | [三维形体的表面积](../../problems/surface-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 885 | [螺旋矩阵 III](../../problems/spiral-matrix-iii) | [[数学](../math/README.md)] | Medium | -| 883 | [三维形体投影面积](../../problems/projection-area-of-3d-shapes) | [[数学](../math/README.md)] | Easy | +| 883 | [三维形体投影面积](../../problems/projection-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Easy | | 878 | [第 N 个神奇数字](../../problems/nth-magical-number) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 877 | [石子游戏](../../problems/stone-game) | [[极小化极大](../minimax/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 869 | [重新排序得到 2 的幂](../../problems/reordered-power-of-2) | [[数学](../math/README.md)] | Medium | -| 868 | [二进制间距](../../problems/binary-gap) | [[数学](../math/README.md)] | Easy | +| 877 | [石子游戏](../../problems/stone-game) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 869 | [重新排序得到 2 的幂](../../problems/reordered-power-of-2) | [[数学](../math/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Medium | +| 868 | [二进制间距](../../problems/binary-gap) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | | 866 | [回文素数](../../problems/prime-palindrome) | [[数学](../math/README.md)] | Medium | -| 858 | [镜面反射](../../problems/mirror-reflection) | [[数学](../math/README.md)] | Medium | -| 836 | [矩形重叠](../../problems/rectangle-overlap) | [[数学](../math/README.md)] | Easy | -| 829 | [连续整数求和](../../problems/consecutive-numbers-sum) | [[数学](../math/README.md)] | Hard | -| 812 | [最大三角形面积](../../problems/largest-triangle-area) | [[数学](../math/README.md)] | Easy | -| 810 | [黑板异或游戏](../../problems/chalkboard-xor-game) | [[数学](../math/README.md)] | Hard | -| 805 | [数组的均值分割](../../problems/split-array-with-same-average) | [[数学](../math/README.md)] | Hard | -| 800 | [相似 RGB 颜色](../../problems/similar-rgb-color) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 789 | [逃脱阻碍者](../../problems/escape-the-ghosts) | [[数学](../math/README.md)] | Medium | -| 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | -| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 858 | [镜面反射](../../problems/mirror-reflection) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | +| 843 | [猜猜这个单词](../../problems/guess-the-word) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] [[交互](../interactive/README.md)] | Hard | +| 840 | [矩阵中的幻方](../../problems/magic-squares-in-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 837 | [新21点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 836 | [矩形重叠](../../problems/rectangle-overlap) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | +| 829 | [连续整数求和](../../problems/consecutive-numbers-sum) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 812 | [最大三角形面积](../../problems/largest-triangle-area) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 810 | [黑板异或游戏](../../problems/chalkboard-xor-game) | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 808 | [分汤](../../problems/soup-servings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 805 | [数组的均值分割](../../problems/split-array-with-same-average) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 800 | [相似 RGB 颜色](../../problems/similar-rgb-color) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[枚举](../enumeration/README.md)] | Easy | +| 793 | [阶乘函数后 K 个零](../../problems/preimage-size-of-factorial-zeroes-function) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 789 | [逃脱阻碍者](../../problems/escape-the-ghosts) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 788 | [旋转数字](../../problems/rotated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 780 | [到达终点](../../problems/reaching-points) | [[数学](../math/README.md)] | Hard | +| 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 775 | [全局倒置与局部倒置](../../problems/global-and-local-inversions) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 754 | [到达终点数字](../../problems/reach-a-number) | [[数学](../math/README.md)] | Medium | -| 753 | [破解保险箱](../../problems/cracking-the-safe) | [[深度优先搜索](../depth-first-search/README.md)] [[数学](../math/README.md)] | Hard | +| 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 762 | [二进制表示中质数个计算置位](../../problems/prime-number-of-set-bits-in-binary-representation) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | +| 754 | [到达终点数字](../../problems/reach-a-number) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 750 | [角矩形的数量](../../problems/number-of-corner-rectangles) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 738 | [单调递增的数字](../../problems/monotone-increasing-digits) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | | 728 | [自除数](../../problems/self-dividing-numbers) | [[数学](../math/README.md)] | Easy | -| 672 | [灯泡开关 Ⅱ](../../problems/bulb-switcher-ii) | [[数学](../math/README.md)] | Medium | -| 670 | [最大交换](../../problems/maximum-swap) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[随机化](../randomized/README.md)] | Hard | +| 679 | [24 点游戏](../../problems/24-game) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 672 | [灯泡开关 Ⅱ](../../problems/bulb-switcher-ii) | [[位运算](../bit-manipulation/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Medium | +| 670 | [最大交换](../../problems/maximum-swap) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 667 | [优美的排列 II](../../problems/beautiful-arrangement-ii) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 660 | [移除 9](../../problems/remove-9) 🔒 | [[数学](../math/README.md)] | Hard | -| 651 | [4键键盘](../../problems/4-keys-keyboard) 🔒 | [[贪心算法](../greedy/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 645 | [错误的集合](../../problems/set-mismatch) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 640 | [求解方程](../../problems/solve-the-equation) | [[数学](../math/README.md)] | Medium | -| 634 | [寻找数组的错位排列](../../problems/find-the-derangement-of-an-array) 🔒 | [[数学](../math/README.md)] | Medium | -| 633 | [平方数之和](../../problems/sum-of-square-numbers) | [[数学](../math/README.md)] | Medium | -| 628 | [三个数的最大乘积](../../problems/maximum-product-of-three-numbers) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 598 | [范围求和 II](../../problems/range-addition-ii) | [[数学](../math/README.md)] | Easy | -| 593 | [有效的正方形](../../problems/valid-square) | [[数学](../math/README.md)] | Medium | -| 592 | [分数加减运算](../../problems/fraction-addition-and-subtraction) | [[数学](../math/README.md)] | Medium | -| 573 | [松鼠模拟](../../problems/squirrel-simulation) 🔒 | [[数学](../math/README.md)] | Medium | -| 553 | [最优除法](../../problems/optimal-division) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 535 | [TinyURL 的加密与解密](../../problems/encode-and-decode-tinyurl) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 523 | [连续的子数组和](../../problems/continuous-subarray-sum) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 517 | [超级洗衣机](../../problems/super-washing-machines) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 651 | [4键键盘](../../problems/4-keys-keyboard) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 650 | [只有两个键的键盘](../../problems/2-keys-keyboard) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 640 | [求解方程](../../problems/solve-the-equation) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 634 | [寻找数组的错位排列](../../problems/find-the-derangement-of-an-array) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 633 | [平方数之和](../../problems/sum-of-square-numbers) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 628 | [三个数的最大乘积](../../problems/maximum-product-of-three-numbers) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 598 | [范围求和 II](../../problems/range-addition-ii) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 593 | [有效的正方形](../../problems/valid-square) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | +| 592 | [分数加减运算](../../problems/fraction-addition-and-subtraction) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 587 | [安装栅栏](../../problems/erect-the-fence) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 573 | [松鼠模拟](../../problems/squirrel-simulation) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 564 | [寻找最近的回文数](../../problems/find-the-closest-palindrome) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 556 | [下一个更大元素 III](../../problems/next-greater-element-iii) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 553 | [最优除法](../../problems/optimal-division) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 539 | [最小时间差](../../problems/minimum-time-difference) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 523 | [连续的子数组和](../../problems/continuous-subarray-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 519 | [随机翻转矩阵](../../problems/random-flip-matrix) | [[水塘抽样](../reservoir-sampling/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 509 | [斐波那契数](../../problems/fibonacci-number) | [[递归](../recursion/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 507 | [完美数](../../problems/perfect-number) | [[数学](../math/README.md)] | Easy | +| 504 | [七进制数](../../problems/base-7) | [[数学](../math/README.md)] | Easy | +| 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[水塘抽样](../reservoir-sampling/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] [[随机化](../randomized/README.md)] | Medium | | 492 | [构造矩形](../../problems/construct-the-rectangle) | [[数学](../math/README.md)] | Easy | +| 486 | [预测赢家](../../problems/predict-the-winner) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 483 | [最小好进制](../../problems/smallest-good-base) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | -| 469 | [凸多边形](../../problems/convex-polygon) 🔒 | [[数学](../math/README.md)] | Medium | -| 462 | [最少移动次数使数组元素相等 II](../../problems/minimum-moves-to-equal-array-elements-ii) | [[数学](../math/README.md)] | Medium | -| 458 | [可怜的小猪](../../problems/poor-pigs) | [[数学](../math/README.md)] | Hard | -| 453 | [最小操作次数使数组元素相等](../../problems/minimum-moves-to-equal-array-elements) | [[数学](../math/README.md)] | Easy | -| 447 | [回旋镖的数量](../../problems/number-of-boomerangs) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 479 | [最大回文数乘积](../../problems/largest-palindrome-product) | [[数学](../math/README.md)] | Hard | +| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] [[拒绝采样](../rejection-sampling/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 477 | [汉明距离总和](../../problems/total-hamming-distance) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[数学](../math/README.md)] [[拒绝采样](../rejection-sampling/README.md)] [[概率与统计](../probability-and-statistics/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 469 | [凸多边形](../../problems/convex-polygon) 🔒 | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | +| 464 | [我能赢吗](../../problems/can-i-win) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 462 | [最少移动次数使数组元素相等 II](../../problems/minimum-moves-to-equal-array-elements-ii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 458 | [可怜的小猪](../../problems/poor-pigs) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 453 | [最小操作次数使数组元素相等](../../problems/minimum-moves-to-equal-array-elements) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 447 | [回旋镖的数量](../../problems/number-of-boomerangs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 445 | [两数相加 II](../../problems/add-two-numbers-ii) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | | 441 | [排列硬币](../../problems/arranging-coins) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 423 | [从英文中重建数字](../../problems/reconstruct-original-digits-from-english) | [[数学](../math/README.md)] | Medium | -| 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 400 | [第 N 位数字](../../problems/nth-digit) | [[数学](../math/README.md)] | Medium | -| 397 | [整数替换](../../problems/integer-replacement) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | -| 396 | [旋转函数](../../problems/rotate-function) | [[数学](../math/README.md)] | Medium | -| 372 | [超级次方](../../problems/super-pow) | [[数学](../math/README.md)] | Medium | -| 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 423 | [从英文中重建数字](../../problems/reconstruct-original-digits-from-english) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 415 | [字符串相加](../../problems/add-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 412 | [Fizz Buzz](../../problems/fizz-buzz) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 405 | [数字转换为十六进制数](../../problems/convert-a-number-to-hexadecimal) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | +| 400 | [第 N 位数字](../../problems/nth-digit) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 398 | [随机数索引](../../problems/random-pick-index) | [[水塘抽样](../reservoir-sampling/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 396 | [旋转函数](../../problems/rotate-function) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 390 | [消除游戏](../../problems/elimination-game) | [[数学](../math/README.md)] | Medium | +| 384 | [打乱数组](../../problems/shuffle-an-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 382 | [链表随机节点](../../problems/linked-list-random-node) | [[水塘抽样](../reservoir-sampling/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Hard | +| 380 | [O(1) 时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 375 | [猜数字大小 II](../../problems/guess-number-higher-or-lower-ii) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 372 | [超级次方](../../problems/super-pow) | [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] | Medium | +| 371 | [两整数之和](../../problems/sum-of-two-integers) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | +| 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | +| 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | | 367 | [有效的完全平方数](../../problems/valid-perfect-square) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 365 | [水壶问题](../../problems/water-and-jug-problem) | [[数学](../math/README.md)] | Medium | -| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 356 | [直线镜像](../../problems/line-reflection) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 365 | [水壶问题](../../problems/water-and-jug-problem) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Medium | +| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 357 | [计算各个位数不同的数字个数](../../problems/count-numbers-with-unique-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 356 | [直线镜像](../../problems/line-reflection) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 343 | [整数拆分](../../problems/integer-break) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 335 | [路径交叉](../../problems/self-crossing) | [[数学](../math/README.md)] | Hard | -| 326 | [3的幂](../../problems/power-of-three) | [[数学](../math/README.md)] | Easy | +| 342 | [4的幂](../../problems/power-of-four) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | +| 335 | [路径交叉](../../problems/self-crossing) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 326 | [3的幂](../../problems/power-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | | 319 | [灯泡开关](../../problems/bulb-switcher) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Medium | -| 313 | [超级丑数](../../problems/super-ugly-number) | [[堆](../heap/README.md)] [[数学](../math/README.md)] | Medium | -| 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | +| 313 | [超级丑数](../../problems/super-ugly-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Hard | +| 294 | [翻转游戏 II](../../problems/flip-game-ii) 🔒 | [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 292 | [Nim 游戏](../../problems/nim-game) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Easy | +| 282 | [给表达式添加运算符](../../problems/expression-add-operators) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 279 | [完全平方数](../../problems/perfect-squares) | [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 268 | [丢失的数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 264 | [丑数 II](../../problems/ugly-number-ii) | [[堆](../heap/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 268 | [丢失的数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 264 | [丑数 II](../../problems/ugly-number-ii) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 263 | [丑数](../../problems/ugly-number) | [[数学](../math/README.md)] | Easy | -| 258 | [各位相加](../../problems/add-digits) | [[数学](../math/README.md)] | Easy | -| 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | -| 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 246 | [中心对称数](../../problems/strobogrammatic-number) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 233 | [数字 1 的个数](../../problems/number-of-digit-one) | [[数学](../math/README.md)] | Hard | -| 231 | [2 的幂](../../problems/power-of-two) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | -| 224 | [基本计算器](../../problems/basic-calculator) | [[栈](../stack/README.md)] [[数学](../math/README.md)] | Hard | -| 223 | [矩形面积](../../problems/rectangle-area) | [[数学](../math/README.md)] | Medium | -| 204 | [计数质数](../../problems/count-primes) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | -| 202 | [快乐数](../../problems/happy-number) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Easy | +| 258 | [各位相加](../../problems/add-digits) | [[数学](../math/README.md)] [[数论](../number-theory/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 241 | [为运算表达式设计优先级](../../problems/different-ways-to-add-parentheses) | [[递归](../recursion/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 233 | [数字 1 的个数](../../problems/number-of-digit-one) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 231 | [2 的幂](../../problems/power-of-two) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | +| 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 224 | [基本计算器](../../problems/basic-calculator) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 223 | [矩形面积](../../problems/rectangle-area) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | +| 204 | [计数质数](../../problems/count-primes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] [[数论](../number-theory/README.md)] | Easy | +| 202 | [快乐数](../../problems/happy-number) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 189 | [旋转数组](../../problems/rotate-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 172 | [阶乘后的零](../../problems/factorial-trailing-zeroes) | [[数学](../math/README.md)] | Easy | -| 171 | [Excel表列序号](../../problems/excel-sheet-column-number) | [[数学](../math/README.md)] | Easy | -| 168 | [Excel表列名称](../../problems/excel-sheet-column-title) | [[数学](../math/README.md)] | Easy | -| 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | -| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 171 | [Excel表列序号](../../problems/excel-sheet-column-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 168 | [Excel表列名称](../../problems/excel-sheet-column-title) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 89 | [格雷编码](../../problems/gray-code) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 70 | [爬楼梯](../../problems/climbing-stairs) | [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 69 | [x 的平方根](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 67 | [二进制求和](../../problems/add-binary) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 65 | [有效数字](../../problems/valid-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 60 | [排列序列](../../problems/permutation-sequence) | [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 50 | [Pow(x, n)](../../problems/powx-n) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 29 | [两数相除](../../problems/divide-two-integers) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 67 | [二进制求和](../../problems/add-binary) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 66 | [加一](../../problems/plus-one) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 62 | [不同路径](../../problems/unique-paths) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | +| 60 | [排列序列](../../problems/permutation-sequence) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | +| 50 | [Pow(x, n)](../../problems/powx-n) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 48 | [旋转图像](../../problems/rotate-image) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 29 | [两数相除](../../problems/divide-two-integers) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | +| 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 9 | [回文数](../../problems/palindrome-number) | [[数学](../math/README.md)] | Easy | -| 8 | [字符串转换整数 (atoi)](../../problems/string-to-integer-atoi) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 7 | [整数反转](../../problems/reverse-integer) | [[数学](../math/README.md)] | Easy | | 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/memoization/README.md b/tag/memoization/README.md index 2c6a5dffd..8c1157c83 100644 --- a/tag/memoization/README.md +++ b/tag/memoization/README.md @@ -9,4 +9,29 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | +| 1900 | [最佳运动员的比拼回合](../../problems/the-earliest-and-latest-rounds-where-players-compete) | [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] [[计数](../counting/README.md)] | Hard | +| 1815 | [得到新鲜甜甜圈的最多组数](../../problems/maximum-number-of-groups-getting-fresh-donuts) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1728 | [猫和老鼠 II](../../problems/cat-and-mouse-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1553 | [吃掉 N 个橘子的最少天数](../../problems/minimum-number-of-days-to-eat-n-oranges) | [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1444 | [切披萨的方案数](../../problems/number-of-ways-of-cutting-a-pizza) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 638 | [大礼包](../../problems/shopping-offers) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 546 | [移除盒子](../../problems/remove-boxes) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 509 | [斐波那契数](../../problems/fibonacci-number) | [[递归](../recursion/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 464 | [我能赢吗](../../problems/can-i-win) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 397 | [整数替换](../../problems/integer-replacement) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 294 | [翻转游戏 II](../../problems/flip-game-ii) 🔒 | [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 241 | [为运算表达式设计优先级](../../problems/different-ways-to-add-parentheses) | [[递归](../recursion/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 140 | [单词拆分 II](../../problems/word-break-ii) | [[字典树](../trie/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 139 | [单词拆分](../../problems/word-break) | [[字典树](../trie/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 70 | [爬楼梯](../../problems/climbing-stairs) | [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | diff --git a/tag/minimax/README.md b/tag/minimax/README.md index 0cf0739a7..dd3b3951d 100644 --- a/tag/minimax/README.md +++ b/tag/minimax/README.md @@ -9,11 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[极小化极大](../minimax/README.md)] | Hard | -| 877 | [石子游戏](../../problems/stone-game) | [[极小化极大](../minimax/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 843 | [猜猜这个单词](../../problems/guess-the-word) | [[极小化极大](../minimax/README.md)] | Hard | -| 486 | [预测赢家](../../problems/predict-the-winner) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 464 | [我能赢吗](../../problems/can-i-win) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 375 | [猜数字大小 II](../../problems/guess-number-higher-or-lower-ii) | [[极小化极大](../minimax/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 294 | [翻转游戏 II](../../problems/flip-game-ii) 🔒 | [[极小化极大](../minimax/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 292 | [Nim 游戏](../../problems/nim-game) | [[脑筋急转弯](../brainteaser/README.md)] [[极小化极大](../minimax/README.md)] | Easy | diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index 86e7c7355..52afd5989 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -9,18 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1865 | [找出和为指定值的下标对](../../problems/finding-pairs-with-a-certain-sum) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | -| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[堆](../heap/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | -| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 855 | [考场就座](../../problems/exam-room) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 846 | [一手顺子](../../problems/hand-of-straights) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 731 | [我的日程安排表 II](../../problems/my-calendar-ii) | [[Ordered Map](../ordered-map/README.md)] | Medium | -| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 683 | [K 个关闭的灯泡](../../problems/k-empty-slots) 🔒 | [[Ordered Map](../ordered-map/README.md)] | Hard | -| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index f0540afe0..60c08ba62 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -9,16 +9,31 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[堆](../heap/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] | Hard | -| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | -| 933 | [最近的请求次数](../../problems/number-of-recent-calls) | [[队列](../queue/README.md)] | Easy | -| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] | Medium | -| 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | -| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Medium | -| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | -| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | +| 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1700 | [无法吃午餐的学生数量](../../problems/number-of-students-unable-to-eat-lunch) | [[栈](../stack/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1696 | [跳跃游戏 VI](../../problems/jump-game-vi) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] | Medium | +| 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] | Medium | +| 1425 | [带限制的子序列和](../../problems/constrained-subsequence-sum) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[数据流](../data-stream/README.md)] | Medium | +| 950 | [按递增顺序显示卡牌](../../problems/reveal-cards-in-increasing-order) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 936 | [戳印序列](../../problems/stamping-the-sequence) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[字符串](../string/README.md)] | Hard | +| 933 | [最近的请求次数](../../problems/number-of-recent-calls) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数据流](../data-stream/README.md)] | Easy | +| 918 | [环形子数组的最大和](../../problems/maximum-sum-circular-subarray) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] | Medium | +| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 649 | [Dota2 参议院](../../problems/dota2-senate) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[字符串](../string/README.md)] | Medium | +| 641 | [设计循环双端队列](../../problems/design-circular-deque) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 622 | [设计循环队列](../../problems/design-circular-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[队列](../queue/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 379 | [电话目录管理系统](../../problems/design-phone-directory) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 362 | [敲击计数器](../../problems/design-hit-counter) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数据流](../data-stream/README.md)] | Easy | +| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | +| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | diff --git a/tag/random/README.md b/tag/random/README.md index 25144cd0a..72a82d98f 100644 --- a/tag/random/README.md +++ b/tag/random/README.md @@ -9,9 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | -| 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | -| 519 | [随机翻转矩阵](../../problems/random-flip-matrix) | [[Random](../random/README.md)] | Medium | -| 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Medium | -| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | -| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 8951347fc..ab90a7221 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -9,44 +9,44 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1863 | [找出所有子集的异或总和再求和](../../problems/sum-of-all-subset-xor-totals) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Easy | -| 1849 | [将字符串拆分为递减的连续值](../../problems/splitting-a-string-into-descending-consecutive-values) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1780 | [判断一个数字是否可以表示成三的幂的和](../../problems/check-if-number-is-a-sum-of-powers-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1306 | [跳跃游戏 III](../../problems/jump-game-iii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1137 | [第 N 个泰波那契数](../../problems/n-th-tribonacci-number) | [[递归](../recursion/README.md)] | Easy | -| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 967 | [连续差相同的数字](../../problems/numbers-with-same-consecutive-differences) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 897 | [递增顺序搜索树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[递归](../recursion/README.md)] | Medium | -| 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | +| 1922 | [统计好数字的数目](../../problems/count-good-numbers) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1808 | [好因子的最大数目](../../problems/maximize-number-of-nice-divisors) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | +| 1545 | [找出第 N 个二进制字符串中的第 K 位](../../problems/find-kth-bit-in-nth-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | +| 1265 | [逆序打印不可变链表](../../problems/print-immutable-linked-list-in-reverse) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1106 | [解析布尔表达式](../../problems/parsing-a-boolean-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | +| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | | 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[递归](../recursion/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 625 | [最小因式分解](../../problems/minimum-factorization) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | -| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 369 | [给单链表加一](../../problems/plus-one-linked-list) 🔒 | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | -| 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | -| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | -| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | +| 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 509 | [斐波那契数](../../problems/fibonacci-number) | [[递归](../recursion/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 486 | [预测赢家](../../problems/predict-the-winner) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 439 | [三元表达式解析器](../../problems/ternary-expression-parser) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | +| 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | +| 344 | [反转字符串](../../problems/reverse-string) | [[递归](../recursion/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 342 | [4的幂](../../problems/power-of-four) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | +| 326 | [3的幂](../../problems/power-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | +| 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | +| 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 241 | [为运算表达式设计优先级](../../problems/different-ways-to-add-parentheses) | [[递归](../recursion/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 234 | [回文链表](../../problems/palindrome-linked-list) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 233 | [数字 1 的个数](../../problems/number-of-digit-one) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 231 | [2 的幂](../../problems/power-of-two) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | +| 224 | [基本计算器](../../problems/basic-calculator) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 206 | [反转链表](../../problems/reverse-linked-list) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Easy | +| 203 | [移除链表元素](../../problems/remove-linked-list-elements) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Easy | +| 143 | [重排链表](../../problems/reorder-list) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 60 | [排列序列](../../problems/permutation-sequence) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | +| 50 | [Pow(x, n)](../../problems/powx-n) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 25 | [K 个一组翻转链表](../../problems/reverse-nodes-in-k-group) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Hard | | 24 | [两两交换链表中的节点](../../problems/swap-nodes-in-pairs) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Medium | | 21 | [合并两个有序链表](../../problems/merge-two-sorted-lists) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] | Easy | -| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/rejection-sampling/README.md b/tag/rejection-sampling/README.md index fc2d396f2..baecbf3f9 100644 --- a/tag/rejection-sampling/README.md +++ b/tag/rejection-sampling/README.md @@ -9,5 +9,5 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[数学](../math/README.md)] [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | -| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[Random](../random/README.md)] [[Rejection Sampling](../rejection-sampling/README.md)] | Medium | +| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] [[拒绝采样](../rejection-sampling/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[数学](../math/README.md)] [[拒绝采样](../rejection-sampling/README.md)] [[概率与统计](../probability-and-statistics/README.md)] [[随机化](../randomized/README.md)] | Medium | diff --git a/tag/reservoir-sampling/README.md b/tag/reservoir-sampling/README.md index 1fc516eb3..59e9ab693 100644 --- a/tag/reservoir-sampling/README.md +++ b/tag/reservoir-sampling/README.md @@ -9,5 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 398 | [随机数索引](../../problems/random-pick-index) | [[蓄水池抽样](../reservoir-sampling/README.md)] | Medium | -| 382 | [链表随机节点](../../problems/linked-list-random-node) | [[蓄水池抽样](../reservoir-sampling/README.md)] | Medium | +| 519 | [随机翻转矩阵](../../problems/random-flip-matrix) | [[水塘抽样](../reservoir-sampling/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[水塘抽样](../reservoir-sampling/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 398 | [随机数索引](../../problems/random-pick-index) | [[水塘抽样](../reservoir-sampling/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 382 | [链表随机节点](../../problems/linked-list-random-node) | [[水塘抽样](../reservoir-sampling/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | diff --git a/tag/rolling-hash/README.md b/tag/rolling-hash/README.md index 70152bf02..c8154f5a4 100644 --- a/tag/rolling-hash/README.md +++ b/tag/rolling-hash/README.md @@ -9,3 +9,15 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1554 | [只有一个不同字符的字符串](../../problems/strings-differ-by-one-character) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1392 | [最长快乐前缀](../../problems/longest-happy-prefix) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1316 | [不同的循环子字符串](../../problems/distinct-echo-substrings) | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1147 | [段式回文](../../problems/longest-chunked-palindrome-decomposition) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1062 | [最长重复子串](../../problems/longest-repeating-substring) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 214 | [最短回文串](../../problems/shortest-palindrome) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 187 | [重复的DNA序列](../../problems/repeated-dna-sequences) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index b34d04e3d..13b0613a2 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -9,19 +9,22 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[线段树](../segment-tree/README.md)] | Hard | -| 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | -| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | -| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 715 | [Range 模块](../../problems/range-module) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 308 | [二维区域和检索 - 可变](../../problems/range-sum-query-2d-mutable) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Hard | -| 307 | [区域和检索 - 数组可修改](../../problems/range-sum-query-mutable) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] | Medium | -| 218 | [天际线问题](../../problems/the-skyline-problem) | [[堆](../heap/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Line Sweep](../line-sweep/README.md)] | Hard | +| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数学](../math/README.md)] | Hard | +| 1521 | [找到最接近目标值的函数值](../../problems/find-a-value-of-a-mysterious-function-closest-to-target) | [[位运算](../bit-manipulation/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1505 | [最多 K 次交换相邻数位后得到的最小整数](../../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | [[贪心](../greedy/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[字符串](../string/README.md)] | Hard | +| 1157 | [子数组中占绝大多数的元素](../../problems/online-majority-element-in-subarray) | [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[扫描线](../line-sweep/README.md)] | Hard | +| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 731 | [我的日程安排表 II](../../problems/my-calendar-ii) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 729 | [我的日程安排表 I](../../problems/my-calendar-i) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 715 | [Range 模块](../../problems/range-module) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 673 | [最长递增子序列的个数](../../problems/number-of-longest-increasing-subsequence) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 493 | [翻转对](../../problems/reverse-pairs) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 308 | [二维区域和检索 - 可变](../../problems/range-sum-query-2d-mutable) 🔒 | [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 307 | [区域和检索 - 数组可修改](../../problems/range-sum-query-mutable) | [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] | Medium | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[扫描线](../line-sweep/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index ee49220e1..211bfe5b5 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -9,30 +9,64 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[排序](../sort/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1176 | [健身计划评估](../../problems/diet-plan-performance) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Easy | -| 1151 | [最少交换次数来组合所有的 1](../../problems/minimum-swaps-to-group-all-1s-together) 🔒 | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 1052 | [爱生气的书店老板](../../problems/grumpy-bookstore-owner) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1040 | [移动石子直到连续 II](../../problems/moving-stones-until-consecutive-ii) | [[数组](../array/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[贪心算法](../greedy/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[动态规划](../dynamic-programming/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 480 | [滑动窗口中位数](../../problems/sliding-window-median) | [[Sliding Window](../sliding-window/README.md)] | Hard | -| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[递归](../recursion/README.md)] [[分治算法](../divide-and-conquer/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[堆](../heap/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 1918 | [Kth Smallest Subarray Sum](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1876 | [长度为三且各字符不同的子字符串](../../problems/substrings-of-size-three-with-distinct-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | +| 1852 | [每个子数组的数字种类数](../../problems/distinct-numbers-in-each-subarray) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1839 | [所有元音按顺序排布的最长子字符串](../../problems/longest-substring-of-all-vowels-in-order) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1838 | [最高频元素的频数](../../problems/frequency-of-the-most-frequent-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1763 | [最长的美好子字符串](../../problems/longest-nice-substring) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | +| 1703 | [得到连续 K 个 1 的最少相邻交换次数](../../problems/minimum-adjacent-swaps-for-k-consecutive-ones) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 1696 | [跳跃游戏 VI](../../problems/jump-game-vi) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1695 | [删除子数组的最大得分](../../problems/maximum-erasure-value) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1493 | [删掉一个元素以后全为 1 的最长子数组](../../problems/longest-subarray-of-1s-after-deleting-one-element) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1477 | [找两个和为目标值且不重叠的子数组](../../problems/find-two-non-overlapping-sub-arrays-each-with-target-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1425 | [带限制的子序列和](../../problems/constrained-subsequence-sum) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1358 | [包含所有三种字符的子字符串数目](../../problems/number-of-substrings-containing-all-three-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1343 | [大小为 K 且平均值大于等于阈值的子数组数目](../../problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1316 | [不同的循环子字符串](../../problems/distinct-echo-substrings) | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1248 | [统计「优美子数组」](../../problems/count-number-of-nice-subarrays) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1176 | [健身计划评估](../../problems/diet-plan-performance) 🔒 | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | +| 1156 | [单字符重复子串的最大长度](../../problems/swap-for-longest-repeated-character-substring) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1151 | [最少交换次数来组合所有的 1](../../problems/minimum-swaps-to-group-all-1s-together) 🔒 | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1052 | [爱生气的书店老板](../../problems/grumpy-bookstore-owner) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1031 | [两个非重叠子数组的最大和](../../problems/maximum-sum-of-two-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 978 | [最长湍流子数组](../../problems/longest-turbulent-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 904 | [水果成篮](../../problems/fruit-into-baskets) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 837 | [新21点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 683 | [K 个关闭的灯泡](../../problems/k-empty-slots) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 643 | [子数组最大平均数 I](../../problems/maximum-average-subarray-i) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | +| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 567 | [字符串的排列](../../problems/permutation-in-string) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 487 | [最大连续1的个数 II](../../problems/max-consecutive-ones-ii) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 480 | [滑动窗口中位数](../../problems/sliding-window-median) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 438 | [找到字符串中所有字母异位词](../../problems/find-all-anagrams-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[数组](../array/README.md)] [[桶排序](../bucket-sort/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 219 | [存在重复元素 II](../../problems/contains-duplicate-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | +| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 187 | [重复的DNA序列](../../problems/repeated-dna-sequences) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index ea6946cac..49e4c7112 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -9,86 +9,3 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1877 | [数组中最大数对和的最小值](../../problems/minimize-maximum-pair-sum-in-array) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1859 | [将句子排序](../../problems/sorting-the-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | -| 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1847 | [最近的房间](../../problems/closest-room) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1846 | [减小和重新排列数组后的最大元素](../../problems/maximum-element-after-decreasing-and-rearranging) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1833 | [雪糕的最大数量](../../problems/maximum-ice-cream-bars) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1772 | [按受欢迎程度排列功能](../../problems/sort-features-by-popularity) 🔒 | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1727 | [重新排列后的最大子矩阵](../../problems/largest-submatrix-with-rearrangements) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1710 | [卡车上的最大单元数](../../problems/maximum-units-on-a-truck) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | -| 1697 | [检查边长度限制的路径是否存在](../../problems/checking-existence-of-edge-length-limited-paths) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] | Hard | -| 1691 | [堆叠长方体的最大高度](../../problems/maximum-height-by-stacking-cuboids) | [[排序](../sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[数学](../math/README.md)] | Medium | -| 1647 | [字符频次唯一的最小删除次数](../../problems/minimum-deletions-to-make-character-frequencies-unique) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1640 | [能否连接形成数组](../../problems/check-array-formation-through-concatenation) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1637 | [两点之间不包含任何点的最宽垂直面积](../../problems/widest-vertical-area-between-two-points-containing-no-points) | [[排序](../sort/README.md)] | Medium | -| 1636 | [按照频率将数组升序排序](../../problems/sort-array-by-increasing-frequency) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1630 | [等差子数组](../../problems/arithmetic-subarrays) | [[排序](../sort/README.md)] | Medium | -| 1561 | [你可以获得的最大硬币数目](../../problems/maximum-number-of-coins-you-can-get) | [[排序](../sort/README.md)] | Medium | -| 1528 | [重新排列字符串](../../problems/shuffle-string) | [[排序](../sort/README.md)] | Easy | -| 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1502 | [判断能否形成等差数列](../../problems/can-make-arithmetic-progression-from-sequence) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[排序](../sort/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1491 | [去掉最低工资和最高工资后的工资平均值](../../problems/average-salary-excluding-the-minimum-and-maximum-salary) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1481 | [不同整数的最少数目](../../problems/least-number-of-unique-integers-after-k-removals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1471 | [数组中的 k 个最强值](../../problems/the-k-strongest-values-in-an-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Easy | -| 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[排序](../sort/README.md)] [[图](../graph/README.md)] | Medium | -| 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Hard | -| 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | -| 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[排序](../sort/README.md)] [[位运算](../bit-manipulation/README.md)] | Easy | -| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[线段树](../segment-tree/README.md)] | Medium | -| 1333 | [餐厅过滤器](../../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1329 | [将矩阵按对角线排序](../../problems/sort-the-matrix-diagonally) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[排序](../sort/README.md)] [[树](../tree/README.md)] | Medium | -| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[排序](../sort/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[排序](../sort/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1183 | [矩阵中 1 的最大数量](../../problems/maximum-number-of-ones) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | -| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1122 | [数组的相对排序](../../problems/relative-sort-array) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 1057 | [校园自行车分配](../../problems/campus-bikes) 🔒 | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] | Medium | -| 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[排序](../sort/README.md)] | Easy | -| 976 | [三角形的最大周长](../../problems/largest-perimeter-triangle) | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Easy | -| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[堆](../heap/README.md)] [[排序](../sort/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 969 | [煎饼排序](../../problems/pancake-sorting) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 922 | [按奇偶排序数组 II](../../problems/sort-array-by-parity-ii) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Easy | -| 853 | [车队](../../problems/car-fleet) | [[排序](../sort/README.md)] | Medium | -| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[Random](../random/README.md)] | Hard | -| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Hard | -| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 493 | [翻转对](../../problems/reverse-pairs) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 324 | [摆动排序 II](../../problems/wiggle-sort-ii) | [[排序](../sort/README.md)] | Medium | -| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[排序](../sort/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[二分查找](../binary-search/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Hard | -| 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] | Hard | -| 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 274 | [H 指数](../../problems/h-index) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] | Medium | -| 252 | [会议室](../../problems/meeting-rooms) 🔒 | [[排序](../sort/README.md)] | Easy | -| 242 | [有效的字母异位词](../../problems/valid-anagram) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[排序](../sort/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | -| 179 | [最大数](../../problems/largest-number) | [[排序](../sort/README.md)] | Medium | -| 164 | [最大间距](../../problems/maximum-gap) | [[排序](../sort/README.md)] | Hard | -| 148 | [排序链表](../../problems/sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[排序](../sort/README.md)] [[链表](../linked-list/README.md)] | Medium | -| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 57 | [插入区间](../../problems/insert-interval) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | -| 56 | [合并区间](../../problems/merge-intervals) | [[排序](../sort/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/stack/README.md b/tag/stack/README.md index b1b3ae826..dde3c9653 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -9,67 +9,112 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1703 | [得到连续 K 个 1 的最少相邻交换次数](../../problems/minimum-adjacent-swaps-for-k-consecutive-ones) | [[栈](../stack/README.md)] | Hard | -| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[队列](../queue/README.md)] | Medium | -| 1598 | [文件夹操作日志搜集器](../../problems/crawler-log-folder) | [[栈](../stack/README.md)] | Easy | +| 1896 | [反转表达式值的最少操作次数](../../problems/minimum-cost-to-change-the-final-value-of-expression) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 1776 | [车队 II](../../problems/car-fleet-ii) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[单调栈](../monotonic-stack/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1762 | [能看到海景的建筑物](../../problems/buildings-with-an-ocean-view) 🔒 | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1717 | [删除子字符串的最大得分](../../problems/maximum-score-from-removing-substrings) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1700 | [无法吃午餐的学生数量](../../problems/number-of-students-unable-to-eat-lunch) | [[栈](../stack/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[数学](../math/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1614 | [括号的最大嵌套深度](../../problems/maximum-nesting-depth-of-the-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | +| 1598 | [文件夹操作日志搜集器](../../problems/crawler-log-folder) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | -| 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1441 | [用栈操作构建数组](../../problems/build-an-array-with-stack-operations) | [[栈](../stack/README.md)] | Easy | -| 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | +| 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 1504 | [统计全 1 子矩形](../../problems/count-submatrices-with-all-ones) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1475 | [商品折扣后的最终价格](../../problems/final-prices-with-a-special-discount-in-a-shop) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Easy | +| 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 1441 | [用栈操作构建数组](../../problems/build-an-array-with-stack-operations) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | +| 1265 | [逆序打印不可变链表](../../problems/print-immutable-linked-list-in-reverse) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1249 | [移除无效的括号](../../problems/minimum-remove-to-make-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1209 | [删除字符串中的所有相邻重复项 II](../../problems/remove-all-adjacent-duplicates-in-string-ii) | [[栈](../stack/README.md)] | Medium | -| 1190 | [反转每对括号间的子串](../../problems/reverse-substrings-between-each-pair-of-parentheses) | [[栈](../stack/README.md)] | Medium | -| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1124 | [表现良好的最长时间段](../../problems/longest-well-performing-interval) | [[栈](../stack/README.md)] | Medium | -| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1063 | [有效子数组的数目](../../problems/number-of-valid-subarrays) 🔒 | [[栈](../stack/README.md)] | Hard | -| 1047 | [删除字符串中的所有相邻重复项](../../problems/remove-all-adjacent-duplicates-in-string) | [[栈](../stack/README.md)] | Easy | -| 1021 | [删除最外层的括号](../../problems/remove-outermost-parentheses) | [[栈](../stack/README.md)] | Easy | -| 1019 | [链表中的下一个更大节点](../../problems/next-greater-node-in-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1209 | [删除字符串中的所有相邻重复项 II](../../problems/remove-all-adjacent-duplicates-in-string-ii) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1190 | [反转每对括号间的子串](../../problems/reverse-substrings-between-each-pair-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1172 | [餐盘栈](../../problems/dinner-plate-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1124 | [表现良好的最长时间段](../../problems/longest-well-performing-interval) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1111 | [有效括号的嵌套深度](../../problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1106 | [解析布尔表达式](../../problems/parsing-a-boolean-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | +| 1096 | [花括号展开 II](../../problems/brace-expansion-ii) | [[栈](../stack/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1063 | [有效子数组的数目](../../problems/number-of-valid-subarrays) 🔒 | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 1047 | [删除字符串中的所有相邻重复项](../../problems/remove-all-adjacent-duplicates-in-string) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | +| 1021 | [删除最外层的括号](../../problems/remove-outermost-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | +| 1019 | [链表中的下一个更大节点](../../problems/next-greater-node-in-linked-list) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1008 | [前序遍历构造二叉搜索树](../../problems/construct-binary-search-tree-from-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1006 | [笨阶乘](../../problems/clumsy-factorial) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1003 | [检查替换后的词是否有效](../../problems/check-if-word-is-valid-after-substitutions) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[动态规划](../dynamic-programming/README.md)] [[Ordered Map](../ordered-map/README.md)] | Hard | -| 946 | [验证栈序列](../../problems/validate-stack-sequences) | [[栈](../stack/README.md)] | Medium | -| 921 | [使括号有效的最少添加](../../problems/minimum-add-to-make-parentheses-valid) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 907 | [子数组的最小值之和](../../problems/sum-of-subarray-minimums) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Medium | -| 901 | [股票价格跨度](../../problems/online-stock-span) | [[栈](../stack/README.md)] | Medium | -| 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 880 | [索引处的解码字符串](../../problems/decoded-string-at-index) | [[栈](../stack/README.md)] | Medium | +| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[有序集合](../ordered-set/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 962 | [最大宽度坡](../../problems/maximum-width-ramp) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 946 | [验证栈序列](../../problems/validate-stack-sequences) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 936 | [戳印序列](../../problems/stamping-the-sequence) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[字符串](../string/README.md)] | Hard | +| 921 | [使括号有效的最少添加](../../problems/minimum-add-to-make-parentheses-valid) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 907 | [子数组的最小值之和](../../problems/sum-of-subarray-minimums) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 901 | [股票价格跨度](../../problems/online-stock-span) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 897 | [递增顺序搜索树](../../problems/increasing-order-search-tree) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 880 | [索引处的解码字符串](../../problems/decoded-string-at-index) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | | 856 | [括号的分数](../../problems/score-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | -| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | -| 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 735 | [行星碰撞](../../problems/asteroid-collision) | [[栈](../stack/README.md)] | Medium | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 682 | [棒球比赛](../../problems/baseball-game) | [[栈](../stack/README.md)] | Easy | -| 636 | [函数的独占时间](../../problems/exclusive-time-of-functions) | [[栈](../stack/README.md)] | Medium | +| 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 769 | [最多能完成排序的块](../../problems/max-chunks-to-make-sorted) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 768 | [最多能完成排序的块 II](../../problems/max-chunks-to-make-sorted-ii) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 735 | [行星碰撞](../../problems/asteroid-collision) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Medium | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 716 | [最大栈](../../problems/max-stack) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] [[有序集合](../ordered-set/README.md)] | Easy | +| 682 | [棒球比赛](../../problems/baseball-game) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 654 | [最大二叉树](../../problems/maximum-binary-tree) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 636 | [函数的独占时间](../../problems/exclusive-time-of-functions) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Medium | | 591 | [标签验证器](../../problems/tag-validator) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | -| 503 | [下一个更大元素 II](../../problems/next-greater-element-ii) | [[栈](../stack/README.md)] | Medium | -| 496 | [下一个更大元素 I](../../problems/next-greater-element-i) | [[栈](../stack/README.md)] | Easy | -| 456 | [132 模式](../../problems/132-pattern) | [[栈](../stack/README.md)] | Medium | -| 439 | [三元表达式解析器](../../problems/ternary-expression-parser) 🔒 | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 402 | [移掉K位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] | Medium | -| 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 385 | [迷你语法分析器](../../problems/mini-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Medium | -| 331 | [验证二叉树的前序序列化](../../problems/verify-preorder-serialization-of-a-binary-tree) | [[栈](../stack/README.md)] | Medium | -| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Hard | -| 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | -| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 224 | [基本计算器](../../problems/basic-calculator) | [[栈](../stack/README.md)] [[数学](../math/README.md)] | Hard | -| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | +| 590 | [N 叉树的后序遍历](../../problems/n-ary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 589 | [N 叉树的前序遍历](../../problems/n-ary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 581 | [最短无序连续子数组](../../problems/shortest-unsorted-continuous-subarray) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 503 | [下一个更大元素 II](../../problems/next-greater-element-ii) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 496 | [下一个更大元素 I](../../problems/next-greater-element-i) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[单调栈](../monotonic-stack/README.md)] | Easy | +| 484 | [寻找排列](../../problems/find-permutation) 🔒 | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 456 | [132 模式](../../problems/132-pattern) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 445 | [两数相加 II](../../problems/add-two-numbers-ii) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | +| 439 | [三元表达式解析器](../../problems/ternary-expression-parser) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | +| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 402 | [移掉 K 位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | +| 388 | [文件的最长绝对路径](../../problems/longest-absolute-file-path) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] | Medium | +| 385 | [迷你语法分析器](../../problems/mini-parser) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] | Medium | +| 364 | [加权嵌套序列和 II](../../problems/nested-list-weight-sum-ii) 🔒 | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 331 | [验证二叉树的前序序列化](../../problems/verify-preorder-serialization-of-a-binary-tree) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 321 | [拼接最大数](../../problems/create-maximum-number) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 234 | [回文链表](../../problems/palindrome-linked-list) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 232 | [用栈实现队列](../../problems/implement-queue-using-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | +| 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 225 | [用队列实现栈](../../problems/implement-stack-using-queues) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] | Easy | +| 224 | [基本计算器](../../problems/basic-calculator) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] | Medium | -| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Easy | -| 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Easy | -| 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 84 | [柱状图中最大的矩形](../../problems/largest-rectangle-in-histogram) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Hard | +| 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 143 | [重排链表](../../problems/reorder-list) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 84 | [柱状图中最大的矩形](../../problems/largest-rectangle-in-histogram) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 71 | [简化路径](../../problems/simplify-path) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 20 | [有效的括号](../../problems/valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | diff --git a/tag/string/README.md b/tag/string/README.md index 913077bf0..3f31b7f5a 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,242 +9,452 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1915 | [最美子字符串的数目](../../problems/number-of-wonderful-substrings) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1910 | [删除一个字符串中所有出现的给定子字符串](../../problems/remove-all-occurrences-of-a-substring) | [[字符串](../string/README.md)] | Medium | +| 1904 | [你完成的完整对局数](../../problems/the-number-of-full-rounds-you-have-played) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1903 | [字符串中的最大奇数](../../problems/largest-odd-number-in-string) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1898 | [可移除字符的最大数目](../../problems/maximum-number-of-removable-characters) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1897 | [重新分配字符使所有字符串都相等](../../problems/redistribute-characters-to-make-all-strings-equal) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1896 | [反转表达式值的最少操作次数](../../problems/minimum-cost-to-change-the-final-value-of-expression) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1888 | [使二进制字符串字符交替的最少反转次数](../../problems/minimum-number-of-flips-to-make-the-binary-string-alternating) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1881 | [插入后的最大值](../../problems/maximum-value-after-insertion) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1880 | [检查某单词是否等于两单词之和](../../problems/check-if-word-equals-summation-of-two-words) | [[字符串](../string/README.md)] | Easy | -| 1876 | [长度为三且各字符不同的子字符串](../../problems/substrings-of-size-three-with-distinct-characters) | [[字符串](../string/README.md)] | Easy | -| 1859 | [将句子排序](../../problems/sorting-the-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | -| 1850 | [邻位交换的最小次数](../../problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1849 | [将字符串拆分为递减的连续值](../../problems/splitting-a-string-into-descending-consecutive-values) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 1876 | [长度为三且各字符不同的子字符串](../../problems/substrings-of-size-three-with-distinct-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | +| 1871 | [跳跃游戏 VII](../../problems/jump-game-vii) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1869 | [哪种连续子字符串更长](../../problems/longer-contiguous-segments-of-ones-than-zeros) | [[字符串](../string/README.md)] | Easy | +| 1864 | [构成交替字符串需要的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-binary-string-alternating) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1859 | [将句子排序](../../problems/sorting-the-sentence) | [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1850 | [邻位交换的最小次数](../../problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1849 | [将字符串拆分为递减的连续值](../../problems/splitting-a-string-into-descending-consecutive-values) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1844 | [将所有数字用字符替换](../../problems/replace-all-digits-with-characters) | [[字符串](../string/README.md)] | Easy | -| 1839 | [所有元音按顺序排布的最长子字符串](../../problems/longest-substring-of-all-vowels-in-order) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1832 | [判断句子是否为全字母句](../../problems/check-if-the-sentence-is-pangram) | [[字符串](../string/README.md)] | Easy | -| 1830 | [使字符串有序的最少操作次数](../../problems/minimum-number-of-operations-to-make-string-sorted) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 1816 | [截断句子](../../problems/truncate-sentence) | [[字符串](../string/README.md)] | Easy | -| 1813 | [句子相似性 III](../../problems/sentence-similarity-iii) | [[字符串](../string/README.md)] | Medium | -| 1812 | [判断国际象棋棋盘中一个格子的颜色](../../problems/determine-color-of-a-chessboard-square) | [[字符串](../string/README.md)] | Easy | -| 1807 | [替换字符串中的括号内容](../../problems/evaluate-the-bracket-pairs-of-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1805 | [字符串中不同整数的数目](../../problems/number-of-different-integers-in-a-string) | [[字符串](../string/README.md)] | Easy | -| 1804 | [实现 Trie (前缀树) II](../../problems/implement-trie-ii-prefix-tree) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | -| 1796 | [字符串中第二大的数字](../../problems/second-largest-digit-in-a-string) | [[字符串](../string/README.md)] | Easy | -| 1794 | [统计距离最小的子串对个数](../../problems/count-pairs-of-equal-substrings-with-minimum-difference) 🔒 | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1790 | [仅执行一次字符串交换能否使两个字符串相等](../../problems/check-if-one-string-swap-can-make-strings-equal) | [[字符串](../string/README.md)] | Easy | -| 1781 | [所有子字符串美丽值之和](../../problems/sum-of-beauty-of-all-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1842 | [下个由相同数字构成的回文串](../../problems/next-palindrome-using-same-digits) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 1839 | [所有元音按顺序排布的最长子字符串](../../problems/longest-substring-of-all-vowels-in-order) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1832 | [判断句子是否为全字母句](../../problems/check-if-the-sentence-is-pangram) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1830 | [使字符串有序的最少操作次数](../../problems/minimum-number-of-operations-to-make-string-sorted) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1816 | [截断句子](../../problems/truncate-sentence) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1813 | [句子相似性 III](../../problems/sentence-similarity-iii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1812 | [判断国际象棋棋盘中一个格子的颜色](../../problems/determine-color-of-a-chessboard-square) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1807 | [替换字符串中的括号内容](../../problems/evaluate-the-bracket-pairs-of-a-string) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1805 | [字符串中不同整数的数目](../../problems/number-of-different-integers-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1804 | [实现 Trie (前缀树) II](../../problems/implement-trie-ii-prefix-tree) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1796 | [字符串中第二大的数字](../../problems/second-largest-digit-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1794 | [统计距离最小的子串对个数](../../problems/count-pairs-of-equal-substrings-with-minimum-difference) 🔒 | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1790 | [仅执行一次字符串交换能否使两个字符串相等](../../problems/check-if-one-string-swap-can-make-strings-equal) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1784 | [检查二进制字符串字段](../../problems/check-if-binary-string-has-at-most-one-segment-of-ones) | [[字符串](../string/README.md)] | Easy | +| 1781 | [所有子字符串美丽值之和](../../problems/sum-of-beauty-of-all-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | | 1773 | [统计匹配检索规则的物品数量](../../problems/count-items-matching-a-rule) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | -| 1768 | [交替合并字符串](../../problems/merge-strings-alternately) | [[字符串](../string/README.md)] | Easy | -| 1763 | [最长的美好子字符串](../../problems/longest-nice-substring) | [[字符串](../string/README.md)] | Easy | -| 1759 | [统计同构子字符串的数目](../../problems/count-number-of-homogenous-substrings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1772 | [按受欢迎程度排列功能](../../problems/sort-features-by-popularity) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1771 | [由子序列构造的最长回文串的长度](../../problems/maximize-palindrome-length-from-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1769 | [移动所有球到每个盒子所需的最小操作数](../../problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1768 | [交替合并字符串](../../problems/merge-strings-alternately) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 1763 | [最长的美好子字符串](../../problems/longest-nice-substring) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | +| 1759 | [统计同构子字符串的数目](../../problems/count-number-of-homogenous-substrings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1758 | [生成交替二进制字符串的最少操作数](../../problems/minimum-changes-to-make-alternating-binary-string) | [[字符串](../string/README.md)] | Easy | +| 1754 | [构造字典序最大的合并字符串](../../problems/largest-merge-of-two-strings) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1750 | [删除字符串两端相同字符后的最短长度](../../problems/minimum-length-of-string-after-deleting-similar-ends) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1745 | [回文串分割 IV](../../problems/palindrome-partitioning-iv) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1737 | [满足三条件之一需改变的最少字符数](../../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1736 | [替换隐藏数字得到的最晚时间](../../problems/latest-time-by-replacing-hidden-digits) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | -| 1704 | [判断字符串的两半是否相似](../../problems/determine-if-string-halves-are-alike) | [[字符串](../string/README.md)] | Easy | -| 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | +| 1737 | [满足三条件之一需改变的最少字符数](../../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1736 | [替换隐藏数字得到的最晚时间](../../problems/latest-time-by-replacing-hidden-digits) | [[字符串](../string/README.md)] | Easy | +| 1717 | [删除子字符串的最大得分](../../problems/maximum-score-from-removing-substrings) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1704 | [判断字符串的两半是否相似](../../problems/determine-if-string-halves-are-alike) | [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1702 | [修改后的最大二进制字符串](../../problems/maximum-binary-string-after-change) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | | 1694 | [重新格式化电话号码](../../problems/reformat-phone-number) | [[字符串](../string/README.md)] | Easy | -| 1684 | [统计一致字符串的数目](../../problems/count-the-number-of-consistent-strings) | [[字符串](../string/README.md)] | Easy | +| 1689 | [十-二进制数的最少数目](../../problems/partitioning-into-minimum-number-of-deci-binary-numbers) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1684 | [统计一致字符串的数目](../../problems/count-the-number-of-consistent-strings) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 1682 | [最长回文子序列 II](../../problems/longest-palindromic-subsequence-ii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1678 | [设计 Goal 解析器](../../problems/goal-parser-interpretation) | [[字符串](../string/README.md)] | Easy | -| 1668 | [最大重复子字符串](../../problems/maximum-repeating-substring) | [[字符串](../string/README.md)] | Easy | -| 1662 | [检查两个字符串数组是否相等](../../problems/check-if-two-string-arrays-are-equivalent) | [[字符串](../string/README.md)] | Easy | -| 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1624 | [两个相同字符之间的最长子字符串](../../problems/largest-substring-between-two-equal-characters) | [[字符串](../string/README.md)] | Easy | -| 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1614 | [括号的最大嵌套深度](../../problems/maximum-nesting-depth-of-the-parentheses) | [[字符串](../string/README.md)] | Easy | -| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[字符串](../string/README.md)] [[Ordered Map](../ordered-map/README.md)] | Medium | -| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Hard | +| 1668 | [最大重复子字符串](../../problems/maximum-repeating-substring) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Easy | +| 1663 | [具有给定数值的最小字符串](../../problems/smallest-string-with-a-given-numeric-value) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1662 | [检查两个字符串数组是否相等](../../problems/check-if-two-string-arrays-are-equivalent) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1657 | [确定两个字符串是否接近](../../problems/determine-if-two-strings-are-close) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1653 | [使字符串平衡的最少删除次数](../../problems/minimum-deletions-to-make-string-balanced) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1647 | [字符频次唯一的最小删除次数](../../problems/minimum-deletions-to-make-character-frequencies-unique) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1639 | [通过给定词典构造目标字符串的方案数](../../problems/number-of-ways-to-form-a-target-string-given-a-dictionary) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1629 | [按键持续时间最长的键](../../problems/slowest-key) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1625 | [执行操作后字典序最小的字符串](../../problems/lexicographically-smallest-string-after-applying-operations) | [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] | Medium | +| 1624 | [两个相同字符之间的最长子字符串](../../problems/largest-substring-between-two-equal-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1614 | [括号的最大嵌套深度](../../problems/maximum-nesting-depth-of-the-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | +| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1598 | [文件夹操作日志搜集器](../../problems/crawler-log-folder) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1592 | [重新排列单词间的空格](../../problems/rearrange-spaces-between-words) | [[字符串](../string/README.md)] | Easy | -| 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | +| 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1576 | [替换所有的问号](../../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | [[字符串](../string/README.md)] | Easy | -| 1573 | [分割字符串的方案数](../../problems/number-of-ways-to-split-a-string) | [[字符串](../string/README.md)] | Medium | +| 1573 | [分割字符串的方案数](../../problems/number-of-ways-to-split-a-string) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 1556 | [千位分隔数](../../problems/thousand-separator) | [[字符串](../string/README.md)] | Easy | -| 1545 | [找出第 N 个二进制字符串中的第 K 位](../../problems/find-kth-bit-in-nth-binary-string) | [[字符串](../string/README.md)] | Medium | +| 1554 | [只有一个不同字符的字符串](../../problems/strings-differ-by-one-character) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1545 | [找出第 N 个二进制字符串中的第 K 位](../../problems/find-kth-bit-in-nth-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | | 1544 | [整理字符串](../../problems/make-the-string-great) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | -| 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Hard | -| 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[字符串](../string/README.md)] | Medium | -| 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1528 | [重新排列字符串](../../problems/shuffle-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | | 1513 | [仅含 1 的子串数](../../problems/number-of-substrings-with-only-1s) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 1507 | [转变日期格式](../../problems/reformat-date) | [[字符串](../string/README.md)] | Easy | -| 1496 | [判断路径是否相交](../../problems/path-crossing) | [[字符串](../string/README.md)] | Easy | -| 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1455 | [检查单词是否为句中其他单词的前缀](../../problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | [[字符串](../string/README.md)] | Easy | -| 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | -| 1449 | [数位成本和为目标值的最大数字](../../problems/form-largest-integer-with-digits-that-add-up-to-target) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1505 | [最多 K 次交换相邻数位后得到的最小整数](../../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | [[贪心](../greedy/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[字符串](../string/README.md)] | Hard | +| 1496 | [判断路径是否相交](../../problems/path-crossing) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1487 | [保证文件名唯一](../../problems/making-file-names-unique) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1456 | [定长子串中元音的最大数目](../../problems/maximum-number-of-vowels-in-a-substring-of-given-length) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1455 | [检查单词是否为句中其他单词的前缀](../../problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Easy | +| 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 1446 | [连续字符](../../problems/consecutive-characters) | [[字符串](../string/README.md)] | Easy | -| 1436 | [旅行终点站](../../problems/destination-city) | [[字符串](../string/README.md)] | Easy | -| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1432 | [改变一个整数能得到的最大差值](../../problems/max-difference-you-can-get-from-changing-an-integer) | [[字符串](../string/README.md)] | Medium | +| 1436 | [旅行终点站](../../problems/destination-city) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1427 | [字符串的左右移](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 1422 | [分割字符串的最大得分](../../problems/maximum-score-after-splitting-a-string) | [[字符串](../string/README.md)] | Easy | -| 1419 | [数青蛙](../../problems/minimum-number-of-frogs-croaking) | [[字符串](../string/README.md)] | Medium | +| 1419 | [数青蛙](../../problems/minimum-number-of-frogs-croaking) | [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 1418 | [点菜展示表](../../problems/display-table-of-food-orders-in-a-restaurant) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] | Medium | | 1417 | [重新格式化字符串](../../problems/reformat-the-string) | [[字符串](../string/README.md)] | Easy | -| 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1408 | [数组中的字符串匹配](../../problems/string-matching-in-an-array) | [[字符串](../string/README.md)] | Easy | +| 1416 | [恢复数组](../../problems/restore-the-array) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1415 | [长度为 n 的开心字符串中字典序第 k 小的字符串](../../problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1410 | [HTML 实体解析器](../../problems/html-entity-parser) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1408 | [数组中的字符串匹配](../../problems/string-matching-in-an-array) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Easy | +| 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1404 | [将二进制表示减到 1 的步骤数](../../problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 1392 | [最长快乐前缀](../../problems/longest-happy-prefix) | [[字符串](../string/README.md)] | Hard | +| 1400 | [构造 K 个回文字符串](../../problems/construct-k-palindrome-strings) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 1397 | [找到所有好字符串](../../problems/find-all-good-strings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[字符串匹配](../string-matching/README.md)] | Hard | +| 1396 | [设计地铁系统](../../problems/design-underground-system) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1392 | [最长快乐前缀](../../problems/longest-happy-prefix) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1374 | [生成每种字符都是奇数个的字符串](../../problems/generate-a-string-with-characters-that-have-odd-counts) | [[字符串](../string/README.md)] | Easy | -| 1371 | [每个元音包含偶数次的最长子字符串](../../problems/find-the-longest-substring-containing-vowels-in-even-counts) | [[字符串](../string/README.md)] | Medium | -| 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Easy | -| 1358 | [包含所有三种字符的子字符串数目](../../problems/number-of-substrings-containing-all-three-characters) | [[字符串](../string/README.md)] | Medium | -| 1347 | [制造字母异位词的最小步骤数](../../problems/minimum-number-of-steps-to-make-two-strings-anagram) | [[字符串](../string/README.md)] | Medium | -| 1332 | [删除回文子序列](../../problems/remove-palindromic-subsequences) | [[字符串](../string/README.md)] | Easy | -| 1328 | [破坏回文串](../../problems/break-a-palindrome) | [[字符串](../string/README.md)] | Medium | -| 1324 | [竖直打印单词](../../problems/print-words-vertically) | [[字符串](../string/README.md)] | Medium | -| 1316 | [不同的循环子字符串](../../problems/distinct-echo-substrings) | [[字符串](../string/README.md)] | Hard | -| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1371 | [每个元音包含偶数次的最长子字符串](../../problems/find-the-longest-substring-containing-vowels-in-even-counts) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1360 | [日期之间隔几天](../../problems/number-of-days-between-two-dates) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1358 | [包含所有三种字符的子字符串数目](../../problems/number-of-substrings-containing-all-three-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1347 | [制造字母异位词的最小步骤数](../../problems/minimum-number-of-steps-to-make-two-strings-anagram) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1332 | [删除回文子序列](../../problems/remove-palindromic-subsequences) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 1328 | [破坏回文串](../../problems/break-a-palindrome) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1324 | [竖直打印单词](../../problems/print-words-vertically) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1320 | [二指输入的的最小距离](../../problems/minimum-distance-to-type-a-word-using-two-fingers) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1316 | [不同的循环子字符串](../../problems/distinct-echo-substrings) | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1312 | [让字符串成为回文串的最少插入次数](../../problems/minimum-insertion-steps-to-make-a-string-palindrome) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1309 | [解码字母到整数映射](../../problems/decrypt-string-from-alphabet-to-integer-mapping) | [[字符串](../string/README.md)] | Easy | -| 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 1307 | [口算难题](../../problems/verbal-arithmetic-puzzle) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 1297 | [子串的最大出现次数](../../problems/maximum-number-of-occurrences-of-a-substring) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 1278 | [分割回文串 III](../../problems/palindrome-partitioning-iii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1271 | [十六进制魔术数字](../../problems/hexspeak) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 1268 | [搜索推荐系统](../../problems/search-suggestions-system) | [[字符串](../string/README.md)] | Medium | +| 1268 | [搜索推荐系统](../../problems/search-suggestions-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1258 | [近义词句子](../../problems/synonymous-sentences) 🔒 | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1257 | [最小公共区域](../../problems/smallest-common-region) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1256 | [加密数字](../../problems/encode-number) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1255 | [得分最高的单词集合](../../problems/maximum-score-words-formed-by-letters) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1249 | [移除无效的括号](../../problems/minimum-remove-to-make-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1247 | [交换字符使得字符串相同](../../problems/minimum-swaps-to-make-strings-equal) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1233 | [删除子文件夹](../../problems/remove-sub-folders-from-the-filesystem) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | -| 1221 | [分割平衡字符串](../../problems/split-a-string-in-balanced-strings) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | +| 1247 | [交换字符使得字符串相同](../../problems/minimum-swaps-to-make-strings-equal) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1239 | [串联字符串的最大长度](../../problems/maximum-length-of-a-concatenated-string-with-unique-characters) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1236 | [网络爬虫](../../problems/web-crawler) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1233 | [删除子文件夹](../../problems/remove-sub-folders-from-the-filesystem) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1221 | [分割平衡字符串](../../problems/split-a-string-in-balanced-strings) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 1216 | [验证回文字符串 III](../../problems/valid-palindrome-iii) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1189 | [“气球” 的最大数量](../../problems/maximum-number-of-balloons) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 1181 | [前后拼接](../../problems/before-and-after-puzzle) 🔒 | [[字符串](../string/README.md)] | Medium | +| 1209 | [删除字符串中的所有相邻重复项 II](../../problems/remove-all-adjacent-duplicates-in-string-ii) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1190 | [反转每对括号间的子串](../../problems/reverse-substrings-between-each-pair-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 1189 | [“气球” 的最大数量](../../problems/maximum-number-of-balloons) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1181 | [前后拼接](../../problems/before-and-after-puzzle) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 1180 | [统计只含单一字母的子串](../../problems/count-substrings-with-only-one-distinct-letter) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 1177 | [构建回文串检测](../../problems/can-make-palindrome-from-substring) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | -| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1169 | [查询无效交易](../../problems/invalid-transactions) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | -| 1165 | [单行键盘](../../problems/single-row-keyboard) 🔒 | [[字符串](../string/README.md)] | Easy | -| 1163 | [按字典序排在最后的子串](../../problems/last-substring-in-lexicographical-order) | [[字符串](../string/README.md)] | Hard | -| 1156 | [单字符重复子串的最大长度](../../problems/swap-for-longest-repeated-character-substring) | [[字符串](../string/README.md)] | Medium | +| 1178 | [猜字谜](../../problems/number-of-valid-words-for-each-puzzle) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 1177 | [构建回文串检测](../../problems/can-make-palindrome-from-substring) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1169 | [查询无效交易](../../problems/invalid-transactions) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1165 | [单行键盘](../../problems/single-row-keyboard) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1163 | [按字典序排在最后的子串](../../problems/last-substring-in-lexicographical-order) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 1160 | [拼写单词](../../problems/find-words-that-can-be-formed-by-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1156 | [单字符重复子串的最大长度](../../problems/swap-for-longest-repeated-character-substring) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1154 | [一年中的第几天](../../problems/day-of-the-year) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1153 | [字符串转化](../../problems/string-transforms-into-another-string) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 1147 | [段式回文](../../problems/longest-chunked-palindrome-decomposition) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1143 | [最长公共子序列](../../problems/longest-common-subsequence) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1138 | [字母板上的路径](../../problems/alphabet-board-path) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1119 | [删去字符串中的元音](../../problems/remove-vowels-from-a-string) 🔒 | [[字符串](../string/README.md)] | Easy | +| 1111 | [有效括号的嵌套深度](../../problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | | 1108 | [IP 地址无效化](../../problems/defanging-an-ip-address) | [[字符串](../string/README.md)] | Easy | -| 1106 | [解析布尔表达式](../../problems/parsing-a-boolean-expression) | [[字符串](../string/README.md)] | Hard | -| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1096 | [花括号展开 II](../../problems/brace-expansion-ii) | [[字符串](../string/README.md)] | Hard | -| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | -| 1071 | [字符串的最大公因子](../../problems/greatest-common-divisor-of-strings) | [[字符串](../string/README.md)] | Easy | -| 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Easy | -| 1062 | [最长重复子串](../../problems/longest-repeating-substring) 🔒 | [[字符串](../string/README.md)] | Medium | -| 1023 | [驼峰式匹配](../../problems/camelcase-matching) | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | +| 1106 | [解析布尔表达式](../../problems/parsing-a-boolean-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | +| 1100 | [长度为 K 的无重复字符子串](../../problems/find-k-length-substrings-with-no-repeated-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1096 | [花括号展开 II](../../problems/brace-expansion-ii) | [[栈](../stack/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 1092 | [最短公共超序列](../../problems/shortest-common-supersequence) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1087 | [花括号展开](../../problems/brace-expansion) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1079 | [活字印刷](../../problems/letter-tile-possibilities) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1078 | [Bigram 分词](../../problems/occurrences-after-bigram) | [[字符串](../string/README.md)] | Easy | +| 1071 | [字符串的最大公因子](../../problems/greatest-common-divisor-of-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1062 | [最长重复子串](../../problems/longest-repeating-substring) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1061 | [按字典序排列最小的等效字符串](../../problems/lexicographically-smallest-equivalent-string) 🔒 | [[并查集](../union-find/README.md)] [[字符串](../string/README.md)] | Medium | +| 1058 | [最小化舍入误差以满足目标](../../problems/minimize-rounding-error-to-meet-target) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 1055 | [形成字符串的最短路径](../../problems/shortest-way-to-form-string) 🔒 | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1048 | [最长字符串链](../../problems/longest-string-chain) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1047 | [删除字符串中的所有相邻重复项](../../problems/remove-all-adjacent-duplicates-in-string) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | +| 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1041 | [困于环中的机器人](../../problems/robot-bounded-in-circle) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1032 | [字符流](../../problems/stream-of-characters) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[数据流](../data-stream/README.md)] | Hard | +| 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 1023 | [驼峰式匹配](../../problems/camelcase-matching) | [[字典树](../trie/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 1021 | [删除最外层的括号](../../problems/remove-outermost-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | | 1016 | [子串能表示从 1 到 N 数字的二进制串](../../problems/binary-string-with-substrings-representing-1-to-n) | [[字符串](../string/README.md)] | Medium | | 1003 | [检查替换后的词是否有效](../../problems/check-if-word-is-valid-after-substitutions) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 937 | [重新排列日志文件](../../problems/reorder-data-in-log-files) | [[字符串](../string/README.md)] | Easy | -| 936 | [戳印序列](../../problems/stamping-the-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | -| 929 | [独特的电子邮件地址](../../problems/unique-email-addresses) | [[字符串](../string/README.md)] | Easy | +| 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 990 | [等式方程的可满足性](../../problems/satisfiability-of-equality-equations) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 988 | [从叶结点开始的最小字符串](../../problems/smallest-string-starting-from-leaf) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 984 | [不含 AAA 或 BBB 的字符串](../../problems/string-without-aaa-or-bbb) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 972 | [相等的有理数](../../problems/equal-rational-numbers) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 960 | [删列造序 III](../../problems/delete-columns-to-make-sorted-iii) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 955 | [删列造序 II](../../problems/delete-columns-to-make-sorted-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 953 | [验证外星语词典](../../problems/verifying-an-alien-dictionary) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 949 | [给定数字能组成的最大时间](../../problems/largest-time-for-given-digits) | [[字符串](../string/README.md)] [[枚举](../enumeration/README.md)] | Medium | +| 944 | [删列造序](../../problems/delete-columns-to-make-sorted) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 943 | [最短超级串](../../problems/find-the-shortest-superstring) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 942 | [增减字符串匹配](../../problems/di-string-match) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 940 | [不同的子序列 II](../../problems/distinct-subsequences-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 937 | [重新排列日志文件](../../problems/reorder-data-in-log-files) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 936 | [戳印序列](../../problems/stamping-the-sequence) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[字符串](../string/README.md)] | Hard | +| 929 | [独特的电子邮件地址](../../problems/unique-email-addresses) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 926 | [将字符串翻转到单调递增](../../problems/flip-string-to-monotone-increasing) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 925 | [长按键入](../../problems/long-pressed-name) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 917 | [仅仅反转字母](../../problems/reverse-only-letters) | [[字符串](../string/README.md)] | Easy | -| 916 | [单词子集](../../problems/word-subsets) | [[字符串](../string/README.md)] | Medium | -| 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[字符串](../string/README.md)] | Easy | -| 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[字符串](../string/README.md)] | Medium | -| 859 | [亲密字符串](../../problems/buddy-strings) | [[字符串](../string/README.md)] | Easy | +| 921 | [使括号有效的最少添加](../../problems/minimum-add-to-make-parentheses-valid) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 917 | [仅仅反转字母](../../problems/reverse-only-letters) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 916 | [单词子集](../../problems/word-subsets) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | +| 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 884 | [两句话中的不常见单词](../../problems/uncommon-words-from-two-sentences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 880 | [索引处的解码字符串](../../problems/decoded-string-at-index) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 859 | [亲密字符串](../../problems/buddy-strings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 856 | [括号的分数](../../problems/score-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 848 | [字母移位](../../problems/shifting-letters) | [[字符串](../string/README.md)] | Medium | -| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 833 | [字符串中的查找与替换](../../problems/find-and-replace-in-string) | [[字符串](../string/README.md)] | Medium | +| 854 | [相似度为 K 的字符串](../../problems/k-similar-strings) | [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] | Hard | +| 848 | [字母移位](../../problems/shifting-letters) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 843 | [猜猜这个单词](../../problems/guess-the-word) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] [[交互](../interactive/README.md)] | Hard | +| 842 | [将数组拆分成斐波那契序列](../../problems/split-array-into-fibonacci-sequence) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[字符串](../string/README.md)] | Hard | +| 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 833 | [字符串中的查找与替换](../../problems/find-and-replace-in-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 831 | [隐藏个人信息](../../problems/masking-personal-information) | [[字符串](../string/README.md)] | Medium | +| 830 | [较大分组的位置](../../problems/positions-of-large-groups) | [[字符串](../string/README.md)] | Easy | +| 828 | [统计子串中的唯一字符](../../problems/count-unique-characters-of-all-substrings-of-a-given-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 824 | [山羊拉丁文](../../problems/goat-latin) | [[字符串](../string/README.md)] | Easy | -| 819 | [最常见的单词](../../problems/most-common-word) | [[字符串](../string/README.md)] | Easy | -| 816 | [模糊坐标](../../problems/ambiguous-coordinates) | [[字符串](../string/README.md)] | Medium | -| 809 | [情感丰富的文字](../../problems/expressive-words) | [[字符串](../string/README.md)] | Medium | -| 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[字符串](../string/README.md)] | Easy | -| 800 | [相似 RGB 颜色](../../problems/similar-rgb-color) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 791 | [自定义字符串排序](../../problems/custom-sort-string) | [[字符串](../string/README.md)] | Medium | -| 788 | [旋转数字](../../problems/rotated-digits) | [[字符串](../string/README.md)] | Easy | -| 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | -| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | -| 767 | [重构字符串](../../problems/reorganize-string) | [[堆](../heap/README.md)] [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Medium | +| 821 | [字符的最短距离](../../problems/shortest-distance-to-a-character) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 820 | [单词的压缩编码](../../problems/short-encoding-of-words) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 819 | [最常见的单词](../../problems/most-common-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 816 | [模糊坐标](../../problems/ambiguous-coordinates) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 809 | [情感丰富的文字](../../problems/expressive-words) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 806 | [写字符串需要的行数](../../problems/number-of-lines-to-write-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 800 | [相似 RGB 颜色](../../problems/similar-rgb-color) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[枚举](../enumeration/README.md)] | Easy | +| 796 | [旋转字符串](../../problems/rotate-string) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Easy | +| 794 | [有效的井字游戏](../../problems/valid-tic-tac-toe-state) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 792 | [匹配子序列的单词数](../../problems/number-of-matching-subsequences) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 791 | [自定义字符串排序](../../problems/custom-sort-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 784 | [字母大小写全排列](../../problems/letter-case-permutation) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 777 | [在LR字符串中交换相邻字符](../../problems/swap-adjacent-in-lr-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 771 | [宝石与石头](../../problems/jewels-and-stones) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 767 | [重构字符串](../../problems/reorganize-string) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 763 | [划分字母区间](../../problems/partition-labels) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 761 | [特殊的二进制序列](../../problems/special-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Hard | -| 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字符串](../string/README.md)] | Medium | -| 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[字符串](../string/README.md)] | Hard | +| 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 751 | [IP 到 CIDR](../../problems/ip-to-cidr) 🔒 | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | +| 748 | [最短补全词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 745 | [前缀和后缀搜索](../../problems/prefix-and-suffix-search) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Hard | +| 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 722 | [删除注释](../../problems/remove-comments) | [[字符串](../string/README.md)] | Medium | +| 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 722 | [删除注释](../../problems/remove-comments) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 721 | [账户合并](../../problems/accounts-merge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 712 | [两个字符串的最小ASCII删除和](../../problems/minimum-ascii-delete-sum-for-two-strings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 709 | [转换成小写字母](../../problems/to-lower-case) | [[字符串](../string/README.md)] | Easy | -| 696 | [计数二进制子串](../../problems/count-binary-substrings) | [[字符串](../string/README.md)] | Easy | -| 686 | [重复叠加字符串匹配](../../problems/repeated-string-match) | [[字符串](../string/README.md)] | Medium | -| 681 | [最近时刻](../../problems/next-closest-time) 🔒 | [[字符串](../string/README.md)] | Medium | -| 680 | [验证回文字符串 Ⅱ](../../problems/valid-palindrome-ii) | [[字符串](../string/README.md)] | Easy | -| 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[字符串](../string/README.md)] | Medium | -| 657 | [机器人能否返回原点](../../problems/robot-return-to-origin) | [[字符串](../string/README.md)] | Easy | +| 696 | [计数二进制子串](../../problems/count-binary-substrings) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 686 | [重复叠加字符串匹配](../../problems/repeated-string-match) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 681 | [最近时刻](../../problems/next-closest-time) 🔒 | [[字符串](../string/README.md)] [[枚举](../enumeration/README.md)] | Medium | +| 680 | [验证回文字符串 Ⅱ](../../problems/valid-palindrome-ii) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 677 | [键值映射](../../problems/map-sum-pairs) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 676 | [实现一个魔法字典](../../problems/implement-magic-dictionary) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 664 | [奇怪的打印机](../../problems/strange-printer) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 657 | [机器人能否返回原点](../../problems/robot-return-to-origin) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 649 | [Dota2 参议院](../../problems/dota2-senate) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[字符串](../string/README.md)] | Medium | +| 648 | [单词替换](../../problems/replace-words) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 647 | [回文子串](../../problems/palindromic-substrings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[字符串](../string/README.md)] | Medium | -| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 616 | [给字符串添加加粗标签](../../problems/add-bold-tag-in-string) 🔒 | [[字符串](../string/README.md)] | Medium | -| 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 606 | [根据二叉树创建字符串](../../problems/construct-string-from-binary-tree) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Easy | +| 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[数据流](../data-stream/README.md)] | Hard | +| 640 | [求解方程](../../problems/solve-the-equation) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 639 | [解码方法 II](../../problems/decode-ways-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 616 | [给字符串添加加粗标签](../../problems/add-bold-tag-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 609 | [在系统中查找重复文件](../../problems/find-duplicate-file-in-system) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 606 | [根据二叉树创建字符串](../../problems/construct-string-from-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[迭代器](../iterator/README.md)] | Easy | +| 599 | [两个列表的最小索引总和](../../problems/minimum-index-sum-of-two-lists) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 592 | [分数加减运算](../../problems/fraction-addition-and-subtraction) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | | 591 | [标签验证器](../../problems/tag-validator) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Hard | -| 583 | [两个字符串的删除操作](../../problems/delete-operation-for-two-strings) | [[字符串](../string/README.md)] | Medium | -| 564 | [寻找最近的回文数](../../problems/find-the-closest-palindrome) | [[字符串](../string/README.md)] | Hard | -| 557 | [反转字符串中的单词 III](../../problems/reverse-words-in-a-string-iii) | [[字符串](../string/README.md)] | Easy | -| 556 | [下一个更大元素 III](../../problems/next-greater-element-iii) | [[字符串](../string/README.md)] | Medium | -| 555 | [分割连接字符串](../../problems/split-concatenated-strings) 🔒 | [[字符串](../string/README.md)] | Medium | -| 553 | [最优除法](../../problems/optimal-division) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 588 | [设计内存文件系统](../../problems/design-in-memory-file-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 583 | [两个字符串的删除操作](../../problems/delete-operation-for-two-strings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 567 | [字符串的排列](../../problems/permutation-in-string) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 564 | [寻找最近的回文数](../../problems/find-the-closest-palindrome) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 557 | [反转字符串中的单词 III](../../problems/reverse-words-in-a-string-iii) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 556 | [下一个更大元素 III](../../problems/next-greater-element-iii) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 555 | [分割连接字符串](../../problems/split-concatenated-strings) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 551 | [学生出勤记录 I](../../problems/student-attendance-record-i) | [[字符串](../string/README.md)] | Easy | -| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | -| 541 | [反转字符串 II](../../problems/reverse-string-ii) | [[字符串](../string/README.md)] | Easy | -| 539 | [最小时间差](../../problems/minimum-time-difference) | [[字符串](../string/README.md)] | Medium | -| 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | -| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[排序](../sort/README.md)] [[字符串](../string/README.md)] | Hard | -| 522 | [最长特殊序列 II](../../problems/longest-uncommon-subsequence-ii) | [[字符串](../string/README.md)] | Medium | -| 521 | [最长特殊序列 Ⅰ](../../problems/longest-uncommon-subsequence-i) | [[脑筋急转弯](../brainteaser/README.md)] [[字符串](../string/README.md)] | Easy | +| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 541 | [反转字符串 II](../../problems/reverse-string-ii) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 539 | [最小时间差](../../problems/minimum-time-difference) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 535 | [TinyURL 的加密与解密](../../problems/encode-and-decode-tinyurl) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Medium | +| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[贪心](../greedy/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | +| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 522 | [最长特殊序列 II](../../problems/longest-uncommon-subsequence-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 521 | [最长特殊序列 Ⅰ](../../problems/longest-uncommon-subsequence-i) | [[字符串](../string/README.md)] | Easy | | 520 | [检测大写字母](../../problems/detect-capital) | [[字符串](../string/README.md)] | Easy | +| 516 | [最长回文子序列](../../problems/longest-palindromic-subsequence) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 500 | [键盘行](../../problems/keyboard-row) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 488 | [祖玛游戏](../../problems/zuma-game) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 482 | [密钥格式化](../../problems/license-key-formatting) | [[字符串](../string/README.md)] | Easy | +| 481 | [神奇字符串](../../problems/magical-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 474 | [一和零](../../problems/ones-and-zeroes) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 471 | [编码最短长度的字符串](../../problems/encode-string-with-shortest-length) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 468 | [验证IP地址](../../problems/validate-ip-address) | [[字符串](../string/README.md)] | Medium | -| 459 | [重复的子字符串](../../problems/repeated-substring-pattern) | [[字符串](../string/README.md)] | Easy | -| 443 | [压缩字符串](../../problems/string-compression) | [[字符串](../string/README.md)] | Medium | +| 467 | [环绕字符串中唯一的子字符串](../../problems/unique-substrings-in-wraparound-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 466 | [统计重复个数](../../problems/count-the-repetitions) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 459 | [重复的子字符串](../../problems/repeated-substring-pattern) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Easy | +| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 449 | [序列化和反序列化二叉搜索树](../../problems/serialize-and-deserialize-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 443 | [压缩字符串](../../problems/string-compression) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 439 | [三元表达式解析器](../../problems/ternary-expression-parser) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | +| 438 | [找到字符串中所有字母异位词](../../problems/find-all-anagrams-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 434 | [字符串中的单词数](../../problems/number-of-segments-in-a-string) | [[字符串](../string/README.md)] | Easy | -| 415 | [字符串相加](../../problems/add-strings) | [[字符串](../string/README.md)] | Easy | -| 408 | [有效单词缩写](../../problems/valid-word-abbreviation) 🔒 | [[字符串](../string/README.md)] | Easy | -| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 385 | [迷你语法分析器](../../problems/mini-parser) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 383 | [赎金信](../../problems/ransom-note) | [[字符串](../string/README.md)] | Easy | +| 433 | [最小基因变化](../../problems/minimum-genetic-mutation) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 428 | [序列化和反序列化 N 叉树](../../problems/serialize-and-deserialize-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] | Hard | +| 425 | [单词方块](../../problems/word-squares) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 423 | [从英文中重建数字](../../problems/reconstruct-original-digits-from-english) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 420 | [强密码检验器](../../problems/strong-password-checker) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 415 | [字符串相加](../../problems/add-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 412 | [Fizz Buzz](../../problems/fizz-buzz) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 411 | [最短独占单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 409 | [最长回文串](../../problems/longest-palindrome) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 408 | [有效单词缩写](../../problems/valid-word-abbreviation) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 402 | [移掉 K 位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 395 | [至少有 K 个重复字符的最长子串](../../problems/longest-substring-with-at-least-k-repeating-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | +| 392 | [判断子序列](../../problems/is-subsequence) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 388 | [文件的最长绝对路径](../../problems/longest-absolute-file-path) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] | Medium | +| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[队列](../queue/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 385 | [迷你语法分析器](../../problems/mini-parser) | [[栈](../stack/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] | Medium | +| 383 | [赎金信](../../problems/ransom-note) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 345 | [反转字符串中的元音字母](../../problems/reverse-vowels-of-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 344 | [反转字符串](../../problems/reverse-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | -| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 344 | [反转字符串](../../problems/reverse-string) | [[递归](../recursion/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 331 | [验证二叉树的前序序列化](../../problems/verify-preorder-serialization-of-a-binary-tree) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 320 | [列举单词的全部缩写](../../problems/generalized-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 318 | [最大单词长度乘积](../../problems/maximum-product-of-word-lengths) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 306 | [累加数](../../problems/additive-number) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 301 | [删除无效的括号](../../problems/remove-invalid-parentheses) | [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 299 | [猜数字游戏](../../problems/bulls-and-cows) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 293 | [翻转游戏](../../problems/flip-game) 🔒 | [[字符串](../string/README.md)] | Easy | -| 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | -| 271 | [字符串的编码与解码](../../problems/encode-and-decode-strings) 🔒 | [[字符串](../string/README.md)] | Medium | -| 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 214 | [最短回文串](../../problems/shortest-palindrome) | [[字符串](../string/README.md)] | Hard | -| 186 | [翻转字符串里的单词 II](../../problems/reverse-words-in-a-string-ii) 🔒 | [[字符串](../string/README.md)] | Medium | -| 165 | [比较版本号](../../problems/compare-version-numbers) | [[字符串](../string/README.md)] | Medium | -| 161 | [相隔为 1 的编辑距离](../../problems/one-edit-distance) 🔒 | [[字符串](../string/README.md)] | Medium | -| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 158 | [用 Read4 读取 N 个字符 II](../../problems/read-n-characters-given-read4-ii-call-multiple-times) 🔒 | [[字符串](../string/README.md)] | Hard | -| 157 | [用 Read4 读取 N 个字符](../../problems/read-n-characters-given-read4) 🔒 | [[字符串](../string/README.md)] | Easy | -| 151 | [翻转字符串里的单词](../../problems/reverse-words-in-a-string) | [[字符串](../string/README.md)] | Medium | -| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | +| 291 | [单词规律 II](../../problems/word-pattern-ii) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 290 | [单词规律](../../problems/word-pattern) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 282 | [给表达式添加运算符](../../problems/expression-add-operators) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 271 | [字符串的编码与解码](../../problems/encode-and-decode-strings) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | +| 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 266 | [回文排列](../../problems/palindrome-permutation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | +| 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 246 | [中心对称数](../../problems/strobogrammatic-number) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 245 | [最短单词距离 III](../../problems/shortest-word-distance-iii) 🔒 | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 243 | [最短单词距离](../../problems/shortest-word-distance) 🔒 | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 242 | [有效的字母异位词](../../problems/valid-anagram) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 241 | [为运算表达式设计优先级](../../problems/different-ways-to-add-parentheses) | [[递归](../recursion/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 224 | [基本计算器](../../problems/basic-calculator) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 214 | [最短回文串](../../problems/shortest-palindrome) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | +| 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 205 | [同构字符串](../../problems/isomorphic-strings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 187 | [重复的DNA序列](../../problems/repeated-dna-sequences) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 186 | [翻转字符串里的单词 II](../../problems/reverse-words-in-a-string-ii) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 179 | [最大数](../../problems/largest-number) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 171 | [Excel表列序号](../../problems/excel-sheet-column-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 168 | [Excel表列名称](../../problems/excel-sheet-column-title) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 165 | [比较版本号](../../problems/compare-version-numbers) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 161 | [相隔为 1 的编辑距离](../../problems/one-edit-distance) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 158 | [用 Read4 读取 N 个字符 II](../../problems/read-n-characters-given-read4-ii-call-multiple-times) 🔒 | [[字符串](../string/README.md)] [[交互](../interactive/README.md)] [[模拟](../simulation/README.md)] | Hard | +| 157 | [用 Read4 读取 N 个字符](../../problems/read-n-characters-given-read4) 🔒 | [[字符串](../string/README.md)] [[交互](../interactive/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 151 | [翻转字符串里的单词](../../problems/reverse-words-in-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 140 | [单词拆分 II](../../problems/word-break-ii) | [[字典树](../trie/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 139 | [单词拆分](../../problems/word-break) | [[字典树](../trie/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 132 | [分割回文串 II](../../problems/palindrome-partitioning-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 131 | [分割回文串](../../problems/palindrome-partitioning) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 127 | [单词接龙](../../problems/word-ladder) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 125 | [验证回文串](../../problems/valid-palindrome) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 115 | [不同的子序列](../../problems/distinct-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 97 | [交错字符串](../../problems/interleaving-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 93 | [复原 IP 地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 93 | [复原 IP 地址](../../problems/restore-ip-addresses) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 91 | [解码方法](../../problems/decode-ways) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 87 | [扰乱字符串](../../problems/scramble-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | +| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | | 72 | [编辑距离](../../problems/edit-distance) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 71 | [简化路径](../../problems/simplify-path) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 68 | [文本左右对齐](../../problems/text-justification) | [[字符串](../string/README.md)] | Hard | -| 67 | [二进制求和](../../problems/add-binary) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 65 | [有效数字](../../problems/valid-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | +| 68 | [文本左右对齐](../../problems/text-justification) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Hard | +| 67 | [二进制求和](../../problems/add-binary) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 65 | [有效数字](../../problems/valid-number) | [[字符串](../string/README.md)] | Hard | | 58 | [最后一个单词的长度](../../problems/length-of-last-word) | [[字符串](../string/README.md)] | Easy | -| 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心算法](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | | 38 | [外观数列](../../problems/count-and-say) | [[字符串](../string/README.md)] | Medium | -| 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 32 | [最长有效括号](../../problems/longest-valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Easy | +| 22 | [括号生成](../../problems/generate-parentheses) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 20 | [有效的括号](../../problems/valid-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | -| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | +| 17 | [电话号码的字母组合](../../problems/letter-combinations-of-a-phone-number) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 14 | [最长公共前缀](../../problems/longest-common-prefix) | [[字符串](../string/README.md)] | Easy | -| 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | -| 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | -| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 8 | [字符串转换整数 (atoi)](../../problems/string-to-integer-atoi) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | +| 10 | [正则表达式匹配](../../problems/regular-expression-matching) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 8 | [字符串转换整数 (atoi)](../../problems/string-to-integer-atoi) | [[字符串](../string/README.md)] | Medium | | 6 | [Z 字形变换](../../problems/zigzag-conversion) | [[字符串](../string/README.md)] | Medium | | 5 | [最长回文子串](../../problems/longest-palindromic-substring) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | diff --git a/tag/suffix-array/README.md b/tag/suffix-array/README.md index f01d0740f..363673362 100644 --- a/tag/suffix-array/README.md +++ b/tag/suffix-array/README.md @@ -9,3 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1062 | [最长重复子串](../../problems/longest-repeating-substring) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | diff --git a/tag/tags.json b/tag/tags.json index 98bc0a798..a05a8218f 100644 --- a/tag/tags.json +++ b/tag/tags.json @@ -22,10 +22,10 @@ { "Name": "Greedy", "Slug": "greedy", - "TranslatedName": "贪心算法" + "TranslatedName": "贪心" }, { - "Name": "Depth-first Search", + "Name": "Depth-First Search", "Slug": "depth-first-search", "TranslatedName": "深度优先搜索" }, @@ -45,7 +45,7 @@ "TranslatedName": "二分查找" }, { - "Name": "Breadth-first Search", + "Name": "Breadth-First Search", "Slug": "breadth-first-search", "TranslatedName": "广度优先搜索" }, @@ -62,7 +62,7 @@ { "Name": "Backtracking", "Slug": "backtracking", - "TranslatedName": "回溯算法" + "TranslatedName": "回溯" }, { "Name": "Design", @@ -107,7 +107,7 @@ { "Name": "Sliding Window", "Slug": "sliding-window", - "TranslatedName": "Sliding Window" + "TranslatedName": "滑动窗口" }, { "Name": "Trie", @@ -117,7 +117,7 @@ { "Name": "Divide and Conquer", "Slug": "divide-and-conquer", - "TranslatedName": "分治算法" + "TranslatedName": "分治" }, { "Name": "Ordered Map", @@ -142,7 +142,7 @@ { "Name": "Line Sweep", "Slug": "line-sweep", - "TranslatedName": "Line Sweep" + "TranslatedName": "扫描线" }, { "Name": "Binary Indexed Tree", @@ -182,22 +182,22 @@ { "Name": "Rolling Hash", "Slug": "rolling-hash", - "TranslatedName": "Rolling Hash" + "TranslatedName": "滚动哈希" }, { "Name": "Suffix Array", "Slug": "suffix-array", - "TranslatedName": "Suffix Array" + "TranslatedName": "后缀数组" }, { "Name": "Rejection Sampling", "Slug": "rejection-sampling", - "TranslatedName": "Rejection Sampling" + "TranslatedName": "拒绝采样" }, { "Name": "Reservoir Sampling", "Slug": "reservoir-sampling", - "TranslatedName": "蓄水池抽样" + "TranslatedName": "水塘抽样" }, { "Name": "Meet In The Middle", @@ -207,11 +207,181 @@ { "Name": "Memoization", "Slug": "memoization", - "TranslatedName": "记忆化" + "TranslatedName": "记忆化搜索" }, { "Name": "OOP", "Slug": "oop", "TranslatedName": "OOP" + }, + { + "Name": "Sorting", + "Slug": "sorting", + "TranslatedName": "排序" + }, + { + "Name": "Heap (Priority Queue)", + "Slug": "heap-priority-queue", + "TranslatedName": "堆(优先队列)" + }, + { + "Name": "Ordered Set", + "Slug": "ordered-set", + "TranslatedName": "有序集合" + }, + { + "Name": "Hash Function", + "Slug": "hash-function", + "TranslatedName": "哈希函数" + }, + { + "Name": "String Matching", + "Slug": "string-matching", + "TranslatedName": "字符串匹配" + }, + { + "Name": "Randomized", + "Slug": "randomized", + "TranslatedName": "随机化" + }, + { + "Name": "Prefix Sum", + "Slug": "prefix-sum", + "TranslatedName": "前缀和" + }, + { + "Name": "Probability and Statistics", + "Slug": "probability-and-statistics", + "TranslatedName": "概率与统计" + }, + { + "Name": "Simulation", + "Slug": "simulation", + "TranslatedName": "模拟" + }, + { + "Name": "Monotonic Queue", + "Slug": "monotonic-queue", + "TranslatedName": "单调队列" + }, + { + "Name": "Data Stream", + "Slug": "data-stream", + "TranslatedName": "数据流" + }, + { + "Name": "Counting", + "Slug": "counting", + "TranslatedName": "计数" + }, + { + "Name": "Matrix", + "Slug": "matrix", + "TranslatedName": "矩阵" + }, + { + "Name": "Iterator", + "Slug": "iterator", + "TranslatedName": "迭代器" + }, + { + "Name": "Quickselect", + "Slug": "quickselect", + "TranslatedName": "快速选择" + }, + { + "Name": "Merge Sort", + "Slug": "merge-sort", + "TranslatedName": "归并排序" + }, + { + "Name": "Binary Tree", + "Slug": "binary-tree", + "TranslatedName": "二叉树" + }, + { + "Name": "Combinatorics", + "Slug": "combinatorics", + "TranslatedName": "组合数学" + }, + { + "Name": "Shortest Path", + "Slug": "shortest-path", + "TranslatedName": "最短路" + }, + { + "Name": "Interactive", + "Slug": "interactive", + "TranslatedName": "交互" + }, + { + "Name": "Bucket Sort", + "Slug": "bucket-sort", + "TranslatedName": "桶排序" + }, + { + "Name": "Counting Sort", + "Slug": "counting-sort", + "TranslatedName": "计数排序" + }, + { + "Name": "Radix Sort", + "Slug": "radix-sort", + "TranslatedName": "基数排序" + }, + { + "Name": "Monotonic Stack", + "Slug": "monotonic-stack", + "TranslatedName": "单调栈" + }, + { + "Name": "Minimum Spanning Tree", + "Slug": "minimum-spanning-tree", + "TranslatedName": "最小生成树" + }, + { + "Name": "Strongly Connected Component", + "Slug": "strongly-connected-component", + "TranslatedName": "强连通分量" + }, + { + "Name": "Game Theory", + "Slug": "game-theory", + "TranslatedName": "博弈" + }, + { + "Name": "Bitmask", + "Slug": "bitmask", + "TranslatedName": "状态压缩" + }, + { + "Name": "Concurrency", + "Slug": "concurrency", + "TranslatedName": "多线程" + }, + { + "Name": "Doubly-Linked List", + "Slug": "doubly-linked-list", + "TranslatedName": "双向链表" + }, + { + "Name": "Enumeration", + "Slug": "enumeration", + "TranslatedName": "枚举" + }, + { + "Name": "Number Theory", + "Slug": "number-theory", + "TranslatedName": "数论" + }, + { + "Name": "Biconnected Component", + "Slug": "biconnected-component", + "TranslatedName": "双连通分量" + }, + { + "Name": "Eulerian Circuit", + "Slug": "eulerian-circuit", + "TranslatedName": "欧拉回路" } ] \ No newline at end of file diff --git a/tag/topological-sort/README.md b/tag/topological-sort/README.md index ec0d2b8df..1edd301f6 100644 --- a/tag/topological-sort/README.md +++ b/tag/topological-sort/README.md @@ -9,10 +9,21 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | -| 444 | [序列重建](../../problems/sequence-reconstruction) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | -| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化](../memoization/README.md)] | Hard | -| 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] [[计数](../counting/README.md)] | Hard | +| 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1591 | [奇怪的打印机 II](../../problems/strange-printer-ii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1462 | [课程表 IV](../../problems/course-schedule-iv) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 1136 | [平行课程](../../problems/parallel-courses) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 851 | [喧闹和富有](../../problems/loud-and-rich) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] | Medium | +| 802 | [找到最终的安全状态](../../problems/find-eventual-safe-states) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 631 | [设计 Excel 求和公式](../../problems/design-excel-sum-formula) 🔒 | [[图](../graph/README.md)] [[设计](../design/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 444 | [序列重建](../../problems/sequence-reconstruction) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] | Medium | +| 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 310 | [最小高度树](../../problems/minimum-height-trees) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | +| 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | | 210 | [课程表 II](../../problems/course-schedule-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | | 207 | [课程表](../../problems/course-schedule) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | diff --git a/tag/tree/README.md b/tag/tree/README.md index ee23e51bc..6cb55ab4e 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,161 +9,180 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | -| 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] | Hard | -| 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1660 | [纠正二叉树](../../problems/correct-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | -| 1650 | [二叉树的最近公共祖先 III](../../problems/lowest-common-ancestor-of-a-binary-tree-iii) 🔒 | [[树](../tree/README.md)] | Medium | -| 1644 | [二叉树的最近公共祖先 II](../../problems/lowest-common-ancestor-of-a-binary-tree-ii) 🔒 | [[树](../tree/README.md)] | Medium | -| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1609 | [奇偶树](../../problems/even-odd-tree) | [[树](../tree/README.md)] | Medium | -| 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Hard | -| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1516 | [移动 N 叉树的子树](../../problems/move-sub-tree-of-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard | +| 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1660 | [纠正二叉树](../../problems/correct-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1650 | [二叉树的最近公共祖先 III](../../problems/lowest-common-ancestor-of-a-binary-tree-iii) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1644 | [二叉树的最近公共祖先 II](../../problems/lowest-common-ancestor-of-a-binary-tree-ii) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[数学](../math/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1609 | [奇偶树](../../problems/even-odd-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1522 | [N 叉树的直径](../../problems/diameter-of-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | +| 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1516 | [移动 N 叉树的子树](../../problems/move-sub-tree-of-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | +| 1506 | [找到 N 叉树的根节点](../../problems/find-root-of-n-ary-tree) 🔒 | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1469 | [寻找所有的独生节点](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 1466 | [重新规划路线](../../problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1430 | [判断给定的序列是否是二叉树从根到叶的路径](../../problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | -| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1325 | [删除给定值的叶子节点](../../problems/delete-leaves-with-a-given-value) | [[树](../tree/README.md)] | Medium | -| 1315 | [祖父节点值为偶数的节点和](../../problems/sum-of-nodes-with-even-valued-grandparent) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[排序](../sort/README.md)] [[树](../tree/README.md)] | Medium | -| 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1257 | [最小公共区域](../../problems/smallest-common-region) 🔒 | [[树](../tree/README.md)] | Medium | +| 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1483 | [树节点的第 K 个祖先](../../problems/kth-ancestor-of-a-tree-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1469 | [寻找所有的独生节点](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1443 | [收集树上所有苹果的最少时间](../../problems/minimum-time-to-collect-all-apples-in-a-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1430 | [判断给定的序列是否是二叉树从根到叶的路径](../../problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1382 | [将二叉搜索树变平衡](../../problems/balance-a-binary-search-tree) | [[贪心](../greedy/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1377 | [T 秒后青蛙的位置](../../problems/frog-position-after-t-seconds) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Hard | +| 1376 | [通知所有员工所需的时间](../../problems/time-needed-to-inform-all-employees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1361 | [验证二叉树](../../problems/validate-binary-tree-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1325 | [删除给定值的叶子节点](../../problems/delete-leaves-with-a-given-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1315 | [祖父节点值为偶数的节点和](../../problems/sum-of-nodes-with-even-valued-grandparent) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1273 | [删除树节点](../../problems/delete-tree-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | +| 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1257 | [最小公共区域](../../problems/smallest-common-region) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] | Medium | -| 1110 | [删点成林](../../problems/delete-nodes-and-return-forest) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1104 | [二叉树寻路](../../problems/path-in-zigzag-labelled-binary-tree) | [[树](../tree/README.md)] [[数学](../math/README.md)] | Medium | -| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 1026 | [节点与其祖先之间的最大差值](../../problems/maximum-difference-between-node-and-ancestor) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 1022 | [从根到叶的二进制数之和](../../problems/sum-of-root-to-leaf-binary-numbers) | [[树](../tree/README.md)] | Easy | -| 1008 | [前序遍历构造二叉搜索树](../../problems/construct-binary-search-tree-from-preorder-traversal) | [[树](../tree/README.md)] | Medium | -| 998 | [最大二叉树 II](../../problems/maximum-binary-tree-ii) | [[树](../tree/README.md)] | Medium | -| 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 988 | [从叶结点开始的最小字符串](../../problems/smallest-string-starting-from-leaf) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 979 | [在二叉树中分配硬币](../../problems/distribute-coins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 971 | [翻转二叉树以匹配先序遍历](../../problems/flip-binary-tree-to-match-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 965 | [单值二叉树](../../problems/univalued-binary-tree) | [[树](../tree/README.md)] | Easy | -| 958 | [二叉树的完全性检验](../../problems/check-completeness-of-a-binary-tree) | [[树](../tree/README.md)] | Medium | -| 951 | [翻转等价二叉树](../../problems/flip-equivalent-binary-trees) | [[树](../tree/README.md)] | Medium | -| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 919 | [完全二叉树插入器](../../problems/complete-binary-tree-inserter) | [[树](../tree/README.md)] | Medium | -| 897 | [递增顺序搜索树](../../problems/increasing-order-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] | Medium | -| 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 814 | [二叉树剪枝](../../problems/binary-tree-pruning) | [[树](../tree/README.md)] | Medium | -| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 742 | [二叉树最近的叶节点](../../problems/closest-leaf-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | -| 701 | [二叉搜索树中的插入操作](../../problems/insert-into-a-binary-search-tree) | [[树](../tree/README.md)] | Medium | -| 700 | [二叉搜索树中的搜索](../../problems/search-in-a-binary-search-tree) | [[树](../tree/README.md)] | Easy | -| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 684 | [冗余连接](../../problems/redundant-connection) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 671 | [二叉树中第二小的节点](../../problems/second-minimum-node-in-a-binary-tree) | [[树](../tree/README.md)] | Easy | -| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 666 | [路径总和 IV](../../problems/path-sum-iv) 🔒 | [[树](../tree/README.md)] | Medium | -| 663 | [均匀树划分](../../problems/equal-tree-partition) 🔒 | [[树](../tree/README.md)] | Medium | -| 662 | [二叉树最大宽度](../../problems/maximum-width-of-binary-tree) | [[树](../tree/README.md)] | Medium | -| 655 | [输出二叉树](../../problems/print-binary-tree) | [[树](../tree/README.md)] | Medium | -| 654 | [最大二叉树](../../problems/maximum-binary-tree) | [[树](../tree/README.md)] | Medium | -| 653 | [两数之和 IV - 输入 BST](../../problems/two-sum-iv-input-is-a-bst) | [[树](../tree/README.md)] | Easy | -| 652 | [寻找重复的子树](../../problems/find-duplicate-subtrees) | [[树](../tree/README.md)] | Medium | -| 637 | [二叉树的层平均值](../../problems/average-of-levels-in-binary-tree) | [[树](../tree/README.md)] | Easy | -| 623 | [在二叉树中增加一行](../../problems/add-one-row-to-tree) | [[树](../tree/README.md)] | Medium | -| 617 | [合并二叉树](../../problems/merge-two-binary-trees) | [[树](../tree/README.md)] | Easy | -| 606 | [根据二叉树创建字符串](../../problems/construct-string-from-binary-tree) | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Easy | -| 590 | [N 叉树的后序遍历](../../problems/n-ary-tree-postorder-traversal) | [[树](../tree/README.md)] | Easy | -| 589 | [N 叉树的前序遍历](../../problems/n-ary-tree-preorder-traversal) | [[树](../tree/README.md)] | Easy | -| 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[队列](../queue/README.md)] | Medium | -| 572 | [另一个树的子树](../../problems/subtree-of-another-tree) | [[树](../tree/README.md)] | Easy | -| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | +| 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1110 | [删点成林](../../problems/delete-nodes-and-return-forest) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1104 | [二叉树寻路](../../problems/path-in-zigzag-labelled-binary-tree) | [[树](../tree/README.md)] [[数学](../math/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1080 | [根到叶路径上的不足节点](../../problems/insufficient-nodes-in-root-to-leaf-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 1026 | [节点与其祖先之间的最大差值](../../problems/maximum-difference-between-node-and-ancestor) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1022 | [从根到叶的二进制数之和](../../problems/sum-of-root-to-leaf-binary-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 1008 | [前序遍历构造二叉搜索树](../../problems/construct-binary-search-tree-from-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 998 | [最大二叉树 II](../../problems/maximum-binary-tree-ii) | [[树](../tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 988 | [从叶结点开始的最小字符串](../../problems/smallest-string-starting-from-leaf) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 979 | [在二叉树中分配硬币](../../problems/distribute-coins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 971 | [翻转二叉树以匹配先序遍历](../../problems/flip-binary-tree-to-match-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 965 | [单值二叉树](../../problems/univalued-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 958 | [二叉树的完全性检验](../../problems/check-completeness-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 951 | [翻转等价二叉树](../../problems/flip-equivalent-binary-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 919 | [完全二叉树插入器](../../problems/complete-binary-tree-inserter) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 897 | [递增顺序搜索树](../../problems/increasing-order-search-tree) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 814 | [二叉树剪枝](../../problems/binary-tree-pruning) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 742 | [二叉树最近的叶节点](../../problems/closest-leaf-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[数据流](../data-stream/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 701 | [二叉搜索树中的插入操作](../../problems/insert-into-a-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 700 | [二叉搜索树中的搜索](../../problems/search-in-a-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 671 | [二叉树中第二小的节点](../../problems/second-minimum-node-in-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 666 | [路径总和 IV](../../problems/path-sum-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 663 | [均匀树划分](../../problems/equal-tree-partition) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 662 | [二叉树最大宽度](../../problems/maximum-width-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 655 | [输出二叉树](../../problems/print-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 654 | [最大二叉树](../../problems/maximum-binary-tree) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 653 | [两数之和 IV - 输入 BST](../../problems/two-sum-iv-input-is-a-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 652 | [寻找重复的子树](../../problems/find-duplicate-subtrees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 637 | [二叉树的层平均值](../../problems/average-of-levels-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 623 | [在二叉树中增加一行](../../problems/add-one-row-to-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 617 | [合并二叉树](../../problems/merge-two-binary-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 606 | [根据二叉树创建字符串](../../problems/construct-string-from-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 590 | [N 叉树的后序遍历](../../problems/n-ary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 589 | [N 叉树的前序遍历](../../problems/n-ary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | +| 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 572 | [另一个树的子树](../../problems/subtree-of-another-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] [[字符串匹配](../string-matching/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | +| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 559 | [N 叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 549 | [二叉树中最长的连续序列](../../problems/binary-tree-longest-consecutive-sequence-ii) 🔒 | [[树](../tree/README.md)] | Medium | -| 545 | [二叉树的边界](../../problems/boundary-of-binary-tree) 🔒 | [[树](../tree/README.md)] | Medium | -| 543 | [二叉树的直径](../../problems/diameter-of-binary-tree) | [[树](../tree/README.md)] | Easy | -| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] | Medium | -| 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[字符串](../string/README.md)] | Medium | -| 530 | [二叉搜索树的最小绝对差](../../problems/minimum-absolute-difference-in-bst) | [[树](../tree/README.md)] | Easy | -| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 510 | [二叉搜索树中的中序后继 II](../../problems/inorder-successor-in-bst-ii) 🔒 | [[树](../tree/README.md)] | Medium | -| 508 | [出现次数最多的子树元素和](../../problems/most-frequent-subtree-sum) | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 501 | [二叉搜索树中的众数](../../problems/find-mode-in-binary-search-tree) | [[树](../tree/README.md)] | Easy | -| 450 | [删除二叉搜索树中的节点](../../problems/delete-node-in-a-bst) | [[树](../tree/README.md)] | Medium | -| 449 | [序列化和反序列化二叉搜索树](../../problems/serialize-and-deserialize-bst) | [[树](../tree/README.md)] | Medium | -| 437 | [路径总和 III](../../problems/path-sum-iii) | [[树](../tree/README.md)] | Medium | -| 431 | [将 N 叉树编码为二叉树](../../problems/encode-n-ary-tree-to-binary-tree) 🔒 | [[树](../tree/README.md)] | Hard | +| 558 | [四叉树交集](../../problems/logical-or-of-two-binary-grids-represented-as-quad-trees) | [[树](../tree/README.md)] [[分治](../divide-and-conquer/README.md)] | Medium | +| 549 | [二叉树中最长的连续序列](../../problems/binary-tree-longest-consecutive-sequence-ii) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 545 | [二叉树的边界](../../problems/boundary-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 543 | [二叉树的直径](../../problems/diameter-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 530 | [二叉搜索树的最小绝对差](../../problems/minimum-absolute-difference-in-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 510 | [二叉搜索树中的中序后继 II](../../problems/inorder-successor-in-bst-ii) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 508 | [出现次数最多的子树元素和](../../problems/most-frequent-subtree-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 501 | [二叉搜索树中的众数](../../problems/find-mode-in-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 450 | [删除二叉搜索树中的节点](../../problems/delete-node-in-a-bst) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 449 | [序列化和反序列化二叉搜索树](../../problems/serialize-and-deserialize-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 437 | [路径总和 III](../../problems/path-sum-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 431 | [将 N 叉树编码为二叉树](../../problems/encode-n-ary-tree-to-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 429 | [N 叉树的层序遍历](../../problems/n-ary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 428 | [序列化和反序列化 N 叉树](../../problems/serialize-and-deserialize-n-ary-tree) 🔒 | [[树](../tree/README.md)] | Hard | -| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](../tree/README.md)] [[链表](../linked-list/README.md)] [[分治算法](../divide-and-conquer/README.md)] | Medium | -| 404 | [左叶子之和](../../problems/sum-of-left-leaves) | [[树](../tree/README.md)] | Easy | -| 366 | [寻找二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 333 | [最大 BST 子树](../../problems/largest-bst-subtree) 🔒 | [[树](../tree/README.md)] | Medium | -| 298 | [二叉树最长连续序列](../../problems/binary-tree-longest-consecutive-sequence) 🔒 | [[树](../tree/README.md)] | Medium | -| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[设计](../design/README.md)] | Hard | -| 285 | [二叉搜索树中的中序后继](../../problems/inorder-successor-in-bst) 🔒 | [[树](../tree/README.md)] | Medium | -| 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Hard | -| 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Medium | -| 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] | Medium | -| 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] | Medium | -| 235 | [二叉搜索树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-search-tree) | [[树](../tree/README.md)] | Easy | -| 230 | [二叉搜索树中第K小的元素](../../problems/kth-smallest-element-in-a-bst) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 226 | [翻转二叉树](../../problems/invert-binary-tree) | [[树](../tree/README.md)] | Easy | -| 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[递归](../recursion/README.md)] [[队列](../queue/README.md)] | Medium | -| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] | Medium | -| 156 | [上下翻转二叉树](../../problems/binary-tree-upside-down) 🔒 | [[树](../tree/README.md)] | Medium | -| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Easy | -| 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] | Easy | -| 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | -| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Easy | -| 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 102 | [二叉树的层序遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | -| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | -| 100 | [相同的树](../../problems/same-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | -| 99 | [恢复二叉搜索树](../../problems/recover-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Hard | -| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[递归](../recursion/README.md)] | Medium | -| 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 428 | [序列化和反序列化 N 叉树](../../problems/serialize-and-deserialize-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] | Hard | +| 427 | [建立四叉树](../../problems/construct-quad-tree) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 404 | [左叶子之和](../../problems/sum-of-left-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 366 | [寻找二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 333 | [最大 BST 子树](../../problems/largest-bst-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 331 | [验证二叉树的前序序列化](../../problems/verify-preorder-serialization-of-a-binary-tree) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 298 | [二叉树最长连续序列](../../problems/binary-tree-longest-consecutive-sequence) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 285 | [二叉搜索树中的中序后继](../../problems/inorder-successor-in-bst) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 235 | [二叉搜索树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 230 | [二叉搜索树中第K小的元素](../../problems/kth-smallest-element-in-a-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 226 | [翻转二叉树](../../problems/invert-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 156 | [上下翻转二叉树](../../problems/binary-tree-upside-down) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 102 | [二叉树的层序遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 100 | [相同的树](../../problems/same-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 99 | [恢复二叉搜索树](../../problems/recover-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | diff --git a/tag/trie/README.md b/tag/trie/README.md index 0f017a498..a93542736 100644 --- a/tag/trie/README.md +++ b/tag/trie/README.md @@ -9,26 +9,40 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1858 | [Longest Word With All Prefixes](../../problems/longest-word-with-all-prefixes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1804 | [实现 Trie (前缀树) II](../../problems/implement-trie-ii-prefix-tree) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | -| 1803 | [统计异或值在范围内的数对有多少](../../problems/count-pairs-with-xor-in-a-range) | [[字典树](../trie/README.md)] | Hard | -| 1707 | [与数组中元素的最大异或值](../../problems/maximum-xor-with-an-element-from-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Hard | -| 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | -| 1638 | [统计只差一个字符的子串数目](../../problems/count-substrings-that-differ-by-one-character) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Easy | -| 1032 | [字符流](../../problems/stream-of-characters) | [[字典树](../trie/README.md)] | Hard | -| 1023 | [驼峰式匹配](../../problems/camelcase-matching) | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | -| 745 | [前缀和后缀搜索](../../problems/prefix-and-suffix-search) | [[字典树](../trie/README.md)] | Hard | -| 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[堆](../heap/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 677 | [键值映射](../../problems/map-sum-pairs) | [[字典树](../trie/README.md)] | Medium | -| 676 | [实现一个魔法字典](../../problems/implement-magic-dictionary) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 648 | [单词替换](../../problems/replace-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Hard | -| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 425 | [单词方块](../../problems/word-squares) 🔒 | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 421 | [数组中两个数的最大异或值](../../problems/maximum-xor-of-two-numbers-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] | Medium | -| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | -| 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Hard | -| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[回溯算法](../backtracking/README.md)] | Medium | -| 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] | Medium | +| 1858 | [包含所有前缀的最长单词](../../problems/longest-word-with-all-prefixes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] | Medium | +| 1804 | [实现 Trie (前缀树) II](../../problems/implement-trie-ii-prefix-tree) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1803 | [统计异或值在范围内的数对有多少](../../problems/count-pairs-with-xor-in-a-range) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] | Hard | +| 1707 | [与数组中元素的最大异或值](../../problems/maximum-xor-with-an-element-from-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] | Hard | +| 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1316 | [不同的循环子字符串](../../problems/distinct-echo-substrings) | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1268 | [搜索推荐系统](../../problems/search-suggestions-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1233 | [删除子文件夹](../../problems/remove-sub-folders-from-the-filesystem) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1178 | [猜字谜](../../problems/number-of-valid-words-for-each-puzzle) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 1166 | [设计文件系统](../../problems/design-file-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1032 | [字符流](../../problems/stream-of-characters) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[数据流](../data-stream/README.md)] | Hard | +| 1023 | [驼峰式匹配](../../problems/camelcase-matching) | [[字典树](../trie/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 820 | [单词的压缩编码](../../problems/short-encoding-of-words) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 792 | [匹配子序列的单词数](../../problems/number-of-matching-subsequences) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 745 | [前缀和后缀搜索](../../problems/prefix-and-suffix-search) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Hard | +| 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 677 | [键值映射](../../problems/map-sum-pairs) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 676 | [实现一个魔法字典](../../problems/implement-magic-dictionary) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 648 | [单词替换](../../problems/replace-words) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[数据流](../data-stream/README.md)] | Hard | +| 616 | [给字符串添加加粗标签](../../problems/add-bold-tag-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 588 | [设计内存文件系统](../../problems/design-in-memory-file-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[贪心](../greedy/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | +| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 440 | [字典序的第K小数字](../../problems/k-th-smallest-in-lexicographical-order) | [[字典树](../trie/README.md)] | Hard | +| 425 | [单词方块](../../problems/word-squares) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 421 | [数组中两个数的最大异或值](../../problems/maximum-xor-of-two-numbers-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 386 | [字典序排数](../../problems/lexicographical-numbers) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] | Medium | +| 336 | [回文对](../../problems/palindrome-pairs) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 211 | [添加与搜索单词 - 数据结构设计](../../problems/design-add-and-search-words-data-structure) | [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Medium | +| 208 | [实现 Trie (前缀树)](../../problems/implement-trie-prefix-tree) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 140 | [单词拆分 II](../../problems/word-break-ii) | [[字典树](../trie/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 139 | [单词拆分](../../problems/word-break) | [[字典树](../trie/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index d08d0bcd0..21d44c02a 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,82 +9,136 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1869 | [哪种连续子字符串更长](../../problems/longer-contiguous-segments-of-ones-than-zeros) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 1868 | [Product of Two Run-Length Encoded Arrays](../../problems/product-of-two-run-length-encoded-arrays) 🔒 | [[双指针](../two-pointers/README.md)] | Medium | -| 1861 | [旋转盒子](../../problems/rotating-the-box) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1855 | [下标对中的最大距离](../../problems/maximum-distance-between-a-pair-of-values) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1839 | [所有元音按顺序排布的最长子字符串](../../problems/longest-substring-of-all-vowels-in-order) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1800 | [最大升序子数组和](../../problems/maximum-ascending-subarray-sum) | [[双指针](../two-pointers/README.md)] | Easy | -| 1750 | [删除字符串两端相同字符后的最短长度](../../problems/minimum-length-of-string-after-deleting-similar-ends) | [[双指针](../two-pointers/README.md)] | Medium | -| 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1711 | [大餐计数](../../problems/count-good-meals) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1695 | [删除子数组的最大得分](../../problems/maximum-erasure-value) | [[双指针](../two-pointers/README.md)] | Medium | -| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[双指针](../two-pointers/README.md)] | Hard | -| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1248 | [统计「优美子数组」](../../problems/count-number-of-nice-subarrays) | [[双指针](../two-pointers/README.md)] | Medium | -| 1234 | [替换子串得到平衡字符串](../../problems/replace-the-substring-for-balanced-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] [[Line Sweep](../line-sweep/README.md)] | Medium | -| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 986 | [区间列表的交集](../../problems/interval-list-intersections) | [[双指针](../two-pointers/README.md)] | Medium | -| 977 | [有序数组的平方](../../problems/squares-of-a-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心算法](../greedy/README.md)] [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1877 | [数组中最大数对和的最小值](../../problems/minimize-maximum-pair-sum-in-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1871 | [跳跃游戏 VII](../../problems/jump-game-vii) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1868 | [两个行程编码数组的积](../../problems/product-of-two-run-length-encoded-arrays) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1861 | [旋转盒子](../../problems/rotating-the-box) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1855 | [下标对中的最大距离](../../problems/maximum-distance-between-a-pair-of-values) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1850 | [邻位交换的最小次数](../../problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1842 | [下个由相同数字构成的回文串](../../problems/next-palindrome-using-same-digits) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 1826 | [有缺陷的传感器](../../problems/faulty-sensor) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1813 | [句子相似性 III](../../problems/sentence-similarity-iii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 1782 | [统计点对的数目](../../problems/count-pairs-of-nodes) | [[图](../graph/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1768 | [交替合并字符串](../../problems/merge-strings-alternately) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 1755 | [最接近目标值的子序列和](../../problems/closest-subsequence-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1754 | [构造字典序最大的合并字符串](../../problems/largest-merge-of-two-strings) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1750 | [删除字符串两端相同字符后的最短长度](../../problems/minimum-length-of-string-after-deleting-similar-ends) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1721 | [交换链表中的节点](../../problems/swapping-nodes-in-a-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1679 | [K 和数对的最大数目](../../problems/max-number-of-k-sum-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1634 | [求两个多项式链表的和](../../problems/add-two-polynomials-represented-as-linked-lists) 🔒 | [[链表](../linked-list/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1570 | [两个稀疏向量的点积](../../problems/dot-product-of-two-sparse-vectors) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1537 | [最大得分](../../problems/get-the-maximum-score) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1471 | [数组中的 k 个最强值](../../problems/the-k-strongest-values-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1385 | [两个数组间的距离值](../../problems/find-the-distance-value-between-two-arrays) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1346 | [检查整数及其两倍数是否存在](../../problems/check-if-n-and-its-double-exist) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1332 | [删除回文子序列](../../problems/remove-palindromic-subsequences) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 1265 | [逆序打印不可变链表](../../problems/print-immutable-linked-list-in-reverse) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1163 | [按字典序排在最后的子串](../../problems/last-substring-in-lexicographical-order) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | +| 1147 | [段式回文](../../problems/longest-chunked-palindrome-decomposition) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 1089 | [复写零](../../problems/duplicate-zeros) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 1048 | [最长字符串链](../../problems/longest-string-chain) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1040 | [移动石子直到连续 II](../../problems/moving-stones-until-consecutive-ii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1023 | [驼峰式匹配](../../problems/camelcase-matching) | [[字典树](../trie/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 986 | [区间列表的交集](../../problems/interval-list-intersections) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 977 | [有序数组的平方](../../problems/squares-of-a-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Easy | +| 969 | [煎饼排序](../../problems/pancake-sorting) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 942 | [增减字符串匹配](../../problems/di-string-match) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 925 | [长按键入](../../problems/long-pressed-name) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 923 | [三数之和的多种可能](../../problems/3sum-with-multiplicity) | [[双指针](../two-pointers/README.md)] | Medium | -| 904 | [水果成篮](../../problems/fruit-into-baskets) | [[双指针](../two-pointers/README.md)] | Medium | -| 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 845 | [数组中的最长山脉](../../problems/longest-mountain-in-array) | [[双指针](../two-pointers/README.md)] | Medium | -| 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 828 | [统计子串中的唯一字符](../../problems/count-unique-characters-of-all-substrings-of-a-given-string) | [[双指针](../two-pointers/README.md)] | Hard | -| 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[双指针](../two-pointers/README.md)] | Medium | -| 763 | [划分字母区间](../../problems/partition-labels) | [[贪心算法](../greedy/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 567 | [字符串的排列](../../problems/permutation-in-string) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[排序](../sort/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 487 | [最大连续1的个数 II](../../problems/max-consecutive-ones-ii) 🔒 | [[双指针](../two-pointers/README.md)] | Medium | -| 457 | [环形数组是否存在循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[双指针](../two-pointers/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[排序](../sort/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[排序](../sort/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 923 | [三数之和的多种可能](../../problems/3sum-with-multiplicity) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 922 | [按奇偶排序数组 II](../../problems/sort-array-by-parity-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Easy | +| 917 | [仅仅反转字母](../../problems/reverse-only-letters) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 905 | [按奇偶排序数组](../../problems/sort-array-by-parity) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Easy | +| 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 876 | [链表的中间结点](../../problems/middle-of-the-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 845 | [数组中的最长山脉](../../problems/longest-mountain-in-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[枚举](../enumeration/README.md)] | Medium | +| 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 832 | [翻转图像](../../problems/flipping-an-image) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 825 | [适龄的朋友](../../problems/friends-of-appropriate-ages) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 821 | [字符的最短距离](../../problems/shortest-distance-to-a-character) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 809 | [情感丰富的文字](../../problems/expressive-words) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 795 | [区间子数组个数](../../problems/number-of-subarrays-with-bounded-maximum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 777 | [在LR字符串中交换相邻字符](../../problems/swap-adjacent-in-lr-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 763 | [划分字母区间](../../problems/partition-labels) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 696 | [计数二进制子串](../../problems/count-binary-substrings) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 680 | [验证回文字符串 Ⅱ](../../problems/valid-palindrome-ii) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 658 | [找到 K 个最接近的元素](../../problems/find-k-closest-elements) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 653 | [两数之和 IV - 输入 BST](../../problems/two-sum-iv-input-is-a-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 633 | [平方数之和](../../problems/sum-of-square-numbers) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 611 | [有效三角形的个数](../../problems/valid-triangle-number) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 581 | [最短无序连续子数组](../../problems/shortest-unsorted-continuous-subarray) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 567 | [字符串的排列](../../problems/permutation-in-string) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 557 | [反转字符串中的单词 III](../../problems/reverse-words-in-a-string-iii) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 556 | [下一个更大元素 III](../../problems/next-greater-element-iii) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 541 | [反转字符串 II](../../problems/reverse-string-ii) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 522 | [最长特殊序列 II](../../problems/longest-uncommon-subsequence-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 481 | [神奇字符串](../../problems/magical-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 457 | [环形数组是否存在循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 443 | [压缩字符串](../../problems/string-compression) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 408 | [有效单词缩写](../../problems/valid-word-abbreviation) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 392 | [判断子序列](../../problems/is-subsequence) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 345 | [反转字符串中的元音字母](../../problems/reverse-vowels-of-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 344 | [反转字符串](../../problems/reverse-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 340 | [至多包含 K 个不同字符的最长子串](../../problems/longest-substring-with-at-most-k-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 344 | [反转字符串](../../problems/reverse-string) | [[递归](../recursion/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[设计](../design/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 234 | [回文链表](../../problems/palindrome-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 277 | [搜寻名人](../../problems/find-the-celebrity) 🔒 | [[贪心](../greedy/README.md)] [[图](../graph/README.md)] [[双指针](../two-pointers/README.md)] [[交互](../interactive/README.md)] | Medium | +| 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 246 | [中心对称数](../../problems/strobogrammatic-number) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 234 | [回文链表](../../problems/palindrome-linked-list) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 202 | [快乐数](../../problems/happy-number) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 189 | [旋转数组](../../problems/rotate-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 186 | [翻转字符串里的单词 II](../../problems/reverse-words-in-a-string-ii) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | | 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | -| 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | -| 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 141 | [环形链表](../../problems/linked-list-cycle) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 165 | [比较版本号](../../problems/compare-version-numbers) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 161 | [相隔为 1 的编辑距离](../../problems/one-edit-distance) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 151 | [翻转字符串里的单词](../../problems/reverse-words-in-a-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 148 | [排序链表](../../problems/sort-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[分治](../divide-and-conquer/README.md)] [[排序](../sorting/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 143 | [重排链表](../../problems/reorder-list) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 141 | [环形链表](../../problems/linked-list-cycle) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 125 | [验证回文串](../../problems/valid-palindrome) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | -| 88 | [合并两个有序数组](../../problems/merge-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | +| 88 | [合并两个有序数组](../../problems/merge-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Easy | | 86 | [分隔链表](../../problems/partition-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 82 | [删除排序链表中的重复元素 II](../../problems/remove-duplicates-from-sorted-list-ii) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 80 | [删除有序数组中的重复项 II](../../problems/remove-duplicates-from-sorted-array-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 76 | [最小覆盖子串](../../problems/minimum-window-substring) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Hard | -| 75 | [颜色分类](../../problems/sort-colors) | [[排序](../sort/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 75 | [颜色分类](../../problems/sort-colors) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 61 | [旋转链表](../../problems/rotate-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 30 | [串联所有单词的子串](../../problems/substring-with-concatenation-of-all-words) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | -| 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 31 | [下一个排列](../../problems/next-permutation) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Easy | | 27 | [移除元素](../../problems/remove-element) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 26 | [删除有序数组中的重复项](../../problems/remove-duplicates-from-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 19 | [删除链表的倒数第 N 个结点](../../problems/remove-nth-node-from-end-of-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 11 | [盛最多水的容器](../../problems/container-with-most-water) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 3 | [无重复字符的最长子串](../../problems/longest-substring-without-repeating-characters) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[Sliding Window](../sliding-window/README.md)] | Medium | +| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 11 | [盛最多水的容器](../../problems/container-with-most-water) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index 12680f716..317e9708c 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -9,42 +9,56 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] [[队列](../queue/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1724 | [检查边长度限制的路径是否存在 II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[贪心算法](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 1697 | [检查边长度限制的路径是否存在](../../problems/checking-existence-of-edge-length-limited-paths) | [[排序](../sort/README.md)] [[并查集](../union-find/README.md)] | Hard | -| 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] | Hard | -| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1627 | [带阈值的图连通性](../../problems/graph-connectivity-with-threshold) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | -| 1584 | [连接所有点的最小费用](../../problems/min-cost-to-connect-all-points) | [[并查集](../union-find/README.md)] | Medium | -| 1579 | [保证图可完全遍历](../../problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | [[并查集](../union-find/README.md)] | Hard | -| 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | -| 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | -| 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 1135 | [最低成本联通所有城市](../../problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 1101 | [彼此熟识的最早时间](../../problems/the-earliest-moment-when-everyone-become-friends) 🔒 | [[并查集](../union-find/README.md)] | Medium | -| 1061 | [按字典序排列最小的等效字符串](../../problems/lexicographically-smallest-equivalent-string) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 990 | [等式方程的可满足性](../../problems/satisfiability-of-equality-equations) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 952 | [按公因数计算最大组件大小](../../problems/largest-component-size-by-common-factor) | [[并查集](../union-find/README.md)] [[数学](../math/README.md)] | Hard | -| 947 | [移除最多的同行或同列石头](../../problems/most-stones-removed-with-same-row-or-column) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 924 | [尽量减少恶意软件的传播](../../problems/minimize-malware-spread) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Hard | -| 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 803 | [打砖块](../../problems/bricks-falling-when-hit) | [[并查集](../union-find/README.md)] | Hard | -| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[堆](../heap/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心算法](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 721 | [账户合并](../../problems/accounts-merge) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | -| 684 | [冗余连接](../../problems/redundant-connection) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 547 | [省份数量](../../problems/number-of-provinces) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 399 | [除法求值](../../problems/evaluate-division) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1724 | [检查边长度限制的路径是否存在 II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] | Hard | +| 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | +| 1697 | [检查边长度限制的路径是否存在](../../problems/checking-existence-of-edge-length-limited-paths) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1627 | [带阈值的图连通性](../../problems/graph-connectivity-with-threshold) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1584 | [连接所有点的最小费用](../../problems/min-cost-to-connect-all-points) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] | Medium | +| 1579 | [保证图可完全遍历](../../problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] [[排序](../sorting/README.md)] [[强连通分量](../strongly-connected-component/README.md)] | Hard | +| 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1361 | [验证二叉树](../../problems/validate-binary-tree-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1319 | [连通网络的操作次数](../../problems/number-of-operations-to-make-network-connected) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1258 | [近义词句子](../../problems/synonymous-sentences) 🔒 | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1254 | [统计封闭岛屿的数目](../../problems/number-of-closed-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] | Hard | +| 1135 | [最低成本联通所有城市](../../problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1101 | [彼此熟识的最早时间](../../problems/the-earliest-moment-when-everyone-become-friends) 🔒 | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | +| 1061 | [按字典序排列最小的等效字符串](../../problems/lexicographically-smallest-equivalent-string) 🔒 | [[并查集](../union-find/README.md)] [[字符串](../string/README.md)] | Medium | +| 1020 | [飞地的数量](../../problems/number-of-enclaves) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 990 | [等式方程的可满足性](../../problems/satisfiability-of-equality-equations) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 959 | [由斜杠划分区域](../../problems/regions-cut-by-slashes) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 952 | [按公因数计算最大组件大小](../../problems/largest-component-size-by-common-factor) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 947 | [移除最多的同行或同列石头](../../problems/most-stones-removed-with-same-row-or-column) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 924 | [尽量减少恶意软件的传播](../../problems/minimize-malware-spread) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 886 | [可能的二分法](../../problems/possible-bipartition) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 839 | [相似字符串组](../../problems/similar-string-groups) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[字符串](../string/README.md)] | Hard | +| 827 | [最大人工岛](../../problems/making-a-large-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 803 | [打砖块](../../problems/bricks-falling-when-hit) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 785 | [判断二分图](../../problems/is-graph-bipartite) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 765 | [情侣牵手](../../problems/couples-holding-hands) | [[贪心](../greedy/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 721 | [账户合并](../../problems/accounts-merge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | +| 695 | [岛屿的最大面积](../../problems/max-area-of-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Medium | +| 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | +| 684 | [冗余连接](../../problems/redundant-connection) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 547 | [省份数量](../../problems/number-of-provinces) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | +| 399 | [除法求值](../../problems/evaluate-division) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 305 | [岛屿数量 II](../../problems/number-of-islands-ii) 🔒 | [[并查集](../union-find/README.md)] | Hard | +| 305 | [岛屿数量 II](../../problems/number-of-islands-ii) 🔒 | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Hard | | 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] | Medium | -| 128 | [最长连续序列](../../problems/longest-consecutive-sequence) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | +| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 128 | [最长连续序列](../../problems/longest-consecutive-sequence) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | From 7bb6e4014674b6366801bab3707ab7eea7b1fe3a Mon Sep 17 00:00:00 2001 From: Shuo Date: Mon, 2 Aug 2021 11:43:21 +0800 Subject: [PATCH 133/145] A: new --- README.md | 39 +++- problems/3sum-smaller/README.md | 12 + problems/4-keys-keyboard/README.md | 34 +++ problems/active-businesses/README.md | 42 ++++ problems/activity-participants/README.md | 64 ++++++ .../README.md | 40 ++++ problems/add-bold-tag-in-string/README.md | 27 +++ .../add-minimum-number-of-rungs/README.md | 85 +++++++ problems/ads-performance/README.md | 56 +++++ problems/advantage-shuffle/README.md | 39 ++-- problems/alien-dictionary/README.md | 51 +++++ .../README.md | 48 ++-- .../README.md | 73 ++++++ .../all-paths-from-source-to-target/README.md | 5 +- .../README.md | 51 +++++ .../README.md | 14 ++ .../mysql_schemas.sql | 11 + .../README.md | 44 ++++ problems/android-unlock-patterns/README.md | 47 ++++ problems/armstrong-number/README.md | 30 +++ problems/array-transformation/README.md | 40 ++++ problems/article-views-i/README.md | 42 ++++ problems/article-views-ii/README.md | 42 ++++ .../README.md | 60 ++++- problems/average-selling-price/README.md | 71 ++++++ problems/basic-calculator-iii/README.md | 19 ++ problems/basic-calculator/README.md | 10 +- problems/beautiful-array/README.md | 35 +-- problems/before-and-after-puzzle/README.md | 50 +++++ problems/best-meeting-point/README.md | 17 ++ problems/biggest-single-number/README.md | 27 +++ .../README.md | 30 +++ .../README.md | 36 +++ problems/binary-tree-upside-down/README.md | 40 ++++ .../README.md | 76 +++++++ problems/bold-words-in-string/README.md | 14 ++ problems/bomb-enemy/README.md | 17 ++ problems/boundary-of-binary-tree/README.md | 52 +++++ problems/brace-expansion/README.md | 32 +++ problems/broken-calculator/README.md | 45 ++-- .../README.md | 2 +- problems/burst-balloons/README.md | 2 +- problems/campus-bikes-ii/README.md | 40 ++++ problems/campus-bikes/README.md | 40 ++++ problems/candy-crush/README.md | 37 +++ problems/capital-gainloss/README.md | 52 +++++ problems/car-fleet/README.md | 46 ++-- problems/card-flipping-game/README.md | 43 ++-- problems/chalkboard-xor-game/README.md | 38 +++- .../README.md | 34 +++ .../README.md | 12 +- .../README.md | 58 +++++ .../README.md | 30 +++ .../README.md | 24 ++ .../README.md | 21 ++ .../closest-leaf-in-a-binary-tree/README.md | 58 +++++ problems/coin-path/README.md | 35 +++ problems/concatenation-of-array/README.md | 56 +++++ problems/confirmation-rate/README.md | 14 ++ problems/confirmation-rate/mysql_schemas.sql | 15 ++ problems/confusing-number-ii/README.md | 38 ++++ problems/confusing-number/README.md | 57 +++++ .../README.md | 40 ++++ .../consecutive-available-seats/README.md | 29 +++ problems/consecutive-numbers-sum/README.md | 31 ++- .../README.md | 31 ++- .../README.md | 24 ++ .../README.md | 21 ++ problems/convex-polygon/README.md | 32 +++ .../README.md | 74 ++++++ problems/count-square-sum-triples/README.md | 55 +++++ .../README.md | 59 +++++ .../README.md | 31 ++- problems/count-univalue-subtrees/README.md | 15 ++ problems/course-schedule-iv/README.md | 22 +- problems/cousins-in-binary-tree/README.md | 46 ++-- problems/custom-sort-string/README.md | 31 ++- .../README.md | 44 ++++ .../README.md | 57 +++++ .../README.md | 64 ++++++ problems/decode-ways-ii/README.md | 2 +- problems/decoded-string-at-index/README.md | 44 ++-- .../README.md | 124 +++++++++++ problems/delete-tree-nodes/README.md | 30 +++ problems/describe-the-painting/README.md | 97 ++++++++ problems/design-a-leaderboard/README.md | 42 ++++ .../design-bounded-blocking-queue/README.md | 73 ++++++ problems/design-circular-deque/README.md | 59 ++--- .../README.md | 35 +++ problems/design-excel-sum-formula/README.md | 56 +++++ problems/design-file-system/README.md | 56 +++++ problems/design-hit-counter/README.md | 34 +++ .../design-in-memory-file-system/README.md | 33 +++ problems/design-log-storage-system/README.md | 24 ++ problems/design-phone-directory/README.md | 36 +++ .../README.md | 59 +++++ problems/design-snake-game/README.md | 48 ++++ problems/design-tic-tac-toe/README.md | 56 +++++ problems/diameter-of-binary-tree/README.md | 2 +- problems/diet-plan-performance/README.md | 43 ++++ problems/digit-count-in-range/README.md | 30 +++ problems/distinct-subsequences-ii/README.md | 48 ++-- .../README.md | 5 +- .../README.md | 30 +++ problems/divide-chocolate/README.md | 39 ++++ problems/domino-and-tromino-tiling/README.md | 37 ++- .../README.md | 23 +- problems/employee-bonus/README.md | 38 ++++ problems/employee-free-time/README.md | 41 ++++ problems/encode-and-decode-strings/README.md | 42 ++++ .../README.md | 19 ++ problems/encode-number/README.md | 26 +++ .../README.md | 62 ++++++ problems/equal-tree-partition/README.md | 47 ++++ problems/erect-the-fence-ii/README.md | 2 +- problems/exam-room/README.md | 51 +++-- problems/excel-sheet-column-number/README.md | 2 +- problems/expressive-words/README.md | 37 ++- problems/factor-combinations/README.md | 53 +++++ problems/fair-candy-swap/README.md | 46 ++-- problems/find-anagram-mappings/README.md | 27 +++ .../README.md | 67 ++++++ .../mysql_schemas.sql | 2 + problems/find-customer-referee/README.md | 28 +++ .../README.md | 30 +++ .../find-k-pairs-with-smallest-sums/README.md | 2 +- problems/find-leaves-of-binary-tree/README.md | 44 ++++ .../README.md | 23 ++ problems/find-permutation/README.md | 25 +++ .../README.md | 17 ++ problems/find-the-celebrity/README.md | 39 ++++ .../README.md | 22 ++ .../README.md | 43 ++++ problems/find-the-team-size/README.md | 43 ++++ problems/find-the-town-judge/README.md | 16 +- problems/first-missing-positive/README.md | 4 +- problems/fixed-point/README.md | 38 ++++ problems/flatten-2d-vector/README.md | 31 +++ problems/flip-game-ii/README.md | 13 ++ problems/flip-game/README.md | 16 ++ .../README.md | 42 ++-- .../README.md | 59 +++++ .../README.md | 40 ++++ .../friends-of-appropriate-ages/README.md | 44 ++-- problems/frog-jump/README.md | 1 + problems/game-play-analysis-i/README.md | 42 ++++ problems/game-play-analysis-ii/README.md | 41 ++++ problems/game-play-analysis-iii/README.md | 47 ++++ problems/game-play-analysis-iv/README.md | 41 ++++ problems/game-play-analysis-v/README.md | 47 ++++ problems/generalized-abbreviation/README.md | 12 + .../README.md | 31 ++- .../README.md | 44 ++++ problems/goat-latin/README.md | 58 +++-- problems/graph-valid-tree/README.md | 14 ++ problems/group-shifted-strings/README.md | 18 ++ .../README.md | 63 +++--- problems/hand-of-straights/README.md | 17 +- problems/handshakes-that-dont-cross/README.md | 46 ++++ problems/hexspeak/README.md | 27 +++ problems/high-five/README.md | 26 +++ .../highest-grade-for-each-student/README.md | 40 ++++ .../README.md | 27 +++ problems/immediate-food-delivery-i/README.md | 43 ++++ problems/immediate-food-delivery-ii/README.md | 50 +++++ problems/index-pairs-of-a-string/README.md | 31 +++ .../inorder-successor-in-bst-ii/README.md | 60 +++++ problems/inorder-successor-in-bst/README.md | 27 +++ .../README.md | 18 ++ .../README.md | 17 ++ .../README.md | 24 +- problems/investments-in-2016/README.md | 51 +++++ problems/ip-to-cidr/README.md | 49 ++++ problems/jump-game/README.md | 6 +- problems/k-closest-points-to-origin/README.md | 5 +- problems/k-empty-slots/README.md | 42 ++++ problems/keys-and-rooms/README.md | 49 ++-- .../README.md | 24 +- problems/kill-process/README.md | 29 +++ .../kth-ancestor-of-a-tree-node/README.md | 4 +- problems/largest-bst-subtree/README.md | 22 ++ .../README.md | 51 ++--- .../README.md | 84 +++++++ problems/largest-sum-of-averages/README.md | 33 +-- problems/largest-triangle-area/README.md | 30 +-- problems/largest-unique-number/README.md | 31 +++ problems/league-statistics/README.md | 2 +- problems/leetcodify-similar-friends/README.md | 2 +- problems/lemonade-change/README.md | 54 ++--- .../README.md | 48 ++++ problems/line-reflection/README.md | 14 ++ problems/linked-list-components/README.md | 39 ++-- .../README.md | 76 +++++++ problems/logger-rate-limiter/README.md | 28 +++ problems/lonely-pixel-i/README.md | 22 ++ problems/lonely-pixel-ii/README.md | 38 ++++ .../README.md | 30 +++ .../README.md | 17 +- problems/longest-mountain-in-array/README.md | 4 +- .../longest-palindromic-substring/README.md | 2 +- .../longest-repeating-substring/README.md | 43 ++++ .../README.md | 17 ++ .../README.md | 14 ++ problems/loud-and-rich/README.md | 62 +++--- .../README.md | 26 +++ problems/market-analysis-i/README.md | 90 ++++++++ problems/market-analysis-ii/README.md | 95 ++++++++ problems/max-consecutive-ones-ii/README.md | 22 ++ problems/max-stack/README.md | 33 +++ .../maximum-average-subarray-ii/README.md | 23 ++ problems/maximum-average-subtree/README.md | 28 +++ .../maximum-compatibility-score-sum/README.md | 76 +++++++ .../maximum-depth-of-n-ary-tree/README.md | 2 +- .../README.md | 6 +- problems/maximum-distance-in-arrays/README.md | 21 ++ .../README.md | 64 ++++++ problems/maximum-number-of-ones/README.md | 36 +++ .../README.md | 74 ++++++ .../README.md | 79 +++++++ .../README.md | 67 ++++++ .../README.md | 30 +++ .../README.md | 20 +- .../README.md | 21 ++ problems/maximum-subarray/README.md | 4 +- .../maximum-sum-bst-in-binary-tree/README.md | 10 +- problems/maximum-vacation-days/README.md | 58 +++++ problems/median-employee-salary/README.md | 38 ++++ problems/meeting-rooms-ii/README.md | 14 ++ problems/meeting-rooms/README.md | 16 ++ problems/meeting-scheduler/README.md | 33 +++ .../merge-bsts-to-create-single-bst/README.md | 110 +++++++++ problems/middle-of-the-linked-list/README.md | 33 ++- .../README.md | 20 ++ .../README.md | 32 +++ .../README.md | 61 +++-- problems/minimum-area-rectangle-ii/README.md | 67 +++--- problems/minimum-area-rectangle/README.md | 34 ++- .../minimum-cost-to-connect-sticks/README.md | 22 +- .../minimum-cost-to-hire-k-workers/README.md | 42 ++-- .../README.md | 80 +++++++ .../README.md | 4 +- .../README.md | 15 +- .../README.md | 3 +- problems/minimum-factorization/README.md | 20 ++ problems/minimum-falling-path-sum/README.md | 3 + .../README.md | 72 ++++++ .../README.md | 34 ++- problems/minimum-knight-moves/README.md | 30 +++ .../README.md | 3 +- .../README.md | 2 +- .../README.md | 42 ++++ .../minimum-time-to-build-blocks/README.md | 44 ++++ .../README.md | 22 ++ problems/minimum-window-subsequence/README.md | 25 +++ problems/mirror-reflection/README.md | 35 +-- .../missing-element-in-sorted-array/README.md | 39 ++++ .../README.md | 28 +++ problems/missing-ranges/README.md | 7 + problems/monotonic-array/README.md | 78 ++----- problems/monthly-transactions-i/README.md | 42 ++++ problems/monthly-transactions-ii/README.md | 67 ++++++ problems/most-profit-assigning-work/README.md | 41 +++- problems/movie-rating/README.md | 92 ++++++++ .../moving-average-from-data-stream/README.md | 12 + .../README.md | 57 ++--- .../README.md | 82 +++++++ problems/nested-list-weight-sum-ii/README.md | 22 ++ problems/nested-list-weight-sum/README.md | 18 ++ problems/new-users-daily-count/README.md | 51 +++++ problems/next-closest-time/README.md | 18 ++ problems/non-overlapping-intervals/README.md | 4 +- .../number-of-comments-per-post/README.md | 56 +++++ .../README.md | 27 +++ .../number-of-corner-rectangles/README.md | 52 +++++ problems/number-of-days-in-a-month/README.md | 32 +++ .../number-of-distinct-islands-ii/README.md | 60 +++++ problems/number-of-distinct-islands/README.md | 35 +++ problems/number-of-islands-ii/README.md | 53 +++++ problems/number-of-music-playlists/README.md | 45 ++-- .../number-of-ships-in-a-rectangle/README.md | 29 +++ .../README.md | 8 +- .../README.md | 6 +- .../README.md | 80 +++++++ .../README.md | 97 ++++++++ problems/number-of-valid-subarrays/README.md | 37 +++ .../README.md | 83 +++++++ problems/one-edit-distance/README.md | 29 +++ problems/optimal-account-balancing/README.md | 43 ++++ .../README.md | 30 +++ problems/orderly-queue/README.md | 42 ++-- problems/output-contest-matches/README.md | 42 ++++ problems/page-recommendations/README.md | 72 ++++++ problems/paint-fence/README.md | 24 ++ problems/paint-house-ii/README.md | 17 ++ problems/paint-house/README.md | 14 ++ .../README.md | 62 ++++++ problems/palindrome-permutation-ii/README.md | 10 + problems/palindrome-permutation/README.md | 15 ++ problems/palindrome-removal/README.md | 26 +++ problems/parallel-courses/README.md | 41 ++++ .../README.md | 40 ++-- problems/path-sum-iv/README.md | 42 ++++ .../path-with-maximum-minimum-value/README.md | 42 ++++ problems/plus-one-linked-list/README.md | 12 + problems/possible-bipartition/README.md | 42 +--- problems/pour-water/README.md | 122 ++++++++++ .../README.md | 29 ++- problems/prime-palindrome/README.md | 53 ++--- .../README.md | 37 +++ .../product-of-the-last-k-numbers/README.md | 4 +- .../product-price-at-a-given-date/README.md | 40 ++++ problems/product-sales-analysis-i/README.md | 62 ++++++ problems/product-sales-analysis-ii/README.md | 60 +++++ problems/product-sales-analysis-iii/README.md | 61 +++++ problems/project-employees-i/README.md | 62 ++++++ problems/project-employees-ii/README.md | 60 +++++ problems/project-employees-iii/README.md | 62 ++++++ problems/push-dominoes/README.md | 47 ++-- .../queries-quality-and-percentage/README.md | 63 ++++++ problems/random-flip-matrix/README.md | 54 +++-- problems/random-pick-with-blacklist/README.md | 73 +++--- .../README.md | 73 +++--- problems/range-addition/README.md | 27 +++ problems/range-sum-query-2d-mutable/README.md | 29 +++ problems/rank-teams-by-votes/README.md | 5 +- problems/reach-a-number/README.md | 21 +- .../README.md | 80 +++++++ .../read-n-characters-given-read4/README.md | 90 ++++++++ .../README.md | 29 +++ .../reduce-array-size-to-the-half/README.md | 2 +- .../regular-expression-matching/README.md | 6 +- problems/remove-9/README.md | 14 ++ problems/remove-interval/README.md | 20 ++ .../remove-vowels-from-a-string/README.md | 25 +++ .../README.md | 65 ++++++ problems/report-contiguous-dates/README.md | 73 ++++++ problems/reported-posts-ii/README.md | 72 ++++++ problems/reported-posts/README.md | 49 ++++ problems/restaurant-growth/README.md | 58 +++++ problems/restore-the-array/README.md | 14 +- .../README.md | 45 ++-- .../reverse-words-in-a-string-ii/README.md | 16 ++ problems/robot-room-cleaner/README.md | 54 +++++ problems/rotate-function/README.md | 2 +- problems/rotate-string/README.md | 26 ++- problems/rotated-digits/README.md | 43 +++- .../README.md | 61 +++++ problems/sales-analysis-i/README.md | 63 ++++++ problems/sales-analysis-ii/README.md | 62 ++++++ problems/sales-analysis-iii/README.md | 62 ++++++ problems/sales-person/README.md | 66 ++++++ .../score-after-flipping-matrix/README.md | 46 ++-- problems/score-of-parentheses/README.md | 50 ++--- .../README.md | 26 +++ problems/second-degree-follower/README.md | 34 +++ problems/sentence-screen-fitting/README.md | 66 ++++++ problems/sentence-similarity-ii/README.md | 21 ++ problems/sentence-similarity/README.md | 21 ++ problems/sequence-reconstruction/README.md | 54 +++++ .../README.md | 21 ++ problems/set-matrix-zeroes/README.md | 2 +- problems/shifting-letters/README.md | 44 ++-- .../README.md | 26 +++ .../shortest-distance-in-a-line/README.md | 31 +++ .../shortest-distance-in-a-plane/README.md | 28 +++ .../README.md | 34 +++ .../shortest-path-in-a-hidden-grid/README.md | 2 +- .../shortest-path-to-get-all-keys/README.md | 59 +++-- .../README.md | 52 ++--- .../shortest-way-to-form-string/README.md | 37 +++ problems/shortest-word-distance-ii/README.md | 13 ++ problems/shortest-word-distance-iii/README.md | 18 ++ problems/shortest-word-distance/README.md | 16 ++ problems/similar-rgb-color/README.md | 24 ++ problems/single-row-keyboard/README.md | 31 +++ problems/smallest-common-region/README.md | 32 +++ problems/smallest-range-i/README.md | 49 ++-- problems/smallest-range-ii/README.md | 49 ++-- .../README.md | 14 ++ .../README.md | 32 +-- problems/sort-array-by-parity/README.md | 27 ++- problems/sort-transformed-array/README.md | 20 ++ problems/soup-servings/README.md | 38 ++-- .../sparse-matrix-multiplication/README.md | 25 +++ problems/spiral-matrix-iii/README.md | 45 ++-- problems/split-array-with-equal-sum/README.md | 28 ++- problems/split-bst/README.md | 36 +++ problems/split-concatenated-strings/README.md | 25 +++ problems/squirrel-simulation/README.md | 1 + problems/stamping-the-sequence/README.md | 53 +++-- problems/stepping-numbers/README.md | 14 ++ .../README.md | 31 +++ problems/strobogrammatic-number-ii/README.md | 9 + problems/strobogrammatic-number-iii/README.md | 12 + problems/strobogrammatic-number/README.md | 21 ++ problems/strong-friendship/README.md | 14 ++ problems/strong-friendship/mysql_schemas.sql | 14 ++ problems/students-and-examinations/README.md | 97 ++++++++ .../students-report-by-geography/README.md | 30 +++ .../README.md | 67 ++++++ problems/subtree-of-another-tree/README.md | 2 +- problems/sum-game/README.md | 87 ++++++++ .../README.md | 31 +++ .../README.md | 81 +++++++ problems/sum-of-distances-in-tree/README.md | 50 +++-- problems/sum-of-subsequence-widths/README.md | 32 +-- problems/surrounded-regions/README.md | 2 +- problems/synonymous-sentences/README.md | 28 ++- .../README.md | 76 +++++++ problems/ternary-expression-parser/README.md | 51 +++++ problems/text-justification/README.md | 14 +- .../README.md | 38 ++++ problems/the-maze-ii/README.md | 56 +++++ problems/the-maze-iii/README.md | 60 +++++ problems/the-maze/README.md | 55 +++++ .../README.md | 82 +++++++ problems/three-divisors/README.md | 51 +++++ problems/top-travellers/README.md | 74 ++++++ problems/toss-strange-coins/README.md | 22 +- problems/total-hamming-distance/README.md | 3 +- problems/total-sales-amount-by-year/README.md | 66 ++++++ problems/tournament-winners/README.md | 74 ++++++ .../README.md | 59 +++++ problems/tree-diameter/README.md | 35 +++ problems/tree-node/README.md | 61 +++++ problems/triangle-judgement/README.md | 22 ++ problems/two-sum-bsts/README.md | 31 +++ .../README.md | 18 ++ problems/two-sum-less-than-k/README.md | 30 +++ .../README.md | 80 +++++++ problems/unique-morse-code-words/README.md | 44 ++-- problems/unique-word-abbreviation/README.md | 31 +++ problems/unpopular-books/README.md | 67 ++++++ .../README.md | 49 ++++ .../README.md | 49 ++++ problems/user-purchase-platform/README.md | 45 ++++ .../README.md | 14 ++ .../mysql_schemas.sql | 16 ++ problems/valid-palindrome-iii/README.md | 20 ++ .../README.md | 44 ++-- problems/valid-word-abbreviation/README.md | 29 +++ problems/valid-word-square/README.md | 76 +++++++ problems/validate-stack-sequences/README.md | 34 ++- .../README.md | 26 +++ problems/walls-and-gates/README.md | 28 +++ .../weather-type-in-each-country/README.md | 82 +++++++ problems/web-crawler-multithreaded/README.md | 92 ++++++++ problems/web-crawler/README.md | 79 +++++++ problems/wiggle-sort/README.md | 6 + problems/winning-candidate/README.md | 46 ++++ problems/word-abbreviation/README.md | 22 ++ problems/word-pattern-ii/README.md | 24 ++ problems/word-squares/README.md | 68 ++++++ problems/word-subsets/README.md | 90 +++----- problems/zigzag-iterator/README.md | 26 +++ readme/1-300.md | 2 +- readme/301-600.md | 4 +- readme/601-900.md | 4 +- tag/README.md | 37 ++- tag/array/README.md | 12 +- tag/backtracking/README.md | 3 +- tag/biconnected-component/README.md | 12 + tag/binary-search/README.md | 2 + tag/binary-tree/README.md | 162 ++++++++++++++ tag/bit-manipulation/README.md | 1 + tag/bitmask/README.md | 38 ++++ tag/breadth-first-search/README.md | 5 +- tag/bucket-sort/README.md | 17 ++ tag/combinatorics/README.md | 21 ++ tag/concurrency/README.md | 20 ++ tag/counting-sort/README.md | 16 ++ tag/counting/README.md | 62 ++++++ tag/data-stream/README.md | 25 +++ tag/depth-first-search/README.md | 7 +- tag/divide-and-conquer/README.md | 2 +- tag/doubly-linked-list/README.md | 18 ++ tag/dynamic-programming/README.md | 5 +- tag/enumeration/README.md | 26 +++ tag/eulerian-circuit/README.md | 13 ++ tag/game-theory/README.md | 32 +++ tag/graph/README.md | 5 +- tag/greedy/README.md | 4 +- tag/hash-function/README.md | 30 +++ tag/hash-table/README.md | 7 +- tag/heap-priority-queue/README.md | 104 +++++++++ tag/interactive/README.md | 29 +++ tag/iterator/README.md | 20 ++ tag/line-sweep/README.md | 2 +- tag/math/README.md | 7 +- tag/matrix/README.md | 151 +++++++++++++ tag/memoization/README.md | 2 +- tag/merge-sort/README.md | 18 ++ tag/minimum-spanning-tree/README.md | 16 ++ tag/monotonic-queue/README.md | 19 ++ tag/monotonic-stack/README.md | 46 ++++ tag/number-theory/README.md | 18 ++ tag/ordered-set/README.md | 44 ++++ tag/prefix-sum/README.md | 72 ++++++ tag/probability-and-statistics/README.md | 18 ++ tag/quickselect/README.md | 16 ++ tag/radix-sort/README.md | 13 ++ tag/randomized/README.md | 23 ++ tag/rejection-sampling/README.md | 2 +- tag/reservoir-sampling/README.md | 2 +- tag/rolling-hash/README.md | 2 +- tag/shortest-path/README.md | 21 ++ tag/simulation/README.md | 78 +++++++ tag/sliding-window/README.md | 2 +- tag/sorting/README.md | 210 ++++++++++++++++++ tag/stack/README.md | 1 + tag/string-matching/README.md | 26 +++ tag/string/README.md | 10 +- tag/strongly-connected-component/README.md | 13 ++ tag/suffix-array/README.md | 2 +- tag/tree/README.md | 3 +- tag/trie/README.md | 1 + 516 files changed, 16976 insertions(+), 1914 deletions(-) create mode 100644 problems/add-minimum-number-of-rungs/README.md create mode 100644 problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md create mode 100644 problems/all-the-pairs-with-the-maximum-number-of-common-followers/mysql_schemas.sql create mode 100644 problems/check-if-all-characters-have-equal-number-of-occurrences/README.md create mode 100644 problems/check-if-string-is-decomposable-into-value-equal-substrings/README.md create mode 100644 problems/concatenation-of-array/README.md create mode 100644 problems/confirmation-rate/README.md create mode 100644 problems/confirmation-rate/mysql_schemas.sql create mode 100644 problems/count-number-of-special-subsequences/README.md create mode 100644 problems/count-square-sum-triples/README.md create mode 100644 problems/delete-duplicate-folders-in-system/README.md create mode 100644 problems/describe-the-painting/README.md create mode 100644 problems/largest-number-after-mutating-substring/README.md create mode 100644 problems/longest-common-subsequence-between-sorted-arrays/README.md create mode 100644 problems/maximum-compatibility-score-sum/README.md create mode 100644 problems/maximum-genetic-difference-query/README.md create mode 100644 problems/maximum-number-of-points-with-cost/README.md create mode 100644 problems/maximum-number-of-weeks-for-which-you-can-work/README.md create mode 100644 problems/maximum-number-of-words-you-can-type/README.md create mode 100644 problems/maximum-of-minimum-values-in-all-subarrays/README.md create mode 100644 problems/merge-bsts-to-create-single-bst/README.md create mode 100644 problems/minimum-cost-to-reach-destination-in-time/README.md create mode 100644 problems/minimum-garden-perimeter-to-collect-enough-apples/README.md create mode 100644 problems/nearest-exit-from-entrance-in-maze/README.md create mode 100644 problems/number-of-visible-people-in-a-queue/README.md create mode 100644 problems/painting-a-grid-with-three-different-colors/README.md create mode 100644 problems/strong-friendship/README.md create mode 100644 problems/strong-friendship/mysql_schemas.sql create mode 100644 problems/sum-game/README.md create mode 100644 problems/sum-of-digits-of-string-after-convert/README.md create mode 100644 problems/the-number-of-the-smallest-unoccupied-chair/README.md create mode 100644 problems/three-divisors/README.md create mode 100644 problems/unique-length-3-palindromic-subsequences/README.md create mode 100644 problems/users-that-actively-request-confirmation-messages/README.md create mode 100644 problems/users-that-actively-request-confirmation-messages/mysql_schemas.sql create mode 100644 tag/biconnected-component/README.md create mode 100644 tag/binary-tree/README.md create mode 100644 tag/bitmask/README.md create mode 100644 tag/bucket-sort/README.md create mode 100644 tag/combinatorics/README.md create mode 100644 tag/concurrency/README.md create mode 100644 tag/counting-sort/README.md create mode 100644 tag/counting/README.md create mode 100644 tag/data-stream/README.md create mode 100644 tag/doubly-linked-list/README.md create mode 100644 tag/enumeration/README.md create mode 100644 tag/eulerian-circuit/README.md create mode 100644 tag/game-theory/README.md create mode 100644 tag/hash-function/README.md create mode 100644 tag/heap-priority-queue/README.md create mode 100644 tag/interactive/README.md create mode 100644 tag/iterator/README.md create mode 100644 tag/matrix/README.md create mode 100644 tag/merge-sort/README.md create mode 100644 tag/minimum-spanning-tree/README.md create mode 100644 tag/monotonic-queue/README.md create mode 100644 tag/monotonic-stack/README.md create mode 100644 tag/number-theory/README.md create mode 100644 tag/ordered-set/README.md create mode 100644 tag/prefix-sum/README.md create mode 100644 tag/probability-and-statistics/README.md create mode 100644 tag/quickselect/README.md create mode 100644 tag/radix-sort/README.md create mode 100644 tag/randomized/README.md create mode 100644 tag/shortest-path/README.md create mode 100644 tag/simulation/README.md create mode 100644 tag/sorting/README.md create mode 100644 tag/string-matching/README.md create mode 100644 tag/strongly-connected-component/README.md diff --git a/README.md b/README.md index a67ad251b..03760c670 100644 --- a/README.md +++ b/README.md @@ -78,12 +78,43 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1955 | [Count Number of Special Subsequences](https://leetcode.com/problems/count-number-of-special-subsequences "统计特殊子序列的数目") | [Go](problems/count-number-of-special-subsequences) | Hard | +| 1954 | [Minimum Garden Perimeter to Collect Enough Apples](https://leetcode.com/problems/minimum-garden-perimeter-to-collect-enough-apples "收集足够苹果的最小花园周长") | [Go](problems/minimum-garden-perimeter-to-collect-enough-apples) | Medium | +| 1953 | [Maximum Number of Weeks for Which You Can Work](https://leetcode.com/problems/maximum-number-of-weeks-for-which-you-can-work "你可以工作的最大周数") | [Go](problems/maximum-number-of-weeks-for-which-you-can-work) | Medium | +| 1952 | [Three Divisors](https://leetcode.com/problems/three-divisors "三除数") | [Go](problems/three-divisors) | Easy | +| 1951 | [All the Pairs With the Maximum Number of Common Followers](https://leetcode.com/problems/all-the-pairs-with-the-maximum-number-of-common-followers) 🔒 | [MySQL](problems/all-the-pairs-with-the-maximum-number-of-common-followers) | Medium | +| 1950 | [Maximum of Minimum Values in All Subarrays](https://leetcode.com/problems/maximum-of-minimum-values-in-all-subarrays "所有子数组最小值中的最大值") 🔒 | [Go](problems/maximum-of-minimum-values-in-all-subarrays) | Medium | +| 1949 | [Strong Friendship](https://leetcode.com/problems/strong-friendship) 🔒 | [MySQL](problems/strong-friendship) | Medium | +| 1948 | [Delete Duplicate Folders in System](https://leetcode.com/problems/delete-duplicate-folders-in-system "删除系统中的重复文件夹") | [Go](problems/delete-duplicate-folders-in-system) | Hard | +| 1947 | [Maximum Compatibility Score Sum](https://leetcode.com/problems/maximum-compatibility-score-sum "最大兼容性评分和") | [Go](problems/maximum-compatibility-score-sum) | Medium | +| 1946 | [Largest Number After Mutating Substring](https://leetcode.com/problems/largest-number-after-mutating-substring "子字符串突变后可能得到的最大整数") | [Go](problems/largest-number-after-mutating-substring) | Medium | +| 1945 | [Sum of Digits of String After Convert](https://leetcode.com/problems/sum-of-digits-of-string-after-convert "字符串转化后的各位数字之和") | [Go](problems/sum-of-digits-of-string-after-convert) | Easy | +| 1944 | [Number of Visible People in a Queue](https://leetcode.com/problems/number-of-visible-people-in-a-queue "队列中可以看到的人数") | [Go](problems/number-of-visible-people-in-a-queue) | Hard | +| 1943 | [Describe the Painting](https://leetcode.com/problems/describe-the-painting "描述绘画结果") | [Go](problems/describe-the-painting) | Medium | +| 1942 | [The Number of the Smallest Unoccupied Chair](https://leetcode.com/problems/the-number-of-the-smallest-unoccupied-chair "最小未被占据椅子的编号") | [Go](problems/the-number-of-the-smallest-unoccupied-chair) | Medium | +| 1941 | [Check if All Characters Have Equal Number of Occurrences](https://leetcode.com/problems/check-if-all-characters-have-equal-number-of-occurrences "检查是否所有字符出现次数相同") | [Go](problems/check-if-all-characters-have-equal-number-of-occurrences) | Easy | +| 1940 | [Longest Common Subsequence Between Sorted Arrays](https://leetcode.com/problems/longest-common-subsequence-between-sorted-arrays "排序数组之间的最长公共子序列") 🔒 | [Go](problems/longest-common-subsequence-between-sorted-arrays) | Medium | +| 1939 | [Users That Actively Request Confirmation Messages](https://leetcode.com/problems/users-that-actively-request-confirmation-messages) 🔒 | [MySQL](problems/users-that-actively-request-confirmation-messages) | Easy | +| 1938 | [Maximum Genetic Difference Query](https://leetcode.com/problems/maximum-genetic-difference-query "查询最大基因差") | [Go](problems/maximum-genetic-difference-query) | Hard | +| 1937 | [Maximum Number of Points with Cost](https://leetcode.com/problems/maximum-number-of-points-with-cost "扣分后的最大得分") | [Go](problems/maximum-number-of-points-with-cost) | Medium | +| 1936 | [Add Minimum Number of Rungs](https://leetcode.com/problems/add-minimum-number-of-rungs "新增的最少台阶数") | [Go](problems/add-minimum-number-of-rungs) | Medium | +| 1935 | [Maximum Number of Words You Can Type](https://leetcode.com/problems/maximum-number-of-words-you-can-type "可以输入的最大单词数") | [Go](problems/maximum-number-of-words-you-can-type) | Easy | +| 1934 | [Confirmation Rate](https://leetcode.com/problems/confirmation-rate) 🔒 | [MySQL](problems/confirmation-rate) | Medium | +| 1933 | [Check if String Is Decomposable Into Value-Equal Substrings](https://leetcode.com/problems/check-if-string-is-decomposable-into-value-equal-substrings "判断字符串是否可分解为值均等的子串") 🔒 | [Go](problems/check-if-string-is-decomposable-into-value-equal-substrings) | Easy | +| 1932 | [Merge BSTs to Create Single BST](https://leetcode.com/problems/merge-bsts-to-create-single-bst "合并多棵二叉搜索树") | [Go](problems/merge-bsts-to-create-single-bst) | Hard | +| 1931 | [Painting a Grid With Three Different Colors](https://leetcode.com/problems/painting-a-grid-with-three-different-colors "用三种不同颜色为网格涂色") | [Go](problems/painting-a-grid-with-three-different-colors) | Hard | +| 1930 | [Unique Length-3 Palindromic Subsequences](https://leetcode.com/problems/unique-length-3-palindromic-subsequences "长度为 3 的不同回文子序列") | [Go](problems/unique-length-3-palindromic-subsequences) | Medium | +| 1929 | [Concatenation of Array](https://leetcode.com/problems/concatenation-of-array "数组串联") | [Go](problems/concatenation-of-array) | Easy | +| 1928 | [Minimum Cost to Reach Destination in Time](https://leetcode.com/problems/minimum-cost-to-reach-destination-in-time "规定时间内到达终点的最小花费") | [Go](problems/minimum-cost-to-reach-destination-in-time) | Hard | +| 1927 | [Sum Game](https://leetcode.com/problems/sum-game "求和游戏") | [Go](problems/sum-game) | Medium | +| 1926 | [Nearest Exit from Entrance in Maze](https://leetcode.com/problems/nearest-exit-from-entrance-in-maze "迷宫中离入口最近的出口") | [Go](problems/nearest-exit-from-entrance-in-maze) | Medium | +| 1925 | [Count Square Sum Triples](https://leetcode.com/problems/count-square-sum-triples "统计平方和三元组的数目") | [Go](problems/count-square-sum-triples) | Easy | | 1924 | [Erect the Fence II](https://leetcode.com/problems/erect-the-fence-ii) 🔒 | [Go](problems/erect-the-fence-ii) | Hard | | 1923 | [Longest Common Subpath](https://leetcode.com/problems/longest-common-subpath "最长公共子路径") | [Go](problems/longest-common-subpath) | Hard | | 1922 | [Count Good Numbers](https://leetcode.com/problems/count-good-numbers "统计好数字的数目") | [Go](problems/count-good-numbers) | Medium | | 1921 | [Eliminate Maximum Number of Monsters](https://leetcode.com/problems/eliminate-maximum-number-of-monsters "消灭怪物的最大数量") | [Go](problems/eliminate-maximum-number-of-monsters) | Medium | | 1920 | [Build Array from Permutation](https://leetcode.com/problems/build-array-from-permutation "基于排列构建数组") | [Go](problems/build-array-from-permutation) | Easy | -| 1919 | [Leetcodify Similar Friends](https://leetcode.com/problems/leetcodify-similar-friends) 🔒 | [MySQL](problems/leetcodify-similar-friends) | Hard | +| 1919 | [Leetcodify Similar Friends](https://leetcode.com/problems/leetcodify-similar-friends "兴趣相同的朋友") 🔒 | [MySQL](problems/leetcodify-similar-friends) | Hard | | 1918 | [Kth Smallest Subarray Sum](https://leetcode.com/problems/kth-smallest-subarray-sum) 🔒 | [Go](problems/kth-smallest-subarray-sum) | Medium | | 1917 | [Leetcodify Friends Recommendations](https://leetcode.com/problems/leetcodify-friends-recommendations) 🔒 | [MySQL](problems/leetcodify-friends-recommendations) | Hard | | 1916 | [Count Ways to Build Rooms in an Ant Colony](https://leetcode.com/problems/count-ways-to-build-rooms-in-an-ant-colony "统计为蚁群构筑房间的不同顺序") | [Go](problems/count-ways-to-build-rooms-in-an-ant-colony) | Hard | @@ -161,7 +192,7 @@ LeetCode Problems' Solutions | 1844 | [Replace All Digits with Characters](https://leetcode.com/problems/replace-all-digits-with-characters "将所有数字用字符替换") | [Go](problems/replace-all-digits-with-characters) | Easy | | 1843 | [Suspicious Bank Accounts](https://leetcode.com/problems/suspicious-bank-accounts) 🔒 | [MySQL](problems/suspicious-bank-accounts) | Medium | | 1842 | [Next Palindrome Using Same Digits](https://leetcode.com/problems/next-palindrome-using-same-digits "下个由相同数字构成的回文串") 🔒 | [Go](problems/next-palindrome-using-same-digits) | Hard | -| 1841 | [League Statistics](https://leetcode.com/problems/league-statistics) 🔒 | [MySQL](problems/league-statistics) | Medium | +| 1841 | [League Statistics](https://leetcode.com/problems/league-statistics "联赛信息统计") 🔒 | [MySQL](problems/league-statistics) | Medium | | 1840 | [Maximum Building Height](https://leetcode.com/problems/maximum-building-height "最高建筑高度") | [Go](problems/maximum-building-height) | Hard | | 1839 | [Longest Substring Of All Vowels in Order](https://leetcode.com/problems/longest-substring-of-all-vowels-in-order "所有元音按顺序排布的最长子字符串") | [Go](problems/longest-substring-of-all-vowels-in-order) | Medium | | 1838 | [Frequency of the Most Frequent Element](https://leetcode.com/problems/frequency-of-the-most-frequent-element "最高频元素的频数") | [Go](problems/frequency-of-the-most-frequent-element) | Medium | @@ -192,7 +223,7 @@ LeetCode Problems' Solutions | 1813 | [Sentence Similarity III](https://leetcode.com/problems/sentence-similarity-iii "句子相似性 III") | [Go](problems/sentence-similarity-iii) | Medium | | 1812 | [Determine Color of a Chessboard Square](https://leetcode.com/problems/determine-color-of-a-chessboard-square "判断国际象棋棋盘中一个格子的颜色") | [Go](problems/determine-color-of-a-chessboard-square) | Easy | | 1811 | [Find Interview Candidates](https://leetcode.com/problems/find-interview-candidates "寻找面试候选人") 🔒 | [MySQL](problems/find-interview-candidates) | Medium | -| 1810 | [Minimum Path Cost in a Hidden Grid](https://leetcode.com/problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [Go](problems/minimum-path-cost-in-a-hidden-grid) | Medium | +| 1810 | [Minimum Path Cost in a Hidden Grid](https://leetcode.com/problems/minimum-path-cost-in-a-hidden-grid "隐藏网格下的最小消耗路径") 🔒 | [Go](problems/minimum-path-cost-in-a-hidden-grid) | Medium | | 1809 | [Ad-Free Sessions](https://leetcode.com/problems/ad-free-sessions "没有广告的剧集") 🔒 | [MySQL](problems/ad-free-sessions) | Easy | | 1808 | [Maximize Number of Nice Divisors](https://leetcode.com/problems/maximize-number-of-nice-divisors "好因子的最大数目") | [Go](problems/maximize-number-of-nice-divisors) | Hard | | 1807 | [Evaluate the Bracket Pairs of a String](https://leetcode.com/problems/evaluate-the-bracket-pairs-of-a-string "替换字符串中的括号内容") | [Go](problems/evaluate-the-bracket-pairs-of-a-string) | Medium | @@ -224,7 +255,7 @@ LeetCode Problems' Solutions | 1781 | [Sum of Beauty of All Substrings](https://leetcode.com/problems/sum-of-beauty-of-all-substrings "所有子字符串美丽值之和") | [Go](problems/sum-of-beauty-of-all-substrings) | Medium | | 1780 | [Check if Number is a Sum of Powers of Three](https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three "判断一个数字是否可以表示成三的幂的和") | [Go](problems/check-if-number-is-a-sum-of-powers-of-three) | Medium | | 1779 | [Find Nearest Point That Has the Same X or Y Coordinate](https://leetcode.com/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate "找到最近的有相同 X 或 Y 坐标的点") | [Go](problems/find-nearest-point-that-has-the-same-x-or-y-coordinate) | Easy | -| 1778 | [Shortest Path in a Hidden Grid](https://leetcode.com/problems/shortest-path-in-a-hidden-grid) 🔒 | [Go](problems/shortest-path-in-a-hidden-grid) | Medium | +| 1778 | [Shortest Path in a Hidden Grid](https://leetcode.com/problems/shortest-path-in-a-hidden-grid "未知网格中的最短路径") 🔒 | [Go](problems/shortest-path-in-a-hidden-grid) | Medium | | 1777 | [Product's Price for Each Store](https://leetcode.com/problems/products-price-for-each-store "每家商店的产品价格") 🔒 | [MySQL](problems/products-price-for-each-store) | Easy | | 1776 | [Car Fleet II](https://leetcode.com/problems/car-fleet-ii "车队 II") | [Go](problems/car-fleet-ii) | Hard | | 1775 | [Equal Sum Arrays With Minimum Number of Operations](https://leetcode.com/problems/equal-sum-arrays-with-minimum-number-of-operations "通过最少操作次数使数组的和相等") | [Go](problems/equal-sum-arrays-with-minimum-number-of-operations) | Medium | diff --git a/problems/3sum-smaller/README.md b/problems/3sum-smaller/README.md index dfffe1c28..bfa0d4d13 100644 --- a/problems/3sum-smaller/README.md +++ b/problems/3sum-smaller/README.md @@ -11,7 +11,19 @@ ## [259. 3Sum Smaller (Medium)](https://leetcode.com/problems/3sum-smaller "较小的三数之和") +

    Given an array of n integers nums and a target, find the number of index triplets i, j, k with 0 <= i < j < k < n that satisfy the condition nums[i] + nums[j] + nums[k] < target.

    +

    Example:

    + +
    +Input: nums = [-2,0,1,3], and target = 2
    +Output: 2 
    +Explanation: Because there are two triplets which sums are less than 2:
    +             [-2,0,1]
    +             [-2,0,3]
    +
    + +

    Follow up: Could you solve it in O(n2) runtime?

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/4-keys-keyboard/README.md b/problems/4-keys-keyboard/README.md index a93312593..dc7964f95 100644 --- a/problems/4-keys-keyboard/README.md +++ b/problems/4-keys-keyboard/README.md @@ -11,8 +11,42 @@ ## [651. 4 Keys Keyboard (Medium)](https://leetcode.com/problems/4-keys-keyboard "4键键盘") +

    Imagine you have a special keyboard with the following keys:

    +

    Key 1: (A): Print one 'A' on screen.

    +

    Key 2: (Ctrl-A): Select the whole screen.

    +

    Key 3: (Ctrl-C): Copy selection to buffer.

    +

    Key 4: (Ctrl-V): Print buffer on screen appending it after what has already been printed.

    + +

    Now, you can only press the keyboard for N times (with the above four keys), find out the maximum numbers of 'A' you can print on screen.

    + + +

    Example 1:
    +

    Input: N = 3
    +Output: 3
    +Explanation: 
    +We can at most get 3 A's on screen by pressing following key sequence:
    +A, A, A
    +
    +

    + +

    Example 2:
    +

    Input: N = 7
    +Output: 9
    +Explanation: 
    +We can at most get 9 A's on screen by pressing following key sequence:
    +A, A, A, Ctrl A, Ctrl C, Ctrl V, Ctrl V
    +
    +

    + +

    Note:
    +

      +
    1. 1 <= N <= 50
    2. +
    3. Answers will be in the range of 32-bit signed integer.
    4. +
    +

    + ### Related Topics [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/active-businesses/README.md b/problems/active-businesses/README.md index c5ef5beeb..0502a4f42 100644 --- a/problems/active-businesses/README.md +++ b/problems/active-businesses/README.md @@ -11,7 +11,49 @@ ## [1126. Active Businesses (Medium)](https://leetcode.com/problems/active-businesses "查询活跃业务") +

    Table: Events

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| business_id   | int     |
    +| event_type    | varchar |
    +| occurences    | int     | 
    ++---------------+---------+
    +(business_id, event_type) is the primary key of this table.
    +Each row in the table logs the info that an event of some type occured at some business for a number of times.
    + +

     

    + +

    Write an SQL query to find all active businesses.

    + +

    An active business is a business that has more than one event type with occurences greater than the average occurences of that event type among all businesses.

    + +

    The query result format is in the following example:

    + +
    +Events table:
    ++-------------+------------+------------+
    +| business_id | event_type | occurences |
    ++-------------+------------+------------+
    +| 1           | reviews    | 7          |
    +| 3           | reviews    | 3          |
    +| 1           | ads        | 11         |
    +| 2           | ads        | 7          |
    +| 3           | ads        | 6          |
    +| 1           | page views | 3          |
    +| 2           | page views | 12         |
    ++-------------+------------+------------+
    +
    +Result table:
    ++-------------+
    +| business_id |
    ++-------------+
    +| 1           |
    ++-------------+ 
    +Average for 'reviews', 'ads' and 'page views' are (7+3)/2=5, (11+7+6)/3=8, (3+12)/2=7.5 respectively.
    +Business with id 1 has 7 'reviews' events (more than 5) and 11 'ads' events (more than 8) so it is an active business.
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/activity-participants/README.md b/problems/activity-participants/README.md index c02acedb9..6cba915c9 100644 --- a/problems/activity-participants/README.md +++ b/problems/activity-participants/README.md @@ -11,7 +11,71 @@ ## [1355. Activity Participants (Medium)](https://leetcode.com/problems/activity-participants "活动参与者") +

    Table: Friends

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| id            | int     |
    +| name          | varchar |
    +| activity      | varchar |
    ++---------------+---------+
    +id is the id of the friend and primary key for this table.
    +name is the name of the friend.
    +activity is the name of the activity which the friend takes part in.
    +
    +

    Table: Activities

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| id            | int     |
    +| name          | varchar |
    ++---------------+---------+
    +id is the primary key for this table.
    +name is the name of the activity.
    +
    + +Write an SQL query to find the names of all the activities with neither maximum, nor minimum number of participants. + +Return the result table in any order. Each activity in table Activities is performed by any person in the table Friends. + +The query result format is in the following example: + +Friends table: +
    ++------+--------------+---------------+
    +| id   | name         | activity      |
    ++------+--------------+---------------+
    +| 1    | Jonathan D.  | Eating        |
    +| 2    | Jade W.      | Singing       |
    +| 3    | Victor J.    | Singing       |
    +| 4    | Elvis Q.     | Eating        |
    +| 5    | Daniel A.    | Eating        |
    +| 6    | Bob B.       | Horse Riding  |
    ++------+--------------+---------------+
    +
    +Activities table:
    ++------+--------------+
    +| id   | name         |
    ++------+--------------+
    +| 1    | Eating       |
    +| 2    | Singing      |
    +| 3    | Horse Riding |
    ++------+--------------+
    +
    +Result table:
    ++--------------+
    +| results      |
    ++--------------+
    +| Singing      |
    ++--------------+
    +
    +Eating activity is performed by 3 friends, maximum number of participants, (Jonathan D. , Elvis Q. and Daniel A.)
    +Horse Riding activity is performed by 1 friend, minimum number of participants, (Bob B.)
    +Singing is performed by 2 friends (Victor J. and Jade W.)
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md b/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md index 579f1765c..7bf3cb0b6 100644 --- a/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md +++ b/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md @@ -11,7 +11,47 @@ ## [1050. Actors and Directors Who Cooperated At Least Three Times (Easy)](https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times "合作过至少三次的演员和导演") +

    Table: ActorDirector

    +
    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| actor_id    | int     |
    +| director_id | int     |
    +| timestamp   | int     |
    ++-------------+---------+
    +timestamp is the primary key column for this table.
    +
    + +

     

    + +

    Write a SQL query for a report that provides the pairs (actor_id, director_id) where the actor have cooperated with the director at least 3 times.

    + +

    Example:

    + +
    +ActorDirector table:
    ++-------------+-------------+-------------+
    +| actor_id    | director_id | timestamp   |
    ++-------------+-------------+-------------+
    +| 1           | 1           | 0           |
    +| 1           | 1           | 1           |
    +| 1           | 1           | 2           |
    +| 1           | 2           | 3           |
    +| 1           | 2           | 4           |
    +| 2           | 1           | 5           |
    +| 2           | 1           | 6           |
    ++-------------+-------------+-------------+
    +
    +Result table:
    ++-------------+-------------+
    +| actor_id    | director_id |
    ++-------------+-------------+
    +| 1           | 1           |
    ++-------------+-------------+
    +The only pair is (1, 1) where they cooperated exactly 3 times.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/add-bold-tag-in-string/README.md b/problems/add-bold-tag-in-string/README.md index 0622eb91d..eee9b70a5 100644 --- a/problems/add-bold-tag-in-string/README.md +++ b/problems/add-bold-tag-in-string/README.md @@ -11,7 +11,34 @@ ## [616. Add Bold Tag in String (Medium)](https://leetcode.com/problems/add-bold-tag-in-string "给字符串添加加粗标签") +Given a string s and a list of strings dict, you need to add a closed pair of bold tag <b> and </b> to wrap the substrings in s that exist in dict. If two such substrings overlap, you need to wrap them together by only one pair of closed bold tag. Also, if two substrings wrapped by bold tags are consecutive, you need to combine them. +

    Example 1:
    +

    +Input: 
    +s = "abcxyz123"
    +dict = ["abc","123"]
    +Output:
    +"<b>abc</b>xyz<b>123</b>"
    +
    +

    + +

    Example 2:
    +

    +Input: 
    +s = "aaabbcc"
    +dict = ["aaa","aab","bc"]
    +Output:
    +"<b>aaabbc</b>c"
    +
    +

    + +

    Note:
    +

      +
    1. The given dict won't contain duplicates, and its length won't exceed 100.
    2. +
    3. All the strings in input have length in range [1, 1000].
    4. +
    +

    ### Related Topics [[Trie](../../tag/trie/README.md)] diff --git a/problems/add-minimum-number-of-rungs/README.md b/problems/add-minimum-number-of-rungs/README.md new file mode 100644 index 000000000..3f14795f0 --- /dev/null +++ b/problems/add-minimum-number-of-rungs/README.md @@ -0,0 +1,85 @@ + + + + + + + +[< Previous](../maximum-number-of-words-you-can-type "Maximum Number of Words You Can Type") +                 +[Next >](../maximum-number-of-points-with-cost "Maximum Number of Points with Cost") + +## [1936. Add Minimum Number of Rungs (Medium)](https://leetcode.com/problems/add-minimum-number-of-rungs "新增的最少台阶数") + +

    You are given a strictly increasing integer array rungs that represents the height of rungs on a ladder. You are currently on the floor at height 0, and you want to reach the last rung.

    + +

    You are also given an integer dist. You can only climb to the next highest rung if the distance between where you are currently at (the floor or on a rung) and the next rung is at most dist. You are able to insert rungs at any positive integer height if a rung is not already there.

    + +

    Return the minimum number of rungs that must be added to the ladder in order for you to climb to the last rung.

    + +

     

    +

    Example 1:

    + +
    +Input: rungs = [1,3,5,10], dist = 2
    +Output: 2
    +Explanation:
    +You currently cannot reach the last rung.
    +Add rungs at heights 7 and 8 to climb this ladder. 
    +The ladder will now have rungs at [1,3,5,7,8,10].
    +
    + +

    Example 2:

    + +
    +Input: rungs = [3,6,8,10], dist = 3
    +Output: 0
    +Explanation:
    +This ladder can be climbed without adding additional rungs.
    +
    + +

    Example 3:

    + +
    +Input: rungs = [3,4,6,7], dist = 2
    +Output: 1
    +Explanation:
    +You currently cannot reach the first rung from the ground.
    +Add a rung at height 1 to climb this ladder.
    +The ladder will now have rungs at [1,3,4,6,7].
    +
    + +

    Example 4:

    + +
    +Input: rungs = [5], dist = 10
    +Output: 0
    +Explanation:
    +This ladder can be climbed without adding additional rungs.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= rungs.length <= 105
    • +
    • 1 <= rungs[i] <= 109
    • +
    • 1 <= dist <= 109
    • +
    • rungs is strictly increasing.
    • +
    + +### Hints +
    +Hint 1 +Go as far as you can on the available rungs before adding new rungs. +
    + +
    +Hint 2 +If you have to add a new rung, add it as high up as possible. +
    + +
    +Hint 3 +Try using division to decrease the number of computations. +
    diff --git a/problems/ads-performance/README.md b/problems/ads-performance/README.md index 6452b89b7..021d8c49e 100644 --- a/problems/ads-performance/README.md +++ b/problems/ads-performance/README.md @@ -11,7 +11,63 @@ ## [1322. Ads Performance (Easy)](https://leetcode.com/problems/ads-performance "广告效果") +

    Table: Ads

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| ad_id         | int     |
    +| user_id       | int     |
    +| action        | enum    |
    ++---------------+---------+
    +(ad_id, user_id) is the primary key for this table.
    +Each row of this table contains the ID of an Ad, the ID of a user and the action taken by this user regarding this Ad.
    +The action column is an ENUM type of ('Clicked', 'Viewed', 'Ignored').
    +
    + +A company is running Ads and wants to calculate the performance of each Ad. +Performance of the Ad is measured using Click-Through Rate (CTR) where: + +[[image-blog:Leetcode: Ads Performance][https://raw.githubusercontent.com/dennyzhang/code.dennyzhang.com/master/problems/ads-performance/ctrformula.png]] + +Write an SQL query to find the ctr of each Ad. + +Round ctr to 2 decimal points. Order the result table by ctr in descending order and by ad_id in ascending order in case of a tie. + +The query result format is in the following example: +
    +Ads table:
    ++-------+---------+---------+
    +| ad_id | user_id | action  |
    ++-------+---------+---------+
    +| 1     | 1       | Clicked |
    +| 2     | 2       | Clicked |
    +| 3     | 3       | Viewed  |
    +| 5     | 5       | Ignored |
    +| 1     | 7       | Ignored |
    +| 2     | 7       | Viewed  |
    +| 3     | 5       | Clicked |
    +| 1     | 4       | Viewed  |
    +| 2     | 11      | Viewed  |
    +| 1     | 2       | Clicked |
    ++-------+---------+---------+
    +Result table:
    ++-------+-------+
    +| ad_id | ctr   |
    ++-------+-------+
    +| 1     | 66.67 |
    +| 3     | 50.00 |
    +| 2     | 33.33 |
    +| 5     | 0.00  |
    ++-------+-------+
    +for ad_id = 1, ctr = (2/(2+1)) * 100 = 66.67
    +for ad_id = 2, ctr = (1/(1+2)) * 100 = 33.33
    +for ad_id = 3, ctr = (1/(1+1)) * 100 = 50.00
    +for ad_id = 5, ctr = 0.00, Note that ad_id has no clicks or views.
    +Note that we don't care about Ignored Ads.
    +Result table is ordered by the ctr. in case of a tie we order them by ad_id
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/advantage-shuffle/README.md b/problems/advantage-shuffle/README.md index 2416071a4..b32ed4ae4 100644 --- a/problems/advantage-shuffle/README.md +++ b/problems/advantage-shuffle/README.md @@ -11,39 +11,26 @@ ## [870. Advantage Shuffle (Medium)](https://leetcode.com/problems/advantage-shuffle "优势洗牌") -

    Given two arrays nums1 and nums2 of equal size, the advantage of nums1 with respect to nums2 is the number of indices i for which nums1[i] > nums2[i].

    +

    You are given two integer arrays nums1 and nums2 both of the same length. The advantage of nums1 with respect to nums2 is the number of indices i for which nums1[i] > nums2[i].

    -

    Return any permutation of nums1 that maximizes its advantage with respect to nums2.

    +

    Return any permutation of nums1 that maximizes its advantage with respect to nums2.

     

    - -

    Example 1:

    - -
    -Input: nums1 = [2,7,11,15], nums2 = [1,10,4,11]
    -Output: [2,11,7,15]
    +
    Input: nums1 = [2,7,11,15], nums2 = [1,10,4,11]
    +Output: [2,11,7,15]
    +

    Example 2:

    +
    Input: nums1 = [12,24,8,32], nums2 = [13,25,32,11]
    +Output: [24,32,8,12]
     
    - -
    -

    Example 2:

    - -
    -Input: nums1 = [12,24,8,32], nums2 = [13,25,32,11]
    -Output: [24,32,8,12]
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= nums1.length = nums2.length <= 10000
    2. -
    3. 0 <= nums1[i] <= 109
    4. -
    5. 0 <= nums2[i] <= 109
    6. -
    -
    -
    +
      +
    • 1 <= nums1.length <= 105
    • +
    • nums2.length == nums1.length
    • +
    • 0 <= nums1[i], nums2[i] <= 109
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/alien-dictionary/README.md b/problems/alien-dictionary/README.md index 87cb564d4..a54c21b2e 100644 --- a/problems/alien-dictionary/README.md +++ b/problems/alien-dictionary/README.md @@ -11,7 +11,58 @@ ## [269. Alien Dictionary (Hard)](https://leetcode.com/problems/alien-dictionary "火星词典") +

    There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. You receive a list of non-empty words from the dictionary, where words are sorted lexicographically by the rules of this new language. Derive the order of letters in this language.

    +

    Example 1:

    + +
    +Input:
    +[
    +  "wrt",
    +  "wrf",
    +  "er",
    +  "ett",
    +  "rftt"
    +]
    +
    +Output: "wertf"
    +
    + +

    Example 2:

    + +
    +Input:
    +[
    +  "z",
    +  "x"
    +]
    +
    +Output: "zx"
    +
    + +

    Example 3:

    + +
    +Input:
    +[
    +  "z",
    +  "x",
    +  "z"
    +] 
    +
    +Output: "" 
    +
    +Explanation: The order is invalid, so return "".
    +
    + +

    Note:

    + +
      +
    1. You may assume all letters are in lowercase.
    2. +
    3. You may assume that if a is a prefix of b, then a must appear before b in the given dictionary.
    4. +
    5. If the order is invalid, return an empty string.
    6. +
    7. There may be multiple valid order of letters, return any one of them is fine.
    8. +
    ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/all-nodes-distance-k-in-binary-tree/README.md b/problems/all-nodes-distance-k-in-binary-tree/README.md index 3877dc425..c312b5eab 100644 --- a/problems/all-nodes-distance-k-in-binary-tree/README.md +++ b/problems/all-nodes-distance-k-in-binary-tree/README.md @@ -11,44 +11,36 @@ ## [863. All Nodes Distance K in Binary Tree (Medium)](https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree "二叉树中所有距离为 K 的结点") -

    We are given a binary tree (with root node root), a target node, and an integer value k.

    +

    Given the root of a binary tree, the value of a target node target, and an integer k, return an array of the values of all nodes that have a distance k from the target node.

    -

    Return a list of the values of all nodes that have a distance k from the target node.  The answer can be returned in any order.

    +

    You can return the answer in any order.

     

    - -
      -
    - -

    Example 1:

    - +
    -Input: root = [3,5,1,6,2,0,8,null,null,7,4], target = 5, k = 2
    -
    -Output: [7,4,1]
    -
    -Explanation: 
    -The nodes that are a distance 2 from the target node (with value 5)
    -have values 7, 4, and 1.
    +Input: root = [3,5,1,6,2,0,8,null,null,7,4], target = 5, k = 2
    +Output: [7,4,1]
    +Explanation: The nodes that are a distance 2 from the target node (with value 5) have values 7, 4, and 1.
    +
    - +

    Example 2:

    -Note that the inputs "root" and "target" are actually TreeNodes. -The descriptions of the inputs above are just serializations of these objects. +
    +Input: root = [1], target = 1, k = 3
    +Output: []
     

     

    - -

    Note:

    - -
      -
    1. The given tree is non-empty.
    2. -
    3. Each node in the tree has unique values 0 <= node.val <= 500.
    4. -
    5. The target node is a node in the tree.
    6. -
    7. 0 <= k <= 1000.
    8. -
    -
    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is in the range [1, 500].
    • +
    • 0 <= Node.val <= 500
    • +
    • All the values Node.val are unique.
    • +
    • target is the value of one of the nodes in the tree.
    • +
    • 0 <= k <= 1000
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/all-paths-from-source-lead-to-destination/README.md b/problems/all-paths-from-source-lead-to-destination/README.md index 9d11be5be..6f5e1223b 100644 --- a/problems/all-paths-from-source-lead-to-destination/README.md +++ b/problems/all-paths-from-source-lead-to-destination/README.md @@ -11,7 +11,80 @@ ## [1059. All Paths from Source Lead to Destination (Medium)](https://leetcode.com/problems/all-paths-from-source-lead-to-destination "从始点到终点的所有路径") +

    Given the edges of a directed graph, and two nodes source and destination of this graph, determine whether or not all paths starting from source eventually end at destination, that is:

    +
      +
    • At least one path exists from the source node to the destination node
    • +
    • If a path exists from the source node to a node with no outgoing edges, then that node is equal to destination.
    • +
    • The number of possible paths from source to destination is a finite number.
    • +
    + +

    Return true if and only if all roads from source lead to destination.

    + +

     

    + +

    Example 1:

    + +

    + +
    +Input: n = 3, edges = [[0,1],[0,2]], source = 0, destination = 2
    +Output: false
    +Explanation: It is possible to reach and get stuck on both node 1 and node 2.
    +
    + +

    Example 2:

    + +

    + +
    +Input: n = 4, edges = [[0,1],[0,3],[1,2],[2,1]], source = 0, destination = 3
    +Output: false
    +Explanation: We have two possibilities: to end at node 3, or to loop over node 1 and node 2 indefinitely.
    +
    + +

    Example 3:

    + +

    + +
    +Input: n = 4, edges = [[0,1],[0,2],[1,3],[2,3]], source = 0, destination = 3
    +Output: true
    +
    + +

    Example 4:

    + +

    + +
    +Input: n = 3, edges = [[0,1],[1,1],[1,2]], source = 0, destination = 2
    +Output: false
    +Explanation: All paths from the source node end at the destination node, but there are an infinite number of paths, such as 0-1-2, 0-1-1-2, 0-1-1-1-2, 0-1-1-1-1-2, and so on.
    +
    + +

    Example 5:

    + +

    + +
    +Input: n = 2, edges = [[0,1],[1,1]], source = 0, destination = 1
    +Output: false
    +Explanation: There is infinite self-loop at destination node.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. The given graph may have self loops and parallel edges.
    2. +
    3. The number of nodes n in the graph is between 1 and 10000
    4. +
    5. The number of edges in the graph is between 0 and 10000
    6. +
    7. 0 <= edges.length <= 10000
    8. +
    9. edges[i].length == 2
    10. +
    11. 0 <= source <= n - 1
    12. +
    13. 0 <= destination <= n - 1
    14. +
    ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/all-paths-from-source-to-target/README.md b/problems/all-paths-from-source-to-target/README.md index 012aa928a..13cd5f69b 100644 --- a/problems/all-paths-from-source-to-target/README.md +++ b/problems/all-paths-from-source-to-target/README.md @@ -11,9 +11,9 @@ ## [797. All Paths From Source to Target (Medium)](https://leetcode.com/problems/all-paths-from-source-to-target "所有可能的路径") -

    Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1, and return them in any order.

    +

    Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1 and return them in any order.

    -

    The graph is given as follows: graph[i] is a list of all nodes you can visit from node i (i.e., there is a directed edge from node i to node graph[i][j]).

    +

    The graph is given as follows: graph[i] is a list of all nodes you can visit from node i (i.e., there is a directed edge from node i to node graph[i][j]).

     

    Example 1:

    @@ -60,6 +60,7 @@
  • 2 <= n <= 15
  • 0 <= graph[i][j] < n
  • graph[i][j] != i (i.e., there will be no self-loops).
  • +
  • All the elements of graph[i] are unique.
  • The input graph is guaranteed to be a DAG.
  • diff --git a/problems/all-people-report-to-the-given-manager/README.md b/problems/all-people-report-to-the-given-manager/README.md index f6c743ee3..55c7ceec6 100644 --- a/problems/all-people-report-to-the-given-manager/README.md +++ b/problems/all-people-report-to-the-given-manager/README.md @@ -11,7 +11,58 @@ ## [1270. All People Report to the Given Manager (Medium)](https://leetcode.com/problems/all-people-report-to-the-given-manager "向公司CEO汇报工作的所有人") +

    Table: Employees

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| employee_id   | int     |
    +| employee_name | varchar |
    +| manager_id    | int     |
    ++---------------+---------+
    +employee_id is the primary key for this table.
    +Each row of this table indicates that the employee with ID employee_id and name employee_name reports his work to his/her direct manager with manager_id
    +The head of the company is the employee with employee_id = 1.
    +
    +Write an SQL query to find employee_id of all employees that directly or indirectly report their work to the head of the company. + +The indirect relation between managers will not exceed 3 managers as the company is small. + +Return result table in any order without duplicates. + +The query result format is in the following example: +
    +Employees table:
    ++-------------+---------------+------------+
    +| employee_id | employee_name | manager_id |
    ++-------------+---------------+------------+
    +| 1           | Boss          | 1          |
    +| 3           | Alice         | 3          |
    +| 2           | Bob           | 1          |
    +| 4           | Daniel        | 2          |
    +| 7           | Luis          | 4          |
    +| 8           | Jhon          | 3          |
    +| 9           | Angela        | 8          |
    +| 77          | Robert        | 1          |
    ++-------------+---------------+------------+
    +
    +Result table:
    ++-------------+
    +| employee_id |
    ++-------------+
    +| 2           |
    +| 77          |
    +| 4           |
    +| 7           |
    ++-------------+
    +
    +The head of the company is the employee with employee_id 1.
    +The employees with employee_id 2 and 77 report their work directly to the head of the company.
    +The employee with employee_id 4 report his work indirectly to the head of the company 4 --> 2 --> 1. 
    +The employee with employee_id 7 report his work indirectly to the head of the company 7 --> 4 --> 2 --> 1.
    +The employees with employee_id 3, 8 and 9 don't report their work to head of company directly or indirectly. 
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md b/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md new file mode 100644 index 000000000..619eb1796 --- /dev/null +++ b/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../maximum-of-minimum-values-in-all-subarrays "Maximum of Minimum Values in All Subarrays") +                 +[Next >](../three-divisors "Three Divisors") + +## [1951. All the Pairs With the Maximum Number of Common Followers (Medium)](https://leetcode.com/problems/all-the-pairs-with-the-maximum-number-of-common-followers "") + + diff --git a/problems/all-the-pairs-with-the-maximum-number-of-common-followers/mysql_schemas.sql b/problems/all-the-pairs-with-the-maximum-number-of-common-followers/mysql_schemas.sql new file mode 100644 index 000000000..358f44061 --- /dev/null +++ b/problems/all-the-pairs-with-the-maximum-number-of-common-followers/mysql_schemas.sql @@ -0,0 +1,11 @@ +Create table If Not Exists Relations (user_id int, follower_id int); +Truncate table Relations; +insert into Relations (user_id, follower_id) values ('1', '3'); +insert into Relations (user_id, follower_id) values ('2', '3'); +insert into Relations (user_id, follower_id) values ('7', '3'); +insert into Relations (user_id, follower_id) values ('1', '4'); +insert into Relations (user_id, follower_id) values ('2', '4'); +insert into Relations (user_id, follower_id) values ('7', '4'); +insert into Relations (user_id, follower_id) values ('1', '5'); +insert into Relations (user_id, follower_id) values ('2', '6'); +insert into Relations (user_id, follower_id) values ('7', '5'); diff --git a/problems/analyze-user-website-visit-pattern/README.md b/problems/analyze-user-website-visit-pattern/README.md index 9fc0be7bc..e6a48d34d 100644 --- a/problems/analyze-user-website-visit-pattern/README.md +++ b/problems/analyze-user-website-visit-pattern/README.md @@ -11,7 +11,51 @@ ## [1152. Analyze User Website Visit Pattern (Medium)](https://leetcode.com/problems/analyze-user-website-visit-pattern "用户网站访问行为分析") +

    We are given some website visits: the user with name username[i] visited the website website[i] at time timestamp[i].

    +

    A 3-sequence is a list of websites of length 3 sorted in ascending order by the time of their visits.  (The websites in a 3-sequence are not necessarily distinct.)

    + +

    Find the 3-sequence visited by the largest number of users. If there is more than one solution, return the lexicographically smallest such 3-sequence.

    + +

     

    + +

    Example 1:

    + +
    +Input: username = ["joe","joe","joe","james","james","james","james","mary","mary","mary"], timestamp = [1,2,3,4,5,6,7,8,9,10], website = ["home","about","career","home","cart","maps","home","home","about","career"]
    +Output: ["home","about","career"]
    +Explanation: 
    +The tuples in this example are:
    +["joe", 1, "home"]
    +["joe", 2, "about"]
    +["joe", 3, "career"]
    +["james", 4, "home"]
    +["james", 5, "cart"]
    +["james", 6, "maps"]
    +["james", 7, "home"]
    +["mary", 8, "home"]
    +["mary", 9, "about"]
    +["mary", 10, "career"]
    +The 3-sequence ("home", "about", "career") was visited at least once by 2 users.
    +The 3-sequence ("home", "cart", "maps") was visited at least once by 1 user.
    +The 3-sequence ("home", "cart", "home") was visited at least once by 1 user.
    +The 3-sequence ("home", "maps", "home") was visited at least once by 1 user.
    +The 3-sequence ("cart", "maps", "home") was visited at least once by 1 user.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 3 <= N = username.length = timestamp.length = website.length <= 50
    2. +
    3. 1 <= username[i].length <= 10
    4. +
    5. 0 <= timestamp[i] <= 10^9
    6. +
    7. 1 <= website[i].length <= 10
    8. +
    9. Both username[i] and website[i] contain only lowercase characters.
    10. +
    11. It is guaranteed that there is at least one user who visited at least 3 websites.
    12. +
    13. No user visits two websites at the same time.
    14. +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/android-unlock-patterns/README.md b/problems/android-unlock-patterns/README.md index af8d16623..9d96cd889 100644 --- a/problems/android-unlock-patterns/README.md +++ b/problems/android-unlock-patterns/README.md @@ -11,7 +11,54 @@ ## [351. Android Unlock Patterns (Medium)](https://leetcode.com/problems/android-unlock-patterns "安卓系统手势解锁") +

    Given an Android 3x3 key lock screen and two integers m and n, where 1 ≤ m ≤ n ≤ 9, count the total number of unlock patterns of the Android lock screen, which consist of minimum of m keys and maximum n keys.

    +

     

    + +

    Rules for a valid pattern:

    + +
      +
    1. Each pattern must connect at least m keys and at most n keys.
    2. +
    3. All the keys must be distinct.
    4. +
    5. If the line connecting two consecutive keys in the pattern passes through any other keys, the other keys must have previously selected in the pattern. No jumps through non selected key is allowed.
    6. +
    7. The order of keys used matters.
    8. +
    + +

     

    + +
    +
    + +

     

    + +

    Explanation:

    + +
    +| 1 | 2 | 3 |
    +| 4 | 5 | 6 |
    +| 7 | 8 | 9 |
    + +

    Invalid move: 4 - 1 - 3 - 6
    +Line 1 - 3 passes through key 2 which had not been selected in the pattern.

    + +

    Invalid move: 4 - 1 - 9 - 2
    +Line 1 - 9 passes through key 5 which had not been selected in the pattern.

    + +

    Valid move: 2 - 4 - 1 - 3 - 6
    +Line 1 - 3 is valid because it passes through key 2, which had been selected in the pattern

    + +

    Valid move: 6 - 5 - 4 - 1 - 9 - 2
    +Line 1 - 9 is valid because it passes through key 5, which had been selected in the pattern.

    + +

     

    + +

    Example:

    + +
    +
    +Input: m = 1, n = 1
    +Output: 9
    +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/armstrong-number/README.md b/problems/armstrong-number/README.md index d7e65b07d..2a5aef613 100644 --- a/problems/armstrong-number/README.md +++ b/problems/armstrong-number/README.md @@ -11,7 +11,37 @@ ## [1134. Armstrong Number (Easy)](https://leetcode.com/problems/armstrong-number "阿姆斯特朗数") +

    The k-digit number N is an Armstrong number if and only if the k-th power of each digit sums to N.

    +

    Given a positive integer N, return true if and only if it is an Armstrong number.

    + +

     

    + +

    Example 1:

    + +
    +Input: 153
    +Output: true
    +Explanation: 
    +153 is a 3-digit number, and 153 = 1^3 + 5^3 + 3^3.
    +
    + +

    Example 2:

    + +
    +Input: 123
    +Output: false
    +Explanation: 
    +123 is a 3-digit number, and 123 != 1^3 + 2^3 + 3^3 = 36.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= N <= 10^8
    2. +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/array-transformation/README.md b/problems/array-transformation/README.md index 0dcd0d0ea..e691c4aaf 100644 --- a/problems/array-transformation/README.md +++ b/problems/array-transformation/README.md @@ -11,7 +11,47 @@ ## [1243. Array Transformation (Easy)](https://leetcode.com/problems/array-transformation "数组变换") +

    Given an initial array arr, every day you produce a new array using the array of the previous day.

    +

    On the i-th day, you do the following operations on the array of day i-1 to produce the array of day i:

    + +
      +
    1. If an element is smaller than both its left neighbor and its right neighbor, then this element is incremented.
    2. +
    3. If an element is bigger than both its left neighbor and its right neighbor, then this element is decremented.
    4. +
    5. The first and last elements never change.
    6. +
    + +

    After some days, the array does not change. Return that final array.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [6,2,3,4]
    +Output: [6,3,3,4]
    +Explanation: 
    +On the first day, the array is changed from [6,2,3,4] to [6,3,3,4].
    +No more operations can be done to this array.
    +
    + +

    Example 2:

    + +
    +Input: arr = [1,6,3,4,3,5]
    +Output: [1,4,4,4,4,5]
    +Explanation: 
    +On the first day, the array is changed from [1,6,3,4,3,5] to [1,5,4,3,4,5].
    +On the second day, the array is changed from [1,5,4,3,4,5] to [1,4,4,4,4,5].
    +No more operations can be done to this array.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 100
    • +
    • 1 <= arr[i] <= 100
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/article-views-i/README.md b/problems/article-views-i/README.md index f2ffc14f7..d7e60e148 100644 --- a/problems/article-views-i/README.md +++ b/problems/article-views-i/README.md @@ -11,7 +11,49 @@ ## [1148. Article Views I (Easy)](https://leetcode.com/problems/article-views-i "文章浏览 I") +

    Table: Views

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| article_id    | int     |
    +| author_id     | int     |
    +| viewer_id     | int     |
    +| view_date     | date    |
    ++---------------+---------+
    +There is no primary key for this table, it may have duplicate rows.
    +Each row of this table indicates that some viewer viewed an article (written by some author) on some date. 
    +Note that equal author_id and viewer_id indicate the same person.
    + +

     

    + +

    Write an SQL query to find all the authors that viewed at least one of their own articles, sorted in ascending order by their id.

    + +

    The query result format is in the following example:

    + +
    +Views table:
    ++------------+-----------+-----------+------------+
    +| article_id | author_id | viewer_id | view_date  |
    ++------------+-----------+-----------+------------+
    +| 1          | 3         | 5         | 2019-08-01 |
    +| 1          | 3         | 6         | 2019-08-02 |
    +| 2          | 7         | 7         | 2019-08-01 |
    +| 2          | 7         | 6         | 2019-08-02 |
    +| 4          | 7         | 1         | 2019-07-22 |
    +| 3          | 4         | 4         | 2019-07-21 |
    +| 3          | 4         | 4         | 2019-07-21 |
    ++------------+-----------+-----------+------------+
    +
    +Result table:
    ++------+
    +| id   |
    ++------+
    +| 4    |
    +| 7    |
    ++------+
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/article-views-ii/README.md b/problems/article-views-ii/README.md index 6de4a276d..efc135214 100644 --- a/problems/article-views-ii/README.md +++ b/problems/article-views-ii/README.md @@ -11,7 +11,49 @@ ## [1149. Article Views II (Medium)](https://leetcode.com/problems/article-views-ii "文章浏览 II") +

    Table: Views

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| article_id    | int     |
    +| author_id     | int     |
    +| viewer_id     | int     |
    +| view_date     | date    |
    ++---------------+---------+
    +There is no primary key for this table, it may have duplicate rows.
    +Each row of this table indicates that some viewer viewed an article (written by some author) on some date. 
    +Note that equal author_id and viewer_id indicate the same person.
    + +

     

    + +

    Write an SQL query to find all the people who viewed more than one article on the same date, sorted in ascending order by their id.

    + +

    The query result format is in the following example:

    + +
    +Views table:
    ++------------+-----------+-----------+------------+
    +| article_id | author_id | viewer_id | view_date  |
    ++------------+-----------+-----------+------------+
    +| 1          | 3         | 5         | 2019-08-01 |
    +| 3          | 4         | 5         | 2019-08-01 |
    +| 1          | 3         | 6         | 2019-08-02 |
    +| 2          | 7         | 7         | 2019-08-01 |
    +| 2          | 7         | 6         | 2019-08-02 |
    +| 4          | 7         | 1         | 2019-07-22 |
    +| 3          | 4         | 4         | 2019-07-21 |
    +| 3          | 4         | 4         | 2019-07-21 |
    ++------------+-----------+-----------+------------+
    +
    +Result table:
    ++------+
    +| id   |
    ++------+
    +| 5    |
    +| 6    |
    ++------+
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/average-salary-departments-vs-company/README.md b/problems/average-salary-departments-vs-company/README.md index 426ec7a09..bd0d831f3 100644 --- a/problems/average-salary-departments-vs-company/README.md +++ b/problems/average-salary-departments-vs-company/README.md @@ -11,10 +11,64 @@ ## [615. Average Salary: Departments VS Company (Hard)](https://leetcode.com/problems/average-salary-departments-vs-company "平均工资:部门与公司比较") +Given two tables as below, write a query to display the comparison result (higher/lower/same) of the average salary of employees in a department to the company's average salary. +

     

    +Table: salary +
    +| id | employee_id | amount | pay_date   |
    +|----|-------------|--------|------------|
    +| 1  | 1           | 9000   | 2017-03-31 |
    +| 2  | 2           | 6000   | 2017-03-31 |
    +| 3  | 3           | 10000  | 2017-03-31 |
    +| 4  | 1           | 7000   | 2017-02-28 |
    +| 5  | 2           | 6000   | 2017-02-28 |
    +| 6  | 3           | 8000   | 2017-02-28 |
    +
    + +

     

    +The employee_id column refers to the employee_id in the following table employee. + +

     

    + +
    +| employee_id | department_id |
    +|-------------|---------------|
    +| 1           | 1             |
    +| 2           | 2             |
    +| 3           | 2             |
    +
    + +

     

    +So for the sample data above, the result is: + +

     

    + +
    +| pay_month | department_id | comparison  |
    +|-----------|---------------|-------------|
    +| 2017-03   | 1             | higher      |
    +| 2017-03   | 2             | lower       |
    +| 2017-02   | 1             | same        |
    +| 2017-02   | 2             | same        |
    +
    + +

     

    +Explanation + +

     

    +In March, the company's average salary is (9000+6000+10000)/3 = 8333.33... + +

     

    +The average salary for department '1' is 9000, which is the salary of employee_id '1' since there is only one employee in this department. So the comparison result is 'higher' since 9000 > 8333.33 obviously. + +

     

    +The average salary of department '2' is (6000 + 10000)/2 = 8000, which is the average of employee_id '2' and '3'. So the comparison result is 'lower' since 8000 < 8333.33. + +

     

    +With he same formula for the average salary comparison in February, the result is 'same' since both the department '1' and '2' have the same average salary with the company, which is 7000. + +

     

    ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Countries You Can Safely Invest In](../countries-you-can-safely-invest-in) (Medium) diff --git a/problems/average-selling-price/README.md b/problems/average-selling-price/README.md index f5163ddd3..cb8de6089 100644 --- a/problems/average-selling-price/README.md +++ b/problems/average-selling-price/README.md @@ -11,7 +11,78 @@ ## [1251. Average Selling Price (Easy)](https://leetcode.com/problems/average-selling-price "平均售价") +

    Table: Prices

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| product_id    | int     |
    +| start_date    | date    |
    +| end_date      | date    |
    +| price         | int     |
    ++---------------+---------+
    +(product_id, start_date, end_date) is the primary key for this table.
    +Each row of this table indicates the price of the product_id in the period from start_date to end_date.
    +For each product_id there will be no two overlapping periods. That means there will be no two intersecting periods for the same product_id.
    +
    + +

     

    + +

    Table: UnitsSold

    + +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| product_id    | int     |
    +| purchase_date | date    |
    +| units         | int     |
    ++---------------+---------+
    +There is no primary key for this table, it may contain duplicates.
    +Each row of this table indicates the date, units and product_id of each product sold. 
    +
    + +

     

    + +

    Write an SQL query to find the average selling price for each product.

    + +

    average_price should be rounded to 2 decimal places.

    + +

    The query result format is in the following example:

    + +
    +Prices table:
    ++------------+------------+------------+--------+
    +| product_id | start_date | end_date   | price  |
    ++------------+------------+------------+--------+
    +| 1          | 2019-02-17 | 2019-02-28 | 5      |
    +| 1          | 2019-03-01 | 2019-03-22 | 20     |
    +| 2          | 2019-02-01 | 2019-02-20 | 15     |
    +| 2          | 2019-02-21 | 2019-03-31 | 30     |
    ++------------+------------+------------+--------+
    + 
    +UnitsSold table:
    ++------------+---------------+-------+
    +| product_id | purchase_date | units |
    ++------------+---------------+-------+
    +| 1          | 2019-02-25    | 100   |
    +| 1          | 2019-03-01    | 15    |
    +| 2          | 2019-02-10    | 200   |
    +| 2          | 2019-03-22    | 30    |
    ++------------+---------------+-------+
    +
    +Result table:
    ++------------+---------------+
    +| product_id | average_price |
    ++------------+---------------+
    +| 1          | 6.96          |
    +| 2          | 16.96         |
    ++------------+---------------+
    +Average selling price = Total Price of Product / Number of products sold.
    +Average selling price for product 1 = ((100 * 5) + (15 * 20)) / 115 = 6.96
    +Average selling price for product 2 = ((200 * 15) + (30 * 30)) / 230 = 16.96
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/basic-calculator-iii/README.md b/problems/basic-calculator-iii/README.md index a68a15b09..a11c8252e 100644 --- a/problems/basic-calculator-iii/README.md +++ b/problems/basic-calculator-iii/README.md @@ -11,7 +11,26 @@ ## [772. Basic Calculator III (Hard)](https://leetcode.com/problems/basic-calculator-iii "基本计算器 III") +

    Implement a basic calculator to evaluate a simple expression string.

    +

    The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty spaces .

    + +

    The expression string contains only non-negative integers, +, -, *, / operators , open ( and closing parentheses ) and empty spaces . The integer division should truncate toward zero.

    + +

    You may assume that the given expression is always valid. All intermediate results will be in the range of [-2147483648, 2147483647].

    + +

    Some examples:

    + +
    +"1 + 1" = 2
    +" 6-4 / 2 " = 4
    +"2*(5+5*2)/3+(6/2+8)" = 21
    +"(2+6* 3+5- (3*14/7+2)*5)+3"=-12
    +
    + +

     

    + +

    Note: Do not use the eval built-in library function.

    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/basic-calculator/README.md b/problems/basic-calculator/README.md index 6eaa01ff9..1485fb9aa 100644 --- a/problems/basic-calculator/README.md +++ b/problems/basic-calculator/README.md @@ -37,14 +37,6 @@ Output: 23 -

    Example 4:

    - -
    -Input: s = "+48 + -48"
    -Output: 0
    -Explanation: Numbers can have multiple digits and start with +/-.
    -
    -

     

    Constraints:

    @@ -52,6 +44,8 @@
  • 1 <= s.length <= 3 * 105
  • s consists of digits, '+', '-', '(', ')', and ' '.
  • s represents a valid expression.
  • +
  • '+' is not used as a unary operation.
  • +
  • '-' could be used as a unary operation but it has to be followed by parentheses.
  • Every number and running calculation will fit in a signed 32-bit integer.
  • diff --git a/problems/beautiful-array/README.md b/problems/beautiful-array/README.md index f5af73d91..481b997ca 100644 --- a/problems/beautiful-array/README.md +++ b/problems/beautiful-array/README.md @@ -11,41 +11,30 @@ ## [932. Beautiful Array (Medium)](https://leetcode.com/problems/beautiful-array "漂亮数组") -

    For some fixed n, an array nums is beautiful if it is a permutation of the integers 1, 2, ..., n, such that:

    +

    An array nums of length n is beautiful if:

    -

    For every i < j, there is no k with i < k < j such that nums[k] * 2 = nums[i] + nums[j].

    +
      +
    • nums is a permutation of the integers in the range [1, n].
    • +
    • For every 0 <= i < j < n, there is no index k with i < k < j where 2 * nums[k] == nums[i] + nums[j].
    • +
    -

    Given n, return any beautiful array nums.  (It is guaranteed that one exists.)

    +

    Given the integer n, return any beautiful array nums of length n. There will be at least one valid answer for the given n.

     

    -

    Example 1:

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

    Example 2:

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

    Example 2:

    - -
    -Input: n = 5
    -Output: [3,1,2,5,4]
    -

     

    -
    - -

    Note:

    +

    Constraints:

    • 1 <= n <= 1000
    -
    -
     
    -
    - ### Related Topics [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] diff --git a/problems/before-and-after-puzzle/README.md b/problems/before-and-after-puzzle/README.md index 4c1aa70cf..61d1a4d67 100644 --- a/problems/before-and-after-puzzle/README.md +++ b/problems/before-and-after-puzzle/README.md @@ -11,7 +11,57 @@ ## [1181. Before and After Puzzle (Medium)](https://leetcode.com/problems/before-and-after-puzzle "前后拼接") +

    Given a list of phrases, generate a list of Before and After puzzles.

    +

    A phrase is a string that consists of lowercase English letters and spaces only. No space appears in the start or the end of a phrase. There are no consecutive spaces in a phrase.

    + +

    Before and After puzzles are phrases that are formed by merging two phrases where the last word of the first phrase is the same as the first word of the second phrase.

    + +

    Return the Before and After puzzles that can be formed by every two phrases phrases[i] and phrases[j] where i != j. Note that the order of matching two phrases matters, we want to consider both orders.

    + +

    You should return a list of distinct strings sorted lexicographically.

    + +

     

    +

    Example 1:

    + +
    +Input: phrases = ["writing code","code rocks"]
    +Output: ["writing code rocks"]
    +
    + +

    Example 2:

    + +
    +Input: phrases = ["mission statement",
    +                  "a quick bite to eat",
    +                  "a chip off the old block",
    +                  "chocolate bar",
    +                  "mission impossible",
    +                  "a man on a mission",
    +                  "block party",
    +                  "eat my words",
    +                  "bar of soap"]
    +Output: ["a chip off the old block party",
    +         "a man on a mission impossible",
    +         "a man on a mission statement",
    +         "a quick bite to eat my words",
    +         "chocolate bar of soap"]
    +
    + +

    Example 3:

    + +
    +Input: phrases = ["a","b","a"]
    +Output: ["a"]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= phrases.length <= 100
    • +
    • 1 <= phrases[i].length <= 100
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/best-meeting-point/README.md b/problems/best-meeting-point/README.md index 84cc36cbc..f513e9738 100644 --- a/problems/best-meeting-point/README.md +++ b/problems/best-meeting-point/README.md @@ -11,7 +11,24 @@ ## [296. Best Meeting Point (Hard)](https://leetcode.com/problems/best-meeting-point "最佳的碰头地点") +

    A group of two or more people wants to meet and minimize the total travel distance. You are given a 2D grid of values 0 or 1, where each 1 marks the home of someone in the group. The distance is calculated using Manhattan Distance, where distance(p1, p2) = |p2.x - p1.x| + |p2.y - p1.y|.

    +

    Example:

    + +
    +Input: 
    +
    +1 - 0 - 0 - 0 - 1
    +|   |   |   |   |
    +0 - 0 - 0 - 0 - 0
    +|   |   |   |   |
    +0 - 0 - 1 - 0 - 0
    +
    +Output: 6 
    +
    +Explanation: Given three people living at (0,0), (0,4), and (2,2):
    +             The point (0,2) is an ideal meeting point, as the total travel distance 
    +             of 2+2+2=6 is minimal. So return 6.
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/biggest-single-number/README.md b/problems/biggest-single-number/README.md index 23a0f8647..bb71e7128 100644 --- a/problems/biggest-single-number/README.md +++ b/problems/biggest-single-number/README.md @@ -11,7 +11,34 @@ ## [619. Biggest Single Number (Easy)](https://leetcode.com/problems/biggest-single-number "只出现一次的最大数字") +

    Table my_numbers contains many numbers in column num including duplicated ones.
    +Can you write a SQL query to find the biggest number, which only appears once.

    +
    ++---+
    +|num|
    ++---+
    +| 8 |
    +| 8 |
    +| 3 |
    +| 3 |
    +| 1 |
    +| 4 |
    +| 5 |
    +| 6 | 
    +
    +For the sample data above, your query should return the following result: + +
    ++---+
    +|num|
    ++---+
    +| 6 |
    +
    +Note:
    +If there is no such number, just output null. + +

     

    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/binary-tree-longest-consecutive-sequence-ii/README.md b/problems/binary-tree-longest-consecutive-sequence-ii/README.md index 48a539084..9c5dc7996 100644 --- a/problems/binary-tree-longest-consecutive-sequence-ii/README.md +++ b/problems/binary-tree-longest-consecutive-sequence-ii/README.md @@ -11,7 +11,37 @@ ## [549. Binary Tree Longest Consecutive Sequence II (Medium)](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence-ii "二叉树中最长的连续序列") +

    Given a binary tree, you need to find the length of Longest Consecutive Path in Binary Tree.

    +

    Especially, this path can be either increasing or decreasing. For example, [1,2,3,4] and [4,3,2,1] are both considered valid, but the path [1,2,4,3] is not valid. On the other hand, the path can be in the child-Parent-child order, where not necessarily be parent-child order.

    + +

    Example 1:

    + +
    +Input:
    +        1
    +       / \
    +      2   3
    +Output: 2
    +Explanation: The longest consecutive path is [1, 2] or [2, 1].
    +
    + +

     

    + +

    Example 2:

    + +
    +Input:
    +        2
    +       / \
    +      1   3
    +Output: 3
    +Explanation: The longest consecutive path is [1, 2, 3] or [3, 2, 1].
    +
    + +

     

    + +

    Note: All the values of tree nodes are in the range of [-1e7, 1e7].

    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/binary-tree-longest-consecutive-sequence/README.md b/problems/binary-tree-longest-consecutive-sequence/README.md index b42983f61..0e25f7869 100644 --- a/problems/binary-tree-longest-consecutive-sequence/README.md +++ b/problems/binary-tree-longest-consecutive-sequence/README.md @@ -11,7 +11,43 @@ ## [298. Binary Tree Longest Consecutive Sequence (Medium)](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence "二叉树最长连续序列") +

    Given a binary tree, find the length of the longest consecutive sequence path.

    +

    The path refers to any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The longest consecutive path need to be from parent to child (cannot be the reverse).

    + +

    Example 1:

    + +
    +Input:
    +
    +   1
    +    \
    +     3
    +    / \
    +   2   4
    +        \
    +         5
    +
    +Output: 3
    +
    +Explanation: Longest consecutive sequence path is 3-4-5, so return 3.
    + +

    Example 2:

    + +
    +Input:
    +
    +   2
    +    \
    +     3
    +    / 
    +   2    
    +  / 
    + 1
    +
    +Output: 2 
    +
    +Explanation: Longest consecutive sequence path is 2-3, not 3-2-1, so return 2.
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/binary-tree-upside-down/README.md b/problems/binary-tree-upside-down/README.md index 2fe055baa..a3bf356be 100644 --- a/problems/binary-tree-upside-down/README.md +++ b/problems/binary-tree-upside-down/README.md @@ -11,7 +11,47 @@ ## [156. Binary Tree Upside Down (Medium)](https://leetcode.com/problems/binary-tree-upside-down "上下翻转二叉树") +

    Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty, flip it upside down and turn it into a tree where the original right nodes turned into left leaf nodes. Return the new root.

    +

    Example:

    + +
    +Input: [1,2,3,4,5]
    +
    +    1
    +   / \
    +  2   3
    + / \
    +4   5
    +
    +Output: return the root of the binary tree [4,5,2,#,#,3,1]
    +
    +   4
    +  / \
    + 5   2
    +    / \
    +   3   1  
    +
    + +

    Clarification:

    + +

    Confused what [4,5,2,#,#,3,1] means? Read more below on how binary tree is serialized on OJ.

    + +

    The serialization of a binary tree follows a level order traversal, where '#' signifies a path terminator where no node exists below.

    + +

    Here's an example:

    + +
    +   1
    +  / \
    + 2   3
    +    /
    +   4
    +    \
    +     5
    +
    + +

    The above binary tree is serialized as [1,2,3,#,#,4,#,#,5].

    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/binary-tree-vertical-order-traversal/README.md b/problems/binary-tree-vertical-order-traversal/README.md index b26f1dbd7..b8069f38e 100644 --- a/problems/binary-tree-vertical-order-traversal/README.md +++ b/problems/binary-tree-vertical-order-traversal/README.md @@ -11,7 +11,83 @@ ## [314. Binary Tree Vertical Order Traversal (Medium)](https://leetcode.com/problems/binary-tree-vertical-order-traversal "二叉树的垂直遍历") +

    Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column).

    +

    If two nodes are in the same row and column, the order should be from left to right.

    + +

    Examples 1:

    + +
    +Input: [3,9,20,null,null,15,7]
    +
    +   3
    +  /\
    + /  \
    + 9  20
    +    /\
    +   /  \
    +  15   7 
    +
    +Output:
    +
    +[
    +  [9],
    +  [3,15],
    +  [20],
    +  [7]
    +]
    +
    + +

    Examples 2:

    + +
    +Input: [3,9,8,4,0,1,7]
    +
    +     3
    +    /\
    +   /  \
    +   9   8
    +  /\  /\
    + /  \/  \
    + 4  01   7 
    +
    +Output:
    +
    +[
    +  [4],
    +  [9],
    +  [3,0,1],
    +  [8],
    +  [7]
    +]
    +
    + +

    Examples 3:

    + +
    +Input: [3,9,8,4,0,1,7,null,null,null,2,5] (0's right child is 2 and 1's left child is 5)
    +
    +     3
    +    /\
    +   /  \
    +   9   8
    +  /\  /\
    + /  \/  \
    + 4  01   7
    +    /\
    +   /  \
    +   5   2
    +
    +Output:
    +
    +[
    +  [4],
    +  [9,5],
    +  [3,0,1],
    +  [8,2],
    +  [7]
    +]
    +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/bold-words-in-string/README.md b/problems/bold-words-in-string/README.md index ffbdaa36d..30a868929 100644 --- a/problems/bold-words-in-string/README.md +++ b/problems/bold-words-in-string/README.md @@ -11,7 +11,21 @@ ## [758. Bold Words in String (Medium)](https://leetcode.com/problems/bold-words-in-string "字符串中的加粗单词") +

    +Given a set of keywords words and a string S, make all appearances of all keywords in S bold. Any letters between <b> and </b> tags become bold. +

    +The returned string should use the least number of tags possible, and of course the tags should form a valid combination. +

    +

    +For example, given that words = ["ab", "bc"] and S = "aabcd", we should return "a<b>abc</b>d". Note that returning "a<b>a<b>b</b>c</b>d" would use more tags, so it is incorrect. +

    +

    Note:

      +
    1. words has length in range [0, 50].
    2. +
    3. words[i] has length in range [1, 10].
    4. +
    5. S has length in range [0, 500].
    6. +
    7. All characters in words[i] and S are lowercase letters.
    8. +

    ### Related Topics [[Trie](../../tag/trie/README.md)] diff --git a/problems/bomb-enemy/README.md b/problems/bomb-enemy/README.md index 454322602..392e525ad 100644 --- a/problems/bomb-enemy/README.md +++ b/problems/bomb-enemy/README.md @@ -11,7 +11,24 @@ ## [361. Bomb Enemy (Medium)](https://leetcode.com/problems/bomb-enemy "轰炸敌人") +

    Given a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero), return the maximum enemies you can kill using one bomb.
    +The bomb kills all the enemies in the same row and column from the planted point until it hits the wall since the wall is too strong to be destroyed.
    +Note: You can only put the bomb at an empty cell.

    +

    Example:

    + +
    +
    +Input: [["0","E","0","0"],["E","0","W","E"],["0","E","0","0"]]
    +Output: 3 
    +Explanation: For the given grid,
    +
    +0 E 0 0 
    +E 0 W E 
    +0 E 0 0
    +
    +Placing a bomb at (1,1) kills 3 enemies.
    +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/boundary-of-binary-tree/README.md b/problems/boundary-of-binary-tree/README.md index 73b39ad56..8b47a94b0 100644 --- a/problems/boundary-of-binary-tree/README.md +++ b/problems/boundary-of-binary-tree/README.md @@ -11,7 +11,59 @@ ## [545. Boundary of Binary Tree (Medium)](https://leetcode.com/problems/boundary-of-binary-tree "二叉树的边界") +

    Given a binary tree, return the values of its boundary in anti-clockwise direction starting from root. Boundary includes left boundary, leaves, and right boundary in order without duplicate nodes.  (The values of the nodes may still be duplicates.)

    +

    Left boundary is defined as the path from root to the left-most node. Right boundary is defined as the path from root to the right-most node. If the root doesn't have left subtree or right subtree, then the root itself is left boundary or right boundary. Note this definition only applies to the input binary tree, and not applies to any subtrees.

    + +

    The left-most node is defined as a leaf node you could reach when you always firstly travel to the left subtree if exists. If not, travel to the right subtree. Repeat until you reach a leaf node.

    + +

    The right-most node is also defined by the same way with left and right exchanged.

    + +

    Example 1

    + +
    +Input:
    +  1
    +   \
    +    2
    +   / \
    +  3   4
    +
    +Ouput:
    +[1, 3, 4, 2]
    +
    +Explanation:
    +The root doesn't have left subtree, so the root itself is left boundary.
    +The leaves are node 3 and 4.
    +The right boundary are node 1,2,4. Note the anti-clockwise direction means you should output reversed right boundary.
    +So order them in anti-clockwise without duplicates and we have [1,3,4,2].
    +
    + +

     

    + +

    Example 2

    + +
    +Input:
    +    ____1_____
    +   /          \
    +  2            3
    + / \          / 
    +4   5        6   
    +   / \      / \
    +  7   8    9  10  
    +       
    +Ouput:
    +[1,2,4,7,8,9,10,6,3]
    +
    +Explanation:
    +The left boundary are node 1,2,4. (4 is the left-most node according to definition)
    +The leaves are node 4,7,8,9,10.
    +The right boundary are node 1,3,6,10. (10 is the right-most node).
    +So order them in anti-clockwise without duplicate nodes we have [1,2,4,7,8,9,10,6,3].
    +
    + +

     

    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/brace-expansion/README.md b/problems/brace-expansion/README.md index b215da2c5..29a57fa5b 100644 --- a/problems/brace-expansion/README.md +++ b/problems/brace-expansion/README.md @@ -11,7 +11,39 @@ ## [1087. Brace Expansion (Medium)](https://leetcode.com/problems/brace-expansion "花括号展开") +

    A string S represents a list of words.

    +

    Each letter in the word has 1 or more options.  If there is one option, the letter is represented as is.  If there is more than one option, then curly braces delimit the options.  For example, "{a,b,c}" represents options ["a", "b", "c"].

    + +

    For example, "{a,b,c}d{e,f}" represents the list ["ade", "adf", "bde", "bdf", "cde", "cdf"].

    + +

    Return all words that can be formed in this manner, in lexicographical order.

    + +

     

    + +

    Example 1:

    + +
    +Input: "{a,b}c{d,e}f"
    +Output: ["acdf","acef","bcdf","bcef"]
    +
    + +

    Example 2:

    + +
    +Input: "abcd"
    +Output: ["abcd"]
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= S.length <= 50
    2. +
    3. There are no nested curly brackets.
    4. +
    5. All characters inside a pair of consecutive opening and ending curly brackets are different.
    6. +
    ### Related Topics [[Breadth-First Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/broken-calculator/README.md b/problems/broken-calculator/README.md index ef2434b74..cd680fffa 100644 --- a/problems/broken-calculator/README.md +++ b/problems/broken-calculator/README.md @@ -11,59 +11,54 @@ ## [991. Broken Calculator (Medium)](https://leetcode.com/problems/broken-calculator "坏了的计算器") -

    On a broken calculator that has a number showing on its display, we can perform two operations:

    +

    There is a broken calculator that has the integer startValue on its display initially. In on operation you can:

      -
    • Double: Multiply the number on the display by 2, or;
    • -
    • Decrement: Subtract 1 from the number on the display.
    • +
    • multiply the number on the display by 2, or
    • +
    • subtract 1 from the number on the display.
    -

    Initially, the calculator is displaying the number x.

    - -

    Return the minimum number of operations needed to display the number y.

    +

    Given two integers startValue and target, return the minimum number of operations needed to display target on the calculator.

     

    -

    Example 1:

    -Input: x = 2, y = 3
    -Output: 2
    -Explanation: Use double operation and then decrement operation {2 -> 4 -> 3}.
    +Input: startValue = 2, target = 3
    +Output: 2
    +Explanation: Use double operation and then decrement operation {2 -> 4 -> 3}.
     

    Example 2:

    -Input: x = 5, y = 8
    -Output: 2
    -Explanation: Use decrement and then double {5 -> 4 -> 8}.
    +Input: startValue = 5, target = 8
    +Output: 2
    +Explanation: Use decrement and then double {5 -> 4 -> 8}.
     

    Example 3:

    -Input: x = 3, y = 10
    -Output: 3
    -Explanation:  Use double, decrement and double {3 -> 6 -> 5 -> 10}.
    +Input: startValue = 3, target = 10
    +Output: 3
    +Explanation: Use double, decrement and double {3 -> 6 -> 5 -> 10}.
     

    Example 4:

    -Input: x = 1024, y = 1
    -Output: 1023
    -Explanation: Use decrement operations 1023 times.
    +Input: startValue = 1024, target = 1
    +Output: 1023
    +Explanation: Use decrement operations 1023 times.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= x <= 109
    2. -
    3. 1 <= y <= 109
    4. -
    +
      +
    • 1 <= x, y <= 109
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/build-an-array-with-stack-operations/README.md b/problems/build-an-array-with-stack-operations/README.md index 60dd71263..1a0aec601 100644 --- a/problems/build-an-array-with-stack-operations/README.md +++ b/problems/build-an-array-with-stack-operations/README.md @@ -68,8 +68,8 @@ Read number 3 and automatically push in the array -> [1,3] ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] + [[Stack](../../tag/stack/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/burst-balloons/README.md b/problems/burst-balloons/README.md index 01d0681b5..e2fb7335a 100644 --- a/problems/burst-balloons/README.md +++ b/problems/burst-balloons/README.md @@ -44,7 +44,7 @@ coins = 3*1*5 + 3*5*8 + 1*3*8 + 1*8*1 = 167
    ### Related Topics - [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions diff --git a/problems/campus-bikes-ii/README.md b/problems/campus-bikes-ii/README.md index a46ba70f2..e75cc52fc 100644 --- a/problems/campus-bikes-ii/README.md +++ b/problems/campus-bikes-ii/README.md @@ -11,7 +11,47 @@ ## [1066. Campus Bikes II (Medium)](https://leetcode.com/problems/campus-bikes-ii "校园自行车分配 II") +

    On a campus represented as a 2D grid, there are N workers and M bikes, with N <= M. Each worker and bike is a 2D coordinate on this grid.

    +

    We assign one unique bike to each worker so that the sum of the Manhattan distances between each worker and their assigned bike is minimized.

    + +

    The Manhattan distance between two points p1 and p2 is Manhattan(p1, p2) = |p1.x - p2.x| + |p1.y - p2.y|.

    + +

    Return the minimum possible sum of Manhattan distances between each worker and their assigned bike.

    + +

     

    + +

    Example 1:

    + +

    + +
    +Input: workers = [[0,0],[2,1]], bikes = [[1,2],[3,3]]
    +Output: 6
    +Explanation: 
    +We assign bike 0 to worker 0, bike 1 to worker 1. The Manhattan distance of both assignments is 3, so the output is 6.
    +
    + +

    Example 2:

    + +

    + +
    +Input: workers = [[0,0],[1,1],[2,0]], bikes = [[1,0],[2,2],[2,1]]
    +Output: 4
    +Explanation: 
    +We first assign bike 0 to worker 0, then assign bike 1 to worker 1 or worker 2, bike 2 to worker 2 or worker 1. Both assignments lead to sum of the Manhattan distances as 4.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 0 <= workers[i][0], workers[i][1], bikes[i][0], bikes[i][1] < 1000
    2. +
    3. All worker and bike locations are distinct.
    4. +
    5. 1 <= workers.length <= bikes.length <= 10
    6. +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/campus-bikes/README.md b/problems/campus-bikes/README.md index 3badcb77d..ea7457295 100644 --- a/problems/campus-bikes/README.md +++ b/problems/campus-bikes/README.md @@ -11,7 +11,47 @@ ## [1057. Campus Bikes (Medium)](https://leetcode.com/problems/campus-bikes "校园自行车分配") +

    On a campus represented as a 2D grid, there are N workers and M bikes, with N <= M. Each worker and bike is a 2D coordinate on this grid.

    +

    Our goal is to assign a bike to each worker. Among the available bikes and workers, we choose the (worker, bike) pair with the shortest Manhattan distance between each other, and assign the bike to that worker. (If there are multiple (worker, bike) pairs with the same shortest Manhattan distance, we choose the pair with the smallest worker index; if there are multiple ways to do that, we choose the pair with the smallest bike index). We repeat this process until there are no available workers.

    + +

    The Manhattan distance between two points p1 and p2 is Manhattan(p1, p2) = |p1.x - p2.x| + |p1.y - p2.y|.

    + +

    Return a vector ans of length N, where ans[i] is the index (0-indexed) of the bike that the i-th worker is assigned to.

    + +

     

    + +

    Example 1:

    + +

    + +
    +Input: workers = [[0,0],[2,1]], bikes = [[1,2],[3,3]]
    +Output: [1,0]
    +Explanation: 
    +Worker 1 grabs Bike 0 as they are closest (without ties), and Worker 0 is assigned Bike 1. So the output is [1, 0].
    +
    + +

    Example 2:

    + +

    + +
    +Input: workers = [[0,0],[1,1],[2,0]], bikes = [[1,0],[2,2],[2,1]]
    +Output: [0,2,1]
    +Explanation: 
    +Worker 0 grabs Bike 0 at first. Worker 1 and Worker 2 share the same distance to Bike 2, thus Worker 1 is assigned to Bike 2, and Worker 2 will take Bike 1. So the output is [0,2,1].
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 0 <= workers[i][j], bikes[i][j] < 1000
    2. +
    3. All worker and bike locations are distinct.
    4. +
    5. 1 <= workers.length <= bikes.length <= 1000
    6. +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/candy-crush/README.md b/problems/candy-crush/README.md index f3326e416..1fe58d7ca 100644 --- a/problems/candy-crush/README.md +++ b/problems/candy-crush/README.md @@ -11,7 +11,44 @@ ## [723. Candy Crush (Medium)](https://leetcode.com/problems/candy-crush "粉碎糖果") +

    This question is about implementing a basic elimination algorithm for Candy Crush.

    +

    Given a 2D integer array board representing the grid of candy, different positive integers board[i][j] represent different types of candies. A value of board[i][j] = 0 represents that the cell at position (i, j) is empty. The given board represents the state of the game following the player's move. Now, you need to restore the board to a stable state by crushing candies according to the following rules:

    + +
      +
    1. If three or more candies of the same type are adjacent vertically or horizontally, "crush" them all at the same time - these positions become empty.
    2. +
    3. After crushing all candies simultaneously, if an empty space on the board has candies on top of itself, then these candies will drop until they hit a candy or bottom at the same time. (No new candies will drop outside the top boundary.)
    4. +
    5. After the above steps, there may exist more candies that can be crushed. If so, you need to repeat the above steps.
    6. +
    7. If there does not exist more candies that can be crushed (ie. the board is stable), then return the current board.
    8. +
    + +

    You need to perform the above rules until the board becomes stable, then return the current board.

    + +

     

    + +

    Example:

    + +
    +Input:
    +board = 
    +[[110,5,112,113,114],[210,211,5,213,214],[310,311,3,313,314],[410,411,412,5,414],[5,1,512,3,3],[610,4,1,613,614],[710,1,2,713,714],[810,1,2,1,1],[1,1,2,2,2],[4,1,4,4,1014]]
    +
    +Output:
    +[[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[110,0,0,0,114],[210,0,0,0,214],[310,0,0,113,314],[410,0,0,213,414],[610,211,112,313,614],[710,311,412,613,714],[810,411,512,713,1014]]
    +
    +Explanation: 
    +
    +
    + +

     

    + +

    Note:

    + +
      +
    1. The length of board will be in the range [3, 50].
    2. +
    3. The length of board[i] will be in the range [3, 50].
    4. +
    5. Each board[i][j] will initially start as an integer in the range [1, 2000].
    6. +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/capital-gainloss/README.md b/problems/capital-gainloss/README.md index 2dd75d662..0529c1234 100644 --- a/problems/capital-gainloss/README.md +++ b/problems/capital-gainloss/README.md @@ -11,7 +11,59 @@ ## [1393. Capital Gain/Loss (Medium)](https://leetcode.com/problems/capital-gainloss "股票的资本损益") +

    Table: Stocks

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| stock_name    | varchar |
    +| operation     | enum    |
    +| operation_day | int     |
    +| price         | int     |
    ++---------------+---------+
    +(stock_name, day) is the primary key for this table.
    +The operation column is an ENUM of type ('Sell', 'Buy')
    +Each row of this table indicates that the stock which has stock_name had an operation on the day operation_day with the price.
    +It is guaranteed that each 'Sell' operation for a stock has a corresponding 'Buy' operation in a previous day.
    +
    + +Write an SQL query to report the Capital gain/loss for each stock. +The capital gain/loss of a stock is total gain or loss after buying and selling the stock one or many times. + +Return the result table in any order. + +The query result format is in the following example: + +
    +Stocks table:
    ++---------------+-----------+---------------+--------+
    +| stock_name    | operation | operation_day | price  |
    ++---------------+-----------+---------------+--------+
    +| Leetcode      | Buy       | 1             | 1000   |
    +| Corona Masks  | Buy       | 2             | 10     |
    +| Leetcode      | Sell      | 5             | 9000   |
    +| Handbags      | Buy       | 17            | 30000  |
    +| Corona Masks  | Sell      | 3             | 1010   |
    +| Corona Masks  | Buy       | 4             | 1000   |
    +| Corona Masks  | Sell      | 5             | 500    |
    +| Corona Masks  | Buy       | 6             | 1000   |
    +| Handbags      | Sell      | 29            | 7000   |
    +| Corona Masks  | Sell      | 10            | 10000  |
    ++---------------+-----------+---------------+--------+
    +
    +Result table:
    ++---------------+-------------------+
    +| stock_name    | capital_gain_loss |
    ++---------------+-------------------+
    +| Corona Masks  | 9500              |
    +| Leetcode      | 8000              |
    +| Handbags      | -23000            |
    ++---------------+-------------------+
    +Leetcode stock was bought at day 1 for 1000$ and was sold at day 5 for 9000$. Capital gain = 9000 - 1000 = 8000$.
    +Handbags stock was bought at day 17 for 30000$ and was sold at day 29 for 7000$. Capital loss = 7000 - 30000 = -23000$.
    +Corona Masks stock was bought at day 1 for 10$ and was sold at day 3 for 1010$. It was bought again at day 4 for 1000$ and was sold at day 5 for 500$. At last, it was bought at day 6 for 1000$ and was sold at day 10 for 10000$. Capital gain/loss is the sum of capital gains/losses for each ('Buy' --> 'Sell') operation = (1010 - 10) + (500 - 1000) + (10000 - 1000) = 1000 - 500 + 9000 = 9500$.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/car-fleet/README.md b/problems/car-fleet/README.md index 5045fa2d5..3c65d371a 100644 --- a/problems/car-fleet/README.md +++ b/problems/car-fleet/README.md @@ -11,45 +11,51 @@ ## [853. Car Fleet (Medium)](https://leetcode.com/problems/car-fleet "车队") -

    N cars are going to the same destination along a one lane road.  The destination is target miles away.

    +

    There are n cars going to the same destination along a one-lane road. The destination is target miles away.

    -

    Each car i has a constant speed speed[i] (in miles per hour), and initial position position[i] miles towards the target along the road.

    +

    You are given two integer array position and speed, both of length n, where position[i] is the position of the ith car and speed[i] is the speed of the ith car (in miles per hour).

    -

    A car can never pass another car ahead of it, but it can catch up to it, and drive bumper to bumper at the same speed.

    +

    A car can never pass another car ahead of it, but it can catch up to it, and drive bumper to bumper at the same speed.

    -

    The distance between these two cars is ignored - they are assumed to have the same position.

    +

    The distance between these two cars is ignored (i.e., they are assumed to have the same position).

    -

    A car fleet is some non-empty set of cars driving at the same position and same speed.  Note that a single car is also a car fleet.

    +

    A car fleet is some non-empty set of cars driving at the same position and same speed. Note that a single car is also a car fleet.

    -

    If a car catches up to a car fleet right at the destination point, it will still be considered as one car fleet.

    +

    If a car catches up to a car fleet right at the destination point, it will still be considered as one car fleet.

    -


    -How many car fleets will arrive at the destination?

    +

    Return the number of car fleets that will arrive at the destination.

     

    -

    Example 1:

    -Input: target = 12, position = [10,8,0,5,3], speed = [2,4,1,1,3]
    -Output: 3
    -Explanation:
    +Input: target = 12, position = [10,8,0,5,3], speed = [2,4,1,1,3]
    +Output: 3
    +Explanation: 
     The cars starting at 10 and 8 become a fleet, meeting each other at 12.
     The car starting at 0 doesn't catch up to any other car, so it is a fleet by itself.
     The cars starting at 5 and 3 become a fleet, meeting each other at 6.
     Note that no other cars meet these fleets before the destination, so the answer is 3.
     
    -


    -Note:

    +

    Example 2:

    + +
    +Input: target = 10, position = [3], speed = [3]
    +Output: 1
    +
    + +

     

    +

    Constraints:

    -
      -
    1. 0 <= N <= 10 ^ 4
    2. -
    3. 0 < target <= 10 ^ 6
    4. -
    5. 0 < speed[i] <= 10 ^ 6
    6. +
        +
      • n == position.length == speed.length
      • +
      • 1 <= n <= 105
      • +
      • 0 < target <= 106
      • 0 <= position[i] < target
      • -
      • All initial positions are different.
      • -
    +
  • All the values of position are unique.
  • +
  • 0 < speed[i] <= 106
  • + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/card-flipping-game/README.md b/problems/card-flipping-game/README.md index 13ff1163c..4f080e4ff 100644 --- a/problems/card-flipping-game/README.md +++ b/problems/card-flipping-game/README.md @@ -11,35 +11,42 @@ ## [822. Card Flipping Game (Medium)](https://leetcode.com/problems/card-flipping-game "翻转卡片游戏") -

    On a table are N cards, with a positive integer printed on the front and back of each card (possibly different).

    +

    You are given n cards, with a positive integer printed on the front and back of each card (possibly different). You can flip any number of cards (possibly zero).

    -

    We flip any number of cards, and after we choose one card. 

    +

    After choosing the front and the back of each card, you will pick each card, and if the integer printed on the back of this card is not printed on the front of any other card, then this integer is good.

    -

    If the number X on the back of the chosen card is not on the front of any card, then this number X is good.

    +

    You are given two integer array fronts and backs where fronts[i] and backs[i] are the integers printer on the front and the back of the ith card respectively.

    -

    What is the smallest number that is good?  If no number is good, output 0.

    +

    Return the smallest good and integer after flipping the cards. If there are no good integers, return 0.

    -

    Here, fronts[i] and backs[i] represent the number on the front and back of card i

    +

    Note that a flip swaps the front and back numbers, so the value on the front is now on the back and vice versa.

    -

    A flip swaps the front and back numbers, so the value on the front is now on the back and vice versa.

    - -

    Example:

    +

     

    +

    Example 1:

     Input: fronts = [1,2,4,4,7], backs = [1,3,4,1,3]
    -Output: 2
    -Explanation: If we flip the second card, the fronts are [1,3,4,4,7] and the backs are [1,2,4,1,3].
    -We choose the second card, which has number 2 on the back, and it isn't on the front of any card, so 2 is good.
    +Output: 2 +Explanation: If we flip the second card, the fronts are [1,3,4,4,7] and the backs are [1,2,4,1,3]. +We choose the second card, which has the number 2 on the back, and it is not on the front of any card, so 2 is good. + -

     

    +

    Example 2:

    -

    Note:

    +
    +Input: fronts = [1], backs = [1]
    +Output: 0
    +
    -
      -
    1. 1 <= fronts.length == backs.length <= 1000.
    2. -
    3. 1 <= fronts[i] <= 2000.
    4. -
    5. 1 <= backs[i] <= 2000.
    6. -
    +

     

    +

    Constraints:

    + +
      +
    • n == fronts.length
    • +
    • n == backs.length
    • +
    • 1 <= n <= 1000
    • +
    • 1 <= fronts[i], backs[i] <= 2000
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/chalkboard-xor-game/README.md b/problems/chalkboard-xor-game/README.md index 893554c2e..f1199e2d4 100644 --- a/problems/chalkboard-xor-game/README.md +++ b/problems/chalkboard-xor-game/README.md @@ -11,31 +11,47 @@ ## [810. Chalkboard XOR Game (Hard)](https://leetcode.com/problems/chalkboard-xor-game "黑板异或游戏") -

    We are given non-negative integers nums[i] which are written on a chalkboard.  Alice and Bob take turns erasing exactly one number from the chalkboard, with Alice starting first.  If erasing a number causes the bitwise XOR of all the elements of the chalkboard to become 0, then that player loses.  (Also, we'll say the bitwise XOR of one element is that element itself, and the bitwise XOR of no elements is 0.)

    +

    You are given an array of integers nums represents the numbers written on a chalkboard.

    -

    Also, if any player starts their turn with the bitwise XOR of all the elements of the chalkboard equal to 0, then that player wins.

    +

    Alice and Bob take turns erasing exactly one number from the chalkboard, with Alice starting first. If erasing a number causes the bitwise XOR of all the elements of the chalkboard to become 0, then that player loses. The bitwise XOR of one element is that element itself, and the bitwise XOR of no elements is 0.

    -

    Return True if and only if Alice wins the game, assuming both players play optimally.

    +

    Also, if any player starts their turn with the bitwise XOR of all the elements of the chalkboard equal to 0, then that player wins.

    + +

    Return true if and only if Alice wins the game, assuming both players play optimally.

    + +

     

    +

    Example 1:

    -Example:
    -Input: nums = [1, 1, 2]
    +Input: nums = [1,1,2]
     Output: false
     Explanation: 
     Alice has two choices: erase 1 or erase 2. 
     If she erases 1, the nums array becomes [1, 2]. The bitwise XOR of all the elements of the chalkboard is 1 XOR 2 = 3. Now Bob can remove any element he wants, because Alice will be the one to erase the last element and she will lose. 
    -If Alice erases 2 first, now nums becomes [1, 1]. The bitwise XOR of all the elements of the chalkboard is 1 XOR 1 = 0. Alice will lose.
    +If Alice erases 2 first, now nums become [1, 1]. The bitwise XOR of all the elements of the chalkboard is 1 XOR 1 = 0. Alice will lose.
    +
    +

    Example 2:

    + +
    +Input: nums = [0,1]
    +Output: true
     
    -

    Notes:

    +

    Example 3:

    -
      -
    • 1 <= N <= 1000
    • -
    • 0 <= nums[i] <= 2^16.
    • -
    +
    +Input: nums = [1,2,3]
    +Output: true
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • 0 <= nums[i] < 216
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/check-if-a-number-is-majority-element-in-a-sorted-array/README.md b/problems/check-if-a-number-is-majority-element-in-a-sorted-array/README.md index 51c072b64..ca9cb277e 100644 --- a/problems/check-if-a-number-is-majority-element-in-a-sorted-array/README.md +++ b/problems/check-if-a-number-is-majority-element-in-a-sorted-array/README.md @@ -11,7 +11,41 @@ ## [1150. Check If a Number Is Majority Element in a Sorted Array (Easy)](https://leetcode.com/problems/check-if-a-number-is-majority-element-in-a-sorted-array "检查一个数是否在数组中占绝大多数") +

    Given an array nums sorted in non-decreasing order, and a number target, return True if and only if target is a majority element.

    +

    A majority element is an element that appears more than N/2 times in an array of length N.

    + +

     

    + +

    Example 1:

    + +
    +Input: nums = [2,4,5,5,5,5,5,6,6], target = 5
    +Output: true
    +Explanation: 
    +The value 5 appears 5 times and the length of the array is 9.
    +Thus, 5 is a majority element because 5 > 9/2 is true.
    +
    + +

    Example 2:

    + +
    +Input: nums = [10,100,101,101], target = 101
    +Output: false
    +Explanation: 
    +The value 101 appears 2 times and the length of the array is 4.
    +Thus, 101 is not a majority element because 2 > 4/2 is false.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= nums.length <= 1000
    2. +
    3. 1 <= nums[i] <= 10^9
    4. +
    5. 1 <= target <= 10^9
    6. +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md b/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md index c7ec6341b..68d50de68 100644 --- a/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md +++ b/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md @@ -11,15 +11,11 @@ ## [1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence (Easy)](https://leetcode.com/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence "检查单词是否为句中其他单词的前缀") -

    Given a sentence that consists of some words separated by a single space, and a searchWord.

    +

    Given a sentence that consists of some words separated by a single space, and a searchWord, check if searchWord is a prefix of any word in sentence.

    -

    You have to check if searchWord is a prefix of any word in sentence.

    +

    Return the index of the word in sentence (1-indexed) where searchWord is a prefix of this word. If searchWord is a prefix of more than one word, return the index of the first word (minimum index). If there is no such word return -1.

    -

    Return the index of the word in sentence where searchWord is a prefix of this word (1-indexed).

    - -

    If searchWord is a prefix of more than one word, return the index of the first word (minimum index). If there is no such word return -1.

    - -

    A prefix of a string S is any leading contiguous substring of S.

    +

    A prefix of a string s is any leading contiguous substring of s.

     

    Example 1:

    @@ -67,7 +63,7 @@
  • 1 <= sentence.length <= 100
  • 1 <= searchWord.length <= 10
  • sentence consists of lowercase English letters and spaces.
  • -
  • searchWord consists of lowercase English letters.
  • +
  • searchWord consists of lowercase English letters.
  • ### Related Topics diff --git a/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md b/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md new file mode 100644 index 000000000..bf477e1ad --- /dev/null +++ b/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md @@ -0,0 +1,58 @@ + + + + + + + +[< Previous](../longest-common-subsequence-between-sorted-arrays "Longest Common Subsequence Between Sorted Arrays") +                 +[Next >](../the-number-of-the-smallest-unoccupied-chair "The Number of the Smallest Unoccupied Chair") + +## [1941. Check if All Characters Have Equal Number of Occurrences (Easy)](https://leetcode.com/problems/check-if-all-characters-have-equal-number-of-occurrences "检查是否所有字符出现次数相同") + +

    Given a string s, return true if s is a good string, or false otherwise.

    + +

    A string s is good if all the characters that appear in s have the same number of occurrences (i.e., the same frequency).

    + +

     

    +

    Example 1:

    + +
    +Input: s = "abacbc"
    +Output: true
    +Explanation: The characters that appear in s are 'a', 'b', and 'c'. All characters occur 2 times in s.
    +
    + +

    Example 2:

    + +
    +Input: s = "aaabb"
    +Output: false
    +Explanation: The characters that appear in s are 'a' and 'b'.
    +'a' occurs 3 times while 'b' occurs 2 times, which is not the same number of times.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 1000
    • +
    • s consists of lowercase English letters.
    • +
    + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Hints +
    +Hint 1 +Build a dictionary containing the frequency of each character appearing in s +
    + +
    +Hint 2 +Check if all values in the dictionary are the same. +
    diff --git a/problems/check-if-string-is-decomposable-into-value-equal-substrings/README.md b/problems/check-if-string-is-decomposable-into-value-equal-substrings/README.md new file mode 100644 index 000000000..bc5640f2f --- /dev/null +++ b/problems/check-if-string-is-decomposable-into-value-equal-substrings/README.md @@ -0,0 +1,30 @@ + + + + + + + +[< Previous](../merge-bsts-to-create-single-bst "Merge BSTs to Create Single BST") +                 +[Next >](../confirmation-rate "Confirmation Rate") + +## [1933. Check if String Is Decomposable Into Value-Equal Substrings (Easy)](https://leetcode.com/problems/check-if-string-is-decomposable-into-value-equal-substrings "判断字符串是否可分解为值均等的子串") + + + +### Hints +
    +Hint 1 +Keep looking for 3-equals, if you find a 3-equal, keep going. If you don't find a 3-equal, check if it is a 2-equal. +
    + +
    +Hint 2 +Make sure that it is the only 2-equal. +
    + +
    +Hint 3 +If it is neither a 3-equal nor a 2-equal, then it is impossible. +
    diff --git a/problems/closest-binary-search-tree-value-ii/README.md b/problems/closest-binary-search-tree-value-ii/README.md index ab9b44389..441168f84 100644 --- a/problems/closest-binary-search-tree-value-ii/README.md +++ b/problems/closest-binary-search-tree-value-ii/README.md @@ -11,7 +11,31 @@ ## [272. Closest Binary Search Tree Value II (Hard)](https://leetcode.com/problems/closest-binary-search-tree-value-ii "最接近的二叉搜索树值 II") +

    Given a non-empty binary search tree and a target value, find k values in the BST that are closest to the target.

    +

    Note:

    + +
      +
    • Given target value is a floating point.
    • +
    • You may assume k is always valid, that is: k ≤ total nodes.
    • +
    • You are guaranteed to have only one unique set of k values in the BST that are closest to the target.
    • +
    + +

    Example:

    + +
    +Input: root = [4,2,5,1,3], target = 3.714286, and k = 2
    +
    +    4
    +   / \
    +  2   5
    + / \
    +1   3
    +
    +Output: [4,3]
    + +

    Follow up:
    +Assume that the BST is balanced, could you solve it in less than O(n) runtime (where n = total nodes)?

    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/closest-binary-search-tree-value/README.md b/problems/closest-binary-search-tree-value/README.md index 7bb4a4843..0153f8003 100644 --- a/problems/closest-binary-search-tree-value/README.md +++ b/problems/closest-binary-search-tree-value/README.md @@ -11,7 +11,28 @@ ## [270. Closest Binary Search Tree Value (Easy)](https://leetcode.com/problems/closest-binary-search-tree-value "最接近的二叉搜索树值") +

    Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target.

    +

    Note:

    + +
      +
    • Given target value is a floating point.
    • +
    • You are guaranteed to have only one unique value in the BST that is closest to the target.
    • +
    + +

    Example:

    + +
    +Input: root = [4,2,5,1,3], target = 3.714286
    +
    +    4
    +   / \
    +  2   5
    + / \
    +1   3
    +
    +Output: 4
    +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/closest-leaf-in-a-binary-tree/README.md b/problems/closest-leaf-in-a-binary-tree/README.md index df23839a3..eb7a99ca0 100644 --- a/problems/closest-leaf-in-a-binary-tree/README.md +++ b/problems/closest-leaf-in-a-binary-tree/README.md @@ -11,7 +11,65 @@ ## [742. Closest Leaf in a Binary Tree (Medium)](https://leetcode.com/problems/closest-leaf-in-a-binary-tree "二叉树最近的叶节点") +

    Given a binary tree where every node has a unique value, and a target key k, find the value of the nearest leaf node to target k in the tree. +

    +Here, nearest to a leaf means the least number of edges travelled on the binary tree to reach any leaf of the tree. Also, a node is called a leaf if it has no children. +

    +In the following examples, the input tree is represented in flattened form row by row. +The actual root tree given will be a TreeNode object. +

    +Example 1: +

    +Input:
    +root = [1, 3, 2], k = 1
    +Diagram of binary tree:
    +          1
    +         / \
    +        3   2
     
    +Output: 2 (or 3)
    +
    +Explanation: Either 2 or 3 is the nearest leaf node to the target of 1.
    +
    +

    +Example 2: +

    +Input:
    +root = [1], k = 1
    +Output: 1
    +
    +Explanation: The nearest leaf node is the root node itself.
    +
    +

    + +

    +Example 3: +

    +Input:
    +root = [1,2,3,4,null,null,null,5,null,6], k = 2
    +Diagram of binary tree:
    +             1
    +            / \
    +           2   3
    +          /
    +         4
    +        /
    +       5
    +      /
    +     6
    +
    +Output: 3
    +Explanation: The leaf node with value 3 (and not the leaf node with value 6) is nearest to the node with value 2.
    +
    +

    + +

    Note:
    +

      +
    1. root represents a binary tree with at least 1 node and at most 1000 nodes.
    2. +
    3. Every node has a unique node.val in range [1, 1000].
    4. +
    5. There exists some node in the given binary tree for which node.val == k.
    6. +
    +

    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/coin-path/README.md b/problems/coin-path/README.md index 911c1b488..ae439b41f 100644 --- a/problems/coin-path/README.md +++ b/problems/coin-path/README.md @@ -11,7 +11,42 @@ ## [656. Coin Path (Hard)](https://leetcode.com/problems/coin-path "金币路径") +

    Given an array A (index starts at 1) consisting of N integers: A1, A2, ..., AN and an integer B. The integer B denotes that from any place (suppose the index is i) in the array A, you can jump to any one of the place in the array A indexed i+1, i+2, …, i+B if this place can be jumped to. Also, if you step on the index i, you have to pay Ai coins. If Ai is -1, it means you can’t jump to the place indexed i in the array.

    +

    Now, you start from the place indexed 1 in the array A, and your aim is to reach the place indexed N using the minimum coins. You need to return the path of indexes (starting from 1 to N) in the array you should take to get to the place indexed N using minimum coins.

    + +

    If there are multiple paths with the same cost, return the lexicographically smallest such path.

    + +

    If it's not possible to reach the place indexed N then you need to return an empty array.

    + +

    Example 1:

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

     

    + +

    Example 2:

    + +
    +Input: [1,2,4,-1,2], 1
    +Output: []
    +
    + +

     

    + +

    Note:

    + +
      +
    1. Path Pa1, Pa2, ..., Pan is lexicographically smaller than Pb1, Pb2, ..., Pbm, if and only if at the first i where Pai and Pbi differ, Pai < Pbi; when no such i exists, then n < m.
    2. +
    3. A1 >= 0. A2, ..., AN (if exist) will in the range of [-1, 100].
    4. +
    5. Length of A is in the range of [1, 1000].
    6. +
    7. B is in the range of [1, 100].
    8. +
    + +

     

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/concatenation-of-array/README.md b/problems/concatenation-of-array/README.md new file mode 100644 index 000000000..0ad0358f5 --- /dev/null +++ b/problems/concatenation-of-array/README.md @@ -0,0 +1,56 @@ + + + + + + + +[< Previous](../minimum-cost-to-reach-destination-in-time "Minimum Cost to Reach Destination in Time") +                 +[Next >](../unique-length-3-palindromic-subsequences "Unique Length-3 Palindromic Subsequences") + +## [1929. Concatenation of Array (Easy)](https://leetcode.com/problems/concatenation-of-array "数组串联") + +

    Given an integer array nums of length n, you want to create an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n (0-indexed).

    + +

    Specifically, ans is the concatenation of two nums arrays.

    + +

    Return the array ans.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,1]
    +Output: [1,2,1,1,2,1]
    +Explanation: The array ans is formed as follows:
    +- ans = [nums[0],nums[1],nums[2],nums[0],nums[1],nums[2]]
    +- ans = [1,2,1,1,2,1]
    + +

    Example 2:

    + +
    +Input: nums = [1,3,2,1]
    +Output: [1,3,2,1,1,3,2,1]
    +Explanation: The array ans is formed as follows:
    +- ans = [nums[0],nums[1],nums[2],nums[3],nums[0],nums[1],nums[2],nums[3]]
    +- ans = [1,3,2,1,1,3,2,1]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= n <= 1000
    • +
    • 1 <= nums[i] <= 1000
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Build an array of size 2 * n and assign num[i] to ans[i] and ans[i + n] +
    diff --git a/problems/confirmation-rate/README.md b/problems/confirmation-rate/README.md new file mode 100644 index 000000000..bf6917053 --- /dev/null +++ b/problems/confirmation-rate/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../check-if-string-is-decomposable-into-value-equal-substrings "Check if String Is Decomposable Into Value-Equal Substrings") +                 +[Next >](../maximum-number-of-words-you-can-type "Maximum Number of Words You Can Type") + +## [1934. Confirmation Rate (Medium)](https://leetcode.com/problems/confirmation-rate "") + + diff --git a/problems/confirmation-rate/mysql_schemas.sql b/problems/confirmation-rate/mysql_schemas.sql new file mode 100644 index 000000000..f7683cd9e --- /dev/null +++ b/problems/confirmation-rate/mysql_schemas.sql @@ -0,0 +1,15 @@ +Create table If Not Exists Signups (user_id int, time_stamp datetime); +Create table If Not Exists Confirmations (user_id int, time_stamp datetime, action ENUM('confirmed','timeout')); +Truncate table Signups; +insert into Signups (user_id, time_stamp) values ('3', '2020-03-21 10:16:13'); +insert into Signups (user_id, time_stamp) values ('7', '2020-01-04 13:57:59'); +insert into Signups (user_id, time_stamp) values ('2', '2020-07-29 23:09:44'); +insert into Signups (user_id, time_stamp) values ('6', '2020-12-09 10:39:37'); +Truncate table Confirmations; +insert into Confirmations (user_id, time_stamp, action) values ('3', '2021-01-06 03:30:46', 'timeout'); +insert into Confirmations (user_id, time_stamp, action) values ('3', '2021-07-14 14:00:00', 'timeout'); +insert into Confirmations (user_id, time_stamp, action) values ('7', '2021-06-12 11:57:29', 'confirmed'); +insert into Confirmations (user_id, time_stamp, action) values ('7', '2021-06-13 12:58:28', 'confirmed'); +insert into Confirmations (user_id, time_stamp, action) values ('7', '2021-06-14 13:59:27', 'confirmed'); +insert into Confirmations (user_id, time_stamp, action) values ('2', '2021-01-22 00:00:00', 'confirmed'); +insert into Confirmations (user_id, time_stamp, action) values ('2', '2021-02-28 23:59:59', 'timeout'); diff --git a/problems/confusing-number-ii/README.md b/problems/confusing-number-ii/README.md index a6cfce917..22064adde 100644 --- a/problems/confusing-number-ii/README.md +++ b/problems/confusing-number-ii/README.md @@ -11,7 +11,45 @@ ## [1088. Confusing Number II (Hard)](https://leetcode.com/problems/confusing-number-ii "易混淆数 II") +

    We can rotate digits by 180 degrees to form new digits. When 0, 1, 6, 8, 9 are rotated 180 degrees, they become 0, 1, 9, 8, 6 respectively. When 2, 3, 4, 5 and 7 are rotated 180 degrees, they become invalid.

    +

    A confusing number is a number that when rotated 180 degrees becomes a different number with each digit valid.(Note that the rotated number can be greater than the original number.)

    + +

    Given a positive integer N, return the number of confusing numbers between 1 and N inclusive.

    + +

     

    + +

    Example 1:

    + +
    +Input: 20
    +Output: 6
    +Explanation: 
    +The confusing numbers are [6,9,10,16,18,19].
    +6 converts to 9.
    +9 converts to 6.
    +10 converts to 01 which is just 1.
    +16 converts to 91.
    +18 converts to 81.
    +19 converts to 61.
    +
    + +

    Example 2:

    + +
    +Input: 100
    +Output: 19
    +Explanation: 
    +The confusing numbers are [6,9,10,16,18,19,60,61,66,68,80,81,86,89,90,91,98,99,100].
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= N <= 10^9
    2. +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/confusing-number/README.md b/problems/confusing-number/README.md index ddea65d43..63070cfc9 100644 --- a/problems/confusing-number/README.md +++ b/problems/confusing-number/README.md @@ -11,7 +11,64 @@ ## [1056. Confusing Number (Easy)](https://leetcode.com/problems/confusing-number "易混淆数") +

    Given a number N, return true if and only if it is a confusing number, which satisfies the following condition:

    +

    We can rotate digits by 180 degrees to form new digits. When 0, 1, 6, 8, 9 are rotated 180 degrees, they become 0, 1, 9, 8, 6 respectively. When 2, 3, 4, 5 and 7 are rotated 180 degrees, they become invalid. A confusing number is a number that when rotated 180 degrees becomes a different number with each digit valid.

    + +

     

    + +

    Example 1:

    + +

    + +
    +Input: 6
    +Output: true
    +Explanation: 
    +We get 9 after rotating 6, 9 is a valid number and 9!=6.
    +
    + +

    Example 2:

    + +

    + +
    +Input: 89
    +Output: true
    +Explanation: 
    +We get 68 after rotating 89, 86 is a valid number and 86!=89.
    +
    + +

    Example 3:

    + +

    + +
    +Input: 11
    +Output: false
    +Explanation: 
    +We get 11 after rotating 11, 11 is a valid number but the value remains the same, thus 11 is not a confusing number.
    +
    + +

    Example 4:

    + +

    + +
    +Input: 25
    +Output: false
    +Explanation: 
    +We get an invalid number after rotating 25.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 0 <= N <= 10^9
    2. +
    3. After the rotation we can ignore leading zeros, for example if after rotation we have 0008 then this number is considered as just 8.
    4. +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/connecting-cities-with-minimum-cost/README.md b/problems/connecting-cities-with-minimum-cost/README.md index 0b04218ee..cc9b861ea 100644 --- a/problems/connecting-cities-with-minimum-cost/README.md +++ b/problems/connecting-cities-with-minimum-cost/README.md @@ -11,7 +11,47 @@ ## [1135. Connecting Cities With Minimum Cost (Medium)](https://leetcode.com/problems/connecting-cities-with-minimum-cost "最低成本联通所有城市") +

    There are N cities numbered from 1 to N.

    +

    You are given connections, where each connections[i] = [city1, city2, cost] represents the cost to connect city1 and city2 together.  (A connection is bidirectional: connecting city1 and city2 is the same as connecting city2 and city1.)

    + +

    Return the minimum cost so that for every pair of cities, there exists a path of connections (possibly of length 1) that connects those two cities together.  The cost is the sum of the connection costs used. If the task is impossible, return -1.

    + +

     

    + +

    Example 1:

    + +

    + +
    +Input: N = 3, connections = [[1,2,5],[1,3,6],[2,3,1]]
    +Output: 6
    +Explanation: 
    +Choosing any 2 edges will connect all cities so we choose the minimum 2.
    +
    + +

    Example 2:

    + +

    + +
    +Input: N = 4, connections = [[1,2,3],[3,4,4]]
    +Output: -1
    +Explanation: 
    +There is no way to connect all cities even if all edges are used.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= N <= 10000
    2. +
    3. 1 <= connections.length <= 10000
    4. +
    5. 1 <= connections[i][0], connections[i][1] <= N
    6. +
    7. 0 <= connections[i][2] <= 10^5
    8. +
    9. connections[i][0] != connections[i][1]
    10. +
    ### Related Topics [[Union Find](../../tag/union-find/README.md)] diff --git a/problems/consecutive-available-seats/README.md b/problems/consecutive-available-seats/README.md index 789dcc170..867f312e7 100644 --- a/problems/consecutive-available-seats/README.md +++ b/problems/consecutive-available-seats/README.md @@ -11,7 +11,36 @@ ## [603. Consecutive Available Seats (Easy)](https://leetcode.com/problems/consecutive-available-seats "连续空余座位") +Several friends at a cinema ticket office would like to reserve consecutive available seats.
    +Can you help to query all the consecutive available seats order by the seat_id using the following cinema table? +
    +| seat_id | free |
    +|---------|------|
    +| 1       | 1    |
    +| 2       | 0    |
    +| 3       | 1    |
    +| 4       | 1    |
    +| 5       | 1    |
    +
    +

     

    +Your query should return the following result for the sample case above. + +

     

    + +
    +| seat_id |
    +|---------|
    +| 3       |
    +| 4       |
    +| 5       |
    +
    +Note: + +
      +
    • The seat_id is an auto increment int, and free is bool ('1' means free, and '0' means occupied.).
    • +
    • Consecutive available seats are more than 2(inclusive) seats consecutively available.
    • +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/consecutive-numbers-sum/README.md b/problems/consecutive-numbers-sum/README.md index 2ab62927b..fd6213696 100644 --- a/problems/consecutive-numbers-sum/README.md +++ b/problems/consecutive-numbers-sum/README.md @@ -11,30 +11,39 @@ ## [829. Consecutive Numbers Sum (Hard)](https://leetcode.com/problems/consecutive-numbers-sum "连续整数求和") -

    Given a positive integer n, how many ways can we write it as a sum of consecutive positive integers?

    +

    Given an integer n, return the number of ways you can write n as the sum of consecutive positive integers.

    +

     

    Example 1:

    -Input: n = 5
    -Output: 2
    -Explanation: 5 = 5 = 2 + 3
    +Input: n = 5 +Output: 2 +Explanation: 5 = 2 + 3 +

    Example 2:

    -Input: n = 9
    -Output: 3
    -Explanation: 9 = 9 = 4 + 5 = 2 + 3 + 4
    +Input: n = 9 +Output: 3 +Explanation: 9 = 4 + 5 = 2 + 3 + 4 +

    Example 3:

    -Input: n = 15
    -Output: 4
    -Explanation: 15 = 15 = 8 + 7 = 4 + 5 + 6 = 1 + 2 + 3 + 4 + 5
    +Input: n = 15 +Output: 4 +Explanation: 15 = 8 + 7 = 4 + 5 + 6 = 1 + 2 + 3 + 4 + 5 + -

    Note: 1 <= n <= 10 ^ 9.

    +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 109
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md b/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md index f4912d732..37ae76162 100644 --- a/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md +++ b/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md @@ -11,30 +11,37 @@ ## [889. Construct Binary Tree from Preorder and Postorder Traversal (Medium)](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal "根据前序和后序遍历构造二叉树") -

    Return any binary tree that matches the given preorder and postorder traversals.

    +

    Given two integer arrays, preorder and postorder where preorder is the preorder traversal of a binary tree of distinct values and postorder is the postorder traversal of the same tree, reconstruct and return the binary tree.

    -

    Values in the traversals pre and post are distinct positive integers.

    +

    If there exist multiple answers, you can return any of them.

     

    - -

    Example 1:

    + +
    +Input: preorder = [1,2,4,5,3,6,7], postorder = [4,5,2,6,7,3,1]
    +Output: [1,2,3,4,5,6,7]
    +
    + +

    Example 2:

    -Input: pre = [1,2,4,5,3,6,7], post = [4,5,2,6,7,3,1]
    -Output: [1,2,3,4,5,6,7]
    +Input: preorder = [1], postorder = [1]
    +Output: [1]
     

     

    - -

    Note:

    +

    Constraints:

      -
    • 1 <= pre.length == post.length <= 30
    • -
    • pre[] and post[] are both permutations of 1, 2, ..., pre.length.
    • -
    • It is guaranteed an answer exists. If there exists multiple answers, you can return any of them.
    • +
    • 1 <= preorder.length <= 30
    • +
    • 1 <= preorder[i] <= preorder.length
    • +
    • All the values of preorder are unique.
    • +
    • postorder.length == preorder.length
    • +
    • 1 <= postorder[i] <= postorder.length
    • +
    • All the values of postorder are unique.
    • +
    • It is guaranteed that preorder and postorder are the preorder traversal and postorder traversal of the same binary tree.
    -
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/construct-binary-tree-from-string/README.md b/problems/construct-binary-tree-from-string/README.md index 00e11b181..05bb73e4e 100644 --- a/problems/construct-binary-tree-from-string/README.md +++ b/problems/construct-binary-tree-from-string/README.md @@ -11,7 +11,31 @@ ## [536. Construct Binary Tree from String (Medium)](https://leetcode.com/problems/construct-binary-tree-from-string "从字符串生成二叉树") +

    You need to construct a binary tree from a string consisting of parenthesis and integers.

    +

    The whole input represents a binary tree. It contains an integer followed by zero, one or two pairs of parenthesis. The integer represents the root's value and a pair of parenthesis contains a child binary tree with the same structure.

    + +

    You always start to construct the left child node of the parent first if it exists.

    + +

    Example:
    +

    +Input: "4(2(3)(1))(6(5))"
    +Output: return the tree root node representing the following tree:
    +
    +       4
    +     /   \
    +    2     6
    +   / \   / 
    +  3   1 5   
    +
    +

    + +

    Note:
    +

      +
    1. There will only be '(', ')', '-' and '0' ~ '9' in the input string.
    2. +
    3. An empty tree is represented by "" instead of "()".
    4. +
    +

    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md b/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md index 6068a9ec4..6380ffd0d 100644 --- a/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md +++ b/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md @@ -11,7 +11,28 @@ ## [426. Convert Binary Search Tree to Sorted Doubly Linked List (Medium)](https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list "将二叉搜索树转化为排序的双向链表") +

    Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right pointers as synonymous to the previous and next pointers in a doubly-linked list.

    +

    Let's take the following BST as an example, it may help you understand the problem better:

    +  + +

    +  + +

    We want to transform this BST into a circular doubly linked list. Each node in a doubly linked list has a predecessor and successor. For a circular doubly linked list, the predecessor of the first element is the last element, and the successor of the last element is the first element.

    + +

    The figure below shows the circular doubly linked list for the BST above. The "head" symbol means the node it points to is the smallest element of the linked list.

    +  + +

    +  + +

    Specifically, we want to do the transformation in place. After the transformation, the left pointer of the tree node should point to its predecessor, and the right pointer should point to its successor. We should return the pointer to the first element of the linked list.

    + +

    The figure below shows the transformed BST. The solid line indicates the successor relationship, while the dashed line means the predecessor relationship.

    +  + +

    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/convex-polygon/README.md b/problems/convex-polygon/README.md index 676fbb8fb..b98a4161f 100644 --- a/problems/convex-polygon/README.md +++ b/problems/convex-polygon/README.md @@ -11,7 +11,39 @@ ## [469. Convex Polygon (Medium)](https://leetcode.com/problems/convex-polygon "凸多边形") +

    Given a list of points that form a polygon when joined sequentially, find if this polygon is convex (Convex polygon definition).

    +

     

    + +

    Note:

    + +
      +
    1. There are at least 3 and at most 10,000 points.
    2. +
    3. Coordinates are in the range -10,000 to 10,000.
    4. +
    5. You may assume the polygon formed by given points is always a simple polygon (Simple polygon definition). In other words, we ensure that exactly two edges intersect at each vertex, and that edges otherwise don't intersect each other.
    6. +
    + +

     

    + +

    Example 1:

    + +
    +[[0,0],[0,1],[1,1],[1,0]]
    +
    +Answer: True
    +
    +Explanation:
    +
    + +

    Example 2:

    + +
    +[[0,0],[0,10],[10,10],[10,0],[5,5]]
    +
    +Answer: False
    +
    +Explanation:
    +
    ### Related Topics [[Geometry](../../tag/geometry/README.md)] diff --git a/problems/count-number-of-special-subsequences/README.md b/problems/count-number-of-special-subsequences/README.md new file mode 100644 index 000000000..96d9cf6e9 --- /dev/null +++ b/problems/count-number-of-special-subsequences/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../minimum-garden-perimeter-to-collect-enough-apples "Minimum Garden Perimeter to Collect Enough Apples") +                 +Next > + +## [1955. Count Number of Special Subsequences (Hard)](https://leetcode.com/problems/count-number-of-special-subsequences "统计特殊子序列的数目") + +

    A sequence is special if it consists of a positive number of 0s, followed by a positive number of 1s, then a positive number of 2s.

    + +
      +
    • For example, [0,1,2] and [0,0,1,1,1,2] are special.
    • +
    • In contrast, [2,1,0], [1], and [0,1,2,0] are not special.
    • +
    + +

    Given an array nums (consisting of only integers 0, 1, and 2), return the number of different subsequences that are special. Since the answer may be very large, return it modulo 109 + 7.

    + +

    A subsequence of an array is a sequence that can be derived from the array by deleting some or no elements without changing the order of the remaining elements. Two subsequences are different if the set of indices chosen are different.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [0,1,2,2]
    +Output: 3
    +Explanation: The special subsequences are [0,1,2,2], [0,1,2,2], and [0,1,2,2].
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,2,0,0]
    +Output: 0
    +Explanation: There are no special subsequences in [2,2,0,0].
    +
    + +

    Example 3:

    + +
    +Input: nums = [0,1,2,0,1,2]
    +Output: 7
    +Explanation: The special subsequences are:
    +- [0,1,2,0,1,2]
    +- [0,1,2,0,1,2]
    +- [0,1,2,0,1,2]
    +- [0,1,2,0,1,2]
    +- [0,1,2,0,1,2]
    +- [0,1,2,0,1,2]
    +- [0,1,2,0,1,2]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 0 <= nums[i] <= 2
    • +
    + +### Hints +
    +Hint 1 +Can we first solve a simpler problem? Counting the number of subsequences with 1s followed by 0s. +
    + +
    +Hint 2 +How can we keep track of the partially matched subsequences to help us find the answer? +
    diff --git a/problems/count-square-sum-triples/README.md b/problems/count-square-sum-triples/README.md new file mode 100644 index 000000000..9407c42a5 --- /dev/null +++ b/problems/count-square-sum-triples/README.md @@ -0,0 +1,55 @@ + + + + + + + +[< Previous](../erect-the-fence-ii "Erect the Fence II") +                 +[Next >](../nearest-exit-from-entrance-in-maze "Nearest Exit from Entrance in Maze") + +## [1925. Count Square Sum Triples (Easy)](https://leetcode.com/problems/count-square-sum-triples "统计平方和三元组的数目") + +

    A square triple (a,b,c) is a triple where a, b, and c are integers and a2 + b2 = c2.

    + +

    Given an integer n, return the number of square triples such that 1 <= a, b, c <= n.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 5
    +Output: 2
    +Explanation: The square triples are (3,4,5) and (4,3,5).
    +
    + +

    Example 2:

    + +
    +Input: n = 10
    +Output: 4
    +Explanation: The square triples are (3,4,5), (4,3,5), (6,8,10), and (8,6,10).
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 250
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + +### Hints +
    +Hint 1 +Iterate over all possible pairs (a,b) and check that the square root of a * a + b * b is an integers less than or equal n +
    + +
    +Hint 2 +You can check that the square root of an integer is an integer using binary seach or a builtin function like sqrt +
    diff --git a/problems/count-student-number-in-departments/README.md b/problems/count-student-number-in-departments/README.md index ebfa9bb92..dc03eb901 100644 --- a/problems/count-student-number-in-departments/README.md +++ b/problems/count-student-number-in-departments/README.md @@ -11,7 +11,66 @@ ## [580. Count Student Number in Departments (Medium)](https://leetcode.com/problems/count-student-number-in-departments "统计各专业学生人数") +

    A university uses 2 data tables, student and department, to store data about its students and the departments associated with each major.

    +

    Write a query to print the respective department name and number of students majoring in each department for all departments in the department table (even ones with no current students).

    + +

    Sort your results by descending number of students; if two or more departments have the same number of students, then sort those departments alphabetically by department name.

    + +

    The student is described as follow:

    + +
    +| Column Name  | Type      |
    +|--------------|-----------|
    +| student_id   | Integer   |
    +| student_name | String    |
    +| gender       | Character |
    +| dept_id      | Integer   |
    +
    + +

    where student_id is the student's ID number, student_name is the student's name, gender is their gender, and dept_id is the department ID associated with their declared major.

    + +

    And the department table is described as below:

    + +
    +| Column Name | Type    |
    +|-------------|---------|
    +| dept_id     | Integer |
    +| dept_name   | String  |
    +
    + +

    where dept_id is the department's ID number and dept_name is the department name.

    + +

    Here is an example input:
    +student table:

    + +
    +| student_id | student_name | gender | dept_id |
    +|------------|--------------|--------|---------|
    +| 1          | Jack         | M      | 1       |
    +| 2          | Jane         | F      | 1       |
    +| 3          | Mark         | M      | 2       |
    +
    + +

    department table:

    + +
    +| dept_id | dept_name   |
    +|---------|-------------|
    +| 1       | Engineering |
    +| 2       | Science     |
    +| 3       | Law         |
    +
    + +

    The Output should be:

    + +
    +| dept_name   | student_number |
    +|-------------|----------------|
    +| Engineering | 2              |
    +| Science     | 1              |
    +| Law         | 0              |
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/count-substrings-with-only-one-distinct-letter/README.md b/problems/count-substrings-with-only-one-distinct-letter/README.md index d43163150..4636959fc 100644 --- a/problems/count-substrings-with-only-one-distinct-letter/README.md +++ b/problems/count-substrings-with-only-one-distinct-letter/README.md @@ -11,7 +11,36 @@ ## [1180. Count Substrings with Only One Distinct Letter (Easy)](https://leetcode.com/problems/count-substrings-with-only-one-distinct-letter "统计只含单一字母的子串") - +

    Given a string S, return the number of substrings that have only one distinct letter.

    + +

     

    +

    Example 1:

    + +
    +Input: S = "aaaba"
    +Output: 8
    +Explanation: The substrings with one distinct letter are "aaa", "aa", "a", "b".
    +"aaa" occurs 1 time.
    +"aa" occurs 2 times.
    +"a" occurs 4 times.
    +"b" occurs 1 time.
    +So the answer is 1 + 2 + 4 + 1 = 8.
    +
    + +

    Example 2:

    + +
    +Input: S = "aaaaaaaaaa"
    +Output: 55
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= S.length <= 1000
    • +
    • S[i] consists of only lowercase English letters.
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/count-univalue-subtrees/README.md b/problems/count-univalue-subtrees/README.md index 4f8832484..e01b65cde 100644 --- a/problems/count-univalue-subtrees/README.md +++ b/problems/count-univalue-subtrees/README.md @@ -11,7 +11,22 @@ ## [250. Count Univalue Subtrees (Medium)](https://leetcode.com/problems/count-univalue-subtrees "统计同值子树") +

    Given a binary tree, count the number of uni-value subtrees.

    +

    A Uni-value subtree means all nodes of the subtree have the same value.

    + +

    Example :

    + +
    Input:  root = [5,1,5,5,5,null,5]
    +
    +              5
    +             / \
    +            1   5
    +           / \   \
    +          5   5   5
    +
    +Output: 4
    +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/course-schedule-iv/README.md b/problems/course-schedule-iv/README.md index 359a55d75..097eec13c 100644 --- a/problems/course-schedule-iv/README.md +++ b/problems/course-schedule-iv/README.md @@ -11,15 +11,17 @@ ## [1462. Course Schedule IV (Medium)](https://leetcode.com/problems/course-schedule-iv "课程表 IV") -

    There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi first if you want to take course ai.

    +

    There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course ai first if you want to take course bi.

      -
    • For example, the pair [0, 1], indicates that to take course 0 you have to first take course 1.
    • +
    • For example, the pair [0, 1] indicates that you have to take course 0 before you can take course 1.
    -

    You are also given an array queries where queries[j] = [uj, vj]. For the jth query, you should answer whether the course uj is a prerequisite of the course vj or not. Note that if course a is a prerequisite of course b and course b is a prerequisite of course c, then, course a is a prerequisite of course c.

    +

    Prerequisites can also be indirect. If course a is a prerequisite of course b, and course b is a prerequisite of course c, then course a is a prerequisite of course c.

    -

    Return a boolean array answer, where answer[j] is the answer of the jth query.

    +

    You are also given an array queries where queries[j] = [uj, vj]. For the jth query, you should answer whether course uj is a prerequisite of course vj or not.

    + +

    Return a boolean array answer, where answer[j] is the answer to the jth query.

     

    Example 1:

    @@ -27,7 +29,8 @@
     Input: numCourses = 2, prerequisites = [[1,0]], queries = [[0,1],[1,0]]
     Output: [false,true]
    -Explanation: course 0 is not a prerequisite of course 1 but the opposite is true.
    +Explanation: The pair [1, 0] indicates that you have to take course 1 before you can take course 0.
    +Course 0 is not a prerequisite of course 1, but the opposite is true.
     

    Example 2:

    @@ -35,7 +38,7 @@
     Input: numCourses = 2, prerequisites = [], queries = [[1,0],[0,1]]
     Output: [false,false]
    -Explanation: There are no prerequisites and each course is independent.
    +Explanation: There are no prerequisites, and each course is independent.
     

    Example 3:

    @@ -50,13 +53,14 @@
    • 2 <= numCourses <= 100
    • -
    • 0 <= prerequisite.length <= (numCourses * (numCourses - 1) / 2)
    • -
    • 0 <= ai, bi < n
    • +
    • 0 <= prerequisites.length <= (numCourses * (numCourses - 1) / 2)
    • +
    • prerequisites[i].length == 2
    • +
    • 0 <= ai, bi <= n - 1
    • ai != bi
    • All the pairs [ai, bi] are unique.
    • The prerequisites graph has no cycles.
    • 1 <= queries.length <= 104
    • -
    • 0 <= ui, vi < n
    • +
    • 0 <= ui, vi <= n - 1
    • ui != vi
    diff --git a/problems/cousins-in-binary-tree/README.md b/problems/cousins-in-binary-tree/README.md index 8caccae10..1acce6499 100644 --- a/problems/cousins-in-binary-tree/README.md +++ b/problems/cousins-in-binary-tree/README.md @@ -11,51 +11,43 @@ ## [993. Cousins in Binary Tree (Easy)](https://leetcode.com/problems/cousins-in-binary-tree "二叉树的堂兄弟节点") -

    In a binary tree, the root node is at depth 0, and children of each depth k node are at depth k+1.

    +

    Given the root of a binary tree with unique values and the values of two different nodes of the tree x and y, return true if the nodes corresponding to the values x and y in the tree are cousins, or false otherwise.

    -

    Two nodes of a binary tree are cousins if they have the same depth, but have different parents.

    +

    Two nodes of a binary tree are cousins if they have the same depth with different parents.

    -

    We are given the root of a binary tree with unique values, and the values x and y of two different nodes in the tree.

    - -

    Return true if and only if the nodes corresponding to the values x and y are cousins.

    +

    Note that in a binary tree, the root node is at the depth 0, and children of each depth k node are at the depth k + 1.

     

    - -

    Example 1:
    -

    - +

    Example 1:

    +
    -Input: root = [1,2,3,4], x = 4, y = 3
    -Output: false
    +Input: root = [1,2,3,4], x = 4, y = 3
    +Output: false
     
    -
    -

    Example 2:
    -

    - +

    Example 2:

    +
    -Input: root = [1,2,3,null,4,null,5], x = 5, y = 4
    -Output: true
    +Input: root = [1,2,3,null,4,null,5], x = 5, y = 4
    +Output: true
     
    -

    Example 3:

    - -

    - +
    -Input: root = [1,2,3,null,4], x = 2, y = 3
    -Output: false
    +Input: root = [1,2,3,null,4], x = 2, y = 3
    +Output: false
     
    -
    -

     

    Constraints:

      -
    • The number of nodes in the tree will be between 2 and 100.
    • -
    • Each node has a unique integer value from 1 to 100.
    • +
    • The number of nodes in the tree is in the range [2, 100].
    • +
    • 1 <= Node.val <= 100
    • +
    • Each node has a unique value.
    • +
    • x != y
    • +
    • x and y are exist in the tree.
    ### Related Topics diff --git a/problems/custom-sort-string/README.md b/problems/custom-sort-string/README.md index 90d65f2d6..6a34c35cf 100644 --- a/problems/custom-sort-string/README.md +++ b/problems/custom-sort-string/README.md @@ -11,31 +11,38 @@ ## [791. Custom Sort String (Medium)](https://leetcode.com/problems/custom-sort-string "自定义字符串排序") -

    order and str are strings composed of lowercase letters. In order, no letter occurs more than once.

    +

    You are given two strings order and s. All the words of order are unique and were sorted in some custom order previously.

    -

    order was sorted in some custom order previously. We want to permute the characters of str so that they match the order that order was sorted. More specifically, if x occurs before y in order, then x should occur before y in the returned string.

    +

    Permute the characters of s so that they match the order that order was sorted. More specifically, if a character x occurs before a character y in order, then x should occur before y in the permuted string.

    -

    Return any permutation of str (as a string) that satisfies this property.

    +

    Return any permutation of s that satisfies this property.

    + +

     

    +

    Example 1:

    -Example:
    -Input: 
    -order = "cba"
    -str = "abcd"
    +Input: order = "cba", s = "abcd"
     Output: "cbad"
     Explanation: 
     "a", "b", "c" appear in order, so the order of "a", "b", "c" should be "c", "b", and "a". 
     Since "d" does not appear in order, it can be at any position in the returned string. "dcba", "cdba", "cbda" are also valid outputs.
     
    -

     

    +

    Example 2:

    + +
    +Input: order = "cbafg", s = "abcd"
    +Output: "cbad"
    +
    -

    Note:

    +

     

    +

    Constraints:

      -
    • order has length at most 26, and no character is repeated in order.
    • -
    • str has length at most 200.
    • -
    • order and str consist of lowercase letters only.
    • +
    • 1 <= order.length <= 26
    • +
    • 1 <= s.length <= 200
    • +
    • order and s consist of lowercase English letters.
    • +
    • All the characters of order are unique.
    ### Related Topics diff --git a/problems/customer-placing-the-largest-number-of-orders/README.md b/problems/customer-placing-the-largest-number-of-orders/README.md index 3c5f5fc3c..6585eb972 100644 --- a/problems/customer-placing-the-largest-number-of-orders/README.md +++ b/problems/customer-placing-the-largest-number-of-orders/README.md @@ -11,7 +11,51 @@ ## [586. Customer Placing the Largest Number of Orders (Easy)](https://leetcode.com/problems/customer-placing-the-largest-number-of-orders "订单最多的客户") +

    Query the customer_number from the orders table for the customer who has placed the largest number of orders.

    +

    It is guaranteed that exactly one customer will have placed more orders than any other customer.

    + +

    The orders table is defined as follows:

    + +
    +| Column            | Type      |
    +|-------------------|-----------|
    +| order_number (PK) | int       |
    +| customer_number   | int       |
    +| order_date        | date      |
    +| required_date     | date      |
    +| shipped_date      | date      |
    +| status            | char(15)  |
    +| comment           | char(200) |
    +
    + +

    Sample Input

    + +
    +| order_number | customer_number | order_date | required_date | shipped_date | status | comment |
    +|--------------|-----------------|------------|---------------|--------------|--------|---------|
    +| 1            | 1               | 2017-04-09 | 2017-04-13    | 2017-04-12   | Closed |         |
    +| 2            | 2               | 2017-04-15 | 2017-04-20    | 2017-04-18   | Closed |         |
    +| 3            | 3               | 2017-04-16 | 2017-04-25    | 2017-04-20   | Closed |         |
    +| 4            | 3               | 2017-04-18 | 2017-04-28    | 2017-04-25   | Closed |         |
    +
    + +

    Sample Output

    + +
    +| customer_number |
    +|-----------------|
    +| 3               |
    +
    + +

    Explanation

    + +
    +The customer with number '3' has two orders, which is greater than either customer '1' or '2' because each of them  only has one order. 
    +So the result is customer_number '3'.
    +
    + +

    Follow up: What if more than one customer have the largest number of orders, can you find all the customer_number in this case?

    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/customers-who-bought-all-products/README.md b/problems/customers-who-bought-all-products/README.md index 860b4e563..1f081037c 100644 --- a/problems/customers-who-bought-all-products/README.md +++ b/problems/customers-who-bought-all-products/README.md @@ -11,7 +11,64 @@ ## [1045. Customers Who Bought All Products (Medium)](https://leetcode.com/problems/customers-who-bought-all-products "买下所有产品的客户") +

    Table: Customer

    +
    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| customer_id | int     |
    +| product_key | int     |
    ++-------------+---------+
    +product_key is a foreign key to Product table.
    +
    + +

    Table: Product

    + +
    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| product_key | int     |
    ++-------------+---------+
    +product_key is the primary key column for this table.
    +
    + +

     

    + +

    Write an SQL query for a report that provides the customer ids from the Customer table that bought all the products in the Product table.

    + +

    For example:

    + +
    +Customer table:
    ++-------------+-------------+
    +| customer_id | product_key |
    ++-------------+-------------+
    +| 1           | 5           |
    +| 2           | 6           |
    +| 3           | 5           |
    +| 3           | 6           |
    +| 1           | 6           |
    ++-------------+-------------+
    +
    +Product table:
    ++-------------+
    +| product_key |
    ++-------------+
    +| 5           |
    +| 6           |
    ++-------------+
    +
    +Result table:
    ++-------------+
    +| customer_id |
    ++-------------+
    +| 1           |
    +| 3           |
    ++-------------+
    +The customers who bought all the products (5 and 6) are customers with id 1 and 3.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/customers-who-bought-products-a-and-b-but-not-c/README.md b/problems/customers-who-bought-products-a-and-b-but-not-c/README.md index d8a181f24..50dfe74b7 100644 --- a/problems/customers-who-bought-products-a-and-b-but-not-c/README.md +++ b/problems/customers-who-bought-products-a-and-b-but-not-c/README.md @@ -11,7 +11,71 @@ ## [1398. Customers Who Bought Products A and B but Not C (Medium)](https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c "购买了产品 A 和产品 B 却没有购买产品 C 的顾客") +

    Table: Customers

    +
    ++---------------------+---------+
    +| Column Name         | Type    |
    ++---------------------+---------+
    +| customer_id         | int     |
    +| customer_name       | varchar |
    ++---------------------+---------+
    +customer_id is the primary key for this table.
    +customer_name is the name of the customer.
    +
    + +

    Table: Orders

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| order_id      | int     |
    +| customer_id   | int     |
    +| product_name  | varchar |
    ++---------------+---------+
    +order_id is the primary key for this table.
    +customer_id is the id of the customer who bought the product "product_name".
    +
    + +Write an SQL query to report the customer_id and customer_name of customers who bought products "A", "B" but did not buy the product "C" since we want to recommend them buy this product. +Return the result table ordered by customer_id. + +The query result format is in the following example. + +
    +Customers table:
    ++-------------+---------------+
    +| customer_id | customer_name |
    ++-------------+---------------+
    +| 1           | Daniel        |
    +| 2           | Diana         |
    +| 3           | Elizabeth     |
    +| 4           | Jhon          |
    ++-------------+---------------+
    +
    +Orders table:
    ++------------+--------------+---------------+
    +| order_id   | customer_id  | product_name  |
    ++------------+--------------+---------------+
    +| 10         |     1        |     A         |
    +| 20         |     1        |     B         |
    +| 30         |     1        |     D         |
    +| 40         |     1        |     C         |
    +| 50         |     2        |     A         |
    +| 60         |     3        |     A         |
    +| 70         |     3        |     B         |
    +| 80         |     3        |     D         |
    +| 90         |     4        |     C         |
    ++------------+--------------+---------------+
    +
    +Result table:
    ++-------------+---------------+
    +| customer_id | customer_name |
    ++-------------+---------------+
    +| 3           | Elizabeth     |
    ++-------------+---------------+
    +Only the customer_id with id 3 bought the product A and B but not the product C.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/decode-ways-ii/README.md b/problems/decode-ways-ii/README.md index c3b4ad0c9..0ce394d3a 100644 --- a/problems/decode-ways-ii/README.md +++ b/problems/decode-ways-ii/README.md @@ -31,7 +31,7 @@

    In addition to the mapping above, an encoded message may contain the '*' character, which can represent any digit from '1' to '9' ('0' is excluded). For example, the encoded message "1*" may represent any of the encoded messages "11", "12", "13", "14", "15", "16", "17", "18", or "19". Decoding "1*" is equivalent to decoding any of the encoded messages it can represent.

    -

    Given a string s containing digits and the '*' character, return the number of ways to decode it.

    +

    Given a string s consisting of digits and '*' characters, return the number of ways to decode it.

    Since the answer may be very large, return it modulo 109 + 7.

    diff --git a/problems/decoded-string-at-index/README.md b/problems/decoded-string-at-index/README.md index 324f84689..23e24d9b4 100644 --- a/problems/decoded-string-at-index/README.md +++ b/problems/decoded-string-at-index/README.md @@ -11,60 +11,52 @@ ## [880. Decoded String at Index (Medium)](https://leetcode.com/problems/decoded-string-at-index "索引处的解码字符串") -

    An encoded string s is given.  To find and write the decoded string to a tape, the encoded string is read one character at a time and the following steps are taken:

    +

    You are given an encoded string s. To decode the string to a tape, the encoded string is read one character at a time and the following steps are taken:

    • If the character read is a letter, that letter is written onto the tape.
    • -
    • If the character read is a digit (say d), the entire current tape is repeatedly written d-1 more times in total.
    • +
    • If the character read is a digit d, the entire current tape is repeatedly written d - 1 more times in total.
    -

    Now for some encoded string s, and an index k, find and return the k-th letter (1 indexed) in the decoded string.

    +

    Given an integer k, return the kth letter (1-indexed) in the decoded string.

     

    - -

    Example 1:

    -Input: s = "leet2code3", k = 10
    -Output: "o"
    -Explanation: 
    -The decoded string is "leetleetcodeleetleetcodeleetleetcode".
    -The 10th letter in the string is "o".
    +Input: s = "leet2code3", k = 10
    +Output: "o"
    +Explanation: The decoded string is "leetleetcodeleetleetcodeleetleetcode".
    +The 10th letter in the string is "o".
     
    -

    Example 2:

    -Input: s = "ha22", k = 5
    -Output: "h"
    -Explanation: 
    -The decoded string is "hahahaha".  The 5th letter is "h".
    +Input: s = "ha22", k = 5
    +Output: "h"
    +Explanation: The decoded string is "hahahaha".
    +The 5th letter is "h".
     
    -

    Example 3:

    -Input: s = "a2345678999999999999999", k = 1
    -Output: "a"
    -Explanation: 
    -The decoded string is "a" repeated 8301530446056247680 times.  The 1st letter is "a".
    +Input: s = "a2345678999999999999999", k = 1
    +Output: "a"
    +Explanation: The decoded string is "a" repeated 8301530446056247680 times.
    +The 1st letter is "a".
     
    -
    -
    -

     

    Constraints:

    • 2 <= s.length <= 100
    • -
    • s will only contain lowercase letters and digits 2 through 9.
    • -
    • s starts with a letter.
    • +
    • s consists of lowercase English letters and digits 2 through 9.
    • +
    • s starts with a letter.
    • 1 <= k <= 109
    • -
    • It's guaranteed that k is less than or equal to the length of the decoded string.
    • +
    • It is guaranteed that k is less than or equal to the length of the decoded string.
    • The decoded string is guaranteed to have less than 263 letters.
    diff --git a/problems/delete-duplicate-folders-in-system/README.md b/problems/delete-duplicate-folders-in-system/README.md new file mode 100644 index 000000000..1ea8b1a42 --- /dev/null +++ b/problems/delete-duplicate-folders-in-system/README.md @@ -0,0 +1,124 @@ + + + + + + + +[< Previous](../maximum-compatibility-score-sum "Maximum Compatibility Score Sum") +                 +[Next >](../strong-friendship "Strong Friendship") + +## [1948. Delete Duplicate Folders in System (Hard)](https://leetcode.com/problems/delete-duplicate-folders-in-system "删除系统中的重复文件夹") + +

    Due to a bug, there are many duplicate folders in a file system. You are given a 2D array paths, where paths[i] is an array representing an absolute path to the ith folder in the file system.

    + +
      +
    • For example, ["one", "two", "three"] represents the path "/one/two/three".
    • +
    + +

    Two folders (not necessarily on the same level) are identical if they contain the same non-empty set of identical subfolders and underlying subfolder structure. The folders do not need to be at the root level to be identical. If two or more folders are identical, then mark the folders as well as all their subfolders.

    + +
      +
    • For example, folders "/a" and "/b" in the file structure below are identical. They (as well as their subfolders) should all be marked: +
        +
      • /a
      • +
      • /a/x
      • +
      • /a/x/y
      • +
      • /a/z
      • +
      • /b
      • +
      • /b/x
      • +
      • /b/x/y
      • +
      • /b/z
      • +
      +
    • +
    • However, if the file structure also included the path "/b/w", then the folders "/a" and "/b" would not be identical. Note that "/a/x" and "/b/x" would still be considered identical even with the added folder.
    • +
    + +

    Once all the identical folders and their subfolders have been marked, the file system will delete all of them. The file system only runs the deletion once, so any folders that become identical after the initial deletion are not deleted.

    + +

    Return the 2D array ans containing the paths of the remaining folders after deleting all the marked folders. The paths may be returned in any order.

    + +

     

    +

    Example 1:

    + +
    +Input: paths = [["a"],["c"],["d"],["a","b"],["c","b"],["d","a"]]
    +Output: [["d"],["d","a"]]
    +Explanation: The file structure is as shown.
    +Folders "/a" and "/c" (and their subfolders) are marked for deletion because they both contain an empty
    +folder named "b".
    +
    + +

    Example 2:

    + +
    +Input: paths = [["a"],["c"],["a","b"],["c","b"],["a","b","x"],["a","b","x","y"],["w"],["w","y"]]
    +Output: [["c"],["c","b"],["a"],["a","b"]]
    +Explanation: The file structure is as shown. 
    +Folders "/a/b/x" and "/w" (and their subfolders) are marked for deletion because they both contain an empty folder named "y".
    +Note that folders "/a" and "/c" are identical after the deletion, but they are not deleted because they were not marked beforehand.
    +
    + +

    Example 3:

    + +
    +Input: paths = [["a","b"],["c","d"],["c"],["a"]]
    +Output: [["c"],["c","d"],["a"],["a","b"]]
    +Explanation: All folders are unique in the file system.
    +Note that the returned array can be in a different order as the order does not matter.
    +
    + +

    Example 4:

    + +
    +Input: paths = [["a"],["a","x"],["a","x","y"],["a","z"],["b"],["b","x"],["b","x","y"],["b","z"]]
    +Output: []
    +Explanation: The file structure is as shown.
    +Folders "/a/x" and "/b/x" (and their subfolders) are marked for deletion because they both contain an
    +empty folder named "y".
    +Folders "/a" and "/b" (and their subfolders) are marked for deletion because they both contain an empty
    +folder "z" and the folder "x" described above.
    +
    + +

    Example 5:

    + +
    +Input: paths = [["a"],["a","x"],["a","x","y"],["a","z"],["b"],["b","x"],["b","x","y"],["b","z"],["b","w"]]
    +Output: [["b"],["b","w"],["b","z"],["a"],["a","z"]]
    +Explanation: This has the same structure as the previous example, except with the added "/b/w".
    +Folders "/a/x" and "/b/x" are still marked, but "/a" and "/b" are no longer marked because "/b" has the
    +empty folder named "w" and "/a" does not.
    +Note that "/a/z" and "/b/z" are not marked because the set of identical subfolders must be non-empty, but these folders are empty.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= paths.length <= 2 * 104
    • +
    • 1 <= paths[i].length <= 500
    • +
    • 1 <= paths[i][j].length <= 10
    • +
    • 1 <= sum(paths[i][j].length) <= 2 * 105
    • +
    • path[i][j] consists of lowercase English letters.
    • +
    • No two paths lead to the same folder.
    • +
    • For any folder not at the root level, its parent folder will also be in the input.
    • +
    + +### Related Topics + [[Trie](../../tag/trie/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + +### Hints +
    +Hint 1 +Can we use a trie to build the folder structure? +
    + +
    +Hint 2 +Can we utilize hashing to hash the folder structures? +
    diff --git a/problems/delete-tree-nodes/README.md b/problems/delete-tree-nodes/README.md index 37f521961..afe244584 100644 --- a/problems/delete-tree-nodes/README.md +++ b/problems/delete-tree-nodes/README.md @@ -11,7 +11,37 @@ ## [1273. Delete Tree Nodes (Medium)](https://leetcode.com/problems/delete-tree-nodes "删除树节点") +

    A tree rooted at node 0 is given as follows:

    +
      +
    • The number of nodes is nodes;
    • +
    • The value of the i-th node is value[i];
    • +
    • The parent of the i-th node is parent[i].
    • +
    + +

    Remove every subtree whose sum of values of nodes is zero.

    + +

    After doing so, return the number of nodes remaining in the tree.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: nodes = 7, parent = [-1,0,0,1,2,2,2], value = [1,-2,4,0,-2,-1,-1]
    +Output: 2
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nodes <= 10^4
    • +
    • -10^5 <= value[i] <= 10^5
    • +
    • parent.length == nodes
    • +
    • parent[0] == -1 which indicates that 0 is the root.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/describe-the-painting/README.md b/problems/describe-the-painting/README.md new file mode 100644 index 000000000..6df82efe4 --- /dev/null +++ b/problems/describe-the-painting/README.md @@ -0,0 +1,97 @@ + + + + + + + +[< Previous](../the-number-of-the-smallest-unoccupied-chair "The Number of the Smallest Unoccupied Chair") +                 +[Next >](../number-of-visible-people-in-a-queue "Number of Visible People in a Queue") + +## [1943. Describe the Painting (Medium)](https://leetcode.com/problems/describe-the-painting "描述绘画结果") + +

    There is a long and thin painting that can be represented by a number line. The painting was painted with multiple overlapping segments where each segment was painted with a unique color. You are given a 2D integer array segments, where segments[i] = [starti, endi, colori] represents the half-closed segment [starti, endi) with colori as the color.

    + +

    The colors in the overlapping segments of the painting were mixed when it was painted. When two or more colors mix, they form a new color that can be represented as a set of mixed colors.

    + +
      +
    • For example, if colors 2, 4, and 6 are mixed, then the resulting mixed color is {2,4,6}.
    • +
    + +

    For the sake of simplicity, you should only output the sum of the elements in the set rather than the full set.

    + +

    You want to describe the painting with the minimum number of non-overlapping half-closed segments of these mixed colors. These segments can be represented by the 2D array painting where painting[j] = [leftj, rightj, mixj] describes a half-closed segment [leftj, rightj) with the mixed color sum of mixj.

    + +
      +
    • For example, the painting created with segments = [[1,4,5],[1,7,7]] can be described by painting = [[1,4,12],[4,7,7]] because: +
        +
      • [1,4) is colored {5,7} (with a sum of 12) from both the first and second segments.
      • +
      • [4,7) is colored {7} from only the second segment.
      • +
      +
    • +
    + +

    Return the 2D array painting describing the finished painting (excluding any parts that are not painted). You may return the segments in any order.

    + +

    A half-closed segment [a, b) is the section of the number line between points a and b including point a and not including point b.

    + +

     

    +

    Example 1:

    + +
    +Input: segments = [[1,4,5],[4,7,7],[1,7,9]]
    +Output: [[1,4,14],[4,7,16]]
    +Explanation: The painting can be described as follows:
    +- [1,4) is colored {5,9} (with a sum of 14) from the first and third segments.
    +- [4,7) is colored {7,9} (with a sum of 16) from the second and third segments.
    +
    + +

    Example 2:

    + +
    +Input: segments = [[1,7,9],[6,8,15],[8,10,7]]
    +Output: [[1,6,9],[6,7,24],[7,8,15],[8,10,7]]
    +Explanation: The painting can be described as follows:
    +- [1,6) is colored 9 from the first segment.
    +- [6,7) is colored {9,15} (with a sum of 24) from the first and second segments.
    +- [7,8) is colored 15 from the second segment.
    +- [8,10) is colored 7 from the third segment.
    +
    + +

    Example 3:

    + +
    +Input: segments = [[1,4,5],[1,4,7],[4,7,1],[4,7,11]]
    +Output: [[1,4,12],[4,7,12]]
    +Explanation: The painting can be described as follows:
    +- [1,4) is colored {5,7} (with a sum of 12) from the first and second segments.
    +- [4,7) is colored {1,11} (with a sum of 12) from the third and fourth segments.
    +Note that returning a single segment [1,7) is incorrect because the mixed color sets are different.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= segments.length <= 2 * 104
    • +
    • segments[i].length == 3
    • +
    • 1 <= starti < endi <= 105
    • +
    • 1 <= colori <= 109
    • +
    • Each colori is distinct.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +Can we sort the segments in a way to help solve the problem? +
    + +
    +Hint 2 +How can we dynamically keep track of the sum of the current segment(s)? +
    diff --git a/problems/design-a-leaderboard/README.md b/problems/design-a-leaderboard/README.md index ec31dc37d..b7b2e63b3 100644 --- a/problems/design-a-leaderboard/README.md +++ b/problems/design-a-leaderboard/README.md @@ -11,7 +11,49 @@ ## [1244. Design A Leaderboard (Medium)](https://leetcode.com/problems/design-a-leaderboard "力扣排行榜") +

    Design a Leaderboard class, which has 3 functions:

    +
      +
    1. addScore(playerId, score): Update the leaderboard by adding score to the given player's score. If there is no player with such id in the leaderboard, add him to the leaderboard with the given score.
    2. +
    3. top(K): Return the score sum of the top K players.
    4. +
    5. reset(playerId): Reset the score of the player with the given id to 0. It is guaranteed that the player was added to the leaderboard before calling this function.
    6. +
    + +

    Initially, the leaderboard is empty.

    + +

     

    +

    Example 1:

    + +
    +Input: 
    +["Leaderboard","addScore","addScore","addScore","addScore","addScore","top","reset","reset","addScore","top"]
    +[[],[1,73],[2,56],[3,39],[4,51],[5,4],[1],[1],[2],[2,51],[3]]
    +Output: 
    +[null,null,null,null,null,null,73,null,null,null,141]
    +
    +Explanation: 
    +Leaderboard leaderboard = new Leaderboard ();
    +leaderboard.addScore(1,73);   // leaderboard = [[1,73]];
    +leaderboard.addScore(2,56);   // leaderboard = [[1,73],[2,56]];
    +leaderboard.addScore(3,39);   // leaderboard = [[1,73],[2,56],[3,39]];
    +leaderboard.addScore(4,51);   // leaderboard = [[1,73],[2,56],[3,39],[4,51]];
    +leaderboard.addScore(5,4);    // leaderboard = [[1,73],[2,56],[3,39],[4,51],[5,4]];
    +leaderboard.top(1);           // returns 73;
    +leaderboard.reset(1);         // leaderboard = [[2,56],[3,39],[4,51],[5,4]];
    +leaderboard.reset(2);         // leaderboard = [[3,39],[4,51],[5,4]];
    +leaderboard.addScore(2,51);   // leaderboard = [[2,51],[3,39],[4,51],[5,4]];
    +leaderboard.top(3);           // returns 141 = 51 + 51 + 39;
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= playerId, K <= 10000
    • +
    • It's guaranteed that K is less than or equal to the current number of players.
    • +
    • 1 <= score <= 100
    • +
    • There will be at most 1000 function calls.
    • +
    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/design-bounded-blocking-queue/README.md b/problems/design-bounded-blocking-queue/README.md index 95fa6abb3..3a2a2fab3 100644 --- a/problems/design-bounded-blocking-queue/README.md +++ b/problems/design-bounded-blocking-queue/README.md @@ -11,7 +11,80 @@ ## [1188. Design Bounded Blocking Queue (Medium)](https://leetcode.com/problems/design-bounded-blocking-queue "设计有限阻塞队列") +

    Implement a thread safe bounded blocking queue that has the following methods:

    +
      +
    • BoundedBlockingQueue(int capacity) The constructor initializes the queue with a maximum capacity.
    • +
    • void enqueue(int element) Adds an element to the front of the queue. If the queue is full, the calling thread is blocked until the queue is no longer full.
    • +
    • int dequeue() Returns the element at the rear of the queue and removes it. If the queue is empty, the calling thread is blocked until the queue is no longer empty.
    • +
    • int size() Returns the number of elements currently in the queue.
    • +
    + +

    Your implementation will be tested using multiple threads at the same time. Each thread will either be a producer thread that only makes calls to the enqueue method or a consumer thread that only makes calls to the dequeue method. The size method will be called after every test case.

    + +

    Please do not use built-in implementations of bounded blocking queue as this will not be accepted in an interview.

    + +

     

    + +

    Example 1:

    + +
    +Input:
    +1
    +1
    +["BoundedBlockingQueue","enqueue","dequeue","dequeue","enqueue","enqueue","enqueue","enqueue","dequeue"]
    +[[2],[1],[],[],[0],[2],[3],[4],[]]
    +
    +Output:
    +[1,0,2,2]
    +
    +Explanation:
    +Number of producer threads = 1
    +Number of consumer threads = 1
    +
    +BoundedBlockingQueue queue = new BoundedBlockingQueue(2);   // initialize the queue with capacity = 2.
    +
    +queue.enqueue(1);   // The producer thread enqueues 1 to the queue.
    +queue.dequeue();    // The consumer thread calls dequeue and returns 1 from the queue.
    +queue.dequeue();    // Since the queue is empty, the consumer thread is blocked.
    +queue.enqueue(0);   // The producer thread enqueues 0 to the queue. The consumer thread is unblocked and returns 0 from the queue.
    +queue.enqueue(2);   // The producer thread enqueues 2 to the queue.
    +queue.enqueue(3);   // The producer thread enqueues 3 to the queue.
    +queue.enqueue(4);   // The producer thread is blocked because the queue's capacity (2) is reached.
    +queue.dequeue();    // The consumer thread returns 2 from the queue. The producer thread is unblocked and enqueues 4 to the queue.
    +queue.size();       // 2 elements remaining in the queue. size() is always called at the end of each test case.
    +
    + +

     

    + +

    Example 2:

    + +
    +Input:
    +3
    +4
    +["BoundedBlockingQueue","enqueue","enqueue","enqueue","dequeue","dequeue","dequeue","enqueue"]
    +[[3],[1],[0],[2],[],[],[],[3]]
    +
    +Output:
    +[1,0,2,1]
    +
    +Explanation:
    +Number of producer threads = 3
    +Number of consumer threads = 4
    +
    +BoundedBlockingQueue queue = new BoundedBlockingQueue(3);   // initialize the queue with capacity = 3.
    +
    +queue.enqueue(1);   // Producer thread P1 enqueues 1 to the queue.
    +queue.enqueue(0);   // Producer thread P2 enqueues 0 to the queue.
    +queue.enqueue(2);   // Producer thread P3 enqueues 2 to the queue.
    +queue.dequeue();    // Consumer thread C1 calls dequeue.
    +queue.dequeue();    // Consumer thread C2 calls dequeue.
    +queue.dequeue();    // Consumer thread C3 calls dequeue.
    +queue.enqueue(3);   // One of the producer threads enqueues 3 to the queue.
    +queue.size();       // 1 element remaining in the queue.
    +
    +Since the number of threads for producer/consumer is greater than 1, we do not know how the threads will be scheduled in the operating system, even though the input seems to imply the ordering. Therefore, any of the output [1,0,2] or [1,2,0] or [0,1,2] or [0,2,1] or [2,0,1] or [2,1,0] will be accepted.
    ### Related Topics [[Concurrency](../../tag/concurrency/README.md)] diff --git a/problems/design-circular-deque/README.md b/problems/design-circular-deque/README.md index 667c1883c..967350e2d 100644 --- a/problems/design-circular-deque/README.md +++ b/problems/design-circular-deque/README.md @@ -13,45 +13,50 @@

    Design your implementation of the circular double-ended queue (deque).

    -

    Your implementation should support following operations:

    +

    Implement the MyCircularDeque class:

      -
    • MyCircularDeque(k): Constructor, set the size of the deque to be k.
    • -
    • insertFront(): Adds an item at the front of Deque. Return true if the operation is successful.
    • -
    • insertLast(): Adds an item at the rear of Deque. Return true if the operation is successful.
    • -
    • deleteFront(): Deletes an item from the front of Deque. Return true if the operation is successful.
    • -
    • deleteLast(): Deletes an item from the rear of Deque. Return true if the operation is successful.
    • -
    • getFront(): Gets the front item from the Deque. If the deque is empty, return -1.
    • -
    • getRear(): Gets the last item from Deque. If the deque is empty, return -1.
    • -
    • isEmpty(): Checks whether Deque is empty or not. 
    • -
    • isFull(): Checks whether Deque is full or not.
    • +
    • MyCircularDeque(int k) Initializes the deque with a maximum size of k.
    • +
    • boolean insertFront() Adds an item at the front of Deque. Returns true if the operation is successful, or false otherwise.
    • +
    • boolean insertLast() Adds an item at the rear of Deque. Returns true if the operation is successful, or false otherwise.
    • +
    • boolean deleteFront() Deletes an item from the front of Deque. Returns true if the operation is successful, or false otherwise.
    • +
    • boolean deleteLast() Deletes an item from the rear of Deque. Returns true if the operation is successful, or false otherwise.
    • +
    • int getFront() Returns the front item from the Deque. Returns -1 if the deque is empty.
    • +
    • int getRear() Returns the last item from Deque. Returns -1 if the deque is empty.
    • +
    • boolean isEmpty() Returns true if the deque is empty, or false otherwise.
    • +
    • boolean isFull() Returns true if the deque is full, or false otherwise.

     

    - -

    Example:

    +

    Example 1:

    -MyCircularDeque circularDeque = new MycircularDeque(3); // set the size to be 3
    -circularDeque.insertLast(1);			// return true
    -circularDeque.insertLast(2);			// return true
    -circularDeque.insertFront(3);			// return true
    -circularDeque.insertFront(4);			// return false, the queue is full
    -circularDeque.getRear();  			// return 2
    -circularDeque.isFull();				// return true
    -circularDeque.deleteLast();			// return true
    -circularDeque.insertFront(4);			// return true
    -circularDeque.getFront();			// return 4
    +Input
    +["MyCircularDeque", "insertLast", "insertLast", "insertFront", "insertFront", "getRear", "isFull", "deleteLast", "insertFront", "getFront"]
    +[[3], [1], [2], [3], [4], [], [], [], [4], []]
    +Output
    +[null, true, true, true, false, 2, true, true, true, 4]
    +
    +Explanation
    +MyCircularDeque myCircularDeque = new MyCircularDeque(3);
    +myCircularDeque.insertLast(1);  // return True
    +myCircularDeque.insertLast(2);  // return True
    +myCircularDeque.insertFront(3); // return True
    +myCircularDeque.insertFront(4); // return False, the queue is full.
    +myCircularDeque.getRear();      // return 2
    +myCircularDeque.isFull();       // return True
    +myCircularDeque.deleteLast();   // return True
    +myCircularDeque.insertFront(4); // return True
    +myCircularDeque.getFront();     // return 4
     

     

    - -

    Note:

    +

    Constraints:

      -
    • All values will be in the range of [0, 1000].
    • -
    • The number of operations will be in the range of [1, 1000].
    • -
    • Please do not use the built-in Deque library.
    • +
    • 1 <= k <= 1000
    • +
    • 0 <= value <= 1000
    • +
    • At most 2000 calls will be made to insertFront, insertLast, deleteFront, deleteLast, getFront, getRear, isEmpty, isFull.
    ### Related Topics diff --git a/problems/design-compressed-string-iterator/README.md b/problems/design-compressed-string-iterator/README.md index 087f3818d..4b87314c6 100644 --- a/problems/design-compressed-string-iterator/README.md +++ b/problems/design-compressed-string-iterator/README.md @@ -11,7 +11,42 @@ ## [604. Design Compressed String Iterator (Easy)](https://leetcode.com/problems/design-compressed-string-iterator "迭代压缩字符串") +

    +Design and implement a data structure for a compressed string iterator. It should support the following operations: next and hasNext. +

    +

    +The given compressed string will be in the form of each letter followed by a positive integer representing the number of this letter existing in the original uncompressed string. +

    + +

    +next() - if the original string still has uncompressed characters, return the next letter; Otherwise return a white space.
    +hasNext() - Judge whether there is any letter needs to be uncompressed. +

    + +

    +Note:
    +Please remember to RESET your class variables declared in StringIterator, as static/class variables are persisted across multiple test cases. Please see here for more details. +

    + + +

    Example: +

    +StringIterator iterator = new StringIterator("L1e2t1C1o1d1e1");
    +
    +iterator.next(); // return 'L'
    +iterator.next(); // return 'e'
    +iterator.next(); // return 'e'
    +iterator.next(); // return 't'
    +iterator.next(); // return 'C'
    +iterator.next(); // return 'o'
    +iterator.next(); // return 'd'
    +iterator.hasNext(); // return true
    +iterator.next(); // return 'e'
    +iterator.hasNext(); // return false
    +iterator.next(); // return ' '
    +
    +

    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/design-excel-sum-formula/README.md b/problems/design-excel-sum-formula/README.md index 0cd3ef4a3..aa80932d7 100644 --- a/problems/design-excel-sum-formula/README.md +++ b/problems/design-excel-sum-formula/README.md @@ -11,8 +11,64 @@ ## [631. Design Excel Sum Formula (Hard)](https://leetcode.com/problems/design-excel-sum-formula "设计 Excel 求和公式") +

    Your task is to design the basic function of Excel and implement the function of sum formula. Specifically, you need to implement the following functions:

    + +

    Excel(int H, char W): This is the constructor. The inputs represents the height and width of the Excel form. H is a positive integer, range from 1 to 26. It represents the height. W is a character range from 'A' to 'Z'. It represents that the width is the number of characters from 'A' to W. The Excel form content is represented by a height * width 2D integer array C, it should be initialized to zero. You should assume that the first row of C starts from 1, and the first column of C starts from 'A'.

    + +
    + +

    void Set(int row, char column, int val): Change the value at C(row, column) to be val.

    +
    +

    int Get(int row, char column): Return the value at C(row, column).

    +
    +

    int Sum(int row, char column, List of Strings : numbers): This function calculate and set the value at C(row, column), where the value should be the sum of cells represented by numbers. This function return the sum result at C(row, column). This sum formula should exist until this cell is overlapped by another value or another sum formula.

    + +

    numbers is a list of strings that each string represent a cell or a range of cells. If the string represent a single cell, then it has the following format : ColRow. For example, "F7" represents the cell at (7, F).

    + +

    If the string represent a range of cells, then it has the following format : ColRow1:ColRow2. The range will always be a rectangle, and ColRow1 represent the position of the top-left cell, and ColRow2 represents the position of the bottom-right cell.

    +
    +

    Example 1:
    +

    +Excel(3,"C"); 
    +// construct a 3*3 2D array with all zero.
    +//   A B C
    +// 1 0 0 0
    +// 2 0 0 0
    +// 3 0 0 0
    +
    +Set(1, "A", 2);
    +// set C(1,"A") to be 2.
    +//   A B C
    +// 1 2 0 0
    +// 2 0 0 0
    +// 3 0 0 0
    +
    +Sum(3, "C", ["A1", "A1:B2"]);
    +// set C(3,"C") to be the sum of value at C(1,"A") and the values sum of the rectangle range whose top-left cell is C(1,"A") and bottom-right cell is C(2,"B"). Return 4. 
    +//   A B C
    +// 1 2 0 0
    +// 2 0 0 0
    +// 3 0 0 4
    +
    +Set(2, "B", 2);
    +// set C(2,"B") to be 2. Note C(3, "C") should also be changed.
    +//   A B C
    +// 1 2 0 0
    +// 2 0 2 0
    +// 3 0 0 6
    +
    +

    + +

    Note:
    +

      +
    1. You could assume that there won't be any circular sum reference. For example, A1 = sum(B1) and B1 = sum(A1).
    2. +
    3. The test cases are using double-quotes to represent a character.
    4. +
    5. Please remember to RESET your class variables declared in class Excel, as static/class variables are persisted across multiple test cases. Please see here for more details.
    6. +
    +

    + ### Related Topics [[Graph](../../tag/graph/README.md)] [[Design](../../tag/design/README.md)] diff --git a/problems/design-file-system/README.md b/problems/design-file-system/README.md index 768154b01..5d8630e7f 100644 --- a/problems/design-file-system/README.md +++ b/problems/design-file-system/README.md @@ -11,7 +11,63 @@ ## [1166. Design File System (Medium)](https://leetcode.com/problems/design-file-system "设计文件系统") +

    You are asked to design a file system which provides two functions:

    +
      +
    • createPath(path, value): Creates a new path and associates a value to it if possible and returns True. Returns False if the path already exists or its parent path doesn't exist.
    • +
    • get(path): Returns the value associated with a path or returns -1 if the path doesn't exist.
    • +
    + +

    The format of a path is one or more concatenated strings of the form: / followed by one or more lowercase English letters. For example, /leetcode and /leetcode/problems are valid paths while an empty string and / are not.

    + +

    Implement the two functions.

    + +

    Please refer to the examples for clarifications.

    + +

     

    +

    Example 1:

    + +
    +Input: 
    +["FileSystem","createPath","get"]
    +[[],["/a",1],["/a"]]
    +Output: 
    +[null,true,1]
    +Explanation: 
    +FileSystem fileSystem = new FileSystem();
    +
    +fileSystem.createPath("/a", 1); // return true
    +fileSystem.get("/a"); // return 1
    +
    + +

    Example 2:

    + +
    +Input: 
    +["FileSystem","createPath","createPath","get","createPath","get"]
    +[[],["/leet",1],["/leet/code",2],["/leet/code"],["/c/d",1],["/c"]]
    +Output: 
    +[null,true,true,2,false,-1]
    +Explanation: 
    +FileSystem fileSystem = new FileSystem();
    +
    +fileSystem.createPath("/leet", 1); // return true
    +fileSystem.createPath("/leet/code", 2); // return true
    +fileSystem.get("/leet/code"); // return 2
    +fileSystem.createPath("/c/d", 1); // return false because the parent path "/c" doesn't exist.
    +fileSystem.get("/c"); // return -1 because this path doesn't exist.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of calls to the two functions is less than or equal to 10^4 in total.
    • +
    • 2 <= path.length <= 100
    • +
    • 1 <= value <= 10^9
    • +
    + +

    NOTE: create method has been changed on August 29, 2019 to createPath. Please reset to default code definition to get new method signature.

    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/design-hit-counter/README.md b/problems/design-hit-counter/README.md index 153d04bcb..48309965b 100644 --- a/problems/design-hit-counter/README.md +++ b/problems/design-hit-counter/README.md @@ -11,7 +11,41 @@ ## [362. Design Hit Counter (Medium)](https://leetcode.com/problems/design-hit-counter "敲击计数器") +

    Design a hit counter which counts the number of hits received in the past 5 minutes.

    +

    Each function accepts a timestamp parameter (in seconds granularity) and you may assume that calls are being made to the system in chronological order (ie, the timestamp is monotonically increasing). You may assume that the earliest timestamp starts at 1.

    + +

    It is possible that several hits arrive roughly at the same time.

    + +

    Example:

    + +
    +HitCounter counter = new HitCounter();
    +
    +// hit at timestamp 1.
    +counter.hit(1);
    +
    +// hit at timestamp 2.
    +counter.hit(2);
    +
    +// hit at timestamp 3.
    +counter.hit(3);
    +
    +// get hits at timestamp 4, should return 3.
    +counter.getHits(4);
    +
    +// hit at timestamp 300.
    +counter.hit(300);
    +
    +// get hits at timestamp 300, should return 4.
    +counter.getHits(300);
    +
    +// get hits at timestamp 301, should return 3.
    +counter.getHits(301); 
    +
    + +

    Follow up:
    +What if the number of hits per second could be very large? Does your design scale?

    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/design-in-memory-file-system/README.md b/problems/design-in-memory-file-system/README.md index 688dc21e7..1e56844a9 100644 --- a/problems/design-in-memory-file-system/README.md +++ b/problems/design-in-memory-file-system/README.md @@ -11,7 +11,40 @@ ## [588. Design In-Memory File System (Hard)](https://leetcode.com/problems/design-in-memory-file-system "设计内存文件系统") +

    Design an in-memory file system to simulate the following functions:

    +

    ls: Given a path in string format. If it is a file path, return a list that only contains this file's name. If it is a directory path, return the list of file and directory names in this directory. Your output (file and directory names together) should in lexicographic order.

    + +

    mkdir: Given a directory path that does not exist, you should make a new directory according to the path. If the middle directories in the path don't exist either, you should create them as well. This function has void return type.

    + +

    addContentToFile: Given a file path and file content in string format. If the file doesn't exist, you need to create that file containing given content. If the file already exists, you need to append given content to original content. This function has void return type.

    + +

    readContentFromFile: Given a file path, return its content in string format.

    + +

     

    + +

    Example:

    + +
    Input: 
    +["FileSystem","ls","mkdir","addContentToFile","ls","readContentFromFile"]
    +[[],["/"],["/a/b/c"],["/a/b/c/d","hello"],["/"],["/a/b/c/d"]]
    +
    +Output:
    +[null,[],null,null,["a"],"hello"]
    +
    +Explanation:
    +filesystem
    +
    + +

     

    + +

    Note:

    + +
      +
    1. You can assume all file or directory paths are absolute paths which begin with / and do not end with / except that the path is just "/".
    2. +
    3. You can assume that all operations will be passed valid parameters and users will not attempt to retrieve file content or list a directory or file that does not exist.
    4. +
    5. You can assume that all directory names and file names only contain lower-case letters, and same names won't exist in the same directory.
    6. +
    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/design-log-storage-system/README.md b/problems/design-log-storage-system/README.md index 973648e3f..703762dd1 100644 --- a/problems/design-log-storage-system/README.md +++ b/problems/design-log-storage-system/README.md @@ -11,7 +11,31 @@ ## [635. Design Log Storage System (Medium)](https://leetcode.com/problems/design-log-storage-system "设计日志存储系统") +

    You are given several logs that each log contains a unique id and timestamp. Timestamp is a string that has the following format: Year:Month:Day:Hour:Minute:Second, for example, 2017:01:01:23:59:59. All domains are zero-padded decimal numbers.

    +

    Design a log storage system to implement the following functions:

    + +

    void Put(int id, string timestamp): Given a log's unique id and timestamp, store the log in your storage system.

    +
    +

    int[] Retrieve(String start, String end, String granularity): Return the id of logs whose timestamps are within the range from start to end. Start and end all have the same format as timestamp. However, granularity means the time level for consideration. For example, start = "2017:01:01:23:59:59", end = "2017:01:02:23:59:59", granularity = "Day", it means that we need to find the logs within the range from Jan. 1st 2017 to Jan. 2nd 2017.

    + +

    Example 1:
    +

    +put(1, "2017:01:01:23:59:59");
    +put(2, "2017:01:01:22:59:59");
    +put(3, "2016:01:01:00:00:00");
    +retrieve("2016:01:01:01:01:01","2017:01:01:23:00:00","Year"); // return [1,2,3], because you need to return all logs within 2016 and 2017.
    +retrieve("2016:01:01:01:01:01","2017:01:01:23:00:00","Hour"); // return [1,2], because you need to return all logs start from 2016:01:01:01 to 2017:01:01:23, where log 3 is left outside the range.
    +
    +

    + +

    Note:
    +

      +
    1. There will be at most 300 operations of Put or Retrieve.
    2. +
    3. Year ranges from [2000,2017]. Hour ranges from [00,23].
    4. +
    5. Output for Retrieve has no order required.
    6. +
    +

    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/design-phone-directory/README.md b/problems/design-phone-directory/README.md index 61e396728..249d0370a 100644 --- a/problems/design-phone-directory/README.md +++ b/problems/design-phone-directory/README.md @@ -11,7 +11,43 @@ ## [379. Design Phone Directory (Medium)](https://leetcode.com/problems/design-phone-directory "电话目录管理系统") +

    Design a Phone Directory which supports the following operations:

    +

    +

      +
    1. get: Provide a number which is not assigned to anyone.
    2. +
    3. check: Check if a number is available or not.
    4. +
    5. release: Recycle or release a number.
    6. +
    +

    + +

    Example: +

    +// Init a phone directory containing a total of 3 numbers: 0, 1, and 2.
    +PhoneDirectory directory = new PhoneDirectory(3);
    +
    +// It can return any available phone number. Here we assume it returns 0.
    +directory.get();
    +
    +// Assume it returns 1.
    +directory.get();
    +
    +// The number 2 is available, so return true.
    +directory.check(2);
    +
    +// It returns 2, the only number that is left.
    +directory.get();
    +
    +// The number 2 is no longer available, so return false.
    +directory.check(2);
    +
    +// Release number 2 back to the pool.
    +directory.release(2);
    +
    +// Number 2 is available again, return true.
    +directory.check(2);
    +
    +

    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/design-search-autocomplete-system/README.md b/problems/design-search-autocomplete-system/README.md index 8b5640771..6e35c7d5b 100644 --- a/problems/design-search-autocomplete-system/README.md +++ b/problems/design-search-autocomplete-system/README.md @@ -11,7 +11,66 @@ ## [642. Design Search Autocomplete System (Hard)](https://leetcode.com/problems/design-search-autocomplete-system "设计搜索自动补全系统") +

    Design a search autocomplete system for a search engine. Users may input a sentence (at least one word and end with a special character '#'). For each character they type except '#', you need to return the top 3 historical hot sentences that have prefix the same as the part of sentence already typed. Here are the specific rules:

    +
      +
    1. The hot degree for a sentence is defined as the number of times a user typed the exactly same sentence before.
    2. +
    3. The returned top 3 hot sentences should be sorted by hot degree (The first is the hottest one). If several sentences have the same degree of hot, you need to use ASCII-code order (smaller one appears first).
    4. +
    5. If less than 3 hot sentences exist, then just return as many as you can.
    6. +
    7. When the input is a special character, it means the sentence ends, and in this case, you need to return an empty list.
    8. +
    + +

    Your job is to implement the following functions:

    + +

    The constructor function:

    + +

    AutocompleteSystem(String[] sentences, int[] times): This is the constructor. The input is historical data. Sentences is a string array consists of previously typed sentences. Times is the corresponding times a sentence has been typed. Your system should record these historical data.

    + +

    Now, the user wants to input a new sentence. The following function will provide the next character the user types:

    + +

    List<String> input(char c): The input c is the next character typed by the user. The character will only be lower-case letters ('a' to 'z'), blank space (' ') or a special character ('#'). Also, the previously typed sentence should be recorded in your system. The output will be the top 3 historical hot sentences that have prefix the same as the part of sentence already typed.

    +  + +

    Example:
    +Operation: AutocompleteSystem(["i love you", "island","ironman", "i love leetcode"], [5,3,2,2])
    +The system have already tracked down the following sentences and their corresponding times:
    +"i love you" : 5 times
    +"island" : 3 times
    +"ironman" : 2 times
    +"i love leetcode" : 2 times
    +Now, the user begins another search:
    +
    +Operation: input('i')
    +Output: ["i love you", "island","i love leetcode"]
    +Explanation:
    +There are four sentences that have prefix "i". Among them, "ironman" and "i love leetcode" have same hot degree. Since ' ' has ASCII code 32 and 'r' has ASCII code 114, "i love leetcode" should be in front of "ironman". Also we only need to output top 3 hot sentences, so "ironman" will be ignored.
    +
    +Operation: input(' ')
    +Output: ["i love you","i love leetcode"]
    +Explanation:
    +There are only two sentences that have prefix "i ".
    +
    +Operation: input('a')
    +Output: []
    +Explanation:
    +There are no sentences that have prefix "i a".
    +
    +Operation: input('#')
    +Output: []
    +Explanation:
    +The user finished the input, the sentence "i a" should be saved as a historical sentence in system. And the following input will be counted as a new search.

    +  + +

    Note:

    + +
      +
    1. The input sentence will always start with a letter and end with '#', and only one blank space will exist between two words.
    2. +
    3. The number of complete sentences that to be searched won't exceed 100. The length of each sentence including those in the historical data won't exceed 100.
    4. +
    5. Please use double-quote instead of single-quote when you write test cases even for a character input.
    6. +
    7. Please remember to RESET your class variables declared in class AutocompleteSystem, as static/class variables are persisted across multiple test cases. Please see here for more details.
    8. +
    + +

     

    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/design-snake-game/README.md b/problems/design-snake-game/README.md index 46198163e..b3e5a91bf 100644 --- a/problems/design-snake-game/README.md +++ b/problems/design-snake-game/README.md @@ -11,7 +11,55 @@ ## [353. Design Snake Game (Medium)](https://leetcode.com/problems/design-snake-game "贪吃蛇") +

    Design a Snake game that is played on a device with screen size = width x height. Play the game online if you are not familiar with the game.

    +

    The snake is initially positioned at the top left corner (0,0) with length = 1 unit.

    + +

    You are given a list of food's positions in row-column order. When a snake eats the food, its length and the game's score both increase by 1.

    + +

    Each food appears one by one on the screen. For example, the second food will not appear until the first food was eaten by the snake.

    + +

    When a food does appear on the screen, it is guaranteed that it will not appear on a block occupied by the snake.

    + +

    Example:

    + +
    +Given width = 3, height = 2, and food = [[1,2],[0,1]].
    +
    +Snake snake = new Snake(width, height, food);
    +
    +Initially the snake appears at position (0,0) and the food at (1,2).
    +
    +|S| | |
    +| | |F|
    +
    +snake.move("R"); -> Returns 0
    +
    +| |S| |
    +| | |F|
    +
    +snake.move("D"); -> Returns 0
    +
    +| | | |
    +| |S|F|
    +
    +snake.move("R"); -> Returns 1 (Snake eats the first food and right after that, the second food appears at (0,1) )
    +
    +| |F| |
    +| |S|S|
    +
    +snake.move("U"); -> Returns 1
    +
    +| |F|S|
    +| | |S|
    +
    +snake.move("L"); -> Returns 2 (Snake eats the second food)
    +
    +| |S|S|
    +| | |S|
    +
    +snake.move("U"); -> Returns -1 (Game over because snake collides with border)
    +
    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/design-tic-tac-toe/README.md b/problems/design-tic-tac-toe/README.md index 1a423fa56..b724a798d 100644 --- a/problems/design-tic-tac-toe/README.md +++ b/problems/design-tic-tac-toe/README.md @@ -11,7 +11,63 @@ ## [348. Design Tic-Tac-Toe (Medium)](https://leetcode.com/problems/design-tic-tac-toe "设计井字棋") +

    Design a Tic-tac-toe game that is played between two players on a n x n grid. +

    +

    You may assume the following rules: +

      +
    1. A move is guaranteed to be valid and is placed on an empty block.
    2. +
    3. Once a winning condition is reached, no more moves is allowed.
    4. +
    5. A player who succeeds in placing n of their marks in a horizontal, vertical, or diagonal row wins the game.
    6. +
    +

    + +

    Example:
    +

    +Given n = 3, assume that player 1 is "X" and player 2 is "O" in the board.
    +
    +TicTacToe toe = new TicTacToe(3);
    +
    +toe.move(0, 0, 1); -> Returns 0 (no one wins)
    +|X| | |
    +| | | |    // Player 1 makes a move at (0, 0).
    +| | | |
    +
    +toe.move(0, 2, 2); -> Returns 0 (no one wins)
    +|X| |O|
    +| | | |    // Player 2 makes a move at (0, 2).
    +| | | |
    +
    +toe.move(2, 2, 1); -> Returns 0 (no one wins)
    +|X| |O|
    +| | | |    // Player 1 makes a move at (2, 2).
    +| | |X|
    +
    +toe.move(1, 1, 2); -> Returns 0 (no one wins)
    +|X| |O|
    +| |O| |    // Player 2 makes a move at (1, 1).
    +| | |X|
    +
    +toe.move(2, 0, 1); -> Returns 0 (no one wins)
    +|X| |O|
    +| |O| |    // Player 1 makes a move at (2, 0).
    +|X| |X|
    +
    +toe.move(1, 0, 2); -> Returns 0 (no one wins)
    +|X| |O|
    +|O|O| |    // Player 2 makes a move at (1, 0).
    +|X| |X|
    +
    +toe.move(2, 1, 1); -> Returns 1 (player 1 wins)
    +|X| |O|
    +|O|O| |    // Player 1 makes a move at (2, 1).
    +|X|X|X|
    +
    +

    + +

    Follow up:
    +Could you do better than O(n2) per move() operation? +

    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/diameter-of-binary-tree/README.md b/problems/diameter-of-binary-tree/README.md index 751c76f4b..2af34eb9c 100644 --- a/problems/diameter-of-binary-tree/README.md +++ b/problems/diameter-of-binary-tree/README.md @@ -23,7 +23,7 @@
     Input: root = [1,2,3,4,5]
     Output: 3
    -Explanation: 3is the length of the path [4,2,1,3] or [5,2,1,3].
    +Explanation: 3 is the length of the path [4,2,1,3] or [5,2,1,3].
     

    Example 2:

    diff --git a/problems/diet-plan-performance/README.md b/problems/diet-plan-performance/README.md index 78b3c6ba0..e13b90c53 100644 --- a/problems/diet-plan-performance/README.md +++ b/problems/diet-plan-performance/README.md @@ -11,7 +11,50 @@ ## [1176. Diet Plan Performance (Easy)](https://leetcode.com/problems/diet-plan-performance "健身计划评估") +

    A dieter consumes calories[i] calories on the i-th day.  For every consecutive sequence of k days, they look at T, the total calories consumed during that sequence of k days:

    +
      +
    • If T < lower, they performed poorly on their diet and lose 1 point; 
    • +
    • If T > upper, they performed well on their diet and gain 1 point;
    • +
    • Otherwise, they performed normally and there is no change in points.
    • +
    + +

    Return the total number of points the dieter has after all calories.length days.

    + +

    Note that: The total points could be negative.

    + +

     

    +

    Example 1:

    + +
    +Input: calories = [1,2,3,4,5], k = 1, lower = 3, upper = 3
    +Output: 0
    +Explaination: calories[0], calories[1] < lower and calories[3], calories[4] > upper, total points = 0.
    + +

    Example 2:

    + +
    +Input: calories = [3,2], k = 2, lower = 0, upper = 1
    +Output: 1
    +Explaination: calories[0] + calories[1] > upper, total points = 1.
    +
    + +

    Example 3:

    + +
    +Input: calories = [6,5,0,0], k = 2, lower = 1, upper = 5
    +Output: 0
    +Explaination: calories[0] + calories[1] > upper, lower <= calories[1] + calories[2] <= upper, calories[2] + calories[3] < lower, total points = 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= calories.length <= 10^5
    • +
    • 0 <= calories[i] <= 20000
    • +
    • 0 <= lower <= upper
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/digit-count-in-range/README.md b/problems/digit-count-in-range/README.md index 86079c016..144467f1b 100644 --- a/problems/digit-count-in-range/README.md +++ b/problems/digit-count-in-range/README.md @@ -11,7 +11,37 @@ ## [1067. Digit Count in Range (Hard)](https://leetcode.com/problems/digit-count-in-range "范围内的数字计数") +Given an integer d between 0 and 9, and two positive integers low and high as lower and upper bounds, respectively. Return the number of times that d occurs as a digit in all integers between low and high, including the bounds low and high. +

     

    +

    Example 1:

    + +
    +Input: d = 1, low = 1, high = 13
    +Output: 6
    +Explanation: 
    +The digit d=1 occurs 6 times in 1,10,11,12,13. Note that the digit d=1 occurs twice in the number 11.
    +
    + +
    +

    Example 2:

    + +
    +Input: d = 3, low = 100, high = 250
    +Output: 35
    +Explanation: 
    +The digit d=3 occurs 35 times in 103,113,123,130,131,...,238,239,243.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 0 <= d <= 9
    2. +
    3. 1 <= low <= high <= 2×10^8
    4. +
    +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/distinct-subsequences-ii/README.md b/problems/distinct-subsequences-ii/README.md index 1deced85a..ef1852f36 100644 --- a/problems/distinct-subsequences-ii/README.md +++ b/problems/distinct-subsequences-ii/README.md @@ -11,58 +11,40 @@ ## [940. Distinct Subsequences II (Hard)](https://leetcode.com/problems/distinct-subsequences-ii "不同的子序列 II") -

    Given a string s, count the number of distinct, non-empty subsequences of s .

    - -

    Since the result may be large, return the answer modulo 109 + 7.

    - +

    Given a string s, return the number of distinct non-empty subsequences of s. Since the answer may be very large, return it modulo 109 + 7.

    +A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ace" is a subsequence of "abcde" while "aec" is not.

     

    -

    Example 1:

    -Input: s = "abc"
    -Output: 7
    -Explanation: The 7 distinct subsequences are "a", "b", "c", "ab", "ac", "bc", and "abc".
    +Input: s = "abc"
    +Output: 7
    +Explanation: The 7 distinct subsequences are "a", "b", "c", "ab", "ac", "bc", and "abc".
     
    -

    Example 2:

    -Input: s = "aba"
    -Output: 6
    -Explanation: The 6 distinct subsequences are "a", "b", "ab", "ba", "aa" and "aba".
    +Input: s = "aba"
    +Output: 6
    +Explanation: The 7 distinct subsequences are "a", "b", "c", "ab", "ac", "bc", and "abc".
     
    -

    Example 3:

    -Input: s = "aaa"
    -Output: 3
    -Explanation: The 3 distinct subsequences are "a", "aa" and "aaa".
    +Input: s = "aaa"
    +Output: 3
    +Explanation: The 3 distinct subsequences are "a", "aa" and "aaa".
     
    -
    -
    - -

     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. s contains only lowercase letters.
    2. +
      • 1 <= s.length <= 2000
      • -
    - -
    -

     

    - -
    -
     
    -
    -
    +
  • s consists of lowercase English letters.
  • + ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md b/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md index 7872ac1cc..7b0bf98af 100644 --- a/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md +++ b/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md @@ -11,8 +11,9 @@ ## [1296. Divide Array in Sets of K Consecutive Numbers (Medium)](https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers "划分数组为连续数字的集合") -

    Given an array of integers nums and a positive integer k, find whether it's possible to divide this array into sets of k consecutive numbers
    -Return True if it is possible. Otherwise, return False.

    +

    Given an array of integers nums and a positive integer k, find whether it is possible to divide this array into sets of k consecutive numbers.

    + +

    Return true if it is possible. Otherwise, return false.

     

    Example 1:

    diff --git a/problems/divide-array-into-increasing-sequences/README.md b/problems/divide-array-into-increasing-sequences/README.md index 374547e12..f16e3dd3e 100644 --- a/problems/divide-array-into-increasing-sequences/README.md +++ b/problems/divide-array-into-increasing-sequences/README.md @@ -11,7 +11,37 @@ ## [1121. Divide Array Into Increasing Sequences (Hard)](https://leetcode.com/problems/divide-array-into-increasing-sequences "将数组分成几个递增序列") +

    Given a non-decreasing array of positive integers nums and an integer K, find out if this array can be divided into one or more disjoint increasing subsequences of length at least K.

    +

     

    + +

    Example 1:

    + +
    +Input: nums = [1,2,2,3,3,4,4], K = 3
    +Output: true
    +Explanation: 
    +The array can be divided into the two subsequences [1,2,3,4] and [2,3,4] with lengths at least 3 each.
    +
    + +

    Example 2:

    + +
    +Input: nums = [5,6,6,7,8], K = 3
    +Output: false
    +Explanation: 
    +There is no way to divide the array using the conditions required.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= nums.length <= 10^5
    2. +
    3. 1 <= K <= nums.length
    4. +
    5. 1 <= nums[i] <= 10^5
    6. +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/divide-chocolate/README.md b/problems/divide-chocolate/README.md index 4e6cb9423..4d9a7d8cf 100644 --- a/problems/divide-chocolate/README.md +++ b/problems/divide-chocolate/README.md @@ -11,7 +11,46 @@ ## [1231. Divide Chocolate (Hard)](https://leetcode.com/problems/divide-chocolate "分享巧克力") +

    You have one chocolate bar that consists of some chunks. Each chunk has its own sweetness given by the array sweetness.

    +

    You want to share the chocolate with your K friends so you start cutting the chocolate bar into K+1 pieces using K cuts, each piece consists of some consecutive chunks.

    + +

    Being generous, you will eat the piece with the minimum total sweetness and give the other pieces to your friends.

    + +

    Find the maximum total sweetness of the piece you can get by cutting the chocolate bar optimally.

    + +

     

    +

    Example 1:

    + +
    +Input: sweetness = [1,2,3,4,5,6,7,8,9], K = 5
    +Output: 6
    +Explanation: You can divide the chocolate to [1,2,3], [4,5], [6], [7], [8], [9]
    +
    + +

    Example 2:

    + +
    +Input: sweetness = [5,6,7,8,9,1,2,3,4], K = 8
    +Output: 1
    +Explanation: There is only one way to cut the bar into 9 pieces.
    +
    + +

    Example 3:

    + +
    +Input: sweetness = [1,2,2,1,2,2,1,2,2], K = 2
    +Output: 5
    +Explanation: You can divide the chocolate to [1,2,2], [1,2,2], [1,2,2]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= K < sweetness.length <= 10^4
    • +
    • 1 <= sweetness[i] <= 10^5
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/domino-and-tromino-tiling/README.md b/problems/domino-and-tromino-tiling/README.md index d2972acf4..fe700add4 100644 --- a/problems/domino-and-tromino-tiling/README.md +++ b/problems/domino-and-tromino-tiling/README.md @@ -11,35 +11,34 @@ ## [790. Domino and Tromino Tiling (Medium)](https://leetcode.com/problems/domino-and-tromino-tiling "多米诺和托米诺平铺") -

    We have two types of tiles: a 2x1 domino shape, and an "L" tromino shape. These shapes may be rotated.

    +

    You have two types of tiles: a 2 x 1 domino shape and a tromino shape. You may rotate these shapes.

    + +

    Given an integer n, return the number of ways to tile an 2 x n board. Since the answer may be very large, return it modulo 109 + 7.

    -
    -XX  <- domino
    +

    In a tiling, every square must be covered by a tile. Two tilings are different if and only if there are two 4-directionally adjacent cells on the board such that exactly one of the tilings has both squares occupied by a tile.

    -XX <- "L" tromino -X +

     

    +

    Example 1:

    + +
    +Input: n = 3
    +Output: 5
    +Explanation: The five different ways are show above.
     
    -

    Given n, how many ways are there to tile a 2 x n board? Return your answer modulo 109 + 7.

    - -

    (In a tiling, every square must be covered by a tile. Two tilings are different if and only if there are two 4-directionally adjacent cells on the board such that exactly one of the tilings has both squares occupied by a tile.)

    +

    Example 2:

    -Example:
    -Input: n = 3
    -Output: 5
    -Explanation: 
    -The five different ways are listed below, different letters indicates different tiles:
    -XYZ XXZ XYY XXY XYY
    -XYZ YYZ XZZ XYY XXY
    +Input: n = 1 +Output: 1 +
    -

    Note:

    +

     

    +

    Constraints:

      -
    • n will be in range [1, 1000].
    • +
    • 1 <= n <= 1000
    -

     

    - ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/eliminate-maximum-number-of-monsters/README.md b/problems/eliminate-maximum-number-of-monsters/README.md index 8f472dff7..38a194480 100644 --- a/problems/eliminate-maximum-number-of-monsters/README.md +++ b/problems/eliminate-maximum-number-of-monsters/README.md @@ -11,11 +11,13 @@ ## [1921. Eliminate Maximum Number of Monsters (Medium)](https://leetcode.com/problems/eliminate-maximum-number-of-monsters "消灭怪物的最大数量") -

    You are playing a video game where you are defending your city from a group of n monsters. You are given a 0-indexed integer array dist of size n, where dist[i] is the initial distance in meters of the ith monster from the city.

    +

    You are playing a video game where you are defending your city from a group of n monsters. You are given a 0-indexed integer array dist of size n, where dist[i] is the initial distance in kilometers of the ith monster from the city.

    -

    The monsters walk toward the city at a constant speed. The speed of each monster is given to you in an integer array speed of size n, where speed[i] is the speed of the ith monster in meters per minute.

    +

    The monsters walk toward the city at a constant speed. The speed of each monster is given to you in an integer array speed of size n, where speed[i] is the speed of the ith monster in kilometers per minute.

    -

    The monsters start moving at minute 0. You have a weapon that you can choose to use at the start of every minute, including minute 0. You cannot use the weapon in the middle of a minute. The weapon can eliminate any monster that is still alive. You lose when any monster reaches your city. If a monster reaches the city exactly at the start of a minute, it counts as a loss, and the game ends before you can use your weapon in that minute.

    +

    You have a weapon that, once fully charged, can eliminate a single monster. However, the weapon takes one minute to charge.The weapon is fully charged at the very start.

    + +

    You lose when any monster reaches your city. If a monster reaches the city at the exact moment the weapon is fully charged, it counts as a loss, and the game ends before you can use your weapon.

    Return the maximum number of monsters that you can eliminate before you lose, or n if you can eliminate all the monsters before they reach the city.

    @@ -26,10 +28,9 @@ Input: dist = [1,3,4], speed = [1,1,1] Output: 3 Explanation: -At the start of minute 0, the distances of the monsters are [1,3,4], you eliminate the first monster. -At the start of minute 1, the distances of the monsters are [X,2,3], you don't do anything. -At the start of minute 2, the distances of the monsters are [X,1,2], you eliminate the second monster. -At the start of minute 3, the distances of the monsters are [X,X,1], you eliminate the third monster. +In the beginning, the distances of the monsters are [1,3,4]. You eliminate the first monster. +After a minute, the distances of the monsters are [X,2,3]. You eliminate the second monster. +After a minute, the distances of the monsters are [X,X,2]. You eliminate the thrid monster. All 3 monsters can be eliminated.

    Example 2:

    @@ -38,8 +39,8 @@ All 3 monsters can be eliminated. Input: dist = [1,1,2,3], speed = [1,1,1,1] Output: 1 Explanation: -At the start of minute 0, the distances of the monsters are [1,1,2,3], you eliminate the first monster. -At the start of minute 1, the distances of the monsters are [X,0,1,2], so you lose. +In the beginning, the distances of the monsters are [1,1,2,3]. You eliminate the first monster. +After a minute, the distances of the monsters are [X,0,1,2], so you lose. You can only eliminate 1 monster. @@ -49,8 +50,8 @@ You can only eliminate 1 monster. Input: dist = [3,2,4], speed = [5,3,2] Output: 1 Explanation: -At the start of minute 0, the distances of the monsters are [3,2,4], you eliminate the first monster. -At the start of minute 1, the distances of the monsters are [X,0,2], so you lose. +In the beginning, the distances of the monsters are [3,2,4]. You eliminate the first monster. +After a minute, the distances of the monsters are [X,0,2], so you lose. You can only eliminate 1 monster. diff --git a/problems/employee-bonus/README.md b/problems/employee-bonus/README.md index 9b43bb34f..3d3570294 100644 --- a/problems/employee-bonus/README.md +++ b/problems/employee-bonus/README.md @@ -11,7 +11,45 @@ ## [577. Employee Bonus (Easy)](https://leetcode.com/problems/employee-bonus "员工奖金") +

    Select all employee's name and bonus whose bonus is < 1000.

    +

    Table:Employee

    + +
    ++-------+--------+-----------+--------+
    +| empId |  name  | supervisor| salary |
    ++-------+--------+-----------+--------+
    +|   1   | John   |  3        | 1000   |
    +|   2   | Dan    |  3        | 2000   |
    +|   3   | Brad   |  null     | 4000   |
    +|   4   | Thomas |  3        | 4000   |
    ++-------+--------+-----------+--------+
    +empId is the primary key column for this table.
    +
    + +

    Table: Bonus

    + +
    ++-------+-------+
    +| empId | bonus |
    ++-------+-------+
    +| 2     | 500   |
    +| 4     | 2000  |
    ++-------+-------+
    +empId is the primary key column for this table.
    +
    + +

    Example ouput:

    + +
    ++-------+-------+
    +| name  | bonus |
    ++-------+-------+
    +| John  | null  |
    +| Dan   | 500   |
    +| Brad  | null  |
    ++-------+-------+
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/employee-free-time/README.md b/problems/employee-free-time/README.md index ef6c65a75..1353e3e34 100644 --- a/problems/employee-free-time/README.md +++ b/problems/employee-free-time/README.md @@ -11,7 +11,48 @@ ## [759. Employee Free Time (Hard)](https://leetcode.com/problems/employee-free-time "员工空闲时间") +

    We are given a list schedule of employees, which represents the working time for each employee.

    +

    Each employee has a list of non-overlapping Intervals, and these intervals are in sorted order.

    + +

    Return the list of finite intervals representing common, positive-length free time for all employees, also in sorted order.

    + +

    Example 1:

    + +
    +Input: schedule = [[[1,2],[5,6]],[[1,3]],[[4,10]]]
    +Output: [[3,4]]
    +Explanation:
    +There are a total of three employees, and all common
    +free time intervals would be [-inf, 1], [3, 4], [10, inf].
    +We discard any intervals that contain inf as they aren't finite.
    +
    + +

     

    + +

    Example 2:

    + +
    +Input: schedule = [[[1,3],[6,7]],[[2,4]],[[2,5],[9,12]]]
    +Output: [[5,6],[7,9]]
    +
    + +

     

    + +

    (Even though we are representing Intervals in the form [x, y], the objects inside are Intervals, not lists or arrays. For example, schedule[0][0].start = 1, schedule[0][0].end = 2, and schedule[0][0][0] is not defined.)

    + +

    Also, we wouldn't include intervals like [5, 5] in our answer, as they have zero length.

    + +

    Note:

    + +
      +
    1. schedule and schedule[i] are lists with lengths in range [1, 50].
    2. +
    3. 0 <= schedule[i].start < schedule[i].end <= 10^8.
    4. +
    + +

    NOTE: input types have been changed on June 17, 2019. Please reset to default code definition to get new method signature.

    + +

     

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/encode-and-decode-strings/README.md b/problems/encode-and-decode-strings/README.md index f66440f9d..b24f694f4 100644 --- a/problems/encode-and-decode-strings/README.md +++ b/problems/encode-and-decode-strings/README.md @@ -11,7 +11,49 @@ ## [271. Encode and Decode Strings (Medium)](https://leetcode.com/problems/encode-and-decode-strings "字符串的编码与解码") +

    Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings.

    +

    Machine 1 (sender) has the function:

    + +
    +string encode(vector<string> strs) {
    +  // ... your code
    +  return encoded_string;
    +}
    +Machine 2 (receiver) has the function: + +
    +vector<string> decode(string s) {
    +  //... your code
    +  return strs;
    +}
    +
    + +

    So Machine 1 does:

    + +
    +string encoded_string = encode(strs);
    +
    + +

    and Machine 2 does:

    + +
    +vector<string> strs2 = decode(encoded_string);
    +
    + +

    strs2 in Machine 2 should be the same as strs in Machine 1.

    + +

    Implement the encode and decode methods.

    + +

     

    + +

    Note:

    + +
      +
    • The string may contain any possible characters out of 256 valid ascii characters. Your algorithm should be generalized enough to work on any possible characters.
    • +
    • Do not use class member/global/static variables to store states. Your encode and decode algorithms should be stateless.
    • +
    • Do not rely on any library method such as eval or serialize methods. You should implement your own encode/decode algorithm.
    • +
    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/encode-n-ary-tree-to-binary-tree/README.md b/problems/encode-n-ary-tree-to-binary-tree/README.md index 57ece564a..22250ebe7 100644 --- a/problems/encode-n-ary-tree-to-binary-tree/README.md +++ b/problems/encode-n-ary-tree-to-binary-tree/README.md @@ -11,7 +11,26 @@ ## [431. Encode N-ary Tree to Binary Tree (Hard)](https://leetcode.com/problems/encode-n-ary-tree-to-binary-tree "将 N 叉树编码为二叉树") +

    Design an algorithm to encode an N-ary tree into a binary tree and decode the binary tree to get the original N-ary tree. An N-ary tree is a rooted tree in which each node has no more than N children. Similarly, a binary tree is a rooted tree in which each node has no more than 2 children. There is no restriction on how your encode/decode algorithm should work. You just need to ensure that an N-ary tree can be encoded to a binary tree and this binary tree can be decoded to the original N-nary tree structure.

    +

    For example, you may encode the following 3-ary tree to a binary tree in this way:

    + +

     

    + +

    + +

     

    + +

    Note that the above is just an example which might or might not work. You do not necessarily need to follow this format, so please be creative and come up with different approaches yourself.

    + +

     

    + +

    Note:

    + +
      +
    1. N is in the range of [1, 1000]
    2. +
    3. Do not use class member/global/static variables to store states. Your encode and decode algorithms should be stateless.
    4. +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/encode-number/README.md b/problems/encode-number/README.md index fda27aa58..a38a4b267 100644 --- a/problems/encode-number/README.md +++ b/problems/encode-number/README.md @@ -11,7 +11,33 @@ ## [1256. Encode Number (Medium)](https://leetcode.com/problems/encode-number "加密数字") +

    Given a non-negative integer num, Return its encoding string.

    +

    The encoding is done by converting the integer to a string using a secret function that you should deduce from the following table:

    + +

    + +

     

    +

    Example 1:

    + +
    +Input: num = 23
    +Output: "1000"
    +
    + +

    Example 2:

    + +
    +Input: num = 107
    +Output: "101100"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= num <= 10^9
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/encode-string-with-shortest-length/README.md b/problems/encode-string-with-shortest-length/README.md index 81f00d96e..6cb5604f0 100644 --- a/problems/encode-string-with-shortest-length/README.md +++ b/problems/encode-string-with-shortest-length/README.md @@ -11,7 +11,69 @@ ## [471. Encode String with Shortest Length (Hard)](https://leetcode.com/problems/encode-string-with-shortest-length "编码最短长度的字符串") +

    Given a non-empty string, encode the string such that its encoded length is the shortest.

    +

    The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times.

    + +

    Note:

    + +
      +
    1. k will be a positive integer and encoded string will not be empty or have extra space.
    2. +
    3. You may assume that the input string contains only lowercase English letters. The string's length is at most 160.
    4. +
    5. If an encoding process does not make the string shorter, then do not encode it. If there are several solutions, return any of them is fine.
    6. +
    + +

     

    + +

    Example 1:

    + +
    +Input: "aaa"
    +Output: "aaa"
    +Explanation: There is no way to encode it such that it is shorter than the input string, so we do not encode it.
    +
    + +

     

    + +

    Example 2:

    + +
    +Input: "aaaaa"
    +Output: "5[a]"
    +Explanation: "5[a]" is shorter than "aaaaa" by 1 character.
    +
    + +

     

    + +

    Example 3:

    + +
    +Input: "aaaaaaaaaa"
    +Output: "10[a]"
    +Explanation: "a9[a]" or "9[a]a" are also valid solutions, both of them have the same length = 5, which is the same as "10[a]".
    +
    + +

     

    + +

    Example 4:

    + +
    +Input: "aabcaabcd"
    +Output: "2[aabc]d"
    +Explanation: "aabc" occurs twice, so one answer can be "2[aabc]d".
    +
    + +

     

    + +

    Example 5:

    + +
    +Input: "abbbabbbcabbbabbbc"
    +Output: "2[2[abbb]c]"
    +Explanation: "abbbabbbc" occurs twice, but "abbbabbbc" can also be encoded to "2[abbb]c", so one answer can be "2[2[abbb]c]".
    +
    + +

     

    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/equal-tree-partition/README.md b/problems/equal-tree-partition/README.md index 84c903e84..e6ca9a94b 100644 --- a/problems/equal-tree-partition/README.md +++ b/problems/equal-tree-partition/README.md @@ -11,7 +11,54 @@ ## [663. Equal Tree Partition (Medium)](https://leetcode.com/problems/equal-tree-partition "均匀树划分") +

    +Given a binary tree with n nodes, your task is to check if it's possible to partition the tree to two trees which have the equal sum of values after removing exactly one edge on the original tree. +

    +

    Example 1:
    +

    Input:     
    +    5
    +   / \
    +  10 10
    +    /  \
    +   2   3
    +
    +Output: True
    +Explanation: 
    +    5
    +   / 
    +  10
    +      
    +Sum: 15
    +
    +   10
    +  /  \
    + 2    3
    +
    +Sum: 15
    +
    +

    + + +

    Example 2:
    +

    Input:     
    +    1
    +   / \
    +  2  10
    +    /  \
    +   2   20
    +
    +Output: False
    +Explanation: You can't split the tree into two trees with equal sum after removing exactly one edge on the tree.
    +
    +

    + +

    Note:
    +

      +
    1. The range of tree node value is in the range of [-100000, 100000].
    2. +
    3. 1 <= n <= 10000
    4. +
    +

    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/erect-the-fence-ii/README.md b/problems/erect-the-fence-ii/README.md index d0f1ff737..3d4143b02 100644 --- a/problems/erect-the-fence-ii/README.md +++ b/problems/erect-the-fence-ii/README.md @@ -7,7 +7,7 @@ [< Previous](../longest-common-subpath "Longest Common Subpath")                  -Next > +[Next >](../count-square-sum-triples "Count Square Sum Triples") ## [1924. Erect the Fence II (Hard)](https://leetcode.com/problems/erect-the-fence-ii "") diff --git a/problems/exam-room/README.md b/problems/exam-room/README.md index 803c6be58..f57444200 100644 --- a/problems/exam-room/README.md +++ b/problems/exam-room/README.md @@ -11,38 +11,49 @@ ## [855. Exam Room (Medium)](https://leetcode.com/problems/exam-room "考场就座") -

    In an exam room, there are n seats in a single row, numbered 0, 1, 2, ..., n-1.

    +

    There is an exam room with n seats in a single row labeled from 0 to n - 1.

    -

    When a student enters the room, they must sit in the seat that maximizes the distance to the closest person.  If there are multiple such seats, they sit in the seat with the lowest number.  (Also, if no one is in the room, then the student sits at seat number 0.)

    +

    When a student enters the room, they must sit in the seat that maximizes the distance to the closest person. If there are multiple such seats, they sit in the seat with the lowest number. If no one is in the room, then the student sits at seat number 0.

    -

    Return a class ExamRoom(int n) that exposes two functions: ExamRoom.seat() returning an int representing what seat the student sat in, and ExamRoom.leave(int p) representing that the student in seat number p now leaves the room.  It is guaranteed that any calls to ExamRoom.leave(p) have a student sitting in seat p.

    +

    Design a class that simulates the mentioned exam room.

    -

     

    +

    Implement the ExamRoom class:

    + +
      +
    • ExamRoom(int n) Initializes the object of the exam room with the number of the seats n.
    • +
    • int seat() Returns the label of the seat at which the next student will set.
    • +
    • void leave(int p) Indicates that the student sitting at seat p will leave the room. It is guaranteed that there will be a student sitting at seat p.
    • +
    +

     

    Example 1:

    -Input: ["ExamRoom","seat","seat","seat","seat","leave","seat"], [[10],[],[],[],[],[4],[]]
    -Output: [null,0,9,4,2,null,5]
    -Explanation:
    -ExamRoom(10) -> null
    -seat() -> 0, no one is in the room, then the student sits at seat number 0.
    -seat() -> 9, the student sits at the last seat number 9.
    -seat() -> 4, the student sits at the last seat number 4.
    -seat() -> 2, the student sits at the last seat number 2.
    -leave(4) -> null
    -seat() -> 5, the student sits at the last seat number 5.
    +Input
    +["ExamRoom", "seat", "seat", "seat", "seat", "leave", "seat"]
    +[[10], [], [], [], [], [4], []]
    +Output
    +[null, 0, 9, 4, 2, null, 5]
    +
    +Explanation
    +ExamRoom examRoom = new ExamRoom(10);
    +examRoom.seat(); // return 0, no one is in the room, then the student sits at seat number 0.
    +examRoom.seat(); // return 9, the student sits at the last seat number 9.
    +examRoom.seat(); // return 4, the student sits at the last seat number 4.
    +examRoom.seat(); // return 2, the student sits at the last seat number 2.
    +examRoom.leave(4);
    +examRoom.seat(); // return 5, the student sits at the last seat number 5.
    +
     

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= n <= 109
      • -
      • ExamRoom.seat() and ExamRoom.leave() will be called at most 104 times across all test cases.
      • -
      • Calls to ExamRoom.leave(p) are guaranteed to have a student currently sitting in seat number p.
      • -
    +
  • It is guaranteed that there is a student sitting at seat p.
  • +
  • At most 104 calls will be made to seat and leave.
  • + ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/excel-sheet-column-number/README.md b/problems/excel-sheet-column-number/README.md index 7be69848f..2db81257f 100644 --- a/problems/excel-sheet-column-number/README.md +++ b/problems/excel-sheet-column-number/README.md @@ -9,7 +9,7 @@                  [Next >](../factorial-trailing-zeroes "Factorial Trailing Zeroes") -## [171. Excel Sheet Column Number (Easy)](https://leetcode.com/problems/excel-sheet-column-number "Excel表列序号") +## [171. Excel Sheet Column Number (Easy)](https://leetcode.com/problems/excel-sheet-column-number "Excel 表列序号")

    Given a string columnTitle that represents the column title as appear in an Excel sheet, return its corresponding column number.

    diff --git a/problems/expressive-words/README.md b/problems/expressive-words/README.md index d55c8837c..f4a2bcfd0 100644 --- a/problems/expressive-words/README.md +++ b/problems/expressive-words/README.md @@ -11,35 +11,48 @@ ## [809. Expressive Words (Medium)](https://leetcode.com/problems/expressive-words "情感丰富的文字") -

    Sometimes people repeat letters to represent extra feeling, such as "hello" -> "heeellooo", "hi" -> "hiiii".  In these strings like "heeellooo", we have groups of adjacent letters that are all the same:  "h", "eee", "ll", "ooo".

    +

    Sometimes people repeat letters to represent extra feeling. For example:

    -

    For some given string s, a query word is stretchy if it can be made to be equal to s by any number of applications of the following extension operation: choose a group consisting of characters c, and add some number of characters c to the group so that the size of the group is 3 or more.

    +
      +
    • "hello" -> "heeellooo"
    • +
    • "hi" -> "hiiii"
    • +
    + +

    In these strings like "heeellooo", we have groups of adjacent letters that are all the same: "h", "eee", "ll", "ooo".

    -

    For example, starting with "hello", we could do an extension on the group "o" to get "hellooo", but we cannot get "helloo" since the group "oo" has size less than 3.  Also, we could do another extension like "ll" -> "lllll" to get "helllllooo".  If s = "helllllooo", then the query word "hello" would be stretchy because of these two extension operations: query = "hello" -> "hellooo" -> "helllllooo" = s.

    +

    You are given a string s and an array of query strings words. A query word is stretchy if it can be made to be equal to s by any number of applications of the following extension operation: choose a group consisting of characters c, and add some number of characters c to the group so that the size of the group is three or more.

    + +
      +
    • For example, starting with "hello", we could do an extension on the group "o" to get "hellooo", but we cannot get "helloo" since the group "oo" has a size less than three. Also, we could do another extension like "ll" -> "lllll" to get "helllllooo". If s = "helllllooo", then the query word "hello" would be stretchy because of these two extension operations: query = "hello" -> "hellooo" -> "helllllooo" = s.
    • +
    -

    Given a list of query words, return the number of words that are stretchy. 

    +

    Return the number of query strings that are stretchy.

     

    +

    Example 1:

    -Example:
    -Input: 
    -s = "heeellooo"
    -words = ["hello", "hi", "helo"]
    +Input: s = "heeellooo", words = ["hello", "hi", "helo"]
     Output: 1
     Explanation: 
     We can extend "e" and "o" in the word "hello" to get "heeellooo".
     We can't extend "helo" to get "heeellooo" because the group "ll" is not size 3 or more.
     
    +

    Example 2:

    + +
    +Input: s = "zzzzzyyyyy", words = ["zzyy","zy","zyy"]
    +Output: 3
    +
    +

     

    Constraints:

      -
    • 0 <= len(s) <= 100.
    • -
    • 0 <= len(words) <= 100.
    • -
    • 0 <= len(words[i]) <= 100.
    • -
    • s and all words in words consist only of lowercase letters
    • +
    • 1 <= s.length, words.length <= 100
    • +
    • 1 <= words[i].length <= 100
    • +
    • s and words[i] consist of lowercase letters.
    ### Related Topics diff --git a/problems/factor-combinations/README.md b/problems/factor-combinations/README.md index ba043174e..99da5532b 100644 --- a/problems/factor-combinations/README.md +++ b/problems/factor-combinations/README.md @@ -11,7 +11,60 @@ ## [254. Factor Combinations (Medium)](https://leetcode.com/problems/factor-combinations "因子的组合") +

    Numbers can be regarded as product of its factors. For example,

    +
    +8 = 2 x 2 x 2;
    +  = 2 x 4.
    +
    + +

    Write a function that takes an integer n and return all possible combinations of its factors.

    + +

    Note:

    + +
      +
    1. You may assume that n is always positive.
    2. +
    3. Factors should be greater than 1 and less than n.
    4. +
    + +

    Example 1:

    + +
    +Input: 1
    +Output: []
    +
    + +

    Example 2:

    + +
    +Input: 37
    +Output:[]
    + +

    Example 3:

    + +
    +Input: 12
    +Output:
    +[
    +  [2, 6],
    +  [2, 2, 3],
    +  [3, 4]
    +]
    + +

    Example 4:

    + +
    +Input: 32
    +Output:
    +[
    +  [2, 16],
    +  [2, 2, 8],
    +  [2, 2, 2, 4],
    +  [2, 2, 2, 2, 2],
    +  [2, 4, 4],
    +  [4, 8]
    +]
    +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/fair-candy-swap/README.md b/problems/fair-candy-swap/README.md index 8512c6b38..65f8226b2 100644 --- a/problems/fair-candy-swap/README.md +++ b/problems/fair-candy-swap/README.md @@ -11,64 +11,50 @@ ## [888. Fair Candy Swap (Easy)](https://leetcode.com/problems/fair-candy-swap "公平的糖果棒交换") -

    Alice and Bob have candy bars of different sizes: aliceSizes[i] is the size of the i-th bar of candy that Alice has, and bobSizes[j] is the size of the j-th bar of candy that Bob has.

    +

    Alice and Bob have a different total number of candies. You are given two integer arrays aliceSizes and bobSizes where aliceSizes[i] is the number of candies of the ith box of candy that Alice has and bobSizes[j] is the number of candies of the jth box of candy that Bob has.

    -

    Since they are friends, they would like to exchange one candy bar each so that after the exchange, they both have the same total amount of candy.  (The total amount of candy a person has is the sum of the sizes of candy bars they have.)

    +

    Since they are friends, they would like to exchange one candy box each so that after the exchange, they both have the same total amount of candy. The total amount of candy a person has is the sum of the number of candies in each box they have.

    -

    Return an integer array ans where ans[0] is the size of the candy bar that Alice must exchange, and ans[1] is the size of the candy bar that Bob must exchange.

    - -

    If there are multiple answers, you may return any one of them.  It is guaranteed an answer exists.

    +

    Return an integer array answer where answer[0] is the number of candies in the box that Alice must exchange, and answer[1] is the number of candies in the box that Bob must exchange. If there are multiple answers, you may return any one of them. It is guaranteed that at least one answer exists.

     

    - -

    Example 1:

    -Input: aliceSizes = [1,1], bobSizes = [2,2]
    -Output: [1,2]
    +Input: aliceSizes = [1,1], bobSizes = [2,2]
    +Output: [1,2]
     
    -

    Example 2:

    -Input: aliceSizes = [1,2], bobSizes = [2,3]
    -Output: [1,2]
    +Input: aliceSizes = [1,2], bobSizes = [2,3]
    +Output: [1,2]
     
    -

    Example 3:

    -Input: aliceSizes = [2], bobSizes = [1,3]
    -Output: [2,3]
    +Input: aliceSizes = [2], bobSizes = [1,3]
    +Output: [2,3]
     
    -

    Example 4:

    -Input: aliceSizes = [1,2,5], bobSizes = [2,4]
    -Output: [5,4]
    +Input: aliceSizes = [1,2,5], bobSizes = [2,4]
    +Output: [5,4]
     

     

    - -

    Note:

    +

    Constraints:

      -
    • 1 <= aliceSizes.length <= 10000
    • -
    • 1 <= bobSizes.length <= 10000
    • -
    • 1 <= aliceSizes[i] <= 100000
    • -
    • 1 <= bobSizes[i] <= 100000
    • -
    • It is guaranteed that Alice and Bob have different total amounts of candy.
    • -
    • It is guaranteed there exists an answer.
    • +
    • 1 <= aliceSizes.length, bobSizes.length <= 104
    • +
    • 1 <= aliceSizes[i], bobSizes[j] <= 105
    • +
    • Alice and Bob have a different total number of candies.
    • +
    • There will be at least one valid answer for the given input.
    -
    -
    -
    -
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/find-anagram-mappings/README.md b/problems/find-anagram-mappings/README.md index 18e2f9012..b6077c62e 100644 --- a/problems/find-anagram-mappings/README.md +++ b/problems/find-anagram-mappings/README.md @@ -11,7 +11,34 @@ ## [760. Find Anagram Mappings (Easy)](https://leetcode.com/problems/find-anagram-mappings "找出变位映射") +

    +Given two lists Aand B, and B is an anagram of A. B is an anagram of A means B is made by randomizing the order of the elements in A. +

    +We want to find an index mapping P, from A to B. A mapping P[i] = j means the ith element in A appears in B at index j. +

    +These lists A and B may contain duplicates. If there are multiple answers, output any of them. +

    +

    +For example, given +

    +A = [12, 28, 46, 32, 50]
    +B = [50, 12, 32, 46, 28]
    +
    +

    +We should return +
    +[1, 4, 3, 2, 0]
    +
    +as P[0] = 1 because the 0th element of A appears at B[1], +and P[1] = 4 because the 1st element of A appears at B[4], +and so on. +

    + +

    Note:

      +
    1. A, B have equal lengths in range [1, 100].
    2. +
    3. A[i], B[i] are integers in range [0, 10^5].
    4. +

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/find-cumulative-salary-of-an-employee/README.md b/problems/find-cumulative-salary-of-an-employee/README.md index 0e8376da5..58c172bf3 100644 --- a/problems/find-cumulative-salary-of-an-employee/README.md +++ b/problems/find-cumulative-salary-of-an-employee/README.md @@ -11,7 +11,74 @@ ## [579. Find Cumulative Salary of an Employee (Hard)](https://leetcode.com/problems/find-cumulative-salary-of-an-employee "查询员工的累计薪水") +

    The Employee table holds the salary information in a year.

    +

    Write a SQL to get the cumulative sum of an employee's salary over a period of 3 months but exclude the most recent month.

    + +

    The result should be displayed by 'Id' ascending, and then by 'Month' descending.

    + +

    Example
    +Input

    + +
    +| Id | Month | Salary |
    +|----|-------|--------|
    +| 1  | 1     | 20     |
    +| 2  | 1     | 20     |
    +| 1  | 2     | 30     |
    +| 2  | 2     | 30     |
    +| 3  | 2     | 40     |
    +| 1  | 3     | 40     |
    +| 3  | 3     | 60     |
    +| 1  | 4     | 60     |
    +| 3  | 4     | 70     |
    +
    +Output + +
    +
    +| Id | Month | Salary |
    +|----|-------|--------|
    +| 1  | 3     | 90     |
    +| 1  | 2     | 50     |
    +| 1  | 1     | 20     |
    +| 2  | 1     | 20     |
    +| 3  | 3     | 100    |
    +| 3  | 2     | 40     |
    +
    + +

     

    +Explanation + +

    Employee '1' has 3 salary records for the following 3 months except the most recent month '4': salary 40 for month '3', 30 for month '2' and 20 for month '1'
    +So the cumulative sum of salary of this employee over 3 months is 90(40+30+20), 50(30+20) and 20 respectively.

    + +
    +| Id | Month | Salary |
    +|----|-------|--------|
    +| 1  | 3     | 90     |
    +| 1  | 2     | 50     |
    +| 1  | 1     | 20     |
    +
    +Employee '2' only has one salary record (month '1') except its most recent month '2'. + +
    +| Id | Month | Salary |
    +|----|-------|--------|
    +| 2  | 1     | 20     |
    +
    + +

     

    +Employ '3' has two salary records except its most recent pay month '4': month '3' with 60 and month '2' with 40. So the cumulative salary is as following. + +
    +| Id | Month | Salary |
    +|----|-------|--------|
    +| 3  | 3     | 100    |
    +| 3  | 2     | 40     |
    +
    + +

     

    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/find-cumulative-salary-of-an-employee/mysql_schemas.sql b/problems/find-cumulative-salary-of-an-employee/mysql_schemas.sql index 3af9e0892..c5a0ea410 100644 --- a/problems/find-cumulative-salary-of-an-employee/mysql_schemas.sql +++ b/problems/find-cumulative-salary-of-an-employee/mysql_schemas.sql @@ -9,3 +9,5 @@ insert into Employee (Id, Month, Salary) values ('1', '3', '40'); insert into Employee (Id, Month, Salary) values ('3', '3', '60'); insert into Employee (Id, Month, Salary) values ('1', '4', '60'); insert into Employee (Id, Month, Salary) values ('3', '4', '70'); +insert into Employee (Id, Month, Salary) values ('1', '7', '90'); +insert into Employee (Id, Month, Salary) values ('1', '8', '90'); diff --git a/problems/find-customer-referee/README.md b/problems/find-customer-referee/README.md index 8d626e3ee..b6fa01c91 100644 --- a/problems/find-customer-referee/README.md +++ b/problems/find-customer-referee/README.md @@ -11,7 +11,35 @@ ## [584. Find Customer Referee (Easy)](https://leetcode.com/problems/find-customer-referee "寻找用户推荐人") +

    Given a table customer holding customers information and the referee.

    +
    ++------+------+-----------+
    +| id   | name | referee_id|
    ++------+------+-----------+
    +|    1 | Will |      NULL |
    +|    2 | Jane |      NULL |
    +|    3 | Alex |         2 |
    +|    4 | Bill |      NULL |
    +|    5 | Zack |         1 |
    +|    6 | Mark |         2 |
    ++------+------+-----------+
    +
    + +

    Write a query to return the list of customers NOT referred by the person with id '2'.

    + +

    For the sample data above, the result is:

    + +
    ++------+
    +| name |
    ++------+
    +| Will |
    +| Jane |
    +| Bill |
    +| Zack |
    ++------+
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/find-k-length-substrings-with-no-repeated-characters/README.md b/problems/find-k-length-substrings-with-no-repeated-characters/README.md index 785708801..8bbd4791a 100644 --- a/problems/find-k-length-substrings-with-no-repeated-characters/README.md +++ b/problems/find-k-length-substrings-with-no-repeated-characters/README.md @@ -11,7 +11,37 @@ ## [1100. Find K-Length Substrings With No Repeated Characters (Medium)](https://leetcode.com/problems/find-k-length-substrings-with-no-repeated-characters "长度为 K 的无重复字符子串") +

    Given a string S, return the number of substrings of length K with no repeated characters.

    +

     

    + +

    Example 1:

    + +
    +Input: S = "havefunonleetcode", K = 5
    +Output: 6
    +Explanation: 
    +There are 6 substrings they are : 'havef','avefu','vefun','efuno','etcod','tcode'.
    +
    + +

    Example 2:

    + +
    +Input: S = "home", K = 5
    +Output: 0
    +Explanation: 
    +Notice K can be larger than the length of S. In this case is not possible to find any substring.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= S.length <= 10^4
    2. +
    3. All characters of S are lowercase English letters.
    4. +
    5. 1 <= K <= 10^4
    6. +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/find-k-pairs-with-smallest-sums/README.md b/problems/find-k-pairs-with-smallest-sums/README.md index 8fcf41fab..12c3c6518 100644 --- a/problems/find-k-pairs-with-smallest-sums/README.md +++ b/problems/find-k-pairs-with-smallest-sums/README.md @@ -46,7 +46,7 @@

    Constraints:

      -
    • 1 <= nums1.length, nums2.length <= 104
    • +
    • 1 <= nums1.length, nums2.length <= 105
    • -109 <= nums1[i], nums2[i] <= 109
    • nums1 and nums2 both are sorted in ascending order.
    • 1 <= k <= 1000
    • diff --git a/problems/find-leaves-of-binary-tree/README.md b/problems/find-leaves-of-binary-tree/README.md index efc38ec48..581997b73 100644 --- a/problems/find-leaves-of-binary-tree/README.md +++ b/problems/find-leaves-of-binary-tree/README.md @@ -11,7 +11,51 @@ ## [366. Find Leaves of Binary Tree (Medium)](https://leetcode.com/problems/find-leaves-of-binary-tree "寻找二叉树的叶子节点") +

      Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all leaves, repeat until the tree is empty.

      +

       

      + +

      Example:

      + +
      +Input: [1,2,3,4,5]
      +  
      +          1
      +         / \
      +        2   3
      +       / \     
      +      4   5    
      +
      +Output: [[4,5,3],[2],[1]]
      +
      + +

       

      + +

      Explanation:

      + +

      1. Removing the leaves [4,5,3] would result in this tree:

      + +
      +          1
      +         / 
      +        2          
      +
      + +

       

      + +

      2. Now removing the leaf [2] would result in this tree:

      + +
      +          1          
      +
      + +

       

      + +

      3. Now removing the leaf [1] would result in the empty tree:

      + +
      +          []         
      +
      ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/find-median-given-frequency-of-numbers/README.md b/problems/find-median-given-frequency-of-numbers/README.md index 19dd85bf2..3450d3392 100644 --- a/problems/find-median-given-frequency-of-numbers/README.md +++ b/problems/find-median-given-frequency-of-numbers/README.md @@ -11,7 +11,30 @@ ## [571. Find Median Given Frequency of Numbers (Hard)](https://leetcode.com/problems/find-median-given-frequency-of-numbers "给定数字的频率查询中位数") +

      The Numbers table keeps the value of number and its frequency.

      +
      ++----------+-------------+
      +|  Number  |  Frequency  |
      ++----------+-------------|
      +|  0       |  7          |
      +|  1       |  1          |
      +|  2       |  3          |
      +|  3       |  1          |
      ++----------+-------------+
      +
      + +

      In this table, the numbers are 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 3, so the median is (0 + 0) / 2 = 0.

      + +
      ++--------+
      +| median |
      ++--------|
      +| 0.0000 |
      ++--------+
      +
      + +

      Write a query to find the median of all numbers and name the result as median.

      ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/find-permutation/README.md b/problems/find-permutation/README.md index f98bd441b..b0a0b5770 100644 --- a/problems/find-permutation/README.md +++ b/problems/find-permutation/README.md @@ -11,7 +11,32 @@ ## [484. Find Permutation (Medium)](https://leetcode.com/problems/find-permutation "寻找排列") +

      +By now, you are given a secret signature consisting of character 'D' and 'I'. 'D' represents a decreasing relationship between two numbers, 'I' represents an increasing relationship between two numbers. And our secret signature was constructed by a special integer array, which contains uniquely all the different number from 1 to n (n is the length of the secret signature plus 1). For example, the secret signature "DI" can be constructed by array [2,1,3] or [3,1,2], but won't be constructed by array [3,2,4] or [2,1,3,4], which are both illegal constructing special string that can't represent the "DI" secret signature. +

      +

      +On the other hand, now your job is to find the lexicographically smallest permutation of [1, 2, ... n] could refer to the given secret signature in the input. +

      + +

      Example 1:
      +

      Input: "I"
      +Output: [1,2]
      +Explanation: [1,2] is the only legal initial spectial string can construct secret signature "I", where the number 1 and 2 construct an increasing relationship.
      +
      +

      + +

      Example 2:
      +

      Input: "DI"
      +Output: [2,1,3]
      +Explanation: Both [2,1,3] and [3,1,2] can construct the secret signature "DI", 
      but since we want to find the one with the smallest lexicographical permutation, you need to output [2,1,3] +
      +

      + +

      Note: +

    • The input string will only contain the character 'D' and 'I'.
    • +
    • The length of input string is a positive integer and will not exceed 10,000
    • +

      ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/find-smallest-common-element-in-all-rows/README.md b/problems/find-smallest-common-element-in-all-rows/README.md index df0fbcb08..e4947d6d1 100644 --- a/problems/find-smallest-common-element-in-all-rows/README.md +++ b/problems/find-smallest-common-element-in-all-rows/README.md @@ -11,7 +11,24 @@ ## [1198. Find Smallest Common Element in All Rows (Medium)](https://leetcode.com/problems/find-smallest-common-element-in-all-rows "找出所有行中最小公共元素") +

      Given a matrix mat where every row is sorted in increasing order, return the smallest common element in all rows.

      +

      If there is no common element, return -1.

      + + +

       

      +

      Example 1:

      +
      Input: mat = [[1,2,3,4,5],[2,4,5,8,10],[3,5,7,9,11],[1,3,5,7,9]]
      +Output: 5
      +
      +

       

      +

      Constraints:

      + +
        +
      • 1 <= mat.length, mat[i].length <= 500
      • +
      • 1 <= mat[i][j] <= 10^4
      • +
      • mat[i] is sorted in increasing order.
      • +
      ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/find-the-celebrity/README.md b/problems/find-the-celebrity/README.md index 77fbabb77..9120109f5 100644 --- a/problems/find-the-celebrity/README.md +++ b/problems/find-the-celebrity/README.md @@ -11,7 +11,46 @@ ## [277. Find the Celebrity (Medium)](https://leetcode.com/problems/find-the-celebrity "搜寻名人") +

      Suppose you are at a party with n people (labeled from 0 to n - 1) and among them, there may exist one celebrity. The definition of a celebrity is that all the other n - 1 people know him/her but he/she does not know any of them.

      +

      Now you want to find out who the celebrity is or verify that there is not one. The only thing you are allowed to do is to ask questions like: "Hi, A. Do you know B?" to get information of whether A knows B. You need to find out the celebrity (or verify there is not one) by asking as few questions as possible (in the asymptotic sense).

      + +

      You are given a helper function bool knows(a, b) which tells you whether A knows B. Implement a function int findCelebrity(n). There will be exactly one celebrity if he/she is in the party. Return the celebrity's label if there is a celebrity in the party. If there is no celebrity, return -1.

      + +

       

      + +

      Example 1:

      + +
      +Input: graph = [
      +  [1,1,0],
      +  [0,1,0],
      +  [1,1,1]
      +]
      +Output: 1
      +Explanation: There are three persons labeled with 0, 1 and 2. graph[i][j] = 1 means person i knows person j, otherwise graph[i][j] = 0 means person i does not know person j. The celebrity is the person labeled as 1 because both 0 and 2 know him but 1 does not know anybody.
      +
      + +

      Example 2:

      + +
      +Input: graph = [
      +  [1,0,1],
      +  [1,1,0],
      +  [0,1,1]
      +]
      +Output: -1
      +Explanation: There is no celebrity.
      +
      + +

       

      + +

      Note:

      + +
        +
      1. The directed graph is represented as an adjacency matrix, which is an n x n matrix where a[i][j] = 1 means person i knows person j while a[i][j] = 0 means the contrary.
      2. +
      3. Remember that you won't have direct access to the adjacency matrix.
      4. +
      ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/find-the-derangement-of-an-array/README.md b/problems/find-the-derangement-of-an-array/README.md index 376017482..9099e2f77 100644 --- a/problems/find-the-derangement-of-an-array/README.md +++ b/problems/find-the-derangement-of-an-array/README.md @@ -11,7 +11,29 @@ ## [634. Find the Derangement of An Array (Medium)](https://leetcode.com/problems/find-the-derangement-of-an-array "寻找数组的错位排列") +

      +In combinatorial mathematics, a derangement is a permutation of the elements of a set, such that no element appears in its original position. +

      +

      +There's originally an array consisting of n integers from 1 to n in ascending order, you need to find the number of derangement it can generate. +

      + +

      +Also, since the answer may be very large, you should return the output mod 109 + 7. +

      + +

      Example 1:
      +

      +Input: 3
      +Output: 2
      +Explanation: The original array is [1,2,3]. The two derangements are [2,3,1] and [3,1,2].
      +
      +

      + +

      Note:
      +n is in the range of [1, 106]. +

      ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/find-the-start-and-end-number-of-continuous-ranges/README.md b/problems/find-the-start-and-end-number-of-continuous-ranges/README.md index 824130f86..2d807b762 100644 --- a/problems/find-the-start-and-end-number-of-continuous-ranges/README.md +++ b/problems/find-the-start-and-end-number-of-continuous-ranges/README.md @@ -11,7 +11,50 @@ ## [1285. Find the Start and End Number of Continuous Ranges (Medium)](https://leetcode.com/problems/find-the-start-and-end-number-of-continuous-ranges "找到连续区间的开始和结束数字") +

      Table: Logs

      +
      ++---------------+---------+
      +| Column Name   | Type    |
      ++---------------+---------+
      +| log_id        | int     |
      ++---------------+---------+
      +id is the primary key for this table.
      +Each row of this table contains the ID in a log Table.
      +
      +Since some IDs have been removed from Logs. Write an SQL query to find the start and end number of continuous ranges in table Logs. + +Order the result table by start_id. + +The query result format is in the following example: +
      +Logs table:
      ++------------+
      +| log_id     |
      ++------------+
      +| 1          |
      +| 2          |
      +| 3          |
      +| 7          |
      +| 8          |
      +| 10         |
      ++------------+
      +
      +Result table:
      ++------------+--------------+
      +| start_id   | end_id       |
      ++------------+--------------+
      +| 1          | 3            |
      +| 7          | 8            |
      +| 10         | 10           |
      ++------------+--------------+
      +The result table should contain all ranges in table Logs.
      +From 1 to 3 is contained in the table.
      +From 4 to 6 is missing in the table
      +From 7 to 8 is contained in the table.
      +Number 9 is missing in the table.
      +Number 10 is contained in the table.
      +
      ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/find-the-team-size/README.md b/problems/find-the-team-size/README.md index a85c4abf3..ef0b10037 100644 --- a/problems/find-the-team-size/README.md +++ b/problems/find-the-team-size/README.md @@ -11,7 +11,50 @@ ## [1303. Find the Team Size (Easy)](https://leetcode.com/problems/find-the-team-size "求团队人数") +

      Table: Employee

      +
      ++---------------+---------+
      +| Column Name   | Type    |
      ++---------------+---------+
      +| employee_id   | int     |
      +| team_id       | int     |
      ++---------------+---------+
      +employee_id is the primary key for this table.
      +Each row of this table contains the ID of each employee and their respective team.
      +
      +Write an SQL query to find the team size of each of the employees. + +Return result table in any order. + +The query result format is in the following example: +
      +Employee Table:
      ++-------------+------------+
      +| employee_id | team_id    |
      ++-------------+------------+
      +|     1       |     8      |
      +|     2       |     8      |
      +|     3       |     8      |
      +|     4       |     7      |
      +|     5       |     9      |
      +|     6       |     9      |
      ++-------------+------------+
      +Result table:
      ++-------------+------------+
      +| employee_id | team_size  |
      ++-------------+------------+
      +|     1       |     3      |
      +|     2       |     3      |
      +|     3       |     3      |
      +|     4       |     1      |
      +|     5       |     2      |
      +|     6       |     2      |
      ++-------------+------------+
      +Employees with Id 1,2,3 are part of a team with team_id = 8.
      +Employees with Id 4 is part of a team with team_id = 7.
      +Employees with Id 5,6 are part of a team with team_id = 9.
      +
      ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/find-the-town-judge/README.md b/problems/find-the-town-judge/README.md index fa9e63116..d801df3e8 100644 --- a/problems/find-the-town-judge/README.md +++ b/problems/find-the-town-judge/README.md @@ -11,19 +11,19 @@ ## [997. Find the Town Judge (Easy)](https://leetcode.com/problems/find-the-town-judge "找到小镇的法官") -

      In a town, there are n people labelled from 1 to n.  There is a rumor that one of these people is secretly the town judge.

      +

      In a town, there are n people labeled from 1 to n. There is a rumor that one of these people is secretly the town judge.

      -

      If the town judge exists, then:

      +

      If the town judge exists, then:

      1. The town judge trusts nobody.
      2. Everybody (except for the town judge) trusts the town judge.
      3. -
      4. There is exactly one person that satisfies properties 1 and 2.
      5. +
      6. There is exactly one person that satisfies properties 1 and 2.
      -

      You are given trust, an array of pairs trust[i] = [a, b] representing that the person labelled a trusts the person labelled b.

      +

      You are given an array trust where trust[i] = [ai, bi] representing that the person labeled ai trusts the person labeled bi.

      -

      If the town judge exists and can be identified, return the label of the town judge.  Otherwise, return -1.

      +

      Return the label of the town judge if the town judge exists and can be identified, or return -1 otherwise.

       

      Example 1:

      @@ -68,9 +68,9 @@
    • 1 <= n <= 1000
    • 0 <= trust.length <= 104
    • trust[i].length == 2
    • -
    • trust[i] are all different
    • -
    • trust[i][0] != trust[i][1]
    • -
    • 1 <= trust[i][0], trust[i][1] <= n
    • +
    • All the pairs of trust are unique.
    • +
    • ai != bi
    • +
    • 1 <= ai, bi <= n
    ### Related Topics diff --git a/problems/first-missing-positive/README.md b/problems/first-missing-positive/README.md index ba04ceb3b..f69d2437e 100644 --- a/problems/first-missing-positive/README.md +++ b/problems/first-missing-positive/README.md @@ -11,9 +11,9 @@ ## [41. First Missing Positive (Hard)](https://leetcode.com/problems/first-missing-positive "缺失的第一个正数") -

    Given an unsorted integer array nums, find the smallest missing positive integer.

    +

    Given an unsorted integer array nums, return the smallest missing positive integer.

    -

    You must implement an algorithm that runs in O(n) time and uses constant extra space.

    +

    You must implement an algorithm that runs in O(n) time and uses constant extra space.

     

    Example 1:

    diff --git a/problems/fixed-point/README.md b/problems/fixed-point/README.md index aed962a45..d3983ae1a 100644 --- a/problems/fixed-point/README.md +++ b/problems/fixed-point/README.md @@ -11,7 +11,45 @@ ## [1064. Fixed Point (Easy)](https://leetcode.com/problems/fixed-point "不动点") +

    Given an array A of distinct integers sorted in ascending order, return the smallest index i that satisfies A[i] == i.  Return -1 if no such i exists.

    +

     

    + +

    Example 1:

    + +
    +Input: [-10,-5,0,3,7]
    +Output: 3
    +Explanation: 
    +For the given array, A[0] = -10, A[1] = -5, A[2] = 0, A[3] = 3, thus the output is 3.
    +
    + +

    Example 2:

    + +
    +Input: [0,2,5,8,17]
    +Output: 0
    +Explanation: 
    +A[0] = 0, thus the output is 0.
    +
    + +

    Example 3:

    + +
    +Input: [-10,-5,3,4,7,9]
    +Output: -1
    +Explanation: 
    +There is no such i that A[i] = i, thus the output is -1.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= A.length < 10^4
    2. +
    3. -10^9 <= A[i] <= 10^9
    4. +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/flatten-2d-vector/README.md b/problems/flatten-2d-vector/README.md index c653eda1c..307ebe7a8 100644 --- a/problems/flatten-2d-vector/README.md +++ b/problems/flatten-2d-vector/README.md @@ -11,7 +11,38 @@ ## [251. Flatten 2D Vector (Medium)](https://leetcode.com/problems/flatten-2d-vector "展开二维向量") +

    Design and implement an iterator to flatten a 2d vector. It should support the following operations: next and hasNext.

    +

     

    + +

    Example:

    + +
    +Vector2D iterator = new Vector2D([[1,2],[3],[4]]);
    +
    +iterator.next(); // return 1
    +iterator.next(); // return 2
    +iterator.next(); // return 3
    +iterator.hasNext(); // return true
    +iterator.hasNext(); // return true
    +iterator.next(); // return 4
    +iterator.hasNext(); // return false
    +
    + +

     

    + +

    Notes:

    + +
      +
    1. Please remember to RESET your class variables declared in Vector2D, as static/class variables are persisted across multiple test cases. Please see here for more details.
    2. +
    3. You may assume that next() call will always be valid, that is, there will be at least a next element in the 2d vector when next() is called.
    4. +
    + +

     

    + +

    Follow up:

    + +

    As an added challenge, try to code it using only iterators in C++ or iterators in Java.

    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/flip-game-ii/README.md b/problems/flip-game-ii/README.md index c4f1e6136..b78ed337c 100644 --- a/problems/flip-game-ii/README.md +++ b/problems/flip-game-ii/README.md @@ -11,7 +11,20 @@ ## [294. Flip Game II (Medium)](https://leetcode.com/problems/flip-game-ii "翻转游戏 II") +

    You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip two consecutive "++" into "--". The game ends when a person can no longer make a move and therefore the other person will be the winner.

    +

    Write a function to determine if the starting player can guarantee a win.

    + +

    Example:

    + +
    +Input: s = "++++"
    +Output: true 
    +Explanation: The starting player can guarantee a win by flipping the middle "++" to become "+--+".
    +
    + +

    Follow up:
    +Derive your algorithm's runtime complexity.

    ### Related Topics [[Memoization](../../tag/memoization/README.md)] diff --git a/problems/flip-game/README.md b/problems/flip-game/README.md index 84ef9580a..5a155f02b 100644 --- a/problems/flip-game/README.md +++ b/problems/flip-game/README.md @@ -11,7 +11,23 @@ ## [293. Flip Game (Easy)](https://leetcode.com/problems/flip-game "翻转游戏") +

    You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip two consecutive "++" into "--". The game ends when a person can no longer make a move and therefore the other person will be the winner.

    +

    Write a function to compute all possible states of the string after one valid move.

    + +

    Example:

    + +
    +Input: s = "++++"
    +Output: 
    +[
    +  "--++",
    +  "+--+",
    +  "++--"
    +]
    +
    + +

    Note: If there is no valid move, return an empty list [].

    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/flip-string-to-monotone-increasing/README.md b/problems/flip-string-to-monotone-increasing/README.md index 4cb102280..64b7a1358 100644 --- a/problems/flip-string-to-monotone-increasing/README.md +++ b/problems/flip-string-to-monotone-increasing/README.md @@ -11,52 +11,44 @@ ## [926. Flip String to Monotone Increasing (Medium)](https://leetcode.com/problems/flip-string-to-monotone-increasing "将字符串翻转到单调递增") -

    A string of '0's and '1's is monotone increasing if it consists of some number of '0's (possibly 0), followed by some number of '1's (also possibly 0.)

    +

    A binary string is monotone increasing if it consists of some number of 0's (possibly none), followed by some number of 1's (also possibly none).

    -

    We are given a string s of '0's and '1's, and we may flip any '0' to a '1' or a '1' to a '0'.

    +

    You are given a binary string s. You can flip s[i] changing it from 0 to 1 or from 1 to 0.

    -

    Return the minimum number of flips to make s monotone increasing.

    +

    Return the minimum number of flips to make s monotone increasing.

     

    - -

    Example 1:

    -Input: s = "00110"
    -Output: 1
    -Explanation: We flip the last digit to get 00111.
    +Input: s = "00110"
    +Output: 1
    +Explanation: We flip the last digit to get 00111.
     
    -

    Example 2:

    -Input: s = "010110"
    -Output: 2
    -Explanation: We flip to get 011111, or alternatively 000111.
    +Input: s = "010110"
    +Output: 2
    +Explanation: We flip to get 011111, or alternatively 000111.
     
    -

    Example 3:

    -Input: s = "00011000"
    -Output: 2
    -Explanation: We flip to get 00000000.
    +Input: s = "00011000"
    +Output: 2
    +Explanation: We flip to get 00000000.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= s.length <= 20000
    2. -
    3. s only consists of '0' and '1' characters.
    4. -
    -
    -
    -
    +
      +
    • 1 <= s.length <= 105
    • +
    • s[i] is either '0' or '1'.
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/friend-requests-i-overall-acceptance-rate/README.md b/problems/friend-requests-i-overall-acceptance-rate/README.md index c5e128e9b..70e41d79e 100644 --- a/problems/friend-requests-i-overall-acceptance-rate/README.md +++ b/problems/friend-requests-i-overall-acceptance-rate/README.md @@ -11,7 +11,66 @@ ## [597. Friend Requests I: Overall Acceptance Rate (Easy)](https://leetcode.com/problems/friend-requests-i-overall-acceptance-rate "好友申请 I:总体通过率") +In social network like Facebook or Twitter, people send friend requests and accept others’ requests as well. Now given two tables as below: +

     

    +Table: friend_request +
    +| sender_id | send_to_id |request_date|
    +|-----------|------------|------------|
    +| 1         | 2          | 2016_06-01 |
    +| 1         | 3          | 2016_06-01 |
    +| 1         | 4          | 2016_06-01 |
    +| 2         | 3          | 2016_06-02 |
    +| 3         | 4          | 2016-06-09 |
    +
    + +

     

    +Table: request_accepted + +
    +| requester_id | accepter_id |accept_date |
    +|--------------|-------------|------------|
    +| 1            | 2           | 2016_06-03 |
    +| 1            | 3           | 2016-06-08 |
    +| 2            | 3           | 2016-06-08 |
    +| 3            | 4           | 2016-06-09 |
    +| 3            | 4           | 2016-06-10 |
    +
    + +

     

    +Write a query to find the overall acceptance rate of requests rounded to 2 decimals, which is the number of acceptance divide the number of requests. + +

     

    +For the sample data above, your query should return the following result. + +

     

    + +
    +|accept_rate|
    +|-----------|
    +|       0.80|
    +
    + +

     

    +Note: + +
      +
    • The accepted requests are not necessarily from the table friend_request. In this case, you just need to simply count the total accepted requests (no matter whether they are in the original requests), and divide it by the number of requests to get the acceptance rate.
    • +
    • It is possible that a sender sends multiple requests to the same receiver, and a request could be accepted more than once. In this case, the ‘duplicated’ requests or acceptances are only counted once.
    • +
    • If there is no requests at all, you should return 0.00 as the accept_rate.
    • +
    + +

     

    +Explanation: There are 4 unique accepted requests, and there are 5 requests in total. So the rate is 0.80. + +

     

    +Follow-up: + +
      +
    • Can you write a query to return the accept rate but for every month?
    • +
    • How about the cumulative accept rate for every day?
    • +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/friend-requests-ii-who-has-the-most-friends/README.md b/problems/friend-requests-ii-who-has-the-most-friends/README.md index 6f4e8426d..3603eb6ca 100644 --- a/problems/friend-requests-ii-who-has-the-most-friends/README.md +++ b/problems/friend-requests-ii-who-has-the-most-friends/README.md @@ -11,7 +11,47 @@ ## [602. Friend Requests II: Who Has the Most Friends (Medium)](https://leetcode.com/problems/friend-requests-ii-who-has-the-most-friends "好友申请 II :谁有最多的好友") +

    In social network like Facebook or Twitter, people send friend requests and accept others' requests as well.

    +

     

    + +

    Table request_accepted

    + +
    ++--------------+-------------+------------+
    +| requester_id | accepter_id | accept_date|
    +|--------------|-------------|------------|
    +| 1            | 2           | 2016_06-03 |
    +| 1            | 3           | 2016-06-08 |
    +| 2            | 3           | 2016-06-08 |
    +| 3            | 4           | 2016-06-09 |
    ++--------------+-------------+------------+
    +This table holds the data of friend acceptance, while requester_id and accepter_id both are the id of a person.
    +
    + +

     

    + +

    Write a query to find the the people who has most friends and the most friends number under the following rules:

    + +
      +
    • It is guaranteed there is only 1 people having the most friends.
    • +
    • The friend request could only been accepted once, which mean there is no multiple records with the same requester_id and accepter_id value.
    • +
    + +

    For the sample data above, the result is:

    + +
    +Result table:
    ++------+------+
    +| id   | num  |
    +|------|------|
    +| 3    | 3    |
    ++------+------+
    +The person with id '3' is a friend of people '1', '2' and '4', so he has 3 friends in total, which is the most number than any others.
    +
    + +

    Follow-up:
    +In the real world, multiple people could have the same most number of friends, can you find all these people in this case?

    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/friends-of-appropriate-ages/README.md b/problems/friends-of-appropriate-ages/README.md index e86686482..acc6b20f9 100644 --- a/problems/friends-of-appropriate-ages/README.md +++ b/problems/friends-of-appropriate-ages/README.md @@ -11,52 +11,54 @@ ## [825. Friends Of Appropriate Ages (Medium)](https://leetcode.com/problems/friends-of-appropriate-ages "适龄的朋友") -

    Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person. 

    +

    There are n persons on a social media website. You are given an integer array ages where ages[i] is the age of the ith person.

    -

    Person A will NOT friend request person B (B != A) if any of the following conditions are true:

    +

    A Person x will not send a friend request to a person y (x != y) if any of the following conditions is true:

      -
    • age[B] <= 0.5 * age[A] + 7
    • -
    • age[B] > age[A]
    • -
    • age[B] > 100 && age[A] < 100
    • +
    • age[y] <= 0.5 * age[x] + 7
    • +
    • age[y] > age[x]
    • +
    • age[y] > 100 && age[x] < 100
    -

    Otherwise, A will friend request B.

    +

    Otherwise, x will send a friend request to y.

    -

    Note that if A requests B, B does not necessarily request A.  Also, people will not friend request themselves.

    +

    Note that if x sends a request to y, y will not necessarily send a request to x. Also, a person will not send a friend request to themself.

    -

    How many total friend requests are made?

    +

    Return the total number of friend requests made.

    +

     

    Example 1:

    -Input: [16,16]
    -Output: 2
    -Explanation: 2 people friend request each other.
    +Input: ages = [16,16]
    +Output: 2
    +Explanation: 2 people friend request each other.
     

    Example 2:

    -Input: [16,17,18]
    -Output: 2
    -Explanation: Friend requests are made 17 -> 16, 18 -> 17.
    +Input: ages = [16,17,18] +Output: 2 +Explanation: Friend requests are made 17 -> 16, 18 -> 17. +

    Example 3:

    -Input: [20,30,100,110,120]
    -Output: 3
    -Explanation: Friend requests are made 110 -> 100, 120 -> 110, 120 -> 100.
    +Input: ages = [20,30,100,110,120]
    +Output: 3
    +Explanation: Friend requests are made 110 -> 100, 120 -> 110, 120 -> 100.
     

     

    - -

    Notes:

    +

    Constraints:

      -
    • 1 <= ages.length <= 20000.
    • -
    • 1 <= ages[i] <= 120.
    • +
    • n == ages.length
    • +
    • 1 <= n <= 2 * 104
    • +
    • 1 <= ages[i] <= 120
    ### Related Topics diff --git a/problems/frog-jump/README.md b/problems/frog-jump/README.md index 1debc319b..210cdabc9 100644 --- a/problems/frog-jump/README.md +++ b/problems/frog-jump/README.md @@ -41,6 +41,7 @@
  • 2 <= stones.length <= 2000
  • 0 <= stones[i] <= 231 - 1
  • stones[0] == 0
  • +
  • stones is sorted in a strictly increasing order.
  • ### Related Topics diff --git a/problems/game-play-analysis-i/README.md b/problems/game-play-analysis-i/README.md index c2e5f6bc2..eaa4b32f3 100644 --- a/problems/game-play-analysis-i/README.md +++ b/problems/game-play-analysis-i/README.md @@ -11,7 +11,49 @@ ## [511. Game Play Analysis I (Easy)](https://leetcode.com/problems/game-play-analysis-i "游戏玩法分析 I") +

    Table: Activity

    +
    ++--------------+---------+
    +| Column Name  | Type    |
    ++--------------+---------+
    +| player_id    | int     |
    +| device_id    | int     |
    +| event_date   | date    |
    +| games_played | int     |
    ++--------------+---------+
    +(player_id, event_date) is the primary key of this table.
    +This table shows the activity of players of some game.
    +Each row is a record of a player who logged in and played a number of games (possibly 0) before logging out on some day using some device.
    +
    + +

     

    + +

    Write an SQL query that reports the first login date for each player.

    + +

    The query result format is in the following example:

    + +
    +Activity table:
    ++-----------+-----------+------------+--------------+
    +| player_id | device_id | event_date | games_played |
    ++-----------+-----------+------------+--------------+
    +| 1         | 2         | 2016-03-01 | 5            |
    +| 1         | 2         | 2016-05-02 | 6            |
    +| 2         | 3         | 2017-06-25 | 1            |
    +| 3         | 1         | 2016-03-02 | 0            |
    +| 3         | 4         | 2018-07-03 | 5            |
    ++-----------+-----------+------------+--------------+
    +
    +Result table:
    ++-----------+-------------+
    +| player_id | first_login |
    ++-----------+-------------+
    +| 1         | 2016-03-01  |
    +| 2         | 2017-06-25  |
    +| 3         | 2016-03-02  |
    ++-----------+-------------+
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/game-play-analysis-ii/README.md b/problems/game-play-analysis-ii/README.md index 95be22933..d71bce674 100644 --- a/problems/game-play-analysis-ii/README.md +++ b/problems/game-play-analysis-ii/README.md @@ -11,7 +11,48 @@ ## [512. Game Play Analysis II (Easy)](https://leetcode.com/problems/game-play-analysis-ii "游戏玩法分析 II") +

    Table: Activity

    +
    ++--------------+---------+
    +| Column Name  | Type    |
    ++--------------+---------+
    +| player_id    | int     |
    +| device_id    | int     |
    +| event_date   | date    |
    +| games_played | int     |
    ++--------------+---------+
    +(player_id, event_date) is the primary key of this table.
    +This table shows the activity of players of some game.
    +Each row is a record of a player who logged in and played a number of games (possibly 0) before logging out on some day using some device.
    +
    + +

     

    + +

    Write a SQL query that reports the device that is first logged in for each player.

    + +

    The query result format is in the following example:

    + +
    +Activity table:
    ++-----------+-----------+------------+--------------+
    +| player_id | device_id | event_date | games_played |
    ++-----------+-----------+------------+--------------+
    +| 1         | 2         | 2016-03-01 | 5            |
    +| 1         | 2         | 2016-05-02 | 6            |
    +| 2         | 3         | 2017-06-25 | 1            |
    +| 3         | 1         | 2016-03-02 | 0            |
    +| 3         | 4         | 2018-07-03 | 5            |
    ++-----------+-----------+------------+--------------+
    +
    +Result table:
    ++-----------+-----------+
    +| player_id | device_id |
    ++-----------+-----------+
    +| 1         | 2         |
    +| 2         | 3         |
    +| 3         | 1         |
    ++-----------+-----------+
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/game-play-analysis-iii/README.md b/problems/game-play-analysis-iii/README.md index 837877b2e..27f77f9b4 100644 --- a/problems/game-play-analysis-iii/README.md +++ b/problems/game-play-analysis-iii/README.md @@ -11,7 +11,54 @@ ## [534. Game Play Analysis III (Medium)](https://leetcode.com/problems/game-play-analysis-iii "游戏玩法分析 III") +

    Table: Activity

    +
    ++--------------+---------+
    +| Column Name  | Type    |
    ++--------------+---------+
    +| player_id    | int     |
    +| device_id    | int     |
    +| event_date   | date    |
    +| games_played | int     |
    ++--------------+---------+
    +(player_id, event_date) is the primary key of this table.
    +This table shows the activity of players of some game.
    +Each row is a record of a player who logged in and played a number of games (possibly 0) before logging out on some day using some device.
    +
    + +

     

    + +

    Write an SQL query that reports for each player and date, how many games played so far by the player. That is, the total number of games played by the player until that date. Check the example for clarity.

    + +

    The query result format is in the following example:

    + +
    +Activity table:
    ++-----------+-----------+------------+--------------+
    +| player_id | device_id | event_date | games_played |
    ++-----------+-----------+------------+--------------+
    +| 1         | 2         | 2016-03-01 | 5            |
    +| 1         | 2         | 2016-05-02 | 6            |
    +| 1         | 3         | 2017-06-25 | 1            |
    +| 3         | 1         | 2016-03-02 | 0            |
    +| 3         | 4         | 2018-07-03 | 5            |
    ++-----------+-----------+------------+--------------+
    +
    +Result table:
    ++-----------+------------+---------------------+
    +| player_id | event_date | games_played_so_far |
    ++-----------+------------+---------------------+
    +| 1         | 2016-03-01 | 5                   |
    +| 1         | 2016-05-02 | 11                  |
    +| 1         | 2017-06-25 | 12                  |
    +| 3         | 2016-03-02 | 0                   |
    +| 3         | 2018-07-03 | 5                   |
    ++-----------+------------+---------------------+
    +For the player with id 1, 5 + 6 = 11 games played by 2016-05-02, and 5 + 6 + 1 = 12 games played by 2017-06-25.
    +For the player with id 3, 0 + 5 = 5 games played by 2018-07-03.
    +Note that for each player we only care about the days when the player logged in.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/game-play-analysis-iv/README.md b/problems/game-play-analysis-iv/README.md index 21801972a..1dbcc4898 100644 --- a/problems/game-play-analysis-iv/README.md +++ b/problems/game-play-analysis-iv/README.md @@ -11,7 +11,48 @@ ## [550. Game Play Analysis IV (Medium)](https://leetcode.com/problems/game-play-analysis-iv "游戏玩法分析 IV") +

    Table: Activity

    +
    ++--------------+---------+
    +| Column Name  | Type    |
    ++--------------+---------+
    +| player_id    | int     |
    +| device_id    | int     |
    +| event_date   | date    |
    +| games_played | int     |
    ++--------------+---------+
    +(player_id, event_date) is the primary key of this table.
    +This table shows the activity of players of some game.
    +Each row is a record of a player who logged in and played a number of games (possibly 0) before logging out on some day using some device.
    +
    + +

     

    + +

    Write an SQL query that reports the fraction of players that logged in again on the day after the day they first logged in, rounded to 2 decimal places. In other words, you need to count the number of players that logged in for at least two consecutive days starting from their first login date, then divide that number by the total number of players.

    + +

    The query result format is in the following example:

    + +
    +Activity table:
    ++-----------+-----------+------------+--------------+
    +| player_id | device_id | event_date | games_played |
    ++-----------+-----------+------------+--------------+
    +| 1         | 2         | 2016-03-01 | 5            |
    +| 1         | 2         | 2016-03-02 | 6            |
    +| 2         | 3         | 2017-06-25 | 1            |
    +| 3         | 1         | 2016-03-02 | 0            |
    +| 3         | 4         | 2018-07-03 | 5            |
    ++-----------+-----------+------------+--------------+
    +
    +Result table:
    ++-----------+
    +| fraction  |
    ++-----------+
    +| 0.33      |
    ++-----------+
    +Only the player with id 1 logged back in after the first day he had logged in so the answer is 1/3 = 0.33
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/game-play-analysis-v/README.md b/problems/game-play-analysis-v/README.md index 720923be6..e1f8657bd 100644 --- a/problems/game-play-analysis-v/README.md +++ b/problems/game-play-analysis-v/README.md @@ -11,7 +11,54 @@ ## [1097. Game Play Analysis V (Hard)](https://leetcode.com/problems/game-play-analysis-v "游戏玩法分析 V") +

    Table: Activity

    +
    ++--------------+---------+
    +| Column Name  | Type    |
    ++--------------+---------+
    +| player_id    | int     |
    +| device_id    | int     |
    +| event_date   | date    |
    +| games_played | int     |
    ++--------------+---------+
    +(player_id, event_date) is the primary key of this table.
    +This table shows the activity of players of some game.
    +Each row is a record of a player who logged in and played a number of games (possibly 0) before logging out on some day using some device.
    +
    + +

     

    + +

    We define the install date of a player to be the first login day of that player.

    + +

    We also define day 1 retention of some date X to be the number of players whose install date is X and they logged back in on the day right after X, divided by the number of players whose install date is X, rounded to 2 decimal places.

    + +

    Write an SQL query that reports for each install date, the number of players that installed the game on that day and the day 1 retention.

    + +

    The query result format is in the following example:

    + +
    +Activity table:
    ++-----------+-----------+------------+--------------+
    +| player_id | device_id | event_date | games_played |
    ++-----------+-----------+------------+--------------+
    +| 1         | 2         | 2016-03-01 | 5            |
    +| 1         | 2         | 2016-03-02 | 6            |
    +| 2         | 3         | 2017-06-25 | 1            |
    +| 3         | 1         | 2016-03-01 | 0            |
    +| 3         | 4         | 2016-07-03 | 5            |
    ++-----------+-----------+------------+--------------+
    +
    +Result table:
    ++------------+----------+----------------+
    +| install_dt | installs | Day1_retention |
    ++------------+----------+----------------+
    +| 2016-03-01 | 2        | 0.50           |
    +| 2017-06-25 | 1        | 0.00           |
    ++------------+----------+----------------+
    +Player 1 and 3 installed the game on 2016-03-01 but only player 1 logged back in on 2016-03-02 so the day 1 retention of 2016-03-01 is 1 / 2 = 0.50
    +Player 2 installed the game on 2017-06-25 but didn't log back in on 2017-06-26 so the day 1 retention of 2017-06-25 is 0 / 1 = 0.00
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/generalized-abbreviation/README.md b/problems/generalized-abbreviation/README.md index 142fbcdfd..3111ba7a4 100644 --- a/problems/generalized-abbreviation/README.md +++ b/problems/generalized-abbreviation/README.md @@ -11,7 +11,19 @@ ## [320. Generalized Abbreviation (Medium)](https://leetcode.com/problems/generalized-abbreviation "列举单词的全部缩写") +

    Write a function to generate the generalized abbreviations of a word. 

    +

    Note: The order of the output does not matter.

    + +

    Example:

    + +
    +Input: "word"
    +Output:
    +["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"]
    +
    + +

     

    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/get-highest-answer-rate-question/README.md b/problems/get-highest-answer-rate-question/README.md index 2a605e8bf..6da9aabb9 100644 --- a/problems/get-highest-answer-rate-question/README.md +++ b/problems/get-highest-answer-rate-question/README.md @@ -11,7 +11,36 @@ ## [578. Get Highest Answer Rate Question (Medium)](https://leetcode.com/problems/get-highest-answer-rate-question "查询回答率最高的问题") - +

    Get the highest answer rate question from a table survey_log with these columns: uid, action, question_id, answer_id, q_num, timestamp.

    + +

    uid means user id; action has these kind of values: "show", "answer", "skip"; answer_id is not null when action column is "answer", while is null for "show" and "skip"; q_num is the numeral order of the question in current session.

    + +

    Write a sql query to identify the question which has the highest answer rate.

    + +

    Example:

    + +
    Input:
    ++------+-----------+--------------+------------+-----------+------------+
    +| uid  | action    | question_id  | answer_id  | q_num     | timestamp  |
    ++------+-----------+--------------+------------+-----------+------------+
    +| 5    | show      | 285          | null       | 1         | 123        |
    +| 5    | answer    | 285          | 124124     | 1         | 124        |
    +| 5    | show      | 369          | null       | 2         | 125        |
    +| 5    | skip      | 369          | null       | 2         | 126        |
    ++------+-----------+--------------+------------+-----------+------------+
    +Output:
    ++-------------+
    +| survey_log  |
    ++-------------+
    +|    285      |
    ++-------------+
    +Explanation:
    +question 285 has answer rate 1/1, while question 369 has 0/1 answer rate, so output 285.
    +
    + +

     

    + +

    Note: The highest answer rate meaning is: answer number's ratio in show number in the same question.

    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/get-the-second-most-recent-activity/README.md b/problems/get-the-second-most-recent-activity/README.md index 5e4a07ea4..11682b2cc 100644 --- a/problems/get-the-second-most-recent-activity/README.md +++ b/problems/get-the-second-most-recent-activity/README.md @@ -11,7 +11,51 @@ ## [1369. Get the Second Most Recent Activity (Hard)](https://leetcode.com/problems/get-the-second-most-recent-activity "获取最近第二次的活动") +SQL Schema +

    Table: UserActivity

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| username      | varchar |
    +| activity      | varchar |
    +| startDate     | Date    |
    +| endDate       | Date    |
    ++---------------+---------+
    +This table does not contain primary key.
    +This table contain information about the activity performed of each user in a period of time.
    +A person with username performed a activity from startDate to endDate.
    +
    +Write an SQL query to show the second most recent activity of each user. + +If the user only has one activity, return that one. + +A user can't perform more than one activity at the same time. Return the result table in any order. + +The query result format is in the following example: +
    +UserActivity table:
    ++------------+--------------+-------------+-------------+
    +| username   | activity     | startDate   | endDate     |
    ++------------+--------------+-------------+-------------+
    +| Alice      | Travel       | 2020-02-12  | 2020-02-20  |
    +| Alice      | Dancing      | 2020-02-21  | 2020-02-23  |
    +| Alice      | Travel       | 2020-02-24  | 2020-02-28  |
    +| Bob        | Travel       | 2020-02-11  | 2020-02-18  |
    ++------------+--------------+-------------+-------------+
    +
    +Result table:
    ++------------+--------------+-------------+-------------+
    +| username   | activity     | startDate   | endDate     |
    ++------------+--------------+-------------+-------------+
    +| Alice      | Dancing      | 2020-02-21  | 2020-02-23  |
    +| Bob        | Travel       | 2020-02-11  | 2020-02-18  |
    ++------------+--------------+-------------+-------------+
    +
    +The most recent activity of Alice is Travel from 2020-02-24 to 2020-02-28, before that she was dancing from 2020-02-21 to 2020-02-23.
    +Bob only has one record, we just take that one.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/goat-latin/README.md b/problems/goat-latin/README.md index a3d5b9389..01ab02553 100644 --- a/problems/goat-latin/README.md +++ b/problems/goat-latin/README.md @@ -11,48 +11,46 @@ ## [824. Goat Latin (Easy)](https://leetcode.com/problems/goat-latin "山羊拉丁文") -

    A sentence sentence is given, composed of words separated by spaces. Each word consists of lowercase and uppercase letters only.

    +

    You are given a string sentence that consist of words separated by spaces. Each word consists of lowercase and uppercase letters only.

    -

    We would like to convert the sentence to "Goat Latin" (a made-up language similar to Pig Latin.)

    - -

    The rules of Goat Latin are as follows:

    +

    We would like to convert the sentence to "Goat Latin" (a made-up language similar to Pig Latin.) The rules of Goat Latin are as follows:

      -
    • If a word begins with a vowel (a, e, i, o, or u), append "ma" to the end of the word.
      - For example, the word 'apple' becomes 'applema'.
      -  
    • -
    • If a word begins with a consonant (i.e. not a vowel), remove the first letter and append it to the end, then add "ma".
      - For example, the word "goat" becomes "oatgma".
      -  
    • -
    • Add one letter 'a' to the end of each word per its word index in the sentence, starting with 1.
      - For example, the first word gets "a" added to the end, the second word gets "aa" added to the end and so on.
    • +
    • If a word begins with a vowel ('a', 'e', 'i', 'o', or 'u'), append "ma" to the end of the word. +
        +
      • For example, the word "apple" becomes "applema".
      • +
      +
    • +
    • If a word begins with a consonant (i.e., not a vowel), remove the first letter and append it to the end, then add "ma". +
        +
      • For example, the word "goat" becomes "oatgma".
      • +
      +
    • +
    • Add one letter 'a' to the end of each word per its word index in the sentence, starting with 1. +
        +
      • For example, the first word gets "a" added to the end, the second word gets "aa" added to the end, and so on.
      • +
      +
    -

    Return the final sentence representing the conversion from sentence to Goat Latin. 

    +

    Return the final sentence representing the conversion from sentence to Goat Latin.

     

    -

    Example 1:

    - -
    -Input: sentence = "I speak Goat Latin"
    -Output: "Imaa peaksmaaa oatGmaaaa atinLmaaaaa"
    -
    - -

    Example 2:

    - -
    -Input: sentence = "The quick brown fox jumped over the lazy dog"
    -Output: "heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpedjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa"
    +
    Input: sentence = "I speak Goat Latin"
    +Output: "Imaa peaksmaaa oatGmaaaa atinLmaaaaa"
    +

    Example 2:

    +
    Input: sentence = "The quick brown fox jumped over the lazy dog"
    +Output: "heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpedjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa"
     
    -

     

    - -

    Notes:

    +

    Constraints:

      -
    • sentence contains only uppercase, lowercase and spaces. Exactly one space between each word.
    • -
    • 1 <= sentence.length <= 150.
    • +
    • 1 <= sentence.length <= 150
    • +
    • sentence consists of English letters and spaces.
    • +
    • sentence has no leading or trailing spaces.
    • +
    • All the words in sentence are separated by a single space.
    ### Related Topics diff --git a/problems/graph-valid-tree/README.md b/problems/graph-valid-tree/README.md index 0d597d720..1613d7917 100644 --- a/problems/graph-valid-tree/README.md +++ b/problems/graph-valid-tree/README.md @@ -11,7 +11,21 @@ ## [261. Graph Valid Tree (Medium)](https://leetcode.com/problems/graph-valid-tree "以图判树") +

    Given n nodes labeled from 0 to n-1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree.

    +

    Example 1:

    + +
    +Input: n = 5, and edges = [[0,1], [0,2], [0,3], [1,4]]
    +Output: true
    + +

    Example 2:

    + +
    +Input: n = 5, and edges = [[0,1], [1,2], [2,3], [1,3], [1,4]]
    +Output: false
    + +

    Note: you can assume that no duplicate edges will appear in edges. Since all edges are undirected, [0,1] is the same as [1,0] and thus will not appear together in edges.

    ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/group-shifted-strings/README.md b/problems/group-shifted-strings/README.md index 686e7ed28..93d32366f 100644 --- a/problems/group-shifted-strings/README.md +++ b/problems/group-shifted-strings/README.md @@ -11,7 +11,25 @@ ## [249. Group Shifted Strings (Medium)](https://leetcode.com/problems/group-shifted-strings "移位字符串分组") +

    Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequence:

    +
    +"abc" -> "bcd" -> ... -> "xyz"
    + +

    Given a list of strings which contains only lowercase alphabets, group all strings that belong to the same shifting sequence.

    + +

    Example:

    + +
    +Input: ["abc", "bcd", "acef", "xyz", "az", "ba", "a", "z"],
    +Output: 
    +[
    +  ["abc","bcd","xyz"],
    +  ["az","ba"],
    +  ["acef"],
    +  ["a","z"]
    +]
    +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/groups-of-special-equivalent-strings/README.md b/problems/groups-of-special-equivalent-strings/README.md index c017096d3..e4a7bbf4f 100644 --- a/problems/groups-of-special-equivalent-strings/README.md +++ b/problems/groups-of-special-equivalent-strings/README.md @@ -9,66 +9,55 @@                  [Next >](../all-possible-full-binary-trees "All Possible Full Binary Trees") -## [893. Groups of Special-Equivalent Strings (Easy)](https://leetcode.com/problems/groups-of-special-equivalent-strings "特殊等价字符串组") +## [893. Groups of Special-Equivalent Strings (Medium)](https://leetcode.com/problems/groups-of-special-equivalent-strings "特殊等价字符串组") -

    You are given an array words of strings.

    +

    You are given an array of strings of the same length words.

    -

    A move onto s consists of swapping any two even indexed characters of s, or any two odd indexed characters of s.

    +

    In one move, you can swap any two even indexed characters or any two odd indexed characters of a string words[i].

    -

    Two strings s and t are special-equivalent if after any number of moves onto s, s == t.

    +

    Two strings words[i] and words[j] are special-equivalent if after any number of moves, words[i] == words[j].

    -

    For example, s = "zzxy" and t = "xyzz" are special-equivalent because we may make the moves "zzxy" -> "xzzy" -> "xyzz" that swap s[0] and s[2], then s[1] and s[3].

    - -

    Now, a group of special-equivalent strings from words is a non-empty subset of words such that:

    +
      +
    • For example, words[i] = "zzxy" and words[j] = "xyzz" are special-equivalent because we may make the moves "zzxy" -> "xzzy" -> "xyzz".
    • +
    -
      -
    1. Every pair of strings in the group are special equivalent, and;
    2. -
    3. The group is the largest size possible (ie., there isn't a string s not in the group such that s is special equivalent to every string in the group)
    4. -
    +

    A group of special-equivalent strings from words is a non-empty subset of words such that:

    -

    Return the number of groups of special-equivalent strings from words.

    +
      +
    • Every pair of strings in the group are special equivalent, and
    • +
    • The group is the largest size possible (i.e., there is not a string words[i] not in the group such that words[i] is special-equivalent to every string in the group).
    • +
    -
     
    +

    Return the number of groups of special-equivalent strings from words.

    -
    +

     

    Example 1:

    -Input: words = ["abcd","cdab","cbad","xyzz","zzxy","zzyx"]
    -Output: 3
    -Explanation: 
    -One group is ["abcd", "cdab", "cbad"], since they are all pairwise special equivalent, and none of the other strings are all pairwise special equivalent to these.
    -
    -The other two groups are ["xyzz", "zzxy"] and ["zzyx"].  Note that in particular, "zzxy" is not special equivalent to "zzyx".
    +Input: words = ["abcd","cdab","cbad","xyzz","zzxy","zzyx"]
    +Output: 3
    +Explanation: 
    +One group is ["abcd", "cdab", "cbad"], since they are all pairwise special equivalent, and none of the other strings is all pairwise special equivalent to these.
    +The other two groups are ["xyzz", "zzxy"] and ["zzyx"].
    +Note that in particular, "zzxy" is not special equivalent to "zzyx".
     
    -

    Example 2:

    -Input: words = ["abc","acb","bac","bca","cab","cba"]
    -Output: 3
    +Input: words = ["abc","acb","bac","bca","cab","cba"] +Output: 3 +

     

    -
    - - -
    -
    -
    -
    -

    Note:

    +

    Constraints:

    • 1 <= words.length <= 1000
    • 1 <= words[i].length <= 20
    • -
    • All words[i] have the same length.
    • -
    • All words[i] consist of only lowercase letters.
    • +
    • words[i] consist of lowercase English letters.
    • +
    • All the strings are of the same length.
    -
    -
    -
    -
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/hand-of-straights/README.md b/problems/hand-of-straights/README.md index 68e245c5a..cfe25d437 100644 --- a/problems/hand-of-straights/README.md +++ b/problems/hand-of-straights/README.md @@ -11,13 +11,9 @@ ## [846. Hand of Straights (Medium)](https://leetcode.com/problems/hand-of-straights "一手顺子") -

    Alice has a hand of cards, given as an array of integers.

    +

    Alice has some number of cards and she wants to rearrange the cards into groups so that each group is of size groupSize, and consists of groupSize consecutive cards.

    -

    Now she wants to rearrange the cards into groups so that each group is size groupSize, and consists of groupSize consecutive cards.

    - -

    Return true if and only if she can.

    - -

    Note: This question is the same as 1296: https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/

    +

    Given an integer array hand where hand[i] is the value written on the ith card and an integer groupSize, return true if she can rearrange the cards, or false otherwise.

     

    Example 1:

    @@ -33,7 +29,7 @@
     Input: hand = [1,2,3,4,5], groupSize = 4
     Output: false
    -Explanation: Alice's hand can't be rearranged into groups of 4.
    +Explanation: Alice's hand can not be rearranged into groups of 4.
     
     
    @@ -41,11 +37,14 @@

    Constraints:

      -
    • 1 <= hand.length <= 10000
    • -
    • 0 <= hand[i] <= 109
    • +
    • 1 <= hand.length <= 104
    • +
    • 0 <= hand[i] <= 109
    • 1 <= groupSize <= hand.length
    +

     

    +

    Note: This question is the same as 1296: https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/

    + ### Related Topics [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] diff --git a/problems/handshakes-that-dont-cross/README.md b/problems/handshakes-that-dont-cross/README.md index 18045f577..3817221f4 100644 --- a/problems/handshakes-that-dont-cross/README.md +++ b/problems/handshakes-that-dont-cross/README.md @@ -11,7 +11,53 @@ ## [1259. Handshakes That Don't Cross (Hard)](https://leetcode.com/problems/handshakes-that-dont-cross "不相交的握手") +

    You are given an even number of people num_people that stand around a circle and each person shakes hands with someone else, so that there are num_people / 2 handshakes total.

    +

    Return the number of ways these handshakes could occur such that none of the handshakes cross.

    + +

    Since this number could be very big, return the answer mod 10^9 + 7

    + +

     

    +

    Example 1:

    + +
    +Input: num_people = 2
    +Output: 1
    +
    + +

    Example 2:

    + +

    + +
    +Input: num_people = 4
    +Output: 2
    +Explanation: There are two ways to do it, the first way is [(1,2),(3,4)] and the second one is [(2,3),(4,1)].
    +
    + +

    Example 3:

    + +

    + +
    +Input: num_people = 6
    +Output: 5
    +
    + +

    Example 4:

    + +
    +Input: num_people = 8
    +Output: 14
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= num_people <= 1000
    • +
    • num_people % 2 == 0
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/hexspeak/README.md b/problems/hexspeak/README.md index b9aaa6089..9813d663b 100644 --- a/problems/hexspeak/README.md +++ b/problems/hexspeak/README.md @@ -11,7 +11,34 @@ ## [1271. Hexspeak (Easy)](https://leetcode.com/problems/hexspeak "十六进制魔术数字") +

    A decimal number can be converted to its Hexspeak representation by first converting it to an uppercase hexadecimal string, then replacing all occurrences of the digit 0 with the letter O, and the digit 1 with the letter I.  Such a representation is valid if and only if it consists only of the letters in the set {"A", "B", "C", "D", "E", "F", "I", "O"}.

    +

    Given a string num representing a decimal integer N, return the Hexspeak representation of N if it is valid, otherwise return "ERROR".

    + +

     

    +

    Example 1:

    + +
    +Input: num = "257"
    +Output: "IOI"
    +Explanation:  257 is 101 in hexadecimal.
    +
    + +

    Example 2:

    + +
    +Input: num = "3"
    +Output: "ERROR"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= N <= 10^12
    • +
    • There are no leading zeros in the given string.
    • +
    • All answers must be in uppercase letters.
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/high-five/README.md b/problems/high-five/README.md index fb1bf84cc..87d79b579 100644 --- a/problems/high-five/README.md +++ b/problems/high-five/README.md @@ -11,7 +11,33 @@ ## [1086. High Five (Easy)](https://leetcode.com/problems/high-five "前五科的均分") +

    Given a list of scores of different students, return the average score of each student's top five scores in the order of each student's id.

    +

    Each entry items[i] has items[i][0] the student's id, and items[i][1] the student's score.  The average score is calculated using integer division.

    + +

     

    + +

    Example 1:

    + +
    +Input: [[1,91],[1,92],[2,93],[2,97],[1,60],[2,77],[1,65],[1,87],[1,100],[2,100],[2,76]]
    +Output: [[1,87],[2,88]]
    +Explanation: 
    +The average of the student with id = 1 is 87.
    +The average of the student with id = 2 is 88.6. But with integer division their average converts to 88.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= items.length <= 1000
    2. +
    3. items[i].length == 2
    4. +
    5. The IDs of the students is between 1 to 1000
    6. +
    7. The score of the students is between 1 to 100
    8. +
    9. For each student, there are at least 5 scores
    10. +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/highest-grade-for-each-student/README.md b/problems/highest-grade-for-each-student/README.md index c92959f85..69c705d34 100644 --- a/problems/highest-grade-for-each-student/README.md +++ b/problems/highest-grade-for-each-student/README.md @@ -11,7 +11,47 @@ ## [1112. Highest Grade For Each Student (Medium)](https://leetcode.com/problems/highest-grade-for-each-student "每位学生的最高成绩") +

    Table: Enrollments

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| student_id    | int     |
    +| course_id     | int     |
    +| grade         | int     |
    ++---------------+---------+
    +(student_id, course_id) is the primary key of this table.
    +
    +
    + +

    Write a SQL query to find the highest grade with its corresponding course for each student. In case of a tie, you should find the course with the smallest course_id. The output must be sorted by increasing student_id.

    + +

    The query result format is in the following example:

    + +
    +Enrollments table:
    ++------------+-------------------+
    +| student_id | course_id | grade |
    ++------------+-----------+-------+
    +| 2          | 2         | 95    |
    +| 2          | 3         | 95    |
    +| 1          | 1         | 90    |
    +| 1          | 2         | 99    |
    +| 3          | 1         | 80    |
    +| 3          | 2         | 75    |
    +| 3          | 3         | 82    |
    ++------------+-----------+-------+
    +
    +Result table:
    ++------------+-------------------+
    +| student_id | course_id | grade |
    ++------------+-----------+-------+
    +| 1          | 2         | 99    |
    +| 2          | 2         | 95    |
    +| 3          | 3         | 82    |
    ++------------+-----------+-------+
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/how-many-apples-can-you-put-into-the-basket/README.md b/problems/how-many-apples-can-you-put-into-the-basket/README.md index a66ee896e..81d680a95 100644 --- a/problems/how-many-apples-can-you-put-into-the-basket/README.md +++ b/problems/how-many-apples-can-you-put-into-the-basket/README.md @@ -11,7 +11,34 @@ ## [1196. How Many Apples Can You Put into the Basket (Easy)](https://leetcode.com/problems/how-many-apples-can-you-put-into-the-basket "最多可以买到的苹果数量") +

    You have some apples, where arr[i] is the weight of the i-th apple.  You also have a basket that can carry up to 5000 units of weight.

    +

    Return the maximum number of apples you can put in the basket.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [100,200,150,1000]
    +Output: 4
    +Explanation: All 4 apples can be carried by the basket since their sum of weights is 1450.
    +
    + +

    Example 2:

    + +
    +Input: arr = [900,950,800,1000,700,800]
    +Output: 5
    +Explanation: The sum of weights of the 6 apples exceeds 5000 so we choose any 5 of them.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 10^3
    • +
    • 1 <= arr[i] <= 10^3
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/immediate-food-delivery-i/README.md b/problems/immediate-food-delivery-i/README.md index e6e8a4d3b..857bf4d63 100644 --- a/problems/immediate-food-delivery-i/README.md +++ b/problems/immediate-food-delivery-i/README.md @@ -11,7 +11,50 @@ ## [1173. Immediate Food Delivery I (Easy)](https://leetcode.com/problems/immediate-food-delivery-i "即时食物配送 I") +

    Table: Delivery

    +
    ++-----------------------------+---------+
    +| Column Name                 | Type    |
    ++-----------------------------+---------+
    +| delivery_id                 | int     |
    +| customer_id                 | int     |
    +| order_date                  | date    |
    +| customer_pref_delivery_date | date    |
    ++-----------------------------+---------+
    +delivery_id is the primary key of this table.
    +The table holds information about food delivery to customers that make orders at some date and specify a preferred delivery date (on the same order date or after it).
    +
    + +

     

    + +

    If the preferred delivery date of the customer is the same as the order date then the order is called immediate otherwise it's called scheduled.

    + +

    Write an SQL query to find the percentage of immediate orders in the table, rounded to 2 decimal places.

    + +

    The query result format is in the following example:

    + +
    +Delivery table:
    ++-------------+-------------+------------+-----------------------------+
    +| delivery_id | customer_id | order_date | customer_pref_delivery_date |
    ++-------------+-------------+------------+-----------------------------+
    +| 1           | 1           | 2019-08-01 | 2019-08-02                  |
    +| 2           | 5           | 2019-08-02 | 2019-08-02                  |
    +| 3           | 1           | 2019-08-11 | 2019-08-11                  |
    +| 4           | 3           | 2019-08-24 | 2019-08-26                  |
    +| 5           | 4           | 2019-08-21 | 2019-08-22                  |
    +| 6           | 2           | 2019-08-11 | 2019-08-13                  |
    ++-------------+-------------+------------+-----------------------------+
    +
    +Result table:
    ++----------------------+
    +| immediate_percentage |
    ++----------------------+
    +| 33.33                |
    ++----------------------+
    +The orders with delivery id 2 and 3 are immediate while the others are scheduled.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/immediate-food-delivery-ii/README.md b/problems/immediate-food-delivery-ii/README.md index f455cf19e..65fcea5cf 100644 --- a/problems/immediate-food-delivery-ii/README.md +++ b/problems/immediate-food-delivery-ii/README.md @@ -11,7 +11,57 @@ ## [1174. Immediate Food Delivery II (Medium)](https://leetcode.com/problems/immediate-food-delivery-ii "即时食物配送 II") +

    Table: Delivery

    +
    ++-----------------------------+---------+
    +| Column Name                 | Type    |
    ++-----------------------------+---------+
    +| delivery_id                 | int     |
    +| customer_id                 | int     |
    +| order_date                  | date    |
    +| customer_pref_delivery_date | date    |
    ++-----------------------------+---------+
    +delivery_id is the primary key of this table.
    +The table holds information about food delivery to customers that make orders at some date and specify a preferred delivery date (on the same order date or after it).
    +
    + +

     

    + +

    If the preferred delivery date of the customer is the same as the order date then the order is called immediate otherwise it's called scheduled.

    + +

    The first order of a customer is the order with the earliest order date that customer made. It is guaranteed that a customer has exactly one first order.

    + +

    Write an SQL query to find the percentage of immediate orders in the first orders of all customers, rounded to 2 decimal places.

    + +

    The query result format is in the following example:

    + +
    +Delivery table:
    ++-------------+-------------+------------+-----------------------------+
    +| delivery_id | customer_id | order_date | customer_pref_delivery_date |
    ++-------------+-------------+------------+-----------------------------+
    +| 1           | 1           | 2019-08-01 | 2019-08-02                  |
    +| 2           | 2           | 2019-08-02 | 2019-08-02                  |
    +| 3           | 1           | 2019-08-11 | 2019-08-12                  |
    +| 4           | 3           | 2019-08-24 | 2019-08-24                  |
    +| 5           | 3           | 2019-08-21 | 2019-08-22                  |
    +| 6           | 2           | 2019-08-11 | 2019-08-13                  |
    +| 7           | 4           | 2019-08-09 | 2019-08-09                  |
    ++-------------+-------------+------------+-----------------------------+
    +
    +Result table:
    ++----------------------+
    +| immediate_percentage |
    ++----------------------+
    +| 50.00                |
    ++----------------------+
    +The customer id 1 has a first order with delivery id 1 and it is scheduled.
    +The customer id 2 has a first order with delivery id 2 and it is immediate.
    +The customer id 3 has a first order with delivery id 5 and it is scheduled.
    +The customer id 4 has a first order with delivery id 7 and it is immediate.
    +Hence, half the customers have immediate first orders.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/index-pairs-of-a-string/README.md b/problems/index-pairs-of-a-string/README.md index 7f4c1ee64..bf0d3c379 100644 --- a/problems/index-pairs-of-a-string/README.md +++ b/problems/index-pairs-of-a-string/README.md @@ -11,7 +11,38 @@ ## [1065. Index Pairs of a String (Easy)](https://leetcode.com/problems/index-pairs-of-a-string "字符串的索引对") +

    Given a text string and words (a list of strings), return all index pairs [i, j] so that the substring text[i]...text[j] is in the list of words.

    +

     

    + +

    Example 1:

    + +
    +Input: text = "thestoryofleetcodeandme", words = ["story","fleet","leetcode"]
    +Output: [[3,7],[9,13],[10,17]]
    +
    + +

    Example 2:

    + +
    +Input: text = "ababa", words = ["aba","ab"]
    +Output: [[0,1],[0,2],[2,3],[2,4]]
    +Explanation: 
    +Notice that matches can overlap, see "aba" is found in [0,2] and [2,4].
    +
    + +

     

    + +

    Note:

    + +
      +
    1. All strings contains only lowercase English letters.
    2. +
    3. It's guaranteed that all strings in words are different.
    4. +
    5. 1 <= text.length <= 100
    6. +
    7. 1 <= words.length <= 20
    8. +
    9. 1 <= words[i].length <= 50
    10. +
    11. Return the pairs [i,j] in sorted order (i.e. sort them by their first coordinate in case of ties sort them by their second coordinate).
    12. +
    ### Related Topics [[Trie](../../tag/trie/README.md)] diff --git a/problems/inorder-successor-in-bst-ii/README.md b/problems/inorder-successor-in-bst-ii/README.md index b99a07000..3a0d8f6d5 100644 --- a/problems/inorder-successor-in-bst-ii/README.md +++ b/problems/inorder-successor-in-bst-ii/README.md @@ -11,7 +11,67 @@ ## [510. Inorder Successor in BST II (Medium)](https://leetcode.com/problems/inorder-successor-in-bst-ii "二叉搜索树中的中序后继 II") +

    Given a binary search tree and a node in it, find the in-order successor of that node in the BST.

    +

    The successor of a node p is the node with the smallest key greater than p.val.

    + +

    You will have direct access to the node but not to the root of the tree. Each node will have a reference to its parent node.

    + +

     

    + +

    Example 1:

    + +
    +Input: 
    +root = {"$id":"1","left":{"$id":"2","left":null,"parent":{"$ref":"1"},"right":null,"val":1},"parent":null,"right":{"$id":"3","left":null,"parent":{"$ref":"1"},"right":null,"val":3},"val":2}
    +p = 1
    +Output: 2
    +Explanation: 1's in-order successor node is 2. Note that both p and the return value is of Node type.
    +
    + +

    Example 2:

    + +
    +Input: 
    +root = {"$id":"1","left":{"$id":"2","left":{"$id":"3","left":{"$id":"4","left":null,"parent":{"$ref":"3"},"right":null,"val":1},"parent":{"$ref":"2"},"right":null,"val":2},"parent":{"$ref":"1"},"right":{"$id":"5","left":null,"parent":{"$ref":"2"},"right":null,"val":4},"val":3},"parent":null,"right":{"$id":"6","left":null,"parent":{"$ref":"1"},"right":null,"val":6},"val":5}
    +p = 6
    +Output: null
    +Explanation: There is no in-order successor of the current node, so the answer is null.
    +
    + +

    Example 3:

    + +
    +Input: 
    +root = {"$id":"1","left":{"$id":"2","left":{"$id":"3","left":{"$id":"4","left":null,"parent":{"$ref":"3"},"right":null,"val":2},"parent":{"$ref":"2"},"right":{"$id":"5","left":null,"parent":{"$ref":"3"},"right":null,"val":4},"val":3},"parent":{"$ref":"1"},"right":{"$id":"6","left":null,"parent":{"$ref":"2"},"right":{"$id":"7","left":{"$id":"8","left":null,"parent":{"$ref":"7"},"right":null,"val":9},"parent":{"$ref":"6"},"right":null,"val":13},"val":7},"val":6},"parent":null,"right":{"$id":"9","left":{"$id":"10","left":null,"parent":{"$ref":"9"},"right":null,"val":17},"parent":{"$ref":"1"},"right":{"$id":"11","left":null,"parent":{"$ref":"9"},"right":null,"val":20},"val":18},"val":15}
    +p = 15
    +Output: 17
    +
    + +

    Example 4:

    + +
    +Input: 
    +root = {"$id":"1","left":{"$id":"2","left":{"$id":"3","left":{"$id":"4","left":null,"parent":{"$ref":"3"},"right":null,"val":2},"parent":{"$ref":"2"},"right":{"$id":"5","left":null,"parent":{"$ref":"3"},"right":null,"val":4},"val":3},"parent":{"$ref":"1"},"right":{"$id":"6","left":null,"parent":{"$ref":"2"},"right":{"$id":"7","left":{"$id":"8","left":null,"parent":{"$ref":"7"},"right":null,"val":9},"parent":{"$ref":"6"},"right":null,"val":13},"val":7},"val":6},"parent":null,"right":{"$id":"9","left":{"$id":"10","left":null,"parent":{"$ref":"9"},"right":null,"val":17},"parent":{"$ref":"1"},"right":{"$id":"11","left":null,"parent":{"$ref":"9"},"right":null,"val":20},"val":18},"val":15}
    +p = 13
    +Output: 15
    +
    + +

     

    + +

    Note:

    + +
      +
    1. If the given node has no in-order successor in the tree, return null.
    2. +
    3. It's guaranteed that the values of the tree are unique.
    4. +
    5. Remember that we are using the Node type instead of TreeNode type so their string representation are different.
    6. +
    + +

     

    + +

    Follow up:

    + +

    Could you solve it without looking up any of the node's values?

    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/inorder-successor-in-bst/README.md b/problems/inorder-successor-in-bst/README.md index a887f7f83..53a67debc 100644 --- a/problems/inorder-successor-in-bst/README.md +++ b/problems/inorder-successor-in-bst/README.md @@ -11,7 +11,34 @@ ## [285. Inorder Successor in BST (Medium)](https://leetcode.com/problems/inorder-successor-in-bst "二叉搜索树中的中序后继") +

    Given a binary search tree and a node in it, find the in-order successor of that node in the BST.

    +

    The successor of a node p is the node with the smallest key greater than p.val.

    + +

     

    + +

    Example 1:

    + +
    Input: root = [2,1,3], p = 1
    +Output: 2
    +Explanation: 1's in-order successor node is 2. Note that both p and the return value is of TreeNode type.
    +
    + +

    Example 2:

    + +
    Input: root = [5,3,6,2,4,null,null,1], p = 6
    +Output: null
    +Explanation: There is no in-order successor of the current node, so the answer is null.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. If the given node has no in-order successor in the tree, return null.
    2. +
    3. It's guaranteed that the values of the tree are unique.
    4. +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/insert-into-a-sorted-circular-linked-list/README.md b/problems/insert-into-a-sorted-circular-linked-list/README.md index cedb2874d..d1c4bc30b 100644 --- a/problems/insert-into-a-sorted-circular-linked-list/README.md +++ b/problems/insert-into-a-sorted-circular-linked-list/README.md @@ -11,7 +11,25 @@ ## [708. Insert into a Sorted Circular Linked List (Medium)](https://leetcode.com/problems/insert-into-a-sorted-circular-linked-list "循环有序列表的插入") +

    Given a node from a cyclic linked list which is sorted in ascending order, write a function to insert a value into the list such that it remains a cyclic sorted list. The given node can be a reference to any single node in the list, and may not be necessarily the smallest value in the cyclic list.

    +

    If there are multiple suitable places for insertion, you may choose any place to insert the new value. After the insertion, the cyclic list should remain sorted.

    + +

    If the list is empty (i.e., given node is null), you should create a new single cyclic list and return the reference to that single node. Otherwise, you should return the original given node.

    + +

    The following example may help you understand the problem better:

    + +

     

    + +


    +
    +In the figure above, there is a cyclic sorted list of three elements. You are given a reference to the node with value 3, and we need to insert 2 into the list.

    + +

     

    + +


    +
    +The new node should insert between node 1 and node 3. After the insertion, the list should look like this, and we should still return node 3.

    ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/intersection-of-three-sorted-arrays/README.md b/problems/intersection-of-three-sorted-arrays/README.md index 7bb10c5b9..5f337a0ef 100644 --- a/problems/intersection-of-three-sorted-arrays/README.md +++ b/problems/intersection-of-three-sorted-arrays/README.md @@ -11,7 +11,24 @@ ## [1213. Intersection of Three Sorted Arrays (Easy)](https://leetcode.com/problems/intersection-of-three-sorted-arrays "三个有序数组的交集") +

    Given three integer arrays arr1, arr2 and arr3 sorted in strictly increasing order, return a sorted array of only the integers that appeared in all three arrays.

    +

     

    +

    Example 1:

    + +
    +Input: arr1 = [1,2,3,4,5], arr2 = [1,2,5,7,9], arr3 = [1,3,4,5,8]
    +Output: [1,5]
    +Explanation: Only 1 and 5 appeared in the three arrays.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr1.length, arr2.length, arr3.length <= 1000
    • +
    • 1 <= arr1[i], arr2[i], arr3[i] <= 2000
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/intersection-of-two-linked-lists/README.md b/problems/intersection-of-two-linked-lists/README.md index d4b432ee3..94fff5675 100644 --- a/problems/intersection-of-two-linked-lists/README.md +++ b/problems/intersection-of-two-linked-lists/README.md @@ -15,13 +15,27 @@

    For example, the following two linked lists begin to intersect at node c1:

    -

    It is guaranteed that there are no cycles anywhere in the entire linked structure.

    +

    The test cases are generated such that there are no cycles anywhere in the entire linked structure.

    Note that the linked lists must retain their original structure after the function returns.

    +

    Custom Judge:

    + +

    The inputs to the judge are given as follows (your program is not given these inputs):

    + +
      +
    • intersectVal - The value of the node where the intersection occurs. This is 0 if there is no intersected node.
    • +
    • listA - The first linked list.
    • +
    • listB - The second linked list.
    • +
    • skipA - The number of nodes to skip ahead in listA (starting from the head) to get to the intersected node.
    • +
    • skipB - The number of nodes to skip ahead in listB (starting from the head) to get to the intersected node.
    • +
    + +

    The judge will then create the linked structure based on these inputs and pass the two heads, headA and headB to your program. If you correctly return the intersected node, then your solution will be accepted.

    +

     

    Example 1:

    - +
     Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,6,1,8,4,5], skipA = 2, skipB = 3
     Output: Intersected at '8'
    @@ -30,7 +44,7 @@ From the head of A, it reads as [4,1,8,4,5]. From the head of B, it reads as [5,
     

    Example 2:

    - +
     Input: intersectVal = 2, listA = [1,9,1,2,4], listB = [3,2,4], skipA = 3, skipB = 1
     Output: Intersected at '2'
    @@ -39,7 +53,7 @@ From the head of A, it reads as [1,9,1,2,4]. From the head of B, it reads as [3,
     

    Example 3:

    - +
     Input: intersectVal = 0, listA = [2,6,4], listB = [1,5], skipA = 3, skipB = 2
     Output: No intersection
    @@ -58,7 +72,7 @@ Explanation: The two lists do not intersect, so return null.
     	
  • 0 <= skipA <= m
  • 0 <= skipB <= n
  • intersectVal is 0 if listA and listB do not intersect.
  • -
  • intersectVal == listA[skipA + 1] == listB[skipB + 1] if listA and listB intersect.
  • +
  • intersectVal == listA[skipA] == listB[skipB] if listA and listB intersect.
  •  

    diff --git a/problems/investments-in-2016/README.md b/problems/investments-in-2016/README.md index afa8207af..23dfc1764 100644 --- a/problems/investments-in-2016/README.md +++ b/problems/investments-in-2016/README.md @@ -11,7 +11,58 @@ ## [585. Investments in 2016 (Medium)](https://leetcode.com/problems/investments-in-2016 "2016年的投资") +

    Write a query to print the sum of all total investment values in 2016 (TIV_2016), to a scale of 2 decimal places, for all policy holders who meet the following criteria:

    +
      +
    1. Have the same TIV_2015 value as one or more other policyholders.
    2. +
    3. Are not located in the same city as any other policyholder (i.e.: the (latitude, longitude) attribute pairs must be unique).
    4. +
    + +

    Input Format:
    +The insurance table is described as follows:

    + +
    +| Column Name | Type          |
    +|-------------|---------------|
    +| PID         | INTEGER(11)   |
    +| TIV_2015    | NUMERIC(15,2) |
    +| TIV_2016    | NUMERIC(15,2) |
    +| LAT         | NUMERIC(5,2)  |
    +| LON         | NUMERIC(5,2)  |
    +
    + +

    where PID is the policyholder's policy ID, TIV_2015 is the total investment value in 2015, TIV_2016 is the total investment value in 2016, LAT is the latitude of the policy holder's city, and LON is the longitude of the policy holder's city.

    + +

    Sample Input

    + +
    +| PID | TIV_2015 | TIV_2016 | LAT | LON |
    +|-----|----------|----------|-----|-----|
    +| 1   | 10       | 5        | 10  | 10  |
    +| 2   | 20       | 20       | 20  | 20  |
    +| 3   | 10       | 30       | 20  | 20  |
    +| 4   | 10       | 40       | 40  | 40  |
    +
    + +

    Sample Output

    + +
    +| TIV_2016 |
    +|----------|
    +| 45.00    |
    +
    + +

    Explanation

    + +
    +The first record in the table, like the last record, meets both of the two criteria.
    +The TIV_2015 value '10' is as the same as the third and forth record, and its location unique.
    +
    +The second record does not meet any of the two criteria. Its TIV_2015 is not like any other policyholders.
    +
    +And its location is the same with the third record, which makes the third record fail, too.
    +
    +So, the result is the sum of TIV_2016 of the first and last record, which is 45.
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/ip-to-cidr/README.md b/problems/ip-to-cidr/README.md index 3ae4f69e8..e1bf2aabc 100644 --- a/problems/ip-to-cidr/README.md +++ b/problems/ip-to-cidr/README.md @@ -11,7 +11,56 @@ ## [751. IP to CIDR (Medium)](https://leetcode.com/problems/ip-to-cidr "IP 到 CIDR") +

    +Given a start IP address ip and a number of ips we need to cover n, return a representation of the range as a list (of smallest possible length) of CIDR blocks. +

    +A CIDR block is a string consisting of an IP, followed by a slash, and then the prefix length. For example: "123.45.67.89/20". That prefix length "20" represents the number of common prefix bits in the specified range. +

    +

    Example 1:
    +

    +Input: ip = "255.0.0.7", n = 10
    +Output: ["255.0.0.7/32","255.0.0.8/29","255.0.0.16/32"]
    +Explanation:
    +The initial ip address, when converted to binary, looks like this (spaces added for clarity):
    +255.0.0.7 -> 11111111 00000000 00000000 00000111
    +The address "255.0.0.7/32" specifies all addresses with a common prefix of 32 bits to the given address,
    +ie. just this one address.
    +
    +The address "255.0.0.8/29" specifies all addresses with a common prefix of 29 bits to the given address:
    +255.0.0.8 -> 11111111 00000000 00000000 00001000
    +Addresses with common prefix of 29 bits are:
    +11111111 00000000 00000000 00001000
    +11111111 00000000 00000000 00001001
    +11111111 00000000 00000000 00001010
    +11111111 00000000 00000000 00001011
    +11111111 00000000 00000000 00001100
    +11111111 00000000 00000000 00001101
    +11111111 00000000 00000000 00001110
    +11111111 00000000 00000000 00001111
    +
    +The address "255.0.0.16/32" specifies all addresses with a common prefix of 32 bits to the given address,
    +ie. just 11111111 00000000 00000000 00010000.
    +
    +In total, the answer specifies the range of 10 ips starting with the address 255.0.0.7 .
    +
    +There were other representations, such as:
    +["255.0.0.7/32","255.0.0.8/30", "255.0.0.12/30", "255.0.0.16/32"],
    +but our answer was the shortest possible.
    +
    +Also note that a representation beginning with say, "255.0.0.7/30" would be incorrect,
    +because it includes addresses like 255.0.0.4 = 11111111 00000000 00000000 00000100 
    +that are outside the specified range.
    +
    +

    + +

    Note:
    +

      +
    1. ip will be a valid IPv4 address.
    2. +
    3. Every implied address ip + x (for x < n) will be a valid IPv4 address.
    4. +
    5. n will be an integer in the range [1, 1000].
    6. +
    +

    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/jump-game/README.md b/problems/jump-game/README.md index d98c78317..161f004dd 100644 --- a/problems/jump-game/README.md +++ b/problems/jump-game/README.md @@ -11,11 +11,9 @@ ## [55. Jump Game (Medium)](https://leetcode.com/problems/jump-game "跳跃游戏") -

    Given an array of non-negative integers nums, you are initially positioned at the first index of the array.

    +

    You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position.

    -

    Each element in the array represents your maximum jump length at that position.

    - -

    Determine if you are able to reach the last index.

    +

    Return true if you can reach the last index, or false otherwise.

     

    Example 1:

    diff --git a/problems/k-closest-points-to-origin/README.md b/problems/k-closest-points-to-origin/README.md index 543ae3548..f9d20533a 100644 --- a/problems/k-closest-points-to-origin/README.md +++ b/problems/k-closest-points-to-origin/README.md @@ -47,16 +47,15 @@ We only want the closest k = 1 points from the origin, so the answer is just [[- ### Related Topics + [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] - [[Geometry](../../tag/geometry/README.md)] + [[Quickselect](../../tag/quickselect/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] - [[Quickselect](../../tag/quickselect/README.md)] ### Similar Questions 1. [Kth Largest Element in an Array](../kth-largest-element-in-an-array) (Medium) 1. [Top K Frequent Elements](../top-k-frequent-elements) (Medium) 1. [Top K Frequent Words](../top-k-frequent-words) (Medium) - 1. [Find Nearest Point That Has the Same X or Y Coordinate](../find-nearest-point-that-has-the-same-x-or-y-coordinate) (Easy) diff --git a/problems/k-empty-slots/README.md b/problems/k-empty-slots/README.md index bdfeb9974..633ae20d4 100644 --- a/problems/k-empty-slots/README.md +++ b/problems/k-empty-slots/README.md @@ -11,7 +11,49 @@ ## [683. K Empty Slots (Hard)](https://leetcode.com/problems/k-empty-slots "K 个关闭的灯泡") +

    You have N bulbs in a row numbered from 1 to N. Initially, all the bulbs are turned off. We turn on exactly one bulb everyday until all bulbs are on after N days.

    +

    You are given an array bulbs of length N where bulbs[i] = x means that on the (i+1)th day, we will turn on the bulb at position x where i is 0-indexed and x is 1-indexed.

    + +

    Given an integer K, find out the minimum day number such that there exists two turned on bulbs that have exactly K bulbs between them that are all turned off.

    + +

    If there isn't such day, return -1.

    + +

     

    + +

    Example 1:

    + +
    +Input: 
    +bulbs: [1,3,2]
    +K: 1
    +Output: 2
    +Explanation:
    +On the first day: bulbs[0] = 1, first bulb is turned on: [1,0,0]
    +On the second day: bulbs[1] = 3, third bulb is turned on: [1,0,1]
    +On the third day: bulbs[2] = 2, second bulb is turned on: [1,1,1]
    +We return 2 because on the second day, there were two on bulbs with one off bulb between them.
    +
    + +

    Example 2:

    + +
    +Input: 
    +bulbs: [1,2,3]
    +K: 1
    +Output: -1
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= N <= 20000
    2. +
    3. 1 <= bulbs[i] <= N
    4. +
    5. bulbs is a permutation of numbers from 1 to N.
    6. +
    7. 0 <= K <= 20000
    8. +
    ### Related Topics [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] diff --git a/problems/keys-and-rooms/README.md b/problems/keys-and-rooms/README.md index 0573ae24c..ba29f0504 100644 --- a/problems/keys-and-rooms/README.md +++ b/problems/keys-and-rooms/README.md @@ -11,46 +11,45 @@ ## [841. Keys and Rooms (Medium)](https://leetcode.com/problems/keys-and-rooms "钥匙和房间") -

    There are N rooms and you start in room 0.  Each room has a distinct number in 0, 1, 2, ..., N-1, and each room may have some keys to access the next room. 

    +

    There are n rooms labeled from 0 to n - 1 and all the rooms are locked except for room 0. Your goal is to visit all the rooms. However, you cannot enter a locked room without having its key.

    -

    Formally, each room i has a list of keys rooms[i], and each key rooms[i][j] is an integer in [0, 1, ..., N-1] where N = rooms.length.  A key rooms[i][j] = v opens the room with number v.

    +

    When you visit a room, you may find a set of distinct keys in it. Each key has a number on it, denoting which room it unlocks, and you can take all of them with you to unlock the other rooms.

    -

    Initially, all the rooms start locked (except for room 0). 

    - -

    You can walk back and forth between rooms freely.

    - -

    Return true if and only if you can enter every room.

    - -
      -
    +

    Given an array rooms where rooms[i] is the set of keys that you can obtain if you visited room i, return true if you can visit all the rooms, or false otherwise.

    +

     

    Example 1:

    -Input: [[1],[2],[3],[]]
    -Output: true
    -Explanation:  
    -We start in room 0, and pick up key 1.
    -We then go to room 1, and pick up key 2.
    -We then go to room 2, and pick up key 3.
    -We then go to room 3.  Since we were able to go to every room, we return true.
    +Input: rooms = [[1],[2],[3],[]]
    +Output: true
    +Explanation: 
    +We visit room 0 and pick up key 1.
    +We then visit room 1 and pick up key 2.
    +We then visit room 2 and pick up key 3.
    +We then visit room 3.
    +Since we were able to visit every room, we return true.
     

    Example 2:

    -Input: [[1,3],[3,0,1],[2],[0]]
    -Output: false
    -Explanation: We can't enter the room with number 2.
    +Input: rooms = [[1,3],[3,0,1],[2],[0]]
    +Output: false
    +Explanation: We can not enter room number 2 since the only key that unlocks it is in that room.
     
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. 1 <= rooms.length <= 1000
    2. +
        +
      • n == rooms.length
      • +
      • 2 <= n <= 1000
      • 0 <= rooms[i].length <= 1000
      • -
      • The number of keys in all rooms combined is at most 3000.
      • -
    +
  • 1 <= sum(rooms[i].length) <= 3000
  • +
  • 0 <= rooms[i][j] < n
  • +
  • All the values of rooms[i] are unique.
  • + ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/kids-with-the-greatest-number-of-candies/README.md b/problems/kids-with-the-greatest-number-of-candies/README.md index df7073b98..85ea93f67 100644 --- a/problems/kids-with-the-greatest-number-of-candies/README.md +++ b/problems/kids-with-the-greatest-number-of-candies/README.md @@ -11,9 +11,11 @@ ## [1431. Kids With the Greatest Number of Candies (Easy)](https://leetcode.com/problems/kids-with-the-greatest-number-of-candies "拥有最多糖果的孩子") -

    Given the array candies and the integer extraCandies, where candies[i] represents the number of candies that the ith kid has.

    +

    There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the ith kid has, and an integer extraCandies, denoting the number of extra candies that you have.

    -

    For each kid check if there is a way to distribute extraCandies among the kids such that he or she can have the greatest number of candies among them. Notice that multiple kids can have the greatest number of candies.

    +

    Return a boolean array result of length n, where result[i] is true if, after giving the ith kid all the extraCandies, they will have the greatest number of candies among all the kids, or false otherwise.

    + +

    Note that multiple kids can have the greatest number of candies.

     

    Example 1:

    @@ -21,12 +23,12 @@
     Input: candies = [2,3,5,1,3], extraCandies = 3
     Output: [true,true,true,false,true] 
    -Explanation: 
    -Kid 1 has 2 candies and if he or she receives all extra candies (3) will have 5 candies --- the greatest number of candies among the kids. 
    -Kid 2 has 3 candies and if he or she receives at least 2 extra candies will have the greatest number of candies among the kids. 
    -Kid 3 has 5 candies and this is already the greatest number of candies among the kids. 
    -Kid 4 has 1 candy and even if he or she receives all extra candies will only have 4 candies. 
    -Kid 5 has 3 candies and if he or she receives at least 2 extra candies will have the greatest number of candies among the kids. 
    +Explanation: If you give all extraCandies to:
    +- Kid 1, they will have 2 + 3 = 5 candies, which is the greatest among the kids.
    +- Kid 2, they will have 3 + 3 = 6 candies, which is the greatest among the kids.
    +- Kid 3, they will have 5 + 3 = 8 candies, which is the greatest among the kids.
    +- Kid 4, they will have 1 + 3 = 4 candies, which is not the greatest among the kids.
    +- Kid 5, they will have 3 + 3 = 6 candies, which is the greatest among the kids.
     

    Example 2:

    @@ -34,7 +36,8 @@ Kid 5 has 3 candies and if he or she receives at least 2 extra candies will have
     Input: candies = [4,2,1,1,2], extraCandies = 1
     Output: [true,false,false,false,false] 
    -Explanation: There is only 1 extra candy, therefore only kid 1 will have the greatest number of candies among the kids regardless of who takes the extra candy.
    +Explanation: There is only 1 extra candy.
    +Kid 1 will always have the greatest number of candies, even if a different kid is given the extra candy.
     

    Example 3:

    @@ -48,7 +51,8 @@ Kid 5 has 3 candies and if he or she receives at least 2 extra candies will have

    Constraints:

      -
    • 2 <= candies.length <= 100
    • +
    • n == candies.length
    • +
    • 2 <= n <= 100
    • 1 <= candies[i] <= 100
    • 1 <= extraCandies <= 50
    diff --git a/problems/kill-process/README.md b/problems/kill-process/README.md index cb9b796f2..51a931677 100644 --- a/problems/kill-process/README.md +++ b/problems/kill-process/README.md @@ -11,7 +11,36 @@ ## [582. Kill Process (Medium)](https://leetcode.com/problems/kill-process "杀掉进程") +

    Given n processes, each process has a unique PID (process id) and its PPID (parent process id). +

    Each process only has one parent process, but may have one or more children processes. This is just like a tree structure. Only one process has PPID that is 0, which means this process has no parent process. All the PIDs will be distinct positive integers.

    + +

    We use two list of integers to represent a list of processes, where the first list contains PID for each process and the second list contains the corresponding PPID.

    + +

    Now given the two lists, and a PID representing a process you want to kill, return a list of PIDs of processes that will be killed in the end. You should assume that when a process is killed, all its children processes will be killed. No order is required for the final answer.

    + +

    Example 1:
    +

    Input: 
    +pid =  [1, 3, 10, 5]
    +ppid = [3, 0, 5, 3]
    +kill = 5
    +Output: [5,10]
    +Explanation: 
    +           3
    +         /   \
    +        1     5
    +             /
    +            10
    +Kill 5 will also kill 10.
    +
    +

    + +

    Note:
    +

      +
    1. The given kill id is guaranteed to be one of the given PIDs.
    2. +
    3. n >= 1.
    4. +
    +

    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/kth-ancestor-of-a-tree-node/README.md b/problems/kth-ancestor-of-a-tree-node/README.md index 45fab111e..eb59c8b0f 100644 --- a/problems/kth-ancestor-of-a-tree-node/README.md +++ b/problems/kth-ancestor-of-a-tree-node/README.md @@ -51,12 +51,12 @@ treeAncestor.getKthAncestor(6, 3); // returns -1 because there is no such ancest ### Related Topics + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Design](../../tag/design/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/largest-bst-subtree/README.md b/problems/largest-bst-subtree/README.md index 42bd7d77b..bdbe666f4 100644 --- a/problems/largest-bst-subtree/README.md +++ b/problems/largest-bst-subtree/README.md @@ -11,7 +11,29 @@ ## [333. Largest BST Subtree (Medium)](https://leetcode.com/problems/largest-bst-subtree "最大 BST 子树") +

    Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest means subtree with largest number of nodes in it.

    +

    Note:
    +A subtree must include all of its descendants.

    + +

    Example:

    + +
    +Input: [10,5,15,1,8,null,7]
    +
    +   10 
    +   / \ 
    +  5  15 
    + / \   \ 
    +1   8   7
    +
    +Output: 3
    +Explanation: The Largest BST Subtree in this case is the highlighted one.
    +             The return value is the subtree's size, which is 3.
    +
    + +

    Follow up:
    +Can you figure out ways to solve it with O(n) time complexity?

    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/largest-component-size-by-common-factor/README.md b/problems/largest-component-size-by-common-factor/README.md index 4f8032059..7750f88a9 100644 --- a/problems/largest-component-size-by-common-factor/README.md +++ b/problems/largest-component-size-by-common-factor/README.md @@ -11,56 +11,45 @@ ## [952. Largest Component Size by Common Factor (Hard)](https://leetcode.com/problems/largest-component-size-by-common-factor "按公因数计算最大组件大小") -

    Given a non-empty array of unique positive integers nums, consider the following graph:

    +

    You are given an integer array of unique positive integers nums. Consider the following graph:

      -
    • There are nums.length nodes, labelled nums[0] to nums[nums.length - 1];
    • -
    • There is an edge between nums[i] and nums[j] if and only if nums[i] and nums[j] share a common factor greater than 1.
    • +
    • There are nums.length nodes, labeled nums[0] to nums[nums.length - 1],
    • +
    • There is an undirected edge between nums[i] and nums[j] if nums[i] and nums[j] share a common factor greater than 1.
    -

    Return the size of the largest connected component in the graph.

    +

    Return the size of the largest connected component in the graph.

     

    - -
      -
    - -

    Example 1:

    - +
    -Input: nums = [4,6,15,35]
    -Output: 4
    -
    +Input: nums = [4,6,15,35]
    +Output: 4
     
    -

    Example 2:

    - +
    -Input: nums = [20,50,9,63]
    -Output: 2
    -
    +Input: nums = [20,50,9,63]
    +Output: 2
     
    -

    Example 3:

    - +
    -Input: nums = [2,3,6,7,4,12,21,39]
    -Output: 8
    -
    +Input: nums = [2,3,6,7,4,12,21,39]
    +Output: 8
     
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. 1 <= nums.length <= 20000
    2. -
    3. 1 <= nums[i] <= 100000
    4. -
    -
    -
    -
    +
      +
    • 1 <= nums.length <= 2 * 104
    • +
    • 1 <= nums[i] <= 105
    • +
    • All the values of nums are unique.
    • +
    ### Related Topics [[Union Find](../../tag/union-find/README.md)] diff --git a/problems/largest-number-after-mutating-substring/README.md b/problems/largest-number-after-mutating-substring/README.md new file mode 100644 index 000000000..393bb93de --- /dev/null +++ b/problems/largest-number-after-mutating-substring/README.md @@ -0,0 +1,84 @@ + + + + + + + +[< Previous](../sum-of-digits-of-string-after-convert "Sum of Digits of String After Convert") +                 +[Next >](../maximum-compatibility-score-sum "Maximum Compatibility Score Sum") + +## [1946. Largest Number After Mutating Substring (Medium)](https://leetcode.com/problems/largest-number-after-mutating-substring "子字符串突变后可能得到的最大整数") + +

    You are given a string num, which represents a large integer. You are also given a 0-indexed integer array change of length 10 that maps each digit 0-9 to another digit. More formally, digit d maps to digit change[d].

    + +

    You may choose to mutate any substring of num. To mutate a substring, replace each digit num[i] with the digit it maps to in change (i.e. replace num[i] with change[num[i]]).

    + +

    Return a string representing the largest possible integer after mutating (or choosing not to) any substring of num.

    + +

    A substring is a contiguous sequence of characters within the string.

    + +

     

    +

    Example 1:

    + +
    +Input: num = "132", change = [9,8,5,0,3,6,4,2,6,8]
    +Output: "832"
    +Explanation: Replace the substring "1":
    +- 1 maps to change[1] = 8.
    +Thus, "132" becomes "832".
    +"832" is the largest number that can be created, so return it.
    +
    + +

    Example 2:

    + +
    +Input: num = "021", change = [9,4,3,5,7,2,1,9,0,6]
    +Output: "934"
    +Explanation: Replace the substring "021":
    +- 0 maps to change[0] = 9.
    +- 2 maps to change[2] = 3.
    +- 1 maps to change[1] = 4.
    +Thus, "021" becomes "934".
    +"934" is the largest number that can be created, so return it.
    +
    + +

    Example 3:

    + +
    +Input: num = "5", change = [1,4,7,5,3,2,5,6,9,4]
    +Output: "5"
    +Explanation: "5" is already the largest number that can be created, so return it.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= num.length <= 105
    • +
    • num consists of only digits 0-9.
    • +
    • change.length == 10
    • +
    • 0 <= change[d] <= 9
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Should you change a digit if the new digit is smaller than the original? +
    + +
    +Hint 2 +If changing the first digit and the last digit both make the number bigger, but you can only change one of them; which one should you change? +
    + +
    +Hint 3 +Changing numbers closer to the front is always better +
    diff --git a/problems/largest-sum-of-averages/README.md b/problems/largest-sum-of-averages/README.md index 19f91e79a..a53338cfd 100644 --- a/problems/largest-sum-of-averages/README.md +++ b/problems/largest-sum-of-averages/README.md @@ -11,31 +11,38 @@ ## [813. Largest Sum of Averages (Medium)](https://leetcode.com/problems/largest-sum-of-averages "最大平均值和的分组") -

    We partition a row of numbers nums into at most k adjacent (non-empty) groups, then our score is the sum of the average of each group. What is the largest score we can achieve?

    +

    You are given an integer array nums and an integer k. You can partition the array into at most k non-empty adjacent subarrays. The score of a partition is the sum of the averages of each subarray.

    -

    Note that our partition must use every number in nums, and that scores are not necessarily integers.

    +

    Note that the partition must use every integer in nums, and that the score is not necessarily an integer.

    + +

    Return the maximum score you can achieve of all the possible partitions. Answers within 10-6 of the actual answer will be accepted.

    + +

     

    +

    Example 1:

    -Example:
    -Input: 
    -nums = [9,1,2,3,9]
    -k = 3
    -Output: 20
    +Input: nums = [9,1,2,3,9], k = 3
    +Output: 20.00000
     Explanation: 
     The best choice is to partition nums into [9], [1, 2, 3], [9]. The answer is 9 + (1 + 2 + 3) / 3 + 9 = 20.
     We could have also partitioned nums into [9, 1], [2], [3, 9], for example.
     That partition would lead to a score of 5 + 2 + 6 = 13, which is worse.
     
    -

     

    +

    Example 2:

    -

    Note:

    +
    +Input: nums = [1,2,3,4,5,6,7], k = 4
    +Output: 20.50000
    +
    + +

     

    +

    Constraints:

      -
    • 1 <= nums.length <= 100.
    • -
    • 1 <= nums[i] <= 10000.
    • -
    • 1 <= k <= nums.length.
    • -
    • Answers within 10-6 of the correct answer will be accepted as correct.
    • +
    • 1 <= nums.length <= 100
    • +
    • 1 <= nums[i] <= 104
    • +
    • 1 <= k <= nums.length
    ### Related Topics diff --git a/problems/largest-triangle-area/README.md b/problems/largest-triangle-area/README.md index 0d7e61ae6..6e29bdca6 100644 --- a/problems/largest-triangle-area/README.md +++ b/problems/largest-triangle-area/README.md @@ -11,29 +11,33 @@ ## [812. Largest Triangle Area (Easy)](https://leetcode.com/problems/largest-triangle-area "最大三角形面积") -

    You have a list of points in the plane. Return the area of the largest triangle that can be formed by any 3 of the points.

    +

    Given an array of points on the X-Y plane points where points[i] = [xi, yi], return the area of the largest triangle that can be formed by any three different points. Answers within 10-5 of the actual answer will be accepted.

    +

     

    +

    Example 1:

    +
    -Example:
     Input: points = [[0,0],[0,1],[1,0],[0,2],[2,0]]
    -Output: 2
    -Explanation: 
    -The five points are show in the figure below. The red triangle is the largest.
    +Output: 2.00000
    +Explanation: The five points are shown in the above figure. The red triangle is the largest.
     
    -

    +

    Example 2:

    -

    Notes:

    +
    +Input: points = [[1,0],[0,0],[0,1]]
    +Output: 0.50000
    +
    + +

     

    +

    Constraints:

      -
    • 3 <= points.length <= 50.
    • -
    • No points will be duplicated.
    • -
    •  -50 <= points[i][j] <= 50.
    • -
    • Answers within 10^-6 of the true value will be accepted as correct.
    • +
    • 3 <= points.length <= 50
    • +
    • -50 <= xi, yi <= 50
    • +
    • All the given points are unique.
    -

     

    - ### Related Topics [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] diff --git a/problems/largest-unique-number/README.md b/problems/largest-unique-number/README.md index 51efc5857..ad2ebb845 100644 --- a/problems/largest-unique-number/README.md +++ b/problems/largest-unique-number/README.md @@ -11,7 +11,38 @@ ## [1133. Largest Unique Number (Easy)](https://leetcode.com/problems/largest-unique-number "最大唯一数") +

    Given an array of integers A, return the largest integer that only occurs once.

    +

    If no integer occurs once, return -1.

    + +

     

    + +

    Example 1:

    + +
    +Input: [5,7,3,9,4,9,8,3,1]
    +Output: 8
    +Explanation: 
    +The maximum integer in the array is 9 but it is repeated. The number 8 occurs only once, so it's the answer.
    +
    + +

    Example 2:

    + +
    +Input: [9,9,8,8]
    +Output: -1
    +Explanation: 
    +There is no number that occurs only once.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= A.length <= 2000
    2. +
    3. 0 <= A[i] <= 1000
    4. +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/league-statistics/README.md b/problems/league-statistics/README.md index 1484b9fe0..726bfab63 100644 --- a/problems/league-statistics/README.md +++ b/problems/league-statistics/README.md @@ -9,7 +9,7 @@                  [Next >](../next-palindrome-using-same-digits "Next Palindrome Using Same Digits") -## [1841. League Statistics (Medium)](https://leetcode.com/problems/league-statistics "") +## [1841. League Statistics (Medium)](https://leetcode.com/problems/league-statistics "联赛信息统计") diff --git a/problems/leetcodify-similar-friends/README.md b/problems/leetcodify-similar-friends/README.md index c15d350c5..71672fe0b 100644 --- a/problems/leetcodify-similar-friends/README.md +++ b/problems/leetcodify-similar-friends/README.md @@ -9,6 +9,6 @@                  [Next >](../build-array-from-permutation "Build Array from Permutation") -## [1919. Leetcodify Similar Friends (Hard)](https://leetcode.com/problems/leetcodify-similar-friends "") +## [1919. Leetcodify Similar Friends (Hard)](https://leetcode.com/problems/leetcodify-similar-friends "兴趣相同的朋友") diff --git a/problems/lemonade-change/README.md b/problems/lemonade-change/README.md index 6dff3b59c..c85ac1bad 100644 --- a/problems/lemonade-change/README.md +++ b/problems/lemonade-change/README.md @@ -11,72 +11,58 @@ ## [860. Lemonade Change (Easy)](https://leetcode.com/problems/lemonade-change "柠檬水找零") -

    At a lemonade stand, each lemonade costs $5

    +

    At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and order one at a time (in the order specified by bills). Each customer will only buy one lemonade and pay with either a $5, $10, or $20 bill. You must provide the correct change to each customer so that the net transaction is that the customer pays $5.

    -

    Customers are standing in a queue to buy from you, and order one at a time (in the order specified by bills).

    +

    Note that you don't have any change in hand at first.

    -

    Each customer will only buy one lemonade and pay with either a $5, $10, or $20 bill.  You must provide the correct change to each customer, so that the net transaction is that the customer pays $5.

    - -

    Note that you don't have any change in hand at first.

    - -

    Return true if and only if you can provide every customer with correct change.

    +

    Given an integer array bills where bills[i] is the bill the ith customer pays, return true if you can provide every customer with correct change, or false otherwise.

     

    - -

    Example 1:

    -Input: [5,5,5,10,20]
    -Output: true
    -Explanation: 
    +Input: bills = [5,5,5,10,20]
    +Output: true
    +Explanation: 
     From the first 3 customers, we collect three $5 bills in order.
     From the fourth customer, we collect a $10 bill and give back a $5.
     From the fifth customer, we give a $10 bill and a $5 bill.
     Since all customers got correct change, we output true.
     
    -

    Example 2:

    -Input: [5,5,10]
    -Output: true
    +Input: bills = [5,5,10,10,20]
    +Output: false
    +Explanation: 
    +From the first two customers in order, we collect two $5 bills.
    +For the next two customers in order, we collect a $10 bill and give back a $5 bill.
    +For the last customer, we can not give change of $15 back because we only have two $10 bills.
    +Since not every customer received correct change, the answer is false.
     
    -

    Example 3:

    -Input: [10,10]
    -Output: false
    +Input: bills = [5,5,10]
    +Output: true
     
    -

    Example 4:

    -Input: [5,5,10,10,20]
    -Output: false
    -Explanation: 
    -From the first two customers in order, we collect two $5 bills.
    -For the next two customers in order, we collect a $10 bill and give back a $5 bill.
    -For the last customer, we can't give change of $15 back because we only have two $10 bills.
    -Since not every customer received correct change, the answer is false.
    +Input: bills = [10,10]
    +Output: false
     

     

    - -

    Note:

    +

    Constraints:

      -
    • 0 <= bills.length <= 10000
    • -
    • bills[i] will be either 5, 10, or 20.
    • +
    • 1 <= bills.length <= 105
    • +
    • bills[i] is either 5, 10, or 20.
    -
    -
    -
    -
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/lexicographically-smallest-equivalent-string/README.md b/problems/lexicographically-smallest-equivalent-string/README.md index e3907ccdd..a93964e99 100644 --- a/problems/lexicographically-smallest-equivalent-string/README.md +++ b/problems/lexicographically-smallest-equivalent-string/README.md @@ -11,7 +11,55 @@ ## [1061. Lexicographically Smallest Equivalent String (Medium)](https://leetcode.com/problems/lexicographically-smallest-equivalent-string "按字典序排列最小的等效字符串") +

    Given strings A and B of the same length, we say A[i] and B[i] are equivalent characters. For example, if A = "abc" and B = "cde", then we have 'a' == 'c', 'b' == 'd', 'c' == 'e'.

    +

    Equivalent characters follow the usual rules of any equivalence relation:

    + +
      +
    • Reflexivity: 'a' == 'a'
    • +
    • Symmetry: 'a' == 'b' implies 'b' == 'a'
    • +
    • Transitivity: 'a' == 'b' and 'b' == 'c' implies 'a' == 'c'
    • +
    + +

    For example, given the equivalency information from A and B above, S = "eed", "acd", and "aab" are equivalent strings, and "aab" is the lexicographically smallest equivalent string of S.

    + +

    Return the lexicographically smallest equivalent string of S by using the equivalency information from A and B.

    + +

     

    + +

    Example 1:

    + +
    +Input: A = "parker", B = "morris", S = "parser"
    +Output: "makkek"
    +Explanation: Based on the equivalency information in A and B, we can group their characters as [m,p], [a,o], [k,r,s], [e,i]. The characters in each group are equivalent and sorted in lexicographical order. So the answer is "makkek".
    +
    + +

    Example 2:

    + +
    +Input: A = "hello", B = "world", S = "hold"
    +Output: "hdld"
    +Explanation:  Based on the equivalency information in A and B, we can group their characters as [h,w], [d,e,o], [l,r]. So only the second letter 'o' in S is changed to 'd', the answer is "hdld".
    +
    + +

    Example 3:

    + +
    +Input: A = "leetcode", B = "programs", S = "sourcecode"
    +Output: "aauaaaaada"
    +Explanation:  We group the equivalent characters in A and B as [a,o,e,r,s,c], [l,p], [g,t] and [d,m], thus all letters in S except 'u' and 'd' are transformed to 'a', the answer is "aauaaaaada".
    +
    + +

     

    + +

    Note:

    + +
      +
    1. String A, B and S consist of only lowercase English letters from 'a' - 'z'.
    2. +
    3. The lengths of string A, B and S are between 1 and 1000.
    4. +
    5. String A and B are of the same length.
    6. +
    ### Related Topics [[Union Find](../../tag/union-find/README.md)] diff --git a/problems/line-reflection/README.md b/problems/line-reflection/README.md index e7e84c1b2..e102b042a 100644 --- a/problems/line-reflection/README.md +++ b/problems/line-reflection/README.md @@ -11,7 +11,21 @@ ## [356. Line Reflection (Medium)](https://leetcode.com/problems/line-reflection "直线镜像") +

    Given n points on a 2D plane, find if there is such a line parallel to y-axis that reflect the given points.

    +

    Example 1:

    + +
    +Input: [[1,1],[-1,1]]
    +Output: true
    +
    + +
    +

    Example 2:

    + +
    +Input: [[1,1],[-1,-1]]
    +Output: false
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/linked-list-components/README.md b/problems/linked-list-components/README.md index d4f1a7f33..16e27528e 100644 --- a/problems/linked-list-components/README.md +++ b/problems/linked-list-components/README.md @@ -11,41 +11,38 @@ ## [817. Linked List Components (Medium)](https://leetcode.com/problems/linked-list-components "链表组件") -

    We are given head, the head node of a linked list containing unique integer values.

    +

    You are given the head of a linked list containing unique integer values and an integer array nums that is a subset of the linked list values.

    -

    We are also given the list nums, a subset of the values in the linked list.

    - -

    Return the number of connected components in nums, where two values are connected if they appear consecutively in the linked list.

    +

    Return the number of connected components in nums where two values are connected if they appear consecutively in the linked list.

    +

     

    Example 1:

    - +
    -Input: 
    -head: 0->1->2->3
    -nums = [0, 1, 3]
    +Input: head = [0,1,2,3], nums = [0,1,3]
     Output: 2
    -Explanation: 
    -0 and 1 are connected, so [0, 1] and [3] are the two connected components.
    +Explanation: 0 and 1 are connected, so [0, 1] and [3] are the two connected components.
     

    Example 2:

    - +
    -Input: 
    -head: 0->1->2->3->4
    -nums = [0, 3, 1, 4]
    +Input: head = [0,1,2,3,4], nums = [0,3,1,4]
     Output: 2
    -Explanation: 
    -0 and 1 are connected, 3 and 4 are connected, so [0, 1] and [3, 4] are the two connected components.
    +Explanation: 0 and 1 are connected, 3 and 4 are connected, so [0, 1] and [3, 4] are the two connected components.
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • If n is the length of the linked list given by head1 <= n <= 10000.
    • -
    • The value of each node in the linked list will be in the range [0, n - 1].
    • -
    • 1 <= nums.length <= 10000.
    • -
    • nums is a subset of all values in the linked list.
    • +
    • The number of nodes in the linked list is n.
    • +
    • 1 <= n <= 104
    • +
    • 0 <= Node.val < n
    • +
    • All the values Node.val are unique.
    • +
    • 1 <= nums.length <= n
    • +
    • 0 <= nums[i] <= n
    • +
    • All the values of nums are unique.
    ### Related Topics diff --git a/problems/list-the-products-ordered-in-a-period/README.md b/problems/list-the-products-ordered-in-a-period/README.md index 3e3989858..5e2623670 100644 --- a/problems/list-the-products-ordered-in-a-period/README.md +++ b/problems/list-the-products-ordered-in-a-period/README.md @@ -11,7 +11,83 @@ ## [1327. List the Products Ordered in a Period (Easy)](https://leetcode.com/problems/list-the-products-ordered-in-a-period "列出指定时间段内所有的下单产品") +SQL Schema +

    Table: Products

    +
    ++------------------+---------+
    +| Column Name      | Type    |
    ++------------------+---------+
    +| product_id       | int     |
    +| product_name     | varchar |
    +| product_category | varchar |
    ++------------------+---------+
    +product_id is the primary key for this table.
    +This table contains data about the company's products.
    +
    +

    Table: Orders

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| product_id    | int     |
    +| order_date    | date    |
    +| unit          | int     |
    ++---------------+---------+
    +There is no primary key for this table. It may have duplicate rows.
    +product_id is a foreign key to Products table.
    +unit is the number of products ordered in order_date.
    +
    + +Write an SQL query to get the names of products with greater than or equal to 100 units ordered in February 2020 and their amount. + +Return result table in any order. + +The query result format is in the following example: +
    +Products table:
    ++-------------+-----------------------+------------------+
    +| product_id  | product_name          | product_category |
    ++-------------+-----------------------+------------------+
    +| 1           | Leetcode Solutions    | Book             |
    +| 2           | Jewels of Stringology | Book             |
    +| 3           | HP                    | Laptop           |
    +| 4           | Lenovo                | Laptop           |
    +| 5           | Leetcode Kit          | T-shirt          |
    ++-------------+-----------------------+------------------+
    +
    +Orders table:
    ++--------------+--------------+----------+
    +| product_id   | order_date   | unit     |
    ++--------------+--------------+----------+
    +| 1            | 2020-02-05   | 60       |
    +| 1            | 2020-02-10   | 70       |
    +| 2            | 2020-01-18   | 30       |
    +| 2            | 2020-02-11   | 80       |
    +| 3            | 2020-02-17   | 2        |
    +| 3            | 2020-02-24   | 3        |
    +| 4            | 2020-03-01   | 20       |
    +| 4            | 2020-03-04   | 30       |
    +| 4            | 2020-03-04   | 60       |
    +| 5            | 2020-02-25   | 50       |
    +| 5            | 2020-02-27   | 50       |
    +| 5            | 2020-03-01   | 50       |
    ++--------------+--------------+----------+
    +
    +Result table:
    ++--------------------+---------+
    +| product_name       | unit    |
    ++--------------------+---------+
    +| Leetcode Solutions | 130     |
    +| Leetcode Kit       | 100     |
    ++--------------------+---------+
    +
    +Products with product_id = 1 is ordered in February a total of (60 + 70) = 130.
    +Products with product_id = 2 is ordered in February a total of 80.
    +Products with product_id = 3 is ordered in February a total of (2 + 3) = 5.
    +Products with product_id = 4 was not ordered in February 2020.
    +Products with product_id = 5 is ordered in February a total of (50 + 50) = 100.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/logger-rate-limiter/README.md b/problems/logger-rate-limiter/README.md index 5ad10c83f..20267a79e 100644 --- a/problems/logger-rate-limiter/README.md +++ b/problems/logger-rate-limiter/README.md @@ -11,7 +11,35 @@ ## [359. Logger Rate Limiter (Easy)](https://leetcode.com/problems/logger-rate-limiter "日志速率限制器") +

    Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it is not printed in the last 10 seconds.

    +

    Given a message and a timestamp (in seconds granularity), return true if the message should be printed in the given timestamp, otherwise returns false.

    + +

    It is possible that several messages arrive roughly at the same time.

    + +

    Example:

    + +
    +Logger logger = new Logger();
    +
    +// logging string "foo" at timestamp 1
    +logger.shouldPrintMessage(1, "foo"); returns true; 
    +
    +// logging string "bar" at timestamp 2
    +logger.shouldPrintMessage(2,"bar"); returns true;
    +
    +// logging string "foo" at timestamp 3
    +logger.shouldPrintMessage(3,"foo"); returns false;
    +
    +// logging string "bar" at timestamp 8
    +logger.shouldPrintMessage(8,"bar"); returns false;
    +
    +// logging string "foo" at timestamp 10
    +logger.shouldPrintMessage(10,"foo"); returns false;
    +
    +// logging string "foo" at timestamp 11
    +logger.shouldPrintMessage(11,"foo"); returns true;
    +
    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/lonely-pixel-i/README.md b/problems/lonely-pixel-i/README.md index ef8e91e88..5a6dda563 100644 --- a/problems/lonely-pixel-i/README.md +++ b/problems/lonely-pixel-i/README.md @@ -11,7 +11,29 @@ ## [531. Lonely Pixel I (Medium)](https://leetcode.com/problems/lonely-pixel-i "孤独像素 I") +

    Given a picture consisting of black and white pixels, find the number of black lonely pixels.

    +

    The picture is represented by a 2D char array consisting of 'B' and 'W', which means black and white pixels respectively.

    + +

    A black lonely pixel is character 'B' that located at a specific position where the same row and same column don't have any other black pixels.

    + +

    Example:
    +

    +Input: 
    +[['W', 'W', 'B'],
    + ['W', 'B', 'W'],
    + ['B', 'W', 'W']]
    +
    +Output: 3
    +Explanation: All the three 'B's are black lonely pixels.
    +
    +

    + +

    Note:
    +

      +
    1. The range of width and height of the input 2D array is [1,500].
    2. +
    +

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/lonely-pixel-ii/README.md b/problems/lonely-pixel-ii/README.md index 8859e8fdf..09c10977b 100644 --- a/problems/lonely-pixel-ii/README.md +++ b/problems/lonely-pixel-ii/README.md @@ -11,7 +11,45 @@ ## [533. Lonely Pixel II (Medium)](https://leetcode.com/problems/lonely-pixel-ii "孤独像素 II") +

    Given a picture consisting of black and white pixels, and a positive integer N, find the number of black pixels located at some specific row R and column C that align with all the following rules:

    +
      +
    1. Row R and column C both contain exactly N black pixels.
    2. +
    3. For all rows that have a black pixel at column C, they should be exactly the same as row R
    4. +
    + +

    The picture is represented by a 2D char array consisting of 'B' and 'W', which means black and white pixels respectively.

    + +

    Example:
    +

    +Input:                                            
    +[['W', 'B', 'W', 'B', 'B', 'W'],    
    + ['W', 'B', 'W', 'B', 'B', 'W'],    
    + ['W', 'B', 'W', 'B', 'B', 'W'],    
    + ['W', 'W', 'B', 'W', 'B', 'W']] 
    +
    +N = 3
    +Output: 6
    +Explanation: All the bold 'B' are the black pixels we need (all 'B's at column 1 and 3).
    +        0    1    2    3    4    5         column index                                            
    +0    [['W', 'B', 'W', 'B', 'B', 'W'],    
    +1     ['W', 'B', 'W', 'B', 'B', 'W'],    
    +2     ['W', 'B', 'W', 'B', 'B', 'W'],    
    +3     ['W', 'W', 'B', 'W', 'B', 'W']]    
    +row index
    +
    +Take 'B' at row R = 0 and column C = 1 as an example:
    +Rule 1, row R = 0 and column C = 1 both have exactly N = 3 black pixels. 
    +Rule 2, the rows have black pixel at column C = 1 are row 0, row 1 and row 2. They are exactly the same as row R = 0.
    +
    +
    +

    + +

    Note:
    +

      +
    1. The range of width and height of the input 2D array is [1,200].
    2. +
    +

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/longest-common-subsequence-between-sorted-arrays/README.md b/problems/longest-common-subsequence-between-sorted-arrays/README.md new file mode 100644 index 000000000..d479ee7fb --- /dev/null +++ b/problems/longest-common-subsequence-between-sorted-arrays/README.md @@ -0,0 +1,30 @@ + + + + + + + +[< Previous](../users-that-actively-request-confirmation-messages "Users That Actively Request Confirmation Messages") +                 +[Next >](../check-if-all-characters-have-equal-number-of-occurrences "Check if All Characters Have Equal Number of Occurrences") + +## [1940. Longest Common Subsequence Between Sorted Arrays (Medium)](https://leetcode.com/problems/longest-common-subsequence-between-sorted-arrays "排序数组之间的最长公共子序列") + + + +### Hints +
    +Hint 1 +Fix one array. +
    + +
    +Hint 2 +Choose the next array and get the common elements. +
    + +
    +Hint 3 +Use the common elements as the new fixed array and keep merging with the rest of the arrays. +
    diff --git a/problems/longest-line-of-consecutive-one-in-matrix/README.md b/problems/longest-line-of-consecutive-one-in-matrix/README.md index 14d45d99d..fb11d2954 100644 --- a/problems/longest-line-of-consecutive-one-in-matrix/README.md +++ b/problems/longest-line-of-consecutive-one-in-matrix/README.md @@ -11,7 +11,22 @@ ## [562. Longest Line of Consecutive One in Matrix (Medium)](https://leetcode.com/problems/longest-line-of-consecutive-one-in-matrix "矩阵中最长的连续1线段") - +Given a 01 matrix M, find the longest line of consecutive one in the matrix. The line could be horizontal, vertical, diagonal or anti-diagonal. + +

    Example:
    +

    +Input:
    +[[0,1,1,0],
    + [0,1,1,0],
    + [0,0,0,1]]
    +Output: 3
    +
    +

    + +

    +Hint: +The number of elements in the given matrix will not exceed 10,000. +

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/longest-mountain-in-array/README.md b/problems/longest-mountain-in-array/README.md index 48a4c05de..275d9a58e 100644 --- a/problems/longest-mountain-in-array/README.md +++ b/problems/longest-mountain-in-array/README.md @@ -23,7 +23,7 @@ -

    Given an integer array arr, return the length of the longest subarray, which is a mountain. Return 0 if there is no mountain subarray.

    +

    Given an integer array arr, return the length of the longest subarray, which is a mountain. Return 0 if there is no mountain subarray.

     

    Example 1:

    @@ -46,7 +46,7 @@

    Constraints:

      -
    • 1 <= arr.length <= 104
    • +
    • 1 <= arr.length <= 104
    • 0 <= arr[i] <= 104
    diff --git a/problems/longest-palindromic-substring/README.md b/problems/longest-palindromic-substring/README.md index 397658072..369742823 100644 --- a/problems/longest-palindromic-substring/README.md +++ b/problems/longest-palindromic-substring/README.md @@ -48,7 +48,7 @@
    • 1 <= s.length <= 1000
    • -
    • s consist of only digits and English letters (lower-case and/or upper-case),
    • +
    • s consist of only digits and English letters.
    ### Related Topics diff --git a/problems/longest-repeating-substring/README.md b/problems/longest-repeating-substring/README.md index 807de6bda..73900af81 100644 --- a/problems/longest-repeating-substring/README.md +++ b/problems/longest-repeating-substring/README.md @@ -11,7 +11,50 @@ ## [1062. Longest Repeating Substring (Medium)](https://leetcode.com/problems/longest-repeating-substring "最长重复子串") +

    Given a string S, find out the length of the longest repeating substring(s). Return 0 if no repeating substring exists.

    +

     

    + +

    Example 1:

    + +
    +Input: "abcd"
    +Output: 0
    +Explanation: There is no repeating substring.
    +
    + +

    Example 2:

    + +
    +Input: "abbaba"
    +Output: 2
    +Explanation: The longest repeating substrings are "ab" and "ba", each of which occurs twice.
    +
    + +

    Example 3:

    + +
    +Input: "aabcaabdaab"
    +Output: 3
    +Explanation: The longest repeating substring is "aab", which occurs 3 times.
    +
    + +

    Example 4:

    + +
    +Input: "aaaaa"
    +Output: 4
    +Explanation: The longest repeating substring is "aaaa", which occurs twice.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. The string S consists of only lowercase English letters from 'a' - 'z'.
    2. +
    3. 1 <= S.length <= 1500
    4. +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/longest-substring-with-at-most-k-distinct-characters/README.md b/problems/longest-substring-with-at-most-k-distinct-characters/README.md index e4d82ba65..3acc212e7 100644 --- a/problems/longest-substring-with-at-most-k-distinct-characters/README.md +++ b/problems/longest-substring-with-at-most-k-distinct-characters/README.md @@ -11,7 +11,24 @@ ## [340. Longest Substring with At Most K Distinct Characters (Medium)](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters "至多包含 K 个不同字符的最长子串") +

    Given a string, find the length of the longest substring T that contains at most k distinct characters.

    +

    Example 1:

    + +
    +
    +Input: s = "eceba", k = 2
    +Output: 3
    +Explanation: T is "ece" which its length is 3.
    + +
    +

    Example 2:

    + +
    +Input: s = "aa", k = 1
    +Output: 2
    +Explanation: T is "aa" which its length is 2.
    +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/longest-substring-with-at-most-two-distinct-characters/README.md b/problems/longest-substring-with-at-most-two-distinct-characters/README.md index cf45ffa44..f0eb80c88 100644 --- a/problems/longest-substring-with-at-most-two-distinct-characters/README.md +++ b/problems/longest-substring-with-at-most-two-distinct-characters/README.md @@ -11,7 +11,21 @@ ## [159. Longest Substring with At Most Two Distinct Characters (Medium)](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters "至多包含两个不同字符的最长子串") +

    Given a string s , find the length of the longest substring t  that contains at most 2 distinct characters.

    +

    Example 1:

    + +
    Input: "eceba"
    +Output: 3
    +Explanation: t is "ece" which its length is 3.
    +
    + +

    Example 2:

    + +
    Input: "ccaabbb"
    +Output: 5
    +Explanation: t is "aabbb" which its length is 5.
    +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/loud-and-rich/README.md b/problems/loud-and-rich/README.md index 47338f113..051aa61ab 100644 --- a/problems/loud-and-rich/README.md +++ b/problems/loud-and-rich/README.md @@ -11,50 +11,48 @@ ## [851. Loud and Rich (Medium)](https://leetcode.com/problems/loud-and-rich "喧闹和富有") -

    In a group of N people (labelled 0, 1, 2, ..., N-1), each person has different amounts of money, and different levels of quietness.

    +

    There is a group of n people labeled from 0 to n - 1 where each person has a different amount of money and a different level of quietness.

    -

    For convenience, we'll call the person with label x, simply "person x".

    +

    You are given an array richer where richer[i] = [ai, bi] indicates that ai has more money than bi and an integer array quiet where quiet[i] is the quietness of the ith person. All the given data in richer are logically correct (i.e., the data will not lead you to a situation where x is richer than y and y is richer than x at the same time).

    -

    We'll say that richer[i] = [x, y] if person x definitely has more money than person y.  Note that richer may only be a subset of valid observations.

    - -

    Also, we'll say quiet[x] = q if person x has quietness q.

    - -

    Now, return answer, where answer[x] = y if y is the least quiet person (that is, the person y with the smallest value of quiet[y]), among all people who definitely have equal to or more money than person x.

    +

    Return an integer array answer where answer[x] = y if y is the least quiet person (that is, the person y with the smallest value of quiet[y]) among all people who definitely have equal to or more money than the person x.

     

    - -

    Example 1:

    -Input: richer = [[1,0],[2,1],[3,1],[3,7],[4,3],[5,3],[6,3]], quiet = [3,2,5,4,6,1,7,0]
    -Output: [5,5,2,5,4,5,6,7]
    -Explanation: 
    +Input: richer = [[1,0],[2,1],[3,1],[3,7],[4,3],[5,3],[6,3]], quiet = [3,2,5,4,6,1,7,0]
    +Output: [5,5,2,5,4,5,6,7]
    +Explanation: 
     answer[0] = 5.
     Person 5 has more money than 3, which has more money than 1, which has more money than 0.
    -The only person who is quieter (has lower quiet[x]) is person 7, but
    -it isn't clear if they have more money than person 0.
    -
    +The only person who is quieter (has lower quiet[x]) is person 7, but it is not clear if they have more money than person 0.
     answer[7] = 7.
    -Among all people that definitely have equal to or more money than person 7
    -(which could be persons 3, 4, 5, 6, or 7), the person who is the quietest (has lower quiet[x])
    -is person 7.
    -
    +Among all people that definitely have equal to or more money than person 7 (which could be persons 3, 4, 5, 6, or 7), the person who is the quietest (has lower quiet[x]) is person 7.
     The other answers can be filled out with similar reasoning.
     
    -
    - -

    Note:

    - -
      -
    1. 1 <= quiet.length = N <= 500
    2. -
    3. 0 <= quiet[i] < N, all quiet[i] are different.
    4. -
    5. 0 <= richer.length <= N * (N-1) / 2
    6. -
    7. 0 <= richer[i][j] < N
    8. -
    9. richer[i][0] != richer[i][1]
    10. -
    11. richer[i]'s are all different.
    12. -
    13. The observations in richer are all logically consistent.
    14. -
    + +

    Example 2:

    + +
    +Input: richer = [], quiet = [0]
    +Output: [0]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == quiet.length
    • +
    • 1 <= n <= 500
    • +
    • 0 <= quiet[i] < n
    • +
    • All the values of quiet are unique.
    • +
    • 0 <= richer.length <= n * (n - 1) / 2
    • +
    • 0 <= ai, bi < n
    • +
    • ai != bi
    • +
    • All the pairs of richer are unique.
    • +
    • The observations in richer are all logically consistent.
    • +
    ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/managers-with-at-least-5-direct-reports/README.md b/problems/managers-with-at-least-5-direct-reports/README.md index 5b6eaf68b..56112b8e5 100644 --- a/problems/managers-with-at-least-5-direct-reports/README.md +++ b/problems/managers-with-at-least-5-direct-reports/README.md @@ -11,7 +11,33 @@ ## [570. Managers with at Least 5 Direct Reports (Medium)](https://leetcode.com/problems/managers-with-at-least-5-direct-reports "至少有5名直接下属的经理") +

    The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.

    +
    ++------+----------+-----------+----------+
    +|Id    |Name 	  |Department |ManagerId |
    ++------+----------+-----------+----------+
    +|101   |John 	  |A 	      |null      |
    +|102   |Dan 	  |A 	      |101       |
    +|103   |James 	  |A 	      |101       |
    +|104   |Amy 	  |A 	      |101       |
    +|105   |Anne 	  |A 	      |101       |
    +|106   |Ron 	  |B 	      |101       |
    ++------+----------+-----------+----------+
    +
    + +

    Given the Employee table, write a SQL query that finds out managers with at least 5 direct report. For the above table, your SQL query should return:

    + +
    ++-------+
    +| Name  |
    ++-------+
    +| John  |
    ++-------+
    +
    + +

    Note:
    +No one would report to himself.

    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/market-analysis-i/README.md b/problems/market-analysis-i/README.md index aaeda6ebf..b5f72e68f 100644 --- a/problems/market-analysis-i/README.md +++ b/problems/market-analysis-i/README.md @@ -11,7 +11,97 @@ ## [1158. Market Analysis I (Medium)](https://leetcode.com/problems/market-analysis-i "市场分析 I") +

    Table: Users

    +
    ++----------------+---------+
    +| Column Name    | Type    |
    ++----------------+---------+
    +| user_id        | int     |
    +| join_date      | date    |
    +| favorite_brand | varchar |
    ++----------------+---------+
    +user_id is the primary key of this table.
    +This table has the info of the users of an online shopping website where users can sell and buy items.
    + +

    Table: Orders

    + +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| order_id      | int     |
    +| order_date    | date    |
    +| item_id       | int     |
    +| buyer_id      | int     |
    +| seller_id     | int     |
    ++---------------+---------+
    +order_id is the primary key of this table.
    +item_id is a foreign key to the Items table.
    +buyer_id and seller_id are foreign keys to the Users table.
    +
    + +

    Table: Items

    + +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| item_id       | int     |
    +| item_brand    | varchar |
    ++---------------+---------+
    +item_id is the primary key of this table.
    +
    + +

     

    + +

    Write an SQL query to find for each user, the join date and the number of orders they made as a buyer in 2019.

    + +

    The query result format is in the following example:

    + +
    +Users table:
    ++---------+------------+----------------+
    +| user_id | join_date  | favorite_brand |
    ++---------+------------+----------------+
    +| 1       | 2018-01-01 | Lenovo         |
    +| 2       | 2018-02-09 | Samsung        |
    +| 3       | 2018-01-19 | LG             |
    +| 4       | 2018-05-21 | HP             |
    ++---------+------------+----------------+
    +
    +Orders table:
    ++----------+------------+---------+----------+-----------+
    +| order_id | order_date | item_id | buyer_id | seller_id |
    ++----------+------------+---------+----------+-----------+
    +| 1        | 2019-08-01 | 4       | 1        | 2         |
    +| 2        | 2018-08-02 | 2       | 1        | 3         |
    +| 3        | 2019-08-03 | 3       | 2        | 3         |
    +| 4        | 2018-08-04 | 1       | 4        | 2         |
    +| 5        | 2018-08-04 | 1       | 3        | 4         |
    +| 6        | 2019-08-05 | 2       | 2        | 4         |
    ++----------+------------+---------+----------+-----------+
    +
    +Items table:
    ++---------+------------+
    +| item_id | item_brand |
    ++---------+------------+
    +| 1       | Samsung    |
    +| 2       | Lenovo     |
    +| 3       | LG         |
    +| 4       | HP         |
    ++---------+------------+
    +
    +Result table:
    ++-----------+------------+----------------+
    +| buyer_id  | join_date  | orders_in_2019 |
    ++-----------+------------+----------------+
    +| 1         | 2018-01-01 | 1              |
    +| 2         | 2018-02-09 | 2              |
    +| 3         | 2018-01-19 | 0              |
    +| 4         | 2018-05-21 | 0              |
    ++-----------+------------+----------------+
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/market-analysis-ii/README.md b/problems/market-analysis-ii/README.md index eb6171338..f1c2f278c 100644 --- a/problems/market-analysis-ii/README.md +++ b/problems/market-analysis-ii/README.md @@ -11,7 +11,102 @@ ## [1159. Market Analysis II (Hard)](https://leetcode.com/problems/market-analysis-ii "市场分析 II") +

    Table: Users

    +
    ++----------------+---------+
    +| Column Name    | Type    |
    ++----------------+---------+
    +| user_id        | int     |
    +| join_date      | date    |
    +| favorite_brand | varchar |
    ++----------------+---------+
    +user_id is the primary key of this table.
    +This table has the info of the users of an online shopping website where users can sell and buy items.
    + +

    Table: Orders

    + +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| order_id      | int     |
    +| order_date    | date    |
    +| item_id       | int     |
    +| buyer_id      | int     |
    +| seller_id     | int     |
    ++---------------+---------+
    +order_id is the primary key of this table.
    +item_id is a foreign key to the Items table.
    +buyer_id and seller_id are foreign keys to the Users table.
    +
    + +

    Table: Items

    + +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| item_id       | int     |
    +| item_brand    | varchar |
    ++---------------+---------+
    +item_id is the primary key of this table.
    +
    + +

     

    + +

    Write an SQL query to find for each user, whether the brand of the second item (by date) they sold is their favorite brand. If a user sold less than two items, report the answer for that user as no.

    + +

    It is guaranteed that no seller sold more than one item on a day.

    + +

    The query result format is in the following example:

    + +
    +Users table:
    ++---------+------------+----------------+
    +| user_id | join_date  | favorite_brand |
    ++---------+------------+----------------+
    +| 1       | 2019-01-01 | Lenovo         |
    +| 2       | 2019-02-09 | Samsung        |
    +| 3       | 2019-01-19 | LG             |
    +| 4       | 2019-05-21 | HP             |
    ++---------+------------+----------------+
    +
    +Orders table:
    ++----------+------------+---------+----------+-----------+
    +| order_id | order_date | item_id | buyer_id | seller_id |
    ++----------+------------+---------+----------+-----------+
    +| 1        | 2019-08-01 | 4       | 1        | 2         |
    +| 2        | 2019-08-02 | 2       | 1        | 3         |
    +| 3        | 2019-08-03 | 3       | 2        | 3         |
    +| 4        | 2019-08-04 | 1       | 4        | 2         |
    +| 5        | 2019-08-04 | 1       | 3        | 4         |
    +| 6        | 2019-08-05 | 2       | 2        | 4         |
    ++----------+------------+---------+----------+-----------+
    +
    +Items table:
    ++---------+------------+
    +| item_id | item_brand |
    ++---------+------------+
    +| 1       | Samsung    |
    +| 2       | Lenovo     |
    +| 3       | LG         |
    +| 4       | HP         |
    ++---------+------------+
    +
    +Result table:
    ++-----------+--------------------+
    +| seller_id | 2nd_item_fav_brand |
    ++-----------+--------------------+
    +| 1         | no                 |
    +| 2         | yes                |
    +| 3         | yes                |
    +| 4         | no                 |
    ++-----------+--------------------+
    +
    +The answer for the user with id 1 is no because they sold nothing.
    +The answer for the users with id 2 and 3 is yes because the brands of their second sold items are their favorite brands.
    +The answer for the user with id 4 is no because the brand of their second sold item is not their favorite brand.
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/max-consecutive-ones-ii/README.md b/problems/max-consecutive-ones-ii/README.md index edfc9e4a2..6c28cd7d7 100644 --- a/problems/max-consecutive-ones-ii/README.md +++ b/problems/max-consecutive-ones-ii/README.md @@ -11,7 +11,29 @@ ## [487. Max Consecutive Ones II (Medium)](https://leetcode.com/problems/max-consecutive-ones-ii "最大连续1的个数 II") +

    +Given a binary array, find the maximum number of consecutive 1s in this array if you can flip at most one 0. +

    +

    Example 1:
    +

    +Input: [1,0,1,1,0]
    +Output: 4
    +Explanation: Flip the first zero will get the the maximum number of consecutive 1s.
    +    After flipping, the maximum number of consecutive 1s is 4.
    +
    +

    + +

    Note: +

      +
    • The input array will only contain 0 and 1.
    • +
    • The length of input array is a positive integer and will not exceed 10,000
    • +
    +

    + +

    Follow up:
    +What if the input numbers come in one by one as an infinite stream? In other words, you can't store all numbers coming from the stream as it's too large to hold in memory. Could you solve it efficiently? +

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/max-stack/README.md b/problems/max-stack/README.md index 41c4fb872..82a74168f 100644 --- a/problems/max-stack/README.md +++ b/problems/max-stack/README.md @@ -11,7 +11,40 @@ ## [716. Max Stack (Easy)](https://leetcode.com/problems/max-stack "最大栈") +

    Design a max stack that supports push, pop, top, peekMax and popMax.

    +

    +

      +
    1. push(x) -- Push element x onto stack.
    2. +
    3. pop() -- Remove the element on top of the stack and return it.
    4. +
    5. top() -- Get the element on the top.
    6. +
    7. peekMax() -- Retrieve the maximum element in the stack.
    8. +
    9. popMax() -- Retrieve the maximum element in the stack, and remove it. If you find more than one maximum elements, only remove the top-most one.
    10. +
    +

    + +

    Example 1:
    +

    +MaxStack stack = new MaxStack();
    +stack.push(5); 
    +stack.push(1);
    +stack.push(5);
    +stack.top(); -> 5
    +stack.popMax(); -> 5
    +stack.top(); -> 1
    +stack.peekMax(); -> 5
    +stack.pop(); -> 1
    +stack.top(); -> 5
    +
    +

    + +

    Note:
    +

      +
    1. -1e7 <= x <= 1e7
    2. +
    3. Number of operations won't exceed 10000.
    4. +
    5. The last four operations won't be called when stack is empty.
    6. +
    +

    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/maximum-average-subarray-ii/README.md b/problems/maximum-average-subarray-ii/README.md index da5eb5464..30b24b8d5 100644 --- a/problems/maximum-average-subarray-ii/README.md +++ b/problems/maximum-average-subarray-ii/README.md @@ -11,8 +11,31 @@ ## [644. Maximum Average Subarray II (Hard)](https://leetcode.com/problems/maximum-average-subarray-ii "子数组最大平均数 II") +

    +Given an array consisting of n integers, find the contiguous subarray whose length is greater than or equal to k that has the maximum average value. And you need to output the maximum average value. +

    +

    Example 1:
    +

    +Input: [1,12,-5,-6,50,3], k = 4
    +Output: 12.75
    +Explanation:
    +when length is 5, maximum average value is 10.8,
    +when length is 6, maximum average value is 9.16667.
    +Thus return 12.75.
    +
    +

    + + +

    Note:
    +

      +
    1. 1 <= k <= n <= 10,000.
    2. +
    3. Elements of the given array will be in range [-10,000, 10,000].
    4. +
    5. The answer with the calculation error less than 10-5 will be accepted.
    6. +
    +

    + ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] diff --git a/problems/maximum-average-subtree/README.md b/problems/maximum-average-subtree/README.md index 6c76109a0..1d4060c3f 100644 --- a/problems/maximum-average-subtree/README.md +++ b/problems/maximum-average-subtree/README.md @@ -11,7 +11,35 @@ ## [1120. Maximum Average Subtree (Medium)](https://leetcode.com/problems/maximum-average-subtree "子树的最大平均值") +

    Given the root of a binary tree, find the maximum average value of any subtree of that tree.

    +

    (A subtree of a tree is any node of that tree plus all its descendants. The average value of a tree is the sum of its values, divided by the number of nodes.)

    + +

     

    + +

    Example 1:

    + +

    + +
    +Input: [5,6,1]
    +Output: 6.00000
    +Explanation: 
    +For the node with value = 5 we have an average of (5 + 6 + 1) / 3 = 4.
    +For the node with value = 6 we have an average of 6 / 1 = 6.
    +For the node with value = 1 we have an average of 1 / 1 = 1.
    +So the answer is 6 which is the maximum.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. The number of nodes in the tree is between 1 and 5000.
    2. +
    3. Each node will have a value between 0 and 100000.
    4. +
    5. Answers will be accepted as correct if they are within 10^-5 of the correct answer.
    6. +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/maximum-compatibility-score-sum/README.md b/problems/maximum-compatibility-score-sum/README.md new file mode 100644 index 000000000..7c86bc6c7 --- /dev/null +++ b/problems/maximum-compatibility-score-sum/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](../largest-number-after-mutating-substring "Largest Number After Mutating Substring") +                 +[Next >](../delete-duplicate-folders-in-system "Delete Duplicate Folders in System") + +## [1947. Maximum Compatibility Score Sum (Medium)](https://leetcode.com/problems/maximum-compatibility-score-sum "最大兼容性评分和") + +

    There is a survey that consists of n questions where each question's answer is either 0 (no) or 1 (yes).

    + +

    The survey was given to m students numbered from 0 to m - 1 and m mentors numbered from 0 to m - 1. The answers of the students are represented by a 2D integer array students where students[i] is an integer array that contains the answers of the ith student (0-indexed). The answers of the mentors are represented by a 2D integer array mentors where mentors[j] is an integer array that contains the answers of the jth mentor (0-indexed).

    + +

    Each student will be assigned to one mentor, and each mentor will have one student assigned to them. The compatibility score of a student-mentor pair is the number of answers that are the same for both the student and the mentor.

    + +
      +
    • For example, if the student's answers were [1, 0, 1] and the mentor's answers were [0, 0, 1], then their compatibility score is 2 because only the second and the third answers are the same.
    • +
    + +

    You are tasked with finding the optimal student-mentor pairings to maximize the sum of the compatibility scores.

    + +

    Given students and mentors, return the maximum compatibility score sum that can be achieved.

    + +

     

    +

    Example 1:

    + +
    +Input: students = [[1,1,0],[1,0,1],[0,0,1]], mentors = [[1,0,0],[0,0,1],[1,1,0]]
    +Output: 8
    +Explanation: We assign students to mentors in the following way:
    +- student 0 to mentor 2 with a compatibility score of 3.
    +- student 1 to mentor 0 with a compatibility score of 2.
    +- student 2 to mentor 1 with a compatibility score of 3.
    +The compatibility score sum is 3 + 2 + 3 = 8.
    +
    + +

    Example 2:

    + +
    +Input: students = [[0,0],[0,0],[0,0]], mentors = [[1,1],[1,1],[1,1]]
    +Output: 0
    +Explanation: The compatibility score of any student-mentor pair is 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == students.length == mentors.length
    • +
    • n == students[i].length == mentors[j].length
    • +
    • 1 <= m, n <= 8
    • +
    • students[i][k] is either 0 or 1.
    • +
    • mentors[j][k] is either 0 or 1.
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] + +### Hints +
    +Hint 1 +Calculate the compatibility score for each student-mentor pair. +
    + +
    +Hint 2 +Try every permutation of students with the original mentors array. +
    diff --git a/problems/maximum-depth-of-n-ary-tree/README.md b/problems/maximum-depth-of-n-ary-tree/README.md index 478fe7ee2..77baede93 100644 --- a/problems/maximum-depth-of-n-ary-tree/README.md +++ b/problems/maximum-depth-of-n-ary-tree/README.md @@ -40,8 +40,8 @@

    Constraints:

      +
    • The total number of nodes is in the range [0, 104].
    • The depth of the n-ary tree is less than or equal to 1000.
    • -
    • The total number of nodes is between [0, 104].
    ### Related Topics diff --git a/problems/maximum-difference-between-node-and-ancestor/README.md b/problems/maximum-difference-between-node-and-ancestor/README.md index eab3e459c..0b9b3cbd1 100644 --- a/problems/maximum-difference-between-node-and-ancestor/README.md +++ b/problems/maximum-difference-between-node-and-ancestor/README.md @@ -11,9 +11,9 @@ ## [1026. Maximum Difference Between Node and Ancestor (Medium)](https://leetcode.com/problems/maximum-difference-between-node-and-ancestor "节点与其祖先之间的最大差值") -

    Given the root of a binary tree, find the maximum value V for which there exist different nodes A and B where V = |A.val - B.val| and A is an ancestor of B.

    +

    Given the root of a binary tree, find the maximum value v for which there exist different nodes a and b where v = |a.val - b.val| and a is an ancestor of b.

    -

    A node A is an ancestor of B if either: any child of A is equal to B, or any child of A is an ancestor of B.

    +

    A node a is an ancestor of b if either: any child of a is equal to b or any child of a is an ancestor of b.

     

    Example 1:

    @@ -39,7 +39,7 @@ Among all possible differences, the maximum value of 7 is obtained by |8 - 1| =

    Constraints:

      -
    • The number of nodes in the tree is in the range [2, 5000].
    • +
    • The number of nodes in the tree is in the range [2, 5000].
    • 0 <= Node.val <= 105
    diff --git a/problems/maximum-distance-in-arrays/README.md b/problems/maximum-distance-in-arrays/README.md index 09b43d3c0..a91f15f03 100644 --- a/problems/maximum-distance-in-arrays/README.md +++ b/problems/maximum-distance-in-arrays/README.md @@ -11,7 +11,28 @@ ## [624. Maximum Distance in Arrays (Medium)](https://leetcode.com/problems/maximum-distance-in-arrays "数组列表中的最大距离") +

    +Given m arrays, and each array is sorted in ascending order. Now you can pick up two integers from two different arrays (each array picks one) and calculate the distance. We define the distance between two integers a and b to be their absolute difference |a-b|. Your task is to find the maximum distance. +

    +

    Example 1:
    +

    Input: 
    +[[1,2,3],
    + [4,5],
    + [1,2,3]]
    +Output: 4
    +Explanation: 
    +One way to reach the maximum distance 4 is to pick 1 in the first or third array and pick 5 in the second array.
    +
    +

    + +

    Note:
    +

      +
    1. Each given array will have at least 1 number. There will be at least two non-empty arrays.
    2. +
    3. The total number of the integers in all the m arrays will be in the range of [2, 10000].
    4. +
    5. The integers in the m arrays will be in the range of [-10000, 10000].
    6. +
    +

    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/maximum-genetic-difference-query/README.md b/problems/maximum-genetic-difference-query/README.md new file mode 100644 index 000000000..856964ac8 --- /dev/null +++ b/problems/maximum-genetic-difference-query/README.md @@ -0,0 +1,64 @@ + + + + + + + +[< Previous](../maximum-number-of-points-with-cost "Maximum Number of Points with Cost") +                 +[Next >](../users-that-actively-request-confirmation-messages "Users That Actively Request Confirmation Messages") + +## [1938. Maximum Genetic Difference Query (Hard)](https://leetcode.com/problems/maximum-genetic-difference-query "查询最大基因差") + +

    There is a rooted tree consisting of n nodes numbered 0 to n - 1. Each node's number denotes its unique genetic value (i.e. the genetic value of node x is x). The genetic difference between two genetic values is defined as the bitwise-XOR of their values. You are given the integer array parents, where parents[i] is the parent for node i. If node x is the root of the tree, then parents[x] == -1.

    + +

    You are also given the array queries where queries[i] = [nodei, vali]. For each query i, find the maximum genetic difference between vali and pi, where pi is the genetic value of any node that is on the path between nodei and the root (including nodei and the root). More formally, you want to maximize vali XOR pi.

    + +

    Return an array ans where ans[i] is the answer to the ith query.

    + +

     

    +

    Example 1:

    + +
    +Input: parents = [-1,0,1,1], queries = [[0,2],[3,2],[2,5]]
    +Output: [2,3,7]
    +Explanation: The queries are processed as follows:
    +- [0,2]: The node with the maximum genetic difference is 0, with a difference of 2 XOR 0 = 2.
    +- [3,2]: The node with the maximum genetic difference is 1, with a difference of 2 XOR 1 = 3.
    +- [2,5]: The node with the maximum genetic difference is 2, with a difference of 5 XOR 2 = 7.
    +
    + +

    Example 2:

    + +
    +Input: parents = [3,7,-1,2,0,7,0,2], queries = [[4,6],[1,15],[0,5]]
    +Output: [6,14,7]
    +Explanation: The queries are processed as follows:
    +- [4,6]: The node with the maximum genetic difference is 0, with a difference of 6 XOR 0 = 6.
    +- [1,15]: The node with the maximum genetic difference is 1, with a difference of 15 XOR 1 = 14.
    +- [0,5]: The node with the maximum genetic difference is 2, with a difference of 5 XOR 2 = 7.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= parents.length <= 105
    • +
    • 0 <= parents[i] <= parents.length - 1 for every node i that is not the root.
    • +
    • parents[root] == -1
    • +
    • 1 <= queries.length <= 3 * 104
    • +
    • 0 <= nodei <= parents.length - 1
    • +
    • 0 <= vali <= 2 * 105
    • +
    + +### Hints +
    +Hint 1 +How can we use a trie to store all the XOR values in the path from a node to the root? +
    + +
    +Hint 2 +How can we dynamically add the XOR values with a DFS search? +
    diff --git a/problems/maximum-number-of-ones/README.md b/problems/maximum-number-of-ones/README.md index e354c8c8e..c6542fe02 100644 --- a/problems/maximum-number-of-ones/README.md +++ b/problems/maximum-number-of-ones/README.md @@ -11,7 +11,43 @@ ## [1183. Maximum Number of Ones (Hard)](https://leetcode.com/problems/maximum-number-of-ones "矩阵中 1 的最大数量") +

    Consider a matrix M with dimensions width * height, such that every cell has value 0 or 1, and any square sub-matrix of M of size sideLength * sideLength has at most maxOnes ones.

    +

    Return the maximum possible number of ones that the matrix M can have.

    + +

     

    +

    Example 1:

    + +
    +Input: width = 3, height = 3, sideLength = 2, maxOnes = 1
    +Output: 4
    +Explanation:
    +In a 3*3 matrix, no 2*2 sub-matrix can have more than 1 one.
    +The best solution that has 4 ones is:
    +[1,0,1]
    +[0,0,0]
    +[1,0,1]
    +
    + +

    Example 2:

    + +
    +Input: width = 3, height = 3, sideLength = 2, maxOnes = 2
    +Output: 6
    +Explanation:
    +[1,0,1]
    +[1,0,1]
    +[1,0,1]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= width, height <= 100
    • +
    • 1 <= sideLength <= width, height
    • +
    • 0 <= maxOnes <= sideLength * sideLength
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/maximum-number-of-points-with-cost/README.md b/problems/maximum-number-of-points-with-cost/README.md new file mode 100644 index 000000000..1893a4388 --- /dev/null +++ b/problems/maximum-number-of-points-with-cost/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../add-minimum-number-of-rungs "Add Minimum Number of Rungs") +                 +[Next >](../maximum-genetic-difference-query "Maximum Genetic Difference Query") + +## [1937. Maximum Number of Points with Cost (Medium)](https://leetcode.com/problems/maximum-number-of-points-with-cost "扣分后的最大得分") + +

    You are given an m x n integer matrix points (0-indexed). Starting with 0 points, you want to maximize the number of points you can get from the matrix.

    + +

    To gain points, you must pick one cell in each row. Picking the cell at coordinates (r, c) will add points[r][c] to your score.

    + +

    However, you will lose points if you pick a cell too far from the cell that you picked in the previous row. For every two adjacent rows r and r + 1 (where 0 <= r < m - 1), picking cells at coordinates (r, c1) and (r + 1, c2) will subtract abs(c1 - c2) from your score.

    + +

    Return the maximum number of points you can achieve.

    + +

    abs(x) is defined as:

    + +
      +
    • x for x >= 0.
    • +
    • -x for x < 0.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: points = [[1,2,3],[1,5,1],[3,1,1]]
    +Output: 9
    +Explanation:
    +The blue cells denote the optimal cells to pick, which have coordinates (0, 2), (1, 1), and (2, 0).
    +You add 3 + 5 + 3 = 11 to your score.
    +However, you must subtract abs(2 - 1) + abs(1 - 0) = 2 from your score.
    +Your final score is 11 - 2 = 9.
    +
    + +

    Example 2:

    + +
    +Input: points = [[1,5],[2,3],[4,2]]
    +Output: 11
    +Explanation:
    +The blue cells denote the optimal cells to pick, which have coordinates (0, 1), (1, 1), and (2, 0).
    +You add 5 + 3 + 4 = 12 to your score.
    +However, you must subtract abs(1 - 1) + abs(1 - 0) = 1 from your score.
    +Your final score is 12 - 1 = 11.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == points.length
    • +
    • n == points[r].length
    • +
    • 1 <= m, n <= 105
    • +
    • 1 <= m * n <= 105
    • +
    • 0 <= points[r][c] <= 105
    • +
    + +### Hints +
    +Hint 1 +Try using dynamic programming. +
    + +
    +Hint 2 +dp[i][j] is the maximum number of points you can have if points[i][j] is the most recent cell you picked. +
    diff --git a/problems/maximum-number-of-weeks-for-which-you-can-work/README.md b/problems/maximum-number-of-weeks-for-which-you-can-work/README.md new file mode 100644 index 000000000..6be231e25 --- /dev/null +++ b/problems/maximum-number-of-weeks-for-which-you-can-work/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../three-divisors "Three Divisors") +                 +[Next >](../minimum-garden-perimeter-to-collect-enough-apples "Minimum Garden Perimeter to Collect Enough Apples") + +## [1953. Maximum Number of Weeks for Which You Can Work (Medium)](https://leetcode.com/problems/maximum-number-of-weeks-for-which-you-can-work "你可以工作的最大周数") + +

    There are n projects numbered from 0 to n - 1. You are given an integer array milestones where each milestones[i] denotes the number of milestones the ith project has.

    + +

    You can work on the projects following these two rules:

    + +
      +
    • Every week, you will finish exactly one milestone of one project. You must work every week.
    • +
    • You cannot work on two milestones from the same project for two consecutive weeks.
    • +
    + +

    Once all the milestones of all the projects are finished, or if the only milestones that you can work on will cause you to violate the above rules, you will stop working. Note that you may not be able to finish every project's milestones due to these constraints.

    + +

    Return the maximum number of weeks you would be able to work on the projects without violating the rules mentioned above.

    + +

     

    +

    Example 1:

    + +
    +Input: milestones = [1,2,3]
    +Output: 6
    +Explanation: One possible scenario is:
    +​​​​- During the 1st week, you will work on a milestone of project 0.
    +- During the 2nd week, you will work on a milestone of project 2.
    +- During the 3rd week, you will work on a milestone of project 1.
    +- During the 4th week, you will work on a milestone of project 2.
    +- During the 5th week, you will work on a milestone of project 1.
    +- During the 6th week, you will work on a milestone of project 2.
    +The total number of weeks is 6.
    +
    + +

    Example 2:

    + +
    +Input: milestones = [5,2,1]
    +Output: 7
    +Explanation: One possible scenario is:
    +- During the 1st week, you will work on a milestone of project 0.
    +- During the 2nd week, you will work on a milestone of project 1.
    +- During the 3rd week, you will work on a milestone of project 0.
    +- During the 4th week, you will work on a milestone of project 1.
    +- During the 5th week, you will work on a milestone of project 0.
    +- During the 6th week, you will work on a milestone of project 2.
    +- During the 7th week, you will work on a milestone of project 0.
    +The total number of weeks is 7.
    +Note that you cannot work on the last milestone of project 0 on 8th week because it would violate the rules.
    +Thus, one milestone in project 0 will remain unfinished.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == milestones.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= milestones[i] <= 109
    • +
    + +### Hints +
    +Hint 1 +Work on the project with the largest number of milestones as long as it is possible. +
    + +
    +Hint 2 +Does the project with the largest number of milestones affect the number of weeks? +
    diff --git a/problems/maximum-number-of-words-you-can-type/README.md b/problems/maximum-number-of-words-you-can-type/README.md new file mode 100644 index 000000000..d7f882682 --- /dev/null +++ b/problems/maximum-number-of-words-you-can-type/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../confirmation-rate "Confirmation Rate") +                 +[Next >](../add-minimum-number-of-rungs "Add Minimum Number of Rungs") + +## [1935. Maximum Number of Words You Can Type (Easy)](https://leetcode.com/problems/maximum-number-of-words-you-can-type "可以输入的最大单词数") + +

    There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly.

    + +

    Given a string text of words separated by a single space (no leading or trailing spaces) and a string brokenLetters of all distinct letter keys that are broken, return the number of words in text you can fully type using this keyboard.

    + +

     

    +

    Example 1:

    + +
    +Input: text = "hello world", brokenLetters = "ad"
    +Output: 1
    +Explanation: We cannot type "world" because the 'd' key is broken.
    +
    + +

    Example 2:

    + +
    +Input: text = "leet code", brokenLetters = "lt"
    +Output: 1
    +Explanation: We cannot type "leet" because the 'l' and 't' keys are broken.
    +
    + +

    Example 3:

    + +
    +Input: text = "leet code", brokenLetters = "e"
    +Output: 0
    +Explanation: We cannot type either word because the 'e' key is broken.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= text.length <= 104
    • +
    • 0 <= brokenLetters.length <= 26
    • +
    • text consists of words separated by a single space without any leading or trailing spaces.
    • +
    • Each word only consists of lowercase English letters.
    • +
    • brokenLetters consists of distinct lowercase English letters.
    • +
    + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Check each word separately if it can be typed. +
    + +
    +Hint 2 +A word can be typed if all its letters are not broken. +
    diff --git a/problems/maximum-of-minimum-values-in-all-subarrays/README.md b/problems/maximum-of-minimum-values-in-all-subarrays/README.md new file mode 100644 index 000000000..71932b7b0 --- /dev/null +++ b/problems/maximum-of-minimum-values-in-all-subarrays/README.md @@ -0,0 +1,30 @@ + + + + + + + +[< Previous](../strong-friendship "Strong Friendship") +                 +[Next >](../all-the-pairs-with-the-maximum-number-of-common-followers "All the Pairs With the Maximum Number of Common Followers") + +## [1950. Maximum of Minimum Values in All Subarrays (Medium)](https://leetcode.com/problems/maximum-of-minimum-values-in-all-subarrays "所有子数组最小值中的最大值") + + + +### Hints +
    +Hint 1 +Imagine the array is empty, and each element is coming to its index one by one, starting with the smallest element. +
    + +
    +Hint 2 +For each coming element nums[i], calculate L and R, the indices of the first smallest elements on the left and the right respectively. +
    + +
    +Hint 3 +The answer of the queries from 1 to R-L+1 will be at least this element. +
    diff --git a/problems/maximum-product-of-splitted-binary-tree/README.md b/problems/maximum-product-of-splitted-binary-tree/README.md index e82c128a5..f9f32841c 100644 --- a/problems/maximum-product-of-splitted-binary-tree/README.md +++ b/problems/maximum-product-of-splitted-binary-tree/README.md @@ -11,15 +11,15 @@ ## [1339. Maximum Product of Splitted Binary Tree (Medium)](https://leetcode.com/problems/maximum-product-of-splitted-binary-tree "分裂二叉树的最大乘积") -

    Given a binary tree root. Split the binary tree into two subtrees by removing 1 edge such that the product of the sums of the subtrees are maximized.

    +

    Given the root of a binary tree, split the binary tree into two subtrees by removing one edge such that the product of the sums of the subtrees is maximized.

    -

    Since the answer may be too large, return it modulo 10^9 + 7.

    +

    Return the maximum product of the sums of the two subtrees. Since the answer may be too large, return it modulo 109 + 7.

    + +

    Note that you need to maximize the answer before taking the mod and not after taking it.

     

    Example 1:

    - -

    - +
     Input: root = [1,2,3,4,5,6]
     Output: 110
    @@ -27,13 +27,11 @@
     

    Example 2:

    - -

    - +
     Input: root = [1,null,2,3,4,null,null,5,6]
     Output: 90
    -Explanation:  Remove the red edge and get 2 binary trees with sum 15 and 6.Their product is 90 (15*6)
    +Explanation: Remove the red edge and get 2 binary trees with sum 15 and 6.Their product is 90 (15*6)
     

    Example 3:

    @@ -54,8 +52,8 @@

    Constraints:

      -
    • Each tree has at most 50000 nodes and at least 2 nodes.
    • -
    • Each node's value is between [1, 10000].
    • +
    • The number of nodes in the tree is in the range [2, 5 * 104].
    • +
    • 1 <= Node.val <= 104
    ### Related Topics diff --git a/problems/maximum-size-subarray-sum-equals-k/README.md b/problems/maximum-size-subarray-sum-equals-k/README.md index f290e5b3d..0a84dae57 100644 --- a/problems/maximum-size-subarray-sum-equals-k/README.md +++ b/problems/maximum-size-subarray-sum-equals-k/README.md @@ -11,7 +11,28 @@ ## [325. Maximum Size Subarray Sum Equals k (Medium)](https://leetcode.com/problems/maximum-size-subarray-sum-equals-k "和等于 k 的最长子数组长度") +

    Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn't one, return 0 instead.

    +

    Note:
    +The sum of the entire nums array is guaranteed to fit within the 32-bit signed integer range.

    + +

    Example 1:

    + +
    +Input: nums = [1, -1, 5, -2, 3], k = 3
    +Output: 4 
    +Explanation: The subarray [1, -1, 5, -2] sums to 3 and is the longest.
    +
    + +

    Example 2:

    + +
    +Input: nums = [-2, -1, 2, 1], k = 1
    +Output: 2 
    +Explanation: The subarray [-1, 2] sums to 1 and is the longest.
    + +

    Follow Up:
    +Can you do it in O(n) time?

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/maximum-subarray/README.md b/problems/maximum-subarray/README.md index 4685ab121..25bc3d99f 100644 --- a/problems/maximum-subarray/README.md +++ b/problems/maximum-subarray/README.md @@ -13,6 +13,8 @@

    Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.

    +

    A subarray is a contiguous part of an array.

    +

     

    Example 1:

    @@ -45,7 +47,7 @@

     

    -Follow up: If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle. +

    Follow up: If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle.

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/maximum-sum-bst-in-binary-tree/README.md b/problems/maximum-sum-bst-in-binary-tree/README.md index a102ef922..0cbcdad6b 100644 --- a/problems/maximum-sum-bst-in-binary-tree/README.md +++ b/problems/maximum-sum-bst-in-binary-tree/README.md @@ -11,13 +11,13 @@ ## [1373. Maximum Sum BST in Binary Tree (Hard)](https://leetcode.com/problems/maximum-sum-bst-in-binary-tree "二叉搜索子树的最大键值和") -

    Given a binary tree root, the task is to return the maximum sum of all keys of any sub-tree which is also a Binary Search Tree (BST).

    +

    Given a binary tree root, return the maximum sum of all keys of any sub-tree which is also a Binary Search Tree (BST).

    Assume a BST is defined as follows:

      -
    • The left subtree of a node contains only nodes with keys less than the node's key.
    • -
    • The right subtree of a node contains only nodes with keys greater than the node's key.
    • +
    • The left subtree of a node contains only nodes with keys less than the node's key.
    • +
    • The right subtree of a node contains only nodes with keys greater than the node's key.
    • Both the left and right subtrees must also be binary search trees.
    @@ -68,8 +68,8 @@

    Constraints:

      -
    • The given binary tree will have between 1 and 40000 nodes.
    • -
    • Each node's value is between [-4 * 10^4 , 4 * 10^4].
    • +
    • The number of nodes in the tree is in the range [1, 4 * 104].
    • +
    • -4 * 104 <= Node.val <= 4 * 104
    ### Related Topics diff --git a/problems/maximum-vacation-days/README.md b/problems/maximum-vacation-days/README.md index 124506545..3f8266116 100644 --- a/problems/maximum-vacation-days/README.md +++ b/problems/maximum-vacation-days/README.md @@ -11,7 +11,65 @@ ## [568. Maximum Vacation Days (Hard)](https://leetcode.com/problems/maximum-vacation-days "最大休假天数") +

    +LeetCode wants to give one of its best employees the option to travel among N cities to collect algorithm problems. But all work and no play makes Jack a dull boy, you could take vacations in some particular cities and weeks. Your job is to schedule the traveling to maximize the number of vacation days you could take, but there are certain rules and restrictions you need to follow. +

    +

    Rules and restrictions:
    +

      +
    1. You can only travel among N cities, represented by indexes from 0 to N-1. Initially, you are in the city indexed 0 on Monday.
    2. +
    3. The cities are connected by flights. The flights are represented as a N*N matrix (not necessary symmetrical), called flights representing the airline status from the city i to the city j. If there is no flight from the city i to the city j, flights[i][j] = 0; Otherwise, flights[i][j] = 1. Also, flights[i][i] = 0 for all i.
    4. +
    5. You totally have K weeks (each week has 7 days) to travel. You can only take flights at most once per day and can only take flights on each week's Monday morning. Since flight time is so short, we don't consider the impact of flight time.
    6. +
    7. For each city, you can only have restricted vacation days in different weeks, given an N*K matrix called days representing this relationship. For the value of days[i][j], it represents the maximum days you could take vacation in the city i in the week j.
    8. +
    +

    + +

    You're given the flights matrix and days matrix, and you need to output the maximum vacation days you could take during K weeks.

    + +

    Example 1:
    +

    +Input:flights = [[0,1,1],[1,0,1],[1,1,0]], days = [[1,3,1],[6,0,3],[3,3,3]]
    +Output: 12
    +Explanation: 
    Ans = 6 + 3 + 3 = 12.
    +One of the best strategies is: +1st week : fly from city 0 to city 1 on Monday, and play 6 days and work 1 day.
    (Although you start at city 0, we could also fly to and start at other cities since it is Monday.) +2nd week : fly from city 1 to city 2 on Monday, and play 3 days and work 4 days. +3rd week : stay at city 2, and play 3 days and work 4 days. +
    +

    + +

    Example 2:
    +

    +Input:flights = [[0,0,0],[0,0,0],[0,0,0]], days = [[1,1,1],[7,7,7],[7,7,7]]
    +Output: 3
    +Explanation: 
    Ans = 1 + 1 + 1 = 3.
    +Since there is no flights enable you to move to another city, you have to stay at city 0 for the whole 3 weeks.
    For each week, you only have one day to play and six days to work.
    So the maximum number of vacation days is 3. +
    +

    + +

    Example 3:
    +

    +Input:flights = [[0,1,1],[1,0,1],[1,1,0]], days = [[7,0,0],[0,7,0],[0,0,7]]
    +Output: 21
    +Explanation:
    Ans = 7 + 7 + 7 = 21
    +One of the best strategies is: +1st week : stay at city 0, and play 7 days. +2nd week : fly from city 0 to city 1 on Monday, and play 7 days. +3rd week : fly from city 1 to city 2 on Monday, and play 7 days. +
    +

    + + +

    Note:
    +

      +
    1. N and K are positive integers, which are in the range of [1, 100].
    2. +
    3. In the matrix flights, all the values are integers in the range of [0, 1].
    4. +
    5. In the matrix days, all the values are integers in the range [0, 7].
    6. +
    7. You could stay at a city beyond the number of vacation days, but you should work on the extra days, which won't be counted as vacation days.
    8. +
    9. If you fly from the city A to the city B and take the vacation on that day, the deduction towards vacation days will count towards the vacation days of city B in that week.
    10. +
    11. We don't consider the impact of flight hours towards the calculation of vacation days.
    12. +
    +

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/median-employee-salary/README.md b/problems/median-employee-salary/README.md index e1416c6fb..1afeed80d 100644 --- a/problems/median-employee-salary/README.md +++ b/problems/median-employee-salary/README.md @@ -11,7 +11,45 @@ ## [569. Median Employee Salary (Hard)](https://leetcode.com/problems/median-employee-salary "员工薪水中位数") +

    The Employee table holds all employees. The employee table has three columns: Employee Id, Company Name, and Salary.

    +
    ++-----+------------+--------+
    +|Id   | Company    | Salary |
    ++-----+------------+--------+
    +|1    | A          | 2341   |
    +|2    | A          | 341    |
    +|3    | A          | 15     |
    +|4    | A          | 15314  |
    +|5    | A          | 451    |
    +|6    | A          | 513    |
    +|7    | B          | 15     |
    +|8    | B          | 13     |
    +|9    | B          | 1154   |
    +|10   | B          | 1345   |
    +|11   | B          | 1221   |
    +|12   | B          | 234    |
    +|13   | C          | 2345   |
    +|14   | C          | 2645   |
    +|15   | C          | 2645   |
    +|16   | C          | 2652   |
    +|17   | C          | 65     |
    ++-----+------------+--------+
    +
    + +

    Write a SQL query to find the median salary of each company. Bonus points if you can solve it without using any built-in SQL functions.

    + +
    ++-----+------------+--------+
    +|Id   | Company    | Salary |
    ++-----+------------+--------+
    +|5    | A          | 451    |
    +|6    | A          | 513    |
    +|12   | B          | 234    |
    +|9    | B          | 1154   |
    +|14   | C          | 2645   |
    ++-----+------------+--------+
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/meeting-rooms-ii/README.md b/problems/meeting-rooms-ii/README.md index 9010f4931..e08daae7c 100644 --- a/problems/meeting-rooms-ii/README.md +++ b/problems/meeting-rooms-ii/README.md @@ -11,7 +11,21 @@ ## [253. Meeting Rooms II (Medium)](https://leetcode.com/problems/meeting-rooms-ii "会议室 II") +

    Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), find the minimum number of conference rooms required.

    +

    Example 1:

    + +
    +Input: [[0, 30],[5, 10],[15, 20]]
    +Output: 2
    + +

    Example 2:

    + +
    +Input: [[7,10],[2,4]]
    +Output: 1
    + +

    NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/meeting-rooms/README.md b/problems/meeting-rooms/README.md index bcbfc704b..7138cc5b1 100644 --- a/problems/meeting-rooms/README.md +++ b/problems/meeting-rooms/README.md @@ -11,7 +11,23 @@ ## [252. Meeting Rooms (Easy)](https://leetcode.com/problems/meeting-rooms "会议室") +

    Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all meetings.

    +

    Example 1:

    + +
    +Input: [[0,30],[5,10],[15,20]]
    +Output: false
    +
    + +

    Example 2:

    + +
    +Input: [[7,10],[2,4]]
    +Output: true
    +
    + +

    NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/meeting-scheduler/README.md b/problems/meeting-scheduler/README.md index 7f8766aaf..1c6ac62b7 100644 --- a/problems/meeting-scheduler/README.md +++ b/problems/meeting-scheduler/README.md @@ -11,7 +11,40 @@ ## [1229. Meeting Scheduler (Medium)](https://leetcode.com/problems/meeting-scheduler "安排会议日程") +

    Given the availability time slots arrays slots1 and slots2 of two people and a meeting duration duration, return the earliest time slot that works for both of them and is of duration duration.

    +

    If there is no common time slot that satisfies the requirements, return an empty array.

    + +

    The format of a time slot is an array of two elements [start, end] representing an inclusive time range from start to end.  

    + +

    It is guaranteed that no two availability slots of the same person intersect with each other. That is, for any two time slots [start1, end1] and [start2, end2] of the same person, either start1 > end2 or start2 > end1.

    + +

     

    +

    Example 1:

    + +
    +Input: slots1 = [[10,50],[60,120],[140,210]], slots2 = [[0,15],[60,70]], duration = 8
    +Output: [60,68]
    +
    + +

    Example 2:

    + +
    +Input: slots1 = [[10,50],[60,120],[140,210]], slots2 = [[0,15],[60,70]], duration = 12
    +Output: []
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= slots1.length, slots2.length <= 10^4
    • +
    • slots1[i].length, slots2[i].length == 2
    • +
    • slots1[i][0] < slots1[i][1]
    • +
    • slots2[i][0] < slots2[i][1]
    • +
    • 0 <= slots1[i][j], slots2[i][j] <= 10^9
    • +
    • 1 <= duration <= 10^6 
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/merge-bsts-to-create-single-bst/README.md b/problems/merge-bsts-to-create-single-bst/README.md new file mode 100644 index 000000000..632bf3435 --- /dev/null +++ b/problems/merge-bsts-to-create-single-bst/README.md @@ -0,0 +1,110 @@ + + + + + + + +[< Previous](../painting-a-grid-with-three-different-colors "Painting a Grid With Three Different Colors") +                 +[Next >](../check-if-string-is-decomposable-into-value-equal-substrings "Check if String Is Decomposable Into Value-Equal Substrings") + +## [1932. Merge BSTs to Create Single BST (Hard)](https://leetcode.com/problems/merge-bsts-to-create-single-bst "合并多棵二叉搜索树") + +

    You are given n BST (binary search tree) root nodes for n separate BSTs stored in an array trees (0-indexed). Each BST in trees has at most 3 nodes, and no two roots have the same value. In one operation, you can:

    + +
      +
    • Select two distinct indices i and j such that the value stored at one of the leaves of trees[i] is equal to the root value of trees[j].
    • +
    • Replace the leaf node in trees[i] with trees[j].
    • +
    • Remove trees[j] from trees.
    • +
    + +

    Return the root of the resulting BST if it is possible to form a valid BST after performing n - 1 operations, or null if it is impossible to create a valid BST.

    + +

    A BST (binary search tree) is a binary tree where each node satisfies the following property:

    + +
      +
    • Every node in the node's left subtree has a value strictly less than the node's value.
    • +
    • Every node in the node's right subtree has a value strictly greater than the node's value.
    • +
    + +

    A leaf is a node that has no children.

    + +

     

    +

    Example 1:

    + +
    +Input: trees = [[2,1],[3,2,5],[5,4]]
    +Output: [3,2,5,1,null,4]
    +Explanation:
    +In the first operation, pick i=1 and j=0, and merge trees[0] into trees[1].
    +Delete trees[0], so trees = [[3,2,5,1],[5,4]].
    +
    +In the second operation, pick i=0 and j=1, and merge trees[1] into trees[0].
    +Delete trees[1], so trees = [[3,2,5,1,null,4]].
    +
    +The resulting tree, shown above, is a valid BST, so return its root.
    + +

    Example 2:

    + +
    +Input: trees = [[5,3,8],[3,2,6]]
    +Output: []
    +Explanation:
    +Pick i=0 and j=1 and merge trees[1] into trees[0].
    +Delete trees[1], so trees = [[5,3,8,2,6]].
    +
    +The resulting tree is shown above. This is the only valid operation that can be performed, but the resulting tree is not a valid BST, so return null.
    +
    + +

    Example 3:

    + +
    +Input: trees = [[5,4],[3]]
    +Output: []
    +Explanation: It is impossible to perform any operations.
    +
    + +

    Example 4:

    + +
    +Input: trees = [[2,1,3]]
    +Output: [2,1,3]
    +Explanation: There is only one tree, and it is already a valid BST, so return its root.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == trees.length
    • +
    • 1 <= n <= 5 * 104
    • +
    • The number of nodes in each tree is in the range [1, 3].
    • +
    • Each node in the input may have children but no grandchildren.
    • +
    • No two roots of trees have the same value.
    • +
    • All the trees in the input are valid BSTs.
    • +
    • 1 <= TreeNode.val <= 5 * 104.
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] + +### Hints +
    +Hint 1 +Is it possible to have multiple leaf nodes with the same values? +
    + +
    +Hint 2 +How many possible positions are there for each tree? +
    + +
    +Hint 3 +The root value of the final tree does not occur as a value in any of the leaves of the original tree. +
    diff --git a/problems/middle-of-the-linked-list/README.md b/problems/middle-of-the-linked-list/README.md index 3ac935c09..e54ef54e1 100644 --- a/problems/middle-of-the-linked-list/README.md +++ b/problems/middle-of-the-linked-list/README.md @@ -11,41 +11,34 @@ ## [876. Middle of the Linked List (Easy)](https://leetcode.com/problems/middle-of-the-linked-list "链表的中间结点") -

    Given a non-empty, singly linked list with head node head, return a middle node of linked list.

    +

    Given the head of a singly linked list, return the middle node of the linked list.

    -

    If there are two middle nodes, return the second middle node.

    +

    If there are two middle nodes, return the second middle node.

     

    - -

    Example 1:

    - +
    -Input: [1,2,3,4,5]
    -Output: Node 3 from this list (Serialization: [3,4,5])
    -The returned node has value 3.  (The judge's serialization of this node is [3,4,5]).
    -Note that we returned a ListNode object ans, such that:
    -ans.val = 3, ans.next.val = 4, ans.next.next.val = 5, and ans.next.next.next = NULL.
    +Input: head = [1,2,3,4,5]
    +Output: [3,4,5]
    +Explanation: The middle node of the list is node 3.
     
    -

    Example 2:

    - +
    -Input: [1,2,3,4,5,6]
    -Output: Node 4 from this list (Serialization: [4,5,6])
    -Since the list has two middle nodes with values 3 and 4, we return the second one.
    +Input: head = [1,2,3,4,5,6]
    +Output: [4,5,6]
    +Explanation: Since the list has two middle nodes with values 3 and 4, we return the second one.
     

     

    - -

    Note:

    +

    Constraints:

      -
    • The number of nodes in the given list will be between 1 and 100.
    • +
    • The number of nodes in the list is in the range [1, 100].
    • +
    • 1 <= Node.val <= 100
    -
    -
    ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/minimize-max-distance-to-gas-station/README.md b/problems/minimize-max-distance-to-gas-station/README.md index 919914c78..61cb492c8 100644 --- a/problems/minimize-max-distance-to-gas-station/README.md +++ b/problems/minimize-max-distance-to-gas-station/README.md @@ -11,7 +11,27 @@ ## [774. Minimize Max Distance to Gas Station (Hard)](https://leetcode.com/problems/minimize-max-distance-to-gas-station "最小化去加油站的最大距离") +

    On a horizontal number line, we have gas stations at positions stations[0], stations[1], ..., stations[N-1], where N = stations.length.

    +

    Now, we add K more gas stations so that D, the maximum distance between adjacent gas stations, is minimized.

    + +

    Return the smallest possible value of D.

    + +

    Example:

    + +
    +Input: stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], K = 9
    +Output: 0.500000
    +
    + +

    Note:

    + +
      +
    1. stations.length will be an integer in range [10, 2000].
    2. +
    3. stations[i] will be an integer in range [0, 10^8].
    4. +
    5. K will be an integer in range [1, 10^6].
    6. +
    7. Answers within 10^-6 of the true value will be accepted as correct.
    8. +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/minimize-rounding-error-to-meet-target/README.md b/problems/minimize-rounding-error-to-meet-target/README.md index 39df68727..6dfbedfbc 100644 --- a/problems/minimize-rounding-error-to-meet-target/README.md +++ b/problems/minimize-rounding-error-to-meet-target/README.md @@ -11,7 +11,39 @@ ## [1058. Minimize Rounding Error to Meet Target (Medium)](https://leetcode.com/problems/minimize-rounding-error-to-meet-target "最小化舍入误差以满足目标") +

    Given an array of prices [p1,p2...,pn] and a target, round each price pi to Roundi(pi) so that the rounded array [Round1(p1),Round2(p2)...,Roundn(pn)] sums to the given target. Each operation Roundi(pi) could be either Floor(pi) or Ceil(pi).

    +

    Return the string "-1" if the rounded array is impossible to sum to target. Otherwise, return the smallest rounding error, which is defined as Σ |Roundi(pi) - (pi)| for i from 1 to n, as a string with three places after the decimal.

    + +

     

    + +

    Example 1:

    + +
    +Input: prices = ["0.700","2.800","4.900"], target = 8
    +Output: "1.000"
    +Explanation: 
    +Use Floor, Ceil and Ceil operations to get (0.7 - 0) + (3 - 2.8) + (5 - 4.9) = 0.7 + 0.2 + 0.1 = 1.0 .
    +
    + +

    Example 2:

    + +
    +Input: prices = ["1.500","2.500","3.500"], target = 10
    +Output: "-1"
    +Explanation: 
    +It is impossible to meet the target.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= prices.length <= 500.
    2. +
    3. Each string of prices prices[i] represents a real number which is between 0 and 1000 and has exactly 3 decimal places.
    4. +
    5. target is between 0 and 1000000.
    6. +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/minimum-add-to-make-parentheses-valid/README.md b/problems/minimum-add-to-make-parentheses-valid/README.md index 792dae379..79477452d 100644 --- a/problems/minimum-add-to-make-parentheses-valid/README.md +++ b/problems/minimum-add-to-make-parentheses-valid/README.md @@ -11,69 +11,58 @@ ## [921. Minimum Add to Make Parentheses Valid (Medium)](https://leetcode.com/problems/minimum-add-to-make-parentheses-valid "使括号有效的最少添加") -

    Given a string s of '(' and ')' parentheses, we add the minimum number of parentheses ( '(' or ')', and in any positions ) so that the resulting parentheses string is valid.

    - -

    Formally, a parentheses string is valid if and only if:

    +

    A parentheses string is valid if and only if:

      -
    • It is the empty string, or
    • -
    • It can be written as AB (A concatenated with B), where A and B are valid strings, or
    • +
    • It is the empty string,
    • +
    • It can be written as AB (A concatenated with B), where A and B are valid strings, or
    • It can be written as (A), where A is a valid string.
    -

    Given a parentheses string, return the minimum number of parentheses we must add to make the resulting string valid.

    +

    You are given a parentheses string s. In one move, you can insert a parenthesis at any position of the string.

    -

     

    +
      +
    • For example, if s = "()))", you can insert an opening parenthesis to be "(()))" or a closing parenthesis to be "())))".
    • +
    + +

    Return the minimum number of moves required to make s valid.

    +

     

    Example 1:

    -Input: s = "())"
    -Output: 1
    +Input: s = "())"
    +Output: 1
     
    -

    Example 2:

    -Input: s = "((("
    -Output: 3
    +Input: s = "((("
    +Output: 3
     
    -

    Example 3:

    -Input: s = "()"
    -Output: 0
    +Input: s = "()"
    +Output: 0
     
    -

    Example 4:

    -Input: s = "()))(("
    -Output: 4
    +Input: s = "()))((" +Output: 4 +

     

    - - - - -

    Note:

    - -
      -
    1. s.length <= 1000
    2. -
    3. s only consists of '(' and ')' characters.
    4. -
    - -
    -
    -
    -
     
    -
    -
    -
    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 1000
    • +
    • s[i] is either '(' or ')'.
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/minimum-area-rectangle-ii/README.md b/problems/minimum-area-rectangle-ii/README.md index 56f0bbfab..ffb222fad 100644 --- a/problems/minimum-area-rectangle-ii/README.md +++ b/problems/minimum-area-rectangle-ii/README.md @@ -11,69 +11,54 @@ ## [963. Minimum Area Rectangle II (Medium)](https://leetcode.com/problems/minimum-area-rectangle-ii "最小面积矩形 II") -

    Given a set of points in the xy-plane, determine the minimum area of any rectangle formed from these points, with sides not necessarily parallel to the x and y axes.

    +

    You are given an array of points in the X-Y plane points where points[i] = [xi, yi].

    -

    If there isn't any rectangle, return 0.

    +

    Return the minimum area of any rectangle formed from these points, with sides not necessarily parallel to the X and Y axes. If there is not any such rectangle, return 0.

    -

     

    +

    Answers within 10-5 of the actual answer will be accepted.

    +

     

    Example 1:

    - -

    - +
    -Input: [[1,2],[2,1],[1,0],[0,1]]
    -Output: 2.00000
    -Explanation: The minimum area rectangle occurs at [1,2],[2,1],[1,0],[0,1], with an area of 2.
    +Input: points = [[1,2],[2,1],[1,0],[0,1]]
    +Output: 2.00000
    +Explanation: The minimum area rectangle occurs at [1,2],[2,1],[1,0],[0,1], with an area of 2.
     
    -

    Example 2:

    - -

    - +
    -Input: [[0,1],[2,1],[1,1],[1,0],[2,0]]
    -Output: 1.00000
    -Explanation: The minimum area rectangle occurs at [1,0],[1,1],[2,1],[2,0], with an area of 1.
    +Input: points = [[0,1],[2,1],[1,1],[1,0],[2,0]]
    +Output: 1.00000
    +Explanation: The minimum area rectangle occurs at [1,0],[1,1],[2,1],[2,0], with an area of 1.
     
    -

    Example 3:

    - -

    - +
    -Input: [[0,3],[1,2],[3,1],[1,3],[2,1]]
    -Output: 0
    -Explanation: There is no possible rectangle to form from these points.
    +Input: points = [[0,3],[1,2],[3,1],[1,3],[2,1]]
    +Output: 0
    +Explanation: There is no possible rectangle to form from these points.
     
    -

    Example 4:

    - -

    - +
    -Input: [[3,1],[1,1],[0,1],[2,1],[3,3],[3,2],[0,2],[2,3]]
    -Output: 2.00000
    -Explanation: The minimum area rectangle occurs at [2,1],[2,3],[3,3],[3,1], with an area of 2.
    +Input: points = [[3,1],[1,1],[0,1],[2,1],[3,3],[3,2],[0,2],[2,3]]
    +Output: 2.00000
    +Explanation: The minimum area rectangle occurs at [2,1],[2,3],[3,3],[3,1], with an area of 2.
     
    -

     

    -
    -
    - -

    Note:

    +

    Constraints:

    -
      +
      • 1 <= points.length <= 50
      • -
      • 0 <= points[i][0] <= 40000
      • -
      • 0 <= points[i][1] <= 40000
      • -
      • All points are distinct.
      • -
      • Answers within 10^-5 of the actual value will be accepted as correct.
      • -
    +
  • points[i].length == 2
  • +
  • 0 <= xi, yi <= 4 * 104
  • +
  • All the given points are unique.
  • + ### Related Topics [[Geometry](../../tag/geometry/README.md)] diff --git a/problems/minimum-area-rectangle/README.md b/problems/minimum-area-rectangle/README.md index b82ae1d30..fce2aaa4a 100644 --- a/problems/minimum-area-rectangle/README.md +++ b/problems/minimum-area-rectangle/README.md @@ -11,40 +11,34 @@ ## [939. Minimum Area Rectangle (Medium)](https://leetcode.com/problems/minimum-area-rectangle "最小面积矩形") -

    Given a set of points in the xy-plane, determine the minimum area of a rectangle formed from these points, with sides parallel to the x and y axes.

    +

    You are given an array of points in the X-Y plane points where points[i] = [xi, yi].

    -

    If there isn't any rectangle, return 0.

    +

    Return the minimum area of a rectangle formed from these points, with sides parallel to the X and Y axes. If there is not any such rectangle, return 0.

     

    - -

    Example 1:

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

    Example 2:

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

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= points.length <= 500
      • -
      • 0 <= points[i][0] <= 40000
      • -
      • 0 <= points[i][1] <= 40000
      • -
      • All points are distinct.
      • -
    -
    -
    +
  • points[i].length == 2
  • +
  • 0 <= xi, yi <= 4 * 104
  • +
  • All the given points are unique.
  • + ### Related Topics [[Geometry](../../tag/geometry/README.md)] diff --git a/problems/minimum-cost-to-connect-sticks/README.md b/problems/minimum-cost-to-connect-sticks/README.md index 49b7b3a65..dc0733fe6 100644 --- a/problems/minimum-cost-to-connect-sticks/README.md +++ b/problems/minimum-cost-to-connect-sticks/README.md @@ -11,7 +11,27 @@ ## [1167. Minimum Cost to Connect Sticks (Medium)](https://leetcode.com/problems/minimum-cost-to-connect-sticks "连接棒材的最低费用") - +

    You have some sticks with positive integer lengths.

    + +

    You can connect any two sticks of lengths X and Y into one stick by paying a cost of X + Y.  You perform this action until there is one stick remaining.

    + +

    Return the minimum cost of connecting all the given sticks into one stick in this way.

    + +

     

    +

    Example 1:

    +
    Input: sticks = [2,4,3]
    +Output: 14
    +

    Example 2:

    +
    Input: sticks = [1,8,3,5]
    +Output: 30
    +
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= sticks.length <= 10^4
    • +
    • 1 <= sticks[i] <= 10^4
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/minimum-cost-to-hire-k-workers/README.md b/problems/minimum-cost-to-hire-k-workers/README.md index 8514710a9..510fbd210 100644 --- a/problems/minimum-cost-to-hire-k-workers/README.md +++ b/problems/minimum-cost-to-hire-k-workers/README.md @@ -11,52 +11,42 @@ ## [857. Minimum Cost to Hire K Workers (Hard)](https://leetcode.com/problems/minimum-cost-to-hire-k-workers "雇佣 K 名工人的最低成本") -

    There are n workers.  The i-th worker has a quality[i] and a minimum wage expectation wage[i].

    +

    There are n workers. You are given two integer arrays quality and wage where quality[i] is the quality of the ith worker and wage[i] is the minimum wage expectation for the ith worker.

    -

    Now we want to hire exactly k workers to form a paid group.  When hiring a group of k workers, we must pay them according to the following rules:

    +

    We want to hire exactly k workers to form a paid group. To hire a group of k workers, we must pay them according to the following rules:

    1. Every worker in the paid group should be paid in the ratio of their quality compared to other workers in the paid group.
    2. -
    3. Every worker in the paid group must be paid at least their minimum wage expectation.
    4. +
    5. Every worker in the paid group must be paid at least their minimum-wage expectation.
    -

    Return the least amount of money needed to form a paid group satisfying the above conditions.

    +

    Given the integer k, return the least amount of money needed to form a paid group satisfying the above conditions. Answers within 10-5 of the actual answer will be accepted.

     

    - -
      -
    - -

    Example 1:

    -Input: quality = [10,20,5], wage = [70,50,30], k = 2
    -Output: 105.00000
    -Explanation: We pay 70 to 0-th worker and 35 to 2-th worker.
    +Input: quality = [10,20,5], wage = [70,50,30], k = 2
    +Output: 105.00000
    +Explanation: We pay 70 to 0th worker and 35 to 2nd worker.
     
    -

    Example 2:

    -Input: quality = [3,1,10,10,1], wage = [4,8,2,2,7], k = 3
    -Output: 30.66667
    -Explanation: We pay 4 to 0-th worker, 13.33333 to 2-th and 3-th workers seperately. 
    +Input: quality = [3,1,10,10,1], wage = [4,8,2,2,7], k = 3
    +Output: 30.66667
    +Explanation: We pay 4 to 0th worker, 13.33333 to 2nd and 3rd workers separately.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= k <= n <= 10000, where n = quality.length = wage.length
    2. -
    3. 1 <= quality[i] <= 10000
    4. -
    5. 1 <= wage[i] <= 10000
    6. -
    7. Answers within 10-5 of the correct answer will be considered correct.
    8. -
    -
    -
    +
      +
    • n == quality.length == wage.length
    • +
    • 1 <= k <= n <= 104
    • +
    • 1 <= quality[i], wage[i] <= 104
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/minimum-cost-to-reach-destination-in-time/README.md b/problems/minimum-cost-to-reach-destination-in-time/README.md new file mode 100644 index 000000000..4081e86be --- /dev/null +++ b/problems/minimum-cost-to-reach-destination-in-time/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../sum-game "Sum Game") +                 +[Next >](../concatenation-of-array "Concatenation of Array") + +## [1928. Minimum Cost to Reach Destination in Time (Hard)](https://leetcode.com/problems/minimum-cost-to-reach-destination-in-time "规定时间内到达终点的最小花费") + +

    There is a country of n cities numbered from 0 to n - 1 where all the cities are connected by bi-directional roads. The roads are represented as a 2D integer array edges where edges[i] = [xi, yi, timei] denotes a road between cities xi and yi that takes timei minutes to travel. There may be multiple roads of differing travel times connecting the same two cities, but no road connects a city to itself.

    + +

    Each time you pass through a city, you must pay a passing fee. This is represented as a 0-indexed integer array passingFees of length n where passingFees[j] is the amount of dollars you must pay when you pass through city j.

    + +

    In the beginning, you are at city 0 and want to reach city n - 1 in maxTime minutes or less. The cost of your journey is the summation of passing fees for each city that you passed through at some moment of your journey (including the source and destination cities).

    + +

    Given maxTime, edges, and passingFees, return the minimum cost to complete your journey, or -1 if you cannot complete it within maxTime minutes.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: maxTime = 30, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3]
    +Output: 11
    +Explanation: The path to take is 0 -> 1 -> 2 -> 5, which takes 30 minutes and has $11 worth of passing fees.
    +
    + +

    Example 2:

    + +

    + +
    +Input: maxTime = 29, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3]
    +Output: 48
    +Explanation: The path to take is 0 -> 3 -> 4 -> 5, which takes 26 minutes and has $48 worth of passing fees.
    +You cannot take path 0 -> 1 -> 2 -> 5 since it would take too long.
    +
    + +

    Example 3:

    + +
    +Input: maxTime = 25, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3]
    +Output: -1
    +Explanation: There is no way to reach city 5 from city 0 within 25 minutes.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= maxTime <= 1000
    • +
    • n == passingFees.length
    • +
    • 2 <= n <= 1000
    • +
    • n - 1 <= edges.length <= 1000
    • +
    • 0 <= xi, yi <= n - 1
    • +
    • 1 <= timei <= 1000
    • +
    • 1 <= passingFees[j] <= 1000 
    • +
    • The graph may contain multiple edges between two nodes.
    • +
    • The graph does not contain self loops.
    • +
    + +### Related Topics + [[Graph](../../tag/graph/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Consider a new graph where each node is one of the old nodes at a specific time. For example, node 0 at time 5. +
    + +
    +Hint 2 +You need to find the shortest path in the new graph. +
    diff --git a/problems/minimum-difficulty-of-a-job-schedule/README.md b/problems/minimum-difficulty-of-a-job-schedule/README.md index d017de816..1efd0840f 100644 --- a/problems/minimum-difficulty-of-a-job-schedule/README.md +++ b/problems/minimum-difficulty-of-a-job-schedule/README.md @@ -21,7 +21,7 @@

     

    Example 1:

    - +
     Input: jobDifficulty = [6,5,4,3,2,1], d = 2
     Output: 7
    @@ -65,7 +65,7 @@ The difficulty of the schedule = 6 + 1 = 7
     
     
    • 1 <= jobDifficulty.length <= 300
    • -
    • 0 <= jobDifficulty[i] <= 1000
    • +
    • 0 <= jobDifficulty[i] <= 1000
    • 1 <= d <= 10
    diff --git a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md index 5c177ce01..bdc16a8b7 100644 --- a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md +++ b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md @@ -11,13 +11,18 @@ ## [1320. Minimum Distance to Type a Word Using Two Fingers (Hard)](https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers "二指输入的的最小距离") -

    + +

    You have a keyboard layout as shown above in the X-Y plane, where each English uppercase letter is located at some coordinate.

    -

    You have a keyboard layout as shown above in the XY plane, where each English uppercase letter is located at some coordinate, for example, the letter A is located at coordinate (0,0), the letter B is located at coordinate (0,1), the letter P is located at coordinate (2,3) and the letter Z is located at coordinate (4,1).

    +
      +
    • For example, the letter 'A' is located at coordinate (0, 0), the letter 'B' is located at coordinate (0, 1), the letter 'P' is located at coordinate (2, 3) and the letter 'Z' is located at coordinate (4, 1).
    • +
    + +

    Given the string word, return the minimum total distance to type such string using only two fingers.

    -

    Given the string word, return the minimum total distance to type such string using only two fingers. The distance between coordinates (x1,y1) and (x2,y2) is |x1 - x2| + |y1 - y2|

    +

    The distance between coordinates (x1, y1) and (x2, y2) is |x1 - x2| + |y1 - y2|.

    -

    Note that the initial positions of your two fingers are considered free so don't count towards your total distance, also your two fingers do not have to start at the first letter or the first two letters.

    +

    Note that the initial positions of your two fingers are considered free so do not count towards your total distance, also your two fingers do not have to start at the first letter or the first two letters.

     

    Example 1:

    @@ -68,7 +73,7 @@ Total distance = 6
    • 2 <= word.length <= 300
    • -
    • Each word[i] is an English uppercase letter.
    • +
    • word consists of uppercase English letters.
    ### Related Topics diff --git a/problems/minimum-domino-rotations-for-equal-row/README.md b/problems/minimum-domino-rotations-for-equal-row/README.md index bd4dc0815..63b5a53a9 100644 --- a/problems/minimum-domino-rotations-for-equal-row/README.md +++ b/problems/minimum-domino-rotations-for-equal-row/README.md @@ -43,7 +43,8 @@ In this case, it is not possible to rotate the dominoes to make one row of value

    Constraints:

      -
    • 2 <= tops.length == bottoms.length <= 2 * 104
    • +
    • 2 <= tops.length <= 2 * 104
    • +
    • bottoms.length == tops.length
    • 1 <= tops[i], bottoms[i] <= 6
    diff --git a/problems/minimum-factorization/README.md b/problems/minimum-factorization/README.md index bb838c730..7ce98b925 100644 --- a/problems/minimum-factorization/README.md +++ b/problems/minimum-factorization/README.md @@ -11,7 +11,27 @@ ## [625. Minimum Factorization (Medium)](https://leetcode.com/problems/minimum-factorization "最小因式分解") +

    Given a positive integer a, find the smallest positive integer b whose multiplication of each digit equals to a.

    +

    +If there is no answer or the answer is not fit in 32-bit signed integer, then return 0.

    + +

    +Example 1
    +Input: +

    48 
    +Output: +
    68
    +

    + +

    +Example 2
    +Input: +

    15
    + +Output: +
    35
    +

    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/minimum-falling-path-sum/README.md b/problems/minimum-falling-path-sum/README.md index 9b36ac783..c8d0aa50b 100644 --- a/problems/minimum-falling-path-sum/README.md +++ b/problems/minimum-falling-path-sum/README.md @@ -58,3 +58,6 @@ [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Matrix](../../tag/matrix/README.md)] + +### Similar Questions + 1. [Minimum Falling Path Sum II](../minimum-falling-path-sum-ii) (Hard) diff --git a/problems/minimum-garden-perimeter-to-collect-enough-apples/README.md b/problems/minimum-garden-perimeter-to-collect-enough-apples/README.md new file mode 100644 index 000000000..fe231b449 --- /dev/null +++ b/problems/minimum-garden-perimeter-to-collect-enough-apples/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../maximum-number-of-weeks-for-which-you-can-work "Maximum Number of Weeks for Which You Can Work") +                 +[Next >](../count-number-of-special-subsequences "Count Number of Special Subsequences") + +## [1954. Minimum Garden Perimeter to Collect Enough Apples (Medium)](https://leetcode.com/problems/minimum-garden-perimeter-to-collect-enough-apples "收集足够苹果的最小花园周长") + +

    In a garden represented as an infinite 2D grid, there is an apple tree planted at every integer coordinate. The apple tree planted at an integer coordinate (i, j) has |i| + |j| apples growing on it.

    + +

    You will buy an axis-aligned square plot of land that is centered at (0, 0).

    + +

    Given an integer neededApples, return the minimum perimeter of a plot such that at least neededApples apples are inside or on the perimeter of that plot.

    + +

    The value of |x| is defined as:

    + +
      +
    • x if x >= 0
    • +
    • -x if x < 0
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: neededApples = 1
    +Output: 8
    +Explanation: A square plot of side length 1 does not contain any apples.
    +However, a square plot of side length 2 has 12 apples inside (as depicted in the image above).
    +The perimeter is 2 * 4 = 8.
    +
    + +

    Example 2:

    + +
    +Input: neededApples = 13
    +Output: 16
    +
    + +

    Example 3:

    + +
    +Input: neededApples = 1000000000
    +Output: 5040
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= neededApples <= 1015
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Find a formula for the number of apples inside a square with a side length L. +
    + +
    +Hint 2 +Iterate over the possible lengths of the square until enough apples are collected. +
    diff --git a/problems/minimum-increment-to-make-array-unique/README.md b/problems/minimum-increment-to-make-array-unique/README.md index c14fba412..27f098950 100644 --- a/problems/minimum-increment-to-make-array-unique/README.md +++ b/problems/minimum-increment-to-make-array-unique/README.md @@ -11,43 +11,35 @@ ## [945. Minimum Increment to Make Array Unique (Medium)](https://leetcode.com/problems/minimum-increment-to-make-array-unique "使数组唯一的最小增量") -

    Given an array of integers nums, a move consists of choosing any nums[i], and incrementing it by 1.

    +

    You are given an integer array nums. In one move, you can pick an index i where 0 <= i < nums.length and increment nums[i] by 1.

    -

    Return the least number of moves to make every value in nums unique.

    +

    Return the minimum number of moves to make every value in nums unique.

     

    -

    Example 1:

    -Input: nums = [1,2,2]
    -Output: 1
    -Explanation:  After 1 move, the array could be [1, 2, 3].
    +Input: nums = [1,2,2]
    +Output: 1
    +Explanation: After 1 move, the array could be [1, 2, 3].
     
    -

    Example 2:

    -Input: nums = [3,2,1,2,1,7]
    -Output: 6
    -Explanation:  After 6 moves, the array could be [3, 4, 1, 2, 5, 7].
    +Input: nums = [3,2,1,2,1,7]
    +Output: 6
    +Explanation: After 6 moves, the array could be [3, 4, 1, 2, 5, 7].
     It can be shown with 5 or less moves that it is impossible for the array to have all unique values.
     

     

    -
    - -

    Note:

    - -
      -
    1. 0 <= nums.length <= 40000
    2. -
    3. 0 <= nums[i] < 40000
    4. -
    +

    Constraints:

    -
    -
     
    -
    +
      +
    • 1 <= nums.length <= 105
    • +
    • 0 <= nums[i] <= 105
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/minimum-knight-moves/README.md b/problems/minimum-knight-moves/README.md index 36b8ed532..6b6aae821 100644 --- a/problems/minimum-knight-moves/README.md +++ b/problems/minimum-knight-moves/README.md @@ -11,7 +11,37 @@ ## [1197. Minimum Knight Moves (Medium)](https://leetcode.com/problems/minimum-knight-moves "进击的骑士") +

    In an infinite chess board with coordinates from -infinity to +infinity, you have a knight at square [0, 0].

    +

    A knight has 8 possible moves it can make, as illustrated below. Each move is two squares in a cardinal direction, then one square in an orthogonal direction.

    + +

    + +

    Return the minimum number of steps needed to move the knight to the square [x, y].  It is guaranteed the answer exists.

    + +

     

    +

    Example 1:

    + +
    +Input: x = 2, y = 1
    +Output: 1
    +Explanation: [0, 0] → [2, 1]
    +
    + +

    Example 2:

    + +
    +Input: x = 5, y = 5
    +Output: 4
    +Explanation: [0, 0] → [2, 1] → [4, 2] → [3, 4] → [5, 5]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • |x| + |y| <= 300
    • +
    ### Related Topics [[Breadth-First Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md b/problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md index 88c831003..9b41ba166 100644 --- a/problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md +++ b/problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md @@ -62,8 +62,9 @@ So it takes only 2 operations. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/minimum-path-cost-in-a-hidden-grid/README.md b/problems/minimum-path-cost-in-a-hidden-grid/README.md index 3fbd24266..4d7d7a664 100644 --- a/problems/minimum-path-cost-in-a-hidden-grid/README.md +++ b/problems/minimum-path-cost-in-a-hidden-grid/README.md @@ -9,7 +9,7 @@                  [Next >](../find-interview-candidates "Find Interview Candidates") -## [1810. Minimum Path Cost in a Hidden Grid (Medium)](https://leetcode.com/problems/minimum-path-cost-in-a-hidden-grid "") +## [1810. Minimum Path Cost in a Hidden Grid (Medium)](https://leetcode.com/problems/minimum-path-cost-in-a-hidden-grid "隐藏网格下的最小消耗路径") diff --git a/problems/minimum-swaps-to-group-all-1s-together/README.md b/problems/minimum-swaps-to-group-all-1s-together/README.md index d2ea84521..4035377a3 100644 --- a/problems/minimum-swaps-to-group-all-1s-together/README.md +++ b/problems/minimum-swaps-to-group-all-1s-together/README.md @@ -11,7 +11,49 @@ ## [1151. Minimum Swaps to Group All 1's Together (Medium)](https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together "最少交换次数来组合所有的 1") +

    Given a binary array data, return the minimum number of swaps required to group all 1’s present in the array together in any place in the array.

    +

     

    + +

    Example 1:

    + +
    +Input: [1,0,1,0,1]
    +Output: 1
    +Explanation: 
    +There are 3 ways to group all 1's together:
    +[1,1,1,0,0] using 1 swap.
    +[0,1,1,1,0] using 2 swaps.
    +[0,0,1,1,1] using 1 swap.
    +The minimum is 1.
    +
    + +

    Example 2:

    + +
    +Input: [0,0,0,1,0]
    +Output: 0
    +Explanation: 
    +Since there is only one 1 in the array, no swaps needed.
    +
    + +

    Example 3:

    + +
    +Input: [1,0,1,0,1,0,0,1,1,0,1]
    +Output: 3
    +Explanation: 
    +One possible solution that uses 3 swaps is [0,0,0,0,0,1,1,1,1,1,1].
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= data.length <= 10^5
    2. +
    3. 0 <= data[i] <= 1
    4. +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/minimum-time-to-build-blocks/README.md b/problems/minimum-time-to-build-blocks/README.md index 7a69e6506..9dc94ff90 100644 --- a/problems/minimum-time-to-build-blocks/README.md +++ b/problems/minimum-time-to-build-blocks/README.md @@ -11,7 +11,51 @@ ## [1199. Minimum Time to Build Blocks (Hard)](https://leetcode.com/problems/minimum-time-to-build-blocks "建造街区的最短时间") +

    You are given a list of blocks, where blocks[i] = t means that the i-th block needs t units of time to be built. A block can only be built by exactly one worker.

    +

    A worker can either split into two workers (number of workers increases by one) or build a block then go home. Both decisions cost some time.

    + +

    The time cost of spliting one worker into two workers is given as an integer split. Note that if two workers split at the same time, they split in parallel so the cost would be split.

    + +

    Output the minimum time needed to build all blocks.

    + +

    Initially, there is only one worker.

    + +

     

    +

    Example 1:

    + +
    +Input: blocks = [1], split = 1
    +Output: 1
    +Explanation: We use 1 worker to build 1 block in 1 time unit.
    +
    + +

    Example 2:

    + +
    +Input: blocks = [1,2], split = 5
    +Output: 7
    +Explanation: We split the worker into 2 workers in 5 time units then assign each of them to a block so the cost is 5 + max(1, 2) = 7.
    +
    + +

    Example 3:

    + +
    +Input: blocks = [1,2,3], split = 1
    +Output: 4
    +Explanation: Split 1 worker into 2, then assign the first worker to the last block and split the second worker into 2.
    +Then, use the two unassigned workers to build the first two blocks.
    +The cost is 1 + max(3, 1 + max(1, 2)) = 4.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= blocks.length <= 1000
    • +
    • 1 <= blocks[i] <= 10^5
    • +
    • 1 <= split <= 100
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/minimum-unique-word-abbreviation/README.md b/problems/minimum-unique-word-abbreviation/README.md index b86431952..a92e70f32 100644 --- a/problems/minimum-unique-word-abbreviation/README.md +++ b/problems/minimum-unique-word-abbreviation/README.md @@ -11,7 +11,29 @@ ## [411. Minimum Unique Word Abbreviation (Hard)](https://leetcode.com/problems/minimum-unique-word-abbreviation "最短独占单词缩写") +

    A string such as "word" contains the following abbreviations:

    +
    ["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"]
    +
    + +

    Given a target string and a set of strings in a dictionary, find an abbreviation of this target string with the smallest possible length such that it does not conflict with abbreviations of the strings in the dictionary.

    + +

    Each number or letter in the abbreviation is considered length = 1. For example, the abbreviation "a32bc" has length = 4.

    + +

    Note:
    +

      +
    • In the case of multiple answers as shown in the second example below, you may return any one of them.
    • +
    • Assume length of target string = m, and dictionary size = n. You may assume that m ≤ 21, n ≤ 1000, and log2(n) + m ≤ 20.
    • +
    +

    + +

    Examples:
    +

    +"apple", ["blade"] -> "a4" (because "5" or "4e" conflicts with "blade")
    +
    +"apple", ["plain", "amber", "blade"] -> "1p3" (other valid answers include "ap3", "a3e", "2p2", "3le", "3l1").
    +
    +

    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/minimum-window-subsequence/README.md b/problems/minimum-window-subsequence/README.md index fd152167e..21e70e9d1 100644 --- a/problems/minimum-window-subsequence/README.md +++ b/problems/minimum-window-subsequence/README.md @@ -11,7 +11,32 @@ ## [727. Minimum Window Subsequence (Hard)](https://leetcode.com/problems/minimum-window-subsequence "最小窗口子序列") +

    Given strings S and T, find the minimum (contiguous) substring W of S, so that T is a subsequence of W.

    +

    If there is no such window in S that covers all characters in T, return the empty string "". If there are multiple such minimum-length windows, return the one with the left-most starting index.

    + +

    Example 1:

    + +
    +Input: 
    +S = "abcdebdde", T = "bde"
    +Output: "bcde"
    +Explanation: 
    +"bcde" is the answer because it occurs before "bdde" which has the same length.
    +"deb" is not a smaller window because the elements of T in the window must occur in order.
    +
    + +

     

    + +

    Note:

    + +
      +
    • All the strings in the input will only contain lowercase letters.
    • +
    • The length of S will be in the range [1, 20000].
    • +
    • The length of T will be in the range [1, 100].
    • +
    + +

     

    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/mirror-reflection/README.md b/problems/mirror-reflection/README.md index 1e1814439..38983a7f9 100644 --- a/problems/mirror-reflection/README.md +++ b/problems/mirror-reflection/README.md @@ -11,31 +11,36 @@ ## [858. Mirror Reflection (Medium)](https://leetcode.com/problems/mirror-reflection "镜面反射") -

    There is a special square room with mirrors on each of the four walls.  Except for the southwest corner, there are receptors on each of the remaining corners, numbered 0, 1, and 2.

    +

    There is a special square room with mirrors on each of the four walls. Except for the southwest corner, there are receptors on each of the remaining corners, numbered 0, 1, and 2.

    -

    The square room has walls of length p, and a laser ray from the southwest corner first meets the east wall at a distance q from the 0th receptor.

    +

    The square room has walls of length p and a laser ray from the southwest corner first meets the east wall at a distance q from the 0th receptor.

    -

    Return the number of the receptor that the ray meets first.  (It is guaranteed that the ray will meet a receptor eventually.)

    +

    Given the two integers p and q, return the number of the receptor that the ray meets first.

    -

     

    +

    The test cases are guaranteed so that the ray will meet a receptor eventually.

    -
    +

     

    Example 1:

    + +
    +Input: p = 2, q = 1
    +Output: 2
    +Explanation: The ray meets receptor 2 the first time it gets reflected back to the left wall.
    +
    + +

    Example 2:

    -Input: p = 2, q = 1
    -Output: 2
    -Explanation: The ray meets receptor 2 the first time it gets reflected back to the left wall.
    -
    +Input: p = 3, q = 1
    +Output: 1
     
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. 1 <= p <= 1000
    2. -
    3. 0 <= q <= p
    4. -
    -
    +
      +
    • 1 <= q <= p <= 1000
    • +
    ### Related Topics [[Geometry](../../tag/geometry/README.md)] diff --git a/problems/missing-element-in-sorted-array/README.md b/problems/missing-element-in-sorted-array/README.md index de0c294b6..9766f6cb3 100644 --- a/problems/missing-element-in-sorted-array/README.md +++ b/problems/missing-element-in-sorted-array/README.md @@ -11,7 +11,46 @@ ## [1060. Missing Element in Sorted Array (Medium)](https://leetcode.com/problems/missing-element-in-sorted-array "有序数组中的缺失元素") +

    Given a sorted array A of unique numbers, find the K-th missing number starting from the leftmost number of the array.

    +

     

    + +

    Example 1:

    + +
    +Input: A = [4,7,9,10], K = 1
    +Output: 5
    +Explanation: 
    +The first missing number is 5.
    +
    + +

    Example 2:

    + +
    +Input: A = [4,7,9,10], K = 3
    +Output: 8
    +Explanation: 
    +The missing numbers are [5,6,8,...], hence the third missing number is 8.
    +
    + +

    Example 3:

    + +
    +Input: A = [1,2,4], K = 3
    +Output: 6
    +Explanation: 
    +The missing numbers are [3,5,6,7,...], hence the third missing number is 6.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= A.length <= 50000
    2. +
    3. 1 <= A[i] <= 1e7
    4. +
    5. 1 <= K <= 1e8
    6. +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/missing-number-in-arithmetic-progression/README.md b/problems/missing-number-in-arithmetic-progression/README.md index b81744d4b..ed3d1c078 100644 --- a/problems/missing-number-in-arithmetic-progression/README.md +++ b/problems/missing-number-in-arithmetic-progression/README.md @@ -11,7 +11,35 @@ ## [1228. Missing Number In Arithmetic Progression (Easy)](https://leetcode.com/problems/missing-number-in-arithmetic-progression "等差数列中缺失的数字") +

    In some array arr, the values were in arithmetic progression: the values arr[i+1] - arr[i] are all equal for every 0 <= i < arr.length - 1.

    +

    Then, a value from arr was removed that was not the first or last value in the array.

    + +

    Return the removed value.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [5,7,11,13]
    +Output: 9
    +Explanation: The previous array was [5,7,9,11,13].
    +
    + +

    Example 2:

    + +
    +Input: arr = [15,13,12]
    +Output: 14
    +Explanation: The previous array was [15,14,13,12].
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= arr.length <= 1000
    • +
    • 0 <= arr[i] <= 10^5
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/missing-ranges/README.md b/problems/missing-ranges/README.md index aea52d801..0b127da34 100644 --- a/problems/missing-ranges/README.md +++ b/problems/missing-ranges/README.md @@ -11,7 +11,14 @@ ## [163. Missing Ranges (Easy)](https://leetcode.com/problems/missing-ranges "缺失的区间") +

    Given a sorted integer array nums, where the range of elements are in the inclusive range [lower, upper], return its missing ranges.

    +

    Example:

    + +
    +Input: nums = [0, 1, 3, 50, 75], lower = 0 and upper = 99,
    +Output: ["2", "4->49", "51->74", "76->99"]
    +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/monotonic-array/README.md b/problems/monotonic-array/README.md index 3915d8277..4c0ca297e 100644 --- a/problems/monotonic-array/README.md +++ b/problems/monotonic-array/README.md @@ -11,70 +11,36 @@ ## [896. Monotonic Array (Easy)](https://leetcode.com/problems/monotonic-array "单调数列") -

    An array is monotonic if it is either monotone increasing or monotone decreasing.

    +

    An array is monotonic if it is either monotone increasing or monotone decreasing.

    -

    An array nums is monotone increasing if for all i <= j, nums[i] <= nums[j].  An array nums is monotone decreasing if for all i <= j, nums[i] >= nums[j].

    +

    An array nums is monotone increasing if for all i <= j, nums[i] <= nums[j]. An array nums is monotone decreasing if for all i <= j, nums[i] >= nums[j].

    -

    Return true if and only if the given array nums is monotonic.

    +

    Given an integer array nums, return true if the given array is monotonic, or false otherwise.

     

    - -
      -
    - -

    Example 1:

    - -
    -Input: nums = [1,2,2,3]
    -Output: true
    -
    - -
    -

    Example 2:

    - -
    -Input: nums = [6,5,4,4]
    -Output: true
    -
    - -
    -

    Example 3:

    - -
    -Input: nums = [1,3,2]
    -Output: false
    +
    Input: nums = [1,2,2,3]
    +Output: true
    +

    Example 2:

    +
    Input: nums = [6,5,4,4]
    +Output: true
    +

    Example 3:

    +
    Input: nums = [1,3,2]
    +Output: false
    +

    Example 4:

    +
    Input: nums = [1,2,4,5]
    +Output: true
    +

    Example 5:

    +
    Input: nums = [1,1,1]
    +Output: true
     
    - -
    -

    Example 4:

    - -
    -Input: nums = [1,2,4,5]
    -Output: true
    -
    - -
    -

    Example 5:

    - -
    -Input: nums = [1,1,1]
    -Output: true
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= nums.length <= 50000
    2. -
    3. -100000 <= nums[i] <= 100000
    4. -
    -
    -
    -
    -
    -
    +
      +
    • 1 <= nums.length <= 105
    • +
    • -105 <= nums[i] <= 105
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/monthly-transactions-i/README.md b/problems/monthly-transactions-i/README.md index b27b9add0..e87c5b4e1 100644 --- a/problems/monthly-transactions-i/README.md +++ b/problems/monthly-transactions-i/README.md @@ -11,7 +11,49 @@ ## [1193. Monthly Transactions I (Medium)](https://leetcode.com/problems/monthly-transactions-i "每月交易 I") +

    Table: Transactions

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| id            | int     |
    +| country       | varchar |
    +| state         | enum    |
    +| amount        | int     |
    +| trans_date    | date    |
    ++---------------+---------+
    +id is the primary key of this table.
    +The table has information about incoming transactions.
    +The state column is an enum of type ["approved", "declined"].
    +
    + +

     

    + +

    Write an SQL query to find for each month and country, the number of transactions and their total amount, the number of approved transactions and their total amount.

    + +

    The query result format is in the following example:

    + +
    +Transactions table:
    ++------+---------+----------+--------+------------+
    +| id   | country | state    | amount | trans_date |
    ++------+---------+----------+--------+------------+
    +| 121  | US      | approved | 1000   | 2018-12-18 |
    +| 122  | US      | declined | 2000   | 2018-12-19 |
    +| 123  | US      | approved | 2000   | 2019-01-01 |
    +| 124  | DE      | approved | 2000   | 2019-01-07 |
    ++------+---------+----------+--------+------------+
    +
    +Result table:
    ++----------+---------+-------------+----------------+--------------------+-----------------------+
    +| month    | country | trans_count | approved_count | trans_total_amount | approved_total_amount |
    ++----------+---------+-------------+----------------+--------------------+-----------------------+
    +| 2018-12  | US      | 2           | 1              | 3000               | 1000                  |
    +| 2019-01  | US      | 1           | 1              | 2000               | 2000                  |
    +| 2019-01  | DE      | 1           | 1              | 2000               | 2000                  |
    ++----------+---------+-------------+----------------+--------------------+-----------------------+
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/monthly-transactions-ii/README.md b/problems/monthly-transactions-ii/README.md index bdca05b96..46803195d 100644 --- a/problems/monthly-transactions-ii/README.md +++ b/problems/monthly-transactions-ii/README.md @@ -11,7 +11,74 @@ ## [1205. Monthly Transactions II (Medium)](https://leetcode.com/problems/monthly-transactions-ii "每月交易II") +

    Table: Transactions

    +
    ++----------------+---------+
    +| Column Name    | Type    |
    ++----------------+---------+
    +| id             | int     |
    +| country        | varchar |
    +| state          | enum    |
    +| amount         | int     |
    +| trans_date     | date    |
    ++----------------+---------+
    +id is the primary key of this table.
    +The table has information about incoming transactions.
    +The state column is an enum of type ["approved", "declined"].
    +
    + +

    Table: Chargebacks

    + +
    ++----------------+---------+
    +| Column Name    | Type    |
    ++----------------+---------+
    +| trans_id       | int     |
    +| charge_date    | date    |
    ++----------------+---------+
    +Chargebacks contains basic information regarding incoming chargebacks from some transactions placed in Transactions table.
    +trans_id is a foreign key to the id column of Transactions table.
    +Each chargeback corresponds to a transaction made previously even if they were not approved.
    + +

     

    + +

    Write an SQL query to find for each month and country, the number of approved transactions and their total amount, the number of chargebacks and their total amount.

    + +

    Note: In your query, given the month and country, ignore rows with all zeros.

    + +

    The query result format is in the following example:

    + +
    +Transactions table:
    ++------+---------+----------+--------+------------+
    +| id   | country | state    | amount | trans_date |
    ++------+---------+----------+--------+------------+
    +| 101  | US      | approved | 1000   | 2019-05-18 |
    +| 102  | US      | declined | 2000   | 2019-05-19 |
    +| 103  | US      | approved | 3000   | 2019-06-10 |
    +| 104  | US      | approved | 4000   | 2019-06-13 |
    +| 105  | US      | approved | 5000   | 2019-06-15 |
    ++------+---------+----------+--------+------------+
    +
    +Chargebacks table:
    ++------------+------------+
    +| trans_id   | trans_date |
    ++------------+------------+
    +| 102        | 2019-05-29 |
    +| 101        | 2019-06-30 |
    +| 105        | 2019-09-18 |
    ++------------+------------+
    +
    +Result table:
    ++----------+---------+----------------+-----------------+-------------------+--------------------+
    +| month    | country | approved_count | approved_amount | chargeback_count  | chargeback_amount  |
    ++----------+---------+----------------+-----------------+-------------------+--------------------+
    +| 2019-05  | US      | 1              | 1000            | 1                 | 2000               |
    +| 2019-06  | US      | 3              | 12000           | 1                 | 1000               |
    +| 2019-09  | US      | 0              | 0               | 1                 | 5000               |
    ++----------+---------+----------------+-----------------+-------------------+--------------------+
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/most-profit-assigning-work/README.md b/problems/most-profit-assigning-work/README.md index fcb4fe052..338226ddf 100644 --- a/problems/most-profit-assigning-work/README.md +++ b/problems/most-profit-assigning-work/README.md @@ -11,29 +11,46 @@ ## [826. Most Profit Assigning Work (Medium)](https://leetcode.com/problems/most-profit-assigning-work "安排工作以达到最大收益") -

    We have jobs: difficulty[i] is the difficulty of the ith job, and profit[i] is the profit of the ith job. 

    +

    You have n jobs and m workers. You are given three arrays: difficulty, profit, and worker where:

    -

    Now we have some workers. worker[i] is the ability of the ith worker, which means that this worker can only complete a job with difficulty at most worker[i]

    +
      +
    • difficulty[i] and profit[i] are the difficulty and the profit of the ith job, and
    • +
    • worker[j] is the ability of jth worker (i.e., the jth worker can only complete a job with difficulty at most worker[j]).
    • +
    -

    Every worker can be assigned at most one job, but one job can be completed multiple times.

    +

    Every worker can be assigned at most one job, but one job can be completed multiple times.

    -

    For example, if 3 people attempt the same job that pays $1, then the total profit will be $3.  If a worker cannot complete any job, his profit is $0.

    +
      +
    • For example, if three workers attempt the same job that pays $1, then the total profit will be $3. If a worker cannot complete any job, their profit is $0.
    • +
    -

    What is the most profit we can make?

    +

    Return the maximum profit we can achieve after assigning the workers to the jobs.

    +

     

    Example 1:

    -Input: difficulty = [2,4,6,8,10], profit = [10,20,30,40,50], worker = [4,5,6,7]
    -Output: 100 
    -Explanation: Workers are assigned jobs of difficulty [4,4,6,6] and they get profit of [20,20,30,30] seperately.
    +Input: difficulty = [2,4,6,8,10], profit = [10,20,30,40,50], worker = [4,5,6,7] +Output: 100 +Explanation: Workers are assigned jobs of difficulty [4,4,6,6] and they get a profit of [20,20,30,30] separately. +
    + +

    Example 2:

    + +
    +Input: difficulty = [85,47,57], profit = [24,66,99], worker = [40,25,25]
    +Output: 0
    +
    -

    Notes:

    +

     

    +

    Constraints:

      -
    • 1 <= difficulty.length = profit.length <= 10000
    • -
    • 1 <= worker.length <= 10000
    • -
    • difficulty[i], profit[i], worker[i]  are in range [1, 10^5]
    • +
    • n == difficulty.length
    • +
    • n == profit.length
    • +
    • m == worker.length
    • +
    • 1 <= n, m <= 104
    • +
    • 1 <= difficulty[i], profit[i], worker[i] <= 105
    ### Related Topics diff --git a/problems/movie-rating/README.md b/problems/movie-rating/README.md index 5b4e1b0f3..d4d0c2a2d 100644 --- a/problems/movie-rating/README.md +++ b/problems/movie-rating/README.md @@ -11,7 +11,99 @@ ## [1341. Movie Rating (Medium)](https://leetcode.com/problems/movie-rating "电影评分") +

    Table: Movies

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| movie_id      | int     |
    +| title         | varchar |
    ++---------------+---------+
    +movie_id is the primary key for this table.
    +title is the name of the movie.
    +
    +

    Table: Users

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| user_id       | int     |
    +| name          | varchar |
    ++---------------+---------+
    +user_id is the primary key for this table.
    +
    + +

    Table: Movie_Rating

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| movie_id      | int     |
    +| user_id       | int     |
    +| rating        | int     |
    +| created_at    | date    |
    ++---------------+---------+
    +(movie_id, user_id) is the primary key for this table.
    +This table contains the rating of a movie by a user in their review.
    +created_at is the user's review date. 
    +
    + +Write the following SQL query: + +- Find the name of the user who has rated the greatest number of the movies. + In case of a tie, return lexicographically smaller user name. + +- Find the movie name with the highest average rating as of Feb 2020. + In case of a tie, return lexicographically smaller movie name.. + +Query is returned in 2 rows, the query result format is in the folowing example: +
    +Movie table:
    ++-------------+--------------+
    +| movie_id    |  title       |
    ++-------------+--------------+
    +| 1           | Avengers     |
    +| 2           | Frozen 2     |
    +| 3           | Joker        |
    ++-------------+--------------+
    +
    +Users table:
    ++-------------+--------------+
    +| user_id     |  name        |
    ++-------------+--------------+
    +| 1           | Daniel       |
    +| 2           | Monica       |
    +| 3           | Maria        |
    +| 4           | James        |
    ++-------------+--------------+
    +
    +Movie_Rating table:
    ++-------------+--------------+--------------+-------------+
    +| movie_id    | user_id      | rating       | created_at  |
    ++-------------+--------------+--------------+-------------+
    +| 1           | 1            | 3            | 2020-01-12  |
    +| 1           | 2            | 4            | 2020-02-11  |
    +| 1           | 3            | 2            | 2020-02-12  |
    +| 1           | 4            | 1            | 2020-01-01  |
    +| 2           | 1            | 5            | 2020-02-17  | 
    +| 2           | 2            | 2            | 2020-02-01  | 
    +| 2           | 3            | 2            | 2020-03-01  |
    +| 3           | 1            | 3            | 2020-02-22  | 
    +| 3           | 2            | 4            | 2020-02-25  | 
    ++-------------+--------------+--------------+-------------+
    +
    +Result table:
    ++--------------+
    +| results      |
    ++--------------+
    +| Daniel       |
    +| Frozen 2     |
    ++--------------+
    +
    +Daniel and Maria have rated 3 movies ("Avengers", "Frozen 2" and "Joker") but Daniel is smaller lexicographically.
    +Frozen 2 and Joker have a rating average of 3.5 in February but Frozen 2 is smaller lexicographically.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/moving-average-from-data-stream/README.md b/problems/moving-average-from-data-stream/README.md index 5a78eaa0c..f918c4396 100644 --- a/problems/moving-average-from-data-stream/README.md +++ b/problems/moving-average-from-data-stream/README.md @@ -11,7 +11,19 @@ ## [346. Moving Average from Data Stream (Easy)](https://leetcode.com/problems/moving-average-from-data-stream "数据流中的移动平均值") +

    Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window.

    +

    Example:

    + +
    +MovingAverage m = new MovingAverage(3);
    +m.next(1) = 1
    +m.next(10) = (1 + 10) / 2
    +m.next(3) = (1 + 10 + 3) / 3
    +m.next(5) = (10 + 3 + 5) / 3
    +
    + +

     

    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/n-repeated-element-in-size-2n-array/README.md b/problems/n-repeated-element-in-size-2n-array/README.md index fd63c7d55..314994e4f 100644 --- a/problems/n-repeated-element-in-size-2n-array/README.md +++ b/problems/n-repeated-element-in-size-2n-array/README.md @@ -11,51 +11,36 @@ ## [961. N-Repeated Element in Size 2N Array (Easy)](https://leetcode.com/problems/n-repeated-element-in-size-2n-array "重复 N 次的元素") -

    In a array nums of size 2 * n, there are n + 1 unique elements, and exactly one of these elements is repeated n times.

    +

    You are given an integer array nums with the following properties:

    -

    Return the element repeated n times.

    - -

     

    +
      +
    • nums.length == 2 * n.
    • +
    • nums contains n + 1 unique elements.
    • +
    • Exactly one element of nums is repeated n times.
    • +
    -
      -
    +

    Return the element that is repeated n times.

    -
    +

     

    Example 1:

    - -
    -Input: nums[1,2,3,3]
    -Output: 3
    -
    - -
    -

    Example 2:

    - -
    -Input: nums[2,1,2,5,3,2]
    -Output: 2
    +
    Input: nums = [1,2,3,3]
    +Output: 3
    +

    Example 2:

    +
    Input: nums = [2,1,2,5,3,2]
    +Output: 2
    +

    Example 3:

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

    Example 3:

    - -
    -Input: nums[5,1,5,2,5,3,5,4]
    -Output: 5
    -
    -

     

    - -

    Note:

    +

    Constraints:

      -
    • 4 <= nums.length <= 10000
    • -
    • 0 <= nums[i] < 10000
    • -
    • nums.length is even
    • +
    • 2 <= n <= 5000
    • +
    • nums.length == 2 * n
    • +
    • 0 <= nums[i] <= 104
    • +
    • nums contains n + 1 unique elements and one of them is repeated exactly n times.
    -
    -
    -
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/nearest-exit-from-entrance-in-maze/README.md b/problems/nearest-exit-from-entrance-in-maze/README.md new file mode 100644 index 000000000..b3e3aabfe --- /dev/null +++ b/problems/nearest-exit-from-entrance-in-maze/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../count-square-sum-triples "Count Square Sum Triples") +                 +[Next >](../sum-game "Sum Game") + +## [1926. Nearest Exit from Entrance in Maze (Medium)](https://leetcode.com/problems/nearest-exit-from-entrance-in-maze "迷宫中离入口最近的出口") + +

    You are given an m x n matrix maze (0-indexed) with empty cells (represented as '.') and walls (represented as '+'). You are also given the entrance of the maze, where entrance = [entrancerow, entrancecol] denotes the row and column of the cell you are initially standing at.

    + +

    In one step, you can move one cell up, down, left, or right. You cannot step into a cell with a wall, and you cannot step outside the maze. Your goal is to find the nearest exit from the entrance. An exit is defined as an empty cell that is at the border of the maze. The entrance does not count as an exit.

    + +

    Return the number of steps in the shortest path from the entrance to the nearest exit, or -1 if no such path exists.

    + +

     

    +

    Example 1:

    + +
    +Input: maze = [["+","+",".","+"],[".",".",".","+"],["+","+","+","."]], entrance = [1,2]
    +Output: 1
    +Explanation: There are 3 exits in this maze at [1,0], [0,2], and [2,3].
    +Initially, you are at the entrance cell [1,2].
    +- You can reach [1,0] by moving 2 steps left.
    +- You can reach [0,2] by moving 1 step up.
    +It is impossible to reach [2,3] from the entrance.
    +Thus, the nearest exit is [0,2], which is 1 step away.
    +
    + +

    Example 2:

    + +
    +Input: maze = [["+","+","+"],[".",".","."],["+","+","+"]], entrance = [1,0]
    +Output: 2
    +Explanation: There is 1 exit in this maze at [1,2].
    +[1,0] does not count as an exit since it is the entrance cell.
    +Initially, you are at the entrance cell [1,0].
    +- You can reach [1,2] by moving 2 steps right.
    +Thus, the nearest exit is [1,2], which is 2 steps away.
    +
    + +

    Example 3:

    + +
    +Input: maze = [[".","+"]], entrance = [0,0]
    +Output: -1
    +Explanation: There are no exits in this maze.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • maze.length == m
    • +
    • maze[i].length == n
    • +
    • 1 <= m, n <= 100
    • +
    • maze[i][j] is either '.' or '+'.
    • +
    • entrance.length == 2
    • +
    • 0 <= entrancerow < m
    • +
    • 0 <= entrancecol < n
    • +
    • entrance will always be an empty cell.
    • +
    + +### Related Topics + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Which type of traversal lets you find the distance from a point? +
    + +
    +Hint 2 +Try using a Breadth First Search. +
    diff --git a/problems/nested-list-weight-sum-ii/README.md b/problems/nested-list-weight-sum-ii/README.md index c03e789de..3dd813ef7 100644 --- a/problems/nested-list-weight-sum-ii/README.md +++ b/problems/nested-list-weight-sum-ii/README.md @@ -11,7 +11,29 @@ ## [364. Nested List Weight Sum II (Medium)](https://leetcode.com/problems/nested-list-weight-sum-ii "加权嵌套序列和 II") +

    Given a nested list of integers, return the sum of all integers in the list weighted by their depth.

    +

    Each element is either an integer, or a list -- whose elements may also be integers or other lists.

    + +

    Different from the previous question where weight is increasing from root to leaf, now the weight is defined from bottom up. i.e., the leaf level integers have weight 1, and the root level integers have the largest weight.

    + +

    Example 1:

    + +
    +
    +Input: [[1,1],2,[1,1]]
    +Output: 8 
    +Explanation: Four 1's at depth 1, one 2 at depth 2.
    +
    + +
    +

    Example 2:

    + +
    +Input: [1,[4,[6]]]
    +Output: 17 
    +Explanation: One 1 at depth 3, one 4 at depth 2, and one 6 at depth 1; 1*3 + 4*2 + 6*1 = 17.
    +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/nested-list-weight-sum/README.md b/problems/nested-list-weight-sum/README.md index 74e265612..11b69f5a6 100644 --- a/problems/nested-list-weight-sum/README.md +++ b/problems/nested-list-weight-sum/README.md @@ -11,7 +11,25 @@ ## [339. Nested List Weight Sum (Medium)](https://leetcode.com/problems/nested-list-weight-sum "嵌套列表权重和") +

    Given a nested list of integers, return the sum of all integers in the list weighted by their depth.

    +

    Each element is either an integer, or a list -- whose elements may also be integers or other lists.

    + +
    +

    Example 1:

    + +
    +Input: [[1,1],2,[1,1]]
    +Output: 10 
    +Explanation: Four 1's at depth 2, one 2 at depth 1.
    + +
    +

    Example 2:

    + +
    +Input: [1,[4,[6]]]
    +Output: 27 
    +Explanation: One 1 at depth 1, one 4 at depth 2, and one 6 at depth 3; 1 + 4*2 + 6*3 = 27.
    ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/new-users-daily-count/README.md b/problems/new-users-daily-count/README.md index 09c92851f..776d40322 100644 --- a/problems/new-users-daily-count/README.md +++ b/problems/new-users-daily-count/README.md @@ -11,7 +11,58 @@ ## [1107. New Users Daily Count (Medium)](https://leetcode.com/problems/new-users-daily-count "每日新用户统计") +

    Table: Traffic

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| user_id       | int     |
    +| activity      | enum    |
    +| activity_date | date    |
    ++---------------+---------+
    +There is no primary key for this table, it may have duplicate rows.
    +The activity column is an ENUM type of ('login', 'logout', 'jobs', 'groups', 'homepage').
    +
    + +

     

    + +

    Write an SQL query that reports for every date within at most 90 days from today, the number of users that logged in for the first time on that date. Assume today is 2019-06-30.

    + +

    The query result format is in the following example:

    + +
    +Traffic table:
    ++---------+----------+---------------+
    +| user_id | activity | activity_date |
    ++---------+----------+---------------+
    +| 1       | login    | 2019-05-01    |
    +| 1       | homepage | 2019-05-01    |
    +| 1       | logout   | 2019-05-01    |
    +| 2       | login    | 2019-06-21    |
    +| 2       | logout   | 2019-06-21    |
    +| 3       | login    | 2019-01-01    |
    +| 3       | jobs     | 2019-01-01    |
    +| 3       | logout   | 2019-01-01    |
    +| 4       | login    | 2019-06-21    |
    +| 4       | groups   | 2019-06-21    |
    +| 4       | logout   | 2019-06-21    |
    +| 5       | login    | 2019-03-01    |
    +| 5       | logout   | 2019-03-01    |
    +| 5       | login    | 2019-06-21    |
    +| 5       | logout   | 2019-06-21    |
    ++---------+----------+---------------+
    +
    +Result table:
    ++------------+-------------+
    +| login_date | user_count  |
    ++------------+-------------+
    +| 2019-05-01 | 1           |
    +| 2019-06-21 | 2           |
    ++------------+-------------+
    +Note that we only care about dates with non zero user count.
    +The user with id 5 first logged in on 2019-03-01 so he's not counted on 2019-06-21.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/next-closest-time/README.md b/problems/next-closest-time/README.md index 216e64318..89431c6f1 100644 --- a/problems/next-closest-time/README.md +++ b/problems/next-closest-time/README.md @@ -11,7 +11,25 @@ ## [681. Next Closest Time (Medium)](https://leetcode.com/problems/next-closest-time "最近时刻") +

    Given a time represented in the format "HH:MM", form the next closest time by reusing the current digits. There is no limit on how many times a digit can be reused.

    +

    You may assume the given input string is always valid. For example, "01:34", "12:09" are all valid. "1:34", "12:9" are all invalid.

    + +

    Example 1: +

    +Input: "19:34"
    +Output: "19:39"
    +Explanation: The next closest time choosing from digits 1, 9, 3, 4, is 19:39, which occurs 5 minutes later.  It is not 19:33, because this occurs 23 hours and 59 minutes later.
    +
    +

    + +

    Example 2: +

    +Input: "23:59"
    +Output: "22:22"
    +Explanation: The next closest time choosing from digits 2, 3, 5, 9, is 22:22. It may be assumed that the returned time is next day's time since it is smaller than the input time numerically.
    +
    +

    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/non-overlapping-intervals/README.md b/problems/non-overlapping-intervals/README.md index e01a5b9a7..8a555151b 100644 --- a/problems/non-overlapping-intervals/README.md +++ b/problems/non-overlapping-intervals/README.md @@ -42,9 +42,9 @@

    Constraints:

      -
    • 1 <= intervals.length <= 2 * 104
    • +
    • 1 <= intervals.length <= 105
    • intervals[i].length == 2
    • -
    • -2 * 104 <= starti < endi <= 2 * 104
    • +
    • -5 * 104 <= starti < endi <= 5 * 104
    ### Related Topics diff --git a/problems/number-of-comments-per-post/README.md b/problems/number-of-comments-per-post/README.md index 6864513c4..f1c436468 100644 --- a/problems/number-of-comments-per-post/README.md +++ b/problems/number-of-comments-per-post/README.md @@ -11,7 +11,63 @@ ## [1241. Number of Comments per Post (Easy)](https://leetcode.com/problems/number-of-comments-per-post "每个帖子的评论数") +

    Table: Submissions

    +
    +---------------+----------+
    +| Column Name   | Type     |
    ++---------------+----------+
    +| sub_id        | int      |
    +| parent_id     | int      |
    ++---------------+----------+
    +There is no primary key for this table, it may have duplicate rows.
    +Each row can be a post or comment on the post.
    +parent_id is null for posts.
    +parent_id for comments is sub_id for another post in the table.
    +
    + +

     

    + +

    Write an SQL query to find number of comments per each post.

    + +

    Result table should contain post_id and its corresponding number_of_comments, and must be sorted by post_id in ascending order.

    + +

    Submissions may contain duplicate comments. You should count the number of unique comments per post.

    + +

    Submissions may contain duplicate posts. You should treat them as one post.

    + +

    The query result format is in the following example:

    + +
    Submissions table:
    ++---------+------------+
    +| sub_id  | parent_id  |
    ++---------+------------+
    +| 1       | Null       |
    +| 2       | Null       |
    +| 1       | Null       |
    +| 12      | Null       |
    +| 3       | 1          |
    +| 5       | 2          |
    +| 3       | 1          |
    +| 4       | 1          |
    +| 9       | 1          |
    +| 10      | 2          |
    +| 6       | 7          |
    ++---------+------------+
    +
    +Result table:
    ++---------+--------------------+
    +| post_id | number_of_comments |
    ++---------+--------------------+
    +| 1       | 3                  |
    +| 2       | 2                  |
    +| 12      | 0                  |
    ++---------+--------------------+
    +
    +The post with id 1 has three comments in the table with id 3, 4 and 9. The comment with id 3 is repeated in the table, we counted it only once.
    +The post with id 2 has two comments in the table with id 5 and 10.
    +The post with id 12 has no comments in the table.
    +The comment with id 6 is a comment on a deleted post with id 7 so we ignored it.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/number-of-connected-components-in-an-undirected-graph/README.md b/problems/number-of-connected-components-in-an-undirected-graph/README.md index c8b38432b..c7a635238 100644 --- a/problems/number-of-connected-components-in-an-undirected-graph/README.md +++ b/problems/number-of-connected-components-in-an-undirected-graph/README.md @@ -11,7 +11,34 @@ ## [323. Number of Connected Components in an Undirected Graph (Medium)](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph "无向图中连通分量的数目") +

    Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected components in an undirected graph.

    +

    Example 1:

    + +
    +Input: n = 5 and edges = [[0, 1], [1, 2], [3, 4]]
    +
    +     0          3
    +     |          |
    +     1 --- 2    4 
    +
    +Output: 2
    +
    + +

    Example 2:

    + +
    +Input: n = 5 and edges = [[0, 1], [1, 2], [2, 3], [3, 4]]
    +
    +     0           4
    +     |           |
    +     1 --- 2 --- 3
    +
    +Output:  1
    +
    + +

    Note:
    +You can assume that no duplicate edges will appear in edges. Since all edges are undirected, [0, 1] is the same as [1, 0] and thus will not appear together in edges.

    ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/number-of-corner-rectangles/README.md b/problems/number-of-corner-rectangles/README.md index 33e7c5d45..d6a1bc642 100644 --- a/problems/number-of-corner-rectangles/README.md +++ b/problems/number-of-corner-rectangles/README.md @@ -11,7 +11,59 @@ ## [750. Number Of Corner Rectangles (Medium)](https://leetcode.com/problems/number-of-corner-rectangles "角矩形的数量") +

    Given a grid where each entry is only 0 or 1, find the number of corner rectangles.

    +

    A corner rectangle is 4 distinct 1s on the grid that form an axis-aligned rectangle. Note that only the corners need to have the value 1. Also, all four 1s used must be distinct.

    + +

     

    + +

    Example 1:

    + +
    +Input: grid = 
    +[[1, 0, 0, 1, 0],
    + [0, 0, 1, 0, 1],
    + [0, 0, 0, 1, 0],
    + [1, 0, 1, 0, 1]]
    +Output: 1
    +Explanation: There is only one corner rectangle, with corners grid[1][2], grid[1][4], grid[3][2], grid[3][4].
    +
    + +

     

    + +

    Example 2:

    + +
    +Input: grid = 
    +[[1, 1, 1],
    + [1, 1, 1],
    + [1, 1, 1]]
    +Output: 9
    +Explanation: There are four 2x2 rectangles, four 2x3 and 3x2 rectangles, and one 3x3 rectangle.
    +
    + +

     

    + +

    Example 3:

    + +
    +Input: grid = 
    +[[1, 1, 1, 1]]
    +Output: 0
    +Explanation: Rectangles must have four distinct corners.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. The number of rows and columns of grid will each be in the range [1, 200].
    2. +
    3. Each grid[i][j] will be either 0 or 1.
    4. +
    5. The number of 1s in the grid will be at most 6000.
    6. +
    + +

     

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/number-of-days-in-a-month/README.md b/problems/number-of-days-in-a-month/README.md index 4dad06f61..467a2fab1 100644 --- a/problems/number-of-days-in-a-month/README.md +++ b/problems/number-of-days-in-a-month/README.md @@ -11,7 +11,39 @@ ## [1118. Number of Days in a Month (Easy)](https://leetcode.com/problems/number-of-days-in-a-month "一月有多少天") +

    Given a year Y and a month M, return how many days there are in that month.

    +

     

    + +

    Example 1:

    + +
    +Input: Y = 1992, M = 7
    +Output: 31
    +
    + +

    Example 2:

    + +
    +Input: Y = 2000, M = 2
    +Output: 29
    +
    + +

    Example 3:

    + +
    +Input: Y = 1900, M = 2
    +Output: 28
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1583 <= Y <= 2100
    2. +
    3. 1 <= M <= 12
    4. +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/number-of-distinct-islands-ii/README.md b/problems/number-of-distinct-islands-ii/README.md index b1c05b730..fd7dc2e14 100644 --- a/problems/number-of-distinct-islands-ii/README.md +++ b/problems/number-of-distinct-islands-ii/README.md @@ -11,7 +11,67 @@ ## [711. Number of Distinct Islands II (Hard)](https://leetcode.com/problems/number-of-distinct-islands-ii "不同岛屿的数量 II") +

    Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.

    +

    Count the number of distinct islands. An island is considered to be the same as another if they have the same shape, or have the same shape after rotation (90, 180, or 270 degrees only) or reflection (left/right direction or up/down direction).

    + +

    Example 1:
    +

    +11000
    +10000
    +00001
    +00011
    +
    +Given the above grid map, return 1. +

    +Notice that: +
    +11
    +1
    +
    +and +
    + 1
    +11
    +
    +are considered same island shapes. Because if we make a 180 degrees clockwise rotation on the first island, then two islands will have the same shapes. +

    + +

    Example 2:
    +

    +11100
    +10001
    +01001
    +01110
    +Given the above grid map, return 2.
    +
    +Here are the two distinct islands: +
    +111
    +1
    +
    +and +
    +1
    +1
    +
    +
    +Notice that: +
    +111
    +1
    +
    +and +
    +1
    +111
    +
    +are considered same island shapes. Because if we flip the first array in the up/down direction, then they have the same shapes. +

    + +

    Note: +The length of each dimension in the given grid does not exceed 50. +

    ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/number-of-distinct-islands/README.md b/problems/number-of-distinct-islands/README.md index f48650134..67b054bcc 100644 --- a/problems/number-of-distinct-islands/README.md +++ b/problems/number-of-distinct-islands/README.md @@ -11,7 +11,42 @@ ## [694. Number of Distinct Islands (Medium)](https://leetcode.com/problems/number-of-distinct-islands "不同岛屿的数量") +

    Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.

    +

    Count the number of distinct islands. An island is considered to be the same as another if and only if one island can be translated (and not rotated or reflected) to equal the other.

    + +

    Example 1:
    +

    +11000
    +11000
    +00011
    +00011
    +
    +Given the above grid map, return 1. +

    + +

    Example 2:
    +

    11011
    +10000
    +00001
    +11011
    +Given the above grid map, return 3.

    +Notice that: +
    +11
    +1
    +
    +and +
    + 1
    +11
    +
    +are considered different island shapes, because we do not consider reflection / rotation. +

    + +

    Note: +The length of each dimension in the given grid does not exceed 50. +

    ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/number-of-islands-ii/README.md b/problems/number-of-islands-ii/README.md index 4229231a6..d11faa469 100644 --- a/problems/number-of-islands-ii/README.md +++ b/problems/number-of-islands-ii/README.md @@ -11,7 +11,60 @@ ## [305. Number of Islands II (Hard)](https://leetcode.com/problems/number-of-islands-ii "岛屿数量 II") +

    A 2d grid map of m rows and n columns is initially filled with water. We may perform an addLand operation which turns the water at position (row, col) into a land. Given a list of positions to operate, count the number of islands after each addLand operation. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.

    +

    Example:

    + +
    +Input: m = 3, n = 3, positions = [[0,0], [0,1], [1,2], [2,1]]
    +Output: [1,1,2,3]
    +
    + +

    Explanation:

    + +

    Initially, the 2d grid grid is filled with water. (Assume 0 represents water and 1 represents land).

    + +
    +0 0 0
    +0 0 0
    +0 0 0
    +
    + +

    Operation #1: addLand(0, 0) turns the water at grid[0][0] into a land.

    + +
    +1 0 0
    +0 0 0   Number of islands = 1
    +0 0 0
    +
    + +

    Operation #2: addLand(0, 1) turns the water at grid[0][1] into a land.

    + +
    +1 1 0
    +0 0 0   Number of islands = 1
    +0 0 0
    +
    + +

    Operation #3: addLand(1, 2) turns the water at grid[1][2] into a land.

    + +
    +1 1 0
    +0 0 1   Number of islands = 2
    +0 0 0
    +
    + +

    Operation #4: addLand(2, 1) turns the water at grid[2][1] into a land.

    + +
    +1 1 0
    +0 0 1   Number of islands = 3
    +0 1 0
    +
    + +

    Follow up:

    + +

    Can you do it in time complexity O(k log mn), where k is the length of the positions?

    ### Related Topics [[Union Find](../../tag/union-find/README.md)] diff --git a/problems/number-of-music-playlists/README.md b/problems/number-of-music-playlists/README.md index 4f5626237..7560a9845 100644 --- a/problems/number-of-music-playlists/README.md +++ b/problems/number-of-music-playlists/README.md @@ -11,58 +11,45 @@ ## [920. Number of Music Playlists (Hard)](https://leetcode.com/problems/number-of-music-playlists "播放列表的数量") -

    Your music player contains n different songs and she wants to listen to goal (not necessarily different) songs during your trip.  You create a playlist so that:

    +

    Your music player contains n different songs. You want to listen to goal songs (not necessarily different) during your trip. To avoid boredom, you will create a playlist so that:

      -
    • Every song is played at least once
    • -
    • A song can only be played again only if k other songs have been played
    • +
    • Every song is played at least once.
    • +
    • A song can only be played again only if k other songs have been played.
    -

    Return the number of possible playlists.  As the answer can be very large, return it modulo 109 + 7.

    - +

    Given n, goal, and k, return the number of possible playlists that you can create. Since the answer can be very large, return it modulo 109 + 7.

     

    - -
    -
    -

    Example 1:

    -Input: n = 3, goal = 3, k = 1
    -Output: 6
    -Explanation: There are 6 possible playlists. [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1].
    +Input: n = 3, goal = 3, k = 1
    +Output: 6
    +Explanation: There are 6 possible playlists: [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], and [3, 2, 1].
     
    -

    Example 2:

    -Input: n = 2, goal = 3, k = 0
    -Output: 6
    -Explanation: There are 6 possible playlists. [1, 1, 2], [1, 2, 1], [2, 1, 1], [2, 2, 1], [2, 1, 2], [1, 2, 2]
    +Input: n = 2, goal = 3, k = 0
    +Output: 6
    +Explanation: There are 6 possible playlists: [1, 1, 2], [1, 2, 1], [2, 1, 1], [2, 2, 1], [2, 1, 2], and [1, 2, 2].
     
    -

    Example 3:

    -Input: n = 2, goal = 3, k = 1
    -Output: 2
    -Explanation: There are 2 possible playlists. [1, 2, 1], [2, 1, 2]
    +Input: n = 2, goal = 3, k = 1
    +Output: 2
    +Explanation: There are 2 possible playlists: [1, 2, 1] and [2, 1, 2].
     
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 0 <= k < n <= goal <= 100
      • -
    -
    -
    -
    + ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/number-of-ships-in-a-rectangle/README.md b/problems/number-of-ships-in-a-rectangle/README.md index 50ffdb7a4..887639986 100644 --- a/problems/number-of-ships-in-a-rectangle/README.md +++ b/problems/number-of-ships-in-a-rectangle/README.md @@ -11,7 +11,36 @@ ## [1274. Number of Ships in a Rectangle (Hard)](https://leetcode.com/problems/number-of-ships-in-a-rectangle "矩形内船只的数目") +

    (This problem is an interactive problem.)

    +

    On the sea represented by a cartesian plane, each ship is located at an integer point, and each integer point may contain at most 1 ship.

    + +

    You have a function Sea.hasShips(topRight, bottomLeft) which takes two points as arguments and returns true if and only if there is at least one ship in the rectangle represented by the two points, including on the boundary.

    + +

    Given two points, which are the top right and bottom left corners of a rectangle, return the number of ships present in that rectangle.  It is guaranteed that there are at most 10 ships in that rectangle.

    + +

    Submissions making more than 400 calls to hasShips will be judged Wrong Answer.  Also, any solutions that attempt to circumvent the judge will result in disqualification.

    + +

     

    +

    Example :

    + +

    + +
    +Input: 
    +ships = [[1,1],[2,2],[3,3],[5,5]], topRight = [4,4], bottomLeft = [0,0]
    +Output: 3
    +Explanation: From [0,0] to [4,4] we can count 3 ships within the range.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • On the input ships is only given to initialize the map internally. You must solve this problem "blindfolded". In other words, you must find the answer using the given hasShips API, without knowing the ships position.
    • +
    • 0 <= bottomLeft[0] <= topRight[0] <= 1000
    • +
    • 0 <= bottomLeft[1] <= topRight[1] <= 1000
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md b/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md index 287f5d23f..02d544edb 100644 --- a/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md +++ b/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md @@ -11,18 +11,18 @@ ## [1404. Number of Steps to Reduce a Number in Binary Representation to One (Medium)](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one "将二进制表示减到 1 的步骤数") -

    Given a number s in their binary representation. Return the number of steps to reduce it to 1 under the following rules:

    +

    Given the binary representation of an integer as a string s, return the number of steps to reduce it to 1 under the following rules:

    • -

      If the current number is even, you have to divide it by 2.

      +

      If the current number is even, you have to divide it by 2.

    • -

      If the current number is odd, you have to add 1 to it.

      +

      If the current number is odd, you have to add 1 to it.

    -

    It's guaranteed that you can always reach to one for all testcases.

    +

    It is guaranteed that you can always reach one for all test cases.

     

    Example 1:

    diff --git a/problems/number-of-steps-to-reduce-a-number-to-zero/README.md b/problems/number-of-steps-to-reduce-a-number-to-zero/README.md index 9b1594ff3..911b06fb1 100644 --- a/problems/number-of-steps-to-reduce-a-number-to-zero/README.md +++ b/problems/number-of-steps-to-reduce-a-number-to-zero/README.md @@ -11,7 +11,9 @@ ## [1342. Number of Steps to Reduce a Number to Zero (Easy)](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero "将数字变成 0 的操作次数") -

    Given a non-negative integer num, return the number of steps to reduce it to zero. If the current number is even, you have to divide it by 2, otherwise, you have to subtract 1 from it.

    +

    Given an integer num, return the number of steps to reduce it to zero.

    + +

    In one step, if the current number is even, you have to divide it by 2, otherwise, you have to subtract 1 from it.

     

    Example 1:

    @@ -51,7 +53,7 @@ Step 4) 1 is odd; subtract 1 and obtain 0.

    Constraints:

      -
    • 0 <= num <= 10^6
    • +
    • 0 <= num <= 106
    ### Related Topics diff --git a/problems/number-of-transactions-per-visit/README.md b/problems/number-of-transactions-per-visit/README.md index 43fc1b21b..e4f0d2d1e 100644 --- a/problems/number-of-transactions-per-visit/README.md +++ b/problems/number-of-transactions-per-visit/README.md @@ -11,7 +11,87 @@ ## [1336. Number of Transactions per Visit (Hard)](https://leetcode.com/problems/number-of-transactions-per-visit "每次访问的交易次数") +

    Table: Visits

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| user_id       | int     |
    +| visit_date    | date    |
    ++---------------+---------+
    +(user_id, visit_date) is the primary key for this table.
    +Each row of this table indicates that user_id has visited the bank in visit_date.
    +
    +

    Table: Transactions

    +
    ++------------------+---------+
    +| Column Name      | Type    |
    ++------------------+---------+
    +| user_id          | int     |
    +| transaction_date | date    |
    +| amount           | int     |
    ++------------------+---------+
    +There is no primary key for this table, it may contain duplicates.
    +Each row of this table indicates that user_id has done a transaction of amount in transaction_date.
    +It is guaranteed that the user has visited the bank in the transaction_date.(i.e The Visits table contains (user_id, transaction_date) in one row)
    +
    + +Write an SQL query to find how many users visited the bank and didn't do any transactions, how many visited the bank and did one transaction and so on. + +The result table will contain two columns transactions_count which is the number of transactions done in one visit and visits_count which is the corresponding number of users who did transactions_count in one visit to the bank. transactions_count should take all values from 0 to max(transactions_count) done by one or more users. + +Order the result table by transactions_count. + +The query result format is in the following example: + +
    +Visits table:
    ++---------+------------+
    +| user_id | visit_date |
    ++---------+------------+
    +| 1       | 2020-01-01 |
    +| 2       | 2020-01-02 |
    +| 12      | 2020-01-01 |
    +| 19      | 2020-01-03 |
    +| 1       | 2020-01-02 |
    +| 2       | 2020-01-03 |
    +| 1       | 2020-01-04 |
    +| 7       | 2020-01-11 |
    +| 9       | 2020-01-25 |
    +| 8       | 2020-01-28 |
    ++---------+------------+
    +Transactions table:
    ++---------+------------------+--------+
    +| user_id | transaction_date | amount |
    ++---------+------------------+--------+
    +| 1       | 2020-01-02       | 120    |
    +| 2       | 2020-01-03       | 22     |
    +| 7       | 2020-01-11       | 232    |
    +| 1       | 2020-01-04       | 7      |
    +| 9       | 2020-01-25       | 33     |
    +| 9       | 2020-01-25       | 66     |
    +| 8       | 2020-01-28       | 1      |
    +| 9       | 2020-01-25       | 99     |
    ++---------+------------------+--------+
    +Result table:
    ++--------------------+--------------+
    +| transactions_count | visits_count |
    ++--------------------+--------------+
    +| 0                  | 4            |
    +| 1                  | 5            |
    +| 2                  | 0            |
    +| 3                  | 1            |
    ++--------------------+--------------+
    +Users 1, 2, 12 and 19 visited the bank in 2020-01-01, 2020-01-02, 2020-01-01 and 2020-01-03 respectively, and didn't do any transactions.
    +So we have visits_count = 4 for transactions_count = 0.
    +Users 2, 7 and 8 visited the bank in 2020-01-03, 2020-01-11 and 2020-01-28 respectively, and did one transaction.
    +User 1 Also visited the bank in 2020-01-02 and 2020-01-04 and did one transaction each day.
    +So we have total visits_count = 5 for transactions_count = 1.
    +For transactions_count = 2 we don't have any users who visited the bank and did two transactions.
    +For transactions_count = 3 we have user 9 who visited the bank in 2020-01-25 and did three transactions.
    +Note that we stopped at transactions_count = 3 as this is the maximum number of transactions done by one user in one visit to the bank.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/number-of-trusted-contacts-of-a-customer/README.md b/problems/number-of-trusted-contacts-of-a-customer/README.md index bb23bf2cd..301d149f1 100644 --- a/problems/number-of-trusted-contacts-of-a-customer/README.md +++ b/problems/number-of-trusted-contacts-of-a-customer/README.md @@ -11,7 +11,104 @@ ## [1364. Number of Trusted Contacts of a Customer (Medium)](https://leetcode.com/problems/number-of-trusted-contacts-of-a-customer "顾客的可信联系人数量") +

    Table: Customers

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| customer_id   | int     |
    +| customer_name | varchar |
    +| email         | varchar |
    ++---------------+---------+
    +customer_id is the primary key for this table.
    +Each row of this table contains the name and the email of a customer of an online shop.
    +
    + +

    Table: Contacts

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| user_id       | id      |
    +| contact_name  | varchar |
    +| contact_email | varchar |
    ++---------------+---------+
    +(user_id, contact_email) is the primary key for this table.
    +Each row of this table contains the name and email of one contact of customer with user_id.
    +This table contains information about people each customer trust. The contact may or may not exist in the Customers table.
    +
    +

    Table: Invoices

    +
    ++--------------+---------+
    +| Column Name  | Type    |
    ++--------------+---------+
    +| invoice_id   | int     |
    +| price        | int     |
    +| user_id      | int     |
    ++--------------+---------+
    +invoice_id is the primary key for this table.
    +Each row of this table indicates that user_id has an invoice with invoice_id and a price.
    +
    + +Write an SQL query to find the following for each invoice_id: + +- customer_name: The name of the customer the invoice is related to. +- price: The price of the invoice. +- contacts_cnt: The number of contacts related to the customer. +- trusted_contacts_cnt: The number of contacts related to the customer and at the same time they are customers to the shop. (i.e His/Her email exists in the Customers table.) + +Order the result table by invoice_id. + +The query result format is in the following example: +
    +Customers table:
    ++-------------+---------------+--------------------+
    +| customer_id | customer_name | email              |
    ++-------------+---------------+--------------------+
    +| 1           | Alice         | alice@leetcode.com |
    +| 2           | Bob           | bob@leetcode.com   |
    +| 13          | John          | john@leetcode.com  |
    +| 6           | Alex          | alex@leetcode.com  |
    ++-------------+---------------+--------------------+
    +Contacts table:
    ++-------------+--------------+--------------------+
    +| user_id     | contact_name | contact_email      |
    ++-------------+--------------+--------------------+
    +| 1           | Bob          | bob@leetcode.com   |
    +| 1           | John         | john@leetcode.com  |
    +| 1           | Jal          | jal@leetcode.com   |
    +| 2           | Omar         | omar@leetcode.com  |
    +| 2           | Meir         | meir@leetcode.com  |
    +| 6           | Alice        | alice@leetcode.com |
    ++-------------+--------------+--------------------+
    +Invoices table:
    ++------------+-------+---------+
    +| invoice_id | price | user_id |
    ++------------+-------+---------+
    +| 77         | 100   | 1       |
    +| 88         | 200   | 1       |
    +| 99         | 300   | 2       |
    +| 66         | 400   | 2       |
    +| 55         | 500   | 13      |
    +| 44         | 60    | 6       |
    ++------------+-------+---------+
    +Result table:
    ++------------+---------------+-------+--------------+----------------------+
    +| invoice_id | customer_name | price | contacts_cnt | trusted_contacts_cnt |
    ++------------+---------------+-------+--------------+----------------------+
    +| 44         | Alex          | 60    | 1            | 1                    |
    +| 55         | John          | 500   | 0            | 0                    |
    +| 66         | Bob           | 400   | 2            | 0                    |
    +| 77         | Alice         | 100   | 3            | 2                    |
    +| 88         | Alice         | 200   | 3            | 2                    |
    +| 99         | Bob           | 300   | 2            | 0                    |
    ++------------+---------------+-------+--------------+----------------------+
    +Alice has three contacts, two of them are trusted contacts (Bob and John).
    +Bob has two contacts, none of them is a trusted contact.
    +Alex has one contact and it is a trusted contact (Alice).
    +John doesn't have any contacts.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/number-of-valid-subarrays/README.md b/problems/number-of-valid-subarrays/README.md index d4fbbf89b..0a0bdd5a5 100644 --- a/problems/number-of-valid-subarrays/README.md +++ b/problems/number-of-valid-subarrays/README.md @@ -11,7 +11,44 @@ ## [1063. Number of Valid Subarrays (Hard)](https://leetcode.com/problems/number-of-valid-subarrays "有效子数组的数目") +

    Given an array A of integers, return the number of non-empty continuous subarrays that satisfy the following condition:

    +

    The leftmost element of the subarray is not larger than other elements in the subarray.

    + +

     

    + +

    Example 1:

    + +
    +Input: [1,4,2,5,3]
    +Output: 11
    +Explanation: There are 11 valid subarrays: [1],[4],[2],[5],[3],[1,4],[2,5],[1,4,2],[2,5,3],[1,4,2,5],[1,4,2,5,3].
    +
    + +

    Example 2:

    + +
    +Input: [3,2,1]
    +Output: 3
    +Explanation: The 3 valid subarrays are: [3],[2],[1].
    +
    + +

    Example 3:

    + +
    +Input: [2,2,2]
    +Output: 6
    +Explanation: There are 6 valid subarrays: [2],[2],[2],[2,2],[2,2],[2,2,2].
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= A.length <= 50000
    2. +
    3. 0 <= A[i] <= 100000
    4. +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/number-of-visible-people-in-a-queue/README.md b/problems/number-of-visible-people-in-a-queue/README.md new file mode 100644 index 000000000..03512d8cf --- /dev/null +++ b/problems/number-of-visible-people-in-a-queue/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../describe-the-painting "Describe the Painting") +                 +[Next >](../sum-of-digits-of-string-after-convert "Sum of Digits of String After Convert") + +## [1944. Number of Visible People in a Queue (Hard)](https://leetcode.com/problems/number-of-visible-people-in-a-queue "队列中可以看到的人数") + +

    There are n people standing in a queue, and they numbered from 0 to n - 1 in left to right order. You are given an array heights of distinct integers where heights[i] represents the height of the ith person.

    + +

    A person can see another person to their right in the queue if everybody in between is shorter than both of them. More formally, the ith person can see the jth person if i < j and min(heights[i], heights[j]) > max(heights[i+1], heights[i+2], ..., heights[j-1]).

    + +

    Return an array answer of length n where answer[i] is the number of people the ith person can see to their right in the queue.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: heights = [10,6,8,5,11,9]
    +Output: [3,1,2,1,1,0]
    +Explanation:
    +Person 0 can see person 1, 2, and 4.
    +Person 1 can see person 2.
    +Person 2 can see person 3 and 4.
    +Person 3 can see person 4.
    +Person 4 can see person 5.
    +Person 5 can see no one since nobody is to the right of them.
    +
    + +

    Example 2:

    + +
    +Input: heights = [5,1,2,3,10]
    +Output: [4,1,1,1,0]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == heights.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= heights[i] <= 105
    • +
    • All the values of heights are unique.
    • +
    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] + +### Hints +
    +Hint 1 +How to solve this problem in quadratic complexity ? +
    + +
    +Hint 2 +For every subarray start at index i, keep finding new maximum values until a value larger than arr[i] is found. +
    + +
    +Hint 3 +Since the limits are high, you need a linear solution. +
    + +
    +Hint 4 +Use a stack to keep the values of the array sorted as you iterate the array from the end to the start. +
    + +
    +Hint 5 +Keep popping from the stack the elements in sorted order until a value larger than arr[i] is found, these are the ones that person i can see. +
    diff --git a/problems/one-edit-distance/README.md b/problems/one-edit-distance/README.md index c7c5cb310..8dff8f8f8 100644 --- a/problems/one-edit-distance/README.md +++ b/problems/one-edit-distance/README.md @@ -11,7 +11,36 @@ ## [161. One Edit Distance (Medium)](https://leetcode.com/problems/one-edit-distance "相隔为 1 的编辑距离") +

    Given two strings s and t, determine if they are both one edit distance apart.

    +

    Note: 

    + +

    There are 3 possiblities to satisify one edit distance apart:

    + +
      +
    1. Insert a character into s to get t
    2. +
    3. Delete a character from s to get t
    4. +
    5. Replace a character of s to get t
    6. +
    + +

    Example 1:

    + +
    Input: s = "ab", t = "acb"
    +Output: true
    +Explanation: We can insert 'c' into s to get t.
    +
    + +

    Example 2:

    + +
    Input: s = "cab", t = "ad"
    +Output: false
    +Explanation: We cannot get t from s by only one step.
    + +

    Example 3:

    + +
    Input: s = "1203", t = "1213"
    +Output: true
    +Explanation: We can replace '0' with '1' to get t.
    ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/optimal-account-balancing/README.md b/problems/optimal-account-balancing/README.md index f68f8160c..0a74001fe 100644 --- a/problems/optimal-account-balancing/README.md +++ b/problems/optimal-account-balancing/README.md @@ -11,7 +11,50 @@ ## [465. Optimal Account Balancing (Hard)](https://leetcode.com/problems/optimal-account-balancing "最优账单平衡") +

    A group of friends went on holiday and sometimes lent each other money. For example, Alice paid for Bill's lunch for $10. Then later Chris gave Alice $5 for a taxi ride. We can model each transaction as a tuple (x, y, z) which means person x gave person y $z. Assuming Alice, Bill, and Chris are person 0, 1, and 2 respectively (0, 1, 2 are the person's ID), the transactions can be represented as [[0, 1, 10], [2, 0, 5]].

    +

    Given a list of transactions between a group of people, return the minimum number of transactions required to settle the debt.

    + +

    Note: +

      +
    1. A transaction will be given as a tuple (x, y, z). Note that x ≠ y and z > 0.
    2. +
    3. Person's IDs may not be linear, e.g. we could have the persons 0, 1, 2 or we could also have the persons 0, 2, 6.
    4. +
    +

    + +

    Example 1: +

    +Input:
    +[[0,1,10], [2,0,5]]
    +
    +Output:
    +2
    +
    +Explanation:
    +Person #0 gave person #1 $10.
    +Person #2 gave person #0 $5.
    +
    +Two transactions are needed. One way to settle the debt is person #1 pays person #0 and #2 $5 each.
    +
    +

    + +

    Example 2: +

    +Input:
    +[[0,1,10], [1,0,1], [1,2,5], [2,0,5]]
    +
    +Output:
    +1
    +
    +Explanation:
    +Person #0 gave person #1 $10.
    +Person #1 gave person #0 $1.
    +Person #1 gave person #2 $5.
    +Person #2 gave person #0 $5.
    +
    +Therefore, person #1 only need to give person #0 $4, and all debt is settled.
    +
    +

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/optimize-water-distribution-in-a-village/README.md b/problems/optimize-water-distribution-in-a-village/README.md index 6eaf6ae41..f946b9978 100644 --- a/problems/optimize-water-distribution-in-a-village/README.md +++ b/problems/optimize-water-distribution-in-a-village/README.md @@ -11,7 +11,37 @@ ## [1168. Optimize Water Distribution in a Village (Hard)](https://leetcode.com/problems/optimize-water-distribution-in-a-village "水资源分配优化") +

    There are n houses in a village. We want to supply water for all the houses by building wells and laying pipes.

    +

    For each house i, we can either build a well inside it directly with cost wells[i], or pipe in water from another well to it. The costs to lay pipes between houses are given by the array pipes, where each pipes[i] = [house1, house2, cost] represents the cost to connect house1 and house2 together using a pipe. Connections are bidirectional.

    + +

    Find the minimum total cost to supply water to all houses.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: n = 3, wells = [1,2,2], pipes = [[1,2,1],[2,3,1]]
    +Output: 3
    +Explanation: 
    +The image shows the costs of connecting houses using pipes.
    +The best strategy is to build a well in the first house with cost 1 and connect the other houses to it with cost 2 so the total cost is 3.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 10000
    • +
    • wells.length == n
    • +
    • 0 <= wells[i] <= 10^5
    • +
    • 1 <= pipes.length <= 10000
    • +
    • 1 <= pipes[i][0], pipes[i][1] <= n
    • +
    • 0 <= pipes[i][2] <= 10^5
    • +
    • pipes[i][0] != pipes[i][1]
    • +
    ### Related Topics [[Union Find](../../tag/union-find/README.md)] diff --git a/problems/orderly-queue/README.md b/problems/orderly-queue/README.md index 30bd525e2..057a44d4e 100644 --- a/problems/orderly-queue/README.md +++ b/problems/orderly-queue/README.md @@ -11,46 +11,38 @@ ## [899. Orderly Queue (Hard)](https://leetcode.com/problems/orderly-queue "有序队列") -

    A string s of lowercase letters is given.  Then, we may make any number of moves.

    +

    You are given a string s and an integer k. You can choose one of the first k letters of s and append it at the end of the string..

    -

    In each move, we choose one of the first k letters (starting from the left), remove it, and place it at the end of the string.

    - -

    Return the lexicographically smallest string we could have after any number of moves.

    +

    Return the lexicographically smallest string you could have after applying the mentioned step any number of moves.

     

    - -

    Example 1:

    -Input: s = "cba", k = 1
    -Output: "acb"
    -Explanation: 
    -In the first move, we move the 1st character ("c") to the end, obtaining the string "bac".
    -In the second move, we move the 1st character ("b") to the end, obtaining the final result "acb".
    +Input: s = "cba", k = 1
    +Output: "acb"
    +Explanation: 
    +In the first move, we move the 1st character 'c' to the end, obtaining the string "bac".
    +In the second move, we move the 1st character 'b' to the end, obtaining the final result "acb".
     
    -

    Example 2:

    -Input: s = "baaca", k = 3
    -Output: "aaabc"
    -Explanation: 
    -In the first move, we move the 1st character ("b") to the end, obtaining the string "aacab".
    -In the second move, we move the 3rd character ("c") to the end, obtaining the final result "aaabc".
    +Input: s = "baaca", k = 3
    +Output: "aaabc"
    +Explanation: 
    +In the first move, we move the 1st character 'b' to the end, obtaining the string "aacab".
    +In the second move, we move the 3rd character 'c' to the end, obtaining the final result "aaabc".
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= k <= s.length <= 1000
    2. -
    3. s consists of lowercase letters only.
    4. -
    -
    -
    +
      +
    • 1 <= k <= s.length <= 1000
    • +
    • s consist of lowercase English letters.
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/output-contest-matches/README.md b/problems/output-contest-matches/README.md index 536b90648..a0e9342e8 100644 --- a/problems/output-contest-matches/README.md +++ b/problems/output-contest-matches/README.md @@ -11,7 +11,49 @@ ## [544. Output Contest Matches (Medium)](https://leetcode.com/problems/output-contest-matches "输出比赛匹配对") +

    +During the NBA playoffs, we always arrange the rather strong team to play with the rather weak team, like make the rank 1 team play with the rank nth team, which is a good strategy to make the contest more interesting. Now, you're given n teams, you need to output their final contest matches in the form of a string. +

    +

    The n teams are given in the form of positive integers from 1 to n, which represents their initial rank. (Rank 1 is the strongest team and Rank n is the weakest team.) We'll use parentheses('(', ')') and commas(',') to represent the contest team pairing - parentheses('(' , ')') for pairing and commas(',') for partition. During the pairing process in each round, you always need to follow the strategy of making the rather strong one pair with the rather weak one.

    + +

    Example 1:
    +

    Input: 2
    +Output: (1,2)
    +Explanation: 
    +Initially, we have the team 1 and the team 2, placed like: 1,2.
    +Then we pair the team (1,2) together with '(', ')' and ',', which is the final answer.
    +
    +

    + +

    Example 2:
    +

    Input: 4
    +Output: ((1,4),(2,3))
    +Explanation: 
    +In the first round, we pair the team 1 and 4, the team 2 and 3 together, as we need to make the strong team and weak team together.
    +And we got (1,4),(2,3).
    +In the second round, the winners of (1,4) and (2,3) need to play again to generate the final winner, so you need to add the paratheses outside them.
    +And we got the final answer ((1,4),(2,3)).
    +
    +

    + +

    Example 3:
    +

    Input: 8
    +Output: (((1,8),(4,5)),((2,7),(3,6)))
    +Explanation: 
    +First round: (1,8),(2,7),(3,6),(4,5)
    +Second round: ((1,8),(4,5)),((2,7),(3,6))
    +Third round: (((1,8),(4,5)),((2,7),(3,6)))
    +Since the third round will generate the final winner, you need to output the answer (((1,8),(4,5)),((2,7),(3,6))).
    +
    +

    + +

    Note:
    +

      +
    1. The n is in range [2, 212].
    2. +
    3. We ensure that the input n can be converted into the form 2k, where k is a positive integer.
    4. +
    +

    ### Related Topics [[Recursion](../../tag/recursion/README.md)] diff --git a/problems/page-recommendations/README.md b/problems/page-recommendations/README.md index cf501ba71..928977a3e 100644 --- a/problems/page-recommendations/README.md +++ b/problems/page-recommendations/README.md @@ -11,7 +11,79 @@ ## [1264. Page Recommendations (Medium)](https://leetcode.com/problems/page-recommendations "页面推荐") +

    Table: Friendship

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| user1_id      | int     |
    +| user2_id      | int     |
    ++---------------+---------+
    +(user1_id, user2_id) is the primary key for this table.
    +Each row of this table indicates that there is a friendship relation between user1_id and user2_id.
    +
    + +

    Table: Likes

    +
    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| user_id     | int     |
    +| page_id     | int     |
    ++-------------+---------+
    +(user_id, page_id) is the primary key for this table.
    +Each row of this table indicates that user_id likes page_id.
    +
    + +Write an SQL query to recommend pages to the user with user_id = 1 using the pages that your friends liked. It should not recommend pages you already liked. +Return result table in any order without duplicates. + +The query result format is in the following example: +
    +Friendship table:
    ++----------+----------+
    +| user1_id | user2_id |
    ++----------+----------+
    +| 1        | 2        |
    +| 1        | 3        |
    +| 1        | 4        |
    +| 2        | 3        |
    +| 2        | 4        |
    +| 2        | 5        |
    +| 6        | 1        |
    ++----------+----------+
    + 
    +Likes table:
    ++---------+---------+
    +| user_id | page_id |
    ++---------+---------+
    +| 1       | 88      |
    +| 2       | 23      |
    +| 3       | 24      |
    +| 4       | 56      |
    +| 5       | 11      |
    +| 6       | 33      |
    +| 2       | 77      |
    +| 3       | 77      |
    +| 6       | 88      |
    ++---------+---------+
    +
    +Result table:
    ++------------------+
    +| recommended_page |
    ++------------------+
    +| 23               |
    +| 24               |
    +| 56               |
    +| 33               |
    +| 77               |
    ++------------------+
    +User one is friend with users 2, 3, 4 and 6.
    +Suggested pages are 23 from user 2, 24 from user 3, 56 from user 3 and 33 from user 6.
    +Page 77 is suggested from both user 2 and user 3.
    +Page 88 is not suggested because user 1 already likes it.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/paint-fence/README.md b/problems/paint-fence/README.md index 0e3f951db..3317001f8 100644 --- a/problems/paint-fence/README.md +++ b/problems/paint-fence/README.md @@ -11,7 +11,31 @@ ## [276. Paint Fence (Medium)](https://leetcode.com/problems/paint-fence "栅栏涂色") +

    There is a fence with n posts, each post can be painted with one of the k colors.

    +

    You have to paint all the posts such that no more than two adjacent fence posts have the same color.

    + +

    Return the total number of ways you can paint the fence.

    + +

    Note:
    +n and k are non-negative integers.

    + +

    Example:

    + +
    +Input: n = 3, k = 2
    +Output: 6
    +Explanation: Take c1 as color 1, c2 as color 2. All possible ways are:
    +
    +            post1  post2  post3      
    + -----      -----  -----  -----       
    +   1         c1     c1     c2 
    +   2         c1     c2     c1 
    +   3         c1     c2     c2 
    +   4         c2     c1     c1  
    +   5         c2     c1     c2
    +   6         c2     c2     c1
    +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/paint-house-ii/README.md b/problems/paint-house-ii/README.md index 3345b2eca..5b98e6c02 100644 --- a/problems/paint-house-ii/README.md +++ b/problems/paint-house-ii/README.md @@ -11,7 +11,24 @@ ## [265. Paint House II (Hard)](https://leetcode.com/problems/paint-house-ii "粉刷房子 II") +

    There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.

    +

    The cost of painting each house with a certain color is represented by a n x k cost matrix. For example, costs[0][0] is the cost of painting house 0 with color 0; costs[1][2] is the cost of painting house 1 with color 2, and so on... Find the minimum cost to paint all houses.

    + +

    Note:
    +All costs are positive integers.

    + +

    Example:

    + +
    +Input: [[1,5,3],[2,9,4]]
    +Output: 5
    +Explanation: Paint house 0 into color 0, paint house 1 into color 2. Minimum cost: 1 + 4 = 5; 
    +             Or paint house 0 into color 2, paint house 1 into color 0. Minimum cost: 3 + 2 = 5. 
    +
    + +

    Follow up:
    +Could you solve it in O(nk) runtime?

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/paint-house/README.md b/problems/paint-house/README.md index d841c5389..e1249385d 100644 --- a/problems/paint-house/README.md +++ b/problems/paint-house/README.md @@ -11,7 +11,21 @@ ## [256. Paint House (Medium)](https://leetcode.com/problems/paint-house "粉刷房子") +

    There are a row of n houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.

    +

    The cost of painting each house with a certain color is represented by a n x 3 cost matrix. For example, costs[0][0] is the cost of painting house 0 with color red; costs[1][2] is the cost of painting house 1 with color green, and so on... Find the minimum cost to paint all houses.

    + +

    Note:
    +All costs are positive integers.

    + +

    Example:

    + +
    +Input: [[17,2,17],[16,16,5],[14,3,19]]
    +Output: 10
    +Explanation: Paint house 0 into blue, paint house 1 into green, paint house 2 into blue. 
    +             Minimum cost: 2 + 5 + 3 = 10.
    +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/painting-a-grid-with-three-different-colors/README.md b/problems/painting-a-grid-with-three-different-colors/README.md new file mode 100644 index 000000000..ad44f8278 --- /dev/null +++ b/problems/painting-a-grid-with-three-different-colors/README.md @@ -0,0 +1,62 @@ + + + + + + + +[< Previous](../unique-length-3-palindromic-subsequences "Unique Length-3 Palindromic Subsequences") +                 +[Next >](../merge-bsts-to-create-single-bst "Merge BSTs to Create Single BST") + +## [1931. Painting a Grid With Three Different Colors (Hard)](https://leetcode.com/problems/painting-a-grid-with-three-different-colors "用三种不同颜色为网格涂色") + +

    You are given two integers m and n. Consider an m x n grid where each cell is initially white. You can paint each cell red, green, or blue. All cells must be painted.

    + +

    Return the number of ways to color the grid with no two adjacent cells having the same color. Since the answer can be very large, return it modulo 109 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: m = 1, n = 1
    +Output: 3
    +Explanation: The three possible colorings are shown in the image above.
    +
    + +

    Example 2:

    + +
    +Input: m = 1, n = 2
    +Output: 6
    +Explanation: The six possible colorings are shown in the image above.
    +
    + +

    Example 3:

    + +
    +Input: m = 5, n = 5
    +Output: 580986
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= m <= 5
    • +
    • 1 <= n <= 1000
    • +
    + +### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Represent each colored column by a bitmask based on each cell color. +
    + +
    +Hint 2 +Use bitmasks DP with state (currentCell, prevColumn). +
    diff --git a/problems/palindrome-permutation-ii/README.md b/problems/palindrome-permutation-ii/README.md index b63151147..8b50ed57e 100644 --- a/problems/palindrome-permutation-ii/README.md +++ b/problems/palindrome-permutation-ii/README.md @@ -11,7 +11,17 @@ ## [267. Palindrome Permutation II (Medium)](https://leetcode.com/problems/palindrome-permutation-ii "回文排列 II") +

    Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could be form.

    +

    Example 1:

    + +
    Input: "aabb"
    +Output: ["abba", "baab"]
    + +

    Example 2:

    + +
    Input: "abc"
    +Output: []
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/palindrome-permutation/README.md b/problems/palindrome-permutation/README.md index 8b9999282..18ecea9e5 100644 --- a/problems/palindrome-permutation/README.md +++ b/problems/palindrome-permutation/README.md @@ -11,7 +11,22 @@ ## [266. Palindrome Permutation (Easy)](https://leetcode.com/problems/palindrome-permutation "回文排列") +

    Given a string, determine if a permutation of the string could form a palindrome.

    +

    Example 1:

    + +
    Input: "code"
    +Output: false
    + +

    Example 2:

    + +
    Input: "aab"
    +Output: true
    + +

    Example 3:

    + +
    Input: "carerac"
    +Output: true
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/palindrome-removal/README.md b/problems/palindrome-removal/README.md index 65c8de011..63f3f227e 100644 --- a/problems/palindrome-removal/README.md +++ b/problems/palindrome-removal/README.md @@ -11,7 +11,33 @@ ## [1246. Palindrome Removal (Hard)](https://leetcode.com/problems/palindrome-removal "删除回文子数组") +

    Given an integer array arr, in one move you can select a palindromic subarray arr[i], arr[i+1], ..., arr[j] where i <= j, and remove that subarray from the given array. Note that after removing a subarray, the elements on the left and on the right of that subarray move to fill the gap left by the removal.

    +

    Return the minimum number of moves needed to remove all numbers from the array.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [1,2]
    +Output: 2
    +
    + +

    Example 2:

    + +
    +Input: arr = [1,3,4,1,5]
    +Output: 3
    +Explanation: Remove [4] then remove [1,3,1] then remove [5].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 100
    • +
    • 1 <= arr[i] <= 20
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/parallel-courses/README.md b/problems/parallel-courses/README.md index bcf5b1eb5..98fde90aa 100644 --- a/problems/parallel-courses/README.md +++ b/problems/parallel-courses/README.md @@ -11,7 +11,48 @@ ## [1136. Parallel Courses (Medium)](https://leetcode.com/problems/parallel-courses "平行课程") +

    There are N courses, labelled from 1 to N.

    +

    We are given relations[i] = [X, Y], representing a prerequisite relationship between course X and course Y: course X has to be studied before course Y.

    + +

    In one semester you can study any number of courses as long as you have studied all the prerequisites for the course you are studying.

    + +

    Return the minimum number of semesters needed to study all courses.  If there is no way to study all the courses, return -1.

    + +

     

    + +

    Example 1:

    + +

    + +
    +Input: N = 3, relations = [[1,3],[2,3]]
    +Output: 2
    +Explanation: 
    +In the first semester, courses 1 and 2 are studied. In the second semester, course 3 is studied.
    +
    + +

    Example 2:

    + +

    + +
    +Input: N = 3, relations = [[1,2],[2,3],[3,1]]
    +Output: -1
    +Explanation: 
    +No course can be studied because they depend on each other.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= N <= 5000
    2. +
    3. 1 <= relations.length <= 5000
    4. +
    5. relations[i][0] != relations[i][1]
    6. +
    7. There are no repeated relations in the input.
    8. +
    ### Related Topics [[Graph](../../tag/graph/README.md)] diff --git a/problems/partition-array-into-disjoint-intervals/README.md b/problems/partition-array-into-disjoint-intervals/README.md index 6f9349413..38534622d 100644 --- a/problems/partition-array-into-disjoint-intervals/README.md +++ b/problems/partition-array-into-disjoint-intervals/README.md @@ -11,49 +11,43 @@ ## [915. Partition Array into Disjoint Intervals (Medium)](https://leetcode.com/problems/partition-array-into-disjoint-intervals "分割数组") -

    Given an array nums, partition it into two (contiguous) subarrays left and right so that:

    +

    Given an integer array nums, partition it into two (contiguous) subarrays left and right so that:

      -
    • Every element in left is less than or equal to every element in right.
    • +
    • Every element in left is less than or equal to every element in right.
    • left and right are non-empty.
    • -
    • left has the smallest possible size.
    • +
    • left has the smallest possible size.
    -

    Return the length of left after such a partitioning.  It is guaranteed that such a partitioning exists.

    +

    Return the length of left after such a partitioning.

    -

     

    +

    Test cases are generated such that partitioning exists.

    +

     

    Example 1:

    -Input: nums = [5,0,3,8,6]
    -Output: 3
    -Explanation: left = [5,0,3], right = [8,6]
    +Input: nums = [5,0,3,8,6]
    +Output: 3
    +Explanation: left = [5,0,3], right = [8,6]
     
    -

    Example 2:

    -Input: nums = [1,1,1,0,6,12]
    -Output: 4
    -Explanation: left = [1,1,1,0], right = [6,12]
    +Input: nums = [1,1,1,0,6,12]
    +Output: 4
    +Explanation: left = [1,1,1,0], right = [6,12]
     

     

    -
    - -

    Note:

    +

    Constraints:

    -
      -
    1. 2 <= nums.length <= 30000
    2. +
        +
      • 2 <= nums.length <= 105
      • 0 <= nums[i] <= 106
      • -
      • It is guaranteed there is at least one way to partition nums as described.
      • -
    - -
    -
     
    -
    +
  • There is at least one valid answer for the given input.
  • + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/path-sum-iv/README.md b/problems/path-sum-iv/README.md index eee284b9e..a1d262920 100644 --- a/problems/path-sum-iv/README.md +++ b/problems/path-sum-iv/README.md @@ -11,7 +11,49 @@ ## [666. Path Sum IV (Medium)](https://leetcode.com/problems/path-sum-iv "路径总和 IV") +

    If the depth of a tree is smaller than 5, then this tree can be represented by a list of three-digits integers.

    +

    For each integer in this list:

    + +
      +
    1. The hundreds digit represents the depth D of this node, 1 <= D <= 4.
    2. +
    3. The tens digit represents the position P of this node in the level it belongs to, 1 <= P <= 8. The position is the same as that in a full binary tree.
    4. +
    5. The units digit represents the value V of this node, 0 <= V <= 9.
    6. +
    + +

     

    + +

    Given a list of ascending three-digits integers representing a binary tree with the depth smaller than 5, you need to return the sum of all paths from the root towards the leaves.

    + +

    Example 1:

    + +
    Input: [113, 215, 221]
    +Output: 12
    +Explanation: 
    +The tree that the list represents is:
    +    3
    +   / \
    +  5   1
    +
    +The path sum is (3 + 5) + (3 + 1) = 12.
    +
    + +

     

    + +

    Example 2:

    + +
    Input: [113, 221]
    +Output: 4
    +Explanation: 
    +The tree that the list represents is: 
    +    3
    +     \
    +      1
    +
    +The path sum is (3 + 1) = 4.
    +
    + +

     

    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/path-with-maximum-minimum-value/README.md b/problems/path-with-maximum-minimum-value/README.md index 0f0174ec9..7e183be3b 100644 --- a/problems/path-with-maximum-minimum-value/README.md +++ b/problems/path-with-maximum-minimum-value/README.md @@ -11,7 +11,49 @@ ## [1102. Path With Maximum Minimum Value (Medium)](https://leetcode.com/problems/path-with-maximum-minimum-value "得分最高的路径") +

    Given a matrix of integers A with R rows and C columns, find the maximum score of a path starting at [0,0] and ending at [R-1,C-1].

    +

    The score of a path is the minimum value in that path.  For example, the value of the path 8 →  4 →  5 →  9 is 4.

    + +

    A path moves some number of times from one visited cell to any neighbouring unvisited cell in one of the 4 cardinal directions (north, east, west, south).

    + +

     

    + +

    Example 1:

    + +

    + +
    +Input: [[5,4,5],[1,2,6],[7,4,6]]
    +Output: 4
    +Explanation: 
    +The path with the maximum score is highlighted in yellow. 
    +
    + +

    Example 2:

    + +

    + +
    +Input: [[2,2,1,2,2,2],[1,2,2,2,1,2]]
    +Output: 2
    + +

    Example 3:

    + +

    + +
    +Input: [[3,4,6,3,4],[0,2,1,1,7],[8,8,3,2,7],[3,2,4,9,8],[4,1,2,0,0],[4,6,5,4,3]]
    +Output: 3
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= R, C <= 100
    2. +
    3. 0 <= A[i][j] <= 10^9
    4. +
    ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/plus-one-linked-list/README.md b/problems/plus-one-linked-list/README.md index d20fb17e5..b8d162510 100644 --- a/problems/plus-one-linked-list/README.md +++ b/problems/plus-one-linked-list/README.md @@ -11,7 +11,19 @@ ## [369. Plus One Linked List (Medium)](https://leetcode.com/problems/plus-one-linked-list "给单链表加一") +

    Given a non-negative integer represented as non-empty a singly linked list of digits, plus one to the integer.

    +

    You may assume the integer do not contain any leading zero, except the number 0 itself.

    + +

    The digits are stored such that the most significant digit is at the head of the list.

    + +
    +

    Example :

    + +
    +Input: [1,2,3]
    +Output: [1,2,4]
    +
    ### Related Topics [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/possible-bipartition/README.md b/problems/possible-bipartition/README.md index fc7878def..1bd27615c 100644 --- a/problems/possible-bipartition/README.md +++ b/problems/possible-bipartition/README.md @@ -11,61 +11,43 @@ ## [886. Possible Bipartition (Medium)](https://leetcode.com/problems/possible-bipartition "可能的二分法") -

    Given a set of n people (numbered 1, 2, ..., n), we would like to split everyone into two groups of any size.

    +

    We want to split a group of n people (labeled from 1 to n) into two groups of any size. Each person may dislike some other people, and they should not go into the same group.

    -

    Each person may dislike some other people, and they should not go into the same group. 

    - -

    Formally, if dislikes[i] = [a, b], it means it is not allowed to put the people numbered a and b into the same group.

    - -

    Return true if and only if it is possible to split everyone into two groups in this way.

    +

    Given the integer n and the array dislikes where dislikes[i] = [ai, bi] indicates that the person labeled ai does not like the person labeled bi, return true if it is possible to split everyone into two groups in this way.

     

    - -
    -
    -
      -
    -
    -
    - -

    Example 1:

    -Input: n = 4, dislikes = [[1,2],[1,3],[2,4]]
    -Output: true
    -Explanation: group1 [1,4], group2 [2,3]
    +Input: n = 4, dislikes = [[1,2],[1,3],[2,4]]
    +Output: true
    +Explanation: group1 [1,4] and group2 [2,3].
     
    -

    Example 2:

    -Input: n = 3, dislikes = [[1,2],[1,3],[2,3]]
    -Output: false
    +Input: n = 3, dislikes = [[1,2],[1,3],[2,3]]
    +Output: false
     
    -

    Example 3:

    -Input: n = 5, dislikes = [[1,2],[2,3],[3,4],[4,5],[1,5]]
    -Output: false
    +Input: n = 5, dislikes = [[1,2],[2,3],[3,4],[4,5],[1,5]]
    +Output: false
     
    -
    -
    -

     

    Constraints:

    • 1 <= n <= 2000
    • -
    • 0 <= dislikes.length <= 10000
    • +
    • 0 <= dislikes.length <= 104
    • dislikes[i].length == 2
    • 1 <= dislikes[i][j] <= n
    • -
    • dislikes[i][0] < dislikes[i][1]
    • -
    • There does not exist i != j for which dislikes[i] == dislikes[j].
    • +
    • ai < bi
    • +
    • All the pairs of dislikes are unique.
    ### Related Topics diff --git a/problems/pour-water/README.md b/problems/pour-water/README.md index c3b6d4d6b..5cb10675a 100644 --- a/problems/pour-water/README.md +++ b/problems/pour-water/README.md @@ -11,7 +11,129 @@ ## [755. Pour Water (Medium)](https://leetcode.com/problems/pour-water "倒水") +

    +We are given an elevation map, heights[i] representing the height of the terrain at that index. The width at each index is 1. After V units of water fall at index K, how much water is at each index? +

    +Water first drops at index K and rests on top of the highest terrain or water at that index. Then, it flows according to the following rules: +

  • If the droplet would eventually fall by moving left, then move left.
  • +
  • Otherwise, if the droplet would eventually fall by moving right, then move right.
  • +
  • Otherwise, rise at it's current position.
  • +Here, "eventually fall" means that the droplet will eventually be at a lower level if it moves in that direction. +Also, "level" means the height of the terrain plus any water in that column. +

    +We can assume there's infinitely high terrain on the two sides out of bounds of the array. Also, there could not be partial water being spread out evenly on more than 1 grid block - each unit of water has to be in exactly one block. +

    +

    Example 1:
    +

    +Input: heights = [2,1,1,2,1,2,2], V = 4, K = 3
    +Output: [2,2,2,3,2,2,2]
    +Explanation:
    +#       #
    +#       #
    +##  # ###
    +#########
    + 0123456    <- index
    +
    +The first drop of water lands at index K = 3:
    +
    +#       #
    +#   w   #
    +##  # ###
    +#########
    + 0123456    
    +
    +When moving left or right, the water can only move to the same level or a lower level.
    +(By level, we mean the total height of the terrain plus any water in that column.)
    +Since moving left will eventually make it fall, it moves left.
    +(A droplet "made to fall" means go to a lower height than it was at previously.)
    +
    +#       #
    +#       #
    +## w# ###
    +#########
    + 0123456    
    +
    +Since moving left will not make it fall, it stays in place.  The next droplet falls:
    +
    +#       #
    +#   w   #
    +## w# ###
    +#########
    + 0123456  
    +
    +Since the new droplet moving left will eventually make it fall, it moves left.
    +Notice that the droplet still preferred to move left,
    +even though it could move right (and moving right makes it fall quicker.)
    +
    +#       #
    +#  w    #
    +## w# ###
    +#########
    + 0123456  
    +
    +#       #
    +#       #
    +##ww# ###
    +#########
    + 0123456  
    +
    +After those steps, the third droplet falls.
    +Since moving left would not eventually make it fall, it tries to move right.
    +Since moving right would eventually make it fall, it moves right.
    +
    +#       #
    +#   w   #
    +##ww# ###
    +#########
    + 0123456  
    +
    +#       #
    +#       #
    +##ww#w###
    +#########
    + 0123456  
    +
    +Finally, the fourth droplet falls.
    +Since moving left would not eventually make it fall, it tries to move right.
    +Since moving right would not eventually make it fall, it stays in place:
    +
    +#       #
    +#   w   #
    +##ww#w###
    +#########
    + 0123456  
    +
    +The final answer is [2,2,2,3,2,2,2]:
    +
    +    #    
    + ####### 
    + ####### 
    + 0123456 
    +
    +

    + +

    Example 2:
    +

    +Input: heights = [1,2,3,4], V = 2, K = 2
    +Output: [2,3,3,4]
    +Explanation:
    +The last droplet settles at index 1, since moving further left would not cause it to eventually fall to a lower height.
    +
    +

    + +

    Example 3:
    +

    +Input: heights = [3,1,3], V = 5, K = 1
    +Output: [4,4,4]
    +
    +

    + +

    Note:

      +
    1. heights will have length in [1, 100] and contain integers in [0, 99].
    2. +
    3. V will be in range [0, 2000].
    4. +
    5. K will be in range [0, heights.length - 1].
    6. +

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/preimage-size-of-factorial-zeroes-function/README.md b/problems/preimage-size-of-factorial-zeroes-function/README.md index 0e624d4ff..281ec3e29 100644 --- a/problems/preimage-size-of-factorial-zeroes-function/README.md +++ b/problems/preimage-size-of-factorial-zeroes-function/README.md @@ -11,26 +11,43 @@ ## [793. Preimage Size of Factorial Zeroes Function (Hard)](https://leetcode.com/problems/preimage-size-of-factorial-zeroes-function "阶乘函数后 K 个零") -

    Let f(x) be the number of zeroes at the end of x!. (Recall that x! = 1 * 2 * 3 * ... * x, and by convention, 0! = 1.)

    +

    Let f(x) be the number of zeroes at the end of x!. Recall that x! = 1 * 2 * 3 * ... * x and by convention, 0! = 1.

    -

    For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has 2 zeroes at the end. Given k, find how many non-negative integers x have the property that f(x) = k.

    +
      +
    • For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has two zeroes at the end.
    • +
    + +

    Given an integer k, return the number of non-negative integers x have the property that f(x) = k.

    + +

     

    +

    Example 1:

    -Example 1:
     Input: k = 0
     Output: 5
     Explanation: 0!, 1!, 2!, 3!, and 4! end with k = 0 zeroes.
    +
    + +

    Example 2:

    -Example 2: +
     Input: k = 5
     Output: 0
     Explanation: There is no x such that x! ends in k = 5 zeroes.
     
    -

    Note:

    +

    Example 3:

    + +
    +Input: k = 3
    +Output: 5
    +
    + +

     

    +

    Constraints:

      -
    • k will be an integer in the range [0, 109].
    • +
    • 0 <= k <= 109
    ### Related Topics diff --git a/problems/prime-palindrome/README.md b/problems/prime-palindrome/README.md index 0bb6264d7..6a821c8e6 100644 --- a/problems/prime-palindrome/README.md +++ b/problems/prime-palindrome/README.md @@ -11,51 +11,38 @@ ## [866. Prime Palindrome (Medium)](https://leetcode.com/problems/prime-palindrome "回文素数") -

    Find the smallest prime palindrome greater than or equal to n.

    +

    Given an integer n, return the smallest prime palindrome greater than or equal to n.

    -

    Recall that a number is prime if it's only divisors are 1 and itself, and it is greater than 1. 

    +

    An integer is prime if it has exactly two divisors: 1 and itself. Note that 1 is not a prime number.

    -

    For example, 2,3,5,7,11 and 13 are primes.

    +
      +
    • For example, 2, 3, 5, 7, 11, and 13 are all primes.
    • +
    -

    Recall that a number is a palindrome if it reads the same from left to right as it does from right to left. 

    +

    An integer is a palindrome if it reads the same from left to right as it does from right to left.

    -

    For example, 12321 is a palindrome.

    +
      +
    • For example, 101 and 12321 are palindromes.
    • +
    -

     

    +

    The test cases are generated so that the answer always exists and is in the range [2, 2 * 108].

    -
    +

     

    Example 1:

    - -
    -Input: n = 6
    -Output: 7
    +
    Input: n = 6
    +Output: 7
    +

    Example 2:

    +
    Input: n = 8
    +Output: 11
    +

    Example 3:

    +
    Input: n = 13
    +Output: 101
     
    - -
    -

    Example 2:

    - -
    -Input: n = 8
    -Output: 11
    -
    - -
    -

    Example 3:

    - -
    -Input: n = 13
    -Output: 101
    -
    -
    -
    -

     

    - -

    Note:

    +

    Constraints:

    • 1 <= n <= 108
    • -
    • The answer is guaranteed to exist and be less than 2 * 108.
    ### Related Topics diff --git a/problems/print-immutable-linked-list-in-reverse/README.md b/problems/print-immutable-linked-list-in-reverse/README.md index 70120f8cb..dce74d494 100644 --- a/problems/print-immutable-linked-list-in-reverse/README.md +++ b/problems/print-immutable-linked-list-in-reverse/README.md @@ -11,7 +11,44 @@ ## [1265. Print Immutable Linked List in Reverse (Medium)](https://leetcode.com/problems/print-immutable-linked-list-in-reverse "逆序打印不可变链表") +You are given an immutable linked list, print out all values of each node in reverse with the help of the following interface: +- ImmutableListNode: An interface of immutable linked list, you are given the head of the list. +You need to use the following functions to access the linked list (you can't access the ImmutableListNode directly): + +- ImmutableListNode.printValue(): Print value of the current node. +- ImmutableListNode.getNext(): Return the next node. +The input is only given to initialize the linked list internally. You must solve this problem without modifying the linked list. In other words, you must operate the linked list using only the mentioned APIs. + +Follow up: + +Could you solve this problem in: + +- Constant space complexity? +- Linear time complexity and less than linear space complexity? + +

    Example 1:

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

    Example 2:

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

    Example 3:

    +
    +Input: head = [-2,0,6,4,4,-6]
    +Output: [-6,4,4,6,0,-2]
    +
    + +Constraints: + +- The length of the linked list is between [1, 1000]. +- The value of each node in the linked list is between [-1000, 1000]. ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/product-of-the-last-k-numbers/README.md b/problems/product-of-the-last-k-numbers/README.md index d33a5cccc..d35c25586 100644 --- a/problems/product-of-the-last-k-numbers/README.md +++ b/problems/product-of-the-last-k-numbers/README.md @@ -63,10 +63,10 @@ productOfNumbers.getProduct(2); // return 32. The product of the last 2 numbers ### Related Topics - [[Array](../../tag/array/README.md)] - [[Math](../../tag/math/README.md)] [[Design](../../tag/design/README.md)] [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] [[Data Stream](../../tag/data-stream/README.md)] ### Hints diff --git a/problems/product-price-at-a-given-date/README.md b/problems/product-price-at-a-given-date/README.md index 45f6e78c0..baaa94e77 100644 --- a/problems/product-price-at-a-given-date/README.md +++ b/problems/product-price-at-a-given-date/README.md @@ -11,7 +11,47 @@ ## [1164. Product Price at a Given Date (Medium)](https://leetcode.com/problems/product-price-at-a-given-date "指定日期的产品价格") +

    Table: Products

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| product_id    | int     |
    +| new_price     | int     |
    +| change_date   | date    |
    ++---------------+---------+
    +(product_id, change_date) is the primary key of this table.
    +Each row of this table indicates that the price of some product was changed to a new price at some date.
    + +

     

    + +

    Write an SQL query to find the prices of all products on 2019-08-16. Assume the price of all products before any change is 10.

    + +

    The query result format is in the following example:

    + +
    +Products table:
    ++------------+-----------+-------------+
    +| product_id | new_price | change_date |
    ++------------+-----------+-------------+
    +| 1          | 20        | 2019-08-14  |
    +| 2          | 50        | 2019-08-14  |
    +| 1          | 30        | 2019-08-15  |
    +| 1          | 35        | 2019-08-16  |
    +| 2          | 65        | 2019-08-17  |
    +| 3          | 20        | 2019-08-18  |
    ++------------+-----------+-------------+
    +
    +Result table:
    ++------------+-------+
    +| product_id | price |
    ++------------+-------+
    +| 2          | 50    |
    +| 1          | 35    |
    +| 3          | 10    |
    ++------------+-------+
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/product-sales-analysis-i/README.md b/problems/product-sales-analysis-i/README.md index bc27e631d..e79cb23de 100644 --- a/problems/product-sales-analysis-i/README.md +++ b/problems/product-sales-analysis-i/README.md @@ -11,7 +11,69 @@ ## [1068. Product Sales Analysis I (Easy)](https://leetcode.com/problems/product-sales-analysis-i "产品销售分析 I") +

    Table: Sales

    +
    ++-------------+-------+
    +| Column Name | Type  |
    ++-------------+-------+
    +| sale_id     | int   |
    +| product_id  | int   |
    +| year        | int   |
    +| quantity    | int   |
    +| price       | int   |
    ++-------------+-------+
    +(sale_id, year) is the primary key of this table.
    +product_id is a foreign key to Product table.
    +Note that the price is per unit.
    +
    + +

    Table: Product

    + +
    ++--------------+---------+
    +| Column Name  | Type    |
    ++--------------+---------+
    +| product_id   | int     |
    +| product_name | varchar |
    ++--------------+---------+
    +product_id is the primary key of this table.
    +
    + +

     

    + +

    Write an SQL query that reports all product names of the products in the Sales table along with their selling year and price.

    + +

    For example:

    + +
    +Sales table:
    ++---------+------------+------+----------+-------+
    +| sale_id | product_id | year | quantity | price |
    ++---------+------------+------+----------+-------+ 
    +| 1       | 100        | 2008 | 10       | 5000  |
    +| 2       | 100        | 2009 | 12       | 5000  |
    +| 7       | 200        | 2011 | 15       | 9000  |
    ++---------+------------+------+----------+-------+
    +
    +Product table:
    ++------------+--------------+
    +| product_id | product_name |
    ++------------+--------------+
    +| 100        | Nokia        |
    +| 200        | Apple        |
    +| 300        | Samsung      |
    ++------------+--------------+
    +
    +Result table:
    ++--------------+-------+-------+
    +| product_name | year  | price |
    ++--------------+-------+-------+
    +| Nokia        | 2008  | 5000  |
    +| Nokia        | 2009  | 5000  |
    +| Apple        | 2011  | 9000  |
    ++--------------+-------+-------+
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/product-sales-analysis-ii/README.md b/problems/product-sales-analysis-ii/README.md index 3dacdaeef..178056173 100644 --- a/problems/product-sales-analysis-ii/README.md +++ b/problems/product-sales-analysis-ii/README.md @@ -11,7 +11,67 @@ ## [1069. Product Sales Analysis II (Easy)](https://leetcode.com/problems/product-sales-analysis-ii "产品销售分析 II") +

    Table: Sales

    +
    ++-------------+-------+
    +| Column Name | Type  |
    ++-------------+-------+
    +| sale_id     | int   |
    +| product_id  | int   |
    +| year        | int   |
    +| quantity    | int   |
    +| price       | int   |
    ++-------------+-------+
    +sale_id is the primary key of this table.
    +product_id is a foreign key to Product table.
    +Note that the price is per unit.
    +
    + +

    Table: Product

    + +
    ++--------------+---------+
    +| Column Name  | Type    |
    ++--------------+---------+
    +| product_id   | int     |
    +| product_name | varchar |
    ++--------------+---------+
    +product_id is the primary key of this table.
    +
    + +

     

    + +

    Write an SQL query that reports the total quantity sold for every product id.

    + +

    The query result format is in the following example:

    + +
    +Sales table:
    ++---------+------------+------+----------+-------+
    +| sale_id | product_id | year | quantity | price |
    ++---------+------------+------+----------+-------+ 
    +| 1       | 100        | 2008 | 10       | 5000  |
    +| 2       | 100        | 2009 | 12       | 5000  |
    +| 7       | 200        | 2011 | 15       | 9000  |
    ++---------+------------+------+----------+-------+
    +
    +Product table:
    ++------------+--------------+
    +| product_id | product_name |
    ++------------+--------------+
    +| 100        | Nokia        |
    +| 200        | Apple        |
    +| 300        | Samsung      |
    ++------------+--------------+
    +
    +Result table:
    ++--------------+----------------+
    +| product_id   | total_quantity |
    ++--------------+----------------+
    +| 100          | 22             |
    +| 200          | 15             |
    ++--------------+----------------+
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/product-sales-analysis-iii/README.md b/problems/product-sales-analysis-iii/README.md index 452616894..2f7335315 100644 --- a/problems/product-sales-analysis-iii/README.md +++ b/problems/product-sales-analysis-iii/README.md @@ -11,7 +11,68 @@ ## [1070. Product Sales Analysis III (Medium)](https://leetcode.com/problems/product-sales-analysis-iii "产品销售分析 III") +

    Table: Sales

    +
    ++-------------+-------+
    +| Column Name | Type  |
    ++-------------+-------+
    +| sale_id     | int   |
    +| product_id  | int   |
    +| year        | int   |
    +| quantity    | int   |
    +| price       | int   |
    ++-------------+-------+
    +sale_id is the primary key of this table.
    +product_id is a foreign key to Product table.
    +Note that the price is per unit.
    +
    + +

    Table: Product

    + +
    ++--------------+---------+
    +| Column Name  | Type    |
    ++--------------+---------+
    +| product_id   | int     |
    +| product_name | varchar |
    ++--------------+---------+
    +product_id is the primary key of this table.
    +
    + +

     

    + +

    Write an SQL query that selects the product id, year, quantity, and price for the first year of every product sold.

    + +

    The query result format is in the following example:

    + +
    +Sales table:
    ++---------+------------+------+----------+-------+
    +| sale_id | product_id | year | quantity | price |
    ++---------+------------+------+----------+-------+ 
    +| 1       | 100        | 2008 | 10       | 5000  |
    +| 2       | 100        | 2009 | 12       | 5000  |
    +| 7       | 200        | 2011 | 15       | 9000  |
    ++---------+------------+------+----------+-------+
    +
    +Product table:
    ++------------+--------------+
    +| product_id | product_name |
    ++------------+--------------+
    +| 100        | Nokia        |
    +| 200        | Apple        |
    +| 300        | Samsung      |
    ++------------+--------------+
    +
    +Result table:
    ++------------+------------+----------+-------+
    +| product_id | first_year | quantity | price |
    ++------------+------------+----------+-------+ 
    +| 100        | 2008       | 10       | 5000  |
    +| 200        | 2011       | 15       | 9000  |
    ++------------+------------+----------+-------+
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/project-employees-i/README.md b/problems/project-employees-i/README.md index 809adbe71..55a182751 100644 --- a/problems/project-employees-i/README.md +++ b/problems/project-employees-i/README.md @@ -11,7 +11,69 @@ ## [1075. Project Employees I (Easy)](https://leetcode.com/problems/project-employees-i "项目员工 I") +

    Table: Project

    +
    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| project_id  | int     |
    +| employee_id | int     |
    ++-------------+---------+
    +(project_id, employee_id) is the primary key of this table.
    +employee_id is a foreign key to Employee table.
    +
    + +

    Table: Employee

    + +
    ++------------------+---------+
    +| Column Name      | Type    |
    ++------------------+---------+
    +| employee_id      | int     |
    +| name             | varchar |
    +| experience_years | int     |
    ++------------------+---------+
    +employee_id is the primary key of this table.
    +
    + +

     

    + +

    Write an SQL query that reports the average experience years of all the employees for each project, rounded to 2 digits.

    + +

    The query result format is in the following example:

    + +
    +Project table:
    ++-------------+-------------+
    +| project_id  | employee_id |
    ++-------------+-------------+
    +| 1           | 1           |
    +| 1           | 2           |
    +| 1           | 3           |
    +| 2           | 1           |
    +| 2           | 4           |
    ++-------------+-------------+
    +
    +Employee table:
    ++-------------+--------+------------------+
    +| employee_id | name   | experience_years |
    ++-------------+--------+------------------+
    +| 1           | Khaled | 3                |
    +| 2           | Ali    | 2                |
    +| 3           | John   | 1                |
    +| 4           | Doe    | 2                |
    ++-------------+--------+------------------+
    +
    +Result table:
    ++-------------+---------------+
    +| project_id  | average_years |
    ++-------------+---------------+
    +| 1           | 2.00          |
    +| 2           | 2.50          |
    ++-------------+---------------+
    +The average experience years for the first project is (3 + 2 + 1) / 3 = 2.00 and for the second project is (3 + 2) / 2 = 2.50
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/project-employees-ii/README.md b/problems/project-employees-ii/README.md index 740494b48..219af6dd1 100644 --- a/problems/project-employees-ii/README.md +++ b/problems/project-employees-ii/README.md @@ -11,7 +11,67 @@ ## [1076. Project Employees II (Easy)](https://leetcode.com/problems/project-employees-ii "项目员工II") +

    Table: Project

    +
    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| project_id  | int     |
    +| employee_id | int     |
    ++-------------+---------+
    +(project_id, employee_id) is the primary key of this table.
    +employee_id is a foreign key to Employee table.
    +
    + +

    Table: Employee

    + +
    ++------------------+---------+
    +| Column Name      | Type    |
    ++------------------+---------+
    +| employee_id      | int     |
    +| name             | varchar |
    +| experience_years | int     |
    ++------------------+---------+
    +employee_id is the primary key of this table.
    +
    + +

     

    + +

    Write an SQL query that reports all the projects that have the most employees.

    + +

    The query result format is in the following example:

    + +
    +Project table:
    ++-------------+-------------+
    +| project_id  | employee_id |
    ++-------------+-------------+
    +| 1           | 1           |
    +| 1           | 2           |
    +| 1           | 3           |
    +| 2           | 1           |
    +| 2           | 4           |
    ++-------------+-------------+
    +
    +Employee table:
    ++-------------+--------+------------------+
    +| employee_id | name   | experience_years |
    ++-------------+--------+------------------+
    +| 1           | Khaled | 3                |
    +| 2           | Ali    | 2                |
    +| 3           | John   | 1                |
    +| 4           | Doe    | 2                |
    ++-------------+--------+------------------+
    +
    +Result table:
    ++-------------+
    +| project_id  |
    ++-------------+
    +| 1           |
    ++-------------+
    +The first project has 3 employees while the second one has 2.
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/project-employees-iii/README.md b/problems/project-employees-iii/README.md index 205f55327..6888a3376 100644 --- a/problems/project-employees-iii/README.md +++ b/problems/project-employees-iii/README.md @@ -11,7 +11,69 @@ ## [1077. Project Employees III (Medium)](https://leetcode.com/problems/project-employees-iii "项目员工 III") +

    Table: Project

    +
    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| project_id  | int     |
    +| employee_id | int     |
    ++-------------+---------+
    +(project_id, employee_id) is the primary key of this table.
    +employee_id is a foreign key to Employee table.
    +
    + +

    Table: Employee

    + +
    ++------------------+---------+
    +| Column Name      | Type    |
    ++------------------+---------+
    +| employee_id      | int     |
    +| name             | varchar |
    +| experience_years | int     |
    ++------------------+---------+
    +employee_id is the primary key of this table.
    +
    + +

     

    + +

    Write an SQL query that reports the most experienced employees in each project. In case of a tie, report all employees with the maximum number of experience years.

    + +

    The query result format is in the following example:

    + +
    +Project table:
    ++-------------+-------------+
    +| project_id  | employee_id |
    ++-------------+-------------+
    +| 1           | 1           |
    +| 1           | 2           |
    +| 1           | 3           |
    +| 2           | 1           |
    +| 2           | 4           |
    ++-------------+-------------+
    +
    +Employee table:
    ++-------------+--------+------------------+
    +| employee_id | name   | experience_years |
    ++-------------+--------+------------------+
    +| 1           | Khaled | 3                |
    +| 2           | Ali    | 2                |
    +| 3           | John   | 3                |
    +| 4           | Doe    | 2                |
    ++-------------+--------+------------------+
    +
    +Result table:
    ++-------------+---------------+
    +| project_id  | employee_id   |
    ++-------------+---------------+
    +| 1           | 1             |
    +| 1           | 3             |
    +| 2           | 1             |
    ++-------------+---------------+
    +Both employees with id 1 and 3 have the most experience among the employees of the first project. For the second project, the employee with id 1 has the most experience.
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/push-dominoes/README.md b/problems/push-dominoes/README.md index fed3b8908..c4d6ee456 100644 --- a/problems/push-dominoes/README.md +++ b/problems/push-dominoes/README.md @@ -11,45 +11,48 @@ ## [838. Push Dominoes (Medium)](https://leetcode.com/problems/push-dominoes "推多米诺") -

    There are N dominoes in a line, and we place each domino vertically upright.

    +

    There are n dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to the left or to the right.

    -

    In the beginning, we simultaneously push some of the dominoes either to the left or to the right.

    - -

    - -

    After each second, each domino that is falling to the left pushes the adjacent domino on the left.

    - -

    Similarly, the dominoes falling to the right push their adjacent dominoes standing on the right.

    +

    After each second, each domino that is falling to the left pushes the adjacent domino on the left. Similarly, the dominoes falling to the right push their adjacent dominoes standing on the right.

    When a vertical domino has dominoes falling on it from both sides, it stays still due to the balance of the forces.

    -

    For the purposes of this question, we will consider that a falling domino expends no additional force to a falling or already fallen domino.

    +

    For the purposes of this question, we will consider that a falling domino expends no additional force to a falling or already fallen domino.

    -

    Given a string "S" representing the initial state. S[i] = 'L', if the i-th domino has been pushed to the left; S[i] = 'R', if the i-th domino has been pushed to the right; S[i] = '.', if the i-th domino has not been pushed.

    +

    You are given a string dominoes representing the initial state where:

    -

    Return a string representing the final state. 

    +
      +
    • dominoes[i] = 'L', if the ith domino has been pushed to the left,
    • +
    • dominoes[i] = 'R', if the ith domino has been pushed to the right, and
    • +
    • dominoes[i] = '.', if the ith domino has not been pushed.
    • +
    +

    Return a string representing the final state.

    + +

     

    Example 1:

    -Input: ".L.R...LR..L.."
    -Output: "LL.RR.LLRRLL.."
    +Input: dominoes = "RR.L"
    +Output: "RR.L"
    +Explanation: The first domino expends no additional force on the second domino.
     

    Example 2:

    - +
    -Input: "RR.L"
    -Output: "RR.L"
    -Explanation: The first domino expends no additional force on the second domino.
    +Input: dominoes = ".L.R...LR..L.."
    +Output: "LL.RR.LLRRLL.."
     
    -

    Note:

    +

     

    +

    Constraints:

    -
      -
    1. 0 <= N <= 10^5
    2. -
    3. String dominoes contains only 'L', 'R' and '.'
    4. -
    +
      +
    • n == dominoes.length
    • +
    • 1 <= n <= 105
    • +
    • dominoes[i] is either 'L', 'R', or '.'.
    • +
    ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/queries-quality-and-percentage/README.md b/problems/queries-quality-and-percentage/README.md index 14ca53a4c..95eef1138 100644 --- a/problems/queries-quality-and-percentage/README.md +++ b/problems/queries-quality-and-percentage/README.md @@ -11,7 +11,70 @@ ## [1211. Queries Quality and Percentage (Easy)](https://leetcode.com/problems/queries-quality-and-percentage "查询结果的质量和占比") +

    Table: Queries

    +
    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| query_name  | varchar |
    +| result      | varchar |
    +| position    | int     |
    +| rating      | int     |
    ++-------------+---------+
    +There is no primary key for this table, it may have duplicate rows.
    +This table contains information collected from some queries on a database.
    +The position column has a value from 1 to 500.
    +The rating column has a value from 1 to 5. Query with rating less than 3 is a poor query.
    +
    + +

     

    + +

    We define query quality as:

    + +
    +

    The average of the ratio between query rating and its position.

    +
    + +

    We also define poor query percentage as:

    + +
    +

    The percentage of all queries with rating less than 3.

    +
    + +

    Write an SQL query to find each query_name, the quality and poor_query_percentage.

    + +

    Both quality and poor_query_percentage should be rounded to 2 decimal places.

    + +

    The query result format is in the following example:

    + +
    +Queries table:
    ++------------+-------------------+----------+--------+
    +| query_name | result            | position | rating |
    ++------------+-------------------+----------+--------+
    +| Dog        | Golden Retriever  | 1        | 5      |
    +| Dog        | German Shepherd   | 2        | 5      |
    +| Dog        | Mule              | 200      | 1      |
    +| Cat        | Shirazi           | 5        | 2      |
    +| Cat        | Siamese           | 3        | 3      |
    +| Cat        | Sphynx            | 7        | 4      |
    ++------------+-------------------+----------+--------+
    +
    +Result table:
    ++------------+---------+-----------------------+
    +| query_name | quality | poor_query_percentage |
    ++------------+---------+-----------------------+
    +| Dog        | 2.50    | 33.33                 |
    +| Cat        | 0.66    | 33.33                 |
    ++------------+---------+-----------------------+
    +
    +Dog queries quality is ((5 / 1) + (5 / 2) + (1 / 200)) / 3 = 2.50
    +Dog queries poor_ query_percentage is (1 / 3) * 100 = 33.33
    +
    +Cat queries quality equals ((2 / 5) + (3 / 3) + (4 / 7)) / 3 = 0.66
    +Cat queries poor_ query_percentage is (1 / 3) * 100 = 33.33
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/random-flip-matrix/README.md b/problems/random-flip-matrix/README.md index f85606dbf..b743724f9 100644 --- a/problems/random-flip-matrix/README.md +++ b/problems/random-flip-matrix/README.md @@ -11,39 +11,45 @@ ## [519. Random Flip Matrix (Medium)](https://leetcode.com/problems/random-flip-matrix "随机翻转矩阵") -

    You are given the number of rows n_rows and number of columns n_cols of a 2D binary matrix where all values are initially 0. Write a function flip which chooses a 0 value uniformly at random, changes it to 1, and then returns the position [row.id, col.id] of that value. Also, write a function reset which sets all values back to 0. Try to minimize the number of calls to system's Math.random() and optimize the time and space complexity.

    +

    There is an m x n binary grid matrix with all the values set 0 initially. Design an algorithm to randomly pick an index (i, j) where matrix[i][j] == 0 and flips it to 1. All the indices (i, j) where matrix[i][j] == 0 should be equally likely to be returned.

    -

    Note:

    +

    Optimize your algorithm to minimize the number of calls made to the built-in random function of your language and optimize the time and space complexity.

    -
      -
    1. 1 <= n_rows, n_cols <= 10000
    2. -
    3. 0 <= row.id < n_rows and 0 <= col.id < n_cols
    4. -
    5. flip will not be called when the matrix has no 0 values left.
    6. -
    7. the total number of calls to flip and reset will not exceed 1000.
    8. -
    +

    Implement the Solution class:

    +
      +
    • Solution(int m, int n) Initializes the object with the size of the binary matrix m and n.
    • +
    • int[] flip() Returns a random index [i, j] of the matrix where matrix[i][j] == 0 and flips it to 1.
    • +
    • void reset() Resets all the values of the matrix to be 0.
    • +
    + +

     

    Example 1:

    -Input: 
    -["Solution","flip","flip","flip","flip"]
    -[[2,3],[],[],[],[]]
    -Output: [null,[0,1],[1,2],[1,0],[1,1]]
    +Input
    +["Solution", "flip", "flip", "flip", "reset", "flip"]
    +[[3, 1], [], [], [], [], []]
    +Output
    +[null, [1, 0], [2, 0], [0, 0], null, [2, 0]]
    +
    +Explanation
    +Solution solution = new Solution(3, 1);
    +solution.flip();  // return [1, 0], [0,0], [1,0], and [2,0] should be equally likely to be returned.
    +solution.flip();  // return [2, 0], Since [1,0] was returned, [2,0] and [0,0]
    +solution.flip();  // return [0, 0], Based on the previously returned indices, only [0,0] can be returned.
    +solution.reset(); // All the values are reset to 0 and can be returned.
    +solution.flip();  // return [2, 0], [0,0], [1,0], and [2,0] should be equally likely to be returned.
     
    -
    -

    Example 2:

    - -
    -Input: 
    -["Solution","flip","flip","reset","flip"]
    -[[1,2],[],[],[],[]]
    -Output: [null,[0,0],[0,1],null,[0,0]]
    -
    - -

    Explanation of Input Syntax:

    +

     

    +

    Constraints:

    -

    The input is two lists: the subroutines called and their arguments. Solution's constructor has two arguments, n_rows and n_colsflip and reset have no arguments. Arguments are always wrapped with a list, even if there aren't any.

    +
      +
    • 1 <= m, n <= 104
    • +
    • There will be at least one free cell for each call to flip.
    • +
    • At most 1000 calls will be made to flip and reset.
    • +
    ### Related Topics [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] diff --git a/problems/random-pick-with-blacklist/README.md b/problems/random-pick-with-blacklist/README.md index 610d14199..3764338a9 100644 --- a/problems/random-pick-with-blacklist/README.md +++ b/problems/random-pick-with-blacklist/README.md @@ -11,57 +11,48 @@ ## [710. Random Pick with Blacklist (Hard)](https://leetcode.com/problems/random-pick-with-blacklist "黑名单中的随机数") -

    Given a blacklist blacklist containing unique integers from [0, n), write a function to return a uniform random integer from [0, n) which is NOT in blacklist.

    +

    You are given an integer n and an array of unique integers blacklist. Design an algorithm to pick a random integer in the range [0, n - 1] that is not in blacklist. Any integer that is in the mentioned range and not in blacklist should be equally likely returned.

    -

    Optimize it such that it minimizes the call to system’s Math.random().

    +

    Optimize your algorithm such that it minimizes the call to the built-in random function of your language.

    -

    Note:

    +

    Implement the Solution class:

    -
      -
    1. 1 <= n <= 1000000000
    2. -
    3. 0 <= blacklist.length < min(100000, n)
    4. -
    5. [0, n) does NOT include n. See interval notation.
    6. -
    +
      +
    • Solution(int n, int[] blacklist) Initializes the object with the integer n and the blacklisted integers blacklist.
    • +
    • int pick() Returns a random integer in the range [0, n - 1] and not in blacklist. All the possible integers should be equally likely returned.
    • +
    +

     

    Example 1:

    -Input: 
    -["Solution","pick","pick","pick"]
    -[[1,[]],[],[],[]]
    -Output: [null,0,0,0]
    +Input
    +["Solution", "pick", "pick", "pick", "pick", "pick", "pick", "pick"]
    +[[7, [2, 3, 5]], [], [], [], [], [], [], []]
    +Output
    +[null, 6, 4, 1, 6, 1, 6, 4]
    +
    +Explanation
    +Solution solution = new Solution(7, [2, 3, 5]);
    +solution.pick(); // return 6, any integer from [1,4,6] should be ok. Note that for every call of pick, 1, 4, and 6 must be equally likely to be returned (i.e., with probability 1/3).
    +solution.pick(); // return 4
    +solution.pick(); // return 1
    +solution.pick(); // return 6
    +solution.pick(); // return 1
    +solution.pick(); // return 6
    +solution.pick(); // return 4
     
    -

    Example 2:

    +

     

    +

    Constraints:

    -
    -Input: 
    -["Solution","pick","pick","pick"]
    -[[2,[]],[],[],[]]
    -Output: [null,1,1,1]
    -
    - -

    Example 3:

    - -
    -Input: 
    -["Solution","pick","pick","pick"]
    -[[3,[1]],[],[],[]]
    -Output: [null,0,0,2]
    -
    - -

    Example 4:

    - -
    -Input: 
    -["Solution","pick","pick","pick"]
    -[[4,[2]],[],[],[]]
    -Output: [null,1,3,1]
    -
    - -

    Explanation of Input Syntax:

    - -

    The input is two lists: the subroutines called and their arguments. Solution's constructor has two arguments, n and the blacklist blacklist. pick has no arguments. Arguments are always wrapped with a list, even if there aren't any.

    +
      +
    • 1 <= n <= 109
    • +
    • 0 <= blacklist.length <- min(105, n - 1)
    • +
    • 0 <= blacklist[i] < n
    • +
    • All the values of blacklist are unique.
    • +
    • At most 2 * 104 calls will be made to pick.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/random-point-in-non-overlapping-rectangles/README.md b/problems/random-point-in-non-overlapping-rectangles/README.md index 8cbb74788..bd9165205 100644 --- a/problems/random-point-in-non-overlapping-rectangles/README.md +++ b/problems/random-point-in-non-overlapping-rectangles/README.md @@ -11,52 +11,51 @@ ## [497. Random Point in Non-overlapping Rectangles (Medium)](https://leetcode.com/problems/random-point-in-non-overlapping-rectangles "非重叠矩形中的随机点") -

    Given a list of non-overlapping axis-aligned rectangles rects, write a function pick which randomly and uniformily picks an integer point in the space covered by the rectangles.

    +

    You are given an array of non-overlapping axis-aligned rectangles rects where rects[i] = [ai, bi, xi, yi] indicates that (ai, bi) is the bottom-left corner point of the ith rectangle and (xi, yi) is the top-right corner point of the ith rectangle. Design an algorithm to pick a random integer point inside the space covered by one of the given rectangles. A point on the perimeter of a rectangle is included in the space covered by the rectangle.

    -

    Note:

    +

    Any integer point inside the space covered by one of the given rectangles should be equally likely to be returned.

    -
      -
    1. An integer point is a point that has integer coordinates. 
    2. -
    3. A point on the perimeter of a rectangle is included in the space covered by the rectangles. 
    4. -
    5. ith rectangle = rects[i][x1,y1,x2,y2], where [x1, y1] are the integer coordinates of the bottom-left corner, and [x2, y2] are the integer coordinates of the top-right corner.
    6. -
    7. length and width of each rectangle does not exceed 2000.
    8. -
    9. 1 <= rects.length <= 100
    10. -
    11. pick return a point as an array of integer coordinates [p_x, p_y]
    12. -
    13. pick is called at most 10000 times.
    14. -
    +

    Note that an integer point is a point that has integer coordinates.

    -
    -

    Example 1:

    - -
    -Input: 
    -["Solution","pick","pick","pick"]
    -[[[[1,1,5,5]]],[],[],[]]
    -Output: 
    -[null,[4,1],[4,1],[3,3]]
    -
    +

    Implement the Solution class:

    -
    -

    Example 2:

    +
      +
    • Solution(int[][] rects) Initializes the object with the given rectangles rects.
    • +
    • int[] pick() Returns a random integer point [u, v] inside the space covered by one of the given rectangles.
    • +
    +

     

    +

    Example 1:

    +
    -Input: 
    -["Solution","pick","pick","pick","pick","pick"]
    -[[[[-2,-2,-1,-1],[1,0,3,0]]],[],[],[],[],[]]
    -Output: 
    -[null,[-1,-2],[2,0],[-2,-1],[3,0],[-2,-2]]
    -
    +Input +["Solution", "pick", "pick", "pick", "pick", "pick"] +[[[[-2, -2, 1, 1], [2, 2, 4, 6]]], [], [], [], [], []] +Output +[null, [1, -2], [1, -1], [-1, -2], [-2, -2], [0, 0]] -
    -

    Explanation of Input Syntax:

    +Explanation +Solution solution = new Solution([[-2, -2, 1, 1], [2, 2, 4, 6]]); +solution.pick(); // return [1, -2] +solution.pick(); // return [1, -1] +solution.pick(); // return [-1, -2] +solution.pick(); // return [-2, -2] +solution.pick(); // return [0, 0] + -

    The input is two lists: the subroutines called and their arguments. Solution's constructor has one argument, the array of rectangles rects. pick has no arguments. Arguments are always wrapped with a list, even if there aren't any.

    -
    -
    +

     

    +

    Constraints:

    -
    -
     
    -
    +
      +
    • 1 <= rects.length <= 100
    • +
    • rects[i].length == 4
    • +
    • -109 <= ai < xi <= 109
    • +
    • -109 <= bi < yi <= 109
    • +
    • xi - ai <= 2000
    • +
    • yi - bi <= 2000
    • +
    • All the rectangles do not overlap.
    • +
    • At most 104 calls will be made to pick.
    • +
    ### Related Topics [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] diff --git a/problems/range-addition/README.md b/problems/range-addition/README.md index 5b7248bc6..6c5eb4f18 100644 --- a/problems/range-addition/README.md +++ b/problems/range-addition/README.md @@ -11,7 +11,34 @@ ## [370. Range Addition (Medium)](https://leetcode.com/problems/range-addition "区间加法") +

    Assume you have an array of length n initialized with all 0's and are given k update operations.

    +

    Each operation is represented as a triplet: [startIndex, endIndex, inc] which increments each element of subarray A[startIndex ... endIndex] (startIndex and endIndex inclusive) with inc.

    + +

    Return the modified array after all k operations were executed.

    + +

    Example:

    + +
    +Input: length = 5, updates = [[1,3,2],[2,4,3],[0,2,-2]]
    +Output: [-2,0,3,5,3]
    +
    + +

    Explanation:

    + +
    +Initial state:
    +[0,0,0,0,0]
    +
    +After applying operation [1,3,2]:
    +[0,2,2,2,0]
    +
    +After applying operation [2,4,3]:
    +[0,2,5,5,3]
    +
    +After applying operation [0,2,-2]:
    +[-2,0,3,5,3]
    +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/range-sum-query-2d-mutable/README.md b/problems/range-sum-query-2d-mutable/README.md index d3c48125f..652e5d210 100644 --- a/problems/range-sum-query-2d-mutable/README.md +++ b/problems/range-sum-query-2d-mutable/README.md @@ -11,7 +11,36 @@ ## [308. Range Sum Query 2D - Mutable (Hard)](https://leetcode.com/problems/range-sum-query-2d-mutable "二维区域和检索 - 可变") +

    Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).

    +

    +Range Sum Query 2D
    +The above rectangle (with the red border) is defined by (row1, col1) = (2, 1) and (row2, col2) = (4, 3), which contains sum = 8. +

    + +

    Example:
    +

    +Given matrix = [
    +  [3, 0, 1, 4, 2],
    +  [5, 6, 3, 2, 1],
    +  [1, 2, 0, 1, 5],
    +  [4, 1, 0, 1, 7],
    +  [1, 0, 3, 0, 5]
    +]
    +
    +sumRegion(2, 1, 4, 3) -> 8
    +update(3, 2, 2)
    +sumRegion(2, 1, 4, 3) -> 10
    +
    +

    + +

    Note:
    +

      +
    1. The matrix is only modifiable by the update function.
    2. +
    3. You may assume the number of calls to update and sumRegion function is distributed evenly.
    4. +
    5. You may assume that row1 ≤ row2 and col1 ≤ col2.
    6. +
    +

    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/rank-teams-by-votes/README.md b/problems/rank-teams-by-votes/README.md index 1a25fb7a8..3f75fb7e4 100644 --- a/problems/rank-teams-by-votes/README.md +++ b/problems/rank-teams-by-votes/README.md @@ -83,11 +83,8 @@ There is a tie and we rank teams ascending by their IDs. [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Sorting](../../tag/sorting/README.md)] [[Counting](../../tag/counting/README.md)] - -### Similar Questions - 1. [Online Election](../online-election) (Medium) + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/reach-a-number/README.md b/problems/reach-a-number/README.md index 5afb83cf4..c9cfef930 100644 --- a/problems/reach-a-number/README.md +++ b/problems/reach-a-number/README.md @@ -11,11 +11,16 @@ ## [754. Reach a Number (Medium)](https://leetcode.com/problems/reach-a-number "到达终点数字") -

    You are standing at position 0 on an infinite number line. There is a goal at position target.

    +

    You are standing at position 0 on an infinite number line. There is a destination at position target.

    -

    On each move, you can either go left or right. During the nth move (starting from n == 1), you take n steps.

    +

    You can make some number of moves numMoves so that:

    -

    Return the minimum number of steps required to reach the destination.

    +
      +
    • On each move, you can either go left or right.
    • +
    • During the ith move (starting from i == 1 to i == numMoves), you take i steps in the chosen direction.
    • +
    + +

    Given the integer target, return the minimum number of moves required (i.e., the minimum numMoves) to reach the destination.

     

    Example 1:

    @@ -24,9 +29,9 @@ Input: target = 2 Output: 3 Explanation: -On the first move, we step from 0 to 1. -On the second move, we step from 1 to -1. -On the third move, we step from -1 to 2. +On the 1st move, we step from 0 to 1 (1 step). +On the 2nd move, we step from 1 to -1 (2 steps). +On the 3rd move, we step from -1 to 2 (3 steps).

    Example 2:

    @@ -35,8 +40,8 @@ On the third move, we step from -1 to 2. Input: target = 3 Output: 2 Explanation: -On the first move, we step from 0 to 1. -On the second step, we step from 1 to 3. +On the 1st move, we step from 0 to 1 (1 step). +On the 2nd move, we step from 1 to 3 (2 steps).

     

    diff --git a/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md b/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md index 1d250b80f..77d25516f 100644 --- a/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md +++ b/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md @@ -11,7 +11,87 @@ ## [158. Read N Characters Given Read4 II - Call multiple times (Hard)](https://leetcode.com/problems/read-n-characters-given-read4-ii-call-multiple-times "用 Read4 读取 N 个字符 II") +

    Given a file and assume that you can only read the file using a given method read4, implement a method read to read n characters. Your method read may be called multiple times.

    +

     

    + +

    Method read4:

    + +

    The API read4 reads 4 consecutive characters from the file, then writes those characters into the buffer array buf.

    + +

    The return value is the number of actual characters read.

    + +

    Note that read4() has its own file pointer, much like FILE *fp in C.

    + +

    Definition of read4:

    + +
    +    Parameter:  char[] buf
    +    Returns:    int
    +
    +Note: buf[] is destination not source, the results from read4 will be copied to buf[]
    +
    + +

    Below is a high level example of how read4 works:

    + +
    +File file("abcdefghijk"); // File is "abcdefghijk", initially file pointer (fp) points to 'a'
    +char[] buf = new char[4]; // Create buffer with enough space to store characters
    +read4(buf); // read4 returns 4. Now buf = "abcd", fp points to 'e'
    +read4(buf); // read4 returns 4. Now buf = "efgh", fp points to 'i'
    +read4(buf); // read4 returns 3. Now buf = "ijk", fp points to end of file
    +
    + +

     

    + +

    Method read:

    + +

    By using the read4 method, implement the method read that reads n characters from the file and store it in the buffer array buf. Consider that you cannot manipulate the file directly.

    + +

    The return value is the number of actual characters read.

    + +

    Definition of read:

    + +
    +    Parameters:	char[] buf, int n
    +    Returns:	int
    +
    +Note: buf[] is destination not source, you will need to write the results to buf[]
    +
    + +

     

    + +

    Example 1:

    + +
    +File file("abc");
    +Solution sol;
    +// Assume buf is allocated and guaranteed to have enough space for storing all characters from the file.
    +sol.read(buf, 1); // After calling your read method, buf should contain "a". We read a total of 1 character from the file, so return 1.
    +sol.read(buf, 2); // Now buf should contain "bc". We read a total of 2 characters from the file, so return 2.
    +sol.read(buf, 1); // We have reached the end of file, no more characters can be read. So return 0.
    +
    + +

    Example 2:

    + +
    +File file("abc");
    +Solution sol;
    +sol.read(buf, 4); // After calling your read method, buf should contain "abc". We read a total of 3 characters from the file, so return 3.
    +sol.read(buf, 1); // We have reached the end of file, no more characters can be read. So return 0.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. Consider that you cannot manipulate the file directly, the file is only accesible for read4 but not for read.
    2. +
    3. The read function may be called multiple times.
    4. +
    5. Please remember to RESET your class variables declared in Solution, as static/class variables are persisted across multiple test cases. Please see here for more details.
    6. +
    7. You may assume the destination buffer array, buf, is guaranteed to have enough space for storing n characters.
    8. +
    9. It is guaranteed that in a given test case the same buffer buf is called by read.
    10. +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/read-n-characters-given-read4/README.md b/problems/read-n-characters-given-read4/README.md index d1992d9e0..9cb75e643 100644 --- a/problems/read-n-characters-given-read4/README.md +++ b/problems/read-n-characters-given-read4/README.md @@ -11,7 +11,97 @@ ## [157. Read N Characters Given Read4 (Easy)](https://leetcode.com/problems/read-n-characters-given-read4 "用 Read4 读取 N 个字符") +

    Given a file and assume that you can only read the file using a given method read4, implement a method to read n characters.

    +

     

    + +

    Method read4:

    + +

    The API read4 reads 4 consecutive characters from the file, then writes those characters into the buffer array buf.

    + +

    The return value is the number of actual characters read.

    + +

    Note that read4() has its own file pointer, much like FILE *fp in C.

    + +

    Definition of read4:

    + +
    +    Parameter:  char[] buf
    +    Returns:    int
    +
    +Note: buf[] is destination not source, the results from read4 will be copied to buf[]
    +
    + +

    Below is a high level example of how read4 works:

    + +
    +File file("abcdefghijk"); // File is "abcdefghijk", initially file pointer (fp) points to 'a'
    +char[] buf = new char[4]; // Create buffer with enough space to store characters
    +read4(buf); // read4 returns 4. Now buf = "abcd", fp points to 'e'
    +read4(buf); // read4 returns 4. Now buf = "efgh", fp points to 'i'
    +read4(buf); // read4 returns 3. Now buf = "ijk", fp points to end of file
    +
    + +

     

    + +

    Method read:

    + +

    By using the read4 method, implement the method read that reads n characters from the file and store it in the buffer array buf. Consider that you cannot manipulate the file directly.

    + +

    The return value is the number of actual characters read.

    + +

    Definition of read:

    + +
    +    Parameters:	char[] buf, int n
    +    Returns:	int
    +
    +Note: buf[] is destination not source, you will need to write the results to buf[]
    +
    + +

     

    + +

    Example 1:

    + +
    +Input: file = "abc", n = 4
    +Output: 3
    +Explanation: After calling your read method, buf should contain "abc". We read a total of 3 characters from the file, so return 3. Note that "abc" is the file's content, not buf. buf is the destination buffer that you will have to write the results to.
    +
    + +

    Example 2:

    + +
    +Input: file = "abcde", n = 5
    +Output: 5
    +Explanation: After calling your read method, buf should contain "abcde". We read a total of 5 characters from the file, so return 5.
    +
    + +

    Example 3:

    + +
    +Input: file = "abcdABCD1234", n = 12
    +Output: 12
    +Explanation: After calling your read method, buf should contain "abcdABCD1234". We read a total of 12 characters from the file, so return 12.
    +
    + +

    Example 4:

    + +
    +Input: file = "leetcode", n = 5
    +Output: 5
    +Explanation: After calling your read method, buf should contain "leetc". We read a total of 5 characters from the file, so return 5.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. Consider that you cannot manipulate the file directly, the file is only accesible for read4 but not for read.
    2. +
    3. The read function will only be called once for each test case.
    4. +
    5. You may assume the destination buffer array, buf, is guaranteed to have enough space for storing n characters.
    6. +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/rearrange-string-k-distance-apart/README.md b/problems/rearrange-string-k-distance-apart/README.md index c6930f952..491309082 100644 --- a/problems/rearrange-string-k-distance-apart/README.md +++ b/problems/rearrange-string-k-distance-apart/README.md @@ -11,7 +11,36 @@ ## [358. Rearrange String k Distance Apart (Hard)](https://leetcode.com/problems/rearrange-string-k-distance-apart "K 距离间隔重排字符串") +

    Given a non-empty string s and an integer k, rearrange the string such that the same characters are at least distance k from each other.

    +

    All input strings are given in lowercase letters. If it is not possible to rearrange the string, return an empty string "".

    + +

    Example 1:

    + +
    +
    +Input: s = "aabbcc", k = 3
    +Output: "abcabc" 
    +Explanation: The same letters are at least distance 3 from each other.
    +
    + +
    +

    Example 2:

    + +
    +Input: s = "aaabc", k = 3
    +Output: "" 
    +Explanation: It is not possible to rearrange the string.
    +
    + +
    +

    Example 3:

    + +
    +Input: s = "aaadbbcc", k = 2
    +Output: "abacabcd"
    +Explanation: The same letters are at least distance 2 from each other.
    +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/reduce-array-size-to-the-half/README.md b/problems/reduce-array-size-to-the-half/README.md index a5ff65836..9bd2bdd1e 100644 --- a/problems/reduce-array-size-to-the-half/README.md +++ b/problems/reduce-array-size-to-the-half/README.md @@ -65,9 +65,9 @@ Choosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/regular-expression-matching/README.md b/problems/regular-expression-matching/README.md index 7e6a7837d..70b91192d 100644 --- a/problems/regular-expression-matching/README.md +++ b/problems/regular-expression-matching/README.md @@ -11,7 +11,7 @@ ## [10. Regular Expression Matching (Hard)](https://leetcode.com/problems/regular-expression-matching "正则表达式匹配") -

    Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*' where: 

    +

    Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where:

    • '.' Matches any single character.​​​​
    • @@ -64,8 +64,8 @@

      Constraints:

        -
      • 0 <= s.length <= 20
      • -
      • 0 <= p.length <= 30
      • +
      • 1 <= s.length <= 20
      • +
      • 1 <= p.length <= 30
      • s contains only lowercase English letters.
      • p contains only lowercase English letters, '.', and '*'.
      • It is guaranteed for each appearance of the character '*', there will be a previous valid character to match.
      • diff --git a/problems/remove-9/README.md b/problems/remove-9/README.md index fef5853dd..c186217f6 100644 --- a/problems/remove-9/README.md +++ b/problems/remove-9/README.md @@ -11,7 +11,21 @@ ## [660. Remove 9 (Hard)](https://leetcode.com/problems/remove-9 "移除 9") +

        Start from integer 1, remove any integer that contains 9 such as 9, 19, 29...

        +

        So now, you will have a new integer sequence: 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, ...

        + +

        Given a positive integer n, you need to return the n-th integer after removing. Note that 1 will be the first integer.

        + +

        Example 1:
        +

        Input: 9
        +Output: 10
        +
        +

        + +

        + Hint: n will not exceed 9 x 10^8. +

        ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/remove-interval/README.md b/problems/remove-interval/README.md index 8ba741477..89f6001a6 100644 --- a/problems/remove-interval/README.md +++ b/problems/remove-interval/README.md @@ -11,7 +11,27 @@ ## [1272. Remove Interval (Medium)](https://leetcode.com/problems/remove-interval "删除区间") +

        Given a sorted list of disjoint intervals, each interval intervals[i] = [a, b] represents the set of real numbers x such that a <= x < b.

        +

        We remove the intersections between any interval in intervals and the interval toBeRemoved.

        + +

        Return a sorted list of intervals after all such removals.

        + +

         

        +

        Example 1:

        +
        Input: intervals = [[0,2],[3,4],[5,7]], toBeRemoved = [1,6]
        +Output: [[0,1],[6,7]]
        +

        Example 2:

        +
        Input: intervals = [[0,5]], toBeRemoved = [2,3]
        +Output: [[0,2],[3,5]]
        +
        +

         

        +

        Constraints:

        + +
          +
        • 1 <= intervals.length <= 10^4
        • +
        • -10^9 <= intervals[i][0] < intervals[i][1] <= 10^9
        • +
        ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/remove-vowels-from-a-string/README.md b/problems/remove-vowels-from-a-string/README.md index 9f69c6768..ac8433ad8 100644 --- a/problems/remove-vowels-from-a-string/README.md +++ b/problems/remove-vowels-from-a-string/README.md @@ -11,7 +11,32 @@ ## [1119. Remove Vowels from a String (Easy)](https://leetcode.com/problems/remove-vowels-from-a-string "删去字符串中的元音") +

        Given a string S, remove the vowels 'a', 'e', 'i', 'o', and 'u' from it, and return the new string.

        +

         

        + +

        Example 1:

        + +
        +Input: "leetcodeisacommunityforcoders"
        +Output: "ltcdscmmntyfrcdrs"
        +
        + +

        Example 2:

        + +
        +Input: "aeiou"
        +Output: ""
        +
        + +

         

        + +

        Note:

        + +
          +
        1. S consists of lowercase English letters only.
        2. +
        3. 1 <= S.length <= 1000
        4. +
        ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/replace-employee-id-with-the-unique-identifier/README.md b/problems/replace-employee-id-with-the-unique-identifier/README.md index 26fefe712..e1db601dd 100644 --- a/problems/replace-employee-id-with-the-unique-identifier/README.md +++ b/problems/replace-employee-id-with-the-unique-identifier/README.md @@ -11,7 +11,72 @@ ## [1378. Replace Employee ID With The Unique Identifier (Easy)](https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier "使用唯一标识码替换员工ID") +

        Table: Employees

        +
        ++---------------+---------+
        +| Column Name   | Type    |
        ++---------------+---------+
        +| id            | int     |
        +| name          | varchar |
        ++---------------+---------+
        +id is the primary key for this table.
        +Each row of this table contains the id and the name of an employee in a company.
        +
        + +

        Table: EmployeeUNI

        +
        ++---------------+---------+
        +| Column Name   | Type    |
        ++---------------+---------+
        +| id            | int     |
        +| unique_id     | int     |
        ++---------------+---------+
        +(id, unique_id) is the primary key for this table.
        +Each row of this table contains the id and the corresponding unique id of an employee in the company.
        +
        + +Write an SQL query to show the unique ID of each user, If a user doesn't have a unique ID replace just show null. +Return the result table in any order. + +The query result format is in the following example: +
        +Employees table:
        ++----+----------+
        +| id | name     |
        ++----+----------+
        +| 1  | Alice    |
        +| 7  | Bob      |
        +| 11 | Meir     |
        +| 90 | Winston  |
        +| 3  | Jonathan |
        ++----+----------+
        +
        +EmployeeUNI table:
        ++----+-----------+
        +| id | unique_id |
        ++----+-----------+
        +| 3  | 1         |
        +| 11 | 2         |
        +| 90 | 3         |
        ++----+-----------+
        +
        +EmployeeUNI table:
        ++-----------+----------+
        +| unique_id | name     |
        ++-----------+----------+
        +| null      | Alice    |
        +| null      | Bob      |
        +| 2         | Meir     |
        +| 3         | Winston  |
        +| 1         | Jonathan |
        ++-----------+----------+
        +
        +Alice and Bob don't have a unique ID, We will show null instead.
        +The unique ID of Meir is 2.
        +The unique ID of Winston is 3.
        +The unique ID of Jonathan is 1.
        +
        ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/report-contiguous-dates/README.md b/problems/report-contiguous-dates/README.md index b69926f2b..7eefc0968 100644 --- a/problems/report-contiguous-dates/README.md +++ b/problems/report-contiguous-dates/README.md @@ -11,7 +11,80 @@ ## [1225. Report Contiguous Dates (Hard)](https://leetcode.com/problems/report-contiguous-dates "报告系统状态的连续日期") +

        Table: Failed

        +
        ++--------------+---------+
        +| Column Name  | Type    |
        ++--------------+---------+
        +| fail_date    | date    |
        ++--------------+---------+
        +Primary key for this table is fail_date.
        +Failed table contains the days of failed tasks.
        +
        + +

        Table: Succeeded

        + +
        ++--------------+---------+
        +| Column Name  | Type    |
        ++--------------+---------+
        +| success_date | date    |
        ++--------------+---------+
        +Primary key for this table is success_date.
        +Succeeded table contains the days of succeeded tasks.
        +
        + +

         

        + +

        A system is running one task every day. Every task is independent of the previous tasks. The tasks can fail or succeed.

        + +

        Write an SQL query to generate a report of period_state for each continuous interval of days in the period from 2019-01-01 to 2019-12-31.

        + +

        period_state is 'failed' if tasks in this interval failed or 'succeeded' if tasks in this interval succeeded. Interval of days are retrieved as start_date and end_date.

        + +

        Order result by start_date.

        + +

        The query result format is in the following example:

        + +
        +Failed table:
        ++-------------------+
        +| fail_date         |
        ++-------------------+
        +| 2018-12-28        |
        +| 2018-12-29        |
        +| 2019-01-04        |
        +| 2019-01-05        |
        ++-------------------+
        +
        +Succeeded table:
        ++-------------------+
        +| success_date      |
        ++-------------------+
        +| 2018-12-30        |
        +| 2018-12-31        |
        +| 2019-01-01        |
        +| 2019-01-02        |
        +| 2019-01-03        |
        +| 2019-01-06        |
        ++-------------------+
        +
        +
        +Result table:
        ++--------------+--------------+--------------+
        +| period_state | start date   | end date     |
        ++--------------+--------------+--------------+
        +| present      | 2019-01-01   | 2019-01-03   |
        +| missing      | 2019-01-04   | 2019-01-05   |
        +| present      | 2019-01-06   | 2019-01-06   |
        ++--------------+--------------+--------------+
        +
        +The report ignored the system state in 2018 as we care about the system in the period 2019-01-01 to 2019-12-31.
        +From 2019-01-01 to 2019-01-03 all tasks succeeded and the system state was "present".
        +From 2019-01-04 to 2019-01-05 all tasks failed and system state was "missing".
        +From 2019-01-06 to 2019-01-06 all tasks succeeded and system state was "present".
        +
        ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/reported-posts-ii/README.md b/problems/reported-posts-ii/README.md index 6012b984d..b14a7515b 100644 --- a/problems/reported-posts-ii/README.md +++ b/problems/reported-posts-ii/README.md @@ -11,7 +11,79 @@ ## [1132. Reported Posts II (Medium)](https://leetcode.com/problems/reported-posts-ii "报告的记录 II") +

        Table: Actions

        +
        ++---------------+---------+
        +| Column Name   | Type    |
        ++---------------+---------+
        +| user_id       | int     |
        +| post_id       | int     |
        +| action_date   | date    |
        +| action        | enum    |
        +| extra         | varchar |
        ++---------------+---------+
        +There is no primary key for this table, it may have duplicate rows.
        +The action column is an ENUM type of ('view', 'like', 'reaction', 'comment', 'report', 'share').
        +The extra column has optional information about the action such as a reason for report or a type of reaction. 
        + +

        Table: Removals

        + +
        ++---------------+---------+
        +| Column Name   | Type    |
        ++---------------+---------+
        +| post_id       | int     |
        +| remove_date   | date    | 
        ++---------------+---------+
        +post_id is the primary key of this table.
        +Each row in this table indicates that some post was removed as a result of being reported or as a result of an admin review.
        +
        + +

         

        + +

        Write an SQL query to find the average for daily percentage of posts that got removed after being reported as spam, rounded to 2 decimal places.

        + +

        The query result format is in the following example:

        + +
        +Actions table:
        ++---------+---------+-------------+--------+--------+
        +| user_id | post_id | action_date | action | extra  |
        ++---------+---------+-------------+--------+--------+
        +| 1       | 1       | 2019-07-01  | view   | null   |
        +| 1       | 1       | 2019-07-01  | like   | null   |
        +| 1       | 1       | 2019-07-01  | share  | null   |
        +| 2       | 2       | 2019-07-04  | view   | null   |
        +| 2       | 2       | 2019-07-04  | report | spam   |
        +| 3       | 4       | 2019-07-04  | view   | null   |
        +| 3       | 4       | 2019-07-04  | report | spam   |
        +| 4       | 3       | 2019-07-02  | view   | null   |
        +| 4       | 3       | 2019-07-02  | report | spam   |
        +| 5       | 2       | 2019-07-03  | view   | null   |
        +| 5       | 2       | 2019-07-03  | report | racism |
        +| 5       | 5       | 2019-07-03  | view   | null   |
        +| 5       | 5       | 2019-07-03  | report | racism |
        ++---------+---------+-------------+--------+--------+
        +
        +Removals table:
        ++---------+-------------+
        +| post_id | remove_date |
        ++---------+-------------+
        +| 2       | 2019-07-20  |
        +| 3       | 2019-07-18  |
        ++---------+-------------+
        +
        +Result table:
        ++-----------------------+
        +| average_daily_percent |
        ++-----------------------+
        +| 75.00                 |
        ++-----------------------+
        +The percentage for 2019-07-04 is 50% because only one post of two spam reported posts was removed.
        +The percentage for 2019-07-02 is 100% because one post was reported as spam and it was removed.
        +The other days had no spam reports so the average is (50 + 100) / 2 = 75%
        +Note that the output is only one number and that we do not care about the remove dates.
        ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/reported-posts/README.md b/problems/reported-posts/README.md index ccc05d369..33a4f61ac 100644 --- a/problems/reported-posts/README.md +++ b/problems/reported-posts/README.md @@ -11,7 +11,56 @@ ## [1113. Reported Posts (Easy)](https://leetcode.com/problems/reported-posts "报告的记录") +

        Table: Actions

        +
        ++---------------+---------+
        +| Column Name   | Type    |
        ++---------------+---------+
        +| user_id       | int     |
        +| post_id       | int     |
        +| action_date   | date    | 
        +| action        | enum    |
        +| extra         | varchar |
        ++---------------+---------+
        +There is no primary key for this table, it may have duplicate rows.
        +The action column is an ENUM type of ('view', 'like', 'reaction', 'comment', 'report', 'share').
        +The extra column has optional information about the action such as a reason for report or a type of reaction. 
        + +

         

        + +

        Write an SQL query that reports the number of posts reported yesterday for each report reason. Assume today is 2019-07-05.

        + +

        The query result format is in the following example:

        + +
        +Actions table:
        ++---------+---------+-------------+--------+--------+
        +| user_id | post_id | action_date | action | extra  |
        ++---------+---------+-------------+--------+--------+
        +| 1       | 1       | 2019-07-01  | view   | null   |
        +| 1       | 1       | 2019-07-01  | like   | null   |
        +| 1       | 1       | 2019-07-01  | share  | null   |
        +| 2       | 4       | 2019-07-04  | view   | null   |
        +| 2       | 4       | 2019-07-04  | report | spam   |
        +| 3       | 4       | 2019-07-04  | view   | null   |
        +| 3       | 4       | 2019-07-04  | report | spam   |
        +| 4       | 3       | 2019-07-02  | view   | null   |
        +| 4       | 3       | 2019-07-02  | report | spam   |
        +| 5       | 2       | 2019-07-04  | view   | null   |
        +| 5       | 2       | 2019-07-04  | report | racism |
        +| 5       | 5       | 2019-07-04  | view   | null   |
        +| 5       | 5       | 2019-07-04  | report | racism |
        ++---------+---------+-------------+--------+--------+
        +
        +Result table:
        ++---------------+--------------+
        +| report_reason | report_count |
        ++---------------+--------------+
        +| spam          | 1            |
        +| racism        | 2            |
        ++---------------+--------------+ 
        +Note that we only care about report reasons with non zero number of reports.
        ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/restaurant-growth/README.md b/problems/restaurant-growth/README.md index fe2838ad0..dc5ce13bc 100644 --- a/problems/restaurant-growth/README.md +++ b/problems/restaurant-growth/README.md @@ -11,7 +11,65 @@ ## [1321. Restaurant Growth (Medium)](https://leetcode.com/problems/restaurant-growth "餐馆营业额变化增长") +

        Table: Customer

        +
        ++---------------+---------+
        +| Column Name   | Type    |
        ++---------------+---------+
        +| customer_id   | int     |
        +| name          | varchar |
        +| visited_on    | date    |
        +| amount        | int     |
        ++---------------+---------+
        +(customer_id, visited_on) is the primary key for this table.
        +This table contains data about customer transactions in a restaurant.
        +visited_on is the date on which the customer with ID (customer_id) have visited the restaurant.
        +amount is the total paid by a customer.
        +
        +You are the restaurant owner and you want to analyze a possible expansion (there will be at least one customer every day). + +Write an SQL query to compute moving average of how much customer paid in a 7 days window (current day + 6 days before) . + +The query result format is in the following example: + +Return result table ordered by visited_on. + +average_amount should be rounded to 2 decimal places, all dates are in the format ('YYYY-MM-DD'). + +
        +Customer table:
        ++-------------+--------------+--------------+-------------+
        +| customer_id | name         | visited_on   | amount      |
        ++-------------+--------------+--------------+-------------+
        +| 1           | Jhon         | 2019-01-01   | 100         |
        +| 2           | Daniel       | 2019-01-02   | 110         |
        +| 3           | Jade         | 2019-01-03   | 120         |
        +| 4           | Khaled       | 2019-01-04   | 130         |
        +| 5           | Winston      | 2019-01-05   | 110         | 
        +| 6           | Elvis        | 2019-01-06   | 140         | 
        +| 7           | Anna         | 2019-01-07   | 150         |
        +| 8           | Maria        | 2019-01-08   | 80          |
        +| 9           | Jaze         | 2019-01-09   | 110         | 
        +| 1           | Jhon         | 2019-01-10   | 130         | 
        +| 3           | Jade         | 2019-01-10   | 150         | 
        ++-------------+--------------+--------------+-------------+
        +
        +Result table:
        ++--------------+--------------+----------------+
        +| visited_on   | amount       | average_amount |
        ++--------------+--------------+----------------+
        +| 2019-01-07   | 860          | 122.86         |
        +| 2019-01-08   | 840          | 120            |
        +| 2019-01-09   | 840          | 120            |
        +| 2019-01-10   | 1000         | 142.86         |
        ++--------------+--------------+----------------+
        +
        +1st moving average from 2019-01-01 to 2019-01-07 has an average_amount of (100 + 110 + 120 + 130 + 110 + 140 + 150)/7 = 122.86
        +2nd moving average from 2019-01-02 to 2019-01-08 has an average_amount of (110 + 120 + 130 + 110 + 140 + 150 + 80)/7 = 120
        +3rd moving average from 2019-01-03 to 2019-01-09 has an average_amount of (120 + 130 + 110 + 140 + 150 + 80 + 110)/7 = 120
        +4th moving average from 2019-01-04 to 2019-01-10 has an average_amount of (130 + 110 + 140 + 150 + 80 + 110 + 130 + 150)/7 = 142.86
        +
        ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/restore-the-array/README.md b/problems/restore-the-array/README.md index 8a6bf34db..570dbce5a 100644 --- a/problems/restore-the-array/README.md +++ b/problems/restore-the-array/README.md @@ -11,13 +11,9 @@ ## [1416. Restore The Array (Hard)](https://leetcode.com/problems/restore-the-array "恢复数组") -

        A program was supposed to print an array of integers. The program forgot to print whitespaces and the array is printed as a string of digits and all we know is that all integers in the array were in the range [1, k] and there are no leading zeros in the array.

        +

        A program was supposed to print an array of integers. The program forgot to print whitespaces and the array is printed as a string of digits s and all we know is that all integers in the array were in the range [1, k] and there are no leading zeros in the array.

        -

        Given the string s and the integer k. There can be multiple ways to restore the array.

        - -

        Return the number of possible array that can be printed as a string s using the mentioned program.

        - -

        The number of ways could be very large so return it modulo 10^9 + 7

        +

        Given the string s and the integer k, return the number of the possible arrays that can be printed as s using the mentioned program. Since the answer may be very large, return it modulo 109 + 7.

         

        Example 1:

        @@ -63,9 +59,9 @@

        Constraints:

          -
        • 1 <= s.length <= 10^5.
        • -
        • s consists of only digits and doesn't contain leading zeros.
        • -
        • 1 <= k <= 10^9.
        • +
        • 1 <= s.length <= 105
        • +
        • s consists of only digits and does not contain leading zeros.
        • +
        • 1 <= k <= 109
        ### Related Topics diff --git a/problems/reveal-cards-in-increasing-order/README.md b/problems/reveal-cards-in-increasing-order/README.md index e236bcd08..8250a5d91 100644 --- a/problems/reveal-cards-in-increasing-order/README.md +++ b/problems/reveal-cards-in-increasing-order/README.md @@ -11,32 +11,30 @@ ## [950. Reveal Cards In Increasing Order (Medium)](https://leetcode.com/problems/reveal-cards-in-increasing-order "按递增顺序显示卡牌") -

        In a deck of cards, every card has a unique integer.  You can order the deck in any order you want.

        +

        You are given an integer array deck. There is a deck of cards where every card has a unique integer. The integer on the ith card is deck[i].

        -

        Initially, all the cards start face down (unrevealed) in one deck.

        +

        You can order the deck in any order you want. Initially, all the cards start face down (unrevealed) in one deck.

        -

        Now, you do the following steps repeatedly, until all cards are revealed:

        +

        You will do the following steps repeatedly until all cards are revealed:

        1. Take the top card of the deck, reveal it, and take it out of the deck.
        2. -
        3. If there are still cards in the deck, put the next top card of the deck at the bottom of the deck.
        4. -
        5. If there are still unrevealed cards, go back to step 1.  Otherwise, stop.
        6. +
        7. If there are still cards in the deck then put the next top card of the deck at the bottom of the deck.
        8. +
        9. If there are still unrevealed cards, go back to step 1. Otherwise, stop.
        -

        Return an ordering of the deck that would reveal the cards in increasing order.

        +

        Return an ordering of the deck that would reveal the cards in increasing order.

        -

        The first entry in the answer is considered to be the top of the deck.

        +

        Note that the first entry in the answer is considered to be the top of the deck.

         

        - -

        Example 1:

        -Input: [17,13,11,2,3,5,7]
        -Output: [2,13,3,11,5,17,7]
        -Explanation: 
        -We get the deck in the order [17,13,11,2,3,5,7] (this order doesn't matter), and reorder it.
        +Input: deck = [17,13,11,2,3,5,7]
        +Output: [2,13,3,11,5,17,7]
        +Explanation: 
        +We get the deck in the order [17,13,11,2,3,5,7] (this order does not matter), and reorder it.
         After reordering, the deck starts as [2,13,3,11,5,17,7], where 2 is the top of the deck.
         We reveal 2, and move 13 to the bottom.  The deck is now [3,11,5,17,7,13].
         We reveal 3, and move 11 to the bottom.  The deck is now [5,17,7,13,11].
        @@ -48,18 +46,21 @@ We reveal 17.
         Since all the cards revealed are in increasing order, the answer is correct.
         
        -
        -

         

        +

        Example 2:

        + +
        +Input: deck = [1,1000]
        +Output: [1,1000]
        +
        -

        Note:

        +

         

        +

        Constraints:

        -
          +
          • 1 <= deck.length <= 1000
          • -
          • 1 <= deck[i] <= 10^6
          • -
          • deck[i] != deck[j] for all i != j
          • -
        -
        -
        +
      • 1 <= deck[i] <= 106
      • +
      • All the values of deck are unique.
      • +
      ### Related Topics [[Queue](../../tag/queue/README.md)] diff --git a/problems/reverse-words-in-a-string-ii/README.md b/problems/reverse-words-in-a-string-ii/README.md index 99bec2cd9..a3f5eff53 100644 --- a/problems/reverse-words-in-a-string-ii/README.md +++ b/problems/reverse-words-in-a-string-ii/README.md @@ -11,7 +11,23 @@ ## [186. Reverse Words in a String II (Medium)](https://leetcode.com/problems/reverse-words-in-a-string-ii "翻转字符串里的单词 II") +

      Given an input string , reverse the string word by word. 

      +

      Example:

      + +
      +Input:  ["t","h","e"," ","s","k","y"," ","i","s"," ","b","l","u","e"]
      +Output: ["b","l","u","e"," ","i","s"," ","s","k","y"," ","t","h","e"]
      + +

      Note: 

      + +
        +
      • A word is defined as a sequence of non-space characters.
      • +
      • The input string does not contain leading or trailing spaces.
      • +
      • The words are always separated by a single space.
      • +
      + +

      Follow up: Could you do it in-place without allocating extra space?

      ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/robot-room-cleaner/README.md b/problems/robot-room-cleaner/README.md index 2967c2fb1..9e0a3c292 100644 --- a/problems/robot-room-cleaner/README.md +++ b/problems/robot-room-cleaner/README.md @@ -11,7 +11,61 @@ ## [489. Robot Room Cleaner (Hard)](https://leetcode.com/problems/robot-room-cleaner "扫地机器人") +

      Given a robot cleaner in a room modeled as a grid.

      +

      Each cell in the grid can be empty or blocked.

      + +

      The robot cleaner with 4 given APIs can move forward, turn left or turn right. Each turn it made is 90 degrees.

      + +

      When it tries to move into a blocked cell, its bumper sensor detects the obstacle and it stays on the current cell.

      + +

      Design an algorithm to clean the entire room using only the 4 given APIs shown below.

      + +
      +interface Robot {
      +  // returns true if next cell is open and robot moves into the cell.
      +  // returns false if next cell is obstacle and robot stays on the current cell.
      +  boolean move();
      +
      +  // Robot will stay on the same cell after calling turnLeft/turnRight.
      +  // Each turn will be 90 degrees.
      +  void turnLeft();
      +  void turnRight();
      +
      +  // Clean the current cell.
      +  void clean();
      +}
      +
      + +

      Example:

      + +
      Input:
      +room = [
      +  [1,1,1,1,1,0,1,1],
      +  [1,1,1,1,1,0,1,1],
      +  [1,0,1,1,1,1,1,1],
      +  [0,0,0,1,0,0,0,0],
      +  [1,1,1,1,1,1,1,1]
      +],
      +row = 1,
      +col = 3
      +
      +Explanation:
      +All grids in the room are marked by either 0 or 1.
      +0 means the cell is blocked, while 1 means the cell is accessible.
      +The robot initially starts at the position of row=1, col=3.
      +From the top left corner, its position is one row below and three columns right.
      +
      + +

      Notes:

      + +
        +
      1. The input is only given to initialize the room and the robot's position internally. You must solve this problem "blindfolded". In other words, you must control the robot using only the mentioned 4 APIs, without knowing the room layout and the initial robot's position.
      2. +
      3. The robot's initial position will always be in an accessible cell.
      4. +
      5. The initial direction of the robot will be facing up.
      6. +
      7. All accessible cells are connected, which means the all cells marked as 1 will be accessible by the robot.
      8. +
      9. Assume all four edges of the grid are all surrounded by wall.
      10. +
      ### Related Topics [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/rotate-function/README.md b/problems/rotate-function/README.md index bf753ce68..56f6101fd 100644 --- a/problems/rotate-function/README.md +++ b/problems/rotate-function/README.md @@ -40,7 +40,7 @@ So the maximum value of F(0), F(1), F(2), F(3) is F(3) = 26.

      Example 2:

      -Input: nums = [1000000007]
      +Input: nums = [100]
       Output: 0
       
      diff --git a/problems/rotate-string/README.md b/problems/rotate-string/README.md index 49209f019..239d3dced 100644 --- a/problems/rotate-string/README.md +++ b/problems/rotate-string/README.md @@ -11,24 +11,28 @@ ## [796. Rotate String (Easy)](https://leetcode.com/problems/rotate-string "旋转字符串") -

      We are given two strings, s and goal.

      +

      Given two strings s and goal, return true if and only if s can become goal after some number of shifts on s.

      -

      A shift on s consists of taking string s and moving the leftmost character to the rightmost position. For example, if s = 'abcde', then it will be 'bcdea' after one shift on s. Return true if and only if s can become goal after some number of shifts on s.

      +

      A shift on s consists of moving the leftmost character of s to the rightmost position.

      -
      -Example 1:
      -Input: s = 'abcde', goal = 'cdeab'
      -Output: true
      +
        +
      • For example, if s = "abcde", then it will be "bcdea" after one shift.
      • +
      -Example 2: -Input: s = 'abcde', goal = 'abced' +

       

      +

      Example 1:

      +
      Input: s = "abcde", goal = "cdeab"
      +Output: true
      +

      Example 2:

      +
      Input: s = "abcde", goal = "abced"
       Output: false
       
      - -

      Note:

      +

       

      +

      Constraints:

        -
      • s and goal will have length at most 100.
      • +
      • 1 <= s.length, goal.length <= 100
      • +
      • s and goal consist of lowercase English letters.
      ### Related Topics diff --git a/problems/rotated-digits/README.md b/problems/rotated-digits/README.md index 90e1e9cdb..c4eb7c509 100644 --- a/problems/rotated-digits/README.md +++ b/problems/rotated-digits/README.md @@ -9,27 +9,50 @@                  [Next >](../escape-the-ghosts "Escape The Ghosts") -## [788. Rotated Digits (Easy)](https://leetcode.com/problems/rotated-digits "旋转数字") +## [788. Rotated Digits (Medium)](https://leetcode.com/problems/rotated-digits "旋转数字") -

      x is a good number if after rotating each digit individually by 180 degrees, we get a valid number that is different from x. Each digit must be rotated - we cannot choose to leave it alone.

      +

      An integer x is a good if after rotating each digit individually by 180 degrees, we get a valid number that is different from x. Each digit must be rotated - we cannot choose to leave it alone.

      -

      A number is valid if each digit remains a digit after rotation. 0, 1, and 8 rotate to themselves; 2 and 5 rotate to each other (on this case they are rotated in a different direction, in other words 2 or 5 gets mirrored); 6 and 9 rotate to each other, and the rest of the numbers do not rotate to any other number and become invalid.

      +

      A number is valid if each digit remains a digit after rotation. For example:

      -

      Now given a positive number n, how many numbers x from 1 to n are good?

      +
        +
      • 0, 1, and 8 rotate to themselves,
      • +
      • 2 and 5 rotate to each other (in this case they are rotated in a different direction, in other words, 2 or 5 gets mirrored),
      • +
      • 6 and 9 rotate to each other, and
      • +
      • the rest of the numbers do not rotate to any other number and become invalid.
      • +
      + +

      Given an integer n, return the number of good integers in the range [1, n].

      + +

       

      +

      Example 1:

      -Example:
      -Input: 10
      +Input: n = 10
       Output: 4
      -Explanation: 
      -There are four good numbers in the range [1, 10] : 2, 5, 6, 9.
      +Explanation: There are four good numbers in the range [1, 10] : 2, 5, 6, 9.
       Note that 1 and 10 are not good numbers, since they remain unchanged after rotating.
       
      -

      Note:

      +

      Example 2:

      + +
      +Input: n = 1
      +Output: 0
      +
      + +

      Example 3:

      + +
      +Input: n = 2
      +Output: 1
      +
      + +

       

      +

      Constraints:

        -
      • n will be in range [1, 10000].
      • +
      • 1 <= n <= 104
      ### Related Topics diff --git a/problems/running-total-for-different-genders/README.md b/problems/running-total-for-different-genders/README.md index 5d8b3fb00..68ee3d821 100644 --- a/problems/running-total-for-different-genders/README.md +++ b/problems/running-total-for-different-genders/README.md @@ -11,7 +11,68 @@ ## [1308. Running Total for Different Genders (Medium)](https://leetcode.com/problems/running-total-for-different-genders "不同性别每日分数总计") +

      Table: Scores

      +
      ++---------------+---------+
      +| Column Name   | Type    |
      ++---------------+---------+
      +| player_name   | varchar |
      +| gender        | varchar |
      +| day           | date    |
      +| score_points  | int     |
      ++---------------+---------+
      +(gender, day) is the primary key for this table.
      +A competition is held between females team and males team.
      +Each row of this table indicates that a player_name and with gender has scored score_point in someday.
      +Gender is 'F' if the player is in females team and 'M' if the player is in males team.
      + 
      +Write an SQL query to find the total score for each gender at each day. + +Order the result table by gender and day + +The query result format is in the following example: +
      +Scores table:
      ++-------------+--------+------------+--------------+
      +| player_name | gender | day        | score_points |
      ++-------------+--------+------------+--------------+
      +| Aron        | F      | 2020-01-01 | 17           |
      +| Alice       | F      | 2020-01-07 | 23           |
      +| Bajrang     | M      | 2020-01-07 | 7            |
      +| Khali       | M      | 2019-12-25 | 11           |
      +| Slaman      | M      | 2019-12-30 | 13           |
      +| Joe         | M      | 2019-12-31 | 3            |
      +| Jose        | M      | 2019-12-18 | 2            |
      +| Priya       | F      | 2019-12-31 | 23           |
      +| Priyanka    | F      | 2019-12-30 | 17           |
      ++-------------+--------+------------+--------------+
      +Result table:
      ++--------+------------+-------+
      +| gender | day        | total |
      ++--------+------------+-------+
      +| F      | 2019-12-30 | 17    |
      +| F      | 2019-12-31 | 40    |
      +| F      | 2020-01-01 | 57    |
      +| F      | 2020-01-07 | 80    |
      +| M      | 2019-12-18 | 2     |
      +| M      | 2019-12-25 | 13    |
      +| M      | 2019-12-30 | 26    |
      +| M      | 2019-12-31 | 29    |
      +| M      | 2020-01-07 | 36    |
      ++--------+------------+-------+
      +For females team:
      +First day is 2019-12-30, Priyanka scored 17 points and the total score for the team is 17.
      +Second day is 2019-12-31, Priya scored 23 points and the total score for the team is 40.
      +Third day is 2020-01-01, Aron scored 17 points and the total score for the team is 57.
      +Fourth day is 2020-01-07, Alice scored 23 points and the total score for the team is 80.
      +For males team:
      +First day is 2019-12-18, Jose scored 2 points and the total score for the team is 2.
      +Second day is 2019-12-25, Khali scored 11 points and the total score for the team is 13.
      +Third day is 2019-12-30, Slaman scored 13 points and the total score for the team is 26.
      +Fourth day is 2019-12-31, Joe scored 3 points and the total score for the team is 29.
      +Fifth day is 2020-01-07, Bajrang scored 7 points and the total score for the team is 36.
      +
      ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/sales-analysis-i/README.md b/problems/sales-analysis-i/README.md index e7a29796b..ff2769a67 100644 --- a/problems/sales-analysis-i/README.md +++ b/problems/sales-analysis-i/README.md @@ -11,7 +11,70 @@ ## [1082. Sales Analysis I (Easy)](https://leetcode.com/problems/sales-analysis-i "销售分析 I ") +

      Table: Product

      +
      ++--------------+---------+
      +| Column Name  | Type    |
      ++--------------+---------+
      +| product_id   | int     |
      +| product_name | varchar |
      +| unit_price   | int     |
      ++--------------+---------+
      +product_id is the primary key of this table.
      +
      + +

      Table: Sales

      + +
      ++-------------+---------+
      +| Column Name | Type    |
      ++-------------+---------+
      +| seller_id   | int     |
      +| product_id  | int     |
      +| buyer_id    | int     |
      +| sale_date   | date    |
      +| quantity    | int     |
      +| price       | int     |
      ++------ ------+---------+
      +This table has no primary key, it can have repeated rows.
      +product_id is a foreign key to Product table.
      +
      + +

       

      + +

      Write an SQL query that reports the best seller by total sales price, If there is a tie, report them all.

      + +

      The query result format is in the following example:

      + +
      +Product table:
      ++------------+--------------+------------+
      +| product_id | product_name | unit_price |
      ++------------+--------------+------------+
      +| 1          | S8           | 1000       |
      +| 2          | G4           | 800        |
      +| 3          | iPhone       | 1400       |
      ++------------+--------------+------------+
      +
      +Sales table:
      ++-----------+------------+----------+------------+----------+-------+
      +| seller_id | product_id | buyer_id | sale_date  | quantity | price |
      ++-----------+------------+----------+------------+----------+-------+
      +| 1         | 1          | 1        | 2019-01-21 | 2        | 2000  |
      +| 1         | 2          | 2        | 2019-02-17 | 1        | 800   |
      +| 2         | 2          | 3        | 2019-06-02 | 1        | 800   |
      +| 3         | 3          | 4        | 2019-05-13 | 2        | 2800  |
      ++-----------+------------+----------+------------+----------+-------+
      +
      +Result table:
      ++-------------+
      +| seller_id   |
      ++-------------+
      +| 1           |
      +| 3           |
      ++-------------+
      +Both sellers with id 1 and 3 sold products with the most total price of 2800.
      ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/sales-analysis-ii/README.md b/problems/sales-analysis-ii/README.md index a466fdd68..05837be7d 100644 --- a/problems/sales-analysis-ii/README.md +++ b/problems/sales-analysis-ii/README.md @@ -11,7 +11,69 @@ ## [1083. Sales Analysis II (Easy)](https://leetcode.com/problems/sales-analysis-ii "销售分析 II") +

      Table: Product

      +
      ++--------------+---------+
      +| Column Name  | Type    |
      ++--------------+---------+
      +| product_id   | int     |
      +| product_name | varchar |
      +| unit_price   | int     |
      ++--------------+---------+
      +product_id is the primary key of this table.
      +
      + +

      Table: Sales

      + +
      ++-------------+---------+
      +| Column Name | Type    |
      ++-------------+---------+
      +| seller_id   | int     |
      +| product_id  | int     |
      +| buyer_id    | int     |
      +| sale_date   | date    |
      +| quantity    | int     |
      +| price       | int     |
      ++------ ------+---------+
      +This table has no primary key, it can have repeated rows.
      +product_id is a foreign key to Product table.
      +
      + +

       

      + +

      Write an SQL query that reports the buyers who have bought S8 but not iPhone. Note that S8 and iPhone are products present in the Product table.

      + +

      The query result format is in the following example:

      + +
      +Product table:
      ++------------+--------------+------------+
      +| product_id | product_name | unit_price |
      ++------------+--------------+------------+
      +| 1          | S8           | 1000       |
      +| 2          | G4           | 800        |
      +| 3          | iPhone       | 1400       |
      ++------------+--------------+------------+
      +
      +Sales table:
      ++-----------+------------+----------+------------+----------+-------+
      +| seller_id | product_id | buyer_id | sale_date  | quantity | price |
      ++-----------+------------+----------+------------+----------+-------+
      +| 1         | 1          | 1        | 2019-01-21 | 2        | 2000  |
      +| 1         | 2          | 2        | 2019-02-17 | 1        | 800   |
      +| 2         | 1          | 3        | 2019-06-02 | 1        | 800   |
      +| 3         | 3          | 3        | 2019-05-13 | 2        | 2800  |
      ++-----------+------------+----------+------------+----------+-------+
      +
      +Result table:
      ++-------------+
      +| buyer_id    |
      ++-------------+
      +| 1           |
      ++-------------+
      +The buyer with id 1 bought an S8 but didn't buy an iPhone. The buyer with id 3 bought both.
      ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/sales-analysis-iii/README.md b/problems/sales-analysis-iii/README.md index fd9448d44..d198a55f4 100644 --- a/problems/sales-analysis-iii/README.md +++ b/problems/sales-analysis-iii/README.md @@ -11,7 +11,69 @@ ## [1084. Sales Analysis III (Easy)](https://leetcode.com/problems/sales-analysis-iii "销售分析III") +

      Table: Product

      +
      ++--------------+---------+
      +| Column Name  | Type    |
      ++--------------+---------+
      +| product_id   | int     |
      +| product_name | varchar |
      +| unit_price   | int     |
      ++--------------+---------+
      +product_id is the primary key of this table.
      +
      + +

      Table: Sales

      + +
      ++-------------+---------+
      +| Column Name | Type    |
      ++-------------+---------+
      +| seller_id   | int     |
      +| product_id  | int     |
      +| buyer_id    | int     |
      +| sale_date   | date    |
      +| quantity    | int     |
      +| price       | int     |
      ++------ ------+---------+
      +This table has no primary key, it can have repeated rows.
      +product_id is a foreign key to Product table.
      +
      + +

       

      + +

      Write an SQL query that reports the products that were only sold in spring 2019. That is, between 2019-01-01 and 2019-03-31 inclusive.

      + +

      The query result format is in the following example:

      + +
      +Product table:
      ++------------+--------------+------------+
      +| product_id | product_name | unit_price |
      ++------------+--------------+------------+
      +| 1          | S8           | 1000       |
      +| 2          | G4           | 800        |
      +| 3          | iPhone       | 1400       |
      ++------------+--------------+------------+
      +
      +Sales table:
      ++-----------+------------+----------+------------+----------+-------+
      +| seller_id | product_id | buyer_id | sale_date  | quantity | price |
      ++-----------+------------+----------+------------+----------+-------+
      +| 1         | 1          | 1        | 2019-01-21 | 2        | 2000  |
      +| 1         | 2          | 2        | 2019-02-17 | 1        | 800   |
      +| 2         | 2          | 3        | 2019-06-02 | 1        | 800   |
      +| 3         | 3          | 4        | 2019-05-13 | 2        | 2800  |
      ++-----------+------------+----------+------------+----------+-------+
      +
      +Result table:
      ++-------------+--------------+
      +| product_id  | product_name |
      ++-------------+--------------+
      +| 1           | S8           |
      ++-------------+--------------+
      +The product with id 1 was only sold in spring 2019 while the other two were sold after.
      ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/sales-person/README.md b/problems/sales-person/README.md index 16f0dcb9d..85f7385bd 100644 --- a/problems/sales-person/README.md +++ b/problems/sales-person/README.md @@ -11,7 +11,73 @@ ## [607. Sales Person (Easy)](https://leetcode.com/problems/sales-person "销售员") +

      Description

      +

      Given three tables: salesperson, company, orders.
      +Output all the names in the table salesperson, who didn’t have sales to company 'RED'.

      + +

      Example
      +Input

      + +

      Table: salesperson

      + +
      ++----------+------+--------+-----------------+-----------+
      +| sales_id | name | salary | commission_rate | hire_date |
      ++----------+------+--------+-----------------+-----------+
      +|   1      | John | 100000 |     6           | 4/1/2006  |
      +|   2      | Amy  | 120000 |     5           | 5/1/2010  |
      +|   3      | Mark | 65000  |     12          | 12/25/2008|
      +|   4      | Pam  | 25000  |     25          | 1/1/2005  |
      +|   5      | Alex | 50000  |     10          | 2/3/2007  |
      ++----------+------+--------+-----------------+-----------+
      +
      +The table salesperson holds the salesperson information. Every salesperson has a sales_id and a name. + +

      Table: company

      + +
      ++---------+--------+------------+
      +| com_id  |  name  |    city    |
      ++---------+--------+------------+
      +|   1     |  RED   |   Boston   |
      +|   2     | ORANGE |   New York |
      +|   3     | YELLOW |   Boston   |
      +|   4     | GREEN  |   Austin   |
      ++---------+--------+------------+
      +
      +The table company holds the company information. Every company has a com_id and a name. + +

      Table: orders

      + +
      ++----------+------------+---------+----------+--------+
      +| order_id | order_date | com_id  | sales_id | amount |
      ++----------+------------+---------+----------+--------+
      +| 1        |   1/1/2014 |    3    |    4     | 100000 |
      +| 2        |   2/1/2014 |    4    |    5     | 5000   |
      +| 3        |   3/1/2014 |    1    |    1     | 50000  |
      +| 4        |   4/1/2014 |    1    |    4     | 25000  |
      ++----------+----------+---------+----------+--------+
      +
      +The table orders holds the sales record information, salesperson and customer company are represented by sales_id and com_id. + +

      output

      + +
      ++------+
      +| name | 
      ++------+
      +| Amy  | 
      +| Mark | 
      +| Alex |
      ++------+
      +
      + +

      Explanation

      + +

      According to order '3' and '4' in table orders, it is easy to tell only salesperson 'John' and 'Alex' have sales to company 'RED',
      +so we need to output all the other names in table salesperson.

      ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/score-after-flipping-matrix/README.md b/problems/score-after-flipping-matrix/README.md index b40ba1d2f..93e475da0 100644 --- a/problems/score-after-flipping-matrix/README.md +++ b/problems/score-after-flipping-matrix/README.md @@ -11,39 +11,39 @@ ## [861. Score After Flipping Matrix (Medium)](https://leetcode.com/problems/score-after-flipping-matrix "翻转矩阵后的得分") -

      We have a two dimensional matrix grid where each value is 0 or 1.

      +

      You are given an m x n binary matrix grid.

      -

      A move consists of choosing any row or column, and toggling each value in that row or column: changing all 0s to 1s, and all 1s to 0s.

      +

      A move consists of choosing any row or column and toggling each value in that row or column (i.e., changing all 0's to 1's, and all 1's to 0's).

      -

      After making any number of moves, every row of this matrix is interpreted as a binary number, and the score of the matrix is the sum of these numbers.

      +

      Every row of the matrix is interpreted as a binary number, and the score of the matrix is the sum of these numbers.

      -

      Return the highest possible score.

      +

      Return the highest possible score after making any number of moves (including zero moves).

       

      - -
        -
      - -

      Example 1:

      - +
      -Input: grid = [[0,0,1,1],[1,0,1,0],[1,1,0,0]]
      -Output: 39
      -Explanation:
      -Toggled to [[1,1,1,1],[1,0,0,1],[1,1,1,1]].
      -0b1111 + 0b1001 + 0b1111 = 15 + 9 + 15 = 39
      +Input: grid = [[0,0,1,1],[1,0,1,0],[1,1,0,0]] +Output: 39 +Explanation: 0b1111 + 0b1001 + 0b1111 = 15 + 9 + 15 = 39 +
      -

       

      +

      Example 2:

      -

      Note:

      +
      +Input: grid = [[0]]
      +Output: 1
      +
      -
        -
      1. 1 <= grid.length <= 20
      2. -
      3. 1 <= grid[0].length <= 20
      4. -
      5. grid[i][j] is 0 or 1.
      6. -
      -
    +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 20
    • +
    • grid[i][j] is either 0 or 1.
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/score-of-parentheses/README.md b/problems/score-of-parentheses/README.md index 94ee29ad6..f03ada8ca 100644 --- a/problems/score-of-parentheses/README.md +++ b/problems/score-of-parentheses/README.md @@ -11,52 +11,38 @@ ## [856. Score of Parentheses (Medium)](https://leetcode.com/problems/score-of-parentheses "括号的分数") -

    Given a balanced parentheses string s, compute the score of the string based on the following rule:

    +

    Given a balanced parentheses string s, return the score of the string.

    + +

    The score of a balanced parentheses string is based on the following rule:

      -
    • () has score 1
    • -
    • AB has score A + B, where A and B are balanced parentheses strings.
    • -
    • (A) has score 2 * A, where A is a balanced parentheses string.
    • +
    • "()" has score 1.
    • +
    • AB has score A + B, where A and B are balanced parentheses strings.
    • +
    • (A) has score 2 * A, where A is a balanced parentheses string.

     

    -

    Example 1:

    - -
    -Input: s = "()"
    +
    Input: s = "()"
     Output: 1
    -
    - -

    Example 2:

    - -
    -Input: s = "(())"
    +

    Example 2:

    +
    Input: s = "(())"
     Output: 2
    -
    - -

    Example 3:

    - -
    -Input: s = "()()"
    +

    Example 3:

    +
    Input: s = "()()"
     Output: 2
    -
    - -

    Example 4:

    - -
    -Input: s = "(()(()))"
    +

    Example 4:

    +
    Input: s = "(()(()))"
     Output: 6
     
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. s is a balanced parentheses string, containing only ( and ).
    2. +
      • 2 <= s.length <= 50
      • -
    +
  • s consists of only '(' and ')'.
  • +
  • s is a balanced parentheses string.
  • + ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/search-in-a-sorted-array-of-unknown-size/README.md b/problems/search-in-a-sorted-array-of-unknown-size/README.md index 772893597..871493340 100644 --- a/problems/search-in-a-sorted-array-of-unknown-size/README.md +++ b/problems/search-in-a-sorted-array-of-unknown-size/README.md @@ -11,7 +11,33 @@ ## [702. Search in a Sorted Array of Unknown Size (Medium)](https://leetcode.com/problems/search-in-a-sorted-array-of-unknown-size "搜索长度未知的有序数组") +

    Given an integer array sorted in ascending order, write a function to search target in nums.  If target exists, then return its index, otherwise return -1. However, the array size is unknown to you. You may only access the array using an ArrayReader interface, where ArrayReader.get(k) returns the element of the array at index k (0-indexed).

    +

    You may assume all integers in the array are less than 10000, and if you access the array out of bounds, ArrayReader.get will return 2147483647.

    + +

     

    + +

    Example 1:

    + +
    Input: array = [-1,0,3,5,9,12], target = 9
    +Output: 4
    +Explanation: 9 exists in nums and its index is 4
    +
    + +

    Example 2:

    + +
    Input: array = [-1,0,3,5,9,12], target = 2
    +Output: -1
    +Explanation: 2 does not exist in nums so return -1
    + +

     

    + +

    Note:

    + +
      +
    1. You may assume that all elements in the array are unique.
    2. +
    3. The value of each element in the array will be in the range [-9999, 9999].
    4. +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/second-degree-follower/README.md b/problems/second-degree-follower/README.md index 010c65f7e..210dc64f2 100644 --- a/problems/second-degree-follower/README.md +++ b/problems/second-degree-follower/README.md @@ -11,7 +11,41 @@ ## [614. Second Degree Follower (Medium)](https://leetcode.com/problems/second-degree-follower "二级关注者") +

    In facebook, there is a follow table with two columns: followee, follower.

    +

    Please write a sql query to get the amount of each follower’s follower if he/she has one.

    + +

    For example:

    + +
    ++-------------+------------+
    +| followee    | follower   |
    ++-------------+------------+
    +|     A       |     B      |
    +|     B       |     C      |
    +|     B       |     D      |
    +|     D       |     E      |
    ++-------------+------------+
    +
    +should output: + +
    ++-------------+------------+
    +| follower    | num        |
    ++-------------+------------+
    +|     B       |  2         |
    +|     D       |  1         |
    ++-------------+------------+
    +
    +Explaination:
    +Both B and D exist in the follower list, when as a followee, B's follower is C and D, and D's follower is E. A does not exist in follower list. +

     

    + +

     

    +Note:
    +Followee would not follow himself/herself in all cases.
    +Please display the result in follower's alphabet order. +

     

    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/sentence-screen-fitting/README.md b/problems/sentence-screen-fitting/README.md index 7f7fafc94..1b40974d7 100644 --- a/problems/sentence-screen-fitting/README.md +++ b/problems/sentence-screen-fitting/README.md @@ -11,7 +11,73 @@ ## [418. Sentence Screen Fitting (Medium)](https://leetcode.com/problems/sentence-screen-fitting "屏幕可显示句子的数量") +

    Given a rows x cols screen and a sentence represented by a list of non-empty words, find how many times the given sentence can be fitted on the screen. +

    +

    Note: +

      +
    1. A word cannot be split into two lines.
    2. +
    3. The order of words in the sentence must remain unchanged.
    4. +
    5. Two consecutive words in a line must be separated by a single space.
    6. +
    7. Total words in the sentence won't exceed 100.
    8. +
    9. Length of each word is greater than 0 and won't exceed 10.
    10. +
    11. 1 ≤ rows, cols ≤ 20,000.
    12. +
    +

    + +

    +Example 1: +

    +Input:
    +rows = 2, cols = 8, sentence = ["hello", "world"]
    +
    +Output: 
    +1
    +
    +Explanation:
    +hello---
    +world---
    +
    +The character '-' signifies an empty space on the screen.
    +
    +

    + +

    +Example 2: +

    +Input:
    +rows = 3, cols = 6, sentence = ["a", "bcd", "e"]
    +
    +Output: 
    +2
    +
    +Explanation:
    +a-bcd- 
    +e-a---
    +bcd-e-
    +
    +The character '-' signifies an empty space on the screen.
    +
    +

    + +

    +Example 3: +

    +Input:
    +rows = 4, cols = 5, sentence = ["I", "had", "apple", "pie"]
    +
    +Output: 
    +1
    +
    +Explanation:
    +I-had
    +apple
    +pie-I
    +had--
    +
    +The character '-' signifies an empty space on the screen.
    +
    +

    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/sentence-similarity-ii/README.md b/problems/sentence-similarity-ii/README.md index 3defd9027..ad783e0e6 100644 --- a/problems/sentence-similarity-ii/README.md +++ b/problems/sentence-similarity-ii/README.md @@ -11,7 +11,28 @@ ## [737. Sentence Similarity II (Medium)](https://leetcode.com/problems/sentence-similarity-ii "句子相似性 II") +

    Given two sentences words1, words2 (each represented as an array of strings), and a list of similar word pairs pairs, determine if two sentences are similar.

    +

    For example, words1 = ["great", "acting", "skills"] and words2 = ["fine", "drama", "talent"] are similar, if the similar word pairs are pairs = [["great", "good"], ["fine", "good"], ["acting","drama"], ["skills","talent"]].

    + +

    Note that the similarity relation is transitive. For example, if "great" and "good" are similar, and "fine" and "good" are similar, then "great" and "fine" are similar.

    + +

    Similarity is also symmetric. For example, "great" and "fine" being similar is the same as "fine" and "great" being similar.

    + +

    Also, a word is always similar with itself. For example, the sentences words1 = ["great"], words2 = ["great"], pairs = [] are similar, even though there are no specified similar word pairs.

    + +

    Finally, sentences can only be similar if they have the same number of words. So a sentence like words1 = ["great"] can never be similar to words2 = ["doubleplus","good"].

    + +

    Note:

    + +
      +
    • The length of words1 and words2 will not exceed 1000.
    • +
    • The length of pairs will not exceed 2000.
    • +
    • The length of each pairs[i] will be 2.
    • +
    • The length of each words[i] and pairs[i][j] will be in the range [1, 20].
    • +
    + +

     

    ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/sentence-similarity/README.md b/problems/sentence-similarity/README.md index d01463178..7daf23854 100644 --- a/problems/sentence-similarity/README.md +++ b/problems/sentence-similarity/README.md @@ -11,7 +11,28 @@ ## [734. Sentence Similarity (Easy)](https://leetcode.com/problems/sentence-similarity "句子相似性") +

    Given two sentences words1, words2 (each represented as an array of strings), and a list of similar word pairs pairs, determine if two sentences are similar.

    +

    For example, "great acting skills" and "fine drama talent" are similar, if the similar word pairs are pairs = [["great", "fine"], ["acting","drama"], ["skills","talent"]].

    + +

    Note that the similarity relation is not transitive. For example, if "great" and "fine" are similar, and "fine" and "good" are similar, "great" and "good" are not necessarily similar.

    + +

    However, similarity is symmetric. For example, "great" and "fine" being similar is the same as "fine" and "great" being similar.

    + +

    Also, a word is always similar with itself. For example, the sentences words1 = ["great"], words2 = ["great"], pairs = [] are similar, even though there are no specified similar word pairs.

    + +

    Finally, sentences can only be similar if they have the same number of words. So a sentence like words1 = ["great"] can never be similar to words2 = ["doubleplus","good"].

    + +

    Note:

    + +
      +
    • The length of words1 and words2 will not exceed 1000.
    • +
    • The length of pairs will not exceed 2000.
    • +
    • The length of each pairs[i] will be 2.
    • +
    • The length of each words[i] and pairs[i][j] will be in the range [1, 20].
    • +
    + +

     

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/sequence-reconstruction/README.md b/problems/sequence-reconstruction/README.md index b8f1627ad..eb0ec0dc7 100644 --- a/problems/sequence-reconstruction/README.md +++ b/problems/sequence-reconstruction/README.md @@ -11,7 +11,61 @@ ## [444. Sequence Reconstruction (Medium)](https://leetcode.com/problems/sequence-reconstruction "序列重建") +

    Check whether the original sequence org can be uniquely reconstructed from the sequences in seqs. The org sequence is a permutation of the integers from 1 to n, with 1 ≤ n ≤ 104. Reconstruction means building a shortest common supersequence of the sequences in seqs (i.e., a shortest sequence so that all sequences in seqs are subsequences of it). Determine whether there is only one sequence that can be reconstructed from seqs and it is the org sequence.

    +

    Example 1: +

    +Input:
    +org: [1,2,3], seqs: [[1,2],[1,3]]
    +
    +Output:
    +false
    +
    +Explanation:
    +[1,2,3] is not the only one sequence that can be reconstructed, because [1,3,2] is also a valid sequence that can be reconstructed.
    +
    +

    + +

    Example 2: +

    +Input:
    +org: [1,2,3], seqs: [[1,2]]
    +
    +Output:
    +false
    +
    +Explanation:
    +The reconstructed sequence can only be [1,2].
    +
    +

    + +

    Example 3: +

    +Input:
    +org: [1,2,3], seqs: [[1,2],[1,3],[2,3]]
    +
    +Output:
    +true
    +
    +Explanation:
    +The sequences [1,2], [1,3], and [2,3] can uniquely reconstruct the original sequence [1,2,3].
    +
    +

    + +

    Example 4: +

    +Input:
    +org: [4,1,5,2,6,3], seqs: [[5,2,6,3],[4,1,5,2]]
    +
    +Output:
    +true
    +
    +

    + +

    +UPDATE (2017/1/8):
    +The seqs parameter had been changed to a list of list of strings (instead of a 2d array of strings). Please reload the code definition to get the latest changes. +

    ### Related Topics [[Graph](../../tag/graph/README.md)] diff --git a/problems/serialize-and-deserialize-n-ary-tree/README.md b/problems/serialize-and-deserialize-n-ary-tree/README.md index b2fea9d5d..a489aad6d 100644 --- a/problems/serialize-and-deserialize-n-ary-tree/README.md +++ b/problems/serialize-and-deserialize-n-ary-tree/README.md @@ -11,7 +11,28 @@ ## [428. Serialize and Deserialize N-ary Tree (Hard)](https://leetcode.com/problems/serialize-and-deserialize-n-ary-tree "序列化和反序列化 N 叉树") +

    Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment.

    +

    Design an algorithm to serialize and deserialize an N-ary tree. An N-ary tree is a rooted tree in which each node has no more than N children. There is no restriction on how your serialization/deserialization algorithm should work. You just need to ensure that an N-ary tree can be serialized to a string and this string can be deserialized to the original tree structure.

    + +

    For example, you may serialize the following 3-ary tree

    + +

     

    + +

    + +

     

    + +

    as [1 [3[5 6] 2 4]]. You do not necessarily need to follow this format, so please be creative and come up with different approaches yourself.

    + +

     

    + +

    Note:

    + +
      +
    1. N is in the range of [1, 1000]
    2. +
    3. Do not use class member/global/static variables to store states. Your serialize and deserialize algorithms should be stateless.
    4. +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/set-matrix-zeroes/README.md b/problems/set-matrix-zeroes/README.md index 23d6d68ea..f2ba94241 100644 --- a/problems/set-matrix-zeroes/README.md +++ b/problems/set-matrix-zeroes/README.md @@ -44,7 +44,7 @@

    Follow up:

      -
    • A straight forward solution using O(mn) space is probably a bad idea.
    • +
    • A straightforward solution using O(mn) space is probably a bad idea.
    • A simple improvement uses O(m + n) space, but still not the best solution.
    • Could you devise a constant space solution?
    diff --git a/problems/shifting-letters/README.md b/problems/shifting-letters/README.md index 6698b4f2c..443c20df6 100644 --- a/problems/shifting-letters/README.md +++ b/problems/shifting-letters/README.md @@ -11,34 +11,46 @@ ## [848. Shifting Letters (Medium)](https://leetcode.com/problems/shifting-letters "字母移位") -

    We have a string s of lowercase letters, and an integer array shifts.

    +

    You are given a string s of lowercase English letters and an integer array shifts of the same length.

    -

    Call the shift of a letter, the next letter in the alphabet, (wrapping around so that 'z' becomes 'a'). 

    +

    Call the shift() of a letter, the next letter in the alphabet, (wrapping around so that 'z' becomes 'a').

    -

    For example, shift('a') = 'b', shift('t') = 'u', and shift('z') = 'a'.

    +
      +
    • For example, shift('a') = 'b', shift('t') = 'u', and shift('z') = 'a'.
    • +
    -

    Now for each shifts[i] = x, we want to shift the first i+1 letters of S, x times.

    +

    Now for each shifts[i] = x, we want to shift the first i + 1 letters of s, x times.

    -

    Return the final string after all such shifts to s are applied.

    +

    Return the final string after all such shifts to s are applied.

    +

     

    Example 1:

    -Input: s = "abc", shifts = [3,5,9]
    -Output: "rpl"
    -Explanation: 
    -We start with "abc".
    -After shifting the first 1 letters of S by 3, we have "dbc".
    -After shifting the first 2 letters of S by 5, we have "igc".
    -After shifting the first 3 letters of S by 9, we have "rpl", the answer.
    +Input: s = "abc", shifts = [3,5,9]
    +Output: "rpl"
    +Explanation: We start with "abc".
    +After shifting the first 1 letters of s by 3, we have "dbc".
    +After shifting the first 2 letters of s by 5, we have "igc".
    +After shifting the first 3 letters of s by 9, we have "rpl", the answer.
     
    -

    Note:

    +

    Example 2:

    -
      -
    1. 1 <= s.length = shifts.length <= 20000
    2. +
      +Input: s = "aaa", shifts = [1,2,3]
      +Output: "gfd"
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= s.length <= 105
      • +
      • s consists of lowercase English letters.
      • +
      • shifts.length == s.length
      • 0 <= shifts[i] <= 109
      • -
    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/shortest-distance-from-all-buildings/README.md b/problems/shortest-distance-from-all-buildings/README.md index 0a986a223..ee20e154f 100644 --- a/problems/shortest-distance-from-all-buildings/README.md +++ b/problems/shortest-distance-from-all-buildings/README.md @@ -11,7 +11,33 @@ ## [317. Shortest Distance from All Buildings (Hard)](https://leetcode.com/problems/shortest-distance-from-all-buildings "离建筑物最近的距离") +

    You want to build a house on an empty land which reaches all buildings in the shortest amount of distance. You can only move up, down, left and right. You are given a 2D grid of values 0, 1 or 2, where:

    +
      +
    • Each 0 marks an empty land which you can pass by freely.
    • +
    • Each 1 marks a building which you cannot pass through.
    • +
    • Each 2 marks an obstacle which you cannot pass through.
    • +
    + +

    Example:

    + +
    +Input: [[1,0,2,0,1],[0,0,0,0,0],[0,0,1,0,0]]
    +
    +1 - 0 - 2 - 0 - 1
    +|   |   |   |   |
    +0 - 0 - 0 - 0 - 0
    +|   |   |   |   |
    +0 - 0 - 1 - 0 - 0
    +
    +Output: 7 
    +
    +Explanation: Given three buildings at (0,0), (0,4), (2,2), and an obstacle at (0,2),
    +             the point (1,2) is an ideal empty land to build a house, as the total 
    +             travel distance of 3+3+1=7 is minimal. So return 7.
    + +

    Note:
    +There will be at least one building. If it is not possible to build such house according to the above rules, return -1.

    ### Related Topics [[Breadth-First Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/shortest-distance-in-a-line/README.md b/problems/shortest-distance-in-a-line/README.md index fb0d985d0..b26f0f20a 100644 --- a/problems/shortest-distance-in-a-line/README.md +++ b/problems/shortest-distance-in-a-line/README.md @@ -11,7 +11,38 @@ ## [613. Shortest Distance in a Line (Easy)](https://leetcode.com/problems/shortest-distance-in-a-line "直线上的最近距离") +Table point holds the x coordinate of some points on x-axis in a plane, which are all integers. +

     

    +Write a query to find the shortest distance between two points in these points. +

     

    + +
    +| x   |
    +|-----|
    +| -1  |
    +| 0   |
    +| 2   |
    +
    + +

     

    +The shortest distance is '1' obviously, which is from point '-1' to '0'. So the output is as below: + +

     

    + +
    +| shortest|
    +|---------|
    +| 1       |
    +
    + +

     

    +Note: Every point is unique, which means there is no duplicates in table point. + +

     

    +Follow-up: What if all these points have an id and are arranged from the left most to the right most of x axis? + +

     

    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/shortest-distance-in-a-plane/README.md b/problems/shortest-distance-in-a-plane/README.md index f5ba847a6..1c8e67ad1 100644 --- a/problems/shortest-distance-in-a-plane/README.md +++ b/problems/shortest-distance-in-a-plane/README.md @@ -11,7 +11,35 @@ ## [612. Shortest Distance in a Plane (Medium)](https://leetcode.com/problems/shortest-distance-in-a-plane "平面上的最近距离") +Table point_2d holds the coordinates (x,y) of some unique points (more than two) in a plane. +

     

    +Write a query to find the shortest distance between these points rounded to 2 decimals. +

     

    + +
    +| x  | y  |
    +|----|----|
    +| -1 | -1 |
    +| 0  | 0  |
    +| -1 | -2 |
    +
    + +

     

    +The shortest distance is 1.00 from point (-1,-1) to (-1,2). So the output should be: + +

     

    + +
    +| shortest |
    +|----------|
    +| 1.00     |
    +
    + +

     

    +Note: The longest distance among all the points are less than 10000. + +

     

    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/shortest-distance-to-target-color/README.md b/problems/shortest-distance-to-target-color/README.md index 1d77abc52..e5974c4fa 100644 --- a/problems/shortest-distance-to-target-color/README.md +++ b/problems/shortest-distance-to-target-color/README.md @@ -11,7 +11,41 @@ ## [1182. Shortest Distance to Target Color (Medium)](https://leetcode.com/problems/shortest-distance-to-target-color "与目标颜色间的最短距离") +

    You are given an array colors, in which there are three colors: 1, 2 and 3.

    +

    You are also given some queries. Each query consists of two integers i and c, return the shortest distance between the given index i and the target color c. If there is no solution return -1.

    + +

     

    +

    Example 1:

    + +
    +Input: colors = [1,1,2,1,3,2,2,3,3], queries = [[1,3],[2,2],[6,1]]
    +Output: [3,0,3]
    +Explanation: 
    +The nearest 3 from index 1 is at index 4 (3 steps away).
    +The nearest 2 from index 2 is at index 2 itself (0 steps away).
    +The nearest 1 from index 6 is at index 3 (3 steps away).
    +
    + +

    Example 2:

    + +
    +Input: colors = [1,2], queries = [[0,3]]
    +Output: [-1]
    +Explanation: There is no 3 in the array.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= colors.length <= 5*10^4
    • +
    • 1 <= colors[i] <= 3
    • +
    • 1 <= queries.length <= 5*10^4
    • +
    • queries[i].length == 2
    • +
    • 0 <= queries[i][0] < colors.length
    • +
    • 1 <= queries[i][1] <= 3
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/shortest-path-in-a-hidden-grid/README.md b/problems/shortest-path-in-a-hidden-grid/README.md index 71950dd1b..499049657 100644 --- a/problems/shortest-path-in-a-hidden-grid/README.md +++ b/problems/shortest-path-in-a-hidden-grid/README.md @@ -9,7 +9,7 @@                  [Next >](../find-nearest-point-that-has-the-same-x-or-y-coordinate "Find Nearest Point That Has the Same X or Y Coordinate") -## [1778. Shortest Path in a Hidden Grid (Medium)](https://leetcode.com/problems/shortest-path-in-a-hidden-grid "") +## [1778. Shortest Path in a Hidden Grid (Medium)](https://leetcode.com/problems/shortest-path-in-a-hidden-grid "未知网格中的最短路径") diff --git a/problems/shortest-path-to-get-all-keys/README.md b/problems/shortest-path-to-get-all-keys/README.md index 8cd4067e8..a4447f698 100644 --- a/problems/shortest-path-to-get-all-keys/README.md +++ b/problems/shortest-path-to-get-all-keys/README.md @@ -11,44 +11,59 @@ ## [864. Shortest Path to Get All Keys (Hard)](https://leetcode.com/problems/shortest-path-to-get-all-keys "获取所有钥匙的最短路径") -

    We are given a 2-dimensional grid"." is an empty cell, "#" is a wall, "@" is the starting point, ("a", "b", ...) are keys, and ("A""B", ...) are locks.

    +

    You are given an m x n grid grid where:

    -

    We start at the starting point, and one move consists of walking one space in one of the 4 cardinal directions.  We cannot walk outside the grid, or walk into a wall.  If we walk over a key, we pick it up.  We can't walk over a lock unless we have the corresponding key.

    +
      +
    • '.' is an empty cell.
    • +
    • '#' is a wall.
    • +
    • '@' is the starting point.
    • +
    • Lowercase letters represent keys.
    • +
    • Uppercase letters represent locks.
    • +
    -

    For some 1 <= K <= 6, there is exactly one lowercase and one uppercase letter of the first K letters of the English alphabet in the grid.  This means that there is exactly one key for each lock, and one lock for each key; and also that the letters used to represent the keys and locks were chosen in the same order as the English alphabet.

    +

    You start at the starting point and one move consists of walking one space in one of the four cardinal directions. You cannot walk outside the grid, or walk into a wall.

    -

    Return the lowest number of moves to acquire all keys.  If it's impossible, return -1.

    +

    If you walk over a key, you can pick it up and you cannot walk over a lock unless you have its corresponding key.

    -

     

    +

    For some 1 <= k <= 6, there is exactly one lowercase and one uppercase letter of the first k letters of the English alphabet in the grid. This means that there is exactly one key for each lock, and one lock for each key; and also that the letters used to represent the keys and locks were chosen in the same order as the English alphabet.

    -
    -

    Example 1:

    +

    Return the lowest number of moves to acquire all keys. If it is impossible, return -1.

    +

     

    +

    Example 1:

    +
    -Input: ["@.a.#","###.#","b.A.B"]
    -Output: 8
    +Input: grid = ["@.a.#","###.#","b.A.B"]
    +Output: 8
    +Explanation: Note that the goal is to obtain all the keys not to open all the locks.
     
    -

    Example 2:

    + +
    +Input: grid = ["@..aA","..B#.","....b"]
    +Output: 6
    +
    +

    Example 3:

    +
    -Input: ["@..aA","..B#.","....b"]
    -Output: 6
    +Input: grid = ["@Aa"]
    +Output: -1
     
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= grid.length <= 30
    2. -
    3. 1 <= grid[0].length <= 30
    4. -
    5. grid[i][j] contains only '.', '#', '@''a'-'f' and 'A'-'F'
    6. -
    7. The number of keys is in [1, 6].  Each key has a different letter and opens exactly one lock.
    8. -
    -
    +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 30
    • +
    • grid[i][j] is either an English letter, '.', '#', or '@'.
    • +
    • The number of keys in the grid is in the range [1, 6].
    • +
    • Each key in the grid is unique.
    • +
    • Each key in the grid has a matching lock.
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/shortest-subarray-with-sum-at-least-k/README.md b/problems/shortest-subarray-with-sum-at-least-k/README.md index 5a99e0dc5..73131621a 100644 --- a/problems/shortest-subarray-with-sum-at-least-k/README.md +++ b/problems/shortest-subarray-with-sum-at-least-k/README.md @@ -11,51 +11,29 @@ ## [862. Shortest Subarray with Sum at Least K (Hard)](https://leetcode.com/problems/shortest-subarray-with-sum-at-least-k "和至少为 K 的最短子数组") -

    Return the length of the shortest, non-empty, contiguous subarray of nums with sum at least k.

    +

    Given an integer array nums and an integer k, return the length of the shortest non-empty subarray of nums with a sum of at least k. If there is no such subarray, return -1.

    -

    If there is no non-empty subarray with sum at least k, return -1.

    +

    A subarray is a contiguous part of an array.

     

    - -
      -
    - -

    Example 1:

    - -
    -Input: nums = [1], k = 1
    -Output: 1
    -
    - -
    -

    Example 2:

    - -
    -Input: nums = [1,2], k = 4
    -Output: -1
    +
    Input: nums = [1], k = 1
    +Output: 1
    +

    Example 2:

    +
    Input: nums = [1,2], k = 4
    +Output: -1
    +

    Example 3:

    +
    Input: nums = [2,-1,2], k = 3
    +Output: 3
     
    - -
    -

    Example 3:

    - -
    -Input: nums = [2,-1,2], k = 3
    -Output: 3
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= nums.length <= 50000
    2. -
    3. -105 <= nums[i] <= 105
    4. +
        +
      • 1 <= nums.length <= 105
      • +
      • -105 <= nums[i] <= 105
      • 1 <= k <= 109
      • -
    -
    -
    -
    + ### Related Topics [[Queue](../../tag/queue/README.md)] diff --git a/problems/shortest-way-to-form-string/README.md b/problems/shortest-way-to-form-string/README.md index 87df1c3dd..6f660e72d 100644 --- a/problems/shortest-way-to-form-string/README.md +++ b/problems/shortest-way-to-form-string/README.md @@ -11,7 +11,44 @@ ## [1055. Shortest Way to Form String (Medium)](https://leetcode.com/problems/shortest-way-to-form-string "形成字符串的最短路径") +

    From any string, we can form a subsequence of that string by deleting some number of characters (possibly no deletions).

    +

    Given two strings source and target, return the minimum number of subsequences of source such that their concatenation equals target. If the task is impossible, return -1.

    + +

     

    + +

    Example 1:

    + +
    +Input: source = "abc", target = "abcbc"
    +Output: 2
    +Explanation: The target "abcbc" can be formed by "abc" and "bc", which are subsequences of source "abc".
    +
    + +

    Example 2:

    + +
    +Input: source = "abc", target = "acdbc"
    +Output: -1
    +Explanation: The target string cannot be constructed from the subsequences of source string due to the character "d" in target string.
    +
    + +

    Example 3:

    + +
    +Input: source = "xyz", target = "xzyxz"
    +Output: 3
    +Explanation: The target string can be constructed as follows "xz" + "y" + "xz".
    +
    + +

     

    + +

    Note:

    + +
      +
    1. Both the source and target strings consist of only lowercase English letters from "a"-"z".
    2. +
    3. The lengths of source and target string are between 1 and 1000.
    4. +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/shortest-word-distance-ii/README.md b/problems/shortest-word-distance-ii/README.md index 84ef2aea5..d353dc002 100644 --- a/problems/shortest-word-distance-ii/README.md +++ b/problems/shortest-word-distance-ii/README.md @@ -11,7 +11,20 @@ ## [244. Shortest Word Distance II (Medium)](https://leetcode.com/problems/shortest-word-distance-ii "最短单词距离 II") +

    Design a class which receives a list of words in the constructor, and implements a method that takes two words word1 and word2 and return the shortest distance between these two words in the list. Your method will be called repeatedly many times with different parameters. 

    +

    Example:
    +Assume that words = ["practice", "makes", "perfect", "coding", "makes"].

    + +
    Input: word1 = “coding”, word2 = “practice”
    +Output: 3
    +
    + +
    Input: word1 = "makes", word2 = "coding"
    +Output: 1
    + +

    Note:
    +You may assume that word1 does not equal to word2, and word1 and word2 are both in the list.

    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/shortest-word-distance-iii/README.md b/problems/shortest-word-distance-iii/README.md index 8b1ecc47f..a3dfa9687 100644 --- a/problems/shortest-word-distance-iii/README.md +++ b/problems/shortest-word-distance-iii/README.md @@ -11,7 +11,25 @@ ## [245. Shortest Word Distance III (Medium)](https://leetcode.com/problems/shortest-word-distance-iii "最短单词距离 III") +

    Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.

    +

    word1 and word2 may be the same and they represent two individual words in the list.

    + +

    Example:
    +Assume that words = ["practice", "makes", "perfect", "coding", "makes"].

    + +
    +Input: word1 = “makes”, word2 = “coding”
    +Output: 1
    +
    + +
    +Input: word1 = "makes", word2 = "makes"
    +Output: 3
    +
    + +

    Note:
    +You may assume word1 and word2 are both in the list.

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/shortest-word-distance/README.md b/problems/shortest-word-distance/README.md index f394887b6..6748ea4e9 100644 --- a/problems/shortest-word-distance/README.md +++ b/problems/shortest-word-distance/README.md @@ -11,7 +11,23 @@ ## [243. Shortest Word Distance (Easy)](https://leetcode.com/problems/shortest-word-distance "最短单词距离") +

    Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.

    +

    Example:
    +Assume that words = ["practice", "makes", "perfect", "coding", "makes"].

    + +
    +Input: word1 = “coding”, word2 = “practice”
    +Output: 3
    +
    + +
    +Input: word1 = "makes", word2 = "coding"
    +Output: 1
    +
    + +

    Note:
    +You may assume that word1 does not equal to word2, and word1 and word2 are both in the list.

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/similar-rgb-color/README.md b/problems/similar-rgb-color/README.md index f4e0110e7..9c96687d1 100644 --- a/problems/similar-rgb-color/README.md +++ b/problems/similar-rgb-color/README.md @@ -11,7 +11,31 @@ ## [800. Similar RGB Color (Easy)](https://leetcode.com/problems/similar-rgb-color "相似 RGB 颜色") +

    In the following, every capital letter represents some hexadecimal digit from 0 to f.

    +

    The red-green-blue color "#AABBCC" can be written as "#ABC" in shorthand.  For example, "#15c" is shorthand for the color "#1155cc".

    + +

    Now, say the similarity between two colors "#ABCDEF" and "#UVWXYZ" is -(AB - UV)^2 - (CD - WX)^2 - (EF - YZ)^2.

    + +

    Given the color "#ABCDEF", return a 7 character color that is most similar to #ABCDEF, and has a shorthand (that is, it can be represented as some "#XYZ"

    + +
    +Example 1:
    +Input: color = "#09f166"
    +Output: "#11ee66"
    +Explanation:  
    +The similarity is -(0x09 - 0x11)^2 -(0xf1 - 0xee)^2 - (0x66 - 0x66)^2 = -64 -9 -0 = -73.
    +This is the highest among any shorthand color.
    +
    + +

    Note:

    + +
      +
    • color is a string of length 7.
    • +
    • color is a valid RGB color: for i > 0, color[i] is a hexadecimal digit from 0 to f
    • +
    • Any answer which has the same (highest) similarity as the best answer will be accepted.
    • +
    • All inputs and outputs should use lowercase letters, and the output is 7 characters.
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/single-row-keyboard/README.md b/problems/single-row-keyboard/README.md index ee579d29d..dabe10b72 100644 --- a/problems/single-row-keyboard/README.md +++ b/problems/single-row-keyboard/README.md @@ -11,7 +11,38 @@ ## [1165. Single-Row Keyboard (Easy)](https://leetcode.com/problems/single-row-keyboard "单行键盘") +

    There is a special keyboard with all keys in a single row.

    +

    Given a string keyboard of length 26 indicating the layout of the keyboard (indexed from 0 to 25), initially your finger is at index 0. To type a character, you have to move your finger to the index of the desired character. The time taken to move your finger from index i to index j is |i - j|.

    + +

    You want to type a string word. Write a function to calculate how much time it takes to type it with one finger.

    + +

     

    +

    Example 1:

    + +
    +Input: keyboard = "abcdefghijklmnopqrstuvwxyz", word = "cba"
    +Output: 4
    +Explanation: The index moves from 0 to 2 to write 'c' then to 1 to write 'b' then to 0 again to write 'a'.
    +Total time = 2 + 1 + 1 = 4. 
    +
    + +

    Example 2:

    + +
    +Input: keyboard = "pqrstuvwxyzabcdefghijklmno", word = "leetcode"
    +Output: 73
    +
    + +

     

    +

    Constraints:

    + +
      +
    • keyboard.length == 26
    • +
    • keyboard contains each English lowercase letter exactly once in some order.
    • +
    • 1 <= word.length <= 10^4
    • +
    • word[i] is an English lowercase letter.
    • +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/smallest-common-region/README.md b/problems/smallest-common-region/README.md index a853c14b1..4ab4daf57 100644 --- a/problems/smallest-common-region/README.md +++ b/problems/smallest-common-region/README.md @@ -11,7 +11,39 @@ ## [1257. Smallest Common Region (Medium)](https://leetcode.com/problems/smallest-common-region "最小公共区域") +

    You are given some lists of regions where the first region of each list includes all other regions in that list.

    +

    Naturally, if a region X contains another region Y then X is bigger than Y.

    + +

    Given two regions region1, region2, find out the smallest region that contains both of them.

    + +

    If you are given regions r1, r2 and r3 such that r1 includes r3, it is guaranteed there is no r2 such that r2 includes r3.
    +
    +It's guaranteed the smallest region exists.

    + +

     

    +

    Example 1:

    + +
    +Input:
    +regions = [["Earth","North America","South America"],
    +["North America","United States","Canada"],
    +["United States","New York","Boston"],
    +["Canada","Ontario","Quebec"],
    +["South America","Brazil"]],
    +region1 = "Quebec",
    +region2 = "New York"
    +Output: "North America"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= regions.length <= 10^4
    • +
    • region1 != region2
    • +
    • All strings consist of English letters and spaces with at most 20 letters.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/smallest-range-i/README.md b/problems/smallest-range-i/README.md index 39315189e..025217ab3 100644 --- a/problems/smallest-range-i/README.md +++ b/problems/smallest-range-i/README.md @@ -11,56 +11,47 @@ ## [908. Smallest Range I (Easy)](https://leetcode.com/problems/smallest-range-i "最小差值 I") -

    Given an array nums of integers, for each integer nums[i] we may choose any x with -k <= x <= k, and add x to nums[i].

    +

    You are given an integer array nums and an integer k.

    -

    After this process, we have some array result.

    +

    In one operation, you can choose any index i where 0 <= i < nums.length and change nums[i] to nums[i] + x where x is an integer from the range [-k, k]. You can apply this operation at most once for each index i.

    -

    Return the smallest possible difference between the maximum value of result and the minimum value of result.

    +

    The score of nums is the difference between the maximum and minimum elements in nums.

    -

     

    - -
      -
    +

    Return the minimum score of nums after applying the mentioned operation at most once for each index in it.

    -
    +

     

    Example 1:

    -Input: nums = [1], k = 0
    -Output: 0
    -Explanation: result = [1]
    +Input: nums = [1], k = 0
    +Output: 0
    +Explanation: The score is max(nums) - min(nums) = 1 - 1 = 0.
     
    -

    Example 2:

    -Input: nums = [0,10], k = 2
    -Output: 6
    -Explanation: result = [2,8]
    +Input: nums = [0,10], k = 2
    +Output: 6
    +Explanation: Change nums to be [2, 8]. The score is max(nums) - min(nums) = 8 - 2 = 6.
     
    -

    Example 3:

    -Input: nums = [1,3,6], k = 3
    -Output: 0
    -Explanation: result = [3,3,3] or result = [4,4,4]
    +Input: nums = [1,3,6], k = 3
    +Output: 0
    +Explanation: Change nums to be [4, 4, 4]. The score is max(nums) - min(nums) = 4 - 4 = 0.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= nums.length <= 10000
    2. -
    3. 0 <= nums[i] <= 10000
    4. -
    5. 0 <= k <= 10000
    6. -
    -
    -
    -
    +
      +
    • 1 <= nums.length <= 104
    • +
    • 0 <= nums[i] <= 104
    • +
    • 0 <= k <= 104
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/smallest-range-ii/README.md b/problems/smallest-range-ii/README.md index 412b355ad..8a6aaf9ed 100644 --- a/problems/smallest-range-ii/README.md +++ b/problems/smallest-range-ii/README.md @@ -11,56 +11,47 @@ ## [910. Smallest Range II (Medium)](https://leetcode.com/problems/smallest-range-ii "最小差值 II") -

    Given an array nums of integers, for each integer nums[i] we need to choose either x = -k or x = k, and add x to nums[i] (only once).

    +

    You are given an integer array nums and an integer k.

    -

    After this process, we have some array result.

    +

    For each index i where 0 <= i < nums.length, change nums[i] to be either nums[i] + k or nums[i] - k.

    -

    Return the smallest possible difference between the maximum value of result and the minimum value of result.

    +

    The score of nums is the difference between the maximum and minimum elements in nums.

    -

     

    - -
      -
    +

    Return the minimum score of nums after changing the values at each index.

    -
    +

     

    Example 1:

    -Input: nums = [1], k = 0
    -Output: 0
    -Explanation: result = [1]
    +Input: nums = [1], k = 0
    +Output: 0
    +Explanation: The score is max(nums) - min(nums) = 1 - 1 = 0.
     
    -

    Example 2:

    -Input: nums = [0,10], k = 2
    -Output: 6
    -Explanation: result = [2,8]
    +Input: nums = [0,10], k = 2
    +Output: 6
    +Explanation: Change nums to be [2, 8]. The score is max(nums) - min(nums) = 8 - 2 = 6.
     
    -

    Example 3:

    -Input: nums = [1,3,6], k = 3
    -Output: 3
    -Explanation: result = [4,6,3]
    +Input: nums = [1,3,6], k = 3
    +Output: 3
    +Explanation: Change nums to be [4, 6, 3]. The score is max(nums) - min(nums) = 6 - 3 = 3.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= nums.length <= 10000
    2. -
    3. 0 <= nums[i] <= 10000
    4. -
    5. 0 <= k <= 10000
    6. -
    -
    -
    -
    +
      +
    • 1 <= nums.length <= 104
    • +
    • 0 <= nums[i] <= 104
    • +
    • 0 <= k <= 104
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/smallest-rectangle-enclosing-black-pixels/README.md b/problems/smallest-rectangle-enclosing-black-pixels/README.md index c66c5abe9..032a287b9 100644 --- a/problems/smallest-rectangle-enclosing-black-pixels/README.md +++ b/problems/smallest-rectangle-enclosing-black-pixels/README.md @@ -11,7 +11,21 @@ ## [302. Smallest Rectangle Enclosing Black Pixels (Hard)](https://leetcode.com/problems/smallest-rectangle-enclosing-black-pixels "包含全部黑色像素的最小矩形") +

    An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black pixels are connected, i.e., there is only one black region. Pixels are connected horizontally and vertically. Given the location (x, y) of one of the black pixels, return the area of the smallest (axis-aligned) rectangle that encloses all black pixels.

    +

    Example:

    + +
    +Input:
    +[
    +  "0010",
    +  "0110",
    +  "0100"
    +]
    +and x = 0, y = 2
    +
    +Output: 6
    +
    ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/smallest-rotation-with-highest-score/README.md b/problems/smallest-rotation-with-highest-score/README.md index 7a586d48b..5cc70c886 100644 --- a/problems/smallest-rotation-with-highest-score/README.md +++ b/problems/smallest-rotation-with-highest-score/README.md @@ -11,42 +11,44 @@ ## [798. Smallest Rotation with Highest Score (Hard)](https://leetcode.com/problems/smallest-rotation-with-highest-score "得分最高的最小轮调") -

    Given an array nums, we may rotate it by a non-negative integer k so that the array becomes nums[k], nums[k+1], nums[k+2], ... nums[nums.length - 1], nums[0], nums[1], ..., nums[k-1].  Afterward, any entries that are less than or equal to their index are worth 1 point.

    +

    You are given an array nums. You can rotate it by a non-negative integer k so that the array becomes [nums[k], nums[k + 1], ... nums[nums.length - 1], nums[0], nums[1], ..., nums[k-1]]. Afterward, any entries that are less than or equal to their index are worth one point.

    -

    For example, if we have [2, 4, 1, 3, 0], and we rotate by k = 2, it becomes [1, 3, 0, 2, 4]. This is worth 3 points because 1 > 0 [no points], 3 > 1 [no points], 0 <= 2 [one point], 2 <= 3 [one point], 4 <= 4 [one point].

    +
      +
    • For example, if we have nums = [2,4,1,3,0], and we rotate by k = 2, it becomes [1,3,0,2,4]. This is worth 3 points because 1 > 0 [no points], 3 > 1 [no points], 0 <= 2 [one point], 2 <= 3 [one point], 4 <= 4 [one point].
    • +
    -

    Over all possible rotations, return the rotation index k that corresponds to the highest score we could receive. If there are multiple answers, return the smallest such index k.

    +

    Return the rotation index k that corresponds to the highest score we can achieve if we rotated nums by it. If there are multiple answers, return the smallest such index k.

    + +

     

    +

    Example 1:

    -Example 1:
    -Input: [2, 3, 1, 4, 0]
    +Input: nums = [2,3,1,4,0]
     Output: 3
    -Explanation:  
    -Scores for each k are listed below: 
    +Explanation: Scores for each k are listed below: 
     k = 0,  nums = [2,3,1,4,0],    score 2
     k = 1,  nums = [3,1,4,0,2],    score 3
     k = 2,  nums = [1,4,0,2,3],    score 3
     k = 3,  nums = [4,0,2,3,1],    score 4
     k = 4,  nums = [0,2,3,1,4],    score 3
    +So we should choose k = 3, which has the highest score.
     
    -

    So we should choose k = 3, which has the highest score.

    - -

     

    +

    Example 2:

    -Example 2:
    -Input: [1, 3, 0, 2, 4]
    +Input: nums = [1,3,0,2,4]
     Output: 0
     Explanation: nums will always have 3 points no matter how it shifts.
     So we will choose the smallest k, which is 0.
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • nums will have length at most 20000.
    • -
    • nums[i] will be in the range [0, nums.length].
    • +
    • 1 <= nums.length <= 105
    • +
    • 0 <= nums[i] < nums.length
    ### Related Topics diff --git a/problems/sort-array-by-parity/README.md b/problems/sort-array-by-parity/README.md index deccd3bdc..ebad65e3c 100644 --- a/problems/sort-array-by-parity/README.md +++ b/problems/sort-array-by-parity/README.md @@ -11,30 +11,33 @@ ## [905. Sort Array By Parity (Easy)](https://leetcode.com/problems/sort-array-by-parity "按奇偶排序数组") -

    Given an array nums of non-negative integers, return an array consisting of all the even elements of nums, followed by all the odd elements of nums.

    +

    Given an integer array nums, move all the even integers at the beginning of the array followed by all the odd integers.

    -

    You may return any answer array that satisfies this condition.

    +

    Return any array that satisfies this condition.

     

    - -

    Example 1:

    -Input: nums = [3,1,2,4]
    -Output: [2,4,3,1]
    -The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be accepted.
    +Input: nums = [3,1,2,4]
    +Output: [2,4,3,1]
    +Explanation: The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be accepted.
     
    -

     

    +

    Example 2:

    + +
    +Input: nums = [0]
    +Output: [0]
    +
    -

    Note:

    +

     

    +

    Constraints:

    -
      +
      • 1 <= nums.length <= 5000
      • 0 <= nums[i] <= 5000
      • -
    -
    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/sort-transformed-array/README.md b/problems/sort-transformed-array/README.md index d6c13c3e6..5e0bdca3e 100644 --- a/problems/sort-transformed-array/README.md +++ b/problems/sort-transformed-array/README.md @@ -11,7 +11,27 @@ ## [360. Sort Transformed Array (Medium)](https://leetcode.com/problems/sort-transformed-array "有序转化数组") +

    Given a sorted array of integers nums and integer values a, b and c. Apply a quadratic function of the form f(x) = ax2 + bx + c to each element x in the array.

    +

    The returned array must be in sorted order.

    + +

    Expected time complexity: O(n)

    + +
    +

    Example 1:

    + +
    +Input: nums = [-4,-2,2,4], a = 1, b = 3, c = 5
    +Output: [3,9,15,33]
    +
    + +
    +

    Example 2:

    + +
    +Input: nums = [-4,-2,2,4], a = -1, b = 3, c = 5
    +Output: [-23,-5,1,7]
    +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/soup-servings/README.md b/problems/soup-servings/README.md index 6d127ce38..1ec57cf30 100644 --- a/problems/soup-servings/README.md +++ b/problems/soup-servings/README.md @@ -11,37 +11,45 @@ ## [808. Soup Servings (Medium)](https://leetcode.com/problems/soup-servings "分汤") -

    There are two types of soup: type A and type B. Initially we have n ml of each type of soup. There are four kinds of operations:

    +

    There are two types of soup: type A and type B. Initially, we have n ml of each type of soup. There are four kinds of operations:

      -
    1. Serve 100 ml of soup A and 0 ml of soup B
    2. -
    3. Serve 75 ml of soup A and 25 ml of soup B
    4. -
    5. Serve 50 ml of soup A and 50 ml of soup B
    6. -
    7. Serve 25 ml of soup A and 75 ml of soup B
    8. +
    9. Serve 100 ml of soup A and 0 ml of soup B,
    10. +
    11. Serve 75 ml of soup A and 25 ml of soup B,
    12. +
    13. Serve 50 ml of soup A and 50 ml of soup B, and
    14. +
    15. Serve 25 ml of soup A and 75 ml of soup B.
    -

    When we serve some soup, we give it to someone and we no longer have it. Each turn, we will choose from the four operations with equal probability 0.25. If the remaining volume of soup is not enough to complete the operation, we will serve as much as we can. We stop once we no longer have some quantity of both types of soup.

    +

    When we serve some soup, we give it to someone, and we no longer have it. Each turn, we will choose from the four operations with an equal probability 0.25. If the remaining volume of soup is not enough to complete the operation, we will serve as much as possible. We stop once we no longer have some quantity of both types of soup.

    -

    Note that we do not have the operation where all 100 ml's of soup B are used first.

    +

    Note that we do not have an operation where all 100 ml's of soup B are used first.

    -

    Return the probability that soup A will be empty first, plus half the probability that A and B become empty at the same time.

    +

    Return the probability that soup A will be empty first, plus half the probability that A and B become empty at the same time. Answers within 10-5 of the actual answer will be accepted.

     

    +

    Example 1:

    -Example:
     Input: n = 50
    -Output: 0.625
    -Explanation: 
    -If we choose the first two operations, A will become empty first. For the third operation, A and B will become empty at the same time. For the fourth operation, B will become empty first. So the total probability of A becoming empty first plus half the probability that A and B become empty at the same time, is 0.25 * (1 + 1 + 0.5 + 0) = 0.625.
    +Output: 0.62500
    +Explanation: If we choose the first two operations, A will become empty first.
    +For the third operation, A and B will become empty at the same time.
    +For the fourth operation, B will become empty first.
    +So the total probability of A becoming empty first plus half the probability that A and B become empty at the same time, is 0.25 * (1 + 1 + 0.5 + 0) = 0.625.
    +
    + +

    Example 2:

    +
    +Input: n = 100
    +Output: 0.71875
     
    -

    Notes:

    +

     

    +

    Constraints:

      -
    • 0 <= n <= 109.
    • -
    • Answers within 10-6 of the true value will be accepted as correct.
    • +
    • 0 <= n <= 109
    ### Related Topics diff --git a/problems/sparse-matrix-multiplication/README.md b/problems/sparse-matrix-multiplication/README.md index 8060d4074..6679df3d3 100644 --- a/problems/sparse-matrix-multiplication/README.md +++ b/problems/sparse-matrix-multiplication/README.md @@ -11,7 +11,32 @@ ## [311. Sparse Matrix Multiplication (Medium)](https://leetcode.com/problems/sparse-matrix-multiplication "稀疏矩阵的乘法") +

    Given two sparse matrices A and B, return the result of AB.

    +

    You may assume that A's column number is equal to B's row number.

    + +

    Example:

    + +
    +Input:
    +
    +A = [
    +  [ 1, 0, 0],
    +  [-1, 0, 3]
    +]
    +
    +B = [
    +  [ 7, 0, 0 ],
    +  [ 0, 0, 0 ],
    +  [ 0, 0, 1 ]
    +]
    +
    +Output:
    +
    +     |  1 0 0 |   | 7 0 0 |   |  7 0 0 |
    +AB = | -1 0 3 | x | 0 0 0 | = | -7 0 3 |
    +                  | 0 0 1 |
    +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/spiral-matrix-iii/README.md b/problems/spiral-matrix-iii/README.md index dc0d2556d..51bdcf795 100644 --- a/problems/spiral-matrix-iii/README.md +++ b/problems/spiral-matrix-iii/README.md @@ -11,54 +11,35 @@ ## [885. Spiral Matrix III (Medium)](https://leetcode.com/problems/spiral-matrix-iii "螺旋矩阵 III") -

    On a 2 dimensional grid with rows rows and cols columns, we start at (rStart, cStart) facing east.

    +

    You start at the cell (rStart, cStart) of an rows x cols grid facing east. The northwest corner is at the first row and column in the grid, and the southeast corner is at the last row and column.

    -

    Here, the north-west corner of the grid is at the first row and column, and the south-east corner of the grid is at the last row and column.

    +

    You will walk in a clockwise spiral shape to visit every position in this grid. Whenever you move outside the grid's boundary, we continue our walk outside the grid (but may return to the grid boundary later.). Eventually, we reach all rows * cols spaces of the grid.

    -

    Now, we walk in a clockwise spiral shape to visit every position in this grid. 

    - -

    Whenever we would move outside the boundary of the grid, we continue our walk outside the grid (but may return to the grid boundary later.) 

    - -

    Eventually, we reach all rows * cols spaces of the grid.

    - -

    Return a list of coordinates representing the positions of the grid in the order they were visited.

    +

    Return an array of coordinates representing the positions of the grid in the order you visited them.

     

    -

    Example 1:

    - -
    -Input: rows = 1, cols = 4, rStart = 0, cStart = 0
    -Output: [[0,0],[0,1],[0,2],[0,3]]
    -
     
    +
    +Input: rows = 1, cols = 4, rStart = 0, cStart = 0
    +Output: [[0,0],[0,1],[0,2],[0,3]]
     
    -

     

    -

    Example 2:

    - -
    -Input: rows = 5, cols = 6, rStart = 1, cStart = 4
    -Output: [[1,4],[1,5],[2,5],[2,4],[2,3],[1,3],[0,3],[0,4],[0,5],[3,5],[3,4],[3,3],[3,2],[2,2],[1,2],[0,2],[4,5],[4,4],[4,3],[4,2],[4,1],[3,1],[2,1],[1,1],[0,1],[4,0],[3,0],[2,0],[1,0],[0,0]]
    -
     
    +
    +Input: rows = 5, cols = 6, rStart = 1, cStart = 4
    +Output: [[1,4],[1,5],[2,5],[2,4],[2,3],[1,3],[0,3],[0,4],[0,5],[3,5],[3,4],[3,3],[3,2],[2,2],[1,2],[0,2],[4,5],[4,4],[4,3],[4,2],[4,1],[3,1],[2,1],[1,1],[0,1],[4,0],[3,0],[2,0],[1,0],[0,0]]
     
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= rows <= 100
    2. -
    3. 1 <= cols <= 100
    4. +
        +
      • 1 <= rows, cols <= 100
      • 0 <= rStart < rows
      • 0 <= cStart < cols
      • -
    -
    -
    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/split-array-with-equal-sum/README.md b/problems/split-array-with-equal-sum/README.md index 78ed17ac5..e4b219c6f 100644 --- a/problems/split-array-with-equal-sum/README.md +++ b/problems/split-array-with-equal-sum/README.md @@ -9,9 +9,35 @@                  [Next >](../binary-tree-longest-consecutive-sequence-ii "Binary Tree Longest Consecutive Sequence II") -## [548. Split Array with Equal Sum (Medium)](https://leetcode.com/problems/split-array-with-equal-sum "将数组分割成和相等的子数组") +## [548. Split Array with Equal Sum (Hard)](https://leetcode.com/problems/split-array-with-equal-sum "将数组分割成和相等的子数组") +

    +Given an array with n integers, you need to find if there are triplets (i, j, k) which satisfies following conditions: +

      +
    1. 0 < i, i + 1 < j, j + 1 < k < n - 1
    2. +
    3. Sum of subarrays (0, i - 1), (i + 1, j - 1), (j + 1, k - 1) and (k + 1, n - 1) should be equal.
    4. +
    +where we define that subarray (L, R) represents a slice of the original array starting from the element indexed L to the element indexed R. +

    +

    Example:
    +

    +Input: [1,2,1,2,1,2,1]
    +Output: True
    +Explanation:
    +i = 1, j = 3, k = 5. 
    +sum(0, i - 1) = sum(0, 0) = 1
    +sum(i + 1, j - 1) = sum(2, 2) = 1
    +sum(j + 1, k - 1) = sum(4, 4) = 1
    +sum(k + 1, n - 1) = sum(6, 6) = 1
    +
    +

    + +Note: +
      +
    1. 1 <= n <= 2000.
    2. +
    3. Elements in the given array will be in range [-1,000,000, 1,000,000].
    4. +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/split-bst/README.md b/problems/split-bst/README.md index 7e5836f2e..69e6d4f6b 100644 --- a/problems/split-bst/README.md +++ b/problems/split-bst/README.md @@ -11,7 +11,43 @@ ## [776. Split BST (Medium)](https://leetcode.com/problems/split-bst "拆分二叉搜索树") +

    Given a Binary Search Tree (BST) with root node root, and a target value V, split the tree into two subtrees where one subtree has nodes that are all smaller or equal to the target value, while the other subtree has all nodes that are greater than the target value.  It's not necessarily the case that the tree contains a node with value V.

    +

    Additionally, most of the structure of the original tree should remain.  Formally, for any child C with parent P in the original tree, if they are both in the same subtree after the split, then node C should still have the parent P.

    + +

    You should output the root TreeNode of both subtrees after splitting, in any order.

    + +

    Example 1:

    + +
    +Input: root = [4,2,6,1,3,5,7], V = 2
    +Output: [[2,1],[4,3,6,null,null,5,7]]
    +Explanation:
    +Note that root, output[0], and output[1] are TreeNode objects, not arrays.
    +
    +The given tree [4,2,6,1,3,5,7] is represented by the following diagram:
    +
    +          4
    +        /   \
    +      2      6
    +     / \    / \
    +    1   3  5   7
    +
    +while the diagrams for the outputs are:
    +
    +          4
    +        /   \
    +      3      6      and    2
    +            / \           /
    +           5   7         1
    +
    + +

    Note:

    + +
      +
    1. The size of the BST will not exceed 50.
    2. +
    3. The BST is always valid and each node's value is different.
    4. +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/split-concatenated-strings/README.md b/problems/split-concatenated-strings/README.md index a999bca1a..036dfb480 100644 --- a/problems/split-concatenated-strings/README.md +++ b/problems/split-concatenated-strings/README.md @@ -11,7 +11,32 @@ ## [555. Split Concatenated Strings (Medium)](https://leetcode.com/problems/split-concatenated-strings "分割连接字符串") +

    Given a list of strings, you could concatenate these strings together into a loop, where for each string you could choose to reverse it or not. Among all the possible loops, you need to find the lexicographically biggest string after cutting the loop, which will make the looped string into a regular one.

    +

    Specifically, to find the lexicographically biggest string, you need to experience two phases: +

      +
    1. Concatenate all the strings into a loop, where you can reverse some strings or not and connect them in the same order as given.
    2. +
    3. Cut and make one breakpoint in any place of the loop, which will make the looped string into a regular one starting from the character at the cutpoint.
    4. +
    +

    + +

    And your job is to find the lexicographically biggest one among all the possible regular strings.

    + + +

    Example:
    +

    +Input: "abc", "xyz"
    +Output: "zyxcba"
    +Explanation: You can get the looped string "-abcxyz-", "-abczyx-", "-cbaxyz-", "-cbazyx-", 
    where '-' represents the looped status.
    The answer string came from the fourth looped one,
    where you could cut from the middle character 'a' and get "zyxcba". +
    +

    + +

    Note:
    +

      +
    1. The input strings will only contain lowercase letters.
    2. +
    3. The total length of all the strings will not over 1,000.
    4. +
    +

    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/squirrel-simulation/README.md b/problems/squirrel-simulation/README.md index 5060c8f49..49ddc5a3e 100644 --- a/problems/squirrel-simulation/README.md +++ b/problems/squirrel-simulation/README.md @@ -36,6 +36,7 @@ Nuts : [[3,0], [2,5]] ### Related Topics + [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] ### Hints diff --git a/problems/stamping-the-sequence/README.md b/problems/stamping-the-sequence/README.md index 2f0b9552b..b260b7a9b 100644 --- a/problems/stamping-the-sequence/README.md +++ b/problems/stamping-the-sequence/README.md @@ -11,49 +11,54 @@ ## [936. Stamping The Sequence (Hard)](https://leetcode.com/problems/stamping-the-sequence "戳印序列") -

    You want to form a target string of lowercase letters.

    +

    You are given two strings stamp and target. Initially, there is a string s of length target.length with all s[i] == '?'.

    -

    At the beginning, your sequence is target.length '?' marks.  You also have a stamp of lowercase letters.

    +

    In one turn, you can place stamp over s and replace every letter in the s with the corresponding letter from stamp.

    -

    On each turn, you may place the stamp over the sequence, and replace every letter in the sequence with the corresponding letter from the stamp.  You can make up to 10 * target.length turns.

    +
      +
    • For example, if stamp = "abc" and target = "abcba", then s is "?????" initially. In one turn you can: +
        +
      • place stamp at index 0 of s to obtain "abc??",
      • +
      • place stamp at index 1 of s to obtain "?abc?", or
      • +
      • place stamp at index 2 of s to obtain "??abc".
      • +
      + Note that stamp must be fully contained in the boundaries of s in order to stamp (i.e., you cannot place stamp at index 3 of s).
    • +
    -

    For example, if the initial sequence is "?????", and your stamp is "abc",  then you may make "abc??", "?abc?", "??abc" in the first turn.  (Note that the stamp must be fully contained in the boundaries of the sequence in order to stamp.)

    +

    We want to convert s to target using at most 10 * target.length turns.

    -

    If the sequence is possible to stamp, then return an array of the index of the left-most letter being stamped at each turn.  If the sequence is not possible to stamp, return an empty array.

    - -

    For example, if the sequence is "ababc", and the stamp is "abc", then we could return the answer [0, 2], corresponding to the moves "?????" -> "abc??" -> "ababc".

    - -

    Also, if the sequence is possible to stamp, it is guaranteed it is possible to stamp within 10 * target.length moves.  Any answers specifying more than this number of moves will not be accepted.

    +

    Return an array of the index of the left-most letter being stamped at each turn. If we cannot obtain target from s within 10 * target.length turns, return an empty array.

     

    -

    Example 1:

    -Input: stamp = "abc", target = "ababc"
    -Output: [0,2]
    -([1,0,2] would also be accepted as an answer, as well as some other answers.)
    +Input: stamp = "abc", target = "ababc"
    +Output: [0,2]
    +Explanation: Initially s = "?????".
    +- Place stamp at index 0 to get "abc??".
    +- Place stamp at index 2 to get "ababc".
    +[1,0,2] would also be accepted as an answer, as well as some other answers.
     
    -

    Example 2:

    -Input: stamp = "abca", target = "aabcaca"
    -Output: [3,0,1]
    +Input: stamp = "abca", target = "aabcaca"
    +Output: [3,0,1]
    +Explanation: Initially s = "???????".
    +- Place stamp at index 3 to get "???abca".
    +- Place stamp at index 0 to get "abcabca".
    +- Place stamp at index 1 to get "aabcaca".
     
    -

     

    +

    Constraints:

    -

    Note:

    -
    -
    - -
      +
      • 1 <= stamp.length <= target.length <= 1000
      • -
      • stamp and target only contain lowercase letters.
      • -
    +
  • stamp and target consist of lowercase English letters.
  • + ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/stepping-numbers/README.md b/problems/stepping-numbers/README.md index ad8a8f1ec..1ee2c7220 100644 --- a/problems/stepping-numbers/README.md +++ b/problems/stepping-numbers/README.md @@ -11,7 +11,21 @@ ## [1215. Stepping Numbers (Medium)](https://leetcode.com/problems/stepping-numbers "步进数") +

    A Stepping Number is an integer such that all of its adjacent digits have an absolute difference of exactly 1. For example, 321 is a Stepping Number while 421 is not.

    +

    Given two integers low and high, find and return a sorted list of all the Stepping Numbers in the range [low, high] inclusive.

    + +

     

    +

    Example 1:

    +
    Input: low = 0, high = 21
    +Output: [0,1,2,3,4,5,6,7,8,9,10,12,21]
    +
    +

     

    +

    Constraints:

    + +
      +
    • 0 <= low <= high <= 2 * 10^9
    • +
    ### Related Topics [[Breadth-First Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/string-transforms-into-another-string/README.md b/problems/string-transforms-into-another-string/README.md index 5ed7f6f1c..a3e6c6cf3 100644 --- a/problems/string-transforms-into-another-string/README.md +++ b/problems/string-transforms-into-another-string/README.md @@ -11,7 +11,38 @@ ## [1153. String Transforms Into Another String (Hard)](https://leetcode.com/problems/string-transforms-into-another-string "字符串转化") +

    Given two strings str1 and str2 of the same length, determine whether you can transform str1 into str2 by doing zero or more conversions.

    +

    In one conversion you can convert all occurrences of one character in str1 to any other lowercase English character.

    + +

    Return true if and only if you can transform str1 into str2.

    + +

     

    + +

    Example 1:

    + +
    +Input: str1 = "aabcc", str2 = "ccdee"
    +Output: true
    +Explanation: Convert 'c' to 'e' then 'b' to 'd' then 'a' to 'c'. Note that the order of conversions matter.
    +
    + +

    Example 2:

    + +
    +Input: str1 = "leetcode", str2 = "codeleet"
    +Output: false
    +Explanation: There is no way to transform str1 to str2.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= str1.length == str2.length <= 10^4
    2. +
    3. Both str1 and str2 contain only lowercase English letters.
    4. +
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/strobogrammatic-number-ii/README.md b/problems/strobogrammatic-number-ii/README.md index bde7e29ae..fc91cab86 100644 --- a/problems/strobogrammatic-number-ii/README.md +++ b/problems/strobogrammatic-number-ii/README.md @@ -11,7 +11,16 @@ ## [247. Strobogrammatic Number II (Medium)](https://leetcode.com/problems/strobogrammatic-number-ii "中心对称数 II") +

    A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).

    +

    Find all strobogrammatic numbers that are of length = n.

    + +

    Example:

    + +
    +Input:  n = 2
    +Output: ["11","69","88","96"]
    +
    ### Related Topics [[Recursion](../../tag/recursion/README.md)] diff --git a/problems/strobogrammatic-number-iii/README.md b/problems/strobogrammatic-number-iii/README.md index db270752d..4648f1223 100644 --- a/problems/strobogrammatic-number-iii/README.md +++ b/problems/strobogrammatic-number-iii/README.md @@ -11,7 +11,19 @@ ## [248. Strobogrammatic Number III (Hard)](https://leetcode.com/problems/strobogrammatic-number-iii "中心对称数 III") +

    A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).

    +

    Write a function to count the total strobogrammatic numbers that exist in the range of low <= num <= high.

    + +

    Example:

    + +
    +Input: low = "50", high = "100"
    +Output: 3 
    +Explanation: 69, 88, and 96 are three strobogrammatic numbers.
    + +

    Note:
    +Because the range might be a large number, the low and high numbers are represented as string.

    ### Related Topics [[Recursion](../../tag/recursion/README.md)] diff --git a/problems/strobogrammatic-number/README.md b/problems/strobogrammatic-number/README.md index eda04becb..805989ec0 100644 --- a/problems/strobogrammatic-number/README.md +++ b/problems/strobogrammatic-number/README.md @@ -11,7 +11,28 @@ ## [246. Strobogrammatic Number (Easy)](https://leetcode.com/problems/strobogrammatic-number "中心对称数") +

    A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).

    +

    Write a function to determine if a number is strobogrammatic. The number is represented as a string.

    + +

    Example 1:

    + +
    +Input:  "69"
    +Output: true
    +
    + +

    Example 2:

    + +
    +Input:  "88"
    +Output: true
    + +

    Example 3:

    + +
    +Input:  "962"
    +Output: false
    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/strong-friendship/README.md b/problems/strong-friendship/README.md new file mode 100644 index 000000000..0ef455b63 --- /dev/null +++ b/problems/strong-friendship/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../delete-duplicate-folders-in-system "Delete Duplicate Folders in System") +                 +[Next >](../maximum-of-minimum-values-in-all-subarrays "Maximum of Minimum Values in All Subarrays") + +## [1949. Strong Friendship (Medium)](https://leetcode.com/problems/strong-friendship "") + + diff --git a/problems/strong-friendship/mysql_schemas.sql b/problems/strong-friendship/mysql_schemas.sql new file mode 100644 index 000000000..e542a265f --- /dev/null +++ b/problems/strong-friendship/mysql_schemas.sql @@ -0,0 +1,14 @@ +Create table If Not Exists Friendship (user1_id int, user2_id int); +Truncate table Friendship; +insert into Friendship (user1_id, user2_id) values ('1', '2'); +insert into Friendship (user1_id, user2_id) values ('1', '3'); +insert into Friendship (user1_id, user2_id) values ('2', '3'); +insert into Friendship (user1_id, user2_id) values ('1', '4'); +insert into Friendship (user1_id, user2_id) values ('2', '4'); +insert into Friendship (user1_id, user2_id) values ('1', '5'); +insert into Friendship (user1_id, user2_id) values ('2', '5'); +insert into Friendship (user1_id, user2_id) values ('1', '7'); +insert into Friendship (user1_id, user2_id) values ('3', '7'); +insert into Friendship (user1_id, user2_id) values ('1', '6'); +insert into Friendship (user1_id, user2_id) values ('3', '6'); +insert into Friendship (user1_id, user2_id) values ('2', '6'); diff --git a/problems/students-and-examinations/README.md b/problems/students-and-examinations/README.md index 6b8d2228c..7247b28a6 100644 --- a/problems/students-and-examinations/README.md +++ b/problems/students-and-examinations/README.md @@ -11,7 +11,104 @@ ## [1280. Students and Examinations (Easy)](https://leetcode.com/problems/students-and-examinations "学生们参加各科测试的次数") +

    Table: Students

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| student_id    | int     |
    +| student_name  | varchar |
    ++---------------+---------+
    +student_id is the primary key for this table.
    +Each row of this table contains the ID and the name of one student in the school.
    +
    + +

    Table: Subjects

    +
    ++--------------+---------+
    +| Column Name  | Type    |
    ++--------------+---------+
    +| subject_name | varchar |
    ++--------------+---------+
    +subject_name is the primary key for this table.
    +Each row of this table contains a name of one subject in the school.
    +
    + +

    Table: Examinations

    +
    ++--------------+---------+
    +| Column Name  | Type    |
    ++--------------+---------+
    +| student_id   | int     |
    +| subject_name | varchar |
    ++--------------+---------+
    +There is no primary key for this table. It may contain duplicates.
    +Each student from Students table takes every course from Subjects table.
    +Each row of this table indicates that a student with ID student_id attended the exam of subject_name.
    +
    + +Write an SQL query to find the number of times each student attended each exam. +Order the result table by student_id and subject_name. + +The query result format is in the following example: +
    +Students table:
    ++------------+--------------+
    +| student_id | student_name |
    ++------------+--------------+
    +| 1          | Alice        |
    +| 2          | Bob          |
    +| 13         | John         |
    +| 6          | Alex         |
    ++------------+--------------+
    +Subjects table:
    ++--------------+
    +| subject_name |
    ++--------------+
    +| Math         |
    +| Physics      |
    +| Programming  |
    ++--------------+
    +Examinations table:
    ++------------+--------------+
    +| student_id | subject_name |
    ++------------+--------------+
    +| 1          | Math         |
    +| 1          | Physics      |
    +| 1          | Programming  |
    +| 2          | Programming  |
    +| 1          | Physics      |
    +| 1          | Math         |
    +| 13         | Math         |
    +| 13         | Programming  |
    +| 13         | Physics      |
    +| 2          | Math         |
    +| 1          | Math         |
    ++------------+--------------+
    +Result table:
    ++------------+--------------+--------------+----------------+
    +| student_id | student_name | subject_name | attended_exams |
    ++------------+--------------+--------------+----------------+
    +| 1          | Alice        | Math         | 3              |
    +| 1          | Alice        | Physics      | 2              |
    +| 1          | Alice        | Programming  | 1              |
    +| 2          | Bob          | Math         | 1              |
    +| 2          | Bob          | Physics      | 0              |
    +| 2          | Bob          | Programming  | 1              |
    +| 6          | Alex         | Math         | 0              |
    +| 6          | Alex         | Physics      | 0              |
    +| 6          | Alex         | Programming  | 0              |
    +| 13         | John         | Math         | 1              |
    +| 13         | John         | Physics      | 1              |
    +| 13         | John         | Programming  | 1              |
    ++------------+--------------+--------------+----------------+
    +The result table should contain all students and all subjects.
    +Alice attended Math exam 3 times, Physics exam 2 times and Programming exam 1 time.
    +Bob attended Math exam 1 time, Programming exam 1 time and didn't attend the Physics exam.
    +Alex didn't attend any exam.
    +John attended Math exam 1 time, Physics exam 1 time and Programming exam 1 time.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/students-report-by-geography/README.md b/problems/students-report-by-geography/README.md index 4ce16b51e..73a5919e9 100644 --- a/problems/students-report-by-geography/README.md +++ b/problems/students-report-by-geography/README.md @@ -11,7 +11,37 @@ ## [618. Students Report By Geography (Hard)](https://leetcode.com/problems/students-report-by-geography "学生地理信息报告") +A U.S graduate school has students from Asia, Europe and America. The students' location information are stored in table student as below. +

     

    +
    +| name   | continent |
    +|--------|-----------|
    +| Jack   | America   |
    +| Pascal | Europe    |
    +| Xi     | Asia      |
    +| Jane   | America   |
    +
    + +

     

    + Pivot the continent column in this table so that each name is sorted alphabetically and displayed underneath its corresponding continent. The output headers should be America, Asia and Europe respectively. It is guaranteed that the student number from America is no less than either Asia or Europe. + +

     

    +For the sample input, the output is: + +

     

    + +
    +| America | Asia | Europe |
    +|---------|------|--------|
    +| Jack    | Xi   | Pascal |
    +| Jane    |      |        |
    +
    + +

     

    +Follow-up: If it is unknown which continent has the most students, can you write a query to generate the student report? + +

     

    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/students-with-invalid-departments/README.md b/problems/students-with-invalid-departments/README.md index 18fd03bac..19cb5a74c 100644 --- a/problems/students-with-invalid-departments/README.md +++ b/problems/students-with-invalid-departments/README.md @@ -11,7 +11,74 @@ ## [1350. Students With Invalid Departments (Easy)](https://leetcode.com/problems/students-with-invalid-departments "院系无效的学生") +

    Table: Departments

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| id            | int     |
    +| name          | varchar |
    ++---------------+---------+
    +id is the primary key of this table.
    +The table has information about the id of each department of a university.
    +
    + +

    Table: Students

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| id            | int     |
    +| name          | varchar |
    +| department_id | int     |
    ++---------------+---------+
    +id is the primary key of this table.
    +The table has information about the id of each student at a university and the id of the department he/she studies at.
    +
    + +Write an SQL query to find the id and the name of all students who are enrolled in departments that no longer exists. +Return the result table in any order. + +The query result format is in the following example: +
    +Departments table:
    ++------+--------------------------+
    +| id   | name                     |
    ++------+--------------------------+
    +| 1    | Electrical Engineering   |
    +| 7    | Computer Engineering     |
    +| 13   | Bussiness Administration |
    ++------+--------------------------+
    +
    +Students table:
    ++------+----------+---------------+
    +| id   | name     | department_id |
    ++------+----------+---------------+
    +| 23   | Alice    | 1             |
    +| 1    | Bob      | 7             |
    +| 5    | Jennifer | 13            |
    +| 2    | John     | 14            |
    +| 4    | Jasmine  | 77            |
    +| 3    | Steve    | 74            |
    +| 6    | Luis     | 1             |
    +| 8    | Jonathan | 7             |
    +| 7    | Daiana   | 33            |
    +| 11   | Madelynn | 1             |
    ++------+----------+---------------+
    +
    +Result table:
    ++------+----------+
    +| id   | name     |
    ++------+----------+
    +| 2    | John     |
    +| 7    | Daiana   |
    +| 4    | Jasmine  |
    +| 3    | Steve    |
    ++------+----------+
    +
    +John, Daiana, Steve and Jasmine are enrolled in departments 14, 33, 74 and 77 respectively. department 14, 33, 74 and 77 doesn't exist in the Departments table.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/subtree-of-another-tree/README.md b/problems/subtree-of-another-tree/README.md index b7a7318f3..654f1ec17 100644 --- a/problems/subtree-of-another-tree/README.md +++ b/problems/subtree-of-another-tree/README.md @@ -9,7 +9,7 @@                  [Next >](../squirrel-simulation "Squirrel Simulation") -## [572. Subtree of Another Tree (Easy)](https://leetcode.com/problems/subtree-of-another-tree "另一个树的子树") +## [572. Subtree of Another Tree (Easy)](https://leetcode.com/problems/subtree-of-another-tree "另一棵树的子树")

    Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise.

    diff --git a/problems/sum-game/README.md b/problems/sum-game/README.md new file mode 100644 index 000000000..fc9526ea6 --- /dev/null +++ b/problems/sum-game/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../nearest-exit-from-entrance-in-maze "Nearest Exit from Entrance in Maze") +                 +[Next >](../minimum-cost-to-reach-destination-in-time "Minimum Cost to Reach Destination in Time") + +## [1927. Sum Game (Medium)](https://leetcode.com/problems/sum-game "求和游戏") + +

    Alice and Bob take turns playing a game, with Alice starting first.

    + +

    You are given a string num of even length consisting of digits and '?' characters. On each turn, a player will do the following if there is still at least one '?' in num:

    + +
      +
    1. Choose an index i where num[i] == '?'.
    2. +
    3. Replace num[i] with any digit between '0' and '9'.
    4. +
    + +

    The game ends when there are no more '?' characters in num.

    + +

    For Bob to win, the sum of the digits in the first half of num must be equal to the sum of the digits in the second half. For Alice to win, the sums must not be equal.

    + +
      +
    • For example, if the game ended with num = "243801", then Bob wins because 2+4+3 = 8+0+1. If the game ended with num = "243803", then Alice wins because 2+4+3 != 8+0+3.
    • +
    + +

    Assuming Alice and Bob play optimally, return true if Alice will win and false if Bob will win.

    + +

     

    +

    Example 1:

    + +
    +Input: num = "5023"
    +Output: false
    +Explanation: There are no moves to be made.
    +The sum of the first half is equal to the sum of the second half: 5 + 0 = 2 + 3.
    +
    + +

    Example 2:

    + +
    +Input: num = "25??"
    +Output: true
    +Explanation: Alice can replace one of the '?'s with '9' and it will be impossible for Bob to make the sums equal.
    +
    + +

    Example 3:

    + +
    +Input: num = "?3295???"
    +Output: false
    +Explanation: It can be proven that Bob will always win. One possible outcome is:
    +- Alice replaces the first '?' with '9'. num = "93295???".
    +- Bob replaces one of the '?' in the right half with '9'. num = "932959??".
    +- Alice replaces one of the '?' in the right half with '2'. num = "9329592?".
    +- Bob replaces the last '?' in the right half with '7'. num = "93295927".
    +Bob wins because 9 + 3 + 2 + 9 = 5 + 9 + 2 + 7.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= num.length <= 105
    • +
    • num.length is even.
    • +
    • num consists of only digits and '?'.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] + +### Hints +
    +Hint 1 +Bob can always make the total sum of both sides equal in mod 9. +
    + +
    +Hint 2 +Why does the difference between the number of question marks on the left and right side matter? +
    diff --git a/problems/sum-of-digits-in-the-minimum-number/README.md b/problems/sum-of-digits-in-the-minimum-number/README.md index 6c5ae3e3a..c0eb6700d 100644 --- a/problems/sum-of-digits-in-the-minimum-number/README.md +++ b/problems/sum-of-digits-in-the-minimum-number/README.md @@ -11,7 +11,38 @@ ## [1085. Sum of Digits in the Minimum Number (Easy)](https://leetcode.com/problems/sum-of-digits-in-the-minimum-number "最小元素各数位之和") +

    Given an array A of positive integers, let S be the sum of the digits of the minimal element of A.

    +

    Return 0 if S is odd, otherwise return 1.

    + +

     

    + +

    Example 1:

    + +
    +Input: [34,23,1,24,75,33,54,8]
    +Output: 0
    +Explanation: 
    +The minimal element is 1, and the sum of those digits is S = 1 which is odd, so the answer is 0.
    +
    + +

    Example 2:

    + +
    +Input: [99,77,33,66,55]
    +Output: 1
    +Explanation: 
    +The minimal element is 33, and the sum of those digits is S = 3 + 3 = 6 which is even, so the answer is 1.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= A.length <= 100
    2. +
    3. 1 <= A[i].length <= 100
    4. +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/sum-of-digits-of-string-after-convert/README.md b/problems/sum-of-digits-of-string-after-convert/README.md new file mode 100644 index 000000000..9e5090d5b --- /dev/null +++ b/problems/sum-of-digits-of-string-after-convert/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../number-of-visible-people-in-a-queue "Number of Visible People in a Queue") +                 +[Next >](../largest-number-after-mutating-substring "Largest Number After Mutating Substring") + +## [1945. Sum of Digits of String After Convert (Easy)](https://leetcode.com/problems/sum-of-digits-of-string-after-convert "字符串转化后的各位数字之和") + +

    You are given a string s consisting of lowercase English letters, and an integer k.

    + +

    First, convert s into an integer by replacing each letter with its position in the alphabet (i.e., replace 'a' with 1, 'b' with 2, ..., 'z' with 26). Then, transform the integer by replacing it with the sum of its digits. Repeat the transform operation k times in total.

    + +

    For example, if s = "zbax" and k = 2, then the resulting integer would be 8 by the following operations:

    + +
      +
    • Convert: "zbax" ➝ "(26)(2)(1)(24)" ➝ "262124" ➝ 262124
    • +
    • Transform #1: 262124 ➝ 2 + 6 + 2 + 1 + 2 + 4 ➝ 17
    • +
    • Transform #2: 17 ➝ 1 + 7 ➝ 8
    • +
    + +

    Return the resulting integer after performing the operations described above.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "iiii", k = 1
    +Output: 36
    +Explanation: The operations are as follows:
    +- Convert: "iiii" ➝ "(9)(9)(9)(9)" ➝ "9999" ➝ 9999
    +- Transform #1: 9999 ➝ 9 + 9 + 9 + 9 ➝ 36
    +Thus the resulting integer is 36.
    +
    + +

    Example 2:

    + +
    +Input: s = "leetcode", k = 2
    +Output: 6
    +Explanation: The operations are as follows:
    +- Convert: "leetcode" ➝ "(12)(5)(5)(20)(3)(15)(4)(5)" ➝ "12552031545" ➝ 12552031545
    +- Transform #1: 12552031545 ➝ 1 + 2 + 5 + 5 + 2 + 0 + 3 + 1 + 5 + 4 + 5 ➝ 33
    +- Transform #2: 33 ➝ 3 + 3 ➝ 6
    +Thus the resulting integer is 6.
    +
    + +

    Example 3:

    + +
    +Input: s = "zbax", k = 2
    +Output: 8
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 100
    • +
    • 1 <= k <= 10
    • +
    • s consists of lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +First, let's note that after the first transform the value will be at most 100 * 9 which is not much +
    + +
    +Hint 2 +After The first transform, we can just do the rest of the transforms by brute force +
    diff --git a/problems/sum-of-distances-in-tree/README.md b/problems/sum-of-distances-in-tree/README.md index 9a6701e17..470093066 100644 --- a/problems/sum-of-distances-in-tree/README.md +++ b/problems/sum-of-distances-in-tree/README.md @@ -11,29 +11,49 @@ ## [834. Sum of Distances in Tree (Hard)](https://leetcode.com/problems/sum-of-distances-in-tree "树中距离之和") -

    An undirected, connected tree with n nodes labelled 0...n-1 and n-1 edges are given.

    +

    There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges.

    -

    The ith edge connects nodes edges[i][0] and edges[i][1] together.

    +

    You are given the integer n and the array edges where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree.

    -

    Return a list ans, where ans[i] is the sum of the distances between node i and all other nodes.

    +

    Return an array answer of length n where answer[i] is the sum of the distances between the ith node in the tree and all other nodes.

    +

     

    Example 1:

    - +
    -Input: n = 6, edges = [[0,1],[0,2],[2,3],[2,4],[2,5]]
    -Output: [8,12,6,10,10,10]
    -Explanation: 
    -Here is a diagram of the given tree:
    -  0
    - / \
    -1   2
    -   /|\
    -  3 4 5
    +Input: n = 6, edges = [[0,1],[0,2],[2,3],[2,4],[2,5]]
    +Output: [8,12,6,10,10,10]
    +Explanation: The tree is shown above.
     We can see that dist(0,1) + dist(0,2) + dist(0,3) + dist(0,4) + dist(0,5)
    -equals 1 + 1 + 2 + 2 + 2 = 8.  Hence, answer[0] = 8, and so on.
    +equals 1 + 1 + 2 + 2 + 2 = 8.
    +Hence, answer[0] = 8, and so on.
    +
    + +

    Example 2:

    + +
    +Input: n = 1, edges = []
    +Output: [0]
     
    -

    Note: 1 <= n <= 10000

    +

    Example 3:

    + +
    +Input: n = 2, edges = [[1,0]]
    +Output: [1,1]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 3 * 104
    • +
    • edges.length == n - 1
    • +
    • edges[i].length == 2
    • +
    • 0 <= ai, bi < n
    • +
    • ai != bi
    • +
    • The given input represents a valid tree.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/sum-of-subsequence-widths/README.md b/problems/sum-of-subsequence-widths/README.md index 900b0678f..ed7f78ad6 100644 --- a/problems/sum-of-subsequence-widths/README.md +++ b/problems/sum-of-subsequence-widths/README.md @@ -11,37 +11,37 @@ ## [891. Sum of Subsequence Widths (Hard)](https://leetcode.com/problems/sum-of-subsequence-widths "子序列宽度之和") -

    Given an array of integers nums, consider all non-empty subsequences of nums.

    +

    The width of a sequence is the difference between the maximum and minimum elements in the sequence.

    -

    For any sequence seq, let the width of seq be the difference between the maximum and minimum element of seq.

    +

    Given an array of integers nums, return the sum of the widths of all the non-empty subsequences of nums. Since the answer may be very large, return it modulo 109 + 7.

    -

    Return the sum of the widths of all subsequences of nums

    +

    A subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements. For example, [3,6,2,7] is a subsequence of the array [0,3,1,6,2,2,7].

    -

    As the answer may be very large, return the answer modulo 109 + 7.

    - -

     

    -

    Example 1:

    -Input: nums = [2,1,3]
    -Output: 6
    -Explanation:
    -Subsequences are [1], [2], [3], [2,1], [2,3], [1,3], [2,1,3].
    +Input: nums = [2,1,3]
    +Output: 6
    +Explanation: The subsequences are [1], [2], [3], [2,1], [2,3], [1,3], [2,1,3].
     The corresponding widths are 0, 0, 0, 1, 1, 2, 2.
     The sum of these widths is 6.
     
    -

     

    +

    Example 2:

    -

    Note:

    +
    +Input: nums = [2]
    +Output: 0
    +
    + +

     

    +

    Constraints:

      -
    • 1 <= nums.length <= 20000
    • -
    • 1 <= nums[i] <= 20000
    • +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 105
    -
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/surrounded-regions/README.md b/problems/surrounded-regions/README.md index 31e7f3500..46f86f00e 100644 --- a/problems/surrounded-regions/README.md +++ b/problems/surrounded-regions/README.md @@ -11,7 +11,7 @@ ## [130. Surrounded Regions (Medium)](https://leetcode.com/problems/surrounded-regions "被围绕的区域") -

    Given an m x n matrix board containing 'X' and 'O', capture all regions surrounded by 'X'.

    +

    Given an m x n matrix board containing 'X' and 'O', capture all regions that are 4-directionally surrounded by 'X'.

    A region is captured by flipping all 'O's into 'X's in that surrounded region.

    diff --git a/problems/synonymous-sentences/README.md b/problems/synonymous-sentences/README.md index ab863fcb1..3bac93e3b 100644 --- a/problems/synonymous-sentences/README.md +++ b/problems/synonymous-sentences/README.md @@ -11,7 +11,33 @@ ## [1258. Synonymous Sentences (Medium)](https://leetcode.com/problems/synonymous-sentences "近义词句子") - +Given a list of pairs of equivalent words synonyms and a sentence text, Return all possible synonymous sentences sorted lexicographically. +

     

    +

    Example 1:

    + +
    +Input:
    +synonyms = [["happy","joy"],["sad","sorrow"],["joy","cheerful"]],
    +text = "I am happy today but was sad yesterday"
    +Output:
    +["I am cheerful today but was sad yesterday",
    +​​​​​​​"I am cheerful today but was sorrow yesterday",
    +"I am happy today but was sad yesterday",
    +"I am happy today but was sorrow yesterday",
    +"I am joy today but was sad yesterday",
    +"I am joy today but was sorrow yesterday"]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= synonyms.length <= 10
    • +
    • synonyms[i].length == 2
    • +
    • synonyms[0] != synonyms[1]
    • +
    • All words consist of at most 10 English letters only.
    • +
    • text is a single space separated sentence of at most 10 words.
    • +
    ### Related Topics [[Union Find](../../tag/union-find/README.md)] diff --git a/problems/team-scores-in-football-tournament/README.md b/problems/team-scores-in-football-tournament/README.md index c21414e96..a177899e6 100644 --- a/problems/team-scores-in-football-tournament/README.md +++ b/problems/team-scores-in-football-tournament/README.md @@ -11,7 +11,83 @@ ## [1212. Team Scores in Football Tournament (Medium)](https://leetcode.com/problems/team-scores-in-football-tournament "查询球队积分") +

    Table: Teams

    +
    ++---------------+----------+
    +| Column Name   | Type     |
    ++---------------+----------+
    +| team_id       | int      |
    +| team_name     | varchar  |
    ++---------------+----------+
    +team_id is the primary key of this table.
    +Each row of this table represents a single football team.
    +
    + +

    Table: Matches

    + +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| match_id      | int     |
    +| host_team     | int     |
    +| guest_team    | int     | 
    +| host_goals    | int     |
    +| guest_goals   | int     |
    ++---------------+---------+
    +match_id is the primary key of this table.
    +Each row is a record of a finished match between two different teams. 
    +Teams host_team and guest_team are represented by their IDs in the teams table (team_id) and they scored host_goals and guest_goals goals respectively.
    +
    + +

     

    +You would like to compute the scores of all teams after all matches. Points are awarded as follows: + +
      +
    • A team receives three points if they win a match (Score strictly more goals than the opponent team).
    • +
    • A team receives one point if they draw a match (Same number of goals as the opponent team).
    • +
    • A team receives no points if they lose a match (Score less goals than the opponent team).
    • +
    + +

    Write an SQL query that selects the team_id, team_name and num_points of each team in the tournament after all described matches. Result table should be ordered by num_points (decreasing order). In case of a tie, order the records by team_id (increasing order).

    + +

    The query result format is in the following example:

    + +
    +Teams table:
    ++-----------+--------------+
    +| team_id   | team_name    |
    ++-----------+--------------+
    +| 10        | Leetcode FC  |
    +| 20        | NewYork FC   |
    +| 30        | Atlanta FC   |
    +| 40        | Chicago FC   |
    +| 50        | Toronto FC   |
    ++-----------+--------------+
    +
    +Matches table:
    ++------------+--------------+---------------+-------------+--------------+
    +| match_id   | host_team    | guest_team    | host_goals  | guest_goals  |
    ++------------+--------------+---------------+-------------+--------------+
    +| 1          | 10           | 20            | 3           | 0            |
    +| 2          | 30           | 10            | 2           | 2            |
    +| 3          | 10           | 50            | 5           | 1            |
    +| 4          | 20           | 30            | 1           | 0            |
    +| 5          | 50           | 30            | 1           | 0            |
    ++------------+--------------+---------------+-------------+--------------+
    +
    +Result table:
    ++------------+--------------+---------------+
    +| team_id    | team_name    | num_points    |
    ++------------+--------------+---------------+
    +| 10         | Leetcode FC  | 7             |
    +| 20         | NewYork FC   | 3             |
    +| 50         | Toronto FC   | 3             |
    +| 30         | Atlanta FC   | 1             |
    +| 40         | Chicago FC   | 0             |
    ++------------+--------------+---------------+
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/ternary-expression-parser/README.md b/problems/ternary-expression-parser/README.md index e1706988a..cee11673f 100644 --- a/problems/ternary-expression-parser/README.md +++ b/problems/ternary-expression-parser/README.md @@ -11,7 +11,58 @@ ## [439. Ternary Expression Parser (Medium)](https://leetcode.com/problems/ternary-expression-parser "三元表达式解析器") +

    Given a string representing arbitrarily nested ternary expressions, calculate the result of the expression. You can always assume that the given expression is valid and only consists of digits 0-9, ?, :, T and F (T and F represent True and False respectively). +

    Note: +

      +
    1. The length of the given string is ≤ 10000.
    2. +
    3. Each number will contain only one digit.
    4. +
    5. The conditional expressions group right-to-left (as usual in most languages).
    6. +
    7. The condition will always be either T or F. That is, the condition will never be a digit.
    8. +
    9. The result of the expression will always evaluate to either a digit 0-9, T or F.
    10. +
    +

    + +

    +Example 1: +

    +Input: "T?2:3"
    +
    +Output: "2"
    +
    +Explanation: If true, then result is 2; otherwise result is 3.
    +
    +

    + +

    +Example 2: +

    +Input: "F?1:T?4:5"
    +
    +Output: "4"
    +
    +Explanation: The conditional expressions group right-to-left. Using parenthesis, it is read/evaluated as:
    +
    +             "(F ? 1 : (T ? 4 : 5))"                   "(F ? 1 : (T ? 4 : 5))"
    +          -> "(F ? 1 : 4)"                 or       -> "(T ? 4 : 5)"
    +          -> "4"                                    -> "4"
    +
    +

    + +

    +Example 3: +

    +Input: "T?T?F:5:3"
    +
    +Output: "F"
    +
    +Explanation: The conditional expressions group right-to-left. Using parenthesis, it is read/evaluated as:
    +
    +             "(T ? (T ? F : 5) : 3)"                   "(T ? (T ? F : 5) : 3)"
    +          -> "(T ? F : 3)"                 or       -> "(T ? F : 5)"
    +          -> "F"                                    -> "F"
    +
    +

    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/text-justification/README.md b/problems/text-justification/README.md index 775a3c692..be21671e2 100644 --- a/problems/text-justification/README.md +++ b/problems/text-justification/README.md @@ -11,20 +11,20 @@ ## [68. Text Justification (Hard)](https://leetcode.com/problems/text-justification "文本左右对齐") -

    Given an array of words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified.

    +

    Given an array of strings words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified.

    -

    You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces ' ' when necessary so that each line has exactly maxWidth characters.

    +

    You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces ' ' when necessary so that each line has exactly maxWidth characters.

    -

    Extra spaces between words should be distributed as evenly as possible. If the number of spaces on a line do not divide evenly between words, the empty slots on the left will be assigned more spaces than the slots on the right.

    +

    Extra spaces between words should be distributed as evenly as possible. If the number of spaces on a line does not divide evenly between words, the empty slots on the left will be assigned more spaces than the slots on the right.

    -

    For the last line of text, it should be left justified and no extra space is inserted between words.

    +

    For the last line of text, it should be left-justified and no extra space is inserted between words.

    Note:

      -
    • A word is defined as a character sequence consisting of non-space characters only.
    • -
    • Each word's length is guaranteed to be greater than 0 and not exceed maxWidth.
    • -
    • The input array words contains at least one word.
    • +
    • A word is defined as a character sequence consisting of non-space characters only.
    • +
    • Each word's length is guaranteed to be greater than 0 and not exceed maxWidth.
    • +
    • The input array words contains at least one word.

     

    diff --git a/problems/the-earliest-moment-when-everyone-become-friends/README.md b/problems/the-earliest-moment-when-everyone-become-friends/README.md index 25a50004f..c9fbad8c2 100644 --- a/problems/the-earliest-moment-when-everyone-become-friends/README.md +++ b/problems/the-earliest-moment-when-everyone-become-friends/README.md @@ -11,7 +11,45 @@ ## [1101. The Earliest Moment When Everyone Become Friends (Medium)](https://leetcode.com/problems/the-earliest-moment-when-everyone-become-friends "彼此熟识的最早时间") +

    In a social group, there are N people, with unique integer ids from 0 to N-1.

    +

    We have a list of logs, where each logs[i] = [timestamp, id_A, id_B] contains a non-negative integer timestamp, and the ids of two different people.

    + +

    Each log represents the time in which two different people became friends.  Friendship is symmetric: if A is friends with B, then B is friends with A.

    + +

    Let's say that person A is acquainted with person B if A is friends with B, or A is a friend of someone acquainted with B.

    + +

    Return the earliest time for which every person became acquainted with every other person. Return -1 if there is no such earliest time.

    + +

     

    + +

    Example 1:

    + +
    +Input: logs = [[20190101,0,1],[20190104,3,4],[20190107,2,3],[20190211,1,5],[20190224,2,4],[20190301,0,3],[20190312,1,2],[20190322,4,5]], N = 6
    +Output: 20190301
    +Explanation: 
    +The first event occurs at timestamp = 20190101 and after 0 and 1 become friends we have the following friendship groups [0,1], [2], [3], [4], [5].
    +The second event occurs at timestamp = 20190104 and after 3 and 4 become friends we have the following friendship groups [0,1], [2], [3,4], [5].
    +The third event occurs at timestamp = 20190107 and after 2 and 3 become friends we have the following friendship groups [0,1], [2,3,4], [5].
    +The fourth event occurs at timestamp = 20190211 and after 1 and 5 become friends we have the following friendship groups [0,1,5], [2,3,4].
    +The fifth event occurs at timestamp = 20190224 and as 2 and 4 are already friend anything happens.
    +The sixth event occurs at timestamp = 20190301 and after 0 and 3 become friends we have that all become friends.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= N <= 100
    2. +
    3. 1 <= logs.length <= 10^4
    4. +
    5. 0 <= logs[i][0] <= 10^9
    6. +
    7. 0 <= logs[i][1], logs[i][2] <= N - 1
    8. +
    9. It's guaranteed that all timestamps in logs[i][0] are different.
    10. +
    11. Logs are not necessarily ordered by some criteria.
    12. +
    13. logs[i][1] != logs[i][2]
    14. +
    ### Related Topics [[Union Find](../../tag/union-find/README.md)] diff --git a/problems/the-maze-ii/README.md b/problems/the-maze-ii/README.md index 79d9ed0f7..d3fabd523 100644 --- a/problems/the-maze-ii/README.md +++ b/problems/the-maze-ii/README.md @@ -11,7 +11,63 @@ ## [505. The Maze II (Medium)](https://leetcode.com/problems/the-maze-ii "迷宫 II") +

    There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up, down, left or right, but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction.

    +

    Given the ball's start position, the destination and the maze, find the shortest distance for the ball to stop at the destination. The distance is defined by the number of empty spaces traveled by the ball from the start position (excluded) to the destination (included). If the ball cannot stop at the destination, return -1.

    + +

    The maze is represented by a binary 2D array. 1 means the wall and 0 means the empty space. You may assume that the borders of the maze are all walls. The start and destination coordinates are represented by row and column indexes.

    + +

     

    + +

    Example 1:

    + +
    Input 1: a maze represented by a 2D array
    +
    +0 0 1 0 0
    +0 0 0 0 0
    +0 0 0 1 0
    +1 1 0 1 1
    +0 0 0 0 0
    +
    +Input 2: start coordinate (rowStart, colStart) = (0, 4)
    +Input 3: destination coordinate (rowDest, colDest) = (4, 4)
    +
    +Output: 12
    +
    +Explanation: One shortest way is : left -> down -> left -> down -> right -> down -> right.
    +             The total distance is 1 + 1 + 3 + 1 + 2 + 2 + 2 = 12.
    +
    +
    + +

    Example 2:

    + +
    Input 1: a maze represented by a 2D array
    +
    +0 0 1 0 0
    +0 0 0 0 0
    +0 0 0 1 0
    +1 1 0 1 1
    +0 0 0 0 0
    +
    +Input 2: start coordinate (rowStart, colStart) = (0, 4)
    +Input 3: destination coordinate (rowDest, colDest) = (3, 2)
    +
    +Output: -1
    +
    +Explanation: There is no way for the ball to stop at the destination.
    +
    +
    + +

     

    + +

    Note:

    + +
      +
    1. There is only one ball and one destination in the maze.
    2. +
    3. Both the ball and the destination exist on an empty space, and they will not be at the same position initially.
    4. +
    5. The given maze does not contain border (like the red rectangle in the example pictures), but you could assume the border of the maze are all walls.
    6. +
    7. The maze contains at least 2 empty spaces, and both the width and height of the maze won't exceed 100.
    8. +
    ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/the-maze-iii/README.md b/problems/the-maze-iii/README.md index 3cedf2c18..859b10015 100644 --- a/problems/the-maze-iii/README.md +++ b/problems/the-maze-iii/README.md @@ -11,7 +11,67 @@ ## [499. The Maze III (Hard)](https://leetcode.com/problems/the-maze-iii "迷宫 III") +

    There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up (u), down (d), left (l) or right (r), but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction. There is also a hole in this maze. The ball will drop into the hole if it rolls on to the hole.

    +

    Given the ball position, the hole position and the maze, find out how the ball could drop into the hole by moving the shortest distance. The distance is defined by the number of empty spaces traveled by the ball from the start position (excluded) to the hole (included). Output the moving directions by using 'u', 'd', 'l' and 'r'. Since there could be several different shortest ways, you should output the lexicographically smallest way. If the ball cannot reach the hole, output "impossible".

    + +

    The maze is represented by a binary 2D array. 1 means the wall and 0 means the empty space. You may assume that the borders of the maze are all walls. The ball and the hole coordinates are represented by row and column indexes.

    + +

     

    + +

    Example 1:

    + +
    +Input 1: a maze represented by a 2D array
    +
    +0 0 0 0 0
    +1 1 0 0 1
    +0 0 0 0 0
    +0 1 0 0 1
    +0 1 0 0 0
    +
    +Input 2: ball coordinate (rowBall, colBall) = (4, 3)
    +Input 3: hole coordinate (rowHole, colHole) = (0, 1)
    +
    +Output: "lul"
    +
    +Explanation: There are two shortest ways for the ball to drop into the hole.
    +The first way is left -> up -> left, represented by "lul".
    +The second way is up -> left, represented by 'ul'.
    +Both ways have shortest distance 6, but the first way is lexicographically smaller because 'l' < 'u'. So the output is "lul".
    +
    +
    + +

    Example 2:

    + +
    +Input 1: a maze represented by a 2D array
    +
    +0 0 0 0 0
    +1 1 0 0 1
    +0 0 0 0 0
    +0 1 0 0 1
    +0 1 0 0 0
    +
    +Input 2: ball coordinate (rowBall, colBall) = (4, 3)
    +Input 3: hole coordinate (rowHole, colHole) = (3, 0)
    +
    +Output: "impossible"
    +
    +Explanation: The ball cannot reach the hole.
    +
    +
    + +

     

    + +

    Note:

    + +
      +
    1. There is only one ball and one hole in the maze.
    2. +
    3. Both the ball and hole exist on an empty space, and they will not be at the same position initially.
    4. +
    5. The given maze does not contain border (like the red rectangle in the example pictures), but you could assume the border of the maze are all walls.
    6. +
    7. The maze contains at least 2 empty spaces, and the width and the height of the maze won't exceed 30.
    8. +
    ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/the-maze/README.md b/problems/the-maze/README.md index 0b56c410d..3f2eed321 100644 --- a/problems/the-maze/README.md +++ b/problems/the-maze/README.md @@ -11,7 +11,62 @@ ## [490. The Maze (Medium)](https://leetcode.com/problems/the-maze "迷宫") +

    There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up, down, left or right, but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction.

    +

    Given the ball's start position, the destination and the maze, determine whether the ball could stop at the destination.

    + +

    The maze is represented by a binary 2D array. 1 means the wall and 0 means the empty space. You may assume that the borders of the maze are all walls. The start and destination coordinates are represented by row and column indexes.

    + +

     

    + +

    Example 1:

    + +
    Input 1: a maze represented by a 2D array
    +
    +0 0 1 0 0
    +0 0 0 0 0
    +0 0 0 1 0
    +1 1 0 1 1
    +0 0 0 0 0
    +
    +Input 2: start coordinate (rowStart, colStart) = (0, 4)
    +Input 3: destination coordinate (rowDest, colDest) = (4, 4)
    +
    +Output: true
    +
    +Explanation: One possible way is : left -> down -> left -> down -> right -> down -> right.
    +
    +
    + +

    Example 2:

    + +
    Input 1: a maze represented by a 2D array
    +
    +0 0 1 0 0
    +0 0 0 0 0
    +0 0 0 1 0
    +1 1 0 1 1
    +0 0 0 0 0
    +
    +Input 2: start coordinate (rowStart, colStart) = (0, 4)
    +Input 3: destination coordinate (rowDest, colDest) = (3, 2)
    +
    +Output: false
    +
    +Explanation: There is no way for the ball to stop at the destination.
    +
    +
    + +

     

    + +

    Note:

    + +
      +
    1. There is only one ball and one destination in the maze.
    2. +
    3. Both the ball and the destination exist on an empty space, and they will not be at the same position initially.
    4. +
    5. The given maze does not contain border (like the red rectangle in the example pictures), but you could assume the border of the maze are all walls.
    6. +
    7. The maze contains at least 2 empty spaces, and both the width and height of the maze won't exceed 100.
    8. +
    ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/the-number-of-the-smallest-unoccupied-chair/README.md b/problems/the-number-of-the-smallest-unoccupied-chair/README.md new file mode 100644 index 000000000..e19e8b297 --- /dev/null +++ b/problems/the-number-of-the-smallest-unoccupied-chair/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../check-if-all-characters-have-equal-number-of-occurrences "Check if All Characters Have Equal Number of Occurrences") +                 +[Next >](../describe-the-painting "Describe the Painting") + +## [1942. The Number of the Smallest Unoccupied Chair (Medium)](https://leetcode.com/problems/the-number-of-the-smallest-unoccupied-chair "最小未被占据椅子的编号") + +

    There is a party where n friends numbered from 0 to n - 1 are attending. There is an infinite number of chairs in this party that are numbered from 0 to infinity. When a friend arrives at the party, they sit on the unoccupied chair with the smallest number.

    + +
      +
    • For example, if chairs 0, 1, and 5 are occupied when a friend comes, they will sit on chair number 2.
    • +
    + +

    When a friend leaves the party, their chair becomes unoccupied at the moment they leave. If another friend arrives at that same moment, they can sit in that chair.

    + +

    You are given a 0-indexed 2D integer array times where times[i] = [arrivali, leavingi], indicating the arrival and leaving times of the ith friend respectively, and an integer targetFriend. All arrival times are distinct.

    + +

    Return the chair number that the friend numbered targetFriend will sit on.

    + +

     

    +

    Example 1:

    + +
    +Input: times = [[1,4],[2,3],[4,6]], targetFriend = 1
    +Output: 1
    +Explanation: 
    +- Friend 0 arrives at time 1 and sits on chair 0.
    +- Friend 1 arrives at time 2 and sits on chair 1.
    +- Friend 1 leaves at time 3 and chair 1 becomes empty.
    +- Friend 0 leaves at time 4 and chair 0 becomes empty.
    +- Friend 2 arrives at time 4 and sits on chair 0.
    +Since friend 1 sat on chair 1, we return 1.
    +
    + +

    Example 2:

    + +
    +Input: times = [[3,10],[1,5],[2,6]], targetFriend = 0
    +Output: 2
    +Explanation: 
    +- Friend 1 arrives at time 1 and sits on chair 0.
    +- Friend 2 arrives at time 2 and sits on chair 1.
    +- Friend 0 arrives at time 3 and sits on chair 2.
    +- Friend 1 leaves at time 5 and chair 0 becomes empty.
    +- Friend 2 leaves at time 6 and chair 1 becomes empty.
    +- Friend 0 leaves at time 10 and chair 2 becomes empty.
    +Since friend 0 sat on chair 2, we return 2.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == times.length
    • +
    • 2 <= n <= 104
    • +
    • times[i].length == 2
    • +
    • 1 <= arrivali < leavingi <= 105
    • +
    • 0 <= targetFriend <= n - 1
    • +
    • Each arrivali time is distinct.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +Sort times by arrival time. +
    + +
    +Hint 2 +for each arrival_i find the smallest unoccupied chair and mark it as occupied until leaving_i. +
    diff --git a/problems/three-divisors/README.md b/problems/three-divisors/README.md new file mode 100644 index 000000000..ad9fb6194 --- /dev/null +++ b/problems/three-divisors/README.md @@ -0,0 +1,51 @@ + + + + + + + +[< Previous](../all-the-pairs-with-the-maximum-number-of-common-followers "All the Pairs With the Maximum Number of Common Followers") +                 +[Next >](../maximum-number-of-weeks-for-which-you-can-work "Maximum Number of Weeks for Which You Can Work") + +## [1952. Three Divisors (Easy)](https://leetcode.com/problems/three-divisors "三除数") + +

    Given an integer n, return true if n has exactly three positive divisors. Otherwise, return false.

    + +

    An integer m is a divisor of n if there exists an integer k such that n = k * m.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 2
    +Output: false
    +Explantion: 2 has only two divisors: 1 and 2.
    +
    + +

    Example 2:

    + +
    +Input: n = 4
    +Output: true
    +Explantion: 4 has three divisors: 1, 2, and 4.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 104
    • +
    + +### Hints +
    +Hint 1 +You can count the number of divisors and just check that they are 3 +
    + +
    +Hint 2 +Beware of the case of n equal 1 as some solutions might fail in it +
    diff --git a/problems/top-travellers/README.md b/problems/top-travellers/README.md index bd370a2a9..a0727269f 100644 --- a/problems/top-travellers/README.md +++ b/problems/top-travellers/README.md @@ -11,7 +11,81 @@ ## [1407. Top Travellers (Easy)](https://leetcode.com/problems/top-travellers "排名靠前的旅行者") +

    Table: Users

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| id            | int     |
    +| name          | varchar |
    ++---------------+---------+
    +id is the primary key for this table.
    +name is the name of the user.
    +
    + +

    Table: Rides

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| id            | int     |
    +| user_id       | int     |
    +| distance      | int     |
    ++---------------+---------+
    +id is the primary key for this table.
    +city_id is the id of the city who bought the product "product_name".
    +
    + +Write an SQL query to report the distance travelled by each user. +Return the result table ordered by travelled_distance in descending order, if two or more users travelled the same distance, order them by their name in ascending order. + +The query result format is in the following example. +
    +Users table:
    ++------+-----------+
    +| id   | name      |
    ++------+-----------+
    +| 1    | Alice     |
    +| 2    | Bob       |
    +| 3    | Alex      |
    +| 4    | Donald    |
    +| 7    | Lee       |
    +| 13   | Jonathan  |
    +| 19   | Elvis     |
    ++------+-----------+
    +
    +Rides table:
    ++------+----------+----------+
    +| id   | user_id  | distance |
    ++------+----------+----------+
    +| 1    | 1        | 120      |
    +| 2    | 2        | 317      |
    +| 3    | 3        | 222      |
    +| 4    | 7        | 100      |
    +| 5    | 13       | 312      |
    +| 6    | 19       | 50       |
    +| 7    | 7        | 120      |
    +| 8    | 19       | 400      |
    +| 9    | 7        | 230      |
    ++------+----------+----------+
    +
    +Result table:
    ++----------+--------------------+
    +| name     | travelled_distance |
    ++----------+--------------------+
    +| Elvis    | 450                |
    +| Lee      | 450                |
    +| Bob      | 317                |
    +| Jonathan | 312                |
    +| Alex     | 222                |
    +| Alice    | 120                |
    +| Donald   | 0                  |
    ++----------+--------------------+
    +Elvis and Lee travelled 450 miles, Elvis is the top traveller as his name is alphabetically smaller than Lee.
    +Bob, Jonathan, Alex and Alice have only one ride and we just order them by the total distances of the ride.
    +Donald didn't have any rides, the distance travelled by him is 0.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/toss-strange-coins/README.md b/problems/toss-strange-coins/README.md index 1def74644..6cbfe92fc 100644 --- a/problems/toss-strange-coins/README.md +++ b/problems/toss-strange-coins/README.md @@ -11,7 +11,27 @@ ## [1230. Toss Strange Coins (Medium)](https://leetcode.com/problems/toss-strange-coins "抛掷硬币") - +

    You have some coins.  The i-th coin has a probability prob[i] of facing heads when tossed.

    + +

    Return the probability that the number of coins facing heads equals target if you toss every coin exactly once.

    + +

     

    +

    Example 1:

    +
    Input: prob = [0.4], target = 1
    +Output: 0.40000
    +

    Example 2:

    +
    Input: prob = [0.5,0.5,0.5,0.5,0.5], target = 0
    +Output: 0.03125
    +
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= prob.length <= 1000
    • +
    • 0 <= prob[i] <= 1
    • +
    • 0 <= target <= prob.length
    • +
    • Answers will be accepted as correct if they are within 10^-5 of the correct answer.
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/total-hamming-distance/README.md b/problems/total-hamming-distance/README.md index 10ba9cf7d..8f56b545d 100644 --- a/problems/total-hamming-distance/README.md +++ b/problems/total-hamming-distance/README.md @@ -38,8 +38,9 @@ HammingDistance(4, 14) + HammingDistance(4, 2) + HammingDistance(14, 2) = 2 + 2

    Constraints:

      -
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums.length <= 104
    • 0 <= nums[i] <= 109
    • +
    • The answer for the given input will fit in a 32-bit integer.
    ### Related Topics diff --git a/problems/total-sales-amount-by-year/README.md b/problems/total-sales-amount-by-year/README.md index 67ca7eee6..7a27cc853 100644 --- a/problems/total-sales-amount-by-year/README.md +++ b/problems/total-sales-amount-by-year/README.md @@ -11,7 +11,73 @@ ## [1384. Total Sales Amount by Year (Hard)](https://leetcode.com/problems/total-sales-amount-by-year "按年度列出销售总额") +

    Table: Product

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| product_id    | int     |
    +| product_name  | varchar |
    ++---------------+---------+
    +product_id is the primary key for this table.
    +product_name is the name of the product.
    +
    + +

    Table: Sales

    +
    ++---------------------+---------+
    +| Column Name         | Type    |
    ++---------------------+---------+
    +| product_id          | int     |
    +| period_start        | varchar |
    +| period_end          | date    |
    +| average_daily_sales | int     |
    ++---------------------+---------+
    +product_id is the primary key for this table. 
    +period_start and period_end indicates the start and end date for sales period, both dates are inclusive.
    +The average_daily_sales column holds the average daily sales amount of the items for the period.
    +
    +Write an SQL query to report the Total sales amount of each item for each year, with corresponding product name, product_id, product_name and report_year. + +Dates of the sales years are between 2018 to 2020. Return the result table ordered by product_id and report_year. + +The query result format is in the following example: + +
    +Product table:
    ++------------+--------------+
    +| product_id | product_name |
    ++------------+--------------+
    +| 1          | LC Phone     |
    +| 2          | LC T-Shirt   |
    +| 3          | LC Keychain  |
    ++------------+--------------+
    +
    +Sales table:
    ++------------+--------------+-------------+---------------------+
    +| product_id | period_start | period_end  | average_daily_sales |
    ++------------+--------------+-------------+---------------------+
    +| 1          | 2019-01-25   | 2019-02-28  | 100                 |
    +| 2          | 2018-12-01   | 2020-01-01  | 10                  |
    +| 3          | 2019-12-01   | 2020-01-31  | 1                   |
    ++------------+--------------+-------------+---------------------+
    +
    +Result table:
    ++------------+--------------+-------------+--------------+
    +| product_id | product_name | report_year | total_amount |
    ++------------+--------------+-------------+--------------+
    +| 1          | LC Phone     |    2019     | 3500         |
    +| 2          | LC T-Shirt   |    2018     | 310          |
    +| 2          | LC T-Shirt   |    2019     | 3650         |
    +| 2          | LC T-Shirt   |    2020     | 10           |
    +| 3          | LC Keychain  |    2019     | 31           |
    +| 3          | LC Keychain  |    2020     | 31           |
    ++------------+--------------+-------------+--------------+
    +LC Phone was sold for the period of 2019-01-25 to 2019-02-28, and there are 35 days for this period. Total amount 35*100 = 3500. 
    +LC T-shirt was sold for the period of 2018-12-01 to 2020-01-01, and there are 31, 365, 1 days for years 2018, 2019 and 2020 respectively.
    +LC Keychain was sold for the period of 2019-12-01 to 2020-01-31, and there are 31, 31 days for years 2019 and 2020 respectively.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/tournament-winners/README.md b/problems/tournament-winners/README.md index d41452330..717780007 100644 --- a/problems/tournament-winners/README.md +++ b/problems/tournament-winners/README.md @@ -11,7 +11,81 @@ ## [1194. Tournament Winners (Hard)](https://leetcode.com/problems/tournament-winners "锦标赛优胜者") +

    Table: Players

    +
    ++-------------+-------+
    +| Column Name | Type  |
    ++-------------+-------+
    +| player_id   | int   |
    +| group_id    | int   |
    ++-------------+-------+
    +player_id is the primary key of this table.
    +Each row of this table indicates the group of each player.
    +
    + +

    Table: Matches

    + +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| match_id      | int     |
    +| first_player  | int     |
    +| second_player | int     | 
    +| first_score   | int     |
    +| second_score  | int     |
    ++---------------+---------+
    +match_id is the primary key of this table.
    +Each row is a record of a match, first_player and second_player contain the player_id of each match.
    +first_score and second_score contain the number of points of the first_player and second_player respectively.
    +You may assume that, in each match, players belongs to the same group.
    +
    + +

     

    + +

    The winner in each group is the player who scored the maximum total points within the group. In the case of a tie, the lowest player_id wins.

    + +

    Write an SQL query to find the winner in each group.

    + +

    The query result format is in the following example:

    + +
    +Players table:
    ++-----------+------------+
    +| player_id | group_id   |
    ++-----------+------------+
    +| 15        | 1          |
    +| 25        | 1          |
    +| 30        | 1          |
    +| 45        | 1          |
    +| 10        | 2          |
    +| 35        | 2          |
    +| 50        | 2          |
    +| 20        | 3          |
    +| 40        | 3          |
    ++-----------+------------+
    +
    +Matches table:
    ++------------+--------------+---------------+-------------+--------------+
    +| match_id   | first_player | second_player | first_score | second_score |
    ++------------+--------------+---------------+-------------+--------------+
    +| 1          | 15           | 45            | 3           | 0            |
    +| 2          | 30           | 25            | 1           | 2            |
    +| 3          | 30           | 15            | 2           | 0            |
    +| 4          | 40           | 20            | 5           | 2            |
    +| 5          | 35           | 50            | 1           | 1            |
    ++------------+--------------+---------------+-------------+--------------+
    +
    +Result table:
    ++-----------+------------+
    +| group_id  | player_id  |
    ++-----------+------------+ 
    +| 1         | 15         |
    +| 2         | 35         |
    +| 3         | 40         |
    ++-----------+------------+
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/traffic-light-controlled-intersection/README.md b/problems/traffic-light-controlled-intersection/README.md index 3ceebb3e1..6c358b949 100644 --- a/problems/traffic-light-controlled-intersection/README.md +++ b/problems/traffic-light-controlled-intersection/README.md @@ -11,7 +11,66 @@ ## [1279. Traffic Light Controlled Intersection (Easy)](https://leetcode.com/problems/traffic-light-controlled-intersection "红绿灯路口") +There is an intersection of two roads. First road is road A where cars travel from North to South in direction 1 and from South to North in direction 2. Second road is road B where cars travel from West to East in direction 3 and from East to West in direction 4. +There is a traffic light located on each road before the intersection. A traffic light can either be green or red. + +1. Green means cars can cross the intersection in both directions of the road. +- Red means cars in both directions cannot cross the intersection and must wait until the light turns green. + +The traffic lights cannot be green on both roads at the same time. That means when the light is green on road A, it is red on road B and when the light is green on road B, it is red on road A. + +Initially, the traffic light is green on road A and red on road B. When the light is green on one road, all cars can cross the intersection in both directions until the light becomes green on the other road. No two cars traveling on different roads should cross at the same time. + +Design a deadlock-free traffic light controlled system at this intersection. + +Implement the function void carArrived(carId, roadId, direction, turnGreen, crossCar) where: + +- carId is the id of the car that arrived. +- roadId is the id of the road that the car travels on. +- direction is the direction of the car. +- turnGreen is a function you can call to turn the traffic light to green on the current road. +- crossCar is a function you can call to let the current car cross the intersection. + +Your answer is considered correct if it avoids cars deadlock in the intersection. Turning the light green on a road when it was already green is considered a wrong answer. + +

    Example 1:

    +
    +Input: cars = [1,3,5,2,4], directions = [2,1,2,4,3], arrivalTimes = [10,20,30,40,50]
    +Output: [
    +"Car 1 Has Passed Road A In Direction 2",    // Traffic light on road A is green, car 1 can cross the intersection.
    +"Car 3 Has Passed Road A In Direction 1",    // Car 3 crosses the intersection as the light is still green.
    +"Car 5 Has Passed Road A In Direction 2",    // Car 5 crosses the intersection as the light is still green.
    +"Traffic Light On Road B Is Green",          // Car 2 requests green light for road B.
    +"Car 2 Has Passed Road B In Direction 4",    // Car 2 crosses as the light is green on road B now.
    +"Car 4 Has Passed Road B In Direction 3"     // Car 4 crosses the intersection as the light is still green.
    +]
    +
    + +

    Example 2:

    +
    +Input: cars = [1,2,3,4,5], directions = [2,4,3,3,1], arrivalTimes = [10,20,30,40,40]
    +Output: [
    +"Car 1 Has Passed Road A In Direction 2",    // Traffic light on road A is green, car 1 can cross the intersection.
    +"Traffic Light On Road B Is Green",          // Car 2 requests green light for road B.
    +"Car 2 Has Passed Road B In Direction 4",    // Car 2 crosses as the light is green on road B now.
    +"Car 3 Has Passed Road B In Direction 3",    // Car 3 crosses as the light is green on road B now.
    +"Traffic Light On Road A Is Green",          // Car 5 requests green light for road A.
    +"Car 5 Has Passed Road A In Direction 1",    // Car 5 crosses as the light is green on road A now.
    +"Traffic Light On Road B Is Green",          // Car 4 requests green light for road B. Car 4 blocked until car 5 crosses and then traffic light is green on road B.
    +"Car 4 Has Passed Road B In Direction 3"     // Car 4 crosses as the light is green on road B now.
    +]
    +Explanation: This is a dead-lock free scenario. Note that the scenario when car 4 crosses before turning light into green on road A and allowing car 5 to pass is also correct and Accepted scenario.
    +
    + +Constraints: + +- 1 <= cars.length <= 20 +- cars.length = directions.length +- cars.length = arrivalTimes.length +- All values of cars are unique +- 1 <= directions[i] <= 4 +- arrivalTimes is non-decreasing ### Related Topics [[Concurrency](../../tag/concurrency/README.md)] diff --git a/problems/tree-diameter/README.md b/problems/tree-diameter/README.md index d927e855f..05ef3b089 100644 --- a/problems/tree-diameter/README.md +++ b/problems/tree-diameter/README.md @@ -11,7 +11,42 @@ ## [1245. Tree Diameter (Medium)](https://leetcode.com/problems/tree-diameter "树的直径") +

    Given an undirected tree, return its diameter: the number of edges in a longest path in that tree.

    +

    The tree is given as an array of edges where edges[i] = [u, v] is a bidirectional edge between nodes u and v.  Each node has labels in the set {0, 1, ..., edges.length}.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input: edges = [[0,1],[0,2]]
    +Output: 2
    +Explanation: 
    +A longest path of the tree is the path 1 - 0 - 2.
    +
    + +

    Example 2:

    + +

    + +
    +Input: edges = [[0,1],[1,2],[2,3],[1,4],[4,5]]
    +Output: 4
    +Explanation: 
    +A longest path of the tree is the path 3 - 2 - 1 - 4 - 5.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= edges.length < 10^4
    • +
    • edges[i][0] != edges[i][1]
    • +
    • 0 <= edges[i][j] <= edges.length
    • +
    • The given edges form an undirected tree.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/tree-node/README.md b/problems/tree-node/README.md index b0d94d495..bc70c3fcd 100644 --- a/problems/tree-node/README.md +++ b/problems/tree-node/README.md @@ -11,7 +11,68 @@ ## [608. Tree Node (Medium)](https://leetcode.com/problems/tree-node "树节点") +

    Given a table tree, id is identifier of the tree node and p_id is its parent node's id.

    +
    ++----+------+
    +| id | p_id |
    ++----+------+
    +| 1  | null |
    +| 2  | 1    |
    +| 3  | 1    |
    +| 4  | 2    |
    +| 5  | 2    |
    ++----+------+
    +
    +Each node in the tree can be one of three types: + +
      +
    • Leaf: if the node is a leaf node.
    • +
    • Root: if the node is the root of the tree.
    • +
    • Inner: If the node is neither a leaf node nor a root node.
    • +
    + +

     

    +Write a query to print the node id and the type of the node. Sort your output by the node id. The result for the above sample is: + +

     

    + +
    ++----+------+
    +| id | Type |
    ++----+------+
    +| 1  | Root |
    +| 2  | Inner|
    +| 3  | Leaf |
    +| 4  | Leaf |
    +| 5  | Leaf |
    ++----+------+
    +
    + +

     

    + +

    Explanation

    + +

     

    + +
      +
    • Node '1' is root node, because its parent node is NULL and it has child node '2' and '3'.
    • +
    • Node '2' is inner node, because it has parent node '1' and child node '4' and '5'.
    • +
    • Node '3', '4' and '5' is Leaf node, because they have parent node and they don't have child node.
    • +
      +
    • And here is the image of the sample tree as below: +

       

      +
      +			  1
      +			/   \
      +                      2       3
      +                    /   \
      +                  4       5
      +
      +

      Note

      +

      If there is only one node on the tree, you only need to output its root attributes.

      +
    • +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/triangle-judgement/README.md b/problems/triangle-judgement/README.md index 38b9fa8fc..e1ddb081d 100644 --- a/problems/triangle-judgement/README.md +++ b/problems/triangle-judgement/README.md @@ -11,7 +11,29 @@ ## [610. Triangle Judgement (Easy)](https://leetcode.com/problems/triangle-judgement "判断三角形") +A pupil Tim gets homework to identify whether three line segments could possibly form a triangle. +

     

    +However, this assignment is very heavy because there are hundreds of records to calculate. +

     

    +Could you help Tim by writing a query to judge whether these three sides can form a triangle, assuming table triangle holds the length of the three sides x, y and z. + +

     

    + +
    +| x  | y  | z  |
    +|----|----|----|
    +| 13 | 15 | 30 |
    +| 10 | 20 | 15 |
    +
    +For the sample data above, your query should return the follow result: + +
    +| x  | y  | z  | triangle |
    +|----|----|----|----------|
    +| 13 | 15 | 30 | No       |
    +| 10 | 20 | 15 | Yes      |
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/two-sum-bsts/README.md b/problems/two-sum-bsts/README.md index a3b009268..a4e10f687 100644 --- a/problems/two-sum-bsts/README.md +++ b/problems/two-sum-bsts/README.md @@ -11,7 +11,38 @@ ## [1214. Two Sum BSTs (Medium)](https://leetcode.com/problems/two-sum-bsts "查找两棵二叉搜索树之和") +

    Given two binary search trees, return True if and only if there is a node in the first tree and a node in the second tree whose values sum up to a given integer target.

    +

     

    + +

    Example 1:

    + +

    + +
    +Input: root1 = [2,1,4], root2 = [1,0,3], target = 5
    +Output: true
    +Explanation: 2 and 3 sum up to 5.
    +
    + +
    +

    Example 2:

    + +

    + +
    +Input: root1 = [0,-10,10], root2 = [5,1,7,0,2], target = 18
    +Output: false
    +
    + +

     

    + +

    Note:

    + +
      +
    1. Each tree has at most 5000 nodes.
    2. +
    3. -10^9 <= target, node.val <= 10^9
    4. +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/two-sum-iii-data-structure-design/README.md b/problems/two-sum-iii-data-structure-design/README.md index c0bf033b3..c212c4fd5 100644 --- a/problems/two-sum-iii-data-structure-design/README.md +++ b/problems/two-sum-iii-data-structure-design/README.md @@ -11,7 +11,25 @@ ## [170. Two Sum III - Data structure design (Easy)](https://leetcode.com/problems/two-sum-iii-data-structure-design "两数之和 III - 数据结构设计") +

    Design and implement a TwoSum class. It should support the following operations: add and find.

    +

    add - Add the number to an internal data structure.
    +find - Find if there exists any pair of numbers which sum is equal to the value.

    + +

    Example 1:

    + +
    +add(1); add(3); add(5);
    +find(4) -> true
    +find(7) -> false
    +
    + +

    Example 2:

    + +
    +add(3); add(1); add(2);
    +find(3) -> true
    +find(6) -> false
    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/two-sum-less-than-k/README.md b/problems/two-sum-less-than-k/README.md index 02e621696..f925185a8 100644 --- a/problems/two-sum-less-than-k/README.md +++ b/problems/two-sum-less-than-k/README.md @@ -11,7 +11,37 @@ ## [1099. Two Sum Less Than K (Easy)](https://leetcode.com/problems/two-sum-less-than-k "小于 K 的两数之和") +

    Given an array A of integers and integer K, return the maximum S such that there exists i < j with A[i] + A[j] = S and S < K. If no i, j exist satisfying this equation, return -1.

    +

     

    + +

    Example 1:

    + +
    +Input: A = [34,23,1,24,75,33,54,8], K = 60
    +Output: 58
    +Explanation: 
    +We can use 34 and 24 to sum 58 which is less than 60.
    +
    + +

    Example 2:

    + +
    +Input: A = [10,20,30], K = 15
    +Output: -1
    +Explanation: 
    +In this case it's not possible to get a pair sum less that 15.
    +
    + +

     

    + +

    Note:

    + +
      +
    1. 1 <= A.length <= 100
    2. +
    3. 1 <= A[i] <= 1000
    4. +
    5. 1 <= K <= 2000
    6. +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/unique-length-3-palindromic-subsequences/README.md b/problems/unique-length-3-palindromic-subsequences/README.md new file mode 100644 index 000000000..8a0332d26 --- /dev/null +++ b/problems/unique-length-3-palindromic-subsequences/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../concatenation-of-array "Concatenation of Array") +                 +[Next >](../painting-a-grid-with-three-different-colors "Painting a Grid With Three Different Colors") + +## [1930. Unique Length-3 Palindromic Subsequences (Medium)](https://leetcode.com/problems/unique-length-3-palindromic-subsequences "长度为 3 的不同回文子序列") + +

    Given a string s, return the number of unique palindromes of length three that are a subsequence of s.

    + +

    Note that even if there are multiple ways to obtain the same subsequence, it is still only counted once.

    + +

    A palindrome is a string that reads the same forwards and backwards.

    + +

    A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.

    + +
      +
    • For example, "ace" is a subsequence of "abcde".
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: s = "aabca"
    +Output: 3
    +Explanation: The 3 palindromic subsequences of length 3 are:
    +- "aba" (subsequence of "aabca")
    +- "aaa" (subsequence of "aabca")
    +- "aca" (subsequence of "aabca")
    +
    + +

    Example 2:

    + +
    +Input: s = "adc"
    +Output: 0
    +Explanation: There are no palindromic subsequences of length 3 in "adc".
    +
    + +

    Example 3:

    + +
    +Input: s = "bbcbaba"
    +Output: 4
    +Explanation: The 4 palindromic subsequences of length 3 are:
    +- "bbb" (subsequence of "bbcbaba")
    +- "bcb" (subsequence of "bbcbaba")
    +- "bab" (subsequence of "bbcbaba")
    +- "aba" (subsequence of "bbcbaba")
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= s.length <= 105
    • +
    • s consists of only lowercase English letters.
    • +
    + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +What is the maximum number of length-3 palindromic strings? +
    + +
    +Hint 2 +How can we keep track of the characters that appeared to the left of a given position? +
    diff --git a/problems/unique-morse-code-words/README.md b/problems/unique-morse-code-words/README.md index 7d9e9758b..0e40378c8 100644 --- a/problems/unique-morse-code-words/README.md +++ b/problems/unique-morse-code-words/README.md @@ -11,37 +11,55 @@ ## [804. Unique Morse Code Words (Easy)](https://leetcode.com/problems/unique-morse-code-words "唯一摩尔斯密码词") -

    International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: "a" maps to ".-", "b" maps to "-...", "c" maps to "-.-.", and so on.

    +

    International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows:

    -

    For convenience, the full table for the 26 letters of the English alphabet is given below:

    +
      +
    • 'a' maps to ".-",
    • +
    • 'b' maps to "-...",
    • +
    • 'c' maps to "-.-.", and so on.
    • +
    + +

    For convenience, the full table for the 26 letters of the English alphabet is given below:

     [".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."]
    -

    Now, given a list of words, each word can be written as a concatenation of the Morse code of each letter. For example, "cab" can be written as "-.-..--...", (which is the concatenation "-.-." + ".-" + "-..."). We'll call such a concatenation, the transformation of a word.

    +

    Given an array of strings words where each word can be written as a concatenation of the Morse code of each letter.

    + +
      +
    • For example, "cab" can be written as "-.-..--...", which is the concatenation of "-.-.", ".-", and "-...". We will call such a concatenation the transformation of a word.
    • +
    + +

    Return the number of different transformations among all words we have.

    -

    Return the number of different transformations among all words we have.

    +

     

    +

    Example 1:

    -Example:
    -Input: words = ["gin", "zen", "gig", "msg"]
    +Input: words = ["gin","zen","gig","msg"]
     Output: 2
    -Explanation: 
    -The transformation of each word is:
    +Explanation: The transformation of each word is:
     "gin" -> "--...-."
     "zen" -> "--...-."
     "gig" -> "--...--."
     "msg" -> "--...--."
    +There are 2 different transformations: "--...-." and "--...--.".
    +
    -There are 2 different transformations, "--...-." and "--...--.". +

    Example 2:

    + +
    +Input: words = ["a"]
    +Output: 1
     
    -

    Note:

    +

     

    +

    Constraints:

      -
    • The length of words will be at most 100.
    • -
    • Each words[i] will have length in range [1, 12].
    • -
    • words[i] will only consist of lowercase letters.
    • +
    • 1 <= words.length <= 100
    • +
    • 1 <= words[i].length <= 12
    • +
    • words[i] consists of lowercase English letters.
    ### Related Topics diff --git a/problems/unique-word-abbreviation/README.md b/problems/unique-word-abbreviation/README.md index 6c43bb1ba..882609e43 100644 --- a/problems/unique-word-abbreviation/README.md +++ b/problems/unique-word-abbreviation/README.md @@ -11,7 +11,38 @@ ## [288. Unique Word Abbreviation (Medium)](https://leetcode.com/problems/unique-word-abbreviation "单词的唯一缩写") +

    An abbreviation of a word follows the form <first letter><number><last letter>. Below are some examples of word abbreviations:

    +
    +a) it                      --> it    (no abbreviation)
    +
    +     1
    +     ↓
    +b) d|o|g                   --> d1g
    +
    +              1    1  1
    +     1---5----0----5--8
    +     ↓   ↓    ↓    ↓  ↓    
    +c) i|nternationalizatio|n  --> i18n
    +
    +              1
    +     1---5----0
    +     ↓   ↓    ↓
    +d) l|ocalizatio|n          --> l10n
    +
    + +

    Assume you have a dictionary and given a word, find whether its abbreviation is unique in the dictionary. A word's abbreviation is unique if no other word from the dictionary has the same abbreviation.

    + +

    Example:

    + +
    +Given dictionary = [ "deer", "door", "cake", "card" ]
    +
    +isUnique("dear") -> false
    +isUnique("cart") -> true
    +isUnique("cane") -> false
    +isUnique("make") -> true
    +
    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/unpopular-books/README.md b/problems/unpopular-books/README.md index 21a3899ce..4cd9e3c91 100644 --- a/problems/unpopular-books/README.md +++ b/problems/unpopular-books/README.md @@ -11,7 +11,74 @@ ## [1098. Unpopular Books (Medium)](https://leetcode.com/problems/unpopular-books "小众书籍") +

    Table: Books

    +
    ++----------------+---------+
    +| Column Name    | Type    |
    ++----------------+---------+
    +| book_id        | int     |
    +| name           | varchar |
    +| available_from | date    |
    ++----------------+---------+
    +book_id is the primary key of this table.
    +
    + +

    Table: Orders

    + +
    ++----------------+---------+
    +| Column Name    | Type    |
    ++----------------+---------+
    +| order_id       | int     |
    +| book_id        | int     |
    +| quantity       | int     |
    +| dispatch_date  | date    |
    ++----------------+---------+
    +order_id is the primary key of this table.
    +book_id is a foreign key to the Books table.
    +
    + +

     

    + +

    Write an SQL query that reports the books that have sold less than 10 copies in the last year, excluding books that have been available for less than 1 month from today. Assume today is 2019-06-23.

    + +

    The query result format is in the following example:

    + +
    +Books table:
    ++---------+--------------------+----------------+
    +| book_id | name               | available_from |
    ++---------+--------------------+----------------+
    +| 1       | "Kalila And Demna" | 2010-01-01     |
    +| 2       | "28 Letters"       | 2012-05-12     |
    +| 3       | "The Hobbit"       | 2019-06-10     |
    +| 4       | "13 Reasons Why"   | 2019-06-01     |
    +| 5       | "The Hunger Games" | 2008-09-21     |
    ++---------+--------------------+----------------+
    +
    +Orders table:
    ++----------+---------+----------+---------------+
    +| order_id | book_id | quantity | dispatch_date |
    ++----------+---------+----------+---------------+
    +| 1        | 1       | 2        | 2018-07-26    |
    +| 2        | 1       | 1        | 2018-11-05    |
    +| 3        | 3       | 8        | 2019-06-11    |
    +| 4        | 4       | 6        | 2019-06-05    |
    +| 5        | 4       | 5        | 2019-06-20    |
    +| 6        | 5       | 9        | 2009-02-02    |
    +| 7        | 5       | 8        | 2010-04-13    |
    ++----------+---------+----------+---------------+
    +
    +Result table:
    ++-----------+--------------------+
    +| book_id   | name               |
    ++-----------+--------------------+
    +| 1         | "Kalila And Demna" |
    +| 2         | "28 Letters"       |
    +| 5         | "The Hunger Games" |
    ++-----------+--------------------+
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/user-activity-for-the-past-30-days-i/README.md b/problems/user-activity-for-the-past-30-days-i/README.md index 95792cb0e..8450ec32e 100644 --- a/problems/user-activity-for-the-past-30-days-i/README.md +++ b/problems/user-activity-for-the-past-30-days-i/README.md @@ -11,7 +11,56 @@ ## [1141. User Activity for the Past 30 Days I (Easy)](https://leetcode.com/problems/user-activity-for-the-past-30-days-i "查询近30天活跃用户数") +

    Table: Activity

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| user_id       | int     |
    +| session_id    | int     |
    +| activity_date | date    |
    +| activity_type | enum    |
    ++---------------+---------+
    +There is no primary key for this table, it may have duplicate rows.
    +The activity_type column is an ENUM of type ('open_session', 'end_session', 'scroll_down', 'send_message').
    +The table shows the user activities for a social media website. 
    +Note that each session belongs to exactly one user.
    +
    + +

     

    + +

    Write an SQL query to find the daily active user count for a period of 30 days ending 2019-07-27 inclusively. A user was active on some day if he/she made at least one activity on that day.

    + +

    The query result format is in the following example:

    + +
    +Activity table:
    ++---------+------------+---------------+---------------+
    +| user_id | session_id | activity_date | activity_type |
    ++---------+------------+---------------+---------------+
    +| 1       | 1          | 2019-07-20    | open_session  |
    +| 1       | 1          | 2019-07-20    | scroll_down   |
    +| 1       | 1          | 2019-07-20    | end_session   |
    +| 2       | 4          | 2019-07-20    | open_session  |
    +| 2       | 4          | 2019-07-21    | send_message  |
    +| 2       | 4          | 2019-07-21    | end_session   |
    +| 3       | 2          | 2019-07-21    | open_session  |
    +| 3       | 2          | 2019-07-21    | send_message  |
    +| 3       | 2          | 2019-07-21    | end_session   |
    +| 4       | 3          | 2019-06-25    | open_session  |
    +| 4       | 3          | 2019-06-25    | end_session   |
    ++---------+------------+---------------+---------------+
    +
    +Result table:
    ++------------+--------------+ 
    +| day        | active_users |
    ++------------+--------------+ 
    +| 2019-07-20 | 2            |
    +| 2019-07-21 | 2            |
    ++------------+--------------+ 
    +Note that we do not care about days with zero active users.
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/user-activity-for-the-past-30-days-ii/README.md b/problems/user-activity-for-the-past-30-days-ii/README.md index 6205e3968..17466257b 100644 --- a/problems/user-activity-for-the-past-30-days-ii/README.md +++ b/problems/user-activity-for-the-past-30-days-ii/README.md @@ -11,7 +11,56 @@ ## [1142. User Activity for the Past 30 Days II (Easy)](https://leetcode.com/problems/user-activity-for-the-past-30-days-ii "过去30天的用户活动 II") +

    Table: Activity

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| user_id       | int     |
    +| session_id    | int     |
    +| activity_date | date    |
    +| activity_type | enum    |
    ++---------------+---------+
    +There is no primary key for this table, it may have duplicate rows.
    +The activity_type column is an ENUM of type ('open_session', 'end_session', 'scroll_down', 'send_message').
    +The table shows the user activities for a social media website.
    +Note that each session belongs to exactly one user.
    + +

     

    + +

    Write an SQL query to find the average number of sessions per user for a period of 30 days ending 2019-07-27 inclusively, rounded to 2 decimal places. The sessions we want to count for a user are those with at least one activity in that time period.

    + +

    The query result format is in the following example:

    + +
    +Activity table:
    ++---------+------------+---------------+---------------+
    +| user_id | session_id | activity_date | activity_type |
    ++---------+------------+---------------+---------------+
    +| 1       | 1          | 2019-07-20    | open_session  |
    +| 1       | 1          | 2019-07-20    | scroll_down   |
    +| 1       | 1          | 2019-07-20    | end_session   |
    +| 2       | 4          | 2019-07-20    | open_session  |
    +| 2       | 4          | 2019-07-21    | send_message  |
    +| 2       | 4          | 2019-07-21    | end_session   |
    +| 3       | 2          | 2019-07-21    | open_session  |
    +| 3       | 2          | 2019-07-21    | send_message  |
    +| 3       | 2          | 2019-07-21    | end_session   |
    +| 3       | 5          | 2019-07-21    | open_session  |
    +| 3       | 5          | 2019-07-21    | scroll_down   |
    +| 3       | 5          | 2019-07-21    | end_session   |
    +| 4       | 3          | 2019-06-25    | open_session  |
    +| 4       | 3          | 2019-06-25    | end_session   |
    ++---------+------------+---------------+---------------+
    +
    +Result table:
    ++---------------------------+ 
    +| average_sessions_per_user |
    ++---------------------------+ 
    +| 1.33                      |
    ++---------------------------+ 
    +User 1 and 2 each had 1 session in the past 30 days while user 3 had 2 sessions so the average is (1 + 1 + 2) / 3 = 1.33.
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/user-purchase-platform/README.md b/problems/user-purchase-platform/README.md index fa18b2dc4..7b5fe2a5e 100644 --- a/problems/user-purchase-platform/README.md +++ b/problems/user-purchase-platform/README.md @@ -11,7 +11,52 @@ ## [1127. User Purchase Platform (Hard)](https://leetcode.com/problems/user-purchase-platform "用户购买平台") +

    Table: Spending

    +
    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| user_id     | int     |
    +| spend_date  | date    |
    +| platform    | enum    | 
    +| amount      | int     |
    ++-------------+---------+
    +The table logs the spendings history of users that make purchases from an online shopping website which has a desktop and a mobile application.
    +(user_id, spend_date, platform) is the primary key of this table.
    +The platform column is an ENUM type of ('desktop', 'mobile').
    +
    + +

    Write an SQL query to find the total number of users and the total amount spent using mobile only, desktop only and both mobile and desktop together for each date.

    + +

    The query result format is in the following example:

    + +
    +Spending table:
    ++---------+------------+----------+--------+
    +| user_id | spend_date | platform | amount |
    ++---------+------------+----------+--------+
    +| 1       | 2019-07-01 | mobile   | 100    |
    +| 1       | 2019-07-01 | desktop  | 100    |
    +| 2       | 2019-07-01 | mobile   | 100    |
    +| 2       | 2019-07-02 | mobile   | 100    |
    +| 3       | 2019-07-01 | desktop  | 100    |
    +| 3       | 2019-07-02 | desktop  | 100    |
    ++---------+------------+----------+--------+
    +
    +Result table:
    ++------------+----------+--------------+-------------+
    +| spend_date | platform | total_amount | total_users |
    ++------------+----------+--------------+-------------+
    +| 2019-07-01 | desktop  | 100          | 1           |
    +| 2019-07-01 | mobile   | 100          | 1           |
    +| 2019-07-01 | both     | 200          | 1           |
    +| 2019-07-02 | desktop  | 100          | 1           |
    +| 2019-07-02 | mobile   | 100          | 1           |
    +| 2019-07-02 | both     | 0            | 0           |
    ++------------+----------+--------------+-------------+ 
    +On 2019-07-01, user 1 purchased using both desktop and mobile, user 2 purchased using mobile only and user 3 purchased using desktop only.
    +On 2019-07-02, user 2 purchased using mobile only, user 3 purchased using desktop only and no one purchased using both platforms.
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/users-that-actively-request-confirmation-messages/README.md b/problems/users-that-actively-request-confirmation-messages/README.md new file mode 100644 index 000000000..92582042b --- /dev/null +++ b/problems/users-that-actively-request-confirmation-messages/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../maximum-genetic-difference-query "Maximum Genetic Difference Query") +                 +[Next >](../longest-common-subsequence-between-sorted-arrays "Longest Common Subsequence Between Sorted Arrays") + +## [1939. Users That Actively Request Confirmation Messages (Easy)](https://leetcode.com/problems/users-that-actively-request-confirmation-messages "") + + diff --git a/problems/users-that-actively-request-confirmation-messages/mysql_schemas.sql b/problems/users-that-actively-request-confirmation-messages/mysql_schemas.sql new file mode 100644 index 000000000..53a892c9b --- /dev/null +++ b/problems/users-that-actively-request-confirmation-messages/mysql_schemas.sql @@ -0,0 +1,16 @@ +Create table If Not Exists Signups (user_id int, time_stamp datetime); +Create table If Not Exists Confirmations (user_id int, time_stamp datetime, action ENUM('confirmed','timeout')); +Truncate table Signups; +insert into Signups (user_id, time_stamp) values ('3', '2020-03-21 10:16:13'); +insert into Signups (user_id, time_stamp) values ('7', '2020-01-04 13:57:59'); +insert into Signups (user_id, time_stamp) values ('2', '2020-07-29 23:09:44'); +insert into Signups (user_id, time_stamp) values ('6', '2020-12-09 10:39:37'); +Truncate table Confirmations; +insert into Confirmations (user_id, time_stamp, action) values ('3', '2021-01-06 03:30:46', 'timeout'); +insert into Confirmations (user_id, time_stamp, action) values ('3', '2021-01-06 03:37:45', 'timeout'); +insert into Confirmations (user_id, time_stamp, action) values ('7', '2021-06-12 11:57:29', 'confirmed'); +insert into Confirmations (user_id, time_stamp, action) values ('7', '2021-06-13 11:57:30', 'confirmed'); +insert into Confirmations (user_id, time_stamp, action) values ('2', '2021-01-22 00:00:00', 'confirmed'); +insert into Confirmations (user_id, time_stamp, action) values ('2', '2021-01-23 00:00:00', 'timeout'); +insert into Confirmations (user_id, time_stamp, action) values ('6', '2021-10-23 14:14:14', 'confirmed'); +insert into Confirmations (user_id, time_stamp, action) values ('6', '2021-10-24 14:14:13', 'timeout'); diff --git a/problems/valid-palindrome-iii/README.md b/problems/valid-palindrome-iii/README.md index 05e6993f6..b9c826790 100644 --- a/problems/valid-palindrome-iii/README.md +++ b/problems/valid-palindrome-iii/README.md @@ -11,7 +11,27 @@ ## [1216. Valid Palindrome III (Hard)](https://leetcode.com/problems/valid-palindrome-iii "验证回文字符串 III") +

    Given a string s and an integer k, find out if the given string is a K-Palindrome or not.

    +

    A string is K-Palindrome if it can be transformed into a palindrome by removing at most k characters from it.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "abcdeca", k = 2
    +Output: true
    +Explanation: Remove 'b' and 'e' characters.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 1000
    • +
    • s has only lowercase English letters.
    • +
    • 1 <= k <= s.length
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/valid-permutations-for-di-sequence/README.md b/problems/valid-permutations-for-di-sequence/README.md index 78b2eaf4d..6fe45763b 100644 --- a/problems/valid-permutations-for-di-sequence/README.md +++ b/problems/valid-permutations-for-di-sequence/README.md @@ -11,26 +11,29 @@ ## [903. Valid Permutations for DI Sequence (Hard)](https://leetcode.com/problems/valid-permutations-for-di-sequence "DI 序列的有效排列") -

    We are given s, a length n string of characters from the set {'D', 'I'}. (These letters stand for "decreasing" and "increasing".)

    +

    You are given a string s of length n where s[i] is either:

    -

    valid permutation is a permutation p[0], p[1], ..., p[n] of integers {0, 1, ..., n}, such that for all i:

    +
      +
    • 'D' means decreasing, or
    • +
    • 'I' means increasing.
    • +
    + +

    A permutation perm of n + 1 integers of all the integers in the range [0, n] is called a valid permutation if for all valid i:

      -
    • If s[i] == 'D', then p[i] > p[i+1], and;
    • -
    • If s[i] == 'I', then p[i] < p[i+1].
    • +
    • If s[i] == 'D', then perm[i] > perm[i + 1], and
    • +
    • If s[i] == 'I', then perm[i] < perm[i + 1].
    -

    How many valid permutations are there?  Since the answer may be large, return your answer modulo 109 + 7.

    +

    Return the number of valid permutations perm. Since the answer may be large, return it modulo 109 + 7.

     

    -

    Example 1:

    -Input: s = "DID"
    -Output: 5
    -Explanation: 
    -The 5 valid permutations of (0, 1, 2, 3) are:
    +Input: s = "DID"
    +Output: 5
    +Explanation: The 5 valid permutations of (0, 1, 2, 3) are:
     (1, 0, 3, 2)
     (2, 0, 3, 1)
     (2, 1, 3, 0)
    @@ -38,18 +41,21 @@ The 5 valid permutations of (0, 1, 2, 3) are:
     (3, 1, 2, 0)
     
    -

     

    - -

    Note:

    +

    Example 2:

    -
      -
    1. 1 <= s.length <= 200
    2. -
    3. s consists only of characters from the set {'D', 'I'}.
    4. -
    +
    +Input: s = "D"
    +Output: 1
    +
    -

     

    -
    +

    Constraints:

    + +
      +
    • n == s.length
    • +
    • 1 <= n <= 200
    • +
    • s[i] is either 'I' or 'D'.
    • +
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/valid-word-abbreviation/README.md b/problems/valid-word-abbreviation/README.md index fd25d6922..29cd566e3 100644 --- a/problems/valid-word-abbreviation/README.md +++ b/problems/valid-word-abbreviation/README.md @@ -11,7 +11,36 @@ ## [408. Valid Word Abbreviation (Easy)](https://leetcode.com/problems/valid-word-abbreviation "有效单词缩写") +

    +Given a non-empty string s and an abbreviation abbr, return whether the string matches with the given abbreviation. +

    +

    A string such as "word" contains only the following valid abbreviations:

    + +
    ["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"]
    +
    + +

    Notice that only the above abbreviations are valid abbreviations of the string "word". Any other string is not a valid abbreviation of "word".

    + +

    Note:
    +Assume s contains only lowercase letters and abbr contains only lowercase letters and digits. +

    + +

    Example 1:
    +

    +Given s = "internationalization", abbr = "i12iz4n":
    +
    +Return true.
    +
    +

    + +

    Example 2:
    +

    +Given s = "apple", abbr = "a2e":
    +
    +Return false.
    +
    +

    ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/valid-word-square/README.md b/problems/valid-word-square/README.md index 036eceb8f..82c857ad4 100644 --- a/problems/valid-word-square/README.md +++ b/problems/valid-word-square/README.md @@ -11,7 +11,83 @@ ## [422. Valid Word Square (Easy)](https://leetcode.com/problems/valid-word-square "有效的单词方块") +

    Given a sequence of words, check whether it forms a valid word square.

    +

    A sequence of words forms a valid word square if the kth row and column read the exact same string, where 0 ≤ k < max(numRows, numColumns).

    + +

    Note:
    +

      +
    1. The number of words given is at least 1 and does not exceed 500.
    2. +
    3. Word length will be at least 1 and does not exceed 500.
    4. +
    5. Each word contains only lowercase English alphabet a-z.
    6. +
    +

    + +

    Example 1: +

    +Input:
    +[
    +  "abcd",
    +  "bnrt",
    +  "crmy",
    +  "dtye"
    +]
    +
    +Output:
    +true
    +
    +Explanation:
    +The first row and first column both read "abcd".
    +The second row and second column both read "bnrt".
    +The third row and third column both read "crmy".
    +The fourth row and fourth column both read "dtye".
    +
    +Therefore, it is a valid word square.
    +
    +

    + +

    Example 2: +

    +Input:
    +[
    +  "abcd",
    +  "bnrt",
    +  "crm",
    +  "dt"
    +]
    +
    +Output:
    +true
    +
    +Explanation:
    +The first row and first column both read "abcd".
    +The second row and second column both read "bnrt".
    +The third row and third column both read "crm".
    +The fourth row and fourth column both read "dt".
    +
    +Therefore, it is a valid word square.
    +
    +

    + +

    Example 3: +

    +Input:
    +[
    +  "ball",
    +  "area",
    +  "read",
    +  "lady"
    +]
    +
    +Output:
    +false
    +
    +Explanation:
    +The third row reads "read" while the third column reads "lead".
    +
    +Therefore, it is NOT a valid word square.
    +
    +

    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/validate-stack-sequences/README.md b/problems/validate-stack-sequences/README.md index 6d2b0d91b..8d88823e7 100644 --- a/problems/validate-stack-sequences/README.md +++ b/problems/validate-stack-sequences/README.md @@ -11,40 +11,38 @@ ## [946. Validate Stack Sequences (Medium)](https://leetcode.com/problems/validate-stack-sequences "验证栈序列") -

    Given two sequences pushed and popped with distinct values, return true if and only if this could have been the result of a sequence of push and pop operations on an initially empty stack.

    +

    Given two integer arrays pushed and popped each with distinct values, return true if this could have been the result of a sequence of push and pop operations on an initially empty stack, or false otherwise.

     

    - -

    Example 1:

    -Input: pushed = [1,2,3,4,5], popped = [4,5,3,2,1]
    -Output: true
    -Explanation: We might do the following sequence:
    -push(1), push(2), push(3), push(4), pop() -> 4,
    -push(5), pop() -> 5, pop() -> 3, pop() -> 2, pop() -> 1
    +Input: pushed = [1,2,3,4,5], popped = [4,5,3,2,1]
    +Output: true
    +Explanation: We might do the following sequence:
    +push(1), push(2), push(3), push(4),
    +pop() -> 4,
    +push(5),
    +pop() -> 5, pop() -> 3, pop() -> 2, pop() -> 1
     
    -

    Example 2:

    -Input: pushed = [1,2,3,4,5], popped = [4,3,5,1,2]
    -Output: false
    -Explanation: 1 cannot be popped before 2.
    +Input: pushed = [1,2,3,4,5], popped = [4,3,5,1,2]
    +Output: false
    +Explanation: 1 cannot be popped before 2.
     
    -
    -

     

    Constraints:

      -
    • 0 <= pushed.length == popped.length <= 1000
    • -
    • 0 <= pushed[i], popped[i] < 1000
    • -
    • pushed is a permutation of popped.
    • -
    • pushed and popped have distinct values.
    • +
    • 1 <= pushed.length <= 1000
    • +
    • 0 <= pushed[i] <= 1000
    • +
    • All the elements of pushed are unique.
    • +
    • popped.length == pushed.length
    • +
    • popped is a permutation of pushed.
    ### Related Topics diff --git a/problems/verify-preorder-sequence-in-binary-search-tree/README.md b/problems/verify-preorder-sequence-in-binary-search-tree/README.md index e68fbc9ae..e9f1f0553 100644 --- a/problems/verify-preorder-sequence-in-binary-search-tree/README.md +++ b/problems/verify-preorder-sequence-in-binary-search-tree/README.md @@ -11,7 +11,33 @@ ## [255. Verify Preorder Sequence in Binary Search Tree (Medium)](https://leetcode.com/problems/verify-preorder-sequence-in-binary-search-tree "验证前序遍历序列二叉搜索树") +

    Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary search tree.

    +

    You may assume each number in the sequence is unique.

    + +

    Consider the following binary search tree: 

    + +
    +     5
    +    / \
    +   2   6
    +  / \
    + 1   3
    + +

    Example 1:

    + +
    +Input: [5,2,6,1,3]
    +Output: false
    + +

    Example 2:

    + +
    +Input: [5,2,1,3,6]
    +Output: true
    + +

    Follow up:
    +Could you do it using only constant space complexity?

    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/walls-and-gates/README.md b/problems/walls-and-gates/README.md index 3eac1befe..520654f7a 100644 --- a/problems/walls-and-gates/README.md +++ b/problems/walls-and-gates/README.md @@ -11,7 +11,35 @@ ## [286. Walls and Gates (Medium)](https://leetcode.com/problems/walls-and-gates "墙与门") +

    You are given a m x n 2D grid initialized with these three possible values.

    +
      +
    1. -1 - A wall or an obstacle.
    2. +
    3. 0 - A gate.
    4. +
    5. INF - Infinity means an empty room. We use the value 231 - 1 = 2147483647 to represent INF as you may assume that the distance to a gate is less than 2147483647.
    6. +
    + +

    Fill each empty room with the distance to its nearest gate. If it is impossible to reach a gate, it should be filled with INF.

    + +

    Example: 

    + +

    Given the 2D grid:

    + +
    +INF  -1  0  INF
    +INF INF INF  -1
    +INF  -1 INF  -1
    +  0  -1 INF INF
    +
    + +

    After running your function, the 2D grid should be:

    + +
    +  3  -1   0   1
    +  2   2   1  -1
    +  1  -1   2  -1
    +  0  -1   3   4
    +
    ### Related Topics [[Breadth-First Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/weather-type-in-each-country/README.md b/problems/weather-type-in-each-country/README.md index e519d5604..981076584 100644 --- a/problems/weather-type-in-each-country/README.md +++ b/problems/weather-type-in-each-country/README.md @@ -11,7 +11,89 @@ ## [1294. Weather Type in Each Country (Easy)](https://leetcode.com/problems/weather-type-in-each-country "不同国家的天气类型") +

    Table: Countries

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| country_id    | int     |
    +| country_name  | varchar |
    ++---------------+---------+
    +country_id is the primary key for this table.
    +Each row of this table contains the ID and the name of one country.
    +
    + +

    Table: Weather

    +
    ++---------------+---------+
    +| Column Name   | Type    |
    ++---------------+---------+
    +| country_id    | int     |
    +| weather_state | varchar |
    +| day           | date    |
    ++---------------+---------+
    +(country_id, day) is the primary key for this table.
    +Each row of this table indicates the weather state in a country for one day.
    +
    + +Write an SQL query to find the type of weather in each country for November 2019. +The type of weather is Cold if the average weather_state is less than or equal 15, Hot if the average weather_state is greater than or equal 25 and Warm otherwise. + +Return result table in any order. + +The query result format is in the following example: +
    +Countries table:
    ++------------+--------------+
    +| country_id | country_name |
    ++------------+--------------+
    +| 2          | USA          |
    +| 3          | Australia    |
    +| 7          | Peru         |
    +| 5          | China        |
    +| 8          | Morocco      |
    +| 9          | Spain        |
    ++------------+--------------+
    +Weather table:
    ++------------+---------------+------------+
    +| country_id | weather_state | day        |
    ++------------+---------------+------------+
    +| 2          | 15            | 2019-11-01 |
    +| 2          | 12            | 2019-10-28 |
    +| 2          | 12            | 2019-10-27 |
    +| 3          | -2            | 2019-11-10 |
    +| 3          | 0             | 2019-11-11 |
    +| 3          | 3             | 2019-11-12 |
    +| 5          | 16            | 2019-11-07 |
    +| 5          | 18            | 2019-11-09 |
    +| 5          | 21            | 2019-11-23 |
    +| 7          | 25            | 2019-11-28 |
    +| 7          | 22            | 2019-12-01 |
    +| 7          | 20            | 2019-12-02 |
    +| 8          | 25            | 2019-11-05 |
    +| 8          | 27            | 2019-11-15 |
    +| 8          | 31            | 2019-11-25 |
    +| 9          | 7             | 2019-10-23 |
    +| 9          | 3             | 2019-12-23 |
    ++------------+---------------+------------+
    +Result table:
    ++--------------+--------------+
    +| country_name | weather_type |
    ++--------------+--------------+
    +| USA          | Cold         |
    +| Austraila    | Cold         |
    +| Peru         | Hot          |
    +| China        | Warm         |
    +| Morocco      | Hot          |
    ++--------------+--------------+
    +Average weather_state in USA in November is (15) / 1 = 15 so weather type is Cold.
    +Average weather_state in Austraila in November is (-2 + 0 + 3) / 3 = 0.333 so weather type is Cold.
    +Average weather_state in Peru in November is (25) / 1 = 25 so weather type is Hot.
    +Average weather_state in China in November is (16 + 18 + 21) / 3 = 18.333 so weather type is Warm.
    +Average weather_state in Morocco in November is (25 + 27 + 31) / 3 = 27.667 so weather type is Hot.
    +We know nothing about average weather_state in Spain in November so we don't include it in the result table. 
    +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/web-crawler-multithreaded/README.md b/problems/web-crawler-multithreaded/README.md index b32fcdcc7..297f0abc9 100644 --- a/problems/web-crawler-multithreaded/README.md +++ b/problems/web-crawler-multithreaded/README.md @@ -11,7 +11,99 @@ ## [1242. Web Crawler Multithreaded (Medium)](https://leetcode.com/problems/web-crawler-multithreaded "多线程网页爬虫") +

    Given a url startUrl and an interface HtmlParser, implement a Multi-threaded web crawler to crawl all links that are under the same hostname as startUrl

    +

    Return all urls obtained by your web crawler in any order.

    + +

    Your crawler should:

    + +
      +
    • Start from the page: startUrl
    • +
    • Call HtmlParser.getUrls(url) to get all urls from a webpage of given url.
    • +
    • Do not crawl the same link twice.
    • +
    • Explore only the links that are under the same hostname as startUrl.
    • +
    + +

    + +

    As shown in the example url above, the hostname is example.org. For simplicity sake, you may assume all urls use http protocol without any port specified. For example, the urls http://leetcode.com/problems and http://leetcode.com/contest are under the same hostname, while urls http://example.org/test and http://example.com/abc are not under the same hostname.

    + +

    The HtmlParser interface is defined as such: 

    + +
    +interface HtmlParser {
    +  // Return a list of all urls from a webpage of given url.
    +  // This is a blocking call, that means it will do HTTP request and return when this request is finished.
    +  public List<String> getUrls(String url);
    +}
    + +

    Note that getUrls(String url) simulates performing a HTTP request. You can treat it as a blocking function call which waits for a HTTP request to finish. It is guaranteed that getUrls(String url) will return the urls within 15ms.  Single-threaded solutions will exceed the time limit so, can your multi-threaded web crawler do better?

    + +

    Below are two examples explaining the functionality of the problem, for custom testing purposes you'll have three variables urlsedges and startUrl. Notice that you will only have access to startUrl in your code, while urls and edges are not directly accessible to you in code.

    + +

     

    + +

    Follow up:

    + +
      +
    1. Assume we have 10,000 nodes and 1 billion URLs to crawl. We will deploy the same software onto each node. The software can know about all the nodes. We have to minimize communication between machines and make sure each node does equal amount of work. How would your web crawler design change?
    2. +
    3. What if one node fails or does not work?
    4. +
    5. How do you know when the crawler is done?
    6. +
    + +

     

    +

    Example 1:

    + +

    + +
    +Input:
    +urls = [
    +  "http://news.yahoo.com",
    +  "http://news.yahoo.com/news",
    +  "http://news.yahoo.com/news/topics/",
    +  "http://news.google.com",
    +  "http://news.yahoo.com/us"
    +]
    +edges = [[2,0],[2,1],[3,2],[3,1],[0,4]]
    +startUrl = "http://news.yahoo.com/news/topics/"
    +Output: [
    +  "http://news.yahoo.com",
    +  "http://news.yahoo.com/news",
    +  "http://news.yahoo.com/news/topics/",
    +  "http://news.yahoo.com/us"
    +]
    +
    + +

    Example 2:

    + +

    + +
    +Input: 
    +urls = [
    +  "http://news.yahoo.com",
    +  "http://news.yahoo.com/news",
    +  "http://news.yahoo.com/news/topics/",
    +  "http://news.google.com"
    +]
    +edges = [[0,2],[2,1],[3,2],[3,1],[3,0]]
    +startUrl = "http://news.google.com"
    +Output: ["http://news.google.com"]
    +Explanation: The startUrl links to all other pages that do not share the same hostname.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= urls.length <= 1000
    • +
    • 1 <= urls[i].length <= 300
    • +
    • startUrl is one of the urls.
    • +
    • Hostname label must be from 1 to 63 characters long, including the dots, may contain only the ASCII letters from 'a' to 'z', digits from '0' to '9' and the hyphen-minus character ('-').
    • +
    • The hostname may not start or end with the hyphen-minus character ('-'). 
    • +
    • See:  https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_hostnames
    • +
    • You may assume there're no duplicates in url library.
    • +
    ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/web-crawler/README.md b/problems/web-crawler/README.md index 60d631889..edd39af60 100644 --- a/problems/web-crawler/README.md +++ b/problems/web-crawler/README.md @@ -11,7 +11,86 @@ ## [1236. Web Crawler (Medium)](https://leetcode.com/problems/web-crawler "网络爬虫") +

    Given a url startUrl and an interface HtmlParser, implement a web crawler to crawl all links that are under the same hostname as startUrl

    +

    Return all urls obtained by your web crawler in any order.

    + +

    Your crawler should:

    + +
      +
    • Start from the page: startUrl
    • +
    • Call HtmlParser.getUrls(url) to get all urls from a webpage of given url.
    • +
    • Do not crawl the same link twice.
    • +
    • Explore only the links that are under the same hostname as startUrl.
    • +
    + +

    + +

    As shown in the example url above, the hostname is example.org. For simplicity sake, you may assume all urls use http protocol without any port specified. For example, the urls http://leetcode.com/problems and http://leetcode.com/contest are under the same hostname, while urls http://example.org/test and http://example.com/abc are not under the same hostname.

    + +

    The HtmlParser interface is defined as such: 

    + +
    +interface HtmlParser {
    +  // Return a list of all urls from a webpage of given url.
    +  public List<String> getUrls(String url);
    +}
    + +

    Below are two examples explaining the functionality of the problem, for custom testing purposes you'll have three variables urlsedges and startUrl. Notice that you will only have access to startUrl in your code, while urls and edges are not directly accessible to you in code.

    + +

     

    +

    Example 1:

    + +

    + +
    +Input:
    +urls = [
    +  "http://news.yahoo.com",
    +  "http://news.yahoo.com/news",
    +  "http://news.yahoo.com/news/topics/",
    +  "http://news.google.com",
    +  "http://news.yahoo.com/us"
    +]
    +edges = [[2,0],[2,1],[3,2],[3,1],[0,4]]
    +startUrl = "http://news.yahoo.com/news/topics/"
    +Output: [
    +  "http://news.yahoo.com",
    +  "http://news.yahoo.com/news",
    +  "http://news.yahoo.com/news/topics/",
    +  "http://news.yahoo.com/us"
    +]
    +
    + +

    Example 2:

    + +

    + +
    +Input: 
    +urls = [
    +  "http://news.yahoo.com",
    +  "http://news.yahoo.com/news",
    +  "http://news.yahoo.com/news/topics/",
    +  "http://news.google.com"
    +]
    +edges = [[0,2],[2,1],[3,2],[3,1],[3,0]]
    +startUrl = "http://news.google.com"
    +Output: ["http://news.google.com"]
    +Explanation: The startUrl links to all other pages that do not share the same hostname.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= urls.length <= 1000
    • +
    • 1 <= urls[i].length <= 300
    • +
    • startUrl is one of the urls.
    • +
    • Hostname label must be from 1 to 63 characters long, including the dots, may contain only the ASCII letters from 'a' to 'z', digits  from '0' to '9' and the hyphen-minus character ('-').
    • +
    • The hostname may not start or end with the hyphen-minus character ('-'). 
    • +
    • See:  https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_hostnames
    • +
    • You may assume there're no duplicates in url library.
    • +
    ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/wiggle-sort/README.md b/problems/wiggle-sort/README.md index ed9bc8a68..f8361134c 100644 --- a/problems/wiggle-sort/README.md +++ b/problems/wiggle-sort/README.md @@ -11,7 +11,13 @@ ## [280. Wiggle Sort (Medium)](https://leetcode.com/problems/wiggle-sort "摆动排序") +

    Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3]....

    +

    Example:

    + +
    +Input: nums = [3,5,2,1,6,4]
    +Output: One possible answer is [3,5,1,6,2,4]
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/winning-candidate/README.md b/problems/winning-candidate/README.md index 6e7bfaf1c..d5fb85d36 100644 --- a/problems/winning-candidate/README.md +++ b/problems/winning-candidate/README.md @@ -11,7 +11,53 @@ ## [574. Winning Candidate (Medium)](https://leetcode.com/problems/winning-candidate "当选者") +

    Table: Candidate

    +
    ++-----+---------+
    +| id  | Name    |
    ++-----+---------+
    +| 1   | A       |
    +| 2   | B       |
    +| 3   | C       |
    +| 4   | D       |
    +| 5   | E       |
    ++-----+---------+  
    +
    + +

    Table: Vote

    + +
    ++-----+--------------+
    +| id  | CandidateId  |
    ++-----+--------------+
    +| 1   |     2        |
    +| 2   |     4        |
    +| 3   |     3        |
    +| 4   |     2        |
    +| 5   |     5        |
    ++-----+--------------+
    +id is the auto-increment primary key,
    +CandidateId is the id appeared in Candidate table.
    +
    + +

    Write a sql to find the name of the winning candidate, the above example will return the winner B.

    + +
    ++------+
    +| Name |
    ++------+
    +| B    |
    ++------+
    +
    + +

    Notes:

    + +
      +
    1. You may assume there is no tie, in other words there will be only one winning candidate.
    2. +
    + +

     

    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/word-abbreviation/README.md b/problems/word-abbreviation/README.md index c51fc4418..16762d141 100644 --- a/problems/word-abbreviation/README.md +++ b/problems/word-abbreviation/README.md @@ -11,7 +11,29 @@ ## [527. Word Abbreviation (Hard)](https://leetcode.com/problems/word-abbreviation "单词缩写") +

    Given an array of n distinct non-empty strings, you need to generate minimal possible abbreviations for every word following rules below.

    +
      +
    1. Begin with the first character and then the number of characters abbreviated, which followed by the last character.
    2. +
    3. If there are any conflict, that is more than one words share the same abbreviation, a longer prefix is used instead of only the first character until making the map from word to abbreviation become unique. In other words, a final abbreviation cannot map to more than one original words.
    4. +
    5. If the abbreviation doesn't make the word shorter, then keep it as original.
    6. +
    + +

    Example:
    +

    +Input: ["like", "god", "internal", "me", "internet", "interval", "intension", "face", "intrusion"]
    +Output: ["l2e","god","internal","me","i6t","interval","inte4n","f2e","intr4n"]
    +
    +

    + + +Note: +
      +
    1. Both n and the length of each word will not exceed 400.
    2. +
    3. The length of each word is greater than 1.
    4. +
    5. The words consist of lowercase English letters only.
    6. +
    7. The return answers should be in the same order as the original array.
    8. +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/word-pattern-ii/README.md b/problems/word-pattern-ii/README.md index 0577b1b73..dbe80c671 100644 --- a/problems/word-pattern-ii/README.md +++ b/problems/word-pattern-ii/README.md @@ -11,7 +11,31 @@ ## [291. Word Pattern II (Medium)](https://leetcode.com/problems/word-pattern-ii "单词规律 II") +

    Given a pattern and a string str, find if str follows the same pattern.

    +

    Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty substring in str.

    + +

    Example 1:

    + +
    +Input: pattern = "abab", str = "redblueredblue"
    +Output: true
    + +

    Example 2:

    + +
    +Input: pattern = pattern = "aaaa", str = "asdasdasdasd"
    +Output: true
    + +

    Example 3:

    + +
    +Input: pattern = "aabb", str = "xyzabcxzyabc"
    +Output: false
    +
    + +

    Notes:
    +You may assume both pattern and str contains only lowercase letters.

    ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/word-squares/README.md b/problems/word-squares/README.md index 5277596be..86cd4ce96 100644 --- a/problems/word-squares/README.md +++ b/problems/word-squares/README.md @@ -11,7 +11,75 @@ ## [425. Word Squares (Hard)](https://leetcode.com/problems/word-squares "单词方块") +

    Given a set of words (without duplicates), find all word squares you can build from them.

    +

    A sequence of words forms a valid word square if the kth row and column read the exact same string, where 0 ≤ k < max(numRows, numColumns).

    + +

    For example, the word sequence ["ball","area","lead","lady"] forms a word square because each word reads the same both horizontally and vertically.

    + +
    +b a l l
    +a r e a
    +l e a d
    +l a d y
    +
    + +

    Note:
    +

      +
    1. There are at least 1 and at most 1000 words.
    2. +
    3. All words will have the exact same length.
    4. +
    5. Word length is at least 1 and at most 5.
    6. +
    7. Each word contains only lowercase English alphabet a-z.
    8. +
    +

    + +

    Example 1: +

    +Input:
    +["area","lead","wall","lady","ball"]
    +
    +Output:
    +[
    +  [ "wall",
    +    "area",
    +    "lead",
    +    "lady"
    +  ],
    +  [ "ball",
    +    "area",
    +    "lead",
    +    "lady"
    +  ]
    +]
    +
    +Explanation:
    +The output consists of two word squares. The order of output does not matter (just the order of words in each word square matters).
    +
    +

    + +

    Example 2: +

    +Input:
    +["abat","baba","atan","atal"]
    +
    +Output:
    +[
    +  [ "baba",
    +    "abat",
    +    "baba",
    +    "atan"
    +  ],
    +  [ "baba",
    +    "abat",
    +    "baba",
    +    "atal"
    +  ]
    +]
    +
    +Explanation:
    +The output consists of two word squares. The order of output does not matter (just the order of words in each word square matters).
    +
    +

    ### Related Topics [[Trie](../../tag/trie/README.md)] diff --git a/problems/word-subsets/README.md b/problems/word-subsets/README.md index a170c34a3..cca849a2d 100644 --- a/problems/word-subsets/README.md +++ b/problems/word-subsets/README.md @@ -11,74 +11,44 @@ ## [916. Word Subsets (Medium)](https://leetcode.com/problems/word-subsets "单词子集") -

    We are given two arrays words1 and words2 of words.  Each word is a string of lowercase letters.

    +

    You are given two string arrays words1 and words2.

    -

    Now, say that word b is a subset of word a if every letter in b occurs in a, including multiplicity.  For example, "wrr" is a subset of "warrior", but is not a subset of "world".

    +

    A string b is a subset of string a if every letter in b occurs in a including multiplicity.

    -

    Now say a word a from words1 is universal if for every b in words2, b is a subset of a

    +
      +
    • For example, "wrr" is a subset of "warrior" but is not a subset of "world".
    • +
    -

    Return a list of all universal words in words1.  You can return the words in any order.

    +

    A string a from words1 is universal if for every string b in words2, b is a subset of a.

    -

     

    - -
      -
    +

    Return an array of all the universal strings in words1. You may return the answer in any order.

    -
    +

     

    Example 1:

    - -
    -Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","o"]
    -Output: ["facebook","google","leetcode"]
    -
    - -
    -

    Example 2:

    - -
    -Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["l","e"]
    -Output: ["apple","google","leetcode"]
    -
    - -
    -

    Example 3:

    - -
    -Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","oo"]
    -Output: ["facebook","google"]
    +
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","o"]
    +Output: ["facebook","google","leetcode"]
    +

    Example 2:

    +
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["l","e"]
    +Output: ["apple","google","leetcode"]
    +

    Example 3:

    +
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","oo"]
    +Output: ["facebook","google"]
    +

    Example 4:

    +
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["lo","eo"]
    +Output: ["google","leetcode"]
    +

    Example 5:

    +
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["ec","oc","ceo"]
    +Output: ["facebook","leetcode"]
     
    - -
    -

    Example 4:

    - -
    -Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["lo","eo"]
    -Output: ["google","leetcode"]
    -
    - -
    -

    Example 5:

    - -
    -Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["ec","oc","ceo"]
    -Output: ["facebook","leetcode"]
    -
    -

     

    - -

    Note:

    - -
      -
    1. 1 <= words1.length, words2.length <= 10000
    2. -
    3. 1 <= words1[i].length, words2[i].length <= 10
    4. -
    5. words1[i] and words2[i] consist only of lowercase letters.
    6. -
    7. All words in words1[i] are unique: there isn't i != j with words1[i] == words1[j].
    8. -
    -
    -
    -
    -
    -
    +

    Constraints:

    + +
      +
    • 1 <= words1.length, words2.length <= 104
    • +
    • 1 <= words1[i].length, words2[i].length <= 10
    • +
    • words1[i] and words2[i] consist only of lowercase English letters.
    • +
    • All the strings of words1 are unique.
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/zigzag-iterator/README.md b/problems/zigzag-iterator/README.md index a2477e502..7ca1fe411 100644 --- a/problems/zigzag-iterator/README.md +++ b/problems/zigzag-iterator/README.md @@ -11,7 +11,33 @@ ## [281. Zigzag Iterator (Medium)](https://leetcode.com/problems/zigzag-iterator "锯齿迭代器") +

    Given two 1d vectors, implement an iterator to return their elements alternately.

    +

    Example:

    + +
    +Input:
    +v1 = [1,2]
    +v2 = [3,4,5,6] 
    +
    +Output: [1,3,2,4,5,6]
    +
    +Explanation: By calling next repeatedly until hasNext returns false, 
    +             the order of elements returned by next should be: [1,3,2,4,5,6].
    + +

    Follow up: What if you are given k 1d vectors? How well can your code be extended to such cases?

    + +

    Clarification for the follow up question:
    +The "Zigzag" order is not clearly defined and is ambiguous for k > 2 cases. If "Zigzag" does not look right to you, replace "Zigzag" with "Cyclic". For example:

    + +
    +Input:
    +[1,2,3]
    +[4,5,6,7]
    +[8,9]
    +
    +Output: [1,4,8,2,5,9,3,6,7].
    +
    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/readme/1-300.md b/readme/1-300.md index e172e48be..e5665afc1 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -248,7 +248,7 @@ LeetCode Problems' Solutions | 168 | [Excel Sheet Column Title](https://leetcode.com/problems/excel-sheet-column-title "Excel表列名称") | [Go](../problems/excel-sheet-column-title) | Easy | | 169 | [Majority Element](https://leetcode.com/problems/majority-element "多数元素") | [Go](../problems/majority-element) | Easy | | 170 | [Two Sum III - Data structure design](https://leetcode.com/problems/two-sum-iii-data-structure-design "两数之和 III - 数据结构设计") 🔒 | [Go](../problems/two-sum-iii-data-structure-design) | Easy | -| 171 | [Excel Sheet Column Number](https://leetcode.com/problems/excel-sheet-column-number "Excel表列序号") | [Go](../problems/excel-sheet-column-number) | Easy | +| 171 | [Excel Sheet Column Number](https://leetcode.com/problems/excel-sheet-column-number "Excel 表列序号") | [Go](../problems/excel-sheet-column-number) | Easy | | 172 | [Factorial Trailing Zeroes](https://leetcode.com/problems/factorial-trailing-zeroes "阶乘后的零") | [Go](../problems/factorial-trailing-zeroes) | Easy | | 173 | [Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator "二叉搜索树迭代器") | [Go](../problems/binary-search-tree-iterator) | Medium | | 174 | [Dungeon Game](https://leetcode.com/problems/dungeon-game "地下城游戏") | [Go](../problems/dungeon-game) | Hard | diff --git a/readme/301-600.md b/readme/301-600.md index 7a4595be6..69074961c 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -325,7 +325,7 @@ LeetCode Problems' Solutions | 545 | [Boundary of Binary Tree](https://leetcode.com/problems/boundary-of-binary-tree "二叉树的边界") 🔒 | [Go](../problems/boundary-of-binary-tree) | Medium | | 546 | [Remove Boxes](https://leetcode.com/problems/remove-boxes "移除盒子") | [Go](../problems/remove-boxes) | Hard | | 547 | [Number of Provinces](https://leetcode.com/problems/number-of-provinces "省份数量") | [Go](../problems/number-of-provinces) | Medium | -| 548 | [Split Array with Equal Sum](https://leetcode.com/problems/split-array-with-equal-sum "将数组分割成和相等的子数组") 🔒 | [Go](../problems/split-array-with-equal-sum) | Medium | +| 548 | [Split Array with Equal Sum](https://leetcode.com/problems/split-array-with-equal-sum "将数组分割成和相等的子数组") 🔒 | [Go](../problems/split-array-with-equal-sum) | Hard | | 549 | [Binary Tree Longest Consecutive Sequence II](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence-ii "二叉树中最长的连续序列") 🔒 | [Go](../problems/binary-tree-longest-consecutive-sequence-ii) | Medium | | 550 | [Game Play Analysis IV](https://leetcode.com/problems/game-play-analysis-iv "游戏玩法分析 IV") 🔒 | [MySQL](../problems/game-play-analysis-iv) | Medium | | 551 | [Student Attendance Record I](https://leetcode.com/problems/student-attendance-record-i "学生出勤记录 I") | [Go](../problems/student-attendance-record-i) | Easy | @@ -349,7 +349,7 @@ LeetCode Problems' Solutions | 569 | [Median Employee Salary](https://leetcode.com/problems/median-employee-salary "员工薪水中位数") 🔒 | [MySQL](../problems/median-employee-salary) | Hard | | 570 | [Managers with at Least 5 Direct Reports](https://leetcode.com/problems/managers-with-at-least-5-direct-reports "至少有5名直接下属的经理") 🔒 | [MySQL](../problems/managers-with-at-least-5-direct-reports) | Medium | | 571 | [Find Median Given Frequency of Numbers](https://leetcode.com/problems/find-median-given-frequency-of-numbers "给定数字的频率查询中位数") 🔒 | [MySQL](../problems/find-median-given-frequency-of-numbers) | Hard | -| 572 | [Subtree of Another Tree](https://leetcode.com/problems/subtree-of-another-tree "另一个树的子树") | [Go](../problems/subtree-of-another-tree) | Easy | +| 572 | [Subtree of Another Tree](https://leetcode.com/problems/subtree-of-another-tree "另一棵树的子树") | [Go](../problems/subtree-of-another-tree) | Easy | | 573 | [Squirrel Simulation](https://leetcode.com/problems/squirrel-simulation "松鼠模拟") 🔒 | [Go](../problems/squirrel-simulation) | Medium | | 574 | [Winning Candidate](https://leetcode.com/problems/winning-candidate "当选者") 🔒 | [MySQL](../problems/winning-candidate) | Medium | | 575 | [Distribute Candies](https://leetcode.com/problems/distribute-candies "分糖果") | [Go](../problems/distribute-candies) | Easy | diff --git a/readme/601-900.md b/readme/601-900.md index d04f80016..6e657be84 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -265,7 +265,7 @@ LeetCode Problems' Solutions | 785 | [Is Graph Bipartite?](https://leetcode.com/problems/is-graph-bipartite "判断二分图") | [Go](../problems/is-graph-bipartite) | Medium | | 786 | [K-th Smallest Prime Fraction](https://leetcode.com/problems/k-th-smallest-prime-fraction "第 K 个最小的素数分数") | [Go](../problems/k-th-smallest-prime-fraction) | Hard | | 787 | [Cheapest Flights Within K Stops](https://leetcode.com/problems/cheapest-flights-within-k-stops "K 站中转内最便宜的航班") | [Go](../problems/cheapest-flights-within-k-stops) | Medium | -| 788 | [Rotated Digits](https://leetcode.com/problems/rotated-digits "旋转数字") | [Go](../problems/rotated-digits) | Easy | +| 788 | [Rotated Digits](https://leetcode.com/problems/rotated-digits "旋转数字") | [Go](../problems/rotated-digits) | Medium | | 789 | [Escape The Ghosts](https://leetcode.com/problems/escape-the-ghosts "逃脱阻碍者") | [Go](../problems/escape-the-ghosts) | Medium | | 790 | [Domino and Tromino Tiling](https://leetcode.com/problems/domino-and-tromino-tiling "多米诺和托米诺平铺") | [Go](../problems/domino-and-tromino-tiling) | Medium | | 791 | [Custom Sort String](https://leetcode.com/problems/custom-sort-string "自定义字符串排序") | [Go](../problems/custom-sort-string) | Medium | @@ -370,7 +370,7 @@ LeetCode Problems' Solutions | 890 | [Find and Replace Pattern](https://leetcode.com/problems/find-and-replace-pattern "查找和替换模式") | [Go](../problems/find-and-replace-pattern) | Medium | | 891 | [Sum of Subsequence Widths](https://leetcode.com/problems/sum-of-subsequence-widths "子序列宽度之和") | [Go](../problems/sum-of-subsequence-widths) | Hard | | 892 | [Surface Area of 3D Shapes](https://leetcode.com/problems/surface-area-of-3d-shapes "三维形体的表面积") | [Go](../problems/surface-area-of-3d-shapes) | Easy | -| 893 | [Groups of Special-Equivalent Strings](https://leetcode.com/problems/groups-of-special-equivalent-strings "特殊等价字符串组") | [Go](../problems/groups-of-special-equivalent-strings) | Easy | +| 893 | [Groups of Special-Equivalent Strings](https://leetcode.com/problems/groups-of-special-equivalent-strings "特殊等价字符串组") | [Go](../problems/groups-of-special-equivalent-strings) | Medium | | 894 | [All Possible Full Binary Trees](https://leetcode.com/problems/all-possible-full-binary-trees "所有可能的满二叉树") | [Go](../problems/all-possible-full-binary-trees) | Medium | | 895 | [Maximum Frequency Stack](https://leetcode.com/problems/maximum-frequency-stack "最大频率栈") | [Go](../problems/maximum-frequency-stack) | Hard | | 896 | [Monotonic Array](https://leetcode.com/problems/monotonic-array "单调数列") | [Go](../problems/monotonic-array) | Easy | diff --git a/tag/README.md b/tag/README.md index 2b803ccaa..0aab38cdc 100644 --- a/tag/README.md +++ b/tag/README.md @@ -11,23 +11,40 @@ | :-: | - | :-: | - | :-: | - | :-: | | 1 | [Array](array/README.md) | [数组](https://openset.github.io/tags/array/) | | 2 | [Dynamic Programming](dynamic-programming/README.md) | [动态规划](https://openset.github.io/tags/dynamic-programming/) | | 3 | [String](string/README.md) | [字符串](https://openset.github.io/tags/string/) | | 4 | [Math](math/README.md) | [数学](https://openset.github.io/tags/math/) | -| 5 | [Greedy](greedy/README.md) | [贪心算法](https://openset.github.io/tags/greedy/) | | 6 | [Depth-first Search](depth-first-search/README.md) | [深度优先搜索](https://openset.github.io/tags/depth-first-search/) | +| 5 | [Greedy](greedy/README.md) | [贪心](https://openset.github.io/tags/greedy/) | | 6 | [Depth-First Search](depth-first-search/README.md) | [深度优先搜索](https://openset.github.io/tags/depth-first-search/) | | 7 | [Tree](tree/README.md) | [树](https://openset.github.io/tags/tree/) | | 8 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | -| 9 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 10 | [Breadth-first Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | +| 9 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 10 | [Breadth-First Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | | 11 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | -| 13 | [Backtracking](backtracking/README.md) | [回溯算法](https://openset.github.io/tags/backtracking/) | | 14 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | +| 13 | [Backtracking](backtracking/README.md) | [回溯](https://openset.github.io/tags/backtracking/) | | 14 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | | 15 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | | 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | | 19 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | | 20 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | -| 21 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | | 22 | [Sliding Window](sliding-window/README.md) | [Sliding Window](https://openset.github.io/tags/sliding-window/) | -| 23 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Divide and Conquer](divide-and-conquer/README.md) | [分治算法](https://openset.github.io/tags/divide-and-conquer/) | +| 21 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | | 22 | [Sliding Window](sliding-window/README.md) | [滑动窗口](https://openset.github.io/tags/sliding-window/) | +| 23 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Divide and Conquer](divide-and-conquer/README.md) | [分治](https://openset.github.io/tags/divide-and-conquer/) | | 25 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | | 26 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | | 27 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | -| 29 | [Line Sweep](line-sweep/README.md) | [Line Sweep](https://openset.github.io/tags/line-sweep/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | +| 29 | [Line Sweep](line-sweep/README.md) | [扫描线](https://openset.github.io/tags/line-sweep/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | | 31 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 32 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | | 33 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | | 34 | [Dequeue](dequeue/README.md) | [Dequeue](https://openset.github.io/tags/dequeue/) | | 35 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 36 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | -| 37 | [Rolling Hash](rolling-hash/README.md) | [Rolling Hash](https://openset.github.io/tags/rolling-hash/) | | 38 | [Suffix Array](suffix-array/README.md) | [Suffix Array](https://openset.github.io/tags/suffix-array/) | -| 39 | [Rejection Sampling](rejection-sampling/README.md) | [Rejection Sampling](https://openset.github.io/tags/rejection-sampling/) | | 40 | [Reservoir Sampling](reservoir-sampling/README.md) | [蓄水池抽样](https://openset.github.io/tags/reservoir-sampling/) | -| 41 | [Meet In The Middle](meet-in-the-middle/README.md) | [Meet In The Middle](https://openset.github.io/tags/meet-in-the-middle/) | | 42 | [Memoization](memoization/README.md) | [记忆化](https://openset.github.io/tags/memoization/) | -| 43 | [OOP](oop/README.md) | [OOP](https://openset.github.io/tags/oop/) | \ No newline at end of file +| 37 | [Rolling Hash](rolling-hash/README.md) | [滚动哈希](https://openset.github.io/tags/rolling-hash/) | | 38 | [Suffix Array](suffix-array/README.md) | [后缀数组](https://openset.github.io/tags/suffix-array/) | +| 39 | [Rejection Sampling](rejection-sampling/README.md) | [拒绝采样](https://openset.github.io/tags/rejection-sampling/) | | 40 | [Reservoir Sampling](reservoir-sampling/README.md) | [水塘抽样](https://openset.github.io/tags/reservoir-sampling/) | +| 41 | [Meet In The Middle](meet-in-the-middle/README.md) | [Meet In The Middle](https://openset.github.io/tags/meet-in-the-middle/) | | 42 | [Memoization](memoization/README.md) | [记忆化搜索](https://openset.github.io/tags/memoization/) | +| 43 | [OOP](oop/README.md) | [OOP](https://openset.github.io/tags/oop/) | | 44 | [Sorting](sorting/README.md) | [排序](https://openset.github.io/tags/sorting/) | +| 45 | [Heap (Priority Queue)](heap-priority-queue/README.md) | [堆(优先队列)](https://openset.github.io/tags/heap-priority-queue/) | | 46 | [Ordered Set](ordered-set/README.md) | [有序集合](https://openset.github.io/tags/ordered-set/) | +| 47 | [Hash Function](hash-function/README.md) | [哈希函数](https://openset.github.io/tags/hash-function/) | | 48 | [String Matching](string-matching/README.md) | [字符串匹配](https://openset.github.io/tags/string-matching/) | +| 49 | [Randomized](randomized/README.md) | [随机化](https://openset.github.io/tags/randomized/) | | 50 | [Prefix Sum](prefix-sum/README.md) | [前缀和](https://openset.github.io/tags/prefix-sum/) | +| 51 | [Probability and Statistics](probability-and-statistics/README.md) | [概率与统计](https://openset.github.io/tags/probability-and-statistics/) | | 52 | [Simulation](simulation/README.md) | [模拟](https://openset.github.io/tags/simulation/) | +| 53 | [Monotonic Queue](monotonic-queue/README.md) | [单调队列](https://openset.github.io/tags/monotonic-queue/) | | 54 | [Data Stream](data-stream/README.md) | [数据流](https://openset.github.io/tags/data-stream/) | +| 55 | [Counting](counting/README.md) | [计数](https://openset.github.io/tags/counting/) | | 56 | [Matrix](matrix/README.md) | [矩阵](https://openset.github.io/tags/matrix/) | +| 57 | [Iterator](iterator/README.md) | [迭代器](https://openset.github.io/tags/iterator/) | | 58 | [Quickselect](quickselect/README.md) | [快速选择](https://openset.github.io/tags/quickselect/) | +| 59 | [Merge Sort](merge-sort/README.md) | [归并排序](https://openset.github.io/tags/merge-sort/) | | 60 | [Binary Tree](binary-tree/README.md) | [二叉树](https://openset.github.io/tags/binary-tree/) | +| 61 | [Combinatorics](combinatorics/README.md) | [组合数学](https://openset.github.io/tags/combinatorics/) | | 62 | [Shortest Path](shortest-path/README.md) | [最短路](https://openset.github.io/tags/shortest-path/) | +| 63 | [Interactive](interactive/README.md) | [交互](https://openset.github.io/tags/interactive/) | | 64 | [Bucket Sort](bucket-sort/README.md) | [桶排序](https://openset.github.io/tags/bucket-sort/) | +| 65 | [Counting Sort](counting-sort/README.md) | [计数排序](https://openset.github.io/tags/counting-sort/) | | 66 | [Radix Sort](radix-sort/README.md) | [基数排序](https://openset.github.io/tags/radix-sort/) | +| 67 | [Monotonic Stack](monotonic-stack/README.md) | [单调栈](https://openset.github.io/tags/monotonic-stack/) | | 68 | [Minimum Spanning Tree](minimum-spanning-tree/README.md) | [最小生成树](https://openset.github.io/tags/minimum-spanning-tree/) | +| 69 | [Strongly Connected Component](strongly-connected-component/README.md) | [强连通分量](https://openset.github.io/tags/strongly-connected-component/) | | 70 | [Game Theory](game-theory/README.md) | [博弈](https://openset.github.io/tags/game-theory/) | +| 71 | [Bitmask](bitmask/README.md) | [状态压缩](https://openset.github.io/tags/bitmask/) | | 72 | [Concurrency](concurrency/README.md) | [多线程](https://openset.github.io/tags/concurrency/) | +| 73 | [Doubly-Linked List](doubly-linked-list/README.md) | [双向链表](https://openset.github.io/tags/doubly-linked-list/) | | 74 | [Enumeration](enumeration/README.md) | [枚举](https://openset.github.io/tags/enumeration/) | +| 75 | [Number Theory](number-theory/README.md) | [数论](https://openset.github.io/tags/number-theory/) | | 76 | [Biconnected Component](biconnected-component/README.md) | [双连通分量](https://openset.github.io/tags/biconnected-component/) | +| 77 | [Eulerian Circuit](eulerian-circuit/README.md) | [欧拉回路](https://openset.github.io/tags/eulerian-circuit/) | \ No newline at end of file diff --git a/tag/array/README.md b/tag/array/README.md index 0a93eae00..204ebab71 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,14 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | +| 1947 | [最大兼容性评分和](../../problems/maximum-compatibility-score-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 1946 | [子字符串突变后可能得到的最大整数](../../problems/largest-number-after-mutating-substring) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1944 | [队列中可以看到的人数](../../problems/number-of-visible-people-in-a-queue) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 1943 | [描述绘画结果](../../problems/describe-the-painting) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1942 | [最小未被占据椅子的编号](../../problems/the-number-of-the-smallest-unoccupied-chair) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1929 | [数组串联](../../problems/concatenation-of-array) | [[数组](../array/README.md)] | Easy | +| 1926 | [迷宫中离入口最近的出口](../../problems/nearest-exit-from-entrance-in-maze) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1920 | [基于排列构建数组](../../problems/build-array-from-permutation) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | @@ -522,7 +530,7 @@ | 900 | [RLE 迭代器](../../problems/rle-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 898 | [子数组按位或操作](../../problems/bitwise-ors-of-subarrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 896 | [单调数列](../../problems/monotonic-array) | [[数组](../array/README.md)] | Easy | -| 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 892 | [三维形体的表面积](../../problems/surface-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Easy | | 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | @@ -676,7 +684,7 @@ | 555 | [分割连接字符串](../../problems/split-concatenated-strings) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 554 | [砖墙](../../problems/brick-wall) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 553 | [最优除法](../../problems/optimal-division) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 548 | [将数组分割成和相等的子数组](../../problems/split-array-with-equal-sum) 🔒 | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 548 | [将数组分割成和相等的子数组](../../problems/split-array-with-equal-sum) 🔒 | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 546 | [移除盒子](../../problems/remove-boxes) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 542 | [01 矩阵](../../problems/01-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 540 | [有序数组中的单一元素](../../problems/single-element-in-a-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 9a4cc1442..efc8ce7e7 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -5,10 +5,11 @@ -## [话题分类](../README.md) > 回溯算法 +## [话题分类](../README.md) > 回溯 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1947 | [最大兼容性评分和](../../problems/maximum-compatibility-score-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1863 | [找出所有子集的异或总和再求和](../../problems/sum-of-all-subset-xor-totals) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Easy | | 1849 | [将字符串拆分为递减的连续值](../../problems/splitting-a-string-into-descending-consecutive-values) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1820 | [最多邀请的个数](../../problems/maximum-number-of-accepted-invitations) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Medium | diff --git a/tag/biconnected-component/README.md b/tag/biconnected-component/README.md new file mode 100644 index 000000000..24393482a --- /dev/null +++ b/tag/biconnected-component/README.md @@ -0,0 +1,12 @@ + + + + + + + +## [话题分类](../README.md) > 双连通分量 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1192 | [查找集群内的「关键连接」](../../problems/critical-connections-in-a-network) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[双连通分量](../biconnected-component/README.md)] | Hard | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index d4f690c92..188204f89 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1954 | [收集足够苹果的最小花园周长](../../problems/minimum-garden-perimeter-to-collect-enough-apples) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1918 | [Kth Smallest Subarray Sum](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1901 | [找出顶峰元素 II](../../problems/find-a-peak-element-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | diff --git a/tag/binary-tree/README.md b/tag/binary-tree/README.md new file mode 100644 index 000000000..eda4ac341 --- /dev/null +++ b/tag/binary-tree/README.md @@ -0,0 +1,162 @@ + + + + + + + +## [话题分类](../README.md) > 二叉树 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1660 | [纠正二叉树](../../problems/correct-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1650 | [二叉树的最近公共祖先 III](../../problems/lowest-common-ancestor-of-a-binary-tree-iii) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1644 | [二叉树的最近公共祖先 II](../../problems/lowest-common-ancestor-of-a-binary-tree-ii) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[数学](../math/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1609 | [奇偶树](../../problems/even-odd-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1597 | [根据中缀表达式构造二叉表达式树](../../problems/build-binary-expression-tree-from-infix-expression) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1469 | [寻找所有的独生节点](../../problems/find-all-the-lonely-nodes) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 1457 | [二叉树中的伪回文路径](../../problems/pseudo-palindromic-paths-in-a-binary-tree) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1448 | [统计二叉树中好节点的数目](../../problems/count-good-nodes-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1430 | [判断给定的序列是否是二叉树从根到叶的路径](../../problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1382 | [将二叉搜索树变平衡](../../problems/balance-a-binary-search-tree) | [[贪心](../greedy/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1379 | [找出克隆二叉树中的相同节点](../../problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1373 | [二叉搜索子树的最大键值和](../../problems/maximum-sum-bst-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 1372 | [二叉树中的最长交错路径](../../problems/longest-zigzag-path-in-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1367 | [二叉树中的列表](../../problems/linked-list-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1361 | [验证二叉树](../../problems/validate-binary-tree-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1339 | [分裂二叉树的最大乘积](../../problems/maximum-product-of-splitted-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1325 | [删除给定值的叶子节点](../../problems/delete-leaves-with-a-given-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1315 | [祖父节点值为偶数的节点和](../../problems/sum-of-nodes-with-even-valued-grandparent) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1110 | [删点成林](../../problems/delete-nodes-and-return-forest) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1104 | [二叉树寻路](../../problems/path-in-zigzag-labelled-binary-tree) | [[树](../tree/README.md)] [[数学](../math/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1080 | [根到叶路径上的不足节点](../../problems/insufficient-nodes-in-root-to-leaf-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 1026 | [节点与其祖先之间的最大差值](../../problems/maximum-difference-between-node-and-ancestor) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1022 | [从根到叶的二进制数之和](../../problems/sum-of-root-to-leaf-binary-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 1008 | [前序遍历构造二叉搜索树](../../problems/construct-binary-search-tree-from-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 998 | [最大二叉树 II](../../problems/maximum-binary-tree-ii) | [[树](../tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 988 | [从叶结点开始的最小字符串](../../problems/smallest-string-starting-from-leaf) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 987 | [二叉树的垂序遍历](../../problems/vertical-order-traversal-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 979 | [在二叉树中分配硬币](../../problems/distribute-coins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 971 | [翻转二叉树以匹配先序遍历](../../problems/flip-binary-tree-to-match-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 968 | [监控二叉树](../../problems/binary-tree-cameras) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 965 | [单值二叉树](../../problems/univalued-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 958 | [二叉树的完全性检验](../../problems/check-completeness-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 951 | [翻转等价二叉树](../../problems/flip-equivalent-binary-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 938 | [二叉搜索树的范围和](../../problems/range-sum-of-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 919 | [完全二叉树插入器](../../problems/complete-binary-tree-inserter) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 897 | [递增顺序搜索树](../../problems/increasing-order-search-tree) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 894 | [所有可能的满二叉树](../../problems/all-possible-full-binary-trees) | [[树](../tree/README.md)] [[递归](../recursion/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 872 | [叶子相似的树](../../problems/leaf-similar-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 863 | [二叉树中所有距离为 K 的结点](../../problems/all-nodes-distance-k-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 814 | [二叉树剪枝](../../problems/binary-tree-pruning) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 783 | [二叉搜索树节点最小距离](../../problems/minimum-distance-between-bst-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 776 | [拆分二叉搜索树](../../problems/split-bst) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 742 | [二叉树最近的叶节点](../../problems/closest-leaf-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[数据流](../data-stream/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 701 | [二叉搜索树中的插入操作](../../problems/insert-into-a-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 700 | [二叉搜索树中的搜索](../../problems/search-in-a-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 671 | [二叉树中第二小的节点](../../problems/second-minimum-node-in-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 669 | [修剪二叉搜索树](../../problems/trim-a-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 666 | [路径总和 IV](../../problems/path-sum-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 663 | [均匀树划分](../../problems/equal-tree-partition) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 662 | [二叉树最大宽度](../../problems/maximum-width-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 655 | [输出二叉树](../../problems/print-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 654 | [最大二叉树](../../problems/maximum-binary-tree) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 653 | [两数之和 IV - 输入 BST](../../problems/two-sum-iv-input-is-a-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 652 | [寻找重复的子树](../../problems/find-duplicate-subtrees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 637 | [二叉树的层平均值](../../problems/average-of-levels-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 623 | [在二叉树中增加一行](../../problems/add-one-row-to-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 617 | [合并二叉树](../../problems/merge-two-binary-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 606 | [根据二叉树创建字符串](../../problems/construct-string-from-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 572 | [另一棵树的子树](../../problems/subtree-of-another-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] [[字符串匹配](../string-matching/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | +| 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 549 | [二叉树中最长的连续序列](../../problems/binary-tree-longest-consecutive-sequence-ii) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 545 | [二叉树的边界](../../problems/boundary-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 543 | [二叉树的直径](../../problems/diameter-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 538 | [把二叉搜索树转换为累加树](../../problems/convert-bst-to-greater-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 536 | [从字符串生成二叉树](../../problems/construct-binary-tree-from-string) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 530 | [二叉搜索树的最小绝对差](../../problems/minimum-absolute-difference-in-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 515 | [在每个树行中找最大值](../../problems/find-largest-value-in-each-tree-row) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 513 | [找树左下角的值](../../problems/find-bottom-left-tree-value) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 510 | [二叉搜索树中的中序后继 II](../../problems/inorder-successor-in-bst-ii) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 508 | [出现次数最多的子树元素和](../../problems/most-frequent-subtree-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 501 | [二叉搜索树中的众数](../../problems/find-mode-in-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 450 | [删除二叉搜索树中的节点](../../problems/delete-node-in-a-bst) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 449 | [序列化和反序列化二叉搜索树](../../problems/serialize-and-deserialize-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 437 | [路径总和 III](../../problems/path-sum-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 431 | [将 N 叉树编码为二叉树](../../problems/encode-n-ary-tree-to-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 404 | [左叶子之和](../../problems/sum-of-left-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 366 | [寻找二叉树的叶子节点](../../problems/find-leaves-of-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 333 | [最大 BST 子树](../../problems/largest-bst-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 331 | [验证二叉树的前序序列化](../../problems/verify-preorder-serialization-of-a-binary-tree) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 298 | [二叉树最长连续序列](../../problems/binary-tree-longest-consecutive-sequence) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 285 | [二叉搜索树中的中序后继](../../problems/inorder-successor-in-bst) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 235 | [二叉搜索树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 230 | [二叉搜索树中第K小的元素](../../problems/kth-smallest-element-in-a-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 226 | [翻转二叉树](../../problems/invert-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 199 | [二叉树的右视图](../../problems/binary-tree-right-side-view) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 156 | [上下翻转二叉树](../../problems/binary-tree-upside-down) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 145 | [二叉树的后序遍历](../../problems/binary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 103 | [二叉树的锯齿形层序遍历](../../problems/binary-tree-zigzag-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 102 | [二叉树的层序遍历](../../problems/binary-tree-level-order-traversal) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 101 | [对称二叉树](../../problems/symmetric-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 100 | [相同的树](../../problems/same-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 99 | [恢复二叉搜索树](../../problems/recover-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 98 | [验证二叉搜索树](../../problems/validate-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 95 | [不同的二叉搜索树 II](../../problems/unique-binary-search-trees-ii) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 94 | [二叉树的中序遍历](../../problems/binary-tree-inorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index ad7787aac..f06c61bd9 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1947 | [最大兼容性评分和](../../problems/maximum-compatibility-score-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1915 | [最美子字符串的数目](../../problems/number-of-wonderful-substrings) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1908 | [Game of Nim](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1879 | [两个数组最小的异或值之和](../../problems/minimum-xor-sum-of-two-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | diff --git a/tag/bitmask/README.md b/tag/bitmask/README.md new file mode 100644 index 000000000..fcd9be1c5 --- /dev/null +++ b/tag/bitmask/README.md @@ -0,0 +1,38 @@ + + + + + + + +## [话题分类](../README.md) > 状态压缩 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1947 | [最大兼容性评分和](../../problems/maximum-compatibility-score-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 1879 | [两个数组最小的异或值之和](../../problems/minimum-xor-sum-of-two-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1815 | [得到新鲜甜甜圈的最多组数](../../problems/maximum-number-of-groups-getting-fresh-donuts) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] [[数论](../number-theory/README.md)] | Hard | +| 1755 | [最接近目标值的子序列和](../../problems/closest-subsequence-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1681 | [最小不兼容性](../../problems/minimum-incompatibility) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1659 | [最大化网格幸福感](../../problems/maximize-grid-happiness) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1494 | [并行课程 II](../../problems/parallel-courses-ii) | [[位运算](../bit-manipulation/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1434 | [每个人戴不同帽子的方案数](../../problems/number-of-ways-to-wear-different-hats-to-each-other) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1349 | [参加考试的最大学生数](../../problems/maximum-students-taking-exam) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1255 | [得分最高的单词集合](../../problems/maximum-score-words-formed-by-letters) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1125 | [最小的必要团队](../../problems/smallest-sufficient-team) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1066 | [校园自行车分配 II](../../problems/campus-bikes-ii) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 996 | [正方形数组的数目](../../problems/number-of-squareful-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 943 | [最短超级串](../../problems/find-the-shortest-superstring) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[位运算](../bit-manipulation/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 805 | [数组的均值分割](../../problems/split-array-with-same-average) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 638 | [大礼包](../../problems/shopping-offers) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 526 | [优美的排列](../../problems/beautiful-arrangement) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 473 | [火柴拼正方形](../../problems/matchsticks-to-square) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 464 | [我能赢吗](../../problems/can-i-win) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[博弈](../game-theory/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 2eadcd8ce..f68dc198e 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,9 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1926 | [迷宫中离入口最近的出口](../../problems/nearest-exit-from-entrance-in-maze) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1810 | [隐藏网格下的最小消耗路径](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1778 | [未知网格中的最短路径](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] | Medium | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | | 1765 | [地图中的最高点](../../problems/map-of-highest-peak) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | diff --git a/tag/bucket-sort/README.md b/tag/bucket-sort/README.md new file mode 100644 index 000000000..b136e2646 --- /dev/null +++ b/tag/bucket-sort/README.md @@ -0,0 +1,17 @@ + + + + + + + +## [话题分类](../README.md) > 桶排序 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 912 | [排序数组](../../problems/sort-an-array) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数排序](../counting-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[数组](../array/README.md)] [[桶排序](../bucket-sort/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 164 | [最大间距](../../problems/maximum-gap) | [[数组](../array/README.md)] [[桶排序](../bucket-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] | Hard | diff --git a/tag/combinatorics/README.md b/tag/combinatorics/README.md new file mode 100644 index 000000000..3f534b7e3 --- /dev/null +++ b/tag/combinatorics/README.md @@ -0,0 +1,21 @@ + + + + + + + +## [话题分类](../README.md) > 组合数学 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1866 | [恰有 K 根木棍可以看到的排列数目](../../problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1830 | [使字符串有序的最少操作次数](../../problems/minimum-number-of-operations-to-make-string-sorted) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1643 | [第 K 条最小指令](../../problems/kth-smallest-instructions) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[组合数学](../combinatorics/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Hard | +| 1359 | [有效的快递序列数目](../../problems/count-all-valid-pickup-and-delivery-options) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 920 | [播放列表的数量](../../problems/number-of-music-playlists) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 458 | [可怜的小猪](../../problems/poor-pigs) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 62 | [不同路径](../../problems/unique-paths) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | diff --git a/tag/concurrency/README.md b/tag/concurrency/README.md new file mode 100644 index 000000000..b06421577 --- /dev/null +++ b/tag/concurrency/README.md @@ -0,0 +1,20 @@ + + + + + + + +## [话题分类](../README.md) > 多线程 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1279 | [红绿灯路口](../../problems/traffic-light-controlled-intersection) 🔒 | [[多线程](../concurrency/README.md)] | Easy | +| 1242 | [多线程网页爬虫](../../problems/web-crawler-multithreaded) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[多线程](../concurrency/README.md)] | Medium | +| 1226 | [哲学家进餐](../../problems/the-dining-philosophers) | [[多线程](../concurrency/README.md)] | Medium | +| 1195 | [交替打印字符串](../../problems/fizz-buzz-multithreaded) | [[多线程](../concurrency/README.md)] | Medium | +| 1188 | [设计有限阻塞队列](../../problems/design-bounded-blocking-queue) 🔒 | [[多线程](../concurrency/README.md)] | Medium | +| 1117 | [H2O 生成](../../problems/building-h2o) | [[多线程](../concurrency/README.md)] | Medium | +| 1116 | [打印零与奇偶数](../../problems/print-zero-even-odd) | [[多线程](../concurrency/README.md)] | Medium | +| 1115 | [交替打印FooBar](../../problems/print-foobar-alternately) | [[多线程](../concurrency/README.md)] | Medium | +| 1114 | [按序打印](../../problems/print-in-order) | [[多线程](../concurrency/README.md)] | Easy | diff --git a/tag/counting-sort/README.md b/tag/counting-sort/README.md new file mode 100644 index 000000000..5fd0c4b31 --- /dev/null +++ b/tag/counting-sort/README.md @@ -0,0 +1,16 @@ + + + + + + + +## [话题分类](../README.md) > 计数排序 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1122 | [数组的相对排序](../../problems/relative-sort-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数排序](../counting-sort/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1051 | [高度检查器](../../problems/height-checker) | [[数组](../array/README.md)] [[计数排序](../counting-sort/README.md)] [[排序](../sorting/README.md)] | Easy | +| 912 | [排序数组](../../problems/sort-an-array) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数排序](../counting-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 561 | [数组拆分 I](../../problems/array-partition-i) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[计数排序](../counting-sort/README.md)] [[排序](../sorting/README.md)] | Easy | +| 274 | [H 指数](../../problems/h-index) | [[数组](../array/README.md)] [[计数排序](../counting-sort/README.md)] [[排序](../sorting/README.md)] | Medium | diff --git a/tag/counting/README.md b/tag/counting/README.md new file mode 100644 index 000000000..9e7cd4573 --- /dev/null +++ b/tag/counting/README.md @@ -0,0 +1,62 @@ + + + + + + + +## [话题分类](../README.md) > 计数 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1941 | [检查是否所有字符出现次数相同](../../problems/check-if-all-characters-have-equal-number-of-occurrences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1897 | [重新分配字符使所有字符串都相等](../../problems/redistribute-characters-to-make-all-strings-equal) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1876 | [长度为三且各字符不同的子字符串](../../problems/substrings-of-size-three-with-distinct-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | +| 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] [[计数](../counting/README.md)] | Hard | +| 1854 | [人口最多的年份](../../problems/maximum-population-year) | [[数组](../array/README.md)] [[计数](../counting/README.md)] | Easy | +| 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Hard | +| 1814 | [统计一个数组中好对子的数目](../../problems/count-nice-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] | Medium | +| 1790 | [仅执行一次字符串交换能否使两个字符串相等](../../problems/check-if-one-string-swap-can-make-strings-equal) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1781 | [所有子字符串美丽值之和](../../problems/sum-of-beauty-of-all-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 1775 | [通过最少操作次数使数组的和相等](../../problems/equal-sum-arrays-with-minimum-number-of-operations) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 1748 | [唯一元素的和](../../problems/sum-of-unique-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | +| 1742 | [盒子中小球的最大数量](../../problems/maximum-number-of-balls-in-a-box) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] | Easy | +| 1737 | [满足三条件之一需改变的最少字符数](../../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1704 | [判断字符串的两半是否相似](../../problems/determine-if-string-halves-are-alike) | [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1603 | [设计停车系统](../../problems/design-parking-system) | [[设计](../design/README.md)] [[计数](../counting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1512 | [好数对的数目](../../problems/number-of-good-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] | Easy | +| 1497 | [检查数组对是否可以被 k 整除](../../problems/check-if-array-pairs-are-divisible-by-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 1481 | [不同整数的最少数目](../../problems/least-number-of-unique-integers-after-k-removals) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1419 | [数青蛙](../../problems/minimum-number-of-frogs-croaking) | [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 1400 | [构造 K 个回文字符串](../../problems/construct-k-palindrome-strings) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 1394 | [找出数组中的幸运数](../../problems/find-lucky-integer-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | +| 1370 | [上升下降字符串](../../problems/increasing-decreasing-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1221 | [分割平衡字符串](../../problems/split-a-string-in-balanced-strings) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1213 | [三个有序数组的交集](../../problems/intersection-of-three-sorted-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[计数](../counting/README.md)] | Easy | +| 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[计数](../counting/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1189 | [“气球” 的最大数量](../../problems/maximum-number-of-balloons) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1128 | [等价多米诺骨牌对的数量](../../problems/number-of-equivalent-domino-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | +| 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1010 | [总持续时间可被 60 整除的歌曲](../../problems/pairs-of-songs-with-total-durations-divisible-by-60) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 945 | [使数组唯一的最小增量](../../problems/minimum-increment-to-make-array-unique) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 923 | [三数之和的多种可能](../../problems/3sum-with-multiplicity) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Easy | +| 900 | [RLE 迭代器](../../problems/rle-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 869 | [重新排序得到 2 的幂](../../problems/reordered-power-of-2) | [[数学](../math/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Medium | +| 767 | [重构字符串](../../problems/reorganize-string) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 387 | [字符串中的第一个唯一字符](../../problems/first-unique-character-in-a-string) | [[队列](../queue/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 383 | [赎金信](../../problems/ransom-note) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 299 | [猜数字游戏](../../problems/bulls-and-cows) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 229 | [求众数 II](../../problems/majority-element-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 169 | [多数元素](../../problems/majority-element) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | diff --git a/tag/data-stream/README.md b/tag/data-stream/README.md new file mode 100644 index 000000000..b733a60f3 --- /dev/null +++ b/tag/data-stream/README.md @@ -0,0 +1,25 @@ + + + + + + + +## [话题分类](../README.md) > 数据流 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] | Medium | +| 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] | Easy | +| 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 1429 | [第一个唯一数字](../../problems/first-unique-number) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] | Medium | +| 1352 | [最后 K 个数的乘积](../../problems/product-of-the-last-k-numbers) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[数据流](../data-stream/README.md)] | Medium | +| 1032 | [字符流](../../problems/stream-of-characters) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[数据流](../data-stream/README.md)] | Hard | +| 933 | [最近的请求次数](../../problems/number-of-recent-calls) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数据流](../data-stream/README.md)] | Easy | +| 901 | [股票价格跨度](../../problems/online-stock-span) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[数据流](../data-stream/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 642 | [设计搜索自动补全系统](../../problems/design-search-autocomplete-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[数据流](../data-stream/README.md)] | Hard | +| 346 | [数据流中的移动平均值](../../problems/moving-average-from-data-stream) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数据流](../data-stream/README.md)] | Easy | +| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[设计](../design/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index c52bc2ec7..93a6e9962 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,10 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1858 | [包含所有前缀的最长单词](../../problems/longest-word-with-all-prefixes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] | Medium | -| 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1810 | [隐藏网格下的最小消耗路径](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1778 | [未知网格中的最短路径](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] | Medium | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | | 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | @@ -147,7 +148,7 @@ | 590 | [N 叉树的后序遍历](../../problems/n-ary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 589 | [N 叉树的前序遍历](../../problems/n-ary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 572 | [另一个树的子树](../../problems/subtree-of-another-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] [[字符串匹配](../string-matching/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | +| 572 | [另一棵树的子树](../../problems/subtree-of-another-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] [[字符串匹配](../string-matching/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | | 565 | [数组嵌套](../../problems/array-nesting) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 559 | [N 叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index 72756360b..157509056 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -5,7 +5,7 @@ -## [话题分类](../README.md) > 分治算法 +## [话题分类](../README.md) > 分治 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | diff --git a/tag/doubly-linked-list/README.md b/tag/doubly-linked-list/README.md new file mode 100644 index 000000000..9cb65f12b --- /dev/null +++ b/tag/doubly-linked-list/README.md @@ -0,0 +1,18 @@ + + + + + + + +## [话题分类](../README.md) > 双向链表 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1472 | [设计浏览器历史记录](../../problems/design-browser-history) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 716 | [最大栈](../../problems/max-stack) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] [[有序集合](../ordered-set/README.md)] | Easy | +| 460 | [LFU 缓存](../../problems/lfu-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Hard | +| 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Hard | +| 430 | [扁平化多级双向链表](../../problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 667cc789c..f81e4f98e 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1947 | [最大兼容性评分和](../../problems/maximum-compatibility-score-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 1931 | [用三种不同颜色为网格涂色](../../problems/painting-a-grid-with-three-different-colors) | [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1928 | [规定时间内到达终点的最小花费](../../problems/minimum-cost-to-reach-destination-in-time) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1911 | [最大子序列交替和](../../problems/maximum-alternating-subsequence-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1908 | [Game of Nim](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | @@ -199,7 +202,7 @@ | 801 | [使序列递增的最小交换次数](../../problems/minimum-swaps-to-make-sequences-increasing) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 799 | [香槟塔](../../problems/champagne-tower) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 790 | [多米诺和托米诺平铺](../../problems/domino-and-tromino-tiling) | [[动态规划](../dynamic-programming/README.md)] | Medium | -| 788 | [旋转数字](../../problems/rotated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 788 | [旋转数字](../../problems/rotated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 764 | [最大加号标志](../../problems/largest-plus-sign) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 750 | [角矩形的数量](../../problems/number-of-corner-rectangles) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | diff --git a/tag/enumeration/README.md b/tag/enumeration/README.md new file mode 100644 index 000000000..06885e38c --- /dev/null +++ b/tag/enumeration/README.md @@ -0,0 +1,26 @@ + + + + + + + +## [话题分类](../README.md) > 枚举 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1925 | [统计平方和三元组的数目](../../problems/count-square-sum-triples) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Easy | +| 1620 | [网络信号最好的坐标](../../problems/coordinate-with-maximum-network-quality) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Medium | +| 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 1566 | [重复至少 K 次且长度为 M 的模式](../../problems/detect-pattern-of-length-m-repeated-k-or-more-times) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Easy | +| 1534 | [统计好三元组](../../problems/count-good-triplets) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Easy | +| 1291 | [顺次数](../../problems/sequential-digits) | [[枚举](../enumeration/README.md)] | Medium | +| 949 | [给定数字能组成的最大时间](../../problems/largest-time-for-given-digits) | [[字符串](../string/README.md)] [[枚举](../enumeration/README.md)] | Medium | +| 906 | [超级回文数](../../problems/super-palindromes) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 869 | [重新排序得到 2 的幂](../../problems/reordered-power-of-2) | [[数学](../math/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Medium | +| 845 | [数组中的最长山脉](../../problems/longest-mountain-in-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[枚举](../enumeration/README.md)] | Medium | +| 829 | [连续整数求和](../../problems/consecutive-numbers-sum) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 800 | [相似 RGB 颜色](../../problems/similar-rgb-color) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[枚举](../enumeration/README.md)] | Easy | +| 681 | [最近时刻](../../problems/next-closest-time) 🔒 | [[字符串](../string/README.md)] [[枚举](../enumeration/README.md)] | Medium | +| 204 | [计数质数](../../problems/count-primes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] [[数论](../number-theory/README.md)] | Easy | diff --git a/tag/eulerian-circuit/README.md b/tag/eulerian-circuit/README.md new file mode 100644 index 000000000..6f8aec228 --- /dev/null +++ b/tag/eulerian-circuit/README.md @@ -0,0 +1,13 @@ + + + + + + + +## [话题分类](../README.md) > 欧拉回路 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 753 | [破解保险箱](../../problems/cracking-the-safe) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | +| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Medium | diff --git a/tag/game-theory/README.md b/tag/game-theory/README.md new file mode 100644 index 000000000..ca413faec --- /dev/null +++ b/tag/game-theory/README.md @@ -0,0 +1,32 @@ + + + + + + + +## [话题分类](../README.md) > 博弈 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1927 | [求和游戏](../../problems/sum-game) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1908 | [Game of Nim](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1872 | [石子游戏 VIII](../../problems/stone-game-viii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 1728 | [猫和老鼠 II](../../problems/cat-and-mouse-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 1690 | [石子游戏 VII](../../problems/stone-game-vii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1686 | [石子游戏 VI](../../problems/stone-game-vi) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1563 | [石子游戏 V](../../problems/stone-game-v) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 1561 | [你可以获得的最大硬币数目](../../problems/maximum-number-of-coins-you-can-get) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1510 | [石子游戏 IV](../../problems/stone-game-iv) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 1406 | [石子游戏 III](../../problems/stone-game-iii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 1140 | [石子游戏 II](../../problems/stone-game-ii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1025 | [除数博弈](../../problems/divisor-game) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Easy | +| 913 | [猫和老鼠](../../problems/cat-and-mouse) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 877 | [石子游戏](../../problems/stone-game) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 843 | [猜猜这个单词](../../problems/guess-the-word) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] [[交互](../interactive/README.md)] | Hard | +| 810 | [黑板异或游戏](../../problems/chalkboard-xor-game) | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Hard | +| 486 | [预测赢家](../../problems/predict-the-winner) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 464 | [我能赢吗](../../problems/can-i-win) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 375 | [猜数字大小 II](../../problems/guess-number-higher-or-lower-ii) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 294 | [翻转游戏 II](../../problems/flip-game-ii) 🔒 | [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 292 | [Nim 游戏](../../problems/nim-game) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Easy | diff --git a/tag/graph/README.md b/tag/graph/README.md index 82fb6b4a0..b3bc559db 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,13 +9,14 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1928 | [规定时间内到达终点的最小花费](../../problems/minimum-cost-to-reach-destination-in-time) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] [[计数](../counting/README.md)] | Hard | -| 1810 | [Minimum Path Cost in a Hidden Grid](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1810 | [隐藏网格下的最小消耗路径](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1791 | [找出星型图的中心节点](../../problems/find-center-of-star-graph) | [[图](../graph/README.md)] | Easy | | 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1782 | [统计点对的数目](../../problems/count-pairs-of-nodes) | [[图](../graph/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 1778 | [Shortest Path in a Hidden Grid](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1778 | [未知网格中的最短路径](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] | Medium | | 1761 | [一个图中连通三元组的最小度数](../../problems/minimum-degree-of-a-connected-trio-in-a-graph) | [[图](../graph/README.md)] | Hard | | 1728 | [猫和老鼠 II](../../problems/cat-and-mouse-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | | 1724 | [检查边长度限制的路径是否存在 II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 85f9d22cc..3196bc6e1 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -5,10 +5,12 @@ -## [话题分类](../README.md) > 贪心算法 +## [话题分类](../README.md) > 贪心 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1946 | [子字符串突变后可能得到的最大整数](../../problems/largest-number-after-mutating-substring) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1927 | [求和游戏](../../problems/sum-game) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1903 | [字符串中的最大奇数](../../problems/largest-odd-number-in-string) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 1899 | [合并若干三元组以形成目标三元组](../../problems/merge-triplets-to-form-target-triplet) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/hash-function/README.md b/tag/hash-function/README.md new file mode 100644 index 000000000..c8f386f97 --- /dev/null +++ b/tag/hash-function/README.md @@ -0,0 +1,30 @@ + + + + + + + +## [话题分类](../README.md) > 哈希函数 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | +| 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1554 | [只有一个不同字符的字符串](../../problems/strings-differ-by-one-character) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1461 | [检查一个字符串是否包含所有长度为 K 的二进制子串](../../problems/check-if-a-string-contains-all-binary-codes-of-size-k) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1392 | [最长快乐前缀](../../problems/longest-happy-prefix) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1316 | [不同的循环子字符串](../../problems/distinct-echo-substrings) | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1147 | [段式回文](../../problems/longest-chunked-palindrome-decomposition) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1062 | [最长重复子串](../../problems/longest-repeating-substring) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 1044 | [最长重复子串](../../problems/longest-duplicate-substring) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | +| 706 | [设计哈希映射](../../problems/design-hashmap) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | +| 705 | [设计哈希集合](../../problems/design-hashset) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | +| 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Medium | +| 572 | [另一棵树的子树](../../problems/subtree-of-another-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] [[字符串匹配](../string-matching/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | +| 535 | [TinyURL 的加密与解密](../../problems/encode-and-decode-tinyurl) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Medium | +| 214 | [最短回文串](../../problems/shortest-palindrome) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 187 | [重复的DNA序列](../../problems/repeated-dna-sequences) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 38e4d93f0..a998336f9 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,6 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | +| 1941 | [检查是否所有字符出现次数相同](../../problems/check-if-all-characters-have-equal-number-of-occurrences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1935 | [可以输入的最大单词数](../../problems/maximum-number-of-words-you-can-type) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | +| 1930 | [长度为 3 的不同回文子序列](../../problems/unique-length-3-palindromic-subsequences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1915 | [最美子字符串的数目](../../problems/number-of-wonderful-substrings) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1906 | [查询差绝对值的最小值](../../problems/minimum-absolute-difference-queries) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | @@ -173,7 +178,7 @@ | 911 | [在线选举](../../problems/online-election) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 904 | [水果成篮](../../problems/fruit-into-baskets) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | -| 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | diff --git a/tag/heap-priority-queue/README.md b/tag/heap-priority-queue/README.md new file mode 100644 index 000000000..41b09f43f --- /dev/null +++ b/tag/heap-priority-queue/README.md @@ -0,0 +1,104 @@ + + + + + + + +## [话题分类](../README.md) > 堆(优先队列) + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1942 | [最小未被占据椅子的编号](../../problems/the-number-of-the-smallest-unoccupied-chair) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1882 | [使用服务器处理任务](../../problems/process-tasks-using-servers) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1878 | [矩阵中最大的三个菱形和](../../problems/get-biggest-three-rhombus-sums-in-a-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1851 | [包含每个查询的最小区间](../../problems/minimum-interval-to-include-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[扫描线](../line-sweep/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1845 | [座位预约管理系统](../../problems/seat-reservation-manager) | [[设计](../design/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1834 | [单线程 CPU](../../problems/single-threaded-cpu) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1810 | [隐藏网格下的最小消耗路径](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1792 | [最大平均通过率](../../problems/maximum-average-pass-ratio) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1776 | [车队 II](../../problems/car-fleet-ii) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[单调栈](../monotonic-stack/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1753 | [移除石子的最大得分](../../problems/maximum-score-from-removing-stones) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1738 | [找出第 K 大的异或坐标值](../../problems/find-kth-largest-xor-coordinate-value) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[快速选择](../quickselect/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1705 | [吃苹果的最大数目](../../problems/maximum-number-of-eaten-apples) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1696 | [跳跃游戏 VI](../../problems/jump-game-vi) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1686 | [石子游戏 VI](../../problems/stone-game-vi) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1642 | [可以到达的最远建筑](../../problems/furthest-building-you-can-reach) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1488 | [避免洪水泛滥](../../problems/avoid-flood-in-the-city) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1464 | [数组中两元素的最大乘积](../../problems/maximum-product-of-two-elements-in-an-array) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 1439 | [有序矩阵中的第 k 个最小数组和](../../problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1425 | [带限制的子序列和](../../problems/constrained-subsequence-sum) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1405 | [最长快乐字符串](../../problems/longest-happy-string) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1388 | [3n 块披萨](../../problems/pizza-with-3n-slices) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1354 | [多次求和构造目标数组](../../problems/construct-target-array-with-multiple-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1353 | [最多可以参加的会议数目](../../problems/maximum-number-of-events-that-can-be-attended) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1337 | [矩阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 1263 | [推箱子](../../problems/minimum-moves-to-move-a-box-to-their-target-location) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1199 | [建造街区的最短时间](../../problems/minimum-time-to-build-blocks) 🔒 | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1183 | [矩阵中 1 的最大数量](../../problems/maximum-number-of-ones) 🔒 | [[贪心](../greedy/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1172 | [餐盘栈](../../problems/dinner-plate-stacks) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1167 | [连接棒材的最低费用](../../problems/minimum-cost-to-connect-sticks) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1135 | [最低成本联通所有城市](../../problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1094 | [拼车](../../problems/car-pooling) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1046 | [最后一块石头的重量](../../problems/last-stone-weight) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 912 | [排序数组](../../problems/sort-an-array) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数排序](../counting-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 882 | [细分图中的可到达结点](../../problems/reachable-nodes-in-subdivided-graph) | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 871 | [最低加油次数](../../problems/minimum-number-of-refueling-stops) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 767 | [重构字符串](../../problems/reorganize-string) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 743 | [网络延迟时间](../../problems/network-delay-time) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 703 | [数据流中的第 K 大元素](../../problems/kth-largest-element-in-a-stream) | [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[数据流](../data-stream/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 675 | [为高尔夫比赛砍树](../../problems/cut-off-trees-for-golf-event) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 658 | [找到 K 个最接近的元素](../../problems/find-k-closest-elements) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 630 | [课程表 III](../../problems/course-schedule-iii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 506 | [相对名次](../../problems/relative-ranks) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 505 | [迷宫 II](../../problems/the-maze-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 502 | [IPO](../../problems/ipo) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 499 | [迷宫 III](../../problems/the-maze-iii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 480 | [滑动窗口中位数](../../problems/sliding-window-median) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 420 | [强密码检验器](../../problems/strong-password-checker) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 373 | [查找和最小的K对数字](../../problems/find-k-pairs-with-smallest-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 355 | [设计推特](../../problems/design-twitter) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 313 | [超级丑数](../../problems/super-ugly-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[设计](../design/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 264 | [丑数 II](../../problems/ugly-number-ii) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[扫描线](../line-sweep/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 215 | [数组中的第K个最大元素](../../problems/kth-largest-element-in-an-array) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | diff --git a/tag/interactive/README.md b/tag/interactive/README.md new file mode 100644 index 000000000..d089e633f --- /dev/null +++ b/tag/interactive/README.md @@ -0,0 +1,29 @@ + + + + + + + +## [话题分类](../README.md) > 交互 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1810 | [隐藏网格下的最小消耗路径](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1778 | [未知网格中的最短路径](../../problems/shortest-path-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1618 | [找出适应屏幕的最大字号](../../problems/maximum-font-to-fit-a-sentence-in-a-screen) 🔒 | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1538 | [找出隐藏数组中出现次数最多的元素](../../problems/guess-the-majority-in-a-hidden-array) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1533 | [找到最大整数的索引](../../problems/find-the-index-of-the-large-integer) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1428 | [至少有一个 1 的最左端列](../../problems/leftmost-column-with-at-least-a-one) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1274 | [矩形内船只的数目](../../problems/number-of-ships-in-a-rectangle) 🔒 | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[交互](../interactive/README.md)] | Hard | +| 1237 | [找出给定方程的正整数解](../../problems/find-positive-integer-solution-for-a-given-equation) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1236 | [网络爬虫](../../problems/web-crawler) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[交互](../interactive/README.md)] | Medium | +| 1095 | [山脉数组中查找目标值](../../problems/find-in-mountain-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Hard | +| 843 | [猜猜这个单词](../../problems/guess-the-word) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] [[交互](../interactive/README.md)] | Hard | +| 702 | [搜索长度未知的有序数组](../../problems/search-in-a-sorted-array-of-unknown-size) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Medium | +| 489 | [扫地机器人](../../problems/robot-room-cleaner) 🔒 | [[回溯](../backtracking/README.md)] [[交互](../interactive/README.md)] | Hard | +| 374 | [猜数字大小](../../problems/guess-number-higher-or-lower) | [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Easy | +| 278 | [第一个错误的版本](../../problems/first-bad-version) | [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] | Easy | +| 277 | [搜寻名人](../../problems/find-the-celebrity) 🔒 | [[贪心](../greedy/README.md)] [[图](../graph/README.md)] [[双指针](../two-pointers/README.md)] [[交互](../interactive/README.md)] | Medium | +| 158 | [用 Read4 读取 N 个字符 II](../../problems/read-n-characters-given-read4-ii-call-multiple-times) 🔒 | [[字符串](../string/README.md)] [[交互](../interactive/README.md)] [[模拟](../simulation/README.md)] | Hard | +| 157 | [用 Read4 读取 N 个字符](../../problems/read-n-characters-given-read4) 🔒 | [[字符串](../string/README.md)] [[交互](../interactive/README.md)] [[模拟](../simulation/README.md)] | Easy | diff --git a/tag/iterator/README.md b/tag/iterator/README.md new file mode 100644 index 000000000..c1750d402 --- /dev/null +++ b/tag/iterator/README.md @@ -0,0 +1,20 @@ + + + + + + + +## [话题分类](../README.md) > 迭代器 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 1286 | [字母组合迭代器](../../problems/iterator-for-combination) | [[设计](../design/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 900 | [RLE 迭代器](../../problems/rle-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[迭代器](../iterator/README.md)] | Easy | +| 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md index 35972eeea..ca06abe3c 100644 --- a/tag/line-sweep/README.md +++ b/tag/line-sweep/README.md @@ -5,7 +5,7 @@ -## [话题分类](../README.md) > Line Sweep +## [话题分类](../README.md) > 扫描线 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | diff --git a/tag/math/README.md b/tag/math/README.md index e7888d8a3..f81a63f18 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1954 | [收集足够苹果的最小花园周长](../../problems/minimum-garden-perimeter-to-collect-enough-apples) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1927 | [求和游戏](../../problems/sum-game) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1925 | [统计平方和三元组的数目](../../problems/count-square-sum-triples) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 1922 | [统计好数字的数目](../../problems/count-good-numbers) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1908 | [Game of Nim](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | @@ -189,7 +192,7 @@ | 800 | [相似 RGB 颜色](../../problems/similar-rgb-color) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 793 | [阶乘函数后 K 个零](../../problems/preimage-size-of-factorial-zeroes-function) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 789 | [逃脱阻碍者](../../problems/escape-the-ghosts) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 788 | [旋转数字](../../problems/rotated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 788 | [旋转数字](../../problems/rotated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 780 | [到达终点](../../problems/reaching-points) | [[数学](../math/README.md)] | Hard | @@ -295,7 +298,7 @@ | 202 | [快乐数](../../problems/happy-number) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 189 | [旋转数组](../../problems/rotate-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 172 | [阶乘后的零](../../problems/factorial-trailing-zeroes) | [[数学](../math/README.md)] | Easy | -| 171 | [Excel表列序号](../../problems/excel-sheet-column-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 171 | [Excel 表列序号](../../problems/excel-sheet-column-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 168 | [Excel表列名称](../../problems/excel-sheet-column-title) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/matrix/README.md b/tag/matrix/README.md new file mode 100644 index 000000000..ed67c415d --- /dev/null +++ b/tag/matrix/README.md @@ -0,0 +1,151 @@ + + + + + + + +## [话题分类](../README.md) > 矩阵 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1926 | [迷宫中离入口最近的出口](../../problems/nearest-exit-from-entrance-in-maze) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1914 | [循环轮转矩阵](../../problems/cyclically-rotating-a-grid) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1901 | [找出顶峰元素 II](../../problems/find-a-peak-element-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1895 | [最大的幻方](../../problems/largest-magic-square) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1886 | [判断矩阵经轮转后是否一致](../../problems/determine-whether-matrix-can-be-obtained-by-rotation) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 1878 | [矩阵中最大的三个菱形和](../../problems/get-biggest-three-rhombus-sums-in-a-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1861 | [旋转盒子](../../problems/rotating-the-box) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1820 | [最多邀请的个数](../../problems/maximum-number-of-accepted-invitations) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1765 | [地图中的最高点](../../problems/map-of-highest-peak) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1738 | [找出第 K 大的异或坐标值](../../problems/find-kth-largest-xor-coordinate-value) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[快速选择](../quickselect/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1730 | [获取食物的最短路径](../../problems/shortest-path-to-get-food) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1727 | [重新排列后的最大子矩阵](../../problems/largest-submatrix-with-rearrangements) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1706 | [球会落何处](../../problems/where-will-the-ball-fall) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1672 | [最富有客户的资产总量](../../problems/richest-customer-wealth) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 1632 | [矩阵转换后的秩](../../problems/rank-transform-of-a-matrix) | [[贪心](../greedy/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1605 | [给定行和列的和求可行矩阵](../../problems/find-valid-matrix-given-row-and-column-sums) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1591 | [奇怪的打印机 II](../../problems/strange-printer-ii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1582 | [二进制矩阵中的特殊位置](../../problems/special-positions-in-a-binary-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 1572 | [矩阵对角线元素的和](../../problems/matrix-diagonal-sum) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 1568 | [使陆地分离的最少天数](../../problems/minimum-number-of-days-to-disconnect-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[强连通分量](../strongly-connected-component/README.md)] | Hard | +| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1504 | [统计全 1 子矩形](../../problems/count-submatrices-with-all-ones) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1476 | [子矩形查询](../../problems/subrectangle-queries) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1463 | [摘樱桃 II](../../problems/cherry-pickup-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1444 | [切披萨的方案数](../../problems/number-of-ways-of-cutting-a-pizza) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1439 | [有序矩阵中的第 k 个最小数组和](../../problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1428 | [至少有一个 1 的最左端列](../../problems/leftmost-column-with-at-least-a-one) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[交互](../interactive/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1380 | [矩阵中的幸运数](../../problems/lucky-numbers-in-a-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1351 | [统计有序矩阵中的负数](../../problems/count-negative-numbers-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 1349 | [参加考试的最大学生数](../../problems/maximum-students-taking-exam) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1337 | [矩阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 1329 | [将矩阵按对角线排序](../../problems/sort-the-matrix-diagonally) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1314 | [矩阵区域和](../../problems/matrix-block-sum) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1301 | [最大得分的路径数目](../../problems/number-of-paths-with-max-score) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1293 | [网格中的最短路径](../../problems/shortest-path-in-a-grid-with-obstacles-elimination) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1289 | [下降路径最小和 II](../../problems/minimum-falling-path-sum-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1284 | [转化为全零矩阵的最少反转次数](../../problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix) | [[位运算](../bit-manipulation/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1277 | [统计全为 1 的正方形子矩阵](../../problems/count-square-submatrices-with-all-ones) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1275 | [找出井字棋的获胜者](../../problems/find-winner-on-a-tic-tac-toe-game) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1267 | [统计参与通信的服务器](../../problems/count-servers-that-communicate) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1263 | [推箱子](../../problems/minimum-moves-to-move-a-box-to-their-target-location) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1260 | [二维网格迁移](../../problems/shift-2d-grid) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1254 | [统计封闭岛屿的数目](../../problems/number-of-closed-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1253 | [重构 2 行二进制矩阵](../../problems/reconstruct-a-2-row-binary-matrix) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1222 | [可以攻击国王的皇后](../../problems/queens-that-can-attack-the-king) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1219 | [黄金矿工](../../problems/path-with-maximum-gold) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1210 | [穿过迷宫的最少移动次数](../../problems/minimum-moves-to-reach-target-with-rotations) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1198 | [找出所有行中最小公共元素](../../problems/find-smallest-common-element-in-all-rows) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[计数](../counting/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1139 | [最大的以 1 为边界的正方形](../../problems/largest-1-bordered-square) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1091 | [二进制矩阵中的最短路径](../../problems/shortest-path-in-binary-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 1072 | [按列翻转得到最大值等行数](../../problems/flip-columns-for-maximum-number-of-equal-rows) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1020 | [飞地的数量](../../problems/number-of-enclaves) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 999 | [可以被一步捕获的棋子数](../../problems/available-captures-for-rook) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 994 | [腐烂的橘子](../../problems/rotting-oranges) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 980 | [不同路径 III](../../problems/unique-paths-iii) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 934 | [最短的桥](../../problems/shortest-bridge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 931 | [下降路径最小和](../../problems/minimum-falling-path-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 928 | [尽量减少恶意软件的传播 II](../../problems/minimize-malware-spread-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 924 | [尽量减少恶意软件的传播](../../problems/minimize-malware-spread) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 909 | [蛇梯棋](../../problems/snakes-and-ladders) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 892 | [三维形体的表面积](../../problems/surface-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 885 | [螺旋矩阵 III](../../problems/spiral-matrix-iii) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 883 | [三维形体投影面积](../../problems/projection-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 867 | [转置矩阵](../../problems/transpose-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 861 | [翻转矩阵后的得分](../../problems/score-after-flipping-matrix) | [[贪心](../greedy/README.md)] [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 840 | [矩阵中的幻方](../../problems/magic-squares-in-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 835 | [图像重叠](../../problems/image-overlap) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 832 | [翻转图像](../../problems/flipping-an-image) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 827 | [最大人工岛](../../problems/making-a-large-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 807 | [保持城市天际线](../../problems/max-increase-to-keep-city-skyline) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 803 | [打砖块](../../problems/bricks-falling-when-hit) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 773 | [滑动谜题](../../problems/sliding-puzzle) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 766 | [托普利茨矩阵](../../problems/toeplitz-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 750 | [角矩形的数量](../../problems/number-of-corner-rectangles) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 749 | [隔离病毒](../../problems/contain-virus) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Hard | +| 741 | [摘樱桃](../../problems/cherry-pickup) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 733 | [图像渲染](../../problems/flood-fill) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 695 | [岛屿的最大面积](../../problems/max-area-of-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 675 | [为高尔夫比赛砍树](../../problems/cut-off-trees-for-golf-event) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 661 | [图片平滑器](../../problems/image-smoother) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 568 | [最大休假天数](../../problems/maximum-vacation-days) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 566 | [重塑矩阵](../../problems/reshape-the-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 562 | [矩阵中最长的连续1线段](../../problems/longest-line-of-consecutive-one-in-matrix) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 542 | [01 矩阵](../../problems/01-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 533 | [孤独像素 II](../../problems/lonely-pixel-ii) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 531 | [孤独像素 I](../../problems/lonely-pixel-i) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 529 | [扫雷游戏](../../problems/minesweeper) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 498 | [对角线遍历](../../problems/diagonal-traverse) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 463 | [岛屿的周长](../../problems/island-perimeter) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 427 | [建立四叉树](../../problems/construct-quad-tree) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 422 | [有效的单词方块](../../problems/valid-word-square) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 419 | [甲板上的战舰](../../problems/battleships-in-a-board) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 417 | [太平洋大西洋水流问题](../../problems/pacific-atlantic-water-flow) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 361 | [轰炸敌人](../../problems/bomb-enemy) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 353 | [贪吃蛇](../../problems/design-snake-game) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 348 | [设计井字棋](../../problems/design-tic-tac-toe) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 317 | [离建筑物最近的距离](../../problems/shortest-distance-from-all-buildings) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 311 | [稀疏矩阵的乘法](../../problems/sparse-matrix-multiplication) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 308 | [二维区域和检索 - 可变](../../problems/range-sum-query-2d-mutable) 🔒 | [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 304 | [二维区域和检索 - 矩阵不可变](../../problems/range-sum-query-2d-immutable) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 302 | [包含全部黑色像素的最小矩形](../../problems/smallest-rectangle-enclosing-black-pixels) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Hard | +| 289 | [生命游戏](../../problems/game-of-life) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 286 | [墙与门](../../problems/walls-and-gates) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 221 | [最大正方形](../../problems/maximal-square) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 174 | [地下城游戏](../../problems/dungeon-game) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 79 | [单词搜索](../../problems/word-search) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 74 | [搜索二维矩阵](../../problems/search-a-2d-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 73 | [矩阵置零](../../problems/set-matrix-zeroes) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 64 | [最小路径和](../../problems/minimum-path-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 63 | [不同路径 II](../../problems/unique-paths-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 59 | [螺旋矩阵 II](../../problems/spiral-matrix-ii) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 54 | [螺旋矩阵](../../problems/spiral-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 48 | [旋转图像](../../problems/rotate-image) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 37 | [解数独](../../problems/sudoku-solver) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 36 | [有效的数独](../../problems/valid-sudoku) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | diff --git a/tag/memoization/README.md b/tag/memoization/README.md index 8c1157c83..fa0ddeaed 100644 --- a/tag/memoization/README.md +++ b/tag/memoization/README.md @@ -5,7 +5,7 @@ -## [话题分类](../README.md) > 记忆化 +## [话题分类](../README.md) > 记忆化搜索 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | diff --git a/tag/merge-sort/README.md b/tag/merge-sort/README.md new file mode 100644 index 000000000..7c05fa549 --- /dev/null +++ b/tag/merge-sort/README.md @@ -0,0 +1,18 @@ + + + + + + + +## [话题分类](../README.md) > 归并排序 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 912 | [排序数组](../../problems/sort-an-array) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数排序](../counting-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 493 | [翻转对](../../problems/reverse-pairs) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 148 | [排序链表](../../problems/sort-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[分治](../divide-and-conquer/README.md)] [[排序](../sorting/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | diff --git a/tag/minimum-spanning-tree/README.md b/tag/minimum-spanning-tree/README.md new file mode 100644 index 000000000..936ea815d --- /dev/null +++ b/tag/minimum-spanning-tree/README.md @@ -0,0 +1,16 @@ + + + + + + + +## [话题分类](../README.md) > 最小生成树 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1724 | [检查边长度限制的路径是否存在 II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] | Hard | +| 1584 | [连接所有点的最小费用](../../problems/min-cost-to-connect-all-points) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] | Medium | +| 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] [[排序](../sorting/README.md)] [[强连通分量](../strongly-connected-component/README.md)] | Hard | +| 1168 | [水资源分配优化](../../problems/optimize-water-distribution-in-a-village) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] | Hard | +| 1135 | [最低成本联通所有城市](../../problems/connecting-cities-with-minimum-cost) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/monotonic-queue/README.md b/tag/monotonic-queue/README.md new file mode 100644 index 000000000..1b001c2c8 --- /dev/null +++ b/tag/monotonic-queue/README.md @@ -0,0 +1,19 @@ + + + + + + + +## [话题分类](../README.md) > 单调队列 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1696 | [跳跃游戏 VI](../../problems/jump-game-vi) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1425 | [带限制的子序列和](../../problems/constrained-subsequence-sum) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 918 | [环形子数组的最大和](../../problems/maximum-sum-circular-subarray) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] | Medium | +| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 239 | [滑动窗口最大值](../../problems/sliding-window-maximum) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | diff --git a/tag/monotonic-stack/README.md b/tag/monotonic-stack/README.md new file mode 100644 index 000000000..e920c5a7c --- /dev/null +++ b/tag/monotonic-stack/README.md @@ -0,0 +1,46 @@ + + + + + + + +## [话题分类](../README.md) > 单调栈 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1944 | [队列中可以看到的人数](../../problems/number-of-visible-people-in-a-queue) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 1776 | [车队 II](../../problems/car-fleet-ii) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[单调栈](../monotonic-stack/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1762 | [能看到海景的建筑物](../../problems/buildings-with-an-ocean-view) 🔒 | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 1504 | [统计全 1 子矩形](../../problems/count-submatrices-with-all-ones) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1475 | [商品折扣后的最终价格](../../problems/final-prices-with-a-special-discount-in-a-shop) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Easy | +| 1130 | [叶值的最小代价生成树](../../problems/minimum-cost-tree-from-leaf-values) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1124 | [表现良好的最长时间段](../../problems/longest-well-performing-interval) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1081 | [不同字符的最小子序列](../../problems/smallest-subsequence-of-distinct-characters) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1063 | [有效子数组的数目](../../problems/number-of-valid-subarrays) 🔒 | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 1019 | [链表中的下一个更大节点](../../problems/next-greater-node-in-linked-list) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1008 | [前序遍历构造二叉搜索树](../../problems/construct-binary-search-tree-from-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[有序集合](../ordered-set/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 962 | [最大宽度坡](../../problems/maximum-width-ramp) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 907 | [子数组的最小值之和](../../problems/sum-of-subarray-minimums) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 901 | [股票价格跨度](../../problems/online-stock-span) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 769 | [最多能完成排序的块](../../problems/max-chunks-to-make-sorted) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 768 | [最多能完成排序的块 II](../../problems/max-chunks-to-make-sorted-ii) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 654 | [最大二叉树](../../problems/maximum-binary-tree) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 581 | [最短无序连续子数组](../../problems/shortest-unsorted-continuous-subarray) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 503 | [下一个更大元素 II](../../problems/next-greater-element-ii) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 496 | [下一个更大元素 I](../../problems/next-greater-element-i) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[单调栈](../monotonic-stack/README.md)] | Easy | +| 456 | [132 模式](../../problems/132-pattern) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 402 | [移掉 K 位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 321 | [拼接最大数](../../problems/create-maximum-number) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 316 | [去除重复字母](../../problems/remove-duplicate-letters) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 85 | [最大矩形](../../problems/maximal-rectangle) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 84 | [柱状图中最大的矩形](../../problems/largest-rectangle-in-histogram) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | diff --git a/tag/number-theory/README.md b/tag/number-theory/README.md new file mode 100644 index 000000000..33b9d5b88 --- /dev/null +++ b/tag/number-theory/README.md @@ -0,0 +1,18 @@ + + + + + + + +## [话题分类](../README.md) > 数论 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Hard | +| 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] [[数论](../number-theory/README.md)] | Hard | +| 1250 | [检查「好数组」](../../problems/check-if-it-is-a-good-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[数论](../number-theory/README.md)] | Hard | +| 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[数论](../number-theory/README.md)] | Medium | +| 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Easy | +| 258 | [各位相加](../../problems/add-digits) | [[数学](../math/README.md)] [[数论](../number-theory/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 204 | [计数质数](../../problems/count-primes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] [[数论](../number-theory/README.md)] | Easy | diff --git a/tag/ordered-set/README.md b/tag/ordered-set/README.md new file mode 100644 index 000000000..52b43d8b0 --- /dev/null +++ b/tag/ordered-set/README.md @@ -0,0 +1,44 @@ + + + + + + + +## [话题分类](../README.md) > 有序集合 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1942 | [最小未被占据椅子的编号](../../problems/the-number-of-the-smallest-unoccupied-chair) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1438 | [绝对差不超过限制的最长连续子数组](../../problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1418 | [点菜展示表](../../problems/display-table-of-food-orders-in-a-restaurant) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] | Medium | +| 975 | [奇偶跳](../../problems/odd-even-jump) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[有序集合](../ordered-set/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 855 | [考场就座](../../problems/exam-room) | [[设计](../design/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[扫描线](../line-sweep/README.md)] | Hard | +| 732 | [我的日程安排表 III](../../problems/my-calendar-iii) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 731 | [我的日程安排表 II](../../problems/my-calendar-ii) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 729 | [我的日程安排表 I](../../problems/my-calendar-i) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 716 | [最大栈](../../problems/max-stack) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] [[有序集合](../ordered-set/README.md)] | Easy | +| 715 | [Range 模块](../../problems/range-module) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 699 | [掉落的方块](../../problems/falling-squares) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 683 | [K 个关闭的灯泡](../../problems/k-empty-slots) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 635 | [设计日志存储系统](../../problems/design-log-storage-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[水塘抽样](../reservoir-sampling/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 493 | [翻转对](../../problems/reverse-pairs) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 456 | [132 模式](../../problems/132-pattern) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 352 | [将数据流变为多个不相交区间](../../problems/data-stream-as-disjoint-intervals) | [[设计](../design/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 327 | [区间和的个数](../../problems/count-of-range-sum) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 315 | [计算右侧小于当前元素的个数](../../problems/count-of-smaller-numbers-after-self) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | +| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[数组](../array/README.md)] [[桶排序](../bucket-sort/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 218 | [天际线问题](../../problems/the-skyline-problem) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[扫描线](../line-sweep/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | diff --git a/tag/prefix-sum/README.md b/tag/prefix-sum/README.md new file mode 100644 index 000000000..559b90b75 --- /dev/null +++ b/tag/prefix-sum/README.md @@ -0,0 +1,72 @@ + + + + + + + +## [话题分类](../README.md) > 前缀和 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1943 | [描述绘画结果](../../problems/describe-the-painting) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1930 | [长度为 3 的不同回文子序列](../../problems/unique-length-3-palindromic-subsequences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1915 | [最美子字符串的数目](../../problems/number-of-wonderful-substrings) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1895 | [最大的幻方](../../problems/largest-magic-square) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1894 | [找到需要补充粉笔的学生编号](../../problems/find-the-student-that-will-replace-the-chalk) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1893 | [检查是否区域内所有整数都被覆盖](../../problems/check-if-all-the-integers-in-a-range-are-covered) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | +| 1889 | [装包裹的最小浪费空间](../../problems/minimum-space-wasted-from-packaging) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1878 | [矩阵中最大的三个菱形和](../../problems/get-biggest-three-rhombus-sums-in-a-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1872 | [石子游戏 VIII](../../problems/stone-game-viii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 1871 | [跳跃游戏 VII](../../problems/jump-game-vii) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1862 | [向下取整数对和](../../problems/sum-of-floored-pairs) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1838 | [最高频元素的频数](../../problems/frequency-of-the-most-frequent-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1829 | [每个查询的最大异或值](../../problems/maximum-xor-for-each-query) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1788 | [最大化花园的美观度](../../problems/maximize-the-beauty-of-the-garden) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 1744 | [你能在你最喜欢的那天吃到你最喜欢的糖果吗?](../../problems/can-you-eat-your-favorite-candy-on-your-favorite-day) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1738 | [找出第 K 大的异或坐标值](../../problems/find-kth-largest-xor-coordinate-value) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[快速选择](../quickselect/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1737 | [满足三条件之一需改变的最少字符数](../../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1732 | [找到最高海拔](../../problems/find-the-highest-altitude) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | +| 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1703 | [得到连续 K 个 1 的最少相邻交换次数](../../problems/minimum-adjacent-swaps-for-k-consecutive-ones) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 1685 | [有序数组中差绝对值之和](../../problems/sum-of-absolute-differences-in-a-sorted-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1674 | [使数组互补的最少操作次数](../../problems/minimum-moves-to-make-array-complementary) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1589 | [所有排列中的最大和](../../problems/maximum-sum-obtained-of-any-permutation) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1588 | [所有奇数长度子数组的和](../../problems/sum-of-all-odd-length-subarrays) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | +| 1546 | [和为目标值且不重叠的非空子数组的最大数目](../../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1480 | [一维数组的动态和](../../problems/running-sum-of-1d-array) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | +| 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1423 | [可获得的最大点数](../../problems/maximum-points-you-can-obtain-from-cards) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1413 | [逐步求和得到正数的最小值](../../problems/minimum-value-to-get-positive-step-by-step-sum) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | +| 1371 | [每个元音包含偶数次的最长子字符串](../../problems/find-the-longest-substring-containing-vowels-in-even-counts) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1314 | [矩阵区域和](../../problems/matrix-block-sum) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1310 | [子数组异或查询](../../problems/xor-queries-of-a-subarray) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1292 | [元素和小于等于阈值的正方形的最大边长](../../problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1208 | [尽可能使字符串相等](../../problems/get-equal-substrings-within-budget) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1177 | [构建回文串检测](../../problems/can-make-palindrome-from-substring) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1124 | [表现良好的最长时间段](../../problems/longest-well-performing-interval) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1109 | [航班预订统计](../../problems/corporate-flight-bookings) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1094 | [拼车](../../problems/car-pooling) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 995 | [K 连续位的最小翻转次数](../../problems/minimum-number-of-k-consecutive-bit-flips) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 974 | [和可被 K 整除的子数组](../../problems/subarray-sums-divisible-by-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 798 | [得分最高的最小轮调](../../problems/smallest-rotation-with-highest-score) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 724 | [寻找数组的中心下标](../../problems/find-pivot-index) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | +| 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 548 | [将数组分割成和相等的子数组](../../problems/split-array-with-equal-sum) 🔒 | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 525 | [连续数组](../../problems/contiguous-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 523 | [连续的子数组和](../../problems/continuous-subarray-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[水塘抽样](../reservoir-sampling/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 370 | [区间加法](../../problems/range-addition) 🔒 | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 304 | [二维区域和检索 - 矩阵不可变](../../problems/range-sum-query-2d-immutable) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 303 | [区域和检索 - 数组不可变](../../problems/range-sum-query-immutable) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | +| 238 | [除自身以外数组的乘积](../../problems/product-of-array-except-self) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | diff --git a/tag/probability-and-statistics/README.md b/tag/probability-and-statistics/README.md new file mode 100644 index 000000000..b2b07bfb3 --- /dev/null +++ b/tag/probability-and-statistics/README.md @@ -0,0 +1,18 @@ + + + + + + + +## [话题分类](../README.md) > 概率与统计 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[组合数学](../combinatorics/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Hard | +| 1230 | [抛掷硬币](../../problems/toss-strange-coins) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 837 | [新21点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 808 | [分汤](../../problems/soup-servings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[数学](../math/README.md)] [[拒绝采样](../rejection-sampling/README.md)] [[概率与统计](../probability-and-statistics/README.md)] [[随机化](../randomized/README.md)] | Medium | diff --git a/tag/quickselect/README.md b/tag/quickselect/README.md new file mode 100644 index 000000000..d118466b4 --- /dev/null +++ b/tag/quickselect/README.md @@ -0,0 +1,16 @@ + + + + + + + +## [话题分类](../README.md) > 快速选择 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1738 | [找出第 K 大的异或坐标值](../../problems/find-kth-largest-xor-coordinate-value) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[快速选择](../quickselect/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 324 | [摆动排序 II](../../problems/wiggle-sort-ii) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] | Medium | +| 215 | [数组中的第K个最大元素](../../problems/kth-largest-element-in-an-array) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/radix-sort/README.md b/tag/radix-sort/README.md new file mode 100644 index 000000000..c7e8486e7 --- /dev/null +++ b/tag/radix-sort/README.md @@ -0,0 +1,13 @@ + + + + + + + +## [话题分类](../README.md) > 基数排序 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 912 | [排序数组](../../problems/sort-an-array) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数排序](../counting-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 164 | [最大间距](../../problems/maximum-gap) | [[数组](../array/README.md)] [[桶排序](../bucket-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] | Hard | diff --git a/tag/randomized/README.md b/tag/randomized/README.md new file mode 100644 index 000000000..3e12f223b --- /dev/null +++ b/tag/randomized/README.md @@ -0,0 +1,23 @@ + + + + + + + +## [话题分类](../README.md) > 随机化 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1515 | [服务中心的最佳位置](../../problems/best-position-for-a-service-centre) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Hard | +| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[随机化](../randomized/README.md)] | Hard | +| 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 519 | [随机翻转矩阵](../../problems/random-flip-matrix) | [[水塘抽样](../reservoir-sampling/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[水塘抽样](../reservoir-sampling/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 478 | [在圆内随机生成点](../../problems/generate-random-point-in-a-circle) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] [[拒绝采样](../rejection-sampling/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[数学](../math/README.md)] [[拒绝采样](../rejection-sampling/README.md)] [[概率与统计](../probability-and-statistics/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 398 | [随机数索引](../../problems/random-pick-index) | [[水塘抽样](../reservoir-sampling/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 384 | [打乱数组](../../problems/shuffle-an-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 382 | [链表随机节点](../../problems/linked-list-random-node) | [[水塘抽样](../reservoir-sampling/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | +| 381 | [O(1) 时间插入、删除和获取随机元素 - 允许重复](../../problems/insert-delete-getrandom-o1-duplicates-allowed) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Hard | +| 380 | [O(1) 时间插入、删除和获取随机元素](../../problems/insert-delete-getrandom-o1) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Medium | diff --git a/tag/rejection-sampling/README.md b/tag/rejection-sampling/README.md index baecbf3f9..ba0e34fee 100644 --- a/tag/rejection-sampling/README.md +++ b/tag/rejection-sampling/README.md @@ -5,7 +5,7 @@ -## [话题分类](../README.md) > Rejection Sampling +## [话题分类](../README.md) > 拒绝采样 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | diff --git a/tag/reservoir-sampling/README.md b/tag/reservoir-sampling/README.md index 59e9ab693..34b47a93f 100644 --- a/tag/reservoir-sampling/README.md +++ b/tag/reservoir-sampling/README.md @@ -5,7 +5,7 @@ -## [话题分类](../README.md) > 蓄水池抽样 +## [话题分类](../README.md) > 水塘抽样 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | diff --git a/tag/rolling-hash/README.md b/tag/rolling-hash/README.md index c8154f5a4..36c2919b2 100644 --- a/tag/rolling-hash/README.md +++ b/tag/rolling-hash/README.md @@ -5,7 +5,7 @@ -## [话题分类](../README.md) > Rolling Hash +## [话题分类](../README.md) > 滚动哈希 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | diff --git a/tag/shortest-path/README.md b/tag/shortest-path/README.md new file mode 100644 index 000000000..76daeded2 --- /dev/null +++ b/tag/shortest-path/README.md @@ -0,0 +1,21 @@ + + + + + + + +## [话题分类](../README.md) > 最短路 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1334 | [阈值距离内邻居最少的城市](../../problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | +| 882 | [细分图中的可到达结点](../../problems/reachable-nodes-in-subdivided-graph) | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 787 | [K 站中转内最便宜的航班](../../problems/cheapest-flights-within-k-stops) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 743 | [网络延迟时间](../../problems/network-delay-time) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 505 | [迷宫 II](../../problems/the-maze-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 499 | [迷宫 III](../../problems/the-maze-iii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 399 | [除法求值](../../problems/evaluate-division) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Medium | diff --git a/tag/simulation/README.md b/tag/simulation/README.md new file mode 100644 index 000000000..d8f453325 --- /dev/null +++ b/tag/simulation/README.md @@ -0,0 +1,78 @@ + + + + + + + +## [话题分类](../README.md) > 模拟 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1945 | [字符串转化后的各位数字之和](../../problems/sum-of-digits-of-string-after-convert) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1920 | [基于排列构建数组](../../problems/build-array-from-permutation) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1914 | [循环轮转矩阵](../../problems/cyclically-rotating-a-grid) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1894 | [找到需要补充粉笔的学生编号](../../problems/find-the-student-that-will-replace-the-chalk) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1860 | [增长的内存泄露](../../problems/incremental-memory-leak) | [[模拟](../simulation/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1806 | [还原排列的最少操作步数](../../problems/minimum-number-of-operations-to-reinitialize-a-permutation) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1706 | [球会落何处](../../problems/where-will-the-ball-fall) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1701 | [平均等待时间](../../problems/average-waiting-time) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1700 | [无法吃午餐的学生数量](../../problems/number-of-students-unable-to-eat-lunch) | [[栈](../stack/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1688 | [比赛中的配对次数](../../problems/count-of-matches-in-tournament) | [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1680 | [连接连续二进制数字](../../problems/concatenation-of-consecutive-binary-numbers) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1646 | [获取生成数组中的最大值](../../problems/get-maximum-in-generated-array) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1603 | [设计停车系统](../../problems/design-parking-system) | [[设计](../design/README.md)] [[计数](../counting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1599 | [经营摩天轮的最大利润](../../problems/maximum-profit-of-operating-a-centennial-wheel) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1583 | [统计不开心的朋友](../../problems/count-unhappy-friends) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1562 | [查找大小为 M 的最新分组](../../problems/find-latest-group-of-size-m) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1560 | [圆形赛道上经过次数最多的扇区](../../problems/most-visited-sector-in-a-circular-track) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1535 | [找出数组游戏的赢家](../../problems/find-the-winner-of-an-array-game) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1518 | [换酒问题](../../problems/water-bottles) | [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1503 | [所有蚂蚁掉下来前的最后一刻](../../problems/last-moment-before-all-ants-fall-out-of-a-plank) | [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1441 | [用栈操作构建数组](../../problems/build-an-array-with-stack-operations) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1409 | [查询带键的排列](../../problems/queries-on-a-permutation-with-key) | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1389 | [按既定顺序创建目标数组](../../problems/create-target-array-in-the-given-order) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1324 | [竖直打印单词](../../problems/print-words-vertically) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1275 | [找出井字棋的获胜者](../../problems/find-winner-on-a-tic-tac-toe-game) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1260 | [二维网格迁移](../../problems/shift-2d-grid) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1252 | [奇数值单元格的数目](../../problems/cells-with-odd-values-in-a-matrix) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1243 | [数组变换](../../problems/array-transformation) 🔒 | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1222 | [可以攻击国王的皇后](../../problems/queens-that-can-attack-the-king) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1103 | [分糖果 II](../../problems/distribute-candies-to-people) | [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1094 | [拼车](../../problems/car-pooling) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1041 | [困于环中的机器人](../../problems/robot-bounded-in-circle) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1006 | [笨阶乘](../../problems/clumsy-factorial) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 999 | [可以被一步捕获的棋子数](../../problems/available-captures-for-rook) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 985 | [查询后的偶数和](../../problems/sum-of-even-numbers-after-queries) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 950 | [按递增顺序显示卡牌](../../problems/reveal-cards-in-increasing-order) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 946 | [验证栈序列](../../problems/validate-stack-sequences) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 885 | [螺旋矩阵 III](../../problems/spiral-matrix-iii) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 874 | [模拟行走机器人](../../problems/walking-robot-simulation) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 867 | [转置矩阵](../../problems/transpose-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 832 | [翻转图像](../../problems/flipping-an-image) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 755 | [倒水](../../problems/pour-water) 🔒 | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 749 | [隔离病毒](../../problems/contain-virus) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Hard | +| 723 | [粉碎糖果](../../problems/candy-crush) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 682 | [棒球比赛](../../problems/baseball-game) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 657 | [机器人能否返回原点](../../problems/robot-return-to-origin) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 640 | [求解方程](../../problems/solve-the-equation) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 592 | [分数加减运算](../../problems/fraction-addition-and-subtraction) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 566 | [重塑矩阵](../../problems/reshape-the-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 544 | [输出比赛匹配对](../../problems/output-contest-matches) 🔒 | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 498 | [对角线遍历](../../problems/diagonal-traverse) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 495 | [提莫攻击](../../problems/teemo-attacking) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 415 | [字符串相加](../../problems/add-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 412 | [Fizz Buzz](../../problems/fizz-buzz) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 289 | [生命游戏](../../problems/game-of-life) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 258 | [各位相加](../../problems/add-digits) | [[数学](../math/README.md)] [[数论](../number-theory/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 158 | [用 Read4 读取 N 个字符 II](../../problems/read-n-characters-given-read4-ii-call-multiple-times) 🔒 | [[字符串](../string/README.md)] [[交互](../interactive/README.md)] [[模拟](../simulation/README.md)] | Hard | +| 157 | [用 Read4 读取 N 个字符](../../problems/read-n-characters-given-read4) 🔒 | [[字符串](../string/README.md)] [[交互](../interactive/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 68 | [文本左右对齐](../../problems/text-justification) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Hard | +| 67 | [二进制求和](../../problems/add-binary) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 59 | [螺旋矩阵 II](../../problems/spiral-matrix-ii) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 54 | [螺旋矩阵](../../problems/spiral-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 43 | [字符串相乘](../../problems/multiply-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index 211bfe5b5..32ff4bf2f 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -5,7 +5,7 @@ -## [话题分类](../README.md) > Sliding Window +## [话题分类](../README.md) > 滑动窗口 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | diff --git a/tag/sorting/README.md b/tag/sorting/README.md new file mode 100644 index 000000000..901eb01c4 --- /dev/null +++ b/tag/sorting/README.md @@ -0,0 +1,210 @@ + + + + + + + +## [话题分类](../README.md) > 排序 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1913 | [两个数对之间的最大乘积差](../../problems/maximum-product-difference-between-two-pairs) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1889 | [装包裹的最小浪费空间](../../problems/minimum-space-wasted-from-packaging) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1887 | [使数组元素相等的减少操作次数](../../problems/reduction-operations-to-make-the-array-elements-equal) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1885 | [Count Pairs in Two Arrays](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1878 | [矩阵中最大的三个菱形和](../../problems/get-biggest-three-rhombus-sums-in-a-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1877 | [数组中最大数对和的最小值](../../problems/minimize-maximum-pair-sum-in-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1874 | [两个数组的最小乘积和](../../problems/minimize-product-sum-of-two-arrays) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1859 | [将句子排序](../../problems/sorting-the-sentence) | [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1851 | [包含每个查询的最小区间](../../problems/minimum-interval-to-include-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[扫描线](../line-sweep/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1847 | [最近的房间](../../problems/closest-room) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1846 | [减小和重新排列数组后的最大元素](../../problems/maximum-element-after-decreasing-and-rearranging) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1834 | [单线程 CPU](../../problems/single-threaded-cpu) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1833 | [雪糕的最大数量](../../problems/maximum-ice-cream-bars) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1772 | [按受欢迎程度排列功能](../../problems/sort-features-by-popularity) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1727 | [重新排列后的最大子矩阵](../../problems/largest-submatrix-with-rearrangements) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1710 | [卡车上的最大单元数](../../problems/maximum-units-on-a-truck) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1697 | [检查边长度限制的路径是否存在](../../problems/checking-existence-of-edge-length-limited-paths) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1691 | [堆叠长方体的最大高度](../../problems/maximum-height-by-stacking-cuboids) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1686 | [石子游戏 VI](../../problems/stone-game-vi) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1679 | [K 和数对的最大数目](../../problems/max-number-of-k-sum-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1665 | [完成所有任务的最少初始能量](../../problems/minimum-initial-energy-to-finish-tasks) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1657 | [确定两个字符串是否接近](../../problems/determine-if-two-strings-are-close) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1647 | [字符频次唯一的最小删除次数](../../problems/minimum-deletions-to-make-character-frequencies-unique) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1637 | [两点之间不包含任何点的最宽垂直面积](../../problems/widest-vertical-area-between-two-points-containing-no-points) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1636 | [按照频率将数组升序排序](../../problems/sort-array-by-increasing-frequency) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1630 | [等差子数组](../../problems/arithmetic-subarrays) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1626 | [无矛盾的最佳球队](../../problems/best-team-with-no-conflicts) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1619 | [删除某些元素后的数组均值](../../problems/mean-of-array-after-removing-some-elements) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 1608 | [特殊数组的特征值](../../problems/special-array-with-x-elements-greater-than-or-equal-x) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1589 | [所有排列中的最大和](../../problems/maximum-sum-obtained-of-any-permutation) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1580 | [把箱子放进仓库里 II](../../problems/put-boxes-into-the-warehouse-ii) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1564 | [把箱子放进仓库里 I](../../problems/put-boxes-into-the-warehouse-i) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1561 | [你可以获得的最大硬币数目](../../problems/maximum-number-of-coins-you-can-get) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1508 | [子数组和排序后的区间和](../../problems/range-sum-of-sorted-subarray-sums) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1502 | [判断能否形成等差数列](../../problems/can-make-arithmetic-progression-from-sequence) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1498 | [满足条件的子序列数目](../../problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1491 | [去掉最低工资和最高工资后的工资平均值](../../problems/average-salary-excluding-the-minimum-and-maximum-salary) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] [[排序](../sorting/README.md)] [[强连通分量](../strongly-connected-component/README.md)] | Hard | +| 1481 | [不同整数的最少数目](../../problems/least-number-of-unique-integers-after-k-removals) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1471 | [数组中的 k 个最强值](../../problems/the-k-strongest-values-in-an-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1465 | [切割后面积最大的蛋糕](../../problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1464 | [数组中两元素的最大乘积](../../problems/maximum-product-of-two-elements-in-an-array) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 1460 | [通过翻转子数组使两个数组相等](../../problems/make-two-arrays-equal-by-reversing-sub-arrays) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1424 | [对角线遍历 II](../../problems/diagonal-traverse-ii) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1418 | [点菜展示表](../../problems/display-table-of-food-orders-in-a-restaurant) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1403 | [非递增顺序的最小子序列](../../problems/minimum-subsequence-in-non-increasing-order) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1402 | [做菜顺序](../../problems/reducing-dishes) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1387 | [将整数按权重排序](../../problems/sort-integers-by-the-power-value) | [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1385 | [两个数组间的距离值](../../problems/find-the-distance-value-between-two-arrays) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1356 | [根据数字二进制下 1 的数目排序](../../problems/sort-integers-by-the-number-of-1-bits) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1348 | [推文计数](../../problems/tweet-counts-per-frequency) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1346 | [检查整数及其两倍数是否存在](../../problems/check-if-n-and-its-double-exist) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1340 | [跳跃游戏 V](../../problems/jump-game-v) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1338 | [数组大小减半](../../problems/reduce-array-size-to-the-half) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1337 | [矩阵中战斗力最弱的 K 行](../../problems/the-k-weakest-rows-in-a-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 1333 | [餐厅过滤器](../../problems/filter-restaurants-by-vegan-friendly-price-and-distance) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1331 | [数组序号转换](../../problems/rank-transform-of-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1329 | [将矩阵按对角线排序](../../problems/sort-the-matrix-diagonally) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1311 | [获取你好友已观看的视频](../../problems/get-watched-videos-by-your-friends) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1305 | [两棵二叉搜索树中的所有元素](../../problems/all-elements-in-two-binary-search-trees) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1300 | [转变数组后最接近目标值的数组和](../../problems/sum-of-mutated-array-closest-to-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1296 | [划分数组为连续数字的集合](../../problems/divide-array-in-sets-of-k-consecutive-numbers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1288 | [删除被覆盖区间](../../problems/remove-covered-intervals) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1244 | [力扣排行榜](../../problems/design-a-leaderboard) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1235 | [规划兼职工作](../../problems/maximum-profit-in-job-scheduling) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1229 | [安排会议日程](../../problems/meeting-scheduler) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1200 | [最小绝对差](../../problems/minimum-absolute-difference) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1196 | [最多可以买到的苹果数量](../../problems/how-many-apples-can-you-put-into-the-basket) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1181 | [前后拼接](../../problems/before-and-after-puzzle) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1170 | [比较字符串最小字母出现频次](../../problems/compare-strings-by-frequency-of-the-smallest-character) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1169 | [查询无效交易](../../problems/invalid-transactions) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1152 | [用户网站访问行为分析](../../problems/analyze-user-website-visit-pattern) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1133 | [最大唯一数](../../problems/largest-unique-number) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1122 | [数组的相对排序](../../problems/relative-sort-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数排序](../counting-sort/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1099 | [小于 K 的两数之和](../../problems/two-sum-less-than-k) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1094 | [拼车](../../problems/car-pooling) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1090 | [受标签影响的最大值](../../problems/largest-values-from-labels) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1086 | [前五科的均分](../../problems/high-five) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1065 | [字符串的索引对](../../problems/index-pairs-of-a-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1057 | [校园自行车分配](../../problems/campus-bikes) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1054 | [距离相等的条形码](../../problems/distant-barcodes) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1051 | [高度检查器](../../problems/height-checker) | [[数组](../array/README.md)] [[计数排序](../counting-sort/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1040 | [移动石子直到连续 II](../../problems/moving-stones-until-consecutive-ii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1029 | [两地调度](../../problems/two-city-scheduling) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1005 | [K 次取反后最大化的数组和](../../problems/maximize-sum-of-array-after-k-negations) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 977 | [有序数组的平方](../../problems/squares-of-a-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Easy | +| 976 | [三角形的最大周长](../../problems/largest-perimeter-triangle) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 969 | [煎饼排序](../../problems/pancake-sorting) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 954 | [二倍数对数组](../../problems/array-of-doubled-pairs) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 950 | [按递增顺序显示卡牌](../../problems/reveal-cards-in-increasing-order) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 948 | [令牌放置](../../problems/bag-of-tokens) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 945 | [使数组唯一的最小增量](../../problems/minimum-increment-to-make-array-unique) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 939 | [最小面积矩形](../../problems/minimum-area-rectangle) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 937 | [重新排列日志文件](../../problems/reorder-data-in-log-files) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 923 | [三数之和的多种可能](../../problems/3sum-with-multiplicity) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 922 | [按奇偶排序数组 II](../../problems/sort-array-by-parity-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Easy | +| 912 | [排序数组](../../problems/sort-an-array) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数排序](../counting-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 910 | [最小差值 II](../../problems/smallest-range-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 905 | [按奇偶排序数组](../../problems/sort-array-by-parity) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Easy | +| 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | +| 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | +| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 869 | [重新排序得到 2 的幂](../../problems/reordered-power-of-2) | [[数学](../math/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Medium | +| 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 853 | [车队](../../problems/car-fleet) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 846 | [一手顺子](../../problems/hand-of-straights) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 833 | [字符串中的查找与替换](../../problems/find-and-replace-in-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 825 | [适龄的朋友](../../problems/friends-of-appropriate-ages) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 792 | [匹配子序列的单词数](../../problems/number-of-matching-subsequences) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 791 | [自定义字符串排序](../../problems/custom-sort-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 769 | [最多能完成排序的块](../../problems/max-chunks-to-make-sorted) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 768 | [最多能完成排序的块 II](../../problems/max-chunks-to-make-sorted-ii) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 767 | [重构字符串](../../problems/reorganize-string) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 757 | [设置交集大小至少为2](../../problems/set-intersection-size-at-least-two) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 747 | [至少是其他数字两倍的最大数](../../problems/largest-number-at-least-twice-of-others) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[随机化](../randomized/README.md)] | Hard | +| 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 658 | [找到 K 个最接近的元素](../../problems/find-k-closest-elements) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 646 | [最长数对链](../../problems/maximum-length-of-pair-chain) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 645 | [错误的集合](../../problems/set-mismatch) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 632 | [最小区间](../../problems/smallest-range-covering-elements-from-k-lists) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 628 | [三个数的最大乘积](../../problems/maximum-product-of-three-numbers) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 621 | [任务调度器](../../problems/task-scheduler) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 611 | [有效三角形的个数](../../problems/valid-triangle-number) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 594 | [最长和谐子序列](../../problems/longest-harmonious-subsequence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 581 | [最短无序连续子数组](../../problems/shortest-unsorted-continuous-subarray) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 561 | [数组拆分 I](../../problems/array-partition-i) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[计数排序](../counting-sort/README.md)] [[排序](../sorting/README.md)] | Easy | +| 539 | [最小时间差](../../problems/minimum-time-difference) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 532 | [数组中的 k-diff 数对](../../problems/k-diff-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[贪心](../greedy/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | +| 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 522 | [最长特殊序列 II](../../problems/longest-uncommon-subsequence-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 506 | [相对名次](../../problems/relative-ranks) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 502 | [IPO](../../problems/ipo) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 475 | [供暖器](../../problems/heaters) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 462 | [最少移动次数使数组元素相等 II](../../problems/minimum-moves-to-equal-array-elements-ii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 455 | [分发饼干](../../problems/assign-cookies) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 451 | [根据字符出现频率排序](../../problems/sort-characters-by-frequency) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 436 | [寻找右区间](../../problems/find-right-interval) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 435 | [无重叠区间](../../problems/non-overlapping-intervals) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 414 | [第三大的数](../../problems/third-maximum-number) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 406 | [根据身高重建队列](../../problems/queue-reconstruction-by-height) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 360 | [有序转化数组](../../problems/sort-transformed-array) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 354 | [俄罗斯套娃信封问题](../../problems/russian-doll-envelopes) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | +| 350 | [两个数组的交集 II](../../problems/intersection-of-two-arrays-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 349 | [两个数组的交集](../../problems/intersection-of-two-arrays) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 324 | [摆动排序 II](../../problems/wiggle-sort-ii) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] | Medium | +| 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Hard | +| 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[设计](../design/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 274 | [H 指数](../../problems/h-index) | [[数组](../array/README.md)] [[计数排序](../counting-sort/README.md)] [[排序](../sorting/README.md)] | Medium | +| 268 | [丢失的数字](../../problems/missing-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 259 | [较小的三数之和](../../problems/3sum-smaller) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 253 | [会议室 II](../../problems/meeting-rooms-ii) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 252 | [会议室](../../problems/meeting-rooms) 🔒 | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 242 | [有效的字母异位词](../../problems/valid-anagram) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | +| 229 | [求众数 II](../../problems/majority-element-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | +| 220 | [存在重复元素 III](../../problems/contains-duplicate-iii) | [[数组](../array/README.md)] [[桶排序](../bucket-sort/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 217 | [存在重复元素](../../problems/contains-duplicate) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Easy | +| 215 | [数组中的第K个最大元素](../../problems/kth-largest-element-in-an-array) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 179 | [最大数](../../problems/largest-number) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 169 | [多数元素](../../problems/majority-element) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | +| 164 | [最大间距](../../problems/maximum-gap) | [[数组](../array/README.md)] [[桶排序](../bucket-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] | Hard | +| 148 | [排序链表](../../problems/sort-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[分治](../divide-and-conquer/README.md)] [[排序](../sorting/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[链表](../linked-list/README.md)] [[排序](../sorting/README.md)] | Medium | +| 88 | [合并两个有序数组](../../problems/merge-sorted-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Easy | +| 75 | [颜色分类](../../problems/sort-colors) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 56 | [合并区间](../../problems/merge-intervals) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 49 | [字母异位词分组](../../problems/group-anagrams) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 18 | [四数之和](../../problems/4sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 16 | [最接近的三数之和](../../problems/3sum-closest) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 15 | [三数之和](../../problems/3sum) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | diff --git a/tag/stack/README.md b/tag/stack/README.md index dde3c9653..08d1c9bfb 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1944 | [队列中可以看到的人数](../../problems/number-of-visible-people-in-a-queue) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1896 | [反转表达式值的最少操作次数](../../problems/minimum-cost-to-change-the-final-value-of-expression) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | diff --git a/tag/string-matching/README.md b/tag/string-matching/README.md new file mode 100644 index 000000000..67472968a --- /dev/null +++ b/tag/string-matching/README.md @@ -0,0 +1,26 @@ + + + + + + + +## [话题分类](../README.md) > 字符串匹配 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1764 | [通过连接另一个数组的子数组得到一个数组](../../problems/form-array-by-concatenating-subarrays-of-another-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 1668 | [最大重复子字符串](../../problems/maximum-repeating-substring) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Easy | +| 1455 | [检查单词是否为句中其他单词的前缀](../../problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Easy | +| 1408 | [数组中的字符串匹配](../../problems/string-matching-in-an-array) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Easy | +| 1397 | [找到所有好字符串](../../problems/find-all-good-strings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[字符串匹配](../string-matching/README.md)] | Hard | +| 1392 | [最长快乐前缀](../../problems/longest-happy-prefix) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1023 | [驼峰式匹配](../../problems/camelcase-matching) | [[字典树](../trie/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 796 | [旋转字符串](../../problems/rotate-string) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Easy | +| 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 686 | [重复叠加字符串匹配](../../problems/repeated-string-match) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 616 | [给字符串添加加粗标签](../../problems/add-bold-tag-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | +| 572 | [另一棵树的子树](../../problems/subtree-of-another-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] [[字符串匹配](../string-matching/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | +| 459 | [重复的子字符串](../../problems/repeated-substring-pattern) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Easy | +| 214 | [最短回文串](../../problems/shortest-palindrome) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 28 | [实现 strStr()](../../problems/implement-strstr) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Easy | diff --git a/tag/string/README.md b/tag/string/README.md index 3f31b7f5a..d35884ace 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | +| 1946 | [子字符串突变后可能得到的最大整数](../../problems/largest-number-after-mutating-substring) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1945 | [字符串转化后的各位数字之和](../../problems/sum-of-digits-of-string-after-convert) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 1941 | [检查是否所有字符出现次数相同](../../problems/check-if-all-characters-have-equal-number-of-occurrences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1935 | [可以输入的最大单词数](../../problems/maximum-number-of-words-you-can-type) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1930 | [长度为 3 的不同回文子序列](../../problems/unique-length-3-palindromic-subsequences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1915 | [最美子字符串的数目](../../problems/number-of-wonderful-substrings) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1910 | [删除一个字符串中所有出现的给定子字符串](../../problems/remove-all-occurrences-of-a-substring) | [[字符串](../string/README.md)] | Medium | | 1904 | [你完成的完整对局数](../../problems/the-number-of-full-rounds-you-have-played) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | @@ -231,7 +237,7 @@ | 917 | [仅仅反转字母](../../problems/reverse-only-letters) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 916 | [单词子集](../../problems/word-subsets) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | -| 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 884 | [两句话中的不常见单词](../../problems/uncommon-words-from-two-sentences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 880 | [索引处的解码字符串](../../problems/decoded-string-at-index) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | @@ -412,7 +418,7 @@ | 187 | [重复的DNA序列](../../problems/repeated-dna-sequences) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | | 186 | [翻转字符串里的单词 II](../../problems/reverse-words-in-a-string-ii) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 179 | [最大数](../../problems/largest-number) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | -| 171 | [Excel表列序号](../../problems/excel-sheet-column-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | +| 171 | [Excel 表列序号](../../problems/excel-sheet-column-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 168 | [Excel表列名称](../../problems/excel-sheet-column-title) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 165 | [比较版本号](../../problems/compare-version-numbers) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/strongly-connected-component/README.md b/tag/strongly-connected-component/README.md new file mode 100644 index 000000000..d32a1515e --- /dev/null +++ b/tag/strongly-connected-component/README.md @@ -0,0 +1,13 @@ + + + + + + + +## [话题分类](../README.md) > 强连通分量 + +| # | 题目 | 标签 | 难度 | +| :-: | - | - | :-: | +| 1568 | [使陆地分离的最少天数](../../problems/minimum-number-of-days-to-disconnect-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[强连通分量](../strongly-connected-component/README.md)] | Hard | +| 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] [[排序](../sorting/README.md)] [[强连通分量](../strongly-connected-component/README.md)] | Hard | diff --git a/tag/suffix-array/README.md b/tag/suffix-array/README.md index 363673362..1ec43d64a 100644 --- a/tag/suffix-array/README.md +++ b/tag/suffix-array/README.md @@ -5,7 +5,7 @@ -## [话题分类](../README.md) > Suffix Array +## [话题分类](../README.md) > 后缀数组 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | diff --git a/tag/tree/README.md b/tag/tree/README.md index 6cb55ab4e..04204a698 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | @@ -114,7 +115,7 @@ | 590 | [N 叉树的后序遍历](../../problems/n-ary-tree-postorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 589 | [N 叉树的前序遍历](../../problems/n-ary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Easy | | 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 572 | [另一个树的子树](../../problems/subtree-of-another-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] [[字符串匹配](../string-matching/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | +| 572 | [另一棵树的子树](../../problems/subtree-of-another-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] [[字符串匹配](../string-matching/README.md)] [[哈希函数](../hash-function/README.md)] | Easy | | 563 | [二叉树的坡度](../../problems/binary-tree-tilt) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 559 | [N 叉树的最大深度](../../problems/maximum-depth-of-n-ary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Easy | | 558 | [四叉树交集](../../problems/logical-or-of-two-binary-grids-represented-as-quad-trees) | [[树](../tree/README.md)] [[分治](../divide-and-conquer/README.md)] | Medium | diff --git a/tag/trie/README.md b/tag/trie/README.md index a93542736..34d2b1846 100644 --- a/tag/trie/README.md +++ b/tag/trie/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | | 1858 | [包含所有前缀的最长单词](../../problems/longest-word-with-all-prefixes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] | Medium | | 1804 | [实现 Trie (前缀树) II](../../problems/implement-trie-ii-prefix-tree) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1803 | [统计异或值在范围内的数对有多少](../../problems/count-pairs-with-xor-in-a-range) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] | Hard | From 0dfdaa82c2d1dceeeca058fee629dd8222d2323d Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 2 Sep 2021 17:51:17 +0800 Subject: [PATCH 134/145] A: new --- README.md | 39 +++++- problems/3sum-closest/README.md | 19 ++- .../README.md | 2 +- .../apply-discount-every-n-orders/README.md | 46 ++++--- .../README.md | 2 +- problems/array-of-doubled-pairs/README.md | 4 +- .../README.md | 65 ++++++++++ .../balance-a-binary-search-tree/README.md | 23 ++-- problems/basic-calculator-ii/README.md | 4 +- problems/basic-calculator/README.md | 3 +- .../README.md | 13 +- .../README.md | 2 +- .../README.md | 2 +- .../README.md | 2 +- .../README.md | 2 +- .../best-time-to-buy-and-sell-stock/README.md | 2 +- .../README.md | 30 +++++ .../README.md | 30 ++--- problems/binary-tree-coloring-game/README.md | 25 ++-- .../README.md | 2 +- problems/building-h2o/README.md | 37 +++--- problems/camelcase-matching/README.md | 41 +++---- .../README.md | 35 +++--- problems/car-pooling/README.md | 49 +++----- problems/check-if-move-is-legal/README.md | 64 ++++++++++ .../README.md | 61 ++++++++++ .../README.md | 3 + problems/clumsy-factorial/README.md | 39 +++--- problems/coloring-a-border/README.md | 62 ++++------ .../complement-of-base-10-integer/README.md | 49 ++++---- .../complete-binary-tree-inserter/README.md | 64 ++++------ problems/consecutive-characters/README.md | 6 +- problems/convert-to-base-2/README.md | 38 +++--- .../README.md | 25 ++++ .../README.md | 24 ++-- problems/cracking-the-safe/README.md | 26 +++- .../README.md | 11 +- .../README.md | 70 +++++++++++ problems/distinct-subsequences-ii/README.md | 2 +- problems/duplicate-zeros/README.md | 28 ++--- .../README.md | 14 +++ .../mysql_schemas.sql | 8 ++ .../README.md | 14 +++ .../mysql_schemas.sql | 10 ++ problems/erect-the-fence-ii/README.md | 5 + problems/filling-bookcase-shelves/README.md | 29 +++-- .../find-all-anagrams-in-a-string/README.md | 2 + .../find-array-given-subset-sums/README.md | 78 ++++++++++++ problems/find-common-characters/README.md | 33 ++--- .../README.md | 14 +++ .../mysql_schemas.sql | 13 ++ .../README.md | 73 +++++++++++ .../find-if-path-exists-in-graph/README.md | 51 ++++++++ .../README.md | 88 ++++++++++++++ .../README.md | 88 ++++++++++++++ problems/find-unique-binary-string/README.md | 66 ++++++++++ .../README.md | 32 +++-- .../README.md | 14 +++ .../mysql_schemas.sql | 8 ++ problems/four-divisors/README.md | 24 +++- problems/game-of-nim/README.md | 2 +- problems/group-anagrams/README.md | 2 +- problems/grumpy-bookstore-owner/README.md | 34 ++++-- problems/house-robber-ii/README.md | 4 +- problems/image-overlap/README.md | 22 ++-- .../implement-queue-using-stacks/README.md | 7 +- problems/insert-interval/README.md | 12 +- .../README.md | 54 +++----- .../interval-list-intersections/README.md | 2 +- .../kth-ancestor-of-a-tree-node/README.md | 4 +- .../kth-largest-element-in-a-stream/README.md | 8 +- problems/kth-smallest-subarray-sum/README.md | 2 +- .../README.md | 4 +- problems/largest-values-from-labels/README.md | 59 ++++----- .../README.md | 79 ++++++++++++ problems/last-stone-weight/README.md | 36 +++--- problems/length-of-last-word/README.md | 30 ++++- problems/linked-list-cycle-ii/README.md | 6 +- problems/linked-list-random-node/README.md | 7 ++ .../README.md | 5 + .../longest-uncommon-subsequence-ii/README.md | 2 +- .../README.md | 11 +- problems/magical-string/README.md | 4 +- .../README.md | 2 +- problems/map-sum-pairs/README.md | 11 +- .../masking-personal-information/README.md | 115 +++++++++++------- .../matrix-cells-in-distance-order/README.md | 41 +++---- .../README.md | 44 +++---- problems/maximum-binary-tree-ii/README.md | 55 ++++----- .../maximum-length-of-pair-chain/README.md | 2 +- problems/maximum-matrix-sum/README.md | 67 ++++++++++ .../README.md | 4 + .../README.md | 66 ++++++++++ .../README.md | 48 +++----- problems/maximum-width-ramp/README.md | 40 ++---- .../README.md | 81 ++++++++++++ problems/minimum-area-rectangle/README.md | 4 +- .../minimum-cost-to-hire-k-workers/README.md | 4 +- .../README.md | 29 +++-- .../README.md | 76 ++++++++++++ .../minimum-falling-path-sum-ii/README.md | 20 ++- problems/minimum-falling-path-sum/README.md | 3 - .../README.md | 31 +++-- .../README.md | 81 ++++++++++++ .../README.md | 2 +- .../README.md | 40 +++--- .../README.md | 88 ++++++++++++++ .../README.md | 83 +++++++++++++ .../README.md | 25 ++++ .../README.md | 93 ++++++++++++++ .../README.md | 75 ++++++++++++ .../README.md | 62 ++++------ .../moving-stones-until-consecutive/README.md | 59 ++++----- .../README.md | 46 +++---- problems/number-complement/README.md | 16 ++- .../README.md | 19 ++- problems/number-of-good-pairs/README.md | 10 +- problems/number-of-squareful-arrays/README.md | 25 ++-- .../README.md | 74 +++++++++++ .../README.md | 24 +--- .../README.md | 74 +++++++++++ .../README.md | 45 ++++--- .../README.md | 71 +++++++++++ .../README.md | 74 +++++++++++ .../numbers-with-repeated-digits/README.md | 32 ++--- problems/odd-even-jump/README.md | 2 +- problems/online-election/README.md | 57 +++++---- problems/online-stock-span/README.md | 60 ++++----- problems/path-sum-ii/README.md | 7 +- problems/permutation-in-string/README.md | 4 +- problems/plus-one/README.md | 24 +++- .../README.md | 32 ++--- .../README.md | 34 +++--- problems/print-foobar-alternately/README.md | 40 ++++-- problems/print-in-order/README.md | 7 ++ .../product-of-the-last-k-numbers/README.md | 24 ++-- problems/pyramid-transition-matrix/README.md | 31 ++--- problems/range-addition-ii/README.md | 2 +- problems/range-module/README.md | 6 - .../range-sum-query-2d-immutable/README.md | 4 +- problems/recover-binary-search-tree/README.md | 7 +- .../reduce-array-size-to-the-half/README.md | 2 +- problems/relative-sort-array/README.md | 14 ++- problems/remove-covered-intervals/README.md | 10 +- .../README.md | 77 ++++++++++++ .../README.md | 10 +- problems/reverse-only-letters/README.md | 65 ++++------ problems/robot-return-to-origin/README.md | 8 +- problems/rotate-list/README.md | 4 +- .../README.md | 57 ++++----- problems/search-a-2d-matrix-ii/README.md | 2 +- .../shortest-common-supersequence/README.md | 25 ++-- .../README.md | 2 +- .../README.md | 14 +-- problems/shuffle-an-array/README.md | 2 +- .../README.md | 59 ++++----- problems/stone-game/README.md | 31 +++-- problems/stream-of-characters/README.md | 55 +++++---- problems/string-compression/README.md | 6 +- .../subarray-sums-divisible-by-k/README.md | 33 ++--- .../README.md | 35 +++--- problems/subdomain-visit-count/README.md | 54 ++++---- problems/sudoku-solver/README.md | 8 +- .../README.md | 42 ++++--- .../README.md | 21 ++-- problems/third-maximum-number/README.md | 18 ++- problems/three-divisors/README.md | 3 + .../README.md | 5 +- problems/top-k-frequent-words/README.md | 55 +++++---- problems/trapping-rain-water/README.md | 2 +- .../README.md | 29 +++-- problems/tuple-with-same-product/README.md | 2 +- problems/uncrossed-lines/README.md | 48 ++++---- problems/unique-paths-iii/README.md | 64 +++++----- problems/univalued-binary-tree/README.md | 26 ++-- problems/valid-sudoku/README.md | 2 +- .../README.md | 2 +- .../verifying-an-alien-dictionary/README.md | 5 +- problems/video-stitching/README.md | 2 +- .../README.md | 35 ++++++ readme/1-300.md | 2 +- readme/601-900.md | 2 +- readme/901-1200.md | 4 +- tag/array/README.md | 29 ++++- tag/backtracking/README.md | 2 + tag/binary-indexed-tree/README.md | 1 + tag/binary-search/README.md | 4 +- tag/bit-manipulation/README.md | 3 +- tag/bitmask/README.md | 1 + tag/brainteaser/README.md | 4 +- tag/breadth-first-search/README.md | 1 + tag/counting/README.md | 1 + tag/depth-first-search/README.md | 1 + tag/divide-and-conquer/README.md | 2 + tag/dynamic-programming/README.md | 11 +- tag/enumeration/README.md | 1 + tag/game-theory/README.md | 2 +- tag/geometry/README.md | 1 + tag/graph/README.md | 1 + tag/greedy/README.md | 8 +- tag/hash-function/README.md | 1 + tag/hash-table/README.md | 3 +- tag/heap-priority-queue/README.md | 2 + tag/math/README.md | 8 +- tag/matrix/README.md | 4 + tag/quickselect/README.md | 1 + tag/recursion/README.md | 1 + tag/rolling-hash/README.md | 1 + tag/shortest-path/README.md | 1 + tag/simulation/README.md | 2 +- tag/sliding-window/README.md | 2 +- tag/sorting/README.md | 3 + tag/stack/README.md | 1 + tag/string/README.md | 13 +- tag/suffix-array/README.md | 1 + tag/topological-sort/README.md | 1 + tag/two-pointers/README.md | 1 + tag/union-find/README.md | 1 + 218 files changed, 3810 insertions(+), 1565 deletions(-) create mode 100644 problems/array-with-elements-not-equal-to-average-of-neighbors/README.md create mode 100644 problems/binary-searchable-numbers-in-an-unsorted-array/README.md create mode 100644 problems/check-if-move-is-legal/README.md create mode 100644 problems/check-if-string-is-a-prefix-of-array/README.md create mode 100644 problems/count-nodes-equal-to-sum-of-descendants/README.md create mode 100644 problems/delete-characters-to-make-fancy-string/README.md create mode 100644 problems/employees-whose-manager-left-the-company/README.md create mode 100644 problems/employees-whose-manager-left-the-company/mysql_schemas.sql create mode 100644 problems/employees-with-missing-information/README.md create mode 100644 problems/employees-with-missing-information/mysql_schemas.sql create mode 100644 problems/find-array-given-subset-sums/README.md create mode 100644 problems/find-cutoff-score-for-each-school/README.md create mode 100644 problems/find-cutoff-score-for-each-school/mysql_schemas.sql create mode 100644 problems/find-greatest-common-divisor-of-array/README.md create mode 100644 problems/find-if-path-exists-in-graph/README.md create mode 100644 problems/find-the-kth-largest-integer-in-the-array/README.md create mode 100644 problems/find-the-longest-valid-obstacle-course-at-each-position/README.md create mode 100644 problems/find-unique-binary-string/README.md create mode 100644 problems/first-and-last-call-on-the-same-day/README.md create mode 100644 problems/first-and-last-call-on-the-same-day/mysql_schemas.sql create mode 100644 problems/last-day-where-you-can-still-cross/README.md create mode 100644 problems/maximum-matrix-sum/README.md create mode 100644 problems/maximum-product-of-the-length-of-two-palindromic-substrings/README.md create mode 100644 problems/minimize-the-difference-between-target-and-chosen-elements/README.md create mode 100644 problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md create mode 100644 problems/minimum-non-zero-product-of-the-array-elements/README.md create mode 100644 problems/minimum-number-of-swaps-to-make-the-string-balanced/README.md create mode 100644 problems/minimum-number-of-work-sessions-to-finish-the-tasks/README.md create mode 100644 problems/minimum-time-for-k-virus-variants-to-spread/README.md create mode 100644 problems/minimum-time-to-type-word-using-special-typewriter/README.md create mode 100644 problems/minimum-total-space-wasted-with-k-resizing-operations/README.md create mode 100644 problems/number-of-strings-that-appear-as-substrings-in-word/README.md create mode 100644 problems/number-of-unique-good-subsequences/README.md create mode 100644 problems/number-of-ways-to-arrive-at-destination/README.md create mode 100644 problems/number-of-ways-to-separate-numbers/README.md create mode 100644 problems/remove-stones-to-minimize-the-total/README.md create mode 100644 problems/widest-pair-of-indices-with-equal-range-sum/README.md diff --git a/README.md b/README.md index 03760c670..bf7de3b75 100644 --- a/README.md +++ b/README.md @@ -78,11 +78,44 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1988 | [Find Cutoff Score for Each School](https://leetcode.com/problems/find-cutoff-score-for-each-school) 🔒 | [MySQL](problems/find-cutoff-score-for-each-school) | Medium | +| 1987 | [Number of Unique Good Subsequences](https://leetcode.com/problems/number-of-unique-good-subsequences "不同的好子序列数目") | [Go](problems/number-of-unique-good-subsequences) | Hard | +| 1986 | [Minimum Number of Work Sessions to Finish the Tasks](https://leetcode.com/problems/minimum-number-of-work-sessions-to-finish-the-tasks "完成任务的最少工作时间段") | [Go](problems/minimum-number-of-work-sessions-to-finish-the-tasks) | Medium | +| 1985 | [Find the Kth Largest Integer in the Array](https://leetcode.com/problems/find-the-kth-largest-integer-in-the-array "找出数组中的第 K 大整数") | [Go](problems/find-the-kth-largest-integer-in-the-array) | Medium | +| 1984 | [Minimum Difference Between Highest and Lowest of K Scores](https://leetcode.com/problems/minimum-difference-between-highest-and-lowest-of-k-scores "学生分数的最小差值") | [Go](problems/minimum-difference-between-highest-and-lowest-of-k-scores) | Easy | +| 1983 | [Widest Pair of Indices With Equal Range Sum](https://leetcode.com/problems/widest-pair-of-indices-with-equal-range-sum) 🔒 | [Go](problems/widest-pair-of-indices-with-equal-range-sum) | Medium | +| 1982 | [Find Array Given Subset Sums](https://leetcode.com/problems/find-array-given-subset-sums "从子集的和还原数组") | [Go](problems/find-array-given-subset-sums) | Hard | +| 1981 | [Minimize the Difference Between Target and Chosen Elements](https://leetcode.com/problems/minimize-the-difference-between-target-and-chosen-elements "最小化目标值与所选元素的差") | [Go](problems/minimize-the-difference-between-target-and-chosen-elements) | Medium | +| 1980 | [Find Unique Binary String](https://leetcode.com/problems/find-unique-binary-string "找出不同的二进制字符串") | [Go](problems/find-unique-binary-string) | Medium | +| 1979 | [Find Greatest Common Divisor of Array](https://leetcode.com/problems/find-greatest-common-divisor-of-array "找出数组的最大公约数") | [Go](problems/find-greatest-common-divisor-of-array) | Easy | +| 1978 | [Employees Whose Manager Left the Company](https://leetcode.com/problems/employees-whose-manager-left-the-company) 🔒 | [MySQL](problems/employees-whose-manager-left-the-company) | Easy | +| 1977 | [Number of Ways to Separate Numbers](https://leetcode.com/problems/number-of-ways-to-separate-numbers "划分数字的方案数") | [Go](problems/number-of-ways-to-separate-numbers) | Hard | +| 1976 | [Number of Ways to Arrive at Destination](https://leetcode.com/problems/number-of-ways-to-arrive-at-destination "到达目的地的方案数") | [Go](problems/number-of-ways-to-arrive-at-destination) | Medium | +| 1975 | [Maximum Matrix Sum](https://leetcode.com/problems/maximum-matrix-sum "最大方阵和") | [Go](problems/maximum-matrix-sum) | Medium | +| 1974 | [Minimum Time to Type Word Using Special Typewriter](https://leetcode.com/problems/minimum-time-to-type-word-using-special-typewriter "使用特殊打字机键入单词的最少时间") | [Go](problems/minimum-time-to-type-word-using-special-typewriter) | Easy | +| 1973 | [Count Nodes Equal to Sum of Descendants](https://leetcode.com/problems/count-nodes-equal-to-sum-of-descendants) 🔒 | [Go](problems/count-nodes-equal-to-sum-of-descendants) | Medium | +| 1972 | [First and Last Call On the Same Day](https://leetcode.com/problems/first-and-last-call-on-the-same-day) 🔒 | [MySQL](problems/first-and-last-call-on-the-same-day) | Hard | +| 1971 | [Find if Path Exists in Graph](https://leetcode.com/problems/find-if-path-exists-in-graph) | [Go](problems/find-if-path-exists-in-graph) | Easy | +| 1970 | [Last Day Where You Can Still Cross](https://leetcode.com/problems/last-day-where-you-can-still-cross "你能穿过矩阵的最后一天") | [Go](problems/last-day-where-you-can-still-cross) | Hard | +| 1969 | [Minimum Non-Zero Product of the Array Elements](https://leetcode.com/problems/minimum-non-zero-product-of-the-array-elements "数组元素的最小非零乘积") | [Go](problems/minimum-non-zero-product-of-the-array-elements) | Medium | +| 1968 | [Array With Elements Not Equal to Average of Neighbors](https://leetcode.com/problems/array-with-elements-not-equal-to-average-of-neighbors "构造元素不等于两相邻元素平均值的数组") | [Go](problems/array-with-elements-not-equal-to-average-of-neighbors) | Medium | +| 1967 | [Number of Strings That Appear as Substrings in Word](https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word "作为子字符串出现在单词中的字符串数目") | [Go](problems/number-of-strings-that-appear-as-substrings-in-word) | Easy | +| 1966 | [Binary Searchable Numbers in an Unsorted Array](https://leetcode.com/problems/binary-searchable-numbers-in-an-unsorted-array) 🔒 | [Go](problems/binary-searchable-numbers-in-an-unsorted-array) | Medium | +| 1965 | [Employees With Missing Information](https://leetcode.com/problems/employees-with-missing-information) 🔒 | [MySQL](problems/employees-with-missing-information) | Easy | +| 1964 | [Find the Longest Valid Obstacle Course at Each Position](https://leetcode.com/problems/find-the-longest-valid-obstacle-course-at-each-position "找出到每个位置为止最长的有效障碍赛跑路线") | [Go](problems/find-the-longest-valid-obstacle-course-at-each-position) | Hard | +| 1963 | [Minimum Number of Swaps to Make the String Balanced](https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-string-balanced "使字符串平衡的最小交换次数") | [Go](problems/minimum-number-of-swaps-to-make-the-string-balanced) | Medium | +| 1962 | [Remove Stones to Minimize the Total](https://leetcode.com/problems/remove-stones-to-minimize-the-total "移除石子使总数最小") | [Go](problems/remove-stones-to-minimize-the-total) | Medium | +| 1961 | [Check If String Is a Prefix of Array](https://leetcode.com/problems/check-if-string-is-a-prefix-of-array "检查字符串是否为数组前缀") | [Go](problems/check-if-string-is-a-prefix-of-array) | Easy | +| 1960 | [Maximum Product of the Length of Two Palindromic Substrings](https://leetcode.com/problems/maximum-product-of-the-length-of-two-palindromic-substrings "两个回文子字符串长度的最大乘积") | [Go](problems/maximum-product-of-the-length-of-two-palindromic-substrings) | Hard | +| 1959 | [Minimum Total Space Wasted With K Resizing Operations](https://leetcode.com/problems/minimum-total-space-wasted-with-k-resizing-operations "K 次调整数组大小浪费的最小总空间") | [Go](problems/minimum-total-space-wasted-with-k-resizing-operations) | Medium | +| 1958 | [Check if Move is Legal](https://leetcode.com/problems/check-if-move-is-legal "检查操作是否合法") | [Go](problems/check-if-move-is-legal) | Medium | +| 1957 | [Delete Characters to Make Fancy String](https://leetcode.com/problems/delete-characters-to-make-fancy-string "删除字符使字符串变好") | [Go](problems/delete-characters-to-make-fancy-string) | Easy | +| 1956 | [Minimum Time For K Virus Variants to Spread](https://leetcode.com/problems/minimum-time-for-k-virus-variants-to-spread "感染 K 种病毒所需的最短时间") 🔒 | [Go](problems/minimum-time-for-k-virus-variants-to-spread) | Hard | | 1955 | [Count Number of Special Subsequences](https://leetcode.com/problems/count-number-of-special-subsequences "统计特殊子序列的数目") | [Go](problems/count-number-of-special-subsequences) | Hard | | 1954 | [Minimum Garden Perimeter to Collect Enough Apples](https://leetcode.com/problems/minimum-garden-perimeter-to-collect-enough-apples "收集足够苹果的最小花园周长") | [Go](problems/minimum-garden-perimeter-to-collect-enough-apples) | Medium | | 1953 | [Maximum Number of Weeks for Which You Can Work](https://leetcode.com/problems/maximum-number-of-weeks-for-which-you-can-work "你可以工作的最大周数") | [Go](problems/maximum-number-of-weeks-for-which-you-can-work) | Medium | | 1952 | [Three Divisors](https://leetcode.com/problems/three-divisors "三除数") | [Go](problems/three-divisors) | Easy | -| 1951 | [All the Pairs With the Maximum Number of Common Followers](https://leetcode.com/problems/all-the-pairs-with-the-maximum-number-of-common-followers) 🔒 | [MySQL](problems/all-the-pairs-with-the-maximum-number-of-common-followers) | Medium | +| 1951 | [All the Pairs With the Maximum Number of Common Followers](https://leetcode.com/problems/all-the-pairs-with-the-maximum-number-of-common-followers "查询具有最多共同关注者的所有两两结对组") 🔒 | [MySQL](problems/all-the-pairs-with-the-maximum-number-of-common-followers) | Medium | | 1950 | [Maximum of Minimum Values in All Subarrays](https://leetcode.com/problems/maximum-of-minimum-values-in-all-subarrays "所有子数组最小值中的最大值") 🔒 | [Go](problems/maximum-of-minimum-values-in-all-subarrays) | Medium | | 1949 | [Strong Friendship](https://leetcode.com/problems/strong-friendship) 🔒 | [MySQL](problems/strong-friendship) | Medium | | 1948 | [Delete Duplicate Folders in System](https://leetcode.com/problems/delete-duplicate-folders-in-system "删除系统中的重复文件夹") | [Go](problems/delete-duplicate-folders-in-system) | Hard | @@ -115,7 +148,7 @@ LeetCode Problems' Solutions | 1921 | [Eliminate Maximum Number of Monsters](https://leetcode.com/problems/eliminate-maximum-number-of-monsters "消灭怪物的最大数量") | [Go](problems/eliminate-maximum-number-of-monsters) | Medium | | 1920 | [Build Array from Permutation](https://leetcode.com/problems/build-array-from-permutation "基于排列构建数组") | [Go](problems/build-array-from-permutation) | Easy | | 1919 | [Leetcodify Similar Friends](https://leetcode.com/problems/leetcodify-similar-friends "兴趣相同的朋友") 🔒 | [MySQL](problems/leetcodify-similar-friends) | Hard | -| 1918 | [Kth Smallest Subarray Sum](https://leetcode.com/problems/kth-smallest-subarray-sum) 🔒 | [Go](problems/kth-smallest-subarray-sum) | Medium | +| 1918 | [Kth Smallest Subarray Sum](https://leetcode.com/problems/kth-smallest-subarray-sum "第 K 小的子序列和") 🔒 | [Go](problems/kth-smallest-subarray-sum) | Medium | | 1917 | [Leetcodify Friends Recommendations](https://leetcode.com/problems/leetcodify-friends-recommendations) 🔒 | [MySQL](problems/leetcodify-friends-recommendations) | Hard | | 1916 | [Count Ways to Build Rooms in an Ant Colony](https://leetcode.com/problems/count-ways-to-build-rooms-in-an-ant-colony "统计为蚁群构筑房间的不同顺序") | [Go](problems/count-ways-to-build-rooms-in-an-ant-colony) | Hard | | 1915 | [Number of Wonderful Substrings](https://leetcode.com/problems/number-of-wonderful-substrings "最美子字符串的数目") | [Go](problems/number-of-wonderful-substrings) | Medium | @@ -125,7 +158,7 @@ LeetCode Problems' Solutions | 1911 | [Maximum Alternating Subsequence Sum](https://leetcode.com/problems/maximum-alternating-subsequence-sum "最大子序列交替和") | [Go](problems/maximum-alternating-subsequence-sum) | Medium | | 1910 | [Remove All Occurrences of a Substring](https://leetcode.com/problems/remove-all-occurrences-of-a-substring "删除一个字符串中所有出现的给定子字符串") | [Go](problems/remove-all-occurrences-of-a-substring) | Medium | | 1909 | [Remove One Element to Make the Array Strictly Increasing](https://leetcode.com/problems/remove-one-element-to-make-the-array-strictly-increasing "删除一个元素使数组严格递增") | [Go](problems/remove-one-element-to-make-the-array-strictly-increasing) | Easy | -| 1908 | [Game of Nim](https://leetcode.com/problems/game-of-nim) 🔒 | [Go](problems/game-of-nim) | Medium | +| 1908 | [Game of Nim](https://leetcode.com/problems/game-of-nim "Nim 游戏 II") 🔒 | [Go](problems/game-of-nim) | Medium | | 1907 | [Count Salary Categories](https://leetcode.com/problems/count-salary-categories "按分类统计薪水") 🔒 | [MySQL](problems/count-salary-categories) | Medium | | 1906 | [Minimum Absolute Difference Queries](https://leetcode.com/problems/minimum-absolute-difference-queries "查询差绝对值的最小值") | [Go](problems/minimum-absolute-difference-queries) | Medium | | 1905 | [Count Sub Islands](https://leetcode.com/problems/count-sub-islands "统计子岛屿") | [Go](problems/count-sub-islands) | Medium | diff --git a/problems/3sum-closest/README.md b/problems/3sum-closest/README.md index e615ead82..b96e513a8 100644 --- a/problems/3sum-closest/README.md +++ b/problems/3sum-closest/README.md @@ -11,7 +11,11 @@ ## [16. 3Sum Closest (Medium)](https://leetcode.com/problems/3sum-closest "最接近的三数之和") -

    Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution.

    +

    Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target.

    + +

    Return the sum of the three integers.

    + +

    You may assume that each input would have exactly one solution.

     

    Example 1:

    @@ -22,13 +26,20 @@ Explanation: The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).
    +

    Example 2:

    + +
    +Input: nums = [0,0,0], target = 1
    +Output: 0
    +
    +

     

    Constraints:

      -
    • 3 <= nums.length <= 10^3
    • -
    • -10^3 <= nums[i] <= 10^3
    • -
    • -10^4 <= target <= 10^4
    • +
    • 3 <= nums.length <= 1000
    • +
    • -1000 <= nums[i] <= 1000
    • +
    • -104 <= target <= 104
    ### Related Topics diff --git a/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md b/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md index 619eb1796..8b13a5d53 100644 --- a/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md +++ b/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md @@ -9,6 +9,6 @@                  [Next >](../three-divisors "Three Divisors") -## [1951. All the Pairs With the Maximum Number of Common Followers (Medium)](https://leetcode.com/problems/all-the-pairs-with-the-maximum-number-of-common-followers "") +## [1951. All the Pairs With the Maximum Number of Common Followers (Medium)](https://leetcode.com/problems/all-the-pairs-with-the-maximum-number-of-common-followers "查询具有最多共同关注者的所有两两结对组") diff --git a/problems/apply-discount-every-n-orders/README.md b/problems/apply-discount-every-n-orders/README.md index 0ca34f047..74c248018 100644 --- a/problems/apply-discount-every-n-orders/README.md +++ b/problems/apply-discount-every-n-orders/README.md @@ -11,16 +11,17 @@ ## [1357. Apply Discount Every n Orders (Medium)](https://leetcode.com/problems/apply-discount-every-n-orders "每隔 n 个顾客打折") -

    There is a sale in a supermarket, there will be a discount every n customer.
    -There are some products in the supermarket where the id of the i-th product is products[i] and the price per unit of this product is prices[i].
    -The system will count the number of customers and when the n-th customer arrive he/she will have a discount on the bill. (i.e if the cost is x the new cost is x - (discount * x) / 100). Then the system will start counting customers again.
    -The customer orders a certain amount of each product where product[i] is the id of the i-th product the customer ordered and amount[i] is the number of units the customer ordered of that product.

    +

    There is a supermarket that is frequented by many customers. The products sold at the supermarket are represented as two parallel integer arrays products and prices, where the ith product has an ID of products[i] and a price of prices[i].

    + +

    When a customer is paying, their bill is represented as two parallel integer arrays product and amount, where the jth product they purchased has an ID of product[j], and amount[j] is how much of the product they bought. Their subtotal is calculated as the sum of each amount[j] * (price of the jth product).

    + +

    The supermarket decided to have a sale. Every nth customer paying for their groceries will be given a percentage discount. The discount amount is given by discount, where they will be given discount percent off their subtotal. More formally, if their subtotal is bill, then they would actually pay bill * ((100 - discount) / 100).

    Implement the Cashier class:

      -
    • Cashier(int n, int discount, int[] products, int[] prices) Initializes the object with n, the discount, the products and their prices.
    • -
    • double getBill(int[] product, int[] amount) returns the value of the bill and apply the discount if needed. Answers within 10^-5 of the actual value will be accepted as correct.
    • +
    • Cashier(int n, int discount, int[] products, int[] prices) Initializes the object with n, the discount, and the products and their prices.
    • +
    • double getBill(int[] product, int[] amount) Returns the final total of the bill with the discount applied (if any). Answers within 10-5 of the actual value will be accepted.

     

    @@ -34,32 +35,39 @@ The customer orders a certain amount of each product where product[i]Explanation Cashier cashier = new Cashier(3,50,[1,2,3,4,5,6,7],[100,200,300,400,300,200,100]); -cashier.getBill([1,2],[1,2]); // return 500.0, bill = 1 * 100 + 2 * 200 = 500. -cashier.getBill([3,7],[10,10]); // return 4000.0 -cashier.getBill([1,2,3,4,5,6,7],[1,1,1,1,1,1,1]); // return 800.0, The bill was 1600.0 but as this is the third customer, he has a discount of 50% which means his bill is only 1600 - 1600 * (50 / 100) = 800. -cashier.getBill([4],[10]); // return 4000.0 -cashier.getBill([7,3],[10,10]); // return 4000.0 -cashier.getBill([7,5,3,1,6,4,2],[10,10,10,9,9,9,7]); // return 7350.0, Bill was 14700.0 but as the system counted three more customers, he will have a 50% discount and the bill becomes 7350.0 -cashier.getBill([2,3,5],[5,3,2]); // return 2500.0 +cashier.getBill([1,2],[1,2]); // return 500.0. 1st customer, no discount. + // bill = 1 * 100 + 2 * 200 = 500. +cashier.getBill([3,7],[10,10]); // return 4000.0. 2nd customer, no discount. + // bill = 10 * 300 + 10 * 100 = 4000. +cashier.getBill([1,2,3,4,5,6,7],[1,1,1,1,1,1,1]); // return 800.0. 3rd customer, 50% discount. + // Original bill = 1600 + // Actual bill = 1600 * ((100 - 50) / 100) = 800. +cashier.getBill([4],[10]); // return 4000.0. 4th customer, no discount. +cashier.getBill([7,3],[10,10]); // return 4000.0. 5th customer, no discount. +cashier.getBill([7,5,3,1,6,4,2],[10,10,10,9,9,9,7]); // return 7350.0. 6th customer, 50% discount. + // Original bill = 14700, but with + // Actual bill = 14700 * ((100 - 50) / 100) = 7350. +cashier.getBill([2,3,5],[5,3,2]); // return 2500.0. 6th customer, no discount.

     

    Constraints:

      -
    • 1 <= n <= 10^4
    • +
    • 1 <= n <= 104
    • 0 <= discount <= 100
    • 1 <= products.length <= 200
    • -
    • 1 <= products[i] <= 200
    • -
    • There are not repeated elements in the array products.
    • prices.length == products.length
    • +
    • 1 <= products[i] <= 200
    • 1 <= prices[i] <= 1000
    • +
    • The elements in products are unique.
    • 1 <= product.length <= products.length
    • -
    • product[i] exists in products.
    • amount.length == product.length
    • -
    • 1 <= amount[i] <= 1000
    • +
    • product[j] exists in products.
    • +
    • 1 <= amount[j] <= 1000
    • +
    • The elements of product are unique.
    • At most 1000 calls will be made to getBill.
    • -
    • Answers within 10^-5 of the actual value will be accepted as correct.
    • +
    • Answers within 10-5 of the actual value will be accepted.
    ### Related Topics diff --git a/problems/arithmetic-slices-ii-subsequence/README.md b/problems/arithmetic-slices-ii-subsequence/README.md index d068568ef..642661dd7 100644 --- a/problems/arithmetic-slices-ii-subsequence/README.md +++ b/problems/arithmetic-slices-ii-subsequence/README.md @@ -26,7 +26,7 @@
  • For example, [2,5,10] is a subsequence of [1,2,1,2,4,1,5,10].
  • -

    The answer is guaranteed to fit in 32-bit integer.

    +

    The test cases are generated so that the answer fits in 32-bit integer.

     

    Example 1:

    diff --git a/problems/array-of-doubled-pairs/README.md b/problems/array-of-doubled-pairs/README.md index 9a6b6ba2a..9ca7bb697 100644 --- a/problems/array-of-doubled-pairs/README.md +++ b/problems/array-of-doubled-pairs/README.md @@ -11,7 +11,7 @@ ## [954. Array of Doubled Pairs (Medium)](https://leetcode.com/problems/array-of-doubled-pairs "二倍数对数组") -

    Given an array of integers arr of even length, return true if and only if it is possible to reorder it such that arr[2 * i + 1] = 2 * arr[2 * i] for every 0 <= i < len(arr) / 2.

    +

    Given an integer array of even length arr, return true if it is possible to reorder arr such that arr[2 * i + 1] = 2 * arr[2 * i] for every 0 <= i < len(arr) / 2, or false otherwise.

     

    Example 1:

    @@ -47,7 +47,7 @@

    Constraints:

      -
    • 0 <= arr.length <= 3 * 104
    • +
    • 2 <= arr.length <= 3 * 104
    • arr.length is even.
    • -105 <= arr[i] <= 105
    diff --git a/problems/array-with-elements-not-equal-to-average-of-neighbors/README.md b/problems/array-with-elements-not-equal-to-average-of-neighbors/README.md new file mode 100644 index 000000000..c74800b58 --- /dev/null +++ b/problems/array-with-elements-not-equal-to-average-of-neighbors/README.md @@ -0,0 +1,65 @@ + + + + + + + +[< Previous](../number-of-strings-that-appear-as-substrings-in-word "Number of Strings That Appear as Substrings in Word") +                 +[Next >](../minimum-non-zero-product-of-the-array-elements "Minimum Non-Zero Product of the Array Elements") + +## [1968. Array With Elements Not Equal to Average of Neighbors (Medium)](https://leetcode.com/problems/array-with-elements-not-equal-to-average-of-neighbors "构造元素不等于两相邻元素平均值的数组") + +

    You are given a 0-indexed array nums of distinct integers. You want to rearrange the elements in the array such that every element in the rearranged array is not equal to the average of its neighbors.

    + +

    More formally, the rearranged array should have the property such that for every i in the range 1 <= i < nums.length - 1, (nums[i-1] + nums[i+1]) / 2 is not equal to nums[i].

    + +

    Return any rearrangement of nums that meets the requirements.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3,4,5]
    +Output: [1,2,4,5,3]
    +Explanation:
    +When i=1, nums[i] = 2, and the average of its neighbors is (1+4) / 2 = 2.5.
    +When i=2, nums[i] = 4, and the average of its neighbors is (2+5) / 2 = 3.5.
    +When i=3, nums[i] = 5, and the average of its neighbors is (4+3) / 2 = 3.5.
    +
    + +

    Example 2:

    + +
    +Input: nums = [6,2,0,9,7]
    +Output: [9,7,6,2,0]
    +Explanation:
    +When i=1, nums[i] = 7, and the average of its neighbors is (9+6) / 2 = 7.5.
    +When i=2, nums[i] = 6, and the average of its neighbors is (7+2) / 2 = 4.5.
    +When i=3, nums[i] = 2, and the average of its neighbors is (6+0) / 2 = 3.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= nums.length <= 105
    • +
    • 0 <= nums[i] <= 105
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +A number can be the average of its neighbors if one neighbor is smaller than the number and the other is greater than the number. +
    + +
    +Hint 2 +We can put numbers smaller than the median on odd indices and the rest on even indices. +
    diff --git a/problems/balance-a-binary-search-tree/README.md b/problems/balance-a-binary-search-tree/README.md index e271036c2..64ca4a5eb 100644 --- a/problems/balance-a-binary-search-tree/README.md +++ b/problems/balance-a-binary-search-tree/README.md @@ -11,29 +11,32 @@ ## [1382. Balance a Binary Search Tree (Medium)](https://leetcode.com/problems/balance-a-binary-search-tree "将二叉搜索树变平衡") -

    Given a binary search tree, return a balanced binary search tree with the same node values.

    +

    Given the root of a binary search tree, return a balanced binary search tree with the same node values. If there is more than one answer, return any of them.

    -

    A binary search tree is balanced if and only if the depth of the two subtrees of every node never differ by more than 1.

    - -

    If there is more than one answer, return any of them.

    +

    A binary search tree is balanced if the depth of the two subtrees of every node never differs by more than 1.

     

    Example 1:

    - -

    - +
     Input: root = [1,null,2,null,3,null,4,null,null]
     Output: [2,1,3,null,null,null,4]
    -Explanation: This is not the only correct answer, [3,1,4,null,2,null,null] is also correct.
    +Explanation: This is not the only correct answer, [3,1,4,null,2] is also correct.
    +
    + +

    Example 2:

    + +
    +Input: root = [2,1,3]
    +Output: [2,1,3]
     

     

    Constraints:

      -
    • The number of nodes in the tree is between 1 and 10^4.
    • -
    • The tree nodes will have distinct values between 1 and 10^5.
    • +
    • The number of nodes in the tree is in the range [1, 104].
    • +
    • 1 <= Node.val <= 105
    ### Related Topics diff --git a/problems/basic-calculator-ii/README.md b/problems/basic-calculator-ii/README.md index 9f1386925..aa4ab58ff 100644 --- a/problems/basic-calculator-ii/README.md +++ b/problems/basic-calculator-ii/README.md @@ -15,7 +15,9 @@

    The integer division should truncate toward zero.

    -

    Note: You are not allowed to use any built-in function which evaluates strings as mathematical expressions, such as eval().

    +

    You may assume that the given expression is always valid. All intermediate results will be in the range of [-231, 231 - 1].

    + +

    Note: You are not allowed to use any built-in function which evaluates strings as mathematical expressions, such as eval().

     

    Example 1:

    diff --git a/problems/basic-calculator/README.md b/problems/basic-calculator/README.md index 1485fb9aa..b5704bfb3 100644 --- a/problems/basic-calculator/README.md +++ b/problems/basic-calculator/README.md @@ -45,7 +45,8 @@
  • s consists of digits, '+', '-', '(', ')', and ' '.
  • s represents a valid expression.
  • '+' is not used as a unary operation.
  • -
  • '-' could be used as a unary operation but it has to be followed by parentheses.
  • +
  • '-' could be used as a unary operation but it has to be inside parentheses.
  • +
  • There will be no two consecutive operators in the input.
  • Every number and running calculation will fit in a signed 32-bit integer.
  • diff --git a/problems/best-time-to-buy-and-sell-stock-ii/README.md b/problems/best-time-to-buy-and-sell-stock-ii/README.md index a7a81fda5..f30d6c5b1 100644 --- a/problems/best-time-to-buy-and-sell-stock-ii/README.md +++ b/problems/best-time-to-buy-and-sell-stock-ii/README.md @@ -9,13 +9,13 @@                  [Next >](../best-time-to-buy-and-sell-stock-iii "Best Time to Buy and Sell Stock III") -## [122. Best Time to Buy and Sell Stock II (Easy)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii "买卖股票的最佳时机 II") +## [122. Best Time to Buy and Sell Stock II (Medium)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii "买卖股票的最佳时机 II") -

    You are given an array prices where prices[i] is the price of a given stock on the ith day.

    +

    You are given an integer array prices where prices[i] is the price of a given stock on the ith day.

    -

    Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times).

    +

    On each day, you may decide to buy and/or sell the stock. You can only hold at most one share of the stock at any time. However, you can buy it then immediately sell it on the same day.

    -

    Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).

    +

    Find and return the maximum profit you can achieve.

     

    Example 1:

    @@ -25,6 +25,7 @@ Output: 7 Explanation: Buy on day 2 (price = 1) and sell on day 3 (price = 5), profit = 5-1 = 4. Then buy on day 4 (price = 3) and sell on day 5 (price = 6), profit = 6-3 = 3. +Total profit is 4 + 3 = 7.

    Example 2:

    @@ -33,7 +34,7 @@ Then buy on day 4 (price = 3) and sell on day 5 (price = 6), profit = 6-3 = 3. Input: prices = [1,2,3,4,5] Output: 4 Explanation: Buy on day 1 (price = 1) and sell on day 5 (price = 5), profit = 5-1 = 4. -Note that you cannot buy on day 1, buy on day 2 and sell them later, as you are engaging multiple transactions at the same time. You must sell before buying again. +Total profit is 4.

    Example 3:

    @@ -41,7 +42,7 @@ Note that you cannot buy on day 1, buy on day 2 and sell them later, as you are
     Input: prices = [7,6,4,3,1]
     Output: 0
    -Explanation: In this case, no transaction is done, i.e., max profit = 0.
    +Explanation: There is no way to make a positive profit, so we never buy the stock to achieve the maximum profit of 0.
     

     

    diff --git a/problems/best-time-to-buy-and-sell-stock-iii/README.md b/problems/best-time-to-buy-and-sell-stock-iii/README.md index 47e162791..9224d5f41 100644 --- a/problems/best-time-to-buy-and-sell-stock-iii/README.md +++ b/problems/best-time-to-buy-and-sell-stock-iii/README.md @@ -64,6 +64,6 @@ Note that you cannot buy on day 1, buy on day 2 and sell them later, as you are ### Similar Questions 1. [Best Time to Buy and Sell Stock](../best-time-to-buy-and-sell-stock) (Easy) - 1. [Best Time to Buy and Sell Stock II](../best-time-to-buy-and-sell-stock-ii) (Easy) + 1. [Best Time to Buy and Sell Stock II](../best-time-to-buy-and-sell-stock-ii) (Medium) 1. [Best Time to Buy and Sell Stock IV](../best-time-to-buy-and-sell-stock-iv) (Hard) 1. [Maximum Sum of 3 Non-Overlapping Subarrays](../maximum-sum-of-3-non-overlapping-subarrays) (Hard) diff --git a/problems/best-time-to-buy-and-sell-stock-iv/README.md b/problems/best-time-to-buy-and-sell-stock-iv/README.md index 85facb4d4..d9bf26f46 100644 --- a/problems/best-time-to-buy-and-sell-stock-iv/README.md +++ b/problems/best-time-to-buy-and-sell-stock-iv/README.md @@ -49,5 +49,5 @@ ### Similar Questions 1. [Best Time to Buy and Sell Stock](../best-time-to-buy-and-sell-stock) (Easy) - 1. [Best Time to Buy and Sell Stock II](../best-time-to-buy-and-sell-stock-ii) (Easy) + 1. [Best Time to Buy and Sell Stock II](../best-time-to-buy-and-sell-stock-ii) (Medium) 1. [Best Time to Buy and Sell Stock III](../best-time-to-buy-and-sell-stock-iii) (Hard) diff --git a/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md b/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md index b4d4bd417..328dcc1d1 100644 --- a/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md +++ b/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md @@ -51,4 +51,4 @@ ### Similar Questions 1. [Best Time to Buy and Sell Stock](../best-time-to-buy-and-sell-stock) (Easy) - 1. [Best Time to Buy and Sell Stock II](../best-time-to-buy-and-sell-stock-ii) (Easy) + 1. [Best Time to Buy and Sell Stock II](../best-time-to-buy-and-sell-stock-ii) (Medium) diff --git a/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md b/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md index cbd299585..654c0256f 100644 --- a/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md +++ b/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md @@ -53,7 +53,7 @@ The total profit is ((8 - 1) - 2) + ((9 - 4) - 2) = 8. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions - 1. [Best Time to Buy and Sell Stock II](../best-time-to-buy-and-sell-stock-ii) (Easy) + 1. [Best Time to Buy and Sell Stock II](../best-time-to-buy-and-sell-stock-ii) (Medium) ### Hints
    diff --git a/problems/best-time-to-buy-and-sell-stock/README.md b/problems/best-time-to-buy-and-sell-stock/README.md index 119db2613..f421fa34b 100644 --- a/problems/best-time-to-buy-and-sell-stock/README.md +++ b/problems/best-time-to-buy-and-sell-stock/README.md @@ -49,7 +49,7 @@ Note that buying on day 2 and selling on day 1 is not allowed because you must b ### Similar Questions 1. [Maximum Subarray](../maximum-subarray) (Easy) - 1. [Best Time to Buy and Sell Stock II](../best-time-to-buy-and-sell-stock-ii) (Easy) + 1. [Best Time to Buy and Sell Stock II](../best-time-to-buy-and-sell-stock-ii) (Medium) 1. [Best Time to Buy and Sell Stock III](../best-time-to-buy-and-sell-stock-iii) (Hard) 1. [Best Time to Buy and Sell Stock IV](../best-time-to-buy-and-sell-stock-iv) (Hard) 1. [Best Time to Buy and Sell Stock with Cooldown](../best-time-to-buy-and-sell-stock-with-cooldown) (Medium) diff --git a/problems/binary-searchable-numbers-in-an-unsorted-array/README.md b/problems/binary-searchable-numbers-in-an-unsorted-array/README.md new file mode 100644 index 000000000..36df24998 --- /dev/null +++ b/problems/binary-searchable-numbers-in-an-unsorted-array/README.md @@ -0,0 +1,30 @@ + + + + + + + +[< Previous](../employees-with-missing-information "Employees With Missing Information") +                 +[Next >](../number-of-strings-that-appear-as-substrings-in-word "Number of Strings That Appear as Substrings in Word") + +## [1966. Binary Searchable Numbers in an Unsorted Array (Medium)](https://leetcode.com/problems/binary-searchable-numbers-in-an-unsorted-array "") + + + +### Hints +
    +Hint 1 +The target will not be found if it is removed from the sequence. When does this occur? +
    + +
    +Hint 2 +If a pivot is to the left of and is greater than the target, then the target will be removed. The same occurs when the pivot is to the right of and is less than the target. +
    + +
    +Hint 3 +Since any element can be chosen as the pivot, for any target NOT to be removed, the condition described in the previous hint must never occur. +
    diff --git a/problems/binary-string-with-substrings-representing-1-to-n/README.md b/problems/binary-string-with-substrings-representing-1-to-n/README.md index 9d41ab3c5..442d0a730 100644 --- a/problems/binary-string-with-substrings-representing-1-to-n/README.md +++ b/problems/binary-string-with-substrings-representing-1-to-n/README.md @@ -11,32 +11,26 @@ ## [1016. Binary String With Substrings Representing 1 To N (Medium)](https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n "子串能表示从 1 到 N 数字的二进制串") -

    Given a binary string s (a string consisting only of '0' and '1's) and a positive integer n, return true if and only if for every integer x from 1 to n, the binary representation of x is a substring of s.

    +

    Given a binary string s and a positive integer n, return true if the binary representation of all the integers in the range [1, n] are substrings of s, or false otherwise.

    -

     

    +

    A substring is a contiguous sequence of characters within a string.

    +

     

    Example 1:

    - -
    -Input: s = "0110", n = 3
    -Output: true
    -
    - -

    Example 2:

    - -
    -Input: s = "0110", n = 4
    -Output: false
    +
    Input: s = "0110", n = 3
    +Output: true
    +

    Example 2:

    +
    Input: s = "0110", n = 4
    +Output: false
     
    -

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= s.length <= 1000
      • +
      • s[i] is either '0' or '1'.
      • 1 <= n <= 109
      • -
    + ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/binary-tree-coloring-game/README.md b/problems/binary-tree-coloring-game/README.md index 243581a7b..dedbfdff1 100644 --- a/problems/binary-tree-coloring-game/README.md +++ b/problems/binary-tree-coloring-game/README.md @@ -11,32 +11,41 @@ ## [1145. Binary Tree Coloring Game (Medium)](https://leetcode.com/problems/binary-tree-coloring-game "二叉树着色游戏") -

    Two players play a turn based game on a binary tree.  We are given the root of this binary tree, and the number of nodes n in the tree.  n is odd, and each node has a distinct value from 1 to n.

    +

    Two players play a turn based game on a binary tree. We are given the root of this binary tree, and the number of nodes n in the tree. n is odd, and each node has a distinct value from 1 to n.

    -

    Initially, the first player names a value x with 1 <= x <= n, and the second player names a value y with 1 <= y <= n and y != x.  The first player colors the node with value x red, and the second player colors the node with value y blue.

    +

    Initially, the first player names a value x with 1 <= x <= n, and the second player names a value y with 1 <= y <= n and y != x. The first player colors the node with value x red, and the second player colors the node with value y blue.

    -

    Then, the players take turns starting with the first player.  In each turn, that player chooses a node of their color (red if player 1, blue if player 2) and colors an uncolored neighbor of the chosen node (either the left child, right child, or parent of the chosen node.)

    +

    Then, the players take turns starting with the first player. In each turn, that player chooses a node of their color (red if player 1, blue if player 2) and colors an uncolored neighbor of the chosen node (either the left child, right child, or parent of the chosen node.)

    -

    If (and only if) a player cannot choose such a node in this way, they must pass their turn.  If both players pass their turn, the game ends, and the winner is the player that colored more nodes.

    +

    If (and only if) a player cannot choose such a node in this way, they must pass their turn. If both players pass their turn, the game ends, and the winner is the player that colored more nodes.

    -

    You are the second player.  If it is possible to choose such a y to ensure you win the game, return true.  If it is not possible, return false.

    +

    You are the second player. If it is possible to choose such a y to ensure you win the game, return true. If it is not possible, return false.

     

    Example 1:

    - +
     Input: root = [1,2,3,4,5,6,7,8,9,10,11], n = 11, x = 3
     Output: true
     Explanation: The second player can choose the node with value 2.
     
    +

    Example 2:

    + +
    +Input: root = [1,2,3], n = 3, x = 1
    +Output: false
    +
    +

     

    Constraints:

      -
    • root is the root of a binary tree with n nodes and distinct node values from 1 to n.
    • +
    • The number of nodes in the tree is n.
    • +
    • 1 <= x <= n <= 100
    • n is odd.
    • -
    • 1 <= x <= n <= 100
    • +
    • 1 <= Node.val <= n
    • +
    • All the values of the tree are unique.
    ### Related Topics diff --git a/problems/build-an-array-with-stack-operations/README.md b/problems/build-an-array-with-stack-operations/README.md index 1a0aec601..60dd71263 100644 --- a/problems/build-an-array-with-stack-operations/README.md +++ b/problems/build-an-array-with-stack-operations/README.md @@ -68,8 +68,8 @@ Read number 3 and automatically push in the array -> [1,3] ### Related Topics - [[Array](../../tag/array/README.md)] [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/building-h2o/README.md b/problems/building-h2o/README.md index 4d1c74db5..b0f6efc6f 100644 --- a/problems/building-h2o/README.md +++ b/problems/building-h2o/README.md @@ -11,50 +11,47 @@ ## [1117. Building H2O (Medium)](https://leetcode.com/problems/building-h2o "H2O 生成") -

    There are two kinds of threads, oxygen and hydrogen. Your goal is to group these threads to form water molecules. There is a barrier where each thread has to wait until a complete molecule can be formed. Hydrogen and oxygen threads will be given releaseHydrogen and releaseOxygen methods respectively, which will allow them to pass the barrier. These threads should pass the barrier in groups of three, and they must be able to immediately bond with each other to form a water molecule. You must guarantee that all the threads from one molecule bond before any other threads from the next molecule do.

    +

    There are two kinds of threads: oxygen and hydrogen. Your goal is to group these threads to form water molecules.

    + +

    There is a barrier where each thread has to wait until a complete molecule can be formed. Hydrogen and oxygen threads will be given releaseHydrogen and releaseOxygen methods respectively, which will allow them to pass the barrier. These threads should pass the barrier in groups of three, and they must immediately bond with each other to form a water molecule. You must guarantee that all the threads from one molecule bond before any other threads from the next molecule do.

    In other words:

      -
    • If an oxygen thread arrives at the barrier when no hydrogen threads are present, it has to wait for two hydrogen threads.
    • -
    • If a hydrogen thread arrives at the barrier when no other threads are present, it has to wait for an oxygen thread and another hydrogen thread.
    • +
    • If an oxygen thread arrives at the barrier when no hydrogen threads are present, it must wait for two hydrogen threads.
    • +
    • If a hydrogen thread arrives at the barrier when no other threads are present, it must wait for an oxygen thread and another hydrogen thread.
    -

    We don’t have to worry about matching the threads up explicitly; that is, the threads do not necessarily know which other threads they are paired up with. The key is just that threads pass the barrier in complete sets; thus, if we examine the sequence of threads that bond and divide them into groups of three, each group should contain one oxygen and two hydrogen threads.

    +

    We do not have to worry about matching the threads up explicitly; the threads do not necessarily know which other threads they are paired up with. The key is that threads pass the barriers in complete sets; thus, if we examine the sequence of threads that bind and divide them into groups of three, each group should contain one oxygen and two hydrogen threads.

    Write synchronization code for oxygen and hydrogen molecules that enforces these constraints.

    -

     

    -
    - -

    Example 1:

    -Input: "HOH"
    -Output: "HHO"
    -Explanation: "HOH" and "OHH" are also valid answers.
    +Input: water = "HOH"
    +Output: "HHO"
    +Explanation: "HOH" and "OHH" are also valid answers.
     
    -

    Example 2:

    -Input: "OOHHHH"
    -Output: "HHOHHO"
    -Explanation: "HOHHHO", "OHHHHO", "HHOHOH", "HOHHOH", "OHHHOH", "HHOOHH", "HOHOHH" and "OHHOHH" are also valid answers.
    +Input: water = "OOHHHH"
    +Output: "HHOHHO"
    +Explanation: "HOHHHO", "OHHHHO", "HHOHOH", "HOHHOH", "OHHHOH", "HHOOHH", "HOHOHH" and "OHHOHH" are also valid answers.
     
    -
    -

     

    Constraints:

      -
    • Total length of input string will be 3n, where 1 ≤ n ≤ 20.
    • -
    • Total number of H will be 2n in the input string.
    • -
    • Total number of O will be n in the input string.
    • +
    • 3 * n == water.length
    • +
    • 1 <= n <= 20
    • +
    • water[i] is either 'H' or 'O'.
    • +
    • There will be exactly 2 * n 'H' in water.
    • +
    • There will be exactly n 'O' in water.
    ### Related Topics diff --git a/problems/camelcase-matching/README.md b/problems/camelcase-matching/README.md index b28104baf..3d40dd3c7 100644 --- a/problems/camelcase-matching/README.md +++ b/problems/camelcase-matching/README.md @@ -11,51 +11,46 @@ ## [1023. Camelcase Matching (Medium)](https://leetcode.com/problems/camelcase-matching "驼峰式匹配") -

    A query word matches a given pattern if we can insert lowercase letters to the pattern word so that it equals the query. (We may insert each character at any position, and may insert 0 characters.)

    +

    Given an array of strings queries and a string pattern, return a boolean array answer where answer[i] is true if queries[i] matches pattern, and false otherwise.

    -

    Given a list of queries, and a pattern, return an answer list of booleans, where answer[i] is true if and only if queries[i] matches the pattern.

    +

    A query word queries[i] matches pattern if you can insert lowercase English letters pattern so that it equals the query. You may insert each character at any position and you may not insert any characters.

     

    -

    Example 1:

    -Input: queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FB"
    -Output: [true,false,true,true,false]
    -Explanation: 
    -"FooBar" can be generated like this "F" + "oo" + "B" + "ar".
    +Input: queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FB"
    +Output: [true,false,true,true,false]
    +Explanation: "FooBar" can be generated like this "F" + "oo" + "B" + "ar".
     "FootBall" can be generated like this "F" + "oot" + "B" + "all".
    -"FrameBuffer" can be generated like this "F" + "rame" + "B" + "uffer".
    +"FrameBuffer" can be generated like this "F" + "rame" + "B" + "uffer". +

    Example 2:

    -Input: queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FoBa"
    -Output: [true,false,true,false,false]
    -Explanation: 
    -"FooBar" can be generated like this "Fo" + "o" + "Ba" + "r".
    +Input: queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FoBa"
    +Output: [true,false,true,false,false]
    +Explanation: "FooBar" can be generated like this "Fo" + "o" + "Ba" + "r".
     "FootBall" can be generated like this "Fo" + "ot" + "Ba" + "ll".
     

    Example 3:

    -Input: queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FoBaT"
    -Output: [false,true,false,false,false]
    -Explanation: 
    -"FooBarTest" can be generated like this "Fo" + "o" + "Ba" + "r" + "T" + "est".
    +Input: queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FoBaT"
    +Output: [false,true,false,false,false]
    +Explanation: "FooBarTest" can be generated like this "Fo" + "o" + "Ba" + "r" + "T" + "est".
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= queries.length <= 100
    2. +
        +
      • 1 <= pattern.length, queries.length <= 100
      • 1 <= queries[i].length <= 100
      • -
      • 1 <= pattern.length <= 100
      • -
      • All strings consists only of lower and upper case English letters.
      • -
    +
  • queries[i] and pattern consist of English letters.
  • + ### Related Topics [[Trie](../../tag/trie/README.md)] diff --git a/problems/can-make-palindrome-from-substring/README.md b/problems/can-make-palindrome-from-substring/README.md index 765d4dd92..11caade72 100644 --- a/problems/can-make-palindrome-from-substring/README.md +++ b/problems/can-make-palindrome-from-substring/README.md @@ -11,15 +11,13 @@ ## [1177. Can Make Palindrome from Substring (Medium)](https://leetcode.com/problems/can-make-palindrome-from-substring "构建回文串检测") -

    Given a string s, we make queries on substrings of s.

    +

    You are given a string s and array queries where queries[i] = [lefti, righti, ki]. We may rearrange the substring s[lefti...righti] for each query and then choose up to ki of them to replace with any lowercase English letter.

    -

    For each query queries[i] = [left, right, k], we may rearrange the substring s[left], ..., s[right], and then choose up to k of them to replace with any lowercase English letter. 

    +

    If the substring is possible to be a palindrome string after the operations above, the result of the query is true. Otherwise, the result is false.

    -

    If the substring is possible to be a palindrome string after the operations above, the result of the query is true. Otherwise, the result is false.

    +

    Return a boolean array answer where answer[i] is the result of the ith query queries[i].

    -

    Return an array answer[], where answer[i] is the result of the i-th query queries[i].

    - -

    Note that: Each letter is counted individually for replacement so if for example s[left..right] = "aaa", and k = 2, we can only replace two of the letters.  (Also, note that the initial string s is never modified by any query.)

    +

    Note that each letter is counted individually for replacement, so if, for example s[lefti...righti] = "aaa", and ki = 2, we can only replace two of the letters. Also, note that no query modifies the initial string s.

     

    Example :

    @@ -28,21 +26,28 @@ Input: s = "abcda", queries = [[3,3,0],[1,2,0],[0,3,1],[0,3,2],[0,4,1]] Output: [true,false,false,true,true] Explanation: -queries[0] : substring = "d", is palidrome. -queries[1] : substring = "bc", is not palidrome. -queries[2] : substring = "abcd", is not palidrome after replacing only 1 character. -queries[3] : substring = "abcd", could be changed to "abba" which is palidrome. Also this can be changed to "baab" first rearrange it "bacd" then replace "cd" with "ab". -queries[4] : substring = "abcda", could be changed to "abcba" which is palidrome. +queries[0]: substring = "d", is palidrome. +queries[1]: substring = "bc", is not palidrome. +queries[2]: substring = "abcd", is not palidrome after replacing only 1 character. +queries[3]: substring = "abcd", could be changed to "abba" which is palidrome. Also this can be changed to "baab" first rearrange it "bacd" then replace "cd" with "ab". +queries[4]: substring = "abcda", could be changed to "abcba" which is palidrome. + + +

    Example 2:

    + +
    +Input: s = "lyb", queries = [[0,1,0],[2,2,1]]
    +Output: [false,true]
     

     

    Constraints:

      -
    • 1 <= s.length, queries.length <= 10^5
    • -
    • 0 <= queries[i][0] <= queries[i][1] < s.length
    • -
    • 0 <= queries[i][2] <= s.length
    • -
    • s only contains lowercase English letters.
    • +
    • 1 <= s.length, queries.length <= 105
    • +
    • 0 <= lefti <= righti < s.length
    • +
    • 0 <= ki <= s.length
    • +
    • s consists of lowercase English letters.
    ### Related Topics diff --git a/problems/car-pooling/README.md b/problems/car-pooling/README.md index ddf9275d2..18852963e 100644 --- a/problems/car-pooling/README.md +++ b/problems/car-pooling/README.md @@ -11,66 +11,51 @@ ## [1094. Car Pooling (Medium)](https://leetcode.com/problems/car-pooling "拼车") -

    You are driving a vehicle that has capacity empty seats initially available for passengers.  The vehicle only drives east (ie. it cannot turn around and drive west.)

    +

    There is a car with capacity empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west).

    -

    Given a list of trips, trip[i] = [num_passengers, start_location, end_location] contains information about the i-th trip: the number of passengers that must be picked up, and the locations to pick them up and drop them off.  The locations are given as the number of kilometers due east from your vehicle's initial location.

    +

    You are given the integer capacity and an array trips where trip[i] = [numPassengersi, fromi, toi] indicates that the ith trip has numPassengersi passengers and the locations to pick them up and drop them off are fromi and toi respectively. The locations are given as the number of kilometers due east from the car's initial location.

    -

    Return true if and only if it is possible to pick up and drop off all passengers for all the given trips. 

    +

    Return true if it is possible to pick up and drop off all passengers for all the given trips, or false otherwise.

     

    -

    Example 1:

    -Input: trips = [[2,1,5],[3,3,7]], capacity = 4
    -Output: false
    +Input: trips = [[2,1,5],[3,3,7]], capacity = 4
    +Output: false
     
    -

    Example 2:

    -Input: trips = [[2,1,5],[3,3,7]], capacity = 5
    -Output: true
    +Input: trips = [[2,1,5],[3,3,7]], capacity = 5
    +Output: true
     
    -

    Example 3:

    -Input: trips = [[2,1,5],[3,5,7]], capacity = 3
    -Output: true
    +Input: trips = [[2,1,5],[3,5,7]], capacity = 3
    +Output: true
     
    -

    Example 4:

    -Input: trips = [[3,2,7],[3,7,9],[8,3,9]], capacity = 11
    -Output: true
    +Input: trips = [[3,2,7],[3,7,9],[8,3,9]], capacity = 11
    +Output: true
     
    -
    -
    -
    - -
    -
    -
    -
     
    -
    -
    -

     

    Constraints:

    -
      -
    1. trips.length <= 1000
    2. +
        +
      • 1 <= trips.length <= 1000
      • trips[i].length == 3
      • -
      • 1 <= trips[i][0] <= 100
      • -
      • 0 <= trips[i][1] < trips[i][2] <= 1000
      • -
      • 1 <= capacity <= 100000
      • -
    +
  • 1 <= numPassengersi <= 100
  • +
  • 0 <= fromi < toi <= 1000
  • +
  • 1 <= capacity <= 105
  • + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/check-if-move-is-legal/README.md b/problems/check-if-move-is-legal/README.md new file mode 100644 index 000000000..9d7c0f21c --- /dev/null +++ b/problems/check-if-move-is-legal/README.md @@ -0,0 +1,64 @@ + + + + + + + +[< Previous](../delete-characters-to-make-fancy-string "Delete Characters to Make Fancy String") +                 +[Next >](../minimum-total-space-wasted-with-k-resizing-operations "Minimum Total Space Wasted With K Resizing Operations") + +## [1958. Check if Move is Legal (Medium)](https://leetcode.com/problems/check-if-move-is-legal "检查操作是否合法") + +

    You are given a 0-indexed 8 x 8 grid board, where board[r][c] represents the cell (r, c) on a game board. On the board, free cells are represented by '.', white cells are represented by 'W', and black cells are represented by 'B'.

    + +

    Each move in this game consists of choosing a free cell and changing it to the color you are playing as (either white or black). However, a move is only legal if, after changing it, the cell becomes the endpoint of a good line (horizontal, vertical, or diagonal).

    + +

    A good line is a line of three or more cells (including the endpoints) where the endpoints of the line are one color, and the remaining cells in the middle are the opposite color (no cells in the line are free). You can find examples for good lines in the figure below:

    + +

    Given two integers rMove and cMove and a character color representing the color you are playing as (white or black), return true if changing cell (rMove, cMove) to color color is a legal move, or false if it is not legal.

    + +

     

    +

    Example 1:

    + +
    +Input: board = [[".",".",".","B",".",".",".","."],[".",".",".","W",".",".",".","."],[".",".",".","W",".",".",".","."],[".",".",".","W",".",".",".","."],["W","B","B",".","W","W","W","B"],[".",".",".","B",".",".",".","."],[".",".",".","B",".",".",".","."],[".",".",".","W",".",".",".","."]], rMove = 4, cMove = 3, color = "B"
    +Output: true
    +Explanation: '.', 'W', and 'B' are represented by the colors blue, white, and black respectively, and cell (rMove, cMove) is marked with an 'X'.
    +The two good lines with the chosen cell as an endpoint are annotated above with the red rectangles.
    +
    + +

    Example 2:

    + +
    +Input: board = [[".",".",".",".",".",".",".","."],[".","B",".",".","W",".",".","."],[".",".","W",".",".",".",".","."],[".",".",".","W","B",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".",".","B","W",".","."],[".",".",".",".",".",".","W","."],[".",".",".",".",".",".",".","B"]], rMove = 4, cMove = 4, color = "W"
    +Output: false
    +Explanation: While there are good lines with the chosen cell as a middle cell, there are no good lines with the chosen cell as an endpoint.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • board.length == board[r].length == 8
    • +
    • 0 <= rMove, cMove < 8
    • +
    • board[rMove][cMove] == '.'
    • +
    • color is either 'B' or 'W'.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +For each line starting at the given cell check if it's a good line +
    + +
    +Hint 2 +To do that iterate over all directions horizontal, vertical, and diagonals then check good lines naively +
    diff --git a/problems/check-if-string-is-a-prefix-of-array/README.md b/problems/check-if-string-is-a-prefix-of-array/README.md new file mode 100644 index 000000000..05ac3e98c --- /dev/null +++ b/problems/check-if-string-is-a-prefix-of-array/README.md @@ -0,0 +1,61 @@ + + + + + + + +[< Previous](../maximum-product-of-the-length-of-two-palindromic-substrings "Maximum Product of the Length of Two Palindromic Substrings") +                 +[Next >](../remove-stones-to-minimize-the-total "Remove Stones to Minimize the Total") + +## [1961. Check If String Is a Prefix of Array (Easy)](https://leetcode.com/problems/check-if-string-is-a-prefix-of-array "检查字符串是否为数组前缀") + +

    Given a string s and an array of strings words, determine whether s is a prefix string of words.

    + +

    A string s is a prefix string of words if s can be made by concatenating the first k strings in words for some positive k no larger than words.length.

    + +

    Return true if s is a prefix string of words, or false otherwise.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "iloveleetcode", words = ["i","love","leetcode","apples"]
    +Output: true
    +Explanation:
    +s can be made by concatenating "i", "love", and "leetcode" together.
    +
    + +

    Example 2:

    + +
    +Input: s = "iloveleetcode", words = ["apples","i","love","leetcode"]
    +Output: false
    +Explanation:
    +It is impossible to make s using a prefix of arr.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 100
    • +
    • 1 <= words[i].length <= 20
    • +
    • 1 <= s.length <= 1000
    • +
    • words[i] and s consist of only lowercase English letters.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +There are only words.length prefix strings. +
    + +
    +Hint 2 +Create all of them and see if s is one of them. +
    diff --git a/problems/check-if-string-is-decomposable-into-value-equal-substrings/README.md b/problems/check-if-string-is-decomposable-into-value-equal-substrings/README.md index bc5640f2f..f15f0c542 100644 --- a/problems/check-if-string-is-decomposable-into-value-equal-substrings/README.md +++ b/problems/check-if-string-is-decomposable-into-value-equal-substrings/README.md @@ -13,6 +13,9 @@ +### Related Topics + [[String](../../tag/string/README.md)] + ### Hints
    Hint 1 diff --git a/problems/clumsy-factorial/README.md b/problems/clumsy-factorial/README.md index e946867c2..0d81c8f41 100644 --- a/problems/clumsy-factorial/README.md +++ b/problems/clumsy-factorial/README.md @@ -11,42 +11,47 @@ ## [1006. Clumsy Factorial (Medium)](https://leetcode.com/problems/clumsy-factorial "笨阶乘") -

    Normally, the factorial of a positive integer n is the product of all positive integers less than or equal to n.  For example, factorial(10) = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1.

    +

    The factorial of a positive integer n is the product of all positive integers less than or equal to n.

    -

    We instead make a clumsy factorial: using the integers in decreasing order, we swap out the multiply operations for a fixed rotation of operations: multiply (*), divide (/), add (+) and subtract (-) in this order.

    +
      +
    • For example, factorial(10) = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1.
    • +
    -

    For example, clumsy(10) = 10 * 9 / 8 + 7 - 6 * 5 / 4 + 3 - 2 * 1.  However, these operations are still applied using the usual order of operations of arithmetic: we do all multiplication and division steps before any addition or subtraction steps, and multiplication and division steps are processed left to right.

    +

    We make a clumsy factorial using the integers in decreasing order by swapping out the multiply operations for a fixed rotation of operations with multiply '*', divide '/', add '+', and subtract '-' in this order.

    -

    Additionally, the division that we use is floor division such that 10 * 9 / 8 equals 11.  This guarantees the result is an integer.

    +
      +
    • For example, clumsy(10) = 10 * 9 / 8 + 7 - 6 * 5 / 4 + 3 - 2 * 1.
    • +
    -

    Implement the clumsy function as defined above: given an integer n, it returns the clumsy factorial of n.

    +

    However, these operations are still applied using the usual order of operations of arithmetic. We do all multiplication and division steps before any addition or subtraction steps, and multiplication and division steps are processed left to right.

    -

     

    +

    Additionally, the division that we use is floor division such that 10 * 9 / 8 = 90 / 8 = 11.

    + +

    Given an integer n, return the clumsy factorial of n.

    +

     

    Example 1:

    -Input: n = 4
    -Output: 7
    +Input: n = 4
    +Output: 7
     Explanation: 7 = 4 * 3 / 2 + 1
     

    Example 2:

    -Input: n = 10
    -Output: 12
    -Explanation: 12 = 10 * 9 / 8 + 7 - 6 * 5 / 4 + 3 - 2 * 1
    +Input: n = 10
    +Output: 12
    +Explanation: 12 = 10 * 9 / 8 + 7 - 6 * 5 / 4 + 3 - 2 * 1
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= n <= 10000
    2. -
    3. -231 <= answer <= 231 - 1  (The answer is guaranteed to fit within a 32-bit integer.)
    4. -
    +
      +
    • 1 <= n <= 104
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/coloring-a-border/README.md b/problems/coloring-a-border/README.md index 159d3e8d9..cd71bfc1e 100644 --- a/problems/coloring-a-border/README.md +++ b/problems/coloring-a-border/README.md @@ -11,52 +11,38 @@ ## [1034. Coloring A Border (Medium)](https://leetcode.com/problems/coloring-a-border "边框着色") -

    Given a 2-dimensional grid of integers, each value in the grid represents the color of the grid square at that location.

    +

    You are given an m x n integer matrix grid, and three integers row, col, and color. Each value in the grid represents the color of the grid square at that location.

    -

    Two squares belong to the same connected component if and only if they have the same color and are next to each other in any of the 4 directions.

    +

    Two squares belong to the same connected component if they have the same color and are next to each other in any of the 4 directions.

    -

    The border of a connected component is all the squares in the connected component that are either 4-directionally adjacent to a square not in the component, or on the boundary of the grid (the first or last row or column).

    +

    The border of a connected component is all the squares in the connected component that are either 4-directionally adjacent to a square not in the component, or on the boundary of the grid (the first or last row or column).

    -

    Given a square at location (r0, c0) in the grid and a color, color the border of the connected component of that square with the given color, and return the final grid.

    +

    You should color the border of the connected component that contains the square grid[row][col] with color.

    -

     

    +

    Return the final grid.

    +

     

    Example 1:

    - -
    -Input: grid = [[1,1],[1,2]], r0 = 0, c0 = 0, color = 3
    -Output: [[3, 3], [3, 2]]
    -
    - -
    -

    Example 2:

    - -
    -Input: grid = [[1,2,2],[2,3,2]], r0 = 0, c0 = 1, color = 3
    -Output: [[1, 3, 3], [2, 3, 3]]
    +
    Input: grid = [[1,1],[1,2]], row = 0, col = 0, color = 3
    +Output: [[3,3],[3,2]]
    +

    Example 2:

    +
    Input: grid = [[1,2,2],[2,3,2]], row = 0, col = 1, color = 3
    +Output: [[1,3,3],[2,3,3]]
    +

    Example 3:

    +
    Input: grid = [[1,1,1],[1,1,1],[1,1,1]], row = 1, col = 1, color = 2
    +Output: [[2,2,2],[2,1,2],[2,2,2]]
     
    - -
    -

    Example 3:

    - -
    -Input: grid = [[1,1,1],[1,1,1],[1,1,1]], r0 = 1, c0 = 1, color = 2
    -Output: [[2, 2, 2], [2, 1, 2], [2, 2, 2]]
    -
    -
    -

     

    - -

    Note:

    - -
      -
    1. 1 <= grid.length <= 50
    2. -
    3. 1 <= grid[0].length <= 50
    4. -
    5. 1 <= grid[i][j] <= 1000
    6. -
    7. 0 <= r0 < grid.length
    8. -
    9. 0 <= c0 < grid[0].length
    10. -
    11. 1 <= color <= 1000
    12. -
    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 50
    • +
    • 1 <= grid[i][j], color <= 1000
    • +
    • 0 <= row < m
    • +
    • 0 <= col < n
    • +
    ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/complement-of-base-10-integer/README.md b/problems/complement-of-base-10-integer/README.md index 57fd323be..ba166f6bd 100644 --- a/problems/complement-of-base-10-integer/README.md +++ b/problems/complement-of-base-10-integer/README.md @@ -11,55 +11,48 @@ ## [1009. Complement of Base 10 Integer (Easy)](https://leetcode.com/problems/complement-of-base-10-integer "十进制整数的反码") -

    Every non-negative integer n has a binary representation.  For example, 5 can be represented as "101" in binary, 11 as "1011" in binary, and so on.  Note that except for n = 0, there are no leading zeroes in any binary representation.

    +

    The complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation.

    -

    The complement of a binary representation is the number in binary you get when changing every 1 to a 0 and 0 to a 1.  For example, the complement of "101" in binary is "010" in binary.

    +
      +
    • For example, The integer 5 is "101" in binary and its complement is "010" which is the integer 2.
    • +
    -

    For a given number n in base-10, return the complement of it's binary representation as a base-10 integer.

    +

    Given an integer n, return its complement.

     

    - -
      -
    - -

    Example 1:

    -Input: n = 5
    -Output: 2
    -Explanation: 5 is "101" in binary, with complement "010" in binary, which is 2 in base-10.
    +Input: n = 5
    +Output: 2
    +Explanation: 5 is "101" in binary, with complement "010" in binary, which is 2 in base-10.
     
    -

    Example 2:

    -Input: n = 7
    -Output: 0
    -Explanation: 7 is "111" in binary, with complement "000" in binary, which is 0 in base-10.
    -
    +Input: n = 7 +Output: 0 +Explanation: 7 is "111" in binary, with complement "000" in binary, which is 0 in base-10. + -

    Example 3:

    -Input: n = 10
    -Output: 5
    -Explanation: 10 is "1010" in binary, with complement "0101" in binary, which is 5 in base-10.
    +Input: n = 10
    +Output: 5
    +Explanation: 10 is "1010" in binary, with complement "0101" in binary, which is 5 in base-10.
     

     

    +

    Constraints:

    -

    Note:

    - -
      +
    -
    -
    -
    + + +

     

    +

    Note: This question is the same as 476: https://leetcode.com/problems/number-complement/

    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/complete-binary-tree-inserter/README.md b/problems/complete-binary-tree-inserter/README.md index 88a69dde3..976e635a4 100644 --- a/problems/complete-binary-tree-inserter/README.md +++ b/problems/complete-binary-tree-inserter/README.md @@ -11,55 +11,45 @@ ## [919. Complete Binary Tree Inserter (Medium)](https://leetcode.com/problems/complete-binary-tree-inserter "完全二叉树插入器") -

    A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.

    +

    A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.

    -

    Write a data structure CBTInserter that is initialized with a complete binary tree and supports the following operations:

    +

    Design an algorithm to insert a new node to a complete binary tree keeping it complete after the insertion.

    + +

    Implement the CBTInserter class:

      -
    • CBTInserter(TreeNode root) initializes the data structure on a given tree with head node root;
    • -
    • CBTInserter.insert(int v) will insert a TreeNode into the tree with value node.val = v so that the tree remains complete, and returns the value of the parent of the inserted TreeNode;
    • -
    • CBTInserter.get_root() will return the head node of the tree.
    • +
    • CBTInserter(TreeNode root) Initializes the data structure with the root of the complete binary tree.
    • +
    • int insert(int v) Inserts a TreeNode into the tree with value Node.val == val so that the tree remains complete, and returns the value of the parent of the inserted TreeNode.
    • +
    • TreeNode get_root() Returns the root node of the tree.
    -
      -
    - -

     

    -

    Example 1:

    - +
    -Input: inputs = ["CBTInserter","insert","get_root"], inputs = [[[1]],[2],[]]
    -Output: [null,1,[1,2]]
    +Input
    +["CBTInserter", "insert", "insert", "get_root"]
    +[[[1, 2]], [3], [4], []]
    +Output
    +[null, 1, 2, [1, 2, 3, 4]]
    +
    +Explanation
    +CBTInserter cBTInserter = new CBTInserter([1, 2]);
    +cBTInserter.insert(3);  // return 1
    +cBTInserter.insert(4);  // return 2
    +cBTInserter.get_root(); // return [1, 2, 3, 4]
     
    -
    -

    Example 2:

    - -
    -Input: inputs = ["CBTInserter","insert","insert","get_root"], inputs = [[[1,2,3,4,5,6]],[7],[8],[]]
    -Output: [null,3,4,[1,2,3,4,5,6,7,8]]
    -
    - -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. The initial given tree is complete and contains between 1 and 1000 nodes.
    2. -
    3. CBTInserter.insert is called at most 10000 times per test case.
    4. -
    5. Every value of a given or inserted node is between 0 and 5000.
    6. -
    -
    -
    - -
    -

     

    - -
     
    -
    +
      +
    • The number of nodes in the tree will be in the range [1, 1000].
    • +
    • 0 <= Node.val <= 5000
    • +
    • root is a complete binary tree.
    • +
    • 0 <= val <= 5000
    • +
    • At most 104 calls will be made to insert and get_root.
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/consecutive-characters/README.md b/problems/consecutive-characters/README.md index 4dc643039..c605bae72 100644 --- a/problems/consecutive-characters/README.md +++ b/problems/consecutive-characters/README.md @@ -11,9 +11,9 @@ ## [1446. Consecutive Characters (Easy)](https://leetcode.com/problems/consecutive-characters "连续字符") -

    Given a string s, the power of the string is the maximum length of a non-empty substring that contains only one unique character.

    +

    The power of the string is the maximum length of a non-empty substring that contains only one unique character.

    -

    Return the power of the string.

    +

    Given a string s, return the power of s.

     

    Example 1:

    @@ -58,7 +58,7 @@
    • 1 <= s.length <= 500
    • -
    • s contains only lowercase English letters.
    • +
    • s consists of only lowercase English letters.
    ### Related Topics diff --git a/problems/convert-to-base-2/README.md b/problems/convert-to-base-2/README.md index b6f198691..485e14739 100644 --- a/problems/convert-to-base-2/README.md +++ b/problems/convert-to-base-2/README.md @@ -11,49 +11,41 @@ ## [1017. Convert to Base -2 (Medium)](https://leetcode.com/problems/convert-to-base-2 "负二进制转换") -

    Given a number n, return a string consisting of "0"s and "1"s that represents its value in base -2 (negative two).

    +

    Given an integer n, return a binary string representing its representation in base -2.

    -

    The returned string must have no leading zeroes, unless the string is "0".

    +

    Note that the returned string should not have leading zeros unless the string is "0".

     

    - -

    Example 1:

    -Input: n = 2
    -Output: "110"
    -Explantion: (-2) ^ 2 + (-2) ^ 1 = 2
    +Input: n = 2
    +Output: "110"
    +Explantion: (-2)2 + (-2)1 = 2
     
    -

    Example 2:

    -Input: n = 3
    -Output: "111"
    -Explantion: (-2) ^ 2 + (-2) ^ 1 + (-2) ^ 0 = 3
    +Input: n = 3
    +Output: "111"
    +Explantion: (-2)2 + (-2)1 + (-2)0 = 3
     
    -

    Example 3:

    -Input: n = 4
    -Output: "100"
    -Explantion: (-2) ^ 2 = 4
    +Input: n = 4
    +Output: "100"
    +Explantion: (-2)2 = 4
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 0 <= n <= 109
    2. -
    -
    -
    -
    +
      +
    • 0 <= n <= 109
    • +
    ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/count-nodes-equal-to-sum-of-descendants/README.md b/problems/count-nodes-equal-to-sum-of-descendants/README.md new file mode 100644 index 000000000..d528cc422 --- /dev/null +++ b/problems/count-nodes-equal-to-sum-of-descendants/README.md @@ -0,0 +1,25 @@ + + + + + + + +[< Previous](../first-and-last-call-on-the-same-day "First and Last Call On the Same Day") +                 +[Next >](../minimum-time-to-type-word-using-special-typewriter "Minimum Time to Type Word Using Special Typewriter") + +## [1973. Count Nodes Equal to Sum of Descendants (Medium)](https://leetcode.com/problems/count-nodes-equal-to-sum-of-descendants "") + + + +### Hints +
    +Hint 1 +Can we reuse previously calculated information? +
    + +
    +Hint 2 +How can we calculate the sum of the current subtree using the sum of the child's subtree? +
    diff --git a/problems/count-number-of-special-subsequences/README.md b/problems/count-number-of-special-subsequences/README.md index 96d9cf6e9..66ffca864 100644 --- a/problems/count-number-of-special-subsequences/README.md +++ b/problems/count-number-of-special-subsequences/README.md @@ -7,7 +7,7 @@ [< Previous](../minimum-garden-perimeter-to-collect-enough-apples "Minimum Garden Perimeter to Collect Enough Apples")                  -Next > +[Next >](../minimum-time-for-k-virus-variants-to-spread "Minimum Time For K Virus Variants to Spread") ## [1955. Count Number of Special Subsequences (Hard)](https://leetcode.com/problems/count-number-of-special-subsequences "统计特殊子序列的数目") @@ -28,7 +28,7 @@ Next >
     Input: nums = [0,1,2,2]
     Output: 3
    -Explanation: The special subsequences are [0,1,2,2], [0,1,2,2], and [0,1,2,2].
    +Explanation: The special subsequences are bolded [0,1,2,2], [0,1,2,2], and [0,1,2,2].
     

    Example 2:

    @@ -44,14 +44,14 @@ Next >
     Input: nums = [0,1,2,0,1,2]
     Output: 7
    -Explanation: The special subsequences are:
    -- [0,1,2,0,1,2]
    -- [0,1,2,0,1,2]
    -- [0,1,2,0,1,2]
    -- [0,1,2,0,1,2]
    -- [0,1,2,0,1,2]
    -- [0,1,2,0,1,2]
    -- [0,1,2,0,1,2]
    +Explanation: The special subsequences are bolded:
    +- [0,1,2,0,1,2]
    +- [0,1,2,0,1,2]
    +- [0,1,2,0,1,2]
    +- [0,1,2,0,1,2]
    +- [0,1,2,0,1,2]
    +- [0,1,2,0,1,2]
    +- [0,1,2,0,1,2]
     

     

    @@ -62,6 +62,10 @@ Next >
  • 0 <= nums[i] <= 2
  • +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + ### Hints
    Hint 1 diff --git a/problems/cracking-the-safe/README.md b/problems/cracking-the-safe/README.md index 67b8cac1e..9682f5adb 100644 --- a/problems/cracking-the-safe/README.md +++ b/problems/cracking-the-safe/README.md @@ -11,15 +11,24 @@ ## [753. Cracking the Safe (Hard)](https://leetcode.com/problems/cracking-the-safe "破解保险箱") -

    There is a box protected by a password. The password is a sequence of n digits where each digit can be in the range [0, k - 1].

    +

    There is a safe protected by a password. The password is a sequence of n digits where each digit can be in the range [0, k - 1].

    -

    While entering a password, the last n digits entered will automatically be matched against the correct password.

    +

    The safe has a peculiar way of checking the password. When you enter in a sequence, it checks the most recent n digits that were entered each time you type a digit.

      -
    • For example, assuming the correct password is "345", if you type "012345", the box will open because the correct password matches the suffix of the entered password.
    • +
    • For example, the correct password is "345" and you enter in "012345": +
        +
      • After typing 0, the most recent 3 digits is "0", which is incorrect.
      • +
      • After typing 1, the most recent 3 digits is "01", which is incorrect.
      • +
      • After typing 2, the most recent 3 digits is "012", which is incorrect.
      • +
      • After typing 3, the most recent 3 digits is "123", which is incorrect.
      • +
      • After typing 4, the most recent 3 digits is "234", which is incorrect.
      • +
      • After typing 5, the most recent 3 digits is "345", which is correct and the safe unlocks.
      • +
      +
    -

    Return any password of minimum length that is guaranteed to open the box at some point of entering it.

    +

    Return any string of minimum length that will unlock the safe at some point of entering it.

     

    Example 1:

    @@ -27,7 +36,7 @@
     Input: n = 1, k = 2
     Output: "10"
    -Explanation: "01" will be accepted too.
    +Explanation: The password is a single digit, so enter each digit. "01" would also unlock the safe.
     

    Example 2:

    @@ -35,7 +44,12 @@
     Input: n = 2, k = 2
     Output: "01100"
    -Explanation: "01100", "10011", "11001" will be accepted too.
    +Explanation: For each possible password:
    +- "00" is typed in starting from the 4th digit.
    +- "01" is typed in starting from the 1st digit.
    +- "10" is typed in starting from the 3rd digit.
    +- "11" is typed in starting from the 2nd digit.
    +Thus "01100" will unlock the safe. "01100", "10011", and "11001" would also unlock the safe.
     

     

    diff --git a/problems/critical-connections-in-a-network/README.md b/problems/critical-connections-in-a-network/README.md index d8e2dc613..244ee23af 100644 --- a/problems/critical-connections-in-a-network/README.md +++ b/problems/critical-connections-in-a-network/README.md @@ -19,15 +19,20 @@

     

    Example 1:

    - -

    - +
     Input: n = 4, connections = [[0,1],[1,2],[2,0],[1,3]]
     Output: [[1,3]]
     Explanation: [[3,1]] is also accepted.
     
    +

    Example 2:

    + +
    +Input: n = 2, connections = [[0,1]]
    +Output: [[0,1]]
    +
    +

     

    Constraints:

    diff --git a/problems/delete-characters-to-make-fancy-string/README.md b/problems/delete-characters-to-make-fancy-string/README.md new file mode 100644 index 000000000..a97b0bf67 --- /dev/null +++ b/problems/delete-characters-to-make-fancy-string/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../minimum-time-for-k-virus-variants-to-spread "Minimum Time For K Virus Variants to Spread") +                 +[Next >](../check-if-move-is-legal "Check if Move is Legal") + +## [1957. Delete Characters to Make Fancy String (Easy)](https://leetcode.com/problems/delete-characters-to-make-fancy-string "删除字符使字符串变好") + +

    A fancy string is a string where no three consecutive characters are equal.

    + +

    Given a string s, delete the minimum possible number of characters from s to make it fancy.

    + +

    Return the final string after the deletion. It can be shown that the answer will always be unique.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "leeetcode"
    +Output: "leetcode"
    +Explanation:
    +Remove an 'e' from the first group of 'e's to create "leetcode".
    +No three consecutive characters are equal, so return "leetcode".
    +
    + +

    Example 2:

    + +
    +Input: s = "aaabaaaa"
    +Output: "aabaa"
    +Explanation:
    +Remove an 'a' from the first group of 'a's to create "aabaaaa".
    +Remove two 'a's from the second group of 'a's to create "aabaa".
    +No three consecutive characters are equal, so return "aabaa".
    +
    + +

    Example 3:

    + +
    +Input: s = "aab"
    +Output: "aab"
    +Explanation: No three consecutive characters are equal, so return "aab".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 105
    • +
    • s consists only of lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +What's the optimal way to delete characters if three or more consecutive characters are equal? +
    + +
    +Hint 2 +If three or more consecutive characters are equal, keep two of them and delete the rest. +
    diff --git a/problems/distinct-subsequences-ii/README.md b/problems/distinct-subsequences-ii/README.md index ef1852f36..f9799dc58 100644 --- a/problems/distinct-subsequences-ii/README.md +++ b/problems/distinct-subsequences-ii/README.md @@ -27,7 +27,7 @@ A subsequence of a string is a new string that is formed from t
     Input: s = "aba"
     Output: 6
    -Explanation: The 7 distinct subsequences are "a", "b", "c", "ab", "ac", "bc", and "abc".
    +Explanation: The 6 distinct subsequences are "a", "b", "ab", "aa", "ba", and "aba".
     

    Example 3:

    diff --git a/problems/duplicate-zeros/README.md b/problems/duplicate-zeros/README.md index b905a4601..b2a925bf9 100644 --- a/problems/duplicate-zeros/README.md +++ b/problems/duplicate-zeros/README.md @@ -11,38 +11,34 @@ ## [1089. Duplicate Zeros (Easy)](https://leetcode.com/problems/duplicate-zeros "复写零") -

    Given a fixed length array arr of integers, duplicate each occurrence of zero, shifting the remaining elements to the right.

    +

    Given a fixed-length integer array arr, duplicate each occurrence of zero, shifting the remaining elements to the right.

    -

    Note that elements beyond the length of the original array are not written.

    - -

    Do the above modifications to the input array in place, do not return anything from your function.

    +

    Note that elements beyond the length of the original array are not written. Do the above modifications to the input array in place and do not return anything.

     

    -

    Example 1:

    -Input: [1,0,2,3,0,4,5,0]
    -Output: null
    -Explanation: After calling your function, the input array is modified to: [1,0,0,2,3,0,0,4]
    +Input: arr = [1,0,2,3,0,4,5,0]
    +Output: [1,0,0,2,3,0,0,4]
    +Explanation: After calling your function, the input array is modified to: [1,0,0,2,3,0,0,4]
     

    Example 2:

    -Input: [1,2,3]
    -Output: null
    -Explanation: After calling your function, the input array is modified to: [1,2,3]
    +Input: arr = [1,2,3]
    +Output: [1,2,3]
    +Explanation: After calling your function, the input array is modified to: [1,2,3]
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= arr.length <= 10000
    2. +
        +
      • 1 <= arr.length <= 104
      • 0 <= arr[i] <= 9
      • -
    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/employees-whose-manager-left-the-company/README.md b/problems/employees-whose-manager-left-the-company/README.md new file mode 100644 index 000000000..87587b2e7 --- /dev/null +++ b/problems/employees-whose-manager-left-the-company/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../number-of-ways-to-separate-numbers "Number of Ways to Separate Numbers") +                 +[Next >](../find-greatest-common-divisor-of-array "Find Greatest Common Divisor of Array") + +## [1978. Employees Whose Manager Left the Company (Easy)](https://leetcode.com/problems/employees-whose-manager-left-the-company "") + + diff --git a/problems/employees-whose-manager-left-the-company/mysql_schemas.sql b/problems/employees-whose-manager-left-the-company/mysql_schemas.sql new file mode 100644 index 000000000..8b8c69f9a --- /dev/null +++ b/problems/employees-whose-manager-left-the-company/mysql_schemas.sql @@ -0,0 +1,8 @@ +Create table If Not Exists Employees (employee_id int, name varchar(20), manager_id int, salary int); +Truncate table Employees; +insert into Employees (employee_id, name, manager_id, salary) values ('3', 'Mila', '9', '60301'); +insert into Employees (employee_id, name, manager_id, salary) values ('12', 'Antonella', 'None', '31000'); +insert into Employees (employee_id, name, manager_id, salary) values ('13', 'Emery', 'None', '67084'); +insert into Employees (employee_id, name, manager_id, salary) values ('1', 'Kalel', '11', '21241'); +insert into Employees (employee_id, name, manager_id, salary) values ('9', 'Mikaela', 'None', '50937'); +insert into Employees (employee_id, name, manager_id, salary) values ('11', 'Joziah', '6', '28485'); diff --git a/problems/employees-with-missing-information/README.md b/problems/employees-with-missing-information/README.md new file mode 100644 index 000000000..7c289fa10 --- /dev/null +++ b/problems/employees-with-missing-information/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../find-the-longest-valid-obstacle-course-at-each-position "Find the Longest Valid Obstacle Course at Each Position") +                 +[Next >](../binary-searchable-numbers-in-an-unsorted-array "Binary Searchable Numbers in an Unsorted Array") + +## [1965. Employees With Missing Information (Easy)](https://leetcode.com/problems/employees-with-missing-information "") + + diff --git a/problems/employees-with-missing-information/mysql_schemas.sql b/problems/employees-with-missing-information/mysql_schemas.sql new file mode 100644 index 000000000..811fe3cbc --- /dev/null +++ b/problems/employees-with-missing-information/mysql_schemas.sql @@ -0,0 +1,10 @@ +Create table If Not Exists Employees (employee_id int, name varchar(30)); +Create table If Not Exists Salaries (employee_id int, salary int); +Truncate table Employees; +insert into Employees (employee_id, name) values ('2', 'Crew'); +insert into Employees (employee_id, name) values ('4', 'Haven'); +insert into Employees (employee_id, name) values ('5', 'Kristian'); +Truncate table Salaries; +insert into Salaries (employee_id, salary) values ('5', '76071'); +insert into Salaries (employee_id, salary) values ('1', '22517'); +insert into Salaries (employee_id, salary) values ('4', '63539'); diff --git a/problems/erect-the-fence-ii/README.md b/problems/erect-the-fence-ii/README.md index 3d4143b02..3b214df0e 100644 --- a/problems/erect-the-fence-ii/README.md +++ b/problems/erect-the-fence-ii/README.md @@ -13,6 +13,11 @@ +### Related Topics + [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + ### Hints
    Hint 1 diff --git a/problems/filling-bookcase-shelves/README.md b/problems/filling-bookcase-shelves/README.md index 096adb2b1..7906d6302 100644 --- a/problems/filling-bookcase-shelves/README.md +++ b/problems/filling-bookcase-shelves/README.md @@ -11,34 +11,45 @@ ## [1105. Filling Bookcase Shelves (Medium)](https://leetcode.com/problems/filling-bookcase-shelves "填充书架") -

    We have a sequence of books: the i-th book has thickness books[i][0] and height books[i][1].

    +

    You are given an array books where books[i] = [thicknessi, heighti] indicates the thickness and height of the ith book. You are also given an integer shelfWidth.

    -

    We want to place these books in order onto bookcase shelves that have total width shelf_width.

    +

    We want to place these books in order onto bookcase shelves that have a total width shelfWidth.

    -

    We choose some of the books to place on this shelf (such that the sum of their thickness is <= shelf_width), then build another level of shelf of the bookcase so that the total height of the bookcase has increased by the maximum height of the books we just put down.  We repeat this process until there are no more books to place.

    +

    We choose some of the books to place on this shelf such that the sum of their thickness is less than or equal to shelfWidth, then build another level of the shelf of the bookcase so that the total height of the bookcase has increased by the maximum height of the books we just put down. We repeat this process until there are no more books to place.

    -

    Note again that at each step of the above process, the order of the books we place is the same order as the given sequence of books.  For example, if we have an ordered list of 5 books, we might place the first and second book onto the first shelf, the third book on the second shelf, and the fourth and fifth book on the last shelf.

    +

    Note that at each step of the above process, the order of the books we place is the same order as the given sequence of books.

    -

    Return the minimum possible height that the total bookshelf can be after placing shelves in this manner.

    +
      +
    • For example, if we have an ordered list of 5 books, we might place the first and second book onto the first shelf, the third book on the second shelf, and the fourth and fifth book on the last shelf.
    • +
    + +

    Return the minimum possible height that the total bookshelf can be after placing shelves in this manner.

     

    Example 1:

    - +
     Input: books = [[1,1],[2,3],[2,3],[1,1],[1,1],[1,1],[1,2]], shelf_width = 4
     Output: 6
     Explanation:
    -The sum of the heights of the 3 shelves are 1 + 3 + 2 = 6.
    +The sum of the heights of the 3 shelves is 1 + 3 + 2 = 6.
     Notice that book number 2 does not have to be on the first shelf.
     
    +

    Example 2:

    + +
    +Input: books = [[1,3],[2,4],[3,2]], shelfWidth = 6
    +Output: 4
    +
    +

     

    Constraints:

    • 1 <= books.length <= 1000
    • -
    • 1 <= books[i][0] <= shelf_width <= 1000
    • -
    • 1 <= books[i][1] <= 1000
    • +
    • 1 <= thicknessi <= shelfWidth <= 1000
    • +
    • 1 <= heighti <= 1000
    ### Related Topics diff --git a/problems/find-all-anagrams-in-a-string/README.md b/problems/find-all-anagrams-in-a-string/README.md index 3f48bf74e..bde000153 100644 --- a/problems/find-all-anagrams-in-a-string/README.md +++ b/problems/find-all-anagrams-in-a-string/README.md @@ -13,6 +13,8 @@

    Given two strings s and p, return an array of all the start indices of p's anagrams in s. You may 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.

    +

     

    Example 1:

    diff --git a/problems/find-array-given-subset-sums/README.md b/problems/find-array-given-subset-sums/README.md new file mode 100644 index 000000000..5a33915d9 --- /dev/null +++ b/problems/find-array-given-subset-sums/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../minimize-the-difference-between-target-and-chosen-elements "Minimize the Difference Between Target and Chosen Elements") +                 +[Next >](../widest-pair-of-indices-with-equal-range-sum "Widest Pair of Indices With Equal Range Sum") + +## [1982. Find Array Given Subset Sums (Hard)](https://leetcode.com/problems/find-array-given-subset-sums "从子集的和还原数组") + +

    You are given an integer n representing the length of an unknown array that you are trying to recover. You are also given an array sums containing the values of all 2n subset sums of the unknown array (in no particular order).

    + +

    Return the array ans of length n representing the unknown array. If multiple answers exist, return any of them.

    + +

    An array sub is a subset of an array arr if sub can be obtained from arr by deleting some (possibly zero or all) elements of arr. The sum of the elements in sub is one possible subset sum of arr. The sum of an empty array is considered to be 0.

    + +

    Note: Test cases are generated such that there will always be at least one correct answer.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 3, sums = [-3,-2,-1,0,0,1,2,3]
    +Output: [1,2,-3]
    +Explanation: [1,2,-3] is able to achieve the given subset sums:
    +- []: sum is 0
    +- [1]: sum is 1
    +- [2]: sum is 2
    +- [1,2]: sum is 3
    +- [-3]: sum is -3
    +- [1,-3]: sum is -2
    +- [2,-3]: sum is -1
    +- [1,2,-3]: sum is 0
    +Note that any permutation of [1,2,-3] and also any permutation of [-1,-2,3] will also be accepted.
    +
    + +

    Example 2:

    + +
    +Input: n = 2, sums = [0,0,0,0]
    +Output: [0,0]
    +Explanation: The only correct answer is [0,0].
    +
    + +

    Example 3:

    + +
    +Input: n = 4, sums = [0,0,5,5,4,-1,4,9,9,-1,4,3,4,8,3,8]
    +Output: [0,-1,4,5]
    +Explanation: [0,-1,4,5] is able to achieve the given subset sums.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 15
    • +
    • sums.length == 2n
    • +
    • -104 <= sums[i] <= 104
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + +### Hints +
    +Hint 1 +What information do the two largest elements tell us? +
    + +
    +Hint 2 +Can we use recursion to check all possible states? +
    diff --git a/problems/find-common-characters/README.md b/problems/find-common-characters/README.md index 117a7e7a1..67afcca85 100644 --- a/problems/find-common-characters/README.md +++ b/problems/find-common-characters/README.md @@ -11,39 +11,24 @@ ## [1002. Find Common Characters (Easy)](https://leetcode.com/problems/find-common-characters "查找常用字符") -

    Given an array words of strings made only from lowercase letters, return a list of all characters that show up in all strings within the list (including duplicates).  For example, if a character occurs 3 times in all strings but not 4 times, you need to include that character three times in the final answer.

    - -

    You may return the answer in any order.

    +

    Given a string array words, return an array of all characters that show up in all strings within the words (including duplicates). You may return the answer in any order.

     

    - -

    Example 1:

    - -
    -Input: ["bella","label","roller"]
    -Output: ["e","l","l"]
    -
    - -
    -

    Example 2:

    - -
    -Input: ["cool","lock","cook"]
    -Output: ["c","o"]
    +
    Input: words = ["bella","label","roller"]
    +Output: ["e","l","l"]
    +

    Example 2:

    +
    Input: words = ["cool","lock","cook"]
    +Output: ["c","o"]
     
    -

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= words.length <= 100
      • 1 <= words[i].length <= 100
      • words[i] consists of lowercase English letters.
      • -
    -
    -
    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/find-cutoff-score-for-each-school/README.md b/problems/find-cutoff-score-for-each-school/README.md new file mode 100644 index 000000000..f5ad302b2 --- /dev/null +++ b/problems/find-cutoff-score-for-each-school/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../number-of-unique-good-subsequences "Number of Unique Good Subsequences") +                 +Next > + +## [1988. Find Cutoff Score for Each School (Medium)](https://leetcode.com/problems/find-cutoff-score-for-each-school "") + + diff --git a/problems/find-cutoff-score-for-each-school/mysql_schemas.sql b/problems/find-cutoff-score-for-each-school/mysql_schemas.sql new file mode 100644 index 000000000..451883127 --- /dev/null +++ b/problems/find-cutoff-score-for-each-school/mysql_schemas.sql @@ -0,0 +1,13 @@ +Create table If Not Exists Schools (school_id int, capacity int); +Create table If Not Exists Exam (score int, student_count int); +Truncate table Schools; +insert into Schools (school_id, capacity) values ('11', '151'); +insert into Schools (school_id, capacity) values ('5', '48'); +insert into Schools (school_id, capacity) values ('9', '9'); +insert into Schools (school_id, capacity) values ('10', '99'); +Truncate table Exam; +insert into Exam (score, student_count) values ('975', '10'); +insert into Exam (score, student_count) values ('966', '60'); +insert into Exam (score, student_count) values ('844', '76'); +insert into Exam (score, student_count) values ('749', '76'); +insert into Exam (score, student_count) values ('744', '100'); diff --git a/problems/find-greatest-common-divisor-of-array/README.md b/problems/find-greatest-common-divisor-of-array/README.md new file mode 100644 index 000000000..6eac12499 --- /dev/null +++ b/problems/find-greatest-common-divisor-of-array/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../employees-whose-manager-left-the-company "Employees Whose Manager Left the Company") +                 +[Next >](../find-unique-binary-string "Find Unique Binary String") + +## [1979. Find Greatest Common Divisor of Array (Easy)](https://leetcode.com/problems/find-greatest-common-divisor-of-array "找出数组的最大公约数") + +

    Given an integer array nums, return the greatest common divisor of the smallest number and largest number in nums.

    + +

    The greatest common divisor of two numbers is the largest positive integer that evenly divides both numbers.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [2,5,6,9,10]
    +Output: 2
    +Explanation:
    +The smallest number in nums is 2.
    +The largest number in nums is 10.
    +The greatest common divisor of 2 and 10 is 2.
    +
    + +

    Example 2:

    + +
    +Input: nums = [7,5,6,8,3]
    +Output: 1
    +Explanation:
    +The smallest number in nums is 3.
    +The largest number in nums is 8.
    +The greatest common divisor of 3 and 8 is 1.
    +
    + +

    Example 3:

    + +
    +Input: nums = [3,3]
    +Output: 3
    +Explanation:
    +The smallest number in nums is 3.
    +The largest number in nums is 3.
    +The greatest common divisor of 3 and 3 is 3.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= nums.length <= 1000
    • +
    • 1 <= nums[i] <= 1000
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Find the minimum and maximum in one iteration. Let them be mn and mx. +
    + +
    +Hint 2 +Try all the numbers in the range [1, mn] and check the largest number which divides both of them. +
    diff --git a/problems/find-if-path-exists-in-graph/README.md b/problems/find-if-path-exists-in-graph/README.md new file mode 100644 index 000000000..0853b910c --- /dev/null +++ b/problems/find-if-path-exists-in-graph/README.md @@ -0,0 +1,51 @@ + + + + + + + +[< Previous](../last-day-where-you-can-still-cross "Last Day Where You Can Still Cross") +                 +[Next >](../first-and-last-call-on-the-same-day "First and Last Call On the Same Day") + +## [1971. Find if Path Exists in Graph (Easy)](https://leetcode.com/problems/find-if-path-exists-in-graph "") + +

    There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself.

    + +

    You want to determine if there is a valid path that exists from vertex start to vertex end.

    + +

    Given edges and the integers n, start, and end, return true if there is a valid path from start to end, or false otherwise.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 3, edges = [[0,1],[1,2],[2,0]], start = 0, end = 2
    +Output: true
    +Explanation: There are two paths from vertex 0 to vertex 2:
    +- 0 → 1 → 2
    +- 0 → 2
    +
    + +

    Example 2:

    + +
    +Input: n = 6, edges = [[0,1],[0,2],[3,5],[5,4],[4,3]], start = 0, end = 5
    +Output: false
    +Explanation: There is no path from vertex 0 to vertex 5.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 2 * 105
    • +
    • 0 <= edges.length <= 2 * 105
    • +
    • edges[i].length == 2
    • +
    • 1 <= ui, vi <= n - 1
    • +
    • ui != vi
    • +
    • 1 <= start, end <= n - 1
    • +
    • There are no duplicate edges.
    • +
    • There are no self edges.
    • +
    diff --git a/problems/find-the-kth-largest-integer-in-the-array/README.md b/problems/find-the-kth-largest-integer-in-the-array/README.md new file mode 100644 index 000000000..30741df8a --- /dev/null +++ b/problems/find-the-kth-largest-integer-in-the-array/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../minimum-difference-between-highest-and-lowest-of-k-scores "Minimum Difference Between Highest and Lowest of K Scores") +                 +[Next >](../minimum-number-of-work-sessions-to-finish-the-tasks "Minimum Number of Work Sessions to Finish the Tasks") + +## [1985. Find the Kth Largest Integer in the Array (Medium)](https://leetcode.com/problems/find-the-kth-largest-integer-in-the-array "找出数组中的第 K 大整数") + +

    You are given an array of strings nums and an integer k. Each string in nums represents an integer without leading zeros.

    + +

    Return the string that represents the kth largest integer in nums.

    + +

    Note: Duplicate numbers should be counted distinctly. For example, if nums is ["1","2","2"], "2" is the first largest integer, "2" is the second-largest integer, and "1" is the third-largest integer.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = ["3","6","7","10"], k = 4
    +Output: "3"
    +Explanation:
    +The numbers in nums sorted in non-decreasing order are ["3","6","7","10"].
    +The 4th largest integer in nums is "3".
    +
    + +

    Example 2:

    + +
    +Input: nums = ["2","21","12","1"], k = 3
    +Output: "2"
    +Explanation:
    +The numbers in nums sorted in non-decreasing order are ["1","2","12","21"].
    +The 3rd largest integer in nums is "2".
    +
    + +

    Example 3:

    + +
    +Input: nums = ["0","0"], k = 2
    +Output: "0"
    +Explanation:
    +The numbers in nums sorted in non-decreasing order are ["0","0"].
    +The 2nd largest integer in nums is "0".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= nums.length <= 104
    • +
    • 1 <= nums[i].length <= 100
    • +
    • nums[i] consists of only digits.
    • +
    • nums[i] will not have any leading zeros.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Quickselect](../../tag/quickselect/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +If two numbers have different lengths, which one will be larger? +
    + +
    +Hint 2 +The longer number is the larger number. +
    + +
    +Hint 3 +If two numbers have the same length, which one will be larger? +
    + +
    +Hint 4 +Compare the two numbers starting from the most significant digit. Once you have found the first digit that differs, the one with the larger digit is the larger number. +
    diff --git a/problems/find-the-longest-valid-obstacle-course-at-each-position/README.md b/problems/find-the-longest-valid-obstacle-course-at-each-position/README.md new file mode 100644 index 000000000..b5af04369 --- /dev/null +++ b/problems/find-the-longest-valid-obstacle-course-at-each-position/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../minimum-number-of-swaps-to-make-the-string-balanced "Minimum Number of Swaps to Make the String Balanced") +                 +[Next >](../employees-with-missing-information "Employees With Missing Information") + +## [1964. Find the Longest Valid Obstacle Course at Each Position (Hard)](https://leetcode.com/problems/find-the-longest-valid-obstacle-course-at-each-position "找出到每个位置为止最长的有效障碍赛跑路线") + +

    You want to build some obstacle courses. You are given a 0-indexed integer array obstacles of length n, where obstacles[i] describes the height of the ith obstacle.

    + +

    For every index i between 0 and n - 1 (inclusive), find the length of the longest obstacle course in obstacles such that:

    + +
      +
    • You choose any number of obstacles between 0 and i inclusive.
    • +
    • You must include the ith obstacle in the course.
    • +
    • You must put the chosen obstacles in the same order as they appear in obstacles.
    • +
    • Every obstacle (except the first) is taller than or the same height as the obstacle immediately before it.
    • +
    + +

    Return an array ans of length n, where ans[i] is the length of the longest obstacle course for index i as described above.

    + +

     

    +

    Example 1:

    + +
    +Input: obstacles = [1,2,3,2]
    +Output: [1,2,3,3]
    +Explanation: The longest valid obstacle course at each position is:
    +- i = 0: [1], [1] has length 1.
    +- i = 1: [1,2], [1,2] has length 2.
    +- i = 2: [1,2,3], [1,2,3] has length 3.
    +- i = 3: [1,2,3,2], [1,2,2] has length 3.
    +
    + +

    Example 2:

    + +
    +Input: obstacles = [2,2,1]
    +Output: [1,2,1]
    +Explanation: The longest valid obstacle course at each position is:
    +- i = 0: [2], [2] has length 1.
    +- i = 1: [2,2], [2,2] has length 2.
    +- i = 2: [2,2,1], [1] has length 1.
    +
    + +

    Example 3:

    + +
    +Input: obstacles = [3,1,5,6,4,2]
    +Output: [1,1,2,3,2,2]
    +Explanation: The longest valid obstacle course at each position is:
    +- i = 0: [3], [3] has length 1.
    +- i = 1: [3,1], [1] has length 1.
    +- i = 2: [3,1,5], [3,5] has length 2. [1,5] is also valid.
    +- i = 3: [3,1,5,6], [3,5,6] has length 3. [1,5,6] is also valid.
    +- i = 4: [3,1,5,6,4], [3,4] has length 2. [1,4] is also valid.
    +- i = 5: [3,1,5,6,4,2], [1,2] has length 2.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == obstacles.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= obstacles[i] <= 107
    • +
    + +### Related Topics + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Can you keep track of the minimum height for each obstacle course length? +
    + +
    +Hint 2 +You can use binary search to find the longest previous obstacle course length that satisfies the conditions. +
    diff --git a/problems/find-unique-binary-string/README.md b/problems/find-unique-binary-string/README.md new file mode 100644 index 000000000..b26bda5aa --- /dev/null +++ b/problems/find-unique-binary-string/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../find-greatest-common-divisor-of-array "Find Greatest Common Divisor of Array") +                 +[Next >](../minimize-the-difference-between-target-and-chosen-elements "Minimize the Difference Between Target and Chosen Elements") + +## [1980. Find Unique Binary String (Medium)](https://leetcode.com/problems/find-unique-binary-string "找出不同的二进制字符串") + +

    Given an array of strings nums containing n unique binary strings each of length n, return a binary string of length n that does not appear in nums. If there are multiple answers, you may return any of them.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = ["01","10"]
    +Output: "11"
    +Explanation: "11" does not appear in nums. "00" would also be correct.
    +
    + +

    Example 2:

    + +
    +Input: nums = ["00","01"]
    +Output: "11"
    +Explanation: "11" does not appear in nums. "10" would also be correct.
    +
    + +

    Example 3:

    + +
    +Input: nums = ["111","011","001"]
    +Output: "101"
    +Explanation: "101" does not appear in nums. "000", "010", "100", and "110" would also be correct.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= n <= 16
    • +
    • nums[i].length == n
    • +
    • nums[i] is either '0' or '1'.
    • +
    • All the strings of nums are unique.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
    +Hint 1 +We can convert the given strings into base 10 integers. +
    + +
    +Hint 2 +Can we use recursion to generate all possible strings? +
    diff --git a/problems/find-words-that-can-be-formed-by-characters/README.md b/problems/find-words-that-can-be-formed-by-characters/README.md index d3422c5c4..083f74b1f 100644 --- a/problems/find-words-that-can-be-formed-by-characters/README.md +++ b/problems/find-words-that-can-be-formed-by-characters/README.md @@ -11,41 +11,37 @@ ## [1160. Find Words That Can Be Formed by Characters (Easy)](https://leetcode.com/problems/find-words-that-can-be-formed-by-characters "拼写单词") -

    You are given an array of strings words and a string chars.

    +

    You are given an array of strings words and a string chars.

    -

    A string is good if it can be formed by characters from chars (each character can only be used once).

    +

    A string is good if it can be formed by characters from chars (each character can only be used once).

    -

    Return the sum of lengths of all good strings in words.

    +

    Return the sum of lengths of all good strings in words.

     

    -

    Example 1:

    -Input: words = ["cat","bt","hat","tree"], chars = "atach"
    -Output: 6
    -Explanation: 
    -The strings that can be formed are "cat" and "hat" so the answer is 3 + 3 = 6.
    +Input: words = ["cat","bt","hat","tree"], chars = "atach"
    +Output: 6
    +Explanation: The strings that can be formed are "cat" and "hat" so the answer is 3 + 3 = 6.
     

    Example 2:

    -Input: words = ["hello","world","leetcode"], chars = "welldonehoneyr"
    -Output: 10
    -Explanation: 
    -The strings that can be formed are "hello" and "world" so the answer is 5 + 5 = 10.
    +Input: words = ["hello","world","leetcode"], chars = "welldonehoneyr"
    +Output: 10
    +Explanation: The strings that can be formed are "hello" and "world" so the answer is 5 + 5 = 10.
     

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= words.length <= 1000
      • -
      • 1 <= words[i].length, chars.length <= 100
      • -
      • All strings contain lowercase English letters only.
      • -
    +
  • 1 <= words[i].length, chars.length <= 100
  • +
  • words[i] and chars consist of lowercase English letters.
  • + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/first-and-last-call-on-the-same-day/README.md b/problems/first-and-last-call-on-the-same-day/README.md new file mode 100644 index 000000000..367339957 --- /dev/null +++ b/problems/first-and-last-call-on-the-same-day/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../find-if-path-exists-in-graph "Find if Path Exists in Graph") +                 +[Next >](../count-nodes-equal-to-sum-of-descendants "Count Nodes Equal to Sum of Descendants") + +## [1972. First and Last Call On the Same Day (Hard)](https://leetcode.com/problems/first-and-last-call-on-the-same-day "") + + diff --git a/problems/first-and-last-call-on-the-same-day/mysql_schemas.sql b/problems/first-and-last-call-on-the-same-day/mysql_schemas.sql new file mode 100644 index 000000000..ff703d10f --- /dev/null +++ b/problems/first-and-last-call-on-the-same-day/mysql_schemas.sql @@ -0,0 +1,8 @@ +Create table If Not Exists Calls (caller_id int, recipient_id int, call_time datetime); +Truncate table Calls; +insert into Calls (caller_id, recipient_id, call_time) values ('8', '4', '2021-08-24 17:46:07'); +insert into Calls (caller_id, recipient_id, call_time) values ('4', '8', '2021-08-24 19:57:13'); +insert into Calls (caller_id, recipient_id, call_time) values ('5', '1', '2021-08-11 05:28:44'); +insert into Calls (caller_id, recipient_id, call_time) values ('8', '3', '2021-08-17 04:04:15'); +insert into Calls (caller_id, recipient_id, call_time) values ('11', '3', '2021-08-17 13:07:00'); +insert into Calls (caller_id, recipient_id, call_time) values ('8', '11', '2021-08-17 22:22:22'); diff --git a/problems/four-divisors/README.md b/problems/four-divisors/README.md index f6da14c3f..c23fcc57b 100644 --- a/problems/four-divisors/README.md +++ b/problems/four-divisors/README.md @@ -11,9 +11,7 @@ ## [1390. Four Divisors (Medium)](https://leetcode.com/problems/four-divisors "四因数") -

    Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors.

    - -

    If there is no such integer in the array, return 0.

    +

    Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.

     

    Example 1:

    @@ -21,19 +19,33 @@
     Input: nums = [21,4,7]
     Output: 32
    -Explanation:
    +Explanation: 
     21 has 4 divisors: 1, 3, 7, 21
     4 has 3 divisors: 1, 2, 4
     7 has 2 divisors: 1, 7
     The answer is the sum of divisors of 21 only.
     
    +

    Example 2:

    + +
    +Input: nums = [21,21]
    +Output: 64
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,2,3,4,5]
    +Output: 0
    +
    +

     

    Constraints:

      -
    • 1 <= nums.length <= 10^4
    • -
    • 1 <= nums[i] <= 10^5
    • +
    • 1 <= nums.length <= 104
    • +
    • 1 <= nums[i] <= 105
    ### Related Topics diff --git a/problems/game-of-nim/README.md b/problems/game-of-nim/README.md index 49664953b..3b3418858 100644 --- a/problems/game-of-nim/README.md +++ b/problems/game-of-nim/README.md @@ -9,7 +9,7 @@                  [Next >](../remove-one-element-to-make-the-array-strictly-increasing "Remove One Element to Make the Array Strictly Increasing") -## [1908. Game of Nim (Medium)](https://leetcode.com/problems/game-of-nim "") +## [1908. Game of Nim (Medium)](https://leetcode.com/problems/game-of-nim "Nim 游戏 II") diff --git a/problems/group-anagrams/README.md b/problems/group-anagrams/README.md index d44c87b44..a6b12a7c8 100644 --- a/problems/group-anagrams/README.md +++ b/problems/group-anagrams/README.md @@ -32,7 +32,7 @@
    • 1 <= strs.length <= 104
    • 0 <= strs[i].length <= 100
    • -
    • strs[i] consists of lower-case English letters.
    • +
    • strs[i] consists of lowercase English letters.
    ### Related Topics diff --git a/problems/grumpy-bookstore-owner/README.md b/problems/grumpy-bookstore-owner/README.md index e18f02973..66324b90c 100644 --- a/problems/grumpy-bookstore-owner/README.md +++ b/problems/grumpy-bookstore-owner/README.md @@ -11,33 +11,41 @@ ## [1052. Grumpy Bookstore Owner (Medium)](https://leetcode.com/problems/grumpy-bookstore-owner "爱生气的书店老板") -

    Today, the bookstore owner has a store open for customers.length minutes.  Every minute, some number of customers (customers[i]) enter the store, and all those customers leave after the end of that minute.

    +

    There is a bookstore owner that has a store open for n minutes. Every minute, some number of customers enter the store. You are given an integer array customers of length n where customers[i] is the number of the customer that enters the store at the start of the ith minute and all those customers leave after the end of that minute.

    -

    On some minutes, the bookstore owner is grumpy.  If the bookstore owner is grumpy on the i-th minute, grumpy[i] = 1, otherwise grumpy[i] = 0.  When the bookstore owner is grumpy, the customers of that minute are not satisfied, otherwise they are satisfied.

    +

    On some minutes, the bookstore owner is grumpy. You are given a binary array grumpy where grumpy[i] is 1 if the bookstore owner is grumpy during the ith minute, and is 0 otherwise.

    -

    The bookstore owner knows a secret technique to keep themselves not grumpy for minutes minutes straight, but can only use it once.

    +

    When the bookstore owner is grumpy, the customers of that minute are not satisfied, otherwise, they are satisfied.

    -

    Return the maximum number of customers that can be satisfied throughout the day.

    +

    The bookstore owner knows a secret technique to keep themselves not grumpy for minutes consecutive minutes, but can only use it once.

    -

     

    +

    Return the maximum number of customers that can be satisfied throughout the day.

    +

     

    Example 1:

    -Input: customers = [1,0,1,2,1,1,7,5], grumpy = [0,1,0,1,0,1,0,1], minutes = 3
    -Output: 16
    -Explanation: The bookstore owner keeps themselves not grumpy for the last 3 minutes. 
    +Input: customers = [1,0,1,2,1,1,7,5], grumpy = [0,1,0,1,0,1,0,1], minutes = 3
    +Output: 16
    +Explanation: The bookstore owner keeps themselves not grumpy for the last 3 minutes. 
     The maximum number of customers that can be satisfied = 1 + 1 + 1 + 1 + 7 + 5 = 16.
     
    -

     

    +

    Example 2:

    -

    Note:

    +
    +Input: customers = [1], grumpy = [0], minutes = 1
    +Output: 1
    +
    + +

     

    +

    Constraints:

      -
    • 1 <= minutes <= customers.length == grumpy.length <= 20000
    • -
    • 0 <= customers[i] <= 1000
    • -
    • 0 <= grumpy[i] <= 1
    • +
    • n == customers.length == grumpy.length
    • +
    • 1 <= minutes <= n <= 2 * 104
    • +
    • 0 <= customers[i] <= 1000
    • +
    • grumpy[i] is either 0 or 1.
    ### Related Topics diff --git a/problems/house-robber-ii/README.md b/problems/house-robber-ii/README.md index 6500d13fb..ec027ba76 100644 --- a/problems/house-robber-ii/README.md +++ b/problems/house-robber-ii/README.md @@ -36,8 +36,8 @@ Total amount you can rob = 1 + 3 = 4.

    Example 3:

    -Input: nums = [0]
    -Output: 0
    +Input: nums = [1,2,3]
    +Output: 3
     

     

    diff --git a/problems/image-overlap/README.md b/problems/image-overlap/README.md index 898fb828d..692a184da 100644 --- a/problems/image-overlap/README.md +++ b/problems/image-overlap/README.md @@ -11,13 +11,13 @@ ## [835. Image Overlap (Medium)](https://leetcode.com/problems/image-overlap "图像重叠") -

    You are given two images img1 and img2 both of size n x n, represented as binary, square matrices of the same size. (A binary matrix has only 0s and 1s as values.)

    +

    You are given two images, img1 and img2, represented as binary, square matrices of size n x n. A binary matrix has only 0s and 1s as values.

    -

    We translate one image however we choose (sliding it left, right, up, or down any number of units), and place it on top of the other image.  After, the overlap of this translation is the number of positions that have a 1 in both images.

    +

    We translate one image however we choose by sliding all the 1 bits left, right, up, and/or down any number of units. We then place it on top of the other image. We can then calculate the overlap by counting the number of positions that have a 1 in both images.

    -

    (Note also that a translation does not include any kind of rotation.)

    +

    Note also that a translation does not include any kind of rotation. Any 1 bits that are translated outside of the matrix borders are erased.

    -

    What is the largest possible overlap?

    +

    Return the largest possible overlap.

     

    Example 1:

    @@ -25,9 +25,9 @@
     Input: img1 = [[1,1,0],[0,1,0],[0,1,0]], img2 = [[0,0,0],[0,1,1],[0,0,1]]
     Output: 3
    -Explanation: We slide img1 to right by 1 unit and down by 1 unit.
    +Explanation: We translate img1 to right by 1 unit and down by 1 unit.
     
    -The number of positions that have a 1 in both images is 3. (Shown in red)
    +The number of positions that have a 1 in both images is 3 (shown in red).
     
     
    @@ -49,13 +49,11 @@ The number of positions that have a 1 in both images is 3. (Shown in red)

    Constraints:

      -
    • n == img1.length
    • -
    • n == img1[i].length
    • -
    • n == img2.length
    • -
    • n == img2[i].length
    • +
    • n == img1.length == img1[i].length
    • +
    • n == img2.length == img2[i].length
    • 1 <= n <= 30
    • -
    • img1[i][j] is 0 or 1.
    • -
    • img2[i][j] is 0 or 1.
    • +
    • img1[i][j] is either 0 or 1.
    • +
    • img2[i][j] is either 0 or 1.
    ### Related Topics diff --git a/problems/implement-queue-using-stacks/README.md b/problems/implement-queue-using-stacks/README.md index d0f72ee16..6a6b99560 100644 --- a/problems/implement-queue-using-stacks/README.md +++ b/problems/implement-queue-using-stacks/README.md @@ -22,15 +22,13 @@
  • boolean empty() Returns true if the queue is empty, false otherwise.
  • -

    Notes:

    +

    Notes:

    • You must use only standard operations of a stack, which means only push to top, peek/pop from top, size, and is empty operations are valid.
    • Depending on your language, the stack may not be supported natively. You may simulate a stack using a list or deque (double-ended queue) as long as you use only a stack's standard operations.
    -

    Follow-up: Can you implement the queue such that each operation is amortized O(1) time complexity? In other words, performing n operations will take overall O(n) time even if one of those operations may take longer.

    -

     

    Example 1:

    @@ -59,6 +57,9 @@ myQueue.empty(); // return false
  • All the calls to pop and peek are valid.
  • +

     

    +

    Follow-up: Can you implement the queue such that each operation is amortized O(1) time complexity? In other words, performing n operations will take overall O(n) time even if one of those operations may take longer.

    + ### Related Topics [[Stack](../../tag/stack/README.md)] [[Design](../../tag/design/README.md)] diff --git a/problems/insert-interval/README.md b/problems/insert-interval/README.md index 5a1964746..c10a0a136 100644 --- a/problems/insert-interval/README.md +++ b/problems/insert-interval/README.md @@ -11,9 +11,11 @@ ## [57. Insert Interval (Medium)](https://leetcode.com/problems/insert-interval "插入区间") -

    Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).

    +

    You are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith interval and intervals is sorted in ascending order by starti. You are also given an interval newInterval = [start, end] that represents the start and end of another interval.

    -

    You may assume that the intervals were initially sorted according to their start times.

    +

    Insert newInterval into intervals such that intervals is still sorted in ascending order by starti and intervals still does not have any overlapping intervals (merge overlapping intervals if necessary).

    + +

    Return intervals after the insertion.

     

    Example 1:

    @@ -57,10 +59,10 @@
    • 0 <= intervals.length <= 104
    • intervals[i].length == 2
    • -
    • 0 <= intervals[i][0] <= intervals[i][1] <= 105
    • -
    • intervals is sorted by intervals[i][0] in ascending order.
    • +
    • 0 <= starti <= endi <= 105
    • +
    • intervals is sorted by starti in ascending order.
    • newInterval.length == 2
    • -
    • 0 <= newInterval[0] <= newInterval[1] <= 105
    • +
    • 0 <= start <= end <= 105
    ### Related Topics diff --git a/problems/insufficient-nodes-in-root-to-leaf-paths/README.md b/problems/insufficient-nodes-in-root-to-leaf-paths/README.md index 19af8bdb1..5c7a71756 100644 --- a/problems/insufficient-nodes-in-root-to-leaf-paths/README.md +++ b/problems/insufficient-nodes-in-root-to-leaf-paths/README.md @@ -11,56 +11,42 @@ ## [1080. Insufficient Nodes in Root to Leaf Paths (Medium)](https://leetcode.com/problems/insufficient-nodes-in-root-to-leaf-paths "根到叶路径上的不足节点") -

    Given the root of a binary tree, consider all root to leaf paths: paths from the root to any leaf.  (A leaf is a node with no children.)

    +

    Given the root of a binary tree and an integer limit, delete all insufficient nodes in the tree simultaneously, and return the root of the resulting binary tree.

    -

    A node is insufficient if every such root to leaf path intersecting this node has sum strictly less than limit.

    +

    A node is insufficient if every root to leaf path intersecting this node has a sum strictly less than limit.

    -

    Delete all insufficient nodes simultaneously, and return the root of the resulting binary tree.

    +

    A leaf is a node with no children.

     

    -

    Example 1:

    - +
    -
    -Input: root = [1,2,3,4,-99,-99,7,8,9,-99,-99,12,13,-99,14], limit = 1
    -
    -Output: [1,2,3,4,null,null,7,8,9,null,14]
    +Input: root = [1,2,3,4,-99,-99,7,8,9,-99,-99,12,13,-99,14], limit = 1
    +Output: [1,2,3,4,null,null,7,8,9,null,14]
     
    -

    Example 2:

    - +
    -
    -Input: root = [5,4,8,11,null,17,4,7,1,null,null,5,3], limit = 22
    -
    -Output: [5,4,8,11,null,17,4,7,null,null,null,5]
    - -

     

    +Input: root = [5,4,8,11,null,17,4,7,1,null,null,5,3], limit = 22 +Output: [5,4,8,11,null,17,4,7,null,null,null,5] +

    Example 3:

    - +
    -
    -Input: root = [1,2,-3,-5,null,4,null], limit = -1
    -
    -Output: [1,null,-3,4]
    -
    +Input: root = [1,2,-3,-5,null,4,null], limit = -1 +Output: [1,null,-3,4] +

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. The given tree will have between 1 and 5000 nodes.
    2. -
    3. -10^5 <= node.val <= 10^5
    4. -
    5. -10^9 <= limit <= 10^9
    6. -
    - -
    -
     
    -
    +
      +
    • The number of nodes in the tree is in the range [1, 5000].
    • +
    • -105 <= Node.val <= 105
    • +
    • -109 <= limit <= 109
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/interval-list-intersections/README.md b/problems/interval-list-intersections/README.md index 5218c2a65..b7251fd39 100644 --- a/problems/interval-list-intersections/README.md +++ b/problems/interval-list-intersections/README.md @@ -15,7 +15,7 @@

    Return the intersection of these two interval lists.

    -

    A closed interval [a, b] (with a < b) denotes the set of real numbers x with a <= x <= b.

    +

    A closed interval [a, b] (with a <= b) denotes the set of real numbers x with a <= x <= b.

    The intersection of two closed intervals is a set of real numbers that are either empty or represented as a closed interval. For example, the intersection of [1, 3] and [2, 4] is [2, 3].

    diff --git a/problems/kth-ancestor-of-a-tree-node/README.md b/problems/kth-ancestor-of-a-tree-node/README.md index eb59c8b0f..45fab111e 100644 --- a/problems/kth-ancestor-of-a-tree-node/README.md +++ b/problems/kth-ancestor-of-a-tree-node/README.md @@ -51,12 +51,12 @@ treeAncestor.getKthAncestor(6, 3); // returns -1 because there is no such ancest ### Related Topics - [[Binary Search](../../tag/binary-search/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Design](../../tag/design/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/kth-largest-element-in-a-stream/README.md b/problems/kth-largest-element-in-a-stream/README.md index 762b4da3d..100e1cf78 100644 --- a/problems/kth-largest-element-in-a-stream/README.md +++ b/problems/kth-largest-element-in-a-stream/README.md @@ -11,13 +11,13 @@ ## [703. Kth Largest Element in a Stream (Easy)](https://leetcode.com/problems/kth-largest-element-in-a-stream "数据流中的第 K 大元素") -

    Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element.

    +

    Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element.

    -

    Implement KthLargest class:

    +

    Implement KthLargest class:

      -
    • KthLargest(int k, int[] nums) Initializes the object with the integer k and the stream of integers nums.
    • -
    • int add(int val) Returns the element representing the kth largest element in the stream.
    • +
    • KthLargest(int k, int[] nums) Initializes the object with the integer k and the stream of integers nums.
    • +
    • int add(int val) Appends the integer val to the stream and returns the element representing the kth largest element in the stream.

     

    diff --git a/problems/kth-smallest-subarray-sum/README.md b/problems/kth-smallest-subarray-sum/README.md index 334a0c5d0..857ca7e54 100644 --- a/problems/kth-smallest-subarray-sum/README.md +++ b/problems/kth-smallest-subarray-sum/README.md @@ -9,7 +9,7 @@                  [Next >](../leetcodify-similar-friends "Leetcodify Similar Friends") -## [1918. Kth Smallest Subarray Sum (Medium)](https://leetcode.com/problems/kth-smallest-subarray-sum "") +## [1918. Kth Smallest Subarray Sum (Medium)](https://leetcode.com/problems/kth-smallest-subarray-sum "第 K 小的子序列和") diff --git a/problems/largest-number-after-mutating-substring/README.md b/problems/largest-number-after-mutating-substring/README.md index 393bb93de..1ad178a38 100644 --- a/problems/largest-number-after-mutating-substring/README.md +++ b/problems/largest-number-after-mutating-substring/README.md @@ -13,9 +13,9 @@

    You are given a string num, which represents a large integer. You are also given a 0-indexed integer array change of length 10 that maps each digit 0-9 to another digit. More formally, digit d maps to digit change[d].

    -

    You may choose to mutate any substring of num. To mutate a substring, replace each digit num[i] with the digit it maps to in change (i.e. replace num[i] with change[num[i]]).

    +

    You may choose to mutate a single substring of num. To mutate a substring, replace each digit num[i] with the digit it maps to in change (i.e. replace num[i] with change[num[i]]).

    -

    Return a string representing the largest possible integer after mutating (or choosing not to) any substring of num.

    +

    Return a string representing the largest possible integer after mutating (or choosing not to) a single substring of num.

    A substring is a contiguous sequence of characters within the string.

    diff --git a/problems/largest-values-from-labels/README.md b/problems/largest-values-from-labels/README.md index dac3364d0..8d16b99c2 100644 --- a/problems/largest-values-from-labels/README.md +++ b/problems/largest-values-from-labels/README.md @@ -11,68 +11,61 @@ ## [1090. Largest Values From Labels (Medium)](https://leetcode.com/problems/largest-values-from-labels "受标签影响的最大值") -

    We have a set of items: the i-th item has value values[i] and label labels[i].

    +

    There is a set of n items. You are given two integer arrays values and labels where the value and the label of the ith element are values[i] and labels[i] respectively. You are also given two integers numWanted and useLimit.

    -

    Then, we choose a subset S of these items, such that:

    +

    Choose a subset s of the n elements such that:

      -
    • |S| <= num_wanted
    • -
    • For every label L, the number of items in S with label L is <= use_limit.
    • +
    • The size of the subset s is less than or equal to numWanted.
    • +
    • There are at most useLimit items with the same label in s.
    -

    Return the largest possible sum of the subset S.

    +

    The score of a subset is the sum of the values in the subset.

    -

     

    +

    Return the maximum score of a subset s.

    -
    +

     

    Example 1:

    -Input: values = [5,4,3,2,1], labels = [1,1,2,2,3], num_wanted = 3, use_limit = 1
    -Output: 9
    -Explanation: The subset chosen is the first, third, and fifth item.
    +Input: values = [5,4,3,2,1], labels = [1,1,2,2,3], numWanted = 3, useLimit = 1
    +Output: 9
    +Explanation: The subset chosen is the first, third, and fifth items.
     
    -

    Example 2:

    -Input: values = [5,4,3,2,1], labels = [1,3,3,3,2], num_wanted = 3, use_limit = 2
    -Output: 12
    -Explanation: The subset chosen is the first, second, and third item.
    +Input: values = [5,4,3,2,1], labels = [1,3,3,3,2], numWanted = 3, useLimit = 2
    +Output: 12
    +Explanation: The subset chosen is the first, second, and third items.
     
    -

    Example 3:

    -Input: values = [9,8,8,7,6], labels = [0,0,0,1,1], num_wanted = 3, use_limit = 1
    -Output: 16
    -Explanation: The subset chosen is the first and fourth item.
    +Input: values = [9,8,8,7,6], labels = [0,0,0,1,1], numWanted = 3, useLimit = 1
    +Output: 16
    +Explanation: The subset chosen is the first and fourth items.
     
    -

    Example 4:

    -Input: values = [9,8,8,7,6], labels = [0,0,0,1,1], num_wanted = 3, use_limit = 2
    -Output: 24
    -Explanation: The subset chosen is the first, second, and fourth item.
    +Input: values = [9,8,8,7,6], labels = [0,0,0,1,1], numWanted = 3, useLimit = 2
    +Output: 24
    +Explanation: The subset chosen is the first, second, and fourth items.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= values.length == labels.length <= 20000
    2. -
    3. 0 <= values[i], labels[i] <= 20000
    4. -
    5. 1 <= num_wanted, use_limit <= values.length
    6. -
    -
    -
    -
    -
    +
      +
    • n == values.length == labels.length
    • +
    • 1 <= n <= 2 * 104
    • +
    • 0 <= values[i], labels[i] <= 2 * 104
    • +
    • 1 <= numWanted, useLimit <= n
    • +
    ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/last-day-where-you-can-still-cross/README.md b/problems/last-day-where-you-can-still-cross/README.md new file mode 100644 index 000000000..4f3148f3d --- /dev/null +++ b/problems/last-day-where-you-can-still-cross/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../minimum-non-zero-product-of-the-array-elements "Minimum Non-Zero Product of the Array Elements") +                 +[Next >](../find-if-path-exists-in-graph "Find if Path Exists in Graph") + +## [1970. Last Day Where You Can Still Cross (Hard)](https://leetcode.com/problems/last-day-where-you-can-still-cross "你能穿过矩阵的最后一天") + +

    There is a 1-based binary matrix where 0 represents land and 1 represents water. You are given integers row and col representing the number of rows and columns in the matrix, respectively.

    + +

    Initially on day 0, the entire matrix is land. However, each day a new cell becomes flooded with water. You are given a 1-based 2D array cells, where cells[i] = [ri, ci] represents that on the ith day, the cell on the rith row and cith column (1-based coordinates) will be covered with water (i.e., changed to 1).

    + +

    You want to find the last day that it is possible to walk from the top to the bottom by only walking on land cells. You can start from any cell in the top row and end at any cell in the bottom row. You can only travel in the four cardinal directions (left, right, up, and down).

    + +

    Return the last day where it is possible to walk from the top to the bottom by only walking on land cells.

    + +

     

    +

    Example 1:

    + +
    +Input: row = 2, col = 2, cells = [[1,1],[2,1],[1,2],[2,2]]
    +Output: 2
    +Explanation: The above image depicts how the matrix changes each day starting from day 0.
    +The last day where it is possible to cross from top to bottom is on day 2.
    +
    + +

    Example 2:

    + +
    +Input: row = 2, col = 2, cells = [[1,1],[1,2],[2,1],[2,2]]
    +Output: 1
    +Explanation: The above image depicts how the matrix changes each day starting from day 0.
    +The last day where it is possible to cross from top to bottom is on day 1.
    +
    + +

    Example 3:

    + +
    +Input: row = 3, col = 3, cells = [[1,2],[2,1],[3,3],[2,2],[1,1],[1,3],[2,3],[3,2],[3,1]]
    +Output: 3
    +Explanation: The above image depicts how the matrix changes each day starting from day 0.
    +The last day where it is possible to cross from top to bottom is on day 3.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= row, col <= 2 * 104
    • +
    • 4 <= row * col <= 2 * 104
    • +
    • cells.length == row * col
    • +
    • 1 <= ri <= row
    • +
    • 1 <= ci <= col
    • +
    • All the values of cells are unique.
    • +
    + +### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +What graph algorithm allows us to find whether a path exists? +
    + +
    +Hint 2 +Can we use binary search to help us solve the problem? +
    diff --git a/problems/last-stone-weight/README.md b/problems/last-stone-weight/README.md index 65dade789..5ebb9e946 100644 --- a/problems/last-stone-weight/README.md +++ b/problems/last-stone-weight/README.md @@ -11,38 +11,46 @@ ## [1046. Last Stone Weight (Easy)](https://leetcode.com/problems/last-stone-weight "最后一块石头的重量") -

    We have a collection of stones, each stone has a positive integer weight.

    +

    You are given an array of integers stones where stones[i] is the weight of the ith stone.

    -

    Each turn, we choose the two heaviest stones and smash them together.  Suppose the stones have weights x and y with x <= y.  The result of this smash is:

    +

    We are playing a game with the stones. On each turn, we choose the heaviest two stones and smash them together. Suppose the heaviest two stones have weights x and y with x <= y. The result of this smash is:

      -
    • If x == y, both stones are totally destroyed;
    • -
    • If x != y, the stone of weight x is totally destroyed, and the stone of weight y has new weight y-x.
    • +
    • If x == y, both stones are destroyed, and
    • +
    • If x != y, the stone of weight x is destroyed, and the stone of weight y has new weight y - x.
    -

    At the end, there is at most 1 stone left.  Return the weight of this stone (or 0 if there are no stones left.)

    +

    At the end of the game, there is at most one stone left.

    -

     

    +

    Return the smallest possible weight of the left stone. If there are no stones left, return 0.

    +

     

    Example 1:

    -Input: [2,7,4,1,8,1]
    -Output: 1
    -Explanation: 
    +Input: stones = [2,7,4,1,8,1]
    +Output: 1
    +Explanation: 
     We combine 7 and 8 to get 1 so the array converts to [2,4,1,1,1] then,
     we combine 2 and 4 to get 2 so the array converts to [2,1,1,1] then,
     we combine 2 and 1 to get 1 so the array converts to [1,1,1] then,
    -we combine 1 and 1 to get 0 so the array converts to [1] then that's the value of last stone.
    +we combine 1 and 1 to get 0 so the array converts to [1] then that's the value of the last stone. + -

     

    +

    Example 2:

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

    Note:

    +

     

    +

    Constraints:

    -
      +
      • 1 <= stones.length <= 30
      • 1 <= stones[i] <= 1000
      • -
    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/length-of-last-word/README.md b/problems/length-of-last-word/README.md index 6bbee543f..5205f2a17 100644 --- a/problems/length-of-last-word/README.md +++ b/problems/length-of-last-word/README.md @@ -11,24 +11,42 @@ ## [58. Length of Last Word (Easy)](https://leetcode.com/problems/length-of-last-word "最后一个单词的长度") -

    Given a string s consists of some words separated by spaces, return the length of the last word in the string. If the last word does not exist, return 0.

    +

    Given a string s consisting of some words separated by some number of spaces, return the length of the last word in the string.

    -

    A word is a maximal substring consisting of non-space characters only.

    +

    A word is a maximal substring consisting of non-space characters only.

     

    Example 1:

    -
    Input: s = "Hello World"
    +
    +
    +Input: s = "Hello World"
     Output: 5
    -

    Example 2:

    -
    Input: s = " "
    -Output: 0
    +Explanation: The last word is "World" with length 5.
    +
    + +

    Example 2:

    + +
    +Input: s = "   fly me   to   the moon  "
    +Output: 4
    +Explanation: The last word is "moon" with length 4.
     
    + +

    Example 3:

    + +
    +Input: s = "luffy is still joyboy"
    +Output: 6
    +Explanation: The last word is "joyboy" with length 6.
    +
    +

     

    Constraints:

    • 1 <= s.length <= 104
    • s consists of only English letters and spaces ' '.
    • +
    • There will be at least one word in s.
    ### Related Topics diff --git a/problems/linked-list-cycle-ii/README.md b/problems/linked-list-cycle-ii/README.md index 91c2b1471..40ac202cf 100644 --- a/problems/linked-list-cycle-ii/README.md +++ b/problems/linked-list-cycle-ii/README.md @@ -11,11 +11,11 @@ ## [142. Linked List Cycle II (Medium)](https://leetcode.com/problems/linked-list-cycle-ii "环形链表 II") -

    Given a linked list, return the node where the cycle begins. If there is no cycle, return null.

    +

    Given the head of a linked list, return the node where the cycle begins. If there is no cycle, return null.

    -

    There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail's next pointer is connected to. Note that pos is not passed as a parameter.

    +

    There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail's next pointer is connected to (0-indexed). It is -1 if there is no cycle. Note that pos is not passed as a parameter.

    -

    Notice that you should not modify the linked list.

    +

    Do not modify the linked list.

     

    Example 1:

    diff --git a/problems/linked-list-random-node/README.md b/problems/linked-list-random-node/README.md index 84cabbd11..d977549d8 100644 --- a/problems/linked-list-random-node/README.md +++ b/problems/linked-list-random-node/README.md @@ -13,6 +13,13 @@

    Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen.

    +

    Implement the Solution class:

    + +
      +
    • Solution(ListNode head) Initializes the object with the integer array nums.
    • +
    • int getRandom() Chooses a node randomly from the list and returns its value. All the nodes of the list should be equally likely to be choosen.
    • +
    +

     

    Example 1:

    diff --git a/problems/longest-common-subsequence-between-sorted-arrays/README.md b/problems/longest-common-subsequence-between-sorted-arrays/README.md index d479ee7fb..11ff4e046 100644 --- a/problems/longest-common-subsequence-between-sorted-arrays/README.md +++ b/problems/longest-common-subsequence-between-sorted-arrays/README.md @@ -13,6 +13,11 @@ +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] + ### Hints
    Hint 1 diff --git a/problems/longest-uncommon-subsequence-ii/README.md b/problems/longest-uncommon-subsequence-ii/README.md index 41698819e..218b3d5fd 100644 --- a/problems/longest-uncommon-subsequence-ii/README.md +++ b/problems/longest-uncommon-subsequence-ii/README.md @@ -33,7 +33,7 @@

    Constraints:

      -
    • 1 <= strs.length <= 50
    • +
    • 2 <= strs.length <= 50
    • 1 <= strs[i].length <= 10
    • strs[i] consists of lowercase English letters.
    diff --git a/problems/longest-well-performing-interval/README.md b/problems/longest-well-performing-interval/README.md index b4040fc96..808f061bf 100644 --- a/problems/longest-well-performing-interval/README.md +++ b/problems/longest-well-performing-interval/README.md @@ -11,7 +11,7 @@ ## [1124. Longest Well-Performing Interval (Medium)](https://leetcode.com/problems/longest-well-performing-interval "表现良好的最长时间段") -

    We are given hours, a list of the number of hours worked per day for a given employee.

    +

    We are given hours, a list of the number of hours worked per day for a given employee.

    A day is considered to be a tiring day if and only if the number of hours worked is (strictly) greater than 8.

    @@ -28,11 +28,18 @@ Explanation: The longest well-performing interval is [9,9,6].
    +

    Example 2:

    + +
    +Input: hours = [6,6,6]
    +Output: 0
    +
    +

     

    Constraints:

      -
    • 1 <= hours.length <= 10000
    • +
    • 1 <= hours.length <= 104
    • 0 <= hours[i] <= 16
    diff --git a/problems/magical-string/README.md b/problems/magical-string/README.md index 18b7d6dd6..176c447fd 100644 --- a/problems/magical-string/README.md +++ b/problems/magical-string/README.md @@ -17,7 +17,7 @@
  • The string s is magical because concatenating the number of contiguous occurrences of characters '1' and '2' generates the string s itself.
  • -

    The first few elements of s is s = "1221121221221121122……". If we group the consecutive 1's and 2's in s, it will be "1 22 11 2 1 22 1 22 11 2 11 22 ......" and the occurrences of 1's or 2's in each group are "1 2 2 1 1 2 1 2 2 1 2 2 ......". You can see that the occurrence sequence is s itself.

    +

    The first few elements of s is s = "1221121221221121122……". If we group the consecutive 1's and 2's in s, it will be "1 22 11 2 1 22 1 22 11 2 11 22 ......" and the occurrences of 1's or 2's in each group are "1 2 2 1 1 2 1 2 2 1 2 2 ......". You can see that the occurrence sequence is s itself.

    Given an integer n, return the number of 1's in the first n number in the magical string s.

    @@ -27,7 +27,7 @@
     Input: n = 6
     Output: 3
    -Explanation: The first 6 elements of magical string s is "12211" and it contains three 1's, so return 3.
    +Explanation: The first 6 elements of magical string s is "122112" and it contains three 1's, so return 3.
     

    Example 2:

    diff --git a/problems/make-the-xor-of-all-segments-equal-to-zero/README.md b/problems/make-the-xor-of-all-segments-equal-to-zero/README.md index 5a2d02c40..1a20704bd 100644 --- a/problems/make-the-xor-of-all-segments-equal-to-zero/README.md +++ b/problems/make-the-xor-of-all-segments-equal-to-zero/README.md @@ -48,9 +48,9 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/map-sum-pairs/README.md b/problems/map-sum-pairs/README.md index e9ee0fc46..2332b6706 100644 --- a/problems/map-sum-pairs/README.md +++ b/problems/map-sum-pairs/README.md @@ -11,12 +11,19 @@ ## [677. Map Sum Pairs (Medium)](https://leetcode.com/problems/map-sum-pairs "键值映射") +

    Design a map that allows you to do the following:

    + +
      +
    • Maps a string key to a given value.
    • +
    • Returns the sum of the values that have a key with a prefix equal to a given string.
    • +
    +

    Implement the MapSum class:

      -
    • MapSum() Initializes the MapSum object.
    • +
    • MapSum() Initializes the MapSum object.
    • void insert(String key, int val) Inserts the key-val pair into the map. If the key already existed, the original key-value pair will be overridden to the new one.
    • -
    • int sum(string prefix) Returns the sum of all the pairs' value whose key starts with the prefix.
    • +
    • int sum(string prefix) Returns the sum of all the pairs' value whose key starts with the prefix.

     

    diff --git a/problems/masking-personal-information/README.md b/problems/masking-personal-information/README.md index 08d083bc7..855d82be5 100644 --- a/problems/masking-personal-information/README.md +++ b/problems/masking-personal-information/README.md @@ -11,82 +11,109 @@ ## [831. Masking Personal Information (Medium)](https://leetcode.com/problems/masking-personal-information "隐藏个人信息") -

    We are given a personal information string s, which may represent either an email address or a phone number.

    +

    You are given a personal information string s, representing either an email address or a phone number. Return the masked personal information using the below rules.

    -

    We would like to mask this personal information according to the following rules:

    +

    Email address:

    -


    -1. Email address:

    +

    An email address is:

    -

    We define a name to be a string of length ≥ 2 consisting of only lowercase letters a-z or uppercase letters A-Z.

    +
      +
    • A name consisting of uppercase and lowercase English letters, followed by
    • +
    • The '@' symbol, followed by
    • +
    • The domain consisting of uppercase and lowercase English letters with a dot '.' somewhere in the middle (not the first or last character).
    • +
    -

    An email address starts with a name, followed by the symbol '@', followed by a name, followed by the dot '.' and followed by a name. 

    +

    To mask an email:

    -

    All email addresses are guaranteed to be valid and in the format of "name1@name2.name3".

    +
      +
    • The uppercase letters in the name and domain must be converted to lowercase letters.
    • +
    • The middle letters of the name (i.e., all but the first and last letters) must be replaced by 5 asterisks "*****".
    • +
    -

    To mask an email, all names must be converted to lowercase and all letters between the first and last letter of the first name must be replaced by 5 asterisks '*'.

    +

    Phone number:

    -


    -2. Phone number:

    +

    A phone number is formatted as follows:

    -

    A phone number is a string consisting of only the digits 0-9 or the characters from the set {'+', '-', '(', ')', ' '}. You may assume a phone number contains 10 to 13 digits.

    +
      +
    • The phone number contains 10-13 digits.
    • +
    • The last 10 digits make up the local number.
    • +
    • The remaining 0-3 digits, in the beginning, make up the country code.
    • +
    • Separation characters from the set {'+', '-', '(', ')', ' '} separate the above digits in some way.
    • +
    -

    The last 10 digits make up the local number, while the digits before those make up the country code. Note that the country code is optional. We want to expose only the last 4 digits and mask all other digits.

    +

    To mask a phone number:

    -

    The local number should be formatted and masked as "***-***-1111", where 1 represents the exposed digits.

    - -

    To mask a phone number with country code like "+111 111 111 1111", we write it in the form "+***-***-***-1111".  The '+' sign and the first '-' sign before the local number should only exist if there is a country code.  For example, a 12 digit phone number mask should start with "+**-".

    - -

    Note that extraneous characters like "(", ")", " ", as well as extra dashes or plus signs not part of the above formatting scheme should be removed.

    - -

     

    - -

    Return the correct "mask" of the information provided.

    +
      +
    • Remove all separation characters.
    • +
    • The masked phone number should have the form: +
        +
      • "***-***-XXXX" if the country code has 0 digits.
      • +
      • "+*-***-***-XXXX" if the country code has 1 digit.
      • +
      • "+**-***-***-XXXX" if the country code has 2 digits.
      • +
      • "+***-***-***-XXXX" if the country code has 3 digits.
      • +
      +
    • +
    • "XXXX" is the last 4 digits of the local number.
    • +

     

    -

    Example 1:

    -Input: s = "LeetCode@LeetCode.com"
    -Output: "l*****e@leetcode.com"
    -Explanation: All names are converted to lowercase, and the letters between the
    -             first and last letter of the first name is replaced by 5 asterisks.
    -             Therefore, "leetcode" -> "l*****e".
    +Input: s = "LeetCode@LeetCode.com"
    +Output: "l*****e@leetcode.com"
    +Explanation: s is an email address.
    +The name and domain are converted to lowercase, and the middle of the name is replaced by 5 asterisks.
     

    Example 2:

    -Input: s = "AB@qq.com"
    -Output: "a*****b@qq.com"
    -Explanation: There must be 5 asterisks between the first and last letter 
    -             of the first name "ab". Therefore, "ab" -> "a*****b".
    +Input: s = "AB@qq.com"
    +Output: "a*****b@qq.com"
    +Explanation: s is an email address.
    +The name and domain are converted to lowercase, and the middle of the name is replaced by 5 asterisks.
    +Note that even though "ab" is 2 characters, it still must have 5 asterisks in the middle.
     

    Example 3:

    -Input: s = "1(234)567-890"
    -Output: "***-***-7890"
    -Explanation: 10 digits in the phone number, which means all digits make up the local number.
    +Input: s = "1(234)567-890"
    +Output: "***-***-7890"
    +Explanation: s is a phone number.
    +There are 10 digits, so the local number is 10 digits and the country code is 0 digits.
    +Thus, the resulting masked number is "***-***-7890".
     

    Example 4:

    -Input: s = "86-(10)12345678"
    -Output: "+**-***-***-5678"
    -Explanation: 12 digits, 2 digits for country code and 10 digits for local number. 
    +Input: s = "86-(10)12345678"
    +Output: "+**-***-***-5678"
    +Explanation: s is a phone number.
    +There are 12 digits, so the local number is 10 digits and the country code is 2 digits.
    +Thus, the resulting masked number is "+**-***-***-7890".
     
    -

    Notes:

    - -
      -
    1. s.length <= 40.
    2. -
    3. Emails have length at least 8.
    4. -
    5. Phone numbers have length at least 10.
    6. -
    +

     

    +

    Constraints:

    + +
      +
    • s is either a valid email or a phone number.
    • +
    • If s is an email: +
        +
      • 8 <= s.length <= 40
      • +
      • s consists of uppercase and lowercase English letters and exactly one '@' symbol and '.' symbol.
      • +
      +
    • +
    • If s is a phone number: +
        +
      • 10 <= s.length <= 20
      • +
      • s consists of digits, spaces, and the symbols '('')''-', and '+'.
      • +
      +
    • +
    ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/matrix-cells-in-distance-order/README.md b/problems/matrix-cells-in-distance-order/README.md index aa62bc666..3e26821f3 100644 --- a/problems/matrix-cells-in-distance-order/README.md +++ b/problems/matrix-cells-in-distance-order/README.md @@ -11,56 +11,47 @@ ## [1030. Matrix Cells in Distance Order (Easy)](https://leetcode.com/problems/matrix-cells-in-distance-order "距离顺序排列矩阵单元格") -

    We are given a matrix with rows rows and cols columns has cells with integer coordinates (r, c), where 0 <= r < rows and 0 <= c < cols.

    +

    You are given four integers row, cols, rCenter, and cCenter. There is a rows x cols matrix and you are on the cell with the coordinates (rCenter, cCenter).

    -

    Additionally, we are given a cell in that matrix with coordinates (rCenter, cCenter).

    +

    Return the coordinates of all cells in the matrix, sorted by their distance from (rCenter, cCenter) from the smallest distance to the largest distance. You may return the answer in any order that satisfies this condition.

    -

    Return the coordinates of all cells in the matrix, sorted by their distance from (rCenter, cCenter) from smallest distance to largest distance.  Here, the distance between two cells (r1, c1) and (r2, c2) is the Manhattan distance, |r1 - r2| + |c1 - c2|.  (You may return the answer in any order that satisfies this condition.)

    +

    The distance between two cells (r1, c1) and (r2, c2) is |r1 - r2| + |c1 - c2|.

     

    - -

    Example 1:

    -Input: rows = 1, cols = 2, rCenter = 0, cCenter = 0
    -Output: [[0,0],[0,1]]
    -Explanation: The distances from (0, 0) to other cells are: [0,1]
    +Input: rows = 1, cols = 2, rCenter = 0, cCenter = 0
    +Output: [[0,0],[0,1]]
    +Explanation: The distances from (0, 0) to other cells are: [0,1]
     
    -

    Example 2:

    -Input: rows = 2, cols = 2, rCenter = 0, cCenter = 1
    -Output: [[0,1],[0,0],[1,1],[1,0]]
    -Explanation: The distances from (0, 1) to other cells are: [0,1,1,2]
    +Input: rows = 2, cols = 2, rCenter = 0, cCenter = 1
    +Output: [[0,1],[0,0],[1,1],[1,0]]
    +Explanation: The distances from (0, 1) to other cells are: [0,1,1,2]
     The answer [[0,1],[1,1],[0,0],[1,0]] would also be accepted as correct.
     
    -

    Example 3:

    -Input: rows = 2, cols = 3, rCenter = 1, cCenter = 2
    -Output: [[1,2],[0,2],[1,1],[0,1],[1,0],[0,0]]
    -Explanation: The distances from (1, 2) to other cells are: [0,1,1,2,2,3]
    +Input: rows = 2, cols = 3, rCenter = 1, cCenter = 2
    +Output: [[1,2],[0,2],[1,1],[0,1],[1,0],[0,0]]
    +Explanation: The distances from (1, 2) to other cells are: [0,1,1,2,2,3]
     There are other answers that would also be accepted as correct, such as [[1,2],[1,1],[0,2],[1,0],[0,1],[0,0]].
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= rows <= 100
    2. -
    3. 1 <= cols <= 100
    4. +
        +
      • 1 <= rows, cols <= 100
      • 0 <= rCenter < rows
      • 0 <= cCenter < cols
      • -
    -
    -
    -
    + ### Related Topics [[Geometry](../../tag/geometry/README.md)] diff --git a/problems/maximize-sum-of-array-after-k-negations/README.md b/problems/maximize-sum-of-array-after-k-negations/README.md index b82451d17..881f9c9c8 100644 --- a/problems/maximize-sum-of-array-after-k-negations/README.md +++ b/problems/maximize-sum-of-array-after-k-negations/README.md @@ -11,49 +11,49 @@ ## [1005. Maximize Sum Of Array After K Negations (Easy)](https://leetcode.com/problems/maximize-sum-of-array-after-k-negations "K 次取反后最大化的数组和") -

    Given an array nums of integers, we must modify the array in the following way: we choose an i and replace nums[i] with -nums[i], and we repeat this process k times in total.  (We may choose the same index i multiple times.)

    +

    Given an integer array nums and an integer k, modify the array in the following way:

    -

    Return the largest possible sum of the array after modifying it in this way.

    +
      +
    • choose an index i and replace nums[i] with -nums[i].
    • +
    -

     

    +

    You should apply this process exactly k times. You may choose the same index i multiple times.

    + +

    Return the largest possible sum of the array after modifying it in this way.

    +

     

    Example 1:

    -Input: nums = [4,2,3], k = 1
    -Output: 5
    -Explanation: Choose indices (1,) and nums becomes [4,-2,3].
    +Input: nums = [4,2,3], k = 1
    +Output: 5
    +Explanation: Choose index 1 and nums becomes [4,-2,3].
     
    -

    Example 2:

    -Input: nums = [3,-1,0,2], k = 3
    -Output: 6
    -Explanation: Choose indices (1, 2, 2) and nums becomes [3,1,0,2].
    +Input: nums = [3,-1,0,2], k = 3
    +Output: 6
    +Explanation: Choose indices (1, 2, 2) and nums becomes [3,1,0,2].
     
    -

    Example 3:

    -Input: nums = [2,-3,-1,5,-4], k = 2
    -Output: 13
    -Explanation: Choose indices (1, 4) and nums becomes [2,3,-1,5,4].
    +Input: nums = [2,-3,-1,5,-4], k = 2
    +Output: 13
    +Explanation: Choose indices (1, 4) and nums becomes [2,3,-1,5,4].
     
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= nums.length <= 10000
    2. -
    3. 1 <= k <= 10000
    4. +
        +
      • 1 <= nums.length <= 104
      • -100 <= nums[i] <= 100
      • -
    +
  • 1 <= k <= 104
  • + ### Related Topics [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/maximum-binary-tree-ii/README.md b/problems/maximum-binary-tree-ii/README.md index e550fe95d..b720ca6e7 100644 --- a/problems/maximum-binary-tree-ii/README.md +++ b/problems/maximum-binary-tree-ii/README.md @@ -11,60 +11,59 @@ ## [998. Maximum Binary Tree II (Medium)](https://leetcode.com/problems/maximum-binary-tree-ii "最大二叉树 II") -

    We are given the root node of a maximum tree: a tree where every node has a value greater than any other value in its subtree.

    +

    A maximum tree is a tree where every node has a value greater than any other value in its subtree.

    -

    Just as in the previous problem, the given tree was constructed from an list A (root = Construct(A)) recursively with the following Construct(A) routine:

    +

    You are given the root of a maximum binary tree and an integer val.

    + +

    Just as in the previous problem, the given tree was constructed from a list a (root = Construct(a)) recursively with the following Construct(a) routine:

      -
    • If A is empty, return null.
    • -
    • Otherwise, let A[i] be the largest element of A.  Create a root node with value A[i].
    • -
    • The left child of root will be Construct([A[0], A[1], ..., A[i-1]])
    • -
    • The right child of root will be Construct([A[i+1], A[i+2], ..., A[A.length - 1]])
    • +
    • If a is empty, return null.
    • +
    • Otherwise, let a[i] be the largest element of a. Create a root node with the value a[i].
    • +
    • The left child of root will be Construct([a[0], a[1], ..., a[i - 1]]).
    • +
    • The right child of root will be Construct([a[i + 1], a[i + 2], ..., a[a.length - 1]]).
    • Return root.
    -

    Note that we were not given A directly, only a root node root = Construct(A).

    +

    Note that we were not given a directly, only a root node root = Construct(a).

    -

    Suppose B is a copy of A with the value val appended to it.  It is guaranteed that B has unique values.

    +

    Suppose b is a copy of a with the value val appended to it. It is guaranteed that b has unique values.

    -

    Return Construct(B).

    +

    Return Construct(b).

     

    Example 1:

    - -

    - +
    -Input: root = [4,1,3,null,null,2], val = 5
    -Output: [5,4,null,1,3,null,null,2]
    -Explanation: A = [1,4,2,3], B = [1,4,2,3,5]
    +Input: root = [4,1,3,null,null,2], val = 5
    +Output: [5,4,null,1,3,null,null,2]
    +Explanation: a = [1,4,2,3], b = [1,4,2,3,5]
     

    Example 2:

    - -

    - +
    -Input: root = [5,2,4,null,1], val = 3
    -Output: [5,2,4,null,1,null,3]
    -Explanation: A = [2,1,5,4], B = [2,1,5,4,3]
    +Input: root = [5,2,4,null,1], val = 3
    +Output: [5,2,4,null,1,null,3]
    +Explanation: a = [2,1,5,4], b = [2,1,5,4,3]
     

    Example 3:

    - -

    - +
    -Input: root = [5,2,3,null,1], val = 4
    -Output: [5,2,4,null,1,3]
    -Explanation: A = [2,1,5,3], B = [2,1,5,3,4]
    +Input: root = [5,2,3,null,1], val = 4
    +Output: [5,2,4,null,1,3]
    +Explanation: a = [2,1,5,3], b = [2,1,5,3,4]
     

     

    Constraints:

      -
    • 1 <= B.length <= 100
    • +
    • The number of nodes in the tree is in the range [1, 100].
    • +
    • 1 <= Node.val <= 100
    • +
    • All the values of the tree are unique.
    • +
    • 1 <= val <= 100
    ### Related Topics diff --git a/problems/maximum-length-of-pair-chain/README.md b/problems/maximum-length-of-pair-chain/README.md index 821eaff92..c108321a1 100644 --- a/problems/maximum-length-of-pair-chain/README.md +++ b/problems/maximum-length-of-pair-chain/README.md @@ -42,7 +42,7 @@
    • n == pairs.length
    • 1 <= n <= 1000
    • -
    • -1000 <= lefti < righti < 1000
    • +
    • -1000 <= lefti < righti <= 1000
    ### Related Topics diff --git a/problems/maximum-matrix-sum/README.md b/problems/maximum-matrix-sum/README.md new file mode 100644 index 000000000..e913149e1 --- /dev/null +++ b/problems/maximum-matrix-sum/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../minimum-time-to-type-word-using-special-typewriter "Minimum Time to Type Word Using Special Typewriter") +                 +[Next >](../number-of-ways-to-arrive-at-destination "Number of Ways to Arrive at Destination") + +## [1975. Maximum Matrix Sum (Medium)](https://leetcode.com/problems/maximum-matrix-sum "最大方阵和") + +

    You are given an n x n integer matrix. You can do the following operation any number of times:

    + +
      +
    • Choose any two adjacent elements of matrix and multiply each of them by -1.
    • +
    + +

    Two elements are considered adjacent if and only if they share a border.

    + +

    Your goal is to maximize the summation of the matrix's elements. Return the maximum sum of the matrix's elements using the operation mentioned above.

    + +

     

    +

    Example 1:

    + +
    +Input: matrix = [[1,-1],[-1,1]]
    +Output: 4
    +Explanation: We can follow the following steps to reach sum equals 4:
    +- Multiply the 2 elements in the first row by -1.
    +- Multiply the 2 elements in the first column by -1.
    +
    + +

    Example 2:

    + +
    +Input: matrix = [[1,2,3],[-1,-2,-3],[1,2,3]]
    +Output: 16
    +Explanation: We can follow the following step to reach sum equals 16:
    +- Multiply the 2 last elements in the second row by -1.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == matrix.length == matrix[i].length
    • +
    • 2 <= n <= 250
    • +
    • -105 <= matrix[i][j] <= 105
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Try to use the operation so that each row has only one negative number. +
    + +
    +Hint 2 +If you have only one negative element you cannot convert it to positive. +
    diff --git a/problems/maximum-number-of-weeks-for-which-you-can-work/README.md b/problems/maximum-number-of-weeks-for-which-you-can-work/README.md index 6be231e25..3cdeb2d18 100644 --- a/problems/maximum-number-of-weeks-for-which-you-can-work/README.md +++ b/problems/maximum-number-of-weeks-for-which-you-can-work/README.md @@ -67,6 +67,10 @@ Thus, one milestone in project 0 will remain unfinished.
  • 1 <= milestones[i] <= 109
  • +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + ### Hints
    Hint 1 diff --git a/problems/maximum-product-of-the-length-of-two-palindromic-substrings/README.md b/problems/maximum-product-of-the-length-of-two-palindromic-substrings/README.md new file mode 100644 index 000000000..ede109cb0 --- /dev/null +++ b/problems/maximum-product-of-the-length-of-two-palindromic-substrings/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../minimum-total-space-wasted-with-k-resizing-operations "Minimum Total Space Wasted With K Resizing Operations") +                 +[Next >](../check-if-string-is-a-prefix-of-array "Check If String Is a Prefix of Array") + +## [1960. Maximum Product of the Length of Two Palindromic Substrings (Hard)](https://leetcode.com/problems/maximum-product-of-the-length-of-two-palindromic-substrings "两个回文子字符串长度的最大乘积") + +

    You are given a 0-indexed string s and are tasked with finding two non-intersecting palindromic substrings of odd length such that the product of their lengths is maximized.

    + +

    More formally, you want to choose four integers i, j, k, l such that 0 <= i <= j < k <= l < s.length and both the substrings s[i...j] and s[k...l] are palindromes and have odd lengths. s[i...j] denotes a substring from index i to index j inclusive.

    + +

    Return the maximum possible product of the lengths of the two non-intersecting palindromic substrings.

    + +

    A palindrome is a string that is the same forward and backward. A substring is a contiguous sequence of characters in a string.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "ababbb"
    +Output: 9
    +Explanation: Substrings "aba" and "bbb" are palindromes with odd length. product = 3 * 3 = 9.
    +
    + +

    Example 2:

    + +
    +Input: s = "zaaaxbbby"
    +Output: 9
    +Explanation: Substrings "aaa" and "bbb" are palindromes with odd length. product = 3 * 3 = 9.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= s.length <= 105
    • +
    • s consists of lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] + +### Hints +
    +Hint 1 +You can use Manacher's algorithm to get the maximum palindromic substring centered at each index +
    + +
    +Hint 2 +After using Manacher's for each center use a line sweep from the center to the left and from the center to the right to find for each index the farthest center to it with distance ≤ palin[center] +
    + +
    +Hint 3 +After that, find the maximum palindrome size for each prefix in the string and for each suffix and the answer would be max(prefix[i] * suffix[i + 1]) +
    diff --git a/problems/maximum-sum-of-two-non-overlapping-subarrays/README.md b/problems/maximum-sum-of-two-non-overlapping-subarrays/README.md index 5210c6872..b82d688ab 100644 --- a/problems/maximum-sum-of-two-non-overlapping-subarrays/README.md +++ b/problems/maximum-sum-of-two-non-overlapping-subarrays/README.md @@ -11,60 +11,46 @@ ## [1031. Maximum Sum of Two Non-Overlapping Subarrays (Medium)](https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays "两个非重叠子数组的最大和") -

    Given an array nums of non-negative integers, return the maximum sum of elements in two non-overlapping (contiguous) subarrays, which have lengths firstLen and secondLen.  (For clarification, the firstLen-length subarray could occur before or after the secondLen-length subarray.)

    +

    Given an integer array nums and two integers firstLen and secondLen, return the maximum sum of elements in two non-overlapping subarrays with lengths firstLen and secondLen.

    -

    Formally, return the largest V for which V = (nums[i] + nums[i+1] + ... + nums[i+firstLen-1]) + (nums[j] + nums[j+1] + ... + nums[j+secondLen-1]) and either:

    +

    The array with length firstLen could occur before or after the array with length secondLen, but they have to be non-overlapping.

    -
      -
    • 0 <= i < i + firstLen - 1 < j < j + secondLen - 1 < nums.length, or
    • -
    • 0 <= j < j + secondLen - 1 < i < i + firstLen - 1 < nums.length.
    • -
    +

    A subarray is a contiguous part of an array.

     

    - -
      -
    - -

    Example 1:

    -Input: nums = [0,6,5,2,2,5,1,9,4], firstLen = 1, secondLen = 2
    -Output: 20
    -Explanation: One choice of subarrays is [9] with length 1, and [6,5] with length 2.
    +Input: nums = [0,6,5,2,2,5,1,9,4], firstLen = 1, secondLen = 2
    +Output: 20
    +Explanation: One choice of subarrays is [9] with length 1, and [6,5] with length 2.
     
    -

    Example 2:

    -Input: nums = [3,8,1,3,2,1,8,9,0], firstLen = 3, secondLen = 2
    -Output: 29
    -Explanation: One choice of subarrays is [3,8,1] with length 3, and [8,9] with length 2.
    +Input: nums = [3,8,1,3,2,1,8,9,0], firstLen = 3, secondLen = 2
    +Output: 29
    +Explanation: One choice of subarrays is [3,8,1] with length 3, and [8,9] with length 2.
     
    -

    Example 3:

    -Input: nums = [2,1,5,6,0,9,5,0,3,8], firstLen = 4, secondLen = 3
    -Output: 31
    -Explanation: One choice of subarrays is [5,6,0,9] with length 4, and [3,8] with length 3.
    +Input: nums = [2,1,5,6,0,9,5,0,3,8], firstLen = 4, secondLen = 3
    +Output: 31
    +Explanation: One choice of subarrays is [5,6,0,9] with length 4, and [3,8] with length 3.
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. firstLen >= 1
    2. -
    3. secondLen >= 1
    4. +
        +
      • 1 <= firstLen, secondLen <= 1000
      • +
      • 2 <= firstLen + secondLen <= 1000
      • firstLen + secondLen <= nums.length <= 1000
      • 0 <= nums[i] <= 1000
      • -
    -
    -
    -
    + ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/maximum-width-ramp/README.md b/problems/maximum-width-ramp/README.md index 0e5b438b2..90711b88d 100644 --- a/problems/maximum-width-ramp/README.md +++ b/problems/maximum-width-ramp/README.md @@ -11,48 +11,34 @@ ## [962. Maximum Width Ramp (Medium)](https://leetcode.com/problems/maximum-width-ramp "最大宽度坡") -

    Given an array nums of integers, a ramp is a tuple (i, j) for which i < j and nums[i] <= nums[j].  The width of such a ramp is j - i.

    +

    A ramp in an integer array nums is a pair (i, j) for which i < j and nums[i] <= nums[j]. The width of such a ramp is j - i.

    -

    Find the maximum width of a ramp in nums.  If one doesn't exist, return 0.

    +

    Given an integer array nums, return the maximum width of a ramp in nums. If there is no ramp in nums, return 0.

     

    -

    Example 1:

    -Input: nums = [6,0,8,2,1,5]
    -Output: 4
    -Explanation: 
    -The maximum width ramp is achieved at (i, j) = (1, 5): nums[1] = 0 and nums[5] = 5.
    +Input: nums = [6,0,8,2,1,5]
    +Output: 4
    +Explanation: The maximum width ramp is achieved at (i, j) = (1, 5): nums[1] = 0 and nums[5] = 5.
     
    -

    Example 2:

    -Input: nums = [9,8,1,0,1,9,4,0,4,1]
    -Output: 7
    -Explanation: 
    -The maximum width ramp is achieved at (i, j) = (2, 9): nums[2] = 1 and nums[9] = 1.
    +Input: nums = [9,8,1,0,1,9,4,0,4,1]
    +Output: 7
    +Explanation: The maximum width ramp is achieved at (i, j) = (2, 9): nums[2] = 1 and nums[9] = 1.
     
    -
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 2 <= nums.length <= 50000
    2. -
    3. 0 <= nums[i] <= 50000
    4. -
    -
    -
    - -
    -
     
    -
    +
      +
    • 2 <= nums.length <= 5 * 104
    • +
    • 0 <= nums[i] <= 5 * 104
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/minimize-the-difference-between-target-and-chosen-elements/README.md b/problems/minimize-the-difference-between-target-and-chosen-elements/README.md new file mode 100644 index 000000000..8729a0137 --- /dev/null +++ b/problems/minimize-the-difference-between-target-and-chosen-elements/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../find-unique-binary-string "Find Unique Binary String") +                 +[Next >](../find-array-given-subset-sums "Find Array Given Subset Sums") + +## [1981. Minimize the Difference Between Target and Chosen Elements (Medium)](https://leetcode.com/problems/minimize-the-difference-between-target-and-chosen-elements "最小化目标值与所选元素的差") + +

    You are given an m x n integer matrix mat and an integer target.

    + +

    Choose one integer from each row in the matrix such that the absolute difference between target and the sum of the chosen elements is minimized.

    + +

    Return the minimum absolute difference.

    + +

    The absolute difference between two numbers a and b is the absolute value of a - b.

    + +

     

    +

    Example 1:

    + +
    +Input: mat = [[1,2,3],[4,5,6],[7,8,9]], target = 13
    +Output: 0
    +Explanation: One possible choice is to:
    +- Choose 1 from the first row.
    +- Choose 5 from the second row.
    +- Choose 7 from the third row.
    +The sum of the chosen elements is 13, which equals the target, so the absolute difference is 0.
    +
    + +

    Example 2:

    + +
    +Input: mat = [[1],[2],[3]], target = 100
    +Output: 94
    +Explanation: The best possible choice is to:
    +- Choose 1 from the first row.
    +- Choose 2 from the second row.
    +- Choose 3 from the third row.
    +The sum of the chosen elements is 6, and the absolute difference is 94.
    +
    + +

    Example 3:

    + +
    +Input: mat = [[1,2,9,8,7]], target = 6
    +Output: 1
    +Explanation: The best choice is to choose 7 from the first row.
    +The absolute difference is 1.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == mat.length
    • +
    • n == mat[i].length
    • +
    • 1 <= m, n <= 70
    • +
    • 1 <= mat[i][j] <= 70
    • +
    • 1 <= target <= 800
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +The sum of chosen elements will not be too large. Consider using a hash set to record all possible sums while iterating each row. +
    + +
    +Hint 2 +Instead of keeping track of all possible sums, since in each row, we are adding positive numbers, only keep those that can be a candidate, not exceeding the target by too much. +
    diff --git a/problems/minimum-area-rectangle/README.md b/problems/minimum-area-rectangle/README.md index fce2aaa4a..9776dd77d 100644 --- a/problems/minimum-area-rectangle/README.md +++ b/problems/minimum-area-rectangle/README.md @@ -17,14 +17,14 @@

     

    Example 1:

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

    Example 2:

    - +
     Input: points = [[1,1],[1,3],[3,1],[3,3],[4,1],[4,3]]
     Output: 2
    diff --git a/problems/minimum-cost-to-hire-k-workers/README.md b/problems/minimum-cost-to-hire-k-workers/README.md
    index 510fbd210..b0c664f3b 100644
    --- a/problems/minimum-cost-to-hire-k-workers/README.md
    +++ b/problems/minimum-cost-to-hire-k-workers/README.md
    @@ -11,13 +11,13 @@
     
     ## [857. Minimum Cost to Hire K Workers (Hard)](https://leetcode.com/problems/minimum-cost-to-hire-k-workers "雇佣 K 名工人的最低成本")
     
    -

    There are n workers. You are given two integer arrays quality and wage where quality[i] is the quality of the ith worker and wage[i] is the minimum wage expectation for the ith worker.

    +

    There are n workers. You are given two integer arrays quality and wage where quality[i] is the quality of the ith worker and wage[i] is the minimum wage expectation for the ith worker.

    We want to hire exactly k workers to form a paid group. To hire a group of k workers, we must pay them according to the following rules:

    1. Every worker in the paid group should be paid in the ratio of their quality compared to other workers in the paid group.
    2. -
    3. Every worker in the paid group must be paid at least their minimum-wage expectation.
    4. +
    5. Every worker in the paid group must be paid at least their minimum wage expectation.

    Given the integer k, return the least amount of money needed to form a paid group satisfying the above conditions. Answers within 10-5 of the actual answer will be accepted.

    diff --git a/problems/minimum-cost-tree-from-leaf-values/README.md b/problems/minimum-cost-tree-from-leaf-values/README.md index 1360f4ad5..8472914f9 100644 --- a/problems/minimum-cost-tree-from-leaf-values/README.md +++ b/problems/minimum-cost-tree-from-leaf-values/README.md @@ -14,27 +14,30 @@

    Given an array arr of positive integers, consider all binary trees such that:

      -
    • Each node has either 0 or 2 children;
    • -
    • The values of arr correspond to the values of each leaf in an in-order traversal of the tree.  (Recall that a node is a leaf if and only if it has 0 children.)
    • -
    • The value of each non-leaf node is equal to the product of the largest leaf value in its left and right subtree respectively.
    • +
    • Each node has either 0 or 2 children;
    • +
    • The values of arr correspond to the values of each leaf in an in-order traversal of the tree.
    • +
    • The value of each non-leaf node is equal to the product of the largest leaf value in its left and right subtree, respectively.
    -

    Among all possible binary trees considered, return the smallest possible sum of the values of each non-leaf node.  It is guaranteed this sum fits into a 32-bit integer.

    +

    Among all possible binary trees considered, return the smallest possible sum of the values of each non-leaf node. It is guaranteed this sum fits into a 32-bit integer.

    + +

    A node is a leaf if and only if it has zero children.

     

    Example 1:

    - +
     Input: arr = [6,2,4]
     Output: 32
    -Explanation:
    -There are two possible trees.  The first has non-leaf node sum 36, and the second has non-leaf node sum 32.
    +Explanation: There are two possible trees shown.
    +The first has a non-leaf node sum 36, and the second has non-leaf node sum 32.
    +
    - 24 24 - / \ / \ - 12 4 6 8 - / \ / \ -6 2 2 4 +

    Example 2:

    + +
    +Input: arr = [4,11]
    +Output: 44
     

     

    @@ -43,7 +46,7 @@ There are two possible trees. The first has non-leaf node sum 36, and the secon
    • 2 <= arr.length <= 40
    • 1 <= arr[i] <= 15
    • -
    • It is guaranteed that the answer fits into a 32-bit signed integer (ie. it is less than 2^31).
    • +
    • It is guaranteed that the answer fits into a 32-bit signed integer (i.e., it is less than 231).
    ### Related Topics diff --git a/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md b/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md new file mode 100644 index 000000000..f082e8fb3 --- /dev/null +++ b/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](../widest-pair-of-indices-with-equal-range-sum "Widest Pair of Indices With Equal Range Sum") +                 +[Next >](../find-the-kth-largest-integer-in-the-array "Find the Kth Largest Integer in the Array") + +## [1984. Minimum Difference Between Highest and Lowest of K Scores (Easy)](https://leetcode.com/problems/minimum-difference-between-highest-and-lowest-of-k-scores "学生分数的最小差值") + +

    You are given a 0-indexed integer array nums, where nums[i] represents the score of the ith student. You are also given an integer k.

    + +

    Pick the scores of any k students from the array so that the difference between the highest and the lowest of the k scores is minimized.

    + +

    Return the minimum possible difference.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [90], k = 1
    +Output: 0
    +Explanation: There is one way to pick score(s) of one student:
    +- [90]. The difference between the highest and lowest score is 90 - 90 = 0.
    +The minimum possible difference is 0.
    +
    + +

    Example 2:

    + +
    +Input: nums = [9,4,1,7], k = 2
    +Output: 2
    +Explanation: There are six ways to pick score(s) of two students:
    +- [9,4,1,7]. The difference between the highest and lowest score is 9 - 4 = 5.
    +- [9,4,1,7]. The difference between the highest and lowest score is 9 - 1 = 8.
    +- [9,4,1,7]. The difference between the highest and lowest score is 9 - 7 = 2.
    +- [9,4,1,7]. The difference between the highest and lowest score is 4 - 1 = 3.
    +- [9,4,1,7]. The difference between the highest and lowest score is 7 - 4 = 3.
    +- [9,4,1,7]. The difference between the highest and lowest score is 7 - 1 = 6.
    +The minimum possible difference is 2.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= nums.length <= 1000
    • +
    • 0 <= nums[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +For the difference between the highest and lowest element to be minimized, the k chosen scores need to be as close to each other as possible. +
    + +
    +Hint 2 +What if the array was sorted? +
    + +
    +Hint 3 +After sorting the scores, any contiguous k scores are as close to each other as possible. +
    + +
    +Hint 4 +Apply a sliding window solution to iterate over each contiguous k scores, and find the minimum of the differences of all windows. +
    diff --git a/problems/minimum-falling-path-sum-ii/README.md b/problems/minimum-falling-path-sum-ii/README.md index 02940f388..31184daa2 100644 --- a/problems/minimum-falling-path-sum-ii/README.md +++ b/problems/minimum-falling-path-sum-ii/README.md @@ -11,17 +11,17 @@ ## [1289. Minimum Falling Path Sum II (Hard)](https://leetcode.com/problems/minimum-falling-path-sum-ii "下降路径最小和 II") -

    Given a square grid of integers arr, a falling path with non-zero shifts is a choice of exactly one element from each row of arr, such that no two elements chosen in adjacent rows are in the same column.

    +

    Given an n x n integer matrix grid, return the minimum sum of a falling path with non-zero shifts.

    -

    Return the minimum sum of a falling path with non-zero shifts.

    +

    A falling path with non-zero shifts is a choice of exactly one element from each row of grid such that no two elements chosen in adjacent rows are in the same column.

     

    Example 1:

    - +
     Input: arr = [[1,2,3],[4,5,6],[7,8,9]]
     Output: 13
    -Explanation: 
    +Explanation: 
     The possible falling paths are:
     [1,5,9], [1,5,7], [1,6,7], [1,6,8],
     [2,4,8], [2,4,9], [2,6,7], [2,6,8],
    @@ -29,12 +29,20 @@ The possible falling paths are:
     The falling path with the smallest sum is [1,5,7], so the answer is 13.
     
    +

    Example 2:

    + +
    +Input: grid = [[7]]
    +Output: 7
    +
    +

     

    Constraints:

      -
    • 1 <= arr.length == arr[i].length <= 200
    • -
    • -99 <= arr[i][j] <= 99
    • +
    • n == grid.length == grid[i].length
    • +
    • 1 <= n <= 200
    • +
    • -99 <= grid[i][j] <= 99
    ### Related Topics diff --git a/problems/minimum-falling-path-sum/README.md b/problems/minimum-falling-path-sum/README.md index c8d0aa50b..9b36ac783 100644 --- a/problems/minimum-falling-path-sum/README.md +++ b/problems/minimum-falling-path-sum/README.md @@ -58,6 +58,3 @@ [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Matrix](../../tag/matrix/README.md)] - -### Similar Questions - 1. [Minimum Falling Path Sum II](../minimum-falling-path-sum-ii) (Hard) diff --git a/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md b/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md index a49c6f701..b2674e4f4 100644 --- a/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md +++ b/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md @@ -11,28 +11,26 @@ ## [1263. Minimum Moves to Move a Box to Their Target Location (Hard)](https://leetcode.com/problems/minimum-moves-to-move-a-box-to-their-target-location "推箱子") -

    Storekeeper is a game in which the player pushes boxes around in a warehouse trying to get them to target locations.

    +

    A storekeeper is a game in which the player pushes boxes around in a warehouse trying to get them to target locations.

    -

    The game is represented by a grid of size m x n, where each element is a wall, floor, or a box.

    +

    The game is represented by an m x n grid of characters grid where each element is a wall, floor, or box.

    -

    Your task is move the box 'B' to the target position 'T' under the following rules:

    +

    Your task is to move the box 'B' to the target position 'T' under the following rules:

      -
    • Player is represented by character 'S' and can move up, down, left, right in the grid if it is a floor (empy cell).
    • -
    • Floor is represented by character '.' that means free cell to walk.
    • -
    • Wall is represented by character '#' that means obstacle  (impossible to walk there). 
    • -
    • There is only one box 'B' and one target cell 'T' in the grid.
    • +
    • The character 'S' represents the player. The player can move up, down, left, right in grid if it is a floor (empty cell).
    • +
    • The character '.' represents the floor which means a free cell to walk.
    • +
    • The character '#' represents the wall which means an obstacle (impossible to walk there).
    • +
    • There is only one box 'B' and one target cell 'T' in the grid.
    • The box can be moved to an adjacent free cell by standing next to the box and then moving in the direction of the box. This is a push.
    • The player cannot walk through the box.
    -

    Return the minimum number of pushes to move the box to the target. If there is no way to reach the target, return -1.

    +

    Return the minimum number of pushes to move the box to the target. If there is no way to reach the target, return -1.

     

    Example 1:

    - -

    - +
     Input: grid = [["#","#","#","#","#","#"],
                    ["#","T","#","#","#","#"],
    @@ -81,12 +79,11 @@
     

    Constraints:

      -
    • m == grid.length
    • -
    • n == grid[i].length
    • -
    • 1 <= m <= 20
    • -
    • 1 <= n <= 20
    • -
    • grid contains only characters '.', '#''S' , 'T', or 'B'.
    • -
    • There is only one character 'S', 'B' and 'T' in the grid.
    • +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 20
    • +
    • grid contains only characters '.', '#', 'S', 'T', or 'B'.
    • +
    • There is only one character 'S', 'B', and 'T' in the grid.
    ### Related Topics diff --git a/problems/minimum-non-zero-product-of-the-array-elements/README.md b/problems/minimum-non-zero-product-of-the-array-elements/README.md new file mode 100644 index 000000000..627db8207 --- /dev/null +++ b/problems/minimum-non-zero-product-of-the-array-elements/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../array-with-elements-not-equal-to-average-of-neighbors "Array With Elements Not Equal to Average of Neighbors") +                 +[Next >](../last-day-where-you-can-still-cross "Last Day Where You Can Still Cross") + +## [1969. Minimum Non-Zero Product of the Array Elements (Medium)](https://leetcode.com/problems/minimum-non-zero-product-of-the-array-elements "数组元素的最小非零乘积") + +

    You are given a positive integer p. Consider an array nums (1-indexed) that consists of the integers in the inclusive range [1, 2p - 1] in their binary representations. You are allowed to do the following operation any number of times:

    + +
      +
    • Choose two elements x and y from nums.
    • +
    • Choose a bit in x and swap it with its corresponding bit in y. Corresponding bit refers to the bit that is in the same position in the other integer.
    • +
    + +

    For example, if x = 1101 and y = 0011, after swapping the 2nd bit from the right, we have x = 1111 and y = 0001.

    + +

    Find the minimum non-zero product of nums after performing the above operation any number of times. Return this product modulo 109 + 7.

    + +

    Note: The answer should be the minimum product before the modulo operation is done.

    + +

     

    +

    Example 1:

    + +
    +Input: p = 1
    +Output: 1
    +Explanation: nums = [1].
    +There is only one element, so the product equals that element.
    +
    + +

    Example 2:

    + +
    +Input: p = 2
    +Output: 6
    +Explanation: nums = [01, 10, 11].
    +Any swap would either make the product 0 or stay the same.
    +Thus, the array product of 1 * 2 * 3 = 6 is already minimized.
    +
    + +

    Example 3:

    + +
    +Input: p = 3
    +Output: 1512
    +Explanation: nums = [001, 010, 011, 100, 101, 110, 111]
    +- In the first operation we can swap the leftmost bit of the second and fifth elements.
    +    - The resulting array is [001, 110, 011, 100, 001, 110, 111].
    +- In the second operation we can swap the middle bit of the third and fourth elements.
    +    - The resulting array is [001, 110, 001, 110, 001, 110, 111].
    +The array product is 1 * 6 * 1 * 6 * 1 * 6 * 7 = 1512, which is the minimum possible product.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= p <= 60
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Try to minimize each element by swapping bits with any of the elements after it. +
    + +
    +Hint 2 +If you swap out all the 1s in some element, this will lead to a product of zero. +
    diff --git a/problems/minimum-number-of-arrows-to-burst-balloons/README.md b/problems/minimum-number-of-arrows-to-burst-balloons/README.md index 71946c8d5..2914390b1 100644 --- a/problems/minimum-number-of-arrows-to-burst-balloons/README.md +++ b/problems/minimum-number-of-arrows-to-burst-balloons/README.md @@ -44,7 +44,7 @@

    Constraints:

      -
    • 1 <= points.length <= 104
    • +
    • 1 <= points.length <= 105
    • points[i].length == 2
    • -231 <= xstart < xend <= 231 - 1
    diff --git a/problems/minimum-number-of-k-consecutive-bit-flips/README.md b/problems/minimum-number-of-k-consecutive-bit-flips/README.md index 868f36388..79f2de9f5 100644 --- a/problems/minimum-number-of-k-consecutive-bit-flips/README.md +++ b/problems/minimum-number-of-k-consecutive-bit-flips/README.md @@ -11,51 +11,49 @@ ## [995. Minimum Number of K Consecutive Bit Flips (Hard)](https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips "K 连续位的最小翻转次数") -

    In an array nums containing only 0s and 1s, a k-bit flip consists of choosing a (contiguous) subarray of length k and simultaneously changing every 0 in the subarray to 1, and every 1 in the subarray to 0.

    +

    You are given a binary array nums and an integer k.

    -

    Return the minimum number of k-bit flips required so that there is no 0 in the array.  If it is not possible, return -1.

    +

    A k-bit flip is choosing a subarray of length k from nums and simultaneously changing every 0 in the subarray to 1, and every 1 in the subarray to 0.

    -

     

    +

    Return the minimum number of k-bit flips required so that there is no 0 in the array. If it is not possible, return -1.

    + +

    A subarray is a contiguous part of an array.

    +

     

    Example 1:

    -Input: nums = [0,1,0], k = 1
    -Output: 2
    -Explanation: Flip nums[0], then flip nums[2].
    +Input: nums = [0,1,0], k = 1
    +Output: 2
    +Explanation: Flip nums[0], then flip nums[2].
     
    -

    Example 2:

    -Input: nums = [1,1,0], k = 2
    -Output: -1
    -Explanation: No matter how we flip subarrays of size 2, we can't make the array become [1,1,1].
    +Input: nums = [1,1,0], k = 2
    +Output: -1
    +Explanation: No matter how we flip subarrays of size 2, we cannot make the array become [1,1,1].
     
    -

    Example 3:

    -Input: nums = [0,0,0,1,0,1,1,0], k = 3
    -Output: 3
    -Explanation:
    +Input: nums = [0,0,0,1,0,1,1,0], k = 3
    +Output: 3
    +Explanation: 
     Flip nums[0],nums[1],nums[2]: nums becomes [1,1,1,1,0,1,1,0]
     Flip nums[4],nums[5],nums[6]: nums becomes [1,1,1,1,1,0,0,0]
     Flip nums[5],nums[6],nums[7]: nums becomes [1,1,1,1,1,1,1,1]
     

     

    -
    -
    - -

    Note:

    +

    Constraints:

    -
      -
    1. 1 <= nums.length <= 30000
    2. +
        +
      • 1 <= nums.length <= 3 * 104
      • 1 <= k <= nums.length
      • -
    + ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/minimum-number-of-swaps-to-make-the-string-balanced/README.md b/problems/minimum-number-of-swaps-to-make-the-string-balanced/README.md new file mode 100644 index 000000000..116007468 --- /dev/null +++ b/problems/minimum-number-of-swaps-to-make-the-string-balanced/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../remove-stones-to-minimize-the-total "Remove Stones to Minimize the Total") +                 +[Next >](../find-the-longest-valid-obstacle-course-at-each-position "Find the Longest Valid Obstacle Course at Each Position") + +## [1963. Minimum Number of Swaps to Make the String Balanced (Medium)](https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-string-balanced "使字符串平衡的最小交换次数") + +

    You are given a 0-indexed string s of even length n. The string consists of exactly n / 2 opening brackets '[' and n / 2 closing brackets ']'.

    + +

    A string is called balanced if and only if:

    + +
      +
    • It is the empty string, or
    • +
    • It can be written as AB, where both A and B are balanced strings, or
    • +
    • It can be written as [C], where C is a balanced string.
    • +
    + +

    You may swap the brackets at any two indices any number of times.

    + +

    Return the minimum number of swaps to make s balanced.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "][]["
    +Output: 1
    +Explanation: You can make the string balanced by swapping index 0 with index 3.
    +The resulting string is "[[]]".
    +
    + +

    Example 2:

    + +
    +Input: s = "]]][[["
    +Output: 2
    +Explanation: You can do the following to make the string balanced:
    +- Swap index 0 with index 4. s = "[]][][".
    +- Swap index 1 with index 5. s = "[[][]]".
    +The resulting string is "[[][]]".
    +
    + +

    Example 3:

    + +
    +Input: s = "[]"
    +Output: 0
    +Explanation: The string is already balanced.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == s.length
    • +
    • 2 <= n <= 106
    • +
    • n is even.
    • +
    • s[i] is either '[' or ']'.
    • +
    • The number of opening brackets '[' equals n / 2, and the number of closing brackets ']' equals n / 2.
    • +
    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Iterate over the string and keep track of the number of opening and closing brackets on each step. +
    + +
    +Hint 2 +If the number of closing brackets is ever larger, you need to make a swap. +
    + +
    +Hint 3 +Swap it with the opening bracket closest to the end of s. +
    diff --git a/problems/minimum-number-of-work-sessions-to-finish-the-tasks/README.md b/problems/minimum-number-of-work-sessions-to-finish-the-tasks/README.md new file mode 100644 index 000000000..68440f11a --- /dev/null +++ b/problems/minimum-number-of-work-sessions-to-finish-the-tasks/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../find-the-kth-largest-integer-in-the-array "Find the Kth Largest Integer in the Array") +                 +[Next >](../number-of-unique-good-subsequences "Number of Unique Good Subsequences") + +## [1986. Minimum Number of Work Sessions to Finish the Tasks (Medium)](https://leetcode.com/problems/minimum-number-of-work-sessions-to-finish-the-tasks "完成任务的最少工作时间段") + +

    There are n tasks assigned to you. The task times are represented as an integer array tasks of length n, where the ith task takes tasks[i] hours to finish. A work session is when you work for at most sessionTime consecutive hours and then take a break.

    + +

    You should finish the given tasks in a way that satisfies the following conditions:

    + +
      +
    • If you start a task in a work session, you must complete it in the same work session.
    • +
    • You can start a new task immediately after finishing the previous one.
    • +
    • You may complete the tasks in any order.
    • +
    + +

    Given tasks and sessionTime, return the minimum number of work sessions needed to finish all the tasks following the conditions above.

    + +

    The tests are generated such that sessionTime is greater than or equal to the maximum element in tasks[i].

    + +

     

    +

    Example 1:

    + +
    +Input: tasks = [1,2,3], sessionTime = 3
    +Output: 2
    +Explanation: You can finish the tasks in two work sessions.
    +- First work session: finish the first and the second tasks in 1 + 2 = 3 hours.
    +- Second work session: finish the third task in 3 hours.
    +
    + +

    Example 2:

    + +
    +Input: tasks = [3,1,3,1,1], sessionTime = 8
    +Output: 2
    +Explanation: You can finish the tasks in two work sessions.
    +- First work session: finish all the tasks except the last one in 3 + 1 + 3 + 1 = 8 hours.
    +- Second work session: finish the last task in 1 hour.
    +
    + +

    Example 3:

    + +
    +Input: tasks = [1,2,3,4,5], sessionTime = 15
    +Output: 1
    +Explanation: You can finish all the tasks in one work session.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == tasks.length
    • +
    • 1 <= n <= 14
    • +
    • 1 <= tasks[i] <= 10
    • +
    • max(tasks[i]) <= sessionTime <= 15
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] + +### Hints +
    +Hint 1 +Try all possible ways of assignment. +
    + +
    +Hint 2 +If we can store the assignments in form of a state then we can reuse that state and solve the problem in a faster way. +
    diff --git a/problems/minimum-time-for-k-virus-variants-to-spread/README.md b/problems/minimum-time-for-k-virus-variants-to-spread/README.md new file mode 100644 index 000000000..9b248d850 --- /dev/null +++ b/problems/minimum-time-for-k-virus-variants-to-spread/README.md @@ -0,0 +1,25 @@ + + + + + + + +[< Previous](../count-number-of-special-subsequences "Count Number of Special Subsequences") +                 +[Next >](../delete-characters-to-make-fancy-string "Delete Characters to Make Fancy String") + +## [1956. Minimum Time For K Virus Variants to Spread (Hard)](https://leetcode.com/problems/minimum-time-for-k-virus-variants-to-spread "感染 K 种病毒所需的最短时间") + + + +### Hints +
    +Hint 1 +n is very small, how can we use that? +
    + +
    +Hint 2 +What shape is the region when two viruses intersect? +
    diff --git a/problems/minimum-time-to-type-word-using-special-typewriter/README.md b/problems/minimum-time-to-type-word-using-special-typewriter/README.md new file mode 100644 index 000000000..21d475e25 --- /dev/null +++ b/problems/minimum-time-to-type-word-using-special-typewriter/README.md @@ -0,0 +1,93 @@ + + + + + + + +[< Previous](../count-nodes-equal-to-sum-of-descendants "Count Nodes Equal to Sum of Descendants") +                 +[Next >](../maximum-matrix-sum "Maximum Matrix Sum") + +## [1974. Minimum Time to Type Word Using Special Typewriter (Easy)](https://leetcode.com/problems/minimum-time-to-type-word-using-special-typewriter "使用特殊打字机键入单词的最少时间") + +

    There is a special typewriter with lowercase English letters 'a' to 'z' arranged in a circle with a pointer. A character can only be typed if the pointer is pointing to that character. The pointer is initially pointing to the character 'a'.

    + +

    Each second, you may perform one of the following operations:

    + +
      +
    • Move the pointer one character counterclockwise or clockwise.
    • +
    • Type the character the pointer is currently on.
    • +
    + +

    Given a string word, return the minimum number of seconds to type out the characters in word.

    + +

     

    +

    Example 1:

    + +
    +Input: word = "abc"
    +Output: 5
    +Explanation: 
    +The characters are printed as follows:
    +- Type the character 'a' in 1 second since the pointer is initially on 'a'.
    +- Move the pointer clockwise to 'b' in 1 second.
    +- Type the character 'b' in 1 second.
    +- Move the pointer clockwise to 'c' in 1 second.
    +- Type the character 'c' in 1 second.
    +
    + +

    Example 2:

    + +
    +Input: word = "bza"
    +Output: 7
    +Explanation:
    +The characters are printed as follows:
    +- Move the pointer clockwise to 'b' in 1 second.
    +- Type the character 'b' in 1 second.
    +- Move the pointer counterclockwise to 'z' in 2 seconds.
    +- Type the character 'z' in 1 second.
    +- Move the pointer clockwise to 'a' in 1 second.
    +- Type the character 'a' in 1 second.
    +
    + +

    Example 3:

    + +
    +Input: word = "zjpc"
    +Output: 34
    +Explanation:
    +The characters are printed as follows:
    +- Move the pointer counterclockwise to 'z' in 1 second.
    +- Type the character 'z' in 1 second.
    +- Move the pointer clockwise to 'j' in 10 seconds.
    +- Type the character 'j' in 1 second.
    +- Move the pointer clockwise to 'p' in 6 seconds.
    +- Type the character 'p' in 1 second.
    +- Move the pointer counterclockwise to 'c' in 13 seconds.
    +- Type the character 'c' in 1 second.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= word.length <= 100
    • +
    • word consists of lowercase English letters.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +There are only two possible directions you can go when you move to the next letter. +
    + +
    +Hint 2 +When moving to the next letter, you will always go in the direction that takes the least amount of time. +
    diff --git a/problems/minimum-total-space-wasted-with-k-resizing-operations/README.md b/problems/minimum-total-space-wasted-with-k-resizing-operations/README.md new file mode 100644 index 000000000..9668b96ce --- /dev/null +++ b/problems/minimum-total-space-wasted-with-k-resizing-operations/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../check-if-move-is-legal "Check if Move is Legal") +                 +[Next >](../maximum-product-of-the-length-of-two-palindromic-substrings "Maximum Product of the Length of Two Palindromic Substrings") + +## [1959. Minimum Total Space Wasted With K Resizing Operations (Medium)](https://leetcode.com/problems/minimum-total-space-wasted-with-k-resizing-operations "K 次调整数组大小浪费的最小总空间") + +

    You are currently designing a dynamic array. You are given a 0-indexed integer array nums, where nums[i] is the number of elements that will be in the array at time i. In addition, you are given an integer k, the maximum number of times you can resize the array (to any size).

    + +

    The size of the array at time t, sizet, must be at least nums[t] because there needs to be enough space in the array to hold all the elements. The space wasted at time t is defined as sizet - nums[t], and the total space wasted is the sum of the space wasted across every time t where 0 <= t < nums.length.

    + +

    Return the minimum total space wasted if you can resize the array at most k times.

    + +

    Note: The array can have any size at the start and does not count towards the number of resizing operations.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [10,20], k = 0
    +Output: 10
    +Explanation: size = [20,20].
    +We can set the initial size to be 20.
    +The total wasted space is (20 - 10) + (20 - 20) = 10.
    +
    + +

    Example 2:

    + +
    +Input: nums = [10,20,30], k = 1
    +Output: 10
    +Explanation: size = [20,20,30].
    +We can set the initial size to be 20 and resize to 30 at time 2. 
    +The total wasted space is (20 - 10) + (20 - 20) + (30 - 30) = 10.
    +
    + +

    Example 3:

    + +
    +Input: nums = [10,20,15,30,20], k = 2
    +Output: 15
    +Explanation: size = [10,20,20,30,30].
    +We can set the initial size to 10, resize to 20 at time 1, and resize to 30 at time 3.
    +The total wasted space is (10 - 10) + (20 - 20) + (20 - 15) + (30 - 30) + (30 - 20) = 15.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 200
    • +
    • 1 <= nums[i] <= 106
    • +
    • 0 <= k <= nums.length - 1
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Given a range, how can you find the minimum waste if you can't perform any resize operations? +
    + +
    +Hint 2 +Can we build our solution using dynamic programming using the current index and the number of resizing operations performed as the states? +
    diff --git a/problems/moving-stones-until-consecutive-ii/README.md b/problems/moving-stones-until-consecutive-ii/README.md index 2867980e0..036567f21 100644 --- a/problems/moving-stones-until-consecutive-ii/README.md +++ b/problems/moving-stones-until-consecutive-ii/README.md @@ -11,63 +11,51 @@ ## [1040. Moving Stones Until Consecutive II (Medium)](https://leetcode.com/problems/moving-stones-until-consecutive-ii "移动石子直到连续 II") -

    On an infinite number line, the position of the i-th stone is given by stones[i].  Call a stone an endpoint stone if it has the smallest or largest position.

    +

    There are some stones in different positions on the X-axis. You are given an integer array stones, the positions of the stones.

    -

    Each turn, you pick up an endpoint stone and move it to an unoccupied position so that it is no longer an endpoint stone.

    +

    Call a stone an endpoint stone if it has the smallest or largest position. In one move, you pick up an endpoint stone and move it to an unoccupied position so that it is no longer an endpoint stone.

    -

    In particular, if the stones are at say, stones = [1,2,5], you cannot move the endpoint stone at position 5, since moving it to any position (such as 0, or 3) will still keep that stone as an endpoint stone.

    +
      +
    • In particular, if the stones are at say, stones = [1,2,5], you cannot move the endpoint stone at position 5, since moving it to any position (such as 0, or 3) will still keep that stone as an endpoint stone.
    • +
    -

    The game ends when you cannot make any more moves, ie. the stones are in consecutive positions.

    +

    The game ends when you cannot make any more moves (i.e., the stones are in three consecutive positions).

    -

    When the game ends, what is the minimum and maximum number of moves that you could have made?  Return the answer as an length 2 array: answer = [minimum_moves, maximum_moves]

    +

    Return an integer array answer of length 2 where:

    -

     

    +
      +
    • answer[0] is the minimum number of moves you can play, and
    • +
    • answer[1] is the maximum number of moves you can play.
    • +
    +

     

    Example 1:

    -Input: [7,4,9]
    -Output: [1,2]
    -Explanation: 
    -We can move 4 -> 8 for one move to finish the game.
    +Input: stones = [7,4,9]
    +Output: [1,2]
    +Explanation: We can move 4 -> 8 for one move to finish the game.
     Or, we can move 9 -> 5, 4 -> 6 for two moves to finish the game.
     
    -

    Example 2:

    -Input: [6,5,4,3,10]
    -Output: [2,3]
    -We can move 3 -> 8 then 10 -> 7 to finish the game.
    +Input: stones = [6,5,4,3,10]
    +Output: [2,3]
    +Explanation: We can move 3 -> 8 then 10 -> 7 to finish the game.
     Or, we can move 3 -> 7, 4 -> 8, 5 -> 9 to finish the game.
     Notice we cannot move 10 -> 2 to finish the game, because that would be an illegal move.
     
    -
    -

    Example 3:

    - -
    -Input: [100,101,104,102,103]
    -Output: [0,0]
    -

     

    -
    -
    - -

    Note:

    - -
      -
    1. 3 <= stones.length <= 10^4
    2. -
    3. 1 <= stones[i] <= 10^9
    4. -
    5. stones[i] have distinct values.
    6. -
    - -
    -
    -
     
    -
    -
    +

    Constraints:

    + +
      +
    • 3 <= stones.length <= 104
    • +
    • 1 <= stones[i] <= 109
    • +
    • All the values of stones are unique.
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/moving-stones-until-consecutive/README.md b/problems/moving-stones-until-consecutive/README.md index a8c92eb18..e7de515ef 100644 --- a/problems/moving-stones-until-consecutive/README.md +++ b/problems/moving-stones-until-consecutive/README.md @@ -9,64 +9,53 @@                  [Next >](../coloring-a-border "Coloring A Border") -## [1033. Moving Stones Until Consecutive (Easy)](https://leetcode.com/problems/moving-stones-until-consecutive "移动石子直到连续") +## [1033. Moving Stones Until Consecutive (Medium)](https://leetcode.com/problems/moving-stones-until-consecutive "移动石子直到连续") -

    Three stones are on a number line at positions a, b, and c.

    +

    There are three stones in different positions on the X-axis. You are given three integers a, b, and c, the positions of the stones.

    -

    Each turn, you pick up a stone at an endpoint (ie., either the lowest or highest position stone), and move it to an unoccupied position between those endpoints.  Formally, let's say the stones are currently at positions x, y, z with x < y < z.  You pick up the stone at either position x or position z, and move that stone to an integer position k, with x < k < z and k != y.

    +

    In one move, you pick up a stone at an endpoint (i.e., either the lowest or highest position stone), and move it to an unoccupied position between those endpoints. Formally, let's say the stones are currently at positions x, y, and z with x < y < z. You pick up the stone at either position x or position z, and move that stone to an integer position k, with x < k < z and k != y.

    -

    The game ends when you cannot make any more moves, ie. the stones are in consecutive positions.

    +

    The game ends when you cannot make any more moves (i.e., the stones are in three consecutive positions).

    -

    When the game ends, what is the minimum and maximum number of moves that you could have made?  Return the answer as an length 2 array: answer = [minimum_moves, maximum_moves]

    +

    Return an integer array answer of length 2 where:

    -

     

    +
      +
    • answer[0] is the minimum number of moves you can play, and
    • +
    • answer[1] is the maximum number of moves you can play.
    • +
    +

     

    Example 1:

    -Input: a = 1, b = 2, c = 5
    -Output: [1,2]
    -Explanation: Move the stone from 5 to 3, or move the stone from 5 to 4 to 3.
    +Input: a = 1, b = 2, c = 5
    +Output: [1,2]
    +Explanation: Move the stone from 5 to 3, or move the stone from 5 to 4 to 3.
     
    -

    Example 2:

    -Input: a = 4, b = 3, c = 2
    -Output: [0,0]
    -Explanation: We cannot make any moves.
    +Input: a = 4, b = 3, c = 2
    +Output: [0,0]
    +Explanation: We cannot make any moves.
     
    -

    Example 3:

    -Input: a = 3, b = 5, c = 1
    -Output: [1,2]
    -Explanation: Move the stone from 1 to 4; or move the stone from 1 to 2 to 4.
    +Input: a = 3, b = 5, c = 1
    +Output: [1,2]
    +Explanation: Move the stone from 1 to 4; or move the stone from 1 to 2 to 4.
     

     

    -
    -
    - -

    Note:

    - -
      -
    1. 1 <= a <= 100
    2. -
    3. 1 <= b <= 100
    4. -
    5. 1 <= c <= 100
    6. -
    7. a != b, b != c, c != a
    8. -
    - -
    -

     

    +

    Constraints:

    -
    -
     
    -
    -
    +
      +
    • 1 <= a, b, c <= 100
    • +
    • a, b, and c have different values.
    • +
    ### Related Topics [[Brainteaser](../../tag/brainteaser/README.md)] diff --git a/problems/next-greater-node-in-linked-list/README.md b/problems/next-greater-node-in-linked-list/README.md index 4b574aeab..ef5eff299 100644 --- a/problems/next-greater-node-in-linked-list/README.md +++ b/problems/next-greater-node-in-linked-list/README.md @@ -11,51 +11,35 @@ ## [1019. Next Greater Node In Linked List (Medium)](https://leetcode.com/problems/next-greater-node-in-linked-list "链表中的下一个更大节点") -

    We are given a linked list with head as the first node.  Let's number the nodes in the list: node_1, node_2, node_3, ... etc.

    +

    You are given the head of a linked list with n nodes.

    -

    Each node may have a next larger value: for node_inext_larger(node_i) is the node_j.val such that j > i, node_j.val > node_i.val, and j is the smallest possible choice.  If such a j does not exist, the next larger value is 0.

    +

    For each node in the list, find the value of the next greater node. That is, for each node, find the value of the first node that is next to it and has a strictly larger value than it.

    -

    Return an array of integers answer, where answer[i] = next_larger(node_{i+1}).

    - -

    Note that in the example inputs (not outputs) below, arrays such as [2,1,5] represent the serialization of a linked list with a head node value of 2, second node value of 1, and third node value of 5.

    +

    Return an integer array answer where answer[i] is the value of the next greater node of the ith node (1-indexed). If the ith node does not have a next greater node, set answer[i] = 0.

     

    - -

    Example 1:

    - +
    -Input: [2,1,5]
    -Output: [5,5,0]
    +Input: head = [2,1,5]
    +Output: [5,5,0]
     
    -

    Example 2:

    - +
    -Input: [2,7,4,3,5]
    -Output: [7,0,5,5,0]
    -
    - -
    -

    Example 3:

    - -
    -Input: [1,7,5,1,9,2,5,1]
    -Output: [7,9,9,9,0,5,0,0]
    +Input: head = [2,7,4,3,5]
    +Output: [7,0,5,5,0]
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= node.val <= 10^9 for each node in the linked list.
    2. -
    3. The given list has length in the range [0, 10000].
    4. -
    -
    -
    -
    +
      +
    • The number of nodes in the list is n.
    • +
    • 1 <= n <= 104
    • +
    • 1 <= Node.val <= 109
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/number-complement/README.md b/problems/number-complement/README.md index 10d005f24..fab5c3486 100644 --- a/problems/number-complement/README.md +++ b/problems/number-complement/README.md @@ -11,7 +11,13 @@ ## [476. Number Complement (Easy)](https://leetcode.com/problems/number-complement "数字的补数") -

    Given a positive integer num, output its complement number. The complement strategy is to flip the bits of its binary representation.

    +

    The complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation.

    + +
      +
    • For example, The integer 5 is "101" in binary and its complement is "010" which is the integer 2.
    • +
    + +

    Given an integer num, return its complement.

     

    Example 1:

    @@ -34,11 +40,11 @@

    Constraints:

    +

     

    +

    Note: This question is the same as 1009: https://leetcode.com/problems/complement-of-base-10-integer/

    + ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/number-of-equivalent-domino-pairs/README.md b/problems/number-of-equivalent-domino-pairs/README.md index 28796636b..0b18a70ad 100644 --- a/problems/number-of-equivalent-domino-pairs/README.md +++ b/problems/number-of-equivalent-domino-pairs/README.md @@ -11,20 +11,31 @@ ## [1128. Number of Equivalent Domino Pairs (Easy)](https://leetcode.com/problems/number-of-equivalent-domino-pairs "等价多米诺骨牌对的数量") -

    Given a list of dominoesdominoes[i] = [a, b] is equivalent to dominoes[j] = [c, d] if and only if either (a==c and b==d), or (a==d and b==c) - that is, one domino can be rotated to be equal to another domino.

    +

    Given a list of dominoes, dominoes[i] = [a, b] is equivalent to dominoes[j] = [c, d] if and only if either (a == c and b == d), or (a == d and b == c) - that is, one domino can be rotated to be equal to another domino.

    -

    Return the number of pairs (i, j) for which 0 <= i < j < dominoes.length, and dominoes[i] is equivalent to dominoes[j].

    +

    Return the number of pairs (i, j) for which 0 <= i < j < dominoes.length, and dominoes[i] is equivalent to dominoes[j].

     

    Example 1:

    -
    Input: dominoes = [[1,2],[2,1],[3,4],[5,6]]
    +
    +
    +Input: dominoes = [[1,2],[2,1],[3,4],[5,6]]
     Output: 1
     
    + +

    Example 2:

    + +
    +Input: dominoes = [[1,2],[1,2],[1,1],[1,2],[2,2]]
    +Output: 3
    +
    +

     

    Constraints:

      -
    • 1 <= dominoes.length <= 40000
    • +
    • 1 <= dominoes.length <= 4 * 104
    • +
    • dominoes[i].length == 2
    • 1 <= dominoes[i][j] <= 9
    diff --git a/problems/number-of-good-pairs/README.md b/problems/number-of-good-pairs/README.md index 4040f598b..e174c305f 100644 --- a/problems/number-of-good-pairs/README.md +++ b/problems/number-of-good-pairs/README.md @@ -11,11 +11,9 @@ ## [1512. Number of Good Pairs (Easy)](https://leetcode.com/problems/number-of-good-pairs "好数对的数目") -

    Given an array of integers nums.

    +

    Given an array of integers nums, return the number of good pairs.

    -

    A pair (i,j) is called good if nums[i] == nums[j] and i < j.

    - -

    Return the number of good pairs.

    +

    A pair (i, j) is called good if nums[i] == nums[j] and i < j.

     

    Example 1:

    @@ -23,7 +21,7 @@
     Input: nums = [1,2,3,1,1,3]
     Output: 4
    -Explanation: There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed.
    +Explanation: There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed.
     

    Example 2:

    @@ -31,7 +29,7 @@
     Input: nums = [1,1,1,1]
     Output: 6
    -Explanation: Each pair in the array are good.
    +Explanation: Each pair in the array are good.
     

    Example 3:

    diff --git a/problems/number-of-squareful-arrays/README.md b/problems/number-of-squareful-arrays/README.md index 5e8390b3d..862424300 100644 --- a/problems/number-of-squareful-arrays/README.md +++ b/problems/number-of-squareful-arrays/README.md @@ -11,36 +11,35 @@ ## [996. Number of Squareful Arrays (Hard)](https://leetcode.com/problems/number-of-squareful-arrays "正方形数组的数目") -

    Given an array nums of non-negative integers, the array is squareful if for every pair of adjacent elements, their sum is a perfect square.

    +

    An array is squareful if the sum of every pair of adjacent elements is a perfect square.

    -

    Return the number of permutations of nums that are squareful.  Two permutations perm1 and perm2 differ if and only if there is some index i such that perm1[i] != perm2[i].

    +

    Given an integer array nums, return the number of permutations of nums that are squareful.

    -

     

    +

    Two permutations perm1 and perm2 are different if there is some index i such that perm1[i] != perm2[i].

    +

     

    Example 1:

    -Input: nums = [1,17,8]
    -Output: 2
    -Explanation: 
    -[1,8,17] and [17,8,1] are the valid permutations.
    +Input: nums = [1,17,8]
    +Output: 2
    +Explanation: [1,8,17] and [17,8,1] are the valid permutations.
     

    Example 2:

    -Input: nums = [2,2,2]
    -Output: 1
    +Input: nums = [2,2,2]
    +Output: 1
     

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= nums.length <= 12
      • 0 <= nums[i] <= 109
      • -
    + ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/number-of-strings-that-appear-as-substrings-in-word/README.md b/problems/number-of-strings-that-appear-as-substrings-in-word/README.md new file mode 100644 index 000000000..9715e0190 --- /dev/null +++ b/problems/number-of-strings-that-appear-as-substrings-in-word/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../binary-searchable-numbers-in-an-unsorted-array "Binary Searchable Numbers in an Unsorted Array") +                 +[Next >](../array-with-elements-not-equal-to-average-of-neighbors "Array With Elements Not Equal to Average of Neighbors") + +## [1967. Number of Strings That Appear as Substrings in Word (Easy)](https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word "作为子字符串出现在单词中的字符串数目") + +

    Given an array of strings patterns and a string word, return the number of strings in patterns that exist as a substring in word.

    + +

    A substring is a contiguous sequence of characters within a string.

    + +

     

    +

    Example 1:

    + +
    +Input: patterns = ["a","abc","bc","d"], word = "abc"
    +Output: 3
    +Explanation:
    +- "a" appears as a substring in "abc".
    +- "abc" appears as a substring in "abc".
    +- "bc" appears as a substring in "abc".
    +- "d" does not appear as a substring in "abc".
    +3 of the strings in patterns appear as a substring in word.
    +
    + +

    Example 2:

    + +
    +Input: patterns = ["a","b","c"], word = "aaaaabbbbb"
    +Output: 2
    +Explanation:
    +- "a" appears as a substring in "aaaaabbbbb".
    +- "b" appears as a substring in "aaaaabbbbb".
    +- "c" does not appear as a substring in "aaaaabbbbb".
    +2 of the strings in patterns appear as a substring in word.
    +
    + +

    Example 3:

    + +
    +Input: patterns = ["a","a","a"], word = "ab"
    +Output: 3
    +Explanation: Each of the patterns appears as a substring in word "ab".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= patterns.length <= 100
    • +
    • 1 <= patterns[i].length <= 100
    • +
    • 1 <= word.length <= 100
    • +
    • patterns[i] and word consist of lowercase English letters.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Deal with each of the patterns individually. +
    + +
    +Hint 2 +Use the built-in function in the language you are using to find if the pattern exists as a substring in word. +
    diff --git a/problems/number-of-sub-arrays-with-odd-sum/README.md b/problems/number-of-sub-arrays-with-odd-sum/README.md index fcc492d90..71d637e99 100644 --- a/problems/number-of-sub-arrays-with-odd-sum/README.md +++ b/problems/number-of-sub-arrays-with-odd-sum/README.md @@ -11,9 +11,9 @@ ## [1524. Number of Sub-arrays With Odd Sum (Medium)](https://leetcode.com/problems/number-of-sub-arrays-with-odd-sum "和为奇数的子数组数目") -

    Given an array of integers arr. Return the number of sub-arrays with odd sum.

    +

    Given an array of integers arr, return the number of subarrays with an odd sum.

    -

    As the answer may grow large, the answer must be computed modulo 10^9 + 7.

    +

    Since the answer can be very large, return it modulo 109 + 7.

     

    Example 1:

    @@ -21,7 +21,7 @@
     Input: arr = [1,3,5]
     Output: 4
    -Explanation: All sub-arrays are [[1],[1,3],[1,3,5],[3],[3,5],[5]]
    +Explanation: All subarrays are [[1],[1,3],[1,3,5],[3],[3,5],[5]]
     All sub-arrays sum are [1,4,9,3,8,5].
     Odd sums are [1,9,3,5] so the answer is 4.
     
    @@ -31,7 +31,7 @@ Odd sums are [1,9,3,5] so the answer is 4.
     Input: arr = [2,4,6]
     Output: 0
    -Explanation: All sub-arrays are [[2],[2,4],[2,4,6],[4],[4,6],[6]]
    +Explanation: All subarrays are [[2],[2,4],[2,4,6],[4],[4,6],[6]]
     All sub-arrays sum are [2,6,12,4,10,6].
     All sub-arrays have even sum and the answer is 0.
     
    @@ -43,25 +43,11 @@ All sub-arrays have even sum and the answer is 0. Output: 16
    -

    Example 4:

    - -
    -Input: arr = [100,100,99,99]
    -Output: 4
    -
    - -

    Example 5:

    - -
    -Input: arr = [7]
    -Output: 1
    -
    -

     

    Constraints:

      -
    • 1 <= arr.length <= 10^5
    • +
    • 1 <= arr.length <= 105
    • 1 <= arr[i] <= 100
    diff --git a/problems/number-of-unique-good-subsequences/README.md b/problems/number-of-unique-good-subsequences/README.md new file mode 100644 index 000000000..a0aa82c51 --- /dev/null +++ b/problems/number-of-unique-good-subsequences/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../minimum-number-of-work-sessions-to-finish-the-tasks "Minimum Number of Work Sessions to Finish the Tasks") +                 +[Next >](../find-cutoff-score-for-each-school "Find Cutoff Score for Each School") + +## [1987. Number of Unique Good Subsequences (Hard)](https://leetcode.com/problems/number-of-unique-good-subsequences "不同的好子序列数目") + +

    You are given a binary string binary. A subsequence of binary is considered good if it is not empty and has no leading zeros (with the exception of "0").

    + +

    Find the number of unique good subsequences of binary.

    + +
      +
    • For example, if binary = "001", then all the good subsequences are ["0", "0", "1"], so the unique good subsequences are "0" and "1". Note that subsequences "00", "01", and "001" are not good because they have leading zeros.
    • +
    + +

    Return the number of unique good subsequences of binary. Since the answer may be very large, return it modulo 109 + 7.

    + +

    A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.

    + +

     

    +

    Example 1:

    + +
    +Input: binary = "001"
    +Output: 2
    +Explanation: The good subsequences of binary are ["0", "0", "1"].
    +The unique good subsequences are "0" and "1".
    +
    + +

    Example 2:

    + +
    +Input: binary = "11"
    +Output: 2
    +Explanation: The good subsequences of binary are ["1", "1", "11"].
    +The unique good subsequences are "1" and "11".
    + +

    Example 3:

    + +
    +Input: binary = "101"
    +Output: 5
    +Explanation: The good subsequences of binary are ["1", "0", "1", "10", "11", "101"]. 
    +The unique good subsequences are "0", "1", "10", "11", and "101".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= binary.length <= 105
    • +
    • binary consists of only '0's and '1's.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +The number of unique good subsequences is equal to the number of unique decimal values there are for all possible subsequences. +
    + +
    +Hint 2 +Find the answer at each index based on the previous indexes' answers. +
    diff --git a/problems/number-of-valid-words-for-each-puzzle/README.md b/problems/number-of-valid-words-for-each-puzzle/README.md index 87ac1ffdf..32cfedc50 100644 --- a/problems/number-of-valid-words-for-each-puzzle/README.md +++ b/problems/number-of-valid-words-for-each-puzzle/README.md @@ -11,40 +11,49 @@ ## [1178. Number of Valid Words for Each Puzzle (Hard)](https://leetcode.com/problems/number-of-valid-words-for-each-puzzle "猜字谜") -With respect to a given puzzle string, a word is valid if both the following conditions are satisfied: +With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:
    • word contains the first letter of puzzle.
    • -
    • For each letter in word, that letter is in puzzle.
      - For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid words are "beefed" (doesn't include "a") and "based" (includes "s" which isn't in the puzzle).
    • +
    • For each letter in word, that letter is in puzzle. +
        +
      • For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage", while
      • +
      • invalid words are "beefed" (does not include 'a') and "based" (includes 's' which is not in the puzzle).
      • +
      +
    -Return an array answer, where answer[i] is the number of words in the given word list words that are valid with respect to the puzzle puzzles[i]. +Return an array answer, where answer[i] is the number of words in the given word list words that is valid with respect to the puzzle puzzles[i].

     

    -

    Example :

    +

    Example 1:

    -Input: 
    -words = ["aaaa","asas","able","ability","actt","actor","access"], 
    -puzzles = ["aboveyz","abrodyz","abslute","absoryz","actresz","gaswxyz"]
    +Input: words = ["aaaa","asas","able","ability","actt","actor","access"], puzzles = ["aboveyz","abrodyz","abslute","absoryz","actresz","gaswxyz"]
     Output: [1,1,3,2,4,0]
    -Explanation:
    -1 valid word for "aboveyz" : "aaaa" 
    -1 valid word for "abrodyz" : "aaaa"
    +Explanation: 
    +1 valid word for "aboveyz" : "aaaa" 
    +1 valid word for "abrodyz" : "aaaa"
     3 valid words for "abslute" : "aaaa", "asas", "able"
    -2 valid words for "absoryz" : "aaaa", "asas"
    -4 valid words for "actresz" : "aaaa", "asas", "actt", "access"
    -There're no valid words for "gaswxyz" cause none of the words in the list contains letter 'g'.
    +2 valid words for "absoryz" : "aaaa", "asas"
    +4 valid words for "actresz" : "aaaa", "asas", "actt", "access"
    +There are no valid words for "gaswxyz" cause none of the words in the list contains letter 'g'.
    +
    + +

    Example 2:

    + +
    +Input: words = ["apple","pleas","please"], puzzles = ["aelwxyz","aelpxyz","aelpsxy","saelpxy","xaelpsy"]
    +Output: [0,1,3,2,0]
     

     

    Constraints:

      -
    • 1 <= words.length <= 10^5
    • +
    • 1 <= words.length <= 105
    • 4 <= words[i].length <= 50
    • -
    • 1 <= puzzles.length <= 10^4
    • +
    • 1 <= puzzles.length <= 104
    • puzzles[i].length == 7
    • -
    • words[i][j], puzzles[i][j] are English lowercase letters.
    • -
    • Each puzzles[i] doesn't contain repeated characters.
    • +
    • words[i] and puzzles[i] consist of lowercase English letters.
    • +
    • Each puzzles[i] does not contain repeated characters.
    ### Related Topics diff --git a/problems/number-of-ways-to-arrive-at-destination/README.md b/problems/number-of-ways-to-arrive-at-destination/README.md new file mode 100644 index 000000000..0c6c974cf --- /dev/null +++ b/problems/number-of-ways-to-arrive-at-destination/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../maximum-matrix-sum "Maximum Matrix Sum") +                 +[Next >](../number-of-ways-to-separate-numbers "Number of Ways to Separate Numbers") + +## [1976. Number of Ways to Arrive at Destination (Medium)](https://leetcode.com/problems/number-of-ways-to-arrive-at-destination "到达目的地的方案数") + +

    You are in a city that consists of n intersections numbered from 0 to n - 1 with bi-directional roads between some intersections. The inputs are generated such that you can reach any intersection from any other intersection and that there is at most one road between any two intersections.

    + +

    You are given an integer n and a 2D integer array roads where roads[i] = [ui, vi, timei] means that there is a road between intersections ui and vi that takes timei minutes to travel. You want to know in how many ways you can travel from intersection 0 to intersection n - 1 in the shortest amount of time.

    + +

    Return the number of ways you can arrive at your destination in the shortest amount of time. Since the answer may be large, return it modulo 109 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 7, roads = [[0,6,7],[0,1,2],[1,2,3],[1,3,3],[6,3,3],[3,5,1],[6,5,1],[2,5,1],[0,4,5],[4,6,2]]
    +Output: 4
    +Explanation: The shortest amount of time it takes to go from intersection 0 to intersection 6 is 7 minutes.
    +The four ways to get there in 7 minutes are:
    +- 0 ➝ 6
    +- 0 ➝ 4 ➝ 6
    +- 0 ➝ 1 ➝ 2 ➝ 5 ➝ 6
    +- 0 ➝ 1 ➝ 3 ➝ 5 ➝ 6
    +
    + +

    Example 2:

    + +
    +Input: n = 2, roads = [[1,0,10]]
    +Output: 1
    +Explanation: There is only one way to go from intersection 0 to intersection 1, and it takes 10 minutes.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 200
    • +
    • n - 1 <= roads.length <= n * (n - 1) / 2
    • +
    • roads[i].length == 3
    • +
    • 0 <= ui, vi <= n - 1
    • +
    • 1 <= timei <= 109
    • +
    • ui != vi
    • +
    • There is at most one road connecting any two intersections.
    • +
    • You can reach any intersection from any other intersection.
    • +
    + +### Related Topics + [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] + +### Hints +
    +Hint 1 +First use any shortest path algorithm to get edges where dist[u] + weight = dist[v], here dist[x] is the shortest distance between node 0 and x +
    + +
    +Hint 2 +Using those edges only the graph turns into a dag now we just need to know the number of ways to get from node 0 to node n - 1 on a dag using dp +
    diff --git a/problems/number-of-ways-to-separate-numbers/README.md b/problems/number-of-ways-to-separate-numbers/README.md new file mode 100644 index 000000000..350a57bf5 --- /dev/null +++ b/problems/number-of-ways-to-separate-numbers/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../number-of-ways-to-arrive-at-destination "Number of Ways to Arrive at Destination") +                 +[Next >](../employees-whose-manager-left-the-company "Employees Whose Manager Left the Company") + +## [1977. Number of Ways to Separate Numbers (Hard)](https://leetcode.com/problems/number-of-ways-to-separate-numbers "划分数字的方案数") + +

    You wrote down many positive integers in a string called num. However, you realized that you forgot to add commas to seperate the different numbers. You remember that the list of integers was non-decreasing and that no integer had leading zeros.

    + +

    Return the number of possible lists of integers that you could have written down to get the string num. Since the answer may be large, return it modulo 109 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: num = "327"
    +Output: 2
    +Explanation: You could have written down the numbers:
    +3, 27
    +327
    +
    + +

    Example 2:

    + +
    +Input: num = "094"
    +Output: 0
    +Explanation: No numbers can have leading zeros and all numbers must be positive.
    +
    + +

    Example 3:

    + +
    +Input: num = "0"
    +Output: 0
    +Explanation: No numbers can have leading zeros and all numbers must be positive.
    +
    + +

    Example 4:

    + +
    +Input: num = "9999999999999"
    +Output: 101
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= num.length <= 3500
    • +
    • num consists of digits '0' through '9'.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Suffix Array](../../tag/suffix-array/README.md)] + +### Hints +
    +Hint 1 +If we know the current number has d digits, how many digits can the previous number have? +
    + +
    +Hint 2 +Is there a quick way of calculating the number of possibilities for the previous number if we know that it must have less than or equal to d digits? Try to do some pre-processing. +
    diff --git a/problems/numbers-with-repeated-digits/README.md b/problems/numbers-with-repeated-digits/README.md index 9de73cb4d..83006a889 100644 --- a/problems/numbers-with-repeated-digits/README.md +++ b/problems/numbers-with-repeated-digits/README.md @@ -11,46 +11,38 @@ ## [1012. Numbers With Repeated Digits (Hard)](https://leetcode.com/problems/numbers-with-repeated-digits "至少有 1 位重复的数字") -

    Given a positive integer n, return the number of positive integers less than or equal to n that have at least 1 repeated digit.

    +

    Given an integer n, return the number of positive integers in the range [1, n] that have at least one repeated digit.

     

    - -

    Example 1:

    -Input: n = 20
    -Output: 1
    -Explanation: The only positive number (<= 20) with at least 1 repeated digit is 11.
    +Input: n = 20
    +Output: 1
    +Explanation: The only positive number (<= 20) with at least 1 repeated digit is 11.
     
    -

    Example 2:

    -Input: n = 100
    -Output: 10
    -Explanation: The positive numbers (<= 100) with atleast 1 repeated digit are 11, 22, 33, 44, 55, 66, 77, 88, 99, and 100.
    +Input: n = 100
    +Output: 10
    +Explanation: The positive numbers (<= 100) with atleast 1 repeated digit are 11, 22, 33, 44, 55, 66, 77, 88, 99, and 100.
     
    -

    Example 3:

    -Input: n = 1000
    -Output: 262
    +Input: n = 1000
    +Output: 262
     
    -

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= n <= 109
      • -
    -
    -
    + ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/odd-even-jump/README.md b/problems/odd-even-jump/README.md index 09b3df687..faf449c89 100644 --- a/problems/odd-even-jump/README.md +++ b/problems/odd-even-jump/README.md @@ -11,7 +11,7 @@ ## [975. Odd Even Jump (Hard)](https://leetcode.com/problems/odd-even-jump "奇偶跳") -

    You are given an integer array arr. From some starting index, you can make a series of jumps. The (1st, 3rd, 5th, ...) jumps in the series are called odd-numbered jumps, and the (2nd, 4th, 6th, ...) jumps in the series are called even-numbered jumps. Note that the jumps are numbered, not the indices.

    +

    You are given an integer array arr. From some starting index, you can make a series of jumps. The (1st, 3rd, 5th, ...) jumps in the series are called odd-numbered jumps, and the (2nd, 4th, 6th, ...) jumps in the series are called even-numbered jumps. Note that the jumps are numbered, not the indices.

    You may jump forward from index i to index j (with i < j) in the following way:

    diff --git a/problems/online-election/README.md b/problems/online-election/README.md index 171ea2423..aca0c3936 100644 --- a/problems/online-election/README.md +++ b/problems/online-election/README.md @@ -11,39 +11,50 @@ ## [911. Online Election (Medium)](https://leetcode.com/problems/online-election "在线选举") -

    In an election, the i-th vote was cast for persons[i] at time times[i].

    +

    You are given two integer arrays persons and times. In an election, the ith vote was cast for persons[i] at time times[i].

    -

    Now, we would like to implement the following query function: TopVotedCandidate.q(int t) will return the number of the person that was leading the election at time t.  

    +

    For each query at a time t, find the person that was leading the election at time t. Votes cast at time t will count towards our query. In the case of a tie, the most recent vote (among tied candidates) wins.

    -

    Votes cast at time t will count towards our query.  In the case of a tie, the most recent vote (among tied candidates) wins.

    +

    Implement the TopVotedCandidate class:

    -

     

    +
      +
    • TopVotedCandidate(int[] persons, int[] times) Initializes the object with the persons and times arrays.
    • +
    • int q(int t) Returns the number of the person that was leading the election at time t according to the mentioned rules.
    • +
    -
    +

     

    Example 1:

    -Input: ["TopVotedCandidate","q","q","q","q","q","q"], [[[0,1,1,0,0,1,0],[0,5,10,15,20,25,30]],[3],[12],[25],[15],[24],[8]]
    -Output: [null,0,1,1,0,0,1]
    -Explanation: 
    -At time 3, the votes are [0], and 0 is leading.
    -At time 12, the votes are [0,1,1], and 1 is leading.
    -At time 25, the votes are [0,1,1,0,0,1], and 1 is leading (as ties go to the most recent vote.)
    -This continues for 3 more queries at time 15, 24, and 8.
    +Input
    +["TopVotedCandidate", "q", "q", "q", "q", "q", "q"]
    +[[[0, 1, 1, 0, 0, 1, 0], [0, 5, 10, 15, 20, 25, 30]], [3], [12], [25], [15], [24], [8]]
    +Output
    +[null, 0, 1, 1, 0, 0, 1]
    +
    +Explanation
    +TopVotedCandidate topVotedCandidate = new TopVotedCandidate([0, 1, 1, 0, 0, 1, 0], [0, 5, 10, 15, 20, 25, 30]);
    +topVotedCandidate.q(3); // return 0, At time 3, the votes are [0], and 0 is leading.
    +topVotedCandidate.q(12); // return 1, At time 12, the votes are [0,1,1], and 1 is leading.
    +topVotedCandidate.q(25); // return 1, At time 25, the votes are [0,1,1,0,0,1], and 1 is leading (as ties go to the most recent vote.)
    +topVotedCandidate.q(15); // return 0
    +topVotedCandidate.q(24); // return 0
    +topVotedCandidate.q(8); // return 1
    +
     

     

    - -

    Note:

    - -
      -
    1. 1 <= persons.length = times.length <= 5000
    2. -
    3. 0 <= persons[i] <= persons.length
    4. -
    5. times is a strictly increasing array with all elements in [0, 10^9].
    6. -
    7. TopVotedCandidate.q is called at most 10000 times per test case.
    8. -
    9. TopVotedCandidate.q(int t) is always called with t >= times[0].
    10. -
    -
    +

    Constraints:

    + +
      +
    • 1 <= persons.length <= 5000
    • +
    • times.length == persons.length
    • +
    • 0 <= persons[i] < persons.length
    • +
    • 0 <= times[i] <= 109
    • +
    • times is sorted in a strictly increasing order.
    • +
    • times[0] <= t <= 109
    • +
    • At most 104 calls will be made to q.
    • +
    ### Related Topics [[Design](../../tag/design/README.md)] diff --git a/problems/online-stock-span/README.md b/problems/online-stock-span/README.md index 16d6ba897..dd85693dc 100644 --- a/problems/online-stock-span/README.md +++ b/problems/online-stock-span/README.md @@ -11,45 +11,49 @@ ## [901. Online Stock Span (Medium)](https://leetcode.com/problems/online-stock-span "股票价格跨度") -

    Write a class StockSpanner which collects daily price quotes for some stock, and returns the span of that stock's price for the current day.

    +

    Design an algorithm that collects daily price quotes for some stock and returns the span of that stock's price for the current day.

    -

    The span of the stock's price today is defined as the maximum number of consecutive days (starting from today and going backwards) for which the price of the stock was less than or equal to today's price.

    +

    The span of the stock's price today is defined as the maximum number of consecutive days (starting from today and going backward) for which the stock price was less than or equal to today's price.

    -

    For example, if the price of a stock over the next 7 days were [100, 80, 60, 70, 60, 75, 85], then the stock spans would be [1, 1, 1, 2, 1, 4, 6].

    +
      +
    • For example, if the price of a stock over the next 7 days were [100,80,60,70,60,75,85], then the stock spans would be [1,1,1,2,1,4,6].
    • +
    -

     

    +

    Implement the StockSpanner class:

    + +
      +
    • StockSpanner() Initializes the object of the class.
    • +
    • int next(int price) Returns the span of the stock's price given that today's price is price.
    • +
    -
    +

     

    Example 1:

    -Input: ["StockSpanner","next","next","next","next","next","next","next"], [[],[100],[80],[60],[70],[60],[75],[85]]
    -Output: [null,1,1,1,2,1,4,6]
    -Explanation: 
    -First, S = StockSpanner() is initialized.  Then:
    -S.next(100) is called and returns 1,
    -S.next(80) is called and returns 1,
    -S.next(60) is called and returns 1,
    -S.next(70) is called and returns 2,
    -S.next(60) is called and returns 1,
    -S.next(75) is called and returns 4,
    -S.next(85) is called and returns 6.
    -
    -Note that (for example) S.next(75) returned 4, because the last 4 prices
    -(including today's price of 75) were less than or equal to today's price.
    +Input
    +["StockSpanner", "next", "next", "next", "next", "next", "next", "next"]
    +[[], [100], [80], [60], [70], [60], [75], [85]]
    +Output
    +[null, 1, 1, 1, 2, 1, 4, 6]
    +
    +Explanation
    +StockSpanner stockSpanner = new StockSpanner();
    +stockSpanner.next(100); // return 1
    +stockSpanner.next(80);  // return 1
    +stockSpanner.next(60);  // return 1
    +stockSpanner.next(70);  // return 2
    +stockSpanner.next(60);  // return 1
    +stockSpanner.next(75);  // return 4, because the last 4 prices (including today's price of 75) were less than or equal to today's price.
    +stockSpanner.next(85);  // return 6
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. Calls to StockSpanner.next(int price) will have 1 <= price <= 10^5.
    2. -
    3. There will be at most 10000 calls to StockSpanner.next per test case.
    4. -
    5. There will be at most 150000 calls to StockSpanner.next across all test cases.
    6. -
    7. The total time limit for this problem has been reduced by 75% for C++, and 50% for all other languages.
    8. -
    -
    +
      +
    • 1 <= price <= 105
    • +
    • At most 104 calls will be made to next.
    • +
    ### Related Topics [[Stack](../../tag/stack/README.md)] diff --git a/problems/path-sum-ii/README.md b/problems/path-sum-ii/README.md index adce85256..67c076b6c 100644 --- a/problems/path-sum-ii/README.md +++ b/problems/path-sum-ii/README.md @@ -11,9 +11,9 @@ ## [113. Path Sum II (Medium)](https://leetcode.com/problems/path-sum-ii "路径总和 II") -

    Given the root of a binary tree and an integer targetSum, return all root-to-leaf paths where each path's sum equals targetSum.

    +

    Given the root of a binary tree and an integer targetSum, return all root-to-leaf paths where the sum of the node values in the path equals targetSum. Each path should be returned as a list of the node values, not node references.

    -

    A leaf is a node with no children.

    +

    A root-to-leaf path is a path starting from the root and ending at any leaf node. A leaf is a node with no children.

     

    Example 1:

    @@ -21,6 +21,9 @@
     Input: root = [5,4,8,11,null,13,4,7,2,null,null,5,1], targetSum = 22
     Output: [[5,4,11,2],[5,8,4,5]]
    +Explanation: There are two paths whose sum equals targetSum:
    +5 + 4 + 11 + 2 = 22
    +5 + 8 + 4 + 5 = 22
     

    Example 2:

    diff --git a/problems/permutation-in-string/README.md b/problems/permutation-in-string/README.md index 345a95944..a928de1f4 100644 --- a/problems/permutation-in-string/README.md +++ b/problems/permutation-in-string/README.md @@ -11,9 +11,9 @@ ## [567. Permutation in String (Medium)](https://leetcode.com/problems/permutation-in-string "字符串的排列") -

    Given two strings s1 and s2, return true if s2 contains the permutation of s1.

    +

    Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise.

    -

    In other words, one of s1's permutations is the substring of s2.

    +

    In other words, return true if one of s1's permutations is the substring of s2.

     

    Example 1:

    diff --git a/problems/plus-one/README.md b/problems/plus-one/README.md index 5fdd553d4..8e2a7d0b8 100644 --- a/problems/plus-one/README.md +++ b/problems/plus-one/README.md @@ -11,11 +11,9 @@ ## [66. Plus One (Easy)](https://leetcode.com/problems/plus-one "加一") -

    Given a non-empty array of decimal digits representing a non-negative integer, increment one to the integer.

    +

    You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading 0's.

    -

    The digits are stored such that the most significant digit is at the head of the list, and each element in the array contains a single digit.

    - -

    You may assume the integer does not contain any leading zero, except the number 0 itself.

    +

    Increment the large integer by one and return the resulting array of digits.

     

    Example 1:

    @@ -24,6 +22,8 @@ Input: digits = [1,2,3] Output: [1,2,4] Explanation: The array represents the integer 123. +Incrementing by one gives 123 + 1 = 124. +Thus, the result should be [1,2,4].

    Example 2:

    @@ -32,6 +32,8 @@ Input: digits = [4,3,2,1] Output: [4,3,2,2] Explanation: The array represents the integer 4321. +Incrementing by one gives 4321 + 1 = 4322. +Thus, the result should be [4,3,2,2].

    Example 3:

    @@ -39,6 +41,19 @@
     Input: digits = [0]
     Output: [1]
    +Explanation: The array represents the integer 0.
    +Incrementing by one gives 0 + 1 = 1.
    +Thus, the result should be [1].
    +
    + +

    Example 4:

    + +
    +Input: digits = [9]
    +Output: [1,0]
    +Explanation: The array represents the integer 9.
    +Incrementing by one gives 9 + 1 = 10.
    +Thus, the result should be [1,0].
     

     

    @@ -47,6 +62,7 @@
    • 1 <= digits.length <= 100
    • 0 <= digits[i] <= 9
    • +
    • digits does not contain any leading 0's.
    ### Related Topics diff --git a/problems/populating-next-right-pointers-in-each-node-ii/README.md b/problems/populating-next-right-pointers-in-each-node-ii/README.md index 8b15d1f52..ea527badd 100644 --- a/problems/populating-next-right-pointers-in-each-node-ii/README.md +++ b/problems/populating-next-right-pointers-in-each-node-ii/README.md @@ -26,32 +26,36 @@ struct Node {

    Initially, all next pointers are set to NULL.

    -

     

    - -

    Follow up:

    - -
      -
    • You may only use constant extra space.
    • -
    • Recursive approach is fine, you may assume implicit stack space does not count as extra space for this problem.
    • -
    -

     

    Example 1:

    - -

    - +
     Input: root = [1,2,3,4,5,null,7]
     Output: [1,#,2,3,#,4,5,7,#]
     Explanation: Given the above binary tree (Figure A), your function should populate each next pointer to point to its next right node, just like in Figure B. The serialized output is in level order as connected by the next pointers, with '#' signifying the end of each level.
     
    +

    Example 2:

    + +
    +Input: root = []
    +Output: []
    +
    +

     

    Constraints:

      -
    • The number of nodes in the given tree is less than 6000.
    • -
    • -100 <= node.val <= 100
    • +
    • The number of nodes in the tree is in the range [0, 6000].
    • +
    • -100 <= Node.val <= 100
    • +
    + +

     

    +

    Follow-up:

    + +
      +
    • You may only use constant extra space.
    • +
    • The recursive approach is fine. You may assume implicit stack space does not count as extra space for this problem.
    ### Related Topics diff --git a/problems/populating-next-right-pointers-in-each-node/README.md b/problems/populating-next-right-pointers-in-each-node/README.md index 8e3b5a4af..e81ccb3de 100644 --- a/problems/populating-next-right-pointers-in-each-node/README.md +++ b/problems/populating-next-right-pointers-in-each-node/README.md @@ -11,7 +11,7 @@ ## [116. Populating Next Right Pointers in Each Node (Medium)](https://leetcode.com/problems/populating-next-right-pointers-in-each-node "填充每个节点的下一个右侧节点指针") -

    You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:

    +

    You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:

     struct Node {
    @@ -26,32 +26,36 @@ struct Node {
     
     

    Initially, all next pointers are set to NULL.

    -

     

    - -

    Follow up:

    - -
      -
    • You may only use constant extra space.
    • -
    • Recursive approach is fine, you may assume implicit stack space does not count as extra space for this problem.
    • -
    -

     

    Example 1:

    - -

    - +
     Input: root = [1,2,3,4,5,6,7]
     Output: [1,#,2,3,#,4,5,6,7,#]
     Explanation: Given the above perfect binary tree (Figure A), your function should populate each next pointer to point to its next right node, just like in Figure B. The serialized output is in level order as connected by the next pointers, with '#' signifying the end of each level.
     
    +

    Example 2:

    + +
    +Input: root = []
    +Output: []
    +
    +

     

    Constraints:

      -
    • The number of nodes in the given tree is less than 4096.
    • -
    • -1000 <= node.val <= 1000
    • +
    • The number of nodes in the tree is in the range [0, 212 - 1].
    • +
    • -1000 <= Node.val <= 1000
    • +
    + +

     

    +

    Follow-up:

    + +
      +
    • You may only use constant extra space.
    • +
    • The recursive approach is fine. You may assume implicit stack space does not count as extra space for this problem.
    ### Related Topics diff --git a/problems/print-foobar-alternately/README.md b/problems/print-foobar-alternately/README.md index 871c2b934..f059e20d7 100644 --- a/problems/print-foobar-alternately/README.md +++ b/problems/print-foobar-alternately/README.md @@ -16,39 +16,53 @@
     class FooBar {
       public void foo() {
    -    for (int i = 0; i < n; i++) {
    -      print("foo");
    -    }
    +    for (int i = 0; i < n; i++) {
    +      print("foo");
    +    }
       }
     
       public void bar() {
    -    for (int i = 0; i < n; i++) {
    -      print("bar");
    -    }
    +    for (int i = 0; i < n; i++) {
    +      print("bar");
    +    }
       }
     }
     
    -

    The same instance of FooBar will be passed to two different threads. Thread A will call foo() while thread B will call bar(). Modify the given program to output "foobar" n times.

    +

    The same instance of FooBar will be passed to two different threads:

    -

     

    +
      +
    • thread A will call foo(), while
    • +
    • thread B will call bar().
    • +
    + +

    Modify the given program to output "foobar" n times.

    +

     

    Example 1:

    -Input: n = 1
    -Output: "foobar"
    -Explanation: There are two threads being fired asynchronously. One of them calls foo(), while the other calls bar(). "foobar" is being output 1 time.
    +Input: n = 1
    +Output: "foobar"
    +Explanation: There are two threads being fired asynchronously. One of them calls foo(), while the other calls bar().
    +"foobar" is being output 1 time.
     

    Example 2:

    -Input: n = 2
    -Output: "foobarfoobar"
    +Input: n = 2
    +Output: "foobarfoobar"
     Explanation: "foobar" is being output 2 times.
     
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 1000
    • +
    + ### Related Topics [[Concurrency](../../tag/concurrency/README.md)] diff --git a/problems/print-in-order/README.md b/problems/print-in-order/README.md index f1d1f274e..b97cb6ac8 100644 --- a/problems/print-in-order/README.md +++ b/problems/print-in-order/README.md @@ -44,6 +44,13 @@ public class Foo { Explanation: The input [1,3,2] means thread A calls first(), thread B calls third(), and thread C calls second(). "firstsecondthird" is the correct output.
    +

     

    +

    Constraints:

    + +
      +
    • nums is a permutation of [1, 2, 3].
    • +
    + ### Related Topics [[Concurrency](../../tag/concurrency/README.md)] diff --git a/problems/product-of-the-last-k-numbers/README.md b/problems/product-of-the-last-k-numbers/README.md index d35c25586..f981f6951 100644 --- a/problems/product-of-the-last-k-numbers/README.md +++ b/problems/product-of-the-last-k-numbers/README.md @@ -11,22 +11,17 @@ ## [1352. Product of the Last K Numbers (Medium)](https://leetcode.com/problems/product-of-the-last-k-numbers "最后 K 个数的乘积") -

    Implement the class ProductOfNumbers that supports two methods:

    +

    Design an algorithm that accepts a stream of integers and retrieves the product of the last k integers of the stream.

    -

    1. add(int num)

    +

    Implement the ProductOfNumbers class:

      -
    • Adds the number num to the back of the current list of numbers.
    • +
    • ProductOfNumbers() Initializes the object with an empty stream.
    • +
    • void add(int num) Appends the integer num to the stream.
    • +
    • int getProduct(int k) Returns the product of the last k numbers in the current list. You can assume that always the current list has at least k numbers.
    -

    2. getProduct(int k)

    - -
      -
    • Returns the product of the last k numbers in the current list.
    • -
    • You can assume that always the current list has at least k numbers.
    • -
    - -

    At any time, the product of any contiguous sequence of numbers will fit into a single 32-bit integer without overflowing.

    +

    The test cases are generated so that, at any time, the product of any contiguous sequence of numbers will fit into a single 32-bit integer without overflowing.

     

    Example:

    @@ -57,9 +52,10 @@ productOfNumbers.getProduct(2); // return 32. The product of the last 2 numbers

    Constraints:

      -
    • There will be at most 40000 operations considering both add and getProduct.
    • -
    • 0 <= num <= 100
    • -
    • 1 <= k <= 40000
    • +
    • 0 <= num <= 100
    • +
    • 1 <= k <= 4 * 104
    • +
    • At most 4 * 104 calls will be made to add and getProduct.
    • +
    • The product of the stream at any point in time will fit in a 32-bit integer.
    ### Related Topics diff --git a/problems/pyramid-transition-matrix/README.md b/problems/pyramid-transition-matrix/README.md index e40f94020..d34c72d79 100644 --- a/problems/pyramid-transition-matrix/README.md +++ b/problems/pyramid-transition-matrix/README.md @@ -21,39 +21,32 @@

     

    Example 1:

    - +
    -Input: bottom = "BCD", allowed = ["BCG","CDE","GEA","FFF"]
    +Input: bottom = "BCD", allowed = ["BCC","CDE","CEA","FFF"]
     Output: true
    -Explanation:
    -We can stack the pyramid like this:
    -    A
    -   / \
    -  G   E
    - / \ / \
    -B   C   D
    -
    -We are allowed to place G on top of B and C because BCG is an allowed triple.  Similarly, we can place E on top of C and D, then A on top of G and E.
    +Explanation: The allowed stacks are shown on the right.
    +Starting from the bottom (level 3), we can build "CE" on level 2 and then build "E" on level 1.
     

    Example 2:

    - +
    -Input: bottom = "AABA", allowed = ["AAA","AAB","ABA","ABB","BAC"]
    +Input: bottom = "AAAA", allowed = ["AAB","AAC","BCD","BBE","DEF"]
     Output: false
    -Explanation:
    -We cannot stack the pyramid to the top.
    -Note that there could be allowed triples (A, B, C) and (A, B, D) with C != D.
    +Explanation: The allowed stacks are shown on the right.
    +Starting from the bottom (level 4), there are multiple ways to build level 3 but trying all the possibilites, you will get always stuck before building level 1.
     

     

    Constraints:

      -
    • 2 <= bottom.length <= 8
    • -
    • 0 <= allowed.length <= 200
    • +
    • 2 <= bottom.length <= 6
    • +
    • 0 <= allowed.length <= 216
    • allowed[i].length == 3
    • -
    • The letters in all input strings are from the set {'A', 'B', 'C', 'D', 'E', 'F', 'G'}.
    • +
    • The letters in all input strings are from the set {'A', 'B', 'C', 'D', 'E', 'F'}.
    • +
    • All the values of allowed are unique.
    ### Related Topics diff --git a/problems/range-addition-ii/README.md b/problems/range-addition-ii/README.md index 95f4f4aa2..957bdcd7f 100644 --- a/problems/range-addition-ii/README.md +++ b/problems/range-addition-ii/README.md @@ -43,7 +43,7 @@
    • 1 <= m, n <= 4 * 104
    • -
    • 1 <= ops.length <= 104
    • +
    • 0 <= ops.length <= 104
    • ops[i].length == 2
    • 1 <= ai <= m
    • 1 <= bi <= n
    • diff --git a/problems/range-module/README.md b/problems/range-module/README.md index b75b4a945..bbe8355dc 100644 --- a/problems/range-module/README.md +++ b/problems/range-module/README.md @@ -20,13 +20,7 @@
      • RangeModule() Initializes the object of the data structure.
      • void addRange(int left, int right) Adds the half-open interval [left, right), tracking every real number in that interval. Adding an interval that partially overlaps with currently tracked numbers should add any numbers in the interval [left, right) that are not already tracked.
      • -
      - -
      • boolean queryRange(int left, int right) Returns true if every real number in the interval [left, right) is currently being tracked, and false otherwise.
      • -
      - -
      • void removeRange(int left, int right) Stops tracking every real number currently being tracked in the half-open interval [left, right).
      diff --git a/problems/range-sum-query-2d-immutable/README.md b/problems/range-sum-query-2d-immutable/README.md index 00f1ce3f4..9b87031fe 100644 --- a/problems/range-sum-query-2d-immutable/README.md +++ b/problems/range-sum-query-2d-immutable/README.md @@ -13,9 +13,9 @@

      Given a 2D matrix matrix, handle multiple queries of the following type:

      -
        +
        • Calculate the sum of the elements of matrix inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).
        • -
      +

    Implement the NumMatrix class:

    diff --git a/problems/recover-binary-search-tree/README.md b/problems/recover-binary-search-tree/README.md index 9d10760b4..d8cfb5216 100644 --- a/problems/recover-binary-search-tree/README.md +++ b/problems/recover-binary-search-tree/README.md @@ -11,9 +11,7 @@ ## [99. Recover Binary Search Tree (Medium)](https://leetcode.com/problems/recover-binary-search-tree "恢复二叉搜索树") -

    You are given the root of a binary search tree (BST), where exactly two nodes of the tree were swapped by mistake. Recover the tree without changing its structure.

    - -

    Follow up: A solution using O(n) space is pretty straight forward. Could you devise a constant space solution?

    +

    You are given the root of a binary search tree (BST), where the values of exactly two nodes of the tree were swapped by mistake. Recover the tree without changing its structure.

     

    Example 1:

    @@ -40,6 +38,9 @@
  • -231 <= Node.val <= 231 - 1
  • +

     

    +Follow up: A solution using O(n) space is pretty straight-forward. Could you devise a constant O(1) space solution? + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/reduce-array-size-to-the-half/README.md b/problems/reduce-array-size-to-the-half/README.md index 9bd2bdd1e..a5ff65836 100644 --- a/problems/reduce-array-size-to-the-half/README.md +++ b/problems/reduce-array-size-to-the-half/README.md @@ -65,9 +65,9 @@ Choosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/relative-sort-array/README.md b/problems/relative-sort-array/README.md index cdc2c3d74..fec67f6ce 100644 --- a/problems/relative-sort-array/README.md +++ b/problems/relative-sort-array/README.md @@ -13,13 +13,23 @@

    Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1.

    -

    Sort the elements of arr1 such that the relative ordering of items in arr1 are the same as in arr2.  Elements that don't appear in arr2 should be placed at the end of arr1 in ascending order.

    +

    Sort the elements of arr1 such that the relative ordering of items in arr1 are the same as in arr2. Elements that do not appear in arr2 should be placed at the end of arr1 in ascending order.

     

    Example 1:

    -
    Input: arr1 = [2,3,1,3,2,4,6,7,9,2,19], arr2 = [2,1,4,3,9,6]
    +
    +
    +Input: arr1 = [2,3,1,3,2,4,6,7,9,2,19], arr2 = [2,1,4,3,9,6]
     Output: [2,2,2,1,4,3,3,9,6,7,19]
     
    + +

    Example 2:

    + +
    +Input: arr1 = [28,6,22,8,44,17], arr2 = [22,28,8,6]
    +Output: [22,28,8,6,17,44]
    +
    +

     

    Constraints:

    diff --git a/problems/remove-covered-intervals/README.md b/problems/remove-covered-intervals/README.md index 3bfa0205d..8f1df2a61 100644 --- a/problems/remove-covered-intervals/README.md +++ b/problems/remove-covered-intervals/README.md @@ -11,11 +11,11 @@ ## [1288. Remove Covered Intervals (Medium)](https://leetcode.com/problems/remove-covered-intervals "删除被覆盖区间") -

    Given a list of intervals, remove all intervals that are covered by another interval in the list.

    +

    Given an array intervals where intervals[i] = [li, ri] represent the interval [li, ri), remove all intervals that are covered by another interval in the list.

    -

    Interval [a,b) is covered by interval [c,d) if and only if c <= a and b <= d.

    +

    The interval [a, b) is covered by the interval [c, d) if and only if c <= a and b <= d.

    -

    After doing so, return the number of remaining intervals.

    +

    Return the number of remaining intervals.

     

    Example 1:

    @@ -60,8 +60,8 @@
    • 1 <= intervals.length <= 1000
    • intervals[i].length == 2
    • -
    • 0 <= intervals[i][0] < intervals[i][1] <= 10^5
    • -
    • All the intervals are unique.
    • +
    • 0 <= li <= ri <= 105
    • +
    • All the given intervals are unique.
    ### Related Topics diff --git a/problems/remove-stones-to-minimize-the-total/README.md b/problems/remove-stones-to-minimize-the-total/README.md new file mode 100644 index 000000000..41af10a76 --- /dev/null +++ b/problems/remove-stones-to-minimize-the-total/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../check-if-string-is-a-prefix-of-array "Check If String Is a Prefix of Array") +                 +[Next >](../minimum-number-of-swaps-to-make-the-string-balanced "Minimum Number of Swaps to Make the String Balanced") + +## [1962. Remove Stones to Minimize the Total (Medium)](https://leetcode.com/problems/remove-stones-to-minimize-the-total "移除石子使总数最小") + +

    You are given a 0-indexed integer array piles, where piles[i] represents the number of stones in the ith pile, and an integer k. You should apply the following operation exactly k times:

    + +
      +
    • Choose any piles[i] and remove floor(piles[i] / 2) stones from it.
    • +
    + +

    Notice that you can apply the operation on the same pile more than once.

    + +

    Return the minimum possible total number of stones remaining after applying the k operations.

    + +

    floor(x) is the greatest integer that is smaller than or equal to x (i.e., rounds x down).

    + +

     

    +

    Example 1:

    + +
    +Input: piles = [5,4,9], k = 2
    +Output: 12
    +Explanation: Steps of a possible scenario are:
    +- Apply the operation on pile 2. The resulting piles are [5,4,5].
    +- Apply the operation on pile 0. The resulting piles are [3,4,5].
    +The total number of stones in [3,4,5] is 12.
    +
    + +

    Example 2:

    + +
    +Input: piles = [4,3,6,7], k = 3
    +Output: 12
    +Explanation: Steps of a possible scenario are:
    +- Apply the operation on pile 2. The resulting piles are [4,3,3,7].
    +- Apply the operation on pile 3. The resulting piles are [4,3,3,4].
    +- Apply the operation on pile 0. The resulting piles are [2,3,3,4].
    +The total number of stones in [2,3,3,4] is 12.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= piles.length <= 105
    • +
    • 1 <= piles[i] <= 104
    • +
    • 1 <= k <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +Choose the pile with the maximum number of stones each time. +
    + +
    +Hint 2 +Use a data structure that helps you find the mentioned pile each time efficiently. +
    + +
    +Hint 3 +One such data structure is a Priority Queue. +
    diff --git a/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md b/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md index 21f99a538..26339c459 100644 --- a/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md +++ b/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md @@ -11,11 +11,11 @@ ## [1576. Replace All ?'s to Avoid Consecutive Repeating Characters (Easy)](https://leetcode.com/problems/replace-all-s-to-avoid-consecutive-repeating-characters "替换所有的问号") -

    Given a string s containing only lower case English letters and the '?' character, convert all the '?' characters into lower case letters such that the final string does not contain any consecutive repeating characters. You cannot modify the non '?' characters.

    +

    Given a string s containing only lowercase English letters and the '?' character, convert all the '?' characters into lowercase letters such that the final string does not contain any consecutive repeating characters. You cannot modify the non '?' characters.

    -

    It is guaranteed that there are no consecutive repeating characters in the given string except for '?'.

    +

    It is guaranteed that there are no consecutive repeating characters in the given string except for '?'.

    -

    Return the final string after all the conversions (possibly zero) have been made. If there is more than one solution, return any of them. It can be shown that an answer is always possible with the given constraints.

    +

    Return the final string after all the conversions (possibly zero) have been made. If there is more than one solution, return any of them. It can be shown that an answer is always possible with the given constraints.

     

    Example 1:

    @@ -51,8 +51,8 @@

    Constraints:

      -
    • 1 <= s.length <= 100
    • -
    • s contains only lower case English letters and '?'.
    • +
    • 1 <= s.length <= 100
    • +
    • s consist of lowercase English letters and '?'.
    ### Related Topics diff --git a/problems/reverse-only-letters/README.md b/problems/reverse-only-letters/README.md index b96d23220..ee75bb83f 100644 --- a/problems/reverse-only-letters/README.md +++ b/problems/reverse-only-letters/README.md @@ -11,57 +11,34 @@ ## [917. Reverse Only Letters (Easy)](https://leetcode.com/problems/reverse-only-letters "仅仅反转字母") -

    Given a string s, return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their positions.

    +

    Given a string s, reverse the string according to the following rules:

    -

     

    +
      +
    • All the characters that are not English letters remain in the same position.
    • +
    • All the English letters (lowercase or uppercase) should be reversed.
    • +
    -
    -
    -
    -
      -
    -
    -
    -
    +

    Return s after reversing it.

    -
    +

     

    Example 1:

    - -
    -Input: s = "ab-cd"
    -Output: "dc-ba"
    -
    - -
    -

    Example 2:

    - -
    -Input: s = "a-bC-dEf-ghIj"
    -Output: "j-Ih-gfE-dCba"
    +
    Input: s = "ab-cd"
    +Output: "dc-ba"
    +

    Example 2:

    +
    Input: s = "a-bC-dEf-ghIj"
    +Output: "j-Ih-gfE-dCba"
    +

    Example 3:

    +
    Input: s = "Test1ng-Leet=code-Q!"
    +Output: "Qedo1ct-eeLg=ntse-T!"
     
    - -
    -

    Example 3:

    - -
    -Input: s = "Test1ng-Leet=code-Q!"
    -Output: "Qedo1ct-eeLg=ntse-T!"
    -
    -

     

    +

    Constraints:

    -
    -

    Note:

    - -
      -
    1. s.length <= 100
    2. -
    3. 33 <= s[i].ASCIIcode <= 122 
    4. -
    5. s doesn't contain \ or "
    6. -
    -
    -
    -
    -
    +
      +
    • 1 <= s.length <= 100
    • +
    • s consists of characters with ASCII values in the range [33, 122].
    • +
    • s does not contain '\"' or '\\'.
    • +
    ### Related Topics [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/robot-return-to-origin/README.md b/problems/robot-return-to-origin/README.md index 5228217a6..c52e00567 100644 --- a/problems/robot-return-to-origin/README.md +++ b/problems/robot-return-to-origin/README.md @@ -11,11 +11,13 @@ ## [657. Robot Return to Origin (Easy)](https://leetcode.com/problems/robot-return-to-origin "机器人能否返回原点") -

    There is a robot starting at position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0) after it completes its moves.

    +

    There is a robot starting at the position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0) after it completes its moves.

    -

    The move sequence is represented by a string, and the character moves[i] represents its ith move. Valid moves are R (right), L (left), U (up), and D (down). If the robot returns to the origin after it finishes all of its moves, return true. Otherwise, return false.

    +

    You are given a string moves that represents the move sequence of the robot where moves[i] represents its ith move. Valid moves are 'R' (right), 'L' (left), 'U' (up), and 'D' (down).

    -

    Note: The way that the robot is "facing" is irrelevant. "R" will always make the robot move to the right once, "L" will always make it move left, etc. Also, assume that the magnitude of the robot's movement is the same for each move.

    +

    Return true if the robot returns to the origin after it finishes all of its moves, or false otherwise.

    + +

    Note: The way that the robot is "facing" is irrelevant. 'R' will always make the robot move to the right once, 'L' will always make it move left, etc. Also, assume that the magnitude of the robot's movement is the same for each move.

     

    Example 1:

    diff --git a/problems/rotate-list/README.md b/problems/rotate-list/README.md index 3c11dc9dc..02544a322 100644 --- a/problems/rotate-list/README.md +++ b/problems/rotate-list/README.md @@ -15,14 +15,14 @@

     

    Example 1:

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

    Example 2:

    - +
     Input: head = [0,1,2], k = 4
     Output: [2,0,1]
    diff --git a/problems/satisfiability-of-equality-equations/README.md b/problems/satisfiability-of-equality-equations/README.md
    index 8f02fc549..a5c93aed6 100644
    --- a/problems/satisfiability-of-equality-equations/README.md
    +++ b/problems/satisfiability-of-equality-equations/README.md
    @@ -11,73 +11,60 @@
     
     ## [990. Satisfiability of Equality Equations (Medium)](https://leetcode.com/problems/satisfiability-of-equality-equations "等式方程的可满足性")
     
    -

    Given an array equations of strings that represent relationships between variables, each string equations[i] has length 4 and takes one of two different forms: "a==b" or "a!=b".  Here, a and b are lowercase letters (not necessarily different) that represent one-letter variable names.

    +

    You are given an array of strings equations that represent relationships between variables where each string equations[i] is of length 4 and takes one of two different forms: "xi==yi" or "xi!=yi".Here, xi and yi are lowercase letters (not necessarily different) that represent one-letter variable names.

    -

    Return true if and only if it is possible to assign integers to variable names so as to satisfy all the given equations.

    +

    Return true if it is possible to assign integers to variable names so as to satisfy all the given equations, or false otherwise.

     

    - -
      -
    - -

    Example 1:

    -Input: ["a==b","b!=a"]
    -Output: false
    -Explanation: If we assign say, a = 1 and b = 1, then the first equation is satisfied, but not the second.  There is no way to assign the variables to satisfy both equations.
    +Input: equations = ["a==b","b!=a"]
    +Output: false
    +Explanation: If we assign say, a = 1 and b = 1, then the first equation is satisfied, but not the second.
    +There is no way to assign the variables to satisfy both equations.
     
    -

    Example 2:

    -Input: ["b==a","a==b"]
    -Output: true
    -Explanation: We could assign a = 1 and b = 1 to satisfy both equations.
    +Input: equations = ["b==a","a==b"]
    +Output: true
    +Explanation: We could assign a = 1 and b = 1 to satisfy both equations.
     
    -

    Example 3:

    -Input: ["a==b","b==c","a==c"]
    -Output: true
    +Input: equations = ["a==b","b==c","a==c"]
    +Output: true
     
    -

    Example 4:

    -Input: ["a==b","b!=c","c==a"]
    -Output: false
    +Input: equations = ["a==b","b!=c","c==a"]
    +Output: false
     
    -

    Example 5:

    -Input: ["c==c","b==d","x!=z"]
    -Output: true
    +Input: equations = ["c==c","b==d","x!=z"]
    +Output: true
     

     

    +

    Constraints:

    -

    Note:

    - -
      +
      • 1 <= equations.length <= 500
      • equations[i].length == 4
      • -
      • equations[i][0] and equations[i][3] are lowercase letters
      • -
      • equations[i][1] is either '=' or '!'
      • -
      • equations[i][2] is '='
      • -
    -
    -
    -
    -
    -
    +
  • equations[i][0] is a lowercase letter.
  • +
  • equations[i][1] is either '=' or '!'.
  • +
  • equations[i][2] is '='.
  • +
  • equations[i][3] is a lowercase letter.
  • + ### Related Topics [[Union Find](../../tag/union-find/README.md)] diff --git a/problems/search-a-2d-matrix-ii/README.md b/problems/search-a-2d-matrix-ii/README.md index 2cc3e859c..a0df5c561 100644 --- a/problems/search-a-2d-matrix-ii/README.md +++ b/problems/search-a-2d-matrix-ii/README.md @@ -40,7 +40,7 @@
  • m == matrix.length
  • n == matrix[i].length
  • 1 <= n, m <= 300
  • -
  • -109 <= matix[i][j] <= 109
  • +
  • -109 <= matrix[i][j] <= 109
  • All the integers in each row are sorted in ascending order.
  • All the integers in each column are sorted in ascending order.
  • -109 <= target <= 109
  • diff --git a/problems/shortest-common-supersequence/README.md b/problems/shortest-common-supersequence/README.md index 9449b1ef7..1a5ac13e8 100644 --- a/problems/shortest-common-supersequence/README.md +++ b/problems/shortest-common-supersequence/README.md @@ -11,31 +11,36 @@ ## [1092. Shortest Common Supersequence (Hard)](https://leetcode.com/problems/shortest-common-supersequence "最短公共超序列") -

    Given two strings str1 and str2, return the shortest string that has both str1 and str2 as subsequences.  If multiple answers exist, you may return any of them.

    +

    Given two strings str1 and str2, return the shortest string that has both str1 and str2 as subsequences. If there are multiple valid strings, return any of them.

    -

    (A string S is a subsequence of string T if deleting some number of characters from T (possibly 0, and the characters are chosen anywhere from T) results in the string S.)

    +

    A string s is a subsequence of string t if deleting some number of characters from t (possibly 0) results in the string s.

     

    -

    Example 1:

    -Input: str1 = "abac", str2 = "cab"
    -Output: "cabac"
    -Explanation: 
    +Input: str1 = "abac", str2 = "cab"
    +Output: "cabac"
    +Explanation: 
     str1 = "abac" is a subsequence of "cabac" because we can delete the first "c".
     str2 = "cab" is a subsequence of "cabac" because we can delete the last "ac".
     The answer provided is the shortest such string that satisfies these properties.
     
    -

     

    +

    Example 2:

    + +
    +Input: str1 = "aaaaaaaa", str2 = "aaaaaaaa"
    +Output: "aaaaaaaa"
    +
    -

    Note:

    +

     

    +

    Constraints:

    -
      +
      • 1 <= str1.length, str2.length <= 1000
      • str1 and str2 consist of lowercase English letters.
      • -
    + ### Related Topics [[String](../../tag/string/README.md)] diff --git a/problems/shortest-distance-to-a-character/README.md b/problems/shortest-distance-to-a-character/README.md index c02b2d68d..1ae107496 100644 --- a/problems/shortest-distance-to-a-character/README.md +++ b/problems/shortest-distance-to-a-character/README.md @@ -23,7 +23,7 @@ Output: [3,2,1,0,1,0,0,1,2,2,1,0] Explanation: The character 'e' appears at indices 3, 5, 6, and 11 (0-indexed). The closest occurrence of 'e' for index 0 is at index 3, so the distance is abs(0 - 3) = 3. -The closest occurrence of 'e' for index 1 is at index 3, so the distance is abs(1 - 3) = 3. +The closest occurrence of 'e' for index 1 is at index 3, so the distance is abs(1 - 3) = 2. For index 4, there is a tie between the 'e' at index 3 and the 'e' at index 5, but the distance is still the same: abs(4 - 3) == abs(4 - 5) = 1. The closest occurrence of 'e' for index 8 is at index 6, so the distance is abs(8 - 6) = 2.
    diff --git a/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md b/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md index 4b5240fc3..fbd8b3633 100644 --- a/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md +++ b/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md @@ -11,9 +11,9 @@ ## [1293. Shortest Path in a Grid with Obstacles Elimination (Hard)](https://leetcode.com/problems/shortest-path-in-a-grid-with-obstacles-elimination "网格中的最短路径") -

    Given a m * n grid, where each cell is either 0 (empty) or 1 (obstacle). In one step, you can move up, down, left or right from and to an empty cell.

    +

    You are given an m x n integer matrix grid where each cell is either 0 (empty) or 1 (obstacle). You can move up, down, left, or right from and to an empty cell in one step.

    -

    Return the minimum number of steps to walk from the upper left corner (0, 0) to the lower right corner (m-1, n-1) given that you can eliminate at most k obstacles. If it is not possible to find such walk return -1.

    +

    Return the minimum number of steps to walk from the upper left corner (0, 0) to the lower right corner (m - 1, n - 1) given that you can eliminate at most k obstacles. If it is not possible to find such walk return -1.

     

    Example 1:

    @@ -33,8 +33,6 @@ k = 1 The shortest path with one obstacle elimination at position (3,2) is 6. Such path is (0,0) -> (0,1) -> (0,2) -> (1,2) -> (2,2) -> (3,2) -> (4,2).
    -

     

    -

    Example 2:

    @@ -53,12 +51,12 @@ k = 1
     

    Constraints:

      -
    • grid.length == m
    • -
    • grid[0].length == n
    • +
    • m == grid.length
    • +
    • n == grid[i].length
    • 1 <= m, n <= 40
    • -
    • 1 <= k <= m*n
    • +
    • 1 <= k <= m * n
    • grid[i][j] == 0 or 1
    • -
    • grid[0][0] == grid[m-1][n-1] == 0
    • +
    • grid[0][0] == grid[m - 1][n - 1] == 0
    ### Related Topics diff --git a/problems/shuffle-an-array/README.md b/problems/shuffle-an-array/README.md index 88c5dd8b1..9ac2b877c 100644 --- a/problems/shuffle-an-array/README.md +++ b/problems/shuffle-an-array/README.md @@ -16,7 +16,7 @@

    Implement the Solution class:

      -
    • Solution(int[] nums) Initializes the object with the integer array nums.
    • +
    • Solution(int[] nums) Initializes the object with the integer array nums.
    • int[] reset() Resets the array to its original configuration and returns it.
    • int[] shuffle() Returns a random shuffling of the array.
    diff --git a/problems/smallest-string-starting-from-leaf/README.md b/problems/smallest-string-starting-from-leaf/README.md index 0aad28275..43b20a40a 100644 --- a/problems/smallest-string-starting-from-leaf/README.md +++ b/problems/smallest-string-starting-from-leaf/README.md @@ -11,62 +11,47 @@ ## [988. Smallest String Starting From Leaf (Medium)](https://leetcode.com/problems/smallest-string-starting-from-leaf "从叶结点开始的最小字符串") -

    Given the root of a binary tree, each node has a value from 0 to 25 representing the letters 'a' to 'z': a value of 0 represents 'a', a value of 1 represents 'b', and so on.

    +

    You are given the root of a binary tree where each node has a value in the range [0, 25] representing the letters 'a' to 'z'.

    -

    Find the lexicographically smallest string that starts at a leaf of this tree and ends at the root.

    +

    Return the lexicographically smallest string that starts at a leaf of this tree and ends at the root.

    -

    (As a reminder, any shorter prefix of a string is lexicographically smaller: for example, "ab" is lexicographically smaller than "aba".  A leaf of a node is a node that has no children.)

    +

    As a reminder, any shorter prefix of a string is lexicographically smaller.

    -
    -
    -

     

    +
      +
    • For example, "ab" is lexicographically smaller than "aba".
    • +
    -
      -
    -
    -
    +

    A leaf of a node is a node that has no children.

    -
    +

     

    Example 1:

    - -

    - +
    -Input: [0,1,2,3,4,3,4]
    -Output: "dba"
    +Input: root = [0,1,2,3,4,3,4]
    +Output: "dba"
     
    -

    Example 2:

    - -

    - +
    -Input: [25,1,3,1,3,0,2]
    -Output: "adz"
    +Input: root = [25,1,3,1,3,0,2]
    +Output: "adz"
     
    -

    Example 3:

    - -

    - +
    -Input: [2,2,1,null,1,0,null,0]
    -Output: "abc"
    +Input: root = [2,2,1,null,1,0,null,0]
    +Output: "abc"
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. The number of nodes in the given tree will be between 1 and 8500.
    2. -
    3. Each node in the tree will have a value between 0 and 25.
    4. -
    -
    -
    -
    +
      +
    • The number of nodes in the tree is in the range [1, 8500].
    • +
    • 0 <= Node.val <= 25
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/stone-game/README.md b/problems/stone-game/README.md index f0ffae5da..111b11a47 100644 --- a/problems/stone-game/README.md +++ b/problems/stone-game/README.md @@ -11,13 +11,13 @@ ## [877. Stone Game (Medium)](https://leetcode.com/problems/stone-game "石子游戏") -

    Alex and Lee play a game with piles of stones.  There are an even number of piles arranged in a row, and each pile has a positive integer number of stones piles[i].

    +

    Alice and Bob play a game with piles of stones. There are an even number of piles arranged in a row, and each pile has a positive integer number of stones piles[i].

    -

    The objective of the game is to end with the most stones.  The total number of stones is odd, so there are no ties.

    +

    The objective of the game is to end with the most stones. The total number of stones across all the piles is odd, so there are no ties.

    -

    Alex and Lee take turns, with Alex starting first.  Each turn, a player takes the entire pile of stones from either the beginning or the end of the row.  This continues until there are no more piles left, at which point the person with the most stones wins.

    +

    Alice and Bob take turns, with Alice starting first. Each turn, a player takes the entire pile of stones either from the beginning or from the end of the row. This continues until there are no more piles left, at which point the person with the most stones wins.

    -

    Assuming Alex and Lee play optimally, return True if and only if Alex wins the game.

    +

    Assuming Alice and Bob play optimally, return true if Alice wins the game, or false if Bob wins.

     

    Example 1:

    @@ -25,12 +25,19 @@
     Input: piles = [5,3,4,5]
     Output: true
    -Explanation: 
    -Alex starts first, and can only take the first 5 or the last 5.
    -Say he takes the first 5, so that the row becomes [3, 4, 5].
    -If Lee takes 3, then the board is [4, 5], and Alex takes 5 to win with 10 points.
    -If Lee takes the last 5, then the board is [3, 4], and Alex takes 4 to win with 9 points.
    -This demonstrated that taking the first 5 was a winning move for Alex, so we return true.
    +Explanation: 
    +Alice starts first, and can only take the first 5 or the last 5.
    +Say she takes the first 5, so that the row becomes [3, 4, 5].
    +If Bob takes 3, then the board is [4, 5], and Alice takes 5 to win with 10 points.
    +If Bob takes the last 5, then the board is [3, 4], and Alice takes 4 to win with 9 points.
    +This demonstrated that taking the first 5 was a winning move for Alice, so we return true.
    +
    + +

    Example 2:

    + +
    +Input: piles = [3,7,2,3]
    +Output: true
     

     

    @@ -38,9 +45,9 @@ This demonstrated that taking the first 5 was a winning move for Alex, so we ret
    • 2 <= piles.length <= 500
    • -
    • piles.length is even.
    • +
    • piles.length is even.
    • 1 <= piles[i] <= 500
    • -
    • sum(piles) is odd.
    • +
    • sum(piles[i]) is odd.
    ### Related Topics diff --git a/problems/stream-of-characters/README.md b/problems/stream-of-characters/README.md index 314c6eb67..1ed4f85dc 100644 --- a/problems/stream-of-characters/README.md +++ b/problems/stream-of-characters/README.md @@ -11,43 +11,52 @@ ## [1032. Stream of Characters (Hard)](https://leetcode.com/problems/stream-of-characters "字符流") -

    Implement the StreamChecker class as follows:

    +

    Design an algorithm that accepts a stream of characters and checks if a suffix of these characters is a string of a given array of strings words.

    + +

    For example, if words = ["abc", "xyz"] and the stream added the four characters (one by one) 'a', 'x', 'y', and 'z', your algorithm should detect that the suffix "xyz" of the characters "axyz" matches "xyz" from words.

    + +

    Implement the StreamChecker class:

      -
    • StreamChecker(words): Constructor, init the data structure with the given words.
    • -
    • query(letter): returns true if and only if for some k >= 1, the last k characters queried (in order from oldest to newest, including this letter just queried) spell one of the words in the given list.
    • +
    • StreamChecker(String[] words) Initializes the object with the strings array words.
    • +
    • boolean query(char letter) Accepts a new character from the stream and returns true if any non-empty suffix from the stream forms a word that is in words.

     

    - -

    Example:

    +

    Example 1:

    -StreamChecker streamChecker = new StreamChecker(["cd","f","kl"]); // init the dictionary.
    -streamChecker.query('a');          // return false
    -streamChecker.query('b');          // return false
    -streamChecker.query('c');          // return false
    -streamChecker.query('d');          // return true, because 'cd' is in the wordlist
    -streamChecker.query('e');          // return false
    -streamChecker.query('f');          // return true, because 'f' is in the wordlist
    -streamChecker.query('g');          // return false
    -streamChecker.query('h');          // return false
    -streamChecker.query('i');          // return false
    -streamChecker.query('j');          // return false
    -streamChecker.query('k');          // return false
    -streamChecker.query('l');          // return true, because 'kl' is in the wordlist
    +Input
    +["StreamChecker", "query", "query", "query", "query", "query", "query", "query", "query", "query", "query", "query", "query"]
    +[[["cd", "f", "kl"]], ["a"], ["b"], ["c"], ["d"], ["e"], ["f"], ["g"], ["h"], ["i"], ["j"], ["k"], ["l"]]
    +Output
    +[null, false, false, false, true, false, true, false, false, false, false, false, true]
    +
    +Explanation
    +StreamChecker streamChecker = new StreamChecker(["cd", "f", "kl"]);
    +streamChecker.query("a"); // return False
    +streamChecker.query("b"); // return False
    +streamChecker.query("c"); // return False
    +streamChecker.query("d"); // return True, because 'cd' is in the wordlist
    +streamChecker.query("e"); // return False
    +streamChecker.query("f"); // return True, because 'f' is in the wordlist
    +streamChecker.query("g"); // return False
    +streamChecker.query("h"); // return False
    +streamChecker.query("i"); // return False
    +streamChecker.query("j"); // return False
    +streamChecker.query("k"); // return False
    +streamChecker.query("l"); // return True, because 'kl' is in the wordlist
     

     

    - -

    Note:

    +

    Constraints:

    • 1 <= words.length <= 2000
    • 1 <= words[i].length <= 2000
    • -
    • Words will only consist of lowercase English letters.
    • -
    • Queries will only consist of lowercase English letters.
    • -
    • The number of queries is at most 40000.
    • +
    • words[i] consists of lowercase English letters.
    • +
    • letter is a lowercase English letter.
    • +
    • At most 4 * 104 calls will be made to query.
    ### Related Topics diff --git a/problems/string-compression/README.md b/problems/string-compression/README.md index 1b8dde388..5c788f044 100644 --- a/problems/string-compression/README.md +++ b/problems/string-compression/README.md @@ -16,11 +16,11 @@

    Begin with an empty string s. For each group of consecutive repeating characters in chars:

      -
    • If the group's length is 1, append the character to s.
    • +
    • If the group's length is 1, append the character to s.
    • Otherwise, append the character followed by the group's length.
    -

    The compressed string s should not be returned separately, but instead be stored in the input character array chars. Note that group lengths that are 10 or longer will be split into multiple characters in chars.

    +

    The compressed string s should not be returned separately, but instead, be stored in the input character array chars. Note that group lengths that are 10 or longer will be split into multiple characters in chars.

    After you are done modifying the input array, return the new length of the array.

    You must write an algorithm that uses only constant extra space. @@ -61,7 +61,7 @@ You must write an algorithm that uses only constant extra space.
    • 1 <= chars.length <= 2000
    • -
    • chars[i] is a lower-case English letter, upper-case English letter, digit, or symbol.
    • +
    • chars[i] is a lowercase English letter, uppercase English letter, digit, or symbol.
    ### Related Topics diff --git a/problems/subarray-sums-divisible-by-k/README.md b/problems/subarray-sums-divisible-by-k/README.md index 358aecf01..15e7339d0 100644 --- a/problems/subarray-sums-divisible-by-k/README.md +++ b/problems/subarray-sums-divisible-by-k/README.md @@ -11,30 +11,35 @@ ## [974. Subarray Sums Divisible by K (Medium)](https://leetcode.com/problems/subarray-sums-divisible-by-k "和可被 K 整除的子数组") -

    Given an array nums of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by k.

    +

    Given an integer array nums and an integer k, return the number of non-empty subarrays that have a sum divisible by k.

    -

     

    +

    A subarray is a contiguous part of an array.

    -
    +

     

    Example 1:

    -Input: nums = [4,5,0,-2,-3,1], k = 5
    -Output: 7
    -Explanation: There are 7 subarrays with a sum divisible by k = 5:
    +Input: nums = [4,5,0,-2,-3,1], k = 5
    +Output: 7
    +Explanation: There are 7 subarrays with a sum divisible by k = 5:
     [4, 5, 0, -2, -3, 1], [5], [5, 0], [5, 0, -2, -3], [0], [0, -2, -3], [-2, -3]
     
    -

     

    +

    Example 2:

    -

    Note:

    +
    +Input: nums = [5], k = 9
    +Output: 0
    +
    + +

     

    +

    Constraints:

    -
      -
    1. 1 <= nums.length <= 30000
    2. -
    3. -10000 <= nums[i] <= 10000
    4. -
    5. 2 <= k <= 10000
    6. -
    -
    +
      +
    • 1 <= nums.length <= 3 * 104
    • +
    • -104 <= nums[i] <= 104
    • +
    • 2 <= k <= 104
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/subarrays-with-k-different-integers/README.md b/problems/subarrays-with-k-different-integers/README.md index 9baba425b..b3ee2f146 100644 --- a/problems/subarrays-with-k-different-integers/README.md +++ b/problems/subarrays-with-k-different-integers/README.md @@ -11,39 +11,40 @@ ## [992. Subarrays with K Different Integers (Hard)](https://leetcode.com/problems/subarrays-with-k-different-integers "K 个不同整数的子数组") -

    Given an array nums of positive integers, call a (contiguous, not necessarily distinct) subarray of nums good if the number of different integers in that subarray is exactly k.

    +

    Given an integer array nums and an integer k, return the number of good subarrays of nums.

    -

    (For example, [1,2,3,1,2] has 3 different integers: 1, 2, and 3.)

    +

    A good array is an array where the number of different integers in that array is exactly k.

    -

    Return the number of good subarrays of nums.

    +
      +
    • For example, [1,2,3,1,2] has 3 different integers: 1, 2, and 3.
    • +
    -

     

    +

    A subarray is a contiguous part of an array.

    +

     

    Example 1:

    -Input: nums = [1,2,1,2,3], k = 2
    -Output: 7
    -Explanation: Subarrays formed with exactly 2 different integers: [1,2], [2,1], [1,2], [2,3], [1,2,1], [2,1,2], [1,2,1,2].
    +Input: nums = [1,2,1,2,3], k = 2
    +Output: 7
    +Explanation: Subarrays formed with exactly 2 different integers: [1,2], [2,1], [1,2], [2,3], [1,2,1], [2,1,2], [1,2,1,2]
     

    Example 2:

    -Input: nums = [1,2,1,3,4], k = 3
    -Output: 3
    -Explanation: Subarrays formed with exactly 3 different integers: [1,2,1,3], [2,1,3], [1,3,4].
    +Input: nums = [1,2,1,3,4], k = 3
    +Output: 3
    +Explanation: Subarrays formed with exactly 3 different integers: [1,2,1,3], [2,1,3], [1,3,4].
     

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= nums.length <= 20000
    2. -
    3. 1 <= nums[i] <= nums.length
    4. -
    5. 1 <= k <= nums.length
    6. -
    +
      +
    • 1 <= nums.length <= 2 * 104
    • +
    • 1 <= nums[i], k <= nums.length
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/subdomain-visit-count/README.md b/problems/subdomain-visit-count/README.md index 21ff1974f..846e45858 100644 --- a/problems/subdomain-visit-count/README.md +++ b/problems/subdomain-visit-count/README.md @@ -9,44 +9,46 @@                  [Next >](../largest-triangle-area "Largest Triangle Area") -## [811. Subdomain Visit Count (Easy)](https://leetcode.com/problems/subdomain-visit-count "子域名访问计数") +## [811. Subdomain Visit Count (Medium)](https://leetcode.com/problems/subdomain-visit-count "子域名访问计数") -

    A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com", and at the lowest level, "discuss.leetcode.com". When we visit a domain like "discuss.leetcode.com", we will also visit the parent domains "leetcode.com" and "com" implicitly.

    +

    A website domain "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com" and at the lowest level, "discuss.leetcode.com". When we visit a domain like "discuss.leetcode.com", we will also visit the parent domains "leetcode.com" and "com" implicitly.

    -

    Now, call a "count-paired domain" to be a count (representing the number of visits this domain received), followed by a space, followed by the address. An example of a count-paired domain might be "9001 discuss.leetcode.com".

    +

    A count-paired domain is a domain that has one of the two formats "rep d1.d2.d3" or "rep d1.d2" where rep is the number of visits to the domain and d1.d2.d3 is the domain itself.

    -

    We are given a list cpdomains of count-paired domains. We would like a list of count-paired domains, (in the same format as the input, and in any order), that explicitly counts the number of visits to each subdomain.

    +
      +
    • For example, "9001 discuss.leetcode.com" is a count-paired domain that indicates that discuss.leetcode.com was visited 9001 times.
    • +
    -
    -Example 1:
    -Input: 
    -["9001 discuss.leetcode.com"]
    -Output: 
    -["9001 discuss.leetcode.com", "9001 leetcode.com", "9001 com"]
    -Explanation: 
    -We only have one website domain: "discuss.leetcode.com". As discussed above, the subdomain "leetcode.com" and "com" will also be visited. So they will all be visited 9001 times.
    +

    Given an array of count-paired domains cpdomains, return an array of the count-paired domains of each subdomain in the input. You may return the answer in any order.

    -
    +

     

    +

    Example 1:

    -Example 2:
    -Input: 
    -["900 google.mail.com", "50 yahoo.com", "1 intel.mail.com", "5 wiki.org"]
    -Output: 
    -["901 mail.com","50 yahoo.com","900 google.mail.com","5 wiki.org","5 org","1 intel.mail.com","951 com"]
    -Explanation: 
    -We will visit "google.mail.com" 900 times, "yahoo.com" 50 times, "intel.mail.com" once and "wiki.org" 5 times. For the subdomains, we will visit "mail.com" 900 + 1 = 901 times, "com" 900 + 50 + 1 = 951 times, and "org" 5 times.
    +Input: cpdomains = ["9001 discuss.leetcode.com"]
    +Output: ["9001 leetcode.com","9001 discuss.leetcode.com","9001 com"]
    +Explanation: We only have one website domain: "discuss.leetcode.com".
    +As discussed above, the subdomain "leetcode.com" and "com" will also be visited. So they will all be visited 9001 times.
    +
    + +

    Example 2:

    +
    +Input: cpdomains = ["900 google.mail.com", "50 yahoo.com", "1 intel.mail.com", "5 wiki.org"]
    +Output: ["901 mail.com","50 yahoo.com","900 google.mail.com","5 wiki.org","5 org","1 intel.mail.com","951 com"]
    +Explanation: We will visit "google.mail.com" 900 times, "yahoo.com" 50 times, "intel.mail.com" once and "wiki.org" 5 times.
    +For the subdomains, we will visit "mail.com" 900 + 1 = 901 times, "com" 900 + 50 + 1 = 951 times, and "org" 5 times.
     
    -

    Notes:

    +

     

    +

    Constraints:

      -
    • The length of cpdomains will not exceed 100
    • -
    • The length of each domain name will not exceed 100.
    • -
    • Each address will have either 1 or 2 "." characters.
    • -
    • The input count in any count-paired domain will not exceed 10000.
    • -
    • The answer output can be returned in any order.
    • +
    • 1 <= cpdomain.length <= 100
    • +
    • 1 <= cpdomain[i].length <= 100
    • +
    • cpdomain[i] follows either the "repi d1i.d2i.d3i" format or the "repi d1i.d2i" format.
    • +
    • repi is an integer in the range [1, 104].
    • +
    • d1i, d2i, and d3i consist of lowercase English letters.
    ### Related Topics diff --git a/problems/sudoku-solver/README.md b/problems/sudoku-solver/README.md index 34c89651e..beb8613ad 100644 --- a/problems/sudoku-solver/README.md +++ b/problems/sudoku-solver/README.md @@ -13,12 +13,12 @@

    Write a program to solve a Sudoku puzzle by filling the empty cells.

    -

    A sudoku solution must satisfy all of the following rules:

    +

    A sudoku solution must satisfy all of the following rules:

      -
    1. Each of the digits 1-9 must occur exactly once in each row.
    2. -
    3. Each of the digits 1-9 must occur exactly once in each column.
    4. -
    5. Each of the digits 1-9 must occur exactly once in each of the 9 3x3 sub-boxes of the grid.
    6. +
    7. Each of the digits 1-9 must occur exactly once in each row.
    8. +
    9. Each of the digits 1-9 must occur exactly once in each column.
    10. +
    11. Each of the digits 1-9 must occur exactly once in each of the 9 3x3 sub-boxes of the grid.

    The '.' character indicates empty cells.

    diff --git a/problems/sum-of-even-numbers-after-queries/README.md b/problems/sum-of-even-numbers-after-queries/README.md index 9ef74b88d..d10a592e5 100644 --- a/problems/sum-of-even-numbers-after-queries/README.md +++ b/problems/sum-of-even-numbers-after-queries/README.md @@ -9,42 +9,44 @@                  [Next >](../interval-list-intersections "Interval List Intersections") -## [985. Sum of Even Numbers After Queries (Easy)](https://leetcode.com/problems/sum-of-even-numbers-after-queries "查询后的偶数和") +## [985. Sum of Even Numbers After Queries (Medium)](https://leetcode.com/problems/sum-of-even-numbers-after-queries "查询后的偶数和") -

    We have an array nums of integers, and an array queries of queries.

    +

    You are given an integer array nums and an array queries where queries[i] = [vali, indexi].

    -

    For the i-th query val = queries[i][0], index = queries[i][1], we add val to nums[index].  Then, the answer to the i-th query is the sum of the even values of A.

    +

    For each query i, first, apply nums[indexi] = nums[indexi] + vali, then print the sum of the even values of nums.

    -

    (Here, the given index = queries[i][1] is a 0-based index, and each query permanently modifies the array nums.)

    - -

    Return the answer to all queries.  Your answer array should have answer[i] as the answer to the i-th query.

    +

    Return an integer array answer where answer[i] is the answer to the ith query.

     

    -

    Example 1:

    -Input: nums = [1,2,3,4], queries = [[1,0],[-3,1],[-4,0],[2,3]]
    -Output: [8,6,2,4]
    -Explanation: 
    -At the beginning, the array is [1,2,3,4].
    +Input: nums = [1,2,3,4], queries = [[1,0],[-3,1],[-4,0],[2,3]]
    +Output: [8,6,2,4]
    +Explanation: At the beginning, the array is [1,2,3,4].
     After adding 1 to nums[0], the array is [2,2,3,4], and the sum of even values is 2 + 2 + 4 = 8.
     After adding -3 to nums[1], the array is [2,-1,3,4], and the sum of even values is 2 + 4 = 6.
     After adding -4 to nums[0], the array is [-2,-1,3,4], and the sum of even values is -2 + 4 = 2.
     After adding 2 to nums[3], the array is [-2,-1,3,6], and the sum of even values is -2 + 6 = 4.
     
    -

     

    +

    Example 2:

    -

    Note:

    +
    +Input: nums = [1], queries = [[4,0]]
    +Output: [0]
    +
    -
      -
    1. 1 <= nums.length <= 10000
    2. -
    3. -10000 <= nums[i] <= 10000
    4. -
    5. 1 <= queries.length <= 10000
    6. -
    7. -10000 <= queries[i][0] <= 10000
    8. -
    9. 0 <= queries[i][1] < nums.length
    10. -
    +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 104
    • +
    • -104 <= nums[i] <= 104
    • +
    • 1 <= queries.length <= 104
    • +
    • -104 <= vali <= 104
    • +
    • 0 <= indexi < nums.length
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/sum-of-nodes-with-even-valued-grandparent/README.md b/problems/sum-of-nodes-with-even-valued-grandparent/README.md index 6048d8e67..2a0c7f7ed 100644 --- a/problems/sum-of-nodes-with-even-valued-grandparent/README.md +++ b/problems/sum-of-nodes-with-even-valued-grandparent/README.md @@ -11,27 +11,32 @@ ## [1315. Sum of Nodes with Even-Valued Grandparent (Medium)](https://leetcode.com/problems/sum-of-nodes-with-even-valued-grandparent "祖父节点值为偶数的节点和") -

    Given a binary tree, return the sum of values of nodes with even-valued grandparent.  (A grandparent of a node is the parent of its parent, if it exists.)

    +

    Given the root of a binary tree, return the sum of values of nodes with an even-valued grandparent. If there are no nodes with an even-valued grandparent, return 0.

    -

    If there are no nodes with an even-valued grandparent, return 0.

    +

    A grandparent of a node is the parent of its parent if it exists.

     

    Example 1:

    - -

    - +
     Input: root = [6,7,8,2,7,1,3,9,null,1,4,null,null,null,5]
     Output: 18
    -Explanation: The red nodes are the nodes with even-value grandparent while the blue nodes are the even-value grandparents.
    +Explanation: The red nodes are the nodes with even-value grandparent while the blue nodes are the even-value grandparents.
    +
    + +

    Example 2:

    + +
    +Input: root = [1]
    +Output: 0
     

     

    Constraints:

      -
    • The number of nodes in the tree is between 1 and 10^4.
    • -
    • The value of nodes is between 1 and 100.
    • +
    • The number of nodes in the tree is in the range [1, 104].
    • +
    • 1 <= Node.val <= 100
    ### Related Topics diff --git a/problems/third-maximum-number/README.md b/problems/third-maximum-number/README.md index a5e43960b..d7b315550 100644 --- a/problems/third-maximum-number/README.md +++ b/problems/third-maximum-number/README.md @@ -11,7 +11,7 @@ ## [414. Third Maximum Number (Easy)](https://leetcode.com/problems/third-maximum-number "第三大的数") -

    Given integer array nums, return the third maximum number in this array. If the third maximum does not exist, return the maximum number.

    +

    Given an integer array nums, return the third distinct maximum number in this array. If the third maximum does not exist, return the maximum number.

     

    Example 1:

    @@ -19,7 +19,10 @@
     Input: nums = [3,2,1]
     Output: 1
    -Explanation: The third maximum is 1.
    +Explanation:
    +The first distinct maximum is 3.
    +The second distinct maximum is 2.
    +The third distinct maximum is 1.
     

    Example 2:

    @@ -27,7 +30,10 @@
     Input: nums = [1,2]
     Output: 2
    -Explanation: The third maximum does not exist, so the maximum (2) is returned instead.
    +Explanation:
    +The first distinct maximum is 2.
    +The second distinct maximum is 1.
    +The third distinct maximum does not exist, so the maximum (2) is returned instead.
     

    Example 3:

    @@ -35,8 +41,10 @@
     Input: nums = [2,2,3,1]
     Output: 1
    -Explanation: Note that the third maximum here means the third maximum distinct number.
    -Both numbers with value 2 are both considered as second maximum.
    +Explanation:
    +The first distinct maximum is 3.
    +The second distinct maximum is 2 (both 2's are counted together since they have the same value).
    +The third distinct maximum is 1.
     

     

    diff --git a/problems/three-divisors/README.md b/problems/three-divisors/README.md index ad9fb6194..ba9064fd6 100644 --- a/problems/three-divisors/README.md +++ b/problems/three-divisors/README.md @@ -39,6 +39,9 @@
  • 1 <= n <= 104
  • +### Related Topics + [[Math](../../tag/math/README.md)] + ### Hints
    Hint 1 diff --git a/problems/tiling-a-rectangle-with-the-fewest-squares/README.md b/problems/tiling-a-rectangle-with-the-fewest-squares/README.md index 2491a536b..d7912de1a 100644 --- a/problems/tiling-a-rectangle-with-the-fewest-squares/README.md +++ b/problems/tiling-a-rectangle-with-the-fewest-squares/README.md @@ -11,7 +11,7 @@ ## [1240. Tiling a Rectangle with the Fewest Squares (Hard)](https://leetcode.com/problems/tiling-a-rectangle-with-the-fewest-squares "铺瓷砖") -

    Given a rectangle of size n x m, find the minimum number of integer-sided squares that tile the rectangle.

    +

    Given a rectangle of size n x m, return the minimum number of integer-sided squares that tile the rectangle.

     

    Example 1:

    @@ -47,8 +47,7 @@

    Constraints:

      -
    • 1 <= n <= 13
    • -
    • 1 <= m <= 13
    • +
    • 1 <= n, m <= 13
    ### Related Topics diff --git a/problems/top-k-frequent-words/README.md b/problems/top-k-frequent-words/README.md index db4cbf356..abcce3c55 100644 --- a/problems/top-k-frequent-words/README.md +++ b/problems/top-k-frequent-words/README.md @@ -11,39 +11,40 @@ ## [692. Top K Frequent Words (Medium)](https://leetcode.com/problems/top-k-frequent-words "前K个高频单词") -

    Given a non-empty list of words, return the k most frequent elements.

    -

    Your answer should be sorted by frequency from highest to lowest. If two words have the same frequency, then the word with the lower alphabetical order comes first.

    +

    Given an array of strings words and an integer k, return the k most frequent strings.

    + +

    Return the answer sorted by the frequency from highest to lowest. Sort the words with the same frequency by their lexicographical order.

    + +

     

    +

    Example 1:

    -

    Example 1:

    -Input: ["i", "love", "leetcode", "i", "love", "coding"], k = 2
    -Output: ["i", "love"]
    -Explanation: "i" and "love" are the two most frequent words.
    -    Note that "i" comes before "love" due to a lower alphabetical order.
    +Input: words = ["i","love","leetcode","i","love","coding"], k = 2
    +Output: ["i","love"]
    +Explanation: "i" and "love" are the two most frequent words.
    +Note that "i" comes before "love" due to a lower alphabetical order.
     
    -

    -

    Example 2:
    +

    Example 2:

    +
    -Input: ["the", "day", "is", "sunny", "the", "the", "the", "sunny", "is", "is"], k = 4
    -Output: ["the", "is", "sunny", "day"]
    -Explanation: "the", "is", "sunny" and "day" are the four most frequent words,
    -    with the number of occurrence being 4, 3, 2 and 1 respectively.
    +Input: words = ["the","day","is","sunny","the","the","the","sunny","is","is"], k = 4
    +Output: ["the","is","sunny","day"]
    +Explanation: "the", "is", "sunny" and "day" are the four most frequent words, with the number of occurrence being 4, 3, 2 and 1 respectively.
     
    -

    - -

    Note:
    -

      -
    1. You may assume k is always valid, 1 ≤ k ≤ number of unique elements.
    2. -
    3. Input words contain only lowercase letters.
    4. -
    -

    - -

    Follow up:
    -

      -
    1. Try to solve it in O(n log k) time and O(n) extra space.
    2. -
    -

    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 500
    • +
    • 1 <= words[i] <= 10
    • +
    • words[i] consists of lowercase English letters.
    • +
    • k is in the range [1, The number of unique words[i]]
    • +
    + +

     

    +

    Follow-up: Could you solve it in O(n log(k)) time and O(n) extra space?

    ### Related Topics [[Trie](../../tag/trie/README.md)] diff --git a/problems/trapping-rain-water/README.md b/problems/trapping-rain-water/README.md index 17ea35c4e..ea93f83c4 100644 --- a/problems/trapping-rain-water/README.md +++ b/problems/trapping-rain-water/README.md @@ -34,7 +34,7 @@
    • n == height.length
    • -
    • 0 <= n <= 3 * 104
    • +
    • 1 <= n <= 2 * 104
    • 0 <= height[i] <= 105
    diff --git a/problems/triples-with-bitwise-and-equal-to-zero/README.md b/problems/triples-with-bitwise-and-equal-to-zero/README.md index 70d948809..7b889765c 100644 --- a/problems/triples-with-bitwise-and-equal-to-zero/README.md +++ b/problems/triples-with-bitwise-and-equal-to-zero/README.md @@ -11,23 +11,24 @@ ## [982. Triples with Bitwise AND Equal To Zero (Hard)](https://leetcode.com/problems/triples-with-bitwise-and-equal-to-zero "按位与为零的三元组") -

    Given an array of integers nums, find the number of triples of indices (i, j, k) such that:

    +

    Given an integer array nums, return the number of AND triples.

    + +

    An AND triple is a triple of indices (i, j, k) such that:

    • 0 <= i < nums.length
    • 0 <= j < nums.length
    • 0 <= k < nums.length
    • -
    • nums[i] & nums[j] & nums[k] == 0, where & represents the bitwise-AND operator.
    • +
    • nums[i] & nums[j] & nums[k] == 0, where & represents the bitwise-AND operator.

     

    -

    Example 1:

    -Input: nums = [2,1,3]
    -Output: 12
    -Explanation: We could choose the following i, j, k triples:
    +Input: nums = [2,1,3]
    +Output: 12
    +Explanation: We could choose the following i, j, k triples:
     (i=0, j=0, k=1) : 2 & 2 & 1
     (i=0, j=1, k=0) : 2 & 1 & 2
     (i=0, j=1, k=1) : 2 & 1 & 1
    @@ -42,14 +43,20 @@
     (i=2, j=1, k=0) : 3 & 1 & 2
     
    -

     

    +

    Example 2:

    -

    Note:

    +
    +Input: nums = [0,0,0]
    +Output: 27
    +
    -
      -
    1. 1 <= nums.length <= 1000
    2. +

       

      +

      Constraints:

      + +
        +
      • 1 <= nums.length <= 1000
      • 0 <= nums[i] < 216
      • -
    + ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/tuple-with-same-product/README.md b/problems/tuple-with-same-product/README.md index fe5ce5a96..b286e0912 100644 --- a/problems/tuple-with-same-product/README.md +++ b/problems/tuple-with-same-product/README.md @@ -32,7 +32,7 @@ Explanation: There are 16 valids tuples: (1,10,2,5) , (1,10,5,2) , (10,1,2,5) , (10,1,5,2) (2,5,1,10) , (2,5,10,1) , (5,2,1,10) , (5,2,10,1) -(2,10,4,5) , (2,10,5,4) , (10,2,4,5) , (10,2,4,5) +(2,10,4,5) , (2,10,5,4) , (10,2,4,5) , (10,2,5,4) (4,5,2,10) , (4,5,10,2) , (5,4,2,10) , (5,4,10,2)
    diff --git a/problems/uncrossed-lines/README.md b/problems/uncrossed-lines/README.md index a76b32605..f53f4158e 100644 --- a/problems/uncrossed-lines/README.md +++ b/problems/uncrossed-lines/README.md @@ -11,56 +11,50 @@ ## [1035. Uncrossed Lines (Medium)](https://leetcode.com/problems/uncrossed-lines "不相交的线") -

    We write the integers of nums1 and nums2 (in the order they are given) on two separate horizontal lines.

    +

    You are given two integer arrays nums1 and nums2. We write the integers of nums1 and nums2 (in the order they are given) on two separate horizontal lines.

    -

    Now, we may draw connecting lines: a straight line connecting two numbers nums1[i] and nums2[j] such that:

    +

    We may draw connecting lines: a straight line connecting two numbers nums1[i] and nums2[j] such that:

      -
    • nums1[i] == nums2[j];
    • -
    • The line we draw does not intersect any other connecting (non-horizontal) line.
    • +
    • nums1[i] == nums2[j], and
    • +
    • the line we draw does not intersect any other connecting (non-horizontal) line.
    -

    Note that a connecting lines cannot intersect even at the endpoints: each number can only belong to one connecting line.

    +

    Note that a connecting line cannot intersect even at the endpoints (i.e., each number can only belong to one connecting line).

    -

    Return the maximum number of connecting lines we can draw in this way.

    +

    Return the maximum number of connecting lines we can draw in this way.

     

    -

    Example 1:

    - +
    -Input: nums1 = [1,4,2], nums2 = [1,2,4]
    -Output: 2
    -Explanation: We can draw 2 uncrossed lines as in the diagram.
    -We cannot draw 3 uncrossed lines, because the line from nums1[1]=4 to nums2[2]=4 will intersect the line from nums1[2]=2 to nums2[1]=2.
    +Input: nums1 = [1,4,2], nums2 = [1,2,4]
    +Output: 2
    +Explanation: We can draw 2 uncrossed lines as in the diagram.
    +We cannot draw 3 uncrossed lines, because the line from nums1[1] = 4 to nums2[2] = 4 will intersect the line from nums1[2]=2 to nums2[1]=2.
     
    -

    Example 2:

    -Input: nums1 = [2,5,1,2,5], nums2 = [10,5,2,1,5,2]
    -Output: 3
    +Input: nums1 = [2,5,1,2,5], nums2 = [10,5,2,1,5,2]
    +Output: 3
     
    -

    Example 3:

    -Input: nums1 = [1,3,7,1,7,5], nums2 = [1,9,2,5,1]
    -Output: 2
    +Input: nums1 = [1,3,7,1,7,5], nums2 = [1,9,2,5,1] +Output: 2 +

     

    -
    -
    - -

    Note:

    +

    Constraints:

    -
      -
    1. 1 <= nums1.length <= 500
    2. -
    3. 1 <= nums2.length <= 500
    4. -
    5. 1 <= nums1[i], nums2[i] <= 2000
    6. -
    +
      +
    • 1 <= nums1.length, nums2.length <= 500
    • +
    • 1 <= nums1[i], nums2[j] <= 2000
    • +
    ### Related Topics [[Array](../../tag/array/README.md)] diff --git a/problems/unique-paths-iii/README.md b/problems/unique-paths-iii/README.md index 0f64c0b7d..0a037cfb6 100644 --- a/problems/unique-paths-iii/README.md +++ b/problems/unique-paths-iii/README.md @@ -11,62 +11,60 @@ ## [980. Unique Paths III (Hard)](https://leetcode.com/problems/unique-paths-iii "不同路径 III") -

    On a 2-dimensional grid, there are 4 types of squares:

    +

    You are given an m x n integer array grid where grid[i][j] could be:

      -
    • 1 represents the starting square.  There is exactly one starting square.
    • -
    • 2 represents the ending square.  There is exactly one ending square.
    • -
    • 0 represents empty squares we can walk over.
    • -
    • -1 represents obstacles that we cannot walk over.
    • +
    • 1 representing the starting square. There is exactly one starting square.
    • +
    • 2 representing the ending square. There is exactly one ending square.
    • +
    • 0 representing empty squares we can walk over.
    • +
    • -1 representing obstacles that we cannot walk over.
    -

    Return the number of 4-directional walks from the starting square to the ending square, that walk over every non-obstacle square exactly once.

    +

    Return the number of 4-directional walks from the starting square to the ending square, that walk over every non-obstacle square exactly once.

     

    - -

    Example 1:

    - +
    -Input: [[1,0,0,0],[0,0,0,0],[0,0,2,-1]]
    -Output: 2
    -Explanation: We have the following two paths: 
    +Input: grid = [[1,0,0,0],[0,0,0,0],[0,0,2,-1]]
    +Output: 2
    +Explanation: We have the following two paths: 
     1. (0,0),(0,1),(0,2),(0,3),(1,3),(1,2),(1,1),(1,0),(2,0),(2,1),(2,2)
    -2. (0,0),(1,0),(2,0),(2,1),(1,1),(0,1),(0,2),(0,3),(1,3),(1,2),(2,2)
    +2. (0,0),(1,0),(2,0),(2,1),(1,1),(0,1),(0,2),(0,3),(1,3),(1,2),(2,2) + -

    Example 2:

    - +
    -Input: [[1,0,0,0],[0,0,0,0],[0,0,0,2]]
    -Output: 4
    -Explanation: We have the following four paths: 
    +Input: grid = [[1,0,0,0],[0,0,0,0],[0,0,0,2]]
    +Output: 4
    +Explanation: We have the following four paths: 
     1. (0,0),(0,1),(0,2),(0,3),(1,3),(1,2),(1,1),(1,0),(2,0),(2,1),(2,2),(2,3)
     2. (0,0),(0,1),(1,1),(1,0),(2,0),(2,1),(2,2),(1,2),(0,2),(0,3),(1,3),(2,3)
     3. (0,0),(1,0),(2,0),(2,1),(2,2),(1,2),(1,1),(0,1),(0,2),(0,3),(1,3),(2,3)
    -4. (0,0),(1,0),(2,0),(2,1),(1,1),(0,1),(0,2),(0,3),(1,3),(1,2),(2,2),(2,3)
    +4. (0,0),(1,0),(2,0),(2,1),(1,1),(0,1),(0,2),(0,3),(1,3),(1,2),(2,2),(2,3) + -

    Example 3:

    - +
    -Input: [[0,1],[2,0]]
    -Output: 0
    -Explanation: 
    -There is no path that walks over every empty square exactly once.
    +Input: grid = [[0,1],[2,0]]
    +Output: 0
    +Explanation: There is no path that walks over every empty square exactly once.
     Note that the starting and ending square can be anywhere in the grid.
     
    -
    -
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. 1 <= grid.length * grid[0].length <= 20
    2. -
    +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 20
    • +
    • 1 <= m * n <= 20
    • +
    • -1 <= grid[i][j] <= 2
    • +
    • There is exactly one starting cell and one ending cell.
    • +
    ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/univalued-binary-tree/README.md b/problems/univalued-binary-tree/README.md index 178433960..a0f8bd91b 100644 --- a/problems/univalued-binary-tree/README.md +++ b/problems/univalued-binary-tree/README.md @@ -11,36 +11,32 @@ ## [965. Univalued Binary Tree (Easy)](https://leetcode.com/problems/univalued-binary-tree "单值二叉树") -

    A binary tree is univalued if every node in the tree has the same value.

    +

    A binary tree is uni-valued if every node in the tree has the same value.

    -

    Return true if and only if the given tree is univalued.

    +

    Given the root of a binary tree, return true if the given tree is uni-valued, or false otherwise.

     

    -

    Example 1:

    -Input: [1,1,1,1,1,null,1]
    -Output: true
    +Input: root = [1,1,1,1,1,null,1]
    +Output: true
     
    -

    Example 2:

    -Input: [2,2,2,5,2]
    -Output: false
    +Input: root = [2,2,2,5,2]
    +Output: false
     
    -

     

    +

    Constraints:

    -

    Note:

    - -
      -
    1. The number of nodes in the given tree will be in the range [1, 100].
    2. -
    3. Each node's value will be an integer in the range [0, 99].
    4. -
    +
      +
    • The number of nodes in the tree is in the range [1, 100].
    • +
    • 0 <= Node.val < 100
    • +
    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/valid-sudoku/README.md b/problems/valid-sudoku/README.md index cd18755de..0ede45b13 100644 --- a/problems/valid-sudoku/README.md +++ b/problems/valid-sudoku/README.md @@ -66,7 +66,7 @@
    • board.length == 9
    • board[i].length == 9
    • -
    • board[i][j] is a digit or '.'.
    • +
    • board[i][j] is a digit 1-9 or '.'.
    ### Related Topics diff --git a/problems/verify-preorder-serialization-of-a-binary-tree/README.md b/problems/verify-preorder-serialization-of-a-binary-tree/README.md index 09e94745a..48029e149 100644 --- a/problems/verify-preorder-serialization-of-a-binary-tree/README.md +++ b/problems/verify-preorder-serialization-of-a-binary-tree/README.md @@ -43,7 +43,7 @@
    • 1 <= preorder.length <= 104
    • -
    • preoder consist of integers in the range [0, 100] and '#' separated by commas ','.
    • +
    • preorder consist of integers in the range [0, 100] and '#' separated by commas ','.
    ### Related Topics diff --git a/problems/verifying-an-alien-dictionary/README.md b/problems/verifying-an-alien-dictionary/README.md index 76908eabe..be804f1c7 100644 --- a/problems/verifying-an-alien-dictionary/README.md +++ b/problems/verifying-an-alien-dictionary/README.md @@ -11,9 +11,10 @@ ## [953. Verifying an Alien Dictionary (Easy)](https://leetcode.com/problems/verifying-an-alien-dictionary "验证外星语词典") -

    In an alien language, surprisingly they also use english lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letters.

    +

    In an alien language, surprisingly, they also use English lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letters.

    + +

    Given a sequence of words written in the alien language, and the order of the alphabet, return true if and only if the given words are sorted lexicographically in this alien language.

    -

    Given a sequence of words written in the alien language, and the order of the alphabet, return true if and only if the given words are sorted lexicographicaly in this alien language.

     

    Example 1:

    diff --git a/problems/video-stitching/README.md b/problems/video-stitching/README.md index 687a03680..c97194b4c 100644 --- a/problems/video-stitching/README.md +++ b/problems/video-stitching/README.md @@ -65,7 +65,7 @@ Now we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 1
    • 1 <= clips.length <= 100
    • -
    • 0 <= clips[i][0] <= clips[i][1] <= 100
    • +
    • 0 <= starti <= endi <= 100
    • 1 <= time <= 100
    diff --git a/problems/widest-pair-of-indices-with-equal-range-sum/README.md b/problems/widest-pair-of-indices-with-equal-range-sum/README.md new file mode 100644 index 000000000..e0979d352 --- /dev/null +++ b/problems/widest-pair-of-indices-with-equal-range-sum/README.md @@ -0,0 +1,35 @@ + + + + + + + +[< Previous](../find-array-given-subset-sums "Find Array Given Subset Sums") +                 +[Next >](../minimum-difference-between-highest-and-lowest-of-k-scores "Minimum Difference Between Highest and Lowest of K Scores") + +## [1983. Widest Pair of Indices With Equal Range Sum (Medium)](https://leetcode.com/problems/widest-pair-of-indices-with-equal-range-sum "") + + + +### Hints +
    +Hint 1 +Keep prefix sums of both arrays. +
    + +
    +Hint 2 +Can the difference between the prefix sums at an index help us? +
    + +
    +Hint 3 +What happens if the difference between the two prefix sums at an index a is x, and x again at a different index b? +
    + +
    +Hint 4 +This means that the sum of nums1 from index a + 1 to index b is equal to the sum of nums2 from index a + 1 to index b. +
    diff --git a/readme/1-300.md b/readme/1-300.md index e5665afc1..ea069a8e8 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -199,7 +199,7 @@ LeetCode Problems' Solutions | 119 | [Pascal's Triangle II](https://leetcode.com/problems/pascals-triangle-ii "杨辉三角 II") | [Go](../problems/pascals-triangle-ii) | Easy | | 120 | [Triangle](https://leetcode.com/problems/triangle "三角形最小路径和") | [Go](../problems/triangle) | Medium | | 121 | [Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock "买卖股票的最佳时机") | [Go](../problems/best-time-to-buy-and-sell-stock) | Easy | -| 122 | [Best Time to Buy and Sell Stock II](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii "买卖股票的最佳时机 II") | [Go](../problems/best-time-to-buy-and-sell-stock-ii) | Easy | +| 122 | [Best Time to Buy and Sell Stock II](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii "买卖股票的最佳时机 II") | [Go](../problems/best-time-to-buy-and-sell-stock-ii) | Medium | | 123 | [Best Time to Buy and Sell Stock III](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii "买卖股票的最佳时机 III") | [Go](../problems/best-time-to-buy-and-sell-stock-iii) | Hard | | 124 | [Binary Tree Maximum Path Sum](https://leetcode.com/problems/binary-tree-maximum-path-sum "二叉树中的最大路径和") | [Go](../problems/binary-tree-maximum-path-sum) | Hard | | 125 | [Valid Palindrome](https://leetcode.com/problems/valid-palindrome "验证回文串") | [Go](../problems/valid-palindrome) | Easy | diff --git a/readme/601-900.md b/readme/601-900.md index 6e657be84..90b8eb912 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -288,7 +288,7 @@ LeetCode Problems' Solutions | 808 | [Soup Servings](https://leetcode.com/problems/soup-servings "分汤") | [Go](../problems/soup-servings) | Medium | | 809 | [Expressive Words](https://leetcode.com/problems/expressive-words "情感丰富的文字") | [Go](../problems/expressive-words) | Medium | | 810 | [Chalkboard XOR Game](https://leetcode.com/problems/chalkboard-xor-game "黑板异或游戏") | [Go](../problems/chalkboard-xor-game) | Hard | -| 811 | [Subdomain Visit Count](https://leetcode.com/problems/subdomain-visit-count "子域名访问计数") | [Go](../problems/subdomain-visit-count) | Easy | +| 811 | [Subdomain Visit Count](https://leetcode.com/problems/subdomain-visit-count "子域名访问计数") | [Go](../problems/subdomain-visit-count) | Medium | | 812 | [Largest Triangle Area](https://leetcode.com/problems/largest-triangle-area "最大三角形面积") | [Go](../problems/largest-triangle-area) | Easy | | 813 | [Largest Sum of Averages](https://leetcode.com/problems/largest-sum-of-averages "最大平均值和的分组") | [Go](../problems/largest-sum-of-averages) | Medium | | 814 | [Binary Tree Pruning](https://leetcode.com/problems/binary-tree-pruning "二叉树剪枝") | [Go](../problems/binary-tree-pruning) | Medium | diff --git a/readme/901-1200.md b/readme/901-1200.md index 1dbc8639f..8a9a768fe 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -162,7 +162,7 @@ LeetCode Problems' Solutions | 982 | [Triples with Bitwise AND Equal To Zero](https://leetcode.com/problems/triples-with-bitwise-and-equal-to-zero "按位与为零的三元组") | [Go](../problems/triples-with-bitwise-and-equal-to-zero) | Hard | | 983 | [Minimum Cost For Tickets](https://leetcode.com/problems/minimum-cost-for-tickets "最低票价") | [Go](../problems/minimum-cost-for-tickets) | Medium | | 984 | [String Without AAA or BBB](https://leetcode.com/problems/string-without-aaa-or-bbb "不含 AAA 或 BBB 的字符串") | [Go](../problems/string-without-aaa-or-bbb) | Medium | -| 985 | [Sum of Even Numbers After Queries](https://leetcode.com/problems/sum-of-even-numbers-after-queries "查询后的偶数和") | [Go](../problems/sum-of-even-numbers-after-queries) | Easy | +| 985 | [Sum of Even Numbers After Queries](https://leetcode.com/problems/sum-of-even-numbers-after-queries "查询后的偶数和") | [Go](../problems/sum-of-even-numbers-after-queries) | Medium | | 986 | [Interval List Intersections](https://leetcode.com/problems/interval-list-intersections "区间列表的交集") | [Go](../problems/interval-list-intersections) | Medium | | 987 | [Vertical Order Traversal of a Binary Tree](https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree "二叉树的垂序遍历") | [Go](../problems/vertical-order-traversal-of-a-binary-tree) | Hard | | 988 | [Smallest String Starting From Leaf](https://leetcode.com/problems/smallest-string-starting-from-leaf "从叶结点开始的最小字符串") | [Go](../problems/smallest-string-starting-from-leaf) | Medium | @@ -210,7 +210,7 @@ LeetCode Problems' Solutions | 1030 | [Matrix Cells in Distance Order](https://leetcode.com/problems/matrix-cells-in-distance-order "距离顺序排列矩阵单元格") | [Go](../problems/matrix-cells-in-distance-order) | Easy | | 1031 | [Maximum Sum of Two Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays "两个非重叠子数组的最大和") | [Go](../problems/maximum-sum-of-two-non-overlapping-subarrays) | Medium | | 1032 | [Stream of Characters](https://leetcode.com/problems/stream-of-characters "字符流") | [Go](../problems/stream-of-characters) | Hard | -| 1033 | [Moving Stones Until Consecutive](https://leetcode.com/problems/moving-stones-until-consecutive "移动石子直到连续") | [Go](../problems/moving-stones-until-consecutive) | Easy | +| 1033 | [Moving Stones Until Consecutive](https://leetcode.com/problems/moving-stones-until-consecutive "移动石子直到连续") | [Go](../problems/moving-stones-until-consecutive) | Medium | | 1034 | [Coloring A Border](https://leetcode.com/problems/coloring-a-border "边框着色") | [Go](../problems/coloring-a-border) | Medium | | 1035 | [Uncrossed Lines](https://leetcode.com/problems/uncrossed-lines "不相交的线") | [Go](../problems/uncrossed-lines) | Medium | | 1036 | [Escape a Large Maze](https://leetcode.com/problems/escape-a-large-maze "逃离大迷宫") | [Go](../problems/escape-a-large-maze) | Hard | diff --git a/tag/array/README.md b/tag/array/README.md index 204ebab71..21fb92963 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,24 +9,43 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1986 | [完成任务的最少工作时间段](../../problems/minimum-number-of-work-sessions-to-finish-the-tasks) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1982 | [从子集的和还原数组](../../problems/find-array-given-subset-sums) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] | Hard | +| 1981 | [最小化目标值与所选元素的差](../../problems/minimize-the-difference-between-target-and-chosen-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1980 | [找出不同的二进制字符串](../../problems/find-unique-binary-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1979 | [找出数组的最大公约数](../../problems/find-greatest-common-divisor-of-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1975 | [最大方阵和](../../problems/maximum-matrix-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1970 | [你能穿过矩阵的最后一天](../../problems/last-day-where-you-can-still-cross) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1968 | [构造元素不等于两相邻元素平均值的数组](../../problems/array-with-elements-not-equal-to-average-of-neighbors) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1964 | [找出到每个位置为止最长的有效障碍赛跑路线](../../problems/find-the-longest-valid-obstacle-course-at-each-position) | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1962 | [移除石子使总数最小](../../problems/remove-stones-to-minimize-the-total) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1961 | [检查字符串是否为数组前缀](../../problems/check-if-string-is-a-prefix-of-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1959 | [K 次调整数组大小浪费的最小总空间](../../problems/minimum-total-space-wasted-with-k-resizing-operations) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1958 | [检查操作是否合法](../../problems/check-if-move-is-legal) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1955 | [统计特殊子序列的数目](../../problems/count-number-of-special-subsequences) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1953 | [你可以工作的最大周数](../../problems/maximum-number-of-weeks-for-which-you-can-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | | 1947 | [最大兼容性评分和](../../problems/maximum-compatibility-score-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1946 | [子字符串突变后可能得到的最大整数](../../problems/largest-number-after-mutating-substring) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 1944 | [队列中可以看到的人数](../../problems/number-of-visible-people-in-a-queue) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1943 | [描述绘画结果](../../problems/describe-the-painting) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1942 | [最小未被占据椅子的编号](../../problems/the-number-of-the-smallest-unoccupied-chair) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1940 | [排序数组之间的最长公共子序列](../../problems/longest-common-subsequence-between-sorted-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | | 1929 | [数组串联](../../problems/concatenation-of-array) | [[数组](../array/README.md)] | Easy | | 1926 | [迷宫中离入口最近的出口](../../problems/nearest-exit-from-entrance-in-maze) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1924 | [Erect the Fence II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1920 | [基于排列构建数组](../../problems/build-array-from-permutation) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | -| 1918 | [Kth Smallest Subarray Sum](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1918 | [第 K 小的子序列和](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1914 | [循环轮转矩阵](../../problems/cyclically-rotating-a-grid) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1913 | [两个数对之间的最大乘积差](../../problems/maximum-product-difference-between-two-pairs) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1911 | [最大子序列交替和](../../problems/maximum-alternating-subsequence-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1909 | [删除一个元素使数组严格递增](../../problems/remove-one-element-to-make-the-array-strictly-increasing) | [[数组](../array/README.md)] | Easy | -| 1908 | [Game of Nim](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1908 | [Nim 游戏 II](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1906 | [查询差绝对值的最小值](../../problems/minimum-absolute-difference-queries) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1901 | [找出顶峰元素 II](../../problems/find-a-peak-element-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -472,7 +491,7 @@ | 990 | [等式方程的可满足性](../../problems/satisfiability-of-equality-equations) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 989 | [数组形式的整数加法](../../problems/add-to-array-form-of-integer) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 986 | [区间列表的交集](../../problems/interval-list-intersections) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 985 | [查询后的偶数和](../../problems/sum-of-even-numbers-after-queries) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 985 | [查询后的偶数和](../../problems/sum-of-even-numbers-after-queries) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | | 983 | [最低票价](../../problems/minimum-cost-for-tickets) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 982 | [按位与为零的三元组](../../problems/triples-with-bitwise-and-equal-to-zero) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 980 | [不同路径 III](../../problems/unique-paths-iii) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Hard | @@ -574,7 +593,7 @@ | 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 813 | [最大平均值和的分组](../../problems/largest-sum-of-averages) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 812 | [最大三角形面积](../../problems/largest-triangle-area) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 810 | [黑板异或游戏](../../problems/chalkboard-xor-game) | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Hard | | 809 | [情感丰富的文字](../../problems/expressive-words) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 807 | [保持城市天际线](../../problems/max-increase-to-keep-city-skyline) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -862,7 +881,7 @@ | 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 128 | [最长连续序列](../../problems/longest-consecutive-sequence) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 123 | [买卖股票的最佳时机 III](../../problems/best-time-to-buy-and-sell-stock-iii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 121 | [买卖股票的最佳时机](../../problems/best-time-to-buy-and-sell-stock) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 120 | [三角形最小路径和](../../problems/triangle) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 119 | [杨辉三角 II](../../problems/pascals-triangle-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index efc8ce7e7..46c9dac8c 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1986 | [完成任务的最少工作时间段](../../problems/minimum-number-of-work-sessions-to-finish-the-tasks) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 1980 | [找出不同的二进制字符串](../../problems/find-unique-binary-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1947 | [最大兼容性评分和](../../problems/maximum-compatibility-score-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1863 | [找出所有子集的异或总和再求和](../../problems/sum-of-all-subset-xor-totals) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Easy | | 1849 | [将字符串拆分为递减的连续值](../../problems/splitting-a-string-into-descending-consecutive-values) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | diff --git a/tag/binary-indexed-tree/README.md b/tag/binary-indexed-tree/README.md index 35a88ea73..a0602d04c 100644 --- a/tag/binary-indexed-tree/README.md +++ b/tag/binary-indexed-tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1964 | [找出到每个位置为止最长的有效障碍赛跑路线](../../problems/find-the-longest-valid-obstacle-course-at-each-position) | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 1505 | [最多 K 次交换相邻数位后得到的最小整数](../../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | [[贪心](../greedy/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[字符串](../string/README.md)] | Hard | | 1409 | [查询带键的排列](../../problems/queries-on-a-permutation-with-key) | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 188204f89..a77cb86cf 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,10 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1970 | [你能穿过矩阵的最后一天](../../problems/last-day-where-you-can-still-cross) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1964 | [找出到每个位置为止最长的有效障碍赛跑路线](../../problems/find-the-longest-valid-obstacle-course-at-each-position) | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1954 | [收集足够苹果的最小花园周长](../../problems/minimum-garden-perimeter-to-collect-enough-apples) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | -| 1918 | [Kth Smallest Subarray Sum](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1918 | [第 K 小的子序列和](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1901 | [找出顶峰元素 II](../../problems/find-a-peak-element-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1898 | [可移除字符的最大数目](../../problems/maximum-number-of-removable-characters) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1894 | [找到需要补充粉笔的学生编号](../../problems/find-the-student-that-will-replace-the-chalk) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[模拟](../simulation/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index f06c61bd9..9ca356e3f 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,9 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1986 | [完成任务的最少工作时间段](../../problems/minimum-number-of-work-sessions-to-finish-the-tasks) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1947 | [最大兼容性评分和](../../problems/maximum-compatibility-score-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1915 | [最美子字符串的数目](../../problems/number-of-wonderful-substrings) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | -| 1908 | [Game of Nim](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1908 | [Nim 游戏 II](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1879 | [两个数组最小的异或值之和](../../problems/minimum-xor-sum-of-two-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1863 | [找出所有子集的异或总和再求和](../../problems/sum-of-all-subset-xor-totals) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Easy | | 1835 | [所有数对按位与结果的异或和](../../problems/find-xor-sum-of-all-pairs-bitwise-and) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/bitmask/README.md b/tag/bitmask/README.md index fcd9be1c5..3f94e143e 100644 --- a/tag/bitmask/README.md +++ b/tag/bitmask/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1986 | [完成任务的最少工作时间段](../../problems/minimum-number-of-work-sessions-to-finish-the-tasks) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1947 | [最大兼容性评分和](../../problems/maximum-compatibility-score-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1879 | [两个数组最小的异或值之和](../../problems/minimum-xor-sum-of-two-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1815 | [得到新鲜甜甜圈的最多组数](../../problems/maximum-number-of-groups-getting-fresh-donuts) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | diff --git a/tag/brainteaser/README.md b/tag/brainteaser/README.md index ac468154c..c0b3910d8 100644 --- a/tag/brainteaser/README.md +++ b/tag/brainteaser/README.md @@ -9,10 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1908 | [Game of Nim](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1908 | [Nim 游戏 II](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1503 | [所有蚂蚁掉下来前的最后一刻](../../problems/last-moment-before-all-ants-fall-out-of-a-plank) | [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | -| 1033 | [移动石子直到连续](../../problems/moving-stones-until-consecutive) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Easy | +| 1033 | [移动石子直到连续](../../problems/moving-stones-until-consecutive) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Medium | | 1025 | [除数博弈](../../problems/divisor-game) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Easy | | 810 | [黑板异或游戏](../../problems/chalkboard-xor-game) | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Hard | | 319 | [灯泡开关](../../problems/bulb-switcher) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index f68dc198e..a0478a227 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1970 | [你能穿过矩阵的最后一天](../../problems/last-day-where-you-can-still-cross) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1926 | [迷宫中离入口最近的出口](../../problems/nearest-exit-from-entrance-in-maze) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1810 | [隐藏网格下的最小消耗路径](../../problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[交互](../interactive/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/counting/README.md b/tag/counting/README.md index 9e7cd4573..81c6b72d0 100644 --- a/tag/counting/README.md +++ b/tag/counting/README.md @@ -10,6 +10,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1941 | [检查是否所有字符出现次数相同](../../problems/check-if-all-characters-have-equal-number-of-occurrences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1940 | [排序数组之间的最长公共子序列](../../problems/longest-common-subsequence-between-sorted-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | | 1897 | [重新分配字符使所有字符串都相等](../../problems/redistribute-characters-to-make-all-strings-equal) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 1876 | [长度为三且各字符不同的子字符串](../../problems/substrings-of-size-three-with-distinct-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] [[计数](../counting/README.md)] | Hard | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 93a6e9962..c19090040 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1970 | [你能穿过矩阵的最后一天](../../problems/last-day-where-you-can-still-cross) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1858 | [包含所有前缀的最长单词](../../problems/longest-word-with-all-prefixes) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] | Medium | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index 157509056..233b43daf 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1982 | [从子集的和还原数组](../../problems/find-array-given-subset-sums) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] | Hard | | 1901 | [找出顶峰元素 II](../../problems/find-a-peak-element-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1738 | [找出第 K 大的异或坐标值](../../problems/find-kth-largest-xor-coordinate-value) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[快速选择](../quickselect/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index f81e4f98e..c29f35c9d 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,12 +9,19 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1987 | [不同的好子序列数目](../../problems/number-of-unique-good-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1986 | [完成任务的最少工作时间段](../../problems/minimum-number-of-work-sessions-to-finish-the-tasks) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 1981 | [最小化目标值与所选元素的差](../../problems/minimize-the-difference-between-target-and-chosen-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1977 | [划分数字的方案数](../../problems/number-of-ways-to-separate-numbers) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[后缀数组](../suffix-array/README.md)] | Hard | +| 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | +| 1959 | [K 次调整数组大小浪费的最小总空间](../../problems/minimum-total-space-wasted-with-k-resizing-operations) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1955 | [统计特殊子序列的数目](../../problems/count-number-of-special-subsequences) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1947 | [最大兼容性评分和](../../problems/maximum-compatibility-score-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1931 | [用三种不同颜色为网格涂色](../../problems/painting-a-grid-with-three-different-colors) | [[动态规划](../dynamic-programming/README.md)] | Hard | | 1928 | [规定时间内到达终点的最小花费](../../problems/minimum-cost-to-reach-destination-in-time) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1911 | [最大子序列交替和](../../problems/maximum-alternating-subsequence-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1908 | [Game of Nim](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1908 | [Nim 游戏 II](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1900 | [最佳运动员的比拼回合](../../problems/the-earliest-and-latest-rounds-where-players-compete) | [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1896 | [反转表达式值的最少操作次数](../../problems/minimum-cost-to-change-the-final-value-of-expression) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1884 | [鸡蛋掉落-两枚鸡蛋](../../problems/egg-drop-with-2-eggs-and-n-floors) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -304,7 +311,7 @@ | 131 | [分割回文串](../../problems/palindrome-partitioning) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 123 | [买卖股票的最佳时机 III](../../problems/best-time-to-buy-and-sell-stock-iii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 121 | [买卖股票的最佳时机](../../problems/best-time-to-buy-and-sell-stock) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 120 | [三角形最小路径和](../../problems/triangle) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 119 | [杨辉三角 II](../../problems/pascals-triangle-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | diff --git a/tag/enumeration/README.md b/tag/enumeration/README.md index 06885e38c..fb1f57975 100644 --- a/tag/enumeration/README.md +++ b/tag/enumeration/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1958 | [检查操作是否合法](../../problems/check-if-move-is-legal) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1925 | [统计平方和三元组的数目](../../problems/count-square-sum-triples) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 1620 | [网络信号最好的坐标](../../problems/coordinate-with-maximum-network-quality) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Medium | | 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[枚举](../enumeration/README.md)] | Hard | diff --git a/tag/game-theory/README.md b/tag/game-theory/README.md index ca413faec..7c7a9a35f 100644 --- a/tag/game-theory/README.md +++ b/tag/game-theory/README.md @@ -10,7 +10,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1927 | [求和游戏](../../problems/sum-game) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Medium | -| 1908 | [Game of Nim](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1908 | [Nim 游戏 II](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1872 | [石子游戏 VIII](../../problems/stone-game-viii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 1728 | [猫和老鼠 II](../../problems/cat-and-mouse-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Hard | | 1690 | [石子游戏 VII](../../problems/stone-game-vii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index a9dcf8e41..686080f2a 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1924 | [Erect the Fence II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1828 | [统计一个圆中点的数目](../../problems/queries-on-number-of-points-inside-a-circle) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | | 1515 | [服务中心的最佳位置](../../problems/best-position-for-a-service-centre) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index b3bc559db..a8f4607d6 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 1928 | [规定时间内到达终点的最小花费](../../problems/minimum-cost-to-reach-destination-in-time) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] [[计数](../counting/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 3196bc6e1..440c0236b 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1975 | [最大方阵和](../../problems/maximum-matrix-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1974 | [使用特殊打字机键入单词的最少时间](../../problems/minimum-time-to-type-word-using-special-typewriter) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | +| 1969 | [数组元素的最小非零乘积](../../problems/minimum-non-zero-product-of-the-array-elements) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 1968 | [构造元素不等于两相邻元素平均值的数组](../../problems/array-with-elements-not-equal-to-average-of-neighbors) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1963 | [使字符串平衡的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-string-balanced) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1953 | [你可以工作的最大周数](../../problems/maximum-number-of-weeks-for-which-you-can-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1946 | [子字符串突变后可能得到的最大整数](../../problems/largest-number-after-mutating-substring) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 1927 | [求和游戏](../../problems/sum-game) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -195,7 +201,7 @@ | 179 | [最大数](../../problems/largest-number) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 135 | [分发糖果](../../problems/candy) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Hard | | 134 | [加油站](../../problems/gas-station) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 122 | [买卖股票的最佳时机 II](../../problems/best-time-to-buy-and-sell-stock-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 55 | [跳跃游戏](../../problems/jump-game) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/hash-function/README.md b/tag/hash-function/README.md index c8f386f97..9b5971506 100644 --- a/tag/hash-function/README.md +++ b/tag/hash-function/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1960 | [两个回文子字符串长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-substrings) | [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index a998336f9..12d0f1245 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -11,6 +11,7 @@ | :-: | - | - | :-: | | 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | | 1941 | [检查是否所有字符出现次数相同](../../problems/check-if-all-characters-have-equal-number-of-occurrences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 1940 | [排序数组之间的最长公共子序列](../../problems/longest-common-subsequence-between-sorted-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | | 1935 | [可以输入的最大单词数](../../problems/maximum-number-of-words-you-can-type) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1930 | [长度为 3 的不同回文子序列](../../problems/unique-length-3-palindromic-subsequences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | @@ -193,7 +194,7 @@ | 819 | [最常见的单词](../../problems/most-common-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 817 | [链表组件](../../problems/linked-list-components) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | | 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 792 | [匹配子序列的单词数](../../problems/number-of-matching-subsequences) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 791 | [自定义字符串排序](../../problems/custom-sort-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | diff --git a/tag/heap-priority-queue/README.md b/tag/heap-priority-queue/README.md index 41b09f43f..e1a43a972 100644 --- a/tag/heap-priority-queue/README.md +++ b/tag/heap-priority-queue/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1962 | [移除石子使总数最小](../../problems/remove-stones-to-minimize-the-total) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1942 | [最小未被占据椅子的编号](../../problems/the-number-of-the-smallest-unoccupied-chair) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1882 | [使用服务器处理任务](../../problems/process-tasks-using-servers) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index f81a63f18..223cc50a5 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,12 +9,16 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1979 | [找出数组的最大公约数](../../problems/find-greatest-common-divisor-of-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | +| 1969 | [数组元素的最小非零乘积](../../problems/minimum-non-zero-product-of-the-array-elements) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 1954 | [收集足够苹果的最小花园周长](../../problems/minimum-garden-perimeter-to-collect-enough-apples) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1952 | [三除数](../../problems/three-divisors) | [[数学](../math/README.md)] | Easy | | 1927 | [求和游戏](../../problems/sum-game) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1925 | [统计平方和三元组的数目](../../problems/count-square-sum-triples) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Easy | +| 1924 | [Erect the Fence II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1922 | [统计好数字的数目](../../problems/count-good-numbers) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | -| 1908 | [Game of Nim](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 1908 | [Nim 游戏 II](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1904 | [你完成的完整对局数](../../problems/the-number-of-full-rounds-you-have-played) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 1903 | [字符串中的最大奇数](../../problems/largest-odd-number-in-string) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 1896 | [反转表达式值的最少操作次数](../../problems/minimum-cost-to-change-the-final-value-of-expression) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -140,7 +144,7 @@ | 1041 | [困于环中的机器人](../../problems/robot-bounded-in-circle) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1040 | [移动石子直到连续 II](../../problems/moving-stones-until-consecutive-ii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 1037 | [有效的回旋镖](../../problems/valid-boomerang) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | -| 1033 | [移动石子直到连续](../../problems/moving-stones-until-consecutive) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Easy | +| 1033 | [移动石子直到连续](../../problems/moving-stones-until-consecutive) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Medium | | 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Easy | | 1025 | [除数博弈](../../problems/divisor-game) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Easy | | 1017 | [负二进制转换](../../problems/convert-to-base-2) | [[数学](../math/README.md)] | Medium | diff --git a/tag/matrix/README.md b/tag/matrix/README.md index ed67c415d..f20883ecc 100644 --- a/tag/matrix/README.md +++ b/tag/matrix/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1981 | [最小化目标值与所选元素的差](../../problems/minimize-the-difference-between-target-and-chosen-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1975 | [最大方阵和](../../problems/maximum-matrix-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1970 | [你能穿过矩阵的最后一天](../../problems/last-day-where-you-can-still-cross) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1958 | [检查操作是否合法](../../problems/check-if-move-is-legal) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1926 | [迷宫中离入口最近的出口](../../problems/nearest-exit-from-entrance-in-maze) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1914 | [循环轮转矩阵](../../problems/cyclically-rotating-a-grid) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | diff --git a/tag/quickselect/README.md b/tag/quickselect/README.md index d118466b4..02d685efc 100644 --- a/tag/quickselect/README.md +++ b/tag/quickselect/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1738 | [找出第 K 大的异或坐标值](../../problems/find-kth-largest-xor-coordinate-value) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[快速选择](../quickselect/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 973 | [最接近原点的 K 个点](../../problems/k-closest-points-to-origin) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index ab90a7221..4b9f00891 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1969 | [数组元素的最小非零乘积](../../problems/minimum-non-zero-product-of-the-array-elements) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 1922 | [统计好数字的数目](../../problems/count-good-numbers) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1808 | [好因子的最大数目](../../problems/maximize-number-of-nice-divisors) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/rolling-hash/README.md b/tag/rolling-hash/README.md index 36c2919b2..b4076acbc 100644 --- a/tag/rolling-hash/README.md +++ b/tag/rolling-hash/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1960 | [两个回文子字符串长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-substrings) | [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | | 1554 | [只有一个不同字符的字符串](../../problems/strings-differ-by-one-character) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | diff --git a/tag/shortest-path/README.md b/tag/shortest-path/README.md index 76daeded2..d1184c760 100644 --- a/tag/shortest-path/README.md +++ b/tag/shortest-path/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | diff --git a/tag/simulation/README.md b/tag/simulation/README.md index d8f453325..139200065 100644 --- a/tag/simulation/README.md +++ b/tag/simulation/README.md @@ -45,7 +45,7 @@ | 1041 | [困于环中的机器人](../../problems/robot-bounded-in-circle) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1006 | [笨阶乘](../../problems/clumsy-factorial) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 999 | [可以被一步捕获的棋子数](../../problems/available-captures-for-rook) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | -| 985 | [查询后的偶数和](../../problems/sum-of-even-numbers-after-queries) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 985 | [查询后的偶数和](../../problems/sum-of-even-numbers-after-queries) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | | 950 | [按递增顺序显示卡牌](../../problems/reveal-cards-in-increasing-order) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Medium | | 946 | [验证栈序列](../../problems/validate-stack-sequences) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | | 885 | [螺旋矩阵 III](../../problems/spiral-matrix-iii) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index 32ff4bf2f..853ab40b9 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1918 | [Kth Smallest Subarray Sum](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1918 | [第 K 小的子序列和](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1876 | [长度为三且各字符不同的子字符串](../../problems/substrings-of-size-three-with-distinct-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1852 | [每个子数组的数字种类数](../../problems/distinct-numbers-in-each-subarray) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1839 | [所有元音按顺序排布的最长子字符串](../../problems/longest-substring-of-all-vowels-in-order) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | diff --git a/tag/sorting/README.md b/tag/sorting/README.md index 901eb01c4..771741dad 100644 --- a/tag/sorting/README.md +++ b/tag/sorting/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1968 | [构造元素不等于两相邻元素平均值的数组](../../problems/array-with-elements-not-equal-to-average-of-neighbors) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1913 | [两个数对之间的最大乘积差](../../problems/maximum-product-difference-between-two-pairs) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 1889 | [装包裹的最小浪费空间](../../problems/minimum-space-wasted-from-packaging) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Hard | diff --git a/tag/stack/README.md b/tag/stack/README.md index 08d1c9bfb..7d9d30074 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1963 | [使字符串平衡的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-string-balanced) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1944 | [队列中可以看到的人数](../../problems/number-of-visible-people-in-a-queue) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1896 | [反转表达式值的最少操作次数](../../problems/minimum-cost-to-change-the-final-value-of-expression) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index d35884ace..c8a186c63 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,11 +9,22 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1987 | [不同的好子序列数目](../../problems/number-of-unique-good-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 1980 | [找出不同的二进制字符串](../../problems/find-unique-binary-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 1977 | [划分数字的方案数](../../problems/number-of-ways-to-separate-numbers) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[后缀数组](../suffix-array/README.md)] | Hard | +| 1974 | [使用特殊打字机键入单词的最少时间](../../problems/minimum-time-to-type-word-using-special-typewriter) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | +| 1967 | [作为子字符串出现在单词中的字符串数目](../../problems/number-of-strings-that-appear-as-substrings-in-word) | [[字符串](../string/README.md)] | Easy | +| 1963 | [使字符串平衡的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-string-balanced) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1961 | [检查字符串是否为数组前缀](../../problems/check-if-string-is-a-prefix-of-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 1960 | [两个回文子字符串长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-substrings) | [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | +| 1957 | [删除字符使字符串变好](../../problems/delete-characters-to-make-fancy-string) | [[字符串](../string/README.md)] | Easy | | 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | | 1946 | [子字符串突变后可能得到的最大整数](../../problems/largest-number-after-mutating-substring) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 1945 | [字符串转化后的各位数字之和](../../problems/sum-of-digits-of-string-after-convert) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 1941 | [检查是否所有字符出现次数相同](../../problems/check-if-all-characters-have-equal-number-of-occurrences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 1935 | [可以输入的最大单词数](../../problems/maximum-number-of-words-you-can-type) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1933 | [判断字符串是否可分解为值均等的子串](../../problems/check-if-string-is-decomposable-into-value-equal-substrings) 🔒 | [[字符串](../string/README.md)] | Easy | | 1930 | [长度为 3 的不同回文子序列](../../problems/unique-length-3-palindromic-subsequences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1915 | [最美子字符串的数目](../../problems/number-of-wonderful-substrings) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1910 | [删除一个字符串中所有出现的给定子字符串](../../problems/remove-all-occurrences-of-a-substring) | [[字符串](../string/README.md)] | Medium | @@ -259,7 +270,7 @@ | 820 | [单词的压缩编码](../../problems/short-encoding-of-words) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 819 | [最常见的单词](../../problems/most-common-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 816 | [模糊坐标](../../problems/ambiguous-coordinates) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | -| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 809 | [情感丰富的文字](../../problems/expressive-words) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 806 | [写字符串需要的行数](../../problems/number-of-lines-to-write-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | diff --git a/tag/suffix-array/README.md b/tag/suffix-array/README.md index 1ec43d64a..4e956db05 100644 --- a/tag/suffix-array/README.md +++ b/tag/suffix-array/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1977 | [划分数字的方案数](../../problems/number-of-ways-to-separate-numbers) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[后缀数组](../suffix-array/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | | 1062 | [最长重复子串](../../problems/longest-repeating-substring) 🔒 | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | diff --git a/tag/topological-sort/README.md b/tag/topological-sort/README.md index 1edd301f6..f779d858d 100644 --- a/tag/topological-sort/README.md +++ b/tag/topological-sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] [[计数](../counting/README.md)] | Hard | | 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 21d44c02a..1f292dfec 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1963 | [使字符串平衡的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-string-balanced) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1877 | [数组中最大数对和的最小值](../../problems/minimize-maximum-pair-sum-in-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 1871 | [跳跃游戏 VII](../../problems/jump-game-vii) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1868 | [两个行程编码数组的积](../../problems/product-of-two-run-length-encoded-arrays) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index 317e9708c..4bcbf438f 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1970 | [你能穿过矩阵的最后一天](../../problems/last-day-where-you-can-still-cross) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1724 | [检查边长度限制的路径是否存在 II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] | Hard | | 1722 | [执行交换操作后的最小汉明距离](../../problems/minimize-hamming-distance-after-swap-operations) | [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] | Medium | From a7e777194b80bf539cad8166e2b6232fa7aa9118 Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 16 Sep 2021 09:34:52 +0800 Subject: [PATCH 135/145] A: new --- README.md | 16 ++++ problems/4sum/README.md | 1 + .../all-paths-from-source-to-target/README.md | 5 +- problems/arithmetic-subarrays/README.md | 4 + .../README.md | 2 +- problems/avoid-flood-in-the-city/README.md | 2 +- .../README.md | 2 +- .../binary-search-tree-iterator-ii/README.md | 3 + .../README.md | 2 +- problems/bulb-switcher-iv/README.md | 2 +- .../README.md | 3 + problems/can-place-flowers/README.md | 2 +- .../README.md | 3 + .../README.md | 2 +- .../README.md | 11 ++- problems/clone-n-ary-tree/README.md | 7 +- .../README.md | 2 +- problems/coloring-a-border/README.md | 2 +- problems/consecutive-characters/README.md | 4 + .../constrained-subsequence-sum/README.md | 4 +- .../convert-a-number-to-hexadecimal/README.md | 2 +- problems/count-all-possible-routes/README.md | 2 +- problems/count-number-of-teams/README.md | 2 +- problems/count-special-quadruplets/README.md | 71 ++++++++++++++ .../count-submatrices-with-all-ones/README.md | 2 +- .../count-the-number-of-experiments/README.md | 14 +++ .../mysql_schemas.sql | 8 ++ .../README.md | 3 + problems/crawler-log-folder/README.md | 6 +- problems/create-a-session-bar-chart/README.md | 3 + .../README.md | 3 + .../README.md | 4 + .../design-a-file-sharing-system/README.md | 7 +- .../README.md | 2 +- .../README.md | 2 +- problems/design-browser-history/README.md | 6 +- problems/design-phone-directory/README.md | 7 +- problems/detect-cycles-in-2d-grid/README.md | 2 +- problems/diameter-of-n-ary-tree/README.md | 3 + problems/dice-roll-simulation/README.md | 6 +- .../README.md | 4 +- .../README.md | 2 +- problems/distinct-echo-substrings/README.md | 4 +- problems/distinct-subsequences-ii/README.md | 3 + .../README.md | 2 +- .../README.md | 4 +- .../find-all-groups-of-farmland/README.md | 82 +++++++++++++++++ .../README.md | 2 +- .../README.md | 2 +- .../find-duplicate-file-in-system/README.md | 3 + problems/find-duplicate-subtrees/README.md | 1 + .../find-if-path-exists-in-graph/README.md | 9 +- .../README.md | 2 +- .../find-longest-awesome-substring/README.md | 2 +- .../find-median-from-data-stream/README.md | 5 +- problems/find-peak-element/README.md | 1 + problems/find-root-of-n-ary-tree/README.md | 5 +- problems/find-the-duplicate-number/README.md | 2 +- .../README.md | 3 + .../README.md | 2 +- .../find-the-middle-index-in-array/README.md | 88 ++++++++++++++++++ .../README.md | 87 ++++++++++++++++++ .../README.md | 2 +- problems/flip-game-ii/README.md | 2 +- problems/flood-fill/README.md | 2 +- problems/freedom-trail/README.md | 4 +- problems/frog-jump/README.md | 3 + problems/gcd-sort-of-an-array/README.md | 75 +++++++++++++++ .../README.md | 2 +- problems/get-the-maximum-score/README.md | 2 +- .../README.md | 2 +- .../README.md | 2 +- problems/iterator-for-combination/README.md | 2 +- problems/jump-game-v/README.md | 3 + .../kth-ancestor-of-a-tree-node/README.md | 4 +- problems/largest-number/README.md | 2 +- problems/largest-values-from-labels/README.md | 4 +- .../README.md | 2 +- problems/lemonade-change/README.md | 2 +- .../README.md | 2 +- problems/linked-list-in-binary-tree/README.md | 2 +- .../README.md | 2 +- .../README.md | 6 +- .../README.md | 6 +- problems/longest-happy-string/README.md | 2 +- problems/make-the-string-great/README.md | 2 +- .../README.md | 2 +- problems/maximum-69-number/README.md | 2 +- .../maximum-depth-of-binary-tree/README.md | 1 + .../README.md | 2 +- .../README.md | 4 +- .../README.md | 2 +- .../README.md | 2 +- .../README.md | 2 +- .../README.md | 40 ++++++++ .../README.md | 4 +- .../maximum-performance-of-a-team/README.md | 2 +- .../README.md | 72 +++++++++++++++ .../README.md | 7 +- .../min-cost-to-connect-all-points/README.md | 2 +- .../README.md | 5 +- .../README.md | 4 +- .../minimum-cost-to-hire-k-workers/README.md | 2 +- .../README.md | 4 +- .../README.md | 5 +- .../README.md | 2 +- .../README.md | 2 +- .../README.md | 5 +- .../README.md | 14 ++- .../README.md | 2 +- .../README.md | 2 +- .../README.md | 2 +- .../README.md | 4 +- .../README.md | 3 + .../README.md | 2 +- .../README.md | 2 +- .../README.md | 2 +- .../README.md | 2 +- problems/nim-game/README.md | 2 +- problems/number-of-islands-ii/README.md | 2 +- .../README.md | 69 ++++++++++++++ .../README.md | 2 +- .../README.md | 3 + .../README.md | 10 +- .../README.md | 3 + .../README.md | 2 +- problems/operations-on-tree/README.md | 92 +++++++++++++++++++ .../path-with-maximum-probability/README.md | 5 +- problems/path-with-minimum-effort/README.md | 10 +- .../README.md | 3 + problems/power-of-four/README.md | 2 +- .../put-boxes-into-the-warehouse-i/README.md | 5 +- .../put-boxes-into-the-warehouse-ii/README.md | 5 +- problems/range-sum-query-immutable/README.md | 2 +- problems/rank-teams-by-votes/README.md | 5 +- problems/rank-transform-of-a-matrix/README.md | 6 +- .../rearrange-spaces-between-words/README.md | 3 + .../reduce-array-size-to-the-half/README.md | 2 +- .../README.md | 5 +- .../README.md | 1 + problems/reverse-prefix-of-word/README.md | 72 +++++++++++++++ problems/robot-room-cleaner/README.md | 2 + problems/russian-doll-envelopes/README.md | 1 + problems/sales-analysis-i/README.md | 3 + problems/sellers-with-no-sales/README.md | 3 + problems/sequence-reconstruction/README.md | 2 +- .../README.md | 2 +- .../README.md | 2 +- problems/simplified-fractions/README.md | 2 +- problems/single-number/README.md | 2 +- problems/sliding-window-maximum/README.md | 5 +- .../README.md | 25 +++++ .../README.md | 85 +++++++++++++++++ .../README.md | 4 +- problems/stone-game-iv/README.md | 6 ++ problems/stone-game-v/README.md | 9 ++ .../strings-differ-by-one-character/README.md | 2 +- problems/subarray-sum-equals-k/README.md | 2 +- problems/subrectangle-queries/README.md | 2 +- .../sum-of-all-odd-length-subarrays/README.md | 1 + problems/task-scheduler/README.md | 5 +- problems/the-maze-iii/README.md | 2 +- .../README.md | 3 + .../README.md | 4 + .../the-most-recent-three-orders/README.md | 3 + .../README.md | 2 +- problems/the-number-of-good-subsets/README.md | 81 ++++++++++++++++ .../README.md | 14 +++ .../mysql_schemas.sql | 8 ++ .../README.md | 70 ++++++++++++++ problems/throne-inheritance/README.md | 5 +- .../README.md | 4 + problems/tweet-counts-per-frequency/README.md | 4 +- .../unique-binary-search-trees-ii/README.md | 4 +- problems/unique-paths-iii/README.md | 2 +- problems/valid-boomerang/README.md | 2 +- problems/valid-parenthesis-string/README.md | 4 +- problems/valid-triangle-number/README.md | 2 +- problems/web-crawler/README.md | 5 +- problems/wiggle-sort-ii/README.md | 3 +- problems/wildcard-matching/README.md | 4 +- readme/301-600.md | 2 +- tag/array/README.md | 12 ++- tag/backtracking/README.md | 1 + tag/bit-manipulation/README.md | 2 + tag/bitmask/README.md | 2 + tag/breadth-first-search/README.md | 3 + tag/counting/README.md | 1 + tag/depth-first-search/README.md | 3 + tag/design/README.md | 1 + tag/dynamic-programming/README.md | 4 + tag/enumeration/README.md | 1 + tag/graph/README.md | 1 + tag/greedy/README.md | 1 + tag/hash-table/README.md | 4 +- tag/math/README.md | 4 + tag/matrix/README.md | 1 + tag/monotonic-stack/README.md | 1 + tag/number-theory/README.md | 1 + tag/prefix-sum/README.md | 5 +- tag/sorting/README.md | 2 + tag/stack/README.md | 1 + tag/string/README.md | 2 + tag/tree/README.md | 2 + tag/two-pointers/README.md | 1 + tag/union-find/README.md | 2 + 206 files changed, 1481 insertions(+), 175 deletions(-) create mode 100644 problems/count-special-quadruplets/README.md create mode 100644 problems/count-the-number-of-experiments/README.md create mode 100644 problems/count-the-number-of-experiments/mysql_schemas.sql create mode 100644 problems/find-all-groups-of-farmland/README.md create mode 100644 problems/find-the-middle-index-in-array/README.md create mode 100644 problems/first-day-where-you-have-been-in-all-the-rooms/README.md create mode 100644 problems/gcd-sort-of-an-array/README.md create mode 100644 problems/maximum-number-of-people-that-can-be-caught-in-tag/README.md create mode 100644 problems/maximum-product-of-the-length-of-two-palindromic-subsequences/README.md create mode 100644 problems/number-of-pairs-of-interchangeable-rectangles/README.md create mode 100644 problems/operations-on-tree/README.md create mode 100644 problems/reverse-prefix-of-word/README.md create mode 100644 problems/smallest-greater-multiple-made-of-two-digits/README.md create mode 100644 problems/smallest-missing-genetic-value-in-each-subtree/README.md create mode 100644 problems/the-number-of-good-subsets/README.md create mode 100644 problems/the-number-of-seniors-and-juniors-to-join-the-company/README.md create mode 100644 problems/the-number-of-seniors-and-juniors-to-join-the-company/mysql_schemas.sql create mode 100644 problems/the-number-of-weak-characters-in-the-game/README.md diff --git a/README.md b/README.md index bf7de3b75..9d975784b 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,22 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 2004 | [The Number of Seniors and Juniors to Join the Company](https://leetcode.com/problems/the-number-of-seniors-and-juniors-to-join-the-company) 🔒 | [MySQL](problems/the-number-of-seniors-and-juniors-to-join-the-company) | Hard | +| 2003 | [Smallest Missing Genetic Value in Each Subtree](https://leetcode.com/problems/smallest-missing-genetic-value-in-each-subtree "每棵子树内缺失的最小基因值") | [Go](problems/smallest-missing-genetic-value-in-each-subtree) | Hard | +| 2002 | [Maximum Product of the Length of Two Palindromic Subsequences](https://leetcode.com/problems/maximum-product-of-the-length-of-two-palindromic-subsequences "两个回文子序列长度的最大乘积") | [Go](problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | Medium | +| 2001 | [Number of Pairs of Interchangeable Rectangles](https://leetcode.com/problems/number-of-pairs-of-interchangeable-rectangles "可互换矩形的组数") | [Go](problems/number-of-pairs-of-interchangeable-rectangles) | Medium | +| 2000 | [Reverse Prefix of Word](https://leetcode.com/problems/reverse-prefix-of-word "反转单词前缀") | [Go](problems/reverse-prefix-of-word) | Easy | +| 1999 | [Smallest Greater Multiple Made of Two Digits](https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits) 🔒 | [Go](problems/smallest-greater-multiple-made-of-two-digits) | Medium | +| 1998 | [GCD Sort of an Array](https://leetcode.com/problems/gcd-sort-of-an-array "数组的最大公因数排序") | [Go](problems/gcd-sort-of-an-array) | Hard | +| 1997 | [First Day Where You Have Been in All the Rooms](https://leetcode.com/problems/first-day-where-you-have-been-in-all-the-rooms "访问完所有房间的第一天") | [Go](problems/first-day-where-you-have-been-in-all-the-rooms) | Medium | +| 1996 | [The Number of Weak Characters in the Game](https://leetcode.com/problems/the-number-of-weak-characters-in-the-game "游戏中弱角色的数量") | [Go](problems/the-number-of-weak-characters-in-the-game) | Medium | +| 1995 | [Count Special Quadruplets](https://leetcode.com/problems/count-special-quadruplets "统计特殊四元组") | [Go](problems/count-special-quadruplets) | Easy | +| 1994 | [The Number of Good Subsets](https://leetcode.com/problems/the-number-of-good-subsets "好子集的数目") | [Go](problems/the-number-of-good-subsets) | Hard | +| 1993 | [Operations on Tree](https://leetcode.com/problems/operations-on-tree "树上的操作") | [Go](problems/operations-on-tree) | Medium | +| 1992 | [Find All Groups of Farmland](https://leetcode.com/problems/find-all-groups-of-farmland "找到所有的农场组") | [Go](problems/find-all-groups-of-farmland) | Medium | +| 1991 | [Find the Middle Index in Array](https://leetcode.com/problems/find-the-middle-index-in-array "找到数组的中间位置") | [Go](problems/find-the-middle-index-in-array) | Easy | +| 1990 | [Count the Number of Experiments](https://leetcode.com/problems/count-the-number-of-experiments) 🔒 | [MySQL](problems/count-the-number-of-experiments) | Medium | +| 1989 | [Maximum Number of People That Can Be Caught in Tag](https://leetcode.com/problems/maximum-number-of-people-that-can-be-caught-in-tag) 🔒 | [Go](problems/maximum-number-of-people-that-can-be-caught-in-tag) | Medium | | 1988 | [Find Cutoff Score for Each School](https://leetcode.com/problems/find-cutoff-score-for-each-school) 🔒 | [MySQL](problems/find-cutoff-score-for-each-school) | Medium | | 1987 | [Number of Unique Good Subsequences](https://leetcode.com/problems/number-of-unique-good-subsequences "不同的好子序列数目") | [Go](problems/number-of-unique-good-subsequences) | Hard | | 1986 | [Minimum Number of Work Sessions to Finish the Tasks](https://leetcode.com/problems/minimum-number-of-work-sessions-to-finish-the-tasks "完成任务的最少工作时间段") | [Go](problems/minimum-number-of-work-sessions-to-finish-the-tasks) | Medium | diff --git a/problems/4sum/README.md b/problems/4sum/README.md index cfc05f039..cbf87def4 100644 --- a/problems/4sum/README.md +++ b/problems/4sum/README.md @@ -54,3 +54,4 @@ 1. [Two Sum](../two-sum) (Easy) 1. [3Sum](../3sum) (Medium) 1. [4Sum II](../4sum-ii) (Medium) + 1. [Count Special Quadruplets](../count-special-quadruplets) (Easy) diff --git a/problems/all-paths-from-source-to-target/README.md b/problems/all-paths-from-source-to-target/README.md index 13cd5f69b..35dbddd71 100644 --- a/problems/all-paths-from-source-to-target/README.md +++ b/problems/all-paths-from-source-to-target/README.md @@ -65,7 +65,10 @@ ### Related Topics + [[Backtracking](../../tag/backtracking/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] - [[Backtracking](../../tag/backtracking/README.md)] + +### Similar Questions + 1. [Number of Ways to Arrive at Destination](../number-of-ways-to-arrive-at-destination) (Medium) diff --git a/problems/arithmetic-subarrays/README.md b/problems/arithmetic-subarrays/README.md index f2b1ee7f4..d594dc368 100644 --- a/problems/arithmetic-subarrays/README.md +++ b/problems/arithmetic-subarrays/README.md @@ -64,6 +64,10 @@ In the 2nd query, the subarray is [5,9,3,7]. This can be [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Arithmetic Slices](../arithmetic-slices) (Medium) + 1. [Can Make Arithmetic Progression From Sequence](../can-make-arithmetic-progression-from-sequence) (Easy) + ### Hints
    Hint 1 diff --git a/problems/average-of-levels-in-binary-tree/README.md b/problems/average-of-levels-in-binary-tree/README.md index 3c9aebacb..50e5c2181 100644 --- a/problems/average-of-levels-in-binary-tree/README.md +++ b/problems/average-of-levels-in-binary-tree/README.md @@ -16,7 +16,7 @@ Given the root of a binary tree, return the average value of th

    Example 1:

    -Input: root = [3,9,20,null,15,7]
    +Input: root = [3,9,20,null,null,15,7]
     Output: [3.00000,14.50000,11.00000]
     Explanation: The average value of nodes on level 0 is 3, on level 1 is 14.5, and on level 2 is 11.
     Hence return [3, 14.5, 11].
    diff --git a/problems/avoid-flood-in-the-city/README.md b/problems/avoid-flood-in-the-city/README.md
    index 3226de883..22fc685a0 100644
    --- a/problems/avoid-flood-in-the-city/README.md
    +++ b/problems/avoid-flood-in-the-city/README.md
    @@ -93,10 +93,10 @@ After that, it will rain over lakes [1,2]. It's easy to prove that no matter
     
     
     ### Related Topics
    -  [[Greedy](../../tag/greedy/README.md)]
       [[Array](../../tag/array/README.md)]
       [[Hash Table](../../tag/hash-table/README.md)]
       [[Binary Search](../../tag/binary-search/README.md)]
    +  [[Greedy](../../tag/greedy/README.md)]
       [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)]
     
     ### Hints
    diff --git a/problems/best-position-for-a-service-centre/README.md b/problems/best-position-for-a-service-centre/README.md
    index 43f17ed8d..53dd69ad6 100644
    --- a/problems/best-position-for-a-service-centre/README.md
    +++ b/problems/best-position-for-a-service-centre/README.md
    @@ -71,8 +71,8 @@ Be careful with the precision!
     
     
     ### Related Topics
    -  [[Geometry](../../tag/geometry/README.md)]
       [[Math](../../tag/math/README.md)]
    +  [[Geometry](../../tag/geometry/README.md)]
       [[Randomized](../../tag/randomized/README.md)]
     
     ### Hints
    diff --git a/problems/binary-search-tree-iterator-ii/README.md b/problems/binary-search-tree-iterator-ii/README.md
    index de7bcc43e..db41437d7 100644
    --- a/problems/binary-search-tree-iterator-ii/README.md
    +++ b/problems/binary-search-tree-iterator-ii/README.md
    @@ -21,6 +21,9 @@
       [[Binary Tree](../../tag/binary-tree/README.md)]
       [[Iterator](../../tag/iterator/README.md)]
     
    +### Similar Questions
    +  1. [Binary Search Tree Iterator](../binary-search-tree-iterator) (Medium)
    +
     ### Hints
     
    Hint 1 diff --git a/problems/build-an-array-with-stack-operations/README.md b/problems/build-an-array-with-stack-operations/README.md index 60dd71263..1a0aec601 100644 --- a/problems/build-an-array-with-stack-operations/README.md +++ b/problems/build-an-array-with-stack-operations/README.md @@ -68,8 +68,8 @@ Read number 3 and automatically push in the array -> [1,3] ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] + [[Stack](../../tag/stack/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/bulb-switcher-iv/README.md b/problems/bulb-switcher-iv/README.md index 61722d446..e3b0c4601 100644 --- a/problems/bulb-switcher-iv/README.md +++ b/problems/bulb-switcher-iv/README.md @@ -69,8 +69,8 @@ We need at least 3 flip operations to form target.
    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/can-make-arithmetic-progression-from-sequence/README.md b/problems/can-make-arithmetic-progression-from-sequence/README.md index 3a893b278..9839584f7 100644 --- a/problems/can-make-arithmetic-progression-from-sequence/README.md +++ b/problems/can-make-arithmetic-progression-from-sequence/README.md @@ -44,6 +44,9 @@ [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Arithmetic Subarrays](../arithmetic-subarrays) (Medium) + ### Hints
    Hint 1 diff --git a/problems/can-place-flowers/README.md b/problems/can-place-flowers/README.md index c50dd2ae1..8833ed008 100644 --- a/problems/can-place-flowers/README.md +++ b/problems/can-place-flowers/README.md @@ -34,8 +34,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions 1. [Teemo Attacking](../teemo-attacking) (Easy) diff --git a/problems/check-if-two-expression-trees-are-equivalent/README.md b/problems/check-if-two-expression-trees-are-equivalent/README.md index 7b0b251b7..cc128802b 100644 --- a/problems/check-if-two-expression-trees-are-equivalent/README.md +++ b/problems/check-if-two-expression-trees-are-equivalent/README.md @@ -18,6 +18,9 @@ [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Build Binary Expression Tree From Infix Expression](../build-binary-expression-tree-from-infix-expression) (Hard) + ### Hints
    Hint 1 diff --git a/problems/circle-and-rectangle-overlapping/README.md b/problems/circle-and-rectangle-overlapping/README.md index 13ebd99f8..edda53622 100644 --- a/problems/circle-and-rectangle-overlapping/README.md +++ b/problems/circle-and-rectangle-overlapping/README.md @@ -64,8 +64,8 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] ### Hints
    diff --git a/problems/clone-binary-tree-with-random-pointer/README.md b/problems/clone-binary-tree-with-random-pointer/README.md index 3d1ee0e30..dac353e67 100644 --- a/problems/clone-binary-tree-with-random-pointer/README.md +++ b/problems/clone-binary-tree-with-random-pointer/README.md @@ -14,19 +14,24 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Clone Graph](../clone-graph) (Medium) + 1. [Copy List with Random Pointer](../copy-list-with-random-pointer) (Medium) + 1. [Clone N-ary Tree](../clone-n-ary-tree) (Medium) + ### Hints
    Hint 1 -Create an equivalent node for each node in the original tree. +Traverse the tree, keep a hashtable with you and create a nodecopy for each node in the tree.
    Hint 2 -Start traversing the original tree and connect the left, right and random pointers in the cloned tree the same way as the original tree. +Start traversing the original tree again and connect the left, right and random pointers in the cloned tree the same way as the original tree with the help of the hashtable.
    diff --git a/problems/clone-n-ary-tree/README.md b/problems/clone-n-ary-tree/README.md index 1416e47f6..7ef16942f 100644 --- a/problems/clone-n-ary-tree/README.md +++ b/problems/clone-n-ary-tree/README.md @@ -14,10 +14,15 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] + +### Similar Questions + 1. [Clone Graph](../clone-graph) (Medium) + 1. [Copy List with Random Pointer](../copy-list-with-random-pointer) (Medium) + 1. [Clone Binary Tree With Random Pointer](../clone-binary-tree-with-random-pointer) (Medium) ### Hints
    diff --git a/problems/closest-binary-search-tree-value/README.md b/problems/closest-binary-search-tree-value/README.md index 0153f8003..a2f2c6f8b 100644 --- a/problems/closest-binary-search-tree-value/README.md +++ b/problems/closest-binary-search-tree-value/README.md @@ -35,10 +35,10 @@ ### Related Topics + [[Binary Search](../../tag/binary-search/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/coloring-a-border/README.md b/problems/coloring-a-border/README.md index cd71bfc1e..a1b9e867c 100644 --- a/problems/coloring-a-border/README.md +++ b/problems/coloring-a-border/README.md @@ -45,9 +45,9 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Similar Questions diff --git a/problems/consecutive-characters/README.md b/problems/consecutive-characters/README.md index c605bae72..9ea25d484 100644 --- a/problems/consecutive-characters/README.md +++ b/problems/consecutive-characters/README.md @@ -64,6 +64,10 @@ ### Related Topics [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Max Consecutive Ones](../max-consecutive-ones) (Easy) + 1. [Count Number of Homogenous Substrings](../count-number-of-homogenous-substrings) (Medium) + ### Hints
    Hint 1 diff --git a/problems/constrained-subsequence-sum/README.md b/problems/constrained-subsequence-sum/README.md index d11ec6674..dfbb62c89 100644 --- a/problems/constrained-subsequence-sum/README.md +++ b/problems/constrained-subsequence-sum/README.md @@ -49,12 +49,12 @@ ### Related Topics - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Queue](../../tag/queue/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Monotonic Queue](../../tag/monotonic-queue/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] ### Hints
    diff --git a/problems/convert-a-number-to-hexadecimal/README.md b/problems/convert-a-number-to-hexadecimal/README.md index 955b7b2d3..9055b2c75 100644 --- a/problems/convert-a-number-to-hexadecimal/README.md +++ b/problems/convert-a-number-to-hexadecimal/README.md @@ -33,5 +33,5 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/count-all-possible-routes/README.md b/problems/count-all-possible-routes/README.md index 979194249..89fadfe87 100644 --- a/problems/count-all-possible-routes/README.md +++ b/problems/count-all-possible-routes/README.md @@ -81,9 +81,9 @@ ### Related Topics - [[Memoization](../../tag/memoization/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Memoization](../../tag/memoization/README.md)] ### Hints
    diff --git a/problems/count-number-of-teams/README.md b/problems/count-number-of-teams/README.md index 6ee99a555..2f27f44d2 100644 --- a/problems/count-number-of-teams/README.md +++ b/problems/count-number-of-teams/README.md @@ -57,9 +57,9 @@ ### Related Topics - [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] ### Hints
    diff --git a/problems/count-special-quadruplets/README.md b/problems/count-special-quadruplets/README.md new file mode 100644 index 000000000..4e3dd8ce3 --- /dev/null +++ b/problems/count-special-quadruplets/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../the-number-of-good-subsets "The Number of Good Subsets") +                 +[Next >](../the-number-of-weak-characters-in-the-game "The Number of Weak Characters in the Game") + +## [1995. Count Special Quadruplets (Easy)](https://leetcode.com/problems/count-special-quadruplets "统计特殊四元组") + +

    Given a 0-indexed integer array nums, return the number of distinct quadruplets (a, b, c, d) such that:

    + +
      +
    • nums[a] + nums[b] + nums[c] == nums[d], and
    • +
    • a < b < c < d
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3,6]
    +Output: 1
    +Explanation: The only quadruplet that satisfies the requirement is (0, 1, 2, 3) because 1 + 2 + 3 == 6.
    +
    + +

    Example 2:

    + +
    +Input: nums = [3,3,6,4,5]
    +Output: 0
    +Explanation: There are no such quadruplets in [3,3,6,4,5].
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,1,1,3,5]
    +Output: 4
    +Explanation: The 4 quadruplets that satisfy the requirement are:
    +- (0, 1, 2, 3): 1 + 1 + 1 == 3
    +- (0, 1, 3, 4): 1 + 1 + 3 == 5
    +- (0, 2, 3, 4): 1 + 1 + 3 == 5
    +- (1, 2, 3, 4): 1 + 1 + 3 == 5
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 4 <= nums.length <= 50
    • +
    • 1 <= nums[i] <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + +### Hints +
    +Hint 1 +N is very small, how can we use that? +
    + +
    +Hint 2 +Can we check every possible quadruplet? +
    diff --git a/problems/count-submatrices-with-all-ones/README.md b/problems/count-submatrices-with-all-ones/README.md index 7487dfdd9..543f8cfc6 100644 --- a/problems/count-submatrices-with-all-ones/README.md +++ b/problems/count-submatrices-with-all-ones/README.md @@ -72,9 +72,9 @@ Total number of rectangles = 8 + 5 + 2 + 4 + 2 + 2 + 1 = 24. ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Stack](../../tag/stack/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] diff --git a/problems/count-the-number-of-experiments/README.md b/problems/count-the-number-of-experiments/README.md new file mode 100644 index 000000000..bbf85f974 --- /dev/null +++ b/problems/count-the-number-of-experiments/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../maximum-number-of-people-that-can-be-caught-in-tag "Maximum Number of People That Can Be Caught in Tag") +                 +[Next >](../find-the-middle-index-in-array "Find the Middle Index in Array") + +## [1990. Count the Number of Experiments (Easy)](https://leetcode.com/problems/count-the-number-of-experiments "") + + diff --git a/problems/count-the-number-of-experiments/mysql_schemas.sql b/problems/count-the-number-of-experiments/mysql_schemas.sql new file mode 100644 index 000000000..751d5694e --- /dev/null +++ b/problems/count-the-number-of-experiments/mysql_schemas.sql @@ -0,0 +1,8 @@ +Create table If Not Exists Experiments (experiment_id int, platform ENUM('Android', 'IOS', 'Web'), experiment_name ENUM('Reading', 'Sports', 'Programming')); +Truncate table Experiments; +insert into Experiments (experiment_id, platform, experiment_name) values ('4', 'IOS', 'Programming'); +insert into Experiments (experiment_id, platform, experiment_name) values ('13', 'IOS', 'Sports'); +insert into Experiments (experiment_id, platform, experiment_name) values ('14', 'Android', 'Reading'); +insert into Experiments (experiment_id, platform, experiment_name) values ('8', 'Web', 'Reading'); +insert into Experiments (experiment_id, platform, experiment_name) values ('12', 'Web', 'Reading'); +insert into Experiments (experiment_id, platform, experiment_name) values ('18', 'Web', 'Programming'); diff --git a/problems/countries-you-can-safely-invest-in/README.md b/problems/countries-you-can-safely-invest-in/README.md index eac2822ed..068f9e87e 100644 --- a/problems/countries-you-can-safely-invest-in/README.md +++ b/problems/countries-you-can-safely-invest-in/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Average Salary: Departments VS Company](../average-salary-departments-vs-company) (Hard) diff --git a/problems/crawler-log-folder/README.md b/problems/crawler-log-folder/README.md index 3cc230641..7b39d13fa 100644 --- a/problems/crawler-log-folder/README.md +++ b/problems/crawler-log-folder/README.md @@ -66,9 +66,13 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] + +### Similar Questions + 1. [Baseball Game](../baseball-game) (Easy) + 1. [Backspace String Compare](../backspace-string-compare) (Easy) ### Hints
    diff --git a/problems/create-a-session-bar-chart/README.md b/problems/create-a-session-bar-chart/README.md index 373135897..9bf7444db 100644 --- a/problems/create-a-session-bar-chart/README.md +++ b/problems/create-a-session-bar-chart/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Count Salary Categories](../count-salary-categories) (Medium) diff --git a/problems/customer-who-visited-but-did-not-make-any-transactions/README.md b/problems/customer-who-visited-but-did-not-make-any-transactions/README.md index 7d9a80b24..128f84e0c 100644 --- a/problems/customer-who-visited-but-did-not-make-any-transactions/README.md +++ b/problems/customer-who-visited-but-did-not-make-any-transactions/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Sellers With No Sales](../sellers-with-no-sales) (Easy) diff --git a/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md b/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md index e73b8b5f1..44384de43 100644 --- a/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md +++ b/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md @@ -16,6 +16,10 @@ ### Related Topics [[Linked List](../../tag/linked-list/README.md)] +### Similar Questions + 1. [Remove Nth Node From End of List](../remove-nth-node-from-end-of-list) (Medium) + 1. [Remove Zero Sum Consecutive Nodes from Linked List](../remove-zero-sum-consecutive-nodes-from-linked-list) (Medium) + ### Hints
    Hint 1 diff --git a/problems/design-a-file-sharing-system/README.md b/problems/design-a-file-sharing-system/README.md index f4f4e80f6..08163d1c0 100644 --- a/problems/design-a-file-sharing-system/README.md +++ b/problems/design-a-file-sharing-system/README.md @@ -14,10 +14,13 @@ ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Data Stream](../../tag/data-stream/README.md)] + [[Design](../../tag/design/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] + +### Similar Questions + 1. [Design Twitter](../design-twitter) (Medium) ### Hints
    diff --git a/problems/design-add-and-search-words-data-structure/README.md b/problems/design-add-and-search-words-data-structure/README.md index a80b5d8e6..fae9b6c28 100644 --- a/problems/design-add-and-search-words-data-structure/README.md +++ b/problems/design-add-and-search-words-data-structure/README.md @@ -53,10 +53,10 @@ wordDictionary.search("b.."); // return True ### Related Topics + [[String](../../tag/string/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Design](../../tag/design/README.md)] [[Trie](../../tag/trie/README.md)] - [[String](../../tag/string/README.md)] ### Similar Questions 1. [Implement Trie (Prefix Tree)](../implement-trie-prefix-tree) (Medium) diff --git a/problems/design-an-expression-tree-with-evaluate-function/README.md b/problems/design-an-expression-tree-with-evaluate-function/README.md index 64a08db2e..da44203bf 100644 --- a/problems/design-an-expression-tree-with-evaluate-function/README.md +++ b/problems/design-an-expression-tree-with-evaluate-function/README.md @@ -14,10 +14,10 @@ ### Related Topics + [[Math](../../tag/math/README.md)] [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] [[Design](../../tag/design/README.md)] - [[Math](../../tag/math/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/design-browser-history/README.md b/problems/design-browser-history/README.md index 9a8ea0750..89eefc01a 100644 --- a/problems/design-browser-history/README.md +++ b/problems/design-browser-history/README.md @@ -58,12 +58,12 @@ browserHistory.back(7); // You are in "google.com", ### Related Topics - [[Stack](../../tag/stack/README.md)] - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Linked List](../../tag/linked-list/README.md)] - [[Data Stream](../../tag/data-stream/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Design](../../tag/design/README.md)] [[Doubly-Linked List](../../tag/doubly-linked-list/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] ### Hints
    diff --git a/problems/design-phone-directory/README.md b/problems/design-phone-directory/README.md index 249d0370a..d8d66629f 100644 --- a/problems/design-phone-directory/README.md +++ b/problems/design-phone-directory/README.md @@ -50,8 +50,11 @@ directory.check(2);

    ### Related Topics - [[Design](../../tag/design/README.md)] - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] + +### Similar Questions + 1. [Seat Reservation Manager](../seat-reservation-manager) (Medium) diff --git a/problems/detect-cycles-in-2d-grid/README.md b/problems/detect-cycles-in-2d-grid/README.md index f8e3b6169..b6f7cb2c5 100644 --- a/problems/detect-cycles-in-2d-grid/README.md +++ b/problems/detect-cycles-in-2d-grid/README.md @@ -63,10 +63,10 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/diameter-of-n-ary-tree/README.md b/problems/diameter-of-n-ary-tree/README.md index 71983e003..fd9fe85c0 100644 --- a/problems/diameter-of-n-ary-tree/README.md +++ b/problems/diameter-of-n-ary-tree/README.md @@ -17,6 +17,9 @@ [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] +### Similar Questions + 1. [Diameter of Binary Tree](../diameter-of-binary-tree) (Easy) + ### Hints
    Hint 1 diff --git a/problems/dice-roll-simulation/README.md b/problems/dice-roll-simulation/README.md index ccafc484f..861c5d154 100644 --- a/problems/dice-roll-simulation/README.md +++ b/problems/dice-roll-simulation/README.md @@ -11,11 +11,11 @@ ## [1223. Dice Roll Simulation (Hard)](https://leetcode.com/problems/dice-roll-simulation "掷骰子模拟") -

    A die simulator generates a random number from 1 to 6 for each roll. You introduced a constraint to the generator such that it cannot roll the number i more than rollMax[i] (1-indexed) consecutive times. 

    +

    A die simulator generates a random number from 1 to 6 for each roll. You introduced a constraint to the generator such that it cannot roll the number i more than rollMax[i] (1-indexed) consecutive times.

    -

    Given an array of integers rollMax and an integer n, return the number of distinct sequences that can be obtained with exact n rolls.

    +

    Given an array of integers rollMax and an integer n, return the number of distinct sequences that can be obtained with exact n rolls. Since the answer may be too large, return it modulo 109 + 7.

    -

    Two sequences are considered different if at least one element differs from each other. Since the answer may be too large, return it modulo 10^9 + 7.

    +

    Two sequences are considered different if at least one element differs from each other.

     

    Example 1:

    diff --git a/problems/different-ways-to-add-parentheses/README.md b/problems/different-ways-to-add-parentheses/README.md index 03c5d8952..add33a88f 100644 --- a/problems/different-ways-to-add-parentheses/README.md +++ b/problems/different-ways-to-add-parentheses/README.md @@ -46,11 +46,11 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] - [[Memoization](../../tag/memoization/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Memoization](../../tag/memoization/README.md)] ### Similar Questions 1. [Unique Binary Search Trees II](../unique-binary-search-trees-ii) (Medium) diff --git a/problems/display-table-of-food-orders-in-a-restaurant/README.md b/problems/display-table-of-food-orders-in-a-restaurant/README.md index 6ea038fe2..ee1233457 100644 --- a/problems/display-table-of-food-orders-in-a-restaurant/README.md +++ b/problems/display-table-of-food-orders-in-a-restaurant/README.md @@ -64,8 +64,8 @@ For the table 12: James, Ratesh and Amadeus order "Fried Chicken". [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Hints
    diff --git a/problems/distinct-echo-substrings/README.md b/problems/distinct-echo-substrings/README.md index 1bb6f7a33..e5f514e7d 100644 --- a/problems/distinct-echo-substrings/README.md +++ b/problems/distinct-echo-substrings/README.md @@ -39,12 +39,12 @@ ### Related Topics - [[Trie](../../tag/trie/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Trie](../../tag/trie/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Hash Function](../../tag/hash-function/README.md)] [[Rolling Hash](../../tag/rolling-hash/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Hints
    diff --git a/problems/distinct-subsequences-ii/README.md b/problems/distinct-subsequences-ii/README.md index f9799dc58..f4e676a5e 100644 --- a/problems/distinct-subsequences-ii/README.md +++ b/problems/distinct-subsequences-ii/README.md @@ -49,3 +49,6 @@ A subsequence of a string is a new string that is formed from t ### Related Topics [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Similar Questions + 1. [Number of Unique Good Subsequences](../number-of-unique-good-subsequences) (Hard) diff --git a/problems/evaluate-reverse-polish-notation/README.md b/problems/evaluate-reverse-polish-notation/README.md index 37780b31e..568b78b2e 100644 --- a/problems/evaluate-reverse-polish-notation/README.md +++ b/problems/evaluate-reverse-polish-notation/README.md @@ -59,9 +59,9 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Stack](../../tag/stack/README.md)] ### Similar Questions 1. [Basic Calculator](../basic-calculator) (Hard) diff --git a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md index d9e42c73b..c3cc0d0d1 100644 --- a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md +++ b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md @@ -53,10 +53,10 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] - [[Segment Tree](../../tag/segment-tree/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] ### Hints
    diff --git a/problems/find-all-groups-of-farmland/README.md b/problems/find-all-groups-of-farmland/README.md new file mode 100644 index 000000000..60fc424fe --- /dev/null +++ b/problems/find-all-groups-of-farmland/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../find-the-middle-index-in-array "Find the Middle Index in Array") +                 +[Next >](../operations-on-tree "Operations on Tree") + +## [1992. Find All Groups of Farmland (Medium)](https://leetcode.com/problems/find-all-groups-of-farmland "找到所有的农场组") + +

    You are given a 0-indexed m x n binary matrix land where a 0 represents a hectare of forested land and a 1 represents a hectare of farmland.

    + +

    To keep the land organized, there are designated rectangular areas of hectares that consist entirely of farmland. These rectangular areas are called groups. No two groups are adjacent, meaning farmland in one group is not four-directionally adjacent to another farmland in a different group.

    + +

    land can be represented by a coordinate system where the top left corner of land is (0, 0) and the bottom right corner of land is (m-1, n-1). Find the coordinates of the top left and bottom right corner of each group of farmland. A group of farmland with a top left corner at (r1, c1) and a bottom right corner at (r2, c2) is represented by the 4-length array [r1, c1, r2, c2].

    + +

    Return a 2D array containing the 4-length arrays described above for each group of farmland in land. If there are no groups of farmland, return an empty array. You may return the answer in any order.

    + +

     

    +

    Example 1:

    + +
    +Input: land = [[1,0,0],[0,1,1],[0,1,1]]
    +Output: [[0,0,0,0],[1,1,2,2]]
    +Explanation:
    +The first group has a top left corner at land[0][0] and a bottom right corner at land[0][0].
    +The second group has a top left corner at land[1][1] and a bottom right corner at land[2][2].
    +
    + +

    Example 2:

    + +
    +Input: land = [[1,1],[1,1]]
    +Output: [[0,0,1,1]]
    +Explanation:
    +The first group has a top left corner at land[0][0] and a bottom right corner at land[1][1].
    +
    + +

    Example 3:

    + +
    +Input: land = [[0]]
    +Output: []
    +Explanation:
    +There are no groups of farmland.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == land.length
    • +
    • n == land[i].length
    • +
    • 1 <= m, n <= 300
    • +
    • land consists of only 0's and 1's.
    • +
    • Groups of farmland are rectangular in shape.
    • +
    + +### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Since every group of farmland is rectangular, the top left corner of each group will have the smallest x-coordinate and y-coordinate of any farmland in the group. +
    + +
    +Hint 2 +Similarly, the top left corner of each group will have the largest x-coordinate and y-coordinate of any farmland in the group. +
    + +
    +Hint 3 +Use DFS to traverse through different groups of farmlands and keep track of the smallest and largest x-coordinate and y-coordinates you have seen in each group. +
    diff --git a/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md b/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md index 82bd85787..d8036fa81 100644 --- a/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md +++ b/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md @@ -57,8 +57,8 @@ The edges 2, 3, 4, and 5 are only part of some MSTs, therefore they are consider ### Related Topics [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] - [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] [[Strongly Connected Component](../../tag/strongly-connected-component/README.md)] ### Hints diff --git a/problems/find-cutoff-score-for-each-school/README.md b/problems/find-cutoff-score-for-each-school/README.md index f5ad302b2..55fa6aafb 100644 --- a/problems/find-cutoff-score-for-each-school/README.md +++ b/problems/find-cutoff-score-for-each-school/README.md @@ -7,7 +7,7 @@ [< Previous](../number-of-unique-good-subsequences "Number of Unique Good Subsequences")                  -Next > +[Next >](../maximum-number-of-people-that-can-be-caught-in-tag "Maximum Number of People That Can Be Caught in Tag") ## [1988. Find Cutoff Score for Each School (Medium)](https://leetcode.com/problems/find-cutoff-score-for-each-school "") diff --git a/problems/find-duplicate-file-in-system/README.md b/problems/find-duplicate-file-in-system/README.md index b3a3d45c5..2fddd47a6 100644 --- a/problems/find-duplicate-file-in-system/README.md +++ b/problems/find-duplicate-file-in-system/README.md @@ -64,3 +64,6 @@ [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + +### Similar Questions + 1. [Delete Duplicate Folders in System](../delete-duplicate-folders-in-system) (Hard) diff --git a/problems/find-duplicate-subtrees/README.md b/problems/find-duplicate-subtrees/README.md index 2d9d022d3..58f1f55fc 100644 --- a/problems/find-duplicate-subtrees/README.md +++ b/problems/find-duplicate-subtrees/README.md @@ -57,3 +57,4 @@ 1. [Serialize and Deserialize Binary Tree](../serialize-and-deserialize-binary-tree) (Hard) 1. [Serialize and Deserialize BST](../serialize-and-deserialize-bst) (Medium) 1. [Construct String from Binary Tree](../construct-string-from-binary-tree) (Easy) + 1. [Delete Duplicate Folders in System](../delete-duplicate-folders-in-system) (Hard) diff --git a/problems/find-if-path-exists-in-graph/README.md b/problems/find-if-path-exists-in-graph/README.md index 0853b910c..2c76e80ba 100644 --- a/problems/find-if-path-exists-in-graph/README.md +++ b/problems/find-if-path-exists-in-graph/README.md @@ -43,9 +43,14 @@
  • 1 <= n <= 2 * 105
  • 0 <= edges.length <= 2 * 105
  • edges[i].length == 2
  • -
  • 1 <= ui, vi <= n - 1
  • +
  • 0 <= ui, vi <= n - 1
  • ui != vi
  • -
  • 1 <= start, end <= n - 1
  • +
  • 0 <= start, end <= n - 1
  • There are no duplicate edges.
  • There are no self edges.
  • + +### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] diff --git a/problems/find-kth-bit-in-nth-binary-string/README.md b/problems/find-kth-bit-in-nth-binary-string/README.md index 472812324..ed9f7dea6 100644 --- a/problems/find-kth-bit-in-nth-binary-string/README.md +++ b/problems/find-kth-bit-in-nth-binary-string/README.md @@ -71,8 +71,8 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[String](../../tag/string/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Hints
    diff --git a/problems/find-longest-awesome-substring/README.md b/problems/find-longest-awesome-substring/README.md index 51ee2950c..b5f3b29e1 100644 --- a/problems/find-longest-awesome-substring/README.md +++ b/problems/find-longest-awesome-substring/README.md @@ -55,9 +55,9 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/find-median-from-data-stream/README.md b/problems/find-median-from-data-stream/README.md index 3d281767d..0c980debd 100644 --- a/problems/find-median-from-data-stream/README.md +++ b/problems/find-median-from-data-stream/README.md @@ -63,11 +63,12 @@ medianFinder.findMedian(); // return 2.0 ### Related Topics - [[Design](../../tag/design/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] - [[Data Stream](../../tag/data-stream/README.md)] + [[Design](../../tag/design/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] ### Similar Questions 1. [Sliding Window Median](../sliding-window-median) (Hard) + 1. [Finding MK Average](../finding-mk-average) (Hard) diff --git a/problems/find-peak-element/README.md b/problems/find-peak-element/README.md index d3fb50e52..88656e492 100644 --- a/problems/find-peak-element/README.md +++ b/problems/find-peak-element/README.md @@ -49,3 +49,4 @@ ### Similar Questions 1. [Peak Index in a Mountain Array](../peak-index-in-a-mountain-array) (Easy) + 1. [Find a Peak Element II](../find-a-peak-element-ii) (Medium) diff --git a/problems/find-root-of-n-ary-tree/README.md b/problems/find-root-of-n-ary-tree/README.md index 2c7f07dae..fc8c6cc86 100644 --- a/problems/find-root-of-n-ary-tree/README.md +++ b/problems/find-root-of-n-ary-tree/README.md @@ -14,10 +14,13 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] + +### Similar Questions + 1. [Move Sub-Tree of N-Ary Tree](../move-sub-tree-of-n-ary-tree) (Hard) ### Hints
    diff --git a/problems/find-the-duplicate-number/README.md b/problems/find-the-duplicate-number/README.md index 963570c1e..aa3962156 100644 --- a/problems/find-the-duplicate-number/README.md +++ b/problems/find-the-duplicate-number/README.md @@ -50,10 +50,10 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [First Missing Positive](../first-missing-positive) (Hard) diff --git a/problems/find-the-index-of-the-large-integer/README.md b/problems/find-the-index-of-the-large-integer/README.md index 64e335f8f..5add4dacc 100644 --- a/problems/find-the-index-of-the-large-integer/README.md +++ b/problems/find-the-index-of-the-large-integer/README.md @@ -18,6 +18,9 @@ [[Binary Search](../../tag/binary-search/README.md)] [[Interactive](../../tag/interactive/README.md)] +### Similar Questions + 1. [Search in a Sorted Array of Unknown Size](../search-in-a-sorted-array-of-unknown-size) (Medium) + ### Hints
    Hint 1 diff --git a/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md index f115bd5f2..47a954fac 100644 --- a/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md +++ b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md @@ -62,8 +62,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Matrix](../../tag/matrix/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/find-the-middle-index-in-array/README.md b/problems/find-the-middle-index-in-array/README.md new file mode 100644 index 000000000..f8ac5cd93 --- /dev/null +++ b/problems/find-the-middle-index-in-array/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../count-the-number-of-experiments "Count the Number of Experiments") +                 +[Next >](../find-all-groups-of-farmland "Find All Groups of Farmland") + +## [1991. Find the Middle Index in Array (Easy)](https://leetcode.com/problems/find-the-middle-index-in-array "找到数组的中间位置") + +

    Given a 0-indexed integer array nums, find the leftmost middleIndex (i.e., the smallest amongst all the possible ones).

    + +

    A middleIndex is an index where nums[0] + nums[1] + ... + nums[middleIndex-1] == nums[middleIndex+1] + nums[middleIndex+2] + ... + nums[nums.length-1].

    + +

    If middleIndex == 0, the left side sum is considered to be 0. Similarly, if middleIndex == nums.length - 1, the right side sum is considered to be 0.

    + +

    Return the leftmost middleIndex that satisfies the condition, or -1 if there is no such index.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [2,3,-1,8,4]
    +Output: 3
    +Explanation:
    +The sum of the numbers before index 3 is: 2 + 3 + -1 = 4
    +The sum of the numbers after index 3 is: 4 = 4
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,-1,4]
    +Output: 2
    +Explanation:
    +The sum of the numbers before index 2 is: 1 + -1 = 0
    +The sum of the numbers after index 2 is: 0
    +
    + +

    Example 3:

    + +
    +Input: nums = [2,5]
    +Output: -1
    +Explanation:
    +There is no valid middleIndex.
    +
    + +

    Example 4:

    + +
    +Input: nums = [1]
    +Output: 0
    +Explantion:
    +The sum of the numbers before index 0 is: 0
    +The sum of the numbers after index 0 is: 0
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • -1000 <= nums[i] <= 1000
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +Could we go from left to right and check to see if an index is a middle index? +
    + +
    +Hint 2 +Do we need to sum every number to the left and right of an index each time? +
    + +
    +Hint 3 +Use a prefix sum array where prefix[i] = nums[0] + nums[1] + ... + nums[i]. +
    diff --git a/problems/first-day-where-you-have-been-in-all-the-rooms/README.md b/problems/first-day-where-you-have-been-in-all-the-rooms/README.md new file mode 100644 index 000000000..8c0034241 --- /dev/null +++ b/problems/first-day-where-you-have-been-in-all-the-rooms/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../the-number-of-weak-characters-in-the-game "The Number of Weak Characters in the Game") +                 +[Next >](../gcd-sort-of-an-array "GCD Sort of an Array") + +## [1997. First Day Where You Have Been in All the Rooms (Medium)](https://leetcode.com/problems/first-day-where-you-have-been-in-all-the-rooms "访问完所有房间的第一天") + +

    There are n rooms you need to visit, labeled from 0 to n - 1. Each day is labeled, starting from 0. You will go in and visit one room a day.

    + +

    Initially on day 0, you visit room 0. The order you visit the rooms for the coming days is determined by the following rules and a given 0-indexed array nextVisit of length n:

    + +
      +
    • Assuming that on a day, you visit room i,
    • +
    • if you have been in room i an odd number of times (including the current visit), on the next day you will visit the room specified by nextVisit[i] where 0 <= nextVisit[i] <= i;
    • +
    • if you have been in room i an even number of times (including the current visit), on the next day you will visit room (i + 1) mod n.
    • +
    + +

    Return the label of the first day where you have been in all the rooms. It can be shown that such a day exists. Since the answer may be very large, return it modulo 109 + 7.

    + +

     

    +

    Example 1:

    + +
    +Input: nextVisit = [0,0]
    +Output: 2
    +Explanation:
    +- On day 0, you visit room 0. The total times you have been in room 0 is 1, which is odd.
    +  On the next day you will visit room nextVisit[0] = 0
    +- On day 1, you visit room 0, The total times you have been in room 0 is 2, which is even.
    +  On the next day you will visit room (0 + 1) mod 2 = 1
    +- On day 2, you visit room 1. This is the first day where you have been in all the rooms.
    +
    + +

    Example 2:

    + +
    +Input: nextVisit = [0,0,2]
    +Output: 6
    +Explanation:
    +Your room visiting order for each day is: [0,0,1,0,0,1,2,...].
    +Day 6 is the first day where you have been in all the rooms.
    +
    + +

    Example 3:

    + +
    +Input: nextVisit = [0,1,2,0]
    +Output: 6
    +Explanation:
    +Your room visiting order for each day is: [0,0,1,1,2,2,3,...].
    +Day 6 is the first day where you have been in all the rooms.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nextVisit.length
    • +
    • 2 <= n <= 105
    • +
    • 0 <= nextVisit[i] <= i
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +The only way to get to room i+1 is when you are visiting room i and room i has been visited an even number of times. +
    + +
    +Hint 2 +After visiting room i an odd number of times, you are required to visit room nextVisit[i] where nextVisit[i] <= i. It takes a fixed amount of days for you to come back from room nextVisit[i] to room i. Then, you have visited room i even number of times.nextVisit[i] +
    + +
    +Hint 3 +Can you use Dynamic Programming to avoid recomputing the number of days it takes to visit room i from room nextVisit[i]? +
    diff --git a/problems/first-unique-character-in-a-string/README.md b/problems/first-unique-character-in-a-string/README.md index c58d7222c..00f41ca4d 100644 --- a/problems/first-unique-character-in-a-string/README.md +++ b/problems/first-unique-character-in-a-string/README.md @@ -33,9 +33,9 @@ ### Related Topics - [[Queue](../../tag/queue/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Queue](../../tag/queue/README.md)] [[Counting](../../tag/counting/README.md)] ### Similar Questions diff --git a/problems/flip-game-ii/README.md b/problems/flip-game-ii/README.md index b78ed337c..1723aa64a 100644 --- a/problems/flip-game-ii/README.md +++ b/problems/flip-game-ii/README.md @@ -27,10 +27,10 @@ Derive your algorithm's runtime complexity.

    ### Related Topics - [[Memoization](../../tag/memoization/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Memoization](../../tag/memoization/README.md)] [[Game Theory](../../tag/game-theory/README.md)] ### Similar Questions diff --git a/problems/flood-fill/README.md b/problems/flood-fill/README.md index 19f075b6b..5951f4762 100644 --- a/problems/flood-fill/README.md +++ b/problems/flood-fill/README.md @@ -49,9 +49,9 @@ Note the bottom corner is not colored 2, because it is not 4-directionally conne ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Similar Questions diff --git a/problems/freedom-trail/README.md b/problems/freedom-trail/README.md index e88bcb965..3590b27dd 100644 --- a/problems/freedom-trail/README.md +++ b/problems/freedom-trail/README.md @@ -54,7 +54,7 @@ So the final output is 4. ### Related Topics - [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/frog-jump/README.md b/problems/frog-jump/README.md index 210cdabc9..caa47c756 100644 --- a/problems/frog-jump/README.md +++ b/problems/frog-jump/README.md @@ -47,3 +47,6 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Similar Questions + 1. [Minimum Sideway Jumps](../minimum-sideway-jumps) (Medium) diff --git a/problems/gcd-sort-of-an-array/README.md b/problems/gcd-sort-of-an-array/README.md new file mode 100644 index 000000000..743271080 --- /dev/null +++ b/problems/gcd-sort-of-an-array/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../first-day-where-you-have-been-in-all-the-rooms "First Day Where You Have Been in All the Rooms") +                 +[Next >](../smallest-greater-multiple-made-of-two-digits "Smallest Greater Multiple Made of Two Digits") + +## [1998. GCD Sort of an Array (Hard)](https://leetcode.com/problems/gcd-sort-of-an-array "数组的最大公因数排序") + +

    You are given an integer array nums, and you can perform the following operation any number of times on nums:

    + +
      +
    • Swap the positions of two elements nums[i] and nums[j] if gcd(nums[i], nums[j]) > 1 where gcd(nums[i], nums[j]) is the greatest common divisor of nums[i] and nums[j].
    • +
    + +

    Return true if it is possible to sort nums in non-decreasing order using the above swap method, or false otherwise.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [7,21,3]
    +Output: true
    +Explanation: We can sort [7,21,3] by performing the following operations:
    +- Swap 7 and 21 because gcd(7,21) = 7. nums = [21,7,3]
    +- Swap 21 and 3 because gcd(21,3) = 3. nums = [3,7,21]
    +
    + +

    Example 2:

    + +
    +Input: nums = [5,2,6,2]
    +Output: false
    +Explanation: It is impossible to sort the array because 5 cannot be swapped with any other element.
    +
    + +

    Example 3:

    + +
    +Input: nums = [10,5,9,3,15]
    +Output: true
    +We can sort [10,5,9,3,15] by performing the following operations:
    +- Swap 10 and 15 because gcd(10,15) = 5. nums = [15,5,9,3,10]
    +- Swap 15 and 3 because gcd(15,3) = 3. nums = [3,5,9,15,10]
    +- Swap 10 and 15 because gcd(10,15) = 5. nums = [3,5,9,10,15]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 3 * 104
    • +
    • 2 <= nums[i] <= 105
    • +
    + +### Related Topics + [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Can we build a graph with all the prime numbers and the original array? +
    + +
    +Hint 2 +We can use union-find to determine which indices are connected (i.e., which indices can be swapped). +
    diff --git a/problems/get-equal-substrings-within-budget/README.md b/problems/get-equal-substrings-within-budget/README.md index c7e278c2c..fb5cb6ac9 100644 --- a/problems/get-equal-substrings-within-budget/README.md +++ b/problems/get-equal-substrings-within-budget/README.md @@ -55,8 +55,8 @@ ### Related Topics [[String](../../tag/string/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Prefix Sum](../../tag/prefix-sum/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/get-the-maximum-score/README.md b/problems/get-the-maximum-score/README.md index d3b8f3baa..58ded5aa5 100644 --- a/problems/get-the-maximum-score/README.md +++ b/problems/get-the-maximum-score/README.md @@ -76,10 +76,10 @@ Maximum sum is obtained with the path [6,7,8,9,10]. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/graph-connectivity-with-threshold/README.md b/problems/graph-connectivity-with-threshold/README.md index d471d5221..06834dd1c 100644 --- a/problems/graph-connectivity-with-threshold/README.md +++ b/problems/graph-connectivity-with-threshold/README.md @@ -74,9 +74,9 @@ Please notice that there can be multiple queries for the same pair of nodes [x, ### Related Topics - [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Union Find](../../tag/union-find/README.md)] ### Hints
    diff --git a/problems/how-many-apples-can-you-put-into-the-basket/README.md b/problems/how-many-apples-can-you-put-into-the-basket/README.md index 81d680a95..a3eff6ff0 100644 --- a/problems/how-many-apples-can-you-put-into-the-basket/README.md +++ b/problems/how-many-apples-can-you-put-into-the-basket/README.md @@ -41,8 +41,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/iterator-for-combination/README.md b/problems/iterator-for-combination/README.md index 90a89c48e..18bcb683a 100644 --- a/problems/iterator-for-combination/README.md +++ b/problems/iterator-for-combination/README.md @@ -50,9 +50,9 @@ itr.hasNext(); // return False ### Related Topics - [[Design](../../tag/design/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Design](../../tag/design/README.md)] [[Iterator](../../tag/iterator/README.md)] ### Hints diff --git a/problems/jump-game-v/README.md b/problems/jump-game-v/README.md index 8193310c6..ed8f8ea0c 100644 --- a/problems/jump-game-v/README.md +++ b/problems/jump-game-v/README.md @@ -79,6 +79,9 @@ Similarly You cannot jump from index 3 to index 2 or index 1. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Jump Game VII](../jump-game-vii) (Medium) + ### Hints
    Hint 1 diff --git a/problems/kth-ancestor-of-a-tree-node/README.md b/problems/kth-ancestor-of-a-tree-node/README.md index 45fab111e..eb59c8b0f 100644 --- a/problems/kth-ancestor-of-a-tree-node/README.md +++ b/problems/kth-ancestor-of-a-tree-node/README.md @@ -51,12 +51,12 @@ treeAncestor.getKthAncestor(6, 3); // returns -1 because there is no such ancest ### Related Topics + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Design](../../tag/design/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/largest-number/README.md b/problems/largest-number/README.md index 14e6b65ba..696779518 100644 --- a/problems/largest-number/README.md +++ b/problems/largest-number/README.md @@ -53,6 +53,6 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/largest-values-from-labels/README.md b/problems/largest-values-from-labels/README.md index 8d16b99c2..86b4bc468 100644 --- a/problems/largest-values-from-labels/README.md +++ b/problems/largest-values-from-labels/README.md @@ -68,11 +68,11 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Counting](../../tag/counting/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md b/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md index f68c40999..8213bad69 100644 --- a/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md +++ b/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md @@ -78,8 +78,8 @@ Note that the last moment when an ant was on the plank is t = 4 second, after th ### Related Topics - [[Brainteaser](../../tag/brainteaser/README.md)] [[Array](../../tag/array/README.md)] + [[Brainteaser](../../tag/brainteaser/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/lemonade-change/README.md b/problems/lemonade-change/README.md index c85ac1bad..1eb2c1502 100644 --- a/problems/lemonade-change/README.md +++ b/problems/lemonade-change/README.md @@ -65,5 +65,5 @@ Since not every customer received correct change, the answer is false. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/lexicographically-smallest-string-after-applying-operations/README.md b/problems/lexicographically-smallest-string-after-applying-operations/README.md index 5b989496f..18a828363 100644 --- a/problems/lexicographically-smallest-string-after-applying-operations/README.md +++ b/problems/lexicographically-smallest-string-after-applying-operations/README.md @@ -83,8 +83,8 @@ There is no way to obtain a string that is lexicographically smaller then " ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[String](../../tag/string/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Hints
    diff --git a/problems/linked-list-in-binary-tree/README.md b/problems/linked-list-in-binary-tree/README.md index 332d65103..20e9f3439 100644 --- a/problems/linked-list-in-binary-tree/README.md +++ b/problems/linked-list-in-binary-tree/README.md @@ -55,10 +55,10 @@ ### Related Topics + [[Linked List](../../tag/linked-list/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Linked List](../../tag/linked-list/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/logical-or-of-two-binary-grids-represented-as-quad-trees/README.md b/problems/logical-or-of-two-binary-grids-represented-as-quad-trees/README.md index 75241cb78..2cae6fc92 100644 --- a/problems/logical-or-of-two-binary-grids-represented-as-quad-trees/README.md +++ b/problems/logical-or-of-two-binary-grids-represented-as-quad-trees/README.md @@ -110,5 +110,5 @@ The resulting matrix is of size 1*1 with also zero. ### Related Topics - [[Tree](../../tag/tree/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Tree](../../tag/tree/README.md)] diff --git a/problems/longer-contiguous-segments-of-ones-than-zeros/README.md b/problems/longer-contiguous-segments-of-ones-than-zeros/README.md index e10a4a1e4..707743592 100644 --- a/problems/longer-contiguous-segments-of-ones-than-zeros/README.md +++ b/problems/longer-contiguous-segments-of-ones-than-zeros/README.md @@ -11,13 +11,13 @@ ## [1869. Longer Contiguous Segments of Ones than Zeros (Easy)](https://leetcode.com/problems/longer-contiguous-segments-of-ones-than-zeros "哪种连续子字符串更长") -

    Given a binary string s, return true if the longest contiguous segment of 1s is strictly longer than the longest contiguous segment of 0s in s. Return false otherwise.

    +

    Given a binary string s, return true if the longest contiguous segment of 1's is strictly longer than the longest contiguous segment of 0's in s, or return false otherwise.

      -
    • For example, in s = "110100010" the longest contiguous segment of 1s has length 2, and the longest contiguous segment of 0s has length 3.
    • +
    • For example, in s = "110100010" the longest continuous segment of 1s has length 2, and the longest continuous segment of 0s has length 3.
    -

    Note that if there are no 0s, then the longest contiguous segment of 0s is considered to have length 0. The same applies if there are no 1s.

    +

    Note that if there are no 0's, then the longest continuous segment of 0's is considered to have a length 0. The same applies if there is no 1's.

     

    Example 1:

    diff --git a/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md index 66c810ef5..38ba47009 100644 --- a/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md +++ b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md @@ -58,12 +58,12 @@ Therefore, the size of the longest subarray is 2. ### Related Topics - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] + [[Queue](../../tag/queue/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Monotonic Queue](../../tag/monotonic-queue/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] ### Hints
    diff --git a/problems/longest-happy-string/README.md b/problems/longest-happy-string/README.md index f678998ac..064f01b24 100644 --- a/problems/longest-happy-string/README.md +++ b/problems/longest-happy-string/README.md @@ -56,8 +56,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/make-the-string-great/README.md b/problems/make-the-string-great/README.md index 42c64ae4e..3512fd642 100644 --- a/problems/make-the-string-great/README.md +++ b/problems/make-the-string-great/README.md @@ -61,8 +61,8 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[String](../../tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] ### Hints
    diff --git a/problems/make-the-xor-of-all-segments-equal-to-zero/README.md b/problems/make-the-xor-of-all-segments-equal-to-zero/README.md index 1a20704bd..5a2d02c40 100644 --- a/problems/make-the-xor-of-all-segments-equal-to-zero/README.md +++ b/problems/make-the-xor-of-all-segments-equal-to-zero/README.md @@ -48,9 +48,9 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/maximum-69-number/README.md b/problems/maximum-69-number/README.md index c03dda068..79c1b13da 100644 --- a/problems/maximum-69-number/README.md +++ b/problems/maximum-69-number/README.md @@ -52,8 +52,8 @@ The maximum number is 9969. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/maximum-depth-of-binary-tree/README.md b/problems/maximum-depth-of-binary-tree/README.md index 4fef9e41f..7ff9c358c 100644 --- a/problems/maximum-depth-of-binary-tree/README.md +++ b/problems/maximum-depth-of-binary-tree/README.md @@ -62,3 +62,4 @@ 1. [Balanced Binary Tree](../balanced-binary-tree) (Easy) 1. [Minimum Depth of Binary Tree](../minimum-depth-of-binary-tree) (Easy) 1. [Maximum Depth of N-ary Tree](../maximum-depth-of-n-ary-tree) (Easy) + 1. [Time Needed to Inform All Employees](../time-needed-to-inform-all-employees) (Medium) diff --git a/problems/maximum-length-of-subarray-with-positive-product/README.md b/problems/maximum-length-of-subarray-with-positive-product/README.md index a3e9e707b..4ceae6c1b 100644 --- a/problems/maximum-length-of-subarray-with-positive-product/README.md +++ b/problems/maximum-length-of-subarray-with-positive-product/README.md @@ -65,9 +65,9 @@ Notice that we cannot include 0 in the subarray since that'll make the produ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-coins-you-can-get/README.md b/problems/maximum-number-of-coins-you-can-get/README.md index 310a9960b..7b7eae3e9 100644 --- a/problems/maximum-number-of-coins-you-can-get/README.md +++ b/problems/maximum-number-of-coins-you-can-get/README.md @@ -61,11 +61,11 @@ On the other hand if we choose this arrangement (1, 2, 8), (2, ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Game Theory](../../tag/game-theory/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md b/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md index a757781c4..61f9aa82c 100644 --- a/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md +++ b/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md @@ -61,9 +61,9 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md b/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md index 2e107370c..a13a23574 100644 --- a/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md +++ b/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md @@ -56,9 +56,9 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints diff --git a/problems/maximum-number-of-non-overlapping-substrings/README.md b/problems/maximum-number-of-non-overlapping-substrings/README.md index 93e3be684..3e571a962 100644 --- a/problems/maximum-number-of-non-overlapping-substrings/README.md +++ b/problems/maximum-number-of-non-overlapping-substrings/README.md @@ -57,8 +57,8 @@ If we choose the first string, we cannot choose anything else and we'd get o ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-people-that-can-be-caught-in-tag/README.md b/problems/maximum-number-of-people-that-can-be-caught-in-tag/README.md new file mode 100644 index 000000000..cec72556d --- /dev/null +++ b/problems/maximum-number-of-people-that-can-be-caught-in-tag/README.md @@ -0,0 +1,40 @@ + + + + + + + +[< Previous](../find-cutoff-score-for-each-school "Find Cutoff Score for Each School") +                 +[Next >](../count-the-number-of-experiments "Count the Number of Experiments") + +## [1989. Maximum Number of People That Can Be Caught in Tag (Medium)](https://leetcode.com/problems/maximum-number-of-people-that-can-be-caught-in-tag "") + + + +### Hints +
    +Hint 1 +Try to use as much of the range of a person who is "it" as possible. +
    + +
    +Hint 2 +Find the leftmost person who is "it" that has not caught anyone yet, and the leftmost person who is not "it" that has not been caught yet. +
    + +
    +Hint 3 +If the person who is not "it" can be caught, pair them together and repeat the process. +
    + +
    +Hint 4 +If the person who is not "it" cannot be caught, and the person who is not "it" is on the left of the person who is "it", find the next leftmost person who is not "it". +
    + +
    +Hint 5 +If the person who is not "it" cannot be caught, and the person who is "it" is on the left of the person who is not "it", find the next leftmost person who is "it". +
    diff --git a/problems/maximum-number-of-visible-points/README.md b/problems/maximum-number-of-visible-points/README.md index fdf1f0654..31e16ca42 100644 --- a/problems/maximum-number-of-visible-points/README.md +++ b/problems/maximum-number-of-visible-points/README.md @@ -62,11 +62,11 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Sorting](../../tag/sorting/README.md)] + [[Geometry](../../tag/geometry/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/maximum-performance-of-a-team/README.md b/problems/maximum-performance-of-a-team/README.md index b3d6167e8..44da51136 100644 --- a/problems/maximum-performance-of-a-team/README.md +++ b/problems/maximum-performance-of-a-team/README.md @@ -57,8 +57,8 @@ We have the maximum performance of the team by selecting engineer 2 (with speed= ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/maximum-product-of-the-length-of-two-palindromic-subsequences/README.md b/problems/maximum-product-of-the-length-of-two-palindromic-subsequences/README.md new file mode 100644 index 000000000..f174e640a --- /dev/null +++ b/problems/maximum-product-of-the-length-of-two-palindromic-subsequences/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../number-of-pairs-of-interchangeable-rectangles "Number of Pairs of Interchangeable Rectangles") +                 +[Next >](../smallest-missing-genetic-value-in-each-subtree "Smallest Missing Genetic Value in Each Subtree") + +## [2002. Maximum Product of the Length of Two Palindromic Subsequences (Medium)](https://leetcode.com/problems/maximum-product-of-the-length-of-two-palindromic-subsequences "两个回文子序列长度的最大乘积") + +

    Given a string s, find two disjoint palindromic subsequences of s such that the product of their lengths is maximized. The two subsequences are disjoint if they do not both pick a character at the same index.

    + +

    Return the maximum possible product of the lengths of the two palindromic subsequences.

    + +

    A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters. A string is palindromic if it reads the same forward and backward.

    + +

     

    +

    Example 1:

    +example-1 +
    +Input: s = "leetcodecom"
    +Output: 9
    +Explanation: An optimal solution is to choose "ete" for the 1st subsequence and "cdc" for the 2nd subsequence.
    +The product of their lengths is: 3 * 3 = 9.
    +
    + +

    Example 2:

    + +
    +Input: s = "bb"
    +Output: 1
    +Explanation: An optimal solution is to choose "b" (the first character) for the 1st subsequence and "b" (the second character) for the 2nd subsequence.
    +The product of their lengths is: 1 * 1 = 1.
    +
    + +

    Example 3:

    + +
    +Input: s = "accbcaxxcxx"
    +Output: 25
    +Explanation: An optimal solution is to choose "accca" for the 1st subsequence and "xxcxx" for the 2nd subsequence.
    +The product of their lengths is: 5 * 5 = 25.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= s.length <= 12
    • +
    • s consists of lowercase English letters only.
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] + +### Hints +
    +Hint 1 +Could you generate all possible pairs of disjoint subsequences? +
    + +
    +Hint 2 +Could you find the maximum length palindrome in each subsequence for a pair of disjoint subsequences? +
    diff --git a/problems/maximum-xor-of-two-numbers-in-an-array/README.md b/problems/maximum-xor-of-two-numbers-in-an-array/README.md index 92757b424..2457f9950 100644 --- a/problems/maximum-xor-of-two-numbers-in-an-array/README.md +++ b/problems/maximum-xor-of-two-numbers-in-an-array/README.md @@ -58,7 +58,10 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] - [[Trie](../../tag/trie/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Trie](../../tag/trie/README.md)] + +### Similar Questions + 1. [Maximum XOR With an Element From Array](../maximum-xor-with-an-element-from-array) (Hard) diff --git a/problems/min-cost-to-connect-all-points/README.md b/problems/min-cost-to-connect-all-points/README.md index 9000431ca..02ad17018 100644 --- a/problems/min-cost-to-connect-all-points/README.md +++ b/problems/min-cost-to-connect-all-points/README.md @@ -69,8 +69,8 @@ Notice that there is a unique path between every pair of points. ### Related Topics - [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] + [[Union Find](../../tag/union-find/README.md)] [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] ### Hints diff --git a/problems/minimum-add-to-make-parentheses-valid/README.md b/problems/minimum-add-to-make-parentheses-valid/README.md index 79477452d..b03b231d9 100644 --- a/problems/minimum-add-to-make-parentheses-valid/README.md +++ b/problems/minimum-add-to-make-parentheses-valid/README.md @@ -65,6 +65,9 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[String](../../tag/string/README.md)] + +### Similar Questions + 1. [Minimum Number of Swaps to Make the String Balanced](../minimum-number-of-swaps-to-make-the-string-balanced) (Medium) diff --git a/problems/minimum-cost-to-connect-two-groups-of-points/README.md b/problems/minimum-cost-to-connect-two-groups-of-points/README.md index cc6a19f95..7d2218d62 100644 --- a/problems/minimum-cost-to-connect-two-groups-of-points/README.md +++ b/problems/minimum-cost-to-connect-two-groups-of-points/README.md @@ -62,11 +62,11 @@ Note that there are multiple points connected to point 2 in the first group and ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Bitmask](../../tag/bitmask/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Matrix](../../tag/matrix/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/minimum-cost-to-hire-k-workers/README.md b/problems/minimum-cost-to-hire-k-workers/README.md index b0c664f3b..388c7e447 100644 --- a/problems/minimum-cost-to-hire-k-workers/README.md +++ b/problems/minimum-cost-to-hire-k-workers/README.md @@ -49,7 +49,7 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/README.md b/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/README.md index 3a3ecc6b7..b9e329ac7 100644 --- a/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/README.md +++ b/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/README.md @@ -77,12 +77,12 @@ The total cost = 3. ### Related Topics + [[Array](../../tag/array/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] - [[Array](../../tag/array/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Shortest Path](../../tag/shortest-path/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/minimum-cost-to-move-chips-to-the-same-position/README.md b/problems/minimum-cost-to-move-chips-to-the-same-position/README.md index 27009f7be..66e1937ff 100644 --- a/problems/minimum-cost-to-move-chips-to-the-same-position/README.md +++ b/problems/minimum-cost-to-move-chips-to-the-same-position/README.md @@ -57,9 +57,12 @@ Total cost is 1. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Similar Questions + 1. [Minimum Number of Operations to Move All Balls to Each Box](../minimum-number-of-operations-to-move-all-balls-to-each-box) (Medium) ### Hints
    diff --git a/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md b/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md index 8f02e64a0..07780cb5d 100644 --- a/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md +++ b/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md @@ -53,10 +53,10 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md b/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md index c97912c97..07461cb07 100644 --- a/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md +++ b/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md @@ -56,8 +56,8 @@ The difference between the maximum and minimum is 1-0 = 1. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/minimum-insertions-to-balance-a-parentheses-string/README.md b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md index 540c98995..c55b8793d 100644 --- a/problems/minimum-insertions-to-balance-a-parentheses-string/README.md +++ b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md @@ -76,9 +76,12 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[String](../../tag/string/README.md)] + +### Similar Questions + 1. [Minimum Number of Swaps to Make the String Balanced](../minimum-number-of-swaps-to-make-the-string-balanced) (Medium) ### Hints
    diff --git a/problems/minimum-number-of-arrows-to-burst-balloons/README.md b/problems/minimum-number-of-arrows-to-burst-balloons/README.md index 2914390b1..592359a87 100644 --- a/problems/minimum-number-of-arrows-to-burst-balloons/README.md +++ b/problems/minimum-number-of-arrows-to-burst-balloons/README.md @@ -11,11 +11,11 @@ ## [452. Minimum Number of Arrows to Burst Balloons (Medium)](https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons "用最少数量的箭引爆气球") -

    There are some spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal, y-coordinates don't matter, and hence the x-coordinates of start and end of the diameter suffice. The start is always smaller than the end.

    +

    There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array points where points[i] = [xstart, xend] denotes a balloon whose horizontal diameter stretches between xstart and xend. You do not know the exact y-coordinates of the balloons.

    -

    An arrow can be shot up exactly vertically from different points along the x-axis. A balloon with xstart and xend bursts by an arrow shot at x if xstart ≤ x ≤ xend. There is no limit to the number of arrows that can be shot. An arrow once shot keeps traveling up infinitely.

    +

    Arrows can be shot up directly vertically (in the positive y-direction) from different points along the x-axis. A balloon with xstart and xend is burst by an arrow shot at x if xstart <= x <= xend. There is no limit to the number of arrows that can be shot. A shot arrow keeps traveling up infinitely, bursting any balloons in its path.

    -

    Given an array points where points[i] = [xstart, xend], return the minimum number of arrows that must be shot to burst all balloons.

    +

    Given the array points, return the minimum number of arrows that must be shot to burst all balloons.

     

    Example 1:

    @@ -23,7 +23,9 @@
     Input: points = [[10,16],[2,8],[1,6],[7,12]]
     Output: 2
    -Explanation: One way is to shoot one arrow for example at x = 6 (bursting the balloons [2,8] and [1,6]) and another arrow at x = 11 (bursting the other two balloons).
    +Explanation: The balloons can be burst by 2 arrows:
    +- Shoot an arrow at x = 6, bursting the balloons [2,8] and [1,6].
    +- Shoot an arrow at x = 11, bursting the balloons [10,16] and [7,12].
     

    Example 2:

    @@ -31,6 +33,7 @@
     Input: points = [[1,2],[3,4],[5,6],[7,8]]
     Output: 4
    +Explanation: One arrow needs to be shot for each balloon for a total of 4 arrows.
     

    Example 3:

    @@ -38,6 +41,9 @@
     Input: points = [[1,2],[2,3],[3,4],[4,5]]
     Output: 2
    +Explanation: The balloons can be burst by 2 arrows:
    +- Shoot an arrow at x = 2, bursting the balloons [1,2] and [2,3].
    +- Shoot an arrow at x = 4, bursting the balloons [3,4] and [4,5].
     

     

    diff --git a/problems/minimum-number-of-days-to-disconnect-island/README.md b/problems/minimum-number-of-days-to-disconnect-island/README.md index 0031b010e..5ae12e99d 100644 --- a/problems/minimum-number-of-days-to-disconnect-island/README.md +++ b/problems/minimum-number-of-days-to-disconnect-island/README.md @@ -75,9 +75,9 @@ Change land grid[1][1] and grid[0][2] to water and get 2 disconnected island. ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Strongly Connected Component](../../tag/strongly-connected-component/README.md)] diff --git a/problems/minimum-number-of-days-to-eat-n-oranges/README.md b/problems/minimum-number-of-days-to-eat-n-oranges/README.md index 60db7f364..a6032a7a1 100644 --- a/problems/minimum-number-of-days-to-eat-n-oranges/README.md +++ b/problems/minimum-number-of-days-to-eat-n-oranges/README.md @@ -71,8 +71,8 @@ You need at least 3 days to eat the 6 oranges. ### Related Topics - [[Memoization](../../tag/memoization/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Memoization](../../tag/memoization/README.md)] ### Hints
    diff --git a/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md b/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md index 6eee1afbf..e7067938d 100644 --- a/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md +++ b/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md @@ -62,9 +62,9 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md b/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md index 56541581e..275f1e4fb 100644 --- a/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md +++ b/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md @@ -65,10 +65,10 @@ The answer is guaranteed to fit within the range of a 32-bit signed integer. ### Related Topics - [[Stack](../../tag/stack/README.md)] - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints diff --git a/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md b/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md index fdf8008a6..a4d10b03d 100644 --- a/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md +++ b/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md @@ -69,6 +69,9 @@ [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Determine if Two Strings Are Close](../determine-if-two-strings-are-close) (Medium) + ### Hints
    Hint 1 diff --git a/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md b/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md index 21ee9a594..0dfac9e44 100644 --- a/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md +++ b/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md @@ -72,8 +72,8 @@ Total of operations: 2 + 1 = 3. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md b/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md index 364006cb0..6c894f63b 100644 --- a/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md +++ b/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md @@ -66,10 +66,10 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] - [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/minimum-subsequence-in-non-increasing-order/README.md b/problems/minimum-subsequence-in-non-increasing-order/README.md index 1f88685e9..d93029247 100644 --- a/problems/minimum-subsequence-in-non-increasing-order/README.md +++ b/problems/minimum-subsequence-in-non-increasing-order/README.md @@ -50,8 +50,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/minimum-swaps-to-arrange-a-binary-grid/README.md b/problems/minimum-swaps-to-arrange-a-binary-grid/README.md index dd28d43d6..95ceaeb03 100644 --- a/problems/minimum-swaps-to-arrange-a-binary-grid/README.md +++ b/problems/minimum-swaps-to-arrange-a-binary-grid/README.md @@ -53,8 +53,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/nim-game/README.md b/problems/nim-game/README.md index 777bf5b83..cd1f0de38 100644 --- a/problems/nim-game/README.md +++ b/problems/nim-game/README.md @@ -57,8 +57,8 @@ In all outcomes, your friend wins. ### Related Topics - [[Brainteaser](../../tag/brainteaser/README.md)] [[Math](../../tag/math/README.md)] + [[Brainteaser](../../tag/brainteaser/README.md)] [[Game Theory](../../tag/game-theory/README.md)] ### Similar Questions diff --git a/problems/number-of-islands-ii/README.md b/problems/number-of-islands-ii/README.md index d11faa469..8abb898ae 100644 --- a/problems/number-of-islands-ii/README.md +++ b/problems/number-of-islands-ii/README.md @@ -67,8 +67,8 @@

    Can you do it in time complexity O(k log mn), where k is the length of the positions?

    ### Related Topics - [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] + [[Union Find](../../tag/union-find/README.md)] ### Similar Questions 1. [Number of Islands](../number-of-islands) (Medium) diff --git a/problems/number-of-pairs-of-interchangeable-rectangles/README.md b/problems/number-of-pairs-of-interchangeable-rectangles/README.md new file mode 100644 index 000000000..ec9f4bd47 --- /dev/null +++ b/problems/number-of-pairs-of-interchangeable-rectangles/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../reverse-prefix-of-word "Reverse Prefix of Word") +                 +[Next >](../maximum-product-of-the-length-of-two-palindromic-subsequences "Maximum Product of the Length of Two Palindromic Subsequences") + +## [2001. Number of Pairs of Interchangeable Rectangles (Medium)](https://leetcode.com/problems/number-of-pairs-of-interchangeable-rectangles "可互换矩形的组数") + +

    You are given n rectangles represented by a 0-indexed 2D integer array rectangles, where rectangles[i] = [widthi, heighti] denotes the width and height of the ith rectangle.

    + +

    Two rectangles i and j (i < j) are considered interchangeable if they have the same width-to-height ratio. More formally, two rectangles are interchangeable if widthi/heighti == widthj/heightj (using decimal division, not integer division).

    + +

    Return the number of pairs of interchangeable rectangles in rectangles.

    + +

     

    +

    Example 1:

    + +
    +Input: rectangles = [[4,8],[3,6],[10,20],[15,30]]
    +Output: 6
    +Explanation: The following are the interchangeable pairs of rectangles by index (0-indexed):
    +- Rectangle 0 with rectangle 1: 4/8 == 3/6.
    +- Rectangle 0 with rectangle 2: 4/8 == 10/20.
    +- Rectangle 0 with rectangle 3: 4/8 == 15/30.
    +- Rectangle 1 with rectangle 2: 3/6 == 10/20.
    +- Rectangle 1 with rectangle 3: 3/6 == 15/30.
    +- Rectangle 2 with rectangle 3: 10/20 == 15/30.
    +
    + +

    Example 2:

    + +
    +Input: rectangles = [[4,5],[7,8]]
    +Output: 0
    +Explanation: There are no interchangeable pairs of rectangles.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == rectangles.length
    • +
    • 1 <= n <= 105
    • +
    • rectangles[i].length == 2
    • +
    • 1 <= widthi, heighti <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Number Theory](../../tag/number-theory/README.md)] + +### Hints +
    +Hint 1 +Store the rectangle height and width ratio in a hashmap. +
    + +
    +Hint 2 +Traverse the ratios, and for each ratio, use the frequency of the ratio to add to the total pair count. +
    diff --git a/problems/number-of-steps-to-reduce-a-number-to-zero/README.md b/problems/number-of-steps-to-reduce-a-number-to-zero/README.md index 911b06fb1..ea8c7d76e 100644 --- a/problems/number-of-steps-to-reduce-a-number-to-zero/README.md +++ b/problems/number-of-steps-to-reduce-a-number-to-zero/README.md @@ -57,8 +57,8 @@ Step 4) 1 is odd; subtract 1 and obtain 0. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/number-of-substrings-with-only-1s/README.md b/problems/number-of-substrings-with-only-1s/README.md index 6a94618ce..920f3d034 100644 --- a/problems/number-of-substrings-with-only-1s/README.md +++ b/problems/number-of-substrings-with-only-1s/README.md @@ -63,6 +63,9 @@ [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Count Number of Homogenous Substrings](../count-number-of-homogenous-substrings) (Medium) + ### Hints
    Hint 1 diff --git a/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md b/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md index b6ad2d6f1..e4f095b6d 100644 --- a/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md +++ b/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md @@ -82,16 +82,16 @@ ### Related Topics - [[Tree](../../tag/tree/README.md)] - [[Union Find](../../tag/union-find/README.md)] - [[Binary Search Tree](../../tag/binary-search-tree/README.md)] - [[Memoization](../../tag/memoization/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Binary Tree](../../tag/binary-tree/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Memoization](../../tag/memoization/README.md)] [[Combinatorics](../../tag/combinatorics/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/number-of-ways-to-split-a-string/README.md b/problems/number-of-ways-to-split-a-string/README.md index 5d6b30520..a9616a150 100644 --- a/problems/number-of-ways-to-split-a-string/README.md +++ b/problems/number-of-ways-to-split-a-string/README.md @@ -67,6 +67,9 @@ [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Split Array with Equal Sum](../split-array-with-equal-sum) (Hard) + ### Hints
    Hint 1 diff --git a/problems/numbers-with-same-consecutive-differences/README.md b/problems/numbers-with-same-consecutive-differences/README.md index 0b47b74d0..eb5735c58 100644 --- a/problems/numbers-with-same-consecutive-differences/README.md +++ b/problems/numbers-with-same-consecutive-differences/README.md @@ -56,5 +56,5 @@ ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] diff --git a/problems/operations-on-tree/README.md b/problems/operations-on-tree/README.md new file mode 100644 index 000000000..035f3dcc7 --- /dev/null +++ b/problems/operations-on-tree/README.md @@ -0,0 +1,92 @@ + + + + + + + +[< Previous](../find-all-groups-of-farmland "Find All Groups of Farmland") +                 +[Next >](../the-number-of-good-subsets "The Number of Good Subsets") + +## [1993. Operations on Tree (Medium)](https://leetcode.com/problems/operations-on-tree "树上的操作") + +

    You are given a tree with n nodes numbered from 0 to n - 1 in the form of a parent array parent where parent[i] is the parent of the ith node. The root of the tree is node 0, so parent[0] = -1 since it has no parent. You want to design a data structure that allows users to lock, unlock, and upgrade nodes in the tree.

    + +

    The data structure should support the following functions:

    + +
      +
    • Lock: Locks the given node for the given user and prevents other users from locking the same node. You may only lock a node if the node is unlocked.
    • +
    • Unlock: Unlocks the given node for the given user. You may only unlock a node if it is currently locked by the same user.
    • +
    • Upgrade: Locks the given node for the given user and unlocks all of its descendants. You may only upgrade a node if all 3 conditions are true: +
        +
      • The node is unlocked,
      • +
      • It has at least one locked descendant (by any user), and
      • +
      • It does not have any locked ancestors.
      • +
      +
    • +
    + +

    Implement the LockingTree class:

    + +
      +
    • LockingTree(int[] parent) initializes the data structure with the parent array.
    • +
    • lock(int num, int user) returns true if it is possible for the user with id user to lock the node num, or false otherwise. If it is possible, the node num will become locked by the user with id user.
    • +
    • unlock(int num, int user) returns true if it is possible for the user with id user to unlock the node num, or false otherwise. If it is possible, the node num will become unlocked.
    • +
    • upgrade(int num, int user) returns true if it is possible for the user with id user to upgrade the node num, or false otherwise. If it is possible, the node num will be upgraded.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input
    +["LockingTree", "lock", "unlock", "unlock", "lock", "upgrade", "lock"]
    +[[[-1, 0, 0, 1, 1, 2, 2]], [2, 2], [2, 3], [2, 2], [4, 5], [0, 1], [0, 1]]
    +Output
    +[null, true, false, true, true, true, false]
    +
    +Explanation
    +LockingTree lockingTree = new LockingTree([-1, 0, 0, 1, 1, 2, 2]);
    +lockingTree.lock(2, 2);    // return true because node 2 is unlocked.
    +                           // Node 2 will now be locked by user 2.
    +lockingTree.unlock(2, 3);  // return false because user 3 cannot unlock a node locked by user 2.
    +lockingTree.unlock(2, 2);  // return true because node 2 was previously locked by user 2.
    +                           // Node 2 will now be unlocked.
    +lockingTree.lock(4, 5);    // return true because node 4 is unlocked.
    +                           // Node 4 will now be locked by user 5.
    +lockingTree.upgrade(0, 1); // return true because node 0 is unlocked and has at least one locked descendant (node 4).
    +                           // Node 0 will now be locked by user 1 and node 4 will now be unlocked.
    +lockingTree.lock(0, 1);    // return false because node 0 is already locked.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == parent.length
    • +
    • 2 <= n <= 2000
    • +
    • 0 <= parent[i] <= n - 1 for i != 0
    • +
    • parent[0] == -1
    • +
    • 0 <= num <= n - 1
    • +
    • 1 <= user <= 104
    • +
    • parent represents a valid tree.
    • +
    • At most 2000 calls in total will be made to lock, unlock, and upgrade.
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +How can we use the small constraints to help us solve the problem? +
    + +
    +Hint 2 +How can we traverse the ancestors and descendants of a node? +
    diff --git a/problems/path-with-maximum-probability/README.md b/problems/path-with-maximum-probability/README.md index ba83dc8d4..0e7bf7148 100644 --- a/problems/path-with-maximum-probability/README.md +++ b/problems/path-with-maximum-probability/README.md @@ -63,8 +63,11 @@ ### Related Topics [[Graph](../../tag/graph/README.md)] - [[Shortest Path](../../tag/shortest-path/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] + +### Similar Questions + 1. [Number of Ways to Arrive at Destination](../number-of-ways-to-arrive-at-destination) (Medium) ### Hints
    diff --git a/problems/path-with-minimum-effort/README.md b/problems/path-with-minimum-effort/README.md index f86467458..87fb8141a 100644 --- a/problems/path-with-minimum-effort/README.md +++ b/problems/path-with-minimum-effort/README.md @@ -58,13 +58,17 @@ This is better than the route of [1,2,2,2,5], where the maximum absolute differe ### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] - [[Matrix](../../tag/matrix/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Similar Questions + 1. [Swim in Rising Water](../swim-in-rising-water) (Hard) + 1. [Path With Maximum Minimum Value](../path-with-maximum-minimum-value) (Medium) ### Hints
    diff --git a/problems/percentage-of-users-attended-a-contest/README.md b/problems/percentage-of-users-attended-a-contest/README.md index ed363bcbd..9afe97740 100644 --- a/problems/percentage-of-users-attended-a-contest/README.md +++ b/problems/percentage-of-users-attended-a-contest/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Queries Quality and Percentage](../queries-quality-and-percentage) (Easy) diff --git a/problems/power-of-four/README.md b/problems/power-of-four/README.md index ce79b5a6d..715bce265 100644 --- a/problems/power-of-four/README.md +++ b/problems/power-of-four/README.md @@ -37,9 +37,9 @@ Follow up: Could you solve it without loops/recursion? ### Related Topics + [[Math](../../tag/math/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Recursion](../../tag/recursion/README.md)] - [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Power of Two](../power-of-two) (Easy) diff --git a/problems/put-boxes-into-the-warehouse-i/README.md b/problems/put-boxes-into-the-warehouse-i/README.md index b285a7652..58ec067a0 100644 --- a/problems/put-boxes-into-the-warehouse-i/README.md +++ b/problems/put-boxes-into-the-warehouse-i/README.md @@ -14,10 +14,13 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Put Boxes Into the Warehouse II](../put-boxes-into-the-warehouse-ii) (Medium) + ### Hints
    Hint 1 diff --git a/problems/put-boxes-into-the-warehouse-ii/README.md b/problems/put-boxes-into-the-warehouse-ii/README.md index 0783da49d..ace8988c8 100644 --- a/problems/put-boxes-into-the-warehouse-ii/README.md +++ b/problems/put-boxes-into-the-warehouse-ii/README.md @@ -14,10 +14,13 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Put Boxes Into the Warehouse I](../put-boxes-into-the-warehouse-i) (Medium) + ### Hints
    Hint 1 diff --git a/problems/range-sum-query-immutable/README.md b/problems/range-sum-query-immutable/README.md index 87424afbe..db9ae983d 100644 --- a/problems/range-sum-query-immutable/README.md +++ b/problems/range-sum-query-immutable/README.md @@ -52,8 +52,8 @@ numArray.sumRange(0, 5); // return (-2) + 0 + 3 + (-5) + 2 + (-1) = -3 ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] + [[Design](../../tag/design/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Similar Questions diff --git a/problems/rank-teams-by-votes/README.md b/problems/rank-teams-by-votes/README.md index 3f75fb7e4..1a25fb7a8 100644 --- a/problems/rank-teams-by-votes/README.md +++ b/problems/rank-teams-by-votes/README.md @@ -83,8 +83,11 @@ There is a tie and we rank teams ascending by their IDs. [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Counting](../../tag/counting/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Similar Questions + 1. [Online Election](../online-election) (Medium) ### Hints
    diff --git a/problems/rank-transform-of-a-matrix/README.md b/problems/rank-transform-of-a-matrix/README.md index 5ae4ddfcf..bd173f55f 100644 --- a/problems/rank-transform-of-a-matrix/README.md +++ b/problems/rank-transform-of-a-matrix/README.md @@ -74,13 +74,17 @@ The rank of matrix[1][1] is 3 because matrix[1][1] > matrix[0][1], matrix[1][ ### Related Topics + [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Rank Transform of an Array](../rank-transform-of-an-array) (Easy) + 1. [GCD Sort of an Array](../gcd-sort-of-an-array) (Hard) + ### Hints
    Hint 1 diff --git a/problems/rearrange-spaces-between-words/README.md b/problems/rearrange-spaces-between-words/README.md index 7705a8c6b..4e8a32046 100644 --- a/problems/rearrange-spaces-between-words/README.md +++ b/problems/rearrange-spaces-between-words/README.md @@ -67,6 +67,9 @@ ### Related Topics [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Text Justification](../text-justification) (Hard) + ### Hints
    Hint 1 diff --git a/problems/reduce-array-size-to-the-half/README.md b/problems/reduce-array-size-to-the-half/README.md index a5ff65836..9bd2bdd1e 100644 --- a/problems/reduce-array-size-to-the-half/README.md +++ b/problems/reduce-array-size-to-the-half/README.md @@ -65,9 +65,9 @@ Choosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/remove-all-adjacent-duplicates-in-string-ii/README.md b/problems/remove-all-adjacent-duplicates-in-string-ii/README.md index cafcb86af..9eebcb21b 100644 --- a/problems/remove-all-adjacent-duplicates-in-string-ii/README.md +++ b/problems/remove-all-adjacent-duplicates-in-string-ii/README.md @@ -52,8 +52,11 @@ Finally delete "ddd", get "aa" ### Related Topics - [[Stack](../../tag/stack/README.md)] [[String](../../tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] + +### Similar Questions + 1. [Remove All Adjacent Duplicates In String](../remove-all-adjacent-duplicates-in-string) (Easy) ### Hints
    diff --git a/problems/remove-duplicates-from-sorted-list-ii/README.md b/problems/remove-duplicates-from-sorted-list-ii/README.md index 23c18038d..5552c9248 100644 --- a/problems/remove-duplicates-from-sorted-list-ii/README.md +++ b/problems/remove-duplicates-from-sorted-list-ii/README.md @@ -43,3 +43,4 @@ ### Similar Questions 1. [Remove Duplicates from Sorted List](../remove-duplicates-from-sorted-list) (Easy) + 1. [Remove Duplicates From an Unsorted Linked List](../remove-duplicates-from-an-unsorted-linked-list) (Medium) diff --git a/problems/reverse-prefix-of-word/README.md b/problems/reverse-prefix-of-word/README.md new file mode 100644 index 000000000..0ac3b4e21 --- /dev/null +++ b/problems/reverse-prefix-of-word/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../smallest-greater-multiple-made-of-two-digits "Smallest Greater Multiple Made of Two Digits") +                 +[Next >](../number-of-pairs-of-interchangeable-rectangles "Number of Pairs of Interchangeable Rectangles") + +## [2000. Reverse Prefix of Word (Easy)](https://leetcode.com/problems/reverse-prefix-of-word "反转单词前缀") + +

    Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive). If the character ch does not exist in word, do nothing.

    + +
      +
    • For example, if word = "abcdefd" and ch = "d", then you should reverse the segment that starts at 0 and ends at 3 (inclusive). The resulting string will be "dcbaefd".
    • +
    + +

    Return the resulting string.

    + +

     

    +

    Example 1:

    + +
    +Input: word = "abcdefd", ch = "d"
    +Output: "dcbaefd"
    +Explanation: The first occurrence of "d" is at index 3. 
    +Reverse the part of word from 0 to 3 (inclusive), the resulting string is "dcbaefd".
    +
    + +

    Example 2:

    + +
    +Input: word = "xyxzxe", ch = "z"
    +Output: "zxyxxe"
    +Explanation: The first and only occurrence of "z" is at index 3.
    +Reverse the part of word from 0 to 3 (inclusive), the resulting string is "zxyxxe".
    +
    + +

    Example 3:

    + +
    +Input: word = "abcd", ch = "z"
    +Output: "abcd"
    +Explanation: "z" does not exist in word.
    +You should not do any reverse operation, the resulting string is "abcd".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= word.length <= 250
    • +
    • word consists of lowercase English letters.
    • +
    • ch is a lowercase English letter.
    • +
    + +### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Find the first index where ch appears. +
    + +
    +Hint 2 +Find a way to reverse a substring of word. +
    diff --git a/problems/robot-room-cleaner/README.md b/problems/robot-room-cleaner/README.md index 9e0a3c292..8cdff14fe 100644 --- a/problems/robot-room-cleaner/README.md +++ b/problems/robot-room-cleaner/README.md @@ -73,3 +73,5 @@ From the top left corner, its position is one row below and three columns right. ### Similar Questions 1. [Walls and Gates](../walls-and-gates) (Medium) + 1. [Shortest Path in a Hidden Grid](../shortest-path-in-a-hidden-grid) (Medium) + 1. [Minimum Path Cost in a Hidden Grid](../minimum-path-cost-in-a-hidden-grid) (Medium) diff --git a/problems/russian-doll-envelopes/README.md b/problems/russian-doll-envelopes/README.md index 6da9f5234..de6f285d3 100644 --- a/problems/russian-doll-envelopes/README.md +++ b/problems/russian-doll-envelopes/README.md @@ -52,3 +52,4 @@ ### Similar Questions 1. [Longest Increasing Subsequence](../longest-increasing-subsequence) (Medium) + 1. [The Number of Weak Characters in the Game](../the-number-of-weak-characters-in-the-game) (Medium) diff --git a/problems/sales-analysis-i/README.md b/problems/sales-analysis-i/README.md index ff2769a67..df00fb03c 100644 --- a/problems/sales-analysis-i/README.md +++ b/problems/sales-analysis-i/README.md @@ -78,3 +78,6 @@ Both sellers with id 1 and 3 sold products with the most total price of 2800.

    seqs parameter had been changed to a list of list of strings (instead

    ### Related Topics + [[Array](../../tag/array/README.md)] [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] - [[Array](../../tag/array/README.md)] ### Similar Questions 1. [Course Schedule II](../course-schedule-ii) (Medium) diff --git a/problems/serialize-and-deserialize-binary-tree/README.md b/problems/serialize-and-deserialize-binary-tree/README.md index 8e0772a1f..4160e5f76 100644 --- a/problems/serialize-and-deserialize-binary-tree/README.md +++ b/problems/serialize-and-deserialize-binary-tree/README.md @@ -55,11 +55,11 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Design](../../tag/design/README.md)] - [[String](../../tag/string/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md b/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md index f16fe056d..fac216680 100644 --- a/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md +++ b/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md @@ -58,10 +58,10 @@ Another correct solution is to remove the subarray [3,10,4]. ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Stack](../../tag/stack/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints diff --git a/problems/simplified-fractions/README.md b/problems/simplified-fractions/README.md index eb7856621..7c4753dfc 100644 --- a/problems/simplified-fractions/README.md +++ b/problems/simplified-fractions/README.md @@ -11,7 +11,7 @@ ## [1447. Simplified Fractions (Medium)](https://leetcode.com/problems/simplified-fractions "最简分数") -

    Given an integer n, return a list of all simplified fractions between 0 and 1 (exclusive) such that the denominator is less-than-or-equal-to n. The fractions can be in any order.

    +

    Given an integer n, return a list of all simplified fractions between 0 and 1 (exclusive) such that the denominator is less-than-or-equal-to n. The fractions can be in any order.

     

    Example 1:

    diff --git a/problems/single-number/README.md b/problems/single-number/README.md index 29a154736..76ce1c6c1 100644 --- a/problems/single-number/README.md +++ b/problems/single-number/README.md @@ -36,8 +36,8 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Single Number II](../single-number-ii) (Medium) diff --git a/problems/sliding-window-maximum/README.md b/problems/sliding-window-maximum/README.md index 8958f8c30..9ba626b8d 100644 --- a/problems/sliding-window-maximum/README.md +++ b/problems/sliding-window-maximum/README.md @@ -70,17 +70,18 @@ Window position Max ### Related Topics - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] + [[Queue](../../tag/queue/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Monotonic Queue](../../tag/monotonic-queue/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] ### Similar Questions 1. [Minimum Window Substring](../minimum-window-substring) (Hard) 1. [Min Stack](../min-stack) (Easy) 1. [Longest Substring with At Most Two Distinct Characters](../longest-substring-with-at-most-two-distinct-characters) (Medium) 1. [Paint House II](../paint-house-ii) (Hard) + 1. [Jump Game VI](../jump-game-vi) (Medium) ### Hints
    diff --git a/problems/smallest-greater-multiple-made-of-two-digits/README.md b/problems/smallest-greater-multiple-made-of-two-digits/README.md new file mode 100644 index 000000000..28004337d --- /dev/null +++ b/problems/smallest-greater-multiple-made-of-two-digits/README.md @@ -0,0 +1,25 @@ + + + + + + + +[< Previous](../gcd-sort-of-an-array "GCD Sort of an Array") +                 +[Next >](../reverse-prefix-of-word "Reverse Prefix of Word") + +## [1999. Smallest Greater Multiple Made of Two Digits (Medium)](https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits "") + + + +### Hints +
    +Hint 1 +Could you generate all the different numbers comprised of only digit1 and digit2 with the constraints? +
    + +
    +Hint 2 +Going from least to greatest, check if the number you generated is greater than k and a multiple of k. +
    diff --git a/problems/smallest-missing-genetic-value-in-each-subtree/README.md b/problems/smallest-missing-genetic-value-in-each-subtree/README.md new file mode 100644 index 000000000..46e0ba16e --- /dev/null +++ b/problems/smallest-missing-genetic-value-in-each-subtree/README.md @@ -0,0 +1,85 @@ + + + + + + + +[< Previous](../maximum-product-of-the-length-of-two-palindromic-subsequences "Maximum Product of the Length of Two Palindromic Subsequences") +                 +[Next >](../the-number-of-seniors-and-juniors-to-join-the-company "The Number of Seniors and Juniors to Join the Company") + +## [2003. Smallest Missing Genetic Value in Each Subtree (Hard)](https://leetcode.com/problems/smallest-missing-genetic-value-in-each-subtree "每棵子树内缺失的最小基因值") + +

    There is a family tree rooted at 0 consisting of n nodes numbered 0 to n - 1. You are given a 0-indexed integer array parents, where parents[i] is the parent for node i. Since node 0 is the root, parents[0] == -1.

    + +

    There are 105 genetic values, each represented by an integer in the inclusive range [1, 105]. You are given a 0-indexed integer array nums, where nums[i] is a distinct genetic value for node i.

    + +

    Return an array ans of length n where ans[i] is the smallest genetic value that is missing from the subtree rooted at node i.

    + +

    The subtree rooted at a node x contains node x and all of its descendant nodes.

    + +

     

    +

    Example 1:

    + +
    +Input: parents = [-1,0,0,2], nums = [1,2,3,4]
    +Output: [5,1,1,1]
    +Explanation: The answer for each subtree is calculated as follows:
    +- 0: The subtree contains nodes [0,1,2,3] with values [1,2,3,4]. 5 is the smallest missing value.
    +- 1: The subtree contains only node 1 with value 2. 1 is the smallest missing value.
    +- 2: The subtree contains nodes [2,3] with values [3,4]. 1 is the smallest missing value.
    +- 3: The subtree contains only node 3 with value 4. 1 is the smallest missing value.
    +
    + +

    Example 2:

    + +
    +Input: parents = [-1,0,1,0,3,3], nums = [5,4,6,2,1,3]
    +Output: [7,1,1,4,2,1]
    +Explanation: The answer for each subtree is calculated as follows:
    +- 0: The subtree contains nodes [0,1,2,3,4,5] with values [5,4,6,2,1,3]. 7 is the smallest missing value.
    +- 1: The subtree contains nodes [1,2] with values [4,6]. 1 is the smallest missing value.
    +- 2: The subtree contains only node 2 with value 6. 1 is the smallest missing value.
    +- 3: The subtree contains nodes [3,4,5] with values [2,1,3]. 4 is the smallest missing value.
    +- 4: The subtree contains only node 4 with value 1. 2 is the smallest missing value.
    +- 5: The subtree contains only node 5 with value 3. 1 is the smallest missing value.
    +
    + +

    Example 3:

    + +
    +Input: parents = [-1,2,3,0,2,4,1], nums = [2,3,4,5,6,7,8]
    +Output: [1,1,1,1,1,1,1]
    +Explanation: The value 1 is missing from all the subtrees.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == parents.length == nums.length
    • +
    • 2 <= n <= 105
    • +
    • 0 <= parents[i] <= n - 1 for i != 0
    • +
    • parents[0] == -1
    • +
    • parents represents a valid tree.
    • +
    • 1 <= nums[i] <= 105
    • +
    • Each nums[i] is distinct.
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +If the subtree doesn't contain 1, then the missing value will always be 1. +
    + +
    +Hint 2 +What data structure allows us to dynamically update the values that are currently not present? +
    diff --git a/problems/sort-integers-by-the-number-of-1-bits/README.md b/problems/sort-integers-by-the-number-of-1-bits/README.md index d9bca208a..21a136eaf 100644 --- a/problems/sort-integers-by-the-number-of-1-bits/README.md +++ b/problems/sort-integers-by-the-number-of-1-bits/README.md @@ -66,10 +66,10 @@ The sorted array by bits is [0,1,2,4,8,3,5,6,7] ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] - [[Counting](../../tag/counting/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/stone-game-iv/README.md b/problems/stone-game-iv/README.md index 5777800a0..c55f7cdca 100644 --- a/problems/stone-game-iv/README.md +++ b/problems/stone-game-iv/README.md @@ -71,6 +71,12 @@ If Alice starts removing 1 stone, Bob will remove 4 stones then Alice only can r [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Game Theory](../../tag/game-theory/README.md)] +### Similar Questions + 1. [Stone Game V](../stone-game-v) (Hard) + 1. [Stone Game VI](../stone-game-vi) (Medium) + 1. [Stone Game VII](../stone-game-vii) (Medium) + 1. [Stone Game VIII](../stone-game-viii) (Hard) + ### Hints
    Hint 1 diff --git a/problems/stone-game-v/README.md b/problems/stone-game-v/README.md index 018a99134..0b872a65f 100644 --- a/problems/stone-game-v/README.md +++ b/problems/stone-game-v/README.md @@ -58,6 +58,15 @@ The last round Alice has only one choice to divide the row which is [2], [3]. Bo [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Game Theory](../../tag/game-theory/README.md)] +### Similar Questions + 1. [Stone Game](../stone-game) (Medium) + 1. [Stone Game II](../stone-game-ii) (Medium) + 1. [Stone Game III](../stone-game-iii) (Hard) + 1. [Stone Game IV](../stone-game-iv) (Hard) + 1. [Stone Game VI](../stone-game-vi) (Medium) + 1. [Stone Game VII](../stone-game-vii) (Medium) + 1. [Stone Game VIII](../stone-game-viii) (Hard) + ### Hints
    Hint 1 diff --git a/problems/strings-differ-by-one-character/README.md b/problems/strings-differ-by-one-character/README.md index 6fea70d9f..5df75f6d3 100644 --- a/problems/strings-differ-by-one-character/README.md +++ b/problems/strings-differ-by-one-character/README.md @@ -16,8 +16,8 @@ ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Hash Function](../../tag/hash-function/README.md)] [[Rolling Hash](../../tag/rolling-hash/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Hints
    diff --git a/problems/subarray-sum-equals-k/README.md b/problems/subarray-sum-equals-k/README.md index ade722bf9..9ef04912b 100644 --- a/problems/subarray-sum-equals-k/README.md +++ b/problems/subarray-sum-equals-k/README.md @@ -9,7 +9,7 @@                  [Next >](../array-partition-i "Array Partition I") -## [560. Subarray Sum Equals K (Medium)](https://leetcode.com/problems/subarray-sum-equals-k "和为K的子数组") +## [560. Subarray Sum Equals K (Medium)](https://leetcode.com/problems/subarray-sum-equals-k "和为 K 的子数组")

    Given an array of integers nums and an integer k, return the total number of continuous subarrays whose sum equals to k.

    diff --git a/problems/subrectangle-queries/README.md b/problems/subrectangle-queries/README.md index 0166968e1..3f4bd973f 100644 --- a/problems/subrectangle-queries/README.md +++ b/problems/subrectangle-queries/README.md @@ -94,8 +94,8 @@ subrectangleQueries.getValue(2, 2); // return 20 ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] + [[Design](../../tag/design/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/sum-of-all-odd-length-subarrays/README.md b/problems/sum-of-all-odd-length-subarrays/README.md index ffc585067..33302a523 100644 --- a/problems/sum-of-all-odd-length-subarrays/README.md +++ b/problems/sum-of-all-odd-length-subarrays/README.md @@ -59,6 +59,7 @@ If we add all these together we get 1 + 4 + 2 + 5 + 3 + 7 + 11 + 10 + 15 = 58

    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Counting](../../tag/counting/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Counting](../../tag/counting/README.md)] ### Similar Questions 1. [Rearrange String k Distance Apart](../rearrange-string-k-distance-apart) (Hard) 1. [Reorganize String](../reorganize-string) (Medium) + 1. [Maximum Number of Weeks for Which You Can Work](../maximum-number-of-weeks-for-which-you-can-work) (Medium) diff --git a/problems/the-maze-iii/README.md b/problems/the-maze-iii/README.md index 859b10015..70b739207 100644 --- a/problems/the-maze-iii/README.md +++ b/problems/the-maze-iii/README.md @@ -77,8 +77,8 @@ Both ways have shortest distance 6, but the first way is lexicographically small [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] - [[Shortest Path](../../tag/shortest-path/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] ### Similar Questions 1. [The Maze](../the-maze) (Medium) diff --git a/problems/the-most-frequently-ordered-products-for-each-customer/README.md b/problems/the-most-frequently-ordered-products-for-each-customer/README.md index dce0cb341..37dcda904 100644 --- a/problems/the-most-frequently-ordered-products-for-each-customer/README.md +++ b/problems/the-most-frequently-ordered-products-for-each-customer/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [The Most Recent Orders for Each Product](../the-most-recent-orders-for-each-product) (Medium) diff --git a/problems/the-most-recent-orders-for-each-product/README.md b/problems/the-most-recent-orders-for-each-product/README.md index 0510140e3..bfc7647a8 100644 --- a/problems/the-most-recent-orders-for-each-product/README.md +++ b/problems/the-most-recent-orders-for-each-product/README.md @@ -15,3 +15,7 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [The Most Recent Three Orders](../the-most-recent-three-orders) (Medium) + 1. [The Most Frequently Ordered Products for Each Customer](../the-most-frequently-ordered-products-for-each-customer) (Medium) diff --git a/problems/the-most-recent-three-orders/README.md b/problems/the-most-recent-three-orders/README.md index 6aac9ec6b..83b306e13 100644 --- a/problems/the-most-recent-three-orders/README.md +++ b/problems/the-most-recent-three-orders/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [The Most Recent Orders for Each Product](../the-most-recent-orders-for-each-product) (Medium) diff --git a/problems/the-most-similar-path-in-a-graph/README.md b/problems/the-most-similar-path-in-a-graph/README.md index 42400599b..3a95c19ae 100644 --- a/problems/the-most-similar-path-in-a-graph/README.md +++ b/problems/the-most-similar-path-in-a-graph/README.md @@ -14,8 +14,8 @@ ### Related Topics - [[Graph](../../tag/graph/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Graph](../../tag/graph/README.md)] ### Hints
    diff --git a/problems/the-number-of-good-subsets/README.md b/problems/the-number-of-good-subsets/README.md new file mode 100644 index 000000000..a49615a4b --- /dev/null +++ b/problems/the-number-of-good-subsets/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../operations-on-tree "Operations on Tree") +                 +[Next >](../count-special-quadruplets "Count Special Quadruplets") + +## [1994. The Number of Good Subsets (Hard)](https://leetcode.com/problems/the-number-of-good-subsets "好子集的数目") + +

    You are given an integer array nums. We call a subset of nums good if its product can be represented as a product of one or more distinct prime numbers.

    + +
      +
    • For example, if nums = [1, 2, 3, 4]: +
        +
      • [2, 3], [1, 2, 3], and [1, 3] are good subsets with products 6 = 2*3, 6 = 2*3, and 3 = 3 respectively.
      • +
      • [1, 4] and [4] are not good subsets with products 4 = 2*2 and 4 = 2*2 respectively.
      • +
      +
    • +
    + +

    Return the number of different good subsets in nums modulo 109 + 7.

    + +

    A subset of nums is any array that can be obtained by deleting some (possibly none or all) elements from nums. Two subsets are different if and only if the chosen indices to delete are different.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3,4]
    +Output: 6
    +Explanation: The good subsets are:
    +- [1,2]: product is 2, which is the product of distinct prime 2.
    +- [1,2,3]: product is 6, which is the product of distinct primes 2 and 3.
    +- [1,3]: product is 3, which is the product of distinct prime 3.
    +- [2]: product is 2, which is the product of distinct prime 2.
    +- [2,3]: product is 6, which is the product of distinct primes 2 and 3.
    +- [3]: product is 3, which is the product of distinct prime 3.
    +
    + +

    Example 2:

    + +
    +Input: nums = [4,2,3,15]
    +Output: 5
    +Explanation: The good subsets are:
    +- [2]: product is 2, which is the product of distinct prime 2.
    +- [2,3]: product is 6, which is the product of distinct primes 2 and 3.
    +- [2,15]: product is 30, which is the product of distinct primes 2, 3, and 5.
    +- [3]: product is 3, which is the product of distinct prime 3.
    +- [15]: product is 15, which is the product of distinct primes 3 and 5.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 30
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] + +### Hints +
    +Hint 1 +Consider only the numbers which have a good prime factorization. +
    + +
    +Hint 2 +Use brute force to find all possible good subsets and then calculate its frequency in nums. +
    diff --git a/problems/the-number-of-seniors-and-juniors-to-join-the-company/README.md b/problems/the-number-of-seniors-and-juniors-to-join-the-company/README.md new file mode 100644 index 000000000..00a26cd8d --- /dev/null +++ b/problems/the-number-of-seniors-and-juniors-to-join-the-company/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../smallest-missing-genetic-value-in-each-subtree "Smallest Missing Genetic Value in Each Subtree") +                 +Next > + +## [2004. The Number of Seniors and Juniors to Join the Company (Hard)](https://leetcode.com/problems/the-number-of-seniors-and-juniors-to-join-the-company "") + + diff --git a/problems/the-number-of-seniors-and-juniors-to-join-the-company/mysql_schemas.sql b/problems/the-number-of-seniors-and-juniors-to-join-the-company/mysql_schemas.sql new file mode 100644 index 000000000..a379f18ed --- /dev/null +++ b/problems/the-number-of-seniors-and-juniors-to-join-the-company/mysql_schemas.sql @@ -0,0 +1,8 @@ +Create table If Not Exists Candidates (employee_id int, experience ENUM('Senior', 'Junior'), salary int); +Truncate table Candidates; +insert into Candidates (employee_id, experience, salary) values ('1', 'Junior', '10000'); +insert into Candidates (employee_id, experience, salary) values ('9', 'Junior', '10000'); +insert into Candidates (employee_id, experience, salary) values ('2', 'Senior', '20000'); +insert into Candidates (employee_id, experience, salary) values ('11', 'Senior', '20000'); +insert into Candidates (employee_id, experience, salary) values ('13', 'Senior', '50000'); +insert into Candidates (employee_id, experience, salary) values ('4', 'Junior', '40000'); diff --git a/problems/the-number-of-weak-characters-in-the-game/README.md b/problems/the-number-of-weak-characters-in-the-game/README.md new file mode 100644 index 000000000..608bbc54e --- /dev/null +++ b/problems/the-number-of-weak-characters-in-the-game/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../count-special-quadruplets "Count Special Quadruplets") +                 +[Next >](../first-day-where-you-have-been-in-all-the-rooms "First Day Where You Have Been in All the Rooms") + +## [1996. The Number of Weak Characters in the Game (Medium)](https://leetcode.com/problems/the-number-of-weak-characters-in-the-game "游戏中弱角色的数量") + +

    You are playing a game that contains multiple characters, and each of the characters has two main properties: attack and defense. You are given a 2D integer array properties where properties[i] = [attacki, defensei] represents the properties of the ith character in the game.

    + +

    A character is said to be weak if any other character has both attack and defense levels strictly greater than this character's attack and defense levels. More formally, a character i is said to be weak if there exists another character j where attackj > attacki and defensej > defensei.

    + +

    Return the number of weak characters.

    + +

     

    +

    Example 1:

    + +
    +Input: properties = [[5,5],[6,3],[3,6]]
    +Output: 0
    +Explanation: No character has strictly greater attack and defense than the other.
    +
    + +

    Example 2:

    + +
    +Input: properties = [[2,2],[3,3]]
    +Output: 1
    +Explanation: The first character is weak because the second character has a strictly greater attack and defense.
    +
    + +

    Example 3:

    + +
    +Input: properties = [[1,5],[10,4],[4,3]]
    +Output: 1
    +Explanation: The third character is weak because the second character has a strictly greater attack and defense.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= properties.length <= 105
    • +
    • properties[i].length == 2
    • +
    • 1 <= attacki, defensei <= 105
    • +
    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] + +### Hints +
    +Hint 1 +Sort the array on the basis of the attack values and group characters with the same attack together. How can you use these groups? +
    + +
    +Hint 2 +Characters in one group will always have a lesser attack value than the characters of the next group. Hence, we will only need to check if there is a higher defense value present in the next groups. +
    diff --git a/problems/throne-inheritance/README.md b/problems/throne-inheritance/README.md index ac0c68e26..781baf8df 100644 --- a/problems/throne-inheritance/README.md +++ b/problems/throne-inheritance/README.md @@ -81,10 +81,13 @@ t.getInheritanceOrder(); // return ["king", "andy", "ma ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Design](../../tag/design/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] + +### Similar Questions + 1. [Operations on Tree](../operations-on-tree) (Medium) ### Hints
    diff --git a/problems/time-needed-to-inform-all-employees/README.md b/problems/time-needed-to-inform-all-employees/README.md index c7127d925..562cedbe1 100644 --- a/problems/time-needed-to-inform-all-employees/README.md +++ b/problems/time-needed-to-inform-all-employees/README.md @@ -90,6 +90,10 @@ The third minute they will inform the rest of employees. [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] +### Similar Questions + 1. [Maximum Depth of Binary Tree](../maximum-depth-of-binary-tree) (Easy) + 1. [Binary Tree Maximum Path Sum](../binary-tree-maximum-path-sum) (Hard) + ### Hints
    Hint 1 diff --git a/problems/tweet-counts-per-frequency/README.md b/problems/tweet-counts-per-frequency/README.md index f928815fb..e6ff8c299 100644 --- a/problems/tweet-counts-per-frequency/README.md +++ b/problems/tweet-counts-per-frequency/README.md @@ -69,8 +69,8 @@ tweetCounts.getTweetCountsPerFrequency("hour", "tweet3", 0, ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] + [[Design](../../tag/design/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] diff --git a/problems/unique-binary-search-trees-ii/README.md b/problems/unique-binary-search-trees-ii/README.md index 8fcad49b8..12cdfd3e6 100644 --- a/problems/unique-binary-search-trees-ii/README.md +++ b/problems/unique-binary-search-trees-ii/README.md @@ -36,10 +36,10 @@ ### Related Topics - [[Tree](../../tag/tree/README.md)] - [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/unique-paths-iii/README.md b/problems/unique-paths-iii/README.md index 0a037cfb6..852b22a75 100644 --- a/problems/unique-paths-iii/README.md +++ b/problems/unique-paths-iii/README.md @@ -67,9 +67,9 @@ Note that the starting and ending square can be anywhere in the grid. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Similar Questions diff --git a/problems/valid-boomerang/README.md b/problems/valid-boomerang/README.md index f7e813c3d..ed69aa5e7 100644 --- a/problems/valid-boomerang/README.md +++ b/problems/valid-boomerang/README.md @@ -33,8 +33,8 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] ### Hints
    diff --git a/problems/valid-parenthesis-string/README.md b/problems/valid-parenthesis-string/README.md index 403d3c274..c95daefdb 100644 --- a/problems/valid-parenthesis-string/README.md +++ b/problems/valid-parenthesis-string/README.md @@ -42,10 +42,10 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions 1. [Special Binary String](../special-binary-string) (Hard) diff --git a/problems/valid-triangle-number/README.md b/problems/valid-triangle-number/README.md index 925813973..5cd750359 100644 --- a/problems/valid-triangle-number/README.md +++ b/problems/valid-triangle-number/README.md @@ -41,10 +41,10 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Similar Questions diff --git a/problems/web-crawler/README.md b/problems/web-crawler/README.md index edd39af60..a2719a55c 100644 --- a/problems/web-crawler/README.md +++ b/problems/web-crawler/README.md @@ -93,11 +93,14 @@ startUrl = "http://news.google.com" ### Related Topics + [[String](../../tag/string/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[String](../../tag/string/README.md)] [[Interactive](../../tag/interactive/README.md)] +### Similar Questions + 1. [Web Crawler Multithreaded](../web-crawler-multithreaded) (Medium) + ### Hints
    Hint 1 diff --git a/problems/wiggle-sort-ii/README.md b/problems/wiggle-sort-ii/README.md index 93083cdda..b38cdbed6 100644 --- a/problems/wiggle-sort-ii/README.md +++ b/problems/wiggle-sort-ii/README.md @@ -46,10 +46,11 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] - [[Quickselect](../../tag/quickselect/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Quickselect](../../tag/quickselect/README.md)] ### Similar Questions 1. [Sort Colors](../sort-colors) (Medium) 1. [Kth Largest Element in an Array](../kth-largest-element-in-an-array) (Medium) 1. [Wiggle Sort](../wiggle-sort) (Medium) + 1. [Array With Elements Not Equal to Average of Neighbors](../array-with-elements-not-equal-to-average-of-neighbors) (Medium) diff --git a/problems/wildcard-matching/README.md b/problems/wildcard-matching/README.md index e5cebeb0e..d9d3561f2 100644 --- a/problems/wildcard-matching/README.md +++ b/problems/wildcard-matching/README.md @@ -70,10 +70,10 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] - [[Recursion](../../tag/recursion/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions 1. [Regular Expression Matching](../regular-expression-matching) (Hard) diff --git a/readme/301-600.md b/readme/301-600.md index 69074961c..b7952889b 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -337,7 +337,7 @@ LeetCode Problems' Solutions | 557 | [Reverse Words in a String III](https://leetcode.com/problems/reverse-words-in-a-string-iii "反转字符串中的单词 III") | [Go](../problems/reverse-words-in-a-string-iii) | Easy | | 558 | [Logical OR of Two Binary Grids Represented as Quad-Trees](https://leetcode.com/problems/logical-or-of-two-binary-grids-represented-as-quad-trees "四叉树交集") | [Go](../problems/logical-or-of-two-binary-grids-represented-as-quad-trees) | Medium | | 559 | [Maximum Depth of N-ary Tree](https://leetcode.com/problems/maximum-depth-of-n-ary-tree "N 叉树的最大深度") | [Go](../problems/maximum-depth-of-n-ary-tree) | Easy | -| 560 | [Subarray Sum Equals K](https://leetcode.com/problems/subarray-sum-equals-k "和为K的子数组") | [Go](../problems/subarray-sum-equals-k) | Medium | +| 560 | [Subarray Sum Equals K](https://leetcode.com/problems/subarray-sum-equals-k "和为 K 的子数组") | [Go](../problems/subarray-sum-equals-k) | Medium | | 561 | [Array Partition I](https://leetcode.com/problems/array-partition-i "数组拆分 I") | [Go](../problems/array-partition-i) | Easy | | 562 | [Longest Line of Consecutive One in Matrix](https://leetcode.com/problems/longest-line-of-consecutive-one-in-matrix "矩阵中最长的连续1线段") 🔒 | [Go](../problems/longest-line-of-consecutive-one-in-matrix) | Medium | | 563 | [Binary Tree Tilt](https://leetcode.com/problems/binary-tree-tilt "二叉树的坡度") | [Go](../problems/binary-tree-tilt) | Easy | diff --git a/tag/array/README.md b/tag/array/README.md index 21fb92963..2d1b2d60a 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,14 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | +| 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1997 | [访问完所有房间的第一天](../../problems/first-day-where-you-have-been-in-all-the-rooms) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1995 | [统计特殊四元组](../../problems/count-special-quadruplets) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Easy | +| 1994 | [好子集的数目](../../problems/the-number-of-good-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1992 | [找到所有的农场组](../../problems/find-all-groups-of-farmland) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1991 | [找到数组的中间位置](../../problems/find-the-middle-index-in-array) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | | 1986 | [完成任务的最少工作时间段](../../problems/minimum-number-of-work-sessions-to-finish-the-tasks) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | @@ -213,7 +221,7 @@ | 1591 | [奇怪的打印机 II](../../problems/strange-printer-ii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1589 | [所有排列中的最大和](../../problems/maximum-sum-obtained-of-any-permutation) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | -| 1588 | [所有奇数长度子数组的和](../../problems/sum-of-all-odd-length-subarrays) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | +| 1588 | [所有奇数长度子数组的和](../../problems/sum-of-all-odd-length-subarrays) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | | 1584 | [连接所有点的最小费用](../../problems/min-cost-to-connect-all-points) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] | Medium | | 1583 | [统计不开心的朋友](../../problems/count-unhappy-friends) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1582 | [二进制矩阵中的特殊位置](../../problems/special-positions-in-a-binary-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | @@ -699,7 +707,7 @@ | 565 | [数组嵌套](../../problems/array-nesting) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 562 | [矩阵中最长的连续1线段](../../problems/longest-line-of-consecutive-one-in-matrix) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 561 | [数组拆分 I](../../problems/array-partition-i) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[计数排序](../counting-sort/README.md)] [[排序](../sorting/README.md)] | Easy | -| 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 560 | [和为 K 的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 555 | [分割连接字符串](../../problems/split-concatenated-strings) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 554 | [砖墙](../../problems/brick-wall) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 553 | [最优除法](../../problems/optimal-division) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 46c9dac8c..f42b7276a 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1986 | [完成任务的最少工作时间段](../../problems/minimum-number-of-work-sessions-to-finish-the-tasks) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1980 | [找出不同的二进制字符串](../../problems/find-unique-binary-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1947 | [最大兼容性评分和](../../problems/maximum-compatibility-score-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 9ca356e3f..a81d9297e 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 1994 | [好子集的数目](../../problems/the-number-of-good-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1986 | [完成任务的最少工作时间段](../../problems/minimum-number-of-work-sessions-to-finish-the-tasks) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1947 | [最大兼容性评分和](../../problems/maximum-compatibility-score-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1915 | [最美子字符串的数目](../../problems/number-of-wonderful-substrings) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | diff --git a/tag/bitmask/README.md b/tag/bitmask/README.md index 3f94e143e..21d0f94f5 100644 --- a/tag/bitmask/README.md +++ b/tag/bitmask/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 1994 | [好子集的数目](../../problems/the-number-of-good-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1986 | [完成任务的最少工作时间段](../../problems/minimum-number-of-work-sessions-to-finish-the-tasks) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1947 | [最大兼容性评分和](../../problems/maximum-compatibility-score-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1879 | [两个数组最小的异或值之和](../../problems/minimum-xor-sum-of-two-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index a0478a227..ce43624db 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 1992 | [找到所有的农场组](../../problems/find-all-groups-of-farmland) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1971 | [Find if Path Exists in Graph](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | | 1970 | [你能穿过矩阵的最后一天](../../problems/last-day-where-you-can-still-cross) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1926 | [迷宫中离入口最近的出口](../../problems/nearest-exit-from-entrance-in-maze) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | diff --git a/tag/counting/README.md b/tag/counting/README.md index 81c6b72d0..947c2d594 100644 --- a/tag/counting/README.md +++ b/tag/counting/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1941 | [检查是否所有字符出现次数相同](../../problems/check-if-all-characters-have-equal-number-of-occurrences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 1940 | [排序数组之间的最长公共子序列](../../problems/longest-common-subsequence-between-sorted-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | | 1897 | [重新分配字符使所有字符串都相等](../../problems/redistribute-characters-to-make-all-strings-equal) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index c19090040..4cbb4b884 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1992 | [找到所有的农场组](../../problems/find-all-groups-of-farmland) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1971 | [Find if Path Exists in Graph](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | | 1970 | [你能穿过矩阵的最后一天](../../problems/last-day-where-you-can-still-cross) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index 57928895b..cf28e5b9e 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1865 | [找出和为指定值的下标对](../../problems/finding-pairs-with-a-certain-sum) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1845 | [座位预约管理系统](../../problems/seat-reservation-manager) | [[设计](../design/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index c29f35c9d..ebbcc048c 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 1997 | [访问完所有房间的第一天](../../problems/first-day-where-you-have-been-in-all-the-rooms) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1994 | [好子集的数目](../../problems/the-number-of-good-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1987 | [不同的好子序列数目](../../problems/number-of-unique-good-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1986 | [完成任务的最少工作时间段](../../problems/minimum-number-of-work-sessions-to-finish-the-tasks) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1981 | [最小化目标值与所选元素的差](../../problems/minimize-the-difference-between-target-and-chosen-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | diff --git a/tag/enumeration/README.md b/tag/enumeration/README.md index fb1f57975..c53c3c671 100644 --- a/tag/enumeration/README.md +++ b/tag/enumeration/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1995 | [统计特殊四元组](../../problems/count-special-quadruplets) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 1958 | [检查操作是否合法](../../problems/check-if-move-is-legal) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1925 | [统计平方和三元组的数目](../../problems/count-square-sum-triples) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 1620 | [网络信号最好的坐标](../../problems/coordinate-with-maximum-network-quality) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Medium | diff --git a/tag/graph/README.md b/tag/graph/README.md index a8f4607d6..eb026350b 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -10,6 +10,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | +| 1971 | [Find if Path Exists in Graph](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | | 1928 | [规定时间内到达终点的最小花费](../../problems/minimum-cost-to-reach-destination-in-time) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] [[计数](../counting/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 440c0236b..63c4716fa 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1975 | [最大方阵和](../../problems/maximum-matrix-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1974 | [使用特殊打字机键入单词的最少时间](../../problems/minimum-time-to-type-word-using-special-typewriter) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | | 1969 | [数组元素的最小非零乘积](../../problems/minimum-non-zero-product-of-the-array-elements) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 12d0f1245..20857bd67 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | +| 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | | 1941 | [检查是否所有字符出现次数相同](../../problems/check-if-all-characters-have-equal-number-of-occurrences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 1940 | [排序数组之间的最长公共子序列](../../problems/longest-common-subsequence-between-sorted-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | @@ -239,7 +241,7 @@ | 582 | [杀掉进程](../../problems/kill-process) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 575 | [分糖果](../../problems/distribute-candies) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 567 | [字符串的排列](../../problems/permutation-in-string) | [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | -| 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 560 | [和为 K 的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 554 | [砖墙](../../problems/brick-wall) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 535 | [TinyURL 的加密与解密](../../problems/encode-and-decode-tinyurl) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Medium | | 533 | [孤独像素 II](../../problems/lonely-pixel-ii) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 223cc50a5..b81c3ffea 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | +| 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1994 | [好子集的数目](../../problems/the-number-of-good-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1979 | [找出数组的最大公约数](../../problems/find-greatest-common-divisor-of-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1969 | [数组元素的最小非零乘积](../../problems/minimum-non-zero-product-of-the-array-elements) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 1954 | [收集足够苹果的最小花园周长](../../problems/minimum-garden-perimeter-to-collect-enough-apples) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -63,6 +66,7 @@ | 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数学](../math/README.md)] | Hard | | 1621 | [大小为 K 的不重叠线段的数目](../../problems/number-of-sets-of-k-non-overlapping-line-segments) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 1588 | [所有奇数长度子数组的和](../../problems/sum-of-all-odd-length-subarrays) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | | 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1573 | [分割字符串的方案数](../../problems/number-of-ways-to-split-a-string) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | diff --git a/tag/matrix/README.md b/tag/matrix/README.md index f20883ecc..0383fad45 100644 --- a/tag/matrix/README.md +++ b/tag/matrix/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1992 | [找到所有的农场组](../../problems/find-all-groups-of-farmland) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1981 | [最小化目标值与所选元素的差](../../problems/minimize-the-difference-between-target-and-chosen-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1975 | [最大方阵和](../../problems/maximum-matrix-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1970 | [你能穿过矩阵的最后一天](../../problems/last-day-where-you-can-still-cross) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | diff --git a/tag/monotonic-stack/README.md b/tag/monotonic-stack/README.md index e920c5a7c..1f30a905a 100644 --- a/tag/monotonic-stack/README.md +++ b/tag/monotonic-stack/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1944 | [队列中可以看到的人数](../../problems/number-of-visible-people-in-a-queue) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | diff --git a/tag/number-theory/README.md b/tag/number-theory/README.md index 33b9d5b88..5a1ff7079 100644 --- a/tag/number-theory/README.md +++ b/tag/number-theory/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Hard | | 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] [[数论](../number-theory/README.md)] | Hard | | 1250 | [检查「好数组」](../../problems/check-if-it-is-a-good-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[数论](../number-theory/README.md)] | Hard | diff --git a/tag/prefix-sum/README.md b/tag/prefix-sum/README.md index 559b90b75..3483f4894 100644 --- a/tag/prefix-sum/README.md +++ b/tag/prefix-sum/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1991 | [找到数组的中间位置](../../problems/find-the-middle-index-in-array) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | | 1943 | [描述绘画结果](../../problems/describe-the-painting) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1930 | [长度为 3 的不同回文子序列](../../problems/unique-length-3-palindromic-subsequences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1915 | [最美子字符串的数目](../../problems/number-of-wonderful-substrings) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | @@ -35,7 +36,7 @@ | 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1589 | [所有排列中的最大和](../../problems/maximum-sum-obtained-of-any-permutation) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | -| 1588 | [所有奇数长度子数组的和](../../problems/sum-of-all-odd-length-subarrays) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | +| 1588 | [所有奇数长度子数组的和](../../problems/sum-of-all-odd-length-subarrays) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | | 1546 | [和为目标值且不重叠的非空子数组的最大数目](../../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1524 | [和为奇数的子数组数目](../../problems/number-of-sub-arrays-with-odd-sum) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1480 | [一维数组的动态和](../../problems/running-sum-of-1d-array) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | @@ -59,7 +60,7 @@ | 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 798 | [得分最高的最小轮调](../../problems/smallest-rotation-with-highest-score) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 724 | [寻找数组的中心下标](../../problems/find-pivot-index) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | -| 560 | [和为K的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 560 | [和为 K 的子数组](../../problems/subarray-sum-equals-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 548 | [将数组分割成和相等的子数组](../../problems/split-array-with-equal-sum) 🔒 | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 528 | [按权重随机选择](../../problems/random-pick-with-weight) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[随机化](../randomized/README.md)] | Medium | | 525 | [连续数组](../../problems/contiguous-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | diff --git a/tag/sorting/README.md b/tag/sorting/README.md index 771741dad..94ffdc25a 100644 --- a/tag/sorting/README.md +++ b/tag/sorting/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | +| 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 1968 | [构造元素不等于两相邻元素平均值的数组](../../problems/array-with-elements-not-equal-to-average-of-neighbors) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | diff --git a/tag/stack/README.md b/tag/stack/README.md index 7d9d30074..7f58a1a43 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1963 | [使字符串平衡的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-string-balanced) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1944 | [队列中可以看到的人数](../../problems/number-of-visible-people-in-a-queue) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1896 | [反转表达式值的最少操作次数](../../problems/minimum-cost-to-change-the-final-value-of-expression) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/string/README.md b/tag/string/README.md index c8a186c63..268c328e0 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2000 | [反转单词前缀](../../problems/reverse-prefix-of-word) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 1987 | [不同的好子序列数目](../../problems/number-of-unique-good-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1980 | [找出不同的二进制字符串](../../problems/find-unique-binary-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | diff --git a/tag/tree/README.md b/tag/tree/README.md index 04204a698..4a0e237b1 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 1f292dfec..842587dfb 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2000 | [反转单词前缀](../../problems/reverse-prefix-of-word) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 1963 | [使字符串平衡的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-string-balanced) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1877 | [数组中最大数对和的最小值](../../problems/minimize-maximum-pair-sum-in-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 1871 | [跳跃游戏 VII](../../problems/jump-game-vii) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index 4bcbf438f..25fb56eb0 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 1970 | [你能穿过矩阵的最后一天](../../problems/last-day-where-you-can-still-cross) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1724 | [检查边长度限制的路径是否存在 II](../../problems/checking-existence-of-edge-length-limited-paths-ii) 🔒 | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] | Hard | From 7c54dc6800d26080da0319ff832dde498dd1a9af Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 20 Oct 2021 11:25:33 +0800 Subject: [PATCH 136/145] A: new --- README.md | 45 ++++++- .../README.md | 17 +++ .../mysql_schemas.sql | 20 ++++ problems/add-digits/README.md | 3 +- problems/advantage-shuffle/README.md | 2 +- .../README.md | 2 +- .../apply-discount-every-n-orders/README.md | 2 +- problems/arithmetic-subarrays/README.md | 4 - problems/array-of-doubled-pairs/README.md | 5 +- .../README.md | 41 +++++++ .../balance-a-binary-search-tree/README.md | 2 +- problems/basic-calculator/README.md | 7 +- problems/beautiful-arrangement/README.md | 2 +- .../binary-search-tree-iterator/README.md | 1 + .../README.md | 11 +- problems/binary-subarrays-with-sum/README.md | 2 +- problems/break-a-palindrome/README.md | 2 +- .../brightest-position-on-street/README.md | 35 ++++++ .../README.md | 2 +- .../README.md | 6 +- problems/bulb-switcher-iii/README.md | 18 +-- .../README.md | 89 ++++++++++++++ .../README.md | 3 - .../README.md | 77 ++++++++++++ problems/cinema-seat-allocation/README.md | 4 +- .../README.md | 2 +- .../README.md | 2 +- problems/consecutive-characters/README.md | 4 - problems/consecutive-numbers/README.md | 9 +- .../constrained-subsequence-sum/README.md | 4 +- .../README.md | 2 +- .../convert-1d-array-into-2d-array/README.md | 90 ++++++++++++++ .../README.md | 2 +- .../README.md | 31 +++-- problems/count-all-possible-routes/README.md | 2 +- problems/count-good-triplets/README.md | 3 + .../README.md | 74 ++++++++++++ .../README.md | 76 ++++++++++++ problems/count-number-of-teams/README.md | 2 +- problems/count-primes/README.md | 4 +- .../count-servers-that-communicate/README.md | 4 +- .../README.md | 39 ++++++ problems/course-schedule-iii/README.md | 2 +- problems/create-a-session-bar-chart/README.md | 3 - problems/customers-who-never-order/README.md | 54 +++++++-- problems/daily-temperatures/README.md | 3 +- .../README.md | 2 +- .../README.md | 3 + .../README.md | 2 +- .../README.md | 4 - problems/delete-node-in-a-bst/README.md | 5 +- problems/department-highest-salary/README.md | 79 ++++++++---- .../department-top-three-salaries/README.md | 22 ++-- .../README.md | 2 +- problems/design-browser-history/README.md | 6 +- .../design-in-memory-file-system/README.md | 4 +- .../design-most-recently-used-queue/README.md | 1 + problems/design-parking-system/README.md | 2 +- problems/design-underground-system/README.md | 2 +- problems/detect-cycles-in-2d-grid/README.md | 15 ++- problems/detect-squares/README.md | 79 ++++++++++++ .../README.md | 5 +- .../README.md | 2 +- problems/distinct-subsequences-ii/README.md | 3 - .../README.md | 5 +- .../README.md | 2 +- problems/duplicate-emails/README.md | 35 ++++-- problems/employee-importance/README.md | 18 +-- .../README.md | 3 + problems/encode-and-decode-tinyurl/README.md | 2 +- problems/encode-number/README.md | 2 +- problems/expression-add-operators/README.md | 56 ++++++--- problems/fancy-sequence/README.md | 2 +- .../README.md | 85 +++++++++++++ .../README.md | 9 +- .../README.md | 4 +- problems/find-all-the-lonely-nodes/README.md | 4 + problems/find-eventual-safe-states/README.md | 14 ++- .../find-k-pairs-with-smallest-sums/README.md | 1 + .../find-longest-awesome-substring/README.md | 2 +- .../README.md | 5 +- problems/find-missing-observations/README.md | 80 +++++++++++++ .../README.md | 75 ++++++++++++ .../README.md | 2 +- .../find-the-middle-index-in-array/README.md | 3 + .../README.md | 2 +- .../README.md | 44 +++---- .../README.md | 3 + .../README.md | 2 +- .../README.md | 2 +- problems/get-the-maximum-score/README.md | 2 +- .../README.md | 2 +- .../README.md | 2 +- problems/grid-game/README.md | 77 ++++++++++++ .../README.md | 5 +- .../implement-rand10-using-rand7/README.md | 17 +-- problems/increasing-subsequences/README.md | 2 +- .../README.md | 2 +- problems/island-perimeter/README.md | 1 + problems/jump-game-iii/README.md | 7 +- problems/jump-game-iv/README.md | 5 +- problems/k-empty-slots/README.md | 4 +- problems/k-similar-strings/README.md | 2 +- problems/keys-and-rooms/README.md | 3 + .../README.md | 77 ++++++++++++ problems/kth-smallest-subarray-sum/README.md | 2 +- problems/largest-bst-subtree/README.md | 2 +- problems/largest-multiple-of-three/README.md | 11 +- .../README.md | 2 +- .../README.md | 4 +- problems/leetcodify-similar-friends/README.md | 3 + .../README.md | 2 +- .../README.md | 6 +- .../longest-duplicate-substring/README.md | 4 +- problems/longest-happy-string/README.md | 2 +- .../README.md | 2 + .../README.md | 8 +- .../README.md | 91 ++++++++++++++ .../README.md | 2 +- problems/low-quality-problems/README.md | 17 +++ .../low-quality-problems/mysql_schemas.sql | 8 ++ .../README.md | 8 +- problems/lucky-numbers-in-a-matrix/README.md | 15 ++- problems/max-consecutive-ones-iii/README.md | 3 +- problems/max-points-on-a-line/README.md | 2 +- problems/max-value-of-equation/README.md | 7 +- .../README.md | 79 ++++++++++++ .../README.md | 39 ++++++ .../README.md | 68 +++++++++++ problems/maximum-distance-in-arrays/README.md | 2 +- problems/maximum-earnings-from-taxi/README.md | 70 +++++++++++ .../README.md | 3 + .../README.md | 27 ++++- .../README.md | 3 +- .../README.md | 5 +- .../README.md | 4 +- .../README.md | 2 +- .../README.md | 6 +- .../README.md | 2 +- .../README.md | 4 +- .../README.md | 86 ++++++++++++++ .../README.md | 2 +- .../README.md | 1 + problems/maximum-subarray/README.md | 4 +- .../maximum-sum-bst-in-binary-tree/README.md | 2 +- problems/maximum-units-on-a-truck/README.md | 2 +- .../min-cost-to-connect-all-points/README.md | 2 +- problems/mini-parser/README.md | 3 +- .../minimize-deviation-in-array/README.md | 4 +- .../README.md | 5 +- problems/minimum-area-rectangle-ii/README.md | 2 +- .../README.md | 4 +- .../README.md | 4 +- .../README.md | 2 +- .../README.md | 3 + .../minimum-falling-path-sum-ii/README.md | 3 + problems/minimum-incompatibility/README.md | 2 +- .../README.md | 5 +- .../minimum-moves-to-convert-string/README.md | 68 +++++++++++ .../README.md | 3 + .../README.md | 92 ++++++++++++++ .../README.md | 78 ++++++++++++ .../README.md | 3 - .../README.md | 6 +- .../README.md | 2 +- .../README.md | 5 +- .../README.md | 80 +++++++++++++ .../README.md | 4 + .../README.md | 7 ++ .../README.md | 12 +- problems/most-frequent-subtree-sum/README.md | 3 +- problems/next-greater-element-ii/README.md | 2 +- problems/nim-game/README.md | 2 +- .../README.md | 17 +++ .../mysql_schemas.sql | 16 +++ .../README.md | 8 +- problems/number-of-good-pairs/README.md | 3 + problems/number-of-islands-ii/README.md | 2 +- .../README.md | 77 ++++++++++++ .../README.md | 16 +-- .../README.md | 3 + .../README.md | 2 +- problems/operations-on-tree/README.md | 6 +- problems/page-recommendations/README.md | 4 + .../palindrome-partitioning-iii/README.md | 3 + problems/parallel-courses-ii/README.md | 5 +- .../README.md | 83 +++++++++++++ problems/path-with-minimum-effort/README.md | 10 +- problems/peeking-iterator/README.md | 2 +- .../README.md | 3 - problems/perfect-squares/README.md | 4 +- problems/pizza-with-3n-slices/README.md | 2 +- .../README.md | 2 +- .../README.md | 19 +-- .../README.md | 4 +- .../product-of-the-last-k-numbers/README.md | 4 +- .../put-boxes-into-the-warehouse-i/README.md | 5 +- problems/random-pick-index/README.md | 2 +- problems/rank-scores/README.md | 60 +++++++--- .../rearrange-spaces-between-words/README.md | 3 - .../README.md | 5 +- problems/reducing-dishes/README.md | 11 +- problems/remove-boxes/README.md | 2 +- .../README.md | 100 ++++++++++++++++ problems/remove-duplicate-letters/README.md | 5 +- problems/reverse-bits/README.md | 11 +- .../README.md | 2 +- problems/rotate-image/README.md | 3 + .../README.md | 3 + .../README.md | 95 +++++++++++++++ problems/shopping-offers/README.md | 4 +- .../README.md | 31 ++--- problems/simple-bank-system/README.md | 80 +++++++++++++ problems/simplify-path/README.md | 2 +- problems/single-number-ii/README.md | 2 +- .../README.md | 76 ++++++++++++ .../README.md | 2 +- problems/split-concatenated-strings/README.md | 2 +- problems/stock-price-fluctuation/README.md | 84 +++++++++++++ problems/stone-game-iv/README.md | 1 + problems/stone-game-ix/README.md | 79 ++++++++++++ problems/stone-game-v/README.md | 9 -- problems/stone-game-vii/README.md | 11 ++ problems/subarray-sum-equals-k/README.md | 1 + .../README.md | 30 +++++ problems/sum-of-beauty-in-the-array/README.md | 78 ++++++++++++ .../README.md | 6 +- problems/swim-in-rising-water/README.md | 9 +- problems/the-maze-ii/README.md | 2 +- problems/the-maze-iii/README.md | 2 +- .../README.md | 14 +++ .../mysql_schemas.sql | 8 ++ .../README.md | 2 +- .../README.md | 112 ++++++++++++++++++ problems/the-skyline-problem/README.md | 6 +- .../README.md | 105 ++++++++++++++++ problems/throne-inheritance/README.md | 5 +- problems/trapping-rain-water-ii/README.md | 4 +- problems/trips-and-users/README.md | 15 ++- problems/tweet-counts-per-frequency/README.md | 4 +- problems/two-out-of-three/README.md | 66 +++++++++++ problems/unique-binary-search-trees/README.md | 4 +- .../unique-number-of-occurrences/README.md | 2 +- .../README.md | 3 + problems/valid-boomerang/README.md | 2 +- problems/where-will-the-ball-fall/README.md | 2 +- problems/word-ladder/README.md | 2 +- problems/xor-operation-in-an-array/README.md | 2 +- problems/xor-queries-of-a-subarray/README.md | 2 +- readme/1-300.md | 12 +- readme/301-600.md | 2 +- readme/601-900.md | 2 +- readme/901-1200.md | 2 +- tag/array/README.md | 46 +++++-- tag/backtracking/README.md | 2 + tag/binary-indexed-tree/README.md | 2 + tag/binary-search/README.md | 12 +- tag/bit-manipulation/README.md | 2 + tag/bitmask/README.md | 1 + tag/breadth-first-search/README.md | 4 +- tag/counting/README.md | 4 + tag/depth-first-search/README.md | 2 +- tag/design/README.md | 7 +- tag/divide-and-conquer/README.md | 1 + tag/dynamic-programming/README.md | 4 + tag/enumeration/README.md | 6 +- tag/game-theory/README.md | 2 + tag/geometry/README.md | 1 + tag/graph/README.md | 2 + tag/greedy/README.md | 7 ++ tag/hash-table/README.md | 10 +- tag/heap-priority-queue/README.md | 2 + tag/iterator/README.md | 2 +- tag/math/README.md | 12 +- tag/matrix/README.md | 6 +- tag/memoization/README.md | 1 + tag/merge-sort/README.md | 1 + tag/monotonic-stack/README.md | 3 +- tag/number-theory/README.md | 2 +- tag/ordered-set/README.md | 6 +- tag/prefix-sum/README.md | 4 + tag/segment-tree/README.md | 1 + tag/shortest-path/README.md | 1 + tag/simulation/README.md | 6 +- tag/sliding-window/README.md | 3 +- tag/sorting/README.md | 5 + tag/stack/README.md | 6 +- tag/string/README.md | 11 +- tag/two-pointers/README.md | 3 +- tag/union-find/README.md | 2 +- 290 files changed, 3890 insertions(+), 533 deletions(-) create mode 100644 problems/accepted-candidates-from-the-interviews/README.md create mode 100644 problems/accepted-candidates-from-the-interviews/mysql_schemas.sql create mode 100644 problems/average-height-of-buildings-in-each-segment/README.md create mode 100644 problems/brightest-position-on-street/README.md create mode 100644 problems/check-if-numbers-are-ascending-in-a-sentence/README.md create mode 100644 problems/check-if-word-can-be-placed-in-crossword/README.md create mode 100644 problems/convert-1d-array-into-2d-array/README.md create mode 100644 problems/count-number-of-maximum-bitwise-or-subsets/README.md create mode 100644 problems/count-number-of-pairs-with-absolute-difference-k/README.md create mode 100644 problems/count-subarrays-with-more-ones-than-zeros/README.md create mode 100644 problems/detect-squares/README.md create mode 100644 problems/final-value-of-variable-after-performing-operations/README.md create mode 100644 problems/find-missing-observations/README.md create mode 100644 problems/find-original-array-from-doubled-array/README.md create mode 100644 problems/grid-game/README.md create mode 100644 problems/kth-smallest-product-of-two-sorted-arrays/README.md create mode 100644 problems/longest-subsequence-repeated-k-times/README.md create mode 100644 problems/low-quality-problems/README.md create mode 100644 problems/low-quality-problems/mysql_schemas.sql create mode 100644 problems/maximize-the-confusion-of-an-exam/README.md create mode 100644 problems/maximum-alternating-subarray-sum/README.md create mode 100644 problems/maximum-difference-between-increasing-elements/README.md create mode 100644 problems/maximum-earnings-from-taxi/README.md create mode 100644 problems/maximum-number-of-ways-to-partition-an-array/README.md create mode 100644 problems/minimum-moves-to-convert-string/README.md create mode 100644 problems/minimum-number-of-moves-to-seat-everyone/README.md create mode 100644 problems/minimum-number-of-operations-to-make-array-continuous/README.md create mode 100644 problems/minimum-operations-to-make-a-uni-value-grid/README.md create mode 100644 problems/number-of-accounts-that-did-not-stream/README.md create mode 100644 problems/number-of-accounts-that-did-not-stream/mysql_schemas.sql create mode 100644 problems/number-of-pairs-of-strings-with-concatenation-equal-to-target/README.md create mode 100644 problems/partition-array-into-two-arrays-to-minimize-sum-difference/README.md create mode 100644 problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/README.md create mode 100644 problems/second-minimum-time-to-reach-destination/README.md create mode 100644 problems/simple-bank-system/README.md create mode 100644 problems/smallest-k-length-subsequence-with-occurrences-of-a-letter/README.md create mode 100644 problems/stock-price-fluctuation/README.md create mode 100644 problems/stone-game-ix/README.md create mode 100644 problems/subtree-removal-game-with-fibonacci-tree/README.md create mode 100644 problems/sum-of-beauty-in-the-array/README.md create mode 100644 problems/the-number-of-seniors-and-juniors-to-join-the-company-ii/README.md create mode 100644 problems/the-number-of-seniors-and-juniors-to-join-the-company-ii/mysql_schemas.sql create mode 100644 problems/the-score-of-students-solving-math-expression/README.md create mode 100644 problems/the-time-when-the-network-becomes-idle/README.md create mode 100644 problems/two-out-of-three/README.md diff --git a/README.md b/README.md index 9d975784b..9bfff812b 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,47 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 2045 | [Second Minimum Time to Reach Destination](https://leetcode.com/problems/second-minimum-time-to-reach-destination "到达目的地的第二短时间") | [Go](problems/second-minimum-time-to-reach-destination) | Hard | +| 2044 | [Count Number of Maximum Bitwise-OR Subsets](https://leetcode.com/problems/count-number-of-maximum-bitwise-or-subsets "统计按位或能得到最大值的子集数目") | [Go](problems/count-number-of-maximum-bitwise-or-subsets) | Medium | +| 2043 | [Simple Bank System](https://leetcode.com/problems/simple-bank-system "简易银行系统") | [Go](problems/simple-bank-system) | Medium | +| 2042 | [Check if Numbers Are Ascending in a Sentence](https://leetcode.com/problems/check-if-numbers-are-ascending-in-a-sentence "检查句子中的数字是否递增") | [Go](problems/check-if-numbers-are-ascending-in-a-sentence) | Easy | +| 2041 | [Accepted Candidates From the Interviews](https://leetcode.com/problems/accepted-candidates-from-the-interviews) 🔒 | [MySQL](problems/accepted-candidates-from-the-interviews) | Medium | +| 2040 | [Kth Smallest Product of Two Sorted Arrays](https://leetcode.com/problems/kth-smallest-product-of-two-sorted-arrays "两个有序数组的第 K 小乘积") | [Go](problems/kth-smallest-product-of-two-sorted-arrays) | Hard | +| 2039 | [The Time When the Network Becomes Idle](https://leetcode.com/problems/the-time-when-the-network-becomes-idle "网络空闲的时刻") | [Go](problems/the-time-when-the-network-becomes-idle) | Medium | +| 2038 | [Remove Colored Pieces if Both Neighbors are the Same Color](https://leetcode.com/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color "如果相邻两个颜色均相同则删除当前颜色") | [Go](problems/remove-colored-pieces-if-both-neighbors-are-the-same-color) | Medium | +| 2037 | [Minimum Number of Moves to Seat Everyone](https://leetcode.com/problems/minimum-number-of-moves-to-seat-everyone "使每位学生都有座位的最少移动次数") | [Go](problems/minimum-number-of-moves-to-seat-everyone) | Easy | +| 2036 | [Maximum Alternating Subarray Sum](https://leetcode.com/problems/maximum-alternating-subarray-sum) 🔒 | [Go](problems/maximum-alternating-subarray-sum) | Medium | +| 2035 | [Partition Array Into Two Arrays to Minimize Sum Difference](https://leetcode.com/problems/partition-array-into-two-arrays-to-minimize-sum-difference "将数组分成两个数组并最小化数组和的差") | [Go](problems/partition-array-into-two-arrays-to-minimize-sum-difference) | Hard | +| 2034 | [Stock Price Fluctuation](https://leetcode.com/problems/stock-price-fluctuation "股票价格波动") | [Go](problems/stock-price-fluctuation) | Medium | +| 2033 | [Minimum Operations to Make a Uni-Value Grid](https://leetcode.com/problems/minimum-operations-to-make-a-uni-value-grid "获取单值网格的最小操作数") | [Go](problems/minimum-operations-to-make-a-uni-value-grid) | Medium | +| 2032 | [Two Out of Three](https://leetcode.com/problems/two-out-of-three "至少在两个数组中出现的值") | [Go](problems/two-out-of-three) | Easy | +| 2031 | [Count Subarrays With More Ones Than Zeros](https://leetcode.com/problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [Go](problems/count-subarrays-with-more-ones-than-zeros) | Medium | +| 2030 | [Smallest K-Length Subsequence With Occurrences of a Letter](https://leetcode.com/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter "含特定字母的最小子序列") | [Go](problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | Hard | +| 2029 | [Stone Game IX](https://leetcode.com/problems/stone-game-ix "石子游戏 IX") | [Go](problems/stone-game-ix) | Medium | +| 2028 | [Find Missing Observations](https://leetcode.com/problems/find-missing-observations "找出缺失的观测数据") | [Go](problems/find-missing-observations) | Medium | +| 2027 | [Minimum Moves to Convert String](https://leetcode.com/problems/minimum-moves-to-convert-string "转换字符串的最少操作次数") | [Go](problems/minimum-moves-to-convert-string) | Easy | +| 2026 | [Low-Quality Problems](https://leetcode.com/problems/low-quality-problems) 🔒 | [MySQL](problems/low-quality-problems) | Easy | +| 2025 | [Maximum Number of Ways to Partition an Array](https://leetcode.com/problems/maximum-number-of-ways-to-partition-an-array "分割数组的最多方案数") | [Go](problems/maximum-number-of-ways-to-partition-an-array) | Hard | +| 2024 | [Maximize the Confusion of an Exam](https://leetcode.com/problems/maximize-the-confusion-of-an-exam "考试的最大困扰度") | [Go](problems/maximize-the-confusion-of-an-exam) | Medium | +| 2023 | [Number of Pairs of Strings With Concatenation Equal to Target](https://leetcode.com/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target "连接后等于目标字符串的字符串对") | [Go](problems/number-of-pairs-of-strings-with-concatenation-equal-to-target) | Medium | +| 2022 | [Convert 1D Array Into 2D Array](https://leetcode.com/problems/convert-1d-array-into-2d-array "将一维数组转变成二维数组") | [Go](problems/convert-1d-array-into-2d-array) | Easy | +| 2021 | [Brightest Position on Street](https://leetcode.com/problems/brightest-position-on-street) 🔒 | [Go](problems/brightest-position-on-street) | Medium | +| 2020 | [Number of Accounts That Did Not Stream](https://leetcode.com/problems/number-of-accounts-that-did-not-stream) 🔒 | [MySQL](problems/number-of-accounts-that-did-not-stream) | Medium | +| 2019 | [The Score of Students Solving Math Expression](https://leetcode.com/problems/the-score-of-students-solving-math-expression "解出数学表达式的学生分数") | [Go](problems/the-score-of-students-solving-math-expression) | Hard | +| 2018 | [Check if Word Can Be Placed In Crossword](https://leetcode.com/problems/check-if-word-can-be-placed-in-crossword "判断单词是否能放入填字游戏内") | [Go](problems/check-if-word-can-be-placed-in-crossword) | Medium | +| 2017 | [Grid Game](https://leetcode.com/problems/grid-game "网格游戏") | [Go](problems/grid-game) | Medium | +| 2016 | [Maximum Difference Between Increasing Elements](https://leetcode.com/problems/maximum-difference-between-increasing-elements "增量元素之间的最大差值") | [Go](problems/maximum-difference-between-increasing-elements) | Easy | +| 2015 | [Average Height of Buildings in Each Segment](https://leetcode.com/problems/average-height-of-buildings-in-each-segment) 🔒 | [Go](problems/average-height-of-buildings-in-each-segment) | Medium | +| 2014 | [Longest Subsequence Repeated k Times](https://leetcode.com/problems/longest-subsequence-repeated-k-times "重复 K 次的最长子序列") | [Go](problems/longest-subsequence-repeated-k-times) | Hard | +| 2013 | [Detect Squares](https://leetcode.com/problems/detect-squares "检测正方形") | [Go](problems/detect-squares) | Medium | +| 2012 | [Sum of Beauty in the Array](https://leetcode.com/problems/sum-of-beauty-in-the-array "数组美丽值求和") | [Go](problems/sum-of-beauty-in-the-array) | Medium | +| 2011 | [Final Value of Variable After Performing Operations](https://leetcode.com/problems/final-value-of-variable-after-performing-operations "执行操作后的变量值") | [Go](problems/final-value-of-variable-after-performing-operations) | Easy | +| 2010 | [The Number of Seniors and Juniors to Join the Company II](https://leetcode.com/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii) 🔒 | [MySQL](problems/the-number-of-seniors-and-juniors-to-join-the-company-ii) | Hard | +| 2009 | [Minimum Number of Operations to Make Array Continuous](https://leetcode.com/problems/minimum-number-of-operations-to-make-array-continuous "使数组连续的最少操作数") | [Go](problems/minimum-number-of-operations-to-make-array-continuous) | Hard | +| 2008 | [Maximum Earnings From Taxi](https://leetcode.com/problems/maximum-earnings-from-taxi "出租车的最大盈利") | [Go](problems/maximum-earnings-from-taxi) | Medium | +| 2007 | [Find Original Array From Doubled Array](https://leetcode.com/problems/find-original-array-from-doubled-array "从双倍数组中还原原数组") | [Go](problems/find-original-array-from-doubled-array) | Medium | +| 2006 | [Count Number of Pairs With Absolute Difference K](https://leetcode.com/problems/count-number-of-pairs-with-absolute-difference-k "差的绝对值为 K 的数对数目") | [Go](problems/count-number-of-pairs-with-absolute-difference-k) | Easy | +| 2005 | [Subtree Removal Game with Fibonacci Tree](https://leetcode.com/problems/subtree-removal-game-with-fibonacci-tree) 🔒 | [Go](problems/subtree-removal-game-with-fibonacci-tree) | Hard | | 2004 | [The Number of Seniors and Juniors to Join the Company](https://leetcode.com/problems/the-number-of-seniors-and-juniors-to-join-the-company) 🔒 | [MySQL](problems/the-number-of-seniors-and-juniors-to-join-the-company) | Hard | | 2003 | [Smallest Missing Genetic Value in Each Subtree](https://leetcode.com/problems/smallest-missing-genetic-value-in-each-subtree "每棵子树内缺失的最小基因值") | [Go](problems/smallest-missing-genetic-value-in-each-subtree) | Hard | | 2002 | [Maximum Product of the Length of Two Palindromic Subsequences](https://leetcode.com/problems/maximum-product-of-the-length-of-two-palindromic-subsequences "两个回文子序列长度的最大乘积") | [Go](problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | Medium | @@ -164,7 +205,7 @@ LeetCode Problems' Solutions | 1921 | [Eliminate Maximum Number of Monsters](https://leetcode.com/problems/eliminate-maximum-number-of-monsters "消灭怪物的最大数量") | [Go](problems/eliminate-maximum-number-of-monsters) | Medium | | 1920 | [Build Array from Permutation](https://leetcode.com/problems/build-array-from-permutation "基于排列构建数组") | [Go](problems/build-array-from-permutation) | Easy | | 1919 | [Leetcodify Similar Friends](https://leetcode.com/problems/leetcodify-similar-friends "兴趣相同的朋友") 🔒 | [MySQL](problems/leetcodify-similar-friends) | Hard | -| 1918 | [Kth Smallest Subarray Sum](https://leetcode.com/problems/kth-smallest-subarray-sum "第 K 小的子序列和") 🔒 | [Go](problems/kth-smallest-subarray-sum) | Medium | +| 1918 | [Kth Smallest Subarray Sum](https://leetcode.com/problems/kth-smallest-subarray-sum "第 K 小的子数组和·") 🔒 | [Go](problems/kth-smallest-subarray-sum) | Medium | | 1917 | [Leetcodify Friends Recommendations](https://leetcode.com/problems/leetcodify-friends-recommendations) 🔒 | [MySQL](problems/leetcodify-friends-recommendations) | Hard | | 1916 | [Count Ways to Build Rooms in an Ant Colony](https://leetcode.com/problems/count-ways-to-build-rooms-in-an-ant-colony "统计为蚁群构筑房间的不同顺序") | [Go](problems/count-ways-to-build-rooms-in-an-ant-colony) | Hard | | 1915 | [Number of Wonderful Substrings](https://leetcode.com/problems/number-of-wonderful-substrings "最美子字符串的数目") | [Go](problems/number-of-wonderful-substrings) | Medium | @@ -523,7 +564,7 @@ LeetCode Problems' Solutions | 1562 | [Find Latest Group of Size M](https://leetcode.com/problems/find-latest-group-of-size-m "查找大小为 M 的最新分组") | [Go](problems/find-latest-group-of-size-m) | Medium | | 1561 | [Maximum Number of Coins You Can Get](https://leetcode.com/problems/maximum-number-of-coins-you-can-get "你可以获得的最大硬币数目") | [Go](problems/maximum-number-of-coins-you-can-get) | Medium | | 1560 | [Most Visited Sector in a Circular Track](https://leetcode.com/problems/most-visited-sector-in-a-circular-track "圆形赛道上经过次数最多的扇区") | [Go](problems/most-visited-sector-in-a-circular-track) | Easy | -| 1559 | [Detect Cycles in 2D Grid](https://leetcode.com/problems/detect-cycles-in-2d-grid "二维网格图中探测环") | [Go](problems/detect-cycles-in-2d-grid) | Hard | +| 1559 | [Detect Cycles in 2D Grid](https://leetcode.com/problems/detect-cycles-in-2d-grid "二维网格图中探测环") | [Go](problems/detect-cycles-in-2d-grid) | Medium | | 1558 | [Minimum Numbers of Function Calls to Make Target Array](https://leetcode.com/problems/minimum-numbers-of-function-calls-to-make-target-array "得到目标数组的最少函数调用次数") | [Go](problems/minimum-numbers-of-function-calls-to-make-target-array) | Medium | | 1557 | [Minimum Number of Vertices to Reach All Nodes](https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes "可以到达所有点的最少点数目") | [Go](problems/minimum-number-of-vertices-to-reach-all-nodes) | Medium | | 1556 | [Thousand Separator](https://leetcode.com/problems/thousand-separator "千位分隔数") | [Go](problems/thousand-separator) | Easy | diff --git a/problems/accepted-candidates-from-the-interviews/README.md b/problems/accepted-candidates-from-the-interviews/README.md new file mode 100644 index 000000000..25555e9f8 --- /dev/null +++ b/problems/accepted-candidates-from-the-interviews/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../kth-smallest-product-of-two-sorted-arrays "Kth Smallest Product of Two Sorted Arrays") +                 +[Next >](../check-if-numbers-are-ascending-in-a-sentence "Check if Numbers Are Ascending in a Sentence") + +## [2041. Accepted Candidates From the Interviews (Medium)](https://leetcode.com/problems/accepted-candidates-from-the-interviews "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/accepted-candidates-from-the-interviews/mysql_schemas.sql b/problems/accepted-candidates-from-the-interviews/mysql_schemas.sql new file mode 100644 index 000000000..6d1a6a9d4 --- /dev/null +++ b/problems/accepted-candidates-from-the-interviews/mysql_schemas.sql @@ -0,0 +1,20 @@ +Create table If Not Exists Candidates (candidate_id int, name varchar(30), years_of_exp int, interview_id int); +Create table If Not Exists Rounds (interview_id int, round_id int, score int); +Truncate table Candidates; +insert into Candidates (candidate_id, name, years_of_exp, interview_id) values ('11', 'Atticus', '1', '101'); +insert into Candidates (candidate_id, name, years_of_exp, interview_id) values ('9', 'Ruben', '6', '104'); +insert into Candidates (candidate_id, name, years_of_exp, interview_id) values ('6', 'Aliza', '10', '109'); +insert into Candidates (candidate_id, name, years_of_exp, interview_id) values ('8', 'Alfredo', '0', '107'); +Truncate table Rounds; +insert into Rounds (interview_id, round_id, score) values ('109', '3', '4'); +insert into Rounds (interview_id, round_id, score) values ('101', '2', '8'); +insert into Rounds (interview_id, round_id, score) values ('109', '4', '1'); +insert into Rounds (interview_id, round_id, score) values ('107', '1', '3'); +insert into Rounds (interview_id, round_id, score) values ('104', '3', '6'); +insert into Rounds (interview_id, round_id, score) values ('109', '1', '4'); +insert into Rounds (interview_id, round_id, score) values ('104', '4', '7'); +insert into Rounds (interview_id, round_id, score) values ('104', '1', '2'); +insert into Rounds (interview_id, round_id, score) values ('109', '2', '1'); +insert into Rounds (interview_id, round_id, score) values ('104', '2', '7'); +insert into Rounds (interview_id, round_id, score) values ('107', '2', '3'); +insert into Rounds (interview_id, round_id, score) values ('101', '1', '8'); diff --git a/problems/add-digits/README.md b/problems/add-digits/README.md index 46101290e..a691d58a8 100644 --- a/problems/add-digits/README.md +++ b/problems/add-digits/README.md @@ -44,12 +44,13 @@ Since 2 has only one digit, return it. ### Related Topics [[Math](../../tag/math/README.md)] - [[Number Theory](../../tag/number-theory/README.md)] [[Simulation](../../tag/simulation/README.md)] + [[Number Theory](../../tag/number-theory/README.md)] ### Similar Questions 1. [Happy Number](../happy-number) (Easy) 1. [Sum of Digits in the Minimum Number](../sum-of-digits-in-the-minimum-number) (Easy) + 1. [Sum of Digits of String After Convert](../sum-of-digits-of-string-after-convert) (Easy) ### Hints
    diff --git a/problems/advantage-shuffle/README.md b/problems/advantage-shuffle/README.md index b32ed4ae4..e32341403 100644 --- a/problems/advantage-shuffle/README.md +++ b/problems/advantage-shuffle/README.md @@ -33,6 +33,6 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/all-elements-in-two-binary-search-trees/README.md b/problems/all-elements-in-two-binary-search-trees/README.md index 7f3b1cadd..bcefb8caf 100644 --- a/problems/all-elements-in-two-binary-search-trees/README.md +++ b/problems/all-elements-in-two-binary-search-trees/README.md @@ -63,8 +63,8 @@ [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] - [[Binary Tree](../../tag/binary-tree/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/apply-discount-every-n-orders/README.md b/problems/apply-discount-every-n-orders/README.md index 74c248018..85a655178 100644 --- a/problems/apply-discount-every-n-orders/README.md +++ b/problems/apply-discount-every-n-orders/README.md @@ -71,9 +71,9 @@ cashier.getBill([2,3,5],[5,3,2]); // return 2500.0. 6th ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Design](../../tag/design/README.md)] ### Hints
    diff --git a/problems/arithmetic-subarrays/README.md b/problems/arithmetic-subarrays/README.md index d594dc368..f2b1ee7f4 100644 --- a/problems/arithmetic-subarrays/README.md +++ b/problems/arithmetic-subarrays/README.md @@ -64,10 +64,6 @@ In the 2nd query, the subarray is [5,9,3,7]. This can be [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Arithmetic Slices](../arithmetic-slices) (Medium) - 1. [Can Make Arithmetic Progression From Sequence](../can-make-arithmetic-progression-from-sequence) (Easy) - ### Hints
    Hint 1 diff --git a/problems/array-of-doubled-pairs/README.md b/problems/array-of-doubled-pairs/README.md index 9ca7bb697..7308b457d 100644 --- a/problems/array-of-doubled-pairs/README.md +++ b/problems/array-of-doubled-pairs/README.md @@ -53,7 +53,10 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] + +### Similar Questions + 1. [Find Original Array From Doubled Array](../find-original-array-from-doubled-array) (Medium) diff --git a/problems/average-height-of-buildings-in-each-segment/README.md b/problems/average-height-of-buildings-in-each-segment/README.md new file mode 100644 index 000000000..6bfe8ad96 --- /dev/null +++ b/problems/average-height-of-buildings-in-each-segment/README.md @@ -0,0 +1,41 @@ + + + + + + + +[< Previous](../longest-subsequence-repeated-k-times "Longest Subsequence Repeated k Times") +                 +[Next >](../maximum-difference-between-increasing-elements "Maximum Difference Between Increasing Elements") + +## [2015. Average Height of Buildings in Each Segment (Medium)](https://leetcode.com/problems/average-height-of-buildings-in-each-segment "") + + + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +Try sorting the start and end points of each building. +
    + +
    +Hint 2 +The naive solution is to go through each position on the street and keep track of the sum of all the buildings at that position and the number of buildings at that position. +
    + +
    +Hint 3 +How could we optimize that solution to pass? +
    + +
    +Hint 4 +We don't need to go through every position, just the ones where a building starts or a building ends. +
    diff --git a/problems/balance-a-binary-search-tree/README.md b/problems/balance-a-binary-search-tree/README.md index 64ca4a5eb..c224333b7 100644 --- a/problems/balance-a-binary-search-tree/README.md +++ b/problems/balance-a-binary-search-tree/README.md @@ -40,11 +40,11 @@ ### Related Topics + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] - [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/basic-calculator/README.md b/problems/basic-calculator/README.md index b5704bfb3..d6bb98e79 100644 --- a/problems/basic-calculator/README.md +++ b/problems/basic-calculator/README.md @@ -45,16 +45,16 @@
  • s consists of digits, '+', '-', '(', ')', and ' '.
  • s represents a valid expression.
  • '+' is not used as a unary operation.
  • -
  • '-' could be used as a unary operation but it has to be inside parentheses.
  • +
  • '-' could be used as a unary operation and in this case, it will not be used directly after a +ve or -ve signs (will be inside parentheses).
  • There will be no two consecutive operators in the input.
  • Every number and running calculation will fit in a signed 32-bit integer.
  • ### Related Topics - [[Stack](../../tag/stack/README.md)] - [[Recursion](../../tag/recursion/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions 1. [Evaluate Reverse Polish Notation](../evaluate-reverse-polish-notation) (Medium) @@ -62,3 +62,4 @@ 1. [Different Ways to Add Parentheses](../different-ways-to-add-parentheses) (Medium) 1. [Expression Add Operators](../expression-add-operators) (Hard) 1. [Basic Calculator III](../basic-calculator-iii) (Hard) + 1. [The Score of Students Solving Math Expression](../the-score-of-students-solving-math-expression) (Hard) diff --git a/problems/beautiful-arrangement/README.md b/problems/beautiful-arrangement/README.md index 71b7abe0f..f772c87c4 100644 --- a/problems/beautiful-arrangement/README.md +++ b/problems/beautiful-arrangement/README.md @@ -50,10 +50,10 @@ The second beautiful arrangement is [2,1]: ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] ### Similar Questions diff --git a/problems/binary-search-tree-iterator/README.md b/problems/binary-search-tree-iterator/README.md index cbac9f23f..a76bdfa24 100644 --- a/problems/binary-search-tree-iterator/README.md +++ b/problems/binary-search-tree-iterator/README.md @@ -76,3 +76,4 @@ bSTIterator.hasNext(); // return False 1. [Zigzag Iterator](../zigzag-iterator) (Medium) 1. [Peeking Iterator](../peeking-iterator) (Medium) 1. [Inorder Successor in BST](../inorder-successor-in-bst) (Medium) + 1. [Binary Search Tree Iterator II](../binary-search-tree-iterator-ii) (Medium) diff --git a/problems/binary-search-tree-to-greater-sum-tree/README.md b/problems/binary-search-tree-to-greater-sum-tree/README.md index 1ce358b4e..b0c0f0076 100644 --- a/problems/binary-search-tree-to-greater-sum-tree/README.md +++ b/problems/binary-search-tree-to-greater-sum-tree/README.md @@ -11,18 +11,16 @@ ## [1038. Binary Search Tree to Greater Sum Tree (Medium)](https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree "把二叉搜索树转换为累加树") -

    Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.

    +

    Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum of all keys greater than the original key in BST.

    As a reminder, a binary search tree is a tree that satisfies these constraints:

      -
    • The left subtree of a node contains only nodes with keys less than the node's key.
    • -
    • The right subtree of a node contains only nodes with keys greater than the node's key.
    • +
    • The left subtree of a node contains only nodes with keys less than the node's key.
    • +
    • The right subtree of a node contains only nodes with keys greater than the node's key.
    • Both the left and right subtrees must also be binary search trees.
    -

    Note: This question is the same as 538: https://leetcode.com/problems/convert-bst-to-greater-tree/

    -

     

    Example 1:

    @@ -62,6 +60,9 @@
  • root is guaranteed to be a valid binary search tree.
  • +

     

    +

    Note: This question is the same as 538: https://leetcode.com/problems/convert-bst-to-greater-tree/

    + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/binary-subarrays-with-sum/README.md b/problems/binary-subarrays-with-sum/README.md index e68171cd9..a618aad06 100644 --- a/problems/binary-subarrays-with-sum/README.md +++ b/problems/binary-subarrays-with-sum/README.md @@ -47,5 +47,5 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Prefix Sum](../../tag/prefix-sum/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] diff --git a/problems/break-a-palindrome/README.md b/problems/break-a-palindrome/README.md index da9de05c1..822edba2f 100644 --- a/problems/break-a-palindrome/README.md +++ b/problems/break-a-palindrome/README.md @@ -57,8 +57,8 @@ Of all the ways, "aaccba" is the lexicographically smallest. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/brightest-position-on-street/README.md b/problems/brightest-position-on-street/README.md new file mode 100644 index 000000000..9c4a0ba90 --- /dev/null +++ b/problems/brightest-position-on-street/README.md @@ -0,0 +1,35 @@ + + + + + + + +[< Previous](../number-of-accounts-that-did-not-stream "Number of Accounts That Did Not Stream") +                 +[Next >](../convert-1d-array-into-2d-array "Convert 1D Array Into 2D Array") + +## [2021. Brightest Position on Street (Medium)](https://leetcode.com/problems/brightest-position-on-street "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +Convert lights into an array of ranges representing the range where each street light can light up and sort the start and end points of the ranges. +
    + +
    +Hint 2 +Do we need to traverse all possible positions on the street? +
    + +
    +Hint 3 +No, we don't, we only need to go to the start and end points of the ranges for each streetlight. +
    diff --git a/problems/build-an-array-with-stack-operations/README.md b/problems/build-an-array-with-stack-operations/README.md index 1a0aec601..60dd71263 100644 --- a/problems/build-an-array-with-stack-operations/README.md +++ b/problems/build-an-array-with-stack-operations/README.md @@ -68,8 +68,8 @@ Read number 3 and automatically push in the array -> [1,3] ### Related Topics - [[Array](../../tag/array/README.md)] [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/build-binary-expression-tree-from-infix-expression/README.md b/problems/build-binary-expression-tree-from-infix-expression/README.md index 7a5f902f0..c6bd15cd5 100644 --- a/problems/build-binary-expression-tree-from-infix-expression/README.md +++ b/problems/build-binary-expression-tree-from-infix-expression/README.md @@ -14,11 +14,15 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] - [[String](../../tag/string/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Basic Calculator III](../basic-calculator-iii) (Hard) + 1. [Check If Two Expression Trees are Equivalent](../check-if-two-expression-trees-are-equivalent) (Medium) + ### Hints
    Hint 1 diff --git a/problems/bulb-switcher-iii/README.md b/problems/bulb-switcher-iii/README.md index 49ff0d736..bc5d0acba 100644 --- a/problems/bulb-switcher-iii/README.md +++ b/problems/bulb-switcher-iii/README.md @@ -13,15 +13,13 @@

    There is a room with n bulbs, numbered from 1 to n, arranged in a row from left to right. Initially, all the bulbs are turned off.

    -

    At moment k (for k from 0 to n - 1), we turn on the light[k] bulb. A bulb change color to blue only if it is on and all the previous bulbs (to the left) are turned on too.

    +

    At moment k (for k from 0 to n - 1), we turn on the light[k] bulb. A bulb changes color to blue only if it is on and all the previous bulbs (to the left) are turned on too.

    -

    Return the number of moments in which all turned on bulbs are blue.

    +

    Return the number of moments in which all turned-on bulbs are blue.

     

    Example 1:

    - -

    - +
     Input: light = [2,1,3,5,4]
     Output: 3
    @@ -63,14 +61,18 @@ Bulb 4th changes to blue at the moment 3.
     

    Constraints:

      -
    • n == light.length
    • -
    • 1 <= n <= 5 * 10^4
    • -
    • light is a permutation of  [1, 2, ..., n]
    • +
    • n == light.length
    • +
    • 1 <= n <= 5 * 104
    • +
    • light is a permutation of the numbers in the range [1, n]
    ### Related Topics [[Array](../../tag/array/README.md)] +### Similar Questions + 1. [Bulb Switcher](../bulb-switcher) (Medium) + 1. [Bulb Switcher II](../bulb-switcher-ii) (Medium) + ### Hints
    Hint 1 diff --git a/problems/check-if-numbers-are-ascending-in-a-sentence/README.md b/problems/check-if-numbers-are-ascending-in-a-sentence/README.md new file mode 100644 index 000000000..c74e2a063 --- /dev/null +++ b/problems/check-if-numbers-are-ascending-in-a-sentence/README.md @@ -0,0 +1,89 @@ + + + + + + + +[< Previous](../accepted-candidates-from-the-interviews "Accepted Candidates From the Interviews") +                 +[Next >](../simple-bank-system "Simple Bank System") + +## [2042. Check if Numbers Are Ascending in a Sentence (Easy)](https://leetcode.com/problems/check-if-numbers-are-ascending-in-a-sentence "检查句子中的数字是否递增") + +

    A sentence is a list of tokens separated by a single space with no leading or trailing spaces. Every token is either a positive number consisting of digits 0-9 with no leading zeros, or a word consisting of lowercase English letters.

    + +
      +
    • For example, "a puppy has 2 eyes 4 legs" is a sentence with seven tokens: "2" and "4" are numbers and the other tokens such as "puppy" are words.
    • +
    + +

    Given a string s representing a sentence, you need to check if all the numbers in s are strictly increasing from left to right (i.e., other than the last number, each number is strictly smaller than the number on its right in s).

    + +

    Return true if so, or false otherwise.

    + +

     

    +

    Example 1:

    +example-1 +
    +Input: s = "1 box has 3 blue 4 red 6 green and 12 yellow marbles"
    +Output: true
    +Explanation: The numbers in s are: 1, 3, 4, 6, 12.
    +They are strictly increasing from left to right: 1 < 3 < 4 < 6 < 12.
    +
    + +

    Example 2:

    + +
    +Input: s = "hello world 5 x 5"
    +Output: false
    +Explanation: The numbers in s are: 5, 5. They are not strictly increasing.
    +
    + +

    Example 3:

    +example-3 +
    +Input: s = "sunset is at 7 51 pm overnight lows will be in the low 50 and 60 s"
    +Output: false
    +Explanation: The numbers in s are: 7, 51, 50, 60. They are not strictly increasing.
    +
    + +

    Example 4:

    + +
    +Input: s = "4 5 11 26"
    +Output: true
    +Explanation: The numbers in s are: 4, 5, 11, 26.
    +They are strictly increasing from left to right: 4 < 5 < 11 < 26.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= s.length <= 200
    • +
    • s consists of lowercase English letters, spaces, and digits from 0 to 9, inclusive.
    • +
    • The number of tokens in s is between 2 and 100, inclusive.
    • +
    • The tokens in s are separated by a single space.
    • +
    • There are at least two numbers in s.
    • +
    • Each number in s is a positive number less than 100, with no leading zeros.
    • +
    • s contains no leading or trailing spaces.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Use string tokenization of your language to extract all the tokens of the string easily. +
    + +
    +Hint 2 +For each token extracted, how can you tell if it is a number? Does the first letter being a digit mean something? +
    + +
    +Hint 3 +Compare the number with the previously occurring number to check if ascending order is maintained. +
    diff --git a/problems/check-if-two-expression-trees-are-equivalent/README.md b/problems/check-if-two-expression-trees-are-equivalent/README.md index cc128802b..7b0b251b7 100644 --- a/problems/check-if-two-expression-trees-are-equivalent/README.md +++ b/problems/check-if-two-expression-trees-are-equivalent/README.md @@ -18,9 +18,6 @@ [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] -### Similar Questions - 1. [Build Binary Expression Tree From Infix Expression](../build-binary-expression-tree-from-infix-expression) (Hard) - ### Hints
    Hint 1 diff --git a/problems/check-if-word-can-be-placed-in-crossword/README.md b/problems/check-if-word-can-be-placed-in-crossword/README.md new file mode 100644 index 000000000..e747c109d --- /dev/null +++ b/problems/check-if-word-can-be-placed-in-crossword/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../grid-game "Grid Game") +                 +[Next >](../the-score-of-students-solving-math-expression "The Score of Students Solving Math Expression") + +## [2018. Check if Word Can Be Placed In Crossword (Medium)](https://leetcode.com/problems/check-if-word-can-be-placed-in-crossword "判断单词是否能放入填字游戏内") + +

    You are given an m x n matrix board, representing the current state of a crossword puzzle. The crossword contains lowercase English letters (from solved words), ' ' to represent any empty cells, and '#' to represent any blocked cells.

    + +

    A word can be placed horizontally (left to right or right to left) or vertically (top to bottom or bottom to top) in the board if:

    + +
      +
    • It does not occupy a cell containing the character '#'.
    • +
    • The cell each letter is placed in must either be ' ' (empty) or match the letter already on the board.
    • +
    • There must not be any empty cells ' ' or other lowercase letters directly left or right of the word if the word was placed horizontally.
    • +
    • There must not be any empty cells ' ' or other lowercase letters directly above or below the word if the word was placed vertically.
    • +
    + +

    Given a string word, return true if word can be placed in board, or false otherwise.

    + +

     

    +

    Example 1:

    + +
    +Input: board = [["#", " ", "#"], [" ", " ", "#"], ["#", "c", " "]], word = "abc"
    +Output: true
    +Explanation: The word "abc" can be placed as shown above (top to bottom).
    +
    + +

    Example 2:

    + +
    +Input: board = [[" ", "#", "a"], [" ", "#", "c"], [" ", "#", "a"]], word = "ac"
    +Output: false
    +Explanation: It is impossible to place the word because there will always be a space/letter above or below it.
    + +

    Example 3:

    + +
    +Input: board = [["#", " ", "#"], [" ", " ", "#"], ["#", " ", "c"]], word = "ca"
    +Output: true
    +Explanation: The word "ca" can be placed as shown above (right to left). 
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == board.length
    • +
    • n == board[i].length
    • +
    • 1 <= m * n <= 2 * 105
    • +
    • board[i][j] will be ' ', '#', or a lowercase English letter.
    • +
    • 1 <= word.length <= max(m, n)
    • +
    • word will contain only lowercase English letters.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Check all possible placements for the word. +
    + +
    +Hint 2 +There is a limited number of places where a word can start. +
    diff --git a/problems/cinema-seat-allocation/README.md b/problems/cinema-seat-allocation/README.md index 39d2387c6..7f0fefe93 100644 --- a/problems/cinema-seat-allocation/README.md +++ b/problems/cinema-seat-allocation/README.md @@ -57,10 +57,10 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/circle-and-rectangle-overlapping/README.md b/problems/circle-and-rectangle-overlapping/README.md index edda53622..13ebd99f8 100644 --- a/problems/circle-and-rectangle-overlapping/README.md +++ b/problems/circle-and-rectangle-overlapping/README.md @@ -64,8 +64,8 @@ ### Related Topics - [[Math](../../tag/math/README.md)] [[Geometry](../../tag/geometry/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/connecting-cities-with-minimum-cost/README.md b/problems/connecting-cities-with-minimum-cost/README.md index cc9b861ea..10856ca12 100644 --- a/problems/connecting-cities-with-minimum-cost/README.md +++ b/problems/connecting-cities-with-minimum-cost/README.md @@ -56,8 +56,8 @@ There is no way to connect all cities even if all edges are used. ### Related Topics [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] - [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] ### Hints
    diff --git a/problems/consecutive-characters/README.md b/problems/consecutive-characters/README.md index 9ea25d484..c605bae72 100644 --- a/problems/consecutive-characters/README.md +++ b/problems/consecutive-characters/README.md @@ -64,10 +64,6 @@ ### Related Topics [[String](../../tag/string/README.md)] -### Similar Questions - 1. [Max Consecutive Ones](../max-consecutive-ones) (Easy) - 1. [Count Number of Homogenous Substrings](../count-number-of-homogenous-substrings) (Medium) - ### Hints
    Hint 1 diff --git a/problems/consecutive-numbers/README.md b/problems/consecutive-numbers/README.md index 5e2dc3f26..283045d24 100644 --- a/problems/consecutive-numbers/README.md +++ b/problems/consecutive-numbers/README.md @@ -29,11 +29,13 @@ id is the primary key for this table.

    Return the result table in any order.

    -

    The query result format is in the following example:

    +

    The query result format is in the following example.

     

    +

    Example 1:

    +Input: 
     Logs table:
     +----+-----+
     | Id | Num |
    @@ -46,14 +48,13 @@ Logs table:
     | 6  | 2   |
     | 7  | 2   |
     +----+-----+
    -
    -Result table:
    +Output: 
     +-----------------+
     | ConsecutiveNums |
     +-----------------+
     | 1               |
     +-----------------+
    -1 is the only number that appears consecutively for at least three times.
    +Explanation: 1 is the only number that appears consecutively for at least three times.
     
    ### Related Topics diff --git a/problems/constrained-subsequence-sum/README.md b/problems/constrained-subsequence-sum/README.md index dfbb62c89..d11ec6674 100644 --- a/problems/constrained-subsequence-sum/README.md +++ b/problems/constrained-subsequence-sum/README.md @@ -49,12 +49,12 @@ ### Related Topics + [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Queue](../../tag/queue/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] [[Monotonic Queue](../../tag/monotonic-queue/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/construct-binary-search-tree-from-preorder-traversal/README.md b/problems/construct-binary-search-tree-from-preorder-traversal/README.md index b05d0daa9..e40306a8c 100644 --- a/problems/construct-binary-search-tree-from-preorder-traversal/README.md +++ b/problems/construct-binary-search-tree-from-preorder-traversal/README.md @@ -39,7 +39,7 @@
    • 1 <= preorder.length <= 100
    • -
    • 1 <= preorder[i] <= 108
    • +
    • 1 <= preorder[i] <= 1000
    • All the values of preorder are unique.
    diff --git a/problems/convert-1d-array-into-2d-array/README.md b/problems/convert-1d-array-into-2d-array/README.md new file mode 100644 index 000000000..923aab8fc --- /dev/null +++ b/problems/convert-1d-array-into-2d-array/README.md @@ -0,0 +1,90 @@ + + + + + + + +[< Previous](../brightest-position-on-street "Brightest Position on Street") +                 +[Next >](../number-of-pairs-of-strings-with-concatenation-equal-to-target "Number of Pairs of Strings With Concatenation Equal to Target") + +## [2022. Convert 1D Array Into 2D Array (Easy)](https://leetcode.com/problems/convert-1d-array-into-2d-array "将一维数组转变成二维数组") + +

    You are given a 0-indexed 1-dimensional (1D) integer array original, and two integers, m and n. You are tasked with creating a 2-dimensional (2D) array with m rows and n columns using all the elements from original.

    + +

    The elements from indices 0 to n - 1 (inclusive) of original should form the first row of the constructed 2D array, the elements from indices n to 2 * n - 1 (inclusive) should form the second row of the constructed 2D array, and so on.

    + +

    Return an m x n 2D array constructed according to the above procedure, or an empty 2D array if it is impossible.

    + +

     

    +

    Example 1:

    + +
    +Input: original = [1,2,3,4], m = 2, n = 2
    +Output: [[1,2],[3,4]]
    +Explanation:
    +The constructed 2D array should contain 2 rows and 2 columns.
    +The first group of n=2 elements in original, [1,2], becomes the first row in the constructed 2D array.
    +The second group of n=2 elements in original, [3,4], becomes the second row in the constructed 2D array.
    +
    + +

    Example 2:

    + +
    +Input: original = [1,2,3], m = 1, n = 3
    +Output: [[1,2,3]]
    +Explanation:
    +The constructed 2D array should contain 1 row and 3 columns.
    +Put all three elements in original into the first row of the constructed 2D array.
    +
    + +

    Example 3:

    + +
    +Input: original = [1,2], m = 1, n = 1
    +Output: []
    +Explanation:
    +There are 2 elements in original.
    +It is impossible to fit 2 elements in a 1x1 2D array, so return an empty 2D array.
    +
    + +

    Example 4:

    + +
    +Input: original = [3], m = 1, n = 2
    +Output: []
    +Explanation:
    +There is 1 element in original.
    +It is impossible to make 1 element fill all the spots in a 1x2 2D array, so return an empty 2D array.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= original.length <= 5 * 104
    • +
    • 1 <= original[i] <= 105
    • +
    • 1 <= m, n <= 4 * 104
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +When is it possible to convert original into a 2D array and when is it impossible? +
    + +
    +Hint 2 +It is possible if and only if m * n == original.length +
    + +
    +Hint 3 +If it is possible to convert original to a 2D array, keep an index i such that original[i] is the next element to add to the 2D array. +
    diff --git a/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md b/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md index 6380ffd0d..493290f51 100644 --- a/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md +++ b/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md @@ -35,11 +35,11 @@

    ### Related Topics + [[Linked List](../../tag/linked-list/README.md)] [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] - [[Linked List](../../tag/linked-list/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] [[Doubly-Linked List](../../tag/doubly-linked-list/README.md)] diff --git a/problems/coordinate-with-maximum-network-quality/README.md b/problems/coordinate-with-maximum-network-quality/README.md index f9e1f72bd..826eb0d7e 100644 --- a/problems/coordinate-with-maximum-network-quality/README.md +++ b/problems/coordinate-with-maximum-network-quality/README.md @@ -11,18 +11,23 @@ ## [1620. Coordinate With Maximum Network Quality (Medium)](https://leetcode.com/problems/coordinate-with-maximum-network-quality "网络信号最好的坐标") -

    You are given an array of network towers towers and an integer radius, where towers[i] = [xi, yi, qi] denotes the ith network tower with location (xi, yi) and quality factor qi. All the coordinates are integral coordinates on the X-Y plane, and the distance between two coordinates is the Euclidean distance.

    +

    You are given an array of network towers towers, where towers[i] = [xi, yi, qi] denotes the ith network tower with location (xi, yi) and quality factor qi. All the coordinates are integral coordinates on the X-Y plane, and the distance between the two coordinates is the Euclidean distance.

    -

    The integer radius denotes the maximum distance in which the tower is reachable. The tower is reachable if the distance is less than or equal to radius. Outside that distance, the signal becomes garbled, and the tower is not reachable.

    +

    You are also given an integer radius where a tower is reachable if the distance is less than or equal to radius. Outside that distance, the signal becomes garbled, and the tower is not reachable.

    The signal quality of the ith tower at a coordinate (x, y) is calculated with the formula ⌊qi / (1 + d)⌋, where d is the distance between the tower and the coordinate. The network quality at a coordinate is the sum of the signal qualities from all the reachable towers.

    -

    Return the integral coordinate where the network quality is maximum. If there are multiple coordinates with the same network quality, return the lexicographically minimum coordinate.

    +

    Return the array [cx, cy] representing the integral coordinate (cx, cy) where the network quality is maximum. If there are multiple coordinates with the same network quality, return the lexicographically minimum non-negative coordinate.

    Note:

      -
    • A coordinate (x1, y1) is lexicographically smaller than (x2, y2) if either x1 < x2 or x1 == x2 and y1 < y2.
    • +
    • A coordinate (x1, y1) is lexicographically smaller than (x2, y2) if either: +
        +
      • x1 < x2, or
      • +
      • x1 == x2 and y1 < y2.
      • +
      +
    • ⌊val⌋ is the greatest integer less than or equal to val (the floor function).
    @@ -32,18 +37,18 @@
     Input: towers = [[1,2,5],[2,1,7],[3,1,9]], radius = 2
     Output: [2,1]
    -Explanation: 
    -At coordinate (2, 1) the total quality is 13
    +Explanation: At coordinate (2, 1) the total quality is 13.
     - Quality of 7 from (2, 1) results in ⌊7 / (1 + sqrt(0)⌋ = ⌊7⌋ = 7
     - Quality of 5 from (1, 2) results in ⌊5 / (1 + sqrt(2)⌋ = ⌊2.07⌋ = 2
     - Quality of 9 from (3, 1) results in ⌊9 / (1 + sqrt(1)⌋ = ⌊4.5⌋ = 4
    -No other coordinate has higher quality.
    +No other coordinate has a higher network quality.

    Example 2:

     Input: towers = [[23,11,21]], radius = 9
     Output: [23,11]
    +Explanation: Since there is only one tower, the network quality is highest right at the tower's location.
     

    Example 3:

    @@ -51,6 +56,7 @@ No other coordinate has higher quality.
     Input: towers = [[1,2,13],[2,1,7],[0,1,9]], radius = 2
     Output: [1,2]
    +Explanation: Coordinate (1, 2) has the highest network quality.
     

    Example 4:

    @@ -58,7 +64,16 @@ No other coordinate has higher quality.
     Input: towers = [[2,1,9],[0,1,9]], radius = 2
     Output: [0,1]
    -Explanation: Both (0, 1) and (2, 1) are optimal in terms of quality but (0, 1) is lexicograpically minimal.
    +Explanation: Both (0, 1) and (2, 1) are optimal in terms of quality, but (0, 1) is lexicographically minimal.
    +
    + +

    Example 5:

    + +
    +Input: towers = [[42,0,0]], radius = 7
    +Output: [0,0]
    +Explanation: The network quality is 0 at every coordinate, even at the tower's location.
    +Thus, the lexicographically minimum non-negative coordinate is (0, 0).
     

     

    diff --git a/problems/count-all-possible-routes/README.md b/problems/count-all-possible-routes/README.md index 89fadfe87..979194249 100644 --- a/problems/count-all-possible-routes/README.md +++ b/problems/count-all-possible-routes/README.md @@ -81,9 +81,9 @@ ### Related Topics + [[Memoization](../../tag/memoization/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Memoization](../../tag/memoization/README.md)] ### Hints
    diff --git a/problems/count-good-triplets/README.md b/problems/count-good-triplets/README.md index 8971656d9..dc0e071a9 100644 --- a/problems/count-good-triplets/README.md +++ b/problems/count-good-triplets/README.md @@ -56,6 +56,9 @@ [[Array](../../tag/array/README.md)] [[Enumeration](../../tag/enumeration/README.md)] +### Similar Questions + 1. [Count Special Quadruplets](../count-special-quadruplets) (Easy) + ### Hints
    Hint 1 diff --git a/problems/count-number-of-maximum-bitwise-or-subsets/README.md b/problems/count-number-of-maximum-bitwise-or-subsets/README.md new file mode 100644 index 000000000..30e2c4f41 --- /dev/null +++ b/problems/count-number-of-maximum-bitwise-or-subsets/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../simple-bank-system "Simple Bank System") +                 +[Next >](../second-minimum-time-to-reach-destination "Second Minimum Time to Reach Destination") + +## [2044. Count Number of Maximum Bitwise-OR Subsets (Medium)](https://leetcode.com/problems/count-number-of-maximum-bitwise-or-subsets "统计按位或能得到最大值的子集数目") + +

    Given an integer array nums, find the maximum possible bitwise OR of a subset of nums and return the number of different non-empty subsets with the maximum bitwise OR.

    + +

    An array a is a subset of an array b if a can be obtained from b by deleting some (possibly zero) elements of b. Two subsets are considered different if the indices of the elements chosen are different.

    + +

    The bitwise OR of an array a is equal to a[0] OR a[1] OR ... OR a[a.length - 1] (0-indexed).

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [3,1]
    +Output: 2
    +Explanation: The maximum possible bitwise OR of a subset is 3. There are 2 subsets with a bitwise OR of 3:
    +- [3]
    +- [3,1]
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,2,2]
    +Output: 7
    +Explanation: All non-empty subsets of [2,2,2] have a bitwise OR of 2. There are 23 - 1 = 7 total subsets.
    +
    + +

    Example 3:

    + +
    +Input: nums = [3,2,1,5]
    +Output: 6
    +Explanation: The maximum possible bitwise OR of a subset is 7. There are 6 subsets with a bitwise OR of 7:
    +- [3,5]
    +- [3,1,5]
    +- [3,2,5]
    +- [3,2,1,5]
    +- [2,5]
    +- [2,1,5]
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 16
    • +
    • 1 <= nums[i] <= 105
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
    +Hint 1 +Can we enumerate all possible subsets? +
    + +
    +Hint 2 +The maximum bitwise-OR is the bitwise-OR of the whole array. +
    diff --git a/problems/count-number-of-pairs-with-absolute-difference-k/README.md b/problems/count-number-of-pairs-with-absolute-difference-k/README.md new file mode 100644 index 000000000..4cbf730a0 --- /dev/null +++ b/problems/count-number-of-pairs-with-absolute-difference-k/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](../subtree-removal-game-with-fibonacci-tree "Subtree Removal Game with Fibonacci Tree") +                 +[Next >](../find-original-array-from-doubled-array "Find Original Array From Doubled Array") + +## [2006. Count Number of Pairs With Absolute Difference K (Easy)](https://leetcode.com/problems/count-number-of-pairs-with-absolute-difference-k "差的绝对值为 K 的数对数目") + +

    Given an integer array nums and an integer k, return the number of pairs (i, j) where i < j such that |nums[i] - nums[j]| == k.

    + +

    The value of |x| is defined as:

    + +
      +
    • x if x >= 0.
    • +
    • -x if x < 0.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,2,1], k = 1
    +Output: 4
    +Explanation: The pairs with an absolute difference of 1 are:
    +- [1,2,2,1]
    +- [1,2,2,1]
    +- [1,2,2,1]
    +- [1,2,2,1]
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,3], k = 3
    +Output: 0
    +Explanation: There are no pairs with an absolute difference of 3.
    +
    + +

    Example 3:

    + +
    +Input: nums = [3,2,1,5,4], k = 2
    +Output: 3
    +Explanation: The pairs with an absolute difference of 2 are:
    +- [3,2,1,5,4]
    +- [3,2,1,5,4]
    +- [3,2,1,5,4]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 200
    • +
    • 1 <= nums[i] <= 100
    • +
    • 1 <= k <= 99
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Can we check every possible pair? +
    + +
    +Hint 2 +Can we use a nested for loop to solve this problem? +
    diff --git a/problems/count-number-of-teams/README.md b/problems/count-number-of-teams/README.md index 2f27f44d2..6ee99a555 100644 --- a/problems/count-number-of-teams/README.md +++ b/problems/count-number-of-teams/README.md @@ -57,9 +57,9 @@ ### Related Topics + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] ### Hints
    diff --git a/problems/count-primes/README.md b/problems/count-primes/README.md index ca4a98cc0..efef39034 100644 --- a/problems/count-primes/README.md +++ b/problems/count-primes/README.md @@ -9,9 +9,9 @@                  [Next >](../isomorphic-strings "Isomorphic Strings") -## [204. Count Primes (Easy)](https://leetcode.com/problems/count-primes "计数质数") +## [204. Count Primes (Medium)](https://leetcode.com/problems/count-primes "计数质数") -

    Count the number of prime numbers less than a non-negative number, n.

    +

    Given an integer n, return the number of prime numbers that are strictly less than n.

     

    Example 1:

    diff --git a/problems/count-servers-that-communicate/README.md b/problems/count-servers-that-communicate/README.md index 7789405cf..77cb4e4a3 100644 --- a/problems/count-servers-that-communicate/README.md +++ b/problems/count-servers-that-communicate/README.md @@ -57,12 +57,12 @@ Return the number of servers that communicate with any other server.

    ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] - [[Counting](../../tag/counting/README.md)] [[Matrix](../../tag/matrix/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/count-subarrays-with-more-ones-than-zeros/README.md b/problems/count-subarrays-with-more-ones-than-zeros/README.md new file mode 100644 index 000000000..c7f52a097 --- /dev/null +++ b/problems/count-subarrays-with-more-ones-than-zeros/README.md @@ -0,0 +1,39 @@ + + + + + + + +[< Previous](../smallest-k-length-subsequence-with-occurrences-of-a-letter "Smallest K-Length Subsequence With Occurrences of a Letter") +                 +[Next >](../two-out-of-three "Two Out of Three") + +## [2031. Count Subarrays With More Ones Than Zeros (Medium)](https://leetcode.com/problems/count-subarrays-with-more-ones-than-zeros "") + + + +### Related Topics + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Merge Sort](../../tag/merge-sort/README.md)] + +### Hints +
    +Hint 1 +Change the zeros in nums to -1 and create a prefix sum array prefixSum using the new nums. +
    + +
    +Hint 2 +If prefixSum[i] for any index i in the range 0 <= i < prefixSum.length is positive, that means that there are more ones than zeros in the prefix ending at index i. +
    + +
    +Hint 3 +If prefixSum[j] > prefixSum[i] for two indexes i and j such that 0 <= i < j < prefixSum.length, that means that there are more ones than zeros in nums in the range [i + 1 : j] (inclusive) +
    diff --git a/problems/course-schedule-iii/README.md b/problems/course-schedule-iii/README.md index 577881318..d9d50a174 100644 --- a/problems/course-schedule-iii/README.md +++ b/problems/course-schedule-iii/README.md @@ -54,8 +54,8 @@ The 4th course cannot be taken now, since you will finish it on the 3 ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions diff --git a/problems/create-a-session-bar-chart/README.md b/problems/create-a-session-bar-chart/README.md index 9bf7444db..373135897 100644 --- a/problems/create-a-session-bar-chart/README.md +++ b/problems/create-a-session-bar-chart/README.md @@ -15,6 +15,3 @@ ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Count Salary Categories](../count-salary-categories) (Medium) diff --git a/problems/customers-who-never-order/README.md b/problems/customers-who-never-order/README.md index 8940d8b39..68643fc72 100644 --- a/problems/customers-who-never-order/README.md +++ b/problems/customers-who-never-order/README.md @@ -11,11 +11,49 @@ ## [183. Customers Who Never Order (Easy)](https://leetcode.com/problems/customers-who-never-order "从不订购的客户") -

    Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything.

    +

    Table: Customers

    -

    Table: Customers.

    +
    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| Id          | int     |
    +| Name        | varchar |
    ++-------------+---------+
    +Id is the primary key column for this table.
    +Each row of this table indicates the ID and name of a customer.
    +
    + +

     

    + +

    Table: Orders

    + +
    ++-------------+------+
    +| Column Name | Type |
    ++-------------+------+
    +| Id          | int  |
    +| CustomerId  | int  |
    ++-------------+------+
    +Id is the primary key column for this table.
    +CustomerId is a foreign key of the ID from the Customers table.
    +Each row of this table indicates the ID of an order and the ID of the customer who ordered it.
    +
    + +

     

    + +

    Write an SQL query to report all customers who never order anything.

    + +

    Return the result table in any order.

    + +

    The query result format is in the following example.

    + +

     

    +

    Example 1:

    +Input: 
    +Customers table:
     +----+-------+
     | Id | Name  |
     +----+-------+
    @@ -24,22 +62,14 @@
     | 3  | Sam   |
     | 4  | Max   |
     +----+-------+
    -
    - -

    Table: Orders.

    - -
    +Orders table:
     +----+------------+
     | Id | CustomerId |
     +----+------------+
     | 1  | 3          |
     | 2  | 1          |
     +----+------------+
    -
    - -

    Using the above tables as example, return the following:

    - -
    +Output: 
     +-----------+
     | Customers |
     +-----------+
    diff --git a/problems/daily-temperatures/README.md b/problems/daily-temperatures/README.md
    index a4c1b1ee8..39b5d4714 100644
    --- a/problems/daily-temperatures/README.md
    +++ b/problems/daily-temperatures/README.md
    @@ -33,12 +33,13 @@
     
     
     ### Related Topics
    -  [[Stack](../../tag/stack/README.md)]
       [[Array](../../tag/array/README.md)]
    +  [[Stack](../../tag/stack/README.md)]
       [[Monotonic Stack](../../tag/monotonic-stack/README.md)]
     
     ### Similar Questions
       1. [Next Greater Element I](../next-greater-element-i) (Easy)
    +  1. [Online Stock Span](../online-stock-span) (Medium)
     
     ### Hints
     
    diff --git a/problems/data-stream-as-disjoint-intervals/README.md b/problems/data-stream-as-disjoint-intervals/README.md index 13b5b4ef5..8bae905bf 100644 --- a/problems/data-stream-as-disjoint-intervals/README.md +++ b/problems/data-stream-as-disjoint-intervals/README.md @@ -57,8 +57,8 @@ summaryRanges.getIntervals(); // return [[1, 3], [6, 7]]

    Follow up: What if there are lots of merges and the number of disjoint intervals is small compared to the size of the data stream?

    ### Related Topics - [[Design](../../tag/design/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Design](../../tag/design/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions diff --git a/problems/decompress-run-length-encoded-list/README.md b/problems/decompress-run-length-encoded-list/README.md index 9d28d4d54..7ccf0f628 100644 --- a/problems/decompress-run-length-encoded-list/README.md +++ b/problems/decompress-run-length-encoded-list/README.md @@ -47,6 +47,9 @@ At the end the concatenation [2] + [4,4,4] is [2,4,4,4]. ### Related Topics [[Array](../../tag/array/README.md)] +### Similar Questions + 1. [String Compression](../string-compression) (Medium) + ### Hints
    Hint 1 diff --git a/problems/delete-leaves-with-a-given-value/README.md b/problems/delete-leaves-with-a-given-value/README.md index 8367ef269..e8074f8c2 100644 --- a/problems/delete-leaves-with-a-given-value/README.md +++ b/problems/delete-leaves-with-a-given-value/README.md @@ -70,10 +70,10 @@ After removing, new nodes become leaf nodes with value (target = 2) (Picture in ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md b/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md index 44384de43..e73b8b5f1 100644 --- a/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md +++ b/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md @@ -16,10 +16,6 @@ ### Related Topics [[Linked List](../../tag/linked-list/README.md)] -### Similar Questions - 1. [Remove Nth Node From End of List](../remove-nth-node-from-end-of-list) (Medium) - 1. [Remove Zero Sum Consecutive Nodes from Linked List](../remove-zero-sum-consecutive-nodes-from-linked-list) (Medium) - ### Hints
    Hint 1 diff --git a/problems/delete-node-in-a-bst/README.md b/problems/delete-node-in-a-bst/README.md index 1bc5f32c5..c9ad5f2fd 100644 --- a/problems/delete-node-in-a-bst/README.md +++ b/problems/delete-node-in-a-bst/README.md @@ -20,8 +20,6 @@
  • If the node is found, delete the node.
  • -

    Follow up: Can you solve it with time complexity O(height of tree)?

    -

     

    Example 1:

    @@ -60,6 +58,9 @@ Please notice that another valid answer is [5,2,6,null,4,null,7] and it's al
  • -105 <= key <= 105
  • +

     

    +

    Follow up: Could you solve it with time complexity O(height of tree)?

    + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] diff --git a/problems/department-highest-salary/README.md b/problems/department-highest-salary/README.md index 69ef35b24..c9072c79e 100644 --- a/problems/department-highest-salary/README.md +++ b/problems/department-highest-salary/README.md @@ -11,46 +11,77 @@ ## [184. Department Highest Salary (Medium)](https://leetcode.com/problems/department-highest-salary "部门工资最高的员工") -

    The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id.

    +

    Table: Employee

    -+----+-------+--------+--------------+
    -| Id | Name  | Salary | DepartmentId |
    -+----+-------+--------+--------------+
    -| 1  | Joe   | 70000  | 1            |
    -| 2  | Jim   | 90000  | 1            |
    -| 3  | Henry | 80000  | 2            |
    -| 4  | Sam   | 60000  | 2            |
    -| 5  | Max   | 90000  | 1            |
    -+----+-------+--------+--------------+
    ++--------------+---------+
    +| Column Name  | Type    |
    ++--------------+---------+
    +| Id           | int     |
    +| Name         | varchar |
    +| Salary       | int     |
    +| DepartmentId | int     |
    ++--------------+---------+
    +Id is the primary key column for this table.
    +DepartmentId is a foreign key of the ID from the Department table.
    +Each row of this table indicates the ID, name, and salary of an employee. It also contains the ID of their department.
     
    -

    The Department table holds all departments of the company.

    +

     

    + +

    Table: Department

    -+----+----------+
    -| Id | Name     |
    -+----+----------+
    -| 1  | IT       |
    -| 2  | Sales    |
    -+----+----------+
    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| Id          | int     |
    +| Name        | varchar |
    ++-------------+---------+
    +Id is the primary key column for this table.
    +Each row of this table indicates the ID of a department and its name.
     
    -

    Write a SQL query to find employees who have the highest salary in each of the departments. For the above tables, your SQL query should return the following rows (order of rows does not matter).

    +

     

    + +

    Write an SQL query to find employees who have the highest salary in each of the departments.

    + +

    Return the result table in any order.

    + +

    The query result format is in the following example.

    + +

     

    +

    Example 1:

    +Input: 
    +Employee table:
    ++----+-------+--------+--------------+
    +| Id | Name  | Salary | DepartmentId |
    ++----+-------+--------+--------------+
    +| 1  | Joe   | 70000  | 1            |
    +| 2  | Jim   | 90000  | 1            |
    +| 3  | Henry | 80000  | 2            |
    +| 4  | Sam   | 60000  | 2            |
    +| 5  | Max   | 90000  | 1            |
    ++----+-------+--------+--------------+
    +Department table:
    ++----+-------+
    +| Id | Name  |
    ++----+-------+
    +| 1  | IT    |
    +| 2  | Sales |
    ++----+-------+
    +Output: 
     +------------+----------+--------+
     | Department | Employee | Salary |
     +------------+----------+--------+
    -| IT         | Max      | 90000  |
    -| IT         | Jim      | 90000  |
    +| IT         | Jim      | 90000  |
     | Sales      | Henry    | 80000  |
    +| IT         | Max      | 90000  |
     +------------+----------+--------+
    +Explanation: Max and Jim both have the highest salary in the IT department and Henry has the highest salary in the Sales department.
     
    -

    Explanation:

    - -

    Max and Jim both have the highest salary in the IT department and Henry has the highest salary in the Sales department.

    - ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/department-top-three-salaries/README.md b/problems/department-top-three-salaries/README.md index 171d4fbb1..3badb634b 100644 --- a/problems/department-top-three-salaries/README.md +++ b/problems/department-top-three-salaries/README.md @@ -22,8 +22,9 @@ | Salary | int | | DepartmentId | int | +--------------+---------+ -Id is the primary key for this table. -Each row contains the ID, name, salary, and department of one employee. +Id is the primary key column for this table. +DepartmentId is a foreign key of the ID from the Department table. +Each row of this table indicates the ID, name, and salary of an employee. It also contains the ID of their department.

     

    @@ -37,8 +38,8 @@ Each row contains the ID, name, salary, and department of one employee. | Id | int | | Name | varchar | +-------------+---------+ -Id is the primary key for this table. -Each row contains the ID and the name of one department. +Id is the primary key column for this table. +Each row of this table indicates the ID of a department and its name.

     

    @@ -49,11 +50,13 @@ Each row contains the ID and the name of one department.

    Return the result table in any order.

    -

    The query result format is in the following example:

    +

    The query result format is in the following example.

     

    +

    Example 1:

    +Input: 
     Employee table:
     +----+-------+--------+--------------+
     | Id | Name  | Salary | DepartmentId |
    @@ -66,7 +69,6 @@ Employee table:
     | 6  | Randy | 85000  | 1            |
     | 7  | Will  | 70000  | 1            |
     +----+-------+--------+--------------+
    -
     Department table:
     +----+-------+
     | Id | Name  |
    @@ -74,8 +76,7 @@ Department table:
     | 1  | IT    |
     | 2  | Sales |
     +----+-------+
    -
    -Result table:
    +Output: 
     +------------+----------+--------+
     | Department | Employee | Salary |
     +------------+----------+--------+
    @@ -86,7 +87,7 @@ Result table:
     | Sales      | Henry    | 80000  |
     | Sales      | Sam      | 60000  |
     +------------+----------+--------+
    -
    +Explanation: 
     In the IT department:
     - Max earns the highest unique salary
     - Both Randy and Joe earn the second-highest unique salary
    @@ -95,7 +96,8 @@ In the IT department:
     In the Sales department:
     - Henry earns the highest salary
     - Sam earns the second-highest salary
    -- There is no third-highest salary as there are only two employees
    +- There is no third-highest salary as there are only two employees + ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/design-a-stack-with-increment-operation/README.md b/problems/design-a-stack-with-increment-operation/README.md index e12ffe054..3266fbabb 100644 --- a/problems/design-a-stack-with-increment-operation/README.md +++ b/problems/design-a-stack-with-increment-operation/README.md @@ -59,9 +59,9 @@ customStack.pop(); // return -1 --> Stack is empty ### Related Topics + [[Array](../../tag/array/README.md)] [[Stack](../../tag/stack/README.md)] [[Design](../../tag/design/README.md)] - [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/design-browser-history/README.md b/problems/design-browser-history/README.md index 89eefc01a..9a8ea0750 100644 --- a/problems/design-browser-history/README.md +++ b/problems/design-browser-history/README.md @@ -58,12 +58,12 @@ browserHistory.back(7); // You are in "google.com", ### Related Topics - [[Array](../../tag/array/README.md)] - [[Linked List](../../tag/linked-list/README.md)] [[Stack](../../tag/stack/README.md)] [[Design](../../tag/design/README.md)] - [[Doubly-Linked List](../../tag/doubly-linked-list/README.md)] + [[Array](../../tag/array/README.md)] + [[Linked List](../../tag/linked-list/README.md)] [[Data Stream](../../tag/data-stream/README.md)] + [[Doubly-Linked List](../../tag/doubly-linked-list/README.md)] ### Hints
    diff --git a/problems/design-in-memory-file-system/README.md b/problems/design-in-memory-file-system/README.md index 1e56844a9..06066a926 100644 --- a/problems/design-in-memory-file-system/README.md +++ b/problems/design-in-memory-file-system/README.md @@ -47,10 +47,10 @@ ### Related Topics - [[Design](../../tag/design/README.md)] - [[Trie](../../tag/trie/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] + [[Trie](../../tag/trie/README.md)] ### Similar Questions 1. [LRU Cache](../lru-cache) (Medium) diff --git a/problems/design-most-recently-used-queue/README.md b/problems/design-most-recently-used-queue/README.md index 8cd6c64aa..ad11af706 100644 --- a/problems/design-most-recently-used-queue/README.md +++ b/problems/design-most-recently-used-queue/README.md @@ -16,6 +16,7 @@ ### Related Topics [[Stack](../../tag/stack/README.md)] [[Design](../../tag/design/README.md)] + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] diff --git a/problems/design-parking-system/README.md b/problems/design-parking-system/README.md index ae59f5976..eaca5e40e 100644 --- a/problems/design-parking-system/README.md +++ b/problems/design-parking-system/README.md @@ -49,8 +49,8 @@ parkingSystem.addCar(1); // return false because there is no available slot for ### Related Topics [[Design](../../tag/design/README.md)] - [[Counting](../../tag/counting/README.md)] [[Simulation](../../tag/simulation/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/design-underground-system/README.md b/problems/design-underground-system/README.md index ad50b7a3d..195801ffa 100644 --- a/problems/design-underground-system/README.md +++ b/problems/design-underground-system/README.md @@ -101,9 +101,9 @@ undergroundSystem.getAverageTime("Leyton", "Paradise"); // r ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] ### Hints
    diff --git a/problems/detect-cycles-in-2d-grid/README.md b/problems/detect-cycles-in-2d-grid/README.md index b6f7cb2c5..e48734252 100644 --- a/problems/detect-cycles-in-2d-grid/README.md +++ b/problems/detect-cycles-in-2d-grid/README.md @@ -9,15 +9,15 @@                  [Next >](../most-visited-sector-in-a-circular-track "Most Visited Sector in a Circular Track") -## [1559. Detect Cycles in 2D Grid (Hard)](https://leetcode.com/problems/detect-cycles-in-2d-grid "二维网格图中探测环") +## [1559. Detect Cycles in 2D Grid (Medium)](https://leetcode.com/problems/detect-cycles-in-2d-grid "二维网格图中探测环") -

    Given a 2D array of characters grid of size m x n, you need to find if there exists any cycle consisting of the same value in grid.

    +

    Given a 2D array of characters grid of size m x n, you need to find if there exists any cycle consisting of the same value in grid.

    -

    A cycle is a path of length 4 or more in the grid that starts and ends at the same cell. From a given cell, you can move to one of the cells adjacent to it - in one of the four directions (up, down, left, or right), if it has the same value of the current cell.

    +

    A cycle is a path of length 4 or more in the grid that starts and ends at the same cell. From a given cell, you can move to one of the cells adjacent to it - in one of the four directions (up, down, left, or right), if it has the same value of the current cell.

    -

    Also, you cannot move to the cell that you visited in your last move. For example, the cycle (1, 1) -> (1, 2) -> (1, 1) is invalid because from (1, 2) we visited (1, 1) which was the last visited cell.

    +

    Also, you cannot move to the cell that you visited in your last move. For example, the cycle (1, 1) -> (1, 2) -> (1, 1) is invalid because from (1, 2) we visited (1, 1) which was the last visited cell.

    -

    Return true if any cycle of the same value exists in grid, otherwise, return false.

    +

    Return true if any cycle of the same value exists in grid, otherwise, return false.

     

    Example 1:

    @@ -57,9 +57,8 @@
    • m == grid.length
    • n == grid[i].length
    • -
    • 1 <= m <= 500
    • -
    • 1 <= n <= 500
    • -
    • grid consists only of lowercase English letters.
    • +
    • 1 <= m, n <= 500
    • +
    • grid consists only of lowercase English letters.
    ### Related Topics diff --git a/problems/detect-squares/README.md b/problems/detect-squares/README.md new file mode 100644 index 000000000..2d618bc66 --- /dev/null +++ b/problems/detect-squares/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../sum-of-beauty-in-the-array "Sum of Beauty in the Array") +                 +[Next >](../longest-subsequence-repeated-k-times "Longest Subsequence Repeated k Times") + +## [2013. Detect Squares (Medium)](https://leetcode.com/problems/detect-squares "检测正方形") + +

    You are given a stream of points on the X-Y plane. Design an algorithm that:

    + +
      +
    • Adds new points from the stream into a data structure. Duplicate points are allowed and should be treated as different points.
    • +
    • Given a query point, counts the number of ways to choose three points from the data structure such that the three points and the query point form an axis-aligned square with positive area.
    • +
    + +

    An axis-aligned square is a square whose edges are all the same length and are either parallel or perpendicular to the x-axis and y-axis.

    + +

    Implement the DetectSquares class:

    + +
      +
    • DetectSquares() Initializes the object with an empty data structure.
    • +
    • void add(int[] point) Adds a new point point = [x, y] to the data structure.
    • +
    • int count(int[] point) Counts the number of ways to form axis-aligned squares with point point = [x, y] as described above.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input
    +["DetectSquares", "add", "add", "add", "count", "count", "add", "count"]
    +[[], [[3, 10]], [[11, 2]], [[3, 2]], [[11, 10]], [[14, 8]], [[11, 2]], [[11, 10]]]
    +Output
    +[null, null, null, null, 1, 0, null, 2]
    +
    +Explanation
    +DetectSquares detectSquares = new DetectSquares();
    +detectSquares.add([3, 10]);
    +detectSquares.add([11, 2]);
    +detectSquares.add([3, 2]);
    +detectSquares.count([11, 10]); // return 1. You can choose:
    +                               //   - The first, second, and third points
    +detectSquares.count([14, 8]);  // return 0. The query point cannot form a square with any points in the data structure.
    +detectSquares.add([11, 2]);    // Adding duplicate points is allowed.
    +detectSquares.count([11, 10]); // return 2. You can choose:
    +                               //   - The first, second, and third points
    +                               //   - The first, third, and fourth points
    +
    + +

     

    +

    Constraints:

    + +
      +
    • point.length == 2
    • +
    • 0 <= x, y <= 1000
    • +
    • At most 3000 calls in total will be made to add and count.
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Hints +
    +Hint 1 +Maintain the frequency of all the points in a hash map. +
    + +
    +Hint 2 +Traverse the hash map and if any point has the same y-coordinate as the query point, consider this point and the query point to form one of the horizontal lines of the square. +
    diff --git a/problems/different-ways-to-add-parentheses/README.md b/problems/different-ways-to-add-parentheses/README.md index add33a88f..970b12558 100644 --- a/problems/different-ways-to-add-parentheses/README.md +++ b/problems/different-ways-to-add-parentheses/README.md @@ -43,14 +43,15 @@
    • 1 <= expression.length <= 20
    • expression consists of digits and the operator '+', '-', and '*'.
    • +
    • All the integer values in the input expression are in the range [0, 99].
    ### Related Topics + [[Recursion](../../tag/recursion/README.md)] + [[Memoization](../../tag/memoization/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Recursion](../../tag/recursion/README.md)] - [[Memoization](../../tag/memoization/README.md)] ### Similar Questions 1. [Unique Binary Search Trees II](../unique-binary-search-trees-ii) (Medium) diff --git a/problems/display-table-of-food-orders-in-a-restaurant/README.md b/problems/display-table-of-food-orders-in-a-restaurant/README.md index ee1233457..6ea038fe2 100644 --- a/problems/display-table-of-food-orders-in-a-restaurant/README.md +++ b/problems/display-table-of-food-orders-in-a-restaurant/README.md @@ -64,8 +64,8 @@ For the table 12: James, Ratesh and Amadeus order "Fried Chicken". [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Sorting](../../tag/sorting/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/distinct-subsequences-ii/README.md b/problems/distinct-subsequences-ii/README.md index f4e676a5e..f9799dc58 100644 --- a/problems/distinct-subsequences-ii/README.md +++ b/problems/distinct-subsequences-ii/README.md @@ -49,6 +49,3 @@ A subsequence of a string is a new string that is formed from t ### Related Topics [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - -### Similar Questions - 1. [Number of Unique Good Subsequences](../number-of-unique-good-subsequences) (Hard) diff --git a/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md b/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md index 7b0bf98af..8fc6c478d 100644 --- a/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md +++ b/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md @@ -59,11 +59,14 @@ Note: This question is the same as 846: https://leetcode.com/problems/hand-of-straights/ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Split Array into Consecutive Subsequences](../split-array-into-consecutive-subsequences) (Medium) + ### Hints
    Hint 1 diff --git a/problems/dot-product-of-two-sparse-vectors/README.md b/problems/dot-product-of-two-sparse-vectors/README.md index 043048d51..2e9db457c 100644 --- a/problems/dot-product-of-two-sparse-vectors/README.md +++ b/problems/dot-product-of-two-sparse-vectors/README.md @@ -14,10 +14,10 @@ ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Design](../../tag/design/README.md)] ### Hints
    diff --git a/problems/duplicate-emails/README.md b/problems/duplicate-emails/README.md index bae40f1a3..c656347b4 100644 --- a/problems/duplicate-emails/README.md +++ b/problems/duplicate-emails/README.md @@ -11,9 +11,33 @@ ## [182. Duplicate Emails (Easy)](https://leetcode.com/problems/duplicate-emails "查找重复的电子邮箱") -

    Write a SQL query to find all duplicate emails in a table named Person.

    +

    Table: Person

    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| Id          | int     |
    +| Email       | varchar |
    ++-------------+---------+
    +Id is the primary key column for this table.
    +Each row of this table contains an email. The emails will not contain uppercase letters.
    +
    + +

     

    + +

    Write an SQL query to report all the duplicate emails.

    + +

    Return the result table in any order.

    + +

    The query result format is in the following example.

    + +

     

    +

    Example 1:

    + +
    +Input: 
    +Person table:
     +----+---------+
     | Id | Email   |
     +----+---------+
    @@ -21,19 +45,14 @@
     | 2  | c@d.com |
     | 3  | a@b.com |
     +----+---------+
    -
    - -

    For example, your query should return the following for the above table:

    - -
    +Output: 
     +---------+
     | Email   |
     +---------+
     | a@b.com |
     +---------+
    +Explanation: a@b.com is repeated two times.
     
    -

    Note: All emails are in lowercase.

    - ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/employee-importance/README.md b/problems/employee-importance/README.md index 36b679fd9..286dc6b8d 100644 --- a/problems/employee-importance/README.md +++ b/problems/employee-importance/README.md @@ -11,17 +11,17 @@ ## [690. Employee Importance (Easy)](https://leetcode.com/problems/employee-importance "员工的重要性") -

    You have a data structure of employee information, which includes the employee's unique id, their importance value, and their direct subordinates' id.

    +

    You have a data structure of employee information, which includes the employee's unique ID, their importance value, and their direct subordinates' IDs.

    You are given an array of employees employees where:

    • employees[i].id is the ID of the ith employee.
    • employees[i].importance is the importance value of the ith employee.
    • -
    • employees[i].subordinates is a list of the IDs of the subordinates of the ith employee.
    • +
    • employees[i].subordinates is a list of the IDs of the direct subordinates of the ith employee.
    -

    Given an integer id that represents the ID of an employee, return the total importance value of this employee and all their subordinates.

    +

    Given an integer id that represents the ID of an employee, return the total importance value of this employee and all their direct subordinates.

     

    Example 1:

    @@ -29,9 +29,9 @@
     Input: employees = [[1,5,[2,3]],[2,3,[]],[3,3,[]]], id = 1
     Output: 11
    -Explanation: Employee 1 has importance value 5, and he has two direct subordinates: employee 2 and employee 3.
    -They both have importance value 3.
    -So the total importance value of employee 1 is 5 + 3 + 3 = 11.
    +Explanation: Employee 1 has an importance value of 5 and has two direct subordinates: employee 2 and employee 3.
    +They both have an importance value of 3.
    +Thus, the total importance value of employee 1 is 5 + 3 + 3 = 11.
     

    Example 2:

    @@ -39,6 +39,8 @@ So the total importance value of employee 1 is 5 + 3 + 3 = 11.
     Input: employees = [[1,2,[5]],[5,-3,[]]], id = 5
     Output: -3
    +Explanation: Employee 5 has an importance value of -3 and has no direct subordinates.
    +Thus, the total importance value of employee 5 is -3.
     

     

    @@ -50,13 +52,13 @@ So the total importance value of employee 1 is 5 + 3 + 3 = 11.
  • All employees[i].id are unique.
  • -100 <= employees[i].importance <= 100
  • One employee has at most one direct leader and may have several subordinates.
  • -
  • id is guaranteed to be a valid employee id.
  • +
  • The IDs in employees[i].subordinates are valid IDs.
  • ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions 1. [Nested List Weight Sum](../nested-list-weight-sum) (Medium) diff --git a/problems/employees-with-missing-information/README.md b/problems/employees-with-missing-information/README.md index 7c289fa10..004d8ee18 100644 --- a/problems/employees-with-missing-information/README.md +++ b/problems/employees-with-missing-information/README.md @@ -12,3 +12,6 @@ ## [1965. Employees With Missing Information (Easy)](https://leetcode.com/problems/employees-with-missing-information "") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/encode-and-decode-tinyurl/README.md b/problems/encode-and-decode-tinyurl/README.md index 878e6d0aa..51741058f 100644 --- a/problems/encode-and-decode-tinyurl/README.md +++ b/problems/encode-and-decode-tinyurl/README.md @@ -47,7 +47,7 @@ string ans = obj.decode(tiny); // returns the original url after deconding it. ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] [[Hash Function](../../tag/hash-function/README.md)] diff --git a/problems/encode-number/README.md b/problems/encode-number/README.md index a38a4b267..880bcff62 100644 --- a/problems/encode-number/README.md +++ b/problems/encode-number/README.md @@ -40,9 +40,9 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Convert to Base -2](../convert-to-base-2) (Medium) diff --git a/problems/expression-add-operators/README.md b/problems/expression-add-operators/README.md index 83b2f4331..c12108c67 100644 --- a/problems/expression-add-operators/README.md +++ b/problems/expression-add-operators/README.md @@ -11,25 +11,53 @@ ## [282. Expression Add Operators (Hard)](https://leetcode.com/problems/expression-add-operators "给表达式添加运算符") -

    Given a string num that contains only digits and an integer target, return all possibilities to add the binary operators '+', '-', or '*' between the digits of num so that the resultant expression evaluates to the target value.

    +

    Given a string num that contains only digits and an integer target, return all possibilities to insert the binary operators '+', '-', and/or '*' between the digits of num so that the resultant expression evaluates to the target value.

    + +

    Note that operands in the returned expressions should not contain leading zeros.

     

    Example 1:

    -
    Input: num = "123", target = 6
    -Output: ["1*2*3","1+2+3"]
    -

    Example 2:

    -
    Input: num = "232", target = 8
    -Output: ["2*3+2","2+3*2"]
    -

    Example 3:

    -
    Input: num = "105", target = 5
    -Output: ["1*0+5","10-5"]
    -

    Example 4:

    -
    Input: num = "00", target = 0
    -Output: ["0*0","0+0","0-0"]
    -

    Example 5:

    -
    Input: num = "3456237490", target = 9191
    +
    +
    +Input: num = "123", target = 6
    +Output: ["1*2*3","1+2+3"]
    +Explanation: Both "1*2*3" and "1+2+3" evaluate to 6.
    +
    + +

    Example 2:

    + +
    +Input: num = "232", target = 8
    +Output: ["2*3+2","2+3*2"]
    +Explanation: Both "2*3+2" and "2+3*2" evaluate to 8.
    +
    + +

    Example 3:

    + +
    +Input: num = "105", target = 5
    +Output: ["1*0+5","10-5"]
    +Explanation: Both "1*0+5" and "10-5" evaluate to 5.
    +Note that "1-05" is not a valid expression because the 5 has a leading zero.
    +
    + +

    Example 4:

    + +
    +Input: num = "00", target = 0
    +Output: ["0*0","0+0","0-0"]
    +Explanation: "0*0", "0+0", and "0-0" all evaluate to 0.
    +Note that "00" is not a valid expression because the 0 has a leading zero.
    +
    + +

    Example 5:

    + +
    +Input: num = "3456237490", target = 9191
     Output: []
    +Explanation: There are no expressions that can be created from "3456237490" to evaluate to 9191.
     
    +

     

    Constraints:

    diff --git a/problems/fancy-sequence/README.md b/problems/fancy-sequence/README.md index 4e0845e90..095f2502b 100644 --- a/problems/fancy-sequence/README.md +++ b/problems/fancy-sequence/README.md @@ -58,9 +58,9 @@ fancy.getIndex(2); // return 20 ### Related Topics + [[Math](../../tag/math/README.md)] [[Design](../../tag/design/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] - [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/final-value-of-variable-after-performing-operations/README.md b/problems/final-value-of-variable-after-performing-operations/README.md new file mode 100644 index 000000000..ba929c144 --- /dev/null +++ b/problems/final-value-of-variable-after-performing-operations/README.md @@ -0,0 +1,85 @@ + + + + + + + +[< Previous](../the-number-of-seniors-and-juniors-to-join-the-company-ii "The Number of Seniors and Juniors to Join the Company II") +                 +[Next >](../sum-of-beauty-in-the-array "Sum of Beauty in the Array") + +## [2011. Final Value of Variable After Performing Operations (Easy)](https://leetcode.com/problems/final-value-of-variable-after-performing-operations "执行操作后的变量值") + +

    There is a programming language with only four operations and one variable X:

    + +
      +
    • ++X and X++ increments the value of the variable X by 1.
    • +
    • --X and X-- decrements the value of the variable X by 1.
    • +
    + +

    Initially, the value of X is 0.

    + +

    Given an array of strings operations containing a list of operations, return the final value of X after performing all the operations.

    + +

     

    +

    Example 1:

    + +
    +Input: operations = ["--X","X++","X++"]
    +Output: 1
    +Explanation: The operations are performed as follows:
    +Initially, X = 0.
    +--X: X is decremented by 1, X =  0 - 1 = -1.
    +X++: X is incremented by 1, X = -1 + 1 =  0.
    +X++: X is incremented by 1, X =  0 + 1 =  1.
    +
    + +

    Example 2:

    + +
    +Input: operations = ["++X","++X","X++"]
    +Output: 3
    +Explanation: The operations are performed as follows:
    +Initially, X = 0.
    +++X: X is incremented by 1, X = 0 + 1 = 1.
    +++X: X is incremented by 1, X = 1 + 1 = 2.
    +X++: X is incremented by 1, X = 2 + 1 = 3.
    +
    + +

    Example 3:

    + +
    +Input: operations = ["X++","++X","--X","X--"]
    +Output: 0
    +Explanation: The operations are performed as follows:
    +Initially, X = 0.
    +X++: X is incremented by 1, X = 0 + 1 = 1.
    +++X: X is incremented by 1, X = 1 + 1 = 2.
    +--X: X is decremented by 1, X = 2 - 1 = 1.
    +X--: X is decremented by 1, X = 1 - 1 = 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= operations.length <= 100
    • +
    • operations[i] will be either "++X", "X++", "--X", or "X--".
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +There are only two operations to keep track of. +
    + +
    +Hint 2 +Use a variable to store the value after each operation. +
    diff --git a/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md b/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md index 3a44dd643..84e1c95e2 100644 --- a/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md +++ b/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md @@ -19,8 +19,6 @@

    Note that you are not allowed to change any of the two trees or the target node and the answer must be a reference to a node in the cloned tree.

    -

    Follow up: Solve the problem if repeated values on the tree are allowed.

    -

     

    Example 1:

    @@ -62,11 +60,14 @@

    Constraints:

      -
    • The number of nodes in the tree is in the range [1, 10^4].
    • +
    • The number of nodes in the tree is in the range [1, 104].
    • The values of the nodes of the tree are unique.
    • -
    • target node is a node from the original tree and is not null.
    • +
    • target node is a node from the original tree and is not null.
    +

     

    +

    Follow up: Could you solve the problem if repeated values on the tree are allowed?

    + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md index c3cc0d0d1..d9e42c73b 100644 --- a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md +++ b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md @@ -53,10 +53,10 @@ ### Related Topics - [[Array](../../tag/array/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
    diff --git a/problems/find-all-the-lonely-nodes/README.md b/problems/find-all-the-lonely-nodes/README.md index 8201c7126..a3379d1e5 100644 --- a/problems/find-all-the-lonely-nodes/README.md +++ b/problems/find-all-the-lonely-nodes/README.md @@ -19,6 +19,10 @@ [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Binary Tree Tilt](../binary-tree-tilt) (Easy) + 1. [Univalued Binary Tree](../univalued-binary-tree) (Easy) + ### Hints
    Hint 1 diff --git a/problems/find-eventual-safe-states/README.md b/problems/find-eventual-safe-states/README.md index a71acd8a5..e0916e64f 100644 --- a/problems/find-eventual-safe-states/README.md +++ b/problems/find-eventual-safe-states/README.md @@ -11,13 +11,11 @@ ## [802. Find Eventual Safe States (Medium)](https://leetcode.com/problems/find-eventual-safe-states "找到最终的安全状态") -

    We start at some node in a directed graph, and every turn, we walk along a directed edge of the graph. If we reach a terminal node (that is, it has no outgoing directed edges), we stop.

    +

    There is a directed graph of n nodes with each node labeled from 0 to n - 1. The graph is represented by a 0-indexed 2D integer array graph where graph[i] is an integer array of nodes adjacent to node i, meaning there is an edge from node i to each node in graph[i].

    -

    We define a starting node to be safe if we must eventually walk to a terminal node. More specifically, there is a natural number k, so that we must have stopped at a terminal node in less than k steps for any choice of where to walk.

    +

    A node is a terminal node if there are no outgoing edges. A node is a safe node if every possible path starting from that node leads to a terminal node.

    -

    Return an array containing all the safe nodes of the graph. The answer should be sorted in ascending order.

    - -

    The directed graph has n nodes with labels from 0 to n - 1, where n is the length of graph. The graph is given in the following form: graph[i] is a list of labels j such that (i, j) is a directed edge of the graph, going from node i to node j.

    +

    Return an array containing all the safe nodes of the graph. The answer should be sorted in ascending order.

     

    Example 1:

    @@ -26,13 +24,16 @@ Input: graph = [[1,2],[2,3],[5],[0],[5],[],[]] Output: [2,4,5,6] Explanation: The given graph is shown above. -
    +Nodes 5 and 6 are terminal nodes as there are no outgoing edges from either of them. +Every path starting at nodes 2, 4, 5, and 6 all lead to either node 5 or 6.

    Example 2:

     Input: graph = [[1,2,3,4],[1,2],[3,4],[0,4],[]]
     Output: [4]
    +Explanation:
    +Only node 4 is a terminal node, and every path starting at node 4 leads to node 4.
     

     

    @@ -42,6 +43,7 @@
  • n == graph.length
  • 1 <= n <= 104
  • 0 <= graph[i].length <= n
  • +
  • 0 <= graph[i][j] <= n - 1
  • graph[i] is sorted in a strictly increasing order.
  • The graph may contain self-loops.
  • The number of edges in the graph will be in the range [1, 4 * 104].
  • diff --git a/problems/find-k-pairs-with-smallest-sums/README.md b/problems/find-k-pairs-with-smallest-sums/README.md index 12c3c6518..93278e009 100644 --- a/problems/find-k-pairs-with-smallest-sums/README.md +++ b/problems/find-k-pairs-with-smallest-sums/README.md @@ -59,3 +59,4 @@ ### Similar Questions 1. [Kth Smallest Element in a Sorted Matrix](../kth-smallest-element-in-a-sorted-matrix) (Medium) 1. [Find K-th Smallest Pair Distance](../find-k-th-smallest-pair-distance) (Hard) + 1. [Kth Smallest Product of Two Sorted Arrays](../kth-smallest-product-of-two-sorted-arrays) (Hard) diff --git a/problems/find-longest-awesome-substring/README.md b/problems/find-longest-awesome-substring/README.md index b5f3b29e1..51ee2950c 100644 --- a/problems/find-longest-awesome-substring/README.md +++ b/problems/find-longest-awesome-substring/README.md @@ -55,9 +55,9 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/find-minimum-time-to-finish-all-jobs/README.md b/problems/find-minimum-time-to-finish-all-jobs/README.md index 092bf7ddc..f23240e69 100644 --- a/problems/find-minimum-time-to-finish-all-jobs/README.md +++ b/problems/find-minimum-time-to-finish-all-jobs/README.md @@ -45,12 +45,15 @@ The maximum working time is 11. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] +### Similar Questions + 1. [Minimum Number of Work Sessions to Finish the Tasks](../minimum-number-of-work-sessions-to-finish-the-tasks) (Medium) + ### Hints
    Hint 1 diff --git a/problems/find-missing-observations/README.md b/problems/find-missing-observations/README.md new file mode 100644 index 000000000..42f206e9c --- /dev/null +++ b/problems/find-missing-observations/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../minimum-moves-to-convert-string "Minimum Moves to Convert String") +                 +[Next >](../stone-game-ix "Stone Game IX") + +## [2028. Find Missing Observations (Medium)](https://leetcode.com/problems/find-missing-observations "找出缺失的观测数据") + +

    You have observations of n + m 6-sided dice rolls with each face numbered from 1 to 6. n of the observations went missing, and you only have the observations of m rolls. Fortunately, you have also calculated the average value of the n + m rolls.

    + +

    You are given an integer array rolls of length m where rolls[i] is the value of the ith observation. You are also given the two integers mean and n.

    + +

    Return an array of length n containing the missing observations such that the average value of the n + m rolls is exactly mean. If there are multiple valid answers, return any of them. If no such array exists, return an empty array.

    + +

    The average value of a set of k numbers is the sum of the numbers divided by k.

    + +

    Note that mean is an integer, so the sum of the n + m rolls should be divisible by n + m.

    + +

     

    +

    Example 1:

    + +
    +Input: rolls = [3,2,4,3], mean = 4, n = 2
    +Output: [6,6]
    +Explanation: The mean of all n + m rolls is (3 + 2 + 4 + 3 + 6 + 6) / 6 = 4.
    +
    + +

    Example 2:

    + +
    +Input: rolls = [1,5,6], mean = 3, n = 4
    +Output: [2,3,2,2]
    +Explanation: The mean of all n + m rolls is (1 + 5 + 6 + 2 + 3 + 2 + 2) / 7 = 3.
    +
    + +

    Example 3:

    + +
    +Input: rolls = [1,2,3,4], mean = 6, n = 4
    +Output: []
    +Explanation: It is impossible for the mean to be 6 no matter what the 4 missing rolls are.
    +
    + +

    Example 4:

    + +
    +Input: rolls = [1], mean = 3, n = 1
    +Output: [5]
    +Explanation: The mean of all n + m rolls is (1 + 5) / 2 = 3.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == rolls.length
    • +
    • 1 <= n, m <= 105
    • +
    • 1 <= rolls[i], mean <= 6
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +What should the sum of the n rolls be? +
    + +
    +Hint 2 +Could you generate an array of size n such that each element is between 1 and 6? +
    diff --git a/problems/find-original-array-from-doubled-array/README.md b/problems/find-original-array-from-doubled-array/README.md new file mode 100644 index 000000000..9630bc2b1 --- /dev/null +++ b/problems/find-original-array-from-doubled-array/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../count-number-of-pairs-with-absolute-difference-k "Count Number of Pairs With Absolute Difference K") +                 +[Next >](../maximum-earnings-from-taxi "Maximum Earnings From Taxi") + +## [2007. Find Original Array From Doubled Array (Medium)](https://leetcode.com/problems/find-original-array-from-doubled-array "从双倍数组中还原原数组") + +

    An integer array original is transformed into a doubled array changed by appending twice the value of every element in original, and then randomly shuffling the resulting array.

    + +

    Given an array changed, return original if changed is a doubled array. If changed is not a doubled array, return an empty array. The elements in original may be returned in any order.

    + +

     

    +

    Example 1:

    + +
    +Input: changed = [1,3,4,2,6,8]
    +Output: [1,3,4]
    +Explanation: One possible original array could be [1,3,4]:
    +- Twice the value of 1 is 1 * 2 = 2.
    +- Twice the value of 3 is 3 * 2 = 6.
    +- Twice the value of 4 is 4 * 2 = 8.
    +Other original arrays could be [4,3,1] or [3,1,4].
    +
    + +

    Example 2:

    + +
    +Input: changed = [6,3,0,1]
    +Output: []
    +Explanation: changed is not a doubled array.
    +
    + +

    Example 3:

    + +
    +Input: changed = [1]
    +Output: []
    +Explanation: changed is not a doubled array.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= changed.length <= 105
    • +
    • 0 <= changed[i] <= 105
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +If changed is a doubled array, you should be able to delete elements and their doubled values until the array is empty. +
    + +
    +Hint 2 +Which element is guaranteed to not be a doubled value? It is the smallest element. +
    + +
    +Hint 3 +After removing the smallest element and its double from changed, is there another number that is guaranteed to not be a doubled value? +
    diff --git a/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md index 47a954fac..f115bd5f2 100644 --- a/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md +++ b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md @@ -62,8 +62,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] [[Matrix](../../tag/matrix/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/find-the-middle-index-in-array/README.md b/problems/find-the-middle-index-in-array/README.md index f8ac5cd93..e08db4f4b 100644 --- a/problems/find-the-middle-index-in-array/README.md +++ b/problems/find-the-middle-index-in-array/README.md @@ -67,6 +67,9 @@ The sum of the numbers after index 0 is: 0
  • -1000 <= nums[i] <= 1000
  • +

     

    +

    Note: This question is the same as 724: https://leetcode.com/problems/find-pivot-index/

    + ### Related Topics [[Array](../../tag/array/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] diff --git a/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md b/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md index 5503561a2..93d2ee3fb 100644 --- a/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md +++ b/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md @@ -50,7 +50,7 @@ For k = 7 we can use 2 + 5 = 7.

    Constraints:

      -
    • 1 <= k <= 10^9
    • +
    • 1 <= k <= 109
    ### Related Topics diff --git a/problems/find-winner-on-a-tic-tac-toe-game/README.md b/problems/find-winner-on-a-tic-tac-toe-game/README.md index c8d6f3722..ea7db93de 100644 --- a/problems/find-winner-on-a-tic-tac-toe-game/README.md +++ b/problems/find-winner-on-a-tic-tac-toe-game/README.md @@ -11,68 +11,52 @@ ## [1275. Find Winner on a Tic Tac Toe Game (Easy)](https://leetcode.com/problems/find-winner-on-a-tic-tac-toe-game "找出井字棋的获胜者") -

    Tic-tac-toe is played by two players A and B on a 3 x 3 grid.

    - -

    Here are the rules of Tic-Tac-Toe:

    +

    Tic-tac-toe is played by two players A and B on a 3 x 3 grid. The rules of Tic-Tac-Toe are:

      -
    • Players take turns placing characters into empty squares (" ").
    • -
    • The first player A always places "X" characters, while the second player B always places "O" characters.
    • -
    • "X" and "O" characters are always placed into empty squares, never on filled ones.
    • -
    • The game ends when there are 3 of the same (non-empty) character filling any row, column, or diagonal.
    • +
    • Players take turns placing characters into empty squares ' '.
    • +
    • The first player A always places 'X' characters, while the second player B always places 'O' characters.
    • +
    • 'X' and 'O' characters are always placed into empty squares, never on filled ones.
    • +
    • The game ends when there are three of the same (non-empty) character filling any row, column, or diagonal.
    • The game also ends if all squares are non-empty.
    • No more moves can be played if the game is over.
    -

    Given an array moves where each element is another array of size 2 corresponding to the row and column of the grid where they mark their respective character in the order in which A and B play.

    - -

    Return the winner of the game if it exists (A or B), in case the game ends in a draw return "Draw", if there are still movements to play return "Pending".

    +

    Given a 2D integer array moves where moves[i] = [rowi, coli] indicates that the ith move will be played on grid[rowi][coli]. return the winner of the game if it exists (A or B). In case the game ends in a draw return "Draw". If there are still movements to play return "Pending".

    -

    You can assume that moves is valid (It follows the rules of Tic-Tac-Toe), the grid is initially empty and A will play first.

    +

    You can assume that moves is valid (i.e., it follows the rules of Tic-Tac-Toe), the grid is initially empty, and A will play first.

     

    Example 1:

    - +
     Input: moves = [[0,0],[2,0],[1,1],[2,1],[2,2]]
     Output: "A"
    -Explanation: "A" wins, he always plays first.
    -"X  "    "X  "    "X  "    "X  "    "X  "
    -"   " -> "   " -> " X " -> " X " -> " X "
    -"   "    "O  "    "O  "    "OO "    "OOX"
    +Explanation: A wins, they always play first.
     

    Example 2:

    - +
     Input: moves = [[0,0],[1,1],[0,1],[0,2],[1,0],[2,0]]
     Output: "B"
    -Explanation: "B" wins.
    -"X  "    "X  "    "XX "    "XXO"    "XXO"    "XXO"
    -"   " -> " O " -> " O " -> " O " -> "XO " -> "XO " 
    -"   "    "   "    "   "    "   "    "   "    "O  "
    +Explanation: B wins.
     

    Example 3:

    - +
     Input: moves = [[0,0],[1,1],[2,0],[1,0],[1,2],[2,1],[0,1],[0,2],[2,2]]
     Output: "Draw"
     Explanation: The game ends in a draw since there are no moves to make.
    -"XXO"
    -"OOX"
    -"XOX"
     

    Example 4:

    - +
     Input: moves = [[0,0],[1,1]]
     Output: "Pending"
     Explanation: The game has not finished yet.
    -"X  "
    -" O "
    -"   "
     

     

    @@ -81,7 +65,7 @@
    • 1 <= moves.length <= 9
    • moves[i].length == 2
    • -
    • 0 <= moves[i][j] <= 2
    • +
    • 0 <= rowi, coli <= 2
    • There are no repeated elements on moves.
    • moves follow the rules of tic tac toe.
    diff --git a/problems/first-and-last-call-on-the-same-day/README.md b/problems/first-and-last-call-on-the-same-day/README.md index 367339957..2ea7414aa 100644 --- a/problems/first-and-last-call-on-the-same-day/README.md +++ b/problems/first-and-last-call-on-the-same-day/README.md @@ -12,3 +12,6 @@ ## [1972. First and Last Call On the Same Day (Hard)](https://leetcode.com/problems/first-and-last-call-on-the-same-day "") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/first-day-where-you-have-been-in-all-the-rooms/README.md b/problems/first-day-where-you-have-been-in-all-the-rooms/README.md index 8c0034241..4ad9d3435 100644 --- a/problems/first-day-where-you-have-been-in-all-the-rooms/README.md +++ b/problems/first-day-where-you-have-been-in-all-the-rooms/README.md @@ -17,7 +17,7 @@
    • Assuming that on a day, you visit room i,
    • -
    • if you have been in room i an odd number of times (including the current visit), on the next day you will visit the room specified by nextVisit[i] where 0 <= nextVisit[i] <= i;
    • +
    • if you have been in room i an odd number of times (including the current visit), on the next day you will visit a room with a lower or equal room number specified by nextVisit[i] where 0 <= nextVisit[i] <= i;
    • if you have been in room i an even number of times (including the current visit), on the next day you will visit room (i + 1) mod n.
    diff --git a/problems/first-unique-character-in-a-string/README.md b/problems/first-unique-character-in-a-string/README.md index 00f41ca4d..c58d7222c 100644 --- a/problems/first-unique-character-in-a-string/README.md +++ b/problems/first-unique-character-in-a-string/README.md @@ -33,9 +33,9 @@ ### Related Topics + [[Queue](../../tag/queue/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Queue](../../tag/queue/README.md)] [[Counting](../../tag/counting/README.md)] ### Similar Questions diff --git a/problems/get-the-maximum-score/README.md b/problems/get-the-maximum-score/README.md index 58ded5aa5..d3b8f3baa 100644 --- a/problems/get-the-maximum-score/README.md +++ b/problems/get-the-maximum-score/README.md @@ -76,10 +76,10 @@ Maximum sum is obtained with the path [6,7,8,9,10]. ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/get-watched-videos-by-your-friends/README.md b/problems/get-watched-videos-by-your-friends/README.md index 749aa190b..79c0f3213 100644 --- a/problems/get-watched-videos-by-your-friends/README.md +++ b/problems/get-watched-videos-by-your-friends/README.md @@ -59,9 +59,9 @@ You have id = 0 (green color in the figure) and the only friend of your friends ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/graph-connectivity-with-threshold/README.md b/problems/graph-connectivity-with-threshold/README.md index 06834dd1c..d471d5221 100644 --- a/problems/graph-connectivity-with-threshold/README.md +++ b/problems/graph-connectivity-with-threshold/README.md @@ -74,9 +74,9 @@ Please notice that there can be multiple queries for the same pair of nodes [x, ### Related Topics + [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Union Find](../../tag/union-find/README.md)] ### Hints
    diff --git a/problems/grid-game/README.md b/problems/grid-game/README.md new file mode 100644 index 000000000..ee2968e0f --- /dev/null +++ b/problems/grid-game/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../maximum-difference-between-increasing-elements "Maximum Difference Between Increasing Elements") +                 +[Next >](../check-if-word-can-be-placed-in-crossword "Check if Word Can Be Placed In Crossword") + +## [2017. Grid Game (Medium)](https://leetcode.com/problems/grid-game "网格游戏") + +

    You are given a 0-indexed 2D array grid of size 2 x n, where grid[r][c] represents the number of points at position (r, c) on the matrix. Two robots are playing a game on this matrix.

    + +

    Both robots initially start at (0, 0) and want to reach (1, n-1). Each robot may only move to the right ((r, c) to (r, c + 1)) or down ((r, c) to (r + 1, c)).

    + +

    At the start of the game, the first robot moves from (0, 0) to (1, n-1), collecting all the points from the cells on its path. For all cells (r, c) traversed on the path, grid[r][c] is set to 0. Then, the second robot moves from (0, 0) to (1, n-1), collecting the points on its path. Note that their paths may intersect with one another.

    + +

    The first robot wants to minimize the number of points collected by the second robot. In contrast, the second robot wants to maximize the number of points it collects. If both robots play optimally, return the number of points collected by the second robot.

    + +

     

    +

    Example 1:

    + +
    +Input: grid = [[2,5,4],[1,5,1]]
    +Output: 4
    +Explanation: The optimal path taken by the first robot is shown in red, and the optimal path taken by the second robot is shown in blue.
    +The cells visited by the first robot are set to 0.
    +The second robot will collect 0 + 0 + 4 + 0 = 4 points.
    +
    + +

    Example 2:

    + +
    +Input: grid = [[3,3,1],[8,5,2]]
    +Output: 4
    +Explanation: The optimal path taken by the first robot is shown in red, and the optimal path taken by the second robot is shown in blue.
    +The cells visited by the first robot are set to 0.
    +The second robot will collect 0 + 3 + 1 + 0 = 4 points.
    +
    + +

    Example 3:

    + +
    +Input: grid = [[1,3,1,15],[1,3,3,1]]
    +Output: 7
    +Explanation: The optimal path taken by the first robot is shown in red, and the optimal path taken by the second robot is shown in blue.
    +The cells visited by the first robot are set to 0.
    +The second robot will collect 0 + 1 + 3 + 3 + 0 = 7 points.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • grid.length == 2
    • +
    • n == grid[r].length
    • +
    • 1 <= n <= 5 * 104
    • +
    • 1 <= grid[r][c] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +There are n choices for when the first robot moves to the second row. +
    + +
    +Hint 2 +Can we use prefix sums to help solve this problem? +
    diff --git a/problems/how-many-numbers-are-smaller-than-the-current-number/README.md b/problems/how-many-numbers-are-smaller-than-the-current-number/README.md index 28aa14d74..1418fd842 100644 --- a/problems/how-many-numbers-are-smaller-than-the-current-number/README.md +++ b/problems/how-many-numbers-are-smaller-than-the-current-number/README.md @@ -54,8 +54,11 @@ For nums[4]=3 there exist three smaller numbers than it (1, 2 and 2). ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Counting](../../tag/counting/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Similar Questions + 1. [Count of Smaller Numbers After Self](../count-of-smaller-numbers-after-self) (Hard) ### Hints
    diff --git a/problems/implement-rand10-using-rand7/README.md b/problems/implement-rand10-using-rand7/README.md index f7caf2300..5ae0a32f1 100644 --- a/problems/implement-rand10-using-rand7/README.md +++ b/problems/implement-rand10-using-rand7/README.md @@ -15,13 +15,6 @@

    Each test case will have one internal argument n, the number of times that your implemented function rand10() will be called while testing. Note that this is not an argument passed to rand10().

    -

    Follow up:

    - -
      -
    • What is the expected value for the number of calls to rand7() function?
    • -
    • Could you minimize the number of calls to rand7()?
    • -
    -

     

    Example 1:

    Input: n = 1
    @@ -40,8 +33,16 @@
     	
  • 1 <= n <= 105
  • +

     

    +

    Follow up:

    + +
      +
    • What is the expected value for the number of calls to rand7() function?
    • +
    • Could you minimize the number of calls to rand7()?
    • +
    + ### Related Topics [[Math](../../tag/math/README.md)] [[Rejection Sampling](../../tag/rejection-sampling/README.md)] - [[Probability and Statistics](../../tag/probability-and-statistics/README.md)] [[Randomized](../../tag/randomized/README.md)] + [[Probability and Statistics](../../tag/probability-and-statistics/README.md)] diff --git a/problems/increasing-subsequences/README.md b/problems/increasing-subsequences/README.md index 5001010d5..23795c8b3 100644 --- a/problems/increasing-subsequences/README.md +++ b/problems/increasing-subsequences/README.md @@ -39,10 +39,10 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Maximum Length of Pair Chain](../maximum-length-of-pair-chain) (Medium) diff --git a/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md b/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md index d18b37a19..5956f4810 100644 --- a/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md +++ b/problems/insert-delete-getrandom-o1-duplicates-allowed/README.md @@ -52,10 +52,10 @@ randomizedCollection.getRandom(); // getRandom should return 1 and 2 both equall ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Design](../../tag/design/README.md)] [[Randomized](../../tag/randomized/README.md)] ### Similar Questions diff --git a/problems/island-perimeter/README.md b/problems/island-perimeter/README.md index b33418489..4bf38e2a2 100644 --- a/problems/island-perimeter/README.md +++ b/problems/island-perimeter/README.md @@ -48,6 +48,7 @@
  • col == grid[i].length
  • 1 <= row, col <= 100
  • grid[i][j] is 0 or 1.
  • +
  • There is exactly one island in grid.
  • ### Related Topics diff --git a/problems/jump-game-iii/README.md b/problems/jump-game-iii/README.md index bded9080e..a8063e365 100644 --- a/problems/jump-game-iii/README.md +++ b/problems/jump-game-iii/README.md @@ -55,9 +55,14 @@ index 0 -> index 4 -> index 1 -> index 3 ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Array](../../tag/array/README.md)] + +### Similar Questions + 1. [Jump Game II](../jump-game-ii) (Medium) + 1. [Jump Game](../jump-game) (Medium) + 1. [Jump Game VII](../jump-game-vii) (Medium) ### Hints
    diff --git a/problems/jump-game-iv/README.md b/problems/jump-game-iv/README.md index 8305870b7..3c3ba13a3 100644 --- a/problems/jump-game-iv/README.md +++ b/problems/jump-game-iv/README.md @@ -73,9 +73,12 @@ ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + +### Similar Questions + 1. [Jump Game VII](../jump-game-vii) (Medium) ### Hints
    diff --git a/problems/k-empty-slots/README.md b/problems/k-empty-slots/README.md index 633ae20d4..52e3d2d3e 100644 --- a/problems/k-empty-slots/README.md +++ b/problems/k-empty-slots/README.md @@ -56,7 +56,7 @@ K: 1 ### Related Topics - [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Array](../../tag/array/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] diff --git a/problems/k-similar-strings/README.md b/problems/k-similar-strings/README.md index 3f7d7d074..75314f709 100644 --- a/problems/k-similar-strings/README.md +++ b/problems/k-similar-strings/README.md @@ -40,8 +40,8 @@ ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[String](../../tag/string/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Similar Questions 1. [Couples Holding Hands](../couples-holding-hands) (Hard) diff --git a/problems/keys-and-rooms/README.md b/problems/keys-and-rooms/README.md index ba29f0504..2b9172aa2 100644 --- a/problems/keys-and-rooms/README.md +++ b/problems/keys-and-rooms/README.md @@ -55,3 +55,6 @@ Since we were able to visit every room, we return true. [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] + +### Similar Questions + 1. [Graph Valid Tree](../graph-valid-tree) (Medium) diff --git a/problems/kth-smallest-product-of-two-sorted-arrays/README.md b/problems/kth-smallest-product-of-two-sorted-arrays/README.md new file mode 100644 index 000000000..b15aac8f0 --- /dev/null +++ b/problems/kth-smallest-product-of-two-sorted-arrays/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../the-time-when-the-network-becomes-idle "The Time When the Network Becomes Idle") +                 +[Next >](../accepted-candidates-from-the-interviews "Accepted Candidates From the Interviews") + +## [2040. Kth Smallest Product of Two Sorted Arrays (Hard)](https://leetcode.com/problems/kth-smallest-product-of-two-sorted-arrays "两个有序数组的第 K 小乘积") + +Given two sorted 0-indexed integer arrays nums1 and nums2 as well as an integer k, return the kth (1-based) smallest product of nums1[i] * nums2[j] where 0 <= i < nums1.length and 0 <= j < nums2.length. +

     

    +

    Example 1:

    + +
    +Input: nums1 = [2,5], nums2 = [3,4], k = 2
    +Output: 8
    +Explanation: The 2 smallest products are:
    +- nums1[0] * nums2[0] = 2 * 3 = 6
    +- nums1[0] * nums2[1] = 2 * 4 = 8
    +The 2nd smallest product is 8.
    +
    + +

    Example 2:

    + +
    +Input: nums1 = [-4,-2,0,3], nums2 = [2,4], k = 6
    +Output: 0
    +Explanation: The 6 smallest products are:
    +- nums1[0] * nums2[1] = (-4) * 4 = -16
    +- nums1[0] * nums2[0] = (-4) * 2 = -8
    +- nums1[1] * nums2[1] = (-2) * 4 = -8
    +- nums1[1] * nums2[0] = (-2) * 2 = -4
    +- nums1[2] * nums2[0] = 0 * 2 = 0
    +- nums1[2] * nums2[1] = 0 * 4 = 0
    +The 6th smallest product is 0.
    +
    + +

    Example 3:

    + +
    +Input: nums1 = [-2,-1,0,1,2], nums2 = [-3,-1,2,4,5], k = 3
    +Output: -6
    +Explanation: The 3 smallest products are:
    +- nums1[0] * nums2[4] = (-2) * 5 = -10
    +- nums1[0] * nums2[3] = (-2) * 4 = -8
    +- nums1[4] * nums2[0] = 2 * (-3) = -6
    +The 3rd smallest product is -6.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums1.length, nums2.length <= 5 * 104
    • +
    • -105 <= nums1[i], nums2[j] <= 105
    • +
    • 1 <= k <= nums1.length * nums2.length
    • +
    • nums1 and nums2 are sorted.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Can we split this problem into four cases depending on the sign of the numbers? +
    + +
    +Hint 2 +Can we binary search the value? +
    diff --git a/problems/kth-smallest-subarray-sum/README.md b/problems/kth-smallest-subarray-sum/README.md index 857ca7e54..12f5c8f9b 100644 --- a/problems/kth-smallest-subarray-sum/README.md +++ b/problems/kth-smallest-subarray-sum/README.md @@ -9,7 +9,7 @@                  [Next >](../leetcodify-similar-friends "Leetcodify Similar Friends") -## [1918. Kth Smallest Subarray Sum (Medium)](https://leetcode.com/problems/kth-smallest-subarray-sum "第 K 小的子序列和") +## [1918. Kth Smallest Subarray Sum (Medium)](https://leetcode.com/problems/kth-smallest-subarray-sum "第 K 小的子数组和·") diff --git a/problems/largest-bst-subtree/README.md b/problems/largest-bst-subtree/README.md index bdbe666f4..1c4b2ebfa 100644 --- a/problems/largest-bst-subtree/README.md +++ b/problems/largest-bst-subtree/README.md @@ -36,10 +36,10 @@ A subtree must include all of its descendants.

    Can you figure out ways to solve it with O(n) time complexity?

    ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/largest-multiple-of-three/README.md b/problems/largest-multiple-of-three/README.md index 83727e4c6..3995859b7 100644 --- a/problems/largest-multiple-of-three/README.md +++ b/problems/largest-multiple-of-three/README.md @@ -11,11 +11,9 @@ ## [1363. Largest Multiple of Three (Hard)](https://leetcode.com/problems/largest-multiple-of-three "形成三的最大倍数") -

    Given an integer array of digits, return the largest multiple of three that can be formed by concatenating some of the given digits in any order.

    +

    Given an array of digits digits, return the largest multiple of three that can be formed by concatenating some of the given digits in any order. If there is no answer return an empty string.

    -

    Since the answer may not fit in an integer data type, return the answer as a string.

    - -

    If there is no answer return an empty string.

    +

    Since the answer may not fit in an integer data type, return the answer as a string. Note that the returning answer must not contain unnecessary leading zeros.

     

    Example 1:

    @@ -50,15 +48,14 @@

    Constraints:

      -
    • 1 <= digits.length <= 10^4
    • +
    • 1 <= digits.length <= 104
    • 0 <= digits[i] <= 9
    • -
    • The returning answer must not contain unnecessary leading zeros.
    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md b/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md index 8213bad69..f68c40999 100644 --- a/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md +++ b/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md @@ -78,8 +78,8 @@ Note that the last moment when an ant was on the plank is t = 4 second, after th ### Related Topics - [[Array](../../tag/array/README.md)] [[Brainteaser](../../tag/brainteaser/README.md)] + [[Array](../../tag/array/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/least-number-of-unique-integers-after-k-removals/README.md b/problems/least-number-of-unique-integers-after-k-removals/README.md index 5e8afd7db..e31706f4f 100644 --- a/problems/least-number-of-unique-integers-after-k-removals/README.md +++ b/problems/least-number-of-unique-integers-after-k-removals/README.md @@ -41,11 +41,11 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Counting](../../tag/counting/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/leetcodify-similar-friends/README.md b/problems/leetcodify-similar-friends/README.md index 71672fe0b..8d1a914e4 100644 --- a/problems/leetcodify-similar-friends/README.md +++ b/problems/leetcodify-similar-friends/README.md @@ -12,3 +12,6 @@ ## [1919. Leetcodify Similar Friends (Hard)](https://leetcode.com/problems/leetcodify-similar-friends "兴趣相同的朋友") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/lexicographically-smallest-string-after-applying-operations/README.md b/problems/lexicographically-smallest-string-after-applying-operations/README.md index 18a828363..5b989496f 100644 --- a/problems/lexicographically-smallest-string-after-applying-operations/README.md +++ b/problems/lexicographically-smallest-string-after-applying-operations/README.md @@ -83,8 +83,8 @@ There is no way to obtain a string that is lexicographically smaller then " ### Related Topics - [[String](../../tag/string/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md index 38ba47009..66c810ef5 100644 --- a/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md +++ b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md @@ -58,12 +58,12 @@ Therefore, the size of the longest subarray is 2. ### Related Topics - [[Array](../../tag/array/README.md)] [[Queue](../../tag/queue/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Array](../../tag/array/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] [[Monotonic Queue](../../tag/monotonic-queue/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/longest-duplicate-substring/README.md b/problems/longest-duplicate-substring/README.md index b40016fef..3542daf1e 100644 --- a/problems/longest-duplicate-substring/README.md +++ b/problems/longest-duplicate-substring/README.md @@ -34,10 +34,10 @@ ### Related Topics [[String](../../tag/string/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Suffix Array](../../tag/suffix-array/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Hash Function](../../tag/hash-function/README.md)] [[Rolling Hash](../../tag/rolling-hash/README.md)] + [[Suffix Array](../../tag/suffix-array/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Hints
    diff --git a/problems/longest-happy-string/README.md b/problems/longest-happy-string/README.md index 064f01b24..f678998ac 100644 --- a/problems/longest-happy-string/README.md +++ b/problems/longest-happy-string/README.md @@ -56,8 +56,8 @@ ### Related Topics - [[String](../../tag/string/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/longest-repeating-character-replacement/README.md b/problems/longest-repeating-character-replacement/README.md index 0d29b5e1a..42e657293 100644 --- a/problems/longest-repeating-character-replacement/README.md +++ b/problems/longest-repeating-character-replacement/README.md @@ -50,3 +50,5 @@ The substring "BBBB" has the longest repeating letters, which is 4. ### Similar Questions 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Medium) 1. [Max Consecutive Ones III](../max-consecutive-ones-iii) (Medium) + 1. [Minimum Number of Operations to Make Array Continuous](../minimum-number-of-operations-to-make-array-continuous) (Hard) + 1. [Maximize the Confusion of an Exam](../maximize-the-confusion-of-an-exam) (Medium) diff --git a/problems/longest-subarray-of-1s-after-deleting-one-element/README.md b/problems/longest-subarray-of-1s-after-deleting-one-element/README.md index 63b411339..06ad49cf8 100644 --- a/problems/longest-subarray-of-1s-after-deleting-one-element/README.md +++ b/problems/longest-subarray-of-1s-after-deleting-one-element/README.md @@ -13,9 +13,7 @@

    Given a binary array nums, you should delete one element from it.

    -

    Return the size of the longest non-empty subarray containing only 1's in the resulting array.

    - -

    Return 0 if there is no such subarray.

    +

    Return the size of the longest non-empty subarray containing only 1's in the resulting array. Return 0 if there is no such subarray.

     

    Example 1:

    @@ -57,8 +55,8 @@

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • nums[i] is either 0 or 1.
    • +
    • 1 <= nums.length <= 105
    • +
    • nums[i] is either 0 or 1.
    ### Related Topics diff --git a/problems/longest-subsequence-repeated-k-times/README.md b/problems/longest-subsequence-repeated-k-times/README.md new file mode 100644 index 000000000..3e8e416f0 --- /dev/null +++ b/problems/longest-subsequence-repeated-k-times/README.md @@ -0,0 +1,91 @@ + + + + + + + +[< Previous](../detect-squares "Detect Squares") +                 +[Next >](../average-height-of-buildings-in-each-segment "Average Height of Buildings in Each Segment") + +## [2014. Longest Subsequence Repeated k Times (Hard)](https://leetcode.com/problems/longest-subsequence-repeated-k-times "重复 K 次的最长子序列") + +

    You are given a string s of length n, and an integer k. You are tasked to find the longest subsequence repeated k times in string s.

    + +

    A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.

    + +

    A subsequence seq is repeated k times in the string s if seq * k is a subsequence of s, where seq * k represents a string constructed by concatenating seq k times.

    + +
      +
    • For example, "bba" is repeated 2 times in the string "bababcba", because the string "bbabba", constructed by concatenating "bba" 2 times, is a subsequence of the string "bababcba".
    • +
    + +

    Return the longest subsequence repeated k times in string s. If multiple such subsequences are found, return the lexicographically largest one. If there is no such subsequence, return an empty string.

    + +

     

    +

    Example 1:

    +example 1 +
    +Input: s = "letsleetcode", k = 2
    +Output: "let"
    +Explanation: There are two longest subsequences repeated 2 times: "let" and "ete".
    +"let" is the lexicographically largest one.
    +
    + +

    Example 2:

    + +
    +Input: s = "bb", k = 2
    +Output: "b"
    +Explanation: The longest subsequence repeated 2 times is "b".
    +
    + +

    Example 3:

    + +
    +Input: s = "ab", k = 2
    +Output: ""
    +Explanation: There is no subsequence repeated 2 times. Empty string is returned.
    +
    + +

    Example 4:

    + +
    +Input: s = "bbabbabbbbabaababab", k = 3
    +Output: "bbbb"
    +Explanation: The longest subsequence "bbbb" is repeated 3 times in "bbabbabbbbabaababab".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == s.length
    • +
    • 2 <= n, k <= 2000
    • +
    • 2 <= n < k * 8
    • +
    • s consists of lowercase English letters.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + +### Hints +
    +Hint 1 +The length of the longest subsequence does not exceed n/k. Do you know why? +
    + +
    +Hint 2 +Find the characters that could be included in the potential answer. A character occurring more than or equal to k times can be used in the answer up to (count of the character / k) times. +
    + +
    +Hint 3 +Try all possible candidates in reverse lexicographic order, and check the string for the subsequence condition. +
    diff --git a/problems/longest-zigzag-path-in-a-binary-tree/README.md b/problems/longest-zigzag-path-in-a-binary-tree/README.md index be005d7d9..b61ea3691 100644 --- a/problems/longest-zigzag-path-in-a-binary-tree/README.md +++ b/problems/longest-zigzag-path-in-a-binary-tree/README.md @@ -59,9 +59,9 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/low-quality-problems/README.md b/problems/low-quality-problems/README.md new file mode 100644 index 000000000..735e73f63 --- /dev/null +++ b/problems/low-quality-problems/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../maximum-number-of-ways-to-partition-an-array "Maximum Number of Ways to Partition an Array") +                 +[Next >](../minimum-moves-to-convert-string "Minimum Moves to Convert String") + +## [2026. Low-Quality Problems (Easy)](https://leetcode.com/problems/low-quality-problems "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/low-quality-problems/mysql_schemas.sql b/problems/low-quality-problems/mysql_schemas.sql new file mode 100644 index 000000000..07951b77f --- /dev/null +++ b/problems/low-quality-problems/mysql_schemas.sql @@ -0,0 +1,8 @@ +Create table If Not Exists Problems (problem_id int, likes int, dislikes int); +Truncate table Problems; +insert into Problems (problem_id, likes, dislikes) values ('6', '1290', '425'); +insert into Problems (problem_id, likes, dislikes) values ('11', '2677', '8659'); +insert into Problems (problem_id, likes, dislikes) values ('1', '4446', '2760'); +insert into Problems (problem_id, likes, dislikes) values ('7', '8569', '6086'); +insert into Problems (problem_id, likes, dislikes) values ('13', '2050', '4164'); +insert into Problems (problem_id, likes, dislikes) values ('10', '9002', '7446'); diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md index f0cf11398..a8e298dd3 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md @@ -14,10 +14,16 @@ ### Related Topics - [[Tree](../../tag/tree/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Tree](../../tag/tree/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Lowest Common Ancestor of a Binary Search Tree](../lowest-common-ancestor-of-a-binary-search-tree) (Easy) + 1. [Lowest Common Ancestor of a Binary Tree](../lowest-common-ancestor-of-a-binary-tree) (Medium) + 1. [Lowest Common Ancestor of a Binary Tree II](../lowest-common-ancestor-of-a-binary-tree-ii) (Medium) + 1. [Lowest Common Ancestor of a Binary Tree IV](../lowest-common-ancestor-of-a-binary-tree-iv) (Medium) + ### Hints
    Hint 1 diff --git a/problems/lucky-numbers-in-a-matrix/README.md b/problems/lucky-numbers-in-a-matrix/README.md index bd873c29d..459c575c6 100644 --- a/problems/lucky-numbers-in-a-matrix/README.md +++ b/problems/lucky-numbers-in-a-matrix/README.md @@ -11,9 +11,9 @@ ## [1380. Lucky Numbers in a Matrix (Easy)](https://leetcode.com/problems/lucky-numbers-in-a-matrix "矩阵中的幸运数") -

    Given a m * n matrix of distinct numbers, return all lucky numbers in the matrix in any order.

    +

    Given an m x n matrix of distinct numbers, return all lucky numbers in the matrix in any order.

    -

    A lucky number is an element of the matrix such that it is the minimum element in its row and maximum in its column.

    +

    A lucky number is an element of the matrix such that it is the minimum element in its row and maximum in its column.

     

    Example 1:

    @@ -37,6 +37,15 @@
     Input: matrix = [[7,8],[1,2]]
     Output: [7]
    +Explanation: 7 is the only lucky number since it is the minimum in its row and the maximum in its column.
    +
    + +

    Example 4:

    + +
    +Input: matrix = [[3,6],[7,1],[5,2],[4,8]]
    +Output: []
    +Explanation: There is no lucky number.
     

     

    @@ -46,7 +55,7 @@
  • m == mat.length
  • n == mat[i].length
  • 1 <= n, m <= 50
  • -
  • 1 <= matrix[i][j] <= 10^5.
  • +
  • 1 <= matrix[i][j] <= 105.
  • All elements in the matrix are distinct.
  • diff --git a/problems/max-consecutive-ones-iii/README.md b/problems/max-consecutive-ones-iii/README.md index 3192f47e3..543968e6c 100644 --- a/problems/max-consecutive-ones-iii/README.md +++ b/problems/max-consecutive-ones-iii/README.md @@ -43,14 +43,15 @@ Bolded numbers were flipped from 0 to 1. The longest subarray is underlined. ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Prefix Sum](../../tag/prefix-sum/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Similar Questions 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Medium) 1. [Longest Repeating Character Replacement](../longest-repeating-character-replacement) (Medium) 1. [Max Consecutive Ones](../max-consecutive-ones) (Easy) 1. [Max Consecutive Ones II](../max-consecutive-ones-ii) (Medium) + 1. [Maximize the Confusion of an Exam](../maximize-the-confusion-of-an-exam) (Medium) ### Hints
    diff --git a/problems/max-points-on-a-line/README.md b/problems/max-points-on-a-line/README.md index 2dab44ae2..30d9071b2 100644 --- a/problems/max-points-on-a-line/README.md +++ b/problems/max-points-on-a-line/README.md @@ -39,9 +39,9 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] ### Similar Questions 1. [Line Reflection](../line-reflection) (Medium) diff --git a/problems/max-value-of-equation/README.md b/problems/max-value-of-equation/README.md index 3feae3e3e..09a54ceb8 100644 --- a/problems/max-value-of-equation/README.md +++ b/problems/max-value-of-equation/README.md @@ -48,11 +48,14 @@ No other pairs satisfy the condition, so we return the max of 4 and 1. ### Related Topics - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] + [[Queue](../../tag/queue/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Monotonic Queue](../../tag/monotonic-queue/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] + +### Similar Questions + 1. [Count Pairs in Two Arrays](../count-pairs-in-two-arrays) (Medium) ### Hints
    diff --git a/problems/maximize-the-confusion-of-an-exam/README.md b/problems/maximize-the-confusion-of-an-exam/README.md new file mode 100644 index 000000000..ba4f6fa1d --- /dev/null +++ b/problems/maximize-the-confusion-of-an-exam/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../number-of-pairs-of-strings-with-concatenation-equal-to-target "Number of Pairs of Strings With Concatenation Equal to Target") +                 +[Next >](../maximum-number-of-ways-to-partition-an-array "Maximum Number of Ways to Partition an Array") + +## [2024. Maximize the Confusion of an Exam (Medium)](https://leetcode.com/problems/maximize-the-confusion-of-an-exam "考试的最大困扰度") + +

    A teacher is writing a test with n true/false questions, with 'T' denoting true and 'F' denoting false. He wants to confuse the students by maximizing the number of consecutive questions with the same answer (multiple trues or multiple falses in a row).

    + +

    You are given a string answerKey, where answerKey[i] is the original answer to the ith question. In addition, you are given an integer k, the maximum number of times you may perform the following operation:

    + +
      +
    • Change the answer key for any question to 'T' or 'F' (i.e., set answerKey[i] to 'T' or 'F').
    • +
    + +

    Return the maximum number of consecutive 'T's or 'F's in the answer key after performing the operation at most k times.

    + +

     

    +

    Example 1:

    + +
    +Input: answerKey = "TTFF", k = 2
    +Output: 4
    +Explanation: We can replace both the 'F's with 'T's to make answerKey = "TTTT".
    +There are four consecutive 'T's.
    +
    + +

    Example 2:

    + +
    +Input: answerKey = "TFFT", k = 1
    +Output: 3
    +Explanation: We can replace the first 'T' with an 'F' to make answerKey = "FFFT".
    +Alternatively, we can replace the second 'T' with an 'F' to make answerKey = "TFFF".
    +In both cases, there are three consecutive 'F's.
    +
    + +

    Example 3:

    + +
    +Input: answerKey = "TTFTTFTT", k = 1
    +Output: 5
    +Explanation: We can replace the first 'F' to make answerKey = "TTTTTFTT"
    +Alternatively, we can replace the second 'F' to make answerKey = "TTFTTTTT". 
    +In both cases, there are five consecutive 'T's.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == answerKey.length
    • +
    • 1 <= n <= 5 * 104
    • +
    • answerKey[i] is either 'T' or 'F'
    • +
    • 1 <= k <= n
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
    +Hint 1 +Can we use the maximum length at the previous position to help us find the answer for the current position? +
    + +
    +Hint 2 +Can we use binary search to find the maximum consecutive same answer at every position? +
    diff --git a/problems/maximum-alternating-subarray-sum/README.md b/problems/maximum-alternating-subarray-sum/README.md new file mode 100644 index 000000000..ff48c4c69 --- /dev/null +++ b/problems/maximum-alternating-subarray-sum/README.md @@ -0,0 +1,39 @@ + + + + + + + +[< Previous](../partition-array-into-two-arrays-to-minimize-sum-difference "Partition Array Into Two Arrays to Minimize Sum Difference") +                 +[Next >](../minimum-number-of-moves-to-seat-everyone "Minimum Number of Moves to Seat Everyone") + +## [2036. Maximum Alternating Subarray Sum (Medium)](https://leetcode.com/problems/maximum-alternating-subarray-sum "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +How can Kadane's Algorithm help us? +
    + +
    +Hint 2 +If you convert all the numbers at odd indices to the negative version of that number, the problem simplifies to finding the maximum subarray sum. +
    + +
    +Hint 3 +However, this strategy needs you to start each subarray at an even index. +
    + +
    +Hint 4 +Do the same except converting all the numbers at even indices to the negative version of that number. +
    diff --git a/problems/maximum-difference-between-increasing-elements/README.md b/problems/maximum-difference-between-increasing-elements/README.md new file mode 100644 index 000000000..c8e49c793 --- /dev/null +++ b/problems/maximum-difference-between-increasing-elements/README.md @@ -0,0 +1,68 @@ + + + + + + + +[< Previous](../average-height-of-buildings-in-each-segment "Average Height of Buildings in Each Segment") +                 +[Next >](../grid-game "Grid Game") + +## [2016. Maximum Difference Between Increasing Elements (Easy)](https://leetcode.com/problems/maximum-difference-between-increasing-elements "增量元素之间的最大差值") + +

    Given a 0-indexed integer array nums of size n, find the maximum difference between nums[i] and nums[j] (i.e., nums[j] - nums[i]), such that 0 <= i < j < n and nums[i] < nums[j].

    + +

    Return the maximum difference. If no such i and j exists, return -1.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [7,1,5,4]
    +Output: 4
    +Explanation:
    +The maximum difference occurs with i = 1 and j = 2, nums[j] - nums[i] = 5 - 1 = 4.
    +Note that with i = 1 and j = 0, the difference nums[j] - nums[i] = 7 - 1 = 6, but i > j, so it is not valid.
    +
    + +

    Example 2:

    + +
    +Input: nums = [9,4,3,2]
    +Output: -1
    +Explanation:
    +There is no i and j such that i < j and nums[i] < nums[j].
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,5,2,10]
    +Output: 9
    +Explanation:
    +The maximum difference occurs with i = 0 and j = 3, nums[j] - nums[i] = 10 - 1 = 9.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 2 <= n <= 1000
    • +
    • 1 <= nums[i] <= 109
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Could you keep track of the minimum element visited while traversing? +
    + +
    +Hint 2 +We have a potential candidate for the answer if the prefix min is lesser than nums[i]. +
    diff --git a/problems/maximum-distance-in-arrays/README.md b/problems/maximum-distance-in-arrays/README.md index a91f15f03..3822d27e7 100644 --- a/problems/maximum-distance-in-arrays/README.md +++ b/problems/maximum-distance-in-arrays/README.md @@ -35,5 +35,5 @@ One way to reach the maximum distance 4 is to pick 1 in the first or third array

    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/maximum-earnings-from-taxi/README.md b/problems/maximum-earnings-from-taxi/README.md new file mode 100644 index 000000000..499f3b764 --- /dev/null +++ b/problems/maximum-earnings-from-taxi/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../find-original-array-from-doubled-array "Find Original Array From Doubled Array") +                 +[Next >](../minimum-number-of-operations-to-make-array-continuous "Minimum Number of Operations to Make Array Continuous") + +## [2008. Maximum Earnings From Taxi (Medium)](https://leetcode.com/problems/maximum-earnings-from-taxi "出租车的最大盈利") + +

    There are n points on a road you are driving your taxi on. The n points on the road are labeled from 1 to n in the direction you are going, and you want to drive from point 1 to point n to make money by picking up passengers. You cannot change the direction of the taxi.

    + +

    The passengers are represented by a 0-indexed 2D integer array rides, where rides[i] = [starti, endi, tipi] denotes the ith passenger requesting a ride from point starti to point endi who is willing to give a tipi dollar tip.

    + +

    For each passenger i you pick up, you earn endi - starti + tipi dollars. You may only drive at most one passenger at a time.

    + +

    Given n and rides, return the maximum number of dollars you can earn by picking up the passengers optimally.

    + +

    Note: You may drop off a passenger and pick up a different passenger at the same point.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 5, rides = [[2,5,4],[1,5,1]]
    +Output: 7
    +Explanation: We can pick up passenger 0 to earn 5 - 2 + 4 = 7 dollars.
    +
    + +

    Example 2:

    + +
    +Input: n = 20, rides = [[1,6,1],[3,10,2],[10,12,3],[11,12,2],[12,15,2],[13,18,1]]
    +Output: 20
    +Explanation: We will pick up the following passengers:
    +- Drive passenger 1 from point 3 to point 10 for a profit of 10 - 3 + 2 = 9 dollars.
    +- Drive passenger 2 from point 10 to point 12 for a profit of 12 - 10 + 3 = 5 dollars.
    +- Drive passenger 5 from point 13 to point 18 for a profit of 18 - 13 + 1 = 6 dollars.
    +We earn 9 + 5 + 6 = 20 dollars in total.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 105
    • +
    • 1 <= rides.length <= 3 * 104
    • +
    • rides[i].length == 3
    • +
    • 1 <= starti < endi <= n
    • +
    • 1 <= tipi <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Can we sort the array to help us solve the problem? +
    + +
    +Hint 2 +We can use dynamic programming to keep track of the maximum at each position. +
    diff --git a/problems/maximum-height-by-stacking-cuboids/README.md b/problems/maximum-height-by-stacking-cuboids/README.md index 3fefb2f9d..ea1da246b 100644 --- a/problems/maximum-height-by-stacking-cuboids/README.md +++ b/problems/maximum-height-by-stacking-cuboids/README.md @@ -67,6 +67,9 @@ The maximum height of stacked cuboids is 6 * 17 = 102. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [The Number of Weak Characters in the Game](../the-number-of-weak-characters-in-the-game) (Medium) + ### Hints
    Hint 1 diff --git a/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md b/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md index 15228dd77..72f94dbc1 100644 --- a/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md +++ b/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md @@ -11,9 +11,11 @@ ## [1239. Maximum Length of a Concatenated String with Unique Characters (Medium)](https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters "串联字符串的最大长度") -

    Given an array of strings arr. String s is a concatenation of a sub-sequence of arr which have unique characters.

    +

    You are given an array of strings arr. A string s is formed by the concatenation of a subsequence of arr that has unique characters.

    -

    Return the maximum possible length of s.

    +

    Return the maximum possible length of s.

    + +

    A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.

     

    Example 1:

    @@ -21,7 +23,13 @@
     Input: arr = ["un","iq","ue"]
     Output: 4
    -Explanation: All possible concatenations are "","un","iq","ue","uniq" and "ique".
    +Explanation: All the valid concatenations are:
    +- ""
    +- "un"
    +- "iq"
    +- "ue"
    +- "uniq" ("un" + "iq")
    +- "ique" ("iq" + "ue")
     Maximum length is 4.
     
    @@ -30,7 +38,7 @@ Maximum length is 4.
     Input: arr = ["cha","r","act","ers"]
     Output: 6
    -Explanation: Possible solutions are "chaers" and "acters".
    +Explanation: Possible longest valid concatenations are "chaers" ("cha" + "ers") and "acters" ("act" + "ers").
     

    Example 3:

    @@ -38,6 +46,15 @@ Maximum length is 4.
     Input: arr = ["abcdefghijklmnopqrstuvwxyz"]
     Output: 26
    +Explanation: The only string in arr has all 26 characters.
    +
    + +

    Example 4:

    + +
    +Input: arr = ["aa","bb"]
    +Output: 0
    +Explanation: Both strings in arr do not have unique characters, thus there are no valid concatenations.
     

     

    @@ -46,7 +63,7 @@ Maximum length is 4.
    • 1 <= arr.length <= 16
    • 1 <= arr[i].length <= 26
    • -
    • arr[i] contains only lower case English letters.
    • +
    • arr[i] contains only lowercase English letters.
    ### Related Topics diff --git a/problems/maximum-length-of-repeated-subarray/README.md b/problems/maximum-length-of-repeated-subarray/README.md index 71dabf33b..1ac8a6857 100644 --- a/problems/maximum-length-of-repeated-subarray/README.md +++ b/problems/maximum-length-of-repeated-subarray/README.md @@ -42,11 +42,12 @@ [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Hash Function](../../tag/hash-function/README.md)] [[Rolling Hash](../../tag/rolling-hash/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Similar Questions 1. [Minimum Size Subarray Sum](../minimum-size-subarray-sum) (Medium) + 1. [Longest Common Subpath](../longest-common-subpath) (Hard) ### Hints
    diff --git a/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/README.md b/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/README.md index adff7103c..ef9ae45b3 100644 --- a/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/README.md +++ b/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/README.md @@ -60,5 +60,8 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[String](../../tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] + +### Similar Questions + 1. [Maximum Nesting Depth of the Parentheses](../maximum-nesting-depth-of-the-parentheses) (Easy) diff --git a/problems/maximum-number-of-coins-you-can-get/README.md b/problems/maximum-number-of-coins-you-can-get/README.md index 7b7eae3e9..310a9960b 100644 --- a/problems/maximum-number-of-coins-you-can-get/README.md +++ b/problems/maximum-number-of-coins-you-can-get/README.md @@ -61,11 +61,11 @@ On the other hand if we choose this arrangement (1, 2, 8), (2, ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Greedy](../../tag/greedy/README.md)] - [[Sorting](../../tag/sorting/README.md)] [[Game Theory](../../tag/game-theory/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md b/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md index 61f9aa82c..a757781c4 100644 --- a/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md +++ b/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md @@ -61,9 +61,9 @@ ### Related Topics + [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Geometry](../../tag/geometry/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-events-that-can-be-attended/README.md b/problems/maximum-number-of-events-that-can-be-attended/README.md index 905c5f0a6..c456f8a46 100644 --- a/problems/maximum-number-of-events-that-can-be-attended/README.md +++ b/problems/maximum-number-of-events-that-can-be-attended/README.md @@ -68,10 +68,14 @@ Attend the third event on day 3. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] +### Similar Questions + 1. [Maximum Number of Events That Can Be Attended II](../maximum-number-of-events-that-can-be-attended-ii) (Hard) + 1. [Maximum Earnings From Taxi](../maximum-earnings-from-taxi) (Medium) + ### Hints
    Hint 1 diff --git a/problems/maximum-number-of-non-overlapping-substrings/README.md b/problems/maximum-number-of-non-overlapping-substrings/README.md index 3e571a962..93e3be684 100644 --- a/problems/maximum-number-of-non-overlapping-substrings/README.md +++ b/problems/maximum-number-of-non-overlapping-substrings/README.md @@ -57,8 +57,8 @@ If we choose the first string, we cannot choose anything else and we'd get o ### Related Topics - [[String](../../tag/string/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-visible-points/README.md b/problems/maximum-number-of-visible-points/README.md index 31e16ca42..fdf1f0654 100644 --- a/problems/maximum-number-of-visible-points/README.md +++ b/problems/maximum-number-of-visible-points/README.md @@ -62,11 +62,11 @@ ### Related Topics + [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Geometry](../../tag/geometry/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-ways-to-partition-an-array/README.md b/problems/maximum-number-of-ways-to-partition-an-array/README.md new file mode 100644 index 000000000..bee8e4c95 --- /dev/null +++ b/problems/maximum-number-of-ways-to-partition-an-array/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../maximize-the-confusion-of-an-exam "Maximize the Confusion of an Exam") +                 +[Next >](../low-quality-problems "Low-Quality Problems") + +## [2025. Maximum Number of Ways to Partition an Array (Hard)](https://leetcode.com/problems/maximum-number-of-ways-to-partition-an-array "分割数组的最多方案数") + +

    You are given a 0-indexed integer array nums of length n. The number of ways to partition nums is the number of pivot indices that satisfy both conditions:

    + +
      +
    • 1 <= pivot < n
    • +
    • nums[0] + nums[1] + ... + nums[pivot - 1] == nums[pivot] + nums[pivot + 1] + ... + nums[n - 1]
    • +
    + +

    You are also given an integer k. You can choose to change the value of one element of nums to k, or to leave the array unchanged.

    + +

    Return the maximum possible number of ways to partition nums to satisfy both conditions after changing at most one element.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [2,-1,2], k = 3
    +Output: 1
    +Explanation: One optimal approach is to change nums[0] to k. The array becomes [3,-1,2].
    +There is one way to partition the array:
    +- For pivot = 2, we have the partition [3,-1 | 2]: 3 + -1 == 2.
    +
    + +

    Example 2:

    + +
    +Input: nums = [0,0,0], k = 1
    +Output: 2
    +Explanation: The optimal approach is to leave the array unchanged.
    +There are two ways to partition the array:
    +- For pivot = 1, we have the partition [0 | 0,0]: 0 == 0 + 0.
    +- For pivot = 2, we have the partition [0,0 | 0]: 0 + 0 == 0.
    +
    + +

    Example 3:

    + +
    +Input: nums = [22,4,-25,-20,-15,15,-16,7,19,-10,0,-13,-14], k = -33
    +Output: 4
    +Explanation: One optimal approach is to change nums[2] to k. The array becomes [22,4,-33,-20,-15,15,-16,7,19,-10,0,-13,-14].
    +There are four ways to partition the array.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 2 <= n <= 105
    • +
    • -105 <= k, nums[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +A pivot point splits the array into equal prefix and suffix. If no change is made to the array, the goal is to find the number of pivot p such that prefix[p-1] == suffix[p]. +
    + +
    +Hint 2 +Consider how prefix and suffix will change when we change a number nums[i] to k. +
    + +
    +Hint 3 +When sweeping through each element, can you find the total number of pivots where the difference of prefix and suffix happens to equal to the changes of k-nums[i]. +
    diff --git a/problems/maximum-score-after-splitting-a-string/README.md b/problems/maximum-score-after-splitting-a-string/README.md index 3fd031b1f..b6f1d3acb 100644 --- a/problems/maximum-score-after-splitting-a-string/README.md +++ b/problems/maximum-score-after-splitting-a-string/README.md @@ -50,7 +50,7 @@ left = "01110" and right = "1", score = 2 + 1 = 3
    • 2 <= s.length <= 500
    • -
    • The string s consists of characters '0' and '1' only.
    • +
    • The string s consists of characters '0' and '1' only.
    ### Related Topics diff --git a/problems/maximum-score-of-a-good-subarray/README.md b/problems/maximum-score-of-a-good-subarray/README.md index 99f408d43..e513c8e21 100644 --- a/problems/maximum-score-of-a-good-subarray/README.md +++ b/problems/maximum-score-of-a-good-subarray/README.md @@ -47,6 +47,7 @@ [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints diff --git a/problems/maximum-subarray/README.md b/problems/maximum-subarray/README.md index 25bc3d99f..39cdbb54e 100644 --- a/problems/maximum-subarray/README.md +++ b/problems/maximum-subarray/README.md @@ -42,8 +42,8 @@

    Constraints:

      -
    • 1 <= nums.length <= 3 * 104
    • -
    • -105 <= nums[i] <= 105
    • +
    • 1 <= nums.length <= 105
    • +
    • -104 <= nums[i] <= 104

     

    diff --git a/problems/maximum-sum-bst-in-binary-tree/README.md b/problems/maximum-sum-bst-in-binary-tree/README.md index 0cbcdad6b..e74dca556 100644 --- a/problems/maximum-sum-bst-in-binary-tree/README.md +++ b/problems/maximum-sum-bst-in-binary-tree/README.md @@ -73,10 +73,10 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/maximum-units-on-a-truck/README.md b/problems/maximum-units-on-a-truck/README.md index 5cd68b096..ab1d4df4a 100644 --- a/problems/maximum-units-on-a-truck/README.md +++ b/problems/maximum-units-on-a-truck/README.md @@ -53,8 +53,8 @@ The total number of units will be = (1 * 3) + (2 * 2) + (1 * 1) = 8. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/min-cost-to-connect-all-points/README.md b/problems/min-cost-to-connect-all-points/README.md index 02ad17018..9000431ca 100644 --- a/problems/min-cost-to-connect-all-points/README.md +++ b/problems/min-cost-to-connect-all-points/README.md @@ -69,8 +69,8 @@ Notice that there is a unique path between every pair of points. ### Related Topics - [[Array](../../tag/array/README.md)] [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] ### Hints diff --git a/problems/mini-parser/README.md b/problems/mini-parser/README.md index 02e680462..35d1f45d1 100644 --- a/problems/mini-parser/README.md +++ b/problems/mini-parser/README.md @@ -44,12 +44,13 @@
  • 1 <= s.length <= 5 * 104
  • s consists of digits, square brackets "[]", negative sign '-', and commas ','.
  • s is the serialization of valid NestedInteger.
  • +
  • All the values in the input are in the range [-106, 106].
  • ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[String](../../tag/string/README.md)] ### Similar Questions 1. [Flatten Nested List Iterator](../flatten-nested-list-iterator) (Medium) diff --git a/problems/minimize-deviation-in-array/README.md b/problems/minimize-deviation-in-array/README.md index 59de5ccf4..785b9ce08 100644 --- a/problems/minimize-deviation-in-array/README.md +++ b/problems/minimize-deviation-in-array/README.md @@ -66,10 +66,10 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Hints
    diff --git a/problems/minimize-hamming-distance-after-swap-operations/README.md b/problems/minimize-hamming-distance-after-swap-operations/README.md index 2e92aaeec..8b2ac2ea0 100644 --- a/problems/minimize-hamming-distance-after-swap-operations/README.md +++ b/problems/minimize-hamming-distance-after-swap-operations/README.md @@ -59,9 +59,12 @@ The Hamming distance of source and target is 2 as they differ in 2 positions: in ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] + +### Similar Questions + 1. [Smallest String With Swaps](../smallest-string-with-swaps) (Medium) ### Hints
    diff --git a/problems/minimum-area-rectangle-ii/README.md b/problems/minimum-area-rectangle-ii/README.md index ffb222fad..3a6830dd7 100644 --- a/problems/minimum-area-rectangle-ii/README.md +++ b/problems/minimum-area-rectangle-ii/README.md @@ -61,6 +61,6 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] diff --git a/problems/minimum-cost-to-connect-two-groups-of-points/README.md b/problems/minimum-cost-to-connect-two-groups-of-points/README.md index 7d2218d62..cc6a19f95 100644 --- a/problems/minimum-cost-to-connect-two-groups-of-points/README.md +++ b/problems/minimum-cost-to-connect-two-groups-of-points/README.md @@ -62,11 +62,11 @@ Note that there are multiple points connected to point 2 in the first group and ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] - [[Matrix](../../tag/matrix/README.md)] [[Bitmask](../../tag/bitmask/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/README.md b/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/README.md index b9e329ac7..3a3ecc6b7 100644 --- a/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/README.md +++ b/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/README.md @@ -77,12 +77,12 @@ The total cost = 3. ### Related Topics - [[Array](../../tag/array/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Shortest Path](../../tag/shortest-path/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md b/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md index 07461cb07..c97912c97 100644 --- a/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md +++ b/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md @@ -56,8 +56,8 @@ The difference between the maximum and minimum is 1-0 = 1. ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md index bdc16a8b7..ddc02a52b 100644 --- a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md +++ b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md @@ -80,6 +80,9 @@ Total distance = 6 [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Minimum Time to Type Word Using Special Typewriter](../minimum-time-to-type-word-using-special-typewriter) (Easy) + ### Hints
    Hint 1 diff --git a/problems/minimum-falling-path-sum-ii/README.md b/problems/minimum-falling-path-sum-ii/README.md index 31184daa2..5eabc469f 100644 --- a/problems/minimum-falling-path-sum-ii/README.md +++ b/problems/minimum-falling-path-sum-ii/README.md @@ -50,6 +50,9 @@ The falling path with the smallest sum is [1,5,7], so the answer is 13 [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Minimum Falling Path Sum](../minimum-falling-path-sum) (Medium) + ### Hints
    Hint 1 diff --git a/problems/minimum-incompatibility/README.md b/problems/minimum-incompatibility/README.md index 7dbfed95f..1bb816cd0 100644 --- a/problems/minimum-incompatibility/README.md +++ b/problems/minimum-incompatibility/README.md @@ -56,9 +56,9 @@ The incompatibility is (2-1) + (3-2) + (8-6) + (3-1) = 6. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] ### Hints diff --git a/problems/minimum-insertions-to-balance-a-parentheses-string/README.md b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md index c55b8793d..540c98995 100644 --- a/problems/minimum-insertions-to-balance-a-parentheses-string/README.md +++ b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md @@ -76,12 +76,9 @@ ### Related Topics - [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] - -### Similar Questions - 1. [Minimum Number of Swaps to Make the String Balanced](../minimum-number-of-swaps-to-make-the-string-balanced) (Medium) + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/minimum-moves-to-convert-string/README.md b/problems/minimum-moves-to-convert-string/README.md new file mode 100644 index 000000000..377145f1d --- /dev/null +++ b/problems/minimum-moves-to-convert-string/README.md @@ -0,0 +1,68 @@ + + + + + + + +[< Previous](../low-quality-problems "Low-Quality Problems") +                 +[Next >](../find-missing-observations "Find Missing Observations") + +## [2027. Minimum Moves to Convert String (Easy)](https://leetcode.com/problems/minimum-moves-to-convert-string "转换字符串的最少操作次数") + +

    You are given a string s consisting of n characters which are either 'X' or 'O'.

    + +

    A move is defined as selecting three consecutive characters of s and converting them to 'O'. Note that if a move is applied to the character 'O', it will stay the same.

    + +

    Return the minimum number of moves required so that all the characters of s are converted to 'O'.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "XXX"
    +Output: 1
    +Explanation: XXX -> OOO
    +We select all the 3 characters and convert them in one move.
    +
    + +

    Example 2:

    + +
    +Input: s = "XXOX"
    +Output: 2
    +Explanation: XXOX -> OOOX -> OOOO
    +We select the first 3 characters in the first move, and convert them to 'O'.
    +Then we select the last 3 characters and convert them so that the final string contains all 'O's.
    + +

    Example 3:

    + +
    +Input: s = "OOOO"
    +Output: 0
    +Explanation: There are no 'X's in s to convert.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= s.length <= 1000
    • +
    • s[i] is either 'X' or 'O'.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Find the smallest substring you need to consider at a time. +
    + +
    +Hint 2 +Try delaying a move as long as possible. +
    diff --git a/problems/minimum-number-of-days-to-make-m-bouquets/README.md b/problems/minimum-number-of-days-to-make-m-bouquets/README.md index b1ebbe7e0..584cd0de2 100644 --- a/problems/minimum-number-of-days-to-make-m-bouquets/README.md +++ b/problems/minimum-number-of-days-to-make-m-bouquets/README.md @@ -83,6 +83,9 @@ It is obvious that we can make two bouquets in different ways. [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] +### Similar Questions + 1. [Maximize the Confusion of an Exam](../maximize-the-confusion-of-an-exam) (Medium) + ### Hints
    Hint 1 diff --git a/problems/minimum-number-of-moves-to-seat-everyone/README.md b/problems/minimum-number-of-moves-to-seat-everyone/README.md new file mode 100644 index 000000000..996c558f9 --- /dev/null +++ b/problems/minimum-number-of-moves-to-seat-everyone/README.md @@ -0,0 +1,92 @@ + + + + + + + +[< Previous](../maximum-alternating-subarray-sum "Maximum Alternating Subarray Sum") +                 +[Next >](../remove-colored-pieces-if-both-neighbors-are-the-same-color "Remove Colored Pieces if Both Neighbors are the Same Color") + +## [2037. Minimum Number of Moves to Seat Everyone (Easy)](https://leetcode.com/problems/minimum-number-of-moves-to-seat-everyone "使每位学生都有座位的最少移动次数") + +

    There are n seats and n students in a room. You are given an array seats of length n, where seats[i] is the position of the ith seat. You are also given the array students of length n, where students[j] is the position of the jth student.

    + +

    You may perform the following move any number of times:

    + +
      +
    • Increase or decrease the position of the ith student by 1 (i.e., moving the ith student from position x to x + 1 or x - 1)
    • +
    + +

    Return the minimum number of moves required to move each student to a seat such that no two students are in the same seat.

    + +

    Note that there may be multiple seats or students in the same position at the beginning.

    + +

     

    +

    Example 1:

    + +
    +Input: seats = [3,1,5], students = [2,7,4]
    +Output: 4
    +Explanation: The students are moved as follows:
    +- The first student is moved from from position 2 to position 1 using 1 move.
    +- The second student is moved from from position 7 to position 5 using 2 moves.
    +- The third student is moved from from position 4 to position 3 using 1 move.
    +In total, 1 + 2 + 1 = 4 moves were used.
    +
    + +

    Example 2:

    + +
    +Input: seats = [4,1,5,9], students = [1,3,2,6]
    +Output: 7
    +Explanation: The students are moved as follows:
    +- The first student is not moved.
    +- The second student is moved from from position 3 to position 4 using 1 move.
    +- The third student is moved from from position 2 to position 5 using 3 moves.
    +- The fourth student is moved from from position 6 to position 9 using 3 moves.
    +In total, 0 + 1 + 3 + 3 = 7 moves were used.
    +
    + +

    Example 3:

    + +
    +Input: seats = [2,2,6,6], students = [1,3,2,6]
    +Output: 4
    +Explanation: The students are moved as follows:
    +- The first student is moved from from position 1 to position 2 using 1 move.
    +- The second student is moved from from position 3 to position 6 using 3 moves.
    +- The third student is not moved.
    +- The fourth student is not moved.
    +In total, 1 + 3 + 0 + 0 = 4 moves were used.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == seats.length == students.length
    • +
    • 1 <= n <= 100
    • +
    • 1 <= seats[i], students[j] <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Can we sort the arrays to help solve the problem? +
    + +
    +Hint 2 +Can we greedily match each student to a seat? +
    + +
    +Hint 3 +The smallest positioned student will go to the smallest positioned chair, and then the next smallest positioned student will go to the next smallest positioned chair, and so on. +
    diff --git a/problems/minimum-number-of-operations-to-make-array-continuous/README.md b/problems/minimum-number-of-operations-to-make-array-continuous/README.md new file mode 100644 index 000000000..e9195c838 --- /dev/null +++ b/problems/minimum-number-of-operations-to-make-array-continuous/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../maximum-earnings-from-taxi "Maximum Earnings From Taxi") +                 +[Next >](../the-number-of-seniors-and-juniors-to-join-the-company-ii "The Number of Seniors and Juniors to Join the Company II") + +## [2009. Minimum Number of Operations to Make Array Continuous (Hard)](https://leetcode.com/problems/minimum-number-of-operations-to-make-array-continuous "使数组连续的最少操作数") + +

    You are given an integer array nums. In one operation, you can replace any element in nums with any integer.

    + +

    nums is considered continuous if both of the following conditions are fulfilled:

    + +
      +
    • All elements in nums are unique.
    • +
    • The difference between the maximum element and the minimum element in nums equals nums.length - 1.
    • +
    + +

    For example, nums = [4, 2, 5, 3] is continuous, but nums = [1, 2, 3, 5, 6] is not continuous.

    + +

    Return the minimum number of operations to make nums continuous.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [4,2,5,3]
    +Output: 0
    +Explanation: nums is already continuous.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,2,3,5,6]
    +Output: 1
    +Explanation: One possible solution is to change the last element to 4.
    +The resulting array is [1,2,3,5,4], which is continuous.
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,10,100,1000]
    +Output: 3
    +Explanation: One possible solution is to:
    +- Change the second element to 2.
    +- Change the third element to 3.
    +- Change the fourth element to 4.
    +The resulting array is [1,2,3,4], which is continuous.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 109
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Sort the array. +
    + +
    +Hint 2 +For every index do a binary search to get the possible right end of the window and calculate the possible answer. +
    diff --git a/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md b/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md index a4d10b03d..fdf8008a6 100644 --- a/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md +++ b/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md @@ -69,9 +69,6 @@ [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] -### Similar Questions - 1. [Determine if Two Strings Are Close](../determine-if-two-strings-are-close) (Medium) - ### Hints
    Hint 1 diff --git a/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md b/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md index 2f642e058..b6c6547fe 100644 --- a/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md +++ b/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md @@ -13,7 +13,7 @@

    There is a one-dimensional garden on the x-axis. The garden starts at the point 0 and ends at the point n. (i.e The length of the garden is n).

    -

    There are n + 1 taps located at points [0, 1, ..., n] in the garden.

    +

    There are n + 1 taps located at points [0, 1, ..., n] in the garden.

    Given an integer n and an integer array ranges of length n + 1 where ranges[i] (0-indexed) means the i-th tap can water the area [i - ranges[i], i + ranges[i]] if it was open.

    @@ -67,15 +67,15 @@ Opening Only the second tap will water the whole garden [0,5]

    Constraints:

      -
    • 1 <= n <= 10^4
    • +
    • 1 <= n <= 104
    • ranges.length == n + 1
    • 0 <= ranges[i] <= 100
    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md b/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md index 0dfac9e44..21ee9a594 100644 --- a/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md +++ b/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md @@ -72,8 +72,8 @@ Total of operations: 2 + 1 = 3. ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/minimum-one-bit-operations-to-make-integers-zero/README.md b/problems/minimum-one-bit-operations-to-make-integers-zero/README.md index b04d7fdaf..cb5a915e0 100644 --- a/problems/minimum-one-bit-operations-to-make-integers-zero/README.md +++ b/problems/minimum-one-bit-operations-to-make-integers-zero/README.md @@ -72,9 +72,12 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Memoization](../../tag/memoization/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Similar Questions + 1. [Minimum Number of Operations to Make Array Continuous](../minimum-number-of-operations-to-make-array-continuous) (Hard) ### Hints
    diff --git a/problems/minimum-operations-to-make-a-uni-value-grid/README.md b/problems/minimum-operations-to-make-a-uni-value-grid/README.md new file mode 100644 index 000000000..7c9e2c738 --- /dev/null +++ b/problems/minimum-operations-to-make-a-uni-value-grid/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../two-out-of-three "Two Out of Three") +                 +[Next >](../stock-price-fluctuation "Stock Price Fluctuation ") + +## [2033. Minimum Operations to Make a Uni-Value Grid (Medium)](https://leetcode.com/problems/minimum-operations-to-make-a-uni-value-grid "获取单值网格的最小操作数") + +

    You are given a 2D integer grid of size m x n and an integer x. In one operation, you can add x to or subtract x from any element in the grid.

    + +

    A uni-value grid is a grid where all the elements of it are equal.

    + +

    Return the minimum number of operations to make the grid uni-value. If it is not possible, return -1.

    + +

     

    +

    Example 1:

    + +
    +Input: grid = [[2,4],[6,8]], x = 2
    +Output: 4
    +Explanation: We can make every element equal to 4 by doing the following: 
    +- Add x to 2 once.
    +- Subtract x from 6 once.
    +- Subtract x from 8 twice.
    +A total of 4 operations were used.
    +
    + +

    Example 2:

    + +
    +Input: grid = [[1,5],[2,3]], x = 1
    +Output: 5
    +Explanation: We can make every element equal to 3.
    +
    + +

    Example 3:

    + +
    +Input: grid = [[1,2],[3,4]], x = 2
    +Output: -1
    +Explanation: It is impossible to make every element equal.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 105
    • +
    • 1 <= m * n <= 105
    • +
    • 1 <= x, grid[i][j] <= 104
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Is it possible to make two integers a and b equal if they have different remainders dividing by x? +
    + +
    +Hint 2 +If it is possible, which number should you select to minimize the number of operations? +
    + +
    +Hint 3 +What if the elements are sorted? +
    diff --git a/problems/minimum-operations-to-reduce-x-to-zero/README.md b/problems/minimum-operations-to-reduce-x-to-zero/README.md index 165d04ab2..4dd99132b 100644 --- a/problems/minimum-operations-to-reduce-x-to-zero/README.md +++ b/problems/minimum-operations-to-reduce-x-to-zero/README.md @@ -55,6 +55,10 @@ [[Binary Search](../../tag/binary-search/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] +### Similar Questions + 1. [Minimum Size Subarray Sum](../minimum-size-subarray-sum) (Medium) + 1. [Subarray Sum Equals K](../subarray-sum-equals-k) (Medium) + ### Hints
    Hint 1 diff --git a/problems/minimum-time-for-k-virus-variants-to-spread/README.md b/problems/minimum-time-for-k-virus-variants-to-spread/README.md index 9b248d850..c91d81e7e 100644 --- a/problems/minimum-time-for-k-virus-variants-to-spread/README.md +++ b/problems/minimum-time-for-k-virus-variants-to-spread/README.md @@ -13,6 +13,13 @@ +### Related Topics + [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + ### Hints
    Hint 1 diff --git a/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md b/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md index 2ba788cc4..a70b6db6b 100644 --- a/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md +++ b/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md @@ -17,9 +17,7 @@

     

    Example 1:

    - -

    - +
     Input: n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], hasApple = [false,false,true,false,true,true,false]
     Output: 8 
    @@ -27,9 +25,7 @@
     

    Example 2:

    - -

    - +
     Input: n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], hasApple = [false,false,true,false,false,true,false]
     Output: 6
    @@ -47,11 +43,11 @@
     

    Constraints:

      -
    • 1 <= n <= 10^5
    • +
    • 1 <= n <= 105
    • edges.length == n - 1
    • edges[i].length == 2
    • 0 <= ai < bi <= n - 1
    • -
    • fromi < toi
    • +
    • fromi < toi
    • hasApple.length == n
    diff --git a/problems/most-frequent-subtree-sum/README.md b/problems/most-frequent-subtree-sum/README.md index f6c8d73d9..be2cc3453 100644 --- a/problems/most-frequent-subtree-sum/README.md +++ b/problems/most-frequent-subtree-sum/README.md @@ -39,10 +39,11 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Subtree of Another Tree](../subtree-of-another-tree) (Easy) + 1. [Count Nodes Equal to Sum of Descendants](../count-nodes-equal-to-sum-of-descendants) (Medium) diff --git a/problems/next-greater-element-ii/README.md b/problems/next-greater-element-ii/README.md index 1007b9d8a..f5aad81ad 100644 --- a/problems/next-greater-element-ii/README.md +++ b/problems/next-greater-element-ii/README.md @@ -42,8 +42,8 @@ The second 1's next greater number needs to search circularly, which is also ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] + [[Stack](../../tag/stack/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Similar Questions diff --git a/problems/nim-game/README.md b/problems/nim-game/README.md index cd1f0de38..777bf5b83 100644 --- a/problems/nim-game/README.md +++ b/problems/nim-game/README.md @@ -57,8 +57,8 @@ In all outcomes, your friend wins. ### Related Topics - [[Math](../../tag/math/README.md)] [[Brainteaser](../../tag/brainteaser/README.md)] + [[Math](../../tag/math/README.md)] [[Game Theory](../../tag/game-theory/README.md)] ### Similar Questions diff --git a/problems/number-of-accounts-that-did-not-stream/README.md b/problems/number-of-accounts-that-did-not-stream/README.md new file mode 100644 index 000000000..6b45c40b6 --- /dev/null +++ b/problems/number-of-accounts-that-did-not-stream/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../the-score-of-students-solving-math-expression "The Score of Students Solving Math Expression") +                 +[Next >](../brightest-position-on-street "Brightest Position on Street") + +## [2020. Number of Accounts That Did Not Stream (Medium)](https://leetcode.com/problems/number-of-accounts-that-did-not-stream "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/number-of-accounts-that-did-not-stream/mysql_schemas.sql b/problems/number-of-accounts-that-did-not-stream/mysql_schemas.sql new file mode 100644 index 000000000..242bcbb86 --- /dev/null +++ b/problems/number-of-accounts-that-did-not-stream/mysql_schemas.sql @@ -0,0 +1,16 @@ +Create table If Not Exists Subscriptions (account_id int, start_date date, end_date date); +Create table If Not Exists Streams (session_id int, account_id int, stream_date date); +Truncate table Subscriptions; +insert into Subscriptions (account_id, start_date, end_date) values ('9', '2020-02-18', '2021-10-30'); +insert into Subscriptions (account_id, start_date, end_date) values ('3', '2021-09-21', '2021-11-13'); +insert into Subscriptions (account_id, start_date, end_date) values ('11', '2020-02-28', '2020-08-18'); +insert into Subscriptions (account_id, start_date, end_date) values ('13', '2021-04-20', '2021-09-22'); +insert into Subscriptions (account_id, start_date, end_date) values ('4', '2020-10-26', '2021-05-08'); +insert into Subscriptions (account_id, start_date, end_date) values ('5', '2020-09-11', '2021-01-17'); +Truncate table Streams; +insert into Streams (session_id, account_id, stream_date) values ('14', '9', '2020-05-16'); +insert into Streams (session_id, account_id, stream_date) values ('16', '3', '2021-10-27'); +insert into Streams (session_id, account_id, stream_date) values ('18', '11', '2020-04-29'); +insert into Streams (session_id, account_id, stream_date) values ('17', '13', '2021-08-08'); +insert into Streams (session_id, account_id, stream_date) values ('19', '4', '2020-12-31'); +insert into Streams (session_id, account_id, stream_date) values ('13', '5', '2021-01-05'); diff --git a/problems/number-of-dice-rolls-with-target-sum/README.md b/problems/number-of-dice-rolls-with-target-sum/README.md index 3b711a2ba..046d5f13e 100644 --- a/problems/number-of-dice-rolls-with-target-sum/README.md +++ b/problems/number-of-dice-rolls-with-target-sum/README.md @@ -11,9 +11,9 @@ ## [1155. Number of Dice Rolls With Target Sum (Medium)](https://leetcode.com/problems/number-of-dice-rolls-with-target-sum "掷骰子的N种方法") -

    You have d dice and each die has f faces numbered 1, 2, ..., f.

    +

    You have d dice and each die has f faces numbered 1, 2, ..., f. You are given three integers d, f, and target.

    -

    Return the number of possible ways (out of fd total ways) modulo 109 + 7 to roll the dice so the sum of the face-up numbers equals target.

    +

    Return the number of possible ways (out of fd total ways) modulo 109 + 7 to roll the dice so the sum of the face-up numbers equals target.

     

    Example 1:

    @@ -73,6 +73,10 @@ The answer must be returned modulo 10^9 + 7. ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Equal Sum Arrays With Minimum Number of Operations](../equal-sum-arrays-with-minimum-number-of-operations) (Medium) + 1. [Find Missing Observations](../find-missing-observations) (Medium) + ### Hints
    Hint 1 diff --git a/problems/number-of-good-pairs/README.md b/problems/number-of-good-pairs/README.md index e174c305f..13e548070 100644 --- a/problems/number-of-good-pairs/README.md +++ b/problems/number-of-good-pairs/README.md @@ -53,6 +53,9 @@ [[Math](../../tag/math/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Number of Pairs of Interchangeable Rectangles](../number-of-pairs-of-interchangeable-rectangles) (Medium) + ### Hints
    Hint 1 diff --git a/problems/number-of-islands-ii/README.md b/problems/number-of-islands-ii/README.md index 8abb898ae..d11faa469 100644 --- a/problems/number-of-islands-ii/README.md +++ b/problems/number-of-islands-ii/README.md @@ -67,8 +67,8 @@

    Can you do it in time complexity O(k log mn), where k is the length of the positions?

    ### Related Topics - [[Array](../../tag/array/README.md)] [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions 1. [Number of Islands](../number-of-islands) (Medium) diff --git a/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target/README.md b/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target/README.md new file mode 100644 index 000000000..994bb5e99 --- /dev/null +++ b/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target/README.md @@ -0,0 +1,77 @@ + + + + + + + +[< Previous](../convert-1d-array-into-2d-array "Convert 1D Array Into 2D Array") +                 +[Next >](../maximize-the-confusion-of-an-exam "Maximize the Confusion of an Exam") + +## [2023. Number of Pairs of Strings With Concatenation Equal to Target (Medium)](https://leetcode.com/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target "连接后等于目标字符串的字符串对") + +

    Given an array of digit strings nums and a digit string target, return the number of pairs of indices (i, j) (where i != j) such that the concatenation of nums[i] + nums[j] equals target.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = ["777","7","77","77"], target = "7777"
    +Output: 4
    +Explanation: Valid pairs are:
    +- (0, 1): "777" + "7"
    +- (1, 0): "7" + "777"
    +- (2, 3): "77" + "77"
    +- (3, 2): "77" + "77"
    +
    + +

    Example 2:

    + +
    +Input: nums = ["123","4","12","34"], target = "1234"
    +Output: 2
    +Explanation: Valid pairs are:
    +- (0, 1): "123" + "4"
    +- (2, 3): "12" + "34"
    +
    + +

    Example 3:

    + +
    +Input: nums = ["1","1","1"], target = "11"
    +Output: 6
    +Explanation: Valid pairs are:
    +- (0, 1): "1" + "1"
    +- (1, 0): "1" + "1"
    +- (0, 2): "1" + "1"
    +- (2, 0): "1" + "1"
    +- (1, 2): "1" + "1"
    +- (2, 1): "1" + "1"
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= nums.length <= 100
    • +
    • 1 <= nums[i].length <= 100
    • +
    • 2 <= target.length <= 100
    • +
    • nums[i] and target consist of digits.
    • +
    • nums[i] and target do not have leading zeros.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Try to concatenate every two different strings from the list. +
    + +
    +Hint 2 +Count the number of pairs with concatenation equals to target. +
    diff --git a/problems/number-of-substrings-with-only-1s/README.md b/problems/number-of-substrings-with-only-1s/README.md index 920f3d034..7fe742f2c 100644 --- a/problems/number-of-substrings-with-only-1s/README.md +++ b/problems/number-of-substrings-with-only-1s/README.md @@ -11,11 +11,7 @@ ## [1513. Number of Substrings With Only 1s (Medium)](https://leetcode.com/problems/number-of-substrings-with-only-1s "仅含 1 的子串数") -

    Given a binary string s (a string consisting only of '0' and '1's).

    - -

    Return the number of substrings with all characters 1's.

    - -

    Since the answer may be too large, return it modulo 10^9 + 7.

    +

    Given a binary string s, return the number of substrings with all characters 1's. Since the answer may be too large, return it modulo 109 + 7.

     

    Example 1:

    @@ -23,7 +19,7 @@
     Input: s = "0110111"
     Output: 9
    -Explanation: There are 9 substring in total with only 1's characters.
    +Explanation: There are 9 substring in total with only 1's characters.
     "1" -> 5 times.
     "11" -> 3 times.
     "111" -> 1 time.
    @@ -33,7 +29,7 @@
     Input: s = "101"
     Output: 2
    -Explanation: Substring "1" is shown 2 times in s.
    +Explanation: Substring "1" is shown 2 times in s.
     

    Example 3:

    @@ -41,7 +37,7 @@
     Input: s = "111111"
     Output: 21
    -Explanation: Each substring contains only 1's characters.
    +Explanation: Each substring contains only 1's characters.
     

    Example 4:

    @@ -55,8 +51,8 @@

    Constraints:

      -
    • s[i] == '0' or s[i] == '1'
    • -
    • 1 <= s.length <= 10^5
    • +
    • 1 <= s.length <= 105
    • +
    • s[i] is either '0' or '1'.
    ### Related Topics diff --git a/problems/number-of-transactions-per-visit/README.md b/problems/number-of-transactions-per-visit/README.md index e4f0d2d1e..8c57e66d2 100644 --- a/problems/number-of-transactions-per-visit/README.md +++ b/problems/number-of-transactions-per-visit/README.md @@ -95,3 +95,6 @@ Note that we stopped at transactions_count = 3 as this is the maximum number of ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Find the Missing IDs](../find-the-missing-ids) (Medium) diff --git a/problems/numbers-with-same-consecutive-differences/README.md b/problems/numbers-with-same-consecutive-differences/README.md index eb5735c58..0b47b74d0 100644 --- a/problems/numbers-with-same-consecutive-differences/README.md +++ b/problems/numbers-with-same-consecutive-differences/README.md @@ -56,5 +56,5 @@ ### Related Topics - [[Backtracking](../../tag/backtracking/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] diff --git a/problems/operations-on-tree/README.md b/problems/operations-on-tree/README.md index 035f3dcc7..500941e2a 100644 --- a/problems/operations-on-tree/README.md +++ b/problems/operations-on-tree/README.md @@ -16,9 +16,9 @@

    The data structure should support the following functions:

      -
    • Lock: Locks the given node for the given user and prevents other users from locking the same node. You may only lock a node if the node is unlocked.
    • -
    • Unlock: Unlocks the given node for the given user. You may only unlock a node if it is currently locked by the same user.
    • -
    • Upgrade: Locks the given node for the given user and unlocks all of its descendants. You may only upgrade a node if all 3 conditions are true: +
    • Lock: Locks the given node for the given user and prevents other users from locking the same node. You may only lock a node using this function if the node is unlocked.
    • +
    • Unlock: Unlocks the given node for the given user. You may only unlock a node using this function if it is currently locked by the same user.
    • +
    • Upgrade: Locks the given node for the given user and unlocks all of its descendants regardless of who locked it. You may only upgrade a node if all 3 conditions are true:
      • The node is unlocked,
      • It has at least one locked descendant (by any user), and
      • diff --git a/problems/page-recommendations/README.md b/problems/page-recommendations/README.md index 928977a3e..b4d9206b7 100644 --- a/problems/page-recommendations/README.md +++ b/problems/page-recommendations/README.md @@ -87,3 +87,7 @@ Page 88 is not suggested because user 1 already likes it. ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Page Recommendations II](../page-recommendations-ii) (Hard) + 1. [Strong Friendship](../strong-friendship) (Medium) diff --git a/problems/palindrome-partitioning-iii/README.md b/problems/palindrome-partitioning-iii/README.md index c64722b83..9838d87d8 100644 --- a/problems/palindrome-partitioning-iii/README.md +++ b/problems/palindrome-partitioning-iii/README.md @@ -55,6 +55,9 @@ [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Palindrome Partitioning IV](../palindrome-partitioning-iv) (Hard) + ### Hints
        Hint 1 diff --git a/problems/parallel-courses-ii/README.md b/problems/parallel-courses-ii/README.md index 279d413f8..01d706e9c 100644 --- a/problems/parallel-courses-ii/README.md +++ b/problems/parallel-courses-ii/README.md @@ -67,11 +67,14 @@ In the fourth semester, you can take course 5.
      ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Graph](../../tag/graph/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bitmask](../../tag/bitmask/README.md)] +### Similar Questions + 1. [Parallel Courses](../parallel-courses) (Medium) + ### Hints
      Hint 1 diff --git a/problems/partition-array-into-two-arrays-to-minimize-sum-difference/README.md b/problems/partition-array-into-two-arrays-to-minimize-sum-difference/README.md new file mode 100644 index 000000000..9eb4c208e --- /dev/null +++ b/problems/partition-array-into-two-arrays-to-minimize-sum-difference/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../stock-price-fluctuation "Stock Price Fluctuation ") +                 +[Next >](../maximum-alternating-subarray-sum "Maximum Alternating Subarray Sum") + +## [2035. Partition Array Into Two Arrays to Minimize Sum Difference (Hard)](https://leetcode.com/problems/partition-array-into-two-arrays-to-minimize-sum-difference "将数组分成两个数组并最小化数组和的差") + +

      You are given an integer array nums of 2 * n integers. You need to partition nums into two arrays of length n to minimize the absolute difference of the sums of the arrays. To partition nums, put each element of nums into one of the two arrays.

      + +

      Return the minimum possible absolute difference.

      + +

       

      +

      Example 1:

      +example-1 +
      +Input: nums = [3,9,7,3]
      +Output: 2
      +Explanation: One optimal partition is: [3,9] and [7,3].
      +The absolute difference between the sums of the arrays is abs((3 + 9) - (7 + 3)) = 2.
      +
      + +

      Example 2:

      + +
      +Input: nums = [-36,36]
      +Output: 72
      +Explanation: One optimal partition is: [-36] and [36].
      +The absolute difference between the sums of the arrays is abs((-36) - (36)) = 72.
      +
      + +

      Example 3:

      +example-3 +
      +Input: nums = [2,-1,0,4,-2,-9]
      +Output: 0
      +Explanation: One optimal partition is: [2,4,-9] and [-1,0,-2].
      +The absolute difference between the sums of the arrays is abs((2 + 4 + -9) - (-1 + 0 + -2)) = 0.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • 1 <= n <= 15
      • +
      • nums.length == 2 * n
      • +
      • -107 <= nums[i] <= 107
      • +
      + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + +### Hints +
      +Hint 1 +The target sum for the two partitions is sum(nums) / 2. +
      + +
      +Hint 2 +Could you reduce the time complexity if you arbitrarily divide nums into two halves (two arrays)? Meet-in-the-Middle? +
      + +
      +Hint 3 +For both halves, pre-calculate a 2D array where the kth index will store all possible sum values if only k elements from this half are added. +
      + +
      +Hint 4 +For each sum of k elements in the first half, find the best sum of n-k elements in the second half such that the two sums add up to a value closest to the target sum from hint 1. These two subsets will form one array of the partition. +
      diff --git a/problems/path-with-minimum-effort/README.md b/problems/path-with-minimum-effort/README.md index 87fb8141a..f86467458 100644 --- a/problems/path-with-minimum-effort/README.md +++ b/problems/path-with-minimum-effort/README.md @@ -58,17 +58,13 @@ This is better than the route of [1,2,2,2,5], where the maximum absolute differe
    ### Related Topics - [[Array](../../tag/array/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Matrix](../../tag/matrix/README.md)] - -### Similar Questions - 1. [Swim in Rising Water](../swim-in-rising-water) (Hard) - 1. [Path With Maximum Minimum Value](../path-with-maximum-minimum-value) (Medium) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/peeking-iterator/README.md b/problems/peeking-iterator/README.md index f3c71d542..760699b87 100644 --- a/problems/peeking-iterator/README.md +++ b/problems/peeking-iterator/README.md @@ -9,7 +9,7 @@                  [Next >](../inorder-successor-in-bst "Inorder Successor in BST") -## [284. Peeking Iterator (Medium)](https://leetcode.com/problems/peeking-iterator "顶端迭代器") +## [284. Peeking Iterator (Medium)](https://leetcode.com/problems/peeking-iterator "窥探迭代器")

    Design an iterator that supports the peek operation on a list in addition to the hasNext and the next operations.

    diff --git a/problems/percentage-of-users-attended-a-contest/README.md b/problems/percentage-of-users-attended-a-contest/README.md index 9afe97740..ed363bcbd 100644 --- a/problems/percentage-of-users-attended-a-contest/README.md +++ b/problems/percentage-of-users-attended-a-contest/README.md @@ -15,6 +15,3 @@ ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Queries Quality and Percentage](../queries-quality-and-percentage) (Easy) diff --git a/problems/perfect-squares/README.md b/problems/perfect-squares/README.md index e87e71299..f7a0cdd4b 100644 --- a/problems/perfect-squares/README.md +++ b/problems/perfect-squares/README.md @@ -40,10 +40,10 @@ ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Similar Questions - 1. [Count Primes](../count-primes) (Easy) + 1. [Count Primes](../count-primes) (Medium) 1. [Ugly Number II](../ugly-number-ii) (Medium) diff --git a/problems/pizza-with-3n-slices/README.md b/problems/pizza-with-3n-slices/README.md index 3c34d91e4..fb5a05914 100644 --- a/problems/pizza-with-3n-slices/README.md +++ b/problems/pizza-with-3n-slices/README.md @@ -69,9 +69,9 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/preimage-size-of-factorial-zeroes-function/README.md b/problems/preimage-size-of-factorial-zeroes-function/README.md index 281ec3e29..dc4e6827d 100644 --- a/problems/preimage-size-of-factorial-zeroes-function/README.md +++ b/problems/preimage-size-of-factorial-zeroes-function/README.md @@ -55,4 +55,4 @@ [[Binary Search](../../tag/binary-search/README.md)] ### Similar Questions - 1. [Factorial Trailing Zeroes](../factorial-trailing-zeroes) (Easy) + 1. [Factorial Trailing Zeroes](../factorial-trailing-zeroes) (Medium) diff --git a/problems/prime-number-of-set-bits-in-binary-representation/README.md b/problems/prime-number-of-set-bits-in-binary-representation/README.md index 13d7f9159..8cc15c482 100644 --- a/problems/prime-number-of-set-bits-in-binary-representation/README.md +++ b/problems/prime-number-of-set-bits-in-binary-representation/README.md @@ -11,12 +11,12 @@ ## [762. Prime Number of Set Bits in Binary Representation (Easy)](https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation "二进制表示中质数个计算置位") -

    Given two integers left and right, return the count of numbers in the inclusive range [left, right] having a prime number of set bits in their binary representation.

    +

    Given two integers left and right, return the count of numbers in the inclusive range [left, right] having a prime number of set bits in their binary representation.

    -

    Recall that the number of set bits an integer has is the number of 1's present when written in binary.

    +

    Recall that the number of set bits an integer has is the number of 1's present when written in binary.

      -
    • For example, 21 written in binary is 10101 which has 3 set bits.
    • +
    • For example, 21 written in binary is 10101, which has 3 set bits.

     

    @@ -26,10 +26,12 @@ Input: left = 6, right = 10 Output: 4 Explanation: -6 -> 110 (2 set bits, 2 is prime) -7 -> 111 (3 set bits, 3 is prime) -9 -> 1001 (2 set bits , 2 is prime) -10->1010 (2 set bits , 2 is prime) +6 -> 110 (2 set bits, 2 is prime) +7 -> 111 (3 set bits, 3 is prime) +8 -> 1000 (1 set bit, 1 is not prime) +9 -> 1001 (2 set bits, 2 is prime) +10 -> 1010 (2 set bits, 2 is prime) +4 numbers have a prime number of set bits.

    Example 2:

    @@ -44,6 +46,7 @@ 13 -> 1101 (3 set bits, 3 is prime) 14 -> 1110 (3 set bits, 3 is prime) 15 -> 1111 (4 set bits, 4 is not prime) +5 numbers have a prime number of set bits.

     

    @@ -55,8 +58,8 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Number of 1 Bits](../number-of-1-bits) (Easy) diff --git a/problems/print-immutable-linked-list-in-reverse/README.md b/problems/print-immutable-linked-list-in-reverse/README.md index dce74d494..36b2d09ff 100644 --- a/problems/print-immutable-linked-list-in-reverse/README.md +++ b/problems/print-immutable-linked-list-in-reverse/README.md @@ -51,7 +51,7 @@ Constraints: - The value of each node in the linked list is between [-1000, 1000]. ### Related Topics - [[Stack](../../tag/stack/README.md)] - [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Recursion](../../tag/recursion/README.md)] diff --git a/problems/product-of-the-last-k-numbers/README.md b/problems/product-of-the-last-k-numbers/README.md index f981f6951..045f7f54c 100644 --- a/problems/product-of-the-last-k-numbers/README.md +++ b/problems/product-of-the-last-k-numbers/README.md @@ -59,10 +59,10 @@ productOfNumbers.getProduct(2); // return 32. The product of the last 2 numbers ### Related Topics - [[Design](../../tag/design/README.md)] - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] [[Data Stream](../../tag/data-stream/README.md)] ### Hints diff --git a/problems/put-boxes-into-the-warehouse-i/README.md b/problems/put-boxes-into-the-warehouse-i/README.md index 58ec067a0..b285a7652 100644 --- a/problems/put-boxes-into-the-warehouse-i/README.md +++ b/problems/put-boxes-into-the-warehouse-i/README.md @@ -14,13 +14,10 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Put Boxes Into the Warehouse II](../put-boxes-into-the-warehouse-ii) (Medium) - ### Hints
    Hint 1 diff --git a/problems/random-pick-index/README.md b/problems/random-pick-index/README.md index 01f9412be..7d3b38155 100644 --- a/problems/random-pick-index/README.md +++ b/problems/random-pick-index/README.md @@ -48,9 +48,9 @@ solution.pick(3); // It should return either index 2, 3, or 4 randomly. Each ind ### Related Topics - [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] [[Randomized](../../tag/randomized/README.md)] ### Similar Questions diff --git a/problems/rank-scores/README.md b/problems/rank-scores/README.md index 4ac52c02c..098772ff7 100644 --- a/problems/rank-scores/README.md +++ b/problems/rank-scores/README.md @@ -11,9 +11,39 @@ ## [178. Rank Scores (Medium)](https://leetcode.com/problems/rank-scores "分数排名") -

    Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ranking. Note that after a tie, the next ranking number should be the next consecutive integer value. In other words, there should be no "holes" between ranks.

    +

    Table: Scores

    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| Id          | int     |
    +| Score       | decimal |
    ++-------------+---------+
    +Id is the primary key for this table.
    +Each row of this table contains the score of a game. Score is a floating point value with two decimal places.
    +
    + +

     

    + +

    Write an SQL query to rank the scores. The ranking should be calculated according to the following rules:

    + +
      +
    • The scores should be ranked from the highest to the lowest.
    • +
    • If there is a tie between two scores, both should have the same ranking.
    • +
    • After a tie, the next ranking number should be the next consecutive integer value. In other words, there should be no holes between ranks.
    • +
    + +

    Return the result table ordered by score in descending order.

    + +

    The query result format is in the following example.

    + +

     

    +

    Example 1:

    + +
    +Input: 
    +Scores table:
     +----+-------+
     | Id | Score |
     +----+-------+
    @@ -24,24 +54,18 @@
     | 5  | 4.00  |
     | 6  | 3.65  |
     +----+-------+
    +Output: 
    ++-------+------+
    +| Score | Rank |
    ++-------+------+
    +| 4.00  | 1    |
    +| 4.00  | 1    |
    +| 3.85  | 2    |
    +| 3.65  | 3    |
    +| 3.65  | 3    |
    +| 3.50  | 4    |
    ++-------+------+
     
    -

    For example, given the above Scores table, your query should generate the following report (order by highest score):

    - -
    -+-------+---------+
    -| score | Rank    |
    -+-------+---------+
    -| 4.00  | 1       |
    -| 4.00  | 1       |
    -| 3.85  | 2       |
    -| 3.65  | 3       |
    -| 3.65  | 3       |
    -| 3.50  | 4       |
    -+-------+---------+
    -
    - -

    Important Note: For MySQL solutions, to escape reserved words used as column names, you can use an apostrophe before and after the keyword. For example `Rank`.

    - ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/rearrange-spaces-between-words/README.md b/problems/rearrange-spaces-between-words/README.md index 4e8a32046..7705a8c6b 100644 --- a/problems/rearrange-spaces-between-words/README.md +++ b/problems/rearrange-spaces-between-words/README.md @@ -67,9 +67,6 @@ ### Related Topics [[String](../../tag/string/README.md)] -### Similar Questions - 1. [Text Justification](../text-justification) (Hard) - ### Hints
    Hint 1 diff --git a/problems/reconstruct-a-2-row-binary-matrix/README.md b/problems/reconstruct-a-2-row-binary-matrix/README.md index 06655f5a4..5c631ae16 100644 --- a/problems/reconstruct-a-2-row-binary-matrix/README.md +++ b/problems/reconstruct-a-2-row-binary-matrix/README.md @@ -61,10 +61,13 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Find Valid Matrix Given Row and Column Sums](../find-valid-matrix-given-row-and-column-sums) (Medium) + ### Hints
    Hint 1 diff --git a/problems/reducing-dishes/README.md b/problems/reducing-dishes/README.md index 9f770ebbe..ce4c9a144 100644 --- a/problems/reducing-dishes/README.md +++ b/problems/reducing-dishes/README.md @@ -11,11 +11,11 @@ ## [1402. Reducing Dishes (Hard)](https://leetcode.com/problems/reducing-dishes "做菜顺序") -

    A chef has collected data on the satisfaction level of his n dishes. Chef can cook any dish in 1 unit of time.

    +

    A chef has collected data on the satisfaction level of his n dishes. Chef can cook any dish in 1 unit of time.

    -

    Like-time coefficient of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its satisfaction level  i.e.  time[i]*satisfaction[i]

    +

    Like-time coefficient of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its satisfaction level i.e. time[i] * satisfaction[i].

    -

    Return the maximum sum of Like-time coefficient that the chef can obtain after dishes preparation.

    +

    Return the maximum sum of like-time coefficient that the chef can obtain after dishes preparation.

    Dishes can be prepared in any order and the chef can discard some dishes to get this maximum value.

    @@ -25,7 +25,8 @@
     Input: satisfaction = [-1,-8,0,5,-9]
     Output: 14
    -Explanation: After Removing the second and last dish, the maximum total Like-time coefficient will be equal to (-1*1 + 0*2 + 5*3 = 14). Each dish is prepared in one unit of time.
    +Explanation: After Removing the second and last dish, the maximum total like-time coefficient will be equal to (-1*1 + 0*2 + 5*3 = 14). +Each dish is prepared in one unit of time.

    Example 2:

    @@ -56,7 +57,7 @@
    • n == satisfaction.length
    • 1 <= n <= 500
    • -
    • -10^3 <= satisfaction[i] <= 10^3
    • +
    • -1000 <= satisfaction[i] <= 1000
    ### Related Topics diff --git a/problems/remove-boxes/README.md b/problems/remove-boxes/README.md index 6f4679bc2..30282b6d7 100644 --- a/problems/remove-boxes/README.md +++ b/problems/remove-boxes/README.md @@ -54,9 +54,9 @@ ### Related Topics - [[Memoization](../../tag/memoization/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Memoization](../../tag/memoization/README.md)] ### Similar Questions 1. [Strange Printer](../strange-printer) (Hard) diff --git a/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/README.md b/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/README.md new file mode 100644 index 000000000..e862d3493 --- /dev/null +++ b/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/README.md @@ -0,0 +1,100 @@ + + + + + + + +[< Previous](../minimum-number-of-moves-to-seat-everyone "Minimum Number of Moves to Seat Everyone") +                 +[Next >](../the-time-when-the-network-becomes-idle "The Time When the Network Becomes Idle") + +## [2038. Remove Colored Pieces if Both Neighbors are the Same Color (Medium)](https://leetcode.com/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color "如果相邻两个颜色均相同则删除当前颜色") + +

    There are n pieces arranged in a line, and each piece is colored either by 'A' or by 'B'. You are given a string colors of length n where colors[i] is the color of the ith piece.

    + +

    Alice and Bob are playing a game where they take alternating turns removing pieces from the line. In this game, Alice moves first.

    + +
      +
    • Alice is only allowed to remove a piece colored 'A' if both its neighbors are also colored 'A'. She is not allowed to remove pieces that are colored 'B'.
    • +
    • Bob is only allowed to remove a piece colored 'B' if both its neighbors are also colored 'B'. He is not allowed to remove pieces that are colored 'A'.
    • +
    • Alice and Bob cannot remove pieces from the edge of the line.
    • +
    • If a player cannot make a move on their turn, that player loses and the other player wins.
    • +
    + +

    Assuming Alice and Bob play optimally, return true if Alice wins, or return false if Bob wins.

    + +

     

    +

    Example 1:

    + +
    +Input: colors = "AAABABB"
    +Output: true
    +Explanation:
    +AAABABB -> AABABB
    +Alice moves first.
    +She removes the second 'A' from the left since that is the only 'A' whose neighbors are both 'A'.
    +
    +Now it's Bob's turn.
    +Bob cannot make a move on his turn since there are no 'B's whose neighbors are both 'B'.
    +Thus, Alice wins, so return true.
    +
    + +

    Example 2:

    + +
    +Input: colors = "AA"
    +Output: false
    +Explanation:
    +Alice has her turn first.
    +There are only two 'A's and both are on the edge of the line, so she cannot move on her turn.
    +Thus, Bob wins, so return false.
    +
    + +

    Example 3:

    + +
    +Input: colors = "ABBBBBBBAAA"
    +Output: false
    +Explanation:
    +ABBBBBBBAAA -> ABBBBBBBAA
    +Alice moves first.
    +Her only option is to remove the second to last 'A' from the right.
    +
    +ABBBBBBBAA -> ABBBBBBAA
    +Next is Bob's turn.
    +He has many options for which 'B' piece to remove. He can pick any.
    +
    +On Alice's second turn, she has no more pieces that she can remove.
    +Thus, Bob wins, so return false.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= colors.length <= 105
    • +
    • colors consists of only the letters 'A' and 'B'
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] + +### Hints +
    +Hint 1 +Does the number of moves a player can make depend on what the other player does? No +
    + +
    +Hint 2 +How many moves can Alice make if colors == "AAAAAA" +
    + +
    +Hint 3 +If a group of n consecutive pieces has the same color, the player can take n - 2 of those pieces if n is greater than or equal to 3 +
    diff --git a/problems/remove-duplicate-letters/README.md b/problems/remove-duplicate-letters/README.md index d25ddda31..737b1f557 100644 --- a/problems/remove-duplicate-letters/README.md +++ b/problems/remove-duplicate-letters/README.md @@ -40,11 +40,14 @@

    Note: This question is the same as 1081: https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/

    ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[String](../../tag/string/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] +### Similar Questions + 1. [Smallest K-Length Subsequence With Occurrences of a Letter](../smallest-k-length-subsequence-with-occurrences-of-a-letter) (Hard) + ### Hints
    Hint 1 diff --git a/problems/reverse-bits/README.md b/problems/reverse-bits/README.md index 9547d3ebb..82360f7ef 100644 --- a/problems/reverse-bits/README.md +++ b/problems/reverse-bits/README.md @@ -16,14 +16,10 @@

    Note:

      -
    • Note that in some languages such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer's internal binary representation is the same, whether it is signed or unsigned.
    • -
    • In Java, the compiler represents the signed integers using 2's complement notation. Therefore, in Example 2 above, the input represents the signed integer -3 and the output represents the signed integer -1073741825.
    • +
    • Note that in some languages, such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer's internal binary representation is the same, whether it is signed or unsigned.
    • +
    • In Java, the compiler represents the signed integers using 2's complement notation. Therefore, in Example 2 above, the input represents the signed integer -3 and the output represents the signed integer -1073741825.
    -

    Follow up:

    - -

    If this function is called many times, how would you optimize it?

    -

     

    Example 1:

    @@ -48,6 +44,9 @@
  • The input must be a binary string of length 32
  • +

     

    +

    Follow up: If this function is called many times, how would you optimize it?

    + ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] diff --git a/problems/reverse-subarray-to-maximize-array-value/README.md b/problems/reverse-subarray-to-maximize-array-value/README.md index 22437b25e..f01437928 100644 --- a/problems/reverse-subarray-to-maximize-array-value/README.md +++ b/problems/reverse-subarray-to-maximize-array-value/README.md @@ -42,9 +42,9 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/rotate-image/README.md b/problems/rotate-image/README.md index 8f50d1f36..5d95f313f 100644 --- a/problems/rotate-image/README.md +++ b/problems/rotate-image/README.md @@ -58,3 +58,6 @@ [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Matrix](../../tag/matrix/README.md)] + +### Similar Questions + 1. [Determine Whether Matrix Can Be Obtained By Rotation](../determine-whether-matrix-can-be-obtained-by-rotation) (Easy) diff --git a/problems/running-total-for-different-genders/README.md b/problems/running-total-for-different-genders/README.md index 68ee3d821..cff1b7ccf 100644 --- a/problems/running-total-for-different-genders/README.md +++ b/problems/running-total-for-different-genders/README.md @@ -76,3 +76,6 @@ Fifth day is 2020-01-07, Bajrang scored 7 points and the total score for the tea ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Last Person to Fit in the Bus](../last-person-to-fit-in-the-bus) (Medium) diff --git a/problems/second-minimum-time-to-reach-destination/README.md b/problems/second-minimum-time-to-reach-destination/README.md new file mode 100644 index 000000000..6d5868e30 --- /dev/null +++ b/problems/second-minimum-time-to-reach-destination/README.md @@ -0,0 +1,95 @@ + + + + + + + +[< Previous](../count-number-of-maximum-bitwise-or-subsets "Count Number of Maximum Bitwise-OR Subsets") +                 +Next > + +## [2045. Second Minimum Time to Reach Destination (Hard)](https://leetcode.com/problems/second-minimum-time-to-reach-destination "到达目的地的第二短时间") + +

    A city is represented as a bi-directional connected graph with n vertices where each vertex is labeled from 1 to n (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself. The time taken to traverse any edge is time minutes.

    + +

    Each vertex has a traffic signal which changes its color from green to red and vice versa every change minutes. All signals change at the same time. You can enter a vertex at any time, but can leave a vertex only when the signal is green. You cannot wait at a vertex if the signal is green.

    + +

    The second minimum value is defined as the smallest value strictly larger than the minimum value.

    + +
      +
    • For example the second minimum value of [2, 3, 4] is 3, and the second minimum value of [2, 2, 4] is 4.
    • +
    + +

    Given n, edges, time, and change, return the second minimum time it will take to go from vertex 1 to vertex n.

    + +

    Notes:

    + +
      +
    • You can go through any vertex any number of times, including 1 and n.
    • +
    • You can assume that when the journey starts, all signals have just turned green.
    • +
    + +

     

    +

    Example 1:

    +         +
    +Input: n = 5, edges = [[1,2],[1,3],[1,4],[3,4],[4,5]], time = 3, change = 5
    +Output: 13
    +Explanation:
    +The figure on the left shows the given graph.
    +The blue path in the figure on the right is the minimum time path.
    +The time taken is:
    +- Start at 1, time elapsed=0
    +- 1 -> 4: 3 minutes, time elapsed=3
    +- 4 -> 5: 3 minutes, time elapsed=6
    +Hence the minimum time needed is 6 minutes.
    +
    +The red path shows the path to get the second minimum time.
    +- Start at 1, time elapsed=0
    +- 1 -> 3: 3 minutes, time elapsed=3
    +- 3 -> 4: 3 minutes, time elapsed=6
    +- Wait at 4 for 4 minutes, time elapsed=10
    +- 4 -> 5: 3 minutes, time elapsed=13
    +Hence the second minimum time is 13 minutes.      
    +
    + +

    Example 2:

    + +
    +Input: n = 2, edges = [[1,2]], time = 3, change = 2
    +Output: 11
    +Explanation:
    +The minimum time path is 1 -> 2 with time = 3 minutes.
    +The second minimum time path is 1 -> 2 -> 1 -> 2 with time = 11 minutes.
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 104
    • +
    • n - 1 <= edges.length <= min(2 * 104, n * (n - 1) / 2)
    • +
    • edges[i].length == 2
    • +
    • 1 <= ui, vi <= n
    • +
    • ui != vi
    • +
    • There are no duplicate edges.
    • +
    • Each vertex can be reached directly or indirectly from every other vertex.
    • +
    • 1 <= time, change <= 103
    • +
    + +### Related Topics + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] + +### Hints +
    +Hint 1 +How much is change actually necessary while calculating the required path? +
    + +
    +Hint 2 +How many extra edges do we need to add to the shortest path? +
    diff --git a/problems/shopping-offers/README.md b/problems/shopping-offers/README.md index 4eb605968..86071e671 100644 --- a/problems/shopping-offers/README.md +++ b/problems/shopping-offers/README.md @@ -57,9 +57,9 @@ You cannot add more items, though only $9 for 2A ,2B and 1C. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] - [[Memoization](../../tag/memoization/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Memoization](../../tag/memoization/README.md)] [[Bitmask](../../tag/bitmask/README.md)] diff --git a/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md b/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md index fbd8b3633..ece449fda 100644 --- a/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md +++ b/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md @@ -17,34 +17,21 @@

     

    Example 1:

    - +
    -Input: 
    -grid = 
    -[[0,0,0],
    - [1,1,0],
    - [0,0,0],
    - [0,1,1],
    - [0,0,0]], 
    -k = 1
    +Input: grid = [[0,0,0],[1,1,0],[0,0,0],[0,1,1],[0,0,0]], k = 1
     Output: 6
    -Explanation: 
    -The shortest path without eliminating any obstacle is 10. 
    -The shortest path with one obstacle elimination at position (3,2) is 6. Such path is (0,0) -> (0,1) -> (0,2) -> (1,2) -> (2,2) -> (3,2) -> (4,2).
    +Explanation: 
    +The shortest path without eliminating any obstacle is 10.
    +The shortest path with one obstacle elimination at position (3,2) is 6. Such path is (0,0) -> (0,1) -> (0,2) -> (1,2) -> (2,2) -> (3,2) -> (4,2).
     

    Example 2:

    - +
    -Input: 
    -grid = 
    -[[0,1,1],
    - [1,1,1],
    - [1,0,0]], 
    -k = 1
    +Input: grid = [[0,1,1],[1,1,1],[1,0,0]], k = 1
     Output: -1
    -Explanation: 
    -We need to eliminate at least two obstacles to find such a walk.
    +Explanation: We need to eliminate at least two obstacles to find such a walk.
     

     

    @@ -55,7 +42,7 @@ k = 1
  • n == grid[i].length
  • 1 <= m, n <= 40
  • 1 <= k <= m * n
  • -
  • grid[i][j] == 0 or 1
  • +
  • grid[i][j] is either 0 or 1.
  • grid[0][0] == grid[m - 1][n - 1] == 0
  • diff --git a/problems/simple-bank-system/README.md b/problems/simple-bank-system/README.md new file mode 100644 index 000000000..3d7d692e0 --- /dev/null +++ b/problems/simple-bank-system/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../check-if-numbers-are-ascending-in-a-sentence "Check if Numbers Are Ascending in a Sentence") +                 +[Next >](../count-number-of-maximum-bitwise-or-subsets "Count Number of Maximum Bitwise-OR Subsets") + +## [2043. Simple Bank System (Medium)](https://leetcode.com/problems/simple-bank-system "简易银行系统") + +

    You have been tasked with writing a program for a popular bank that will automate all its incoming transactions (transfer, deposit, and withdraw). The bank has n accounts numbered from 1 to n. The initial balance of each account is stored in a 0-indexed integer array balance, with the (i + 1)th account having an initial balance of balance[i].

    + +

    Execute all the valid transactions. A transaction is valid if:

    + +
      +
    • The given account number(s) are between 1 and n, and
    • +
    • The amount of money withdrawn or transferred from is less than or equal to the balance of the account.
    • +
    + +

    Implement the Bank class:

    + +
      +
    • Bank(long[] balance) Initializes the object with the 0-indexed integer array balance.
    • +
    • boolean transfer(int account1, int account2, long money) Transfers money dollars from the account numbered account1 to the account numbered account2. Return true if the transaction was successful, false otherwise.
    • +
    • boolean deposit(int account, long money) Deposit money dollars into the account numbered account. Return true if the transaction was successful, false otherwise.
    • +
    • boolean withdraw(int account, long money) Withdraw money dollars from the account numbered account. Return true if the transaction was successful, false otherwise.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input
    +["Bank", "withdraw", "transfer", "deposit", "transfer", "withdraw"]
    +[[[10, 100, 20, 50, 30]], [3, 10], [5, 1, 20], [5, 20], [3, 4, 15], [10, 50]]
    +Output
    +[null, true, true, true, false, false]
    +
    +Explanation
    +Bank bank = new Bank([10, 100, 20, 50, 30]);
    +bank.withdraw(3, 10);    // return true, account 3 has a balance of $20, so it is valid to withdraw $10.
    +                         // Account 3 has $20 - $10 = $10.
    +bank.transfer(5, 1, 20); // return true, account 5 has a balance of $30, so it is valid to transfer $20.
    +                         // Account 5 has $30 - $20 = $10, and account 1 has $10 + $20 = $30.
    +bank.deposit(5, 20);     // return true, it is valid to deposit $20 to account 5.
    +                         // Account 5 has $10 + $20 = $30.
    +bank.transfer(3, 4, 15); // return false, the current balance of account 3 is $10,
    +                         // so it is invalid to transfer $15 from it.
    +bank.withdraw(10, 50);   // return false, it is invalid because account 10 does not exist.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == balance.length
    • +
    • 1 <= n, account, account1, account2 <= 105
    • +
    • 0 <= balance[i], money <= 1012
    • +
    • At most 104 calls will be made to each function transfer, deposit, withdraw.
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +How do you determine if a transaction will fail? +
    + +
    +Hint 2 +Simply apply the operations if the transaction is valid. +
    diff --git a/problems/simplify-path/README.md b/problems/simplify-path/README.md index dee67b0ef..842c7792e 100644 --- a/problems/simplify-path/README.md +++ b/problems/simplify-path/README.md @@ -68,5 +68,5 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[String](../../tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] diff --git a/problems/single-number-ii/README.md b/problems/single-number-ii/README.md index fa41c7517..92cfb1b12 100644 --- a/problems/single-number-ii/README.md +++ b/problems/single-number-ii/README.md @@ -33,8 +33,8 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Single Number](../single-number) (Easy) diff --git a/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter/README.md b/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter/README.md new file mode 100644 index 000000000..78a814d9c --- /dev/null +++ b/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](../stone-game-ix "Stone Game IX") +                 +[Next >](../count-subarrays-with-more-ones-than-zeros "Count Subarrays With More Ones Than Zeros") + +## [2030. Smallest K-Length Subsequence With Occurrences of a Letter (Hard)](https://leetcode.com/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter "含特定字母的最小子序列") + +

    You are given a string s, an integer k, a letter letter, and an integer repetition.

    + +

    Return the lexicographically smallest subsequence of s of length k that has the letter letter appear at least repetition times. The test cases are generated so that the letter appears in s at least repetition times.

    + +

    A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.

    + +

    A string a is lexicographically smaller than a string b if in the first position where a and b differ, string a has a letter that appears earlier in the alphabet than the corresponding letter in b.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "leet", k = 3, letter = "e", repetition = 1
    +Output: "eet"
    +Explanation: There are four subsequences of length 3 that have the letter 'e' appear at least 1 time:
    +- "lee" (from "leet")
    +- "let" (from "leet")
    +- "let" (from "leet")
    +- "eet" (from "leet")
    +The lexicographically smallest subsequence among them is "eet".
    +
    + +

    Example 2:

    +example-2 +
    +Input: s = "leetcode", k = 4, letter = "e", repetition = 2
    +Output: "ecde"
    +Explanation: "ecde" is the lexicographically smallest subsequence of length 4 that has the letter "e" appear at least 2 times.
    +
    + +

    Example 3:

    + +
    +Input: s = "bb", k = 2, letter = "b", repetition = 2
    +Output: "bb"
    +Explanation: "bb" is the only subsequence of length 2 that has the letter "b" appear at least 2 times.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= repetition <= k <= s.length <= 5 * 104
    • +
    • s consists of lowercase English letters.
    • +
    • letter is a lowercase English letter, and appears in s at least repetition times.
    • +
    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] + +### Hints +
    +Hint 1 +Use stack. For every character to be appended, decide how many character(s) from the stack needs to get popped based on the stack length and the count of the required character. +
    + +
    +Hint 2 +Pop the extra characters out from the stack and return the characters in the stack (reversed). +
    diff --git a/problems/sort-integers-by-the-power-value/README.md b/problems/sort-integers-by-the-power-value/README.md index 5e0e1b88f..80eefa8c1 100644 --- a/problems/sort-integers-by-the-power-value/README.md +++ b/problems/sort-integers-by-the-power-value/README.md @@ -80,8 +80,8 @@ The fourth number in the sorted array is 7. ### Related Topics - [[Memoization](../../tag/memoization/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Memoization](../../tag/memoization/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/split-concatenated-strings/README.md b/problems/split-concatenated-strings/README.md index 036dfb480..ebca547de 100644 --- a/problems/split-concatenated-strings/README.md +++ b/problems/split-concatenated-strings/README.md @@ -39,6 +39,6 @@

    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/stock-price-fluctuation/README.md b/problems/stock-price-fluctuation/README.md new file mode 100644 index 000000000..49dacf30f --- /dev/null +++ b/problems/stock-price-fluctuation/README.md @@ -0,0 +1,84 @@ + + + + + + + +[< Previous](../minimum-operations-to-make-a-uni-value-grid "Minimum Operations to Make a Uni-Value Grid") +                 +[Next >](../partition-array-into-two-arrays-to-minimize-sum-difference "Partition Array Into Two Arrays to Minimize Sum Difference") + +## [2034. Stock Price Fluctuation (Medium)](https://leetcode.com/problems/stock-price-fluctuation "股票价格波动") + +

    You are given a stream of records about a particular stock. Each record contains a timestamp and the corresponding price of the stock at that timestamp.

    + +

    Unfortunately due to the volatile nature of the stock market, the records do not come in order. Even worse, some records may be incorrect. Another record with the same timestamp may appear later in the stream correcting the price of the previous wrong record.

    + +

    Design an algorithm that:

    + +
      +
    • Updates the price of the stock at a particular timestamp, correcting the price from any previous records at the timestamp.
    • +
    • Finds the latest price of the stock based on the current records. The latest price is the price at the latest timestamp recorded.
    • +
    • Finds the maximum price the stock has been based on the current records.
    • +
    • Finds the minimum price the stock has been based on the current records.
    • +
    + +

    Implement the StockPrice class:

    + +
      +
    • StockPrice() Initializes the object with no price records.
    • +
    • void update(int timestamp, int price) Updates the price of the stock at the given timestamp.
    • +
    • int current() Returns the latest price of the stock.
    • +
    • int maximum() Returns the maximum price of the stock.
    • +
    • int minimum() Returns the minimum price of the stock.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input
    +["StockPrice", "update", "update", "current", "maximum", "update", "maximum", "update", "minimum"]
    +[[], [1, 10], [2, 5], [], [], [1, 3], [], [4, 2], []]
    +Output
    +[null, null, null, 5, 10, null, 5, null, 2]
    +
    +Explanation
    +StockPrice stockPrice = new StockPrice();
    +stockPrice.update(1, 10); // Timestamps are [1] with corresponding prices [10].
    +stockPrice.update(2, 5);  // Timestamps are [1,2] with corresponding prices [10,5].
    +stockPrice.current();     // return 5, the latest timestamp is 2 with the price being 5.
    +stockPrice.maximum();     // return 10, the maximum price is 10 at timestamp 1.
    +stockPrice.update(1, 3);  // The previous timestamp 1 had the wrong price, so it is updated to 3.
    +                          // Timestamps are [1,2] with corresponding prices [3,5].
    +stockPrice.maximum();     // return 5, the maximum price is 5 after the correction.
    +stockPrice.update(4, 2);  // Timestamps are [1,2,4] with corresponding prices [3,5,2].
    +stockPrice.minimum();     // return 2, the minimum price is 2 at timestamp 4.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= timestamp, price <= 109
    • +
    • At most 105 calls will be made in total to update, current, maximum, and minimum.
    • +
    • current, maximum, and minimum will be called only after update has been called at least once.
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +How would you solve the problem for offline queries (all queries given at once)? +
    + +
    +Hint 2 +Think about which data structure can help insert and delete the most optimal way. +
    diff --git a/problems/stone-game-iv/README.md b/problems/stone-game-iv/README.md index c55f7cdca..5a2578d26 100644 --- a/problems/stone-game-iv/README.md +++ b/problems/stone-game-iv/README.md @@ -76,6 +76,7 @@ If Alice starts removing 1 stone, Bob will remove 4 stones then Alice only can r 1. [Stone Game VI](../stone-game-vi) (Medium) 1. [Stone Game VII](../stone-game-vii) (Medium) 1. [Stone Game VIII](../stone-game-viii) (Hard) + 1. [Stone Game IX](../stone-game-ix) (Medium) ### Hints
    diff --git a/problems/stone-game-ix/README.md b/problems/stone-game-ix/README.md new file mode 100644 index 000000000..543ba198a --- /dev/null +++ b/problems/stone-game-ix/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../find-missing-observations "Find Missing Observations") +                 +[Next >](../smallest-k-length-subsequence-with-occurrences-of-a-letter "Smallest K-Length Subsequence With Occurrences of a Letter") + +## [2029. Stone Game IX (Medium)](https://leetcode.com/problems/stone-game-ix "石子游戏 IX") + +

    Alice and Bob continue their games with stones. There is a row of n stones, and each stone has an associated value. You are given an integer array stones, where stones[i] is the value of the ith stone.

    + +

    Alice and Bob take turns, with Alice starting first. On each turn, the player may remove any stone from stones. The player who removes a stone loses if the sum of the values of all removed stones is divisible by 3. Bob will win automatically if there are no remaining stones (even if it is Alice's turn).

    + +

    Assuming both players play optimally, return true if Alice wins and false if Bob wins.

    + +

     

    +

    Example 1:

    + +
    +Input: stones = [2,1]
    +Output: true
    +Explanation: The game will be played as follows:
    +- Turn 1: Alice can remove either stone.
    +- Turn 2: Bob removes the remaining stone. 
    +The sum of the removed stones is 1 + 2 = 3 and is divisible by 3. Therefore, Bob loses and Alice wins the game.
    +
    + +

    Example 2:

    + +
    +Input: stones = [2]
    +Output: false
    +Explanation: Alice will remove the only stone, and the sum of the values on the removed stones is 2. 
    +Since all the stones are removed and the sum of values is not divisible by 3, Bob wins the game.
    +
    + +

    Example 3:

    + +
    +Input: stones = [5,1,2,4,3]
    +Output: false
    +Explanation: Bob will always win. One possible way for Bob to win is shown below:
    +- Turn 1: Alice can remove the second stone with value 1. Sum of removed stones = 1.
    +- Turn 2: Bob removes the fifth stone with value 3. Sum of removed stones = 1 + 3 = 4.
    +- Turn 3: Alices removes the fourth stone with value 4. Sum of removed stones = 1 + 3 + 4 = 8.
    +- Turn 4: Bob removes the third stone with value 2. Sum of removed stones = 1 + 3 + 4 + 2 = 10.
    +- Turn 5: Alice removes the first stone with value 5. Sum of removed stones = 1 + 3 + 4 + 2 + 5 = 15.
    +Alice loses the game because the sum of the removed stones (15) is divisible by 3. Bob wins the game.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= stones.length <= 105
    • +
    • 1 <= stones[i] <= 104
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] + +### Hints +
    +Hint 1 +There are limited outcomes given the current sum and the stones remaining. +
    + +
    +Hint 2 +Can we greedily simulate starting with taking a stone with remainder 1 or 2 divided by 3? +
    diff --git a/problems/stone-game-v/README.md b/problems/stone-game-v/README.md index 0b872a65f..018a99134 100644 --- a/problems/stone-game-v/README.md +++ b/problems/stone-game-v/README.md @@ -58,15 +58,6 @@ The last round Alice has only one choice to divide the row which is [2], [3]. Bo [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Game Theory](../../tag/game-theory/README.md)] -### Similar Questions - 1. [Stone Game](../stone-game) (Medium) - 1. [Stone Game II](../stone-game-ii) (Medium) - 1. [Stone Game III](../stone-game-iii) (Hard) - 1. [Stone Game IV](../stone-game-iv) (Hard) - 1. [Stone Game VI](../stone-game-vi) (Medium) - 1. [Stone Game VII](../stone-game-vii) (Medium) - 1. [Stone Game VIII](../stone-game-viii) (Hard) - ### Hints
    Hint 1 diff --git a/problems/stone-game-vii/README.md b/problems/stone-game-vii/README.md index c2614f1d6..49528c39a 100644 --- a/problems/stone-game-vii/README.md +++ b/problems/stone-game-vii/README.md @@ -55,6 +55,17 @@ The score difference is 18 - 12 = 6. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Game Theory](../../tag/game-theory/README.md)] +### Similar Questions + 1. [Stone Game](../stone-game) (Medium) + 1. [Stone Game II](../stone-game-ii) (Medium) + 1. [Stone Game III](../stone-game-iii) (Hard) + 1. [Stone Game IV](../stone-game-iv) (Hard) + 1. [Stone Game V](../stone-game-v) (Hard) + 1. [Stone Game VI](../stone-game-vi) (Medium) + 1. [Maximum Score from Performing Multiplication Operations](../maximum-score-from-performing-multiplication-operations) (Medium) + 1. [Stone Game VIII](../stone-game-viii) (Hard) + 1. [Stone Game IX](../stone-game-ix) (Medium) + ### Hints
    Hint 1 diff --git a/problems/subarray-sum-equals-k/README.md b/problems/subarray-sum-equals-k/README.md index 9ef04912b..c2756c8bc 100644 --- a/problems/subarray-sum-equals-k/README.md +++ b/problems/subarray-sum-equals-k/README.md @@ -41,6 +41,7 @@ 1. [Subarray Product Less Than K](../subarray-product-less-than-k) (Medium) 1. [Find Pivot Index](../find-pivot-index) (Easy) 1. [Subarray Sums Divisible by K](../subarray-sums-divisible-by-k) (Medium) + 1. [Minimum Operations to Reduce X to Zero](../minimum-operations-to-reduce-x-to-zero) (Medium) ### Hints
    diff --git a/problems/subtree-removal-game-with-fibonacci-tree/README.md b/problems/subtree-removal-game-with-fibonacci-tree/README.md new file mode 100644 index 000000000..bb7bf2a9e --- /dev/null +++ b/problems/subtree-removal-game-with-fibonacci-tree/README.md @@ -0,0 +1,30 @@ + + + + + + + +[< Previous](../the-number-of-seniors-and-juniors-to-join-the-company "The Number of Seniors and Juniors to Join the Company") +                 +[Next >](../count-number-of-pairs-with-absolute-difference-k "Count Number of Pairs With Absolute Difference K") + +## [2005. Subtree Removal Game with Fibonacci Tree (Hard)](https://leetcode.com/problems/subtree-removal-game-with-fibonacci-tree "") + + + +### Hints +
    +Hint 1 +How can game theory help us solve this problem? +
    + +
    +Hint 2 +Think about the Sprague–Grundy theorem and the Colon Principle +
    + +
    +Hint 3 +The Grundy value of a node is the nim sum of the Grundy values of its children. +
    diff --git a/problems/sum-of-beauty-in-the-array/README.md b/problems/sum-of-beauty-in-the-array/README.md new file mode 100644 index 000000000..09e6a56b5 --- /dev/null +++ b/problems/sum-of-beauty-in-the-array/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../final-value-of-variable-after-performing-operations "Final Value of Variable After Performing Operations") +                 +[Next >](../detect-squares "Detect Squares") + +## [2012. Sum of Beauty in the Array (Medium)](https://leetcode.com/problems/sum-of-beauty-in-the-array "数组美丽值求和") + +

    You are given a 0-indexed integer array nums. For each index i (1 <= i <= nums.length - 2) the beauty of nums[i] equals:

    + +
      +
    • 2, if nums[j] < nums[i] < nums[k], for all 0 <= j < i and for all i < k <= nums.length - 1.
    • +
    • 1, if nums[i - 1] < nums[i] < nums[i + 1], and the previous condition is not satisfied.
    • +
    • 0, if none of the previous conditions holds.
    • +
    + +

    Return the sum of beauty of all nums[i] where 1 <= i <= nums.length - 2.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3]
    +Output: 2
    +Explanation: For each index i in the range 1 <= i <= 1:
    +- The beauty of nums[1] equals 2.
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,4,6,4]
    +Output: 1
    +Explanation: For each index i in the range 1 <= i <= 2:
    +- The beauty of nums[1] equals 1.
    +- The beauty of nums[2] equals 0.
    +
    + +

    Example 3:

    + +
    +Input: nums = [3,2,1]
    +Output: 0
    +Explanation: For each index i in the range 1 <= i <= 1:
    +- The beauty of nums[1] equals 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Use suffix/prefix arrays. +
    + +
    +Hint 2 +prefix[i] records the maximum value in range (0, i - 1) inclusive. +
    + +
    +Hint 3 +suffix[i] records the minimum value in range (i + 1, n - 1) inclusive. +
    diff --git a/problems/swap-for-longest-repeated-character-substring/README.md b/problems/swap-for-longest-repeated-character-substring/README.md index 4eb980009..0d76e2af0 100644 --- a/problems/swap-for-longest-repeated-character-substring/README.md +++ b/problems/swap-for-longest-repeated-character-substring/README.md @@ -11,7 +11,9 @@ ## [1156. Swap For Longest Repeated Character Substring (Medium)](https://leetcode.com/problems/swap-for-longest-repeated-character-substring "单字符重复子串的最大长度") -

    Given a string text, we are allowed to swap two of the characters in the string. Find the length of the longest substring with repeated characters.

    +

    You are given a string text. You can swap two of the characters in the text.

    + +

    Return the length of the longest substring with repeated characters.

     

    Example 1:

    @@ -56,7 +58,7 @@

    Constraints:

      -
    • 1 <= text.length <= 20000
    • +
    • 1 <= text.length <= 2 * 104
    • text consist of lowercase English characters only.
    diff --git a/problems/swim-in-rising-water/README.md b/problems/swim-in-rising-water/README.md index 549f5e0da..8022b876b 100644 --- a/problems/swim-in-rising-water/README.md +++ b/problems/swim-in-rising-water/README.md @@ -51,13 +51,16 @@ We need to wait until time 16 so that (0, 0) and (4, 4) are connected. ### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] - [[Matrix](../../tag/matrix/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Similar Questions + 1. [Path With Minimum Effort](../path-with-minimum-effort) (Medium) ### Hints
    diff --git a/problems/the-maze-ii/README.md b/problems/the-maze-ii/README.md index d3fabd523..12ba31289 100644 --- a/problems/the-maze-ii/README.md +++ b/problems/the-maze-ii/README.md @@ -73,8 +73,8 @@ [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] - [[Shortest Path](../../tag/shortest-path/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] ### Similar Questions 1. [The Maze](../the-maze) (Medium) diff --git a/problems/the-maze-iii/README.md b/problems/the-maze-iii/README.md index 70b739207..859b10015 100644 --- a/problems/the-maze-iii/README.md +++ b/problems/the-maze-iii/README.md @@ -77,8 +77,8 @@ Both ways have shortest distance 6, but the first way is lexicographically small [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] [[Shortest Path](../../tag/shortest-path/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [The Maze](../the-maze) (Medium) diff --git a/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii/README.md b/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii/README.md new file mode 100644 index 000000000..59dee44be --- /dev/null +++ b/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../minimum-number-of-operations-to-make-array-continuous "Minimum Number of Operations to Make Array Continuous") +                 +[Next >](../final-value-of-variable-after-performing-operations "Final Value of Variable After Performing Operations") + +## [2010. The Number of Seniors and Juniors to Join the Company II (Hard)](https://leetcode.com/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii "") + + diff --git a/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii/mysql_schemas.sql b/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii/mysql_schemas.sql new file mode 100644 index 000000000..998e0268a --- /dev/null +++ b/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii/mysql_schemas.sql @@ -0,0 +1,8 @@ +Create table If Not Exists Candidates (employee_id int, experience ENUM('Senior', 'Junior'), salary int); +Truncate table Candidates; +insert into Candidates (employee_id, experience, salary) values ('1', 'Junior', '10000'); +insert into Candidates (employee_id, experience, salary) values ('9', 'Junior', '15000'); +insert into Candidates (employee_id, experience, salary) values ('2', 'Senior', '20000'); +insert into Candidates (employee_id, experience, salary) values ('11', 'Senior', '16000'); +insert into Candidates (employee_id, experience, salary) values ('13', 'Senior', '50000'); +insert into Candidates (employee_id, experience, salary) values ('4', 'Junior', '40000'); diff --git a/problems/the-number-of-seniors-and-juniors-to-join-the-company/README.md b/problems/the-number-of-seniors-and-juniors-to-join-the-company/README.md index 00a26cd8d..5d2216554 100644 --- a/problems/the-number-of-seniors-and-juniors-to-join-the-company/README.md +++ b/problems/the-number-of-seniors-and-juniors-to-join-the-company/README.md @@ -7,7 +7,7 @@ [< Previous](../smallest-missing-genetic-value-in-each-subtree "Smallest Missing Genetic Value in Each Subtree")                  -Next > +[Next >](../subtree-removal-game-with-fibonacci-tree "Subtree Removal Game with Fibonacci Tree") ## [2004. The Number of Seniors and Juniors to Join the Company (Hard)](https://leetcode.com/problems/the-number-of-seniors-and-juniors-to-join-the-company "") diff --git a/problems/the-score-of-students-solving-math-expression/README.md b/problems/the-score-of-students-solving-math-expression/README.md new file mode 100644 index 000000000..f2e092b53 --- /dev/null +++ b/problems/the-score-of-students-solving-math-expression/README.md @@ -0,0 +1,112 @@ + + + + + + + +[< Previous](../check-if-word-can-be-placed-in-crossword "Check if Word Can Be Placed In Crossword") +                 +[Next >](../number-of-accounts-that-did-not-stream "Number of Accounts That Did Not Stream") + +## [2019. The Score of Students Solving Math Expression (Hard)](https://leetcode.com/problems/the-score-of-students-solving-math-expression "解出数学表达式的学生分数") + +

    You are given a string s that contains digits 0-9, addition symbols '+', and multiplication symbols '*' only, representing a valid math expression of single digit numbers (e.g., 3+5*2). This expression was given to n elementary school students. The students were instructed to get the answer of the expression by following this order of operations:

    + +
      +
    1. Compute multiplication, reading from left to right; Then,
    2. +
    3. Compute addition, reading from left to right.
    4. +
    + +

    You are given an integer array answers of length n, which are the submitted answers of the students in no particular order. You are asked to grade the answers, by following these rules:

    + +
      +
    • If an answer equals the correct answer of the expression, this student will be rewarded 5 points;
    • +
    • Otherwise, if the answer could be interpreted as if the student applied the operators in the wrong order but had correct arithmetic, this student will be rewarded 2 points;
    • +
    • Otherwise, this student will be rewarded 0 points.
    • +
    + +

    Return the sum of the points of the students.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "7+3*1*2", answers = [20,13,42]
    +Output: 7
    +Explanation: As illustrated above, the correct answer of the expression is 13, therefore one student is rewarded 5 points: [20,13,42]
    +A student might have applied the operators in this wrong order: ((7+3)*1)*2 = 20. Therefore one student is rewarded 2 points: [20,13,42]
    +The points for the students are: [2,5,0]. The sum of the points is 2+5+0=7.
    +
    + +

    Example 2:

    + +
    +Input: s = "3+5*2", answers = [13,0,10,13,13,16,16]
    +Output: 19
    +Explanation: The correct answer of the expression is 13, therefore three students are rewarded 5 points each: [13,0,10,13,13,16,16]
    +A student might have applied the operators in this wrong order: ((3+5)*2 = 16. Therefore two students are rewarded 2 points: [13,0,10,13,13,16,16]
    +The points for the students are: [5,0,0,5,5,2,2]. The sum of the points is 5+0+0+5+5+2+2=19.
    +
    + +

    Example 3:

    + +
    +Input: s = "6+0*1", answers = [12,9,6,4,8,6]
    +Output: 10
    +Explanation: The correct answer of the expression is 6.
    +If a student had incorrectly done (6+0)*1, the answer would also be 6.
    +By the rules of grading, the students will still be rewarded 5 points (as they got the correct answer), not 2 points.
    +The points for the students are: [0,0,5,0,0,5]. The sum of the points is 10.
    +
    + +

    Example 4:

    + +
    +Input: s = "1+2*3+4", answers = [13,21,11,15]
    +Output: 11
    +Explanation: The correct answer of the expression is 11.
    +Every other student was rewarded 2 points because they could have applied the operators as follows:
    +- ((1+2)*3)+4 = 13
    +- (1+2)*(3+4) = 21
    +- 1+(2*(3+4)) = 15
    +The points for the students are: [2,2,5,2]. The sum of the points is 11.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= s.length <= 31
    • +
    • s represents a valid expression that contains only digits 0-9, '+', and '*' only.
    • +
    • All the integer operands in the expression are in the inclusive range [0, 9].
    • +
    • 1 <= The count of all operators ('+' and '*') in the math expression <= 15
    • +
    • Test data are generated such that the correct answer of the expression is in the range of [0, 1000].
    • +
    • n == answers.length
    • +
    • 1 <= n <= 104
    • +
    • 0 <= answers[i] <= 1000
    • +
    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Memoization](../../tag/memoization/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +The number of operators in the equation is less. Could you find the right answer then generate all possible answers using different orders of operations? +
    + +
    +Hint 2 +Divide the equation into blocks separated by the operators, and use memoization on the results of blocks for optimization. +
    + +
    +Hint 3 +Use set and the max limit of the answer for further optimization. +
    diff --git a/problems/the-skyline-problem/README.md b/problems/the-skyline-problem/README.md index 80dc279c6..769f51184 100644 --- a/problems/the-skyline-problem/README.md +++ b/problems/the-skyline-problem/README.md @@ -56,13 +56,13 @@ Figure B shows the skyline formed by those buildings. The red points in figure B ### Related Topics - [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] - [[Segment Tree](../../tag/segment-tree/README.md)] [[Array](../../tag/array/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] [[Line Sweep](../../tag/line-sweep/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions 1. [Falling Squares](../falling-squares) (Hard) diff --git a/problems/the-time-when-the-network-becomes-idle/README.md b/problems/the-time-when-the-network-becomes-idle/README.md new file mode 100644 index 000000000..5c13d9e49 --- /dev/null +++ b/problems/the-time-when-the-network-becomes-idle/README.md @@ -0,0 +1,105 @@ + + + + + + + +[< Previous](../remove-colored-pieces-if-both-neighbors-are-the-same-color "Remove Colored Pieces if Both Neighbors are the Same Color") +                 +[Next >](../kth-smallest-product-of-two-sorted-arrays "Kth Smallest Product of Two Sorted Arrays") + +## [2039. The Time When the Network Becomes Idle (Medium)](https://leetcode.com/problems/the-time-when-the-network-becomes-idle "网络空闲的时刻") + +

    There is a network of n servers, labeled from 0 to n - 1. You are given a 2D integer array edges, where edges[i] = [ui, vi] indicates there is a message channel between servers ui and vi, and they can pass any number of messages to each other directly in one second. You are also given a 0-indexed integer array patience of length n.

    + +

    All servers are connected, i.e., a message can be passed from one server to any other server(s) directly or indirectly through the message channels.

    + +

    The server labeled 0 is the master server. The rest are data servers. Each data server needs to send its message to the master server for processing and wait for a reply. Messages move between servers optimally, so every message takes the least amount of time to arrive at the master server. The master server will process all newly arrived messages instantly and send a reply to the originating server via the reversed path the message had gone through.

    + +

    At the beginning of second 0, each data server sends its message to be processed. Starting from second 1, at the beginning of every second, each data server will check if it has received a reply to the message it sent (including any newly arrived replies) from the master server:

    + +
      +
    • If it has not, it will resend the message periodically. The data server i will resend the message every patience[i] second(s), i.e., the data server i will resend the message if patience[i] second(s) have elapsed since the last time the message was sent from this server.
    • +
    • Otherwise, no more resending will occur from this server.
    • +
    + +

    The network becomes idle when there are no messages passing between servers or arriving at servers.

    + +

    Return the earliest second starting from which the network becomes idle.

    + +

     

    +

    Example 1:

    +example 1 +
    +Input: edges = [[0,1],[1,2]], patience = [0,2,1]
    +Output: 8
    +Explanation:
    +At (the beginning of) second 0,
    +- Data server 1 sends its message (denoted 1A) to the master server.
    +- Data server 2 sends its message (denoted 2A) to the master server.
    +
    +At second 1,
    +- Message 1A arrives at the master server. Master server processes message 1A instantly and sends a reply 1A back.
    +- Server 1 has not received any reply. 1 second (1 < patience[1] = 2) elapsed since this server has sent the message, therefore it does not resend the message.
    +- Server 2 has not received any reply. 1 second (1 == patience[2] = 1) elapsed since this server has sent the message, therefore it resends the message (denoted 2B).
    +
    +At second 2,
    +- The reply 1A arrives at server 1. No more resending will occur from server 1.
    +- Message 2A arrives at the master server. Master server processes message 2A instantly and sends a reply 2A back.
    +- Server 2 resends the message (denoted 2C).
    +...
    +At second 4,
    +- The reply 2A arrives at server 2. No more resending will occur from server 2.
    +...
    +At second 7, reply 2D arrives at server 2.
    +
    +Starting from the beginning of the second 8, there are no messages passing between servers or arriving at servers.
    +This is the time when the network becomes idle.
    +
    + +

    Example 2:

    +example 2 +
    +Input: edges = [[0,1],[0,2],[1,2]], patience = [0,10,10]
    +Output: 3
    +Explanation: Data servers 1 and 2 receive a reply back at the beginning of second 2.
    +From the beginning of the second 3, the network becomes idle.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == patience.length
    • +
    • 2 <= n <= 105
    • +
    • patience[0] == 0
    • +
    • 1 <= patience[i] <= 105 for 1 <= i < n
    • +
    • 1 <= edges.length <= min(105, n * (n - 1) / 2)
    • +
    • edges[i].length == 2
    • +
    • 0 <= ui, vi < n
    • +
    • ui != vi
    • +
    • There are no duplicate edges.
    • +
    • Each server can directly or indirectly reach another server.
    • +
    + +### Related Topics + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +What method can you use to find the shortest time taken for a message from a data server to reach the master server? How can you use this value and the server's patience value to determine the time at which the server sends its last message? +
    + +
    +Hint 2 +What is the time when the last message sent from a server gets back to the server? +
    + +
    +Hint 3 +For each data server, by the time the server receives the first returned messages, how many messages has the server sent? +
    diff --git a/problems/throne-inheritance/README.md b/problems/throne-inheritance/README.md index 781baf8df..ac0c68e26 100644 --- a/problems/throne-inheritance/README.md +++ b/problems/throne-inheritance/README.md @@ -81,13 +81,10 @@ t.getInheritanceOrder(); // return ["king", "andy", "ma ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Design](../../tag/design/README.md)] - -### Similar Questions - 1. [Operations on Tree](../operations-on-tree) (Medium) + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/trapping-rain-water-ii/README.md b/problems/trapping-rain-water-ii/README.md index a3c0155fd..4455c7d46 100644 --- a/problems/trapping-rain-water-ii/README.md +++ b/problems/trapping-rain-water-ii/README.md @@ -42,10 +42,10 @@ The total volume of water trapped is 4. ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] - [[Matrix](../../tag/matrix/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Trapping Rain Water](../trapping-rain-water) (Hard) diff --git a/problems/trips-and-users/README.md b/problems/trips-and-users/README.md index 51d276090..8d32e593e 100644 --- a/problems/trips-and-users/README.md +++ b/problems/trips-and-users/README.md @@ -54,11 +54,13 @@ Status is an ENUM type of (‘Yes’, ‘No’).

    Return the result table in any order. Round Cancellation Rate to two decimal points.

    -

    The query result format is in the following example:

    +

    The query result format is in the following example.

     

    +

    Example 1:

    +Input: 
     Trips table:
     +----+-----------+-----------+---------+---------------------+------------+
     | Id | Client_Id | Driver_Id | City_Id | Status              | Request_at |
    @@ -74,7 +76,6 @@ Trips table:
     | 9  | 3         | 10        | 12      | completed           | 2013-10-03 |
     | 10 | 4         | 13        | 12      | cancelled_by_driver | 2013-10-03 |
     +----+-----------+-----------+---------+---------------------+------------+
    -
     Users table:
     +----------+--------+--------+
     | Users_Id | Banned | Role   |
    @@ -88,8 +89,7 @@ Users table:
     | 12       | No     | driver |
     | 13       | No     | driver |
     +----------+--------+--------+
    -
    -Result table:
    +Output: 
     +------------+-------------------+
     | Day        | Cancellation Rate |
     +------------+-------------------+
    @@ -97,7 +97,7 @@ Result table:
     | 2013-10-02 | 0.00              |
     | 2013-10-03 | 0.50              |
     +------------+-------------------+
    -
    +Explanation: 
     On 2013-10-01:
       - There were 4 requests in total, 2 of which were canceled.
       - However, the request with Id=2 was made by a banned client (User_Id=2), so it is ignored in the calculation.
    @@ -117,3 +117,8 @@ On 2013-10-03:
     
     ### Related Topics
       [[Database](../../tag/database/README.md)]
    +
    +### Similar Questions
    +  1. [Hopper Company Queries I](../hopper-company-queries-i) (Hard)
    +  1. [Hopper Company Queries II](../hopper-company-queries-ii) (Hard)
    +  1. [Hopper Company Queries III](../hopper-company-queries-iii) (Hard)
    diff --git a/problems/tweet-counts-per-frequency/README.md b/problems/tweet-counts-per-frequency/README.md
    index e6ff8c299..f928815fb 100644
    --- a/problems/tweet-counts-per-frequency/README.md
    +++ b/problems/tweet-counts-per-frequency/README.md
    @@ -69,8 +69,8 @@ tweetCounts.getTweetCountsPerFrequency("hour", "tweet3", 0,
     
     
     ### Related Topics
    +  [[Design](../../tag/design/README.md)]
       [[Hash Table](../../tag/hash-table/README.md)]
       [[Binary Search](../../tag/binary-search/README.md)]
    -  [[Design](../../tag/design/README.md)]
    -  [[Sorting](../../tag/sorting/README.md)]
       [[Ordered Set](../../tag/ordered-set/README.md)]
    +  [[Sorting](../../tag/sorting/README.md)]
    diff --git a/problems/two-out-of-three/README.md b/problems/two-out-of-three/README.md
    new file mode 100644
    index 000000000..fa79fcd67
    --- /dev/null
    +++ b/problems/two-out-of-three/README.md
    @@ -0,0 +1,66 @@
    +
    +
    +
    +
    +
    +
    +
    +[< Previous](../count-subarrays-with-more-ones-than-zeros "Count Subarrays With More Ones Than Zeros")
    +                
    +[Next >](../minimum-operations-to-make-a-uni-value-grid "Minimum Operations to Make a Uni-Value Grid")
    +
    +## [2032. Two Out of Three (Easy)](https://leetcode.com/problems/two-out-of-three "至少在两个数组中出现的值")
    +
    +Given three integer arrays nums1, nums2, and nums3, return a distinct array containing all the values that are present in at least two out of the three arrays. You may return the values in any order.
    +

     

    +

    Example 1:

    + +
    +Input: nums1 = [1,1,3,2], nums2 = [2,3], nums3 = [3]
    +Output: [3,2]
    +Explanation: The values that are present in at least two arrays are:
    +- 3, in all three arrays.
    +- 2, in nums1 and nums2.
    +
    + +

    Example 2:

    + +
    +Input: nums1 = [3,1], nums2 = [2,3], nums3 = [1,2]
    +Output: [2,3,1]
    +Explanation: The values that are present in at least two arrays are:
    +- 2, in nums2 and nums3.
    +- 3, in nums1 and nums2.
    +- 1, in nums1 and nums3.
    +
    + +

    Example 3:

    + +
    +Input: nums1 = [1,2,2], nums2 = [4,3,3], nums3 = [5]
    +Output: []
    +Explanation: No value is present in at least two arrays.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums1.length, nums2.length, nums3.length <= 100
    • +
    • 1 <= nums1[i], nums2[j], nums3[k] <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +What data structure can we use to help us quickly find whether an element belongs in an array? +
    + +
    +Hint 2 +Can we count the frequencies of the elements in each array? +
    diff --git a/problems/unique-binary-search-trees/README.md b/problems/unique-binary-search-trees/README.md index a4a346d4b..178525946 100644 --- a/problems/unique-binary-search-trees/README.md +++ b/problems/unique-binary-search-trees/README.md @@ -36,10 +36,10 @@ ### Related Topics - [[Tree](../../tag/tree/README.md)] - [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/unique-number-of-occurrences/README.md b/problems/unique-number-of-occurrences/README.md index ba609788c..7b6144b8a 100644 --- a/problems/unique-number-of-occurrences/README.md +++ b/problems/unique-number-of-occurrences/README.md @@ -11,7 +11,7 @@ ## [1207. Unique Number of Occurrences (Easy)](https://leetcode.com/problems/unique-number-of-occurrences "独一无二的出现次数") -

    Given an array of integers arr, write a function that returns true if and only if the number of occurrences of each value in the array is unique.

    +

    Given an array of integers arr, return true if the number of occurrences of each value in the array is unique, or false otherwise.

     

    Example 1:

    diff --git a/problems/users-that-actively-request-confirmation-messages/README.md b/problems/users-that-actively-request-confirmation-messages/README.md index 92582042b..291046281 100644 --- a/problems/users-that-actively-request-confirmation-messages/README.md +++ b/problems/users-that-actively-request-confirmation-messages/README.md @@ -12,3 +12,6 @@ ## [1939. Users That Actively Request Confirmation Messages (Easy)](https://leetcode.com/problems/users-that-actively-request-confirmation-messages "") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/valid-boomerang/README.md b/problems/valid-boomerang/README.md index ed69aa5e7..f7e813c3d 100644 --- a/problems/valid-boomerang/README.md +++ b/problems/valid-boomerang/README.md @@ -33,8 +33,8 @@ ### Related Topics - [[Math](../../tag/math/README.md)] [[Geometry](../../tag/geometry/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/where-will-the-ball-fall/README.md b/problems/where-will-the-ball-fall/README.md index 130043f1b..d575bdf00 100644 --- a/problems/where-will-the-ball-fall/README.md +++ b/problems/where-will-the-ball-fall/README.md @@ -66,9 +66,9 @@ Ball b4 is dropped at column 4 and will get stuck on the box between column 2 an ### Related Topics - [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/word-ladder/README.md b/problems/word-ladder/README.md index 8a1932b13..410e3dd19 100644 --- a/problems/word-ladder/README.md +++ b/problems/word-ladder/README.md @@ -52,9 +52,9 @@ ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Similar Questions 1. [Word Ladder II](../word-ladder-ii) (Hard) diff --git a/problems/xor-operation-in-an-array/README.md b/problems/xor-operation-in-an-array/README.md index fb190c246..ee65a7eff 100644 --- a/problems/xor-operation-in-an-array/README.md +++ b/problems/xor-operation-in-an-array/README.md @@ -58,8 +58,8 @@ Where "^" corresponds to bitwise XOR operator. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/xor-queries-of-a-subarray/README.md b/problems/xor-queries-of-a-subarray/README.md index e8898071e..5b92b9e83 100644 --- a/problems/xor-queries-of-a-subarray/README.md +++ b/problems/xor-queries-of-a-subarray/README.md @@ -50,8 +50,8 @@ The XOR values for queries are: ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints diff --git a/readme/1-300.md b/readme/1-300.md index ea069a8e8..f8bc7f021 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -84,7 +84,7 @@ LeetCode Problems' Solutions | 4 | [Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays "寻找两个正序数组的中位数") | [Go](../problems/median-of-two-sorted-arrays) | Hard | | 5 | [Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring "最长回文子串") | [Go](../problems/longest-palindromic-substring) | Medium | | 6 | [ZigZag Conversion](https://leetcode.com/problems/zigzag-conversion "Z 字形变换") | [Go](../problems/zigzag-conversion) | Medium | -| 7 | [Reverse Integer](https://leetcode.com/problems/reverse-integer "整数反转") | [Go](../problems/reverse-integer) | Easy | +| 7 | [Reverse Integer](https://leetcode.com/problems/reverse-integer "整数反转") | [Go](../problems/reverse-integer) | Medium | | 8 | [String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-atoi "字符串转换整数 (atoi)") | [Go](../problems/string-to-integer-atoi) | Medium | | 9 | [Palindrome Number](https://leetcode.com/problems/palindrome-number "回文数") | [Go](../problems/palindrome-number) | Easy | | 10 | [Regular Expression Matching](https://leetcode.com/problems/regular-expression-matching "正则表达式匹配") | [Go](../problems/regular-expression-matching) | Hard | @@ -146,7 +146,7 @@ LeetCode Problems' Solutions | 66 | [Plus One](https://leetcode.com/problems/plus-one "加一") | [Go](../problems/plus-one) | Easy | | 67 | [Add Binary](https://leetcode.com/problems/add-binary "二进制求和") | [Go](../problems/add-binary) | Easy | | 68 | [Text Justification](https://leetcode.com/problems/text-justification "文本左右对齐") | [Go](../problems/text-justification) | Hard | -| 69 | [Sqrt(x)](https://leetcode.com/problems/sqrtx "x 的平方根") | [Go](../problems/sqrtx) | Easy | +| 69 | [Sqrt(x)](https://leetcode.com/problems/sqrtx "Sqrt(x)") | [Go](../problems/sqrtx) | Easy | | 70 | [Climbing Stairs](https://leetcode.com/problems/climbing-stairs "爬楼梯") | [Go](../problems/climbing-stairs) | Easy | | 71 | [Simplify Path](https://leetcode.com/problems/simplify-path "简化路径") | [Go](../problems/simplify-path) | Medium | | 72 | [Edit Distance](https://leetcode.com/problems/edit-distance "编辑距离") | [Go](../problems/edit-distance) | Hard | @@ -249,11 +249,11 @@ LeetCode Problems' Solutions | 169 | [Majority Element](https://leetcode.com/problems/majority-element "多数元素") | [Go](../problems/majority-element) | Easy | | 170 | [Two Sum III - Data structure design](https://leetcode.com/problems/two-sum-iii-data-structure-design "两数之和 III - 数据结构设计") 🔒 | [Go](../problems/two-sum-iii-data-structure-design) | Easy | | 171 | [Excel Sheet Column Number](https://leetcode.com/problems/excel-sheet-column-number "Excel 表列序号") | [Go](../problems/excel-sheet-column-number) | Easy | -| 172 | [Factorial Trailing Zeroes](https://leetcode.com/problems/factorial-trailing-zeroes "阶乘后的零") | [Go](../problems/factorial-trailing-zeroes) | Easy | +| 172 | [Factorial Trailing Zeroes](https://leetcode.com/problems/factorial-trailing-zeroes "阶乘后的零") | [Go](../problems/factorial-trailing-zeroes) | Medium | | 173 | [Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator "二叉搜索树迭代器") | [Go](../problems/binary-search-tree-iterator) | Medium | | 174 | [Dungeon Game](https://leetcode.com/problems/dungeon-game "地下城游戏") | [Go](../problems/dungeon-game) | Hard | | 175 | [Combine Two Tables](https://leetcode.com/problems/combine-two-tables "组合两个表") | [MySQL](../problems/combine-two-tables) | Easy | -| 176 | [Second Highest Salary](https://leetcode.com/problems/second-highest-salary "第二高的薪水") | [MySQL](../problems/second-highest-salary) | Easy | +| 176 | [Second Highest Salary](https://leetcode.com/problems/second-highest-salary "第二高的薪水") | [MySQL](../problems/second-highest-salary) | Medium | | 177 | [Nth Highest Salary](https://leetcode.com/problems/nth-highest-salary "第N高的薪水") | [MySQL](../problems/nth-highest-salary) | Medium | | 178 | [Rank Scores](https://leetcode.com/problems/rank-scores "分数排名") | [MySQL](../problems/rank-scores) | Medium | | 179 | [Largest Number](https://leetcode.com/problems/largest-number "最大数") | [Go](../problems/largest-number) | Medium | @@ -281,7 +281,7 @@ LeetCode Problems' Solutions | 201 | [Bitwise AND of Numbers Range](https://leetcode.com/problems/bitwise-and-of-numbers-range "数字范围按位与") | [Go](../problems/bitwise-and-of-numbers-range) | Medium | | 202 | [Happy Number](https://leetcode.com/problems/happy-number "快乐数") | [Go](../problems/happy-number) | Easy | | 203 | [Remove Linked List Elements](https://leetcode.com/problems/remove-linked-list-elements "移除链表元素") | [Go](../problems/remove-linked-list-elements) | Easy | -| 204 | [Count Primes](https://leetcode.com/problems/count-primes "计数质数") | [Go](../problems/count-primes) | Easy | +| 204 | [Count Primes](https://leetcode.com/problems/count-primes "计数质数") | [Go](../problems/count-primes) | Medium | | 205 | [Isomorphic Strings](https://leetcode.com/problems/isomorphic-strings "同构字符串") | [Go](../problems/isomorphic-strings) | Easy | | 206 | [Reverse Linked List](https://leetcode.com/problems/reverse-linked-list "反转链表") | [Go](../problems/reverse-linked-list) | Easy | | 207 | [Course Schedule](https://leetcode.com/problems/course-schedule "课程表") | [Go](../problems/course-schedule) | Medium | @@ -361,7 +361,7 @@ LeetCode Problems' Solutions | 281 | [Zigzag Iterator](https://leetcode.com/problems/zigzag-iterator "锯齿迭代器") 🔒 | [Go](../problems/zigzag-iterator) | Medium | | 282 | [Expression Add Operators](https://leetcode.com/problems/expression-add-operators "给表达式添加运算符") | [Go](../problems/expression-add-operators) | Hard | | 283 | [Move Zeroes](https://leetcode.com/problems/move-zeroes "移动零") | [Go](../problems/move-zeroes) | Easy | -| 284 | [Peeking Iterator](https://leetcode.com/problems/peeking-iterator "顶端迭代器") | [Go](../problems/peeking-iterator) | Medium | +| 284 | [Peeking Iterator](https://leetcode.com/problems/peeking-iterator "窥探迭代器") | [Go](../problems/peeking-iterator) | Medium | | 285 | [Inorder Successor in BST](https://leetcode.com/problems/inorder-successor-in-bst "二叉搜索树中的中序后继") 🔒 | [Go](../problems/inorder-successor-in-bst) | Medium | | 286 | [Walls and Gates](https://leetcode.com/problems/walls-and-gates "墙与门") 🔒 | [Go](../problems/walls-and-gates) | Medium | | 287 | [Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number "寻找重复数") | [Go](../problems/find-the-duplicate-number) | Medium | diff --git a/readme/301-600.md b/readme/301-600.md index b7952889b..4001d56d8 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -230,7 +230,7 @@ LeetCode Problems' Solutions | 450 | [Delete Node in a BST](https://leetcode.com/problems/delete-node-in-a-bst "删除二叉搜索树中的节点") | [Go](../problems/delete-node-in-a-bst) | Medium | | 451 | [Sort Characters By Frequency](https://leetcode.com/problems/sort-characters-by-frequency "根据字符出现频率排序") | [Go](../problems/sort-characters-by-frequency) | Medium | | 452 | [Minimum Number of Arrows to Burst Balloons](https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons "用最少数量的箭引爆气球") | [Go](../problems/minimum-number-of-arrows-to-burst-balloons) | Medium | -| 453 | [Minimum Moves to Equal Array Elements](https://leetcode.com/problems/minimum-moves-to-equal-array-elements "最小操作次数使数组元素相等") | [Go](../problems/minimum-moves-to-equal-array-elements) | Easy | +| 453 | [Minimum Moves to Equal Array Elements](https://leetcode.com/problems/minimum-moves-to-equal-array-elements "最小操作次数使数组元素相等") | [Go](../problems/minimum-moves-to-equal-array-elements) | Medium | | 454 | [4Sum II](https://leetcode.com/problems/4sum-ii "四数相加 II") | [Go](../problems/4sum-ii) | Medium | | 455 | [Assign Cookies](https://leetcode.com/problems/assign-cookies "分发饼干") | [Go](../problems/assign-cookies) | Easy | | 456 | [132 Pattern](https://leetcode.com/problems/132-pattern "132 模式") | [Go](../problems/132-pattern) | Medium | diff --git a/readme/601-900.md b/readme/601-900.md index 90b8eb912..f5563b085 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -351,7 +351,7 @@ LeetCode Problems' Solutions | 871 | [Minimum Number of Refueling Stops](https://leetcode.com/problems/minimum-number-of-refueling-stops "最低加油次数") | [Go](../problems/minimum-number-of-refueling-stops) | Hard | | 872 | [Leaf-Similar Trees](https://leetcode.com/problems/leaf-similar-trees "叶子相似的树") | [Go](../problems/leaf-similar-trees) | Easy | | 873 | [Length of Longest Fibonacci Subsequence](https://leetcode.com/problems/length-of-longest-fibonacci-subsequence "最长的斐波那契子序列的长度") | [Go](../problems/length-of-longest-fibonacci-subsequence) | Medium | -| 874 | [Walking Robot Simulation](https://leetcode.com/problems/walking-robot-simulation "模拟行走机器人") | [Go](../problems/walking-robot-simulation) | Easy | +| 874 | [Walking Robot Simulation](https://leetcode.com/problems/walking-robot-simulation "模拟行走机器人") | [Go](../problems/walking-robot-simulation) | Medium | | 875 | [Koko Eating Bananas](https://leetcode.com/problems/koko-eating-bananas "爱吃香蕉的珂珂") | [Go](../problems/koko-eating-bananas) | Medium | | 876 | [Middle of the Linked List](https://leetcode.com/problems/middle-of-the-linked-list "链表的中间结点") | [Go](../problems/middle-of-the-linked-list) | Easy | | 877 | [Stone Game](https://leetcode.com/problems/stone-game "石子游戏") | [Go](../problems/stone-game) | Medium | diff --git a/readme/901-1200.md b/readme/901-1200.md index 8a9a768fe..809027847 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -179,7 +179,7 @@ LeetCode Problems' Solutions | 999 | [Available Captures for Rook](https://leetcode.com/problems/available-captures-for-rook "可以被一步捕获的棋子数") | [Go](../problems/available-captures-for-rook) | Easy | | 1000 | [Minimum Cost to Merge Stones](https://leetcode.com/problems/minimum-cost-to-merge-stones "合并石头的最低成本") | [Go](../problems/minimum-cost-to-merge-stones) | Hard | | 1001 | [Grid Illumination](https://leetcode.com/problems/grid-illumination "网格照明") | [Go](../problems/grid-illumination) | Hard | -| 1002 | [Find Common Characters](https://leetcode.com/problems/find-common-characters "查找常用字符") | [Go](../problems/find-common-characters) | Easy | +| 1002 | [Find Common Characters](https://leetcode.com/problems/find-common-characters "查找共用字符") | [Go](../problems/find-common-characters) | Easy | | 1003 | [Check If Word Is Valid After Substitutions](https://leetcode.com/problems/check-if-word-is-valid-after-substitutions "检查替换后的词是否有效") | [Go](../problems/check-if-word-is-valid-after-substitutions) | Medium | | 1004 | [Max Consecutive Ones III](https://leetcode.com/problems/max-consecutive-ones-iii "最大连续1的个数 III") | [Go](../problems/max-consecutive-ones-iii) | Medium | | 1005 | [Maximize Sum Of Array After K Negations](https://leetcode.com/problems/maximize-sum-of-array-after-k-negations "K 次取反后最大化的数组和") | [Go](../problems/maximize-sum-of-array-after-k-negations) | Easy | diff --git a/tag/array/README.md b/tag/array/README.md index 2d1b2d60a..240db0d5e 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,35 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | +| 2044 | [统计按位或能得到最大值的子集数目](../../problems/count-number-of-maximum-bitwise-or-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2040 | [两个有序数组的第 K 小乘积](../../problems/kth-smallest-product-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | +| 2037 | [使每位学生都有座位的最少移动次数](../../problems/minimum-number-of-moves-to-seat-everyone) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2036 | [Maximum Alternating Subarray Sum](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2032 | [至少在两个数组中出现的值](../../problems/two-out-of-three) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2029 | [石子游戏 IX](../../problems/stone-game-ix) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 2028 | [找出缺失的观测数据](../../problems/find-missing-observations) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2023 | [连接后等于目标字符串的字符串对](../../problems/number-of-pairs-of-strings-with-concatenation-equal-to-target) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 2022 | [将一维数组转变成二维数组](../../problems/convert-1d-array-into-2d-array) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2021 | [Brightest Position on Street](../../problems/brightest-position-on-street) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2018 | [判断单词是否能放入填字游戏内](../../problems/check-if-word-can-be-placed-in-crossword) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2017 | [网格游戏](../../problems/grid-game) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2016 | [增量元素之间的最大差值](../../problems/maximum-difference-between-increasing-elements) | [[数组](../array/README.md)] | Easy | +| 2015 | [Average Height of Buildings in Each Segment](../../problems/average-height-of-buildings-in-each-segment) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2013 | [检测正方形](../../problems/detect-squares) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2012 | [数组美丽值求和](../../problems/sum-of-beauty-in-the-array) | [[数组](../array/README.md)] | Medium | +| 2011 | [执行操作后的变量值](../../problems/final-value-of-variable-after-performing-operations) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2009 | [使数组连续的最少操作数](../../problems/minimum-number-of-operations-to-make-array-continuous) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 2008 | [出租车的最大盈利](../../problems/maximum-earnings-from-taxi) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2007 | [从双倍数组中还原原数组](../../problems/find-original-array-from-doubled-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2006 | [差的绝对值为 K 的数对数目](../../problems/count-number-of-pairs-with-absolute-difference-k) | [[数组](../array/README.md)] | Easy | | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 1997 | [访问完所有房间的第一天](../../problems/first-day-where-you-have-been-in-all-the-rooms) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -32,6 +61,7 @@ | 1961 | [检查字符串是否为数组前缀](../../problems/check-if-string-is-a-prefix-of-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 1959 | [K 次调整数组大小浪费的最小总空间](../../problems/minimum-total-space-wasted-with-k-resizing-operations) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1958 | [检查操作是否合法](../../problems/check-if-move-is-legal) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1956 | [感染 K 种病毒所需的最短时间](../../problems/minimum-time-for-k-virus-variants-to-spread) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1955 | [统计特殊子序列的数目](../../problems/count-number-of-special-subsequences) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1953 | [你可以工作的最大周数](../../problems/maximum-number-of-weeks-for-which-you-can-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | @@ -47,7 +77,7 @@ | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1920 | [基于排列构建数组](../../problems/build-array-from-permutation) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | -| 1918 | [第 K 小的子序列和](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1918 | [第 K 小的子数组和·](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1914 | [循环轮转矩阵](../../problems/cyclically-rotating-a-grid) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1913 | [两个数对之间的最大乘积差](../../problems/maximum-product-difference-between-two-pairs) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | @@ -115,7 +145,7 @@ | 1800 | [最大升序子数组和](../../problems/maximum-ascending-subarray-sum) | [[数组](../array/README.md)] | Easy | | 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] [[数论](../number-theory/README.md)] | Hard | | 1798 | [你能构造出连续值的最大数目](../../problems/maximum-number-of-consecutive-values-you-can-make) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | -| 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1792 | [最大平均通过率](../../problems/maximum-average-pass-ratio) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1788 | [最大化花园的美观度](../../problems/maximize-the-beauty-of-the-garden) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 1787 | [使所有区间的异或结果为零](../../problems/make-the-xor-of-all-segments-equal-to-zero) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -132,7 +162,7 @@ | 1764 | [通过连接另一个数组的子数组得到一个数组](../../problems/form-array-by-concatenating-subarrays-of-another-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | | 1762 | [能看到海景的建筑物](../../problems/buildings-with-an-ocean-view) 🔒 | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1760 | [袋子里最少数目的球](../../problems/minimum-limit-of-balls-in-a-bag) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1755 | [最接近目标值的子序列和](../../problems/closest-subsequence-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1752 | [检查数组是否经排序和轮转得到](../../problems/check-if-array-is-sorted-and-rotated) | [[数组](../array/README.md)] | Easy | | 1751 | [最多可以参加的会议数目 II](../../problems/maximum-number-of-events-that-can-be-attended-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -241,7 +271,7 @@ | 1562 | [查找大小为 M 的最新分组](../../problems/find-latest-group-of-size-m) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1561 | [你可以获得的最大硬币数目](../../problems/maximum-number-of-coins-you-can-get) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] [[排序](../sorting/README.md)] | Medium | | 1560 | [圆形赛道上经过次数最多的扇区](../../problems/most-visited-sector-in-a-circular-track) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | -| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1558 | [得到目标数组的最少函数调用次数](../../problems/minimum-numbers-of-function-calls-to-make-target-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1552 | [两球之间的磁力](../../problems/magnetic-force-between-two-balls) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 1550 | [存在连续三个奇数的数组](../../problems/three-consecutive-odds) | [[数组](../array/README.md)] | Easy | @@ -487,7 +517,7 @@ | 1007 | [行相等的最少多米诺旋转](../../problems/minimum-domino-rotations-for-equal-row) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1005 | [K 次取反后最大化的数组和](../../problems/maximize-sum-of-array-after-k-negations) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 1004 | [最大连续1的个数 III](../../problems/max-consecutive-ones-iii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | -| 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1002 | [查找共用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 1001 | [网格照明](../../problems/grid-illumination) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 1000 | [合并石头的最低成本](../../problems/minimum-cost-to-merge-stones) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 999 | [可以被一步捕获的棋子数](../../problems/available-captures-for-rook) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | @@ -569,7 +599,7 @@ | 879 | [盈利计划](../../problems/profitable-schemes) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 877 | [石子游戏](../../problems/stone-game) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 875 | [爱吃香蕉的珂珂](../../problems/koko-eating-bananas) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 874 | [模拟行走机器人](../../problems/walking-robot-simulation) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 874 | [模拟行走机器人](../../problems/walking-robot-simulation) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | | 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 871 | [最低加油次数](../../problems/minimum-number-of-refueling-stops) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -828,7 +858,7 @@ | 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 286 | [墙与门](../../problems/walls-and-gates) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 284 | [窥探迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -866,7 +896,7 @@ | 213 | [打家劫舍 II](../../problems/house-robber-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | -| 204 | [计数质数](../../problems/count-primes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] [[数论](../number-theory/README.md)] | Easy | +| 204 | [计数质数](../../problems/count-primes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] [[数论](../number-theory/README.md)] | Medium | | 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 198 | [打家劫舍](../../problems/house-robber) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 189 | [旋转数组](../../problems/rotate-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index f42b7276a..e7b5987dd 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2044 | [统计按位或能得到最大值的子集数目](../../problems/count-number-of-maximum-bitwise-or-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 2014 | [重复 K 次的最长子序列](../../problems/longest-subsequence-repeated-k-times) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1986 | [完成任务的最少工作时间段](../../problems/minimum-number-of-work-sessions-to-finish-the-tasks) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1980 | [找出不同的二进制字符串](../../problems/find-unique-binary-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | diff --git a/tag/binary-indexed-tree/README.md b/tag/binary-indexed-tree/README.md index a0602d04c..9efbf1687 100644 --- a/tag/binary-indexed-tree/README.md +++ b/tag/binary-indexed-tree/README.md @@ -9,7 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1964 | [找出到每个位置为止最长的有效障碍赛跑路线](../../problems/find-the-longest-valid-obstacle-course-at-each-position) | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 1505 | [最多 K 次交换相邻数位后得到的最小整数](../../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | [[贪心](../greedy/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[字符串](../string/README.md)] | Hard | | 1409 | [查询带键的排列](../../problems/queries-on-a-permutation-with-key) | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index a77cb86cf..ef1bebbd9 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,12 +9,19 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2040 | [两个有序数组的第 K 小乘积](../../problems/kth-smallest-product-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2024 | [考试的最大困扰度](../../problems/maximize-the-confusion-of-an-exam) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2009 | [使数组连续的最少操作数](../../problems/minimum-number-of-operations-to-make-array-continuous) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 2008 | [出租车的最大盈利](../../problems/maximum-earnings-from-taxi) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | | 1970 | [你能穿过矩阵的最后一天](../../problems/last-day-where-you-can-still-cross) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1964 | [找出到每个位置为止最长的有效障碍赛跑路线](../../problems/find-the-longest-valid-obstacle-course-at-each-position) | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 1956 | [感染 K 种病毒所需的最短时间](../../problems/minimum-time-for-k-virus-variants-to-spread) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1954 | [收集足够苹果的最小花园周长](../../problems/minimum-garden-perimeter-to-collect-enough-apples) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | -| 1918 | [第 K 小的子序列和](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1918 | [第 K 小的子数组和·](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1901 | [找出顶峰元素 II](../../problems/find-a-peak-element-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1898 | [可移除字符的最大数目](../../problems/maximum-number-of-removable-characters) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1894 | [找到需要补充粉笔的学生编号](../../problems/find-the-student-that-will-replace-the-chalk) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[模拟](../simulation/README.md)] | Medium | @@ -29,6 +36,7 @@ | 1838 | [最高频元素的频数](../../problems/frequency-of-the-most-frequent-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1802 | [有界数组中指定下标处的最大值](../../problems/maximum-value-at-a-given-index-in-a-bounded-array) | [[贪心](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1782 | [统计点对的数目](../../problems/count-pairs-of-nodes) | [[图](../graph/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1760 | [袋子里最少数目的球](../../problems/minimum-limit-of-balls-in-a-bag) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1751 | [最多可以参加的会议数目 II](../../problems/maximum-number-of-events-that-can-be-attended-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -153,7 +161,7 @@ | 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 81 | [搜索旋转排序数组 II](../../problems/search-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 74 | [搜索二维矩阵](../../problems/search-a-2d-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 69 | [x 的平方根](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 69 | [Sqrt(x)](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 35 | [搜索插入位置](../../problems/search-insert-position) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 34 | [在排序数组中查找元素的第一个和最后一个位置](../../problems/find-first-and-last-position-of-element-in-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 33 | [搜索旋转排序数组](../../problems/search-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index a81d9297e..0be114e27 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2044 | [统计按位或能得到最大值的子集数目](../../problems/count-number-of-maximum-bitwise-or-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1994 | [好子集的数目](../../problems/the-number-of-good-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1986 | [完成任务的最少工作时间段](../../problems/minimum-number-of-work-sessions-to-finish-the-tasks) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | diff --git a/tag/bitmask/README.md b/tag/bitmask/README.md index 21d0f94f5..b15c69aa3 100644 --- a/tag/bitmask/README.md +++ b/tag/bitmask/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1994 | [好子集的数目](../../problems/the-number-of-good-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1986 | [完成任务的最少工作时间段](../../problems/minimum-number-of-work-sessions-to-finish-the-tasks) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index ce43624db..aed470287 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | +| 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1992 | [找到所有的农场组](../../problems/find-all-groups-of-farmland) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1971 | [Find if Path Exists in Graph](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | @@ -29,7 +31,7 @@ | 1609 | [奇偶树](../../problems/even-odd-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1602 | [找到二叉树中最近的右侧节点](../../problems/find-nearest-right-node-in-binary-tree) 🔒 | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1568 | [使陆地分离的最少天数](../../problems/minimum-number-of-days-to-disconnect-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[强连通分量](../strongly-connected-component/README.md)] | Hard | -| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1490 | [克隆 N 叉树](../../problems/clone-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1485 | [克隆含随机指针的二叉树](../../problems/clone-binary-tree-with-random-pointer) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | diff --git a/tag/counting/README.md b/tag/counting/README.md index 947c2d594..a56c615c1 100644 --- a/tag/counting/README.md +++ b/tag/counting/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2029 | [石子游戏 IX](../../problems/stone-game-ix) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2014 | [重复 K 次的最长子序列](../../problems/longest-subsequence-repeated-k-times) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 2013 | [检测正方形](../../problems/detect-squares) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1941 | [检查是否所有字符出现次数相同](../../problems/check-if-all-characters-have-equal-number-of-occurrences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 1940 | [排序数组之间的最长公共子序列](../../problems/longest-common-subsequence-between-sorted-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 4cbb4b884..7afb641e5 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -30,7 +30,7 @@ | 1612 | [检查两棵二叉表达式树是否等价](../../problems/check-if-two-expression-trees-are-equivalent) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1600 | [皇位继承顺序](../../problems/throne-inheritance) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1568 | [使陆地分离的最少天数](../../problems/minimum-number-of-days-to-disconnect-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[强连通分量](../strongly-connected-component/README.md)] | Hard | -| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1530 | [好叶子节点对的数量](../../problems/number-of-good-leaf-nodes-pairs) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1522 | [N 叉树的直径](../../problems/diameter-of-n-ary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] | Medium | | 1519 | [子树中标签相同的节点数](../../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index cf28e5b9e..e34d41c6e 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2013 | [检测正方形](../../problems/detect-squares) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1865 | [找出和为指定值的下标对](../../problems/finding-pairs-with-a-certain-sum) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | @@ -16,7 +19,7 @@ | 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1804 | [实现 Trie (前缀树) II](../../problems/implement-trie-ii-prefix-tree) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1797 | [设计一个验证系统](../../problems/design-authentication-manager) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] | Medium | | 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] | Easy | | 1628 | [设计带解析函数的表达式树](../../problems/design-an-expression-tree-with-evaluate-function) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[数学](../math/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -94,7 +97,7 @@ | 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[设计](../design/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 284 | [窥探迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 271 | [字符串的编码与解码](../../problems/encode-and-decode-strings) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[迭代器](../iterator/README.md)] | Medium | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index 233b43daf..3d2028983 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1982 | [从子集的和还原数组](../../problems/find-array-given-subset-sums) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] | Hard | | 1901 | [找出顶峰元素 II](../../problems/find-a-peak-element-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index ebbcc048c..19af95bb4 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2036 | [Maximum Alternating Subarray Sum](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2008 | [出租车的最大盈利](../../problems/maximum-earnings-from-taxi) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | | 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1997 | [访问完所有房间的第一天](../../problems/first-day-where-you-have-been-in-all-the-rooms) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/enumeration/README.md b/tag/enumeration/README.md index c53c3c671..4c68ea96d 100644 --- a/tag/enumeration/README.md +++ b/tag/enumeration/README.md @@ -9,8 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2018 | [判断单词是否能放入填字游戏内](../../problems/check-if-word-can-be-placed-in-crossword) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2014 | [重复 K 次的最长子序列](../../problems/longest-subsequence-repeated-k-times) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1995 | [统计特殊四元组](../../problems/count-special-quadruplets) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 1958 | [检查操作是否合法](../../problems/check-if-move-is-legal) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1956 | [感染 K 种病毒所需的最短时间](../../problems/minimum-time-for-k-virus-variants-to-spread) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1925 | [统计平方和三元组的数目](../../problems/count-square-sum-triples) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 1620 | [网络信号最好的坐标](../../problems/coordinate-with-maximum-network-quality) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Medium | | 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[枚举](../enumeration/README.md)] | Hard | @@ -25,4 +29,4 @@ | 829 | [连续整数求和](../../problems/consecutive-numbers-sum) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 800 | [相似 RGB 颜色](../../problems/similar-rgb-color) 🔒 | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 681 | [最近时刻](../../problems/next-closest-time) 🔒 | [[字符串](../string/README.md)] [[枚举](../enumeration/README.md)] | Medium | -| 204 | [计数质数](../../problems/count-primes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] [[数论](../number-theory/README.md)] | Easy | +| 204 | [计数质数](../../problems/count-primes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] [[数论](../number-theory/README.md)] | Medium | diff --git a/tag/game-theory/README.md b/tag/game-theory/README.md index 7c7a9a35f..f47303880 100644 --- a/tag/game-theory/README.md +++ b/tag/game-theory/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2038 | [如果相邻两个颜色均相同则删除当前颜色](../../problems/remove-colored-pieces-if-both-neighbors-are-the-same-color) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 2029 | [石子游戏 IX](../../problems/stone-game-ix) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1927 | [求和游戏](../../problems/sum-game) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1908 | [Nim 游戏 II](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1872 | [石子游戏 VIII](../../problems/stone-game-viii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index 686080f2a..d63defc50 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 1956 | [感染 K 种病毒所需的最短时间](../../problems/minimum-time-for-k-virus-variants-to-spread) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1924 | [Erect the Fence II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1828 | [统计一个圆中点的数目](../../problems/queries-on-number-of-points-inside-a-circle) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index eb026350b..2560c43df 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | +| 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 1971 | [Find if Path Exists in Graph](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | | 1928 | [规定时间内到达终点的最小花费](../../problems/minimum-cost-to-reach-destination-in-time) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 63c4716fa..e27af2371 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,13 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2038 | [如果相邻两个颜色均相同则删除当前颜色](../../problems/remove-colored-pieces-if-both-neighbors-are-the-same-color) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 2030 | [含特定字母的最小子序列](../../problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 2029 | [石子游戏 IX](../../problems/stone-game-ix) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 2027 | [转换字符串的最少操作次数](../../problems/minimum-moves-to-convert-string) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | +| 2015 | [Average Height of Buildings in Each Segment](../../problems/average-height-of-buildings-in-each-segment) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2014 | [重复 K 次的最长子序列](../../problems/longest-subsequence-repeated-k-times) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 2007 | [从双倍数组中还原原数组](../../problems/find-original-array-from-doubled-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | | 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1975 | [最大方阵和](../../problems/maximum-matrix-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1974 | [使用特殊打字机键入单词的最少时间](../../problems/minimum-time-to-type-word-using-special-typewriter) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index 20857bd67..a2f17ec46 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,6 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2032 | [至少在两个数组中出现的值](../../problems/two-out-of-three) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2013 | [检测正方形](../../problems/detect-squares) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2007 | [从双倍数组中还原原数组](../../problems/find-original-array-from-doubled-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | @@ -41,7 +47,7 @@ | 1775 | [通过最少操作次数使数组的和相等](../../problems/equal-sum-arrays-with-minimum-number-of-operations) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | | 1772 | [按受欢迎程度排列功能](../../problems/sort-features-by-popularity) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 1763 | [最长的美好子字符串](../../problems/longest-nice-substring) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | -| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1748 | [唯一元素的和](../../problems/sum-of-unique-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | | 1743 | [从相邻元素对还原数组](../../problems/restore-the-array-from-adjacent-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1742 | [盒子中小球的最大数量](../../problems/maximum-number-of-balls-in-a-box) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] | Easy | @@ -158,7 +164,7 @@ | 1027 | [最长等差数列](../../problems/longest-arithmetic-subsequence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1015 | [可被 K 整除的最小整数](../../problems/smallest-integer-divisible-by-k) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 1010 | [总持续时间可被 60 整除的歌曲](../../problems/pairs-of-songs-with-total-durations-divisible-by-60) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | -| 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1002 | [查找共用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 1001 | [网格照明](../../problems/grid-illumination) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 997 | [找到小镇的法官](../../problems/find-the-town-judge) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 992 | [K 个不同整数的子数组](../../problems/subarrays-with-k-different-integers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | diff --git a/tag/heap-priority-queue/README.md b/tag/heap-priority-queue/README.md index e1a43a972..605ef67c7 100644 --- a/tag/heap-priority-queue/README.md +++ b/tag/heap-priority-queue/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2015 | [Average Height of Buildings in Each Segment](../../problems/average-height-of-buildings-in-each-segment) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1962 | [移除石子使总数最小](../../problems/remove-stones-to-minimize-the-total) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1942 | [最小未被占据椅子的编号](../../problems/the-number-of-the-smallest-unoccupied-chair) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/iterator/README.md b/tag/iterator/README.md index c1750d402..d7569eef4 100644 --- a/tag/iterator/README.md +++ b/tag/iterator/README.md @@ -14,7 +14,7 @@ | 900 | [RLE 迭代器](../../problems/rle-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[迭代器](../iterator/README.md)] | Easy | | 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] [[迭代器](../iterator/README.md)] | Medium | -| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 284 | [窥探迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index b81c3ffea..513cac81c 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,11 +9,17 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2038 | [如果相邻两个颜色均相同则删除当前颜色](../../problems/remove-colored-pieces-if-both-neighbors-are-the-same-color) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2029 | [石子游戏 IX](../../problems/stone-game-ix) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 2028 | [找出缺失的观测数据](../../problems/find-missing-observations) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 1994 | [好子集的数目](../../problems/the-number-of-good-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1979 | [找出数组的最大公约数](../../problems/find-greatest-common-divisor-of-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1969 | [数组元素的最小非零乘积](../../problems/minimum-non-zero-product-of-the-array-elements) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | +| 1956 | [感染 K 种病毒所需的最短时间](../../problems/minimum-time-for-k-virus-variants-to-spread) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1954 | [收集足够苹果的最小花园周长](../../problems/minimum-garden-perimeter-to-collect-enough-apples) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1952 | [三除数](../../problems/three-divisors) | [[数学](../math/README.md)] | Easy | | 1927 | [求和游戏](../../problems/sum-game) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Medium | @@ -302,10 +308,10 @@ | 227 | [基本计算器 II](../../problems/basic-calculator-ii) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 224 | [基本计算器](../../problems/basic-calculator) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | | 223 | [矩形面积](../../problems/rectangle-area) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | -| 204 | [计数质数](../../problems/count-primes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] [[数论](../number-theory/README.md)] | Easy | +| 204 | [计数质数](../../problems/count-primes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] [[数论](../number-theory/README.md)] | Medium | | 202 | [快乐数](../../problems/happy-number) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 189 | [旋转数组](../../problems/rotate-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | -| 172 | [阶乘后的零](../../problems/factorial-trailing-zeroes) | [[数学](../math/README.md)] | Easy | +| 172 | [阶乘后的零](../../problems/factorial-trailing-zeroes) | [[数学](../math/README.md)] | Medium | | 171 | [Excel 表列序号](../../problems/excel-sheet-column-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 168 | [Excel表列名称](../../problems/excel-sheet-column-title) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | @@ -314,7 +320,7 @@ | 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 89 | [格雷编码](../../problems/gray-code) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 70 | [爬楼梯](../../problems/climbing-stairs) | [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 69 | [x 的平方根](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 69 | [Sqrt(x)](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 67 | [二进制求和](../../problems/add-binary) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 66 | [加一](../../problems/plus-one) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 62 | [不同路径](../../problems/unique-paths) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | diff --git a/tag/matrix/README.md b/tag/matrix/README.md index 0383fad45..f45aba1f5 100644 --- a/tag/matrix/README.md +++ b/tag/matrix/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2022 | [将一维数组转变成二维数组](../../problems/convert-1d-array-into-2d-array) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2018 | [判断单词是否能放入填字游戏内](../../problems/check-if-word-can-be-placed-in-crossword) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2017 | [网格游戏](../../problems/grid-game) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1992 | [找到所有的农场组](../../problems/find-all-groups-of-farmland) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1981 | [最小化目标值与所选元素的差](../../problems/minimize-the-difference-between-target-and-chosen-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1975 | [最大方阵和](../../problems/maximum-matrix-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -38,7 +42,7 @@ | 1582 | [二进制矩阵中的特殊位置](../../problems/special-positions-in-a-binary-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | | 1572 | [矩阵对角线元素的和](../../problems/matrix-diagonal-sum) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | | 1568 | [使陆地分离的最少天数](../../problems/minimum-number-of-days-to-disconnect-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[强连通分量](../strongly-connected-component/README.md)] | Hard | -| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1504 | [统计全 1 子矩形](../../problems/count-submatrices-with-all-ones) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1476 | [子矩形查询](../../problems/subrectangle-queries) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | diff --git a/tag/memoization/README.md b/tag/memoization/README.md index fa0ddeaed..755983572 100644 --- a/tag/memoization/README.md +++ b/tag/memoization/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1900 | [最佳运动员的比拼回合](../../problems/the-earliest-and-latest-rounds-where-players-compete) | [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] [[计数](../counting/README.md)] | Hard | | 1815 | [得到新鲜甜甜圈的最多组数](../../problems/maximum-number-of-groups-getting-fresh-donuts) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | diff --git a/tag/merge-sort/README.md b/tag/merge-sort/README.md index 7c05fa549..29614f7df 100644 --- a/tag/merge-sort/README.md +++ b/tag/merge-sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 912 | [排序数组](../../problems/sort-an-array) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数排序](../counting-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 493 | [翻转对](../../problems/reverse-pairs) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | diff --git a/tag/monotonic-stack/README.md b/tag/monotonic-stack/README.md index 1f30a905a..54985b13f 100644 --- a/tag/monotonic-stack/README.md +++ b/tag/monotonic-stack/README.md @@ -9,10 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2030 | [含特定字母的最小子序列](../../problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1944 | [队列中可以看到的人数](../../problems/number-of-visible-people-in-a-queue) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | -| 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1776 | [车队 II](../../problems/car-fleet-ii) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[单调栈](../monotonic-stack/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1762 | [能看到海景的建筑物](../../problems/buildings-with-an-ocean-view) 🔒 | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | diff --git a/tag/number-theory/README.md b/tag/number-theory/README.md index 5a1ff7079..82435c8d2 100644 --- a/tag/number-theory/README.md +++ b/tag/number-theory/README.md @@ -16,4 +16,4 @@ | 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[数论](../number-theory/README.md)] | Medium | | 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Easy | | 258 | [各位相加](../../problems/add-digits) | [[数学](../math/README.md)] [[数论](../number-theory/README.md)] [[模拟](../simulation/README.md)] | Easy | -| 204 | [计数质数](../../problems/count-primes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] [[数论](../number-theory/README.md)] | Easy | +| 204 | [计数质数](../../problems/count-primes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] [[数论](../number-theory/README.md)] | Medium | diff --git a/tag/ordered-set/README.md b/tag/ordered-set/README.md index 52b43d8b0..94715a26a 100644 --- a/tag/ordered-set/README.md +++ b/tag/ordered-set/README.md @@ -9,12 +9,16 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2021 | [Brightest Position on Street](../../problems/brightest-position-on-street) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1942 | [最小未被占据椅子的编号](../../problems/the-number-of-the-smallest-unoccupied-chair) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | -| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | diff --git a/tag/prefix-sum/README.md b/tag/prefix-sum/README.md index 3483f4894..89f66e12b 100644 --- a/tag/prefix-sum/README.md +++ b/tag/prefix-sum/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2024 | [考试的最大困扰度](../../problems/maximize-the-confusion-of-an-exam) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2021 | [Brightest Position on Street](../../problems/brightest-position-on-street) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2017 | [网格游戏](../../problems/grid-game) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1991 | [找到数组的中间位置](../../problems/find-the-middle-index-in-array) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | | 1943 | [描述绘画结果](../../problems/describe-the-painting) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1930 | [长度为 3 的不同回文子序列](../../problems/unique-length-3-palindromic-subsequences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index 13b0613a2..55fd9bddb 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/shortest-path/README.md b/tag/shortest-path/README.md index d1184c760..1b0378a62 100644 --- a/tag/shortest-path/README.md +++ b/tag/shortest-path/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/simulation/README.md b/tag/simulation/README.md index 139200065..da35f0bca 100644 --- a/tag/simulation/README.md +++ b/tag/simulation/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2028 | [找出缺失的观测数据](../../problems/find-missing-observations) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2022 | [将一维数组转变成二维数组](../../problems/convert-1d-array-into-2d-array) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2011 | [执行操作后的变量值](../../problems/final-value-of-variable-after-performing-operations) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 1945 | [字符串转化后的各位数字之和](../../problems/sum-of-digits-of-string-after-convert) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 1920 | [基于排列构建数组](../../problems/build-array-from-permutation) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 1914 | [循环轮转矩阵](../../problems/cyclically-rotating-a-grid) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | @@ -49,7 +53,7 @@ | 950 | [按递增顺序显示卡牌](../../problems/reveal-cards-in-increasing-order) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Medium | | 946 | [验证栈序列](../../problems/validate-stack-sequences) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | | 885 | [螺旋矩阵 III](../../problems/spiral-matrix-iii) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | -| 874 | [模拟行走机器人](../../problems/walking-robot-simulation) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 874 | [模拟行走机器人](../../problems/walking-robot-simulation) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | | 867 | [转置矩阵](../../problems/transpose-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | | 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 832 | [翻转图像](../../problems/flipping-an-image) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index 853ab40b9..4f631cd5b 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -9,7 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1918 | [第 K 小的子序列和](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2024 | [考试的最大困扰度](../../problems/maximize-the-confusion-of-an-exam) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1918 | [第 K 小的子数组和·](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1876 | [长度为三且各字符不同的子字符串](../../problems/substrings-of-size-three-with-distinct-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1852 | [每个子数组的数字种类数](../../problems/distinct-numbers-in-each-subarray) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1839 | [所有元音按顺序排布的最长子字符串](../../problems/longest-substring-of-all-vowels-in-order) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | diff --git a/tag/sorting/README.md b/tag/sorting/README.md index 94ffdc25a..e90de4a2f 100644 --- a/tag/sorting/README.md +++ b/tag/sorting/README.md @@ -9,6 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2037 | [使每位学生都有座位的最少移动次数](../../problems/minimum-number-of-moves-to-seat-everyone) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2015 | [Average Height of Buildings in Each Segment](../../problems/average-height-of-buildings-in-each-segment) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2008 | [出租车的最大盈利](../../problems/maximum-earnings-from-taxi) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2007 | [从双倍数组中还原原数组](../../problems/find-original-array-from-doubled-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | | 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/stack/README.md b/tag/stack/README.md index 7f58a1a43..5e7381fb9 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -9,15 +9,17 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2030 | [含特定字母的最小子序列](../../problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1963 | [使字符串平衡的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-string-balanced) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1944 | [队列中可以看到的人数](../../problems/number-of-visible-people-in-a-queue) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1896 | [反转表达式值的最少操作次数](../../problems/minimum-cost-to-change-the-final-value-of-expression) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | -| 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1776 | [车队 II](../../problems/car-fleet-ii) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[单调栈](../monotonic-stack/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1762 | [能看到海景的建筑物](../../problems/buildings-with-an-ocean-view) 🔒 | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | -| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1717 | [删除子字符串的最大得分](../../problems/maximum-score-from-removing-substrings) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1700 | [无法吃午餐的学生数量](../../problems/number-of-students-unable-to-eat-lunch) | [[栈](../stack/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 1673 | [找出最具竞争力的子序列](../../problems/find-the-most-competitive-subsequence) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index 268c328e0..a0fbdcc46 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,15 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2042 | [检查句子中的数字是否递增](../../problems/check-if-numbers-are-ascending-in-a-sentence) | [[字符串](../string/README.md)] | Easy | +| 2038 | [如果相邻两个颜色均相同则删除当前颜色](../../problems/remove-colored-pieces-if-both-neighbors-are-the-same-color) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] | Medium | +| 2030 | [含特定字母的最小子序列](../../problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 2027 | [转换字符串的最少操作次数](../../problems/minimum-moves-to-convert-string) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Easy | +| 2024 | [考试的最大困扰度](../../problems/maximize-the-confusion-of-an-exam) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2023 | [连接后等于目标字符串的字符串对](../../problems/number-of-pairs-of-strings-with-concatenation-equal-to-target) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2014 | [重复 K 次的最长子序列](../../problems/longest-subsequence-repeated-k-times) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 2011 | [执行操作后的变量值](../../problems/final-value-of-variable-after-performing-operations) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 2000 | [反转单词前缀](../../problems/reverse-prefix-of-word) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 1987 | [不同的好子序列数目](../../problems/number-of-unique-good-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -226,7 +235,7 @@ | 1021 | [删除最外层的括号](../../problems/remove-outermost-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Easy | | 1016 | [子串能表示从 1 到 N 数字的二进制串](../../problems/binary-string-with-substrings-representing-1-to-n) | [[字符串](../string/README.md)] | Medium | | 1003 | [检查替换后的词是否有效](../../problems/check-if-word-is-valid-after-substitutions) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | -| 1002 | [查找常用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 1002 | [查找共用字符](../../problems/find-common-characters) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 990 | [等式方程的可满足性](../../problems/satisfiability-of-equality-equations) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 988 | [从叶结点开始的最小字符串](../../problems/smallest-string-starting-from-leaf) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 984 | [不含 AAA 或 BBB 的字符串](../../problems/string-without-aaa-or-bbb) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 842587dfb..879f2798d 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2000 | [反转单词前缀](../../problems/reverse-prefix-of-word) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 1963 | [使字符串平衡的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-string-balanced) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1877 | [数组中最大数对和的最小值](../../problems/minimize-maximum-pair-sum-in-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -20,7 +21,7 @@ | 1842 | [下个由相同数字构成的回文串](../../problems/next-palindrome-using-same-digits) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Hard | | 1826 | [有缺陷的传感器](../../problems/faulty-sensor) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 1813 | [句子相似性 III](../../problems/sentence-similarity-iii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | -| 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | +| 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1782 | [统计点对的数目](../../problems/count-pairs-of-nodes) | [[图](../graph/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1768 | [交替合并字符串](../../problems/merge-strings-alternately) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 1755 | [最接近目标值的子序列和](../../problems/closest-subsequence-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index 25fb56eb0..9cd25bba1 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -22,7 +22,7 @@ | 1584 | [连接所有点的最小费用](../../problems/min-cost-to-connect-all-points) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] | Medium | | 1579 | [保证图可完全遍历](../../problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | -| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 1559 | [二维网格图中探测环](../../problems/detect-cycles-in-2d-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1489 | [找到最小生成树里的关键边和伪关键边](../../problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[最小生成树](../minimum-spanning-tree/README.md)] [[排序](../sorting/README.md)] [[强连通分量](../strongly-connected-component/README.md)] | Hard | | 1391 | [检查网格中是否存在有效路径](../../problems/check-if-there-is-a-valid-path-in-a-grid) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1361 | [验证二叉树](../../problems/validate-binary-tree-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | From 5792575f74ec336c01ed595249c2471dfbd1ec78 Mon Sep 17 00:00:00 2001 From: Shuo Date: Fri, 19 Nov 2021 16:38:49 +0800 Subject: [PATCH 137/145] A: new --- README.md | 33 ++++- problems/account-balance/README.md | 17 +++ problems/account-balance/mysql_schemas.sql | 7 + problems/accounts-merge/README.md | 4 +- .../README.md | 3 + problems/basic-calculator/README.md | 11 +- .../binary-tree-maximum-path-sum/README.md | 5 +- problems/building-boxes/README.md | 2 +- problems/bulb-switcher-ii/README.md | 40 +++++- .../README.md | 3 - problems/car-fleet-ii/README.md | 7 +- .../README.md | 135 ++++++++++++++++++ .../README.md | 3 + .../README.md | 3 + .../README.md | 3 + .../README.md | 3 + .../README.md | 79 ++++++++++ .../README.md | 3 + .../README.md | 2 +- problems/clone-graph/README.md | 4 +- .../README.md | 2 +- problems/closest-room/README.md | 1 - problems/closest-subsequence-sum/README.md | 6 +- problems/coloring-a-border/README.md | 2 +- problems/combine-two-tables/README.md | 57 ++++++-- problems/combine-two-tables/mysql_schemas.sql | 10 +- problems/confirmation-rate/README.md | 3 + problems/consecutive-characters/README.md | 4 + .../README.md | 2 +- .../construct-k-palindrome-strings/README.md | 2 +- problems/container-with-most-water/README.md | 2 +- problems/contains-duplicate-iii/README.md | 6 +- .../convert-a-number-to-hexadecimal/README.md | 2 +- .../README.md | 2 +- .../convert-bst-to-greater-tree/README.md | 11 +- problems/correct-a-binary-tree/README.md | 6 +- problems/count-good-meals/README.md | 4 + .../README.md | 78 ++++++++++ .../README.md | 4 + problems/count-number-of-teams/README.md | 2 +- .../README.md | 7 +- problems/count-pairs-of-nodes/README.md | 2 +- .../README.md | 7 +- .../README.md | 82 +++++++++++ .../README.md | 3 - problems/create-a-session-bar-chart/README.md | 3 + problems/customers-who-never-order/README.md | 18 +-- .../mysql_schemas.sql | 16 +-- .../decode-the-slanted-ciphertext/README.md | 95 ++++++++++++ problems/decode-ways/README.md | 1 + .../README.md | 3 - .../README.md | 1 + .../design-front-middle-back-queue/README.md | 8 +- problems/design-log-storage-system/README.md | 2 +- .../design-most-recently-used-queue/README.md | 7 +- problems/design-skiplist/README.md | 7 +- problems/design-snake-game/README.md | 2 +- problems/design-underground-system/README.md | 2 +- .../README.md | 3 + .../distribute-repeating-integers/README.md | 2 +- .../README.md | 5 +- .../README.md | 2 +- problems/duplicate-emails/README.md | 8 +- problems/duplicate-emails/mysql_schemas.sql | 8 +- .../README.md | 10 +- .../README.md | 41 ++++-- .../mysql_schemas.sql | 10 +- .../README.md | 2 +- problems/encode-number/README.md | 2 +- problems/exchange-seats/README.md | 71 +++++---- problems/exchange-seats/mysql_schemas.sql | 14 +- problems/falling-squares/README.md | 2 +- .../README.md | 4 +- .../find-all-groups-of-farmland/README.md | 2 +- .../find-customer-referee/mysql_schemas.sql | 16 +-- .../find-distance-in-a-binary-tree/README.md | 2 +- .../README.md | 2 +- .../README.md | 5 +- .../README.md | 4 +- .../README.md | 87 +++++++++++ problems/find-the-missing-ids/README.md | 5 + .../README.md | 5 +- .../README.md | 2 +- problems/first-unique-number/README.md | 4 +- problems/fizz-buzz-multithreaded/README.md | 4 + .../README.md | 2 +- .../furthest-building-you-can-reach/README.md | 2 +- problems/gas-station/README.md | 4 +- .../get-maximum-in-generated-array/README.md | 8 +- .../README.md | 2 +- problems/graph-valid-tree/README.md | 1 + problems/h-index/README.md | 2 +- problems/hopper-company-queries-i/README.md | 5 + .../README.md | 2 +- problems/index-pairs-of-a-string/README.md | 2 +- problems/integer-replacement/README.md | 3 +- .../investments-in-2016/mysql_schemas.sql | 12 +- problems/ip-to-cidr/README.md | 2 +- problems/iterator-for-combination/README.md | 14 +- problems/k-diff-pairs-in-an-array/README.md | 2 + problems/keys-and-rooms/README.md | 3 - problems/kill-process/README.md | 4 +- .../kth-ancestor-of-a-tree-node/README.md | 4 +- .../kth-distinct-string-in-an-array/README.md | 70 +++++++++ .../largest-merge-of-two-strings/README.md | 2 +- problems/largest-subarray-length-k/README.md | 2 +- .../README.md | 1 + problems/linked-list-components/README.md | 2 +- .../longest-duplicate-substring/README.md | 4 +- .../README.md | 2 +- .../longest-increasing-subsequence/README.md | 2 + problems/longest-nice-substring/README.md | 2 +- .../longest-palindromic-subsequence/README.md | 4 + .../longest-palindromic-substring/README.md | 2 +- .../README.md | 4 + .../README.md | 8 +- .../README.md | 8 ++ .../README.md | 11 +- .../README.md | 3 + problems/make-sum-divisible-by-p/README.md | 3 + .../README.md | 2 +- problems/map-of-highest-peak/README.md | 2 +- .../max-chunks-to-make-sorted-ii/README.md | 2 +- problems/max-number-of-k-sum-pairs/README.md | 4 + .../README.md | 5 +- .../README.md | 3 + .../README.md | 2 +- .../README.md | 3 + problems/maximum-average-pass-ratio/README.md | 2 +- problems/maximum-average-subtree/README.md | 3 + .../README.md | 2 +- .../README.md | 3 +- problems/maximum-equal-frequency/README.md | 4 +- .../README.md | 5 +- .../README.md | 4 +- .../README.md | 5 + .../README.md | 98 +++++++++++++ .../README.md | 5 + .../maximum-path-quality-of-a-graph/README.md | 94 ++++++++++++ .../README.md | 4 + .../README.md | 2 +- .../README.md | 2 +- .../README.md | 5 +- .../README.md | 3 + .../README.md | 4 +- .../README.md | 6 +- problems/merge-strings-alternately/README.md | 3 + .../min-cost-to-connect-all-points/README.md | 2 +- .../minimize-deviation-in-array/README.md | 4 +- .../README.md | 5 +- .../README.md | 86 +++++++++++ .../minimum-absolute-sum-difference/README.md | 2 +- .../README.md | 8 +- .../README.md | 4 +- .../README.md | 34 +++++ .../README.md | 2 +- .../README.md | 2 +- .../README.md | 2 +- problems/minimum-falling-path-sum/README.md | 26 ++-- problems/minimum-incompatibility/README.md | 2 +- .../README.md | 2 +- .../minimum-jumps-to-reach-home/README.md | 2 +- .../minimum-limit-of-balls-in-a-bag/README.md | 3 + .../README.md | 19 +-- .../README.md | 9 +- .../README.md | 3 + .../README.md | 2 +- .../README.md | 9 +- .../README.md | 2 +- .../README.md | 5 +- .../README.md | 107 ++++++++++++++ .../README.md | 2 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 12 +- .../README.md | 8 +- problems/missing-number/README.md | 5 +- .../README.md | 79 ++++++++++ problems/movie-rating/mysql_schemas.sql | 22 +-- .../README.md | 76 ++++++++++ problems/non-overlapping-intervals/README.md | 2 +- problems/not-boring-movies/README.md | 14 +- problems/nth-highest-salary/README.md | 46 +++++- problems/nth-highest-salary/mysql_schemas.sql | 5 + .../README.md | 40 ++++++ .../README.md | 2 +- .../README.md | 4 +- .../README.md | 35 +++++ .../README.md | 5 +- .../README.md | 1 + .../README.md | 116 +++++++++++++++ .../README.md | 85 +++++++++++ .../README.md | 2 +- .../README.md | 10 +- .../README.md | 3 - .../README.md | 5 +- problems/palindrome-partitioning-ii/README.md | 1 + problems/parallel-courses-iii/README.md | 88 ++++++++++++ problems/path-sum-ii/README.md | 2 +- .../path-with-maximum-minimum-value/README.md | 7 +- .../path-with-maximum-probability/README.md | 5 +- problems/path-with-minimum-effort/README.md | 10 +- .../README.md | 3 + problems/plates-between-candles/README.md | 71 +++++++++ problems/power-of-two/README.md | 2 +- problems/powx-n/README.md | 2 +- problems/predict-the-winner/README.md | 2 +- .../README.md | 4 +- .../README.md | 83 +++++++++++ problems/product-sales-analysis-ii/README.md | 4 + .../mysql_schemas.sql | 4 +- problems/product-sales-analysis-iii/README.md | 3 + .../mysql_schemas.sql | 4 +- .../put-boxes-into-the-warehouse-i/README.md | 5 +- problems/random-pick-index/README.md | 2 +- problems/rank-scores/README.md | 10 +- problems/rank-scores/mysql_schemas.sql | 14 +- problems/rearrange-products-table/README.md | 3 + .../rearrange-spaces-between-words/README.md | 3 + .../README.md | 5 +- .../README.md | 2 +- problems/rectangle-area/README.md | 2 +- problems/reformat-department-table/README.md | 29 ++-- .../README.md | 5 +- problems/remove-duplicate-letters/README.md | 5 +- .../README.md | 3 + problems/reorganize-string/README.md | 4 +- problems/reshape-the-matrix/README.md | 3 + problems/restore-ip-addresses/README.md | 10 +- problems/reverse-bits/README.md | 4 +- problems/reverse-integer/README.md | 4 +- .../README.md | 121 ++++++++++++++++ .../README.md | 2 +- .../README.md | 2 +- problems/sentence-screen-fitting/README.md | 3 + problems/sequence-reconstruction/README.md | 2 +- problems/shopping-offers/README.md | 4 +- problems/short-encoding-of-words/README.md | 2 +- problems/single-number-ii/README.md | 2 +- problems/single-number/README.md | 2 +- .../smallest-index-with-equal-value/README.md | 75 ++++++++++ .../sort-features-by-popularity/README.md | 4 + .../README.md | 35 +++++ problems/spiral-matrix/README.md | 1 + .../README.md | 2 +- problems/stone-game-iv/README.md | 7 - problems/stone-game-vi/README.md | 14 +- problems/stone-game-vii/README.md | 11 -- problems/string-to-integer-atoi/README.md | 2 +- .../strings-differ-by-one-character/README.md | 2 +- problems/strobogrammatic-number-ii/README.md | 2 +- problems/strong-friendship/README.md | 3 + .../sum-of-all-subset-xor-totals/README.md | 2 + .../README.md | 17 +++ .../mysql_schemas.sql | 21 +++ .../README.md | 3 - problems/the-winner-university/README.md | 17 +++ .../the-winner-university/mysql_schemas.sql | 8 ++ problems/throne-inheritance/README.md | 5 +- problems/time-based-key-value-store/README.md | 7 +- problems/time-needed-to-buy-tickets/README.md | 69 +++++++++ .../README.md | 2 +- problems/trips-and-users/README.md | 40 +++--- problems/trips-and-users/mysql_schemas.sql | 40 +++--- .../two-best-non-overlapping-events/README.md | 70 +++++++++ problems/two-city-scheduling/README.md | 2 +- problems/ugly-number-ii/README.md | 3 +- .../unique-binary-search-trees-ii/README.md | 4 +- problems/unique-binary-search-trees/README.md | 4 +- problems/utf-8-validation/README.md | 2 +- problems/vowels-of-all-substrings/README.md | 83 +++++++++++ .../walking-robot-simulation-ii/README.md | 88 ++++++++++++ problems/web-crawler-multithreaded/README.md | 3 + problems/web-crawler/README.md | 5 +- problems/where-will-the-ball-fall/README.md | 2 +- problems/xor-operation-in-an-array/README.md | 2 +- problems/zigzag-conversion/README.md | 2 +- readme/1-300.md | 8 +- readme/1201-1500.md | 2 +- readme/301-600.md | 2 +- readme/601-900.md | 2 +- readme/901-1200.md | 2 +- tag/array/README.md | 28 +++- tag/backtracking/README.md | 6 +- tag/binary-search/README.md | 11 +- tag/binary-tree/README.md | 1 + tag/bit-manipulation/README.md | 4 +- tag/breadth-first-search/README.md | 4 +- tag/combinatorics/README.md | 2 + tag/counting/README.md | 3 + tag/depth-first-search/README.md | 7 +- tag/design/README.md | 1 + tag/dynamic-programming/README.md | 10 +- tag/enumeration/README.md | 1 + tag/eulerian-circuit/README.md | 2 +- tag/graph/README.md | 4 +- tag/greedy/README.md | 3 +- tag/hash-table/README.md | 9 +- tag/heap-priority-queue/README.md | 1 + tag/linked-list/README.md | 3 + tag/math/README.md | 5 +- tag/matrix/README.md | 1 + tag/memoization/README.md | 3 +- tag/monotonic-queue/README.md | 1 + tag/monotonic-stack/README.md | 1 + tag/ordered-set/README.md | 2 +- tag/prefix-sum/README.md | 4 +- tag/queue/README.md | 2 + tag/simulation/README.md | 5 + tag/sliding-window/README.md | 1 + tag/sorting/README.md | 7 +- tag/stack/README.md | 1 + tag/string/README.md | 14 +- tag/topological-sort/README.md | 1 + tag/tree/README.md | 1 + tag/trie/README.md | 2 +- tag/two-pointers/README.md | 5 +- 317 files changed, 3368 insertions(+), 586 deletions(-) create mode 100644 problems/account-balance/README.md create mode 100644 problems/account-balance/mysql_schemas.sql create mode 100644 problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md create mode 100644 problems/check-whether-two-strings-are-almost-equivalent/README.md create mode 100644 problems/count-nodes-with-the-highest-score/README.md create mode 100644 problems/count-vowel-substrings-of-a-string/README.md create mode 100644 problems/decode-the-slanted-ciphertext/README.md create mode 100644 problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md create mode 100644 problems/kth-distinct-string-in-an-array/README.md create mode 100644 problems/maximum-number-of-tasks-you-can-assign/README.md create mode 100644 problems/maximum-path-quality-of-a-graph/README.md create mode 100644 problems/minimized-maximum-of-products-distributed-to-any-store/README.md create mode 100644 problems/minimum-cost-to-separate-sentence-into-rows/README.md create mode 100644 problems/minimum-operations-to-convert-number/README.md create mode 100644 problems/most-beautiful-item-for-each-query/README.md create mode 100644 problems/next-greater-numerically-balanced-number/README.md create mode 100644 problems/nth-highest-salary/mysql_schemas.sql create mode 100644 problems/number-of-equal-count-substrings/README.md create mode 100644 problems/number-of-spaces-cleaning-robot-cleaned/README.md create mode 100644 problems/number-of-valid-move-combinations-on-chessboard/README.md create mode 100644 problems/number-of-valid-words-in-a-sentence/README.md create mode 100644 problems/parallel-courses-iii/README.md create mode 100644 problems/plates-between-candles/README.md create mode 100644 problems/process-restricted-friend-requests/README.md create mode 100644 problems/reverse-nodes-in-even-length-groups/README.md create mode 100644 problems/smallest-index-with-equal-value/README.md create mode 100644 problems/sort-linked-list-already-sorted-using-absolute-values/README.md create mode 100644 problems/the-category-of-each-member-in-the-store/README.md create mode 100644 problems/the-category-of-each-member-in-the-store/mysql_schemas.sql create mode 100644 problems/the-winner-university/README.md create mode 100644 problems/the-winner-university/mysql_schemas.sql create mode 100644 problems/time-needed-to-buy-tickets/README.md create mode 100644 problems/two-best-non-overlapping-events/README.md create mode 100644 problems/vowels-of-all-substrings/README.md create mode 100644 problems/walking-robot-simulation-ii/README.md diff --git a/README.md b/README.md index 9bfff812b..f967b5ab9 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,37 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 2076 | [Process Restricted Friend Requests](https://leetcode.com/problems/process-restricted-friend-requests "处理含限制条件的好友请求") | [Go](problems/process-restricted-friend-requests) | Hard | +| 2075 | [Decode the Slanted Ciphertext](https://leetcode.com/problems/decode-the-slanted-ciphertext "解码斜向换位密码") | [Go](problems/decode-the-slanted-ciphertext) | Medium | +| 2074 | [Reverse Nodes in Even Length Groups](https://leetcode.com/problems/reverse-nodes-in-even-length-groups "反转偶数长度组的节点") | [Go](problems/reverse-nodes-in-even-length-groups) | Medium | +| 2073 | [Time Needed to Buy Tickets](https://leetcode.com/problems/time-needed-to-buy-tickets "买票需要的时间") | [Go](problems/time-needed-to-buy-tickets) | Easy | +| 2072 | [The Winner University](https://leetcode.com/problems/the-winner-university) 🔒 | [MySQL](problems/the-winner-university) | Easy | +| 2071 | [Maximum Number of Tasks You Can Assign](https://leetcode.com/problems/maximum-number-of-tasks-you-can-assign "你可以安排的最多任务数目") | [Go](problems/maximum-number-of-tasks-you-can-assign) | Hard | +| 2070 | [Most Beautiful Item for Each Query](https://leetcode.com/problems/most-beautiful-item-for-each-query "每一个查询的最大美丽值") | [Go](problems/most-beautiful-item-for-each-query) | Medium | +| 2069 | [Walking Robot Simulation II](https://leetcode.com/problems/walking-robot-simulation-ii "模拟行走机器人 II") | [Go](problems/walking-robot-simulation-ii) | Medium | +| 2068 | [Check Whether Two Strings are Almost Equivalent](https://leetcode.com/problems/check-whether-two-strings-are-almost-equivalent "检查两个字符串是否几乎相等") | [Go](problems/check-whether-two-strings-are-almost-equivalent) | Easy | +| 2067 | [Number of Equal Count Substrings](https://leetcode.com/problems/number-of-equal-count-substrings) 🔒 | [Go](problems/number-of-equal-count-substrings) | Medium | +| 2066 | [Account Balance](https://leetcode.com/problems/account-balance) 🔒 | [MySQL](problems/account-balance) | Medium | +| 2065 | [Maximum Path Quality of a Graph](https://leetcode.com/problems/maximum-path-quality-of-a-graph "最大化一张图中的路径价值") | [Go](problems/maximum-path-quality-of-a-graph) | Hard | +| 2064 | [Minimized Maximum of Products Distributed to Any Store](https://leetcode.com/problems/minimized-maximum-of-products-distributed-to-any-store "分配给商店的最多商品的最小值") | [Go](problems/minimized-maximum-of-products-distributed-to-any-store) | Medium | +| 2063 | [Vowels of All Substrings](https://leetcode.com/problems/vowels-of-all-substrings "所有子字符串中的元音") | [Go](problems/vowels-of-all-substrings) | Medium | +| 2062 | [Count Vowel Substrings of a String](https://leetcode.com/problems/count-vowel-substrings-of-a-string "统计字符串中的元音子字符串") | [Go](problems/count-vowel-substrings-of-a-string) | Easy | +| 2061 | [Number of Spaces Cleaning Robot Cleaned](https://leetcode.com/problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [Go](problems/number-of-spaces-cleaning-robot-cleaned) | Medium | +| 2060 | [Check if an Original String Exists Given Two Encoded Strings](https://leetcode.com/problems/check-if-an-original-string-exists-given-two-encoded-strings "同源字符串检测") | [Go](problems/check-if-an-original-string-exists-given-two-encoded-strings) | Hard | +| 2059 | [Minimum Operations to Convert Number](https://leetcode.com/problems/minimum-operations-to-convert-number "转化数字的最小运算数") | [Go](problems/minimum-operations-to-convert-number) | Medium | +| 2058 | [Find the Minimum and Maximum Number of Nodes Between Critical Points](https://leetcode.com/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points "找出临界点之间的最小和最大距离") | [Go](problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points) | Medium | +| 2057 | [Smallest Index With Equal Value](https://leetcode.com/problems/smallest-index-with-equal-value "值相等的最小索引") | [Go](problems/smallest-index-with-equal-value) | Easy | +| 2056 | [Number of Valid Move Combinations On Chessboard](https://leetcode.com/problems/number-of-valid-move-combinations-on-chessboard "棋盘上有效移动组合的数目") | [Go](problems/number-of-valid-move-combinations-on-chessboard) | Hard | +| 2055 | [Plates Between Candles](https://leetcode.com/problems/plates-between-candles "蜡烛之间的盘子") | [Go](problems/plates-between-candles) | Medium | +| 2054 | [Two Best Non-Overlapping Events](https://leetcode.com/problems/two-best-non-overlapping-events "两个最好的不重叠活动") | [Go](problems/two-best-non-overlapping-events) | Medium | +| 2053 | [Kth Distinct String in an Array](https://leetcode.com/problems/kth-distinct-string-in-an-array "数组中第 K 个独一无二的字符串") | [Go](problems/kth-distinct-string-in-an-array) | Easy | +| 2052 | [Minimum Cost to Separate Sentence Into Rows](https://leetcode.com/problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [Go](problems/minimum-cost-to-separate-sentence-into-rows) | Medium | +| 2051 | [The Category of Each Member in the Store](https://leetcode.com/problems/the-category-of-each-member-in-the-store) 🔒 | [MySQL](problems/the-category-of-each-member-in-the-store) | Medium | +| 2050 | [Parallel Courses III](https://leetcode.com/problems/parallel-courses-iii "并行课程 III") | [Go](problems/parallel-courses-iii) | Hard | +| 2049 | [Count Nodes With the Highest Score](https://leetcode.com/problems/count-nodes-with-the-highest-score "统计最高分的节点数目") | [Go](problems/count-nodes-with-the-highest-score) | Medium | +| 2048 | [Next Greater Numerically Balanced Number](https://leetcode.com/problems/next-greater-numerically-balanced-number "下一个更大的数值平衡数") | [Go](problems/next-greater-numerically-balanced-number) | Medium | +| 2047 | [Number of Valid Words in a Sentence](https://leetcode.com/problems/number-of-valid-words-in-a-sentence "句子中的有效单词数") | [Go](problems/number-of-valid-words-in-a-sentence) | Easy | +| 2046 | [Sort Linked List Already Sorted Using Absolute Values](https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [Go](problems/sort-linked-list-already-sorted-using-absolute-values) | Medium | | 2045 | [Second Minimum Time to Reach Destination](https://leetcode.com/problems/second-minimum-time-to-reach-destination "到达目的地的第二短时间") | [Go](problems/second-minimum-time-to-reach-destination) | Hard | | 2044 | [Count Number of Maximum Bitwise-OR Subsets](https://leetcode.com/problems/count-number-of-maximum-bitwise-or-subsets "统计按位或能得到最大值的子集数目") | [Go](problems/count-number-of-maximum-bitwise-or-subsets) | Medium | | 2043 | [Simple Bank System](https://leetcode.com/problems/simple-bank-system "简易银行系统") | [Go](problems/simple-bank-system) | Medium | @@ -158,7 +189,7 @@ LeetCode Problems' Solutions | 1968 | [Array With Elements Not Equal to Average of Neighbors](https://leetcode.com/problems/array-with-elements-not-equal-to-average-of-neighbors "构造元素不等于两相邻元素平均值的数组") | [Go](problems/array-with-elements-not-equal-to-average-of-neighbors) | Medium | | 1967 | [Number of Strings That Appear as Substrings in Word](https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word "作为子字符串出现在单词中的字符串数目") | [Go](problems/number-of-strings-that-appear-as-substrings-in-word) | Easy | | 1966 | [Binary Searchable Numbers in an Unsorted Array](https://leetcode.com/problems/binary-searchable-numbers-in-an-unsorted-array) 🔒 | [Go](problems/binary-searchable-numbers-in-an-unsorted-array) | Medium | -| 1965 | [Employees With Missing Information](https://leetcode.com/problems/employees-with-missing-information) 🔒 | [MySQL](problems/employees-with-missing-information) | Easy | +| 1965 | [Employees With Missing Information](https://leetcode.com/problems/employees-with-missing-information "丢失信息的雇员") 🔒 | [MySQL](problems/employees-with-missing-information) | Easy | | 1964 | [Find the Longest Valid Obstacle Course at Each Position](https://leetcode.com/problems/find-the-longest-valid-obstacle-course-at-each-position "找出到每个位置为止最长的有效障碍赛跑路线") | [Go](problems/find-the-longest-valid-obstacle-course-at-each-position) | Hard | | 1963 | [Minimum Number of Swaps to Make the String Balanced](https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-string-balanced "使字符串平衡的最小交换次数") | [Go](problems/minimum-number-of-swaps-to-make-the-string-balanced) | Medium | | 1962 | [Remove Stones to Minimize the Total](https://leetcode.com/problems/remove-stones-to-minimize-the-total "移除石子使总数最小") | [Go](problems/remove-stones-to-minimize-the-total) | Medium | diff --git a/problems/account-balance/README.md b/problems/account-balance/README.md new file mode 100644 index 000000000..a06c26130 --- /dev/null +++ b/problems/account-balance/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../maximum-path-quality-of-a-graph "Maximum Path Quality of a Graph") +                 +[Next >](../number-of-equal-count-substrings "Number of Equal Count Substrings") + +## [2066. Account Balance (Medium)](https://leetcode.com/problems/account-balance "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/account-balance/mysql_schemas.sql b/problems/account-balance/mysql_schemas.sql new file mode 100644 index 000000000..74d4a5114 --- /dev/null +++ b/problems/account-balance/mysql_schemas.sql @@ -0,0 +1,7 @@ +Create table If Not Exists Transactions (account_id int, day date, type ENUM('Deposit', 'Withdraw'), amount int); +Truncate table Transactions; +insert into Transactions (account_id, day, type, amount) values ('1', '2021-11-07', 'Deposit', '2000'); +insert into Transactions (account_id, day, type, amount) values ('1', '2021-11-09', 'Withdraw', '1000'); +insert into Transactions (account_id, day, type, amount) values ('1', '2021-11-11', 'Deposit', '3000'); +insert into Transactions (account_id, day, type, amount) values ('2', '2021-12-07', 'Deposit', '7000'); +insert into Transactions (account_id, day, type, amount) values ('2', '2021-12-12', 'Withdraw', '7000'); diff --git a/problems/accounts-merge/README.md b/problems/accounts-merge/README.md index 939f314ea..63f2c14d2 100644 --- a/problems/accounts-merge/README.md +++ b/problems/accounts-merge/README.md @@ -24,8 +24,8 @@ Input: accounts = [["John","johnsmith@mail.com","john_newyork@mail.com"],["John","johnsmith@mail.com","john00@mail.com"],["Mary","mary@mail.com"],["John","johnnybravo@mail.com"]] Output: [["John","john00@mail.com","john_newyork@mail.com","johnsmith@mail.com"],["Mary","mary@mail.com"],["John","johnnybravo@mail.com"]] Explanation: -The first and third John's are the same person as they have the common email "johnsmith@mail.com". -The second John and Mary are different people as none of their email addresses are used by other accounts. +The first and second John's are the same person as they have the common email "johnsmith@mail.com". +The third John and Mary are different people as none of their email addresses are used by other accounts. We could return these lists in any order, for example the answer [['Mary', 'mary@mail.com'], ['John', 'johnnybravo@mail.com'], ['John', 'john00@mail.com', 'john_newyork@mail.com', 'johnsmith@mail.com']] would still be accepted.
    diff --git a/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md b/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md index 8b13a5d53..e3b2a3f1f 100644 --- a/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md +++ b/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md @@ -12,3 +12,6 @@ ## [1951. All the Pairs With the Maximum Number of Common Followers (Medium)](https://leetcode.com/problems/all-the-pairs-with-the-maximum-number-of-common-followers "查询具有最多共同关注者的所有两两结对组") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/basic-calculator/README.md b/problems/basic-calculator/README.md index d6bb98e79..df8bef877 100644 --- a/problems/basic-calculator/README.md +++ b/problems/basic-calculator/README.md @@ -41,20 +41,20 @@

    Constraints:

      -
    • 1 <= s.length <= 3 * 105
    • +
    • 1 <= s.length <= 3 * 105
    • s consists of digits, '+', '-', '(', ')', and ' '.
    • s represents a valid expression.
    • -
    • '+' is not used as a unary operation.
    • -
    • '-' could be used as a unary operation and in this case, it will not be used directly after a +ve or -ve signs (will be inside parentheses).
    • +
    • '+' is not used as a unary operation (i.e., "+1" and "+(2 + 3)" is invalid).
    • +
    • '-' could be used as a unary operation (i.e., "-1" and "-(2 + 3)" is valid).
    • There will be no two consecutive operators in the input.
    • Every number and running calculation will fit in a signed 32-bit integer.
    ### Related Topics - [[Math](../../tag/math/README.md)] - [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Recursion](../../tag/recursion/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Evaluate Reverse Polish Notation](../evaluate-reverse-polish-notation) (Medium) @@ -62,4 +62,3 @@ 1. [Different Ways to Add Parentheses](../different-ways-to-add-parentheses) (Medium) 1. [Expression Add Operators](../expression-add-operators) (Hard) 1. [Basic Calculator III](../basic-calculator-iii) (Hard) - 1. [The Score of Students Solving Math Expression](../the-score-of-students-solving-math-expression) (Hard) diff --git a/problems/binary-tree-maximum-path-sum/README.md b/problems/binary-tree-maximum-path-sum/README.md index f964f3ee9..52c632575 100644 --- a/problems/binary-tree-maximum-path-sum/README.md +++ b/problems/binary-tree-maximum-path-sum/README.md @@ -15,7 +15,7 @@

    The path sum of a path is the sum of the node's values in the path.

    -

    Given the root of a binary tree, return the maximum path sum of any path.

    +

    Given the root of a binary tree, return the maximum path sum of any non-empty path.

     

    Example 1:

    @@ -43,9 +43,9 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions @@ -53,3 +53,4 @@ 1. [Sum Root to Leaf Numbers](../sum-root-to-leaf-numbers) (Medium) 1. [Path Sum IV](../path-sum-iv) (Medium) 1. [Longest Univalue Path](../longest-univalue-path) (Medium) + 1. [Time Needed to Inform All Employees](../time-needed-to-inform-all-employees) (Medium) diff --git a/problems/building-boxes/README.md b/problems/building-boxes/README.md index dfbb7aae7..f00a11199 100644 --- a/problems/building-boxes/README.md +++ b/problems/building-boxes/README.md @@ -61,9 +61,9 @@ These boxes are placed in the corner of the room, where the corner is on the bac ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/bulb-switcher-ii/README.md b/problems/bulb-switcher-ii/README.md index 48862a5f5..c2af65e7a 100644 --- a/problems/bulb-switcher-ii/README.md +++ b/problems/bulb-switcher-ii/README.md @@ -20,9 +20,9 @@
  • Button 4: Flips the status of all the bulbs with a label j = 3k + 1 where k = 0, 1, 2, ... (i.e., 1, 4, 7, 10, ...).
  • -

    You will press one of the four mentioned buttons exactly presses times.

    +

    You must make exactly presses button presses in total. For each press, you may pick any of the four buttons to press.

    -

    Given the two integers n and presses, return the number of different statuses after pressing the four buttons exactly presses times.

    +

    Given the two integers n and presses, return the number of different possible statuses after performing all presses button presses.

     

    Example 1:

    @@ -30,7 +30,9 @@
     Input: n = 1, presses = 1
     Output: 2
    -Explanation: Status can be: [on], [off].
    +Explanation: Status can be:
    +- [off] by pressing button 1
    +- [on] by pressing button 2
     

    Example 2:

    @@ -38,7 +40,10 @@
     Input: n = 2, presses = 1
     Output: 3
    -Explanation: Status can be: [on, off], [off, on], [off, off].
    +Explanation: Status can be:
    +- [off, off] by pressing button 1
    +- [on, off] by pressing button 2
    +- [off, on] by pressing button 3
     

    Example 3:

    @@ -46,7 +51,29 @@
     Input: n = 3, presses = 1
     Output: 4
    -Explanation: Status can be: [off, on, off], [on, off, on], [off, off, off], [off, on, on].
    +Explanation: Status can be:
    +- [off, off, off] by pressing button 1
    +- [off, on, off] by pressing button 2
    +- [on, off, on] by pressing button 3
    +- [off, on, on] by pressing button 4
    +
    + +

    Example 4:

    + +
    +Input: n = 1, presses = 0
    +Output: 1
    +Explanation: Status can only be [on] since you cannot press any of the buttons.
    +
    + +

    Example 5:

    + +
    +Input: n = 1, presses = 2
    +Output: 2
    +Explanation: Status can be:
    +- [off] by pressing button 1 then button 1 again
    +- [on] by pressing button 1 then button 2
     

     

    @@ -58,10 +85,11 @@ ### Related Topics + [[Math](../../tag/math/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Bulb Switcher](../bulb-switcher) (Medium) + 1. [Bulb Switcher III](../bulb-switcher-iii) (Medium) diff --git a/problems/can-make-arithmetic-progression-from-sequence/README.md b/problems/can-make-arithmetic-progression-from-sequence/README.md index 9839584f7..3a893b278 100644 --- a/problems/can-make-arithmetic-progression-from-sequence/README.md +++ b/problems/can-make-arithmetic-progression-from-sequence/README.md @@ -44,9 +44,6 @@ [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Arithmetic Subarrays](../arithmetic-subarrays) (Medium) - ### Hints
    Hint 1 diff --git a/problems/car-fleet-ii/README.md b/problems/car-fleet-ii/README.md index e1c563772..cae3f8577 100644 --- a/problems/car-fleet-ii/README.md +++ b/problems/car-fleet-ii/README.md @@ -48,11 +48,14 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Monotonic Stack](../../tag/monotonic-stack/README.md)] + [[Stack](../../tag/stack/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] + +### Similar Questions + 1. [Car Fleet](../car-fleet) (Medium) ### Hints
    diff --git a/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md b/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md new file mode 100644 index 000000000..028c57844 --- /dev/null +++ b/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md @@ -0,0 +1,135 @@ + + + + + + + +[< Previous](../minimum-operations-to-convert-number "Minimum Operations to Convert Number") +                 +[Next >](../number-of-spaces-cleaning-robot-cleaned "Number of Spaces Cleaning Robot Cleaned") + +## [2060. Check if an Original String Exists Given Two Encoded Strings (Hard)](https://leetcode.com/problems/check-if-an-original-string-exists-given-two-encoded-strings "同源字符串检测") + +

    An original string, consisting of lowercase English letters, can be encoded by the following steps:

    + +
      +
    • Arbitrarily split it into a sequence of some number of non-empty substrings.
    • +
    • Arbitrarily choose some elements (possibly none) of the sequence, and replace each with its length (as a numeric string).
    • +
    • Concatenate the sequence as the encoded string.
    • +
    + +

    For example, one way to encode an original string "abcdefghijklmnop" might be:

    + +
      +
    • Split it as a sequence: ["ab", "cdefghijklmn", "o", "p"].
    • +
    • Choose the second and third elements to be replaced by their lengths, respectively. The sequence becomes ["ab", "12", "1", "p"].
    • +
    • Concatenate the elements of the sequence to get the encoded string: "ab121p".
    • +
    + +

    Given two encoded strings s1 and s2, consisting of lowercase English letters and digits 1-9 (inclusive), return true if there exists an original string that could be encoded as both s1 and s2. Otherwise, return false.

    + +

    Note: The test cases are generated such that the number of consecutive digits in s1 and s2 does not exceed 3.

    + +

     

    +

    Example 1:

    + +
    +Input: s1 = "internationalization", s2 = "i18n"
    +Output: true
    +Explanation: It is possible that "internationalization" was the original string.
    +- "internationalization" 
    +  -> Split:       ["internationalization"]
    +  -> Do not replace any element
    +  -> Concatenate:  "internationalization", which is s1.
    +- "internationalization"
    +  -> Split:       ["i", "nternationalizatio", "n"]
    +  -> Replace:     ["i", "18",                 "n"]
    +  -> Concatenate:  "i18n", which is s2
    +
    + +

    Example 2:

    + +
    +Input: s1 = "l123e", s2 = "44"
    +Output: true
    +Explanation: It is possible that "leetcode" was the original string.
    +- "leetcode" 
    +  -> Split:      ["l", "e", "et", "cod", "e"]
    +  -> Replace:    ["l", "1", "2",  "3",   "e"]
    +  -> Concatenate: "l123e", which is s1.
    +- "leetcode" 
    +  -> Split:      ["leet", "code"]
    +  -> Replace:    ["4",    "4"]
    +  -> Concatenate: "44", which is s2.
    +
    + +

    Example 3:

    + +
    +Input: s1 = "a5b", s2 = "c5b"
    +Output: false
    +Explanation: It is impossible.
    +- The original string encoded as s1 must start with the letter 'a'.
    +- The original string encoded as s2 must start with the letter 'c'.
    +
    + +

    Example 4:

    + +
    +Input: s1 = "112s", s2 = "g841"
    +Output: true
    +Explanation: It is possible that "gaaaaaaaaaaaas" was the original string
    +- "gaaaaaaaaaaaas"
    +  -> Split:      ["g", "aaaaaaaaaaaa", "s"]
    +  -> Replace:    ["1", "12",           "s"]
    +  -> Concatenate: "112s", which is s1.
    +- "gaaaaaaaaaaaas"
    +  -> Split:      ["g", "aaaaaaaa", "aaaa", "s"]
    +  -> Replace:    ["g", "8",        "4",    "1"]
    +  -> Concatenate: "g841", which is s2.
    +
    + +

    Example 5:

    + +
    +Input: s1 = "ab", s2 = "a2"
    +Output: false
    +Explanation: It is impossible.
    +- The original string encoded as s1 has two letters.
    +- The original string encoded as s2 has three letters.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s1.length, s2.length <= 40
    • +
    • s1 and s2 consist of digits 1-9 (inclusive), and lowercase English letters only.
    • +
    • The number of consecutive digits in s1 and s2 does not exceed 3.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +For s1 and s2, divide each into a sequence of single alphabet strings and digital strings. The problem now becomes comparing if two sequences are equal. +
    + +
    +Hint 2 +A single alphabet string has no variation, but a digital string has variations. For example: "124" can be interpreted as 1+2+4, 12+4, 1+24, and 124 wildcard characters. +
    + +
    +Hint 3 +There are four kinds of comparisons: a single alphabet vs another; a single alphabet vs a number, a number vs a single alphabet, and a number vs another number. In the case of a number vs another (a single alphabet or a number), can you decrease the number by the min length of both? +
    + +
    +Hint 4 +There is a recurrence relation in the search which ends when either a single alphabet != another, or one sequence ran out, or both sequences ran out. +
    diff --git a/problems/check-if-number-is-a-sum-of-powers-of-three/README.md b/problems/check-if-number-is-a-sum-of-powers-of-three/README.md index 49f9a0f36..f8170ffb3 100644 --- a/problems/check-if-number-is-a-sum-of-powers-of-three/README.md +++ b/problems/check-if-number-is-a-sum-of-powers-of-three/README.md @@ -49,6 +49,9 @@ ### Related Topics [[Math](../../tag/math/README.md)] +### Similar Questions + 1. [Power of Three](../power-of-three) (Easy) + ### Hints
    Hint 1 diff --git a/problems/check-if-one-string-swap-can-make-strings-equal/README.md b/problems/check-if-one-string-swap-can-make-strings-equal/README.md index ec504c532..a328452f3 100644 --- a/problems/check-if-one-string-swap-can-make-strings-equal/README.md +++ b/problems/check-if-one-string-swap-can-make-strings-equal/README.md @@ -61,6 +61,9 @@ [[String](../../tag/string/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Buddy Strings](../buddy-strings) (Easy) + ### Hints
    Hint 1 diff --git a/problems/check-if-two-expression-trees-are-equivalent/README.md b/problems/check-if-two-expression-trees-are-equivalent/README.md index 7b0b251b7..cc128802b 100644 --- a/problems/check-if-two-expression-trees-are-equivalent/README.md +++ b/problems/check-if-two-expression-trees-are-equivalent/README.md @@ -18,6 +18,9 @@ [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Build Binary Expression Tree From Infix Expression](../build-binary-expression-tree-from-infix-expression) (Hard) + ### Hints
    Hint 1 diff --git a/problems/check-if-two-string-arrays-are-equivalent/README.md b/problems/check-if-two-string-arrays-are-equivalent/README.md index 55153a000..f06c09fce 100644 --- a/problems/check-if-two-string-arrays-are-equivalent/README.md +++ b/problems/check-if-two-string-arrays-are-equivalent/README.md @@ -54,6 +54,9 @@ The strings are the same, so return true. [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Check if an Original String Exists Given Two Encoded Strings](../check-if-an-original-string-exists-given-two-encoded-strings) (Hard) + ### Hints
    Hint 1 diff --git a/problems/check-whether-two-strings-are-almost-equivalent/README.md b/problems/check-whether-two-strings-are-almost-equivalent/README.md new file mode 100644 index 000000000..fc14405ad --- /dev/null +++ b/problems/check-whether-two-strings-are-almost-equivalent/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../number-of-equal-count-substrings "Number of Equal Count Substrings") +                 +[Next >](../walking-robot-simulation-ii "Walking Robot Simulation II") + +## [2068. Check Whether Two Strings are Almost Equivalent (Easy)](https://leetcode.com/problems/check-whether-two-strings-are-almost-equivalent "检查两个字符串是否几乎相等") + +

    Two strings word1 and word2 are considered almost equivalent if the differences between the frequencies of each letter from 'a' to 'z' between word1 and word2 is at most 3.

    + +

    Given two strings word1 and word2, each of length n, return true if word1 and word2 are almost equivalent, or false otherwise.

    + +

    The frequency of a letter x is the number of times it occurs in the string.

    + +

     

    +

    Example 1:

    + +
    +Input: word1 = "aaaa", word2 = "bccb"
    +Output: false
    +Explanation: There are 4 'a's in "aaaa" but 0 'a's in "bccb".
    +The difference is 4, which is more than the allowed 3.
    +
    + +

    Example 2:

    + +
    +Input: word1 = "abcdeef", word2 = "abaaacc"
    +Output: true
    +Explanation: The differences between the frequencies of each letter in word1 and word2 are at most 3:
    +- 'a' appears 1 time in word1 and 4 times in word2. The difference is 3.
    +- 'b' appears 1 time in word1 and 1 time in word2. The difference is 0.
    +- 'c' appears 1 time in word1 and 2 times in word2. The difference is 1.
    +- 'd' appears 1 time in word1 and 0 times in word2. The difference is 1.
    +- 'e' appears 2 times in word1 and 0 times in word2. The difference is 2.
    +- 'f' appears 1 time in word1 and 0 times in word2. The difference is 1.
    +
    + +

    Example 3:

    + +
    +Input: word1 = "cccddabba", word2 = "babababab"
    +Output: true
    +Explanation: The differences between the frequencies of each letter in word1 and word2 are at most 3:
    +- 'a' appears 2 times in word1 and 4 times in word2. The difference is 2.
    +- 'b' appears 2 times in word1 and 5 times in word2. The difference is 3.
    +- 'c' appears 3 times in word1 and 0 times in word2. The difference is 3.
    +- 'd' appears 2 times in word1 and 0 times in word2. The difference is 2.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == word1.length == word2.length
    • +
    • 1 <= n <= 100
    • +
    • word1 and word2 consist only of lowercase English letters.
    • +
    + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Hints +
    +Hint 1 +What data structure can we use to count the frequency of each character? +
    + +
    +Hint 2 +Are there edge cases where a character is present in one string but not the other? +
    diff --git a/problems/checking-existence-of-edge-length-limited-paths-ii/README.md b/problems/checking-existence-of-edge-length-limited-paths-ii/README.md index b97a129ae..521244d38 100644 --- a/problems/checking-existence-of-edge-length-limited-paths-ii/README.md +++ b/problems/checking-existence-of-edge-length-limited-paths-ii/README.md @@ -18,6 +18,9 @@ [[Graph](../../tag/graph/README.md)] [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] +### Similar Questions + 1. [Checking Existence of Edge Length Limited Paths](../checking-existence-of-edge-length-limited-paths) (Hard) + ### Hints
    Hint 1 diff --git a/problems/circle-and-rectangle-overlapping/README.md b/problems/circle-and-rectangle-overlapping/README.md index 13ebd99f8..edda53622 100644 --- a/problems/circle-and-rectangle-overlapping/README.md +++ b/problems/circle-and-rectangle-overlapping/README.md @@ -64,8 +64,8 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] ### Hints
    diff --git a/problems/clone-graph/README.md b/problems/clone-graph/README.md index 39acebb91..9ba5fa989 100644 --- a/problems/clone-graph/README.md +++ b/problems/clone-graph/README.md @@ -82,10 +82,12 @@ class Node { ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions 1. [Copy List with Random Pointer](../copy-list-with-random-pointer) (Medium) + 1. [Clone Binary Tree With Random Pointer](../clone-binary-tree-with-random-pointer) (Medium) + 1. [Clone N-ary Tree](../clone-n-ary-tree) (Medium) diff --git a/problems/closest-binary-search-tree-value/README.md b/problems/closest-binary-search-tree-value/README.md index a2f2c6f8b..0153f8003 100644 --- a/problems/closest-binary-search-tree-value/README.md +++ b/problems/closest-binary-search-tree-value/README.md @@ -35,10 +35,10 @@ ### Related Topics - [[Binary Search](../../tag/binary-search/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/closest-room/README.md b/problems/closest-room/README.md index 41f31a572..cfbce9e63 100644 --- a/problems/closest-room/README.md +++ b/problems/closest-room/README.md @@ -55,7 +55,6 @@ Query = [2,5]: Room number 3 is the only room with a size of at least 5. The ans
  • 1 <= k <= 104
  • 1 <= roomIdi, preferredj <= 107
  • 1 <= sizei, minSizej <= 107
  • -
  •  
  • ### Related Topics diff --git a/problems/closest-subsequence-sum/README.md b/problems/closest-subsequence-sum/README.md index a0bb7ed0a..08560e3fa 100644 --- a/problems/closest-subsequence-sum/README.md +++ b/problems/closest-subsequence-sum/README.md @@ -55,12 +55,16 @@ The absolute difference is abs(-4 - (-5)) = abs(1) = 1, which is the minimum. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] +### Similar Questions + 1. [Minimize the Difference Between Target and Chosen Elements](../minimize-the-difference-between-target-and-chosen-elements) (Medium) + 1. [Partition Array Into Two Arrays to Minimize Sum Difference](../partition-array-into-two-arrays-to-minimize-sum-difference) (Hard) + ### Hints
    Hint 1 diff --git a/problems/coloring-a-border/README.md b/problems/coloring-a-border/README.md index a1b9e867c..cd71bfc1e 100644 --- a/problems/coloring-a-border/README.md +++ b/problems/coloring-a-border/README.md @@ -45,9 +45,9 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Similar Questions diff --git a/problems/combine-two-tables/README.md b/problems/combine-two-tables/README.md index a1e43602f..905d39ec6 100644 --- a/problems/combine-two-tables/README.md +++ b/problems/combine-two-tables/README.md @@ -17,33 +17,68 @@ +-------------+---------+ | Column Name | Type | +-------------+---------+ -| PersonId | int | -| FirstName | varchar | -| LastName | varchar | +| personId | int | +| lastName | varchar | +| firstName | varchar | +-------------+---------+ -PersonId is the primary key column for this table. +personId is the primary key column for this table. +This table contains information about the ID of some persons and their first and last names. +

     

    +

    Table: Address

     +-------------+---------+
     | Column Name | Type    |
     +-------------+---------+
    -| AddressId   | int     |
    -| PersonId    | int     |
    -| City        | varchar |
    -| State       | varchar |
    +| addressId   | int     |
    +| personId    | int     |
    +| city        | varchar |
    +| state       | varchar |
     +-------------+---------+
    -AddressId is the primary key column for this table.
    +addressId is the primary key column for this table.
    +Each row of this table contains information about the city and state of one person with ID = PersonId.
     

     

    -

    Write a SQL query for a report that provides the following information for each person in the Person table, regardless if there is an address for each of those people:

    +

    Write an SQL query to report the first name, last name, city, and state of each person in the Person table. If the address of a personId is not present in the Address table, report null instead.

    + +

    Return the result table in any order.

    + +

    The query result format is in the following example.

    + +

     

    +

    Example 1:

    -FirstName, LastName, City, State
    +Input: 
    +Person table:
    ++----------+----------+-----------+
    +| personId | lastName | firstName |
    ++----------+----------+-----------+
    +| 1        | Wang     | Allen     |
    +| 2        | Alice    | Bob       |
    ++----------+----------+-----------+
    +Address table:
    ++-----------+----------+---------------+------------+
    +| addressId | personId | city          | state      |
    ++-----------+----------+---------------+------------+
    +| 1         | 2        | New York City | New York   |
    +| 2         | 3        | Leetcode      | California |
    ++-----------+----------+---------------+------------+
    +Output: 
    ++-----------+----------+---------------+----------+
    +| firstName | lastName | city          | state    |
    ++-----------+----------+---------------+----------+
    +| Allen     | Wang     | Null          | Null     |
    +| Bob       | Alice    | New York City | New York |
    ++-----------+----------+---------------+----------+
    +Explanation: 
    +There is no address in the address table for the personId = 1 so we return null in their city and state.
    +addressId = 1 contains information about the address of personId = 2.
     
    ### Related Topics diff --git a/problems/combine-two-tables/mysql_schemas.sql b/problems/combine-two-tables/mysql_schemas.sql index 7c8428e17..b6d12b76c 100644 --- a/problems/combine-two-tables/mysql_schemas.sql +++ b/problems/combine-two-tables/mysql_schemas.sql @@ -1,6 +1,8 @@ -Create table Person (PersonId int, FirstName varchar(255), LastName varchar(255)); -Create table Address (AddressId int, PersonId int, City varchar(255), State varchar(255)); +Create table If Not Exists Person (personId int, firstName varchar(255), lastName varchar(255)); +Create table If Not Exists Address (addressId int, personId int, city varchar(255), state varchar(255)); Truncate table Person; -insert into Person (PersonId, LastName, FirstName) values ('1', 'Wang', 'Allen'); +insert into Person (personId, lastName, firstName) values ('1', 'Wang', 'Allen'); +insert into Person (personId, lastName, firstName) values ('2', 'Alice', 'Bob'); Truncate table Address; -insert into Address (AddressId, PersonId, City, State) values ('1', '2', 'New York City', 'New York'); +insert into Address (addressId, personId, city, state) values ('1', '2', 'New York City', 'New York'); +insert into Address (addressId, personId, city, state) values ('2', '3', 'Leetcode', 'California'); diff --git a/problems/confirmation-rate/README.md b/problems/confirmation-rate/README.md index bf6917053..ce3bac860 100644 --- a/problems/confirmation-rate/README.md +++ b/problems/confirmation-rate/README.md @@ -12,3 +12,6 @@ ## [1934. Confirmation Rate (Medium)](https://leetcode.com/problems/confirmation-rate "") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/consecutive-characters/README.md b/problems/consecutive-characters/README.md index c605bae72..9ea25d484 100644 --- a/problems/consecutive-characters/README.md +++ b/problems/consecutive-characters/README.md @@ -64,6 +64,10 @@ ### Related Topics [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Max Consecutive Ones](../max-consecutive-ones) (Easy) + 1. [Count Number of Homogenous Substrings](../count-number-of-homogenous-substrings) (Medium) + ### Hints
    Hint 1 diff --git a/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md b/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md index d810e669d..2ac7d5a8c 100644 --- a/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md +++ b/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md @@ -42,10 +42,10 @@ ### Related Topics - [[Tree](../../tag/tree/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Tree](../../tag/tree/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/construct-k-palindrome-strings/README.md b/problems/construct-k-palindrome-strings/README.md index b899f1598..8b249b0a4 100644 --- a/problems/construct-k-palindrome-strings/README.md +++ b/problems/construct-k-palindrome-strings/README.md @@ -67,9 +67,9 @@ Some possible constructions "anna" + "elble", "anbna&qu ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Counting](../../tag/counting/README.md)] ### Hints diff --git a/problems/container-with-most-water/README.md b/problems/container-with-most-water/README.md index 783c10827..edfe43eec 100644 --- a/problems/container-with-most-water/README.md +++ b/problems/container-with-most-water/README.md @@ -55,9 +55,9 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions 1. [Trapping Rain Water](../trapping-rain-water) (Hard) diff --git a/problems/contains-duplicate-iii/README.md b/problems/contains-duplicate-iii/README.md index 6ce24574c..ea57af0ca 100644 --- a/problems/contains-duplicate-iii/README.md +++ b/problems/contains-duplicate-iii/README.md @@ -28,7 +28,7 @@

    Constraints:

      -
    • 0 <= nums.length <= 2 * 104
    • +
    • 1 <= nums.length <= 2 * 104
    • -231 <= nums[i] <= 231 - 1
    • 0 <= k <= 104
    • 0 <= t <= 231 - 1
    • @@ -36,10 +36,10 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + [[Sorting](../../tag/sorting/README.md)] [[Bucket Sort](../../tag/bucket-sort/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] - [[Sorting](../../tag/sorting/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions 1. [Contains Duplicate](../contains-duplicate) (Easy) diff --git a/problems/convert-a-number-to-hexadecimal/README.md b/problems/convert-a-number-to-hexadecimal/README.md index 9055b2c75..955b7b2d3 100644 --- a/problems/convert-a-number-to-hexadecimal/README.md +++ b/problems/convert-a-number-to-hexadecimal/README.md @@ -33,5 +33,5 @@
    ### Related Topics - [[Math](../../tag/math/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Math](../../tag/math/README.md)] diff --git a/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md b/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md index 493290f51..6380ffd0d 100644 --- a/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md +++ b/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/README.md @@ -35,11 +35,11 @@

    ### Related Topics - [[Linked List](../../tag/linked-list/README.md)] [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Linked List](../../tag/linked-list/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] [[Doubly-Linked List](../../tag/doubly-linked-list/README.md)] diff --git a/problems/convert-bst-to-greater-tree/README.md b/problems/convert-bst-to-greater-tree/README.md index 65d919826..03a2b8541 100644 --- a/problems/convert-bst-to-greater-tree/README.md +++ b/problems/convert-bst-to-greater-tree/README.md @@ -11,18 +11,16 @@ ## [538. Convert BST to Greater Tree (Medium)](https://leetcode.com/problems/convert-bst-to-greater-tree "把二叉搜索树转换为累加树") -

    Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.

    +

    Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum of all keys greater than the original key in BST.

    As a reminder, a binary search tree is a tree that satisfies these constraints:

      -
    • The left subtree of a node contains only nodes with keys less than the node's key.
    • -
    • The right subtree of a node contains only nodes with keys greater than the node's key.
    • +
    • The left subtree of a node contains only nodes with keys less than the node's key.
    • +
    • The right subtree of a node contains only nodes with keys greater than the node's key.
    • Both the left and right subtrees must also be binary search trees.
    -

    Note: This question is the same as 1038: https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree/

    -

     

    Example 1:

    @@ -62,6 +60,9 @@
  • root is guaranteed to be a valid binary search tree.
  • +

     

    +

    Note: This question is the same as 1038: https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree/

    + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/correct-a-binary-tree/README.md b/problems/correct-a-binary-tree/README.md index 67651be4f..24a792f77 100644 --- a/problems/correct-a-binary-tree/README.md +++ b/problems/correct-a-binary-tree/README.md @@ -14,12 +14,16 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Flatten Binary Tree to Linked List](../flatten-binary-tree-to-linked-list) (Medium) + 1. [Flatten a Multilevel Doubly Linked List](../flatten-a-multilevel-doubly-linked-list) (Medium) + ### Hints
    Hint 1 diff --git a/problems/count-good-meals/README.md b/problems/count-good-meals/README.md index 5331d246a..e23d90e05 100644 --- a/problems/count-good-meals/README.md +++ b/problems/count-good-meals/README.md @@ -48,6 +48,10 @@ Their respective sums are 4, 8, 8, and 16, all of which are powers of 2. [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] +### Similar Questions + 1. [Two Sum](../two-sum) (Easy) + 1. [Max Number of K-Sum Pairs](../max-number-of-k-sum-pairs) (Medium) + ### Hints
    Hint 1 diff --git a/problems/count-nodes-with-the-highest-score/README.md b/problems/count-nodes-with-the-highest-score/README.md new file mode 100644 index 000000000..cca15d348 --- /dev/null +++ b/problems/count-nodes-with-the-highest-score/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../next-greater-numerically-balanced-number "Next Greater Numerically Balanced Number") +                 +[Next >](../parallel-courses-iii "Parallel Courses III") + +## [2049. Count Nodes With the Highest Score (Medium)](https://leetcode.com/problems/count-nodes-with-the-highest-score "统计最高分的节点数目") + +

    There is a binary tree rooted at 0 consisting of n nodes. The nodes are labeled from 0 to n - 1. You are given a 0-indexed integer array parents representing the tree, where parents[i] is the parent of node i. Since node 0 is the root, parents[0] == -1.

    + +

    Each node has a score. To find the score of a node, consider if the node and the edges connected to it were removed. The tree would become one or more non-empty subtrees. The size of a subtree is the number of the nodes in it. The score of the node is the product of the sizes of all those subtrees.

    + +

    Return the number of nodes that have the highest score.

    + +

     

    +

    Example 1:

    +example-1 +
    +Input: parents = [-1,2,0,2,0]
    +Output: 3
    +Explanation:
    +- The score of node 0 is: 3 * 1 = 3
    +- The score of node 1 is: 4 = 4
    +- The score of node 2 is: 1 * 1 * 2 = 2
    +- The score of node 3 is: 4 = 4
    +- The score of node 4 is: 4 = 4
    +The highest score is 4, and three nodes (node 1, node 3, and node 4) have the highest score.
    +
    + +

    Example 2:

    +example-2 +
    +Input: parents = [-1,2,0]
    +Output: 2
    +Explanation:
    +- The score of node 0 is: 2 = 2
    +- The score of node 1 is: 2 = 2
    +- The score of node 2 is: 1 * 1 = 1
    +The highest score is 2, and two nodes (node 0 and node 1) have the highest score.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == parents.length
    • +
    • 2 <= n <= 105
    • +
    • parents[0] == -1
    • +
    • 0 <= parents[i] <= n - 1 for i != 0
    • +
    • parents represents a valid binary tree.
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] + +### Hints +
    +Hint 1 +For each node, you need to find the sizes of the subtrees rooted in each of its children. Maybe DFS? +
    + +
    +Hint 2 +How to determine the number of nodes in the rest of the tree? Can you subtract the size of the subtree rooted at the node from the total number of nodes of the tree? +
    + +
    +Hint 3 +Use these values to compute the score of the node. Track the maximum score, and how many nodes achieve such score. +
    diff --git a/problems/count-number-of-homogenous-substrings/README.md b/problems/count-number-of-homogenous-substrings/README.md index 6259c34f8..12e2e7e31 100644 --- a/problems/count-number-of-homogenous-substrings/README.md +++ b/problems/count-number-of-homogenous-substrings/README.md @@ -59,6 +59,10 @@ [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Consecutive Characters](../consecutive-characters) (Easy) + 1. [Number of Substrings With Only 1s](../number-of-substrings-with-only-1s) (Medium) + ### Hints
    Hint 1 diff --git a/problems/count-number-of-teams/README.md b/problems/count-number-of-teams/README.md index 6ee99a555..2f27f44d2 100644 --- a/problems/count-number-of-teams/README.md +++ b/problems/count-number-of-teams/README.md @@ -57,9 +57,9 @@ ### Related Topics - [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] ### Hints
    diff --git a/problems/count-of-smaller-numbers-after-self/README.md b/problems/count-of-smaller-numbers-after-self/README.md index 81dd24885..84bfffbb5 100644 --- a/problems/count-of-smaller-numbers-after-self/README.md +++ b/problems/count-of-smaller-numbers-after-self/README.md @@ -49,15 +49,16 @@ To the right of 1 there is 0 smaller element. ### Related Topics - [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] - [[Segment Tree](../../tag/segment-tree/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] [[Merge Sort](../../tag/merge-sort/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions 1. [Count of Range Sum](../count-of-range-sum) (Hard) 1. [Queue Reconstruction by Height](../queue-reconstruction-by-height) (Medium) 1. [Reverse Pairs](../reverse-pairs) (Hard) + 1. [How Many Numbers Are Smaller Than the Current Number](../how-many-numbers-are-smaller-than-the-current-number) (Easy) diff --git a/problems/count-pairs-of-nodes/README.md b/problems/count-pairs-of-nodes/README.md index 125c28307..aa061db47 100644 --- a/problems/count-pairs-of-nodes/README.md +++ b/problems/count-pairs-of-nodes/README.md @@ -58,9 +58,9 @@ The answers for each of the queries are as follows: ### Related Topics - [[Graph](../../tag/graph/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Graph](../../tag/graph/README.md)] ### Hints
    diff --git a/problems/count-subtrees-with-max-distance-between-cities/README.md b/problems/count-subtrees-with-max-distance-between-cities/README.md index ce23fc9b5..ce9398bf5 100644 --- a/problems/count-subtrees-with-max-distance-between-cities/README.md +++ b/problems/count-subtrees-with-max-distance-between-cities/README.md @@ -61,11 +61,14 @@ No subtree has two nodes where the max distance between them is 3. ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Tree](../../tag/tree/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Bitmask](../../tag/bitmask/README.md)] [[Enumeration](../../tag/enumeration/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] + +### Similar Questions + 1. [Tree Diameter](../tree-diameter) (Medium) ### Hints
    diff --git a/problems/count-vowel-substrings-of-a-string/README.md b/problems/count-vowel-substrings-of-a-string/README.md new file mode 100644 index 000000000..baf298120 --- /dev/null +++ b/problems/count-vowel-substrings-of-a-string/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../number-of-spaces-cleaning-robot-cleaned "Number of Spaces Cleaning Robot Cleaned") +                 +[Next >](../vowels-of-all-substrings "Vowels of All Substrings") + +## [2062. Count Vowel Substrings of a String (Easy)](https://leetcode.com/problems/count-vowel-substrings-of-a-string "统计字符串中的元音子字符串") + +

    A substring is a contiguous (non-empty) sequence of characters within a string.

    + +

    A vowel substring is a substring that only consists of vowels ('a', 'e', 'i', 'o', and 'u') and has all five vowels present in it.

    + +

    Given a string word, return the number of vowel substrings in word.

    + +

     

    +

    Example 1:

    + +
    +Input: word = "aeiouu"
    +Output: 2
    +Explanation: The vowel substrings of word are as follows (underlined):
    +- "aeiouu"
    +- "aeiouu"
    +
    + +

    Example 2:

    + +
    +Input: word = "unicornarihan"
    +Output: 0
    +Explanation: Not all 5 vowels are present, so there are no vowel substrings.
    +
    + +

    Example 3:

    + +
    +Input: word = "cuaieuouac"
    +Output: 7
    +Explanation: The vowel substrings of word are as follows (underlined):
    +- "cuaieuouac"
    +- "cuaieuouac"
    +- "cuaieuouac"
    +- "cuaieuouac"
    +- "cuaieuouac"
    +- "cuaieuouac"
    +- "cuaieuouac"
    + +

    Example 4:

    + +
    +Input: word = "bbaeixoubb"
    +Output: 0
    +Explanation: The only substrings that contain all five vowels also contain consonants, so there are no vowel substrings.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= word.length <= 100
    • +
    • word consists of lowercase English letters only.
    • +
    + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +While generating substrings starting at any index, do you need to continue generating larger substrings if you encounter a consonant? +
    + +
    +Hint 2 +Can you store the count of characters to avoid generating substrings altogether? +
    diff --git a/problems/countries-you-can-safely-invest-in/README.md b/problems/countries-you-can-safely-invest-in/README.md index 068f9e87e..eac2822ed 100644 --- a/problems/countries-you-can-safely-invest-in/README.md +++ b/problems/countries-you-can-safely-invest-in/README.md @@ -15,6 +15,3 @@ ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Average Salary: Departments VS Company](../average-salary-departments-vs-company) (Hard) diff --git a/problems/create-a-session-bar-chart/README.md b/problems/create-a-session-bar-chart/README.md index 373135897..9bf7444db 100644 --- a/problems/create-a-session-bar-chart/README.md +++ b/problems/create-a-session-bar-chart/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Count Salary Categories](../count-salary-categories) (Medium) diff --git a/problems/customers-who-never-order/README.md b/problems/customers-who-never-order/README.md index 68643fc72..91232a781 100644 --- a/problems/customers-who-never-order/README.md +++ b/problems/customers-who-never-order/README.md @@ -17,10 +17,10 @@ +-------------+---------+ | Column Name | Type | +-------------+---------+ -| Id | int | -| Name | varchar | +| id | int | +| name | varchar | +-------------+---------+ -Id is the primary key column for this table. +id is the primary key column for this table. Each row of this table indicates the ID and name of a customer. @@ -32,11 +32,11 @@ Each row of this table indicates the ID and name of a customer. +-------------+------+ | Column Name | Type | +-------------+------+ -| Id | int | -| CustomerId | int | +| id | int | +| customerId | int | +-------------+------+ -Id is the primary key column for this table. -CustomerId is a foreign key of the ID from the Customers table. +id is the primary key column for this table. +customerId is a foreign key of the ID from the Customers table. Each row of this table indicates the ID of an order and the ID of the customer who ordered it. @@ -55,7 +55,7 @@ Each row of this table indicates the ID of an order and the ID of the customer w Input: Customers table: +----+-------+ -| Id | Name | +| id | name | +----+-------+ | 1 | Joe | | 2 | Henry | @@ -64,7 +64,7 @@ Customers table: +----+-------+ Orders table: +----+------------+ -| Id | CustomerId | +| id | customerId | +----+------------+ | 1 | 3 | | 2 | 1 | diff --git a/problems/customers-who-never-order/mysql_schemas.sql b/problems/customers-who-never-order/mysql_schemas.sql index bf5bf0b40..9a38db656 100644 --- a/problems/customers-who-never-order/mysql_schemas.sql +++ b/problems/customers-who-never-order/mysql_schemas.sql @@ -1,10 +1,10 @@ -Create table If Not Exists Customers (Id int, Name varchar(255)); -Create table If Not Exists Orders (Id int, CustomerId int); +Create table If Not Exists Customers (id int, name varchar(255)); +Create table If Not Exists Orders (id int, customerId int); Truncate table Customers; -insert into Customers (Id, Name) values ('1', 'Joe'); -insert into Customers (Id, Name) values ('2', 'Henry'); -insert into Customers (Id, Name) values ('3', 'Sam'); -insert into Customers (Id, Name) values ('4', 'Max'); +insert into Customers (id, name) values ('1', 'Joe'); +insert into Customers (id, name) values ('2', 'Henry'); +insert into Customers (id, name) values ('3', 'Sam'); +insert into Customers (id, name) values ('4', 'Max'); Truncate table Orders; -insert into Orders (Id, CustomerId) values ('1', '3'); -insert into Orders (Id, CustomerId) values ('2', '1'); +insert into Orders (id, customerId) values ('1', '3'); +insert into Orders (id, customerId) values ('2', '1'); diff --git a/problems/decode-the-slanted-ciphertext/README.md b/problems/decode-the-slanted-ciphertext/README.md new file mode 100644 index 000000000..9e67b65fe --- /dev/null +++ b/problems/decode-the-slanted-ciphertext/README.md @@ -0,0 +1,95 @@ + + + + + + + +[< Previous](../reverse-nodes-in-even-length-groups "Reverse Nodes in Even Length Groups") +                 +[Next >](../process-restricted-friend-requests "Process Restricted Friend Requests") + +## [2075. Decode the Slanted Ciphertext (Medium)](https://leetcode.com/problems/decode-the-slanted-ciphertext "解码斜向换位密码") + +

    A string originalText is encoded using a slanted transposition cipher to a string encodedText with the help of a matrix having a fixed number of rows rows.

    + +

    originalText is placed first in a top-left to bottom-right manner.

    + +

    The blue cells are filled first, followed by the red cells, then the yellow cells, and so on, until we reach the end of originalText. The arrow indicates the order in which the cells are filled. All empty cells are filled with ' '. The number of columns is chosen such that the rightmost column will not be empty after filling in originalText.

    + +

    encodedText is then formed by appending all characters of the matrix in a row-wise fashion.

    + +

    The characters in the blue cells are appended first to encodedText, then the red cells, and so on, and finally the yellow cells. The arrow indicates the order in which the cells are accessed.

    + +

    For example, if originalText = "cipher" and rows = 3, then we encode it in the following manner:

    + +

    The blue arrows depict how originalText is placed in the matrix, and the red arrows denote the order in which encodedText is formed. In the above example, encodedText = "ch ie pr".

    + +

    Given the encoded string encodedText and number of rows rows, return the original string originalText.

    + +

    Note: originalText does not have any trailing spaces ' '. The test cases are generated such that there is only one possible originalText.

    + +

     

    +

    Example 1:

    + +
    +Input: encodedText = "ch   ie   pr", rows = 3
    +Output: "cipher"
    +Explanation: This is the same example described in the problem description.
    +
    + +

    Example 2:

    + +
    +Input: encodedText = "iveo    eed   l te   olc", rows = 4
    +Output: "i love leetcode"
    +Explanation: The figure above denotes the matrix that was used to encode originalText. 
    +The blue arrows show how we can find originalText from encodedText.
    +
    + +

    Example 3:

    + +
    +Input: encodedText = "coding", rows = 1
    +Output: "coding"
    +Explanation: Since there is only 1 row, both originalText and encodedText are the same.
    +
    + +

    Example 4:

    + +
    +Input: encodedText = " b  ac", rows = 2
    +Output: " abc"
    +Explanation: originalText cannot have trailing spaces, but it may be preceded by one or more spaces.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= encodedText.length <= 106
    • +
    • encodedText consists of lowercase English letters and ' ' only.
    • +
    • encodedText is a valid encoding of some originalText that does not have trailing spaces.
    • +
    • 1 <= rows <= 1000
    • +
    • The testcases are generated such that there is only one possible originalText.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +How can you use rows and encodedText to find the number of columns of the matrix? +
    + +
    +Hint 2 +Once you have the number of rows and columns, you can create the matrix and place encodedText in it. How should you place it in the matrix? +
    + +
    +Hint 3 +How should you traverse the matrix to "decode" originalText? +
    diff --git a/problems/decode-ways/README.md b/problems/decode-ways/README.md index c33e1a58f..4f55bba1d 100644 --- a/problems/decode-ways/README.md +++ b/problems/decode-ways/README.md @@ -82,3 +82,4 @@ Hence, there are no valid ways to decode this since all digits need to be mapped ### Similar Questions 1. [Decode Ways II](../decode-ways-ii) (Hard) + 1. [Number of Ways to Separate Numbers](../number-of-ways-to-separate-numbers) (Hard) diff --git a/problems/decompress-run-length-encoded-list/README.md b/problems/decompress-run-length-encoded-list/README.md index 7ccf0f628..9d28d4d54 100644 --- a/problems/decompress-run-length-encoded-list/README.md +++ b/problems/decompress-run-length-encoded-list/README.md @@ -47,9 +47,6 @@ At the end the concatenation [2] + [4,4,4] is [2,4,4,4]. ### Related Topics [[Array](../../tag/array/README.md)] -### Similar Questions - 1. [String Compression](../string-compression) (Medium) - ### Hints
    Hint 1 diff --git a/problems/delete-operation-for-two-strings/README.md b/problems/delete-operation-for-two-strings/README.md index 56fb975e9..30e5ed60c 100644 --- a/problems/delete-operation-for-two-strings/README.md +++ b/problems/delete-operation-for-two-strings/README.md @@ -46,3 +46,4 @@ ### Similar Questions 1. [Edit Distance](../edit-distance) (Hard) 1. [Minimum ASCII Delete Sum for Two Strings](../minimum-ascii-delete-sum-for-two-strings) (Medium) + 1. [Longest Common Subsequence](../longest-common-subsequence) (Medium) diff --git a/problems/design-front-middle-back-queue/README.md b/problems/design-front-middle-back-queue/README.md index b3a498d9f..be57778c1 100644 --- a/problems/design-front-middle-back-queue/README.md +++ b/problems/design-front-middle-back-queue/README.md @@ -64,12 +64,16 @@ q.popFront(); // return -1 -> [] (The queue is empty) ### Related Topics - [[Design](../../tag/design/README.md)] - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] [[Data Stream](../../tag/data-stream/README.md)] +### Similar Questions + 1. [Design Circular Deque](../design-circular-deque) (Medium) + 1. [Design Circular Queue](../design-circular-queue) (Medium) + ### Hints
    Hint 1 diff --git a/problems/design-log-storage-system/README.md b/problems/design-log-storage-system/README.md index 703762dd1..9537e98a4 100644 --- a/problems/design-log-storage-system/README.md +++ b/problems/design-log-storage-system/README.md @@ -38,9 +38,9 @@ retrieve("2016:01:01:01:01:01","2017:01:01:23:00:00","Hour"); // return [1,2], b

    ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions diff --git a/problems/design-most-recently-used-queue/README.md b/problems/design-most-recently-used-queue/README.md index ad11af706..12dfa1e0a 100644 --- a/problems/design-most-recently-used-queue/README.md +++ b/problems/design-most-recently-used-queue/README.md @@ -14,13 +14,16 @@ ### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Stack](../../tag/stack/README.md)] [[Design](../../tag/design/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] - [[Array](../../tag/array/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] +### Similar Questions + 1. [LRU Cache](../lru-cache) (Medium) + ### Hints
    Hint 1 diff --git a/problems/design-skiplist/README.md b/problems/design-skiplist/README.md index 44185a46f..c79f5f35d 100644 --- a/problems/design-skiplist/README.md +++ b/problems/design-skiplist/README.md @@ -66,5 +66,10 @@ skiplist.search(1); // return False, 1 has already been erased. ### Related Topics - [[Design](../../tag/design/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Design](../../tag/design/README.md)] + +### Similar Questions + 1. [Design HashSet](../design-hashset) (Easy) + 1. [Design HashMap](../design-hashmap) (Easy) + 1. [Design Linked List](../design-linked-list) (Medium) diff --git a/problems/design-snake-game/README.md b/problems/design-snake-game/README.md index b3e5a91bf..16eb867f5 100644 --- a/problems/design-snake-game/README.md +++ b/problems/design-snake-game/README.md @@ -62,7 +62,7 @@ snake.move("U"); -> Returns -1 (Game over because snake collides wi ### Related Topics + [[Array](../../tag/array/README.md)] [[Design](../../tag/design/README.md)] [[Queue](../../tag/queue/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/design-underground-system/README.md b/problems/design-underground-system/README.md index 195801ffa..ad50b7a3d 100644 --- a/problems/design-underground-system/README.md +++ b/problems/design-underground-system/README.md @@ -101,9 +101,9 @@ undergroundSystem.getAverageTime("Leyton", "Paradise"); // r ### Related Topics + [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Design](../../tag/design/README.md)] ### Hints
    diff --git a/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md b/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md index 012a4246e..42cd38d62 100644 --- a/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md +++ b/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md @@ -72,6 +72,9 @@ [[Array](../../tag/array/README.md)] [[Enumeration](../../tag/enumeration/README.md)] +### Similar Questions + 1. [Maximum Repeating Substring](../maximum-repeating-substring) (Easy) + ### Hints
    Hint 1 diff --git a/problems/distribute-repeating-integers/README.md b/problems/distribute-repeating-integers/README.md index 0c1f43ecf..f1649ed8b 100644 --- a/problems/distribute-repeating-integers/README.md +++ b/problems/distribute-repeating-integers/README.md @@ -75,10 +75,10 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] ### Hints diff --git a/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md b/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md index 8fc6c478d..7b0bf98af 100644 --- a/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md +++ b/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md @@ -59,14 +59,11 @@ Note: This question is the same as 846: https://leetcode.com/problems/hand-of-straights/ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Split Array into Consecutive Subsequences](../split-array-into-consecutive-subsequences) (Medium) - ### Hints
    Hint 1 diff --git a/problems/divide-array-into-increasing-sequences/README.md b/problems/divide-array-into-increasing-sequences/README.md index f16e3dd3e..9cafc4768 100644 --- a/problems/divide-array-into-increasing-sequences/README.md +++ b/problems/divide-array-into-increasing-sequences/README.md @@ -44,8 +44,8 @@ There is no way to divide the array using the conditions required. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/duplicate-emails/README.md b/problems/duplicate-emails/README.md index c656347b4..d03810ad8 100644 --- a/problems/duplicate-emails/README.md +++ b/problems/duplicate-emails/README.md @@ -17,10 +17,10 @@ +-------------+---------+ | Column Name | Type | +-------------+---------+ -| Id | int | -| Email | varchar | +| id | int | +| email | varchar | +-------------+---------+ -Id is the primary key column for this table. +id is the primary key column for this table. Each row of this table contains an email. The emails will not contain uppercase letters. @@ -39,7 +39,7 @@ Each row of this table contains an email. The emails will not contain uppercase Input: Person table: +----+---------+ -| Id | Email | +| id | email | +----+---------+ | 1 | a@b.com | | 2 | c@d.com | diff --git a/problems/duplicate-emails/mysql_schemas.sql b/problems/duplicate-emails/mysql_schemas.sql index bc5060c21..5e65f14b1 100644 --- a/problems/duplicate-emails/mysql_schemas.sql +++ b/problems/duplicate-emails/mysql_schemas.sql @@ -1,5 +1,5 @@ -Create table If Not Exists Person (Id int, Email varchar(255)); +Create table If Not Exists Person (id int, email varchar(255)); Truncate table Person; -insert into Person (Id, Email) values ('1', 'a@b.com'); -insert into Person (Id, Email) values ('2', 'c@d.com'); -insert into Person (Id, Email) values ('3', 'a@b.com'); +insert into Person (id, email) values ('1', 'a@b.com'); +insert into Person (id, email) values ('2', 'c@d.com'); +insert into Person (id, email) values ('3', 'a@b.com'); diff --git a/problems/egg-drop-with-2-eggs-and-n-floors/README.md b/problems/egg-drop-with-2-eggs-and-n-floors/README.md index 9c72cf70b..507213b79 100644 --- a/problems/egg-drop-with-2-eggs-and-n-floors/README.md +++ b/problems/egg-drop-with-2-eggs-and-n-floors/README.md @@ -37,13 +37,9 @@ Otherwise, if both eggs survive, we know that f = 2. Input: n = 100 Output: 14 Explanation: One optimal strategy is: -- Drop the 1st egg at floor 9. If it breaks, we know f is between 0 and 8. Drop the 2nd egg starting - from floor 1 and going up one at a time to find f within 7 more drops. Total drops is 1 + 7 = 8. -- If the 1st egg does not break, drop the 1st egg again at floor 22. If it breaks, we know f is between 9 - and 21. Drop the 2nd egg starting from floor 10 and going up one at a time to find f within 12 more - drops. Total drops is 2 + 12 = 14. -- If the 1st egg does not break again, follow a similar process dropping the 1st egg from floors 34, 45, - 55, 64, 72, 79, 85, 90, 94, 97, 99, and 100. +- Drop the 1st egg at floor 9. If it breaks, we know f is between 0 and 8. Drop the 2nd egg starting from floor 1 and going up one at a time to find f within 7 more drops. Total drops is 1 + 7 = 8. +- If the 1st egg does not break, drop the 1st egg again at floor 22. If it breaks, we know f is between 9 and 21. Drop the 2nd egg starting from floor 10 and going up one at a time to find f within 12 more drops. Total drops is 2 + 12 = 14. +- If the 1st egg does not break again, follow a similar process dropping the 1st egg from floors 34, 45, 55, 64, 72, 79, 85, 90, 94, 97, 99, and 100. Regardless of the outcome, it takes at most 14 drops to determine f. diff --git a/problems/employees-earning-more-than-their-managers/README.md b/problems/employees-earning-more-than-their-managers/README.md index b6a723096..cae3f944b 100644 --- a/problems/employees-earning-more-than-their-managers/README.md +++ b/problems/employees-earning-more-than-their-managers/README.md @@ -11,27 +11,50 @@ ## [181. Employees Earning More Than Their Managers (Easy)](https://leetcode.com/problems/employees-earning-more-than-their-managers "超过经理收入的员工") -

    The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.

    +

    Table: Employee

    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| id          | int     |
    +| name        | varchar |
    +| salary      | int     |
    +| managerId   | int     |
    ++-------------+---------+
    +id is the primary key column for this table.
    +Each row of this table indicates the ID of an employee, their name, salary, and the ID of their manager.
    +
    + +

     

    + +

    Write an SQL query to find the employees who earn more than their managers.

    + +

    Return the result table in any order.

    + +

    The query result format is in the following example.

    + +

     

    +

    Example 1:

    + +
    +Input: 
    +Employee table:
     +----+-------+--------+-----------+
    -| Id | Name  | Salary | ManagerId |
    +| id | name  | salary | managerId |
     +----+-------+--------+-----------+
     | 1  | Joe   | 70000  | 3         |
     | 2  | Henry | 80000  | 4         |
    -| 3  | Sam   | 60000  | NULL      |
    -| 4  | Max   | 90000  | NULL      |
    +| 3  | Sam   | 60000  | Null      |
    +| 4  | Max   | 90000  | Null      |
     +----+-------+--------+-----------+
    -
    - -

    Given the Employee table, write a SQL query that finds out employees who earn more than their managers. For the above table, Joe is the only employee who earns more than his manager.

    - -
    +Output: 
     +----------+
     | Employee |
     +----------+
     | Joe      |
     +----------+
    +Explanation: Joe is the only employee who earns more than his manager.
     
    ### Related Topics diff --git a/problems/employees-earning-more-than-their-managers/mysql_schemas.sql b/problems/employees-earning-more-than-their-managers/mysql_schemas.sql index cc26f9c88..47d72e79c 100644 --- a/problems/employees-earning-more-than-their-managers/mysql_schemas.sql +++ b/problems/employees-earning-more-than-their-managers/mysql_schemas.sql @@ -1,6 +1,6 @@ -Create table If Not Exists Employee (Id int, Name varchar(255), Salary int, ManagerId int); +Create table If Not Exists Employee (id int, name varchar(255), salary int, managerId int); Truncate table Employee; -insert into Employee (Id, Name, Salary, ManagerId) values ('1', 'Joe', '70000', '3'); -insert into Employee (Id, Name, Salary, ManagerId) values ('2', 'Henry', '80000', '4'); -insert into Employee (Id, Name, Salary, ManagerId) values ('3', 'Sam', '60000', 'None'); -insert into Employee (Id, Name, Salary, ManagerId) values ('4', 'Max', '90000', 'None'); +insert into Employee (id, name, salary, managerId) values ('1', 'Joe', '70000', '3'); +insert into Employee (id, name, salary, managerId) values ('2', 'Henry', '80000', '4'); +insert into Employee (id, name, salary, managerId) values ('3', 'Sam', '60000', 'None'); +insert into Employee (id, name, salary, managerId) values ('4', 'Max', '90000', 'None'); diff --git a/problems/employees-with-missing-information/README.md b/problems/employees-with-missing-information/README.md index 004d8ee18..2b6a9253b 100644 --- a/problems/employees-with-missing-information/README.md +++ b/problems/employees-with-missing-information/README.md @@ -9,7 +9,7 @@                  [Next >](../binary-searchable-numbers-in-an-unsorted-array "Binary Searchable Numbers in an Unsorted Array") -## [1965. Employees With Missing Information (Easy)](https://leetcode.com/problems/employees-with-missing-information "") +## [1965. Employees With Missing Information (Easy)](https://leetcode.com/problems/employees-with-missing-information "丢失信息的雇员") diff --git a/problems/encode-number/README.md b/problems/encode-number/README.md index 880bcff62..a38a4b267 100644 --- a/problems/encode-number/README.md +++ b/problems/encode-number/README.md @@ -40,9 +40,9 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Convert to Base -2](../convert-to-base-2) (Medium) diff --git a/problems/exchange-seats/README.md b/problems/exchange-seats/README.md index 67215c08b..3aacfcb82 100644 --- a/problems/exchange-seats/README.md +++ b/problems/exchange-seats/README.md @@ -11,45 +11,56 @@ ## [626. Exchange Seats (Medium)](https://leetcode.com/problems/exchange-seats "换座位") -

    Mary is a teacher in a middle school and she has a table seat storing students' names and their corresponding seat ids.

    +

    Table: Seat

    -

    The column id is continuous increment.

    +
    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| id          | int     |
    +| name        | varchar |
    ++-------------+---------+
    +id is the primary key column for this table.
    +Each row of this table indicates the name and the ID of a student.
    +id is a continuous increment.
    +
    -

    Mary wants to change seats for the adjacent students.

    +

     

    -

    Can you write a SQL query to output the result for Mary?

    +

    Write an SQL query to swap the seat id of every two consecutive students. If the number of students is odd, the id of the last student is not swapped.

    -

     

    +

    Return the result table ordered by id in ascending order.

    -
    -+---------+---------+
    -|    id   | student |
    -+---------+---------+
    -|    1    | Abbot   |
    -|    2    | Doris   |
    -|    3    | Emerson |
    -|    4    | Green   |
    -|    5    | Jeames  |
    -+---------+---------+
    -
    +

    The query result format is in the following example.

    -

    For the sample input, the output is:

    +

     

    +

    Example 1:

    -+---------+---------+
    -|    id   | student |
    -+---------+---------+
    -|    1    | Doris   |
    -|    2    | Abbot   |
    -|    3    | Green   |
    -|    4    | Emerson |
    -|    5    | Jeames  |
    -+---------+---------+
    +Input: 
    +Seat table:
    ++----+---------+
    +| id | student |
    ++----+---------+
    +| 1  | Abbot   |
    +| 2  | Doris   |
    +| 3  | Emerson |
    +| 4  | Green   |
    +| 5  | Jeames  |
    ++----+---------+
    +Output: 
    ++----+---------+
    +| id | student |
    ++----+---------+
    +| 1  | Doris   |
    +| 2  | Abbot   |
    +| 3  | Green   |
    +| 4  | Emerson |
    +| 5  | Jeames  |
    ++----+---------+
    +Explanation: 
    +Note that if the number of students is odd, there is no need to change the last one's seat.
     
    -

    Note:

    - -

    If the number of students is odd, there is no need to change the last one's seat.

    - ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/exchange-seats/mysql_schemas.sql b/problems/exchange-seats/mysql_schemas.sql index 8d0a904e3..3c3587aea 100644 --- a/problems/exchange-seats/mysql_schemas.sql +++ b/problems/exchange-seats/mysql_schemas.sql @@ -1,7 +1,7 @@ -Create table If Not Exists seat(id int, student varchar(255)); -Truncate table seat; -insert into seat (id, student) values ('1', 'Abbot'); -insert into seat (id, student) values ('2', 'Doris'); -insert into seat (id, student) values ('3', 'Emerson'); -insert into seat (id, student) values ('4', 'Green'); -insert into seat (id, student) values ('5', 'Jeames'); +Create table If Not Exists Seat (id int, student varchar(255)); +Truncate table Seat; +insert into Seat (id, student) values ('1', 'Abbot'); +insert into Seat (id, student) values ('2', 'Doris'); +insert into Seat (id, student) values ('3', 'Emerson'); +insert into Seat (id, student) values ('4', 'Green'); +insert into Seat (id, student) values ('5', 'Jeames'); diff --git a/problems/falling-squares/README.md b/problems/falling-squares/README.md index 050aa9122..dc7d38777 100644 --- a/problems/falling-squares/README.md +++ b/problems/falling-squares/README.md @@ -56,8 +56,8 @@ Note that square 2 only brushes the right side of square 1, which does not count ### Related Topics - [[Segment Tree](../../tag/segment-tree/README.md)] [[Array](../../tag/array/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions diff --git a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md index d9e42c73b..c3cc0d0d1 100644 --- a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md +++ b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md @@ -53,10 +53,10 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] - [[Segment Tree](../../tag/segment-tree/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] ### Hints
    diff --git a/problems/find-all-groups-of-farmland/README.md b/problems/find-all-groups-of-farmland/README.md index 60fc424fe..c44ea8517 100644 --- a/problems/find-all-groups-of-farmland/README.md +++ b/problems/find-all-groups-of-farmland/README.md @@ -73,7 +73,7 @@ Since every group of farmland is rectangular, the top left corner of each group
    Hint 2 -Similarly, the top left corner of each group will have the largest x-coordinate and y-coordinate of any farmland in the group. +Similarly, the bootm right corner of each group will have the largest x-coordinate and y-coordinate of any farmland in the group.
    diff --git a/problems/find-customer-referee/mysql_schemas.sql b/problems/find-customer-referee/mysql_schemas.sql index 76b3abc7c..77f4671ec 100644 --- a/problems/find-customer-referee/mysql_schemas.sql +++ b/problems/find-customer-referee/mysql_schemas.sql @@ -1,8 +1,8 @@ -CREATE TABLE IF NOT EXISTS customer (id INT,name VARCHAR(25),referee_id INT);; -Truncate table customer; -insert into customer (id, name, referee_id) values ('1', 'Will', 'None'); -insert into customer (id, name, referee_id) values ('2', 'Jane', 'None'); -insert into customer (id, name, referee_id) values ('3', 'Alex', '2'); -insert into customer (id, name, referee_id) values ('4', 'Bill', 'None'); -insert into customer (id, name, referee_id) values ('5', 'Zack', '1'); -insert into customer (id, name, referee_id) values ('6', 'Mark', '2'); +Create table If Not Exists Customer (id int, name varchar(25), referee_id int); +Truncate table Customer; +insert into Customer (id, name, referee_id) values ('1', 'Will', 'None'); +insert into Customer (id, name, referee_id) values ('2', 'Jane', 'None'); +insert into Customer (id, name, referee_id) values ('3', 'Alex', '2'); +insert into Customer (id, name, referee_id) values ('4', 'Bill', 'None'); +insert into Customer (id, name, referee_id) values ('5', 'Zack', '1'); +insert into Customer (id, name, referee_id) values ('6', 'Mark', '2'); diff --git a/problems/find-distance-in-a-binary-tree/README.md b/problems/find-distance-in-a-binary-tree/README.md index e7f24cae8..707c7eb48 100644 --- a/problems/find-distance-in-a-binary-tree/README.md +++ b/problems/find-distance-in-a-binary-tree/README.md @@ -14,10 +14,10 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/find-kth-bit-in-nth-binary-string/README.md b/problems/find-kth-bit-in-nth-binary-string/README.md index ed9f7dea6..472812324 100644 --- a/problems/find-kth-bit-in-nth-binary-string/README.md +++ b/problems/find-kth-bit-in-nth-binary-string/README.md @@ -71,8 +71,8 @@ ### Related Topics - [[String](../../tag/string/README.md)] [[Recursion](../../tag/recursion/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/find-minimum-time-to-finish-all-jobs/README.md b/problems/find-minimum-time-to-finish-all-jobs/README.md index f23240e69..092bf7ddc 100644 --- a/problems/find-minimum-time-to-finish-all-jobs/README.md +++ b/problems/find-minimum-time-to-finish-all-jobs/README.md @@ -45,15 +45,12 @@ The maximum working time is 11. ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] -### Similar Questions - 1. [Minimum Number of Work Sessions to Finish the Tasks](../minimum-number-of-work-sessions-to-finish-the-tasks) (Medium) - ### Hints
    Hint 1 diff --git a/problems/find-the-distance-value-between-two-arrays/README.md b/problems/find-the-distance-value-between-two-arrays/README.md index 862061d4c..dfe1d8545 100644 --- a/problems/find-the-distance-value-between-two-arrays/README.md +++ b/problems/find-the-distance-value-between-two-arrays/README.md @@ -11,7 +11,7 @@ ## [1385. Find the Distance Value Between Two Arrays (Easy)](https://leetcode.com/problems/find-the-distance-value-between-two-arrays "两个数组间的距离值") -

    Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays.

    +

    Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays.

    The distance value is defined as the number of elements arr1[i] such that there is not any element arr2[j] where |arr1[i]-arr2[j]| <= d.

    @@ -58,7 +58,7 @@ For arr1[2]=8 we have:
    • 1 <= arr1.length, arr2.length <= 500
    • -
    • -10^3 <= arr1[i], arr2[j] <= 10^3
    • +
    • -1000 <= arr1[i], arr2[j] <= 1000
    • 0 <= d <= 100
    diff --git a/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md b/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md new file mode 100644 index 000000000..df7f6ef2a --- /dev/null +++ b/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../smallest-index-with-equal-value "Smallest Index With Equal Value") +                 +[Next >](../minimum-operations-to-convert-number "Minimum Operations to Convert Number") + +## [2058. Find the Minimum and Maximum Number of Nodes Between Critical Points (Medium)](https://leetcode.com/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points "找出临界点之间的最小和最大距离") + +

    A critical point in a linked list is defined as either a local maxima or a local minima.

    + +

    A node is a local maxima if the current node has a value strictly greater than the previous node and the next node.

    + +

    A node is a local minima if the current node has a value strictly smaller than the previous node and the next node.

    + +

    Note that a node can only be a local maxima/minima if there exists both a previous node and a next node.

    + +

    Given a linked list head, return an array of length 2 containing [minDistance, maxDistance] where minDistance is the minimum distance between any two distinct critical points and maxDistance is the maximum distance between any two distinct critical points. If there are fewer than two critical points, return [-1, -1].

    + +

     

    +

    Example 1:

    + +
    +Input: head = [3,1]
    +Output: [-1,-1]
    +Explanation: There are no critical points in [3,1].
    +
    + +

    Example 2:

    + +
    +Input: head = [5,3,1,2,5,1,2]
    +Output: [1,3]
    +Explanation: There are three critical points:
    +- [5,3,1,2,5,1,2]: The third node is a local minima because 1 is less than 3 and 2.
    +- [5,3,1,2,5,1,2]: The fifth node is a local maxima because 5 is greater than 2 and 1.
    +- [5,3,1,2,5,1,2]: The sixth node is a local minima because 1 is less than 5 and 2.
    +The minimum distance is between the fifth and the sixth node. minDistance = 6 - 5 = 1.
    +The maximum distance is between the third and the sixth node. maxDistance = 6 - 3 = 3.
    +
    + +

    Example 3:

    + +
    +Input: head = [1,3,2,2,3,2,2,2,7]
    +Output: [3,3]
    +Explanation: There are two critical points:
    +- [1,3,2,2,3,2,2,2,7]: The second node is a local maxima because 3 is greater than 1 and 2.
    +- [1,3,2,2,3,2,2,2,7]: The fifth node is a local maxima because 3 is greater than 2 and 2.
    +Both the minimum and maximum distances are between the second and the fifth node.
    +Thus, minDistance and maxDistance is 5 - 2 = 3.
    +Note that the last node is not considered a local maxima because it does not have a next node.
    +
    + +

    Example 4:

    + +
    +Input: head = [2,3,3,2]
    +Output: [-1,-1]
    +Explanation: There are no critical points in [2,3,3,2].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is in the range [2, 105].
    • +
    • 1 <= Node.val <= 105
    • +
    + +### Related Topics + [[Linked List](../../tag/linked-list/README.md)] + +### Hints +
    +Hint 1 +The maximum distance must be the distance between the first and last critical point. +
    + +
    +Hint 2 +For each adjacent critical point, calculate the difference and check if it is the minimum distance. +
    diff --git a/problems/find-the-missing-ids/README.md b/problems/find-the-missing-ids/README.md index f3802ddc8..36acbeda6 100644 --- a/problems/find-the-missing-ids/README.md +++ b/problems/find-the-missing-ids/README.md @@ -15,3 +15,8 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Report Contiguous Dates](../report-contiguous-dates) (Hard) + 1. [Find the Start and End Number of Continuous Ranges](../find-the-start-and-end-number-of-continuous-ranges) (Medium) + 1. [Number of Transactions per Visit](../number-of-transactions-per-visit) (Hard) diff --git a/problems/find-valid-matrix-given-row-and-column-sums/README.md b/problems/find-valid-matrix-given-row-and-column-sums/README.md index ac285d0b9..40380151c 100644 --- a/problems/find-valid-matrix-given-row-and-column-sums/README.md +++ b/problems/find-valid-matrix-given-row-and-column-sums/README.md @@ -76,10 +76,13 @@ Another possible matrix is: [[1,2], ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Reconstruct a 2-Row Binary Matrix](../reconstruct-a-2-row-binary-matrix) (Medium) + ### Hints
    Hint 1 diff --git a/problems/first-unique-character-in-a-string/README.md b/problems/first-unique-character-in-a-string/README.md index c58d7222c..00f41ca4d 100644 --- a/problems/first-unique-character-in-a-string/README.md +++ b/problems/first-unique-character-in-a-string/README.md @@ -33,9 +33,9 @@ ### Related Topics - [[Queue](../../tag/queue/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Queue](../../tag/queue/README.md)] [[Counting](../../tag/counting/README.md)] ### Similar Questions diff --git a/problems/first-unique-number/README.md b/problems/first-unique-number/README.md index fca55d778..9607addcc 100644 --- a/problems/first-unique-number/README.md +++ b/problems/first-unique-number/README.md @@ -14,10 +14,10 @@ ### Related Topics - [[Design](../../tag/design/README.md)] - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] [[Data Stream](../../tag/data-stream/README.md)] ### Hints diff --git a/problems/fizz-buzz-multithreaded/README.md b/problems/fizz-buzz-multithreaded/README.md index e73fb106d..998449392 100644 --- a/problems/fizz-buzz-multithreaded/README.md +++ b/problems/fizz-buzz-multithreaded/README.md @@ -65,3 +65,7 @@ ### Related Topics [[Concurrency](../../tag/concurrency/README.md)] + +### Similar Questions + 1. [Fizz Buzz](../fizz-buzz) (Easy) + 1. [Print Zero Even Odd](../print-zero-even-odd) (Medium) diff --git a/problems/form-array-by-concatenating-subarrays-of-another-array/README.md b/problems/form-array-by-concatenating-subarrays-of-another-array/README.md index 2130761a9..2be6bddc1 100644 --- a/problems/form-array-by-concatenating-subarrays-of-another-array/README.md +++ b/problems/form-array-by-concatenating-subarrays-of-another-array/README.md @@ -59,8 +59,8 @@ They share a common elements nums[4] (0-indexed). ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[String Matching](../../tag/string-matching/README.md)] ### Hints diff --git a/problems/furthest-building-you-can-reach/README.md b/problems/furthest-building-you-can-reach/README.md index a1caf89c8..46e316b3f 100644 --- a/problems/furthest-building-you-can-reach/README.md +++ b/problems/furthest-building-you-can-reach/README.md @@ -63,8 +63,8 @@ It is impossible to go beyond building 4 because you do not have any more bricks ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/gas-station/README.md b/problems/gas-station/README.md index 9a4c1432b..23e9d83d9 100644 --- a/problems/gas-station/README.md +++ b/problems/gas-station/README.md @@ -53,10 +53,10 @@ Therefore, you can't travel around the circuit once no matter where you star
    • gas.length == n
    • cost.length == n
    • -
    • 1 <= n <= 104
    • +
    • 1 <= n <= 105
    • 0 <= gas[i], cost[i] <= 104
    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/get-maximum-in-generated-array/README.md b/problems/get-maximum-in-generated-array/README.md index 7fbcf4414..3e9575206 100644 --- a/problems/get-maximum-in-generated-array/README.md +++ b/problems/get-maximum-in-generated-array/README.md @@ -11,7 +11,7 @@ ## [1646. Get Maximum in Generated Array (Easy)](https://leetcode.com/problems/get-maximum-in-generated-array "获取生成数组中的最大值") -

    You are given an integer n. An array nums of length n + 1 is generated in the following way:

    +

    You are given an integer n. A 0-indexed integer array nums of length n + 1 is generated in the following way:

    • nums[0] = 0
    • @@ -37,7 +37,7 @@ nums[(2 * 2) + 1 = 5] = nums[2] + nums[3] = 1 + 2 = 3 nums[(3 * 2) = 6] = nums[3] = 2 nums[(3 * 2) + 1 = 7] = nums[3] + nums[4] = 2 + 1 = 3 -Hence, nums = [0,1,1,2,1,3,2,3], and the maximum is 3. +Hence, nums = [0,1,1,2,1,3,2,3], and the maximum is max(0,1,1,2,1,3,2,3) = 3.

      Example 2:

      @@ -45,7 +45,7 @@ Hence, nums = [0,1,1,2,1,3,2,3], and the maximum is 3.
       Input: n = 2
       Output: 1
      -Explanation: According to the given rules, the maximum between nums[0], nums[1], and nums[2] is 1.
      +Explanation: According to the given rules, nums = [0,1,1]. The maximum is max(0,1,1) = 1.
       

      Example 3:

      @@ -53,7 +53,7 @@ Hence, nums = [0,1,1,2,1,3,2,3], and the maximum is 3.
       Input: n = 3
       Output: 2
      -Explanation: According to the given rules, the maximum between nums[0], nums[1], nums[2], and nums[3] is 2.
      +Explanation: According to the given rules, nums = [0,1,1,2]. The maximum is max(0,1,1,2) = 2.
       

       

      diff --git a/problems/graph-connectivity-with-threshold/README.md b/problems/graph-connectivity-with-threshold/README.md index d471d5221..06834dd1c 100644 --- a/problems/graph-connectivity-with-threshold/README.md +++ b/problems/graph-connectivity-with-threshold/README.md @@ -74,9 +74,9 @@ Please notice that there can be multiple queries for the same pair of nodes [x,
    ### Related Topics - [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Union Find](../../tag/union-find/README.md)] ### Hints
    diff --git a/problems/graph-valid-tree/README.md b/problems/graph-valid-tree/README.md index 1613d7917..811f8946d 100644 --- a/problems/graph-valid-tree/README.md +++ b/problems/graph-valid-tree/README.md @@ -36,6 +36,7 @@ ### Similar Questions 1. [Course Schedule](../course-schedule) (Medium) 1. [Number of Connected Components in an Undirected Graph](../number-of-connected-components-in-an-undirected-graph) (Medium) + 1. [Keys and Rooms](../keys-and-rooms) (Medium) ### Hints
    diff --git a/problems/h-index/README.md b/problems/h-index/README.md index 7bb1f9d82..5e924ef5d 100644 --- a/problems/h-index/README.md +++ b/problems/h-index/README.md @@ -45,8 +45,8 @@ Since the researcher has 3 papers with at least 3 citations each and the remaini ### Related Topics [[Array](../../tag/array/README.md)] - [[Counting Sort](../../tag/counting-sort/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Counting Sort](../../tag/counting-sort/README.md)] ### Similar Questions 1. [H-Index II](../h-index-ii) (Medium) diff --git a/problems/hopper-company-queries-i/README.md b/problems/hopper-company-queries-i/README.md index 7656d5e8c..4b5a7682e 100644 --- a/problems/hopper-company-queries-i/README.md +++ b/problems/hopper-company-queries-i/README.md @@ -15,3 +15,8 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Trips and Users](../trips-and-users) (Hard) + 1. [Hopper Company Queries II](../hopper-company-queries-ii) (Hard) + 1. [Hopper Company Queries III](../hopper-company-queries-iii) (Hard) diff --git a/problems/how-many-apples-can-you-put-into-the-basket/README.md b/problems/how-many-apples-can-you-put-into-the-basket/README.md index a3eff6ff0..81d680a95 100644 --- a/problems/how-many-apples-can-you-put-into-the-basket/README.md +++ b/problems/how-many-apples-can-you-put-into-the-basket/README.md @@ -41,8 +41,8 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/index-pairs-of-a-string/README.md b/problems/index-pairs-of-a-string/README.md index bf0d3c379..69275ff74 100644 --- a/problems/index-pairs-of-a-string/README.md +++ b/problems/index-pairs-of-a-string/README.md @@ -45,9 +45,9 @@ Notice that matches can overlap, see "aba" is found in [0,2] and [2,4] ### Related Topics - [[Trie](../../tag/trie/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Trie](../../tag/trie/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/integer-replacement/README.md b/problems/integer-replacement/README.md index 3acb44928..ca7535ef4 100644 --- a/problems/integer-replacement/README.md +++ b/problems/integer-replacement/README.md @@ -53,6 +53,7 @@ or 7 -> 6 -> 3 -> 2 -> 1 ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Memoization](../../tag/memoization/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/investments-in-2016/mysql_schemas.sql b/problems/investments-in-2016/mysql_schemas.sql index b46743fd4..7541fd98a 100644 --- a/problems/investments-in-2016/mysql_schemas.sql +++ b/problems/investments-in-2016/mysql_schemas.sql @@ -1,6 +1,6 @@ -CREATE TABLE IF NOT EXISTS insurance (PID INTEGER(11), TIV_2015 NUMERIC(15,2), TIV_2016 NUMERIC(15,2), LAT NUMERIC(5,2), LON NUMERIC(5,2) ); -Truncate table insurance; -insert into insurance (PID, TIV_2015, TIV_2016, LAT, LON) values ('1', '10', '5', '10', '10'); -insert into insurance (PID, TIV_2015, TIV_2016, LAT, LON) values ('2', '20', '20', '20', '20'); -insert into insurance (PID, TIV_2015, TIV_2016, LAT, LON) values ('3', '10', '30', '20', '20'); -insert into insurance (PID, TIV_2015, TIV_2016, LAT, LON) values ('4', '10', '40', '40', '40'); +Create Table If Not Exists Insurance (pid int, tiv_2015 float, tiv_2016 float, lat float, lon float); +Truncate table Insurance; +insert into Insurance (pid, tiv_2015, tiv_2016, lat, lon) values ('1', '10', '5', '10', '10'); +insert into Insurance (pid, tiv_2015, tiv_2016, lat, lon) values ('2', '20', '20', '20', '20'); +insert into Insurance (pid, tiv_2015, tiv_2016, lat, lon) values ('3', '10', '30', '20', '20'); +insert into Insurance (pid, tiv_2015, tiv_2016, lat, lon) values ('4', '10', '40', '40', '40'); diff --git a/problems/ip-to-cidr/README.md b/problems/ip-to-cidr/README.md index e1bf2aabc..1e4eb571f 100644 --- a/problems/ip-to-cidr/README.md +++ b/problems/ip-to-cidr/README.md @@ -63,8 +63,8 @@ that are outside the specified range.

    ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[String](../../tag/string/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Restore IP Addresses](../restore-ip-addresses) (Medium) diff --git a/problems/iterator-for-combination/README.md b/problems/iterator-for-combination/README.md index 18bcb683a..a196371df 100644 --- a/problems/iterator-for-combination/README.md +++ b/problems/iterator-for-combination/README.md @@ -14,9 +14,9 @@

    Design the CombinationIterator class:

      -
    • CombinationIterator(string characters, int combinationLength) Initializes the object with a string characters of sorted distinct lowercase English letters and a number combinationLength as arguments.
    • -
    • next() Returns the next combination of length combinationLength in lexicographical order.
    • -
    • hasNext() Returns true if and only if there exists a next combination.
    • +
    • CombinationIterator(string characters, int combinationLength) Initializes the object with a string characters of sorted distinct lowercase English letters and a number combinationLength as arguments.
    • +
    • next() Returns the next combination of length combinationLength in lexicographical order.
    • +
    • hasNext() Returns true if and only if there exists a next combination.

     

    @@ -43,16 +43,16 @@ itr.hasNext(); // return False

    Constraints:

      -
    • 1 <= combinationLength <= characters.length <= 15
    • +
    • 1 <= combinationLength <= characters.length <= 15
    • All the characters of characters are unique.
    • -
    • At most 104 calls will be made to next and hasNext.
    • -
    • It's guaranteed that all calls of the function next are valid.
    • +
    • At most 104 calls will be made to next and hasNext.
    • +
    • It is guaranteed that all calls of the function next are valid.
    ### Related Topics + [[Design](../../tag/design/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] - [[Design](../../tag/design/README.md)] [[Iterator](../../tag/iterator/README.md)] ### Hints diff --git a/problems/k-diff-pairs-in-an-array/README.md b/problems/k-diff-pairs-in-an-array/README.md index dbfcab6fe..a78983e37 100644 --- a/problems/k-diff-pairs-in-an-array/README.md +++ b/problems/k-diff-pairs-in-an-array/README.md @@ -80,3 +80,5 @@ Although we have two 1s in the input, we should only return the number of ### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Array](../../tag/array/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] diff --git a/problems/kth-ancestor-of-a-tree-node/README.md b/problems/kth-ancestor-of-a-tree-node/README.md index eb59c8b0f..45fab111e 100644 --- a/problems/kth-ancestor-of-a-tree-node/README.md +++ b/problems/kth-ancestor-of-a-tree-node/README.md @@ -51,12 +51,12 @@ treeAncestor.getKthAncestor(6, 3); // returns -1 because there is no such ancest ### Related Topics - [[Binary Search](../../tag/binary-search/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Design](../../tag/design/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/kth-distinct-string-in-an-array/README.md b/problems/kth-distinct-string-in-an-array/README.md new file mode 100644 index 000000000..f92f4b12e --- /dev/null +++ b/problems/kth-distinct-string-in-an-array/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../minimum-cost-to-separate-sentence-into-rows "Minimum Cost to Separate Sentence Into Rows") +                 +[Next >](../two-best-non-overlapping-events "Two Best Non-Overlapping Events") + +## [2053. Kth Distinct String in an Array (Easy)](https://leetcode.com/problems/kth-distinct-string-in-an-array "数组中第 K 个独一无二的字符串") + +

    A distinct string is a string that is present only once in an array.

    + +

    Given an array of strings arr, and an integer k, return the kth distinct string present in arr. If there are fewer than k distinct strings, return an empty string "".

    + +

    Note that the strings are considered in the order in which they appear in the array.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = ["d","b","c","b","c","a"], k = 2
    +Output: "a"
    +Explanation:
    +The only distinct strings in arr are "d" and "a".
    +"d" appears 1st, so it is the 1st distinct string.
    +"a" appears 2nd, so it is the 2nd distinct string.
    +Since k == 2, "a" is returned. 
    +
    + +

    Example 2:

    + +
    +Input: arr = ["aaa","aa","a"], k = 1
    +Output: "aaa"
    +Explanation:
    +All strings in arr are distinct, so the 1st string "aaa" is returned.
    +
    + +

    Example 3:

    + +
    +Input: arr = ["a","b","a"], k = 3
    +Output: ""
    +Explanation:
    +The only distinct string is "b". Since there are fewer than 3 distinct strings, we return an empty string "".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= arr.length <= 1000
    • +
    • 1 <= arr[i].length <= 5
    • +
    • arr[i] consists of lowercase English letters.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Hints +
    +Hint 1 +Try 'mapping' the strings to check if they are unique or not. +
    diff --git a/problems/largest-merge-of-two-strings/README.md b/problems/largest-merge-of-two-strings/README.md index d0e7b18d9..d34b995e1 100644 --- a/problems/largest-merge-of-two-strings/README.md +++ b/problems/largest-merge-of-two-strings/README.md @@ -61,9 +61,9 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/largest-subarray-length-k/README.md b/problems/largest-subarray-length-k/README.md index c4643ca22..468e3c7c9 100644 --- a/problems/largest-subarray-length-k/README.md +++ b/problems/largest-subarray-length-k/README.md @@ -14,8 +14,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/latest-time-by-replacing-hidden-digits/README.md b/problems/latest-time-by-replacing-hidden-digits/README.md index cb8487ada..d149d6f02 100644 --- a/problems/latest-time-by-replacing-hidden-digits/README.md +++ b/problems/latest-time-by-replacing-hidden-digits/README.md @@ -50,6 +50,7 @@ ### Related Topics [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/linked-list-components/README.md b/problems/linked-list-components/README.md index 16e27528e..ec94414ff 100644 --- a/problems/linked-list-components/README.md +++ b/problems/linked-list-components/README.md @@ -41,7 +41,7 @@
  • 0 <= Node.val < n
  • All the values Node.val are unique.
  • 1 <= nums.length <= n
  • -
  • 0 <= nums[i] <= n
  • +
  • 0 <= nums[i] < n
  • All the values of nums are unique.
  • diff --git a/problems/longest-duplicate-substring/README.md b/problems/longest-duplicate-substring/README.md index 3542daf1e..b40016fef 100644 --- a/problems/longest-duplicate-substring/README.md +++ b/problems/longest-duplicate-substring/README.md @@ -34,10 +34,10 @@ ### Related Topics [[String](../../tag/string/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] - [[Rolling Hash](../../tag/rolling-hash/README.md)] [[Suffix Array](../../tag/suffix-array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/longest-increasing-path-in-a-matrix/README.md b/problems/longest-increasing-path-in-a-matrix/README.md index e180b85d2..213f6ceaf 100644 --- a/problems/longest-increasing-path-in-a-matrix/README.md +++ b/problems/longest-increasing-path-in-a-matrix/README.md @@ -50,9 +50,9 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] [[Memoization](../../tag/memoization/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/longest-increasing-subsequence/README.md b/problems/longest-increasing-subsequence/README.md index 671123113..ee3880e5b 100644 --- a/problems/longest-increasing-subsequence/README.md +++ b/problems/longest-increasing-subsequence/README.md @@ -60,3 +60,5 @@ 1. [Maximum Length of Pair Chain](../maximum-length-of-pair-chain) (Medium) 1. [Number of Longest Increasing Subsequence](../number-of-longest-increasing-subsequence) (Medium) 1. [Minimum ASCII Delete Sum for Two Strings](../minimum-ascii-delete-sum-for-two-strings) (Medium) + 1. [Minimum Number of Removals to Make Mountain Array](../minimum-number-of-removals-to-make-mountain-array) (Hard) + 1. [Find the Longest Valid Obstacle Course at Each Position](../find-the-longest-valid-obstacle-course-at-each-position) (Hard) diff --git a/problems/longest-nice-substring/README.md b/problems/longest-nice-substring/README.md index a51c01026..4448c532b 100644 --- a/problems/longest-nice-substring/README.md +++ b/problems/longest-nice-substring/README.md @@ -56,9 +56,9 @@ As there are multiple longest nice substrings, return "dD" since it oc ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints diff --git a/problems/longest-palindromic-subsequence/README.md b/problems/longest-palindromic-subsequence/README.md index 0a73ec183..7ba508696 100644 --- a/problems/longest-palindromic-subsequence/README.md +++ b/problems/longest-palindromic-subsequence/README.md @@ -48,3 +48,7 @@ 1. [Longest Palindromic Substring](../longest-palindromic-substring) (Medium) 1. [Palindromic Substrings](../palindromic-substrings) (Medium) 1. [Count Different Palindromic Subsequences](../count-different-palindromic-subsequences) (Hard) + 1. [Longest Common Subsequence](../longest-common-subsequence) (Medium) + 1. [Longest Palindromic Subsequence II](../longest-palindromic-subsequence-ii) (Medium) + 1. [Maximize Palindrome Length From Subsequences](../maximize-palindrome-length-from-subsequences) (Hard) + 1. [Maximum Product of the Length of Two Palindromic Subsequences](../maximum-product-of-the-length-of-two-palindromic-subsequences) (Medium) diff --git a/problems/longest-palindromic-substring/README.md b/problems/longest-palindromic-substring/README.md index 369742823..ef45a2370 100644 --- a/problems/longest-palindromic-substring/README.md +++ b/problems/longest-palindromic-substring/README.md @@ -7,7 +7,7 @@ [< Previous](../median-of-two-sorted-arrays "Median of Two Sorted Arrays")                  -[Next >](../zigzag-conversion "ZigZag Conversion") +[Next >](../zigzag-conversion "Zigzag Conversion") ## [5. Longest Palindromic Substring (Medium)](https://leetcode.com/problems/longest-palindromic-substring "最长回文子串") diff --git a/problems/longest-substring-with-at-least-k-repeating-characters/README.md b/problems/longest-substring-with-at-least-k-repeating-characters/README.md index 2429b4075..2186a91b8 100644 --- a/problems/longest-substring-with-at-least-k-repeating-characters/README.md +++ b/problems/longest-substring-with-at-least-k-repeating-characters/README.md @@ -44,3 +44,7 @@ [[String](../../tag/string/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + +### Similar Questions + 1. [Longest Subsequence Repeated k Times](../longest-subsequence-repeated-k-times) (Hard) + 1. [Number of Equal Count Substrings](../number-of-equal-count-substrings) (Medium) diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md index a8e298dd3..f0cf11398 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md @@ -14,16 +14,10 @@ ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] -### Similar Questions - 1. [Lowest Common Ancestor of a Binary Search Tree](../lowest-common-ancestor-of-a-binary-search-tree) (Easy) - 1. [Lowest Common Ancestor of a Binary Tree](../lowest-common-ancestor-of-a-binary-tree) (Medium) - 1. [Lowest Common Ancestor of a Binary Tree II](../lowest-common-ancestor-of-a-binary-tree-ii) (Medium) - 1. [Lowest Common Ancestor of a Binary Tree IV](../lowest-common-ancestor-of-a-binary-tree-iv) (Medium) - ### Hints
    Hint 1 diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md index bd96ddd5d..ecc88fe56 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md @@ -18,6 +18,14 @@ [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Lowest Common Ancestor of a Binary Search Tree](../lowest-common-ancestor-of-a-binary-search-tree) (Easy) + 1. [Lowest Common Ancestor of a Binary Tree](../lowest-common-ancestor-of-a-binary-tree) (Medium) + 1. [Lowest Common Ancestor of Deepest Leaves](../lowest-common-ancestor-of-deepest-leaves) (Medium) + 1. [Lowest Common Ancestor of a Binary Tree II](../lowest-common-ancestor-of-a-binary-tree-ii) (Medium) + 1. [Lowest Common Ancestor of a Binary Tree III](../lowest-common-ancestor-of-a-binary-tree-iii) (Medium) + 1. [Lowest Common Ancestor of a Binary Tree IV](../lowest-common-ancestor-of-a-binary-tree-iv) (Medium) + ### Hints
    Hint 1 diff --git a/problems/lowest-common-ancestor-of-deepest-leaves/README.md b/problems/lowest-common-ancestor-of-deepest-leaves/README.md index 4abc2574d..723e47239 100644 --- a/problems/lowest-common-ancestor-of-deepest-leaves/README.md +++ b/problems/lowest-common-ancestor-of-deepest-leaves/README.md @@ -11,18 +11,16 @@ ## [1123. Lowest Common Ancestor of Deepest Leaves (Medium)](https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves "最深叶节点的最近公共祖先") -

    Given the root of a binary tree, return the lowest common ancestor of its deepest leaves.

    +

    Given the root of a binary tree, return the lowest common ancestor of its deepest leaves.

    Recall that:

    • The node of a binary tree is a leaf if and only if it has no children
    • -
    • The depth of the root of the tree is 0. if the depth of a node is d, the depth of each of its children is d + 1.
    • +
    • The depth of the root of the tree is 0. if the depth of a node is d, the depth of each of its children is d + 1.
    • The lowest common ancestor of a set S of nodes, is the node A with the largest depth such that every node in S is in the subtree with root A.
    -

    Note: This question is the same as 865: https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/

    -

     

    Example 1:

    @@ -55,9 +53,12 @@ Note that nodes 6, 0, and 8 are also leaf nodes, but the depth of them is 2, but
    • The number of nodes in the tree will be in the range [1, 1000].
    • 0 <= Node.val <= 1000
    • -
    • The values of the nodes in the tree are unique.
    • +
    • The values of the nodes in the tree are unique.
    +

     

    +

    Note: This question is the same as 865: https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/

    + ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/magnetic-force-between-two-balls/README.md b/problems/magnetic-force-between-two-balls/README.md index 7d0cb6355..7cf25a0cb 100644 --- a/problems/magnetic-force-between-two-balls/README.md +++ b/problems/magnetic-force-between-two-balls/README.md @@ -50,6 +50,9 @@ [[Binary Search](../../tag/binary-search/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Minimized Maximum of Products Distributed to Any Store](../minimized-maximum-of-products-distributed-to-any-store) (Medium) + ### Hints
    Hint 1 diff --git a/problems/make-sum-divisible-by-p/README.md b/problems/make-sum-divisible-by-p/README.md index d20c220ff..7339ec36b 100644 --- a/problems/make-sum-divisible-by-p/README.md +++ b/problems/make-sum-divisible-by-p/README.md @@ -71,6 +71,9 @@ [[Hash Table](../../tag/hash-table/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] +### Similar Questions + 1. [Subarray Sums Divisible by K](../subarray-sums-divisible-by-k) (Medium) + ### Hints
    Hint 1 diff --git a/problems/make-the-xor-of-all-segments-equal-to-zero/README.md b/problems/make-the-xor-of-all-segments-equal-to-zero/README.md index 5a2d02c40..1a20704bd 100644 --- a/problems/make-the-xor-of-all-segments-equal-to-zero/README.md +++ b/problems/make-the-xor-of-all-segments-equal-to-zero/README.md @@ -48,9 +48,9 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/map-of-highest-peak/README.md b/problems/map-of-highest-peak/README.md index 52e0c84f2..c5d8c841d 100644 --- a/problems/map-of-highest-peak/README.md +++ b/problems/map-of-highest-peak/README.md @@ -65,8 +65,8 @@ Any height assignment that has a maximum height of 2 while still meeting the rul ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/max-chunks-to-make-sorted-ii/README.md b/problems/max-chunks-to-make-sorted-ii/README.md index 577755e36..c0c9f7075 100644 --- a/problems/max-chunks-to-make-sorted-ii/README.md +++ b/problems/max-chunks-to-make-sorted-ii/README.md @@ -47,9 +47,9 @@ However, splitting into [2, 1], [3], [4], [4] is the highest number of chunks po ### Related Topics + [[Array](../../tag/array/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] diff --git a/problems/max-number-of-k-sum-pairs/README.md b/problems/max-number-of-k-sum-pairs/README.md index f52bd07bd..5f9d4e125 100644 --- a/problems/max-number-of-k-sum-pairs/README.md +++ b/problems/max-number-of-k-sum-pairs/README.md @@ -52,6 +52,10 @@ There are no more pairs that sum up to 6, hence a total of 1 operation. [[Two Pointers](../../tag/two-pointers/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Two Sum](../two-sum) (Easy) + 1. [Count Good Meals](../count-good-meals) (Medium) + ### Hints
    Hint 1 diff --git a/problems/maximize-number-of-nice-divisors/README.md b/problems/maximize-number-of-nice-divisors/README.md index cd91cb86b..962ddb55d 100644 --- a/problems/maximize-number-of-nice-divisors/README.md +++ b/problems/maximize-number-of-nice-divisors/README.md @@ -48,8 +48,11 @@ There is not other value of n that has at most 5 prime factors and more nice div ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Math](../../tag/math/README.md)] + [[Recursion](../../tag/recursion/README.md)] + +### Similar Questions + 1. [Integer Break](../integer-break) (Medium) ### Hints
    diff --git a/problems/maximize-palindrome-length-from-subsequences/README.md b/problems/maximize-palindrome-length-from-subsequences/README.md index 2eefe38e1..ecd3dcc68 100644 --- a/problems/maximize-palindrome-length-from-subsequences/README.md +++ b/problems/maximize-palindrome-length-from-subsequences/README.md @@ -59,6 +59,9 @@ [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Longest Palindromic Subsequence](../longest-palindromic-subsequence) (Medium) + ### Hints
    Hint 1 diff --git a/problems/maximize-the-beauty-of-the-garden/README.md b/problems/maximize-the-beauty-of-the-garden/README.md index 5e094774d..5ac672d74 100644 --- a/problems/maximize-the-beauty-of-the-garden/README.md +++ b/problems/maximize-the-beauty-of-the-garden/README.md @@ -14,8 +14,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints diff --git a/problems/maximum-absolute-sum-of-any-subarray/README.md b/problems/maximum-absolute-sum-of-any-subarray/README.md index 7a8fd35f0..8c23314be 100644 --- a/problems/maximum-absolute-sum-of-any-subarray/README.md +++ b/problems/maximum-absolute-sum-of-any-subarray/README.md @@ -51,6 +51,9 @@ [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Maximum Subarray](../maximum-subarray) (Easy) + ### Hints
    Hint 1 diff --git a/problems/maximum-average-pass-ratio/README.md b/problems/maximum-average-pass-ratio/README.md index 7ff7c691a..d6491109e 100644 --- a/problems/maximum-average-pass-ratio/README.md +++ b/problems/maximum-average-pass-ratio/README.md @@ -46,8 +46,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/maximum-average-subtree/README.md b/problems/maximum-average-subtree/README.md index 1d4060c3f..c47644c8e 100644 --- a/problems/maximum-average-subtree/README.md +++ b/problems/maximum-average-subtree/README.md @@ -46,6 +46,9 @@ So the answer is 6 which is the maximum. [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Count Nodes Equal to Sum of Descendants](../count-nodes-equal-to-sum-of-descendants) (Medium) + ### Hints
    Hint 1 diff --git a/problems/maximum-binary-string-after-change/README.md b/problems/maximum-binary-string-after-change/README.md index ba26d20c5..2f37d4d4a 100644 --- a/problems/maximum-binary-string-after-change/README.md +++ b/problems/maximum-binary-string-after-change/README.md @@ -59,8 +59,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/maximum-distance-between-a-pair-of-values/README.md b/problems/maximum-distance-between-a-pair-of-values/README.md index 0ea83b677..c25f541de 100644 --- a/problems/maximum-distance-between-a-pair-of-values/README.md +++ b/problems/maximum-distance-between-a-pair-of-values/README.md @@ -59,8 +59,7 @@ The maximum distance is 2 with pair (2,4).

    Constraints:

      -
    • 1 <= nums1.length <= 105
    • -
    • 1 <= nums2.length <= 105
    • +
    • 1 <= nums1.length, nums2.length <= 105
    • 1 <= nums1[i], nums2[j] <= 105
    • Both nums1 and nums2 are non-increasing.
    diff --git a/problems/maximum-equal-frequency/README.md b/problems/maximum-equal-frequency/README.md index 790dae684..9557464da 100644 --- a/problems/maximum-equal-frequency/README.md +++ b/problems/maximum-equal-frequency/README.md @@ -49,8 +49,8 @@

    Constraints:

      -
    • 2 <= nums.length <= 10^5
    • -
    • 1 <= nums[i] <= 10^5
    • +
    • 2 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 105
    ### Related Topics diff --git a/problems/maximum-nesting-depth-of-the-parentheses/README.md b/problems/maximum-nesting-depth-of-the-parentheses/README.md index b1ae9a2e3..cda784e44 100644 --- a/problems/maximum-nesting-depth-of-the-parentheses/README.md +++ b/problems/maximum-nesting-depth-of-the-parentheses/README.md @@ -72,8 +72,11 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[String](../../tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] + +### Similar Questions + 1. [Maximum Nesting Depth of Two Valid Parentheses Strings](../maximum-nesting-depth-of-two-valid-parentheses-strings) (Medium) ### Hints
    diff --git a/problems/maximum-number-of-coins-you-can-get/README.md b/problems/maximum-number-of-coins-you-can-get/README.md index 310a9960b..7b7eae3e9 100644 --- a/problems/maximum-number-of-coins-you-can-get/README.md +++ b/problems/maximum-number-of-coins-you-can-get/README.md @@ -61,11 +61,11 @@ On the other hand if we choose this arrangement (1, 2, 8), (2, ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Game Theory](../../tag/game-theory/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-events-that-can-be-attended-ii/README.md b/problems/maximum-number-of-events-that-can-be-attended-ii/README.md index 0b0bc2903..e0d998f2a 100644 --- a/problems/maximum-number-of-events-that-can-be-attended-ii/README.md +++ b/problems/maximum-number-of-events-that-can-be-attended-ii/README.md @@ -61,6 +61,11 @@ Notice that you cannot attend any other event as they overlap, and that you do < [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Maximum Number of Events That Can Be Attended](../maximum-number-of-events-that-can-be-attended) (Medium) + 1. [Maximum Earnings From Taxi](../maximum-earnings-from-taxi) (Medium) + 1. [Two Best Non-Overlapping Events](../two-best-non-overlapping-events) (Medium) + ### Hints
    Hint 1 diff --git a/problems/maximum-number-of-tasks-you-can-assign/README.md b/problems/maximum-number-of-tasks-you-can-assign/README.md new file mode 100644 index 000000000..c3ba54efe --- /dev/null +++ b/problems/maximum-number-of-tasks-you-can-assign/README.md @@ -0,0 +1,98 @@ + + + + + + + +[< Previous](../most-beautiful-item-for-each-query "Most Beautiful Item for Each Query") +                 +[Next >](../the-winner-university "The Winner University") + +## [2071. Maximum Number of Tasks You Can Assign (Hard)](https://leetcode.com/problems/maximum-number-of-tasks-you-can-assign "你可以安排的最多任务数目") + +

    You have n tasks and m workers. Each task has a strength requirement stored in a 0-indexed integer array tasks, with the ith task requiring tasks[i] strength to complete. The strength of each worker is stored in a 0-indexed integer array workers, with the jth worker having workers[j] strength. Each worker can only be assigned to a single task and must have a strength greater than or equal to the task's strength requirement (i.e., workers[j] >= tasks[i]).

    + +

    Additionally, you have pills magical pills that will increase a worker's strength by strength. You can decide which workers receive the magical pills, however, you may only give each worker at most one magical pill.

    + +

    Given the 0-indexed integer arrays tasks and workers and the integers pills and strength, return the maximum number of tasks that can be completed.

    + +

     

    +

    Example 1:

    + +
    +Input: tasks = [3,2,1], workers = [0,3,3], pills = 1, strength = 1
    +Output: 3
    +Explanation:
    +We can assign the magical pill and tasks as follows:
    +- Give the magical pill to worker 0.
    +- Assign worker 0 to task 2 (0 + 1 >= 1)
    +- Assign worker 1 to task 1 (3 >= 2)
    +- Assign worker 2 to task 0 (3 >= 3)
    +
    + +

    Example 2:

    + +
    +Input: tasks = [5,4], workers = [0,0,0], pills = 1, strength = 5
    +Output: 1
    +Explanation:
    +We can assign the magical pill and tasks as follows:
    +- Give the magical pill to worker 0.
    +- Assign worker 0 to task 0 (0 + 5 >= 5)
    +
    + +

    Example 3:

    + +
    +Input: tasks = [10,15,30], workers = [0,10,10,10,10], pills = 3, strength = 10
    +Output: 2
    +Explanation:
    +We can assign the magical pills and tasks as follows:
    +- Give the magical pill to worker 0 and worker 1.
    +- Assign worker 0 to task 0 (0 + 10 >= 10)
    +- Assign worker 1 to task 1 (10 + 10 >= 15)
    +
    + +

    Example 4:

    + +
    +Input: tasks = [5,9,8,5,9], workers = [1,6,4,2,6], pills = 1, strength = 5
    +Output: 3
    +Explanation:
    +We can assign the magical pill and tasks as follows:
    +- Give the magical pill to worker 2.
    +- Assign worker 1 to task 0 (6 >= 5)
    +- Assign worker 2 to task 2 (4 + 5 >= 8)
    +- Assign worker 4 to task 3 (6 >= 5)
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == tasks.length
    • +
    • m == workers.length
    • +
    • 1 <= n, m <= 5 * 104
    • +
    • 0 <= pills <= m
    • +
    • 0 <= tasks[i], workers[j], strength <= 109
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] + +### Hints +
    +Hint 1 +Is it possible to assign the first k smallest tasks to the workers? +
    + +
    +Hint 2 +How can you efficiently try every k? +
    diff --git a/problems/maximum-of-minimum-values-in-all-subarrays/README.md b/problems/maximum-of-minimum-values-in-all-subarrays/README.md index 71932b7b0..7df537e3f 100644 --- a/problems/maximum-of-minimum-values-in-all-subarrays/README.md +++ b/problems/maximum-of-minimum-values-in-all-subarrays/README.md @@ -13,6 +13,11 @@ +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] + ### Hints
    Hint 1 diff --git a/problems/maximum-path-quality-of-a-graph/README.md b/problems/maximum-path-quality-of-a-graph/README.md new file mode 100644 index 000000000..051e550b3 --- /dev/null +++ b/problems/maximum-path-quality-of-a-graph/README.md @@ -0,0 +1,94 @@ + + + + + + + +[< Previous](../minimized-maximum-of-products-distributed-to-any-store "Minimized Maximum of Products Distributed to Any Store") +                 +[Next >](../account-balance "Account Balance") + +## [2065. Maximum Path Quality of a Graph (Hard)](https://leetcode.com/problems/maximum-path-quality-of-a-graph "最大化一张图中的路径价值") + +

    There is an undirected graph with n nodes numbered from 0 to n - 1 (inclusive). You are given a 0-indexed integer array values where values[i] is the value of the ith node. You are also given a 0-indexed 2D integer array edges, where each edges[j] = [uj, vj, timej] indicates that there is an undirected edge between the nodes uj and vj, and it takes timej seconds to travel between the two nodes. Finally, you are given an integer maxTime.

    + +

    A valid path in the graph is any path that starts at node 0, ends at node 0, and takes at most maxTime seconds to complete. You may visit the same node multiple times. The quality of a valid path is the sum of the values of the unique nodes visited in the path (each node's value is added at most once to the sum).

    + +

    Return the maximum quality of a valid path.

    + +

    Note: There are at most four edges connected to each node.

    + +

     

    +

    Example 1:

    + +
    +Input: values = [0,32,10,43], edges = [[0,1,10],[1,2,15],[0,3,10]], maxTime = 49
    +Output: 75
    +Explanation:
    +One possible path is 0 -> 1 -> 0 -> 3 -> 0. The total time taken is 10 + 10 + 10 + 10 = 40 <= 49.
    +The nodes visited are 0, 1, and 3, giving a maximal path quality of 0 + 32 + 43 = 75.
    +
    + +

    Example 2:

    + +
    +Input: values = [5,10,15,20], edges = [[0,1,10],[1,2,10],[0,3,10]], maxTime = 30
    +Output: 25
    +Explanation:
    +One possible path is 0 -> 3 -> 0. The total time taken is 10 + 10 = 20 <= 30.
    +The nodes visited are 0 and 3, giving a maximal path quality of 5 + 20 = 25.
    +
    + +

    Example 3:

    + +
    +Input: values = [1,2,3,4], edges = [[0,1,10],[1,2,11],[2,3,12],[1,3,13]], maxTime = 50
    +Output: 7
    +Explanation:
    +One possible path is 0 -> 1 -> 3 -> 1 -> 0. The total time taken is 10 + 13 + 13 + 10 = 46 <= 50.
    +The nodes visited are 0, 1, and 3, giving a maximal path quality of 1 + 2 + 4 = 7.
    + +

    Example 4:

    + +

    + +
    +Input: values = [0,1,2], edges = [[1,2,10]], maxTime = 10
    +Output: 0
    +Explanation: 
    +The only path is 0. The total time taken is 0.
    +The only node visited is 0, giving a maximal path quality of 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == values.length
    • +
    • 1 <= n <= 1000
    • +
    • 0 <= values[i] <= 108
    • +
    • 0 <= edges.length <= 2000
    • +
    • edges[j].length == 3
    • +
    • 0 <= uj < vj <= n - 1
    • +
    • 10 <= timej, maxTime <= 100
    • +
    • All the pairs [uj, vj] are unique.
    • +
    • There are at most four edges connected to each node.
    • +
    • The graph may not be connected.
    • +
    + +### Related Topics + [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + +### Hints +
    +Hint 1 +How many nodes can you visit within maxTime seconds? +
    + +
    +Hint 2 +Can you try every valid path? +
    diff --git a/problems/maximum-score-from-performing-multiplication-operations/README.md b/problems/maximum-score-from-performing-multiplication-operations/README.md index c4deff3bb..8537c3b8b 100644 --- a/problems/maximum-score-from-performing-multiplication-operations/README.md +++ b/problems/maximum-score-from-performing-multiplication-operations/README.md @@ -64,6 +64,10 @@ The total score is 50 + 15 - 9 + 4 + 42 = 102. [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Maximum Points You Can Obtain from Cards](../maximum-points-you-can-obtain-from-cards) (Medium) + 1. [Stone Game VII](../stone-game-vii) (Medium) + ### Hints
    Hint 1 diff --git a/problems/maximum-score-from-removing-stones/README.md b/problems/maximum-score-from-removing-stones/README.md index 1c3587b37..96ed16df6 100644 --- a/problems/maximum-score-from-removing-stones/README.md +++ b/problems/maximum-score-from-removing-stones/README.md @@ -64,8 +64,8 @@ After that, there are fewer than two non-empty piles, so the game ends. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/maximum-score-from-removing-substrings/README.md b/problems/maximum-score-from-removing-substrings/README.md index 194104d20..88b5b05a6 100644 --- a/problems/maximum-score-from-removing-substrings/README.md +++ b/problems/maximum-score-from-removing-substrings/README.md @@ -58,9 +58,9 @@ Total score = 5 + 4 + 5 + 5 = 19. ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/maximum-score-of-a-good-subarray/README.md b/problems/maximum-score-of-a-good-subarray/README.md index e513c8e21..0d95a2e7d 100644 --- a/problems/maximum-score-of-a-good-subarray/README.md +++ b/problems/maximum-score-of-a-good-subarray/README.md @@ -44,12 +44,15 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Stack](../../tag/stack/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] +### Similar Questions + 1. [Largest Rectangle in Histogram](../largest-rectangle-in-histogram) (Hard) + ### Hints
    Hint 1 diff --git a/problems/maximum-subarray-sum-after-one-operation/README.md b/problems/maximum-subarray-sum-after-one-operation/README.md index 0c2afea07..391cf4e8a 100644 --- a/problems/maximum-subarray-sum-after-one-operation/README.md +++ b/problems/maximum-subarray-sum-after-one-operation/README.md @@ -17,6 +17,9 @@ [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Maximum Subarray](../maximum-subarray) (Easy) + ### Hints
    Hint 1 diff --git a/problems/maximum-sum-obtained-of-any-permutation/README.md b/problems/maximum-sum-obtained-of-any-permutation/README.md index dcb1c3861..a6863f609 100644 --- a/problems/maximum-sum-obtained-of-any-permutation/README.md +++ b/problems/maximum-sum-obtained-of-any-permutation/README.md @@ -60,10 +60,10 @@ Total sum: 11 + 8 = 19, which is the best that you can do. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] - [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/maximum-xor-with-an-element-from-array/README.md b/problems/maximum-xor-with-an-element-from-array/README.md index aaef703f0..eb4acccfb 100644 --- a/problems/maximum-xor-with-an-element-from-array/README.md +++ b/problems/maximum-xor-with-an-element-from-array/README.md @@ -46,9 +46,13 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Trie](../../tag/trie/README.md)] - [[Array](../../tag/array/README.md)] + +### Similar Questions + 1. [Maximum XOR of Two Numbers in an Array](../maximum-xor-of-two-numbers-in-an-array) (Medium) + 1. [Maximum Genetic Difference Query](../maximum-genetic-difference-query) (Hard) ### Hints
    diff --git a/problems/merge-strings-alternately/README.md b/problems/merge-strings-alternately/README.md index dc54e2d06..db11585b5 100644 --- a/problems/merge-strings-alternately/README.md +++ b/problems/merge-strings-alternately/README.md @@ -61,6 +61,9 @@ merged: a p b q c d [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Zigzag Iterator](../zigzag-iterator) (Medium) + ### Hints
    Hint 1 diff --git a/problems/min-cost-to-connect-all-points/README.md b/problems/min-cost-to-connect-all-points/README.md index 9000431ca..02ad17018 100644 --- a/problems/min-cost-to-connect-all-points/README.md +++ b/problems/min-cost-to-connect-all-points/README.md @@ -69,8 +69,8 @@ Notice that there is a unique path between every pair of points. ### Related Topics - [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] + [[Union Find](../../tag/union-find/README.md)] [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] ### Hints diff --git a/problems/minimize-deviation-in-array/README.md b/problems/minimize-deviation-in-array/README.md index 785b9ce08..59de5ccf4 100644 --- a/problems/minimize-deviation-in-array/README.md +++ b/problems/minimize-deviation-in-array/README.md @@ -66,10 +66,10 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Array](../../tag/array/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/minimize-hamming-distance-after-swap-operations/README.md b/problems/minimize-hamming-distance-after-swap-operations/README.md index 8b2ac2ea0..2e92aaeec 100644 --- a/problems/minimize-hamming-distance-after-swap-operations/README.md +++ b/problems/minimize-hamming-distance-after-swap-operations/README.md @@ -59,12 +59,9 @@ The Hamming distance of source and target is 2 as they differ in 2 positions: in ### Related Topics - [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - -### Similar Questions - 1. [Smallest String With Swaps](../smallest-string-with-swaps) (Medium) + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/minimized-maximum-of-products-distributed-to-any-store/README.md b/problems/minimized-maximum-of-products-distributed-to-any-store/README.md new file mode 100644 index 000000000..0a00c12a9 --- /dev/null +++ b/problems/minimized-maximum-of-products-distributed-to-any-store/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../vowels-of-all-substrings "Vowels of All Substrings") +                 +[Next >](../maximum-path-quality-of-a-graph "Maximum Path Quality of a Graph") + +## [2064. Minimized Maximum of Products Distributed to Any Store (Medium)](https://leetcode.com/problems/minimized-maximum-of-products-distributed-to-any-store "分配给商店的最多商品的最小值") + +

    You are given an integer n indicating there are n specialty retail stores. There are m product types of varying amounts, which are given as a 0-indexed integer array quantities, where quantities[i] represents the number of products of the ith product type.

    + +

    You need to distribute all products to the retail stores following these rules:

    + +
      +
    • A store can only be given at most one product type but can be given any amount of it.
    • +
    • After distribution, each store will have been given some number of products (possibly 0). Let x represent the maximum number of products given to any store. You want x to be as small as possible, i.e., you want to minimize the maximum number of products that are given to any store.
    • +
    + +

    Return the minimum possible x.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 6, quantities = [11,6]
    +Output: 3
    +Explanation: One optimal way is:
    +- The 11 products of type 0 are distributed to the first four stores in these amounts: 2, 3, 3, 3
    +- The 6 products of type 1 are distributed to the other two stores in these amounts: 3, 3
    +The maximum number of products given to any store is max(2, 3, 3, 3, 3, 3) = 3.
    +
    + +

    Example 2:

    + +
    +Input: n = 7, quantities = [15,10,10]
    +Output: 5
    +Explanation: One optimal way is:
    +- The 15 products of type 0 are distributed to the first three stores in these amounts: 5, 5, 5
    +- The 10 products of type 1 are distributed to the next two stores in these amounts: 5, 5
    +- The 10 products of type 2 are distributed to the last two stores in these amounts: 5, 5
    +The maximum number of products given to any store is max(5, 5, 5, 5, 5, 5, 5) = 5.
    +
    + +

    Example 3:

    + +
    +Input: n = 1, quantities = [100000]
    +Output: 100000
    +Explanation: The only optimal way is:
    +- The 100000 products of type 0 are distributed to the only store.
    +The maximum number of products given to any store is max(100000) = 100000.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == quantities.length
    • +
    • 1 <= m <= n <= 105
    • +
    • 1 <= quantities[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +There exists a monotonic nature such that when x is smaller than some number, there will be no way to distribute, and when x is not smaller than that number, there will always be a way to distribute. +
    + +
    +Hint 2 +If you are given a number k, where the number of products given to any store does not exceed k, could you determine if all products can be distributed? +
    + +
    +Hint 3 +Implement a function canDistribute(k), which returns true if you can distribute all products such that any store will not be given more than k products, and returns false if you cannot. Use this function to binary search for the smallest possible k. +
    diff --git a/problems/minimum-absolute-sum-difference/README.md b/problems/minimum-absolute-sum-difference/README.md index 561cb0971..de66d4865 100644 --- a/problems/minimum-absolute-sum-difference/README.md +++ b/problems/minimum-absolute-sum-difference/README.md @@ -67,10 +67,10 @@ This yields an absolute sum difference of |10-9| + |10-3| + |4-5| + |4-1| ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md b/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md index 860cd1ae1..cbbe3cb7c 100644 --- a/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md +++ b/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md @@ -50,10 +50,14 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] - [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Similar Questions + 1. [Minimum Swaps to Group All 1's Together](../minimum-swaps-to-group-all-1s-together) (Medium) + 1. [Minimum Number of Operations to Make Array Continuous](../minimum-number-of-operations-to-make-array-continuous) (Hard) ### Hints
    diff --git a/problems/minimum-cost-to-connect-two-groups-of-points/README.md b/problems/minimum-cost-to-connect-two-groups-of-points/README.md index cc6a19f95..7d2218d62 100644 --- a/problems/minimum-cost-to-connect-two-groups-of-points/README.md +++ b/problems/minimum-cost-to-connect-two-groups-of-points/README.md @@ -62,11 +62,11 @@ Note that there are multiple points connected to point 2 in the first group and ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Bitmask](../../tag/bitmask/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Matrix](../../tag/matrix/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/minimum-cost-to-separate-sentence-into-rows/README.md b/problems/minimum-cost-to-separate-sentence-into-rows/README.md new file mode 100644 index 000000000..17d922a39 --- /dev/null +++ b/problems/minimum-cost-to-separate-sentence-into-rows/README.md @@ -0,0 +1,34 @@ + + + + + + + +[< Previous](../the-category-of-each-member-in-the-store "The Category of Each Member in the Store") +                 +[Next >](../kth-distinct-string-in-an-array "Kth Distinct String in an Array") + +## [2052. Minimum Cost to Separate Sentence Into Rows (Medium)](https://leetcode.com/problems/minimum-cost-to-separate-sentence-into-rows "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Create an array storing all of the words in sentence separated. +
    + +
    +Hint 2 +Try dynamic programming. +
    + +
    +Hint 3 +Build a dp array where dp[i] represents the minimum total cost for the first i + 1 words. +
    diff --git a/problems/minimum-deletions-to-make-character-frequencies-unique/README.md b/problems/minimum-deletions-to-make-character-frequencies-unique/README.md index c1ab8ee8a..7832dcdcd 100644 --- a/problems/minimum-deletions-to-make-character-frequencies-unique/README.md +++ b/problems/minimum-deletions-to-make-character-frequencies-unique/README.md @@ -52,8 +52,8 @@ Note that we only care about characters that are still in the string at the end ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/minimum-deletions-to-make-string-balanced/README.md b/problems/minimum-deletions-to-make-string-balanced/README.md index 8db9ec049..1c757d15b 100644 --- a/problems/minimum-deletions-to-make-string-balanced/README.md +++ b/problems/minimum-deletions-to-make-string-balanced/README.md @@ -45,9 +45,9 @@ Delete the characters at 0-indexed positions 3 and 6 ("aababba ### Related Topics - [[Stack](../../tag/stack/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Stack](../../tag/stack/README.md)] ### Hints
    diff --git a/problems/minimum-elements-to-add-to-form-a-given-sum/README.md b/problems/minimum-elements-to-add-to-form-a-given-sum/README.md index cb2567cc7..7d9b5723f 100644 --- a/problems/minimum-elements-to-add-to-form-a-given-sum/README.md +++ b/problems/minimum-elements-to-add-to-form-a-given-sum/README.md @@ -44,8 +44,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/minimum-falling-path-sum/README.md b/problems/minimum-falling-path-sum/README.md index 9b36ac783..9e7856ffb 100644 --- a/problems/minimum-falling-path-sum/README.md +++ b/problems/minimum-falling-path-sum/README.md @@ -17,39 +17,26 @@

     

    Example 1:

    - +
     Input: matrix = [[2,1,3],[6,5,4],[7,8,9]]
     Output: 13
    -Explanation: There are two falling paths with a minimum sum underlined below:
    -[[2,1,3],      [[2,1,3],
    - [6,5,4],       [6,5,4],
    - [7,8,9]]       [7,8,9]]
    +Explanation: There are two falling paths with a minimum sum as shown.
     

    Example 2:

    - +
     Input: matrix = [[-19,57],[-40,-5]]
     Output: -59
    -Explanation: The falling path with a minimum sum is underlined below:
    -[[-19,57],
    - [-40,-5]]
    -
    - -

    Example 3:

    - -
    -Input: matrix = [[-48]]
    -Output: -48
    +Explanation: The falling path with a minimum sum is shown.
     

     

    Constraints:

      -
    • n == matrix.length
    • -
    • n == matrix[i].length
    • +
    • n == matrix.length == matrix[i].length
    • 1 <= n <= 100
    • -100 <= matrix[i][j] <= 100
    @@ -58,3 +45,6 @@ [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Matrix](../../tag/matrix/README.md)] + +### Similar Questions + 1. [Minimum Falling Path Sum II](../minimum-falling-path-sum-ii) (Hard) diff --git a/problems/minimum-incompatibility/README.md b/problems/minimum-incompatibility/README.md index 1bb816cd0..7dbfed95f 100644 --- a/problems/minimum-incompatibility/README.md +++ b/problems/minimum-incompatibility/README.md @@ -56,9 +56,9 @@ The incompatibility is (2-1) + (3-2) + (8-6) + (3-1) = 6. ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] ### Hints diff --git a/problems/minimum-initial-energy-to-finish-tasks/README.md b/problems/minimum-initial-energy-to-finish-tasks/README.md index ee29ca74f..88eac2a24 100644 --- a/problems/minimum-initial-energy-to-finish-tasks/README.md +++ b/problems/minimum-initial-energy-to-finish-tasks/README.md @@ -74,8 +74,8 @@ Starting with 27 energy, we finish the tasks in the following order: ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/minimum-jumps-to-reach-home/README.md b/problems/minimum-jumps-to-reach-home/README.md index 86c939c0f..cee72e6fb 100644 --- a/problems/minimum-jumps-to-reach-home/README.md +++ b/problems/minimum-jumps-to-reach-home/README.md @@ -62,9 +62,9 @@ ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Hints
    diff --git a/problems/minimum-limit-of-balls-in-a-bag/README.md b/problems/minimum-limit-of-balls-in-a-bag/README.md index 166ebf7fe..996ff699d 100644 --- a/problems/minimum-limit-of-balls-in-a-bag/README.md +++ b/problems/minimum-limit-of-balls-in-a-bag/README.md @@ -71,6 +71,9 @@ The bag with the most number of balls has 2 balls, so your penalty is 2 an you s [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] +### Similar Questions + 1. [Minimized Maximum of Products Distributed to Any Store](../minimized-maximum-of-products-distributed-to-any-store) (Medium) + ### Hints
    Hint 1 diff --git a/problems/minimum-number-of-frogs-croaking/README.md b/problems/minimum-number-of-frogs-croaking/README.md index 493964769..4ad168c9b 100644 --- a/problems/minimum-number-of-frogs-croaking/README.md +++ b/problems/minimum-number-of-frogs-croaking/README.md @@ -11,9 +11,11 @@ ## [1419. Minimum Number of Frogs Croaking (Medium)](https://leetcode.com/problems/minimum-number-of-frogs-croaking "数青蛙") -

    Given the string croakOfFrogs, which represents a combination of the string "croak" from different frogs, that is, multiple frogs can croak at the same time, so multiple “croak” are mixed. Return the minimum number of different frogs to finish all the croak in the given string.

    +

    You are given the string croakOfFrogs, which represents a combination of the string "croak" from different frogs, that is, multiple frogs can croak at the same time, so multiple "croak" are mixed.

    -

    A valid "croak" means a frog is printing 5 letters ‘c’, ’r’, ’o’, ’a’, ’k’ sequentially. The frogs have to print all five letters to finish a croak. If the given string is not a combination of valid "croak" return -1.

    +

    Return the minimum number of different frogs to finish all the croaks in the given string.

    + +

    A valid "croak" means a frog is printing five letters 'c', 'r', 'o', 'a', and 'k' sequentially. The frogs have to print all five letters to finish a croak. If the given string is not a combination of a valid "croak" return -1.

     

    Example 1:

    @@ -29,7 +31,7 @@
     Input: croakOfFrogs = "crcoakroak"
     Output: 2 
    -Explanation: The minimum number of frogs is two. 
    +Explanation: The minimum number of frogs is two. 
     The first frog could yell "crcoakroak".
     The second frog could yell later "crcoakroak".
     
    @@ -42,19 +44,12 @@ The second frog could yell later "crcoakroakExplanation: The given string is an invalid combination of "croak" from different frogs. -

    Example 4:

    - -
    -Input: croakOfFrogs = "croakcroa"
    -Output: -1
    -
    -

     

    Constraints:

      -
    • 1 <= croakOfFrogs.length <= 10^5
    • -
    • All characters in the string are: 'c', 'r', 'o', 'a' or 'k'.
    • +
    • 1 <= croakOfFrogs.length <= 105
    • +
    • croakOfFrogs is either 'c', 'r', 'o', 'a', or 'k'.
    ### Related Topics diff --git a/problems/minimum-number-of-moves-to-seat-everyone/README.md b/problems/minimum-number-of-moves-to-seat-everyone/README.md index 996c558f9..8667b1d0c 100644 --- a/problems/minimum-number-of-moves-to-seat-everyone/README.md +++ b/problems/minimum-number-of-moves-to-seat-everyone/README.md @@ -21,7 +21,7 @@

    Return the minimum number of moves required to move each student to a seat such that no two students are in the same seat.

    -

    Note that there may be multiple seats or students in the same position at the beginning.

    +

    Note that there may be multiple seats or students in the same position at the beginning.

     

    Example 1:

    @@ -29,7 +29,7 @@
     Input: seats = [3,1,5], students = [2,7,4]
     Output: 4
    -Explanation: The students are moved as follows:
    +Explanation: The students are moved as follows:
     - The first student is moved from from position 2 to position 1 using 1 move.
     - The second student is moved from from position 7 to position 5 using 2 moves.
     - The third student is moved from from position 4 to position 3 using 1 move.
    @@ -41,7 +41,7 @@ In total, 1 + 2 + 1 = 4 moves were used.
     
     Input: seats = [4,1,5,9], students = [1,3,2,6]
     Output: 7
    -Explanation: The students are moved as follows:
    +Explanation: The students are moved as follows:
     - The first student is not moved.
     - The second student is moved from from position 3 to position 4 using 1 move.
     - The third student is moved from from position 2 to position 5 using 3 moves.
    @@ -54,7 +54,8 @@ In total, 0 + 1 + 3 + 3 = 7 moves were used.
     
     Input: seats = [2,2,6,6], students = [1,3,2,6]
     Output: 4
    -Explanation: The students are moved as follows:
    +Explanation: Note that there are two seats at position 2 and two seats at position 6.
    +The students are moved as follows:
     - The first student is moved from from position 1 to position 2 using 1 move.
     - The second student is moved from from position 3 to position 6 using 3 moves.
     - The third student is not moved.
    diff --git a/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md b/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md
    index 60ff1d8f5..39d2ee8a2 100644
    --- a/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md
    +++ b/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md
    @@ -50,6 +50,9 @@
       [[Array](../../tag/array/README.md)]
       [[String](../../tag/string/README.md)]
     
    +### Similar Questions
    +  1. [Minimum Cost to Move Chips to The Same Position](../minimum-cost-to-move-chips-to-the-same-position) (Easy)
    +
     ### Hints
     
    Hint 1 diff --git a/problems/minimum-number-of-people-to-teach/README.md b/problems/minimum-number-of-people-to-teach/README.md index 0da9d8daa..1dc39674f 100644 --- a/problems/minimum-number-of-people-to-teach/README.md +++ b/problems/minimum-number-of-people-to-teach/README.md @@ -56,8 +56,8 @@ Note that friendships are not transitive, meaning if x is a friend ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/minimum-number-of-removals-to-make-mountain-array/README.md b/problems/minimum-number-of-removals-to-make-mountain-array/README.md index f9ab29ddf..732e11a35 100644 --- a/problems/minimum-number-of-removals-to-make-mountain-array/README.md +++ b/problems/minimum-number-of-removals-to-make-mountain-array/README.md @@ -66,10 +66,17 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Similar Questions + 1. [Longest Increasing Subsequence](../longest-increasing-subsequence) (Medium) + 1. [Longest Mountain in Array](../longest-mountain-in-array) (Medium) + 1. [Peak Index in a Mountain Array](../peak-index-in-a-mountain-array) (Easy) + 1. [Valid Mountain Array](../valid-mountain-array) (Easy) + 1. [Find in Mountain Array](../find-in-mountain-array) (Hard) ### Hints
    diff --git a/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md b/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md index 21ee9a594..0dfac9e44 100644 --- a/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md +++ b/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md @@ -72,8 +72,8 @@ Total of operations: 2 + 1 = 3. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/minimum-one-bit-operations-to-make-integers-zero/README.md b/problems/minimum-one-bit-operations-to-make-integers-zero/README.md index cb5a915e0..b04d7fdaf 100644 --- a/problems/minimum-one-bit-operations-to-make-integers-zero/README.md +++ b/problems/minimum-one-bit-operations-to-make-integers-zero/README.md @@ -72,12 +72,9 @@ ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Memoization](../../tag/memoization/README.md)] - -### Similar Questions - 1. [Minimum Number of Operations to Make Array Continuous](../minimum-number-of-operations-to-make-array-continuous) (Hard) + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/minimum-operations-to-convert-number/README.md b/problems/minimum-operations-to-convert-number/README.md new file mode 100644 index 000000000..090f581f2 --- /dev/null +++ b/problems/minimum-operations-to-convert-number/README.md @@ -0,0 +1,107 @@ + + + + + + + +[< Previous](../find-the-minimum-and-maximum-number-of-nodes-between-critical-points "Find the Minimum and Maximum Number of Nodes Between Critical Points") +                 +[Next >](../check-if-an-original-string-exists-given-two-encoded-strings "Check if an Original String Exists Given Two Encoded Strings") + +## [2059. Minimum Operations to Convert Number (Medium)](https://leetcode.com/problems/minimum-operations-to-convert-number "转化数字的最小运算数") + +

    You are given a 0-indexed integer array nums containing distinct numbers, an integer start, and an integer goal. There is an integer x that is initially set to start, and you want to perform operations on x such that it is converted to goal. You can perform the following operation repeatedly on the number x:

    + +

    If 0 <= x <= 1000, then for any index i in the array (0 <= i < nums.length), you can set x to any of the following:

    + +
      +
    • x + nums[i]
    • +
    • x - nums[i]
    • +
    • x ^ nums[i] (bitwise-XOR)
    • +
    + +

    Note that you can use each nums[i] any number of times in any order. Operations that set x to be out of the range 0 <= x <= 1000 are valid, but no more operations can be done afterward.

    + +

    Return the minimum number of operations needed to convert x = start into goal, and -1 if it is not possible.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,3], start = 6, goal = 4
    +Output: 2
    +Explanation:
    +We can go from 6 → 7 → 4 with the following 2 operations.
    +- 6 ^ 1 = 7
    +- 7 ^ 3 = 4
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,4,12], start = 2, goal = 12
    +Output: 2
    +Explanation:
    +We can go from 2 → 14 → 12 with the following 2 operations.
    +- 2 + 12 = 14
    +- 14 - 2 = 12
    +
    + +

    Example 3:

    + +
    +Input: nums = [3,5,7], start = 0, goal = -4
    +Output: 2
    +Explanation:
    +We can go from 0 → 3 → -4 with the following 2 operations. 
    +- 0 + 3 = 3
    +- 3 - 7 = -4
    +Note that the last operation sets x out of the range 0 <= x <= 1000, which is valid.
    +
    + +

    Example 4:

    + +
    +Input: nums = [2,8,16], start = 0, goal = 1
    +Output: -1
    +Explanation:
    +There is no way to convert 0 into 1.
    + +

    Example 5:

    + +
    +Input: nums = [1], start = 0, goal = 3
    +Output: 3
    +Explanation: 
    +We can go from 0 → 1 → 2 → 3 with the following 3 operations. 
    +- 0 + 1 = 1 
    +- 1 + 1 = 2
    +- 2 + 1 = 3
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • -109 <= nums[i], goal <= 109
    • +
    • 0 <= start <= 1000
    • +
    • start != goal
    • +
    • All the integers in nums are distinct.
    • +
    + +### Related Topics + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Once x drops below 0 or goes above 1000, is it possible to continue performing operations on x? +
    + +
    +Hint 2 +How can you use BFS to find the minimum operations? +
    diff --git a/problems/minimum-operations-to-make-a-subsequence/README.md b/problems/minimum-operations-to-make-a-subsequence/README.md index c805ac2d5..1f0095ead 100644 --- a/problems/minimum-operations-to-make-a-subsequence/README.md +++ b/problems/minimum-operations-to-make-a-subsequence/README.md @@ -45,10 +45,10 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/minimum-operations-to-reduce-x-to-zero/README.md b/problems/minimum-operations-to-reduce-x-to-zero/README.md index 4dd99132b..0b14663ae 100644 --- a/problems/minimum-operations-to-reduce-x-to-zero/README.md +++ b/problems/minimum-operations-to-reduce-x-to-zero/README.md @@ -51,13 +51,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] - -### Similar Questions - 1. [Minimum Size Subarray Sum](../minimum-size-subarray-sum) (Medium) - 1. [Subarray Sum Equals K](../subarray-sum-equals-k) (Medium) + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/minimum-path-cost-in-a-hidden-grid/README.md b/problems/minimum-path-cost-in-a-hidden-grid/README.md index 4d7d7a664..96b02ee45 100644 --- a/problems/minimum-path-cost-in-a-hidden-grid/README.md +++ b/problems/minimum-path-cost-in-a-hidden-grid/README.md @@ -17,8 +17,12 @@ [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] - [[Interactive](../../tag/interactive/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Interactive](../../tag/interactive/README.md)] + +### Similar Questions + 1. [Robot Room Cleaner](../robot-room-cleaner) (Hard) + 1. [Shortest Path in a Hidden Grid](../shortest-path-in-a-hidden-grid) (Medium) ### Hints
    diff --git a/problems/minimum-remove-to-make-valid-parentheses/README.md b/problems/minimum-remove-to-make-valid-parentheses/README.md index a8280751f..b9c47d07b 100644 --- a/problems/minimum-remove-to-make-valid-parentheses/README.md +++ b/problems/minimum-remove-to-make-valid-parentheses/README.md @@ -11,16 +11,16 @@ ## [1249. Minimum Remove to Make Valid Parentheses (Medium)](https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses "移除无效的括号") -

    Given a string s of '(' , ')' and lowercase English characters. 

    +

    Given a string s of '(' , ')' and lowercase English characters.

    -

    Your task is to remove the minimum number of parentheses ( '(' or ')', in any positions ) so that the resulting parentheses string is valid and return any valid string.

    +

    Your task is to remove the minimum number of parentheses ( '(' or ')', in any positions ) so that the resulting parentheses string is valid and return any valid string.

    Formally, a parentheses string is valid if and only if:

    • It is the empty string, contains only lowercase characters, or
    • -
    • It can be written as AB (A concatenated with B), where A and B are valid strings, or
    • -
    • It can be written as (A), where A is a valid string.
    • +
    • It can be written as AB (A concatenated with B), where A and B are valid strings, or
    • +
    • It can be written as (A), where A is a valid string.

     

    @@ -58,8 +58,8 @@

    Constraints:

      -
    • 1 <= s.length <= 10^5
    • -
    • s[i] is one of  '(' , ')' and lowercase English letters.
    • +
    • 1 <= s.length <= 105
    • +
    • s[i] is either'(' , ')', or lowercase English letter.
    ### Related Topics diff --git a/problems/minimum-swaps-to-make-strings-equal/README.md b/problems/minimum-swaps-to-make-strings-equal/README.md index 93d4e667a..e50b97c41 100644 --- a/problems/minimum-swaps-to-make-strings-equal/README.md +++ b/problems/minimum-swaps-to-make-strings-equal/README.md @@ -11,9 +11,9 @@ ## [1247. Minimum Swaps to Make Strings Equal (Medium)](https://leetcode.com/problems/minimum-swaps-to-make-strings-equal "交换字符使得字符串相同") -

    You are given two strings s1 and s2 of equal length consisting of letters "x" and "y" only. Your task is to make these two strings equal to each other. You can swap any two characters that belong to different strings, which means: swap s1[i] and s2[j].

    +

    You are given two strings s1 and s2 of equal length consisting of letters "x" and "y" only. Your task is to make these two strings equal to each other. You can swap any two characters that belong to different strings, which means: swap s1[i] and s2[j].

    -

    Return the minimum number of swaps required to make s1 and s2 equal, or return -1 if it is impossible to do so.

    +

    Return the minimum number of swaps required to make s1 and s2 equal, or return -1 if it is impossible to do so.

     

    Example 1:

    @@ -24,7 +24,7 @@ Explanation: Swap s1[0] and s2[1], s1 = "yx", s2 = "yx".
    -

    Example 2: 

    +

    Example 2:

     Input: s1 = "xy", s2 = "yx"
    @@ -53,7 +53,7 @@ Note that you can't swap s1[0] and s1[1] to make s1 equal to "yx",
     
     
    • 1 <= s1.length, s2.length <= 1000
    • -
    • s1, s2 only contain 'x' or 'y'.
    • +
    • s1, s2 only contain 'x' or 'y'.
    ### Related Topics diff --git a/problems/missing-number/README.md b/problems/missing-number/README.md index 2e382e59f..c6300790f 100644 --- a/problems/missing-number/README.md +++ b/problems/missing-number/README.md @@ -13,8 +13,6 @@

    Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.

    -

    Follow up: Could you implement a solution using only O(1) extra space complexity and O(n) runtime complexity?

    -

     

    Example 1:

    @@ -58,6 +56,9 @@
  • All the numbers of nums are unique.
  • +

     

    +

    Follow up: Could you implement a solution using only O(1) extra space complexity and O(n) runtime complexity?

    + ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] diff --git a/problems/most-beautiful-item-for-each-query/README.md b/problems/most-beautiful-item-for-each-query/README.md new file mode 100644 index 000000000..8b0c0dcc5 --- /dev/null +++ b/problems/most-beautiful-item-for-each-query/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../walking-robot-simulation-ii "Walking Robot Simulation II") +                 +[Next >](../maximum-number-of-tasks-you-can-assign "Maximum Number of Tasks You Can Assign") + +## [2070. Most Beautiful Item for Each Query (Medium)](https://leetcode.com/problems/most-beautiful-item-for-each-query "每一个查询的最大美丽值") + +

    You are given a 2D integer array items where items[i] = [pricei, beautyi] denotes the price and beauty of an item respectively.

    + +

    You are also given a 0-indexed integer array queries. For each queries[j], you want to determine the maximum beauty of an item whose price is less than or equal to queries[j]. If no such item exists, then the answer to this query is 0.

    + +

    Return an array answer of the same length as queries where answer[j] is the answer to the jth query.

    + +

     

    +

    Example 1:

    + +
    +Input: items = [[1,2],[3,2],[2,4],[5,6],[3,5]], queries = [1,2,3,4,5,6]
    +Output: [2,4,5,5,6,6]
    +Explanation:
    +- For queries[0]=1, [1,2] is the only item which has price <= 1. Hence, the answer for this query is 2.
    +- For queries[1]=2, the items which can be considered are [1,2] and [2,4]. 
    +  The maximum beauty among them is 4.
    +- For queries[2]=3 and queries[3]=4, the items which can be considered are [1,2], [3,2], [2,4], and [3,5].
    +  The maximum beauty among them is 5.
    +- For queries[4]=5 and queries[5]=6, all items can be considered.
    +  Hence, the answer for them is the maximum beauty of all items, i.e., 6.
    +
    + +

    Example 2:

    + +
    +Input: items = [[1,2],[1,2],[1,3],[1,4]], queries = [1]
    +Output: [4]
    +Explanation: 
    +The price of every item is equal to 1, so we choose the item with the maximum beauty 4. 
    +Note that multiple items can have the same price and/or beauty.  
    +
    + +

    Example 3:

    + +
    +Input: items = [[10,1000]], queries = [5]
    +Output: [0]
    +Explanation:
    +No item has a price less than or equal to 5, so no item can be chosen.
    +Hence, the answer to the query is 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= items.length, queries.length <= 105
    • +
    • items[i].length == 2
    • +
    • 1 <= pricei, beautyi, queries[j] <= 109
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Can we process the queries in a smart order to avoid repeatedly checking the same items? +
    + +
    +Hint 2 +How can we use the answer to a query for other queries? +
    diff --git a/problems/movie-rating/mysql_schemas.sql b/problems/movie-rating/mysql_schemas.sql index 03c2afee1..7f1cf7c36 100644 --- a/problems/movie-rating/mysql_schemas.sql +++ b/problems/movie-rating/mysql_schemas.sql @@ -1,6 +1,6 @@ Create table If Not Exists Movies (movie_id int, title varchar(30)); Create table If Not Exists Users (user_id int, name varchar(30)); -Create table If Not Exists Movie_Rating (movie_id int, user_id int, rating int, created_at date); +Create table If Not Exists MovieRating (movie_id int, user_id int, rating int, created_at date); Truncate table Movies; insert into Movies (movie_id, title) values ('1', 'Avengers'); insert into Movies (movie_id, title) values ('2', 'Frozen 2'); @@ -10,13 +10,13 @@ insert into Users (user_id, name) values ('1', 'Daniel'); insert into Users (user_id, name) values ('2', 'Monica'); insert into Users (user_id, name) values ('3', 'Maria'); insert into Users (user_id, name) values ('4', 'James'); -Truncate table Movie_Rating; -insert into Movie_Rating (movie_id, user_id, rating, created_at) values ('1', '1', '3', '2020-01-12'); -insert into Movie_Rating (movie_id, user_id, rating, created_at) values ('1', '2', '4', '2020-02-11'); -insert into Movie_Rating (movie_id, user_id, rating, created_at) values ('1', '3', '2', '2020-02-12'); -insert into Movie_Rating (movie_id, user_id, rating, created_at) values ('1', '4', '1', '2020-01-01'); -insert into Movie_Rating (movie_id, user_id, rating, created_at) values ('2', '1', '5', '2020-02-17'); -insert into Movie_Rating (movie_id, user_id, rating, created_at) values ('2', '2', '2', '2020-02-01'); -insert into Movie_Rating (movie_id, user_id, rating, created_at) values ('2', '3', '2', '2020-03-01'); -insert into Movie_Rating (movie_id, user_id, rating, created_at) values ('3', '1', '3', '2020-02-22'); -insert into Movie_Rating (movie_id, user_id, rating, created_at) values ('3', '2', '4', '2020-02-25'); +Truncate table MovieRating; +insert into MovieRating (movie_id, user_id, rating, created_at) values ('1', '1', '3', '2020-01-12'); +insert into MovieRating (movie_id, user_id, rating, created_at) values ('1', '2', '4', '2020-02-11'); +insert into MovieRating (movie_id, user_id, rating, created_at) values ('1', '3', '2', '2020-02-12'); +insert into MovieRating (movie_id, user_id, rating, created_at) values ('1', '4', '1', '2020-01-01'); +insert into MovieRating (movie_id, user_id, rating, created_at) values ('2', '1', '5', '2020-02-17'); +insert into MovieRating (movie_id, user_id, rating, created_at) values ('2', '2', '2', '2020-02-01'); +insert into MovieRating (movie_id, user_id, rating, created_at) values ('2', '3', '2', '2020-03-01'); +insert into MovieRating (movie_id, user_id, rating, created_at) values ('3', '1', '3', '2020-02-22'); +insert into MovieRating (movie_id, user_id, rating, created_at) values ('3', '2', '4', '2020-02-25'); diff --git a/problems/next-greater-numerically-balanced-number/README.md b/problems/next-greater-numerically-balanced-number/README.md new file mode 100644 index 000000000..4f7356902 --- /dev/null +++ b/problems/next-greater-numerically-balanced-number/README.md @@ -0,0 +1,76 @@ + + + + + + + +[< Previous](../number-of-valid-words-in-a-sentence "Number of Valid Words in a Sentence") +                 +[Next >](../count-nodes-with-the-highest-score "Count Nodes With the Highest Score") + +## [2048. Next Greater Numerically Balanced Number (Medium)](https://leetcode.com/problems/next-greater-numerically-balanced-number "下一个更大的数值平衡数") + +

    An integer x is numerically balanced if for every digit d in the number x, there are exactly d occurrences of that digit in x.

    + +

    Given an integer n, return the smallest numerically balanced number strictly greater than n.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 1
    +Output: 22
    +Explanation: 
    +22 is numerically balanced since:
    +- The digit 2 occurs 2 times. 
    +It is also the smallest numerically balanced number strictly greater than 1.
    +
    + +

    Example 2:

    + +
    +Input: n = 1000
    +Output: 1333
    +Explanation: 
    +1333 is numerically balanced since:
    +- The digit 1 occurs 1 time.
    +- The digit 3 occurs 3 times. 
    +It is also the smallest numerically balanced number strictly greater than 1000.
    +Note that 1022 cannot be the answer because 0 appeared more than 0 times.
    +
    + +

    Example 3:

    + +
    +Input: n = 3000
    +Output: 3133
    +Explanation: 
    +3133 is numerically balanced since:
    +- The digit 1 occurs 1 time.
    +- The digit 3 occurs 3 times.
    +It is also the smallest numerically balanced number strictly greater than 3000.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= n <= 106
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + +### Hints +
    +Hint 1 +How far away can the next greater numerically balanced number be from n? +
    + +
    +Hint 2 +With the given constraints, what is the largest numerically balanced number? +
    diff --git a/problems/non-overlapping-intervals/README.md b/problems/non-overlapping-intervals/README.md index 8a555151b..87e619f28 100644 --- a/problems/non-overlapping-intervals/README.md +++ b/problems/non-overlapping-intervals/README.md @@ -48,9 +48,9 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Similar Questions diff --git a/problems/not-boring-movies/README.md b/problems/not-boring-movies/README.md index 7af6c6351..b778ac53b 100644 --- a/problems/not-boring-movies/README.md +++ b/problems/not-boring-movies/README.md @@ -31,13 +31,15 @@ rating is a 2 decimal places float in the range [0, 10]

    Write an SQL query to report the movies with an odd-numbered ID and a description that is not "boring".

    -

    Return the result table in descending order by rating.

    +

    Return the result table ordered by rating in descending order.

    -

    The query result format is in the following example:

    +

    The query result format is in the following example.

     

    +

    Example 1:

    +Input: 
     Cinema table:
     +----+------------+-------------+--------+
     | id | movie      | description | rating |
    @@ -48,16 +50,16 @@ Cinema table:
     | 4  | Ice song   | Fantacy     | 8.6    |
     | 5  | House card | Interesting | 9.1    |
     +----+------------+-------------+--------+
    -
    -Result table:
    +Output: 
     +----+------------+-------------+--------+
     | id | movie      | description | rating |
     +----+------------+-------------+--------+
     | 5  | House card | Interesting | 9.1    |
     | 1  | War        | great 3D    | 8.9    |
     +----+------------+-------------+--------+
    -
    -We have three movies with odd-numbered ID: 1, 3, and 5. The movie with ID = 3 is boring so we don't include it in the answer.
    +Explanation: +We have three movies with odd-numbered IDs: 1, 3, and 5. The movie with ID = 3 is boring so we do not include it in the answer. +
    ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/nth-highest-salary/README.md b/problems/nth-highest-salary/README.md index ece613a10..c8364cb74 100644 --- a/problems/nth-highest-salary/README.md +++ b/problems/nth-highest-salary/README.md @@ -11,25 +11,63 @@ ## [177. Nth Highest Salary (Medium)](https://leetcode.com/problems/nth-highest-salary "第N高的薪水") -

    Write a SQL query to get the nth highest salary from the Employee table.

    +

    Table: Employee

    ++-------------+------+
    +| Column Name | Type |
    ++-------------+------+
    +| id          | int  |
    +| salary      | int  |
    ++-------------+------+
    +id is the primary key column for this table.
    +Each row of this table contains information about the salary of an employee.
    +
    + +

     

    + +

    Write an SQL query to report the nth highest salary from the Employee table. If there is no nth highest salary, the query should report null.

    + +

    The query result format is in the following example.

    + +

     

    +

    Example 1:

    + +
    +Input: 
    +Employee table:
     +----+--------+
    -| Id | Salary |
    +| id | salary |
     +----+--------+
     | 1  | 100    |
     | 2  | 200    |
     | 3  | 300    |
     +----+--------+
    +n = 2
    +Output: 
    ++------------------------+
    +| getNthHighestSalary(2) |
    ++------------------------+
    +| 200                    |
    ++------------------------+
     
    -

    For example, given the above Employee table, the nth highest salary where n = 2 is 200. If there is no nth highest salary, then the query should return null.

    +

    Example 2:

    +Input: 
    +Employee table:
    ++----+--------+
    +| id | salary |
    ++----+--------+
    +| 1  | 100    |
    ++----+--------+
    +n = 2
    +Output: 
     +------------------------+
     | getNthHighestSalary(2) |
     +------------------------+
    -| 200                    |
    +| null                   |
     +------------------------+
     
    diff --git a/problems/nth-highest-salary/mysql_schemas.sql b/problems/nth-highest-salary/mysql_schemas.sql new file mode 100644 index 000000000..aca054391 --- /dev/null +++ b/problems/nth-highest-salary/mysql_schemas.sql @@ -0,0 +1,5 @@ +Create table If Not Exists Employee (Id int, Salary int); +Truncate table Employee; +insert into Employee (id, salary) values ('1', '100'); +insert into Employee (id, salary) values ('2', '200'); +insert into Employee (id, salary) values ('3', '300'); diff --git a/problems/number-of-equal-count-substrings/README.md b/problems/number-of-equal-count-substrings/README.md new file mode 100644 index 000000000..66252ff68 --- /dev/null +++ b/problems/number-of-equal-count-substrings/README.md @@ -0,0 +1,40 @@ + + + + + + + +[< Previous](../account-balance "Account Balance") +                 +[Next >](../check-whether-two-strings-are-almost-equivalent "Check Whether Two Strings are Almost Equivalent") + +## [2067. Number of Equal Count Substrings (Medium)](https://leetcode.com/problems/number-of-equal-count-substrings "") + + + +### Related Topics + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +The brute force solution is to check every substring, which would TLE. How can we improve this solution? +
    + +
    +Hint 2 +In an equal count substring, the first character appears count times, the second character appears count times, and so on. +
    + +
    +Hint 3 +The length of an equal count substring is the number of unique characters multiplied by count. +
    + +
    +Hint 4 +The length of all equal count substrings are multiples of count. +
    diff --git a/problems/number-of-good-ways-to-split-a-string/README.md b/problems/number-of-good-ways-to-split-a-string/README.md index 2001e985a..3fe28aa73 100644 --- a/problems/number-of-good-ways-to-split-a-string/README.md +++ b/problems/number-of-good-ways-to-split-a-string/README.md @@ -60,9 +60,9 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/number-of-restricted-paths-from-first-to-last-node/README.md b/problems/number-of-restricted-paths-from-first-to-last-node/README.md index 6482427e7..decd9b210 100644 --- a/problems/number-of-restricted-paths-from-first-to-last-node/README.md +++ b/problems/number-of-restricted-paths-from-first-to-last-node/README.md @@ -54,11 +54,11 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Shortest Path](../../tag/shortest-path/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] ### Hints
    diff --git a/problems/number-of-spaces-cleaning-robot-cleaned/README.md b/problems/number-of-spaces-cleaning-robot-cleaned/README.md new file mode 100644 index 000000000..7773d1791 --- /dev/null +++ b/problems/number-of-spaces-cleaning-robot-cleaned/README.md @@ -0,0 +1,35 @@ + + + + + + + +[< Previous](../check-if-an-original-string-exists-given-two-encoded-strings "Check if an Original String Exists Given Two Encoded Strings") +                 +[Next >](../count-vowel-substrings-of-a-string "Count Vowel Substrings of a String") + +## [2061. Number of Spaces Cleaning Robot Cleaned (Medium)](https://leetcode.com/problems/number-of-spaces-cleaning-robot-cleaned "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Simulate how the robot moves and keep track of how many spaces it has cleaned so far. +
    + +
    +Hint 2 +When can we stop the simulation? +
    + +
    +Hint 3 +When the robot reaches a space that it has already cleaned and is facing the same direction as before, we can stop the simulation. +
    diff --git a/problems/number-of-students-unable-to-eat-lunch/README.md b/problems/number-of-students-unable-to-eat-lunch/README.md index eb9a4f00d..bf8575ed0 100644 --- a/problems/number-of-students-unable-to-eat-lunch/README.md +++ b/problems/number-of-students-unable-to-eat-lunch/README.md @@ -60,11 +60,14 @@ Hence all students are able to eat. ### Related Topics + [[Array](../../tag/array/README.md)] [[Stack](../../tag/stack/README.md)] [[Queue](../../tag/queue/README.md)] - [[Array](../../tag/array/README.md)] [[Simulation](../../tag/simulation/README.md)] +### Similar Questions + 1. [Time Needed to Buy Tickets](../time-needed-to-buy-tickets) (Easy) + ### Hints
    Hint 1 diff --git a/problems/number-of-substrings-with-only-1s/README.md b/problems/number-of-substrings-with-only-1s/README.md index 7fe742f2c..3d3b4c739 100644 --- a/problems/number-of-substrings-with-only-1s/README.md +++ b/problems/number-of-substrings-with-only-1s/README.md @@ -61,6 +61,7 @@ ### Similar Questions 1. [Count Number of Homogenous Substrings](../count-number-of-homogenous-substrings) (Medium) + 1. [Count Vowel Substrings of a String](../count-vowel-substrings-of-a-string) (Easy) ### Hints
    diff --git a/problems/number-of-valid-move-combinations-on-chessboard/README.md b/problems/number-of-valid-move-combinations-on-chessboard/README.md new file mode 100644 index 000000000..f4e33082d --- /dev/null +++ b/problems/number-of-valid-move-combinations-on-chessboard/README.md @@ -0,0 +1,116 @@ + + + + + + + +[< Previous](../plates-between-candles "Plates Between Candles") +                 +[Next >](../smallest-index-with-equal-value "Smallest Index With Equal Value") + +## [2056. Number of Valid Move Combinations On Chessboard (Hard)](https://leetcode.com/problems/number-of-valid-move-combinations-on-chessboard "棋盘上有效移动组合的数目") + +

    There is an 8 x 8 chessboard containing n pieces (rooks, queens, or bishops). You are given a string array pieces of length n, where pieces[i] describes the type (rook, queen, or bishop) of the ith piece. In addition, you are given a 2D integer array positions also of length n, where positions[i] = [ri, ci] indicates that the ith piece is currently at the 1-based coordinate (ri, ci) on the chessboard.

    + +

    When making a move for a piece, you choose a destination square that the piece will travel toward and stop on.

    + +
      +
    • A rook can only travel horizontally or vertically from (r, c) to the direction of (r+1, c), (r-1, c), (r, c+1), or (r, c-1).
    • +
    • A queen can only travel horizontally, vertically, or diagonally from (r, c) to the direction of (r+1, c), (r-1, c), (r, c+1), (r, c-1), (r+1, c+1), (r+1, c-1), (r-1, c+1), (r-1, c-1).
    • +
    • A bishop can only travel diagonally from (r, c) to the direction of (r+1, c+1), (r+1, c-1), (r-1, c+1), (r-1, c-1).
    • +
    + +

    You must make a move for every piece on the board simultaneously. A move combination consists of all the moves performed on all the given pieces. Every second, each piece will instantaneously travel one square towards their destination if they are not already at it. All pieces start traveling at the 0th second. A move combination is invalid if, at a given time, two or more pieces occupy the same square.

    + +

    Return the number of valid move combinations​​​​​.

    + +

    Notes:

    + +
      +
    • No two pieces will start in the same square.
    • +
    • You may choose the square a piece is already on as its destination.
    • +
    • If two pieces are directly adjacent to each other, it is valid for them to move past each other and swap positions in one second.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: pieces = ["rook"], positions = [[1,1]]
    +Output: 15
    +Explanation: The image above shows the possible squares the piece can move to.
    +
    + +

    Example 2:

    + +
    +Input: pieces = ["queen"], positions = [[1,1]]
    +Output: 22
    +Explanation: The image above shows the possible squares the piece can move to.
    +
    + +

    Example 3:

    + +
    +Input: pieces = ["bishop"], positions = [[4,3]]
    +Output: 12
    +Explanation: The image above shows the possible squares the piece can move to.
    +
    + +

    Example 4:

    + +
    +Input: pieces = ["rook","rook"], positions = [[1,1],[8,8]]
    +Output: 223
    +Explanation: There are 15 moves for each rook which results in 15 * 15 = 225 move combinations.
    +However, there are two invalid move combinations:
    +- Move both rooks to (8, 1), where they collide.
    +- Move both rooks to (1, 8), where they collide.
    +Thus there are 225 - 2 = 223 valid move combinations.
    +Note that there are two valid move combinations that would result in one rook at (1, 8) and the other at (8, 1).
    +Even though the board state is the same, these two move combinations are considered different since the moves themselves are different.
    +
    + +

    Example 5:

    + +
    +Input: pieces = ["queen","bishop"], positions = [[5,7],[3,4]]
    +Output: 281
    +Explanation: There are 12 * 24 = 288 move combinations.
    +However, there are several invalid move combinations:
    +- If the queen stops at (6, 7), it blocks the bishop from moving to (6, 7) or (7, 8).
    +- If the queen stops at (5, 6), it blocks the bishop from moving to (5, 6), (6, 7), or (7, 8).
    +- If the bishop stops at (5, 2), it blocks the queen from moving to (5, 2) or (5, 1).
    +Of the 288 move combinations, 281 are valid.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == pieces.length
    • +
    • n == positions.length
    • +
    • 1 <= n <= 4
    • +
    • pieces only contains the strings "rook""queen", and "bishop".
    • +
    • There will be at most one queen on the chessboard.
    • +
    • 1 <= xi, yi <= 8
    • +
    • Each positions[i] is distinct.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +N is small, we can generate all possible move combinations. +
    + +
    +Hint 2 +For each possible move combination, determine which ones are valid. +
    diff --git a/problems/number-of-valid-words-in-a-sentence/README.md b/problems/number-of-valid-words-in-a-sentence/README.md new file mode 100644 index 000000000..9a884bf5c --- /dev/null +++ b/problems/number-of-valid-words-in-a-sentence/README.md @@ -0,0 +1,85 @@ + + + + + + + +[< Previous](../sort-linked-list-already-sorted-using-absolute-values "Sort Linked List Already Sorted Using Absolute Values") +                 +[Next >](../next-greater-numerically-balanced-number "Next Greater Numerically Balanced Number") + +## [2047. Number of Valid Words in a Sentence (Easy)](https://leetcode.com/problems/number-of-valid-words-in-a-sentence "句子中的有效单词数") + +

    A sentence consists of lowercase letters ('a' to 'z'), digits ('0' to '9'), hyphens ('-'), punctuation marks ('!', '.', and ','), and spaces (' ') only. Each sentence can be broken down into one or more tokens separated by one or more spaces ' '.

    + +

    A token is a valid word if all three of the following are true:

    + +
      +
    • It only contains lowercase letters, hyphens, and/or punctuation (no digits).
    • +
    • There is at most one hyphen '-'. If present, it must be surrounded by lowercase characters ("a-b" is valid, but "-ab" and "ab-" are not valid).
    • +
    • There is at most one punctuation mark. If present, it must be at the end of the token ("ab,", "cd!", and "." are valid, but "a!b" and "c.," are not valid).
    • +
    + +

    Examples of valid words include "a-b.", "afad", "ba-c", "a!", and "!".

    + +

    Given a string sentence, return the number of valid words in sentence.

    + +

     

    +

    Example 1:

    + +
    +Input: sentence = "cat and  dog"
    +Output: 3
    +Explanation: The valid words in the sentence are "cat", "and", and "dog".
    +
    + +

    Example 2:

    + +
    +Input: sentence = "!this  1-s b8d!"
    +Output: 0
    +Explanation: There are no valid words in the sentence.
    +"!this" is invalid because it starts with a punctuation mark.
    +"1-s" and "b8d" are invalid because they contain digits.
    +
    + +

    Example 3:

    + +
    +Input: sentence = "alice and  bob are playing stone-game10"
    +Output: 5
    +Explanation: The valid words in the sentence are "alice", "and", "bob", "are", and "playing".
    +"stone-game10" is invalid because it contains digits.
    +
    + +

    Example 4:

    + +
    +Input: sentence = "he bought 2 pencils, 3 erasers, and 1  pencil-sharpener."
    +Output: 6
    +Explanation: The valid words in the sentence are "he", "bought", "pencils,", "erasers,", "and", and "pencil-sharpener.".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= sentence.length <= 1000
    • +
    • sentence only contains lowercase English letters, digits, ' ', '-', '!', '.', and ','.
    • +
    • There will be at least 1 token.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Iterate through the string to split it by spaces. +
    + +
    +Hint 2 +Count the number of characters of each type (letters, numbers, hyphens, and punctuations). +
    diff --git a/problems/number-of-ways-of-cutting-a-pizza/README.md b/problems/number-of-ways-of-cutting-a-pizza/README.md index 13058d42d..7b9e1d165 100644 --- a/problems/number-of-ways-of-cutting-a-pizza/README.md +++ b/problems/number-of-ways-of-cutting-a-pizza/README.md @@ -54,9 +54,9 @@ ### Related Topics - [[Memoization](../../tag/memoization/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Memoization](../../tag/memoization/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md b/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md index e4f095b6d..b6ad2d6f1 100644 --- a/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md +++ b/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md @@ -82,16 +82,16 @@ ### Related Topics - [[Array](../../tag/array/README.md)] - [[Math](../../tag/math/README.md)] - [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Tree](../../tag/tree/README.md)] [[Union Find](../../tag/union-find/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Memoization](../../tag/memoization/README.md)] - [[Combinatorics](../../tag/combinatorics/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] + [[Combinatorics](../../tag/combinatorics/README.md)] ### Hints
    diff --git a/problems/number-of-ways-to-split-a-string/README.md b/problems/number-of-ways-to-split-a-string/README.md index a9616a150..5d6b30520 100644 --- a/problems/number-of-ways-to-split-a-string/README.md +++ b/problems/number-of-ways-to-split-a-string/README.md @@ -67,9 +67,6 @@ [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] -### Similar Questions - 1. [Split Array with Equal Sum](../split-array-with-equal-sum) (Hard) - ### Hints
    Hint 1 diff --git a/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md b/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md index b9db71387..f49a48d8b 100644 --- a/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md +++ b/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md @@ -65,11 +65,14 @@ Number of Permutations of (1,2,3,4) = 24. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] +### Similar Questions + 1. [The Number of Good Subsets](../the-number-of-good-subsets) (Hard) + ### Hints
    Hint 1 diff --git a/problems/palindrome-partitioning-ii/README.md b/problems/palindrome-partitioning-ii/README.md index aef95045d..2473475be 100644 --- a/problems/palindrome-partitioning-ii/README.md +++ b/problems/palindrome-partitioning-ii/README.md @@ -52,3 +52,4 @@ ### Similar Questions 1. [Palindrome Partitioning](../palindrome-partitioning) (Medium) + 1. [Palindrome Partitioning IV](../palindrome-partitioning-iv) (Hard) diff --git a/problems/parallel-courses-iii/README.md b/problems/parallel-courses-iii/README.md new file mode 100644 index 000000000..cfb2028ca --- /dev/null +++ b/problems/parallel-courses-iii/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../count-nodes-with-the-highest-score "Count Nodes With the Highest Score") +                 +[Next >](../the-category-of-each-member-in-the-store "The Category of Each Member in the Store") + +## [2050. Parallel Courses III (Hard)](https://leetcode.com/problems/parallel-courses-iii "并行课程 III") + +

    You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given a 2D integer array relations where relations[j] = [prevCoursej, nextCoursej] denotes that course prevCoursej has to be completed before course nextCoursej (prerequisite relationship). Furthermore, you are given a 0-indexed integer array time where time[i] denotes how many months it takes to complete the (i+1)th course.

    + +

    You must find the minimum number of months needed to complete all the courses following these rules:

    + +
      +
    • You may start taking a course at any time if the prerequisites are met.
    • +
    • Any number of courses can be taken at the same time.
    • +
    + +

    Return the minimum number of months needed to complete all the courses.

    + +

    Note: The test cases are generated such that it is possible to complete every course (i.e., the graph is a directed acyclic graph).

    + +

     

    +

    Example 1:

    + + +
    +Input: n = 3, relations = [[1,3],[2,3]], time = [3,2,5]
    +Output: 8
    +Explanation: The figure above represents the given graph and the time required to complete each course. 
    +We start course 1 and course 2 simultaneously at month 0.
    +Course 1 takes 3 months and course 2 takes 2 months to complete respectively.
    +Thus, the earliest time we can start course 3 is at month 3, and the total time required is 3 + 5 = 8 months.
    +
    + +

    Example 2:

    + + +
    +Input: n = 5, relations = [[1,5],[2,5],[3,5],[3,4],[4,5]], time = [1,2,3,4,5]
    +Output: 12
    +Explanation: The figure above represents the given graph and the time required to complete each course.
    +You can start courses 1, 2, and 3 at month 0.
    +You can complete them after 1, 2, and 3 months respectively.
    +Course 4 can be taken only after course 3 is completed, i.e., after 3 months. It is completed after 3 + 4 = 7 months.
    +Course 5 can be taken only after courses 1, 2, 3, and 4 have been completed, i.e., after max(1,2,3,7) = 7 months.
    +Thus, the minimum time needed to complete all the courses is 7 + 5 = 12 months.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= 5 * 104
    • +
    • 0 <= relations.length <= min(n * (n - 1) / 2, 5 * 104)
    • +
    • relations[j].length == 2
    • +
    • 1 <= prevCoursej, nextCoursej <= n
    • +
    • prevCoursej != nextCoursej
    • +
    • All the pairs [prevCoursej, nextCoursej] are unique.
    • +
    • time.length == n
    • +
    • 1 <= time[i] <= 104
    • +
    • The given graph is a directed acyclic graph.
    • +
    + +### Related Topics + [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +What is the earliest time a course can be taken? +
    + +
    +Hint 2 +How would you solve the problem if all courses take equal time? +
    + +
    +Hint 3 +How would you generalize this approach? +
    diff --git a/problems/path-sum-ii/README.md b/problems/path-sum-ii/README.md index 67c076b6c..acd143c07 100644 --- a/problems/path-sum-ii/README.md +++ b/problems/path-sum-ii/README.md @@ -50,9 +50,9 @@ ### Related Topics + [[Backtracking](../../tag/backtracking/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[Backtracking](../../tag/backtracking/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/path-with-maximum-minimum-value/README.md b/problems/path-with-maximum-minimum-value/README.md index 7e183be3b..ff4461a28 100644 --- a/problems/path-with-maximum-minimum-value/README.md +++ b/problems/path-with-maximum-minimum-value/README.md @@ -56,12 +56,15 @@ The path with the maximum score is highlighted in yellow. ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] - [[Matrix](../../tag/matrix/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Similar Questions + 1. [Path With Minimum Effort](../path-with-minimum-effort) (Medium) ### Hints
    diff --git a/problems/path-with-maximum-probability/README.md b/problems/path-with-maximum-probability/README.md index 0e7bf7148..ba83dc8d4 100644 --- a/problems/path-with-maximum-probability/README.md +++ b/problems/path-with-maximum-probability/README.md @@ -63,11 +63,8 @@ ### Related Topics [[Graph](../../tag/graph/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] [[Shortest Path](../../tag/shortest-path/README.md)] - -### Similar Questions - 1. [Number of Ways to Arrive at Destination](../number-of-ways-to-arrive-at-destination) (Medium) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/path-with-minimum-effort/README.md b/problems/path-with-minimum-effort/README.md index f86467458..87fb8141a 100644 --- a/problems/path-with-minimum-effort/README.md +++ b/problems/path-with-minimum-effort/README.md @@ -58,13 +58,17 @@ This is better than the route of [1,2,2,2,5], where the maximum absolute differe ### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] - [[Matrix](../../tag/matrix/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Similar Questions + 1. [Swim in Rising Water](../swim-in-rising-water) (Hard) + 1. [Path With Maximum Minimum Value](../path-with-maximum-minimum-value) (Medium) ### Hints
    diff --git a/problems/percentage-of-users-attended-a-contest/README.md b/problems/percentage-of-users-attended-a-contest/README.md index ed363bcbd..9afe97740 100644 --- a/problems/percentage-of-users-attended-a-contest/README.md +++ b/problems/percentage-of-users-attended-a-contest/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Queries Quality and Percentage](../queries-quality-and-percentage) (Easy) diff --git a/problems/plates-between-candles/README.md b/problems/plates-between-candles/README.md new file mode 100644 index 000000000..1c6f57624 --- /dev/null +++ b/problems/plates-between-candles/README.md @@ -0,0 +1,71 @@ + + + + + + + +[< Previous](../two-best-non-overlapping-events "Two Best Non-Overlapping Events") +                 +[Next >](../number-of-valid-move-combinations-on-chessboard "Number of Valid Move Combinations On Chessboard") + +## [2055. Plates Between Candles (Medium)](https://leetcode.com/problems/plates-between-candles "蜡烛之间的盘子") + +

    There is a long table with a line of plates and candles arranged on top of it. You are given a 0-indexed string s consisting of characters '*' and '|' only, where a '*' represents a plate and a '|' represents a candle.

    + +

    You are also given a 0-indexed 2D integer array queries where queries[i] = [lefti, righti] denotes the substring s[lefti...righti] (inclusive). For each query, you need to find the number of plates between candles that are in the substring. A plate is considered between candles if there is at least one candle to its left and at least one candle to its right in the substring.

    + +
      +
    • For example, s = "||**||**|*", and a query [3, 8] denotes the substring "*||**|". The number of plates between candles in this substring is 2, as each of the two plates has at least one candle in the substring to its left and right.
    • +
    + +

    Return an integer array answer where answer[i] is the answer to the ith query.

    + +

     

    +

    Example 1:

    +ex-1 +
    +Input: s = "**|**|***|", queries = [[2,5],[5,9]]
    +Output: [2,3]
    +Explanation:
    +- queries[0] has two plates between candles.
    +- queries[1] has three plates between candles.
    +
    + +

    Example 2:

    +ex-2 +
    +Input: s = "***|**|*****|**||**|*", queries = [[1,17],[4,5],[14,17],[5,11],[15,16]]
    +Output: [9,0,0,0,0]
    +Explanation:
    +- queries[0] has nine plates between candles.
    +- The other queries have zero plates between candles.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= s.length <= 105
    • +
    • s consists of '*' and '|' characters.
    • +
    • 1 <= queries.length <= 105
    • +
    • queries[i].length == 2
    • +
    • 0 <= lefti <= righti < s.length
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +Can you find the indices of the most left and right candles for a given substring, perhaps by using binary search (or better) over an array of indices of all the bars? +
    + +
    +Hint 2 +Once the indices of the most left and right bars are determined, how can you efficiently count the number of plates within the range? Prefix sums? +
    diff --git a/problems/power-of-two/README.md b/problems/power-of-two/README.md index 7ac540a2a..ad4c61126 100644 --- a/problems/power-of-two/README.md +++ b/problems/power-of-two/README.md @@ -64,9 +64,9 @@ Follow up: Could you solve it without loops/recursion? ### Related Topics + [[Math](../../tag/math/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Recursion](../../tag/recursion/README.md)] - [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Number of 1 Bits](../number-of-1-bits) (Easy) diff --git a/problems/powx-n/README.md b/problems/powx-n/README.md index 89d9cf803..8e1765ef7 100644 --- a/problems/powx-n/README.md +++ b/problems/powx-n/README.md @@ -46,8 +46,8 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Math](../../tag/math/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions 1. [Sqrt(x)](../sqrtx) (Easy) diff --git a/problems/predict-the-winner/README.md b/problems/predict-the-winner/README.md index 58f951db9..4e364f34e 100644 --- a/problems/predict-the-winner/README.md +++ b/problems/predict-the-winner/README.md @@ -47,10 +47,10 @@ Finally, player 1 has more score (234) than player 2 (12), so you need to return ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Recursion](../../tag/recursion/README.md)] [[Game Theory](../../tag/game-theory/README.md)] ### Similar Questions diff --git a/problems/print-immutable-linked-list-in-reverse/README.md b/problems/print-immutable-linked-list-in-reverse/README.md index 36b2d09ff..dce74d494 100644 --- a/problems/print-immutable-linked-list-in-reverse/README.md +++ b/problems/print-immutable-linked-list-in-reverse/README.md @@ -51,7 +51,7 @@ Constraints: - The value of each node in the linked list is between [-1000, 1000]. ### Related Topics - [[Linked List](../../tag/linked-list/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] [[Stack](../../tag/stack/README.md)] [[Recursion](../../tag/recursion/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/process-restricted-friend-requests/README.md b/problems/process-restricted-friend-requests/README.md new file mode 100644 index 000000000..d2d91d28e --- /dev/null +++ b/problems/process-restricted-friend-requests/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../decode-the-slanted-ciphertext "Decode the Slanted Ciphertext") +                 +Next > + +## [2076. Process Restricted Friend Requests (Hard)](https://leetcode.com/problems/process-restricted-friend-requests "处理含限制条件的好友请求") + +

    You are given an integer n indicating the number of people in a network. Each person is labeled from 0 to n - 1.

    + +

    You are also given a 0-indexed 2D integer array restrictions, where restrictions[i] = [xi, yi] means that person xi and person yi cannot become friends, either directly or indirectly through other people.

    + +

    Initially, no one is friends with each other. You are given a list of friend requests as a 0-indexed 2D integer array requests, where requests[j] = [uj, vj] is a friend request between person uj and person vj.

    + +

    A friend request is successful if uj and vj can be friends. Each friend request is processed in the given order (i.e., requests[j] occurs before requests[j + 1]), and upon a successful request, uj and vj become direct friends for all future friend requests.

    + +

    Return a boolean array result, where each result[j] is true if the jth friend request is successful or false if it is not.

    + +

    Note: If uj and vj are already direct friends, the request is still successful.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 3, restrictions = [[0,1]], requests = [[0,2],[2,1]]
    +Output: [true,false]
    +Explanation:
    +Request 0: Person 0 and person 2 can be friends, so they become direct friends. 
    +Request 1: Person 2 and person 1 cannot be friends since person 0 and person 1 would be indirect friends (1--2--0).
    +
    + +

    Example 2:

    + +
    +Input: n = 3, restrictions = [[0,1]], requests = [[1,2],[0,2]]
    +Output: [true,false]
    +Explanation:
    +Request 0: Person 1 and person 2 can be friends, so they become direct friends.
    +Request 1: Person 0 and person 2 cannot be friends since person 0 and person 1 would be indirect friends (0--2--1).
    +
    + +

    Example 3:

    + +
    +Input: n = 5, restrictions = [[0,1],[1,2],[2,3]], requests = [[0,4],[1,2],[3,1],[3,4]]
    +Output: [true,false,true,false]
    +Explanation:
    +Request 0: Person 0 and person 4 can be friends, so they become direct friends.
    +Request 1: Person 1 and person 2 cannot be friends since they are directly restricted.
    +Request 2: Person 3 and person 1 can be friends, so they become direct friends.
    +Request 3: Person 3 and person 4 cannot be friends since person 0 and person 1 would be indirect friends (0--4--3--1).
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 1000
    • +
    • 0 <= restrictions.length <= 1000
    • +
    • restrictions[i].length == 2
    • +
    • 0 <= xi, yi <= n - 1
    • +
    • xi != yi
    • +
    • 1 <= requests.length <= 1000
    • +
    • requests[j].length == 2
    • +
    • 0 <= uj, vj <= n - 1
    • +
    • uj != vj
    • +
    + +### Hints +
    +Hint 1 +For each request, we could loop through all restrictions. Can you think of doing a check-in close to O(1)? +
    + +
    +Hint 2 +Could you use Union Find? +
    diff --git a/problems/product-sales-analysis-ii/README.md b/problems/product-sales-analysis-ii/README.md index 178056173..3e35e1e17 100644 --- a/problems/product-sales-analysis-ii/README.md +++ b/problems/product-sales-analysis-ii/README.md @@ -75,3 +75,7 @@ Result table: ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Product Sales Analysis I](../product-sales-analysis-i) (Easy) + 1. [Product Sales Analysis III](../product-sales-analysis-iii) (Medium) diff --git a/problems/product-sales-analysis-ii/mysql_schemas.sql b/problems/product-sales-analysis-ii/mysql_schemas.sql index 592f4f5a9..2d7632cb2 100644 --- a/problems/product-sales-analysis-ii/mysql_schemas.sql +++ b/problems/product-sales-analysis-ii/mysql_schemas.sql @@ -1,5 +1,5 @@ -Create table Sales (sale_id int, product_id int, year int, quantity int, price int); -Create table Product (product_id int, product_name varchar(10)); +Create table If Not Exists Sales (sale_id int, product_id int, year int, quantity int, price int); +Create table If Not Exists Product (product_id int, product_name varchar(10)); Truncate table Sales; insert into Sales (sale_id, product_id, year, quantity, price) values ('1', '100', '2008', '10', '5000'); insert into Sales (sale_id, product_id, year, quantity, price) values ('2', '100', '2009', '12', '5000'); diff --git a/problems/product-sales-analysis-iii/README.md b/problems/product-sales-analysis-iii/README.md index 2f7335315..ceec81328 100644 --- a/problems/product-sales-analysis-iii/README.md +++ b/problems/product-sales-analysis-iii/README.md @@ -76,3 +76,6 @@ Result table: ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Product Sales Analysis II](../product-sales-analysis-ii) (Easy) diff --git a/problems/product-sales-analysis-iii/mysql_schemas.sql b/problems/product-sales-analysis-iii/mysql_schemas.sql index 592f4f5a9..2d7632cb2 100644 --- a/problems/product-sales-analysis-iii/mysql_schemas.sql +++ b/problems/product-sales-analysis-iii/mysql_schemas.sql @@ -1,5 +1,5 @@ -Create table Sales (sale_id int, product_id int, year int, quantity int, price int); -Create table Product (product_id int, product_name varchar(10)); +Create table If Not Exists Sales (sale_id int, product_id int, year int, quantity int, price int); +Create table If Not Exists Product (product_id int, product_name varchar(10)); Truncate table Sales; insert into Sales (sale_id, product_id, year, quantity, price) values ('1', '100', '2008', '10', '5000'); insert into Sales (sale_id, product_id, year, quantity, price) values ('2', '100', '2009', '12', '5000'); diff --git a/problems/put-boxes-into-the-warehouse-i/README.md b/problems/put-boxes-into-the-warehouse-i/README.md index b285a7652..58ec067a0 100644 --- a/problems/put-boxes-into-the-warehouse-i/README.md +++ b/problems/put-boxes-into-the-warehouse-i/README.md @@ -14,10 +14,13 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Put Boxes Into the Warehouse II](../put-boxes-into-the-warehouse-ii) (Medium) + ### Hints
    Hint 1 diff --git a/problems/random-pick-index/README.md b/problems/random-pick-index/README.md index 7d3b38155..01f9412be 100644 --- a/problems/random-pick-index/README.md +++ b/problems/random-pick-index/README.md @@ -48,9 +48,9 @@ solution.pick(3); // It should return either index 2, 3, or 4 randomly. Each ind ### Related Topics + [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] - [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] [[Randomized](../../tag/randomized/README.md)] ### Similar Questions diff --git a/problems/rank-scores/README.md b/problems/rank-scores/README.md index 098772ff7..6160acfc4 100644 --- a/problems/rank-scores/README.md +++ b/problems/rank-scores/README.md @@ -17,10 +17,10 @@ +-------------+---------+ | Column Name | Type | +-------------+---------+ -| Id | int | -| Score | decimal | +| id | int | +| score | decimal | +-------------+---------+ -Id is the primary key for this table. +id is the primary key for this table. Each row of this table contains the score of a game. Score is a floating point value with two decimal places.
    @@ -45,7 +45,7 @@ Each row of this table contains the score of a game. Score is a floating point v Input: Scores table: +----+-------+ -| Id | Score | +| id | score | +----+-------+ | 1 | 3.50 | | 2 | 3.65 | @@ -56,7 +56,7 @@ Scores table: +----+-------+ Output: +-------+------+ -| Score | Rank | +| score | rank | +-------+------+ | 4.00 | 1 | | 4.00 | 1 | diff --git a/problems/rank-scores/mysql_schemas.sql b/problems/rank-scores/mysql_schemas.sql index 8dac1d57e..e95d6ffae 100644 --- a/problems/rank-scores/mysql_schemas.sql +++ b/problems/rank-scores/mysql_schemas.sql @@ -1,8 +1,8 @@ -Create table If Not Exists Scores (Id int, Score DECIMAL(3,2)); +Create table If Not Exists Scores (id int, score DECIMAL(3,2)); Truncate table Scores; -insert into Scores (Id, Score) values ('1', '3.5'); -insert into Scores (Id, Score) values ('2', '3.65'); -insert into Scores (Id, Score) values ('3', '4.0'); -insert into Scores (Id, Score) values ('4', '3.85'); -insert into Scores (Id, Score) values ('5', '4.0'); -insert into Scores (Id, Score) values ('6', '3.65'); +insert into Scores (id, score) values ('1', '3.5'); +insert into Scores (id, score) values ('2', '3.65'); +insert into Scores (id, score) values ('3', '4.0'); +insert into Scores (id, score) values ('4', '3.85'); +insert into Scores (id, score) values ('5', '4.0'); +insert into Scores (id, score) values ('6', '3.65'); diff --git a/problems/rearrange-products-table/README.md b/problems/rearrange-products-table/README.md index dc9fa1f5a..32103d604 100644 --- a/problems/rearrange-products-table/README.md +++ b/problems/rearrange-products-table/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Product's Price for Each Store](../products-price-for-each-store) (Easy) diff --git a/problems/rearrange-spaces-between-words/README.md b/problems/rearrange-spaces-between-words/README.md index 7705a8c6b..4e8a32046 100644 --- a/problems/rearrange-spaces-between-words/README.md +++ b/problems/rearrange-spaces-between-words/README.md @@ -67,6 +67,9 @@ ### Related Topics [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Text Justification](../text-justification) (Hard) + ### Hints
    Hint 1 diff --git a/problems/reconstruct-a-2-row-binary-matrix/README.md b/problems/reconstruct-a-2-row-binary-matrix/README.md index 5c631ae16..06655f5a4 100644 --- a/problems/reconstruct-a-2-row-binary-matrix/README.md +++ b/problems/reconstruct-a-2-row-binary-matrix/README.md @@ -61,13 +61,10 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] -### Similar Questions - 1. [Find Valid Matrix Given Row and Column Sums](../find-valid-matrix-given-row-and-column-sums) (Medium) - ### Hints
    Hint 1 diff --git a/problems/recover-a-tree-from-preorder-traversal/README.md b/problems/recover-a-tree-from-preorder-traversal/README.md index 9b6e11135..9c1a4fc92 100644 --- a/problems/recover-a-tree-from-preorder-traversal/README.md +++ b/problems/recover-a-tree-from-preorder-traversal/README.md @@ -50,9 +50,9 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[String](../../tag/string/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/rectangle-area/README.md b/problems/rectangle-area/README.md index 8f428eab9..fb0602d4b 100644 --- a/problems/rectangle-area/README.md +++ b/problems/rectangle-area/README.md @@ -40,8 +40,8 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] ### Similar Questions 1. [Rectangle Overlap](../rectangle-overlap) (Easy) diff --git a/problems/reformat-department-table/README.md b/problems/reformat-department-table/README.md index 4d2225d89..9c71adbca 100644 --- a/problems/reformat-department-table/README.md +++ b/problems/reformat-department-table/README.md @@ -14,13 +14,13 @@

    Table: Department

    -+---------------+---------+
    -| Column Name   | Type    |
    -+---------------+---------+
    -| id            | int     |
    -| revenue       | int     |
    -| month         | varchar |
    -+---------------+---------+
    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| id          | int     |
    +| revenue     | int     |
    +| month       | varchar |
    ++-------------+---------+
     (id, month) is the primary key of this table.
     The table has information about the revenue of each department per month.
     The month has values in ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].
    @@ -28,11 +28,17 @@ The month has values in ["Jan","Feb","Mar","A
     
     

     

    -

    Write an SQL query to reformat the table such that there is a department id column and a revenue column for each month.

    +

    Write an SQL query to reformat the table such that there is a department id column and a revenue column for each month.

    -

    The query result format is in the following example:

    +

    Return the result table in any order.

    + +

    The query result format is in the following example.

    + +

     

    +

    Example 1:

    +Input: 
     Department table:
     +------+---------+-------+
     | id   | revenue | month |
    @@ -43,8 +49,7 @@ Department table:
     | 1    | 7000    | Feb   |
     | 1    | 6000    | Mar   |
     +------+---------+-------+
    -
    -Result table:
    +Output: 
     +------+-------------+-------------+-------------+-----+-------------+
     | id   | Jan_Revenue | Feb_Revenue | Mar_Revenue | ... | Dec_Revenue |
     +------+-------------+-------------+-------------+-----+-------------+
    @@ -52,7 +57,7 @@ Result table:
     | 2    | 9000        | null        | null        | ... | null        |
     | 3    | null        | 10000       | null        | ... | null        |
     +------+-------------+-------------+-------------+-----+-------------+
    -
    +Explanation: The revenue from Apr to Dec is null.
     Note that the result table has 13 columns (1 for the department id + 12 for the months).
     
    diff --git a/problems/remove-all-adjacent-duplicates-in-string-ii/README.md b/problems/remove-all-adjacent-duplicates-in-string-ii/README.md index 9eebcb21b..cafcb86af 100644 --- a/problems/remove-all-adjacent-duplicates-in-string-ii/README.md +++ b/problems/remove-all-adjacent-duplicates-in-string-ii/README.md @@ -52,11 +52,8 @@ Finally delete "ddd", get "aa"
    ### Related Topics - [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] - -### Similar Questions - 1. [Remove All Adjacent Duplicates In String](../remove-all-adjacent-duplicates-in-string) (Easy) + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/remove-duplicate-letters/README.md b/problems/remove-duplicate-letters/README.md index 737b1f557..d25ddda31 100644 --- a/problems/remove-duplicate-letters/README.md +++ b/problems/remove-duplicate-letters/README.md @@ -40,14 +40,11 @@

    Note: This question is the same as 1081: https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/

    ### Related Topics - [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] -### Similar Questions - 1. [Smallest K-Length Subsequence With Occurrences of a Letter](../smallest-k-length-subsequence-with-occurrences-of-a-letter) (Hard) - ### Hints
    Hint 1 diff --git a/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md b/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md index 407e2f7e7..a3ee99f6e 100644 --- a/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md +++ b/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md @@ -52,6 +52,9 @@ [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] +### Similar Questions + 1. [Delete N Nodes After M Nodes of a Linked List](../delete-n-nodes-after-m-nodes-of-a-linked-list) (Easy) + ### Hints
    Hint 1 diff --git a/problems/reorganize-string/README.md b/problems/reorganize-string/README.md index bcb52bdbf..15bee45f9 100644 --- a/problems/reorganize-string/README.md +++ b/problems/reorganize-string/README.md @@ -32,12 +32,12 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Counting](../../tag/counting/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Counting](../../tag/counting/README.md)] ### Similar Questions 1. [Rearrange String k Distance Apart](../rearrange-string-k-distance-apart) (Hard) diff --git a/problems/reshape-the-matrix/README.md b/problems/reshape-the-matrix/README.md index 786d327de..391c47503 100644 --- a/problems/reshape-the-matrix/README.md +++ b/problems/reshape-the-matrix/README.md @@ -50,6 +50,9 @@ [[Matrix](../../tag/matrix/README.md)] [[Simulation](../../tag/simulation/README.md)] +### Similar Questions + 1. [Convert 1D Array Into 2D Array](../convert-1d-array-into-2d-array) (Easy) + ### Hints
    Hint 1 diff --git a/problems/restore-ip-addresses/README.md b/problems/restore-ip-addresses/README.md index e236a5367..bb1747346 100644 --- a/problems/restore-ip-addresses/README.md +++ b/problems/restore-ip-addresses/README.md @@ -11,9 +11,13 @@ ## [93. Restore IP Addresses (Medium)](https://leetcode.com/problems/restore-ip-addresses "复原 IP 地址") -

    Given a string s containing only digits, return all possible valid IP addresses that can be obtained from s. You can return them in any order.

    +

    A valid IP address consists of exactly four integers separated by single dots. Each integer is between 0 and 255 (inclusive) and cannot have leading zeros.

    -

    A valid IP address consists of exactly four integers, each integer is between 0 and 255, separated by single dots and cannot have leading zeros. For example, "0.1.2.201" and "192.168.1.1" are valid IP addresses and "0.011.255.245", "192.168.1.312" and "192.168@1.1" are invalid IP addresses. 

    +
      +
    • For example, "0.1.2.201" and "192.168.1.1" are valid IP addresses, but "0.011.255.245", "192.168.1.312" and "192.168@1.1" are invalid IP addresses.
    • +
    + +

    Given a string s containing only digits, return all possible valid IP addresses that can be formed by inserting dots into s. You are not allowed to reorder or remove any digits in s. You may return the valid IP addresses in any order.

     

    Example 1:

    @@ -36,7 +40,7 @@

    Constraints:

      -
    • 0 <= s.length <= 3000
    • +
    • 0 <= s.length <= 20
    • s consists of digits only.
    diff --git a/problems/reverse-bits/README.md b/problems/reverse-bits/README.md index 82360f7ef..a613f07a4 100644 --- a/problems/reverse-bits/README.md +++ b/problems/reverse-bits/README.md @@ -48,9 +48,9 @@

    Follow up: If this function is called many times, how would you optimize it?

    ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions - 1. [Reverse Integer](../reverse-integer) (Easy) + 1. [Reverse Integer](../reverse-integer) (Medium) 1. [Number of 1 Bits](../number-of-1-bits) (Easy) diff --git a/problems/reverse-integer/README.md b/problems/reverse-integer/README.md index 443f96087..6a50b5bed 100644 --- a/problems/reverse-integer/README.md +++ b/problems/reverse-integer/README.md @@ -5,11 +5,11 @@ -[< Previous](../zigzag-conversion "ZigZag Conversion") +[< Previous](../zigzag-conversion "Zigzag Conversion")                  [Next >](../string-to-integer-atoi "String to Integer (atoi)") -## [7. Reverse Integer (Easy)](https://leetcode.com/problems/reverse-integer "整数反转") +## [7. Reverse Integer (Medium)](https://leetcode.com/problems/reverse-integer "整数反转")

    Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0.

    diff --git a/problems/reverse-nodes-in-even-length-groups/README.md b/problems/reverse-nodes-in-even-length-groups/README.md new file mode 100644 index 000000000..274f57c6f --- /dev/null +++ b/problems/reverse-nodes-in-even-length-groups/README.md @@ -0,0 +1,121 @@ + + + + + + + +[< Previous](../time-needed-to-buy-tickets "Time Needed to Buy Tickets") +                 +[Next >](../decode-the-slanted-ciphertext "Decode the Slanted Ciphertext") + +## [2074. Reverse Nodes in Even Length Groups (Medium)](https://leetcode.com/problems/reverse-nodes-in-even-length-groups "反转偶数长度组的节点") + +

    You are given the head of a linked list.

    + +

    The nodes in the linked list are sequentially assigned to non-empty groups whose lengths form the sequence of the natural numbers (1, 2, 3, 4, ...). The length of a group is the number of nodes assigned to it. In other words,

    + +
      +
    • The 1st node is assigned to the first group.
    • +
    • The 2nd and the 3rd nodes are assigned to the second group.
    • +
    • The 4th, 5th, and 6th nodes are assigned to the third group, and so on.
    • +
    + +

    Note that the length of the last group may be less than or equal to 1 + the length of the second to last group.

    + +

    Reverse the nodes in each group with an even length, and return the head of the modified linked list.

    + +

     

    +

    Example 1:

    + +
    +Input: head = [5,2,6,3,9,1,7,3,8,4]
    +Output: [5,6,2,3,9,1,4,8,3,7]
    +Explanation:
    +- The length of the first group is 1, which is odd, hence no reversal occurrs.
    +- The length of the second group is 2, which is even, hence the nodes are reversed.
    +- The length of the third group is 3, which is odd, hence no reversal occurrs.
    +- The length of the last group is 4, which is even, hence the nodes are reversed.
    +
    + +

    Example 2:

    + +
    +Input: head = [1,1,0,6]
    +Output: [1,0,1,6]
    +Explanation:
    +- The length of the first group is 1. No reversal occurrs.
    +- The length of the second group is 2. The nodes are reversed.
    +- The length of the last group is 1. No reversal occurrs.
    +
    + +

    Example 3:

    + +
    +Input: head = [1,1,0,6,5]
    +Output: [1,0,1,5,6]
    +Explanation:
    +- The length of the first group is 1. No reversal occurrs.
    +- The length of the second group is 2. The nodes are reversed.
    +- The length of the last group is 2. The nodes are reversed.
    +
    + +

    Example 4:

    + +
    +Input: head = [2,1]
    +Output: [2,1]
    +Explanation:
    +- The length of the first group is 1. No reversal occurrs.
    +- The length of the last group is 1. No reversal occurrs.
    +
    + +

    Example 5:

    + +
    +Input: head = [8]
    +Output: [8]
    +Explanation: There is only one group whose length is 1. No reversal occurrs.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is in the range [1, 105].
    • +
    • 0 <= Node.val <= 105
    • +
    + +### Related Topics + [[Linked List](../../tag/linked-list/README.md)] + +### Hints +
    +Hint 1 +Consider the list structure ...A → (B → ... → C) → D..., where the nodes between B and C (inclusive) form a group, A is the last node of the previous group, and D is the first node of the next group. How can you utilize this structure? +
    + +
    +Hint 2 +Suppose you have B → ... → C reversed (because it was of even length) so that it is now C → ... → B. What references do you need to fix so that the transitions between the previous, current, and next groups are correct? +
    + +
    +Hint 3 +A.next should be set to C, and B.next should be set to D. +
    + +
    +Hint 4 +Once the current group is finished being modified, you need to find the new A, B, C, and D nodes for the next group. How can you use the old A, B, C, and D nodes to find the new ones? +
    + +
    +Hint 5 +The new A is either the old B or old C depending on if the group was of even or odd length. The new B is always the old D. The new C and D can be found based on the new B and the next group's length. +
    + +
    +Hint 6 +You can set the initial values of A, B, C, and D to A = null, B = head, C = head, D = head.next. Repeat the steps from the previous hints until D is null. +
    diff --git a/problems/second-minimum-time-to-reach-destination/README.md b/problems/second-minimum-time-to-reach-destination/README.md index 6d5868e30..5fd12cc5b 100644 --- a/problems/second-minimum-time-to-reach-destination/README.md +++ b/problems/second-minimum-time-to-reach-destination/README.md @@ -7,7 +7,7 @@ [< Previous](../count-number-of-maximum-bitwise-or-subsets "Count Number of Maximum Bitwise-OR Subsets")                  -Next > +[Next >](../sort-linked-list-already-sorted-using-absolute-values "Sort Linked List Already Sorted Using Absolute Values") ## [2045. Second Minimum Time to Reach Destination (Hard)](https://leetcode.com/problems/second-minimum-time-to-reach-destination "到达目的地的第二短时间") diff --git a/problems/sell-diminishing-valued-colored-balls/README.md b/problems/sell-diminishing-valued-colored-balls/README.md index cfcb4112b..0f152dc19 100644 --- a/problems/sell-diminishing-valued-colored-balls/README.md +++ b/problems/sell-diminishing-valued-colored-balls/README.md @@ -63,10 +63,10 @@ The maximum total value is 3 + 2 + 5 + 4 + 3 + 2 = 19. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/sentence-screen-fitting/README.md b/problems/sentence-screen-fitting/README.md index 1b40974d7..e23dcefe5 100644 --- a/problems/sentence-screen-fitting/README.md +++ b/problems/sentence-screen-fitting/README.md @@ -82,3 +82,6 @@ The character '-' signifies an empty space on the screen. ### Related Topics [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Similar Questions + 1. [Minimum Cost to Separate Sentence Into Rows](../minimum-cost-to-separate-sentence-into-rows) (Medium) diff --git a/problems/sequence-reconstruction/README.md b/problems/sequence-reconstruction/README.md index 56bc38255..eb0ec0dc7 100644 --- a/problems/sequence-reconstruction/README.md +++ b/problems/sequence-reconstruction/README.md @@ -68,9 +68,9 @@ The seqs parameter had been changed to a list of list of strings (instead

    ### Related Topics - [[Array](../../tag/array/README.md)] [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions 1. [Course Schedule II](../course-schedule-ii) (Medium) diff --git a/problems/shopping-offers/README.md b/problems/shopping-offers/README.md index 86071e671..4eb605968 100644 --- a/problems/shopping-offers/README.md +++ b/problems/shopping-offers/README.md @@ -57,9 +57,9 @@ You cannot add more items, though only $9 for 2A ,2B and 1C. ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Memoization](../../tag/memoization/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] - [[Memoization](../../tag/memoization/README.md)] [[Bitmask](../../tag/bitmask/README.md)] diff --git a/problems/short-encoding-of-words/README.md b/problems/short-encoding-of-words/README.md index 5ef2d5a74..533cd2c87 100644 --- a/problems/short-encoding-of-words/README.md +++ b/problems/short-encoding-of-words/README.md @@ -51,7 +51,7 @@ words[2] = "bell", the substring of s starting from indices[2] = 5 to ### Related Topics - [[Trie](../../tag/trie/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Trie](../../tag/trie/README.md)] diff --git a/problems/single-number-ii/README.md b/problems/single-number-ii/README.md index 92cfb1b12..fa41c7517 100644 --- a/problems/single-number-ii/README.md +++ b/problems/single-number-ii/README.md @@ -33,8 +33,8 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions 1. [Single Number](../single-number) (Easy) diff --git a/problems/single-number/README.md b/problems/single-number/README.md index 76ce1c6c1..29a154736 100644 --- a/problems/single-number/README.md +++ b/problems/single-number/README.md @@ -36,8 +36,8 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions 1. [Single Number II](../single-number-ii) (Medium) diff --git a/problems/smallest-index-with-equal-value/README.md b/problems/smallest-index-with-equal-value/README.md new file mode 100644 index 000000000..c6d5572b7 --- /dev/null +++ b/problems/smallest-index-with-equal-value/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../number-of-valid-move-combinations-on-chessboard "Number of Valid Move Combinations On Chessboard") +                 +[Next >](../find-the-minimum-and-maximum-number-of-nodes-between-critical-points "Find the Minimum and Maximum Number of Nodes Between Critical Points") + +## [2057. Smallest Index With Equal Value (Easy)](https://leetcode.com/problems/smallest-index-with-equal-value "值相等的最小索引") + +

    Given a 0-indexed integer array nums, return the smallest index i of nums such that i mod 10 == nums[i], or -1 if such index does not exist.

    + +

    x mod y denotes the remainder when x is divided by y.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [0,1,2]
    +Output: 0
    +Explanation: 
    +i=0: 0 mod 10 = 0 == nums[0].
    +i=1: 1 mod 10 = 1 == nums[1].
    +i=2: 2 mod 10 = 2 == nums[2].
    +All indices have i mod 10 == nums[i], so we return the smallest index 0.
    +
    + +

    Example 2:

    + +
    +Input: nums = [4,3,2,1]
    +Output: 2
    +Explanation: 
    +i=0: 0 mod 10 = 0 != nums[0].
    +i=1: 1 mod 10 = 1 != nums[1].
    +i=2: 2 mod 10 = 2 == nums[2].
    +i=3: 3 mod 10 = 3 != nums[3].
    +2 is the only index which has i mod 10 == nums[i].
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,2,3,4,5,6,7,8,9,0]
    +Output: -1
    +Explanation: No index satisfies i mod 10 == nums[i].
    +
    + +

    Example 4:

    + +
    +Input: nums = [2,1,3,5,2]
    +Output: 1
    +Explanation: 1 is the only index with i mod 10 == nums[i].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • 0 <= nums[i] <= 9
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Starting with i=0, check the condition for each index. The first one you find to be true is the smallest index. +
    diff --git a/problems/sort-features-by-popularity/README.md b/problems/sort-features-by-popularity/README.md index fd38ba169..0964c24dd 100644 --- a/problems/sort-features-by-popularity/README.md +++ b/problems/sort-features-by-popularity/README.md @@ -19,6 +19,10 @@ [[String](../../tag/string/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Top K Frequent Elements](../top-k-frequent-elements) (Medium) + 1. [Top K Frequent Words](../top-k-frequent-words) (Medium) + ### Hints
    Hint 1 diff --git a/problems/sort-linked-list-already-sorted-using-absolute-values/README.md b/problems/sort-linked-list-already-sorted-using-absolute-values/README.md new file mode 100644 index 000000000..ea2daefe8 --- /dev/null +++ b/problems/sort-linked-list-already-sorted-using-absolute-values/README.md @@ -0,0 +1,35 @@ + + + + + + + +[< Previous](../second-minimum-time-to-reach-destination "Second Minimum Time to Reach Destination") +                 +[Next >](../number-of-valid-words-in-a-sentence "Number of Valid Words in a Sentence") + +## [2046. Sort Linked List Already Sorted Using Absolute Values (Medium)](https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values "") + + + +### Related Topics + [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +The nodes with positive values are already in the correct order. +
    + +
    +Hint 2 +Nodes with negative values need to be moved to the front. +
    + +
    +Hint 3 +Nodes with negative values are in reversed order. +
    diff --git a/problems/spiral-matrix/README.md b/problems/spiral-matrix/README.md index ce34e4c08..c1b018a6b 100644 --- a/problems/spiral-matrix/README.md +++ b/problems/spiral-matrix/README.md @@ -45,6 +45,7 @@ ### Similar Questions 1. [Spiral Matrix II](../spiral-matrix-ii) (Medium) + 1. [Spiral Matrix III](../spiral-matrix-iii) (Medium) ### Hints
    diff --git a/problems/split-two-strings-to-make-palindrome/README.md b/problems/split-two-strings-to-make-palindrome/README.md index 1e357df0c..0077e76a5 100644 --- a/problems/split-two-strings-to-make-palindrome/README.md +++ b/problems/split-two-strings-to-make-palindrome/README.md @@ -66,9 +66,9 @@ Then, aprefix + bsuffix = "ula" + "alu" ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/stone-game-iv/README.md b/problems/stone-game-iv/README.md index 5a2578d26..5777800a0 100644 --- a/problems/stone-game-iv/README.md +++ b/problems/stone-game-iv/README.md @@ -71,13 +71,6 @@ If Alice starts removing 1 stone, Bob will remove 4 stones then Alice only can r [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Game Theory](../../tag/game-theory/README.md)] -### Similar Questions - 1. [Stone Game V](../stone-game-v) (Hard) - 1. [Stone Game VI](../stone-game-vi) (Medium) - 1. [Stone Game VII](../stone-game-vii) (Medium) - 1. [Stone Game VIII](../stone-game-viii) (Hard) - 1. [Stone Game IX](../stone-game-ix) (Medium) - ### Hints
    Hint 1 diff --git a/problems/stone-game-vi/README.md b/problems/stone-game-vi/README.md index ea21b157d..4295171bb 100644 --- a/problems/stone-game-vi/README.md +++ b/problems/stone-game-vi/README.md @@ -70,12 +70,22 @@ Bob wins. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Game Theory](../../tag/game-theory/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] + +### Similar Questions + 1. [Stone Game](../stone-game) (Medium) + 1. [Stone Game II](../stone-game-ii) (Medium) + 1. [Stone Game III](../stone-game-iii) (Hard) + 1. [Stone Game IV](../stone-game-iv) (Hard) + 1. [Stone Game V](../stone-game-v) (Hard) + 1. [Stone Game VII](../stone-game-vii) (Medium) + 1. [Stone Game VIII](../stone-game-viii) (Hard) + 1. [Stone Game IX](../stone-game-ix) (Medium) ### Hints
    diff --git a/problems/stone-game-vii/README.md b/problems/stone-game-vii/README.md index 49528c39a..c2614f1d6 100644 --- a/problems/stone-game-vii/README.md +++ b/problems/stone-game-vii/README.md @@ -55,17 +55,6 @@ The score difference is 18 - 12 = 6. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Game Theory](../../tag/game-theory/README.md)] -### Similar Questions - 1. [Stone Game](../stone-game) (Medium) - 1. [Stone Game II](../stone-game-ii) (Medium) - 1. [Stone Game III](../stone-game-iii) (Hard) - 1. [Stone Game IV](../stone-game-iv) (Hard) - 1. [Stone Game V](../stone-game-v) (Hard) - 1. [Stone Game VI](../stone-game-vi) (Medium) - 1. [Maximum Score from Performing Multiplication Operations](../maximum-score-from-performing-multiplication-operations) (Medium) - 1. [Stone Game VIII](../stone-game-viii) (Hard) - 1. [Stone Game IX](../stone-game-ix) (Medium) - ### Hints
    Hint 1 diff --git a/problems/string-to-integer-atoi/README.md b/problems/string-to-integer-atoi/README.md index c7a84a2e0..f3583d52e 100644 --- a/problems/string-to-integer-atoi/README.md +++ b/problems/string-to-integer-atoi/README.md @@ -18,7 +18,7 @@
    1. Read in and ignore any leading whitespace.
    2. Check if the next character (if not already at the end of the string) is '-' or '+'. Read this character in if it is either. This determines if the final result is negative or positive respectively. Assume the result is positive if neither is present.
    3. -
    4. Read in next the characters until the next non-digit charcter or the end of the input is reached. The rest of the string is ignored.
    5. +
    6. Read in next the characters until the next non-digit character or the end of the input is reached. The rest of the string is ignored.
    7. Convert these digits into an integer (i.e. "123" -> 123, "0032" -> 32). If no digits were read, then the integer is 0. Change the sign as necessary (from step 2).
    8. If the integer is out of the 32-bit signed integer range [-231, 231 - 1], then clamp the integer so that it remains in the range. Specifically, integers less than -231 should be clamped to -231, and integers greater than 231 - 1 should be clamped to 231 - 1.
    9. Return the integer as the final result.
    10. diff --git a/problems/strings-differ-by-one-character/README.md b/problems/strings-differ-by-one-character/README.md index 5df75f6d3..6fea70d9f 100644 --- a/problems/strings-differ-by-one-character/README.md +++ b/problems/strings-differ-by-one-character/README.md @@ -16,8 +16,8 @@ ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Rolling Hash](../../tag/rolling-hash/README.md)] [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
      diff --git a/problems/strobogrammatic-number-ii/README.md b/problems/strobogrammatic-number-ii/README.md index fc91cab86..f40c678c5 100644 --- a/problems/strobogrammatic-number-ii/README.md +++ b/problems/strobogrammatic-number-ii/README.md @@ -23,9 +23,9 @@
    ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions 1. [Strobogrammatic Number](../strobogrammatic-number) (Easy) diff --git a/problems/strong-friendship/README.md b/problems/strong-friendship/README.md index 0ef455b63..8be710f81 100644 --- a/problems/strong-friendship/README.md +++ b/problems/strong-friendship/README.md @@ -12,3 +12,6 @@ ## [1949. Strong Friendship (Medium)](https://leetcode.com/problems/strong-friendship "") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/sum-of-all-subset-xor-totals/README.md b/problems/sum-of-all-subset-xor-totals/README.md index 21dfba198..be0743994 100644 --- a/problems/sum-of-all-subset-xor-totals/README.md +++ b/problems/sum-of-all-subset-xor-totals/README.md @@ -73,7 +73,9 @@ ### Related Topics [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Combinatorics](../../tag/combinatorics/README.md)] ### Hints
    diff --git a/problems/the-category-of-each-member-in-the-store/README.md b/problems/the-category-of-each-member-in-the-store/README.md new file mode 100644 index 000000000..7de23d89c --- /dev/null +++ b/problems/the-category-of-each-member-in-the-store/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../parallel-courses-iii "Parallel Courses III") +                 +[Next >](../minimum-cost-to-separate-sentence-into-rows "Minimum Cost to Separate Sentence Into Rows") + +## [2051. The Category of Each Member in the Store (Medium)](https://leetcode.com/problems/the-category-of-each-member-in-the-store "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/the-category-of-each-member-in-the-store/mysql_schemas.sql b/problems/the-category-of-each-member-in-the-store/mysql_schemas.sql new file mode 100644 index 000000000..e5664f6fc --- /dev/null +++ b/problems/the-category-of-each-member-in-the-store/mysql_schemas.sql @@ -0,0 +1,21 @@ +Create table If Not Exists Members (member_id int, name varchar(30)); +Create table If Not Exists Visits (visit_id int, member_id int, visit_date date); +Create table If Not Exists Purchases (visit_id int, charged_amount int); +Truncate table Members; +insert into Members (member_id, name) values ('9', 'Alice'); +insert into Members (member_id, name) values ('11', 'Bob'); +insert into Members (member_id, name) values ('3', 'Winston'); +insert into Members (member_id, name) values ('8', 'Hercy'); +insert into Members (member_id, name) values ('1', 'Narihan'); +Truncate table Visits; +insert into Visits (visit_id, member_id, visit_date) values ('22', '11', '2021-10-28'); +insert into Visits (visit_id, member_id, visit_date) values ('16', '11', '2021-01-12'); +insert into Visits (visit_id, member_id, visit_date) values ('18', '9', '2021-12-10'); +insert into Visits (visit_id, member_id, visit_date) values ('19', '3', '2021-10-19'); +insert into Visits (visit_id, member_id, visit_date) values ('12', '11', '2021-03-01'); +insert into Visits (visit_id, member_id, visit_date) values ('17', '8', '2021-05-07'); +insert into Visits (visit_id, member_id, visit_date) values ('21', '9', '2021-05-12'); +Truncate table Purchases; +insert into Purchases (visit_id, charged_amount) values ('12', '2000'); +insert into Purchases (visit_id, charged_amount) values ('18', '9000'); +insert into Purchases (visit_id, charged_amount) values ('17', '7000'); diff --git a/problems/the-most-frequently-ordered-products-for-each-customer/README.md b/problems/the-most-frequently-ordered-products-for-each-customer/README.md index 37dcda904..dce0cb341 100644 --- a/problems/the-most-frequently-ordered-products-for-each-customer/README.md +++ b/problems/the-most-frequently-ordered-products-for-each-customer/README.md @@ -15,6 +15,3 @@ ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [The Most Recent Orders for Each Product](../the-most-recent-orders-for-each-product) (Medium) diff --git a/problems/the-winner-university/README.md b/problems/the-winner-university/README.md new file mode 100644 index 000000000..e294f698f --- /dev/null +++ b/problems/the-winner-university/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../maximum-number-of-tasks-you-can-assign "Maximum Number of Tasks You Can Assign") +                 +[Next >](../time-needed-to-buy-tickets "Time Needed to Buy Tickets") + +## [2072. The Winner University (Easy)](https://leetcode.com/problems/the-winner-university "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/the-winner-university/mysql_schemas.sql b/problems/the-winner-university/mysql_schemas.sql new file mode 100644 index 000000000..a1aefcc9b --- /dev/null +++ b/problems/the-winner-university/mysql_schemas.sql @@ -0,0 +1,8 @@ +Create table If Not Exists NewYork (student_id int, score int); +Create table If Not Exists California (student_id int, score int); +Truncate table NewYork; +insert into NewYork (student_id, score) values ('1', '90'); +insert into NewYork (student_id, score) values ('2', '87'); +Truncate table California; +insert into California (student_id, score) values ('2', '89'); +insert into California (student_id, score) values ('3', '88'); diff --git a/problems/throne-inheritance/README.md b/problems/throne-inheritance/README.md index ac0c68e26..781baf8df 100644 --- a/problems/throne-inheritance/README.md +++ b/problems/throne-inheritance/README.md @@ -81,10 +81,13 @@ t.getInheritanceOrder(); // return ["king", "andy", "ma ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Design](../../tag/design/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] + +### Similar Questions + 1. [Operations on Tree](../operations-on-tree) (Medium) ### Hints
    diff --git a/problems/time-based-key-value-store/README.md b/problems/time-based-key-value-store/README.md index e931d5f10..9eb998f86 100644 --- a/problems/time-based-key-value-store/README.md +++ b/problems/time-based-key-value-store/README.md @@ -36,7 +36,7 @@ TimeMap timeMap = new TimeMap(); timeMap.set("foo", "bar", 1); // store the key "foo" and value "bar" along with timestamp = 1. timeMap.get("foo", 1); // return "bar" timeMap.get("foo", 3); // return "bar", since there is no value corresponding to foo at timestamp 3 and timestamp 2, then the only value is at timestamp 1 is "bar". -timeMap.set("foo", "bar2", 4); // store the key "foo" and value "ba2r" along with timestamp = 4. +timeMap.set("foo", "bar2", 4); // store the key "foo" and value "bar2" along with timestamp = 4. timeMap.get("foo", 4); // return "bar2" timeMap.get("foo", 5); // return "bar2" @@ -53,7 +53,10 @@ timeMap.get("foo", 5); // return "bar2" ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Design](../../tag/design/README.md)] + +### Similar Questions + 1. [Stock Price Fluctuation ](../stock-price-fluctuation) (Medium) diff --git a/problems/time-needed-to-buy-tickets/README.md b/problems/time-needed-to-buy-tickets/README.md new file mode 100644 index 000000000..841c55630 --- /dev/null +++ b/problems/time-needed-to-buy-tickets/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../the-winner-university "The Winner University") +                 +[Next >](../reverse-nodes-in-even-length-groups "Reverse Nodes in Even Length Groups") + +## [2073. Time Needed to Buy Tickets (Easy)](https://leetcode.com/problems/time-needed-to-buy-tickets "买票需要的时间") + +

    There are n people in a line queuing to buy tickets, where the 0th person is at the front of the line and the (n - 1)th person is at the back of the line.

    + +

    You are given a 0-indexed integer array tickets of length n where the number of tickets that the ith person would like to buy is tickets[i].

    + +

    Each person takes exactly 1 second to buy a ticket. A person can only buy 1 ticket at a time and has to go back to the end of the line (which happens instantaneously) in order to buy more tickets. If a person does not have any tickets left to buy, the person will leave the line.

    + +

    Return the time taken for the person at position k (0-indexed) to finish buying tickets.

    + +

     

    +

    Example 1:

    + +
    +Input: tickets = [2,3,2], k = 2
    +Output: 6
    +Explanation: 
    +- In the first pass, everyone in the line buys a ticket and the line becomes [1, 2, 1].
    +- In the second pass, everyone in the line buys a ticket and the line becomes [0, 1, 0].
    +The person at position 2 has successfully bought 2 tickets and it took 3 + 3 = 6 seconds.
    +
    + +

    Example 2:

    + +
    +Input: tickets = [5,1,1,1], k = 0
    +Output: 8
    +Explanation:
    +- In the first pass, everyone in the line buys a ticket and the line becomes [4, 0, 0, 0].
    +- In the next 4 passes, only the person in position 0 is buying tickets.
    +The person at position 0 has successfully bought 5 tickets and it took 4 + 1 + 1 + 1 + 1 = 8 seconds.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == tickets.length
    • +
    • 1 <= n <= 100
    • +
    • 1 <= tickets[i] <= 100
    • +
    • 0 <= k < n
    • +
    + +### Related Topics + [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Loop through the line of people and decrement the number of tickets for each to buy one at a time as if simulating the line moving forward. Keep track of how many tickets have been sold up until person k has no more tickets to buy. +
    + +
    +Hint 2 +Remember that those who have no more tickets to buy will leave the line. +
    diff --git a/problems/triples-with-bitwise-and-equal-to-zero/README.md b/problems/triples-with-bitwise-and-equal-to-zero/README.md index 7b889765c..f8188c11b 100644 --- a/problems/triples-with-bitwise-and-equal-to-zero/README.md +++ b/problems/triples-with-bitwise-and-equal-to-zero/README.md @@ -59,6 +59,6 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/trips-and-users/README.md b/problems/trips-and-users/README.md index 8d32e593e..37733ca07 100644 --- a/problems/trips-and-users/README.md +++ b/problems/trips-and-users/README.md @@ -17,16 +17,16 @@ +-------------+----------+ | Column Name | Type | +-------------+----------+ -| Id | int | -| Client_Id | int | -| Driver_Id | int | -| City_Id | int | -| Status | enum | -| Request_at | date | +| id | int | +| client_id | int | +| driver_id | int | +| city_id | int | +| status | enum | +| request_at | date | +-------------+----------+ -Id is the primary key for this table. -The table holds all taxi trips. Each trip has a unique Id, while Client_Id and Driver_Id are foreign keys to the Users_Id at the Users table. -Status is an ENUM type of (‘completed’, ‘cancelled_by_driver’, ‘cancelled_by_client’). +id is the primary key for this table. +The table holds all taxi trips. Each trip has a unique id, while client_id and driver_id are foreign keys to the users_id at the Users table. +Status is an ENUM type of ('completed', 'cancelled_by_driver', 'cancelled_by_client').

     

    @@ -37,22 +37,22 @@ Status is an ENUM type of (‘completed’, ‘cancelled_by_driver&r +-------------+----------+ | Column Name | Type | +-------------+----------+ -| Users_Id | int | -| Banned | enum | -| Role | enum | +| users_id | int | +| banned | enum | +| role | enum | +-------------+----------+ -Users_Id is the primary key for this table. -The table holds all users. Each user has a unique Users_Id, and Role is an ENUM type of (‘client’, ‘driver’, ‘partner’). -Status is an ENUM type of (‘Yes’, ‘No’). +users_id is the primary key for this table. +The table holds all users. Each user has a unique users_id, and role is an ENUM type of ('client', 'driver', 'partner'). +banned is an ENUM type of ('Yes', 'No').

     

    -

    Write a SQL query to find the cancellation rate of requests with unbanned users (both client and driver must not be banned) each day between "2013-10-01" and "2013-10-03".

    -

    The cancellation rate is computed by dividing the number of canceled (by client or driver) requests with unbanned users by the total number of requests with unbanned users on that day.

    -

    Return the result table in any order. Round Cancellation Rate to two decimal points.

    +

    Write a SQL query to find the cancellation rate of requests with unbanned users (both client and driver must not be banned) each day between "2013-10-01" and "2013-10-03". Round Cancellation Rate to two decimal points.

    + +

    Return the result table in any order.

    The query result format is in the following example.

    @@ -63,7 +63,7 @@ Status is an ENUM type of (‘Yes’, ‘No’). Input: Trips table: +----+-----------+-----------+---------+---------------------+------------+ -| Id | Client_Id | Driver_Id | City_Id | Status | Request_at | +| id | client_id | driver_id | city_id | status | request_at | +----+-----------+-----------+---------+---------------------+------------+ | 1 | 1 | 10 | 1 | completed | 2013-10-01 | | 2 | 2 | 11 | 1 | cancelled_by_driver | 2013-10-01 | @@ -78,7 +78,7 @@ Trips table: +----+-----------+-----------+---------+---------------------+------------+ Users table: +----------+--------+--------+ -| Users_Id | Banned | Role | +| users_id | banned | role | +----------+--------+--------+ | 1 | No | client | | 2 | Yes | client | diff --git a/problems/trips-and-users/mysql_schemas.sql b/problems/trips-and-users/mysql_schemas.sql index e71a764f3..eb8b97370 100644 --- a/problems/trips-and-users/mysql_schemas.sql +++ b/problems/trips-and-users/mysql_schemas.sql @@ -1,22 +1,22 @@ -Create table If Not Exists Trips (Id int, Client_Id int, Driver_Id int, City_Id int, Status ENUM('completed', 'cancelled_by_driver', 'cancelled_by_client'), Request_at varchar(50)); -Create table If Not Exists Users (Users_Id int, Banned varchar(50), Role ENUM('client', 'driver', 'partner')); +Create table If Not Exists Trips (id int, client_id int, driver_id int, city_id int, status ENUM('completed', 'cancelled_by_driver', 'cancelled_by_client'), request_at varchar(50)); +Create table If Not Exists Users (users_id int, banned varchar(50), role ENUM('client', 'driver', 'partner')); Truncate table Trips; -insert into Trips (Id, Client_Id, Driver_Id, City_Id, Status, Request_at) values ('1', '1', '10', '1', 'completed', '2013-10-01'); -insert into Trips (Id, Client_Id, Driver_Id, City_Id, Status, Request_at) values ('2', '2', '11', '1', 'cancelled_by_driver', '2013-10-01'); -insert into Trips (Id, Client_Id, Driver_Id, City_Id, Status, Request_at) values ('3', '3', '12', '6', 'completed', '2013-10-01'); -insert into Trips (Id, Client_Id, Driver_Id, City_Id, Status, Request_at) values ('4', '4', '13', '6', 'cancelled_by_client', '2013-10-01'); -insert into Trips (Id, Client_Id, Driver_Id, City_Id, Status, Request_at) values ('5', '1', '10', '1', 'completed', '2013-10-02'); -insert into Trips (Id, Client_Id, Driver_Id, City_Id, Status, Request_at) values ('6', '2', '11', '6', 'completed', '2013-10-02'); -insert into Trips (Id, Client_Id, Driver_Id, City_Id, Status, Request_at) values ('7', '3', '12', '6', 'completed', '2013-10-02'); -insert into Trips (Id, Client_Id, Driver_Id, City_Id, Status, Request_at) values ('8', '2', '12', '12', 'completed', '2013-10-03'); -insert into Trips (Id, Client_Id, Driver_Id, City_Id, Status, Request_at) values ('9', '3', '10', '12', 'completed', '2013-10-03'); -insert into Trips (Id, Client_Id, Driver_Id, City_Id, Status, Request_at) values ('10', '4', '13', '12', 'cancelled_by_driver', '2013-10-03'); +insert into Trips (id, client_id, driver_id, city_id, status, request_at) values ('1', '1', '10', '1', 'completed', '2013-10-01'); +insert into Trips (id, client_id, driver_id, city_id, status, request_at) values ('2', '2', '11', '1', 'cancelled_by_driver', '2013-10-01'); +insert into Trips (id, client_id, driver_id, city_id, status, request_at) values ('3', '3', '12', '6', 'completed', '2013-10-01'); +insert into Trips (id, client_id, driver_id, city_id, status, request_at) values ('4', '4', '13', '6', 'cancelled_by_client', '2013-10-01'); +insert into Trips (id, client_id, driver_id, city_id, status, request_at) values ('5', '1', '10', '1', 'completed', '2013-10-02'); +insert into Trips (id, client_id, driver_id, city_id, status, request_at) values ('6', '2', '11', '6', 'completed', '2013-10-02'); +insert into Trips (id, client_id, driver_id, city_id, status, request_at) values ('7', '3', '12', '6', 'completed', '2013-10-02'); +insert into Trips (id, client_id, driver_id, city_id, status, request_at) values ('8', '2', '12', '12', 'completed', '2013-10-03'); +insert into Trips (id, client_id, driver_id, city_id, status, request_at) values ('9', '3', '10', '12', 'completed', '2013-10-03'); +insert into Trips (id, client_id, driver_id, city_id, status, request_at) values ('10', '4', '13', '12', 'cancelled_by_driver', '2013-10-03'); Truncate table Users; -insert into Users (Users_Id, Banned, Role) values ('1', 'No', 'client'); -insert into Users (Users_Id, Banned, Role) values ('2', 'Yes', 'client'); -insert into Users (Users_Id, Banned, Role) values ('3', 'No', 'client'); -insert into Users (Users_Id, Banned, Role) values ('4', 'No', 'client'); -insert into Users (Users_Id, Banned, Role) values ('10', 'No', 'driver'); -insert into Users (Users_Id, Banned, Role) values ('11', 'No', 'driver'); -insert into Users (Users_Id, Banned, Role) values ('12', 'No', 'driver'); -insert into Users (Users_Id, Banned, Role) values ('13', 'No', 'driver'); +insert into Users (users_id, banned, role) values ('1', 'No', 'client'); +insert into Users (users_id, banned, role) values ('2', 'Yes', 'client'); +insert into Users (users_id, banned, role) values ('3', 'No', 'client'); +insert into Users (users_id, banned, role) values ('4', 'No', 'client'); +insert into Users (users_id, banned, role) values ('10', 'No', 'driver'); +insert into Users (users_id, banned, role) values ('11', 'No', 'driver'); +insert into Users (users_id, banned, role) values ('12', 'No', 'driver'); +insert into Users (users_id, banned, role) values ('13', 'No', 'driver'); diff --git a/problems/two-best-non-overlapping-events/README.md b/problems/two-best-non-overlapping-events/README.md new file mode 100644 index 000000000..85ace1a73 --- /dev/null +++ b/problems/two-best-non-overlapping-events/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../kth-distinct-string-in-an-array "Kth Distinct String in an Array") +                 +[Next >](../plates-between-candles "Plates Between Candles") + +## [2054. Two Best Non-Overlapping Events (Medium)](https://leetcode.com/problems/two-best-non-overlapping-events "两个最好的不重叠活动") + +

    You are given a 0-indexed 2D integer array of events where events[i] = [startTimei, endTimei, valuei]. The ith event starts at startTimei and ends at endTimei, and if you attend this event, you will receive a value of valuei. You can choose at most two non-overlapping events to attend such that the sum of their values is maximized.

    + +

    Return this maximum sum.

    + +

    Note that the start time and end time is inclusive: that is, you cannot attend two events where one of them starts and the other ends at the same time. More specifically, if you attend an event with end time t, the next event must start at or after t + 1.

    + +

     

    +

    Example 1:

    + +
    +Input: events = [[1,3,2],[4,5,2],[2,4,3]]
    +Output: 4
    +Explanation: Choose the green events, 0 and 1 for a sum of 2 + 2 = 4.
    +
    + +

    Example 2:

    +Example 1 Diagram +
    +Input: events = [[1,3,2],[4,5,2],[1,5,5]]
    +Output: 5
    +Explanation: Choose event 2 for a sum of 5.
    +
    + +

    Example 3:

    + +
    +Input: events = [[1,5,3],[1,5,1],[6,6,5]]
    +Output: 8
    +Explanation: Choose events 0 and 2 for a sum of 3 + 5 = 8.
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= events.length <= 105
    • +
    • events[i].length == 3
    • +
    • 1 <= startTimei <= endTimei <= 109
    • +
    • 1 <= valuei <= 106
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +How can sorting the events on the basis of their start times help? How about end times? +
    + +
    +Hint 2 +How can we quickly get the maximum score of an interval not intersecting with the interval we chose? +
    diff --git a/problems/two-city-scheduling/README.md b/problems/two-city-scheduling/README.md index 840a932d5..854fd250e 100644 --- a/problems/two-city-scheduling/README.md +++ b/problems/two-city-scheduling/README.md @@ -55,6 +55,6 @@ The total minimum cost is 10 + 30 + 50 + 20 = 110 to have half the people interv ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/ugly-number-ii/README.md b/problems/ugly-number-ii/README.md index 0b62a037d..43eeab7b8 100644 --- a/problems/ugly-number-ii/README.md +++ b/problems/ugly-number-ii/README.md @@ -47,10 +47,11 @@ ### Similar Questions 1. [Merge k Sorted Lists](../merge-k-sorted-lists) (Hard) - 1. [Count Primes](../count-primes) (Easy) + 1. [Count Primes](../count-primes) (Medium) 1. [Ugly Number](../ugly-number) (Easy) 1. [Perfect Squares](../perfect-squares) (Medium) 1. [Super Ugly Number](../super-ugly-number) (Medium) + 1. [Ugly Number III](../ugly-number-iii) (Medium) ### Hints
    diff --git a/problems/unique-binary-search-trees-ii/README.md b/problems/unique-binary-search-trees-ii/README.md index 12cdfd3e6..8fcad49b8 100644 --- a/problems/unique-binary-search-trees-ii/README.md +++ b/problems/unique-binary-search-trees-ii/README.md @@ -36,10 +36,10 @@ ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Backtracking](../../tag/backtracking/README.md)] [[Tree](../../tag/tree/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/unique-binary-search-trees/README.md b/problems/unique-binary-search-trees/README.md index 178525946..a4a346d4b 100644 --- a/problems/unique-binary-search-trees/README.md +++ b/problems/unique-binary-search-trees/README.md @@ -36,10 +36,10 @@ ### Related Topics - [[Math](../../tag/math/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Tree](../../tag/tree/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/utf-8-validation/README.md b/problems/utf-8-validation/README.md index c8677b9f1..2655a7631 100644 --- a/problems/utf-8-validation/README.md +++ b/problems/utf-8-validation/README.md @@ -64,8 +64,8 @@ But the second continuation byte does not start with 10, so it is invalid. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/vowels-of-all-substrings/README.md b/problems/vowels-of-all-substrings/README.md new file mode 100644 index 000000000..b16c802cf --- /dev/null +++ b/problems/vowels-of-all-substrings/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../count-vowel-substrings-of-a-string "Count Vowel Substrings of a String") +                 +[Next >](../minimized-maximum-of-products-distributed-to-any-store "Minimized Maximum of Products Distributed to Any Store") + +## [2063. Vowels of All Substrings (Medium)](https://leetcode.com/problems/vowels-of-all-substrings "所有子字符串中的元音") + +

    Given a string word, return the sum of the number of vowels ('a', 'e', 'i', 'o', and 'u') in every substring of word.

    + +

    A substring is a contiguous (non-empty) sequence of characters within a string.

    + +

    Note: Due to the large constraints, the answer may not fit in a signed 32-bit integer. Please be careful during the calculations.

    + +

     

    +

    Example 1:

    + +
    +Input: word = "aba"
    +Output: 6
    +Explanation: 
    +All possible substrings are: "a", "ab", "aba", "b", "ba", and "a".
    +- "b" has 0 vowels in it
    +- "a", "ab", "ba", and "a" have 1 vowel each
    +- "aba" has 2 vowels in it
    +Hence, the total sum of vowels = 0 + 1 + 1 + 1 + 1 + 2 = 6. 
    +
    + +

    Example 2:

    + +
    +Input: word = "abc"
    +Output: 3
    +Explanation: 
    +All possible substrings are: "a", "ab", "abc", "b", "bc", and "c".
    +- "a", "ab", and "abc" have 1 vowel each
    +- "b", "bc", and "c" have 0 vowels each
    +Hence, the total sum of vowels = 1 + 1 + 1 + 0 + 0 + 0 = 3. 
    + +

    Example 3:

    + +
    +Input: word = "ltcd"
    +Output: 0
    +Explanation: There are no vowels in any substring of "ltcd".
    + +

    Example 4:

    + +
    +Input: word = "noosabasboosa"
    +Output: 237
    +Explanation: There are a total of 237 vowels in all the substrings.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= word.length <= 105
    • +
    • word consists of lowercase English letters.
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Combinatorics](../../tag/combinatorics/README.md)] + +### Hints +
    +Hint 1 +Since generating substrings is not an option, can we count the number of substrings a vowel appears in? +
    + +
    +Hint 2 +How much does each vowel contribute to the total sum? +
    diff --git a/problems/walking-robot-simulation-ii/README.md b/problems/walking-robot-simulation-ii/README.md new file mode 100644 index 000000000..681dc572e --- /dev/null +++ b/problems/walking-robot-simulation-ii/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../check-whether-two-strings-are-almost-equivalent "Check Whether Two Strings are Almost Equivalent") +                 +[Next >](../most-beautiful-item-for-each-query "Most Beautiful Item for Each Query") + +## [2069. Walking Robot Simulation II (Medium)](https://leetcode.com/problems/walking-robot-simulation-ii "模拟行走机器人 II") + +

    A width x height grid is on an XY-plane with the bottom-left cell at (0, 0) and the top-right cell at (width - 1, height - 1). The grid is aligned with the four cardinal directions ("North", "East", "South", and "West"). A robot is initially at cell (0, 0) facing direction "East".

    + +

    The robot can be instructed to move for a specific number of steps. For each step, it does the following.

    + +
      +
    1. Attempts to move forward one cell in the direction it is facing.
    2. +
    3. If the cell the robot is moving to is out of bounds, the robot instead turns 90 degrees counterclockwise and retries the step.
    4. +
    + +

    After the robot finishes moving the number of steps required, it stops and awaits the next instruction.

    + +

    Implement the Robot class:

    + +
      +
    • Robot(int width, int height) Initializes the width x height grid with the robot at (0, 0) facing "East".
    • +
    • void step(int num) Instructs the robot to move forward num steps.
    • +
    • int[] getPos() Returns the current cell the robot is at, as an array of length 2, [x, y].
    • +
    • String getDir() Returns the current direction of the robot, "North", "East", "South", or "West".
    • +
    + +

     

    +

    Example 1:

    +example-1 +
    +Input
    +["Robot", "move", "move", "getPos", "getDir", "move", "move", "move", "getPos", "getDir"]
    +[[6, 3], [2], [2], [], [], [2], [1], [4], [], []]
    +Output
    +[null, null, null, [4, 0], "East", null, null, null, [1, 2], "West"]
    +
    +Explanation
    +Robot robot = new Robot(6, 3); // Initialize the grid and the robot at (0, 0) facing East.
    +robot.move(2);  // It moves two steps East to (2, 0), and faces East.
    +robot.move(2);  // It moves two steps East to (4, 0), and faces East.
    +robot.getPos(); // return [4, 0]
    +robot.getDir(); // return "East"
    +robot.move(2);  // It moves one step East to (5, 0), and faces East.
    +                // Moving the next step East would be out of bounds, so it turns and faces North.
    +                // Then, it moves one step North to (5, 1), and faces North.
    +robot.move(1);  // It moves one step North to (5, 2), and faces North (not West).
    +robot.move(4);  // Moving the next step North would be out of bounds, so it turns and faces West.
    +                // Then, it moves four steps West to (1, 2), and faces West.
    +robot.getPos(); // return [1, 2]
    +robot.getDir(); // return "West"
    +
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= width, height <= 100
    • +
    • 1 <= num <= 105
    • +
    • At most 104 calls in total will be made to step, getPos, and getDir.
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +The robot only moves along the perimeter of the grid. Can you think if modulus can help you quickly compute which cell it stops at? +
    + +
    +Hint 2 +After the robot moves one time, whenever the robot stops at some cell, it will always face a specific direction. i.e., The direction it faces is determined by the cell it stops at. +
    + +
    +Hint 3 +Can you precompute what direction it faces when it stops at each cell along the perimeter, and reuse the results? +
    diff --git a/problems/web-crawler-multithreaded/README.md b/problems/web-crawler-multithreaded/README.md index 297f0abc9..aea83a6c6 100644 --- a/problems/web-crawler-multithreaded/README.md +++ b/problems/web-crawler-multithreaded/README.md @@ -109,3 +109,6 @@ startUrl = "http://news.google.com" [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Concurrency](../../tag/concurrency/README.md)] + +### Similar Questions + 1. [Web Crawler](../web-crawler) (Medium) diff --git a/problems/web-crawler/README.md b/problems/web-crawler/README.md index a2719a55c..edd39af60 100644 --- a/problems/web-crawler/README.md +++ b/problems/web-crawler/README.md @@ -93,14 +93,11 @@ startUrl = "http://news.google.com" ### Related Topics - [[String](../../tag/string/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[String](../../tag/string/README.md)] [[Interactive](../../tag/interactive/README.md)] -### Similar Questions - 1. [Web Crawler Multithreaded](../web-crawler-multithreaded) (Medium) - ### Hints
    Hint 1 diff --git a/problems/where-will-the-ball-fall/README.md b/problems/where-will-the-ball-fall/README.md index d575bdf00..130043f1b 100644 --- a/problems/where-will-the-ball-fall/README.md +++ b/problems/where-will-the-ball-fall/README.md @@ -66,9 +66,9 @@ Ball b4 is dropped at column 4 and will get stuck on the box between column 2 an ### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/xor-operation-in-an-array/README.md b/problems/xor-operation-in-an-array/README.md index ee65a7eff..fb190c246 100644 --- a/problems/xor-operation-in-an-array/README.md +++ b/problems/xor-operation-in-an-array/README.md @@ -58,8 +58,8 @@ Where "^" corresponds to bitwise XOR operator. ### Related Topics - [[Math](../../tag/math/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/zigzag-conversion/README.md b/problems/zigzag-conversion/README.md index de6d1e232..2307a86c4 100644 --- a/problems/zigzag-conversion/README.md +++ b/problems/zigzag-conversion/README.md @@ -9,7 +9,7 @@                  [Next >](../reverse-integer "Reverse Integer") -## [6. ZigZag Conversion (Medium)](https://leetcode.com/problems/zigzag-conversion "Z 字形变换") +## [6. Zigzag Conversion (Medium)](https://leetcode.com/problems/zigzag-conversion "Z 字形变换")

    The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)

    diff --git a/readme/1-300.md b/readme/1-300.md index f8bc7f021..fa535c2e6 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -83,7 +83,7 @@ LeetCode Problems' Solutions | 3 | [Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters "无重复字符的最长子串") | [Go](../problems/longest-substring-without-repeating-characters) | Medium | | 4 | [Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays "寻找两个正序数组的中位数") | [Go](../problems/median-of-two-sorted-arrays) | Hard | | 5 | [Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring "最长回文子串") | [Go](../problems/longest-palindromic-substring) | Medium | -| 6 | [ZigZag Conversion](https://leetcode.com/problems/zigzag-conversion "Z 字形变换") | [Go](../problems/zigzag-conversion) | Medium | +| 6 | [Zigzag Conversion](https://leetcode.com/problems/zigzag-conversion "Z 字形变换") | [Go](../problems/zigzag-conversion) | Medium | | 7 | [Reverse Integer](https://leetcode.com/problems/reverse-integer "整数反转") | [Go](../problems/reverse-integer) | Medium | | 8 | [String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-atoi "字符串转换整数 (atoi)") | [Go](../problems/string-to-integer-atoi) | Medium | | 9 | [Palindrome Number](https://leetcode.com/problems/palindrome-number "回文数") | [Go](../problems/palindrome-number) | Easy | @@ -235,7 +235,7 @@ LeetCode Problems' Solutions | 155 | [Min Stack](https://leetcode.com/problems/min-stack "最小栈") | [Go](../problems/min-stack) | Easy | | 156 | [Binary Tree Upside Down](https://leetcode.com/problems/binary-tree-upside-down "上下翻转二叉树") 🔒 | [Go](../problems/binary-tree-upside-down) | Medium | | 157 | [Read N Characters Given Read4](https://leetcode.com/problems/read-n-characters-given-read4 "用 Read4 读取 N 个字符") 🔒 | [Go](../problems/read-n-characters-given-read4) | Easy | -| 158 | [Read N Characters Given Read4 II - Call multiple times](https://leetcode.com/problems/read-n-characters-given-read4-ii-call-multiple-times "用 Read4 读取 N 个字符 II") 🔒 | [Go](../problems/read-n-characters-given-read4-ii-call-multiple-times) | Hard | +| 158 | [Read N Characters Given read4 II - Call Multiple Times](https://leetcode.com/problems/read-n-characters-given-read4-ii-call-multiple-times "用 Read4 读取 N 个字符 II") 🔒 | [Go](../problems/read-n-characters-given-read4-ii-call-multiple-times) | Hard | | 159 | [Longest Substring with At Most Two Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters "至多包含两个不同字符的最长子串") 🔒 | [Go](../problems/longest-substring-with-at-most-two-distinct-characters) | Medium | | 160 | [Intersection of Two Linked Lists](https://leetcode.com/problems/intersection-of-two-linked-lists "相交链表") | [Go](../problems/intersection-of-two-linked-lists) | Easy | | 161 | [One Edit Distance](https://leetcode.com/problems/one-edit-distance "相隔为 1 的编辑距离") 🔒 | [Go](../problems/one-edit-distance) | Medium | @@ -244,7 +244,7 @@ LeetCode Problems' Solutions | 164 | [Maximum Gap](https://leetcode.com/problems/maximum-gap "最大间距") | [Go](../problems/maximum-gap) | Hard | | 165 | [Compare Version Numbers](https://leetcode.com/problems/compare-version-numbers "比较版本号") | [Go](../problems/compare-version-numbers) | Medium | | 166 | [Fraction to Recurring Decimal](https://leetcode.com/problems/fraction-to-recurring-decimal "分数到小数") | [Go](../problems/fraction-to-recurring-decimal) | Medium | -| 167 | [Two Sum II - Input array is sorted](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted "两数之和 II - 输入有序数组") | [Go](../problems/two-sum-ii-input-array-is-sorted) | Easy | +| 167 | [Two Sum II - Input Array Is Sorted](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted "两数之和 II - 输入有序数组") | [Go](../problems/two-sum-ii-input-array-is-sorted) | Easy | | 168 | [Excel Sheet Column Title](https://leetcode.com/problems/excel-sheet-column-title "Excel表列名称") | [Go](../problems/excel-sheet-column-title) | Easy | | 169 | [Majority Element](https://leetcode.com/problems/majority-element "多数元素") | [Go](../problems/majority-element) | Easy | | 170 | [Two Sum III - Data structure design](https://leetcode.com/problems/two-sum-iii-data-structure-design "两数之和 III - 数据结构设计") 🔒 | [Go](../problems/two-sum-iii-data-structure-design) | Easy | @@ -266,7 +266,7 @@ LeetCode Problems' Solutions | 186 | [Reverse Words in a String II](https://leetcode.com/problems/reverse-words-in-a-string-ii "翻转字符串里的单词 II") 🔒 | [Go](../problems/reverse-words-in-a-string-ii) | Medium | | 187 | [Repeated DNA Sequences](https://leetcode.com/problems/repeated-dna-sequences "重复的DNA序列") | [Go](../problems/repeated-dna-sequences) | Medium | | 188 | [Best Time to Buy and Sell Stock IV](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv "买卖股票的最佳时机 IV") | [Go](../problems/best-time-to-buy-and-sell-stock-iv) | Hard | -| 189 | [Rotate Array](https://leetcode.com/problems/rotate-array "旋转数组") | [Go](../problems/rotate-array) | Medium | +| 189 | [Rotate Array](https://leetcode.com/problems/rotate-array "轮转数组") | [Go](../problems/rotate-array) | Medium | | 190 | [Reverse Bits](https://leetcode.com/problems/reverse-bits "颠倒二进制位") | [Go](../problems/reverse-bits) | Easy | | 191 | [Number of 1 Bits](https://leetcode.com/problems/number-of-1-bits "位1的个数") | [Go](../problems/number-of-1-bits) | Easy | | 192 | [Word Frequency](https://leetcode.com/problems/word-frequency "统计词频") | [Bash](../problems/word-frequency) | Medium | diff --git a/readme/1201-1500.md b/readme/1201-1500.md index 2df0492eb..bacd2ea5c 100644 --- a/readme/1201-1500.md +++ b/readme/1201-1500.md @@ -298,7 +298,7 @@ LeetCode Problems' Solutions | 1418 | [Display Table of Food Orders in a Restaurant](https://leetcode.com/problems/display-table-of-food-orders-in-a-restaurant "点菜展示表") | [Go](../problems/display-table-of-food-orders-in-a-restaurant) | Medium | | 1419 | [Minimum Number of Frogs Croaking](https://leetcode.com/problems/minimum-number-of-frogs-croaking "数青蛙") | [Go](../problems/minimum-number-of-frogs-croaking) | Medium | | 1420 | [Build Array Where You Can Find The Maximum Exactly K Comparisons](https://leetcode.com/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons "生成数组") | [Go](../problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons) | Hard | -| 1421 | [NPV Queries](https://leetcode.com/problems/npv-queries "净现值查询") 🔒 | [MySQL](../problems/npv-queries) | Medium | +| 1421 | [NPV Queries](https://leetcode.com/problems/npv-queries "净现值查询") 🔒 | [MySQL](../problems/npv-queries) | Easy | | 1422 | [Maximum Score After Splitting a String](https://leetcode.com/problems/maximum-score-after-splitting-a-string "分割字符串的最大得分") | [Go](../problems/maximum-score-after-splitting-a-string) | Easy | | 1423 | [Maximum Points You Can Obtain from Cards](https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards "可获得的最大点数") | [Go](../problems/maximum-points-you-can-obtain-from-cards) | Medium | | 1424 | [Diagonal Traverse II](https://leetcode.com/problems/diagonal-traverse-ii "对角线遍历 II") | [Go](../problems/diagonal-traverse-ii) | Medium | diff --git a/readme/301-600.md b/readme/301-600.md index 4001d56d8..4ebd07acb 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -109,7 +109,7 @@ LeetCode Problems' Solutions | 329 | [Longest Increasing Path in a Matrix](https://leetcode.com/problems/longest-increasing-path-in-a-matrix "矩阵中的最长递增路径") | [Go](../problems/longest-increasing-path-in-a-matrix) | Hard | | 330 | [Patching Array](https://leetcode.com/problems/patching-array "按要求补齐数组") | [Go](../problems/patching-array) | Hard | | 331 | [Verify Preorder Serialization of a Binary Tree](https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree "验证二叉树的前序序列化") | [Go](../problems/verify-preorder-serialization-of-a-binary-tree) | Medium | -| 332 | [Reconstruct Itinerary](https://leetcode.com/problems/reconstruct-itinerary "重新安排行程") | [Go](../problems/reconstruct-itinerary) | Medium | +| 332 | [Reconstruct Itinerary](https://leetcode.com/problems/reconstruct-itinerary "重新安排行程") | [Go](../problems/reconstruct-itinerary) | Hard | | 333 | [Largest BST Subtree](https://leetcode.com/problems/largest-bst-subtree "最大 BST 子树") 🔒 | [Go](../problems/largest-bst-subtree) | Medium | | 334 | [Increasing Triplet Subsequence](https://leetcode.com/problems/increasing-triplet-subsequence "递增的三元子序列") | [Go](../problems/increasing-triplet-subsequence) | Medium | | 335 | [Self Crossing](https://leetcode.com/problems/self-crossing "路径交叉") | [Go](../problems/self-crossing) | Hard | diff --git a/readme/601-900.md b/readme/601-900.md index f5563b085..269a32bb0 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -167,7 +167,7 @@ LeetCode Problems' Solutions | 687 | [Longest Univalue Path](https://leetcode.com/problems/longest-univalue-path "最长同值路径") | [Go](../problems/longest-univalue-path) | Medium | | 688 | [Knight Probability in Chessboard](https://leetcode.com/problems/knight-probability-in-chessboard "“马”在棋盘上的概率") | [Go](../problems/knight-probability-in-chessboard) | Medium | | 689 | [Maximum Sum of 3 Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays "三个无重叠子数组的最大和") | [Go](../problems/maximum-sum-of-3-non-overlapping-subarrays) | Hard | -| 690 | [Employee Importance](https://leetcode.com/problems/employee-importance "员工的重要性") | [Go](../problems/employee-importance) | Easy | +| 690 | [Employee Importance](https://leetcode.com/problems/employee-importance "员工的重要性") | [Go](../problems/employee-importance) | Medium | | 691 | [Stickers to Spell Word](https://leetcode.com/problems/stickers-to-spell-word "贴纸拼词") | [Go](../problems/stickers-to-spell-word) | Hard | | 692 | [Top K Frequent Words](https://leetcode.com/problems/top-k-frequent-words "前K个高频单词") | [Go](../problems/top-k-frequent-words) | Medium | | 693 | [Binary Number with Alternating Bits](https://leetcode.com/problems/binary-number-with-alternating-bits "交替位二进制数") | [Go](../problems/binary-number-with-alternating-bits) | Easy | diff --git a/readme/901-1200.md b/readme/901-1200.md index 809027847..a21552f13 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -138,7 +138,7 @@ LeetCode Problems' Solutions | 958 | [Check Completeness of a Binary Tree](https://leetcode.com/problems/check-completeness-of-a-binary-tree "二叉树的完全性检验") | [Go](../problems/check-completeness-of-a-binary-tree) | Medium | | 959 | [Regions Cut By Slashes](https://leetcode.com/problems/regions-cut-by-slashes "由斜杠划分区域") | [Go](../problems/regions-cut-by-slashes) | Medium | | 960 | [Delete Columns to Make Sorted III](https://leetcode.com/problems/delete-columns-to-make-sorted-iii "删列造序 III") | [Go](../problems/delete-columns-to-make-sorted-iii) | Hard | -| 961 | [N-Repeated Element in Size 2N Array](https://leetcode.com/problems/n-repeated-element-in-size-2n-array "重复 N 次的元素") | [Go](../problems/n-repeated-element-in-size-2n-array) | Easy | +| 961 | [N-Repeated Element in Size 2N Array](https://leetcode.com/problems/n-repeated-element-in-size-2n-array "在长度 2N 的数组中找出重复 N 次的元素") | [Go](../problems/n-repeated-element-in-size-2n-array) | Easy | | 962 | [Maximum Width Ramp](https://leetcode.com/problems/maximum-width-ramp "最大宽度坡") | [Go](../problems/maximum-width-ramp) | Medium | | 963 | [Minimum Area Rectangle II](https://leetcode.com/problems/minimum-area-rectangle-ii "最小面积矩形 II") | [Go](../problems/minimum-area-rectangle-ii) | Medium | | 964 | [Least Operators to Express Number](https://leetcode.com/problems/least-operators-to-express-number "表示数字的最少运算符") | [Go](../problems/least-operators-to-express-number) | Hard | diff --git a/tag/array/README.md b/tag/array/README.md index 240db0d5e..0ed39d8a2 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,20 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2073 | [买票需要的时间](../../problems/time-needed-to-buy-tickets) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | +| 2070 | [每一个查询的最大美丽值](../../problems/most-beautiful-item-for-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2065 | [最大化一张图中的路径价值](../../problems/maximum-path-quality-of-a-graph) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 2064 | [分配给商店的最多商品的最小值](../../problems/minimized-maximum-of-products-distributed-to-any-store) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 2061 | [Number of Spaces Cleaning Robot Cleaned](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2059 | [转化数字的最小运算数](../../problems/minimum-operations-to-convert-number) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] | Medium | +| 2057 | [值相等的最小索引](../../problems/smallest-index-with-equal-value) | [[数组](../array/README.md)] | Easy | +| 2056 | [棋盘上有效移动组合的数目](../../problems/number-of-valid-move-combinations-on-chessboard) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[模拟](../simulation/README.md)] | Hard | +| 2055 | [蜡烛之间的盘子](../../problems/plates-between-candles) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2053 | [数组中第 K 个独一无二的字符串](../../problems/kth-distinct-string-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 2052 | [Minimum Cost to Separate Sentence Into Rows](../../problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 2044 | [统计按位或能得到最大值的子集数目](../../problems/count-number-of-maximum-bitwise-or-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | @@ -64,6 +78,7 @@ | 1956 | [感染 K 种病毒所需的最短时间](../../problems/minimum-time-for-k-virus-variants-to-spread) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1955 | [统计特殊子序列的数目](../../problems/count-number-of-special-subsequences) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1953 | [你可以工作的最大周数](../../problems/maximum-number-of-weeks-for-which-you-can-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 1950 | [所有子数组最小值中的最大值](../../problems/maximum-of-minimum-values-in-all-subarrays) 🔒 | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | | 1947 | [最大兼容性评分和](../../problems/maximum-compatibility-score-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1946 | [子字符串突变后可能得到的最大整数](../../problems/largest-number-after-mutating-substring) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | @@ -107,7 +122,7 @@ | 1870 | [准时到达的列车最小时速](../../problems/minimum-speed-to-arrive-on-time) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1868 | [两个行程编码数组的积](../../problems/product-of-two-run-length-encoded-arrays) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1865 | [找出和为指定值的下标对](../../problems/finding-pairs-with-a-certain-sum) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | -| 1863 | [找出所有子集的异或总和再求和](../../problems/sum-of-all-subset-xor-totals) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Easy | +| 1863 | [找出所有子集的异或总和再求和](../../problems/sum-of-all-subset-xor-totals) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[组合数学](../combinatorics/README.md)] | Easy | | 1862 | [向下取整数对和](../../problems/sum-of-floored-pairs) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 1861 | [旋转盒子](../../problems/rotating-the-box) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | @@ -132,7 +147,7 @@ | 1822 | [数组元素积的符号](../../problems/sign-of-the-product-of-an-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1820 | [最多邀请的个数](../../problems/maximum-number-of-accepted-invitations) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Hard | -| 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] | Medium | | 1817 | [查找用户活跃分钟数](../../problems/finding-the-users-active-minutes) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1816 | [截断句子](../../problems/truncate-sentence) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 1815 | [得到新鲜甜甜圈的最多组数](../../problems/maximum-number-of-groups-getting-fresh-donuts) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | @@ -216,7 +231,7 @@ | 1665 | [完成所有任务的最少初始能量](../../problems/minimum-initial-energy-to-finish-tasks) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | | 1664 | [生成平衡数组的方案数](../../problems/ways-to-make-a-fair-array) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1662 | [检查两个字符串数组是否相等](../../problems/check-if-two-string-arrays-are-equivalent) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] | Easy | | 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1654 | [到家的最少跳跃次数](../../problems/minimum-jumps-to-reach-home) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -543,7 +558,7 @@ | 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 963 | [最小面积矩形 II](../../problems/minimum-area-rectangle-ii) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 962 | [最大宽度坡](../../problems/maximum-width-ramp) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | -| 961 | [重复 N 次的元素](../../problems/n-repeated-element-in-size-2n-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 961 | [在长度 2N 的数组中找出重复 N 次的元素](../../problems/n-repeated-element-in-size-2n-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 960 | [删列造序 III](../../problems/delete-columns-to-make-sorted-iii) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 957 | [N 天后的牢房](../../problems/prison-cells-after-n-days) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 956 | [最高的广告牌](../../problems/tallest-billboard) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -774,9 +789,10 @@ | 484 | [寻找排列](../../problems/find-permutation) 🔒 | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 480 | [滑动窗口中位数](../../problems/sliding-window-median) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 477 | [汉明距离总和](../../problems/total-hamming-distance) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 475 | [供暖器](../../problems/heaters) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 475 | [供暖器](../../problems/heaters) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 474 | [一和零](../../problems/ones-and-zeroes) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 473 | [火柴拼正方形](../../problems/matchsticks-to-square) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 465 | [最优账单平衡](../../problems/optimal-account-balancing) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 463 | [岛屿的周长](../../problems/island-perimeter) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | | 462 | [最少移动次数使数组元素相等 II](../../problems/minimum-moves-to-equal-array-elements-ii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -899,7 +915,7 @@ | 204 | [计数质数](../../problems/count-primes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] [[数论](../number-theory/README.md)] | Medium | | 200 | [岛屿数量](../../problems/number-of-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 198 | [打家劫舍](../../problems/house-robber) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 189 | [旋转数组](../../problems/rotate-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 189 | [轮转数组](../../problems/rotate-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 188 | [买卖股票的最佳时机 IV](../../problems/best-time-to-buy-and-sell-stock-iv) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 174 | [地下城游戏](../../problems/dungeon-game) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index e7b5987dd..502c29958 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,13 +9,16 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2065 | [最大化一张图中的路径价值](../../problems/maximum-path-quality-of-a-graph) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 2056 | [棋盘上有效移动组合的数目](../../problems/number-of-valid-move-combinations-on-chessboard) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[模拟](../simulation/README.md)] | Hard | +| 2048 | [下一个更大的数值平衡数](../../problems/next-greater-numerically-balanced-number) | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Medium | | 2044 | [统计按位或能得到最大值的子集数目](../../problems/count-number-of-maximum-bitwise-or-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 2014 | [重复 K 次的最长子序列](../../problems/longest-subsequence-repeated-k-times) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1986 | [完成任务的最少工作时间段](../../problems/minimum-number-of-work-sessions-to-finish-the-tasks) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1980 | [找出不同的二进制字符串](../../problems/find-unique-binary-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1947 | [最大兼容性评分和](../../problems/maximum-compatibility-score-sum) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | -| 1863 | [找出所有子集的异或总和再求和](../../problems/sum-of-all-subset-xor-totals) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Easy | +| 1863 | [找出所有子集的异或总和再求和](../../problems/sum-of-all-subset-xor-totals) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[组合数学](../combinatorics/README.md)] | Easy | | 1849 | [将字符串拆分为递减的连续值](../../problems/splitting-a-string-into-descending-consecutive-values) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1820 | [最多邀请的个数](../../problems/maximum-number-of-accepted-invitations) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] [[数论](../number-theory/README.md)] | Hard | @@ -55,7 +58,6 @@ | 494 | [目标和](../../problems/target-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 491 | [递增子序列](../../problems/increasing-subsequences) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 489 | [扫地机器人](../../problems/robot-room-cleaner) 🔒 | [[回溯](../backtracking/README.md)] [[交互](../interactive/README.md)] | Hard | -| 488 | [祖玛游戏](../../problems/zuma-game) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 473 | [火柴拼正方形](../../problems/matchsticks-to-square) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 465 | [最优账单平衡](../../problems/optimal-account-balancing) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 425 | [单词方块](../../problems/word-squares) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index ef1bebbd9..be5e9e54a 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | +| 2070 | [每一个查询的最大美丽值](../../problems/most-beautiful-item-for-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2064 | [分配给商店的最多商品的最小值](../../problems/minimized-maximum-of-products-distributed-to-any-store) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 2055 | [蜡烛之间的盘子](../../problems/plates-between-candles) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2040 | [两个有序数组的第 K 小乘积](../../problems/kth-smallest-product-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | @@ -34,7 +39,7 @@ | 1851 | [包含每个查询的最小区间](../../problems/minimum-interval-to-include-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[扫描线](../line-sweep/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1847 | [最近的房间](../../problems/closest-room) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | | 1838 | [最高频元素的频数](../../problems/frequency-of-the-most-frequent-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | -| 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] | Medium | | 1802 | [有界数组中指定下标处的最大值](../../problems/maximum-value-at-a-given-index-in-a-bounded-array) | [[贪心](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1782 | [统计点对的数目](../../problems/count-pairs-of-nodes) | [[图](../graph/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Hard | @@ -44,7 +49,7 @@ | 1713 | [得到子序列的最少操作次数](../../problems/minimum-operations-to-make-a-subsequence) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1671 | [得到山形数组的最少删除次数](../../problems/minimum-number-of-removals-to-make-mountain-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 1648 | [销售价值减少的颜色球](../../problems/sell-diminishing-valued-colored-balls) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1631 | [最小体力消耗路径](../../problems/path-with-minimum-effort) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | @@ -128,7 +133,7 @@ | 497 | [非重叠矩形中的随机点](../../problems/random-point-in-non-overlapping-rectangles) | [[水塘抽样](../reservoir-sampling/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] [[随机化](../randomized/README.md)] | Medium | | 493 | [翻转对](../../problems/reverse-pairs) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 483 | [最小好进制](../../problems/smallest-good-base) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | -| 475 | [供暖器](../../problems/heaters) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 475 | [供暖器](../../problems/heaters) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 456 | [132 模式](../../problems/132-pattern) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 441 | [排列硬币](../../problems/arranging-coins) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 436 | [寻找右区间](../../problems/find-right-interval) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | diff --git a/tag/binary-tree/README.md b/tag/binary-tree/README.md index eda4ac341..db723ee96 100644 --- a/tag/binary-tree/README.md +++ b/tag/binary-tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 0be114e27..8e7e9b5ee 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -18,7 +18,7 @@ | 1915 | [最美子字符串的数目](../../problems/number-of-wonderful-substrings) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1908 | [Nim 游戏 II](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1879 | [两个数组最小的异或值之和](../../problems/minimum-xor-sum-of-two-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | -| 1863 | [找出所有子集的异或总和再求和](../../problems/sum-of-all-subset-xor-totals) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Easy | +| 1863 | [找出所有子集的异或总和再求和](../../problems/sum-of-all-subset-xor-totals) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[组合数学](../combinatorics/README.md)] | Easy | | 1835 | [所有数对按位与结果的异或和](../../problems/find-xor-sum-of-all-pairs-bitwise-and) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1829 | [每个查询的最大异或值](../../problems/maximum-xor-for-each-query) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1815 | [得到新鲜甜甜圈的最多组数](../../problems/maximum-number-of-groups-getting-fresh-donuts) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | @@ -105,7 +105,7 @@ | 411 | [最短独占单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 405 | [数字转换为十六进制数](../../problems/convert-a-number-to-hexadecimal) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Easy | | 401 | [二进制手表](../../problems/binary-watch) | [[位运算](../bit-manipulation/README.md)] [[回溯](../backtracking/README.md)] | Easy | -| 397 | [整数替换](../../problems/integer-replacement) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 397 | [整数替换](../../problems/integer-replacement) | [[贪心](../greedy/README.md)] [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 393 | [UTF-8 编码验证](../../problems/utf-8-validation) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Medium | | 389 | [找不同](../../problems/find-the-difference) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | | 371 | [两整数之和](../../problems/sum-of-two-integers) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index aed470287..ce91b4628 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2059 | [转化数字的最小运算数](../../problems/minimum-operations-to-convert-number) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | @@ -128,7 +129,7 @@ | 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | | 695 | [岛屿的最大面积](../../problems/max-area-of-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Medium | -| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 684 | [冗余连接](../../problems/redundant-connection) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 675 | [为高尔夫比赛砍树](../../problems/cut-off-trees-for-golf-event) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | @@ -152,6 +153,7 @@ | 505 | [迷宫 II](../../problems/the-maze-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 499 | [迷宫 III](../../problems/the-maze-iii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 490 | [迷宫](../../problems/the-maze) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | +| 488 | [祖玛游戏](../../problems/zuma-game) | [[广度优先搜索](../breadth-first-search/README.md)] [[记忆化搜索](../memoization/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 463 | [岛屿的周长](../../problems/island-perimeter) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | | 449 | [序列化和反序列化二叉搜索树](../../problems/serialize-and-deserialize-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 433 | [最小基因变化](../../problems/minimum-genetic-mutation) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/combinatorics/README.md b/tag/combinatorics/README.md index 3f534b7e3..2e59a4103 100644 --- a/tag/combinatorics/README.md +++ b/tag/combinatorics/README.md @@ -9,8 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2063 | [所有子字符串中的元音](../../problems/vowels-of-all-substrings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1866 | [恰有 K 根木棍可以看到的排列数目](../../problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1863 | [找出所有子集的异或总和再求和](../../problems/sum-of-all-subset-xor-totals) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[组合数学](../combinatorics/README.md)] | Easy | | 1830 | [使字符串有序的最少操作次数](../../problems/minimum-number-of-operations-to-make-string-sorted) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1643 | [第 K 条最小指令](../../problems/kth-smallest-instructions) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | diff --git a/tag/counting/README.md b/tag/counting/README.md index a56c615c1..1ffc4d5bf 100644 --- a/tag/counting/README.md +++ b/tag/counting/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2068 | [检查两个字符串是否几乎相等](../../problems/check-whether-two-strings-are-almost-equivalent) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 2067 | [Number of Equal Count Substrings](../../problems/number-of-equal-count-substrings) 🔒 | [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2053 | [数组中第 K 个独一无二的字符串](../../problems/kth-distinct-string-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2029 | [石子游戏 IX](../../problems/stone-game-ix) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2014 | [重复 K 次的最长子序列](../../problems/longest-subsequence-repeated-k-times) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] | Hard | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 7afb641e5..da3b6896e 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1992 | [找到所有的农场组](../../problems/find-all-groups-of-farmland) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1971 | [Find if Path Exists in Graph](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | @@ -132,7 +133,7 @@ | 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | | 695 | [岛屿的最大面积](../../problems/max-area-of-island) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Medium | -| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 687 | [最长同值路径](../../problems/longest-univalue-path) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 685 | [冗余连接 II](../../problems/redundant-connection-ii) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 684 | [冗余连接](../../problems/redundant-connection) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | @@ -172,7 +173,7 @@ | 501 | [二叉搜索树中的众数](../../problems/find-mode-in-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 499 | [迷宫 III](../../problems/the-maze-iii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 490 | [迷宫](../../problems/the-maze) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | -| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 463 | [岛屿的周长](../../problems/island-perimeter) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | | 449 | [序列化和反序列化二叉搜索树](../../problems/serialize-and-deserialize-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 437 | [路径总和 III](../../problems/path-sum-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -194,7 +195,7 @@ | 339 | [嵌套列表权重和](../../problems/nested-list-weight-sum) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 337 | [打家劫舍 III](../../problems/house-robber-iii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 333 | [最大 BST 子树](../../problems/largest-bst-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Medium | +| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | | 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 314 | [二叉树的垂直遍历](../../problems/binary-tree-vertical-order-traversal) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | diff --git a/tag/design/README.md b/tag/design/README.md index e34d41c6e..1bcdb3140 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2069 | [模拟行走机器人 II](../../problems/walking-robot-simulation-ii) | [[设计](../design/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2013 | [检测正方形](../../problems/detect-squares) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 19af95bb4..9b51c3b2c 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,6 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2063 | [所有子字符串中的元音](../../problems/vowels-of-all-substrings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | +| 2060 | [同源字符串检测](../../problems/check-if-an-original-string-exists-given-two-encoded-strings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2052 | [Minimum Cost to Separate Sentence Into Rows](../../problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2050 | [并行课程 III](../../problems/parallel-courses-iii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 2036 | [Maximum Alternating Subarray Sum](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -260,11 +265,12 @@ | 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 509 | [斐波那契数](../../problems/fibonacci-number) | [[递归](../recursion/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 494 | [目标和](../../problems/target-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 488 | [祖玛游戏](../../problems/zuma-game) | [[广度优先搜索](../breadth-first-search/README.md)] [[记忆化搜索](../memoization/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 487 | [最大连续1的个数 II](../../problems/max-consecutive-ones-ii) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 486 | [预测赢家](../../problems/predict-the-winner) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 474 | [一和零](../../problems/ones-and-zeroes) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 473 | [火柴拼正方形](../../problems/matchsticks-to-square) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | -| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 471 | [编码最短长度的字符串](../../problems/encode-string-with-shortest-length) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 467 | [环绕字符串中唯一的子字符串](../../problems/unique-substrings-in-wraparound-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 466 | [统计重复个数](../../problems/count-the-repetitions) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -277,7 +283,7 @@ | 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 403 | [青蛙过河](../../problems/frog-jump) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 397 | [整数替换](../../problems/integer-replacement) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 397 | [整数替换](../../problems/integer-replacement) | [[贪心](../greedy/README.md)] [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 396 | [旋转函数](../../problems/rotate-function) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 392 | [判断子序列](../../problems/is-subsequence) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 377 | [组合总和 Ⅳ](../../problems/combination-sum-iv) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/enumeration/README.md b/tag/enumeration/README.md index 4c68ea96d..f2c725d05 100644 --- a/tag/enumeration/README.md +++ b/tag/enumeration/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2048 | [下一个更大的数值平衡数](../../problems/next-greater-numerically-balanced-number) | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Medium | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2018 | [判断单词是否能放入填字游戏内](../../problems/check-if-word-can-be-placed-in-crossword) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 2014 | [重复 K 次的最长子序列](../../problems/longest-subsequence-repeated-k-times) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] | Hard | diff --git a/tag/eulerian-circuit/README.md b/tag/eulerian-circuit/README.md index 6f8aec228..4a15e673d 100644 --- a/tag/eulerian-circuit/README.md +++ b/tag/eulerian-circuit/README.md @@ -10,4 +10,4 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | | 753 | [破解保险箱](../../problems/cracking-the-safe) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | -| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Medium | +| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index 2560c43df..d40bb1c01 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2065 | [最大化一张图中的路径价值](../../problems/maximum-path-quality-of-a-graph) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 2050 | [并行课程 III](../../problems/parallel-courses-iii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | @@ -77,7 +79,7 @@ | 490 | [迷宫](../../problems/the-maze) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 444 | [序列重建](../../problems/sequence-reconstruction) 🔒 | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] | Medium | | 399 | [除法求值](../../problems/evaluate-division) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Medium | -| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Medium | +| 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | | 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 323 | [无向图中连通分量的数目](../../problems/number-of-connected-components-in-an-undirected-graph) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | | 310 | [最小高度树](../../problems/minimum-height-trees) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Medium | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index e27af2371..b992d5bed 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 2038 | [如果相邻两个颜色均相同则删除当前颜色](../../problems/remove-colored-pieces-if-both-neighbors-are-the-same-color) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 2030 | [含特定字母的最小子序列](../../problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 2029 | [石子游戏 IX](../../problems/stone-game-ix) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[博弈](../game-theory/README.md)] | Medium | @@ -39,7 +40,6 @@ | 1833 | [雪糕的最大数量](../../problems/maximum-ice-cream-bars) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1827 | [最少操作使数组递增](../../problems/minimum-operations-to-make-the-array-increasing) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 1824 | [最少侧跳次数](../../problems/minimum-sideway-jumps) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1802 | [有界数组中指定下标处的最大值](../../problems/maximum-value-at-a-given-index-in-a-bounded-array) | [[贪心](../greedy/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1798 | [你能构造出连续值的最大数目](../../problems/maximum-number-of-consecutive-values-you-can-make) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1794 | [统计距离最小的子串对个数](../../problems/count-pairs-of-equal-substrings-with-minimum-difference) 🔒 | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | @@ -197,6 +197,7 @@ | 409 | [最长回文串](../../problems/longest-palindrome) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 406 | [根据身高重建队列](../../problems/queue-reconstruction-by-height) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 402 | [移掉 K 位数字](../../problems/remove-k-digits) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 397 | [整数替换](../../problems/integer-replacement) | [[贪心](../greedy/README.md)] [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 334 | [递增的三元子序列](../../problems/increasing-triplet-subsequence) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index a2f17ec46..b3e559827 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2068 | [检查两个字符串是否几乎相等](../../problems/check-whether-two-strings-are-almost-equivalent) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 2062 | [统计字符串中的元音子字符串](../../problems/count-vowel-substrings-of-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 2053 | [数组中第 K 个独一无二的字符串](../../problems/kth-distinct-string-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2032 | [至少在两个数组中出现的值](../../problems/two-out-of-three) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | @@ -61,7 +64,7 @@ | 1679 | [K 和数对的最大数目](../../problems/max-number-of-k-sum-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 1674 | [使数组互补的最少操作次数](../../problems/minimum-moves-to-make-array-complementary) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1660 | [纠正二叉树](../../problems/correct-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1657 | [确定两个字符串是否接近](../../problems/determine-if-two-strings-are-close) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] | Easy | | 1650 | [二叉树的最近公共祖先 III](../../problems/lowest-common-ancestor-of-a-binary-tree-iii) 🔒 | [[树](../tree/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -174,7 +177,7 @@ | 974 | [和可被 K 整除的子数组](../../problems/subarray-sums-divisible-by-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 970 | [强整数](../../problems/powerful-integers) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 966 | [元音拼写检查器](../../problems/vowel-spellchecker) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 961 | [重复 N 次的元素](../../problems/n-repeated-element-in-size-2n-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 961 | [在长度 2N 的数组中找出重复 N 次的元素](../../problems/n-repeated-element-in-size-2n-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 957 | [N 天后的牢房](../../problems/prison-cells-after-n-days) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 954 | [二倍数对数组](../../problems/array-of-doubled-pairs) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | | 953 | [验证外星语词典](../../problems/verifying-an-alien-dictionary) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | @@ -228,7 +231,7 @@ | 697 | [数组的度](../../problems/degree-of-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 694 | [不同岛屿的数量](../../problems/number-of-distinct-islands) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Medium | | 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Easy | +| 690 | [员工的重要性](../../problems/employee-importance) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 677 | [键值映射](../../problems/map-sum-pairs) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 676 | [实现一个魔法字典](../../problems/implement-magic-dictionary) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 659 | [分割数组为连续子序列](../../problems/split-array-into-consecutive-subsequences) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/heap-priority-queue/README.md b/tag/heap-priority-queue/README.md index 605ef67c7..f27a28295 100644 --- a/tag/heap-priority-queue/README.md +++ b/tag/heap-priority-queue/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2015 | [Average Height of Buildings in Each Segment](../../problems/average-height-of-buildings-in-each-segment) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index 0bfa59a4d..f7822a978 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2074 | [反转偶数长度组的节点](../../problems/reverse-nodes-in-even-length-groups) | [[链表](../linked-list/README.md)] | Medium | +| 2058 | [找出临界点之间的最小和最大距离](../../problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points) | [[链表](../linked-list/README.md)] | Medium | +| 2046 | [Sort Linked List Already Sorted Using Absolute Values](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 1836 | [从未排序的链表中移除重复元素](../../problems/remove-duplicates-from-an-unsorted-linked-list) 🔒 | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | | 1721 | [交换链表中的节点](../../problems/swapping-nodes-in-a-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 513cac81c..9c7ca9107 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2063 | [所有子字符串中的元音](../../problems/vowels-of-all-substrings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | +| 2048 | [下一个更大的数值平衡数](../../problems/next-greater-numerically-balanced-number) | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Medium | | 2038 | [如果相邻两个颜色均相同则删除当前颜色](../../problems/remove-colored-pieces-if-both-neighbors-are-the-same-color) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | | 2029 | [石子游戏 IX](../../problems/stone-game-ix) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[博弈](../game-theory/README.md)] | Medium | @@ -35,6 +37,7 @@ | 1878 | [矩阵中最大的三个菱形和](../../problems/get-biggest-three-rhombus-sums-in-a-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1872 | [石子游戏 VIII](../../problems/stone-game-viii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 1866 | [恰有 K 根木棍可以看到的排列数目](../../problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | +| 1863 | [找出所有子集的异或总和再求和](../../problems/sum-of-all-subset-xor-totals) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[组合数学](../combinatorics/README.md)] | Easy | | 1862 | [向下取整数对和](../../problems/sum-of-floored-pairs) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 1840 | [最高建筑高度](../../problems/maximum-building-height) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1837 | [K 进制表示下的各位数字总和](../../problems/sum-of-digits-in-base-k) | [[数学](../math/README.md)] | Easy | @@ -310,7 +313,7 @@ | 223 | [矩形面积](../../problems/rectangle-area) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | | 204 | [计数质数](../../problems/count-primes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] [[数论](../number-theory/README.md)] | Medium | | 202 | [快乐数](../../problems/happy-number) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 189 | [旋转数组](../../problems/rotate-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 189 | [轮转数组](../../problems/rotate-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 172 | [阶乘后的零](../../problems/factorial-trailing-zeroes) | [[数学](../math/README.md)] | Medium | | 171 | [Excel 表列序号](../../problems/excel-sheet-column-number) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 168 | [Excel表列名称](../../problems/excel-sheet-column-title) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | diff --git a/tag/matrix/README.md b/tag/matrix/README.md index f45aba1f5..997dc3f2b 100644 --- a/tag/matrix/README.md +++ b/tag/matrix/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2061 | [Number of Spaces Cleaning Robot Cleaned](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | | 2022 | [将一维数组转变成二维数组](../../problems/convert-1d-array-into-2d-array) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | | 2018 | [判断单词是否能放入填字游戏内](../../problems/check-if-word-can-be-placed-in-crossword) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | diff --git a/tag/memoization/README.md b/tag/memoization/README.md index 755983572..f1f07257d 100644 --- a/tag/memoization/README.md +++ b/tag/memoization/README.md @@ -28,8 +28,9 @@ | 638 | [大礼包](../../problems/shopping-offers) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 546 | [移除盒子](../../problems/remove-boxes) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 509 | [斐波那契数](../../problems/fibonacci-number) | [[递归](../recursion/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 488 | [祖玛游戏](../../problems/zuma-game) | [[广度优先搜索](../breadth-first-search/README.md)] [[记忆化搜索](../memoization/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 464 | [我能赢吗](../../problems/can-i-win) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[博弈](../game-theory/README.md)] | Medium | -| 397 | [整数替换](../../problems/integer-replacement) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 397 | [整数替换](../../problems/integer-replacement) | [[贪心](../greedy/README.md)] [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 329 | [矩阵中的最长递增路径](../../problems/longest-increasing-path-in-a-matrix) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 294 | [翻转游戏 II](../../problems/flip-game-ii) 🔒 | [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 241 | [为运算表达式设计优先级](../../problems/different-ways-to-add-parentheses) | [[递归](../recursion/README.md)] [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/monotonic-queue/README.md b/tag/monotonic-queue/README.md index 1b001c2c8..2297ba064 100644 --- a/tag/monotonic-queue/README.md +++ b/tag/monotonic-queue/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 1696 | [跳跃游戏 VI](../../problems/jump-game-vi) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | diff --git a/tag/monotonic-stack/README.md b/tag/monotonic-stack/README.md index 54985b13f..b53323820 100644 --- a/tag/monotonic-stack/README.md +++ b/tag/monotonic-stack/README.md @@ -11,6 +11,7 @@ | :-: | - | - | :-: | | 2030 | [含特定字母的最小子序列](../../problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 1950 | [所有子数组最小值中的最大值](../../problems/maximum-of-minimum-values-in-all-subarrays) 🔒 | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1944 | [队列中可以看到的人数](../../problems/number-of-visible-people-in-a-queue) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1793 | [好子数组的最大分数](../../problems/maximum-score-of-a-good-subarray) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | diff --git a/tag/ordered-set/README.md b/tag/ordered-set/README.md index 94715a26a..435f180e2 100644 --- a/tag/ordered-set/README.md +++ b/tag/ordered-set/README.md @@ -17,7 +17,7 @@ | 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] | Medium | | 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1675 | [数组的最小偏移量](../../problems/minimize-deviation-in-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | diff --git a/tag/prefix-sum/README.md b/tag/prefix-sum/README.md index 89f66e12b..a5638d976 100644 --- a/tag/prefix-sum/README.md +++ b/tag/prefix-sum/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2067 | [Number of Equal Count Substrings](../../problems/number-of-equal-count-substrings) 🔒 | [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2055 | [蜡烛之间的盘子](../../problems/plates-between-candles) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2024 | [考试的最大困扰度](../../problems/maximize-the-confusion-of-an-exam) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 2021 | [Brightest Position on Street](../../problems/brightest-position-on-street) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | @@ -37,7 +39,7 @@ | 1703 | [得到连续 K 个 1 的最少相邻交换次数](../../problems/minimum-adjacent-swaps-for-k-consecutive-ones) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | | 1685 | [有序数组中差绝对值之和](../../problems/sum-of-absolute-differences-in-a-sorted-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1674 | [使数组互补的最少操作次数](../../problems/minimum-moves-to-make-array-complementary) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1590 | [使数组和能被 P 整除](../../problems/make-sum-divisible-by-p) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1589 | [所有排列中的最大和](../../problems/maximum-sum-obtained-of-any-permutation) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | | 1588 | [所有奇数长度子数组的和](../../problems/sum-of-all-odd-length-subarrays) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | diff --git a/tag/queue/README.md b/tag/queue/README.md index 60c08ba62..3f3d21fda 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2073 | [买票需要的时间](../../problems/time-needed-to-buy-tickets) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1700 | [无法吃午餐的学生数量](../../problems/number-of-students-unable-to-eat-lunch) | [[栈](../stack/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 1696 | [跳跃游戏 VI](../../problems/jump-game-vi) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/simulation/README.md b/tag/simulation/README.md index da35f0bca..550c95a99 100644 --- a/tag/simulation/README.md +++ b/tag/simulation/README.md @@ -9,6 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2075 | [解码斜向换位密码](../../problems/decode-the-slanted-ciphertext) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2073 | [买票需要的时间](../../problems/time-needed-to-buy-tickets) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2069 | [模拟行走机器人 II](../../problems/walking-robot-simulation-ii) | [[设计](../design/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2061 | [Number of Spaces Cleaning Robot Cleaned](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2056 | [棋盘上有效移动组合的数目](../../problems/number-of-valid-move-combinations-on-chessboard) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[模拟](../simulation/README.md)] | Hard | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2028 | [找出缺失的观测数据](../../problems/find-missing-observations) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2022 | [将一维数组转变成二维数组](../../problems/convert-1d-array-into-2d-array) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index 4f631cd5b..fe8902785 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -19,6 +19,7 @@ | 1703 | [得到连续 K 个 1 的最少相邻交换次数](../../problems/minimum-adjacent-swaps-for-k-consecutive-ones) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | | 1696 | [跳跃游戏 VI](../../problems/jump-game-vi) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1695 | [删除子数组的最大得分](../../problems/maximum-erasure-value) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | | 1499 | [满足不等式的最大值](../../problems/max-value-of-equation) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1493 | [删掉一个元素以后全为 1 的最长子数组](../../problems/longest-subarray-of-1s-after-deleting-one-element) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | diff --git a/tag/sorting/README.md b/tag/sorting/README.md index e90de4a2f..0b4e358dd 100644 --- a/tag/sorting/README.md +++ b/tag/sorting/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | +| 2070 | [每一个查询的最大美丽值](../../problems/most-beautiful-item-for-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2046 | [Sort Linked List Already Sorted Using Absolute Values](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 2037 | [使每位学生都有座位的最少移动次数](../../problems/minimum-number-of-moves-to-seat-everyone) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | | 2015 | [Average Height of Buildings in Each Segment](../../problems/average-height-of-buildings-in-each-segment) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | @@ -33,6 +37,7 @@ | 1846 | [减小和重新排列数组后的最大元素](../../problems/maximum-element-after-decreasing-and-rearranging) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1834 | [单线程 CPU](../../problems/single-threaded-cpu) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1833 | [雪糕的最大数量](../../problems/maximum-ice-cream-bars) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] | Medium | | 1772 | [按受欢迎程度排列功能](../../problems/sort-features-by-popularity) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 1727 | [重新排列后的最大子矩阵](../../problems/largest-submatrix-with-rearrangements) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | | 1710 | [卡车上的最大单元数](../../problems/maximum-units-on-a-truck) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | @@ -174,7 +179,7 @@ | 522 | [最长特殊序列 II](../../problems/longest-uncommon-subsequence-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 506 | [相对名次](../../problems/relative-ranks) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | | 502 | [IPO](../../problems/ipo) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 475 | [供暖器](../../problems/heaters) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 475 | [供暖器](../../problems/heaters) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 462 | [最少移动次数使数组元素相等 II](../../problems/minimum-moves-to-equal-array-elements-ii) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | | 455 | [分发饼干](../../problems/assign-cookies) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 452 | [用最少数量的箭引爆气球](../../problems/minimum-number-of-arrows-to-burst-balloons) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | diff --git a/tag/stack/README.md b/tag/stack/README.md index 5e7381fb9..cd27a9446 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -13,6 +13,7 @@ | 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1963 | [使字符串平衡的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-string-balanced) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 1950 | [所有子数组最小值中的最大值](../../problems/maximum-of-minimum-values-in-all-subarrays) 🔒 | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1944 | [队列中可以看到的人数](../../problems/number-of-visible-people-in-a-queue) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1896 | [反转表达式值的最少操作次数](../../problems/minimum-cost-to-change-the-final-value-of-expression) | [[栈](../stack/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1856 | [子数组最小乘积的最大值](../../problems/maximum-subarray-min-product) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index a0fbdcc46..a013be18a 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,16 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2075 | [解码斜向换位密码](../../problems/decode-the-slanted-ciphertext) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2068 | [检查两个字符串是否几乎相等](../../problems/check-whether-two-strings-are-almost-equivalent) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 2067 | [Number of Equal Count Substrings](../../problems/number-of-equal-count-substrings) 🔒 | [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2063 | [所有子字符串中的元音](../../problems/vowels-of-all-substrings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | +| 2062 | [统计字符串中的元音子字符串](../../problems/count-vowel-substrings-of-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 2060 | [同源字符串检测](../../problems/check-if-an-original-string-exists-given-two-encoded-strings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2056 | [棋盘上有效移动组合的数目](../../problems/number-of-valid-move-combinations-on-chessboard) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[模拟](../simulation/README.md)] | Hard | +| 2055 | [蜡烛之间的盘子](../../problems/plates-between-candles) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2053 | [数组中第 K 个独一无二的字符串](../../problems/kth-distinct-string-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 2047 | [句子中的有效单词数](../../problems/number-of-valid-words-in-a-sentence) | [[字符串](../string/README.md)] | Easy | | 2042 | [检查句子中的数字是否递增](../../problems/check-if-numbers-are-ascending-in-a-sentence) | [[字符串](../string/README.md)] | Easy | | 2038 | [如果相邻两个颜色均相同则删除当前颜色](../../problems/remove-colored-pieces-if-both-neighbors-are-the-same-color) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 2030 | [含特定字母的最小子序列](../../problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | @@ -360,11 +370,11 @@ | 516 | [最长回文子序列](../../problems/longest-palindromic-subsequence) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 514 | [自由之路](../../problems/freedom-trail) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 500 | [键盘行](../../problems/keyboard-row) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 488 | [祖玛游戏](../../problems/zuma-game) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | +| 488 | [祖玛游戏](../../problems/zuma-game) | [[广度优先搜索](../breadth-first-search/README.md)] [[记忆化搜索](../memoization/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 482 | [密钥格式化](../../problems/license-key-formatting) | [[字符串](../string/README.md)] | Easy | | 481 | [神奇字符串](../../problems/magical-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 474 | [一和零](../../problems/ones-and-zeroes) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 471 | [编码最短长度的字符串](../../problems/encode-string-with-shortest-length) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 468 | [验证IP地址](../../problems/validate-ip-address) | [[字符串](../string/README.md)] | Medium | | 467 | [环绕字符串中唯一的子字符串](../../problems/unique-substrings-in-wraparound-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/topological-sort/README.md b/tag/topological-sort/README.md index f779d858d..5ef75237a 100644 --- a/tag/topological-sort/README.md +++ b/tag/topological-sort/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2050 | [并行课程 III](../../problems/parallel-courses-iii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] [[计数](../counting/README.md)] | Hard | diff --git a/tag/tree/README.md b/tag/tree/README.md index 4a0e237b1..6db4f7127 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | diff --git a/tag/trie/README.md b/tag/trie/README.md index 34d2b1846..4221d14ad 100644 --- a/tag/trie/README.md +++ b/tag/trie/README.md @@ -36,7 +36,7 @@ | 616 | [给字符串添加加粗标签](../../problems/add-bold-tag-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | | 588 | [设计内存文件系统](../../problems/design-in-memory-file-system) 🔒 | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 527 | [单词缩写](../../problems/word-abbreviation) 🔒 | [[贪心](../greedy/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | -| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 472 | [连接词](../../problems/concatenated-words) | [[深度优先搜索](../depth-first-search/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 440 | [字典序的第K小数字](../../problems/k-th-smallest-in-lexicographical-order) | [[字典树](../trie/README.md)] | Hard | | 425 | [单词方块](../../problems/word-squares) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 421 | [数组中两个数的最大异或值](../../problems/maximum-xor-of-two-numbers-in-an-array) | [[位运算](../bit-manipulation/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index 879f2798d..ac1e57620 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2046 | [Sort Linked List Already Sorted Using Absolute Values](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2000 | [反转单词前缀](../../problems/reverse-prefix-of-word) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 1963 | [使字符串平衡的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-string-balanced) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | @@ -30,7 +31,6 @@ | 1721 | [交换链表中的节点](../../problems/swapping-nodes-in-a-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1712 | [将数组分成三个子数组的方案数](../../problems/ways-to-split-array-into-three-subarrays) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1679 | [K 和数对的最大数目](../../problems/max-number-of-k-sum-pairs) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | -| 1658 | [将 x 减到 0 的最小操作数](../../problems/minimum-operations-to-reduce-x-to-zero) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1634 | [求两个多项式链表的和](../../problems/add-two-polynomials-represented-as-linked-lists) 🔒 | [[链表](../linked-list/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1616 | [分割两个字符串得到回文串](../../problems/split-two-strings-to-make-palindrome) | [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | @@ -95,6 +95,7 @@ | 524 | [通过删除字母匹配到字典里最长单词](../../problems/longest-word-in-dictionary-through-deleting) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 522 | [最长特殊序列 II](../../problems/longest-uncommon-subsequence-ii) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 481 | [神奇字符串](../../problems/magical-string) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | +| 475 | [供暖器](../../problems/heaters) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 457 | [环形数组是否存在循环](../../problems/circular-array-loop) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 443 | [压缩字符串](../../problems/string-compression) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 408 | [有效单词缩写](../../problems/valid-word-abbreviation) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | @@ -116,7 +117,7 @@ | 244 | [最短单词距离 II](../../problems/shortest-word-distance-ii) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 234 | [回文链表](../../problems/palindrome-linked-list) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 202 | [快乐数](../../problems/happy-number) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Easy | -| 189 | [旋转数组](../../problems/rotate-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 189 | [轮转数组](../../problems/rotate-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 186 | [翻转字符串里的单词 II](../../problems/reverse-words-in-a-string-ii) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | | 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | From 934ba9cb8087bbd0225c76076a1921a7c3e2604e Mon Sep 17 00:00:00 2001 From: Shuo Date: Sat, 27 Nov 2021 17:09:32 +0800 Subject: [PATCH 138/145] U: mod --- go.mod | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index b4846db92..5eb7c7282 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/openset/leetcode +module github.com/awesee/leetcode -go 1.15 +go 1.16 From 4d4b7afc7be596b725dece2e3ee4a08c620823a4 Mon Sep 17 00:00:00 2001 From: Shuo Date: Sat, 27 Nov 2021 17:53:37 +0800 Subject: [PATCH 139/145] U: mod --- internal/base/base.go | 8 ++--- internal/build/build.go | 6 ++-- internal/clean/clean.go | 4 +-- internal/client/client.go | 2 +- internal/description/description.go | 4 +-- internal/help/help.go | 2 +- internal/helper/helper.go | 2 +- internal/leetcode/base.go | 4 +-- internal/leetcode/problems_algorithms.go | 2 +- internal/leetcode/problems_all.go | 2 +- internal/leetcode/problems_database.go | 2 +- internal/leetcode/problems_shell.go | 2 +- internal/leetcode/question_article.go | 2 +- internal/leetcode/topic_tag.go | 2 +- internal/open/open.go | 6 ++-- internal/page/page.go | 4 +-- internal/post/post.go | 6 ++-- internal/question/question.go | 4 +-- internal/readme/readme.go | 22 +++++++------- internal/tag/tag.go | 6 ++-- internal/test/test.go | 4 +-- internal/update/update.go | 4 +-- internal/version/version.go | 2 +- main.go | 30 +++++++++---------- .../add_one_row_to_tree.go | 2 +- .../add_one_row_to_tree_test.go | 2 +- .../add-two-numbers-ii/add_two_numbers_ii.go | 2 +- .../add_two_numbers_ii_test.go | 2 +- problems/add-two-numbers/add_two_numbers.go | 2 +- .../add-two-numbers/add_two_numbers_test.go | 2 +- .../balanced_binary_tree.go | 2 +- .../balanced_binary_tree_test.go | 2 +- .../construct_string_from_binary_tree.go | 2 +- .../construct_string_from_binary_tree_test.go | 2 +- ...vert_sorted_array_to_binary_search_tree.go | 2 +- ...sorted_array_to_binary_search_tree_test.go | 2 +- .../cousins_in_binary_tree.go | 2 +- .../cousins_in_binary_tree_test.go | 2 +- .../delete_node_in_a_linked_list.go | 2 +- .../delete_node_in_a_linked_list_test.go | 2 +- .../intersection_of_two_arrays_ii_test.go | 2 +- .../intersection_of_two_linked_lists.go | 2 +- .../intersection_of_two_linked_lists_test.go | 2 +- .../invert-binary-tree/invert_binary_tree.go | 2 +- .../invert_binary_tree_test.go | 2 +- .../linked-list-cycle/linked_list_cycle.go | 2 +- .../linked_list_cycle_test.go | 2 +- .../maximum_depth_of_binary_tree.go | 2 +- .../maximum_depth_of_binary_tree_test.go | 2 +- .../merge_k_sorted_lists.go | 2 +- .../merge_k_sorted_lists_test.go | 2 +- .../merge_two_binary_trees.go | 2 +- .../merge_two_binary_trees_test.go | 2 +- .../merge_two_sorted_lists.go | 2 +- .../merge_two_sorted_lists_test.go | 2 +- .../minimum_depth_of_binary_tree.go | 2 +- .../minimum_depth_of_binary_tree_test.go | 2 +- .../palindrome_linked_list.go | 2 +- .../palindrome_linked_list_test.go | 2 +- problems/path-sum-iii/path_sum_iii.go | 2 +- problems/path-sum-iii/path_sum_iii_test.go | 2 +- problems/path-sum/path_sum.go | 2 +- problems/path-sum/path_sum_test.go | 2 +- .../powerful_integers_test.go | 2 +- problems/range-sum-of-bst/range_sum_of_bst.go | 2 +- .../range-sum-of-bst/range_sum_of_bst_test.go | 2 +- .../remove_duplicates_from_sorted_list.go | 2 +- ...remove_duplicates_from_sorted_list_test.go | 2 +- .../remove_nth_node_from_end_of_list.go | 2 +- .../remove_nth_node_from_end_of_list_test.go | 2 +- .../reverse_linked_list.go | 2 +- .../reverse_linked_list_test.go | 2 +- problems/same-tree/same_tree.go | 2 +- problems/same-tree/same_tree_test.go | 2 +- .../sum_of_root_to_leaf_binary_numbers.go | 2 +- ...sum_of_root_to_leaf_binary_numbers_test.go | 2 +- problems/symmetric-tree/symmetric_tree.go | 2 +- .../symmetric-tree/symmetric_tree_test.go | 2 +- problems/to-lower-case/to_lower_case_test.go | 8 ++--- .../unique_email_addresses_test.go | 2 +- .../univalued_binary_tree.go | 2 +- .../univalued_binary_tree_test.go | 2 +- 82 files changed, 127 insertions(+), 127 deletions(-) diff --git a/internal/base/base.go b/internal/base/base.go index 43bec5f6a..63c94a469 100644 --- a/internal/base/base.go +++ b/internal/base/base.go @@ -13,7 +13,7 @@ import ( ) // URL - base.URL -const URL = "https://github.com/openset/leetcode/tree/master" +const URL = "https://github.com/awesee/leetcode/tree/master" // CmdName - base.CmdName var CmdName = filepath.Base(os.Args[0]) @@ -68,9 +68,9 @@ func CheckErr(err error) { func AuthInfo(cmd string) string { format := "\n" format += "\n" - format += "\n" - format += "\n" - format += "\n" + format += "\n" + format += "\n" + format += "\n" format += "\n" return fmt.Sprintf(format, cmd, strings.Repeat(" ", 15-len(cmd))) } diff --git a/internal/build/build.go b/internal/build/build.go index f0186fe99..8a7fcdf72 100644 --- a/internal/build/build.go +++ b/internal/build/build.go @@ -9,8 +9,8 @@ import ( "os/exec" "time" - "github.com/openset/leetcode/internal/base" - "github.com/openset/leetcode/internal/version" + "github.com/awesee/leetcode/internal/base" + "github.com/awesee/leetcode/internal/version" ) // CmdBuild - build.CmdBuild @@ -56,7 +56,7 @@ func runBuild(cmd *base.Command, args []string) { Modified: time.Now(), }) base.CheckErr(err) - err = exec.Command("go", "build", "-ldflags", "-s -w", "github.com/openset/leetcode").Run() + err = exec.Command("go", "build", "-ldflags", "-s -w", "github.com/awesee/leetcode").Run() base.CheckErr(err) src, err := os.Open(binName()) base.CheckErr(err) diff --git a/internal/clean/clean.go b/internal/clean/clean.go index 3ec61a0e2..3d07fd0b6 100644 --- a/internal/clean/clean.go +++ b/internal/clean/clean.go @@ -2,8 +2,8 @@ package clean import ( - "github.com/openset/leetcode/internal/base" - "github.com/openset/leetcode/internal/leetcode" + "github.com/awesee/leetcode/internal/base" + "github.com/awesee/leetcode/internal/leetcode" ) // CmdClean - clean.CmdClean diff --git a/internal/client/client.go b/internal/client/client.go index b25a8eb32..9a419e513 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -8,7 +8,7 @@ import ( "net/http/cookiejar" "strings" - "github.com/openset/leetcode/internal/base" + "github.com/awesee/leetcode/internal/base" ) var err error diff --git a/internal/description/description.go b/internal/description/description.go index c2cc5d4c4..7a71538bf 100644 --- a/internal/description/description.go +++ b/internal/description/description.go @@ -6,8 +6,8 @@ import ( "runtime" "sync" - "github.com/openset/leetcode/internal/base" - "github.com/openset/leetcode/internal/leetcode" + "github.com/awesee/leetcode/internal/base" + "github.com/awesee/leetcode/internal/leetcode" ) // CmdDescription - description.CmdDescription diff --git a/internal/help/help.go b/internal/help/help.go index 0b52c3c2c..cf00dbe93 100644 --- a/internal/help/help.go +++ b/internal/help/help.go @@ -4,7 +4,7 @@ package help import ( "fmt" - "github.com/openset/leetcode/internal/base" + "github.com/awesee/leetcode/internal/base" ) // CmdHelp - help.CmdHelp diff --git a/internal/helper/helper.go b/internal/helper/helper.go index facf53f81..b12d1e739 100644 --- a/internal/helper/helper.go +++ b/internal/helper/helper.go @@ -5,7 +5,7 @@ import ( "bytes" "os/exec" - "github.com/openset/leetcode/internal/base" + "github.com/awesee/leetcode/internal/base" ) // CmdHelper - help.CmdHelper diff --git a/internal/leetcode/base.go b/internal/leetcode/base.go index 2584d2d20..f53c732ed 100644 --- a/internal/leetcode/base.go +++ b/internal/leetcode/base.go @@ -10,8 +10,8 @@ import ( "strings" "time" - "github.com/openset/leetcode/internal/base" - "github.com/openset/leetcode/internal/client" + "github.com/awesee/leetcode/internal/base" + "github.com/awesee/leetcode/internal/client" ) // leetcode var diff --git a/internal/leetcode/problems_algorithms.go b/internal/leetcode/problems_algorithms.go index 24c4b0c7a..cde634476 100644 --- a/internal/leetcode/problems_algorithms.go +++ b/internal/leetcode/problems_algorithms.go @@ -1,6 +1,6 @@ package leetcode -import "github.com/openset/leetcode/internal/client" +import "github.com/awesee/leetcode/internal/client" // ProblemsAlgorithms - leetcode.ProblemsAlgorithms func ProblemsAlgorithms() (ps ProblemsType) { diff --git a/internal/leetcode/problems_all.go b/internal/leetcode/problems_all.go index 294baae0c..86248b591 100644 --- a/internal/leetcode/problems_all.go +++ b/internal/leetcode/problems_all.go @@ -6,7 +6,7 @@ import ( "sort" "strings" - "github.com/openset/leetcode/internal/client" + "github.com/awesee/leetcode/internal/client" ) // ProblemsType - leetcode.ProblemsType diff --git a/internal/leetcode/problems_database.go b/internal/leetcode/problems_database.go index 48ef446f8..c2495a9b0 100644 --- a/internal/leetcode/problems_database.go +++ b/internal/leetcode/problems_database.go @@ -1,6 +1,6 @@ package leetcode -import "github.com/openset/leetcode/internal/client" +import "github.com/awesee/leetcode/internal/client" // ProblemsDatabase - leetcode.ProblemsDatabase func ProblemsDatabase() (ps ProblemsType) { diff --git a/internal/leetcode/problems_shell.go b/internal/leetcode/problems_shell.go index 6854a8313..5714429de 100644 --- a/internal/leetcode/problems_shell.go +++ b/internal/leetcode/problems_shell.go @@ -1,6 +1,6 @@ package leetcode -import "github.com/openset/leetcode/internal/client" +import "github.com/awesee/leetcode/internal/client" // ProblemsShell - leetcode.ProblemsShell func ProblemsShell() (ps ProblemsType) { diff --git a/internal/leetcode/question_article.go b/internal/leetcode/question_article.go index a70a0561b..ece22475f 100644 --- a/internal/leetcode/question_article.go +++ b/internal/leetcode/question_article.go @@ -5,7 +5,7 @@ import ( "fmt" "regexp" - "github.com/openset/leetcode/internal/client" + "github.com/awesee/leetcode/internal/client" ) // GetDescription - leetcode.GetDescription diff --git a/internal/leetcode/topic_tag.go b/internal/leetcode/topic_tag.go index cf127e472..d045f1a28 100644 --- a/internal/leetcode/topic_tag.go +++ b/internal/leetcode/topic_tag.go @@ -11,7 +11,7 @@ import ( "strconv" "sync" - "github.com/openset/leetcode/internal/client" + "github.com/awesee/leetcode/internal/client" ) var ( diff --git a/internal/open/open.go b/internal/open/open.go index 5e9d9280c..3e6bf14be 100644 --- a/internal/open/open.go +++ b/internal/open/open.go @@ -5,9 +5,9 @@ import ( "fmt" "strconv" - "github.com/openset/leetcode/internal/base" - "github.com/openset/leetcode/internal/browser" - "github.com/openset/leetcode/internal/leetcode" + "github.com/awesee/leetcode/internal/base" + "github.com/awesee/leetcode/internal/browser" + "github.com/awesee/leetcode/internal/leetcode" ) // CmdOpen - open.CmdOpen diff --git a/internal/page/page.go b/internal/page/page.go index 5766b7e68..a58df6130 100644 --- a/internal/page/page.go +++ b/internal/page/page.go @@ -2,8 +2,8 @@ package page import ( - "github.com/openset/leetcode/internal/base" - "github.com/openset/leetcode/internal/readme" + "github.com/awesee/leetcode/internal/base" + "github.com/awesee/leetcode/internal/readme" ) // CmdPage - page.CmdPage diff --git a/internal/post/post.go b/internal/post/post.go index e10388367..9238b6ff7 100644 --- a/internal/post/post.go +++ b/internal/post/post.go @@ -10,8 +10,8 @@ import ( "strings" "time" - "github.com/openset/leetcode/internal/base" - "github.com/openset/leetcode/internal/leetcode" + "github.com/awesee/leetcode/internal/base" + "github.com/awesee/leetcode/internal/leetcode" ) const frontMatter = `--- @@ -43,7 +43,7 @@ var CmdPost = &base.Command{ var ( homeDir, _ = os.UserHomeDir() - basePath = filepath.Join(homeDir, "openset", "openset") + basePath = filepath.Join(homeDir, "awesee", "awesee") ) func runPost(cmd *base.Command, args []string) { diff --git a/internal/question/question.go b/internal/question/question.go index dd60943c8..3dd7e56eb 100644 --- a/internal/question/question.go +++ b/internal/question/question.go @@ -5,8 +5,8 @@ import ( "fmt" "strconv" - "github.com/openset/leetcode/internal/base" - "github.com/openset/leetcode/internal/leetcode" + "github.com/awesee/leetcode/internal/base" + "github.com/awesee/leetcode/internal/leetcode" ) // CmdQuestion - question.CmdQuestion diff --git a/internal/readme/readme.go b/internal/readme/readme.go index 477ff952f..0a4e1e10f 100644 --- a/internal/readme/readme.go +++ b/internal/readme/readme.go @@ -6,22 +6,22 @@ import ( "fmt" "path/filepath" - "github.com/openset/leetcode/internal/base" - "github.com/openset/leetcode/internal/leetcode" + "github.com/awesee/leetcode/internal/base" + "github.com/awesee/leetcode/internal/leetcode" ) const defaultStr = ` -# [LeetCode](https://openset.github.io/leetcode) +# [LeetCode](https://awesee.github.io/leetcode) LeetCode Problems' Solutions -[[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] +[[力扣](https://awesee.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/awesee/leetcode/blob/master/tag/README.md)] -[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) -[![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) -[![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) -[![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) -[![license](https://img.shields.io/github/license/openset/leetcode.svg)](https://github.com/openset/leetcode/blob/master/LICENSE) -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fopenset%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fopenset%2Fleetcode?ref=badge_shield) -[![Join the chat](https://badges.gitter.im/openset/leetcode.svg)](https://gitter.im/openset/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Go](https://github.com/awesee/leetcode/workflows/Go/badge.svg)](https://github.com/awesee/leetcode/actions) +[![codecov](https://codecov.io/gh/awesee/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/awesee/leetcode) +[![Go Report Card](https://goreportcard.com/badge/github.com/awesee/leetcode)](https://goreportcard.com/report/github.com/awesee/leetcode) +[![GitHub contributors](https://img.shields.io/github/contributors/awesee/leetcode.svg)](https://github.com/awesee/leetcode/graphs/contributors) +[![license](https://img.shields.io/github/license/awesee/leetcode.svg)](https://github.com/awesee/leetcode/blob/master/LICENSE) +[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fawesee%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fawesee%2Fleetcode?ref=badge_shield) +[![Join the chat](https://badges.gitter.im/awesee/leetcode.svg)](https://gitter.im/awesee/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ` diff --git a/internal/tag/tag.go b/internal/tag/tag.go index 2ca146756..02819523a 100644 --- a/internal/tag/tag.go +++ b/internal/tag/tag.go @@ -7,8 +7,8 @@ import ( "reflect" "sync" - "github.com/openset/leetcode/internal/base" - "github.com/openset/leetcode/internal/leetcode" + "github.com/awesee/leetcode/internal/base" + "github.com/awesee/leetcode/internal/leetcode" ) // CmdTag - tag.CmdTag @@ -31,7 +31,7 @@ func runTag(cmd *base.Command, args []string) { buf.WriteString("\n## 话题分类\n\n") buf.WriteString("| # | Topic | 话题 | | # | Topic | 话题 |\n") buf.WriteString("| :-: | - | :-: | - | :-: | - | :-: |\n") - format := "| %d | [%s](%s/README.md) | [%s](https://openset.github.io/tags/%s/) | " + format := "| %d | [%s](%s/README.md) | [%s](https://awesee.github.io/tags/%s/) | " n := buf.Len() for times := 0; times < 2; times++ { buf.Truncate(n) diff --git a/internal/test/test.go b/internal/test/test.go index c8d1da39d..1ce2e7bf0 100644 --- a/internal/test/test.go +++ b/internal/test/test.go @@ -6,8 +6,8 @@ import ( "os/exec" "strconv" - "github.com/openset/leetcode/internal/base" - "github.com/openset/leetcode/internal/leetcode" + "github.com/awesee/leetcode/internal/base" + "github.com/awesee/leetcode/internal/leetcode" ) // CmdTest - test.CmdTest diff --git a/internal/update/update.go b/internal/update/update.go index 4abfb3a6f..47a9ebca3 100644 --- a/internal/update/update.go +++ b/internal/update/update.go @@ -6,7 +6,7 @@ import ( "os" "os/exec" - "github.com/openset/leetcode/internal/base" + "github.com/awesee/leetcode/internal/base" ) // CmdUpdate - update.CmdUpdate @@ -22,7 +22,7 @@ func runUpdate(cmd *base.Command, args []string) { cmd.Usage() return } - err := exec.Command("go", "get", "-u", "github.com/openset/leetcode").Run() + err := exec.Command("go", "get", "-u", "github.com/awesee/leetcode").Run() base.CheckErr(err) c := exec.Command(base.CmdName, "version") c.Stdout = os.Stdout diff --git a/internal/version/version.go b/internal/version/version.go index 67e21835c..5964f69a4 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -5,7 +5,7 @@ import ( "fmt" "runtime" - "github.com/openset/leetcode/internal/base" + "github.com/awesee/leetcode/internal/base" ) const version = "1.6.5" diff --git a/main.go b/main.go index 1b7032cec..954f38eaf 100644 --- a/main.go +++ b/main.go @@ -2,21 +2,21 @@ package main import ( - "github.com/openset/leetcode/internal/base" - "github.com/openset/leetcode/internal/build" - "github.com/openset/leetcode/internal/clean" - "github.com/openset/leetcode/internal/description" - "github.com/openset/leetcode/internal/help" - "github.com/openset/leetcode/internal/helper" - "github.com/openset/leetcode/internal/open" - "github.com/openset/leetcode/internal/page" - "github.com/openset/leetcode/internal/post" - "github.com/openset/leetcode/internal/question" - "github.com/openset/leetcode/internal/readme" - "github.com/openset/leetcode/internal/tag" - "github.com/openset/leetcode/internal/test" - "github.com/openset/leetcode/internal/update" - "github.com/openset/leetcode/internal/version" + "github.com/awesee/leetcode/internal/base" + "github.com/awesee/leetcode/internal/build" + "github.com/awesee/leetcode/internal/clean" + "github.com/awesee/leetcode/internal/description" + "github.com/awesee/leetcode/internal/help" + "github.com/awesee/leetcode/internal/helper" + "github.com/awesee/leetcode/internal/open" + "github.com/awesee/leetcode/internal/page" + "github.com/awesee/leetcode/internal/post" + "github.com/awesee/leetcode/internal/question" + "github.com/awesee/leetcode/internal/readme" + "github.com/awesee/leetcode/internal/tag" + "github.com/awesee/leetcode/internal/test" + "github.com/awesee/leetcode/internal/update" + "github.com/awesee/leetcode/internal/version" ) func main() { diff --git a/problems/add-one-row-to-tree/add_one_row_to_tree.go b/problems/add-one-row-to-tree/add_one_row_to_tree.go index fc21be51b..332bbab67 100644 --- a/problems/add-one-row-to-tree/add_one_row_to_tree.go +++ b/problems/add-one-row-to-tree/add_one_row_to_tree.go @@ -1,6 +1,6 @@ package problem623 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // TreeNode - Definition for a binary tree node. type TreeNode = kit.TreeNode diff --git a/problems/add-one-row-to-tree/add_one_row_to_tree_test.go b/problems/add-one-row-to-tree/add_one_row_to_tree_test.go index 71d1f281d..ca8869b1f 100644 --- a/problems/add-one-row-to-tree/add_one_row_to_tree_test.go +++ b/problems/add-one-row-to-tree/add_one_row_to_tree_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/add-two-numbers-ii/add_two_numbers_ii.go b/problems/add-two-numbers-ii/add_two_numbers_ii.go index c38bcae14..e6c4cae64 100644 --- a/problems/add-two-numbers-ii/add_two_numbers_ii.go +++ b/problems/add-two-numbers-ii/add_two_numbers_ii.go @@ -1,6 +1,6 @@ package problem445 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // ListNode - Definition for singly-linked list. type ListNode = kit.ListNode diff --git a/problems/add-two-numbers-ii/add_two_numbers_ii_test.go b/problems/add-two-numbers-ii/add_two_numbers_ii_test.go index f0f49ac1d..3d09f2cda 100644 --- a/problems/add-two-numbers-ii/add_two_numbers_ii_test.go +++ b/problems/add-two-numbers-ii/add_two_numbers_ii_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/add-two-numbers/add_two_numbers.go b/problems/add-two-numbers/add_two_numbers.go index 77909af8d..2bd03f25e 100644 --- a/problems/add-two-numbers/add_two_numbers.go +++ b/problems/add-two-numbers/add_two_numbers.go @@ -1,6 +1,6 @@ package problem2 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // ListNode - Definition for singly-linked list. type ListNode = kit.ListNode diff --git a/problems/add-two-numbers/add_two_numbers_test.go b/problems/add-two-numbers/add_two_numbers_test.go index e60a3c521..435a43070 100644 --- a/problems/add-two-numbers/add_two_numbers_test.go +++ b/problems/add-two-numbers/add_two_numbers_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/balanced-binary-tree/balanced_binary_tree.go b/problems/balanced-binary-tree/balanced_binary_tree.go index 83750f1b4..7b1ccbb96 100644 --- a/problems/balanced-binary-tree/balanced_binary_tree.go +++ b/problems/balanced-binary-tree/balanced_binary_tree.go @@ -1,6 +1,6 @@ package problem110 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // TreeNode - Definition for a binary tree node. type TreeNode = kit.TreeNode diff --git a/problems/balanced-binary-tree/balanced_binary_tree_test.go b/problems/balanced-binary-tree/balanced_binary_tree_test.go index 459dd6205..c5df3012b 100644 --- a/problems/balanced-binary-tree/balanced_binary_tree_test.go +++ b/problems/balanced-binary-tree/balanced_binary_tree_test.go @@ -3,7 +3,7 @@ package problem110 import ( "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/construct-string-from-binary-tree/construct_string_from_binary_tree.go b/problems/construct-string-from-binary-tree/construct_string_from_binary_tree.go index 690042882..870bb6aad 100644 --- a/problems/construct-string-from-binary-tree/construct_string_from_binary_tree.go +++ b/problems/construct-string-from-binary-tree/construct_string_from_binary_tree.go @@ -3,7 +3,7 @@ package problem606 import ( "strconv" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) // TreeNode - Definition for a binary tree node. diff --git a/problems/construct-string-from-binary-tree/construct_string_from_binary_tree_test.go b/problems/construct-string-from-binary-tree/construct_string_from_binary_tree_test.go index 1cea179af..a91f07506 100644 --- a/problems/construct-string-from-binary-tree/construct_string_from_binary_tree_test.go +++ b/problems/construct-string-from-binary-tree/construct_string_from_binary_tree_test.go @@ -3,7 +3,7 @@ package problem606 import ( "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/convert-sorted-array-to-binary-search-tree/convert_sorted_array_to_binary_search_tree.go b/problems/convert-sorted-array-to-binary-search-tree/convert_sorted_array_to_binary_search_tree.go index a1b41e487..2db149324 100644 --- a/problems/convert-sorted-array-to-binary-search-tree/convert_sorted_array_to_binary_search_tree.go +++ b/problems/convert-sorted-array-to-binary-search-tree/convert_sorted_array_to_binary_search_tree.go @@ -1,6 +1,6 @@ package problem108 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // TreeNode - Definition for a binary tree node. type TreeNode = kit.TreeNode diff --git a/problems/convert-sorted-array-to-binary-search-tree/convert_sorted_array_to_binary_search_tree_test.go b/problems/convert-sorted-array-to-binary-search-tree/convert_sorted_array_to_binary_search_tree_test.go index 6f1116063..b9b685b0f 100644 --- a/problems/convert-sorted-array-to-binary-search-tree/convert_sorted_array_to_binary_search_tree_test.go +++ b/problems/convert-sorted-array-to-binary-search-tree/convert_sorted_array_to_binary_search_tree_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/cousins-in-binary-tree/cousins_in_binary_tree.go b/problems/cousins-in-binary-tree/cousins_in_binary_tree.go index b2ca1a3f7..20991940b 100644 --- a/problems/cousins-in-binary-tree/cousins_in_binary_tree.go +++ b/problems/cousins-in-binary-tree/cousins_in_binary_tree.go @@ -1,6 +1,6 @@ package problem993 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // TreeNode - Definition for a binary tree node. type TreeNode = kit.TreeNode diff --git a/problems/cousins-in-binary-tree/cousins_in_binary_tree_test.go b/problems/cousins-in-binary-tree/cousins_in_binary_tree_test.go index 3d28c3ff7..5b3a94ed9 100644 --- a/problems/cousins-in-binary-tree/cousins_in_binary_tree_test.go +++ b/problems/cousins-in-binary-tree/cousins_in_binary_tree_test.go @@ -3,7 +3,7 @@ package problem993 import ( "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/delete-node-in-a-linked-list/delete_node_in_a_linked_list.go b/problems/delete-node-in-a-linked-list/delete_node_in_a_linked_list.go index baf0a4d08..9f981e47c 100644 --- a/problems/delete-node-in-a-linked-list/delete_node_in_a_linked_list.go +++ b/problems/delete-node-in-a-linked-list/delete_node_in_a_linked_list.go @@ -1,6 +1,6 @@ package problem237 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // ListNode - Definition for singly-linked list. type ListNode = kit.ListNode diff --git a/problems/delete-node-in-a-linked-list/delete_node_in_a_linked_list_test.go b/problems/delete-node-in-a-linked-list/delete_node_in_a_linked_list_test.go index 66e611bf3..0508d497e 100644 --- a/problems/delete-node-in-a-linked-list/delete_node_in_a_linked_list_test.go +++ b/problems/delete-node-in-a-linked-list/delete_node_in_a_linked_list_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/intersection-of-two-arrays-ii/intersection_of_two_arrays_ii_test.go b/problems/intersection-of-two-arrays-ii/intersection_of_two_arrays_ii_test.go index a25703034..09e52d7a1 100644 --- a/problems/intersection-of-two-arrays-ii/intersection_of_two_arrays_ii_test.go +++ b/problems/intersection-of-two-arrays-ii/intersection_of_two_arrays_ii_test.go @@ -3,7 +3,7 @@ package problem350 import ( "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/intersection-of-two-linked-lists/intersection_of_two_linked_lists.go b/problems/intersection-of-two-linked-lists/intersection_of_two_linked_lists.go index 2d4fb87db..eb7ef2aba 100644 --- a/problems/intersection-of-two-linked-lists/intersection_of_two_linked_lists.go +++ b/problems/intersection-of-two-linked-lists/intersection_of_two_linked_lists.go @@ -1,6 +1,6 @@ package problem160 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // ListNode - Definition for singly-linked list. type ListNode = kit.ListNode diff --git a/problems/intersection-of-two-linked-lists/intersection_of_two_linked_lists_test.go b/problems/intersection-of-two-linked-lists/intersection_of_two_linked_lists_test.go index ff9e48259..b1f4b2d5b 100644 --- a/problems/intersection-of-two-linked-lists/intersection_of_two_linked_lists_test.go +++ b/problems/intersection-of-two-linked-lists/intersection_of_two_linked_lists_test.go @@ -3,7 +3,7 @@ package problem160 import ( "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/invert-binary-tree/invert_binary_tree.go b/problems/invert-binary-tree/invert_binary_tree.go index f0f256593..ae7bccdf6 100644 --- a/problems/invert-binary-tree/invert_binary_tree.go +++ b/problems/invert-binary-tree/invert_binary_tree.go @@ -1,6 +1,6 @@ package problem226 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // TreeNode - Definition for a binary tree node. type TreeNode = kit.TreeNode diff --git a/problems/invert-binary-tree/invert_binary_tree_test.go b/problems/invert-binary-tree/invert_binary_tree_test.go index 5250480b0..7a6a30719 100644 --- a/problems/invert-binary-tree/invert_binary_tree_test.go +++ b/problems/invert-binary-tree/invert_binary_tree_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/linked-list-cycle/linked_list_cycle.go b/problems/linked-list-cycle/linked_list_cycle.go index 883c6928b..cdc748858 100644 --- a/problems/linked-list-cycle/linked_list_cycle.go +++ b/problems/linked-list-cycle/linked_list_cycle.go @@ -1,6 +1,6 @@ package problem141 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // ListNode - Definition for singly-linked list. type ListNode = kit.ListNode diff --git a/problems/linked-list-cycle/linked_list_cycle_test.go b/problems/linked-list-cycle/linked_list_cycle_test.go index 12b1a01af..7581d1cd5 100644 --- a/problems/linked-list-cycle/linked_list_cycle_test.go +++ b/problems/linked-list-cycle/linked_list_cycle_test.go @@ -3,7 +3,7 @@ package problem141 import ( "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/maximum-depth-of-binary-tree/maximum_depth_of_binary_tree.go b/problems/maximum-depth-of-binary-tree/maximum_depth_of_binary_tree.go index 93d3f9c91..b415d42a2 100644 --- a/problems/maximum-depth-of-binary-tree/maximum_depth_of_binary_tree.go +++ b/problems/maximum-depth-of-binary-tree/maximum_depth_of_binary_tree.go @@ -1,6 +1,6 @@ package problem104 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // TreeNode - Definition for a binary tree node. type TreeNode = kit.TreeNode diff --git a/problems/maximum-depth-of-binary-tree/maximum_depth_of_binary_tree_test.go b/problems/maximum-depth-of-binary-tree/maximum_depth_of_binary_tree_test.go index ec8b137c6..ad32798aa 100644 --- a/problems/maximum-depth-of-binary-tree/maximum_depth_of_binary_tree_test.go +++ b/problems/maximum-depth-of-binary-tree/maximum_depth_of_binary_tree_test.go @@ -3,7 +3,7 @@ package problem104 import ( "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/merge-k-sorted-lists/merge_k_sorted_lists.go b/problems/merge-k-sorted-lists/merge_k_sorted_lists.go index 25d1dc230..e702a73d7 100644 --- a/problems/merge-k-sorted-lists/merge_k_sorted_lists.go +++ b/problems/merge-k-sorted-lists/merge_k_sorted_lists.go @@ -1,6 +1,6 @@ package problem23 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // ListNode - Definition for singly-linked list. type ListNode = kit.ListNode diff --git a/problems/merge-k-sorted-lists/merge_k_sorted_lists_test.go b/problems/merge-k-sorted-lists/merge_k_sorted_lists_test.go index 47f574d2b..ebf91ea91 100644 --- a/problems/merge-k-sorted-lists/merge_k_sorted_lists_test.go +++ b/problems/merge-k-sorted-lists/merge_k_sorted_lists_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/merge-two-binary-trees/merge_two_binary_trees.go b/problems/merge-two-binary-trees/merge_two_binary_trees.go index 0d74d4582..f82bf9106 100644 --- a/problems/merge-two-binary-trees/merge_two_binary_trees.go +++ b/problems/merge-two-binary-trees/merge_two_binary_trees.go @@ -1,6 +1,6 @@ package problem617 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // TreeNode - Definition for a binary tree node. type TreeNode = kit.TreeNode diff --git a/problems/merge-two-binary-trees/merge_two_binary_trees_test.go b/problems/merge-two-binary-trees/merge_two_binary_trees_test.go index c7795e8f4..9da149f2e 100644 --- a/problems/merge-two-binary-trees/merge_two_binary_trees_test.go +++ b/problems/merge-two-binary-trees/merge_two_binary_trees_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/merge-two-sorted-lists/merge_two_sorted_lists.go b/problems/merge-two-sorted-lists/merge_two_sorted_lists.go index c80a6c0b4..2701fa1ee 100644 --- a/problems/merge-two-sorted-lists/merge_two_sorted_lists.go +++ b/problems/merge-two-sorted-lists/merge_two_sorted_lists.go @@ -1,6 +1,6 @@ package problem21 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // ListNode - Definition for singly-linked list. type ListNode = kit.ListNode diff --git a/problems/merge-two-sorted-lists/merge_two_sorted_lists_test.go b/problems/merge-two-sorted-lists/merge_two_sorted_lists_test.go index 905fe5fd2..125d12f2f 100644 --- a/problems/merge-two-sorted-lists/merge_two_sorted_lists_test.go +++ b/problems/merge-two-sorted-lists/merge_two_sorted_lists_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/minimum-depth-of-binary-tree/minimum_depth_of_binary_tree.go b/problems/minimum-depth-of-binary-tree/minimum_depth_of_binary_tree.go index cb1c6f5f7..b1fd97022 100644 --- a/problems/minimum-depth-of-binary-tree/minimum_depth_of_binary_tree.go +++ b/problems/minimum-depth-of-binary-tree/minimum_depth_of_binary_tree.go @@ -1,6 +1,6 @@ package problem111 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // TreeNode - Definition for a binary tree node. type TreeNode = kit.TreeNode diff --git a/problems/minimum-depth-of-binary-tree/minimum_depth_of_binary_tree_test.go b/problems/minimum-depth-of-binary-tree/minimum_depth_of_binary_tree_test.go index 87367c423..9d7a07899 100644 --- a/problems/minimum-depth-of-binary-tree/minimum_depth_of_binary_tree_test.go +++ b/problems/minimum-depth-of-binary-tree/minimum_depth_of_binary_tree_test.go @@ -3,7 +3,7 @@ package problem111 import ( "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/palindrome-linked-list/palindrome_linked_list.go b/problems/palindrome-linked-list/palindrome_linked_list.go index ef82aa4e3..03d22883d 100644 --- a/problems/palindrome-linked-list/palindrome_linked_list.go +++ b/problems/palindrome-linked-list/palindrome_linked_list.go @@ -1,6 +1,6 @@ package problem234 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // ListNode - Definition for singly-linked list. type ListNode = kit.ListNode diff --git a/problems/palindrome-linked-list/palindrome_linked_list_test.go b/problems/palindrome-linked-list/palindrome_linked_list_test.go index baac89617..01e9ded68 100644 --- a/problems/palindrome-linked-list/palindrome_linked_list_test.go +++ b/problems/palindrome-linked-list/palindrome_linked_list_test.go @@ -3,7 +3,7 @@ package problem234 import ( "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/path-sum-iii/path_sum_iii.go b/problems/path-sum-iii/path_sum_iii.go index cdc1542d6..c096c6c56 100644 --- a/problems/path-sum-iii/path_sum_iii.go +++ b/problems/path-sum-iii/path_sum_iii.go @@ -1,6 +1,6 @@ package problem437 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // TreeNode - Definition for a binary tree node. type TreeNode = kit.TreeNode diff --git a/problems/path-sum-iii/path_sum_iii_test.go b/problems/path-sum-iii/path_sum_iii_test.go index 6a28bf338..63bfddee1 100644 --- a/problems/path-sum-iii/path_sum_iii_test.go +++ b/problems/path-sum-iii/path_sum_iii_test.go @@ -3,7 +3,7 @@ package problem437 import ( "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/path-sum/path_sum.go b/problems/path-sum/path_sum.go index 51d9ac9ab..a8e044bda 100644 --- a/problems/path-sum/path_sum.go +++ b/problems/path-sum/path_sum.go @@ -1,6 +1,6 @@ package problem112 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // TreeNode - Definition for a binary tree node. type TreeNode = kit.TreeNode diff --git a/problems/path-sum/path_sum_test.go b/problems/path-sum/path_sum_test.go index 095e9dcae..93325f6fd 100644 --- a/problems/path-sum/path_sum_test.go +++ b/problems/path-sum/path_sum_test.go @@ -3,7 +3,7 @@ package problem112 import ( "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/powerful-integers/powerful_integers_test.go b/problems/powerful-integers/powerful_integers_test.go index e1918818b..6fa8ef17c 100644 --- a/problems/powerful-integers/powerful_integers_test.go +++ b/problems/powerful-integers/powerful_integers_test.go @@ -3,7 +3,7 @@ package problem970 import ( "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/range-sum-of-bst/range_sum_of_bst.go b/problems/range-sum-of-bst/range_sum_of_bst.go index 20abf84b6..61d87593d 100644 --- a/problems/range-sum-of-bst/range_sum_of_bst.go +++ b/problems/range-sum-of-bst/range_sum_of_bst.go @@ -1,6 +1,6 @@ package problem938 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // TreeNode - Definition for a binary tree node. type TreeNode = kit.TreeNode diff --git a/problems/range-sum-of-bst/range_sum_of_bst_test.go b/problems/range-sum-of-bst/range_sum_of_bst_test.go index 4636b6814..86b8e1020 100644 --- a/problems/range-sum-of-bst/range_sum_of_bst_test.go +++ b/problems/range-sum-of-bst/range_sum_of_bst_test.go @@ -3,7 +3,7 @@ package problem938 import ( "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/remove-duplicates-from-sorted-list/remove_duplicates_from_sorted_list.go b/problems/remove-duplicates-from-sorted-list/remove_duplicates_from_sorted_list.go index b446d6218..938b18944 100644 --- a/problems/remove-duplicates-from-sorted-list/remove_duplicates_from_sorted_list.go +++ b/problems/remove-duplicates-from-sorted-list/remove_duplicates_from_sorted_list.go @@ -1,6 +1,6 @@ package problem83 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // ListNode - Definition for singly-linked list. type ListNode = kit.ListNode diff --git a/problems/remove-duplicates-from-sorted-list/remove_duplicates_from_sorted_list_test.go b/problems/remove-duplicates-from-sorted-list/remove_duplicates_from_sorted_list_test.go index 0bedfe976..8c040aedc 100644 --- a/problems/remove-duplicates-from-sorted-list/remove_duplicates_from_sorted_list_test.go +++ b/problems/remove-duplicates-from-sorted-list/remove_duplicates_from_sorted_list_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list.go b/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list.go index 360761d09..713467b36 100644 --- a/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list.go +++ b/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list.go @@ -1,6 +1,6 @@ package problem19 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // ListNode - Definition for singly-linked list. type ListNode = kit.ListNode diff --git a/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list_test.go b/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list_test.go index 3407d4d1a..f8dc2cff8 100644 --- a/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list_test.go +++ b/problems/remove-nth-node-from-end-of-list/remove_nth_node_from_end_of_list_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/reverse-linked-list/reverse_linked_list.go b/problems/reverse-linked-list/reverse_linked_list.go index b54463038..d46a6bf54 100644 --- a/problems/reverse-linked-list/reverse_linked_list.go +++ b/problems/reverse-linked-list/reverse_linked_list.go @@ -1,6 +1,6 @@ package problem206 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // ListNode - Definition for singly-linked list. type ListNode = kit.ListNode diff --git a/problems/reverse-linked-list/reverse_linked_list_test.go b/problems/reverse-linked-list/reverse_linked_list_test.go index 8bffc1a0f..47f5c2046 100644 --- a/problems/reverse-linked-list/reverse_linked_list_test.go +++ b/problems/reverse-linked-list/reverse_linked_list_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/same-tree/same_tree.go b/problems/same-tree/same_tree.go index 69c95902c..d5af0401b 100644 --- a/problems/same-tree/same_tree.go +++ b/problems/same-tree/same_tree.go @@ -1,6 +1,6 @@ package problem100 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // TreeNode - Definition for a binary tree node. type TreeNode = kit.TreeNode diff --git a/problems/same-tree/same_tree_test.go b/problems/same-tree/same_tree_test.go index 264348cd2..76493b9d1 100644 --- a/problems/same-tree/same_tree_test.go +++ b/problems/same-tree/same_tree_test.go @@ -3,7 +3,7 @@ package problem100 import ( "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/sum-of-root-to-leaf-binary-numbers/sum_of_root_to_leaf_binary_numbers.go b/problems/sum-of-root-to-leaf-binary-numbers/sum_of_root_to_leaf_binary_numbers.go index 50d5bf910..5ee19e766 100644 --- a/problems/sum-of-root-to-leaf-binary-numbers/sum_of_root_to_leaf_binary_numbers.go +++ b/problems/sum-of-root-to-leaf-binary-numbers/sum_of_root_to_leaf_binary_numbers.go @@ -1,6 +1,6 @@ package problem1022 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // TreeNode - Definition for a binary tree node. type TreeNode = kit.TreeNode diff --git a/problems/sum-of-root-to-leaf-binary-numbers/sum_of_root_to_leaf_binary_numbers_test.go b/problems/sum-of-root-to-leaf-binary-numbers/sum_of_root_to_leaf_binary_numbers_test.go index f1e9535c5..d75ed8f38 100644 --- a/problems/sum-of-root-to-leaf-binary-numbers/sum_of_root_to_leaf_binary_numbers_test.go +++ b/problems/sum-of-root-to-leaf-binary-numbers/sum_of_root_to_leaf_binary_numbers_test.go @@ -3,7 +3,7 @@ package problem1022 import ( "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/symmetric-tree/symmetric_tree.go b/problems/symmetric-tree/symmetric_tree.go index b8dca8cf1..1b4995c61 100644 --- a/problems/symmetric-tree/symmetric_tree.go +++ b/problems/symmetric-tree/symmetric_tree.go @@ -1,6 +1,6 @@ package problem101 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // TreeNode - Definition for a binary tree node. type TreeNode = kit.TreeNode diff --git a/problems/symmetric-tree/symmetric_tree_test.go b/problems/symmetric-tree/symmetric_tree_test.go index ea0d1a635..f84c9d137 100644 --- a/problems/symmetric-tree/symmetric_tree_test.go +++ b/problems/symmetric-tree/symmetric_tree_test.go @@ -3,7 +3,7 @@ package problem101 import ( "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { diff --git a/problems/to-lower-case/to_lower_case_test.go b/problems/to-lower-case/to_lower_case_test.go index c8973390e..6be8dcd93 100644 --- a/problems/to-lower-case/to_lower_case_test.go +++ b/problems/to-lower-case/to_lower_case_test.go @@ -4,10 +4,10 @@ import "testing" func TestToLowerCase(t *testing.T) { tests := map[string]string{ - "Hello": "hello", - "here": "here", - "LOVELY": "lovely", - "OpenSet": "openset", + "Hello": "hello", + "here": "here", + "LOVELY": "lovely", + "aweSee": "awesee", } for in, want := range tests { diff --git a/problems/unique-email-addresses/unique_email_addresses_test.go b/problems/unique-email-addresses/unique_email_addresses_test.go index 4b25e1d09..f9f3af6f2 100644 --- a/problems/unique-email-addresses/unique_email_addresses_test.go +++ b/problems/unique-email-addresses/unique_email_addresses_test.go @@ -14,7 +14,7 @@ func TestNumUniqueEmails(t *testing.T) { want: 2, }, { - in: []string{"sandy+wang@openset.wang", "openset.wang@openset.com", "openset+wang@openset.com"}, + in: []string{"awesee+wang@awesee.cn", "awesee.wang@awesee.cn", "aweSee+wang@awesee.cn"}, want: 3, }, } diff --git a/problems/univalued-binary-tree/univalued_binary_tree.go b/problems/univalued-binary-tree/univalued_binary_tree.go index 7fc4813a1..9a1d09899 100644 --- a/problems/univalued-binary-tree/univalued_binary_tree.go +++ b/problems/univalued-binary-tree/univalued_binary_tree.go @@ -1,6 +1,6 @@ package problem965 -import "github.com/openset/leetcode/internal/kit" +import "github.com/awesee/leetcode/internal/kit" // TreeNode - Definition for a binary tree node. type TreeNode = kit.TreeNode diff --git a/problems/univalued-binary-tree/univalued_binary_tree_test.go b/problems/univalued-binary-tree/univalued_binary_tree_test.go index e2948682c..77d80c2e6 100644 --- a/problems/univalued-binary-tree/univalued_binary_tree_test.go +++ b/problems/univalued-binary-tree/univalued_binary_tree_test.go @@ -3,7 +3,7 @@ package problem965 import ( "testing" - "github.com/openset/leetcode/internal/kit" + "github.com/awesee/leetcode/internal/kit" ) type testType struct { From 5942e516448480d1687ccc4d3380aef81a4c22a4 Mon Sep 17 00:00:00 2001 From: Shuo Date: Sat, 27 Nov 2021 18:32:48 +0800 Subject: [PATCH 140/145] A: 1.6.6 --- internal/version/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/version/version.go b/internal/version/version.go index 5964f69a4..87f26aefc 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -8,7 +8,7 @@ import ( "github.com/awesee/leetcode/internal/base" ) -const version = "1.6.5" +const version = "1.6.6" // CmdVersion - version.CmdVersion var CmdVersion = &base.Command{ From cb30580f4e086e837831650051e84df64bf7ace9 Mon Sep 17 00:00:00 2001 From: Shuo Date: Sat, 27 Nov 2021 21:22:53 +0800 Subject: [PATCH 141/145] A: new --- README.md | 118 ++++++++++-------- helper/README.md | 6 +- problems/1-bit-and-2-bit-characters/README.md | 6 +- problems/2-keys-keyboard/README.md | 6 +- problems/24-game/README.md | 6 +- problems/3sum/README.md | 6 +- problems/4-keys-keyboard/README.md | 6 +- .../README.md | 6 +- problems/account-balance/README.md | 6 +- problems/activity-participants/README.md | 6 +- .../README.md | 6 +- problems/ad-free-sessions/README.md | 6 +- problems/add-bold-tag-in-string/README.md | 6 +- .../add-minimum-number-of-rungs/README.md | 6 +- problems/add-one-row-to-tree/README.md | 6 +- .../add-to-array-form-of-integer/README.md | 6 +- .../README.md | 6 +- .../adding-two-negabinary-numbers/README.md | 6 +- problems/advantage-shuffle/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/alien-dictionary/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../all-possible-full-binary-trees/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/alphabet-board-path/README.md | 6 +- .../angle-between-hands-of-a-clock/README.md | 6 +- .../apply-discount-every-n-orders/README.md | 6 +- .../README.md | 6 +- problems/arithmetic-slices/README.md | 7 +- problems/arithmetic-subarrays/README.md | 10 +- problems/arranging-coins/README.md | 6 +- problems/array-nesting/README.md | 6 +- problems/array-transformation/README.md | 6 +- .../README.md | 6 +- problems/article-views-i/README.md | 6 +- problems/article-views-ii/README.md | 6 +- .../as-far-from-land-as-possible/README.md | 6 +- problems/assign-cookies/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../mysql_schemas.sql | 26 ++-- problems/average-selling-price/README.md | 6 +- .../README.md | 6 +- problems/average-waiting-time/README.md | 9 +- problems/avoid-flood-in-the-city/README.md | 6 +- problems/backspace-string-compare/README.md | 6 +- .../balance-a-binary-search-tree/README.md | 6 +- problems/balanced-binary-tree/README.md | 6 +- problems/bank-account-summary-ii/README.md | 6 +- problems/bank-account-summary/README.md | 6 +- problems/beautiful-arrangement/README.md | 8 +- problems/beautiful-array/README.md | 6 +- problems/before-and-after-puzzle/README.md | 6 +- .../README.md | 6 +- problems/best-sightseeing-pair/README.md | 6 +- .../best-team-with-no-conflicts/README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../biggest-window-between-visits/README.md | 6 +- .../binary-prefix-divisible-by-5/README.md | 6 +- .../binary-search-tree-iterator-ii/README.md | 9 +- problems/binary-search/README.md | 6 +- .../README.md | 6 +- problems/binary-tree-coloring-game/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/binary-tree-paths/README.md | 6 +- .../README.md | 6 +- problems/binary-watch/README.md | 6 +- problems/bitwise-ors-of-subarrays/README.md | 8 +- problems/bomb-enemy/README.md | 6 +- problems/brace-expansion-ii/README.md | 16 +-- problems/brace-expansion/README.md | 6 +- problems/break-a-palindrome/README.md | 6 +- problems/brick-wall/README.md | 6 +- problems/bricks-falling-when-hit/README.md | 6 +- .../brightest-position-on-street/README.md | 6 +- .../build-array-from-permutation/README.md | 6 +- .../README.md | 6 +- .../README.md | 12 +- problems/building-boxes/README.md | 8 +- problems/building-h2o/README.md | 6 +- .../buildings-with-an-ocean-view/README.md | 6 +- problems/bulb-switcher-iv/README.md | 6 +- problems/bus-routes/README.md | 6 +- .../README.md | 6 +- problems/calculate-special-bonus/README.md | 6 +- .../can-convert-string-in-k-moves/README.md | 6 +- .../README.md | 6 +- .../README.md | 11 +- problems/can-place-flowers/README.md | 8 +- .../README.md | 6 +- .../README.md | 14 ++- problems/car-fleet-ii/README.md | 13 +- problems/card-flipping-game/README.md | 6 +- problems/cat-and-mouse-ii/README.md | 6 +- .../README.md | 6 +- problems/chalkboard-xor-game/README.md | 10 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../check-if-it-is-a-good-array/README.md | 6 +- problems/check-if-move-is-legal/README.md | 6 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 9 +- .../README.md | 11 +- problems/cherry-pickup-ii/README.md | 6 +- problems/cinema-seat-allocation/README.md | 10 +- .../README.md | 8 +- problems/circular-array-loop/README.md | 6 +- .../classes-more-than-5-students/README.md | 70 +++++++---- .../mysql_schemas.sql | 22 ++-- problems/climbing-stairs/README.md | 8 +- problems/clone-graph/README.md | 10 +- .../README.md | 6 +- problems/closest-dessert-cost/README.md | 6 +- .../closest-leaf-in-a-binary-tree/README.md | 6 +- problems/closest-room/README.md | 6 +- problems/closest-subsequence-sum/README.md | 12 +- problems/clumsy-factorial/README.md | 6 +- problems/coin-path/README.md | 6 +- problems/coloring-a-border/README.md | 6 +- problems/combination-sum-iii/README.md | 6 +- problems/combinations/README.md | 6 +- problems/combine-two-tables/README.md | 6 +- .../README.md | 6 +- problems/compare-version-numbers/README.md | 6 +- .../complex-number-multiplication/README.md | 6 +- problems/concatenation-of-array/README.md | 6 +- .../README.md | 6 +- problems/confirmation-rate/README.md | 6 +- problems/confusing-number/README.md | 6 +- problems/consecutive-numbers-sum/README.md | 6 +- problems/consecutive-numbers/README.md | 8 +- .../consecutive-numbers/mysql_schemas.sql | 16 +-- .../constrained-subsequence-sum/README.md | 10 +- .../README.md | 8 +- .../construct-k-palindrome-strings/README.md | 8 +- problems/construct-quad-tree/README.md | 6 +- .../README.md | 14 +-- .../README.md | 6 +- .../README.md | 6 +- problems/contain-virus/README.md | 6 +- problems/contains-duplicate-iii/README.md | 10 +- problems/contains-duplicate/README.md | 6 +- .../convert-1d-array-into-2d-array/README.md | 6 +- .../convert-bst-to-greater-tree/README.md | 6 +- problems/convert-date-format/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/convert-to-base-2/README.md | 6 +- problems/convex-polygon/README.md | 6 +- .../README.md | 6 +- problems/correct-a-binary-tree/README.md | 12 +- problems/count-all-possible-routes/README.md | 24 ++-- problems/count-apples-and-oranges/README.md | 6 +- problems/count-good-meals/README.md | 10 +- problems/count-good-numbers/README.md | 6 +- problems/count-good-triplets/README.md | 6 +- .../count-items-matching-a-rule/README.md | 6 +- problems/count-largest-group/README.md | 6 +- .../README.md | 6 +- .../count-nice-pairs-in-an-array/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 10 +- .../README.md | 6 +- .../count-number-of-nice-subarrays/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../count-of-matches-in-tournament/README.md | 6 +- problems/count-pairs-in-two-arrays/README.md | 6 +- .../README.md | 6 +- problems/count-pairs-of-nodes/README.md | 8 +- .../count-pairs-with-xor-in-a-range/README.md | 6 +- problems/count-salary-categories/README.md | 6 +- .../count-servers-that-communicate/README.md | 10 +- problems/count-sorted-vowel-strings/README.md | 6 +- problems/count-special-quadruplets/README.md | 6 +- problems/count-square-sum-triples/README.md | 6 +- problems/count-sub-islands/README.md | 6 +- .../README.md | 6 +- .../count-submatrices-with-all-ones/README.md | 71 ++++------- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- .../count-the-number-of-experiments/README.md | 6 +- .../README.md | 8 +- problems/count-unhappy-friends/README.md | 6 +- .../README.md | 6 +- problems/count-vowels-permutation/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/counting-elements/README.md | 6 +- .../README.md | 6 +- problems/course-schedule-ii/README.md | 7 +- problems/course-schedule-iii/README.md | 8 +- problems/course-schedule-iv/README.md | 6 +- problems/cracking-the-safe/README.md | 6 +- problems/crawler-log-folder/README.md | 6 +- problems/create-maximum-number/README.md | 6 +- .../README.md | 6 +- problems/customer-order-frequency/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/customers-who-never-order/README.md | 6 +- problems/cutting-ribbons/README.md | 10 +- problems/cyclically-rotating-a-grid/README.md | 6 +- problems/daily-leads-and-partners/README.md | 6 +- problems/daily-temperatures/README.md | 9 +- problems/day-of-the-week/README.md | 6 +- .../decode-the-slanted-ciphertext/README.md | 6 +- problems/decode-ways-ii/README.md | 7 +- problems/decode-xored-array/README.md | 8 +- problems/decode-xored-permutation/README.md | 6 +- problems/decoded-string-at-index/README.md | 6 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- problems/defanging-an-ip-address/README.md | 6 +- problems/defuse-the-bomb/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- .../delete-node-in-a-linked-list/README.md | 6 +- .../delete-nodes-and-return-forest/README.md | 6 +- problems/delete-tree-nodes/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/describe-the-painting/README.md | 6 +- .../design-a-file-sharing-system/README.md | 13 +- problems/design-a-leaderboard/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- problems/design-an-ordered-stream/README.md | 6 +- .../design-authentication-manager/README.md | 6 +- .../design-bounded-blocking-queue/README.md | 6 +- problems/design-browser-history/README.md | 12 +- problems/design-circular-deque/README.md | 6 +- problems/design-circular-queue/README.md | 6 +- .../README.md | 6 +- .../design-front-middle-back-queue/README.md | 14 +-- problems/design-hit-counter/README.md | 10 +- .../design-in-memory-file-system/README.md | 10 +- problems/design-log-storage-system/README.md | 6 +- .../design-most-recently-used-queue/README.md | 13 +- problems/design-movie-rental-system/README.md | 6 +- problems/design-parking-system/README.md | 8 +- problems/design-phone-directory/README.md | 6 +- .../README.md | 6 +- problems/design-skiplist/README.md | 13 +- problems/design-underground-system/README.md | 6 +- problems/destination-city/README.md | 6 +- problems/detect-capital/README.md | 6 +- problems/detect-cycles-in-2d-grid/README.md | 6 +- .../README.md | 9 +- problems/detect-squares/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 11 +- .../README.md | 6 +- problems/diagonal-traverse-ii/README.md | 6 +- problems/diagonal-traverse/README.md | 9 +- problems/diameter-of-n-ary-tree/README.md | 6 +- problems/dice-roll-simulation/README.md | 9 +- problems/diet-plan-performance/README.md | 6 +- .../README.md | 6 +- problems/dinner-plate-stacks/README.md | 8 +- problems/distance-between-bus-stops/README.md | 6 +- problems/distant-barcodes/README.md | 6 +- problems/distinct-echo-substrings/README.md | 6 +- .../README.md | 6 +- problems/distinct-subsequences/README.md | 11 +- .../distribute-candies-to-people/README.md | 6 +- problems/distribute-candies/README.md | 6 +- .../distribute-coins-in-binary-tree/README.md | 6 +- .../distribute-repeating-integers/README.md | 6 +- .../README.md | 11 +- .../README.md | 8 +- problems/domino-and-tromino-tiling/README.md | 6 +- .../README.md | 8 +- problems/dota2-senate/README.md | 8 +- .../README.md | 14 +++ .../mysql_schemas.sql | 10 ++ problems/dungeon-game/README.md | 6 +- problems/duplicate-zeros/README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- problems/employee-bonus/README.md | 6 +- problems/employee-bonus/mysql_schemas.sql | 16 +-- .../README.md | 6 +- .../README.md | 6 +- problems/encode-and-decode-tinyurl/README.md | 8 +- problems/encode-number/README.md | 8 +- .../README.md | 6 +- problems/erect-the-fence-ii/README.md | 6 +- problems/erect-the-fence/README.md | 6 +- problems/escape-a-large-maze/README.md | 6 +- problems/escape-the-ghosts/README.md | 12 +- .../README.md | 6 +- .../README.md | 6 +- problems/even-odd-tree/README.md | 6 +- problems/exchange-seats/README.md | 6 +- .../exclusive-time-of-functions/README.md | 6 +- problems/expression-add-operators/README.md | 6 +- problems/expressive-words/README.md | 6 +- problems/factor-combinations/README.md | 6 +- problems/factorial-trailing-zeroes/README.md | 19 +-- problems/falling-squares/README.md | 8 +- problems/fancy-sequence/README.md | 8 +- problems/faulty-sensor/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/find-a-peak-element-ii/README.md | 6 +- .../README.md | 10 +- .../find-all-anagrams-in-a-string/README.md | 6 +- problems/find-all-good-strings/README.md | 6 +- .../find-all-groups-of-farmland/README.md | 6 +- .../README.md | 6 +- problems/find-all-the-lonely-nodes/README.md | 10 +- .../find-array-given-subset-sums/README.md | 6 +- .../find-bottom-left-tree-value/README.md | 6 +- problems/find-center-of-star-graph/README.md | 6 +- problems/find-customer-referee/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../find-distance-in-a-binary-tree/README.md | 8 +- problems/find-duplicate-subtrees/README.md | 7 +- .../README.md | 6 +- problems/find-eventual-safe-states/README.md | 6 +- problems/find-followers-count/README.md | 6 +- .../README.md | 6 +- .../find-if-path-exists-in-graph/README.md | 8 +- problems/find-in-mountain-array/README.md | 41 +++--- problems/find-interview-candidates/README.md | 6 +- .../find-k-pairs-with-smallest-sums/README.md | 6 +- .../README.md | 24 ++-- .../README.md | 6 +- .../README.md | 6 +- .../find-latest-group-of-size-m/README.md | 19 +-- .../find-longest-awesome-substring/README.md | 10 +- .../find-lucky-integer-in-an-array/README.md | 6 +- .../README.md | 6 +- .../mysql_schemas.sql | 10 +- .../README.md | 6 +- problems/find-missing-observations/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 11 +- .../README.md | 6 +- .../README.md | 6 +- problems/find-root-of-n-ary-tree/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/find-the-celebrity/README.md | 8 +- .../find-the-closest-palindrome/README.md | 9 +- .../README.md | 6 +- problems/find-the-difference/README.md | 8 +- .../README.md | 6 +- problems/find-the-highest-altitude/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../find-the-middle-index-in-array/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/find-the-missing-ids/README.md | 11 +- .../README.md | 12 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 10 +- .../README.md | 8 +- .../README.md | 6 +- problems/find-the-team-size/README.md | 6 +- problems/find-the-town-judge/README.md | 6 +- .../README.md | 16 +-- .../README.md | 6 +- .../README.md | 6 +- problems/find-unique-binary-string/README.md | 6 +- .../find-users-with-valid-e-mails/README.md | 6 +- .../README.md | 11 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/finding-mk-average/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/first-bad-version/README.md | 6 +- .../README.md | 6 +- problems/first-missing-positive/README.md | 6 +- problems/first-unique-number/README.md | 6 +- problems/fix-names-in-a-table/README.md | 6 +- problems/fix-product-name-format/README.md | 6 +- .../README.md | 69 +++++----- .../flatten-nested-list-iterator/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/flip-game/README.md | 6 +- problems/flood-fill/README.md | 8 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../mysql_schemas.sql | 12 +- .../README.md | 6 +- .../friends-of-appropriate-ages/README.md | 6 +- problems/frog-jump/README.md | 9 +- .../frog-position-after-t-seconds/README.md | 6 +- problems/fruit-into-baskets/README.md | 6 +- .../furthest-building-you-can-reach/README.md | 8 +- problems/game-of-nim/README.md | 6 +- problems/game-play-analysis-iv/README.md | 6 +- problems/game-play-analysis-v/README.md | 6 +- problems/gas-station/README.md | 8 +- problems/gcd-sort-of-an-array/README.md | 6 +- problems/generalized-abbreviation/README.md | 8 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../mysql_schemas.sql | 12 +- .../get-maximum-in-generated-array/README.md | 6 +- problems/get-the-maximum-score/README.md | 21 ++-- .../global-and-local-inversions/README.md | 6 +- problems/goal-parser-interpretation/README.md | 6 +- problems/goat-latin/README.md | 6 +- problems/grand-slam-titles/README.md | 6 +- .../README.md | 6 +- problems/graph-valid-tree/README.md | 6 +- .../README.md | 9 +- .../greatest-sum-divisible-by-three/README.md | 8 +- problems/grid-game/README.md | 6 +- problems/group-anagrams/README.md | 6 +- .../README.md | 6 +- problems/group-shifted-strings/README.md | 6 +- .../README.md | 6 +- problems/grumpy-bookstore-owner/README.md | 6 +- .../README.md | 6 +- problems/guess-the-word/README.md | 8 +- problems/h-index-ii/README.md | 6 +- problems/h-index/README.md | 8 +- problems/hand-of-straights/README.md | 8 +- problems/heaters/README.md | 7 +- problems/height-checker/README.md | 6 +- .../highest-grade-for-each-student/README.md | 6 +- problems/hopper-company-queries-i/README.md | 6 +- problems/hopper-company-queries-ii/README.md | 6 +- problems/hopper-company-queries-iii/README.md | 11 +- problems/house-robber-ii/README.md | 6 +- problems/house-robber-iii/README.md | 6 +- .../README.md | 8 +- problems/human-traffic-of-stadium/README.md | 17 +-- .../mysql_schemas.sql | 20 +-- problems/image-smoother/README.md | 6 +- problems/implement-magic-dictionary/README.md | 12 +- .../implement-queue-using-stacks/README.md | 6 +- .../implement-trie-ii-prefix-tree/README.md | 6 +- .../increasing-order-search-tree/README.md | 6 +- .../increasing-triplet-subsequence/README.md | 6 +- problems/incremental-memory-leak/README.md | 6 +- .../inorder-successor-in-bst-ii/README.md | 6 +- problems/inorder-successor-in-bst/README.md | 6 +- problems/insert-interval/README.md | 6 +- problems/insertion-sort-list/README.md | 6 +- problems/integer-break/README.md | 9 +- .../README.md | 6 +- problems/invalid-transactions/README.md | 6 +- problems/invalid-tweets/README.md | 6 +- problems/investments-in-2016/README.md | 6 +- problems/ip-to-cidr/README.md | 8 +- problems/is-subsequence/README.md | 6 +- problems/iterator-for-combination/README.md | 6 +- problems/jump-game-ii/README.md | 10 +- problems/jump-game-vi/README.md | 14 ++- problems/jump-game-vii/README.md | 6 +- .../k-concatenation-maximum-sum/README.md | 6 +- problems/k-inverse-pairs-array/README.md | 6 +- problems/keys-and-rooms/README.md | 9 +- .../README.md | 6 +- problems/knight-dialer/README.md | 6 +- .../README.md | 6 +- problems/koko-eating-bananas/README.md | 6 +- .../kth-ancestor-of-a-tree-node/README.md | 10 +- .../kth-distinct-string-in-an-array/README.md | 6 +- .../kth-missing-positive-number/README.md | 6 +- .../kth-smallest-element-in-a-bst/README.md | 10 +- problems/kth-smallest-instructions/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/kth-smallest-subarray-sum/README.md | 6 +- problems/largest-bst-subtree/README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- problems/largest-divisible-subset/README.md | 6 +- problems/largest-magic-square/README.md | 9 +- .../largest-merge-of-two-strings/README.md | 8 +- .../README.md | 6 +- problems/largest-number/README.md | 8 +- .../largest-odd-number-in-string/README.md | 6 +- problems/largest-palindrome-product/README.md | 6 +- .../largest-rectangle-in-histogram/README.md | 6 +- problems/largest-subarray-length-k/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../largest-time-for-given-digits/README.md | 6 +- problems/largest-unique-number/README.md | 6 +- problems/largest-values-from-labels/README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- .../last-person-to-fit-in-the-bus/README.md | 6 +- problems/last-stone-weight-ii/README.md | 6 +- problems/last-stone-weight/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/league-statistics/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/leetcodify-similar-friends/README.md | 6 +- problems/leetflex-banned-accounts/README.md | 6 +- problems/letter-case-permutation/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/lfu-cache/README.md | 6 +- problems/linked-list-cycle-ii/README.md | 6 +- problems/linked-list-cycle/README.md | 6 +- problems/linked-list-in-binary-tree/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- problems/longest-absolute-file-path/README.md | 6 +- .../README.md | 10 +- problems/longest-common-subpath/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/longest-happy-prefix/README.md | 6 +- problems/longest-happy-string/README.md | 8 +- .../README.md | 8 +- .../README.md | 6 +- problems/longest-nice-substring/README.md | 8 +- .../README.md | 6 +- .../longest-palindromic-substring/README.md | 6 +- .../README.md | 6 +- .../longest-repeating-substring/README.md | 6 +- problems/longest-string-chain/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- problems/longest-turbulent-subarray/README.md | 6 +- .../longest-uncommon-subsequence-i/README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- problems/longest-word-in-dictionary/README.md | 6 +- .../longest-word-with-all-prefixes/README.md | 6 +- .../README.md | 6 +- problems/low-quality-problems/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 14 +-- .../README.md | 11 +- problems/lucky-numbers-in-a-matrix/README.md | 6 +- problems/magical-string/README.md | 6 +- .../README.md | 16 +-- problems/make-sum-divisible-by-p/README.md | 9 +- problems/make-the-string-great/README.md | 10 +- .../README.md | 8 +- problems/making-file-names-unique/README.md | 6 +- problems/map-of-highest-peak/README.md | 8 +- problems/market-analysis-i/README.md | 6 +- problems/market-analysis-i/mysql_schemas.sql | 4 +- problems/market-analysis-ii/README.md | 6 +- problems/market-analysis-ii/mysql_schemas.sql | 4 +- .../masking-personal-information/README.md | 6 +- problems/matrix-diagonal-sum/README.md | 6 +- problems/max-area-of-island/README.md | 9 +- problems/max-chunks-to-make-sorted/README.md | 6 +- problems/max-number-of-k-sum-pairs/README.md | 10 +- problems/max-stack/README.md | 6 +- .../README.md | 6 +- problems/max-value-of-equation/README.md | 13 +- problems/maximal-network-rank/README.md | 6 +- problems/maximal-rectangle/README.md | 8 +- .../README.md | 6 +- problems/maximize-grid-happiness/README.md | 8 +- .../README.md | 11 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- .../maximum-ascending-subarray-sum/README.md | 6 +- problems/maximum-average-pass-ratio/README.md | 8 +- problems/maximum-average-subarray-i/README.md | 6 +- .../maximum-average-subarray-ii/README.md | 6 +- problems/maximum-average-subtree/README.md | 6 +- .../README.md | 8 +- problems/maximum-binary-tree/README.md | 6 +- problems/maximum-building-height/README.md | 6 +- .../README.md | 8 +- .../maximum-compatibility-score-sum/README.md | 6 +- .../maximum-depth-of-n-ary-tree/README.md | 7 +- .../README.md | 6 +- .../README.md | 6 +- problems/maximum-distance-in-arrays/README.md | 6 +- problems/maximum-earnings-from-taxi/README.md | 6 +- .../README.md | 6 +- problems/maximum-equal-frequency/README.md | 6 +- problems/maximum-erasure-value/README.md | 6 +- .../README.md | 6 +- problems/maximum-gap/README.md | 6 +- .../README.md | 6 +- .../README.md | 9 +- problems/maximum-ice-cream-bars/README.md | 6 +- .../README.md | 8 +- .../maximum-length-of-pair-chain/README.md | 8 +- .../README.md | 8 +- problems/maximum-matrix-sum/README.md | 6 +- .../README.md | 11 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/maximum-number-of-balloons/README.md | 6 +- .../README.md | 6 +- .../README.md | 24 ++-- .../README.md | 6 +- .../README.md | 8 +- .../maximum-number-of-eaten-apples/README.md | 6 +- .../README.md | 11 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/maximum-number-of-ones/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../maximum-path-quality-of-a-graph/README.md | 6 +- .../maximum-performance-of-a-team/README.md | 6 +- .../README.md | 6 +- problems/maximum-population-year/README.md | 6 +- .../README.md | 6 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../maximum-repeating-substring/README.md | 9 +- .../README.md | 6 +- .../README.md | 10 +- .../README.md | 8 +- .../README.md | 8 +- .../README.md | 11 +- .../README.md | 8 +- .../README.md | 6 +- .../maximum-students-taking-exam/README.md | 6 +- .../maximum-subarray-min-product/README.md | 6 +- .../README.md | 9 +- .../README.md | 6 +- .../maximum-sum-circular-subarray/README.md | 6 +- .../README.md | 10 +- .../maximum-transaction-each-day/README.md | 6 +- problems/maximum-units-on-a-truck/README.md | 6 +- problems/maximum-vacation-days/README.md | 6 +- .../maximum-value-after-insertion/README.md | 6 +- .../README.md | 6 +- problems/maximum-xor-for-each-query/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- problems/median-employee-salary/README.md | 6 +- .../median-employee-salary/mysql_schemas.sql | 36 +++--- .../merge-bsts-to-create-single-bst/README.md | 6 +- .../merge-in-between-linked-lists/README.md | 6 +- problems/merge-intervals/README.md | 6 +- problems/merge-strings-alternately/README.md | 9 +- .../README.md | 6 +- problems/merge-two-binary-trees/README.md | 6 +- problems/merge-two-sorted-lists/README.md | 20 +-- problems/min-cost-climbing-stairs/README.md | 23 ++-- .../min-cost-to-connect-all-points/README.md | 8 +- problems/min-stack/README.md | 8 +- problems/minesweeper/README.md | 6 +- .../minimize-deviation-in-array/README.md | 10 +- .../README.md | 6 +- problems/minimize-malware-spread/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../minimum-absolute-sum-difference/README.md | 6 +- .../README.md | 14 +-- .../README.md | 6 +- problems/minimum-area-rectangle-ii/README.md | 8 +- problems/minimum-area-rectangle/README.md | 6 +- .../README.md | 6 +- problems/minimum-cost-for-tickets/README.md | 6 +- .../README.md | 6 +- .../minimum-cost-to-connect-sticks/README.md | 8 +- .../README.md | 10 +- .../minimum-cost-to-cut-a-stick/README.md | 14 +-- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../minimum-depth-of-binary-tree/README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- problems/minimum-factorization/README.md | 8 +- .../minimum-falling-path-sum-ii/README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- problems/minimum-height-trees/README.md | 6 +- problems/minimum-incompatibility/README.md | 6 +- .../minimum-index-sum-of-two-lists/README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 11 +- .../README.md | 6 +- .../minimum-jumps-to-reach-home/README.md | 6 +- .../README.md | 6 +- .../minimum-limit-of-balls-in-a-bag/README.md | 9 +- .../minimum-moves-to-convert-string/README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 10 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 12 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 15 +-- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 14 +-- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 12 +- .../README.md | 6 +- problems/minimum-sideway-jumps/README.md | 11 +- problems/minimum-size-subarray-sum/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../minimum-speed-to-arrive-on-time/README.md | 6 +- .../README.md | 8 +- .../README.md | 15 ++- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 20 +-- problems/minimum-window-substring/README.md | 7 +- .../minimum-xor-sum-of-two-arrays/README.md | 6 +- problems/mirror-reflection/README.md | 8 +- .../missing-element-in-sorted-array/README.md | 6 +- .../README.md | 6 +- problems/missing-number/README.md | 6 +- problems/monthly-transactions-i/README.md | 6 +- .../monthly-transactions-i/mysql_schemas.sql | 2 +- .../README.md | 6 +- problems/most-profit-assigning-work/README.md | 6 +- .../README.md | 6 +- .../README.md | 10 +- .../move-sub-tree-of-n-ary-tree/README.md | 9 +- problems/movie-rating/README.md | 6 +- .../moving-average-from-data-stream/README.md | 6 +- .../README.md | 6 +- .../moving-stones-until-consecutive/README.md | 8 +- problems/multiply-strings/README.md | 6 +- problems/my-calendar-ii/README.md | 6 +- .../README.md | 6 +- .../n-ary-tree-postorder-traversal/README.md | 6 +- .../n-ary-tree-preorder-traversal/README.md | 6 +- problems/n-th-tribonacci-number/README.md | 6 +- .../README.md | 6 +- problems/nested-list-weight-sum/README.md | 8 +- problems/new-21-game/README.md | 8 +- problems/next-closest-time/README.md | 6 +- problems/next-greater-element-i/README.md | 6 +- problems/next-greater-element-ii/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/nim-game/README.md | 8 +- .../README.md | 6 +- problems/not-boring-movies/README.md | 6 +- problems/nth-digit/README.md | 6 +- problems/nth-magical-number/README.md | 6 +- problems/number-complement/README.md | 6 +- .../README.md | 6 +- problems/number-of-boomerangs/README.md | 6 +- .../README.md | 6 +- problems/number-of-closed-islands/README.md | 8 +- .../number-of-comments-per-post/README.md | 6 +- .../README.md | 6 +- problems/number-of-days-in-a-month/README.md | 6 +- .../README.md | 10 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../number-of-good-leaf-nodes-pairs/README.md | 6 +- problems/number-of-good-pairs/README.md | 7 +- .../README.md | 6 +- problems/number-of-islands/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../number-of-orders-in-the-backlog/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../number-of-paths-with-max-score/README.md | 6 +- problems/number-of-recent-calls/README.md | 6 +- .../README.md | 6 +- .../README.md | 10 +- .../README.md | 6 +- .../number-of-ships-in-a-rectangle/README.md | 6 +- .../README.md | 6 +- problems/number-of-squareful-arrays/README.md | 8 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 11 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 10 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../number-of-wonderful-substrings/README.md | 6 +- .../README.md | 6 +- problems/odd-even-linked-list/README.md | 6 +- problems/one-edit-distance/README.md | 6 +- .../README.md | 6 +- problems/online-stock-span/README.md | 6 +- problems/operations-on-tree/README.md | 6 +- problems/optimal-division/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/out-of-boundary-paths/README.md | 6 +- problems/output-contest-matches/README.md | 8 +- .../pacific-atlantic-water-flow/README.md | 8 +- problems/page-recommendations-ii/README.md | 6 +- problems/page-recommendations/README.md | 6 +- problems/paint-house-ii/README.md | 6 +- problems/paint-house/README.md | 6 +- .../README.md | 6 +- problems/palindrome-pairs/README.md | 8 +- .../palindrome-partitioning-iii/README.md | 9 +- problems/palindrome-partitioning-iv/README.md | 6 +- problems/palindrome-permutation/README.md | 8 +- problems/palindromic-substrings/README.md | 6 +- problems/parallel-courses-iii/README.md | 6 +- problems/parallel-courses/README.md | 6 +- .../parsing-a-boolean-expression/README.md | 8 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- problems/pascals-triangle/README.md | 6 +- problems/path-crossing/README.md | 6 +- .../README.md | 8 +- problems/path-sum-iv/README.md | 8 +- problems/path-with-maximum-gold/README.md | 6 +- .../path-with-maximum-minimum-value/README.md | 13 +- .../path-with-maximum-probability/README.md | 11 +- problems/path-with-minimum-effort/README.md | 6 +- .../README.md | 28 +++++ problems/patients-with-a-condition/README.md | 6 +- problems/peeking-iterator/README.md | 16 +-- .../README.md | 6 +- .../README.md | 9 +- problems/perfect-rectangle/README.md | 6 +- problems/perfect-squares/README.md | 6 +- problems/perform-string-shifts/README.md | 6 +- problems/permutation-in-string/README.md | 6 +- problems/permutations-ii/README.md | 6 +- problems/plates-between-candles/README.md | 6 +- problems/power-of-four/README.md | 8 +- problems/power-of-two/README.md | 8 +- problems/powx-n/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- problems/print-binary-tree/README.md | 6 +- .../README.md | 10 +- problems/print-words-vertically/README.md | 6 +- problems/print-zero-even-odd/README.md | 6 +- .../README.md | 19 ++- .../README.md | 12 +- .../process-tasks-using-servers/README.md | 6 +- .../product-of-the-last-k-numbers/README.md | 10 +- .../README.md | 6 +- .../product-price-at-a-given-date/README.md | 6 +- .../products-price-for-each-store/README.md | 6 +- .../products-worth-over-invoices/README.md | 6 +- problems/profitable-schemes/README.md | 6 +- problems/project-employees-i/README.md | 9 +- problems/project-employees-ii/README.md | 6 +- .../README.md | 6 +- problems/push-dominoes/README.md | 6 +- .../put-boxes-into-the-warehouse-i/README.md | 11 +- .../put-boxes-into-the-warehouse-ii/README.md | 11 +- .../queens-that-can-attack-the-king/README.md | 6 +- .../README.md | 6 +- .../queries-quality-and-percentage/README.md | 6 +- .../queue-reconstruction-by-height/README.md | 8 +- problems/random-flip-matrix/README.md | 8 +- .../README.md | 6 +- problems/range-addition-ii/README.md | 6 +- problems/range-addition/README.md | 6 +- problems/range-frequency-queries/README.md | 79 ++++++++++++ problems/range-module/README.md | 6 +- problems/range-sum-of-bst/README.md | 6 +- .../README.md | 6 +- problems/range-sum-query-immutable/README.md | 8 +- problems/rank-teams-by-votes/README.md | 6 +- problems/rank-transform-of-a-matrix/README.md | 12 +- .../README.md | 6 +- problems/rearrange-products-table/README.md | 9 +- .../rearrange-spaces-between-words/README.md | 9 +- .../README.md | 11 +- problems/reconstruct-itinerary/README.md | 11 +- .../README.md | 6 +- problems/rectangle-area/README.md | 8 +- .../recyclable-and-low-fat-products/README.md | 6 +- .../README.md | 6 +- .../reduce-array-size-to-the-half/README.md | 6 +- problems/reducing-dishes/README.md | 6 +- .../README.md | 6 +- problems/reformat-date/README.md | 6 +- problems/reformat-department-table/README.md | 6 +- problems/reformat-phone-number/README.md | 6 +- problems/relative-ranks/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/remove-covered-intervals/README.md | 6 +- problems/remove-duplicate-letters/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 7 +- .../README.md | 6 +- problems/remove-element/README.md | 6 +- problems/remove-invalid-parentheses/README.md | 6 +- problems/remove-k-digits/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../remove-palindromic-subsequences/README.md | 6 +- .../README.md | 6 +- .../README.md | 24 ++-- .../remove-vowels-from-a-string/README.md | 6 +- .../README.md | 9 +- problems/reorganize-string/README.md | 6 +- problems/repeated-string-match/README.md | 6 +- problems/repeated-substring-pattern/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 9 +- .../README.md | 6 +- .../README.md | 6 +- problems/replace-words/README.md | 6 +- problems/report-contiguous-dates/README.md | 10 +- problems/reported-posts/README.md | 6 +- problems/reshape-the-matrix/README.md | 9 +- problems/restaurant-growth/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/reverse-only-letters/README.md | 6 +- problems/reverse-prefix-of-word/README.md | 6 +- problems/reverse-string-ii/README.md | 6 +- problems/reverse-string/README.md | 11 +- .../README.md | 12 +- .../README.md | 8 +- problems/reverse-vowels-of-a-string/README.md | 6 +- .../reverse-words-in-a-string-iii/README.md | 6 +- problems/richest-customer-wealth/README.md | 6 +- problems/rle-iterator/README.md | 6 +- problems/rotate-image/README.md | 9 +- problems/rotating-the-box/README.md | 6 +- problems/running-sum-of-1d-array/README.md | 6 +- .../README.md | 6 +- problems/sales-analysis-i/README.md | 9 +- problems/sales-analysis-ii/README.md | 6 +- problems/sales-analysis-iii/README.md | 6 +- problems/sales-person/README.md | 6 +- problems/sales-person/mysql_schemas.sql | 38 +++--- .../score-after-flipping-matrix/README.md | 6 +- problems/scramble-string/README.md | 6 +- problems/search-a-2d-matrix-ii/README.md | 6 +- .../README.md | 6 +- problems/search-suggestions-system/README.md | 8 +- problems/seat-reservation-manager/README.md | 6 +- problems/second-degree-follower/README.md | 6 +- .../second-degree-follower/mysql_schemas.sql | 12 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 8 +- problems/sellers-with-no-sales/README.md | 6 +- problems/sentence-similarity-iii/README.md | 6 +- problems/sentence-similarity/README.md | 6 +- problems/sequence-reconstruction/README.md | 6 +- problems/sequential-digits/README.md | 6 +- .../README.md | 6 +- problems/set-mismatch/README.md | 6 +- problems/shifting-letters/README.md | 6 +- problems/shopping-offers/README.md | 6 +- problems/short-encoding-of-words/README.md | 6 +- problems/shortest-completing-word/README.md | 6 +- .../shortest-distance-in-a-line/README.md | 6 +- .../mysql_schemas.sql | 10 +- .../shortest-distance-in-a-plane/README.md | 6 +- .../mysql_schemas.sql | 10 +- .../README.md | 11 +- .../shortest-path-in-a-hidden-grid/README.md | 6 +- .../shortest-path-in-binary-matrix/README.md | 8 +- .../shortest-path-to-get-all-keys/README.md | 6 +- problems/shortest-path-to-get-food/README.md | 6 +- .../README.md | 6 +- .../README.md | 18 +-- .../README.md | 6 +- .../shortest-way-to-form-string/README.md | 9 +- problems/shortest-word-distance/README.md | 6 +- problems/shuffle-string/README.md | 6 +- .../sign-of-the-product-of-an-array/README.md | 6 +- problems/similar-rgb-color/README.md | 6 +- problems/simple-bank-system/README.md | 6 +- problems/simplified-fractions/README.md | 6 +- .../README.md | 16 +-- problems/single-number-ii/README.md | 8 +- problems/single-threaded-cpu/README.md | 6 +- problems/sliding-puzzle/README.md | 8 +- problems/sliding-window-median/README.md | 8 +- problems/slowest-key/README.md | 6 +- problems/smallest-common-region/README.md | 12 +- .../README.md | 6 +- .../smallest-index-with-equal-value/README.md | 6 +- .../smallest-integer-divisible-by-k/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/smallest-range-i/README.md | 6 +- problems/smallest-range-ii/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/smallest-string-with-swaps/README.md | 14 ++- .../README.md | 13 +- problems/smallest-sufficient-team/README.md | 12 +- problems/solve-the-equation/README.md | 6 +- .../README.md | 9 +- problems/sort-array-by-parity/README.md | 6 +- .../sort-features-by-popularity/README.md | 10 +- .../README.md | 6 +- .../README.md | 6 +- problems/sort-the-matrix-diagonally/README.md | 8 +- problems/sorting-the-sentence/README.md | 6 +- problems/soup-servings/README.md | 6 +- .../sparse-matrix-multiplication/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/spiral-matrix/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/split-bst/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/squirrel-simulation/README.md | 6 +- problems/stickers-to-spell-word/README.md | 6 +- problems/stock-price-fluctuation/README.md | 6 +- problems/stone-game-iv/README.md | 6 +- problems/stone-game-ix/README.md | 6 +- problems/stone-game-v/README.md | 12 +- problems/stone-game-vi/README.md | 20 +-- problems/stone-game-vii/README.md | 17 ++- problems/stone-game-viii/README.md | 6 +- problems/strange-printer-ii/README.md | 6 +- problems/strange-printer/README.md | 6 +- problems/string-compression-ii/README.md | 6 +- .../README.md | 6 +- .../strings-differ-by-one-character/README.md | 8 +- problems/strobogrammatic-number-ii/README.md | 7 +- problems/strong-friendship/README.md | 6 +- problems/strong-password-checker/README.md | 8 +- .../student-attendance-record-i/README.md | 6 +- problems/students-and-examinations/README.md | 6 +- .../students-report-by-geography/README.md | 6 +- .../mysql_schemas.sql | 12 +- .../README.md | 6 +- problems/subdomain-visit-count/README.md | 6 +- problems/subrectangle-queries/README.md | 8 +- .../README.md | 6 +- .../README.md | 8 +- .../README.md | 40 ++++++ .../README.md | 6 +- .../README.md | 6 +- problems/sum-game/README.md | 6 +- .../README.md | 6 +- .../sum-of-all-odd-length-subarrays/README.md | 6 +- .../sum-of-all-subset-xor-totals/README.md | 6 +- problems/sum-of-beauty-in-the-array/README.md | 6 +- .../sum-of-beauty-of-all-substrings/README.md | 6 +- problems/sum-of-digits-in-base-k/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/sum-of-floored-pairs/README.md | 6 +- problems/sum-of-k-mirror-numbers/README.md | 93 ++++++++++++++ .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/sum-of-square-numbers/README.md | 6 +- problems/sum-of-unique-elements/README.md | 6 +- problems/sum-root-to-leaf-numbers/README.md | 6 +- problems/super-palindromes/README.md | 6 +- problems/super-ugly-number/README.md | 6 +- problems/super-washing-machines/README.md | 6 +- problems/surrounded-regions/README.md | 6 +- problems/suspicious-bank-accounts/README.md | 6 +- .../README.md | 6 +- problems/swap-nodes-in-pairs/README.md | 9 +- problems/swap-salary/README.md | 18 +-- problems/swap-salary/mysql_schemas.sql | 2 +- .../swapping-nodes-in-a-linked-list/README.md | 6 +- problems/swim-in-rising-water/README.md | 6 +- problems/tag-validator/README.md | 6 +- problems/task-scheduler/README.md | 6 +- .../README.md | 6 +- problems/teemo-attacking/README.md | 6 +- problems/tenth-line/README.md | 6 +- problems/ternary-expression-parser/README.md | 8 +- .../README.md | 6 +- problems/the-dining-philosophers/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../the-k-weakest-rows-in-a-matrix/README.md | 6 +- problems/the-kth-factor-of-n/README.md | 6 +- problems/the-latest-login-in-2020/README.md | 6 +- problems/the-maze-ii/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../the-most-recent-three-orders/README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/the-number-of-good-subsets/README.md | 6 +- .../the-number-of-rich-customers/README.md | 17 +++ .../mysql_schemas.sql | 7 ++ .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- .../README.md | 6 +- problems/the-winner-university/README.md | 6 +- problems/thousand-separator/README.md | 10 +- problems/three-consecutive-odds/README.md | 6 +- problems/three-divisors/README.md | 6 +- problems/three-equal-parts/README.md | 6 +- problems/throne-inheritance/README.md | 11 +- .../README.md | 6 +- problems/time-based-key-value-store/README.md | 6 +- problems/time-needed-to-buy-tickets/README.md | 6 +- problems/to-lower-case/README.md | 6 +- problems/toeplitz-matrix/README.md | 6 +- problems/top-k-frequent-words/README.md | 6 +- problems/top-travellers/README.md | 6 +- problems/toss-strange-coins/README.md | 6 +- problems/total-hamming-distance/README.md | 8 +- problems/tournament-winners/README.md | 6 +- .../README.md | 6 +- problems/transpose-file/README.md | 6 +- problems/transpose-matrix/README.md | 6 +- problems/trapping-rain-water-ii/README.md | 12 +- problems/tree-diameter/README.md | 9 +- problems/tree-node/README.md | 6 +- problems/tree-node/mysql_schemas.sql | 14 +-- problems/tree-of-coprimes/README.md | 6 +- problems/triangle-judgement/README.md | 6 +- problems/triangle-judgement/mysql_schemas.sql | 8 +- .../README.md | 8 +- problems/truncate-sentence/README.md | 6 +- problems/tuple-with-same-product/README.md | 6 +- problems/tweet-counts-per-frequency/README.md | 6 +- .../two-best-non-overlapping-events/README.md | 6 +- .../README.md | 74 +++++++++++ problems/two-out-of-three/README.md | 6 +- problems/two-sum-bsts/README.md | 6 +- problems/two-sum-iv-input-is-a-bst/README.md | 8 +- problems/two-sum-less-than-k/README.md | 8 +- problems/ugly-number-iii/README.md | 6 +- .../README.md | 6 +- problems/unique-email-addresses/README.md | 6 +- .../README.md | 6 +- problems/unique-morse-code-words/README.md | 6 +- .../unique-number-of-occurrences/README.md | 6 +- .../README.md | 6 +- problems/unique-paths-iii/README.md | 8 +- problems/univalued-binary-tree/README.md | 9 +- problems/unpopular-books/README.md | 6 +- .../README.md | 6 +- problems/user-purchase-platform/README.md | 6 +- .../README.md | 6 +- problems/utf-8-validation/README.md | 8 +- problems/valid-anagram/README.md | 6 +- problems/valid-boomerang/README.md | 6 +- problems/valid-parenthesis-string/README.md | 6 +- problems/valid-perfect-square/README.md | 6 +- problems/valid-phone-numbers/README.md | 6 +- problems/valid-square/README.md | 6 +- problems/valid-tic-tac-toe-state/README.md | 6 +- problems/valid-triangle-number/README.md | 6 +- .../validate-binary-search-tree/README.md | 6 +- problems/validate-binary-tree-nodes/README.md | 6 +- problems/verbal-arithmetic-puzzle/README.md | 6 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 8 +- problems/vowels-of-all-substrings/README.md | 6 +- .../walking-robot-simulation-ii/README.md | 6 +- problems/warehouse-manager/README.md | 6 +- problems/water-bottles/README.md | 6 +- problems/watering-plants/README.md | 88 +++++++++++++ problems/ways-to-make-a-fair-array/README.md | 6 +- .../README.md | 6 +- problems/web-crawler-multithreaded/README.md | 6 +- problems/web-crawler/README.md | 11 +- problems/where-will-the-ball-fall/README.md | 8 +- .../README.md | 6 +- .../README.md | 6 +- problems/wildcard-matching/README.md | 10 +- problems/word-break-ii/README.md | 10 +- problems/word-break/README.md | 6 +- problems/word-frequency/README.md | 6 +- problems/word-ladder-ii/README.md | 6 +- problems/word-ladder/README.md | 6 +- problems/word-pattern/README.md | 6 +- problems/word-search-ii/README.md | 8 +- problems/word-squares/README.md | 6 +- problems/xor-queries-of-a-subarray/README.md | 20 +-- problems/zigzag-iterator/README.md | 6 +- readme/1-300.md | 108 ++++++++-------- readme/1201-1500.md | 108 ++++++++-------- readme/301-600.md | 108 ++++++++-------- readme/601-900.md | 110 ++++++++-------- readme/901-1200.md | 108 ++++++++-------- tag/README.md | 84 ++++++------- tag/array/README.md | 9 +- tag/backtracking/README.md | 6 +- tag/biconnected-component/README.md | 6 +- tag/binary-indexed-tree/README.md | 6 +- tag/binary-search-tree/README.md | 6 +- tag/binary-search/README.md | 7 +- tag/binary-tree/README.md | 6 +- tag/bit-manipulation/README.md | 6 +- tag/bitmask/README.md | 6 +- tag/brainteaser/README.md | 6 +- tag/breadth-first-search/README.md | 8 +- tag/bucket-sort/README.md | 6 +- tag/combinatorics/README.md | 6 +- tag/concurrency/README.md | 6 +- tag/counting-sort/README.md | 6 +- tag/counting/README.md | 6 +- tag/data-stream/README.md | 6 +- tag/depth-first-search/README.md | 8 +- tag/dequeue/README.md | 6 +- tag/design/README.md | 7 +- tag/divide-and-conquer/README.md | 6 +- tag/doubly-linked-list/README.md | 6 +- tag/dynamic-programming/README.md | 8 +- tag/enumeration/README.md | 7 +- tag/eulerian-circuit/README.md | 6 +- tag/game-theory/README.md | 6 +- tag/geometry/README.md | 6 +- tag/graph/README.md | 10 +- tag/greedy/README.md | 7 +- tag/hash-function/README.md | 6 +- tag/hash-table/README.md | 7 +- tag/heap-priority-queue/README.md | 6 +- tag/heap/README.md | 6 +- tag/interactive/README.md | 6 +- tag/iterator/README.md | 6 +- tag/line-sweep/README.md | 6 +- tag/linked-list/README.md | 6 +- tag/math/README.md | 9 +- tag/matrix/README.md | 6 +- tag/meet-in-the-middle/README.md | 6 +- tag/memoization/README.md | 6 +- tag/merge-sort/README.md | 6 +- tag/minimax/README.md | 6 +- tag/minimum-spanning-tree/README.md | 6 +- tag/monotonic-queue/README.md | 6 +- tag/monotonic-stack/README.md | 6 +- tag/number-theory/README.md | 6 +- tag/oop/README.md | 6 +- tag/ordered-map/README.md | 6 +- tag/ordered-set/README.md | 6 +- tag/prefix-sum/README.md | 6 +- tag/probability-and-statistics/README.md | 8 +- tag/queue/README.md | 6 +- tag/quickselect/README.md | 6 +- tag/radix-sort/README.md | 6 +- tag/random/README.md | 6 +- tag/randomized/README.md | 6 +- tag/recursion/README.md | 6 +- tag/rejection-sampling/README.md | 6 +- tag/reservoir-sampling/README.md | 6 +- tag/rolling-hash/README.md | 6 +- tag/segment-tree/README.md | 7 +- tag/shortest-path/README.md | 6 +- tag/simulation/README.md | 6 +- tag/sliding-window/README.md | 8 +- tag/sort/README.md | 6 +- tag/sorting/README.md | 6 +- tag/stack/README.md | 6 +- tag/string-matching/README.md | 6 +- tag/string/README.md | 6 +- tag/strongly-connected-component/README.md | 6 +- tag/suffix-array/README.md | 6 +- tag/topological-sort/README.md | 6 +- tag/tree/README.md | 6 +- tag/trie/README.md | 6 +- tag/two-pointers/README.md | 6 +- tag/union-find/README.md | 7 +- 1421 files changed, 5862 insertions(+), 5414 deletions(-) create mode 100644 problems/drop-type-1-orders-for-customers-with-type-0-orders/README.md create mode 100644 problems/drop-type-1-orders-for-customers-with-type-0-orders/mysql_schemas.sql create mode 100644 problems/paths-in-maze-that-lead-to-same-room/README.md create mode 100644 problems/range-frequency-queries/README.md create mode 100644 problems/substrings-that-begin-and-end-with-the-same-letter/README.md create mode 100644 problems/sum-of-k-mirror-numbers/README.md create mode 100644 problems/the-number-of-rich-customers/README.md create mode 100644 problems/the-number-of-rich-customers/mysql_schemas.sql create mode 100644 problems/two-furthest-houses-with-different-colors/README.md create mode 100644 problems/watering-plants/README.md diff --git a/README.md b/README.md index f967b5ab9..d8ed2b05d 100644 --- a/README.md +++ b/README.md @@ -1,83 +1,91 @@ - - - + + + -# [LeetCode](https://openset.github.io/leetcode) +# [LeetCode](https://awesee.github.io/leetcode) LeetCode Problems' Solutions -[[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] +[[力扣](https://awesee.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/awesee/leetcode/blob/master/tag/README.md)] -[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) -[![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) -[![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) -[![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) -[![license](https://img.shields.io/github/license/openset/leetcode.svg)](https://github.com/openset/leetcode/blob/master/LICENSE) -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fopenset%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fopenset%2Fleetcode?ref=badge_shield) -[![Join the chat](https://badges.gitter.im/openset/leetcode.svg)](https://gitter.im/openset/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Go](https://github.com/awesee/leetcode/workflows/Go/badge.svg)](https://github.com/awesee/leetcode/actions) +[![codecov](https://codecov.io/gh/awesee/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/awesee/leetcode) +[![Go Report Card](https://goreportcard.com/badge/github.com/awesee/leetcode)](https://goreportcard.com/report/github.com/awesee/leetcode) +[![GitHub contributors](https://img.shields.io/github/contributors/awesee/leetcode.svg)](https://github.com/awesee/leetcode/graphs/contributors) +[![license](https://img.shields.io/github/license/awesee/leetcode.svg)](https://github.com/awesee/leetcode/blob/master/LICENSE) +[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fawesee%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fawesee%2Fleetcode?ref=badge_shield) +[![Join the chat](https://badges.gitter.im/awesee/leetcode.svg)](https://gitter.im/awesee/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 2084 | [Drop Type 1 Orders for Customers With Type 0 Orders](https://leetcode.com/problems/drop-type-1-orders-for-customers-with-type-0-orders) 🔒 | [MySQL](problems/drop-type-1-orders-for-customers-with-type-0-orders) | Medium | +| 2083 | [Substrings That Begin and End With the Same Letter](https://leetcode.com/problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [Go](problems/substrings-that-begin-and-end-with-the-same-letter) | Medium | +| 2082 | [The Number of Rich Customers](https://leetcode.com/problems/the-number-of-rich-customers) 🔒 | [MySQL](problems/the-number-of-rich-customers) | Easy | +| 2081 | [Sum of k-Mirror Numbers](https://leetcode.com/problems/sum-of-k-mirror-numbers "k 镜像数字的和") | [Go](problems/sum-of-k-mirror-numbers) | Hard | +| 2080 | [Range Frequency Queries](https://leetcode.com/problems/range-frequency-queries "区间内查询数字的频率") | [Go](problems/range-frequency-queries) | Medium | +| 2079 | [Watering Plants](https://leetcode.com/problems/watering-plants "给植物浇水") | [Go](problems/watering-plants) | Medium | +| 2078 | [Two Furthest Houses With Different Colors](https://leetcode.com/problems/two-furthest-houses-with-different-colors "两栋颜色不同且距离最远的房子") | [Go](problems/two-furthest-houses-with-different-colors) | Easy | +| 2077 | [Paths in Maze That Lead to Same Room](https://leetcode.com/problems/paths-in-maze-that-lead-to-same-room) 🔒 | [Go](problems/paths-in-maze-that-lead-to-same-room) | Medium | | 2076 | [Process Restricted Friend Requests](https://leetcode.com/problems/process-restricted-friend-requests "处理含限制条件的好友请求") | [Go](problems/process-restricted-friend-requests) | Hard | | 2075 | [Decode the Slanted Ciphertext](https://leetcode.com/problems/decode-the-slanted-ciphertext "解码斜向换位密码") | [Go](problems/decode-the-slanted-ciphertext) | Medium | | 2074 | [Reverse Nodes in Even Length Groups](https://leetcode.com/problems/reverse-nodes-in-even-length-groups "反转偶数长度组的节点") | [Go](problems/reverse-nodes-in-even-length-groups) | Medium | @@ -183,7 +191,7 @@ LeetCode Problems' Solutions | 1974 | [Minimum Time to Type Word Using Special Typewriter](https://leetcode.com/problems/minimum-time-to-type-word-using-special-typewriter "使用特殊打字机键入单词的最少时间") | [Go](problems/minimum-time-to-type-word-using-special-typewriter) | Easy | | 1973 | [Count Nodes Equal to Sum of Descendants](https://leetcode.com/problems/count-nodes-equal-to-sum-of-descendants) 🔒 | [Go](problems/count-nodes-equal-to-sum-of-descendants) | Medium | | 1972 | [First and Last Call On the Same Day](https://leetcode.com/problems/first-and-last-call-on-the-same-day) 🔒 | [MySQL](problems/first-and-last-call-on-the-same-day) | Hard | -| 1971 | [Find if Path Exists in Graph](https://leetcode.com/problems/find-if-path-exists-in-graph) | [Go](problems/find-if-path-exists-in-graph) | Easy | +| 1971 | [Find if Path Exists in Graph](https://leetcode.com/problems/find-if-path-exists-in-graph "寻找图中是否存在路径") | [Go](problems/find-if-path-exists-in-graph) | Easy | | 1970 | [Last Day Where You Can Still Cross](https://leetcode.com/problems/last-day-where-you-can-still-cross "你能穿过矩阵的最后一天") | [Go](problems/last-day-where-you-can-still-cross) | Hard | | 1969 | [Minimum Non-Zero Product of the Array Elements](https://leetcode.com/problems/minimum-non-zero-product-of-the-array-elements "数组元素的最小非零乘积") | [Go](problems/minimum-non-zero-product-of-the-array-elements) | Medium | | 1968 | [Array With Elements Not Equal to Average of Neighbors](https://leetcode.com/problems/array-with-elements-not-equal-to-average-of-neighbors "构造元素不等于两相邻元素平均值的数组") | [Go](problems/array-with-elements-not-equal-to-average-of-neighbors) | Medium | diff --git a/helper/README.md b/helper/README.md index 0b90a3c9f..b5d445180 100644 --- a/helper/README.md +++ b/helper/README.md @@ -1,8 +1,8 @@ - - - + + + # Helper diff --git a/problems/1-bit-and-2-bit-characters/README.md b/problems/1-bit-and-2-bit-characters/README.md index 8a4f4ecb9..12f6933a1 100644 --- a/problems/1-bit-and-2-bit-characters/README.md +++ b/problems/1-bit-and-2-bit-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-stack "Max Stack") diff --git a/problems/2-keys-keyboard/README.md b/problems/2-keys-keyboard/README.md index 10bd85b1e..6bf91790a 100644 --- a/problems/2-keys-keyboard/README.md +++ b/problems/2-keys-keyboard/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../dota2-senate "Dota2 Senate") diff --git a/problems/24-game/README.md b/problems/24-game/README.md index bd52440e6..64205b65d 100644 --- a/problems/24-game/README.md +++ b/problems/24-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-parenthesis-string "Valid Parenthesis String") diff --git a/problems/3sum/README.md b/problems/3sum/README.md index f707b18e9..74eb35d4c 100644 --- a/problems/3sum/README.md +++ b/problems/3sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-common-prefix "Longest Common Prefix") diff --git a/problems/4-keys-keyboard/README.md b/problems/4-keys-keyboard/README.md index dc7964f95..14b9a794c 100644 --- a/problems/4-keys-keyboard/README.md +++ b/problems/4-keys-keyboard/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../2-keys-keyboard "2 Keys Keyboard") diff --git a/problems/accepted-candidates-from-the-interviews/README.md b/problems/accepted-candidates-from-the-interviews/README.md index 25555e9f8..19d0072c0 100644 --- a/problems/accepted-candidates-from-the-interviews/README.md +++ b/problems/accepted-candidates-from-the-interviews/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-smallest-product-of-two-sorted-arrays "Kth Smallest Product of Two Sorted Arrays") diff --git a/problems/account-balance/README.md b/problems/account-balance/README.md index a06c26130..ce0895597 100644 --- a/problems/account-balance/README.md +++ b/problems/account-balance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-path-quality-of-a-graph "Maximum Path Quality of a Graph") diff --git a/problems/activity-participants/README.md b/problems/activity-participants/README.md index 6cba915c9..066be853b 100644 --- a/problems/activity-participants/README.md +++ b/problems/activity-participants/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-target-array-with-multiple-sums "Construct Target Array With Multiple Sums") diff --git a/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md b/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md index 7bf3cb0b6..553490bae 100644 --- a/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md +++ b/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../last-stone-weight-ii "Last Stone Weight II") diff --git a/problems/ad-free-sessions/README.md b/problems/ad-free-sessions/README.md index c65a46fb3..4e9bc9677 100644 --- a/problems/ad-free-sessions/README.md +++ b/problems/ad-free-sessions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximize-number-of-nice-divisors "Maximize Number of Nice Divisors") diff --git a/problems/add-bold-tag-in-string/README.md b/problems/add-bold-tag-in-string/README.md index eee9b70a5..2af02380c 100644 --- a/problems/add-bold-tag-in-string/README.md +++ b/problems/add-bold-tag-in-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../average-salary-departments-vs-company "Average Salary: Departments VS Company") diff --git a/problems/add-minimum-number-of-rungs/README.md b/problems/add-minimum-number-of-rungs/README.md index 3f14795f0..a1e778ff4 100644 --- a/problems/add-minimum-number-of-rungs/README.md +++ b/problems/add-minimum-number-of-rungs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-words-you-can-type "Maximum Number of Words You Can Type") diff --git a/problems/add-one-row-to-tree/README.md b/problems/add-one-row-to-tree/README.md index 8a98e1d21..46e4b2d6a 100644 --- a/problems/add-one-row-to-tree/README.md +++ b/problems/add-one-row-to-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-circular-queue "Design Circular Queue") diff --git a/problems/add-to-array-form-of-integer/README.md b/problems/add-to-array-form-of-integer/README.md index db5ec4798..83da4ee23 100644 --- a/problems/add-to-array-form-of-integer/README.md +++ b/problems/add-to-array-form-of-integer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-string-starting-from-leaf "Smallest String Starting From Leaf") diff --git a/problems/add-two-polynomials-represented-as-linked-lists/README.md b/problems/add-two-polynomials-represented-as-linked-lists/README.md index 0b7574ebc..3c0db5e11 100644 --- a/problems/add-two-polynomials-represented-as-linked-lists/README.md +++ b/problems/add-two-polynomials-represented-as-linked-lists/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../percentage-of-users-attended-a-contest "Percentage of Users Attended a Contest") diff --git a/problems/adding-two-negabinary-numbers/README.md b/problems/adding-two-negabinary-numbers/README.md index f7f8a4c72..be61ff03b 100644 --- a/problems/adding-two-negabinary-numbers/README.md +++ b/problems/adding-two-negabinary-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flip-columns-for-maximum-number-of-equal-rows "Flip Columns For Maximum Number of Equal Rows") diff --git a/problems/advantage-shuffle/README.md b/problems/advantage-shuffle/README.md index e32341403..129cfef84 100644 --- a/problems/advantage-shuffle/README.md +++ b/problems/advantage-shuffle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reordered-power-of-2 "Reordered Power of 2") diff --git a/problems/airplane-seat-assignment-probability/README.md b/problems/airplane-seat-assignment-probability/README.md index 7c3ce83cd..27e58d0cf 100644 --- a/problems/airplane-seat-assignment-probability/README.md +++ b/problems/airplane-seat-assignment-probability/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-dining-philosophers "The Dining Philosophers") diff --git a/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md b/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md index e225d4dce..e57869f6d 100644 --- a/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md +++ b/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-parking-system "Design Parking System") diff --git a/problems/alien-dictionary/README.md b/problems/alien-dictionary/README.md index a54c21b2e..4c7fde95a 100644 --- a/problems/alien-dictionary/README.md +++ b/problems/alien-dictionary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../missing-number "Missing Number") diff --git a/problems/all-elements-in-two-binary-search-trees/README.md b/problems/all-elements-in-two-binary-search-trees/README.md index bcefb8caf..3489830b3 100644 --- a/problems/all-elements-in-two-binary-search-trees/README.md +++ b/problems/all-elements-in-two-binary-search-trees/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-n-unique-integers-sum-up-to-zero "Find N Unique Integers Sum up to Zero") diff --git a/problems/all-people-report-to-the-given-manager/README.md b/problems/all-people-report-to-the-given-manager/README.md index 55c7ceec6..e5e7d006b 100644 --- a/problems/all-people-report-to-the-given-manager/README.md +++ b/problems/all-people-report-to-the-given-manager/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-stay-in-the-same-place-after-some-steps "Number of Ways to Stay in the Same Place After Some Steps") diff --git a/problems/all-possible-full-binary-trees/README.md b/problems/all-possible-full-binary-trees/README.md index 2ace2a85a..7d2cba86f 100644 --- a/problems/all-possible-full-binary-trees/README.md +++ b/problems/all-possible-full-binary-trees/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../groups-of-special-equivalent-strings "Groups of Special-Equivalent Strings") diff --git a/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md b/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md index e3b2a3f1f..85484c71c 100644 --- a/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md +++ b/problems/all-the-pairs-with-the-maximum-number-of-common-followers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-of-minimum-values-in-all-subarrays "Maximum of Minimum Values in All Subarrays") diff --git a/problems/all-valid-triplets-that-can-represent-a-country/README.md b/problems/all-valid-triplets-that-can-represent-a-country/README.md index ced73e063..30cf0bbaa 100644 --- a/problems/all-valid-triplets-that-can-represent-a-country/README.md +++ b/problems/all-valid-triplets-that-can-represent-a-country/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fancy-sequence "Fancy Sequence") diff --git a/problems/alphabet-board-path/README.md b/problems/alphabet-board-path/README.md index c5062fab4..6a4c93f65 100644 --- a/problems/alphabet-board-path/README.md +++ b/problems/alphabet-board-path/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../n-th-tribonacci-number "N-th Tribonacci Number") diff --git a/problems/angle-between-hands-of-a-clock/README.md b/problems/angle-between-hands-of-a-clock/README.md index 96ac413ee..a3bacec65 100644 --- a/problems/angle-between-hands-of-a-clock/README.md +++ b/problems/angle-between-hands-of-a-clock/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold "Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold") diff --git a/problems/apply-discount-every-n-orders/README.md b/problems/apply-discount-every-n-orders/README.md index 85a655178..d43de40f0 100644 --- a/problems/apply-discount-every-n-orders/README.md +++ b/problems/apply-discount-every-n-orders/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-integers-by-the-number-of-1-bits "Sort Integers by The Number of 1 Bits") diff --git a/problems/arithmetic-slices-ii-subsequence/README.md b/problems/arithmetic-slices-ii-subsequence/README.md index 642661dd7..8481d5223 100644 --- a/problems/arithmetic-slices-ii-subsequence/README.md +++ b/problems/arithmetic-slices-ii-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../add-two-numbers-ii "Add Two Numbers II") diff --git a/problems/arithmetic-slices/README.md b/problems/arithmetic-slices/README.md index eaed04793..90d411755 100644 --- a/problems/arithmetic-slices/README.md +++ b/problems/arithmetic-slices/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fizz-buzz "Fizz Buzz") @@ -51,3 +51,4 @@ ### Similar Questions 1. [Arithmetic Slices II - Subsequence](../arithmetic-slices-ii-subsequence) (Hard) + 1. [Arithmetic Subarrays](../arithmetic-subarrays) (Medium) diff --git a/problems/arithmetic-subarrays/README.md b/problems/arithmetic-subarrays/README.md index f2b1ee7f4..5c34778f3 100644 --- a/problems/arithmetic-subarrays/README.md +++ b/problems/arithmetic-subarrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../slowest-key "Slowest Key") @@ -64,6 +64,10 @@ In the 2nd query, the subarray is [5,9,3,7]. This can be [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Arithmetic Slices](../arithmetic-slices) (Medium) + 1. [Can Make Arithmetic Progression From Sequence](../can-make-arithmetic-progression-from-sequence) (Easy) + ### Hints
    Hint 1 diff --git a/problems/arranging-coins/README.md b/problems/arranging-coins/README.md index 0c3efdf6d..57ce5aa46 100644 --- a/problems/arranging-coins/README.md +++ b/problems/arranging-coins/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../k-th-smallest-in-lexicographical-order "K-th Smallest in Lexicographical Order") diff --git a/problems/array-nesting/README.md b/problems/array-nesting/README.md index 977d14105..8d0be2a7b 100644 --- a/problems/array-nesting/README.md +++ b/problems/array-nesting/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-closest-palindrome "Find the Closest Palindrome") diff --git a/problems/array-transformation/README.md b/problems/array-transformation/README.md index e691c4aaf..b4fcc4466 100644 --- a/problems/array-transformation/README.md +++ b/problems/array-transformation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../web-crawler-multithreaded "Web Crawler Multithreaded") diff --git a/problems/array-with-elements-not-equal-to-average-of-neighbors/README.md b/problems/array-with-elements-not-equal-to-average-of-neighbors/README.md index c74800b58..25d9d3c60 100644 --- a/problems/array-with-elements-not-equal-to-average-of-neighbors/README.md +++ b/problems/array-with-elements-not-equal-to-average-of-neighbors/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-strings-that-appear-as-substrings-in-word "Number of Strings That Appear as Substrings in Word") diff --git a/problems/article-views-i/README.md b/problems/article-views-i/README.md index d7e60e148..8b68e333a 100644 --- a/problems/article-views-i/README.md +++ b/problems/article-views-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-chunked-palindrome-decomposition "Longest Chunked Palindrome Decomposition") diff --git a/problems/article-views-ii/README.md b/problems/article-views-ii/README.md index efc135214..49af2063a 100644 --- a/problems/article-views-ii/README.md +++ b/problems/article-views-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../article-views-i "Article Views I") diff --git a/problems/as-far-from-land-as-possible/README.md b/problems/as-far-from-land-as-possible/README.md index 904d2bf2a..f7b860658 100644 --- a/problems/as-far-from-land-as-possible/README.md +++ b/problems/as-far-from-land-as-possible/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-level-sum-of-a-binary-tree "Maximum Level Sum of a Binary Tree") diff --git a/problems/assign-cookies/README.md b/problems/assign-cookies/README.md index 15111acc7..b2899d806 100644 --- a/problems/assign-cookies/README.md +++ b/problems/assign-cookies/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../4sum-ii "4Sum II") @@ -46,6 +46,6 @@ You need to output 2. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/average-height-of-buildings-in-each-segment/README.md b/problems/average-height-of-buildings-in-each-segment/README.md index 6bfe8ad96..d47e0bd37 100644 --- a/problems/average-height-of-buildings-in-each-segment/README.md +++ b/problems/average-height-of-buildings-in-each-segment/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-subsequence-repeated-k-times "Longest Subsequence Repeated k Times") diff --git a/problems/average-of-levels-in-binary-tree/README.md b/problems/average-of-levels-in-binary-tree/README.md index 50e5c2181..aac5fb089 100644 --- a/problems/average-of-levels-in-binary-tree/README.md +++ b/problems/average-of-levels-in-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../exclusive-time-of-functions "Exclusive Time of Functions") diff --git a/problems/average-salary-departments-vs-company/README.md b/problems/average-salary-departments-vs-company/README.md index bd0d831f3..7e1bd353e 100644 --- a/problems/average-salary-departments-vs-company/README.md +++ b/problems/average-salary-departments-vs-company/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../second-degree-follower "Second Degree Follower") diff --git a/problems/average-salary-departments-vs-company/mysql_schemas.sql b/problems/average-salary-departments-vs-company/mysql_schemas.sql index ef2258ccd..3ab9ca94f 100644 --- a/problems/average-salary-departments-vs-company/mysql_schemas.sql +++ b/problems/average-salary-departments-vs-company/mysql_schemas.sql @@ -1,13 +1,13 @@ -Create table If Not Exists salary (id int, employee_id int, amount int, pay_date date); -Create table If Not Exists employee (employee_id int, department_id int); -Truncate table salary; -insert into salary (id, employee_id, amount, pay_date) values ('1', '1', '9000', '2017/03/31'); -insert into salary (id, employee_id, amount, pay_date) values ('2', '2', '6000', '2017/03/31'); -insert into salary (id, employee_id, amount, pay_date) values ('3', '3', '10000', '2017/03/31'); -insert into salary (id, employee_id, amount, pay_date) values ('4', '1', '7000', '2017/02/28'); -insert into salary (id, employee_id, amount, pay_date) values ('5', '2', '6000', '2017/02/28'); -insert into salary (id, employee_id, amount, pay_date) values ('6', '3', '8000', '2017/02/28'); -Truncate table employee; -insert into employee (employee_id, department_id) values ('1', '1'); -insert into employee (employee_id, department_id) values ('2', '2'); -insert into employee (employee_id, department_id) values ('3', '2'); +Create table If Not Exists Salary (id int, employee_id int, amount int, pay_date date); +Create table If Not Exists Employee (employee_id int, department_id int); +Truncate table Salary; +insert into Salary (id, employee_id, amount, pay_date) values ('1', '1', '9000', '2017/03/31'); +insert into Salary (id, employee_id, amount, pay_date) values ('2', '2', '6000', '2017/03/31'); +insert into Salary (id, employee_id, amount, pay_date) values ('3', '3', '10000', '2017/03/31'); +insert into Salary (id, employee_id, amount, pay_date) values ('4', '1', '7000', '2017/02/28'); +insert into Salary (id, employee_id, amount, pay_date) values ('5', '2', '6000', '2017/02/28'); +insert into Salary (id, employee_id, amount, pay_date) values ('6', '3', '8000', '2017/02/28'); +Truncate table Employee; +insert into Employee (employee_id, department_id) values ('1', '1'); +insert into Employee (employee_id, department_id) values ('2', '2'); +insert into Employee (employee_id, department_id) values ('3', '2'); diff --git a/problems/average-selling-price/README.md b/problems/average-selling-price/README.md index cb8de6089..2801a6793 100644 --- a/problems/average-selling-price/README.md +++ b/problems/average-selling-price/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-it-is-a-good-array "Check If It Is a Good Array") diff --git a/problems/average-time-of-process-per-machine/README.md b/problems/average-time-of-process-per-machine/README.md index ded7eb2f7..0a4023215 100644 --- a/problems/average-time-of-process-per-machine/README.md +++ b/problems/average-time-of-process-per-machine/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../correct-a-binary-tree "Correct a Binary Tree") diff --git a/problems/average-waiting-time/README.md b/problems/average-waiting-time/README.md index e176a9e09..ef5e69e93 100644 --- a/problems/average-waiting-time/README.md +++ b/problems/average-waiting-time/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-students-unable-to-eat-lunch "Number of Students Unable to Eat Lunch") @@ -61,6 +61,9 @@ So the average waiting time = (2 + 6 + 4 + 1) / 4 = 3.25. [[Array](../../tag/array/README.md)] [[Simulation](../../tag/simulation/README.md)] +### Similar Questions + 1. [Average Height of Buildings in Each Segment](../average-height-of-buildings-in-each-segment) (Medium) + ### Hints
    Hint 1 diff --git a/problems/avoid-flood-in-the-city/README.md b/problems/avoid-flood-in-the-city/README.md index 22fc685a0..a691b24b6 100644 --- a/problems/avoid-flood-in-the-city/README.md +++ b/problems/avoid-flood-in-the-city/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../making-file-names-unique "Making File Names Unique") diff --git a/problems/backspace-string-compare/README.md b/problems/backspace-string-compare/README.md index af13e23c9..d11ab235a 100644 --- a/problems/backspace-string-compare/README.md +++ b/problems/backspace-string-compare/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../guess-the-word "Guess the Word") diff --git a/problems/balance-a-binary-search-tree/README.md b/problems/balance-a-binary-search-tree/README.md index c224333b7..29cbd7b6c 100644 --- a/problems/balance-a-binary-search-tree/README.md +++ b/problems/balance-a-binary-search-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-a-stack-with-increment-operation "Design a Stack With Increment Operation") diff --git a/problems/balanced-binary-tree/README.md b/problems/balanced-binary-tree/README.md index 26e6aced1..22b4d5ef7 100644 --- a/problems/balanced-binary-tree/README.md +++ b/problems/balanced-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-sorted-list-to-binary-search-tree "Convert Sorted List to Binary Search Tree") diff --git a/problems/bank-account-summary-ii/README.md b/problems/bank-account-summary-ii/README.md index 07e5acb2a..485e97320 100644 --- a/problems/bank-account-summary-ii/README.md +++ b/problems/bank-account-summary-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-search-tree-iterator-ii "Binary Search Tree Iterator II") diff --git a/problems/bank-account-summary/README.md b/problems/bank-account-summary/README.md index 3c9ca5b4e..bbd146880 100644 --- a/problems/bank-account-summary/README.md +++ b/problems/bank-account-summary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../strings-differ-by-one-character "Strings Differ by One Character") diff --git a/problems/beautiful-arrangement/README.md b/problems/beautiful-arrangement/README.md index f772c87c4..e9a44b8fa 100644 --- a/problems/beautiful-arrangement/README.md +++ b/problems/beautiful-arrangement/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../contiguous-array "Contiguous Array") @@ -50,10 +50,10 @@ The second beautiful arrangement is [2,1]: ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] ### Similar Questions diff --git a/problems/beautiful-array/README.md b/problems/beautiful-array/README.md index 481b997ca..7d27947ad 100644 --- a/problems/beautiful-array/README.md +++ b/problems/beautiful-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-falling-path-sum "Minimum Falling Path Sum") diff --git a/problems/before-and-after-puzzle/README.md b/problems/before-and-after-puzzle/README.md index 61d1a4d67..24706b19c 100644 --- a/problems/before-and-after-puzzle/README.md +++ b/problems/before-and-after-puzzle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-substrings-with-only-one-distinct-letter "Count Substrings with Only One Distinct Letter") diff --git a/problems/best-position-for-a-service-centre/README.md b/problems/best-position-for-a-service-centre/README.md index 53dd69ad6..776cdd14f 100644 --- a/problems/best-position-for-a-service-centre/README.md +++ b/problems/best-position-for-a-service-centre/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-with-maximum-probability "Path with Maximum Probability") diff --git a/problems/best-sightseeing-pair/README.md b/problems/best-sightseeing-pair/README.md index da2981efc..2889a419e 100644 --- a/problems/best-sightseeing-pair/README.md +++ b/problems/best-sightseeing-pair/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../partition-array-into-three-parts-with-equal-sum "Partition Array Into Three Parts With Equal Sum") diff --git a/problems/best-team-with-no-conflicts/README.md b/problems/best-team-with-no-conflicts/README.md index ec9b2440d..945122c01 100644 --- a/problems/best-team-with-no-conflicts/README.md +++ b/problems/best-team-with-no-conflicts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lexicographically-smallest-string-after-applying-operations "Lexicographically Smallest String After Applying Operations") diff --git a/problems/best-time-to-buy-and-sell-stock-ii/README.md b/problems/best-time-to-buy-and-sell-stock-ii/README.md index f30d6c5b1..2bd861814 100644 --- a/problems/best-time-to-buy-and-sell-stock-ii/README.md +++ b/problems/best-time-to-buy-and-sell-stock-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../best-time-to-buy-and-sell-stock "Best Time to Buy and Sell Stock") @@ -54,9 +54,9 @@ Total profit is 4. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions 1. [Best Time to Buy and Sell Stock](../best-time-to-buy-and-sell-stock) (Easy) diff --git a/problems/best-time-to-buy-and-sell-stock-iii/README.md b/problems/best-time-to-buy-and-sell-stock-iii/README.md index 9224d5f41..198700c20 100644 --- a/problems/best-time-to-buy-and-sell-stock-iii/README.md +++ b/problems/best-time-to-buy-and-sell-stock-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../best-time-to-buy-and-sell-stock-ii "Best Time to Buy and Sell Stock II") diff --git a/problems/best-time-to-buy-and-sell-stock-iv/README.md b/problems/best-time-to-buy-and-sell-stock-iv/README.md index d9bf26f46..6bba064fd 100644 --- a/problems/best-time-to-buy-and-sell-stock-iv/README.md +++ b/problems/best-time-to-buy-and-sell-stock-iv/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../repeated-dna-sequences "Repeated DNA Sequences") diff --git a/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md b/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md index 328dcc1d1..1c8c2b76d 100644 --- a/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md +++ b/problems/best-time-to-buy-and-sell-stock-with-cooldown/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../range-sum-query-2d-mutable "Range Sum Query 2D - Mutable") diff --git a/problems/biggest-window-between-visits/README.md b/problems/biggest-window-between-visits/README.md index 1403336f8..b6e868d16 100644 --- a/problems/biggest-window-between-visits/README.md +++ b/problems/biggest-window-between-visits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-subarray-length-k "Largest Subarray Length K") diff --git a/problems/binary-prefix-divisible-by-5/README.md b/problems/binary-prefix-divisible-by-5/README.md index 05535257d..15d409927 100644 --- a/problems/binary-prefix-divisible-by-5/README.md +++ b/problems/binary-prefix-divisible-by-5/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-to-base-2 "Convert to Base -2") diff --git a/problems/binary-search-tree-iterator-ii/README.md b/problems/binary-search-tree-iterator-ii/README.md index db41437d7..b4e7ca01b 100644 --- a/problems/binary-search-tree-iterator-ii/README.md +++ b/problems/binary-search-tree-iterator-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-string-is-transformable-with-substring-sort-operations "Check If String Is Transformable With Substring Sort Operations") @@ -21,9 +21,6 @@ [[Binary Tree](../../tag/binary-tree/README.md)] [[Iterator](../../tag/iterator/README.md)] -### Similar Questions - 1. [Binary Search Tree Iterator](../binary-search-tree-iterator) (Medium) - ### Hints
    Hint 1 diff --git a/problems/binary-search/README.md b/problems/binary-search/README.md index 551d40e5b..782afcd83 100644 --- a/problems/binary-search/README.md +++ b/problems/binary-search/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-largest-element-in-a-stream "Kth Largest Element in a Stream") diff --git a/problems/binary-searchable-numbers-in-an-unsorted-array/README.md b/problems/binary-searchable-numbers-in-an-unsorted-array/README.md index 36df24998..456b220f6 100644 --- a/problems/binary-searchable-numbers-in-an-unsorted-array/README.md +++ b/problems/binary-searchable-numbers-in-an-unsorted-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../employees-with-missing-information "Employees With Missing Information") diff --git a/problems/binary-tree-coloring-game/README.md b/problems/binary-tree-coloring-game/README.md index dedbfdff1..d1f3a7289 100644 --- a/problems/binary-tree-coloring-game/README.md +++ b/problems/binary-tree-coloring-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../decrease-elements-to-make-array-zigzag "Decrease Elements To Make Array Zigzag") diff --git a/problems/binary-tree-level-order-traversal-ii/README.md b/problems/binary-tree-level-order-traversal-ii/README.md index 0bd7a20bc..4cf8b3360 100644 --- a/problems/binary-tree-level-order-traversal-ii/README.md +++ b/problems/binary-tree-level-order-traversal-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-binary-tree-from-inorder-and-postorder-traversal "Construct Binary Tree from Inorder and Postorder Traversal") diff --git a/problems/binary-tree-longest-consecutive-sequence-ii/README.md b/problems/binary-tree-longest-consecutive-sequence-ii/README.md index 9c5dc7996..04a3c7e03 100644 --- a/problems/binary-tree-longest-consecutive-sequence-ii/README.md +++ b/problems/binary-tree-longest-consecutive-sequence-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../split-array-with-equal-sum "Split Array with Equal Sum") diff --git a/problems/binary-tree-longest-consecutive-sequence/README.md b/problems/binary-tree-longest-consecutive-sequence/README.md index 0e25f7869..555757df4 100644 --- a/problems/binary-tree-longest-consecutive-sequence/README.md +++ b/problems/binary-tree-longest-consecutive-sequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../serialize-and-deserialize-binary-tree "Serialize and Deserialize Binary Tree") diff --git a/problems/binary-tree-paths/README.md b/problems/binary-tree-paths/README.md index d91fa309d..7d34b50d0 100644 --- a/problems/binary-tree-paths/README.md +++ b/problems/binary-tree-paths/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../paint-house "Paint House") diff --git a/problems/binary-tree-vertical-order-traversal/README.md b/problems/binary-tree-vertical-order-traversal/README.md index b8069f38e..860aab5be 100644 --- a/problems/binary-tree-vertical-order-traversal/README.md +++ b/problems/binary-tree-vertical-order-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../super-ugly-number "Super Ugly Number") diff --git a/problems/binary-watch/README.md b/problems/binary-watch/README.md index d0157a61c..032afb9af 100644 --- a/problems/binary-watch/README.md +++ b/problems/binary-watch/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../nth-digit "Nth Digit") diff --git a/problems/bitwise-ors-of-subarrays/README.md b/problems/bitwise-ors-of-subarrays/README.md index b86c8a8a0..1bc3dc5b0 100644 --- a/problems/bitwise-ors-of-subarrays/README.md +++ b/problems/bitwise-ors-of-subarrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../increasing-order-search-tree "Increasing Order Search Tree") @@ -53,6 +53,6 @@ There are 3 unique values, so the answer is 3. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/bomb-enemy/README.md b/problems/bomb-enemy/README.md index 392e525ad..d4e476cea 100644 --- a/problems/bomb-enemy/README.md +++ b/problems/bomb-enemy/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-transformed-array "Sort Transformed Array") diff --git a/problems/brace-expansion-ii/README.md b/problems/brace-expansion-ii/README.md index fa56a935b..b5dea6de0 100644 --- a/problems/brace-expansion-ii/README.md +++ b/problems/brace-expansion-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-in-mountain-array "Find in Mountain Array") @@ -11,9 +11,9 @@ ## [1096. Brace Expansion II (Hard)](https://leetcode.com/problems/brace-expansion-ii "花括号展开 II") -

    Under the grammar given below, strings can represent a set of lowercase words. Let's use R(expr) to denote the set of words the expression represents.

    +

    Under the grammar given below, strings can represent a set of lowercase words. Let R(expr) denote the set of words the expression represents.

    -

    Grammar can best be understood through simple examples:

    +

    The grammar can best be understood through simple examples:

    • Single letters represent a singleton set containing that word. @@ -25,7 +25,7 @@
    • When we take a comma-delimited list of two or more expressions, we take the union of possibilities.
      • R("{a,b,c}") = {"a","b","c"}
      • -
      • R("{{a,b},{b,c}}") = {"a","b","c"} (notice the final set only contains each word at most once)
      • +
      • R("{{a,b},{b,c}}") = {"a","b","c"} (notice the final set only contains each word at most once)
    • When we concatenate two expressions, we take the set of possible concatenations between two words where the first word comes from the first expression and the second word comes from the second expression. @@ -72,10 +72,10 @@
    ### Related Topics - [[Stack](../../tag/stack/README.md)] - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Similar Questions 1. [Brace Expansion](../brace-expansion) (Medium) diff --git a/problems/brace-expansion/README.md b/problems/brace-expansion/README.md index 29a57fa5b..7aec2e852 100644 --- a/problems/brace-expansion/README.md +++ b/problems/brace-expansion/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../high-five "High Five") diff --git a/problems/break-a-palindrome/README.md b/problems/break-a-palindrome/README.md index 822edba2f..a6d34289d 100644 --- a/problems/break-a-palindrome/README.md +++ b/problems/break-a-palindrome/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../list-the-products-ordered-in-a-period "List the Products Ordered in a Period") diff --git a/problems/brick-wall/README.md b/problems/brick-wall/README.md index 350f76c73..252c2432c 100644 --- a/problems/brick-wall/README.md +++ b/problems/brick-wall/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../optimal-division "Optimal Division") diff --git a/problems/bricks-falling-when-hit/README.md b/problems/bricks-falling-when-hit/README.md index cc73a4f95..9720c2f60 100644 --- a/problems/bricks-falling-when-hit/README.md +++ b/problems/bricks-falling-when-hit/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-eventual-safe-states "Find Eventual Safe States") diff --git a/problems/brightest-position-on-street/README.md b/problems/brightest-position-on-street/README.md index 9c4a0ba90..cf9a10f81 100644 --- a/problems/brightest-position-on-street/README.md +++ b/problems/brightest-position-on-street/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-accounts-that-did-not-stream "Number of Accounts That Did Not Stream") diff --git a/problems/build-array-from-permutation/README.md b/problems/build-array-from-permutation/README.md index 9216a4a8d..e72aa6eb5 100644 --- a/problems/build-array-from-permutation/README.md +++ b/problems/build-array-from-permutation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../leetcodify-similar-friends "Leetcodify Similar Friends") diff --git a/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/README.md b/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/README.md index 9b129e918..a375d8613 100644 --- a/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/README.md +++ b/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-frogs-croaking "Minimum Number of Frogs Croaking") diff --git a/problems/build-binary-expression-tree-from-infix-expression/README.md b/problems/build-binary-expression-tree-from-infix-expression/README.md index c6bd15cd5..fc0ee4558 100644 --- a/problems/build-binary-expression-tree-from-infix-expression/README.md +++ b/problems/build-binary-expression-tree-from-infix-expression/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-most-frequently-ordered-products-for-each-customer "The Most Frequently Ordered Products for Each Customer") @@ -14,15 +14,11 @@ ### Related Topics - [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] + [[String](../../tag/string/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] -### Similar Questions - 1. [Basic Calculator III](../basic-calculator-iii) (Hard) - 1. [Check If Two Expression Trees are Equivalent](../check-if-two-expression-trees-are-equivalent) (Medium) - ### Hints
    Hint 1 diff --git a/problems/building-boxes/README.md b/problems/building-boxes/README.md index f00a11199..55d42ffd8 100644 --- a/problems/building-boxes/README.md +++ b/problems/building-boxes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-kth-largest-xor-coordinate-value "Find Kth Largest XOR Coordinate Value") @@ -61,9 +61,9 @@ These boxes are placed in the corner of the room, where the corner is on the bac ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/building-h2o/README.md b/problems/building-h2o/README.md index b0f6efc6f..a449643cb 100644 --- a/problems/building-h2o/README.md +++ b/problems/building-h2o/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../print-zero-even-odd "Print Zero Even Odd") diff --git a/problems/buildings-with-an-ocean-view/README.md b/problems/buildings-with-an-ocean-view/README.md index 1f3707e3f..37792f25e 100644 --- a/problems/buildings-with-an-ocean-view/README.md +++ b/problems/buildings-with-an-ocean-view/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-degree-of-a-connected-trio-in-a-graph "Minimum Degree of a Connected Trio in a Graph") diff --git a/problems/bulb-switcher-iv/README.md b/problems/bulb-switcher-iv/README.md index e3b0c4601..dfaa2dd4f 100644 --- a/problems/bulb-switcher-iv/README.md +++ b/problems/bulb-switcher-iv/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shuffle-string "Shuffle String") diff --git a/problems/bus-routes/README.md b/problems/bus-routes/README.md index 547aa9852..8be99bf69 100644 --- a/problems/bus-routes/README.md +++ b/problems/bus-routes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-tree-pruning "Binary Tree Pruning") diff --git a/problems/calculate-money-in-leetcode-bank/README.md b/problems/calculate-money-in-leetcode-bank/README.md index 625ae8730..7f70f38b2 100644 --- a/problems/calculate-money-in-leetcode-bank/README.md +++ b/problems/calculate-money-in-leetcode-bank/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-apples-and-oranges "Count Apples and Oranges") diff --git a/problems/calculate-special-bonus/README.md b/problems/calculate-special-bonus/README.md index 40fc4b72f..1fdb4c0d3 100644 --- a/problems/calculate-special-bonus/README.md +++ b/problems/calculate-special-bonus/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game-viii "Stone Game VIII") diff --git a/problems/can-convert-string-in-k-moves/README.md b/problems/can-convert-string-in-k-moves/README.md index a30659677..38ce7036e 100644 --- a/problems/can-convert-string-in-k-moves/README.md +++ b/problems/can-convert-string-in-k-moves/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-missing-positive-number "Kth Missing Positive Number") diff --git a/problems/can-make-arithmetic-progression-from-sequence/README.md b/problems/can-make-arithmetic-progression-from-sequence/README.md index 3a893b278..92f0cbc72 100644 --- a/problems/can-make-arithmetic-progression-from-sequence/README.md +++ b/problems/can-make-arithmetic-progression-from-sequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../countries-you-can-safely-invest-in "Countries You Can Safely Invest In") diff --git a/problems/can-make-palindrome-from-substring/README.md b/problems/can-make-palindrome-from-substring/README.md index 11caade72..e8a95283e 100644 --- a/problems/can-make-palindrome-from-substring/README.md +++ b/problems/can-make-palindrome-from-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../diet-plan-performance "Diet Plan Performance") @@ -51,11 +51,14 @@ queries[4]: substring = "abcda", could be changed to "abcba" ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] +### Similar Questions + 1. [Plates Between Candles](../plates-between-candles) (Medium) + ### Hints
    Hint 1 diff --git a/problems/can-place-flowers/README.md b/problems/can-place-flowers/README.md index 8833ed008..2cf0c8bdd 100644 --- a/problems/can-place-flowers/README.md +++ b/problems/can-place-flowers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-compressed-string-iterator "Design Compressed String Iterator") @@ -34,8 +34,8 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] ### Similar Questions 1. [Teemo Attacking](../teemo-attacking) (Easy) diff --git a/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/README.md b/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/README.md index 8aeb288b6..ea7291af7 100644 --- a/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/README.md +++ b/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../restore-the-array-from-adjacent-pairs "Restore the Array From Adjacent Pairs") diff --git a/problems/capacity-to-ship-packages-within-d-days/README.md b/problems/capacity-to-ship-packages-within-d-days/README.md index 68f6563bb..b2df14c7d 100644 --- a/problems/capacity-to-ship-packages-within-d-days/README.md +++ b/problems/capacity-to-ship-packages-within-d-days/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../pairs-of-songs-with-total-durations-divisible-by-60 "Pairs of Songs With Total Durations Divisible by 60") @@ -65,9 +65,15 @@ Note that the cargo must be shipped in the order given, so using a ship of capac ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Similar Questions + 1. [Split Array Largest Sum](../split-array-largest-sum) (Hard) + 1. [Divide Chocolate](../divide-chocolate) (Hard) + 1. [Cutting Ribbons](../cutting-ribbons) (Medium) + 1. [Minimized Maximum of Products Distributed to Any Store](../minimized-maximum-of-products-distributed-to-any-store) (Medium) ### Hints
    diff --git a/problems/car-fleet-ii/README.md b/problems/car-fleet-ii/README.md index cae3f8577..dda2040c2 100644 --- a/problems/car-fleet-ii/README.md +++ b/problems/car-fleet-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../equal-sum-arrays-with-minimum-number-of-operations "Equal Sum Arrays With Minimum Number of Operations") @@ -48,14 +48,11 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Stack](../../tag/stack/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] - -### Similar Questions - 1. [Car Fleet](../car-fleet) (Medium) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/card-flipping-game/README.md b/problems/card-flipping-game/README.md index 4f080e4ff..90ae2335a 100644 --- a/problems/card-flipping-game/README.md +++ b/problems/card-flipping-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-distance-to-a-character "Shortest Distance to a Character") diff --git a/problems/cat-and-mouse-ii/README.md b/problems/cat-and-mouse-ii/README.md index 7935c07ae..1163fd2b3 100644 --- a/problems/cat-and-mouse-ii/README.md +++ b/problems/cat-and-mouse-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-submatrix-with-rearrangements "Largest Submatrix With Rearrangements") diff --git a/problems/cells-with-odd-values-in-a-matrix/README.md b/problems/cells-with-odd-values-in-a-matrix/README.md index 3b170b034..b8fc0de26 100644 --- a/problems/cells-with-odd-values-in-a-matrix/README.md +++ b/problems/cells-with-odd-values-in-a-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../average-selling-price "Average Selling Price") diff --git a/problems/chalkboard-xor-game/README.md b/problems/chalkboard-xor-game/README.md index f1199e2d4..b3e8c6744 100644 --- a/problems/chalkboard-xor-game/README.md +++ b/problems/chalkboard-xor-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../expressive-words "Expressive Words") @@ -54,8 +54,8 @@ If Alice erases 2 first, now nums become [1, 1]. The bitwise XOR of all the elem ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] - [[Brainteaser](../../tag/brainteaser/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Brainteaser](../../tag/brainteaser/README.md)] [[Game Theory](../../tag/game-theory/README.md)] diff --git a/problems/change-minimum-characters-to-satisfy-one-of-three-conditions/README.md b/problems/change-minimum-characters-to-satisfy-one-of-three-conditions/README.md index 1782e05bd..98008661a 100644 --- a/problems/change-minimum-characters-to-satisfy-one-of-three-conditions/README.md +++ b/problems/change-minimum-characters-to-satisfy-one-of-three-conditions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../latest-time-by-replacing-hidden-digits "Latest Time by Replacing Hidden Digits") diff --git a/problems/change-the-root-of-a-binary-tree/README.md b/problems/change-the-root-of-a-binary-tree/README.md index abde09cc9..532482af4 100644 --- a/problems/change-the-root-of-a-binary-tree/README.md +++ b/problems/change-the-root-of-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-initial-energy-to-finish-tasks "Minimum Initial Energy to Finish Tasks") diff --git a/problems/check-array-formation-through-concatenation/README.md b/problems/check-array-formation-through-concatenation/README.md index 26c5480c2..d010e77ab 100644 --- a/problems/check-array-formation-through-concatenation/README.md +++ b/problems/check-array-formation-through-concatenation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-form-a-target-string-given-a-dictionary "Number of Ways to Form a Target String Given a Dictionary") diff --git a/problems/check-completeness-of-a-binary-tree/README.md b/problems/check-completeness-of-a-binary-tree/README.md index d4f4f8b39..e6538cb8f 100644 --- a/problems/check-completeness-of-a-binary-tree/README.md +++ b/problems/check-completeness-of-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../prison-cells-after-n-days "Prison Cells After N Days") diff --git a/problems/check-if-a-string-can-break-another-string/README.md b/problems/check-if-a-string-can-break-another-string/README.md index 47a04fa96..967b846b1 100644 --- a/problems/check-if-a-string-can-break-another-string/README.md +++ b/problems/check-if-a-string-can-break-another-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-difference-you-can-get-from-changing-an-integer "Max Difference You Can Get From Changing an Integer") @@ -50,8 +50,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md b/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md index bf477e1ad..d33963e44 100644 --- a/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md +++ b/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-common-subsequence-between-sorted-arrays "Longest Common Subsequence Between Sorted Arrays") diff --git a/problems/check-if-all-the-integers-in-a-range-are-covered/README.md b/problems/check-if-all-the-integers-in-a-range-are-covered/README.md index b8d20d0f6..d12d6aad3 100644 --- a/problems/check-if-all-the-integers-in-a-range-are-covered/README.md +++ b/problems/check-if-all-the-integers-in-a-range-are-covered/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../page-recommendations-ii "Page Recommendations II") diff --git a/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md b/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md index 028c57844..ce29c124c 100644 --- a/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md +++ b/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-operations-to-convert-number "Minimum Operations to Convert Number") diff --git a/problems/check-if-array-is-sorted-and-rotated/README.md b/problems/check-if-array-is-sorted-and-rotated/README.md index cf7fd74e0..f10753e75 100644 --- a/problems/check-if-array-is-sorted-and-rotated/README.md +++ b/problems/check-if-array-is-sorted-and-rotated/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-events-that-can-be-attended-ii "Maximum Number of Events That Can Be Attended II") diff --git a/problems/check-if-array-pairs-are-divisible-by-k/README.md b/problems/check-if-array-pairs-are-divisible-by-k/README.md index a904e7a19..729dfd51c 100644 --- a/problems/check-if-array-pairs-are-divisible-by-k/README.md +++ b/problems/check-if-array-pairs-are-divisible-by-k/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-crossing "Path Crossing") diff --git a/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md b/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md index d2e2de0b9..1306dc3e1 100644 --- a/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md +++ b/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../grand-slam-titles "Grand Slam Titles") diff --git a/problems/check-if-it-is-a-good-array/README.md b/problems/check-if-it-is-a-good-array/README.md index c25acbf33..289c87eae 100644 --- a/problems/check-if-it-is-a-good-array/README.md +++ b/problems/check-if-it-is-a-good-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-remove-to-make-valid-parentheses "Minimum Remove to Make Valid Parentheses") diff --git a/problems/check-if-move-is-legal/README.md b/problems/check-if-move-is-legal/README.md index 9d7c0f21c..026618369 100644 --- a/problems/check-if-move-is-legal/README.md +++ b/problems/check-if-move-is-legal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-characters-to-make-fancy-string "Delete Characters to Make Fancy String") diff --git a/problems/check-if-number-is-a-sum-of-powers-of-three/README.md b/problems/check-if-number-is-a-sum-of-powers-of-three/README.md index f8170ffb3..85e10f36c 100644 --- a/problems/check-if-number-is-a-sum-of-powers-of-three/README.md +++ b/problems/check-if-number-is-a-sum-of-powers-of-three/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-nearest-point-that-has-the-same-x-or-y-coordinate "Find Nearest Point That Has the Same X or Y Coordinate") @@ -49,9 +49,6 @@ ### Related Topics [[Math](../../tag/math/README.md)] -### Similar Questions - 1. [Power of Three](../power-of-three) (Easy) - ### Hints
    Hint 1 diff --git a/problems/check-if-numbers-are-ascending-in-a-sentence/README.md b/problems/check-if-numbers-are-ascending-in-a-sentence/README.md index c74e2a063..7c77fe501 100644 --- a/problems/check-if-numbers-are-ascending-in-a-sentence/README.md +++ b/problems/check-if-numbers-are-ascending-in-a-sentence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../accepted-candidates-from-the-interviews "Accepted Candidates From the Interviews") diff --git a/problems/check-if-one-string-swap-can-make-strings-equal/README.md b/problems/check-if-one-string-swap-can-make-strings-equal/README.md index a328452f3..d278fdcd0 100644 --- a/problems/check-if-one-string-swap-can-make-strings-equal/README.md +++ b/problems/check-if-one-string-swap-can-make-strings-equal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../primary-department-for-each-employee "Primary Department for Each Employee") @@ -61,9 +61,6 @@ [[String](../../tag/string/README.md)] [[Counting](../../tag/counting/README.md)] -### Similar Questions - 1. [Buddy Strings](../buddy-strings) (Easy) - ### Hints
    Hint 1 diff --git a/problems/check-if-string-is-a-prefix-of-array/README.md b/problems/check-if-string-is-a-prefix-of-array/README.md index 05ac3e98c..9bf0c41d0 100644 --- a/problems/check-if-string-is-a-prefix-of-array/README.md +++ b/problems/check-if-string-is-a-prefix-of-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-product-of-the-length-of-two-palindromic-substrings "Maximum Product of the Length of Two Palindromic Substrings") diff --git a/problems/check-if-string-is-decomposable-into-value-equal-substrings/README.md b/problems/check-if-string-is-decomposable-into-value-equal-substrings/README.md index f15f0c542..e984f649b 100644 --- a/problems/check-if-string-is-decomposable-into-value-equal-substrings/README.md +++ b/problems/check-if-string-is-decomposable-into-value-equal-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../merge-bsts-to-create-single-bst "Merge BSTs to Create Single BST") diff --git a/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md b/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md index 1b332b52c..439964b1e 100644 --- a/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md +++ b/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../min-cost-to-connect-all-points "Min Cost to Connect All Points") diff --git a/problems/check-if-the-sentence-is-pangram/README.md b/problems/check-if-the-sentence-is-pangram/README.md index 21b9fe963..c937655c0 100644 --- a/problems/check-if-the-sentence-is-pangram/README.md +++ b/problems/check-if-the-sentence-is-pangram/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-transaction-each-day "Maximum Transaction Each Day") diff --git a/problems/check-if-two-expression-trees-are-equivalent/README.md b/problems/check-if-two-expression-trees-are-equivalent/README.md index cc128802b..c25f72b60 100644 --- a/problems/check-if-two-expression-trees-are-equivalent/README.md +++ b/problems/check-if-two-expression-trees-are-equivalent/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-one-bit-operations-to-make-integers-zero "Minimum One Bit Operations to Make Integers Zero") diff --git a/problems/check-if-two-string-arrays-are-equivalent/README.md b/problems/check-if-two-string-arrays-are-equivalent/README.md index f06c09fce..4a4b7f734 100644 --- a/problems/check-if-two-string-arrays-are-equivalent/README.md +++ b/problems/check-if-two-string-arrays-are-equivalent/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../average-time-of-process-per-machine "Average Time of Process per Machine") @@ -54,9 +54,6 @@ The strings are the same, so return true. [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] -### Similar Questions - 1. [Check if an Original String Exists Given Two Encoded Strings](../check-if-an-original-string-exists-given-two-encoded-strings) (Hard) - ### Hints
    Hint 1 diff --git a/problems/check-if-word-can-be-placed-in-crossword/README.md b/problems/check-if-word-can-be-placed-in-crossword/README.md index e747c109d..b67375a41 100644 --- a/problems/check-if-word-can-be-placed-in-crossword/README.md +++ b/problems/check-if-word-can-be-placed-in-crossword/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../grid-game "Grid Game") diff --git a/problems/check-if-word-equals-summation-of-two-words/README.md b/problems/check-if-word-equals-summation-of-two-words/README.md index 72644c446..65bbc3074 100644 --- a/problems/check-if-word-equals-summation-of-two-words/README.md +++ b/problems/check-if-word-equals-summation-of-two-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-xor-sum-of-two-arrays "Minimum XOR Sum of Two Arrays") diff --git a/problems/check-whether-two-strings-are-almost-equivalent/README.md b/problems/check-whether-two-strings-are-almost-equivalent/README.md index fc14405ad..00b1bcd6e 100644 --- a/problems/check-whether-two-strings-are-almost-equivalent/README.md +++ b/problems/check-whether-two-strings-are-almost-equivalent/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-equal-count-substrings "Number of Equal Count Substrings") diff --git a/problems/checking-existence-of-edge-length-limited-paths-ii/README.md b/problems/checking-existence-of-edge-length-limited-paths-ii/README.md index 521244d38..c1bdb7548 100644 --- a/problems/checking-existence-of-edge-length-limited-paths-ii/README.md +++ b/problems/checking-existence-of-edge-length-limited-paths-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-minimum-time-to-finish-all-jobs "Find Minimum Time to Finish All Jobs") @@ -18,9 +18,6 @@ [[Graph](../../tag/graph/README.md)] [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] -### Similar Questions - 1. [Checking Existence of Edge Length Limited Paths](../checking-existence-of-edge-length-limited-paths) (Hard) - ### Hints
    Hint 1 diff --git a/problems/checking-existence-of-edge-length-limited-paths/README.md b/problems/checking-existence-of-edge-length-limited-paths/README.md index a7972ea78..86f617a92 100644 --- a/problems/checking-existence-of-edge-length-limited-paths/README.md +++ b/problems/checking-existence-of-edge-length-limited-paths/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../jump-game-vi "Jump Game VI") @@ -52,11 +52,14 @@ For the second query, there is a path (0 -> 1 -> 2) of two edges with dist ### Related Topics + [[Array](../../tag/array/README.md)] [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] - [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Checking Existence of Edge Length Limited Paths II](../checking-existence-of-edge-length-limited-paths-ii) (Hard) + ### Hints
    Hint 1 diff --git a/problems/cherry-pickup-ii/README.md b/problems/cherry-pickup-ii/README.md index 647727cdc..0dac251a8 100644 --- a/problems/cherry-pickup-ii/README.md +++ b/problems/cherry-pickup-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../course-schedule-iv "Course Schedule IV") diff --git a/problems/cinema-seat-allocation/README.md b/problems/cinema-seat-allocation/README.md index 7f0fefe93..b08c37802 100644 --- a/problems/cinema-seat-allocation/README.md +++ b/problems/cinema-seat-allocation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-distance-value-between-two-arrays "Find the Distance Value Between Two Arrays") @@ -57,10 +57,10 @@ ### Related Topics - [[Array](../../tag/array/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/circle-and-rectangle-overlapping/README.md b/problems/circle-and-rectangle-overlapping/README.md index edda53622..3f115e148 100644 --- a/problems/circle-and-rectangle-overlapping/README.md +++ b/problems/circle-and-rectangle-overlapping/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-k-palindrome-strings "Construct K Palindrome Strings") @@ -64,8 +64,8 @@ ### Related Topics - [[Math](../../tag/math/README.md)] [[Geometry](../../tag/geometry/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/circular-array-loop/README.md b/problems/circular-array-loop/README.md index 3d67613c6..48326bf27 100644 --- a/problems/circular-array-loop/README.md +++ b/problems/circular-array-loop/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../132-pattern "132 Pattern") diff --git a/problems/classes-more-than-5-students/README.md b/problems/classes-more-than-5-students/README.md index f2c545b0c..4f131c182 100644 --- a/problems/classes-more-than-5-students/README.md +++ b/problems/classes-more-than-5-students/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../big-countries "Big Countries") @@ -11,42 +11,58 @@ ## [596. Classes More Than 5 Students (Easy)](https://leetcode.com/problems/classes-more-than-5-students "超过5名学生的课") -

    There is a table courses with columns: student and class

    - -

    Please list out all classes which have more than or equal to 5 students.

    - -

    For example, the table:

    +

    Table: Courses

    -+---------+------------+
    -| student | class      |
    -+---------+------------+
    -| A       | Math       |
    -| B       | English    |
    -| C       | Math       |
    -| D       | Biology    |
    -| E       | Math       |
    -| F       | Computer   |
    -| G       | Math       |
    -| H       | Math       |
    -| I       | Math       |
    -+---------+------------+
    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| student     | varchar |
    +| class       | varchar |
    ++-------------+---------+
    +(student, class) is the primary key column for this table.
    +Each row of this table indicates the name of a student and the class in which they are enrolled.
     
    -

    Should output:

    +

     

    + +

    Write an SQL query to report all the classes that have at least five students.

    + +

    Return the result table in any order.

    + +

    The query result format is in the following example.

    + +

     

    +

    Example 1:

    +Input: 
    +Courses table:
    ++---------+----------+
    +| student | class    |
    ++---------+----------+
    +| A       | Math     |
    +| B       | English  |
    +| C       | Math     |
    +| D       | Biology  |
    +| E       | Math     |
    +| F       | Computer |
    +| G       | Math     |
    +| H       | Math     |
    +| I       | Math     |
    ++---------+----------+
    +Output: 
     +---------+
     | class   |
     +---------+
     | Math    |
     +---------+
    +Explanation: 
    +- Math has 6 students, so we include it.
    +- English has 1 student, so we do not include it.
    +- Biology has 1 student, so we do not include it.
    +- Computer has 1 student, so we do not include it.
     
    -

     

    - -

    Note:
    -The students should not be counted duplicate in each course.

    - ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/classes-more-than-5-students/mysql_schemas.sql b/problems/classes-more-than-5-students/mysql_schemas.sql index f0d0ac7e3..b063c3153 100644 --- a/problems/classes-more-than-5-students/mysql_schemas.sql +++ b/problems/classes-more-than-5-students/mysql_schemas.sql @@ -1,11 +1,11 @@ -Create table If Not Exists courses (student varchar(255), class varchar(255)); -Truncate table courses; -insert into courses (student, class) values ('A', 'Math'); -insert into courses (student, class) values ('B', 'English'); -insert into courses (student, class) values ('C', 'Math'); -insert into courses (student, class) values ('D', 'Biology'); -insert into courses (student, class) values ('E', 'Math'); -insert into courses (student, class) values ('F', 'Computer'); -insert into courses (student, class) values ('G', 'Math'); -insert into courses (student, class) values ('H', 'Math'); -insert into courses (student, class) values ('I', 'Math'); +Create table If Not Exists Courses (student varchar(255), class varchar(255)); +Truncate table Courses; +insert into Courses (student, class) values ('A', 'Math'); +insert into Courses (student, class) values ('B', 'English'); +insert into Courses (student, class) values ('C', 'Math'); +insert into Courses (student, class) values ('D', 'Biology'); +insert into Courses (student, class) values ('E', 'Math'); +insert into Courses (student, class) values ('F', 'Computer'); +insert into Courses (student, class) values ('G', 'Math'); +insert into Courses (student, class) values ('H', 'Math'); +insert into Courses (student, class) values ('I', 'Math'); diff --git a/problems/climbing-stairs/README.md b/problems/climbing-stairs/README.md index 09fbeff5f..5a7ddf992 100644 --- a/problems/climbing-stairs/README.md +++ b/problems/climbing-stairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sqrtx "Sqrt(x)") @@ -45,9 +45,9 @@ ### Related Topics - [[Memoization](../../tag/memoization/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Memoization](../../tag/memoization/README.md)] ### Similar Questions 1. [Min Cost Climbing Stairs](../min-cost-climbing-stairs) (Easy) diff --git a/problems/clone-graph/README.md b/problems/clone-graph/README.md index 9ba5fa989..4c7683c89 100644 --- a/problems/clone-graph/README.md +++ b/problems/clone-graph/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../palindrome-partitioning-ii "Palindrome Partitioning II") @@ -82,12 +82,10 @@ class Node { ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] ### Similar Questions 1. [Copy List with Random Pointer](../copy-list-with-random-pointer) (Medium) - 1. [Clone Binary Tree With Random Pointer](../clone-binary-tree-with-random-pointer) (Medium) - 1. [Clone N-ary Tree](../clone-n-ary-tree) (Medium) diff --git a/problems/closest-binary-search-tree-value/README.md b/problems/closest-binary-search-tree-value/README.md index 0153f8003..e1c3da73f 100644 --- a/problems/closest-binary-search-tree-value/README.md +++ b/problems/closest-binary-search-tree-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../alien-dictionary "Alien Dictionary") diff --git a/problems/closest-dessert-cost/README.md b/problems/closest-dessert-cost/README.md index e3526bff9..82b8f7617 100644 --- a/problems/closest-dessert-cost/README.md +++ b/problems/closest-dessert-cost/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-items-matching-a-rule "Count Items Matching a Rule") diff --git a/problems/closest-leaf-in-a-binary-tree/README.md b/problems/closest-leaf-in-a-binary-tree/README.md index eb7a99ca0..417cfb5a6 100644 --- a/problems/closest-leaf-in-a-binary-tree/README.md +++ b/problems/closest-leaf-in-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cherry-pickup "Cherry Pickup") diff --git a/problems/closest-room/README.md b/problems/closest-room/README.md index cfbce9e63..6b25587c4 100644 --- a/problems/closest-room/README.md +++ b/problems/closest-room/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-element-after-decreasing-and-rearranging "Maximum Element After Decreasing and Rearranging") diff --git a/problems/closest-subsequence-sum/README.md b/problems/closest-subsequence-sum/README.md index 08560e3fa..1f41fe465 100644 --- a/problems/closest-subsequence-sum/README.md +++ b/problems/closest-subsequence-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-merge-of-two-strings "Largest Merge Of Two Strings") @@ -55,16 +55,12 @@ The absolute difference is abs(-4 - (-5)) = abs(1) = 1, which is the minimum. ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] -### Similar Questions - 1. [Minimize the Difference Between Target and Chosen Elements](../minimize-the-difference-between-target-and-chosen-elements) (Medium) - 1. [Partition Array Into Two Arrays to Minimize Sum Difference](../partition-array-into-two-arrays-to-minimize-sum-difference) (Hard) - ### Hints
    Hint 1 diff --git a/problems/clumsy-factorial/README.md b/problems/clumsy-factorial/README.md index 0d81c8f41..b6ca2e085 100644 --- a/problems/clumsy-factorial/README.md +++ b/problems/clumsy-factorial/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximize-sum-of-array-after-k-negations "Maximize Sum Of Array After K Negations") diff --git a/problems/coin-path/README.md b/problems/coin-path/README.md index ae439b41f..35ef5334b 100644 --- a/problems/coin-path/README.md +++ b/problems/coin-path/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../print-binary-tree "Print Binary Tree") diff --git a/problems/coloring-a-border/README.md b/problems/coloring-a-border/README.md index cd71bfc1e..9ab6ec39b 100644 --- a/problems/coloring-a-border/README.md +++ b/problems/coloring-a-border/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../moving-stones-until-consecutive "Moving Stones Until Consecutive") diff --git a/problems/combination-sum-iii/README.md b/problems/combination-sum-iii/README.md index 1a42716e4..4f08564db 100644 --- a/problems/combination-sum-iii/README.md +++ b/problems/combination-sum-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-largest-element-in-an-array "Kth Largest Element in an Array") diff --git a/problems/combinations/README.md b/problems/combinations/README.md index 5fefaef75..c9bdd2fba 100644 --- a/problems/combinations/README.md +++ b/problems/combinations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-window-substring "Minimum Window Substring") diff --git a/problems/combine-two-tables/README.md b/problems/combine-two-tables/README.md index 905d39ec6..f507a1bf4 100644 --- a/problems/combine-two-tables/README.md +++ b/problems/combine-two-tables/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../dungeon-game "Dungeon Game") diff --git a/problems/compare-strings-by-frequency-of-the-smallest-character/README.md b/problems/compare-strings-by-frequency-of-the-smallest-character/README.md index 2be2ea622..faac7ff0d 100644 --- a/problems/compare-strings-by-frequency-of-the-smallest-character/README.md +++ b/problems/compare-strings-by-frequency-of-the-smallest-character/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../invalid-transactions "Invalid Transactions") diff --git a/problems/compare-version-numbers/README.md b/problems/compare-version-numbers/README.md index 3a5f430e5..08840605a 100644 --- a/problems/compare-version-numbers/README.md +++ b/problems/compare-version-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-gap "Maximum Gap") diff --git a/problems/complex-number-multiplication/README.md b/problems/complex-number-multiplication/README.md index 7c224f346..7e9767ca2 100644 --- a/problems/complex-number-multiplication/README.md +++ b/problems/complex-number-multiplication/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-binary-tree-from-string "Construct Binary Tree from String") diff --git a/problems/concatenation-of-array/README.md b/problems/concatenation-of-array/README.md index 0ad0358f5..1c3c142f7 100644 --- a/problems/concatenation-of-array/README.md +++ b/problems/concatenation-of-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-reach-destination-in-time "Minimum Cost to Reach Destination in Time") diff --git a/problems/concatenation-of-consecutive-binary-numbers/README.md b/problems/concatenation-of-consecutive-binary-numbers/README.md index abe11247d..1bd4d3bc7 100644 --- a/problems/concatenation-of-consecutive-binary-numbers/README.md +++ b/problems/concatenation-of-consecutive-binary-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-number-of-k-sum-pairs "Max Number of K-Sum Pairs") diff --git a/problems/confirmation-rate/README.md b/problems/confirmation-rate/README.md index ce3bac860..4f0f62c6c 100644 --- a/problems/confirmation-rate/README.md +++ b/problems/confirmation-rate/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-string-is-decomposable-into-value-equal-substrings "Check if String Is Decomposable Into Value-Equal Substrings") diff --git a/problems/confusing-number/README.md b/problems/confusing-number/README.md index 63070cfc9..2dab50cf9 100644 --- a/problems/confusing-number/README.md +++ b/problems/confusing-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-way-to-form-string "Shortest Way to Form String") diff --git a/problems/consecutive-numbers-sum/README.md b/problems/consecutive-numbers-sum/README.md index fd6213696..7eae4e37c 100644 --- a/problems/consecutive-numbers-sum/README.md +++ b/problems/consecutive-numbers-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-unique-characters-of-all-substrings-of-a-given-string "Count Unique Characters of All Substrings of a Given String") diff --git a/problems/consecutive-numbers/README.md b/problems/consecutive-numbers/README.md index 283045d24..9fc244819 100644 --- a/problems/consecutive-numbers/README.md +++ b/problems/consecutive-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-number "Largest Number") @@ -38,7 +38,7 @@ id is the primary key for this table. Input: Logs table: +----+-----+ -| Id | Num | +| id | num | +----+-----+ | 1 | 1 | | 2 | 1 | diff --git a/problems/consecutive-numbers/mysql_schemas.sql b/problems/consecutive-numbers/mysql_schemas.sql index ea8fd6816..0576b97dd 100644 --- a/problems/consecutive-numbers/mysql_schemas.sql +++ b/problems/consecutive-numbers/mysql_schemas.sql @@ -1,9 +1,9 @@ -Create table If Not Exists Logs (Id int, Num int); +Create table If Not Exists Logs (id int, num int); Truncate table Logs; -insert into Logs (Id, Num) values ('1', '1'); -insert into Logs (Id, Num) values ('2', '1'); -insert into Logs (Id, Num) values ('3', '1'); -insert into Logs (Id, Num) values ('4', '2'); -insert into Logs (Id, Num) values ('5', '1'); -insert into Logs (Id, Num) values ('6', '2'); -insert into Logs (Id, Num) values ('7', '2'); +insert into Logs (id, num) values ('1', '1'); +insert into Logs (id, num) values ('2', '1'); +insert into Logs (id, num) values ('3', '1'); +insert into Logs (id, num) values ('4', '2'); +insert into Logs (id, num) values ('5', '1'); +insert into Logs (id, num) values ('6', '2'); +insert into Logs (id, num) values ('7', '2'); diff --git a/problems/constrained-subsequence-sum/README.md b/problems/constrained-subsequence-sum/README.md index d11ec6674..007e5bc29 100644 --- a/problems/constrained-subsequence-sum/README.md +++ b/problems/constrained-subsequence-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../diagonal-traverse-ii "Diagonal Traverse II") @@ -49,12 +49,12 @@ ### Related Topics - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Queue](../../tag/queue/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Monotonic Queue](../../tag/monotonic-queue/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] ### Hints
    diff --git a/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md b/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md index 2ac7d5a8c..a9cb8e9ca 100644 --- a/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md +++ b/problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-depth-of-binary-tree "Maximum Depth of Binary Tree") @@ -42,10 +42,10 @@ ### Related Topics + [[Tree](../../tag/tree/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] - [[Tree](../../tag/tree/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/construct-k-palindrome-strings/README.md b/problems/construct-k-palindrome-strings/README.md index 8b249b0a4..95c994cd8 100644 --- a/problems/construct-k-palindrome-strings/README.md +++ b/problems/construct-k-palindrome-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-largest-group "Count Largest Group") @@ -67,9 +67,9 @@ Some possible constructions "anna" + "elble", "anbna&qu ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Greedy](../../tag/greedy/README.md)] [[Counting](../../tag/counting/README.md)] ### Hints diff --git a/problems/construct-quad-tree/README.md b/problems/construct-quad-tree/README.md index 955215f0e..54e92d898 100644 --- a/problems/construct-quad-tree/README.md +++ b/problems/construct-quad-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-binary-search-tree-to-sorted-doubly-linked-list "Convert Binary Search Tree to Sorted Doubly Linked List") diff --git a/problems/construct-string-from-binary-tree/README.md b/problems/construct-string-from-binary-tree/README.md index da920e8d0..b1805ba12 100644 --- a/problems/construct-string-from-binary-tree/README.md +++ b/problems/construct-string-from-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../can-place-flowers "Can Place Flowers") @@ -11,7 +11,7 @@ ## [606. Construct String from Binary Tree (Easy)](https://leetcode.com/problems/construct-string-from-binary-tree "根据二叉树创建字符串") -

    Given the root of a binary tree, construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way, and return it.

    +

    Given the root of a binary tree, construct a string consisting of parenthesis and integers from a binary tree with the preorder traversal way, and return it.

    Omit all the empty parenthesis pairs that do not affect the one-to-one mapping relationship between the string and the original binary tree.

    @@ -21,7 +21,7 @@
     Input: root = [1,2,3,4]
     Output: "1(2(4))(3)"
    -Explanation: Originallay it needs to be "1(2(4)())(3()())", but you need to omit all the unnecessary empty parenthesis pairs. And it will be "1(2(4))(3)"
    +Explanation: Originally, it needs to be "1(2(4)())(3()())", but you need to omit all the unnecessary empty parenthesis pairs. And it will be "1(2(4))(3)"
     

    Example 2:

    @@ -29,7 +29,7 @@
     Input: root = [1,2,3,null,4]
     Output: "1(2()(4))(3)"
    -Explanation: Almost the same as the first example, except we cannot omit the first parenthesis pair to break the one-to-one mapping relationship between the input and the output.
    +Explanation: Almost the same as the first example, except we cannot omit the first parenthesis pair to break the one-to-one mapping relationship between the input and the output.
     

     

    @@ -41,9 +41,9 @@ Explanation: Almost the same as the first example, except we cannot omit the fir ### Related Topics + [[String](../../tag/string/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[String](../../tag/string/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/construct-target-array-with-multiple-sums/README.md b/problems/construct-target-array-with-multiple-sums/README.md index 3f029a70f..31a390147 100644 --- a/problems/construct-target-array-with-multiple-sums/README.md +++ b/problems/construct-target-array-with-multiple-sums/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-events-that-can-be-attended "Maximum Number of Events That Can Be Attended") diff --git a/problems/construct-the-lexicographically-largest-valid-sequence/README.md b/problems/construct-the-lexicographically-largest-valid-sequence/README.md index c922c5bf7..7a7a64fd4 100644 --- a/problems/construct-the-lexicographically-largest-valid-sequence/README.md +++ b/problems/construct-the-lexicographically-largest-valid-sequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-score-from-removing-substrings "Maximum Score From Removing Substrings") diff --git a/problems/contain-virus/README.md b/problems/contain-virus/README.md index 5dfaf0c02..4771a9807 100644 --- a/problems/contain-virus/README.md +++ b/problems/contain-virus/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-completing-word "Shortest Completing Word") diff --git a/problems/contains-duplicate-iii/README.md b/problems/contains-duplicate-iii/README.md index ea57af0ca..ded15be9d 100644 --- a/problems/contains-duplicate-iii/README.md +++ b/problems/contains-duplicate-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../contains-duplicate-ii "Contains Duplicate II") @@ -36,10 +36,10 @@ ### Related Topics [[Array](../../tag/array/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] - [[Sorting](../../tag/sorting/README.md)] [[Bucket Sort](../../tag/bucket-sort/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions 1. [Contains Duplicate](../contains-duplicate) (Easy) diff --git a/problems/contains-duplicate/README.md b/problems/contains-duplicate/README.md index 82e2e2365..ef9f2a2d2 100644 --- a/problems/contains-duplicate/README.md +++ b/problems/contains-duplicate/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../combination-sum-iii "Combination Sum III") diff --git a/problems/convert-1d-array-into-2d-array/README.md b/problems/convert-1d-array-into-2d-array/README.md index 923aab8fc..43070be5f 100644 --- a/problems/convert-1d-array-into-2d-array/README.md +++ b/problems/convert-1d-array-into-2d-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../brightest-position-on-street "Brightest Position on Street") diff --git a/problems/convert-bst-to-greater-tree/README.md b/problems/convert-bst-to-greater-tree/README.md index 03a2b8541..203b61449 100644 --- a/problems/convert-bst-to-greater-tree/README.md +++ b/problems/convert-bst-to-greater-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../complex-number-multiplication "Complex Number Multiplication") diff --git a/problems/convert-date-format/README.md b/problems/convert-date-format/README.md index 18ad540b6..3723629a4 100644 --- a/problems/convert-date-format/README.md +++ b/problems/convert-date-format/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../distinct-numbers-in-each-subarray "Distinct Numbers in Each Subarray") diff --git a/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md b/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md index 1d4bf848c..7f0be835b 100644 --- a/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md +++ b/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../distinct-echo-substrings "Distinct Echo Substrings") diff --git a/problems/convert-sorted-array-to-binary-search-tree/README.md b/problems/convert-sorted-array-to-binary-search-tree/README.md index 1a7403853..1a722bd23 100644 --- a/problems/convert-sorted-array-to-binary-search-tree/README.md +++ b/problems/convert-sorted-array-to-binary-search-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-tree-level-order-traversal-ii "Binary Tree Level Order Traversal II") diff --git a/problems/convert-to-base-2/README.md b/problems/convert-to-base-2/README.md index 485e14739..93f9120b6 100644 --- a/problems/convert-to-base-2/README.md +++ b/problems/convert-to-base-2/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-string-with-substrings-representing-1-to-n "Binary String With Substrings Representing 1 To N") diff --git a/problems/convex-polygon/README.md b/problems/convex-polygon/README.md index b98a4161f..866c02f6d 100644 --- a/problems/convex-polygon/README.md +++ b/problems/convex-polygon/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../validate-ip-address "Validate IP Address") diff --git a/problems/coordinate-with-maximum-network-quality/README.md b/problems/coordinate-with-maximum-network-quality/README.md index 826eb0d7e..91f1ce025 100644 --- a/problems/coordinate-with-maximum-network-quality/README.md +++ b/problems/coordinate-with-maximum-network-quality/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../mean-of-array-after-removing-some-elements "Mean of Array After Removing Some Elements") diff --git a/problems/correct-a-binary-tree/README.md b/problems/correct-a-binary-tree/README.md index 24a792f77..a98761723 100644 --- a/problems/correct-a-binary-tree/README.md +++ b/problems/correct-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximize-grid-happiness "Maximize Grid Happiness") @@ -14,16 +14,12 @@ ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] -### Similar Questions - 1. [Flatten Binary Tree to Linked List](../flatten-binary-tree-to-linked-list) (Medium) - 1. [Flatten a Multilevel Doubly Linked List](../flatten-a-multilevel-doubly-linked-list) (Medium) - ### Hints
    Hint 1 diff --git a/problems/count-all-possible-routes/README.md b/problems/count-all-possible-routes/README.md index 979194249..9dfddc3fe 100644 --- a/problems/count-all-possible-routes/README.md +++ b/problems/count-all-possible-routes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-subarray-to-be-removed-to-make-array-sorted "Shortest Subarray to be Removed to Make Array Sorted") @@ -11,15 +11,13 @@ ## [1575. Count All Possible Routes (Hard)](https://leetcode.com/problems/count-all-possible-routes "统计所有可行路径") -

    You are given an array of distinct positive integers locations where locations[i] represents the position of city i. You are also given integers startfinish and fuel representing the starting city, ending city, and the initial amount of fuel you have, respectively.

    +

    You are given an array of distinct positive integers locations where locations[i] represents the position of city i. You are also given integers start, finish and fuel representing the starting city, ending city, and the initial amount of fuel you have, respectively.

    -

    At each step, if you are at city i, you can pick any city j such that j != i and 0 <= j < locations.length and move to city j. Moving from city i to city j reduces the amount of fuel you have by |locations[i] - locations[j]|. Please notice that |x| denotes the absolute value of x.

    +

    At each step, if you are at city i, you can pick any city j such that j != i and 0 <= j < locations.length and move to city j. Moving from city i to city j reduces the amount of fuel you have by |locations[i] - locations[j]|. Please notice that |x| denotes the absolute value of x.

    -

    Notice that fuel cannot become negative at any point in time, and that you are allowed to visit any city more than once (including start and finish).

    +

    Notice that fuel cannot become negative at any point in time, and that you are allowed to visit any city more than once (including start and finish).

    -

    Return the count of all possible routes from start to finish.

    - -

    Since the answer may be too large, return it modulo 10^9 + 7.

    +

    Return the count of all possible routes from start to finish. Since the answer may be too large, return it modulo 109 + 7.

     

    Example 1:

    @@ -74,10 +72,10 @@
    • 2 <= locations.length <= 100
    • -
    • 1 <= locations[i] <= 10^9
    • -
    • All integers in locations are distinct.
    • -
    • 0 <= start, finish < locations.length
    • -
    • 1 <= fuel <= 200
    • +
    • 1 <= locations[i] <= 109
    • +
    • All integers in locations are distinct.
    • +
    • 0 <= start, finish < locations.length
    • +
    • 1 <= fuel <= 200
    ### Related Topics diff --git a/problems/count-apples-and-oranges/README.md b/problems/count-apples-and-oranges/README.md index b37077c6d..beb6557bc 100644 --- a/problems/count-apples-and-oranges/README.md +++ b/problems/count-apples-and-oranges/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-special-evenly-spaced-elements-in-array "Sum Of Special Evenly-Spaced Elements In Array") diff --git a/problems/count-good-meals/README.md b/problems/count-good-meals/README.md index e23d90e05..a79cf7106 100644 --- a/problems/count-good-meals/README.md +++ b/problems/count-good-meals/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-units-on-a-truck "Maximum Units on a Truck") @@ -48,10 +48,6 @@ Their respective sums are 4, 8, 8, and 16, all of which are powers of 2. [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] -### Similar Questions - 1. [Two Sum](../two-sum) (Easy) - 1. [Max Number of K-Sum Pairs](../max-number-of-k-sum-pairs) (Medium) - ### Hints
    Hint 1 diff --git a/problems/count-good-numbers/README.md b/problems/count-good-numbers/README.md index 58b46f11f..ab7e822a8 100644 --- a/problems/count-good-numbers/README.md +++ b/problems/count-good-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../eliminate-maximum-number-of-monsters "Eliminate Maximum Number of Monsters") diff --git a/problems/count-good-triplets/README.md b/problems/count-good-triplets/README.md index dc0e071a9..782b76d51 100644 --- a/problems/count-good-triplets/README.md +++ b/problems/count-good-triplets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-index-of-the-large-integer "Find the Index of the Large Integer") diff --git a/problems/count-items-matching-a-rule/README.md b/problems/count-items-matching-a-rule/README.md index 06bc64a51..0da1a676a 100644 --- a/problems/count-items-matching-a-rule/README.md +++ b/problems/count-items-matching-a-rule/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-features-by-popularity "Sort Features by Popularity") diff --git a/problems/count-largest-group/README.md b/problems/count-largest-group/README.md index 4f3aaf3a2..577545eae 100644 --- a/problems/count-largest-group/README.md +++ b/problems/count-largest-group/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../customers-who-bought-products-a-and-b-but-not-c "Customers Who Bought Products A and B but Not C") diff --git a/problems/count-negative-numbers-in-a-sorted-matrix/README.md b/problems/count-negative-numbers-in-a-sorted-matrix/README.md index 11c98a5ff..b9aac1ed8 100644 --- a/problems/count-negative-numbers-in-a-sorted-matrix/README.md +++ b/problems/count-negative-numbers-in-a-sorted-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../students-with-invalid-departments "Students With Invalid Departments") diff --git a/problems/count-nice-pairs-in-an-array/README.md b/problems/count-nice-pairs-in-an-array/README.md index 6aed91e6a..ce79ee89e 100644 --- a/problems/count-nice-pairs-in-an-array/README.md +++ b/problems/count-nice-pairs-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sentence-similarity-iii "Sentence Similarity III") diff --git a/problems/count-nodes-equal-to-sum-of-descendants/README.md b/problems/count-nodes-equal-to-sum-of-descendants/README.md index d528cc422..4edd6ed06 100644 --- a/problems/count-nodes-equal-to-sum-of-descendants/README.md +++ b/problems/count-nodes-equal-to-sum-of-descendants/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../first-and-last-call-on-the-same-day "First and Last Call On the Same Day") diff --git a/problems/count-nodes-with-the-highest-score/README.md b/problems/count-nodes-with-the-highest-score/README.md index cca15d348..1bab0218c 100644 --- a/problems/count-nodes-with-the-highest-score/README.md +++ b/problems/count-nodes-with-the-highest-score/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../next-greater-numerically-balanced-number "Next Greater Numerically Balanced Number") diff --git a/problems/count-number-of-homogenous-substrings/README.md b/problems/count-number-of-homogenous-substrings/README.md index 12e2e7e31..efa87ce86 100644 --- a/problems/count-number-of-homogenous-substrings/README.md +++ b/problems/count-number-of-homogenous-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-changes-to-make-alternating-binary-string "Minimum Changes To Make Alternating Binary String") @@ -59,10 +59,6 @@ [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] -### Similar Questions - 1. [Consecutive Characters](../consecutive-characters) (Easy) - 1. [Number of Substrings With Only 1s](../number-of-substrings-with-only-1s) (Medium) - ### Hints
    Hint 1 diff --git a/problems/count-number-of-maximum-bitwise-or-subsets/README.md b/problems/count-number-of-maximum-bitwise-or-subsets/README.md index 30e2c4f41..0a0609c00 100644 --- a/problems/count-number-of-maximum-bitwise-or-subsets/README.md +++ b/problems/count-number-of-maximum-bitwise-or-subsets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../simple-bank-system "Simple Bank System") diff --git a/problems/count-number-of-nice-subarrays/README.md b/problems/count-number-of-nice-subarrays/README.md index ad11c6a23..5a88c6c6a 100644 --- a/problems/count-number-of-nice-subarrays/README.md +++ b/problems/count-number-of-nice-subarrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-swaps-to-make-strings-equal "Minimum Swaps to Make Strings Equal") diff --git a/problems/count-number-of-pairs-with-absolute-difference-k/README.md b/problems/count-number-of-pairs-with-absolute-difference-k/README.md index 4cbf730a0..29e70cae0 100644 --- a/problems/count-number-of-pairs-with-absolute-difference-k/README.md +++ b/problems/count-number-of-pairs-with-absolute-difference-k/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../subtree-removal-game-with-fibonacci-tree "Subtree Removal Game with Fibonacci Tree") diff --git a/problems/count-number-of-special-subsequences/README.md b/problems/count-number-of-special-subsequences/README.md index 66ffca864..3871d7327 100644 --- a/problems/count-number-of-special-subsequences/README.md +++ b/problems/count-number-of-special-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-garden-perimeter-to-collect-enough-apples "Minimum Garden Perimeter to Collect Enough Apples") diff --git a/problems/count-numbers-with-unique-digits/README.md b/problems/count-numbers-with-unique-digits/README.md index 85c0da7f6..340f61812 100644 --- a/problems/count-numbers-with-unique-digits/README.md +++ b/problems/count-numbers-with-unique-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../line-reflection "Line Reflection") diff --git a/problems/count-odd-numbers-in-an-interval-range/README.md b/problems/count-odd-numbers-in-an-interval-range/README.md index 787c6b9c3..ded9c497f 100644 --- a/problems/count-odd-numbers-in-an-interval-range/README.md +++ b/problems/count-odd-numbers-in-an-interval-range/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../diameter-of-n-ary-tree "Diameter of N-Ary Tree") diff --git a/problems/count-of-matches-in-tournament/README.md b/problems/count-of-matches-in-tournament/README.md index 39e36fa7a..71e5c1cba 100644 --- a/problems/count-of-matches-in-tournament/README.md +++ b/problems/count-of-matches-in-tournament/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delivering-boxes-from-storage-to-ports "Delivering Boxes from Storage to Ports") diff --git a/problems/count-pairs-in-two-arrays/README.md b/problems/count-pairs-in-two-arrays/README.md index 315548881..f7cdb43e0 100644 --- a/problems/count-pairs-in-two-arrays/README.md +++ b/problems/count-pairs-in-two-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../egg-drop-with-2-eggs-and-n-floors "Egg Drop With 2 Eggs and N Floors") diff --git a/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md b/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md index 9a8db9c5d..cd3d037fd 100644 --- a/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md +++ b/problems/count-pairs-of-equal-substrings-with-minimum-difference/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-score-of-a-good-subarray "Maximum Score of a Good Subarray") diff --git a/problems/count-pairs-of-nodes/README.md b/problems/count-pairs-of-nodes/README.md index aa061db47..9678daee2 100644 --- a/problems/count-pairs-of-nodes/README.md +++ b/problems/count-pairs-of-nodes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-beauty-of-all-substrings "Sum of Beauty of All Substrings") @@ -58,9 +58,9 @@ The answers for each of the queries are as follows: ### Related Topics + [[Graph](../../tag/graph/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Graph](../../tag/graph/README.md)] ### Hints
    diff --git a/problems/count-pairs-with-xor-in-a-range/README.md b/problems/count-pairs-with-xor-in-a-range/README.md index 35ec7bfce..8195188bb 100644 --- a/problems/count-pairs-with-xor-in-a-range/README.md +++ b/problems/count-pairs-with-xor-in-a-range/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-value-at-a-given-index-in-a-bounded-array "Maximum Value at a Given Index in a Bounded Array") diff --git a/problems/count-salary-categories/README.md b/problems/count-salary-categories/README.md index 503298df1..5ca708082 100644 --- a/problems/count-salary-categories/README.md +++ b/problems/count-salary-categories/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-absolute-difference-queries "Minimum Absolute Difference Queries") diff --git a/problems/count-servers-that-communicate/README.md b/problems/count-servers-that-communicate/README.md index 77cb4e4a3..b5454c4ec 100644 --- a/problems/count-servers-that-communicate/README.md +++ b/problems/count-servers-that-communicate/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-time-visiting-all-points "Minimum Time Visiting All Points") @@ -57,12 +57,12 @@ Return the number of servers that communicate with any other server.

    ### Related Topics - [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Matrix](../../tag/matrix/README.md)] + [[Array](../../tag/array/README.md)] [[Counting](../../tag/counting/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/count-sorted-vowel-strings/README.md b/problems/count-sorted-vowel-strings/README.md index d65e1dafe..9f86adbcb 100644 --- a/problems/count-sorted-vowel-strings/README.md +++ b/problems/count-sorted-vowel-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-array-formation-through-concatenation "Check Array Formation Through Concatenation") diff --git a/problems/count-special-quadruplets/README.md b/problems/count-special-quadruplets/README.md index 4e3dd8ce3..d9938c15d 100644 --- a/problems/count-special-quadruplets/README.md +++ b/problems/count-special-quadruplets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-number-of-good-subsets "The Number of Good Subsets") diff --git a/problems/count-square-sum-triples/README.md b/problems/count-square-sum-triples/README.md index 9407c42a5..d9d046279 100644 --- a/problems/count-square-sum-triples/README.md +++ b/problems/count-square-sum-triples/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../erect-the-fence-ii "Erect the Fence II") diff --git a/problems/count-sub-islands/README.md b/problems/count-sub-islands/README.md index 11d21ca47..3bc57c1ed 100644 --- a/problems/count-sub-islands/README.md +++ b/problems/count-sub-islands/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-number-of-full-rounds-you-have-played "The Number of Full Rounds You Have Played") diff --git a/problems/count-subarrays-with-more-ones-than-zeros/README.md b/problems/count-subarrays-with-more-ones-than-zeros/README.md index c7f52a097..6b4eea3b1 100644 --- a/problems/count-subarrays-with-more-ones-than-zeros/README.md +++ b/problems/count-subarrays-with-more-ones-than-zeros/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-k-length-subsequence-with-occurrences-of-a-letter "Smallest K-Length Subsequence With Occurrences of a Letter") diff --git a/problems/count-submatrices-with-all-ones/README.md b/problems/count-submatrices-with-all-ones/README.md index 543f8cfc6..a142458a3 100644 --- a/problems/count-submatrices-with-all-ones/README.md +++ b/problems/count-submatrices-with-all-ones/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../last-moment-before-all-ants-fall-out-of-a-plank "Last Moment Before All Ants Fall Out of a Plank") @@ -11,64 +11,45 @@ ## [1504. Count Submatrices With All Ones (Medium)](https://leetcode.com/problems/count-submatrices-with-all-ones "统计全 1 子矩形") -

    Given a rows * columns matrix mat of ones and zeros, return how many submatrices have all ones.

    +

    Given an m x n binary matrix mat, return the number of submatrices that have all ones.

     

    Example 1:

    - +
    -Input: mat = [[1,0,1],
    -              [1,1,0],
    -              [1,1,0]]
    +Input: mat = [[1,0,1],[1,1,0],[1,1,0]]
     Output: 13
    -Explanation:
    -There are 6 rectangles of side 1x1.
    -There are 2 rectangles of side 1x2.
    -There are 3 rectangles of side 2x1.
    -There is 1 rectangle of side 2x2. 
    -There is 1 rectangle of side 3x1.
    -Total number of rectangles = 6 + 2 + 3 + 1 + 1 = 13.
    +Explanation: 
    +There are 6 rectangles of side 1x1.
    +There are 2 rectangles of side 1x2.
    +There are 3 rectangles of side 2x1.
    +There is 1 rectangle of side 2x2. 
    +There is 1 rectangle of side 3x1.
    +Total number of rectangles = 6 + 2 + 3 + 1 + 1 = 13.
     

    Example 2:

    - +
    -Input: mat = [[0,1,1,0],
    -              [0,1,1,1],
    -              [1,1,1,0]]
    +Input: mat = [[0,1,1,0],[0,1,1,1],[1,1,1,0]]
     Output: 24
    -Explanation:
    -There are 8 rectangles of side 1x1.
    -There are 5 rectangles of side 1x2.
    -There are 2 rectangles of side 1x3. 
    -There are 4 rectangles of side 2x1.
    -There are 2 rectangles of side 2x2. 
    -There are 2 rectangles of side 3x1. 
    -There is 1 rectangle of side 3x2. 
    -Total number of rectangles = 8 + 5 + 2 + 4 + 2 + 2 + 1 = 24.
    -
    - -

    Example 3:

    - -
    -Input: mat = [[1,1,1,1,1,1]]
    -Output: 21
    -
    - -

    Example 4:

    - -
    -Input: mat = [[1,0,1],[0,1,0],[1,0,1]]
    -Output: 5
    +Explanation: 
    +There are 8 rectangles of side 1x1.
    +There are 5 rectangles of side 1x2.
    +There are 2 rectangles of side 1x3. 
    +There are 4 rectangles of side 2x1.
    +There are 2 rectangles of side 2x2. 
    +There are 2 rectangles of side 3x1. 
    +There is 1 rectangle of side 3x2. 
    +Total number of rectangles = 8 + 5 + 2 + 4 + 2 + 2 + 1 = 24.
     

     

    Constraints:

      -
    • 1 <= rows <= 150
    • -
    • 1 <= columns <= 150
    • -
    • 0 <= mat[i][j] <= 1
    • +
    • 1 <= m, n <= 150
    • +
    • mat[i][j] is either 0 or 1.
    ### Related Topics diff --git a/problems/count-substrings-that-differ-by-one-character/README.md b/problems/count-substrings-that-differ-by-one-character/README.md index b69935728..dc837a236 100644 --- a/problems/count-substrings-that-differ-by-one-character/README.md +++ b/problems/count-substrings-that-differ-by-one-character/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../widest-vertical-area-between-two-points-containing-no-points "Widest Vertical Area Between Two Points Containing No Points") diff --git a/problems/count-substrings-with-only-one-distinct-letter/README.md b/problems/count-substrings-with-only-one-distinct-letter/README.md index 4636959fc..bb512697a 100644 --- a/problems/count-substrings-with-only-one-distinct-letter/README.md +++ b/problems/count-substrings-with-only-one-distinct-letter/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reformat-department-table "Reformat Department Table") diff --git a/problems/count-subtrees-with-max-distance-between-cities/README.md b/problems/count-subtrees-with-max-distance-between-cities/README.md index ce9398bf5..b2fafe331 100644 --- a/problems/count-subtrees-with-max-distance-between-cities/README.md +++ b/problems/count-subtrees-with-max-distance-between-cities/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../split-two-strings-to-make-palindrome "Split Two Strings to Make Palindrome") diff --git a/problems/count-the-number-of-consistent-strings/README.md b/problems/count-the-number-of-consistent-strings/README.md index c48a70fcf..e96a04d61 100644 --- a/problems/count-the-number-of-consistent-strings/README.md +++ b/problems/count-the-number-of-consistent-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../invalid-tweets "Invalid Tweets") @@ -52,10 +52,10 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/count-the-number-of-experiments/README.md b/problems/count-the-number-of-experiments/README.md index bbf85f974..004d98070 100644 --- a/problems/count-the-number-of-experiments/README.md +++ b/problems/count-the-number-of-experiments/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-people-that-can-be-caught-in-tag "Maximum Number of People That Can Be Caught in Tag") diff --git a/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md b/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md index 30c9275c0..db696b55f 100644 --- a/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md +++ b/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../build-an-array-with-stack-operations "Build an Array With Stack Operations") @@ -72,10 +72,10 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints diff --git a/problems/count-unhappy-friends/README.md b/problems/count-unhappy-friends/README.md index 15d272ff7..10eb99863 100644 --- a/problems/count-unhappy-friends/README.md +++ b/problems/count-unhappy-friends/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../special-positions-in-a-binary-matrix "Special Positions in a Binary Matrix") diff --git a/problems/count-vowel-substrings-of-a-string/README.md b/problems/count-vowel-substrings-of-a-string/README.md index baf298120..f66f9ed84 100644 --- a/problems/count-vowel-substrings-of-a-string/README.md +++ b/problems/count-vowel-substrings-of-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-spaces-cleaning-robot-cleaned "Number of Spaces Cleaning Robot Cleaned") diff --git a/problems/count-vowels-permutation/README.md b/problems/count-vowels-permutation/README.md index 31af29368..ea4985e9b 100644 --- a/problems/count-vowels-permutation/README.md +++ b/problems/count-vowels-permutation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-with-maximum-gold "Path with Maximum Gold") diff --git a/problems/count-ways-to-build-rooms-in-an-ant-colony/README.md b/problems/count-ways-to-build-rooms-in-an-ant-colony/README.md index 14dfe8447..60c14efc3 100644 --- a/problems/count-ways-to-build-rooms-in-an-ant-colony/README.md +++ b/problems/count-ways-to-build-rooms-in-an-ant-colony/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-wonderful-substrings "Number of Wonderful Substrings") diff --git a/problems/count-ways-to-distribute-candies/README.md b/problems/count-ways-to-distribute-candies/README.md index 6c08f4c9c..e84290d1c 100644 --- a/problems/count-ways-to-distribute-candies/README.md +++ b/problems/count-ways-to-distribute-candies/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-height-by-stacking-cuboids "Maximum Height by Stacking Cuboids ") diff --git a/problems/count-ways-to-make-array-with-product/README.md b/problems/count-ways-to-make-array-with-product/README.md index 52c4da44f..e96f4859a 100644 --- a/problems/count-ways-to-make-array-with-product/README.md +++ b/problems/count-ways-to-make-array-with-product/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../decode-xored-permutation "Decode XORed Permutation") diff --git a/problems/counting-elements/README.md b/problems/counting-elements/README.md index 11326dfda..5b85f3d94 100644 --- a/problems/counting-elements/README.md +++ b/problems/counting-elements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../constrained-subsequence-sum "Constrained Subsequence Sum") diff --git a/problems/countries-you-can-safely-invest-in/README.md b/problems/countries-you-can-safely-invest-in/README.md index eac2822ed..0450b8cee 100644 --- a/problems/countries-you-can-safely-invest-in/README.md +++ b/problems/countries-you-can-safely-invest-in/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-a-file-sharing-system "Design a File Sharing System") diff --git a/problems/course-schedule-ii/README.md b/problems/course-schedule-ii/README.md index 877d068c6..e84e3bcf3 100644 --- a/problems/course-schedule-ii/README.md +++ b/problems/course-schedule-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-size-subarray-sum "Minimum Size Subarray Sum") @@ -68,6 +68,7 @@ So one correct course order is [0,1,2,3]. Another correct ordering is [0,2,1,3]. 1. [Minimum Height Trees](../minimum-height-trees) (Medium) 1. [Sequence Reconstruction](../sequence-reconstruction) (Medium) 1. [Course Schedule III](../course-schedule-iii) (Hard) + 1. [Parallel Courses](../parallel-courses) (Medium) ### Hints
    diff --git a/problems/course-schedule-iii/README.md b/problems/course-schedule-iii/README.md index d9d50a174..bdfa941a0 100644 --- a/problems/course-schedule-iii/README.md +++ b/problems/course-schedule-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../k-inverse-pairs-array "K Inverse Pairs Array") @@ -54,8 +54,8 @@ The 4th course cannot be taken now, since you will finish it on the 3 ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions diff --git a/problems/course-schedule-iv/README.md b/problems/course-schedule-iv/README.md index 097eec13c..261ed9931 100644 --- a/problems/course-schedule-iv/README.md +++ b/problems/course-schedule-iv/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-a-string-contains-all-binary-codes-of-size-k "Check If a String Contains All Binary Codes of Size K") diff --git a/problems/cracking-the-safe/README.md b/problems/cracking-the-safe/README.md index 9682f5adb..17db621dd 100644 --- a/problems/cracking-the-safe/README.md +++ b/problems/cracking-the-safe/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../open-the-lock "Open the Lock") diff --git a/problems/crawler-log-folder/README.md b/problems/crawler-log-folder/README.md index 7b39d13fa..dc6240635 100644 --- a/problems/crawler-log-folder/README.md +++ b/problems/crawler-log-folder/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../build-binary-expression-tree-from-infix-expression "Build Binary Expression Tree From Infix Expression") diff --git a/problems/create-maximum-number/README.md b/problems/create-maximum-number/README.md index 6b7047a53..a556c1b4b 100644 --- a/problems/create-maximum-number/README.md +++ b/problems/create-maximum-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../generalized-abbreviation "Generalized Abbreviation") diff --git a/problems/create-sorted-array-through-instructions/README.md b/problems/create-sorted-array-through-instructions/README.md index d91cd5108..7143b44aa 100644 --- a/problems/create-sorted-array-through-instructions/README.md +++ b/problems/create-sorted-array-through-instructions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sell-diminishing-valued-colored-balls "Sell Diminishing-Valued Colored Balls") diff --git a/problems/customer-order-frequency/README.md b/problems/customer-order-frequency/README.md index 866f4d346..c683e39f5 100644 --- a/problems/customer-order-frequency/README.md +++ b/problems/customer-order-frequency/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game-iv "Stone Game IV") diff --git a/problems/customer-placing-the-largest-number-of-orders/README.md b/problems/customer-placing-the-largest-number-of-orders/README.md index 6585eb972..e00893cb3 100644 --- a/problems/customer-placing-the-largest-number-of-orders/README.md +++ b/problems/customer-placing-the-largest-number-of-orders/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../investments-in-2016 "Investments in 2016") diff --git a/problems/customer-who-visited-but-did-not-make-any-transactions/README.md b/problems/customer-who-visited-but-did-not-make-any-transactions/README.md index 128f84e0c..c37bf735d 100644 --- a/problems/customer-who-visited-but-did-not-make-any-transactions/README.md +++ b/problems/customer-who-visited-but-did-not-make-any-transactions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../put-boxes-into-the-warehouse-ii "Put Boxes Into the Warehouse II") diff --git a/problems/customers-who-bought-products-a-and-b-but-not-c/README.md b/problems/customers-who-bought-products-a-and-b-but-not-c/README.md index 50dfe74b7..443bb7664 100644 --- a/problems/customers-who-bought-products-a-and-b-but-not-c/README.md +++ b/problems/customers-who-bought-products-a-and-b-but-not-c/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-all-good-strings "Find All Good Strings") diff --git a/problems/customers-who-never-order/README.md b/problems/customers-who-never-order/README.md index 91232a781..470908e17 100644 --- a/problems/customers-who-never-order/README.md +++ b/problems/customers-who-never-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../duplicate-emails "Duplicate Emails") diff --git a/problems/cutting-ribbons/README.md b/problems/cutting-ribbons/README.md index f9032d076..6d7c7f13c 100644 --- a/problems/cutting-ribbons/README.md +++ b/problems/cutting-ribbons/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-latest-login-in-2020 "The Latest Login in 2020") @@ -17,6 +17,10 @@ [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] +### Similar Questions + 1. [Capacity To Ship Packages Within D Days](../capacity-to-ship-packages-within-d-days) (Medium) + 1. [Add Minimum Number of Rungs](../add-minimum-number-of-rungs) (Medium) + ### Hints
    Hint 1 diff --git a/problems/cyclically-rotating-a-grid/README.md b/problems/cyclically-rotating-a-grid/README.md index 827d5058b..bd3a7fc9f 100644 --- a/problems/cyclically-rotating-a-grid/README.md +++ b/problems/cyclically-rotating-a-grid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-product-difference-between-two-pairs "Maximum Product Difference Between Two Pairs") diff --git a/problems/daily-leads-and-partners/README.md b/problems/daily-leads-and-partners/README.md index 68f708978..299b0bd44 100644 --- a/problems/daily-leads-and-partners/README.md +++ b/problems/daily-leads-and-partners/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-ways-to-distribute-candies "Count Ways to Distribute Candies") diff --git a/problems/daily-temperatures/README.md b/problems/daily-temperatures/README.md index 39b5d4714..ff6a70607 100644 --- a/problems/daily-temperatures/README.md +++ b/problems/daily-temperatures/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../monotone-increasing-digits "Monotone Increasing Digits") @@ -33,13 +33,12 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Similar Questions 1. [Next Greater Element I](../next-greater-element-i) (Easy) - 1. [Online Stock Span](../online-stock-span) (Medium) ### Hints
    diff --git a/problems/day-of-the-week/README.md b/problems/day-of-the-week/README.md index f582f978c..9ffca921a 100644 --- a/problems/day-of-the-week/README.md +++ b/problems/day-of-the-week/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../distance-between-bus-stops "Distance Between Bus Stops") diff --git a/problems/decode-the-slanted-ciphertext/README.md b/problems/decode-the-slanted-ciphertext/README.md index 9e67b65fe..413cba302 100644 --- a/problems/decode-the-slanted-ciphertext/README.md +++ b/problems/decode-the-slanted-ciphertext/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-nodes-in-even-length-groups "Reverse Nodes in Even Length Groups") diff --git a/problems/decode-ways-ii/README.md b/problems/decode-ways-ii/README.md index 0ce394d3a..d8a78212b 100644 --- a/problems/decode-ways-ii/README.md +++ b/problems/decode-ways-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shopping-offers "Shopping Offers") @@ -80,3 +80,4 @@ Hence, there are a total of (6 * 2) + (3 * 1) = 12 + 3 = 15 ways to decode " ### Similar Questions 1. [Decode Ways](../decode-ways) (Medium) + 1. [Number of Ways to Separate Numbers](../number-of-ways-to-separate-numbers) (Hard) diff --git a/problems/decode-xored-array/README.md b/problems/decode-xored-array/README.md index 9a3191419..a1431e45a 100644 --- a/problems/decode-xored-array/README.md +++ b/problems/decode-xored-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-reconstruct-a-tree "Number Of Ways To Reconstruct A Tree") @@ -46,8 +46,8 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/decode-xored-permutation/README.md b/problems/decode-xored-permutation/README.md index acf817fd1..c848d7942 100644 --- a/problems/decode-xored-permutation/README.md +++ b/problems/decode-xored-permutation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-people-to-teach "Minimum Number of People to Teach") diff --git a/problems/decoded-string-at-index/README.md b/problems/decoded-string-at-index/README.md index 23e24d9b4..db82b21f2 100644 --- a/problems/decoded-string-at-index/README.md +++ b/problems/decoded-string-at-index/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../profitable-schemes "Profitable Schemes") diff --git a/problems/decompress-run-length-encoded-list/README.md b/problems/decompress-run-length-encoded-list/README.md index 9d28d4d54..cda578f8a 100644 --- a/problems/decompress-run-length-encoded-list/README.md +++ b/problems/decompress-run-length-encoded-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-insertion-steps-to-make-a-string-palindrome "Minimum Insertion Steps to Make a String Palindrome") @@ -47,6 +47,9 @@ At the end the concatenation [2] + [4,4,4] is [2,4,4,4]. ### Related Topics [[Array](../../tag/array/README.md)] +### Similar Questions + 1. [String Compression](../string-compression) (Medium) + ### Hints
    Hint 1 diff --git a/problems/decrease-elements-to-make-array-zigzag/README.md b/problems/decrease-elements-to-make-array-zigzag/README.md index 66c9ddb1e..1abcb21e0 100644 --- a/problems/decrease-elements-to-make-array-zigzag/README.md +++ b/problems/decrease-elements-to-make-array-zigzag/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-common-subsequence "Longest Common Subsequence") diff --git a/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md b/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md index ebfe6aaa5..e7eb154e6 100644 --- a/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md +++ b/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../running-total-for-different-genders "Running Total for Different Genders") diff --git a/problems/defanging-an-ip-address/README.md b/problems/defanging-an-ip-address/README.md index 916337166..1a89b5589 100644 --- a/problems/defanging-an-ip-address/README.md +++ b/problems/defanging-an-ip-address/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../new-users-daily-count "New Users Daily Count") diff --git a/problems/defuse-the-bomb/README.md b/problems/defuse-the-bomb/README.md index 49481547e..efc8b1b80 100644 --- a/problems/defuse-the-bomb/README.md +++ b/problems/defuse-the-bomb/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../hopper-company-queries-iii "Hopper Company Queries III") diff --git a/problems/delete-characters-to-make-fancy-string/README.md b/problems/delete-characters-to-make-fancy-string/README.md index a97b0bf67..786cb11c1 100644 --- a/problems/delete-characters-to-make-fancy-string/README.md +++ b/problems/delete-characters-to-make-fancy-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-time-for-k-virus-variants-to-spread "Minimum Time For K Virus Variants to Spread") diff --git a/problems/delete-duplicate-folders-in-system/README.md b/problems/delete-duplicate-folders-in-system/README.md index 1ea8b1a42..4bb81e72f 100644 --- a/problems/delete-duplicate-folders-in-system/README.md +++ b/problems/delete-duplicate-folders-in-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-compatibility-score-sum "Maximum Compatibility Score Sum") diff --git a/problems/delete-leaves-with-a-given-value/README.md b/problems/delete-leaves-with-a-given-value/README.md index e8074f8c2..d581caa4a 100644 --- a/problems/delete-leaves-with-a-given-value/README.md +++ b/problems/delete-leaves-with-a-given-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../print-words-vertically "Print Words Vertically") @@ -70,10 +70,10 @@ After removing, new nodes become leaf nodes with value (target = 2) (Picture in ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/delete-node-in-a-linked-list/README.md b/problems/delete-node-in-a-linked-list/README.md index 2348ae696..232dc471f 100644 --- a/problems/delete-node-in-a-linked-list/README.md +++ b/problems/delete-node-in-a-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lowest-common-ancestor-of-a-binary-tree "Lowest Common Ancestor of a Binary Tree") diff --git a/problems/delete-nodes-and-return-forest/README.md b/problems/delete-nodes-and-return-forest/README.md index 9d7a41d13..0260c45dd 100644 --- a/problems/delete-nodes-and-return-forest/README.md +++ b/problems/delete-nodes-and-return-forest/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../corporate-flight-bookings "Corporate Flight Bookings") diff --git a/problems/delete-tree-nodes/README.md b/problems/delete-tree-nodes/README.md index afe244584..c355e3823 100644 --- a/problems/delete-tree-nodes/README.md +++ b/problems/delete-tree-nodes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-interval "Remove Interval") diff --git a/problems/delivering-boxes-from-storage-to-ports/README.md b/problems/delivering-boxes-from-storage-to-ports/README.md index a47b58504..a282ef700 100644 --- a/problems/delivering-boxes-from-storage-to-ports/README.md +++ b/problems/delivering-boxes-from-storage-to-ports/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game-vi "Stone Game VI") diff --git a/problems/depth-of-bst-given-insertion-order/README.md b/problems/depth-of-bst-given-insertion-order/README.md index f7279a921..87f0d6196 100644 --- a/problems/depth-of-bst-given-insertion-order/README.md +++ b/problems/depth-of-bst-given-insertion-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-a-peak-element-ii "Find a Peak Element II") diff --git a/problems/describe-the-painting/README.md b/problems/describe-the-painting/README.md index 6df82efe4..edda7d60e 100644 --- a/problems/describe-the-painting/README.md +++ b/problems/describe-the-painting/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-number-of-the-smallest-unoccupied-chair "The Number of the Smallest Unoccupied Chair") diff --git a/problems/design-a-file-sharing-system/README.md b/problems/design-a-file-sharing-system/README.md index 08163d1c0..0eee8641a 100644 --- a/problems/design-a-file-sharing-system/README.md +++ b/problems/design-a-file-sharing-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-value-of-equation "Max Value of Equation") @@ -14,13 +14,10 @@ ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] [[Design](../../tag/design/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Data Stream](../../tag/data-stream/README.md)] - -### Similar Questions - 1. [Design Twitter](../design-twitter) (Medium) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/design-a-leaderboard/README.md b/problems/design-a-leaderboard/README.md index b7b2e63b3..8d0f86afa 100644 --- a/problems/design-a-leaderboard/README.md +++ b/problems/design-a-leaderboard/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../array-transformation "Array Transformation") @@ -56,8 +56,8 @@ leaderboard.top(3); // returns 141 = 51 + 51 + 39; ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Design](../../tag/design/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/design-a-stack-with-increment-operation/README.md b/problems/design-a-stack-with-increment-operation/README.md index 3266fbabb..136646831 100644 --- a/problems/design-a-stack-with-increment-operation/README.md +++ b/problems/design-a-stack-with-increment-operation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lucky-numbers-in-a-matrix "Lucky Numbers in a Matrix") diff --git a/problems/design-an-expression-tree-with-evaluate-function/README.md b/problems/design-an-expression-tree-with-evaluate-function/README.md index da44203bf..1a7b65ecc 100644 --- a/problems/design-an-expression-tree-with-evaluate-function/README.md +++ b/problems/design-an-expression-tree-with-evaluate-function/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../graph-connectivity-with-threshold "Graph Connectivity With Threshold") diff --git a/problems/design-an-ordered-stream/README.md b/problems/design-an-ordered-stream/README.md index 4b55be2b0..33f5fb0c2 100644 --- a/problems/design-an-ordered-stream/README.md +++ b/problems/design-an-ordered-stream/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../distribute-repeating-integers "Distribute Repeating Integers") diff --git a/problems/design-authentication-manager/README.md b/problems/design-authentication-manager/README.md index 8bf9e9234..9a190e5aa 100644 --- a/problems/design-authentication-manager/README.md +++ b/problems/design-authentication-manager/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../second-largest-digit-in-a-string "Second Largest Digit in a String") diff --git a/problems/design-bounded-blocking-queue/README.md b/problems/design-bounded-blocking-queue/README.md index 3a2a2fab3..70fd07167 100644 --- a/problems/design-bounded-blocking-queue/README.md +++ b/problems/design-bounded-blocking-queue/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../make-array-strictly-increasing "Make Array Strictly Increasing") diff --git a/problems/design-browser-history/README.md b/problems/design-browser-history/README.md index 9a8ea0750..54bb7bfee 100644 --- a/problems/design-browser-history/README.md +++ b/problems/design-browser-history/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-k-strongest-values-in-an-array "The k Strongest Values in an Array") @@ -58,12 +58,12 @@ browserHistory.back(7); // You are in "google.com", ### Related Topics - [[Stack](../../tag/stack/README.md)] - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Linked List](../../tag/linked-list/README.md)] - [[Data Stream](../../tag/data-stream/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Design](../../tag/design/README.md)] [[Doubly-Linked List](../../tag/doubly-linked-list/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] ### Hints
    diff --git a/problems/design-circular-deque/README.md b/problems/design-circular-deque/README.md index 967350e2d..06669c2c1 100644 --- a/problems/design-circular-deque/README.md +++ b/problems/design-circular-deque/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../solve-the-equation "Solve the Equation") diff --git a/problems/design-circular-queue/README.md b/problems/design-circular-queue/README.md index 06ee8a6a0..ac1b86d00 100644 --- a/problems/design-circular-queue/README.md +++ b/problems/design-circular-queue/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../task-scheduler "Task Scheduler") diff --git a/problems/design-compressed-string-iterator/README.md b/problems/design-compressed-string-iterator/README.md index 4b87314c6..d6072bc36 100644 --- a/problems/design-compressed-string-iterator/README.md +++ b/problems/design-compressed-string-iterator/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../consecutive-available-seats "Consecutive Available Seats") diff --git a/problems/design-front-middle-back-queue/README.md b/problems/design-front-middle-back-queue/README.md index be57778c1..2d57da3a1 100644 --- a/problems/design-front-middle-back-queue/README.md +++ b/problems/design-front-middle-back-queue/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../merge-in-between-linked-lists "Merge In Between Linked Lists") @@ -64,16 +64,12 @@ q.popFront(); // return -1 -> [] (The queue is empty) ### Related Topics - [[Array](../../tag/array/README.md)] - [[Linked List](../../tag/linked-list/README.md)] [[Design](../../tag/design/README.md)] [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Linked List](../../tag/linked-list/README.md)] [[Data Stream](../../tag/data-stream/README.md)] -### Similar Questions - 1. [Design Circular Deque](../design-circular-deque) (Medium) - 1. [Design Circular Queue](../design-circular-queue) (Medium) - ### Hints
    Hint 1 diff --git a/problems/design-hit-counter/README.md b/problems/design-hit-counter/README.md index 48309965b..e094f0392 100644 --- a/problems/design-hit-counter/README.md +++ b/problems/design-hit-counter/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../bomb-enemy "Bomb Enemy") @@ -48,11 +48,11 @@ counter.getHits(301); What if the number of hits per second could be very large? Does your design scale?

    ### Related Topics - [[Design](../../tag/design/README.md)] - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Design](../../tag/design/README.md)] + [[Queue](../../tag/queue/README.md)] ### Similar Questions 1. [Logger Rate Limiter](../logger-rate-limiter) (Easy) diff --git a/problems/design-in-memory-file-system/README.md b/problems/design-in-memory-file-system/README.md index 06066a926..4c8354284 100644 --- a/problems/design-in-memory-file-system/README.md +++ b/problems/design-in-memory-file-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../erect-the-fence "Erect the Fence") @@ -47,10 +47,10 @@ ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] - [[String](../../tag/string/README.md)] [[Design](../../tag/design/README.md)] [[Trie](../../tag/trie/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [LRU Cache](../lru-cache) (Medium) diff --git a/problems/design-log-storage-system/README.md b/problems/design-log-storage-system/README.md index 9537e98a4..1560bb852 100644 --- a/problems/design-log-storage-system/README.md +++ b/problems/design-log-storage-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-derangement-of-an-array "Find the Derangement of An Array") diff --git a/problems/design-most-recently-used-queue/README.md b/problems/design-most-recently-used-queue/README.md index 12dfa1e0a..b2b8f0d02 100644 --- a/problems/design-most-recently-used-queue/README.md +++ b/problems/design-most-recently-used-queue/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../closest-subsequence-sum "Closest Subsequence Sum") @@ -14,16 +14,13 @@ ### Related Topics - [[Array](../../tag/array/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Stack](../../tag/stack/README.md)] [[Design](../../tag/design/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] -### Similar Questions - 1. [LRU Cache](../lru-cache) (Medium) - ### Hints
    Hint 1 diff --git a/problems/design-movie-rental-system/README.md b/problems/design-movie-rental-system/README.md index bb43f98e6..7d30137c7 100644 --- a/problems/design-movie-rental-system/README.md +++ b/problems/design-movie-rental-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-alternating-subsequence-sum "Maximum Alternating Subsequence Sum") diff --git a/problems/design-parking-system/README.md b/problems/design-parking-system/README.md index eaca5e40e..c3e886f43 100644 --- a/problems/design-parking-system/README.md +++ b/problems/design-parking-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-nearest-right-node-in-binary-tree "Find Nearest Right Node in Binary Tree") @@ -49,8 +49,8 @@ parkingSystem.addCar(1); // return false because there is no available slot for ### Related Topics [[Design](../../tag/design/README.md)] - [[Simulation](../../tag/simulation/README.md)] [[Counting](../../tag/counting/README.md)] + [[Simulation](../../tag/simulation/README.md)] ### Hints
    diff --git a/problems/design-phone-directory/README.md b/problems/design-phone-directory/README.md index d8d66629f..b25857881 100644 --- a/problems/design-phone-directory/README.md +++ b/problems/design-phone-directory/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-smallest-element-in-a-sorted-matrix "Kth Smallest Element in a Sorted Matrix") diff --git a/problems/design-search-autocomplete-system/README.md b/problems/design-search-autocomplete-system/README.md index 6e35c7d5b..a42e4d98b 100644 --- a/problems/design-search-autocomplete-system/README.md +++ b/problems/design-search-autocomplete-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-circular-deque "Design Circular Deque") diff --git a/problems/design-skiplist/README.md b/problems/design-skiplist/README.md index c79f5f35d..c4e2f39fa 100644 --- a/problems/design-skiplist/README.md +++ b/problems/design-skiplist/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../monthly-transactions-ii "Monthly Transactions II") @@ -66,10 +66,5 @@ skiplist.search(1); // return False, 1 has already been erased. ### Related Topics - [[Linked List](../../tag/linked-list/README.md)] [[Design](../../tag/design/README.md)] - -### Similar Questions - 1. [Design HashSet](../design-hashset) (Easy) - 1. [Design HashMap](../design-hashmap) (Easy) - 1. [Design Linked List](../design-linked-list) (Medium) + [[Linked List](../../tag/linked-list/README.md)] diff --git a/problems/design-underground-system/README.md b/problems/design-underground-system/README.md index ad50b7a3d..3c3d61dd4 100644 --- a/problems/design-underground-system/README.md +++ b/problems/design-underground-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-number-of-teams "Count Number of Teams") diff --git a/problems/destination-city/README.md b/problems/destination-city/README.md index 9bf4e8971..37239c418 100644 --- a/problems/destination-city/README.md +++ b/problems/destination-city/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../create-a-session-bar-chart "Create a Session Bar Chart") diff --git a/problems/detect-capital/README.md b/problems/detect-capital/README.md index 203f2448a..c37869020 100644 --- a/problems/detect-capital/README.md +++ b/problems/detect-capital/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../random-flip-matrix "Random Flip Matrix") diff --git a/problems/detect-cycles-in-2d-grid/README.md b/problems/detect-cycles-in-2d-grid/README.md index e48734252..da2157e5e 100644 --- a/problems/detect-cycles-in-2d-grid/README.md +++ b/problems/detect-cycles-in-2d-grid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-numbers-of-function-calls-to-make-target-array "Minimum Numbers of Function Calls to Make Target Array") diff --git a/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md b/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md index 42cd38d62..e154bfa69 100644 --- a/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md +++ b/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../unique-orders-and-customers-per-month "Unique Orders and Customers Per Month") @@ -72,9 +72,6 @@ [[Array](../../tag/array/README.md)] [[Enumeration](../../tag/enumeration/README.md)] -### Similar Questions - 1. [Maximum Repeating Substring](../maximum-repeating-substring) (Easy) - ### Hints
    Hint 1 diff --git a/problems/detect-squares/README.md b/problems/detect-squares/README.md index 2d618bc66..982fcb70c 100644 --- a/problems/detect-squares/README.md +++ b/problems/detect-squares/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-beauty-in-the-array "Sum of Beauty in the Array") diff --git a/problems/determine-color-of-a-chessboard-square/README.md b/problems/determine-color-of-a-chessboard-square/README.md index dfe83e935..defbbb33c 100644 --- a/problems/determine-color-of-a-chessboard-square/README.md +++ b/problems/determine-color-of-a-chessboard-square/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-interview-candidates "Find Interview Candidates") diff --git a/problems/determine-if-string-halves-are-alike/README.md b/problems/determine-if-string-halves-are-alike/README.md index c087e409a..c436e1ff8 100644 --- a/problems/determine-if-string-halves-are-alike/README.md +++ b/problems/determine-if-string-halves-are-alike/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-adjacent-swaps-for-k-consecutive-ones "Minimum Adjacent Swaps for K Consecutive Ones") diff --git a/problems/determine-if-two-strings-are-close/README.md b/problems/determine-if-two-strings-are-close/README.md index 05e1a68f6..9da101df9 100644 --- a/problems/determine-if-two-strings-are-close/README.md +++ b/problems/determine-if-two-strings-are-close/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-an-ordered-stream "Design an Ordered Stream") @@ -81,6 +81,11 @@ Apply Operation 2: "baaccc" -> "abbccc" [[String](../../tag/string/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Buddy Strings](../buddy-strings) (Easy) + 1. [Minimum Swaps to Make Strings Equal](../minimum-swaps-to-make-strings-equal) (Medium) + 1. [Minimum Number of Steps to Make Two Strings Anagram](../minimum-number-of-steps-to-make-two-strings-anagram) (Medium) + ### Hints
    Hint 1 diff --git a/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md b/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md index 552837e15..3f86bc907 100644 --- a/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md +++ b/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-pairs-in-two-arrays "Count Pairs in Two Arrays") diff --git a/problems/diagonal-traverse-ii/README.md b/problems/diagonal-traverse-ii/README.md index e05a840e1..89e88c505 100644 --- a/problems/diagonal-traverse-ii/README.md +++ b/problems/diagonal-traverse-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-points-you-can-obtain-from-cards "Maximum Points You Can Obtain from Cards") diff --git a/problems/diagonal-traverse/README.md b/problems/diagonal-traverse/README.md index 47dfd76a5..54d674860 100644 --- a/problems/diagonal-traverse/README.md +++ b/problems/diagonal-traverse/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../random-point-in-non-overlapping-rectangles "Random Point in Non-overlapping Rectangles") @@ -43,3 +43,6 @@ [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Simulation](../../tag/simulation/README.md)] + +### Similar Questions + 1. [Decode the Slanted Ciphertext](../decode-the-slanted-ciphertext) (Medium) diff --git a/problems/diameter-of-n-ary-tree/README.md b/problems/diameter-of-n-ary-tree/README.md index fd9fe85c0..23080aa67 100644 --- a/problems/diameter-of-n-ary-tree/README.md +++ b/problems/diameter-of-n-ary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-a-value-of-a-mysterious-function-closest-to-target "Find a Value of a Mysterious Function Closest to Target") diff --git a/problems/dice-roll-simulation/README.md b/problems/dice-roll-simulation/README.md index 861c5d154..5bcd14155 100644 --- a/problems/dice-roll-simulation/README.md +++ b/problems/dice-roll-simulation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../queens-that-can-attack-the-king "Queens That Can Attack the King") @@ -53,6 +53,9 @@ [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Find Missing Observations](../find-missing-observations) (Medium) + ### Hints
    Hint 1 diff --git a/problems/diet-plan-performance/README.md b/problems/diet-plan-performance/README.md index e13b90c53..8a830f600 100644 --- a/problems/diet-plan-performance/README.md +++ b/problems/diet-plan-performance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../prime-arrangements "Prime Arrangements") diff --git a/problems/different-ways-to-add-parentheses/README.md b/problems/different-ways-to-add-parentheses/README.md index 970b12558..7846b8a73 100644 --- a/problems/different-ways-to-add-parentheses/README.md +++ b/problems/different-ways-to-add-parentheses/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../search-a-2d-matrix-ii "Search a 2D Matrix II") diff --git a/problems/dinner-plate-stacks/README.md b/problems/dinner-plate-stacks/README.md index 538937cca..3536498dd 100644 --- a/problems/dinner-plate-stacks/README.md +++ b/problems/dinner-plate-stacks/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-zero-sum-consecutive-nodes-from-linked-list "Remove Zero Sum Consecutive Nodes from Linked List") @@ -78,9 +78,9 @@ D.pop() // Returns -1. There are still no stacks. ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Stack](../../tag/stack/README.md)] [[Design](../../tag/design/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/distance-between-bus-stops/README.md b/problems/distance-between-bus-stops/README.md index 1d919d552..f94b2ff73 100644 --- a/problems/distance-between-bus-stops/README.md +++ b/problems/distance-between-bus-stops/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-ones "Maximum Number of Ones") diff --git a/problems/distant-barcodes/README.md b/problems/distant-barcodes/README.md index 2915f6b4b..cf6019f5a 100644 --- a/problems/distant-barcodes/README.md +++ b/problems/distant-barcodes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../previous-permutation-with-one-swap "Previous Permutation With One Swap") diff --git a/problems/distinct-echo-substrings/README.md b/problems/distinct-echo-substrings/README.md index e5f514e7d..de3a4e081 100644 --- a/problems/distinct-echo-substrings/README.md +++ b/problems/distinct-echo-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-nodes-with-even-valued-grandparent "Sum of Nodes with Even-Valued Grandparent") diff --git a/problems/distinct-numbers-in-each-subarray/README.md b/problems/distinct-numbers-in-each-subarray/README.md index a6e1ecaf6..7f5aeec91 100644 --- a/problems/distinct-numbers-in-each-subarray/README.md +++ b/problems/distinct-numbers-in-each-subarray/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-interval-to-include-each-query "Minimum Interval to Include Each Query") diff --git a/problems/distinct-subsequences/README.md b/problems/distinct-subsequences/README.md index 4dddc80bc..56f06d216 100644 --- a/problems/distinct-subsequences/README.md +++ b/problems/distinct-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flatten-binary-tree-to-linked-list "Flatten Binary Tree to Linked List") @@ -15,7 +15,7 @@

    A string's subsequence is a new string formed from the original string by deleting some (can be none) of the characters without disturbing the remaining characters' relative positions. (i.e., "ACE" is a subsequence of "ABCDE" while "AEC" is not).

    -

    It is guaranteed the answer fits on a 32-bit signed integer.

    +

    The test cases are generated so that the answer fits on a 32-bit signed integer.

     

    Example 1:

    @@ -54,3 +54,6 @@ As shown below, there are 5 ways you can generate "bag" from S. ### Related Topics [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Similar Questions + 1. [Number of Unique Good Subsequences](../number-of-unique-good-subsequences) (Hard) diff --git a/problems/distribute-candies-to-people/README.md b/problems/distribute-candies-to-people/README.md index 27495dffc..e593c51a1 100644 --- a/problems/distribute-candies-to-people/README.md +++ b/problems/distribute-candies-to-people/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-with-maximum-minimum-value "Path With Maximum Minimum Value") diff --git a/problems/distribute-candies/README.md b/problems/distribute-candies/README.md index 5d133bdfc..597d2572d 100644 --- a/problems/distribute-candies/README.md +++ b/problems/distribute-candies/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../winning-candidate "Winning Candidate") diff --git a/problems/distribute-coins-in-binary-tree/README.md b/problems/distribute-coins-in-binary-tree/README.md index 82f360eb4..bca1db8a7 100644 --- a/problems/distribute-coins-in-binary-tree/README.md +++ b/problems/distribute-coins-in-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-turbulent-subarray "Longest Turbulent Subarray") diff --git a/problems/distribute-repeating-integers/README.md b/problems/distribute-repeating-integers/README.md index f1649ed8b..aa9699270 100644 --- a/problems/distribute-repeating-integers/README.md +++ b/problems/distribute-repeating-integers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-jumps-to-reach-home "Minimum Jumps to Reach Home") diff --git a/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md b/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md index 7b0bf98af..99aa7bbf4 100644 --- a/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md +++ b/problems/divide-array-in-sets-of-k-consecutive-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-numbers-with-even-number-of-digits "Find Numbers with Even Number of Digits") @@ -59,11 +59,14 @@ Note: This question is the same as 846: https://leetcode.com/problems/hand-of-straights/ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Split Array into Consecutive Subsequences](../split-array-into-consecutive-subsequences) (Medium) + ### Hints
    Hint 1 diff --git a/problems/divide-array-into-increasing-sequences/README.md b/problems/divide-array-into-increasing-sequences/README.md index 9cafc4768..6863391eb 100644 --- a/problems/divide-array-into-increasing-sequences/README.md +++ b/problems/divide-array-into-increasing-sequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-average-subtree "Maximum Average Subtree") @@ -44,8 +44,8 @@ There is no way to divide the array using the conditions required. ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/domino-and-tromino-tiling/README.md b/problems/domino-and-tromino-tiling/README.md index fe700add4..0aab6467f 100644 --- a/problems/domino-and-tromino-tiling/README.md +++ b/problems/domino-and-tromino-tiling/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../escape-the-ghosts "Escape The Ghosts") diff --git a/problems/dot-product-of-two-sparse-vectors/README.md b/problems/dot-product-of-two-sparse-vectors/README.md index 2e9db457c..0c36b471c 100644 --- a/problems/dot-product-of-two-sparse-vectors/README.md +++ b/problems/dot-product-of-two-sparse-vectors/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-reorder-array-to-get-same-bst "Number of Ways to Reorder Array to Get Same BST") @@ -14,10 +14,10 @@ ### Related Topics + [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] - [[Design](../../tag/design/README.md)] ### Hints
    diff --git a/problems/dota2-senate/README.md b/problems/dota2-senate/README.md index b1c725bee..9d40d16ad 100644 --- a/problems/dota2-senate/README.md +++ b/problems/dota2-senate/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../replace-words "Replace Words") @@ -60,9 +60,9 @@ And in round 2, the third senator can just announce the victory since he is the ### Related Topics + [[String](../../tag/string/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Queue](../../tag/queue/README.md)] - [[String](../../tag/string/README.md)] ### Similar Questions 1. [Teemo Attacking](../teemo-attacking) (Easy) diff --git a/problems/drop-type-1-orders-for-customers-with-type-0-orders/README.md b/problems/drop-type-1-orders-for-customers-with-type-0-orders/README.md new file mode 100644 index 000000000..1a73e08ea --- /dev/null +++ b/problems/drop-type-1-orders-for-customers-with-type-0-orders/README.md @@ -0,0 +1,14 @@ + + + + + + + +[< Previous](../substrings-that-begin-and-end-with-the-same-letter "Substrings That Begin and End With the Same Letter") +                 +Next > + +## [2084. Drop Type 1 Orders for Customers With Type 0 Orders (Medium)](https://leetcode.com/problems/drop-type-1-orders-for-customers-with-type-0-orders "") + + diff --git a/problems/drop-type-1-orders-for-customers-with-type-0-orders/mysql_schemas.sql b/problems/drop-type-1-orders-for-customers-with-type-0-orders/mysql_schemas.sql new file mode 100644 index 000000000..22a499aa9 --- /dev/null +++ b/problems/drop-type-1-orders-for-customers-with-type-0-orders/mysql_schemas.sql @@ -0,0 +1,10 @@ +Create table If Not Exists Orders (order_id int, customer_id int, order_type int); +Truncate table Orders; +insert into Orders (order_id, customer_id, order_type) values ('1', '1', '0'); +insert into Orders (order_id, customer_id, order_type) values ('2', '1', '0'); +insert into Orders (order_id, customer_id, order_type) values ('11', '2', '0'); +insert into Orders (order_id, customer_id, order_type) values ('12', '2', '1'); +insert into Orders (order_id, customer_id, order_type) values ('21', '3', '1'); +insert into Orders (order_id, customer_id, order_type) values ('22', '3', '0'); +insert into Orders (order_id, customer_id, order_type) values ('31', '4', '1'); +insert into Orders (order_id, customer_id, order_type) values ('32', '4', '1'); diff --git a/problems/dungeon-game/README.md b/problems/dungeon-game/README.md index a1ad87bb9..481597181 100644 --- a/problems/dungeon-game/README.md +++ b/problems/dungeon-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-search-tree-iterator "Binary Search Tree Iterator") diff --git a/problems/duplicate-zeros/README.md b/problems/duplicate-zeros/README.md index b2a925bf9..c933127d7 100644 --- a/problems/duplicate-zeros/README.md +++ b/problems/duplicate-zeros/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../confusing-number-ii "Confusing Number II") diff --git a/problems/egg-drop-with-2-eggs-and-n-floors/README.md b/problems/egg-drop-with-2-eggs-and-n-floors/README.md index 507213b79..b8408e61b 100644 --- a/problems/egg-drop-with-2-eggs-and-n-floors/README.md +++ b/problems/egg-drop-with-2-eggs-and-n-floors/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-skips-to-arrive-at-meeting-on-time "Minimum Skips to Arrive at Meeting On Time") @@ -37,7 +37,7 @@ Otherwise, if both eggs survive, we know that f = 2. Input: n = 100 Output: 14 Explanation: One optimal strategy is: -- Drop the 1st egg at floor 9. If it breaks, we know f is between 0 and 8. Drop the 2nd egg starting from floor 1 and going up one at a time to find f within 7 more drops. Total drops is 1 + 7 = 8. +- Drop the 1st egg at floor 9. If it breaks, we know f is between 0 and 8. Drop the 2nd egg starting from floor 1 and going up one at a time to find f within 8 more drops. Total drops is 1 + 8 = 9. - If the 1st egg does not break, drop the 1st egg again at floor 22. If it breaks, we know f is between 9 and 21. Drop the 2nd egg starting from floor 10 and going up one at a time to find f within 12 more drops. Total drops is 2 + 12 = 14. - If the 1st egg does not break again, follow a similar process dropping the 1st egg from floors 34, 45, 55, 64, 72, 79, 85, 90, 94, 97, 99, and 100. Regardless of the outcome, it takes at most 14 drops to determine f. diff --git a/problems/element-appearing-more-than-25-in-sorted-array/README.md b/problems/element-appearing-more-than-25-in-sorted-array/README.md index 8ed66371b..f8ef3054c 100644 --- a/problems/element-appearing-more-than-25-in-sorted-array/README.md +++ b/problems/element-appearing-more-than-25-in-sorted-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../iterator-for-combination "Iterator for Combination") diff --git a/problems/eliminate-maximum-number-of-monsters/README.md b/problems/eliminate-maximum-number-of-monsters/README.md index 38a194480..6a752338f 100644 --- a/problems/eliminate-maximum-number-of-monsters/README.md +++ b/problems/eliminate-maximum-number-of-monsters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../build-array-from-permutation "Build Array from Permutation") diff --git a/problems/employee-bonus/README.md b/problems/employee-bonus/README.md index 3d3570294..5caf7f8e1 100644 --- a/problems/employee-bonus/README.md +++ b/problems/employee-bonus/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../out-of-boundary-paths "Out of Boundary Paths") diff --git a/problems/employee-bonus/mysql_schemas.sql b/problems/employee-bonus/mysql_schemas.sql index 2242c50c5..44404f355 100644 --- a/problems/employee-bonus/mysql_schemas.sql +++ b/problems/employee-bonus/mysql_schemas.sql @@ -1,10 +1,10 @@ -Create table If Not Exists Employee (EmpId int, Name varchar(255), Supervisor int, Salary int); -Create table If Not Exists Bonus (EmpId int, Bonus int); +Create table If Not Exists Employee (empId int, name varchar(255), supervisor int, salary int); +Create table If Not Exists Bonus (empId int, bonus int); Truncate table Employee; -insert into Employee (EmpId, Name, Supervisor, Salary) values ('3', 'Brad', 'None', '4000'); -insert into Employee (EmpId, Name, Supervisor, Salary) values ('1', 'John', '3', '1000'); -insert into Employee (EmpId, Name, Supervisor, Salary) values ('2', 'Dan', '3', '2000'); -insert into Employee (EmpId, Name, Supervisor, Salary) values ('4', 'Thomas', '3', '4000'); +insert into Employee (empId, name, supervisor, salary) values ('3', 'Brad', 'None', '4000'); +insert into Employee (empId, name, supervisor, salary) values ('1', 'John', '3', '1000'); +insert into Employee (empId, name, supervisor, salary) values ('2', 'Dan', '3', '2000'); +insert into Employee (empId, name, supervisor, salary) values ('4', 'Thomas', '3', '4000'); Truncate table Bonus; -insert into Bonus (EmpId, Bonus) values ('2', '500'); -insert into Bonus (EmpId, Bonus) values ('4', '2000'); +insert into Bonus (empId, bonus) values ('2', '500'); +insert into Bonus (empId, bonus) values ('4', '2000'); diff --git a/problems/employees-whose-manager-left-the-company/README.md b/problems/employees-whose-manager-left-the-company/README.md index 87587b2e7..56eee226f 100644 --- a/problems/employees-whose-manager-left-the-company/README.md +++ b/problems/employees-whose-manager-left-the-company/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-separate-numbers "Number of Ways to Separate Numbers") diff --git a/problems/employees-with-missing-information/README.md b/problems/employees-with-missing-information/README.md index 2b6a9253b..87a73e013 100644 --- a/problems/employees-with-missing-information/README.md +++ b/problems/employees-with-missing-information/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-longest-valid-obstacle-course-at-each-position "Find the Longest Valid Obstacle Course at Each Position") diff --git a/problems/encode-and-decode-tinyurl/README.md b/problems/encode-and-decode-tinyurl/README.md index 51741058f..66c905748 100644 --- a/problems/encode-and-decode-tinyurl/README.md +++ b/problems/encode-and-decode-tinyurl/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../game-play-analysis-iii "Game Play Analysis III") @@ -47,7 +47,7 @@ string ans = obj.decode(tiny); // returns the original url after deconding it. ### Related Topics + [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Design](../../tag/design/README.md)] [[Hash Function](../../tag/hash-function/README.md)] diff --git a/problems/encode-number/README.md b/problems/encode-number/README.md index a38a4b267..a64ac2153 100644 --- a/problems/encode-number/README.md +++ b/problems/encode-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-score-words-formed-by-letters "Maximum Score Words Formed by Letters") @@ -40,9 +40,9 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Convert to Base -2](../convert-to-base-2) (Medium) diff --git a/problems/equal-sum-arrays-with-minimum-number-of-operations/README.md b/problems/equal-sum-arrays-with-minimum-number-of-operations/README.md index 30b2a8af9..2d888a5e5 100644 --- a/problems/equal-sum-arrays-with-minimum-number-of-operations/README.md +++ b/problems/equal-sum-arrays-with-minimum-number-of-operations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../closest-dessert-cost "Closest Dessert Cost") diff --git a/problems/erect-the-fence-ii/README.md b/problems/erect-the-fence-ii/README.md index 3b214df0e..4ca218a50 100644 --- a/problems/erect-the-fence-ii/README.md +++ b/problems/erect-the-fence-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-common-subpath "Longest Common Subpath") diff --git a/problems/erect-the-fence/README.md b/problems/erect-the-fence/README.md index 29da91e7a..3fde094a3 100644 --- a/problems/erect-the-fence/README.md +++ b/problems/erect-the-fence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../customer-placing-the-largest-number-of-orders "Customer Placing the Largest Number of Orders") diff --git a/problems/escape-a-large-maze/README.md b/problems/escape-a-large-maze/README.md index 50cdd6178..d8546cb79 100644 --- a/problems/escape-a-large-maze/README.md +++ b/problems/escape-a-large-maze/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../uncrossed-lines "Uncrossed Lines") diff --git a/problems/escape-the-ghosts/README.md b/problems/escape-the-ghosts/README.md index 971ab7c90..8457916e6 100644 --- a/problems/escape-the-ghosts/README.md +++ b/problems/escape-the-ghosts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rotated-digits "Rotated Digits") @@ -11,13 +11,13 @@ ## [789. Escape The Ghosts (Medium)](https://leetcode.com/problems/escape-the-ghosts "逃脱阻碍者") -

    You are playing a simplified PAC-MAN game on an infinite 2-D grid. You start at the point [0, 0], and you are given a destination point target = [xtarget, ytarget], which you are trying to get to. There are several ghosts on the map with their starting positions given as an array ghosts, where ghosts[i] = [xi, yi] represents the starting position of the ith ghost. All inputs are integral coordinates.

    +

    You are playing a simplified PAC-MAN game on an infinite 2-D grid. You start at the point [0, 0], and you are given a destination point target = [xtarget, ytarget] that you are trying to get to. There are several ghosts on the map with their starting positions given as a 2D array ghosts, where ghosts[i] = [xi, yi] represents the starting position of the ith ghost. All inputs are integral coordinates.

    -

    Each turn, you and all the ghosts may independently choose to either move 1 unit in any of the four cardinal directions: north, east, south, or west or stay still. All actions happen simultaneously.

    +

    Each turn, you and all the ghosts may independently choose to either move 1 unit in any of the four cardinal directions: north, east, south, or west, or stay still. All actions happen simultaneously.

    You escape if and only if you can reach the target before any ghost reaches you. If you reach any square (including the target) at the same time as a ghost, it does not count as an escape.

    -

    Return true if it is possible to escape, otherwise return false.

    +

    Return true if it is possible to escape regardless of how the ghosts move, otherwise return false.

     

    Example 1:

    diff --git a/problems/evaluate-reverse-polish-notation/README.md b/problems/evaluate-reverse-polish-notation/README.md index 568b78b2e..9db4857d2 100644 --- a/problems/evaluate-reverse-polish-notation/README.md +++ b/problems/evaluate-reverse-polish-notation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-points-on-a-line "Max Points on a Line") diff --git a/problems/evaluate-the-bracket-pairs-of-a-string/README.md b/problems/evaluate-the-bracket-pairs-of-a-string/README.md index 75f157112..5e9c0c85e 100644 --- a/problems/evaluate-the-bracket-pairs-of-a-string/README.md +++ b/problems/evaluate-the-bracket-pairs-of-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-operations-to-reinitialize-a-permutation "Minimum Number of Operations to Reinitialize a Permutation") diff --git a/problems/even-odd-tree/README.md b/problems/even-odd-tree/README.md index e38eac346..2cbc1f3a2 100644 --- a/problems/even-odd-tree/README.md +++ b/problems/even-odd-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../special-array-with-x-elements-greater-than-or-equal-x "Special Array With X Elements Greater Than or Equal X") diff --git a/problems/exchange-seats/README.md b/problems/exchange-seats/README.md index 3aacfcb82..a75b1b85e 100644 --- a/problems/exchange-seats/README.md +++ b/problems/exchange-seats/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-factorization "Minimum Factorization") diff --git a/problems/exclusive-time-of-functions/README.md b/problems/exclusive-time-of-functions/README.md index 01008e61c..9c6b4fb4d 100644 --- a/problems/exclusive-time-of-functions/README.md +++ b/problems/exclusive-time-of-functions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-log-storage-system "Design Log Storage System") diff --git a/problems/expression-add-operators/README.md b/problems/expression-add-operators/README.md index c12108c67..eadb58d1c 100644 --- a/problems/expression-add-operators/README.md +++ b/problems/expression-add-operators/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../zigzag-iterator "Zigzag Iterator") diff --git a/problems/expressive-words/README.md b/problems/expressive-words/README.md index f4a2bcfd0..9e1612013 100644 --- a/problems/expressive-words/README.md +++ b/problems/expressive-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../soup-servings "Soup Servings") diff --git a/problems/factor-combinations/README.md b/problems/factor-combinations/README.md index 99da5532b..d31d61b22 100644 --- a/problems/factor-combinations/README.md +++ b/problems/factor-combinations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../meeting-rooms-ii "Meeting Rooms II") diff --git a/problems/factorial-trailing-zeroes/README.md b/problems/factorial-trailing-zeroes/README.md index d5a86fafa..502539b28 100644 --- a/problems/factorial-trailing-zeroes/README.md +++ b/problems/factorial-trailing-zeroes/README.md @@ -1,19 +1,19 @@ - - - + + + [< Previous](../excel-sheet-column-number "Excel Sheet Column Number")                  [Next >](../binary-search-tree-iterator "Binary Search Tree Iterator") -## [172. Factorial Trailing Zeroes (Easy)](https://leetcode.com/problems/factorial-trailing-zeroes "阶乘后的零") +## [172. Factorial Trailing Zeroes (Medium)](https://leetcode.com/problems/factorial-trailing-zeroes "阶乘后的零") -

    Given an integer n, return the number of trailing zeroes in n!.

    +

    Given an integer n, return the number of trailing zeroes in n!.

    -

    Follow up: Could you write a solution that works in logarithmic time complexity?

    +

    Note that n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1.

     

    Example 1:

    @@ -21,7 +21,7 @@
     Input: n = 3
     Output: 0
    -Explanation: 3! = 6, no trailing zero.
    +Explanation: 3! = 6, no trailing zero.
     

    Example 2:

    @@ -29,7 +29,7 @@
     Input: n = 5
     Output: 1
    -Explanation: 5! = 120, one trailing zero.
    +Explanation: 5! = 120, one trailing zero.
     

    Example 3:

    @@ -46,6 +46,9 @@
  • 0 <= n <= 104
  • +

     

    +

    Follow up: Could you write a solution that works in logarithmic time complexity?

    + ### Related Topics [[Math](../../tag/math/README.md)] diff --git a/problems/falling-squares/README.md b/problems/falling-squares/README.md index dc7d38777..e1b6573d7 100644 --- a/problems/falling-squares/README.md +++ b/problems/falling-squares/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../partition-to-k-equal-sum-subsets "Partition to K Equal Sum Subsets") @@ -56,8 +56,8 @@ Note that square 2 only brushes the right side of square 1, which does not count ### Related Topics - [[Array](../../tag/array/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions diff --git a/problems/fancy-sequence/README.md b/problems/fancy-sequence/README.md index 095f2502b..93301026d 100644 --- a/problems/fancy-sequence/README.md +++ b/problems/fancy-sequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-sets-of-k-non-overlapping-line-segments "Number of Sets of K Non-Overlapping Line Segments") @@ -58,9 +58,9 @@ fancy.getIndex(2); // return 20 ### Related Topics - [[Math](../../tag/math/README.md)] [[Design](../../tag/design/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/faulty-sensor/README.md b/problems/faulty-sensor/README.md index 3025254b5..6ae59d245 100644 --- a/problems/faulty-sensor/README.md +++ b/problems/faulty-sensor/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../finding-mk-average "Finding MK Average") diff --git a/problems/filter-restaurants-by-vegan-friendly-price-and-distance/README.md b/problems/filter-restaurants-by-vegan-friendly-price-and-distance/README.md index 352e8bb21..8f334288f 100644 --- a/problems/filter-restaurants-by-vegan-friendly-price-and-distance/README.md +++ b/problems/filter-restaurants-by-vegan-friendly-price-and-distance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-palindromic-subsequences "Remove Palindromic Subsequences") diff --git a/problems/final-value-of-variable-after-performing-operations/README.md b/problems/final-value-of-variable-after-performing-operations/README.md index ba929c144..acb1477c9 100644 --- a/problems/final-value-of-variable-after-performing-operations/README.md +++ b/problems/final-value-of-variable-after-performing-operations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-number-of-seniors-and-juniors-to-join-the-company-ii "The Number of Seniors and Juniors to Join the Company II") diff --git a/problems/find-a-peak-element-ii/README.md b/problems/find-a-peak-element-ii/README.md index 6f59efabd..cdf0afb44 100644 --- a/problems/find-a-peak-element-ii/README.md +++ b/problems/find-a-peak-element-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-earliest-and-latest-rounds-where-players-compete "The Earliest and Latest Rounds Where Players Compete") diff --git a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md index c3cc0d0d1..93a511564 100644 --- a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md +++ b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-non-overlapping-substrings "Maximum Number of Non-Overlapping Substrings") @@ -53,10 +53,10 @@ ### Related Topics - [[Array](../../tag/array/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] ### Hints
    diff --git a/problems/find-all-anagrams-in-a-string/README.md b/problems/find-all-anagrams-in-a-string/README.md index bde000153..d9ea68ed6 100644 --- a/problems/find-all-anagrams-in-a-string/README.md +++ b/problems/find-all-anagrams-in-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-sum-iii "Path Sum III") diff --git a/problems/find-all-good-strings/README.md b/problems/find-all-good-strings/README.md index fbad6ebbf..266e3884f 100644 --- a/problems/find-all-good-strings/README.md +++ b/problems/find-all-good-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-underground-system "Design Underground System") diff --git a/problems/find-all-groups-of-farmland/README.md b/problems/find-all-groups-of-farmland/README.md index c44ea8517..f3390da7d 100644 --- a/problems/find-all-groups-of-farmland/README.md +++ b/problems/find-all-groups-of-farmland/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-middle-index-in-array "Find the Middle Index in Array") diff --git a/problems/find-all-numbers-disappeared-in-an-array/README.md b/problems/find-all-numbers-disappeared-in-an-array/README.md index a303d22e0..c05834526 100644 --- a/problems/find-all-numbers-disappeared-in-an-array/README.md +++ b/problems/find-all-numbers-disappeared-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-boomerangs "Number of Boomerangs") diff --git a/problems/find-all-the-lonely-nodes/README.md b/problems/find-all-the-lonely-nodes/README.md index a3379d1e5..d0bb2cb6d 100644 --- a/problems/find-all-the-lonely-nodes/README.md +++ b/problems/find-all-the-lonely-nodes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../calculate-salaries "Calculate Salaries") @@ -19,10 +19,6 @@ [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] -### Similar Questions - 1. [Binary Tree Tilt](../binary-tree-tilt) (Easy) - 1. [Univalued Binary Tree](../univalued-binary-tree) (Easy) - ### Hints
    Hint 1 diff --git a/problems/find-array-given-subset-sums/README.md b/problems/find-array-given-subset-sums/README.md index 5a33915d9..70ed5cc1f 100644 --- a/problems/find-array-given-subset-sums/README.md +++ b/problems/find-array-given-subset-sums/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimize-the-difference-between-target-and-chosen-elements "Minimize the Difference Between Target and Chosen Elements") diff --git a/problems/find-bottom-left-tree-value/README.md b/problems/find-bottom-left-tree-value/README.md index 6a72e27bc..0bddae477 100644 --- a/problems/find-bottom-left-tree-value/README.md +++ b/problems/find-bottom-left-tree-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../game-play-analysis-ii "Game Play Analysis II") diff --git a/problems/find-center-of-star-graph/README.md b/problems/find-center-of-star-graph/README.md index bdbc51763..62c53fe1e 100644 --- a/problems/find-center-of-star-graph/README.md +++ b/problems/find-center-of-star-graph/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-one-string-swap-can-make-strings-equal "Check if One String Swap Can Make Strings Equal") diff --git a/problems/find-customer-referee/README.md b/problems/find-customer-referee/README.md index b6fa01c91..1a32fee64 100644 --- a/problems/find-customer-referee/README.md +++ b/problems/find-customer-referee/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-operation-for-two-strings "Delete Operation for Two Strings") diff --git a/problems/find-customers-with-positive-revenue-this-year/README.md b/problems/find-customers-with-positive-revenue-this-year/README.md index 4f5d7a5ba..aff999682 100644 --- a/problems/find-customers-with-positive-revenue-this-year/README.md +++ b/problems/find-customers-with-positive-revenue-this-year/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-accepted-invitations "Maximum Number of Accepted Invitations") diff --git a/problems/find-cutoff-score-for-each-school/README.md b/problems/find-cutoff-score-for-each-school/README.md index 55fa6aafb..5009be138 100644 --- a/problems/find-cutoff-score-for-each-school/README.md +++ b/problems/find-cutoff-score-for-each-school/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-unique-good-subsequences "Number of Unique Good Subsequences") diff --git a/problems/find-distance-in-a-binary-tree/README.md b/problems/find-distance-in-a-binary-tree/README.md index 707c7eb48..3daa4c20d 100644 --- a/problems/find-distance-in-a-binary-tree/README.md +++ b/problems/find-distance-in-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../building-boxes "Building Boxes") @@ -14,10 +14,10 @@ ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/find-duplicate-subtrees/README.md b/problems/find-duplicate-subtrees/README.md index 58f1f55fc..13bb973a2 100644 --- a/problems/find-duplicate-subtrees/README.md +++ b/problems/find-duplicate-subtrees/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../4-keys-keyboard "4 Keys Keyboard") @@ -57,4 +57,3 @@ 1. [Serialize and Deserialize Binary Tree](../serialize-and-deserialize-binary-tree) (Hard) 1. [Serialize and Deserialize BST](../serialize-and-deserialize-bst) (Medium) 1. [Construct String from Binary Tree](../construct-string-from-binary-tree) (Easy) - 1. [Delete Duplicate Folders in System](../delete-duplicate-folders-in-system) (Hard) diff --git a/problems/find-elements-in-a-contaminated-binary-tree/README.md b/problems/find-elements-in-a-contaminated-binary-tree/README.md index bfd81d4c5..c775ccfe2 100644 --- a/problems/find-elements-in-a-contaminated-binary-tree/README.md +++ b/problems/find-elements-in-a-contaminated-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shift-2d-grid "Shift 2D Grid") diff --git a/problems/find-eventual-safe-states/README.md b/problems/find-eventual-safe-states/README.md index e0916e64f..5ed0ba863 100644 --- a/problems/find-eventual-safe-states/README.md +++ b/problems/find-eventual-safe-states/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-swaps-to-make-sequences-increasing "Minimum Swaps To Make Sequences Increasing") diff --git a/problems/find-followers-count/README.md b/problems/find-followers-count/README.md index 19b344c7c..296bbf93d 100644 --- a/problems/find-followers-count/README.md +++ b/problems/find-followers-count/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cat-and-mouse-ii "Cat and Mouse II") diff --git a/problems/find-greatest-common-divisor-of-array/README.md b/problems/find-greatest-common-divisor-of-array/README.md index 6eac12499..0aca50aaa 100644 --- a/problems/find-greatest-common-divisor-of-array/README.md +++ b/problems/find-greatest-common-divisor-of-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../employees-whose-manager-left-the-company "Employees Whose Manager Left the Company") diff --git a/problems/find-if-path-exists-in-graph/README.md b/problems/find-if-path-exists-in-graph/README.md index 2c76e80ba..08b773042 100644 --- a/problems/find-if-path-exists-in-graph/README.md +++ b/problems/find-if-path-exists-in-graph/README.md @@ -1,15 +1,15 @@ - - - + + + [< Previous](../last-day-where-you-can-still-cross "Last Day Where You Can Still Cross")                  [Next >](../first-and-last-call-on-the-same-day "First and Last Call On the Same Day") -## [1971. Find if Path Exists in Graph (Easy)](https://leetcode.com/problems/find-if-path-exists-in-graph "") +## [1971. Find if Path Exists in Graph (Easy)](https://leetcode.com/problems/find-if-path-exists-in-graph "寻找图中是否存在路径")

    There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself.

    diff --git a/problems/find-in-mountain-array/README.md b/problems/find-in-mountain-array/README.md index c4c73ab6b..972eb7790 100644 --- a/problems/find-in-mountain-array/README.md +++ b/problems/find-in-mountain-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../car-pooling "Car Pooling") @@ -11,33 +11,30 @@ ## [1095. Find in Mountain Array (Hard)](https://leetcode.com/problems/find-in-mountain-array "山脉数组中查找目标值") -

    (This problem is an interactive problem.)

    +

    (This problem is an interactive problem.)

    -

    You may recall that an array A is a mountain array if and only if:

    +

    You may recall that an array arr is a mountain array if and only if:

      -
    • A.length >= 3
    • -
    • There exists some i with 0 < i < A.length - 1 such that: +
    • arr.length >= 3
    • +
    • There exists some i with 0 < i < arr.length - 1 such that:
        -
      • A[0] < A[1] < ... A[i-1] < A[i]
      • -
      • A[i] > A[i+1] > ... > A[A.length - 1]
      • +
      • arr[0] < arr[1] < ... < arr[i - 1] < arr[i]
      • +
      • arr[i] > arr[i + 1] > ... > arr[arr.length - 1]
    -

    Given a mountain array mountainArr, return the minimum index such that mountainArr.get(index) == target.  If such an index doesn't exist, return -1.

    +

    Given a mountain array mountainArr, return the minimum index such that mountainArr.get(index) == target. If such an index does not exist, return -1.

    -

    You can't access the mountain array directly.  You may only access the array using a MountainArray interface:

    +

    You cannot access the mountain array directly. You may only access the array using a MountainArray interface:

      -
    • MountainArray.get(k) returns the element of the array at index k (0-indexed).
    • -
    • MountainArray.length() returns the length of the array.
    • +
    • MountainArray.get(k) returns the element of the array at index k (0-indexed).
    • +
    • MountainArray.length() returns the length of the array.
    -

    Submissions making more than 100 calls to MountainArray.get will be judged Wrong Answer.  Also, any solutions that attempt to circumvent the judge will result in disqualification.

    - -
      -
    +

    Submissions making more than 100 calls to MountainArray.get will be judged Wrong Answer. Also, any solutions that attempt to circumvent the judge will result in disqualification.

     

    Example 1:

    @@ -59,9 +56,9 @@

    Constraints:

      -
    • 3 <= mountain_arr.length() <= 10000
    • -
    • 0 <= target <= 10^9
    • -
    • 0 <= mountain_arr.get(index) <= 10^9
    • +
    • 3 <= mountain_arr.length() <= 104
    • +
    • 0 <= target <= 109
    • +
    • 0 <= mountain_arr.get(index) <= 109
    ### Related Topics @@ -69,6 +66,10 @@ [[Binary Search](../../tag/binary-search/README.md)] [[Interactive](../../tag/interactive/README.md)] +### Similar Questions + 1. [Peak Index in a Mountain Array](../peak-index-in-a-mountain-array) (Easy) + 1. [Minimum Number of Removals to Make Mountain Array](../minimum-number-of-removals-to-make-mountain-array) (Hard) + ### Hints
    Hint 1 diff --git a/problems/find-interview-candidates/README.md b/problems/find-interview-candidates/README.md index c7e04117a..660d053e7 100644 --- a/problems/find-interview-candidates/README.md +++ b/problems/find-interview-candidates/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-path-cost-in-a-hidden-grid "Minimum Path Cost in a Hidden Grid") diff --git a/problems/find-k-pairs-with-smallest-sums/README.md b/problems/find-k-pairs-with-smallest-sums/README.md index 93278e009..34da2c164 100644 --- a/problems/find-k-pairs-with-smallest-sums/README.md +++ b/problems/find-k-pairs-with-smallest-sums/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../super-pow "Super Pow") diff --git a/problems/find-kth-bit-in-nth-binary-string/README.md b/problems/find-kth-bit-in-nth-binary-string/README.md index 472812324..c6deb7db6 100644 --- a/problems/find-kth-bit-in-nth-binary-string/README.md +++ b/problems/find-kth-bit-in-nth-binary-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../make-the-string-great "Make The String Great") @@ -11,25 +11,25 @@ ## [1545. Find Kth Bit in Nth Binary String (Medium)](https://leetcode.com/problems/find-kth-bit-in-nth-binary-string "找出第 N 个二进制字符串中的第 K 位") -

    Given two positive integers n and k, the binary string  Sn is formed as follows:

    +

    Given two positive integers n and k, the binary string Sn is formed as follows:

      -
    • S1 = "0"
    • -
    • Si = Si-1 + "1" + reverse(invert(Si-1)) for i > 1
    • +
    • S1 = "0"
    • +
    • Si = Si-1 + "1" + reverse(invert(Si-1)) for i > 1
    -

    Where + denotes the concatenation operation, reverse(x) returns the reversed string x, and invert(x) inverts all the bits in x (0 changes to 1 and 1 changes to 0).

    +

    Where + denotes the concatenation operation, reverse(x) returns the reversed string x, and invert(x) inverts all the bits in x (0 changes to 1 and 1 changes to 0).

    For example, the first 4 strings in the above sequence are:

      -
    • S= "0"
    • -
    • S= "011"
    • -
    • S= "0111001"
    • +
    • S1 = "0"
    • +
    • S2 = "011"
    • +
    • S3 = "0111001"
    • S4 = "011100110110001"
    -

    Return the kth bit in Sn. It is guaranteed that k is valid for the given n.

    +

    Return the kth bit in Sn. It is guaranteed that k is valid for the given n.

     

    Example 1:

    @@ -71,8 +71,8 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[String](../../tag/string/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Hints
    diff --git a/problems/find-kth-largest-xor-coordinate-value/README.md b/problems/find-kth-largest-xor-coordinate-value/README.md index f69f71c83..09a8dc816 100644 --- a/problems/find-kth-largest-xor-coordinate-value/README.md +++ b/problems/find-kth-largest-xor-coordinate-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../change-minimum-characters-to-satisfy-one-of-three-conditions "Change Minimum Characters to Satisfy One of Three Conditions") diff --git a/problems/find-largest-value-in-each-tree-row/README.md b/problems/find-largest-value-in-each-tree-row/README.md index 4ef0b9546..28388634d 100644 --- a/problems/find-largest-value-in-each-tree-row/README.md +++ b/problems/find-largest-value-in-each-tree-row/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../freedom-trail "Freedom Trail") diff --git a/problems/find-latest-group-of-size-m/README.md b/problems/find-latest-group-of-size-m/README.md index 5251c6beb..7b8f9ad12 100644 --- a/problems/find-latest-group-of-size-m/README.md +++ b/problems/find-latest-group-of-size-m/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-coins-you-can-get "Maximum Number of Coins You Can Get") @@ -11,11 +11,13 @@ ## [1562. Find Latest Group of Size M (Medium)](https://leetcode.com/problems/find-latest-group-of-size-m "查找大小为 M 的最新分组") -

    Given an array arr that represents a permutation of numbers from 1 to n. You have a binary string of size n that initially has all its bits set to zero.

    +

    Given an array arr that represents a permutation of numbers from 1 to n.

    -

    At each step i (assuming both the binary string and arr are 1-indexed) from 1 to n, the bit at position arr[i] is set to 1. You are given an integer m and you need to find the latest step at which there exists a group of ones of length m. A group of ones is a contiguous substring of 1s such that it cannot be extended in either direction.

    +

    You have a binary string of size n that initially has all its bits set to zero. At each step i (assuming both the binary string and arr are 1-indexed) from 1 to n, the bit at position arr[i] is set to 1.

    -

    Return the latest step at which there exists a group of ones of length exactly m. If no such group exists, return -1.

    +

    You are also given an integer m. Find the latest step at which there exists a group of ones of length m. A group of ones is a contiguous substring of 1's such that it cannot be extended in either direction.

    + +

    Return the latest step at which there exists a group of ones of length exactly m. If no such group exists, return -1.

     

    Example 1:

    @@ -64,10 +66,9 @@ No group of size 2 exists during any step.
    • n == arr.length
    • -
    • 1 <= n <= 10^5
    • +
    • 1 <= m <= n <= 105
    • 1 <= arr[i] <= n
    • -
    • All integers in arr are distinct.
    • -
    • 1 <= m <= arr.length
    • +
    • All integers in arr are distinct.
    ### Related Topics diff --git a/problems/find-longest-awesome-substring/README.md b/problems/find-longest-awesome-substring/README.md index 51ee2950c..35bff6ebc 100644 --- a/problems/find-longest-awesome-substring/README.md +++ b/problems/find-longest-awesome-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-insertions-to-balance-a-parentheses-string "Minimum Insertions to Balance a Parentheses String") @@ -50,14 +50,14 @@

    Constraints:

      -
    • 1 <= s.length <= 10^5
    • +
    • 1 <= s.length <= 105
    • s consists only of digits.
    ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/find-lucky-integer-in-an-array/README.md b/problems/find-lucky-integer-in-an-array/README.md index 7f5d812a1..2308ca8e0 100644 --- a/problems/find-lucky-integer-in-an-array/README.md +++ b/problems/find-lucky-integer-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../capital-gainloss "Capital Gain/Loss") diff --git a/problems/find-median-given-frequency-of-numbers/README.md b/problems/find-median-given-frequency-of-numbers/README.md index 3450d3392..012bc7fbb 100644 --- a/problems/find-median-given-frequency-of-numbers/README.md +++ b/problems/find-median-given-frequency-of-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../managers-with-at-least-5-direct-reports "Managers with at Least 5 Direct Reports") diff --git a/problems/find-median-given-frequency-of-numbers/mysql_schemas.sql b/problems/find-median-given-frequency-of-numbers/mysql_schemas.sql index 09ba2b969..045c651e6 100644 --- a/problems/find-median-given-frequency-of-numbers/mysql_schemas.sql +++ b/problems/find-median-given-frequency-of-numbers/mysql_schemas.sql @@ -1,6 +1,6 @@ -Create table If Not Exists Numbers (Number int, Frequency int); +Create table If Not Exists Numbers (num int, frequency int); Truncate table Numbers; -insert into Numbers (Number, Frequency) values ('0', '7'); -insert into Numbers (Number, Frequency) values ('1', '1'); -insert into Numbers (Number, Frequency) values ('2', '3'); -insert into Numbers (Number, Frequency) values ('3', '1'); +insert into Numbers (num, frequency) values ('0', '7'); +insert into Numbers (num, frequency) values ('1', '1'); +insert into Numbers (num, frequency) values ('2', '3'); +insert into Numbers (num, frequency) values ('3', '1'); diff --git a/problems/find-minimum-time-to-finish-all-jobs/README.md b/problems/find-minimum-time-to-finish-all-jobs/README.md index 092bf7ddc..04d2f0c05 100644 --- a/problems/find-minimum-time-to-finish-all-jobs/README.md +++ b/problems/find-minimum-time-to-finish-all-jobs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimize-hamming-distance-after-swap-operations "Minimize Hamming Distance After Swap Operations") diff --git a/problems/find-missing-observations/README.md b/problems/find-missing-observations/README.md index 42f206e9c..7509a72d7 100644 --- a/problems/find-missing-observations/README.md +++ b/problems/find-missing-observations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-moves-to-convert-string "Minimum Moves to Convert String") diff --git a/problems/find-n-unique-integers-sum-up-to-zero/README.md b/problems/find-n-unique-integers-sum-up-to-zero/README.md index f7bf6803a..adcf4c9f1 100644 --- a/problems/find-n-unique-integers-sum-up-to-zero/README.md +++ b/problems/find-n-unique-integers-sum-up-to-zero/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-team-size "Find the Team Size") diff --git a/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md b/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md index 870808615..428b9c620 100644 --- a/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md +++ b/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-path-in-a-hidden-grid "Shortest Path in a Hidden Grid") diff --git a/problems/find-nearest-right-node-in-binary-tree/README.md b/problems/find-nearest-right-node-in-binary-tree/README.md index 2da65c22e..3202654d0 100644 --- a/problems/find-nearest-right-node-in-binary-tree/README.md +++ b/problems/find-nearest-right-node-in-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-achievable-transfer-requests "Maximum Number of Achievable Transfer Requests") diff --git a/problems/find-numbers-with-even-number-of-digits/README.md b/problems/find-numbers-with-even-number-of-digits/README.md index fc610d517..b13bbff63 100644 --- a/problems/find-numbers-with-even-number-of-digits/README.md +++ b/problems/find-numbers-with-even-number-of-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../weather-type-in-each-country "Weather Type in Each Country") @@ -11,7 +11,8 @@ ## [1295. Find Numbers with Even Number of Digits (Easy)](https://leetcode.com/problems/find-numbers-with-even-number-of-digits "统计位数为偶数的数字") -Given an array nums of integers, return how many of them contain an even number of digits. +

    Given an array nums of integers, return how many of them contain an even number of digits.

    +

     

    Example 1:

    @@ -41,7 +42,7 @@ Only 1771 contains an even number of digits.
    • 1 <= nums.length <= 500
    • -
    • 1 <= nums[i] <= 10^5
    • +
    • 1 <= nums[i] <= 105
    ### Related Topics diff --git a/problems/find-original-array-from-doubled-array/README.md b/problems/find-original-array-from-doubled-array/README.md index 9630bc2b1..82ef650df 100644 --- a/problems/find-original-array-from-doubled-array/README.md +++ b/problems/find-original-array-from-doubled-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-number-of-pairs-with-absolute-difference-k "Count Number of Pairs With Absolute Difference K") diff --git a/problems/find-positive-integer-solution-for-a-given-equation/README.md b/problems/find-positive-integer-solution-for-a-given-equation/README.md index 4c7eabb44..51ee21ffb 100644 --- a/problems/find-positive-integer-solution-for-a-given-equation/README.md +++ b/problems/find-positive-integer-solution-for-a-given-equation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../web-crawler "Web Crawler") diff --git a/problems/find-root-of-n-ary-tree/README.md b/problems/find-root-of-n-ary-tree/README.md index fc8c6cc86..86d931298 100644 --- a/problems/find-root-of-n-ary-tree/README.md +++ b/problems/find-root-of-n-ary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "Minimum Possible Integer After at Most K Adjacent Swaps On Digits") diff --git a/problems/find-servers-that-handled-most-number-of-requests/README.md b/problems/find-servers-that-handled-most-number-of-requests/README.md index 237d5cb81..c18b61cd2 100644 --- a/problems/find-servers-that-handled-most-number-of-requests/README.md +++ b/problems/find-servers-that-handled-most-number-of-requests/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-valid-matrix-given-row-and-column-sums "Find Valid Matrix Given Row and Column Sums") diff --git a/problems/find-smallest-common-element-in-all-rows/README.md b/problems/find-smallest-common-element-in-all-rows/README.md index e4947d6d1..e59271161 100644 --- a/problems/find-smallest-common-element-in-all-rows/README.md +++ b/problems/find-smallest-common-element-in-all-rows/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-knight-moves "Minimum Knight Moves") diff --git a/problems/find-smallest-letter-greater-than-target/README.md b/problems/find-smallest-letter-greater-than-target/README.md index ddcaa5c62..49127e3fe 100644 --- a/problems/find-smallest-letter-greater-than-target/README.md +++ b/problems/find-smallest-letter-greater-than-target/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../network-delay-time "Network Delay Time") diff --git a/problems/find-the-celebrity/README.md b/problems/find-the-celebrity/README.md index 9120109f5..41679c4a7 100644 --- a/problems/find-the-celebrity/README.md +++ b/problems/find-the-celebrity/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../paint-fence "Paint Fence") @@ -53,9 +53,9 @@ ### Related Topics + [[Two Pointers](../../tag/two-pointers/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Graph](../../tag/graph/README.md)] - [[Two Pointers](../../tag/two-pointers/README.md)] [[Interactive](../../tag/interactive/README.md)] ### Similar Questions diff --git a/problems/find-the-closest-palindrome/README.md b/problems/find-the-closest-palindrome/README.md index 712140264..59015a153 100644 --- a/problems/find-the-closest-palindrome/README.md +++ b/problems/find-the-closest-palindrome/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-tree-tilt "Binary Tree Tilt") @@ -45,6 +45,9 @@ [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Next Palindrome Using Same Digits](../next-palindrome-using-same-digits) (Hard) + ### Hints
    Hint 1 diff --git a/problems/find-the-derangement-of-an-array/README.md b/problems/find-the-derangement-of-an-array/README.md index 9099e2f77..0bfe1bf04 100644 --- a/problems/find-the-derangement-of-an-array/README.md +++ b/problems/find-the-derangement-of-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-square-numbers "Sum of Square Numbers") diff --git a/problems/find-the-difference/README.md b/problems/find-the-difference/README.md index 4f2cd24a5..26f99b8ad 100644 --- a/problems/find-the-difference/README.md +++ b/problems/find-the-difference/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-absolute-file-path "Longest Absolute File Path") @@ -57,9 +57,9 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Similar Questions diff --git a/problems/find-the-distance-value-between-two-arrays/README.md b/problems/find-the-distance-value-between-two-arrays/README.md index dfe1d8545..6bd0eda3c 100644 --- a/problems/find-the-distance-value-between-two-arrays/README.md +++ b/problems/find-the-distance-value-between-two-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../total-sales-amount-by-year "Total Sales Amount by Year") diff --git a/problems/find-the-highest-altitude/README.md b/problems/find-the-highest-altitude/README.md index b67880b44..d4cdabadb 100644 --- a/problems/find-the-highest-altitude/README.md +++ b/problems/find-the-highest-altitude/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-number-of-employees-which-report-to-each-employee "The Number of Employees Which Report to Each Employee") diff --git a/problems/find-the-index-of-the-large-integer/README.md b/problems/find-the-index-of-the-large-integer/README.md index 5add4dacc..57eb5c872 100644 --- a/problems/find-the-index-of-the-large-integer/README.md +++ b/problems/find-the-index-of-the-large-integer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-most-recent-three-orders "The Most Recent Three Orders") diff --git a/problems/find-the-kth-largest-integer-in-the-array/README.md b/problems/find-the-kth-largest-integer-in-the-array/README.md index 30741df8a..26ca0ca05 100644 --- a/problems/find-the-kth-largest-integer-in-the-array/README.md +++ b/problems/find-the-kth-largest-integer-in-the-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-difference-between-highest-and-lowest-of-k-scores "Minimum Difference Between Highest and Lowest of K Scores") diff --git a/problems/find-the-longest-valid-obstacle-course-at-each-position/README.md b/problems/find-the-longest-valid-obstacle-course-at-each-position/README.md index b5af04369..92086d4ed 100644 --- a/problems/find-the-longest-valid-obstacle-course-at-each-position/README.md +++ b/problems/find-the-longest-valid-obstacle-course-at-each-position/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-swaps-to-make-the-string-balanced "Minimum Number of Swaps to Make the String Balanced") diff --git a/problems/find-the-middle-index-in-array/README.md b/problems/find-the-middle-index-in-array/README.md index e08db4f4b..c9372d3c6 100644 --- a/problems/find-the-middle-index-in-array/README.md +++ b/problems/find-the-middle-index-in-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-the-number-of-experiments "Count the Number of Experiments") diff --git a/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md b/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md index df7f6ef2a..aa3940150 100644 --- a/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md +++ b/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-index-with-equal-value "Smallest Index With Equal Value") diff --git a/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md b/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md index 93d2ee3fb..1d1f7e2c6 100644 --- a/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md +++ b/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-value-to-get-positive-step-by-step-sum "Minimum Value to Get Positive Step by Step Sum") diff --git a/problems/find-the-missing-ids/README.md b/problems/find-the-missing-ids/README.md index 36acbeda6..493874513 100644 --- a/problems/find-the-missing-ids/README.md +++ b/problems/find-the-missing-ids/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-two-expression-trees-are-equivalent "Check If Two Expression Trees are Equivalent") @@ -15,8 +15,3 @@ ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Report Contiguous Dates](../report-contiguous-dates) (Hard) - 1. [Find the Start and End Number of Continuous Ranges](../find-the-start-and-end-number-of-continuous-ranges) (Medium) - 1. [Number of Transactions per Visit](../number-of-transactions-per-visit) (Hard) diff --git a/problems/find-the-most-competitive-subsequence/README.md b/problems/find-the-most-competitive-subsequence/README.md index 2a2156173..918cfd3ad 100644 --- a/problems/find-the-most-competitive-subsequence/README.md +++ b/problems/find-the-most-competitive-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../richest-customer-wealth "Richest Customer Wealth") @@ -43,11 +43,15 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[Array](../../tag/array/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] +### Similar Questions + 1. [Remove K Digits](../remove-k-digits) (Medium) + 1. [Smallest Subsequence of Distinct Characters](../smallest-subsequence-of-distinct-characters) (Medium) + ### Hints
    Hint 1 diff --git a/problems/find-the-quiet-students-in-all-exams/README.md b/problems/find-the-quiet-students-in-all-exams/README.md index 74d7ae0dd..82f0db71d 100644 --- a/problems/find-the-quiet-students-in-all-exams/README.md +++ b/problems/find-the-quiet-students-in-all-exams/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-paint-n-3-grid "Number of Ways to Paint N × 3 Grid") diff --git a/problems/find-the-smallest-divisor-given-a-threshold/README.md b/problems/find-the-smallest-divisor-given-a-threshold/README.md index b8d22252c..ff3a0bece 100644 --- a/problems/find-the-smallest-divisor-given-a-threshold/README.md +++ b/problems/find-the-smallest-divisor-given-a-threshold/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../group-the-people-given-the-group-size-they-belong-to "Group the People Given the Group Size They Belong To") diff --git a/problems/find-the-start-and-end-number-of-continuous-ranges/README.md b/problems/find-the-start-and-end-number-of-continuous-ranges/README.md index 2d807b762..5521814a1 100644 --- a/problems/find-the-start-and-end-number-of-continuous-ranges/README.md +++ b/problems/find-the-start-and-end-number-of-continuous-ranges/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix "Minimum Number of Flips to Convert Binary Matrix to Zero Matrix") @@ -58,3 +58,7 @@ Number 10 is contained in the table. ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Report Contiguous Dates](../report-contiguous-dates) (Hard) + 1. [Find the Missing IDs](../find-the-missing-ids) (Medium) diff --git a/problems/find-the-student-that-will-replace-the-chalk/README.md b/problems/find-the-student-that-will-replace-the-chalk/README.md index e86b38815..ed3062efa 100644 --- a/problems/find-the-student-that-will-replace-the-chalk/README.md +++ b/problems/find-the-student-that-will-replace-the-chalk/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-all-the-integers-in-a-range-are-covered "Check if All the Integers in a Range Are Covered") @@ -63,8 +63,8 @@ Student number 1 does not have enough chalk, so they will have to replace it. ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Prefix Sum](../../tag/prefix-sum/README.md)] [[Simulation](../../tag/simulation/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/find-the-subtasks-that-did-not-execute/README.md b/problems/find-the-subtasks-that-did-not-execute/README.md index 92270fe9b..8d94adad5 100644 --- a/problems/find-the-subtasks-that-did-not-execute/README.md +++ b/problems/find-the-subtasks-that-did-not-execute/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tree-of-coprimes "Tree of Coprimes") diff --git a/problems/find-the-team-size/README.md b/problems/find-the-team-size/README.md index ef0b10037..dd11cf0b0 100644 --- a/problems/find-the-team-size/README.md +++ b/problems/find-the-team-size/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../deepest-leaves-sum "Deepest Leaves Sum") diff --git a/problems/find-the-town-judge/README.md b/problems/find-the-town-judge/README.md index d801df3e8..ff1d47922 100644 --- a/problems/find-the-town-judge/README.md +++ b/problems/find-the-town-judge/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-squareful-arrays "Number of Squareful Arrays") diff --git a/problems/find-the-winner-of-an-array-game/README.md b/problems/find-the-winner-of-an-array-game/README.md index e8e735030..ab1c0c3a7 100644 --- a/problems/find-the-winner-of-an-array-game/README.md +++ b/problems/find-the-winner-of-an-array-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-good-triplets "Count Good Triplets") @@ -13,7 +13,7 @@

    Given an integer array arr of distinct integers and an integer k.

    -

    A game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of the game, we compare arr[0] with arr[1], the larger integer wins and remains at position 0 and the smaller integer moves to the end of the array. The game ends when an integer wins k consecutive rounds.

    +

    A game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of the game, we compare arr[0] with arr[1], the larger integer wins and remains at position 0 and the smaller integer moves to the end of the array. The game ends when an integer wins k consecutive rounds.

    Return the integer which will win the game.

    @@ -60,10 +60,10 @@ So we can see that 4 rounds will be played and 5 is the winner because it wins 2

    Constraints:

      -
    • 2 <= arr.length <= 10^5
    • -
    • 1 <= arr[i] <= 10^6
    • -
    • arr contains distinct integers.
    • -
    • 1 <= k <= 10^9
    • +
    • 2 <= arr.length <= 105
    • +
    • 1 <= arr[i] <= 106
    • +
    • arr contains distinct integers.
    • +
    • 1 <= k <= 109
    ### Related Topics diff --git a/problems/find-the-winner-of-the-circular-game/README.md b/problems/find-the-winner-of-the-circular-game/README.md index 383ef9c03..72592a8ab 100644 --- a/problems/find-the-winner-of-the-circular-game/README.md +++ b/problems/find-the-winner-of-the-circular-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sign-of-the-product-of-an-array "Sign of the Product of an Array") diff --git a/problems/find-total-time-spent-by-each-employee/README.md b/problems/find-total-time-spent-by-each-employee/README.md index f0f8b247f..280619629 100644 --- a/problems/find-total-time-spent-by-each-employee/README.md +++ b/problems/find-total-time-spent-by-each-employee/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-distance-in-a-binary-tree "Find Distance in a Binary Tree") diff --git a/problems/find-unique-binary-string/README.md b/problems/find-unique-binary-string/README.md index b26bda5aa..986125758 100644 --- a/problems/find-unique-binary-string/README.md +++ b/problems/find-unique-binary-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-greatest-common-divisor-of-array "Find Greatest Common Divisor of Array") diff --git a/problems/find-users-with-valid-e-mails/README.md b/problems/find-users-with-valid-e-mails/README.md index a7378ffad..d28cde732 100644 --- a/problems/find-users-with-valid-e-mails/README.md +++ b/problems/find-users-with-valid-e-mails/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../move-sub-tree-of-n-ary-tree "Move Sub-Tree of N-Ary Tree") diff --git a/problems/find-valid-matrix-given-row-and-column-sums/README.md b/problems/find-valid-matrix-given-row-and-column-sums/README.md index 40380151c..937b21680 100644 --- a/problems/find-valid-matrix-given-row-and-column-sums/README.md +++ b/problems/find-valid-matrix-given-row-and-column-sums/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../alert-using-same-key-card-three-or-more-times-in-a-one-hour-period "Alert Using Same Key-Card Three or More Times in a One Hour Period") @@ -76,13 +76,10 @@ Another possible matrix is: [[1,2], ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] -### Similar Questions - 1. [Reconstruct a 2-Row Binary Matrix](../reconstruct-a-2-row-binary-matrix) (Medium) - ### Hints
    Hint 1 diff --git a/problems/find-winner-on-a-tic-tac-toe-game/README.md b/problems/find-winner-on-a-tic-tac-toe-game/README.md index ea7db93de..a9fb045d4 100644 --- a/problems/find-winner-on-a-tic-tac-toe-game/README.md +++ b/problems/find-winner-on-a-tic-tac-toe-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ships-in-a-rectangle "Number of Ships in a Rectangle") diff --git a/problems/find-words-that-can-be-formed-by-characters/README.md b/problems/find-words-that-can-be-formed-by-characters/README.md index 083f74b1f..86c08abca 100644 --- a/problems/find-words-that-can-be-formed-by-characters/README.md +++ b/problems/find-words-that-can-be-formed-by-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../market-analysis-ii "Market Analysis II") diff --git a/problems/find-xor-sum-of-all-pairs-bitwise-and/README.md b/problems/find-xor-sum-of-all-pairs-bitwise-and/README.md index 8eae2dff9..188930335 100644 --- a/problems/find-xor-sum-of-all-pairs-bitwise-and/README.md +++ b/problems/find-xor-sum-of-all-pairs-bitwise-and/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../single-threaded-cpu "Single-Threaded CPU") diff --git a/problems/finding-mk-average/README.md b/problems/finding-mk-average/README.md index 0600c9f54..17b35c582 100644 --- a/problems/finding-mk-average/README.md +++ b/problems/finding-mk-average/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-sideway-jumps "Minimum Sideway Jumps") diff --git a/problems/finding-pairs-with-a-certain-sum/README.md b/problems/finding-pairs-with-a-certain-sum/README.md index eec73339b..db4adce8e 100644 --- a/problems/finding-pairs-with-a-certain-sum/README.md +++ b/problems/finding-pairs-with-a-certain-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-swaps-to-make-the-binary-string-alternating "Minimum Number of Swaps to Make the Binary String Alternating") diff --git a/problems/finding-the-users-active-minutes/README.md b/problems/finding-the-users-active-minutes/README.md index 6d76694ed..4b7acd96b 100644 --- a/problems/finding-the-users-active-minutes/README.md +++ b/problems/finding-the-users-active-minutes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../truncate-sentence "Truncate Sentence") diff --git a/problems/first-and-last-call-on-the-same-day/README.md b/problems/first-and-last-call-on-the-same-day/README.md index 2ea7414aa..b8f2de048 100644 --- a/problems/first-and-last-call-on-the-same-day/README.md +++ b/problems/first-and-last-call-on-the-same-day/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-if-path-exists-in-graph "Find if Path Exists in Graph") diff --git a/problems/first-bad-version/README.md b/problems/first-bad-version/README.md index 86a060793..8c880f141 100644 --- a/problems/first-bad-version/README.md +++ b/problems/first-bad-version/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-celebrity "Find the Celebrity") diff --git a/problems/first-day-where-you-have-been-in-all-the-rooms/README.md b/problems/first-day-where-you-have-been-in-all-the-rooms/README.md index 4ad9d3435..856a5085b 100644 --- a/problems/first-day-where-you-have-been-in-all-the-rooms/README.md +++ b/problems/first-day-where-you-have-been-in-all-the-rooms/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-number-of-weak-characters-in-the-game "The Number of Weak Characters in the Game") diff --git a/problems/first-missing-positive/README.md b/problems/first-missing-positive/README.md index f69d2437e..efea25ae1 100644 --- a/problems/first-missing-positive/README.md +++ b/problems/first-missing-positive/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../combination-sum-ii "Combination Sum II") diff --git a/problems/first-unique-number/README.md b/problems/first-unique-number/README.md index 9607addcc..5c9046d3d 100644 --- a/problems/first-unique-number/README.md +++ b/problems/first-unique-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../leftmost-column-with-at-least-a-one "Leftmost Column with at Least a One") diff --git a/problems/fix-names-in-a-table/README.md b/problems/fix-names-in-a-table/README.md index 838558462..3a3b17e11 100644 --- a/problems/fix-names-in-a-table/README.md +++ b/problems/fix-names-in-a-table/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../change-the-root-of-a-binary-tree "Change the Root of a Binary Tree") diff --git a/problems/fix-product-name-format/README.md b/problems/fix-product-name-format/README.md index 6393a7cc7..1ac7a026a 100644 --- a/problems/fix-product-name-format/README.md +++ b/problems/fix-product-name-format/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-longest-awesome-substring "Find Longest Awesome Substring") diff --git a/problems/flatten-a-multilevel-doubly-linked-list/README.md b/problems/flatten-a-multilevel-doubly-linked-list/README.md index 9bcd39aa9..45570d484 100644 --- a/problems/flatten-a-multilevel-doubly-linked-list/README.md +++ b/problems/flatten-a-multilevel-doubly-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../n-ary-tree-level-order-traversal "N-ary Tree Level Order Traversal") @@ -11,39 +11,31 @@ ## [430. Flatten a Multilevel Doubly Linked List (Medium)](https://leetcode.com/problems/flatten-a-multilevel-doubly-linked-list "扁平化多级双向链表") -

    You are given a doubly linked list which in addition to the next and previous pointers, it could have a child pointer, which may or may not point to a separate doubly linked list. These child lists may have one or more children of their own, and so on, to produce a multilevel data structure, as shown in the example below.

    +

    You are given a doubly linked list, which contains nodes that have a next pointer, a previous pointer, and an additional child pointer. This child pointer may or may not point to a separate doubly linked list, also containing these special nodes. These child lists may have one or more children of their own, and so on, to produce a multilevel data structure as shown in the example below.

    -

    Flatten the list so that all the nodes appear in a single-level, doubly linked list. You are given the head of the first level of the list.

    +

    Given the head of the first level of the list, flatten the list so that all the nodes appear in a single-level, doubly linked list. Let curr be a node with a child list. The nodes in the child list should appear after curr and before curr.next in the flattened list.

    + +

    Return the head of the flattened list. The nodes in the list must have all of their child pointers set to null.

     

    Example 1:

    - +
     Input: head = [1,2,3,4,5,6,null,null,null,7,8,9,10,null,null,11,12]
     Output: [1,2,3,7,8,11,12,9,10,4,5,6]
    -Explanation:
    -
    -The multilevel linked list in the input is as follows:
    -
    -
    -
    +Explanation: The multilevel linked list in the input is shown.
     After flattening the multilevel linked list it becomes:
    -
    -
    +
     

    Example 2:

    - +
     Input: head = [1,2,null,3]
     Output: [1,3,2]
    -Explanation:
    -
    -The input multilevel linked list is as follows:
    -
    -  1---2---NULL
    -  |
    -  3---NULL
    +Explanation: The multilevel linked list in the input is shown.
    +After flattening the multilevel linked list it becomes:
    +
     

    Example 3:

    @@ -51,13 +43,21 @@ After flattening the multilevel linked list it becomes:
     Input: head = []
     Output: []
    +Explanation: There could be empty list in the input.
     

     

    +

    Constraints:

    -

    How multilevel linked list is represented in test case:

    +
      +
    • The number of Nodes will not exceed 1000.
    • +
    • 1 <= Node.val <= 105
    • +
    -

    We use the multilevel linked list from Example 1 above:

    +

     

    +

    How the multilevel linked list is represented in test cases:

    + +

    We use the multilevel linked list from Example 1 above:

      1---2---3---4---5---6--NULL
    @@ -74,26 +74,21 @@ After flattening the multilevel linked list it becomes:
     [11,12,null]
     
    -

    To serialize all levels together we will add nulls in each level to signify no node connects to the upper node of the previous level. The serialization becomes:

    +

    To serialize all levels together, we will add nulls in each level to signify no node connects to the upper node of the previous level. The serialization becomes:

    -[1,2,3,4,5,6,null]
    -[null,null,7,8,9,10,null]
    -[null,11,12,null]
    +[1,    2,    3, 4, 5, 6, null]
    +             |
    +[null, null, 7,    8, 9, 10, null]
    +                   |
    +[            null, 11, 12, null]
     

    Merging the serialization of each level and removing trailing nulls we obtain:

    -[1,2,3,4,5,6,null,null,null,7,8,9,10,null,null,11,12]
    - -

     

    -

    Constraints:

    - -
      -
    • The number of Nodes will not exceed 1000.
    • -
    • 1 <= Node.val <= 105
    • -
    +[1,2,3,4,5,6,null,null,null,7,8,9,10,null,null,11,12] + ### Related Topics [[Depth-First Search](../../tag/depth-first-search/README.md)] diff --git a/problems/flatten-nested-list-iterator/README.md b/problems/flatten-nested-list-iterator/README.md index 703ee263e..de96115b9 100644 --- a/problems/flatten-nested-list-iterator/README.md +++ b/problems/flatten-nested-list-iterator/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-substring-with-at-most-k-distinct-characters "Longest Substring with At Most K Distinct Characters") diff --git a/problems/flip-binary-tree-to-match-preorder-traversal/README.md b/problems/flip-binary-tree-to-match-preorder-traversal/README.md index a1fb9274b..c9c6d7295 100644 --- a/problems/flip-binary-tree-to-match-preorder-traversal/README.md +++ b/problems/flip-binary-tree-to-match-preorder-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../powerful-integers "Powerful Integers") diff --git a/problems/flip-columns-for-maximum-number-of-equal-rows/README.md b/problems/flip-columns-for-maximum-number-of-equal-rows/README.md index 3e99da15b..a1bae20b6 100644 --- a/problems/flip-columns-for-maximum-number-of-equal-rows/README.md +++ b/problems/flip-columns-for-maximum-number-of-equal-rows/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../greatest-common-divisor-of-strings "Greatest Common Divisor of Strings") diff --git a/problems/flip-game/README.md b/problems/flip-game/README.md index 5a155f02b..944792052 100644 --- a/problems/flip-game/README.md +++ b/problems/flip-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../nim-game "Nim Game") diff --git a/problems/flood-fill/README.md b/problems/flood-fill/README.md index 5951f4762..b47ff858f 100644 --- a/problems/flood-fill/README.md +++ b/problems/flood-fill/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../my-calendar-iii "My Calendar III") @@ -49,9 +49,9 @@ Note the bottom corner is not colored 2, because it is not 4-directionally conne ### Related Topics - [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Similar Questions diff --git a/problems/form-array-by-concatenating-subarrays-of-another-array/README.md b/problems/form-array-by-concatenating-subarrays-of-another-array/README.md index 2be6bddc1..6cc68179e 100644 --- a/problems/form-array-by-concatenating-subarrays-of-another-array/README.md +++ b/problems/form-array-by-concatenating-subarrays-of-another-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-nice-substring "Longest Nice Substring") @@ -59,8 +59,8 @@ They share a common elements nums[4] (0-indexed). ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[String Matching](../../tag/string-matching/README.md)] ### Hints diff --git a/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md b/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md index 64067ce77..c79ccb267 100644 --- a/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md +++ b/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-good-nodes-in-binary-tree "Count Good Nodes in Binary Tree") diff --git a/problems/fraction-addition-and-subtraction/README.md b/problems/fraction-addition-and-subtraction/README.md index 1c8149557..56530a40d 100644 --- a/problems/fraction-addition-and-subtraction/README.md +++ b/problems/fraction-addition-and-subtraction/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tag-validator "Tag Validator") diff --git a/problems/frequency-of-the-most-frequent-element/README.md b/problems/frequency-of-the-most-frequent-element/README.md index 31f99ec46..82187cf4f 100644 --- a/problems/frequency-of-the-most-frequent-element/README.md +++ b/problems/frequency-of-the-most-frequent-element/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-digits-in-base-k "Sum of Digits in Base K") diff --git a/problems/friend-requests-ii-who-has-the-most-friends/README.md b/problems/friend-requests-ii-who-has-the-most-friends/README.md index 3603eb6ca..fc66fee5a 100644 --- a/problems/friend-requests-ii-who-has-the-most-friends/README.md +++ b/problems/friend-requests-ii-who-has-the-most-friends/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../human-traffic-of-stadium "Human Traffic of Stadium") diff --git a/problems/friend-requests-ii-who-has-the-most-friends/mysql_schemas.sql b/problems/friend-requests-ii-who-has-the-most-friends/mysql_schemas.sql index ef96415f0..331165b54 100644 --- a/problems/friend-requests-ii-who-has-the-most-friends/mysql_schemas.sql +++ b/problems/friend-requests-ii-who-has-the-most-friends/mysql_schemas.sql @@ -1,6 +1,6 @@ -Create table If Not Exists request_accepted ( requester_id INT NOT NULL, accepter_id INT NULL, accept_date DATE NULL); -Truncate table request_accepted; -insert into request_accepted (requester_id, accepter_id, accept_date) values ('1', '2', '2016/06/03'); -insert into request_accepted (requester_id, accepter_id, accept_date) values ('1', '3', '2016/06/08'); -insert into request_accepted (requester_id, accepter_id, accept_date) values ('2', '3', '2016/06/08'); -insert into request_accepted (requester_id, accepter_id, accept_date) values ('3', '4', '2016/06/09'); +Create table If Not Exists RequestAccepted (requester_id int not null, accepter_id int null, accept_date date null); +Truncate table RequestAccepted; +insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('1', '2', '2016/06/03'); +insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('1', '3', '2016/06/08'); +insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('2', '3', '2016/06/08'); +insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('3', '4', '2016/06/09'); diff --git a/problems/friendly-movies-streamed-last-month/README.md b/problems/friendly-movies-streamed-last-month/README.md index be49a97f7..406712a31 100644 --- a/problems/friendly-movies-streamed-last-month/README.md +++ b/problems/friendly-movies-streamed-last-month/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../parallel-courses-ii "Parallel Courses II") diff --git a/problems/friends-of-appropriate-ages/README.md b/problems/friends-of-appropriate-ages/README.md index acc6b20f9..2cb361627 100644 --- a/problems/friends-of-appropriate-ages/README.md +++ b/problems/friends-of-appropriate-ages/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../goat-latin "Goat Latin") diff --git a/problems/frog-jump/README.md b/problems/frog-jump/README.md index caa47c756..25614c52b 100644 --- a/problems/frog-jump/README.md +++ b/problems/frog-jump/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-k-digits "Remove K Digits") @@ -47,6 +47,3 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - -### Similar Questions - 1. [Minimum Sideway Jumps](../minimum-sideway-jumps) (Medium) diff --git a/problems/frog-position-after-t-seconds/README.md b/problems/frog-position-after-t-seconds/README.md index e65bc3e3d..a47663936 100644 --- a/problems/frog-position-after-t-seconds/README.md +++ b/problems/frog-position-after-t-seconds/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../time-needed-to-inform-all-employees "Time Needed to Inform All Employees") diff --git a/problems/fruit-into-baskets/README.md b/problems/fruit-into-baskets/README.md index 658ca0fad..5ddc874cb 100644 --- a/problems/fruit-into-baskets/README.md +++ b/problems/fruit-into-baskets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-permutations-for-di-sequence "Valid Permutations for DI Sequence") diff --git a/problems/furthest-building-you-can-reach/README.md b/problems/furthest-building-you-can-reach/README.md index 46e316b3f..0eb1d71a5 100644 --- a/problems/furthest-building-you-can-reach/README.md +++ b/problems/furthest-building-you-can-reach/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-sorted-vowel-strings "Count Sorted Vowel Strings") @@ -63,8 +63,8 @@ It is impossible to go beyond building 4 because you do not have any more bricks ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/game-of-nim/README.md b/problems/game-of-nim/README.md index 3b3418858..fcbf6020d 100644 --- a/problems/game-of-nim/README.md +++ b/problems/game-of-nim/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-salary-categories "Count Salary Categories") diff --git a/problems/game-play-analysis-iv/README.md b/problems/game-play-analysis-iv/README.md index 1dbcc4898..78c3fc2e1 100644 --- a/problems/game-play-analysis-iv/README.md +++ b/problems/game-play-analysis-iv/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-tree-longest-consecutive-sequence-ii "Binary Tree Longest Consecutive Sequence II") diff --git a/problems/game-play-analysis-v/README.md b/problems/game-play-analysis-v/README.md index e1f8657bd..6de3e4488 100644 --- a/problems/game-play-analysis-v/README.md +++ b/problems/game-play-analysis-v/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../brace-expansion-ii "Brace Expansion II") diff --git a/problems/gas-station/README.md b/problems/gas-station/README.md index 23e9d83d9..be07ba5dd 100644 --- a/problems/gas-station/README.md +++ b/problems/gas-station/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../clone-graph "Clone Graph") @@ -58,5 +58,5 @@ Therefore, you can't travel around the circuit once no matter where you star ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/gcd-sort-of-an-array/README.md b/problems/gcd-sort-of-an-array/README.md index 743271080..963bb3455 100644 --- a/problems/gcd-sort-of-an-array/README.md +++ b/problems/gcd-sort-of-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../first-day-where-you-have-been-in-all-the-rooms "First Day Where You Have Been in All the Rooms") diff --git a/problems/generalized-abbreviation/README.md b/problems/generalized-abbreviation/README.md index 3111ba7a4..017a197f6 100644 --- a/problems/generalized-abbreviation/README.md +++ b/problems/generalized-abbreviation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../bulb-switcher "Bulb Switcher") @@ -26,9 +26,9 @@

     

    ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Subsets](../subsets) (Medium) diff --git a/problems/generate-a-string-with-characters-that-have-odd-counts/README.md b/problems/generate-a-string-with-characters-that-have-odd-counts/README.md index a8034e1a7..f92d2f599 100644 --- a/problems/generate-a-string-with-characters-that-have-odd-counts/README.md +++ b/problems/generate-a-string-with-characters-that-have-odd-counts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-sum-bst-in-binary-tree "Maximum Sum BST in Binary Tree") diff --git a/problems/generate-random-point-in-a-circle/README.md b/problems/generate-random-point-in-a-circle/README.md index 701e687e8..3ba2759c5 100644 --- a/problems/generate-random-point-in-a-circle/README.md +++ b/problems/generate-random-point-in-a-circle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../total-hamming-distance "Total Hamming Distance") @@ -47,8 +47,8 @@ solution.randPoint(); // return [0.36572, 0.17248] ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] [[Rejection Sampling](../../tag/rejection-sampling/README.md)] [[Randomized](../../tag/randomized/README.md)] diff --git a/problems/get-biggest-three-rhombus-sums-in-a-grid/README.md b/problems/get-biggest-three-rhombus-sums-in-a-grid/README.md index ca48ac971..0d8c4cfcf 100644 --- a/problems/get-biggest-three-rhombus-sums-in-a-grid/README.md +++ b/problems/get-biggest-three-rhombus-sums-in-a-grid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimize-maximum-pair-sum-in-array "Minimize Maximum Pair Sum in Array") diff --git a/problems/get-equal-substrings-within-budget/README.md b/problems/get-equal-substrings-within-budget/README.md index fb5cb6ac9..56d17a731 100644 --- a/problems/get-equal-substrings-within-budget/README.md +++ b/problems/get-equal-substrings-within-budget/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../unique-number-of-occurrences "Unique Number of Occurrences") @@ -55,8 +55,8 @@ ### Related Topics [[String](../../tag/string/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/get-highest-answer-rate-question/README.md b/problems/get-highest-answer-rate-question/README.md index 6da9aabb9..fe5999032 100644 --- a/problems/get-highest-answer-rate-question/README.md +++ b/problems/get-highest-answer-rate-question/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../employee-bonus "Employee Bonus") diff --git a/problems/get-highest-answer-rate-question/mysql_schemas.sql b/problems/get-highest-answer-rate-question/mysql_schemas.sql index ce07f2d2a..c0c01f73a 100644 --- a/problems/get-highest-answer-rate-question/mysql_schemas.sql +++ b/problems/get-highest-answer-rate-question/mysql_schemas.sql @@ -1,6 +1,6 @@ -Create table If Not Exists survey_log (id int, action varchar(255), question_id int, answer_id int, q_num int, timestamp int); -Truncate table survey_log; -insert into survey_log (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'show', '285', 'None', '1', '123'); -insert into survey_log (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'answer', '285', '124124', '1', '124'); -insert into survey_log (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'show', '369', 'None', '2', '125'); -insert into survey_log (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'skip', '369', 'None', '2', '126'); +Create table If Not Exists SurveyLog (id int, action varchar(255), question_id int, answer_id int, q_num int, timestamp int); +Truncate table SurveyLog; +insert into SurveyLog (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'show', '285', 'None', '1', '123'); +insert into SurveyLog (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'answer', '285', '124124', '1', '124'); +insert into SurveyLog (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'show', '369', 'None', '2', '125'); +insert into SurveyLog (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'skip', '369', 'None', '2', '126'); diff --git a/problems/get-maximum-in-generated-array/README.md b/problems/get-maximum-in-generated-array/README.md index 3e9575206..e5d390300 100644 --- a/problems/get-maximum-in-generated-array/README.md +++ b/problems/get-maximum-in-generated-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../hopper-company-queries-ii "Hopper Company Queries II") diff --git a/problems/get-the-maximum-score/README.md b/problems/get-the-maximum-score/README.md index d3b8f3baa..86d638303 100644 --- a/problems/get-the-maximum-score/README.md +++ b/problems/get-the-maximum-score/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-swaps-to-arrange-a-binary-grid "Minimum Swaps to Arrange a Binary Grid") @@ -16,16 +16,14 @@

    A valid path is defined as follows:

      -
    • Choose array nums1 or nums2 to traverse (from index-0).
    • +
    • Choose array nums1 or nums2 to traverse (from index-0).
    • Traverse the current array from left to right.
    • -
    • If you are reading any value that is present in nums1 and nums2 you are allowed to change your path to the other array. (Only one repeated value is considered in the valid path).
    • +
    • If you are reading any value that is present in nums1 and nums2 you are allowed to change your path to the other array. (Only one repeated value is considered in the valid path).
    -

    Score is defined as the sum of uniques values in a valid path.

    +

    The score is defined as the sum of uniques values in a valid path.

    -

    Return the maximum score you can obtain of all possible valid paths.

    - -

    Since the answer may be too large, return it modulo 10^9 + 7.

    +

    Return the maximum score you can obtain of all possible valid paths. Since the answer may be too large, return it modulo 109 + 7.

     

    Example 1:

    @@ -69,9 +67,8 @@ Maximum sum is obtained with the path [6,7,8,9,10].

    Constraints:

      -
    • 1 <= nums1.length <= 10^5
    • -
    • 1 <= nums2.length <= 10^5
    • -
    • 1 <= nums1[i], nums2[i] <= 10^7
    • +
    • 1 <= nums1.length, nums2.length <= 105
    • +
    • 1 <= nums1[i], nums2[i] <= 107
    • nums1 and nums2 are strictly increasing.
    diff --git a/problems/global-and-local-inversions/README.md b/problems/global-and-local-inversions/README.md index fcf250992..37e03dcb7 100644 --- a/problems/global-and-local-inversions/README.md +++ b/problems/global-and-local-inversions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimize-max-distance-to-gas-station "Minimize Max Distance to Gas Station") diff --git a/problems/goal-parser-interpretation/README.md b/problems/goal-parser-interpretation/README.md index fbd323536..bb3dee44a 100644 --- a/problems/goal-parser-interpretation/README.md +++ b/problems/goal-parser-interpretation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../products-worth-over-invoices "Product's Worth Over Invoices") diff --git a/problems/goat-latin/README.md b/problems/goat-latin/README.md index 01ab02553..113402d0a 100644 --- a/problems/goat-latin/README.md +++ b/problems/goat-latin/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-trees-with-factors "Binary Trees With Factors") diff --git a/problems/grand-slam-titles/README.md b/problems/grand-slam-titles/README.md index a5325d294..f47024e06 100644 --- a/problems/grand-slam-titles/README.md +++ b/problems/grand-slam-titles/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-pairs-of-nodes "Count Pairs Of Nodes") diff --git a/problems/graph-connectivity-with-threshold/README.md b/problems/graph-connectivity-with-threshold/README.md index 06834dd1c..c09292090 100644 --- a/problems/graph-connectivity-with-threshold/README.md +++ b/problems/graph-connectivity-with-threshold/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../best-team-with-no-conflicts "Best Team With No Conflicts") diff --git a/problems/graph-valid-tree/README.md b/problems/graph-valid-tree/README.md index 811f8946d..ffb6f3b79 100644 --- a/problems/graph-valid-tree/README.md +++ b/problems/graph-valid-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../single-number-iii "Single Number III") diff --git a/problems/greatest-common-divisor-of-strings/README.md b/problems/greatest-common-divisor-of-strings/README.md index 313d29097..fdacf33b8 100644 --- a/problems/greatest-common-divisor-of-strings/README.md +++ b/problems/greatest-common-divisor-of-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../product-sales-analysis-iii "Product Sales Analysis III") @@ -42,6 +42,9 @@ [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Find Greatest Common Divisor of Array](../find-greatest-common-divisor-of-array) (Easy) + ### Hints
    Hint 1 diff --git a/problems/greatest-sum-divisible-by-three/README.md b/problems/greatest-sum-divisible-by-three/README.md index 229e2df13..5e1039e36 100644 --- a/problems/greatest-sum-divisible-by-three/README.md +++ b/problems/greatest-sum-divisible-by-three/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-elements-in-a-contaminated-binary-tree "Find Elements in a Contaminated Binary Tree") @@ -49,9 +49,9 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/grid-game/README.md b/problems/grid-game/README.md index ee2968e0f..a18819ded 100644 --- a/problems/grid-game/README.md +++ b/problems/grid-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-difference-between-increasing-elements "Maximum Difference Between Increasing Elements") diff --git a/problems/group-anagrams/README.md b/problems/group-anagrams/README.md index a6b12a7c8..03735262a 100644 --- a/problems/group-anagrams/README.md +++ b/problems/group-anagrams/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rotate-image "Rotate Image") diff --git a/problems/group-employees-of-the-same-salary/README.md b/problems/group-employees-of-the-same-salary/README.md index c6e8894fe..f221375de 100644 --- a/problems/group-employees-of-the-same-salary/README.md +++ b/problems/group-employees-of-the-same-salary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimize-product-sum-of-two-arrays "Minimize Product Sum of Two Arrays") diff --git a/problems/group-shifted-strings/README.md b/problems/group-shifted-strings/README.md index 93d32366f..1c029e1c7 100644 --- a/problems/group-shifted-strings/README.md +++ b/problems/group-shifted-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../strobogrammatic-number-iii "Strobogrammatic Number III") diff --git a/problems/group-the-people-given-the-group-size-they-belong-to/README.md b/problems/group-the-people-given-the-group-size-they-belong-to/README.md index 9626d08e9..dba3a9ead 100644 --- a/problems/group-the-people-given-the-group-size-they-belong-to/README.md +++ b/problems/group-the-people-given-the-group-size-they-belong-to/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../subtract-the-product-and-sum-of-digits-of-an-integer "Subtract the Product and Sum of Digits of an Integer") diff --git a/problems/grumpy-bookstore-owner/README.md b/problems/grumpy-bookstore-owner/README.md index 66324b90c..046dc245c 100644 --- a/problems/grumpy-bookstore-owner/README.md +++ b/problems/grumpy-bookstore-owner/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../height-checker "Height Checker") diff --git a/problems/guess-the-majority-in-a-hidden-array/README.md b/problems/guess-the-majority-in-a-hidden-array/README.md index b04070742..633b3be7d 100644 --- a/problems/guess-the-majority-in-a-hidden-array/README.md +++ b/problems/guess-the-majority-in-a-hidden-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../get-the-maximum-score "Get the Maximum Score") diff --git a/problems/guess-the-word/README.md b/problems/guess-the-word/README.md index 91e225d77..488ba5ca4 100644 --- a/problems/guess-the-word/README.md +++ b/problems/guess-the-word/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../split-array-into-fibonacci-sequence "Split Array into Fibonacci Sequence") @@ -59,5 +59,5 @@ We made 5 calls to master.guess and one of them was the secret, so we pass the t [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] - [[Game Theory](../../tag/game-theory/README.md)] [[Interactive](../../tag/interactive/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] diff --git a/problems/h-index-ii/README.md b/problems/h-index-ii/README.md index c569b3fab..4952cf45a 100644 --- a/problems/h-index-ii/README.md +++ b/problems/h-index-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../h-index "H-Index") diff --git a/problems/h-index/README.md b/problems/h-index/README.md index 5e924ef5d..1ac775cba 100644 --- a/problems/h-index/README.md +++ b/problems/h-index/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../integer-to-english-words "Integer to English Words") @@ -45,8 +45,8 @@ Since the researcher has 3 papers with at least 3 citations each and the remaini ### Related Topics [[Array](../../tag/array/README.md)] - [[Sorting](../../tag/sorting/README.md)] [[Counting Sort](../../tag/counting-sort/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Similar Questions 1. [H-Index II](../h-index-ii) (Medium) diff --git a/problems/hand-of-straights/README.md b/problems/hand-of-straights/README.md index cfe25d437..676fad6b1 100644 --- a/problems/hand-of-straights/README.md +++ b/problems/hand-of-straights/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-mountain-in-array "Longest Mountain in Array") @@ -46,7 +46,7 @@

    Note: This question is the same as 1296: https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/

    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/heaters/README.md b/problems/heaters/README.md index c5b3d4d06..ffacf380b 100644 --- a/problems/heaters/README.md +++ b/problems/heaters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../ones-and-zeroes "Ones and Zeroes") @@ -53,5 +53,6 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/height-checker/README.md b/problems/height-checker/README.md index a0eebcf67..01ace7bdc 100644 --- a/problems/height-checker/README.md +++ b/problems/height-checker/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../actors-and-directors-who-cooperated-at-least-three-times "Actors and Directors Who Cooperated At Least Three Times") diff --git a/problems/highest-grade-for-each-student/README.md b/problems/highest-grade-for-each-student/README.md index 69c705d34..42134a56f 100644 --- a/problems/highest-grade-for-each-student/README.md +++ b/problems/highest-grade-for-each-student/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-nesting-depth-of-two-valid-parentheses-strings "Maximum Nesting Depth of Two Valid Parentheses Strings") diff --git a/problems/hopper-company-queries-i/README.md b/problems/hopper-company-queries-i/README.md index 4b5a7682e..da53acdea 100644 --- a/problems/hopper-company-queries-i/README.md +++ b/problems/hopper-company-queries-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../add-two-polynomials-represented-as-linked-lists "Add Two Polynomials Represented as Linked Lists") diff --git a/problems/hopper-company-queries-ii/README.md b/problems/hopper-company-queries-ii/README.md index 19fa94092..61349c63d 100644 --- a/problems/hopper-company-queries-ii/README.md +++ b/problems/hopper-company-queries-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lowest-common-ancestor-of-a-binary-tree-ii "Lowest Common Ancestor of a Binary Tree II") diff --git a/problems/hopper-company-queries-iii/README.md b/problems/hopper-company-queries-iii/README.md index 9f6fd1489..62a14af70 100644 --- a/problems/hopper-company-queries-iii/README.md +++ b/problems/hopper-company-queries-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lowest-common-ancestor-of-a-binary-tree-iii "Lowest Common Ancestor of a Binary Tree III") @@ -15,3 +15,8 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Trips and Users](../trips-and-users) (Hard) + 1. [Hopper Company Queries I](../hopper-company-queries-i) (Hard) + 1. [Hopper Company Queries II](../hopper-company-queries-ii) (Hard) diff --git a/problems/house-robber-ii/README.md b/problems/house-robber-ii/README.md index ec027ba76..221ff0d5e 100644 --- a/problems/house-robber-ii/README.md +++ b/problems/house-robber-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-search-ii "Word Search II") diff --git a/problems/house-robber-iii/README.md b/problems/house-robber-iii/README.md index 1eb529b55..4f3e1613f 100644 --- a/problems/house-robber-iii/README.md +++ b/problems/house-robber-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../palindrome-pairs "Palindrome Pairs") diff --git a/problems/how-many-apples-can-you-put-into-the-basket/README.md b/problems/how-many-apples-can-you-put-into-the-basket/README.md index 81d680a95..b933f4598 100644 --- a/problems/how-many-apples-can-you-put-into-the-basket/README.md +++ b/problems/how-many-apples-can-you-put-into-the-basket/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fizz-buzz-multithreaded "Fizz Buzz Multithreaded") @@ -41,8 +41,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/human-traffic-of-stadium/README.md b/problems/human-traffic-of-stadium/README.md index c12bb4e60..ffdab638f 100644 --- a/problems/human-traffic-of-stadium/README.md +++ b/problems/human-traffic-of-stadium/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../non-negative-integers-without-consecutive-ones "Non-negative Integers without Consecutive Ones") @@ -35,9 +35,11 @@ No two rows will have the same visit_date, and as the id increases, the dates in

    The query result format is in the following example.

     

    +

    Example 1:

    -Stadium table:
    +Input: 
    +Stadium table:
     +------+------------+-----------+
     | id   | visit_date | people    |
     +------+------------+-----------+
    @@ -50,8 +52,7 @@ No two rows will have the same visit_date, and as the id increases, the dates in
     | 7    | 2017-01-07 | 199       |
     | 8    | 2017-01-09 | 188       |
     +------+------------+-----------+
    -
    -Result table:
    +Output: 
     +------+------------+-----------+
     | id   | visit_date | people    |
     +------+------------+-----------+
    @@ -60,8 +61,10 @@ Result table:
     | 7    | 2017-01-07 | 199       |
     | 8    | 2017-01-09 | 188       |
     +------+------------+-----------+
    +Explanation: 
     The four rows with ids 5, 6, 7, and 8 have consecutive ids and each of them has >= 100 people attended. Note that row 8 was included even though the visit_date was not the next day after row 7.
    -The rows with ids 2 and 3 are not included because we need at least three consecutive ids.
    +The rows with ids 2 and 3 are not included because we need at least three consecutive ids. + ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/human-traffic-of-stadium/mysql_schemas.sql b/problems/human-traffic-of-stadium/mysql_schemas.sql index 735337369..b01b95410 100644 --- a/problems/human-traffic-of-stadium/mysql_schemas.sql +++ b/problems/human-traffic-of-stadium/mysql_schemas.sql @@ -1,10 +1,10 @@ -Create table If Not Exists stadium (id int, visit_date DATE NULL, people int); -Truncate table stadium; -insert into stadium (id, visit_date, people) values ('1', '2017-01-01', '10'); -insert into stadium (id, visit_date, people) values ('2', '2017-01-02', '109'); -insert into stadium (id, visit_date, people) values ('3', '2017-01-03', '150'); -insert into stadium (id, visit_date, people) values ('4', '2017-01-04', '99'); -insert into stadium (id, visit_date, people) values ('5', '2017-01-05', '145'); -insert into stadium (id, visit_date, people) values ('6', '2017-01-06', '1455'); -insert into stadium (id, visit_date, people) values ('7', '2017-01-07', '199'); -insert into stadium (id, visit_date, people) values ('8', '2017-01-09', '188'); +Create table If Not Exists Stadium (id int, visit_date DATE NULL, people int); +Truncate table Stadium; +insert into Stadium (id, visit_date, people) values ('1', '2017-01-01', '10'); +insert into Stadium (id, visit_date, people) values ('2', '2017-01-02', '109'); +insert into Stadium (id, visit_date, people) values ('3', '2017-01-03', '150'); +insert into Stadium (id, visit_date, people) values ('4', '2017-01-04', '99'); +insert into Stadium (id, visit_date, people) values ('5', '2017-01-05', '145'); +insert into Stadium (id, visit_date, people) values ('6', '2017-01-06', '1455'); +insert into Stadium (id, visit_date, people) values ('7', '2017-01-07', '199'); +insert into Stadium (id, visit_date, people) values ('8', '2017-01-09', '188'); diff --git a/problems/image-smoother/README.md b/problems/image-smoother/README.md index a664dcfbe..357df58ca 100644 --- a/problems/image-smoother/README.md +++ b/problems/image-smoother/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-9 "Remove 9") diff --git a/problems/implement-magic-dictionary/README.md b/problems/implement-magic-dictionary/README.md index 7237ddd01..212ba9254 100644 --- a/problems/implement-magic-dictionary/README.md +++ b/problems/implement-magic-dictionary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cut-off-trees-for-golf-event "Cut Off Trees for Golf Event") @@ -55,11 +55,11 @@ magicDictionary.search("leetcoded"); // return False ### Related Topics - [[Design](../../tag/design/README.md)] - [[Trie](../../tag/trie/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] + [[Trie](../../tag/trie/README.md)] ### Similar Questions 1. [Implement Trie (Prefix Tree)](../implement-trie-prefix-tree) (Medium) - 1. [Longest Word in Dictionary](../longest-word-in-dictionary) (Easy) + 1. [Longest Word in Dictionary](../longest-word-in-dictionary) (Medium) diff --git a/problems/implement-queue-using-stacks/README.md b/problems/implement-queue-using-stacks/README.md index 6a6b99560..6fc28351e 100644 --- a/problems/implement-queue-using-stacks/README.md +++ b/problems/implement-queue-using-stacks/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../power-of-two "Power of Two") diff --git a/problems/implement-trie-ii-prefix-tree/README.md b/problems/implement-trie-ii-prefix-tree/README.md index a4db81819..f7c7d2d56 100644 --- a/problems/implement-trie-ii-prefix-tree/README.md +++ b/problems/implement-trie-ii-prefix-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-pairs-with-xor-in-a-range "Count Pairs With XOR in a Range") diff --git a/problems/increasing-order-search-tree/README.md b/problems/increasing-order-search-tree/README.md index 166decb16..0d79507af 100644 --- a/problems/increasing-order-search-tree/README.md +++ b/problems/increasing-order-search-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../monotonic-array "Monotonic Array") diff --git a/problems/increasing-triplet-subsequence/README.md b/problems/increasing-triplet-subsequence/README.md index 232b97085..8c9db9595 100644 --- a/problems/increasing-triplet-subsequence/README.md +++ b/problems/increasing-triplet-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-bst-subtree "Largest BST Subtree") diff --git a/problems/incremental-memory-leak/README.md b/problems/incremental-memory-leak/README.md index d2ca85d65..17c716d16 100644 --- a/problems/incremental-memory-leak/README.md +++ b/problems/incremental-memory-leak/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sorting-the-sentence "Sorting the Sentence") diff --git a/problems/inorder-successor-in-bst-ii/README.md b/problems/inorder-successor-in-bst-ii/README.md index 3a0d8f6d5..296fe42ec 100644 --- a/problems/inorder-successor-in-bst-ii/README.md +++ b/problems/inorder-successor-in-bst-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fibonacci-number "Fibonacci Number") diff --git a/problems/inorder-successor-in-bst/README.md b/problems/inorder-successor-in-bst/README.md index 53a67debc..f81ac9086 100644 --- a/problems/inorder-successor-in-bst/README.md +++ b/problems/inorder-successor-in-bst/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../peeking-iterator "Peeking Iterator") diff --git a/problems/insert-interval/README.md b/problems/insert-interval/README.md index c10a0a136..c40a05e55 100644 --- a/problems/insert-interval/README.md +++ b/problems/insert-interval/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../merge-intervals "Merge Intervals") diff --git a/problems/insertion-sort-list/README.md b/problems/insertion-sort-list/README.md index 0f772bb2b..2e918925e 100644 --- a/problems/insertion-sort-list/README.md +++ b/problems/insertion-sort-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lru-cache "LRU Cache") diff --git a/problems/integer-break/README.md b/problems/integer-break/README.md index 0358214d1..0975fcec2 100644 --- a/problems/integer-break/README.md +++ b/problems/integer-break/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../power-of-four "Power of Four") @@ -43,6 +43,9 @@ [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Maximize Number of Nice Divisors](../maximize-number-of-nice-divisors) (Hard) + ### Hints
    Hint 1 diff --git a/problems/intersection-of-three-sorted-arrays/README.md b/problems/intersection-of-three-sorted-arrays/README.md index 5f337a0ef..4c336af5d 100644 --- a/problems/intersection-of-three-sorted-arrays/README.md +++ b/problems/intersection-of-three-sorted-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../team-scores-in-football-tournament "Team Scores in Football Tournament") diff --git a/problems/invalid-transactions/README.md b/problems/invalid-transactions/README.md index 0a84ff410..f8165e7ad 100644 --- a/problems/invalid-transactions/README.md +++ b/problems/invalid-transactions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../optimize-water-distribution-in-a-village "Optimize Water Distribution in a Village") diff --git a/problems/invalid-tweets/README.md b/problems/invalid-tweets/README.md index 098ac36fe..2c9eab577 100644 --- a/problems/invalid-tweets/README.md +++ b/problems/invalid-tweets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-palindromic-subsequence-ii "Longest Palindromic Subsequence II") diff --git a/problems/investments-in-2016/README.md b/problems/investments-in-2016/README.md index 23dfc1764..0d88b615d 100644 --- a/problems/investments-in-2016/README.md +++ b/problems/investments-in-2016/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-customer-referee "Find Customer Referee") diff --git a/problems/ip-to-cidr/README.md b/problems/ip-to-cidr/README.md index 1e4eb571f..be63e0887 100644 --- a/problems/ip-to-cidr/README.md +++ b/problems/ip-to-cidr/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-corner-rectangles "Number Of Corner Rectangles") @@ -63,8 +63,8 @@ that are outside the specified range.

    ### Related Topics - [[String](../../tag/string/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[String](../../tag/string/README.md)] ### Similar Questions 1. [Restore IP Addresses](../restore-ip-addresses) (Medium) diff --git a/problems/is-subsequence/README.md b/problems/is-subsequence/README.md index 64a0597ae..a57e77471 100644 --- a/problems/is-subsequence/README.md +++ b/problems/is-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../perfect-rectangle "Perfect Rectangle") diff --git a/problems/iterator-for-combination/README.md b/problems/iterator-for-combination/README.md index a196371df..193a09a29 100644 --- a/problems/iterator-for-combination/README.md +++ b/problems/iterator-for-combination/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-start-and-end-number-of-continuous-ranges "Find the Start and End Number of Continuous Ranges") diff --git a/problems/jump-game-ii/README.md b/problems/jump-game-ii/README.md index 7a13e8b1d..986e4cccd 100644 --- a/problems/jump-game-ii/README.md +++ b/problems/jump-game-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../wildcard-matching "Wildcard Matching") @@ -44,9 +44,11 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions 1. [Jump Game](../jump-game) (Medium) + 1. [Jump Game III](../jump-game-iii) (Medium) + 1. [Jump Game VII](../jump-game-vii) (Medium) diff --git a/problems/jump-game-vi/README.md b/problems/jump-game-vi/README.md index 7a6eecb5a..e18bac1d8 100644 --- a/problems/jump-game-vi/README.md +++ b/problems/jump-game-vi/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-erasure-value "Maximum Erasure Value") @@ -52,12 +52,16 @@ ### Related Topics - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Queue](../../tag/queue/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Monotonic Queue](../../tag/monotonic-queue/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] + +### Similar Questions + 1. [Sliding Window Maximum](../sliding-window-maximum) (Hard) + 1. [Jump Game VII](../jump-game-vii) (Medium) ### Hints
    diff --git a/problems/jump-game-vii/README.md b/problems/jump-game-vii/README.md index 68a2bd819..b8df8c8f6 100644 --- a/problems/jump-game-vii/README.md +++ b/problems/jump-game-vii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-speed-to-arrive-on-time "Minimum Speed to Arrive on Time") diff --git a/problems/k-concatenation-maximum-sum/README.md b/problems/k-concatenation-maximum-sum/README.md index 7217df2cb..bc3299b89 100644 --- a/problems/k-concatenation-maximum-sum/README.md +++ b/problems/k-concatenation-maximum-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-substrings-between-each-pair-of-parentheses "Reverse Substrings Between Each Pair of Parentheses") diff --git a/problems/k-inverse-pairs-array/README.md b/problems/k-inverse-pairs-array/README.md index e3078c854..965cf20b2 100644 --- a/problems/k-inverse-pairs-array/README.md +++ b/problems/k-inverse-pairs-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-product-of-three-numbers "Maximum Product of Three Numbers") diff --git a/problems/keys-and-rooms/README.md b/problems/keys-and-rooms/README.md index ba29f0504..0e91287a1 100644 --- a/problems/keys-and-rooms/README.md +++ b/problems/keys-and-rooms/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../magic-squares-in-grid "Magic Squares In Grid") @@ -55,3 +55,6 @@ Since we were able to visit every room, we return true. [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] + +### Similar Questions + 1. [Graph Valid Tree](../graph-valid-tree) (Medium) diff --git a/problems/kids-with-the-greatest-number-of-candies/README.md b/problems/kids-with-the-greatest-number-of-candies/README.md index 85ea93f67..248845bf8 100644 --- a/problems/kids-with-the-greatest-number-of-candies/README.md +++ b/problems/kids-with-the-greatest-number-of-candies/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree "Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree") diff --git a/problems/knight-dialer/README.md b/problems/knight-dialer/README.md index a3353836c..4184e20d6 100644 --- a/problems/knight-dialer/README.md +++ b/problems/knight-dialer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-bridge "Shortest Bridge") diff --git a/problems/knight-probability-in-chessboard/README.md b/problems/knight-probability-in-chessboard/README.md index 0de237ddb..6d64e64fb 100644 --- a/problems/knight-probability-in-chessboard/README.md +++ b/problems/knight-probability-in-chessboard/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-univalue-path "Longest Univalue Path") diff --git a/problems/koko-eating-bananas/README.md b/problems/koko-eating-bananas/README.md index 43eeda9ad..89ee52e14 100644 --- a/problems/koko-eating-bananas/README.md +++ b/problems/koko-eating-bananas/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../walking-robot-simulation "Walking Robot Simulation") diff --git a/problems/kth-ancestor-of-a-tree-node/README.md b/problems/kth-ancestor-of-a-tree-node/README.md index 45fab111e..b453b8438 100644 --- a/problems/kth-ancestor-of-a-tree-node/README.md +++ b/problems/kth-ancestor-of-a-tree-node/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-days-to-make-m-bouquets "Minimum Number of Days to Make m Bouquets") @@ -51,12 +51,12 @@ treeAncestor.getKthAncestor(6, 3); // returns -1 because there is no such ancest ### Related Topics + [[Binary Search](../../tag/binary-search/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Design](../../tag/design/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Hints
    diff --git a/problems/kth-distinct-string-in-an-array/README.md b/problems/kth-distinct-string-in-an-array/README.md index f92f4b12e..ecdafd738 100644 --- a/problems/kth-distinct-string-in-an-array/README.md +++ b/problems/kth-distinct-string-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-separate-sentence-into-rows "Minimum Cost to Separate Sentence Into Rows") diff --git a/problems/kth-missing-positive-number/README.md b/problems/kth-missing-positive-number/README.md index 63e8ab069..243391cfb 100644 --- a/problems/kth-missing-positive-number/README.md +++ b/problems/kth-missing-positive-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../guess-the-majority-in-a-hidden-array "Guess the Majority in a Hidden Array") diff --git a/problems/kth-smallest-element-in-a-bst/README.md b/problems/kth-smallest-element-in-a-bst/README.md index f8eda47d2..baf52bc92 100644 --- a/problems/kth-smallest-element-in-a-bst/README.md +++ b/problems/kth-smallest-element-in-a-bst/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../majority-element-ii "Majority Element II") @@ -11,7 +11,7 @@ ## [230. Kth Smallest Element in a BST (Medium)](https://leetcode.com/problems/kth-smallest-element-in-a-bst "二叉搜索树中第K小的元素") -

    Given the root of a binary search tree, and an integer k, return the kth (1-indexed) smallest element in the tree.

    +

    Given the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the tree.

     

    Example 1:

    @@ -38,7 +38,7 @@

     

    -Follow up: If the BST is modified often (i.e., we can do insert and delete operations) and you need to find the kth smallest frequently, how would you optimize? +

    Follow up: If the BST is modified often (i.e., we can do insert and delete operations) and you need to find the kth smallest frequently, how would you optimize?

    ### Related Topics [[Tree](../../tag/tree/README.md)] diff --git a/problems/kth-smallest-instructions/README.md b/problems/kth-smallest-instructions/README.md index 43d8a7e9e..5820b7981 100644 --- a/problems/kth-smallest-instructions/README.md +++ b/problems/kth-smallest-instructions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../furthest-building-you-can-reach "Furthest Building You Can Reach") diff --git a/problems/kth-smallest-number-in-multiplication-table/README.md b/problems/kth-smallest-number-in-multiplication-table/README.md index cda7f63f4..92bfa7196 100644 --- a/problems/kth-smallest-number-in-multiplication-table/README.md +++ b/problems/kth-smallest-number-in-multiplication-table/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../beautiful-arrangement-ii "Beautiful Arrangement II") diff --git a/problems/kth-smallest-product-of-two-sorted-arrays/README.md b/problems/kth-smallest-product-of-two-sorted-arrays/README.md index b15aac8f0..a603687f3 100644 --- a/problems/kth-smallest-product-of-two-sorted-arrays/README.md +++ b/problems/kth-smallest-product-of-two-sorted-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-time-when-the-network-becomes-idle "The Time When the Network Becomes Idle") diff --git a/problems/kth-smallest-subarray-sum/README.md b/problems/kth-smallest-subarray-sum/README.md index 12f5c8f9b..e58ecad9f 100644 --- a/problems/kth-smallest-subarray-sum/README.md +++ b/problems/kth-smallest-subarray-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../leetcodify-friends-recommendations "Leetcodify Friends Recommendations") diff --git a/problems/largest-bst-subtree/README.md b/problems/largest-bst-subtree/README.md index 1c4b2ebfa..69c9b4513 100644 --- a/problems/largest-bst-subtree/README.md +++ b/problems/largest-bst-subtree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reconstruct-itinerary "Reconstruct Itinerary") diff --git a/problems/largest-color-value-in-a-directed-graph/README.md b/problems/largest-color-value-in-a-directed-graph/README.md index 57ca403d2..9ca2b2ad1 100644 --- a/problems/largest-color-value-in-a-directed-graph/README.md +++ b/problems/largest-color-value-in-a-directed-graph/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-subarray-min-product "Maximum Subarray Min-Product") diff --git a/problems/largest-component-size-by-common-factor/README.md b/problems/largest-component-size-by-common-factor/README.md index 7750f88a9..a9303e864 100644 --- a/problems/largest-component-size-by-common-factor/README.md +++ b/problems/largest-component-size-by-common-factor/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flip-equivalent-binary-trees "Flip Equivalent Binary Trees") @@ -52,6 +52,6 @@ ### Related Topics - [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Union Find](../../tag/union-find/README.md)] diff --git a/problems/largest-divisible-subset/README.md b/problems/largest-divisible-subset/README.md index 0f9a2ebe3..18b71216d 100644 --- a/problems/largest-divisible-subset/README.md +++ b/problems/largest-divisible-subset/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-perfect-square "Valid Perfect Square") diff --git a/problems/largest-magic-square/README.md b/problems/largest-magic-square/README.md index 59cda4a50..d0553679e 100644 --- a/problems/largest-magic-square/README.md +++ b/problems/largest-magic-square/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-student-that-will-replace-the-chalk "Find the Student that Will Replace the Chalk") @@ -50,6 +50,9 @@ Every row sum, column sum, and diagonal sum of this magic square is equal to 12. [[Matrix](../../tag/matrix/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] +### Similar Questions + 1. [Magic Squares In Grid](../magic-squares-in-grid) (Medium) + ### Hints
    Hint 1 diff --git a/problems/largest-merge-of-two-strings/README.md b/problems/largest-merge-of-two-strings/README.md index d34b995e1..35fd263b1 100644 --- a/problems/largest-merge-of-two-strings/README.md +++ b/problems/largest-merge-of-two-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-score-from-removing-stones "Maximum Score From Removing Stones") @@ -61,9 +61,9 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/largest-number-after-mutating-substring/README.md b/problems/largest-number-after-mutating-substring/README.md index 1ad178a38..4dd0ddd4a 100644 --- a/problems/largest-number-after-mutating-substring/README.md +++ b/problems/largest-number-after-mutating-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-digits-of-string-after-convert "Sum of Digits of String After Convert") diff --git a/problems/largest-number/README.md b/problems/largest-number/README.md index 696779518..de24d869a 100644 --- a/problems/largest-number/README.md +++ b/problems/largest-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rank-scores "Rank Scores") @@ -53,6 +53,6 @@ ### Related Topics - [[String](../../tag/string/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/largest-odd-number-in-string/README.md b/problems/largest-odd-number-in-string/README.md index 791077f0c..71116c391 100644 --- a/problems/largest-odd-number-in-string/README.md +++ b/problems/largest-odd-number-in-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../depth-of-bst-given-insertion-order "Depth of BST Given Insertion Order") diff --git a/problems/largest-palindrome-product/README.md b/problems/largest-palindrome-product/README.md index b46bed414..0dd3baf0d 100644 --- a/problems/largest-palindrome-product/README.md +++ b/problems/largest-palindrome-product/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../generate-random-point-in-a-circle "Generate Random Point in a Circle") diff --git a/problems/largest-rectangle-in-histogram/README.md b/problems/largest-rectangle-in-histogram/README.md index 8c39df842..9257981d2 100644 --- a/problems/largest-rectangle-in-histogram/README.md +++ b/problems/largest-rectangle-in-histogram/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-duplicates-from-sorted-list "Remove Duplicates from Sorted List") diff --git a/problems/largest-subarray-length-k/README.md b/problems/largest-subarray-length-k/README.md index 468e3c7c9..f4590c82e 100644 --- a/problems/largest-subarray-length-k/README.md +++ b/problems/largest-subarray-length-k/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-xor-with-an-element-from-array "Maximum XOR With an Element From Array") @@ -14,8 +14,8 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/largest-submatrix-with-rearrangements/README.md b/problems/largest-submatrix-with-rearrangements/README.md index 7c6e765e0..6c614e375 100644 --- a/problems/largest-submatrix-with-rearrangements/README.md +++ b/problems/largest-submatrix-with-rearrangements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tuple-with-same-product "Tuple with Same Product") diff --git a/problems/largest-substring-between-two-equal-characters/README.md b/problems/largest-substring-between-two-equal-characters/README.md index 69dbaf3e6..c707c3506 100644 --- a/problems/largest-substring-between-two-equal-characters/README.md +++ b/problems/largest-substring-between-two-equal-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-valid-triplets-that-can-represent-a-country "All Valid Triplets That Can Represent a Country") diff --git a/problems/largest-time-for-given-digits/README.md b/problems/largest-time-for-given-digits/README.md index ba0573dd8..73adf0242 100644 --- a/problems/largest-time-for-given-digits/README.md +++ b/problems/largest-time-for-given-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../bag-of-tokens "Bag of Tokens") diff --git a/problems/largest-unique-number/README.md b/problems/largest-unique-number/README.md index ad2ebb845..ee87cb4c9 100644 --- a/problems/largest-unique-number/README.md +++ b/problems/largest-unique-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reported-posts-ii "Reported Posts II") diff --git a/problems/largest-values-from-labels/README.md b/problems/largest-values-from-labels/README.md index 86b4bc468..b29a41655 100644 --- a/problems/largest-values-from-labels/README.md +++ b/problems/largest-values-from-labels/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../duplicate-zeros "Duplicate Zeros") diff --git a/problems/last-day-where-you-can-still-cross/README.md b/problems/last-day-where-you-can-still-cross/README.md index 4f3148f3d..fbaecbd9f 100644 --- a/problems/last-day-where-you-can-still-cross/README.md +++ b/problems/last-day-where-you-can-still-cross/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-non-zero-product-of-the-array-elements "Minimum Non-Zero Product of the Array Elements") diff --git a/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md b/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md index f68c40999..2cd2780b0 100644 --- a/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md +++ b/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../can-make-arithmetic-progression-from-sequence "Can Make Arithmetic Progression From Sequence") @@ -78,8 +78,8 @@ Note that the last moment when an ant was on the plank is t = 4 second, after th ### Related Topics - [[Brainteaser](../../tag/brainteaser/README.md)] [[Array](../../tag/array/README.md)] + [[Brainteaser](../../tag/brainteaser/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/last-person-to-fit-in-the-bus/README.md b/problems/last-person-to-fit-in-the-bus/README.md index f2795f8aa..68645ff52 100644 --- a/problems/last-person-to-fit-in-the-bus/README.md +++ b/problems/last-person-to-fit-in-the-bus/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-items-by-groups-respecting-dependencies "Sort Items by Groups Respecting Dependencies") diff --git a/problems/last-stone-weight-ii/README.md b/problems/last-stone-weight-ii/README.md index 011157ea3..6a41ec950 100644 --- a/problems/last-stone-weight-ii/README.md +++ b/problems/last-stone-weight-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-string-chain "Longest String Chain") diff --git a/problems/last-stone-weight/README.md b/problems/last-stone-weight/README.md index 5ebb9e946..781736daf 100644 --- a/problems/last-stone-weight/README.md +++ b/problems/last-stone-weight/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../customers-who-bought-all-products "Customers Who Bought All Products") diff --git a/problems/last-substring-in-lexicographical-order/README.md b/problems/last-substring-in-lexicographical-order/README.md index 59cc6eebd..a0a54cd2d 100644 --- a/problems/last-substring-in-lexicographical-order/README.md +++ b/problems/last-substring-in-lexicographical-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../as-far-from-land-as-possible "As Far from Land as Possible") diff --git a/problems/latest-time-by-replacing-hidden-digits/README.md b/problems/latest-time-by-replacing-hidden-digits/README.md index d149d6f02..1410e84f9 100644 --- a/problems/latest-time-by-replacing-hidden-digits/README.md +++ b/problems/latest-time-by-replacing-hidden-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-ways-to-make-array-with-product "Count Ways to Make Array With Product") diff --git a/problems/league-statistics/README.md b/problems/league-statistics/README.md index 726bfab63..30c677001 100644 --- a/problems/league-statistics/README.md +++ b/problems/league-statistics/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-building-height "Maximum Building Height") diff --git a/problems/least-operators-to-express-number/README.md b/problems/least-operators-to-express-number/README.md index d85bbf369..b66220e68 100644 --- a/problems/least-operators-to-express-number/README.md +++ b/problems/least-operators-to-express-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-area-rectangle-ii "Minimum Area Rectangle II") diff --git a/problems/leetcodify-friends-recommendations/README.md b/problems/leetcodify-friends-recommendations/README.md index 1ea2a6933..cb786fb0e 100644 --- a/problems/leetcodify-friends-recommendations/README.md +++ b/problems/leetcodify-friends-recommendations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-ways-to-build-rooms-in-an-ant-colony "Count Ways to Build Rooms in an Ant Colony") diff --git a/problems/leetcodify-similar-friends/README.md b/problems/leetcodify-similar-friends/README.md index 8d1a914e4..f7168514e 100644 --- a/problems/leetcodify-similar-friends/README.md +++ b/problems/leetcodify-similar-friends/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-smallest-subarray-sum "Kth Smallest Subarray Sum") diff --git a/problems/leetflex-banned-accounts/README.md b/problems/leetflex-banned-accounts/README.md index 9abe49cd9..b6c7f5d38 100644 --- a/problems/leetflex-banned-accounts/README.md +++ b/problems/leetflex-banned-accounts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-subarray-sum-after-one-operation "Maximum Subarray Sum After One Operation") diff --git a/problems/letter-case-permutation/README.md b/problems/letter-case-permutation/README.md index 2b66690bb..1599aa88b 100644 --- a/problems/letter-case-permutation/README.md +++ b/problems/letter-case-permutation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-distance-between-bst-nodes "Minimum Distance Between BST Nodes") diff --git a/problems/letter-combinations-of-a-phone-number/README.md b/problems/letter-combinations-of-a-phone-number/README.md index 6a7642720..9137185d6 100644 --- a/problems/letter-combinations-of-a-phone-number/README.md +++ b/problems/letter-combinations-of-a-phone-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../3sum-closest "3Sum Closest") diff --git a/problems/lexicographically-smallest-string-after-applying-operations/README.md b/problems/lexicographically-smallest-string-after-applying-operations/README.md index 5b989496f..d0c943cb6 100644 --- a/problems/lexicographically-smallest-string-after-applying-operations/README.md +++ b/problems/lexicographically-smallest-string-after-applying-operations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-substring-between-two-equal-characters "Largest Substring Between Two Equal Characters") diff --git a/problems/lfu-cache/README.md b/problems/lfu-cache/README.md index fd420a0ad..2f18a3838 100644 --- a/problems/lfu-cache/README.md +++ b/problems/lfu-cache/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../repeated-substring-pattern "Repeated Substring Pattern") diff --git a/problems/linked-list-cycle-ii/README.md b/problems/linked-list-cycle-ii/README.md index 40ac202cf..df0746b4d 100644 --- a/problems/linked-list-cycle-ii/README.md +++ b/problems/linked-list-cycle-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../linked-list-cycle "Linked List Cycle") diff --git a/problems/linked-list-cycle/README.md b/problems/linked-list-cycle/README.md index 1f86ca6c2..9a218076f 100644 --- a/problems/linked-list-cycle/README.md +++ b/problems/linked-list-cycle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-break-ii "Word Break II") diff --git a/problems/linked-list-in-binary-tree/README.md b/problems/linked-list-in-binary-tree/README.md index 20e9f3439..bd5ccf805 100644 --- a/problems/linked-list-in-binary-tree/README.md +++ b/problems/linked-list-in-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rank-teams-by-votes "Rank Teams by Votes") @@ -55,10 +55,10 @@ ### Related Topics - [[Linked List](../../tag/linked-list/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Linked List](../../tag/linked-list/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/list-the-products-ordered-in-a-period/README.md b/problems/list-the-products-ordered-in-a-period/README.md index 5e2623670..d05f83a48 100644 --- a/problems/list-the-products-ordered-in-a-period/README.md +++ b/problems/list-the-products-ordered-in-a-period/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-taps-to-open-to-water-a-garden "Minimum Number of Taps to Open to Water a Garden") diff --git a/problems/longer-contiguous-segments-of-ones-than-zeros/README.md b/problems/longer-contiguous-segments-of-ones-than-zeros/README.md index 707743592..ea4ae8c81 100644 --- a/problems/longer-contiguous-segments-of-ones-than-zeros/README.md +++ b/problems/longer-contiguous-segments-of-ones-than-zeros/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../product-of-two-run-length-encoded-arrays "Product of Two Run-Length Encoded Arrays") diff --git a/problems/longest-absolute-file-path/README.md b/problems/longest-absolute-file-path/README.md index 2d20db2af..12ed18bb9 100644 --- a/problems/longest-absolute-file-path/README.md +++ b/problems/longest-absolute-file-path/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../first-unique-character-in-a-string "First Unique Character in a String") diff --git a/problems/longest-chunked-palindrome-decomposition/README.md b/problems/longest-chunked-palindrome-decomposition/README.md index 9efadd596..6c7f56e26 100644 --- a/problems/longest-chunked-palindrome-decomposition/README.md +++ b/problems/longest-chunked-palindrome-decomposition/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../snapshot-array "Snapshot Array") @@ -63,12 +63,12 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Hash Function](../../tag/hash-function/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Rolling Hash](../../tag/rolling-hash/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Hints
    diff --git a/problems/longest-common-subpath/README.md b/problems/longest-common-subpath/README.md index d0905f5ff..45d219a2c 100644 --- a/problems/longest-common-subpath/README.md +++ b/problems/longest-common-subpath/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-good-numbers "Count Good Numbers") diff --git a/problems/longest-common-subsequence-between-sorted-arrays/README.md b/problems/longest-common-subsequence-between-sorted-arrays/README.md index 11ff4e046..3f9f604dc 100644 --- a/problems/longest-common-subsequence-between-sorted-arrays/README.md +++ b/problems/longest-common-subsequence-between-sorted-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../users-that-actively-request-confirmation-messages "Users That Actively Request Confirmation Messages") diff --git a/problems/longest-continuous-increasing-subsequence/README.md b/problems/longest-continuous-increasing-subsequence/README.md index dd958afd2..c3fe206ee 100644 --- a/problems/longest-continuous-increasing-subsequence/README.md +++ b/problems/longest-continuous-increasing-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-longest-increasing-subsequence "Number of Longest Increasing Subsequence") diff --git a/problems/longest-happy-prefix/README.md b/problems/longest-happy-prefix/README.md index e9dc543d9..673083037 100644 --- a/problems/longest-happy-prefix/README.md +++ b/problems/longest-happy-prefix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-there-is-a-valid-path-in-a-grid "Check if There is a Valid Path in a Grid") diff --git a/problems/longest-happy-string/README.md b/problems/longest-happy-string/README.md index f678998ac..bd6c6c74d 100644 --- a/problems/longest-happy-string/README.md +++ b/problems/longest-happy-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-steps-to-reduce-a-number-in-binary-representation-to-one "Number of Steps to Reduce a Number in Binary Representation to One") @@ -56,8 +56,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/longest-increasing-path-in-a-matrix/README.md b/problems/longest-increasing-path-in-a-matrix/README.md index 213f6ceaf..2561b5543 100644 --- a/problems/longest-increasing-path-in-a-matrix/README.md +++ b/problems/longest-increasing-path-in-a-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../odd-even-linked-list "Odd Even Linked List") @@ -50,9 +50,9 @@ ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] [[Memoization](../../tag/memoization/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/longest-line-of-consecutive-one-in-matrix/README.md b/problems/longest-line-of-consecutive-one-in-matrix/README.md index fb11d2954..a6ea512dd 100644 --- a/problems/longest-line-of-consecutive-one-in-matrix/README.md +++ b/problems/longest-line-of-consecutive-one-in-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../array-partition-i "Array Partition I") diff --git a/problems/longest-nice-substring/README.md b/problems/longest-nice-substring/README.md index 4448c532b..8d3fc5369 100644 --- a/problems/longest-nice-substring/README.md +++ b/problems/longest-nice-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../buildings-with-an-ocean-view "Buildings With an Ocean View") @@ -56,9 +56,9 @@ As there are multiple longest nice substrings, return "dD" since it oc ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints diff --git a/problems/longest-palindromic-subsequence-ii/README.md b/problems/longest-palindromic-subsequence-ii/README.md index 01a6261bd..7e5d73629 100644 --- a/problems/longest-palindromic-subsequence-ii/README.md +++ b/problems/longest-palindromic-subsequence-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-incompatibility "Minimum Incompatibility") diff --git a/problems/longest-palindromic-substring/README.md b/problems/longest-palindromic-substring/README.md index ef45a2370..9e3b74a31 100644 --- a/problems/longest-palindromic-substring/README.md +++ b/problems/longest-palindromic-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../median-of-two-sorted-arrays "Median of Two Sorted Arrays") diff --git a/problems/longest-repeating-character-replacement/README.md b/problems/longest-repeating-character-replacement/README.md index 42e657293..650562490 100644 --- a/problems/longest-repeating-character-replacement/README.md +++ b/problems/longest-repeating-character-replacement/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reconstruct-original-digits-from-english "Reconstruct Original Digits from English") diff --git a/problems/longest-repeating-substring/README.md b/problems/longest-repeating-substring/README.md index 73900af81..0f83a9c26 100644 --- a/problems/longest-repeating-substring/README.md +++ b/problems/longest-repeating-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lexicographically-smallest-equivalent-string "Lexicographically Smallest Equivalent String") diff --git a/problems/longest-string-chain/README.md b/problems/longest-string-chain/README.md index 1aeb2e1e1..d659234b5 100644 --- a/problems/longest-string-chain/README.md +++ b/problems/longest-string-chain/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-all-adjacent-duplicates-in-string "Remove All Adjacent Duplicates In String") diff --git a/problems/longest-subarray-of-1s-after-deleting-one-element/README.md b/problems/longest-subarray-of-1s-after-deleting-one-element/README.md index 06ad49cf8..6da0a32b4 100644 --- a/problems/longest-subarray-of-1s-after-deleting-one-element/README.md +++ b/problems/longest-subarray-of-1s-after-deleting-one-element/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-kth-factor-of-n "The kth Factor of n") diff --git a/problems/longest-subsequence-repeated-k-times/README.md b/problems/longest-subsequence-repeated-k-times/README.md index 3e8e416f0..eb18b2de0 100644 --- a/problems/longest-subsequence-repeated-k-times/README.md +++ b/problems/longest-subsequence-repeated-k-times/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../detect-squares "Detect Squares") diff --git a/problems/longest-substring-of-all-vowels-in-order/README.md b/problems/longest-substring-of-all-vowels-in-order/README.md index 19e072052..c3cb2938b 100644 --- a/problems/longest-substring-of-all-vowels-in-order/README.md +++ b/problems/longest-substring-of-all-vowels-in-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../frequency-of-the-most-frequent-element "Frequency of the Most Frequent Element") diff --git a/problems/longest-substring-with-at-least-k-repeating-characters/README.md b/problems/longest-substring-with-at-least-k-repeating-characters/README.md index 2186a91b8..399a1e0f2 100644 --- a/problems/longest-substring-with-at-least-k-repeating-characters/README.md +++ b/problems/longest-substring-with-at-least-k-repeating-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../decode-string "Decode String") diff --git a/problems/longest-substring-with-at-most-k-distinct-characters/README.md b/problems/longest-substring-with-at-most-k-distinct-characters/README.md index 3acc212e7..b2e57c3fa 100644 --- a/problems/longest-substring-with-at-most-k-distinct-characters/README.md +++ b/problems/longest-substring-with-at-most-k-distinct-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../nested-list-weight-sum "Nested List Weight Sum") diff --git a/problems/longest-substring-with-at-most-two-distinct-characters/README.md b/problems/longest-substring-with-at-most-two-distinct-characters/README.md index f0eb80c88..34675cf52 100644 --- a/problems/longest-substring-with-at-most-two-distinct-characters/README.md +++ b/problems/longest-substring-with-at-most-two-distinct-characters/README.md @@ -1,11 +1,11 @@ - - - + + + -[< Previous](../read-n-characters-given-read4-ii-call-multiple-times "Read N Characters Given Read4 II - Call multiple times") +[< Previous](../read-n-characters-given-read4-ii-call-multiple-times "Read N Characters Given read4 II - Call Multiple Times")                  [Next >](../intersection-of-two-linked-lists "Intersection of Two Linked Lists") diff --git a/problems/longest-turbulent-subarray/README.md b/problems/longest-turbulent-subarray/README.md index 7487ae651..f73561019 100644 --- a/problems/longest-turbulent-subarray/README.md +++ b/problems/longest-turbulent-subarray/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../squares-of-a-sorted-array "Squares of a Sorted Array") diff --git a/problems/longest-uncommon-subsequence-i/README.md b/problems/longest-uncommon-subsequence-i/README.md index 604a89b0e..eaafad4e9 100644 --- a/problems/longest-uncommon-subsequence-i/README.md +++ b/problems/longest-uncommon-subsequence-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../detect-capital "Detect Capital") diff --git a/problems/longest-well-performing-interval/README.md b/problems/longest-well-performing-interval/README.md index 808f061bf..d9318ddc4 100644 --- a/problems/longest-well-performing-interval/README.md +++ b/problems/longest-well-performing-interval/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lowest-common-ancestor-of-deepest-leaves "Lowest Common Ancestor of Deepest Leaves") diff --git a/problems/longest-word-in-dictionary-through-deleting/README.md b/problems/longest-word-in-dictionary-through-deleting/README.md index 2a5c3657c..4569d4553 100644 --- a/problems/longest-word-in-dictionary-through-deleting/README.md +++ b/problems/longest-word-in-dictionary-through-deleting/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../continuous-subarray-sum "Continuous Subarray Sum") @@ -45,4 +45,4 @@ [[Sorting](../../tag/sorting/README.md)] ### Similar Questions - 1. [Longest Word in Dictionary](../longest-word-in-dictionary) (Easy) + 1. [Longest Word in Dictionary](../longest-word-in-dictionary) (Medium) diff --git a/problems/longest-word-in-dictionary/README.md b/problems/longest-word-in-dictionary/README.md index b7d6e76d6..4af3ff4db 100644 --- a/problems/longest-word-in-dictionary/README.md +++ b/problems/longest-word-in-dictionary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-k-th-smallest-pair-distance "Find K-th Smallest Pair Distance") diff --git a/problems/longest-word-with-all-prefixes/README.md b/problems/longest-word-with-all-prefixes/README.md index 7dfc2a6ba..f43785bbb 100644 --- a/problems/longest-word-with-all-prefixes/README.md +++ b/problems/longest-word-with-all-prefixes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-color-value-in-a-directed-graph "Largest Color Value in a Directed Graph") diff --git a/problems/longest-zigzag-path-in-a-binary-tree/README.md b/problems/longest-zigzag-path-in-a-binary-tree/README.md index b61ea3691..9790e1013 100644 --- a/problems/longest-zigzag-path-in-a-binary-tree/README.md +++ b/problems/longest-zigzag-path-in-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-longest-substring-containing-vowels-in-even-counts "Find the Longest Substring Containing Vowels in Even Counts") diff --git a/problems/low-quality-problems/README.md b/problems/low-quality-problems/README.md index 735e73f63..9daaf212c 100644 --- a/problems/low-quality-problems/README.md +++ b/problems/low-quality-problems/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-ways-to-partition-an-array "Maximum Number of Ways to Partition an Array") diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md index d4d4f6ea0..bd6b7bf17 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-smallest-instructions "Kth Smallest Instructions") diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md index f0cf11398..856c04b3a 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../create-sorted-array-through-instructions "Create Sorted Array through Instructions") diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md index ecc88fe56..026487e5f 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimize-deviation-in-array "Minimize Deviation in Array") @@ -18,14 +18,6 @@ [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] -### Similar Questions - 1. [Lowest Common Ancestor of a Binary Search Tree](../lowest-common-ancestor-of-a-binary-search-tree) (Easy) - 1. [Lowest Common Ancestor of a Binary Tree](../lowest-common-ancestor-of-a-binary-tree) (Medium) - 1. [Lowest Common Ancestor of Deepest Leaves](../lowest-common-ancestor-of-deepest-leaves) (Medium) - 1. [Lowest Common Ancestor of a Binary Tree II](../lowest-common-ancestor-of-a-binary-tree-ii) (Medium) - 1. [Lowest Common Ancestor of a Binary Tree III](../lowest-common-ancestor-of-a-binary-tree-iii) (Medium) - 1. [Lowest Common Ancestor of a Binary Tree IV](../lowest-common-ancestor-of-a-binary-tree-iv) (Medium) - ### Hints
    Hint 1 diff --git a/problems/lowest-common-ancestor-of-deepest-leaves/README.md b/problems/lowest-common-ancestor-of-deepest-leaves/README.md index 723e47239..bb79771bb 100644 --- a/problems/lowest-common-ancestor-of-deepest-leaves/README.md +++ b/problems/lowest-common-ancestor-of-deepest-leaves/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../relative-sort-array "Relative Sort Array") @@ -60,12 +60,15 @@ Note that nodes 6, 0, and 8 are also leaf nodes, but the depth of them is 2, but

    Note: This question is the same as 865: https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/

    ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Lowest Common Ancestor of a Binary Tree IV](../lowest-common-ancestor-of-a-binary-tree-iv) (Medium) + ### Hints
    Hint 1 diff --git a/problems/lucky-numbers-in-a-matrix/README.md b/problems/lucky-numbers-in-a-matrix/README.md index 459c575c6..a48481978 100644 --- a/problems/lucky-numbers-in-a-matrix/README.md +++ b/problems/lucky-numbers-in-a-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree "Find a Corresponding Node of a Binary Tree in a Clone of That Tree") diff --git a/problems/magical-string/README.md b/problems/magical-string/README.md index 176c447fd..6b960806b 100644 --- a/problems/magical-string/README.md +++ b/problems/magical-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sliding-window-median "Sliding Window Median") diff --git a/problems/magnetic-force-between-two-balls/README.md b/problems/magnetic-force-between-two-balls/README.md index 7cf25a0cb..f9fc9e02f 100644 --- a/problems/magnetic-force-between-two-balls/README.md +++ b/problems/magnetic-force-between-two-balls/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-operations-to-make-array-equal "Minimum Operations to Make Array Equal") @@ -11,11 +11,11 @@ ## [1552. Magnetic Force Between Two Balls (Medium)](https://leetcode.com/problems/magnetic-force-between-two-balls "两球之间的磁力") -

    In universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket. Rick has n empty baskets, the ith basket is at position[i], Morty has m balls and needs to distribute the balls into the baskets such that the minimum magnetic force between any two balls is maximum.

    +

    In the universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket. Rick has n empty baskets, the ith basket is at position[i], Morty has m balls and needs to distribute the balls into the baskets such that the minimum magnetic force between any two balls is maximum.

    -

    Rick stated that magnetic force between two different balls at positions x and y is |x - y|.

    +

    Rick stated that magnetic force between two different balls at positions x and y is |x - y|.

    -

    Given the integer array position and the integer m. Return the required force.

    +

    Given the integer array position and the integer m. Return the required force.

     

    Example 1:

    @@ -39,8 +39,8 @@
    • n == position.length
    • -
    • 2 <= n <= 10^5
    • -
    • 1 <= position[i] <= 10^9
    • +
    • 2 <= n <= 105
    • +
    • 1 <= position[i] <= 109
    • All integers in position are distinct.
    • 2 <= m <= position.length
    diff --git a/problems/make-sum-divisible-by-p/README.md b/problems/make-sum-divisible-by-p/README.md index 7339ec36b..ecef87f72 100644 --- a/problems/make-sum-divisible-by-p/README.md +++ b/problems/make-sum-divisible-by-p/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-sum-obtained-of-any-permutation "Maximum Sum Obtained of Any Permutation") @@ -71,9 +71,6 @@ [[Hash Table](../../tag/hash-table/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] -### Similar Questions - 1. [Subarray Sums Divisible by K](../subarray-sums-divisible-by-k) (Medium) - ### Hints
    Hint 1 diff --git a/problems/make-the-string-great/README.md b/problems/make-the-string-great/README.md index 3512fd642..2f6e82d68 100644 --- a/problems/make-the-string-great/README.md +++ b/problems/make-the-string-great/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fix-product-name-format "Fix Product Name Format") @@ -13,11 +13,11 @@

    Given a string s of lower and upper case English letters.

    -

    A good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where:

    +

    A good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where:

    • 0 <= i <= s.length - 2
    • -
    • s[i] is a lower-case letter and s[i + 1] is the same letter but in upper-case or vice-versa.
    • +
    • s[i] is a lower-case letter and s[i + 1] is the same letter but in upper-case or vice-versa.

    To make the string good, you can choose two adjacent characters that make the string bad and remove them. You can keep doing this until the string becomes good.

    diff --git a/problems/make-the-xor-of-all-segments-equal-to-zero/README.md b/problems/make-the-xor-of-all-segments-equal-to-zero/README.md index 1a20704bd..050bb69d1 100644 --- a/problems/make-the-xor-of-all-segments-equal-to-zero/README.md +++ b/problems/make-the-xor-of-all-segments-equal-to-zero/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-restricted-paths-from-first-to-last-node "Number of Restricted Paths From First to Last Node") @@ -48,9 +48,9 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/making-file-names-unique/README.md b/problems/making-file-names-unique/README.md index 52a57457b..dc950449f 100644 --- a/problems/making-file-names-unique/README.md +++ b/problems/making-file-names-unique/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../xor-operation-in-an-array "XOR Operation in an Array") diff --git a/problems/map-of-highest-peak/README.md b/problems/map-of-highest-peak/README.md index c5d8c841d..e87e23d08 100644 --- a/problems/map-of-highest-peak/README.md +++ b/problems/map-of-highest-peak/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../form-array-by-concatenating-subarrays-of-another-array "Form Array by Concatenating Subarrays of Another Array") @@ -65,8 +65,8 @@ Any height assignment that has a maximum height of 2 while still meeting the rul ### Related Topics - [[Array](../../tag/array/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/market-analysis-i/README.md b/problems/market-analysis-i/README.md index b5f72e68f..db202cb38 100644 --- a/problems/market-analysis-i/README.md +++ b/problems/market-analysis-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../online-majority-element-in-subarray "Online Majority Element In Subarray") diff --git a/problems/market-analysis-i/mysql_schemas.sql b/problems/market-analysis-i/mysql_schemas.sql index 31eafa569..82f724345 100644 --- a/problems/market-analysis-i/mysql_schemas.sql +++ b/problems/market-analysis-i/mysql_schemas.sql @@ -1,6 +1,6 @@ Create table If Not Exists Users (user_id int, join_date date, favorite_brand varchar(10)); -create table if not exists Orders (order_id int, order_date date, item_id int, buyer_id int, seller_id int); -create table if not exists Items (item_id int, item_brand varchar(10)); +Create table If Not Exists Orders (order_id int, order_date date, item_id int, buyer_id int, seller_id int); +Create table If Not Exists Items (item_id int, item_brand varchar(10)); Truncate table Users; insert into Users (user_id, join_date, favorite_brand) values ('1', '2018-01-01', 'Lenovo'); insert into Users (user_id, join_date, favorite_brand) values ('2', '2018-02-09', 'Samsung'); diff --git a/problems/market-analysis-ii/README.md b/problems/market-analysis-ii/README.md index f1c2f278c..90625782d 100644 --- a/problems/market-analysis-ii/README.md +++ b/problems/market-analysis-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../market-analysis-i "Market Analysis I") diff --git a/problems/market-analysis-ii/mysql_schemas.sql b/problems/market-analysis-ii/mysql_schemas.sql index 2932728aa..1eea2fa16 100644 --- a/problems/market-analysis-ii/mysql_schemas.sql +++ b/problems/market-analysis-ii/mysql_schemas.sql @@ -1,6 +1,6 @@ Create table If Not Exists Users (user_id int, join_date date, favorite_brand varchar(10)); -create table if not exists Orders (order_id int, order_date date, item_id int, buyer_id int, seller_id int); -create table if not exists Items (item_id int, item_brand varchar(10)); +Create table If Not Exists Orders (order_id int, order_date date, item_id int, buyer_id int, seller_id int); +Create table If Not Exists Items (item_id int, item_brand varchar(10)); Truncate table Users; insert into Users (user_id, join_date, favorite_brand) values ('1', '2019-01-01', 'Lenovo'); insert into Users (user_id, join_date, favorite_brand) values ('2', '2019-02-09', 'Samsung'); diff --git a/problems/masking-personal-information/README.md b/problems/masking-personal-information/README.md index 855d82be5..7269126a5 100644 --- a/problems/masking-personal-information/README.md +++ b/problems/masking-personal-information/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../positions-of-large-groups "Positions of Large Groups") diff --git a/problems/matrix-diagonal-sum/README.md b/problems/matrix-diagonal-sum/README.md index 36266ded8..f45ad0315 100644 --- a/problems/matrix-diagonal-sum/README.md +++ b/problems/matrix-diagonal-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../warehouse-manager "Warehouse Manager") diff --git a/problems/max-area-of-island/README.md b/problems/max-area-of-island/README.md index fdc129b02..670981ff1 100644 --- a/problems/max-area-of-island/README.md +++ b/problems/max-area-of-island/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-distinct-islands "Number of Distinct Islands") @@ -44,12 +44,13 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Similar Questions 1. [Number of Islands](../number-of-islands) (Medium) 1. [Island Perimeter](../island-perimeter) (Easy) + 1. [Largest Submatrix With Rearrangements](../largest-submatrix-with-rearrangements) (Medium) diff --git a/problems/max-chunks-to-make-sorted/README.md b/problems/max-chunks-to-make-sorted/README.md index f83c459f5..f5bbcec5d 100644 --- a/problems/max-chunks-to-make-sorted/README.md +++ b/problems/max-chunks-to-make-sorted/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-chunks-to-make-sorted-ii "Max Chunks To Make Sorted II") diff --git a/problems/max-number-of-k-sum-pairs/README.md b/problems/max-number-of-k-sum-pairs/README.md index 5f9d4e125..3fbe61087 100644 --- a/problems/max-number-of-k-sum-pairs/README.md +++ b/problems/max-number-of-k-sum-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../goal-parser-interpretation "Goal Parser Interpretation") @@ -52,10 +52,6 @@ There are no more pairs that sum up to 6, hence a total of 1 operation. [[Two Pointers](../../tag/two-pointers/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Two Sum](../two-sum) (Easy) - 1. [Count Good Meals](../count-good-meals) (Medium) - ### Hints
    Hint 1 diff --git a/problems/max-stack/README.md b/problems/max-stack/README.md index 82a74168f..638b9406a 100644 --- a/problems/max-stack/README.md +++ b/problems/max-stack/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../range-module "Range Module") diff --git a/problems/max-sum-of-rectangle-no-larger-than-k/README.md b/problems/max-sum-of-rectangle-no-larger-than-k/README.md index 6ecd97fc0..fd0a83635 100644 --- a/problems/max-sum-of-rectangle-no-larger-than-k/README.md +++ b/problems/max-sum-of-rectangle-no-larger-than-k/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-hit-counter "Design Hit Counter") diff --git a/problems/max-value-of-equation/README.md b/problems/max-value-of-equation/README.md index 09a54ceb8..485de6f96 100644 --- a/problems/max-value-of-equation/README.md +++ b/problems/max-value-of-equation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-subsequences-that-satisfy-the-given-sum-condition "Number of Subsequences That Satisfy the Given Sum Condition") @@ -48,14 +48,11 @@ No other pairs satisfy the condition, so we return the max of 4 and 1. ### Related Topics - [[Array](../../tag/array/README.md)] [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] [[Monotonic Queue](../../tag/monotonic-queue/README.md)] - -### Similar Questions - 1. [Count Pairs in Two Arrays](../count-pairs-in-two-arrays) (Medium) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/maximal-network-rank/README.md b/problems/maximal-network-rank/README.md index 6526d1dc1..d5630d2b3 100644 --- a/problems/maximal-network-rank/README.md +++ b/problems/maximal-network-rank/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-nesting-depth-of-the-parentheses "Maximum Nesting Depth of the Parentheses") diff --git a/problems/maximal-rectangle/README.md b/problems/maximal-rectangle/README.md index 4f3f25908..0a5485bb9 100644 --- a/problems/maximal-rectangle/README.md +++ b/problems/maximal-rectangle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-rectangle-in-histogram "Largest Rectangle in Histogram") @@ -61,9 +61,9 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Stack](../../tag/stack/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] diff --git a/problems/maximize-distance-to-closest-person/README.md b/problems/maximize-distance-to-closest-person/README.md index 53c48ce05..e998d48da 100644 --- a/problems/maximize-distance-to-closest-person/README.md +++ b/problems/maximize-distance-to-closest-person/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shifting-letters "Shifting Letters") diff --git a/problems/maximize-grid-happiness/README.md b/problems/maximize-grid-happiness/README.md index b06fc1fe4..55e3d6ec6 100644 --- a/problems/maximize-grid-happiness/README.md +++ b/problems/maximize-grid-happiness/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-operations-to-reduce-x-to-zero "Minimum Operations to Reduce X to Zero") @@ -69,9 +69,9 @@ The grid happiness is 90 + 80 + 90 = 260. ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Memoization](../../tag/memoization/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bitmask](../../tag/bitmask/README.md)] ### Hints diff --git a/problems/maximize-number-of-nice-divisors/README.md b/problems/maximize-number-of-nice-divisors/README.md index 962ddb55d..b325bd1cf 100644 --- a/problems/maximize-number-of-nice-divisors/README.md +++ b/problems/maximize-number-of-nice-divisors/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../evaluate-the-bracket-pairs-of-a-string "Evaluate the Bracket Pairs of a String") @@ -48,11 +48,8 @@ There is not other value of n that has at most 5 prime factors and more nice div ### Related Topics - [[Math](../../tag/math/README.md)] [[Recursion](../../tag/recursion/README.md)] - -### Similar Questions - 1. [Integer Break](../integer-break) (Medium) + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/maximize-palindrome-length-from-subsequences/README.md b/problems/maximize-palindrome-length-from-subsequences/README.md index ecd3dcc68..d81e5e0b6 100644 --- a/problems/maximize-palindrome-length-from-subsequences/README.md +++ b/problems/maximize-palindrome-length-from-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-score-from-performing-multiplication-operations "Maximum Score from Performing Multiplication Operations") @@ -59,9 +59,6 @@ [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] -### Similar Questions - 1. [Longest Palindromic Subsequence](../longest-palindromic-subsequence) (Medium) - ### Hints
    Hint 1 diff --git a/problems/maximize-score-after-n-operations/README.md b/problems/maximize-score-after-n-operations/README.md index 15161e2ff..2435627b1 100644 --- a/problems/maximize-score-after-n-operations/README.md +++ b/problems/maximize-score-after-n-operations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-consecutive-values-you-can-make "Maximum Number of Consecutive Values You Can Make") diff --git a/problems/maximize-the-beauty-of-the-garden/README.md b/problems/maximize-the-beauty-of-the-garden/README.md index 5ac672d74..20133a4ef 100644 --- a/problems/maximize-the-beauty-of-the-garden/README.md +++ b/problems/maximize-the-beauty-of-the-garden/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../make-the-xor-of-all-segments-equal-to-zero "Make the XOR of All Segments Equal to Zero") @@ -14,8 +14,8 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints diff --git a/problems/maximize-the-confusion-of-an-exam/README.md b/problems/maximize-the-confusion-of-an-exam/README.md index ba4f6fa1d..f750e9c89 100644 --- a/problems/maximize-the-confusion-of-an-exam/README.md +++ b/problems/maximize-the-confusion-of-an-exam/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-pairs-of-strings-with-concatenation-equal-to-target "Number of Pairs of Strings With Concatenation Equal to Target") diff --git a/problems/maximum-absolute-sum-of-any-subarray/README.md b/problems/maximum-absolute-sum-of-any-subarray/README.md index 8c23314be..77031437a 100644 --- a/problems/maximum-absolute-sum-of-any-subarray/README.md +++ b/problems/maximum-absolute-sum-of-any-subarray/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-unique-elements "Sum of Unique Elements") @@ -51,9 +51,6 @@ [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] -### Similar Questions - 1. [Maximum Subarray](../maximum-subarray) (Easy) - ### Hints
    Hint 1 diff --git a/problems/maximum-alternating-subarray-sum/README.md b/problems/maximum-alternating-subarray-sum/README.md index ff48c4c69..0ae635e82 100644 --- a/problems/maximum-alternating-subarray-sum/README.md +++ b/problems/maximum-alternating-subarray-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../partition-array-into-two-arrays-to-minimize-sum-difference "Partition Array Into Two Arrays to Minimize Sum Difference") diff --git a/problems/maximum-alternating-subsequence-sum/README.md b/problems/maximum-alternating-subsequence-sum/README.md index 93376d6f3..2265c28fd 100644 --- a/problems/maximum-alternating-subsequence-sum/README.md +++ b/problems/maximum-alternating-subsequence-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-all-occurrences-of-a-substring "Remove All Occurrences of a Substring") diff --git a/problems/maximum-ascending-subarray-sum/README.md b/problems/maximum-ascending-subarray-sum/README.md index 01261c083..33dd72404 100644 --- a/problems/maximum-ascending-subarray-sum/README.md +++ b/problems/maximum-ascending-subarray-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximize-score-after-n-operations "Maximize Score After N Operations") diff --git a/problems/maximum-average-pass-ratio/README.md b/problems/maximum-average-pass-ratio/README.md index d6491109e..d4bcfbbb9 100644 --- a/problems/maximum-average-pass-ratio/README.md +++ b/problems/maximum-average-pass-ratio/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-center-of-star-graph "Find Center of Star Graph") @@ -46,8 +46,8 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/maximum-average-subarray-i/README.md b/problems/maximum-average-subarray-i/README.md index 46233ffdc..47c8abf56 100644 --- a/problems/maximum-average-subarray-i/README.md +++ b/problems/maximum-average-subarray-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-search-autocomplete-system "Design Search Autocomplete System") diff --git a/problems/maximum-average-subarray-ii/README.md b/problems/maximum-average-subarray-ii/README.md index 30b24b8d5..323fe56de 100644 --- a/problems/maximum-average-subarray-ii/README.md +++ b/problems/maximum-average-subarray-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-average-subarray-i "Maximum Average Subarray I") diff --git a/problems/maximum-average-subtree/README.md b/problems/maximum-average-subtree/README.md index c47644c8e..87f334554 100644 --- a/problems/maximum-average-subtree/README.md +++ b/problems/maximum-average-subtree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-vowels-from-a-string "Remove Vowels from a String") diff --git a/problems/maximum-binary-string-after-change/README.md b/problems/maximum-binary-string-after-change/README.md index 2f37d4d4a..07af7eb1a 100644 --- a/problems/maximum-binary-string-after-change/README.md +++ b/problems/maximum-binary-string-after-change/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../average-waiting-time "Average Waiting Time") @@ -59,8 +59,8 @@ ### Related Topics - [[String](../../tag/string/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/maximum-binary-tree/README.md b/problems/maximum-binary-tree/README.md index a3e73213f..c2a8af6e9 100644 --- a/problems/maximum-binary-tree/README.md +++ b/problems/maximum-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-sum-iv-input-is-a-bst "Two Sum IV - Input is a BST") diff --git a/problems/maximum-building-height/README.md b/problems/maximum-building-height/README.md index 011a85a98..00f21bae3 100644 --- a/problems/maximum-building-height/README.md +++ b/problems/maximum-building-height/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-substring-of-all-vowels-in-order "Longest Substring Of All Vowels in Order") diff --git a/problems/maximum-candies-you-can-get-from-boxes/README.md b/problems/maximum-candies-you-can-get-from-boxes/README.md index 97727578b..7977327ee 100644 --- a/problems/maximum-candies-you-can-get-from-boxes/README.md +++ b/problems/maximum-candies-you-can-get-from-boxes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-occurrences-of-a-substring "Maximum Number of Occurrences of a Substring") @@ -84,8 +84,8 @@ Total number of candies collected = 7 + 4 + 5 = 16 candy. ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Hints
    diff --git a/problems/maximum-compatibility-score-sum/README.md b/problems/maximum-compatibility-score-sum/README.md index 7c86bc6c7..f0aa7c7a8 100644 --- a/problems/maximum-compatibility-score-sum/README.md +++ b/problems/maximum-compatibility-score-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-number-after-mutating-substring "Largest Number After Mutating Substring") diff --git a/problems/maximum-depth-of-n-ary-tree/README.md b/problems/maximum-depth-of-n-ary-tree/README.md index 77baede93..77172cb21 100644 --- a/problems/maximum-depth-of-n-ary-tree/README.md +++ b/problems/maximum-depth-of-n-ary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../logical-or-of-two-binary-grids-represented-as-quad-trees "Logical OR of Two Binary Grids Represented as Quad-Trees") @@ -51,3 +51,4 @@ ### Similar Questions 1. [Maximum Depth of Binary Tree](../maximum-depth-of-binary-tree) (Easy) + 1. [The Time When the Network Becomes Idle](../the-time-when-the-network-becomes-idle) (Medium) diff --git a/problems/maximum-difference-between-increasing-elements/README.md b/problems/maximum-difference-between-increasing-elements/README.md index c8e49c793..30cb293a1 100644 --- a/problems/maximum-difference-between-increasing-elements/README.md +++ b/problems/maximum-difference-between-increasing-elements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../average-height-of-buildings-in-each-segment "Average Height of Buildings in Each Segment") diff --git a/problems/maximum-distance-between-a-pair-of-values/README.md b/problems/maximum-distance-between-a-pair-of-values/README.md index c25f541de..6303a4c38 100644 --- a/problems/maximum-distance-between-a-pair-of-values/README.md +++ b/problems/maximum-distance-between-a-pair-of-values/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-population-year "Maximum Population Year") diff --git a/problems/maximum-distance-in-arrays/README.md b/problems/maximum-distance-in-arrays/README.md index 3822d27e7..b9bcdb2a2 100644 --- a/problems/maximum-distance-in-arrays/README.md +++ b/problems/maximum-distance-in-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../add-one-row-to-tree "Add One Row to Tree") diff --git a/problems/maximum-earnings-from-taxi/README.md b/problems/maximum-earnings-from-taxi/README.md index 499f3b764..94e38354e 100644 --- a/problems/maximum-earnings-from-taxi/README.md +++ b/problems/maximum-earnings-from-taxi/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-original-array-from-doubled-array "Find Original Array From Doubled Array") diff --git a/problems/maximum-element-after-decreasing-and-rearranging/README.md b/problems/maximum-element-after-decreasing-and-rearranging/README.md index cb31b4cfe..2ec14e72a 100644 --- a/problems/maximum-element-after-decreasing-and-rearranging/README.md +++ b/problems/maximum-element-after-decreasing-and-rearranging/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../seat-reservation-manager "Seat Reservation Manager") diff --git a/problems/maximum-equal-frequency/README.md b/problems/maximum-equal-frequency/README.md index 9557464da..8657085d5 100644 --- a/problems/maximum-equal-frequency/README.md +++ b/problems/maximum-equal-frequency/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../dice-roll-simulation "Dice Roll Simulation") diff --git a/problems/maximum-erasure-value/README.md b/problems/maximum-erasure-value/README.md index 949d2a397..212f859cf 100644 --- a/problems/maximum-erasure-value/README.md +++ b/problems/maximum-erasure-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reformat-phone-number "Reformat Phone Number") diff --git a/problems/maximum-font-to-fit-a-sentence-in-a-screen/README.md b/problems/maximum-font-to-fit-a-sentence-in-a-screen/README.md index e7e5e1380..fdb3b26d9 100644 --- a/problems/maximum-font-to-fit-a-sentence-in-a-screen/README.md +++ b/problems/maximum-font-to-fit-a-sentence-in-a-screen/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-subtrees-with-max-distance-between-cities "Count Subtrees With Max Distance Between Cities") diff --git a/problems/maximum-gap/README.md b/problems/maximum-gap/README.md index a099a38f9..d0c7d9316 100644 --- a/problems/maximum-gap/README.md +++ b/problems/maximum-gap/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../missing-ranges "Missing Ranges") diff --git a/problems/maximum-genetic-difference-query/README.md b/problems/maximum-genetic-difference-query/README.md index 856964ac8..dbd84060c 100644 --- a/problems/maximum-genetic-difference-query/README.md +++ b/problems/maximum-genetic-difference-query/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-points-with-cost "Maximum Number of Points with Cost") diff --git a/problems/maximum-height-by-stacking-cuboids/README.md b/problems/maximum-height-by-stacking-cuboids/README.md index ea1da246b..4c988381f 100644 --- a/problems/maximum-height-by-stacking-cuboids/README.md +++ b/problems/maximum-height-by-stacking-cuboids/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game-vii "Stone Game VII") @@ -67,9 +67,6 @@ The maximum height of stacked cuboids is 6 * 17 = 102. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [The Number of Weak Characters in the Game](../the-number-of-weak-characters-in-the-game) (Medium) - ### Hints
    Hint 1 diff --git a/problems/maximum-ice-cream-bars/README.md b/problems/maximum-ice-cream-bars/README.md index 548ec3514..5fbc91a10 100644 --- a/problems/maximum-ice-cream-bars/README.md +++ b/problems/maximum-ice-cream-bars/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-the-sentence-is-pangram "Check if the Sentence Is Pangram") diff --git a/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md b/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md index 72f94dbc1..7dd80565b 100644 --- a/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md +++ b/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../circular-permutation-in-binary-representation "Circular Permutation in Binary Representation") @@ -67,10 +67,10 @@ Maximum length is 4. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/maximum-length-of-pair-chain/README.md b/problems/maximum-length-of-pair-chain/README.md index c108321a1..a7e566c55 100644 --- a/problems/maximum-length-of-pair-chain/README.md +++ b/problems/maximum-length-of-pair-chain/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../set-mismatch "Set Mismatch") @@ -46,9 +46,9 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Similar Questions diff --git a/problems/maximum-length-of-subarray-with-positive-product/README.md b/problems/maximum-length-of-subarray-with-positive-product/README.md index 4ceae6c1b..09559fc46 100644 --- a/problems/maximum-length-of-subarray-with-positive-product/README.md +++ b/problems/maximum-length-of-subarray-with-positive-product/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../detect-pattern-of-length-m-repeated-k-or-more-times "Detect Pattern of Length M Repeated K or More Times") @@ -65,9 +65,9 @@ Notice that we cannot include 0 in the subarray since that'll make the produ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/maximum-matrix-sum/README.md b/problems/maximum-matrix-sum/README.md index e913149e1..8eb766ade 100644 --- a/problems/maximum-matrix-sum/README.md +++ b/problems/maximum-matrix-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-time-to-type-word-using-special-typewriter "Minimum Time to Type Word Using Special Typewriter") diff --git a/problems/maximum-nesting-depth-of-the-parentheses/README.md b/problems/maximum-nesting-depth-of-the-parentheses/README.md index cda784e44..b4df75520 100644 --- a/problems/maximum-nesting-depth-of-the-parentheses/README.md +++ b/problems/maximum-nesting-depth-of-the-parentheses/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-missing-ids "Find the Missing IDs") @@ -72,11 +72,8 @@ ### Related Topics - [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] - -### Similar Questions - 1. [Maximum Nesting Depth of Two Valid Parentheses Strings](../maximum-nesting-depth-of-two-valid-parentheses-strings) (Medium) + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/maximum-non-negative-product-in-a-matrix/README.md b/problems/maximum-non-negative-product-in-a-matrix/README.md index 29be70abf..0b1c73b57 100644 --- a/problems/maximum-non-negative-product-in-a-matrix/README.md +++ b/problems/maximum-non-negative-product-in-a-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../split-a-string-into-the-max-number-of-unique-substrings "Split a String Into the Max Number of Unique Substrings") diff --git a/problems/maximum-number-of-accepted-invitations/README.md b/problems/maximum-number-of-accepted-invitations/README.md index b46d29238..ef403fdb6 100644 --- a/problems/maximum-number-of-accepted-invitations/README.md +++ b/problems/maximum-number-of-accepted-invitations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-different-subsequences-gcds "Number of Different Subsequences GCDs") diff --git a/problems/maximum-number-of-achievable-transfer-requests/README.md b/problems/maximum-number-of-achievable-transfer-requests/README.md index 8e0396600..144c6a30e 100644 --- a/problems/maximum-number-of-achievable-transfer-requests/README.md +++ b/problems/maximum-number-of-achievable-transfer-requests/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../throne-inheritance "Throne Inheritance") diff --git a/problems/maximum-number-of-balloons/README.md b/problems/maximum-number-of-balloons/README.md index 12d3bbfe9..b871476da 100644 --- a/problems/maximum-number-of-balloons/README.md +++ b/problems/maximum-number-of-balloons/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-bounded-blocking-queue "Design Bounded Blocking Queue") diff --git a/problems/maximum-number-of-balls-in-a-box/README.md b/problems/maximum-number-of-balls-in-a-box/README.md index da67222e1..a31e84d04 100644 --- a/problems/maximum-number-of-balls-in-a-box/README.md +++ b/problems/maximum-number-of-balls-in-a-box/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-total-time-spent-by-each-employee "Find Total Time Spent by Each Employee") diff --git a/problems/maximum-number-of-coins-you-can-get/README.md b/problems/maximum-number-of-coins-you-can-get/README.md index 7b7eae3e9..61ecb3167 100644 --- a/problems/maximum-number-of-coins-you-can-get/README.md +++ b/problems/maximum-number-of-coins-you-can-get/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../most-visited-sector-in-a-circular-track "Most Visited Sector in a Circular Track") @@ -11,19 +11,19 @@ ## [1561. Maximum Number of Coins You Can Get (Medium)](https://leetcode.com/problems/maximum-number-of-coins-you-can-get "你可以获得的最大硬币数目") -

    There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows:

    +

    There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows:

      -
    • In each step, you will choose any 3 piles of coins (not necessarily consecutive).
    • -
    • Of your choice, Alice will pick the pile with the maximum number of coins.
    • -
    • You will pick the next pile with maximum number of coins.
    • +
    • In each step, you will choose any 3 piles of coins (not necessarily consecutive).
    • +
    • Of your choice, Alice will pick the pile with the maximum number of coins.
    • +
    • You will pick the next pile with the maximum number of coins.
    • Your friend Bob will pick the last pile.
    • -
    • Repeat until there are no more piles of coins.
    • +
    • Repeat until there are no more piles of coins.
    -

    Given an array of integers piles where piles[i] is the number of coins in the ith pile.

    +

    Given an array of integers piles where piles[i] is the number of coins in the ith pile.

    -

    Return the maximum number of coins which you can have.

    +

    Return the maximum number of coins that you can have.

     

    Example 1:

    @@ -55,9 +55,9 @@ On the other hand if we choose this arrangement (1, 2, 8), (2,

    Constraints:

      -
    • 3 <= piles.length <= 10^5
    • +
    • 3 <= piles.length <= 105
    • piles.length % 3 == 0
    • -
    • 1 <= piles[i] <= 10^4
    • +
    • 1 <= piles[i] <= 104
    ### Related Topics diff --git a/problems/maximum-number-of-consecutive-values-you-can-make/README.md b/problems/maximum-number-of-consecutive-values-you-can-make/README.md index 684b0035e..7fdf0d08f 100644 --- a/problems/maximum-number-of-consecutive-values-you-can-make/README.md +++ b/problems/maximum-number-of-consecutive-values-you-can-make/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-authentication-manager "Design Authentication Manager") diff --git a/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md b/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md index a757781c4..03a0c1879 100644 --- a/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md +++ b/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list "People Whose List of Favorite Companies Is Not a Subset of Another List") @@ -61,9 +61,9 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-eaten-apples/README.md b/problems/maximum-number-of-eaten-apples/README.md index 31499bb00..2e29bdaa3 100644 --- a/problems/maximum-number-of-eaten-apples/README.md +++ b/problems/maximum-number-of-eaten-apples/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../determine-if-string-halves-are-alike "Determine if String Halves Are Alike") diff --git a/problems/maximum-number-of-events-that-can-be-attended-ii/README.md b/problems/maximum-number-of-events-that-can-be-attended-ii/README.md index e0d998f2a..dc8c37595 100644 --- a/problems/maximum-number-of-events-that-can-be-attended-ii/README.md +++ b/problems/maximum-number-of-events-that-can-be-attended-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-length-of-string-after-deleting-similar-ends "Minimum Length of String After Deleting Similar Ends") @@ -61,11 +61,6 @@ Notice that you cannot attend any other event as they overlap, and that you do < [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] -### Similar Questions - 1. [Maximum Number of Events That Can Be Attended](../maximum-number-of-events-that-can-be-attended) (Medium) - 1. [Maximum Earnings From Taxi](../maximum-earnings-from-taxi) (Medium) - 1. [Two Best Non-Overlapping Events](../two-best-non-overlapping-events) (Medium) - ### Hints
    Hint 1 diff --git a/problems/maximum-number-of-events-that-can-be-attended/README.md b/problems/maximum-number-of-events-that-can-be-attended/README.md index c456f8a46..4559f8e33 100644 --- a/problems/maximum-number-of-events-that-can-be-attended/README.md +++ b/problems/maximum-number-of-events-that-can-be-attended/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../product-of-the-last-k-numbers "Product of the Last K Numbers") diff --git a/problems/maximum-number-of-groups-getting-fresh-donuts/README.md b/problems/maximum-number-of-groups-getting-fresh-donuts/README.md index e4ab76574..415e129b0 100644 --- a/problems/maximum-number-of-groups-getting-fresh-donuts/README.md +++ b/problems/maximum-number-of-groups-getting-fresh-donuts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-nice-pairs-in-an-array "Count Nice Pairs in an Array") diff --git a/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md b/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md index a13a23574..6f963ba4b 100644 --- a/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md +++ b/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-kth-bit-in-nth-binary-string "Find Kth Bit in Nth Binary String") diff --git a/problems/maximum-number-of-non-overlapping-substrings/README.md b/problems/maximum-number-of-non-overlapping-substrings/README.md index 93e3be684..4c57eba84 100644 --- a/problems/maximum-number-of-non-overlapping-substrings/README.md +++ b/problems/maximum-number-of-non-overlapping-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-nodes-in-the-sub-tree-with-the-same-label "Number of Nodes in the Sub-Tree With the Same Label") diff --git a/problems/maximum-number-of-occurrences-of-a-substring/README.md b/problems/maximum-number-of-occurrences-of-a-substring/README.md index 39e7f1bd0..3634859c2 100644 --- a/problems/maximum-number-of-occurrences-of-a-substring/README.md +++ b/problems/maximum-number-of-occurrences-of-a-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../divide-array-in-sets-of-k-consecutive-numbers "Divide Array in Sets of K Consecutive Numbers") diff --git a/problems/maximum-number-of-ones/README.md b/problems/maximum-number-of-ones/README.md index c6542fe02..dca5bed9c 100644 --- a/problems/maximum-number-of-ones/README.md +++ b/problems/maximum-number-of-ones/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-distance-to-target-color "Shortest Distance to Target Color") diff --git a/problems/maximum-number-of-people-that-can-be-caught-in-tag/README.md b/problems/maximum-number-of-people-that-can-be-caught-in-tag/README.md index cec72556d..bdce1b715 100644 --- a/problems/maximum-number-of-people-that-can-be-caught-in-tag/README.md +++ b/problems/maximum-number-of-people-that-can-be-caught-in-tag/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-cutoff-score-for-each-school "Find Cutoff Score for Each School") diff --git a/problems/maximum-number-of-points-with-cost/README.md b/problems/maximum-number-of-points-with-cost/README.md index 1893a4388..971d5b4e4 100644 --- a/problems/maximum-number-of-points-with-cost/README.md +++ b/problems/maximum-number-of-points-with-cost/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../add-minimum-number-of-rungs "Add Minimum Number of Rungs") diff --git a/problems/maximum-number-of-removable-characters/README.md b/problems/maximum-number-of-removable-characters/README.md index f8996cff2..6dc55f65c 100644 --- a/problems/maximum-number-of-removable-characters/README.md +++ b/problems/maximum-number-of-removable-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../redistribute-characters-to-make-all-strings-equal "Redistribute Characters to Make All Strings Equal") diff --git a/problems/maximum-number-of-tasks-you-can-assign/README.md b/problems/maximum-number-of-tasks-you-can-assign/README.md index c3ba54efe..a917e8956 100644 --- a/problems/maximum-number-of-tasks-you-can-assign/README.md +++ b/problems/maximum-number-of-tasks-you-can-assign/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../most-beautiful-item-for-each-query "Most Beautiful Item for Each Query") diff --git a/problems/maximum-number-of-visible-points/README.md b/problems/maximum-number-of-visible-points/README.md index fdf1f0654..1dcf62a62 100644 --- a/problems/maximum-number-of-visible-points/README.md +++ b/problems/maximum-number-of-visible-points/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../even-odd-tree "Even Odd Tree") diff --git a/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md b/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md index ff2dbd569..8bc9d9ffb 100644 --- a/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md +++ b/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence "Check If a Word Occurs As a Prefix of Any Word in a Sentence") diff --git a/problems/maximum-number-of-ways-to-partition-an-array/README.md b/problems/maximum-number-of-ways-to-partition-an-array/README.md index bee8e4c95..9ab28a83d 100644 --- a/problems/maximum-number-of-ways-to-partition-an-array/README.md +++ b/problems/maximum-number-of-ways-to-partition-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximize-the-confusion-of-an-exam "Maximize the Confusion of an Exam") diff --git a/problems/maximum-number-of-weeks-for-which-you-can-work/README.md b/problems/maximum-number-of-weeks-for-which-you-can-work/README.md index 3cdeb2d18..60f444ba4 100644 --- a/problems/maximum-number-of-weeks-for-which-you-can-work/README.md +++ b/problems/maximum-number-of-weeks-for-which-you-can-work/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../three-divisors "Three Divisors") diff --git a/problems/maximum-number-of-words-you-can-type/README.md b/problems/maximum-number-of-words-you-can-type/README.md index d7f882682..2426e2dd3 100644 --- a/problems/maximum-number-of-words-you-can-type/README.md +++ b/problems/maximum-number-of-words-you-can-type/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../confirmation-rate "Confirmation Rate") diff --git a/problems/maximum-of-absolute-value-expression/README.md b/problems/maximum-of-absolute-value-expression/README.md index b89071148..1ab54a71d 100644 --- a/problems/maximum-of-absolute-value-expression/README.md +++ b/problems/maximum-of-absolute-value-expression/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-tree-from-leaf-values "Minimum Cost Tree From Leaf Values") diff --git a/problems/maximum-of-minimum-values-in-all-subarrays/README.md b/problems/maximum-of-minimum-values-in-all-subarrays/README.md index 7df537e3f..2bad1050a 100644 --- a/problems/maximum-of-minimum-values-in-all-subarrays/README.md +++ b/problems/maximum-of-minimum-values-in-all-subarrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../strong-friendship "Strong Friendship") diff --git a/problems/maximum-path-quality-of-a-graph/README.md b/problems/maximum-path-quality-of-a-graph/README.md index 051e550b3..de1176b46 100644 --- a/problems/maximum-path-quality-of-a-graph/README.md +++ b/problems/maximum-path-quality-of-a-graph/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimized-maximum-of-products-distributed-to-any-store "Minimized Maximum of Products Distributed to Any Store") diff --git a/problems/maximum-performance-of-a-team/README.md b/problems/maximum-performance-of-a-team/README.md index 44da51136..4bf572f41 100644 --- a/problems/maximum-performance-of-a-team/README.md +++ b/problems/maximum-performance-of-a-team/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../balance-a-binary-search-tree "Balance a Binary Search Tree") diff --git a/problems/maximum-points-you-can-obtain-from-cards/README.md b/problems/maximum-points-you-can-obtain-from-cards/README.md index 69ddfcb04..c5c74b84a 100644 --- a/problems/maximum-points-you-can-obtain-from-cards/README.md +++ b/problems/maximum-points-you-can-obtain-from-cards/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-score-after-splitting-a-string "Maximum Score After Splitting a String") diff --git a/problems/maximum-population-year/README.md b/problems/maximum-population-year/README.md index ebe6e3ffe..5c709dc10 100644 --- a/problems/maximum-population-year/README.md +++ b/problems/maximum-population-year/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-date-format "Convert Date Format") diff --git a/problems/maximum-product-difference-between-two-pairs/README.md b/problems/maximum-product-difference-between-two-pairs/README.md index 62728115c..c42a5e7f6 100644 --- a/problems/maximum-product-difference-between-two-pairs/README.md +++ b/problems/maximum-product-difference-between-two-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-movie-rental-system "Design Movie Rental System") diff --git a/problems/maximum-product-of-splitted-binary-tree/README.md b/problems/maximum-product-of-splitted-binary-tree/README.md index f9f32841c..0d7bea15e 100644 --- a/problems/maximum-product-of-splitted-binary-tree/README.md +++ b/problems/maximum-product-of-splitted-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reduce-array-size-to-the-half "Reduce Array Size to The Half") @@ -61,6 +61,9 @@ [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Count Nodes With the Highest Score](../count-nodes-with-the-highest-score) (Medium) + ### Hints
    Hint 1 diff --git a/problems/maximum-product-of-the-length-of-two-palindromic-subsequences/README.md b/problems/maximum-product-of-the-length-of-two-palindromic-subsequences/README.md index f174e640a..e882747e2 100644 --- a/problems/maximum-product-of-the-length-of-two-palindromic-subsequences/README.md +++ b/problems/maximum-product-of-the-length-of-two-palindromic-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-pairs-of-interchangeable-rectangles "Number of Pairs of Interchangeable Rectangles") diff --git a/problems/maximum-product-of-the-length-of-two-palindromic-substrings/README.md b/problems/maximum-product-of-the-length-of-two-palindromic-substrings/README.md index ede109cb0..9cdca3f6e 100644 --- a/problems/maximum-product-of-the-length-of-two-palindromic-substrings/README.md +++ b/problems/maximum-product-of-the-length-of-two-palindromic-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-total-space-wasted-with-k-resizing-operations "Minimum Total Space Wasted With K Resizing Operations") diff --git a/problems/maximum-product-of-two-elements-in-an-array/README.md b/problems/maximum-product-of-two-elements-in-an-array/README.md index e13c8b8ea..6780a411d 100644 --- a/problems/maximum-product-of-two-elements-in-an-array/README.md +++ b/problems/maximum-product-of-two-elements-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cherry-pickup-ii "Cherry Pickup II") diff --git a/problems/maximum-profit-in-job-scheduling/README.md b/problems/maximum-profit-in-job-scheduling/README.md index 3c4b4a932..8cb51b614 100644 --- a/problems/maximum-profit-in-job-scheduling/README.md +++ b/problems/maximum-profit-in-job-scheduling/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../replace-the-substring-for-balanced-string "Replace the Substring for Balanced String") diff --git a/problems/maximum-profit-of-operating-a-centennial-wheel/README.md b/problems/maximum-profit-of-operating-a-centennial-wheel/README.md index 29ba62fb4..f638ef1e3 100644 --- a/problems/maximum-profit-of-operating-a-centennial-wheel/README.md +++ b/problems/maximum-profit-of-operating-a-centennial-wheel/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../crawler-log-folder "Crawler Log Folder") diff --git a/problems/maximum-repeating-substring/README.md b/problems/maximum-repeating-substring/README.md index 4a6ecdf62..96fe3070b 100644 --- a/problems/maximum-repeating-substring/README.md +++ b/problems/maximum-repeating-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fix-names-in-a-table "Fix Names in a Table") @@ -53,6 +53,9 @@ [[String](../../tag/string/README.md)] [[String Matching](../../tag/string-matching/README.md)] +### Similar Questions + 1. [Detect Pattern of Length M Repeated K or More Times](../detect-pattern-of-length-m-repeated-k-or-more-times) (Easy) + ### Hints
    Hint 1 diff --git a/problems/maximum-score-after-splitting-a-string/README.md b/problems/maximum-score-after-splitting-a-string/README.md index b6f1d3acb..589727c3a 100644 --- a/problems/maximum-score-after-splitting-a-string/README.md +++ b/problems/maximum-score-after-splitting-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../npv-queries "NPV Queries") diff --git a/problems/maximum-score-from-performing-multiplication-operations/README.md b/problems/maximum-score-from-performing-multiplication-operations/README.md index 8537c3b8b..bc78098df 100644 --- a/problems/maximum-score-from-performing-multiplication-operations/README.md +++ b/problems/maximum-score-from-performing-multiplication-operations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-operations-to-move-all-balls-to-each-box "Minimum Number of Operations to Move All Balls to Each Box") @@ -64,10 +64,6 @@ The total score is 50 + 15 - 9 + 4 + 42 = 102. [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] -### Similar Questions - 1. [Maximum Points You Can Obtain from Cards](../maximum-points-you-can-obtain-from-cards) (Medium) - 1. [Stone Game VII](../stone-game-vii) (Medium) - ### Hints
    Hint 1 diff --git a/problems/maximum-score-from-removing-stones/README.md b/problems/maximum-score-from-removing-stones/README.md index 96ed16df6..01389e015 100644 --- a/problems/maximum-score-from-removing-stones/README.md +++ b/problems/maximum-score-from-removing-stones/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-array-is-sorted-and-rotated "Check if Array Is Sorted and Rotated") @@ -64,8 +64,8 @@ After that, there are fewer than two non-empty piles, so the game ends. ### Related Topics - [[Math](../../tag/math/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/maximum-score-from-removing-substrings/README.md b/problems/maximum-score-from-removing-substrings/README.md index 88b5b05a6..17c71631f 100644 --- a/problems/maximum-score-from-removing-substrings/README.md +++ b/problems/maximum-score-from-removing-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../calculate-money-in-leetcode-bank "Calculate Money in Leetcode Bank") @@ -58,9 +58,9 @@ Total score = 5 + 4 + 5 + 5 = 19. ### Related Topics - [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/maximum-score-of-a-good-subarray/README.md b/problems/maximum-score-of-a-good-subarray/README.md index 0d95a2e7d..edeb34460 100644 --- a/problems/maximum-score-of-a-good-subarray/README.md +++ b/problems/maximum-score-of-a-good-subarray/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-average-pass-ratio "Maximum Average Pass Ratio") @@ -44,15 +44,12 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Stack](../../tag/stack/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] -### Similar Questions - 1. [Largest Rectangle in Histogram](../largest-rectangle-in-histogram) (Hard) - ### Hints
    Hint 1 diff --git a/problems/maximum-score-words-formed-by-letters/README.md b/problems/maximum-score-words-formed-by-letters/README.md index 4423384c4..97452e4ff 100644 --- a/problems/maximum-score-words-formed-by-letters/README.md +++ b/problems/maximum-score-words-formed-by-letters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-closed-islands "Number of Closed Islands") @@ -60,11 +60,11 @@ Letter "e" can only be used once. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] ### Hints diff --git a/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md b/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md index 9b67293a2..96e80a8cc 100644 --- a/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md +++ b/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sequential-digits "Sequential Digits") diff --git a/problems/maximum-students-taking-exam/README.md b/problems/maximum-students-taking-exam/README.md index c47343171..3e752af5f 100644 --- a/problems/maximum-students-taking-exam/README.md +++ b/problems/maximum-students-taking-exam/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tweet-counts-per-frequency "Tweet Counts Per Frequency") diff --git a/problems/maximum-subarray-min-product/README.md b/problems/maximum-subarray-min-product/README.md index 16ec5c983..79aac2c47 100644 --- a/problems/maximum-subarray-min-product/README.md +++ b/problems/maximum-subarray-min-product/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-distance-between-a-pair-of-values "Maximum Distance Between a Pair of Values") diff --git a/problems/maximum-subarray-sum-after-one-operation/README.md b/problems/maximum-subarray-sum-after-one-operation/README.md index 391cf4e8a..152758454 100644 --- a/problems/maximum-subarray-sum-after-one-operation/README.md +++ b/problems/maximum-subarray-sum-after-one-operation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../palindrome-partitioning-iv "Palindrome Partitioning IV") @@ -17,9 +17,6 @@ [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] -### Similar Questions - 1. [Maximum Subarray](../maximum-subarray) (Easy) - ### Hints
    Hint 1 diff --git a/problems/maximum-subarray-sum-with-one-deletion/README.md b/problems/maximum-subarray-sum-with-one-deletion/README.md index 3c9286232..3e76e709f 100644 --- a/problems/maximum-subarray-sum-with-one-deletion/README.md +++ b/problems/maximum-subarray-sum-with-one-deletion/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../day-of-the-week "Day of the Week") diff --git a/problems/maximum-sum-circular-subarray/README.md b/problems/maximum-sum-circular-subarray/README.md index d0207e9ad..278c2fad3 100644 --- a/problems/maximum-sum-circular-subarray/README.md +++ b/problems/maximum-sum-circular-subarray/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-only-letters "Reverse Only Letters") diff --git a/problems/maximum-sum-obtained-of-any-permutation/README.md b/problems/maximum-sum-obtained-of-any-permutation/README.md index a6863f609..a1d9a7bbb 100644 --- a/problems/maximum-sum-obtained-of-any-permutation/README.md +++ b/problems/maximum-sum-obtained-of-any-permutation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-all-odd-length-subarrays "Sum of All Odd Length Subarrays") @@ -60,10 +60,10 @@ Total sum: 11 + 8 = 19, which is the best that you can do. ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[Sorting](../../tag/sorting/README.md)] + [[Array](../../tag/array/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/maximum-transaction-each-day/README.md b/problems/maximum-transaction-each-day/README.md index 1931be985..977486d49 100644 --- a/problems/maximum-transaction-each-day/README.md +++ b/problems/maximum-transaction-each-day/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-operations-to-make-string-sorted "Minimum Number of Operations to Make String Sorted") diff --git a/problems/maximum-units-on-a-truck/README.md b/problems/maximum-units-on-a-truck/README.md index ab1d4df4a..3ead65713 100644 --- a/problems/maximum-units-on-a-truck/README.md +++ b/problems/maximum-units-on-a-truck/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../biggest-window-between-visits "Biggest Window Between Visits") diff --git a/problems/maximum-vacation-days/README.md b/problems/maximum-vacation-days/README.md index 3f8266116..6d4ea8813 100644 --- a/problems/maximum-vacation-days/README.md +++ b/problems/maximum-vacation-days/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../permutation-in-string "Permutation in String") diff --git a/problems/maximum-value-after-insertion/README.md b/problems/maximum-value-after-insertion/README.md index c643ca1ad..9d453f146 100644 --- a/problems/maximum-value-after-insertion/README.md +++ b/problems/maximum-value-after-insertion/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-word-equals-summation-of-two-words "Check if Word Equals Summation of Two Words") diff --git a/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md b/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md index a3840e9fe..b41ba72a4 100644 --- a/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md +++ b/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-orders-in-the-backlog "Number of Orders in the Backlog") diff --git a/problems/maximum-xor-for-each-query/README.md b/problems/maximum-xor-for-each-query/README.md index c2d67f4c1..77772fb9e 100644 --- a/problems/maximum-xor-for-each-query/README.md +++ b/problems/maximum-xor-for-each-query/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../queries-on-number-of-points-inside-a-circle "Queries on Number of Points Inside a Circle") @@ -64,8 +64,8 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints diff --git a/problems/maximum-xor-with-an-element-from-array/README.md b/problems/maximum-xor-with-an-element-from-array/README.md index eb4acccfb..daa3f0add 100644 --- a/problems/maximum-xor-with-an-element-from-array/README.md +++ b/problems/maximum-xor-with-an-element-from-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../where-will-the-ball-fall "Where Will the Ball Fall") diff --git a/problems/mean-of-array-after-removing-some-elements/README.md b/problems/mean-of-array-after-removing-some-elements/README.md index f87020608..82a728f5a 100644 --- a/problems/mean-of-array-after-removing-some-elements/README.md +++ b/problems/mean-of-array-after-removing-some-elements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-font-to-fit-a-sentence-in-a-screen "Maximum Font to Fit a Sentence in a Screen") diff --git a/problems/median-employee-salary/README.md b/problems/median-employee-salary/README.md index 1afeed80d..90ee0f2bb 100644 --- a/problems/median-employee-salary/README.md +++ b/problems/median-employee-salary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-vacation-days "Maximum Vacation Days") diff --git a/problems/median-employee-salary/mysql_schemas.sql b/problems/median-employee-salary/mysql_schemas.sql index dd828e723..5dd574292 100644 --- a/problems/median-employee-salary/mysql_schemas.sql +++ b/problems/median-employee-salary/mysql_schemas.sql @@ -1,19 +1,19 @@ -Create table If Not Exists Employee (Id int, Company varchar(255), Salary int); +Create table If Not Exists Employee (id int, company varchar(255), salary int); Truncate table Employee; -insert into Employee (Id, Company, Salary) values ('1', 'A', '2341'); -insert into Employee (Id, Company, Salary) values ('2', 'A', '341'); -insert into Employee (Id, Company, Salary) values ('3', 'A', '15'); -insert into Employee (Id, Company, Salary) values ('4', 'A', '15314'); -insert into Employee (Id, Company, Salary) values ('5', 'A', '451'); -insert into Employee (Id, Company, Salary) values ('6', 'A', '513'); -insert into Employee (Id, Company, Salary) values ('7', 'B', '15'); -insert into Employee (Id, Company, Salary) values ('8', 'B', '13'); -insert into Employee (Id, Company, Salary) values ('9', 'B', '1154'); -insert into Employee (Id, Company, Salary) values ('10', 'B', '1345'); -insert into Employee (Id, Company, Salary) values ('11', 'B', '1221'); -insert into Employee (Id, Company, Salary) values ('12', 'B', '234'); -insert into Employee (Id, Company, Salary) values ('13', 'C', '2345'); -insert into Employee (Id, Company, Salary) values ('14', 'C', '2645'); -insert into Employee (Id, Company, Salary) values ('15', 'C', '2645'); -insert into Employee (Id, Company, Salary) values ('16', 'C', '2652'); -insert into Employee (Id, Company, Salary) values ('17', 'C', '65'); +insert into Employee (id, company, salary) values ('1', 'A', '2341'); +insert into Employee (id, company, salary) values ('2', 'A', '341'); +insert into Employee (id, company, salary) values ('3', 'A', '15'); +insert into Employee (id, company, salary) values ('4', 'A', '15314'); +insert into Employee (id, company, salary) values ('5', 'A', '451'); +insert into Employee (id, company, salary) values ('6', 'A', '513'); +insert into Employee (id, company, salary) values ('7', 'B', '15'); +insert into Employee (id, company, salary) values ('8', 'B', '13'); +insert into Employee (id, company, salary) values ('9', 'B', '1154'); +insert into Employee (id, company, salary) values ('10', 'B', '1345'); +insert into Employee (id, company, salary) values ('11', 'B', '1221'); +insert into Employee (id, company, salary) values ('12', 'B', '234'); +insert into Employee (id, company, salary) values ('13', 'C', '2345'); +insert into Employee (id, company, salary) values ('14', 'C', '2645'); +insert into Employee (id, company, salary) values ('15', 'C', '2645'); +insert into Employee (id, company, salary) values ('16', 'C', '2652'); +insert into Employee (id, company, salary) values ('17', 'C', '65'); diff --git a/problems/merge-bsts-to-create-single-bst/README.md b/problems/merge-bsts-to-create-single-bst/README.md index 632bf3435..63d8f9678 100644 --- a/problems/merge-bsts-to-create-single-bst/README.md +++ b/problems/merge-bsts-to-create-single-bst/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../painting-a-grid-with-three-different-colors "Painting a Grid With Three Different Colors") diff --git a/problems/merge-in-between-linked-lists/README.md b/problems/merge-in-between-linked-lists/README.md index 35e8f41ff..246908775 100644 --- a/problems/merge-in-between-linked-lists/README.md +++ b/problems/merge-in-between-linked-lists/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-repeating-substring "Maximum Repeating Substring") diff --git a/problems/merge-intervals/README.md b/problems/merge-intervals/README.md index 38bf97a47..d474da066 100644 --- a/problems/merge-intervals/README.md +++ b/problems/merge-intervals/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../jump-game "Jump Game") diff --git a/problems/merge-strings-alternately/README.md b/problems/merge-strings-alternately/README.md index db11585b5..fa3b9c32b 100644 --- a/problems/merge-strings-alternately/README.md +++ b/problems/merge-strings-alternately/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-subtasks-that-did-not-execute "Find the Subtasks That Did Not Execute") @@ -61,9 +61,6 @@ merged: a p b q c d [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] -### Similar Questions - 1. [Zigzag Iterator](../zigzag-iterator) (Medium) - ### Hints
    Hint 1 diff --git a/problems/merge-triplets-to-form-target-triplet/README.md b/problems/merge-triplets-to-form-target-triplet/README.md index 510475f65..a2105787a 100644 --- a/problems/merge-triplets-to-form-target-triplet/README.md +++ b/problems/merge-triplets-to-form-target-triplet/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-removable-characters "Maximum Number of Removable Characters") diff --git a/problems/merge-two-binary-trees/README.md b/problems/merge-two-binary-trees/README.md index 3419dd720..330e3191b 100644 --- a/problems/merge-two-binary-trees/README.md +++ b/problems/merge-two-binary-trees/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../add-bold-tag-in-string "Add Bold Tag in String") diff --git a/problems/merge-two-sorted-lists/README.md b/problems/merge-two-sorted-lists/README.md index e8bcebf0f..893f84595 100644 --- a/problems/merge-two-sorted-lists/README.md +++ b/problems/merge-two-sorted-lists/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-parentheses "Valid Parentheses") @@ -11,27 +11,31 @@ ## [21. Merge Two Sorted Lists (Easy)](https://leetcode.com/problems/merge-two-sorted-lists "合并两个有序链表") -

    Merge two sorted linked lists and return it as a sorted list. The list should be made by splicing together the nodes of the first two lists.

    +

    You are given the heads of two sorted linked lists list1 and list2.

    + +

    Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists.

    + +

    Return the head of the merged linked list.

     

    Example 1:

    -Input: l1 = [1,2,4], l2 = [1,3,4]
    +Input: list1 = [1,2,4], list2 = [1,3,4]
     Output: [1,1,2,3,4,4]
     

    Example 2:

    -Input: l1 = [], l2 = []
    +Input: list1 = [], list2 = []
     Output: []
     

    Example 3:

    -Input: l1 = [], l2 = [0]
    +Input: list1 = [], list2 = [0]
     Output: [0]
     
    @@ -41,7 +45,7 @@
    • The number of nodes in both lists is in the range [0, 50].
    • -100 <= Node.val <= 100
    • -
    • Both l1 and l2 are sorted in non-decreasing order.
    • +
    • Both list1 and list2 are sorted in non-decreasing order.
    ### Related Topics diff --git a/problems/min-cost-climbing-stairs/README.md b/problems/min-cost-climbing-stairs/README.md index ebc266e4d..9e47493b8 100644 --- a/problems/min-cost-climbing-stairs/README.md +++ b/problems/min-cost-climbing-stairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../prefix-and-suffix-search "Prefix and Suffix Search") @@ -21,17 +21,26 @@

    Example 1:

    -Input: cost = [10,15,20]
    +Input: cost = [10,15,20]
     Output: 15
    -Explanation: Cheapest is: start on cost[1], pay that cost, and go to the top.
    +Explanation: You will start at index 1.
    +- Pay 15 and climb two steps to reach the top.
    +The total cost is 15.
     

    Example 2:

    -Input: cost = [1,100,1,1,1,100,1,1,100,1]
    +Input: cost = [1,100,1,1,1,100,1,1,100,1]
     Output: 6
    -Explanation: Cheapest is: start on cost[0], and only step on 1s, skipping cost[3].
    +Explanation: You will start at index 0.
    +- Pay 1 and climb two steps to reach index 2.
    +- Pay 1 and climb two steps to reach index 4.
    +- Pay 1 and climb two steps to reach index 6.
    +- Pay 1 and climb one step to reach index 7.
    +- Pay 1 and climb two steps to reach index 9.
    +- Pay 1 and climb one step to reach the top.
    +The total cost is 6.
     

     

    diff --git a/problems/min-cost-to-connect-all-points/README.md b/problems/min-cost-to-connect-all-points/README.md index 02ad17018..6ad6e59f7 100644 --- a/problems/min-cost-to-connect-all-points/README.md +++ b/problems/min-cost-to-connect-all-points/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-unhappy-friends "Count Unhappy Friends") @@ -69,8 +69,8 @@ Notice that there is a unique path between every pair of points. ### Related Topics - [[Array](../../tag/array/README.md)] [[Union Find](../../tag/union-find/README.md)] + [[Array](../../tag/array/README.md)] [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] ### Hints diff --git a/problems/min-stack/README.md b/problems/min-stack/README.md index 61955b7d8..13567cb2e 100644 --- a/problems/min-stack/README.md +++ b/problems/min-stack/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-minimum-in-rotated-sorted-array-ii "Find Minimum in Rotated Sorted Array II") @@ -17,7 +17,7 @@
    • MinStack() initializes the stack object.
    • -
    • void push(val) pushes the element val onto the stack.
    • +
    • void push(int val) pushes the element val onto the stack.
    • void pop() removes the element on the top of the stack.
    • int top() gets the top element of the stack.
    • int getMin() retrieves the minimum element in the stack.
    • diff --git a/problems/minesweeper/README.md b/problems/minesweeper/README.md index 9b7ee8f6a..618c0715f 100644 --- a/problems/minesweeper/README.md +++ b/problems/minesweeper/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../random-pick-with-weight "Random Pick with Weight") diff --git a/problems/minimize-deviation-in-array/README.md b/problems/minimize-deviation-in-array/README.md index 59de5ccf4..67f25aefa 100644 --- a/problems/minimize-deviation-in-array/README.md +++ b/problems/minimize-deviation-in-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-moves-to-make-array-complementary "Minimum Moves to Make Array Complementary") @@ -66,10 +66,10 @@
    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Hints
    diff --git a/problems/minimize-hamming-distance-after-swap-operations/README.md b/problems/minimize-hamming-distance-after-swap-operations/README.md index 2e92aaeec..56ca147c2 100644 --- a/problems/minimize-hamming-distance-after-swap-operations/README.md +++ b/problems/minimize-hamming-distance-after-swap-operations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../swapping-nodes-in-a-linked-list "Swapping Nodes in a Linked List") diff --git a/problems/minimize-malware-spread/README.md b/problems/minimize-malware-spread/README.md index d2c1090d5..0adf6f7bc 100644 --- a/problems/minimize-malware-spread/README.md +++ b/problems/minimize-malware-spread/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../3sum-with-multiplicity "3Sum With Multiplicity") @@ -48,8 +48,8 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/minimize-maximum-pair-sum-in-array/README.md b/problems/minimize-maximum-pair-sum-in-array/README.md index 8722e266c..dc7eeaccd 100644 --- a/problems/minimize-maximum-pair-sum-in-array/README.md +++ b/problems/minimize-maximum-pair-sum-in-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../substrings-of-size-three-with-distinct-characters "Substrings of Size Three with Distinct Characters") diff --git a/problems/minimize-product-sum-of-two-arrays/README.md b/problems/minimize-product-sum-of-two-arrays/README.md index 1cd2fb9c5..deb391bad 100644 --- a/problems/minimize-product-sum-of-two-arrays/README.md +++ b/problems/minimize-product-sum-of-two-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../calculate-special-bonus "Calculate Special Bonus") diff --git a/problems/minimize-the-difference-between-target-and-chosen-elements/README.md b/problems/minimize-the-difference-between-target-and-chosen-elements/README.md index 8729a0137..37fe28b71 100644 --- a/problems/minimize-the-difference-between-target-and-chosen-elements/README.md +++ b/problems/minimize-the-difference-between-target-and-chosen-elements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-unique-binary-string "Find Unique Binary String") diff --git a/problems/minimized-maximum-of-products-distributed-to-any-store/README.md b/problems/minimized-maximum-of-products-distributed-to-any-store/README.md index 0a00c12a9..3f1dcfa07 100644 --- a/problems/minimized-maximum-of-products-distributed-to-any-store/README.md +++ b/problems/minimized-maximum-of-products-distributed-to-any-store/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../vowels-of-all-substrings "Vowels of All Substrings") diff --git a/problems/minimum-absolute-difference-in-bst/README.md b/problems/minimum-absolute-difference-in-bst/README.md index ea4f41eb3..65dc1df78 100644 --- a/problems/minimum-absolute-difference-in-bst/README.md +++ b/problems/minimum-absolute-difference-in-bst/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minesweeper "Minesweeper") diff --git a/problems/minimum-absolute-difference-queries/README.md b/problems/minimum-absolute-difference-queries/README.md index e7ef7ed6a..a87e08fff 100644 --- a/problems/minimum-absolute-difference-queries/README.md +++ b/problems/minimum-absolute-difference-queries/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-sub-islands "Count Sub Islands") diff --git a/problems/minimum-absolute-sum-difference/README.md b/problems/minimum-absolute-sum-difference/README.md index de66d4865..9fc9ca593 100644 --- a/problems/minimum-absolute-sum-difference/README.md +++ b/problems/minimum-absolute-sum-difference/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../finding-the-users-active-minutes "Finding the Users Active Minutes") diff --git a/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md b/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md index cbbe3cb7c..94852b978 100644 --- a/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md +++ b/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-binary-string-after-change "Maximum Binary String After Change") @@ -50,14 +50,10 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] + [[Array](../../tag/array/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] - -### Similar Questions - 1. [Minimum Swaps to Group All 1's Together](../minimum-swaps-to-group-all-1s-together) (Medium) - 1. [Minimum Number of Operations to Make Array Continuous](../minimum-number-of-operations-to-make-array-continuous) (Hard) + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/README.md b/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/README.md index 5866154fc..59c7fc47c 100644 --- a/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/README.md +++ b/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../splitting-a-string-into-descending-consecutive-values "Splitting a String Into Descending Consecutive Values") diff --git a/problems/minimum-area-rectangle-ii/README.md b/problems/minimum-area-rectangle-ii/README.md index 3a6830dd7..c8fc5d698 100644 --- a/problems/minimum-area-rectangle-ii/README.md +++ b/problems/minimum-area-rectangle-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-width-ramp "Maximum Width Ramp") @@ -61,6 +61,6 @@ ### Related Topics + [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Geometry](../../tag/geometry/README.md)] diff --git a/problems/minimum-area-rectangle/README.md b/problems/minimum-area-rectangle/README.md index 9776dd77d..45969bc7e 100644 --- a/problems/minimum-area-rectangle/README.md +++ b/problems/minimum-area-rectangle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../range-sum-of-bst "Range Sum of BST") diff --git a/problems/minimum-changes-to-make-alternating-binary-string/README.md b/problems/minimum-changes-to-make-alternating-binary-string/README.md index af16901e6..88450664e 100644 --- a/problems/minimum-changes-to-make-alternating-binary-string/README.md +++ b/problems/minimum-changes-to-make-alternating-binary-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../recyclable-and-low-fat-products "Recyclable and Low Fat Products") diff --git a/problems/minimum-cost-for-tickets/README.md b/problems/minimum-cost-for-tickets/README.md index 6e7b201c6..3cf8ec9f0 100644 --- a/problems/minimum-cost-for-tickets/README.md +++ b/problems/minimum-cost-for-tickets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../triples-with-bitwise-and-equal-to-zero "Triples with Bitwise AND Equal To Zero") diff --git a/problems/minimum-cost-to-change-the-final-value-of-expression/README.md b/problems/minimum-cost-to-change-the-final-value-of-expression/README.md index 6cc6f3d6c..382e822b6 100644 --- a/problems/minimum-cost-to-change-the-final-value-of-expression/README.md +++ b/problems/minimum-cost-to-change-the-final-value-of-expression/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-magic-square "Largest Magic Square") diff --git a/problems/minimum-cost-to-connect-sticks/README.md b/problems/minimum-cost-to-connect-sticks/README.md index dc0733fe6..f2782da11 100644 --- a/problems/minimum-cost-to-connect-sticks/README.md +++ b/problems/minimum-cost-to-connect-sticks/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-file-system "Design File System") @@ -34,8 +34,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions diff --git a/problems/minimum-cost-to-connect-two-groups-of-points/README.md b/problems/minimum-cost-to-connect-two-groups-of-points/README.md index 7d2218d62..fa8b8b06d 100644 --- a/problems/minimum-cost-to-connect-two-groups-of-points/README.md +++ b/problems/minimum-cost-to-connect-two-groups-of-points/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-non-negative-product-in-a-matrix "Maximum Non Negative Product in a Matrix") @@ -62,11 +62,11 @@ Note that there are multiple points connected to point 2 in the first group and ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] - [[Matrix](../../tag/matrix/README.md)] [[Bitmask](../../tag/bitmask/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/minimum-cost-to-cut-a-stick/README.md b/problems/minimum-cost-to-cut-a-stick/README.md index 2c0ac95df..bd27a000b 100644 --- a/problems/minimum-cost-to-cut-a-stick/README.md +++ b/problems/minimum-cost-to-cut-a-stick/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "Maximum Number of Non-Overlapping Subarrays With Sum Equals Target") @@ -13,13 +13,13 @@

    Given a wooden stick of length n units. The stick is labelled from 0 to n. For example, a stick of length 6 is labelled as follows:

    -

    Given an integer array cuts where cuts[i] denotes a position you should perform a cut at.

    +

    Given an integer array cuts where cuts[i] denotes a position you should perform a cut at.

    You should perform the cuts in order, you can change the order of the cuts as you wish.

    The cost of one cut is the length of the stick to be cut, the total cost is the sum of costs of all cuts. When you cut a stick, it will be split into two smaller sticks (i.e. the sum of their lengths is the length of the stick before the cut). Please refer to the first example for a better explanation.

    -

    Return the minimum total cost of the cuts.

    +

    Return the minimum total cost of the cuts.

     

    Example 1:

    @@ -45,10 +45,10 @@ There are much ordering with total cost <= 25, for example, the order [4, 6,

    Constraints:

      -
    • 2 <= n <= 10^6
    • +
    • 2 <= n <= 106
    • 1 <= cuts.length <= min(n - 1, 100)
    • 1 <= cuts[i] <= n - 1
    • -
    • All the integers in cuts array are distinct.
    • +
    • All the integers in cuts array are distinct.
    ### Related Topics diff --git a/problems/minimum-cost-to-reach-destination-in-time/README.md b/problems/minimum-cost-to-reach-destination-in-time/README.md index 4081e86be..73dbdb11c 100644 --- a/problems/minimum-cost-to-reach-destination-in-time/README.md +++ b/problems/minimum-cost-to-reach-destination-in-time/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-game "Sum Game") diff --git a/problems/minimum-cost-to-separate-sentence-into-rows/README.md b/problems/minimum-cost-to-separate-sentence-into-rows/README.md index 17d922a39..36029ae69 100644 --- a/problems/minimum-cost-to-separate-sentence-into-rows/README.md +++ b/problems/minimum-cost-to-separate-sentence-into-rows/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-category-of-each-member-in-the-store "The Category of Each Member in the Store") diff --git a/problems/minimum-cost-tree-from-leaf-values/README.md b/problems/minimum-cost-tree-from-leaf-values/README.md index 8472914f9..35cd83444 100644 --- a/problems/minimum-cost-tree-from-leaf-values/README.md +++ b/problems/minimum-cost-tree-from-leaf-values/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-path-with-alternating-colors "Shortest Path with Alternating Colors") diff --git a/problems/minimum-degree-of-a-connected-trio-in-a-graph/README.md b/problems/minimum-degree-of-a-connected-trio-in-a-graph/README.md index 7f3055dc2..039af768b 100644 --- a/problems/minimum-degree-of-a-connected-trio-in-a-graph/README.md +++ b/problems/minimum-degree-of-a-connected-trio-in-a-graph/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-limit-of-balls-in-a-bag "Minimum Limit of Balls in a Bag") diff --git a/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md b/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md index 07780cb5d..7bcb7dda0 100644 --- a/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md +++ b/problems/minimum-deletion-cost-to-avoid-repeating-letters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "Number of Ways Where Square of Number Is Equal to Product of Two Numbers") diff --git a/problems/minimum-deletions-to-make-character-frequencies-unique/README.md b/problems/minimum-deletions-to-make-character-frequencies-unique/README.md index 7832dcdcd..3fdb2db07 100644 --- a/problems/minimum-deletions-to-make-character-frequencies-unique/README.md +++ b/problems/minimum-deletions-to-make-character-frequencies-unique/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../get-maximum-in-generated-array "Get Maximum in Generated Array") @@ -52,8 +52,8 @@ Note that we only care about characters that are still in the string at the end ### Related Topics - [[String](../../tag/string/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/minimum-deletions-to-make-string-balanced/README.md b/problems/minimum-deletions-to-make-string-balanced/README.md index 1c757d15b..ced0f75da 100644 --- a/problems/minimum-deletions-to-make-string-balanced/README.md +++ b/problems/minimum-deletions-to-make-string-balanced/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../defuse-the-bomb "Defuse the Bomb") diff --git a/problems/minimum-depth-of-binary-tree/README.md b/problems/minimum-depth-of-binary-tree/README.md index e24eb7705..890e8b2ea 100644 --- a/problems/minimum-depth-of-binary-tree/README.md +++ b/problems/minimum-depth-of-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../balanced-binary-tree "Balanced Binary Tree") diff --git a/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md b/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md index f082e8fb3..e33c271fd 100644 --- a/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md +++ b/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../widest-pair-of-indices-with-equal-range-sum "Widest Pair of Indices With Equal Range Sum") diff --git a/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md b/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md index c97912c97..b999215c1 100644 --- a/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md +++ b/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../range-sum-of-sorted-subarray-sums "Range Sum of Sorted Subarray Sums") @@ -56,8 +56,8 @@ The difference between the maximum and minimum is 1-0 = 1. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/minimum-difficulty-of-a-job-schedule/README.md b/problems/minimum-difficulty-of-a-job-schedule/README.md index 1efd0840f..1dcb96035 100644 --- a/problems/minimum-difficulty-of-a-job-schedule/README.md +++ b/problems/minimum-difficulty-of-a-job-schedule/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance "Find the City With the Smallest Number of Neighbors at a Threshold Distance") diff --git a/problems/minimum-distance-to-the-target-element/README.md b/problems/minimum-distance-to-the-target-element/README.md index 184725e67..12fce50f8 100644 --- a/problems/minimum-distance-to-the-target-element/README.md +++ b/problems/minimum-distance-to-the-target-element/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../closest-room "Closest Room") diff --git a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md index ddc02a52b..b519e4090 100644 --- a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md +++ b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-operations-to-make-network-connected "Number of Operations to Make Network Connected") diff --git a/problems/minimum-elements-to-add-to-form-a-given-sum/README.md b/problems/minimum-elements-to-add-to-form-a-given-sum/README.md index 7d9b5723f..dfbb7e274 100644 --- a/problems/minimum-elements-to-add-to-form-a-given-sum/README.md +++ b/problems/minimum-elements-to-add-to-form-a-given-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-binary-string-has-at-most-one-segment-of-ones "Check if Binary String Has at Most One Segment of Ones") @@ -44,8 +44,8 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/minimum-factorization/README.md b/problems/minimum-factorization/README.md index 7ce98b925..2de984add 100644 --- a/problems/minimum-factorization/README.md +++ b/problems/minimum-factorization/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-distance-in-arrays "Maximum Distance in Arrays") @@ -34,5 +34,5 @@ Output:

    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/minimum-falling-path-sum-ii/README.md b/problems/minimum-falling-path-sum-ii/README.md index 5eabc469f..d0c06f521 100644 --- a/problems/minimum-falling-path-sum-ii/README.md +++ b/problems/minimum-falling-path-sum-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-covered-intervals "Remove Covered Intervals") @@ -50,9 +50,6 @@ The falling path with the smallest sum is [1,5,7], so the answer is 13 [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Matrix](../../tag/matrix/README.md)] -### Similar Questions - 1. [Minimum Falling Path Sum](../minimum-falling-path-sum) (Medium) - ### Hints
    Hint 1 diff --git a/problems/minimum-flips-to-make-a-or-b-equal-to-c/README.md b/problems/minimum-flips-to-make-a-or-b-equal-to-c/README.md index e9644a5ae..81c358c5a 100644 --- a/problems/minimum-flips-to-make-a-or-b-equal-to-c/README.md +++ b/problems/minimum-flips-to-make-a-or-b-equal-to-c/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-integer-to-the-sum-of-two-no-zero-integers "Convert Integer to the Sum of Two No-Zero Integers") diff --git a/problems/minimum-garden-perimeter-to-collect-enough-apples/README.md b/problems/minimum-garden-perimeter-to-collect-enough-apples/README.md index fe231b449..8b7b380b8 100644 --- a/problems/minimum-garden-perimeter-to-collect-enough-apples/README.md +++ b/problems/minimum-garden-perimeter-to-collect-enough-apples/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-weeks-for-which-you-can-work "Maximum Number of Weeks for Which You Can Work") diff --git a/problems/minimum-height-trees/README.md b/problems/minimum-height-trees/README.md index 0a7354288..5f5d66e2d 100644 --- a/problems/minimum-height-trees/README.md +++ b/problems/minimum-height-trees/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../best-time-to-buy-and-sell-stock-with-cooldown "Best Time to Buy and Sell Stock with Cooldown") diff --git a/problems/minimum-incompatibility/README.md b/problems/minimum-incompatibility/README.md index 7dbfed95f..cb789c363 100644 --- a/problems/minimum-incompatibility/README.md +++ b/problems/minimum-incompatibility/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../concatenation-of-consecutive-binary-numbers "Concatenation of Consecutive Binary Numbers") diff --git a/problems/minimum-index-sum-of-two-lists/README.md b/problems/minimum-index-sum-of-two-lists/README.md index c8c570aa8..846a3b8fa 100644 --- a/problems/minimum-index-sum-of-two-lists/README.md +++ b/problems/minimum-index-sum-of-two-lists/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../range-addition-ii "Range Addition II") diff --git a/problems/minimum-initial-energy-to-finish-tasks/README.md b/problems/minimum-initial-energy-to-finish-tasks/README.md index 88eac2a24..c8593ac98 100644 --- a/problems/minimum-initial-energy-to-finish-tasks/README.md +++ b/problems/minimum-initial-energy-to-finish-tasks/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../ways-to-make-a-fair-array "Ways to Make a Fair Array") @@ -74,8 +74,8 @@ Starting with 27 energy, we finish the tasks in the following order: ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md b/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md index 03ff464ad..db3e86945 100644 --- a/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md +++ b/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../get-watched-videos-by-your-friends "Get Watched Videos by Your Friends") diff --git a/problems/minimum-insertions-to-balance-a-parentheses-string/README.md b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md index 540c98995..3fd4fb5b2 100644 --- a/problems/minimum-insertions-to-balance-a-parentheses-string/README.md +++ b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../can-convert-string-in-k-moves "Can Convert String in K Moves") @@ -76,9 +76,12 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[String](../../tag/string/README.md)] + +### Similar Questions + 1. [Minimum Number of Swaps to Make the String Balanced](../minimum-number-of-swaps-to-make-the-string-balanced) (Medium) ### Hints
    diff --git a/problems/minimum-interval-to-include-each-query/README.md b/problems/minimum-interval-to-include-each-query/README.md index df5948a15..4cfe2d11c 100644 --- a/problems/minimum-interval-to-include-each-query/README.md +++ b/problems/minimum-interval-to-include-each-query/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-adjacent-swaps-to-reach-the-kth-smallest-number "Minimum Adjacent Swaps to Reach the Kth Smallest Number") diff --git a/problems/minimum-jumps-to-reach-home/README.md b/problems/minimum-jumps-to-reach-home/README.md index cee72e6fb..d9e52ef2a 100644 --- a/problems/minimum-jumps-to-reach-home/README.md +++ b/problems/minimum-jumps-to-reach-home/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-deletions-to-make-string-balanced "Minimum Deletions to Make String Balanced") diff --git a/problems/minimum-length-of-string-after-deleting-similar-ends/README.md b/problems/minimum-length-of-string-after-deleting-similar-ends/README.md index 6bad2b22e..83de2d6e8 100644 --- a/problems/minimum-length-of-string-after-deleting-similar-ends/README.md +++ b/problems/minimum-length-of-string-after-deleting-similar-ends/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-absolute-sum-of-any-subarray "Maximum Absolute Sum of Any Subarray") diff --git a/problems/minimum-limit-of-balls-in-a-bag/README.md b/problems/minimum-limit-of-balls-in-a-bag/README.md index 996ff699d..85b5b54ac 100644 --- a/problems/minimum-limit-of-balls-in-a-bag/README.md +++ b/problems/minimum-limit-of-balls-in-a-bag/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-number-of-homogenous-substrings "Count Number of Homogenous Substrings") @@ -71,9 +71,6 @@ The bag with the most number of balls has 2 balls, so your penalty is 2 an you s [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] -### Similar Questions - 1. [Minimized Maximum of Products Distributed to Any Store](../minimized-maximum-of-products-distributed-to-any-store) (Medium) - ### Hints
    Hint 1 diff --git a/problems/minimum-moves-to-convert-string/README.md b/problems/minimum-moves-to-convert-string/README.md index 377145f1d..b05b55634 100644 --- a/problems/minimum-moves-to-convert-string/README.md +++ b/problems/minimum-moves-to-convert-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../low-quality-problems "Low-Quality Problems") diff --git a/problems/minimum-moves-to-equal-array-elements-ii/README.md b/problems/minimum-moves-to-equal-array-elements-ii/README.md index 6b7d83e00..93facd4a6 100644 --- a/problems/minimum-moves-to-equal-array-elements-ii/README.md +++ b/problems/minimum-moves-to-equal-array-elements-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../hamming-distance "Hamming Distance") diff --git a/problems/minimum-moves-to-equal-array-elements/README.md b/problems/minimum-moves-to-equal-array-elements/README.md index c1d2c38a3..b830f1c85 100644 --- a/problems/minimum-moves-to-equal-array-elements/README.md +++ b/problems/minimum-moves-to-equal-array-elements/README.md @@ -1,15 +1,15 @@ - - - + + + [< Previous](../minimum-number-of-arrows-to-burst-balloons "Minimum Number of Arrows to Burst Balloons")                  [Next >](../4sum-ii "4Sum II") -## [453. Minimum Moves to Equal Array Elements (Easy)](https://leetcode.com/problems/minimum-moves-to-equal-array-elements "最小操作次数使数组元素相等") +## [453. Minimum Moves to Equal Array Elements (Medium)](https://leetcode.com/problems/minimum-moves-to-equal-array-elements "最小操作次数使数组元素相等")

    Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal.

    diff --git a/problems/minimum-moves-to-make-array-complementary/README.md b/problems/minimum-moves-to-make-array-complementary/README.md index 23c4443a6..bac1b8a62 100644 --- a/problems/minimum-moves-to-make-array-complementary/README.md +++ b/problems/minimum-moves-to-make-array-complementary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-most-competitive-subsequence "Find the Most Competitive Subsequence") diff --git a/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md b/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md index b2674e4f4..486ed61bd 100644 --- a/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md +++ b/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../greatest-sum-divisible-by-three "Greatest Sum Divisible by Three") @@ -87,10 +87,10 @@ ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] - [[Matrix](../../tag/matrix/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/minimum-non-zero-product-of-the-array-elements/README.md b/problems/minimum-non-zero-product-of-the-array-elements/README.md index 627db8207..9652b9b39 100644 --- a/problems/minimum-non-zero-product-of-the-array-elements/README.md +++ b/problems/minimum-non-zero-product-of-the-array-elements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../array-with-elements-not-equal-to-average-of-neighbors "Array With Elements Not Equal to Average of Neighbors") diff --git a/problems/minimum-number-of-days-to-disconnect-island/README.md b/problems/minimum-number-of-days-to-disconnect-island/README.md index 5ae12e99d..26163ef0f 100644 --- a/problems/minimum-number-of-days-to-disconnect-island/README.md +++ b/problems/minimum-number-of-days-to-disconnect-island/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-length-of-subarray-with-positive-product "Maximum Length of Subarray With Positive Product") @@ -75,9 +75,9 @@ Change land grid[1][1] and grid[0][2] to water and get 2 disconnected island. ### Related Topics - [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Strongly Connected Component](../../tag/strongly-connected-component/README.md)] diff --git a/problems/minimum-number-of-days-to-eat-n-oranges/README.md b/problems/minimum-number-of-days-to-eat-n-oranges/README.md index a6032a7a1..2f250b084 100644 --- a/problems/minimum-number-of-days-to-eat-n-oranges/README.md +++ b/problems/minimum-number-of-days-to-eat-n-oranges/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../magnetic-force-between-two-balls "Magnetic Force Between Two Balls") @@ -15,8 +15,8 @@
    • Eat one orange.
    • -
    • If the number of remaining oranges (n) is divisible by 2 then you can eat  n/2 oranges.
    • -
    • If the number of remaining oranges (n) is divisible by 3 then you can eat  2*(n/3) oranges.
    • +
    • If the number of remaining oranges n is divisible by 2 then you can eat n / 2 oranges.
    • +
    • If the number of remaining oranges n is divisible by 3 then you can eat 2 * (n / 3) oranges.

    You can only choose one of the actions per day.

    @@ -67,7 +67,7 @@ You need at least 3 days to eat the 6 oranges.

    Constraints:

      -
    • 1 <= n <= 2*10^9
    • +
    • 1 <= n <= 2 * 109
    ### Related Topics diff --git a/problems/minimum-number-of-days-to-make-m-bouquets/README.md b/problems/minimum-number-of-days-to-make-m-bouquets/README.md index 584cd0de2..79478879e 100644 --- a/problems/minimum-number-of-days-to-make-m-bouquets/README.md +++ b/problems/minimum-number-of-days-to-make-m-bouquets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../least-number-of-unique-integers-after-k-removals "Least Number of Unique Integers after K Removals") diff --git a/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md b/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md index e7067938d..0dcbfe47e 100644 --- a/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md +++ b/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-smallest-divisor-given-a-threshold "Find the Smallest Divisor Given a Threshold") diff --git a/problems/minimum-number-of-flips-to-make-the-binary-string-alternating/README.md b/problems/minimum-number-of-flips-to-make-the-binary-string-alternating/README.md index 5f1ca62a4..b039c7179 100644 --- a/problems/minimum-number-of-flips-to-make-the-binary-string-alternating/README.md +++ b/problems/minimum-number-of-flips-to-make-the-binary-string-alternating/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reduction-operations-to-make-the-array-elements-equal "Reduction Operations to Make the Array Elements Equal") diff --git a/problems/minimum-number-of-frogs-croaking/README.md b/problems/minimum-number-of-frogs-croaking/README.md index 4ad168c9b..55866e125 100644 --- a/problems/minimum-number-of-frogs-croaking/README.md +++ b/problems/minimum-number-of-frogs-croaking/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../display-table-of-food-orders-in-a-restaurant "Display Table of Food Orders in a Restaurant") diff --git a/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md b/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md index 275f1e4fb..d2ff2706f 100644 --- a/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md +++ b/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-good-ways-to-split-a-string "Number of Good Ways to Split a String") diff --git a/problems/minimum-number-of-moves-to-seat-everyone/README.md b/problems/minimum-number-of-moves-to-seat-everyone/README.md index 8667b1d0c..16ab9e64b 100644 --- a/problems/minimum-number-of-moves-to-seat-everyone/README.md +++ b/problems/minimum-number-of-moves-to-seat-everyone/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-alternating-subarray-sum "Maximum Alternating Subarray Sum") diff --git a/problems/minimum-number-of-operations-to-make-array-continuous/README.md b/problems/minimum-number-of-operations-to-make-array-continuous/README.md index e9195c838..93bc9000d 100644 --- a/problems/minimum-number-of-operations-to-make-array-continuous/README.md +++ b/problems/minimum-number-of-operations-to-make-array-continuous/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-earnings-from-taxi "Maximum Earnings From Taxi") diff --git a/problems/minimum-number-of-operations-to-make-string-sorted/README.md b/problems/minimum-number-of-operations-to-make-string-sorted/README.md index 8d1e43c2e..7aa3e5a7d 100644 --- a/problems/minimum-number-of-operations-to-make-string-sorted/README.md +++ b/problems/minimum-number-of-operations-to-make-string-sorted/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-xor-for-each-query "Maximum XOR for Each Query") diff --git a/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md b/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md index 39d2ee8a2..3f34200f4 100644 --- a/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md +++ b/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../merge-strings-alternately "Merge Strings Alternately") @@ -50,9 +50,6 @@ [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] -### Similar Questions - 1. [Minimum Cost to Move Chips to The Same Position](../minimum-cost-to-move-chips-to-the-same-position) (Easy) - ### Hints
    Hint 1 diff --git a/problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md b/problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md index 9b41ba166..ed5e1cc09 100644 --- a/problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md +++ b/problems/minimum-number-of-operations-to-reinitialize-a-permutation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-different-integers-in-a-string "Number of Different Integers in a String") diff --git a/problems/minimum-number-of-people-to-teach/README.md b/problems/minimum-number-of-people-to-teach/README.md index 1dc39674f..7dd7bea79 100644 --- a/problems/minimum-number-of-people-to-teach/README.md +++ b/problems/minimum-number-of-people-to-teach/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-highest-altitude "Find the Highest Altitude") diff --git a/problems/minimum-number-of-removals-to-make-mountain-array/README.md b/problems/minimum-number-of-removals-to-make-mountain-array/README.md index 732e11a35..7f2ca1d02 100644 --- a/problems/minimum-number-of-removals-to-make-mountain-array/README.md +++ b/problems/minimum-number-of-removals-to-make-mountain-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-front-middle-back-queue "Design Front Middle Back Queue") @@ -66,17 +66,10 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Greedy](../../tag/greedy/README.md)] - -### Similar Questions - 1. [Longest Increasing Subsequence](../longest-increasing-subsequence) (Medium) - 1. [Longest Mountain in Array](../longest-mountain-in-array) (Medium) - 1. [Peak Index in a Mountain Array](../peak-index-in-a-mountain-array) (Easy) - 1. [Valid Mountain Array](../valid-mountain-array) (Easy) - 1. [Find in Mountain Array](../find-in-mountain-array) (Hard) ### Hints
    diff --git a/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md b/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md index fdf8008a6..5038dbee9 100644 --- a/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md +++ b/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-n-and-its-double-exist "Check If N and Its Double Exist") @@ -69,6 +69,9 @@ [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Determine if Two Strings Are Close](../determine-if-two-strings-are-close) (Medium) + ### Hints
    Hint 1 diff --git a/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md b/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md index 6100faa01..179da70b9 100644 --- a/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md +++ b/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-all-subset-xor-totals "Sum of All Subset XOR Totals") diff --git a/problems/minimum-number-of-swaps-to-make-the-string-balanced/README.md b/problems/minimum-number-of-swaps-to-make-the-string-balanced/README.md index 116007468..04944ffd0 100644 --- a/problems/minimum-number-of-swaps-to-make-the-string-balanced/README.md +++ b/problems/minimum-number-of-swaps-to-make-the-string-balanced/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-stones-to-minimize-the-total "Remove Stones to Minimize the Total") diff --git a/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md b/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md index b6c6547fe..3f1157121 100644 --- a/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md +++ b/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-leaves-with-a-given-value "Delete Leaves With a Given Value") @@ -73,9 +73,9 @@ Opening Only the second tap will water the whole garden [0,5] ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/minimum-number-of-vertices-to-reach-all-nodes/README.md b/problems/minimum-number-of-vertices-to-reach-all-nodes/README.md index 8dd361e1c..0732e0be0 100644 --- a/problems/minimum-number-of-vertices-to-reach-all-nodes/README.md +++ b/problems/minimum-number-of-vertices-to-reach-all-nodes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../thousand-separator "Thousand Separator") diff --git a/problems/minimum-number-of-work-sessions-to-finish-the-tasks/README.md b/problems/minimum-number-of-work-sessions-to-finish-the-tasks/README.md index 68440f11a..7062502be 100644 --- a/problems/minimum-number-of-work-sessions-to-finish-the-tasks/README.md +++ b/problems/minimum-number-of-work-sessions-to-finish-the-tasks/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-kth-largest-integer-in-the-array "Find the Kth Largest Integer in the Array") diff --git a/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md b/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md index 0dfac9e44..9fcfb0f7e 100644 --- a/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md +++ b/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-vertices-to-reach-all-nodes "Minimum Number of Vertices to Reach All Nodes") diff --git a/problems/minimum-one-bit-operations-to-make-integers-zero/README.md b/problems/minimum-one-bit-operations-to-make-integers-zero/README.md index b04d7fdaf..6daae4a00 100644 --- a/problems/minimum-one-bit-operations-to-make-integers-zero/README.md +++ b/problems/minimum-one-bit-operations-to-make-integers-zero/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-visible-points "Maximum Number of Visible Points") diff --git a/problems/minimum-operations-to-convert-number/README.md b/problems/minimum-operations-to-convert-number/README.md index 090f581f2..941b3a389 100644 --- a/problems/minimum-operations-to-convert-number/README.md +++ b/problems/minimum-operations-to-convert-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-minimum-and-maximum-number-of-nodes-between-critical-points "Find the Minimum and Maximum Number of Nodes Between Critical Points") diff --git a/problems/minimum-operations-to-make-a-subsequence/README.md b/problems/minimum-operations-to-make-a-subsequence/README.md index 1f0095ead..2284fd92b 100644 --- a/problems/minimum-operations-to-make-a-subsequence/README.md +++ b/problems/minimum-operations-to-make-a-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../ways-to-split-array-into-three-subarrays "Ways to Split Array Into Three Subarrays") diff --git a/problems/minimum-operations-to-make-a-uni-value-grid/README.md b/problems/minimum-operations-to-make-a-uni-value-grid/README.md index 7c9e2c738..e0b204b83 100644 --- a/problems/minimum-operations-to-make-a-uni-value-grid/README.md +++ b/problems/minimum-operations-to-make-a-uni-value-grid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-out-of-three "Two Out of Three") diff --git a/problems/minimum-operations-to-make-array-equal/README.md b/problems/minimum-operations-to-make-array-equal/README.md index a975cb28b..6b184beb4 100644 --- a/problems/minimum-operations-to-make-array-equal/README.md +++ b/problems/minimum-operations-to-make-array-equal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../three-consecutive-odds "Three Consecutive Odds") @@ -11,11 +11,11 @@ ## [1551. Minimum Operations to Make Array Equal (Medium)](https://leetcode.com/problems/minimum-operations-to-make-array-equal "使数组中所有元素相等的最小操作数") -

    You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i (i.e. 0 <= i < n).

    +

    You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i (i.e., 0 <= i < n).

    -

    In one operation, you can select two indices x and y where 0 <= x, y < n and subtract 1 from arr[x] and add 1 to arr[y] (i.e. perform arr[x] -=1 and arr[y] += 1). The goal is to make all the elements of the array equal. It is guaranteed that all the elements of the array can be made equal using some operations.

    +

    In one operation, you can select two indices x and y where 0 <= x, y < n and subtract 1 from arr[x] and add 1 to arr[y] (i.e., perform arr[x] -=1 and arr[y] += 1). The goal is to make all the elements of the array equal. It is guaranteed that all the elements of the array can be made equal using some operations.

    -

    Given an integer n, the length of the array. Return the minimum number of operations needed to make all the elements of arr equal.

    +

    Given an integer n, the length of the array, return the minimum number of operations needed to make all the elements of arr equal.

     

    Example 1:

    @@ -39,7 +39,7 @@ In the second operation choose x = 2 and y = 0 again, thus arr = [3, 3, 3].

    Constraints:

      -
    • 1 <= n <= 10^4
    • +
    • 1 <= n <= 104
    ### Related Topics diff --git a/problems/minimum-operations-to-make-the-array-increasing/README.md b/problems/minimum-operations-to-make-the-array-increasing/README.md index e556d5320..ea365b974 100644 --- a/problems/minimum-operations-to-make-the-array-increasing/README.md +++ b/problems/minimum-operations-to-make-the-array-increasing/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../faulty-sensor "Faulty Sensor") diff --git a/problems/minimum-operations-to-reduce-x-to-zero/README.md b/problems/minimum-operations-to-reduce-x-to-zero/README.md index 0b14663ae..a3e83af42 100644 --- a/problems/minimum-operations-to-reduce-x-to-zero/README.md +++ b/problems/minimum-operations-to-reduce-x-to-zero/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../determine-if-two-strings-are-close "Determine if Two Strings Are Close") diff --git a/problems/minimum-path-cost-in-a-hidden-grid/README.md b/problems/minimum-path-cost-in-a-hidden-grid/README.md index 96b02ee45..cfccec590 100644 --- a/problems/minimum-path-cost-in-a-hidden-grid/README.md +++ b/problems/minimum-path-cost-in-a-hidden-grid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../ad-free-sessions "Ad-Free Sessions") @@ -17,12 +17,8 @@ [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] [[Interactive](../../tag/interactive/README.md)] - -### Similar Questions - 1. [Robot Room Cleaner](../robot-room-cleaner) (Hard) - 1. [Shortest Path in a Hidden Grid](../shortest-path-in-a-hidden-grid) (Medium) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/minimum-remove-to-make-valid-parentheses/README.md b/problems/minimum-remove-to-make-valid-parentheses/README.md index b9c47d07b..370877ada 100644 --- a/problems/minimum-remove-to-make-valid-parentheses/README.md +++ b/problems/minimum-remove-to-make-valid-parentheses/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-number-of-nice-subarrays "Count Number of Nice Subarrays") diff --git a/problems/minimum-sideway-jumps/README.md b/problems/minimum-sideway-jumps/README.md index 56fe5ea6c..e3df8214b 100644 --- a/problems/minimum-sideway-jumps/README.md +++ b/problems/minimum-sideway-jumps/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-winner-of-the-circular-game "Find the Winner of the Circular Game") @@ -66,9 +66,12 @@ Note that the frog can jump over obstacles only when making side jumps (as shown ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Similar Questions + 1. [Frog Jump](../frog-jump) (Hard) ### Hints
    diff --git a/problems/minimum-size-subarray-sum/README.md b/problems/minimum-size-subarray-sum/README.md index 8d4323693..431ecc096 100644 --- a/problems/minimum-size-subarray-sum/README.md +++ b/problems/minimum-size-subarray-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../implement-trie-prefix-tree "Implement Trie (Prefix Tree)") diff --git a/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md b/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md index b40cb1c74..0e88486e6 100644 --- a/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md +++ b/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../process-tasks-using-servers "Process Tasks Using Servers") diff --git a/problems/minimum-space-wasted-from-packaging/README.md b/problems/minimum-space-wasted-from-packaging/README.md index 28578d552..a012e8bca 100644 --- a/problems/minimum-space-wasted-from-packaging/README.md +++ b/problems/minimum-space-wasted-from-packaging/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-flips-to-make-the-binary-string-alternating "Minimum Number of Flips to Make the Binary String Alternating") diff --git a/problems/minimum-speed-to-arrive-on-time/README.md b/problems/minimum-speed-to-arrive-on-time/README.md index adcbdfe4d..c9ecb7bc8 100644 --- a/problems/minimum-speed-to-arrive-on-time/README.md +++ b/problems/minimum-speed-to-arrive-on-time/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longer-contiguous-segments-of-ones-than-zeros "Longer Contiguous Segments of Ones than Zeros") diff --git a/problems/minimum-subsequence-in-non-increasing-order/README.md b/problems/minimum-subsequence-in-non-increasing-order/README.md index d93029247..af2af0779 100644 --- a/problems/minimum-subsequence-in-non-increasing-order/README.md +++ b/problems/minimum-subsequence-in-non-increasing-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reducing-dishes "Reducing Dishes") @@ -50,8 +50,8 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/minimum-swaps-to-arrange-a-binary-grid/README.md b/problems/minimum-swaps-to-arrange-a-binary-grid/README.md index 95ceaeb03..9a67343eb 100644 --- a/problems/minimum-swaps-to-arrange-a-binary-grid/README.md +++ b/problems/minimum-swaps-to-arrange-a-binary-grid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-winner-of-an-array-game "Find the Winner of an Array Game") @@ -11,7 +11,7 @@ ## [1536. Minimum Swaps to Arrange a Binary Grid (Medium)](https://leetcode.com/problems/minimum-swaps-to-arrange-a-binary-grid "排布二进制网格的最少交换次数") -

    Given an n x n binary grid, in one step you can choose two adjacent rows of the grid and swap them.

    +

    Given an n x n binary grid, in one step you can choose two adjacent rows of the grid and swap them.

    A grid is said to be valid if all the cells above the main diagonal are zeros.

    @@ -46,10 +46,9 @@

    Constraints:

      -
    • n == grid.length
    • -
    • n == grid[i].length
    • -
    • 1 <= n <= 200
    • -
    • grid[i][j] is 0 or 1
    • +
    • n == grid.length == grid[i].length
    • +
    • 1 <= n <= 200
    • +
    • grid[i][j] is either 0 or 1
    ### Related Topics diff --git a/problems/minimum-swaps-to-group-all-1s-together/README.md b/problems/minimum-swaps-to-group-all-1s-together/README.md index 4035377a3..7709f2917 100644 --- a/problems/minimum-swaps-to-group-all-1s-together/README.md +++ b/problems/minimum-swaps-to-group-all-1s-together/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-a-number-is-majority-element-in-a-sorted-array "Check If a Number Is Majority Element in a Sorted Array") @@ -59,6 +59,9 @@ One possible solution that uses 3 swaps is [0,0,0,0,0,1,1,1,1,1,1]. [[Array](../../tag/array/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] +### Similar Questions + 1. [Minimum Adjacent Swaps for K Consecutive Ones](../minimum-adjacent-swaps-for-k-consecutive-ones) (Hard) + ### Hints
    Hint 1 diff --git a/problems/minimum-swaps-to-make-strings-equal/README.md b/problems/minimum-swaps-to-make-strings-equal/README.md index e50b97c41..c80adf70c 100644 --- a/problems/minimum-swaps-to-make-strings-equal/README.md +++ b/problems/minimum-swaps-to-make-strings-equal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../palindrome-removal "Palindrome Removal") diff --git a/problems/minimum-time-for-k-virus-variants-to-spread/README.md b/problems/minimum-time-for-k-virus-variants-to-spread/README.md index c91d81e7e..3b5cdd475 100644 --- a/problems/minimum-time-for-k-virus-variants-to-spread/README.md +++ b/problems/minimum-time-for-k-virus-variants-to-spread/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-number-of-special-subsequences "Count Number of Special Subsequences") diff --git a/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md b/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md index a70b6db6b..72ac218db 100644 --- a/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md +++ b/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-triplets-that-can-form-two-arrays-of-equal-xor "Count Triplets That Can Form Two Arrays of Equal XOR") diff --git a/problems/minimum-time-to-type-word-using-special-typewriter/README.md b/problems/minimum-time-to-type-word-using-special-typewriter/README.md index 21d475e25..3fb98afb0 100644 --- a/problems/minimum-time-to-type-word-using-special-typewriter/README.md +++ b/problems/minimum-time-to-type-word-using-special-typewriter/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-nodes-equal-to-sum-of-descendants "Count Nodes Equal to Sum of Descendants") diff --git a/problems/minimum-time-visiting-all-points/README.md b/problems/minimum-time-visiting-all-points/README.md index f66a2fe95..a30f21c83 100644 --- a/problems/minimum-time-visiting-all-points/README.md +++ b/problems/minimum-time-visiting-all-points/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../print-immutable-linked-list-in-reverse "Print Immutable Linked List in Reverse") diff --git a/problems/minimum-total-space-wasted-with-k-resizing-operations/README.md b/problems/minimum-total-space-wasted-with-k-resizing-operations/README.md index 9668b96ce..38cc07a1b 100644 --- a/problems/minimum-total-space-wasted-with-k-resizing-operations/README.md +++ b/problems/minimum-total-space-wasted-with-k-resizing-operations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-move-is-legal "Check if Move is Legal") diff --git a/problems/minimum-value-to-get-positive-step-by-step-sum/README.md b/problems/minimum-value-to-get-positive-step-by-step-sum/README.md index 97ef9c6ee..9d3ae86dc 100644 --- a/problems/minimum-value-to-get-positive-step-by-step-sum/README.md +++ b/problems/minimum-value-to-get-positive-step-by-step-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-quiet-students-in-all-exams "Find the Quiet Students in All Exams") @@ -24,13 +24,13 @@ Input: nums = [-3,2,-3,4,2] Output: 5 Explanation: If you choose startValue = 4, in the third iteration your step by step sum is less than 1. - step by step sum -  startValue = 4 | startValue = 5 | nums -  (4 -3 ) = 1 | (5 -3 ) = 2 | -3 -  (1 +2 ) = 3 | (2 +2 ) = 4 | 2 -  (3 -3 ) = 0 | (4 -3 ) = 1 | -3 -  (0 +4 ) = 4 | (1 +4 ) = 5 | 4 -  (4 +2 ) = 6 | (5 +2 ) = 7 | 2 +step by step sum +startValue = 4 | startValue = 5 | nums + (4 -3 ) = 1 | (5 -3 ) = 2 | -3 + (1 +2 ) = 3 | (2 +2 ) = 4 | 2 + (3 -3 ) = 0 | (4 -3 ) = 1 | -3 + (0 +4 ) = 4 | (1 +4 ) = 5 | 4 + (4 +2 ) = 6 | (5 +2 ) = 7 | 2

    Example 2:

    diff --git a/problems/minimum-window-substring/README.md b/problems/minimum-window-substring/README.md index 0135d2e32..8fd505163 100644 --- a/problems/minimum-window-substring/README.md +++ b/problems/minimum-window-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-colors "Sort Colors") @@ -66,6 +66,7 @@ Since the largest window of s only has one 'a', return empty string. 1. [Minimum Size Subarray Sum](../minimum-size-subarray-sum) (Medium) 1. [Sliding Window Maximum](../sliding-window-maximum) (Hard) 1. [Permutation in String](../permutation-in-string) (Medium) + 1. [Smallest Range Covering Elements from K Lists](../smallest-range-covering-elements-from-k-lists) (Hard) 1. [Minimum Window Subsequence](../minimum-window-subsequence) (Hard) ### Hints diff --git a/problems/minimum-xor-sum-of-two-arrays/README.md b/problems/minimum-xor-sum-of-two-arrays/README.md index 1b1ab001c..e2aefc089 100644 --- a/problems/minimum-xor-sum-of-two-arrays/README.md +++ b/problems/minimum-xor-sum-of-two-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../get-biggest-three-rhombus-sums-in-a-grid "Get Biggest Three Rhombus Sums in a Grid") diff --git a/problems/mirror-reflection/README.md b/problems/mirror-reflection/README.md index 38983a7f9..df9c98dfa 100644 --- a/problems/mirror-reflection/README.md +++ b/problems/mirror-reflection/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-hire-k-workers "Minimum Cost to Hire K Workers") @@ -43,5 +43,5 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] diff --git a/problems/missing-element-in-sorted-array/README.md b/problems/missing-element-in-sorted-array/README.md index 9766f6cb3..096bf02d0 100644 --- a/problems/missing-element-in-sorted-array/README.md +++ b/problems/missing-element-in-sorted-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-paths-from-source-lead-to-destination "All Paths from Source Lead to Destination") diff --git a/problems/missing-number-in-arithmetic-progression/README.md b/problems/missing-number-in-arithmetic-progression/README.md index ed3d1c078..26c0e9499 100644 --- a/problems/missing-number-in-arithmetic-progression/README.md +++ b/problems/missing-number-in-arithmetic-progression/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../airplane-seat-assignment-probability "Airplane Seat Assignment Probability") diff --git a/problems/missing-number/README.md b/problems/missing-number/README.md index c6300790f..6537570f6 100644 --- a/problems/missing-number/README.md +++ b/problems/missing-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../palindrome-permutation-ii "Palindrome Permutation II") diff --git a/problems/monthly-transactions-i/README.md b/problems/monthly-transactions-i/README.md index e87c5b4e1..7eaff3dbd 100644 --- a/problems/monthly-transactions-i/README.md +++ b/problems/monthly-transactions-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../critical-connections-in-a-network "Critical Connections in a Network") diff --git a/problems/monthly-transactions-i/mysql_schemas.sql b/problems/monthly-transactions-i/mysql_schemas.sql index c5a883654..f46d70e2f 100644 --- a/problems/monthly-transactions-i/mysql_schemas.sql +++ b/problems/monthly-transactions-i/mysql_schemas.sql @@ -1,4 +1,4 @@ -create table if not exists Transactions (id int, country varchar(4), state enum('approved', 'declined'), amount int, trans_date date); +Create table If Not Exists Transactions (id int, country varchar(4), state enum('approved', 'declined'), amount int, trans_date date); Truncate table Transactions; insert into Transactions (id, country, state, amount, trans_date) values ('121', 'US', 'approved', '1000', '2018-12-18'); insert into Transactions (id, country, state, amount, trans_date) values ('122', 'US', 'declined', '2000', '2018-12-19'); diff --git a/problems/most-beautiful-item-for-each-query/README.md b/problems/most-beautiful-item-for-each-query/README.md index 8b0c0dcc5..4322b3b80 100644 --- a/problems/most-beautiful-item-for-each-query/README.md +++ b/problems/most-beautiful-item-for-each-query/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../walking-robot-simulation-ii "Walking Robot Simulation II") diff --git a/problems/most-profit-assigning-work/README.md b/problems/most-profit-assigning-work/README.md index 338226ddf..ff6912b7e 100644 --- a/problems/most-profit-assigning-work/README.md +++ b/problems/most-profit-assigning-work/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../friends-of-appropriate-ages "Friends Of Appropriate Ages") diff --git a/problems/most-stones-removed-with-same-row-or-column/README.md b/problems/most-stones-removed-with-same-row-or-column/README.md index 8a44c6396..5c81899d5 100644 --- a/problems/most-stones-removed-with-same-row-or-column/README.md +++ b/problems/most-stones-removed-with-same-row-or-column/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../validate-stack-sequences "Validate Stack Sequences") diff --git a/problems/most-visited-sector-in-a-circular-track/README.md b/problems/most-visited-sector-in-a-circular-track/README.md index aeadb51fb..dde19d99c 100644 --- a/problems/most-visited-sector-in-a-circular-track/README.md +++ b/problems/most-visited-sector-in-a-circular-track/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../detect-cycles-in-2d-grid "Detect Cycles in 2D Grid") @@ -11,11 +11,11 @@ ## [1560. Most Visited Sector in a Circular Track (Easy)](https://leetcode.com/problems/most-visited-sector-in-a-circular-track "圆形赛道上经过次数最多的扇区") -

    Given an integer n and an integer array rounds. We have a circular track which consists of n sectors labeled from 1 to n. A marathon will be held on this track, the marathon consists of m rounds. The ith round starts at sector rounds[i - 1] and ends at sector rounds[i]. For example, round 1 starts at sector rounds[0] and ends at sector rounds[1]

    +

    Given an integer n and an integer array rounds. We have a circular track which consists of n sectors labeled from 1 to n. A marathon will be held on this track, the marathon consists of m rounds. The ith round starts at sector rounds[i - 1] and ends at sector rounds[i]. For example, round 1 starts at sector rounds[0] and ends at sector rounds[1]

    Return an array of the most visited sectors sorted in ascending order.

    -

    Notice that you circulate the track in ascending order of sector numbers in the counter-clockwise direction (See the first example).

    +

    Notice that you circulate the track in ascending order of sector numbers in the counter-clockwise direction (See the first example).

     

    Example 1:

    diff --git a/problems/move-sub-tree-of-n-ary-tree/README.md b/problems/move-sub-tree-of-n-ary-tree/README.md index 7b3f55ebd..a6afdc459 100644 --- a/problems/move-sub-tree-of-n-ary-tree/README.md +++ b/problems/move-sub-tree-of-n-ary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../best-position-for-a-service-centre "Best Position for a Service Centre") @@ -17,6 +17,9 @@ [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] +### Similar Questions + 1. [Find Root of N-Ary Tree](../find-root-of-n-ary-tree) (Medium) + ### Hints
    Hint 1 diff --git a/problems/movie-rating/README.md b/problems/movie-rating/README.md index d4d0c2a2d..92060fa44 100644 --- a/problems/movie-rating/README.md +++ b/problems/movie-rating/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../jump-game-v "Jump Game V") diff --git a/problems/moving-average-from-data-stream/README.md b/problems/moving-average-from-data-stream/README.md index f918c4396..d114871ff 100644 --- a/problems/moving-average-from-data-stream/README.md +++ b/problems/moving-average-from-data-stream/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-vowels-of-a-string "Reverse Vowels of a String") diff --git a/problems/moving-stones-until-consecutive-ii/README.md b/problems/moving-stones-until-consecutive-ii/README.md index 036567f21..23713bb67 100644 --- a/problems/moving-stones-until-consecutive-ii/README.md +++ b/problems/moving-stones-until-consecutive-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-score-triangulation-of-polygon "Minimum Score Triangulation of Polygon") diff --git a/problems/moving-stones-until-consecutive/README.md b/problems/moving-stones-until-consecutive/README.md index e7de515ef..ed4929f36 100644 --- a/problems/moving-stones-until-consecutive/README.md +++ b/problems/moving-stones-until-consecutive/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stream-of-characters "Stream of Characters") @@ -58,8 +58,8 @@ ### Related Topics - [[Brainteaser](../../tag/brainteaser/README.md)] [[Math](../../tag/math/README.md)] + [[Brainteaser](../../tag/brainteaser/README.md)] ### Hints
    diff --git a/problems/multiply-strings/README.md b/problems/multiply-strings/README.md index 5de23a000..0a72f5fdf 100644 --- a/problems/multiply-strings/README.md +++ b/problems/multiply-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../trapping-rain-water "Trapping Rain Water") diff --git a/problems/my-calendar-ii/README.md b/problems/my-calendar-ii/README.md index ff37dee7b..b7e248b90 100644 --- a/problems/my-calendar-ii/README.md +++ b/problems/my-calendar-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-different-palindromic-subsequences "Count Different Palindromic Subsequences") diff --git a/problems/n-ary-tree-level-order-traversal/README.md b/problems/n-ary-tree-level-order-traversal/README.md index b98d1f2b6..cf206b66c 100644 --- a/problems/n-ary-tree-level-order-traversal/README.md +++ b/problems/n-ary-tree-level-order-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../serialize-and-deserialize-n-ary-tree "Serialize and Deserialize N-ary Tree") diff --git a/problems/n-ary-tree-postorder-traversal/README.md b/problems/n-ary-tree-postorder-traversal/README.md index 6fb7c1ada..3e107347d 100644 --- a/problems/n-ary-tree-postorder-traversal/README.md +++ b/problems/n-ary-tree-postorder-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../n-ary-tree-preorder-traversal "N-ary Tree Preorder Traversal") diff --git a/problems/n-ary-tree-preorder-traversal/README.md b/problems/n-ary-tree-preorder-traversal/README.md index 748911d67..94fc226d9 100644 --- a/problems/n-ary-tree-preorder-traversal/README.md +++ b/problems/n-ary-tree-preorder-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-in-memory-file-system "Design In-Memory File System") diff --git a/problems/n-th-tribonacci-number/README.md b/problems/n-th-tribonacci-number/README.md index 43b0b3b94..aad681a58 100644 --- a/problems/n-th-tribonacci-number/README.md +++ b/problems/n-th-tribonacci-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../parallel-courses "Parallel Courses") diff --git a/problems/nearest-exit-from-entrance-in-maze/README.md b/problems/nearest-exit-from-entrance-in-maze/README.md index b3e3aabfe..6ecf2c2bf 100644 --- a/problems/nearest-exit-from-entrance-in-maze/README.md +++ b/problems/nearest-exit-from-entrance-in-maze/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-square-sum-triples "Count Square Sum Triples") diff --git a/problems/nested-list-weight-sum/README.md b/problems/nested-list-weight-sum/README.md index 11b69f5a6..68ee743ea 100644 --- a/problems/nested-list-weight-sum/README.md +++ b/problems/nested-list-weight-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../counting-bits "Counting Bits") @@ -38,4 +38,4 @@ ### Similar Questions 1. [Nested List Weight Sum II](../nested-list-weight-sum-ii) (Medium) 1. [Array Nesting](../array-nesting) (Medium) - 1. [Employee Importance](../employee-importance) (Easy) + 1. [Employee Importance](../employee-importance) (Medium) diff --git a/problems/new-21-game/README.md b/problems/new-21-game/README.md index a1643a0c3..71e615e07 100644 --- a/problems/new-21-game/README.md +++ b/problems/new-21-game/README.md @@ -1,15 +1,15 @@ - - - + + + [< Previous](../rectangle-overlap "Rectangle Overlap")                  [Next >](../push-dominoes "Push Dominoes") -## [837. New 21 Game (Medium)](https://leetcode.com/problems/new-21-game "新21点") +## [837. New 21 Game (Medium)](https://leetcode.com/problems/new-21-game "新 21 点")

    Alice plays the following game, loosely based on the card game "21".

    diff --git a/problems/next-closest-time/README.md b/problems/next-closest-time/README.md index 89431c6f1..668e17970 100644 --- a/problems/next-closest-time/README.md +++ b/problems/next-closest-time/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-palindrome-ii "Valid Palindrome II") diff --git a/problems/next-greater-element-i/README.md b/problems/next-greater-element-i/README.md index 834144f2f..3a5f0dc2f 100644 --- a/problems/next-greater-element-i/README.md +++ b/problems/next-greater-element-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../teemo-attacking "Teemo Attacking") diff --git a/problems/next-greater-element-ii/README.md b/problems/next-greater-element-ii/README.md index f5aad81ad..7bcd419b2 100644 --- a/problems/next-greater-element-ii/README.md +++ b/problems/next-greater-element-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../ipo "IPO") @@ -42,8 +42,8 @@ The second 1's next greater number needs to search circularly, which is also ### Related Topics - [[Array](../../tag/array/README.md)] [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Similar Questions diff --git a/problems/next-greater-node-in-linked-list/README.md b/problems/next-greater-node-in-linked-list/README.md index ef5eff299..89037df98 100644 --- a/problems/next-greater-node-in-linked-list/README.md +++ b/problems/next-greater-node-in-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-prefix-divisible-by-5 "Binary Prefix Divisible By 5") diff --git a/problems/next-greater-numerically-balanced-number/README.md b/problems/next-greater-numerically-balanced-number/README.md index 4f7356902..338830ba3 100644 --- a/problems/next-greater-numerically-balanced-number/README.md +++ b/problems/next-greater-numerically-balanced-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-valid-words-in-a-sentence "Number of Valid Words in a Sentence") diff --git a/problems/next-palindrome-using-same-digits/README.md b/problems/next-palindrome-using-same-digits/README.md index 53bbc8357..5c062380d 100644 --- a/problems/next-palindrome-using-same-digits/README.md +++ b/problems/next-palindrome-using-same-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../league-statistics "League Statistics") diff --git a/problems/nim-game/README.md b/problems/nim-game/README.md index 777bf5b83..263994332 100644 --- a/problems/nim-game/README.md +++ b/problems/nim-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-pattern-ii "Word Pattern II") @@ -57,8 +57,8 @@ In all outcomes, your friend wins. ### Related Topics - [[Brainteaser](../../tag/brainteaser/README.md)] [[Math](../../tag/math/README.md)] + [[Brainteaser](../../tag/brainteaser/README.md)] [[Game Theory](../../tag/game-theory/README.md)] ### Similar Questions diff --git a/problems/non-negative-integers-without-consecutive-ones/README.md b/problems/non-negative-integers-without-consecutive-ones/README.md index 5d571fa2b..f91c56fd0 100644 --- a/problems/non-negative-integers-without-consecutive-ones/README.md +++ b/problems/non-negative-integers-without-consecutive-ones/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-index-sum-of-two-lists "Minimum Index Sum of Two Lists") diff --git a/problems/not-boring-movies/README.md b/problems/not-boring-movies/README.md index b778ac53b..98c86a8bc 100644 --- a/problems/not-boring-movies/README.md +++ b/problems/not-boring-movies/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../biggest-single-number "Biggest Single Number") diff --git a/problems/nth-digit/README.md b/problems/nth-digit/README.md index 2edcbf0c7..b2130eefe 100644 --- a/problems/nth-digit/README.md +++ b/problems/nth-digit/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../evaluate-division "Evaluate Division") diff --git a/problems/nth-magical-number/README.md b/problems/nth-magical-number/README.md index c7aaf6b59..841e0934d 100644 --- a/problems/nth-magical-number/README.md +++ b/problems/nth-magical-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game "Stone Game") diff --git a/problems/number-complement/README.md b/problems/number-complement/README.md index fab5c3486..63dd7a66c 100644 --- a/problems/number-complement/README.md +++ b/problems/number-complement/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../heaters "Heaters") diff --git a/problems/number-of-accounts-that-did-not-stream/README.md b/problems/number-of-accounts-that-did-not-stream/README.md index 6b45c40b6..d386e55a8 100644 --- a/problems/number-of-accounts-that-did-not-stream/README.md +++ b/problems/number-of-accounts-that-did-not-stream/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-score-of-students-solving-math-expression "The Score of Students Solving Math Expression") diff --git a/problems/number-of-boomerangs/README.md b/problems/number-of-boomerangs/README.md index 09da47c42..236720226 100644 --- a/problems/number-of-boomerangs/README.md +++ b/problems/number-of-boomerangs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../arithmetic-slices-ii-subsequence "Arithmetic Slices II - Subsequence") diff --git a/problems/number-of-calls-between-two-persons/README.md b/problems/number-of-calls-between-two-persons/README.md index 431f2c375..341c37f73 100644 --- a/problems/number-of-calls-between-two-persons/README.md +++ b/problems/number-of-calls-between-two-persons/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-distinct-substrings-in-a-string "Number of Distinct Substrings in a String") diff --git a/problems/number-of-closed-islands/README.md b/problems/number-of-closed-islands/README.md index 01c2cafea..1c2c4e1ee 100644 --- a/problems/number-of-closed-islands/README.md +++ b/problems/number-of-closed-islands/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reconstruct-a-2-row-binary-matrix "Reconstruct a 2-Row Binary Matrix") @@ -57,10 +57,10 @@ Islands in gray are closed because they are completely surrounded by water (grou ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/number-of-comments-per-post/README.md b/problems/number-of-comments-per-post/README.md index f1c436468..b190512bd 100644 --- a/problems/number-of-comments-per-post/README.md +++ b/problems/number-of-comments-per-post/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tiling-a-rectangle-with-the-fewest-squares "Tiling a Rectangle with the Fewest Squares") diff --git a/problems/number-of-days-between-two-dates/README.md b/problems/number-of-days-between-two-dates/README.md index ade5f0f63..6f1fd8d63 100644 --- a/problems/number-of-days-between-two-dates/README.md +++ b/problems/number-of-days-between-two-dates/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-all-valid-pickup-and-delivery-options "Count All Valid Pickup and Delivery Options") diff --git a/problems/number-of-days-in-a-month/README.md b/problems/number-of-days-in-a-month/README.md index 467a2fab1..217dbebec 100644 --- a/problems/number-of-days-in-a-month/README.md +++ b/problems/number-of-days-in-a-month/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../building-h2o "Building H2O") diff --git a/problems/number-of-dice-rolls-with-target-sum/README.md b/problems/number-of-dice-rolls-with-target-sum/README.md index 046d5f13e..8ef9457d8 100644 --- a/problems/number-of-dice-rolls-with-target-sum/README.md +++ b/problems/number-of-dice-rolls-with-target-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../day-of-the-year "Day of the Year") @@ -73,10 +73,6 @@ The answer must be returned modulo 10^9 + 7. ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] -### Similar Questions - 1. [Equal Sum Arrays With Minimum Number of Operations](../equal-sum-arrays-with-minimum-number-of-operations) (Medium) - 1. [Find Missing Observations](../find-missing-observations) (Medium) - ### Hints
    Hint 1 diff --git a/problems/number-of-different-integers-in-a-string/README.md b/problems/number-of-different-integers-in-a-string/README.md index ef92569f3..0da225fa1 100644 --- a/problems/number-of-different-integers-in-a-string/README.md +++ b/problems/number-of-different-integers-in-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../implement-trie-ii-prefix-tree "Implement Trie II (Prefix Tree)") diff --git a/problems/number-of-different-subsequences-gcds/README.md b/problems/number-of-different-subsequences-gcds/README.md index e2b2407fc..3665c4ac0 100644 --- a/problems/number-of-different-subsequences-gcds/README.md +++ b/problems/number-of-different-subsequences-gcds/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-absolute-sum-difference "Minimum Absolute Sum Difference") diff --git a/problems/number-of-distinct-substrings-in-a-string/README.md b/problems/number-of-distinct-substrings-in-a-string/README.md index ed9bc0d15..cbf499178 100644 --- a/problems/number-of-distinct-substrings-in-a-string/README.md +++ b/problems/number-of-distinct-substrings-in-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../checking-existence-of-edge-length-limited-paths "Checking Existence of Edge Length Limited Paths") diff --git a/problems/number-of-equal-count-substrings/README.md b/problems/number-of-equal-count-substrings/README.md index 66252ff68..1b65042c0 100644 --- a/problems/number-of-equal-count-substrings/README.md +++ b/problems/number-of-equal-count-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../account-balance "Account Balance") diff --git a/problems/number-of-equivalent-domino-pairs/README.md b/problems/number-of-equivalent-domino-pairs/README.md index 0b18a70ad..188b4d506 100644 --- a/problems/number-of-equivalent-domino-pairs/README.md +++ b/problems/number-of-equivalent-domino-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../user-purchase-platform "User Purchase Platform") diff --git a/problems/number-of-good-leaf-nodes-pairs/README.md b/problems/number-of-good-leaf-nodes-pairs/README.md index 36b330f20..b7b4d21c1 100644 --- a/problems/number-of-good-leaf-nodes-pairs/README.md +++ b/problems/number-of-good-leaf-nodes-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../bulb-switcher-iv "Bulb Switcher IV") diff --git a/problems/number-of-good-pairs/README.md b/problems/number-of-good-pairs/README.md index 13e548070..f7631e3ce 100644 --- a/problems/number-of-good-pairs/README.md +++ b/problems/number-of-good-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../customer-order-frequency "Customer Order Frequency") @@ -55,6 +55,7 @@ ### Similar Questions 1. [Number of Pairs of Interchangeable Rectangles](../number-of-pairs-of-interchangeable-rectangles) (Medium) + 1. [Substrings That Begin and End With the Same Letter](../substrings-that-begin-and-end-with-the-same-letter) (Medium) ### Hints
    diff --git a/problems/number-of-good-ways-to-split-a-string/README.md b/problems/number-of-good-ways-to-split-a-string/README.md index 3fe28aa73..93f58f1d9 100644 --- a/problems/number-of-good-ways-to-split-a-string/README.md +++ b/problems/number-of-good-ways-to-split-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-sub-arrays-with-odd-sum "Number of Sub-arrays With Odd Sum") diff --git a/problems/number-of-islands/README.md b/problems/number-of-islands/README.md index 4b45db33a..f0a9b1b79 100644 --- a/problems/number-of-islands/README.md +++ b/problems/number-of-islands/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-tree-right-side-view "Binary Tree Right Side View") diff --git a/problems/number-of-longest-increasing-subsequence/README.md b/problems/number-of-longest-increasing-subsequence/README.md index cb26b44e1..9baaae016 100644 --- a/problems/number-of-longest-increasing-subsequence/README.md +++ b/problems/number-of-longest-increasing-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../bulb-switcher-ii "Bulb Switcher II") diff --git a/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md b/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md index b689df9f5..633560907 100644 --- a/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md +++ b/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../water-bottles "Water Bottles") diff --git a/problems/number-of-orders-in-the-backlog/README.md b/problems/number-of-orders-in-the-backlog/README.md index 3a917b5d9..dcfcdfae9 100644 --- a/problems/number-of-orders-in-the-backlog/README.md +++ b/problems/number-of-orders-in-the-backlog/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-ascending-subarray-sum "Maximum Ascending Subarray Sum") diff --git a/problems/number-of-pairs-of-interchangeable-rectangles/README.md b/problems/number-of-pairs-of-interchangeable-rectangles/README.md index ec9f4bd47..c03ce8bca 100644 --- a/problems/number-of-pairs-of-interchangeable-rectangles/README.md +++ b/problems/number-of-pairs-of-interchangeable-rectangles/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-prefix-of-word "Reverse Prefix of Word") diff --git a/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target/README.md b/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target/README.md index 994bb5e99..07acd4a01 100644 --- a/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target/README.md +++ b/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-1d-array-into-2d-array "Convert 1D Array Into 2D Array") diff --git a/problems/number-of-paths-with-max-score/README.md b/problems/number-of-paths-with-max-score/README.md index b18be23d3..773e71630 100644 --- a/problems/number-of-paths-with-max-score/README.md +++ b/problems/number-of-paths-with-max-score/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-mutated-array-closest-to-target "Sum of Mutated Array Closest to Target") diff --git a/problems/number-of-recent-calls/README.md b/problems/number-of-recent-calls/README.md index 5725fbc5e..d961559a0 100644 --- a/problems/number-of-recent-calls/README.md +++ b/problems/number-of-recent-calls/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../beautiful-array "Beautiful Array") diff --git a/problems/number-of-rectangles-that-can-form-the-largest-square/README.md b/problems/number-of-rectangles-that-can-form-the-largest-square/README.md index f478cd3a1..4e1dbdfa1 100644 --- a/problems/number-of-rectangles-that-can-form-the-largest-square/README.md +++ b/problems/number-of-rectangles-that-can-form-the-largest-square/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../checking-existence-of-edge-length-limited-paths-ii "Checking Existence of Edge Length Limited Paths II") diff --git a/problems/number-of-restricted-paths-from-first-to-last-node/README.md b/problems/number-of-restricted-paths-from-first-to-last-node/README.md index decd9b210..991d1a7a2 100644 --- a/problems/number-of-restricted-paths-from-first-to-last-node/README.md +++ b/problems/number-of-restricted-paths-from-first-to-last-node/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-elements-to-add-to-form-a-given-sum "Minimum Elements to Add to Form a Given Sum") @@ -54,11 +54,11 @@ ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Shortest Path](../../tag/shortest-path/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md b/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md index 449b22cf6..693b07e4d 100644 --- a/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md +++ b/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../coordinate-with-maximum-network-quality "Coordinate With Maximum Network Quality") diff --git a/problems/number-of-ships-in-a-rectangle/README.md b/problems/number-of-ships-in-a-rectangle/README.md index 887639986..754422647 100644 --- a/problems/number-of-ships-in-a-rectangle/README.md +++ b/problems/number-of-ships-in-a-rectangle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-tree-nodes "Delete Tree Nodes") diff --git a/problems/number-of-spaces-cleaning-robot-cleaned/README.md b/problems/number-of-spaces-cleaning-robot-cleaned/README.md index 7773d1791..f9fed2877 100644 --- a/problems/number-of-spaces-cleaning-robot-cleaned/README.md +++ b/problems/number-of-spaces-cleaning-robot-cleaned/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-an-original-string-exists-given-two-encoded-strings "Check if an Original String Exists Given Two Encoded Strings") diff --git a/problems/number-of-squareful-arrays/README.md b/problems/number-of-squareful-arrays/README.md index 862424300..bfd6778ee 100644 --- a/problems/number-of-squareful-arrays/README.md +++ b/problems/number-of-squareful-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-k-consecutive-bit-flips "Minimum Number of K Consecutive Bit Flips") @@ -42,11 +42,11 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] ### Similar Questions diff --git a/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md b/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md index 02d544edb..089c252a9 100644 --- a/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md +++ b/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-subsequence-in-non-increasing-order "Minimum Subsequence in Non-Increasing Order") diff --git a/problems/number-of-steps-to-reduce-a-number-to-zero/README.md b/problems/number-of-steps-to-reduce-a-number-to-zero/README.md index ea8c7d76e..ac1dab90c 100644 --- a/problems/number-of-steps-to-reduce-a-number-to-zero/README.md +++ b/problems/number-of-steps-to-reduce-a-number-to-zero/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../movie-rating "Movie Rating") @@ -57,8 +57,8 @@ Step 4) 1 is odd; subtract 1 and obtain 0. ### Related Topics - [[Math](../../tag/math/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Math](../../tag/math/README.md)] ### Hints
    diff --git a/problems/number-of-strings-that-appear-as-substrings-in-word/README.md b/problems/number-of-strings-that-appear-as-substrings-in-word/README.md index 9715e0190..f5aec31f7 100644 --- a/problems/number-of-strings-that-appear-as-substrings-in-word/README.md +++ b/problems/number-of-strings-that-appear-as-substrings-in-word/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-searchable-numbers-in-an-unsorted-array "Binary Searchable Numbers in an Unsorted Array") diff --git a/problems/number-of-students-unable-to-eat-lunch/README.md b/problems/number-of-students-unable-to-eat-lunch/README.md index bf8575ed0..0251d8e4b 100644 --- a/problems/number-of-students-unable-to-eat-lunch/README.md +++ b/problems/number-of-students-unable-to-eat-lunch/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-calls-between-two-persons "Number of Calls Between Two Persons") @@ -60,14 +60,11 @@ Hence all students are able to eat. ### Related Topics - [[Array](../../tag/array/README.md)] [[Stack](../../tag/stack/README.md)] [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] [[Simulation](../../tag/simulation/README.md)] -### Similar Questions - 1. [Time Needed to Buy Tickets](../time-needed-to-buy-tickets) (Easy) - ### Hints
    Hint 1 diff --git a/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md b/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md index 0f6665efe..4eead3055 100644 --- a/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md +++ b/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-steps-to-reduce-a-number-to-zero "Number of Steps to Reduce a Number to Zero") diff --git a/problems/number-of-sub-arrays-with-odd-sum/README.md b/problems/number-of-sub-arrays-with-odd-sum/README.md index 71d637e99..cbb19a8a7 100644 --- a/problems/number-of-sub-arrays-with-odd-sum/README.md +++ b/problems/number-of-sub-arrays-with-odd-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-odd-numbers-in-an-interval-range "Count Odd Numbers in an Interval Range") diff --git a/problems/number-of-subarrays-with-bounded-maximum/README.md b/problems/number-of-subarrays-with-bounded-maximum/README.md index 24d460568..80823a666 100644 --- a/problems/number-of-subarrays-with-bounded-maximum/README.md +++ b/problems/number-of-subarrays-with-bounded-maximum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-tic-tac-toe-state "Valid Tic-Tac-Toe State") diff --git a/problems/number-of-substrings-with-only-1s/README.md b/problems/number-of-substrings-with-only-1s/README.md index 3d3b4c739..ac9643cdb 100644 --- a/problems/number-of-substrings-with-only-1s/README.md +++ b/problems/number-of-substrings-with-only-1s/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-good-pairs "Number of Good Pairs") @@ -59,10 +59,6 @@ [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] -### Similar Questions - 1. [Count Number of Homogenous Substrings](../count-number-of-homogenous-substrings) (Medium) - 1. [Count Vowel Substrings of a String](../count-vowel-substrings-of-a-string) (Easy) - ### Hints
    Hint 1 diff --git a/problems/number-of-transactions-per-visit/README.md b/problems/number-of-transactions-per-visit/README.md index 8c57e66d2..423f88ca9 100644 --- a/problems/number-of-transactions-per-visit/README.md +++ b/problems/number-of-transactions-per-visit/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-difficulty-of-a-job-schedule "Minimum Difficulty of a Job Schedule") diff --git a/problems/number-of-trusted-contacts-of-a-customer/README.md b/problems/number-of-trusted-contacts-of-a-customer/README.md index 301d149f1..fc43743ce 100644 --- a/problems/number-of-trusted-contacts-of-a-customer/README.md +++ b/problems/number-of-trusted-contacts-of-a-customer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-multiple-of-three "Largest Multiple of Three") diff --git a/problems/number-of-unique-good-subsequences/README.md b/problems/number-of-unique-good-subsequences/README.md index a0aa82c51..7a678c170 100644 --- a/problems/number-of-unique-good-subsequences/README.md +++ b/problems/number-of-unique-good-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-work-sessions-to-finish-the-tasks "Minimum Number of Work Sessions to Finish the Tasks") diff --git a/problems/number-of-valid-move-combinations-on-chessboard/README.md b/problems/number-of-valid-move-combinations-on-chessboard/README.md index f4e33082d..dfb94f7e2 100644 --- a/problems/number-of-valid-move-combinations-on-chessboard/README.md +++ b/problems/number-of-valid-move-combinations-on-chessboard/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../plates-between-candles "Plates Between Candles") diff --git a/problems/number-of-valid-words-in-a-sentence/README.md b/problems/number-of-valid-words-in-a-sentence/README.md index 9a884bf5c..624517eb4 100644 --- a/problems/number-of-valid-words-in-a-sentence/README.md +++ b/problems/number-of-valid-words-in-a-sentence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-linked-list-already-sorted-using-absolute-values "Sort Linked List Already Sorted Using Absolute Values") diff --git a/problems/number-of-visible-people-in-a-queue/README.md b/problems/number-of-visible-people-in-a-queue/README.md index 03512d8cf..0cf9c4819 100644 --- a/problems/number-of-visible-people-in-a-queue/README.md +++ b/problems/number-of-visible-people-in-a-queue/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../describe-the-painting "Describe the Painting") diff --git a/problems/number-of-ways-of-cutting-a-pizza/README.md b/problems/number-of-ways-of-cutting-a-pizza/README.md index 7b9e1d165..67d6c62c9 100644 --- a/problems/number-of-ways-of-cutting-a-pizza/README.md +++ b/problems/number-of-ways-of-cutting-a-pizza/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-time-to-collect-all-apples-in-a-tree "Minimum Time to Collect All Apples in a Tree") @@ -54,9 +54,9 @@ ### Related Topics + [[Memoization](../../tag/memoization/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Memoization](../../tag/memoization/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/number-of-ways-to-arrive-at-destination/README.md b/problems/number-of-ways-to-arrive-at-destination/README.md index 0c6c974cf..84295ec95 100644 --- a/problems/number-of-ways-to-arrive-at-destination/README.md +++ b/problems/number-of-ways-to-arrive-at-destination/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-matrix-sum "Maximum Matrix Sum") diff --git a/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md b/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md index 10c784b2b..209ae1f48 100644 --- a/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md +++ b/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-substrings-that-differ-by-one-character "Count Substrings That Differ by One Character") diff --git a/problems/number-of-ways-to-paint-n-3-grid/README.md b/problems/number-of-ways-to-paint-n-3-grid/README.md index 0db030cab..5b1198fdb 100644 --- a/problems/number-of-ways-to-paint-n-3-grid/README.md +++ b/problems/number-of-ways-to-paint-n-3-grid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../html-entity-parser "HTML Entity Parser") diff --git a/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible/README.md b/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible/README.md index 4baf6cb24..d107b5fdd 100644 --- a/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible/README.md +++ b/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../finding-pairs-with-a-certain-sum "Finding Pairs With a Certain Sum") diff --git a/problems/number-of-ways-to-reconstruct-a-tree/README.md b/problems/number-of-ways-to-reconstruct-a-tree/README.md index 6596cef38..11533af4f 100644 --- a/problems/number-of-ways-to-reconstruct-a-tree/README.md +++ b/problems/number-of-ways-to-reconstruct-a-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-the-lexicographically-largest-valid-sequence "Construct the Lexicographically Largest Valid Sequence") diff --git a/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md b/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md index b6ad2d6f1..b6a36b36a 100644 --- a/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md +++ b/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-days-to-disconnect-island "Minimum Number of Days to Disconnect Island") diff --git a/problems/number-of-ways-to-separate-numbers/README.md b/problems/number-of-ways-to-separate-numbers/README.md index 350a57bf5..f305dec5b 100644 --- a/problems/number-of-ways-to-separate-numbers/README.md +++ b/problems/number-of-ways-to-separate-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-arrive-at-destination "Number of Ways to Arrive at Destination") diff --git a/problems/number-of-ways-to-split-a-string/README.md b/problems/number-of-ways-to-split-a-string/README.md index 5d6b30520..cfdbf11da 100644 --- a/problems/number-of-ways-to-split-a-string/README.md +++ b/problems/number-of-ways-to-split-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../matrix-diagonal-sum "Matrix Diagonal Sum") diff --git a/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/README.md b/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/README.md index 2c012417f..5dfd4cae6 100644 --- a/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/README.md +++ b/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../search-suggestions-system "Search Suggestions System") diff --git a/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md b/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md index 5a33eb775..4a9a83b5e 100644 --- a/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md +++ b/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../replace-all-s-to-avoid-consecutive-repeating-characters "Replace All ?'s to Avoid Consecutive Repeating Characters") diff --git a/problems/number-of-wonderful-substrings/README.md b/problems/number-of-wonderful-substrings/README.md index ec22793d8..0c236f651 100644 --- a/problems/number-of-wonderful-substrings/README.md +++ b/problems/number-of-wonderful-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cyclically-rotating-a-grid "Cyclically Rotating a Grid") diff --git a/problems/numbers-with-same-consecutive-differences/README.md b/problems/numbers-with-same-consecutive-differences/README.md index 0b47b74d0..b13d65569 100644 --- a/problems/numbers-with-same-consecutive-differences/README.md +++ b/problems/numbers-with-same-consecutive-differences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../vowel-spellchecker "Vowel Spellchecker") diff --git a/problems/odd-even-linked-list/README.md b/problems/odd-even-linked-list/README.md index ddd2c354e..febedeac1 100644 --- a/problems/odd-even-linked-list/README.md +++ b/problems/odd-even-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-of-range-sum "Count of Range Sum") diff --git a/problems/one-edit-distance/README.md b/problems/one-edit-distance/README.md index 8dff8f8f8..abc01c622 100644 --- a/problems/one-edit-distance/README.md +++ b/problems/one-edit-distance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../intersection-of-two-linked-lists "Intersection of Two Linked Lists") diff --git a/problems/online-majority-element-in-subarray/README.md b/problems/online-majority-element-in-subarray/README.md index bd81dbbcf..5dd0844bb 100644 --- a/problems/online-majority-element-in-subarray/README.md +++ b/problems/online-majority-element-in-subarray/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../swap-for-longest-repeated-character-substring "Swap For Longest Repeated Character Substring") diff --git a/problems/online-stock-span/README.md b/problems/online-stock-span/README.md index dd85693dc..169db46d1 100644 --- a/problems/online-stock-span/README.md +++ b/problems/online-stock-span/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rle-iterator "RLE Iterator") diff --git a/problems/operations-on-tree/README.md b/problems/operations-on-tree/README.md index 500941e2a..e249614a9 100644 --- a/problems/operations-on-tree/README.md +++ b/problems/operations-on-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-all-groups-of-farmland "Find All Groups of Farmland") diff --git a/problems/optimal-division/README.md b/problems/optimal-division/README.md index 7b4611e58..b24028aef 100644 --- a/problems/optimal-division/README.md +++ b/problems/optimal-division/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../student-attendance-record-ii "Student Attendance Record II") diff --git a/problems/optimize-water-distribution-in-a-village/README.md b/problems/optimize-water-distribution-in-a-village/README.md index f946b9978..29b3a78bd 100644 --- a/problems/optimize-water-distribution-in-a-village/README.md +++ b/problems/optimize-water-distribution-in-a-village/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-connect-sticks "Minimum Cost to Connect Sticks") diff --git a/problems/orders-with-maximum-quantity-above-average/README.md b/problems/orders-with-maximum-quantity-above-average/README.md index fcef76c7e..063bde62f 100644 --- a/problems/orders-with-maximum-quantity-above-average/README.md +++ b/problems/orders-with-maximum-quantity-above-average/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-rearrange-sticks-with-k-sticks-visible "Number of Ways to Rearrange Sticks With K Sticks Visible") diff --git a/problems/out-of-boundary-paths/README.md b/problems/out-of-boundary-paths/README.md index 72d8d9cc6..d870983f9 100644 --- a/problems/out-of-boundary-paths/README.md +++ b/problems/out-of-boundary-paths/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../distribute-candies "Distribute Candies") diff --git a/problems/output-contest-matches/README.md b/problems/output-contest-matches/README.md index a0e9342e8..d2ed16eb9 100644 --- a/problems/output-contest-matches/README.md +++ b/problems/output-contest-matches/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../diameter-of-binary-tree "Diameter of Binary Tree") @@ -56,6 +56,6 @@ Since the third round will generate the final winner, you need to output the ans

    ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[String](../../tag/string/README.md)] + [[Recursion](../../tag/recursion/README.md)] [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/pacific-atlantic-water-flow/README.md b/problems/pacific-atlantic-water-flow/README.md index 207dcce39..7e8c05bc0 100644 --- a/problems/pacific-atlantic-water-flow/README.md +++ b/problems/pacific-atlantic-water-flow/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../partition-equal-subset-sum "Partition Equal Subset Sum") @@ -45,7 +45,7 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/page-recommendations-ii/README.md b/problems/page-recommendations-ii/README.md index 42de505c3..3e21532ec 100644 --- a/problems/page-recommendations-ii/README.md +++ b/problems/page-recommendations-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cutting-ribbons "Cutting Ribbons") diff --git a/problems/page-recommendations/README.md b/problems/page-recommendations/README.md index b4d9206b7..3faa1073c 100644 --- a/problems/page-recommendations/README.md +++ b/problems/page-recommendations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-moves-to-move-a-box-to-their-target-location "Minimum Moves to Move a Box to Their Target Location") diff --git a/problems/paint-house-ii/README.md b/problems/paint-house-ii/README.md index 5b98e6c02..79c853a1c 100644 --- a/problems/paint-house-ii/README.md +++ b/problems/paint-house-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../ugly-number-ii "Ugly Number II") diff --git a/problems/paint-house/README.md b/problems/paint-house/README.md index e1249385d..4c8b8ad64 100644 --- a/problems/paint-house/README.md +++ b/problems/paint-house/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../verify-preorder-sequence-in-binary-search-tree "Verify Preorder Sequence in Binary Search Tree") diff --git a/problems/painting-a-grid-with-three-different-colors/README.md b/problems/painting-a-grid-with-three-different-colors/README.md index ad44f8278..381805838 100644 --- a/problems/painting-a-grid-with-three-different-colors/README.md +++ b/problems/painting-a-grid-with-three-different-colors/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../unique-length-3-palindromic-subsequences "Unique Length-3 Palindromic Subsequences") diff --git a/problems/palindrome-pairs/README.md b/problems/palindrome-pairs/README.md index 797531cba..7c370230a 100644 --- a/problems/palindrome-pairs/README.md +++ b/problems/palindrome-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../self-crossing "Self Crossing") @@ -47,10 +47,10 @@ ### Related Topics - [[Trie](../../tag/trie/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Trie](../../tag/trie/README.md)] ### Similar Questions 1. [Longest Palindromic Substring](../longest-palindromic-substring) (Medium) diff --git a/problems/palindrome-partitioning-iii/README.md b/problems/palindrome-partitioning-iii/README.md index 9838d87d8..b54eb04ff 100644 --- a/problems/palindrome-partitioning-iii/README.md +++ b/problems/palindrome-partitioning-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-square-submatrices-with-all-ones "Count Square Submatrices with All Ones") @@ -55,9 +55,6 @@ [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] -### Similar Questions - 1. [Palindrome Partitioning IV](../palindrome-partitioning-iv) (Hard) - ### Hints
    Hint 1 diff --git a/problems/palindrome-partitioning-iv/README.md b/problems/palindrome-partitioning-iv/README.md index e5baddac7..360b484e8 100644 --- a/problems/palindrome-partitioning-iv/README.md +++ b/problems/palindrome-partitioning-iv/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../can-you-eat-your-favorite-candy-on-your-favorite-day "Can You Eat Your Favorite Candy on Your Favorite Day?") diff --git a/problems/palindrome-permutation/README.md b/problems/palindrome-permutation/README.md index 18ecea9e5..26442c494 100644 --- a/problems/palindrome-permutation/README.md +++ b/problems/palindrome-permutation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../paint-house-ii "Paint House II") @@ -29,9 +29,9 @@ Output: true ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Longest Palindromic Substring](../longest-palindromic-substring) (Medium) diff --git a/problems/palindromic-substrings/README.md b/problems/palindromic-substrings/README.md index 7d549d549..878a0a02e 100644 --- a/problems/palindromic-substrings/README.md +++ b/problems/palindromic-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-length-of-pair-chain "Maximum Length of Pair Chain") diff --git a/problems/parallel-courses-iii/README.md b/problems/parallel-courses-iii/README.md index cfb2028ca..ca6fddca5 100644 --- a/problems/parallel-courses-iii/README.md +++ b/problems/parallel-courses-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-nodes-with-the-highest-score "Count Nodes With the Highest Score") diff --git a/problems/parallel-courses/README.md b/problems/parallel-courses/README.md index 98fde90aa..ce0d249ab 100644 --- a/problems/parallel-courses/README.md +++ b/problems/parallel-courses/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../connecting-cities-with-minimum-cost "Connecting Cities With Minimum Cost") diff --git a/problems/parsing-a-boolean-expression/README.md b/problems/parsing-a-boolean-expression/README.md index 540f3d48f..9ab927c3f 100644 --- a/problems/parsing-a-boolean-expression/README.md +++ b/problems/parsing-a-boolean-expression/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../filling-bookcase-shelves "Filling Bookcase Shelves") @@ -62,9 +62,9 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Recursion](../../tag/recursion/README.md)] - [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/partition-array-into-disjoint-intervals/README.md b/problems/partition-array-into-disjoint-intervals/README.md index 38534622d..5a1693ed6 100644 --- a/problems/partition-array-into-disjoint-intervals/README.md +++ b/problems/partition-array-into-disjoint-intervals/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../x-of-a-kind-in-a-deck-of-cards "X of a Kind in a Deck of Cards") @@ -51,3 +51,6 @@ ### Related Topics [[Array](../../tag/array/README.md)] + +### Similar Questions + 1. [Sum of Beauty in the Array](../sum-of-beauty-in-the-array) (Medium) diff --git a/problems/partition-array-into-three-parts-with-equal-sum/README.md b/problems/partition-array-into-three-parts-with-equal-sum/README.md index 9a728e44c..2acd962bb 100644 --- a/problems/partition-array-into-three-parts-with-equal-sum/README.md +++ b/problems/partition-array-into-three-parts-with-equal-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../numbers-with-repeated-digits "Numbers With Repeated Digits") diff --git a/problems/partition-array-into-two-arrays-to-minimize-sum-difference/README.md b/problems/partition-array-into-two-arrays-to-minimize-sum-difference/README.md index 9eb4c208e..2869b4b0e 100644 --- a/problems/partition-array-into-two-arrays-to-minimize-sum-difference/README.md +++ b/problems/partition-array-into-two-arrays-to-minimize-sum-difference/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stock-price-fluctuation "Stock Price Fluctuation ") diff --git a/problems/partitioning-into-minimum-number-of-deci-binary-numbers/README.md b/problems/partitioning-into-minimum-number-of-deci-binary-numbers/README.md index 382809959..3b62f1968 100644 --- a/problems/partitioning-into-minimum-number-of-deci-binary-numbers/README.md +++ b/problems/partitioning-into-minimum-number-of-deci-binary-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-of-matches-in-tournament "Count of Matches in Tournament") @@ -48,8 +48,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/pascals-triangle/README.md b/problems/pascals-triangle/README.md index bab942839..26b59095c 100644 --- a/problems/pascals-triangle/README.md +++ b/problems/pascals-triangle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../populating-next-right-pointers-in-each-node-ii "Populating Next Right Pointers in Each Node II") diff --git a/problems/path-crossing/README.md b/problems/path-crossing/README.md index 7ad9cf22a..5c59e8448 100644 --- a/problems/path-crossing/README.md +++ b/problems/path-crossing/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../friendly-movies-streamed-last-month "Friendly Movies Streamed Last Month") diff --git a/problems/path-in-zigzag-labelled-binary-tree/README.md b/problems/path-in-zigzag-labelled-binary-tree/README.md index 30164fa54..32eb5c01b 100644 --- a/problems/path-in-zigzag-labelled-binary-tree/README.md +++ b/problems/path-in-zigzag-labelled-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../distribute-candies-to-people "Distribute Candies to People") @@ -42,8 +42,8 @@ ### Related Topics - [[Tree](../../tag/tree/README.md)] [[Math](../../tag/math/README.md)] + [[Tree](../../tag/tree/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/path-sum-iv/README.md b/problems/path-sum-iv/README.md index a1d262920..d0052c494 100644 --- a/problems/path-sum-iv/README.md +++ b/problems/path-sum-iv/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../non-decreasing-array "Non-decreasing Array") @@ -56,9 +56,9 @@ The path sum is (3 + 1) = 4.

     

    ### Related Topics + [[Array](../../tag/array/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[Array](../../tag/array/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/path-with-maximum-gold/README.md b/problems/path-with-maximum-gold/README.md index b21af4df4..7b86e75cc 100644 --- a/problems/path-with-maximum-gold/README.md +++ b/problems/path-with-maximum-gold/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-arithmetic-subsequence-of-given-difference "Longest Arithmetic Subsequence of Given Difference") diff --git a/problems/path-with-maximum-minimum-value/README.md b/problems/path-with-maximum-minimum-value/README.md index ff4461a28..023f25b3f 100644 --- a/problems/path-with-maximum-minimum-value/README.md +++ b/problems/path-with-maximum-minimum-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-earliest-moment-when-everyone-become-friends "The Earliest Moment When Everyone Become Friends") @@ -56,15 +56,12 @@ The path with the maximum score is highlighted in yellow. ### Related Topics - [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] - -### Similar Questions - 1. [Path With Minimum Effort](../path-with-minimum-effort) (Medium) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/path-with-maximum-probability/README.md b/problems/path-with-maximum-probability/README.md index ba83dc8d4..8a74476a7 100644 --- a/problems/path-with-maximum-probability/README.md +++ b/problems/path-with-maximum-probability/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-substrings-with-only-1s "Number of Substrings With Only 1s") @@ -63,8 +63,11 @@ ### Related Topics [[Graph](../../tag/graph/README.md)] - [[Shortest Path](../../tag/shortest-path/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] + +### Similar Questions + 1. [Number of Ways to Arrive at Destination](../number-of-ways-to-arrive-at-destination) (Medium) ### Hints
    diff --git a/problems/path-with-minimum-effort/README.md b/problems/path-with-minimum-effort/README.md index 87fb8141a..b964c1049 100644 --- a/problems/path-with-minimum-effort/README.md +++ b/problems/path-with-minimum-effort/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../arithmetic-subarrays "Arithmetic Subarrays") diff --git a/problems/paths-in-maze-that-lead-to-same-room/README.md b/problems/paths-in-maze-that-lead-to-same-room/README.md new file mode 100644 index 000000000..40ea18453 --- /dev/null +++ b/problems/paths-in-maze-that-lead-to-same-room/README.md @@ -0,0 +1,28 @@ + + + + + + + +[< Previous](../process-restricted-friend-requests "Process Restricted Friend Requests") +                 +[Next >](../two-furthest-houses-with-different-colors "Two Furthest Houses With Different Colors") + +## [2077. Paths in Maze That Lead to Same Room (Medium)](https://leetcode.com/problems/paths-in-maze-that-lead-to-same-room "") + + + +### Related Topics + [[Graph](../../tag/graph/README.md)] + +### Hints +
    +Hint 1 +If the path starts at room i, what properties must the other two rooms in the cycle have? +
    + +
    +Hint 2 +The other two rooms must be connected to room i, and must be connected to each other. +
    diff --git a/problems/patients-with-a-condition/README.md b/problems/patients-with-a-condition/README.md index 12471e948..27a1f5cd3 100644 --- a/problems/patients-with-a-condition/README.md +++ b/problems/patients-with-a-condition/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-increments-on-subarrays-to-form-a-target-array "Minimum Number of Increments on Subarrays to Form a Target Array") diff --git a/problems/peeking-iterator/README.md b/problems/peeking-iterator/README.md index 760699b87..c922a69d3 100644 --- a/problems/peeking-iterator/README.md +++ b/problems/peeking-iterator/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../move-zeroes "Move Zeroes") @@ -11,17 +11,19 @@ ## [284. Peeking Iterator (Medium)](https://leetcode.com/problems/peeking-iterator "窥探迭代器") -

    Design an iterator that supports the peek operation on a list in addition to the hasNext and the next operations.

    +

    Design an iterator that supports the peek operation on an existing iterator in addition to the hasNext and the next operations.

    Implement the PeekingIterator class:

      -
    • PeekingIterator(int[] nums) Initializes the object with the given integer array nums.
    • +
    • PeekingIterator(Iterator<int> nums) Initializes the object with the given integer iterator iterator.
    • int next() Returns the next element in the array and moves the pointer to the next element.
    • -
    • bool hasNext() Returns true if there are still elements in the array.
    • +
    • boolean hasNext() Returns true if there are still elements in the array.
    • int peek() Returns the next element in the array without moving the pointer.
    +

    Note: Each language may have a different implementation of the constructor and Iterator, but they all support the int next() and boolean hasNext() functions.

    +

     

    Example 1:

    @@ -55,8 +57,8 @@ peekingIterator.hasNext(); // return False Follow up: How would you extend your design to be generic and work with all types, not just integer? ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] + [[Design](../../tag/design/README.md)] [[Iterator](../../tag/iterator/README.md)] ### Similar Questions diff --git a/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md b/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md index 86fdbf260..7c32ea78e 100644 --- a/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md +++ b/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rearrange-words-in-a-sentence "Rearrange Words in a Sentence") diff --git a/problems/percentage-of-users-attended-a-contest/README.md b/problems/percentage-of-users-attended-a-contest/README.md index 9afe97740..7773dffab 100644 --- a/problems/percentage-of-users-attended-a-contest/README.md +++ b/problems/percentage-of-users-attended-a-contest/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rank-transform-of-a-matrix "Rank Transform of a Matrix") @@ -15,6 +15,3 @@ ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Queries Quality and Percentage](../queries-quality-and-percentage) (Easy) diff --git a/problems/perfect-rectangle/README.md b/problems/perfect-rectangle/README.md index 7967cfa49..8949f5f14 100644 --- a/problems/perfect-rectangle/README.md +++ b/problems/perfect-rectangle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../elimination-game "Elimination Game") diff --git a/problems/perfect-squares/README.md b/problems/perfect-squares/README.md index f7a0cdd4b..75653ae8d 100644 --- a/problems/perfect-squares/README.md +++ b/problems/perfect-squares/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../first-bad-version "First Bad Version") diff --git a/problems/perform-string-shifts/README.md b/problems/perform-string-shifts/README.md index 87f73a5e4..b9c87caf9 100644 --- a/problems/perform-string-shifts/README.md +++ b/problems/perform-string-shifts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../counting-elements "Counting Elements") diff --git a/problems/permutation-in-string/README.md b/problems/permutation-in-string/README.md index a928de1f4..04f2c828a 100644 --- a/problems/permutation-in-string/README.md +++ b/problems/permutation-in-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reshape-the-matrix "Reshape the Matrix") diff --git a/problems/permutations-ii/README.md b/problems/permutations-ii/README.md index e4d819dcf..ec4163911 100644 --- a/problems/permutations-ii/README.md +++ b/problems/permutations-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../permutations "Permutations") diff --git a/problems/plates-between-candles/README.md b/problems/plates-between-candles/README.md index 1c6f57624..ae2f893fb 100644 --- a/problems/plates-between-candles/README.md +++ b/problems/plates-between-candles/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-best-non-overlapping-events "Two Best Non-Overlapping Events") diff --git a/problems/power-of-four/README.md b/problems/power-of-four/README.md index 715bce265..925cd1c2b 100644 --- a/problems/power-of-four/README.md +++ b/problems/power-of-four/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flatten-nested-list-iterator "Flatten Nested List Iterator") @@ -37,9 +37,9 @@ Follow up: Could you solve it without loops/recursion? ### Related Topics - [[Math](../../tag/math/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Recursion](../../tag/recursion/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Power of Two](../power-of-two) (Easy) diff --git a/problems/power-of-two/README.md b/problems/power-of-two/README.md index ad4c61126..8967dc809 100644 --- a/problems/power-of-two/README.md +++ b/problems/power-of-two/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-smallest-element-in-a-bst "Kth Smallest Element in a BST") @@ -64,9 +64,9 @@ Follow up: Could you solve it without loops/recursion? ### Related Topics - [[Math](../../tag/math/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Recursion](../../tag/recursion/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Number of 1 Bits](../number-of-1-bits) (Easy) diff --git a/problems/powx-n/README.md b/problems/powx-n/README.md index 8e1765ef7..b16dbab50 100644 --- a/problems/powx-n/README.md +++ b/problems/powx-n/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../group-anagrams "Group Anagrams") @@ -46,8 +46,8 @@ ### Related Topics - [[Math](../../tag/math/README.md)] [[Recursion](../../tag/recursion/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Sqrt(x)](../sqrtx) (Easy) diff --git a/problems/previous-permutation-with-one-swap/README.md b/problems/previous-permutation-with-one-swap/README.md index 1f1162653..34691ac25 100644 --- a/problems/previous-permutation-with-one-swap/README.md +++ b/problems/previous-permutation-with-one-swap/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../grumpy-bookstore-owner "Grumpy Bookstore Owner") diff --git a/problems/primary-department-for-each-employee/README.md b/problems/primary-department-for-each-employee/README.md index 0d304e075..cbceac426 100644 --- a/problems/primary-department-for-each-employee/README.md +++ b/problems/primary-department-for-each-employee/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximize-the-beauty-of-the-garden "Maximize the Beauty of the Garden") diff --git a/problems/print-binary-tree/README.md b/problems/print-binary-tree/README.md index 76ac13314..1cc4050d4 100644 --- a/problems/print-binary-tree/README.md +++ b/problems/print-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-binary-tree "Maximum Binary Tree") diff --git a/problems/print-immutable-linked-list-in-reverse/README.md b/problems/print-immutable-linked-list-in-reverse/README.md index dce74d494..28cd9038f 100644 --- a/problems/print-immutable-linked-list-in-reverse/README.md +++ b/problems/print-immutable-linked-list-in-reverse/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../page-recommendations "Page Recommendations") @@ -51,7 +51,7 @@ Constraints: - The value of each node in the linked list is between [-1000, 1000]. ### Related Topics - [[Stack](../../tag/stack/README.md)] - [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Stack](../../tag/stack/README.md)] + [[Recursion](../../tag/recursion/README.md)] diff --git a/problems/print-words-vertically/README.md b/problems/print-words-vertically/README.md index 9a5204cdf..76e308fc7 100644 --- a/problems/print-words-vertically/README.md +++ b/problems/print-words-vertically/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-69-number "Maximum 69 Number") diff --git a/problems/print-zero-even-odd/README.md b/problems/print-zero-even-odd/README.md index 69bd1ec94..e053c905b 100644 --- a/problems/print-zero-even-odd/README.md +++ b/problems/print-zero-even-odd/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../print-foobar-alternately "Print FooBar Alternately") diff --git a/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md b/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md index fd3525ed7..40e16a1df 100644 --- a/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md +++ b/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reorder-routes-to-make-all-paths-lead-to-the-city-zero "Reorder Routes to Make All Paths Lead to the City Zero") @@ -11,13 +11,13 @@ ## [1467. Probability of a Two Boxes Having The Same Number of Distinct Balls (Hard)](https://leetcode.com/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "两个盒子中球的颜色数相同的概率") -

    Given 2n balls of k distinct colors. You will be given an integer array balls of size k where balls[i] is the number of balls of color i

    +

    Given 2n balls of k distinct colors. You will be given an integer array balls of size k where balls[i] is the number of balls of color i.

    -

    All the balls will be shuffled uniformly at random, then we will distribute the first n balls to the first box and the remaining n balls to the other box (Please read the explanation of the second example carefully).

    +

    All the balls will be shuffled uniformly at random, then we will distribute the first n balls to the first box and the remaining n balls to the other box (Please read the explanation of the second example carefully).

    -

    Please note that the two boxes are considered different. For example, if we have two balls of colors a and b, and two boxes [] and (), then the distribution [a] (b) is considered different than the distribution [b] (a) (Please read the explanation of the first example carefully).

    +

    Please note that the two boxes are considered different. For example, if we have two balls of colors a and b, and two boxes [] and (), then the distribution [a] (b) is considered different than the distribution [b] (a) (Please read the explanation of the first example carefully).

    -

    We want to calculate the probability that the two boxes have the same number of distinct balls.

    +

    Return the probability that the two boxes have the same number of distinct balls. Answers within 10-5 of the actual value will be accepted as correct.

     

    Example 1:

    @@ -37,9 +37,9 @@ In both ways, the number of distinct colors in each box is equal. The probabilit Input: balls = [2,1,1] Output: 0.66667 Explanation: We have the set of balls [1, 1, 2, 3] -This set of balls will be shuffled randomly and we may have one of the 12 distinct shuffles with equale probability (i.e. 1/12): +This set of balls will be shuffled randomly and we may have one of the 12 distinct shuffles with equal probability (i.e. 1/12): [1,1 / 2,3], [1,1 / 3,2], [1,2 / 1,3], [1,2 / 3,1], [1,3 / 1,2], [1,3 / 2,1], [2,1 / 1,3], [2,1 / 3,1], [2,3 / 1,1], [3,1 / 1,2], [3,1 / 2,1], [3,2 / 1,1] -After that we add the first two balls to the first box and the second two balls to the second box. +After that, we add the first two balls to the first box and the second two balls to the second box. We can see that 8 of these 12 possible random distributions have the same number of distinct colors of balls in each box. Probability is 8/12 = 0.66667 @@ -76,7 +76,6 @@ Probability = 18 / 60 = 0.3
  • 1 <= balls.length <= 8
  • 1 <= balls[i] <= 6
  • sum(balls) is even.
  • -
  • Answers within 10^-5 of the actual value will be accepted as correct.
  • ### Related Topics diff --git a/problems/process-restricted-friend-requests/README.md b/problems/process-restricted-friend-requests/README.md index d2d91d28e..cd6c67d9f 100644 --- a/problems/process-restricted-friend-requests/README.md +++ b/problems/process-restricted-friend-requests/README.md @@ -1,13 +1,13 @@ - - - + + + [< Previous](../decode-the-slanted-ciphertext "Decode the Slanted Ciphertext")                  -Next > +[Next >](../paths-in-maze-that-lead-to-same-room "Paths in Maze That Lead to Same Room") ## [2076. Process Restricted Friend Requests (Hard)](https://leetcode.com/problems/process-restricted-friend-requests "处理含限制条件的好友请求") @@ -71,6 +71,10 @@ Request 3: Person 3 and person 4 cannot be friends since person 0 and person 1 w
  • uj != vj
  • +### Related Topics + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] + ### Hints
    Hint 1 diff --git a/problems/process-tasks-using-servers/README.md b/problems/process-tasks-using-servers/README.md index 5bd75a390..d2523efe7 100644 --- a/problems/process-tasks-using-servers/README.md +++ b/problems/process-tasks-using-servers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-value-after-insertion "Maximum Value after Insertion") diff --git a/problems/product-of-the-last-k-numbers/README.md b/problems/product-of-the-last-k-numbers/README.md index 045f7f54c..f09bf9ba2 100644 --- a/problems/product-of-the-last-k-numbers/README.md +++ b/problems/product-of-the-last-k-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-negative-numbers-in-a-sorted-matrix "Count Negative Numbers in a Sorted Matrix") @@ -59,10 +59,10 @@ productOfNumbers.getProduct(2); // return 32. The product of the last 2 numbers ### Related Topics - [[Array](../../tag/array/README.md)] - [[Math](../../tag/math/README.md)] [[Design](../../tag/design/README.md)] [[Queue](../../tag/queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] [[Data Stream](../../tag/data-stream/README.md)] ### Hints diff --git a/problems/product-of-two-run-length-encoded-arrays/README.md b/problems/product-of-two-run-length-encoded-arrays/README.md index 9968ca9dd..60b12f2ad 100644 --- a/problems/product-of-two-run-length-encoded-arrays/README.md +++ b/problems/product-of-two-run-length-encoded-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../orders-with-maximum-quantity-above-average "Orders With Maximum Quantity Above Average") diff --git a/problems/product-price-at-a-given-date/README.md b/problems/product-price-at-a-given-date/README.md index baaa94e77..3a1cd5645 100644 --- a/problems/product-price-at-a-given-date/README.md +++ b/problems/product-price-at-a-given-date/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../last-substring-in-lexicographical-order "Last Substring in Lexicographical Order") diff --git a/problems/products-price-for-each-store/README.md b/problems/products-price-for-each-store/README.md index c71de0528..5d46b038f 100644 --- a/problems/products-price-for-each-store/README.md +++ b/problems/products-price-for-each-store/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../car-fleet-ii "Car Fleet II") diff --git a/problems/products-worth-over-invoices/README.md b/problems/products-worth-over-invoices/README.md index 1524ab49b..a73a4de86 100644 --- a/problems/products-worth-over-invoices/README.md +++ b/problems/products-worth-over-invoices/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lowest-common-ancestor-of-a-binary-tree-iv "Lowest Common Ancestor of a Binary Tree IV") diff --git a/problems/profitable-schemes/README.md b/problems/profitable-schemes/README.md index 5573231e3..f5e1c053b 100644 --- a/problems/profitable-schemes/README.md +++ b/problems/profitable-schemes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../nth-magical-number "Nth Magical Number") diff --git a/problems/project-employees-i/README.md b/problems/project-employees-i/README.md index 55a182751..663cffab8 100644 --- a/problems/project-employees-i/README.md +++ b/problems/project-employees-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-submatrices-that-sum-to-target "Number of Submatrices That Sum to Target") @@ -77,3 +77,6 @@ The average experience years for the first project is (3 + 2 + 1) / 3 = 2.00 and ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Project Employees II](../project-employees-ii) (Easy) diff --git a/problems/project-employees-ii/README.md b/problems/project-employees-ii/README.md index 219af6dd1..bc5178900 100644 --- a/problems/project-employees-ii/README.md +++ b/problems/project-employees-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../project-employees-i "Project Employees I") diff --git a/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md b/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md index 074c5ea1c..80f6d4723 100644 --- a/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md +++ b/problems/pseudo-palindromic-paths-in-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-vowels-in-a-substring-of-given-length "Maximum Number of Vowels in a Substring of Given Length") diff --git a/problems/push-dominoes/README.md b/problems/push-dominoes/README.md index c4d6ee456..2d7a28c6f 100644 --- a/problems/push-dominoes/README.md +++ b/problems/push-dominoes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../new-21-game "New 21 Game") diff --git a/problems/put-boxes-into-the-warehouse-i/README.md b/problems/put-boxes-into-the-warehouse-i/README.md index 58ec067a0..a1d6f02d4 100644 --- a/problems/put-boxes-into-the-warehouse-i/README.md +++ b/problems/put-boxes-into-the-warehouse-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game-v "Stone Game V") @@ -14,13 +14,10 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Put Boxes Into the Warehouse II](../put-boxes-into-the-warehouse-ii) (Medium) - ### Hints
    Hint 1 diff --git a/problems/put-boxes-into-the-warehouse-ii/README.md b/problems/put-boxes-into-the-warehouse-ii/README.md index ace8988c8..e6089dd71 100644 --- a/problems/put-boxes-into-the-warehouse-ii/README.md +++ b/problems/put-boxes-into-the-warehouse-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-max-number-of-edges-to-keep-graph-fully-traversable "Remove Max Number of Edges to Keep Graph Fully Traversable") @@ -14,13 +14,10 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Put Boxes Into the Warehouse I](../put-boxes-into-the-warehouse-i) (Medium) - ### Hints
    Hint 1 diff --git a/problems/queens-that-can-attack-the-king/README.md b/problems/queens-that-can-attack-the-king/README.md index bb2c5afe0..9c4914988 100644 --- a/problems/queens-that-can-attack-the-king/README.md +++ b/problems/queens-that-can-attack-the-king/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../split-a-string-in-balanced-strings "Split a String in Balanced Strings") diff --git a/problems/queries-on-number-of-points-inside-a-circle/README.md b/problems/queries-on-number-of-points-inside-a-circle/README.md index ccef067ca..1ab1e0aab 100644 --- a/problems/queries-on-number-of-points-inside-a-circle/README.md +++ b/problems/queries-on-number-of-points-inside-a-circle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-operations-to-make-the-array-increasing "Minimum Operations to Make the Array Increasing") diff --git a/problems/queries-quality-and-percentage/README.md b/problems/queries-quality-and-percentage/README.md index 95eef1138..36250d98d 100644 --- a/problems/queries-quality-and-percentage/README.md +++ b/problems/queries-quality-and-percentage/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-moves-to-reach-target-with-rotations "Minimum Moves to Reach Target with Rotations") diff --git a/problems/queue-reconstruction-by-height/README.md b/problems/queue-reconstruction-by-height/README.md index e06f59238..2378a7f52 100644 --- a/problems/queue-reconstruction-by-height/README.md +++ b/problems/queue-reconstruction-by-height/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-a-number-to-hexadecimal "Convert a Number to Hexadecimal") @@ -49,8 +49,8 @@ Hence [[5,0],[7,0],[5,2],[6,1],[4,4],[7,1]] is the reconstructed queue. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Similar Questions diff --git a/problems/random-flip-matrix/README.md b/problems/random-flip-matrix/README.md index b743724f9..6af8b4746 100644 --- a/problems/random-flip-matrix/README.md +++ b/problems/random-flip-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../coin-change-2 "Coin Change 2") @@ -52,7 +52,7 @@ solution.flip(); // return [2, 0], [0,0], [1,0], and [2,0] should be equally li ### Related Topics - [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] [[Randomized](../../tag/randomized/README.md)] diff --git a/problems/random-point-in-non-overlapping-rectangles/README.md b/problems/random-point-in-non-overlapping-rectangles/README.md index bd9165205..3e58d9e56 100644 --- a/problems/random-point-in-non-overlapping-rectangles/README.md +++ b/problems/random-point-in-non-overlapping-rectangles/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../next-greater-element-i "Next Greater Element I") diff --git a/problems/range-addition-ii/README.md b/problems/range-addition-ii/README.md index 957bdcd7f..8ed1babe6 100644 --- a/problems/range-addition-ii/README.md +++ b/problems/range-addition-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../friend-requests-i-overall-acceptance-rate "Friend Requests I: Overall Acceptance Rate") diff --git a/problems/range-addition/README.md b/problems/range-addition/README.md index 6c5eb4f18..595b65b0a 100644 --- a/problems/range-addition/README.md +++ b/problems/range-addition/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../plus-one-linked-list "Plus One Linked List") diff --git a/problems/range-frequency-queries/README.md b/problems/range-frequency-queries/README.md new file mode 100644 index 000000000..01668228f --- /dev/null +++ b/problems/range-frequency-queries/README.md @@ -0,0 +1,79 @@ + + + + + + + +[< Previous](../watering-plants "Watering Plants") +                 +[Next >](../sum-of-k-mirror-numbers "Sum of k-Mirror Numbers") + +## [2080. Range Frequency Queries (Medium)](https://leetcode.com/problems/range-frequency-queries "区间内查询数字的频率") + +

    Design a data structure to find the frequency of a given value in a given subarray.

    + +

    The frequency of a value in a subarray is the number of occurrences of that value in the subarray.

    + +

    Implement the RangeFreqQuery class:

    + +
      +
    • RangeFreqQuery(int[] arr) Constructs an instance of the class with the given 0-indexed integer array arr.
    • +
    • int query(int left, int right, int value) Returns the frequency of value in the subarray arr[left...right].
    • +
    + +

    A subarray is a contiguous sequence of elements within an array. arr[left...right] denotes the subarray that contains the elements of nums between indices left and right (inclusive).

    + +

     

    +

    Example 1:

    + +
    +Input
    +["RangeFreqQuery", "query", "query"]
    +[[[12, 33, 4, 56, 22, 2, 34, 33, 22, 12, 34, 56]], [1, 2, 4], [0, 11, 33]]
    +Output
    +[null, 1, 2]
    +
    +Explanation
    +RangeFreqQuery rangeFreqQuery = new RangeFreqQuery([12, 33, 4, 56, 22, 2, 34, 33, 22, 12, 34, 56]);
    +rangeFreqQuery.query(1, 2, 4); // return 1. The value 4 occurs 1 time in the subarray [33, 4]
    +rangeFreqQuery.query(0, 11, 33); // return 2. The value 33 occurs 2 times in the whole array.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 105
    • +
    • 1 <= arr[i], value <= 104
    • +
    • 0 <= left <= right < arr.length
    • +
    • At most 105 calls will be made to query
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +The queries must be answered efficiently to avoid time limit exceeded verdict. +
    + +
    +Hint 2 +Store the elements of the array in a data structure that helps answering the queries efficiently. +
    + +
    +Hint 3 +Use a hash table that stored for each value, the indices where that value appeared. +
    + +
    +Hint 4 +Use binary search over the indices of a value to find its range frequency. +
    diff --git a/problems/range-module/README.md b/problems/range-module/README.md index bbe8355dc..f4f13ff58 100644 --- a/problems/range-module/README.md +++ b/problems/range-module/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../best-time-to-buy-and-sell-stock-with-transaction-fee "Best Time to Buy and Sell Stock with Transaction Fee") diff --git a/problems/range-sum-of-bst/README.md b/problems/range-sum-of-bst/README.md index 0f677dbe8..db95e3008 100644 --- a/problems/range-sum-of-bst/README.md +++ b/problems/range-sum-of-bst/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reorder-data-in-log-files "Reorder Data in Log Files") diff --git a/problems/range-sum-of-sorted-subarray-sums/README.md b/problems/range-sum-of-sorted-subarray-sums/README.md index cb299d5ef..6cc505677 100644 --- a/problems/range-sum-of-sorted-subarray-sums/README.md +++ b/problems/range-sum-of-sorted-subarray-sums/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reformat-date "Reformat Date") diff --git a/problems/range-sum-query-immutable/README.md b/problems/range-sum-query-immutable/README.md index db9ae983d..450493ab6 100644 --- a/problems/range-sum-query-immutable/README.md +++ b/problems/range-sum-query-immutable/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-rectangle-enclosing-black-pixels "Smallest Rectangle Enclosing Black Pixels") @@ -52,8 +52,8 @@ numArray.sumRange(0, 5); // return (-2) + 0 + 3 + (-5) + 2 + (-1) = -3 ### Related Topics - [[Array](../../tag/array/README.md)] [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Similar Questions diff --git a/problems/rank-teams-by-votes/README.md b/problems/rank-teams-by-votes/README.md index 1a25fb7a8..5c2dc2e62 100644 --- a/problems/rank-teams-by-votes/README.md +++ b/problems/rank-teams-by-votes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../how-many-numbers-are-smaller-than-the-current-number "How Many Numbers Are Smaller Than the Current Number") diff --git a/problems/rank-transform-of-a-matrix/README.md b/problems/rank-transform-of-a-matrix/README.md index bd173f55f..836561c15 100644 --- a/problems/rank-transform-of-a-matrix/README.md +++ b/problems/rank-transform-of-a-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-with-minimum-effort "Path With Minimum Effort") @@ -74,17 +74,13 @@ The rank of matrix[1][1] is 3 because matrix[1][1] > matrix[0][1], matrix[1][ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] + [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] -### Similar Questions - 1. [Rank Transform of an Array](../rank-transform-of-an-array) (Easy) - 1. [GCD Sort of an Array](../gcd-sort-of-an-array) (Hard) - ### Hints
    Hint 1 diff --git a/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md b/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md index 77d25516f..4ceaafb65 100644 --- a/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md +++ b/problems/read-n-characters-given-read4-ii-call-multiple-times/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../read-n-characters-given-read4 "Read N Characters Given Read4") diff --git a/problems/rearrange-products-table/README.md b/problems/rearrange-products-table/README.md index 32103d604..834046e1b 100644 --- a/problems/rearrange-products-table/README.md +++ b/problems/rearrange-products-table/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-pairs-of-equal-substrings-with-minimum-difference "Count Pairs of Equal Substrings With Minimum Difference") @@ -15,6 +15,3 @@ ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Product's Price for Each Store](../products-price-for-each-store) (Easy) diff --git a/problems/rearrange-spaces-between-words/README.md b/problems/rearrange-spaces-between-words/README.md index 4e8a32046..bd77b2d6f 100644 --- a/problems/rearrange-spaces-between-words/README.md +++ b/problems/rearrange-spaces-between-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../strange-printer-ii "Strange Printer II") @@ -67,9 +67,6 @@ ### Related Topics [[String](../../tag/string/README.md)] -### Similar Questions - 1. [Text Justification](../text-justification) (Hard) - ### Hints
    Hint 1 diff --git a/problems/reconstruct-a-2-row-binary-matrix/README.md b/problems/reconstruct-a-2-row-binary-matrix/README.md index 06655f5a4..99fabdd1a 100644 --- a/problems/reconstruct-a-2-row-binary-matrix/README.md +++ b/problems/reconstruct-a-2-row-binary-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cells-with-odd-values-in-a-matrix "Cells with Odd Values in a Matrix") @@ -61,10 +61,13 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Find Valid Matrix Given Row and Column Sums](../find-valid-matrix-given-row-and-column-sums) (Medium) + ### Hints
    Hint 1 diff --git a/problems/reconstruct-itinerary/README.md b/problems/reconstruct-itinerary/README.md index 39017661d..02269425d 100644 --- a/problems/reconstruct-itinerary/README.md +++ b/problems/reconstruct-itinerary/README.md @@ -1,15 +1,15 @@ - - - + + + [< Previous](../verify-preorder-serialization-of-a-binary-tree "Verify Preorder Serialization of a Binary Tree")                  [Next >](../largest-bst-subtree "Largest BST Subtree") -## [332. Reconstruct Itinerary (Medium)](https://leetcode.com/problems/reconstruct-itinerary "重新安排行程") +## [332. Reconstruct Itinerary (Hard)](https://leetcode.com/problems/reconstruct-itinerary "重新安排行程")

    You are given a list of airline tickets where tickets[i] = [fromi, toi] represent the departure and the arrival airports of one flight. Reconstruct the itinerary in order and return it.

    @@ -53,3 +53,6 @@ [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] [[Eulerian Circuit](../../tag/eulerian-circuit/README.md)] + +### Similar Questions + 1. [Longest Common Subpath](../longest-common-subpath) (Hard) diff --git a/problems/reconstruct-original-digits-from-english/README.md b/problems/reconstruct-original-digits-from-english/README.md index 84bd5fed4..b2233eee7 100644 --- a/problems/reconstruct-original-digits-from-english/README.md +++ b/problems/reconstruct-original-digits-from-english/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-word-square "Valid Word Square") diff --git a/problems/rectangle-area/README.md b/problems/rectangle-area/README.md index fb0602d4b..1aad627f3 100644 --- a/problems/rectangle-area/README.md +++ b/problems/rectangle-area/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-complete-tree-nodes "Count Complete Tree Nodes") @@ -40,8 +40,8 @@ ### Related Topics - [[Math](../../tag/math/README.md)] [[Geometry](../../tag/geometry/README.md)] + [[Math](../../tag/math/README.md)] ### Similar Questions 1. [Rectangle Overlap](../rectangle-overlap) (Easy) diff --git a/problems/recyclable-and-low-fat-products/README.md b/problems/recyclable-and-low-fat-products/README.md index ed3399698..1bb3bbf66 100644 --- a/problems/recyclable-and-low-fat-products/README.md +++ b/problems/recyclable-and-low-fat-products/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-most-recently-used-queue "Design Most Recently Used Queue") diff --git a/problems/redistribute-characters-to-make-all-strings-equal/README.md b/problems/redistribute-characters-to-make-all-strings-equal/README.md index 2534847db..267df957b 100644 --- a/problems/redistribute-characters-to-make-all-strings-equal/README.md +++ b/problems/redistribute-characters-to-make-all-strings-equal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-change-the-final-value-of-expression "Minimum Cost to Change the Final Value of Expression") diff --git a/problems/reduce-array-size-to-the-half/README.md b/problems/reduce-array-size-to-the-half/README.md index 9bd2bdd1e..3667f864d 100644 --- a/problems/reduce-array-size-to-the-half/README.md +++ b/problems/reduce-array-size-to-the-half/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-k-weakest-rows-in-a-matrix "The K Weakest Rows in a Matrix") diff --git a/problems/reducing-dishes/README.md b/problems/reducing-dishes/README.md index ce4c9a144..6e87b7e6c 100644 --- a/problems/reducing-dishes/README.md +++ b/problems/reducing-dishes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../circle-and-rectangle-overlapping "Circle and Rectangle Overlapping") diff --git a/problems/reduction-operations-to-make-the-array-elements-equal/README.md b/problems/reduction-operations-to-make-the-array-elements-equal/README.md index 033de883b..f165aae46 100644 --- a/problems/reduction-operations-to-make-the-array-elements-equal/README.md +++ b/problems/reduction-operations-to-make-the-array-elements-equal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../determine-whether-matrix-can-be-obtained-by-rotation "Determine Whether Matrix Can Be Obtained By Rotation") diff --git a/problems/reformat-date/README.md b/problems/reformat-date/README.md index 672285045..c75714512 100644 --- a/problems/reformat-date/README.md +++ b/problems/reformat-date/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-root-of-n-ary-tree "Find Root of N-Ary Tree") diff --git a/problems/reformat-department-table/README.md b/problems/reformat-department-table/README.md index 9c71adbca..22185b884 100644 --- a/problems/reformat-department-table/README.md +++ b/problems/reformat-department-table/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-valid-words-for-each-puzzle "Number of Valid Words for Each Puzzle") diff --git a/problems/reformat-phone-number/README.md b/problems/reformat-phone-number/README.md index 3efa683ad..0ee2dbf14 100644 --- a/problems/reformat-phone-number/README.md +++ b/problems/reformat-phone-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../daily-leads-and-partners "Daily Leads and Partners") diff --git a/problems/relative-ranks/README.md b/problems/relative-ranks/README.md index 15a17adc8..16519bc3b 100644 --- a/problems/relative-ranks/README.md +++ b/problems/relative-ranks/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-maze-ii "The Maze II") diff --git a/problems/remove-all-adjacent-duplicates-in-string/README.md b/problems/remove-all-adjacent-duplicates-in-string/README.md index 897bb8aad..47d5e9e54 100644 --- a/problems/remove-all-adjacent-duplicates-in-string/README.md +++ b/problems/remove-all-adjacent-duplicates-in-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../last-stone-weight "Last Stone Weight") diff --git a/problems/remove-all-occurrences-of-a-substring/README.md b/problems/remove-all-occurrences-of-a-substring/README.md index 107f284fc..f73fbe00d 100644 --- a/problems/remove-all-occurrences-of-a-substring/README.md +++ b/problems/remove-all-occurrences-of-a-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-one-element-to-make-the-array-strictly-increasing "Remove One Element to Make the Array Strictly Increasing") diff --git a/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/README.md b/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/README.md index e862d3493..c8b5cd729 100644 --- a/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/README.md +++ b/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-moves-to-seat-everyone "Minimum Number of Moves to Seat Everyone") diff --git a/problems/remove-covered-intervals/README.md b/problems/remove-covered-intervals/README.md index 8f1df2a61..b319a77a3 100644 --- a/problems/remove-covered-intervals/README.md +++ b/problems/remove-covered-intervals/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../element-appearing-more-than-25-in-sorted-array "Element Appearing More Than 25% In Sorted Array") diff --git a/problems/remove-duplicate-letters/README.md b/problems/remove-duplicate-letters/README.md index d25ddda31..e61c74e31 100644 --- a/problems/remove-duplicate-letters/README.md +++ b/problems/remove-duplicate-letters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-of-smaller-numbers-after-self "Count of Smaller Numbers After Self") diff --git a/problems/remove-duplicates-from-an-unsorted-linked-list/README.md b/problems/remove-duplicates-from-an-unsorted-linked-list/README.md index 527659931..27ee4a822 100644 --- a/problems/remove-duplicates-from-an-unsorted-linked-list/README.md +++ b/problems/remove-duplicates-from-an-unsorted-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-xor-sum-of-all-pairs-bitwise-and "Find XOR Sum of All Pairs Bitwise AND") diff --git a/problems/remove-duplicates-from-sorted-array-ii/README.md b/problems/remove-duplicates-from-sorted-array-ii/README.md index 3a62a0ac8..8d14937d8 100644 --- a/problems/remove-duplicates-from-sorted-array-ii/README.md +++ b/problems/remove-duplicates-from-sorted-array-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-search "Word Search") diff --git a/problems/remove-duplicates-from-sorted-list-ii/README.md b/problems/remove-duplicates-from-sorted-list-ii/README.md index 5552c9248..fb75f2c4c 100644 --- a/problems/remove-duplicates-from-sorted-list-ii/README.md +++ b/problems/remove-duplicates-from-sorted-list-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../search-in-rotated-sorted-array-ii "Search in Rotated Sorted Array II") @@ -43,4 +43,3 @@ ### Similar Questions 1. [Remove Duplicates from Sorted List](../remove-duplicates-from-sorted-list) (Easy) - 1. [Remove Duplicates From an Unsorted Linked List](../remove-duplicates-from-an-unsorted-linked-list) (Medium) diff --git a/problems/remove-duplicates-from-sorted-list/README.md b/problems/remove-duplicates-from-sorted-list/README.md index 31a128b39..19e592c13 100644 --- a/problems/remove-duplicates-from-sorted-list/README.md +++ b/problems/remove-duplicates-from-sorted-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-duplicates-from-sorted-list-ii "Remove Duplicates from Sorted List II") diff --git a/problems/remove-element/README.md b/problems/remove-element/README.md index bf7c534e0..6a3a4c92d 100644 --- a/problems/remove-element/README.md +++ b/problems/remove-element/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-duplicates-from-sorted-array "Remove Duplicates from Sorted Array") diff --git a/problems/remove-invalid-parentheses/README.md b/problems/remove-invalid-parentheses/README.md index cf2197412..81d23cba2 100644 --- a/problems/remove-invalid-parentheses/README.md +++ b/problems/remove-invalid-parentheses/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-increasing-subsequence "Longest Increasing Subsequence") diff --git a/problems/remove-k-digits/README.md b/problems/remove-k-digits/README.md index c382758d4..51f3dea55 100644 --- a/problems/remove-k-digits/README.md +++ b/problems/remove-k-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-watch "Binary Watch") diff --git a/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md b/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md index 1b68f02c6..2073e3fc8 100644 --- a/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md +++ b/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-deletion-cost-to-avoid-repeating-letters "Minimum Deletion Cost to Avoid Repeating Letters") diff --git a/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md b/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md index b10d2d94e..c8499e554 100644 --- a/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md +++ b/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../game-of-nim "Game of Nim") diff --git a/problems/remove-palindromic-subsequences/README.md b/problems/remove-palindromic-subsequences/README.md index 9b302fce5..9127113a0 100644 --- a/problems/remove-palindromic-subsequences/README.md +++ b/problems/remove-palindromic-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rank-transform-of-an-array "Rank Transform of an Array") diff --git a/problems/remove-stones-to-minimize-the-total/README.md b/problems/remove-stones-to-minimize-the-total/README.md index 41af10a76..64414e15e 100644 --- a/problems/remove-stones-to-minimize-the-total/README.md +++ b/problems/remove-stones-to-minimize-the-total/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-string-is-a-prefix-of-array "Check If String Is a Prefix of Array") diff --git a/problems/remove-sub-folders-from-the-filesystem/README.md b/problems/remove-sub-folders-from-the-filesystem/README.md index 01d6c85ed..18bd119aa 100644 --- a/problems/remove-sub-folders-from-the-filesystem/README.md +++ b/problems/remove-sub-folders-from-the-filesystem/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-it-is-a-straight-line "Check If It Is a Straight Line") @@ -11,11 +11,15 @@ ## [1233. Remove Sub-Folders from the Filesystem (Medium)](https://leetcode.com/problems/remove-sub-folders-from-the-filesystem "删除子文件夹") -

    Given a list of folders, remove all sub-folders in those folders and return in any order the folders after removing.

    +

    Given a list of folders folder, return the folders after removing all sub-folders in those folders. You may return the answer in any order.

    -

    If a folder[i] is located within another folder[j], it is called a sub-folder of it.

    +

    If a folder[i] is located within another folder[j], it is called a sub-folder of it.

    -

    The format of a path is one or more concatenated strings of the form: / followed by one or more lowercase English letters. For example, /leetcode and /leetcode/problems are valid paths while an empty string and / are not.

    +

    The format of a path is one or more concatenated strings of the form: '/' followed by one or more lowercase English letters.

    + +
      +
    • For example, "/leetcode" and "/leetcode/problems" are valid paths while an empty string and "/" are not.
    • +

     

    Example 1:

    @@ -45,11 +49,11 @@

    Constraints:

      -
    • 1 <= folder.length <= 4 * 10^4
    • +
    • 1 <= folder.length <= 4 * 104
    • 2 <= folder[i].length <= 100
    • -
    • folder[i] contains only lowercase letters and '/'
    • -
    • folder[i] always starts with character '/'
    • -
    • Each folder name is unique.
    • +
    • folder[i] contains only lowercase letters and '/'.
    • +
    • folder[i] always starts with the character '/'.
    • +
    • Each folder name is unique.
    ### Related Topics diff --git a/problems/remove-vowels-from-a-string/README.md b/problems/remove-vowels-from-a-string/README.md index ac8433ad8..35d9277c6 100644 --- a/problems/remove-vowels-from-a-string/README.md +++ b/problems/remove-vowels-from-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-days-in-a-month "Number of Days in a Month") diff --git a/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md b/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md index a3ee99f6e..239cd5e5b 100644 --- a/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md +++ b/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../compare-strings-by-frequency-of-the-smallest-character "Compare Strings by Frequency of the Smallest Character") @@ -52,9 +52,6 @@ [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] -### Similar Questions - 1. [Delete N Nodes After M Nodes of a Linked List](../delete-n-nodes-after-m-nodes-of-a-linked-list) (Easy) - ### Hints
    Hint 1 diff --git a/problems/reorganize-string/README.md b/problems/reorganize-string/README.md index 15bee45f9..dbc402d4e 100644 --- a/problems/reorganize-string/README.md +++ b/problems/reorganize-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../toeplitz-matrix "Toeplitz Matrix") diff --git a/problems/repeated-string-match/README.md b/problems/repeated-string-match/README.md index 8c8b15b2e..508494d61 100644 --- a/problems/repeated-string-match/README.md +++ b/problems/repeated-string-match/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../redundant-connection-ii "Redundant Connection II") diff --git a/problems/repeated-substring-pattern/README.md b/problems/repeated-substring-pattern/README.md index 0d1fe46bf..bbed9fa11 100644 --- a/problems/repeated-substring-pattern/README.md +++ b/problems/repeated-substring-pattern/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../poor-pigs "Poor Pigs") diff --git a/problems/replace-all-digits-with-characters/README.md b/problems/replace-all-digits-with-characters/README.md index 931c1dc3a..03ef8a3ed 100644 --- a/problems/replace-all-digits-with-characters/README.md +++ b/problems/replace-all-digits-with-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../suspicious-bank-accounts "Suspicious Bank Accounts") diff --git a/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md b/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md index 26339c459..42bc3386d 100644 --- a/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md +++ b/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-all-possible-routes "Count All Possible Routes") diff --git a/problems/replace-elements-with-greatest-element-on-right-side/README.md b/problems/replace-elements-with-greatest-element-on-right-side/README.md index c8e5376fb..211f24d21 100644 --- a/problems/replace-elements-with-greatest-element-on-right-side/README.md +++ b/problems/replace-elements-with-greatest-element-on-right-side/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-candies-you-can-get-from-boxes "Maximum Candies You Can Get from Boxes") @@ -49,6 +49,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] +### Similar Questions + 1. [Two Furthest Houses With Different Colors](../two-furthest-houses-with-different-colors) (Easy) + ### Hints
    Hint 1 diff --git a/problems/replace-employee-id-with-the-unique-identifier/README.md b/problems/replace-employee-id-with-the-unique-identifier/README.md index e1db601dd..ab56752eb 100644 --- a/problems/replace-employee-id-with-the-unique-identifier/README.md +++ b/problems/replace-employee-id-with-the-unique-identifier/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../frog-position-after-t-seconds "Frog Position After T Seconds") diff --git a/problems/replace-the-substring-for-balanced-string/README.md b/problems/replace-the-substring-for-balanced-string/README.md index 1697262d2..dd661d977 100644 --- a/problems/replace-the-substring-for-balanced-string/README.md +++ b/problems/replace-the-substring-for-balanced-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-sub-folders-from-the-filesystem "Remove Sub-Folders from the Filesystem") diff --git a/problems/replace-words/README.md b/problems/replace-words/README.md index 2b09cd90d..d8c027369 100644 --- a/problems/replace-words/README.md +++ b/problems/replace-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../palindromic-substrings "Palindromic Substrings") diff --git a/problems/report-contiguous-dates/README.md b/problems/report-contiguous-dates/README.md index 7eefc0968..8653cf4c4 100644 --- a/problems/report-contiguous-dates/README.md +++ b/problems/report-contiguous-dates/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-equal-frequency "Maximum Equal Frequency") @@ -88,3 +88,7 @@ From 2019-01-06 to 2019-01-06 all tasks succeeded and system state was "pre ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Find the Start and End Number of Continuous Ranges](../find-the-start-and-end-number-of-continuous-ranges) (Medium) + 1. [Find the Missing IDs](../find-the-missing-ids) (Medium) diff --git a/problems/reported-posts/README.md b/problems/reported-posts/README.md index 33a4f61ac..df69c7f59 100644 --- a/problems/reported-posts/README.md +++ b/problems/reported-posts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../highest-grade-for-each-student "Highest Grade For Each Student") diff --git a/problems/reshape-the-matrix/README.md b/problems/reshape-the-matrix/README.md index 391c47503..f453ed4fa 100644 --- a/problems/reshape-the-matrix/README.md +++ b/problems/reshape-the-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../array-nesting "Array Nesting") @@ -50,9 +50,6 @@ [[Matrix](../../tag/matrix/README.md)] [[Simulation](../../tag/simulation/README.md)] -### Similar Questions - 1. [Convert 1D Array Into 2D Array](../convert-1d-array-into-2d-array) (Easy) - ### Hints
    Hint 1 diff --git a/problems/restaurant-growth/README.md b/problems/restaurant-growth/README.md index dc5ce13bc..4375bf834 100644 --- a/problems/restaurant-growth/README.md +++ b/problems/restaurant-growth/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-distance-to-type-a-word-using-two-fingers "Minimum Distance to Type a Word Using Two Fingers") diff --git a/problems/restore-the-array-from-adjacent-pairs/README.md b/problems/restore-the-array-from-adjacent-pairs/README.md index 6e2e7ab50..8569f4741 100644 --- a/problems/restore-the-array-from-adjacent-pairs/README.md +++ b/problems/restore-the-array-from-adjacent-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-balls-in-a-box "Maximum Number of Balls in a Box") diff --git a/problems/reverse-nodes-in-even-length-groups/README.md b/problems/reverse-nodes-in-even-length-groups/README.md index 274f57c6f..1acbfaf3b 100644 --- a/problems/reverse-nodes-in-even-length-groups/README.md +++ b/problems/reverse-nodes-in-even-length-groups/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../time-needed-to-buy-tickets "Time Needed to Buy Tickets") diff --git a/problems/reverse-only-letters/README.md b/problems/reverse-only-letters/README.md index ee75bb83f..d614140f3 100644 --- a/problems/reverse-only-letters/README.md +++ b/problems/reverse-only-letters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-subsets "Word Subsets") diff --git a/problems/reverse-prefix-of-word/README.md b/problems/reverse-prefix-of-word/README.md index 0ac3b4e21..37f9b97e9 100644 --- a/problems/reverse-prefix-of-word/README.md +++ b/problems/reverse-prefix-of-word/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-greater-multiple-made-of-two-digits "Smallest Greater Multiple Made of Two Digits") diff --git a/problems/reverse-string-ii/README.md b/problems/reverse-string-ii/README.md index 4700b4759..0ae3f3651 100644 --- a/problems/reverse-string-ii/README.md +++ b/problems/reverse-string-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../single-element-in-a-sorted-array "Single Element in a Sorted Array") diff --git a/problems/reverse-string/README.md b/problems/reverse-string/README.md index cdbb71fcb..af5bd5a71 100644 --- a/problems/reverse-string/README.md +++ b/problems/reverse-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../integer-break "Integer Break") @@ -13,6 +13,8 @@

    Write a function that reverses a string. The input string is given as an array of characters s.

    +

    You must do this by modifying the input array in-place with O(1) extra memory.

    +

     

    Example 1:

    Input: s = ["h","e","l","l","o"]
    @@ -29,9 +31,6 @@
     	
  • s[i] is a printable ascii character.
  • -

     

    -

    Follow up: Do not allocate extra space for another array. You must do this by modifying the input array in-place with O(1) extra memory.

    - ### Related Topics [[Recursion](../../tag/recursion/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] diff --git a/problems/reverse-subarray-to-maximize-array-value/README.md b/problems/reverse-subarray-to-maximize-array-value/README.md index f01437928..3ff6d629e 100644 --- a/problems/reverse-subarray-to-maximize-array-value/README.md +++ b/problems/reverse-subarray-to-maximize-array-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-the-matrix-diagonally "Sort the Matrix Diagonally") @@ -11,7 +11,7 @@ ## [1330. Reverse Subarray To Maximize Array Value (Hard)](https://leetcode.com/problems/reverse-subarray-to-maximize-array-value "翻转子数组得到最大的数组值") -

    You are given an integer array nums. The value of this array is defined as the sum of |nums[i]-nums[i+1]| for all 0 <= i < nums.length-1.

    +

    You are given an integer array nums. The value of this array is defined as the sum of |nums[i] - nums[i + 1]| for all 0 <= i < nums.length - 1.

    You are allowed to select any subarray of the given array and reverse it. You can perform this operation only once.

    @@ -37,8 +37,8 @@

    Constraints:

      -
    • 1 <= nums.length <= 3*10^4
    • -
    • -10^5 <= nums[i] <= 10^5
    • +
    • 1 <= nums.length <= 3 * 104
    • +
    • -105 <= nums[i] <= 105
    ### Related Topics diff --git a/problems/reverse-substrings-between-each-pair-of-parentheses/README.md b/problems/reverse-substrings-between-each-pair-of-parentheses/README.md index 822cda347..b9b0748fe 100644 --- a/problems/reverse-substrings-between-each-pair-of-parentheses/README.md +++ b/problems/reverse-substrings-between-each-pair-of-parentheses/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-balloons "Maximum Number of Balloons") @@ -58,8 +58,8 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[String](../../tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] ### Hints
    diff --git a/problems/reverse-vowels-of-a-string/README.md b/problems/reverse-vowels-of-a-string/README.md index 415304e24..cdc3e5937 100644 --- a/problems/reverse-vowels-of-a-string/README.md +++ b/problems/reverse-vowels-of-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-string "Reverse String") diff --git a/problems/reverse-words-in-a-string-iii/README.md b/problems/reverse-words-in-a-string-iii/README.md index c0be62ca8..68b40c93c 100644 --- a/problems/reverse-words-in-a-string-iii/README.md +++ b/problems/reverse-words-in-a-string-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../next-greater-element-iii "Next Greater Element III") diff --git a/problems/richest-customer-wealth/README.md b/problems/richest-customer-wealth/README.md index 05169133b..b977f74c4 100644 --- a/problems/richest-customer-wealth/README.md +++ b/problems/richest-customer-wealth/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-removals-to-make-mountain-array "Minimum Number of Removals to Make Mountain Array") diff --git a/problems/rle-iterator/README.md b/problems/rle-iterator/README.md index 2a5a2eb27..2ebd53cc0 100644 --- a/problems/rle-iterator/README.md +++ b/problems/rle-iterator/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../orderly-queue "Orderly Queue") diff --git a/problems/rotate-image/README.md b/problems/rotate-image/README.md index 5d95f313f..ad68bc8fe 100644 --- a/problems/rotate-image/README.md +++ b/problems/rotate-image/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../permutations-ii "Permutations II") @@ -58,6 +58,3 @@ [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Matrix](../../tag/matrix/README.md)] - -### Similar Questions - 1. [Determine Whether Matrix Can Be Obtained By Rotation](../determine-whether-matrix-can-be-obtained-by-rotation) (Easy) diff --git a/problems/rotating-the-box/README.md b/problems/rotating-the-box/README.md index 0d115c323..c7b5a2d59 100644 --- a/problems/rotating-the-box/README.md +++ b/problems/rotating-the-box/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../incremental-memory-leak "Incremental Memory Leak") diff --git a/problems/running-sum-of-1d-array/README.md b/problems/running-sum-of-1d-array/README.md index 14417c0f0..00ceb6f78 100644 --- a/problems/running-sum-of-1d-array/README.md +++ b/problems/running-sum-of-1d-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sales-by-day-of-the-week "Sales by Day of the Week") diff --git a/problems/running-total-for-different-genders/README.md b/problems/running-total-for-different-genders/README.md index cff1b7ccf..db8e732bc 100644 --- a/problems/running-total-for-different-genders/README.md +++ b/problems/running-total-for-different-genders/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../verbal-arithmetic-puzzle "Verbal Arithmetic Puzzle") diff --git a/problems/sales-analysis-i/README.md b/problems/sales-analysis-i/README.md index df00fb03c..7f9b0f947 100644 --- a/problems/sales-analysis-i/README.md +++ b/problems/sales-analysis-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-subsequence-of-distinct-characters "Smallest Subsequence of Distinct Characters") @@ -78,6 +78,3 @@ Both sellers with id 1 and 3 sold products with the most total price of 2800.

    - - - + + + [< Previous](../sales-analysis-i "Sales Analysis I") diff --git a/problems/sales-analysis-iii/README.md b/problems/sales-analysis-iii/README.md index d198a55f4..82d94eef2 100644 --- a/problems/sales-analysis-iii/README.md +++ b/problems/sales-analysis-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sales-analysis-ii "Sales Analysis II") diff --git a/problems/sales-person/README.md b/problems/sales-person/README.md index 85f7385bd..1c51029ea 100644 --- a/problems/sales-person/README.md +++ b/problems/sales-person/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-string-from-binary-tree "Construct String from Binary Tree") diff --git a/problems/sales-person/mysql_schemas.sql b/problems/sales-person/mysql_schemas.sql index 05b85ab4c..b583e9691 100644 --- a/problems/sales-person/mysql_schemas.sql +++ b/problems/sales-person/mysql_schemas.sql @@ -1,19 +1,19 @@ -Create table If Not Exists salesperson (sales_id int, name varchar(255), salary int,commission_rate int, hire_date varchar(255)); -Create table If Not Exists company (com_id int, name varchar(255), city varchar(255)); -Create table If Not Exists orders (order_id int, order_date varchar(255), com_id int, sales_id int, amount int); -Truncate table salesperson; -insert into salesperson (sales_id, name, salary, commission_rate, hire_date) values ('1', 'John', '100000', '6', '4/1/2006'); -insert into salesperson (sales_id, name, salary, commission_rate, hire_date) values ('2', 'Amy', '12000', '5', '5/1/2010'); -insert into salesperson (sales_id, name, salary, commission_rate, hire_date) values ('3', 'Mark', '65000', '12', '12/25/2008'); -insert into salesperson (sales_id, name, salary, commission_rate, hire_date) values ('4', 'Pam', '25000', '25', '1/1/2005'); -insert into salesperson (sales_id, name, salary, commission_rate, hire_date) values ('5', 'Alex', '5000', '10', '2/3/2007'); -Truncate table company; -insert into company (com_id, name, city) values ('1', 'RED', 'Boston'); -insert into company (com_id, name, city) values ('2', 'ORANGE', 'New York'); -insert into company (com_id, name, city) values ('3', 'YELLOW', 'Boston'); -insert into company (com_id, name, city) values ('4', 'GREEN', 'Austin'); -Truncate table orders; -insert into orders (order_id, order_date, com_id, sales_id, amount) values ('1', '1/1/2014', '3', '4', '10000'); -insert into orders (order_id, order_date, com_id, sales_id, amount) values ('2', '2/1/2014', '4', '5', '5000'); -insert into orders (order_id, order_date, com_id, sales_id, amount) values ('3', '3/1/2014', '1', '1', '50000'); -insert into orders (order_id, order_date, com_id, sales_id, amount) values ('4', '4/1/2014', '1', '4', '25000'); +Create table If Not Exists SalesPerson (sales_id int, name varchar(255), salary int, commission_rate int, hire_date date); +Create table If Not Exists Company (com_id int, name varchar(255), city varchar(255)); +Create table If Not Exists Orders (order_id int, order_date date, com_id int, sales_id int, amount int); +Truncate table SalesPerson; +insert into SalesPerson (sales_id, name, salary, commission_rate, hire_date) values ('1', 'John', '100000', '6', '4/1/2006'); +insert into SalesPerson (sales_id, name, salary, commission_rate, hire_date) values ('2', 'Amy', '12000', '5', '5/1/2010'); +insert into SalesPerson (sales_id, name, salary, commission_rate, hire_date) values ('3', 'Mark', '65000', '12', '12/25/2008'); +insert into SalesPerson (sales_id, name, salary, commission_rate, hire_date) values ('4', 'Pam', '25000', '25', '1/1/2005'); +insert into SalesPerson (sales_id, name, salary, commission_rate, hire_date) values ('5', 'Alex', '5000', '10', '2/3/2007'); +Truncate table Company; +insert into Company (com_id, name, city) values ('1', 'RED', 'Boston'); +insert into Company (com_id, name, city) values ('2', 'ORANGE', 'New York'); +insert into Company (com_id, name, city) values ('3', 'YELLOW', 'Boston'); +insert into Company (com_id, name, city) values ('4', 'GREEN', 'Austin'); +Truncate table Orders; +insert into Orders (order_id, order_date, com_id, sales_id, amount) values ('1', '1/1/2014', '3', '4', '10000'); +insert into Orders (order_id, order_date, com_id, sales_id, amount) values ('2', '2/1/2014', '4', '5', '5000'); +insert into Orders (order_id, order_date, com_id, sales_id, amount) values ('3', '3/1/2014', '1', '1', '50000'); +insert into Orders (order_id, order_date, com_id, sales_id, amount) values ('4', '4/1/2014', '1', '4', '25000'); diff --git a/problems/score-after-flipping-matrix/README.md b/problems/score-after-flipping-matrix/README.md index 93e475da0..4fdce91e4 100644 --- a/problems/score-after-flipping-matrix/README.md +++ b/problems/score-after-flipping-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lemonade-change "Lemonade Change") diff --git a/problems/scramble-string/README.md b/problems/scramble-string/README.md index 0c661df9b..3dfafc5ac 100644 --- a/problems/scramble-string/README.md +++ b/problems/scramble-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../partition-list "Partition List") diff --git a/problems/search-a-2d-matrix-ii/README.md b/problems/search-a-2d-matrix-ii/README.md index a0df5c561..ef44b3d7d 100644 --- a/problems/search-a-2d-matrix-ii/README.md +++ b/problems/search-a-2d-matrix-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sliding-window-maximum "Sliding Window Maximum") diff --git a/problems/search-in-rotated-sorted-array-ii/README.md b/problems/search-in-rotated-sorted-array-ii/README.md index 5e54861d2..8bf333932 100644 --- a/problems/search-in-rotated-sorted-array-ii/README.md +++ b/problems/search-in-rotated-sorted-array-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-duplicates-from-sorted-array-ii "Remove Duplicates from Sorted Array II") diff --git a/problems/search-suggestions-system/README.md b/problems/search-suggestions-system/README.md index 6190a1717..e572da055 100644 --- a/problems/search-suggestions-system/README.md +++ b/problems/search-suggestions-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-servers-that-communicate "Count Servers that Communicate") @@ -66,9 +66,9 @@ After typing mou, mous and mouse the system suggests ["mouse","mo ### Related Topics - [[Trie](../../tag/trie/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Trie](../../tag/trie/README.md)] ### Hints
    diff --git a/problems/seat-reservation-manager/README.md b/problems/seat-reservation-manager/README.md index 44c1ac1ab..83f878644 100644 --- a/problems/seat-reservation-manager/README.md +++ b/problems/seat-reservation-manager/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../replace-all-digits-with-characters "Replace All Digits with Characters") diff --git a/problems/second-degree-follower/README.md b/problems/second-degree-follower/README.md index 210dc64f2..da3878fbb 100644 --- a/problems/second-degree-follower/README.md +++ b/problems/second-degree-follower/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-distance-in-a-line "Shortest Distance in a Line") diff --git a/problems/second-degree-follower/mysql_schemas.sql b/problems/second-degree-follower/mysql_schemas.sql index 3f3df12bc..1dbb57626 100644 --- a/problems/second-degree-follower/mysql_schemas.sql +++ b/problems/second-degree-follower/mysql_schemas.sql @@ -1,6 +1,6 @@ -Create table If Not Exists follow (followee varchar(255), follower varchar(255)); -Truncate table follow; -insert into follow (followee, follower) values ('A', 'B'); -insert into follow (followee, follower) values ('B', 'C'); -insert into follow (followee, follower) values ('B', 'D'); -insert into follow (followee, follower) values ('D', 'E'); +Create table If Not Exists Follow (followee varchar(255), follower varchar(255)); +Truncate table Follow; +insert into Follow (followee, follower) values ('Alice', 'Bob'); +insert into Follow (followee, follower) values ('Bob', 'Cena'); +insert into Follow (followee, follower) values ('Bob', 'Donald'); +insert into Follow (followee, follower) values ('Donald', 'Edward'); diff --git a/problems/second-largest-digit-in-a-string/README.md b/problems/second-largest-digit-in-a-string/README.md index 458d94a57..e50360bbb 100644 --- a/problems/second-largest-digit-in-a-string/README.md +++ b/problems/second-largest-digit-in-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rearrange-products-table "Rearrange Products Table") diff --git a/problems/second-minimum-node-in-a-binary-tree/README.md b/problems/second-minimum-node-in-a-binary-tree/README.md index 7118b46e6..3dc88a88f 100644 --- a/problems/second-minimum-node-in-a-binary-tree/README.md +++ b/problems/second-minimum-node-in-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-swap "Maximum Swap") diff --git a/problems/second-minimum-time-to-reach-destination/README.md b/problems/second-minimum-time-to-reach-destination/README.md index 5fd12cc5b..b6cd23da1 100644 --- a/problems/second-minimum-time-to-reach-destination/README.md +++ b/problems/second-minimum-time-to-reach-destination/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-number-of-maximum-bitwise-or-subsets "Count Number of Maximum Bitwise-OR Subsets") diff --git a/problems/sell-diminishing-valued-colored-balls/README.md b/problems/sell-diminishing-valued-colored-balls/README.md index 0f152dc19..4f26b0d86 100644 --- a/problems/sell-diminishing-valued-colored-balls/README.md +++ b/problems/sell-diminishing-valued-colored-balls/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-deletions-to-make-character-frequencies-unique "Minimum Deletions to Make Character Frequencies Unique") @@ -63,10 +63,10 @@ The maximum total value is 3 + 2 + 5 + 4 + 3 + 2 = 19. ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/sellers-with-no-sales/README.md b/problems/sellers-with-no-sales/README.md index 965b59bb3..3d659cfa6 100644 --- a/problems/sellers-with-no-sales/README.md +++ b/problems/sellers-with-no-sales/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-servers-that-handled-most-number-of-requests "Find Servers That Handled Most Number of Requests") diff --git a/problems/sentence-similarity-iii/README.md b/problems/sentence-similarity-iii/README.md index 1adf040d6..02839ffad 100644 --- a/problems/sentence-similarity-iii/README.md +++ b/problems/sentence-similarity-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../determine-color-of-a-chessboard-square "Determine Color of a Chessboard Square") diff --git a/problems/sentence-similarity/README.md b/problems/sentence-similarity/README.md index 7daf23854..4c2e329ba 100644 --- a/problems/sentence-similarity/README.md +++ b/problems/sentence-similarity/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flood-fill "Flood Fill") diff --git a/problems/sequence-reconstruction/README.md b/problems/sequence-reconstruction/README.md index eb0ec0dc7..fab41cd33 100644 --- a/problems/sequence-reconstruction/README.md +++ b/problems/sequence-reconstruction/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../string-compression "String Compression") diff --git a/problems/sequential-digits/README.md b/problems/sequential-digits/README.md index 079552bd4..9dfeeb487 100644 --- a/problems/sequential-digits/README.md +++ b/problems/sequential-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-binary-number-in-a-linked-list-to-integer "Convert Binary Number in a Linked List to Integer") diff --git a/problems/serialize-and-deserialize-n-ary-tree/README.md b/problems/serialize-and-deserialize-n-ary-tree/README.md index a489aad6d..cacfe9ae5 100644 --- a/problems/serialize-and-deserialize-n-ary-tree/README.md +++ b/problems/serialize-and-deserialize-n-ary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-quad-tree "Construct Quad Tree") diff --git a/problems/set-mismatch/README.md b/problems/set-mismatch/README.md index 1186eb92f..4fd90d16f 100644 --- a/problems/set-mismatch/README.md +++ b/problems/set-mismatch/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-average-subarray-ii "Maximum Average Subarray II") diff --git a/problems/shifting-letters/README.md b/problems/shifting-letters/README.md index 443c20df6..8a9fdbb35 100644 --- a/problems/shifting-letters/README.md +++ b/problems/shifting-letters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-path-visiting-all-nodes "Shortest Path Visiting All Nodes") diff --git a/problems/shopping-offers/README.md b/problems/shopping-offers/README.md index 4eb605968..7203395b5 100644 --- a/problems/shopping-offers/README.md +++ b/problems/shopping-offers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../average-of-levels-in-binary-tree "Average of Levels in Binary Tree") diff --git a/problems/short-encoding-of-words/README.md b/problems/short-encoding-of-words/README.md index 533cd2c87..96b3b8a2a 100644 --- a/problems/short-encoding-of-words/README.md +++ b/problems/short-encoding-of-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../most-common-word "Most Common Word") diff --git a/problems/shortest-completing-word/README.md b/problems/shortest-completing-word/README.md index 11e367461..5501b8b5b 100644 --- a/problems/shortest-completing-word/README.md +++ b/problems/shortest-completing-word/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-number-at-least-twice-of-others "Largest Number At Least Twice of Others") diff --git a/problems/shortest-distance-in-a-line/README.md b/problems/shortest-distance-in-a-line/README.md index b26f0f20a..1d788e5d0 100644 --- a/problems/shortest-distance-in-a-line/README.md +++ b/problems/shortest-distance-in-a-line/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-distance-in-a-plane "Shortest Distance in a Plane") diff --git a/problems/shortest-distance-in-a-line/mysql_schemas.sql b/problems/shortest-distance-in-a-line/mysql_schemas.sql index 5c2505ad0..bef5a5599 100644 --- a/problems/shortest-distance-in-a-line/mysql_schemas.sql +++ b/problems/shortest-distance-in-a-line/mysql_schemas.sql @@ -1,5 +1,5 @@ -CREATE TABLE If Not Exists point (x INT NOT NULL, UNIQUE INDEX x_UNIQUE (x ASC)); -Truncate table point; -insert into point (x) values ('-1'); -insert into point (x) values ('0'); -insert into point (x) values ('2'); +Create Table If Not Exists Point (x int not null); +Truncate table Point; +insert into Point (x) values ('-1'); +insert into Point (x) values ('0'); +insert into Point (x) values ('2'); diff --git a/problems/shortest-distance-in-a-plane/README.md b/problems/shortest-distance-in-a-plane/README.md index 1c8e67ad1..3f758e57e 100644 --- a/problems/shortest-distance-in-a-plane/README.md +++ b/problems/shortest-distance-in-a-plane/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-triangle-number "Valid Triangle Number") diff --git a/problems/shortest-distance-in-a-plane/mysql_schemas.sql b/problems/shortest-distance-in-a-plane/mysql_schemas.sql index c66c065d4..fe36290c3 100644 --- a/problems/shortest-distance-in-a-plane/mysql_schemas.sql +++ b/problems/shortest-distance-in-a-plane/mysql_schemas.sql @@ -1,5 +1,5 @@ -CREATE TABLE If Not Exists point_2d (x INT NOT NULL, y INT NOT NULL); -Truncate table point_2d; -insert into point_2d (x, y) values ('-1', '-1'); -insert into point_2d (x, y) values ('0', '0'); -insert into point_2d (x, y) values ('-1', '-2'); +Create Table If Not Exists Point2D (x int not null, y int not null); +Truncate table Point2D; +insert into Point2D (x, y) values ('-1', '-1'); +insert into Point2D (x, y) values ('0', '0'); +insert into Point2D (x, y) values ('-1', '-2'); diff --git a/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md b/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md index ece449fda..50024922b 100644 --- a/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md +++ b/problems/shortest-path-in-a-grid-with-obstacles-elimination/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold "Maximum Side Length of a Square with Sum Less than or Equal to Threshold") @@ -47,10 +47,13 @@ The shortest path with one obstacle elimination at position (3,2) is 6. Such pat ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Shortest Path to Get Food](../shortest-path-to-get-food) (Medium) + ### Hints
    Hint 1 diff --git a/problems/shortest-path-in-a-hidden-grid/README.md b/problems/shortest-path-in-a-hidden-grid/README.md index 499049657..9a8aae6c9 100644 --- a/problems/shortest-path-in-a-hidden-grid/README.md +++ b/problems/shortest-path-in-a-hidden-grid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../products-price-for-each-store "Product's Price for Each Store") diff --git a/problems/shortest-path-in-binary-matrix/README.md b/problems/shortest-path-in-binary-matrix/README.md index 45bb40cc7..2922b9f93 100644 --- a/problems/shortest-path-in-binary-matrix/README.md +++ b/problems/shortest-path-in-binary-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-values-from-labels "Largest Values From Labels") @@ -55,8 +55,8 @@ ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/shortest-path-to-get-all-keys/README.md b/problems/shortest-path-to-get-all-keys/README.md index a4447f698..8499f1d63 100644 --- a/problems/shortest-path-to-get-all-keys/README.md +++ b/problems/shortest-path-to-get-all-keys/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-nodes-distance-k-in-binary-tree "All Nodes Distance K in Binary Tree") diff --git a/problems/shortest-path-to-get-food/README.md b/problems/shortest-path-to-get-food/README.md index 602173318..1332ad811 100644 --- a/problems/shortest-path-to-get-food/README.md +++ b/problems/shortest-path-to-get-food/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-followers-count "Find Followers Count") diff --git a/problems/shortest-path-with-alternating-colors/README.md b/problems/shortest-path-with-alternating-colors/README.md index 3c2ac776e..4412b632c 100644 --- a/problems/shortest-path-with-alternating-colors/README.md +++ b/problems/shortest-path-with-alternating-colors/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-equivalent-domino-pairs "Number of Equivalent Domino Pairs") diff --git a/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md b/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md index fac216680..0c1a1106f 100644 --- a/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md +++ b/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-split-a-string "Number of Ways to Split a String") @@ -11,11 +11,11 @@ ## [1574. Shortest Subarray to be Removed to Make Array Sorted (Medium)](https://leetcode.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted "删除最短的子数组使剩余数组有序") -

    Given an integer array arr, remove a subarray (can be empty) from arr such that the remaining elements in arr are non-decreasing.

    +

    Given an integer array arr, remove a subarray (can be empty) from arr such that the remaining elements in arr are non-decreasing.

    -

    A subarray is a contiguous subsequence of the array.

    +

    Return the length of the shortest subarray to remove.

    -

    Return the length of the shortest subarray to remove.

    +

    A subarray is a contiguous subsequence of the array.

     

    Example 1:

    @@ -53,15 +53,15 @@ Another correct solution is to remove the subarray [3,10,4].

    Constraints:

      -
    • 1 <= arr.length <= 10^5
    • -
    • 0 <= arr[i] <= 10^9
    • +
    • 1 <= arr.length <= 105
    • +
    • 0 <= arr[i] <= 109
    ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Stack](../../tag/stack/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints diff --git a/problems/shortest-unsorted-continuous-subarray/README.md b/problems/shortest-unsorted-continuous-subarray/README.md index 0d387f824..4727ed77a 100644 --- a/problems/shortest-unsorted-continuous-subarray/README.md +++ b/problems/shortest-unsorted-continuous-subarray/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-student-number-in-departments "Count Student Number in Departments") diff --git a/problems/shortest-way-to-form-string/README.md b/problems/shortest-way-to-form-string/README.md index 6f660e72d..6a522ebee 100644 --- a/problems/shortest-way-to-form-string/README.md +++ b/problems/shortest-way-to-form-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../distant-barcodes "Distant Barcodes") @@ -51,12 +51,13 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions 1. [Is Subsequence](../is-subsequence) (Easy) + 1. [Number of Matching Subsequences](../number-of-matching-subsequences) (Medium) ### Hints
    diff --git a/problems/shortest-word-distance/README.md b/problems/shortest-word-distance/README.md index 6748ea4e9..13002efde 100644 --- a/problems/shortest-word-distance/README.md +++ b/problems/shortest-word-distance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-anagram "Valid Anagram") diff --git a/problems/shuffle-string/README.md b/problems/shuffle-string/README.md index 197004674..83e038f81 100644 --- a/problems/shuffle-string/README.md +++ b/problems/shuffle-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../patients-with-a-condition "Patients With a Condition") diff --git a/problems/sign-of-the-product-of-an-array/README.md b/problems/sign-of-the-product-of-an-array/README.md index 6091454dd..2ce92356b 100644 --- a/problems/sign-of-the-product-of-an-array/README.md +++ b/problems/sign-of-the-product-of-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-customers-with-positive-revenue-this-year "Find Customers With Positive Revenue this Year") diff --git a/problems/similar-rgb-color/README.md b/problems/similar-rgb-color/README.md index 9c96687d1..da973a626 100644 --- a/problems/similar-rgb-color/README.md +++ b/problems/similar-rgb-color/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../champagne-tower "Champagne Tower") diff --git a/problems/simple-bank-system/README.md b/problems/simple-bank-system/README.md index 3d7d692e0..21519e1c9 100644 --- a/problems/simple-bank-system/README.md +++ b/problems/simple-bank-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-numbers-are-ascending-in-a-sentence "Check if Numbers Are Ascending in a Sentence") diff --git a/problems/simplified-fractions/README.md b/problems/simplified-fractions/README.md index 7c4753dfc..3b5c60dc4 100644 --- a/problems/simplified-fractions/README.md +++ b/problems/simplified-fractions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../consecutive-characters "Consecutive Characters") diff --git a/problems/single-element-in-a-sorted-array/README.md b/problems/single-element-in-a-sorted-array/README.md index 19496af4f..1a2a0ca96 100644 --- a/problems/single-element-in-a-sorted-array/README.md +++ b/problems/single-element-in-a-sorted-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-time-difference "Minimum Time Difference") @@ -11,9 +11,11 @@ ## [540. Single Element in a Sorted Array (Medium)](https://leetcode.com/problems/single-element-in-a-sorted-array "有序数组中的单一元素") -

    You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Find this single element that appears only once.

    +

    You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once.

    -

    Follow up: Your solution should run in O(log n) time and O(1) space.

    +

    Return the single element that appears only once.

    + +

    Your solution must run in O(log n) time and O(1) space.

     

    Example 1:

    @@ -27,8 +29,8 @@

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • 0 <= nums[i] <= 10^5
    • +
    • 1 <= nums.length <= 105
    • +
    • 0 <= nums[i] <= 105
    ### Related Topics diff --git a/problems/single-number-ii/README.md b/problems/single-number-ii/README.md index fa41c7517..61038fb11 100644 --- a/problems/single-number-ii/README.md +++ b/problems/single-number-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../single-number "Single Number") @@ -33,8 +33,8 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Single Number](../single-number) (Easy) diff --git a/problems/single-threaded-cpu/README.md b/problems/single-threaded-cpu/README.md index 57b8e7761..4b61ed447 100644 --- a/problems/single-threaded-cpu/README.md +++ b/problems/single-threaded-cpu/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-ice-cream-bars "Maximum Ice Cream Bars") diff --git a/problems/sliding-puzzle/README.md b/problems/sliding-puzzle/README.md index d635f66ae..6b0fb4589 100644 --- a/problems/sliding-puzzle/README.md +++ b/problems/sliding-puzzle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../basic-calculator-iii "Basic Calculator III") @@ -67,8 +67,8 @@ After move 5: [[1,2,3],[4,5,0]] ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/sliding-window-median/README.md b/problems/sliding-window-median/README.md index 3b6027df7..af143bcb9 100644 --- a/problems/sliding-window-median/README.md +++ b/problems/sliding-window-median/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-palindrome-product "Largest Palindrome Product") @@ -51,7 +51,7 @@ Window position Median
    • 1 <= k <= nums.length <= 105
    • -
    • 231 <= nums[i] <= 231 - 1
    • +
    • -231 <= nums[i] <= 231 - 1
    ### Related Topics diff --git a/problems/slowest-key/README.md b/problems/slowest-key/README.md index a40c8a33e..96e1088ff 100644 --- a/problems/slowest-key/README.md +++ b/problems/slowest-key/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-an-expression-tree-with-evaluate-function "Design an Expression Tree With Evaluate Function") diff --git a/problems/smallest-common-region/README.md b/problems/smallest-common-region/README.md index 4ab4daf57..85f65043f 100644 --- a/problems/smallest-common-region/README.md +++ b/problems/smallest-common-region/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../encode-number "Encode Number") @@ -46,12 +46,12 @@ region2 = "New York" ### Related Topics - [[Tree](../../tag/tree/README.md)] - [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Similar Questions 1. [Lowest Common Ancestor of a Binary Search Tree](../lowest-common-ancestor-of-a-binary-search-tree) (Easy) diff --git a/problems/smallest-greater-multiple-made-of-two-digits/README.md b/problems/smallest-greater-multiple-made-of-two-digits/README.md index 28004337d..2b62f9d3f 100644 --- a/problems/smallest-greater-multiple-made-of-two-digits/README.md +++ b/problems/smallest-greater-multiple-made-of-two-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../gcd-sort-of-an-array "GCD Sort of an Array") diff --git a/problems/smallest-index-with-equal-value/README.md b/problems/smallest-index-with-equal-value/README.md index c6d5572b7..580d8f059 100644 --- a/problems/smallest-index-with-equal-value/README.md +++ b/problems/smallest-index-with-equal-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-valid-move-combinations-on-chessboard "Number of Valid Move Combinations On Chessboard") diff --git a/problems/smallest-integer-divisible-by-k/README.md b/problems/smallest-integer-divisible-by-k/README.md index 6c044bdf0..295bc573d 100644 --- a/problems/smallest-integer-divisible-by-k/README.md +++ b/problems/smallest-integer-divisible-by-k/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../best-sightseeing-pair "Best Sightseeing Pair") diff --git a/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter/README.md b/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter/README.md index 78a814d9c..172effb70 100644 --- a/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter/README.md +++ b/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game-ix "Stone Game IX") diff --git a/problems/smallest-missing-genetic-value-in-each-subtree/README.md b/problems/smallest-missing-genetic-value-in-each-subtree/README.md index 46e0ba16e..0a4c2f101 100644 --- a/problems/smallest-missing-genetic-value-in-each-subtree/README.md +++ b/problems/smallest-missing-genetic-value-in-each-subtree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-product-of-the-length-of-two-palindromic-subsequences "Maximum Product of the Length of Two Palindromic Subsequences") diff --git a/problems/smallest-range-covering-elements-from-k-lists/README.md b/problems/smallest-range-covering-elements-from-k-lists/README.md index f0eef6e1d..c6b732dd2 100644 --- a/problems/smallest-range-covering-elements-from-k-lists/README.md +++ b/problems/smallest-range-covering-elements-from-k-lists/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-excel-sum-formula "Design Excel Sum Formula") diff --git a/problems/smallest-range-i/README.md b/problems/smallest-range-i/README.md index 025217ab3..124e529b4 100644 --- a/problems/smallest-range-i/README.md +++ b/problems/smallest-range-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-subarray-minimums "Sum of Subarray Minimums") diff --git a/problems/smallest-range-ii/README.md b/problems/smallest-range-ii/README.md index 8a6aaf9ed..8dbed5def 100644 --- a/problems/smallest-range-ii/README.md +++ b/problems/smallest-range-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../snakes-and-ladders "Snakes and Ladders") diff --git a/problems/smallest-string-starting-from-leaf/README.md b/problems/smallest-string-starting-from-leaf/README.md index 43b20a40a..2cacbb7f1 100644 --- a/problems/smallest-string-starting-from-leaf/README.md +++ b/problems/smallest-string-starting-from-leaf/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../vertical-order-traversal-of-a-binary-tree "Vertical Order Traversal of a Binary Tree") diff --git a/problems/smallest-string-with-a-given-numeric-value/README.md b/problems/smallest-string-with-a-given-numeric-value/README.md index 8763258c3..031de599d 100644 --- a/problems/smallest-string-with-a-given-numeric-value/README.md +++ b/problems/smallest-string-with-a-given-numeric-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-two-string-arrays-are-equivalent "Check If Two String Arrays are Equivalent") diff --git a/problems/smallest-string-with-swaps/README.md b/problems/smallest-string-with-swaps/README.md index c137301b4..4275dfbf4 100644 --- a/problems/smallest-string-with-swaps/README.md +++ b/problems/smallest-string-with-swaps/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../ugly-number-iii "Ugly Number III") @@ -60,11 +60,15 @@ Swap s[0] and s[1], s = "abc" ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] - [[String](../../tag/string/README.md)] + +### Similar Questions + 1. [Minimize Hamming Distance After Swap Operations](../minimize-hamming-distance-after-swap-operations) (Medium) + 1. [Process Restricted Friend Requests](../process-restricted-friend-requests) (Hard) ### Hints
    diff --git a/problems/smallest-subsequence-of-distinct-characters/README.md b/problems/smallest-subsequence-of-distinct-characters/README.md index 43c0c4660..8df56998f 100644 --- a/problems/smallest-subsequence-of-distinct-characters/README.md +++ b/problems/smallest-subsequence-of-distinct-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../insufficient-nodes-in-root-to-leaf-paths "Insufficient Nodes in Root to Leaf Paths") @@ -11,9 +11,7 @@ ## [1081. Smallest Subsequence of Distinct Characters (Medium)](https://leetcode.com/problems/smallest-subsequence-of-distinct-characters "不同字符的最小子序列") -

    Return the lexicographically smallest subsequence of s that contains all the distinct characters of s exactly once.

    - -

    Note: This question is the same as 316: https://leetcode.com/problems/remove-duplicate-letters/

    +

    Given a string s, return the lexicographically smallest subsequence of s that contains all the distinct characters of s exactly once.

     

    Example 1:

    @@ -38,6 +36,9 @@
  • s consists of lowercase English letters.
  • +

     

    +Note: This question is the same as 316: https://leetcode.com/problems/remove-duplicate-letters/ + ### Related Topics [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/smallest-sufficient-team/README.md b/problems/smallest-sufficient-team/README.md index cf1bd21ec..eca83514e 100644 --- a/problems/smallest-sufficient-team/README.md +++ b/problems/smallest-sufficient-team/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-well-performing-interval "Longest Well-Performing Interval") @@ -49,11 +49,15 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] +### Similar Questions + 1. [The Number of Good Subsets](../the-number-of-good-subsets) (Hard) + 1. [Minimum Number of Work Sessions to Finish the Tasks](../minimum-number-of-work-sessions-to-finish-the-tasks) (Medium) + ### Hints
    Hint 1 diff --git a/problems/solve-the-equation/README.md b/problems/solve-the-equation/README.md index 15c84e9ab..b3c314bab 100644 --- a/problems/solve-the-equation/README.md +++ b/problems/solve-the-equation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../decode-ways-ii "Decode Ways II") diff --git a/problems/sort-array-by-increasing-frequency/README.md b/problems/sort-array-by-increasing-frequency/README.md index 9c21983ff..9ed63490c 100644 --- a/problems/sort-array-by-increasing-frequency/README.md +++ b/problems/sort-array-by-increasing-frequency/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../hopper-company-queries-i "Hopper Company Queries I") @@ -51,6 +51,9 @@ [[Hash Table](../../tag/hash-table/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Sort Characters By Frequency](../sort-characters-by-frequency) (Medium) + ### Hints
    Hint 1 diff --git a/problems/sort-array-by-parity/README.md b/problems/sort-array-by-parity/README.md index ebad65e3c..62b5fbb01 100644 --- a/problems/sort-array-by-parity/README.md +++ b/problems/sort-array-by-parity/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fruit-into-baskets "Fruit Into Baskets") diff --git a/problems/sort-features-by-popularity/README.md b/problems/sort-features-by-popularity/README.md index 0964c24dd..6dd77659d 100644 --- a/problems/sort-features-by-popularity/README.md +++ b/problems/sort-features-by-popularity/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximize-palindrome-length-from-subsequences "Maximize Palindrome Length From Subsequences") @@ -19,10 +19,6 @@ [[String](../../tag/string/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Top K Frequent Elements](../top-k-frequent-elements) (Medium) - 1. [Top K Frequent Words](../top-k-frequent-words) (Medium) - ### Hints
    Hint 1 diff --git a/problems/sort-items-by-groups-respecting-dependencies/README.md b/problems/sort-items-by-groups-respecting-dependencies/README.md index b82eaa3cf..f6a849031 100644 --- a/problems/sort-items-by-groups-respecting-dependencies/README.md +++ b/problems/sort-items-by-groups-respecting-dependencies/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-string-with-swaps "Smallest String With Swaps") diff --git a/problems/sort-linked-list-already-sorted-using-absolute-values/README.md b/problems/sort-linked-list-already-sorted-using-absolute-values/README.md index ea2daefe8..787f6c9e5 100644 --- a/problems/sort-linked-list-already-sorted-using-absolute-values/README.md +++ b/problems/sort-linked-list-already-sorted-using-absolute-values/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../second-minimum-time-to-reach-destination "Second Minimum Time to Reach Destination") diff --git a/problems/sort-the-matrix-diagonally/README.md b/problems/sort-the-matrix-diagonally/README.md index de6bdde4e..2105b4213 100644 --- a/problems/sort-the-matrix-diagonally/README.md +++ b/problems/sort-the-matrix-diagonally/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../break-a-palindrome "Break a Palindrome") @@ -42,8 +42,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] - [[Matrix](../../tag/matrix/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/sorting-the-sentence/README.md b/problems/sorting-the-sentence/README.md index 5a48c1d7e..bf34188c7 100644 --- a/problems/sorting-the-sentence/README.md +++ b/problems/sorting-the-sentence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-word-with-all-prefixes "Longest Word With All Prefixes") diff --git a/problems/soup-servings/README.md b/problems/soup-servings/README.md index 1ec57cf30..f49525fb8 100644 --- a/problems/soup-servings/README.md +++ b/problems/soup-servings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-increase-to-keep-city-skyline "Max Increase to Keep City Skyline") diff --git a/problems/sparse-matrix-multiplication/README.md b/problems/sparse-matrix-multiplication/README.md index 6679df3d3..3656b4858 100644 --- a/problems/sparse-matrix-multiplication/README.md +++ b/problems/sparse-matrix-multiplication/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-height-trees "Minimum Height Trees") diff --git a/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md b/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md index ee02ba5e1..421305253 100644 --- a/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md +++ b/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sellers-with-no-sales "Sellers With No Sales") diff --git a/problems/special-positions-in-a-binary-matrix/README.md b/problems/special-positions-in-a-binary-matrix/README.md index 36f6711a1..a3e5ee837 100644 --- a/problems/special-positions-in-a-binary-matrix/README.md +++ b/problems/special-positions-in-a-binary-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../customer-who-visited-but-did-not-make-any-transactions "Customer Who Visited but Did Not Make Any Transactions") diff --git a/problems/spiral-matrix/README.md b/problems/spiral-matrix/README.md index c1b018a6b..90e6207f2 100644 --- a/problems/spiral-matrix/README.md +++ b/problems/spiral-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-subarray "Maximum Subarray") diff --git a/problems/split-a-string-in-balanced-strings/README.md b/problems/split-a-string-in-balanced-strings/README.md index 949a4f46d..e2cb832da 100644 --- a/problems/split-a-string-in-balanced-strings/README.md +++ b/problems/split-a-string-in-balanced-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-vowels-permutation "Count Vowels Permutation") diff --git a/problems/split-a-string-into-the-max-number-of-unique-substrings/README.md b/problems/split-a-string-into-the-max-number-of-unique-substrings/README.md index 0006e7742..1bdc20e26 100644 --- a/problems/split-a-string-into-the-max-number-of-unique-substrings/README.md +++ b/problems/split-a-string-into-the-max-number-of-unique-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rearrange-spaces-between-words "Rearrange Spaces Between Words") diff --git a/problems/split-array-into-consecutive-subsequences/README.md b/problems/split-array-into-consecutive-subsequences/README.md index 7487fd286..26dc3b3e0 100644 --- a/problems/split-array-into-consecutive-subsequences/README.md +++ b/problems/split-array-into-consecutive-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-k-closest-elements "Find K Closest Elements") diff --git a/problems/split-array-into-fibonacci-sequence/README.md b/problems/split-array-into-fibonacci-sequence/README.md index 8e3310bea..bf63e8c47 100644 --- a/problems/split-array-into-fibonacci-sequence/README.md +++ b/problems/split-array-into-fibonacci-sequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../keys-and-rooms "Keys and Rooms") diff --git a/problems/split-bst/README.md b/problems/split-bst/README.md index 69e6d4f6b..143d477ad 100644 --- a/problems/split-bst/README.md +++ b/problems/split-bst/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../global-and-local-inversions "Global and Local Inversions") diff --git a/problems/split-two-strings-to-make-palindrome/README.md b/problems/split-two-strings-to-make-palindrome/README.md index 0077e76a5..8684258eb 100644 --- a/problems/split-two-strings-to-make-palindrome/README.md +++ b/problems/split-two-strings-to-make-palindrome/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximal-network-rank "Maximal Network Rank") diff --git a/problems/splitting-a-string-into-descending-consecutive-values/README.md b/problems/splitting-a-string-into-descending-consecutive-values/README.md index a371b2796..936b7ddf8 100644 --- a/problems/splitting-a-string-into-descending-consecutive-values/README.md +++ b/problems/splitting-a-string-into-descending-consecutive-values/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-distance-to-the-target-element "Minimum Distance to the Target Element") diff --git a/problems/squirrel-simulation/README.md b/problems/squirrel-simulation/README.md index 49ddc5a3e..dcb935bcb 100644 --- a/problems/squirrel-simulation/README.md +++ b/problems/squirrel-simulation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../subtree-of-another-tree "Subtree of Another Tree") diff --git a/problems/stickers-to-spell-word/README.md b/problems/stickers-to-spell-word/README.md index 4612eabd5..344c35177 100644 --- a/problems/stickers-to-spell-word/README.md +++ b/problems/stickers-to-spell-word/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../employee-importance "Employee Importance") diff --git a/problems/stock-price-fluctuation/README.md b/problems/stock-price-fluctuation/README.md index 49dacf30f..85f72ad28 100644 --- a/problems/stock-price-fluctuation/README.md +++ b/problems/stock-price-fluctuation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-operations-to-make-a-uni-value-grid "Minimum Operations to Make a Uni-Value Grid") diff --git a/problems/stone-game-iv/README.md b/problems/stone-game-iv/README.md index 5777800a0..e54c3fc94 100644 --- a/problems/stone-game-iv/README.md +++ b/problems/stone-game-iv/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-difference-between-largest-and-smallest-value-in-three-moves "Minimum Difference Between Largest and Smallest Value in Three Moves") diff --git a/problems/stone-game-ix/README.md b/problems/stone-game-ix/README.md index 543ba198a..d3a199649 100644 --- a/problems/stone-game-ix/README.md +++ b/problems/stone-game-ix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-missing-observations "Find Missing Observations") diff --git a/problems/stone-game-v/README.md b/problems/stone-game-v/README.md index 018a99134..79aa9c07c 100644 --- a/problems/stone-game-v/README.md +++ b/problems/stone-game-v/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-latest-group-of-size-m "Find Latest Group of Size M") @@ -11,9 +11,9 @@ ## [1563. Stone Game V (Hard)](https://leetcode.com/problems/stone-game-v "石子游戏 V") -

    There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.

    +

    There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.

    -

    In each round of the game, Alice divides the row into two non-empty rows (i.e. left row and right row), then Bob calculates the value of each row which is the sum of the values of all the stones in this row. Bob throws away the row which has the maximum value, and Alice's score increases by the value of the remaining row. If the value of the two rows are equal, Bob lets Alice decide which row will be thrown away. The next round starts with the remaining row.

    +

    In each round of the game, Alice divides the row into two non-empty rows (i.e. left row and right row), then Bob calculates the value of each row which is the sum of the values of all the stones in this row. Bob throws away the row which has the maximum value, and Alice's score increases by the value of the remaining row. If the value of the two rows are equal, Bob lets Alice decide which row will be thrown away. The next round starts with the remaining row.

    The game ends when there is only one stone remaining. Alice's is initially zero.

    @@ -49,7 +49,7 @@ The last round Alice has only one choice to divide the row which is [2], [3]. Bo
    • 1 <= stoneValue.length <= 500
    • -
    • 1 <= stoneValue[i] <= 10^6
    • +
    • 1 <= stoneValue[i] <= 106
    ### Related Topics diff --git a/problems/stone-game-vi/README.md b/problems/stone-game-vi/README.md index 4295171bb..5d868a7e1 100644 --- a/problems/stone-game-vi/README.md +++ b/problems/stone-game-vi/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-absolute-differences-in-a-sorted-array "Sum of Absolute Differences in a Sorted Array") @@ -70,22 +70,12 @@ Bob wins. ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Greedy](../../tag/greedy/README.md)] + [[Game Theory](../../tag/game-theory/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] - [[Game Theory](../../tag/game-theory/README.md)] - -### Similar Questions - 1. [Stone Game](../stone-game) (Medium) - 1. [Stone Game II](../stone-game-ii) (Medium) - 1. [Stone Game III](../stone-game-iii) (Hard) - 1. [Stone Game IV](../stone-game-iv) (Hard) - 1. [Stone Game V](../stone-game-v) (Hard) - 1. [Stone Game VII](../stone-game-vii) (Medium) - 1. [Stone Game VIII](../stone-game-viii) (Hard) - 1. [Stone Game IX](../stone-game-ix) (Medium) ### Hints
    diff --git a/problems/stone-game-vii/README.md b/problems/stone-game-vii/README.md index c2614f1d6..c84453367 100644 --- a/problems/stone-game-vii/README.md +++ b/problems/stone-game-vii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../partitioning-into-minimum-number-of-deci-binary-numbers "Partitioning Into Minimum Number Of Deci-Binary Numbers") @@ -55,6 +55,17 @@ The score difference is 18 - 12 = 6. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Game Theory](../../tag/game-theory/README.md)] +### Similar Questions + 1. [Stone Game](../stone-game) (Medium) + 1. [Stone Game II](../stone-game-ii) (Medium) + 1. [Stone Game III](../stone-game-iii) (Hard) + 1. [Stone Game IV](../stone-game-iv) (Hard) + 1. [Stone Game V](../stone-game-v) (Hard) + 1. [Stone Game VI](../stone-game-vi) (Medium) + 1. [Maximum Score from Performing Multiplication Operations](../maximum-score-from-performing-multiplication-operations) (Medium) + 1. [Stone Game VIII](../stone-game-viii) (Hard) + 1. [Stone Game IX](../stone-game-ix) (Medium) + ### Hints
    Hint 1 diff --git a/problems/stone-game-viii/README.md b/problems/stone-game-viii/README.md index 45ec75bbc..5fa74e2c5 100644 --- a/problems/stone-game-viii/README.md +++ b/problems/stone-game-viii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../jump-game-vii "Jump Game VII") diff --git a/problems/strange-printer-ii/README.md b/problems/strange-printer-ii/README.md index d352ac2dd..efef2f8b8 100644 --- a/problems/strange-printer-ii/README.md +++ b/problems/strange-printer-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../make-sum-divisible-by-p "Make Sum Divisible by P") diff --git a/problems/strange-printer/README.md b/problems/strange-printer/README.md index 2d6df9e37..c94739d6a 100644 --- a/problems/strange-printer/README.md +++ b/problems/strange-printer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../equal-tree-partition "Equal Tree Partition") diff --git a/problems/string-compression-ii/README.md b/problems/string-compression-ii/README.md index 9929ee6c8..5fb6dc2db 100644 --- a/problems/string-compression-ii/README.md +++ b/problems/string-compression-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-good-leaf-nodes-pairs "Number of Good Leaf Nodes Pairs") diff --git a/problems/string-transforms-into-another-string/README.md b/problems/string-transforms-into-another-string/README.md index a3e6c6cf3..4e1724a91 100644 --- a/problems/string-transforms-into-another-string/README.md +++ b/problems/string-transforms-into-another-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../analyze-user-website-visit-pattern "Analyze User Website Visit Pattern") diff --git a/problems/strings-differ-by-one-character/README.md b/problems/strings-differ-by-one-character/README.md index 6fea70d9f..16a62cb47 100644 --- a/problems/strings-differ-by-one-character/README.md +++ b/problems/strings-differ-by-one-character/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-days-to-eat-n-oranges "Minimum Number of Days to Eat N Oranges") @@ -16,8 +16,8 @@ ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Hash Function](../../tag/hash-function/README.md)] [[Rolling Hash](../../tag/rolling-hash/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Hints
    diff --git a/problems/strobogrammatic-number-ii/README.md b/problems/strobogrammatic-number-ii/README.md index f40c678c5..b6bd42690 100644 --- a/problems/strobogrammatic-number-ii/README.md +++ b/problems/strobogrammatic-number-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../strobogrammatic-number "Strobogrammatic Number") @@ -30,6 +30,7 @@ ### Similar Questions 1. [Strobogrammatic Number](../strobogrammatic-number) (Easy) 1. [Strobogrammatic Number III](../strobogrammatic-number-iii) (Hard) + 1. [Sum of k-Mirror Numbers](../sum-of-k-mirror-numbers) (Hard) ### Hints
    diff --git a/problems/strong-friendship/README.md b/problems/strong-friendship/README.md index 8be710f81..d02716190 100644 --- a/problems/strong-friendship/README.md +++ b/problems/strong-friendship/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-duplicate-folders-in-system "Delete Duplicate Folders in System") diff --git a/problems/strong-password-checker/README.md b/problems/strong-password-checker/README.md index 5bcd0b817..e52efecb5 100644 --- a/problems/strong-password-checker/README.md +++ b/problems/strong-password-checker/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../battleships-in-a-board "Battleships in a Board") @@ -49,6 +49,6 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/student-attendance-record-i/README.md b/problems/student-attendance-record-i/README.md index e360626a9..edbe92853 100644 --- a/problems/student-attendance-record-i/README.md +++ b/problems/student-attendance-record-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../game-play-analysis-iv "Game Play Analysis IV") diff --git a/problems/students-and-examinations/README.md b/problems/students-and-examinations/README.md index 7247b28a6..e9b327fe4 100644 --- a/problems/students-and-examinations/README.md +++ b/problems/students-and-examinations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../traffic-light-controlled-intersection "Traffic Light Controlled Intersection") diff --git a/problems/students-report-by-geography/README.md b/problems/students-report-by-geography/README.md index 73a5919e9..1d661e8f6 100644 --- a/problems/students-report-by-geography/README.md +++ b/problems/students-report-by-geography/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../merge-two-binary-trees "Merge Two Binary Trees") diff --git a/problems/students-report-by-geography/mysql_schemas.sql b/problems/students-report-by-geography/mysql_schemas.sql index d3da4c6a5..271a37487 100644 --- a/problems/students-report-by-geography/mysql_schemas.sql +++ b/problems/students-report-by-geography/mysql_schemas.sql @@ -1,6 +1,6 @@ -Create table If Not Exists student (name varchar(50), continent varchar(7)); -Truncate table student; -insert into student (name, continent) values ('Jane', 'America'); -insert into student (name, continent) values ('Pascal', 'Europe'); -insert into student (name, continent) values ('Xi', 'Asia'); -insert into student (name, continent) values ('Jack', 'America'); +Create table If Not Exists Student (name varchar(50), continent varchar(7)); +Truncate table Student; +insert into Student (name, continent) values ('Jane', 'America'); +insert into Student (name, continent) values ('Pascal', 'Europe'); +insert into Student (name, continent) values ('Xi', 'Asia'); +insert into Student (name, continent) values ('Jack', 'America'); diff --git a/problems/students-with-invalid-departments/README.md b/problems/students-with-invalid-departments/README.md index 19cb5a74c..ea308e0fa 100644 --- a/problems/students-with-invalid-departments/README.md +++ b/problems/students-with-invalid-departments/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-students-taking-exam "Maximum Students Taking Exam") diff --git a/problems/subdomain-visit-count/README.md b/problems/subdomain-visit-count/README.md index 846e45858..700b534f3 100644 --- a/problems/subdomain-visit-count/README.md +++ b/problems/subdomain-visit-count/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../chalkboard-xor-game "Chalkboard XOR Game") diff --git a/problems/subrectangle-queries/README.md b/problems/subrectangle-queries/README.md index 3f4bd973f..fd1f45944 100644 --- a/problems/subrectangle-queries/README.md +++ b/problems/subrectangle-queries/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../final-prices-with-a-special-discount-in-a-shop "Final Prices With a Special Discount in a Shop") @@ -94,8 +94,8 @@ subrectangleQueries.getValue(2, 2); // return 20 ### Related Topics - [[Array](../../tag/array/README.md)] [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/substring-with-concatenation-of-all-words/README.md b/problems/substring-with-concatenation-of-all-words/README.md index 29eca0990..a24d4771a 100644 --- a/problems/substring-with-concatenation-of-all-words/README.md +++ b/problems/substring-with-concatenation-of-all-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../divide-two-integers "Divide Two Integers") diff --git a/problems/substrings-of-size-three-with-distinct-characters/README.md b/problems/substrings-of-size-three-with-distinct-characters/README.md index 84a9ab14d..ee678eb6c 100644 --- a/problems/substrings-of-size-three-with-distinct-characters/README.md +++ b/problems/substrings-of-size-three-with-distinct-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../group-employees-of-the-same-salary "Group Employees of the Same Salary") @@ -49,8 +49,8 @@ The good substrings are "abc", "bca", "cab", and & ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Counting](../../tag/counting/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/substrings-that-begin-and-end-with-the-same-letter/README.md b/problems/substrings-that-begin-and-end-with-the-same-letter/README.md new file mode 100644 index 000000000..d3d18e50a --- /dev/null +++ b/problems/substrings-that-begin-and-end-with-the-same-letter/README.md @@ -0,0 +1,40 @@ + + + + + + + +[< Previous](../the-number-of-rich-customers "The Number of Rich Customers") +                 +[Next >](../drop-type-1-orders-for-customers-with-type-0-orders "Drop Type 1 Orders for Customers With Type 0 Orders") + +## [2083. Substrings That Begin and End With the Same Letter (Medium)](https://leetcode.com/problems/substrings-that-begin-and-end-with-the-same-letter "") + + + +### Hints +
    +Hint 1 +In the string "abacad", the letter "a" appears 3 times. How many substrings begin with the first "a" and end with any "a"? +
    + +
    +Hint 2 +There are 3 substrings ("a", "aba", and "abaca"). How many substrings begin with the second "a" and end with any "a"? How about the third? +
    + +
    +Hint 3 +2 substrings begin with the second "a" ("a", and "aca") and 1 substring begins with the third "a" ("a"). +
    + +
    +Hint 4 +There is a total of 3 + 2 + 1 = 6 substrings that begin and end with "a". +
    + +
    +Hint 5 +If a character appears i times in the string, there are i * (i + 1) / 2 substrings that begin and end with that character. +
    diff --git a/problems/subtract-the-product-and-sum-of-digits-of-an-integer/README.md b/problems/subtract-the-product-and-sum-of-digits-of-an-integer/README.md index e4546b616..bff43a94f 100644 --- a/problems/subtract-the-product-and-sum-of-digits-of-an-integer/README.md +++ b/problems/subtract-the-product-and-sum-of-digits-of-an-integer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../students-and-examinations "Students and Examinations") diff --git a/problems/subtree-removal-game-with-fibonacci-tree/README.md b/problems/subtree-removal-game-with-fibonacci-tree/README.md index bb7bf2a9e..07cd9d6f4 100644 --- a/problems/subtree-removal-game-with-fibonacci-tree/README.md +++ b/problems/subtree-removal-game-with-fibonacci-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-number-of-seniors-and-juniors-to-join-the-company "The Number of Seniors and Juniors to Join the Company") diff --git a/problems/sum-game/README.md b/problems/sum-game/README.md index fc9526ea6..013d6e38e 100644 --- a/problems/sum-game/README.md +++ b/problems/sum-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../nearest-exit-from-entrance-in-maze "Nearest Exit from Entrance in Maze") diff --git a/problems/sum-of-absolute-differences-in-a-sorted-array/README.md b/problems/sum-of-absolute-differences-in-a-sorted-array/README.md index 203d0d8ac..8d6a3c30c 100644 --- a/problems/sum-of-absolute-differences-in-a-sorted-array/README.md +++ b/problems/sum-of-absolute-differences-in-a-sorted-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-the-number-of-consistent-strings "Count the Number of Consistent Strings") diff --git a/problems/sum-of-all-odd-length-subarrays/README.md b/problems/sum-of-all-odd-length-subarrays/README.md index 33302a523..89cc61509 100644 --- a/problems/sum-of-all-odd-length-subarrays/README.md +++ b/problems/sum-of-all-odd-length-subarrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../bank-account-summary-ii "Bank Account Summary II") diff --git a/problems/sum-of-all-subset-xor-totals/README.md b/problems/sum-of-all-subset-xor-totals/README.md index be0743994..1fa7a407f 100644 --- a/problems/sum-of-all-subset-xor-totals/README.md +++ b/problems/sum-of-all-subset-xor-totals/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-floored-pairs "Sum of Floored Pairs") diff --git a/problems/sum-of-beauty-in-the-array/README.md b/problems/sum-of-beauty-in-the-array/README.md index 09e6a56b5..f6a1c02c1 100644 --- a/problems/sum-of-beauty-in-the-array/README.md +++ b/problems/sum-of-beauty-in-the-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../final-value-of-variable-after-performing-operations "Final Value of Variable After Performing Operations") diff --git a/problems/sum-of-beauty-of-all-substrings/README.md b/problems/sum-of-beauty-of-all-substrings/README.md index 1d2667a17..8e5cea5de 100644 --- a/problems/sum-of-beauty-of-all-substrings/README.md +++ b/problems/sum-of-beauty-of-all-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-number-is-a-sum-of-powers-of-three "Check if Number is a Sum of Powers of Three") diff --git a/problems/sum-of-digits-in-base-k/README.md b/problems/sum-of-digits-in-base-k/README.md index 709e3d543..8ae9cb78f 100644 --- a/problems/sum-of-digits-in-base-k/README.md +++ b/problems/sum-of-digits-in-base-k/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-duplicates-from-an-unsorted-linked-list "Remove Duplicates From an Unsorted Linked List") diff --git a/problems/sum-of-digits-of-string-after-convert/README.md b/problems/sum-of-digits-of-string-after-convert/README.md index 9e5090d5b..a8fba598f 100644 --- a/problems/sum-of-digits-of-string-after-convert/README.md +++ b/problems/sum-of-digits-of-string-after-convert/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-visible-people-in-a-queue "Number of Visible People in a Queue") diff --git a/problems/sum-of-even-numbers-after-queries/README.md b/problems/sum-of-even-numbers-after-queries/README.md index d10a592e5..392687112 100644 --- a/problems/sum-of-even-numbers-after-queries/README.md +++ b/problems/sum-of-even-numbers-after-queries/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../string-without-aaa-or-bbb "String Without AAA or BBB") diff --git a/problems/sum-of-floored-pairs/README.md b/problems/sum-of-floored-pairs/README.md index 84a0bad5d..10d72bc34 100644 --- a/problems/sum-of-floored-pairs/README.md +++ b/problems/sum-of-floored-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rotating-the-box "Rotating the Box") diff --git a/problems/sum-of-k-mirror-numbers/README.md b/problems/sum-of-k-mirror-numbers/README.md new file mode 100644 index 000000000..3d18182e4 --- /dev/null +++ b/problems/sum-of-k-mirror-numbers/README.md @@ -0,0 +1,93 @@ + + + + + + + +[< Previous](../range-frequency-queries "Range Frequency Queries") +                 +[Next >](../the-number-of-rich-customers "The Number of Rich Customers") + +## [2081. Sum of k-Mirror Numbers (Hard)](https://leetcode.com/problems/sum-of-k-mirror-numbers "k 镜像数字的和") + +

    A k-mirror number is a positive integer without leading zeros that reads the same both forward and backward in base-10 as well as in base-k.

    + +
      +
    • For example, 9 is a 2-mirror number. The representation of 9 in base-10 and base-2 are 9 and 1001 respectively, which read the same both forward and backward.
    • +
    • On the contrary, 4 is not a 2-mirror number. The representation of 4 in base-2 is 100, which does not read the same both forward and backward.
    • +
    + +

    Given the base k and the number n, return the sum of the n smallest k-mirror numbers.

    + +

     

    +

    Example 1:

    + +
    +Input: k = 2, n = 5
    +Output: 25
    +Explanation:
    +The 5 smallest 2-mirror numbers and their representations in base-2 are listed as follows:
    +  base-10    base-2
    +    1          1
    +    3          11
    +    5          101
    +    7          111
    +    9          1001
    +Their sum = 1 + 3 + 5 + 7 + 9 = 25. 
    +
    + +

    Example 2:

    + +
    +Input: k = 3, n = 7
    +Output: 499
    +Explanation:
    +The 7 smallest 3-mirror numbers are and their representations in base-3 are listed as follows:
    +  base-10    base-3
    +    1          1
    +    2          2
    +    4          11
    +    8          22
    +    121        11111
    +    151        12121
    +    212        21212
    +Their sum = 1 + 2 + 4 + 8 + 121 + 151 + 212 = 499.
    +
    + +

    Example 3:

    + +
    +Input: k = 7, n = 17
    +Output: 20379000
    +Explanation: The 17 smallest 7-mirror numbers are:
    +1, 2, 3, 4, 5, 6, 8, 121, 171, 242, 292, 16561, 65656, 2137312, 4602064, 6597956, 6958596
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= k <= 9
    • +
    • 1 <= n <= 30
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + +### Hints +
    +Hint 1 +Since we need to reduce search space, instead of checking if every number is a palindrome in base-10, can we try to "generate" the palindromic numbers? +
    + +
    +Hint 2 +If you are provided with a d digit number, how can you generate a palindrome with 2*d or 2*d - 1 digit? +
    + +
    +Hint 3 +Try brute-forcing and checking if the palindrome you generated is a "k-Mirror" number. +
    diff --git a/problems/sum-of-mutated-array-closest-to-target/README.md b/problems/sum-of-mutated-array-closest-to-target/README.md index 140b8fb86..490eaebb2 100644 --- a/problems/sum-of-mutated-array-closest-to-target/README.md +++ b/problems/sum-of-mutated-array-closest-to-target/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../replace-elements-with-greatest-element-on-right-side "Replace Elements with Greatest Element on Right Side") diff --git a/problems/sum-of-nodes-with-even-valued-grandparent/README.md b/problems/sum-of-nodes-with-even-valued-grandparent/README.md index 2a0c7f7ed..fdcf237f6 100644 --- a/problems/sum-of-nodes-with-even-valued-grandparent/README.md +++ b/problems/sum-of-nodes-with-even-valued-grandparent/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../matrix-block-sum "Matrix Block Sum") diff --git a/problems/sum-of-root-to-leaf-binary-numbers/README.md b/problems/sum-of-root-to-leaf-binary-numbers/README.md index 8ea2c7e73..b74243c58 100644 --- a/problems/sum-of-root-to-leaf-binary-numbers/README.md +++ b/problems/sum-of-root-to-leaf-binary-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-outermost-parentheses "Remove Outermost Parentheses") diff --git a/problems/sum-of-special-evenly-spaced-elements-in-array/README.md b/problems/sum-of-special-evenly-spaced-elements-in-array/README.md index 8ce6a2aaf..0ef13bf98 100644 --- a/problems/sum-of-special-evenly-spaced-elements-in-array/README.md +++ b/problems/sum-of-special-evenly-spaced-elements-in-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-operations-to-make-a-subsequence "Minimum Operations to Make a Subsequence") diff --git a/problems/sum-of-square-numbers/README.md b/problems/sum-of-square-numbers/README.md index f4a3e2a16..1a6589b9a 100644 --- a/problems/sum-of-square-numbers/README.md +++ b/problems/sum-of-square-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-range-covering-elements-from-k-lists "Smallest Range Covering Elements from K Lists") diff --git a/problems/sum-of-unique-elements/README.md b/problems/sum-of-unique-elements/README.md index 869dd2a26..b4d997c06 100644 --- a/problems/sum-of-unique-elements/README.md +++ b/problems/sum-of-unique-elements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../leetflex-banned-accounts "Leetflex Banned Accounts") diff --git a/problems/sum-root-to-leaf-numbers/README.md b/problems/sum-root-to-leaf-numbers/README.md index 5421831d0..808108913 100644 --- a/problems/sum-root-to-leaf-numbers/README.md +++ b/problems/sum-root-to-leaf-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-consecutive-sequence "Longest Consecutive Sequence") diff --git a/problems/super-palindromes/README.md b/problems/super-palindromes/README.md index e48447ffa..85d5a43b7 100644 --- a/problems/super-palindromes/README.md +++ b/problems/super-palindromes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-array-by-parity "Sort Array By Parity") diff --git a/problems/super-ugly-number/README.md b/problems/super-ugly-number/README.md index 2e149110e..ab12d29e0 100644 --- a/problems/super-ugly-number/README.md +++ b/problems/super-ugly-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../burst-balloons "Burst Balloons") diff --git a/problems/super-washing-machines/README.md b/problems/super-washing-machines/README.md index 27d42a2d7..4fcb527d0 100644 --- a/problems/super-washing-machines/README.md +++ b/problems/super-washing-machines/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-palindromic-subsequence "Longest Palindromic Subsequence") diff --git a/problems/surrounded-regions/README.md b/problems/surrounded-regions/README.md index 46f86f00e..b0fdb237d 100644 --- a/problems/surrounded-regions/README.md +++ b/problems/surrounded-regions/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-root-to-leaf-numbers "Sum Root to Leaf Numbers") diff --git a/problems/suspicious-bank-accounts/README.md b/problems/suspicious-bank-accounts/README.md index e76384a0c..5d8cdf1ff 100644 --- a/problems/suspicious-bank-accounts/README.md +++ b/problems/suspicious-bank-accounts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../next-palindrome-using-same-digits "Next Palindrome Using Same Digits") diff --git a/problems/swap-for-longest-repeated-character-substring/README.md b/problems/swap-for-longest-repeated-character-substring/README.md index 0d76e2af0..117c95cdd 100644 --- a/problems/swap-for-longest-repeated-character-substring/README.md +++ b/problems/swap-for-longest-repeated-character-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-dice-rolls-with-target-sum "Number of Dice Rolls With Target Sum") diff --git a/problems/swap-nodes-in-pairs/README.md b/problems/swap-nodes-in-pairs/README.md index 698a6f723..25b2d137f 100644 --- a/problems/swap-nodes-in-pairs/README.md +++ b/problems/swap-nodes-in-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../merge-k-sorted-lists "Merge k Sorted Lists") @@ -44,8 +44,9 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions 1. [Reverse Nodes in k-Group](../reverse-nodes-in-k-group) (Hard) + 1. [Swapping Nodes in a Linked List](../swapping-nodes-in-a-linked-list) (Medium) diff --git a/problems/swap-salary/README.md b/problems/swap-salary/README.md index d81d80e0c..3f9a113dc 100644 --- a/problems/swap-salary/README.md +++ b/problems/swap-salary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../exchange-seats "Exchange Seats") @@ -29,15 +29,17 @@ The table contains information about an employee.

     

    -

    Write an SQL query to swap all 'f' and 'm' values (i.e., change all 'f' values to 'm' and vice versa) with a single update statement and no intermediate temp table(s).

    +

    Write an SQL query to swap all 'f' and 'm' values (i.e., change all 'f' values to 'm' and vice versa) with a single update statement and no intermediate temporary tables.

    -

    Note that you must write a single update statement, DO NOT write any select statement for this problem.

    +

    Note that you must write a single update statement, do not write any select statement for this problem.

    -

    The query result format is in the following example:

    +

    The query result format is in the following example.

     

    +

    Example 1:

    +Input: 
     Salary table:
     +----+------+-----+--------+
     | id | name | sex | salary |
    @@ -47,8 +49,7 @@ Salary table:
     | 3  | C    | m   | 5500   |
     | 4  | D    | f   | 500    |
     +----+------+-----+--------+
    -
    -Result table:
    +Output: 
     +----+------+-----+--------+
     | id | name | sex | salary |
     +----+------+-----+--------+
    @@ -57,6 +58,7 @@ Result table:
     | 3  | C    | f   | 5500   |
     | 4  | D    | m   | 500    |
     +----+------+-----+--------+
    +Explanation: 
     (1, A) and (3, C) were changed from 'm' to 'f'.
     (2, B) and (4, D) were changed from 'f' to 'm'.
     
    diff --git a/problems/swap-salary/mysql_schemas.sql b/problems/swap-salary/mysql_schemas.sql index ba43d5f9b..dd8dccfe3 100644 --- a/problems/swap-salary/mysql_schemas.sql +++ b/problems/swap-salary/mysql_schemas.sql @@ -1,4 +1,4 @@ -create table if not exists salary(id int, name varchar(100), sex char(1), salary int); +Create table If Not Exists Salary (id int, name varchar(100), sex char(1), salary int); Truncate table salary; insert into salary (id, name, sex, salary) values ('1', 'A', 'm', '2500'); insert into salary (id, name, sex, salary) values ('2', 'B', 'f', '1500'); diff --git a/problems/swapping-nodes-in-a-linked-list/README.md b/problems/swapping-nodes-in-a-linked-list/README.md index c5d03018f..6ec21a3ad 100644 --- a/problems/swapping-nodes-in-a-linked-list/README.md +++ b/problems/swapping-nodes-in-a-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../decode-xored-array "Decode XORed Array") diff --git a/problems/swim-in-rising-water/README.md b/problems/swim-in-rising-water/README.md index 8022b876b..b70685f53 100644 --- a/problems/swim-in-rising-water/README.md +++ b/problems/swim-in-rising-water/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../swap-adjacent-in-lr-string "Swap Adjacent in LR String") diff --git a/problems/tag-validator/README.md b/problems/tag-validator/README.md index ece5590a6..f210a6fe3 100644 --- a/problems/tag-validator/README.md +++ b/problems/tag-validator/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../n-ary-tree-postorder-traversal "N-ary Tree Postorder Traversal") diff --git a/problems/task-scheduler/README.md b/problems/task-scheduler/README.md index 553d94755..1b9a40e12 100644 --- a/problems/task-scheduler/README.md +++ b/problems/task-scheduler/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../not-boring-movies "Not Boring Movies") diff --git a/problems/team-scores-in-football-tournament/README.md b/problems/team-scores-in-football-tournament/README.md index a177899e6..ea77aa03e 100644 --- a/problems/team-scores-in-football-tournament/README.md +++ b/problems/team-scores-in-football-tournament/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../queries-quality-and-percentage "Queries Quality and Percentage") diff --git a/problems/teemo-attacking/README.md b/problems/teemo-attacking/README.md index 96399dae9..2698808e4 100644 --- a/problems/teemo-attacking/README.md +++ b/problems/teemo-attacking/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../target-sum "Target Sum") diff --git a/problems/tenth-line/README.md b/problems/tenth-line/README.md index ef6093c1d..83cca284d 100644 --- a/problems/tenth-line/README.md +++ b/problems/tenth-line/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../transpose-file "Transpose File") diff --git a/problems/ternary-expression-parser/README.md b/problems/ternary-expression-parser/README.md index cee11673f..9ada653a3 100644 --- a/problems/ternary-expression-parser/README.md +++ b/problems/ternary-expression-parser/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-all-anagrams-in-a-string "Find All Anagrams in a String") @@ -65,9 +65,9 @@

    ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Recursion](../../tag/recursion/README.md)] - [[String](../../tag/string/README.md)] ### Similar Questions 1. [Mini Parser](../mini-parser) (Medium) diff --git a/problems/the-category-of-each-member-in-the-store/README.md b/problems/the-category-of-each-member-in-the-store/README.md index 7de23d89c..2f2569f3c 100644 --- a/problems/the-category-of-each-member-in-the-store/README.md +++ b/problems/the-category-of-each-member-in-the-store/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../parallel-courses-iii "Parallel Courses III") diff --git a/problems/the-dining-philosophers/README.md b/problems/the-dining-philosophers/README.md index 7736dfd1b..8199b4c4e 100644 --- a/problems/the-dining-philosophers/README.md +++ b/problems/the-dining-philosophers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../report-contiguous-dates "Report Contiguous Dates") diff --git a/problems/the-earliest-and-latest-rounds-where-players-compete/README.md b/problems/the-earliest-and-latest-rounds-where-players-compete/README.md index 3ac0a467c..21a5d1e92 100644 --- a/problems/the-earliest-and-latest-rounds-where-players-compete/README.md +++ b/problems/the-earliest-and-latest-rounds-where-players-compete/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../merge-triplets-to-form-target-triplet "Merge Triplets to Form Target Triplet") diff --git a/problems/the-earliest-moment-when-everyone-become-friends/README.md b/problems/the-earliest-moment-when-everyone-become-friends/README.md index c9fbad8c2..5dd41821e 100644 --- a/problems/the-earliest-moment-when-everyone-become-friends/README.md +++ b/problems/the-earliest-moment-when-everyone-become-friends/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-k-length-substrings-with-no-repeated-characters "Find K-Length Substrings With No Repeated Characters") diff --git a/problems/the-k-strongest-values-in-an-array/README.md b/problems/the-k-strongest-values-in-an-array/README.md index 944e8d4cd..2249537cb 100644 --- a/problems/the-k-strongest-values-in-an-array/README.md +++ b/problems/the-k-strongest-values-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shuffle-the-array "Shuffle the Array") diff --git a/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/README.md b/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/README.md index b65772ab3..099a3b76a 100644 --- a/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/README.md +++ b/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k "Find the Minimum Number of Fibonacci Numbers Whose Sum Is K") diff --git a/problems/the-k-weakest-rows-in-a-matrix/README.md b/problems/the-k-weakest-rows-in-a-matrix/README.md index 7b28b9018..7c502a569 100644 --- a/problems/the-k-weakest-rows-in-a-matrix/README.md +++ b/problems/the-k-weakest-rows-in-a-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-transactions-per-visit "Number of Transactions per Visit") diff --git a/problems/the-kth-factor-of-n/README.md b/problems/the-kth-factor-of-n/README.md index a375f78b4..50dfaa95a 100644 --- a/problems/the-kth-factor-of-n/README.md +++ b/problems/the-kth-factor-of-n/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../average-salary-excluding-the-minimum-and-maximum-salary "Average Salary Excluding the Minimum and Maximum Salary") diff --git a/problems/the-latest-login-in-2020/README.md b/problems/the-latest-login-in-2020/README.md index eb9ffbf02..09cab9b9a 100644 --- a/problems/the-latest-login-in-2020/README.md +++ b/problems/the-latest-login-in-2020/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-space-wasted-from-packaging "Minimum Space Wasted From Packaging") diff --git a/problems/the-maze-ii/README.md b/problems/the-maze-ii/README.md index 12ba31289..d9bc886f6 100644 --- a/problems/the-maze-ii/README.md +++ b/problems/the-maze-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../base-7 "Base 7") diff --git a/problems/the-most-frequently-ordered-products-for-each-customer/README.md b/problems/the-most-frequently-ordered-products-for-each-customer/README.md index dce0cb341..876cd2c83 100644 --- a/problems/the-most-frequently-ordered-products-for-each-customer/README.md +++ b/problems/the-most-frequently-ordered-products-for-each-customer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-connect-two-groups-of-points "Minimum Cost to Connect Two Groups of Points") diff --git a/problems/the-most-recent-orders-for-each-product/README.md b/problems/the-most-recent-orders-for-each-product/README.md index bfc7647a8..9eb2bee4d 100644 --- a/problems/the-most-recent-orders-for-each-product/README.md +++ b/problems/the-most-recent-orders-for-each-product/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-most-similar-path-in-a-graph "The Most Similar Path in a Graph") diff --git a/problems/the-most-recent-three-orders/README.md b/problems/the-most-recent-three-orders/README.md index 83b306e13..992bd55db 100644 --- a/problems/the-most-recent-three-orders/README.md +++ b/problems/the-most-recent-three-orders/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../string-compression-ii "String Compression II") diff --git a/problems/the-most-similar-path-in-a-graph/README.md b/problems/the-most-similar-path-in-a-graph/README.md index 3a95c19ae..f1f57b715 100644 --- a/problems/the-most-similar-path-in-a-graph/README.md +++ b/problems/the-most-similar-path-in-a-graph/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-cut-a-stick "Minimum Cost to Cut a Stick") diff --git a/problems/the-number-of-employees-which-report-to-each-employee/README.md b/problems/the-number-of-employees-which-report-to-each-employee/README.md index 7900b68ce..8251eb140 100644 --- a/problems/the-number-of-employees-which-report-to-each-employee/README.md +++ b/problems/the-number-of-employees-which-report-to-each-employee/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-path-to-get-food "Shortest Path to Get Food") diff --git a/problems/the-number-of-full-rounds-you-have-played/README.md b/problems/the-number-of-full-rounds-you-have-played/README.md index fc09fbe71..72715c1e9 100644 --- a/problems/the-number-of-full-rounds-you-have-played/README.md +++ b/problems/the-number-of-full-rounds-you-have-played/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-odd-number-in-string "Largest Odd Number in String") diff --git a/problems/the-number-of-good-subsets/README.md b/problems/the-number-of-good-subsets/README.md index a49615a4b..14eac458b 100644 --- a/problems/the-number-of-good-subsets/README.md +++ b/problems/the-number-of-good-subsets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../operations-on-tree "Operations on Tree") diff --git a/problems/the-number-of-rich-customers/README.md b/problems/the-number-of-rich-customers/README.md new file mode 100644 index 000000000..c9d106c47 --- /dev/null +++ b/problems/the-number-of-rich-customers/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../sum-of-k-mirror-numbers "Sum of k-Mirror Numbers") +                 +[Next >](../substrings-that-begin-and-end-with-the-same-letter "Substrings That Begin and End With the Same Letter") + +## [2082. The Number of Rich Customers (Easy)](https://leetcode.com/problems/the-number-of-rich-customers "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/the-number-of-rich-customers/mysql_schemas.sql b/problems/the-number-of-rich-customers/mysql_schemas.sql new file mode 100644 index 000000000..63d1df440 --- /dev/null +++ b/problems/the-number-of-rich-customers/mysql_schemas.sql @@ -0,0 +1,7 @@ +Create table If Not Exists Store (bill_id int, customer_id int, amount int); +Truncate table Store; +insert into Store (bill_id, customer_id, amount) values ('6', '1', '549'); +insert into Store (bill_id, customer_id, amount) values ('8', '1', '834'); +insert into Store (bill_id, customer_id, amount) values ('4', '2', '394'); +insert into Store (bill_id, customer_id, amount) values ('11', '3', '657'); +insert into Store (bill_id, customer_id, amount) values ('13', '3', '257'); diff --git a/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii/README.md b/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii/README.md index 59dee44be..3ce1b5c42 100644 --- a/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii/README.md +++ b/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-operations-to-make-array-continuous "Minimum Number of Operations to Make Array Continuous") diff --git a/problems/the-number-of-seniors-and-juniors-to-join-the-company/README.md b/problems/the-number-of-seniors-and-juniors-to-join-the-company/README.md index 5d2216554..b6d5ea3a4 100644 --- a/problems/the-number-of-seniors-and-juniors-to-join-the-company/README.md +++ b/problems/the-number-of-seniors-and-juniors-to-join-the-company/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-missing-genetic-value-in-each-subtree "Smallest Missing Genetic Value in Each Subtree") diff --git a/problems/the-number-of-the-smallest-unoccupied-chair/README.md b/problems/the-number-of-the-smallest-unoccupied-chair/README.md index e19e8b297..c5e38453c 100644 --- a/problems/the-number-of-the-smallest-unoccupied-chair/README.md +++ b/problems/the-number-of-the-smallest-unoccupied-chair/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-all-characters-have-equal-number-of-occurrences "Check if All Characters Have Equal Number of Occurrences") diff --git a/problems/the-number-of-weak-characters-in-the-game/README.md b/problems/the-number-of-weak-characters-in-the-game/README.md index 608bbc54e..86f87d699 100644 --- a/problems/the-number-of-weak-characters-in-the-game/README.md +++ b/problems/the-number-of-weak-characters-in-the-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-special-quadruplets "Count Special Quadruplets") diff --git a/problems/the-score-of-students-solving-math-expression/README.md b/problems/the-score-of-students-solving-math-expression/README.md index f2e092b53..d4f8632b1 100644 --- a/problems/the-score-of-students-solving-math-expression/README.md +++ b/problems/the-score-of-students-solving-math-expression/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-word-can-be-placed-in-crossword "Check if Word Can Be Placed In Crossword") diff --git a/problems/the-time-when-the-network-becomes-idle/README.md b/problems/the-time-when-the-network-becomes-idle/README.md index 5c13d9e49..e3b5677b0 100644 --- a/problems/the-time-when-the-network-becomes-idle/README.md +++ b/problems/the-time-when-the-network-becomes-idle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-colored-pieces-if-both-neighbors-are-the-same-color "Remove Colored Pieces if Both Neighbors are the Same Color") diff --git a/problems/the-winner-university/README.md b/problems/the-winner-university/README.md index e294f698f..aa1d5cf91 100644 --- a/problems/the-winner-university/README.md +++ b/problems/the-winner-university/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-tasks-you-can-assign "Maximum Number of Tasks You Can Assign") diff --git a/problems/thousand-separator/README.md b/problems/thousand-separator/README.md index 40056c61b..66c20c984 100644 --- a/problems/thousand-separator/README.md +++ b/problems/thousand-separator/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../bank-account-summary "Bank Account Summary") @@ -11,7 +11,7 @@ ## [1556. Thousand Separator (Easy)](https://leetcode.com/problems/thousand-separator "千位分隔数") -

    Given an integer n, add a dot (".") as the thousands separator and return it in string format.

    +

    Given an integer n, add a dot (".") as the thousands separator and return it in string format.

     

    Example 1:

    @@ -46,7 +46,7 @@

    Constraints:

      -
    • 0 <= n < 2^31
    • +
    • 0 <= n < 231
    ### Related Topics diff --git a/problems/three-consecutive-odds/README.md b/problems/three-consecutive-odds/README.md index 89b1e53d8..fae398752 100644 --- a/problems/three-consecutive-odds/README.md +++ b/problems/three-consecutive-odds/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-most-recent-orders-for-each-product "The Most Recent Orders for Each Product") diff --git a/problems/three-divisors/README.md b/problems/three-divisors/README.md index ba9064fd6..259c755b3 100644 --- a/problems/three-divisors/README.md +++ b/problems/three-divisors/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-the-pairs-with-the-maximum-number-of-common-followers "All the Pairs With the Maximum Number of Common Followers") diff --git a/problems/three-equal-parts/README.md b/problems/three-equal-parts/README.md index 847224192..275dd7810 100644 --- a/problems/three-equal-parts/README.md +++ b/problems/three-equal-parts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flip-string-to-monotone-increasing "Flip String to Monotone Increasing") diff --git a/problems/throne-inheritance/README.md b/problems/throne-inheritance/README.md index 781baf8df..1c639babc 100644 --- a/problems/throne-inheritance/README.md +++ b/problems/throne-inheritance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-profit-of-operating-a-centennial-wheel "Maximum Profit of Operating a Centennial Wheel") @@ -81,13 +81,10 @@ t.getInheritanceOrder(); // return ["king", "andy", "ma ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Design](../../tag/design/README.md)] - -### Similar Questions - 1. [Operations on Tree](../operations-on-tree) (Medium) + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/tiling-a-rectangle-with-the-fewest-squares/README.md b/problems/tiling-a-rectangle-with-the-fewest-squares/README.md index d7912de1a..1c2d357e2 100644 --- a/problems/tiling-a-rectangle-with-the-fewest-squares/README.md +++ b/problems/tiling-a-rectangle-with-the-fewest-squares/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-length-of-a-concatenated-string-with-unique-characters "Maximum Length of a Concatenated String with Unique Characters") diff --git a/problems/time-based-key-value-store/README.md b/problems/time-based-key-value-store/README.md index 9eb998f86..3905deed8 100644 --- a/problems/time-based-key-value-store/README.md +++ b/problems/time-based-key-value-store/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../unique-paths-iii "Unique Paths III") diff --git a/problems/time-needed-to-buy-tickets/README.md b/problems/time-needed-to-buy-tickets/README.md index 841c55630..5fd112421 100644 --- a/problems/time-needed-to-buy-tickets/README.md +++ b/problems/time-needed-to-buy-tickets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-winner-university "The Winner University") diff --git a/problems/to-lower-case/README.md b/problems/to-lower-case/README.md index 16573fc70..5b2bc0157 100644 --- a/problems/to-lower-case/README.md +++ b/problems/to-lower-case/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../insert-into-a-sorted-circular-linked-list "Insert into a Sorted Circular Linked List") diff --git a/problems/toeplitz-matrix/README.md b/problems/toeplitz-matrix/README.md index 65ec493f2..c9dffec1b 100644 --- a/problems/toeplitz-matrix/README.md +++ b/problems/toeplitz-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../couples-holding-hands "Couples Holding Hands") diff --git a/problems/top-k-frequent-words/README.md b/problems/top-k-frequent-words/README.md index abcce3c55..333a0533c 100644 --- a/problems/top-k-frequent-words/README.md +++ b/problems/top-k-frequent-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stickers-to-spell-word "Stickers to Spell Word") diff --git a/problems/top-travellers/README.md b/problems/top-travellers/README.md index a0727269f..8e18a5b3a 100644 --- a/problems/top-travellers/README.md +++ b/problems/top-travellers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game-iii "Stone Game III") diff --git a/problems/toss-strange-coins/README.md b/problems/toss-strange-coins/README.md index 6cbfe92fc..045ee166b 100644 --- a/problems/toss-strange-coins/README.md +++ b/problems/toss-strange-coins/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../meeting-scheduler "Meeting Scheduler") diff --git a/problems/total-hamming-distance/README.md b/problems/total-hamming-distance/README.md index 8f56b545d..6ec41c314 100644 --- a/problems/total-hamming-distance/README.md +++ b/problems/total-hamming-distance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-complement "Number Complement") @@ -44,9 +44,9 @@ HammingDistance(4, 14) + HammingDistance(4, 2) + HammingDistance(14, 2) = 2 + 2 ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Hamming Distance](../hamming-distance) (Easy) diff --git a/problems/tournament-winners/README.md b/problems/tournament-winners/README.md index 717780007..0453627de 100644 --- a/problems/tournament-winners/README.md +++ b/problems/tournament-winners/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../monthly-transactions-i "Monthly Transactions I") diff --git a/problems/traffic-light-controlled-intersection/README.md b/problems/traffic-light-controlled-intersection/README.md index 6c358b949..818d55bd4 100644 --- a/problems/traffic-light-controlled-intersection/README.md +++ b/problems/traffic-light-controlled-intersection/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../palindrome-partitioning-iii "Palindrome Partitioning III") diff --git a/problems/transpose-file/README.md b/problems/transpose-file/README.md index dfc56ba85..4555a5929 100644 --- a/problems/transpose-file/README.md +++ b/problems/transpose-file/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-phone-numbers "Valid Phone Numbers") diff --git a/problems/transpose-matrix/README.md b/problems/transpose-matrix/README.md index 1afcf2daa..df3a7aaa6 100644 --- a/problems/transpose-matrix/README.md +++ b/problems/transpose-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../prime-palindrome "Prime Palindrome") diff --git a/problems/trapping-rain-water-ii/README.md b/problems/trapping-rain-water-ii/README.md index 4455c7d46..d7f037184 100644 --- a/problems/trapping-rain-water-ii/README.md +++ b/problems/trapping-rain-water-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../queue-reconstruction-by-height "Queue Reconstruction by Height") @@ -20,7 +20,7 @@ Input: heightMap = [[1,4,3,1,3,2],[3,2,1,3,2,4],[2,3,3,2,3,1]] Output: 4 Explanation: After the rain, water is trapped between the blocks. -We have two small pounds 1 and 3 units trapped. +We have two small ponds 1 and 3 units trapped. The total volume of water trapped is 4. @@ -42,10 +42,10 @@ The total volume of water trapped is 4. ### Related Topics - [[Array](../../tag/array/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Similar Questions 1. [Trapping Rain Water](../trapping-rain-water) (Hard) diff --git a/problems/tree-diameter/README.md b/problems/tree-diameter/README.md index 05ef3b089..2deb63430 100644 --- a/problems/tree-diameter/README.md +++ b/problems/tree-diameter/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-a-leaderboard "Design A Leaderboard") @@ -53,6 +53,9 @@ A longest path of the tree is the path 3 - 2 - 1 - 4 - 5. [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] +### Similar Questions + 1. [Count Subtrees With Max Distance Between Cities](../count-subtrees-with-max-distance-between-cities) (Hard) + ### Hints
    Hint 1 diff --git a/problems/tree-node/README.md b/problems/tree-node/README.md index bc70c3fcd..fb7de2645 100644 --- a/problems/tree-node/README.md +++ b/problems/tree-node/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sales-person "Sales Person") diff --git a/problems/tree-node/mysql_schemas.sql b/problems/tree-node/mysql_schemas.sql index 4511b7280..85a4aefaa 100644 --- a/problems/tree-node/mysql_schemas.sql +++ b/problems/tree-node/mysql_schemas.sql @@ -1,7 +1,7 @@ -Create table If Not Exists tree (id int, p_id int); -Truncate table tree; -insert into tree (id, p_id) values ('1', 'None'); -insert into tree (id, p_id) values ('2', '1'); -insert into tree (id, p_id) values ('3', '1'); -insert into tree (id, p_id) values ('4', '2'); -insert into tree (id, p_id) values ('5', '2'); +Create table If Not Exists Tree (id int, p_id int); +Truncate table Tree; +insert into Tree (id, p_id) values ('1', 'None'); +insert into Tree (id, p_id) values ('2', '1'); +insert into Tree (id, p_id) values ('3', '1'); +insert into Tree (id, p_id) values ('4', '2'); +insert into Tree (id, p_id) values ('5', '2'); diff --git a/problems/tree-of-coprimes/README.md b/problems/tree-of-coprimes/README.md index d1a8325d0..14026bb81 100644 --- a/problems/tree-of-coprimes/README.md +++ b/problems/tree-of-coprimes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../map-of-highest-peak "Map of Highest Peak") diff --git a/problems/triangle-judgement/README.md b/problems/triangle-judgement/README.md index e1ddb081d..c2e4a3e2d 100644 --- a/problems/triangle-judgement/README.md +++ b/problems/triangle-judgement/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-duplicate-file-in-system "Find Duplicate File in System") diff --git a/problems/triangle-judgement/mysql_schemas.sql b/problems/triangle-judgement/mysql_schemas.sql index 11cad442d..3f64d0d37 100644 --- a/problems/triangle-judgement/mysql_schemas.sql +++ b/problems/triangle-judgement/mysql_schemas.sql @@ -1,4 +1,4 @@ -Create table If Not Exists triangle (x int, y int, z int); -Truncate table triangle; -insert into triangle (x, y, z) values ('13', '15', '30'); -insert into triangle (x, y, z) values ('10', '20', '15'); +Create table If Not Exists Triangle (x int, y int, z int); +Truncate table Triangle; +insert into Triangle (x, y, z) values ('13', '15', '30'); +insert into Triangle (x, y, z) values ('10', '20', '15'); diff --git a/problems/triples-with-bitwise-and-equal-to-zero/README.md b/problems/triples-with-bitwise-and-equal-to-zero/README.md index f8188c11b..289e966c4 100644 --- a/problems/triples-with-bitwise-and-equal-to-zero/README.md +++ b/problems/triples-with-bitwise-and-equal-to-zero/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../time-based-key-value-store "Time Based Key-Value Store") @@ -59,6 +59,6 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/truncate-sentence/README.md b/problems/truncate-sentence/README.md index 73f173b14..80201d24e 100644 --- a/problems/truncate-sentence/README.md +++ b/problems/truncate-sentence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-groups-getting-fresh-donuts "Maximum Number of Groups Getting Fresh Donuts") diff --git a/problems/tuple-with-same-product/README.md b/problems/tuple-with-same-product/README.md index b286e0912..89f9e7bd6 100644 --- a/problems/tuple-with-same-product/README.md +++ b/problems/tuple-with-same-product/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-rectangles-that-can-form-the-largest-square "Number Of Rectangles That Can Form The Largest Square") diff --git a/problems/tweet-counts-per-frequency/README.md b/problems/tweet-counts-per-frequency/README.md index f928815fb..ec49dcb06 100644 --- a/problems/tweet-counts-per-frequency/README.md +++ b/problems/tweet-counts-per-frequency/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-number-of-steps-to-make-two-strings-anagram "Minimum Number of Steps to Make Two Strings Anagram") diff --git a/problems/two-best-non-overlapping-events/README.md b/problems/two-best-non-overlapping-events/README.md index 85ace1a73..4526374a2 100644 --- a/problems/two-best-non-overlapping-events/README.md +++ b/problems/two-best-non-overlapping-events/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-distinct-string-in-an-array "Kth Distinct String in an Array") diff --git a/problems/two-furthest-houses-with-different-colors/README.md b/problems/two-furthest-houses-with-different-colors/README.md new file mode 100644 index 000000000..0cb4b8ae4 --- /dev/null +++ b/problems/two-furthest-houses-with-different-colors/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../paths-in-maze-that-lead-to-same-room "Paths in Maze That Lead to Same Room") +                 +[Next >](../watering-plants "Watering Plants") + +## [2078. Two Furthest Houses With Different Colors (Easy)](https://leetcode.com/problems/two-furthest-houses-with-different-colors "两栋颜色不同且距离最远的房子") + +

    There are n houses evenly lined up on the street, and each house is beautifully painted. You are given a 0-indexed integer array colors of length n, where colors[i] represents the color of the ith house.

    + +

    Return the maximum distance between two houses with different colors.

    + +

    The distance between the ith and jth houses is abs(i - j), where abs(x) is the absolute value of x.

    + +

     

    +

    Example 1:

    + +
    +Input: colors = [1,1,1,6,1,1,1]
    +Output: 3
    +Explanation: In the above image, color 1 is blue, and color 6 is red.
    +The furthest two houses with different colors are house 0 and house 3.
    +House 0 has color 1, and house 3 has color 6. The distance between them is abs(0 - 3) = 3.
    +Note that houses 3 and 6 can also produce the optimal answer.
    +
    + +

    Example 2:

    + +
    +Input: colors = [1,8,3,8,3]
    +Output: 4
    +Explanation: In the above image, color 1 is blue, color 8 is yellow, and color 3 is green.
    +The furthest two houses with different colors are house 0 and house 4.
    +House 0 has color 1, and house 4 has color 3. The distance between them is abs(0 - 4) = 4.
    +
    + +

    Example 3:

    + +
    +Input: colors = [0,1]
    +Output: 1
    +Explanation: The furthest two houses with different colors are house 0 and house 1.
    +House 0 has color 0, and house 1 has color 1. The distance between them is abs(0 - 1) = 1.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == colors.length
    • +
    • 2 <= n <= 100
    • +
    • 0 <= colors[i] <= 100
    • +
    • Test data are generated such that at least two houses have different colors.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +The constraints are small. Can you try the combination of every two houses? +
    + +
    +Hint 2 +Greedily, the maximum distance will come from either the pair of the leftmost house and possibly some house on the right with a different color, or the pair of the rightmost house and possibly some house on the left with a different color. +
    diff --git a/problems/two-out-of-three/README.md b/problems/two-out-of-three/README.md index fa79fcd67..176e64f08 100644 --- a/problems/two-out-of-three/README.md +++ b/problems/two-out-of-three/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-subarrays-with-more-ones-than-zeros "Count Subarrays With More Ones Than Zeros") diff --git a/problems/two-sum-bsts/README.md b/problems/two-sum-bsts/README.md index a4e10f687..a8e816200 100644 --- a/problems/two-sum-bsts/README.md +++ b/problems/two-sum-bsts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../intersection-of-three-sorted-arrays "Intersection of Three Sorted Arrays") diff --git a/problems/two-sum-iv-input-is-a-bst/README.md b/problems/two-sum-iv-input-is-a-bst/README.md index 4f5748895..098f7ab54 100644 --- a/problems/two-sum-iv-input-is-a-bst/README.md +++ b/problems/two-sum-iv-input-is-a-bst/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-duplicate-subtrees "Find Duplicate Subtrees") @@ -70,6 +70,6 @@ ### Similar Questions 1. [Two Sum](../two-sum) (Easy) - 1. [Two Sum II - Input array is sorted](../two-sum-ii-input-array-is-sorted) (Easy) + 1. [Two Sum II - Input Array Is Sorted](../two-sum-ii-input-array-is-sorted) (Easy) 1. [Two Sum III - Data structure design](../two-sum-iii-data-structure-design) (Easy) 1. [Two Sum BSTs](../two-sum-bsts) (Medium) diff --git a/problems/two-sum-less-than-k/README.md b/problems/two-sum-less-than-k/README.md index f925185a8..396a01979 100644 --- a/problems/two-sum-less-than-k/README.md +++ b/problems/two-sum-less-than-k/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../unpopular-books "Unpopular Books") @@ -51,7 +51,7 @@ In this case it's not possible to get a pair sum less that 15. ### Similar Questions 1. [Two Sum](../two-sum) (Easy) - 1. [Two Sum II - Input array is sorted](../two-sum-ii-input-array-is-sorted) (Easy) + 1. [Two Sum II - Input Array Is Sorted](../two-sum-ii-input-array-is-sorted) (Easy) 1. [3Sum Smaller](../3sum-smaller) (Medium) 1. [Subarray Product Less Than K](../subarray-product-less-than-k) (Medium) diff --git a/problems/ugly-number-iii/README.md b/problems/ugly-number-iii/README.md index b08dd80e8..0790cc0c7 100644 --- a/problems/ugly-number-iii/README.md +++ b/problems/ugly-number-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-absolute-difference "Minimum Absolute Difference") diff --git a/problems/uncommon-words-from-two-sentences/README.md b/problems/uncommon-words-from-two-sentences/README.md index f94135705..f4921ce8a 100644 --- a/problems/uncommon-words-from-two-sentences/README.md +++ b/problems/uncommon-words-from-two-sentences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../projection-area-of-3d-shapes "Projection Area of 3D Shapes") diff --git a/problems/unique-email-addresses/README.md b/problems/unique-email-addresses/README.md index 06949920b..755ffc50b 100644 --- a/problems/unique-email-addresses/README.md +++ b/problems/unique-email-addresses/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimize-malware-spread-ii "Minimize Malware Spread II") diff --git a/problems/unique-length-3-palindromic-subsequences/README.md b/problems/unique-length-3-palindromic-subsequences/README.md index 8a0332d26..842141df7 100644 --- a/problems/unique-length-3-palindromic-subsequences/README.md +++ b/problems/unique-length-3-palindromic-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../concatenation-of-array "Concatenation of Array") diff --git a/problems/unique-morse-code-words/README.md b/problems/unique-morse-code-words/README.md index 0e40378c8..cc8a0767d 100644 --- a/problems/unique-morse-code-words/README.md +++ b/problems/unique-morse-code-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../bricks-falling-when-hit "Bricks Falling When Hit") diff --git a/problems/unique-number-of-occurrences/README.md b/problems/unique-number-of-occurrences/README.md index 7b6144b8a..9340795c8 100644 --- a/problems/unique-number-of-occurrences/README.md +++ b/problems/unique-number-of-occurrences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-skiplist "Design Skiplist") diff --git a/problems/unique-orders-and-customers-per-month/README.md b/problems/unique-orders-and-customers-per-month/README.md index 3bf932182..be33a1b8b 100644 --- a/problems/unique-orders-and-customers-per-month/README.md +++ b/problems/unique-orders-and-customers-per-month/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../put-boxes-into-the-warehouse-i "Put Boxes Into the Warehouse I") diff --git a/problems/unique-paths-iii/README.md b/problems/unique-paths-iii/README.md index 852b22a75..23d0cdfc2 100644 --- a/problems/unique-paths-iii/README.md +++ b/problems/unique-paths-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../distribute-coins-in-binary-tree "Distribute Coins in Binary Tree") @@ -67,9 +67,9 @@ Note that the starting and ending square can be anywhere in the grid. ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Backtracking](../../tag/backtracking/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Similar Questions diff --git a/problems/univalued-binary-tree/README.md b/problems/univalued-binary-tree/README.md index a0f8bd91b..2c9f33f16 100644 --- a/problems/univalued-binary-tree/README.md +++ b/problems/univalued-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../least-operators-to-express-number "Least Operators to Express Number") @@ -43,3 +43,6 @@ [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] + +### Similar Questions + 1. [Find All The Lonely Nodes](../find-all-the-lonely-nodes) (Easy) diff --git a/problems/unpopular-books/README.md b/problems/unpopular-books/README.md index 4cd9e3c91..3eae0fff4 100644 --- a/problems/unpopular-books/README.md +++ b/problems/unpopular-books/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../game-play-analysis-v "Game Play Analysis V") diff --git a/problems/user-activity-for-the-past-30-days-ii/README.md b/problems/user-activity-for-the-past-30-days-ii/README.md index 17466257b..798f30669 100644 --- a/problems/user-activity-for-the-past-30-days-ii/README.md +++ b/problems/user-activity-for-the-past-30-days-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../user-activity-for-the-past-30-days-i "User Activity for the Past 30 Days I") diff --git a/problems/user-purchase-platform/README.md b/problems/user-purchase-platform/README.md index 7b5fe2a5e..6fce28e7c 100644 --- a/problems/user-purchase-platform/README.md +++ b/problems/user-purchase-platform/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../active-businesses "Active Businesses") diff --git a/problems/users-that-actively-request-confirmation-messages/README.md b/problems/users-that-actively-request-confirmation-messages/README.md index 291046281..1b94ef273 100644 --- a/problems/users-that-actively-request-confirmation-messages/README.md +++ b/problems/users-that-actively-request-confirmation-messages/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-genetic-difference-query "Maximum Genetic Difference Query") diff --git a/problems/utf-8-validation/README.md b/problems/utf-8-validation/README.md index 2655a7631..cbbf134ce 100644 --- a/problems/utf-8-validation/README.md +++ b/problems/utf-8-validation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../is-subsequence "Is Subsequence") @@ -64,8 +64,8 @@ But the second continuation byte does not start with 10, so it is invalid. ### Related Topics - [[Array](../../tag/array/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/valid-anagram/README.md b/problems/valid-anagram/README.md index f4b1d90dd..782c3336d 100644 --- a/problems/valid-anagram/README.md +++ b/problems/valid-anagram/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../different-ways-to-add-parentheses "Different Ways to Add Parentheses") diff --git a/problems/valid-boomerang/README.md b/problems/valid-boomerang/README.md index f7e813c3d..5cd0d3c99 100644 --- a/problems/valid-boomerang/README.md +++ b/problems/valid-boomerang/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../escape-a-large-maze "Escape a Large Maze") diff --git a/problems/valid-parenthesis-string/README.md b/problems/valid-parenthesis-string/README.md index c95daefdb..b4ce17b44 100644 --- a/problems/valid-parenthesis-string/README.md +++ b/problems/valid-parenthesis-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../map-sum-pairs "Map Sum Pairs") diff --git a/problems/valid-perfect-square/README.md b/problems/valid-perfect-square/README.md index d014f8517..cc1cf1509 100644 --- a/problems/valid-perfect-square/README.md +++ b/problems/valid-perfect-square/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-leaves-of-binary-tree "Find Leaves of Binary Tree") diff --git a/problems/valid-phone-numbers/README.md b/problems/valid-phone-numbers/README.md index e12d2952a..0f7a3f58e 100644 --- a/problems/valid-phone-numbers/README.md +++ b/problems/valid-phone-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-frequency "Word Frequency") diff --git a/problems/valid-square/README.md b/problems/valid-square/README.md index b3ff9993f..0d0c4f5cb 100644 --- a/problems/valid-square/README.md +++ b/problems/valid-square/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fraction-addition-and-subtraction "Fraction Addition and Subtraction") diff --git a/problems/valid-tic-tac-toe-state/README.md b/problems/valid-tic-tac-toe-state/README.md index e9993467e..fde5d893b 100644 --- a/problems/valid-tic-tac-toe-state/README.md +++ b/problems/valid-tic-tac-toe-state/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../preimage-size-of-factorial-zeroes-function "Preimage Size of Factorial Zeroes Function") diff --git a/problems/valid-triangle-number/README.md b/problems/valid-triangle-number/README.md index 5cd750359..abf3295a3 100644 --- a/problems/valid-triangle-number/README.md +++ b/problems/valid-triangle-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../triangle-judgement "Triangle Judgement") diff --git a/problems/validate-binary-search-tree/README.md b/problems/validate-binary-search-tree/README.md index 47b796017..889fb70ee 100644 --- a/problems/validate-binary-search-tree/README.md +++ b/problems/validate-binary-search-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../interleaving-string "Interleaving String") diff --git a/problems/validate-binary-tree-nodes/README.md b/problems/validate-binary-tree-nodes/README.md index c6ad1fd5a..a972d39a9 100644 --- a/problems/validate-binary-tree-nodes/README.md +++ b/problems/validate-binary-tree-nodes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-days-between-two-dates "Number of Days Between Two Dates") diff --git a/problems/verbal-arithmetic-puzzle/README.md b/problems/verbal-arithmetic-puzzle/README.md index a3b625841..9982377e8 100644 --- a/problems/verbal-arithmetic-puzzle/README.md +++ b/problems/verbal-arithmetic-puzzle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../jump-game-iii "Jump Game III") diff --git a/problems/verify-preorder-sequence-in-binary-search-tree/README.md b/problems/verify-preorder-sequence-in-binary-search-tree/README.md index e9f1f0553..1eabfacad 100644 --- a/problems/verify-preorder-sequence-in-binary-search-tree/README.md +++ b/problems/verify-preorder-sequence-in-binary-search-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../factor-combinations "Factor Combinations") @@ -44,8 +44,8 @@ Could you do it using only constant space complexity?

    [[Tree](../../tag/tree/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Recursion](../../tag/recursion/README.md)] - [[Binary Tree](../../tag/binary-tree/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions 1. [Binary Tree Preorder Traversal](../binary-tree-preorder-traversal) (Easy) diff --git a/problems/verify-preorder-serialization-of-a-binary-tree/README.md b/problems/verify-preorder-serialization-of-a-binary-tree/README.md index 48029e149..b598c3005 100644 --- a/problems/verify-preorder-serialization-of-a-binary-tree/README.md +++ b/problems/verify-preorder-serialization-of-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../patching-array "Patching Array") diff --git a/problems/vertical-order-traversal-of-a-binary-tree/README.md b/problems/vertical-order-traversal-of-a-binary-tree/README.md index 9c6cd7974..b82b15314 100644 --- a/problems/vertical-order-traversal-of-a-binary-tree/README.md +++ b/problems/vertical-order-traversal-of-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../interval-list-intersections "Interval List Intersections") @@ -65,8 +65,8 @@ Note that the solution remains the same since 5 and 6 are in the same location a ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/vowels-of-all-substrings/README.md b/problems/vowels-of-all-substrings/README.md index b16c802cf..3d35932cd 100644 --- a/problems/vowels-of-all-substrings/README.md +++ b/problems/vowels-of-all-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-vowel-substrings-of-a-string "Count Vowel Substrings of a String") diff --git a/problems/walking-robot-simulation-ii/README.md b/problems/walking-robot-simulation-ii/README.md index 681dc572e..89f18a29f 100644 --- a/problems/walking-robot-simulation-ii/README.md +++ b/problems/walking-robot-simulation-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-whether-two-strings-are-almost-equivalent "Check Whether Two Strings are Almost Equivalent") diff --git a/problems/warehouse-manager/README.md b/problems/warehouse-manager/README.md index 33d84cfec..1bd5e33f8 100644 --- a/problems/warehouse-manager/README.md +++ b/problems/warehouse-manager/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../dot-product-of-two-sparse-vectors "Dot Product of Two Sparse Vectors") diff --git a/problems/water-bottles/README.md b/problems/water-bottles/README.md index 5df550788..a12dce419 100644 --- a/problems/water-bottles/README.md +++ b/problems/water-bottles/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-users-with-valid-e-mails "Find Users With Valid E-Mails") diff --git a/problems/watering-plants/README.md b/problems/watering-plants/README.md new file mode 100644 index 000000000..a130195d4 --- /dev/null +++ b/problems/watering-plants/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../two-furthest-houses-with-different-colors "Two Furthest Houses With Different Colors") +                 +[Next >](../range-frequency-queries "Range Frequency Queries") + +## [2079. Watering Plants (Medium)](https://leetcode.com/problems/watering-plants "给植物浇水") + +

    You want to water n plants in your garden with a watering can. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i. There is a river at x = -1 that you can refill your watering can at.

    + +

    Each plant needs a specific amount of water. You will water the plants in the following way:

    + +
      +
    • Water the plants in order from left to right.
    • +
    • After watering the current plant, if you do not have enough water to completely water the next plant, return to the river to fully refill the watering can.
    • +
    • You cannot refill the watering can early.
    • +
    + +

    You are initially at the river (i.e., x = -1). It takes one step to move one unit on the x-axis.

    + +

    Given a 0-indexed integer array plants of n integers, where plants[i] is the amount of water the ith plant needs, and an integer capacity representing the watering can capacity, return the number of steps needed to water all the plants.

    + +

     

    +

    Example 1:

    + +
    +Input: plants = [2,2,3,3], capacity = 5
    +Output: 14
    +Explanation: Start at the river with a full watering can:
    +- Walk to plant 0 (1 step) and water it. Watering can has 3 units of water.
    +- Walk to plant 1 (1 step) and water it. Watering can has 1 unit of water.
    +- Since you cannot completely water plant 2, walk back to the river to refill (2 steps).
    +- Walk to plant 2 (3 steps) and water it. Watering can has 2 units of water.
    +- Since you cannot completely water plant 3, walk back to the river to refill (3 steps).
    +- Walk to plant 3 (4 steps) and water it.
    +Steps needed = 1 + 1 + 2 + 3 + 3 + 4 = 14.
    +
    + +

    Example 2:

    + +
    +Input: plants = [1,1,1,4,2,3], capacity = 4
    +Output: 30
    +Explanation: Start at the river with a full watering can:
    +- Water plants 0, 1, and 2 (3 steps). Return to river (3 steps).
    +- Water plant 3 (4 steps). Return to river (4 steps).
    +- Water plant 4 (5 steps). Return to river (5 steps).
    +- Water plant 5 (6 steps).
    +Steps needed = 3 + 3 + 4 + 4 + 5 + 5 + 6 = 30.
    +
    + +

    Example 3:

    + +
    +Input: plants = [7,7,7,7,7,7,7], capacity = 8
    +Output: 49
    +Explanation: You have to refill before watering each plant.
    +Steps needed = 1 + 1 + 2 + 2 + 3 + 3 + 4 + 4 + 5 + 5 + 6 + 6 + 7 = 49.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == plants.length
    • +
    • 1 <= n <= 1000
    • +
    • 1 <= plants[i] <= 106
    • +
    • max(plants[i]) <= capacity <= 109
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Simulate the process. +
    + +
    +Hint 2 +Return to refill the container once you meet a plant that needs more water than you have. +
    diff --git a/problems/ways-to-make-a-fair-array/README.md b/problems/ways-to-make-a-fair-array/README.md index 6915c63e6..b09a128d7 100644 --- a/problems/ways-to-make-a-fair-array/README.md +++ b/problems/ways-to-make-a-fair-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-string-with-a-given-numeric-value "Smallest String With A Given Numeric Value") diff --git a/problems/ways-to-split-array-into-three-subarrays/README.md b/problems/ways-to-split-array-into-three-subarrays/README.md index 79d91c75e..543aad389 100644 --- a/problems/ways-to-split-array-into-three-subarrays/README.md +++ b/problems/ways-to-split-array-into-three-subarrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-good-meals "Count Good Meals") diff --git a/problems/web-crawler-multithreaded/README.md b/problems/web-crawler-multithreaded/README.md index aea83a6c6..40b986e48 100644 --- a/problems/web-crawler-multithreaded/README.md +++ b/problems/web-crawler-multithreaded/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-comments-per-post "Number of Comments per Post") diff --git a/problems/web-crawler/README.md b/problems/web-crawler/README.md index edd39af60..e6bd65041 100644 --- a/problems/web-crawler/README.md +++ b/problems/web-crawler/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-profit-in-job-scheduling "Maximum Profit in Job Scheduling") @@ -93,11 +93,14 @@ startUrl = "http://news.google.com" ### Related Topics + [[String](../../tag/string/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[String](../../tag/string/README.md)] [[Interactive](../../tag/interactive/README.md)] +### Similar Questions + 1. [Web Crawler Multithreaded](../web-crawler-multithreaded) (Medium) + ### Hints
    Hint 1 diff --git a/problems/where-will-the-ball-fall/README.md b/problems/where-will-the-ball-fall/README.md index 130043f1b..62d5babec 100644 --- a/problems/where-will-the-ball-fall/README.md +++ b/problems/where-will-the-ball-fall/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-eaten-apples "Maximum Number of Eaten Apples") @@ -66,9 +66,9 @@ Ball b4 is dropped at column 4 and will get stuck on the box between column 2 an ### Related Topics - [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/widest-pair-of-indices-with-equal-range-sum/README.md b/problems/widest-pair-of-indices-with-equal-range-sum/README.md index e0979d352..03bb08145 100644 --- a/problems/widest-pair-of-indices-with-equal-range-sum/README.md +++ b/problems/widest-pair-of-indices-with-equal-range-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-array-given-subset-sums "Find Array Given Subset Sums") diff --git a/problems/widest-vertical-area-between-two-points-containing-no-points/README.md b/problems/widest-vertical-area-between-two-points-containing-no-points/README.md index 6f79021ca..9e0d052f3 100644 --- a/problems/widest-vertical-area-between-two-points-containing-no-points/README.md +++ b/problems/widest-vertical-area-between-two-points-containing-no-points/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sort-array-by-increasing-frequency "Sort Array by Increasing Frequency") diff --git a/problems/wildcard-matching/README.md b/problems/wildcard-matching/README.md index d9d3561f2..1230d3ff7 100644 --- a/problems/wildcard-matching/README.md +++ b/problems/wildcard-matching/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../multiply-strings "Multiply Strings") @@ -70,10 +70,10 @@ ### Related Topics - [[String](../../tag/string/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Recursion](../../tag/recursion/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] ### Similar Questions 1. [Regular Expression Matching](../regular-expression-matching) (Hard) diff --git a/problems/word-break-ii/README.md b/problems/word-break-ii/README.md index 7cb8189ef..2442e9ffc 100644 --- a/problems/word-break-ii/README.md +++ b/problems/word-break-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-break "Word Break") @@ -50,12 +50,12 @@ ### Related Topics - [[Trie](../../tag/trie/README.md)] - [[Memoization](../../tag/memoization/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Memoization](../../tag/memoization/README.md)] ### Similar Questions 1. [Word Break](../word-break) (Medium) diff --git a/problems/word-break/README.md b/problems/word-break/README.md index 1f1e3d229..13cb790a8 100644 --- a/problems/word-break/README.md +++ b/problems/word-break/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../copy-list-with-random-pointer "Copy List with Random Pointer") diff --git a/problems/word-frequency/README.md b/problems/word-frequency/README.md index 4ffb16244..6948c18ae 100644 --- a/problems/word-frequency/README.md +++ b/problems/word-frequency/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-1-bits "Number of 1 Bits") diff --git a/problems/word-ladder-ii/README.md b/problems/word-ladder-ii/README.md index 947eec7f7..fd36368df 100644 --- a/problems/word-ladder-ii/README.md +++ b/problems/word-ladder-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-palindrome "Valid Palindrome") diff --git a/problems/word-ladder/README.md b/problems/word-ladder/README.md index 410e3dd19..8a73d975c 100644 --- a/problems/word-ladder/README.md +++ b/problems/word-ladder/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-ladder-ii "Word Ladder II") diff --git a/problems/word-pattern/README.md b/problems/word-pattern/README.md index 043632042..9a39a81df 100644 --- a/problems/word-pattern/README.md +++ b/problems/word-pattern/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../game-of-life "Game of Life") diff --git a/problems/word-search-ii/README.md b/problems/word-search-ii/README.md index 10b6d62b4..65fb04542 100644 --- a/problems/word-search-ii/README.md +++ b/problems/word-search-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-add-and-search-words-data-structure "Design Add and Search Words Data Structure") @@ -45,10 +45,10 @@ ### Related Topics - [[Trie](../../tag/trie/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Trie](../../tag/trie/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Similar Questions diff --git a/problems/word-squares/README.md b/problems/word-squares/README.md index 86cd4ce96..05908d666 100644 --- a/problems/word-squares/README.md +++ b/problems/word-squares/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-repeating-character-replacement "Longest Repeating Character Replacement") diff --git a/problems/xor-queries-of-a-subarray/README.md b/problems/xor-queries-of-a-subarray/README.md index 5b92b9e83..90df382e7 100644 --- a/problems/xor-queries-of-a-subarray/README.md +++ b/problems/xor-queries-of-a-subarray/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../decrypt-string-from-alphabet-to-integer-mapping "Decrypt String from Alphabet to Integer Mapping") @@ -11,7 +11,12 @@ ## [1310. XOR Queries of a Subarray (Medium)](https://leetcode.com/problems/xor-queries-of-a-subarray "子数组异或查询") -Given the array arr of positive integers and the array queries where queries[i] = [Li, Ri], for each query i compute the XOR of elements from Li to Ri (that is, arr[Li] xor arr[Li+1] xor ... xor arr[Ri] ). Return an array containing the result for the given queries. +

    You are given an array arr of positive integers. You are also given the array queries where queries[i] = [lefti, righti].

    + +

    For each query i compute the XOR of elements from lefti to righti (that is, arr[lefti] XOR arr[lefti + 1] XOR ... XOR arr[righti] ).

    + +

    Return an array answer where answer[i] is the answer to the ith query.

    +

     

    Example 1:

    @@ -42,11 +47,10 @@ The XOR values for queries are:

    Constraints:

      -
    • 1 <= arr.length <= 3 * 10^4
    • -
    • 1 <= arr[i] <= 10^9
    • -
    • 1 <= queries.length <= 3 * 10^4
    • +
    • 1 <= arr.length, queries.length <= 3 * 104
    • +
    • 1 <= arr[i] <= 109
    • queries[i].length == 2
    • -
    • 0 <= queries[i][0] <= queries[i][1] < arr.length
    • +
    • 0 <= lefti <= righti < arr.length
    ### Related Topics diff --git a/problems/zigzag-iterator/README.md b/problems/zigzag-iterator/README.md index 7ca1fe411..9c3ae3609 100644 --- a/problems/zigzag-iterator/README.md +++ b/problems/zigzag-iterator/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../wiggle-sort "Wiggle Sort") diff --git a/readme/1-300.md b/readme/1-300.md index fa535c2e6..a4db89dcb 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -1,78 +1,78 @@ - - - + + + -# [LeetCode](https://openset.github.io/leetcode) +# [LeetCode](https://awesee.github.io/leetcode) LeetCode Problems' Solutions -[[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] +[[力扣](https://awesee.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/awesee/leetcode/blob/master/tag/README.md)] -[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) -[![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) -[![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) -[![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) -[![license](https://img.shields.io/github/license/openset/leetcode.svg)](https://github.com/openset/leetcode/blob/master/LICENSE) -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fopenset%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fopenset%2Fleetcode?ref=badge_shield) -[![Join the chat](https://badges.gitter.im/openset/leetcode.svg)](https://gitter.im/openset/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Go](https://github.com/awesee/leetcode/workflows/Go/badge.svg)](https://github.com/awesee/leetcode/actions) +[![codecov](https://codecov.io/gh/awesee/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/awesee/leetcode) +[![Go Report Card](https://goreportcard.com/badge/github.com/awesee/leetcode)](https://goreportcard.com/report/github.com/awesee/leetcode) +[![GitHub contributors](https://img.shields.io/github/contributors/awesee/leetcode.svg)](https://github.com/awesee/leetcode/graphs/contributors) +[![license](https://img.shields.io/github/license/awesee/leetcode.svg)](https://github.com/awesee/leetcode/blob/master/LICENSE) +[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fawesee%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fawesee%2Fleetcode?ref=badge_shield) +[![Join the chat](https://badges.gitter.im/awesee/leetcode.svg)](https://gitter.im/awesee/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    diff --git a/readme/1201-1500.md b/readme/1201-1500.md index bacd2ea5c..8b5c5123a 100644 --- a/readme/1201-1500.md +++ b/readme/1201-1500.md @@ -1,78 +1,78 @@ - - - + + + -# [LeetCode](https://openset.github.io/leetcode) +# [LeetCode](https://awesee.github.io/leetcode) LeetCode Problems' Solutions -[[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] +[[力扣](https://awesee.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/awesee/leetcode/blob/master/tag/README.md)] -[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) -[![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) -[![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) -[![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) -[![license](https://img.shields.io/github/license/openset/leetcode.svg)](https://github.com/openset/leetcode/blob/master/LICENSE) -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fopenset%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fopenset%2Fleetcode?ref=badge_shield) -[![Join the chat](https://badges.gitter.im/openset/leetcode.svg)](https://gitter.im/openset/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Go](https://github.com/awesee/leetcode/workflows/Go/badge.svg)](https://github.com/awesee/leetcode/actions) +[![codecov](https://codecov.io/gh/awesee/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/awesee/leetcode) +[![Go Report Card](https://goreportcard.com/badge/github.com/awesee/leetcode)](https://goreportcard.com/report/github.com/awesee/leetcode) +[![GitHub contributors](https://img.shields.io/github/contributors/awesee/leetcode.svg)](https://github.com/awesee/leetcode/graphs/contributors) +[![license](https://img.shields.io/github/license/awesee/leetcode.svg)](https://github.com/awesee/leetcode/blob/master/LICENSE) +[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fawesee%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fawesee%2Fleetcode?ref=badge_shield) +[![Join the chat](https://badges.gitter.im/awesee/leetcode.svg)](https://gitter.im/awesee/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    diff --git a/readme/301-600.md b/readme/301-600.md index 4ebd07acb..d0b689921 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -1,78 +1,78 @@ - - - + + + -# [LeetCode](https://openset.github.io/leetcode) +# [LeetCode](https://awesee.github.io/leetcode) LeetCode Problems' Solutions -[[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] +[[力扣](https://awesee.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/awesee/leetcode/blob/master/tag/README.md)] -[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) -[![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) -[![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) -[![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) -[![license](https://img.shields.io/github/license/openset/leetcode.svg)](https://github.com/openset/leetcode/blob/master/LICENSE) -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fopenset%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fopenset%2Fleetcode?ref=badge_shield) -[![Join the chat](https://badges.gitter.im/openset/leetcode.svg)](https://gitter.im/openset/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Go](https://github.com/awesee/leetcode/workflows/Go/badge.svg)](https://github.com/awesee/leetcode/actions) +[![codecov](https://codecov.io/gh/awesee/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/awesee/leetcode) +[![Go Report Card](https://goreportcard.com/badge/github.com/awesee/leetcode)](https://goreportcard.com/report/github.com/awesee/leetcode) +[![GitHub contributors](https://img.shields.io/github/contributors/awesee/leetcode.svg)](https://github.com/awesee/leetcode/graphs/contributors) +[![license](https://img.shields.io/github/license/awesee/leetcode.svg)](https://github.com/awesee/leetcode/blob/master/LICENSE) +[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fawesee%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fawesee%2Fleetcode?ref=badge_shield) +[![Join the chat](https://badges.gitter.im/awesee/leetcode.svg)](https://gitter.im/awesee/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    diff --git a/readme/601-900.md b/readme/601-900.md index 269a32bb0..5ceafc962 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -1,78 +1,78 @@ - - - + + + -# [LeetCode](https://openset.github.io/leetcode) +# [LeetCode](https://awesee.github.io/leetcode) LeetCode Problems' Solutions -[[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] +[[力扣](https://awesee.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/awesee/leetcode/blob/master/tag/README.md)] -[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) -[![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) -[![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) -[![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) -[![license](https://img.shields.io/github/license/openset/leetcode.svg)](https://github.com/openset/leetcode/blob/master/LICENSE) -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fopenset%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fopenset%2Fleetcode?ref=badge_shield) -[![Join the chat](https://badges.gitter.im/openset/leetcode.svg)](https://gitter.im/openset/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Go](https://github.com/awesee/leetcode/workflows/Go/badge.svg)](https://github.com/awesee/leetcode/actions) +[![codecov](https://codecov.io/gh/awesee/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/awesee/leetcode) +[![Go Report Card](https://goreportcard.com/badge/github.com/awesee/leetcode)](https://goreportcard.com/report/github.com/awesee/leetcode) +[![GitHub contributors](https://img.shields.io/github/contributors/awesee/leetcode.svg)](https://github.com/awesee/leetcode/graphs/contributors) +[![license](https://img.shields.io/github/license/awesee/leetcode.svg)](https://github.com/awesee/leetcode/blob/master/LICENSE) +[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fawesee%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fawesee%2Fleetcode?ref=badge_shield) +[![Join the chat](https://badges.gitter.im/awesee/leetcode.svg)](https://gitter.im/awesee/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    @@ -314,7 +314,7 @@ LeetCode Problems' Solutions | 834 | [Sum of Distances in Tree](https://leetcode.com/problems/sum-of-distances-in-tree "树中距离之和") | [Go](../problems/sum-of-distances-in-tree) | Hard | | 835 | [Image Overlap](https://leetcode.com/problems/image-overlap "图像重叠") | [Go](../problems/image-overlap) | Medium | | 836 | [Rectangle Overlap](https://leetcode.com/problems/rectangle-overlap "矩形重叠") | [Go](../problems/rectangle-overlap) | Easy | -| 837 | [New 21 Game](https://leetcode.com/problems/new-21-game "新21点") | [Go](../problems/new-21-game) | Medium | +| 837 | [New 21 Game](https://leetcode.com/problems/new-21-game "新 21 点") | [Go](../problems/new-21-game) | Medium | | 838 | [Push Dominoes](https://leetcode.com/problems/push-dominoes "推多米诺") | [Go](../problems/push-dominoes) | Medium | | 839 | [Similar String Groups](https://leetcode.com/problems/similar-string-groups "相似字符串组") | [Go](../problems/similar-string-groups) | Hard | | 840 | [Magic Squares In Grid](https://leetcode.com/problems/magic-squares-in-grid "矩阵中的幻方") | [Go](../problems/magic-squares-in-grid) | Medium | diff --git a/readme/901-1200.md b/readme/901-1200.md index a21552f13..56787b7be 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -1,78 +1,78 @@ - - - + + + -# [LeetCode](https://openset.github.io/leetcode) +# [LeetCode](https://awesee.github.io/leetcode) LeetCode Problems' Solutions -[[力扣](https://openset.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md)] +[[力扣](https://awesee.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/awesee/leetcode/blob/master/tag/README.md)] -[![Go](https://github.com/openset/leetcode/workflows/Go/badge.svg)](https://github.com/openset/leetcode/actions) -[![codecov](https://codecov.io/gh/openset/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/openset/leetcode) -[![Go Report Card](https://goreportcard.com/badge/github.com/openset/leetcode)](https://goreportcard.com/report/github.com/openset/leetcode) -[![GitHub contributors](https://img.shields.io/github/contributors/openset/leetcode.svg)](https://github.com/openset/leetcode/graphs/contributors) -[![license](https://img.shields.io/github/license/openset/leetcode.svg)](https://github.com/openset/leetcode/blob/master/LICENSE) -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fopenset%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fopenset%2Fleetcode?ref=badge_shield) -[![Join the chat](https://badges.gitter.im/openset/leetcode.svg)](https://gitter.im/openset/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Go](https://github.com/awesee/leetcode/workflows/Go/badge.svg)](https://github.com/awesee/leetcode/actions) +[![codecov](https://codecov.io/gh/awesee/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/awesee/leetcode) +[![Go Report Card](https://goreportcard.com/badge/github.com/awesee/leetcode)](https://goreportcard.com/report/github.com/awesee/leetcode) +[![GitHub contributors](https://img.shields.io/github/contributors/awesee/leetcode.svg)](https://github.com/awesee/leetcode/graphs/contributors) +[![license](https://img.shields.io/github/license/awesee/leetcode.svg)](https://github.com/awesee/leetcode/blob/master/LICENSE) +[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fawesee%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fawesee%2Fleetcode?ref=badge_shield) +[![Join the chat](https://badges.gitter.im/awesee/leetcode.svg)](https://gitter.im/awesee/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    diff --git a/tag/README.md b/tag/README.md index 0aab38cdc..a260ae4a8 100644 --- a/tag/README.md +++ b/tag/README.md @@ -1,50 +1,50 @@ - - - + + + ## 话题分类 | # | Topic | 话题 | | # | Topic | 话题 | | :-: | - | :-: | - | :-: | - | :-: | -| 1 | [Array](array/README.md) | [数组](https://openset.github.io/tags/array/) | | 2 | [Dynamic Programming](dynamic-programming/README.md) | [动态规划](https://openset.github.io/tags/dynamic-programming/) | -| 3 | [String](string/README.md) | [字符串](https://openset.github.io/tags/string/) | | 4 | [Math](math/README.md) | [数学](https://openset.github.io/tags/math/) | -| 5 | [Greedy](greedy/README.md) | [贪心](https://openset.github.io/tags/greedy/) | | 6 | [Depth-First Search](depth-first-search/README.md) | [深度优先搜索](https://openset.github.io/tags/depth-first-search/) | -| 7 | [Tree](tree/README.md) | [树](https://openset.github.io/tags/tree/) | | 8 | [Hash Table](hash-table/README.md) | [哈希表](https://openset.github.io/tags/hash-table/) | -| 9 | [Binary Search](binary-search/README.md) | [二分查找](https://openset.github.io/tags/binary-search/) | | 10 | [Breadth-First Search](breadth-first-search/README.md) | [广度优先搜索](https://openset.github.io/tags/breadth-first-search/) | -| 11 | [Sort](sort/README.md) | [排序](https://openset.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://openset.github.io/tags/two-pointers/) | -| 13 | [Backtracking](backtracking/README.md) | [回溯](https://openset.github.io/tags/backtracking/) | | 14 | [Design](design/README.md) | [设计](https://openset.github.io/tags/design/) | -| 15 | [Stack](stack/README.md) | [栈](https://openset.github.io/tags/stack/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://openset.github.io/tags/bit-manipulation/) | -| 17 | [Graph](graph/README.md) | [图](https://openset.github.io/tags/graph/) | | 18 | [Heap](heap/README.md) | [堆](https://openset.github.io/tags/heap/) | -| 19 | [Linked List](linked-list/README.md) | [链表](https://openset.github.io/tags/linked-list/) | | 20 | [Recursion](recursion/README.md) | [递归](https://openset.github.io/tags/recursion/) | -| 21 | [Union Find](union-find/README.md) | [并查集](https://openset.github.io/tags/union-find/) | | 22 | [Sliding Window](sliding-window/README.md) | [滑动窗口](https://openset.github.io/tags/sliding-window/) | -| 23 | [Trie](trie/README.md) | [字典树](https://openset.github.io/tags/trie/) | | 24 | [Divide and Conquer](divide-and-conquer/README.md) | [分治](https://openset.github.io/tags/divide-and-conquer/) | -| 25 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://openset.github.io/tags/ordered-map/) | | 26 | [Segment Tree](segment-tree/README.md) | [线段树](https://openset.github.io/tags/segment-tree/) | -| 27 | [Queue](queue/README.md) | [队列](https://openset.github.io/tags/queue/) | | 28 | [Geometry](geometry/README.md) | [几何](https://openset.github.io/tags/geometry/) | -| 29 | [Line Sweep](line-sweep/README.md) | [扫描线](https://openset.github.io/tags/line-sweep/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://openset.github.io/tags/binary-indexed-tree/) | -| 31 | [Minimax](minimax/README.md) | [极小化极大](https://openset.github.io/tags/minimax/) | | 32 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://openset.github.io/tags/brainteaser/) | -| 33 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://openset.github.io/tags/topological-sort/) | | 34 | [Dequeue](dequeue/README.md) | [Dequeue](https://openset.github.io/tags/dequeue/) | -| 35 | [Random](random/README.md) | [Random](https://openset.github.io/tags/random/) | | 36 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://openset.github.io/tags/binary-search-tree/) | -| 37 | [Rolling Hash](rolling-hash/README.md) | [滚动哈希](https://openset.github.io/tags/rolling-hash/) | | 38 | [Suffix Array](suffix-array/README.md) | [后缀数组](https://openset.github.io/tags/suffix-array/) | -| 39 | [Rejection Sampling](rejection-sampling/README.md) | [拒绝采样](https://openset.github.io/tags/rejection-sampling/) | | 40 | [Reservoir Sampling](reservoir-sampling/README.md) | [水塘抽样](https://openset.github.io/tags/reservoir-sampling/) | -| 41 | [Meet In The Middle](meet-in-the-middle/README.md) | [Meet In The Middle](https://openset.github.io/tags/meet-in-the-middle/) | | 42 | [Memoization](memoization/README.md) | [记忆化搜索](https://openset.github.io/tags/memoization/) | -| 43 | [OOP](oop/README.md) | [OOP](https://openset.github.io/tags/oop/) | | 44 | [Sorting](sorting/README.md) | [排序](https://openset.github.io/tags/sorting/) | -| 45 | [Heap (Priority Queue)](heap-priority-queue/README.md) | [堆(优先队列)](https://openset.github.io/tags/heap-priority-queue/) | | 46 | [Ordered Set](ordered-set/README.md) | [有序集合](https://openset.github.io/tags/ordered-set/) | -| 47 | [Hash Function](hash-function/README.md) | [哈希函数](https://openset.github.io/tags/hash-function/) | | 48 | [String Matching](string-matching/README.md) | [字符串匹配](https://openset.github.io/tags/string-matching/) | -| 49 | [Randomized](randomized/README.md) | [随机化](https://openset.github.io/tags/randomized/) | | 50 | [Prefix Sum](prefix-sum/README.md) | [前缀和](https://openset.github.io/tags/prefix-sum/) | -| 51 | [Probability and Statistics](probability-and-statistics/README.md) | [概率与统计](https://openset.github.io/tags/probability-and-statistics/) | | 52 | [Simulation](simulation/README.md) | [模拟](https://openset.github.io/tags/simulation/) | -| 53 | [Monotonic Queue](monotonic-queue/README.md) | [单调队列](https://openset.github.io/tags/monotonic-queue/) | | 54 | [Data Stream](data-stream/README.md) | [数据流](https://openset.github.io/tags/data-stream/) | -| 55 | [Counting](counting/README.md) | [计数](https://openset.github.io/tags/counting/) | | 56 | [Matrix](matrix/README.md) | [矩阵](https://openset.github.io/tags/matrix/) | -| 57 | [Iterator](iterator/README.md) | [迭代器](https://openset.github.io/tags/iterator/) | | 58 | [Quickselect](quickselect/README.md) | [快速选择](https://openset.github.io/tags/quickselect/) | -| 59 | [Merge Sort](merge-sort/README.md) | [归并排序](https://openset.github.io/tags/merge-sort/) | | 60 | [Binary Tree](binary-tree/README.md) | [二叉树](https://openset.github.io/tags/binary-tree/) | -| 61 | [Combinatorics](combinatorics/README.md) | [组合数学](https://openset.github.io/tags/combinatorics/) | | 62 | [Shortest Path](shortest-path/README.md) | [最短路](https://openset.github.io/tags/shortest-path/) | -| 63 | [Interactive](interactive/README.md) | [交互](https://openset.github.io/tags/interactive/) | | 64 | [Bucket Sort](bucket-sort/README.md) | [桶排序](https://openset.github.io/tags/bucket-sort/) | -| 65 | [Counting Sort](counting-sort/README.md) | [计数排序](https://openset.github.io/tags/counting-sort/) | | 66 | [Radix Sort](radix-sort/README.md) | [基数排序](https://openset.github.io/tags/radix-sort/) | -| 67 | [Monotonic Stack](monotonic-stack/README.md) | [单调栈](https://openset.github.io/tags/monotonic-stack/) | | 68 | [Minimum Spanning Tree](minimum-spanning-tree/README.md) | [最小生成树](https://openset.github.io/tags/minimum-spanning-tree/) | -| 69 | [Strongly Connected Component](strongly-connected-component/README.md) | [强连通分量](https://openset.github.io/tags/strongly-connected-component/) | | 70 | [Game Theory](game-theory/README.md) | [博弈](https://openset.github.io/tags/game-theory/) | -| 71 | [Bitmask](bitmask/README.md) | [状态压缩](https://openset.github.io/tags/bitmask/) | | 72 | [Concurrency](concurrency/README.md) | [多线程](https://openset.github.io/tags/concurrency/) | -| 73 | [Doubly-Linked List](doubly-linked-list/README.md) | [双向链表](https://openset.github.io/tags/doubly-linked-list/) | | 74 | [Enumeration](enumeration/README.md) | [枚举](https://openset.github.io/tags/enumeration/) | -| 75 | [Number Theory](number-theory/README.md) | [数论](https://openset.github.io/tags/number-theory/) | | 76 | [Biconnected Component](biconnected-component/README.md) | [双连通分量](https://openset.github.io/tags/biconnected-component/) | -| 77 | [Eulerian Circuit](eulerian-circuit/README.md) | [欧拉回路](https://openset.github.io/tags/eulerian-circuit/) | \ No newline at end of file +| 1 | [Array](array/README.md) | [数组](https://awesee.github.io/tags/array/) | | 2 | [Dynamic Programming](dynamic-programming/README.md) | [动态规划](https://awesee.github.io/tags/dynamic-programming/) | +| 3 | [String](string/README.md) | [字符串](https://awesee.github.io/tags/string/) | | 4 | [Math](math/README.md) | [数学](https://awesee.github.io/tags/math/) | +| 5 | [Greedy](greedy/README.md) | [贪心](https://awesee.github.io/tags/greedy/) | | 6 | [Depth-First Search](depth-first-search/README.md) | [深度优先搜索](https://awesee.github.io/tags/depth-first-search/) | +| 7 | [Tree](tree/README.md) | [树](https://awesee.github.io/tags/tree/) | | 8 | [Hash Table](hash-table/README.md) | [哈希表](https://awesee.github.io/tags/hash-table/) | +| 9 | [Binary Search](binary-search/README.md) | [二分查找](https://awesee.github.io/tags/binary-search/) | | 10 | [Breadth-First Search](breadth-first-search/README.md) | [广度优先搜索](https://awesee.github.io/tags/breadth-first-search/) | +| 11 | [Sort](sort/README.md) | [排序](https://awesee.github.io/tags/sort/) | | 12 | [Two Pointers](two-pointers/README.md) | [双指针](https://awesee.github.io/tags/two-pointers/) | +| 13 | [Backtracking](backtracking/README.md) | [回溯](https://awesee.github.io/tags/backtracking/) | | 14 | [Design](design/README.md) | [设计](https://awesee.github.io/tags/design/) | +| 15 | [Stack](stack/README.md) | [栈](https://awesee.github.io/tags/stack/) | | 16 | [Bit Manipulation](bit-manipulation/README.md) | [位运算](https://awesee.github.io/tags/bit-manipulation/) | +| 17 | [Graph](graph/README.md) | [图](https://awesee.github.io/tags/graph/) | | 18 | [Heap](heap/README.md) | [堆](https://awesee.github.io/tags/heap/) | +| 19 | [Linked List](linked-list/README.md) | [链表](https://awesee.github.io/tags/linked-list/) | | 20 | [Recursion](recursion/README.md) | [递归](https://awesee.github.io/tags/recursion/) | +| 21 | [Union Find](union-find/README.md) | [并查集](https://awesee.github.io/tags/union-find/) | | 22 | [Sliding Window](sliding-window/README.md) | [滑动窗口](https://awesee.github.io/tags/sliding-window/) | +| 23 | [Trie](trie/README.md) | [字典树](https://awesee.github.io/tags/trie/) | | 24 | [Divide and Conquer](divide-and-conquer/README.md) | [分治](https://awesee.github.io/tags/divide-and-conquer/) | +| 25 | [Ordered Map](ordered-map/README.md) | [Ordered Map](https://awesee.github.io/tags/ordered-map/) | | 26 | [Segment Tree](segment-tree/README.md) | [线段树](https://awesee.github.io/tags/segment-tree/) | +| 27 | [Queue](queue/README.md) | [队列](https://awesee.github.io/tags/queue/) | | 28 | [Geometry](geometry/README.md) | [几何](https://awesee.github.io/tags/geometry/) | +| 29 | [Line Sweep](line-sweep/README.md) | [扫描线](https://awesee.github.io/tags/line-sweep/) | | 30 | [Binary Indexed Tree](binary-indexed-tree/README.md) | [树状数组](https://awesee.github.io/tags/binary-indexed-tree/) | +| 31 | [Minimax](minimax/README.md) | [极小化极大](https://awesee.github.io/tags/minimax/) | | 32 | [Brainteaser](brainteaser/README.md) | [脑筋急转弯](https://awesee.github.io/tags/brainteaser/) | +| 33 | [Topological Sort](topological-sort/README.md) | [拓扑排序](https://awesee.github.io/tags/topological-sort/) | | 34 | [Dequeue](dequeue/README.md) | [Dequeue](https://awesee.github.io/tags/dequeue/) | +| 35 | [Random](random/README.md) | [Random](https://awesee.github.io/tags/random/) | | 36 | [Binary Search Tree](binary-search-tree/README.md) | [二叉搜索树](https://awesee.github.io/tags/binary-search-tree/) | +| 37 | [Rolling Hash](rolling-hash/README.md) | [滚动哈希](https://awesee.github.io/tags/rolling-hash/) | | 38 | [Suffix Array](suffix-array/README.md) | [后缀数组](https://awesee.github.io/tags/suffix-array/) | +| 39 | [Rejection Sampling](rejection-sampling/README.md) | [拒绝采样](https://awesee.github.io/tags/rejection-sampling/) | | 40 | [Reservoir Sampling](reservoir-sampling/README.md) | [水塘抽样](https://awesee.github.io/tags/reservoir-sampling/) | +| 41 | [Meet In The Middle](meet-in-the-middle/README.md) | [Meet In The Middle](https://awesee.github.io/tags/meet-in-the-middle/) | | 42 | [Memoization](memoization/README.md) | [记忆化搜索](https://awesee.github.io/tags/memoization/) | +| 43 | [OOP](oop/README.md) | [OOP](https://awesee.github.io/tags/oop/) | | 44 | [Sorting](sorting/README.md) | [排序](https://awesee.github.io/tags/sorting/) | +| 45 | [Heap (Priority Queue)](heap-priority-queue/README.md) | [堆(优先队列)](https://awesee.github.io/tags/heap-priority-queue/) | | 46 | [Ordered Set](ordered-set/README.md) | [有序集合](https://awesee.github.io/tags/ordered-set/) | +| 47 | [Hash Function](hash-function/README.md) | [哈希函数](https://awesee.github.io/tags/hash-function/) | | 48 | [String Matching](string-matching/README.md) | [字符串匹配](https://awesee.github.io/tags/string-matching/) | +| 49 | [Randomized](randomized/README.md) | [随机化](https://awesee.github.io/tags/randomized/) | | 50 | [Prefix Sum](prefix-sum/README.md) | [前缀和](https://awesee.github.io/tags/prefix-sum/) | +| 51 | [Probability and Statistics](probability-and-statistics/README.md) | [概率与统计](https://awesee.github.io/tags/probability-and-statistics/) | | 52 | [Simulation](simulation/README.md) | [模拟](https://awesee.github.io/tags/simulation/) | +| 53 | [Monotonic Queue](monotonic-queue/README.md) | [单调队列](https://awesee.github.io/tags/monotonic-queue/) | | 54 | [Data Stream](data-stream/README.md) | [数据流](https://awesee.github.io/tags/data-stream/) | +| 55 | [Counting](counting/README.md) | [计数](https://awesee.github.io/tags/counting/) | | 56 | [Matrix](matrix/README.md) | [矩阵](https://awesee.github.io/tags/matrix/) | +| 57 | [Iterator](iterator/README.md) | [迭代器](https://awesee.github.io/tags/iterator/) | | 58 | [Quickselect](quickselect/README.md) | [快速选择](https://awesee.github.io/tags/quickselect/) | +| 59 | [Merge Sort](merge-sort/README.md) | [归并排序](https://awesee.github.io/tags/merge-sort/) | | 60 | [Binary Tree](binary-tree/README.md) | [二叉树](https://awesee.github.io/tags/binary-tree/) | +| 61 | [Combinatorics](combinatorics/README.md) | [组合数学](https://awesee.github.io/tags/combinatorics/) | | 62 | [Shortest Path](shortest-path/README.md) | [最短路](https://awesee.github.io/tags/shortest-path/) | +| 63 | [Interactive](interactive/README.md) | [交互](https://awesee.github.io/tags/interactive/) | | 64 | [Bucket Sort](bucket-sort/README.md) | [桶排序](https://awesee.github.io/tags/bucket-sort/) | +| 65 | [Counting Sort](counting-sort/README.md) | [计数排序](https://awesee.github.io/tags/counting-sort/) | | 66 | [Radix Sort](radix-sort/README.md) | [基数排序](https://awesee.github.io/tags/radix-sort/) | +| 67 | [Monotonic Stack](monotonic-stack/README.md) | [单调栈](https://awesee.github.io/tags/monotonic-stack/) | | 68 | [Minimum Spanning Tree](minimum-spanning-tree/README.md) | [最小生成树](https://awesee.github.io/tags/minimum-spanning-tree/) | +| 69 | [Strongly Connected Component](strongly-connected-component/README.md) | [强连通分量](https://awesee.github.io/tags/strongly-connected-component/) | | 70 | [Game Theory](game-theory/README.md) | [博弈](https://awesee.github.io/tags/game-theory/) | +| 71 | [Bitmask](bitmask/README.md) | [状态压缩](https://awesee.github.io/tags/bitmask/) | | 72 | [Concurrency](concurrency/README.md) | [多线程](https://awesee.github.io/tags/concurrency/) | +| 73 | [Doubly-Linked List](doubly-linked-list/README.md) | [双向链表](https://awesee.github.io/tags/doubly-linked-list/) | | 74 | [Enumeration](enumeration/README.md) | [枚举](https://awesee.github.io/tags/enumeration/) | +| 75 | [Number Theory](number-theory/README.md) | [数论](https://awesee.github.io/tags/number-theory/) | | 76 | [Biconnected Component](biconnected-component/README.md) | [双连通分量](https://awesee.github.io/tags/biconnected-component/) | +| 77 | [Eulerian Circuit](eulerian-circuit/README.md) | [欧拉回路](https://awesee.github.io/tags/eulerian-circuit/) | \ No newline at end of file diff --git a/tag/array/README.md b/tag/array/README.md index 0ed39d8a2..90abb510d 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -1,14 +1,17 @@ - - - + + + ## [话题分类](../README.md) > 数组 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 2079 | [给植物浇水](../../problems/watering-plants) | [[数组](../array/README.md)] | Medium | +| 2078 | [两栋颜色不同且距离最远的房子](../../problems/two-furthest-houses-with-different-colors) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 2073 | [买票需要的时间](../../problems/time-needed-to-buy-tickets) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 2070 | [每一个查询的最大美丽值](../../problems/most-beautiful-item-for-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index 502c29958..b864fa7ec 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 回溯 diff --git a/tag/biconnected-component/README.md b/tag/biconnected-component/README.md index 24393482a..04440ac7e 100644 --- a/tag/biconnected-component/README.md +++ b/tag/biconnected-component/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 双连通分量 diff --git a/tag/binary-indexed-tree/README.md b/tag/binary-indexed-tree/README.md index 9efbf1687..350e34ae8 100644 --- a/tag/binary-indexed-tree/README.md +++ b/tag/binary-indexed-tree/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 树状数组 diff --git a/tag/binary-search-tree/README.md b/tag/binary-search-tree/README.md index 7960c1f8f..3a558f6de 100644 --- a/tag/binary-search-tree/README.md +++ b/tag/binary-search-tree/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 二叉搜索树 diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index be5e9e54a..3205ba91a 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -1,14 +1,15 @@ - - - + + + ## [话题分类](../README.md) > 二分查找 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 2070 | [每一个查询的最大美丽值](../../problems/most-beautiful-item-for-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 2064 | [分配给商店的最多商品的最小值](../../problems/minimized-maximum-of-products-distributed-to-any-store) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/binary-tree/README.md b/tag/binary-tree/README.md index db723ee96..9cea043e7 100644 --- a/tag/binary-tree/README.md +++ b/tag/binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 二叉树 diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index 8e7e9b5ee..f008e795e 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 位运算 diff --git a/tag/bitmask/README.md b/tag/bitmask/README.md index b15c69aa3..056368cdd 100644 --- a/tag/bitmask/README.md +++ b/tag/bitmask/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 状态压缩 diff --git a/tag/brainteaser/README.md b/tag/brainteaser/README.md index c0b3910d8..c19f7f1e2 100644 --- a/tag/brainteaser/README.md +++ b/tag/brainteaser/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 脑筋急转弯 diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index ce91b4628..54cf36cd5 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 广度优先搜索 @@ -14,7 +14,7 @@ | 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1992 | [找到所有的农场组](../../problems/find-all-groups-of-farmland) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1971 | [Find if Path Exists in Graph](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | +| 1971 | [寻找图中是否存在路径](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | | 1970 | [你能穿过矩阵的最后一天](../../problems/last-day-where-you-can-still-cross) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1926 | [迷宫中离入口最近的出口](../../problems/nearest-exit-from-entrance-in-maze) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | diff --git a/tag/bucket-sort/README.md b/tag/bucket-sort/README.md index b136e2646..57c6c0ff4 100644 --- a/tag/bucket-sort/README.md +++ b/tag/bucket-sort/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 桶排序 diff --git a/tag/combinatorics/README.md b/tag/combinatorics/README.md index 2e59a4103..c3322fa15 100644 --- a/tag/combinatorics/README.md +++ b/tag/combinatorics/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 组合数学 diff --git a/tag/concurrency/README.md b/tag/concurrency/README.md index b06421577..6ad20643a 100644 --- a/tag/concurrency/README.md +++ b/tag/concurrency/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 多线程 diff --git a/tag/counting-sort/README.md b/tag/counting-sort/README.md index 5fd0c4b31..80437a981 100644 --- a/tag/counting-sort/README.md +++ b/tag/counting-sort/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 计数排序 diff --git a/tag/counting/README.md b/tag/counting/README.md index 1ffc4d5bf..111d9c1de 100644 --- a/tag/counting/README.md +++ b/tag/counting/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 计数 diff --git a/tag/data-stream/README.md b/tag/data-stream/README.md index b733a60f3..1f6d61328 100644 --- a/tag/data-stream/README.md +++ b/tag/data-stream/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 数据流 diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index da3b6896e..6174bf935 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 深度优先搜索 @@ -12,7 +12,7 @@ | 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1992 | [找到所有的农场组](../../problems/find-all-groups-of-farmland) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1971 | [Find if Path Exists in Graph](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | +| 1971 | [寻找图中是否存在路径](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | | 1970 | [你能穿过矩阵的最后一天](../../problems/last-day-where-you-can-still-cross) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1905 | [统计子岛屿](../../problems/count-sub-islands) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | diff --git a/tag/dequeue/README.md b/tag/dequeue/README.md index 337f59d12..f86e5c7c7 100644 --- a/tag/dequeue/README.md +++ b/tag/dequeue/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > Dequeue diff --git a/tag/design/README.md b/tag/design/README.md index 1bcdb3140..e62692267 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -1,14 +1,15 @@ - - - + + + ## [话题分类](../README.md) > 设计 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2069 | [模拟行走机器人 II](../../problems/walking-robot-simulation-ii) | [[设计](../design/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index 3d2028983..6e1eebbbb 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 分治 diff --git a/tag/doubly-linked-list/README.md b/tag/doubly-linked-list/README.md index 9cb65f12b..104be93b5 100644 --- a/tag/doubly-linked-list/README.md +++ b/tag/doubly-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 双向链表 diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index 9b51c3b2c..e156b1010 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 动态规划 @@ -211,7 +211,7 @@ | 847 | [访问所有节点的最短路径](../../problems/shortest-path-visiting-all-nodes) | [[位运算](../bit-manipulation/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 845 | [数组中的最长山脉](../../problems/longest-mountain-in-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[枚举](../enumeration/README.md)] | Medium | | 838 | [推多米诺](../../problems/push-dominoes) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 837 | [新21点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 837 | [新 21 点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | | 834 | [树中距离之和](../../problems/sum-of-distances-in-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 828 | [统计子串中的唯一字符](../../problems/count-unique-characters-of-all-substrings-of-a-given-string) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 823 | [带因子的二叉树](../../problems/binary-trees-with-factors) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/enumeration/README.md b/tag/enumeration/README.md index f2c725d05..cfa2fed90 100644 --- a/tag/enumeration/README.md +++ b/tag/enumeration/README.md @@ -1,14 +1,15 @@ - - - + + + ## [话题分类](../README.md) > 枚举 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2081 | [k 镜像数字的和](../../problems/sum-of-k-mirror-numbers) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2048 | [下一个更大的数值平衡数](../../problems/next-greater-numerically-balanced-number) | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Medium | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2018 | [判断单词是否能放入填字游戏内](../../problems/check-if-word-can-be-placed-in-crossword) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | diff --git a/tag/eulerian-circuit/README.md b/tag/eulerian-circuit/README.md index 4a15e673d..f48b4407a 100644 --- a/tag/eulerian-circuit/README.md +++ b/tag/eulerian-circuit/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 欧拉回路 diff --git a/tag/game-theory/README.md b/tag/game-theory/README.md index f47303880..50c4354cf 100644 --- a/tag/game-theory/README.md +++ b/tag/game-theory/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 博弈 diff --git a/tag/geometry/README.md b/tag/geometry/README.md index d63defc50..3bb8dcf8f 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 几何 diff --git a/tag/graph/README.md b/tag/graph/README.md index d40bb1c01..2c116d55e 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -1,20 +1,22 @@ - - - + + + ## [话题分类](../README.md) > 图 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2077 | [Paths in Maze That Lead to Same Room](../../problems/paths-in-maze-that-lead-to-same-room) 🔒 | [[图](../graph/README.md)] | Medium | +| 2076 | [处理含限制条件的好友请求](../../problems/process-restricted-friend-requests) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 2065 | [最大化一张图中的路径价值](../../problems/maximum-path-quality-of-a-graph) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 2050 | [并行课程 III](../../problems/parallel-courses-iii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | -| 1971 | [Find if Path Exists in Graph](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | +| 1971 | [寻找图中是否存在路径](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | | 1928 | [规定时间内到达终点的最小花费](../../problems/minimum-cost-to-reach-destination-in-time) | [[图](../graph/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1857 | [有向图中最大颜色值](../../problems/largest-color-value-in-a-directed-graph) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] [[计数](../counting/README.md)] | Hard | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index b992d5bed..0d5ade543 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -1,14 +1,15 @@ - - - + + + ## [话题分类](../README.md) > 贪心 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2078 | [两栋颜色不同且距离最远的房子](../../problems/two-furthest-houses-with-different-colors) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 2038 | [如果相邻两个颜色均相同则删除当前颜色](../../problems/remove-colored-pieces-if-both-neighbors-are-the-same-color) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 2030 | [含特定字母的最小子序列](../../problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | diff --git a/tag/hash-function/README.md b/tag/hash-function/README.md index 9b5971506..7061229ce 100644 --- a/tag/hash-function/README.md +++ b/tag/hash-function/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 哈希函数 diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index b3e559827..ac840e676 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -1,14 +1,15 @@ - - - + + + ## [话题分类](../README.md) > 哈希表 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2068 | [检查两个字符串是否几乎相等](../../problems/check-whether-two-strings-are-almost-equivalent) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2062 | [统计字符串中的元音子字符串](../../problems/count-vowel-substrings-of-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 2053 | [数组中第 K 个独一无二的字符串](../../problems/kth-distinct-string-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | diff --git a/tag/heap-priority-queue/README.md b/tag/heap-priority-queue/README.md index f27a28295..c5868632c 100644 --- a/tag/heap-priority-queue/README.md +++ b/tag/heap-priority-queue/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 堆(优先队列) diff --git a/tag/heap/README.md b/tag/heap/README.md index 39b134930..48c257e6f 100644 --- a/tag/heap/README.md +++ b/tag/heap/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 堆 diff --git a/tag/interactive/README.md b/tag/interactive/README.md index d089e633f..542b0fb48 100644 --- a/tag/interactive/README.md +++ b/tag/interactive/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 交互 diff --git a/tag/iterator/README.md b/tag/iterator/README.md index d7569eef4..641c321ca 100644 --- a/tag/iterator/README.md +++ b/tag/iterator/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 迭代器 diff --git a/tag/line-sweep/README.md b/tag/line-sweep/README.md index ca06abe3c..8cd80d13e 100644 --- a/tag/line-sweep/README.md +++ b/tag/line-sweep/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 扫描线 diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index f7822a978..c58530bba 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 链表 diff --git a/tag/math/README.md b/tag/math/README.md index 9c7ca9107..053a05c92 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -1,14 +1,15 @@ - - - + + + ## [话题分类](../README.md) > 数学 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2081 | [k 镜像数字的和](../../problems/sum-of-k-mirror-numbers) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2063 | [所有子字符串中的元音](../../problems/vowels-of-all-substrings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | | 2048 | [下一个更大的数值平衡数](../../problems/next-greater-numerically-balanced-number) | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Medium | | 2038 | [如果相邻两个颜色均相同则删除当前颜色](../../problems/remove-colored-pieces-if-both-neighbors-are-the-same-color) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] | Medium | @@ -199,7 +200,7 @@ | 858 | [镜面反射](../../problems/mirror-reflection) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | | 843 | [猜猜这个单词](../../problems/guess-the-word) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] [[交互](../interactive/README.md)] | Hard | | 840 | [矩阵中的幻方](../../problems/magic-squares-in-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 837 | [新21点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 837 | [新 21 点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | | 836 | [矩形重叠](../../problems/rectangle-overlap) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Easy | | 829 | [连续整数求和](../../problems/consecutive-numbers-sum) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 812 | [最大三角形面积](../../problems/largest-triangle-area) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | diff --git a/tag/matrix/README.md b/tag/matrix/README.md index 997dc3f2b..f1af6860d 100644 --- a/tag/matrix/README.md +++ b/tag/matrix/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 矩阵 diff --git a/tag/meet-in-the-middle/README.md b/tag/meet-in-the-middle/README.md index e22e2978d..0b779f115 100644 --- a/tag/meet-in-the-middle/README.md +++ b/tag/meet-in-the-middle/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > Meet In The Middle diff --git a/tag/memoization/README.md b/tag/memoization/README.md index f1f07257d..377f20f06 100644 --- a/tag/memoization/README.md +++ b/tag/memoization/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 记忆化搜索 diff --git a/tag/merge-sort/README.md b/tag/merge-sort/README.md index 29614f7df..87b8fff12 100644 --- a/tag/merge-sort/README.md +++ b/tag/merge-sort/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 归并排序 diff --git a/tag/minimax/README.md b/tag/minimax/README.md index dd3b3951d..2b0194212 100644 --- a/tag/minimax/README.md +++ b/tag/minimax/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 极小化极大 diff --git a/tag/minimum-spanning-tree/README.md b/tag/minimum-spanning-tree/README.md index 936ea815d..8fcbd0882 100644 --- a/tag/minimum-spanning-tree/README.md +++ b/tag/minimum-spanning-tree/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 最小生成树 diff --git a/tag/monotonic-queue/README.md b/tag/monotonic-queue/README.md index 2297ba064..79f7a4226 100644 --- a/tag/monotonic-queue/README.md +++ b/tag/monotonic-queue/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 单调队列 diff --git a/tag/monotonic-stack/README.md b/tag/monotonic-stack/README.md index b53323820..69ccccc69 100644 --- a/tag/monotonic-stack/README.md +++ b/tag/monotonic-stack/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 单调栈 diff --git a/tag/number-theory/README.md b/tag/number-theory/README.md index 82435c8d2..47d79b04e 100644 --- a/tag/number-theory/README.md +++ b/tag/number-theory/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 数论 diff --git a/tag/oop/README.md b/tag/oop/README.md index 4871b5c65..4920fb050 100644 --- a/tag/oop/README.md +++ b/tag/oop/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > OOP diff --git a/tag/ordered-map/README.md b/tag/ordered-map/README.md index 52afd5989..bce1a6995 100644 --- a/tag/ordered-map/README.md +++ b/tag/ordered-map/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > Ordered Map diff --git a/tag/ordered-set/README.md b/tag/ordered-set/README.md index 435f180e2..7665f8456 100644 --- a/tag/ordered-set/README.md +++ b/tag/ordered-set/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 有序集合 diff --git a/tag/prefix-sum/README.md b/tag/prefix-sum/README.md index a5638d976..82e3e9c76 100644 --- a/tag/prefix-sum/README.md +++ b/tag/prefix-sum/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 前缀和 diff --git a/tag/probability-and-statistics/README.md b/tag/probability-and-statistics/README.md index b2b07bfb3..e96a3f6ad 100644 --- a/tag/probability-and-statistics/README.md +++ b/tag/probability-and-statistics/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 概率与统计 @@ -13,6 +13,6 @@ | 1230 | [抛掷硬币](../../problems/toss-strange-coins) 🔒 | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | | 1227 | [飞机座位分配概率](../../problems/airplane-seat-assignment-probability) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | | 1093 | [大样本统计](../../problems/statistics-from-a-large-sample) | [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | -| 837 | [新21点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 837 | [新 21 点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | | 808 | [分汤](../../problems/soup-servings) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | | 470 | [用 Rand7() 实现 Rand10()](../../problems/implement-rand10-using-rand7) | [[数学](../math/README.md)] [[拒绝采样](../rejection-sampling/README.md)] [[概率与统计](../probability-and-statistics/README.md)] [[随机化](../randomized/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index 3f3d21fda..d76a040d3 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 队列 diff --git a/tag/quickselect/README.md b/tag/quickselect/README.md index 02d685efc..758e2f111 100644 --- a/tag/quickselect/README.md +++ b/tag/quickselect/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 快速选择 diff --git a/tag/radix-sort/README.md b/tag/radix-sort/README.md index c7e8486e7..859147d07 100644 --- a/tag/radix-sort/README.md +++ b/tag/radix-sort/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 基数排序 diff --git a/tag/random/README.md b/tag/random/README.md index 72a82d98f..66c8e79c0 100644 --- a/tag/random/README.md +++ b/tag/random/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > Random diff --git a/tag/randomized/README.md b/tag/randomized/README.md index 3e12f223b..c991c6b5f 100644 --- a/tag/randomized/README.md +++ b/tag/randomized/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 随机化 diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 4b9f00891..9e3769198 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 递归 diff --git a/tag/rejection-sampling/README.md b/tag/rejection-sampling/README.md index ba0e34fee..7dda478a0 100644 --- a/tag/rejection-sampling/README.md +++ b/tag/rejection-sampling/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 拒绝采样 diff --git a/tag/reservoir-sampling/README.md b/tag/reservoir-sampling/README.md index 34b47a93f..719ab9946 100644 --- a/tag/reservoir-sampling/README.md +++ b/tag/reservoir-sampling/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 水塘抽样 diff --git a/tag/rolling-hash/README.md b/tag/rolling-hash/README.md index b4076acbc..85629bdc3 100644 --- a/tag/rolling-hash/README.md +++ b/tag/rolling-hash/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 滚动哈希 diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index 55fd9bddb..872832452 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -1,14 +1,15 @@ - - - + + + ## [话题分类](../README.md) > 线段树 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | diff --git a/tag/shortest-path/README.md b/tag/shortest-path/README.md index 1b0378a62..a1cacef5d 100644 --- a/tag/shortest-path/README.md +++ b/tag/shortest-path/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 最短路 diff --git a/tag/simulation/README.md b/tag/simulation/README.md index 550c95a99..de5ff39b9 100644 --- a/tag/simulation/README.md +++ b/tag/simulation/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 模拟 diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index fe8902785..888c73f17 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 滑动窗口 @@ -49,7 +49,7 @@ | 930 | [和相同的二元子数组](../../problems/binary-subarrays-with-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 904 | [水果成篮](../../problems/fruit-into-baskets) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 862 | [和至少为 K 的最短子数组](../../problems/shortest-subarray-with-sum-at-least-k) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 837 | [新21点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | +| 837 | [新 21 点](../../problems/new-21-game) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Medium | | 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | | 718 | [最长重复子数组](../../problems/maximum-length-of-repeated-subarray) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | | 713 | [乘积小于K的子数组](../../problems/subarray-product-less-than-k) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | diff --git a/tag/sort/README.md b/tag/sort/README.md index 49e4c7112..420418d41 100644 --- a/tag/sort/README.md +++ b/tag/sort/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 排序 diff --git a/tag/sorting/README.md b/tag/sorting/README.md index 0b4e358dd..1e795d316 100644 --- a/tag/sorting/README.md +++ b/tag/sorting/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 排序 diff --git a/tag/stack/README.md b/tag/stack/README.md index cd27a9446..7fe784c89 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 栈 diff --git a/tag/string-matching/README.md b/tag/string-matching/README.md index 67472968a..304b8dd22 100644 --- a/tag/string-matching/README.md +++ b/tag/string-matching/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 字符串匹配 diff --git a/tag/string/README.md b/tag/string/README.md index a013be18a..f61110315 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 字符串 diff --git a/tag/strongly-connected-component/README.md b/tag/strongly-connected-component/README.md index d32a1515e..10e0277ac 100644 --- a/tag/strongly-connected-component/README.md +++ b/tag/strongly-connected-component/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 强连通分量 diff --git a/tag/suffix-array/README.md b/tag/suffix-array/README.md index 4e956db05..de556bab0 100644 --- a/tag/suffix-array/README.md +++ b/tag/suffix-array/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 后缀数组 diff --git a/tag/topological-sort/README.md b/tag/topological-sort/README.md index 5ef75237a..f3fc7304f 100644 --- a/tag/topological-sort/README.md +++ b/tag/topological-sort/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 拓扑排序 diff --git a/tag/tree/README.md b/tag/tree/README.md index 6db4f7127..a4f396b09 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 树 diff --git a/tag/trie/README.md b/tag/trie/README.md index 4221d14ad..1b00eff9c 100644 --- a/tag/trie/README.md +++ b/tag/trie/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 字典树 diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index ac1e57620..b676b857d 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -1,8 +1,8 @@ - - - + + + ## [话题分类](../README.md) > 双指针 diff --git a/tag/union-find/README.md b/tag/union-find/README.md index 9cd25bba1..b13c5ebf0 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -1,14 +1,15 @@ - - - + + + ## [话题分类](../README.md) > 并查集 | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2076 | [处理含限制条件的好友请求](../../problems/process-restricted-friend-requests) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 1970 | [你能穿过矩阵的最后一天](../../problems/last-day-where-you-can-still-cross) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Hard | From 170643058e306cb821920bf7378f0c16ca48a070 Mon Sep 17 00:00:00 2001 From: Shuo Date: Sat, 27 Nov 2021 21:33:58 +0800 Subject: [PATCH 142/145] U: main --- .github/workflows/go.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 77fe0b084..288780793 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -2,9 +2,9 @@ name: Go on: push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] jobs: From d600c7dfd9b5227d61efe60d3d46e056cc5d4888 Mon Sep 17 00:00:00 2001 From: Shuo Date: Sat, 27 Nov 2021 21:43:50 +0800 Subject: [PATCH 143/145] U: main --- internal/base/base.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/base/base.go b/internal/base/base.go index 63c94a469..3b1b4451f 100644 --- a/internal/base/base.go +++ b/internal/base/base.go @@ -13,7 +13,7 @@ import ( ) // URL - base.URL -const URL = "https://github.com/awesee/leetcode/tree/master" +const URL = "https://github.com/awesee/leetcode/tree/main" // CmdName - base.CmdName var CmdName = filepath.Base(os.Args[0]) From ce6b5442cd7b9f7bc216be589e4ab481e67642dc Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 16 Feb 2022 15:49:36 +0800 Subject: [PATCH 144/145] A:new --- README.md | 541 ++++++------------ problems/01-matrix/README.md | 6 +- .../README.md | 61 ++ .../README.md | 103 ++++ .../README.md | 2 +- problems/account-balance/README.md | 2 +- problems/active-users/README.md | 6 +- .../add-minimum-number-of-rungs/README.md | 13 +- problems/add-two-numbers/README.md | 6 +- problems/adding-spaces-to-a-string/README.md | 82 +++ problems/ads-performance/README.md | 6 +- .../README.md | 16 +- .../README.md | 92 +++ .../README.md | 29 +- problems/all-oone-data-structure/README.md | 8 +- .../all-possible-full-binary-trees/README.md | 2 +- problems/allocate-mailboxes/README.md | 46 +- .../README.md | 40 ++ problems/android-unlock-patterns/README.md | 6 +- problems/apples-oranges/README.md | 6 +- problems/arithmetic-subarrays/README.md | 4 - problems/armstrong-number/README.md | 6 +- .../available-captures-for-rook/README.md | 6 +- .../README.md | 37 +- problems/average-waiting-time/README.md | 3 - problems/avoid-flood-in-the-city/README.md | 18 +- problems/backspace-string-compare/README.md | 10 +- problems/bag-of-tokens/README.md | 8 +- problems/battleships-in-a-board/README.md | 8 +- problems/beautiful-arrangement/README.md | 2 +- .../README.md | 35 +- .../README.md | 7 - .../README.md | 8 +- .../README.md | 20 +- .../README.md | 2 +- .../README.md | 6 +- problems/binary-subarrays-with-sum/README.md | 8 +- .../README.md | 6 +- .../binary-tree-right-side-view/README.md | 6 +- problems/binary-tree-upside-down/README.md | 6 +- .../README.md | 2 +- problems/break-a-palindrome/README.md | 13 - .../brightest-position-on-street/README.md | 2 +- .../README.md | 39 +- .../README.md | 6 +- problems/build-the-equation/README.md | 17 + problems/build-the-equation/mysql_schemas.sql | 5 + problems/burst-balloons/README.md | 8 +- problems/calculate-salaries/README.md | 6 +- problems/campus-bikes/README.md | 6 +- .../README.md | 3 + .../README.md | 5 +- .../README.md | 8 +- problems/capital-gainloss/README.md | 6 +- problems/capitalize-the-title/README.md | 74 +++ problems/car-fleet-ii/README.md | 7 +- problems/car-pooling/README.md | 22 +- problems/cat-and-mouse-ii/README.md | 30 +- .../cheapest-flights-within-k-stops/README.md | 6 +- .../README.md | 25 +- .../README.md | 86 +++ .../README.md | 34 +- .../README.md | 20 +- .../README.md | 66 +++ .../README.md | 3 + .../README.md | 26 - .../README.md | 18 - .../README.md | 18 +- .../README.md | 3 + .../README.md | 60 ++ .../check-if-n-and-its-double-exist/README.md | 9 +- .../README.md | 9 - .../README.md | 10 +- .../README.md | 23 +- .../README.md | 5 +- problems/cherry-pickup-ii/README.md | 49 +- problems/cherry-pickup/README.md | 6 +- .../README.md | 34 ++ problems/cinema-seat-allocation/README.md | 4 +- .../README.md | 41 +- .../README.md | 6 +- problems/clone-n-ary-tree/README.md | 6 +- .../README.md | 2 +- problems/closest-dessert-cost/README.md | 7 - problems/combination-sum-ii/README.md | 6 +- problems/combination-sum/README.md | 20 +- .../complement-of-base-10-integer/README.md | 6 +- .../README.md | 2 +- problems/consecutive-characters/README.md | 31 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 8 +- problems/container-with-most-water/README.md | 28 +- problems/contiguous-array/README.md | 6 +- problems/continuous-subarray-sum/README.md | 6 +- .../convert-1d-array-into-2d-array/README.md | 19 +- .../convert-bst-to-greater-tree/README.md | 16 +- .../README.md | 33 +- .../README.md | 4 +- .../README.md | 22 +- .../README.md | 17 - problems/corporate-flight-bookings/README.md | 6 +- problems/count-all-possible-routes/README.md | 22 +- .../README.md | 6 +- problems/count-binary-substrings/README.md | 6 +- .../README.md | 70 +++ .../README.md | 6 +- .../README.md | 62 ++ .../README.md | 99 ++++ problems/count-good-meals/README.md | 5 + .../count-good-nodes-in-binary-tree/README.md | 6 +- problems/count-good-triplets/README.md | 3 - problems/count-largest-group/README.md | 25 +- .../README.md | 14 - .../count-nice-pairs-in-an-array/README.md | 3 + .../README.md | 2 +- .../README.md | 2 + problems/count-number-of-teams/README.md | 8 +- .../README.md | 13 +- .../count-operations-to-obtain-zero/README.md | 69 +++ problems/count-pairs-in-two-arrays/README.md | 2 +- .../count-pairs-with-xor-in-a-range/README.md | 2 +- .../count-servers-that-communicate/README.md | 4 +- .../README.md | 6 +- .../mysql_schemas.sql | 20 +- problems/count-sub-islands/README.md | 7 +- .../README.md | 2 +- .../README.md | 20 +- .../README.md | 7 +- problems/count-the-hidden-sequences/README.md | 96 ++++ .../README.md | 2 +- .../count-the-number-of-experiments/README.md | 2 +- .../README.md | 25 +- .../README.md | 9 +- .../README.md | 86 +++ problems/counting-bits/README.md | 8 +- .../README.md | 3 + problems/create-a-session-bar-chart/README.md | 6 +- .../README.md | 6 +- .../decode-the-slanted-ciphertext/README.md | 8 - problems/decode-ways-ii/README.md | 1 + problems/decode-xored-permutation/README.md | 2 +- .../README.md | 28 +- problems/deepest-leaves-sum/README.md | 6 +- problems/degree-of-an-array/README.md | 6 +- problems/delete-duplicate-emails/README.md | 48 +- .../delete-duplicate-emails/mysql_schemas.sql | 7 +- .../README.md | 23 - .../README.md | 31 +- .../README.md | 6 +- .../README.md | 75 +++ .../README.md | 15 - .../README.md | 2 +- problems/describe-the-painting/README.md | 4 + .../design-a-file-sharing-system/README.md | 7 +- problems/design-bitset/README.md | 78 +++ problems/design-excel-sum-formula/README.md | 6 +- problems/design-file-system/README.md | 6 +- problems/design-hashmap/README.md | 9 +- problems/design-log-storage-system/README.md | 2 +- problems/design-movie-rental-system/README.md | 4 +- problems/design-parking-system/README.md | 2 +- problems/design-skiplist/README.md | 7 +- problems/design-snake-game/README.md | 6 +- problems/design-underground-system/README.md | 5 +- problems/destroying-asteroids/README.md | 78 +++ .../README.md | 27 +- .../README.md | 18 +- .../README.md | 13 - .../README.md | 3 + problems/detonate-the-maximum-bombs/README.md | 93 +++ problems/diagonal-traverse-ii/README.md | 33 +- problems/diameter-of-binary-tree/README.md | 9 +- problems/distant-barcodes/README.md | 4 +- problems/distinct-echo-substrings/README.md | 4 +- .../distribute-coins-in-binary-tree/README.md | 18 +- .../distribute-repeating-integers/README.md | 21 +- .../README.md | 73 +++ .../README.md | 2 +- .../README.md | 7 +- .../README.md | 95 +++ .../README.md | 3 + .../README.md | 33 ++ .../README.md | 2 +- problems/elimination-game/README.md | 6 +- .../README.md | 2 +- problems/encode-and-decode-strings/README.md | 8 +- problems/encode-and-decode-tinyurl/README.md | 2 +- .../README.md | 6 +- problems/equal-rational-numbers/README.md | 6 +- problems/erect-the-fence-ii/README.md | 2 +- problems/escape-a-large-maze/README.md | 4 +- .../README.md | 2 +- .../README.md | 6 - problems/even-odd-tree/README.md | 30 +- problems/excel-sheet-column-number/README.md | 13 +- .../README.md | 86 +++ problems/fair-candy-swap/README.md | 15 +- problems/filling-bookcase-shelves/README.md | 6 +- .../README.md | 6 +- .../README.md | 20 +- problems/find-a-peak-element-ii/README.md | 3 + .../README.md | 4 +- .../find-all-duplicates-in-an-array/README.md | 6 +- .../README.md | 67 +++ .../find-all-people-with-secret/README.md | 95 +++ .../README.md | 82 +++ problems/find-all-the-lonely-nodes/README.md | 4 + problems/find-and-replace-in-string/README.md | 6 +- problems/find-and-replace-pattern/README.md | 6 +- .../README.md | 6 +- .../README.md | 2 +- problems/find-duplicate-subtrees/README.md | 1 + .../README.md | 10 +- .../README.md | 67 +++ .../find-good-days-to-rob-the-bank/README.md | 86 +++ .../find-if-path-exists-in-graph/README.md | 10 +- problems/find-k-closest-elements/README.md | 6 +- .../README.md | 6 +- .../README.md | 26 +- .../README.md | 13 +- .../find-latest-group-of-size-m/README.md | 25 +- .../find-longest-awesome-substring/README.md | 11 +- .../find-lucky-integer-in-an-array/README.md | 18 +- .../README.md | 6 +- problems/find-missing-observations/README.md | 8 - .../README.md | 3 + .../README.md | 3 + problems/find-root-of-n-ary-tree/README.md | 5 +- .../README.md | 24 +- .../README.md | 72 +++ .../README.md | 75 +++ .../README.md | 70 +++ .../README.md | 11 +- .../README.md | 3 - .../README.md | 30 +- .../find-the-middle-index-in-array/README.md | 19 +- .../README.md | 8 - problems/find-the-missing-ids/README.md | 5 + .../README.md | 6 +- .../README.md | 16 +- .../README.md | 16 +- .../README.md | 3 +- .../README.md | 24 +- .../README.md | 33 +- .../README.md | 8 - .../finding-3-digit-even-numbers/README.md | 73 +++ problems/finding-mk-average/README.md | 7 +- .../README.md | 5 +- .../README.md | 2 +- .../README.md | 6 +- problems/fizz-buzz-multithreaded/README.md | 6 +- .../README.md | 6 +- problems/flip-game-ii/README.md | 6 +- .../README.md | 6 +- .../README.md | 26 +- problems/four-divisors/README.md | 6 +- .../frog-position-after-t-seconds/README.md | 23 +- problems/fruit-into-baskets/README.md | 8 - problems/game-play-analysis-i/README.md | 6 +- problems/get-the-maximum-score/README.md | 19 +- .../README.md | 6 +- .../README.md | 2 +- .../group-sold-products-by-the-date/README.md | 6 +- problems/groups-of-strings/README.md | 96 ++++ .../guess-number-higher-or-lower/README.md | 38 +- problems/guess-the-word/README.md | 2 +- problems/hexspeak/README.md | 6 +- problems/hopper-company-queries-i/README.md | 5 - problems/hopper-company-queries-iii/README.md | 5 - problems/house-robber-iii/README.md | 2 +- problems/house-robber/README.md | 6 +- .../README.md | 6 +- problems/html-entity-parser/README.md | 45 +- problems/image-overlap/README.md | 6 +- problems/immediate-food-delivery-i/README.md | 6 +- problems/immediate-food-delivery-ii/README.md | 6 +- .../implement-rand10-using-rand7/README.md | 6 +- problems/implement-strstr/README.md | 6 +- .../increasing-decreasing-string/README.md | 37 +- problems/integer-replacement/README.md | 6 +- problems/integer-to-english-words/README.md | 36 +- .../README.md | 83 +++ problems/is-graph-bipartite/README.md | 6 +- problems/jump-game-iii/README.md | 6 +- problems/jump-game-v/README.md | 25 +- problems/jump-game-vi/README.md | 8 +- .../README.md | 121 ++++ problems/k-radius-subarray-averages/README.md | 87 +++ .../README.md | 6 +- .../README.md | 81 +++ problems/kill-process/README.md | 6 +- problems/koko-eating-bananas/README.md | 1 + .../kth-largest-element-in-a-stream/README.md | 6 +- problems/largest-1-bordered-square/README.md | 6 +- problems/largest-magic-square/README.md | 3 - problems/largest-multiple-of-three/README.md | 15 +- problems/largest-number/README.md | 18 +- .../largest-odd-number-in-string/README.md | 2 +- problems/largest-perimeter-triangle/README.md | 25 +- problems/largest-subarray-length-k/README.md | 2 +- .../README.md | 20 +- .../README.md | 8 - .../README.md | 29 +- .../README.md | 6 +- .../README.md | 2 +- problems/leetcodify-similar-friends/README.md | 3 + .../README.md | 8 +- problems/letter-case-permutation/README.md | 24 +- .../README.md | 19 +- problems/line-reflection/README.md | 6 +- problems/linked-list-in-binary-tree/README.md | 2 +- problems/logger-rate-limiter/README.md | 6 +- .../README.md | 5 + .../README.md | 6 +- .../longest-arithmetic-subsequence/README.md | 6 +- .../README.md | 8 - .../README.md | 3 + .../README.md | 12 +- .../longest-duplicate-substring/README.md | 10 +- problems/longest-happy-prefix/README.md | 16 +- problems/longest-happy-string/README.md | 28 +- .../longest-harmonious-subsequence/README.md | 6 +- .../README.md | 2 +- problems/longest-mountain-in-array/README.md | 6 +- problems/longest-nice-substring/README.md | 14 +- .../README.md | 80 +++ .../README.md | 3 + .../README.md | 21 +- .../README.md | 8 - .../longest-uncommon-subsequence-ii/README.md | 6 +- problems/longest-univalue-path/README.md | 6 +- problems/longest-winning-streak/README.md | 17 + .../longest-winning-streak/mysql_schemas.sql | 10 + problems/low-quality-problems/README.md | 2 +- .../README.md | 8 + .../README.md | 6 +- problems/majority-element-ii/README.md | 13 +- problems/majority-element/README.md | 6 +- problems/make-sum-divisible-by-p/README.md | 15 - .../README.md | 28 +- problems/making-file-names-unique/README.md | 26 +- problems/map-sum-pairs/README.md | 10 +- problems/matrix-block-sum/README.md | 9 +- .../matrix-cells-in-distance-order/README.md | 10 +- problems/matrix-diagonal-sum/README.md | 3 + problems/max-consecutive-ones-iii/README.md | 9 +- .../README.md | 6 +- problems/max-value-of-equation/README.md | 7 +- problems/maximal-rectangle/README.md | 20 +- .../README.md | 5 +- .../README.md | 2 +- .../README.md | 3 + problems/maximum-and-sum-of-array/README.md | 69 +++ .../README.md | 8 +- .../maximum-ascending-subarray-sum/README.md | 10 +- .../README.md | 2 +- .../README.md | 65 +-- .../README.md | 6 +- .../README.md | 8 - problems/maximum-distance-in-arrays/README.md | 2 +- .../README.md | 2 +- .../README.md | 88 +++ .../README.md | 99 ++++ .../README.md | 8 + .../README.md | 114 ++++ problems/maximum-ice-cream-bars/README.md | 2 +- .../README.md | 8 - .../README.md | 30 +- .../README.md | 19 +- .../README.md | 45 +- .../README.md | 2 + .../README.md | 14 +- .../README.md | 38 +- .../maximum-number-of-eaten-apples/README.md | 5 +- .../README.md | 35 +- .../README.md | 31 +- .../README.md | 2 +- .../README.md | 22 +- .../README.md | 14 +- .../README.md | 4 +- .../README.md | 25 +- .../README.md | 5 +- .../README.md | 61 ++ .../maximum-path-quality-of-a-graph/README.md | 13 +- .../maximum-performance-of-a-team/README.md | 3 + .../README.md | 21 +- .../README.md | 14 - .../maximum-product-of-word-lengths/README.md | 6 +- .../README.md | 25 +- .../maximum-repeating-substring/README.md | 3 - .../README.md | 72 +++ .../README.md | 4 + .../README.md | 5 +- .../README.md | 5 +- .../README.md | 3 + .../maximum-students-taking-exam/README.md | 4 +- .../maximum-sum-bst-in-binary-tree/README.md | 20 +- .../README.md | 6 +- .../README.md | 89 +++ problems/maximum-units-on-a-truck/README.md | 2 +- .../README.md | 2 +- .../README.md | 14 - problems/meeting-rooms-ii/README.md | 8 +- .../merge-bsts-to-create-single-bst/README.md | 8 - .../merge-in-between-linked-lists/README.md | 2 +- problems/merge-intervals/README.md | 1 + problems/merge-strings-alternately/README.md | 3 + .../README.md | 16 +- .../min-cost-to-connect-all-points/README.md | 42 +- problems/mini-parser/README.md | 6 +- .../minimize-deviation-in-array/README.md | 4 +- .../README.md | 5 +- .../minimum-absolute-difference/README.md | 17 +- .../README.md | 20 +- .../README.md | 8 +- problems/minimum-area-rectangle-ii/README.md | 16 +- .../README.md | 75 +++ .../README.md | 100 ++++ .../README.md | 4 +- .../minimum-cost-to-cut-a-stick/README.md | 3 + .../minimum-cost-to-merge-stones/README.md | 6 +- .../README.md | 34 ++ .../README.md | 6 +- .../README.md | 2 +- .../README.md | 98 ++++ .../README.md | 3 + .../README.md | 1 + .../README.md | 25 +- .../README.md | 90 +++ .../README.md | 22 +- .../README.md | 20 +- .../README.md | 8 +- .../README.md | 2 +- .../minimum-falling-path-sum-ii/README.md | 3 + problems/minimum-falling-path-sum/README.md | 6 +- problems/minimum-genetic-mutation/README.md | 6 +- problems/minimum-incompatibility/README.md | 2 +- .../README.md | 16 +- .../README.md | 28 +- .../README.md | 2 +- .../minimum-jumps-to-reach-home/README.md | 2 +- .../README.md | 41 +- .../README.md | 82 +++ .../README.md | 87 +++ .../README.md | 50 +- .../README.md | 20 +- .../README.md | 34 +- .../README.md | 15 +- .../README.md | 36 +- .../README.md | 45 ++ .../README.md | 13 - .../README.md | 3 + .../README.md | 8 +- .../README.md | 14 - .../README.md | 24 +- .../README.md | 2 +- .../README.md | 23 +- .../README.md | 28 +- .../README.md | 40 +- .../README.md | 37 +- .../README.md | 78 +++ .../README.md | 100 ++++ .../README.md | 40 ++ .../README.md | 34 +- .../README.md | 7 - .../README.md | 3 + .../README.md | 2 +- .../README.md | 2 +- problems/minimum-suffix-flips/README.md | 70 +++ .../README.md | 67 +++ .../README.md | 91 +++ .../README.md | 9 +- .../README.md | 22 +- .../README.md | 2 +- .../README.md | 2 +- .../README.md | 67 +++ .../README.md | 97 ++++ .../README.md | 2 +- problems/missing-number/README.md | 17 +- problems/monotone-increasing-digits/README.md | 6 +- problems/monthly-transactions-ii/README.md | 9 +- .../monthly-transactions-ii/mysql_schemas.sql | 4 +- problems/my-calendar-i/README.md | 6 +- problems/my-calendar-ii/README.md | 2 +- .../README.md | 2 +- problems/new-users-daily-count/README.md | 6 +- problems/non-decreasing-array/README.md | 9 +- problems/nth-highest-salary/README.md | 6 +- problems/number-of-1-bits/README.md | 6 +- .../number-of-corner-rectangles/README.md | 6 +- .../README.md | 46 +- problems/number-of-digit-one/README.md | 10 +- .../README.md | 4 +- .../number-of-good-leaf-nodes-pairs/README.md | 26 +- .../README.md | 26 +- .../number-of-laser-beams-in-a-bank/README.md | 89 +++ .../number-of-lines-to-write-string/README.md | 6 +- .../README.md | 4 +- .../README.md | 34 +- .../README.md | 35 +- .../number-of-segments-in-a-string/README.md | 24 +- .../README.md | 25 +- .../README.md | 75 +++ .../README.md | 2 +- .../README.md | 5 +- .../README.md | 6 +- .../README.md | 31 +- .../README.md | 5 +- .../README.md | 31 +- .../README.md | 3 + .../README.md | 26 +- .../README.md | 11 +- .../README.md | 3 - .../README.md | 35 ++ .../README.md | 31 +- .../README.md | 8 - .../README.md | 83 +++ .../README.md | 16 +- .../README.md | 25 +- .../README.md | 57 +- .../README.md | 13 +- .../README.md | 20 +- .../README.md | 30 +- .../README.md | 30 +- .../numbers-with-repeated-digits/README.md | 6 +- problems/odd-even-jump/README.md | 6 +- .../README.md | 4 +- .../order-two-columns-independently/README.md | 17 + .../mysql_schemas.sql | 6 + .../README.md | 2 +- problems/paint-fence/README.md | 6 +- problems/paint-house-iii/README.md | 17 +- problems/palindrome-linked-list/README.md | 6 +- problems/palindrome-pairs/README.md | 1 + .../palindrome-partitioning-iii/README.md | 3 + problems/palindrome-removal/README.md | 6 +- problems/parallel-courses-ii/README.md | 11 +- .../README.md | 74 +++ problems/partition-list/README.md | 6 +- problems/path-sum-ii/README.md | 8 +- problems/path-sum/README.md | 15 +- problems/path-with-minimum-effort/README.md | 10 +- problems/perfect-rectangle/README.md | 8 - problems/pizza-with-3n-slices/README.md | 44 +- problems/plus-one-linked-list/README.md | 6 +- problems/poor-pigs/README.md | 6 +- .../README.md | 7 +- problems/possible-bipartition/README.md | 6 +- .../README.md | 39 ++ problems/power-of-three/README.md | 32 +- problems/prime-arrangements/README.md | 6 +- problems/print-in-order/README.md | 6 +- problems/prison-cells-after-n-days/README.md | 8 +- .../README.md | 16 - .../product-of-array-except-self/README.md | 6 +- .../products-price-for-each-store/README.md | 3 + .../projection-area-of-3d-shapes/README.md | 25 +- .../put-boxes-into-the-warehouse-ii/README.md | 5 +- .../README.md | 6 +- .../queries-quality-and-percentage/README.md | 3 + .../queue-reconstruction-by-height/README.md | 2 +- problems/race-car/README.md | 6 +- problems/random-pick-index/README.md | 8 +- problems/random-pick-with-weight/README.md | 29 +- problems/range-sum-query-mutable/README.md | 8 +- problems/rank-scores/README.md | 6 +- problems/rank-transform-of-a-matrix/README.md | 9 +- problems/reach-a-number/README.md | 6 +- .../README.md | 72 +++ .../rearrange-spaces-between-words/README.md | 32 +- .../README.md | 6 +- .../rearrange-words-in-a-sentence/README.md | 6 +- problems/recover-the-original-array/README.md | 95 +++ problems/rectangle-overlap/README.md | 8 +- problems/rectangles-area/README.md | 6 +- .../reduce-array-size-to-the-half/README.md | 27 +- problems/reducing-dishes/README.md | 11 +- problems/reformat-phone-number/README.md | 16 +- .../README.md | 46 ++ problems/remove-covered-intervals/README.md | 23 +- problems/remove-interval/README.md | 6 +- .../README.md | 2 +- .../README.md | 8 - .../README.md | 3 + .../README.md | 94 +++ .../README.md | 85 +++ .../README.md | 6 +- problems/repeated-string-match/README.md | 23 +- .../README.md | 19 +- problems/reported-posts-ii/README.md | 6 +- problems/restore-the-array/README.md | 24 +- problems/reverse-bits/README.md | 8 +- problems/reverse-linked-list/README.md | 10 +- .../README.md | 28 +- problems/reverse-words-in-a-string/README.md | 20 +- problems/rings-and-rods/README.md | 83 +++ problems/rotate-array/README.md | 8 +- problems/rotate-function/README.md | 6 +- .../README.md | 3 - problems/russian-doll-envelopes/README.md | 10 +- problems/sales-analysis-ii/README.md | 4 + problems/sales-by-day-of-the-week/README.md | 6 +- problems/search-insert-position/README.md | 33 +- problems/search-suggestions-system/README.md | 22 +- problems/second-highest-salary/README.md | 52 +- .../second-highest-salary/mysql_schemas.sql | 8 +- .../README.md | 1 - problems/self-crossing/README.md | 6 +- .../README.md | 15 - problems/sentence-similarity-iii/README.md | 7 - .../README.md | 113 ++++ problems/set-matrix-zeroes/README.md | 10 +- problems/set-mismatch/README.md | 2 +- problems/shift-2d-grid/README.md | 6 +- problems/shortest-bridge/README.md | 20 +- problems/shortest-completing-word/README.md | 22 +- .../README.md | 6 +- .../shortest-path-in-a-hidden-grid/README.md | 4 + problems/shortest-path-to-get-food/README.md | 6 +- .../README.md | 18 +- .../shortest-way-to-form-string/README.md | 3 +- problems/shuffle-string/README.md | 33 +- problems/shuffle-the-array/README.md | 6 +- problems/simplify-path/README.md | 15 +- problems/single-row-keyboard/README.md | 6 +- .../README.md | 2 +- .../smallest-index-with-equal-value/README.md | 8 - .../README.md | 28 +- .../README.md | 2 +- .../README.md | 19 +- .../README.md | 59 ++ .../README.md | 92 +++ problems/sort-an-array/README.md | 12 +- .../README.md | 3 - .../README.md | 81 +++ .../README.md | 36 +- .../README.md | 37 +- .../README.md | 2 +- problems/sort-transformed-array/README.md | 6 +- problems/sorting-the-sentence/README.md | 3 + .../README.md | 7 - .../README.md | 49 +- .../README.md | 22 +- .../split-array-with-same-average/README.md | 6 +- .../README.md | 13 +- .../README.md | 9 - problems/squares-of-a-sorted-array/README.md | 6 +- problems/stamping-the-grid/README.md | 78 +++ problems/stamping-the-sequence/README.md | 8 +- .../README.md | 75 +++ problems/stepping-numbers/README.md | 6 +- problems/stock-price-fluctuation/README.md | 1 + problems/stone-game-ii/README.md | 6 +- problems/stone-game-iii/README.md | 38 +- problems/stone-game-iv/README.md | 33 +- problems/stone-game-vii/README.md | 11 - problems/strange-printer-ii/README.md | 16 +- problems/stream-of-characters/README.md | 10 +- .../string-matching-in-an-array/README.md | 6 +- problems/string-to-integer-atoi/README.md | 41 +- .../strings-differ-by-one-character/README.md | 2 +- problems/strobogrammatic-number-iii/README.md | 6 +- problems/strobogrammatic-number/README.md | 6 +- problems/strong-friendship/README.md | 2 +- .../student-attendance-record-ii/README.md | 6 +- problems/subrectangle-queries/README.md | 2 +- .../README.md | 35 ++ .../README.md | 2 +- .../README.md | 9 +- .../README.md | 2 +- problems/sudoku-solver/README.md | 6 +- problems/sum-of-square-numbers/README.md | 21 - problems/sum-of-subarray-minimums/README.md | 6 +- problems/sum-of-subarray-ranges/README.md | 83 +++ problems/sum-of-subsequence-widths/README.md | 6 +- problems/surface-area-of-3d-shapes/README.md | 27 +- problems/surrounded-regions/README.md | 2 +- problems/suspicious-bank-accounts/README.md | 2 +- problems/swap-adjacent-in-lr-string/README.md | 27 +- .../README.md | 20 +- .../swapping-nodes-in-a-linked-list/README.md | 28 +- problems/symmetric-tree/README.md | 6 +- problems/synonymous-sentences/README.md | 8 +- .../README.md | 17 + .../mysql_schemas.sql | 5 + .../README.md | 2 +- .../README.md | 28 +- problems/the-kth-factor-of-n/README.md | 26 +- .../README.md | 3 + .../README.md | 49 +- .../README.md | 17 + .../mysql_schemas.sql | 11 + .../README.md | 17 + .../mysql_schemas.sql | 12 + .../the-number-of-rich-customers/README.md | 2 +- .../README.md | 13 - problems/the-winner-university/README.md | 2 +- problems/thousand-separator/README.md | 16 +- problems/three-divisors/README.md | 3 + problems/throne-inheritance/README.md | 5 +- problems/time-based-key-value-store/README.md | 5 +- .../README.md | 39 +- problems/total-sales-amount-by-year/README.md | 6 +- problems/trapping-rain-water/README.md | 6 +- problems/tuple-with-same-product/README.md | 16 +- problems/two-sum/README.md | 10 +- .../README.md | 47 ++ .../README.md | 6 +- .../README.md | 2 +- problems/utf-8-validation/README.md | 2 +- problems/valid-arrangement-of-pairs/README.md | 87 +++ problems/valid-parenthesis-string/README.md | 1 + problems/valid-word-abbreviation/README.md | 7 +- problems/verbal-arithmetic-puzzle/README.md | 19 +- problems/video-stitching/README.md | 19 +- problems/vowels-of-all-substrings/README.md | 12 +- problems/water-bottles/README.md | 34 +- problems/watering-plants-ii/README.md | 94 +++ .../README.md | 3 + .../weather-type-in-each-country/README.md | 6 +- problems/where-will-the-ball-fall/README.md | 2 +- problems/wiggle-subsequence/README.md | 11 +- problems/word-abbreviation/README.md | 6 +- problems/word-pattern-ii/README.md | 6 +- problems/word-squares/README.md | 2 +- problems/word-subsets/README.md | 32 +- problems/xor-operation-in-an-array/README.md | 31 +- problems/xor-queries-of-a-subarray/README.md | 2 +- readme/1-300.md | 102 ++-- readme/1201-1500.md | 94 +-- readme/1501-1800.md | 388 +++++++++++++ readme/301-600.md | 96 ++-- readme/601-900.md | 96 ++-- readme/901-1200.md | 96 ++-- tag/array/README.md | 102 +++- tag/backtracking/README.md | 4 + tag/binary-indexed-tree/README.md | 2 +- tag/binary-search-tree/README.md | 2 +- tag/binary-search/README.md | 15 +- tag/binary-tree/README.md | 13 +- tag/bit-manipulation/README.md | 8 +- tag/bitmask/README.md | 2 + tag/breadth-first-search/README.md | 14 +- tag/concurrency/README.md | 2 +- tag/counting/README.md | 8 + tag/data-stream/README.md | 2 + tag/depth-first-search/README.md | 16 +- tag/design/README.md | 8 +- tag/divide-and-conquer/README.md | 4 +- tag/doubly-linked-list/README.md | 2 +- tag/dynamic-programming/README.md | 23 +- tag/enumeration/README.md | 6 +- tag/eulerian-circuit/README.md | 1 + tag/geometry/README.md | 6 +- tag/graph/README.md | 9 +- tag/greedy/README.md | 21 +- tag/hash-function/README.md | 2 + tag/hash-table/README.md | 35 +- tag/heap-priority-queue/README.md | 8 +- tag/iterator/README.md | 2 +- tag/linked-list/README.md | 8 +- tag/math/README.md | 30 +- tag/matrix/README.md | 12 +- tag/merge-sort/README.md | 2 +- tag/monotonic-stack/README.md | 2 + tag/number-theory/README.md | 1 + tag/ordered-set/README.md | 10 +- tag/prefix-sum/README.md | 9 +- tag/queue/README.md | 1 + tag/recursion/README.md | 4 +- tag/rolling-hash/README.md | 2 + tag/segment-tree/README.md | 3 +- tag/shortest-path/README.md | 3 +- tag/simulation/README.md | 13 +- tag/sliding-window/README.md | 6 + tag/sorting/README.md | 29 +- tag/stack/README.md | 6 +- tag/string/README.md | 37 +- tag/topological-sort/README.md | 2 + tag/tree/README.md | 13 +- tag/two-pointers/README.md | 10 +- tag/union-find/README.md | 2 + 783 files changed, 10343 insertions(+), 5686 deletions(-) create mode 100644 problems/a-number-after-a-double-reversal/README.md create mode 100644 problems/abbreviating-the-product-of-a-range/README.md create mode 100644 problems/adding-spaces-to-a-string/README.md create mode 100644 problems/all-divisions-with-the-highest-score-of-a-binary-array/README.md create mode 100644 problems/amount-of-new-area-painted-each-day/README.md create mode 100644 problems/build-the-equation/README.md create mode 100644 problems/build-the-equation/mysql_schemas.sql create mode 100644 problems/capitalize-the-title/README.md create mode 100644 problems/check-if-a-parentheses-string-can-be-valid/README.md create mode 100644 problems/check-if-all-as-appears-before-all-bs/README.md create mode 100644 problems/check-if-every-row-and-column-contains-all-numbers/README.md create mode 100644 problems/choose-numbers-from-two-arrays-in-range/README.md create mode 100644 problems/count-common-words-with-one-occurrence/README.md create mode 100644 problems/count-elements-with-strictly-smaller-and-greater-elements/README.md create mode 100644 problems/count-fertile-pyramids-in-a-land/README.md create mode 100644 problems/count-operations-to-obtain-zero/README.md create mode 100644 problems/count-the-hidden-sequences/README.md create mode 100644 problems/count-words-obtained-after-adding-a-letter/README.md create mode 100644 problems/delete-the-middle-node-of-a-linked-list/README.md create mode 100644 problems/design-bitset/README.md create mode 100644 problems/destroying-asteroids/README.md create mode 100644 problems/detonate-the-maximum-bombs/README.md create mode 100644 problems/divide-a-string-into-groups-of-size-k/README.md create mode 100644 problems/earliest-possible-day-of-full-bloom/README.md create mode 100644 problems/elements-in-array-after-removing-and-replacing-elements/README.md create mode 100644 problems/execution-of-all-suffix-instructions-staying-in-a-grid/README.md create mode 100644 problems/find-all-lonely-numbers-in-the-array/README.md create mode 100644 problems/find-all-people-with-secret/README.md create mode 100644 problems/find-all-possible-recipes-from-given-supplies/README.md create mode 100644 problems/find-first-palindromic-string-in-the-array/README.md create mode 100644 problems/find-good-days-to-rob-the-bank/README.md create mode 100644 problems/find-subsequence-of-length-k-with-the-largest-sum/README.md create mode 100644 problems/find-substring-with-given-hash-value/README.md create mode 100644 problems/find-target-indices-after-sorting-array/README.md create mode 100644 problems/finding-3-digit-even-numbers/README.md create mode 100644 problems/groups-of-strings/README.md create mode 100644 problems/intervals-between-identical-elements/README.md create mode 100644 problems/k-highest-ranked-items-within-a-price-range/README.md create mode 100644 problems/k-radius-subarray-averages/README.md create mode 100644 problems/keep-multiplying-found-values-by-two/README.md create mode 100644 problems/longest-palindrome-by-concatenating-two-letter-words/README.md create mode 100644 problems/longest-winning-streak/README.md create mode 100644 problems/longest-winning-streak/mysql_schemas.sql create mode 100644 problems/maximum-and-sum-of-array/README.md create mode 100644 problems/maximum-employees-to-be-invited-to-a-meeting/README.md create mode 100644 problems/maximum-fruits-harvested-after-at-most-k-steps/README.md create mode 100644 problems/maximum-good-people-based-on-statements/README.md create mode 100644 problems/maximum-number-of-words-found-in-sentences/README.md create mode 100644 problems/maximum-running-time-of-n-computers/README.md create mode 100644 problems/maximum-twin-sum-of-a-linked-list/README.md create mode 100644 problems/minimum-cost-homecoming-of-a-robot-in-a-grid/README.md create mode 100644 problems/minimum-cost-of-buying-candies-with-discount/README.md create mode 100644 problems/minimum-cost-to-reach-city-with-discounts/README.md create mode 100644 problems/minimum-cost-to-set-cooking-time/README.md create mode 100644 problems/minimum-difference-in-sums-after-removal-of-elements/README.md create mode 100644 problems/minimum-moves-to-reach-target-score/README.md create mode 100644 problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses/README.md create mode 100644 problems/minimum-number-of-lines-to-cover-points/README.md create mode 100644 problems/minimum-operations-to-make-the-array-alternating/README.md create mode 100644 problems/minimum-operations-to-make-the-array-k-increasing/README.md create mode 100644 problems/minimum-operations-to-remove-adjacent-ones-in-matrix/README.md create mode 100644 problems/minimum-suffix-flips/README.md create mode 100644 problems/minimum-sum-of-four-digit-number-after-splitting-digits/README.md create mode 100644 problems/minimum-swaps-to-group-all-1s-together-ii/README.md create mode 100644 problems/minimum-time-to-make-rope-colorful/README.md create mode 100644 problems/minimum-time-to-remove-all-cars-containing-illegal-goods/README.md create mode 100644 problems/number-of-laser-beams-in-a-bank/README.md create mode 100644 problems/number-of-smooth-descent-periods-of-a-stock/README.md create mode 100644 problems/number-of-unique-flavors-after-sharing-k-candies/README.md create mode 100644 problems/number-of-ways-to-divide-a-long-corridor/README.md create mode 100644 problems/order-two-columns-independently/README.md create mode 100644 problems/order-two-columns-independently/mysql_schemas.sql create mode 100644 problems/partition-array-according-to-given-pivot/README.md create mode 100644 problems/pour-water-between-buckets-to-make-water-levels-equal/README.md create mode 100644 problems/rearrange-array-elements-by-sign/README.md create mode 100644 problems/recover-the-original-array/README.md create mode 100644 problems/remove-all-ones-with-row-and-column-flips/README.md create mode 100644 problems/removing-minimum-and-maximum-from-array/README.md create mode 100644 problems/removing-minimum-number-of-magic-beans/README.md create mode 100644 problems/rings-and-rods/README.md create mode 100644 problems/sequentially-ordinal-rank-tracker/README.md create mode 100644 problems/smallest-value-of-the-rearranged-number/README.md create mode 100644 problems/solving-questions-with-brainpower/README.md create mode 100644 problems/sort-even-and-odd-indices-independently/README.md create mode 100644 problems/stamping-the-grid/README.md create mode 100644 problems/step-by-step-directions-from-a-binary-tree-node-to-another/README.md create mode 100644 problems/subsequence-of-size-k-with-the-largest-even-sum/README.md create mode 100644 problems/sum-of-subarray-ranges/README.md create mode 100644 problems/the-airport-with-the-most-traffic/README.md create mode 100644 problems/the-airport-with-the-most-traffic/mysql_schemas.sql create mode 100644 problems/the-number-of-passengers-in-each-bus-i/README.md create mode 100644 problems/the-number-of-passengers-in-each-bus-i/mysql_schemas.sql create mode 100644 problems/the-number-of-passengers-in-each-bus-ii/README.md create mode 100644 problems/the-number-of-passengers-in-each-bus-ii/mysql_schemas.sql create mode 100644 problems/unique-substrings-with-equal-digit-frequency/README.md create mode 100644 problems/valid-arrangement-of-pairs/README.md create mode 100644 problems/watering-plants-ii/README.md create mode 100644 readme/1501-1800.md diff --git a/README.md b/README.md index d8ed2b05d..340a1f882 100644 --- a/README.md +++ b/README.md @@ -19,68 +19,165 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    | # | Title | Solution | Difficulty | | :-: | - | - | :-: | -| 2084 | [Drop Type 1 Orders for Customers With Type 0 Orders](https://leetcode.com/problems/drop-type-1-orders-for-customers-with-type-0-orders) 🔒 | [MySQL](problems/drop-type-1-orders-for-customers-with-type-0-orders) | Medium | -| 2083 | [Substrings That Begin and End With the Same Letter](https://leetcode.com/problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [Go](problems/substrings-that-begin-and-end-with-the-same-letter) | Medium | -| 2082 | [The Number of Rich Customers](https://leetcode.com/problems/the-number-of-rich-customers) 🔒 | [MySQL](problems/the-number-of-rich-customers) | Easy | +| 2173 | [Longest Winning Streak](https://leetcode.com/problems/longest-winning-streak) 🔒 | [MySQL](problems/longest-winning-streak) | Hard | +| 2172 | [Maximum AND Sum of Array](https://leetcode.com/problems/maximum-and-sum-of-array "数组的最大与和") | [Go](problems/maximum-and-sum-of-array) | Hard | +| 2171 | [Removing Minimum Number of Magic Beans](https://leetcode.com/problems/removing-minimum-number-of-magic-beans "拿出最少数目的魔法豆") | [Go](problems/removing-minimum-number-of-magic-beans) | Medium | +| 2170 | [Minimum Operations to Make the Array Alternating](https://leetcode.com/problems/minimum-operations-to-make-the-array-alternating "使数组变成交替数组的最少操作数") | [Go](problems/minimum-operations-to-make-the-array-alternating) | Medium | +| 2169 | [Count Operations to Obtain Zero](https://leetcode.com/problems/count-operations-to-obtain-zero "得到 0 的操作数") | [Go](problems/count-operations-to-obtain-zero) | Easy | +| 2168 | [Unique Substrings With Equal Digit Frequency](https://leetcode.com/problems/unique-substrings-with-equal-digit-frequency) 🔒 | [Go](problems/unique-substrings-with-equal-digit-frequency) | Medium | +| 2167 | [Minimum Time to Remove All Cars Containing Illegal Goods](https://leetcode.com/problems/minimum-time-to-remove-all-cars-containing-illegal-goods "移除所有载有违禁货物车厢所需的最少时间") | [Go](problems/minimum-time-to-remove-all-cars-containing-illegal-goods) | Hard | +| 2166 | [Design Bitset](https://leetcode.com/problems/design-bitset "设计位集") | [Go](problems/design-bitset) | Medium | +| 2165 | [Smallest Value of the Rearranged Number](https://leetcode.com/problems/smallest-value-of-the-rearranged-number "重排数字的最小值") | [Go](problems/smallest-value-of-the-rearranged-number) | Medium | +| 2164 | [Sort Even and Odd Indices Independently](https://leetcode.com/problems/sort-even-and-odd-indices-independently "对奇偶下标分别排序") | [Go](problems/sort-even-and-odd-indices-independently) | Easy | +| 2163 | [Minimum Difference in Sums After Removal of Elements](https://leetcode.com/problems/minimum-difference-in-sums-after-removal-of-elements "删除元素后和的最小差值") | [Go](problems/minimum-difference-in-sums-after-removal-of-elements) | Hard | +| 2162 | [Minimum Cost to Set Cooking Time](https://leetcode.com/problems/minimum-cost-to-set-cooking-time "设置时间的最少代价") | [Go](problems/minimum-cost-to-set-cooking-time) | Medium | +| 2161 | [Partition Array According to Given Pivot](https://leetcode.com/problems/partition-array-according-to-given-pivot "根据给定数字划分数组") | [Go](problems/partition-array-according-to-given-pivot) | Medium | +| 2160 | [Minimum Sum of Four Digit Number After Splitting Digits](https://leetcode.com/problems/minimum-sum-of-four-digit-number-after-splitting-digits "拆分数位后四位数字的最小和") | [Go](problems/minimum-sum-of-four-digit-number-after-splitting-digits) | Easy | +| 2159 | [Order Two Columns Independently](https://leetcode.com/problems/order-two-columns-independently) 🔒 | [MySQL](problems/order-two-columns-independently) | Medium | +| 2158 | [Amount of New Area Painted Each Day](https://leetcode.com/problems/amount-of-new-area-painted-each-day) 🔒 | [Go](problems/amount-of-new-area-painted-each-day) | Hard | +| 2157 | [Groups of Strings](https://leetcode.com/problems/groups-of-strings "字符串分组") | [Go](problems/groups-of-strings) | Hard | +| 2156 | [Find Substring With Given Hash Value](https://leetcode.com/problems/find-substring-with-given-hash-value "查找给定哈希值的子串") | [Go](problems/find-substring-with-given-hash-value) | Hard | +| 2155 | [All Divisions With the Highest Score of a Binary Array](https://leetcode.com/problems/all-divisions-with-the-highest-score-of-a-binary-array "分组得分最高的所有下标") | [Go](problems/all-divisions-with-the-highest-score-of-a-binary-array) | Medium | +| 2154 | [Keep Multiplying Found Values by Two](https://leetcode.com/problems/keep-multiplying-found-values-by-two "将找到的值乘以 2") | [Go](problems/keep-multiplying-found-values-by-two) | Easy | +| 2153 | [The Number of Passengers in Each Bus II](https://leetcode.com/problems/the-number-of-passengers-in-each-bus-ii) 🔒 | [MySQL](problems/the-number-of-passengers-in-each-bus-ii) | Hard | +| 2152 | [Minimum Number of Lines to Cover Points](https://leetcode.com/problems/minimum-number-of-lines-to-cover-points) 🔒 | [Go](problems/minimum-number-of-lines-to-cover-points) | Medium | +| 2151 | [Maximum Good People Based on Statements](https://leetcode.com/problems/maximum-good-people-based-on-statements "基于陈述统计最多好人数") | [Go](problems/maximum-good-people-based-on-statements) | Hard | +| 2150 | [Find All Lonely Numbers in the Array](https://leetcode.com/problems/find-all-lonely-numbers-in-the-array "找出数组中的所有孤独数字") | [Go](problems/find-all-lonely-numbers-in-the-array) | Medium | +| 2149 | [Rearrange Array Elements by Sign](https://leetcode.com/problems/rearrange-array-elements-by-sign "按符号重排数组") | [Go](problems/rearrange-array-elements-by-sign) | Medium | +| 2148 | [Count Elements With Strictly Smaller and Greater Elements](https://leetcode.com/problems/count-elements-with-strictly-smaller-and-greater-elements "元素计数") | [Go](problems/count-elements-with-strictly-smaller-and-greater-elements) | Easy | +| 2147 | [Number of Ways to Divide a Long Corridor](https://leetcode.com/problems/number-of-ways-to-divide-a-long-corridor "分隔长廊的方案数") | [Go](problems/number-of-ways-to-divide-a-long-corridor) | Hard | +| 2146 | [K Highest Ranked Items Within a Price Range](https://leetcode.com/problems/k-highest-ranked-items-within-a-price-range "价格范围内最高排名的 K 样物品") | [Go](problems/k-highest-ranked-items-within-a-price-range) | Medium | +| 2145 | [Count the Hidden Sequences](https://leetcode.com/problems/count-the-hidden-sequences "统计隐藏数组数目") | [Go](problems/count-the-hidden-sequences) | Medium | +| 2144 | [Minimum Cost of Buying Candies With Discount](https://leetcode.com/problems/minimum-cost-of-buying-candies-with-discount "打折购买糖果的最小开销") | [Go](problems/minimum-cost-of-buying-candies-with-discount) | Easy | +| 2143 | [Choose Numbers From Two Arrays in Range](https://leetcode.com/problems/choose-numbers-from-two-arrays-in-range) 🔒 | [Go](problems/choose-numbers-from-two-arrays-in-range) | Hard | +| 2142 | [The Number of Passengers in Each Bus I](https://leetcode.com/problems/the-number-of-passengers-in-each-bus-i) 🔒 | [MySQL](problems/the-number-of-passengers-in-each-bus-i) | Medium | +| 2141 | [Maximum Running Time of N Computers](https://leetcode.com/problems/maximum-running-time-of-n-computers "同时运行 N 台电脑的最长时间") | [Go](problems/maximum-running-time-of-n-computers) | Hard | +| 2140 | [Solving Questions With Brainpower](https://leetcode.com/problems/solving-questions-with-brainpower "解决智力问题") | [Go](problems/solving-questions-with-brainpower) | Medium | +| 2139 | [Minimum Moves to Reach Target Score](https://leetcode.com/problems/minimum-moves-to-reach-target-score "得到目标值的最少行动次数") | [Go](problems/minimum-moves-to-reach-target-score) | Medium | +| 2138 | [Divide a String Into Groups of Size k](https://leetcode.com/problems/divide-a-string-into-groups-of-size-k "将字符串拆分为若干长度为 k 的组") | [Go](problems/divide-a-string-into-groups-of-size-k) | Easy | +| 2137 | [Pour Water Between Buckets to Make Water Levels Equal](https://leetcode.com/problems/pour-water-between-buckets-to-make-water-levels-equal) 🔒 | [Go](problems/pour-water-between-buckets-to-make-water-levels-equal) | Medium | +| 2136 | [Earliest Possible Day of Full Bloom](https://leetcode.com/problems/earliest-possible-day-of-full-bloom "全部开花的最早一天") | [Go](problems/earliest-possible-day-of-full-bloom) | Hard | +| 2135 | [Count Words Obtained After Adding a Letter](https://leetcode.com/problems/count-words-obtained-after-adding-a-letter "统计追加字母可以获得的单词数") | [Go](problems/count-words-obtained-after-adding-a-letter) | Medium | +| 2134 | [Minimum Swaps to Group All 1's Together II](https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii "最少交换次数来组合所有的 1 II") | [Go](problems/minimum-swaps-to-group-all-1s-together-ii) | Medium | +| 2133 | [Check if Every Row and Column Contains All Numbers](https://leetcode.com/problems/check-if-every-row-and-column-contains-all-numbers "检查是否每一行每一列都包含全部整数") | [Go](problems/check-if-every-row-and-column-contains-all-numbers) | Easy | +| 2132 | [Stamping the Grid](https://leetcode.com/problems/stamping-the-grid "用邮票贴满网格图") | [Go](problems/stamping-the-grid) | Hard | +| 2131 | [Longest Palindrome by Concatenating Two Letter Words](https://leetcode.com/problems/longest-palindrome-by-concatenating-two-letter-words "连接两字母单词得到的最长回文串") | [Go](problems/longest-palindrome-by-concatenating-two-letter-words) | Medium | +| 2130 | [Maximum Twin Sum of a Linked List](https://leetcode.com/problems/maximum-twin-sum-of-a-linked-list "链表最大孪生和") | [Go](problems/maximum-twin-sum-of-a-linked-list) | Medium | +| 2129 | [Capitalize the Title](https://leetcode.com/problems/capitalize-the-title "将标题首字母大写") | [Go](problems/capitalize-the-title) | Easy | +| 2128 | [Remove All Ones With Row and Column Flips](https://leetcode.com/problems/remove-all-ones-with-row-and-column-flips) 🔒 | [Go](problems/remove-all-ones-with-row-and-column-flips) | Medium | +| 2127 | [Maximum Employees to Be Invited to a Meeting](https://leetcode.com/problems/maximum-employees-to-be-invited-to-a-meeting "参加会议的最多员工数") | [Go](problems/maximum-employees-to-be-invited-to-a-meeting) | Hard | +| 2126 | [Destroying Asteroids](https://leetcode.com/problems/destroying-asteroids "摧毁小行星") | [Go](problems/destroying-asteroids) | Medium | +| 2125 | [Number of Laser Beams in a Bank](https://leetcode.com/problems/number-of-laser-beams-in-a-bank "银行中的激光束数量") | [Go](problems/number-of-laser-beams-in-a-bank) | Medium | +| 2124 | [Check if All A's Appears Before All B's](https://leetcode.com/problems/check-if-all-as-appears-before-all-bs "检查是否所有 A 都在 B 之前") | [Go](problems/check-if-all-as-appears-before-all-bs) | Easy | +| 2123 | [Minimum Operations to Remove Adjacent Ones in Matrix](https://leetcode.com/problems/minimum-operations-to-remove-adjacent-ones-in-matrix) 🔒 | [Go](problems/minimum-operations-to-remove-adjacent-ones-in-matrix) | Hard | +| 2122 | [Recover the Original Array](https://leetcode.com/problems/recover-the-original-array "还原原数组") | [Go](problems/recover-the-original-array) | Hard | +| 2121 | [Intervals Between Identical Elements](https://leetcode.com/problems/intervals-between-identical-elements "相同元素的间隔之和") | [Go](problems/intervals-between-identical-elements) | Medium | +| 2120 | [Execution of All Suffix Instructions Staying in a Grid](https://leetcode.com/problems/execution-of-all-suffix-instructions-staying-in-a-grid "执行所有后缀指令") | [Go](problems/execution-of-all-suffix-instructions-staying-in-a-grid) | Medium | +| 2119 | [A Number After a Double Reversal](https://leetcode.com/problems/a-number-after-a-double-reversal "反转两次的数字") | [Go](problems/a-number-after-a-double-reversal) | Easy | +| 2118 | [Build the Equation](https://leetcode.com/problems/build-the-equation) 🔒 | [MySQL](problems/build-the-equation) | Hard | +| 2117 | [Abbreviating the Product of a Range](https://leetcode.com/problems/abbreviating-the-product-of-a-range "一个区间内所有数乘积的缩写") | [Go](problems/abbreviating-the-product-of-a-range) | Hard | +| 2116 | [Check if a Parentheses String Can Be Valid](https://leetcode.com/problems/check-if-a-parentheses-string-can-be-valid "判断一个括号字符串是否有效") | [Go](problems/check-if-a-parentheses-string-can-be-valid) | Medium | +| 2115 | [Find All Possible Recipes from Given Supplies](https://leetcode.com/problems/find-all-possible-recipes-from-given-supplies "从给定原材料中找到所有可以做出的菜") | [Go](problems/find-all-possible-recipes-from-given-supplies) | Medium | +| 2114 | [Maximum Number of Words Found in Sentences](https://leetcode.com/problems/maximum-number-of-words-found-in-sentences "句子中的最多单词数") | [Go](problems/maximum-number-of-words-found-in-sentences) | Easy | +| 2113 | [Elements in Array After Removing and Replacing Elements](https://leetcode.com/problems/elements-in-array-after-removing-and-replacing-elements) 🔒 | [Go](problems/elements-in-array-after-removing-and-replacing-elements) | Medium | +| 2112 | [The Airport With the Most Traffic](https://leetcode.com/problems/the-airport-with-the-most-traffic) 🔒 | [MySQL](problems/the-airport-with-the-most-traffic) | Medium | +| 2111 | [Minimum Operations to Make the Array K-Increasing](https://leetcode.com/problems/minimum-operations-to-make-the-array-k-increasing "使数组 K 递增的最少操作次数") | [Go](problems/minimum-operations-to-make-the-array-k-increasing) | Hard | +| 2110 | [Number of Smooth Descent Periods of a Stock](https://leetcode.com/problems/number-of-smooth-descent-periods-of-a-stock "股票平滑下跌阶段的数目") | [Go](problems/number-of-smooth-descent-periods-of-a-stock) | Medium | +| 2109 | [Adding Spaces to a String](https://leetcode.com/problems/adding-spaces-to-a-string "向字符串添加空格") | [Go](problems/adding-spaces-to-a-string) | Medium | +| 2108 | [Find First Palindromic String in the Array](https://leetcode.com/problems/find-first-palindromic-string-in-the-array "找出数组中的第一个回文字符串") | [Go](problems/find-first-palindromic-string-in-the-array) | Easy | +| 2107 | [Number of Unique Flavors After Sharing K Candies](https://leetcode.com/problems/number-of-unique-flavors-after-sharing-k-candies) 🔒 | [Go](problems/number-of-unique-flavors-after-sharing-k-candies) | Medium | +| 2106 | [Maximum Fruits Harvested After at Most K Steps](https://leetcode.com/problems/maximum-fruits-harvested-after-at-most-k-steps "摘水果") | [Go](problems/maximum-fruits-harvested-after-at-most-k-steps) | Hard | +| 2105 | [Watering Plants II](https://leetcode.com/problems/watering-plants-ii "给植物浇水 II") | [Go](problems/watering-plants-ii) | Medium | +| 2104 | [Sum of Subarray Ranges](https://leetcode.com/problems/sum-of-subarray-ranges "子数组范围和") | [Go](problems/sum-of-subarray-ranges) | Medium | +| 2103 | [Rings and Rods](https://leetcode.com/problems/rings-and-rods "环和杆") | [Go](problems/rings-and-rods) | Easy | +| 2102 | [Sequentially Ordinal Rank Tracker](https://leetcode.com/problems/sequentially-ordinal-rank-tracker "序列顺序查询") | [Go](problems/sequentially-ordinal-rank-tracker) | Hard | +| 2101 | [Detonate the Maximum Bombs](https://leetcode.com/problems/detonate-the-maximum-bombs "引爆最多的炸弹") | [Go](problems/detonate-the-maximum-bombs) | Medium | +| 2100 | [Find Good Days to Rob the Bank](https://leetcode.com/problems/find-good-days-to-rob-the-bank "适合打劫银行的日子") | [Go](problems/find-good-days-to-rob-the-bank) | Medium | +| 2099 | [Find Subsequence of Length K With the Largest Sum](https://leetcode.com/problems/find-subsequence-of-length-k-with-the-largest-sum "找到和最大的长度为 K 的子序列") | [Go](problems/find-subsequence-of-length-k-with-the-largest-sum) | Easy | +| 2098 | [Subsequence of Size K With the Largest Even Sum](https://leetcode.com/problems/subsequence-of-size-k-with-the-largest-even-sum) 🔒 | [Go](problems/subsequence-of-size-k-with-the-largest-even-sum) | Medium | +| 2097 | [Valid Arrangement of Pairs](https://leetcode.com/problems/valid-arrangement-of-pairs "合法重新排列数对") | [Go](problems/valid-arrangement-of-pairs) | Hard | +| 2096 | [Step-By-Step Directions From a Binary Tree Node to Another](https://leetcode.com/problems/step-by-step-directions-from-a-binary-tree-node-to-another "从二叉树一个节点到另一个节点每一步的方向") | [Go](problems/step-by-step-directions-from-a-binary-tree-node-to-another) | Medium | +| 2095 | [Delete the Middle Node of a Linked List](https://leetcode.com/problems/delete-the-middle-node-of-a-linked-list "删除链表的中间节点") | [Go](problems/delete-the-middle-node-of-a-linked-list) | Medium | +| 2094 | [Finding 3-Digit Even Numbers](https://leetcode.com/problems/finding-3-digit-even-numbers "找出 3 位偶数") | [Go](problems/finding-3-digit-even-numbers) | Easy | +| 2093 | [Minimum Cost to Reach City With Discounts](https://leetcode.com/problems/minimum-cost-to-reach-city-with-discounts) 🔒 | [Go](problems/minimum-cost-to-reach-city-with-discounts) | Medium | +| 2092 | [Find All People With Secret](https://leetcode.com/problems/find-all-people-with-secret "找出知晓秘密的所有专家") | [Go](problems/find-all-people-with-secret) | Hard | +| 2091 | [Removing Minimum and Maximum From Array](https://leetcode.com/problems/removing-minimum-and-maximum-from-array "从数组中移除最大值和最小值") | [Go](problems/removing-minimum-and-maximum-from-array) | Medium | +| 2090 | [K Radius Subarray Averages](https://leetcode.com/problems/k-radius-subarray-averages "半径为 k 的子数组平均值") | [Go](problems/k-radius-subarray-averages) | Medium | +| 2089 | [Find Target Indices After Sorting Array](https://leetcode.com/problems/find-target-indices-after-sorting-array "找出数组排序后的目标下标") | [Go](problems/find-target-indices-after-sorting-array) | Easy | +| 2088 | [Count Fertile Pyramids in a Land](https://leetcode.com/problems/count-fertile-pyramids-in-a-land "统计农场中肥沃金字塔的数目") | [Go](problems/count-fertile-pyramids-in-a-land) | Hard | +| 2087 | [Minimum Cost Homecoming of a Robot in a Grid](https://leetcode.com/problems/minimum-cost-homecoming-of-a-robot-in-a-grid "网格图中机器人回家的最小代价") | [Go](problems/minimum-cost-homecoming-of-a-robot-in-a-grid) | Medium | +| 2086 | [Minimum Number of Buckets Required to Collect Rainwater from Houses](https://leetcode.com/problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses "从房屋收集雨水需要的最少水桶数") | [Go](problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses) | Medium | +| 2085 | [Count Common Words With One Occurrence](https://leetcode.com/problems/count-common-words-with-one-occurrence "统计出现过一次的公共字符串") | [Go](problems/count-common-words-with-one-occurrence) | Easy | +| 2084 | [Drop Type 1 Orders for Customers With Type 0 Orders](https://leetcode.com/problems/drop-type-1-orders-for-customers-with-type-0-orders "为订单类型为 0 的客户删除类型为 1 的订单") 🔒 | [MySQL](problems/drop-type-1-orders-for-customers-with-type-0-orders) | Medium | +| 2083 | [Substrings That Begin and End With the Same Letter](https://leetcode.com/problems/substrings-that-begin-and-end-with-the-same-letter "求以相同字母开头和结尾的子串总数") 🔒 | [Go](problems/substrings-that-begin-and-end-with-the-same-letter) | Medium | +| 2082 | [The Number of Rich Customers](https://leetcode.com/problems/the-number-of-rich-customers "富有客户的数量") 🔒 | [MySQL](problems/the-number-of-rich-customers) | Easy | | 2081 | [Sum of k-Mirror Numbers](https://leetcode.com/problems/sum-of-k-mirror-numbers "k 镜像数字的和") | [Go](problems/sum-of-k-mirror-numbers) | Hard | | 2080 | [Range Frequency Queries](https://leetcode.com/problems/range-frequency-queries "区间内查询数字的频率") | [Go](problems/range-frequency-queries) | Medium | | 2079 | [Watering Plants](https://leetcode.com/problems/watering-plants "给植物浇水") | [Go](problems/watering-plants) | Medium | @@ -90,18 +187,18 @@ LeetCode Problems' Solutions | 2075 | [Decode the Slanted Ciphertext](https://leetcode.com/problems/decode-the-slanted-ciphertext "解码斜向换位密码") | [Go](problems/decode-the-slanted-ciphertext) | Medium | | 2074 | [Reverse Nodes in Even Length Groups](https://leetcode.com/problems/reverse-nodes-in-even-length-groups "反转偶数长度组的节点") | [Go](problems/reverse-nodes-in-even-length-groups) | Medium | | 2073 | [Time Needed to Buy Tickets](https://leetcode.com/problems/time-needed-to-buy-tickets "买票需要的时间") | [Go](problems/time-needed-to-buy-tickets) | Easy | -| 2072 | [The Winner University](https://leetcode.com/problems/the-winner-university) 🔒 | [MySQL](problems/the-winner-university) | Easy | +| 2072 | [The Winner University](https://leetcode.com/problems/the-winner-university "赢得比赛的大学") 🔒 | [MySQL](problems/the-winner-university) | Easy | | 2071 | [Maximum Number of Tasks You Can Assign](https://leetcode.com/problems/maximum-number-of-tasks-you-can-assign "你可以安排的最多任务数目") | [Go](problems/maximum-number-of-tasks-you-can-assign) | Hard | | 2070 | [Most Beautiful Item for Each Query](https://leetcode.com/problems/most-beautiful-item-for-each-query "每一个查询的最大美丽值") | [Go](problems/most-beautiful-item-for-each-query) | Medium | | 2069 | [Walking Robot Simulation II](https://leetcode.com/problems/walking-robot-simulation-ii "模拟行走机器人 II") | [Go](problems/walking-robot-simulation-ii) | Medium | | 2068 | [Check Whether Two Strings are Almost Equivalent](https://leetcode.com/problems/check-whether-two-strings-are-almost-equivalent "检查两个字符串是否几乎相等") | [Go](problems/check-whether-two-strings-are-almost-equivalent) | Easy | | 2067 | [Number of Equal Count Substrings](https://leetcode.com/problems/number-of-equal-count-substrings) 🔒 | [Go](problems/number-of-equal-count-substrings) | Medium | -| 2066 | [Account Balance](https://leetcode.com/problems/account-balance) 🔒 | [MySQL](problems/account-balance) | Medium | +| 2066 | [Account Balance](https://leetcode.com/problems/account-balance "账户余额") 🔒 | [MySQL](problems/account-balance) | Medium | | 2065 | [Maximum Path Quality of a Graph](https://leetcode.com/problems/maximum-path-quality-of-a-graph "最大化一张图中的路径价值") | [Go](problems/maximum-path-quality-of-a-graph) | Hard | | 2064 | [Minimized Maximum of Products Distributed to Any Store](https://leetcode.com/problems/minimized-maximum-of-products-distributed-to-any-store "分配给商店的最多商品的最小值") | [Go](problems/minimized-maximum-of-products-distributed-to-any-store) | Medium | | 2063 | [Vowels of All Substrings](https://leetcode.com/problems/vowels-of-all-substrings "所有子字符串中的元音") | [Go](problems/vowels-of-all-substrings) | Medium | | 2062 | [Count Vowel Substrings of a String](https://leetcode.com/problems/count-vowel-substrings-of-a-string "统计字符串中的元音子字符串") | [Go](problems/count-vowel-substrings-of-a-string) | Easy | -| 2061 | [Number of Spaces Cleaning Robot Cleaned](https://leetcode.com/problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [Go](problems/number-of-spaces-cleaning-robot-cleaned) | Medium | +| 2061 | [Number of Spaces Cleaning Robot Cleaned](https://leetcode.com/problems/number-of-spaces-cleaning-robot-cleaned "扫地机器人清扫过的空间个数") 🔒 | [Go](problems/number-of-spaces-cleaning-robot-cleaned) | Medium | | 2060 | [Check if an Original String Exists Given Two Encoded Strings](https://leetcode.com/problems/check-if-an-original-string-exists-given-two-encoded-strings "同源字符串检测") | [Go](problems/check-if-an-original-string-exists-given-two-encoded-strings) | Hard | | 2059 | [Minimum Operations to Convert Number](https://leetcode.com/problems/minimum-operations-to-convert-number "转化数字的最小运算数") | [Go](problems/minimum-operations-to-convert-number) | Medium | | 2058 | [Find the Minimum and Maximum Number of Nodes Between Critical Points](https://leetcode.com/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points "找出临界点之间的最小和最大距离") | [Go](problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points) | Medium | @@ -110,38 +207,38 @@ LeetCode Problems' Solutions | 2055 | [Plates Between Candles](https://leetcode.com/problems/plates-between-candles "蜡烛之间的盘子") | [Go](problems/plates-between-candles) | Medium | | 2054 | [Two Best Non-Overlapping Events](https://leetcode.com/problems/two-best-non-overlapping-events "两个最好的不重叠活动") | [Go](problems/two-best-non-overlapping-events) | Medium | | 2053 | [Kth Distinct String in an Array](https://leetcode.com/problems/kth-distinct-string-in-an-array "数组中第 K 个独一无二的字符串") | [Go](problems/kth-distinct-string-in-an-array) | Easy | -| 2052 | [Minimum Cost to Separate Sentence Into Rows](https://leetcode.com/problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [Go](problems/minimum-cost-to-separate-sentence-into-rows) | Medium | +| 2052 | [Minimum Cost to Separate Sentence Into Rows](https://leetcode.com/problems/minimum-cost-to-separate-sentence-into-rows "将句子分隔成行的最低成本") 🔒 | [Go](problems/minimum-cost-to-separate-sentence-into-rows) | Medium | | 2051 | [The Category of Each Member in the Store](https://leetcode.com/problems/the-category-of-each-member-in-the-store) 🔒 | [MySQL](problems/the-category-of-each-member-in-the-store) | Medium | | 2050 | [Parallel Courses III](https://leetcode.com/problems/parallel-courses-iii "并行课程 III") | [Go](problems/parallel-courses-iii) | Hard | | 2049 | [Count Nodes With the Highest Score](https://leetcode.com/problems/count-nodes-with-the-highest-score "统计最高分的节点数目") | [Go](problems/count-nodes-with-the-highest-score) | Medium | | 2048 | [Next Greater Numerically Balanced Number](https://leetcode.com/problems/next-greater-numerically-balanced-number "下一个更大的数值平衡数") | [Go](problems/next-greater-numerically-balanced-number) | Medium | | 2047 | [Number of Valid Words in a Sentence](https://leetcode.com/problems/number-of-valid-words-in-a-sentence "句子中的有效单词数") | [Go](problems/number-of-valid-words-in-a-sentence) | Easy | -| 2046 | [Sort Linked List Already Sorted Using Absolute Values](https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [Go](problems/sort-linked-list-already-sorted-using-absolute-values) | Medium | +| 2046 | [Sort Linked List Already Sorted Using Absolute Values](https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values "给按照绝对值排序的链表排序") 🔒 | [Go](problems/sort-linked-list-already-sorted-using-absolute-values) | Medium | | 2045 | [Second Minimum Time to Reach Destination](https://leetcode.com/problems/second-minimum-time-to-reach-destination "到达目的地的第二短时间") | [Go](problems/second-minimum-time-to-reach-destination) | Hard | | 2044 | [Count Number of Maximum Bitwise-OR Subsets](https://leetcode.com/problems/count-number-of-maximum-bitwise-or-subsets "统计按位或能得到最大值的子集数目") | [Go](problems/count-number-of-maximum-bitwise-or-subsets) | Medium | | 2043 | [Simple Bank System](https://leetcode.com/problems/simple-bank-system "简易银行系统") | [Go](problems/simple-bank-system) | Medium | | 2042 | [Check if Numbers Are Ascending in a Sentence](https://leetcode.com/problems/check-if-numbers-are-ascending-in-a-sentence "检查句子中的数字是否递增") | [Go](problems/check-if-numbers-are-ascending-in-a-sentence) | Easy | -| 2041 | [Accepted Candidates From the Interviews](https://leetcode.com/problems/accepted-candidates-from-the-interviews) 🔒 | [MySQL](problems/accepted-candidates-from-the-interviews) | Medium | +| 2041 | [Accepted Candidates From the Interviews](https://leetcode.com/problems/accepted-candidates-from-the-interviews "面试中被录取的候选人") 🔒 | [MySQL](problems/accepted-candidates-from-the-interviews) | Medium | | 2040 | [Kth Smallest Product of Two Sorted Arrays](https://leetcode.com/problems/kth-smallest-product-of-two-sorted-arrays "两个有序数组的第 K 小乘积") | [Go](problems/kth-smallest-product-of-two-sorted-arrays) | Hard | | 2039 | [The Time When the Network Becomes Idle](https://leetcode.com/problems/the-time-when-the-network-becomes-idle "网络空闲的时刻") | [Go](problems/the-time-when-the-network-becomes-idle) | Medium | | 2038 | [Remove Colored Pieces if Both Neighbors are the Same Color](https://leetcode.com/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color "如果相邻两个颜色均相同则删除当前颜色") | [Go](problems/remove-colored-pieces-if-both-neighbors-are-the-same-color) | Medium | | 2037 | [Minimum Number of Moves to Seat Everyone](https://leetcode.com/problems/minimum-number-of-moves-to-seat-everyone "使每位学生都有座位的最少移动次数") | [Go](problems/minimum-number-of-moves-to-seat-everyone) | Easy | -| 2036 | [Maximum Alternating Subarray Sum](https://leetcode.com/problems/maximum-alternating-subarray-sum) 🔒 | [Go](problems/maximum-alternating-subarray-sum) | Medium | +| 2036 | [Maximum Alternating Subarray Sum](https://leetcode.com/problems/maximum-alternating-subarray-sum "最大交替子数组和") 🔒 | [Go](problems/maximum-alternating-subarray-sum) | Medium | | 2035 | [Partition Array Into Two Arrays to Minimize Sum Difference](https://leetcode.com/problems/partition-array-into-two-arrays-to-minimize-sum-difference "将数组分成两个数组并最小化数组和的差") | [Go](problems/partition-array-into-two-arrays-to-minimize-sum-difference) | Hard | | 2034 | [Stock Price Fluctuation](https://leetcode.com/problems/stock-price-fluctuation "股票价格波动") | [Go](problems/stock-price-fluctuation) | Medium | | 2033 | [Minimum Operations to Make a Uni-Value Grid](https://leetcode.com/problems/minimum-operations-to-make-a-uni-value-grid "获取单值网格的最小操作数") | [Go](problems/minimum-operations-to-make-a-uni-value-grid) | Medium | | 2032 | [Two Out of Three](https://leetcode.com/problems/two-out-of-three "至少在两个数组中出现的值") | [Go](problems/two-out-of-three) | Easy | -| 2031 | [Count Subarrays With More Ones Than Zeros](https://leetcode.com/problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [Go](problems/count-subarrays-with-more-ones-than-zeros) | Medium | +| 2031 | [Count Subarrays With More Ones Than Zeros](https://leetcode.com/problems/count-subarrays-with-more-ones-than-zeros "1 比 0 多的子数组个数") 🔒 | [Go](problems/count-subarrays-with-more-ones-than-zeros) | Medium | | 2030 | [Smallest K-Length Subsequence With Occurrences of a Letter](https://leetcode.com/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter "含特定字母的最小子序列") | [Go](problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | Hard | | 2029 | [Stone Game IX](https://leetcode.com/problems/stone-game-ix "石子游戏 IX") | [Go](problems/stone-game-ix) | Medium | | 2028 | [Find Missing Observations](https://leetcode.com/problems/find-missing-observations "找出缺失的观测数据") | [Go](problems/find-missing-observations) | Medium | | 2027 | [Minimum Moves to Convert String](https://leetcode.com/problems/minimum-moves-to-convert-string "转换字符串的最少操作次数") | [Go](problems/minimum-moves-to-convert-string) | Easy | -| 2026 | [Low-Quality Problems](https://leetcode.com/problems/low-quality-problems) 🔒 | [MySQL](problems/low-quality-problems) | Easy | +| 2026 | [Low-Quality Problems](https://leetcode.com/problems/low-quality-problems "低质量的问题") 🔒 | [MySQL](problems/low-quality-problems) | Easy | | 2025 | [Maximum Number of Ways to Partition an Array](https://leetcode.com/problems/maximum-number-of-ways-to-partition-an-array "分割数组的最多方案数") | [Go](problems/maximum-number-of-ways-to-partition-an-array) | Hard | | 2024 | [Maximize the Confusion of an Exam](https://leetcode.com/problems/maximize-the-confusion-of-an-exam "考试的最大困扰度") | [Go](problems/maximize-the-confusion-of-an-exam) | Medium | | 2023 | [Number of Pairs of Strings With Concatenation Equal to Target](https://leetcode.com/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target "连接后等于目标字符串的字符串对") | [Go](problems/number-of-pairs-of-strings-with-concatenation-equal-to-target) | Medium | | 2022 | [Convert 1D Array Into 2D Array](https://leetcode.com/problems/convert-1d-array-into-2d-array "将一维数组转变成二维数组") | [Go](problems/convert-1d-array-into-2d-array) | Easy | -| 2021 | [Brightest Position on Street](https://leetcode.com/problems/brightest-position-on-street) 🔒 | [Go](problems/brightest-position-on-street) | Medium | +| 2021 | [Brightest Position on Street](https://leetcode.com/problems/brightest-position-on-street "街上最亮的位置") 🔒 | [Go](problems/brightest-position-on-street) | Medium | | 2020 | [Number of Accounts That Did Not Stream](https://leetcode.com/problems/number-of-accounts-that-did-not-stream) 🔒 | [MySQL](problems/number-of-accounts-that-did-not-stream) | Medium | | 2019 | [The Score of Students Solving Math Expression](https://leetcode.com/problems/the-score-of-students-solving-math-expression "解出数学表达式的学生分数") | [Go](problems/the-score-of-students-solving-math-expression) | Hard | | 2018 | [Check if Word Can Be Placed In Crossword](https://leetcode.com/problems/check-if-word-can-be-placed-in-crossword "判断单词是否能放入填字游戏内") | [Go](problems/check-if-word-can-be-placed-in-crossword) | Medium | @@ -157,13 +254,13 @@ LeetCode Problems' Solutions | 2008 | [Maximum Earnings From Taxi](https://leetcode.com/problems/maximum-earnings-from-taxi "出租车的最大盈利") | [Go](problems/maximum-earnings-from-taxi) | Medium | | 2007 | [Find Original Array From Doubled Array](https://leetcode.com/problems/find-original-array-from-doubled-array "从双倍数组中还原原数组") | [Go](problems/find-original-array-from-doubled-array) | Medium | | 2006 | [Count Number of Pairs With Absolute Difference K](https://leetcode.com/problems/count-number-of-pairs-with-absolute-difference-k "差的绝对值为 K 的数对数目") | [Go](problems/count-number-of-pairs-with-absolute-difference-k) | Easy | -| 2005 | [Subtree Removal Game with Fibonacci Tree](https://leetcode.com/problems/subtree-removal-game-with-fibonacci-tree) 🔒 | [Go](problems/subtree-removal-game-with-fibonacci-tree) | Hard | +| 2005 | [Subtree Removal Game with Fibonacci Tree](https://leetcode.com/problems/subtree-removal-game-with-fibonacci-tree "斐波那契树的移除子树游戏") 🔒 | [Go](problems/subtree-removal-game-with-fibonacci-tree) | Hard | | 2004 | [The Number of Seniors and Juniors to Join the Company](https://leetcode.com/problems/the-number-of-seniors-and-juniors-to-join-the-company) 🔒 | [MySQL](problems/the-number-of-seniors-and-juniors-to-join-the-company) | Hard | | 2003 | [Smallest Missing Genetic Value in Each Subtree](https://leetcode.com/problems/smallest-missing-genetic-value-in-each-subtree "每棵子树内缺失的最小基因值") | [Go](problems/smallest-missing-genetic-value-in-each-subtree) | Hard | | 2002 | [Maximum Product of the Length of Two Palindromic Subsequences](https://leetcode.com/problems/maximum-product-of-the-length-of-two-palindromic-subsequences "两个回文子序列长度的最大乘积") | [Go](problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | Medium | | 2001 | [Number of Pairs of Interchangeable Rectangles](https://leetcode.com/problems/number-of-pairs-of-interchangeable-rectangles "可互换矩形的组数") | [Go](problems/number-of-pairs-of-interchangeable-rectangles) | Medium | | 2000 | [Reverse Prefix of Word](https://leetcode.com/problems/reverse-prefix-of-word "反转单词前缀") | [Go](problems/reverse-prefix-of-word) | Easy | -| 1999 | [Smallest Greater Multiple Made of Two Digits](https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits) 🔒 | [Go](problems/smallest-greater-multiple-made-of-two-digits) | Medium | +| 1999 | [Smallest Greater Multiple Made of Two Digits](https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits "最小的仅由两个数组成的倍数") 🔒 | [Go](problems/smallest-greater-multiple-made-of-two-digits) | Medium | | 1998 | [GCD Sort of an Array](https://leetcode.com/problems/gcd-sort-of-an-array "数组的最大公因数排序") | [Go](problems/gcd-sort-of-an-array) | Hard | | 1997 | [First Day Where You Have Been in All the Rooms](https://leetcode.com/problems/first-day-where-you-have-been-in-all-the-rooms "访问完所有房间的第一天") | [Go](problems/first-day-where-you-have-been-in-all-the-rooms) | Medium | | 1996 | [The Number of Weak Characters in the Game](https://leetcode.com/problems/the-number-of-weak-characters-in-the-game "游戏中弱角色的数量") | [Go](problems/the-number-of-weak-characters-in-the-game) | Medium | @@ -172,9 +269,9 @@ LeetCode Problems' Solutions | 1993 | [Operations on Tree](https://leetcode.com/problems/operations-on-tree "树上的操作") | [Go](problems/operations-on-tree) | Medium | | 1992 | [Find All Groups of Farmland](https://leetcode.com/problems/find-all-groups-of-farmland "找到所有的农场组") | [Go](problems/find-all-groups-of-farmland) | Medium | | 1991 | [Find the Middle Index in Array](https://leetcode.com/problems/find-the-middle-index-in-array "找到数组的中间位置") | [Go](problems/find-the-middle-index-in-array) | Easy | -| 1990 | [Count the Number of Experiments](https://leetcode.com/problems/count-the-number-of-experiments) 🔒 | [MySQL](problems/count-the-number-of-experiments) | Medium | +| 1990 | [Count the Number of Experiments](https://leetcode.com/problems/count-the-number-of-experiments "统计实验的数量") 🔒 | [MySQL](problems/count-the-number-of-experiments) | Medium | | 1989 | [Maximum Number of People That Can Be Caught in Tag](https://leetcode.com/problems/maximum-number-of-people-that-can-be-caught-in-tag) 🔒 | [Go](problems/maximum-number-of-people-that-can-be-caught-in-tag) | Medium | -| 1988 | [Find Cutoff Score for Each School](https://leetcode.com/problems/find-cutoff-score-for-each-school) 🔒 | [MySQL](problems/find-cutoff-score-for-each-school) | Medium | +| 1988 | [Find Cutoff Score for Each School](https://leetcode.com/problems/find-cutoff-score-for-each-school "找出每所学校的最低分数要求") 🔒 | [MySQL](problems/find-cutoff-score-for-each-school) | Medium | | 1987 | [Number of Unique Good Subsequences](https://leetcode.com/problems/number-of-unique-good-subsequences "不同的好子序列数目") | [Go](problems/number-of-unique-good-subsequences) | Hard | | 1986 | [Minimum Number of Work Sessions to Finish the Tasks](https://leetcode.com/problems/minimum-number-of-work-sessions-to-finish-the-tasks "完成任务的最少工作时间段") | [Go](problems/minimum-number-of-work-sessions-to-finish-the-tasks) | Medium | | 1985 | [Find the Kth Largest Integer in the Array](https://leetcode.com/problems/find-the-kth-largest-integer-in-the-array "找出数组中的第 K 大整数") | [Go](problems/find-the-kth-largest-integer-in-the-array) | Medium | @@ -184,19 +281,19 @@ LeetCode Problems' Solutions | 1981 | [Minimize the Difference Between Target and Chosen Elements](https://leetcode.com/problems/minimize-the-difference-between-target-and-chosen-elements "最小化目标值与所选元素的差") | [Go](problems/minimize-the-difference-between-target-and-chosen-elements) | Medium | | 1980 | [Find Unique Binary String](https://leetcode.com/problems/find-unique-binary-string "找出不同的二进制字符串") | [Go](problems/find-unique-binary-string) | Medium | | 1979 | [Find Greatest Common Divisor of Array](https://leetcode.com/problems/find-greatest-common-divisor-of-array "找出数组的最大公约数") | [Go](problems/find-greatest-common-divisor-of-array) | Easy | -| 1978 | [Employees Whose Manager Left the Company](https://leetcode.com/problems/employees-whose-manager-left-the-company) 🔒 | [MySQL](problems/employees-whose-manager-left-the-company) | Easy | +| 1978 | [Employees Whose Manager Left the Company](https://leetcode.com/problems/employees-whose-manager-left-the-company "上级经理已离职的公司员工") 🔒 | [MySQL](problems/employees-whose-manager-left-the-company) | Easy | | 1977 | [Number of Ways to Separate Numbers](https://leetcode.com/problems/number-of-ways-to-separate-numbers "划分数字的方案数") | [Go](problems/number-of-ways-to-separate-numbers) | Hard | | 1976 | [Number of Ways to Arrive at Destination](https://leetcode.com/problems/number-of-ways-to-arrive-at-destination "到达目的地的方案数") | [Go](problems/number-of-ways-to-arrive-at-destination) | Medium | | 1975 | [Maximum Matrix Sum](https://leetcode.com/problems/maximum-matrix-sum "最大方阵和") | [Go](problems/maximum-matrix-sum) | Medium | | 1974 | [Minimum Time to Type Word Using Special Typewriter](https://leetcode.com/problems/minimum-time-to-type-word-using-special-typewriter "使用特殊打字机键入单词的最少时间") | [Go](problems/minimum-time-to-type-word-using-special-typewriter) | Easy | -| 1973 | [Count Nodes Equal to Sum of Descendants](https://leetcode.com/problems/count-nodes-equal-to-sum-of-descendants) 🔒 | [Go](problems/count-nodes-equal-to-sum-of-descendants) | Medium | -| 1972 | [First and Last Call On the Same Day](https://leetcode.com/problems/first-and-last-call-on-the-same-day) 🔒 | [MySQL](problems/first-and-last-call-on-the-same-day) | Hard | +| 1973 | [Count Nodes Equal to Sum of Descendants](https://leetcode.com/problems/count-nodes-equal-to-sum-of-descendants "值等于子节点值之和的节点数量") 🔒 | [Go](problems/count-nodes-equal-to-sum-of-descendants) | Medium | +| 1972 | [First and Last Call On the Same Day](https://leetcode.com/problems/first-and-last-call-on-the-same-day "同一天的第一个电话和最后一个电话") 🔒 | [MySQL](problems/first-and-last-call-on-the-same-day) | Hard | | 1971 | [Find if Path Exists in Graph](https://leetcode.com/problems/find-if-path-exists-in-graph "寻找图中是否存在路径") | [Go](problems/find-if-path-exists-in-graph) | Easy | | 1970 | [Last Day Where You Can Still Cross](https://leetcode.com/problems/last-day-where-you-can-still-cross "你能穿过矩阵的最后一天") | [Go](problems/last-day-where-you-can-still-cross) | Hard | | 1969 | [Minimum Non-Zero Product of the Array Elements](https://leetcode.com/problems/minimum-non-zero-product-of-the-array-elements "数组元素的最小非零乘积") | [Go](problems/minimum-non-zero-product-of-the-array-elements) | Medium | | 1968 | [Array With Elements Not Equal to Average of Neighbors](https://leetcode.com/problems/array-with-elements-not-equal-to-average-of-neighbors "构造元素不等于两相邻元素平均值的数组") | [Go](problems/array-with-elements-not-equal-to-average-of-neighbors) | Medium | | 1967 | [Number of Strings That Appear as Substrings in Word](https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word "作为子字符串出现在单词中的字符串数目") | [Go](problems/number-of-strings-that-appear-as-substrings-in-word) | Easy | -| 1966 | [Binary Searchable Numbers in an Unsorted Array](https://leetcode.com/problems/binary-searchable-numbers-in-an-unsorted-array) 🔒 | [Go](problems/binary-searchable-numbers-in-an-unsorted-array) | Medium | +| 1966 | [Binary Searchable Numbers in an Unsorted Array](https://leetcode.com/problems/binary-searchable-numbers-in-an-unsorted-array "未排序数组中的可被二分搜索的数") 🔒 | [Go](problems/binary-searchable-numbers-in-an-unsorted-array) | Medium | | 1965 | [Employees With Missing Information](https://leetcode.com/problems/employees-with-missing-information "丢失信息的雇员") 🔒 | [MySQL](problems/employees-with-missing-information) | Easy | | 1964 | [Find the Longest Valid Obstacle Course at Each Position](https://leetcode.com/problems/find-the-longest-valid-obstacle-course-at-each-position "找出到每个位置为止最长的有效障碍赛跑路线") | [Go](problems/find-the-longest-valid-obstacle-course-at-each-position) | Hard | | 1963 | [Minimum Number of Swaps to Make the String Balanced](https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-string-balanced "使字符串平衡的最小交换次数") | [Go](problems/minimum-number-of-swaps-to-make-the-string-balanced) | Medium | @@ -213,7 +310,7 @@ LeetCode Problems' Solutions | 1952 | [Three Divisors](https://leetcode.com/problems/three-divisors "三除数") | [Go](problems/three-divisors) | Easy | | 1951 | [All the Pairs With the Maximum Number of Common Followers](https://leetcode.com/problems/all-the-pairs-with-the-maximum-number-of-common-followers "查询具有最多共同关注者的所有两两结对组") 🔒 | [MySQL](problems/all-the-pairs-with-the-maximum-number-of-common-followers) | Medium | | 1950 | [Maximum of Minimum Values in All Subarrays](https://leetcode.com/problems/maximum-of-minimum-values-in-all-subarrays "所有子数组最小值中的最大值") 🔒 | [Go](problems/maximum-of-minimum-values-in-all-subarrays) | Medium | -| 1949 | [Strong Friendship](https://leetcode.com/problems/strong-friendship) 🔒 | [MySQL](problems/strong-friendship) | Medium | +| 1949 | [Strong Friendship](https://leetcode.com/problems/strong-friendship "坚定的友谊") 🔒 | [MySQL](problems/strong-friendship) | Medium | | 1948 | [Delete Duplicate Folders in System](https://leetcode.com/problems/delete-duplicate-folders-in-system "删除系统中的重复文件夹") | [Go](problems/delete-duplicate-folders-in-system) | Hard | | 1947 | [Maximum Compatibility Score Sum](https://leetcode.com/problems/maximum-compatibility-score-sum "最大兼容性评分和") | [Go](problems/maximum-compatibility-score-sum) | Medium | | 1946 | [Largest Number After Mutating Substring](https://leetcode.com/problems/largest-number-after-mutating-substring "子字符串突变后可能得到的最大整数") | [Go](problems/largest-number-after-mutating-substring) | Medium | @@ -223,7 +320,7 @@ LeetCode Problems' Solutions | 1942 | [The Number of the Smallest Unoccupied Chair](https://leetcode.com/problems/the-number-of-the-smallest-unoccupied-chair "最小未被占据椅子的编号") | [Go](problems/the-number-of-the-smallest-unoccupied-chair) | Medium | | 1941 | [Check if All Characters Have Equal Number of Occurrences](https://leetcode.com/problems/check-if-all-characters-have-equal-number-of-occurrences "检查是否所有字符出现次数相同") | [Go](problems/check-if-all-characters-have-equal-number-of-occurrences) | Easy | | 1940 | [Longest Common Subsequence Between Sorted Arrays](https://leetcode.com/problems/longest-common-subsequence-between-sorted-arrays "排序数组之间的最长公共子序列") 🔒 | [Go](problems/longest-common-subsequence-between-sorted-arrays) | Medium | -| 1939 | [Users That Actively Request Confirmation Messages](https://leetcode.com/problems/users-that-actively-request-confirmation-messages) 🔒 | [MySQL](problems/users-that-actively-request-confirmation-messages) | Easy | +| 1939 | [Users That Actively Request Confirmation Messages](https://leetcode.com/problems/users-that-actively-request-confirmation-messages "主动请求确认消息的用户") 🔒 | [MySQL](problems/users-that-actively-request-confirmation-messages) | Easy | | 1938 | [Maximum Genetic Difference Query](https://leetcode.com/problems/maximum-genetic-difference-query "查询最大基因差") | [Go](problems/maximum-genetic-difference-query) | Hard | | 1937 | [Maximum Number of Points with Cost](https://leetcode.com/problems/maximum-number-of-points-with-cost "扣分后的最大得分") | [Go](problems/maximum-number-of-points-with-cost) | Medium | | 1936 | [Add Minimum Number of Rungs](https://leetcode.com/problems/add-minimum-number-of-rungs "新增的最少台阶数") | [Go](problems/add-minimum-number-of-rungs) | Medium | @@ -238,14 +335,14 @@ LeetCode Problems' Solutions | 1927 | [Sum Game](https://leetcode.com/problems/sum-game "求和游戏") | [Go](problems/sum-game) | Medium | | 1926 | [Nearest Exit from Entrance in Maze](https://leetcode.com/problems/nearest-exit-from-entrance-in-maze "迷宫中离入口最近的出口") | [Go](problems/nearest-exit-from-entrance-in-maze) | Medium | | 1925 | [Count Square Sum Triples](https://leetcode.com/problems/count-square-sum-triples "统计平方和三元组的数目") | [Go](problems/count-square-sum-triples) | Easy | -| 1924 | [Erect the Fence II](https://leetcode.com/problems/erect-the-fence-ii) 🔒 | [Go](problems/erect-the-fence-ii) | Hard | +| 1924 | [Erect the Fence II](https://leetcode.com/problems/erect-the-fence-ii "安装栅栏 II") 🔒 | [Go](problems/erect-the-fence-ii) | Hard | | 1923 | [Longest Common Subpath](https://leetcode.com/problems/longest-common-subpath "最长公共子路径") | [Go](problems/longest-common-subpath) | Hard | | 1922 | [Count Good Numbers](https://leetcode.com/problems/count-good-numbers "统计好数字的数目") | [Go](problems/count-good-numbers) | Medium | | 1921 | [Eliminate Maximum Number of Monsters](https://leetcode.com/problems/eliminate-maximum-number-of-monsters "消灭怪物的最大数量") | [Go](problems/eliminate-maximum-number-of-monsters) | Medium | | 1920 | [Build Array from Permutation](https://leetcode.com/problems/build-array-from-permutation "基于排列构建数组") | [Go](problems/build-array-from-permutation) | Easy | | 1919 | [Leetcodify Similar Friends](https://leetcode.com/problems/leetcodify-similar-friends "兴趣相同的朋友") 🔒 | [MySQL](problems/leetcodify-similar-friends) | Hard | | 1918 | [Kth Smallest Subarray Sum](https://leetcode.com/problems/kth-smallest-subarray-sum "第 K 小的子数组和·") 🔒 | [Go](problems/kth-smallest-subarray-sum) | Medium | -| 1917 | [Leetcodify Friends Recommendations](https://leetcode.com/problems/leetcodify-friends-recommendations) 🔒 | [MySQL](problems/leetcodify-friends-recommendations) | Hard | +| 1917 | [Leetcodify Friends Recommendations](https://leetcode.com/problems/leetcodify-friends-recommendations "Leetcodify 好友推荐") 🔒 | [MySQL](problems/leetcodify-friends-recommendations) | Hard | | 1916 | [Count Ways to Build Rooms in an Ant Colony](https://leetcode.com/problems/count-ways-to-build-rooms-in-an-ant-colony "统计为蚁群构筑房间的不同顺序") | [Go](problems/count-ways-to-build-rooms-in-an-ant-colony) | Hard | | 1915 | [Number of Wonderful Substrings](https://leetcode.com/problems/number-of-wonderful-substrings "最美子字符串的数目") | [Go](problems/number-of-wonderful-substrings) | Medium | | 1914 | [Cyclically Rotating a Grid](https://leetcode.com/problems/cyclically-rotating-a-grid "循环轮转矩阵") | [Go](problems/cyclically-rotating-a-grid) | Medium | @@ -260,7 +357,7 @@ LeetCode Problems' Solutions | 1905 | [Count Sub Islands](https://leetcode.com/problems/count-sub-islands "统计子岛屿") | [Go](problems/count-sub-islands) | Medium | | 1904 | [The Number of Full Rounds You Have Played](https://leetcode.com/problems/the-number-of-full-rounds-you-have-played "你完成的完整对局数") | [Go](problems/the-number-of-full-rounds-you-have-played) | Medium | | 1903 | [Largest Odd Number in String](https://leetcode.com/problems/largest-odd-number-in-string "字符串中的最大奇数") | [Go](problems/largest-odd-number-in-string) | Easy | -| 1902 | [Depth of BST Given Insertion Order](https://leetcode.com/problems/depth-of-bst-given-insertion-order) 🔒 | [Go](problems/depth-of-bst-given-insertion-order) | Medium | +| 1902 | [Depth of BST Given Insertion Order](https://leetcode.com/problems/depth-of-bst-given-insertion-order "给定二叉搜索树的插入顺序求深度") 🔒 | [Go](problems/depth-of-bst-given-insertion-order) | Medium | | 1901 | [Find a Peak Element II](https://leetcode.com/problems/find-a-peak-element-ii "找出顶峰元素 II") | [Go](problems/find-a-peak-element-ii) | Medium | | 1900 | [The Earliest and Latest Rounds Where Players Compete](https://leetcode.com/problems/the-earliest-and-latest-rounds-where-players-compete "最佳运动员的比拼回合") | [Go](problems/the-earliest-and-latest-rounds-where-players-compete) | Hard | | 1899 | [Merge Triplets to Form Target Triplet](https://leetcode.com/problems/merge-triplets-to-form-target-triplet "合并若干三元组以形成目标三元组") | [Go](problems/merge-triplets-to-form-target-triplet) | Medium | @@ -277,7 +374,7 @@ LeetCode Problems' Solutions | 1888 | [Minimum Number of Flips to Make the Binary String Alternating](https://leetcode.com/problems/minimum-number-of-flips-to-make-the-binary-string-alternating "使二进制字符串字符交替的最少反转次数") | [Go](problems/minimum-number-of-flips-to-make-the-binary-string-alternating) | Medium | | 1887 | [Reduction Operations to Make the Array Elements Equal](https://leetcode.com/problems/reduction-operations-to-make-the-array-elements-equal "使数组元素相等的减少操作次数") | [Go](problems/reduction-operations-to-make-the-array-elements-equal) | Medium | | 1886 | [Determine Whether Matrix Can Be Obtained By Rotation](https://leetcode.com/problems/determine-whether-matrix-can-be-obtained-by-rotation "判断矩阵经轮转后是否一致") | [Go](problems/determine-whether-matrix-can-be-obtained-by-rotation) | Easy | -| 1885 | [Count Pairs in Two Arrays](https://leetcode.com/problems/count-pairs-in-two-arrays) 🔒 | [Go](problems/count-pairs-in-two-arrays) | Medium | +| 1885 | [Count Pairs in Two Arrays](https://leetcode.com/problems/count-pairs-in-two-arrays "统计数对") 🔒 | [Go](problems/count-pairs-in-two-arrays) | Medium | | 1884 | [Egg Drop With 2 Eggs and N Floors](https://leetcode.com/problems/egg-drop-with-2-eggs-and-n-floors "鸡蛋掉落-两枚鸡蛋") | [Go](problems/egg-drop-with-2-eggs-and-n-floors) | Medium | | 1883 | [Minimum Skips to Arrive at Meeting On Time](https://leetcode.com/problems/minimum-skips-to-arrive-at-meeting-on-time "准时抵达会议现场的最小跳过休息次数") | [Go](problems/minimum-skips-to-arrive-at-meeting-on-time) | Hard | | 1882 | [Process Tasks Using Servers](https://leetcode.com/problems/process-tasks-using-servers "使用服务器处理任务") | [Go](problems/process-tasks-using-servers) | Medium | @@ -287,7 +384,7 @@ LeetCode Problems' Solutions | 1878 | [Get Biggest Three Rhombus Sums in a Grid](https://leetcode.com/problems/get-biggest-three-rhombus-sums-in-a-grid "矩阵中最大的三个菱形和") | [Go](problems/get-biggest-three-rhombus-sums-in-a-grid) | Medium | | 1877 | [Minimize Maximum Pair Sum in Array](https://leetcode.com/problems/minimize-maximum-pair-sum-in-array "数组中最大数对和的最小值") | [Go](problems/minimize-maximum-pair-sum-in-array) | Medium | | 1876 | [Substrings of Size Three with Distinct Characters](https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters "长度为三且各字符不同的子字符串") | [Go](problems/substrings-of-size-three-with-distinct-characters) | Easy | -| 1875 | [Group Employees of the Same Salary](https://leetcode.com/problems/group-employees-of-the-same-salary) 🔒 | [MySQL](problems/group-employees-of-the-same-salary) | Medium | +| 1875 | [Group Employees of the Same Salary](https://leetcode.com/problems/group-employees-of-the-same-salary "将工资相同的雇员分组") 🔒 | [MySQL](problems/group-employees-of-the-same-salary) | Medium | | 1874 | [Minimize Product Sum of Two Arrays](https://leetcode.com/problems/minimize-product-sum-of-two-arrays "两个数组的最小乘积和") 🔒 | [Go](problems/minimize-product-sum-of-two-arrays) | Medium | | 1873 | [Calculate Special Bonus](https://leetcode.com/problems/calculate-special-bonus "计算特殊奖金") 🔒 | [MySQL](problems/calculate-special-bonus) | Easy | | 1872 | [Stone Game VIII](https://leetcode.com/problems/stone-game-viii "石子游戏 VIII") | [Go](problems/stone-game-viii) | Hard | @@ -295,7 +392,7 @@ LeetCode Problems' Solutions | 1870 | [Minimum Speed to Arrive on Time](https://leetcode.com/problems/minimum-speed-to-arrive-on-time "准时到达的列车最小时速") | [Go](problems/minimum-speed-to-arrive-on-time) | Medium | | 1869 | [Longer Contiguous Segments of Ones than Zeros](https://leetcode.com/problems/longer-contiguous-segments-of-ones-than-zeros "哪种连续子字符串更长") | [Go](problems/longer-contiguous-segments-of-ones-than-zeros) | Easy | | 1868 | [Product of Two Run-Length Encoded Arrays](https://leetcode.com/problems/product-of-two-run-length-encoded-arrays "两个行程编码数组的积") 🔒 | [Go](problems/product-of-two-run-length-encoded-arrays) | Medium | -| 1867 | [Orders With Maximum Quantity Above Average](https://leetcode.com/problems/orders-with-maximum-quantity-above-average) 🔒 | [MySQL](problems/orders-with-maximum-quantity-above-average) | Medium | +| 1867 | [Orders With Maximum Quantity Above Average](https://leetcode.com/problems/orders-with-maximum-quantity-above-average "最大数量高于平均水平的订单") 🔒 | [MySQL](problems/orders-with-maximum-quantity-above-average) | Medium | | 1866 | [Number of Ways to Rearrange Sticks With K Sticks Visible](https://leetcode.com/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible "恰有 K 根木棍可以看到的排列数目") | [Go](problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible) | Hard | | 1865 | [Finding Pairs With a Certain Sum](https://leetcode.com/problems/finding-pairs-with-a-certain-sum "找出和为指定值的下标对") | [Go](problems/finding-pairs-with-a-certain-sum) | Medium | | 1864 | [Minimum Number of Swaps to Make the Binary String Alternating](https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating "构成交替字符串需要的最小交换次数") | [Go](problems/minimum-number-of-swaps-to-make-the-binary-string-alternating) | Medium | @@ -319,7 +416,7 @@ LeetCode Problems' Solutions | 1846 | [Maximum Element After Decreasing and Rearranging](https://leetcode.com/problems/maximum-element-after-decreasing-and-rearranging "减小和重新排列数组后的最大元素") | [Go](problems/maximum-element-after-decreasing-and-rearranging) | Medium | | 1845 | [Seat Reservation Manager](https://leetcode.com/problems/seat-reservation-manager "座位预约管理系统") | [Go](problems/seat-reservation-manager) | Medium | | 1844 | [Replace All Digits with Characters](https://leetcode.com/problems/replace-all-digits-with-characters "将所有数字用字符替换") | [Go](problems/replace-all-digits-with-characters) | Easy | -| 1843 | [Suspicious Bank Accounts](https://leetcode.com/problems/suspicious-bank-accounts) 🔒 | [MySQL](problems/suspicious-bank-accounts) | Medium | +| 1843 | [Suspicious Bank Accounts](https://leetcode.com/problems/suspicious-bank-accounts "可疑银行账户") 🔒 | [MySQL](problems/suspicious-bank-accounts) | Medium | | 1842 | [Next Palindrome Using Same Digits](https://leetcode.com/problems/next-palindrome-using-same-digits "下个由相同数字构成的回文串") 🔒 | [Go](problems/next-palindrome-using-same-digits) | Hard | | 1841 | [League Statistics](https://leetcode.com/problems/league-statistics "联赛信息统计") 🔒 | [MySQL](problems/league-statistics) | Medium | | 1840 | [Maximum Building Height](https://leetcode.com/problems/maximum-building-height "最高建筑高度") | [Go](problems/maximum-building-height) | Hard | @@ -362,303 +459,3 @@ LeetCode Problems' Solutions | 1803 | [Count Pairs With XOR in a Range](https://leetcode.com/problems/count-pairs-with-xor-in-a-range "统计异或值在范围内的数对有多少") | [Go](problems/count-pairs-with-xor-in-a-range) | Hard | | 1802 | [Maximum Value at a Given Index in a Bounded Array](https://leetcode.com/problems/maximum-value-at-a-given-index-in-a-bounded-array "有界数组中指定下标处的最大值") | [Go](problems/maximum-value-at-a-given-index-in-a-bounded-array) | Medium | | 1801 | [Number of Orders in the Backlog](https://leetcode.com/problems/number-of-orders-in-the-backlog "积压订单中的订单总数") | [Go](problems/number-of-orders-in-the-backlog) | Medium | -| 1800 | [Maximum Ascending Subarray Sum](https://leetcode.com/problems/maximum-ascending-subarray-sum "最大升序子数组和") | [Go](problems/maximum-ascending-subarray-sum) | Easy | -| 1799 | [Maximize Score After N Operations](https://leetcode.com/problems/maximize-score-after-n-operations "N 次操作后的最大分数和") | [Go](problems/maximize-score-after-n-operations) | Hard | -| 1798 | [Maximum Number of Consecutive Values You Can Make](https://leetcode.com/problems/maximum-number-of-consecutive-values-you-can-make "你能构造出连续值的最大数目") | [Go](problems/maximum-number-of-consecutive-values-you-can-make) | Medium | -| 1797 | [Design Authentication Manager](https://leetcode.com/problems/design-authentication-manager "设计一个验证系统") | [Go](problems/design-authentication-manager) | Medium | -| 1796 | [Second Largest Digit in a String](https://leetcode.com/problems/second-largest-digit-in-a-string "字符串中第二大的数字") | [Go](problems/second-largest-digit-in-a-string) | Easy | -| 1795 | [Rearrange Products Table](https://leetcode.com/problems/rearrange-products-table "每个产品在不同商店的价格") 🔒 | [MySQL](problems/rearrange-products-table) | Easy | -| 1794 | [Count Pairs of Equal Substrings With Minimum Difference](https://leetcode.com/problems/count-pairs-of-equal-substrings-with-minimum-difference "统计距离最小的子串对个数") 🔒 | [Go](problems/count-pairs-of-equal-substrings-with-minimum-difference) | Medium | -| 1793 | [Maximum Score of a Good Subarray](https://leetcode.com/problems/maximum-score-of-a-good-subarray "好子数组的最大分数") | [Go](problems/maximum-score-of-a-good-subarray) | Hard | -| 1792 | [Maximum Average Pass Ratio](https://leetcode.com/problems/maximum-average-pass-ratio "最大平均通过率") | [Go](problems/maximum-average-pass-ratio) | Medium | -| 1791 | [Find Center of Star Graph](https://leetcode.com/problems/find-center-of-star-graph "找出星型图的中心节点") | [Go](problems/find-center-of-star-graph) | Easy | -| 1790 | [Check if One String Swap Can Make Strings Equal](https://leetcode.com/problems/check-if-one-string-swap-can-make-strings-equal "仅执行一次字符串交换能否使两个字符串相等") | [Go](problems/check-if-one-string-swap-can-make-strings-equal) | Easy | -| 1789 | [Primary Department for Each Employee](https://leetcode.com/problems/primary-department-for-each-employee "员工的直属部门") 🔒 | [MySQL](problems/primary-department-for-each-employee) | Easy | -| 1788 | [Maximize the Beauty of the Garden](https://leetcode.com/problems/maximize-the-beauty-of-the-garden "最大化花园的美观度") 🔒 | [Go](problems/maximize-the-beauty-of-the-garden) | Hard | -| 1787 | [Make the XOR of All Segments Equal to Zero](https://leetcode.com/problems/make-the-xor-of-all-segments-equal-to-zero "使所有区间的异或结果为零") | [Go](problems/make-the-xor-of-all-segments-equal-to-zero) | Hard | -| 1786 | [Number of Restricted Paths From First to Last Node](https://leetcode.com/problems/number-of-restricted-paths-from-first-to-last-node "从第一个节点出发到最后一个节点的受限路径数") | [Go](problems/number-of-restricted-paths-from-first-to-last-node) | Medium | -| 1785 | [Minimum Elements to Add to Form a Given Sum](https://leetcode.com/problems/minimum-elements-to-add-to-form-a-given-sum "构成特定和需要添加的最少元素") | [Go](problems/minimum-elements-to-add-to-form-a-given-sum) | Medium | -| 1784 | [Check if Binary String Has at Most One Segment of Ones](https://leetcode.com/problems/check-if-binary-string-has-at-most-one-segment-of-ones "检查二进制字符串字段") | [Go](problems/check-if-binary-string-has-at-most-one-segment-of-ones) | Easy | -| 1783 | [Grand Slam Titles](https://leetcode.com/problems/grand-slam-titles "大满贯数量") 🔒 | [MySQL](problems/grand-slam-titles) | Medium | -| 1782 | [Count Pairs Of Nodes](https://leetcode.com/problems/count-pairs-of-nodes "统计点对的数目") | [Go](problems/count-pairs-of-nodes) | Hard | -| 1781 | [Sum of Beauty of All Substrings](https://leetcode.com/problems/sum-of-beauty-of-all-substrings "所有子字符串美丽值之和") | [Go](problems/sum-of-beauty-of-all-substrings) | Medium | -| 1780 | [Check if Number is a Sum of Powers of Three](https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three "判断一个数字是否可以表示成三的幂的和") | [Go](problems/check-if-number-is-a-sum-of-powers-of-three) | Medium | -| 1779 | [Find Nearest Point That Has the Same X or Y Coordinate](https://leetcode.com/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate "找到最近的有相同 X 或 Y 坐标的点") | [Go](problems/find-nearest-point-that-has-the-same-x-or-y-coordinate) | Easy | -| 1778 | [Shortest Path in a Hidden Grid](https://leetcode.com/problems/shortest-path-in-a-hidden-grid "未知网格中的最短路径") 🔒 | [Go](problems/shortest-path-in-a-hidden-grid) | Medium | -| 1777 | [Product's Price for Each Store](https://leetcode.com/problems/products-price-for-each-store "每家商店的产品价格") 🔒 | [MySQL](problems/products-price-for-each-store) | Easy | -| 1776 | [Car Fleet II](https://leetcode.com/problems/car-fleet-ii "车队 II") | [Go](problems/car-fleet-ii) | Hard | -| 1775 | [Equal Sum Arrays With Minimum Number of Operations](https://leetcode.com/problems/equal-sum-arrays-with-minimum-number-of-operations "通过最少操作次数使数组的和相等") | [Go](problems/equal-sum-arrays-with-minimum-number-of-operations) | Medium | -| 1774 | [Closest Dessert Cost](https://leetcode.com/problems/closest-dessert-cost "最接近目标价格的甜点成本") | [Go](problems/closest-dessert-cost) | Medium | -| 1773 | [Count Items Matching a Rule](https://leetcode.com/problems/count-items-matching-a-rule "统计匹配检索规则的物品数量") | [Go](problems/count-items-matching-a-rule) | Easy | -| 1772 | [Sort Features by Popularity](https://leetcode.com/problems/sort-features-by-popularity "按受欢迎程度排列功能") 🔒 | [Go](problems/sort-features-by-popularity) | Medium | -| 1771 | [Maximize Palindrome Length From Subsequences](https://leetcode.com/problems/maximize-palindrome-length-from-subsequences "由子序列构造的最长回文串的长度") | [Go](problems/maximize-palindrome-length-from-subsequences) | Hard | -| 1770 | [Maximum Score from Performing Multiplication Operations](https://leetcode.com/problems/maximum-score-from-performing-multiplication-operations "执行乘法运算的最大分数") | [Go](problems/maximum-score-from-performing-multiplication-operations) | Medium | -| 1769 | [Minimum Number of Operations to Move All Balls to Each Box](https://leetcode.com/problems/minimum-number-of-operations-to-move-all-balls-to-each-box "移动所有球到每个盒子所需的最小操作数") | [Go](problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | Medium | -| 1768 | [Merge Strings Alternately](https://leetcode.com/problems/merge-strings-alternately "交替合并字符串") | [Go](problems/merge-strings-alternately) | Easy | -| 1767 | [Find the Subtasks That Did Not Execute](https://leetcode.com/problems/find-the-subtasks-that-did-not-execute "寻找没有被执行的任务对") 🔒 | [MySQL](problems/find-the-subtasks-that-did-not-execute) | Hard | -| 1766 | [Tree of Coprimes](https://leetcode.com/problems/tree-of-coprimes "互质树") | [Go](problems/tree-of-coprimes) | Hard | -| 1765 | [Map of Highest Peak](https://leetcode.com/problems/map-of-highest-peak "地图中的最高点") | [Go](problems/map-of-highest-peak) | Medium | -| 1764 | [Form Array by Concatenating Subarrays of Another Array](https://leetcode.com/problems/form-array-by-concatenating-subarrays-of-another-array "通过连接另一个数组的子数组得到一个数组") | [Go](problems/form-array-by-concatenating-subarrays-of-another-array) | Medium | -| 1763 | [Longest Nice Substring](https://leetcode.com/problems/longest-nice-substring "最长的美好子字符串") | [Go](problems/longest-nice-substring) | Easy | -| 1762 | [Buildings With an Ocean View](https://leetcode.com/problems/buildings-with-an-ocean-view "能看到海景的建筑物") 🔒 | [Go](problems/buildings-with-an-ocean-view) | Medium | -| 1761 | [Minimum Degree of a Connected Trio in a Graph](https://leetcode.com/problems/minimum-degree-of-a-connected-trio-in-a-graph "一个图中连通三元组的最小度数") | [Go](problems/minimum-degree-of-a-connected-trio-in-a-graph) | Hard | -| 1760 | [Minimum Limit of Balls in a Bag](https://leetcode.com/problems/minimum-limit-of-balls-in-a-bag "袋子里最少数目的球") | [Go](problems/minimum-limit-of-balls-in-a-bag) | Medium | -| 1759 | [Count Number of Homogenous Substrings](https://leetcode.com/problems/count-number-of-homogenous-substrings "统计同构子字符串的数目") | [Go](problems/count-number-of-homogenous-substrings) | Medium | -| 1758 | [Minimum Changes To Make Alternating Binary String](https://leetcode.com/problems/minimum-changes-to-make-alternating-binary-string "生成交替二进制字符串的最少操作数") | [Go](problems/minimum-changes-to-make-alternating-binary-string) | Easy | -| 1757 | [Recyclable and Low Fat Products](https://leetcode.com/problems/recyclable-and-low-fat-products "可回收且低脂的产品") 🔒 | [MySQL](problems/recyclable-and-low-fat-products) | Easy | -| 1756 | [Design Most Recently Used Queue](https://leetcode.com/problems/design-most-recently-used-queue "设计最近使用(MRU)队列") 🔒 | [Go](problems/design-most-recently-used-queue) | Medium | -| 1755 | [Closest Subsequence Sum](https://leetcode.com/problems/closest-subsequence-sum "最接近目标值的子序列和") | [Go](problems/closest-subsequence-sum) | Hard | -| 1754 | [Largest Merge Of Two Strings](https://leetcode.com/problems/largest-merge-of-two-strings "构造字典序最大的合并字符串") | [Go](problems/largest-merge-of-two-strings) | Medium | -| 1753 | [Maximum Score From Removing Stones](https://leetcode.com/problems/maximum-score-from-removing-stones "移除石子的最大得分") | [Go](problems/maximum-score-from-removing-stones) | Medium | -| 1752 | [Check if Array Is Sorted and Rotated](https://leetcode.com/problems/check-if-array-is-sorted-and-rotated "检查数组是否经排序和轮转得到") | [Go](problems/check-if-array-is-sorted-and-rotated) | Easy | -| 1751 | [Maximum Number of Events That Can Be Attended II](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended-ii "最多可以参加的会议数目 II") | [Go](problems/maximum-number-of-events-that-can-be-attended-ii) | Hard | -| 1750 | [Minimum Length of String After Deleting Similar Ends](https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends "删除字符串两端相同字符后的最短长度") | [Go](problems/minimum-length-of-string-after-deleting-similar-ends) | Medium | -| 1749 | [Maximum Absolute Sum of Any Subarray](https://leetcode.com/problems/maximum-absolute-sum-of-any-subarray "任意子数组和的绝对值的最大值") | [Go](problems/maximum-absolute-sum-of-any-subarray) | Medium | -| 1748 | [Sum of Unique Elements](https://leetcode.com/problems/sum-of-unique-elements "唯一元素的和") | [Go](problems/sum-of-unique-elements) | Easy | -| 1747 | [Leetflex Banned Accounts](https://leetcode.com/problems/leetflex-banned-accounts "应该被禁止的Leetflex账户") 🔒 | [MySQL](problems/leetflex-banned-accounts) | Medium | -| 1746 | [Maximum Subarray Sum After One Operation](https://leetcode.com/problems/maximum-subarray-sum-after-one-operation "经过一次操作后的最大子数组和") 🔒 | [Go](problems/maximum-subarray-sum-after-one-operation) | Medium | -| 1745 | [Palindrome Partitioning IV](https://leetcode.com/problems/palindrome-partitioning-iv "回文串分割 IV") | [Go](problems/palindrome-partitioning-iv) | Hard | -| 1744 | [Can You Eat Your Favorite Candy on Your Favorite Day?](https://leetcode.com/problems/can-you-eat-your-favorite-candy-on-your-favorite-day "你能在你最喜欢的那天吃到你最喜欢的糖果吗?") | [Go](problems/can-you-eat-your-favorite-candy-on-your-favorite-day) | Medium | -| 1743 | [Restore the Array From Adjacent Pairs](https://leetcode.com/problems/restore-the-array-from-adjacent-pairs "从相邻元素对还原数组") | [Go](problems/restore-the-array-from-adjacent-pairs) | Medium | -| 1742 | [Maximum Number of Balls in a Box](https://leetcode.com/problems/maximum-number-of-balls-in-a-box "盒子中小球的最大数量") | [Go](problems/maximum-number-of-balls-in-a-box) | Easy | -| 1741 | [Find Total Time Spent by Each Employee](https://leetcode.com/problems/find-total-time-spent-by-each-employee "查找每个员工花费的总时间") 🔒 | [MySQL](problems/find-total-time-spent-by-each-employee) | Easy | -| 1740 | [Find Distance in a Binary Tree](https://leetcode.com/problems/find-distance-in-a-binary-tree "找到二叉树中的距离") 🔒 | [Go](problems/find-distance-in-a-binary-tree) | Medium | -| 1739 | [Building Boxes](https://leetcode.com/problems/building-boxes "放置盒子") | [Go](problems/building-boxes) | Hard | -| 1738 | [Find Kth Largest XOR Coordinate Value](https://leetcode.com/problems/find-kth-largest-xor-coordinate-value "找出第 K 大的异或坐标值") | [Go](problems/find-kth-largest-xor-coordinate-value) | Medium | -| 1737 | [Change Minimum Characters to Satisfy One of Three Conditions](https://leetcode.com/problems/change-minimum-characters-to-satisfy-one-of-three-conditions "满足三条件之一需改变的最少字符数") | [Go](problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | Medium | -| 1736 | [Latest Time by Replacing Hidden Digits](https://leetcode.com/problems/latest-time-by-replacing-hidden-digits "替换隐藏数字得到的最晚时间") | [Go](problems/latest-time-by-replacing-hidden-digits) | Easy | -| 1735 | [Count Ways to Make Array With Product](https://leetcode.com/problems/count-ways-to-make-array-with-product "生成乘积数组的方案数") | [Go](problems/count-ways-to-make-array-with-product) | Hard | -| 1734 | [Decode XORed Permutation](https://leetcode.com/problems/decode-xored-permutation "解码异或后的排列") | [Go](problems/decode-xored-permutation) | Medium | -| 1733 | [Minimum Number of People to Teach](https://leetcode.com/problems/minimum-number-of-people-to-teach "需要教语言的最少人数") | [Go](problems/minimum-number-of-people-to-teach) | Medium | -| 1732 | [Find the Highest Altitude](https://leetcode.com/problems/find-the-highest-altitude "找到最高海拔") | [Go](problems/find-the-highest-altitude) | Easy | -| 1731 | [The Number of Employees Which Report to Each Employee](https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee "每位经理的下属员工数量") 🔒 | [MySQL](problems/the-number-of-employees-which-report-to-each-employee) | Easy | -| 1730 | [Shortest Path to Get Food](https://leetcode.com/problems/shortest-path-to-get-food "获取食物的最短路径") 🔒 | [Go](problems/shortest-path-to-get-food) | Medium | -| 1729 | [Find Followers Count](https://leetcode.com/problems/find-followers-count "求关注者的数量") 🔒 | [MySQL](problems/find-followers-count) | Easy | -| 1728 | [Cat and Mouse II](https://leetcode.com/problems/cat-and-mouse-ii "猫和老鼠 II") | [Go](problems/cat-and-mouse-ii) | Hard | -| 1727 | [Largest Submatrix With Rearrangements](https://leetcode.com/problems/largest-submatrix-with-rearrangements "重新排列后的最大子矩阵") | [Go](problems/largest-submatrix-with-rearrangements) | Medium | -| 1726 | [Tuple with Same Product](https://leetcode.com/problems/tuple-with-same-product "同积元组") | [Go](problems/tuple-with-same-product) | Medium | -| 1725 | [Number Of Rectangles That Can Form The Largest Square](https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square "可以形成最大正方形的矩形数目") | [Go](problems/number-of-rectangles-that-can-form-the-largest-square) | Easy | -| 1724 | [Checking Existence of Edge Length Limited Paths II](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths-ii "检查边长度限制的路径是否存在 II") 🔒 | [Go](problems/checking-existence-of-edge-length-limited-paths-ii) | Hard | -| 1723 | [Find Minimum Time to Finish All Jobs](https://leetcode.com/problems/find-minimum-time-to-finish-all-jobs "完成所有工作的最短时间") | [Go](problems/find-minimum-time-to-finish-all-jobs) | Hard | -| 1722 | [Minimize Hamming Distance After Swap Operations](https://leetcode.com/problems/minimize-hamming-distance-after-swap-operations "执行交换操作后的最小汉明距离") | [Go](problems/minimize-hamming-distance-after-swap-operations) | Medium | -| 1721 | [Swapping Nodes in a Linked List](https://leetcode.com/problems/swapping-nodes-in-a-linked-list "交换链表中的节点") | [Go](problems/swapping-nodes-in-a-linked-list) | Medium | -| 1720 | [Decode XORed Array](https://leetcode.com/problems/decode-xored-array "解码异或后的数组") | [Go](problems/decode-xored-array) | Easy | -| 1719 | [Number Of Ways To Reconstruct A Tree](https://leetcode.com/problems/number-of-ways-to-reconstruct-a-tree "重构一棵树的方案数") | [Go](problems/number-of-ways-to-reconstruct-a-tree) | Hard | -| 1718 | [Construct the Lexicographically Largest Valid Sequence](https://leetcode.com/problems/construct-the-lexicographically-largest-valid-sequence "构建字典序最大的可行序列") | [Go](problems/construct-the-lexicographically-largest-valid-sequence) | Medium | -| 1717 | [Maximum Score From Removing Substrings](https://leetcode.com/problems/maximum-score-from-removing-substrings "删除子字符串的最大得分") | [Go](problems/maximum-score-from-removing-substrings) | Medium | -| 1716 | [Calculate Money in Leetcode Bank](https://leetcode.com/problems/calculate-money-in-leetcode-bank "计算力扣银行的钱") | [Go](problems/calculate-money-in-leetcode-bank) | Easy | -| 1715 | [Count Apples and Oranges](https://leetcode.com/problems/count-apples-and-oranges "苹果和橘子的个数") 🔒 | [MySQL](problems/count-apples-and-oranges) | Medium | -| 1714 | [Sum Of Special Evenly-Spaced Elements In Array](https://leetcode.com/problems/sum-of-special-evenly-spaced-elements-in-array "数组中特殊等间距元素的和") 🔒 | [Go](problems/sum-of-special-evenly-spaced-elements-in-array) | Hard | -| 1713 | [Minimum Operations to Make a Subsequence](https://leetcode.com/problems/minimum-operations-to-make-a-subsequence "得到子序列的最少操作次数") | [Go](problems/minimum-operations-to-make-a-subsequence) | Hard | -| 1712 | [Ways to Split Array Into Three Subarrays](https://leetcode.com/problems/ways-to-split-array-into-three-subarrays "将数组分成三个子数组的方案数") | [Go](problems/ways-to-split-array-into-three-subarrays) | Medium | -| 1711 | [Count Good Meals](https://leetcode.com/problems/count-good-meals "大餐计数") | [Go](problems/count-good-meals) | Medium | -| 1710 | [Maximum Units on a Truck](https://leetcode.com/problems/maximum-units-on-a-truck "卡车上的最大单元数") | [Go](problems/maximum-units-on-a-truck) | Easy | -| 1709 | [Biggest Window Between Visits](https://leetcode.com/problems/biggest-window-between-visits "访问日期之间最大的空档期") 🔒 | [MySQL](problems/biggest-window-between-visits) | Medium | -| 1708 | [Largest Subarray Length K](https://leetcode.com/problems/largest-subarray-length-k "长度为 K 的最大子数组") 🔒 | [Go](problems/largest-subarray-length-k) | Easy | -| 1707 | [Maximum XOR With an Element From Array](https://leetcode.com/problems/maximum-xor-with-an-element-from-array "与数组中元素的最大异或值") | [Go](problems/maximum-xor-with-an-element-from-array) | Hard | -| 1706 | [Where Will the Ball Fall](https://leetcode.com/problems/where-will-the-ball-fall "球会落何处") | [Go](problems/where-will-the-ball-fall) | Medium | -| 1705 | [Maximum Number of Eaten Apples](https://leetcode.com/problems/maximum-number-of-eaten-apples "吃苹果的最大数目") | [Go](problems/maximum-number-of-eaten-apples) | Medium | -| 1704 | [Determine if String Halves Are Alike](https://leetcode.com/problems/determine-if-string-halves-are-alike "判断字符串的两半是否相似") | [Go](problems/determine-if-string-halves-are-alike) | Easy | -| 1703 | [Minimum Adjacent Swaps for K Consecutive Ones](https://leetcode.com/problems/minimum-adjacent-swaps-for-k-consecutive-ones "得到连续 K 个 1 的最少相邻交换次数") | [Go](problems/minimum-adjacent-swaps-for-k-consecutive-ones) | Hard | -| 1702 | [Maximum Binary String After Change](https://leetcode.com/problems/maximum-binary-string-after-change "修改后的最大二进制字符串") | [Go](problems/maximum-binary-string-after-change) | Medium | -| 1701 | [Average Waiting Time](https://leetcode.com/problems/average-waiting-time "平均等待时间") | [Go](problems/average-waiting-time) | Medium | -| 1700 | [Number of Students Unable to Eat Lunch](https://leetcode.com/problems/number-of-students-unable-to-eat-lunch "无法吃午餐的学生数量") | [Go](problems/number-of-students-unable-to-eat-lunch) | Easy | -| 1699 | [Number of Calls Between Two Persons](https://leetcode.com/problems/number-of-calls-between-two-persons "两人之间的通话次数") 🔒 | [MySQL](problems/number-of-calls-between-two-persons) | Medium | -| 1698 | [Number of Distinct Substrings in a String](https://leetcode.com/problems/number-of-distinct-substrings-in-a-string "字符串的不同子字符串个数") 🔒 | [Go](problems/number-of-distinct-substrings-in-a-string) | Medium | -| 1697 | [Checking Existence of Edge Length Limited Paths](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths "检查边长度限制的路径是否存在") | [Go](problems/checking-existence-of-edge-length-limited-paths) | Hard | -| 1696 | [Jump Game VI](https://leetcode.com/problems/jump-game-vi "跳跃游戏 VI") | [Go](problems/jump-game-vi) | Medium | -| 1695 | [Maximum Erasure Value](https://leetcode.com/problems/maximum-erasure-value "删除子数组的最大得分") | [Go](problems/maximum-erasure-value) | Medium | -| 1694 | [Reformat Phone Number](https://leetcode.com/problems/reformat-phone-number "重新格式化电话号码") | [Go](problems/reformat-phone-number) | Easy | -| 1693 | [Daily Leads and Partners](https://leetcode.com/problems/daily-leads-and-partners "每天的领导和合伙人") 🔒 | [MySQL](problems/daily-leads-and-partners) | Easy | -| 1692 | [Count Ways to Distribute Candies](https://leetcode.com/problems/count-ways-to-distribute-candies "计算分配糖果的不同方式") 🔒 | [Go](problems/count-ways-to-distribute-candies) | Hard | -| 1691 | [Maximum Height by Stacking Cuboids](https://leetcode.com/problems/maximum-height-by-stacking-cuboids "堆叠长方体的最大高度") | [Go](problems/maximum-height-by-stacking-cuboids) | Hard | -| 1690 | [Stone Game VII](https://leetcode.com/problems/stone-game-vii "石子游戏 VII") | [Go](problems/stone-game-vii) | Medium | -| 1689 | [Partitioning Into Minimum Number Of Deci-Binary Numbers](https://leetcode.com/problems/partitioning-into-minimum-number-of-deci-binary-numbers "十-二进制数的最少数目") | [Go](problems/partitioning-into-minimum-number-of-deci-binary-numbers) | Medium | -| 1688 | [Count of Matches in Tournament](https://leetcode.com/problems/count-of-matches-in-tournament "比赛中的配对次数") | [Go](problems/count-of-matches-in-tournament) | Easy | -| 1687 | [Delivering Boxes from Storage to Ports](https://leetcode.com/problems/delivering-boxes-from-storage-to-ports "从仓库到码头运输箱子") | [Go](problems/delivering-boxes-from-storage-to-ports) | Hard | -| 1686 | [Stone Game VI](https://leetcode.com/problems/stone-game-vi "石子游戏 VI") | [Go](problems/stone-game-vi) | Medium | -| 1685 | [Sum of Absolute Differences in a Sorted Array](https://leetcode.com/problems/sum-of-absolute-differences-in-a-sorted-array "有序数组中差绝对值之和") | [Go](problems/sum-of-absolute-differences-in-a-sorted-array) | Medium | -| 1684 | [Count the Number of Consistent Strings](https://leetcode.com/problems/count-the-number-of-consistent-strings "统计一致字符串的数目") | [Go](problems/count-the-number-of-consistent-strings) | Easy | -| 1683 | [Invalid Tweets](https://leetcode.com/problems/invalid-tweets "无效的推文") 🔒 | [MySQL](problems/invalid-tweets) | Easy | -| 1682 | [Longest Palindromic Subsequence II](https://leetcode.com/problems/longest-palindromic-subsequence-ii "最长回文子序列 II") 🔒 | [Go](problems/longest-palindromic-subsequence-ii) | Medium | -| 1681 | [Minimum Incompatibility](https://leetcode.com/problems/minimum-incompatibility "最小不兼容性") | [Go](problems/minimum-incompatibility) | Hard | -| 1680 | [Concatenation of Consecutive Binary Numbers](https://leetcode.com/problems/concatenation-of-consecutive-binary-numbers "连接连续二进制数字") | [Go](problems/concatenation-of-consecutive-binary-numbers) | Medium | -| 1679 | [Max Number of K-Sum Pairs](https://leetcode.com/problems/max-number-of-k-sum-pairs "K 和数对的最大数目") | [Go](problems/max-number-of-k-sum-pairs) | Medium | -| 1678 | [Goal Parser Interpretation](https://leetcode.com/problems/goal-parser-interpretation "设计 Goal 解析器") | [Go](problems/goal-parser-interpretation) | Easy | -| 1677 | [Product's Worth Over Invoices](https://leetcode.com/problems/products-worth-over-invoices "发票中的产品金额") 🔒 | [MySQL](problems/products-worth-over-invoices) | Easy | -| 1676 | [Lowest Common Ancestor of a Binary Tree IV](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iv "二叉树的最近公共祖先 IV") 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-iv) | Medium | -| 1675 | [Minimize Deviation in Array](https://leetcode.com/problems/minimize-deviation-in-array "数组的最小偏移量") | [Go](problems/minimize-deviation-in-array) | Hard | -| 1674 | [Minimum Moves to Make Array Complementary](https://leetcode.com/problems/minimum-moves-to-make-array-complementary "使数组互补的最少操作次数") | [Go](problems/minimum-moves-to-make-array-complementary) | Medium | -| 1673 | [Find the Most Competitive Subsequence](https://leetcode.com/problems/find-the-most-competitive-subsequence "找出最具竞争力的子序列") | [Go](problems/find-the-most-competitive-subsequence) | Medium | -| 1672 | [Richest Customer Wealth](https://leetcode.com/problems/richest-customer-wealth "最富有客户的资产总量") | [Go](problems/richest-customer-wealth) | Easy | -| 1671 | [Minimum Number of Removals to Make Mountain Array](https://leetcode.com/problems/minimum-number-of-removals-to-make-mountain-array "得到山形数组的最少删除次数") | [Go](problems/minimum-number-of-removals-to-make-mountain-array) | Hard | -| 1670 | [Design Front Middle Back Queue](https://leetcode.com/problems/design-front-middle-back-queue "设计前中后队列") | [Go](problems/design-front-middle-back-queue) | Medium | -| 1669 | [Merge In Between Linked Lists](https://leetcode.com/problems/merge-in-between-linked-lists "合并两个链表") | [Go](problems/merge-in-between-linked-lists) | Medium | -| 1668 | [Maximum Repeating Substring](https://leetcode.com/problems/maximum-repeating-substring "最大重复子字符串") | [Go](problems/maximum-repeating-substring) | Easy | -| 1667 | [Fix Names in a Table](https://leetcode.com/problems/fix-names-in-a-table "修复表中的名字") 🔒 | [MySQL](problems/fix-names-in-a-table) | Easy | -| 1666 | [Change the Root of a Binary Tree](https://leetcode.com/problems/change-the-root-of-a-binary-tree "改变二叉树的根节点") 🔒 | [Go](problems/change-the-root-of-a-binary-tree) | Medium | -| 1665 | [Minimum Initial Energy to Finish Tasks](https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks "完成所有任务的最少初始能量") | [Go](problems/minimum-initial-energy-to-finish-tasks) | Hard | -| 1664 | [Ways to Make a Fair Array](https://leetcode.com/problems/ways-to-make-a-fair-array "生成平衡数组的方案数") | [Go](problems/ways-to-make-a-fair-array) | Medium | -| 1663 | [Smallest String With A Given Numeric Value](https://leetcode.com/problems/smallest-string-with-a-given-numeric-value "具有给定数值的最小字符串") | [Go](problems/smallest-string-with-a-given-numeric-value) | Medium | -| 1662 | [Check If Two String Arrays are Equivalent](https://leetcode.com/problems/check-if-two-string-arrays-are-equivalent "检查两个字符串数组是否相等") | [Go](problems/check-if-two-string-arrays-are-equivalent) | Easy | -| 1661 | [Average Time of Process per Machine](https://leetcode.com/problems/average-time-of-process-per-machine "每台机器的进程平均运行时间") 🔒 | [MySQL](problems/average-time-of-process-per-machine) | Easy | -| 1660 | [Correct a Binary Tree](https://leetcode.com/problems/correct-a-binary-tree "纠正二叉树") 🔒 | [Go](problems/correct-a-binary-tree) | Medium | -| 1659 | [Maximize Grid Happiness](https://leetcode.com/problems/maximize-grid-happiness "最大化网格幸福感") | [Go](problems/maximize-grid-happiness) | Hard | -| 1658 | [Minimum Operations to Reduce X to Zero](https://leetcode.com/problems/minimum-operations-to-reduce-x-to-zero "将 x 减到 0 的最小操作数") | [Go](problems/minimum-operations-to-reduce-x-to-zero) | Medium | -| 1657 | [Determine if Two Strings Are Close](https://leetcode.com/problems/determine-if-two-strings-are-close "确定两个字符串是否接近") | [Go](problems/determine-if-two-strings-are-close) | Medium | -| 1656 | [Design an Ordered Stream](https://leetcode.com/problems/design-an-ordered-stream "设计有序流") | [Go](problems/design-an-ordered-stream) | Easy | -| 1655 | [Distribute Repeating Integers](https://leetcode.com/problems/distribute-repeating-integers "分配重复整数") | [Go](problems/distribute-repeating-integers) | Hard | -| 1654 | [Minimum Jumps to Reach Home](https://leetcode.com/problems/minimum-jumps-to-reach-home "到家的最少跳跃次数") | [Go](problems/minimum-jumps-to-reach-home) | Medium | -| 1653 | [Minimum Deletions to Make String Balanced](https://leetcode.com/problems/minimum-deletions-to-make-string-balanced "使字符串平衡的最少删除次数") | [Go](problems/minimum-deletions-to-make-string-balanced) | Medium | -| 1652 | [Defuse the Bomb](https://leetcode.com/problems/defuse-the-bomb "拆炸弹") | [Go](problems/defuse-the-bomb) | Easy | -| 1651 | [Hopper Company Queries III](https://leetcode.com/problems/hopper-company-queries-iii) 🔒 | [MySQL](problems/hopper-company-queries-iii) | Hard | -| 1650 | [Lowest Common Ancestor of a Binary Tree III](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iii "二叉树的最近公共祖先 III") 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-iii) | Medium | -| 1649 | [Create Sorted Array through Instructions](https://leetcode.com/problems/create-sorted-array-through-instructions "通过指令创建有序数组") | [Go](problems/create-sorted-array-through-instructions) | Hard | -| 1648 | [Sell Diminishing-Valued Colored Balls](https://leetcode.com/problems/sell-diminishing-valued-colored-balls "销售价值减少的颜色球") | [Go](problems/sell-diminishing-valued-colored-balls) | Medium | -| 1647 | [Minimum Deletions to Make Character Frequencies Unique](https://leetcode.com/problems/minimum-deletions-to-make-character-frequencies-unique "字符频次唯一的最小删除次数") | [Go](problems/minimum-deletions-to-make-character-frequencies-unique) | Medium | -| 1646 | [Get Maximum in Generated Array](https://leetcode.com/problems/get-maximum-in-generated-array "获取生成数组中的最大值") | [Go](problems/get-maximum-in-generated-array) | Easy | -| 1645 | [Hopper Company Queries II](https://leetcode.com/problems/hopper-company-queries-ii) 🔒 | [MySQL](problems/hopper-company-queries-ii) | Hard | -| 1644 | [Lowest Common Ancestor of a Binary Tree II](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-ii "二叉树的最近公共祖先 II") 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-ii) | Medium | -| 1643 | [Kth Smallest Instructions](https://leetcode.com/problems/kth-smallest-instructions "第 K 条最小指令") | [Go](problems/kth-smallest-instructions) | Hard | -| 1642 | [Furthest Building You Can Reach](https://leetcode.com/problems/furthest-building-you-can-reach "可以到达的最远建筑") | [Go](problems/furthest-building-you-can-reach) | Medium | -| 1641 | [Count Sorted Vowel Strings](https://leetcode.com/problems/count-sorted-vowel-strings "统计字典序元音字符串的数目") | [Go](problems/count-sorted-vowel-strings) | Medium | -| 1640 | [Check Array Formation Through Concatenation](https://leetcode.com/problems/check-array-formation-through-concatenation "能否连接形成数组") | [Go](problems/check-array-formation-through-concatenation) | Easy | -| 1639 | [Number of Ways to Form a Target String Given a Dictionary](https://leetcode.com/problems/number-of-ways-to-form-a-target-string-given-a-dictionary "通过给定词典构造目标字符串的方案数") | [Go](problems/number-of-ways-to-form-a-target-string-given-a-dictionary) | Hard | -| 1638 | [Count Substrings That Differ by One Character](https://leetcode.com/problems/count-substrings-that-differ-by-one-character "统计只差一个字符的子串数目") | [Go](problems/count-substrings-that-differ-by-one-character) | Medium | -| 1637 | [Widest Vertical Area Between Two Points Containing No Points](https://leetcode.com/problems/widest-vertical-area-between-two-points-containing-no-points "两点之间不包含任何点的最宽垂直面积") | [Go](problems/widest-vertical-area-between-two-points-containing-no-points) | Medium | -| 1636 | [Sort Array by Increasing Frequency](https://leetcode.com/problems/sort-array-by-increasing-frequency "按照频率将数组升序排序") | [Go](problems/sort-array-by-increasing-frequency) | Easy | -| 1635 | [Hopper Company Queries I](https://leetcode.com/problems/hopper-company-queries-i "Hopper 公司查询 I") 🔒 | [MySQL](problems/hopper-company-queries-i) | Hard | -| 1634 | [Add Two Polynomials Represented as Linked Lists](https://leetcode.com/problems/add-two-polynomials-represented-as-linked-lists "求两个多项式链表的和") 🔒 | [Go](problems/add-two-polynomials-represented-as-linked-lists) | Medium | -| 1633 | [Percentage of Users Attended a Contest](https://leetcode.com/problems/percentage-of-users-attended-a-contest "各赛事的用户注册率") 🔒 | [MySQL](problems/percentage-of-users-attended-a-contest) | Easy | -| 1632 | [Rank Transform of a Matrix](https://leetcode.com/problems/rank-transform-of-a-matrix "矩阵转换后的秩") | [Go](problems/rank-transform-of-a-matrix) | Hard | -| 1631 | [Path With Minimum Effort](https://leetcode.com/problems/path-with-minimum-effort "最小体力消耗路径") | [Go](problems/path-with-minimum-effort) | Medium | -| 1630 | [Arithmetic Subarrays](https://leetcode.com/problems/arithmetic-subarrays "等差子数组") | [Go](problems/arithmetic-subarrays) | Medium | -| 1629 | [Slowest Key](https://leetcode.com/problems/slowest-key "按键持续时间最长的键") | [Go](problems/slowest-key) | Easy | -| 1628 | [Design an Expression Tree With Evaluate Function](https://leetcode.com/problems/design-an-expression-tree-with-evaluate-function "设计带解析函数的表达式树") 🔒 | [Go](problems/design-an-expression-tree-with-evaluate-function) | Medium | -| 1627 | [Graph Connectivity With Threshold](https://leetcode.com/problems/graph-connectivity-with-threshold "带阈值的图连通性") | [Go](problems/graph-connectivity-with-threshold) | Hard | -| 1626 | [Best Team With No Conflicts](https://leetcode.com/problems/best-team-with-no-conflicts "无矛盾的最佳球队") | [Go](problems/best-team-with-no-conflicts) | Medium | -| 1625 | [Lexicographically Smallest String After Applying Operations](https://leetcode.com/problems/lexicographically-smallest-string-after-applying-operations "执行操作后字典序最小的字符串") | [Go](problems/lexicographically-smallest-string-after-applying-operations) | Medium | -| 1624 | [Largest Substring Between Two Equal Characters](https://leetcode.com/problems/largest-substring-between-two-equal-characters "两个相同字符之间的最长子字符串") | [Go](problems/largest-substring-between-two-equal-characters) | Easy | -| 1623 | [All Valid Triplets That Can Represent a Country](https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country "三人国家代表队") 🔒 | [MySQL](problems/all-valid-triplets-that-can-represent-a-country) | Easy | -| 1622 | [Fancy Sequence](https://leetcode.com/problems/fancy-sequence "奇妙序列") | [Go](problems/fancy-sequence) | Hard | -| 1621 | [Number of Sets of K Non-Overlapping Line Segments](https://leetcode.com/problems/number-of-sets-of-k-non-overlapping-line-segments "大小为 K 的不重叠线段的数目") | [Go](problems/number-of-sets-of-k-non-overlapping-line-segments) | Medium | -| 1620 | [Coordinate With Maximum Network Quality](https://leetcode.com/problems/coordinate-with-maximum-network-quality "网络信号最好的坐标") | [Go](problems/coordinate-with-maximum-network-quality) | Medium | -| 1619 | [Mean of Array After Removing Some Elements](https://leetcode.com/problems/mean-of-array-after-removing-some-elements "删除某些元素后的数组均值") | [Go](problems/mean-of-array-after-removing-some-elements) | Easy | -| 1618 | [Maximum Font to Fit a Sentence in a Screen](https://leetcode.com/problems/maximum-font-to-fit-a-sentence-in-a-screen "找出适应屏幕的最大字号") 🔒 | [Go](problems/maximum-font-to-fit-a-sentence-in-a-screen) | Medium | -| 1617 | [Count Subtrees With Max Distance Between Cities](https://leetcode.com/problems/count-subtrees-with-max-distance-between-cities "统计子树中城市之间最大距离") | [Go](problems/count-subtrees-with-max-distance-between-cities) | Hard | -| 1616 | [Split Two Strings to Make Palindrome](https://leetcode.com/problems/split-two-strings-to-make-palindrome "分割两个字符串得到回文串") | [Go](problems/split-two-strings-to-make-palindrome) | Medium | -| 1615 | [Maximal Network Rank](https://leetcode.com/problems/maximal-network-rank "最大网络秩") | [Go](problems/maximal-network-rank) | Medium | -| 1614 | [Maximum Nesting Depth of the Parentheses](https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses "括号的最大嵌套深度") | [Go](problems/maximum-nesting-depth-of-the-parentheses) | Easy | -| 1613 | [Find the Missing IDs](https://leetcode.com/problems/find-the-missing-ids "找到遗失的ID") 🔒 | [MySQL](problems/find-the-missing-ids) | Medium | -| 1612 | [Check If Two Expression Trees are Equivalent](https://leetcode.com/problems/check-if-two-expression-trees-are-equivalent "检查两棵二叉表达式树是否等价") 🔒 | [Go](problems/check-if-two-expression-trees-are-equivalent) | Medium | -| 1611 | [Minimum One Bit Operations to Make Integers Zero](https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero "使整数变为 0 的最少操作次数") | [Go](problems/minimum-one-bit-operations-to-make-integers-zero) | Hard | -| 1610 | [Maximum Number of Visible Points](https://leetcode.com/problems/maximum-number-of-visible-points "可见点的最大数目") | [Go](problems/maximum-number-of-visible-points) | Hard | -| 1609 | [Even Odd Tree](https://leetcode.com/problems/even-odd-tree "奇偶树") | [Go](problems/even-odd-tree) | Medium | -| 1608 | [Special Array With X Elements Greater Than or Equal X](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x "特殊数组的特征值") | [Go](problems/special-array-with-x-elements-greater-than-or-equal-x) | Easy | -| 1607 | [Sellers With No Sales](https://leetcode.com/problems/sellers-with-no-sales "没有卖出的卖家") 🔒 | [MySQL](problems/sellers-with-no-sales) | Easy | -| 1606 | [Find Servers That Handled Most Number of Requests](https://leetcode.com/problems/find-servers-that-handled-most-number-of-requests "找到处理最多请求的服务器") | [Go](problems/find-servers-that-handled-most-number-of-requests) | Hard | -| 1605 | [Find Valid Matrix Given Row and Column Sums](https://leetcode.com/problems/find-valid-matrix-given-row-and-column-sums "给定行和列的和求可行矩阵") | [Go](problems/find-valid-matrix-given-row-and-column-sums) | Medium | -| 1604 | [Alert Using Same Key-Card Three or More Times in a One Hour Period](https://leetcode.com/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period "警告一小时内使用相同员工卡大于等于三次的人") | [Go](problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | Medium | -| 1603 | [Design Parking System](https://leetcode.com/problems/design-parking-system "设计停车系统") | [Go](problems/design-parking-system) | Easy | -| 1602 | [Find Nearest Right Node in Binary Tree](https://leetcode.com/problems/find-nearest-right-node-in-binary-tree "找到二叉树中最近的右侧节点") 🔒 | [Go](problems/find-nearest-right-node-in-binary-tree) | Medium | -| 1601 | [Maximum Number of Achievable Transfer Requests](https://leetcode.com/problems/maximum-number-of-achievable-transfer-requests "最多可达成的换楼请求数目") | [Go](problems/maximum-number-of-achievable-transfer-requests) | Hard | -| 1600 | [Throne Inheritance](https://leetcode.com/problems/throne-inheritance "皇位继承顺序") | [Go](problems/throne-inheritance) | Medium | -| 1599 | [Maximum Profit of Operating a Centennial Wheel](https://leetcode.com/problems/maximum-profit-of-operating-a-centennial-wheel "经营摩天轮的最大利润") | [Go](problems/maximum-profit-of-operating-a-centennial-wheel) | Medium | -| 1598 | [Crawler Log Folder](https://leetcode.com/problems/crawler-log-folder "文件夹操作日志搜集器") | [Go](problems/crawler-log-folder) | Easy | -| 1597 | [Build Binary Expression Tree From Infix Expression](https://leetcode.com/problems/build-binary-expression-tree-from-infix-expression "根据中缀表达式构造二叉表达式树") 🔒 | [Go](problems/build-binary-expression-tree-from-infix-expression) | Hard | -| 1596 | [The Most Frequently Ordered Products for Each Customer](https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer "每位顾客最经常订购的商品") 🔒 | [MySQL](problems/the-most-frequently-ordered-products-for-each-customer) | Medium | -| 1595 | [Minimum Cost to Connect Two Groups of Points](https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points "连通两组点的最小成本") | [Go](problems/minimum-cost-to-connect-two-groups-of-points) | Hard | -| 1594 | [Maximum Non Negative Product in a Matrix](https://leetcode.com/problems/maximum-non-negative-product-in-a-matrix "矩阵的最大非负积") | [Go](problems/maximum-non-negative-product-in-a-matrix) | Medium | -| 1593 | [Split a String Into the Max Number of Unique Substrings](https://leetcode.com/problems/split-a-string-into-the-max-number-of-unique-substrings "拆分字符串使唯一子字符串的数目最大") | [Go](problems/split-a-string-into-the-max-number-of-unique-substrings) | Medium | -| 1592 | [Rearrange Spaces Between Words](https://leetcode.com/problems/rearrange-spaces-between-words "重新排列单词间的空格") | [Go](problems/rearrange-spaces-between-words) | Easy | -| 1591 | [Strange Printer II](https://leetcode.com/problems/strange-printer-ii "奇怪的打印机 II") | [Go](problems/strange-printer-ii) | Hard | -| 1590 | [Make Sum Divisible by P](https://leetcode.com/problems/make-sum-divisible-by-p "使数组和能被 P 整除") | [Go](problems/make-sum-divisible-by-p) | Medium | -| 1589 | [Maximum Sum Obtained of Any Permutation](https://leetcode.com/problems/maximum-sum-obtained-of-any-permutation "所有排列中的最大和") | [Go](problems/maximum-sum-obtained-of-any-permutation) | Medium | -| 1588 | [Sum of All Odd Length Subarrays](https://leetcode.com/problems/sum-of-all-odd-length-subarrays "所有奇数长度子数组的和") | [Go](problems/sum-of-all-odd-length-subarrays) | Easy | -| 1587 | [Bank Account Summary II](https://leetcode.com/problems/bank-account-summary-ii "银行账户概要 II") 🔒 | [MySQL](problems/bank-account-summary-ii) | Easy | -| 1586 | [Binary Search Tree Iterator II](https://leetcode.com/problems/binary-search-tree-iterator-ii "二叉搜索树迭代器 II") 🔒 | [Go](problems/binary-search-tree-iterator-ii) | Medium | -| 1585 | [Check If String Is Transformable With Substring Sort Operations](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations "检查字符串是否可以通过排序子字符串得到另一个字符串") | [Go](problems/check-if-string-is-transformable-with-substring-sort-operations) | Hard | -| 1584 | [Min Cost to Connect All Points](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") | [Go](problems/min-cost-to-connect-all-points) | Medium | -| 1583 | [Count Unhappy Friends](https://leetcode.com/problems/count-unhappy-friends "统计不开心的朋友") | [Go](problems/count-unhappy-friends) | Medium | -| 1582 | [Special Positions in a Binary Matrix](https://leetcode.com/problems/special-positions-in-a-binary-matrix "二进制矩阵中的特殊位置") | [Go](problems/special-positions-in-a-binary-matrix) | Easy | -| 1581 | [Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的顾客") 🔒 | [MySQL](problems/customer-who-visited-but-did-not-make-any-transactions) | Easy | -| 1580 | [Put Boxes Into the Warehouse II](https://leetcode.com/problems/put-boxes-into-the-warehouse-ii "把箱子放进仓库里 II") 🔒 | [Go](problems/put-boxes-into-the-warehouse-ii) | Medium | -| 1579 | [Remove Max Number of Edges to Keep Graph Fully Traversable](https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable "保证图可完全遍历") | [Go](problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | Hard | -| 1578 | [Minimum Deletion Cost to Avoid Repeating Letters](https://leetcode.com/problems/minimum-deletion-cost-to-avoid-repeating-letters "避免重复字母的最小删除成本") | [Go](problems/minimum-deletion-cost-to-avoid-repeating-letters) | Medium | -| 1577 | [Number of Ways Where Square of Number Is Equal to Product of Two Numbers](https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "数的平方等于两数乘积的方法数") | [Go](problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | Medium | -| 1576 | [Replace All ?'s to Avoid Consecutive Repeating Characters](https://leetcode.com/problems/replace-all-s-to-avoid-consecutive-repeating-characters "替换所有的问号") | [Go](problems/replace-all-s-to-avoid-consecutive-repeating-characters) | Easy | -| 1575 | [Count All Possible Routes](https://leetcode.com/problems/count-all-possible-routes "统计所有可行路径") | [Go](problems/count-all-possible-routes) | Hard | -| 1574 | [Shortest Subarray to be Removed to Make Array Sorted](https://leetcode.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted "删除最短的子数组使剩余数组有序") | [Go](problems/shortest-subarray-to-be-removed-to-make-array-sorted) | Medium | -| 1573 | [Number of Ways to Split a String](https://leetcode.com/problems/number-of-ways-to-split-a-string "分割字符串的方案数") | [Go](problems/number-of-ways-to-split-a-string) | Medium | -| 1572 | [Matrix Diagonal Sum](https://leetcode.com/problems/matrix-diagonal-sum "矩阵对角线元素的和") | [Go](problems/matrix-diagonal-sum) | Easy | -| 1571 | [Warehouse Manager](https://leetcode.com/problems/warehouse-manager "仓库经理") 🔒 | [MySQL](problems/warehouse-manager) | Easy | -| 1570 | [Dot Product of Two Sparse Vectors](https://leetcode.com/problems/dot-product-of-two-sparse-vectors "两个稀疏向量的点积") 🔒 | [Go](problems/dot-product-of-two-sparse-vectors) | Medium | -| 1569 | [Number of Ways to Reorder Array to Get Same BST](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst "将子数组重新排序得到同一个二叉查找树的方案数") | [Go](problems/number-of-ways-to-reorder-array-to-get-same-bst) | Hard | -| 1568 | [Minimum Number of Days to Disconnect Island](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数") | [Go](problems/minimum-number-of-days-to-disconnect-island) | Hard | -| 1567 | [Maximum Length of Subarray With Positive Product](https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product "乘积为正数的最长子数组长度") | [Go](problems/maximum-length-of-subarray-with-positive-product) | Medium | -| 1566 | [Detect Pattern of Length M Repeated K or More Times](https://leetcode.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times "重复至少 K 次且长度为 M 的模式") | [Go](problems/detect-pattern-of-length-m-repeated-k-or-more-times) | Easy | -| 1565 | [Unique Orders and Customers Per Month](https://leetcode.com/problems/unique-orders-and-customers-per-month "按月统计订单数与顾客数") 🔒 | [MySQL](problems/unique-orders-and-customers-per-month) | Easy | -| 1564 | [Put Boxes Into the Warehouse I](https://leetcode.com/problems/put-boxes-into-the-warehouse-i "把箱子放进仓库里 I") 🔒 | [Go](problems/put-boxes-into-the-warehouse-i) | Medium | -| 1563 | [Stone Game V](https://leetcode.com/problems/stone-game-v "石子游戏 V") | [Go](problems/stone-game-v) | Hard | -| 1562 | [Find Latest Group of Size M](https://leetcode.com/problems/find-latest-group-of-size-m "查找大小为 M 的最新分组") | [Go](problems/find-latest-group-of-size-m) | Medium | -| 1561 | [Maximum Number of Coins You Can Get](https://leetcode.com/problems/maximum-number-of-coins-you-can-get "你可以获得的最大硬币数目") | [Go](problems/maximum-number-of-coins-you-can-get) | Medium | -| 1560 | [Most Visited Sector in a Circular Track](https://leetcode.com/problems/most-visited-sector-in-a-circular-track "圆形赛道上经过次数最多的扇区") | [Go](problems/most-visited-sector-in-a-circular-track) | Easy | -| 1559 | [Detect Cycles in 2D Grid](https://leetcode.com/problems/detect-cycles-in-2d-grid "二维网格图中探测环") | [Go](problems/detect-cycles-in-2d-grid) | Medium | -| 1558 | [Minimum Numbers of Function Calls to Make Target Array](https://leetcode.com/problems/minimum-numbers-of-function-calls-to-make-target-array "得到目标数组的最少函数调用次数") | [Go](problems/minimum-numbers-of-function-calls-to-make-target-array) | Medium | -| 1557 | [Minimum Number of Vertices to Reach All Nodes](https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes "可以到达所有点的最少点数目") | [Go](problems/minimum-number-of-vertices-to-reach-all-nodes) | Medium | -| 1556 | [Thousand Separator](https://leetcode.com/problems/thousand-separator "千位分隔数") | [Go](problems/thousand-separator) | Easy | -| 1555 | [Bank Account Summary](https://leetcode.com/problems/bank-account-summary "银行账户概要") 🔒 | [MySQL](problems/bank-account-summary) | Medium | -| 1554 | [Strings Differ by One Character](https://leetcode.com/problems/strings-differ-by-one-character "只有一个不同字符的字符串") 🔒 | [Go](problems/strings-differ-by-one-character) | Medium | -| 1553 | [Minimum Number of Days to Eat N Oranges](https://leetcode.com/problems/minimum-number-of-days-to-eat-n-oranges "吃掉 N 个橘子的最少天数") | [Go](problems/minimum-number-of-days-to-eat-n-oranges) | Hard | -| 1552 | [Magnetic Force Between Two Balls](https://leetcode.com/problems/magnetic-force-between-two-balls "两球之间的磁力") | [Go](problems/magnetic-force-between-two-balls) | Medium | -| 1551 | [Minimum Operations to Make Array Equal](https://leetcode.com/problems/minimum-operations-to-make-array-equal "使数组中所有元素相等的最小操作数") | [Go](problems/minimum-operations-to-make-array-equal) | Medium | -| 1550 | [Three Consecutive Odds](https://leetcode.com/problems/three-consecutive-odds "存在连续三个奇数的数组") | [Go](problems/three-consecutive-odds) | Easy | -| 1549 | [The Most Recent Orders for Each Product](https://leetcode.com/problems/the-most-recent-orders-for-each-product "每件商品的最新订单") 🔒 | [MySQL](problems/the-most-recent-orders-for-each-product) | Medium | -| 1548 | [The Most Similar Path in a Graph](https://leetcode.com/problems/the-most-similar-path-in-a-graph "图中最相似的路径") 🔒 | [Go](problems/the-most-similar-path-in-a-graph) | Hard | -| 1547 | [Minimum Cost to Cut a Stick](https://leetcode.com/problems/minimum-cost-to-cut-a-stick "切棍子的最小成本") | [Go](problems/minimum-cost-to-cut-a-stick) | Hard | -| 1546 | [Maximum Number of Non-Overlapping Subarrays With Sum Equals Target](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值且不重叠的非空子数组的最大数目") | [Go](problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | Medium | -| 1545 | [Find Kth Bit in Nth Binary String](https://leetcode.com/problems/find-kth-bit-in-nth-binary-string "找出第 N 个二进制字符串中的第 K 位") | [Go](problems/find-kth-bit-in-nth-binary-string) | Medium | -| 1544 | [Make The String Great](https://leetcode.com/problems/make-the-string-great "整理字符串") | [Go](problems/make-the-string-great) | Easy | -| 1543 | [Fix Product Name Format](https://leetcode.com/problems/fix-product-name-format "产品名称格式修复") 🔒 | [MySQL](problems/fix-product-name-format) | Easy | -| 1542 | [Find Longest Awesome Substring](https://leetcode.com/problems/find-longest-awesome-substring "找出最长的超赞子字符串") | [Go](problems/find-longest-awesome-substring) | Hard | -| 1541 | [Minimum Insertions to Balance a Parentheses String](https://leetcode.com/problems/minimum-insertions-to-balance-a-parentheses-string "平衡括号字符串的最少插入次数") | [Go](problems/minimum-insertions-to-balance-a-parentheses-string) | Medium | -| 1540 | [Can Convert String in K Moves](https://leetcode.com/problems/can-convert-string-in-k-moves "K 次操作转变字符串") | [Go](problems/can-convert-string-in-k-moves) | Medium | -| 1539 | [Kth Missing Positive Number](https://leetcode.com/problems/kth-missing-positive-number "第 k 个缺失的正整数") | [Go](problems/kth-missing-positive-number) | Easy | -| 1538 | [Guess the Majority in a Hidden Array](https://leetcode.com/problems/guess-the-majority-in-a-hidden-array "找出隐藏数组中出现次数最多的元素") 🔒 | [Go](problems/guess-the-majority-in-a-hidden-array) | Medium | -| 1537 | [Get the Maximum Score](https://leetcode.com/problems/get-the-maximum-score "最大得分") | [Go](problems/get-the-maximum-score) | Hard | -| 1536 | [Minimum Swaps to Arrange a Binary Grid](https://leetcode.com/problems/minimum-swaps-to-arrange-a-binary-grid "排布二进制网格的最少交换次数") | [Go](problems/minimum-swaps-to-arrange-a-binary-grid) | Medium | -| 1535 | [Find the Winner of an Array Game](https://leetcode.com/problems/find-the-winner-of-an-array-game "找出数组游戏的赢家") | [Go](problems/find-the-winner-of-an-array-game) | Medium | -| 1534 | [Count Good Triplets](https://leetcode.com/problems/count-good-triplets "统计好三元组") | [Go](problems/count-good-triplets) | Easy | -| 1533 | [Find the Index of the Large Integer](https://leetcode.com/problems/find-the-index-of-the-large-integer "找到最大整数的索引") 🔒 | [Go](problems/find-the-index-of-the-large-integer) | Medium | -| 1532 | [The Most Recent Three Orders](https://leetcode.com/problems/the-most-recent-three-orders "最近的三笔订单") 🔒 | [MySQL](problems/the-most-recent-three-orders) | Medium | -| 1531 | [String Compression II](https://leetcode.com/problems/string-compression-ii "压缩字符串 II") | [Go](problems/string-compression-ii) | Hard | -| 1530 | [Number of Good Leaf Nodes Pairs](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs "好叶子节点对的数量") | [Go](problems/number-of-good-leaf-nodes-pairs) | Medium | -| 1529 | [Bulb Switcher IV](https://leetcode.com/problems/bulb-switcher-iv "灯泡开关 IV") | [Go](problems/bulb-switcher-iv) | Medium | -| 1528 | [Shuffle String](https://leetcode.com/problems/shuffle-string "重新排列字符串") | [Go](problems/shuffle-string) | Easy | -| 1527 | [Patients With a Condition](https://leetcode.com/problems/patients-with-a-condition "患某种疾病的患者") 🔒 | [MySQL](problems/patients-with-a-condition) | Easy | -| 1526 | [Minimum Number of Increments on Subarrays to Form a Target Array](https://leetcode.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array "形成目标数组的子数组最少增加次数") | [Go](problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | Hard | -| 1525 | [Number of Good Ways to Split a String](https://leetcode.com/problems/number-of-good-ways-to-split-a-string "字符串的好分割数目") | [Go](problems/number-of-good-ways-to-split-a-string) | Medium | -| 1524 | [Number of Sub-arrays With Odd Sum](https://leetcode.com/problems/number-of-sub-arrays-with-odd-sum "和为奇数的子数组数目") | [Go](problems/number-of-sub-arrays-with-odd-sum) | Medium | -| 1523 | [Count Odd Numbers in an Interval Range](https://leetcode.com/problems/count-odd-numbers-in-an-interval-range "在区间范围内统计奇数数目") | [Go](problems/count-odd-numbers-in-an-interval-range) | Easy | -| 1522 | [Diameter of N-Ary Tree](https://leetcode.com/problems/diameter-of-n-ary-tree "N 叉树的直径") 🔒 | [Go](problems/diameter-of-n-ary-tree) | Medium | -| 1521 | [Find a Value of a Mysterious Function Closest to Target](https://leetcode.com/problems/find-a-value-of-a-mysterious-function-closest-to-target "找到最接近目标值的函数值") | [Go](problems/find-a-value-of-a-mysterious-function-closest-to-target) | Hard | -| 1520 | [Maximum Number of Non-Overlapping Substrings](https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings "最多的不重叠子字符串") | [Go](problems/maximum-number-of-non-overlapping-substrings) | Hard | -| 1519 | [Number of Nodes in the Sub-Tree With the Same Label](https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label "子树中标签相同的节点数") | [Go](problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | Medium | -| 1518 | [Water Bottles](https://leetcode.com/problems/water-bottles "换酒问题") | [Go](problems/water-bottles) | Easy | -| 1517 | [Find Users With Valid E-Mails](https://leetcode.com/problems/find-users-with-valid-e-mails "查找拥有有效邮箱的用户") 🔒 | [MySQL](problems/find-users-with-valid-e-mails) | Easy | -| 1516 | [Move Sub-Tree of N-Ary Tree](https://leetcode.com/problems/move-sub-tree-of-n-ary-tree "移动 N 叉树的子树") 🔒 | [Go](problems/move-sub-tree-of-n-ary-tree) | Hard | -| 1515 | [Best Position for a Service Centre](https://leetcode.com/problems/best-position-for-a-service-centre "服务中心的最佳位置") | [Go](problems/best-position-for-a-service-centre) | Hard | -| 1514 | [Path with Maximum Probability](https://leetcode.com/problems/path-with-maximum-probability "概率最大的路径") | [Go](problems/path-with-maximum-probability) | Medium | -| 1513 | [Number of Substrings With Only 1s](https://leetcode.com/problems/number-of-substrings-with-only-1s "仅含 1 的子串数") | [Go](problems/number-of-substrings-with-only-1s) | Medium | -| 1512 | [Number of Good Pairs](https://leetcode.com/problems/number-of-good-pairs "好数对的数目") | [Go](problems/number-of-good-pairs) | Easy | -| 1511 | [Customer Order Frequency](https://leetcode.com/problems/customer-order-frequency "消费者下单频率") 🔒 | [MySQL](problems/customer-order-frequency) | Easy | -| 1510 | [Stone Game IV](https://leetcode.com/problems/stone-game-iv "石子游戏 IV") | [Go](problems/stone-game-iv) | Hard | -| 1509 | [Minimum Difference Between Largest and Smallest Value in Three Moves](https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves "三次操作后最大值与最小值的最小差") | [Go](problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | Medium | -| 1508 | [Range Sum of Sorted Subarray Sums](https://leetcode.com/problems/range-sum-of-sorted-subarray-sums "子数组和排序后的区间和") | [Go](problems/range-sum-of-sorted-subarray-sums) | Medium | -| 1507 | [Reformat Date](https://leetcode.com/problems/reformat-date "转变日期格式") | [Go](problems/reformat-date) | Easy | -| 1506 | [Find Root of N-Ary Tree](https://leetcode.com/problems/find-root-of-n-ary-tree "找到 N 叉树的根节点") 🔒 | [Go](problems/find-root-of-n-ary-tree) | Medium | -| 1505 | [Minimum Possible Integer After at Most K Adjacent Swaps On Digits](https://leetcode.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "最多 K 次交换相邻数位后得到的最小整数") | [Go](problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | Hard | -| 1504 | [Count Submatrices With All Ones](https://leetcode.com/problems/count-submatrices-with-all-ones "统计全 1 子矩形") | [Go](problems/count-submatrices-with-all-ones) | Medium | -| 1503 | [Last Moment Before All Ants Fall Out of a Plank](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank "所有蚂蚁掉下来前的最后一刻") | [Go](problems/last-moment-before-all-ants-fall-out-of-a-plank) | Medium | -| 1502 | [Can Make Arithmetic Progression From Sequence](https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence "判断能否形成等差数列") | [Go](problems/can-make-arithmetic-progression-from-sequence) | Easy | -| 1501 | [Countries You Can Safely Invest In](https://leetcode.com/problems/countries-you-can-safely-invest-in "可以放心投资的国家") 🔒 | [MySQL](problems/countries-you-can-safely-invest-in) | Medium | diff --git a/problems/01-matrix/README.md b/problems/01-matrix/README.md index 35b6ca3e1..47aff04e7 100644 --- a/problems/01-matrix/README.md +++ b/problems/01-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-string-ii "Reverse String II") diff --git a/problems/a-number-after-a-double-reversal/README.md b/problems/a-number-after-a-double-reversal/README.md new file mode 100644 index 000000000..4fffcb4b3 --- /dev/null +++ b/problems/a-number-after-a-double-reversal/README.md @@ -0,0 +1,61 @@ + + + + + + + +[< Previous](../build-the-equation "Build the Equation") +                 +[Next >](../execution-of-all-suffix-instructions-staying-in-a-grid "Execution of All Suffix Instructions Staying in a Grid") + +## [2119. A Number After a Double Reversal (Easy)](https://leetcode.com/problems/a-number-after-a-double-reversal "反转两次的数字") + +

    Reversing an integer means to reverse all its digits.

    + +
      +
    • For example, reversing 2021 gives 1202. Reversing 12300 gives 321 as the leading zeros are not retained.
    • +
    + +

    Given an integer num, reverse num to get reversed1, then reverse reversed1 to get reversed2. Return true if reversed2 equals num. Otherwise return false.

    + +

     

    +

    Example 1:

    + +
    +Input: num = 526
    +Output: true
    +Explanation: Reverse num to get 625, then reverse 625 to get 526, which equals num.
    +
    + +

    Example 2:

    + +
    +Input: num = 1800
    +Output: false
    +Explanation: Reverse num to get 81, then reverse 81 to get 18, which does not equal num.
    +
    + +

    Example 3:

    + +
    +Input: num = 0
    +Output: true
    +Explanation: Reverse num to get 0, then reverse 0 to get 0, which equals num.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= num <= 106
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Other than the number 0 itself, any number that ends with 0 would lose some digits permanently when reversed. +
    diff --git a/problems/abbreviating-the-product-of-a-range/README.md b/problems/abbreviating-the-product-of-a-range/README.md new file mode 100644 index 000000000..3ee8a1c74 --- /dev/null +++ b/problems/abbreviating-the-product-of-a-range/README.md @@ -0,0 +1,103 @@ + + + + + + + +[< Previous](../check-if-a-parentheses-string-can-be-valid "Check if a Parentheses String Can Be Valid") +                 +[Next >](../build-the-equation "Build the Equation") + +## [2117. Abbreviating the Product of a Range (Hard)](https://leetcode.com/problems/abbreviating-the-product-of-a-range "一个区间内所有数乘积的缩写") + +

    You are given two positive integers left and right with left <= right. Calculate the product of all integers in the inclusive range [left, right].

    + +

    Since the product may be very large, you will abbreviate it following these steps:

    + +
      +
    1. Count all trailing zeros in the product and remove them. Let us denote this count as C. +
        +
      • For example, there are 3 trailing zeros in 1000, and there are 0 trailing zeros in 546.
      • +
      +
    2. +
    3. Denote the remaining number of digits in the product as d. If d > 10, then express the product as <pre>...<suf> where <pre> denotes the first 5 digits of the product, and <suf> denotes the last 5 digits of the product after removing all trailing zeros. If d <= 10, we keep it unchanged. +
        +
      • For example, we express 1234567654321 as 12345...54321, but 1234567 is represented as 1234567.
      • +
      +
    4. +
    5. Finally, represent the product as a string "<pre>...<suf>eC". +
        +
      • For example, 12345678987600000 will be represented as "12345...89876e5".
      • +
      +
    6. +
    + +

    Return a string denoting the abbreviated product of all integers in the inclusive range [left, right].

    + +

     

    +

    Example 1:

    + +
    +Input: left = 1, right = 4
    +Output: "24e0"
    +Explanation: The product is 1 × 2 × 3 × 4 = 24.
    +There are no trailing zeros, so 24 remains the same. The abbreviation will end with "e0".
    +Since the number of digits is 2, which is less than 10, we do not have to abbreviate it further.
    +Thus, the final representation is "24e0".
    +
    + +

    Example 2:

    + +
    +Input: left = 2, right = 11
    +Output: "399168e2"
    +Explanation: The product is 39916800.
    +There are 2 trailing zeros, which we remove to get 399168. The abbreviation will end with "e2".
    +The number of digits after removing the trailing zeros is 6, so we do not abbreviate it further.
    +Hence, the abbreviated product is "399168e2".
    +
    + +

    Example 3:

    + +
    +Input: left = 371, right = 375
    +Output: "7219856259e3"
    +Explanation: The product is 7219856259000.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= left <= right <= 104
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Calculating the number of trailing zeros, the last five digits, and the first five digits can all be done separately. +
    + +
    +Hint 2 +Use a prime factorization property to find the number of trailing zeros. Use modulo to find the last 5 digits. Use a logarithm property to find the first 5 digits. +
    + +
    +Hint 3 +The number of trailing zeros C is nothing but the number of times the product is completely divisible by 10. Since 2 and 5 are the only prime factors of 10, C will be equal to the minimum number of times 2 or 5 appear in the prime factorization of the product. +
    + +
    +Hint 4 +Iterate through the integers from left to right. For every integer, keep dividing it by 2 as long as it is divisible by 2 and C occurrences of 2 haven't been removed in total. Repeat this process for 5. Finally, multiply the integer under modulo of 10^5 with the product obtained till now to obtain the last five digits. +
    + +
    +Hint 5 +The product P can be represented as P=10^(x+y) where x is the integral part and y is the fractional part of x+y. Using the property "if S = A * B, then log(S) = log(A) + log(B)", we can write x+y = log_10(P) = sum(log_10(i)) for each integer i in [left, right]. Once we obtain the sum, the first five digits can be represented as floor(10^(y+4)). +
    diff --git a/problems/accepted-candidates-from-the-interviews/README.md b/problems/accepted-candidates-from-the-interviews/README.md index 19d0072c0..b6aa925d5 100644 --- a/problems/accepted-candidates-from-the-interviews/README.md +++ b/problems/accepted-candidates-from-the-interviews/README.md @@ -9,7 +9,7 @@                  [Next >](../check-if-numbers-are-ascending-in-a-sentence "Check if Numbers Are Ascending in a Sentence") -## [2041. Accepted Candidates From the Interviews (Medium)](https://leetcode.com/problems/accepted-candidates-from-the-interviews "") +## [2041. Accepted Candidates From the Interviews (Medium)](https://leetcode.com/problems/accepted-candidates-from-the-interviews "面试中被录取的候选人") diff --git a/problems/account-balance/README.md b/problems/account-balance/README.md index ce0895597..a5dbfabc3 100644 --- a/problems/account-balance/README.md +++ b/problems/account-balance/README.md @@ -9,7 +9,7 @@                  [Next >](../number-of-equal-count-substrings "Number of Equal Count Substrings") -## [2066. Account Balance (Medium)](https://leetcode.com/problems/account-balance "") +## [2066. Account Balance (Medium)](https://leetcode.com/problems/account-balance "账户余额") diff --git a/problems/active-users/README.md b/problems/active-users/README.md index ba0038306..ef8762c21 100644 --- a/problems/active-users/README.md +++ b/problems/active-users/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-darts-inside-of-a-circular-dartboard "Maximum Number of Darts Inside of a Circular Dartboard") diff --git a/problems/add-minimum-number-of-rungs/README.md b/problems/add-minimum-number-of-rungs/README.md index a1e778ff4..75ced1a88 100644 --- a/problems/add-minimum-number-of-rungs/README.md +++ b/problems/add-minimum-number-of-rungs/README.md @@ -49,15 +49,6 @@ Add a rung at height 1 to climb this ladder. The ladder will now have rungs at [1,3,4,6,7]. -

    Example 4:

    - -
    -Input: rungs = [5], dist = 10
    -Output: 0
    -Explanation:
    -This ladder can be climbed without adding additional rungs.
    -
    -

     

    Constraints:

    @@ -68,6 +59,10 @@ This ladder can be climbed without adding additional rungs.
  • rungs is strictly increasing.
  • +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + ### Hints
    Hint 1 diff --git a/problems/add-two-numbers/README.md b/problems/add-two-numbers/README.md index 5d07d51cf..4b8b6c228 100644 --- a/problems/add-two-numbers/README.md +++ b/problems/add-two-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-sum "Two Sum") diff --git a/problems/adding-spaces-to-a-string/README.md b/problems/adding-spaces-to-a-string/README.md new file mode 100644 index 000000000..2239ba4fd --- /dev/null +++ b/problems/adding-spaces-to-a-string/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../find-first-palindromic-string-in-the-array "Find First Palindromic String in the Array") +                 +[Next >](../number-of-smooth-descent-periods-of-a-stock "Number of Smooth Descent Periods of a Stock") + +## [2109. Adding Spaces to a String (Medium)](https://leetcode.com/problems/adding-spaces-to-a-string "向字符串添加空格") + +

    You are given a 0-indexed string s and a 0-indexed integer array spaces that describes the indices in the original string where spaces will be added. Each space should be inserted before the character at the given index.

    + +
      +
    • For example, given s = "EnjoyYourCoffee" and spaces = [5, 9], we place spaces before 'Y' and 'C', which are at indices 5 and 9 respectively. Thus, we obtain "Enjoy Your Coffee".
    • +
    + +

    Return the modified string after the spaces have been added.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "LeetcodeHelpsMeLearn", spaces = [8,13,15]
    +Output: "Leetcode Helps Me Learn"
    +Explanation: 
    +The indices 8, 13, and 15 correspond to the underlined characters in "LeetcodeHelpsMeLearn".
    +We then place spaces before those characters.
    +
    + +

    Example 2:

    + +
    +Input: s = "icodeinpython", spaces = [1,5,7,9]
    +Output: "i code in py thon"
    +Explanation:
    +The indices 1, 5, 7, and 9 correspond to the underlined characters in "icodeinpython".
    +We then place spaces before those characters.
    +
    + +

    Example 3:

    + +
    +Input: s = "spacing", spaces = [0,1,2,3,4,5,6]
    +Output: " s p a c i n g"
    +Explanation:
    +We are also able to place spaces before the first character of the string.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 3 * 105
    • +
    • s consists only of lowercase and uppercase English letters.
    • +
    • 1 <= spaces.length <= 3 * 105
    • +
    • 0 <= spaces[i] <= s.length - 1
    • +
    • All the values of spaces are strictly increasing.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Create a new string, initially empty, as the modified string. Iterate through the original string and append each character of the original string to the new string. However, each time you reach a character that requires a space before it, append a space before appending the character. +
    + +
    +Hint 2 +Since the array of indices for the space locations is sorted, use a pointer to keep track of the next index to place a space. Only increment the pointer once a space has been appended. +
    + +
    +Hint 3 +Ensure that your append operation can be done in O(1). +
    diff --git a/problems/ads-performance/README.md b/problems/ads-performance/README.md index 021d8c49e..6ab077012 100644 --- a/problems/ads-performance/README.md +++ b/problems/ads-performance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../restaurant-growth "Restaurant Growth") diff --git a/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md b/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md index e57869f6d..a91e1b097 100644 --- a/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md +++ b/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md @@ -38,27 +38,13 @@ Explanation: "bob" used the keycard 3 times in a one-hour period ("21:00","21:20", "21:30"). -

    Example 3:

    - -
    -Input: keyName = ["john","john","john"], keyTime = ["23:58","23:59","00:01"]
    -Output: []
    -
    - -

    Example 4:

    - -
    -Input: keyName = ["leslie","leslie","leslie","clare","clare","clare","clare"], keyTime = ["13:00","13:20","14:00","18:00","18:51","19:30","19:49"]
    -Output: ["clare","leslie"]
    -
    -

     

    Constraints:

    • 1 <= keyName.length, keyTime.length <= 105
    • keyName.length == keyTime.length
    • -
    • keyTime[i] is in the format "HH:MM".
    • +
    • keyTime[i] is in the format "HH:MM".
    • [keyName[i], keyTime[i]] is unique.
    • 1 <= keyName[i].length <= 10
    • keyName[i] contains only lowercase English letters.
    • diff --git a/problems/all-divisions-with-the-highest-score-of-a-binary-array/README.md b/problems/all-divisions-with-the-highest-score-of-a-binary-array/README.md new file mode 100644 index 000000000..3e8ea2eca --- /dev/null +++ b/problems/all-divisions-with-the-highest-score-of-a-binary-array/README.md @@ -0,0 +1,92 @@ + + + + + + + +[< Previous](../keep-multiplying-found-values-by-two "Keep Multiplying Found Values by Two") +                 +[Next >](../find-substring-with-given-hash-value "Find Substring With Given Hash Value") + +## [2155. All Divisions With the Highest Score of a Binary Array (Medium)](https://leetcode.com/problems/all-divisions-with-the-highest-score-of-a-binary-array "分组得分最高的所有下标") + +

      You are given a 0-indexed binary array nums of length n. nums can be divided at index i (where 0 <= i <= n) into two arrays (possibly empty) numsleft and numsright:

      + +
        +
      • numsleft has all the elements of nums between index 0 and i - 1 (inclusive), while numsright has all the elements of nums between index i and n - 1 (inclusive).
      • +
      • If i == 0, numsleft is empty, while numsright has all the elements of nums.
      • +
      • If i == n, numsleft has all the elements of nums, while numsright is empty.
      • +
      + +

      The division score of an index i is the sum of the number of 0's in numsleft and the number of 1's in numsright.

      + +

      Return all distinct indices that have the highest possible division score. You may return the answer in any order.

      + +

       

      +

      Example 1:

      + +
      +Input: nums = [0,0,1,0]
      +Output: [2,4]
      +Explanation: Division at index
      +- 0: numsleft is []. numsright is [0,0,1,0]. The score is 0 + 1 = 1.
      +- 1: numsleft is [0]. numsright is [0,1,0]. The score is 1 + 1 = 2.
      +- 2: numsleft is [0,0]. numsright is [1,0]. The score is 2 + 1 = 3.
      +- 3: numsleft is [0,0,1]. numsright is [0]. The score is 2 + 0 = 2.
      +- 4: numsleft is [0,0,1,0]. numsright is []. The score is 3 + 0 = 3.
      +Indices 2 and 4 both have the highest possible division score 3.
      +Note the answer [4,2] would also be accepted.
      + +

      Example 2:

      + +
      +Input: nums = [0,0,0]
      +Output: [3]
      +Explanation: Division at index
      +- 0: numsleft is []. numsright is [0,0,0]. The score is 0 + 0 = 0.
      +- 1: numsleft is [0]. numsright is [0,0]. The score is 1 + 0 = 1.
      +- 2: numsleft is [0,0]. numsright is [0]. The score is 2 + 0 = 2.
      +- 3: numsleft is [0,0,0]. numsright is []. The score is 3 + 0 = 3.
      +Only index 3 has the highest possible division score 3.
      +
      + +

      Example 3:

      + +
      +Input: nums = [1,1]
      +Output: [0]
      +Explanation: Division at index
      +- 0: numsleft is []. numsright is [1,1]. The score is 0 + 2 = 2.
      +- 1: numsleft is [1]. numsright is [1]. The score is 0 + 1 = 1.
      +- 2: numsleft is [1,1]. numsright is []. The score is 0 + 0 = 0.
      +Only index 0 has the highest possible division score 2.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • n == nums.length
      • +
      • 1 <= n <= 105
      • +
      • nums[i] is either 0 or 1.
      • +
      + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
      +Hint 1 +When you iterate the array, maintain the number of zeros and ones on the left side. Can you quickly calculate the number of ones on the right side? +
      + +
      +Hint 2 +The number of ones on the right side equals the number of ones in the whole array minus the number of ones on the left side. +
      + +
      +Hint 3 +Alternatively, you can quickly calculate it by using a prefix sum array. +
      diff --git a/problems/all-elements-in-two-binary-search-trees/README.md b/problems/all-elements-in-two-binary-search-trees/README.md index 3489830b3..add402354 100644 --- a/problems/all-elements-in-two-binary-search-trees/README.md +++ b/problems/all-elements-in-two-binary-search-trees/README.md @@ -11,9 +11,7 @@ ## [1305. All Elements in Two Binary Search Trees (Medium)](https://leetcode.com/problems/all-elements-in-two-binary-search-trees "两棵二叉搜索树中的所有元素") -

      Given two binary search trees root1 and root2.

      - -

      Return a list containing all the integers from both trees sorted in ascending order.

      +

      Given two binary search trees root1 and root2, return a list containing all the integers from both trees sorted in ascending order.

       

      Example 1:

      @@ -24,27 +22,6 @@

      Example 2:

      - -
      -Input: root1 = [0,-10,10], root2 = [5,1,7,0,2]
      -Output: [-10,0,0,1,2,5,7,10]
      -
      - -

      Example 3:

      - -
      -Input: root1 = [], root2 = [5,1,7,0,2]
      -Output: [0,1,2,5,7]
      -
      - -

      Example 4:

      - -
      -Input: root1 = [0,-10,10], root2 = []
      -Output: [-10,0,10]
      -
      - -

      Example 5:

       Input: root1 = [1,null,8], root2 = [8,1]
      @@ -55,8 +32,8 @@
       

      Constraints:

        -
      • Each tree has at most 5000 nodes.
      • -
      • Each node's value is between [-10^5, 10^5].
      • +
      • The number of nodes in each tree is in the range [0, 5000].
      • +
      • -105 <= Node.val <= 105
      ### Related Topics diff --git a/problems/all-oone-data-structure/README.md b/problems/all-oone-data-structure/README.md index c4c565fc7..b1bf3b3fc 100644 --- a/problems/all-oone-data-structure/README.md +++ b/problems/all-oone-data-structure/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../encode-n-ary-tree-to-binary-tree "Encode N-ary Tree to Binary Tree") @@ -55,7 +55,7 @@ allOne.getMinKey(); // return "leet"
    ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Design](../../tag/design/README.md)] [[Doubly-Linked List](../../tag/doubly-linked-list/README.md)] diff --git a/problems/all-possible-full-binary-trees/README.md b/problems/all-possible-full-binary-trees/README.md index 7d2cba86f..663028786 100644 --- a/problems/all-possible-full-binary-trees/README.md +++ b/problems/all-possible-full-binary-trees/README.md @@ -40,8 +40,8 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Tree](../../tag/tree/README.md)] [[Recursion](../../tag/recursion/README.md)] [[Memoization](../../tag/memoization/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/allocate-mailboxes/README.md b/problems/allocate-mailboxes/README.md index 5d982f082..b0bd29e7e 100644 --- a/problems/allocate-mailboxes/README.md +++ b/problems/allocate-mailboxes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-two-non-overlapping-sub-arrays-each-with-target-sum "Find Two Non-overlapping Sub-arrays Each With Target Sum") @@ -11,58 +11,38 @@ ## [1478. Allocate Mailboxes (Hard)](https://leetcode.com/problems/allocate-mailboxes "安排邮筒") -

    Given the array houses and an integer k. where houses[i] is the location of the ith house along a street, your task is to allocate k mailboxes in the street.

    +

    Given the array houses where houses[i] is the location of the ith house along a street and an integer k, allocate k mailboxes in the street.

    -

    Return the minimum total distance between each house and its nearest mailbox.

    +

    Return the minimum total distance between each house and its nearest mailbox.

    -

    The answer is guaranteed to fit in a 32-bit signed integer.

    +

    The test cases are generated so that the answer fits in a 32-bit integer.

     

    Example 1:

    - -

    - +
     Input: houses = [1,4,8,10,20], k = 3
     Output: 5
    -Explanation: Allocate mailboxes in position 3, 9 and 20.
    +Explanation: Allocate mailboxes in position 3, 9 and 20.
     Minimum total distance from each houses to nearest mailboxes is |3-1| + |4-3| + |9-8| + |10-9| + |20-20| = 5 
     

    Example 2:

    - -

    - +
     Input: houses = [2,3,5,12,18], k = 2
     Output: 9
    -Explanation: Allocate mailboxes in position 3 and 14.
    +Explanation: Allocate mailboxes in position 3 and 14.
     Minimum total distance from each houses to nearest mailboxes is |2-3| + |3-3| + |5-3| + |12-14| + |18-14| = 9.
     
    -

    Example 3:

    - -
    -Input: houses = [7,4,6,1], k = 1
    -Output: 8
    -
    - -

    Example 4:

    - -
    -Input: houses = [3,6,14,10], k = 4
    -Output: 0
    -
    -

     

    Constraints:

      -
    • n == houses.length
    • -
    • 1 <= n <= 100
    • -
    • 1 <= houses[i] <= 10^4
    • -
    • 1 <= k <= n
    • -
    • Array houses contain unique integers.
    • +
    • 1 <= k <= houses.length <= 100
    • +
    • 1 <= houses[i] <= 104
    • +
    • All the integers of houses are unique.
    ### Related Topics diff --git a/problems/amount-of-new-area-painted-each-day/README.md b/problems/amount-of-new-area-painted-each-day/README.md new file mode 100644 index 000000000..7af517b36 --- /dev/null +++ b/problems/amount-of-new-area-painted-each-day/README.md @@ -0,0 +1,40 @@ + + + + + + + +[< Previous](../groups-of-strings "Groups of Strings") +                 +[Next >](../order-two-columns-independently "Order Two Columns Independently") + +## [2158. Amount of New Area Painted Each Day (Hard)](https://leetcode.com/problems/amount-of-new-area-painted-each-day "") + + + +### Related Topics + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + +### Hints +
    +Hint 1 +What’s a good way to keep track of intervals that you have already painted? +
    + +
    +Hint 2 +Create an array of all 1’s, and when you have painted an interval, set the values in that interval to 0. +
    + +
    +Hint 3 +Using this array, how can you quickly calculate the amount of new area that you paint on a given day? +
    + +
    +Hint 4 +Calculate the sum of the new array in the interval that you paint. +
    diff --git a/problems/android-unlock-patterns/README.md b/problems/android-unlock-patterns/README.md index 9d96cd889..681daf4dc 100644 --- a/problems/android-unlock-patterns/README.md +++ b/problems/android-unlock-patterns/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../intersection-of-two-arrays-ii "Intersection of Two Arrays II") diff --git a/problems/apples-oranges/README.md b/problems/apples-oranges/README.md index be80dd0cb..61bfaa61e 100644 --- a/problems/apples-oranges/README.md +++ b/problems/apples-oranges/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-of-cutting-a-pizza "Number of Ways of Cutting a Pizza") diff --git a/problems/arithmetic-subarrays/README.md b/problems/arithmetic-subarrays/README.md index 5c34778f3..e38ff7b32 100644 --- a/problems/arithmetic-subarrays/README.md +++ b/problems/arithmetic-subarrays/README.md @@ -64,10 +64,6 @@ In the 2nd query, the subarray is [5,9,3,7]. This can be [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Arithmetic Slices](../arithmetic-slices) (Medium) - 1. [Can Make Arithmetic Progression From Sequence](../can-make-arithmetic-progression-from-sequence) (Easy) - ### Hints
    Hint 1 diff --git a/problems/armstrong-number/README.md b/problems/armstrong-number/README.md index 2a5aef613..6393d60cd 100644 --- a/problems/armstrong-number/README.md +++ b/problems/armstrong-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-unique-number "Largest Unique Number") diff --git a/problems/available-captures-for-rook/README.md b/problems/available-captures-for-rook/README.md index 6c4c5b748..d1375f510 100644 --- a/problems/available-captures-for-rook/README.md +++ b/problems/available-captures-for-rook/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-binary-tree-ii "Maximum Binary Tree II") diff --git a/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md b/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md index 1dcd53d41..239269d1b 100644 --- a/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md +++ b/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../clone-n-ary-tree "Clone N-ary Tree") @@ -11,9 +11,9 @@ ## [1491. Average Salary Excluding the Minimum and Maximum Salary (Easy)](https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary "去掉最低工资和最高工资后的工资平均值") -

    Given an array of unique integers salary where salary[i] is the salary of the employee i.

    +

    You are given an array of unique integers salary where salary[i] is the salary of the ith employee.

    -

    Return the average salary of employees excluding the minimum and maximum salary.

    +

    Return the average salary of employees excluding the minimum and maximum salary. Answers within 10-5 of the actual answer will be accepted.

     

    Example 1:

    @@ -21,8 +21,8 @@
     Input: salary = [4000,3000,1000,2000]
     Output: 2500.00000
    -Explanation: Minimum salary and maximum salary are 1000 and 4000 respectively.
    -Average salary excluding minimum and maximum salary is (2000+3000)/2= 2500
    +Explanation: Minimum salary and maximum salary are 1000 and 4000 respectively.
    +Average salary excluding minimum and maximum salary is (2000+3000) / 2 = 2500
     

    Example 2:

    @@ -30,22 +30,8 @@ Average salary excluding minimum and maximum salary is (2000+3000)/2= 2500
     Input: salary = [1000,2000,3000]
     Output: 2000.00000
    -Explanation: Minimum salary and maximum salary are 1000 and 3000 respectively.
    -Average salary excluding minimum and maximum salary is (2000)/1= 2000
    -
    - -

    Example 3:

    - -
    -Input: salary = [6000,5000,4000,3000,2000,1000]
    -Output: 3500.00000
    -
    - -

    Example 4:

    - -
    -Input: salary = [8000,9000,2000,3000,6000,1000]
    -Output: 4750.00000
    +Explanation: Minimum salary and maximum salary are 1000 and 3000 respectively.
    +Average salary excluding minimum and maximum salary is (2000) / 1 = 2000
     

     

    @@ -53,9 +39,8 @@ Average salary excluding minimum and maximum salary is (2000)/1= 2000
    • 3 <= salary.length <= 100
    • -
    • 10^3 <= salary[i] <= 10^6
    • -
    • salary[i] is unique.
    • -
    • Answers within 10^-5 of the actual value will be accepted as correct.
    • +
    • 1000 <= salary[i] <= 106
    • +
    • All the integers of salary are unique.
    ### Related Topics diff --git a/problems/average-waiting-time/README.md b/problems/average-waiting-time/README.md index ef5e69e93..d2cba9701 100644 --- a/problems/average-waiting-time/README.md +++ b/problems/average-waiting-time/README.md @@ -61,9 +61,6 @@ So the average waiting time = (2 + 6 + 4 + 1) / 4 = 3.25. [[Array](../../tag/array/README.md)] [[Simulation](../../tag/simulation/README.md)] -### Similar Questions - 1. [Average Height of Buildings in Each Segment](../average-height-of-buildings-in-each-segment) (Medium) - ### Hints
    Hint 1 diff --git a/problems/avoid-flood-in-the-city/README.md b/problems/avoid-flood-in-the-city/README.md index a691b24b6..fdd8339ce 100644 --- a/problems/avoid-flood-in-the-city/README.md +++ b/problems/avoid-flood-in-the-city/README.md @@ -25,7 +25,7 @@
    • ans.length == rains.length
    • ans[i] == -1 if rains[i] > 0.
    • -
    • ans[i] is the lake you choose to dry in the ith day if rains[i] == 0.
    • +
    • ans[i] is the lake you choose to dry in the ith day if rains[i] == 0.

    If there are multiple valid answers return any of them. If it is impossible to avoid flood return an empty array.

    @@ -68,22 +68,6 @@ It is easy that this scenario is flood-free. [-1,-1,1,2,-1,-1] is another accept After that, it will rain over lakes [1,2]. It's easy to prove that no matter which lake you choose to dry in the 3rd day, the other one will flood. -

    Example 4:

    - -
    -Input: rains = [69,0,0,0,69]
    -Output: [-1,69,1,1,-1]
    -Explanation: Any solution on one of the forms [-1,69,x,y,-1], [-1,x,69,y,-1] or [-1,x,y,69,-1] is acceptable where 1 <= x,y <= 10^9
    -
    - -

    Example 5:

    - -
    -Input: rains = [10,20,20]
    -Output: []
    -Explanation: It will rain over lake 20 two consecutive days. There is no chance to dry any lake.
    -
    -

     

    Constraints:

    diff --git a/problems/backspace-string-compare/README.md b/problems/backspace-string-compare/README.md index d11ab235a..e5ba9c09d 100644 --- a/problems/backspace-string-compare/README.md +++ b/problems/backspace-string-compare/README.md @@ -34,14 +34,6 @@

    Example 3:

    -
    -Input: s = "a##c", t = "#a#c"
    -Output: true
    -Explanation: Both s and t become "c".
    -
    - -

    Example 4:

    -
     Input: s = "a#c", t = "b"
     Output: false
    @@ -53,7 +45,7 @@
     
     
    • 1 <= s.length, t.length <= 200
    • -
    • s and t only contain lowercase letters and '#' characters.
    • +
    • s and t only contain lowercase letters and '#' characters.

     

    diff --git a/problems/bag-of-tokens/README.md b/problems/bag-of-tokens/README.md index 8b1f6e747..e5400398d 100644 --- a/problems/bag-of-tokens/README.md +++ b/problems/bag-of-tokens/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../most-stones-removed-with-same-row-or-column "Most Stones Removed with Same Row or Column") @@ -63,7 +63,7 @@ There is no need to play the 1st token since you cannot play it face ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/battleships-in-a-board/README.md b/problems/battleships-in-a-board/README.md index 4fd781d03..0fd2ab0d2 100644 --- a/problems/battleships-in-a-board/README.md +++ b/problems/battleships-in-a-board/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sentence-screen-fitting "Sentence Screen Fitting") @@ -44,6 +44,6 @@

    Follow up: Could you do it in one-pass, using only O(1) extra memory and without modifying the values board?

    ### Related Topics - [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Array](../../tag/array/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/beautiful-arrangement/README.md b/problems/beautiful-arrangement/README.md index e9a44b8fa..054a56581 100644 --- a/problems/beautiful-arrangement/README.md +++ b/problems/beautiful-arrangement/README.md @@ -50,10 +50,10 @@ The second beautiful arrangement is [2,1]: ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] ### Similar Questions diff --git a/problems/best-position-for-a-service-centre/README.md b/problems/best-position-for-a-service-centre/README.md index 776cdd14f..224671215 100644 --- a/problems/best-position-for-a-service-centre/README.md +++ b/problems/best-position-for-a-service-centre/README.md @@ -11,13 +11,13 @@ ## [1515. Best Position for a Service Centre (Hard)](https://leetcode.com/problems/best-position-for-a-service-centre "服务中心的最佳位置") -

    A delivery company wants to build a new service centre in a new city. The company knows the positions of all the customers in this city on a 2D-Map and wants to build the new centre in a position such that the sum of the euclidean distances to all customers is minimum.

    +

    A delivery company wants to build a new service center in a new city. The company knows the positions of all the customers in this city on a 2D-Map and wants to build the new center in a position such that the sum of the euclidean distances to all customers is minimum.

    Given an array positions where positions[i] = [xi, yi] is the position of the ith customer on the map, return the minimum sum of the euclidean distances to all customers.

    -

    In other words, you need to choose the position of the service centre [xcentre, ycentre] such that the following formula is minimized:

    +

    In other words, you need to choose the position of the service center [xcentre, ycentre] such that the following formula is minimized:

    -

    Answers within 10^-5 of the actual value will be accepted.

    +

    Answers within 10-5 of the actual value will be accepted.

     

    Example 1:

    @@ -36,38 +36,13 @@ Explanation: The minimum possible sum of distances = sqrt(2) + sqrt(2) = 2.82843
    -

    Example 3:

    - -
    -Input: positions = [[1,1]]
    -Output: 0.00000
    -
    - -

    Example 4:

    - -
    -Input: positions = [[1,1],[0,0],[2,0]]
    -Output: 2.73205
    -Explanation: At the first glance, you may think that locating the centre at [1, 0] will achieve the minimum sum, but locating it at [1, 0] will make the sum of distances = 3.
    -Try to locate the centre at [1.0, 0.5773502711] you will see that the sum of distances is 2.73205.
    -Be careful with the precision!
    -
    - -

    Example 5:

    - -
    -Input: positions = [[0,1],[3,2],[4,5],[7,6],[8,9],[11,1],[2,12]]
    -Output: 32.94036
    -Explanation: You can use [4.3460852395, 4.9813795505] as the position of the centre.
    -
    -

     

    Constraints:

      -
    • 1 <= positions.length <= 50
    • +
    • 1 <= positions.length <= 50
    • positions[i].length == 2
    • -
    • 0 <= positions[i][0], positions[i][1] <= 100
    • +
    • 0 <= xi, yi <= 100
    ### Related Topics diff --git a/problems/best-time-to-buy-and-sell-stock-iii/README.md b/problems/best-time-to-buy-and-sell-stock-iii/README.md index 198700c20..aed420db4 100644 --- a/problems/best-time-to-buy-and-sell-stock-iii/README.md +++ b/problems/best-time-to-buy-and-sell-stock-iii/README.md @@ -43,13 +43,6 @@ Note that you cannot buy on day 1, buy on day 2 and sell them later, as you are Explanation: In this case, no transaction is done, i.e. max profit = 0. -

    Example 4:

    - -
    -Input: prices = [1]
    -Output: 0
    -
    -

     

    Constraints:

    diff --git a/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md b/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md index 654c0256f..199745595 100644 --- a/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md +++ b/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../subarray-product-less-than-k "Subarray Product Less Than K") @@ -48,9 +48,9 @@ The total profit is ((8 - 1) - 2) + ((9 - 4) - 2) = 8. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions 1. [Best Time to Buy and Sell Stock II](../best-time-to-buy-and-sell-stock-ii) (Medium) diff --git a/problems/binary-number-with-alternating-bits/README.md b/problems/binary-number-with-alternating-bits/README.md index e1a0fdba1..c4e00c4fe 100644 --- a/problems/binary-number-with-alternating-bits/README.md +++ b/problems/binary-number-with-alternating-bits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../top-k-frequent-words "Top K Frequent Words") @@ -36,20 +36,6 @@ Output: false Explanation: The binary representation of 11 is: 1011. -

    Example 4:

    - -
    -Input: n = 10
    -Output: true
    -Explanation: The binary representation of 10 is: 1010.
    - -

    Example 5:

    - -
    -Input: n = 3
    -Output: false
    -
    -

     

    Constraints:

    diff --git a/problems/binary-searchable-numbers-in-an-unsorted-array/README.md b/problems/binary-searchable-numbers-in-an-unsorted-array/README.md index 456b220f6..6bebaaf0d 100644 --- a/problems/binary-searchable-numbers-in-an-unsorted-array/README.md +++ b/problems/binary-searchable-numbers-in-an-unsorted-array/README.md @@ -9,7 +9,7 @@                  [Next >](../number-of-strings-that-appear-as-substrings-in-word "Number of Strings That Appear as Substrings in Word") -## [1966. Binary Searchable Numbers in an Unsorted Array (Medium)](https://leetcode.com/problems/binary-searchable-numbers-in-an-unsorted-array "") +## [1966. Binary Searchable Numbers in an Unsorted Array (Medium)](https://leetcode.com/problems/binary-searchable-numbers-in-an-unsorted-array "未排序数组中的可被二分搜索的数") diff --git a/problems/binary-string-with-substrings-representing-1-to-n/README.md b/problems/binary-string-with-substrings-representing-1-to-n/README.md index 442d0a730..86dfded8d 100644 --- a/problems/binary-string-with-substrings-representing-1-to-n/README.md +++ b/problems/binary-string-with-substrings-representing-1-to-n/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-integer-divisible-by-k "Smallest Integer Divisible by K") diff --git a/problems/binary-subarrays-with-sum/README.md b/problems/binary-subarrays-with-sum/README.md index a618aad06..775b0833f 100644 --- a/problems/binary-subarrays-with-sum/README.md +++ b/problems/binary-subarrays-with-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../unique-email-addresses "Unique Email Addresses") @@ -47,5 +47,5 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] diff --git a/problems/binary-tree-level-order-traversal/README.md b/problems/binary-tree-level-order-traversal/README.md index 31bcd1c24..60197a3e7 100644 --- a/problems/binary-tree-level-order-traversal/README.md +++ b/problems/binary-tree-level-order-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../symmetric-tree "Symmetric Tree") diff --git a/problems/binary-tree-right-side-view/README.md b/problems/binary-tree-right-side-view/README.md index 792501a62..d005f8380 100644 --- a/problems/binary-tree-right-side-view/README.md +++ b/problems/binary-tree-right-side-view/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../house-robber "House Robber") diff --git a/problems/binary-tree-upside-down/README.md b/problems/binary-tree-upside-down/README.md index a3bf356be..9e4be9643 100644 --- a/problems/binary-tree-upside-down/README.md +++ b/problems/binary-tree-upside-down/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../min-stack "Min Stack") diff --git a/problems/binary-tree-vertical-order-traversal/README.md b/problems/binary-tree-vertical-order-traversal/README.md index 860aab5be..a23002120 100644 --- a/problems/binary-tree-vertical-order-traversal/README.md +++ b/problems/binary-tree-vertical-order-traversal/README.md @@ -90,10 +90,10 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/break-a-palindrome/README.md b/problems/break-a-palindrome/README.md index a6d34289d..aaaae4da1 100644 --- a/problems/break-a-palindrome/README.md +++ b/problems/break-a-palindrome/README.md @@ -35,19 +35,6 @@ Of all the ways, "aaccba" is the lexicographically smallest. Explanation: There is no way to replace a single character to make "a" not a palindrome, so return an empty string. -

    Example 3:

    - -
    -Input: palindrome = "aa"
    -Output: "ab"
    - -

    Example 4:

    - -
    -Input: palindrome = "aba"
    -Output: "abb"
    -
    -

     

    Constraints:

    diff --git a/problems/brightest-position-on-street/README.md b/problems/brightest-position-on-street/README.md index cf9a10f81..0aaf7cc50 100644 --- a/problems/brightest-position-on-street/README.md +++ b/problems/brightest-position-on-street/README.md @@ -9,7 +9,7 @@                  [Next >](../convert-1d-array-into-2d-array "Convert 1D Array Into 2D Array") -## [2021. Brightest Position on Street (Medium)](https://leetcode.com/problems/brightest-position-on-street "") +## [2021. Brightest Position on Street (Medium)](https://leetcode.com/problems/brightest-position-on-street "街上最亮的位置") diff --git a/problems/build-an-array-with-stack-operations/README.md b/problems/build-an-array-with-stack-operations/README.md index 60dd71263..15700b124 100644 --- a/problems/build-an-array-with-stack-operations/README.md +++ b/problems/build-an-array-with-stack-operations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../evaluate-boolean-expression "Evaluate Boolean Expression") @@ -11,17 +11,19 @@ ## [1441. Build an Array With Stack Operations (Easy)](https://leetcode.com/problems/build-an-array-with-stack-operations "用栈操作构建数组") -

    Given an array target and an integer n. In each iteration, you will read a number from  list = {1,2,3..., n}.

    +

    You are given an array target and an integer n.

    -

    Build the target array using the following operations:

    +

    In each iteration, you will read a number from list = [1, 2, 3, ..., n].

    + +

    Build the target array using the following operations:

      -
    • Push: Read a new element from the beginning list, and push it in the array.
    • -
    • Pop: delete the last element of the array.
    • -
    • If the target array is already built, stop reading more elements.
    • +
    • "Push": Reads a new element from the beginning list, and pushes it in the array.
    • +
    • "Pop": Deletes the last element of the array.
    • +
    • If the target array is already built, stop reading more elements.
    -

    Return the operations to build the target array. You are guaranteed that the answer is unique.

    +

    Return a list of the operations needed to build target. The test cases are generated so that the answer is unique.

     

    Example 1:

    @@ -29,8 +31,8 @@
     Input: target = [1,3], n = 3
     Output: ["Push","Push","Pop","Push"]
    -Explanation: 
    -Read number 1 and automatically push in the array -> [1]
    +Explanation: 
    +Read number 1 and automatically push in the array -> [1]
     Read number 2 and automatically push in the array then Pop it -> [1]
     Read number 3 and automatically push in the array -> [1,3]
     
    @@ -47,14 +49,7 @@ Read number 3 and automatically push in the array -> [1,3]
     Input: target = [1,2], n = 4
     Output: ["Push","Push"]
    -Explanation: You only need to read the first 2 numbers and stop.
    -
    - -

    Example 4:

    - -
    -Input: target = [2,3,4], n = 4
    -Output: ["Push","Pop","Push","Push","Push"]
    +Explanation: You only need to read the first 2 numbers and stop.
     

     

    @@ -62,14 +57,14 @@ Read number 3 and automatically push in the array -> [1,3]
    • 1 <= target.length <= 100
    • -
    • 1 <= target[i] <= n
    • 1 <= n <= 100
    • -
    • target is strictly increasing.
    • +
    • 1 <= target[i] <= n
    • +
    • target is strictly increasing.
    ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] + [[Stack](../../tag/stack/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/build-binary-expression-tree-from-infix-expression/README.md b/problems/build-binary-expression-tree-from-infix-expression/README.md index fc0ee4558..ccb059a16 100644 --- a/problems/build-binary-expression-tree-from-infix-expression/README.md +++ b/problems/build-binary-expression-tree-from-infix-expression/README.md @@ -14,11 +14,15 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] - [[String](../../tag/string/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Basic Calculator III](../basic-calculator-iii) (Hard) + 1. [Check If Two Expression Trees are Equivalent](../check-if-two-expression-trees-are-equivalent) (Medium) + ### Hints
    Hint 1 diff --git a/problems/build-the-equation/README.md b/problems/build-the-equation/README.md new file mode 100644 index 000000000..1a035a2c2 --- /dev/null +++ b/problems/build-the-equation/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../abbreviating-the-product-of-a-range "Abbreviating the Product of a Range") +                 +[Next >](../a-number-after-a-double-reversal "A Number After a Double Reversal") + +## [2118. Build the Equation (Hard)](https://leetcode.com/problems/build-the-equation "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/build-the-equation/mysql_schemas.sql b/problems/build-the-equation/mysql_schemas.sql new file mode 100644 index 000000000..9cb986611 --- /dev/null +++ b/problems/build-the-equation/mysql_schemas.sql @@ -0,0 +1,5 @@ +Create table If Not Exists Terms (power int, factor int); +Truncate table Terms; +insert into Terms (power, factor) values ('2', '1'); +insert into Terms (power, factor) values ('1', '-4'); +insert into Terms (power, factor) values ('0', '2'); diff --git a/problems/burst-balloons/README.md b/problems/burst-balloons/README.md index e2fb7335a..d8143c649 100644 --- a/problems/burst-balloons/README.md +++ b/problems/burst-balloons/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sparse-matrix-multiplication "Sparse Matrix Multiplication") @@ -39,7 +39,7 @@ coins = 3*1*5 + 3*5*8 + 1*3*8 + 1*8*1 = 167
    • n == nums.length
    • -
    • 1 <= n <= 500
    • +
    • 1 <= n <= 300
    • 0 <= nums[i] <= 100
    diff --git a/problems/calculate-salaries/README.md b/problems/calculate-salaries/README.md index 23f8246eb..9f0654cc5 100644 --- a/problems/calculate-salaries/README.md +++ b/problems/calculate-salaries/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "Probability of a Two Boxes Having The Same Number of Distinct Balls") diff --git a/problems/campus-bikes/README.md b/problems/campus-bikes/README.md index ea7457295..6e99c5415 100644 --- a/problems/campus-bikes/README.md +++ b/problems/campus-bikes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../confusing-number "Confusing Number") diff --git a/problems/can-make-arithmetic-progression-from-sequence/README.md b/problems/can-make-arithmetic-progression-from-sequence/README.md index 92f0cbc72..8ab8e871e 100644 --- a/problems/can-make-arithmetic-progression-from-sequence/README.md +++ b/problems/can-make-arithmetic-progression-from-sequence/README.md @@ -44,6 +44,9 @@ [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Arithmetic Subarrays](../arithmetic-subarrays) (Medium) + ### Hints
    Hint 1 diff --git a/problems/can-make-palindrome-from-substring/README.md b/problems/can-make-palindrome-from-substring/README.md index e8a95283e..20ea8a9eb 100644 --- a/problems/can-make-palindrome-from-substring/README.md +++ b/problems/can-make-palindrome-from-substring/README.md @@ -51,14 +51,11 @@ queries[4]: substring = "abcda", could be changed to "abcba" ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] -### Similar Questions - 1. [Plates Between Candles](../plates-between-candles) (Medium) - ### Hints
    Hint 1 diff --git a/problems/capacity-to-ship-packages-within-d-days/README.md b/problems/capacity-to-ship-packages-within-d-days/README.md index b2df14c7d..7bb5aba1c 100644 --- a/problems/capacity-to-ship-packages-within-d-days/README.md +++ b/problems/capacity-to-ship-packages-within-d-days/README.md @@ -65,15 +65,9 @@ Note that the cargo must be shipped in the order given, so using a ship of capac ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Greedy](../../tag/greedy/README.md)] - -### Similar Questions - 1. [Split Array Largest Sum](../split-array-largest-sum) (Hard) - 1. [Divide Chocolate](../divide-chocolate) (Hard) - 1. [Cutting Ribbons](../cutting-ribbons) (Medium) - 1. [Minimized Maximum of Products Distributed to Any Store](../minimized-maximum-of-products-distributed-to-any-store) (Medium) ### Hints
    diff --git a/problems/capital-gainloss/README.md b/problems/capital-gainloss/README.md index 0529c1234..df3815de0 100644 --- a/problems/capital-gainloss/README.md +++ b/problems/capital-gainloss/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-happy-prefix "Longest Happy Prefix") diff --git a/problems/capitalize-the-title/README.md b/problems/capitalize-the-title/README.md new file mode 100644 index 000000000..390a33635 --- /dev/null +++ b/problems/capitalize-the-title/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../remove-all-ones-with-row-and-column-flips "Remove All Ones With Row and Column Flips") +                 +[Next >](../maximum-twin-sum-of-a-linked-list "Maximum Twin Sum of a Linked List") + +## [2129. Capitalize the Title (Easy)](https://leetcode.com/problems/capitalize-the-title "将标题首字母大写") + +

    You are given a string title consisting of one or more words separated by a single space, where each word consists of English letters. Capitalize the string by changing the capitalization of each word such that:

    + +
      +
    • If the length of the word is 1 or 2 letters, change all letters to lowercase.
    • +
    • Otherwise, change the first letter to uppercase and the remaining letters to lowercase.
    • +
    + +

    Return the capitalized title.

    + +

     

    +

    Example 1:

    + +
    +Input: title = "capiTalIze tHe titLe"
    +Output: "Capitalize The Title"
    +Explanation:
    +Since all the words have a length of at least 3, the first letter of each word is uppercase, and the remaining letters are lowercase.
    +
    + +

    Example 2:

    + +
    +Input: title = "First leTTeR of EACH Word"
    +Output: "First Letter of Each Word"
    +Explanation:
    +The word "of" has length 2, so it is all lowercase.
    +The remaining words have a length of at least 3, so the first letter of each remaining word is uppercase, and the remaining letters are lowercase.
    +
    + +

    Example 3:

    + +
    +Input: title = "i lOve leetcode"
    +Output: "i Love Leetcode"
    +Explanation:
    +The word "i" has length 1, so it is lowercase.
    +The remaining words have a length of at least 3, so the first letter of each remaining word is uppercase, and the remaining letters are lowercase.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= title.length <= 100
    • +
    • title consists of words separated by a single space without any leading or trailing spaces.
    • +
    • Each word consists of uppercase and lowercase English letters and is non-empty.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Firstly, try to find all the words present in the string. +
    + +
    +Hint 2 +On the basis of each word's lengths, simulate the process explained in Problem. +
    diff --git a/problems/car-fleet-ii/README.md b/problems/car-fleet-ii/README.md index dda2040c2..49ff94884 100644 --- a/problems/car-fleet-ii/README.md +++ b/problems/car-fleet-ii/README.md @@ -48,11 +48,14 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Monotonic Stack](../../tag/monotonic-stack/README.md)] + [[Stack](../../tag/stack/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] + +### Similar Questions + 1. [Car Fleet](../car-fleet) (Medium) ### Hints
    diff --git a/problems/car-pooling/README.md b/problems/car-pooling/README.md index 18852963e..ee4665fef 100644 --- a/problems/car-pooling/README.md +++ b/problems/car-pooling/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../statistics-from-a-large-sample "Statistics from a Large Sample") @@ -13,7 +13,7 @@

    There is a car with capacity empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west).

    -

    You are given the integer capacity and an array trips where trip[i] = [numPassengersi, fromi, toi] indicates that the ith trip has numPassengersi passengers and the locations to pick them up and drop them off are fromi and toi respectively. The locations are given as the number of kilometers due east from the car's initial location.

    +

    You are given the integer capacity and an array trips where trips[i] = [numPassengersi, fromi, toi] indicates that the ith trip has numPassengersi passengers and the locations to pick them up and drop them off are fromi and toi respectively. The locations are given as the number of kilometers due east from the car's initial location.

    Return true if it is possible to pick up and drop off all passengers for all the given trips, or false otherwise.

    @@ -32,20 +32,6 @@ Output: true -

    Example 3:

    - -
    -Input: trips = [[2,1,5],[3,5,7]], capacity = 3
    -Output: true
    -
    - -

    Example 4:

    - -
    -Input: trips = [[3,2,7],[3,7,9],[8,3,9]], capacity = 11
    -Output: true
    -
    -

     

    Constraints:

    diff --git a/problems/cat-and-mouse-ii/README.md b/problems/cat-and-mouse-ii/README.md index 1163fd2b3..87c97a15a 100644 --- a/problems/cat-and-mouse-ii/README.md +++ b/problems/cat-and-mouse-ii/README.md @@ -46,9 +46,7 @@

     

    Example 1:

    - -

    - +
     Input: grid = ["####F","#C...","M...."], catJump = 1, mouseJump = 2
     Output: true
    @@ -56,9 +54,7 @@
     

    Example 2:

    - -

    - +
     Input: grid = ["M.C...F"], catJump = 1, mouseJump = 4
     Output: true
    @@ -71,20 +67,6 @@
     Output: false
     
    -

    Example 4:

    - -
    -Input: grid = ["C...#","...#F","....#","M...."], catJump = 2, mouseJump = 5
    -Output: false
    -
    - -

    Example 5:

    - -
    -Input: grid = [".M...","..#..","#..#.","C#.#.","...#F"], catJump = 3, mouseJump = 1
    -Output: true
    -
    -

     

    Constraints:

    @@ -98,13 +80,17 @@ ### Related Topics + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] [[Memoization](../../tag/memoization/README.md)] - [[Math](../../tag/math/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Game Theory](../../tag/game-theory/README.md)] +### Similar Questions + 1. [Escape The Ghosts](../escape-the-ghosts) (Medium) + 1. [Cat and Mouse](../cat-and-mouse) (Hard) + ### Hints
    Hint 1 diff --git a/problems/cheapest-flights-within-k-stops/README.md b/problems/cheapest-flights-within-k-stops/README.md index b2cd7e7b3..04469ee9c 100644 --- a/problems/cheapest-flights-within-k-stops/README.md +++ b/problems/cheapest-flights-within-k-stops/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../k-th-smallest-prime-fraction "K-th Smallest Prime Fraction") diff --git a/problems/check-array-formation-through-concatenation/README.md b/problems/check-array-formation-through-concatenation/README.md index d010e77ab..21e3f6946 100644 --- a/problems/check-array-formation-through-concatenation/README.md +++ b/problems/check-array-formation-through-concatenation/README.md @@ -18,20 +18,13 @@

     

    Example 1:

    -
    -Input: arr = [85], pieces = [[85]]
    -Output: true
    -
    - -

    Example 2:

    -
     Input: arr = [15,88], pieces = [[88],[15]]
     Output: true
    -Explanation: Concatenate [15] then [88]
    +Explanation: Concatenate [15] then [88]
     
    -

    Example 3:

    +

    Example 2:

     Input: arr = [49,18,16], pieces = [[16,18,49]]
    @@ -39,18 +32,12 @@
     Explanation: Even though the numbers match, we cannot reorder pieces[0].
     
    -

    Example 4:

    +

    Example 3:

     Input: arr = [91,4,64,78], pieces = [[78],[4,64],[91]]
     Output: true
    -Explanation: Concatenate [91] then [4,64] then [78]
    - -

    Example 5:

    - -
    -Input: arr = [1,3,5,7], pieces = [[2,4,6,8]]
    -Output: false
    +Explanation: Concatenate [91] then [4,64] then [78]
     

     

    @@ -61,8 +48,8 @@
  • sum(pieces[i].length) == arr.length
  • 1 <= pieces[i].length <= arr.length
  • 1 <= arr[i], pieces[i][j] <= 100
  • -
  • The integers in arr are distinct.
  • -
  • The integers in pieces are distinct (i.e., If we flatten pieces in a 1D array, all the integers in this array are distinct).
  • +
  • The integers in arr are distinct.
  • +
  • The integers in pieces are distinct (i.e., If we flatten pieces in a 1D array, all the integers in this array are distinct).
  • ### Related Topics diff --git a/problems/check-if-a-parentheses-string-can-be-valid/README.md b/problems/check-if-a-parentheses-string-can-be-valid/README.md new file mode 100644 index 000000000..9145e429f --- /dev/null +++ b/problems/check-if-a-parentheses-string-can-be-valid/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../find-all-possible-recipes-from-given-supplies "Find All Possible Recipes from Given Supplies") +                 +[Next >](../abbreviating-the-product-of-a-range "Abbreviating the Product of a Range") + +## [2116. Check if a Parentheses String Can Be Valid (Medium)](https://leetcode.com/problems/check-if-a-parentheses-string-can-be-valid "判断一个括号字符串是否有效") + +

    A parentheses string is a non-empty string consisting only of '(' and ')'. It is valid if any of the following conditions is true:

    + +
      +
    • It is ().
    • +
    • It can be written as AB (A concatenated with B), where A and B are valid parentheses strings.
    • +
    • It can be written as (A), where A is a valid parentheses string.
    • +
    + +

    You are given a parentheses string s and a string locked, both of length n. locked is a binary string consisting only of '0's and '1's. For each index i of locked,

    + +
      +
    • If locked[i] is '1', you cannot change s[i].
    • +
    • But if locked[i] is '0', you can change s[i] to either '(' or ')'.
    • +
    + +

    Return true if you can make s a valid parentheses string. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "))()))", locked = "010100"
    +Output: true
    +Explanation: locked[1] == '1' and locked[3] == '1', so we cannot change s[1] or s[3].
    +We change s[0] and s[4] to '(' while leaving s[2] and s[5] unchanged to make s valid.
    + +

    Example 2:

    + +
    +Input: s = "()()", locked = "0000"
    +Output: true
    +Explanation: We do not need to make any changes because s is already valid.
    +
    + +

    Example 3:

    + +
    +Input: s = ")", locked = "0"
    +Output: false
    +Explanation: locked permits us to change s[0]. 
    +Changing s[0] to either '(' or ')' will not make s valid.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == s.length == locked.length
    • +
    • 1 <= n <= 105
    • +
    • s[i] is either '(' or ')'.
    • +
    • locked[i] is either '0' or '1'.
    • +
    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Can an odd length string ever be valid? +
    + +
    +Hint 2 +From left to right, if a locked ')' is encountered, it must be balanced with either a locked '(' or an unlocked index on its left. If neither exist, what conclusion can be drawn? If both exist, which one is more preferable to use? +
    + +
    +Hint 3 +After the above, we may have locked indices of '(' and additional unlocked indices. How can you balance out the locked '(' now? What if you cannot balance any locked '('? +
    diff --git a/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md b/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md index 9a2188d97..1e1302333 100644 --- a/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md +++ b/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../make-two-arrays-equal-by-reversing-sub-arrays "Make Two Arrays Equal by Reversing Sub-arrays") @@ -11,9 +11,7 @@ ## [1461. Check If a String Contains All Binary Codes of Size K (Medium)](https://leetcode.com/problems/check-if-a-string-contains-all-binary-codes-of-size-k "检查一个字符串是否包含所有长度为 K 的二进制子串") -

    Given a binary string s and an integer k.

    - -

    Return true if every binary code of length k is a substring of s. Otherwise, return false.

    +

    Given a binary string s and an integer k, return true if every binary code of length k is a substring of s. Otherwise, return false.

     

    Example 1:

    @@ -21,37 +19,23 @@
     Input: s = "00110110", k = 2
     Output: true
    -Explanation: The binary codes of length 2 are "00", "01", "10" and "11". They can be all found as substrings at indicies 0, 1, 3 and 2 respectively.
    +Explanation: The binary codes of length 2 are "00", "01", "10" and "11". They can be all found as substrings at indices 0, 1, 3 and 2 respectively.
     

    Example 2:

    -
    -Input: s = "00110", k = 2
    -Output: true
    -
    - -

    Example 3:

    -
     Input: s = "0110", k = 1
     Output: true
     Explanation: The binary codes of length 1 are "0" and "1", it is clear that both exist as a substring. 
     
    -

    Example 4:

    +

    Example 3:

     Input: s = "0110", k = 2
     Output: false
    -Explanation: The binary code "00" is of length 2 and doesn't exist in the array.
    -
    - -

    Example 5:

    - -
    -Input: s = "0000000001011100", k = 4
    -Output: false
    +Explanation: The binary code "00" is of length 2 and does not exist in the array.
     

     

    @@ -64,11 +48,11 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Hash Function](../../tag/hash-function/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Rolling Hash](../../tag/rolling-hash/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Hints
    diff --git a/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md b/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md index 68d50de68..95c2506ca 100644 --- a/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md +++ b/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../active-users "Active Users") @@ -42,20 +42,6 @@ Explanation: "you" is not a prefix of any word in the sentence. -

    Example 4:

    - -
    -Input: sentence = "i use triple pillow", searchWord = "pill"
    -Output: 4
    -
    - -

    Example 5:

    - -
    -Input: sentence = "hello from the other side", searchWord = "they"
    -Output: -1
    -
    -

     

    Constraints:

    diff --git a/problems/check-if-all-as-appears-before-all-bs/README.md b/problems/check-if-all-as-appears-before-all-bs/README.md new file mode 100644 index 000000000..a5c03bdf8 --- /dev/null +++ b/problems/check-if-all-as-appears-before-all-bs/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../minimum-operations-to-remove-adjacent-ones-in-matrix "Minimum Operations to Remove Adjacent Ones in Matrix") +                 +[Next >](../number-of-laser-beams-in-a-bank "Number of Laser Beams in a Bank") + +## [2124. Check if All A's Appears Before All B's (Easy)](https://leetcode.com/problems/check-if-all-as-appears-before-all-bs "检查是否所有 A 都在 B 之前") + +

    Given a string s consisting of only the characters 'a' and 'b', return true if every 'a' appears before every 'b' in the string. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "aaabbb"
    +Output: true
    +Explanation:
    +The 'a's are at indices 0, 1, and 2, while the 'b's are at indices 3, 4, and 5.
    +Hence, every 'a' appears before every 'b' and we return true.
    +
    + +

    Example 2:

    + +
    +Input: s = "abab"
    +Output: false
    +Explanation:
    +There is an 'a' at index 2 and a 'b' at index 1.
    +Hence, not every 'a' appears before every 'b' and we return false.
    +
    + +

    Example 3:

    + +
    +Input: s = "bbb"
    +Output: true
    +Explanation:
    +There are no 'a's, hence, every 'a' appears before every 'b' and we return true.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 100
    • +
    • s[i] is either 'a' or 'b'.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +You can check the opposite: check if there is a ‘b’ before an ‘a’. Then, negate and return that answer. +
    + +
    +Hint 2 +s should not have any occurrences of “ba” as a substring. +
    diff --git a/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md b/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md index d33963e44..aacdbbaa9 100644 --- a/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md +++ b/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md @@ -46,6 +46,9 @@ [[String](../../tag/string/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Rings and Rods](../rings-and-rods) (Easy) + ### Hints
    Hint 1 diff --git a/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md b/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md index ce29c124c..caeebf97b 100644 --- a/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md +++ b/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md @@ -74,32 +74,6 @@ - The original string encoded as s2 must start with the letter 'c'. -

    Example 4:

    - -
    -Input: s1 = "112s", s2 = "g841"
    -Output: true
    -Explanation: It is possible that "gaaaaaaaaaaaas" was the original string
    -- "gaaaaaaaaaaaas"
    -  -> Split:      ["g", "aaaaaaaaaaaa", "s"]
    -  -> Replace:    ["1", "12",           "s"]
    -  -> Concatenate: "112s", which is s1.
    -- "gaaaaaaaaaaaas"
    -  -> Split:      ["g", "aaaaaaaa", "aaaa", "s"]
    -  -> Replace:    ["g", "8",        "4",    "1"]
    -  -> Concatenate: "g841", which is s2.
    -
    - -

    Example 5:

    - -
    -Input: s1 = "ab", s2 = "a2"
    -Output: false
    -Explanation: It is impossible.
    -- The original string encoded as s1 has two letters.
    -- The original string encoded as s2 has three letters.
    -
    -

     

    Constraints:

    diff --git a/problems/check-if-array-is-sorted-and-rotated/README.md b/problems/check-if-array-is-sorted-and-rotated/README.md index f10753e75..0db6947c5 100644 --- a/problems/check-if-array-is-sorted-and-rotated/README.md +++ b/problems/check-if-array-is-sorted-and-rotated/README.md @@ -44,24 +44,6 @@ You can rotate the array by x = 3 positions to begin on the the element of value You can rotate the array by x = 0 positions (i.e. no rotation) to make nums. -

    Example 4:

    - -
    -Input: nums = [1,1,1]
    -Output: true
    -Explanation: [1,1,1] is the original sorted array.
    -You can rotate any number of positions to make nums.
    -
    - -

    Example 5:

    - -
    -Input: nums = [2,1]
    -Output: true
    -Explanation: [1,2] is the original sorted array.
    -You can rotate the array by x = 5 positions to begin on the element of value 2: [2,1].
    -
    -

     

    Constraints:

    diff --git a/problems/check-if-array-pairs-are-divisible-by-k/README.md b/problems/check-if-array-pairs-are-divisible-by-k/README.md index 729dfd51c..2eeb96e92 100644 --- a/problems/check-if-array-pairs-are-divisible-by-k/README.md +++ b/problems/check-if-array-pairs-are-divisible-by-k/README.md @@ -13,9 +13,9 @@

    Given an array of integers arr of even length n and an integer k.

    -

    We want to divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k.

    +

    We want to divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k.

    -

    Return True If you can find a way to do that or False otherwise.

    +

    Return true If you can find a way to do that or false otherwise.

     

    Example 1:

    @@ -42,20 +42,6 @@ Explanation: You can try all possible pairs to see that there is no way to divide arr into 3 pairs each with sum divisible by 10. -

    Example 4:

    - -
    -Input: arr = [-10,10], k = 2
    -Output: true
    -
    - -

    Example 5:

    - -
    -Input: arr = [-1,1,-2,2,-3,3,-4,4], k = 3
    -Output: true
    -
    -

     

    Constraints:

    diff --git a/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md b/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md index 1306dc3e1..60756572a 100644 --- a/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md +++ b/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md @@ -40,6 +40,9 @@ ### Related Topics [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Longer Contiguous Segments of Ones than Zeros](../longer-contiguous-segments-of-ones-than-zeros) (Easy) + ### Hints
    Hint 1 diff --git a/problems/check-if-every-row-and-column-contains-all-numbers/README.md b/problems/check-if-every-row-and-column-contains-all-numbers/README.md new file mode 100644 index 000000000..b3597801f --- /dev/null +++ b/problems/check-if-every-row-and-column-contains-all-numbers/README.md @@ -0,0 +1,60 @@ + + + + + + + +[< Previous](../stamping-the-grid "Stamping the Grid") +                 +[Next >](../minimum-swaps-to-group-all-1s-together-ii "Minimum Swaps to Group All 1's Together II") + +## [2133. Check if Every Row and Column Contains All Numbers (Easy)](https://leetcode.com/problems/check-if-every-row-and-column-contains-all-numbers "检查是否每一行每一列都包含全部整数") + +

    An n x n matrix is valid if every row and every column contains all the integers from 1 to n (inclusive).

    + +

    Given an n x n integer matrix matrix, return true if the matrix is valid. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: matrix = [[1,2,3],[3,1,2],[2,3,1]]
    +Output: true
    +Explanation: In this case, n = 3, and every row and column contains the numbers 1, 2, and 3.
    +Hence, we return true.
    +
    + +

    Example 2:

    + +
    +Input: matrix = [[1,1,1],[1,2,3],[1,2,3]]
    +Output: false
    +Explanation: In this case, n = 3, but the first row and the first column do not contain the numbers 2 or 3.
    +Hence, we return false.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == matrix.length == matrix[i].length
    • +
    • 1 <= n <= 100
    • +
    • 1 <= matrix[i][j] <= n
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Use for loops to check each row for every number from 1 to n. Similarly, do the same for each column. +
    + +
    +Hint 2 +For each check, you can keep a set of the unique elements in the checked row/col. By the end of the check, the size of the set should be n. +
    diff --git a/problems/check-if-n-and-its-double-exist/README.md b/problems/check-if-n-and-its-double-exist/README.md index 5eead7909..c54a20cf5 100644 --- a/problems/check-if-n-and-its-double-exist/README.md +++ b/problems/check-if-n-and-its-double-exist/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../jump-game-iv "Jump Game IV") @@ -61,6 +61,9 @@ [[Binary Search](../../tag/binary-search/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Keep Multiplying Found Values by Two](../keep-multiplying-found-values-by-two) (Easy) + ### Hints
    Hint 1 diff --git a/problems/check-if-numbers-are-ascending-in-a-sentence/README.md b/problems/check-if-numbers-are-ascending-in-a-sentence/README.md index 7c77fe501..f23398623 100644 --- a/problems/check-if-numbers-are-ascending-in-a-sentence/README.md +++ b/problems/check-if-numbers-are-ascending-in-a-sentence/README.md @@ -47,15 +47,6 @@ They are strictly increasing from left to right: 1 < 3 < 4 < 6 < 12. Explanation: The numbers in s are: 7, 51, 50, 60. They are not strictly increasing. -

    Example 4:

    - -
    -Input: s = "4 5 11 26"
    -Output: true
    -Explanation: The numbers in s are: 4, 5, 11, 26.
    -They are strictly increasing from left to right: 4 < 5 < 11 < 26.
    -
    -

     

    Constraints:

    diff --git a/problems/check-if-one-string-swap-can-make-strings-equal/README.md b/problems/check-if-one-string-swap-can-make-strings-equal/README.md index d278fdcd0..97904c0b9 100644 --- a/problems/check-if-one-string-swap-can-make-strings-equal/README.md +++ b/problems/check-if-one-string-swap-can-make-strings-equal/README.md @@ -40,13 +40,6 @@ Explanation: The two strings are already equal, so no string swap operation is required. -

    Example 4:

    - -
    -Input: s1 = "abcd", s2 = "dcba"
    -Output: false
    -
    -

     

    Constraints:

    @@ -61,6 +54,9 @@ [[String](../../tag/string/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Buddy Strings](../buddy-strings) (Easy) + ### Hints
    Hint 1 diff --git a/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md b/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md index 439964b1e..59a65dbb5 100644 --- a/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md +++ b/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md @@ -11,17 +11,19 @@ ## [1585. Check If String Is Transformable With Substring Sort Operations (Hard)](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations "检查字符串是否可以通过排序子字符串得到另一个字符串") -

    Given two strings s and t, you want to transform string s into string t using the following operation any number of times:

    +

    Given two strings s and t, transform string s into string t using the following operation any number of times:

      -
    • Choose a non-empty substring in s and sort it in-place so the characters are in ascending order.
    • +
    • Choose a non-empty substring in s and sort it in place so the characters are in ascending order. +
        +
      • For example, applying the operation on the underlined substring in "14234" results in "12344".
      • +
      +
    -

    For example, applying the operation on the underlined substring in "14234" results in "12344".

    +

    Return true if it is possible to transform s into t. Otherwise, return false.

    -

    Return true if it is possible to transform string s into string t. Otherwise, return false.

    - -

    A substring is a contiguous sequence of characters within a string.

    +

    A substring is a contiguous sequence of characters within a string.

     

    Example 1:

    @@ -51,20 +53,13 @@ Output: false -

    Example 4:

    - -
    -Input: s = "1", t = "2"
    -Output: false
    -
    -

     

    Constraints:

    • s.length == t.length
    • 1 <= s.length <= 105
    • -
    • s and t only contain digits from '0' to '9'.
    • +
    • s and t consist of only digits.
    ### Related Topics diff --git a/problems/checking-existence-of-edge-length-limited-paths/README.md b/problems/checking-existence-of-edge-length-limited-paths/README.md index 86f617a92..cb9115df3 100644 --- a/problems/checking-existence-of-edge-length-limited-paths/README.md +++ b/problems/checking-existence-of-edge-length-limited-paths/README.md @@ -52,14 +52,11 @@ For the second query, there is a path (0 -> 1 -> 2) of two edges with dist ### Related Topics - [[Array](../../tag/array/README.md)] [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Checking Existence of Edge Length Limited Paths II](../checking-existence-of-edge-length-limited-paths-ii) (Hard) - ### Hints
    Hint 1 diff --git a/problems/cherry-pickup-ii/README.md b/problems/cherry-pickup-ii/README.md index 0dac251a8..e44b8c7f0 100644 --- a/problems/cherry-pickup-ii/README.md +++ b/problems/cherry-pickup-ii/README.md @@ -11,61 +11,48 @@ ## [1463. Cherry Pickup II (Hard)](https://leetcode.com/problems/cherry-pickup-ii "摘樱桃 II") -

    Given a rows x cols matrix grid representing a field of cherries. Each cell in grid represents the number of cherries that you can collect.

    +

    You are given a rows x cols matrix grid representing a field of cherries where grid[i][j] represents the number of cherries that you can collect from the (i, j) cell.

    -

    You have two robots that can collect cherries for you, Robot #1 is located at the top-left corner (0,0) , and Robot #2 is located at the top-right corner (0, cols-1) of the grid.

    +

    You have two robots that can collect cherries for you:

    -

    Return the maximum number of cherries collection using both robots  by following the rules below:

    +
      +
    • Robot #1 is located at the top-left corner (0, 0), and
    • +
    • Robot #2 is located at the top-right corner (0, cols - 1).
    • +
    + +

    Return the maximum number of cherries collection using both robots by following the rules below:

      -
    • From a cell (i,j), robots can move to cell (i+1, j-1) , (i+1, j) or (i+1, j+1).
    • -
    • When any robot is passing through a cell, It picks it up all cherries, and the cell becomes an empty cell (0).
    • -
    • When both robots stay on the same cell, only one of them takes the cherries.
    • -
    • Both robots cannot move outside of the grid at any moment.
    • -
    • Both robots should reach the bottom row in the grid.
    • +
    • From a cell (i, j), robots can move to cell (i + 1, j - 1), (i + 1, j), or (i + 1, j + 1).
    • +
    • When any robot passes through a cell, It picks up all cherries, and the cell becomes an empty cell.
    • +
    • When both robots stay in the same cell, only one takes the cherries.
    • +
    • Both robots cannot move outside of the grid at any moment.
    • +
    • Both robots should reach the bottom row in grid.

     

    Example 1:

    - -

    - +
     Input: grid = [[3,1,1],[2,5,1],[1,5,5],[2,1,1]]
     Output: 24
    -Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
    +Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
     Cherries taken by Robot #1, (3 + 2 + 5 + 2) = 12.
     Cherries taken by Robot #2, (1 + 5 + 5 + 1) = 12.
     Total of cherries: 12 + 12 = 24.
     

    Example 2:

    - -

    - +
     Input: grid = [[1,0,0,0,0,0,1],[2,0,0,0,0,3,0],[2,0,9,0,0,0,0],[0,3,0,5,4,0,0],[1,0,2,3,0,0,6]]
     Output: 28
    -Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
    +Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
     Cherries taken by Robot #1, (1 + 9 + 5 + 2) = 17.
     Cherries taken by Robot #2, (1 + 3 + 4 + 3) = 11.
     Total of cherries: 17 + 11 = 28.
     
    -

    Example 3:

    - -
    -Input: grid = [[1,0,0,3],[0,0,0,3],[0,0,3,3],[9,0,3,3]]
    -Output: 22
    -
    - -

    Example 4:

    - -
    -Input: grid = [[1,1],[1,1]]
    -Output: 4
    -
    -

     

    Constraints:

    @@ -73,7 +60,7 @@ Total of cherries: 17 + 11 = 28.
  • rows == grid.length
  • cols == grid[i].length
  • 2 <= rows, cols <= 70
  • -
  • 0 <= grid[i][j] <= 100 
  • +
  • 0 <= grid[i][j] <= 100
  • ### Related Topics diff --git a/problems/cherry-pickup/README.md b/problems/cherry-pickup/README.md index 25337a3d5..07f1b153f 100644 --- a/problems/cherry-pickup/README.md +++ b/problems/cherry-pickup/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-and-earn "Delete and Earn") diff --git a/problems/choose-numbers-from-two-arrays-in-range/README.md b/problems/choose-numbers-from-two-arrays-in-range/README.md new file mode 100644 index 000000000..d35ea7619 --- /dev/null +++ b/problems/choose-numbers-from-two-arrays-in-range/README.md @@ -0,0 +1,34 @@ + + + + + + + +[< Previous](../the-number-of-passengers-in-each-bus-i "The Number of Passengers in Each Bus I") +                 +[Next >](../minimum-cost-of-buying-candies-with-discount "Minimum Cost of Buying Candies With Discount") + +## [2143. Choose Numbers From Two Arrays in Range (Hard)](https://leetcode.com/problems/choose-numbers-from-two-arrays-in-range "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +If you know the possible sums you can get for a range [l, r], how can you use this information to calculate the possible sums you can get for a range [l, r + 1]? +
    + +
    +Hint 2 +For the range [l, r], if it is possible to choose elements such that the sum of elements you picked from nums1 is x and the sum of elements you picked from nums2 is y, then (x + nums1[r + 1], y) and (x, y + nums2[r + 1]) are possible sums you can get in the range [l, r + 1]. +
    + +
    +Hint 3 +How can we save the possible sums obtainable at a given index so that we can reuse this information later? +
    diff --git a/problems/cinema-seat-allocation/README.md b/problems/cinema-seat-allocation/README.md index b08c37802..2a9094e0f 100644 --- a/problems/cinema-seat-allocation/README.md +++ b/problems/cinema-seat-allocation/README.md @@ -57,10 +57,10 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/circle-and-rectangle-overlapping/README.md b/problems/circle-and-rectangle-overlapping/README.md index 3f115e148..546cedeb1 100644 --- a/problems/circle-and-rectangle-overlapping/README.md +++ b/problems/circle-and-rectangle-overlapping/README.md @@ -11,61 +11,46 @@ ## [1401. Circle and Rectangle Overlapping (Medium)](https://leetcode.com/problems/circle-and-rectangle-overlapping "圆和矩形是否有重叠") -

    Given a circle represented as (radius, x_center, y_center) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the rectangle.

    +

    You are given a circle represented as (radius, xCenter, yCenter) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the rectangle.

    -

    Return True if the circle and rectangle are overlapped otherwise return False.

    - -

    In other words, check if there are any point (xi, yi) such that belongs to the circle and the rectangle at the same time.

    +

    Return true if the circle and rectangle are overlapped otherwise return false. In other words, check if there is any point (xi, yi) that belongs to the circle and the rectangle at the same time.

     

    Example 1:

    - -

    - +
    -Input: radius = 1, x_center = 0, y_center = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1
    +Input: radius = 1, xCenter = 0, yCenter = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1
     Output: true
    -Explanation: Circle and rectangle share the point (1,0) 
    +Explanation: Circle and rectangle share the point (1,0).
     

    Example 2:

    -

    -
    -Input: radius = 1, x_center = 0, y_center = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1
    -Output: true
    +Input: radius = 1, xCenter = 1, yCenter = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1
    +Output: false
     

    Example 3:

    - -

    - +
    -Input: radius = 1, x_center = 1, y_center = 1, x1 = -3, y1 = -3, x2 = 3, y2 = 3
    +Input: radius = 1, xCenter = 0, yCenter = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1
     Output: true
     
    -

    Example 4:

    - -
    -Input: radius = 1, x_center = 1, y_center = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1
    -Output: false
    -
    -

     

    Constraints:

    • 1 <= radius <= 2000
    • -
    • -10^4 <= x_center, y_center, x1, y1, x2, y2 <= 10^4
    • -
    • x1 < x2
    • -
    • y1 < y2
    • +
    • -104 <= xCenter, yCenter <= 104
    • +
    • -104 <= x1 < x2 <= 104
    • +
    • -104 <= y1 < y2 <= 104
    ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] ### Hints
    diff --git a/problems/clone-binary-tree-with-random-pointer/README.md b/problems/clone-binary-tree-with-random-pointer/README.md index dac353e67..e50978b09 100644 --- a/problems/clone-binary-tree-with-random-pointer/README.md +++ b/problems/clone-binary-tree-with-random-pointer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../group-sold-products-by-the-date "Group Sold Products By The Date") diff --git a/problems/clone-n-ary-tree/README.md b/problems/clone-n-ary-tree/README.md index 7ef16942f..d1d37b8bd 100644 --- a/problems/clone-n-ary-tree/README.md +++ b/problems/clone-n-ary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree "Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree") diff --git a/problems/closest-binary-search-tree-value/README.md b/problems/closest-binary-search-tree-value/README.md index e1c3da73f..6178001ff 100644 --- a/problems/closest-binary-search-tree-value/README.md +++ b/problems/closest-binary-search-tree-value/README.md @@ -35,10 +35,10 @@ ### Related Topics + [[Binary Search](../../tag/binary-search/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/closest-dessert-cost/README.md b/problems/closest-dessert-cost/README.md index 82b8f7617..876fe6d2c 100644 --- a/problems/closest-dessert-cost/README.md +++ b/problems/closest-dessert-cost/README.md @@ -65,13 +65,6 @@ Total: 3 + 4 + 10 + 0 = 17. You cannot make a dessert with a total cost of 18. Explanation: It is possible to make desserts with cost 8 and 10. Return 8 as it is the lower cost. -

    Example 4:

    - -
    -Input: baseCosts = [10], toppingCosts = [1], target = 1
    -Output: 10
    -Explanation: Notice that you don't have to have any toppings, but you must have exactly one base.
    -

     

    Constraints:

    diff --git a/problems/combination-sum-ii/README.md b/problems/combination-sum-ii/README.md index c99f3bcb8..fa8221b01 100644 --- a/problems/combination-sum-ii/README.md +++ b/problems/combination-sum-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../combination-sum "Combination Sum") diff --git a/problems/combination-sum/README.md b/problems/combination-sum/README.md index 9a823c811..14716ac29 100644 --- a/problems/combination-sum/README.md +++ b/problems/combination-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-and-say "Count and Say") @@ -43,20 +43,6 @@ These are the only two combinations. Output: [] -

    Example 4:

    - -
    -Input: candidates = [1], target = 1
    -Output: [[1]]
    -
    - -

    Example 5:

    - -
    -Input: candidates = [1], target = 2
    -Output: [[1,1]]
    -
    -

     

    Constraints:

    diff --git a/problems/complement-of-base-10-integer/README.md b/problems/complement-of-base-10-integer/README.md index ba166f6bd..8b3cbb658 100644 --- a/problems/complement-of-base-10-integer/README.md +++ b/problems/complement-of-base-10-integer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-binary-search-tree-from-preorder-traversal "Construct Binary Search Tree from Preorder Traversal") diff --git a/problems/concatenation-of-consecutive-binary-numbers/README.md b/problems/concatenation-of-consecutive-binary-numbers/README.md index 1bd4d3bc7..c79a5b348 100644 --- a/problems/concatenation-of-consecutive-binary-numbers/README.md +++ b/problems/concatenation-of-consecutive-binary-numbers/README.md @@ -49,8 +49,8 @@ After modulo 109 + 7, the result is 505379714. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/consecutive-characters/README.md b/problems/consecutive-characters/README.md index 9ea25d484..c3ea0e124 100644 --- a/problems/consecutive-characters/README.md +++ b/problems/consecutive-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../apples-oranges "Apples & Oranges") @@ -32,27 +32,6 @@ Explanation: The substring "eeeee" is of length 5 with the character 'e' only. -

    Example 3:

    - -
    -Input: s = "triplepillooooow"
    -Output: 5
    -
    - -

    Example 4:

    - -
    -Input: s = "hooraaaaaaaaaaay"
    -Output: 11
    -
    - -

    Example 5:

    - -
    -Input: s = "tourist"
    -Output: 1
    -
    -

     

    Constraints:

    @@ -64,10 +43,6 @@ ### Related Topics [[String](../../tag/string/README.md)] -### Similar Questions - 1. [Max Consecutive Ones](../max-consecutive-ones) (Easy) - 1. [Count Number of Homogenous Substrings](../count-number-of-homogenous-substrings) (Medium) - ### Hints
    Hint 1 diff --git a/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md b/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md index 5271b0d6f..f48710384 100644 --- a/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md +++ b/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-binary-tree-from-preorder-and-inorder-traversal "Construct Binary Tree from Preorder and Inorder Traversal") @@ -42,10 +42,10 @@ ### Related Topics - [[Tree](../../tag/tree/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Tree](../../tag/tree/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md b/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md index 37ae76162..eb1be2100 100644 --- a/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md +++ b/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fair-candy-swap "Fair Candy Swap") diff --git a/problems/construct-binary-tree-from-string/README.md b/problems/construct-binary-tree-from-string/README.md index 05bb73e4e..985211a95 100644 --- a/problems/construct-binary-tree-from-string/README.md +++ b/problems/construct-binary-tree-from-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../encode-and-decode-tinyurl "Encode and Decode TinyURL") @@ -38,9 +38,9 @@

    ### Related Topics + [[String](../../tag/string/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[String](../../tag/string/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/container-with-most-water/README.md b/problems/container-with-most-water/README.md index edfe43eec..b3b25e052 100644 --- a/problems/container-with-most-water/README.md +++ b/problems/container-with-most-water/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../regular-expression-matching "Regular Expression Matching") @@ -11,7 +11,11 @@ ## [11. Container With Most Water (Medium)](https://leetcode.com/problems/container-with-most-water "盛最多水的容器") -

    Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.

    +

    You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]).

    + +

    Find two lines that together with the x-axis form a container, such that the container contains the most water.

    + +

    Return the maximum amount of water a container can store.

    Notice that you may not slant the container.

    @@ -21,7 +25,7 @@
     Input: height = [1,8,6,2,5,4,8,3,7]
     Output: 49
    -Explanation: The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49.
    +Explanation: The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49.
     

    Example 2:

    @@ -31,20 +35,6 @@ Output: 1 -

    Example 3:

    - -
    -Input: height = [4,3,2,1,4]
    -Output: 16
    -
    - -

    Example 4:

    - -
    -Input: height = [1,2,1]
    -Output: 2
    -
    -

     

    Constraints:

    diff --git a/problems/contiguous-array/README.md b/problems/contiguous-array/README.md index b0b4dbc33..39dec4a3a 100644 --- a/problems/contiguous-array/README.md +++ b/problems/contiguous-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-word-in-dictionary-through-deleting "Longest Word in Dictionary through Deleting") diff --git a/problems/continuous-subarray-sum/README.md b/problems/continuous-subarray-sum/README.md index b70633b7c..f182bd82e 100644 --- a/problems/continuous-subarray-sum/README.md +++ b/problems/continuous-subarray-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-uncommon-subsequence-ii "Longest Uncommon Subsequence II") diff --git a/problems/convert-1d-array-into-2d-array/README.md b/problems/convert-1d-array-into-2d-array/README.md index 43070be5f..1a2c6e69f 100644 --- a/problems/convert-1d-array-into-2d-array/README.md +++ b/problems/convert-1d-array-into-2d-array/README.md @@ -23,8 +23,7 @@
     Input: original = [1,2,3,4], m = 2, n = 2
     Output: [[1,2],[3,4]]
    -Explanation:
    -The constructed 2D array should contain 2 rows and 2 columns.
    +Explanation: The constructed 2D array should contain 2 rows and 2 columns.
     The first group of n=2 elements in original, [1,2], becomes the first row in the constructed 2D array.
     The second group of n=2 elements in original, [3,4], becomes the second row in the constructed 2D array.
     
    @@ -34,8 +33,7 @@ The second group of n=2 elements in original, [3,4], becomes the second row in t
     Input: original = [1,2,3], m = 1, n = 3
     Output: [[1,2,3]]
    -Explanation:
    -The constructed 2D array should contain 1 row and 3 columns.
    +Explanation: The constructed 2D array should contain 1 row and 3 columns.
     Put all three elements in original into the first row of the constructed 2D array.
     
    @@ -44,21 +42,10 @@ Put all three elements in original into the first row of the constructed 2D arra
     Input: original = [1,2], m = 1, n = 1
     Output: []
    -Explanation:
    -There are 2 elements in original.
    +Explanation: There are 2 elements in original.
     It is impossible to fit 2 elements in a 1x1 2D array, so return an empty 2D array.
     
    -

    Example 4:

    - -
    -Input: original = [3], m = 1, n = 2
    -Output: []
    -Explanation:
    -There is 1 element in original.
    -It is impossible to make 1 element fill all the spots in a 1x2 2D array, so return an empty 2D array.
    -
    -

     

    Constraints:

    diff --git a/problems/convert-bst-to-greater-tree/README.md b/problems/convert-bst-to-greater-tree/README.md index 203b61449..d29540249 100644 --- a/problems/convert-bst-to-greater-tree/README.md +++ b/problems/convert-bst-to-greater-tree/README.md @@ -23,7 +23,7 @@

     

    Example 1:

    - +
     Input: root = [4,1,6,0,2,5,7,null,null,null,3,null,null,null,8]
     Output: [30,36,21,36,35,26,15,null,null,null,33,null,null,null,8]
    @@ -36,20 +36,6 @@
     Output: [1,null,1]
     
    -

    Example 3:

    - -
    -Input: root = [1,0,2]
    -Output: [3,3,2]
    -
    - -

    Example 4:

    - -
    -Input: root = [3,2,4,1]
    -Output: [7,9,4,10]
    -
    -

     

    Constraints:

    diff --git a/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md b/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md index 7f0be835b..c06050fea 100644 --- a/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md +++ b/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md @@ -11,16 +11,16 @@ ## [1317. Convert Integer to the Sum of Two No-Zero Integers (Easy)](https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers "将整数转换为两个无零整数的和") -

    Given an integer n. No-Zero integer is a positive integer which doesn't contain any 0 in its decimal representation.

    +

    No-Zero integer is a positive integer that does not contain any 0 in its decimal representation.

    -

    Return a list of two integers [A, B] where:

    +

    Given an integer n, return a list of two integers [A, B] where:

      -
    • A and B are No-Zero integers.
    • +
    • A and B are No-Zero integers.
    • A + B = n
    -

    It's guarateed that there is at least one valid solution. If there are many valid solutions you can return any of them.

    +

    The test cases are generated so that there is at least one valid solution. If there are many valid solutions you can return any of them.

     

    Example 1:

    @@ -28,7 +28,7 @@
     Input: n = 2
     Output: [1,1]
    -Explanation: A = 1, B = 1. A + B = n and both A and B don't contain any 0 in their decimal representation.
    +Explanation: A = 1, B = 1. A + B = n and both A and B do not contain any 0 in their decimal representation.
     

    Example 2:

    @@ -38,32 +38,11 @@ Output: [2,9] -

    Example 3:

    - -
    -Input: n = 10000
    -Output: [1,9999]
    -
    - -

    Example 4:

    - -
    -Input: n = 69
    -Output: [1,68]
    -
    - -

    Example 5:

    - -
    -Input: n = 1010
    -Output: [11,999]
    -
    -

     

    Constraints:

      -
    • 2 <= n <= 10^4
    • +
    • 2 <= n <= 104
    ### Related Topics diff --git a/problems/convert-sorted-array-to-binary-search-tree/README.md b/problems/convert-sorted-array-to-binary-search-tree/README.md index 1a722bd23..83415f923 100644 --- a/problems/convert-sorted-array-to-binary-search-tree/README.md +++ b/problems/convert-sorted-array-to-binary-search-tree/README.md @@ -43,10 +43,10 @@ ### Related Topics - [[Tree](../../tag/tree/README.md)] - [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Array](../../tag/array/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/convert-sorted-list-to-binary-search-tree/README.md b/problems/convert-sorted-list-to-binary-search-tree/README.md index e3261f6d8..e91c9b31d 100644 --- a/problems/convert-sorted-list-to-binary-search-tree/README.md +++ b/problems/convert-sorted-list-to-binary-search-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-sorted-array-to-binary-search-tree "Convert Sorted Array to Binary Search Tree") @@ -17,7 +17,7 @@

     

    Example 1:

    - +
     Input: head = [-10,-3,0,5,9]
     Output: [0,-3,9,-10,null,5]
    @@ -31,20 +31,6 @@
     Output: []
     
    -

    Example 3:

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

    Example 4:

    - -
    -Input: head = [1,3]
    -Output: [3,1]
    -
    -

     

    Constraints:

    diff --git a/problems/coordinate-with-maximum-network-quality/README.md b/problems/coordinate-with-maximum-network-quality/README.md index 91f1ce025..6ada4d259 100644 --- a/problems/coordinate-with-maximum-network-quality/README.md +++ b/problems/coordinate-with-maximum-network-quality/README.md @@ -59,23 +59,6 @@ No other coordinate has a higher network quality. Explanation: Coordinate (1, 2) has the highest network quality. -

    Example 4:

    - -
    -Input: towers = [[2,1,9],[0,1,9]], radius = 2
    -Output: [0,1]
    -Explanation: Both (0, 1) and (2, 1) are optimal in terms of quality, but (0, 1) is lexicographically minimal.
    -
    - -

    Example 5:

    - -
    -Input: towers = [[42,0,0]], radius = 7
    -Output: [0,0]
    -Explanation: The network quality is 0 at every coordinate, even at the tower's location.
    -Thus, the lexicographically minimum non-negative coordinate is (0, 0).
    -
    -

     

    Constraints:

    diff --git a/problems/corporate-flight-bookings/README.md b/problems/corporate-flight-bookings/README.md index e48e88b45..63e874b4c 100644 --- a/problems/corporate-flight-bookings/README.md +++ b/problems/corporate-flight-bookings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../defanging-an-ip-address "Defanging an IP Address") diff --git a/problems/count-all-possible-routes/README.md b/problems/count-all-possible-routes/README.md index 9dfddc3fe..5de9e8ec3 100644 --- a/problems/count-all-possible-routes/README.md +++ b/problems/count-all-possible-routes/README.md @@ -25,7 +25,7 @@
     Input: locations = [2,3,6,8,4], start = 1, finish = 3, fuel = 5
     Output: 4
    -Explanation: The following are all possible routes, each uses 5 units of fuel:
    +Explanation: The following are all possible routes, each uses 5 units of fuel:
     1 -> 3
     1 -> 2 -> 3
     1 -> 4 -> 3
    @@ -37,7 +37,7 @@
     
     Input: locations = [4,3,1], start = 1, finish = 0, fuel = 6
     Output: 5
    -Explanation: The following are all possible routes:
    +Explanation: The following are all possible routes:
     1 -> 0, used fuel = 1
     1 -> 2 -> 0, used fuel = 5
     1 -> 2 -> 1 -> 0, used fuel = 5
    @@ -50,21 +50,7 @@
     
     Input: locations = [5,2,1], start = 0, finish = 2, fuel = 3
     Output: 0
    -Explanation: It's impossible to get from 0 to 2 using only 3 units of fuel since the shortest route needs 4 units of fuel.
    - -

    Example 4:

    - -
    -Input: locations = [2,1,5], start = 0, finish = 0, fuel = 3
    -Output: 2
    -Explanation: There are two possible routes, 0 and 0 -> 1 -> 0.
    - -

    Example 5:

    - -
    -Input: locations = [1,2,3], start = 0, finish = 2, fuel = 40
    -Output: 615088286
    -Explanation: The total number of possible routes is 2615088300. Taking this number modulo 10^9 + 7 gives us 615088286.
    +Explanation: It is impossible to get from 0 to 2 using only 3 units of fuel since the shortest route needs 4 units of fuel.
     

     

    @@ -79,9 +65,9 @@ ### Related Topics - [[Memoization](../../tag/memoization/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Memoization](../../tag/memoization/README.md)] ### Hints
    diff --git a/problems/count-all-valid-pickup-and-delivery-options/README.md b/problems/count-all-valid-pickup-and-delivery-options/README.md index 2ff24eb41..32cda0c3e 100644 --- a/problems/count-all-valid-pickup-and-delivery-options/README.md +++ b/problems/count-all-valid-pickup-and-delivery-options/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-substrings-containing-all-three-characters "Number of Substrings Containing All Three Characters") diff --git a/problems/count-binary-substrings/README.md b/problems/count-binary-substrings/README.md index 42e1f4151..de93a8d21 100644 --- a/problems/count-binary-substrings/README.md +++ b/problems/count-binary-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-area-of-island "Max Area of Island") diff --git a/problems/count-common-words-with-one-occurrence/README.md b/problems/count-common-words-with-one-occurrence/README.md new file mode 100644 index 000000000..776b6f8bc --- /dev/null +++ b/problems/count-common-words-with-one-occurrence/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../drop-type-1-orders-for-customers-with-type-0-orders "Drop Type 1 Orders for Customers With Type 0 Orders") +                 +[Next >](../minimum-number-of-buckets-required-to-collect-rainwater-from-houses "Minimum Number of Buckets Required to Collect Rainwater from Houses") + +## [2085. Count Common Words With One Occurrence (Easy)](https://leetcode.com/problems/count-common-words-with-one-occurrence "统计出现过一次的公共字符串") + +

    Given two string arrays words1 and words2, return the number of strings that appear exactly once in each of the two arrays.

    + +

     

    +

    Example 1:

    + +
    +Input: words1 = ["leetcode","is","amazing","as","is"], words2 = ["amazing","leetcode","is"]
    +Output: 2
    +Explanation:
    +- "leetcode" appears exactly once in each of the two arrays. We count this string.
    +- "amazing" appears exactly once in each of the two arrays. We count this string.
    +- "is" appears in each of the two arrays, but there are 2 occurrences of it in words1. We do not count this string.
    +- "as" appears once in words1, but does not appear in words2. We do not count this string.
    +Thus, there are 2 strings that appear exactly once in each of the two arrays.
    +
    + +

    Example 2:

    + +
    +Input: words1 = ["b","bb","bbb"], words2 = ["a","aa","aaa"]
    +Output: 0
    +Explanation: There are no strings that appear in each of the two arrays.
    +
    + +

    Example 3:

    + +
    +Input: words1 = ["a","ab"], words2 = ["a","a","a","ab"]
    +Output: 1
    +Explanation: The only string that appears exactly once in each of the two arrays is "ab".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words1.length, words2.length <= 1000
    • +
    • 1 <= words1[i].length, words2[j].length <= 30
    • +
    • words1[i] and words2[j] consists only of lowercase English letters.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Hints +
    +Hint 1 +Could you try every word? +
    + +
    +Hint 2 +Could you use a hash map to achieve a good complexity? +
    diff --git a/problems/count-different-palindromic-subsequences/README.md b/problems/count-different-palindromic-subsequences/README.md index ffc4a31e6..c0d8334f8 100644 --- a/problems/count-different-palindromic-subsequences/README.md +++ b/problems/count-different-palindromic-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../my-calendar-i "My Calendar I") diff --git a/problems/count-elements-with-strictly-smaller-and-greater-elements/README.md b/problems/count-elements-with-strictly-smaller-and-greater-elements/README.md new file mode 100644 index 000000000..199267f0b --- /dev/null +++ b/problems/count-elements-with-strictly-smaller-and-greater-elements/README.md @@ -0,0 +1,62 @@ + + + + + + + +[< Previous](../number-of-ways-to-divide-a-long-corridor "Number of Ways to Divide a Long Corridor") +                 +[Next >](../rearrange-array-elements-by-sign "Rearrange Array Elements by Sign") + +## [2148. Count Elements With Strictly Smaller and Greater Elements (Easy)](https://leetcode.com/problems/count-elements-with-strictly-smaller-and-greater-elements "元素计数") + +

    Given an integer array nums, return the number of elements that have both a strictly smaller and a strictly greater element appear in nums.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [11,7,2,15]
    +Output: 2
    +Explanation: The element 7 has the element 2 strictly smaller than it and the element 11 strictly greater than it.
    +Element 11 has element 7 strictly smaller than it and element 15 strictly greater than it.
    +In total there are 2 elements having both a strictly smaller and a strictly greater element appear in nums.
    +
    + +

    Example 2:

    + +
    +Input: nums = [-3,3,3,90]
    +Output: 2
    +Explanation: The element 3 has the element -3 strictly smaller than it and the element 90 strictly greater than it.
    +Since there are two elements with the value 3, in total there are 2 elements having both a strictly smaller and a strictly greater element appear in nums.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • -105 <= nums[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +All the elements in the array should be counted except for the minimum and maximum elements. +
    + +
    +Hint 2 +If the array has n elements, the answer will be n - count(min(nums)) - count(max(nums)) +
    + +
    +Hint 3 +This formula will not work in case the array has all the elements equal, why? +
    diff --git a/problems/count-fertile-pyramids-in-a-land/README.md b/problems/count-fertile-pyramids-in-a-land/README.md new file mode 100644 index 000000000..9e438e6a1 --- /dev/null +++ b/problems/count-fertile-pyramids-in-a-land/README.md @@ -0,0 +1,99 @@ + + + + + + + +[< Previous](../minimum-cost-homecoming-of-a-robot-in-a-grid "Minimum Cost Homecoming of a Robot in a Grid") +                 +[Next >](../find-target-indices-after-sorting-array "Find Target Indices After Sorting Array") + +## [2088. Count Fertile Pyramids in a Land (Hard)](https://leetcode.com/problems/count-fertile-pyramids-in-a-land "统计农场中肥沃金字塔的数目") + +

    A farmer has a rectangular grid of land with m rows and n columns that can be divided into unit cells. Each cell is either fertile (represented by a 1) or barren (represented by a 0). All cells outside the grid are considered barren.

    + +

    A pyramidal plot of land can be defined as a set of cells with the following criteria:

    + +
      +
    1. The number of cells in the set has to be greater than 1 and all cells must be fertile.
    2. +
    3. The apex of a pyramid is the topmost cell of the pyramid. The height of a pyramid is the number of rows it covers. Let (r, c) be the apex of the pyramid, and its height be h. Then, the plot comprises of cells (i, j) where r <= i <= r + h - 1 and c - (i - r) <= j <= c + (i - r).
    4. +
    + +

    An inverse pyramidal plot of land can be defined as a set of cells with similar criteria:

    + +
      +
    1. The number of cells in the set has to be greater than 1 and all cells must be fertile.
    2. +
    3. The apex of an inverse pyramid is the bottommost cell of the inverse pyramid. The height of an inverse pyramid is the number of rows it covers. Let (r, c) be the apex of the pyramid, and its height be h. Then, the plot comprises of cells (i, j) where r - h + 1 <= i <= r and c - (r - i) <= j <= c + (r - i).
    4. +
    + +

    Some examples of valid and invalid pyramidal (and inverse pyramidal) plots are shown below. Black cells indicate fertile cells.

    + +

    Given a 0-indexed m x n binary matrix grid representing the farmland, return the total number of pyramidal and inverse pyramidal plots that can be found in grid.

    + +

     

    +

    Example 1:

    + +
    +Input: grid = [[0,1,1,0],[1,1,1,1]]
    +Output: 2
    +Explanation: The 2 possible pyramidal plots are shown in blue and red respectively.
    +There are no inverse pyramidal plots in this grid. 
    +Hence total number of pyramidal and inverse pyramidal plots is 2 + 0 = 2.
    +
    + +

    Example 2:

    + +
    +Input: grid = [[1,1,1],[1,1,1]]
    +Output: 2
    +Explanation: The pyramidal plot is shown in blue, and the inverse pyramidal plot is shown in red. 
    +Hence the total number of plots is 1 + 1 = 2.
    +
    + +

    Example 3:

    + +
    +Input: grid = [[1,1,1,1,0],[1,1,1,1,1],[1,1,1,1,1],[0,1,0,0,1]]
    +Output: 13
    +Explanation: There are 7 pyramidal plots, 3 of which are shown in the 2nd and 3rd figures.
    +There are 6 inverse pyramidal plots, 2 of which are shown in the last figure.
    +The total number of plots is 7 + 6 = 13.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 1000
    • +
    • 1 <= m * n <= 105
    • +
    • grid[i][j] is either 0 or 1.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Think about how dynamic programming can help solve the problem. +
    + +
    +Hint 2 +For any fixed cell (r, c), can you calculate the maximum height of the pyramid for which it is the apex? Let us denote this value as dp[r][c]. +
    + +
    +Hint 3 +How will the values at dp[r+1][c-1] and dp[r+1][c+1] help in determining the value at dp[r][c]? +
    + +
    +Hint 4 +For the cell (r, c), is there a relation between the number of pyramids for which it serves as the apex and dp[r][c]? How does it help in calculating the answer? +
    diff --git a/problems/count-good-meals/README.md b/problems/count-good-meals/README.md index a79cf7106..472223138 100644 --- a/problems/count-good-meals/README.md +++ b/problems/count-good-meals/README.md @@ -48,6 +48,11 @@ Their respective sums are 4, 8, 8, and 16, all of which are powers of 2. [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] +### Similar Questions + 1. [Two Sum](../two-sum) (Easy) + 1. [Max Number of K-Sum Pairs](../max-number-of-k-sum-pairs) (Medium) + 1. [Find All Possible Recipes from Given Supplies](../find-all-possible-recipes-from-given-supplies) (Medium) + ### Hints
    Hint 1 diff --git a/problems/count-good-nodes-in-binary-tree/README.md b/problems/count-good-nodes-in-binary-tree/README.md index acab1defb..4a8baa459 100644 --- a/problems/count-good-nodes-in-binary-tree/README.md +++ b/problems/count-good-nodes-in-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../simplified-fractions "Simplified Fractions") diff --git a/problems/count-good-triplets/README.md b/problems/count-good-triplets/README.md index 782b76d51..10a302420 100644 --- a/problems/count-good-triplets/README.md +++ b/problems/count-good-triplets/README.md @@ -56,9 +56,6 @@ [[Array](../../tag/array/README.md)] [[Enumeration](../../tag/enumeration/README.md)] -### Similar Questions - 1. [Count Special Quadruplets](../count-special-quadruplets) (Easy) - ### Hints
    Hint 1 diff --git a/problems/count-largest-group/README.md b/problems/count-largest-group/README.md index 577545eae..38160b260 100644 --- a/problems/count-largest-group/README.md +++ b/problems/count-largest-group/README.md @@ -11,9 +11,11 @@ ## [1399. Count Largest Group (Easy)](https://leetcode.com/problems/count-largest-group "统计最大组的数目") -

    Given an integer n. Each number from 1 to n is grouped according to the sum of its digits. 

    +

    You are given an integer n.

    -

    Return how many groups have the largest size.

    +

    Each number from 1 to n is grouped according to the sum of its digits.

    + +

    Return the number of groups that have the largest size.

     

    Example 1:

    @@ -22,7 +24,8 @@ Input: n = 13 Output: 4 Explanation: There are 9 groups in total, they are grouped according sum of its digits of numbers from 1 to 13: -[1,10], [2,11], [3,12], [4,13], [5], [6], [7], [8], [9]. There are 4 groups with largest size. +[1,10], [2,11], [3,12], [4,13], [5], [6], [7], [8], [9]. +There are 4 groups with largest size.

    Example 2:

    @@ -33,25 +36,11 @@ Explanation: There are 2 groups [1], [2] of size 1.
    -

    Example 3:

    - -
    -Input: n = 15
    -Output: 6
    -
    - -

    Example 4:

    - -
    -Input: n = 24
    -Output: 5
    -
    -

     

    Constraints:

      -
    • 1 <= n <= 10^4
    • +
    • 1 <= n <= 104
    ### Related Topics diff --git a/problems/count-negative-numbers-in-a-sorted-matrix/README.md b/problems/count-negative-numbers-in-a-sorted-matrix/README.md index b9aac1ed8..7bfda52f4 100644 --- a/problems/count-negative-numbers-in-a-sorted-matrix/README.md +++ b/problems/count-negative-numbers-in-a-sorted-matrix/README.md @@ -29,20 +29,6 @@ Output: 0 -

    Example 3:

    - -
    -Input: grid = [[1,-1],[-1,-1]]
    -Output: 3
    -
    - -

    Example 4:

    - -
    -Input: grid = [[-1]]
    -Output: 1
    -
    -

     

    Constraints:

    diff --git a/problems/count-nice-pairs-in-an-array/README.md b/problems/count-nice-pairs-in-an-array/README.md index ce79ee89e..5cc54e815 100644 --- a/problems/count-nice-pairs-in-an-array/README.md +++ b/problems/count-nice-pairs-in-an-array/README.md @@ -52,6 +52,9 @@ [[Math](../../tag/math/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Number of Pairs of Interchangeable Rectangles](../number-of-pairs-of-interchangeable-rectangles) (Medium) + ### Hints
    Hint 1 diff --git a/problems/count-nodes-equal-to-sum-of-descendants/README.md b/problems/count-nodes-equal-to-sum-of-descendants/README.md index 4edd6ed06..3008e7d1d 100644 --- a/problems/count-nodes-equal-to-sum-of-descendants/README.md +++ b/problems/count-nodes-equal-to-sum-of-descendants/README.md @@ -9,7 +9,7 @@                  [Next >](../minimum-time-to-type-word-using-special-typewriter "Minimum Time to Type Word Using Special Typewriter") -## [1973. Count Nodes Equal to Sum of Descendants (Medium)](https://leetcode.com/problems/count-nodes-equal-to-sum-of-descendants "") +## [1973. Count Nodes Equal to Sum of Descendants (Medium)](https://leetcode.com/problems/count-nodes-equal-to-sum-of-descendants "值等于子节点值之和的节点数量") diff --git a/problems/count-number-of-pairs-with-absolute-difference-k/README.md b/problems/count-number-of-pairs-with-absolute-difference-k/README.md index 29e70cae0..588fa71df 100644 --- a/problems/count-number-of-pairs-with-absolute-difference-k/README.md +++ b/problems/count-number-of-pairs-with-absolute-difference-k/README.md @@ -63,6 +63,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/count-number-of-teams/README.md b/problems/count-number-of-teams/README.md index 2f27f44d2..2fb55323d 100644 --- a/problems/count-number-of-teams/README.md +++ b/problems/count-number-of-teams/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-lucky-integer-in-an-array "Find Lucky Integer in an Array") @@ -57,9 +57,9 @@ ### Related Topics + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] ### Hints
    diff --git a/problems/count-of-smaller-numbers-after-self/README.md b/problems/count-of-smaller-numbers-after-self/README.md index 84bfffbb5..70e0604bd 100644 --- a/problems/count-of-smaller-numbers-after-self/README.md +++ b/problems/count-of-smaller-numbers-after-self/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-tree-vertical-order-traversal "Binary Tree Vertical Order Traversal") @@ -49,16 +49,15 @@ To the right of 1 there is 0 smaller element. ### Related Topics + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] - [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] - [[Segment Tree](../../tag/segment-tree/README.md)] - [[Merge Sort](../../tag/merge-sort/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] + [[Merge Sort](../../tag/merge-sort/README.md)] ### Similar Questions 1. [Count of Range Sum](../count-of-range-sum) (Hard) 1. [Queue Reconstruction by Height](../queue-reconstruction-by-height) (Medium) 1. [Reverse Pairs](../reverse-pairs) (Hard) - 1. [How Many Numbers Are Smaller Than the Current Number](../how-many-numbers-are-smaller-than-the-current-number) (Easy) diff --git a/problems/count-operations-to-obtain-zero/README.md b/problems/count-operations-to-obtain-zero/README.md new file mode 100644 index 000000000..019bc3626 --- /dev/null +++ b/problems/count-operations-to-obtain-zero/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../unique-substrings-with-equal-digit-frequency "Unique Substrings With Equal Digit Frequency") +                 +[Next >](../minimum-operations-to-make-the-array-alternating "Minimum Operations to Make the Array Alternating") + +## [2169. Count Operations to Obtain Zero (Easy)](https://leetcode.com/problems/count-operations-to-obtain-zero "得到 0 的操作数") + +

    You are given two non-negative integers num1 and num2.

    + +

    In one operation, if num1 >= num2, you must subtract num2 from num1, otherwise subtract num1 from num2.

    + +
      +
    • For example, if num1 = 5 and num2 = 4, subtract num2 from num1, thus obtaining num1 = 1 and num2 = 4. However, if num1 = 4 and num2 = 5, after one operation, num1 = 4 and num2 = 1.
    • +
    + +

    Return the number of operations required to make either num1 = 0 or num2 = 0.

    + +

     

    +

    Example 1:

    + +
    +Input: num1 = 2, num2 = 3
    +Output: 3
    +Explanation: 
    +- Operation 1: num1 = 2, num2 = 3. Since num1 < num2, we subtract num1 from num2 and get num1 = 2, num2 = 3 - 2 = 1.
    +- Operation 2: num1 = 2, num2 = 1. Since num1 > num2, we subtract num2 from num1.
    +- Operation 3: num1 = 1, num2 = 1. Since num1 == num2, we subtract num2 from num1.
    +Now num1 = 0 and num2 = 1. Since num1 == 0, we do not need to perform any further operations.
    +So the total number of operations required is 3.
    +
    + +

    Example 2:

    + +
    +Input: num1 = 10, num2 = 10
    +Output: 1
    +Explanation: 
    +- Operation 1: num1 = 10, num2 = 10. Since num1 == num2, we subtract num2 from num1 and get num1 = 10 - 10 = 0.
    +Now num1 = 0 and num2 = 10. Since num1 == 0, we are done.
    +So the total number of operations required is 1.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= num1, num2 <= 105
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Try simulating the process until either of the two integers is zero. +
    + +
    +Hint 2 +Count the number of operations done. +
    diff --git a/problems/count-pairs-in-two-arrays/README.md b/problems/count-pairs-in-two-arrays/README.md index f7cdb43e0..82a198799 100644 --- a/problems/count-pairs-in-two-arrays/README.md +++ b/problems/count-pairs-in-two-arrays/README.md @@ -9,7 +9,7 @@                  [Next >](../determine-whether-matrix-can-be-obtained-by-rotation "Determine Whether Matrix Can Be Obtained By Rotation") -## [1885. Count Pairs in Two Arrays (Medium)](https://leetcode.com/problems/count-pairs-in-two-arrays "") +## [1885. Count Pairs in Two Arrays (Medium)](https://leetcode.com/problems/count-pairs-in-two-arrays "统计数对") diff --git a/problems/count-pairs-with-xor-in-a-range/README.md b/problems/count-pairs-with-xor-in-a-range/README.md index 8195188bb..1f7764e98 100644 --- a/problems/count-pairs-with-xor-in-a-range/README.md +++ b/problems/count-pairs-with-xor-in-a-range/README.md @@ -55,9 +55,9 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Trie](../../tag/trie/README.md)] - [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/count-servers-that-communicate/README.md b/problems/count-servers-that-communicate/README.md index b5454c4ec..5e4c3cca0 100644 --- a/problems/count-servers-that-communicate/README.md +++ b/problems/count-servers-that-communicate/README.md @@ -57,12 +57,12 @@ Return the number of servers that communicate with any other server.

    ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] - [[Counting](../../tag/counting/README.md)] [[Matrix](../../tag/matrix/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/count-student-number-in-departments/README.md b/problems/count-student-number-in-departments/README.md index dc03eb901..089034b63 100644 --- a/problems/count-student-number-in-departments/README.md +++ b/problems/count-student-number-in-departments/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-cumulative-salary-of-an-employee "Find Cumulative Salary of an Employee") diff --git a/problems/count-student-number-in-departments/mysql_schemas.sql b/problems/count-student-number-in-departments/mysql_schemas.sql index e4e479904..618e4666d 100644 --- a/problems/count-student-number-in-departments/mysql_schemas.sql +++ b/problems/count-student-number-in-departments/mysql_schemas.sql @@ -1,10 +1,10 @@ -CREATE TABLE IF NOT EXISTS student (student_id INT,student_name VARCHAR(45), gender VARCHAR(6), dept_id INT); -CREATE TABLE IF NOT EXISTS department (dept_id INT, dept_name VARCHAR(255)); -Truncate table student; -insert into student (student_id, student_name, gender, dept_id) values ('1', 'Jack', 'M', '1'); -insert into student (student_id, student_name, gender, dept_id) values ('2', 'Jane', 'F', '1'); -insert into student (student_id, student_name, gender, dept_id) values ('3', 'Mark', 'M', '2'); -Truncate table department; -insert into department (dept_id, dept_name) values ('1', 'Engineering'); -insert into department (dept_id, dept_name) values ('2', 'Science'); -insert into department (dept_id, dept_name) values ('3', 'Law'); +Create table If Not Exists Student (student_id int,student_name varchar(45), gender varchar(6), dept_id int); +Create table If Not Exists Department (dept_id int, dept_name varchar(255)); +Truncate table Student; +insert into Student (student_id, student_name, gender, dept_id) values ('1', 'Jack', 'M', '1'); +insert into Student (student_id, student_name, gender, dept_id) values ('2', 'Jane', 'F', '1'); +insert into Student (student_id, student_name, gender, dept_id) values ('3', 'Mark', 'M', '2'); +Truncate table Department; +insert into Department (dept_id, dept_name) values ('1', 'Engineering'); +insert into Department (dept_id, dept_name) values ('2', 'Science'); +insert into Department (dept_id, dept_name) values ('3', 'Law'); diff --git a/problems/count-sub-islands/README.md b/problems/count-sub-islands/README.md index 3bc57c1ed..03d87c466 100644 --- a/problems/count-sub-islands/README.md +++ b/problems/count-sub-islands/README.md @@ -47,12 +47,17 @@ The 1s colored red in grid2 are those considered to be part of a sub-island. The ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Number of Islands](../number-of-islands) (Medium) + 1. [Number of Distinct Islands](../number-of-distinct-islands) (Medium) + 1. [Find All Groups of Farmland](../find-all-groups-of-farmland) (Medium) + ### Hints
    Hint 1 diff --git a/problems/count-subarrays-with-more-ones-than-zeros/README.md b/problems/count-subarrays-with-more-ones-than-zeros/README.md index 6b4eea3b1..e91e1a9cf 100644 --- a/problems/count-subarrays-with-more-ones-than-zeros/README.md +++ b/problems/count-subarrays-with-more-ones-than-zeros/README.md @@ -9,7 +9,7 @@                  [Next >](../two-out-of-three "Two Out of Three") -## [2031. Count Subarrays With More Ones Than Zeros (Medium)](https://leetcode.com/problems/count-subarrays-with-more-ones-than-zeros "") +## [2031. Count Subarrays With More Ones Than Zeros (Medium)](https://leetcode.com/problems/count-subarrays-with-more-ones-than-zeros "1 比 0 多的子数组个数") diff --git a/problems/count-substrings-that-differ-by-one-character/README.md b/problems/count-substrings-that-differ-by-one-character/README.md index dc837a236..4250e2fc0 100644 --- a/problems/count-substrings-that-differ-by-one-character/README.md +++ b/problems/count-substrings-that-differ-by-one-character/README.md @@ -25,7 +25,7 @@
     Input: s = "aba", t = "baba"
     Output: 6
    -Explanation: The following are the pairs of substrings from s and t that differ by exactly 1 character:
    +Explanation: The following are the pairs of substrings from s and t that differ by exactly 1 character:
     ("aba", "baba")
     ("aba", "baba")
     ("aba", "baba")
    @@ -39,25 +39,12 @@ The underlined portions are the substrings that are chosen from s and t.
     
     Input: s = "ab", t = "bb"
     Output: 3
    -Explanation: The following are the pairs of substrings from s and t that differ by 1 character:
    +Explanation: The following are the pairs of substrings from s and t that differ by 1 character:
     ("ab", "bb")
     ("ab", "bb")
     ("ab", "bb")
     ​​​​The underlined portions are the substrings that are chosen from s and t.
     
    -Example 3: - -
    -Input: s = "a", t = "a"
    -Output: 0
    -
    - -

    Example 4:

    - -
    -Input: s = "abe", t = "bbc"
    -Output: 10
    -

     

    Constraints:

    @@ -72,6 +59,9 @@ The underlined portions are the substrings that are chosen from s and t. [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Count Words Obtained After Adding a Letter](../count-words-obtained-after-adding-a-letter) (Medium) + ### Hints
    Hint 1 diff --git a/problems/count-subtrees-with-max-distance-between-cities/README.md b/problems/count-subtrees-with-max-distance-between-cities/README.md index b2fafe331..4b8a8e661 100644 --- a/problems/count-subtrees-with-max-distance-between-cities/README.md +++ b/problems/count-subtrees-with-max-distance-between-cities/README.md @@ -61,14 +61,11 @@ No subtree has two nodes where the max distance between them is 3. ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Tree](../../tag/tree/README.md)] - [[Enumeration](../../tag/enumeration/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bitmask](../../tag/bitmask/README.md)] - -### Similar Questions - 1. [Tree Diameter](../tree-diameter) (Medium) + [[Enumeration](../../tag/enumeration/README.md)] ### Hints
    diff --git a/problems/count-the-hidden-sequences/README.md b/problems/count-the-hidden-sequences/README.md new file mode 100644 index 000000000..7b6dd0bc0 --- /dev/null +++ b/problems/count-the-hidden-sequences/README.md @@ -0,0 +1,96 @@ + + + + + + + +[< Previous](../minimum-cost-of-buying-candies-with-discount "Minimum Cost of Buying Candies With Discount") +                 +[Next >](../k-highest-ranked-items-within-a-price-range "K Highest Ranked Items Within a Price Range") + +## [2145. Count the Hidden Sequences (Medium)](https://leetcode.com/problems/count-the-hidden-sequences "统计隐藏数组数目") + +

    You are given a 0-indexed array of n integers differences, which describes the differences between each pair of consecutive integers of a hidden sequence of length (n + 1). More formally, call the hidden sequence hidden, then we have that differences[i] = hidden[i + 1] - hidden[i].

    + +

    You are further given two integers lower and upper that describe the inclusive range of values [lower, upper] that the hidden sequence can contain.

    + +
      +
    • For example, given differences = [1, -3, 4], lower = 1, upper = 6, the hidden sequence is a sequence of length 4 whose elements are in between 1 and 6 (inclusive). +
        +
      • [3, 4, 1, 5] and [4, 5, 2, 6] are possible hidden sequences.
      • +
      • [5, 6, 3, 7] is not possible since it contains an element greater than 6.
      • +
      • [1, 2, 3, 4] is not possible since the differences are not correct.
      • +
      +
    • +
    + +

    Return the number of possible hidden sequences there are. If there are no possible sequences, return 0.

    + +

     

    +

    Example 1:

    + +
    +Input: differences = [1,-3,4], lower = 1, upper = 6
    +Output: 2
    +Explanation: The possible hidden sequences are:
    +- [3, 4, 1, 5]
    +- [4, 5, 2, 6]
    +Thus, we return 2.
    +
    + +

    Example 2:

    + +
    +Input: differences = [3,-4,5,1,-2], lower = -4, upper = 5
    +Output: 4
    +Explanation: The possible hidden sequences are:
    +- [-3, 0, -4, 1, 2, 0]
    +- [-2, 1, -3, 2, 3, 1]
    +- [-1, 2, -2, 3, 4, 2]
    +- [0, 3, -1, 4, 5, 3]
    +Thus, we return 4.
    +
    + +

    Example 3:

    + +
    +Input: differences = [4,-7,2], lower = 3, upper = 6
    +Output: 0
    +Explanation: There are no possible hidden sequences. Thus, we return 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == differences.length
    • +
    • 1 <= n <= 105
    • +
    • -105 <= differences[i] <= 105
    • +
    • -105 <= lower <= upper <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +Fix the first element of the hidden sequence to any value x and ignore the given bounds. Notice that we can then determine all the other elements of the sequence by using the differences array. +
    + +
    +Hint 2 +We will also be able to determine the difference between the minimum and maximum elements of the sequence. Notice that the value of x does not affect this. +
    + +
    +Hint 3 +We now have the ‘range’ of the sequence (difference between min and max element), we can then calculate how many ways there are to fit this range into the given range of lower to upper. +
    + +
    +Hint 4 +Answer is (upper - lower + 1) - (range of sequence) +
    diff --git a/problems/count-the-number-of-consistent-strings/README.md b/problems/count-the-number-of-consistent-strings/README.md index e96a04d61..0149ed188 100644 --- a/problems/count-the-number-of-consistent-strings/README.md +++ b/problems/count-the-number-of-consistent-strings/README.md @@ -52,10 +52,10 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/count-the-number-of-experiments/README.md b/problems/count-the-number-of-experiments/README.md index 004d98070..32f1a9733 100644 --- a/problems/count-the-number-of-experiments/README.md +++ b/problems/count-the-number-of-experiments/README.md @@ -9,6 +9,6 @@                  [Next >](../find-the-middle-index-in-array "Find the Middle Index in Array") -## [1990. Count the Number of Experiments (Easy)](https://leetcode.com/problems/count-the-number-of-experiments "") +## [1990. Count the Number of Experiments (Easy)](https://leetcode.com/problems/count-the-number-of-experiments "统计实验的数量") diff --git a/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md b/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md index db696b55f..54729a4f0 100644 --- a/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md +++ b/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md @@ -11,7 +11,7 @@ ## [1442. Count Triplets That Can Form Two Arrays of Equal XOR (Medium)](https://leetcode.com/problems/count-triplets-that-can-form-two-arrays-of-equal-xor "形成两个异或相等数组的三元组数目") -

    Given an array of integers arr.

    +

    Given an array of integers arr.

    We want to select three indices i, j and k where (0 <= i < j <= k < arr.length).

    @@ -42,33 +42,12 @@ Output: 10
    -

    Example 3:

    - -
    -Input: arr = [2,3]
    -Output: 0
    -
    - -

    Example 4:

    - -
    -Input: arr = [1,3,5,7,9]
    -Output: 3
    -
    - -

    Example 5:

    - -
    -Input: arr = [7,11,12,9,5,2,7,17,22]
    -Output: 8
    -
    -

     

    Constraints:

    • 1 <= arr.length <= 300
    • -
    • 1 <= arr[i] <= 10^8
    • +
    • 1 <= arr[i] <= 108
    ### Related Topics diff --git a/problems/count-vowel-substrings-of-a-string/README.md b/problems/count-vowel-substrings-of-a-string/README.md index f66f9ed84..29a590805 100644 --- a/problems/count-vowel-substrings-of-a-string/README.md +++ b/problems/count-vowel-substrings-of-a-string/README.md @@ -48,14 +48,7 @@ - "cuaieuouac" - "cuaieuouac" - "cuaieuouac" -- "cuaieuouac" - -

    Example 4:

    - -
    -Input: word = "bbaeixoubb"
    -Output: 0
    -Explanation: The only substrings that contain all five vowels also contain consonants, so there are no vowel substrings.
    +- "cuaieuouac"
     

     

    diff --git a/problems/count-words-obtained-after-adding-a-letter/README.md b/problems/count-words-obtained-after-adding-a-letter/README.md new file mode 100644 index 000000000..b182d8fbc --- /dev/null +++ b/problems/count-words-obtained-after-adding-a-letter/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../minimum-swaps-to-group-all-1s-together-ii "Minimum Swaps to Group All 1's Together II") +                 +[Next >](../earliest-possible-day-of-full-bloom "Earliest Possible Day of Full Bloom") + +## [2135. Count Words Obtained After Adding a Letter (Medium)](https://leetcode.com/problems/count-words-obtained-after-adding-a-letter "统计追加字母可以获得的单词数") + +

    You are given two 0-indexed arrays of strings startWords and targetWords. Each string consists of lowercase English letters only.

    + +

    For each string in targetWords, check if it is possible to choose a string from startWords and perform a conversion operation on it to be equal to that from targetWords.

    + +

    The conversion operation is described in the following two steps:

    + +
      +
    1. Append any lowercase letter that is not present in the string to its end. +
        +
      • For example, if the string is "abc", the letters 'd', 'e', or 'y' can be added to it, but not 'a'. If 'd' is added, the resulting string will be "abcd".
      • +
      +
    2. +
    3. Rearrange the letters of the new string in any arbitrary order. +
        +
      • For example, "abcd" can be rearranged to "acbd", "bacd", "cbda", and so on. Note that it can also be rearranged to "abcd" itself.
      • +
      +
    4. +
    + +

    Return the number of strings in targetWords that can be obtained by performing the operations on any string of startWords.

    + +

    Note that you will only be verifying if the string in targetWords can be obtained from a string in startWords by performing the operations. The strings in startWords do not actually change during this process.

    + +

     

    +

    Example 1:

    + +
    +Input: startWords = ["ant","act","tack"], targetWords = ["tack","act","acti"]
    +Output: 2
    +Explanation:
    +- In order to form targetWords[0] = "tack", we use startWords[1] = "act", append 'k' to it, and rearrange "actk" to "tack".
    +- There is no string in startWords that can be used to obtain targetWords[1] = "act".
    +  Note that "act" does exist in startWords, but we must append one letter to the string before rearranging it.
    +- In order to form targetWords[2] = "acti", we use startWords[1] = "act", append 'i' to it, and rearrange "acti" to "acti" itself.
    +
    + +

    Example 2:

    + +
    +Input: startWords = ["ab","a"], targetWords = ["abc","abcd"]
    +Output: 1
    +Explanation:
    +- In order to form targetWords[0] = "abc", we use startWords[0] = "ab", add 'c' to it, and rearrange it to "abc".
    +- There is no string in startWords that can be used to obtain targetWords[1] = "abcd".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= startWords.length, targetWords.length <= 5 * 104
    • +
    • 1 <= startWords[i].length, targetWords[j].length <= 26
    • +
    • Each string of startWords and targetWords consists of lowercase English letters only.
    • +
    • No letter occurs more than once in any string of startWords or targetWords.
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Which data structure can be used to efficiently check if a string exists in startWords? +
    + +
    +Hint 2 +After appending a letter, all letters of a string can be rearranged in any possible way. How can we use this to reduce our search space while checking if a string in targetWords can be obtained from a string in startWords? +
    diff --git a/problems/counting-bits/README.md b/problems/counting-bits/README.md index 52e02d477..edcd0c085 100644 --- a/problems/counting-bits/README.md +++ b/problems/counting-bits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../house-robber-iii "House Robber III") @@ -55,8 +55,8 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Number of 1 Bits](../number-of-1-bits) (Easy) diff --git a/problems/countries-you-can-safely-invest-in/README.md b/problems/countries-you-can-safely-invest-in/README.md index 0450b8cee..75a1ea51b 100644 --- a/problems/countries-you-can-safely-invest-in/README.md +++ b/problems/countries-you-can-safely-invest-in/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Average Salary: Departments VS Company](../average-salary-departments-vs-company) (Hard) diff --git a/problems/create-a-session-bar-chart/README.md b/problems/create-a-session-bar-chart/README.md index 9bf7444db..2d98529f9 100644 --- a/problems/create-a-session-bar-chart/README.md +++ b/problems/create-a-session-bar-chart/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-wear-different-hats-to-each-other "Number of Ways to Wear Different Hats to Each Other") diff --git a/problems/create-target-array-in-the-given-order/README.md b/problems/create-target-array-in-the-given-order/README.md index 26cc2be14..ed80d4212 100644 --- a/problems/create-target-array-in-the-given-order/README.md +++ b/problems/create-target-array-in-the-given-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../pizza-with-3n-slices "Pizza With 3n Slices") diff --git a/problems/decode-the-slanted-ciphertext/README.md b/problems/decode-the-slanted-ciphertext/README.md index 413cba302..b6fac51a5 100644 --- a/problems/decode-the-slanted-ciphertext/README.md +++ b/problems/decode-the-slanted-ciphertext/README.md @@ -55,14 +55,6 @@ The blue arrows show how we can find originalText from encodedText. Explanation: Since there is only 1 row, both originalText and encodedText are the same. -

    Example 4:

    - -
    -Input: encodedText = " b  ac", rows = 2
    -Output: " abc"
    -Explanation: originalText cannot have trailing spaces, but it may be preceded by one or more spaces.
    -
    -

     

    Constraints:

    diff --git a/problems/decode-ways-ii/README.md b/problems/decode-ways-ii/README.md index d8a78212b..7e825db0d 100644 --- a/problems/decode-ways-ii/README.md +++ b/problems/decode-ways-ii/README.md @@ -81,3 +81,4 @@ Hence, there are a total of (6 * 2) + (3 * 1) = 12 + 3 = 15 ways to decode " ### Similar Questions 1. [Decode Ways](../decode-ways) (Medium) 1. [Number of Ways to Separate Numbers](../number-of-ways-to-separate-numbers) (Hard) + 1. [Number of Ways to Divide a Long Corridor](../number-of-ways-to-divide-a-long-corridor) (Hard) diff --git a/problems/decode-xored-permutation/README.md b/problems/decode-xored-permutation/README.md index c848d7942..f1782835e 100644 --- a/problems/decode-xored-permutation/README.md +++ b/problems/decode-xored-permutation/README.md @@ -43,8 +43,8 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md b/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md index e7eb154e6..51121f55c 100644 --- a/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md +++ b/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md @@ -11,16 +11,16 @@ ## [1309. Decrypt String from Alphabet to Integer Mapping (Easy)](https://leetcode.com/problems/decrypt-string-from-alphabet-to-integer-mapping "解码字母到整数映射") -

    Given a string s formed by digits ('0' - '9') and '#' . We want to map s to English lowercase characters as follows:

    +

    You are given a string s formed by digits and '#'. We want to map s to English lowercase characters as follows:

      -
    • Characters ('a' to 'i') are represented by ('1' to '9') respectively.
    • -
    • Characters ('j' to 'z') are represented by ('10#' to '26#') respectively. 
    • +
    • Characters ('a' to 'i') are represented by ('1' to '9') respectively.
    • +
    • Characters ('j' to 'z') are represented by ('10#' to '26#') respectively.
    -

    Return the string formed after mapping.

    +

    Return the string formed after mapping.

    -

    It's guaranteed that a unique mapping will always exist.

    +

    The test cases are generated so that a unique mapping will always exist.

     

    Example 1:

    @@ -38,27 +38,13 @@ Output: "acz" -

    Example 3:

    - -
    -Input: s = "25#"
    -Output: "y"
    -
    - -

    Example 4:

    - -
    -Input: s = "12345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#"
    -Output: "abcdefghijklmnopqrstuvwxyz"
    -
    -

     

    Constraints:

    • 1 <= s.length <= 1000
    • -
    • s[i] only contains digits letters ('0'-'9') and '#' letter.
    • -
    • s will be valid string such that mapping is always possible.
    • +
    • s consists of digits and the '#' letter.
    • +
    • s will be a valid string such that mapping is always possible.
    ### Related Topics diff --git a/problems/deepest-leaves-sum/README.md b/problems/deepest-leaves-sum/README.md index 91cae7c59..82c34bc7f 100644 --- a/problems/deepest-leaves-sum/README.md +++ b/problems/deepest-leaves-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-paths-with-max-score "Number of Paths with Max Score") diff --git a/problems/degree-of-an-array/README.md b/problems/degree-of-an-array/README.md index 691229adc..46abd362f 100644 --- a/problems/degree-of-an-array/README.md +++ b/problems/degree-of-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-binary-substrings "Count Binary Substrings") diff --git a/problems/delete-duplicate-emails/README.md b/problems/delete-duplicate-emails/README.md index b3669d52c..f2ba686fb 100644 --- a/problems/delete-duplicate-emails/README.md +++ b/problems/delete-duplicate-emails/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tenth-line "Tenth Line") @@ -11,33 +11,49 @@ ## [196. Delete Duplicate Emails (Easy)](https://leetcode.com/problems/delete-duplicate-emails "删除重复的电子邮箱") -

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id.

    +

    Table: Person

    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| id          | int     |
    +| email       | varchar |
    ++-------------+---------+
    +id is the primary key column for this table.
    +Each row of this table contains an email. The emails will not contain uppercase letters.
    +
    + +

     

    + +

    Write an SQL query to delete all the duplicate emails, keeping only one unique email with the smallest id. Note that you are supposed to write a DELETE statement and not a SELECT one.

    + +

    Return the result table in any order.

    + +

    The query result format is in the following example.

    + +

     

    +

    Example 1:

    + +
    +Input: 
    +Person table:
     +----+------------------+
    -| Id | Email            |
    +| id | email            |
     +----+------------------+
     | 1  | john@example.com |
     | 2  | bob@example.com  |
     | 3  | john@example.com |
     +----+------------------+
    -Id is the primary key column for this table.
    -
    - -

    For example, after running your query, the above Person table should have the following rows:

    - -
    +Output: 
     +----+------------------+
    -| Id | Email            |
    +| id | email            |
     +----+------------------+
     | 1  | john@example.com |
     | 2  | bob@example.com  |
     +----+------------------+
    +Explanation: john@example.com is repeated two times. We keep the row with the smallest Id = 1.
     
    -

    Note:

    - -

    Your output is the whole Person table after executing your sql. Use delete statement.

    - ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/delete-duplicate-emails/mysql_schemas.sql b/problems/delete-duplicate-emails/mysql_schemas.sql index 89062100e..6ee53bdfa 100644 --- a/problems/delete-duplicate-emails/mysql_schemas.sql +++ b/problems/delete-duplicate-emails/mysql_schemas.sql @@ -1,4 +1,5 @@ +Create table If Not Exists Person (Id int, Email varchar(255)); Truncate table Person; -insert into Person (Id, Email) values ('1', 'john@example.com'); -insert into Person (Id, Email) values ('2', 'bob@example.com'); -insert into Person (Id, Email) values ('3', 'john@example.com'); +insert into Person (id, email) values ('1', 'john@example.com'); +insert into Person (id, email) values ('2', 'bob@example.com'); +insert into Person (id, email) values ('3', 'john@example.com'); diff --git a/problems/delete-duplicate-folders-in-system/README.md b/problems/delete-duplicate-folders-in-system/README.md index 4bb81e72f..7e5d89477 100644 --- a/problems/delete-duplicate-folders-in-system/README.md +++ b/problems/delete-duplicate-folders-in-system/README.md @@ -69,29 +69,6 @@ Note that folders "/a" and "/c" are identical after the dele Note that the returned array can be in a different order as the order does not matter. -

    Example 4:

    - -
    -Input: paths = [["a"],["a","x"],["a","x","y"],["a","z"],["b"],["b","x"],["b","x","y"],["b","z"]]
    -Output: []
    -Explanation: The file structure is as shown.
    -Folders "/a/x" and "/b/x" (and their subfolders) are marked for deletion because they both contain an
    -empty folder named "y".
    -Folders "/a" and "/b" (and their subfolders) are marked for deletion because they both contain an empty
    -folder "z" and the folder "x" described above.
    -
    - -

    Example 5:

    - -
    -Input: paths = [["a"],["a","x"],["a","x","y"],["a","z"],["b"],["b","x"],["b","x","y"],["b","z"],["b","w"]]
    -Output: [["b"],["b","w"],["b","z"],["a"],["a","z"]]
    -Explanation: This has the same structure as the previous example, except with the added "/b/w".
    -Folders "/a/x" and "/b/x" are still marked, but "/a" and "/b" are no longer marked because "/b" has the
    -empty folder named "w" and "/a" does not.
    -Note that "/a/z" and "/b/z" are not marked because the set of identical subfolders must be non-empty, but these folders are empty.
    -
    -

     

    Constraints:

    diff --git a/problems/delete-leaves-with-a-given-value/README.md b/problems/delete-leaves-with-a-given-value/README.md index d581caa4a..1b4d423df 100644 --- a/problems/delete-leaves-with-a-given-value/README.md +++ b/problems/delete-leaves-with-a-given-value/README.md @@ -11,14 +11,14 @@ ## [1325. Delete Leaves With a Given Value (Medium)](https://leetcode.com/problems/delete-leaves-with-a-given-value "删除给定值的叶子节点") -

    Given a binary tree root and an integer target, delete all the leaf nodes with value target.

    +

    Given a binary tree root and an integer target, delete all the leaf nodes with value target.

    -

    Note that once you delete a leaf node with value targetif it's parent node becomes a leaf node and has the value target, it should also be deleted (you need to continue doing that until you can't).

    +

    Note that once you delete a leaf node with value target, if its parent node becomes a leaf node and has the value target, it should also be deleted (you need to continue doing that until you cannot).

     

    Example 1:

    -

    +

     Input: root = [1,2,3,2,null,2,4], target = 2
    @@ -29,7 +29,7 @@ After removing, new nodes become leaf nodes with value (target = 2) (Picture in
     
     

    Example 2:

    -

    +

     Input: root = [1,3,3,3,2], target = 3
    @@ -38,7 +38,7 @@ After removing, new nodes become leaf nodes with value (target = 2) (Picture in
     
     

    Example 3:

    -

    +

     Input: root = [1,2,null,2,null,2], target = 2
    @@ -46,34 +46,19 @@ After removing, new nodes become leaf nodes with value (target = 2) (Picture in
     Explanation: Leaf nodes in green with value (target = 2) are removed at each step.
     
    -

    Example 4:

    - -
    -Input: root = [1,1,1], target = 1
    -Output: []
    -
    - -

    Example 5:

    - -
    -Input: root = [1,2,3], target = 1
    -Output: [1,2,3]
    -
    -

     

    Constraints:

      -
    • 1 <= target <= 1000
    • -
    • The given binary tree will have between 1 and 3000 nodes.
    • -
    • Each node's value is between [1, 1000].
    • +
    • The number of nodes in the tree is in the range [1, 3000].
    • +
    • 1 <= Node.val, target <= 1000
    ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md b/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md index e73b8b5f1..9c97fa0c3 100644 --- a/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md +++ b/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../paint-house-iii "Paint House III") diff --git a/problems/delete-the-middle-node-of-a-linked-list/README.md b/problems/delete-the-middle-node-of-a-linked-list/README.md new file mode 100644 index 000000000..e88e98744 --- /dev/null +++ b/problems/delete-the-middle-node-of-a-linked-list/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../finding-3-digit-even-numbers "Finding 3-Digit Even Numbers") +                 +[Next >](../step-by-step-directions-from-a-binary-tree-node-to-another "Step-By-Step Directions From a Binary Tree Node to Another") + +## [2095. Delete the Middle Node of a Linked List (Medium)](https://leetcode.com/problems/delete-the-middle-node-of-a-linked-list "删除链表的中间节点") + +

    You are given the head of a linked list. Delete the middle node, and return the head of the modified linked list.

    + +

    The middle node of a linked list of size n is the ⌊n / 2⌋th node from the start using 0-based indexing, where ⌊x⌋ denotes the largest integer less than or equal to x.

    + +
      +
    • For n = 1, 2, 3, 4, and 5, the middle nodes are 0, 1, 1, 2, and 2, respectively.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: head = [1,3,4,7,1,2,6]
    +Output: [1,3,4,1,2,6]
    +Explanation:
    +The above figure represents the given linked list. The indices of the nodes are written below.
    +Since n = 7, node 3 with value 7 is the middle node, which is marked in red.
    +We return the new list after removing this node. 
    +
    + +

    Example 2:

    + +
    +Input: head = [1,2,3,4]
    +Output: [1,2,4]
    +Explanation:
    +The above figure represents the given linked list.
    +For n = 4, node 2 with value 3 is the middle node, which is marked in red.
    +
    + +

    Example 3:

    + +
    +Input: head = [2,1]
    +Output: [2]
    +Explanation:
    +The above figure represents the given linked list.
    +For n = 2, node 1 with value 1 is the middle node, which is marked in red.
    +Node 0 with value 2 is the only node remaining after removing node 1.
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is in the range [1, 105].
    • +
    • 1 <= Node.val <= 105
    • +
    + +### Related Topics + [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + +### Hints +
    +Hint 1 +If a point with a speed s moves n units in a given time, a point with speed 2 * s will move 2 * n units at the same time. Can you use this to find the middle node of a linked list? +
    + +
    +Hint 2 +If you are given the middle node, the node before it, and the node after it, how can you modify the linked list? +
    diff --git a/problems/delivering-boxes-from-storage-to-ports/README.md b/problems/delivering-boxes-from-storage-to-ports/README.md index a282ef700..a72e47f52 100644 --- a/problems/delivering-boxes-from-storage-to-ports/README.md +++ b/problems/delivering-boxes-from-storage-to-ports/README.md @@ -69,21 +69,6 @@ So the total number of trips is 2 + 2 + 2 = 6. So the total number of trips is 2 + 2 + 2 = 6.
    -

    Example 4:

    - -
    -Input: boxes = [[2,4],[2,5],[3,1],[3,2],[3,7],[3,1],[4,4],[1,3],[5,2]], portsCount = 5, maxBoxes = 5, maxWeight = 7
    -Output: 14
    -Explanation: The optimal strategy is as follows:
    -- The ship takes the first box, goes to port 2, then storage. 2 trips.
    -- The ship takes the second box, goes to port 2, then storage. 2 trips.
    -- The ship takes the third and fourth boxes, goes to port 3, then storage. 2 trips.
    -- The ship takes the fifth box, goes to port 3, then storage. 2 trips.
    -- The ship takes the sixth and seventh boxes, goes to port 3, then port 4, then storage. 3 trips. 
    -- The ship takes the eighth and ninth boxes, goes to port 1, then port 5, then storage. 3 trips.
    -So the total number of trips is 2 + 2 + 2 + 2 + 3 + 3 = 14.
    -
    -

     

    Constraints:

    diff --git a/problems/depth-of-bst-given-insertion-order/README.md b/problems/depth-of-bst-given-insertion-order/README.md index 87f0d6196..ecf971b20 100644 --- a/problems/depth-of-bst-given-insertion-order/README.md +++ b/problems/depth-of-bst-given-insertion-order/README.md @@ -9,7 +9,7 @@                  [Next >](../largest-odd-number-in-string "Largest Odd Number in String") -## [1902. Depth of BST Given Insertion Order (Medium)](https://leetcode.com/problems/depth-of-bst-given-insertion-order "") +## [1902. Depth of BST Given Insertion Order (Medium)](https://leetcode.com/problems/depth-of-bst-given-insertion-order "给定二叉搜索树的插入顺序求深度") diff --git a/problems/describe-the-painting/README.md b/problems/describe-the-painting/README.md index edda7d60e..ac2cbbea4 100644 --- a/problems/describe-the-painting/README.md +++ b/problems/describe-the-painting/README.md @@ -85,6 +85,10 @@ Note that returning a single segment [1,7) is incorrect because the mixed color [[Array](../../tag/array/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] +### Similar Questions + 1. [Average Height of Buildings in Each Segment](../average-height-of-buildings-in-each-segment) (Medium) + 1. [Amount of New Area Painted Each Day](../amount-of-new-area-painted-each-day) (Hard) + ### Hints
    Hint 1 diff --git a/problems/design-a-file-sharing-system/README.md b/problems/design-a-file-sharing-system/README.md index 0eee8641a..ff0ae03e8 100644 --- a/problems/design-a-file-sharing-system/README.md +++ b/problems/design-a-file-sharing-system/README.md @@ -14,10 +14,13 @@ ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Data Stream](../../tag/data-stream/README.md)] + [[Design](../../tag/design/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] + +### Similar Questions + 1. [Design Twitter](../design-twitter) (Medium) ### Hints
    diff --git a/problems/design-bitset/README.md b/problems/design-bitset/README.md new file mode 100644 index 000000000..2cbd3a0ed --- /dev/null +++ b/problems/design-bitset/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../smallest-value-of-the-rearranged-number "Smallest Value of the Rearranged Number") +                 +[Next >](../minimum-time-to-remove-all-cars-containing-illegal-goods "Minimum Time to Remove All Cars Containing Illegal Goods") + +## [2166. Design Bitset (Medium)](https://leetcode.com/problems/design-bitset "设计位集") + +

    A Bitset is a data structure that compactly stores bits.

    + +

    Implement the Bitset class:

    + +
      +
    • Bitset(int size) Initializes the Bitset with size bits, all of which are 0.
    • +
    • void fix(int idx) Updates the value of the bit at the index idx to 1. If the value was already 1, no change occurs.
    • +
    • void unfix(int idx) Updates the value of the bit at the index idx to 0. If the value was already 0, no change occurs.
    • +
    • void flip() Flips the values of each bit in the Bitset. In other words, all bits with value 0 will now have value 1 and vice versa.
    • +
    • boolean all() Checks if the value of each bit in the Bitset is 1. Returns true if it satisfies the condition, false otherwise.
    • +
    • boolean one() Checks if there is at least one bit in the Bitset with value 1. Returns true if it satisfies the condition, false otherwise.
    • +
    • int count() Returns the total number of bits in the Bitset which have value 1.
    • +
    • String toString() Returns the current composition of the Bitset. Note that in the resultant string, the character at the ith index should coincide with the value at the ith bit of the Bitset.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input
    +["Bitset", "fix", "fix", "flip", "all", "unfix", "flip", "one", "unfix", "count", "toString"]
    +[[5], [3], [1], [], [], [0], [], [], [0], [], []]
    +Output
    +[null, null, null, null, false, null, null, true, null, 2, "01010"]
    +
    +Explanation
    +Bitset bs = new Bitset(5); // bitset = "00000".
    +bs.fix(3);     // the value at idx = 3 is updated to 1, so bitset = "00010".
    +bs.fix(1);     // the value at idx = 1 is updated to 1, so bitset = "01010". 
    +bs.flip();     // the value of each bit is flipped, so bitset = "10101". 
    +bs.all();      // return False, as not all values of the bitset are 1.
    +bs.unfix(0);   // the value at idx = 0 is updated to 0, so bitset = "00101".
    +bs.flip();     // the value of each bit is flipped, so bitset = "11010". 
    +bs.one();      // return True, as there is at least 1 index with value 1.
    +bs.unfix(0);   // the value at idx = 0 is updated to 0, so bitset = "01010".
    +bs.count();    // return 2, as there are 2 bits with value 1.
    +bs.toString(); // return "01010", which is the composition of bitset.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= size <= 105
    • +
    • 0 <= idx <= size - 1
    • +
    • At most 105 calls will be made in total to fix, unfix, flip, all, one, count, and toString.
    • +
    • At least one call will be made to all, one, count, or toString.
    • +
    • At most 5 calls will be made to toString.
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +Note that flipping a bit twice does nothing. +
    + +
    +Hint 2 +In order to determine the value of a bit, consider how you can efficiently count the number of flips made on the bit since its latest update. +
    diff --git a/problems/design-excel-sum-formula/README.md b/problems/design-excel-sum-formula/README.md index aa80932d7..367ed9cca 100644 --- a/problems/design-excel-sum-formula/README.md +++ b/problems/design-excel-sum-formula/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../course-schedule-iii "Course Schedule III") diff --git a/problems/design-file-system/README.md b/problems/design-file-system/README.md index 5d8630e7f..c37500d85 100644 --- a/problems/design-file-system/README.md +++ b/problems/design-file-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../single-row-keyboard "Single-Row Keyboard") diff --git a/problems/design-hashmap/README.md b/problems/design-hashmap/README.md index 14ef975d5..ede07f6c4 100644 --- a/problems/design-hashmap/README.md +++ b/problems/design-hashmap/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-hashset "Design HashSet") @@ -53,11 +53,12 @@ myHashMap.get(2); // return -1 (i.e., not found), The map is now [[1,1]] ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Design](../../tag/design/README.md)] [[Hash Function](../../tag/hash-function/README.md)] ### Similar Questions 1. [Design HashSet](../design-hashset) (Easy) + 1. [Design Skiplist](../design-skiplist) (Hard) diff --git a/problems/design-log-storage-system/README.md b/problems/design-log-storage-system/README.md index 1560bb852..9f35d631e 100644 --- a/problems/design-log-storage-system/README.md +++ b/problems/design-log-storage-system/README.md @@ -38,9 +38,9 @@ retrieve("2016:01:01:01:01:01","2017:01:01:23:00:00","Hour"); // return [1,2], b

    ### Related Topics + [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Design](../../tag/design/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions diff --git a/problems/design-movie-rental-system/README.md b/problems/design-movie-rental-system/README.md index 7d30137c7..8f579b4f1 100644 --- a/problems/design-movie-rental-system/README.md +++ b/problems/design-movie-rental-system/README.md @@ -69,11 +69,11 @@ movieRentingSystem.search(2); // return [0, 1]. Movies of ID 2 are unrented at ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] + [[Design](../../tag/design/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Hints
    diff --git a/problems/design-parking-system/README.md b/problems/design-parking-system/README.md index c3e886f43..3b78047ab 100644 --- a/problems/design-parking-system/README.md +++ b/problems/design-parking-system/README.md @@ -49,8 +49,8 @@ parkingSystem.addCar(1); // return false because there is no available slot for ### Related Topics [[Design](../../tag/design/README.md)] - [[Counting](../../tag/counting/README.md)] [[Simulation](../../tag/simulation/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/design-skiplist/README.md b/problems/design-skiplist/README.md index c4e2f39fa..07f2933c2 100644 --- a/problems/design-skiplist/README.md +++ b/problems/design-skiplist/README.md @@ -66,5 +66,10 @@ skiplist.search(1); // return False, 1 has already been erased.
    ### Related Topics - [[Design](../../tag/design/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Design](../../tag/design/README.md)] + +### Similar Questions + 1. [Design HashSet](../design-hashset) (Easy) + 1. [Design HashMap](../design-hashmap) (Easy) + 1. [Design Linked List](../design-linked-list) (Medium) diff --git a/problems/design-snake-game/README.md b/problems/design-snake-game/README.md index 16eb867f5..d4a133824 100644 --- a/problems/design-snake-game/README.md +++ b/problems/design-snake-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../data-stream-as-disjoint-intervals "Data Stream as Disjoint Intervals") diff --git a/problems/design-underground-system/README.md b/problems/design-underground-system/README.md index 3c3d61dd4..07d725874 100644 --- a/problems/design-underground-system/README.md +++ b/problems/design-underground-system/README.md @@ -101,9 +101,12 @@ undergroundSystem.getAverageTime("Leyton", "Paradise"); // r ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] + +### Similar Questions + 1. [Design Bitset](../design-bitset) (Medium) ### Hints
    diff --git a/problems/destroying-asteroids/README.md b/problems/destroying-asteroids/README.md new file mode 100644 index 000000000..f1ff813bf --- /dev/null +++ b/problems/destroying-asteroids/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../number-of-laser-beams-in-a-bank "Number of Laser Beams in a Bank") +                 +[Next >](../maximum-employees-to-be-invited-to-a-meeting "Maximum Employees to Be Invited to a Meeting") + +## [2126. Destroying Asteroids (Medium)](https://leetcode.com/problems/destroying-asteroids "摧毁小行星") + +

    You are given an integer mass, which represents the original mass of a planet. You are further given an integer array asteroids, where asteroids[i] is the mass of the ith asteroid.

    + +

    You can arrange for the planet to collide with the asteroids in any arbitrary order. If the mass of the planet is greater than or equal to the mass of the asteroid, the asteroid is destroyed and the planet gains the mass of the asteroid. Otherwise, the planet is destroyed.

    + +

    Return true if all asteroids can be destroyed. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: mass = 10, asteroids = [3,9,19,5,21]
    +Output: true
    +Explanation: One way to order the asteroids is [9,19,5,3,21]:
    +- The planet collides with the asteroid with a mass of 9. New planet mass: 10 + 9 = 19
    +- The planet collides with the asteroid with a mass of 19. New planet mass: 19 + 19 = 38
    +- The planet collides with the asteroid with a mass of 5. New planet mass: 38 + 5 = 43
    +- The planet collides with the asteroid with a mass of 3. New planet mass: 43 + 3 = 46
    +- The planet collides with the asteroid with a mass of 21. New planet mass: 46 + 21 = 67
    +All asteroids are destroyed.
    +
    + +

    Example 2:

    + +
    +Input: mass = 5, asteroids = [4,9,23,4]
    +Output: false
    +Explanation: 
    +The planet cannot ever gain enough mass to destroy the asteroid with a mass of 23.
    +After the planet destroys the other asteroids, it will have a mass of 5 + 4 + 9 + 4 = 22.
    +This is less than 23, so a collision would not destroy the last asteroid.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= mass <= 105
    • +
    • 1 <= asteroids.length <= 105
    • +
    • 1 <= asteroids[i] <= 105
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Choosing the asteroid to collide with can be done greedily. +
    + +
    +Hint 2 +If an asteroid will destroy the planet, then every bigger asteroid will also destroy the planet. +
    + +
    +Hint 3 +You only need to check the smallest asteroid at each collision. If it will destroy the planet, then every other asteroid will also destroy the planet. +
    + +
    +Hint 4 +Sort the asteroids in non-decreasing order by mass, then greedily try to collide with the asteroids in that order. +
    diff --git a/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md b/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md index e154bfa69..6f2fcdace 100644 --- a/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md +++ b/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md @@ -11,11 +11,11 @@ ## [1566. Detect Pattern of Length M Repeated K or More Times (Easy)](https://leetcode.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times "重复至少 K 次且长度为 M 的模式") -

    Given an array of positive integers arr,  find a pattern of length m that is repeated k or more times.

    +

    Given an array of positive integers arr, find a pattern of length m that is repeated k or more times.

    A pattern is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times consecutively without overlapping. A pattern is defined by its length and the number of repetitions.

    -

    Return true if there exists a pattern of length m that is repeated k or more times, otherwise return false.

    +

    Return true if there exists a pattern of length m that is repeated k or more times, otherwise return false.

     

    Example 1:

    @@ -42,36 +42,23 @@ Explanation: The pattern (1,2) is of length 2 but is repeated only 2 times. There is no pattern of length 2 that is repeated 3 or more times. -

    Example 4:

    - -
    -Input: arr = [1,2,3,1,2], m = 2, k = 2
    -Output: false
    -Explanation: Notice that the pattern (1,2) exists twice but not consecutively, so it doesn't count.
    -
    - -

    Example 5:

    - -
    -Input: arr = [2,2,2,2], m = 2, k = 3
    -Output: false
    -Explanation: The only pattern of length 2 is (2,2) however it's repeated only twice. Notice that we do not count overlapping repetitions.
    -
    -

     

    Constraints:

    • 2 <= arr.length <= 100
    • 1 <= arr[i] <= 100
    • -
    • 1 <= m <= 100
    • -
    • 2 <= k <= 100
    • +
    • 1 <= m <= 100
    • +
    • 2 <= k <= 100
    ### Related Topics [[Array](../../tag/array/README.md)] [[Enumeration](../../tag/enumeration/README.md)] +### Similar Questions + 1. [Maximum Repeating Substring](../maximum-repeating-substring) (Easy) + ### Hints
    Hint 1 diff --git a/problems/determine-if-string-halves-are-alike/README.md b/problems/determine-if-string-halves-are-alike/README.md index c436e1ff8..8f0453b94 100644 --- a/problems/determine-if-string-halves-are-alike/README.md +++ b/problems/determine-if-string-halves-are-alike/README.md @@ -23,7 +23,7 @@
     Input: s = "book"
     Output: true
    -Explanation: a = "bo" and b = "ok". a has 1 vowel and b has 1 vowel. Therefore, they are alike.
    +Explanation: a = "bo" and b = "ok". a has 1 vowel and b has 1 vowel. Therefore, they are alike.
     

    Example 2:

    @@ -31,24 +31,10 @@
     Input: s = "textbook"
     Output: false
    -Explanation: a = "text" and b = "book". a has 1 vowel whereas b has 2. Therefore, they are not alike.
    +Explanation: a = "text" and b = "book". a has 1 vowel whereas b has 2. Therefore, they are not alike.
     Notice that the vowel o is counted twice.
     
    -

    Example 3:

    - -
    -Input: s = "MerryChristmas"
    -Output: false
    -
    - -

    Example 4:

    - -
    -Input: s = "AbCdEfGh"
    -Output: true
    -
    -

     

    Constraints:

    diff --git a/problems/determine-if-two-strings-are-close/README.md b/problems/determine-if-two-strings-are-close/README.md index 9da101df9..a6740f403 100644 --- a/problems/determine-if-two-strings-are-close/README.md +++ b/problems/determine-if-two-strings-are-close/README.md @@ -60,14 +60,6 @@ Apply Operation 1: "cabbba" -> "caabbb Apply Operation 2: "baaccc" -> "abbccc" -

    Example 4:

    - -
    -Input: word1 = "cabbba", word2 = "aabbss"
    -Output: false
    -Explanation: It is impossible to attain word2 from word1, or vice versa, in any amount of operations.
    -
    -

     

    Constraints:

    @@ -81,11 +73,6 @@ Apply Operation 2: "baaccc" -> "abbccc" [[String](../../tag/string/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Buddy Strings](../buddy-strings) (Easy) - 1. [Minimum Swaps to Make Strings Equal](../minimum-swaps-to-make-strings-equal) (Medium) - 1. [Minimum Number of Steps to Make Two Strings Anagram](../minimum-number-of-steps-to-make-two-strings-anagram) (Medium) - ### Hints
    Hint 1 diff --git a/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md b/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md index 3f86bc907..dc07d77be 100644 --- a/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md +++ b/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md @@ -52,6 +52,9 @@ [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Rotate Image](../rotate-image) (Medium) + ### Hints
    Hint 1 diff --git a/problems/detonate-the-maximum-bombs/README.md b/problems/detonate-the-maximum-bombs/README.md new file mode 100644 index 000000000..2a7ecfe4b --- /dev/null +++ b/problems/detonate-the-maximum-bombs/README.md @@ -0,0 +1,93 @@ + + + + + + + +[< Previous](../find-good-days-to-rob-the-bank "Find Good Days to Rob the Bank") +                 +[Next >](../sequentially-ordinal-rank-tracker "Sequentially Ordinal Rank Tracker") + +## [2101. Detonate the Maximum Bombs (Medium)](https://leetcode.com/problems/detonate-the-maximum-bombs "引爆最多的炸弹") + +

    You are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the center as the location of the bomb.

    + +

    The bombs are represented by a 0-indexed 2D integer array bombs where bombs[i] = [xi, yi, ri]. xi and yi denote the X-coordinate and Y-coordinate of the location of the ith bomb, whereas ri denotes the radius of its range.

    + +

    You may choose to detonate a single bomb. When a bomb is detonated, it will detonate all bombs that lie in its range. These bombs will further detonate the bombs that lie in their ranges.

    + +

    Given the list of bombs, return the maximum number of bombs that can be detonated if you are allowed to detonate only one bomb.

    + +

     

    +

    Example 1:

    + +
    +Input: bombs = [[2,1,3],[6,1,4]]
    +Output: 2
    +Explanation:
    +The above figure shows the positions and ranges of the 2 bombs.
    +If we detonate the left bomb, the right bomb will not be affected.
    +But if we detonate the right bomb, both bombs will be detonated.
    +So the maximum bombs that can be detonated is max(1, 2) = 2.
    +
    + +

    Example 2:

    + +
    +Input: bombs = [[1,1,5],[10,10,5]]
    +Output: 1
    +Explanation:
    +Detonating either bomb will not detonate the other bomb, so the maximum number of bombs that can be detonated is 1.
    +
    + +

    Example 3:

    + +
    +Input: bombs = [[1,2,3],[2,3,1],[3,4,2],[4,5,3],[5,6,4]]
    +Output: 5
    +Explanation:
    +The best bomb to detonate is bomb 0 because:
    +- Bomb 0 detonates bombs 1 and 2. The red circle denotes the range of bomb 0.
    +- Bomb 2 detonates bomb 3. The blue circle denotes the range of bomb 2.
    +- Bomb 3 detonates bomb 4. The green circle denotes the range of bomb 3.
    +Thus all 5 bombs are detonated.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= bombs.length <= 100
    • +
    • bombs[i].length == 3
    • +
    • 1 <= xi, yi, ri <= 105
    • +
    + +### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +How can we model the relationship between different bombs? Can "graphs" help us? +
    + +
    +Hint 2 +Bombs are nodes and are connected to other bombs in their range by directed edges. +
    + +
    +Hint 3 +If we know which bombs will be affected when any bomb is detonated, how can we find the total number of bombs that will be detonated if we start from a fixed bomb? +
    + +
    +Hint 4 +Run a Depth First Search (DFS) from every node, and all the nodes it reaches are the bombs that will be detonated. +
    diff --git a/problems/diagonal-traverse-ii/README.md b/problems/diagonal-traverse-ii/README.md index 89e88c505..f0f505c37 100644 --- a/problems/diagonal-traverse-ii/README.md +++ b/problems/diagonal-traverse-ii/README.md @@ -11,48 +11,31 @@ ## [1424. Diagonal Traverse II (Medium)](https://leetcode.com/problems/diagonal-traverse-ii "对角线遍历 II") -Given a list of lists of integers, nums, return all elements of nums in diagonal order as shown in the below images. +

    Given a 2D integer array nums, return all elements of nums in diagonal order as shown in the below images.

    +

     

    Example 1:

    - -

    - +
     Input: nums = [[1,2,3],[4,5,6],[7,8,9]]
     Output: [1,4,2,7,5,3,8,6,9]
     

    Example 2:

    - -

    - +
     Input: nums = [[1,2,3,4,5],[6,7],[8],[9,10,11],[12,13,14,15,16]]
     Output: [1,6,2,8,7,3,9,4,12,10,5,13,11,14,15,16]
     
    -

    Example 3:

    - -
    -Input: nums = [[1,2,3],[4],[5,6,7],[8],[9,10,11]]
    -Output: [1,4,2,5,3,8,6,9,7,10,11]
    -
    - -

    Example 4:

    - -
    -Input: nums = [[1,2,3,4,5,6]]
    -Output: [1,2,3,4,5,6]
    -
    -

     

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • 1 <= nums[i].length <= 10^5
    • -
    • 1 <= nums[i][j] <= 10^9
    • -
    • There at most 10^5 elements in nums.
    • +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i].length <= 105
    • +
    • 1 <= sum(nums[i].length) <= 105
    • +
    • 1 <= nums[i][j] <= 105
    ### Related Topics diff --git a/problems/diameter-of-binary-tree/README.md b/problems/diameter-of-binary-tree/README.md index 2af34eb9c..afe2198fb 100644 --- a/problems/diameter-of-binary-tree/README.md +++ b/problems/diameter-of-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../01-matrix "01 Matrix") @@ -45,3 +45,6 @@ [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] + +### Similar Questions + 1. [Diameter of N-Ary Tree](../diameter-of-n-ary-tree) (Medium) diff --git a/problems/distant-barcodes/README.md b/problems/distant-barcodes/README.md index cf6019f5a..dc8ebc8b1 100644 --- a/problems/distant-barcodes/README.md +++ b/problems/distant-barcodes/README.md @@ -32,12 +32,12 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Counting](../../tag/counting/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/distinct-echo-substrings/README.md b/problems/distinct-echo-substrings/README.md index de3a4e081..e27254199 100644 --- a/problems/distinct-echo-substrings/README.md +++ b/problems/distinct-echo-substrings/README.md @@ -39,12 +39,12 @@ ### Related Topics + [[Trie](../../tag/trie/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Trie](../../tag/trie/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Rolling Hash](../../tag/rolling-hash/README.md)] [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/distribute-coins-in-binary-tree/README.md b/problems/distribute-coins-in-binary-tree/README.md index bca1db8a7..fe77331b2 100644 --- a/problems/distribute-coins-in-binary-tree/README.md +++ b/problems/distribute-coins-in-binary-tree/README.md @@ -19,7 +19,7 @@

     

    Example 1:

    - +
     Input: root = [3,0,0]
     Output: 2
    @@ -27,27 +27,13 @@
     

    Example 2:

    - +
     Input: root = [0,3,0]
     Output: 3
     Explanation: From the left child of the root, we move two coins to the root [taking two moves]. Then, we move one coin from the root of the tree to the right child.
     
    -

    Example 3:

    - -
    -Input: root = [1,0,2]
    -Output: 2
    -
    - -

    Example 4:

    - -
    -Input: root = [1,0,0,null,3]
    -Output: 4
    -
    -

     

    Constraints:

    diff --git a/problems/distribute-repeating-integers/README.md b/problems/distribute-repeating-integers/README.md index aa9699270..c9c238bd3 100644 --- a/problems/distribute-repeating-integers/README.md +++ b/problems/distribute-repeating-integers/README.md @@ -27,7 +27,7 @@
     Input: nums = [1,2,3,4], quantity = [2]
     Output: false
    -Explanation: The 0th customer cannot be given two different integers.
    +Explanation: The 0th customer cannot be given two different integers.
     

    Example 2:

    @@ -35,7 +35,7 @@
     Input: nums = [1,2,3,3], quantity = [2]
     Output: true
    -Explanation: The 0th customer is given [3,3]. The integers [1,2] are not used.
    +Explanation: The 0th customer is given [3,3]. The integers [1,2] are not used.
     

    Example 3:

    @@ -43,22 +43,7 @@
     Input: nums = [1,1,2,2], quantity = [2,2]
     Output: true
    -Explanation: The 0th customer is given [1,1], and the 1st customer is given [2,2].
    -
    - -

    Example 4:

    - -
    -Input: nums = [1,1,2,3], quantity = [2,2]
    -Output: false
    -Explanation: Although the 0th customer could be given [1,1], the 1st customer cannot be satisfied.
    - -

    Example 5:

    - -
    -Input: nums = [1,1,1,1,1], quantity = [2,3]
    -Output: true
    -Explanation: The 0th customer is given [1,1], and the 1st customer is given [1,1,1].
    +Explanation: The 0th customer is given [1,1], and the 1st customer is given [2,2].
     

     

    diff --git a/problems/divide-a-string-into-groups-of-size-k/README.md b/problems/divide-a-string-into-groups-of-size-k/README.md new file mode 100644 index 000000000..f7fc58e35 --- /dev/null +++ b/problems/divide-a-string-into-groups-of-size-k/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../pour-water-between-buckets-to-make-water-levels-equal "Pour Water Between Buckets to Make Water Levels Equal") +                 +[Next >](../minimum-moves-to-reach-target-score "Minimum Moves to Reach Target Score") + +## [2138. Divide a String Into Groups of Size k (Easy)](https://leetcode.com/problems/divide-a-string-into-groups-of-size-k "将字符串拆分为若干长度为 k 的组") + +

    A string s can be partitioned into groups of size k using the following procedure:

    + +
      +
    • The first group consists of the first k characters of the string, the second group consists of the next k characters of the string, and so on. Each character can be a part of exactly one group.
    • +
    • For the last group, if the string does not have k characters remaining, a character fill is used to complete the group.
    • +
    + +

    Note that the partition is done so that after removing the fill character from the last group (if it exists) and concatenating all the groups in order, the resultant string should be s.

    + +

    Given the string s, the size of each group k and the character fill, return a string array denoting the composition of every group s has been divided into, using the above procedure.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "abcdefghi", k = 3, fill = "x"
    +Output: ["abc","def","ghi"]
    +Explanation:
    +The first 3 characters "abc" form the first group.
    +The next 3 characters "def" form the second group.
    +The last 3 characters "ghi" form the third group.
    +Since all groups can be completely filled by characters from the string, we do not need to use fill.
    +Thus, the groups formed are "abc", "def", and "ghi".
    +
    + +

    Example 2:

    + +
    +Input: s = "abcdefghij", k = 3, fill = "x"
    +Output: ["abc","def","ghi","jxx"]
    +Explanation:
    +Similar to the previous example, we are forming the first three groups "abc", "def", and "ghi".
    +For the last group, we can only use the character 'j' from the string. To complete this group, we add 'x' twice.
    +Thus, the 4 groups formed are "abc", "def", "ghi", and "jxx".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 100
    • +
    • s consists of lowercase English letters only.
    • +
    • 1 <= k <= 100
    • +
    • fill is a lowercase English letter.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Using the length of the string and k, can you count the number of groups the string can be divided into? +
    + +
    +Hint 2 +Try completing each group using characters from the string. If there aren’t enough characters for the last group, use the fill character to complete the group. +
    diff --git a/problems/dot-product-of-two-sparse-vectors/README.md b/problems/dot-product-of-two-sparse-vectors/README.md index 0c36b471c..4dd93440a 100644 --- a/problems/dot-product-of-two-sparse-vectors/README.md +++ b/problems/dot-product-of-two-sparse-vectors/README.md @@ -14,10 +14,10 @@ ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Design](../../tag/design/README.md)] ### Hints
    diff --git a/problems/drop-type-1-orders-for-customers-with-type-0-orders/README.md b/problems/drop-type-1-orders-for-customers-with-type-0-orders/README.md index 1a73e08ea..015d77373 100644 --- a/problems/drop-type-1-orders-for-customers-with-type-0-orders/README.md +++ b/problems/drop-type-1-orders-for-customers-with-type-0-orders/README.md @@ -7,8 +7,11 @@ [< Previous](../substrings-that-begin-and-end-with-the-same-letter "Substrings That Begin and End With the Same Letter")                  -Next > +[Next >](../count-common-words-with-one-occurrence "Count Common Words With One Occurrence") -## [2084. Drop Type 1 Orders for Customers With Type 0 Orders (Medium)](https://leetcode.com/problems/drop-type-1-orders-for-customers-with-type-0-orders "") +## [2084. Drop Type 1 Orders for Customers With Type 0 Orders (Medium)](https://leetcode.com/problems/drop-type-1-orders-for-customers-with-type-0-orders "为订单类型为 0 的客户删除类型为 1 的订单") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/earliest-possible-day-of-full-bloom/README.md b/problems/earliest-possible-day-of-full-bloom/README.md new file mode 100644 index 000000000..ac699a6ed --- /dev/null +++ b/problems/earliest-possible-day-of-full-bloom/README.md @@ -0,0 +1,95 @@ + + + + + + + +[< Previous](../count-words-obtained-after-adding-a-letter "Count Words Obtained After Adding a Letter") +                 +[Next >](../pour-water-between-buckets-to-make-water-levels-equal "Pour Water Between Buckets to Make Water Levels Equal") + +## [2136. Earliest Possible Day of Full Bloom (Hard)](https://leetcode.com/problems/earliest-possible-day-of-full-bloom "全部开花的最早一天") + +

    You have n flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two 0-indexed integer arrays plantTime and growTime, of length n each:

    + +
      +
    • plantTime[i] is the number of full days it takes you to plant the ith seed. Every day, you can work on planting exactly one seed. You do not have to work on planting the same seed on consecutive days, but the planting of a seed is not complete until you have worked plantTime[i] days on planting it in total.
    • +
    • growTime[i] is the number of full days it takes the ith seed to grow after being completely planted. After the last day of its growth, the flower blooms and stays bloomed forever.
    • +
    + +

    From the beginning of day 0, you can plant the seeds in any order.

    + +

    Return the earliest possible day where all seeds are blooming.

    + +

     

    +

    Example 1:

    + +
    +Input: plantTime = [1,4,3], growTime = [2,3,1]
    +Output: 9
    +Explanation: The grayed out pots represent planting days, colored pots represent growing days, and the flower represents the day it blooms.
    +One optimal way is:
    +On day 0, plant the 0th seed. The seed grows for 2 full days and blooms on day 3.
    +On days 1, 2, 3, and 4, plant the 1st seed. The seed grows for 3 full days and blooms on day 8.
    +On days 5, 6, and 7, plant the 2nd seed. The seed grows for 1 full day and blooms on day 9.
    +Thus, on day 9, all the seeds are blooming.
    +
    + +

    Example 2:

    + +
    +Input: plantTime = [1,2,3,2], growTime = [2,1,2,1]
    +Output: 9
    +Explanation: The grayed out pots represent planting days, colored pots represent growing days, and the flower represents the day it blooms.
    +One optimal way is:
    +On day 1, plant the 0th seed. The seed grows for 2 full days and blooms on day 4.
    +On days 0 and 3, plant the 1st seed. The seed grows for 1 full day and blooms on day 5.
    +On days 2, 4, and 5, plant the 2nd seed. The seed grows for 2 full days and blooms on day 8.
    +On days 6 and 7, plant the 3rd seed. The seed grows for 1 full day and blooms on day 9.
    +Thus, on day 9, all the seeds are blooming.
    +
    + +

    Example 3:

    + +
    +Input: plantTime = [1], growTime = [1]
    +Output: 2
    +Explanation: On day 0, plant the 0th seed. The seed grows for 1 full day and blooms on day 2.
    +Thus, on day 2, all the seeds are blooming.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == plantTime.length == growTime.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= plantTime[i], growTime[i] <= 104
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +List the planting like the diagram above shows, where a row represents the timeline of a seed. A row i is above another row j if the last day planting seed i is ahead of the last day for seed j. Does it have any advantage to spend some days to plant seed j before completely planting seed i? +
    + +
    +Hint 2 +No. It does not help seed j but could potentially delay the completion of seed i, resulting in a worse final answer. Remaining focused is a part of the optimal solution. +
    + +
    +Hint 3 +Sort the seeds by their growTime in descending order. Can you prove why this strategy is the other part of the optimal solution? Note the bloom time of a seed is the sum of plantTime of all seeds preceding this seed plus the growTime of this seed. +
    + +
    +Hint 4 +There is no way to improve this strategy. The seed to bloom last dominates the final answer. Exchanging the planting of this seed with another seed with either a larger or smaller growTime will result in a potentially worse answer. +
    diff --git a/problems/egg-drop-with-2-eggs-and-n-floors/README.md b/problems/egg-drop-with-2-eggs-and-n-floors/README.md index b8408e61b..fb4e7cc26 100644 --- a/problems/egg-drop-with-2-eggs-and-n-floors/README.md +++ b/problems/egg-drop-with-2-eggs-and-n-floors/README.md @@ -54,6 +54,9 @@ Regardless of the outcome, it takes at most 14 drops to determine f. [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Super Egg Drop](../super-egg-drop) (Hard) + ### Hints
    Hint 1 diff --git a/problems/elements-in-array-after-removing-and-replacing-elements/README.md b/problems/elements-in-array-after-removing-and-replacing-elements/README.md new file mode 100644 index 000000000..745729049 --- /dev/null +++ b/problems/elements-in-array-after-removing-and-replacing-elements/README.md @@ -0,0 +1,33 @@ + + + + + + + +[< Previous](../the-airport-with-the-most-traffic "The Airport With the Most Traffic") +                 +[Next >](../maximum-number-of-words-found-in-sentences "Maximum Number of Words Found in Sentences") + +## [2113. Elements in Array After Removing and Replacing Elements (Medium)](https://leetcode.com/problems/elements-in-array-after-removing-and-replacing-elements "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Try to find a pattern in how nums changes. +
    + +
    +Hint 2 +Let m be the original length of nums. If time_i / m (integer division) is even, then nums is at its original size or decreasing in size. If it is odd, then it is empty, or increasing in size. +
    + +
    +Hint 3 +time_i % m can be used to find how many elements are in nums at minute time_i. +
    diff --git a/problems/eliminate-maximum-number-of-monsters/README.md b/problems/eliminate-maximum-number-of-monsters/README.md index 6a752338f..96c3ed4ba 100644 --- a/problems/eliminate-maximum-number-of-monsters/README.md +++ b/problems/eliminate-maximum-number-of-monsters/README.md @@ -65,8 +65,8 @@ You can only eliminate 1 monster. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/elimination-game/README.md b/problems/elimination-game/README.md index 276a8e60b..2368ac99f 100644 --- a/problems/elimination-game/README.md +++ b/problems/elimination-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-difference "Find the Difference") diff --git a/problems/employees-whose-manager-left-the-company/README.md b/problems/employees-whose-manager-left-the-company/README.md index 56eee226f..f6c3b1350 100644 --- a/problems/employees-whose-manager-left-the-company/README.md +++ b/problems/employees-whose-manager-left-the-company/README.md @@ -9,6 +9,6 @@                  [Next >](../find-greatest-common-divisor-of-array "Find Greatest Common Divisor of Array") -## [1978. Employees Whose Manager Left the Company (Easy)](https://leetcode.com/problems/employees-whose-manager-left-the-company "") +## [1978. Employees Whose Manager Left the Company (Easy)](https://leetcode.com/problems/employees-whose-manager-left-the-company "上级经理已离职的公司员工") diff --git a/problems/encode-and-decode-strings/README.md b/problems/encode-and-decode-strings/README.md index b24f694f4..b1676d0e4 100644 --- a/problems/encode-and-decode-strings/README.md +++ b/problems/encode-and-decode-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../closest-binary-search-tree-value "Closest Binary Search Tree Value") @@ -56,9 +56,9 @@ vector<string> strs2 = decode(encoded_string); ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions 1. [Count and Say](../count-and-say) (Medium) diff --git a/problems/encode-and-decode-tinyurl/README.md b/problems/encode-and-decode-tinyurl/README.md index 66c905748..da7d5d6bd 100644 --- a/problems/encode-and-decode-tinyurl/README.md +++ b/problems/encode-and-decode-tinyurl/README.md @@ -47,7 +47,7 @@ string ans = obj.decode(tiny); // returns the original url after deconding it. ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] [[Hash Function](../../tag/hash-function/README.md)] diff --git a/problems/encode-n-ary-tree-to-binary-tree/README.md b/problems/encode-n-ary-tree-to-binary-tree/README.md index 22250ebe7..4ed404913 100644 --- a/problems/encode-n-ary-tree-to-binary-tree/README.md +++ b/problems/encode-n-ary-tree-to-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flatten-a-multilevel-doubly-linked-list "Flatten a Multilevel Doubly Linked List") diff --git a/problems/equal-rational-numbers/README.md b/problems/equal-rational-numbers/README.md index 6bf83eb5e..c11e97a3a 100644 --- a/problems/equal-rational-numbers/README.md +++ b/problems/equal-rational-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flip-binary-tree-to-match-preorder-traversal "Flip Binary Tree To Match Preorder Traversal") diff --git a/problems/erect-the-fence-ii/README.md b/problems/erect-the-fence-ii/README.md index 4ca218a50..dcc541793 100644 --- a/problems/erect-the-fence-ii/README.md +++ b/problems/erect-the-fence-ii/README.md @@ -9,7 +9,7 @@                  [Next >](../count-square-sum-triples "Count Square Sum Triples") -## [1924. Erect the Fence II (Hard)](https://leetcode.com/problems/erect-the-fence-ii "") +## [1924. Erect the Fence II (Hard)](https://leetcode.com/problems/erect-the-fence-ii "安装栅栏 II") diff --git a/problems/escape-a-large-maze/README.md b/problems/escape-a-large-maze/README.md index d8546cb79..94f65508f 100644 --- a/problems/escape-a-large-maze/README.md +++ b/problems/escape-a-large-maze/README.md @@ -52,10 +52,10 @@ We cannot move south or west because we cannot go outside of the grid. ### Related Topics - [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Hints
    diff --git a/problems/evaluate-reverse-polish-notation/README.md b/problems/evaluate-reverse-polish-notation/README.md index 9db4857d2..43faff9a6 100644 --- a/problems/evaluate-reverse-polish-notation/README.md +++ b/problems/evaluate-reverse-polish-notation/README.md @@ -59,9 +59,9 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Stack](../../tag/stack/README.md)] ### Similar Questions 1. [Basic Calculator](../basic-calculator) (Hard) diff --git a/problems/evaluate-the-bracket-pairs-of-a-string/README.md b/problems/evaluate-the-bracket-pairs-of-a-string/README.md index 5e9c0c85e..dc2c9de26 100644 --- a/problems/evaluate-the-bracket-pairs-of-a-string/README.md +++ b/problems/evaluate-the-bracket-pairs-of-a-string/README.md @@ -59,12 +59,6 @@ The key "a" has a value of "yes", so replace all occurrences Notice that the "a"s not in a bracket pair are not evaluated. -

    Example 4:

    - -
    -Input: s = "(a)(b)", knowledge = [["a","b"],["b","a"]]
    -Output: "ba"
    -

     

    Constraints:

    diff --git a/problems/even-odd-tree/README.md b/problems/even-odd-tree/README.md index 2cbc1f3a2..733b0e483 100644 --- a/problems/even-odd-tree/README.md +++ b/problems/even-odd-tree/README.md @@ -23,9 +23,7 @@

     

    Example 1:

    - -

    - +
     Input: root = [1,10,4,3,null,7,9,12,8,6,null,null,2]
     Output: true
    @@ -34,13 +32,11 @@ Level 0: [1]
     Level 1: [10,4]
     Level 2: [3,7,9]
     Level 3: [12,8,6,2]
    -Since levels 0 and 2 are all odd and increasing, and levels 1 and 3 are all even and decreasing, the tree is Even-Odd.
    +Since levels 0 and 2 are all odd and increasing and levels 1 and 3 are all even and decreasing, the tree is Even-Odd.
     

    Example 2:

    - -

    - +
     Input: root = [5,4,2,3,3,7]
     Output: false
    @@ -48,33 +44,17 @@ Since levels 0 and 2 are all odd and increasing, and levels 1 and 3 are all even
     Level 0: [5]
     Level 1: [4,2]
     Level 2: [3,3,7]
    -Node values in the level 2 must be in strictly increasing order, so the tree is not Even-Odd.
    +Node values in level 2 must be in strictly increasing order, so the tree is not Even-Odd.
     

    Example 3:

    - -

    - +
     Input: root = [5,9,1,3,5,7]
     Output: false
     Explanation: Node values in the level 1 should be even integers.
     
    -

    Example 4:

    - -
    -Input: root = [1]
    -Output: true
    -
    - -

    Example 5:

    - -
    -Input: root = [11,8,6,1,3,9,11,30,20,18,16,12,10,4,2,17]
    -Output: true
    -
    -

     

    Constraints:

    diff --git a/problems/excel-sheet-column-number/README.md b/problems/excel-sheet-column-number/README.md index 2db81257f..dad535777 100644 --- a/problems/excel-sheet-column-number/README.md +++ b/problems/excel-sheet-column-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-sum-iii-data-structure-design "Two Sum III - Data structure design") @@ -48,13 +48,6 @@ AB -> 28 Output: 701 -

    Example 4:

    - -
    -Input: columnTitle = "FXSHRXW"
    -Output: 2147483647
    -
    -

     

    Constraints:

    diff --git a/problems/execution-of-all-suffix-instructions-staying-in-a-grid/README.md b/problems/execution-of-all-suffix-instructions-staying-in-a-grid/README.md new file mode 100644 index 000000000..b462fe8ea --- /dev/null +++ b/problems/execution-of-all-suffix-instructions-staying-in-a-grid/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../a-number-after-a-double-reversal "A Number After a Double Reversal") +                 +[Next >](../intervals-between-identical-elements "Intervals Between Identical Elements") + +## [2120. Execution of All Suffix Instructions Staying in a Grid (Medium)](https://leetcode.com/problems/execution-of-all-suffix-instructions-staying-in-a-grid "执行所有后缀指令") + +

    There is an n x n grid, with the top-left cell at (0, 0) and the bottom-right cell at (n - 1, n - 1). You are given the integer n and an integer array startPos where startPos = [startrow, startcol] indicates that a robot is initially at cell (startrow, startcol).

    + +

    You are also given a 0-indexed string s of length m where s[i] is the ith instruction for the robot: 'L' (move left), 'R' (move right), 'U' (move up), and 'D' (move down).

    + +

    The robot can begin executing from any ith instruction in s. It executes the instructions one by one towards the end of s but it stops if either of these conditions is met:

    + +
      +
    • The next instruction will move the robot off the grid.
    • +
    • There are no more instructions left to execute.
    • +
    + +

    Return an array answer of length m where answer[i] is the number of instructions the robot can execute if the robot begins executing from the ith instruction in s.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 3, startPos = [0,1], s = "RRDDLU"
    +Output: [1,5,4,3,1,0]
    +Explanation: Starting from startPos and beginning execution from the ith instruction:
    +- 0th: "RRDDLU". Only one instruction "R" can be executed before it moves off the grid.
    +- 1st:  "RDDLU". All five instructions can be executed while it stays in the grid and ends at (1, 1).
    +- 2nd:   "DDLU". All four instructions can be executed while it stays in the grid and ends at (1, 0).
    +- 3rd:    "DLU". All three instructions can be executed while it stays in the grid and ends at (0, 0).
    +- 4th:     "LU". Only one instruction "L" can be executed before it moves off the grid.
    +- 5th:      "U". If moving up, it would move off the grid.
    +
    + +

    Example 2:

    + +
    +Input: n = 2, startPos = [1,1], s = "LURD"
    +Output: [4,1,0,0]
    +Explanation:
    +- 0th: "LURD".
    +- 1st:  "URD".
    +- 2nd:   "RD".
    +- 3rd:    "D".
    +
    + +

    Example 3:

    + +
    +Input: n = 1, startPos = [0,0], s = "LRUD"
    +Output: [0,0,0,0]
    +Explanation: No matter which instruction the robot begins execution from, it would move off the grid.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == s.length
    • +
    • 1 <= n, m <= 500
    • +
    • startPos.length == 2
    • +
    • 0 <= startrow, startcol < n
    • +
    • s consists of 'L', 'R', 'U', and 'D'.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +The constraints are not very large. Can we simulate the execution by starting from each index of s? +
    + +
    +Hint 2 +Before any of the stopping conditions is met, stop the simulation for that index and set the answer for that index. +
    diff --git a/problems/fair-candy-swap/README.md b/problems/fair-candy-swap/README.md index 65f8226b2..dbdc443d5 100644 --- a/problems/fair-candy-swap/README.md +++ b/problems/fair-candy-swap/README.md @@ -1,15 +1,15 @@ - - - + + + [< Previous](../super-egg-drop "Super Egg Drop")                  [Next >](../construct-binary-tree-from-preorder-and-postorder-traversal "Construct Binary Tree from Preorder and Postorder Traversal") -## [888. Fair Candy Swap (Easy)](https://leetcode.com/problems/fair-candy-swap "公平的糖果棒交换") +## [888. Fair Candy Swap (Easy)](https://leetcode.com/problems/fair-candy-swap "公平的糖果交换")

    Alice and Bob have a different total number of candies. You are given two integer arrays aliceSizes and bobSizes where aliceSizes[i] is the number of candies of the ith box of candy that Alice has and bobSizes[j] is the number of candies of the jth box of candy that Bob has.

    @@ -39,13 +39,6 @@ Output: [2,3] -

    Example 4:

    - -
    -Input: aliceSizes = [1,2,5], bobSizes = [2,4]
    -Output: [5,4]
    -
    -

     

    Constraints:

    diff --git a/problems/filling-bookcase-shelves/README.md b/problems/filling-bookcase-shelves/README.md index 7906d6302..c6cf32c76 100644 --- a/problems/filling-bookcase-shelves/README.md +++ b/problems/filling-bookcase-shelves/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-in-zigzag-labelled-binary-tree "Path In Zigzag Labelled Binary Tree") diff --git a/problems/final-prices-with-a-special-discount-in-a-shop/README.md b/problems/final-prices-with-a-special-discount-in-a-shop/README.md index 25c0fa2da..7c6538477 100644 --- a/problems/final-prices-with-a-special-discount-in-a-shop/README.md +++ b/problems/final-prices-with-a-special-discount-in-a-shop/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-n-nodes-after-m-nodes-of-a-linked-list "Delete N Nodes After M Nodes of a Linked List") diff --git a/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md b/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md index 84e1c95e2..66b06bfd1 100644 --- a/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md +++ b/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../replace-employee-id-with-the-unique-identifier "Replace Employee ID With The Unique Identifier") @@ -42,20 +42,6 @@ Output: 4 -

    Example 4:

    - -
    -Input: tree = [1,2,3,4,5,6,7,8,9,10], target = 5
    -Output: 5
    -
    - -

    Example 5:

    - -
    -Input: tree = [1,2,null,3], target = 2
    -Output: 2
    -
    -

     

    Constraints:

    diff --git a/problems/find-a-peak-element-ii/README.md b/problems/find-a-peak-element-ii/README.md index cdf0afb44..c47255627 100644 --- a/problems/find-a-peak-element-ii/README.md +++ b/problems/find-a-peak-element-ii/README.md @@ -57,6 +57,9 @@ [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Find Peak Element](../find-peak-element) (Medium) + ### Hints
    Hint 1 diff --git a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md index 93a511564..bf5dc8ff7 100644 --- a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md +++ b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md @@ -53,10 +53,10 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] - [[Segment Tree](../../tag/segment-tree/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] ### Hints
    diff --git a/problems/find-all-duplicates-in-an-array/README.md b/problems/find-all-duplicates-in-an-array/README.md index c3651b409..56daee0c2 100644 --- a/problems/find-all-duplicates-in-an-array/README.md +++ b/problems/find-all-duplicates-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../arranging-coins "Arranging Coins") diff --git a/problems/find-all-lonely-numbers-in-the-array/README.md b/problems/find-all-lonely-numbers-in-the-array/README.md new file mode 100644 index 000000000..3ab667e3d --- /dev/null +++ b/problems/find-all-lonely-numbers-in-the-array/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../rearrange-array-elements-by-sign "Rearrange Array Elements by Sign") +                 +[Next >](../maximum-good-people-based-on-statements "Maximum Good People Based on Statements") + +## [2150. Find All Lonely Numbers in the Array (Medium)](https://leetcode.com/problems/find-all-lonely-numbers-in-the-array "找出数组中的所有孤独数字") + +

    You are given an integer array nums. A number x is lonely when it appears only once, and no adjacent numbers (i.e. x + 1 and x - 1) appear in the array.

    + +

    Return all lonely numbers in nums. You may return the answer in any order.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [10,6,5,8]
    +Output: [10,8]
    +Explanation: 
    +- 10 is a lonely number since it appears exactly once and 9 and 11 does not appear in nums.
    +- 8 is a lonely number since it appears exactly once and 7 and 9 does not appear in nums.
    +- 5 is not a lonely number since 6 appears in nums and vice versa.
    +Hence, the lonely numbers in nums are [10, 8].
    +Note that [8, 10] may also be returned.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,3,5,3]
    +Output: [1,5]
    +Explanation: 
    +- 1 is a lonely number since it appears exactly once and 0 and 2 does not appear in nums.
    +- 5 is a lonely number since it appears exactly once and 4 and 6 does not appear in nums.
    +- 3 is not a lonely number since it appears twice.
    +Hence, the lonely numbers in nums are [1, 5].
    +Note that [5, 1] may also be returned.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 0 <= nums[i] <= 106
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Hints +
    +Hint 1 +For a given element x, how can you quickly check if x - 1 and x + 1 are present in the array without reiterating through the entire array? +
    + +
    +Hint 2 +Use a set or a hash map. +
    diff --git a/problems/find-all-people-with-secret/README.md b/problems/find-all-people-with-secret/README.md new file mode 100644 index 000000000..0ff67d5f5 --- /dev/null +++ b/problems/find-all-people-with-secret/README.md @@ -0,0 +1,95 @@ + + + + + + + +[< Previous](../removing-minimum-and-maximum-from-array "Removing Minimum and Maximum From Array") +                 +[Next >](../minimum-cost-to-reach-city-with-discounts "Minimum Cost to Reach City With Discounts") + +## [2092. Find All People With Secret (Hard)](https://leetcode.com/problems/find-all-people-with-secret "找出知晓秘密的所有专家") + +

    You are given an integer n indicating there are n people numbered from 0 to n - 1. You are also given a 0-indexed 2D integer array meetings where meetings[i] = [xi, yi, timei] indicates that person xi and person yi have a meeting at timei. A person may attend multiple meetings at the same time. Finally, you are given an integer firstPerson.

    + +

    Person 0 has a secret and initially shares the secret with a person firstPerson at time 0. This secret is then shared every time a meeting takes place with a person that has the secret. More formally, for every meeting, if a person xi has the secret at timei, then they will share the secret with person yi, and vice versa.

    + +

    The secrets are shared instantaneously. That is, a person may receive the secret and share it with people in other meetings within the same time frame.

    + +

    Return a list of all the people that have the secret after all the meetings have taken place. You may return the answer in any order.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 6, meetings = [[1,2,5],[2,3,8],[1,5,10]], firstPerson = 1
    +Output: [0,1,2,3,5]
    +Explanation:
    +At time 0, person 0 shares the secret with person 1.
    +At time 5, person 1 shares the secret with person 2.
    +At time 8, person 2 shares the secret with person 3.
    +At time 10, person 1 shares the secret with person 5.​​​​
    +Thus, people 0, 1, 2, 3, and 5 know the secret after all the meetings.
    +
    + +

    Example 2:

    + +
    +Input: n = 4, meetings = [[3,1,3],[1,2,2],[0,3,3]], firstPerson = 3
    +Output: [0,1,3]
    +Explanation:
    +At time 0, person 0 shares the secret with person 3.
    +At time 2, neither person 1 nor person 2 know the secret.
    +At time 3, person 3 shares the secret with person 0 and person 1.
    +Thus, people 0, 1, and 3 know the secret after all the meetings.
    +
    + +

    Example 3:

    + +
    +Input: n = 5, meetings = [[3,4,2],[1,2,1],[2,3,1]], firstPerson = 1
    +Output: [0,1,2,3,4]
    +Explanation:
    +At time 0, person 0 shares the secret with person 1.
    +At time 1, person 1 shares the secret with person 2, and person 2 shares the secret with person 3.
    +Note that person 2 can share the secret at the same time as receiving it.
    +At time 2, person 3 shares the secret with person 4.
    +Thus, people 0, 1, 2, 3, and 4 know the secret after all the meetings.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 105
    • +
    • 1 <= meetings.length <= 105
    • +
    • meetings[i].length == 3
    • +
    • 0 <= xi, yi <= n - 1
    • +
    • xi != yi
    • +
    • 1 <= timei <= 105
    • +
    • 1 <= firstPerson <= n - 1
    • +
    + +### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Could you model all the meetings happening at the same time as a graph? +
    + +
    +Hint 2 +What data structure can you use to efficiently share the secret? +
    + +
    +Hint 3 +You can use the union-find data structure to quickly determine who knows the secret and share the secret. +
    diff --git a/problems/find-all-possible-recipes-from-given-supplies/README.md b/problems/find-all-possible-recipes-from-given-supplies/README.md new file mode 100644 index 000000000..a2dc609d4 --- /dev/null +++ b/problems/find-all-possible-recipes-from-given-supplies/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../maximum-number-of-words-found-in-sentences "Maximum Number of Words Found in Sentences") +                 +[Next >](../check-if-a-parentheses-string-can-be-valid "Check if a Parentheses String Can Be Valid") + +## [2115. Find All Possible Recipes from Given Supplies (Medium)](https://leetcode.com/problems/find-all-possible-recipes-from-given-supplies "从给定原材料中找到所有可以做出的菜") + +

    You have information about n different recipes. You are given a string array recipes and a 2D string array ingredients. The ith recipe has the name recipes[i], and you can create it if you have all the needed ingredients from ingredients[i]. Ingredients to a recipe may need to be created from other recipes, i.e., ingredients[i] may contain a string that is in recipes.

    + +

    You are also given a string array supplies containing all the ingredients that you initially have, and you have an infinite supply of all of them.

    + +

    Return a list of all the recipes that you can create. You may return the answer in any order.

    + +

    Note that two recipes may contain each other in their ingredients.

    + +

     

    +

    Example 1:

    + +
    +Input: recipes = ["bread"], ingredients = [["yeast","flour"]], supplies = ["yeast","flour","corn"]
    +Output: ["bread"]
    +Explanation:
    +We can create "bread" since we have the ingredients "yeast" and "flour".
    +
    + +

    Example 2:

    + +
    +Input: recipes = ["bread","sandwich"], ingredients = [["yeast","flour"],["bread","meat"]], supplies = ["yeast","flour","meat"]
    +Output: ["bread","sandwich"]
    +Explanation:
    +We can create "bread" since we have the ingredients "yeast" and "flour".
    +We can create "sandwich" since we have the ingredient "meat" and can create the ingredient "bread".
    +
    + +

    Example 3:

    + +
    +Input: recipes = ["bread","sandwich","burger"], ingredients = [["yeast","flour"],["bread","meat"],["sandwich","meat","bread"]], supplies = ["yeast","flour","meat"]
    +Output: ["bread","sandwich","burger"]
    +Explanation:
    +We can create "bread" since we have the ingredients "yeast" and "flour".
    +We can create "sandwich" since we have the ingredient "meat" and can create the ingredient "bread".
    +We can create "burger" since we have the ingredient "meat" and can create the ingredients "bread" and "sandwich".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == recipes.length == ingredients.length
    • +
    • 1 <= n <= 100
    • +
    • 1 <= ingredients[i].length, supplies.length <= 100
    • +
    • 1 <= recipes[i].length, ingredients[i][j].length, supplies[k].length <= 10
    • +
    • recipes[i], ingredients[i][j], and supplies[k] consist only of lowercase English letters.
    • +
    • All the values of recipes and supplies combined are unique.
    • +
    • Each ingredients[i] does not contain any duplicate values.
    • +
    + +### Related Topics + [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Can we use a data structure to quickly query whether we have a certain ingredient? +
    + +
    +Hint 2 +Once we verify that we can make a recipe, we can add it to our ingredient data structure. We can then check if we can make more recipes as a result of this. +
    diff --git a/problems/find-all-the-lonely-nodes/README.md b/problems/find-all-the-lonely-nodes/README.md index d0bb2cb6d..d7b5cec33 100644 --- a/problems/find-all-the-lonely-nodes/README.md +++ b/problems/find-all-the-lonely-nodes/README.md @@ -19,6 +19,10 @@ [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Binary Tree Tilt](../binary-tree-tilt) (Easy) + 1. [Univalued Binary Tree](../univalued-binary-tree) (Easy) + ### Hints
    Hint 1 diff --git a/problems/find-and-replace-in-string/README.md b/problems/find-and-replace-in-string/README.md index a7f371184..1d762c099 100644 --- a/problems/find-and-replace-in-string/README.md +++ b/problems/find-and-replace-in-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flipping-an-image "Flipping an Image") diff --git a/problems/find-and-replace-pattern/README.md b/problems/find-and-replace-pattern/README.md index f1d5c8d67..9dfda5196 100644 --- a/problems/find-and-replace-pattern/README.md +++ b/problems/find-and-replace-pattern/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-binary-tree-from-preorder-and-postorder-traversal "Construct Binary Tree from Preorder and Postorder Traversal") diff --git a/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md b/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md index d8036fa81..01117621a 100644 --- a/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md +++ b/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../avoid-flood-in-the-city "Avoid Flood in The City") diff --git a/problems/find-cutoff-score-for-each-school/README.md b/problems/find-cutoff-score-for-each-school/README.md index 5009be138..81a12ad5a 100644 --- a/problems/find-cutoff-score-for-each-school/README.md +++ b/problems/find-cutoff-score-for-each-school/README.md @@ -9,6 +9,6 @@                  [Next >](../maximum-number-of-people-that-can-be-caught-in-tag "Maximum Number of People That Can Be Caught in Tag") -## [1988. Find Cutoff Score for Each School (Medium)](https://leetcode.com/problems/find-cutoff-score-for-each-school "") +## [1988. Find Cutoff Score for Each School (Medium)](https://leetcode.com/problems/find-cutoff-score-for-each-school "找出每所学校的最低分数要求") diff --git a/problems/find-duplicate-subtrees/README.md b/problems/find-duplicate-subtrees/README.md index 13bb973a2..83c94b5a6 100644 --- a/problems/find-duplicate-subtrees/README.md +++ b/problems/find-duplicate-subtrees/README.md @@ -57,3 +57,4 @@ 1. [Serialize and Deserialize Binary Tree](../serialize-and-deserialize-binary-tree) (Hard) 1. [Serialize and Deserialize BST](../serialize-and-deserialize-bst) (Medium) 1. [Construct String from Binary Tree](../construct-string-from-binary-tree) (Easy) + 1. [Delete Duplicate Folders in System](../delete-duplicate-folders-in-system) (Hard) diff --git a/problems/find-first-and-last-position-of-element-in-sorted-array/README.md b/problems/find-first-and-last-position-of-element-in-sorted-array/README.md index fd35bab24..bc6e12886 100644 --- a/problems/find-first-and-last-position-of-element-in-sorted-array/README.md +++ b/problems/find-first-and-last-position-of-element-in-sorted-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../search-in-rotated-sorted-array "Search in Rotated Sorted Array") @@ -11,7 +11,7 @@ ## [34. Find First and Last Position of Element in Sorted Array (Medium)](https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array "在排序数组中查找元素的第一个和最后一个位置") -

    Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.

    +

    Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value.

    If target is not found in the array, return [-1, -1].

    @@ -44,3 +44,5 @@ ### Similar Questions 1. [First Bad Version](../first-bad-version) (Easy) + 1. [Plates Between Candles](../plates-between-candles) (Medium) + 1. [Find Target Indices After Sorting Array](../find-target-indices-after-sorting-array) (Easy) diff --git a/problems/find-first-palindromic-string-in-the-array/README.md b/problems/find-first-palindromic-string-in-the-array/README.md new file mode 100644 index 000000000..d10defefd --- /dev/null +++ b/problems/find-first-palindromic-string-in-the-array/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../number-of-unique-flavors-after-sharing-k-candies "Number of Unique Flavors After Sharing K Candies") +                 +[Next >](../adding-spaces-to-a-string "Adding Spaces to a String") + +## [2108. Find First Palindromic String in the Array (Easy)](https://leetcode.com/problems/find-first-palindromic-string-in-the-array "找出数组中的第一个回文字符串") + +

    Given an array of strings words, return the first palindromic string in the array. If there is no such string, return an empty string "".

    + +

    A string is palindromic if it reads the same forward and backward.

    + +

     

    +

    Example 1:

    + +
    +Input: words = ["abc","car","ada","racecar","cool"]
    +Output: "ada"
    +Explanation: The first string that is palindromic is "ada".
    +Note that "racecar" is also palindromic, but it is not the first.
    +
    + +

    Example 2:

    + +
    +Input: words = ["notapalindrome","racecar"]
    +Output: "racecar"
    +Explanation: The first and only string that is palindromic is "racecar".
    +
    + +

    Example 3:

    + +
    +Input: words = ["def","ghi"]
    +Output: ""
    +Explanation: There are no palindromic strings, so the empty string is returned.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 100
    • +
    • 1 <= words[i].length <= 100
    • +
    • words[i] consists only of lowercase English letters.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Iterate through the elements in order. As soon as the current element is a palindrome, return it. +
    + +
    +Hint 2 +To check if an element is a palindrome, can you reverse the string? +
    diff --git a/problems/find-good-days-to-rob-the-bank/README.md b/problems/find-good-days-to-rob-the-bank/README.md new file mode 100644 index 000000000..0f8c76b53 --- /dev/null +++ b/problems/find-good-days-to-rob-the-bank/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../find-subsequence-of-length-k-with-the-largest-sum "Find Subsequence of Length K With the Largest Sum") +                 +[Next >](../detonate-the-maximum-bombs "Detonate the Maximum Bombs") + +## [2100. Find Good Days to Rob the Bank (Medium)](https://leetcode.com/problems/find-good-days-to-rob-the-bank "适合打劫银行的日子") + +

    You and a gang of thieves are planning on robbing a bank. You are given a 0-indexed integer array security, where security[i] is the number of guards on duty on the ith day. The days are numbered starting from 0. You are also given an integer time.

    + +

    The ith day is a good day to rob the bank if:

    + +
      +
    • There are at least time days before and after the ith day,
    • +
    • The number of guards at the bank for the time days before i are non-increasing, and
    • +
    • The number of guards at the bank for the time days after i are non-decreasing.
    • +
    + +

    More formally, this means day i is a good day to rob the bank if and only if security[i - time] >= security[i - time + 1] >= ... >= security[i] <= ... <= security[i + time - 1] <= security[i + time].

    + +

    Return a list of all days (0-indexed) that are good days to rob the bank. The order that the days are returned in does not matter.

    + +

     

    +

    Example 1:

    + +
    +Input: security = [5,3,3,3,5,6,2], time = 2
    +Output: [2,3]
    +Explanation:
    +On day 2, we have security[0] >= security[1] >= security[2] <= security[3] <= security[4].
    +On day 3, we have security[1] >= security[2] >= security[3] <= security[4] <= security[5].
    +No other days satisfy this condition, so days 2 and 3 are the only good days to rob the bank.
    +
    + +

    Example 2:

    + +
    +Input: security = [1,1,1,1,1], time = 0
    +Output: [0,1,2,3,4]
    +Explanation:
    +Since time equals 0, every day is a good day to rob the bank, so return every day.
    +
    + +

    Example 3:

    + +
    +Input: security = [1,2,3,4,5,6], time = 2
    +Output: []
    +Explanation:
    +No day has 2 days before it that have a non-increasing number of guards.
    +Thus, no day is a good day to rob the bank, so return an empty list.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= security.length <= 105
    • +
    • 0 <= security[i], time <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +The trivial solution is to check the time days before and after each day. There are a lot of repeated operations using this solution. How could we optimize this solution? +
    + +
    +Hint 2 +We can use precomputation to make the solution faster. +
    + +
    +Hint 3 +Use an array to store the number of days before the ith day that is non-increasing, and another array to store the number of days after the ith day that is non-decreasing. +
    diff --git a/problems/find-if-path-exists-in-graph/README.md b/problems/find-if-path-exists-in-graph/README.md index 08b773042..f0623ec1c 100644 --- a/problems/find-if-path-exists-in-graph/README.md +++ b/problems/find-if-path-exists-in-graph/README.md @@ -13,15 +13,15 @@

    There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself.

    -

    You want to determine if there is a valid path that exists from vertex start to vertex end.

    +

    You want to determine if there is a valid path that exists from vertex source to vertex destination.

    -

    Given edges and the integers n, start, and end, return true if there is a valid path from start to end, or false otherwise.

    +

    Given edges and the integers n, source, and destination, return true if there is a valid path from source to destination, or false otherwise.

     

    Example 1:

    -Input: n = 3, edges = [[0,1],[1,2],[2,0]], start = 0, end = 2
    +Input: n = 3, edges = [[0,1],[1,2],[2,0]], source = 0, destination = 2
     Output: true
     Explanation: There are two paths from vertex 0 to vertex 2:
     - 0 → 1 → 2
    @@ -31,7 +31,7 @@
     

    Example 2:

    -Input: n = 6, edges = [[0,1],[0,2],[3,5],[5,4],[4,3]], start = 0, end = 5
    +Input: n = 6, edges = [[0,1],[0,2],[3,5],[5,4],[4,3]], source = 0, destination = 5
     Output: false
     Explanation: There is no path from vertex 0 to vertex 5.
     
    @@ -45,7 +45,7 @@
  • edges[i].length == 2
  • 0 <= ui, vi <= n - 1
  • ui != vi
  • -
  • 0 <= start, end <= n - 1
  • +
  • 0 <= source, destination <= n - 1
  • There are no duplicate edges.
  • There are no self edges.
  • diff --git a/problems/find-k-closest-elements/README.md b/problems/find-k-closest-elements/README.md index db3d6d94d..3256c0ea8 100644 --- a/problems/find-k-closest-elements/README.md +++ b/problems/find-k-closest-elements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../robot-return-to-origin "Robot Return to Origin") diff --git a/problems/find-k-length-substrings-with-no-repeated-characters/README.md b/problems/find-k-length-substrings-with-no-repeated-characters/README.md index 8bbd4791a..2ffabda34 100644 --- a/problems/find-k-length-substrings-with-no-repeated-characters/README.md +++ b/problems/find-k-length-substrings-with-no-repeated-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-sum-less-than-k "Two Sum Less Than K") diff --git a/problems/find-kth-bit-in-nth-binary-string/README.md b/problems/find-kth-bit-in-nth-binary-string/README.md index c6deb7db6..a3be3ef9b 100644 --- a/problems/find-kth-bit-in-nth-binary-string/README.md +++ b/problems/find-kth-bit-in-nth-binary-string/README.md @@ -15,12 +15,12 @@
    • S1 = "0"
    • -
    • Si = Si-1 + "1" + reverse(invert(Si-1)) for i > 1
    • +
    • Si = Si - 1 + "1" + reverse(invert(Si - 1)) for i > 1
    -

    Where + denotes the concatenation operation, reverse(x) returns the reversed string x, and invert(x) inverts all the bits in x (0 changes to 1 and 1 changes to 0).

    +

    Where + denotes the concatenation operation, reverse(x) returns the reversed string x, and invert(x) inverts all the bits in x (0 changes to 1 and 1 changes to 0).

    -

    For example, the first 4 strings in the above sequence are:

    +

    For example, the first four strings in the above sequence are:

    • S1 = "0"
    • @@ -37,7 +37,8 @@
       Input: n = 3, k = 1
       Output: "0"
      -Explanation: S3 is "0111001". The first bit is "0".
      +Explanation: S3 is "0111001".
      +The 1st bit is "0".
       

      Example 2:

      @@ -45,21 +46,8 @@
       Input: n = 4, k = 11
       Output: "1"
      -Explanation: S4 is "011100110110001". The 11th bit is "1".
      -
      - -

      Example 3:

      - -
      -Input: n = 1, k = 1
      -Output: "0"
      -
      - -

      Example 4:

      - -
      -Input: n = 2, k = 3
      -Output: "1"
      +Explanation: S4 is "011100110110001".
      +The 11th bit is "1".
       

       

      diff --git a/problems/find-kth-largest-xor-coordinate-value/README.md b/problems/find-kth-largest-xor-coordinate-value/README.md index 09a8dc816..1e1e0f942 100644 --- a/problems/find-kth-largest-xor-coordinate-value/README.md +++ b/problems/find-kth-largest-xor-coordinate-value/README.md @@ -23,14 +23,16 @@
       Input: matrix = [[5,2],[1,6]], k = 1
       Output: 7
      -Explanation: The value of coordinate (0,1) is 5 XOR 2 = 7, which is the largest value.
      +Explanation: The value of coordinate (0,1) is 5 XOR 2 = 7, which is the largest value. +

    Example 2:

     Input: matrix = [[5,2],[1,6]], k = 2
     Output: 5
    -Explanation: The value of coordinate (0,0) is 5 = 5, which is the 2nd largest value.
    +Explanation: The value of coordinate (0,0) is 5 = 5, which is the 2nd largest value. +

    Example 3:

    @@ -39,13 +41,6 @@ Output: 4 Explanation: The value of coordinate (1,0) is 5 XOR 1 = 4, which is the 3rd largest value. -

    Example 4:

    - -
    -Input: matrix = [[5,2],[1,6]], k = 4
    -Output: 0
    -Explanation: The value of coordinate (1,1) is 5 XOR 2 XOR 1 XOR 6 = 0, which is the 4th largest value.
    -

     

    Constraints:

    diff --git a/problems/find-latest-group-of-size-m/README.md b/problems/find-latest-group-of-size-m/README.md index 7b8f9ad12..a9082fdad 100644 --- a/problems/find-latest-group-of-size-m/README.md +++ b/problems/find-latest-group-of-size-m/README.md @@ -25,21 +25,22 @@
     Input: arr = [3,5,1,2,4], m = 1
     Output: 4
    -Explanation:
    -Step 1: "00100", groups: ["1"]
    +Explanation: 
    +Step 1: "00100", groups: ["1"]
     Step 2: "00101", groups: ["1", "1"]
     Step 3: "10101", groups: ["1", "1", "1"]
     Step 4: "11101", groups: ["111", "1"]
     Step 5: "11111", groups: ["11111"]
    -The latest step at which there exists a group of size 1 is step 4.
    +The latest step at which there exists a group of size 1 is step 4. +

    Example 2:

     Input: arr = [3,1,5,4,2], m = 2
     Output: -1
    -Explanation:
    -Step 1: "00100", groups: ["1"]
    +Explanation: 
    +Step 1: "00100", groups: ["1"]
     Step 2: "10100", groups: ["1", "1"]
     Step 3: "10101", groups: ["1", "1", "1"]
     Step 4: "10111", groups: ["1", "111"]
    @@ -47,20 +48,6 @@ Step 5: "11111", groups: ["11111"]
     No group of size 2 exists during any step.
     
    -

    Example 3:

    - -
    -Input: arr = [1], m = 1
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: arr = [2,1], m = 2
    -Output: 2
    -
    -

     

    Constraints:

    diff --git a/problems/find-longest-awesome-substring/README.md b/problems/find-longest-awesome-substring/README.md index 35bff6ebc..b024ca96d 100644 --- a/problems/find-longest-awesome-substring/README.md +++ b/problems/find-longest-awesome-substring/README.md @@ -11,9 +11,9 @@ ## [1542. Find Longest Awesome Substring (Hard)](https://leetcode.com/problems/find-longest-awesome-substring "找出最长的超赞子字符串") -

    Given a string s. An awesome substring is a non-empty substring of s such that we can make any number of swaps in order to make it palindrome.

    +

    You are given a string s. An awesome substring is a non-empty substring of s such that we can make any number of swaps in order to make it a palindrome.

    -

    Return the length of the maximum length awesome substring of s.

    +

    Return the length of the maximum length awesome substring of s.

     

    Example 1:

    @@ -39,13 +39,6 @@ Explanation: "213123" is the longest awesome substring, we can form the palindrome "231132" with some swaps. -

    Example 4:

    - -
    -Input: s = "00"
    -Output: 2
    -
    -

     

    Constraints:

    diff --git a/problems/find-lucky-integer-in-an-array/README.md b/problems/find-lucky-integer-in-an-array/README.md index 2308ca8e0..197c818bd 100644 --- a/problems/find-lucky-integer-in-an-array/README.md +++ b/problems/find-lucky-integer-in-an-array/README.md @@ -11,9 +11,9 @@ ## [1394. Find Lucky Integer in an Array (Easy)](https://leetcode.com/problems/find-lucky-integer-in-an-array "找出数组中的幸运数") -

    Given an array of integers arr, a lucky integer is an integer which has a frequency in the array equal to its value.

    +

    Given an array of integers arr, a lucky integer is an integer that has a frequency in the array equal to its value.

    -

    Return a lucky integer in the array. If there are multiple lucky integers return the largest of them. If there is no lucky integer return -1.

    +

    Return the largest lucky integer in the array. If there is no lucky integer return -1.

     

    Example 1:

    @@ -40,20 +40,6 @@ Explanation: There are no lucky numbers in the array. -

    Example 4:

    - -
    -Input: arr = [5]
    -Output: -1
    -
    - -

    Example 5:

    - -
    -Input: arr = [7,7,7,7,7,7,7]
    -Output: 7
    -
    -

     

    Constraints:

    diff --git a/problems/find-minimum-in-rotated-sorted-array-ii/README.md b/problems/find-minimum-in-rotated-sorted-array-ii/README.md index d9cf6cda9..5fa38008e 100644 --- a/problems/find-minimum-in-rotated-sorted-array-ii/README.md +++ b/problems/find-minimum-in-rotated-sorted-array-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-minimum-in-rotated-sorted-array "Find Minimum in Rotated Sorted Array") diff --git a/problems/find-missing-observations/README.md b/problems/find-missing-observations/README.md index 7509a72d7..65ccb1f6d 100644 --- a/problems/find-missing-observations/README.md +++ b/problems/find-missing-observations/README.md @@ -46,14 +46,6 @@ Explanation: It is impossible for the mean to be 6 no matter what the 4 missing rolls are. -

    Example 4:

    - -
    -Input: rolls = [1], mean = 3, n = 1
    -Output: [5]
    -Explanation: The mean of all n + m rolls is (1 + 5) / 2 = 3.
    -
    -

     

    Constraints:

    diff --git a/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md b/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md index 428b9c620..f390364e6 100644 --- a/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md +++ b/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md @@ -51,6 +51,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] +### Similar Questions + 1. [K Closest Points to Origin](../k-closest-points-to-origin) (Medium) + ### Hints
    Hint 1 diff --git a/problems/find-numbers-with-even-number-of-digits/README.md b/problems/find-numbers-with-even-number-of-digits/README.md index b13bbff63..22abd4751 100644 --- a/problems/find-numbers-with-even-number-of-digits/README.md +++ b/problems/find-numbers-with-even-number-of-digits/README.md @@ -48,6 +48,9 @@ Only 1771 contains an even number of digits. ### Related Topics [[Array](../../tag/array/README.md)] +### Similar Questions + 1. [Finding 3-Digit Even Numbers](../finding-3-digit-even-numbers) (Easy) + ### Hints
    Hint 1 diff --git a/problems/find-root-of-n-ary-tree/README.md b/problems/find-root-of-n-ary-tree/README.md index 86d931298..1e76d79f4 100644 --- a/problems/find-root-of-n-ary-tree/README.md +++ b/problems/find-root-of-n-ary-tree/README.md @@ -14,13 +14,10 @@ ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - -### Similar Questions - 1. [Move Sub-Tree of N-Ary Tree](../move-sub-tree-of-n-ary-tree) (Hard) + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/find-servers-that-handled-most-number-of-requests/README.md b/problems/find-servers-that-handled-most-number-of-requests/README.md index c18b61cd2..ac8510ccd 100644 --- a/problems/find-servers-that-handled-most-number-of-requests/README.md +++ b/problems/find-servers-that-handled-most-number-of-requests/README.md @@ -30,7 +30,7 @@
     Input: k = 3, arrival = [1,2,3,4,5], load = [5,2,3,3,3] 
     Output: [1] 
    -Explanation:
    +Explanation: 
     All of the servers start out available.
     The first 3 requests are handled by the first 3 servers in order.
     Request 3 comes in. Server 0 is busy, so it's assigned to the next available server, which is 1.
    @@ -43,7 +43,7 @@ Servers 0 and 2 handled one request each, while server 1 handled two requests. H
     
     Input: k = 3, arrival = [1,2,3,4], load = [1,2,1,2]
     Output: [0]
    -Explanation:
    +Explanation: 
     The first 3 requests are handled by first 3 servers.
     Request 3 comes in. It is handled by server 0 since the server is available.
     Server 0 handled two requests, while servers 1 and 2 handled one request each. Hence server 0 is the busiest server.
    @@ -54,21 +54,7 @@ Server 0 handled two requests, while servers 1 and 2 handled one request each. H
     
     Input: k = 3, arrival = [1,2,3], load = [10,12,11]
     Output: [0,1,2]
    -Explanation: Each server handles a single request, so they are all considered the busiest.
    -
    - -

    Example 4:

    - -
    -Input: k = 3, arrival = [1,2,3,4,8,9,10], load = [5,2,10,3,1,2,2]
    -Output: [1]
    -
    - -

    Example 5:

    - -
    -Input: k = 1, arrival = [1], load = [1]
    -Output: [0]
    +Explanation: Each server handles a single request, so they are all considered the busiest.
     

     

    @@ -83,10 +69,10 @@ Server 0 handled two requests, while servers 1 and 2 handled one request each. H ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Hints
    diff --git a/problems/find-subsequence-of-length-k-with-the-largest-sum/README.md b/problems/find-subsequence-of-length-k-with-the-largest-sum/README.md new file mode 100644 index 000000000..dcdab30b2 --- /dev/null +++ b/problems/find-subsequence-of-length-k-with-the-largest-sum/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../subsequence-of-size-k-with-the-largest-even-sum "Subsequence of Size K With the Largest Even Sum") +                 +[Next >](../find-good-days-to-rob-the-bank "Find Good Days to Rob the Bank") + +## [2099. Find Subsequence of Length K With the Largest Sum (Easy)](https://leetcode.com/problems/find-subsequence-of-length-k-with-the-largest-sum "找到和最大的长度为 K 的子序列") + +

    You are given an integer array nums and an integer k. You want to find a subsequence of nums of length k that has the largest sum.

    + +

    Return any such subsequence as an integer array of length k.

    + +

    A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [2,1,3,3], k = 2
    +Output: [3,3]
    +Explanation:
    +The subsequence has the largest sum of 3 + 3 = 6.
    + +

    Example 2:

    + +
    +Input: nums = [-1,-2,3,4], k = 3
    +Output: [-1,3,4]
    +Explanation: 
    +The subsequence has the largest sum of -1 + 3 + 4 = 6.
    +
    + +

    Example 3:

    + +
    +Input: nums = [3,4,3,3], k = 2
    +Output: [3,4]
    +Explanation:
    +The subsequence has the largest sum of 3 + 4 = 7. 
    +Another possible subsequence is [4, 3].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • -105 <= nums[i] <= 105
    • +
    • 1 <= k <= nums.length
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +From a greedy perspective, what k elements should you pick? +
    + +
    +Hint 2 +Could you sort the array while maintaining the index? +
    diff --git a/problems/find-substring-with-given-hash-value/README.md b/problems/find-substring-with-given-hash-value/README.md new file mode 100644 index 000000000..0c9182b7e --- /dev/null +++ b/problems/find-substring-with-given-hash-value/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../all-divisions-with-the-highest-score-of-a-binary-array "All Divisions With the Highest Score of a Binary Array") +                 +[Next >](../groups-of-strings "Groups of Strings") + +## [2156. Find Substring With Given Hash Value (Medium)](https://leetcode.com/problems/find-substring-with-given-hash-value "查找给定哈希值的子串") + +

    The hash of a 0-indexed string s of length k, given integers p and m, is computed using the following function:

    + +
      +
    • hash(s, p, m) = (val(s[0]) * p0 + val(s[1]) * p1 + ... + val(s[k-1]) * pk-1) mod m.
    • +
    + +

    Where val(s[i]) represents the index of s[i] in the alphabet from val('a') = 1 to val('z') = 26.

    + +

    You are given a string s and the integers power, modulo, k, and hashValue. Return sub, the first substring of s of length k such that hash(sub, power, modulo) == hashValue.

    + +

    The test cases will be generated such that an answer always exists.

    + +

    A substring is a contiguous non-empty sequence of characters within a string.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "leetcode", power = 7, modulo = 20, k = 2, hashValue = 0
    +Output: "ee"
    +Explanation: The hash of "ee" can be computed to be hash("ee", 7, 20) = (5 * 1 + 5 * 7) mod 20 = 40 mod 20 = 0. 
    +"ee" is the first substring of length 2 with hashValue 0. Hence, we return "ee".
    +
    + +

    Example 2:

    + +
    +Input: s = "fbxzaad", power = 31, modulo = 100, k = 3, hashValue = 32
    +Output: "fbx"
    +Explanation: The hash of "fbx" can be computed to be hash("fbx", 31, 100) = (6 * 1 + 2 * 31 + 24 * 312) mod 100 = 23132 mod 100 = 32. 
    +The hash of "bxz" can be computed to be hash("bxz", 31, 100) = (2 * 1 + 24 * 31 + 26 * 312) mod 100 = 25732 mod 100 = 32. 
    +"fbx" is the first substring of length 3 with hashValue 32. Hence, we return "fbx".
    +Note that "bxz" also has a hash of 32 but it appears later than "fbx".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= s.length <= 2 * 104
    • +
    • 1 <= power, modulo <= 109
    • +
    • 0 <= hashValue < modulo
    • +
    • s consists of lowercase English letters only.
    • +
    • The test cases are generated such that an answer always exists.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] + +### Hints +
    +Hint 1 +How can we update the hash value efficiently while iterating instead of recalculating it each time? +
    + +
    +Hint 2 +Use the rolling hash method. +
    diff --git a/problems/find-target-indices-after-sorting-array/README.md b/problems/find-target-indices-after-sorting-array/README.md new file mode 100644 index 000000000..ef7f2708f --- /dev/null +++ b/problems/find-target-indices-after-sorting-array/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../count-fertile-pyramids-in-a-land "Count Fertile Pyramids in a Land") +                 +[Next >](../k-radius-subarray-averages "K Radius Subarray Averages") + +## [2089. Find Target Indices After Sorting Array (Easy)](https://leetcode.com/problems/find-target-indices-after-sorting-array "找出数组排序后的目标下标") + +

    You are given a 0-indexed integer array nums and a target element target.

    + +

    A target index is an index i such that nums[i] == target.

    + +

    Return a list of the target indices of nums after sorting nums in non-decreasing order. If there are no target indices, return an empty list. The returned list must be sorted in increasing order.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,5,2,3], target = 2
    +Output: [1,2]
    +Explanation: After sorting, nums is [1,2,2,3,5].
    +The indices where nums[i] == 2 are 1 and 2.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,2,5,2,3], target = 3
    +Output: [3]
    +Explanation: After sorting, nums is [1,2,2,3,5].
    +The index where nums[i] == 3 is 3.
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,2,5,2,3], target = 5
    +Output: [4]
    +Explanation: After sorting, nums is [1,2,2,3,5].
    +The index where nums[i] == 5 is 4.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • 1 <= nums[i], target <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Try "sorting" the array first. +
    + +
    +Hint 2 +Now find all indices in the array whose values are equal to target. +
    diff --git a/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md b/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md index 8a56a7c1b..fe8cd7fdf 100644 --- a/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md +++ b/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../filter-restaurants-by-vegan-friendly-price-and-distance "Filter Restaurants by Vegan-Friendly, Price and Distance") @@ -60,10 +60,13 @@ The city 0 has 1 neighboring city at a distanceThreshold = 2. ### Related Topics - [[Graph](../../tag/graph/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Graph](../../tag/graph/README.md)] [[Shortest Path](../../tag/shortest-path/README.md)] +### Similar Questions + 1. [Second Minimum Time to Reach Destination](../second-minimum-time-to-reach-destination) (Hard) + ### Hints
    Hint 1 diff --git a/problems/find-the-index-of-the-large-integer/README.md b/problems/find-the-index-of-the-large-integer/README.md index 57eb5c872..4206c138e 100644 --- a/problems/find-the-index-of-the-large-integer/README.md +++ b/problems/find-the-index-of-the-large-integer/README.md @@ -18,9 +18,6 @@ [[Binary Search](../../tag/binary-search/README.md)] [[Interactive](../../tag/interactive/README.md)] -### Similar Questions - 1. [Search in a Sorted Array of Unknown Size](../search-in-a-sorted-array-of-unknown-size) (Medium) - ### Hints
    Hint 1 diff --git a/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md index f115bd5f2..04ac15592 100644 --- a/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md +++ b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit") @@ -11,9 +11,11 @@ ## [1439. Find the Kth Smallest Sum of a Matrix With Sorted Rows (Hard)](https://leetcode.com/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows "有序矩阵中的第 k 个最小数组和") -

    You are given an m * n matrix, mat, and an integer k, which has its rows sorted in non-decreasing order.

    +

    You are given an m x n matrix mat that has its rows sorted in non-decreasing order and an integer k.

    -

    You are allowed to choose exactly 1 element from each row to form an array. Return the Kth smallest array sum among all possible arrays.

    +

    You are allowed to choose exactly one element from each row to form an array.

    + +

    Return the kth smallest array sum among all possible arrays.

     

    Example 1:

    @@ -21,8 +23,9 @@
     Input: mat = [[1,3,11],[2,4,6]], k = 5
     Output: 7
    -Explanation: Choosing one element from each row, the first k smallest sum are:
    -[1,2], [1,4], [3,2], [3,4], [1,6]. Where the 5th sum is 7.  
    +Explanation: Choosing one element from each row, the first k smallest sum are: +[1,2], [1,4], [3,2], [3,4], [1,6]. Where the 5th sum is 7. +

    Example 2:

    @@ -40,13 +43,6 @@ [1,1,2], [1,1,3], [1,4,2], [1,4,3], [1,1,6], [1,5,2], [1,5,3]. Where the 7th sum is 9.
    -

    Example 4:

    - -
    -Input: mat = [[1,1,10],[2,2,9]], k = 7
    -Output: 12
    -
    -

     

    Constraints:

    @@ -54,16 +50,16 @@
  • m == mat.length
  • n == mat.length[i]
  • 1 <= m, n <= 40
  • -
  • 1 <= k <= min(200, n ^ m)
  • 1 <= mat[i][j] <= 5000
  • -
  • mat[i] is a non decreasing array.
  • +
  • 1 <= k <= min(200, nm)
  • +
  • mat[i] is a non-decreasing array.
  • ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Matrix](../../tag/matrix/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/find-the-middle-index-in-array/README.md b/problems/find-the-middle-index-in-array/README.md index c9372d3c6..5a9991797 100644 --- a/problems/find-the-middle-index-in-array/README.md +++ b/problems/find-the-middle-index-in-array/README.md @@ -25,8 +25,7 @@
     Input: nums = [2,3,-1,8,4]
     Output: 3
    -Explanation:
    -The sum of the numbers before index 3 is: 2 + 3 + -1 = 4
    +Explanation: The sum of the numbers before index 3 is: 2 + 3 + -1 = 4
     The sum of the numbers after index 3 is: 4 = 4
     
    @@ -35,8 +34,7 @@ The sum of the numbers after index 3 is: 4 = 4
     Input: nums = [1,-1,4]
     Output: 2
    -Explanation:
    -The sum of the numbers before index 2 is: 1 + -1 = 0
    +Explanation: The sum of the numbers before index 2 is: 1 + -1 = 0
     The sum of the numbers after index 2 is: 0
     
    @@ -45,18 +43,7 @@ The sum of the numbers after index 2 is: 0
     Input: nums = [2,5]
     Output: -1
    -Explanation:
    -There is no valid middleIndex.
    -
    - -

    Example 4:

    - -
    -Input: nums = [1]
    -Output: 0
    -Explantion:
    -The sum of the numbers before index 0 is: 0
    -The sum of the numbers after index 0 is: 0
    +Explanation: There is no valid middleIndex.
     

     

    diff --git a/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md b/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md index aa3940150..e614c8384 100644 --- a/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md +++ b/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md @@ -56,14 +56,6 @@ Thus, minDistance and maxDistance is 5 - 2 = 3. Note that the last node is not considered a local maxima because it does not have a next node. -

    Example 4:

    - -
    -Input: head = [2,3,3,2]
    -Output: [-1,-1]
    -Explanation: There are no critical points in [2,3,3,2].
    -
    -

     

    Constraints:

    diff --git a/problems/find-the-missing-ids/README.md b/problems/find-the-missing-ids/README.md index 493874513..ad3d152ac 100644 --- a/problems/find-the-missing-ids/README.md +++ b/problems/find-the-missing-ids/README.md @@ -15,3 +15,8 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Report Contiguous Dates](../report-contiguous-dates) (Hard) + 1. [Find the Start and End Number of Continuous Ranges](../find-the-start-and-end-number-of-continuous-ranges) (Medium) + 1. [Number of Transactions per Visit](../number-of-transactions-per-visit) (Hard) diff --git a/problems/find-the-most-competitive-subsequence/README.md b/problems/find-the-most-competitive-subsequence/README.md index 918cfd3ad..6f21e4840 100644 --- a/problems/find-the-most-competitive-subsequence/README.md +++ b/problems/find-the-most-competitive-subsequence/README.md @@ -43,15 +43,11 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] -### Similar Questions - 1. [Remove K Digits](../remove-k-digits) (Medium) - 1. [Smallest Subsequence of Distinct Characters](../smallest-subsequence-of-distinct-characters) (Medium) - ### Hints
    Hint 1 diff --git a/problems/find-the-smallest-divisor-given-a-threshold/README.md b/problems/find-the-smallest-divisor-given-a-threshold/README.md index ff3a0bece..45f02e814 100644 --- a/problems/find-the-smallest-divisor-given-a-threshold/README.md +++ b/problems/find-the-smallest-divisor-given-a-threshold/README.md @@ -15,7 +15,7 @@

    Each result of the division is rounded to the nearest integer greater than or equal to that element. (For example: 7/3 = 3 and 10/2 = 5).

    -

    It is guaranteed that there will be an answer.

    +

    The test cases are generated so that there will be an answer.

     

    Example 1:

    @@ -34,20 +34,6 @@ If the divisor is 4 we can get a sum of 7 (1+1+2+3) and if the divisor is 5 the Output: 44 -

    Example 3:

    - -
    -Input: nums = [21212,10101,12121], threshold = 1000000
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: nums = [2,3,5,7,11], threshold = 11
    -Output: 3
    -
    -

     

    Constraints:

    diff --git a/problems/find-the-winner-of-an-array-game/README.md b/problems/find-the-winner-of-an-array-game/README.md index ab1c0c3a7..70bb38ceb 100644 --- a/problems/find-the-winner-of-an-array-game/README.md +++ b/problems/find-the-winner-of-an-array-game/README.md @@ -13,7 +13,7 @@

    Given an integer array arr of distinct integers and an integer k.

    -

    A game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of the game, we compare arr[0] with arr[1], the larger integer wins and remains at position 0 and the smaller integer moves to the end of the array. The game ends when an integer wins k consecutive rounds.

    +

    A game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of the game, we compare arr[0] with arr[1], the larger integer wins and remains at position 0, and the smaller integer moves to the end of the array. The game ends when an integer wins k consecutive rounds.

    Return the integer which will win the game.

    @@ -42,20 +42,6 @@ So we can see that 4 rounds will be played and 5 is the winner because it wins 2 Explanation: 3 will win the first 10 rounds consecutively. -

    Example 3:

    - -
    -Input: arr = [1,9,8,2,3,7,6,4,5], k = 7
    -Output: 9
    -
    - -

    Example 4:

    - -
    -Input: arr = [1,11,22,33,44,55,66,77,88,99], k = 1000000000
    -Output: 99
    -
    -

     

    Constraints:

    diff --git a/problems/find-the-winner-of-the-circular-game/README.md b/problems/find-the-winner-of-the-circular-game/README.md index 72592a8ab..f697c1c36 100644 --- a/problems/find-the-winner-of-the-circular-game/README.md +++ b/problems/find-the-winner-of-the-circular-game/README.md @@ -58,9 +58,10 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Queue](../../tag/queue/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md b/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md index 028421234..8f35b94cf 100644 --- a/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md +++ b/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../subrectangle-queries "Subrectangle Queries") @@ -11,7 +11,7 @@ ## [1477. Find Two Non-overlapping Sub-arrays Each With Target Sum (Medium)](https://leetcode.com/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum "找两个和为目标值且不重叠的子数组") -

    Given an array of integers arr and an integer target.

    +

    You are given an array of integers arr and an integer target.

    You have to find two non-overlapping sub-arrays of arr each with a sum equal target. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is minimum.

    @@ -42,22 +42,6 @@ Explanation: We have only one sub-array of sum = 6. -

    Example 4:

    - -
    -Input: arr = [5,5,4,4,5], target = 3
    -Output: -1
    -Explanation: We cannot find a sub-array of sum = 3.
    -
    - -

    Example 5:

    - -
    -Input: arr = [3,1,1,1,5,1,2,1], target = 3
    -Output: 3
    -Explanation: Note that sub-arrays [1,2] and [2,1] cannot be an answer because they overlap.
    -
    -

     

    Constraints:

    diff --git a/problems/find-valid-matrix-given-row-and-column-sums/README.md b/problems/find-valid-matrix-given-row-and-column-sums/README.md index 937b21680..1ca194f17 100644 --- a/problems/find-valid-matrix-given-row-and-column-sums/README.md +++ b/problems/find-valid-matrix-given-row-and-column-sums/README.md @@ -24,11 +24,11 @@ Input: rowSum = [3,8], colSum = [4,7] Output: [[3,0], [1,7]] -Explanation: -0th row: 3 + 0 = 3 == rowSum[0] -1st row: 1 + 7 = 8 == rowSum[1] -0th column: 3 + 1 = 4 == colSum[0] -1st column: 0 + 7 = 7 == colSum[1] +Explanation: +0th row: 3 + 0 = 3 == rowSum[0] +1st row: 1 + 7 = 8 == rowSum[1] +0th column: 3 + 1 = 4 == colSum[0] +1st column: 0 + 7 = 7 == colSum[1] The row and column sums match, and all matrix elements are non-negative. Another possible matrix is: [[1,2], [3,5]] @@ -43,29 +43,6 @@ Another possible matrix is: [[1,2], [2,0,8]] -

    Example 3:

    - -
    -Input: rowSum = [14,9], colSum = [6,9,8]
    -Output: [[0,9,5],
    -         [6,0,3]]
    -
    - -

    Example 4:

    - -
    -Input: rowSum = [1,0], colSum = [1]
    -Output: [[1],
    -         [0]]
    -
    - -

    Example 5:

    - -
    -Input: rowSum = [0], colSum = [0]
    -Output: [[0]]
    -
    -

     

    Constraints:

    diff --git a/problems/find-winner-on-a-tic-tac-toe-game/README.md b/problems/find-winner-on-a-tic-tac-toe-game/README.md index a9fb045d4..b92f461f3 100644 --- a/problems/find-winner-on-a-tic-tac-toe-game/README.md +++ b/problems/find-winner-on-a-tic-tac-toe-game/README.md @@ -51,14 +51,6 @@ Explanation: The game ends in a draw since there are no moves to make. -

    Example 4:

    - -
    -Input: moves = [[0,0],[1,1]]
    -Output: "Pending"
    -Explanation: The game has not finished yet.
    -
    -

     

    Constraints:

    diff --git a/problems/finding-3-digit-even-numbers/README.md b/problems/finding-3-digit-even-numbers/README.md new file mode 100644 index 000000000..b3b7cc928 --- /dev/null +++ b/problems/finding-3-digit-even-numbers/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../minimum-cost-to-reach-city-with-discounts "Minimum Cost to Reach City With Discounts") +                 +[Next >](../delete-the-middle-node-of-a-linked-list "Delete the Middle Node of a Linked List") + +## [2094. Finding 3-Digit Even Numbers (Easy)](https://leetcode.com/problems/finding-3-digit-even-numbers "找出 3 位偶数") + +

    You are given an integer array digits, where each element is a digit. The array may contain duplicates.

    + +

    You need to find all the unique integers that follow the given requirements:

    + +
      +
    • The integer consists of the concatenation of three elements from digits in any arbitrary order.
    • +
    • The integer does not have leading zeros.
    • +
    • The integer is even.
    • +
    + +

    For example, if the given digits were [1, 2, 3], integers 132 and 312 follow the requirements.

    + +

    Return a sorted array of the unique integers.

    + +

     

    +

    Example 1:

    + +
    +Input: digits = [2,1,3,0]
    +Output: [102,120,130,132,210,230,302,310,312,320]
    +Explanation: All the possible integers that follow the requirements are in the output array. 
    +Notice that there are no odd integers or integers with leading zeros.
    +
    + +

    Example 2:

    + +
    +Input: digits = [2,2,8,8,2]
    +Output: [222,228,282,288,822,828,882]
    +Explanation: The same digit can be used as many times as it appears in digits. 
    +In this example, the digit 8 is used twice each time in 288, 828, and 882. 
    +
    + +

    Example 3:

    + +
    +Input: digits = [3,7,5]
    +Output: []
    +Explanation: No even integers can be formed using the given digits.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= digits.length <= 100
    • +
    • 0 <= digits[i] <= 9
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +The range of possible answers includes all even numbers between 100 and 999 inclusive. Could you check each possible answer to see if it could be formed from the digits in the array? +
    diff --git a/problems/finding-mk-average/README.md b/problems/finding-mk-average/README.md index 17b35c582..8986cc95c 100644 --- a/problems/finding-mk-average/README.md +++ b/problems/finding-mk-average/README.md @@ -69,8 +69,13 @@ obj.calculateMKAverage(); // The last 3 elements are [5,5,5]. ### Related Topics [[Design](../../tag/design/README.md)] [[Queue](../../tag/queue/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + +### Similar Questions + 1. [Find Median from Data Stream](../find-median-from-data-stream) (Hard) + 1. [Kth Largest Element in a Stream](../kth-largest-element-in-a-stream) (Easy) + 1. [Sequentially Ordinal Rank Tracker](../sequentially-ordinal-rank-tracker) (Hard) ### Hints
    diff --git a/problems/finding-pairs-with-a-certain-sum/README.md b/problems/finding-pairs-with-a-certain-sum/README.md index db4adce8e..618963a92 100644 --- a/problems/finding-pairs-with-a-certain-sum/README.md +++ b/problems/finding-pairs-with-a-certain-sum/README.md @@ -62,9 +62,12 @@ findSumPairs.count(7); // return 11; pairs (2,1), (2,2), (2,4), (3,1), (3,2), ( ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Design](../../tag/design/README.md)] + +### Similar Questions + 1. [Count Number of Pairs With Absolute Difference K](../count-number-of-pairs-with-absolute-difference-k) (Easy) ### Hints
    diff --git a/problems/first-and-last-call-on-the-same-day/README.md b/problems/first-and-last-call-on-the-same-day/README.md index b8f2de048..c8755953e 100644 --- a/problems/first-and-last-call-on-the-same-day/README.md +++ b/problems/first-and-last-call-on-the-same-day/README.md @@ -9,7 +9,7 @@                  [Next >](../count-nodes-equal-to-sum-of-descendants "Count Nodes Equal to Sum of Descendants") -## [1972. First and Last Call On the Same Day (Hard)](https://leetcode.com/problems/first-and-last-call-on-the-same-day "") +## [1972. First and Last Call On the Same Day (Hard)](https://leetcode.com/problems/first-and-last-call-on-the-same-day "同一天的第一个电话和最后一个电话") diff --git a/problems/first-unique-character-in-a-string/README.md b/problems/first-unique-character-in-a-string/README.md index 00f41ca4d..6935d8b35 100644 --- a/problems/first-unique-character-in-a-string/README.md +++ b/problems/first-unique-character-in-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lexicographical-numbers "Lexicographical Numbers") diff --git a/problems/fizz-buzz-multithreaded/README.md b/problems/fizz-buzz-multithreaded/README.md index 998449392..64187532e 100644 --- a/problems/fizz-buzz-multithreaded/README.md +++ b/problems/fizz-buzz-multithreaded/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tournament-winners "Tournament Winners") diff --git a/problems/flatten-binary-tree-to-linked-list/README.md b/problems/flatten-binary-tree-to-linked-list/README.md index 2fed5e2d1..3ec60780b 100644 --- a/problems/flatten-binary-tree-to-linked-list/README.md +++ b/problems/flatten-binary-tree-to-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-sum-ii "Path Sum II") diff --git a/problems/flip-game-ii/README.md b/problems/flip-game-ii/README.md index 1723aa64a..6814174ea 100644 --- a/problems/flip-game-ii/README.md +++ b/problems/flip-game-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flip-game "Flip Game") diff --git a/problems/flip-string-to-monotone-increasing/README.md b/problems/flip-string-to-monotone-increasing/README.md index 64b7a1358..1a4c257d1 100644 --- a/problems/flip-string-to-monotone-increasing/README.md +++ b/problems/flip-string-to-monotone-increasing/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../long-pressed-name "Long Pressed Name") diff --git a/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md b/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md index c79ccb267..939b93d2f 100644 --- a/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md +++ b/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md @@ -11,17 +11,15 @@ ## [1449. Form Largest Integer With Digits That Add up to Target (Hard)](https://leetcode.com/problems/form-largest-integer-with-digits-that-add-up-to-target "数位成本和为目标值的最大数字") -

    Given an array of integers cost and an integer target. Return the maximum integer you can paint under the following rules:

    +

    Given an array of integers cost and an integer target, return the maximum integer you can paint under the following rules:

      -
    • The cost of painting a digit (i+1) is given by cost[i] (0 indexed).
    • -
    • The total cost used must be equal to target.
    • -
    • Integer does not have digits 0.
    • +
    • The cost of painting a digit (i + 1) is given by cost[i] (0-indexed).
    • +
    • The total cost used must be equal to target.
    • +
    • The integer does not have 0 digits.
    -

    Since the answer may be too large, return it as string.

    - -

    If there is no way to paint any integer given the condition, return "0".

    +

    Since the answer may be very large, return it as a string. If there is no way to paint any integer given the condition, return "0".

     

    Example 1:

    @@ -29,7 +27,7 @@
     Input: cost = [4,3,2,5,6,7,2,5,5], target = 9
     Output: "7772"
    -Explanation:  The cost to paint the digit '7' is 2, and the digit '2' is 3. Then cost("7772") = 2*3+ 3*1 = 9. You could also paint "977", but "7772" is the largest number.
    +Explanation: The cost to paint the digit '7' is 2, and the digit '2' is 3. Then cost("7772") = 2*3+ 3*1 = 9. You could also paint "977", but "7772" is the largest number.
     Digit    cost
       1  ->   4
       2  ->   3
    @@ -55,14 +53,7 @@
     
     Input: cost = [2,4,6,2,4,6,4,4,4], target = 5
     Output: "0"
    -Explanation: It's not possible to paint any integer with total cost equal to target.
    -
    - -

    Example 4:

    - -
    -Input: cost = [6,10,15,40,40,40,40,40,40], target = 47
    -Output: "32211"
    +Explanation: It is impossible to paint any integer with total cost equal to target.
     

     

    @@ -70,8 +61,7 @@
    • cost.length == 9
    • -
    • 1 <= cost[i] <= 5000
    • -
    • 1 <= target <= 5000
    • +
    • 1 <= cost[i], target <= 5000
    ### Related Topics diff --git a/problems/four-divisors/README.md b/problems/four-divisors/README.md index c23fcc57b..0bdc98273 100644 --- a/problems/four-divisors/README.md +++ b/problems/four-divisors/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../create-target-array-in-the-given-order "Create Target Array in the Given Order") diff --git a/problems/frog-position-after-t-seconds/README.md b/problems/frog-position-after-t-seconds/README.md index a47663936..1e6ecd7bf 100644 --- a/problems/frog-position-after-t-seconds/README.md +++ b/problems/frog-position-after-t-seconds/README.md @@ -15,22 +15,19 @@

    The edges of the undirected tree are given in the array edges, where edges[i] = [ai, bi] means that exists an edge connecting the vertices ai and bi.

    -

    Return the probability that after t seconds the frog is on the vertex target.

    +

    Return the probability that after t seconds the frog is on the vertex target. Answers within 10-5 of the actual answer will be accepted.

     

    Example 1:

    - -

    - +
     Input: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 2, target = 4
     Output: 0.16666666666666666 
    -Explanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 probability to the vertex 2 after second 1 and then jumping with 1/2 probability to vertex 4 after second 2. Thus the probability for the frog is on the vertex 4 after 2 seconds is 1/3 * 1/2 = 1/6 = 0.16666666666666666. 
    +Explanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 probability to the vertex 2 after second 1 and then jumping with 1/2 probability to vertex 4 after second 2. Thus the probability for the frog is on the vertex 4 after 2 seconds is 1/3 * 1/2 = 1/6 = 0.16666666666666666. 
     

    Example 2:

    - -

    +
     Input: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 1, target = 7
    @@ -38,13 +35,6 @@
     Explanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 = 0.3333333333333333 probability to the vertex 7 after second 1. 
     
    -

    Example 3:

    - -
    -Input: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 20, target = 6
    -Output: 0.16666666666666666
    -
    -

     

    Constraints:

    @@ -53,9 +43,8 @@
  • edges.length == n - 1
  • edges[i].length == 2
  • 1 <= ai, bi <= n
  • -
  • 1 <= t <= 50
  • -
  • 1 <= target <= n
  • -
  • Answers within 10-5 of the actual value will be accepted as correct.
  • +
  • 1 <= t <= 50
  • +
  • 1 <= target <= n
  • ### Related Topics diff --git a/problems/fruit-into-baskets/README.md b/problems/fruit-into-baskets/README.md index 5ddc874cb..e4961b828 100644 --- a/problems/fruit-into-baskets/README.md +++ b/problems/fruit-into-baskets/README.md @@ -50,14 +50,6 @@ If we had started at the first tree, we would only pick from trees [0,1]. If we had started at the first tree, we would only pick from trees [1,2].
    -

    Example 4:

    - -
    -Input: fruits = [3,3,3,1,2,1,1,2,3,3,4]
    -Output: 5
    -Explanation: We can pick from trees [1,2,1,1,2].
    -
    -

     

    Constraints:

    diff --git a/problems/game-play-analysis-i/README.md b/problems/game-play-analysis-i/README.md index eaa4b32f3..5fccd1c99 100644 --- a/problems/game-play-analysis-i/README.md +++ b/problems/game-play-analysis-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../inorder-successor-in-bst-ii "Inorder Successor in BST II") diff --git a/problems/get-the-maximum-score/README.md b/problems/get-the-maximum-score/README.md index 86d638303..26e258cc6 100644 --- a/problems/get-the-maximum-score/README.md +++ b/problems/get-the-maximum-score/README.md @@ -27,13 +27,11 @@

     

    Example 1:

    - -

    - +
     Input: nums1 = [2,4,5,8,10], nums2 = [4,6,8,9]
     Output: 30
    -Explanation: Valid paths:
    +Explanation: Valid paths:
     [2,4,5,8,10], [2,4,5,8,9], [2,4,6,8,9], [2,4,6,8,10],  (starting from nums1)
     [4,6,8,9], [4,5,8,10], [4,5,8,9], [4,6,8,10]    (starting from nums2)
     The maximum is obtained with the path in green [2,4,6,8,10].
    @@ -44,7 +42,7 @@ The maximum is obtained with the path in green [2,4,6,8,10].
     
     Input: nums1 = [1,3,5,7,9], nums2 = [3,5,100]
     Output: 109
    -Explanation: Maximum sum is obtained with the path [1,3,5,100].
    +Explanation: Maximum sum is obtained with the path [1,3,5,100].
     

    Example 3:

    @@ -52,17 +50,10 @@ The maximum is obtained with the path in green [2,4,6,8,10].
     Input: nums1 = [1,2,3,4,5], nums2 = [6,7,8,9,10]
     Output: 40
    -Explanation: There are no common elements between nums1 and nums2.
    +Explanation: There are no common elements between nums1 and nums2.
     Maximum sum is obtained with the path [6,7,8,9,10].
     
    -

    Example 4:

    - -
    -Input: nums1 = [1,4,5,8,9,11,19], nums2 = [2,3,4,11,12]
    -Output: 61
    -
    -

     

    Constraints:

    @@ -73,10 +64,10 @@ Maximum sum is obtained with the path [6,7,8,9,10]. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/get-the-second-most-recent-activity/README.md b/problems/get-the-second-most-recent-activity/README.md index 11682b2cc..60c83d6b0 100644 --- a/problems/get-the-second-most-recent-activity/README.md +++ b/problems/get-the-second-most-recent-activity/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-make-at-least-one-valid-path-in-a-grid "Minimum Cost to Make at Least One Valid Path in a Grid") diff --git a/problems/group-employees-of-the-same-salary/README.md b/problems/group-employees-of-the-same-salary/README.md index f221375de..0b2f7fc0a 100644 --- a/problems/group-employees-of-the-same-salary/README.md +++ b/problems/group-employees-of-the-same-salary/README.md @@ -9,7 +9,7 @@                  [Next >](../substrings-of-size-three-with-distinct-characters "Substrings of Size Three with Distinct Characters") -## [1875. Group Employees of the Same Salary (Medium)](https://leetcode.com/problems/group-employees-of-the-same-salary "") +## [1875. Group Employees of the Same Salary (Medium)](https://leetcode.com/problems/group-employees-of-the-same-salary "将工资相同的雇员分组") diff --git a/problems/group-sold-products-by-the-date/README.md b/problems/group-sold-products-by-the-date/README.md index f107e9cdc..6722eb2d8 100644 --- a/problems/group-sold-products-by-the-date/README.md +++ b/problems/group-sold-products-by-the-date/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-ancestor-of-a-tree-node "Kth Ancestor of a Tree Node") diff --git a/problems/groups-of-strings/README.md b/problems/groups-of-strings/README.md new file mode 100644 index 000000000..0cc7e7afb --- /dev/null +++ b/problems/groups-of-strings/README.md @@ -0,0 +1,96 @@ + + + + + + + +[< Previous](../find-substring-with-given-hash-value "Find Substring With Given Hash Value") +                 +[Next >](../amount-of-new-area-painted-each-day "Amount of New Area Painted Each Day") + +## [2157. Groups of Strings (Hard)](https://leetcode.com/problems/groups-of-strings "字符串分组") + +

    You are given a 0-indexed array of strings words. Each string consists of lowercase English letters only. No letter occurs more than once in any string of words.

    + +

    Two strings s1 and s2 are said to be connected if the set of letters of s2 can be obtained from the set of letters of s1 by any one of the following operations:

    + +
      +
    • Adding exactly one letter to the set of the letters of s1.
    • +
    • Deleting exactly one letter from the set of the letters of s1.
    • +
    • Replacing exactly one letter from the set of the letters of s1 with any letter, including itself.
    • +
    + +

    The array words can be divided into one or more non-intersecting groups. A string belongs to a group if any one of the following is true:

    + +
      +
    • It is connected to at least one other string of the group.
    • +
    • It is the only string present in the group.
    • +
    + +

    Note that the strings in words should be grouped in such a manner that a string belonging to a group cannot be connected to a string present in any other group. It can be proved that such an arrangement is always unique.

    + +

    Return an array ans of size 2 where:

    + +
      +
    • ans[0] is the maximum number of groups words can be divided into, and
    • +
    • ans[1] is the size of the largest group.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: words = ["a","b","ab","cde"]
    +Output: [2,3]
    +Explanation:
    +- words[0] can be used to obtain words[1] (by replacing 'a' with 'b'), and words[2] (by adding 'b'). So words[0] is connected to words[1] and words[2].
    +- words[1] can be used to obtain words[0] (by replacing 'b' with 'a'), and words[2] (by adding 'a'). So words[1] is connected to words[0] and words[2].
    +- words[2] can be used to obtain words[0] (by deleting 'b'), and words[1] (by deleting 'a'). So words[2] is connected to words[0] and words[1].
    +- words[3] is not connected to any string in words.
    +Thus, words can be divided into 2 groups ["a","b","ab"] and ["cde"]. The size of the largest group is 3.  
    +
    + +

    Example 2:

    + +
    +Input: words = ["a","ab","abc"]
    +Output: [1,3]
    +Explanation:
    +- words[0] is connected to words[1].
    +- words[1] is connected to words[0] and words[2].
    +- words[2] is connected to words[1].
    +Since all strings are connected to each other, they should be grouped together.
    +Thus, the size of the largest group is 3.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 2 * 104
    • +
    • 1 <= words[i].length <= 26
    • +
    • words[i] consists of lowercase English letters only.
    • +
    • No letter occurs more than once in words[i].
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Can we build a graph from words, where there exists an edge between nodes i and j if words[i] and words[j] are connected? +
    + +
    +Hint 2 +The problem now boils down to finding the total number of components and the size of the largest component in the graph. +
    + +
    +Hint 3 +How can we use bit masking to reduce the search space while adding edges to node i? +
    diff --git a/problems/guess-number-higher-or-lower/README.md b/problems/guess-number-higher-or-lower/README.md index c09647967..52aa4fcb3 100644 --- a/problems/guess-number-higher-or-lower/README.md +++ b/problems/guess-number-higher-or-lower/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-k-pairs-with-smallest-sums "Find K Pairs with Smallest Sums") @@ -17,30 +17,38 @@

    Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess.

    -

    You call a pre-defined API int guess(int num), which returns 3 possible results:

    +

    You call a pre-defined API int guess(int num), which returns three possible results:

      -
    • -1: The number I picked is lower than your guess (i.e. pick < num).
    • -
    • 1: The number I picked is higher than your guess (i.e. pick > num).
    • -
    • 0: The number I picked is equal to your guess (i.e. pick == num).
    • +
    • -1: Your guess is higher than the number I picked (i.e. num > pick).
    • +
    • 1: Your guess is lower than the number I picked (i.e. num < pick).
    • +
    • 0: your guess is equal to the number I picked (i.e. num == pick).

    Return the number that I picked.

     

    Example 1:

    -
    Input: n = 10, pick = 6
    +
    +
    +Input: n = 10, pick = 6
     Output: 6
    -

    Example 2:

    -
    Input: n = 1, pick = 1
    +
    + +

    Example 2:

    + +
    +Input: n = 1, pick = 1
     Output: 1
    -

    Example 3:

    -
    Input: n = 2, pick = 1
    +
    + +

    Example 3:

    + +
    +Input: n = 2, pick = 1
     Output: 1
    -

    Example 4:

    -
    Input: n = 2, pick = 2
    -Output: 2
     
    +

     

    Constraints:

    diff --git a/problems/guess-the-word/README.md b/problems/guess-the-word/README.md index 488ba5ca4..97fb5c1ad 100644 --- a/problems/guess-the-word/README.md +++ b/problems/guess-the-word/README.md @@ -59,5 +59,5 @@ We made 5 calls to master.guess and one of them was the secret, so we pass the t [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] - [[Interactive](../../tag/interactive/README.md)] [[Game Theory](../../tag/game-theory/README.md)] + [[Interactive](../../tag/interactive/README.md)] diff --git a/problems/hexspeak/README.md b/problems/hexspeak/README.md index 9813d663b..a1b971d22 100644 --- a/problems/hexspeak/README.md +++ b/problems/hexspeak/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-people-report-to-the-given-manager "All People Report to the Given Manager") diff --git a/problems/hopper-company-queries-i/README.md b/problems/hopper-company-queries-i/README.md index da53acdea..c436e61f3 100644 --- a/problems/hopper-company-queries-i/README.md +++ b/problems/hopper-company-queries-i/README.md @@ -15,8 +15,3 @@ ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Trips and Users](../trips-and-users) (Hard) - 1. [Hopper Company Queries II](../hopper-company-queries-ii) (Hard) - 1. [Hopper Company Queries III](../hopper-company-queries-iii) (Hard) diff --git a/problems/hopper-company-queries-iii/README.md b/problems/hopper-company-queries-iii/README.md index 62a14af70..5424cf7fb 100644 --- a/problems/hopper-company-queries-iii/README.md +++ b/problems/hopper-company-queries-iii/README.md @@ -15,8 +15,3 @@ ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Trips and Users](../trips-and-users) (Hard) - 1. [Hopper Company Queries I](../hopper-company-queries-i) (Hard) - 1. [Hopper Company Queries II](../hopper-company-queries-ii) (Hard) diff --git a/problems/house-robber-iii/README.md b/problems/house-robber-iii/README.md index 4f3e1613f..350409147 100644 --- a/problems/house-robber-iii/README.md +++ b/problems/house-robber-iii/README.md @@ -43,9 +43,9 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/house-robber/README.md b/problems/house-robber/README.md index 572ab037c..a37cd0a07 100644 --- a/problems/house-robber/README.md +++ b/problems/house-robber/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rising-temperature "Rising Temperature") diff --git a/problems/how-many-numbers-are-smaller-than-the-current-number/README.md b/problems/how-many-numbers-are-smaller-than-the-current-number/README.md index 1418fd842..2b291471d 100644 --- a/problems/how-many-numbers-are-smaller-than-the-current-number/README.md +++ b/problems/how-many-numbers-are-smaller-than-the-current-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-trusted-contacts-of-a-customer "Number of Trusted Contacts of a Customer") diff --git a/problems/html-entity-parser/README.md b/problems/html-entity-parser/README.md index 87d42149e..5201de90f 100644 --- a/problems/html-entity-parser/README.md +++ b/problems/html-entity-parser/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../queries-on-a-permutation-with-key "Queries on a Permutation With Key") @@ -16,17 +16,17 @@

    The special characters and their entities for HTML are:

      -
    • Quotation Mark: the entity is &quot; and symbol character is ".
    • -
    • Single Quote Mark: the entity is &apos; and symbol character is '.
    • -
    • Ampersand: the entity is &amp; and symbol character is &.
    • -
    • Greater Than Sign: the entity is &gt; and symbol character is >.
    • -
    • Less Than Sign: the entity is &lt; and symbol character is <.
    • -
    • Slash: the entity is &frasl; and symbol character is /.
    • +
    • Quotation Mark: the entity is &quot; and symbol character is ".
    • +
    • Single Quote Mark: the entity is &apos; and symbol character is '.
    • +
    • Ampersand: the entity is &amp; and symbol character is &.
    • +
    • Greater Than Sign: the entity is &gt; and symbol character is >.
    • +
    • Less Than Sign: the entity is &lt; and symbol character is <.
    • +
    • Slash: the entity is &frasl; and symbol character is /.

    Given the input text string to the HTML parser, you have to implement the entity parser.

    -

    Return the text after replacing the entities by the special characters.

    +

    Return the text after replacing the entities by the special characters.

     

    Example 1:

    @@ -44,33 +44,12 @@ Output: "and I quote: \"...\""
    -

    Example 3:

    - -
    -Input: text = "Stay home! Practice on Leetcode :)"
    -Output: "Stay home! Practice on Leetcode :)"
    -
    - -

    Example 4:

    - -
    -Input: text = "x &gt; y &amp;&amp; x &lt; y is always false"
    -Output: "x > y && x < y is always false"
    -
    - -

    Example 5:

    - -
    -Input: text = "leetcode.com&frasl;problemset&frasl;all"
    -Output: "leetcode.com/problemset/all"
    -
    -

     

    Constraints:

      -
    • 1 <= text.length <= 10^5
    • -
    • The string may contain any possible characters out of all the 256 ASCII characters.
    • +
    • 1 <= text.length <= 105
    • +
    • The string may contain any possible characters out of all the 256 ASCII characters.
    ### Related Topics diff --git a/problems/image-overlap/README.md b/problems/image-overlap/README.md index 692a184da..808a96906 100644 --- a/problems/image-overlap/README.md +++ b/problems/image-overlap/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-distances-in-tree "Sum of Distances in Tree") diff --git a/problems/immediate-food-delivery-i/README.md b/problems/immediate-food-delivery-i/README.md index 857bf4d63..446d674e7 100644 --- a/problems/immediate-food-delivery-i/README.md +++ b/problems/immediate-food-delivery-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../dinner-plate-stacks "Dinner Plate Stacks") diff --git a/problems/immediate-food-delivery-ii/README.md b/problems/immediate-food-delivery-ii/README.md index 65fcea5cf..69aa37ffd 100644 --- a/problems/immediate-food-delivery-ii/README.md +++ b/problems/immediate-food-delivery-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../immediate-food-delivery-i "Immediate Food Delivery I") diff --git a/problems/implement-rand10-using-rand7/README.md b/problems/implement-rand10-using-rand7/README.md index 5ae0a32f1..9a1d23cdc 100644 --- a/problems/implement-rand10-using-rand7/README.md +++ b/problems/implement-rand10-using-rand7/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convex-polygon "Convex Polygon") diff --git a/problems/implement-strstr/README.md b/problems/implement-strstr/README.md index eaaae77cc..a744c0b83 100644 --- a/problems/implement-strstr/README.md +++ b/problems/implement-strstr/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-element "Remove Element") diff --git a/problems/increasing-decreasing-string/README.md b/problems/increasing-decreasing-string/README.md index a64f532bd..8a62e65a2 100644 --- a/problems/increasing-decreasing-string/README.md +++ b/problems/increasing-decreasing-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../get-the-second-most-recent-activity "Get the Second Most Recent Activity") @@ -11,21 +11,21 @@ ## [1370. Increasing Decreasing String (Easy)](https://leetcode.com/problems/increasing-decreasing-string "上升下降字符串") -

    Given a string s. You should re-order the string using the following algorithm:

    +

    You are given a string s. Reorder the string using the following algorithm:

    1. Pick the smallest character from s and append it to the result.
    2. Pick the smallest character from s which is greater than the last appended character to the result and append it.
    3. Repeat step 2 until you cannot pick more characters.
    4. -
    5. Pick the largest character from s and append it to the result.
    6. -
    7. Pick the largest character from s which is smaller than the last appended character to the result and append it.
    8. +
    9. Pick the largest character from s and append it to the result.
    10. +
    11. Pick the largest character from s which is smaller than the last appended character to the result and append it.
    12. Repeat step 5 until you cannot pick more characters.
    13. Repeat the steps from 1 to 6 until you pick all characters from s.

    In each step, If the smallest or the largest character appears more than once you can choose any occurrence and append it to the result.

    -

    Return the result string after sorting s with this algorithm.

    +

    Return the result string after sorting s with this algorithm.

     

    Example 1:

    @@ -48,33 +48,12 @@ After steps 4, 5 and 6 of the second iteration, result = "abccbaabccba" Explanation: The word "rat" becomes "art" after re-ordering it with the mentioned algorithm.
    -

    Example 3:

    - -
    -Input: s = "leetcode"
    -Output: "cdelotee"
    -
    - -

    Example 4:

    - -
    -Input: s = "ggggggg"
    -Output: "ggggggg"
    -
    - -

    Example 5:

    - -
    -Input: s = "spo"
    -Output: "ops"
    -
    -

     

    Constraints:

    • 1 <= s.length <= 500
    • -
    • s contains only lower-case English letters.
    • +
    • s consists of only lowercase English letters.
    ### Related Topics diff --git a/problems/integer-replacement/README.md b/problems/integer-replacement/README.md index ca7535ef4..6e163430d 100644 --- a/problems/integer-replacement/README.md +++ b/problems/integer-replacement/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rotate-function "Rotate Function") diff --git a/problems/integer-to-english-words/README.md b/problems/integer-to-english-words/README.md index a79d587c3..4bc0037c2 100644 --- a/problems/integer-to-english-words/README.md +++ b/problems/integer-to-english-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../closest-binary-search-tree-value-ii "Closest Binary Search Tree Value II") @@ -15,18 +15,26 @@

     

    Example 1:

    -
    Input: num = 123
    -Output: "One Hundred Twenty Three"
    -

    Example 2:

    -
    Input: num = 12345
    -Output: "Twelve Thousand Three Hundred Forty Five"
    -

    Example 3:

    -
    Input: num = 1234567
    -Output: "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven"
    -

    Example 4:

    -
    Input: num = 1234567891
    -Output: "One Billion Two Hundred Thirty Four Million Five Hundred Sixty Seven Thousand Eight Hundred Ninety One"
    +
    +
    +Input: num = 123
    +Output: "One Hundred Twenty Three"
    +
    + +

    Example 2:

    + +
    +Input: num = 12345
    +Output: "Twelve Thousand Three Hundred Forty Five"
     
    + +

    Example 3:

    + +
    +Input: num = 1234567
    +Output: "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven"
    +
    +

     

    Constraints:

    diff --git a/problems/intervals-between-identical-elements/README.md b/problems/intervals-between-identical-elements/README.md new file mode 100644 index 000000000..8b689aeac --- /dev/null +++ b/problems/intervals-between-identical-elements/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../execution-of-all-suffix-instructions-staying-in-a-grid "Execution of All Suffix Instructions Staying in a Grid") +                 +[Next >](../recover-the-original-array "Recover the Original Array") + +## [2121. Intervals Between Identical Elements (Medium)](https://leetcode.com/problems/intervals-between-identical-elements "相同元素的间隔之和") + +

    You are given a 0-indexed array of n integers arr.

    + +

    The interval between two elements in arr is defined as the absolute difference between their indices. More formally, the interval between arr[i] and arr[j] is |i - j|.

    + +

    Return an array intervals of length n where intervals[i] is the sum of intervals between arr[i] and each element in arr with the same value as arr[i].

    + +

    Note: |x| is the absolute value of x.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [2,1,3,1,2,3,3]
    +Output: [4,2,7,2,4,4,5]
    +Explanation:
    +- Index 0: Another 2 is found at index 4. |0 - 4| = 4
    +- Index 1: Another 1 is found at index 3. |1 - 3| = 2
    +- Index 2: Two more 3s are found at indices 5 and 6. |2 - 5| + |2 - 6| = 7
    +- Index 3: Another 1 is found at index 1. |3 - 1| = 2
    +- Index 4: Another 2 is found at index 0. |4 - 0| = 4
    +- Index 5: Two more 3s are found at indices 2 and 6. |5 - 2| + |5 - 6| = 4
    +- Index 6: Two more 3s are found at indices 2 and 5. |6 - 2| + |6 - 5| = 5
    +
    + +

    Example 2:

    + +
    +Input: arr = [10,5,10,10]
    +Output: [5,0,3,4]
    +Explanation:
    +- Index 0: Two more 10s are found at indices 2 and 3. |0 - 2| + |0 - 3| = 5
    +- Index 1: There is only one 5 in the array, so its sum of intervals to identical elements is 0.
    +- Index 2: Two more 10s are found at indices 0 and 3. |2 - 0| + |2 - 3| = 3
    +- Index 3: Two more 10s are found at indices 0 and 2. |3 - 0| + |3 - 2| = 4
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == arr.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= arr[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +For each unique value found in the array, store a sorted list of indices of elements that have this value in the array. +
    + +
    +Hint 2 +One way of doing this is to use a HashMap that maps the values to their list of indices. Update this mapping as you iterate through the array. +
    + +
    +Hint 3 +Process each list of indices separately and get the sum of intervals for the elements of that value by utilizing prefix sums. +
    + +
    +Hint 4 +For each element, keep track of the sum of indices of the identical elements that have come before and that will come after respectively. Use this to calculate the sum of intervals for that element to the rest of the elements with identical values. +
    diff --git a/problems/is-graph-bipartite/README.md b/problems/is-graph-bipartite/README.md index dd7928a28..fa8efd94f 100644 --- a/problems/is-graph-bipartite/README.md +++ b/problems/is-graph-bipartite/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../letter-case-permutation "Letter Case Permutation") diff --git a/problems/jump-game-iii/README.md b/problems/jump-game-iii/README.md index a8063e365..876cb75b2 100644 --- a/problems/jump-game-iii/README.md +++ b/problems/jump-game-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-elements-in-two-binary-search-trees "All Elements in Two Binary Search Trees") diff --git a/problems/jump-game-v/README.md b/problems/jump-game-v/README.md index ed8f8ea0c..5c5e3730c 100644 --- a/problems/jump-game-v/README.md +++ b/problems/jump-game-v/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-product-of-splitted-binary-tree "Maximum Product of Splitted Binary Tree") @@ -51,26 +51,12 @@ Similarly You cannot jump from index 3 to index 2 or index 1. Explanation: Start at index 0. You can visit all the indicies.
    -

    Example 4:

    - -
    -Input: arr = [7,1,7,1,7,1], d = 2
    -Output: 2
    -
    - -

    Example 5:

    - -
    -Input: arr = [66], d = 1
    -Output: 1
    -
    -

     

    Constraints:

    • 1 <= arr.length <= 1000
    • -
    • 1 <= arr[i] <= 10^5
    • +
    • 1 <= arr[i] <= 105
    • 1 <= d <= arr.length
    @@ -79,9 +65,6 @@ Similarly You cannot jump from index 3 to index 2 or index 1. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Jump Game VII](../jump-game-vii) (Medium) - ### Hints
    Hint 1 diff --git a/problems/jump-game-vi/README.md b/problems/jump-game-vi/README.md index e18bac1d8..80cd600af 100644 --- a/problems/jump-game-vi/README.md +++ b/problems/jump-game-vi/README.md @@ -52,16 +52,12 @@ ### Related Topics + [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Queue](../../tag/queue/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] [[Monotonic Queue](../../tag/monotonic-queue/README.md)] - -### Similar Questions - 1. [Sliding Window Maximum](../sliding-window-maximum) (Hard) - 1. [Jump Game VII](../jump-game-vii) (Medium) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/k-highest-ranked-items-within-a-price-range/README.md b/problems/k-highest-ranked-items-within-a-price-range/README.md new file mode 100644 index 000000000..85a214e2c --- /dev/null +++ b/problems/k-highest-ranked-items-within-a-price-range/README.md @@ -0,0 +1,121 @@ + + + + + + + +[< Previous](../count-the-hidden-sequences "Count the Hidden Sequences") +                 +[Next >](../number-of-ways-to-divide-a-long-corridor "Number of Ways to Divide a Long Corridor") + +## [2146. K Highest Ranked Items Within a Price Range (Medium)](https://leetcode.com/problems/k-highest-ranked-items-within-a-price-range "价格范围内最高排名的 K 样物品") + +

    You are given a 0-indexed 2D integer array grid of size m x n that represents a map of the items in a shop. The integers in the grid represent the following:

    + +
      +
    • 0 represents a wall that you cannot pass through.
    • +
    • 1 represents an empty cell that you can freely move to and from.
    • +
    • All other positive integers represent the price of an item in that cell. You may also freely move to and from these item cells.
    • +
    + +

    It takes 1 step to travel between adjacent grid cells.

    + +

    You are also given integer arrays pricing and start where pricing = [low, high] and start = [row, col] indicates that you start at the position (row, col) and are interested only in items with a price in the range of [low, high] (inclusive). You are further given an integer k.

    + +

    You are interested in the positions of the k highest-ranked items whose prices are within the given price range. The rank is determined by the first of these criteria that is different:

    + +
      +
    1. Distance, defined as the length of the shortest path from the start (shorter distance has a higher rank).
    2. +
    3. Price (lower price has a higher rank, but it must be in the price range).
    4. +
    5. The row number (smaller row number has a higher rank).
    6. +
    7. The column number (smaller column number has a higher rank).
    8. +
    + +

    Return the k highest-ranked items within the price range sorted by their rank (highest to lowest). If there are fewer than k reachable items within the price range, return all of them.

    + +

     

    +

    Example 1:

    + +
    +Input: grid = [[1,2,0,1],[1,3,0,1],[0,2,5,1]], pricing = [2,5], start = [0,0], k = 3
    +Output: [[0,1],[1,1],[2,1]]
    +Explanation: You start at (0,0).
    +With a price range of [2,5], we can take items from (0,1), (1,1), (2,1) and (2,2).
    +The ranks of these items are:
    +- (0,1) with distance 1
    +- (1,1) with distance 2
    +- (2,1) with distance 3
    +- (2,2) with distance 4
    +Thus, the 3 highest ranked items in the price range are (0,1), (1,1), and (2,1).
    +
    + +

    Example 2:

    + +
    +Input: grid = [[1,2,0,1],[1,3,3,1],[0,2,5,1]], pricing = [2,3], start = [2,3], k = 2
    +Output: [[2,1],[1,2]]
    +Explanation: You start at (2,3).
    +With a price range of [2,3], we can take items from (0,1), (1,1), (1,2) and (2,1).
    +The ranks of these items are:
    +- (2,1) with distance 2, price 2
    +- (1,2) with distance 2, price 3
    +- (1,1) with distance 3
    +- (0,1) with distance 4
    +Thus, the 2 highest ranked items in the price range are (2,1) and (1,2).
    +
    + +

    Example 3:

    + +
    +Input: grid = [[1,1,1],[0,0,1],[2,3,4]], pricing = [2,3], start = [0,0], k = 3
    +Output: [[2,1],[2,0]]
    +Explanation: You start at (0,0).
    +With a price range of [2,3], we can take items from (2,0) and (2,1). 
    +The ranks of these items are: 
    +- (2,1) with distance 5
    +- (2,0) with distance 6
    +Thus, the 2 highest ranked items in the price range are (2,1) and (2,0). 
    +Note that k = 3 but there are only 2 reachable items within the price range.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 105
    • +
    • 1 <= m * n <= 105
    • +
    • 0 <= grid[i][j] <= 105
    • +
    • pricing.length == 2
    • +
    • 2 <= low <= high <= 105
    • +
    • start.length == 2
    • +
    • 0 <= row <= m - 1
    • +
    • 0 <= col <= n - 1
    • +
    • grid[row][col] > 0
    • +
    • 1 <= k <= m * n
    • +
    + +### Related Topics + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +Could you determine the rank of every item efficiently? +
    + +
    +Hint 2 +We can perform a breadth-first search from the starting position and know the length of the shortest path from start to every item. +
    + +
    +Hint 3 +Sort all the items according to the conditions listed in the problem, and return the first k (or all if less than k exist) items as the answer. +
    diff --git a/problems/k-radius-subarray-averages/README.md b/problems/k-radius-subarray-averages/README.md new file mode 100644 index 000000000..f062f0a12 --- /dev/null +++ b/problems/k-radius-subarray-averages/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../find-target-indices-after-sorting-array "Find Target Indices After Sorting Array") +                 +[Next >](../removing-minimum-and-maximum-from-array "Removing Minimum and Maximum From Array") + +## [2090. K Radius Subarray Averages (Medium)](https://leetcode.com/problems/k-radius-subarray-averages "半径为 k 的子数组平均值") + +

    You are given a 0-indexed array nums of n integers, and an integer k.

    + +

    The k-radius average for a subarray of nums centered at some index i with the radius k is the average of all elements in nums between the indices i - k and i + k (inclusive). If there are less than k elements before or after the index i, then the k-radius average is -1.

    + +

    Build and return an array avgs of length n where avgs[i] is the k-radius average for the subarray centered at index i.

    + +

    The average of x elements is the sum of the x elements divided by x, using integer division. The integer division truncates toward zero, which means losing its fractional part.

    + +
      +
    • For example, the average of four elements 2, 3, 1, and 5 is (2 + 3 + 1 + 5) / 4 = 11 / 4 = 2.75, which truncates to 2.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: nums = [7,4,3,9,1,8,5,2,6], k = 3
    +Output: [-1,-1,-1,5,4,4,-1,-1,-1]
    +Explanation:
    +- avg[0], avg[1], and avg[2] are -1 because there are less than k elements before each index.
    +- The sum of the subarray centered at index 3 with radius 3 is: 7 + 4 + 3 + 9 + 1 + 8 + 5 = 37.
    +  Using integer division, avg[3] = 37 / 7 = 5.
    +- For the subarray centered at index 4, avg[4] = (4 + 3 + 9 + 1 + 8 + 5 + 2) / 7 = 4.
    +- For the subarray centered at index 5, avg[5] = (3 + 9 + 1 + 8 + 5 + 2 + 6) / 7 = 4.
    +- avg[6], avg[7], and avg[8] are -1 because there are less than k elements after each index.
    +
    + +

    Example 2:

    + +
    +Input: nums = [100000], k = 0
    +Output: [100000]
    +Explanation:
    +- The sum of the subarray centered at index 0 with radius 0 is: 100000.
    +  avg[0] = 100000 / 1 = 100000.
    +
    + +

    Example 3:

    + +
    +Input: nums = [8], k = 100000
    +Output: [-1]
    +Explanation: 
    +- avg[0] is -1 because there are less than k elements before and after index 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= n <= 105
    • +
    • 0 <= nums[i], k <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
    +Hint 1 +To calculate the average of a subarray, you need the sum and the K. K is already given. How could you quickly calculate the sum of a subarray? +
    + +
    +Hint 2 +Use the Prefix Sums method to calculate the subarray sums. +
    + +
    +Hint 3 +It is possible that the sum of all the elements does not fit in a 32-bit integer type. Be sure to use a 64-bit integer type for the prefix sum array. +
    diff --git a/problems/k-th-smallest-in-lexicographical-order/README.md b/problems/k-th-smallest-in-lexicographical-order/README.md index 00ede0949..b5ef1c26b 100644 --- a/problems/k-th-smallest-in-lexicographical-order/README.md +++ b/problems/k-th-smallest-in-lexicographical-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../ternary-expression-parser "Ternary Expression Parser") diff --git a/problems/keep-multiplying-found-values-by-two/README.md b/problems/keep-multiplying-found-values-by-two/README.md new file mode 100644 index 000000000..bb4be6ff6 --- /dev/null +++ b/problems/keep-multiplying-found-values-by-two/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../the-number-of-passengers-in-each-bus-ii "The Number of Passengers in Each Bus II") +                 +[Next >](../all-divisions-with-the-highest-score-of-a-binary-array "All Divisions With the Highest Score of a Binary Array") + +## [2154. Keep Multiplying Found Values by Two (Easy)](https://leetcode.com/problems/keep-multiplying-found-values-by-two "将找到的值乘以 2") + +

    You are given an array of integers nums. You are also given an integer original which is the first number that needs to be searched for in nums.

    + +

    You then do the following steps:

    + +
      +
    1. If original is found in nums, multiply it by two (i.e., set original = 2 * original).
    2. +
    3. Otherwise, stop the process.
    4. +
    5. Repeat this process with the new number as long as you keep finding the number.
    6. +
    + +

    Return the final value of original.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [5,3,6,1,12], original = 3
    +Output: 24
    +Explanation: 
    +- 3 is found in nums. 3 is multiplied by 2 to obtain 6.
    +- 6 is found in nums. 6 is multiplied by 2 to obtain 12.
    +- 12 is found in nums. 12 is multiplied by 2 to obtain 24.
    +- 24 is not found in nums. Thus, 24 is returned.
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,7,9], original = 4
    +Output: 4
    +Explanation:
    +- 4 is not found in nums. Thus, 4 is returned.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • 1 <= nums[i], original <= 1000
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Repeatedly iterate through the array and check if the current value of original is in the array. +
    + +
    +Hint 2 +If original is not found, stop and return its current value. +
    + +
    +Hint 3 +Otherwise, multiply original by 2 and repeat the process. +
    + +
    +Hint 4 +Use set data structure to check the existence faster. +
    diff --git a/problems/kill-process/README.md b/problems/kill-process/README.md index 7e5c758ca..bd317f457 100644 --- a/problems/kill-process/README.md +++ b/problems/kill-process/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-unsorted-continuous-subarray "Shortest Unsorted Continuous Subarray") diff --git a/problems/koko-eating-bananas/README.md b/problems/koko-eating-bananas/README.md index 89ee52e14..1a72a6186 100644 --- a/problems/koko-eating-bananas/README.md +++ b/problems/koko-eating-bananas/README.md @@ -56,3 +56,4 @@ ### Similar Questions 1. [Minimize Max Distance to Gas Station](../minimize-max-distance-to-gas-station) (Hard) + 1. [Minimized Maximum of Products Distributed to Any Store](../minimized-maximum-of-products-distributed-to-any-store) (Medium) diff --git a/problems/kth-largest-element-in-a-stream/README.md b/problems/kth-largest-element-in-a-stream/README.md index 100e1cf78..5c9061b41 100644 --- a/problems/kth-largest-element-in-a-stream/README.md +++ b/problems/kth-largest-element-in-a-stream/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../search-in-a-sorted-array-of-unknown-size "Search in a Sorted Array of Unknown Size") diff --git a/problems/largest-1-bordered-square/README.md b/problems/largest-1-bordered-square/README.md index 35359c6e7..b2e11e036 100644 --- a/problems/largest-1-bordered-square/README.md +++ b/problems/largest-1-bordered-square/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../alphabet-board-path "Alphabet Board Path") diff --git a/problems/largest-magic-square/README.md b/problems/largest-magic-square/README.md index d0553679e..c13ed708f 100644 --- a/problems/largest-magic-square/README.md +++ b/problems/largest-magic-square/README.md @@ -50,9 +50,6 @@ Every row sum, column sum, and diagonal sum of this magic square is equal to 12. [[Matrix](../../tag/matrix/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] -### Similar Questions - 1. [Magic Squares In Grid](../magic-squares-in-grid) (Medium) - ### Hints
    Hint 1 diff --git a/problems/largest-multiple-of-three/README.md b/problems/largest-multiple-of-three/README.md index 3995859b7..91ce76469 100644 --- a/problems/largest-multiple-of-three/README.md +++ b/problems/largest-multiple-of-three/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../closest-divisors "Closest Divisors") @@ -37,13 +37,6 @@ Output: "" -

    Example 4:

    - -
    -Input: digits = [0,0,0,0,0,0]
    -Output: "0"
    -
    -

     

    Constraints:

    @@ -53,9 +46,9 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/largest-number/README.md b/problems/largest-number/README.md index de24d869a..308b5ad2c 100644 --- a/problems/largest-number/README.md +++ b/problems/largest-number/README.md @@ -11,9 +11,9 @@ ## [179. Largest Number (Medium)](https://leetcode.com/problems/largest-number "最大数") -

    Given a list of non-negative integers nums, arrange them such that they form the largest number.

    +

    Given a list of non-negative integers nums, arrange them such that they form the largest number and return it.

    -

    Note: The result may be very large, so you need to return a string instead of an integer.

    +

    Since the result may be very large, so you need to return a string instead of an integer.

     

    Example 1:

    @@ -30,20 +30,6 @@ Output: "9534330" -

    Example 3:

    - -
    -Input: nums = [1]
    -Output: "1"
    -
    - -

    Example 4:

    - -
    -Input: nums = [10]
    -Output: "10"
    -
    -

     

    Constraints:

    diff --git a/problems/largest-odd-number-in-string/README.md b/problems/largest-odd-number-in-string/README.md index 71116c391..433ce9589 100644 --- a/problems/largest-odd-number-in-string/README.md +++ b/problems/largest-odd-number-in-string/README.md @@ -49,9 +49,9 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/largest-perimeter-triangle/README.md b/problems/largest-perimeter-triangle/README.md index 924d7001a..0bc3e6422 100644 --- a/problems/largest-perimeter-triangle/README.md +++ b/problems/largest-perimeter-triangle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../odd-even-jump "Odd Even Jump") @@ -15,18 +15,19 @@

     

    Example 1:

    -
    Input: nums = [2,1,2]
    +
    +
    +Input: nums = [2,1,2]
     Output: 5
    -

    Example 2:

    -
    Input: nums = [1,2,1]
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,2,1]
     Output: 0
    -

    Example 3:

    -
    Input: nums = [3,2,3,4]
    -Output: 10
    -

    Example 4:

    -
    Input: nums = [3,6,2,3]
    -Output: 8
     
    +

     

    Constraints:

    diff --git a/problems/largest-subarray-length-k/README.md b/problems/largest-subarray-length-k/README.md index f4590c82e..29371e2c9 100644 --- a/problems/largest-subarray-length-k/README.md +++ b/problems/largest-subarray-length-k/README.md @@ -14,8 +14,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/largest-submatrix-with-rearrangements/README.md b/problems/largest-submatrix-with-rearrangements/README.md index 6c614e375..fd5ac277b 100644 --- a/problems/largest-submatrix-with-rearrangements/README.md +++ b/problems/largest-submatrix-with-rearrangements/README.md @@ -17,9 +17,7 @@

     

    Example 1:

    - -

    - +
     Input: matrix = [[0,0,1],[1,1,1],[1,0,1]]
     Output: 4
    @@ -28,9 +26,7 @@ The largest submatrix of 1s, in bold, has an area of 4.
     

    Example 2:

    - -

    - +
     Input: matrix = [[1,0,1,0,1]]
     Output: 3
    @@ -43,14 +39,8 @@ The largest submatrix of 1s, in bold, has an area of 3.
     
     Input: matrix = [[1,1,0],[1,0,1]]
     Output: 2
    -Explanation: Notice that you must rearrange entire columns, and there is no way to make a submatrix of 1s larger than an area of 2.
    - -

    Example 4:

    - -
    -Input: matrix = [[0,0],[0,0]]
    -Output: 0
    -Explanation: As there are no 1s, no submatrix of 1s can be formed and the area is 0.
    +Explanation: Notice that you must rearrange entire columns, and there is no way to make a submatrix of 1s larger than an area of 2. +

     

    Constraints:

    @@ -59,7 +49,7 @@ The largest submatrix of 1s, in bold, has an area of 3.
  • m == matrix.length
  • n == matrix[i].length
  • 1 <= m * n <= 105
  • -
  • matrix[i][j] is 0 or 1.
  • +
  • matrix[i][j] is either 0 or 1.
  • ### Related Topics diff --git a/problems/largest-substring-between-two-equal-characters/README.md b/problems/largest-substring-between-two-equal-characters/README.md index c707c3506..46a160a10 100644 --- a/problems/largest-substring-between-two-equal-characters/README.md +++ b/problems/largest-substring-between-two-equal-characters/README.md @@ -39,14 +39,6 @@ Explanation: There are no characters that appear twice in s.
    -

    Example 4:

    - -
    -Input: s = "cabbac"
    -Output: 4
    -Explanation: The optimal substring here is "abba". Other non-optimal substrings include "bb" and "".
    -
    -

     

    Constraints:

    diff --git a/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md b/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md index 2cd2780b0..4c259e38a 100644 --- a/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md +++ b/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md @@ -11,13 +11,13 @@ ## [1503. Last Moment Before All Ants Fall Out of a Plank (Medium)](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank "所有蚂蚁掉下来前的最后一刻") -

    We have a wooden plank of the length n units. Some ants are walking on the plank, each ant moves with speed 1 unit per second. Some of the ants move to the left, the other move to the right.

    +

    We have a wooden plank of the length n units. Some ants are walking on the plank, each ant moves with a speed of 1 unit per second. Some of the ants move to the left, the other move to the right.

    -

    When two ants moving in two different directions meet at some point, they change their directions and continue moving again. Assume changing directions doesn't take any additional time.

    +

    When two ants moving in two different directions meet at some point, they change their directions and continue moving again. Assume changing directions does not take any additional time.

    -

    When an ant reaches one end of the plank at a time t, it falls out of the plank imediately.

    +

    When an ant reaches one end of the plank at a time t, it falls out of the plank immediately.

    -

    Given an integer n and two integer arrays left and right, the positions of the ants moving to the left and the right. Return the moment when the last ant(s) fall out of the plank.

    +

    Given an integer n and two integer arrays left and right, the positions of the ants moving to the left and the right, return the moment when the last ant(s) fall out of the plank.

     

    Example 1:

    @@ -30,7 +30,7 @@ -The ant at index 1 is named B and going to the right. -The ant at index 3 is named C and going to the left. -The ant at index 4 is named D and going to the left. -Note that the last moment when an ant was on the plank is t = 4 second, after that it falls imediately out of the plank. (i.e. We can say that at t = 4.0000000001, there is no ants on the plank). +The last moment when an ant was on the plank is t = 4 seconds. After that, it falls immediately out of the plank. (i.e., We can say that at t = 4.0000000001, there are no ants on the plank).

    Example 2:

    @@ -49,26 +49,11 @@ Note that the last moment when an ant was on the plank is t = 4 second, after th Explanation: All ants are going to the left, the ant at index 7 needs 7 seconds to fall. -

    Example 4:

    - -
    -Input: n = 9, left = [5], right = [4]
    -Output: 5
    -Explanation: At t = 1 second, both ants will be at the same intial position but with different direction.
    -
    - -

    Example 5:

    - -
    -Input: n = 6, left = [6], right = [0]
    -Output: 6
    -
    -

     

    Constraints:

      -
    • 1 <= n <= 10^4
    • +
    • 1 <= n <= 104
    • 0 <= left.length <= n + 1
    • 0 <= left[i] <= n
    • 0 <= right.length <= n + 1
    • @@ -78,8 +63,8 @@ Note that the last moment when an ant was on the plank is t = 4 second, after th
    ### Related Topics - [[Array](../../tag/array/README.md)] [[Brainteaser](../../tag/brainteaser/README.md)] + [[Array](../../tag/array/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/least-number-of-unique-integers-after-k-removals/README.md b/problems/least-number-of-unique-integers-after-k-removals/README.md index e31706f4f..07b4b71a6 100644 --- a/problems/least-number-of-unique-integers-after-k-removals/README.md +++ b/problems/least-number-of-unique-integers-after-k-removals/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../running-sum-of-1d-array "Running Sum of 1d Array") diff --git a/problems/leetcodify-friends-recommendations/README.md b/problems/leetcodify-friends-recommendations/README.md index cb786fb0e..dcc682953 100644 --- a/problems/leetcodify-friends-recommendations/README.md +++ b/problems/leetcodify-friends-recommendations/README.md @@ -9,7 +9,7 @@                  [Next >](../kth-smallest-subarray-sum "Kth Smallest Subarray Sum") -## [1917. Leetcodify Friends Recommendations (Hard)](https://leetcode.com/problems/leetcodify-friends-recommendations "") +## [1917. Leetcodify Friends Recommendations (Hard)](https://leetcode.com/problems/leetcodify-friends-recommendations "Leetcodify 好友推荐") diff --git a/problems/leetcodify-similar-friends/README.md b/problems/leetcodify-similar-friends/README.md index f7168514e..3d20773a3 100644 --- a/problems/leetcodify-similar-friends/README.md +++ b/problems/leetcodify-similar-friends/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Leetcodify Friends Recommendations](../leetcodify-friends-recommendations) (Hard) diff --git a/problems/leftmost-column-with-at-least-a-one/README.md b/problems/leftmost-column-with-at-least-a-one/README.md index 52434c5cc..da3d04af4 100644 --- a/problems/leftmost-column-with-at-least-a-one/README.md +++ b/problems/leftmost-column-with-at-least-a-one/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../perform-string-shifts "Perform String Shifts") @@ -16,8 +16,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Interactive](../../tag/interactive/README.md)] [[Matrix](../../tag/matrix/README.md)] + [[Interactive](../../tag/interactive/README.md)] ### Hints
    diff --git a/problems/letter-case-permutation/README.md b/problems/letter-case-permutation/README.md index 1599aa88b..975c5da62 100644 --- a/problems/letter-case-permutation/README.md +++ b/problems/letter-case-permutation/README.md @@ -11,9 +11,9 @@ ## [784. Letter Case Permutation (Medium)](https://leetcode.com/problems/letter-case-permutation "字母大小写全排列") -

    Given a string s, we can transform every letter individually to be lowercase or uppercase to create another string.

    +

    Given a string s, you can transform every letter individually to be lowercase or uppercase to create another string.

    -

    Return a list of all possible strings we could create. You can return the output in any order.

    +

    Return a list of all possible strings we could create. Return the output in any order.

     

    Example 1:

    @@ -30,32 +30,18 @@ Output: ["3z4","3Z4"] -

    Example 3:

    - -
    -Input: s = "12345"
    -Output: ["12345"]
    -
    - -

    Example 4:

    - -
    -Input: s = "0"
    -Output: ["0"]
    -
    -

     

    Constraints:

      -
    • s will be a string with length between 1 and 12.
    • -
    • s will consist only of letters or digits.
    • +
    • 1 <= s.length <= 12
    • +
    • s consists of lowercase English letters, uppercase English letters, and digits.
    ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Subsets](../subsets) (Medium) diff --git a/problems/lexicographically-smallest-string-after-applying-operations/README.md b/problems/lexicographically-smallest-string-after-applying-operations/README.md index d0c943cb6..09ea81db8 100644 --- a/problems/lexicographically-smallest-string-after-applying-operations/README.md +++ b/problems/lexicographically-smallest-string-after-applying-operations/README.md @@ -30,15 +30,15 @@
     Input: s = "5525", a = 9, b = 2
     Output: "2050"
    -Explanation: We can apply the following operations:
    +Explanation: We can apply the following operations:
     Start:  "5525"
     Rotate: "2555"
     Add:    "2454"
     Add:    "2353"
     Rotate: "5323"
     Add:    "5222"
    -​​​​​​​Add:    "5121"
    -​​​​​​​Rotate: "2151"
    +Add:    "5121"
    +Rotate: "2151"
     ​​​​​​​Add:    "2050"​​​​​​​​​​​​
     There is no way to obtain a string that is lexicographically smaller then "2050".
     
    @@ -48,7 +48,7 @@ There is no way to obtain a string that is lexicographically smaller then "
     Input: s = "74", a = 5, b = 1
     Output: "24"
    -Explanation: We can apply the following operations:
    +Explanation: We can apply the following operations:
     Start:  "74"
     Rotate: "47"
     ​​​​​​​Add:    "42"
    @@ -61,14 +61,7 @@ There is no way to obtain a string that is lexicographically smaller then "
     
     Input: s = "0011", a = 4, b = 2
     Output: "0011"
    -Explanation: There are no sequence of operations that will give us a lexicographically smaller string than "0011".
    -
    - -

    Example 4:

    - -
    -Input: s = "43987654", a = 7, b = 3
    -Output: "00553311"
    +Explanation: There are no sequence of operations that will give us a lexicographically smaller string than "0011".
     

     

    @@ -83,8 +76,8 @@ There is no way to obtain a string that is lexicographically smaller then " ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[String](../../tag/string/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Hints
    diff --git a/problems/line-reflection/README.md b/problems/line-reflection/README.md index e102b042a..ba950f01d 100644 --- a/problems/line-reflection/README.md +++ b/problems/line-reflection/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-twitter "Design Twitter") diff --git a/problems/linked-list-in-binary-tree/README.md b/problems/linked-list-in-binary-tree/README.md index bd5ccf805..9b1a71dfe 100644 --- a/problems/linked-list-in-binary-tree/README.md +++ b/problems/linked-list-in-binary-tree/README.md @@ -55,10 +55,10 @@ ### Related Topics + [[Linked List](../../tag/linked-list/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Linked List](../../tag/linked-list/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/logger-rate-limiter/README.md b/problems/logger-rate-limiter/README.md index 20267a79e..52a6f01b0 100644 --- a/problems/logger-rate-limiter/README.md +++ b/problems/logger-rate-limiter/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rearrange-string-k-distance-apart "Rearrange String k Distance Apart") diff --git a/problems/longer-contiguous-segments-of-ones-than-zeros/README.md b/problems/longer-contiguous-segments-of-ones-than-zeros/README.md index ea4ae8c81..a95dfe168 100644 --- a/problems/longer-contiguous-segments-of-ones-than-zeros/README.md +++ b/problems/longer-contiguous-segments-of-ones-than-zeros/README.md @@ -64,6 +64,11 @@ The segment of 1s is not longer, so return false. ### Related Topics [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Max Consecutive Ones](../max-consecutive-ones) (Easy) + 1. [Count Subarrays With More Ones Than Zeros](../count-subarrays-with-more-ones-than-zeros) (Medium) + 1. [Check if Binary String Has at Most One Segment of Ones](../check-if-binary-string-has-at-most-one-segment-of-ones) (Easy) + ### Hints
    Hint 1 diff --git a/problems/longest-arithmetic-subsequence-of-given-difference/README.md b/problems/longest-arithmetic-subsequence-of-given-difference/README.md index 4158fbe84..dc350155e 100644 --- a/problems/longest-arithmetic-subsequence-of-given-difference/README.md +++ b/problems/longest-arithmetic-subsequence-of-given-difference/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-move-chips-to-the-same-position "Minimum Cost to Move Chips to The Same Position") diff --git a/problems/longest-arithmetic-subsequence/README.md b/problems/longest-arithmetic-subsequence/README.md index a11e3f40c..33b7de800 100644 --- a/problems/longest-arithmetic-subsequence/README.md +++ b/problems/longest-arithmetic-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-difference-between-node-and-ancestor "Maximum Difference Between Node and Ancestor") diff --git a/problems/longest-chunked-palindrome-decomposition/README.md b/problems/longest-chunked-palindrome-decomposition/README.md index 6c7f56e26..6e555f50b 100644 --- a/problems/longest-chunked-palindrome-decomposition/README.md +++ b/problems/longest-chunked-palindrome-decomposition/README.md @@ -46,14 +46,6 @@ Explanation: We can split the string on "(a)(nt)(a)(pre)(za)(tpe)(za)(pre)(a)(nt)(a)".
    -

    Example 4:

    - -
    -Input: text = "aaa"
    -Output: 3
    -Explanation: We can split the string on "(a)(a)(a)".
    -
    -

     

    Constraints:

    diff --git a/problems/longest-common-subsequence-between-sorted-arrays/README.md b/problems/longest-common-subsequence-between-sorted-arrays/README.md index 3f9f604dc..1477353b8 100644 --- a/problems/longest-common-subsequence-between-sorted-arrays/README.md +++ b/problems/longest-common-subsequence-between-sorted-arrays/README.md @@ -18,6 +18,9 @@ [[Hash Table](../../tag/hash-table/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Merge Two Sorted Lists](../merge-two-sorted-lists) (Easy) + ### Hints
    Hint 1 diff --git a/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md index 66c810ef5..ae7344147 100644 --- a/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md +++ b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-all-1s-are-at-least-length-k-places-away "Check If All 1's Are at Least Length K Places Away") @@ -58,12 +58,12 @@ Therefore, the size of the longest subarray is 2. ### Related Topics - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] + [[Queue](../../tag/queue/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Monotonic Queue](../../tag/monotonic-queue/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] ### Hints
    diff --git a/problems/longest-duplicate-substring/README.md b/problems/longest-duplicate-substring/README.md index b40016fef..e3a41f9d7 100644 --- a/problems/longest-duplicate-substring/README.md +++ b/problems/longest-duplicate-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../partition-array-for-maximum-sum "Partition Array for Maximum Sum") @@ -34,10 +34,10 @@ ### Related Topics [[String](../../tag/string/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Suffix Array](../../tag/suffix-array/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Hash Function](../../tag/hash-function/README.md)] [[Rolling Hash](../../tag/rolling-hash/README.md)] + [[Suffix Array](../../tag/suffix-array/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Hints
    diff --git a/problems/longest-happy-prefix/README.md b/problems/longest-happy-prefix/README.md index 673083037..7fa67f4df 100644 --- a/problems/longest-happy-prefix/README.md +++ b/problems/longest-happy-prefix/README.md @@ -32,20 +32,6 @@ Explanation: "abab" is the largest prefix which is also suffix. They can overlap in the original string. -

    Example 3:

    - -
    -Input: s = "leetcodeleet"
    -Output: "leet"
    -
    - -

    Example 4:

    - -
    -Input: s = "a"
    -Output: ""
    -
    -

     

    Constraints:

    @@ -56,9 +42,9 @@ ### Related Topics [[String](../../tag/string/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] [[String Matching](../../tag/string-matching/README.md)] [[Hash Function](../../tag/hash-function/README.md)] - [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/longest-happy-string/README.md b/problems/longest-happy-string/README.md index bd6c6c74d..a07549769 100644 --- a/problems/longest-happy-string/README.md +++ b/problems/longest-happy-string/README.md @@ -11,17 +11,19 @@ ## [1405. Longest Happy String (Medium)](https://leetcode.com/problems/longest-happy-string "最长快乐字符串") -

    A string is called happy if it does not have any of the strings 'aaa', 'bbb' or 'ccc' as a substring.

    - -

    Given three integers a, b and c, return any string s, which satisfies following conditions:

    +

    A string s is called happy if it satisfies the following conditions:

      -
    • s is happy and longest possible.
    • -
    • s contains at most a occurrences of the letter 'a', at most b occurrences of the letter 'b' and at most c occurrences of the letter 'c'.
    • -
    • will only contain 'a', 'b' and 'c' letters.
    • +
    • s only contains the letters 'a', 'b', and 'c'.
    • +
    • s does not contain any of "aaa", "bbb", or "ccc" as a substring.
    • +
    • s contains at most a occurrences of the letter 'a'.
    • +
    • s contains at most b occurrences of the letter 'b'.
    • +
    • s contains at most c occurrences of the letter 'c'.
    -

    If there is no such string s return the empty string "".

    +

    Given three integers a, b, and c, return the longest possible happy string. If there are multiple longest happy strings, return any of them. If there is no such string, return the empty string "".

    + +

    A substring is a contiguous sequence of characters within a string.

     

    Example 1:

    @@ -34,17 +36,10 @@

    Example 2:

    -
    -Input: a = 2, b = 2, c = 1
    -Output: "aabbc"
    -
    - -

    Example 3:

    -
     Input: a = 7, b = 1, c = 0
     Output: "aabaa"
    -Explanation: It's the only correct answer in this case.
    +Explanation: It is the only correct answer in this case.
     

     

    @@ -60,6 +55,9 @@ [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] +### Similar Questions + 1. [Reorganize String](../reorganize-string) (Medium) + ### Hints
    Hint 1 diff --git a/problems/longest-harmonious-subsequence/README.md b/problems/longest-harmonious-subsequence/README.md index 61d1605f2..a965eb210 100644 --- a/problems/longest-harmonious-subsequence/README.md +++ b/problems/longest-harmonious-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-square "Valid Square") diff --git a/problems/longest-increasing-path-in-a-matrix/README.md b/problems/longest-increasing-path-in-a-matrix/README.md index 2561b5543..e03319e78 100644 --- a/problems/longest-increasing-path-in-a-matrix/README.md +++ b/problems/longest-increasing-path-in-a-matrix/README.md @@ -50,9 +50,9 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] [[Memoization](../../tag/memoization/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/longest-mountain-in-array/README.md b/problems/longest-mountain-in-array/README.md index 275d9a58e..c391abf44 100644 --- a/problems/longest-mountain-in-array/README.md +++ b/problems/longest-mountain-in-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../backspace-string-compare "Backspace String Compare") diff --git a/problems/longest-nice-substring/README.md b/problems/longest-nice-substring/README.md index 8d3fc5369..20b09a0f5 100644 --- a/problems/longest-nice-substring/README.md +++ b/problems/longest-nice-substring/README.md @@ -30,22 +30,16 @@
     Input: s = "Bb"
     Output: "Bb"
    -Explanation: "Bb" is a nice string because both 'B' and 'b' appear. The whole string is a substring.
    +Explanation: "Bb" is a nice string because both 'B' and 'b' appear. The whole string is a substring. +

    Example 3:

     Input: s = "c"
     Output: ""
    -Explanation: There are no nice substrings.
    - -

    Example 4:

    - -
    -Input: s = "dDzeE"
    -Output: "dD"
    -Explanation: Both "dD" and "eE" are the longest nice substrings.
    -As there are multiple longest nice substrings, return "dD" since it occurs earlier.
    +Explanation: There are no nice substrings. +

     

    Constraints:

    diff --git a/problems/longest-palindrome-by-concatenating-two-letter-words/README.md b/problems/longest-palindrome-by-concatenating-two-letter-words/README.md new file mode 100644 index 000000000..3efa72307 --- /dev/null +++ b/problems/longest-palindrome-by-concatenating-two-letter-words/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../maximum-twin-sum-of-a-linked-list "Maximum Twin Sum of a Linked List") +                 +[Next >](../stamping-the-grid "Stamping the Grid") + +## [2131. Longest Palindrome by Concatenating Two Letter Words (Medium)](https://leetcode.com/problems/longest-palindrome-by-concatenating-two-letter-words "连接两字母单词得到的最长回文串") + +

    You are given an array of strings words. Each element of words consists of two lowercase English letters.

    + +

    Create the longest possible palindrome by selecting some elements from words and concatenating them in any order. Each element can be selected at most once.

    + +

    Return the length of the longest palindrome that you can create. If it is impossible to create any palindrome, return 0.

    + +

    A palindrome is a string that reads the same forward and backward.

    + +

     

    +

    Example 1:

    + +
    +Input: words = ["lc","cl","gg"]
    +Output: 6
    +Explanation: One longest palindrome is "lc" + "gg" + "cl" = "lcggcl", of length 6.
    +Note that "clgglc" is another longest palindrome that can be created.
    +
    + +

    Example 2:

    + +
    +Input: words = ["ab","ty","yt","lc","cl","ab"]
    +Output: 8
    +Explanation: One longest palindrome is "ty" + "lc" + "cl" + "yt" = "tylcclyt", of length 8.
    +Note that "lcyttycl" is another longest palindrome that can be created.
    +
    + +

    Example 3:

    + +
    +Input: words = ["cc","ll","xx"]
    +Output: 2
    +Explanation: One longest palindrome is "cc", of length 2.
    +Note that "ll" is another longest palindrome that can be created, and so is "xx".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 105
    • +
    • words[i].length == 2
    • +
    • words[i] consists of lowercase English letters.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Hints +
    +Hint 1 +A palindrome must be mirrored over the center. Suppose we have a palindrome. If we prepend the word "ab" on the left, what must we append on the right to keep it a palindrome? +
    + +
    +Hint 2 +We must append "ba" on the right. The number of times we can do this is the minimum of (occurrences of "ab") and (occurrences of "ba"). +
    + +
    +Hint 3 +For words that are already palindromes, e.g. "aa", we can prepend and append these in pairs as described in the previous hint. We can also use exactly one in the middle to form an even longer palindrome. +
    diff --git a/problems/longest-palindromic-subsequence-ii/README.md b/problems/longest-palindromic-subsequence-ii/README.md index 7e5d73629..7f8a858a1 100644 --- a/problems/longest-palindromic-subsequence-ii/README.md +++ b/problems/longest-palindromic-subsequence-ii/README.md @@ -17,6 +17,9 @@ [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Longest Palindromic Subsequence](../longest-palindromic-subsequence) (Medium) + ### Hints
    Hint 1 diff --git a/problems/longest-subarray-of-1s-after-deleting-one-element/README.md b/problems/longest-subarray-of-1s-after-deleting-one-element/README.md index 6da0a32b4..4c5892b99 100644 --- a/problems/longest-subarray-of-1s-after-deleting-one-element/README.md +++ b/problems/longest-subarray-of-1s-after-deleting-one-element/README.md @@ -21,34 +21,23 @@
     Input: nums = [1,1,0,1]
     Output: 3
    -Explanation: After deleting the number in position 2, [1,1,1] contains 3 numbers with value of 1's.
    +Explanation: After deleting the number in position 2, [1,1,1] contains 3 numbers with value of 1's. +

    Example 2:

     Input: nums = [0,1,1,1,0,1,1,0,1]
     Output: 5
    -Explanation: After deleting the number in position 4, [0,1,1,1,1,1,0,1] longest subarray with value of 1's is [1,1,1,1,1].
    +Explanation: After deleting the number in position 4, [0,1,1,1,1,1,0,1] longest subarray with value of 1's is [1,1,1,1,1]. +

    Example 3:

     Input: nums = [1,1,1]
     Output: 2
    -Explanation: You must delete one element.
    - -

    Example 4:

    - -
    -Input: nums = [1,1,0,0,1,1,1,0,1]
    -Output: 4
    -
    - -

    Example 5:

    - -
    -Input: nums = [0,0,0]
    -Output: 0
    +Explanation: You must delete one element.
     

     

    diff --git a/problems/longest-subsequence-repeated-k-times/README.md b/problems/longest-subsequence-repeated-k-times/README.md index eb18b2de0..2879b957e 100644 --- a/problems/longest-subsequence-repeated-k-times/README.md +++ b/problems/longest-subsequence-repeated-k-times/README.md @@ -49,14 +49,6 @@ Explanation: There is no subsequence repeated 2 times. Empty string is returned. -

    Example 4:

    - -
    -Input: s = "bbabbabbbbabaababab", k = 3
    -Output: "bbbb"
    -Explanation: The longest subsequence "bbbb" is repeated 3 times in "bbabbabbbbabaababab".
    -
    -

     

    Constraints:

    diff --git a/problems/longest-uncommon-subsequence-ii/README.md b/problems/longest-uncommon-subsequence-ii/README.md index 218b3d5fd..be9dd896a 100644 --- a/problems/longest-uncommon-subsequence-ii/README.md +++ b/problems/longest-uncommon-subsequence-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-uncommon-subsequence-i "Longest Uncommon Subsequence I") diff --git a/problems/longest-univalue-path/README.md b/problems/longest-univalue-path/README.md index de2efc274..87333d2cc 100644 --- a/problems/longest-univalue-path/README.md +++ b/problems/longest-univalue-path/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../repeated-string-match "Repeated String Match") diff --git a/problems/longest-winning-streak/README.md b/problems/longest-winning-streak/README.md new file mode 100644 index 000000000..d136c15df --- /dev/null +++ b/problems/longest-winning-streak/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../maximum-and-sum-of-array "Maximum AND Sum of Array") +                 +Next > + +## [2173. Longest Winning Streak (Hard)](https://leetcode.com/problems/longest-winning-streak "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/longest-winning-streak/mysql_schemas.sql b/problems/longest-winning-streak/mysql_schemas.sql new file mode 100644 index 000000000..6da5cb0fb --- /dev/null +++ b/problems/longest-winning-streak/mysql_schemas.sql @@ -0,0 +1,10 @@ +Create table If Not Exists Matches (player_id int, match_day date, result ENUM('Win', 'Draw', 'Lose')); +Truncate table Matches; +insert into Matches (player_id, match_day, result) values ('1', '2022-01-17', 'Win'); +insert into Matches (player_id, match_day, result) values ('1', '2022-01-18', 'Win'); +insert into Matches (player_id, match_day, result) values ('1', '2022-01-25', 'Win'); +insert into Matches (player_id, match_day, result) values ('1', '2022-01-31', 'Draw'); +insert into Matches (player_id, match_day, result) values ('1', '2022-02-08', 'Win'); +insert into Matches (player_id, match_day, result) values ('2', '2022-02-06', 'Lose'); +insert into Matches (player_id, match_day, result) values ('2', '2022-02-08', 'Lose'); +insert into Matches (player_id, match_day, result) values ('3', '2022-03-30', 'Win'); diff --git a/problems/low-quality-problems/README.md b/problems/low-quality-problems/README.md index 9daaf212c..09b5a0c7a 100644 --- a/problems/low-quality-problems/README.md +++ b/problems/low-quality-problems/README.md @@ -9,7 +9,7 @@                  [Next >](../minimum-moves-to-convert-string "Minimum Moves to Convert String") -## [2026. Low-Quality Problems (Easy)](https://leetcode.com/problems/low-quality-problems "") +## [2026. Low-Quality Problems (Easy)](https://leetcode.com/problems/low-quality-problems "低质量的问题") diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md index 026487e5f..a616f79c8 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md @@ -18,6 +18,14 @@ [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Lowest Common Ancestor of a Binary Search Tree](../lowest-common-ancestor-of-a-binary-search-tree) (Easy) + 1. [Lowest Common Ancestor of a Binary Tree](../lowest-common-ancestor-of-a-binary-tree) (Medium) + 1. [Lowest Common Ancestor of Deepest Leaves](../lowest-common-ancestor-of-deepest-leaves) (Medium) + 1. [Lowest Common Ancestor of a Binary Tree II](../lowest-common-ancestor-of-a-binary-tree-ii) (Medium) + 1. [Lowest Common Ancestor of a Binary Tree III](../lowest-common-ancestor-of-a-binary-tree-iii) (Medium) + 1. [Lowest Common Ancestor of a Binary Tree IV](../lowest-common-ancestor-of-a-binary-tree-iv) (Medium) + ### Hints
    Hint 1 diff --git a/problems/lowest-common-ancestor-of-a-binary-tree/README.md b/problems/lowest-common-ancestor-of-a-binary-tree/README.md index 6baf04ac6..bd54f479f 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lowest-common-ancestor-of-a-binary-search-tree "Lowest Common Ancestor of a Binary Search Tree") diff --git a/problems/majority-element-ii/README.md b/problems/majority-element-ii/README.md index 8fe8073d6..07c9879d8 100644 --- a/problems/majority-element-ii/README.md +++ b/problems/majority-element-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../summary-ranges "Summary Ranges") @@ -13,8 +13,6 @@

    Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times.

    -

    Follow-up: Could you solve the problem in linear time and in O(1) space?

    -

     

    Example 1:

    @@ -45,11 +43,14 @@
  • -109 <= nums[i] <= 109
  • +

     

    +

    Follow up: Could you solve the problem in linear time and in O(1) space?

    + ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Counting](../../tag/counting/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Counting](../../tag/counting/README.md)] ### Similar Questions 1. [Majority Element](../majority-element) (Easy) diff --git a/problems/majority-element/README.md b/problems/majority-element/README.md index ae8eb9d3d..0e1ec3228 100644 --- a/problems/majority-element/README.md +++ b/problems/majority-element/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../excel-sheet-column-title "Excel Sheet Column Title") diff --git a/problems/make-sum-divisible-by-p/README.md b/problems/make-sum-divisible-by-p/README.md index ecef87f72..bcdc0d891 100644 --- a/problems/make-sum-divisible-by-p/README.md +++ b/problems/make-sum-divisible-by-p/README.md @@ -42,21 +42,6 @@ Explanation: Here the sum is 6. which is already divisible by 3. Thus we do not need to remove anything. -

    Example 4:

    - -
    -Input: nums = [1,2,3], p = 7
    -Output: -1
    -Explanation: There is no way to remove a subarray in order to get a sum divisible by 7.
    -
    - -

    Example 5:

    - -
    -Input: nums = [1000000000,1000000000,1000000000], p = 3
    -Output: 0
    -
    -

     

    Constraints:

    diff --git a/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md b/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md index 7ccaa9fe5..3f98c203d 100644 --- a/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md +++ b/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rectangles-area "Rectangles Area") @@ -11,11 +11,9 @@ ## [1460. Make Two Arrays Equal by Reversing Sub-arrays (Easy)](https://leetcode.com/problems/make-two-arrays-equal-by-reversing-sub-arrays "通过翻转子数组使两个数组相等") -

    Given two integer arrays of equal length target and arr.

    +

    You are given two integer arrays of equal length target and arr. In one step, you can select any non-empty sub-array of arr and reverse it. You are allowed to make any number of steps.

    -

    In one step, you can select any non-empty sub-array of arr and reverse it. You are allowed to make any number of steps.

    - -

    Return True if you can make arr equal to target, or False otherwise.

    +

    Return true if you can make arr equal to target or false otherwise.

     

    Example 1:

    @@ -40,24 +38,10 @@ There are multiple ways to convert arr to target, this is not the only way to do

    Example 3:

    -
    -Input: target = [1,12], arr = [12,1]
    -Output: true
    -
    - -

    Example 4:

    -
     Input: target = [3,7,9], arr = [3,7,11]
     Output: false
    -Explanation: arr doesn't have value 9 and it can never be converted to target.
    -
    - -

    Example 5:

    - -
    -Input: target = [1,1,1,1,1], arr = [1,1,1,1,1]
    -Output: true
    +Explanation: arr does not have value 9 and it can never be converted to target.
     

     

    diff --git a/problems/making-file-names-unique/README.md b/problems/making-file-names-unique/README.md index dc950449f..0b8995d41 100644 --- a/problems/making-file-names-unique/README.md +++ b/problems/making-file-names-unique/README.md @@ -11,11 +11,11 @@ ## [1487. Making File Names Unique (Medium)](https://leetcode.com/problems/making-file-names-unique "保证文件名唯一") -

    Given an array of strings names of size n. You will create n folders in your file system such that, at the ith minute, you will create a folder with the name names[i].

    +

    Given an array of strings names of size n. You will create n folders in your file system such that, at the ith minute, you will create a folder with the name names[i].

    -

    Since two files cannot have the same name, if you enter a folder name which is previously used, the system will have a suffix addition to its name in the form of (k), where, k is the smallest positive integer such that the obtained name remains unique.

    +

    Since two files cannot have the same name, if you enter a folder name that was previously used, the system will have a suffix addition to its name in the form of (k), where, k is the smallest positive integer such that the obtained name remains unique.

    -

    Return an array of strings of length n where ans[i] is the actual name the system will assign to the ith folder when you create it.

    +

    Return an array of strings of length n where ans[i] is the actual name the system will assign to the ith folder when you create it.

     

    Example 1:

    @@ -50,29 +50,13 @@ Explanation: When the last folder is created, the smallest positive valid k is 4, and it becomes "onepiece(4)". -

    Example 4:

    - -
    -Input: names = ["wano","wano","wano","wano"]
    -Output: ["wano","wano(1)","wano(2)","wano(3)"]
    -Explanation: Just increase the value of k each time you create folder "wano".
    -
    - -

    Example 5:

    - -
    -Input: names = ["kaido","kaido(1)","kaido","kaido(1)"]
    -Output: ["kaido","kaido(1)","kaido(2)","kaido(1)(1)"]
    -Explanation: Please note that system adds the suffix (k) to current name even it contained the same suffix before.
    -
    -

     

    Constraints:

      -
    • 1 <= names.length <= 5 * 10^4
    • +
    • 1 <= names.length <= 5 * 104
    • 1 <= names[i].length <= 20
    • -
    • names[i] consists of lower case English letters, digits and/or round brackets.
    • +
    • names[i] consists of lowercase English letters, digits, and/or round brackets.
    ### Related Topics diff --git a/problems/map-sum-pairs/README.md b/problems/map-sum-pairs/README.md index 2332b6706..ffca94185 100644 --- a/problems/map-sum-pairs/README.md +++ b/problems/map-sum-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../implement-magic-dictionary "Implement Magic Dictionary") @@ -55,7 +55,7 @@ mapSum.sum("ap"); // return 5 (apple + app = 3 ### Related Topics - [[Design](../../tag/design/README.md)] - [[Trie](../../tag/trie/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] + [[Trie](../../tag/trie/README.md)] diff --git a/problems/matrix-block-sum/README.md b/problems/matrix-block-sum/README.md index 91ae8977a..9fe7fe48f 100644 --- a/problems/matrix-block-sum/README.md +++ b/problems/matrix-block-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../decompress-run-length-encoded-list "Decompress Run-Length Encoded List") @@ -49,6 +49,9 @@ [[Matrix](../../tag/matrix/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] +### Similar Questions + 1. [Stamping the Grid](../stamping-the-grid) (Hard) + ### Hints
    Hint 1 diff --git a/problems/matrix-cells-in-distance-order/README.md b/problems/matrix-cells-in-distance-order/README.md index 3e26821f3..9fa55ff71 100644 --- a/problems/matrix-cells-in-distance-order/README.md +++ b/problems/matrix-cells-in-distance-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-city-scheduling "Two City Scheduling") @@ -54,8 +54,8 @@ There are other answers that would also be accepted as correct, such as [[1,2],[ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Matrix](../../tag/matrix/README.md)] + [[Geometry](../../tag/geometry/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/matrix-diagonal-sum/README.md b/problems/matrix-diagonal-sum/README.md index f45ad0315..ea3934e05 100644 --- a/problems/matrix-diagonal-sum/README.md +++ b/problems/matrix-diagonal-sum/README.md @@ -57,6 +57,9 @@ Notice that element mat[1][1] = 5 is counted only once. [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Check if Every Row and Column Contains All Numbers](../check-if-every-row-and-column-contains-all-numbers) (Easy) + ### Hints
    Hint 1 diff --git a/problems/max-consecutive-ones-iii/README.md b/problems/max-consecutive-ones-iii/README.md index 543968e6c..2d8260401 100644 --- a/problems/max-consecutive-ones-iii/README.md +++ b/problems/max-consecutive-ones-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-word-is-valid-after-substitutions "Check If Word Is Valid After Substitutions") @@ -43,15 +43,14 @@ Bolded numbers were flipped from 0 to 1. The longest subarray is underlined. ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Medium) 1. [Longest Repeating Character Replacement](../longest-repeating-character-replacement) (Medium) 1. [Max Consecutive Ones](../max-consecutive-ones) (Easy) 1. [Max Consecutive Ones II](../max-consecutive-ones-ii) (Medium) - 1. [Maximize the Confusion of an Exam](../maximize-the-confusion-of-an-exam) (Medium) ### Hints
    diff --git a/problems/max-dot-product-of-two-subsequences/README.md b/problems/max-dot-product-of-two-subsequences/README.md index 7e4087e25..87cfbc3c3 100644 --- a/problems/max-dot-product-of-two-subsequences/README.md +++ b/problems/max-dot-product-of-two-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../pseudo-palindromic-paths-in-a-binary-tree "Pseudo-Palindromic Paths in a Binary Tree") diff --git a/problems/max-value-of-equation/README.md b/problems/max-value-of-equation/README.md index 485de6f96..4acc64f7b 100644 --- a/problems/max-value-of-equation/README.md +++ b/problems/max-value-of-equation/README.md @@ -48,11 +48,14 @@ No other pairs satisfy the condition, so we return the max of 4 and 1. ### Related Topics - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] + [[Queue](../../tag/queue/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Monotonic Queue](../../tag/monotonic-queue/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] + +### Similar Questions + 1. [Count Pairs in Two Arrays](../count-pairs-in-two-arrays) (Medium) ### Hints
    diff --git a/problems/maximal-rectangle/README.md b/problems/maximal-rectangle/README.md index 0a5485bb9..78ebdca14 100644 --- a/problems/maximal-rectangle/README.md +++ b/problems/maximal-rectangle/README.md @@ -24,46 +24,32 @@

    Example 2:

    -
    -Input: matrix = []
    -Output: 0
    -
    - -

    Example 3:

    -
     Input: matrix = [["0"]]
     Output: 0
     
    -

    Example 4:

    +

    Example 3:

     Input: matrix = [["1"]]
     Output: 1
     
    -

    Example 5:

    - -
    -Input: matrix = [["0","0"]]
    -Output: 0
    -
    -

     

    Constraints:

    • rows == matrix.length
    • cols == matrix[i].length
    • -
    • 0 <= row, cols <= 200
    • +
    • 1 <= row, cols <= 200
    • matrix[i][j] is '0' or '1'.
    ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Stack](../../tag/stack/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] diff --git a/problems/maximize-number-of-nice-divisors/README.md b/problems/maximize-number-of-nice-divisors/README.md index b325bd1cf..69b41c77f 100644 --- a/problems/maximize-number-of-nice-divisors/README.md +++ b/problems/maximize-number-of-nice-divisors/README.md @@ -48,8 +48,11 @@ There is not other value of n that has at most 5 prime factors and more nice div ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Math](../../tag/math/README.md)] + [[Recursion](../../tag/recursion/README.md)] + +### Similar Questions + 1. [Integer Break](../integer-break) (Medium) ### Hints
    diff --git a/problems/maximum-alternating-subarray-sum/README.md b/problems/maximum-alternating-subarray-sum/README.md index 0ae635e82..d761dc4d7 100644 --- a/problems/maximum-alternating-subarray-sum/README.md +++ b/problems/maximum-alternating-subarray-sum/README.md @@ -9,7 +9,7 @@                  [Next >](../minimum-number-of-moves-to-seat-everyone "Minimum Number of Moves to Seat Everyone") -## [2036. Maximum Alternating Subarray Sum (Medium)](https://leetcode.com/problems/maximum-alternating-subarray-sum "") +## [2036. Maximum Alternating Subarray Sum (Medium)](https://leetcode.com/problems/maximum-alternating-subarray-sum "最大交替子数组和") diff --git a/problems/maximum-alternating-subsequence-sum/README.md b/problems/maximum-alternating-subsequence-sum/README.md index 2265c28fd..340f9b788 100644 --- a/problems/maximum-alternating-subsequence-sum/README.md +++ b/problems/maximum-alternating-subsequence-sum/README.md @@ -61,6 +61,9 @@ [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Maximum Alternating Subarray Sum](../maximum-alternating-subarray-sum) (Medium) + ### Hints
    Hint 1 diff --git a/problems/maximum-and-sum-of-array/README.md b/problems/maximum-and-sum-of-array/README.md new file mode 100644 index 000000000..c3a632e65 --- /dev/null +++ b/problems/maximum-and-sum-of-array/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../removing-minimum-number-of-magic-beans "Removing Minimum Number of Magic Beans") +                 +[Next >](../longest-winning-streak "Longest Winning Streak") + +## [2172. Maximum AND Sum of Array (Hard)](https://leetcode.com/problems/maximum-and-sum-of-array "数组的最大与和") + +

    You are given an integer array nums of length n and an integer numSlots such that 2 * numSlots >= n. There are numSlots slots numbered from 1 to numSlots.

    + +

    You have to place all n integers into the slots such that each slot contains at most two numbers. The AND sum of a given placement is the sum of the bitwise AND of every number with its respective slot number.

    + +
      +
    • For example, the AND sum of placing the numbers [1, 3] into slot 1 and [4, 6] into slot 2 is equal to (1 AND 1) + (3 AND 1) + (4 AND 2) + (6 AND 2) = 1 + 1 + 0 + 2 = 4.
    • +
    + +

    Return the maximum possible AND sum of nums given numSlots slots.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3,4,5,6], numSlots = 3
    +Output: 9
    +Explanation: One possible placement is [1, 4] into slot 1, [2, 6] into slot 2, and [3, 5] into slot 3. 
    +This gives the maximum AND sum of (1 AND 1) + (4 AND 1) + (2 AND 2) + (6 AND 2) + (3 AND 3) + (5 AND 3) = 1 + 0 + 2 + 2 + 3 + 1 = 9.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,3,10,4,7,1], numSlots = 9
    +Output: 24
    +Explanation: One possible placement is [1, 1] into slot 1, [3] into slot 3, [4] into slot 4, [7] into slot 7, and [10] into slot 9.
    +This gives the maximum AND sum of (1 AND 1) + (1 AND 1) + (3 AND 3) + (4 AND 4) + (7 AND 7) + (10 AND 9) = 1 + 1 + 3 + 4 + 7 + 8 = 24.
    +Note that slots 2, 5, 6, and 8 are empty which is permitted.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= numSlots <= 9
    • +
    • 1 <= n <= 2 * numSlots
    • +
    • 1 <= nums[i] <= 15
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] + +### Hints +
    +Hint 1 +Can you think of a dynamic programming solution to this problem? +
    + +
    +Hint 2 +Can you use a bitmask to represent the state of the slots? +
    diff --git a/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md b/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md index c1efb356e..43b1a9eeb 100644 --- a/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md +++ b/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-product-of-two-elements-in-an-array "Maximum Product of Two Elements in an Array") @@ -58,8 +58,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/maximum-ascending-subarray-sum/README.md b/problems/maximum-ascending-subarray-sum/README.md index 33dd72404..349c6752a 100644 --- a/problems/maximum-ascending-subarray-sum/README.md +++ b/problems/maximum-ascending-subarray-sum/README.md @@ -42,13 +42,6 @@ Explanation: [10,11,12] is the ascending subarray with the maximum sum of 33. -

    Example 4:

    - -
    -Input: nums = [100,10,1]
    -Output: 100
    -
    -

     

    Constraints:

    @@ -60,6 +53,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] +### Similar Questions + 1. [Find Good Days to Rob the Bank](../find-good-days-to-rob-the-bank) (Medium) + ### Hints
    Hint 1 diff --git a/problems/maximum-binary-string-after-change/README.md b/problems/maximum-binary-string-after-change/README.md index 07af7eb1a..8f105f46c 100644 --- a/problems/maximum-binary-string-after-change/README.md +++ b/problems/maximum-binary-string-after-change/README.md @@ -59,8 +59,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/maximum-candies-you-can-get-from-boxes/README.md b/problems/maximum-candies-you-can-get-from-boxes/README.md index 7977327ee..d714a6c5d 100644 --- a/problems/maximum-candies-you-can-get-from-boxes/README.md +++ b/problems/maximum-candies-you-can-get-from-boxes/README.md @@ -11,18 +11,18 @@ ## [1298. Maximum Candies You Can Get from Boxes (Hard)](https://leetcode.com/problems/maximum-candies-you-can-get-from-boxes "你能从盒子里获得的最大糖果数") -

    Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:

    +

    You have n boxes labeled from 0 to n - 1. You are given four arrays: status, candies, keys, and containedBoxes where:

      -
    • status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
    • -
    • candies[i]: an integer representing the number of candies in box[i].
    • -
    • keys[i]: an array contains the indices of the boxes you can open with the key in box[i].
    • -
    • containedBoxes[i]: an array contains the indices of the boxes found in box[i].
    • +
    • status[i] is 1 if the ith box is open and 0 if the ith box is closed,
    • +
    • candies[i] is the number of candies in the ith box,
    • +
    • keys[i] is a list of the labels of the boxes you can open after opening the ith box.
    • +
    • containedBoxes[i] is a list of the boxes you found inside the ith box.
    -

    You will start with some boxes given in initialBoxes array. You can take all the candies in any open box and you can use the keys in it to open new boxes and you also can use the boxes you find in it.

    +

    You are given an integer array initialBoxes that contains the labels of the boxes you initially have. You can take all the candies in any open box and you can use the keys in it to open new boxes and you also can use the boxes you find in it.

    -

    Return the maximum number of candies you can get following the rules above.

    +

    Return the maximum number of candies you can get following the rules above.

     

    Example 1:

    @@ -30,7 +30,8 @@
     Input: status = [1,0,1,0], candies = [7,5,4,100], keys = [[],[],[1],[]], containedBoxes = [[1,2],[3],[],[]], initialBoxes = [0]
     Output: 16
    -Explanation: You will be initially given box 0. You will find 7 candies in it and boxes 1 and 2. Box 1 is closed and you don't have a key for it so you will open box 2. You will find 4 candies and a key to box 1 in box 2.
    +Explanation: You will be initially given box 0. You will find 7 candies in it and boxes 1 and 2.
    +Box 1 is closed and you do not have a key for it so you will open box 2. You will find 4 candies and a key to box 1 in box 2.
     In box 1, you will find 5 candies and box 3 but you will not find a key to box 3 so box 3 will remain closed.
     Total number of candies collected = 7 + 4 + 5 = 16 candy.
     
    @@ -40,52 +41,32 @@ Total number of candies collected = 7 + 4 + 5 = 16 candy.
     Input: status = [1,0,0,0,0,0], candies = [1,1,1,1,1,1], keys = [[1,2,3,4,5],[],[],[],[],[]], containedBoxes = [[1,2,3,4,5],[],[],[],[],[]], initialBoxes = [0]
     Output: 6
    -Explanation: You have initially box 0. Opening it you can find boxes 1,2,3,4 and 5 and their keys. The total number of candies will be 6.
    -
    - -

    Example 3:

    - -
    -Input: status = [1,1,1], candies = [100,1,100], keys = [[],[0,2],[]], containedBoxes = [[],[],[]], initialBoxes = [1]
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: status = [1], candies = [100], keys = [[]], containedBoxes = [[]], initialBoxes = []
    -Output: 0
    -
    - -

    Example 5:

    - -
    -Input: status = [1,1,1], candies = [2,3,2], keys = [[],[],[]], containedBoxes = [[],[],[]], initialBoxes = [2,1,0]
    -Output: 7
    +Explanation: You have initially box 0. Opening it you can find boxes 1,2,3,4 and 5 and their keys.
    +The total number of candies will be 6.
     

     

    Constraints:

      -
    • 1 <= status.length <= 1000
    • -
    • status.length == candies.length == keys.length == containedBoxes.length == n
    • -
    • status[i] is 0 or 1.
    • +
    • n == status.length == candies.length == keys.length == containedBoxes.length
    • +
    • 1 <= n <= 1000
    • +
    • status[i] is either 0 or 1.
    • 1 <= candies[i] <= 1000
    • -
    • 0 <= keys[i].length <= status.length
    • -
    • 0 <= keys[i][j] < status.length
    • -
    • All values in keys[i] are unique.
    • -
    • 0 <= containedBoxes[i].length <= status.length
    • -
    • 0 <= containedBoxes[i][j] < status.length
    • -
    • All values in containedBoxes[i] are unique.
    • +
    • 0 <= keys[i].length <= n
    • +
    • 0 <= keys[i][j] < n
    • +
    • All values of keys[i] are unique.
    • +
    • 0 <= containedBoxes[i].length <= n
    • +
    • 0 <= containedBoxes[i][j] < n
    • +
    • All values of containedBoxes[i] are unique.
    • Each box is contained in one box at most.
    • -
    • 0 <= initialBoxes.length <= status.length
    • -
    • 0 <= initialBoxes[i] < status.length
    • +
    • 0 <= initialBoxes.length <= n
    • +
    • 0 <= initialBoxes[i] < n
    ### Related Topics - [[Array](../../tag/array/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/maximum-difference-between-node-and-ancestor/README.md b/problems/maximum-difference-between-node-and-ancestor/README.md index 0b9b3cbd1..d8ad9af3b 100644 --- a/problems/maximum-difference-between-node-and-ancestor/README.md +++ b/problems/maximum-difference-between-node-and-ancestor/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../divisor-game "Divisor Game") diff --git a/problems/maximum-distance-between-a-pair-of-values/README.md b/problems/maximum-distance-between-a-pair-of-values/README.md index 6303a4c38..e88895f23 100644 --- a/problems/maximum-distance-between-a-pair-of-values/README.md +++ b/problems/maximum-distance-between-a-pair-of-values/README.md @@ -47,14 +47,6 @@ The maximum distance is 1 with pair (0,1). The maximum distance is 2 with pair (2,4). -

    Example 4:

    - -
    -Input: nums1 = [5,4], nums2 = [3,2]
    -Output: 0
    -Explanation: There are no valid pairs, so return 0.
    -
    -

     

    Constraints:

    diff --git a/problems/maximum-distance-in-arrays/README.md b/problems/maximum-distance-in-arrays/README.md index b9bcdb2a2..4190a9404 100644 --- a/problems/maximum-distance-in-arrays/README.md +++ b/problems/maximum-distance-in-arrays/README.md @@ -35,5 +35,5 @@ One way to reach the maximum distance 4 is to pick 1 in the first or third array

    ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/maximum-element-after-decreasing-and-rearranging/README.md b/problems/maximum-element-after-decreasing-and-rearranging/README.md index 2ec14e72a..b3c3ef248 100644 --- a/problems/maximum-element-after-decreasing-and-rearranging/README.md +++ b/problems/maximum-element-after-decreasing-and-rearranging/README.md @@ -69,8 +69,8 @@ The largest element in arr is 3. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/maximum-employees-to-be-invited-to-a-meeting/README.md b/problems/maximum-employees-to-be-invited-to-a-meeting/README.md new file mode 100644 index 000000000..b593c81e1 --- /dev/null +++ b/problems/maximum-employees-to-be-invited-to-a-meeting/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../destroying-asteroids "Destroying Asteroids") +                 +[Next >](../remove-all-ones-with-row-and-column-flips "Remove All Ones With Row and Column Flips") + +## [2127. Maximum Employees to Be Invited to a Meeting (Hard)](https://leetcode.com/problems/maximum-employees-to-be-invited-to-a-meeting "参加会议的最多员工数") + +

    A company is organizing a meeting and has a list of n employees, waiting to be invited. They have arranged for a large circular table, capable of seating any number of employees.

    + +

    The employees are numbered from 0 to n - 1. Each employee has a favorite person and they will attend the meeting only if they can sit next to their favorite person at the table. The favorite person of an employee is not themself.

    + +

    Given a 0-indexed integer array favorite, where favorite[i] denotes the favorite person of the ith employee, return the maximum number of employees that can be invited to the meeting.

    + +

     

    +

    Example 1:

    + +
    +Input: favorite = [2,2,1,2]
    +Output: 3
    +Explanation:
    +The above figure shows how the company can invite employees 0, 1, and 2, and seat them at the round table.
    +All employees cannot be invited because employee 2 cannot sit beside employees 0, 1, and 3, simultaneously.
    +Note that the company can also invite employees 1, 2, and 3, and give them their desired seats.
    +The maximum number of employees that can be invited to the meeting is 3. 
    +
    + +

    Example 2:

    + +
    +Input: favorite = [1,2,0]
    +Output: 3
    +Explanation: 
    +Each employee is the favorite person of at least one other employee, and the only way the company can invite them is if they invite every employee.
    +The seating arrangement will be the same as that in the figure given in example 1:
    +- Employee 0 will sit between employees 2 and 1.
    +- Employee 1 will sit between employees 0 and 2.
    +- Employee 2 will sit between employees 1 and 0.
    +The maximum number of employees that can be invited to the meeting is 3.
    +
    + +

    Example 3:

    + +
    +Input: favorite = [3,0,1,4,1]
    +Output: 4
    +Explanation:
    +The above figure shows how the company will invite employees 0, 1, 3, and 4, and seat them at the round table.
    +Employee 2 cannot be invited because the two spots next to their favorite employee 1 are taken.
    +So the company leaves them out of the meeting.
    +The maximum number of employees that can be invited to the meeting is 4.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == favorite.length
    • +
    • 2 <= n <= 105
    • +
    • 0 <= favorite[i] <= n - 1
    • +
    • favorite[i] != i
    • +
    + +### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] + +### Hints +
    +Hint 1 +From the given array favorite, create a graph where for every index i, there is a directed edge from favorite[i] to i. The graph will be a combination of cycles and chains of acyclic edges. Now, what are the ways in which we can choose employees to sit at the table? +
    + +
    +Hint 2 +The first way by which we can choose employees is by selecting a cycle of the graph. It can be proven that in this case, the employees that do not lie in the cycle can never be seated at the table. +
    + +
    +Hint 3 +The second way is by combining acyclic chains. At most two chains can be combined by a cycle of length 2, where each chain ends on one of the employees in the cycle. +
    diff --git a/problems/maximum-fruits-harvested-after-at-most-k-steps/README.md b/problems/maximum-fruits-harvested-after-at-most-k-steps/README.md new file mode 100644 index 000000000..997d2537c --- /dev/null +++ b/problems/maximum-fruits-harvested-after-at-most-k-steps/README.md @@ -0,0 +1,99 @@ + + + + + + + +[< Previous](../watering-plants-ii "Watering Plants II") +                 +[Next >](../number-of-unique-flavors-after-sharing-k-candies "Number of Unique Flavors After Sharing K Candies") + +## [2106. Maximum Fruits Harvested After at Most K Steps (Hard)](https://leetcode.com/problems/maximum-fruits-harvested-after-at-most-k-steps "摘水果") + +

    Fruits are available at some positions on an infinite x-axis. You are given a 2D integer array fruits where fruits[i] = [positioni, amounti] depicts amounti fruits at the position positioni. fruits is already sorted by positioni in ascending order, and each positioni is unique.

    + +

    You are also given an integer startPos and an integer k. Initially, you are at the position startPos. From any position, you can either walk to the left or right. It takes one step to move one unit on the x-axis, and you can walk at most k steps in total. For every position you reach, you harvest all the fruits at that position, and the fruits will disappear from that position.

    + +

    Return the maximum total number of fruits you can harvest.

    + +

     

    +

    Example 1:

    + +
    +Input: fruits = [[2,8],[6,3],[8,6]], startPos = 5, k = 4
    +Output: 9
    +Explanation: 
    +The optimal way is to:
    +- Move right to position 6 and harvest 3 fruits
    +- Move right to position 8 and harvest 6 fruits
    +You moved 3 steps and harvested 3 + 6 = 9 fruits in total.
    +
    + +

    Example 2:

    + +
    +Input: fruits = [[0,9],[4,1],[5,7],[6,2],[7,4],[10,9]], startPos = 5, k = 4
    +Output: 14
    +Explanation: 
    +You can move at most k = 4 steps, so you cannot reach position 0 nor 10.
    +The optimal way is to:
    +- Harvest the 7 fruits at the starting position 5
    +- Move left to position 4 and harvest 1 fruit
    +- Move right to position 6 and harvest 2 fruits
    +- Move right to position 7 and harvest 4 fruits
    +You moved 1 + 3 = 4 steps and harvested 7 + 1 + 2 + 4 = 14 fruits in total.
    +
    + +

    Example 3:

    + +
    +Input: fruits = [[0,3],[6,4],[8,5]], startPos = 3, k = 2
    +Output: 0
    +Explanation:
    +You can move at most k = 2 steps and cannot reach any position with fruits.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= fruits.length <= 105
    • +
    • fruits[i].length == 2
    • +
    • 0 <= startPos, positioni <= 2 * 105
    • +
    • positioni-1 < positioni for any i > 0 (0-indexed)
    • +
    • 1 <= amounti <= 104
    • +
    • 0 <= k <= 2 * 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
    +Hint 1 +Does an optimal path have very few patterns? For example, could a path that goes left, turns and goes right, then turns again and goes left be any better than a path that simply goes left, turns, and goes right? +
    + +
    +Hint 2 +The optimal path turns at most once. That is, the optimal path is one of these: to go left only; to go right only; to go left, turn and go right; or to go right, turn and go left. +
    + +
    +Hint 3 +Moving x steps left then k-x steps right gives you a range of positions that you can reach. +
    + +
    +Hint 4 +Use prefix sums to get the sum of all fruits for each possible range. +
    + +
    +Hint 5 +Use a similar strategy for all the paths that go right, then turn and go left. +
    diff --git a/problems/maximum-genetic-difference-query/README.md b/problems/maximum-genetic-difference-query/README.md index dbd84060c..1b13b9038 100644 --- a/problems/maximum-genetic-difference-query/README.md +++ b/problems/maximum-genetic-difference-query/README.md @@ -52,6 +52,14 @@
  • 0 <= vali <= 2 * 105
  • +### Related Topics + [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Trie](../../tag/trie/README.md)] + +### Similar Questions + 1. [Maximum XOR With an Element From Array](../maximum-xor-with-an-element-from-array) (Hard) + ### Hints
    Hint 1 diff --git a/problems/maximum-good-people-based-on-statements/README.md b/problems/maximum-good-people-based-on-statements/README.md new file mode 100644 index 000000000..9b0cf9661 --- /dev/null +++ b/problems/maximum-good-people-based-on-statements/README.md @@ -0,0 +1,114 @@ + + + + + + + +[< Previous](../find-all-lonely-numbers-in-the-array "Find All Lonely Numbers in the Array") +                 +[Next >](../minimum-number-of-lines-to-cover-points "Minimum Number of Lines to Cover Points") + +## [2151. Maximum Good People Based on Statements (Hard)](https://leetcode.com/problems/maximum-good-people-based-on-statements "基于陈述统计最多好人数") + +

    There are two types of persons:

    + +
      +
    • The good person: The person who always tells the truth.
    • +
    • The bad person: The person who might tell the truth and might lie.
    • +
    + +

    You are given a 0-indexed 2D integer array statements of size n x n that represents the statements made by n people about each other. More specifically, statements[i][j] could be one of the following:

    + +
      +
    • 0 which represents a statement made by person i that person j is a bad person.
    • +
    • 1 which represents a statement made by person i that person j is a good person.
    • +
    • 2 represents that no statement is made by person i about person j.
    • +
    + +

    Additionally, no person ever makes a statement about themselves. Formally, we have that statements[i][i] = 2 for all 0 <= i < n.

    + +

    Return the maximum number of people who can be good based on the statements made by the n people.

    + +

     

    +

    Example 1:

    + +
    +Input: statements = [[2,1,2],[1,2,2],[2,0,2]]
    +Output: 2
    +Explanation: Each person makes a single statement.
    +- Person 0 states that person 1 is good.
    +- Person 1 states that person 0 is good.
    +- Person 2 states that person 1 is bad.
    +Let's take person 2 as the key.
    +- Assuming that person 2 is a good person:
    +    - Based on the statement made by person 2, person 1 is a bad person.
    +    - Now we know for sure that person 1 is bad and person 2 is good.
    +    - Based on the statement made by person 1, and since person 1 is bad, they could be:
    +        - telling the truth. There will be a contradiction in this case and this assumption is invalid.
    +        - lying. In this case, person 0 is also a bad person and lied in their statement.
    +    - Following that person 2 is a good person, there will be only one good person in the group.
    +- Assuming that person 2 is a bad person:
    +    - Based on the statement made by person 2, and since person 2 is bad, they could be:
    +        - telling the truth. Following this scenario, person 0 and 1 are both bad as explained before.
    +            - Following that person 2 is bad but told the truth, there will be no good persons in the group.
    +        - lying. In this case person 1 is a good person.
    +            - Since person 1 is a good person, person 0 is also a good person.
    +            - Following that person 2 is bad and lied, there will be two good persons in the group.
    +We can see that at most 2 persons are good in the best case, so we return 2.
    +Note that there is more than one way to arrive at this conclusion.
    +
    + +

    Example 2:

    + +
    +Input: statements = [[2,0],[0,2]]
    +Output: 1
    +Explanation: Each person makes a single statement.
    +- Person 0 states that person 1 is bad.
    +- Person 1 states that person 0 is bad.
    +Let's take person 0 as the key.
    +- Assuming that person 0 is a good person:
    +    - Based on the statement made by person 0, person 1 is a bad person and was lying.
    +    - Following that person 0 is a good person, there will be only one good person in the group.
    +- Assuming that person 0 is a bad person:
    +    - Based on the statement made by person 0, and since person 0 is bad, they could be:
    +        - telling the truth. Following this scenario, person 0 and 1 are both bad.
    +            - Following that person 0 is bad but told the truth, there will be no good persons in the group.
    +        - lying. In this case person 1 is a good person.
    +            - Following that person 0 is bad and lied, there will be only one good person in the group.
    +We can see that at most, one person is good in the best case, so we return 1.
    +Note that there is more than one way to arrive at this conclusion.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == statements.length == statements[i].length
    • +
    • 2 <= n <= 15
    • +
    • statements[i][j] is either 0, 1, or 2.
    • +
    • statements[i][i] == 2
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + +### Hints +
    +Hint 1 +You should test every possible assignment of good and bad people, using a bitmask. +
    + +
    +Hint 2 +In each bitmask, if the person i is good, then his statements should be consistent with the bitmask in order for the assignment to be valid. +
    + +
    +Hint 3 +If the assignment is valid, count how many people are good and keep track of the maximum. +
    diff --git a/problems/maximum-ice-cream-bars/README.md b/problems/maximum-ice-cream-bars/README.md index 5fbc91a10..5b90aaafb 100644 --- a/problems/maximum-ice-cream-bars/README.md +++ b/problems/maximum-ice-cream-bars/README.md @@ -55,8 +55,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md b/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md index 7dd80565b..cc15cde53 100644 --- a/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md +++ b/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md @@ -49,14 +49,6 @@ Maximum length is 4. Explanation: The only string in arr has all 26 characters. -

    Example 4:

    - -
    -Input: arr = ["aa","bb"]
    -Output: 0
    -Explanation: Both strings in arr do not have unique characters, thus there are no valid concatenations.
    -
    -

     

    Constraints:

    diff --git a/problems/maximum-length-of-subarray-with-positive-product/README.md b/problems/maximum-length-of-subarray-with-positive-product/README.md index 09559fc46..d1b1c444c 100644 --- a/problems/maximum-length-of-subarray-with-positive-product/README.md +++ b/problems/maximum-length-of-subarray-with-positive-product/README.md @@ -11,11 +11,11 @@ ## [1567. Maximum Length of Subarray With Positive Product (Medium)](https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product "乘积为正数的最长子数组长度") -

    Given an array of integers nums, find the maximum length of a subarray where the product of all its elements is positive.

    +

    Given an array of integers nums, find the maximum length of a subarray where the product of all its elements is positive.

    A subarray of an array is a consecutive sequence of zero or more values taken out of that array.

    -

    Return the maximum length of a subarray with positive product.

    +

    Return the maximum length of a subarray with positive product.

     

    Example 1:

    @@ -23,7 +23,7 @@
     Input: nums = [1,-2,-3,4]
     Output: 4
    -Explanation: The array nums already has a positive product of 24.
    +Explanation: The array nums already has a positive product of 24.
     

    Example 2:

    @@ -31,7 +31,7 @@
     Input: nums = [0,1,-2,-3,-4]
     Output: 3
    -Explanation: The longest subarray with positive product is [1,-2,-3] which has a product of 6.
    +Explanation: The longest subarray with positive product is [1,-2,-3] which has a product of 6.
     Notice that we cannot include 0 in the subarray since that'll make the product 0 which is not positive.

    Example 3:

    @@ -39,35 +39,21 @@ Notice that we cannot include 0 in the subarray since that'll make the produ
     Input: nums = [-1,-2,-3,0,1]
     Output: 2
    -Explanation: The longest subarray with positive product is [-1,-2] or [-2,-3].
    -
    - -

    Example 4:

    - -
    -Input: nums = [-1,2]
    -Output: 1
    -
    - -

    Example 5:

    - -
    -Input: nums = [1,2,3,5,-6,4,0,10]
    -Output: 4
    +Explanation: The longest subarray with positive product is [-1,-2] or [-2,-3].
     

     

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • -10^9 <= nums[i] <= 10^9
    • +
    • 1 <= nums.length <= 105
    • +
    • -109 <= nums[i] <= 109
    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/maximum-nesting-depth-of-the-parentheses/README.md b/problems/maximum-nesting-depth-of-the-parentheses/README.md index b4df75520..93c9ebc78 100644 --- a/problems/maximum-nesting-depth-of-the-parentheses/README.md +++ b/problems/maximum-nesting-depth-of-the-parentheses/README.md @@ -48,20 +48,6 @@ Output: 3 -

    Example 3:

    - -
    -Input: s = "1+(2*3)/(2-1)"
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: s = "1"
    -Output: 0
    -
    -

     

    Constraints:

    @@ -72,8 +58,11 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[String](../../tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] + +### Similar Questions + 1. [Maximum Nesting Depth of Two Valid Parentheses Strings](../maximum-nesting-depth-of-two-valid-parentheses-strings) (Medium) ### Hints
    diff --git a/problems/maximum-non-negative-product-in-a-matrix/README.md b/problems/maximum-non-negative-product-in-a-matrix/README.md index 0b1c73b57..061a705d5 100644 --- a/problems/maximum-non-negative-product-in-a-matrix/README.md +++ b/problems/maximum-non-negative-product-in-a-matrix/README.md @@ -11,59 +11,46 @@ ## [1594. Maximum Non Negative Product in a Matrix (Medium)](https://leetcode.com/problems/maximum-non-negative-product-in-a-matrix "矩阵的最大非负积") -

    You are given a rows x cols matrix grid. Initially, you are located at the top-left corner (0, 0), and in each step, you can only move right or down in the matrix.

    +

    You are given a m x n matrix grid. Initially, you are located at the top-left corner (0, 0), and in each step, you can only move right or down in the matrix.

    -

    Among all possible paths starting from the top-left corner (0, 0) and ending in the bottom-right corner (rows - 1, cols - 1), find the path with the maximum non-negative product. The product of a path is the product of all integers in the grid cells visited along the path.

    +

    Among all possible paths starting from the top-left corner (0, 0) and ending in the bottom-right corner (m - 1, n - 1), find the path with the maximum non-negative product. The product of a path is the product of all integers in the grid cells visited along the path.

    -

    Return the maximum non-negative product modulo 109 + 7If the maximum product is negative return -1.

    +

    Return the maximum non-negative product modulo 109 + 7. If the maximum product is negative, return -1.

    -

    Notice that the modulo is performed after getting the maximum product.

    +

    Notice that the modulo is performed after getting the maximum product.

     

    Example 1:

    - +
    -Input: grid = [[-1,-2,-3],
    -               [-2,-3,-3],
    -               [-3,-3,-2]]
    +Input: grid = [[-1,-2,-3],[-2,-3,-3],[-3,-3,-2]]
     Output: -1
    -Explanation: It's not possible to get non-negative product in the path from (0, 0) to (2, 2), so return -1.
    +Explanation: It is not possible to get non-negative product in the path from (0, 0) to (2, 2), so return -1.
     

    Example 2:

    - +
    -Input: grid = [[1,-2,1],
    -               [1,-2,1],
    -               [3,-4,1]]
    +Input: grid = [[1,-2,1],[1,-2,1],[3,-4,1]]
     Output: 8
    -Explanation: Maximum non-negative product is in bold (1 * 1 * -2 * -4 * 1 = 8).
    +Explanation: Maximum non-negative product is shown (1 * 1 * -2 * -4 * 1 = 8).
     

    Example 3:

    - +
    -Input: grid = [[1, 3],
    -               [0,-4]]
    +Input: grid = [[1,3],[0,-4]]
     Output: 0
    -Explanation: Maximum non-negative product is in bold (1 * 0 * -4 = 0).
    -
    - -

    Example 4:

    - -
    -Input: grid = [[ 1, 4,4,0],
    -               [-2, 0,0,1],
    -               [ 1,-1,1,1]]
    -Output: 2
    -Explanation: Maximum non-negative product is in bold (1 * -2 * 1 * -1 * 1 * 1 = 2).
    +Explanation: Maximum non-negative product is shown (1 * 0 * -4 = 0).
     

     

    Constraints:

      -
    • 1 <= rows, cols <= 15
    • +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 15
    • -4 <= grid[i][j] <= 4
    diff --git a/problems/maximum-number-of-achievable-transfer-requests/README.md b/problems/maximum-number-of-achievable-transfer-requests/README.md index 144c6a30e..8c9be33c7 100644 --- a/problems/maximum-number-of-achievable-transfer-requests/README.md +++ b/problems/maximum-number-of-achievable-transfer-requests/README.md @@ -64,6 +64,8 @@ We can achieve all the requests. ### Related Topics + [[Array](../../tag/array/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Enumeration](../../tag/enumeration/README.md)] diff --git a/problems/maximum-number-of-consecutive-values-you-can-make/README.md b/problems/maximum-number-of-consecutive-values-you-can-make/README.md index 7fdf0d08f..b0826514c 100644 --- a/problems/maximum-number-of-consecutive-values-you-can-make/README.md +++ b/problems/maximum-number-of-consecutive-values-you-can-make/README.md @@ -60,16 +60,24 @@ You can make 8 consecutive integer values starting from 0. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Similar Questions + 1. [Patching Array](../patching-array) (Hard) ### Hints
    Hint 1 -Let's note that if you can make the first x values then you can and you have a value v≤x+1 then you can make all values ≤v+x +If you can make the first x values and you have a value v, then you can make all the values ≤ v + x
    Hint 2 -The smaller v is the smaller the x you need so it's optimal to process elements in a sorted order +Sort the array of coins. You can always make the value 0 so you can start with x = 0. +
    + +
    +Hint 3 +Process the values starting from the smallest and stop when there is a value that cannot be achieved with the current x.
    diff --git a/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md b/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md index 03a0c1879..7767a3d0e 100644 --- a/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md +++ b/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md @@ -11,52 +11,36 @@ ## [1453. Maximum Number of Darts Inside of a Circular Dartboard (Hard)](https://leetcode.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard "圆形靶内的最大飞镖数量") -

    You have a very large square wall and a circular dartboard placed on the wall. You have been challenged to throw darts into the board blindfolded. Darts thrown at the wall are represented as an array of points on a 2D plane. 

    +

    Alice is throwing n darts on a very large wall. You are given an array darts where darts[i] = [xi, yi] is the position of the ith dart that Alice threw on the wall.

    -

    Return the maximum number of points that are within or lie on any circular dartboard of radius r.

    +

    Bob knows the positions of the n darts on the wall. He wants to place a dartboard of radius r on the wall so that the maximum number of darts that Alice throws lies on the dartboard.

    + +

    Given the integer r, return the maximum number of darts that can lie on the dartboard.

     

    Example 1:

    - -

    - +
    -Input: points = [[-2,0],[2,0],[0,2],[0,-2]], r = 2
    +Input: darts = [[-2,0],[2,0],[0,2],[0,-2]], r = 2
     Output: 4
     Explanation: Circle dartboard with center in (0,0) and radius = 2 contain all points.
     

    Example 2:

    - -

    - +
    -Input: points = [[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]], r = 5
    +Input: darts = [[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]], r = 5
     Output: 5
     Explanation: Circle dartboard with center in (0,4) and radius = 5 contain all points except the point (7,8).
     
    -

    Example 3:

    - -
    -Input: points = [[-2,0],[2,0],[0,2],[0,-2]], r = 1
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: points = [[1,2],[3,5],[1,-1],[2,3],[4,1],[1,3]], r = 2
    -Output: 4
    -
    -

     

    Constraints:

      -
    • 1 <= points.length <= 100
    • -
    • points[i].length == 2
    • -
    • -10^4 <= points[i][0], points[i][1] <= 10^4
    • +
    • 1 <= darts.length <= 100
    • +
    • darts[i].length == 2
    • +
    • -104 <= xi, yi <= 104
    • 1 <= r <= 5000
    diff --git a/problems/maximum-number-of-eaten-apples/README.md b/problems/maximum-number-of-eaten-apples/README.md index 2e29bdaa3..4d83aebe7 100644 --- a/problems/maximum-number-of-eaten-apples/README.md +++ b/problems/maximum-number-of-eaten-apples/README.md @@ -45,16 +45,15 @@

    Constraints:

      -
    • apples.length == n
    • -
    • days.length == n
    • +
    • n == apples.length == days.length
    • 1 <= n <= 2 * 104
    • 0 <= apples[i], days[i] <= 2 * 104
    • days[i] = 0 if and only if apples[i] = 0.
    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/maximum-number-of-events-that-can-be-attended/README.md b/problems/maximum-number-of-events-that-can-be-attended/README.md index 4559f8e33..1db35bebc 100644 --- a/problems/maximum-number-of-events-that-can-be-attended/README.md +++ b/problems/maximum-number-of-events-that-can-be-attended/README.md @@ -11,15 +11,15 @@ ## [1353. Maximum Number of Events That Can Be Attended (Medium)](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended "最多可以参加的会议数目") -

    Given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi.

    +

    You are given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi.

    -

    You can attend an event i at any day d where startTimei <= d <= endTimei. Notice that you can only attend one event at any time d.

    +

    You can attend an event i at any day d where startTimei <= d <= endTimei. You can only attend one event at any time d.

    -

    Return the maximum number of events you can attend.

    +

    Return the maximum number of events you can attend.

     

    Example 1:

    - +
     Input: events = [[1,2],[2,3],[3,4]]
     Output: 3
    @@ -37,27 +37,6 @@ Attend the third event on day 3.
     Output: 4
     
    -

    Example 3:

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

    Example 4:

    - -
    -Input: events = [[1,100000]]
    -Output: 1
    -
    - -

    Example 5:

    - -
    -Input: events = [[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7]]
    -Output: 7
    -
    -

     

    Constraints:

    @@ -68,14 +47,10 @@ Attend the third event on day 3. ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] -### Similar Questions - 1. [Maximum Number of Events That Can Be Attended II](../maximum-number-of-events-that-can-be-attended-ii) (Hard) - 1. [Maximum Earnings From Taxi](../maximum-earnings-from-taxi) (Medium) - ### Hints
    Hint 1 diff --git a/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md b/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md index 6f963ba4b..e7e645d7d 100644 --- a/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md +++ b/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md @@ -11,9 +11,7 @@ ## [1546. Maximum Number of Non-Overlapping Subarrays With Sum Equals Target (Medium)](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值且不重叠的非空子数组的最大数目") -

    Given an array nums and an integer target.

    - -

    Return the maximum number of non-empty non-overlapping subarrays such that the sum of values in each subarray is equal to target.

    +

    Given an array nums and an integer target, return the maximum number of non-empty non-overlapping subarrays such that the sum of values in each subarray is equal to target.

     

    Example 1:

    @@ -21,7 +19,7 @@
     Input: nums = [1,1,1,1,1], target = 2
     Output: 2
    -Explanation: There are 2 non-overlapping subarrays [1,1,1,1,1] with sum equals to target(2).
    +Explanation: There are 2 non-overlapping subarrays [1,1,1,1,1] with sum equals to target(2).
     

    Example 2:

    @@ -29,36 +27,23 @@
     Input: nums = [-1,3,5,1,4,2,-9], target = 6
     Output: 2
    -Explanation: There are 3 subarrays with sum equal to 6.
    -([5,1], [4,2], [3,5,1,4,2,-9]) but only the first 2 are non-overlapping.
    - -

    Example 3:

    - -
    -Input: nums = [-2,6,6,3,5,4,1,2,8], target = 10
    -Output: 3
    -
    - -

    Example 4:

    - -
    -Input: nums = [0,0,0], target = 0
    -Output: 3
    +Explanation: There are 3 subarrays with sum equal to 6.
    +([5,1], [4,2], [3,5,1,4,2,-9]) but only the first 2 are non-overlapping.
     

     

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • -10^4 <= nums[i] <= 10^4
    • -
    • 0 <= target <= 10^6
    • +
    • 1 <= nums.length <= 105
    • +
    • -104 <= nums[i] <= 104
    • +
    • 0 <= target <= 106
    ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Greedy](../../tag/greedy/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints diff --git a/problems/maximum-number-of-non-overlapping-substrings/README.md b/problems/maximum-number-of-non-overlapping-substrings/README.md index 4c57eba84..2fb424741 100644 --- a/problems/maximum-number-of-non-overlapping-substrings/README.md +++ b/problems/maximum-number-of-non-overlapping-substrings/README.md @@ -57,8 +57,8 @@ If we choose the first string, we cannot choose anything else and we'd get o ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-occurrences-of-a-substring/README.md b/problems/maximum-number-of-occurrences-of-a-substring/README.md index 3634859c2..c8a0ba0fb 100644 --- a/problems/maximum-number-of-occurrences-of-a-substring/README.md +++ b/problems/maximum-number-of-occurrences-of-a-substring/README.md @@ -11,11 +11,11 @@ ## [1297. Maximum Number of Occurrences of a Substring (Medium)](https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring "子串的最大出现次数") -

    Given a string s, return the maximum number of ocurrences of any substring under the following rules:

    +

    Given a string s, return the maximum number of ocurrences of any substring under the following rules:

    • The number of unique characters in the substring must be less than or equal to maxLetters.
    • -
    • The substring size must be between minSize and maxSize inclusive.
    • +
    • The substring size must be between minSize and maxSize inclusive.

     

    @@ -36,28 +36,14 @@ It satisfies the conditions, 2 unique letters and size 3 (between minSize and ma Explanation: Substring "aaa" occur 2 times in the string. It can overlap. -

    Example 3:

    - -
    -Input: s = "aabcabcab", maxLetters = 2, minSize = 2, maxSize = 3
    -Output: 3
    -
    - -

    Example 4:

    - -
    -Input: s = "abcde", maxLetters = 2, minSize = 3, maxSize = 3
    -Output: 0
    -
    -

     

    Constraints:

      -
    • 1 <= s.length <= 10^5
    • +
    • 1 <= s.length <= 105
    • 1 <= maxLetters <= 26
    • 1 <= minSize <= maxSize <= min(26, s.length)
    • -
    • s only contains lowercase English letters.
    • +
    • s consists of only lowercase English letters.
    ### Related Topics diff --git a/problems/maximum-number-of-tasks-you-can-assign/README.md b/problems/maximum-number-of-tasks-you-can-assign/README.md index a917e8956..03bd179c2 100644 --- a/problems/maximum-number-of-tasks-you-can-assign/README.md +++ b/problems/maximum-number-of-tasks-you-can-assign/README.md @@ -52,19 +52,7 @@ We can assign the magical pills and tasks as follows: - Give the magical pill to worker 0 and worker 1. - Assign worker 0 to task 0 (0 + 10 >= 10) - Assign worker 1 to task 1 (10 + 10 >= 15) - - -

    Example 4:

    - -
    -Input: tasks = [5,9,8,5,9], workers = [1,6,4,2,6], pills = 1, strength = 5
    -Output: 3
    -Explanation:
    -We can assign the magical pill and tasks as follows:
    -- Give the magical pill to worker 2.
    -- Assign worker 1 to task 0 (6 >= 5)
    -- Assign worker 2 to task 2 (4 + 5 >= 8)
    -- Assign worker 4 to task 3 (6 >= 5)
    +The last pill is not given because it will not make any worker strong enough for the last task.
     

     

    diff --git a/problems/maximum-number-of-visible-points/README.md b/problems/maximum-number-of-visible-points/README.md index 1dcf62a62..f9401d886 100644 --- a/problems/maximum-number-of-visible-points/README.md +++ b/problems/maximum-number-of-visible-points/README.md @@ -62,11 +62,11 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Sorting](../../tag/sorting/README.md)] + [[Geometry](../../tag/geometry/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md b/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md index 8bc9d9ffb..0222974a8 100644 --- a/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md +++ b/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md @@ -11,11 +11,9 @@ ## [1456. Maximum Number of Vowels in a Substring of Given Length (Medium)](https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length "定长子串中元音的最大数目") -

    Given a string s and an integer k.

    +

    Given a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k.

    -

    Return the maximum number of vowel letters in any substring of s with length k.

    - -

    Vowel letters in English are (a, e, i, o, u).

    +

    Vowel letters in English are 'a', 'e', 'i', 'o', and 'u'.

     

    Example 1:

    @@ -42,27 +40,12 @@ Explanation: "lee", "eet" and "ode" contain 2 vowels. -

    Example 4:

    - -
    -Input: s = "rhythms", k = 4
    -Output: 0
    -Explanation: We can see that s doesn't have any vowel letters.
    -
    - -

    Example 5:

    - -
    -Input: s = "tryhard", k = 4
    -Output: 1
    -
    -

     

    Constraints:

      -
    • 1 <= s.length <= 10^5
    • -
    • s consists of lowercase English letters.
    • +
    • 1 <= s.length <= 105
    • +
    • s consists of lowercase English letters.
    • 1 <= k <= s.length
    diff --git a/problems/maximum-number-of-weeks-for-which-you-can-work/README.md b/problems/maximum-number-of-weeks-for-which-you-can-work/README.md index 60f444ba4..406210336 100644 --- a/problems/maximum-number-of-weeks-for-which-you-can-work/README.md +++ b/problems/maximum-number-of-weeks-for-which-you-can-work/README.md @@ -68,8 +68,11 @@ Thus, one milestone in project 0 will remain unfinished. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Similar Questions + 1. [Task Scheduler](../task-scheduler) (Medium) ### Hints
    diff --git a/problems/maximum-number-of-words-found-in-sentences/README.md b/problems/maximum-number-of-words-found-in-sentences/README.md new file mode 100644 index 000000000..38e5c6b31 --- /dev/null +++ b/problems/maximum-number-of-words-found-in-sentences/README.md @@ -0,0 +1,61 @@ + + + + + + + +[< Previous](../elements-in-array-after-removing-and-replacing-elements "Elements in Array After Removing and Replacing Elements") +                 +[Next >](../find-all-possible-recipes-from-given-supplies "Find All Possible Recipes from Given Supplies") + +## [2114. Maximum Number of Words Found in Sentences (Easy)](https://leetcode.com/problems/maximum-number-of-words-found-in-sentences "句子中的最多单词数") + +

    A sentence is a list of words that are separated by a single space with no leading or trailing spaces.

    + +

    You are given an array of strings sentences, where each sentences[i] represents a single sentence.

    + +

    Return the maximum number of words that appear in a single sentence.

    + +

     

    +

    Example 1:

    + +
    +Input: sentences = ["alice and bob love leetcode", "i think so too", "this is great thanks very much"]
    +Output: 6
    +Explanation: 
    +- The first sentence, "alice and bob love leetcode", has 5 words in total.
    +- The second sentence, "i think so too", has 4 words in total.
    +- The third sentence, "this is great thanks very much", has 6 words in total.
    +Thus, the maximum number of words in a single sentence comes from the third sentence, which has 6 words.
    +
    + +

    Example 2:

    + +
    +Input: sentences = ["please wait", "continue to fight", "continue to win"]
    +Output: 3
    +Explanation: It is possible that multiple sentences contain the same number of words. 
    +In this example, the second and third sentences (underlined) have the same number of words.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= sentences.length <= 100
    • +
    • 1 <= sentences[i].length <= 100
    • +
    • sentences[i] consists only of lowercase English letters and ' ' only.
    • +
    • sentences[i] does not have leading or trailing spaces.
    • +
    • All the words in sentences[i] are separated by a single space.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Process each sentence separately and count the number of words by looking for the number of space characters in the sentence and adding it by 1. +
    diff --git a/problems/maximum-path-quality-of-a-graph/README.md b/problems/maximum-path-quality-of-a-graph/README.md index de1176b46..9e6c3bbfd 100644 --- a/problems/maximum-path-quality-of-a-graph/README.md +++ b/problems/maximum-path-quality-of-a-graph/README.md @@ -47,18 +47,7 @@ The nodes visited are 0 and 3, giving a maximal path quality of 5 + 20 = 25. Output: 7 Explanation: One possible path is 0 -> 1 -> 3 -> 1 -> 0. The total time taken is 10 + 13 + 13 + 10 = 46 <= 50. -The nodes visited are 0, 1, and 3, giving a maximal path quality of 1 + 2 + 4 = 7. - -

    Example 4:

    - -

    - -
    -Input: values = [0,1,2], edges = [[1,2,10]], maxTime = 10
    -Output: 0
    -Explanation: 
    -The only path is 0. The total time taken is 0.
    -The only node visited is 0, giving a maximal path quality of 0.
    +The nodes visited are 0, 1, and 3, giving a maximal path quality of 1 + 2 + 4 = 7.
     

     

    diff --git a/problems/maximum-performance-of-a-team/README.md b/problems/maximum-performance-of-a-team/README.md index 4bf572f41..875210e17 100644 --- a/problems/maximum-performance-of-a-team/README.md +++ b/problems/maximum-performance-of-a-team/README.md @@ -62,6 +62,9 @@ We have the maximum performance of the team by selecting engineer 2 (with speed= [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] +### Similar Questions + 1. [Maximum Fruits Harvested After at Most K Steps](../maximum-fruits-harvested-after-at-most-k-steps) (Hard) + ### Hints
    Hint 1 diff --git a/problems/maximum-points-you-can-obtain-from-cards/README.md b/problems/maximum-points-you-can-obtain-from-cards/README.md index c5c74b84a..d01d36990 100644 --- a/problems/maximum-points-you-can-obtain-from-cards/README.md +++ b/problems/maximum-points-you-can-obtain-from-cards/README.md @@ -44,21 +44,6 @@ Explanation: You have to take all the cards. Your score is the sum of points of all cards. -

    Example 4:

    - -
    -Input: cardPoints = [1,1000,1], k = 1
    -Output: 1
    -Explanation: You cannot take the card in the middle. Your best score is 1. 
    -
    - -

    Example 5:

    - -
    -Input: cardPoints = [1,79,80,1,1,1,200,1], k = 3
    -Output: 202
    -
    -

     

    Constraints:

    @@ -70,8 +55,12 @@ ### Related Topics [[Array](../../tag/array/README.md)] - [[Prefix Sum](../../tag/prefix-sum/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Similar Questions + 1. [Maximum Score from Performing Multiplication Operations](../maximum-score-from-performing-multiplication-operations) (Medium) + 1. [Removing Minimum and Maximum From Array](../removing-minimum-and-maximum-from-array) (Medium) ### Hints
    diff --git a/problems/maximum-product-of-splitted-binary-tree/README.md b/problems/maximum-product-of-splitted-binary-tree/README.md index 0d7bea15e..aad097cb2 100644 --- a/problems/maximum-product-of-splitted-binary-tree/README.md +++ b/problems/maximum-product-of-splitted-binary-tree/README.md @@ -34,20 +34,6 @@ Explanation: Remove the red edge and get 2 binary trees with sum 15 and 6.Their product is 90 (15*6) -

    Example 3:

    - -
    -Input: root = [2,3,9,10,7,8,6,5,4,11,1]
    -Output: 1025
    -
    - -

    Example 4:

    - -
    -Input: root = [1,1]
    -Output: 1
    -
    -

     

    Constraints:

    diff --git a/problems/maximum-product-of-word-lengths/README.md b/problems/maximum-product-of-word-lengths/README.md index 32a3e74c8..40fec0598 100644 --- a/problems/maximum-product-of-word-lengths/README.md +++ b/problems/maximum-product-of-word-lengths/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-distance-from-all-buildings "Shortest Distance from All Buildings") diff --git a/problems/maximum-profit-of-operating-a-centennial-wheel/README.md b/problems/maximum-profit-of-operating-a-centennial-wheel/README.md index f638ef1e3..0ef854aa3 100644 --- a/problems/maximum-profit-of-operating-a-centennial-wheel/README.md +++ b/problems/maximum-profit-of-operating-a-centennial-wheel/README.md @@ -21,7 +21,7 @@

     

    Example 1:

    - +
     Input: customers = [8,3], boardingCost = 5, runningCost = 6
     Output: 3
    @@ -29,7 +29,8 @@
     1. 8 customers arrive, 4 board and 4 wait for the next gondola, the wheel rotates. Current profit is 4 * $5 - 1 * $6 = $14.
     2. 3 customers arrive, the 4 waiting board the wheel and the other 3 wait, the wheel rotates. Current profit is 8 * $5 - 2 * $6 = $28.
     3. The final 3 customers board the gondola, the wheel rotates. Current profit is 11 * $5 - 3 * $6 = $37.
    -The highest profit was $37 after rotating the wheel 3 times.
    +The highest profit was $37 after rotating the wheel 3 times. +

    Example 2:

    @@ -45,7 +46,6 @@ The highest profit was $37 after rotating the wheel 3 times. 6. 4 board and 1 waits, the wheel rotates. Current profit is 24 * $6 - 6 * $4 = $120. 7. 1 boards, the wheel rotates. Current profit is 25 * $6 - 7 * $4 = $122. The highest profit was $122 after rotating the wheel 7 times. -

    Example 3:

    @@ -62,25 +62,6 @@ The highest profit was $122 after rotating the wheel 7 times. The profit was never positive, so return -1. -

    Example 4:

    - -
    -Input: customers = [10,10,6,4,7], boardingCost = 3, runningCost = 8
    -Output: 9
    -Explanation:
    -1. 10 customers arrive, 4 board and 6 wait, the wheel rotates. Current profit is 4 * $3 - 1 * $8 = $4.
    -2. 10 customers arrive, 4 board and 12 wait, the wheel rotates. Current profit is 8 * $3 - 2 * $8 = $8.
    -3. 6 customers arrive, 4 board and 14 wait, the wheel rotates. Current profit is 12 * $3 - 3 * $8 = $12.
    -4. 4 customers arrive, 4 board and 14 wait, the wheel rotates. Current profit is 16 * $3 - 4 * $8 = $16.
    -5. 7 customers arrive, 4 board and 17 wait, the wheel rotates. Current profit is 20 * $3 - 5 * $8 = $20.
    -6. 4 board and 13 wait, the wheel rotates. Current profit is 24 * $3 - 6 * $8 = $24.
    -7. 4 board and 9 wait, the wheel rotates. Current profit is 28 * $3 - 7 * $8 = $28.
    -8. 4 board and 5 wait, the wheel rotates. Current profit is 32 * $3 - 8 * $8 = $32.
    -9. 4 board and 1 waits, the wheel rotates. Current profit is 36 * $3 - 9 * $8 = $36.
    -10. 1 board and 0 wait, the wheel rotates. Current profit is 37 * $3 - 10 * $8 = $31.
    -The highest profit was $36 after rotating the wheel 9 times.
    -
    -

     

    Constraints:

    diff --git a/problems/maximum-repeating-substring/README.md b/problems/maximum-repeating-substring/README.md index 96fe3070b..708d69560 100644 --- a/problems/maximum-repeating-substring/README.md +++ b/problems/maximum-repeating-substring/README.md @@ -53,9 +53,6 @@ [[String](../../tag/string/README.md)] [[String Matching](../../tag/string-matching/README.md)] -### Similar Questions - 1. [Detect Pattern of Length M Repeated K or More Times](../detect-pattern-of-length-m-repeated-k-or-more-times) (Easy) - ### Hints
    Hint 1 diff --git a/problems/maximum-running-time-of-n-computers/README.md b/problems/maximum-running-time-of-n-computers/README.md new file mode 100644 index 000000000..671f8e340 --- /dev/null +++ b/problems/maximum-running-time-of-n-computers/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../solving-questions-with-brainpower "Solving Questions With Brainpower") +                 +[Next >](../the-number-of-passengers-in-each-bus-i "The Number of Passengers in Each Bus I") + +## [2141. Maximum Running Time of N Computers (Hard)](https://leetcode.com/problems/maximum-running-time-of-n-computers "同时运行 N 台电脑的最长时间") + +

    You have n computers. You are given the integer n and a 0-indexed integer array batteries where the ith battery can run a computer for batteries[i] minutes. You are interested in running all n computers simultaneously using the given batteries.

    + +

    Initially, you can insert at most one battery into each computer. After that and at any integer time moment, you can remove a battery from a computer and insert another battery any number of times. The inserted battery can be a totally new battery or a battery from another computer. You may assume that the removing and inserting processes take no time.

    + +

    Note that the batteries cannot be recharged.

    + +

    Return the maximum number of minutes you can run all the n computers simultaneously.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 2, batteries = [3,3,3]
    +Output: 4
    +Explanation: 
    +Initially, insert battery 0 into the first computer and battery 1 into the second computer.
    +After two minutes, remove battery 1 from the second computer and insert battery 2 instead. Note that battery 1 can still run for one minute.
    +At the end of the third minute, battery 0 is drained, and you need to remove it from the first computer and insert battery 1 instead.
    +By the end of the fourth minute, battery 1 is also drained, and the first computer is no longer running.
    +We can run the two computers simultaneously for at most 4 minutes, so we return 4.
    +
    +
    + +

    Example 2:

    + +
    +Input: n = 2, batteries = [1,1,1,1]
    +Output: 2
    +Explanation: 
    +Initially, insert battery 0 into the first computer and battery 2 into the second computer. 
    +After one minute, battery 0 and battery 2 are drained so you need to remove them and insert battery 1 into the first computer and battery 3 into the second computer. 
    +After another minute, battery 1 and battery 3 are also drained so the first and second computers are no longer running.
    +We can run the two computers simultaneously for at most 2 minutes, so we return 2.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= batteries.length <= 105
    • +
    • 1 <= batteries[i] <= 109
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +For a given running time, can you determine if it is possible to run all n computers simultaneously? +
    + +
    +Hint 2 +Try to use Binary Search to find the maximal running time +
    diff --git a/problems/maximum-score-from-performing-multiplication-operations/README.md b/problems/maximum-score-from-performing-multiplication-operations/README.md index bc78098df..31175d357 100644 --- a/problems/maximum-score-from-performing-multiplication-operations/README.md +++ b/problems/maximum-score-from-performing-multiplication-operations/README.md @@ -64,6 +64,10 @@ The total score is 50 + 15 - 9 + 4 + 42 = 102. [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Maximum Points You Can Obtain from Cards](../maximum-points-you-can-obtain-from-cards) (Medium) + 1. [Stone Game VII](../stone-game-vii) (Medium) + ### Hints
    Hint 1 diff --git a/problems/maximum-score-from-removing-substrings/README.md b/problems/maximum-score-from-removing-substrings/README.md index 17c71631f..7fca866cd 100644 --- a/problems/maximum-score-from-removing-substrings/README.md +++ b/problems/maximum-score-from-removing-substrings/README.md @@ -58,9 +58,12 @@ Total score = 5 + 4 + 5 + 5 = 19. ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[String](../../tag/string/README.md)] + +### Similar Questions + 1. [Count Words Obtained After Adding a Letter](../count-words-obtained-after-adding-a-letter) (Medium) ### Hints
    diff --git a/problems/maximum-score-of-a-good-subarray/README.md b/problems/maximum-score-of-a-good-subarray/README.md index edeb34460..46c3d4d84 100644 --- a/problems/maximum-score-of-a-good-subarray/README.md +++ b/problems/maximum-score-of-a-good-subarray/README.md @@ -44,12 +44,15 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Stack](../../tag/stack/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] +### Similar Questions + 1. [Largest Rectangle in Histogram](../largest-rectangle-in-histogram) (Hard) + ### Hints
    Hint 1 diff --git a/problems/maximum-score-words-formed-by-letters/README.md b/problems/maximum-score-words-formed-by-letters/README.md index 97452e4ff..f2d0288bb 100644 --- a/problems/maximum-score-words-formed-by-letters/README.md +++ b/problems/maximum-score-words-formed-by-letters/README.md @@ -67,6 +67,9 @@ Letter "e" can only be used once. [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] +### Similar Questions + 1. [Maximum Good People Based on Statements](../maximum-good-people-based-on-statements) (Hard) + ### Hints
    Hint 1 diff --git a/problems/maximum-students-taking-exam/README.md b/problems/maximum-students-taking-exam/README.md index 3e752af5f..5b38f2519 100644 --- a/problems/maximum-students-taking-exam/README.md +++ b/problems/maximum-students-taking-exam/README.md @@ -65,11 +65,11 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Bitmask](../../tag/bitmask/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Matrix](../../tag/matrix/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/maximum-sum-bst-in-binary-tree/README.md b/problems/maximum-sum-bst-in-binary-tree/README.md index e74dca556..2cdd3f82f 100644 --- a/problems/maximum-sum-bst-in-binary-tree/README.md +++ b/problems/maximum-sum-bst-in-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-zigzag-path-in-a-binary-tree "Longest ZigZag Path in a Binary Tree") @@ -50,20 +50,6 @@ Explanation: All values are negatives. Return an empty BST. -

    Example 4:

    - -
    -Input: root = [2,1,3]
    -Output: 6
    -
    - -

    Example 5:

    - -
    -Input: root = [5,4,8,3,null,6,3]
    -Output: 7
    -
    -

     

    Constraints:

    diff --git a/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md b/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md index bc2d40939..f29094169 100644 --- a/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md +++ b/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../knight-probability-in-chessboard "Knight Probability in Chessboard") diff --git a/problems/maximum-twin-sum-of-a-linked-list/README.md b/problems/maximum-twin-sum-of-a-linked-list/README.md new file mode 100644 index 000000000..03df5b91f --- /dev/null +++ b/problems/maximum-twin-sum-of-a-linked-list/README.md @@ -0,0 +1,89 @@ + + + + + + + +[< Previous](../capitalize-the-title "Capitalize the Title") +                 +[Next >](../longest-palindrome-by-concatenating-two-letter-words "Longest Palindrome by Concatenating Two Letter Words") + +## [2130. Maximum Twin Sum of a Linked List (Medium)](https://leetcode.com/problems/maximum-twin-sum-of-a-linked-list "链表最大孪生和") + +

    In a linked list of size n, where n is even, the ith node (0-indexed) of the linked list is known as the twin of the (n-1-i)th node, if 0 <= i <= (n / 2) - 1.

    + +
      +
    • For example, if n = 4, then node 0 is the twin of node 3, and node 1 is the twin of node 2. These are the only nodes with twins for n = 4.
    • +
    + +

    The twin sum is defined as the sum of a node and its twin.

    + +

    Given the head of a linked list with even length, return the maximum twin sum of the linked list.

    + +

     

    +

    Example 1:

    + +
    +Input: head = [5,4,2,1]
    +Output: 6
    +Explanation:
    +Nodes 0 and 1 are the twins of nodes 3 and 2, respectively. All have twin sum = 6.
    +There are no other nodes with twins in the linked list.
    +Thus, the maximum twin sum of the linked list is 6. 
    +
    + +

    Example 2:

    + +
    +Input: head = [4,2,2,3]
    +Output: 7
    +Explanation:
    +The nodes with twins present in this linked list are:
    +- Node 0 is the twin of node 3 having a twin sum of 4 + 3 = 7.
    +- Node 1 is the twin of node 2 having a twin sum of 2 + 2 = 4.
    +Thus, the maximum twin sum of the linked list is max(7, 4) = 7. 
    +
    + +

    Example 3:

    + +
    +Input: head = [1,100000]
    +Output: 100001
    +Explanation:
    +There is only one node with a twin in the linked list having twin sum of 1 + 100000 = 100001.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is an even integer in the range [2, 105].
    • +
    • 1 <= Node.val <= 105
    • +
    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + +### Hints +
    +Hint 1 +How can "reversing" a part of the linked list help find the answer? +
    + +
    +Hint 2 +We know that the nodes of the first half are twins of nodes in the second half, so try dividing the linked list in half and reverse the second half. +
    + +
    +Hint 3 +How can two pointers be used to find every twin sum optimally? +
    + +
    +Hint 4 +Use two different pointers pointing to the first nodes of the two halves of the linked list. The second pointer will point to the first node of the reversed half, which is the (n-1-i)th node in the original linked list. By moving both pointers forward at the same time, we find all twin sums. +
    diff --git a/problems/maximum-units-on-a-truck/README.md b/problems/maximum-units-on-a-truck/README.md index 3ead65713..e08582c6e 100644 --- a/problems/maximum-units-on-a-truck/README.md +++ b/problems/maximum-units-on-a-truck/README.md @@ -53,8 +53,8 @@ The total number of units will be = (1 * 3) + (2 * 2) + (1 * 1) = 8. ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md b/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md index b41ba72a4..885b19f5f 100644 --- a/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md +++ b/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md @@ -51,8 +51,8 @@ There are no arrays that satisfy all the conditions and have nums[2] == 3, so 2 ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/mean-of-array-after-removing-some-elements/README.md b/problems/mean-of-array-after-removing-some-elements/README.md index 82a728f5a..a3838f31b 100644 --- a/problems/mean-of-array-after-removing-some-elements/README.md +++ b/problems/mean-of-array-after-removing-some-elements/README.md @@ -38,20 +38,6 @@ Output: 4.77778 -

    Example 4:

    - -
    -Input: arr = [9,7,8,7,7,8,4,4,6,8,8,7,6,8,8,9,2,6,0,0,1,10,8,6,3,3,5,1,10,9,0,7,10,0,10,4,1,10,6,9,3,6,0,0,2,7,0,6,7,2,9,7,7,3,0,1,6,1,10,3]
    -Output: 5.27778
    -
    - -

    Example 5:

    - -
    -Input: arr = [4,8,4,10,0,7,1,3,7,8,8,3,4,1,6,2,1,1,8,0,9,8,0,3,9,10,3,10,1,10,7,3,2,1,4,9,10,7,6,4,0,8,5,1,2,1,6,2,5,0,7,10,9,10,3,7,10,5,8,5,7,6,7,6,10,9,5,10,5,5,7,2,10,7,7,8,2,0,1,1]
    -Output: 5.29167
    -
    -

     

    Constraints:

    diff --git a/problems/meeting-rooms-ii/README.md b/problems/meeting-rooms-ii/README.md index e08daae7c..03636b0e5 100644 --- a/problems/meeting-rooms-ii/README.md +++ b/problems/meeting-rooms-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../meeting-rooms "Meeting Rooms") @@ -28,9 +28,9 @@

    NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/merge-bsts-to-create-single-bst/README.md b/problems/merge-bsts-to-create-single-bst/README.md index 63d8f9678..f8271915c 100644 --- a/problems/merge-bsts-to-create-single-bst/README.md +++ b/problems/merge-bsts-to-create-single-bst/README.md @@ -65,14 +65,6 @@ The resulting tree is shown above. This is the only valid operation that can be Explanation: It is impossible to perform any operations. -

    Example 4:

    - -
    -Input: trees = [[2,1,3]]
    -Output: [2,1,3]
    -Explanation: There is only one tree, and it is already a valid BST, so return its root.
    -
    -

     

    Constraints:

    diff --git a/problems/merge-in-between-linked-lists/README.md b/problems/merge-in-between-linked-lists/README.md index 246908775..2206ccda2 100644 --- a/problems/merge-in-between-linked-lists/README.md +++ b/problems/merge-in-between-linked-lists/README.md @@ -15,7 +15,7 @@

    Remove list1's nodes from the ath node to the bth node, and put list2 in their place.

    -

    The blue edges and nodes in the following figure incidate the result:

    +

    The blue edges and nodes in the following figure indicate the result:

    Build the result list and return its head.

    diff --git a/problems/merge-intervals/README.md b/problems/merge-intervals/README.md index d474da066..9a94b715c 100644 --- a/problems/merge-intervals/README.md +++ b/problems/merge-intervals/README.md @@ -53,3 +53,4 @@ 1. [Employee Free Time](../employee-free-time) (Hard) 1. [Partition Labels](../partition-labels) (Medium) 1. [Interval List Intersections](../interval-list-intersections) (Medium) + 1. [Amount of New Area Painted Each Day](../amount-of-new-area-painted-each-day) (Hard) diff --git a/problems/merge-strings-alternately/README.md b/problems/merge-strings-alternately/README.md index fa3b9c32b..27cb88935 100644 --- a/problems/merge-strings-alternately/README.md +++ b/problems/merge-strings-alternately/README.md @@ -61,6 +61,9 @@ merged: a p b q c d [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Zigzag Iterator](../zigzag-iterator) (Medium) + ### Hints
    Hint 1 diff --git a/problems/merge-triplets-to-form-target-triplet/README.md b/problems/merge-triplets-to-form-target-triplet/README.md index a2105787a..cc1c8f67d 100644 --- a/problems/merge-triplets-to-form-target-triplet/README.md +++ b/problems/merge-triplets-to-form-target-triplet/README.md @@ -31,7 +31,7 @@
     Input: triplets = [[2,5,3],[1,8,4],[1,7,5]], target = [2,7,5]
     Output: true
    -Explanation: Perform the following operations:
    +Explanation: Perform the following operations:
     - Choose the first and last triplets [[2,5,3],[1,8,4],[1,7,5]]. Update the last triplet to be [max(2,1), max(5,7), max(3,5)] = [2,7,5]. triplets = [[2,5,3],[1,8,4],[2,7,5]]
     The target triplet [2,7,5] is now an element of triplets.
     
    @@ -39,9 +39,9 @@ The target triplet [2,7,5] is now an element of triplets.

    Example 2:

    -Input: triplets = [[1,3,4],[2,5,8]], target = [2,5,8]
    -Output: true
    -Explanation: The target triplet [2,5,8] is already an element of triplets.
    +Input: triplets = [[3,4,5],[4,5,6]], target = [3,2,5]
    +Output: false
    +Explanation: It is impossible to have [3,2,5] as an element because there is no 2 in any of the triplets.
     

    Example 3:

    @@ -55,14 +55,6 @@ The target triplet [2,7,5] is now an element of triplets. The target triplet [5,5,5] is now an element of triplets. -

    Example 4:

    - -
    -Input: triplets = [[3,4,5],[4,5,6]], target = [3,2,5]
    -Output: false
    -Explanation: It is impossible to have [3,2,5] as an element because there is no 2 in any of the triplets.
    -
    -

     

    Constraints:

    diff --git a/problems/min-cost-to-connect-all-points/README.md b/problems/min-cost-to-connect-all-points/README.md index 6ad6e59f7..7cb2c19ad 100644 --- a/problems/min-cost-to-connect-all-points/README.md +++ b/problems/min-cost-to-connect-all-points/README.md @@ -11,22 +11,20 @@ ## [1584. Min Cost to Connect All Points (Medium)](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") -

    You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].

    +

    You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].

    -

    The cost of connecting two points [xi, yi] and [xj, yj] is the manhattan distance between them: |xi - xj| + |yi - yj|, where |val| denotes the absolute value of val.

    +

    The cost of connecting two points [xi, yi] and [xj, yj] is the manhattan distance between them: |xi - xj| + |yi - yj|, where |val| denotes the absolute value of val.

    -

    Return the minimum cost to make all points connected. All points are connected if there is exactly one simple path between any two points.

    +

    Return the minimum cost to make all points connected. All points are connected if there is exactly one simple path between any two points.

     

    Example 1:

    - -

    - +
     Input: points = [[0,0],[2,2],[3,10],[5,2],[7,0]]
     Output: 20
    -Explanation:
    -
    +Explanation: 
    +
     We can connect the points as shown above to get the minimum cost of 20.
     Notice that there is a unique path between every pair of points.
     
    @@ -38,41 +36,23 @@ Notice that there is a unique path between every pair of points. Output: 18 -

    Example 3:

    - -
    -Input: points = [[0,0],[1,1],[1,0],[-1,1]]
    -Output: 4
    -
    - -

    Example 4:

    - -
    -Input: points = [[-1000000,-1000000],[1000000,1000000]]
    -Output: 4000000
    -
    - -

    Example 5:

    - -
    -Input: points = [[0,0]]
    -Output: 0
    -
    -

     

    Constraints:

    • 1 <= points.length <= 1000
    • -
    • -106 <= xi, yi <= 106
    • +
    • -106 <= xi, yi <= 106
    • All pairs (xi, yi) are distinct.
    ### Related Topics - [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] + [[Union Find](../../tag/union-find/README.md)] [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] +### Similar Questions + 1. [Minimum Number of Lines to Cover Points](../minimum-number-of-lines-to-cover-points) (Medium) + ### Hints
    Hint 1 diff --git a/problems/mini-parser/README.md b/problems/mini-parser/README.md index 35d1f45d1..2a2884145 100644 --- a/problems/mini-parser/README.md +++ b/problems/mini-parser/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shuffle-an-array "Shuffle an Array") diff --git a/problems/minimize-deviation-in-array/README.md b/problems/minimize-deviation-in-array/README.md index 67f25aefa..9b41e74d4 100644 --- a/problems/minimize-deviation-in-array/README.md +++ b/problems/minimize-deviation-in-array/README.md @@ -66,10 +66,10 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Array](../../tag/array/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/minimize-hamming-distance-after-swap-operations/README.md b/problems/minimize-hamming-distance-after-swap-operations/README.md index 56ca147c2..9a9482090 100644 --- a/problems/minimize-hamming-distance-after-swap-operations/README.md +++ b/problems/minimize-hamming-distance-after-swap-operations/README.md @@ -59,9 +59,12 @@ The Hamming distance of source and target is 2 as they differ in 2 positions: in ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] + +### Similar Questions + 1. [Smallest String With Swaps](../smallest-string-with-swaps) (Medium) ### Hints
    diff --git a/problems/minimum-absolute-difference/README.md b/problems/minimum-absolute-difference/README.md index 58e0d2f6b..a2d9fe276 100644 --- a/problems/minimum-absolute-difference/README.md +++ b/problems/minimum-absolute-difference/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-time-to-build-blocks "Minimum Time to Build Blocks") @@ -11,14 +11,14 @@ ## [1200. Minimum Absolute Difference (Easy)](https://leetcode.com/problems/minimum-absolute-difference "最小绝对差") -

    Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements. 

    +

    Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements.

    Return a list of pairs in ascending order(with respect to pairs), each pair [a, b] follows

    • a, b are from arr
    • a < b
    • -
    • b - a equals to the minimum absolute difference of any two elements in arr
    • +
    • b - a equals to the minimum absolute difference of any two elements in arr

     

    @@ -47,14 +47,17 @@

    Constraints:

      -
    • 2 <= arr.length <= 10^5
    • -
    • -10^6 <= arr[i] <= 10^6
    • +
    • 2 <= arr.length <= 105
    • +
    • -106 <= arr[i] <= 106
    ### Related Topics [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Minimum Cost of Buying Candies With Discount](../minimum-cost-of-buying-candies-with-discount) (Easy) + ### Hints
    Hint 1 diff --git a/problems/minimum-add-to-make-parentheses-valid/README.md b/problems/minimum-add-to-make-parentheses-valid/README.md index b03b231d9..f22abd1a7 100644 --- a/problems/minimum-add-to-make-parentheses-valid/README.md +++ b/problems/minimum-add-to-make-parentheses-valid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-music-playlists "Number of Music Playlists") @@ -42,20 +42,6 @@ Output: 3 -

    Example 3:

    - -
    -Input: s = "()"
    -Output: 0
    -
    - -

    Example 4:

    - -
    -Input: s = "()))(("
    -Output: 4
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md b/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md index 94852b978..2f7a8dce0 100644 --- a/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md +++ b/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md @@ -50,10 +50,14 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] - [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Similar Questions + 1. [Minimum Swaps to Group All 1's Together](../minimum-swaps-to-group-all-1s-together) (Medium) + 1. [Minimum Number of Operations to Make Array Continuous](../minimum-number-of-operations-to-make-array-continuous) (Hard) ### Hints
    diff --git a/problems/minimum-area-rectangle-ii/README.md b/problems/minimum-area-rectangle-ii/README.md index c8fc5d698..c413480e8 100644 --- a/problems/minimum-area-rectangle-ii/README.md +++ b/problems/minimum-area-rectangle-ii/README.md @@ -19,7 +19,7 @@

     

    Example 1:

    - +
     Input: points = [[1,2],[2,1],[1,0],[0,1]]
     Output: 2.00000
    @@ -27,7 +27,7 @@
     

    Example 2:

    - +
     Input: points = [[0,1],[2,1],[1,1],[1,0],[2,0]]
     Output: 1.00000
    @@ -35,21 +35,13 @@
     

    Example 3:

    - +
     Input: points = [[0,3],[1,2],[3,1],[1,3],[2,1]]
     Output: 0
     Explanation: There is no possible rectangle to form from these points.
     
    -

    Example 4:

    - -
    -Input: points = [[3,1],[1,1],[0,1],[2,1],[3,3],[3,2],[0,2],[2,3]]
    -Output: 2.00000
    -Explanation: The minimum area rectangle occurs at [2,1],[2,3],[3,3],[3,1], with an area of 2.
    -
    -

     

    Constraints:

    @@ -61,6 +53,6 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] diff --git a/problems/minimum-cost-homecoming-of-a-robot-in-a-grid/README.md b/problems/minimum-cost-homecoming-of-a-robot-in-a-grid/README.md new file mode 100644 index 000000000..49d80e975 --- /dev/null +++ b/problems/minimum-cost-homecoming-of-a-robot-in-a-grid/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../minimum-number-of-buckets-required-to-collect-rainwater-from-houses "Minimum Number of Buckets Required to Collect Rainwater from Houses") +                 +[Next >](../count-fertile-pyramids-in-a-land "Count Fertile Pyramids in a Land") + +## [2087. Minimum Cost Homecoming of a Robot in a Grid (Medium)](https://leetcode.com/problems/minimum-cost-homecoming-of-a-robot-in-a-grid "网格图中机器人回家的最小代价") + +

    There is an m x n grid, where (0, 0) is the top-left cell and (m - 1, n - 1) is the bottom-right cell. You are given an integer array startPos where startPos = [startrow, startcol] indicates that initially, a robot is at the cell (startrow, startcol). You are also given an integer array homePos where homePos = [homerow, homecol] indicates that its home is at the cell (homerow, homecol).

    + +

    The robot needs to go to its home. It can move one cell in four directions: left, right, up, or down, and it can not move outside the boundary. Every move incurs some cost. You are further given two 0-indexed integer arrays: rowCosts of length m and colCosts of length n.

    + +
      +
    • If the robot moves up or down into a cell whose row is r, then this move costs rowCosts[r].
    • +
    • If the robot moves left or right into a cell whose column is c, then this move costs colCosts[c].
    • +
    + +

    Return the minimum total cost for this robot to return home.

    + +

     

    +

    Example 1:

    + +
    +Input: startPos = [1, 0], homePos = [2, 3], rowCosts = [5, 4, 3], colCosts = [8, 2, 6, 7]
    +Output: 18
    +Explanation: One optimal path is that:
    +Starting from (1, 0)
    +-> It goes down to (2, 0). This move costs rowCosts[2] = 3.
    +-> It goes right to (2, 1). This move costs colCosts[1] = 2.
    +-> It goes right to (2, 2). This move costs colCosts[2] = 6.
    +-> It goes right to (2, 3). This move costs colCosts[3] = 7.
    +The total cost is 3 + 2 + 6 + 7 = 18
    + +

    Example 2:

    + +
    +Input: startPos = [0, 0], homePos = [0, 0], rowCosts = [5], colCosts = [26]
    +Output: 0
    +Explanation: The robot is already at its home. Since no moves occur, the total cost is 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == rowCosts.length
    • +
    • n == colCosts.length
    • +
    • 1 <= m, n <= 105
    • +
    • 0 <= rowCosts[r], colCosts[c] <= 104
    • +
    • startPos.length == 2
    • +
    • homePos.length == 2
    • +
    • 0 <= startrow, homerow < m
    • +
    • 0 <= startcol, homecol < n
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Irrespective of what path the robot takes, it will have to traverse all the rows between startRow and homeRow and all the columns between startCol and homeCol. +
    + +
    +Hint 2 +Hence, making any other move other than traversing the required rows and columns will potentially incur more cost which can be avoided. +
    diff --git a/problems/minimum-cost-of-buying-candies-with-discount/README.md b/problems/minimum-cost-of-buying-candies-with-discount/README.md new file mode 100644 index 000000000..f1b686fbd --- /dev/null +++ b/problems/minimum-cost-of-buying-candies-with-discount/README.md @@ -0,0 +1,100 @@ + + + + + + + +[< Previous](../choose-numbers-from-two-arrays-in-range "Choose Numbers From Two Arrays in Range") +                 +[Next >](../count-the-hidden-sequences "Count the Hidden Sequences") + +## [2144. Minimum Cost of Buying Candies With Discount (Easy)](https://leetcode.com/problems/minimum-cost-of-buying-candies-with-discount "打折购买糖果的最小开销") + +

    A shop is selling candies at a discount. For every two candies sold, the shop gives a third candy for free.

    + +

    The customer can choose any candy to take away for free as long as the cost of the chosen candy is less than or equal to the minimum cost of the two candies bought.

    + +
      +
    • For example, if there are 4 candies with costs 1, 2, 3, and 4, and the customer buys candies with costs 2 and 3, they can take the candy with cost 1 for free, but not the candy with cost 4.
    • +
    + +

    Given a 0-indexed integer array cost, where cost[i] denotes the cost of the ith candy, return the minimum cost of buying all the candies.

    + +

     

    +

    Example 1:

    + +
    +Input: cost = [1,2,3]
    +Output: 5
    +Explanation: We buy the candies with costs 2 and 3, and take the candy with cost 1 for free.
    +The total cost of buying all candies is 2 + 3 = 5. This is the only way we can buy the candies.
    +Note that we cannot buy candies with costs 1 and 3, and then take the candy with cost 2 for free.
    +The cost of the free candy has to be less than or equal to the minimum cost of the purchased candies.
    +
    + +

    Example 2:

    + +
    +Input: cost = [6,5,7,9,2,2]
    +Output: 23
    +Explanation: The way in which we can get the minimum cost is described below:
    +- Buy candies with costs 9 and 7
    +- Take the candy with cost 6 for free
    +- We buy candies with costs 5 and 2
    +- Take the last remaining candy with cost 2 for free
    +Hence, the minimum cost to buy all candies is 9 + 7 + 5 + 2 = 23.
    +
    + +

    Example 3:

    + +
    +Input: cost = [5,5]
    +Output: 10
    +Explanation: Since there are only 2 candies, we buy both of them. There is not a third candy we can take for free.
    +Hence, the minimum cost to buy all candies is 5 + 5 = 10.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= cost.length <= 100
    • +
    • 1 <= cost[i] <= 100
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +If we consider costs from high to low, what is the maximum cost of a single candy that we can get for free? +
    + +
    +Hint 2 +How can we generalize this approach to maximize the costs of the candies we get for free? +
    + +
    +Hint 3 +Can “sorting” the array help us find the minimum cost? +
    + +
    +Hint 4 +If we consider costs from high to low, what is the maximum cost of a single candy that we can get for free? +
    + +
    +Hint 5 +How can we generalize this approach to maximize the costs of the candies we get for free? +
    + +
    +Hint 6 +Can “sorting” the array help us find the minimum cost? +
    diff --git a/problems/minimum-cost-to-connect-two-groups-of-points/README.md b/problems/minimum-cost-to-connect-two-groups-of-points/README.md index fa8b8b06d..64c0a7e2b 100644 --- a/problems/minimum-cost-to-connect-two-groups-of-points/README.md +++ b/problems/minimum-cost-to-connect-two-groups-of-points/README.md @@ -62,11 +62,11 @@ Note that there are multiple points connected to point 2 in the first group and ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Bitmask](../../tag/bitmask/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Matrix](../../tag/matrix/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/minimum-cost-to-cut-a-stick/README.md b/problems/minimum-cost-to-cut-a-stick/README.md index bd27a000b..232a331a8 100644 --- a/problems/minimum-cost-to-cut-a-stick/README.md +++ b/problems/minimum-cost-to-cut-a-stick/README.md @@ -55,6 +55,9 @@ There are much ordering with total cost <= 25, for example, the order [4, 6, [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Number of Ways to Divide a Long Corridor](../number-of-ways-to-divide-a-long-corridor) (Hard) + ### Hints
    Hint 1 diff --git a/problems/minimum-cost-to-merge-stones/README.md b/problems/minimum-cost-to-merge-stones/README.md index da1b34bf4..8efb726aa 100644 --- a/problems/minimum-cost-to-merge-stones/README.md +++ b/problems/minimum-cost-to-merge-stones/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../available-captures-for-rook "Available Captures for Rook") diff --git a/problems/minimum-cost-to-reach-city-with-discounts/README.md b/problems/minimum-cost-to-reach-city-with-discounts/README.md new file mode 100644 index 000000000..873df6d98 --- /dev/null +++ b/problems/minimum-cost-to-reach-city-with-discounts/README.md @@ -0,0 +1,34 @@ + + + + + + + +[< Previous](../find-all-people-with-secret "Find All People With Secret") +                 +[Next >](../finding-3-digit-even-numbers "Finding 3-Digit Even Numbers") + +## [2093. Minimum Cost to Reach City With Discounts (Medium)](https://leetcode.com/problems/minimum-cost-to-reach-city-with-discounts "") + + + +### Related Topics + [[Graph](../../tag/graph/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] + +### Hints +
    +Hint 1 +Try to construct a graph out of highways. What type of graph is this? +
    + +
    +Hint 2 +We essentially need to find the minimum distance to get from node 0 to node n - 1 in an undirected weighted graph. What algorithm should we use to do this? +
    + +
    +Hint 3 +Use Dijkstra's algorithm to find the minimum weight path. Keep track of the minimum distance to each vertex with d discounts left +
    diff --git a/problems/minimum-cost-to-reach-destination-in-time/README.md b/problems/minimum-cost-to-reach-destination-in-time/README.md index 73dbdb11c..d2bc9797e 100644 --- a/problems/minimum-cost-to-reach-destination-in-time/README.md +++ b/problems/minimum-cost-to-reach-destination-in-time/README.md @@ -65,8 +65,12 @@ You cannot take path 0 -> 1 -> 2 -> 5 since it would take too long. ### Related Topics - [[Graph](../../tag/graph/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Graph](../../tag/graph/README.md)] + +### Similar Questions + 1. [Maximum Path Quality of a Graph](../maximum-path-quality-of-a-graph) (Hard) + 1. [Minimum Cost to Reach City With Discounts](../minimum-cost-to-reach-city-with-discounts) (Medium) ### Hints
    diff --git a/problems/minimum-cost-to-separate-sentence-into-rows/README.md b/problems/minimum-cost-to-separate-sentence-into-rows/README.md index 36029ae69..559bc0df4 100644 --- a/problems/minimum-cost-to-separate-sentence-into-rows/README.md +++ b/problems/minimum-cost-to-separate-sentence-into-rows/README.md @@ -9,7 +9,7 @@                  [Next >](../kth-distinct-string-in-an-array "Kth Distinct String in an Array") -## [2052. Minimum Cost to Separate Sentence Into Rows (Medium)](https://leetcode.com/problems/minimum-cost-to-separate-sentence-into-rows "") +## [2052. Minimum Cost to Separate Sentence Into Rows (Medium)](https://leetcode.com/problems/minimum-cost-to-separate-sentence-into-rows "将句子分隔成行的最低成本") diff --git a/problems/minimum-cost-to-set-cooking-time/README.md b/problems/minimum-cost-to-set-cooking-time/README.md new file mode 100644 index 000000000..c3235cd38 --- /dev/null +++ b/problems/minimum-cost-to-set-cooking-time/README.md @@ -0,0 +1,98 @@ + + + + + + + +[< Previous](../partition-array-according-to-given-pivot "Partition Array According to Given Pivot") +                 +[Next >](../minimum-difference-in-sums-after-removal-of-elements "Minimum Difference in Sums After Removal of Elements") + +## [2162. Minimum Cost to Set Cooking Time (Medium)](https://leetcode.com/problems/minimum-cost-to-set-cooking-time "设置时间的最少代价") + +

    A generic microwave supports cooking times for:

    + +
      +
    • at least 1 second.
    • +
    • at most 99 minutes and 99 seconds.
    • +
    + +

    To set the cooking time, you push at most four digits. The microwave normalizes what you push as four digits by prepending zeroes. It interprets the first two digits as the minutes and the last two digits as the seconds. It then adds them up as the cooking time. For example,

    + +
      +
    • You push 9 5 4 (three digits). It is normalized as 0954 and interpreted as 9 minutes and 54 seconds.
    • +
    • You push 0 0 0 8 (four digits). It is interpreted as 0 minutes and 8 seconds.
    • +
    • You push 8 0 9 0. It is interpreted as 80 minutes and 90 seconds.
    • +
    • You push 8 1 3 0. It is interpreted as 81 minutes and 30 seconds.
    • +
    + +

    You are given integers startAt, moveCost, pushCost, and targetSeconds. Initially, your finger is on the digit startAt. Moving the finger above any specific digit costs moveCost units of fatigue. Pushing the digit below the finger once costs pushCost units of fatigue.

    + +

    There can be multiple ways to set the microwave to cook for targetSeconds seconds but you are interested in the way with the minimum cost.

    + +

    Return the minimum cost to set targetSeconds seconds of cooking time.

    + +

    Remember that one minute consists of 60 seconds.

    + +

     

    +

    Example 1:

    + +
    +Input: startAt = 1, moveCost = 2, pushCost = 1, targetSeconds = 600
    +Output: 6
    +Explanation: The following are the possible ways to set the cooking time.
    +- 1 0 0 0, interpreted as 10 minutes and 0 seconds.
    +  The finger is already on digit 1, pushes 1 (with cost 1), moves to 0 (with cost 2), pushes 0 (with cost 1), pushes 0 (with cost 1), and pushes 0 (with cost 1).
    +  The cost is: 1 + 2 + 1 + 1 + 1 = 6. This is the minimum cost.
    +- 0 9 6 0, interpreted as 9 minutes and 60 seconds. That is also 600 seconds.
    +  The finger moves to 0 (with cost 2), pushes 0 (with cost 1), moves to 9 (with cost 2), pushes 9 (with cost 1), moves to 6 (with cost 2), pushes 6 (with cost 1), moves to 0 (with cost 2), and pushes 0 (with cost 1).
    +  The cost is: 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 = 12.
    +- 9 6 0, normalized as 0960 and interpreted as 9 minutes and 60 seconds.
    +  The finger moves to 9 (with cost 2), pushes 9 (with cost 1), moves to 6 (with cost 2), pushes 6 (with cost 1), moves to 0 (with cost 2), and pushes 0 (with cost 1).
    +  The cost is: 2 + 1 + 2 + 1 + 2 + 1 = 9.
    +
    + +

    Example 2:

    + +
    +Input: startAt = 0, moveCost = 1, pushCost = 2, targetSeconds = 76
    +Output: 6
    +Explanation: The optimal way is to push two digits: 7 6, interpreted as 76 seconds.
    +The finger moves to 7 (with cost 1), pushes 7 (with cost 2), moves to 6 (with cost 1), and pushes 6 (with cost 2). The total cost is: 1 + 2 + 1 + 2 = 6
    +Note other possible ways are 0076, 076, 0116, and 116, but none of them produces the minimum cost.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= startAt <= 9
    • +
    • 1 <= moveCost, pushCost <= 105
    • +
    • 1 <= targetSeconds <= 6039
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + +### Hints +
    +Hint 1 +Define a separate function Cost(mm, ss) where 0 <= mm <= 99 and 0 <= ss <= 99. This function should calculate the cost of setting the cocking time to mm minutes and ss seconds +
    + +
    +Hint 2 +The range of the minutes is small (i.e., [0, 99]), how can you use that? +
    + +
    +Hint 3 +For every mm in [0, 99], calculate the needed ss to make mm:ss equal to targetSeconds and minimize the cost of setting the cocking time to mm:ss +
    + +
    +Hint 4 +Be careful in some cases when ss is not in the valid range [0, 99]. +
    diff --git a/problems/minimum-deletions-to-make-string-balanced/README.md b/problems/minimum-deletions-to-make-string-balanced/README.md index ced0f75da..32083314e 100644 --- a/problems/minimum-deletions-to-make-string-balanced/README.md +++ b/problems/minimum-deletions-to-make-string-balanced/README.md @@ -49,6 +49,9 @@ Delete the characters at 0-indexed positions 3 and 6 ("aababba Hint 1 diff --git a/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md b/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md index e33c271fd..f53074997 100644 --- a/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md +++ b/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md @@ -53,6 +53,7 @@ The minimum possible difference is 2. ### Related Topics [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md b/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md index b999215c1..4c51853a1 100644 --- a/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md +++ b/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md @@ -11,9 +11,9 @@ ## [1509. Minimum Difference Between Largest and Smallest Value in Three Moves (Medium)](https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves "三次操作后最大值与最小值的最小差") -

    Given an array nums, you are allowed to choose one element of nums and change it by any value in one move.

    +

    You are given an integer array nums. In one move, you can choose one element of nums and change it by any value.

    -

    Return the minimum difference between the largest and smallest value of nums after perfoming at most 3 moves.

    +

    Return the minimum difference between the largest and smallest value of nums after performing at most three moves.

     

    Example 1:

    @@ -22,7 +22,8 @@ Input: nums = [5,3,2,4] Output: 0 Explanation: Change the array [5,3,2,4] to [2,2,2,2]. -The difference between the maximum and minimum is 2-2 = 0. +The difference between the maximum and minimum is 2-2 = 0. +

    Example 2:

    @@ -33,26 +34,12 @@ The difference between the maximum and minimum is 2-2 = 0. The difference between the maximum and minimum is 1-0 = 1. -

    Example 3:

    - -
    -Input: nums = [6,6,0,1,1,4,6]
    -Output: 2
    -
    - -

    Example 4:

    - -
    -Input: nums = [1,5,6,14,15]
    -Output: 1
    -
    -

     

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • -10^9 <= nums[i] <= 10^9
    • +
    • 1 <= nums.length <= 105
    • +
    • -109 <= nums[i] <= 109
    ### Related Topics diff --git a/problems/minimum-difference-in-sums-after-removal-of-elements/README.md b/problems/minimum-difference-in-sums-after-removal-of-elements/README.md new file mode 100644 index 000000000..9daf25991 --- /dev/null +++ b/problems/minimum-difference-in-sums-after-removal-of-elements/README.md @@ -0,0 +1,90 @@ + + + + + + + +[< Previous](../minimum-cost-to-set-cooking-time "Minimum Cost to Set Cooking Time") +                 +[Next >](../sort-even-and-odd-indices-independently "Sort Even and Odd Indices Independently") + +## [2163. Minimum Difference in Sums After Removal of Elements (Hard)](https://leetcode.com/problems/minimum-difference-in-sums-after-removal-of-elements "删除元素后和的最小差值") + +

    You are given a 0-indexed integer array nums consisting of 3 * n elements.

    + +

    You are allowed to remove any subsequence of elements of size exactly n from nums. The remaining 2 * n elements will be divided into two equal parts:

    + +
      +
    • The first n elements belonging to the first part and their sum is sumfirst.
    • +
    • The next n elements belonging to the second part and their sum is sumsecond.
    • +
    + +

    The difference in sums of the two parts is denoted as sumfirst - sumsecond.

    + +
      +
    • For example, if sumfirst = 3 and sumsecond = 2, their difference is 1.
    • +
    • Similarly, if sumfirst = 2 and sumsecond = 3, their difference is -1.
    • +
    + +

    Return the minimum difference possible between the sums of the two parts after the removal of n elements.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [3,1,2]
    +Output: -1
    +Explanation: Here, nums has 3 elements, so n = 1. 
    +Thus we have to remove 1 element from nums and divide the array into two equal parts.
    +- If we remove nums[0] = 3, the array will be [1,2]. The difference in sums of the two parts will be 1 - 2 = -1.
    +- If we remove nums[1] = 1, the array will be [3,2]. The difference in sums of the two parts will be 3 - 2 = 1.
    +- If we remove nums[2] = 2, the array will be [3,1]. The difference in sums of the two parts will be 3 - 1 = 2.
    +The minimum difference between sums of the two parts is min(-1,1,2) = -1. 
    +
    + +

    Example 2:

    + +
    +Input: nums = [7,9,5,8,1,3]
    +Output: 1
    +Explanation: Here n = 2. So we must remove 2 elements and divide the remaining array into two parts containing two elements each.
    +If we remove nums[2] = 5 and nums[3] = 8, the resultant array will be [7,9,1,3]. The difference in sums will be (7+9) - (1+3) = 12.
    +To obtain the minimum difference, we should remove nums[1] = 9 and nums[4] = 1. The resultant array becomes [7,5,8,3]. The difference in sums of the two parts is (7+5) - (8+3) = 1.
    +It can be shown that it is not possible to obtain a difference smaller than 1.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • nums.length == 3 * n
    • +
    • 1 <= n <= 105
    • +
    • 1 <= nums[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +The lowest possible difference can be obtained when the sum of the first n elements in the resultant array is minimum, and the sum of the next n elements is maximum. +
    + +
    +Hint 2 +For every index i, think about how you can find the minimum possible sum of n elements with indices lesser or equal to i, if possible. +
    + +
    +Hint 3 +Similarly, for every index i, try to find the maximum possible sum of n elements with indices greater or equal to i, if possible. +
    + +
    +Hint 4 +Now for all indices, check if we can consider it as the partitioning index and hence find the answer. +
    diff --git a/problems/minimum-difficulty-of-a-job-schedule/README.md b/problems/minimum-difficulty-of-a-job-schedule/README.md index 1dcb96035..7367d9f71 100644 --- a/problems/minimum-difficulty-of-a-job-schedule/README.md +++ b/problems/minimum-difficulty-of-a-job-schedule/README.md @@ -11,13 +11,13 @@ ## [1335. Minimum Difficulty of a Job Schedule (Hard)](https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule "工作计划的最低难度") -

    You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the i-th job, you have to finish all the jobs j where 0 <= j < i).

    +

    You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the ith job, you have to finish all the jobs j where 0 <= j < i).

    -

    You have to finish at least one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the d days. The difficulty of a day is the maximum difficulty of a job done in that day.

    +

    You have to finish at least one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the d days. The difficulty of a day is the maximum difficulty of a job done on that day.

    -

    Given an array of integers jobDifficulty and an integer d. The difficulty of the i-th job is jobDifficulty[i].

    +

    You are given an integer array jobDifficulty and an integer d. The difficulty of the ith job is jobDifficulty[i].

    -

    Return the minimum difficulty of a job schedule. If you cannot find a schedule for the jobs return -1.

    +

    Return the minimum difficulty of a job schedule. If you cannot find a schedule for the jobs return -1.

     

    Example 1:

    @@ -46,20 +46,6 @@ The difficulty of the schedule = 6 + 1 = 7 Explanation: The schedule is one job per day. total difficulty will be 3. -

    Example 4:

    - -
    -Input: jobDifficulty = [7,1,7,1,7,1], d = 3
    -Output: 15
    -
    - -

    Example 5:

    - -
    -Input: jobDifficulty = [11,111,22,222,33,333,44,444], d = 6
    -Output: 843
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md index b519e4090..48841f1ad 100644 --- a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md +++ b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md @@ -30,8 +30,7 @@
     Input: word = "CAKE"
     Output: 3
    -Explanation: 
    -Using two fingers, one optimal way to type "CAKE" is: 
    +Explanation: Using two fingers, one optimal way to type "CAKE" is: 
     Finger 1 on letter 'C' -> cost = 0 
     Finger 1 on letter 'A' -> cost = Distance from letter 'C' to letter 'A' = 2 
     Finger 2 on letter 'K' -> cost = 0 
    @@ -44,8 +43,7 @@ Total distance = 3
     
     Input: word = "HAPPY"
     Output: 6
    -Explanation: 
    -Using two fingers, one optimal way to type "HAPPY" is:
    +Explanation: Using two fingers, one optimal way to type "HAPPY" is:
     Finger 1 on letter 'H' -> cost = 0
     Finger 1 on letter 'A' -> cost = Distance from letter 'H' to letter 'A' = 2
     Finger 2 on letter 'P' -> cost = 0
    @@ -54,20 +52,6 @@ Finger 1 on letter 'Y' -> cost = Distance from letter 'A' to
     Total distance = 6
     
    -

    Example 3:

    - -
    -Input: word = "NEW"
    -Output: 3
    -
    - -

    Example 4:

    - -
    -Input: word = "YEAR"
    -Output: 7
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-domino-rotations-for-equal-row/README.md b/problems/minimum-domino-rotations-for-equal-row/README.md index 63b5a53a9..70e13dd34 100644 --- a/problems/minimum-domino-rotations-for-equal-row/README.md +++ b/problems/minimum-domino-rotations-for-equal-row/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../clumsy-factorial "Clumsy Factorial") @@ -49,5 +49,5 @@ In this case, it is not possible to rotate the dominoes to make one row of value ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/minimum-elements-to-add-to-form-a-given-sum/README.md b/problems/minimum-elements-to-add-to-form-a-given-sum/README.md index dfbb7e274..1bad5bcd5 100644 --- a/problems/minimum-elements-to-add-to-form-a-given-sum/README.md +++ b/problems/minimum-elements-to-add-to-form-a-given-sum/README.md @@ -44,8 +44,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/minimum-falling-path-sum-ii/README.md b/problems/minimum-falling-path-sum-ii/README.md index d0c06f521..446fbe15c 100644 --- a/problems/minimum-falling-path-sum-ii/README.md +++ b/problems/minimum-falling-path-sum-ii/README.md @@ -50,6 +50,9 @@ The falling path with the smallest sum is [1,5,7], so the answer is 13 [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Minimum Falling Path Sum](../minimum-falling-path-sum) (Medium) + ### Hints
    Hint 1 diff --git a/problems/minimum-falling-path-sum/README.md b/problems/minimum-falling-path-sum/README.md index 9e7856ffb..cbd4580c6 100644 --- a/problems/minimum-falling-path-sum/README.md +++ b/problems/minimum-falling-path-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-subarrays-with-sum "Binary Subarrays With Sum") diff --git a/problems/minimum-genetic-mutation/README.md b/problems/minimum-genetic-mutation/README.md index 906685cc7..464225609 100644 --- a/problems/minimum-genetic-mutation/README.md +++ b/problems/minimum-genetic-mutation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-oone-data-structure "All O`one Data Structure") diff --git a/problems/minimum-incompatibility/README.md b/problems/minimum-incompatibility/README.md index cb789c363..8cce8ee4d 100644 --- a/problems/minimum-incompatibility/README.md +++ b/problems/minimum-incompatibility/README.md @@ -56,9 +56,9 @@ The incompatibility is (2-1) + (3-2) + (8-6) + (3-1) = 6. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] ### Hints diff --git a/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md b/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md index db3e86945..4dea8e463 100644 --- a/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md +++ b/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md @@ -42,26 +42,12 @@ Explanation: Inserting 5 characters the string becomes "leetcodocteel".
    -

    Example 4:

    - -
    -Input: s = "g"
    -Output: 0
    -
    - -

    Example 5:

    - -
    -Input: s = "no"
    -Output: 1
    -
    -

     

    Constraints:

    • 1 <= s.length <= 500
    • -
    • All characters of s are lower case English letters.
    • +
    • s consists of lowercase English letters.
    ### Related Topics diff --git a/problems/minimum-insertions-to-balance-a-parentheses-string/README.md b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md index 3fd4fb5b2..ee880867b 100644 --- a/problems/minimum-insertions-to-balance-a-parentheses-string/README.md +++ b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md @@ -14,13 +14,15 @@

    Given a parentheses string s containing only the characters '(' and ')'. A parentheses string is balanced if:

      -
    • Any left parenthesis '(' must have a corresponding two consecutive right parenthesis '))'.
    • -
    • Left parenthesis '(' must go before the corresponding two consecutive right parenthesis '))'.
    • +
    • Any left parenthesis '(' must have a corresponding two consecutive right parenthesis '))'.
    • +
    • Left parenthesis '(' must go before the corresponding two consecutive right parenthesis '))'.
    -

    In other words, we treat '(' as openning parenthesis and '))' as closing parenthesis.

    +

    In other words, we treat '(' as an opening parenthesis and '))' as a closing parenthesis.

    -

    For example, "())", "())(())))" and "(())())))" are balanced, ")()", "()))" and "(()))" are not balanced.

    +
      +
    • For example, "())", "())(())))" and "(())())))" are balanced, ")()", "()))" and "(()))" are not balanced.
    • +

    You can insert the characters '(' and ')' at any position of the string to balance it if needed.

    @@ -51,27 +53,11 @@ Explanation: Add '(' to match the first '))', Add '))' to match the last '('. -

    Example 4:

    - -
    -Input: s = "(((((("
    -Output: 12
    -Explanation: Add 12 ')' to balance the string.
    -
    - -

    Example 5:

    - -
    -Input: s = ")))))))"
    -Output: 5
    -Explanation: Add 4 '(' at the beginning of the string and one ')' at the end. The string becomes "(((())))))))".
    -
    -

     

    Constraints:

      -
    • 1 <= s.length <= 10^5
    • +
    • 1 <= s.length <= 105
    • s consists of '(' and ')' only.
    diff --git a/problems/minimum-interval-to-include-each-query/README.md b/problems/minimum-interval-to-include-each-query/README.md index 4cfe2d11c..f9a6134b5 100644 --- a/problems/minimum-interval-to-include-each-query/README.md +++ b/problems/minimum-interval-to-include-each-query/README.md @@ -56,8 +56,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Sorting](../../tag/sorting/README.md)] [[Line Sweep](../../tag/line-sweep/README.md)] + [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/minimum-jumps-to-reach-home/README.md b/problems/minimum-jumps-to-reach-home/README.md index d9e52ef2a..5f74939af 100644 --- a/problems/minimum-jumps-to-reach-home/README.md +++ b/problems/minimum-jumps-to-reach-home/README.md @@ -62,9 +62,9 @@ ### Related Topics + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Hints
    diff --git a/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md b/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md index 486ed61bd..34b543908 100644 --- a/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md +++ b/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md @@ -30,26 +30,26 @@

     

    Example 1:

    - +
     Input: grid = [["#","#","#","#","#","#"],
                    ["#","T","#","#","#","#"],
    -               ["#",".",".","B",".","#"],
    -               ["#",".","#","#",".","#"],
    -               ["#",".",".",".","S","#"],
    -               ["#","#","#","#","#","#"]]
    +               ["#",".",".","B",".","#"],
    +               ["#",".","#","#",".","#"],
    +               ["#",".",".",".","S","#"],
    +               ["#","#","#","#","#","#"]]
     Output: 3
    -Explanation: We return only the number of times the box is pushed.
    +Explanation: We return only the number of times the box is pushed.

    Example 2:

     Input: grid = [["#","#","#","#","#","#"],
                    ["#","T","#","#","#","#"],
    -               ["#",".",".","B",".","#"],
    -               ["#","#","#","#",".","#"],
    -               ["#",".",".",".","S","#"],
    -               ["#","#","#","#","#","#"]]
    +               ["#",".",".","B",".","#"],
    +               ["#","#","#","#",".","#"],
    +               ["#",".",".",".","S","#"],
    +               ["#","#","#","#","#","#"]]
     Output: -1
     
    @@ -57,22 +57,13 @@
     Input: grid = [["#","#","#","#","#","#"],
    -               ["#","T",".",".","#","#"],
    -               ["#",".","#","B",".","#"],
    -               ["#",".",".",".",".","#"],
    -               ["#",".",".",".","S","#"],
    -               ["#","#","#","#","#","#"]]
    +               ["#","T",".",".","#","#"],
    +               ["#",".","#","B",".","#"],
    +               ["#",".",".",".",".","#"],
    +               ["#",".",".",".","S","#"],
    +               ["#","#","#","#","#","#"]]
     Output: 5
    -Explanation:  push the box down, left, left, up and up.
    -
    - -

    Example 4:

    - -
    -Input: grid = [["#","#","#","#","#","#","#"],
    -               ["#","S","#",".","B","T","#"],
    -               ["#","#","#","#","#","#","#"]]
    -Output: -1
    +Explanation: push the box down, left, left, up and up.
     

     

    diff --git a/problems/minimum-moves-to-reach-target-score/README.md b/problems/minimum-moves-to-reach-target-score/README.md new file mode 100644 index 000000000..03f9395f4 --- /dev/null +++ b/problems/minimum-moves-to-reach-target-score/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../divide-a-string-into-groups-of-size-k "Divide a String Into Groups of Size k") +                 +[Next >](../solving-questions-with-brainpower "Solving Questions With Brainpower") + +## [2139. Minimum Moves to Reach Target Score (Medium)](https://leetcode.com/problems/minimum-moves-to-reach-target-score "得到目标值的最少行动次数") + +

    You are playing a game with integers. You start with the integer 1 and you want to reach the integer target.

    + +

    In one move, you can either:

    + +
      +
    • Increment the current integer by one (i.e., x = x + 1).
    • +
    • Double the current integer (i.e., x = 2 * x).
    • +
    + +

    You can use the increment operation any number of times, however, you can only use the double operation at most maxDoubles times.

    + +

    Given the two integers target and maxDoubles, return the minimum number of moves needed to reach target starting with 1.

    + +

     

    +

    Example 1:

    + +
    +Input: target = 5, maxDoubles = 0
    +Output: 4
    +Explanation: Keep incrementing by 1 until you reach target.
    +
    + +

    Example 2:

    + +
    +Input: target = 19, maxDoubles = 2
    +Output: 7
    +Explanation: Initially, x = 1
    +Increment 3 times so x = 4
    +Double once so x = 8
    +Increment once so x = 9
    +Double again so x = 18
    +Increment once so x = 19
    +
    + +

    Example 3:

    + +
    +Input: target = 10, maxDoubles = 4
    +Output: 4
    +Explanation: Initially, x = 1
    +Increment once so x = 2
    +Double once so x = 4
    +Increment once so x = 5
    +Double again so x = 10
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= target <= 109
    • +
    • 0 <= maxDoubles <= 100
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Solve the opposite problem: start at the given score and move to 1. +
    + +
    +Hint 2 +It is better to use the move of the second type once we can to lose more scores fast. +
    diff --git a/problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses/README.md b/problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses/README.md new file mode 100644 index 000000000..8a0798f2f --- /dev/null +++ b/problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../count-common-words-with-one-occurrence "Count Common Words With One Occurrence") +                 +[Next >](../minimum-cost-homecoming-of-a-robot-in-a-grid "Minimum Cost Homecoming of a Robot in a Grid") + +## [2086. Minimum Number of Buckets Required to Collect Rainwater from Houses (Medium)](https://leetcode.com/problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses "从房屋收集雨水需要的最少水桶数") + +

    You are given a 0-indexed string street. Each character in street is either 'H' representing a house or '.' representing an empty space.

    + +

    You can place buckets on the empty spaces to collect rainwater that falls from the adjacent houses. The rainwater from a house at index i is collected if a bucket is placed at index i - 1 and/or index i + 1. A single bucket, if placed adjacent to two houses, can collect the rainwater from both houses.

    + +

    Return the minimum number of buckets needed so that for every house, there is at least one bucket collecting rainwater from it, or -1 if it is impossible.

    + +

     

    +

    Example 1:

    + +
    +Input: street = "H..H"
    +Output: 2
    +Explanation:
    +We can put buckets at index 1 and index 2.
    +"H..H" -> "HBBH" ('B' denotes where a bucket is placed).
    +The house at index 0 has a bucket to its right, and the house at index 3 has a bucket to its left.
    +Thus, for every house, there is at least one bucket collecting rainwater from it.
    +
    + +

    Example 2:

    + +
    +Input: street = ".H.H."
    +Output: 1
    +Explanation:
    +We can put a bucket at index 2.
    +".H.H." -> ".HBH." ('B' denotes where a bucket is placed).
    +The house at index 1 has a bucket to its right, and the house at index 3 has a bucket to its left.
    +Thus, for every house, there is at least one bucket collecting rainwater from it.
    +
    + +

    Example 3:

    + +
    +Input: street = ".HHH."
    +Output: -1
    +Explanation:
    +There is no empty space to place a bucket to collect the rainwater from the house at index 2.
    +Thus, it is impossible to collect the rainwater from all the houses.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= street.length <= 105
    • +
    • street[i] is either'H' or '.'.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +When is it impossible to collect the rainwater from all the houses? +
    + +
    +Hint 2 +When one or more houses do not have an empty space adjacent to it. +
    + +
    +Hint 3 +Assuming the rainwater from all previous houses is collected. If there is a house at index i and you are able to place a bucket at index i - 1 or i + 1, where should you put it? +
    + +
    +Hint 4 +It is always better to place a bucket at index i + 1 because it can collect the rainwater from the next house as well. +
    diff --git a/problems/minimum-number-of-days-to-disconnect-island/README.md b/problems/minimum-number-of-days-to-disconnect-island/README.md index 26163ef0f..2f96201d0 100644 --- a/problems/minimum-number-of-days-to-disconnect-island/README.md +++ b/problems/minimum-number-of-days-to-disconnect-island/README.md @@ -11,73 +11,47 @@ ## [1568. Minimum Number of Days to Disconnect Island (Hard)](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数") -

    Given a 2D grid consisting of 1s (land) and 0s (water).  An island is a maximal 4-directionally (horizontal or vertical) connected group of 1s.

    +

    You are given an m x n binary grid grid where 1 represents land and 0 represents water. An island is a maximal 4-directionally (horizontal or vertical) connected group of 1's.

    -

    The grid is said to be connected if we have exactly one island, otherwise is said disconnected.

    +

    The grid is said to be connected if we have exactly one island, otherwise is said disconnected.

    In one day, we are allowed to change any single land cell (1) into a water cell (0).

    -

    Return the minimum number of days to disconnect the grid.

    +

    Return the minimum number of days to disconnect the grid.

     

    Example 1:

    - -

    - +
     Input: grid = [[0,1,1,0],[0,1,1,0],[0,0,0,0]]
    +
     Output: 2
     Explanation: We need at least 2 days to get a disconnected grid.
     Change land grid[1][1] and grid[0][2] to water and get 2 disconnected island.
     

    Example 2:

    - +
     Input: grid = [[1,1]]
     Output: 2
    -Explanation: Grid of full water is also disconnected ([[1,1]] -> [[0,0]]), 0 islands.
    -
    - -

    Example 3:

    - -
    -Input: grid = [[1,0,1,0]]
    -Output: 0
    -
    - -

    Example 4:

    - -
    -Input: grid = [[1,1,0,1,1],
    -               [1,1,1,1,1],
    -               [1,1,0,1,1],
    -               [1,1,0,1,1]]
    -Output: 1
    -
    - -

    Example 5:

    - -
    -Input: grid = [[1,1,0,1,1],
    -               [1,1,1,1,1],
    -               [1,1,0,1,1],
    -               [1,1,1,1,1]]
    -Output: 2
    +Explanation: Grid of full water is also disconnected ([[1,1]] -> [[0,0]]), 0 islands.
     

     

    Constraints:

      -
    • 1 <= grid.length, grid[i].length <= 30
    • -
    • grid[i][j] is 0 or 1.
    • +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 30
    • +
    • grid[i][j] is either 0 or 1.
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Strongly Connected Component](../../tag/strongly-connected-component/README.md)] diff --git a/problems/minimum-number-of-days-to-eat-n-oranges/README.md b/problems/minimum-number-of-days-to-eat-n-oranges/README.md index 2f250b084..ef9a3d0c3 100644 --- a/problems/minimum-number-of-days-to-eat-n-oranges/README.md +++ b/problems/minimum-number-of-days-to-eat-n-oranges/README.md @@ -15,13 +15,13 @@
    • Eat one orange.
    • -
    • If the number of remaining oranges n is divisible by 2 then you can eat n / 2 oranges.
    • -
    • If the number of remaining oranges n is divisible by 3 then you can eat 2 * (n / 3) oranges.
    • +
    • If the number of remaining oranges n is divisible by 2 then you can eat n / 2 oranges.
    • +
    • If the number of remaining oranges n is divisible by 3 then you can eat 2 * (n / 3) oranges.

    You can only choose one of the actions per day.

    -

    Return the minimum number of days to eat n oranges.

    +

    Given the integer n, return the minimum number of days to eat n oranges.

     

    Example 1:

    @@ -49,20 +49,6 @@ Day 3: Eat the last orange 1 - 1 = 0. You need at least 3 days to eat the 6 oranges. -

    Example 3:

    - -
    -Input: n = 1
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: n = 56
    -Output: 6
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-number-of-days-to-make-m-bouquets/README.md b/problems/minimum-number-of-days-to-make-m-bouquets/README.md index 79478879e..23c7493b3 100644 --- a/problems/minimum-number-of-days-to-make-m-bouquets/README.md +++ b/problems/minimum-number-of-days-to-make-m-bouquets/README.md @@ -11,13 +11,13 @@ ## [1482. Minimum Number of Days to Make m Bouquets (Medium)](https://leetcode.com/problems/minimum-number-of-days-to-make-m-bouquets "制作 m 束花所需的最少天数") -

    Given an integer array bloomDay, an integer m and an integer k.

    +

    You are given an integer array bloomDay, an integer m and an integer k.

    -

    We need to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden.

    +

    You want to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden.

    -

    The garden consists of n flowers, the ith flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet.

    +

    The garden consists of n flowers, the ith flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet.

    -

    Return the minimum number of days you need to wait to be able to make m bouquets from the garden. If it is impossible to make m bouquets return -1.

    +

    Return the minimum number of days you need to wait to be able to make m bouquets from the garden. If it is impossible to make m bouquets return -1.

     

    Example 1:

    @@ -25,7 +25,7 @@
     Input: bloomDay = [1,10,3,10,2], m = 3, k = 1
     Output: 3
    -Explanation: Let's see what happened in the first three days. x means flower bloomed and _ means flower didn't bloom in the garden.
    +Explanation: Let us see what happened in the first three days. x means flower bloomed and _ means flower did not bloom in the garden.
     We need 3 bouquets each should contain 1 flower.
     After day 1: [x, _, _, _, _]   // we can only make one bouquet.
     After day 2: [x, _, _, _, x]   // we can only make two bouquets.
    @@ -46,36 +46,21 @@ After day 3: [x, _, x, _, x]   // we can make 3 bouquets. The answer is 3.
     Input: bloomDay = [7,7,7,7,12,7,7], m = 2, k = 3
     Output: 12
     Explanation: We need 2 bouquets each should have 3 flowers.
    -Here's the garden after the 7 and 12 days:
    +Here is the garden after the 7 and 12 days:
     After day 7: [x, x, x, x, _, x, x]
     We can make one bouquet of the first three flowers that bloomed. We cannot make another bouquet from the last three flowers that bloomed because they are not adjacent.
     After day 12: [x, x, x, x, x, x, x]
     It is obvious that we can make two bouquets in different ways.
     
    -

    Example 4:

    - -
    -Input: bloomDay = [1000000000,1000000000], m = 1, k = 1
    -Output: 1000000000
    -Explanation: You need to wait 1000000000 days to have a flower ready for a bouquet.
    -
    - -

    Example 5:

    - -
    -Input: bloomDay = [1,10,2,9,3,8,4,7,5,6], m = 4, k = 2
    -Output: 9
    -
    -

     

    Constraints:

    • bloomDay.length == n
    • -
    • 1 <= n <= 10^5
    • -
    • 1 <= bloomDay[i] <= 10^9
    • -
    • 1 <= m <= 10^6
    • +
    • 1 <= n <= 105
    • +
    • 1 <= bloomDay[i] <= 109
    • +
    • 1 <= m <= 106
    • 1 <= k <= n
    @@ -85,6 +70,7 @@ It is obvious that we can make two bouquets in different ways. ### Similar Questions 1. [Maximize the Confusion of an Exam](../maximize-the-confusion-of-an-exam) (Medium) + 1. [Earliest Possible Day of Full Bloom](../earliest-possible-day-of-full-bloom) (Hard) ### Hints
    diff --git a/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md b/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md index 0dcbfe47e..1dc73d265 100644 --- a/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md +++ b/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md @@ -33,22 +33,15 @@
     Input: mat = [[0]]
     Output: 0
    -Explanation: Given matrix is a zero matrix. We don't need to change it.
    +Explanation: Given matrix is a zero matrix. We do not need to change it.
     

    Example 3:

    -
    -Input: mat = [[1,1,1],[1,0,1],[0,0,0]]
    -Output: 6
    -
    - -

    Example 4:

    -
     Input: mat = [[1,0,0],[1,0,0]]
     Output: -1
    -Explanation: Given matrix can't be a zero matrix
    +Explanation: Given matrix cannot be a zero matrix.
     

     

    @@ -67,6 +60,10 @@ [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Minimum Operations to Remove Adjacent Ones in Matrix](../minimum-operations-to-remove-adjacent-ones-in-matrix) (Hard) + 1. [Remove All Ones With Row and Column Flips](../remove-all-ones-with-row-and-column-flips) (Medium) + ### Hints
    Hint 1 diff --git a/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md b/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md index d2ff2706f..48368b32a 100644 --- a/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md +++ b/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md @@ -11,24 +11,24 @@ ## [1526. Minimum Number of Increments on Subarrays to Form a Target Array (Hard)](https://leetcode.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array "形成目标数组的子数组最少增加次数") -

    Given an array of positive integers target and an array initial of same size with all zeros.

    +

    You are given an integer array target. You have an integer array initial of the same size as target with all elements initially zeros.

    -

    Return the minimum number of operations to form a target array from initial if you are allowed to do the following operation:

    +

    In one operation you can choose any subarray from initial and increment each value by one.

    + +

    Return the minimum number of operations to form a target array from initial.

    + +

    The test cases are generated so that the answer fits in a 32-bit integer.

    -
      -
    • Choose any subarray from initial and increment each value by one.
    • -
    -The answer is guaranteed to fit within the range of a 32-bit signed integer.

     

    Example 1:

     Input: target = [1,2,3,2,1]
     Output: 3
    -Explanation: We need at least 3 operations to form the target array from the initial array.
    -[0,0,0,0,0] increment 1 from index 0 to 4 (inclusive).
    -[1,1,1,1,1] increment 1 from index 1 to 3 (inclusive).
    -[1,2,2,2,1] increment 1 at index 2.
    +Explanation: We need at least 3 operations to form the target array from the initial array.
    +[0,0,0,0,0] increment 1 from index 0 to 4 (inclusive).
    +[1,1,1,1,1] increment 1 from index 1 to 3 (inclusive).
    +[1,2,2,2,1] increment 1 at index 2.
     [1,2,3,2,1] target array is formed.
     
    @@ -37,7 +37,7 @@ The answer is guaranteed to fit within the range of a 32-bit signed integer.
     Input: target = [3,1,1,2]
     Output: 4
    -Explanation: (initial)[0,0,0,0] -> [1,1,1,1] -> [1,1,1,2] -> [2,1,1,2] -> [3,1,1,2] (target).
    +Explanation: [0,0,0,0] -> [1,1,1,1] -> [1,1,1,2] -> [2,1,1,2] -> [3,1,1,2]
     

    Example 3:

    @@ -45,23 +45,15 @@ The answer is guaranteed to fit within the range of a 32-bit signed integer.
     Input: target = [3,1,5,4,2]
     Output: 7
    -Explanation: (initial)[0,0,0,0,0] -> [1,1,1,1,1] -> [2,1,1,1,1] -> [3,1,1,1,1] 
    -                                  -> [3,1,2,2,2] -> [3,1,3,3,2] -> [3,1,4,4,2] -> [3,1,5,4,2] (target).
    -
    - -

    Example 4:

    - -
    -Input: target = [1,1,1,1]
    -Output: 1
    +Explanation: [0,0,0,0,0] -> [1,1,1,1,1] -> [2,1,1,1,1] -> [3,1,1,1,1] -> [3,1,2,2,2] -> [3,1,3,3,2] -> [3,1,4,4,2] -> [3,1,5,4,2].
     

     

    Constraints:

      -
    • 1 <= target.length <= 10^5
    • -
    • 1 <= target[i] <= 10^5
    • +
    • 1 <= target.length <= 105
    • +
    • 1 <= target[i] <= 105
    ### Related Topics diff --git a/problems/minimum-number-of-lines-to-cover-points/README.md b/problems/minimum-number-of-lines-to-cover-points/README.md new file mode 100644 index 000000000..582bba6e1 --- /dev/null +++ b/problems/minimum-number-of-lines-to-cover-points/README.md @@ -0,0 +1,45 @@ + + + + + + + +[< Previous](../maximum-good-people-based-on-statements "Maximum Good People Based on Statements") +                 +[Next >](../the-number-of-passengers-in-each-bus-ii "The Number of Passengers in Each Bus II") + +## [2152. Minimum Number of Lines to Cover Points (Medium)](https://leetcode.com/problems/minimum-number-of-lines-to-cover-points "") + + + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] + +### Hints +
    +Hint 1 +What is the highest possible answer for a set of n points? +
    + +
    +Hint 2 +The highest possible answer is n / 2 (rounded up). This is because you can cover at least two points with a line, and if n is odd, you need to add one extra line to cover the last point. +
    + +
    +Hint 3 +Suppose you have a line covering two points, how can you quickly check if a third point is also covered by that line? +
    + +
    +Hint 4 +Calculate the slope from the first point to the second point. If the slope from the first point to the third point is the same, then it is also covered by that line. +
    diff --git a/problems/minimum-number-of-operations-to-make-string-sorted/README.md b/problems/minimum-number-of-operations-to-make-string-sorted/README.md index 7aa3e5a7d..60c4203fb 100644 --- a/problems/minimum-number-of-operations-to-make-string-sorted/README.md +++ b/problems/minimum-number-of-operations-to-make-string-sorted/README.md @@ -46,19 +46,6 @@ Operation 1: i=3, j=4. Swap s[2] and s[4] to get s="aaaab", then rever Operation 2: i=4, j=4. Swap s[3] and s[4] to get s="aaaab", then reverse the substring starting at 4. Now, s="aaaab". -

    Example 3:

    - -
    -Input: s = "cdbea"
    -Output: 63
    - -

    Example 4:

    - -
    -Input: s = "leetcodeleetcodeleetcode"
    -Output: 982157772
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md b/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md index 3f34200f4..42d3cc5e1 100644 --- a/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md +++ b/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md @@ -50,6 +50,9 @@ [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Minimum Cost to Move Chips to The Same Position](../minimum-cost-to-move-chips-to-the-same-position) (Easy) + ### Hints
    Hint 1 diff --git a/problems/minimum-number-of-refueling-stops/README.md b/problems/minimum-number-of-refueling-stops/README.md index c990e21b1..1cc8c8b1f 100644 --- a/problems/minimum-number-of-refueling-stops/README.md +++ b/problems/minimum-number-of-refueling-stops/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../advantage-shuffle "Advantage Shuffle") @@ -61,7 +61,7 @@ We made 2 refueling stops along the way, so we return 2. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/minimum-number-of-removals-to-make-mountain-array/README.md b/problems/minimum-number-of-removals-to-make-mountain-array/README.md index 7f2ca1d02..bfc45b56b 100644 --- a/problems/minimum-number-of-removals-to-make-mountain-array/README.md +++ b/problems/minimum-number-of-removals-to-make-mountain-array/README.md @@ -42,20 +42,6 @@ Explanation: One solution is to remove the elements at indices 0, 1, and 5, making the array nums = [1,5,6,3,1]. -

    Example 3:

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

    Example 4:

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

     

    Constraints:

    diff --git a/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md b/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md index 5038dbee9..22618114e 100644 --- a/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md +++ b/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md @@ -11,11 +11,11 @@ ## [1347. Minimum Number of Steps to Make Two Strings Anagram (Medium)](https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram "制造字母异位词的最小步骤数") -

    Given two equal-size strings s and t. In one step you can choose any character of t and replace it with another character.

    +

    You are given two strings of the same length s and t. In one step you can choose any character of t and replace it with another character.

    -

    Return the minimum number of steps to make t an anagram of s.

    +

    Return the minimum number of steps to make t an anagram of s.

    -

    An Anagram of a string is a string that contains the same characters with a different (or the same) ordering.

    +

    An Anagram of a string is a string that contains the same characters with a different (or the same) ordering.

     

    Example 1:

    @@ -42,27 +42,13 @@ Explanation: "anagram" and "mangaar" are anagrams. -

    Example 4:

    - -
    -Input: s = "xxyyzz", t = "xxyyzz"
    -Output: 0
    -
    - -

    Example 5:

    - -
    -Input: s = "friend", t = "family"
    -Output: 4
    -
    -

     

    Constraints:

      -
    • 1 <= s.length <= 50000
    • +
    • 1 <= s.length <= 5 * 104
    • s.length == t.length
    • -
    • s and t contain lower-case English letters only.
    • +
    • s and t consist of lowercase English letters only.
    ### Related Topics diff --git a/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md b/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md index 179da70b9..51d236eaa 100644 --- a/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md +++ b/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md @@ -51,8 +51,8 @@ The string is now alternating. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md b/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md index 3f1157121..c44128242 100644 --- a/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md +++ b/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md @@ -42,27 +42,6 @@ Opening Only the second tap will water the whole garden [0,5] Explanation: Even if you activate all the four taps you cannot water the whole garden. -

    Example 3:

    - -
    -Input: n = 7, ranges = [1,2,1,0,2,1,0,1]
    -Output: 3
    -
    - -

    Example 4:

    - -
    -Input: n = 8, ranges = [4,0,0,0,0,0,0,0,4]
    -Output: 2
    -
    - -

    Example 5:

    - -
    -Input: n = 8, ranges = [4,0,0,0,4,0,0,0,4]
    -Output: 1
    -
    -

     

    Constraints:

    @@ -73,9 +52,9 @@ Opening Only the second tap will water the whole garden [0,5] ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md b/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md index 9fcfb0f7e..78c2033c8 100644 --- a/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md +++ b/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md @@ -11,13 +11,13 @@ ## [1558. Minimum Numbers of Function Calls to Make Target Array (Medium)](https://leetcode.com/problems/minimum-numbers-of-function-calls-to-make-target-array "得到目标数组的最少函数调用次数") -

    +

    You are given an integer array nums. You have an integer array arr of the same length with all values set to 0 initially. You also have the following modify function:

    + +

    You want to use the modify function to covert arr to nums using the minimum number of calls.

    -

    Your task is to form an integer array nums from an initial array of zeros arr that is the same size as nums.

    +

    Return the minimum number of function calls to make nums from arr.

    -

    Return the minimum number of function calls to make nums from arr.

    - -

    The answer is guaranteed to fit in a 32-bit signed integer.

    +

    The test cases are generated so that the answer fits in a 32-bit signed integer.

     

    Example 1:

    @@ -49,26 +49,12 @@ Total of operations: 2 + 1 = 3. Explanation: (initial)[0,0,0] -> [1,0,0] -> [1,0,1] -> [2,0,2] -> [2,1,2] -> [4,2,4] -> [4,2,5](nums). -

    Example 4:

    - -
    -Input: nums = [3,2,2,4]
    -Output: 7
    -
    - -

    Example 5:

    - -
    -Input: nums = [2,4,8,16]
    -Output: 8
    -
    -

     

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • 0 <= nums[i] <= 10^9
    • +
    • 1 <= nums.length <= 105
    • +
    • 0 <= nums[i] <= 109
    ### Related Topics diff --git a/problems/minimum-one-bit-operations-to-make-integers-zero/README.md b/problems/minimum-one-bit-operations-to-make-integers-zero/README.md index 6daae4a00..8051fc22e 100644 --- a/problems/minimum-one-bit-operations-to-make-integers-zero/README.md +++ b/problems/minimum-one-bit-operations-to-make-integers-zero/README.md @@ -23,45 +23,24 @@

     

    Example 1:

    -
    -Input: n = 0
    -Output: 0
    -
    - -

    Example 2:

    -
     Input: n = 3
     Output: 2
     Explanation: The binary representation of 3 is "11".
    -"11" -> "01" with the 2nd operation since the 0th bit is 1.
    -"01" -> "00" with the 1st operation.
    +"11" -> "01" with the 2nd operation since the 0th bit is 1.
    +"01" -> "00" with the 1st operation.
     
    -

    Example 3:

    +

    Example 2:

     Input: n = 6
     Output: 4
     Explanation: The binary representation of 6 is "110".
    -"110" -> "010" with the 2nd operation since the 1st bit is 1 and 0th through 0th bits are 0.
    -"010" -> "011" with the 1st operation.
    -"011" -> "001" with the 2nd operation since the 0th bit is 1.
    -"001" -> "000" with the 1st operation.
    -
    - -

    Example 4:

    - -
    -Input: n = 9
    -Output: 14
    -
    - -

    Example 5:

    - -
    -Input: n = 333
    -Output: 393
    +"110" -> "010" with the 2nd operation since the 1st bit is 1 and 0th through 0th bits are 0.
    +"010" -> "011" with the 1st operation.
    +"011" -> "001" with the 2nd operation since the 0th bit is 1.
    +"001" -> "000" with the 1st operation.
     

     

    @@ -72,9 +51,12 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Memoization](../../tag/memoization/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Similar Questions + 1. [Minimum Number of Operations to Make Array Continuous](../minimum-number-of-operations-to-make-array-continuous) (Hard) ### Hints
    diff --git a/problems/minimum-operations-to-convert-number/README.md b/problems/minimum-operations-to-convert-number/README.md index 941b3a389..dbf649ccb 100644 --- a/problems/minimum-operations-to-convert-number/README.md +++ b/problems/minimum-operations-to-convert-number/README.md @@ -11,7 +11,7 @@ ## [2059. Minimum Operations to Convert Number (Medium)](https://leetcode.com/problems/minimum-operations-to-convert-number "转化数字的最小运算数") -

    You are given a 0-indexed integer array nums containing distinct numbers, an integer start, and an integer goal. There is an integer x that is initially set to start, and you want to perform operations on x such that it is converted to goal. You can perform the following operation repeatedly on the number x:

    +

    You are given a 0-indexed integer array nums containing distinct numbers, an integer start, and an integer goal. There is an integer x that is initially set to start, and you want to perform operations on x such that it is converted to goal. You can perform the following operation repeatedly on the number x:

    If 0 <= x <= 1000, then for any index i in the array (0 <= i < nums.length), you can set x to any of the following:

    @@ -28,56 +28,31 @@

     

    Example 1:

    -
    -Input: nums = [1,3], start = 6, goal = 4
    -Output: 2
    -Explanation:
    -We can go from 6 → 7 → 4 with the following 2 operations.
    -- 6 ^ 1 = 7
    -- 7 ^ 3 = 4
    -
    - -

    Example 2:

    -
     Input: nums = [2,4,12], start = 2, goal = 12
     Output: 2
    -Explanation:
    -We can go from 2 → 14 → 12 with the following 2 operations.
    +Explanation: We can go from 2 → 14 → 12 with the following 2 operations.
     - 2 + 12 = 14
     - 14 - 2 = 12
     
    -

    Example 3:

    +

    Example 2:

     Input: nums = [3,5,7], start = 0, goal = -4
     Output: 2
    -Explanation:
    -We can go from 0 → 3 → -4 with the following 2 operations. 
    +Explanation: We can go from 0 → 3 → -4 with the following 2 operations. 
     - 0 + 3 = 3
     - 3 - 7 = -4
     Note that the last operation sets x out of the range 0 <= x <= 1000, which is valid.
     
    -

    Example 4:

    +

    Example 3:

     Input: nums = [2,8,16], start = 0, goal = 1
     Output: -1
    -Explanation:
    -There is no way to convert 0 into 1.
    - -

    Example 5:

    - -
    -Input: nums = [1], start = 0, goal = 3
    -Output: 3
    -Explanation: 
    -We can go from 0 → 1 → 2 → 3 with the following 3 operations. 
    -- 0 + 1 = 1 
    -- 1 + 1 = 2
    -- 2 + 1 = 3
    +Explanation: There is no way to convert 0 into 1.
     

     

    diff --git a/problems/minimum-operations-to-make-the-array-alternating/README.md b/problems/minimum-operations-to-make-the-array-alternating/README.md new file mode 100644 index 000000000..8b1fec07d --- /dev/null +++ b/problems/minimum-operations-to-make-the-array-alternating/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../count-operations-to-obtain-zero "Count Operations to Obtain Zero") +                 +[Next >](../removing-minimum-number-of-magic-beans "Removing Minimum Number of Magic Beans") + +## [2170. Minimum Operations to Make the Array Alternating (Medium)](https://leetcode.com/problems/minimum-operations-to-make-the-array-alternating "使数组变成交替数组的最少操作数") + +

    You are given a 0-indexed array nums consisting of n positive integers.

    + +

    The array nums is called alternating if:

    + +
      +
    • nums[i - 2] == nums[i], where 2 <= i <= n - 1.
    • +
    • nums[i - 1] != nums[i], where 1 <= i <= n - 1.
    • +
    + +

    In one operation, you can choose an index i and change nums[i] into any positive integer.

    + +

    Return the minimum number of operations required to make the array alternating.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [3,1,3,2,4,3]
    +Output: 3
    +Explanation:
    +One way to make the array alternating is by converting it to [3,1,3,1,3,1].
    +The number of operations required in this case is 3.
    +It can be proven that it is not possible to make the array alternating in less than 3 operations. 
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,2,2,2,2]
    +Output: 2
    +Explanation:
    +One way to make the array alternating is by converting it to [1,2,1,2,1].
    +The number of operations required in this case is 2.
    +Note that the array cannot be converted to [2,2,2,2,2] because in this case nums[0] == nums[1] which violates the conditions of an alternating array.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 105
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Hints +
    +Hint 1 +Count the frequency of each element in odd positions in the array. Do the same for elements in even positions. +
    + +
    +Hint 2 +To minimize the number of operations we need to maximize the number of elements we keep from the original array. +
    + +
    +Hint 3 +What are the possible combinations of elements we can choose from odd indices and even indices so that the number of unchanged elements is maximized? +
    diff --git a/problems/minimum-operations-to-make-the-array-k-increasing/README.md b/problems/minimum-operations-to-make-the-array-k-increasing/README.md new file mode 100644 index 000000000..3ecfaec2b --- /dev/null +++ b/problems/minimum-operations-to-make-the-array-k-increasing/README.md @@ -0,0 +1,100 @@ + + + + + + + +[< Previous](../number-of-smooth-descent-periods-of-a-stock "Number of Smooth Descent Periods of a Stock") +                 +[Next >](../the-airport-with-the-most-traffic "The Airport With the Most Traffic") + +## [2111. Minimum Operations to Make the Array K-Increasing (Hard)](https://leetcode.com/problems/minimum-operations-to-make-the-array-k-increasing "使数组 K 递增的最少操作次数") + +

    You are given a 0-indexed array arr consisting of n positive integers, and a positive integer k.

    + +

    The array arr is called K-increasing if arr[i-k] <= arr[i] holds for every index i, where k <= i <= n-1.

    + +
      +
    • For example, arr = [4, 1, 5, 2, 6, 2] is K-increasing for k = 2 because: +
        +
      • arr[0] <= arr[2] (4 <= 5)
      • +
      • arr[1] <= arr[3] (1 <= 2)
      • +
      • arr[2] <= arr[4] (5 <= 6)
      • +
      • arr[3] <= arr[5] (2 <= 2)
      • +
      +
    • +
    • However, the same arr is not K-increasing for k = 1 (because arr[0] > arr[1]) or k = 3 (because arr[0] > arr[3]).
    • +
    + +

    In one operation, you can choose an index i and change arr[i] into any positive integer.

    + +

    Return the minimum number of operations required to make the array K-increasing for the given k.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [5,4,3,2,1], k = 1
    +Output: 4
    +Explanation:
    +For k = 1, the resultant array has to be non-decreasing.
    +Some of the K-increasing arrays that can be formed are [5,6,7,8,9], [1,1,1,1,1], [2,2,3,4,4]. All of them require 4 operations.
    +It is suboptimal to change the array to, for example, [6,7,8,9,10] because it would take 5 operations.
    +It can be shown that we cannot make the array K-increasing in less than 4 operations.
    +
    + +

    Example 2:

    + +
    +Input: arr = [4,1,5,2,6,2], k = 2
    +Output: 0
    +Explanation:
    +This is the same example as the one in the problem description.
    +Here, for every index i where 2 <= i <= 5, arr[i-2] <= arr[i].
    +Since the given array is already K-increasing, we do not need to perform any operations.
    + +

    Example 3:

    + +
    +Input: arr = [4,1,5,2,6,2], k = 3
    +Output: 2
    +Explanation:
    +Indices 3 and 5 are the only ones not satisfying arr[i-3] <= arr[i] for 3 <= i <= 5.
    +One of the ways we can make the array K-increasing is by changing arr[3] to 4 and arr[5] to 5.
    +The array will now be [4,1,5,4,6,5].
    +Note that there can be other ways to make the array K-increasing, but none of them require less than 2 operations.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 105
    • +
    • 1 <= arr[i], k <= arr.length
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Can we divide the array into non-overlapping subsequences and simplify the problem? +
    + +
    +Hint 2 +In the final array, arr[i-k] ≤ arr[i] should hold. We can use this to divide the array into at most k non-overlapping sequences, where arr[i] will belong to the (i%k)th sequence. +
    + +
    +Hint 3 +Now our problem boils down to performing the minimum operations on each sequence such that it becomes non-decreasing. Our answer will be the sum of operations on each sequence. +
    + +
    +Hint 4 +Which indices of a sequence should we not change in order to count the minimum operations? Can finding the longest non-decreasing subsequence of the sequence help? +
    diff --git a/problems/minimum-operations-to-remove-adjacent-ones-in-matrix/README.md b/problems/minimum-operations-to-remove-adjacent-ones-in-matrix/README.md new file mode 100644 index 000000000..1d0824208 --- /dev/null +++ b/problems/minimum-operations-to-remove-adjacent-ones-in-matrix/README.md @@ -0,0 +1,40 @@ + + + + + + + +[< Previous](../recover-the-original-array "Recover the Original Array") +                 +[Next >](../check-if-all-as-appears-before-all-bs "Check if All A's Appears Before All B's") + +## [2123. Minimum Operations to Remove Adjacent Ones in Matrix (Hard)](https://leetcode.com/problems/minimum-operations-to-remove-adjacent-ones-in-matrix "") + + + +### Related Topics + [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Consider each cell containing a 1 as a vertex whose neighbors are the cells 4-directionally connected to it. The grid then becomes a bipartite graph. +
    + +
    +Hint 2 +You want to find the smallest set of vertices such that every edge in the graph has an endpoint in this set. If you remove every vertex in this set from the graph, then all the 1’s will be disconnected. Are there any well-known algorithms for finding this set? +
    + +
    +Hint 3 +This set of vertices is called a minimum vertex cover. You can find the size of a minimum vertex cover by finding the size of a maximum matching (Konig’s theorem). +
    + +
    +Hint 4 +There are well-known algorithms such as Kuhn’s algorithm and Hopcroft-Karp-Karzanov algorithm which can find a maximum matching in a bipartite graph quickly. +
    diff --git a/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md b/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md index 6c894f63b..2bf5130bc 100644 --- a/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md +++ b/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-submatrices-with-all-ones "Count Submatrices With All Ones") @@ -11,11 +11,9 @@ ## [1505. Minimum Possible Integer After at Most K Adjacent Swaps On Digits (Hard)](https://leetcode.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "最多 K 次交换相邻数位后得到的最小整数") -

    Given a string num representing the digits of a very large integer and an integer k.

    +

    You are given a string num representing the digits of a very large integer and an integer k. You are allowed to swap any two adjacent digits of the integer at most k times.

    -

    You are allowed to swap any two adjacent digits of the integer at most k times.

    - -

    Return the minimum integer you can obtain also as a string.

    +

    Return the minimum integer you can obtain also as a string.

     

    Example 1:

    @@ -42,34 +40,20 @@ Explanation: We can keep the number without any swaps. -

    Example 4:

    - -
    -Input: num = "22", k = 22
    -Output: "22"
    -
    - -

    Example 5:

    - -
    -Input: num = "9438957234785635408", k = 23
    -Output: "0345989723478563548"
    -
    -

     

    Constraints:

      -
    • 1 <= num.length <= 30000
    • -
    • num contains digits only and doesn't have leading zeros.
    • -
    • 1 <= k <= 10^9
    • +
    • 1 <= num.length <= 3 * 104
    • +
    • num consists of only digits and does not contain leading zeros.
    • +
    • 1 <= k <= 104
    ### Related Topics - [[String](../../tag/string/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/minimum-remove-to-make-valid-parentheses/README.md b/problems/minimum-remove-to-make-valid-parentheses/README.md index 370877ada..3dc52b55e 100644 --- a/problems/minimum-remove-to-make-valid-parentheses/README.md +++ b/problems/minimum-remove-to-make-valid-parentheses/README.md @@ -47,13 +47,6 @@ Explanation: An empty string is also valid. -

    Example 4:

    - -
    -Input: s = "(a(b(c)d)"
    -Output: "a(b(c)d)"
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md b/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md index 0e88486e6..788e77637 100644 --- a/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md +++ b/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md @@ -72,6 +72,9 @@ You can skip the first and third rest to arrive in ((7/2 + 0) + (3/2 + 0) [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Minimum Speed to Arrive on Time](../minimum-speed-to-arrive-on-time) (Medium) + ### Hints
    Hint 1 diff --git a/problems/minimum-space-wasted-from-packaging/README.md b/problems/minimum-space-wasted-from-packaging/README.md index a012e8bca..5dc48480a 100644 --- a/problems/minimum-space-wasted-from-packaging/README.md +++ b/problems/minimum-space-wasted-from-packaging/README.md @@ -68,8 +68,8 @@ The total waste is (5-3) + (5-5) + (10-8) + (10-10) + (14-11) + (14-12) = 9. ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Prefix Sum](../../tag/prefix-sum/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/minimum-subsequence-in-non-increasing-order/README.md b/problems/minimum-subsequence-in-non-increasing-order/README.md index af2af0779..d9e699479 100644 --- a/problems/minimum-subsequence-in-non-increasing-order/README.md +++ b/problems/minimum-subsequence-in-non-increasing-order/README.md @@ -50,8 +50,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/minimum-suffix-flips/README.md b/problems/minimum-suffix-flips/README.md new file mode 100644 index 000000000..2208589ce --- /dev/null +++ b/problems/minimum-suffix-flips/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../shuffle-string "Shuffle String") +                 +[Next >](../number-of-good-leaf-nodes-pairs "Number of Good Leaf Nodes Pairs") + +## [1529. Minimum Suffix Flips (Medium)](https://leetcode.com/problems/minimum-suffix-flips "最少的后缀翻转次数") + +

    You are given a 0-indexed binary string target of length n. You have another binary string s of length n that is initially set to all zeros. You want to make s equal to target.

    + +

    In one operation, you can pick an index i where 0 <= i < n and flip all bits in the inclusive range [i, n - 1]. Flip means changing '0' to '1' and '1' to '0'.

    + +

    Return the minimum number of operations needed to make s equal to target.

    + +

     

    +

    Example 1:

    + +
    +Input: target = "10111"
    +Output: 3
    +Explanation: Initially, s = "00000".
    +Choose index i = 2: "00000" -> "00111"
    +Choose index i = 0: "00111" -> "11000"
    +Choose index i = 1: "11000" -> "10111"
    +We need at least 3 flip operations to form target.
    +
    + +

    Example 2:

    + +
    +Input: target = "101"
    +Output: 3
    +Explanation: Initially, s = "000".
    +Choose index i = 0: "000" -> "111"
    +Choose index i = 1: "111" -> "100"
    +Choose index i = 2: "100" -> "101"
    +We need at least 3 flip operations to form target.
    +
    + +

    Example 3:

    + +
    +Input: target = "00000"
    +Output: 0
    +Explanation: We do not need any operations since the initial s already equals target.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == target.length
    • +
    • 1 <= n <= 105
    • +
    • target[i] is either '0' or '1'.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Consider a strategy where the choice of bulb with number i is increasing. In such a strategy, you no longer need to worry about bulbs that have been set to the left. +
    diff --git a/problems/minimum-sum-of-four-digit-number-after-splitting-digits/README.md b/problems/minimum-sum-of-four-digit-number-after-splitting-digits/README.md new file mode 100644 index 000000000..a961edf68 --- /dev/null +++ b/problems/minimum-sum-of-four-digit-number-after-splitting-digits/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../order-two-columns-independently "Order Two Columns Independently") +                 +[Next >](../partition-array-according-to-given-pivot "Partition Array According to Given Pivot") + +## [2160. Minimum Sum of Four Digit Number After Splitting Digits (Easy)](https://leetcode.com/problems/minimum-sum-of-four-digit-number-after-splitting-digits "拆分数位后四位数字的最小和") + +

    You are given a positive integer num consisting of exactly four digits. Split num into two new integers new1 and new2 by using the digits found in num. Leading zeros are allowed in new1 and new2, and all the digits found in num must be used.

    + +
      +
    • For example, given num = 2932, you have the following digits: two 2's, one 9 and one 3. Some of the possible pairs [new1, new2] are [22, 93], [23, 92], [223, 9] and [2, 329].
    • +
    + +

    Return the minimum possible sum of new1 and new2.

    + +

     

    +

    Example 1:

    + +
    +Input: num = 2932
    +Output: 52
    +Explanation: Some possible pairs [new1, new2] are [29, 23], [223, 9], etc.
    +The minimum sum can be obtained by the pair [29, 23]: 29 + 23 = 52.
    +
    + +

    Example 2:

    + +
    +Input: num = 4009
    +Output: 13
    +Explanation: Some possible pairs [new1, new2] are [0, 49], [490, 0], etc. 
    +The minimum sum can be obtained by the pair [4, 9]: 4 + 9 = 13.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1000 <= num <= 9999
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Notice that the most optimal way to obtain the minimum possible sum using 4 digits is by summing up two 2-digit numbers. +
    + +
    +Hint 2 +We can use the two smallest digits out of the four as the digits found in the tens place respectively. +
    + +
    +Hint 3 +Similarly, we use the final 2 larger digits as the digits found in the ones place. +
    diff --git a/problems/minimum-swaps-to-group-all-1s-together-ii/README.md b/problems/minimum-swaps-to-group-all-1s-together-ii/README.md new file mode 100644 index 000000000..f254b9dd9 --- /dev/null +++ b/problems/minimum-swaps-to-group-all-1s-together-ii/README.md @@ -0,0 +1,91 @@ + + + + + + + +[< Previous](../check-if-every-row-and-column-contains-all-numbers "Check if Every Row and Column Contains All Numbers") +                 +[Next >](../count-words-obtained-after-adding-a-letter "Count Words Obtained After Adding a Letter") + +## [2134. Minimum Swaps to Group All 1's Together II (Medium)](https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii "最少交换次数来组合所有的 1 II") + +

    A swap is defined as taking two distinct positions in an array and swapping the values in them.

    + +

    A circular array is defined as an array where we consider the first element and the last element to be adjacent.

    + +

    Given a binary circular array nums, return the minimum number of swaps required to group all 1's present in the array together at any location.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [0,1,0,1,1,0,0]
    +Output: 1
    +Explanation: Here are a few of the ways to group all the 1's together:
    +[0,0,1,1,1,0,0] using 1 swap.
    +[0,1,1,1,0,0,0] using 1 swap.
    +[1,1,0,0,0,0,1] using 2 swaps (using the circular property of the array).
    +There is no way to group all 1's together with 0 swaps.
    +Thus, the minimum number of swaps required is 1.
    +
    + +

    Example 2:

    + +
    +Input: nums = [0,1,1,1,0,0,1,1,0]
    +Output: 2
    +Explanation: Here are a few of the ways to group all the 1's together:
    +[1,1,1,0,0,0,0,1,1] using 2 swaps (using the circular property of the array).
    +[1,1,1,1,1,0,0,0,0] using 2 swaps.
    +There is no way to group all 1's together with 0 or 1 swaps.
    +Thus, the minimum number of swaps required is 2.
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,1,0,0,1]
    +Output: 0
    +Explanation: All the 1's are already grouped together due to the circular property of the array.
    +Thus, the minimum number of swaps required is 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • nums[i] is either 0 or 1.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
    +Hint 1 +Notice that the number of 1’s to be grouped together is fixed. It is the number of 1's the whole array has. +
    + +
    +Hint 2 +Call this number total. We should then check for every subarray of size total (possibly wrapped around), how many swaps are required to have the subarray be all 1’s. +
    + +
    +Hint 3 +The number of swaps required is the number of 0’s in the subarray. +
    + +
    +Hint 4 +To eliminate the circular property of the array, we can append the original array to itself. Then, we check each subarray of length total. +
    + +
    +Hint 5 +How do we avoid recounting the number of 0’s in the subarray each time? The Sliding Window technique can help. +
    diff --git a/problems/minimum-swaps-to-make-sequences-increasing/README.md b/problems/minimum-swaps-to-make-sequences-increasing/README.md index 40e16413e..81ce68ef8 100644 --- a/problems/minimum-swaps-to-make-sequences-increasing/README.md +++ b/problems/minimum-swaps-to-make-sequences-increasing/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../similar-rgb-color "Similar RGB Color") @@ -52,3 +52,6 @@ which are both strictly increasing. ### Related Topics [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Similar Questions + 1. [Minimum Operations to Make the Array K-Increasing](../minimum-operations-to-make-the-array-k-increasing) (Hard) diff --git a/problems/minimum-swaps-to-make-strings-equal/README.md b/problems/minimum-swaps-to-make-strings-equal/README.md index c80adf70c..efa4ee8ed 100644 --- a/problems/minimum-swaps-to-make-strings-equal/README.md +++ b/problems/minimum-swaps-to-make-strings-equal/README.md @@ -21,18 +21,18 @@
     Input: s1 = "xx", s2 = "yy"
     Output: 1
    -Explanation: 
    -Swap s1[0] and s2[1], s1 = "yx", s2 = "yx".
    +Explanation: Swap s1[0] and s2[1], s1 = "yx", s2 = "yx". +

    Example 2:

     Input: s1 = "xy", s2 = "yx"
     Output: 2
    -Explanation: 
    -Swap s1[0] and s2[0], s1 = "yy", s2 = "xx".
    +Explanation: Swap s1[0] and s2[0], s1 = "yy", s2 = "xx".
     Swap s1[0] and s2[1], s1 = "xy", s2 = "xy".
    -Note that you can't swap s1[0] and s1[1] to make s1 equal to "yx", cause we can only swap chars in different strings.
    +Note that you cannot swap s1[0] and s1[1] to make s1 equal to "yx", cause we can only swap chars in different strings. +

    Example 3:

    @@ -41,13 +41,6 @@ Note that you can't swap s1[0] and s1[1] to make s1 equal to "yx", Output: -1 -

    Example 4:

    - -
    -Input: s1 = "xxyyxyxyxx", s2 = "xyyxyxxxyx"
    -Output: 4
    -
    -

     

    Constraints:

    @@ -57,9 +50,12 @@ Note that you can't swap s1[0] and s1[1] to make s1 equal to "yx", ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Similar Questions + 1. [Determine if Two Strings Are Close](../determine-if-two-strings-are-close) (Medium) ### Hints
    diff --git a/problems/minimum-time-for-k-virus-variants-to-spread/README.md b/problems/minimum-time-for-k-virus-variants-to-spread/README.md index 3b5cdd475..c288759ed 100644 --- a/problems/minimum-time-for-k-virus-variants-to-spread/README.md +++ b/problems/minimum-time-for-k-virus-variants-to-spread/README.md @@ -14,10 +14,10 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Geometry](../../tag/geometry/README.md)] [[Enumeration](../../tag/enumeration/README.md)] ### Hints diff --git a/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md b/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md index 72ac218db..7572aba8c 100644 --- a/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md +++ b/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md @@ -52,10 +52,10 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/minimum-time-to-make-rope-colorful/README.md b/problems/minimum-time-to-make-rope-colorful/README.md new file mode 100644 index 000000000..0bbeb08a5 --- /dev/null +++ b/problems/minimum-time-to-make-rope-colorful/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "Number of Ways Where Square of Number Is Equal to Product of Two Numbers") +                 +[Next >](../remove-max-number-of-edges-to-keep-graph-fully-traversable "Remove Max Number of Edges to Keep Graph Fully Traversable") + +## [1578. Minimum Time to Make Rope Colorful (Medium)](https://leetcode.com/problems/minimum-time-to-make-rope-colorful "使绳子变成彩色的最短时间") + +

    Alice has n balloons arranged on a rope. You are given a 0-indexed string colors where colors[i] is the color of the ith balloon.

    + +

    Alice wants the rope to be colorful. She does not want two consecutive balloons to be of the same color, so she asks Bob for help. Bob can remove some balloons from the rope to make it colorful. You are given a 0-indexed integer array neededTime where neededTime[i] is the time (in seconds) that Bob needs to remove the ith balloon from the rope.

    + +

    Return the minimum time Bob needs to make the rope colorful.

    + +

     

    +

    Example 1:

    + +
    +Input: colors = "abaac", neededTime = [1,2,3,4,5]
    +Output: 3
    +Explanation: In the above image, 'a' is blue, 'b' is red, and 'c' is green.
    +Bob can remove the blue balloon at index 2. This takes 3 seconds.
    +There are no longer two consecutive balloons of the same color. Total time = 3.
    + +

    Example 2:

    + +
    +Input: colors = "abc", neededTime = [1,2,3]
    +Output: 0
    +Explanation: The rope is already colorful. Bob does not need to remove any balloons from the rope.
    +
    + +

    Example 3:

    + +
    +Input: colors = "aabaa", neededTime = [1,2,3,4,1]
    +Output: 2
    +Explanation: Bob will remove the ballons at indices 0 and 4. Each ballon takes 1 second to remove.
    +There are no longer two consecutive balloons of the same color. Total time = 1 + 1 = 2.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == colors.length == neededTime.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= neededTime[i] <= 104
    • +
    • colors contains only lowercase English letters.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Maintain the running sum and max value for repeated letters. +
    diff --git a/problems/minimum-time-to-remove-all-cars-containing-illegal-goods/README.md b/problems/minimum-time-to-remove-all-cars-containing-illegal-goods/README.md new file mode 100644 index 000000000..2d0a1ba6c --- /dev/null +++ b/problems/minimum-time-to-remove-all-cars-containing-illegal-goods/README.md @@ -0,0 +1,97 @@ + + + + + + + +[< Previous](../design-bitset "Design Bitset") +                 +[Next >](../unique-substrings-with-equal-digit-frequency "Unique Substrings With Equal Digit Frequency") + +## [2167. Minimum Time to Remove All Cars Containing Illegal Goods (Hard)](https://leetcode.com/problems/minimum-time-to-remove-all-cars-containing-illegal-goods "移除所有载有违禁货物车厢所需的最少时间") + +

    You are given a 0-indexed binary string s which represents a sequence of train cars. s[i] = '0' denotes that the ith car does not contain illegal goods and s[i] = '1' denotes that the ith car does contain illegal goods.

    + +

    As the train conductor, you would like to get rid of all the cars containing illegal goods. You can do any of the following three operations any number of times:

    + +
      +
    1. Remove a train car from the left end (i.e., remove s[0]) which takes 1 unit of time.
    2. +
    3. Remove a train car from the right end (i.e., remove s[s.length - 1]) which takes 1 unit of time.
    4. +
    5. Remove a train car from anywhere in the sequence which takes 2 units of time.
    6. +
    + +

    Return the minimum time to remove all the cars containing illegal goods.

    + +

    Note that an empty sequence of cars is considered to have no cars containing illegal goods.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "1100101"
    +Output: 5
    +Explanation: 
    +One way to remove all the cars containing illegal goods from the sequence is to
    +- remove a car from the left end 2 times. Time taken is 2 * 1 = 2.
    +- remove a car from the right end. Time taken is 1.
    +- remove the car containing illegal goods found in the middle. Time taken is 2.
    +This obtains a total time of 2 + 1 + 2 = 5. 
    +
    +An alternative way is to
    +- remove a car from the left end 2 times. Time taken is 2 * 1 = 2.
    +- remove a car from the right end 3 times. Time taken is 3 * 1 = 3.
    +This also obtains a total time of 2 + 3 = 5.
    +
    +5 is the minimum time taken to remove all the cars containing illegal goods. 
    +There are no other ways to remove them with less time.
    +
    + +

    Example 2:

    + +
    +Input: s = "0010"
    +Output: 2
    +Explanation:
    +One way to remove all the cars containing illegal goods from the sequence is to
    +- remove a car from the left end 3 times. Time taken is 3 * 1 = 3.
    +This obtains a total time of 3.
    +
    +Another way to remove all the cars containing illegal goods from the sequence is to
    +- remove the car containing illegal goods found in the middle. Time taken is 2.
    +This obtains a total time of 2.
    +
    +Another way to remove all the cars containing illegal goods from the sequence is to 
    +- remove a car from the right end 2 times. Time taken is 2 * 1 = 2. 
    +This obtains a total time of 2.
    +
    +2 is the minimum time taken to remove all the cars containing illegal goods. 
    +There are no other ways to remove them with less time.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 2 * 105
    • +
    • s[i] is either '0' or '1'.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Build an array withoutFirst where withoutFirst[i] stores the minimum time to remove all the cars containing illegal goods from the ‘suffix’ of the sequence starting from the ith car without using any type 1 operations. +
    + +
    +Hint 2 +Next, build an array onlyFirst where onlyFirst[i] stores the minimum time to remove all the cars containing illegal goods from the ‘prefix’ of the sequence ending on the ith car using only type 1 operations. +
    + +
    +Hint 3 +Finally, we can compare the best way to split the operations amongst these two types by finding the minimum time across all onlyFirst[i] + withoutFirst[i + 1]. +
    diff --git a/problems/minimum-time-visiting-all-points/README.md b/problems/minimum-time-visiting-all-points/README.md index a30f21c83..8182cda1a 100644 --- a/problems/minimum-time-visiting-all-points/README.md +++ b/problems/minimum-time-visiting-all-points/README.md @@ -56,9 +56,9 @@ Total time = 7 seconds ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] ### Hints
    diff --git a/problems/missing-number/README.md b/problems/missing-number/README.md index 6537570f6..6c6174e60 100644 --- a/problems/missing-number/README.md +++ b/problems/missing-number/README.md @@ -19,7 +19,7 @@
     Input: nums = [3,0,1]
     Output: 2
    -Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not appear in nums.
    +Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not appear in nums.
     

    Example 2:

    @@ -27,7 +27,7 @@
     Input: nums = [0,1]
     Output: 2
    -Explanation: n = 2 since there are 2 numbers, so all numbers are in the range [0,2]. 2 is the missing number in the range since it does not appear in nums.
    +Explanation: n = 2 since there are 2 numbers, so all numbers are in the range [0,2]. 2 is the missing number in the range since it does not appear in nums.
     

    Example 3:

    @@ -35,15 +35,7 @@
     Input: nums = [9,6,4,2,3,5,7,0,1]
     Output: 8
    -Explanation: n = 9 since there are 9 numbers, so all numbers are in the range [0,9]. 8 is the missing number in the range since it does not appear in nums.
    -
    - -

    Example 4:

    - -
    -Input: nums = [0]
    -Output: 1
    -Explanation: n = 1 since there is 1 number, so all numbers are in the range [0,1]. 1 is the missing number in the range since it does not appear in nums.
    +Explanation: n = 9 since there are 9 numbers, so all numbers are in the range [0,9]. 8 is the missing number in the range since it does not appear in nums.
     

     

    @@ -60,10 +52,10 @@

    Follow up: Could you implement a solution using only O(1) extra space complexity and O(n) runtime complexity?

    ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Similar Questions @@ -71,3 +63,4 @@ 1. [Single Number](../single-number) (Easy) 1. [Find the Duplicate Number](../find-the-duplicate-number) (Medium) 1. [Couples Holding Hands](../couples-holding-hands) (Hard) + 1. [Find Unique Binary String](../find-unique-binary-string) (Medium) diff --git a/problems/monotone-increasing-digits/README.md b/problems/monotone-increasing-digits/README.md index acec2dd07..dca596465 100644 --- a/problems/monotone-increasing-digits/README.md +++ b/problems/monotone-increasing-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sentence-similarity-ii "Sentence Similarity II") diff --git a/problems/monthly-transactions-ii/README.md b/problems/monthly-transactions-ii/README.md index 46803195d..8662b3c72 100644 --- a/problems/monthly-transactions-ii/README.md +++ b/problems/monthly-transactions-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../last-person-to-fit-in-the-bus "Last Person to Fit in the Bus") @@ -82,3 +82,6 @@ Result table: ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Monthly Transactions I](../monthly-transactions-i) (Medium) diff --git a/problems/monthly-transactions-ii/mysql_schemas.sql b/problems/monthly-transactions-ii/mysql_schemas.sql index 7b54c5361..d73b157c0 100644 --- a/problems/monthly-transactions-ii/mysql_schemas.sql +++ b/problems/monthly-transactions-ii/mysql_schemas.sql @@ -1,6 +1,6 @@ -create table if not exists Transactions (id int, country varchar(4), state enum('approved', 'declined'), amount int, trans_date date) +Create table If Not Exists Transactions (id int, country varchar(4), state enum('approved', 'declined'), amount int, trans_date date) ; -create table if not exists Chargebacks (trans_id int, trans_date date) +Create table If Not Exists Chargebacks (trans_id int, trans_date date) ; Truncate table Transactions; insert into Transactions (id, country, state, amount, trans_date) values ('101', 'US', 'approved', '1000', '2019-05-18'); diff --git a/problems/my-calendar-i/README.md b/problems/my-calendar-i/README.md index 11c307265..d8e8ab306 100644 --- a/problems/my-calendar-i/README.md +++ b/problems/my-calendar-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../self-dividing-numbers "Self Dividing Numbers") diff --git a/problems/my-calendar-ii/README.md b/problems/my-calendar-ii/README.md index b7e248b90..07f53d2b3 100644 --- a/problems/my-calendar-ii/README.md +++ b/problems/my-calendar-ii/README.md @@ -39,7 +39,7 @@ MyCalendarTwo myCalendarTwo = new MyCalendarTwo(); myCalendarTwo.book(10, 20); // return True, The event can be booked. myCalendarTwo.book(50, 60); // return True, The event can be booked. myCalendarTwo.book(10, 40); // return True, The event can be double booked. -myCalendarTwo.book(5, 15); // return False, The event ca not be booked, because it would result in a triple booking. +myCalendarTwo.book(5, 15); // return False, The event cannot be booked, because it would result in a triple booking. myCalendarTwo.book(5, 10); // return True, The event can be booked, as it does not use time 10 which is already double booked. myCalendarTwo.book(25, 55); // return True, The event can be booked, as the time in [25, 40) will be double booked with the third event, the time [40, 50) will be single booked, and the time [50, 55) will be double booked with the second event. diff --git a/problems/nearest-exit-from-entrance-in-maze/README.md b/problems/nearest-exit-from-entrance-in-maze/README.md index 6ecf2c2bf..3f05dc6b0 100644 --- a/problems/nearest-exit-from-entrance-in-maze/README.md +++ b/problems/nearest-exit-from-entrance-in-maze/README.md @@ -66,8 +66,8 @@ Thus, the nearest exit is [1,2], which is 2 steps away. ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/new-users-daily-count/README.md b/problems/new-users-daily-count/README.md index 776d40322..76f4e50e6 100644 --- a/problems/new-users-daily-count/README.md +++ b/problems/new-users-daily-count/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../parsing-a-boolean-expression "Parsing A Boolean Expression") diff --git a/problems/non-decreasing-array/README.md b/problems/non-decreasing-array/README.md index de826c401..1bf899059 100644 --- a/problems/non-decreasing-array/README.md +++ b/problems/non-decreasing-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../strange-printer "Strange Printer") @@ -43,3 +43,6 @@ ### Related Topics [[Array](../../tag/array/README.md)] + +### Similar Questions + 1. [Find Good Days to Rob the Bank](../find-good-days-to-rob-the-bank) (Medium) diff --git a/problems/nth-highest-salary/README.md b/problems/nth-highest-salary/README.md index c8364cb74..b810c5eca 100644 --- a/problems/nth-highest-salary/README.md +++ b/problems/nth-highest-salary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../second-highest-salary "Second Highest Salary") diff --git a/problems/number-of-1-bits/README.md b/problems/number-of-1-bits/README.md index dc25d62d8..0fff41367 100644 --- a/problems/number-of-1-bits/README.md +++ b/problems/number-of-1-bits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-bits "Reverse Bits") diff --git a/problems/number-of-corner-rectangles/README.md b/problems/number-of-corner-rectangles/README.md index d6a1bc642..d504a9398 100644 --- a/problems/number-of-corner-rectangles/README.md +++ b/problems/number-of-corner-rectangles/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../contain-virus "Contain Virus") diff --git a/problems/number-of-dice-rolls-with-target-sum/README.md b/problems/number-of-dice-rolls-with-target-sum/README.md index 8ef9457d8..2a075c709 100644 --- a/problems/number-of-dice-rolls-with-target-sum/README.md +++ b/problems/number-of-dice-rolls-with-target-sum/README.md @@ -11,68 +11,52 @@ ## [1155. Number of Dice Rolls With Target Sum (Medium)](https://leetcode.com/problems/number-of-dice-rolls-with-target-sum "掷骰子的N种方法") -

    You have d dice and each die has f faces numbered 1, 2, ..., f. You are given three integers d, f, and target.

    +

    You have n dice and each die has k faces numbered from 1 to k.

    -

    Return the number of possible ways (out of fd total ways) modulo 109 + 7 to roll the dice so the sum of the face-up numbers equals target.

    +

    Given three integers n, k, and target, return the number of possible ways (out of the kn total ways) to roll the dice so the sum of the face-up numbers equals target. Since the answer may be too large, return it modulo 109 + 7.

     

    Example 1:

    -Input: d = 1, f = 6, target = 3
    +Input: n = 1, k = 6, target = 3
     Output: 1
    -Explanation: 
    -You throw one die with 6 faces.  There is only one way to get a sum of 3.
    +Explanation: You throw one die with 6 faces.
    +There is only one way to get a sum of 3.
     

    Example 2:

    -Input: d = 2, f = 6, target = 7
    +Input: n = 2, k = 6, target = 7
     Output: 6
    -Explanation: 
    -You throw two dice, each with 6 faces.  There are 6 ways to get a sum of 7:
    -1+6, 2+5, 3+4, 4+3, 5+2, 6+1.
    +Explanation: You throw two dice, each with 6 faces.
    +There are 6 ways to get a sum of 7: 1+6, 2+5, 3+4, 4+3, 5+2, 6+1.
     

    Example 3:

    -Input: d = 2, f = 5, target = 10
    -Output: 1
    -Explanation: 
    -You throw two dice, each with 5 faces.  There is only one way to get a sum of 10: 5+5.
    -
    - -

    Example 4:

    - -
    -Input: d = 1, f = 2, target = 3
    -Output: 0
    -Explanation: 
    -You throw one die with 2 faces.  There is no way to get a sum of 3.
    -
    - -

    Example 5:

    - -
    -Input: d = 30, f = 30, target = 500
    +Input: n = 30, k = 30, target = 500
     Output: 222616187
    -Explanation: 
    -The answer must be returned modulo 10^9 + 7.
    +Explanation: The answer must be returned modulo 109 + 7.
     

     

    Constraints:

      -
    • 1 <= d, f <= 30
    • +
    • 1 <= n, k <= 30
    • 1 <= target <= 1000
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Equal Sum Arrays With Minimum Number of Operations](../equal-sum-arrays-with-minimum-number-of-operations) (Medium) + 1. [Find Missing Observations](../find-missing-observations) (Medium) + ### Hints
    Hint 1 diff --git a/problems/number-of-digit-one/README.md b/problems/number-of-digit-one/README.md index 79ca7fbd5..efc194352 100644 --- a/problems/number-of-digit-one/README.md +++ b/problems/number-of-digit-one/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../implement-queue-using-stacks "Implement Queue using Stacks") @@ -36,12 +36,12 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions - 1. [Factorial Trailing Zeroes](../factorial-trailing-zeroes) (Easy) + 1. [Factorial Trailing Zeroes](../factorial-trailing-zeroes) (Medium) 1. [Digit Count in Range](../digit-count-in-range) (Hard) ### Hints diff --git a/problems/number-of-distinct-substrings-in-a-string/README.md b/problems/number-of-distinct-substrings-in-a-string/README.md index cbf499178..97806c83a 100644 --- a/problems/number-of-distinct-substrings-in-a-string/README.md +++ b/problems/number-of-distinct-substrings-in-a-string/README.md @@ -14,11 +14,11 @@ ### Related Topics - [[Trie](../../tag/trie/README.md)] [[String](../../tag/string/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] [[Suffix Array](../../tag/suffix-array/README.md)] [[Hash Function](../../tag/hash-function/README.md)] - [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/number-of-good-leaf-nodes-pairs/README.md b/problems/number-of-good-leaf-nodes-pairs/README.md index b7b4d21c1..d01430c7f 100644 --- a/problems/number-of-good-leaf-nodes-pairs/README.md +++ b/problems/number-of-good-leaf-nodes-pairs/README.md @@ -5,19 +5,19 @@ -[< Previous](../bulb-switcher-iv "Bulb Switcher IV") +[< Previous](../minimum-suffix-flips "Minimum Suffix Flips")                  [Next >](../string-compression-ii "String Compression II") ## [1530. Number of Good Leaf Nodes Pairs (Medium)](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs "好叶子节点对的数量") -

    Given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the shortest path between them is less than or equal to distance.

    +

    You are given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the shortest path between them is less than or equal to distance.

    Return the number of good leaf node pairs in the tree.

     

    Example 1:

    - +
     Input: root = [1,2,3,null,4], distance = 3
     Output: 1
    @@ -25,7 +25,7 @@
     

    Example 2:

    - +
     Input: root = [1,2,3,4,5,6,7], distance = 3
     Output: 2
    @@ -40,26 +40,12 @@
     Explanation: The only good pair is [2,5].
     
    -

    Example 4:

    - -
    -Input: root = [100], distance = 1
    -Output: 0
    -
    - -

    Example 5:

    - -
    -Input: root = [1,1,1], distance = 2
    -Output: 1
    -
    -

     

    Constraints:

      -
    • The number of nodes in the tree is in the range [1, 2^10].
    • -
    • Each node's value is between [1, 100].
    • +
    • The number of nodes in the tree is in the range [1, 210].
    • +
    • 1 <= Node.val <= 100
    • 1 <= distance <= 10
    diff --git a/problems/number-of-good-ways-to-split-a-string/README.md b/problems/number-of-good-ways-to-split-a-string/README.md index 93f58f1d9..39d75a7e4 100644 --- a/problems/number-of-good-ways-to-split-a-string/README.md +++ b/problems/number-of-good-ways-to-split-a-string/README.md @@ -11,9 +11,11 @@ ## [1525. Number of Good Ways to Split a String (Medium)](https://leetcode.com/problems/number-of-good-ways-to-split-a-string "字符串的好分割数目") -

    You are given a string s, a split is called good if you can split s into 2 non-empty strings p and q where its concatenation is equal to s and the number of distinct letters in p and q are the same.

    +

    You are given a string s.

    -

    Return the number of good splits you can make in s.

    +

    A split is called good if you can split s into two non-empty strings sleft and sright where their concatenation is equal to s (i.e., sleft + sright = s) and the number of distinct letters in sleft and sright is the same.

    + +

    Return the number of good splits you can make in s.

     

    Example 1:

    @@ -34,29 +36,15 @@
     Input: s = "abcd"
     Output: 1
    -Explanation: Split the string as follows ("ab", "cd").
    -
    - -

    Example 3:

    - -
    -Input: s = "aaaaa"
    -Output: 4
    -Explanation: All possible splits are good.
    - -

    Example 4:

    - -
    -Input: s = "acbadbaada"
    -Output: 2
    +Explanation: Split the string as follows ("ab", "cd").
     

     

    Constraints:

      -
    • s contains only lowercase English letters.
    • -
    • 1 <= s.length <= 10^5
    • +
    • 1 <= s.length <= 105
    • +
    • s consists of only lowercase English letters.
    ### Related Topics diff --git a/problems/number-of-laser-beams-in-a-bank/README.md b/problems/number-of-laser-beams-in-a-bank/README.md new file mode 100644 index 000000000..831713168 --- /dev/null +++ b/problems/number-of-laser-beams-in-a-bank/README.md @@ -0,0 +1,89 @@ + + + + + + + +[< Previous](../check-if-all-as-appears-before-all-bs "Check if All A's Appears Before All B's") +                 +[Next >](../destroying-asteroids "Destroying Asteroids") + +## [2125. Number of Laser Beams in a Bank (Medium)](https://leetcode.com/problems/number-of-laser-beams-in-a-bank "银行中的激光束数量") + +

    Anti-theft security devices are activated inside a bank. You are given a 0-indexed binary string array bank representing the floor plan of the bank, which is an m x n 2D matrix. bank[i] represents the ith row, consisting of '0's and '1's. '0' means the cell is empty, while'1' means the cell has a security device.

    + +

    There is one laser beam between any two security devices if both conditions are met:

    + +
      +
    • The two devices are located on two different rows: r1 and r2, where r1 < r2.
    • +
    • For each row i where r1 < i < r2, there are no security devices in the ith row.
    • +
    + +

    Laser beams are independent, i.e., one beam does not interfere nor join with another.

    + +

    Return the total number of laser beams in the bank.

    + +

     

    +

    Example 1:

    + +
    +Input: bank = ["011001","000000","010100","001000"]
    +Output: 8
    +Explanation: Between each of the following device pairs, there is one beam. In total, there are 8 beams:
    + * bank[0][1] -- bank[2][1]
    + * bank[0][1] -- bank[2][3]
    + * bank[0][2] -- bank[2][1]
    + * bank[0][2] -- bank[2][3]
    + * bank[0][5] -- bank[2][1]
    + * bank[0][5] -- bank[2][3]
    + * bank[2][1] -- bank[3][2]
    + * bank[2][3] -- bank[3][2]
    +Note that there is no beam between any device on the 0th row with any on the 3rd row.
    +This is because the 2nd row contains security devices, which breaks the second condition.
    +
    + +

    Example 2:

    + +
    +Input: bank = ["000","111","000"]
    +Output: 0
    +Explanation: There does not exist two devices located on two different rows.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == bank.length
    • +
    • n == bank[i].length
    • +
    • 1 <= m, n <= 500
    • +
    • bank[i][j] is either '0' or '1'.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +What is the commonality between security devices on the same row? +
    + +
    +Hint 2 +Each device on the same row has the same number of beams pointing towards the devices on the next row with devices. +
    + +
    +Hint 3 +If you were given an integer array where each element is the number of security devices on each row, can you solve it? +
    + +
    +Hint 4 +Convert the input to such an array, skip any row with no security device, then find the sum of the product between adjacent elements. +
    diff --git a/problems/number-of-lines-to-write-string/README.md b/problems/number-of-lines-to-write-string/README.md index bff49cf49..c21fe3637 100644 --- a/problems/number-of-lines-to-write-string/README.md +++ b/problems/number-of-lines-to-write-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../split-array-with-same-average "Split Array With Same Average") diff --git a/problems/number-of-longest-increasing-subsequence/README.md b/problems/number-of-longest-increasing-subsequence/README.md index 9baaae016..b3431dc6c 100644 --- a/problems/number-of-longest-increasing-subsequence/README.md +++ b/problems/number-of-longest-increasing-subsequence/README.md @@ -42,10 +42,10 @@ ### Related Topics - [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] - [[Segment Tree](../../tag/segment-tree/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] ### Similar Questions 1. [Longest Increasing Subsequence](../longest-increasing-subsequence) (Medium) diff --git a/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md b/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md index 633560907..fbfb6a7ef 100644 --- a/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md +++ b/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md @@ -11,17 +11,17 @@ ## [1519. Number of Nodes in the Sub-Tree With the Same Label (Medium)](https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label "子树中标签相同的节点数") -

    Given a tree (i.e. a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of the tree is the node 0, and each node of the tree has a label which is a lower-case character given in the string labels (i.e. The node with the number i has the label labels[i]).

    +

    You are given a tree (i.e. a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of the tree is the node 0, and each node of the tree has a label which is a lower-case character given in the string labels (i.e. The node with the number i has the label labels[i]).

    The edges array is given on the form edges[i] = [ai, bi], which means there is an edge between nodes ai and bi in the tree.

    -

    Return an array of size n where ans[i] is the number of nodes in the subtree of the ith node which have the same label as node i.

    +

    Return an array of size n where ans[i] is the number of nodes in the subtree of the ith node which have the same label as node i.

    -

    A subtree of a tree T is the tree consisting of a node in T and all of its descendant nodes.

    +

    A subtree of a tree T is the tree consisting of a node in T and all of its descendant nodes.

     

    Example 1:

    - +
     Input: n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], labels = "abaedcd"
     Output: [2,1,1,1,1,1,1]
    @@ -30,7 +30,7 @@ Node 1 has a label 'b'. The sub-tree of node 1 contains nodes 1,4 and 5,
     

    Example 2:

    - +
     Input: n = 4, edges = [[0,1],[1,2],[0,3]], labels = "bbbb"
     Output: [4,2,1,1]
    @@ -41,37 +41,23 @@ The sub-tree of node 0 contains nodes 0, 1, 2 and 3, all with label 'b',
     

    Example 3:

    - +
     Input: n = 5, edges = [[0,1],[0,2],[1,3],[0,4]], labels = "aabab"
     Output: [3,2,1,1,1]
     
    -

    Example 4:

    - -
    -Input: n = 6, edges = [[0,1],[0,2],[1,3],[3,4],[4,5]], labels = "cbabaa"
    -Output: [1,2,1,1,2,1]
    -
    - -

    Example 5:

    - -
    -Input: n = 7, edges = [[0,1],[1,2],[2,3],[3,4],[4,5],[5,6]], labels = "aaabaaa"
    -Output: [6,5,4,1,3,2,1]
    -
    -

     

    Constraints:

      -
    • 1 <= n <= 10^5
    • +
    • 1 <= n <= 105
    • edges.length == n - 1
    • edges[i].length == 2
    • -
    • 0 <= ai, bi < n
    • -
    • ai != bi
    • +
    • 0 <= ai, bi < n
    • +
    • ai != bi
    • labels.length == n
    • -
    • labels is consisting of only of lower-case English letters.
    • +
    • labels is consisting of only of lowercase English letters.
    ### Related Topics diff --git a/problems/number-of-operations-to-make-network-connected/README.md b/problems/number-of-operations-to-make-network-connected/README.md index 68f9686b0..77fb4cf07 100644 --- a/problems/number-of-operations-to-make-network-connected/README.md +++ b/problems/number-of-operations-to-make-network-connected/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-flips-to-make-a-or-b-equal-to-c "Minimum Flips to Make a OR b Equal to c") @@ -11,15 +11,15 @@ ## [1319. Number of Operations to Make Network Connected (Medium)](https://leetcode.com/problems/number-of-operations-to-make-network-connected "连通网络的操作次数") -

    There are n computers numbered from 0 to n-1 connected by ethernet cables connections forming a network where connections[i] = [a, b] represents a connection between computers a and b. Any computer can reach any other computer directly or indirectly through the network.

    +

    There are n computers numbered from 0 to n - 1 connected by ethernet cables connections forming a network where connections[i] = [ai, bi] represents a connection between computers ai and bi. Any computer can reach any other computer directly or indirectly through the network.

    -

    Given an initial computer network connections. You can extract certain cables between two directly connected computers, and place them between any pair of disconnected computers to make them directly connected. Return the minimum number of times you need to do this in order to make all the computers connected. If it's not possible, return -1. 

    +

    You are given an initial computer network connections. You can extract certain cables between two directly connected computers, and place them between any pair of disconnected computers to make them directly connected.

    + +

    Return the minimum number of times you need to do this in order to make all the computers connected. If it is not possible, return -1.

     

    Example 1:

    - -

    - +
     Input: n = 4, connections = [[0,1],[0,2],[1,2]]
     Output: 1
    @@ -27,9 +27,7 @@
     

    Example 2:

    - -

    - +
     Input: n = 6, connections = [[0,1],[0,2],[0,3],[1,2],[1,3]]
     Output: 2
    @@ -43,22 +41,15 @@
     Explanation: There are not enough cables.
     
    -

    Example 4:

    - -
    -Input: n = 5, connections = [[0,1],[0,2],[3,4],[2,3]]
    -Output: 0
    -
    -

     

    Constraints:

      -
    • 1 <= n <= 10^5
    • -
    • 1 <= connections.length <= min(n*(n-1)/2, 10^5)
    • +
    • 1 <= n <= 105
    • +
    • 1 <= connections.length <= min(n * (n - 1) / 2, 105)
    • connections[i].length == 2
    • -
    • 0 <= connections[i][0], connections[i][1] < n
    • -
    • connections[i][0] != connections[i][1]
    • +
    • 0 <= ai, bi < n
    • +
    • ai != bi
    • There are no repeated connections.
    • No two computers are connected by more than one cable.
    diff --git a/problems/number-of-segments-in-a-string/README.md b/problems/number-of-segments-in-a-string/README.md index 75512a97e..ccd1d349a 100644 --- a/problems/number-of-segments-in-a-string/README.md +++ b/problems/number-of-segments-in-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-genetic-mutation "Minimum Genetic Mutation") @@ -11,7 +11,7 @@ ## [434. Number of Segments in a String (Easy)](https://leetcode.com/problems/number-of-segments-in-a-string "字符串中的单词数") -

    You are given a string s, return the number of segments in the string

    +

    Given a string s, return the number of segments in the string.

    A segment is defined to be a contiguous sequence of non-space characters.

    @@ -31,26 +31,12 @@ Output: 1 -

    Example 3:

    - -
    -Input: s = "love live! mu'sic forever"
    -Output: 4
    -
    - -

    Example 4:

    - -
    -Input: s = ""
    -Output: 0
    -
    -

     

    Constraints:

    • 0 <= s.length <= 300
    • -
    • s consists of lower-case and upper-case English letters, digits or one of the following characters "!@#$%^&*()_+-=',.:".
    • +
    • s consists of lowercase and uppercase English letters, digits, or one of the following characters "!@#$%^&*()_+-=',.:".
    • The only space character in s is ' '.
    diff --git a/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md b/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md index 693b07e4d..72246a390 100644 --- a/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md +++ b/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md @@ -13,7 +13,7 @@

    Given n points on a 1-D plane, where the ith point (from 0 to n-1) is at x = i, find the number of ways we can draw exactly k non-overlapping line segments such that each segment covers two or more points. The endpoints of each segment must have integral coordinates. The k line segments do not have to cover all n points, and they are allowed to share endpoints.

    -

    Return the number of ways we can draw k non-overlapping line segments. Since this number can be huge, return it modulo 109 + 7.

    +

    Return the number of ways we can draw k non-overlapping line segments. Since this number can be huge, return it modulo 109 + 7.

     

    Example 1:

    @@ -21,16 +21,16 @@
     Input: n = 4, k = 2
     Output: 5
    -Explanation: 
    -The two line segments are shown in red and blue.
    -The image above shows the 5 different ways {(0,2),(2,3)}, {(0,1),(1,3)}, {(0,1),(2,3)}, {(1,2),(2,3)}, {(0,1),(1,2)}.
    +Explanation: The two line segments are shown in red and blue. +The image above shows the 5 different ways {(0,2),(2,3)}, {(0,1),(1,3)}, {(0,1),(2,3)}, {(1,2),(2,3)}, {(0,1),(1,2)}. +

    Example 2:

     Input: n = 3, k = 1
     Output: 3
    -Explanation: The 3 ways are {(0,1)}, {(0,2)}, {(1,2)}.
    +Explanation: The 3 ways are {(0,1)}, {(0,2)}, {(1,2)}.
     

    Example 3:

    @@ -38,22 +38,9 @@ The image above shows the 5 different ways {(0,2),(2,3)}, {(0,1),(1,3)}, {(0,1),
     Input: n = 30, k = 7
     Output: 796297179
    -Explanation: The total number of possible ways to draw 7 line segments is 3796297200. Taking this number modulo 109 + 7 gives us 796297179.
    -
    - -

    Example 4:

    - -
    -Input: n = 5, k = 3
    -Output: 7
    +Explanation: The total number of possible ways to draw 7 line segments is 3796297200. Taking this number modulo 109 + 7 gives us 796297179.
     
    -

    Example 5:

    - -
    -Input: n = 3, k = 2
    -Output: 1
    -

     

    Constraints:

    diff --git a/problems/number-of-smooth-descent-periods-of-a-stock/README.md b/problems/number-of-smooth-descent-periods-of-a-stock/README.md new file mode 100644 index 000000000..8a05be526 --- /dev/null +++ b/problems/number-of-smooth-descent-periods-of-a-stock/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../adding-spaces-to-a-string "Adding Spaces to a String") +                 +[Next >](../minimum-operations-to-make-the-array-k-increasing "Minimum Operations to Make the Array K-Increasing") + +## [2110. Number of Smooth Descent Periods of a Stock (Medium)](https://leetcode.com/problems/number-of-smooth-descent-periods-of-a-stock "股票平滑下跌阶段的数目") + +

    You are given an integer array prices representing the daily price history of a stock, where prices[i] is the stock price on the ith day.

    + +

    A smooth descent period of a stock consists of one or more contiguous days such that the price on each day is lower than the price on the preceding day by exactly 1. The first day of the period is exempted from this rule.

    + +

    Return the number of smooth descent periods.

    + +

     

    +

    Example 1:

    + +
    +Input: prices = [3,2,1,4]
    +Output: 7
    +Explanation: There are 7 smooth descent periods:
    +[3], [2], [1], [4], [3,2], [2,1], and [3,2,1]
    +Note that a period with one day is a smooth descent period by the definition.
    +
    + +

    Example 2:

    + +
    +Input: prices = [8,6,7,7]
    +Output: 4
    +Explanation: There are 4 smooth descent periods: [8], [6], [7], and [7]
    +Note that [8,6] is not a smooth descent period as 8 - 6 ≠ 1.
    +
    + +

    Example 3:

    + +
    +Input: prices = [1]
    +Output: 1
    +Explanation: There is 1 smooth descent period: [1]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= prices.length <= 105
    • +
    • 1 <= prices[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Any array is a series of adjacent longest possible smooth descent periods. For example, [5,3,2,1,7,6] is [5] + [3,2,1] + [7,6]. +
    + +
    +Hint 2 +Think of a 2-pointer approach to traverse the array and find each longest possible period. +
    + +
    +Hint 3 +Suppose you found the longest possible period with a length of k. How many periods are within that period? How can you count them quickly? Think of the formula to calculate the sum of 1, 2, 3, ..., k. +
    diff --git a/problems/number-of-spaces-cleaning-robot-cleaned/README.md b/problems/number-of-spaces-cleaning-robot-cleaned/README.md index f9fed2877..c40efb276 100644 --- a/problems/number-of-spaces-cleaning-robot-cleaned/README.md +++ b/problems/number-of-spaces-cleaning-robot-cleaned/README.md @@ -9,7 +9,7 @@                  [Next >](../count-vowel-substrings-of-a-string "Count Vowel Substrings of a String") -## [2061. Number of Spaces Cleaning Robot Cleaned (Medium)](https://leetcode.com/problems/number-of-spaces-cleaning-robot-cleaned "") +## [2061. Number of Spaces Cleaning Robot Cleaned (Medium)](https://leetcode.com/problems/number-of-spaces-cleaning-robot-cleaned "扫地机器人清扫过的空间个数") diff --git a/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md b/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md index 089c252a9..a94b24aca 100644 --- a/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md +++ b/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md @@ -65,8 +65,11 @@ Step 1) 2 is even, divide by 2 and obtain 1.  ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[String](../../tag/string/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + +### Similar Questions + 1. [Minimum Moves to Reach Target Score](../minimum-moves-to-reach-target-score) (Medium) ### Hints
    diff --git a/problems/number-of-steps-to-reduce-a-number-to-zero/README.md b/problems/number-of-steps-to-reduce-a-number-to-zero/README.md index ac1dab90c..6a5b12197 100644 --- a/problems/number-of-steps-to-reduce-a-number-to-zero/README.md +++ b/problems/number-of-steps-to-reduce-a-number-to-zero/README.md @@ -57,8 +57,12 @@ Step 4) 1 is odd; subtract 1 and obtain 0. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + +### Similar Questions + 1. [Minimum Moves to Reach Target Score](../minimum-moves-to-reach-target-score) (Medium) + 1. [Count Operations to Obtain Zero](../count-operations-to-obtain-zero) (Easy) ### Hints
    diff --git a/problems/number-of-students-doing-homework-at-a-given-time/README.md b/problems/number-of-students-doing-homework-at-a-given-time/README.md index 549a039e0..0378b7668 100644 --- a/problems/number-of-students-doing-homework-at-a-given-time/README.md +++ b/problems/number-of-students-doing-homework-at-a-given-time/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../form-largest-integer-with-digits-that-add-up-to-target "Form Largest Integer With Digits That Add up to Target") @@ -15,7 +15,7 @@

    The ith student started doing their homework at the time startTime[i] and finished it at time endTime[i].

    -

    Return the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime lays in the interval [startTime[i], endTime[i]] inclusive.

    +

    Return the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime lays in the interval [startTime[i], endTime[i]] inclusive.

     

    Example 1:

    @@ -37,27 +37,6 @@ The third student started doing homework at time 3 and finished at time 7 and wa Explanation: The only student was doing their homework at the queryTime. -

    Example 3:

    - -
    -Input: startTime = [4], endTime = [4], queryTime = 5
    -Output: 0
    -
    - -

    Example 4:

    - -
    -Input: startTime = [1,1,1,1], endTime = [1,3,2,4], queryTime = 7
    -Output: 0
    -
    - -

    Example 5:

    - -
    -Input: startTime = [9,8,7,6,5,4,3,2,1], endTime = [10,10,10,10,10,10,10,10,10], queryTime = 5
    -Output: 5
    -
    -

     

    Constraints:

    @@ -65,7 +44,7 @@ The third student started doing homework at time 3 and finished at time 7 and wa
  • startTime.length == endTime.length
  • 1 <= startTime.length <= 100
  • 1 <= startTime[i] <= endTime[i] <= 1000
  • -
  • 1 <= queryTime <= 1000
  • +
  • 1 <= queryTime <= 1000
  • ### Related Topics diff --git a/problems/number-of-students-unable-to-eat-lunch/README.md b/problems/number-of-students-unable-to-eat-lunch/README.md index 0251d8e4b..010fc4510 100644 --- a/problems/number-of-students-unable-to-eat-lunch/README.md +++ b/problems/number-of-students-unable-to-eat-lunch/README.md @@ -60,11 +60,14 @@ Hence all students are able to eat. ### Related Topics + [[Array](../../tag/array/README.md)] [[Stack](../../tag/stack/README.md)] [[Queue](../../tag/queue/README.md)] - [[Array](../../tag/array/README.md)] [[Simulation](../../tag/simulation/README.md)] +### Similar Questions + 1. [Time Needed to Buy Tickets](../time-needed-to-buy-tickets) (Easy) + ### Hints
    Hint 1 diff --git a/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md b/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md index 4eead3055..ea0d4c7dd 100644 --- a/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md +++ b/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md @@ -11,9 +11,7 @@ ## [1343. Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold (Medium)](https://leetcode.com/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold "大小为 K 且平均值大于等于阈值的子数组数目") -

    Given an array of integers arr and two integers k and threshold.

    - -

    Return the number of sub-arrays of size k and average greater than or equal to threshold.

    +

    Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold.

     

    Example 1:

    @@ -26,41 +24,20 @@

    Example 2:

    -
    -Input: arr = [1,1,1,1,1], k = 1, threshold = 0
    -Output: 5
    -
    - -

    Example 3:

    -
     Input: arr = [11,13,17,23,29,31,7,5,2,3], k = 3, threshold = 5
     Output: 6
     Explanation: The first 6 sub-arrays of size 3 have averages greater than 5. Note that averages are not integers.
     
    -

    Example 4:

    - -
    -Input: arr = [7,7,7,7,7,7,7], k = 7, threshold = 7
    -Output: 1
    -
    - -

    Example 5:

    - -
    -Input: arr = [4,4,4,4], k = 4, threshold = 1
    -Output: 1
    -
    -

     

    Constraints:

      -
    • 1 <= arr.length <= 10^5
    • -
    • 1 <= arr[i] <= 10^4
    • +
    • 1 <= arr.length <= 105
    • +
    • 1 <= arr[i] <= 104
    • 1 <= k <= arr.length
    • -
    • 0 <= threshold <= 10^4
    • +
    • 0 <= threshold <= 104
    ### Related Topics diff --git a/problems/number-of-sub-arrays-with-odd-sum/README.md b/problems/number-of-sub-arrays-with-odd-sum/README.md index cbb19a8a7..98a5c903c 100644 --- a/problems/number-of-sub-arrays-with-odd-sum/README.md +++ b/problems/number-of-sub-arrays-with-odd-sum/README.md @@ -57,6 +57,9 @@ All sub-arrays have even sum and the answer is 0. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] +### Similar Questions + 1. [Subsequence of Size K With the Largest Even Sum](../subsequence-of-size-k-with-the-largest-even-sum) (Medium) + ### Hints
    Hint 1 diff --git a/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md b/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md index d049a56a9..e05fcbde2 100644 --- a/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md +++ b/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-array-pairs-are-divisible-by-k "Check If Array Pairs Are Divisible by k") @@ -11,9 +11,9 @@ ## [1498. Number of Subsequences That Satisfy the Given Sum Condition (Medium)](https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition "满足条件的子序列数目") -

    Given an array of integers nums and an integer target.

    +

    You are given an array of integers nums and an integer target.

    -

    Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too large, return it modulo 109 + 7.

    +

    Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too large, return it modulo 109 + 7.

     

    Example 1:

    @@ -21,7 +21,7 @@
     Input: nums = [3,5,6,7], target = 9
     Output: 4
    -Explanation: There are 4 subsequences that satisfy the condition.
    +Explanation: There are 4 subsequences that satisfy the condition.
     [3] -> Min value + max value <= target (3 + 3 <= 9)
     [3,5] -> (3 + 5 <= 9)
     [3,5,6] -> (3 + 6 <= 9)
    @@ -33,25 +33,19 @@
     
     Input: nums = [3,3,6,8], target = 10
     Output: 6
    -Explanation: There are 6 subsequences that satisfy the condition. (nums can have repeated numbers).
    -[3] , [3] , [3,3], [3,6] , [3,6] , [3,3,6]
    +Explanation: There are 6 subsequences that satisfy the condition. (nums can have repeated numbers). +[3] , [3] , [3,3], [3,6] , [3,6] , [3,3,6] +

    Example 3:

     Input: nums = [2,3,3,4,6,7], target = 12
     Output: 61
    -Explanation: There are 63 non-empty subsequences, two of them don't satisfy the condition ([6,7], [7]).
    +Explanation: There are 63 non-empty subsequences, two of them do not satisfy the condition ([6,7], [7]).
     Number of valid subsequences (63 - 2 = 61).
     
    -

    Example 4:

    - -
    -Input: nums = [5,2,4,1,7,6,8], target = 16
    -Output: 127
    -Explanation: All non-empty subset satisfy the condition (2^7 - 1) = 127
    -

     

    Constraints:

    diff --git a/problems/number-of-substrings-with-only-1s/README.md b/problems/number-of-substrings-with-only-1s/README.md index ac9643cdb..3e0062cdb 100644 --- a/problems/number-of-substrings-with-only-1s/README.md +++ b/problems/number-of-substrings-with-only-1s/README.md @@ -40,13 +40,6 @@ Explanation: Each substring contains only 1's characters. -

    Example 4:

    - -
    -Input: s = "000"
    -Output: 0
    -
    -

     

    Constraints:

    @@ -59,6 +52,10 @@ [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Count Number of Homogenous Substrings](../count-number-of-homogenous-substrings) (Medium) + 1. [Count Vowel Substrings of a String](../count-vowel-substrings-of-a-string) (Easy) + ### Hints
    Hint 1 diff --git a/problems/number-of-transactions-per-visit/README.md b/problems/number-of-transactions-per-visit/README.md index 423f88ca9..e08f68f39 100644 --- a/problems/number-of-transactions-per-visit/README.md +++ b/problems/number-of-transactions-per-visit/README.md @@ -95,6 +95,3 @@ Note that we stopped at transactions_count = 3 as this is the maximum number of ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Find the Missing IDs](../find-the-missing-ids) (Medium) diff --git a/problems/number-of-unique-flavors-after-sharing-k-candies/README.md b/problems/number-of-unique-flavors-after-sharing-k-candies/README.md new file mode 100644 index 000000000..e77956fbe --- /dev/null +++ b/problems/number-of-unique-flavors-after-sharing-k-candies/README.md @@ -0,0 +1,35 @@ + + + + + + + +[< Previous](../maximum-fruits-harvested-after-at-most-k-steps "Maximum Fruits Harvested After at Most K Steps") +                 +[Next >](../find-first-palindromic-string-in-the-array "Find First Palindromic String in the Array") + +## [2107. Number of Unique Flavors After Sharing K Candies (Medium)](https://leetcode.com/problems/number-of-unique-flavors-after-sharing-k-candies "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
    +Hint 1 +For every group of k consecutive candies, count the number of unique flavors not inside that group. Return the largest number of unique flavors. +
    + +
    +Hint 2 +When calculating an adjacent group of k consecutive candies, can you use some of your previous calculations? +
    + +
    +Hint 3 +Use a sliding window where the window is the group of k consecutive candies you are sharing. Use a hash map to store the number of candies of each type you can keep. +
    diff --git a/problems/number-of-valid-move-combinations-on-chessboard/README.md b/problems/number-of-valid-move-combinations-on-chessboard/README.md index dfb94f7e2..89549528a 100644 --- a/problems/number-of-valid-move-combinations-on-chessboard/README.md +++ b/problems/number-of-valid-move-combinations-on-chessboard/README.md @@ -58,33 +58,6 @@ Explanation: The image above shows the possible squares the piece can move to. -

    Example 4:

    - -
    -Input: pieces = ["rook","rook"], positions = [[1,1],[8,8]]
    -Output: 223
    -Explanation: There are 15 moves for each rook which results in 15 * 15 = 225 move combinations.
    -However, there are two invalid move combinations:
    -- Move both rooks to (8, 1), where they collide.
    -- Move both rooks to (1, 8), where they collide.
    -Thus there are 225 - 2 = 223 valid move combinations.
    -Note that there are two valid move combinations that would result in one rook at (1, 8) and the other at (8, 1).
    -Even though the board state is the same, these two move combinations are considered different since the moves themselves are different.
    -
    - -

    Example 5:

    - -
    -Input: pieces = ["queen","bishop"], positions = [[5,7],[3,4]]
    -Output: 281
    -Explanation: There are 12 * 24 = 288 move combinations.
    -However, there are several invalid move combinations:
    -- If the queen stops at (6, 7), it blocks the bishop from moving to (6, 7) or (7, 8).
    -- If the queen stops at (5, 6), it blocks the bishop from moving to (5, 6), (6, 7), or (7, 8).
    -- If the bishop stops at (5, 2), it blocks the queen from moving to (5, 2) or (5, 1).
    -Of the 288 move combinations, 281 are valid.
    -
    -

     

    Constraints:

    @@ -92,10 +65,10 @@ Of the 288 move combinations, 281 are valid.
  • n == pieces.length
  • n == positions.length
  • 1 <= n <= 4
  • -
  • pieces only contains the strings "rook""queen", and "bishop".
  • +
  • pieces only contains the strings "rook", "queen", and "bishop".
  • There will be at most one queen on the chessboard.
  • 1 <= xi, yi <= 8
  • -
  • Each positions[i] is distinct.
  • +
  • Each positions[i] is distinct.
  • ### Related Topics diff --git a/problems/number-of-valid-words-in-a-sentence/README.md b/problems/number-of-valid-words-in-a-sentence/README.md index 624517eb4..6687e6bd5 100644 --- a/problems/number-of-valid-words-in-a-sentence/README.md +++ b/problems/number-of-valid-words-in-a-sentence/README.md @@ -53,14 +53,6 @@ "stone-game10" is invalid because it contains digits. -

    Example 4:

    - -
    -Input: sentence = "he bought 2 pencils, 3 erasers, and 1  pencil-sharpener."
    -Output: 6
    -Explanation: The valid words in the sentence are "he", "bought", "pencils,", "erasers,", "and", and "pencil-sharpener.".
    -
    -

     

    Constraints:

    diff --git a/problems/number-of-ways-to-divide-a-long-corridor/README.md b/problems/number-of-ways-to-divide-a-long-corridor/README.md new file mode 100644 index 000000000..020172312 --- /dev/null +++ b/problems/number-of-ways-to-divide-a-long-corridor/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../k-highest-ranked-items-within-a-price-range "K Highest Ranked Items Within a Price Range") +                 +[Next >](../count-elements-with-strictly-smaller-and-greater-elements "Count Elements With Strictly Smaller and Greater Elements ") + +## [2147. Number of Ways to Divide a Long Corridor (Hard)](https://leetcode.com/problems/number-of-ways-to-divide-a-long-corridor "分隔长廊的方案数") + +

    Along a long library corridor, there is a line of seats and decorative plants. You are given a 0-indexed string corridor of length n consisting of letters 'S' and 'P' where each 'S' represents a seat and each 'P' represents a plant.

    + +

    One room divider has already been installed to the left of index 0, and another to the right of index n - 1. Additional room dividers can be installed. For each position between indices i - 1 and i (1 <= i <= n - 1), at most one divider can be installed.

    + +

    Divide the corridor into non-overlapping sections, where each section has exactly two seats with any number of plants. There may be multiple ways to perform the division. Two ways are different if there is a position with a room divider installed in the first way but not in the second way.

    + +

    Return the number of ways to divide the corridor. Since the answer may be very large, return it modulo 109 + 7. If there is no way, return 0.

    + +

     

    +

    Example 1:

    + +
    +Input: corridor = "SSPPSPS"
    +Output: 3
    +Explanation: There are 3 different ways to divide the corridor.
    +The black bars in the above image indicate the two room dividers already installed.
    +Note that in each of the ways, each section has exactly two seats.
    +
    + +

    Example 2:

    + +
    +Input: corridor = "PPSPSP"
    +Output: 1
    +Explanation: There is only 1 way to divide the corridor, by not installing any additional dividers.
    +Installing any would create some section that does not have exactly two seats.
    +
    + +

    Example 3:

    + +
    +Input: corridor = "S"
    +Output: 0
    +Explanation: There is no way to divide the corridor because there will always be a section that does not have exactly two seats.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == corridor.length
    • +
    • 1 <= n <= 105
    • +
    • corridor[i] is either 'S' or 'P'.
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Divide the corridor into segments. Each segment has two seats, starts precisely with one seat, and ends precisely with the other seat. +
    + +
    +Hint 2 +How many dividers can you install between two adjacent segments? You must install precisely one. Otherwise, you would have created a section with not exactly two seats. +
    + +
    +Hint 3 +If there are k plants between two adjacent segments, there are k + 1 positions (ways) you could install the divider you must install. +
    + +
    +Hint 4 +The problem now becomes: Find the product of all possible positions between every two adjacent segments. +
    diff --git a/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md b/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md index 209ae1f48..8ef01bd16 100644 --- a/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md +++ b/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md @@ -22,7 +22,7 @@
  • Repeat the process until you form the string target.
  • -

    Notice that you can use multiple characters from the same string in words provided the conditions above are met.

    +

    Notice that you can use multiple characters from the same string in words provided the conditions above are met.

    Return the number of ways to form target from words. Since the answer may be too large, return it modulo 109 + 7.

    @@ -53,20 +53,6 @@ "bab" -> index 1 ("abba"), index 2 ("baab"), index 3 ("baab") -

    Example 3:

    - -
    -Input: words = ["abcd"], target = "abcd"
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: words = ["abab","baba","abba","baab"], target = "abba"
    -Output: 16
    -
    -

     

    Constraints:

    diff --git a/problems/number-of-ways-to-paint-n-3-grid/README.md b/problems/number-of-ways-to-paint-n-3-grid/README.md index 5b1198fdb..aea32d531 100644 --- a/problems/number-of-ways-to-paint-n-3-grid/README.md +++ b/problems/number-of-ways-to-paint-n-3-grid/README.md @@ -26,27 +26,6 @@

    Example 2:

    -
    -Input: n = 2
    -Output: 54
    -
    - -

    Example 3:

    - -
    -Input: n = 3
    -Output: 246
    -
    - -

    Example 4:

    - -
    -Input: n = 7
    -Output: 106494
    -
    - -

    Example 5:

    -
     Input: n = 5000
     Output: 30228214
    @@ -57,13 +36,15 @@
     
     
    • n == grid.length
    • -
    • grid[i].length == 3
    • 1 <= n <= 5000
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Painting a Grid With Three Different Colors](../painting-a-grid-with-three-different-colors) (Hard) + ### Hints
    Hint 1 diff --git a/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md b/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md index b6a36b36a..698d1d0ed 100644 --- a/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md +++ b/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md @@ -11,33 +11,31 @@ ## [1569. Number of Ways to Reorder Array to Get Same BST (Hard)](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst "将子数组重新排序得到同一个二叉查找树的方案数") -

    Given an array nums that represents a permutation of integers from 1 to n. We are going to construct a binary search tree (BST) by inserting the elements of nums in order into an initially empty BST. Find the number of different ways to reorder nums so that the constructed BST is identical to that formed from the original array nums.

    +

    Given an array nums that represents a permutation of integers from 1 to n. We are going to construct a binary search tree (BST) by inserting the elements of nums in order into an initially empty BST. Find the number of different ways to reorder nums so that the constructed BST is identical to that formed from the original array nums.

    -

    For example, given nums = [2,1,3], we will have 2 as the root, 1 as a left child, and 3 as a right child. The array [2,3,1] also yields the same BST but [3,2,1] yields a different BST.

    +
      +
    • For example, given nums = [2,1,3], we will have 2 as the root, 1 as a left child, and 3 as a right child. The array [2,3,1] also yields the same BST but [3,2,1] yields a different BST.
    • +
    -

    Return the number of ways to reorder nums such that the BST formed is identical to the original BST formed from nums.

    +

    Return the number of ways to reorder nums such that the BST formed is identical to the original BST formed from nums.

    -

    Since the answer may be very large, return it modulo 10^9 + 7.

    +

    Since the answer may be very large, return it modulo 109 + 7.

     

    Example 1:

    - -

    - +
     Input: nums = [2,1,3]
     Output: 1
    -Explanation: We can reorder nums to be [2,3,1] which will yield the same BST. There are no other ways to reorder nums which will yield the same BST.
    +Explanation: We can reorder nums to be [2,3,1] which will yield the same BST. There are no other ways to reorder nums which will yield the same BST.
     

    Example 2:

    - -

    - +
     Input: nums = [3,4,5,1,2]
     Output: 5
    -Explanation: The following 5 arrays will yield the same BST: 
    +Explanation: The following 5 arrays will yield the same BST: 
     [3,1,2,4,5]
     [3,1,4,2,5]
     [3,1,4,5,2]
    @@ -46,30 +44,11 @@
     

    Example 3:

    - -

    - +
     Input: nums = [1,2,3]
     Output: 0
    -Explanation: There are no other orderings of nums that will yield the same BST.
    -
    - -

    Example 4:

    - -

    - -
    -Input: nums = [3,1,2,5,4,6]
    -Output: 19
    -
    - -

    Example 5:

    - -
    -Input: nums = [9,4,2,1,3,6,5,7,8,14,11,10,12,13,16,15,17,18]
    -Output: 216212978
    -Explanation: The number of ways to reorder nums to get the same BST is 3216212999. Taking this number modulo 10^9 + 7 gives 216212978.
    +Explanation: There are no other orderings of nums that will yield the same BST.
     

     

    @@ -78,20 +57,20 @@
    • 1 <= nums.length <= 1000
    • 1 <= nums[i] <= nums.length
    • -
    • All integers in nums are distinct.
    • +
    • All integers in nums are distinct.
    ### Related Topics - [[Tree](../../tag/tree/README.md)] - [[Union Find](../../tag/union-find/README.md)] - [[Binary Search Tree](../../tag/binary-search-tree/README.md)] - [[Memoization](../../tag/memoization/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Binary Tree](../../tag/binary-tree/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Memoization](../../tag/memoization/README.md)] [[Combinatorics](../../tag/combinatorics/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/number-of-ways-to-separate-numbers/README.md b/problems/number-of-ways-to-separate-numbers/README.md index f305dec5b..1d359dd07 100644 --- a/problems/number-of-ways-to-separate-numbers/README.md +++ b/problems/number-of-ways-to-separate-numbers/README.md @@ -21,7 +21,7 @@
     Input: num = "327"
     Output: 2
    -Explanation: You could have written down the numbers:
    +Explanation: You could have written down the numbers:
     3, 27
     327
     
    @@ -31,7 +31,7 @@
     Input: num = "094"
     Output: 0
    -Explanation: No numbers can have leading zeros and all numbers must be positive.
    +Explanation: No numbers can have leading zeros and all numbers must be positive.
     

    Example 3:

    @@ -39,14 +39,7 @@
     Input: num = "0"
     Output: 0
    -Explanation: No numbers can have leading zeros and all numbers must be positive.
    -
    - -

    Example 4:

    - -
    -Input: num = "9999999999999"
    -Output: 101
    +Explanation: No numbers can have leading zeros and all numbers must be positive.
     

     

    diff --git a/problems/number-of-ways-to-split-a-string/README.md b/problems/number-of-ways-to-split-a-string/README.md index cfdbf11da..9874c1112 100644 --- a/problems/number-of-ways-to-split-a-string/README.md +++ b/problems/number-of-ways-to-split-a-string/README.md @@ -11,11 +11,9 @@ ## [1573. Number of Ways to Split a String (Medium)](https://leetcode.com/problems/number-of-ways-to-split-a-string "分割字符串的方案数") -

    Given a binary string s (a string consisting only of '0's and '1's), we can split s into 3 non-empty strings s1, s2, s3 (s1+ s2+ s3 = s).

    +

    Given a binary string s, you can split s into 3 non-empty strings s1, s2, and s3 where s1 + s2 + s3 = s.

    -

    Return the number of ways s can be split such that the number of characters '1' is the same in s1, s2, and s3.

    - -

    Since the answer may be too large, return it modulo 10^9 + 7.

    +

    Return the number of ways s can be split such that the number of ones is the same in s1, s2, and s3. Since the answer may be too large, return it modulo 109 + 7.

     

    Example 1:

    @@ -48,25 +46,21 @@ "00|0|0"
    -

    Example 4:

    - -
    -Input: s = "100100010100110"
    -Output: 12
    -
    -

     

    Constraints:

      -
    • 3 <= s.length <= 10^5
    • -
    • s[i] is '0' or '1'.
    • +
    • 3 <= s.length <= 105
    • +
    • s[i] is either '0' or '1'.
    ### Related Topics [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Split Array with Equal Sum](../split-array-with-equal-sum) (Hard) + ### Hints
    Hint 1 diff --git a/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md b/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md index f49a48d8b..a5b016402 100644 --- a/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md +++ b/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-a-string-can-break-another-string "Check If a String Can Break Another String") @@ -11,13 +11,13 @@ ## [1434. Number of Ways to Wear Different Hats to Each Other (Hard)](https://leetcode.com/problems/number-of-ways-to-wear-different-hats-to-each-other "每个人戴不同帽子的方案数") -

    There are n people and 40 types of hats labeled from 1 to 40.

    +

    There are n people and 40 types of hats labeled from 1 to 40.

    -

    Given a list of list of integers hats, where hats[i] is a list of all hats preferred by the i-th person.

    +

    Given a 2D integer array hats, where hats[i] is a list of all hats preferred by the ith person.

    -

    Return the number of ways that the n people wear different hats to each other.

    +

    Return the number of ways that the n people wear different hats to each other.

    -

    Since the answer may be too large, return it modulo 10^9 + 7.

    +

    Since the answer may be too large, return it modulo 109 + 7.

     

    Example 1:

    @@ -25,15 +25,16 @@
     Input: hats = [[3,4],[4,5],[5]]
     Output: 1
    -Explanation: There is only one way to choose hats given the conditions. 
    -First person choose hat 3, Second person choose hat 4 and last one hat 5.
    +Explanation: There is only one way to choose hats given the conditions. +First person choose hat 3, Second person choose hat 4 and last one hat 5. +

    Example 2:

     Input: hats = [[3,5,1],[3,5]]
     Output: 4
    -Explanation: There are 4 ways to choose hats
    +Explanation: There are 4 ways to choose hats:
     (3,5), (5,3), (1,3) and (1,5)
     
    @@ -42,17 +43,10 @@ First person choose hat 3, Second person choose hat 4 and last one hat 5.
     Input: hats = [[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]]
     Output: 24
    -Explanation: Each person can choose hats labeled from 1 to 4.
    +Explanation: Each person can choose hats labeled from 1 to 4.
     Number of Permutations of (1,2,3,4) = 24.
     
    -

    Example 4:

    - -
    -Input: hats = [[1,2,3],[2,3,5,6],[1,3,7,9],[1,8,9],[2,5,7]]
    -Output: 111
    -
    -

     

    Constraints:

    diff --git a/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md b/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md index 4a9a83b5e..9a7b126db 100644 --- a/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md +++ b/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md @@ -7,15 +7,15 @@ [< Previous](../replace-all-s-to-avoid-consecutive-repeating-characters "Replace All ?'s to Avoid Consecutive Repeating Characters")                  -[Next >](../minimum-deletion-cost-to-avoid-repeating-letters "Minimum Deletion Cost to Avoid Repeating Letters") +[Next >](../minimum-time-to-make-rope-colorful "Minimum Time to Make Rope Colorful") ## [1577. Number of Ways Where Square of Number Is Equal to Product of Two Numbers (Medium)](https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "数的平方等于两数乘积的方法数") -

    Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:

    +

    Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:

      -
    • Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
    • -
    • Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where 0 <= i < nums2.length and 0 <= j < k < nums1.length.
    • +
    • Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
    • +
    • Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where 0 <= i < nums2.length and 0 <= j < k < nums1.length.

     

    @@ -24,7 +24,7 @@
     Input: nums1 = [7,4], nums2 = [5,2,8,9]
     Output: 1
    -Explanation: Type 1: (1,1,2), nums1[1]^2 = nums2[1] * nums2[2]. (4^2 = 2 * 8). 
    +Explanation: Type 1: (1, 1, 2), nums1[1]2 = nums2[1] * nums2[2]. (42 = 2 * 8). 
     

    Example 2:

    @@ -32,9 +32,9 @@
     Input: nums1 = [1,1], nums2 = [1,1,1]
     Output: 9
    -Explanation: All Triplets are valid, because 1^2 = 1 * 1.
    -Type 1: (0,0,1), (0,0,2), (0,1,2), (1,0,1), (1,0,2), (1,1,2).  nums1[i]^2 = nums2[j] * nums2[k].
    -Type 2: (0,0,1), (1,0,1), (2,0,1). nums2[i]^2 = nums1[j] * nums1[k].
    +Explanation: All Triplets are valid, because 12 = 1 * 1.
    +Type 1: (0,0,1), (0,0,2), (0,1,2), (1,0,1), (1,0,2), (1,1,2).  nums1[i]2 = nums2[j] * nums2[k].
    +Type 2: (0,0,1), (1,0,1), (2,0,1). nums2[i]2 = nums1[j] * nums1[k].
     

    Example 3:

    @@ -43,16 +43,8 @@ Type 2: (0,0,1), (1,0,1), (2,0,1). nums2[i]^2 = nums1[j] * nums1[k]. Input: nums1 = [7,7,8,3], nums2 = [1,2,9,7] Output: 2 Explanation: There are 2 valid triplets. -Type 1: (3,0,2). nums1[3]^2 = nums2[0] * nums2[2]. -Type 2: (3,0,1). nums2[3]^2 = nums1[0] * nums1[1]. - - -

    Example 4:

    - -
    -Input: nums1 = [4,7,9,11,23], nums2 = [3,5,1024,12,18]
    -Output: 0
    -Explanation: There are no valid triplets.
    +Type 1: (3,0,2).  nums1[3]2 = nums2[0] * nums2[2].
    +Type 2: (3,0,1).  nums2[3]2 = nums1[0] * nums1[1].
     

     

    @@ -60,7 +52,7 @@ Type 2: (3,0,1). nums2[3]^2 = nums1[0] * nums1[1].
    • 1 <= nums1.length, nums2.length <= 1000
    • -
    • 1 <= nums1[i], nums2[i] <= 10^5
    • +
    • 1 <= nums1[i], nums2[i] <= 105
    ### Related Topics diff --git a/problems/numbers-with-repeated-digits/README.md b/problems/numbers-with-repeated-digits/README.md index 83006a889..4d2f0738f 100644 --- a/problems/numbers-with-repeated-digits/README.md +++ b/problems/numbers-with-repeated-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../capacity-to-ship-packages-within-d-days "Capacity To Ship Packages Within D Days") diff --git a/problems/odd-even-jump/README.md b/problems/odd-even-jump/README.md index faf449c89..43a345e2d 100644 --- a/problems/odd-even-jump/README.md +++ b/problems/odd-even-jump/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../subarray-sums-divisible-by-k "Subarray Sums Divisible by K") diff --git a/problems/online-majority-element-in-subarray/README.md b/problems/online-majority-element-in-subarray/README.md index 5dd0844bb..a21a6a7ed 100644 --- a/problems/online-majority-element-in-subarray/README.md +++ b/problems/online-majority-element-in-subarray/README.md @@ -52,11 +52,11 @@ majorityChecker.query(2, 3, 2); // return 2 ### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Design](../../tag/design/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] - [[Array](../../tag/array/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] ### Hints
    diff --git a/problems/order-two-columns-independently/README.md b/problems/order-two-columns-independently/README.md new file mode 100644 index 000000000..24bed0989 --- /dev/null +++ b/problems/order-two-columns-independently/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../amount-of-new-area-painted-each-day "Amount of New Area Painted Each Day") +                 +[Next >](../minimum-sum-of-four-digit-number-after-splitting-digits "Minimum Sum of Four Digit Number After Splitting Digits") + +## [2159. Order Two Columns Independently (Medium)](https://leetcode.com/problems/order-two-columns-independently "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/order-two-columns-independently/mysql_schemas.sql b/problems/order-two-columns-independently/mysql_schemas.sql new file mode 100644 index 000000000..444d9231f --- /dev/null +++ b/problems/order-two-columns-independently/mysql_schemas.sql @@ -0,0 +1,6 @@ +Create table If Not Exists Data (first_col int, second_col int); +Truncate table Data; +insert into Data (first_col, second_col) values ('4', '2'); +insert into Data (first_col, second_col) values ('2', '3'); +insert into Data (first_col, second_col) values ('3', '1'); +insert into Data (first_col, second_col) values ('1', '4'); diff --git a/problems/orders-with-maximum-quantity-above-average/README.md b/problems/orders-with-maximum-quantity-above-average/README.md index 063bde62f..4743751d8 100644 --- a/problems/orders-with-maximum-quantity-above-average/README.md +++ b/problems/orders-with-maximum-quantity-above-average/README.md @@ -9,7 +9,7 @@                  [Next >](../product-of-two-run-length-encoded-arrays "Product of Two Run-Length Encoded Arrays") -## [1867. Orders With Maximum Quantity Above Average (Medium)](https://leetcode.com/problems/orders-with-maximum-quantity-above-average "") +## [1867. Orders With Maximum Quantity Above Average (Medium)](https://leetcode.com/problems/orders-with-maximum-quantity-above-average "最大数量高于平均水平的订单") diff --git a/problems/paint-fence/README.md b/problems/paint-fence/README.md index 3317001f8..508201a5d 100644 --- a/problems/paint-fence/README.md +++ b/problems/paint-fence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../h-index-ii "H-Index II") diff --git a/problems/paint-house-iii/README.md b/problems/paint-house-iii/README.md index 71f75b642..2edda59c6 100644 --- a/problems/paint-house-iii/README.md +++ b/problems/paint-house-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-browser-history "Design Browser History") @@ -19,7 +19,7 @@
  • For example: houses = [1,2,2,3,3,2,1,1] contains 5 neighborhoods [{1}, {2,2}, {3,3}, {2}, {1,1}].
  • -

    Given an array houses, an m x n matrix cost and an integer target where:

    +

    Given an array houses, an m x n matrix cost and an integer target where:

    • houses[i]: is the color of the house i, and 0 if the house is not painted yet.
    • @@ -51,13 +51,6 @@ Cost of paint the first and last house (10 + 1) = 11.

      Example 3:

      -
      -Input: houses = [0,0,0,0,0], cost = [[1,10],[10,1],[1,10],[10,1],[1,10]], m = 5, n = 2, target = 5
      -Output: 5
      -
      - -

      Example 4:

      -
       Input: houses = [3,1,2,3], cost = [[1,1,1],[1,1,1],[1,1,1],[1,1,1]], m = 4, n = 3, target = 3
       Output: -1
      @@ -74,7 +67,7 @@ Cost of paint the first and last house (10 + 1) = 11.
       	
    • 1 <= n <= 20
    • 1 <= target <= m
    • 0 <= houses[i] <= n
    • -
    • 1 <= cost[i][j] <= 10^4
    • +
    • 1 <= cost[i][j] <= 104
    ### Related Topics diff --git a/problems/palindrome-linked-list/README.md b/problems/palindrome-linked-list/README.md index 3baebf8c4..95753900b 100644 --- a/problems/palindrome-linked-list/README.md +++ b/problems/palindrome-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-digit-one "Number of Digit One") diff --git a/problems/palindrome-pairs/README.md b/problems/palindrome-pairs/README.md index 7c370230a..05b89368f 100644 --- a/problems/palindrome-pairs/README.md +++ b/problems/palindrome-pairs/README.md @@ -55,3 +55,4 @@ ### Similar Questions 1. [Longest Palindromic Substring](../longest-palindromic-substring) (Medium) 1. [Shortest Palindrome](../shortest-palindrome) (Hard) + 1. [Longest Palindrome by Concatenating Two Letter Words](../longest-palindrome-by-concatenating-two-letter-words) (Medium) diff --git a/problems/palindrome-partitioning-iii/README.md b/problems/palindrome-partitioning-iii/README.md index b54eb04ff..8116ce7c1 100644 --- a/problems/palindrome-partitioning-iii/README.md +++ b/problems/palindrome-partitioning-iii/README.md @@ -55,6 +55,9 @@ [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Palindrome Partitioning IV](../palindrome-partitioning-iv) (Hard) + ### Hints
    Hint 1 diff --git a/problems/palindrome-removal/README.md b/problems/palindrome-removal/README.md index 63f3f227e..f7b82a429 100644 --- a/problems/palindrome-removal/README.md +++ b/problems/palindrome-removal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tree-diameter "Tree Diameter") diff --git a/problems/parallel-courses-ii/README.md b/problems/parallel-courses-ii/README.md index 01d706e9c..f3ace5883 100644 --- a/problems/parallel-courses-ii/README.md +++ b/problems/parallel-courses-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-subarray-of-1s-after-deleting-one-element "Longest Subarray of 1's After Deleting One Element") @@ -67,14 +67,11 @@ In the fourth semester, you can take course 5. ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Graph](../../tag/graph/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bitmask](../../tag/bitmask/README.md)] -### Similar Questions - 1. [Parallel Courses](../parallel-courses) (Medium) - ### Hints
    Hint 1 diff --git a/problems/partition-array-according-to-given-pivot/README.md b/problems/partition-array-according-to-given-pivot/README.md new file mode 100644 index 000000000..c058a818e --- /dev/null +++ b/problems/partition-array-according-to-given-pivot/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../minimum-sum-of-four-digit-number-after-splitting-digits "Minimum Sum of Four Digit Number After Splitting Digits") +                 +[Next >](../minimum-cost-to-set-cooking-time "Minimum Cost to Set Cooking Time") + +## [2161. Partition Array According to Given Pivot (Medium)](https://leetcode.com/problems/partition-array-according-to-given-pivot "根据给定数字划分数组") + +

    You are given a 0-indexed integer array nums and an integer pivot. Rearrange nums such that the following conditions are satisfied:

    + +
      +
    • Every element less than pivot appears before every element greater than pivot.
    • +
    • Every element equal to pivot appears in between the elements less than and greater than pivot.
    • +
    • The relative order of the elements less than pivot and the elements greater than pivot is maintained. +
        +
      • More formally, consider every pi, pj where pi is the new position of the ith element and pj is the new position of the jth element. For elements less than pivot, if i < j and nums[i] < pivot and nums[j] < pivot, then pi < pj. Similarly for elements greater than pivot, if i < j and nums[i] > pivot and nums[j] > pivot, then pi < pj.
      • +
      +
    • +
    + +

    Return nums after the rearrangement.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [9,12,5,10,14,3,10], pivot = 10
    +Output: [9,5,3,10,10,12,14]
    +Explanation: 
    +The elements 9, 5, and 3 are less than the pivot so they are on the left side of the array.
    +The elements 12 and 14 are greater than the pivot so they are on the right side of the array.
    +The relative ordering of the elements less than and greater than pivot is also maintained. [9, 5, 3] and [12, 14] are the respective orderings.
    +
    + +

    Example 2:

    + +
    +Input: nums = [-3,4,3,2], pivot = 2
    +Output: [-3,2,4,3]
    +Explanation: 
    +The element -3 is less than the pivot so it is on the left side of the array.
    +The elements 4 and 3 are greater than the pivot so they are on the right side of the array.
    +The relative ordering of the elements less than and greater than pivot is also maintained. [-3] and [4, 3] are the respective orderings.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • -106 <= nums[i] <= 106
    • +
    • pivot equals to an element of nums.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Could you put the elements smaller than the pivot and greater than the pivot in a separate list as in the sequence that they occur? +
    + +
    +Hint 2 +With the separate lists generated, could you then generate the result? +
    diff --git a/problems/partition-list/README.md b/problems/partition-list/README.md index fc0ea514d..e212ee33c 100644 --- a/problems/partition-list/README.md +++ b/problems/partition-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximal-rectangle "Maximal Rectangle") diff --git a/problems/path-sum-ii/README.md b/problems/path-sum-ii/README.md index acd143c07..50e88d874 100644 --- a/problems/path-sum-ii/README.md +++ b/problems/path-sum-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-sum "Path Sum") @@ -50,9 +50,9 @@ ### Related Topics - [[Backtracking](../../tag/backtracking/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/path-sum/README.md b/problems/path-sum/README.md index db538a498..71194c380 100644 --- a/problems/path-sum/README.md +++ b/problems/path-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-depth-of-binary-tree "Minimum Depth of Binary Tree") @@ -21,6 +21,7 @@
     Input: root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum = 22
     Output: true
    +Explanation: The root-to-leaf path with the target sum is shown.
     

    Example 2:

    @@ -28,13 +29,18 @@
     Input: root = [1,2,3], targetSum = 5
     Output: false
    +Explanation: There two root-to-leaf paths in the tree:
    +(1 --> 2): The sum is 3.
    +(1 --> 3): The sum is 4.
    +There is no root-to-leaf path with sum = 5.
     

    Example 3:

    -Input: root = [1,2], targetSum = 0
    +Input: root = [], targetSum = 0
     Output: false
    +Explanation: Since the tree is empty, there are no root-to-leaf paths.
     

     

    @@ -49,6 +55,7 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/path-with-minimum-effort/README.md b/problems/path-with-minimum-effort/README.md index b964c1049..9cee131df 100644 --- a/problems/path-with-minimum-effort/README.md +++ b/problems/path-with-minimum-effort/README.md @@ -58,17 +58,13 @@ This is better than the route of [1,2,2,2,5], where the maximum absolute differe ### Related Topics - [[Array](../../tag/array/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Matrix](../../tag/matrix/README.md)] - -### Similar Questions - 1. [Swim in Rising Water](../swim-in-rising-water) (Hard) - 1. [Path With Maximum Minimum Value](../path-with-maximum-minimum-value) (Medium) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/perfect-rectangle/README.md b/problems/perfect-rectangle/README.md index 8949f5f14..971198a6f 100644 --- a/problems/perfect-rectangle/README.md +++ b/problems/perfect-rectangle/README.md @@ -33,14 +33,6 @@

    Example 3:

    - -
    -Input: rectangles = [[1,1,3,3],[3,1,4,2],[1,3,2,4],[3,2,4,4]]
    -Output: false
    -Explanation: Because there is a gap in the top center.
    -
    - -

    Example 4:

     Input: rectangles = [[1,1,3,3],[3,1,4,2],[1,3,2,4],[2,2,4,4]]
    diff --git a/problems/pizza-with-3n-slices/README.md b/problems/pizza-with-3n-slices/README.md
    index fb5a05914..eb813cd89 100644
    --- a/problems/pizza-with-3n-slices/README.md
    +++ b/problems/pizza-with-3n-slices/README.md
    @@ -1,8 +1,8 @@
     
     
    -
    -
    -
    +
    +
    +
     
     
     [< Previous](../sort-integers-by-the-power-value "Sort Integers by The Power Value")
    @@ -11,24 +11,20 @@
     
     ## [1388. Pizza With 3n Slices (Hard)](https://leetcode.com/problems/pizza-with-3n-slices "3n 块披萨")
     
    -

    There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:

    +

    There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:

    • You will pick any pizza slice.
    • -
    • Your friend Alice will pick next slice in anti clockwise direction of your pick. 
    • -
    • Your friend Bob will pick next slice in clockwise direction of your pick.
    • -
    • Repeat until there are no more slices of pizzas.
    • +
    • Your friend Alice will pick the next slice in the anti-clockwise direction of your pick.
    • +
    • Your friend Bob will pick the next slice in the clockwise direction of your pick.
    • +
    • Repeat until there are no more slices of pizzas.
    -

    Sizes of Pizza slices is represented by circular array slices in clockwise direction.

    - -

    Return the maximum possible sum of slice sizes which you can have.

    +

    Given an integer array slices that represent the sizes of the pizza slices in a clockwise direction, return the maximum possible sum of slice sizes that you can pick.

     

    Example 1:

    - -

    - +
     Input: slices = [1,2,3,4,5,6]
     Output: 10
    @@ -36,35 +32,19 @@
     

    Example 2:

    - -

    - +
     Input: slices = [8,9,8,6,1,1]
     Output: 16
    -Output: Pick pizza slice of size 8 in each turn. If you pick slice with size 9 your partners will pick slices of size 8.
    -
    - -

    Example 3:

    - -
    -Input: slices = [4,1,2,5,8,3,1,9,7]
    -Output: 21
    -
    - -

    Example 4:

    - -
    -Input: slices = [3,1,2]
    -Output: 3
    +Explanation: Pick pizza slice of size 8 in each turn. If you pick slice with size 9 your partners will pick slices of size 8.
     

     

    Constraints:

      +
    • 3 * n == slices.length
    • 1 <= slices.length <= 500
    • -
    • slices.length % 3 == 0
    • 1 <= slices[i] <= 1000
    diff --git a/problems/plus-one-linked-list/README.md b/problems/plus-one-linked-list/README.md index b8d162510..ae6a641b4 100644 --- a/problems/plus-one-linked-list/README.md +++ b/problems/plus-one-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-divisible-subset "Largest Divisible Subset") diff --git a/problems/poor-pigs/README.md b/problems/poor-pigs/README.md index a63d6d81b..ed7c5ff79 100644 --- a/problems/poor-pigs/README.md +++ b/problems/poor-pigs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../circular-array-loop "Circular Array Loop") diff --git a/problems/populating-next-right-pointers-in-each-node-ii/README.md b/problems/populating-next-right-pointers-in-each-node-ii/README.md index ea527badd..7621d80dc 100644 --- a/problems/populating-next-right-pointers-in-each-node-ii/README.md +++ b/problems/populating-next-right-pointers-in-each-node-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../populating-next-right-pointers-in-each-node "Populating Next Right Pointers in Each Node") @@ -62,6 +62,7 @@ struct Node { [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Linked List](../../tag/linked-list/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/possible-bipartition/README.md b/problems/possible-bipartition/README.md index 1bd27615c..d37d11381 100644 --- a/problems/possible-bipartition/README.md +++ b/problems/possible-bipartition/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../spiral-matrix-iii "Spiral Matrix III") diff --git a/problems/pour-water-between-buckets-to-make-water-levels-equal/README.md b/problems/pour-water-between-buckets-to-make-water-levels-equal/README.md new file mode 100644 index 000000000..3c977e969 --- /dev/null +++ b/problems/pour-water-between-buckets-to-make-water-levels-equal/README.md @@ -0,0 +1,39 @@ + + + + + + + +[< Previous](../earliest-possible-day-of-full-bloom "Earliest Possible Day of Full Bloom") +                 +[Next >](../divide-a-string-into-groups-of-size-k "Divide a String Into Groups of Size k") + +## [2137. Pour Water Between Buckets to Make Water Levels Equal (Medium)](https://leetcode.com/problems/pour-water-between-buckets-to-make-water-levels-equal "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +What is the range that the answer must fall into? +
    + +
    +Hint 2 +The answer has to be in the range [0, max(buckets)] (inclusive). +
    + +
    +Hint 3 +For a number x, is there an efficient way to check if it is possible to make the amount of water in each bucket x. +
    + +
    +Hint 4 +Let in be the total amount of water that needs to be poured into buckets and out be the total amount of water that needs to be poured out of buckets to make the amount of water in each bucket x. If out - (out * loss) >= in, then it is possible. +
    diff --git a/problems/power-of-three/README.md b/problems/power-of-three/README.md index e9bd83b14..1f77942fa 100644 --- a/problems/power-of-three/README.md +++ b/problems/power-of-three/README.md @@ -1,15 +1,15 @@ - - - + + + [< Previous](../maximum-size-subarray-sum-equals-k "Maximum Size Subarray Sum Equals k")                  [Next >](../count-of-range-sum "Count of Range Sum") -## [326. Power of Three (Easy)](https://leetcode.com/problems/power-of-three "3的幂") +## [326. Power of Three (Easy)](https://leetcode.com/problems/power-of-three "3 的幂")

    Given an integer n, return true if it is a power of three. Otherwise, return false.

    @@ -17,18 +17,26 @@

     

    Example 1:

    -
    Input: n = 27
    +
    +
    +Input: n = 27
     Output: true
    -

    Example 2:

    -
    Input: n = 0
    +
    + +

    Example 2:

    + +
    +Input: n = 0
     Output: false
    -

    Example 3:

    -
    Input: n = 9
    +
    + +

    Example 3:

    + +
    +Input: n = 9
     Output: true
    -

    Example 4:

    -
    Input: n = 45
    -Output: false
     
    +

     

    Constraints:

    diff --git a/problems/prime-arrangements/README.md b/problems/prime-arrangements/README.md index b85fa61f2..bb7caddf2 100644 --- a/problems/prime-arrangements/README.md +++ b/problems/prime-arrangements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../immediate-food-delivery-ii "Immediate Food Delivery II") diff --git a/problems/print-in-order/README.md b/problems/print-in-order/README.md index b97cb6ac8..2f0675943 100644 --- a/problems/print-in-order/README.md +++ b/problems/print-in-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reported-posts "Reported Posts") diff --git a/problems/prison-cells-after-n-days/README.md b/problems/prison-cells-after-n-days/README.md index fe203b401..1459ec6aa 100644 --- a/problems/prison-cells-after-n-days/README.md +++ b/problems/prison-cells-after-n-days/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tallest-billboard "Tallest Billboard") @@ -60,7 +60,7 @@ Day 7: [0, 0, 1, 1, 0, 0, 0, 0] ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md b/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md index 40e16a1df..4e558e1e6 100644 --- a/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md +++ b/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md @@ -53,22 +53,6 @@ Probability is 8/12 = 0.66667 Probability = 108 / 180 = 0.6
    -

    Example 4:

    - -
    -Input: balls = [3,2,1]
    -Output: 0.30000
    -Explanation: The set of balls is [1, 1, 1, 2, 2, 3]. It is hard to display all the 60 possible random shuffles of this set but it is easy to check that 18 of them will have the same number of distinct colors in each box.
    -Probability = 18 / 60 = 0.3
    -
    - -

    Example 5:

    - -
    -Input: balls = [6,6,6,6,6,6]
    -Output: 0.90327
    -
    -

     

    Constraints:

    diff --git a/problems/product-of-array-except-self/README.md b/problems/product-of-array-except-self/README.md index 665cd7199..0b3fe0d47 100644 --- a/problems/product-of-array-except-self/README.md +++ b/problems/product-of-array-except-self/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-node-in-a-linked-list "Delete Node in a Linked List") diff --git a/problems/products-price-for-each-store/README.md b/problems/products-price-for-each-store/README.md index 5d46b038f..ad3e0f768 100644 --- a/problems/products-price-for-each-store/README.md +++ b/problems/products-price-for-each-store/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Rearrange Products Table](../rearrange-products-table) (Easy) diff --git a/problems/projection-area-of-3d-shapes/README.md b/problems/projection-area-of-3d-shapes/README.md index 5d23f8dbe..645e1c1af 100644 --- a/problems/projection-area-of-3d-shapes/README.md +++ b/problems/projection-area-of-3d-shapes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reachable-nodes-in-subdivided-graph "Reachable Nodes In Subdivided Graph") @@ -44,27 +44,12 @@ Output: 8
    -

    Example 4:

    - -
    -Input: grid = [[1,1,1],[1,0,1],[1,1,1]]
    -Output: 14
    -
    - -

    Example 5:

    - -
    -Input: grid = [[2,2,2],[2,1,2],[2,2,2]]
    -Output: 21
    -
    -

     

    Constraints:

      -
    • n == grid.length
    • -
    • n == grid[i].length
    • -
    • 1 <= n <= 50
    • +
    • n == grid.length == grid[i].length
    • +
    • 1 <= n <= 50
    • 0 <= grid[i][j] <= 50
    diff --git a/problems/put-boxes-into-the-warehouse-ii/README.md b/problems/put-boxes-into-the-warehouse-ii/README.md index e6089dd71..467663579 100644 --- a/problems/put-boxes-into-the-warehouse-ii/README.md +++ b/problems/put-boxes-into-the-warehouse-ii/README.md @@ -14,10 +14,13 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Put Boxes Into the Warehouse I](../put-boxes-into-the-warehouse-i) (Medium) + ### Hints
    Hint 1 diff --git a/problems/queries-on-a-permutation-with-key/README.md b/problems/queries-on-a-permutation-with-key/README.md index 60eb9a5fb..d1f4999c2 100644 --- a/problems/queries-on-a-permutation-with-key/README.md +++ b/problems/queries-on-a-permutation-with-key/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../string-matching-in-an-array "String Matching in an Array") diff --git a/problems/queries-quality-and-percentage/README.md b/problems/queries-quality-and-percentage/README.md index 36250d98d..a856dd542 100644 --- a/problems/queries-quality-and-percentage/README.md +++ b/problems/queries-quality-and-percentage/README.md @@ -78,3 +78,6 @@ Cat queries poor_ query_percentage is (1 / 3) * 100 = 33.33 ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Percentage of Users Attended a Contest](../percentage-of-users-attended-a-contest) (Easy) diff --git a/problems/queue-reconstruction-by-height/README.md b/problems/queue-reconstruction-by-height/README.md index 2378a7f52..7045e7aa1 100644 --- a/problems/queue-reconstruction-by-height/README.md +++ b/problems/queue-reconstruction-by-height/README.md @@ -49,8 +49,8 @@ Hence [[5,0],[7,0],[5,2],[6,1],[4,4],[7,1]] is the reconstructed queue. ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Similar Questions diff --git a/problems/race-car/README.md b/problems/race-car/README.md index bbb7c6451..f0097cbbb 100644 --- a/problems/race-car/README.md +++ b/problems/race-car/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../linked-list-components "Linked List Components") diff --git a/problems/random-pick-index/README.md b/problems/random-pick-index/README.md index 01f9412be..8a120eb57 100644 --- a/problems/random-pick-index/README.md +++ b/problems/random-pick-index/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../integer-replacement "Integer Replacement") @@ -48,9 +48,9 @@ solution.pick(3); // It should return either index 2, 3, or 4 randomly. Each ind ### Related Topics - [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] [[Randomized](../../tag/randomized/README.md)] ### Similar Questions diff --git a/problems/random-pick-with-weight/README.md b/problems/random-pick-with-weight/README.md index a9dd6b22b..003bbd478 100644 --- a/problems/random-pick-with-weight/README.md +++ b/problems/random-pick-with-weight/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-abbreviation "Word Abbreviation") @@ -11,11 +11,13 @@ ## [528. Random Pick with Weight (Medium)](https://leetcode.com/problems/random-pick-with-weight "按权重随机选择") -

    You are given an array of positive integers w where w[i] describes the weight of ith index (0-indexed).

    +

    You are given a 0-indexed array of positive integers w where w[i] describes the weight of the ith index.

    -

    We need to call the function pickIndex() which randomly returns an integer in the range [0, w.length - 1]pickIndex() should return the integer proportional to its weight in the w array. For example, for w = [1, 3], the probability of picking the index 0 is 1 / (1 + 3) = 0.25 (i.e 25%) while the probability of picking the index 1 is 3 / (1 + 3) = 0.75 (i.e 75%).

    +

    You need to implement the function pickIndex(), which randomly picks an index in the range [0, w.length - 1] (inclusive) and returns it. The probability of picking an index i is w[i] / sum(w).

    -

    More formally, the probability of picking index i is w[i] / sum(w).

    +
      +
    • For example, if w = [1, 3], the probability of picking index 0 is 1 / (1 + 3) = 0.25 (i.e., 25%), and the probability of picking index 1 is 3 / (1 + 3) = 0.75 (i.e., 75%).
    • +

     

    Example 1:

    @@ -29,7 +31,7 @@ Explanation Solution solution = new Solution([1]); -solution.pickIndex(); // return 0. Since there is only one single element on the array the only option is to return the first element. +solution.pickIndex(); // return 0. The only option is to return 0 since there is only one element in w.

    Example 2:

    @@ -43,13 +45,14 @@ solution.pickIndex(); // return 0. Since there is only one single element on the Explanation Solution solution = new Solution([1, 3]); -solution.pickIndex(); // return 1. It's returning the second element (index = 1) that has probability of 3/4. +solution.pickIndex(); // return 1. It is returning the second element (index = 1) that has a probability of 3/4. solution.pickIndex(); // return 1 solution.pickIndex(); // return 1 solution.pickIndex(); // return 1 -solution.pickIndex(); // return 0. It's returning the first element (index = 0) that has probability of 1/4. +solution.pickIndex(); // return 0. It is returning the first element (index = 0) that has a probability of 1/4. -Since this is a randomization problem, multiple answers are allowed so the following outputs can be considered correct : +Since this is a randomization problem, multiple answers are allowed. +All of the following outputs can be considered correct: [null,1,1,1,1,0] [null,1,1,1,1,1] [null,1,1,1,0,0] @@ -63,9 +66,9 @@ and so on.

    Constraints:

      -
    • 1 <= w.length <= 10000
    • -
    • 1 <= w[i] <= 10^5
    • -
    • pickIndex will be called at most 10000 times.
    • +
    • 1 <= w.length <= 104
    • +
    • 1 <= w[i] <= 105
    • +
    • pickIndex will be called at most 104 times.
    ### Related Topics diff --git a/problems/range-sum-query-mutable/README.md b/problems/range-sum-query-mutable/README.md index 8dd88dfdd..9e9b4991a 100644 --- a/problems/range-sum-query-mutable/README.md +++ b/problems/range-sum-query-mutable/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../additive-number "Additive Number") @@ -56,10 +56,10 @@ numArray.sumRange(0, 2); // return 1 + 2 + 5 = 8 ### Related Topics + [[Array](../../tag/array/README.md)] [[Design](../../tag/design/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] - [[Array](../../tag/array/README.md)] ### Similar Questions 1. [Range Sum Query - Immutable](../range-sum-query-immutable) (Easy) diff --git a/problems/rank-scores/README.md b/problems/rank-scores/README.md index 6160acfc4..22dc4120c 100644 --- a/problems/rank-scores/README.md +++ b/problems/rank-scores/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../nth-highest-salary "Nth Highest Salary") diff --git a/problems/rank-transform-of-a-matrix/README.md b/problems/rank-transform-of-a-matrix/README.md index 836561c15..50ab56c4c 100644 --- a/problems/rank-transform-of-a-matrix/README.md +++ b/problems/rank-transform-of-a-matrix/README.md @@ -27,7 +27,7 @@
  • The rank should be as small as possible.
  • -

    It is guaranteed that answer is unique under the given rules.

    +

    The test cases are generated so that answer is unique under the given rules.

     

    Example 1:

    @@ -56,13 +56,6 @@ The rank of matrix[1][1] is 3 because matrix[1][1] > matrix[0][1], matrix[1][ Output: [[4,2,3],[1,3,4],[5,1,6],[1,3,4]] -

    Example 4:

    - -
    -Input: matrix = [[7,3,6],[1,4,5],[9,8,2]]
    -Output: [[5,1,4],[1,2,3],[6,3,1]]
    -
    -

     

    Constraints:

    diff --git a/problems/reach-a-number/README.md b/problems/reach-a-number/README.md index c9cfef930..3d3d442ee 100644 --- a/problems/reach-a-number/README.md +++ b/problems/reach-a-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cracking-the-safe "Cracking the Safe") diff --git a/problems/rearrange-array-elements-by-sign/README.md b/problems/rearrange-array-elements-by-sign/README.md new file mode 100644 index 000000000..42e6a72bd --- /dev/null +++ b/problems/rearrange-array-elements-by-sign/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../count-elements-with-strictly-smaller-and-greater-elements "Count Elements With Strictly Smaller and Greater Elements ") +                 +[Next >](../find-all-lonely-numbers-in-the-array "Find All Lonely Numbers in the Array") + +## [2149. Rearrange Array Elements by Sign (Medium)](https://leetcode.com/problems/rearrange-array-elements-by-sign "按符号重排数组") + +

    You are given a 0-indexed integer array nums of even length consisting of an equal number of positive and negative integers.

    + +

    You should rearrange the elements of nums such that the modified array follows the given conditions:

    + +
      +
    1. Every consecutive pair of integers have opposite signs.
    2. +
    3. For all integers with the same sign, the order in which they were present in nums is preserved.
    4. +
    5. The rearranged array begins with a positive integer.
    6. +
    + +

    Return the modified array after rearranging the elements to satisfy the aforementioned conditions.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [3,1,-2,-5,2,-4]
    +Output: [3,-2,1,-5,2,-4]
    +Explanation:
    +The positive integers in nums are [3,1,2]. The negative integers are [-2,-5,-4].
    +The only possible way to rearrange them such that they satisfy all conditions is [3,-2,1,-5,2,-4].
    +Other ways such as [1,-2,2,-5,3,-4], [3,1,2,-2,-5,-4], [-2,3,-5,1,-4,2] are incorrect because they do not satisfy one or more conditions.  
    +
    + +

    Example 2:

    + +
    +Input: nums = [-1,1]
    +Output: [1,-1]
    +Explanation:
    +1 is the only positive integer and -1 the only negative integer in nums.
    +So nums is rearranged to [1,-1].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= nums.length <= 2 * 105
    • +
    • nums.length is even
    • +
    • 1 <= |nums[i]| <= 105
    • +
    • nums consists of equal number of positive and negative integers.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Divide the array into two parts- one comprising of only positive integers and the other of negative integers. +
    + +
    +Hint 2 +Merge the two parts to get the resultant array. +
    diff --git a/problems/rearrange-spaces-between-words/README.md b/problems/rearrange-spaces-between-words/README.md index bd77b2d6f..96a5b97d5 100644 --- a/problems/rearrange-spaces-between-words/README.md +++ b/problems/rearrange-spaces-between-words/README.md @@ -23,7 +23,7 @@
     Input: text = "  this   is  a sentence "
     Output: "this   is   a   sentence"
    -Explanation: There are a total of 9 spaces and 4 words. We can evenly divide the 9 spaces between the words: 9 / (4-1) = 3 spaces.
    +Explanation: There are a total of 9 spaces and 4 words. We can evenly divide the 9 spaces between the words: 9 / (4-1) = 3 spaces.
     

    Example 2:

    @@ -31,28 +31,7 @@
     Input: text = " practice   makes   perfect"
     Output: "practice   makes   perfect "
    -Explanation: There are a total of 7 spaces and 3 words. 7 / (3-1) = 3 spaces plus 1 extra space. We place this extra space at the end of the string.
    -
    - -

    Example 3:

    - -
    -Input: text = "hello   world"
    -Output: "hello   world"
    -
    - -

    Example 4:

    - -
    -Input: text = "  walks  udp package   into  bar a"
    -Output: "walks  udp  package  into  bar  a "
    -
    - -

    Example 5:

    - -
    -Input: text = "a"
    -Output: "a"
    +Explanation: There are a total of 7 spaces and 3 words. 7 / (3-1) = 3 spaces plus 1 extra space. We place this extra space at the end of the string.
     

     

    @@ -60,13 +39,16 @@
    • 1 <= text.length <= 100
    • -
    • text consists of lowercase English letters and ' '.
    • -
    • text contains at least one word.
    • +
    • text consists of lowercase English letters and ' '.
    • +
    • text contains at least one word.
    ### Related Topics [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Text Justification](../text-justification) (Hard) + ### Hints
    Hint 1 diff --git a/problems/rearrange-string-k-distance-apart/README.md b/problems/rearrange-string-k-distance-apart/README.md index 491309082..831175238 100644 --- a/problems/rearrange-string-k-distance-apart/README.md +++ b/problems/rearrange-string-k-distance-apart/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-numbers-with-unique-digits "Count Numbers with Unique Digits") diff --git a/problems/rearrange-words-in-a-sentence/README.md b/problems/rearrange-words-in-a-sentence/README.md index 5a62d6e06..b920aad7d 100644 --- a/problems/rearrange-words-in-a-sentence/README.md +++ b/problems/rearrange-words-in-a-sentence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-students-doing-homework-at-a-given-time "Number of Students Doing Homework at a Given Time") diff --git a/problems/recover-the-original-array/README.md b/problems/recover-the-original-array/README.md new file mode 100644 index 000000000..31c4a2224 --- /dev/null +++ b/problems/recover-the-original-array/README.md @@ -0,0 +1,95 @@ + + + + + + + +[< Previous](../intervals-between-identical-elements "Intervals Between Identical Elements") +                 +[Next >](../minimum-operations-to-remove-adjacent-ones-in-matrix "Minimum Operations to Remove Adjacent Ones in Matrix") + +## [2122. Recover the Original Array (Hard)](https://leetcode.com/problems/recover-the-original-array "还原原数组") + +

    Alice had a 0-indexed array arr consisting of n positive integers. She chose an arbitrary positive integer k and created two new 0-indexed integer arrays lower and higher in the following manner:

    + +
      +
    1. lower[i] = arr[i] - k, for every index i where 0 <= i < n
    2. +
    3. higher[i] = arr[i] + k, for every index i where 0 <= i < n
    4. +
    + +

    Unfortunately, Alice lost all three arrays. However, she remembers the integers that were present in the arrays lower and higher, but not the array each integer belonged to. Help Alice and recover the original array.

    + +

    Given an array nums consisting of 2n integers, where exactly n of the integers were present in lower and the remaining in higher, return the original array arr. In case the answer is not unique, return any valid array.

    + +

    Note: The test cases are generated such that there exists at least one valid array arr.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [2,10,6,4,8,12]
    +Output: [3,7,11]
    +Explanation:
    +If arr = [3,7,11] and k = 1, we get lower = [2,6,10] and higher = [4,8,12].
    +Combining lower and higher gives us [2,6,10,4,8,12], which is a permutation of nums.
    +Another valid possibility is that arr = [5,7,9] and k = 3. In that case, lower = [2,4,6] and higher = [8,10,12]. 
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,1,3,3]
    +Output: [2,2]
    +Explanation:
    +If arr = [2,2] and k = 1, we get lower = [1,1] and higher = [3,3].
    +Combining lower and higher gives us [1,1,3,3], which is equal to nums.
    +Note that arr cannot be [1,3] because in that case, the only possible way to obtain [1,1,3,3] is with k = 0.
    +This is invalid since k must be positive.
    +
    + +

    Example 3:

    + +
    +Input: nums = [5,435]
    +Output: [220]
    +Explanation:
    +The only possible combination is arr = [220] and k = 215. Using them, we get lower = [5] and higher = [435].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 * n == nums.length
    • +
    • 1 <= n <= 1000
    • +
    • 1 <= nums[i] <= 109
    • +
    • The test cases are generated such that there exists at least one valid array arr.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +If we fix the value of k, how can we check if an original array exists for the fixed k? +
    + +
    +Hint 2 +The smallest value of nums is obtained by subtracting k from the smallest value of the original array. How can we use this to reduce the search space for finding a valid k? +
    + +
    +Hint 3 +You can compute every possible k by using the smallest value of nums (as lower[i]) against every other value in nums (as the corresponding higher[i]). +
    + +
    +Hint 4 +For every computed k, greedily pair up the values in nums. This can be done sorting nums, then using a map to store previous values and searching that map for a corresponding lower[i] for the current nums[j] (as higher[i]). +
    diff --git a/problems/rectangle-overlap/README.md b/problems/rectangle-overlap/README.md index 00ff72825..e5649b1d5 100644 --- a/problems/rectangle-overlap/README.md +++ b/problems/rectangle-overlap/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../image-overlap "Image Overlap") @@ -39,8 +39,8 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] ### Similar Questions 1. [Rectangle Area](../rectangle-area) (Medium) diff --git a/problems/rectangles-area/README.md b/problems/rectangles-area/README.md index f63085a0a..f64effc69 100644 --- a/problems/rectangles-area/README.md +++ b/problems/rectangles-area/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-dot-product-of-two-subsequences "Max Dot Product of Two Subsequences") diff --git a/problems/reduce-array-size-to-the-half/README.md b/problems/reduce-array-size-to-the-half/README.md index 3667f864d..7dcae1f59 100644 --- a/problems/reduce-array-size-to-the-half/README.md +++ b/problems/reduce-array-size-to-the-half/README.md @@ -23,7 +23,7 @@ Output: 2 Explanation: Choosing {3,7} will make the new array [5,5,5,2,2] which has size 5 (i.e equal to half of the size of the old array). Possible sets of size 2 are {3,5},{3,2},{5,2}. -Choosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] which has size greater than half of the size of the old array. +Choosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] which has a size greater than half of the size of the old array.

    Example 2:

    @@ -34,40 +34,19 @@ Choosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] Explanation: The only possible set you can choose is {7}. This will make the new array empty. -

    Example 3:

    - -
    -Input: arr = [1,9]
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: arr = [1000,1000,3,7]
    -Output: 1
    -
    - -

    Example 5:

    - -
    -Input: arr = [1,2,3,4,5,6,7,8,9,10]
    -Output: 5
    -
    -

     

    Constraints:

      -
    • 1 <= arr.length <= 105
    • +
    • 2 <= arr.length <= 105
    • arr.length is even.
    • 1 <= arr[i] <= 105
    ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/reducing-dishes/README.md b/problems/reducing-dishes/README.md index 6e87b7e6c..c17b51662 100644 --- a/problems/reducing-dishes/README.md +++ b/problems/reducing-dishes/README.md @@ -41,14 +41,7 @@ Each dish is prepared in one unit of time.
     Input: satisfaction = [-1,-4,-5]
     Output: 0
    -Explanation: People don't like the dishes. No dish is prepared.
    -
    - -

    Example 4:

    - -
    -Input: satisfaction = [-2,5,-1,0,3,-3]
    -Output: 35
    +Explanation: People do not like the dishes. No dish is prepared.
     

     

    @@ -61,9 +54,9 @@ Each dish is prepared in one unit of time. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/reformat-phone-number/README.md b/problems/reformat-phone-number/README.md index 0ee2dbf14..d4dc85908 100644 --- a/problems/reformat-phone-number/README.md +++ b/problems/reformat-phone-number/README.md @@ -60,26 +60,12 @@ Step 3: There are 2 digits left, so put them in a single block of length 2. The Joining the blocks gives "123-456-78". -

    Example 4:

    - -
    -Input: number = "12"
    -Output: "12"
    -
    - -

    Example 5:

    - -
    -Input: number = "--17-5 229 35-39475 "
    -Output: "175-229-353-94-75"
    -
    -

     

    Constraints:

    • 2 <= number.length <= 100
    • -
    • number consists of digits and the characters '-' and ' '.
    • +
    • number consists of digits and the characters '-' and ' '.
    • There are at least two digits in number.
    diff --git a/problems/remove-all-ones-with-row-and-column-flips/README.md b/problems/remove-all-ones-with-row-and-column-flips/README.md new file mode 100644 index 000000000..f1857a910 --- /dev/null +++ b/problems/remove-all-ones-with-row-and-column-flips/README.md @@ -0,0 +1,46 @@ + + + + + + + +[< Previous](../maximum-employees-to-be-invited-to-a-meeting "Maximum Employees to Be Invited to a Meeting") +                 +[Next >](../capitalize-the-title "Capitalize the Title") + +## [2128. Remove All Ones With Row and Column Flips (Medium)](https://leetcode.com/problems/remove-all-ones-with-row-and-column-flips "") + + + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Does the order, in which you do the operations, matter? +
    + +
    +Hint 2 +No, it does not. An element will keep its original value if the number of operations done on it is even and vice versa. This also means that doing more than 1 operation on the same row or column is unproductive. +
    + +
    +Hint 3 +Try working backward, start with a matrix of all zeros and try to construct grid using operations. +
    + +
    +Hint 4 +Start with operations on columns, after doing them what do you notice about each row? +
    + +
    +Hint 5 +Each row is the exact same. If we then flip some rows, that leaves only two possible arrangements for each row: the same as the original or the opposite. +
    diff --git a/problems/remove-covered-intervals/README.md b/problems/remove-covered-intervals/README.md index b319a77a3..22a2a0ad3 100644 --- a/problems/remove-covered-intervals/README.md +++ b/problems/remove-covered-intervals/README.md @@ -23,7 +23,7 @@
     Input: intervals = [[1,4],[3,6],[2,8]]
     Output: 2
    -Explanation: Interval [3,6] is covered by [2,8], therefore it is removed.
    +Explanation: Interval [3,6] is covered by [2,8], therefore it is removed.
     

    Example 2:

    @@ -33,27 +33,6 @@ Output: 1 -

    Example 3:

    - -
    -Input: intervals = [[0,10],[5,12]]
    -Output: 2
    -
    - -

    Example 4:

    - -
    -Input: intervals = [[3,10],[4,10],[5,11]]
    -Output: 2
    -
    - -

    Example 5:

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

     

    Constraints:

    diff --git a/problems/remove-interval/README.md b/problems/remove-interval/README.md index 89f6001a6..bce96a0c0 100644 --- a/problems/remove-interval/README.md +++ b/problems/remove-interval/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../hexspeak "Hexspeak") diff --git a/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md b/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md index 2073e3fc8..11e59e27d 100644 --- a/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md +++ b/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md @@ -5,7 +5,7 @@ -[< Previous](../minimum-deletion-cost-to-avoid-repeating-letters "Minimum Deletion Cost to Avoid Repeating Letters") +[< Previous](../minimum-time-to-make-rope-colorful "Minimum Time to Make Rope Colorful")                  [Next >](../put-boxes-into-the-warehouse-ii "Put Boxes Into the Warehouse II") diff --git a/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md b/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md index c8499e554..2a1183730 100644 --- a/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md +++ b/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md @@ -46,14 +46,6 @@ No resulting array is strictly increasing, so return false. [1,1] is not strictly increasing, so return false. -

    Example 4:

    - -
    -Input: nums = [1,2,3]
    -Output: true
    -Explanation: [1,2,3] is already strictly increasing, so return true.
    -
    -

     

    Constraints:

    diff --git a/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md b/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md index 239cd5e5b..674f758f7 100644 --- a/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md +++ b/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md @@ -52,6 +52,9 @@ [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] +### Similar Questions + 1. [Delete N Nodes After M Nodes of a Linked List](../delete-n-nodes-after-m-nodes-of-a-linked-list) (Easy) + ### Hints
    Hint 1 diff --git a/problems/removing-minimum-and-maximum-from-array/README.md b/problems/removing-minimum-and-maximum-from-array/README.md new file mode 100644 index 000000000..6a9d08876 --- /dev/null +++ b/problems/removing-minimum-and-maximum-from-array/README.md @@ -0,0 +1,94 @@ + + + + + + + +[< Previous](../k-radius-subarray-averages "K Radius Subarray Averages") +                 +[Next >](../find-all-people-with-secret "Find All People With Secret") + +## [2091. Removing Minimum and Maximum From Array (Medium)](https://leetcode.com/problems/removing-minimum-and-maximum-from-array "从数组中移除最大值和最小值") + +

    You are given a 0-indexed array of distinct integers nums.

    + +

    There is an element in nums that has the lowest value and an element that has the highest value. We call them the minimum and maximum respectively. Your goal is to remove both these elements from the array.

    + +

    A deletion is defined as either removing an element from the front of the array or removing an element from the back of the array.

    + +

    Return the minimum number of deletions it would take to remove both the minimum and maximum element from the array.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [2,10,7,5,4,1,8,6]
    +Output: 5
    +Explanation: 
    +The minimum element in the array is nums[5], which is 1.
    +The maximum element in the array is nums[1], which is 10.
    +We can remove both the minimum and maximum by removing 2 elements from the front and 3 elements from the back.
    +This results in 2 + 3 = 5 deletions, which is the minimum number possible.
    +
    + +

    Example 2:

    + +
    +Input: nums = [0,-4,19,1,8,-2,-3,5]
    +Output: 3
    +Explanation: 
    +The minimum element in the array is nums[1], which is -4.
    +The maximum element in the array is nums[2], which is 19.
    +We can remove both the minimum and maximum by removing 3 elements from the front.
    +This results in only 3 deletions, which is the minimum number possible.
    +
    + +

    Example 3:

    + +
    +Input: nums = [101]
    +Output: 1
    +Explanation:  
    +There is only one element in the array, which makes it both the minimum and maximum element.
    +We can remove it with 1 deletion.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • -105 <= nums[i] <= 105
    • +
    • The integers in nums are distinct.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +There can only be three scenarios for deletions such that both minimum and maximum elements are removed: +
    + +
    +Hint 2 +Scenario 1: Both elements are removed by only deleting from the front. +
    + +
    +Hint 3 +Scenario 2: Both elements are removed by only deleting from the back. +
    + +
    +Hint 4 +Scenario 3: Delete from the front to remove one of the elements, and delete from the back to remove the other element. +
    + +
    +Hint 5 +Compare which of the three scenarios results in the minimum number of moves. +
    diff --git a/problems/removing-minimum-number-of-magic-beans/README.md b/problems/removing-minimum-number-of-magic-beans/README.md new file mode 100644 index 000000000..0e495bb15 --- /dev/null +++ b/problems/removing-minimum-number-of-magic-beans/README.md @@ -0,0 +1,85 @@ + + + + + + + +[< Previous](../minimum-operations-to-make-the-array-alternating "Minimum Operations to Make the Array Alternating") +                 +[Next >](../maximum-and-sum-of-array "Maximum AND Sum of Array") + +## [2171. Removing Minimum Number of Magic Beans (Medium)](https://leetcode.com/problems/removing-minimum-number-of-magic-beans "拿出最少数目的魔法豆") + +

    You are given an array of positive integers beans, where each integer represents the number of magic beans found in a particular magic bag.

    + +

    Remove any number of beans (possibly none) from each bag such that the number of beans in each remaining non-empty bag (still containing at least one bean) is equal. Once a bean has been removed from a bag, you are not allowed to return it to any of the bags.

    + +

    Return the minimum number of magic beans that you have to remove.

    + +

     

    +

    Example 1:

    + +
    +Input: beans = [4,1,6,5]
    +Output: 4
    +Explanation: 
    +- We remove 1 bean from the bag with only 1 bean.
    +  This results in the remaining bags: [4,0,6,5]
    +- Then we remove 2 beans from the bag with 6 beans.
    +  This results in the remaining bags: [4,0,4,5]
    +- Then we remove 1 bean from the bag with 5 beans.
    +  This results in the remaining bags: [4,0,4,4]
    +We removed a total of 1 + 2 + 1 = 4 beans to make the remaining non-empty bags have an equal number of beans.
    +There are no other solutions that remove 4 beans or fewer.
    +
    + +

    Example 2:

    + +
    +Input: beans = [2,10,3,2]
    +Output: 7
    +Explanation:
    +- We remove 2 beans from one of the bags with 2 beans.
    +  This results in the remaining bags: [0,10,3,2]
    +- Then we remove 2 beans from the other bag with 2 beans.
    +  This results in the remaining bags: [0,10,3,0]
    +- Then we remove 3 beans from the bag with 3 beans. 
    +  This results in the remaining bags: [0,10,0,0]
    +We removed a total of 2 + 2 + 3 = 7 beans to make the remaining non-empty bags have an equal number of beans.
    +There are no other solutions that removes 7 beans or fewer.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= beans.length <= 105
    • +
    • 1 <= beans[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Notice that if we choose to make x bags of beans empty, we should choose the x bags with the least amount of beans. +
    + +
    +Hint 2 +Notice that if the minimum number of beans in a non-empty bag is m, then the best way to make all bags have an equal amount of beans is to reduce all the bags to have m beans. +
    + +
    +Hint 3 +Can we iterate over how many bags we should remove and choose the one that minimizes the total amount of beans to remove? +
    + +
    +Hint 4 +Sort the bags of beans first. +
    diff --git a/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md b/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md index 192f235ee..6743b154d 100644 --- a/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md +++ b/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts "Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts") diff --git a/problems/repeated-string-match/README.md b/problems/repeated-string-match/README.md index 508494d61..49ac83fce 100644 --- a/problems/repeated-string-match/README.md +++ b/problems/repeated-string-match/README.md @@ -11,9 +11,9 @@ ## [686. Repeated String Match (Medium)](https://leetcode.com/problems/repeated-string-match "重复叠加字符串匹配") -

    Given two strings a and b, return the minimum number of times you should repeat string a so that string b is a substring of it. If it is impossible for b​​​​​​ to be a substring of a after repeating it, return -1.

    +

    Given two strings a and b, return the minimum number of times you should repeat string a so that string b is a substring of it. If it is impossible for b​​​​​​ to be a substring of a after repeating it, return -1.

    -

    Notice: string "abc" repeated 0 times is "",  repeated 1 time is "abc" and repeated 2 times is "abcabc".

    +

    Notice: string "abc" repeated 0 times is "", repeated 1 time is "abc" and repeated 2 times is "abcabc".

     

    Example 1:

    @@ -31,27 +31,12 @@ Output: 2 -

    Example 3:

    - -
    -Input: a = "a", b = "a"
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: a = "abc", b = "wxyz"
    -Output: -1
    -
    -

     

    Constraints:

      -
    • 1 <= a.length <= 104
    • -
    • 1 <= b.length <= 104
    • -
    • a and b consist of lower-case English letters.
    • +
    • 1 <= a.length, b.length <= 104
    • +
    • a and b consist of lowercase English letters.
    ### Related Topics diff --git a/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md b/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md index 42bc3386d..e9aadef5e 100644 --- a/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md +++ b/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md @@ -23,28 +23,15 @@
     Input: s = "?zs"
     Output: "azs"
    -Explanation: There are 25 solutions for this problem. From "azs" to "yzs", all are valid. Only "z" is an invalid modification as the string will consist of consecutive repeating characters in "zzs".
    +Explanation: There are 25 solutions for this problem. From "azs" to "yzs", all are valid. Only "z" is an invalid modification as the string will consist of consecutive repeating characters in "zzs". +

    Example 2:

     Input: s = "ubv?w"
     Output: "ubvaw"
    -Explanation: There are 24 solutions for this problem. Only "v" and "w" are invalid modifications as the strings will consist of consecutive repeating characters in "ubvvw" and "ubvww".
    -
    - -

    Example 3:

    - -
    -Input: s = "j?qg??b"
    -Output: "jaqgacb"
    -
    - -

    Example 4:

    - -
    -Input: s = "??yw?ipkj?"
    -Output: "acywaipkja"
    +Explanation: There are 24 solutions for this problem. Only "v" and "w" are invalid modifications as the strings will consist of consecutive repeating characters in "ubvvw" and "ubvww".
     

     

    diff --git a/problems/reported-posts-ii/README.md b/problems/reported-posts-ii/README.md index b14a7515b..bd1a28b4e 100644 --- a/problems/reported-posts-ii/README.md +++ b/problems/reported-posts-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-of-absolute-value-expression "Maximum of Absolute Value Expression") diff --git a/problems/restore-the-array/README.md b/problems/restore-the-array/README.md index 570dbce5a..caa50f9a9 100644 --- a/problems/restore-the-array/README.md +++ b/problems/restore-the-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-k-th-lexicographical-string-of-all-happy-strings-of-length-n "The k-th Lexicographical String of All Happy Strings of Length n") @@ -40,21 +40,6 @@ Explanation: Possible arrays are [1317],[131,7],[13,17],[1,317],[13,1,7],[1,31,7],[1,3,17],[1,3,1,7] -

    Example 4:

    - -
    -Input: s = "2020", k = 30
    -Output: 1
    -Explanation: The only possible array is [20,20]. [2020] is invalid because 2020 > 30. [2,020] is ivalid because 020 contains leading zeros.
    -
    - -

    Example 5:

    - -
    -Input: s = "1234567890", k = 90
    -Output: 34
    -
    -

     

    Constraints:

    @@ -68,6 +53,9 @@ [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Number of Ways to Separate Numbers](../number-of-ways-to-separate-numbers) (Hard) + ### Hints
    Hint 1 diff --git a/problems/reverse-bits/README.md b/problems/reverse-bits/README.md index a613f07a4..37efcfc69 100644 --- a/problems/reverse-bits/README.md +++ b/problems/reverse-bits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rotate-array "Rotate Array") @@ -48,8 +48,8 @@

    Follow up: If this function is called many times, how would you optimize it?

    ### Related Topics - [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions 1. [Reverse Integer](../reverse-integer) (Medium) diff --git a/problems/reverse-linked-list/README.md b/problems/reverse-linked-list/README.md index 393cdb8d1..be9956cae 100644 --- a/problems/reverse-linked-list/README.md +++ b/problems/reverse-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../isomorphic-strings "Isomorphic Strings") @@ -47,10 +47,12 @@

    Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both?

    ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions 1. [Reverse Linked List II](../reverse-linked-list-ii) (Medium) 1. [Binary Tree Upside Down](../binary-tree-upside-down) (Medium) 1. [Palindrome Linked List](../palindrome-linked-list) (Easy) + 1. [Reverse Nodes in Even Length Groups](../reverse-nodes-in-even-length-groups) (Medium) + 1. [Maximum Twin Sum of a Linked List](../maximum-twin-sum-of-a-linked-list) (Medium) diff --git a/problems/reverse-nodes-in-even-length-groups/README.md b/problems/reverse-nodes-in-even-length-groups/README.md index 1acbfaf3b..ff39ee8c6 100644 --- a/problems/reverse-nodes-in-even-length-groups/README.md +++ b/problems/reverse-nodes-in-even-length-groups/README.md @@ -32,9 +32,9 @@ Input: head = [5,2,6,3,9,1,7,3,8,4] Output: [5,6,2,3,9,1,4,8,3,7] Explanation: -- The length of the first group is 1, which is odd, hence no reversal occurrs. +- The length of the first group is 1, which is odd, hence no reversal occurs. - The length of the second group is 2, which is even, hence the nodes are reversed. -- The length of the third group is 3, which is odd, hence no reversal occurrs. +- The length of the third group is 3, which is odd, hence no reversal occurs. - The length of the last group is 4, which is even, hence the nodes are reversed. @@ -44,9 +44,9 @@ Input: head = [1,1,0,6] Output: [1,0,1,6] Explanation: -- The length of the first group is 1. No reversal occurrs. +- The length of the first group is 1. No reversal occurs. - The length of the second group is 2. The nodes are reversed. -- The length of the last group is 1. No reversal occurrs. +- The length of the last group is 1. No reversal occurs.

    Example 3:

    @@ -55,29 +55,11 @@ Input: head = [1,1,0,6,5] Output: [1,0,1,5,6] Explanation: -- The length of the first group is 1. No reversal occurrs. +- The length of the first group is 1. No reversal occurs. - The length of the second group is 2. The nodes are reversed. - The length of the last group is 2. The nodes are reversed. -

    Example 4:

    - -
    -Input: head = [2,1]
    -Output: [2,1]
    -Explanation:
    -- The length of the first group is 1. No reversal occurrs.
    -- The length of the last group is 1. No reversal occurrs.
    -
    - -

    Example 5:

    - -
    -Input: head = [8]
    -Output: [8]
    -Explanation: There is only one group whose length is 1. No reversal occurrs.
    -
    -

     

    Constraints:

    diff --git a/problems/reverse-words-in-a-string/README.md b/problems/reverse-words-in-a-string/README.md index a42fabf98..0a2002fd0 100644 --- a/problems/reverse-words-in-a-string/README.md +++ b/problems/reverse-words-in-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../evaluate-reverse-polish-notation "Evaluate Reverse Polish Notation") @@ -43,20 +43,6 @@ Explanation: You need to reduce multiple spaces between two words to a single space in the reversed string. -

    Example 4:

    - -
    -Input: s = "  Bob    Loves  Alice   "
    -Output: "Alice Loves Bob"
    -
    - -

    Example 5:

    - -
    -Input: s = "Alice does not even like bob"
    -Output: "bob like even not does Alice"
    -
    -

     

    Constraints:

    diff --git a/problems/rings-and-rods/README.md b/problems/rings-and-rods/README.md new file mode 100644 index 000000000..3944e5b9c --- /dev/null +++ b/problems/rings-and-rods/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../sequentially-ordinal-rank-tracker "Sequentially Ordinal Rank Tracker") +                 +[Next >](../sum-of-subarray-ranges "Sum of Subarray Ranges") + +## [2103. Rings and Rods (Easy)](https://leetcode.com/problems/rings-and-rods "环和杆") + +

    There are n rings and each ring is either red, green, or blue. The rings are distributed across ten rods labeled from 0 to 9.

    + +

    You are given a string rings of length 2n that describes the n rings that are placed onto the rods. Every two characters in rings forms a color-position pair that is used to describe each ring where:

    + +
      +
    • The first character of the ith pair denotes the ith ring's color ('R', 'G', 'B').
    • +
    • The second character of the ith pair denotes the rod that the ith ring is placed on ('0' to '9').
    • +
    + +

    For example, "R3G2B1" describes n == 3 rings: a red ring placed onto the rod labeled 3, a green ring placed onto the rod labeled 2, and a blue ring placed onto the rod labeled 1.

    + +

    Return the number of rods that have all three colors of rings on them.

    + +

     

    +

    Example 1:

    + +
    +Input: rings = "B0B6G0R6R0R6G9"
    +Output: 1
    +Explanation: 
    +- The rod labeled 0 holds 3 rings with all colors: red, green, and blue.
    +- The rod labeled 6 holds 3 rings, but it only has red and blue.
    +- The rod labeled 9 holds only a green ring.
    +Thus, the number of rods with all three colors is 1.
    +
    + +

    Example 2:

    + +
    +Input: rings = "B0R0G0R9R0B0G0"
    +Output: 1
    +Explanation: 
    +- The rod labeled 0 holds 6 rings with all colors: red, green, and blue.
    +- The rod labeled 9 holds only a red ring.
    +Thus, the number of rods with all three colors is 1.
    +
    + +

    Example 3:

    + +
    +Input: rings = "G4"
    +Output: 0
    +Explanation: 
    +Only one ring is given. Thus, no rods have all three colors.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • rings.length == 2 * n
    • +
    • 1 <= n <= 100
    • +
    • rings[i] where i is even is either 'R', 'G', or 'B' (0-indexed).
    • +
    • rings[i] where i is odd is a digit from '0' to '9' (0-indexed).
    • +
    + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +For every rod, look through ‘rings’ to see if the rod contains all colors. +
    + +
    +Hint 2 +Create 3 booleans, 1 for each color, to store if that color is present for the current rod. If all 3 are true after looking through the string, then the rod contains all the colors. +
    diff --git a/problems/rotate-array/README.md b/problems/rotate-array/README.md index cf4d0ec51..9b80793b2 100644 --- a/problems/rotate-array/README.md +++ b/problems/rotate-array/README.md @@ -1,15 +1,15 @@ - - - + + + [< Previous](../best-time-to-buy-and-sell-stock-iv "Best Time to Buy and Sell Stock IV")                  [Next >](../reverse-bits "Reverse Bits") -## [189. Rotate Array (Medium)](https://leetcode.com/problems/rotate-array "旋转数组") +## [189. Rotate Array (Medium)](https://leetcode.com/problems/rotate-array "轮转数组")

    Given an array, rotate the array to the right by k steps, where k is non-negative.

    diff --git a/problems/rotate-function/README.md b/problems/rotate-function/README.md index 56f6101fd..1dd719a63 100644 --- a/problems/rotate-function/README.md +++ b/problems/rotate-function/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-substring-with-at-least-k-repeating-characters "Longest Substring with At Least K Repeating Characters") diff --git a/problems/running-total-for-different-genders/README.md b/problems/running-total-for-different-genders/README.md index db8e732bc..107500405 100644 --- a/problems/running-total-for-different-genders/README.md +++ b/problems/running-total-for-different-genders/README.md @@ -76,6 +76,3 @@ Fifth day is 2020-01-07, Bajrang scored 7 points and the total score for the tea ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Last Person to Fit in the Bus](../last-person-to-fit-in-the-bus) (Medium) diff --git a/problems/russian-doll-envelopes/README.md b/problems/russian-doll-envelopes/README.md index de6f285d3..96062bae2 100644 --- a/problems/russian-doll-envelopes/README.md +++ b/problems/russian-doll-envelopes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-snake-game "Design Snake Game") @@ -39,9 +39,9 @@

    Constraints:

      -
    • 1 <= envelopes.length <= 5000
    • +
    • 1 <= envelopes.length <= 105
    • envelopes[i].length == 2
    • -
    • 1 <= wi, hi <= 104
    • +
    • 1 <= wi, hi <= 105
    ### Related Topics diff --git a/problems/sales-analysis-ii/README.md b/problems/sales-analysis-ii/README.md index 30e305088..c0995e4d1 100644 --- a/problems/sales-analysis-ii/README.md +++ b/problems/sales-analysis-ii/README.md @@ -77,3 +77,7 @@ The buyer with id 1 bought an S8 but didn't buy an iPhone. The buyer with id ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Sales Analysis I](../sales-analysis-i) (Easy) + 1. [Sales Analysis III](../sales-analysis-iii) (Easy) diff --git a/problems/sales-by-day-of-the-week/README.md b/problems/sales-by-day-of-the-week/README.md index dcc18624a..753d7a48d 100644 --- a/problems/sales-by-day-of-the-week/README.md +++ b/problems/sales-by-day-of-the-week/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../allocate-mailboxes "Allocate Mailboxes") diff --git a/problems/search-insert-position/README.md b/problems/search-insert-position/README.md index b94c0636a..09a83df93 100644 --- a/problems/search-insert-position/README.md +++ b/problems/search-insert-position/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-first-and-last-position-of-element-in-sorted-array "Find First and Last Position of Element in Sorted Array") @@ -17,21 +17,26 @@

     

    Example 1:

    -
    Input: nums = [1,3,5,6], target = 5
    +
    +
    +Input: nums = [1,3,5,6], target = 5
     Output: 2
    -

    Example 2:

    -
    Input: nums = [1,3,5,6], target = 2
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,3,5,6], target = 2
     Output: 1
    -

    Example 3:

    -
    Input: nums = [1,3,5,6], target = 7
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,3,5,6], target = 7
     Output: 4
    -

    Example 4:

    -
    Input: nums = [1,3,5,6], target = 0
    -Output: 0
    -

    Example 5:

    -
    Input: nums = [1], target = 0
    -Output: 0
     
    +

     

    Constraints:

    diff --git a/problems/search-suggestions-system/README.md b/problems/search-suggestions-system/README.md index e572da055..be6fd4f4d 100644 --- a/problems/search-suggestions-system/README.md +++ b/problems/search-suggestions-system/README.md @@ -11,9 +11,11 @@ ## [1268. Search Suggestions System (Medium)](https://leetcode.com/problems/search-suggestions-system "搜索推荐系统") -

    Given an array of strings products and a string searchWord. We want to design a system that suggests at most three product names from products after each character of searchWord is typed. Suggested products should have common prefix with the searchWord. If there are more than three products with a common prefix return the three lexicographically minimums products.

    +

    You are given an array of strings products and a string searchWord.

    -

    Return list of lists of the suggested products after each character of searchWord is typed. 

    +

    Design a system that suggests at most three product names from products after each character of searchWord is typed. Suggested products should have common prefix with searchWord. If there are more than three products with a common prefix return the three lexicographically minimums products.

    + +

    Return a list of lists of the suggested products after each character of searchWord is typed.

     

    Example 1:

    @@ -46,23 +48,17 @@ After typing mou, mous and mouse the system suggests ["mouse","mo Output: [["baggage","bags","banner"],["baggage","bags","banner"],["baggage","bags"],["bags"]]
    -

    Example 4:

    - -
    -Input: products = ["havana"], searchWord = "tatiana"
    -Output: [[],[],[],[],[],[],[]]
    -
    -

     

    Constraints:

    • 1 <= products.length <= 1000
    • -
    • There are no repeated elements in products.
    • -
    • 1 <= Σ products[i].length <= 2 * 10^4
    • -
    • All characters of products[i] are lower-case English letters.
    • +
    • 1 <= products[i].length <= 3000
    • +
    • 1 <= sum(products[i].length) <= 2 * 104
    • +
    • All the strings of products are unique.
    • +
    • products[i] consists of lowercase English letters.
    • 1 <= searchWord.length <= 1000
    • -
    • All characters of searchWord are lower-case English letters.
    • +
    • searchWord consists of lowercase English letters.
    ### Related Topics diff --git a/problems/second-highest-salary/README.md b/problems/second-highest-salary/README.md index 6f9a61f07..6cb8a3e24 100644 --- a/problems/second-highest-salary/README.md +++ b/problems/second-highest-salary/README.md @@ -1,35 +1,71 @@ - - - + + + [< Previous](../combine-two-tables "Combine Two Tables")                  [Next >](../nth-highest-salary "Nth Highest Salary") -## [176. Second Highest Salary (Easy)](https://leetcode.com/problems/second-highest-salary "第二高的薪水") +## [176. Second Highest Salary (Medium)](https://leetcode.com/problems/second-highest-salary "第二高的薪水") -

    Write a SQL query to get the second highest salary from the Employee table.

    +

    Table: Employee

    ++-------------+------+
    +| Column Name | Type |
    ++-------------+------+
    +| id          | int  |
    +| salary      | int  |
    ++-------------+------+
    +id is the primary key column for this table.
    +Each row of this table contains information about the salary of an employee.
    +
    + +

     

    + +

    Write an SQL query to report the second highest salary from the Employee table. If there is no second highest salary, the query should report null.

    + +

    The query result format is in the following example.

    + +

     

    +

    Example 1:

    + +
    +Input: 
    +Employee table:
     +----+--------+
    -| Id | Salary |
    +| id | salary |
     +----+--------+
     | 1  | 100    |
     | 2  | 200    |
     | 3  | 300    |
     +----+--------+
    +Output: 
    ++---------------------+
    +| SecondHighestSalary |
    ++---------------------+
    +| 200                 |
    ++---------------------+
     
    -

    For example, given the above Employee table, the query should return 200 as the second highest salary. If there is no second highest salary, then the query should return null.

    +

    Example 2:

    +Input: 
    +Employee table:
    ++----+--------+
    +| id | salary |
    ++----+--------+
    +| 1  | 100    |
    ++----+--------+
    +Output: 
     +---------------------+
     | SecondHighestSalary |
     +---------------------+
    -| 200                 |
    +| null                |
     +---------------------+
     
    diff --git a/problems/second-highest-salary/mysql_schemas.sql b/problems/second-highest-salary/mysql_schemas.sql index c08cc8bd5..f98a8511a 100644 --- a/problems/second-highest-salary/mysql_schemas.sql +++ b/problems/second-highest-salary/mysql_schemas.sql @@ -1,5 +1,5 @@ -Create table If Not Exists Employee (Id int, Salary int); +Create table If Not Exists Employee (id int, salary int); Truncate table Employee; -insert into Employee (Id, Salary) values ('1', '100'); -insert into Employee (Id, Salary) values ('2', '200'); -insert into Employee (Id, Salary) values ('3', '300'); +insert into Employee (id, salary) values ('1', '100'); +insert into Employee (id, salary) values ('2', '200'); +insert into Employee (id, salary) values ('3', '300'); diff --git a/problems/second-minimum-time-to-reach-destination/README.md b/problems/second-minimum-time-to-reach-destination/README.md index b6cd23da1..6511ed733 100644 --- a/problems/second-minimum-time-to-reach-destination/README.md +++ b/problems/second-minimum-time-to-reach-destination/README.md @@ -80,7 +80,6 @@ The second minimum time path is 1 -> 2 -> 1 -> 2 with time = 11 minutes ### Related Topics [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] - [[Array](../../tag/array/README.md)] [[Shortest Path](../../tag/shortest-path/README.md)] ### Hints diff --git a/problems/self-crossing/README.md b/problems/self-crossing/README.md index fdf7c5d0b..39f96b944 100644 --- a/problems/self-crossing/README.md +++ b/problems/self-crossing/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../increasing-triplet-subsequence "Increasing Triplet Subsequence") diff --git a/problems/sell-diminishing-valued-colored-balls/README.md b/problems/sell-diminishing-valued-colored-balls/README.md index 4f26b0d86..e010dd174 100644 --- a/problems/sell-diminishing-valued-colored-balls/README.md +++ b/problems/sell-diminishing-valued-colored-balls/README.md @@ -38,21 +38,6 @@ The maximum total value is 2 + 5 + 4 + 3 = 14. The maximum total value is 3 + 2 + 5 + 4 + 3 + 2 = 19. -

    Example 3:

    - -
    -Input: inventory = [2,8,4,10,6], orders = 20
    -Output: 110
    -
    - -

    Example 4:

    - -
    -Input: inventory = [1000000000], orders = 1000000000
    -Output: 21
    -Explanation: Sell the 1st color 1000000000 times for a total value of 500000000500000000. 500000000500000000 modulo 109 + 7 = 21.
    -
    -

     

    Constraints:

    diff --git a/problems/sentence-similarity-iii/README.md b/problems/sentence-similarity-iii/README.md index 02839ffad..45db111c7 100644 --- a/problems/sentence-similarity-iii/README.md +++ b/problems/sentence-similarity-iii/README.md @@ -42,13 +42,6 @@ Explanation: sentence2 can be turned to sentence1 by inserting "right now" at the end of the sentence. -

    Example 4:

    - -
    -Input: sentence1 = "Luky", sentence2 = "Lucccky"
    -Output: false
    -
    -

     

    Constraints:

    diff --git a/problems/sequentially-ordinal-rank-tracker/README.md b/problems/sequentially-ordinal-rank-tracker/README.md new file mode 100644 index 000000000..4b1402419 --- /dev/null +++ b/problems/sequentially-ordinal-rank-tracker/README.md @@ -0,0 +1,113 @@ + + + + + + + +[< Previous](../detonate-the-maximum-bombs "Detonate the Maximum Bombs") +                 +[Next >](../rings-and-rods "Rings and Rods") + +## [2102. Sequentially Ordinal Rank Tracker (Hard)](https://leetcode.com/problems/sequentially-ordinal-rank-tracker "序列顺序查询") + +

    A scenic location is represented by its name and attractiveness score, where name is a unique string among all locations and score is an integer. Locations can be ranked from the best to the worst. The higher the score, the better the location. If the scores of two locations are equal, then the location with the lexicographically smaller name is better.

    + +

    You are building a system that tracks the ranking of locations with the system initially starting with no locations. It supports:

    + +
      +
    • Adding scenic locations, one at a time.
    • +
    • Querying the ith best location of all locations already added, where i is the number of times the system has been queried (including the current query). +
        +
      • For example, when the system is queried for the 4th time, it returns the 4th best location of all locations already added.
      • +
      +
    • +
    + +

    Note that the test data are generated so that at any time, the number of queries does not exceed the number of locations added to the system.

    + +

    Implement the SORTracker class:

    + +
      +
    • SORTracker() Initializes the tracker system.
    • +
    • void add(string name, int score) Adds a scenic location with name and score to the system.
    • +
    • string get() Queries and returns the ith best location, where i is the number of times this method has been invoked (including this invocation).
    • +
    + +

     

    +

    Example 1:

    + +
    +Input
    +["SORTracker", "add", "add", "get", "add", "get", "add", "get", "add", "get", "add", "get", "get"]
    +[[], ["bradford", 2], ["branford", 3], [], ["alps", 2], [], ["orland", 2], [], ["orlando", 3], [], ["alpine", 2], [], []]
    +Output
    +[null, null, null, "branford", null, "alps", null, "bradford", null, "bradford", null, "bradford", "orland"]
    +
    +Explanation
    +SORTracker tracker = new SORTracker(); // Initialize the tracker system.
    +tracker.add("bradford", 2); // Add location with name="bradford" and score=2 to the system.
    +tracker.add("branford", 3); // Add location with name="branford" and score=3 to the system.
    +tracker.get();              // The sorted locations, from best to worst, are: branford, bradford.
    +                            // Note that branford precedes bradford due to its higher score (3 > 2).
    +                            // This is the 1st time get() is called, so return the best location: "branford".
    +tracker.add("alps", 2);     // Add location with name="alps" and score=2 to the system.
    +tracker.get();              // Sorted locations: branford, alps, bradford.
    +                            // Note that alps precedes bradford even though they have the same score (2).
    +                            // This is because "alps" is lexicographically smaller than "bradford".
    +                            // Return the 2nd best location "alps", as it is the 2nd time get() is called.
    +tracker.add("orland", 2);   // Add location with name="orland" and score=2 to the system.
    +tracker.get();              // Sorted locations: branford, alps, bradford, orland.
    +                            // Return "bradford", as it is the 3rd time get() is called.
    +tracker.add("orlando", 3);  // Add location with name="orlando" and score=3 to the system.
    +tracker.get();              // Sorted locations: branford, orlando, alps, bradford, orland.
    +                            // Return "bradford".
    +tracker.add("alpine", 2);   // Add location with name="alpine" and score=2 to the system.
    +tracker.get();              // Sorted locations: branford, orlando, alpine, alps, bradford, orland.
    +                            // Return "bradford".
    +tracker.get();              // Sorted locations: branford, orlando, alpine, alps, bradford, orland.
    +                            // Return "orland".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • name consists of lowercase English letters, and is unique among all locations.
    • +
    • 1 <= name.length <= 10
    • +
    • 1 <= score <= 105
    • +
    • At any time, the number of calls to get does not exceed the number of calls to add.
    • +
    • At most 4 * 104 calls in total will be made to add and get.
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +If the problem were to find the median of a stream of scenery locations while they are being added, can you solve it? +
    + +
    +Hint 2 +We can use a similar approach as an optimization to avoid repeated sorting. +
    + +
    +Hint 3 +Employ two heaps: left heap and right heap. The left heap is a max-heap, and the right heap is a min-heap. The size of the left heap is k + 1 (best locations), where k is the number of times the get method was invoked. The other locations are maintained in the right heap. +
    + +
    +Hint 4 +Every time when add is being called, we add it to the left heap. If the size of the left heap exceeds k + 1, we move the head element to the right heap. +
    + +
    +Hint 5 +When the get method is invoked again (the k + 1 time it is invoked), we can return the head element of the left heap. But before returning it, if the right heap is not empty, we maintain the left heap to have the best k + 2 items by moving the best location from the right heap to the left heap. +
    diff --git a/problems/set-matrix-zeroes/README.md b/problems/set-matrix-zeroes/README.md index f2ba94241..f3c767924 100644 --- a/problems/set-matrix-zeroes/README.md +++ b/problems/set-matrix-zeroes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../edit-distance "Edit Distance") @@ -11,7 +11,7 @@ ## [73. Set Matrix Zeroes (Medium)](https://leetcode.com/problems/set-matrix-zeroes "矩阵置零") -

    Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's, and return the matrix.

    +

    Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's.

    You must do it in place.

    @@ -56,6 +56,8 @@ ### Similar Questions 1. [Game of Life](../game-of-life) (Medium) + 1. [Number of Laser Beams in a Bank](../number-of-laser-beams-in-a-bank) (Medium) + 1. [Minimum Operations to Remove Adjacent Ones in Matrix](../minimum-operations-to-remove-adjacent-ones-in-matrix) (Hard) ### Hints
    diff --git a/problems/set-mismatch/README.md b/problems/set-mismatch/README.md index 4fd90d16f..afde337fb 100644 --- a/problems/set-mismatch/README.md +++ b/problems/set-mismatch/README.md @@ -34,9 +34,9 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Similar Questions diff --git a/problems/shift-2d-grid/README.md b/problems/shift-2d-grid/README.md index 2e724740e..3474f127a 100644 --- a/problems/shift-2d-grid/README.md +++ b/problems/shift-2d-grid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../handshakes-that-dont-cross "Handshakes That Don't Cross") diff --git a/problems/shortest-bridge/README.md b/problems/shortest-bridge/README.md index c99a6492f..c28bec2ab 100644 --- a/problems/shortest-bridge/README.md +++ b/problems/shortest-bridge/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-recent-calls "Number of Recent Calls") @@ -11,11 +11,13 @@ ## [934. Shortest Bridge (Medium)](https://leetcode.com/problems/shortest-bridge "最短的桥") -

    In a given 2D binary array grid, there are two islands.  (An island is a 4-directionally connected group of 1s not connected to any other 1s.)

    +

    You are given an n x n binary matrix grid where 1 represents land and 0 represents water.

    -

    Now, we may change 0s to 1s so as to connect the two islands together to form 1 island.

    +

    An island is a 4-directionally connected group of 1's not connected to any other 1's. There are exactly two islands in grid.

    -

    Return the smallest number of 0s that must be flipped.  (It is guaranteed that the answer is at least 1.)

    +

    You may change 0's to 1's to connect the two islands to form one island.

    + +

    Return the smallest number of 0's you must flip to connect the two islands.

     

    Example 1:

    @@ -43,8 +45,10 @@

    Constraints:

      -
    • 2 <= grid.length == grid[0].length <= 100
    • -
    • grid[i][j] == 0 or grid[i][j] == 1
    • +
    • n == grid.length == grid[i].length
    • +
    • 2 <= n <= 100
    • +
    • grid[i][j] is either 0 or 1.
    • +
    • There are exactly two islands in grid.
    ### Related Topics diff --git a/problems/shortest-completing-word/README.md b/problems/shortest-completing-word/README.md index 5501b8b5b..10eb3e10f 100644 --- a/problems/shortest-completing-word/README.md +++ b/problems/shortest-completing-word/README.md @@ -41,27 +41,6 @@ Since "steps" is the only word containing all the letters, that is the Explanation: licensePlate only contains the letter 's'. All the words contain 's', but among these "pest", "stew", and "show" are shortest. The answer is "pest" because it is the word that appears earliest of the 3. -

    Example 3:

    - -
    -Input: licensePlate = "Ah71752", words = ["suggest","letter","of","husband","easy","education","drug","prevent","writer","old"]
    -Output: "husband"
    -
    - -

    Example 4:

    - -
    -Input: licensePlate = "OgEu755", words = ["enough","these","play","wide","wonder","box","arrive","money","tax","thus"]
    -Output: "enough"
    -
    - -

    Example 5:

    - -
    -Input: licensePlate = "iMSlpe4", words = ["claim","consumer","student","camera","public","never","wonder","simple","thought","use"]
    -Output: "simple"
    -
    -

     

    Constraints:

    @@ -74,6 +53,7 @@ Since "steps" is the only word containing all the letters, that is the ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/shortest-distance-from-all-buildings/README.md b/problems/shortest-distance-from-all-buildings/README.md index ee20e154f..d8508700c 100644 --- a/problems/shortest-distance-from-all-buildings/README.md +++ b/problems/shortest-distance-from-all-buildings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-duplicate-letters "Remove Duplicate Letters") diff --git a/problems/shortest-path-in-a-hidden-grid/README.md b/problems/shortest-path-in-a-hidden-grid/README.md index 9a8aae6c9..c519f5a97 100644 --- a/problems/shortest-path-in-a-hidden-grid/README.md +++ b/problems/shortest-path-in-a-hidden-grid/README.md @@ -19,6 +19,10 @@ [[Graph](../../tag/graph/README.md)] [[Interactive](../../tag/interactive/README.md)] +### Similar Questions + 1. [Robot Room Cleaner](../robot-room-cleaner) (Hard) + 1. [Minimum Path Cost in a Hidden Grid](../minimum-path-cost-in-a-hidden-grid) (Medium) + ### Hints
    Hint 1 diff --git a/problems/shortest-path-to-get-food/README.md b/problems/shortest-path-to-get-food/README.md index 1332ad811..d6251d5c9 100644 --- a/problems/shortest-path-to-get-food/README.md +++ b/problems/shortest-path-to-get-food/README.md @@ -14,10 +14,14 @@ ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [01 Matrix](../01-matrix) (Medium) + 1. [Shortest Path in a Grid with Obstacles Elimination](../shortest-path-in-a-grid-with-obstacles-elimination) (Hard) + ### Hints
    Hint 1 diff --git a/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md b/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md index 0c1a1106f..6af342eff 100644 --- a/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md +++ b/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md @@ -23,15 +23,16 @@
     Input: arr = [1,2,3,10,4,2,3,5]
     Output: 3
    -Explanation: The shortest subarray we can remove is [10,4,2] of length 3. The remaining elements after that will be [1,2,3,3,5] which are sorted.
    -Another correct solution is to remove the subarray [3,10,4].
    +Explanation: The shortest subarray we can remove is [10,4,2] of length 3. The remaining elements after that will be [1,2,3,3,5] which are sorted. +Another correct solution is to remove the subarray [3,10,4]. +

    Example 2:

     Input: arr = [5,4,3,2,1]
     Output: 4
    -Explanation: Since the array is strictly decreasing, we can only keep a single element. Therefore we need to remove a subarray of length 4, either [5,4,3,2] or [4,3,2,1].
    +Explanation: Since the array is strictly decreasing, we can only keep a single element. Therefore we need to remove a subarray of length 4, either [5,4,3,2] or [4,3,2,1].
     

    Example 3:

    @@ -39,14 +40,7 @@ Another correct solution is to remove the subarray [3,10,4].
     Input: arr = [1,2,3]
     Output: 0
    -Explanation: The array is already non-decreasing. We do not need to remove any elements.
    -
    - -

    Example 4:

    - -
    -Input: arr = [1]
    -Output: 0
    +Explanation: The array is already non-decreasing. We do not need to remove any elements.
     

     

    @@ -58,10 +52,10 @@ Another correct solution is to remove the subarray [3,10,4]. ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Stack](../../tag/stack/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints diff --git a/problems/shortest-way-to-form-string/README.md b/problems/shortest-way-to-form-string/README.md index 6a522ebee..2a8fb3a4b 100644 --- a/problems/shortest-way-to-form-string/README.md +++ b/problems/shortest-way-to-form-string/README.md @@ -51,13 +51,12 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### Similar Questions 1. [Is Subsequence](../is-subsequence) (Easy) - 1. [Number of Matching Subsequences](../number-of-matching-subsequences) (Medium) ### Hints
    diff --git a/problems/shuffle-string/README.md b/problems/shuffle-string/README.md index 83e038f81..ab3bf2124 100644 --- a/problems/shuffle-string/README.md +++ b/problems/shuffle-string/README.md @@ -7,13 +7,11 @@ [< Previous](../patients-with-a-condition "Patients With a Condition")                  -[Next >](../bulb-switcher-iv "Bulb Switcher IV") +[Next >](../minimum-suffix-flips "Minimum Suffix Flips") ## [1528. Shuffle String (Easy)](https://leetcode.com/problems/shuffle-string "重新排列字符串") -

    Given a string s and an integer array indices of the same length.

    - -

    The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.

    +

    You are given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.

    Return the shuffled string.

    @@ -34,36 +32,15 @@ Explanation: After shuffling, each character remains in its position. -

    Example 3:

    - -
    -Input: s = "aiohn", indices = [3,1,4,2,0]
    -Output: "nihao"
    -
    - -

    Example 4:

    - -
    -Input: s = "aaiougrt", indices = [4,0,2,6,7,3,1,5]
    -Output: "arigatou"
    -
    - -

    Example 5:

    - -
    -Input: s = "art", indices = [1,0,2]
    -Output: "rat"
    -
    -

     

    Constraints:

    • s.length == indices.length == n
    • 1 <= n <= 100
    • -
    • s contains only lower-case English letters.
    • -
    • 0 <= indices[i] < n
    • -
    • All values of indices are unique (i.e. indices is a permutation of the integers from 0 to n - 1).
    • +
    • s consists of only lowercase English letters.
    • +
    • 0 <= indices[i] < n
    • +
    • All values of indices are unique.
    ### Related Topics diff --git a/problems/shuffle-the-array/README.md b/problems/shuffle-the-array/README.md index 43679a3af..9180ca6d1 100644 --- a/problems/shuffle-the-array/README.md +++ b/problems/shuffle-the-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-all-the-lonely-nodes "Find All The Lonely Nodes") diff --git a/problems/simplify-path/README.md b/problems/simplify-path/README.md index 842c7792e..3e55de4ff 100644 --- a/problems/simplify-path/README.md +++ b/problems/simplify-path/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../climbing-stairs "Climbing Stairs") @@ -48,14 +48,7 @@
     Input: path = "/home//foo/"
     Output: "/home/foo"
    -Explanation: In the canonical path, multiple consecutive slashes are replaced by a single one.
    -
    - -

    Example 4:

    - -
    -Input: path = "/a/./b/../../c/"
    -Output: "/c"
    +Explanation: In the canonical path, multiple consecutive slashes are replaced by a single one.
     

     

    diff --git a/problems/single-row-keyboard/README.md b/problems/single-row-keyboard/README.md index dabe10b72..37330813a 100644 --- a/problems/single-row-keyboard/README.md +++ b/problems/single-row-keyboard/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../product-price-at-a-given-date "Product Price at a Given Date") diff --git a/problems/smallest-greater-multiple-made-of-two-digits/README.md b/problems/smallest-greater-multiple-made-of-two-digits/README.md index 2b62f9d3f..cd7e4bd7f 100644 --- a/problems/smallest-greater-multiple-made-of-two-digits/README.md +++ b/problems/smallest-greater-multiple-made-of-two-digits/README.md @@ -9,7 +9,7 @@                  [Next >](../reverse-prefix-of-word "Reverse Prefix of Word") -## [1999. Smallest Greater Multiple Made of Two Digits (Medium)](https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits "") +## [1999. Smallest Greater Multiple Made of Two Digits (Medium)](https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits "最小的仅由两个数组成的倍数") diff --git a/problems/smallest-index-with-equal-value/README.md b/problems/smallest-index-with-equal-value/README.md index 580d8f059..48843d83d 100644 --- a/problems/smallest-index-with-equal-value/README.md +++ b/problems/smallest-index-with-equal-value/README.md @@ -49,14 +49,6 @@ i=3: 3 mod 10 = 3 != nums[3]. Explanation: No index satisfies i mod 10 == nums[i]. -

    Example 4:

    - -
    -Input: nums = [2,1,3,5,2]
    -Output: 1
    -Explanation: 1 is the only index with i mod 10 == nums[i].
    -
    -

     

    Constraints:

    diff --git a/problems/smallest-range-covering-elements-from-k-lists/README.md b/problems/smallest-range-covering-elements-from-k-lists/README.md index c6b732dd2..7738b24d9 100644 --- a/problems/smallest-range-covering-elements-from-k-lists/README.md +++ b/problems/smallest-range-covering-elements-from-k-lists/README.md @@ -34,27 +34,6 @@ List 3: [5, 18, 22, 30], 22 is in range [20,24]. Output: [1,1] -

    Example 3:

    - -
    -Input: nums = [[10,10],[11,11]]
    -Output: [10,11]
    -
    - -

    Example 4:

    - -
    -Input: nums = [[10],[11]]
    -Output: [10,11]
    -
    - -

    Example 5:

    - -
    -Input: nums = [[1],[2],[3],[4],[5],[6],[7]]
    -Output: [1,7]
    -
    -

     

    Constraints:

    @@ -67,9 +46,12 @@ List 3: [5, 18, 22, 30], 22 is in range [20,24]. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Sorting](../../tag/sorting/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Similar Questions + 1. [Minimum Window Substring](../minimum-window-substring) (Hard) diff --git a/problems/smallest-string-starting-from-leaf/README.md b/problems/smallest-string-starting-from-leaf/README.md index 2cacbb7f1..9b0831735 100644 --- a/problems/smallest-string-starting-from-leaf/README.md +++ b/problems/smallest-string-starting-from-leaf/README.md @@ -54,9 +54,9 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[String](../../tag/string/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md index 8c29362be..f7479d7cc 100644 --- a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md +++ b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-path-to-get-all-keys "Shortest Path to Get All Keys") @@ -15,11 +15,9 @@

    Return the smallest subtree such that it contains all the deepest nodes in the original tree.

    -

    A node is called the deepest if it has the largest depth possible among any node in the entire tree.

    +

    A node is called the deepest if it has the largest depth possible among any node in the entire tree.

    -

    The subtree of a node is tree consisting of that node, plus the set of all descendants of that node.

    - -

    Note: This question is the same as 1123: https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/

    +

    The subtree of a node is a tree consisting of that node, plus the set of all descendants of that node.

     

    Example 1:

    @@ -54,12 +52,15 @@ Notice that nodes 5, 3 and 2 contain the deepest nodes in the tree but node 2 is
    • The number of nodes in the tree will be in the range [1, 500].
    • 0 <= Node.val <= 500
    • -
    • The values of the nodes in the tree are unique.
    • +
    • The values of the nodes in the tree are unique.
    +

     

    +

    Note: This question is the same as 1123: https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/

    + ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/smallest-value-of-the-rearranged-number/README.md b/problems/smallest-value-of-the-rearranged-number/README.md new file mode 100644 index 000000000..3d029d147 --- /dev/null +++ b/problems/smallest-value-of-the-rearranged-number/README.md @@ -0,0 +1,59 @@ + + + + + + + +[< Previous](../sort-even-and-odd-indices-independently "Sort Even and Odd Indices Independently") +                 +[Next >](../design-bitset "Design Bitset") + +## [2165. Smallest Value of the Rearranged Number (Medium)](https://leetcode.com/problems/smallest-value-of-the-rearranged-number "重排数字的最小值") + +

    You are given an integer num. Rearrange the digits of num such that its value is minimized and it does not contain any leading zeros.

    + +

    Return the rearranged number with minimal value.

    + +

    Note that the sign of the number does not change after rearranging the digits.

    + +

     

    +

    Example 1:

    + +
    +Input: num = 310
    +Output: 103
    +Explanation: The possible arrangements for the digits of 310 are 013, 031, 103, 130, 301, 310. 
    +The arrangement with the smallest value that does not contain any leading zeros is 103.
    +
    + +

    Example 2:

    + +
    +Input: num = -7605
    +Output: -7650
    +Explanation: Some possible arrangements for the digits of -7605 are -7650, -6705, -5076, -0567.
    +The arrangement with the smallest value that does not contain any leading zeros is -7650.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • -1015 <= num <= 1015
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +For positive numbers, the leading digit should be the smallest nonzero digit. Then the remaining digits follow in ascending order. +
    + +
    +Hint 2 +For negative numbers, the digits should be arranged in descending order. +
    diff --git a/problems/solving-questions-with-brainpower/README.md b/problems/solving-questions-with-brainpower/README.md new file mode 100644 index 000000000..91656b129 --- /dev/null +++ b/problems/solving-questions-with-brainpower/README.md @@ -0,0 +1,92 @@ + + + + + + + +[< Previous](../minimum-moves-to-reach-target-score "Minimum Moves to Reach Target Score") +                 +[Next >](../maximum-running-time-of-n-computers "Maximum Running Time of N Computers") + +## [2140. Solving Questions With Brainpower (Medium)](https://leetcode.com/problems/solving-questions-with-brainpower "解决智力问题") + +

    You are given a 0-indexed 2D integer array questions where questions[i] = [pointsi, brainpoweri].

    + +

    The array describes the questions of an exam, where you have to process the questions in order (i.e., starting from question 0) and make a decision whether to solve or skip each question. Solving question i will earn you pointsi points but you will be unable to solve each of the next brainpoweri questions. If you skip question i, you get to make the decision on the next question.

    + +
      +
    • For example, given questions = [[3, 2], [4, 3], [4, 4], [2, 5]]: +
        +
      • If question 0 is solved, you will earn 3 points but you will be unable to solve questions 1 and 2.
      • +
      • If instead, question 0 is skipped and question 1 is solved, you will earn 4 points but you will be unable to solve questions 2 and 3.
      • +
      +
    • +
    + +

    Return the maximum points you can earn for the exam.

    + +

     

    +

    Example 1:

    + +
    +Input: questions = [[3,2],[4,3],[4,4],[2,5]]
    +Output: 5
    +Explanation: The maximum points can be earned by solving questions 0 and 3.
    +- Solve question 0: Earn 3 points, will be unable to solve the next 2 questions
    +- Unable to solve questions 1 and 2
    +- Solve question 3: Earn 2 points
    +Total points earned: 3 + 2 = 5. There is no other way to earn 5 or more points.
    +
    + +

    Example 2:

    + +
    +Input: questions = [[1,1],[2,2],[3,3],[4,4],[5,5]]
    +Output: 7
    +Explanation: The maximum points can be earned by solving questions 1 and 4.
    +- Skip question 0
    +- Solve question 1: Earn 2 points, will be unable to solve the next 2 questions
    +- Unable to solve questions 2 and 3
    +- Solve question 4: Earn 5 points
    +Total points earned: 2 + 5 = 7. There is no other way to earn 7 or more points.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= questions.length <= 105
    • +
    • questions[i].length == 2
    • +
    • 1 <= pointsi, brainpoweri <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +For each question, we can either solve it or skip it. How can we use Dynamic Programming to decide the most optimal option for each problem? +
    + +
    +Hint 2 +We store for each question the maximum points we can earn if we started the exam on that question. +
    + +
    +Hint 3 +If we skip a question, then the answer for it will be the same as the answer for the next question. +
    + +
    +Hint 4 +If we solve a question, then the answer for it will be the points of the current question plus the answer for the next solvable question. +
    + +
    +Hint 5 +The maximum of these two values will be the answer to the current question. +
    diff --git a/problems/sort-an-array/README.md b/problems/sort-an-array/README.md index defec3b25..eade2aa53 100644 --- a/problems/sort-an-array/README.md +++ b/problems/sort-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../online-election "Online Election") @@ -32,9 +32,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] - [[Bucket Sort](../../tag/bucket-sort/README.md)] - [[Counting Sort](../../tag/counting-sort/README.md)] - [[Radix Sort](../../tag/radix-sort/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] [[Merge Sort](../../tag/merge-sort/README.md)] + [[Bucket Sort](../../tag/bucket-sort/README.md)] + [[Radix Sort](../../tag/radix-sort/README.md)] + [[Counting Sort](../../tag/counting-sort/README.md)] diff --git a/problems/sort-array-by-increasing-frequency/README.md b/problems/sort-array-by-increasing-frequency/README.md index 9ed63490c..e5cbf4b46 100644 --- a/problems/sort-array-by-increasing-frequency/README.md +++ b/problems/sort-array-by-increasing-frequency/README.md @@ -51,9 +51,6 @@ [[Hash Table](../../tag/hash-table/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Sort Characters By Frequency](../sort-characters-by-frequency) (Medium) - ### Hints
    Hint 1 diff --git a/problems/sort-even-and-odd-indices-independently/README.md b/problems/sort-even-and-odd-indices-independently/README.md new file mode 100644 index 000000000..9cf9fc559 --- /dev/null +++ b/problems/sort-even-and-odd-indices-independently/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../minimum-difference-in-sums-after-removal-of-elements "Minimum Difference in Sums After Removal of Elements") +                 +[Next >](../smallest-value-of-the-rearranged-number "Smallest Value of the Rearranged Number") + +## [2164. Sort Even and Odd Indices Independently (Easy)](https://leetcode.com/problems/sort-even-and-odd-indices-independently "对奇偶下标分别排序") + +

    You are given a 0-indexed integer array nums. Rearrange the values of nums according to the following rules:

    + +
      +
    1. Sort the values at odd indices of nums in non-increasing order. +
        +
      • For example, if nums = [4,1,2,3] before this step, it becomes [4,3,2,1] after. The values at odd indices 1 and 3 are sorted in non-increasing order.
      • +
      +
    2. +
    3. Sort the values at even indices of nums in non-decreasing order. +
        +
      • For example, if nums = [4,1,2,3] before this step, it becomes [2,1,4,3] after. The values at even indices 0 and 2 are sorted in non-decreasing order.
      • +
      +
    4. +
    + +

    Return the array formed after rearranging the values of nums.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [4,1,2,3]
    +Output: [2,3,4,1]
    +Explanation: 
    +First, we sort the values present at odd indices (1 and 3) in non-increasing order.
    +So, nums changes from [4,1,2,3] to [4,3,2,1].
    +Next, we sort the values present at even indices (0 and 2) in non-decreasing order.
    +So, nums changes from [4,1,2,3] to [2,3,4,1].
    +Thus, the array formed after rearranging the values is [2,3,4,1].
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,1]
    +Output: [2,1]
    +Explanation: 
    +Since there is exactly one odd index and one even index, no rearrangement of values takes place.
    +The resultant array formed is [2,1], which is the same as the initial array. 
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • 1 <= nums[i] <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Try to separate the elements at odd indices from the elements at even indices. +
    + +
    +Hint 2 +Sort the two groups of elements individually. +
    + +
    +Hint 3 +Combine them to form the resultant array. +
    diff --git a/problems/sort-integers-by-the-number-of-1-bits/README.md b/problems/sort-integers-by-the-number-of-1-bits/README.md index 21a136eaf..9ffba5ff0 100644 --- a/problems/sort-integers-by-the-number-of-1-bits/README.md +++ b/problems/sort-integers-by-the-number-of-1-bits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../activity-participants "Activity Participants") @@ -11,9 +11,9 @@ ## [1356. Sort Integers by The Number of 1 Bits (Easy)](https://leetcode.com/problems/sort-integers-by-the-number-of-1-bits "根据数字二进制下 1 的数目排序") -

    Given an integer array arr. You have to sort the integers in the array in ascending order by the number of 1's in their binary representation and in case of two or more integers have the same number of 1's you have to sort them in ascending order.

    +

    You are given an integer array arr. Sort the integers in the array in ascending order by the number of 1's in their binary representation and in case of two or more integers have the same number of 1's you have to sort them in ascending order.

    -

    Return the sorted array.

    +

    Return the array after sorting it.

     

    Example 1:

    @@ -36,33 +36,12 @@ The sorted array by bits is [0,1,2,4,8,3,5,6,7] Explantion: All integers have 1 bit in the binary representation, you should just sort them in ascending order. -

    Example 3:

    - -
    -Input: arr = [10000,10000]
    -Output: [10000,10000]
    -
    - -

    Example 4:

    - -
    -Input: arr = [2,3,5,7,11,13,17,19]
    -Output: [2,3,5,17,7,11,13,19]
    -
    - -

    Example 5:

    - -
    -Input: arr = [10,100,1000,10000]
    -Output: [10,100,10000,1000]
    -
    -

     

    Constraints:

    • 1 <= arr.length <= 500
    • -
    • 0 <= arr[i] <= 10^4
    • +
    • 0 <= arr[i] <= 104
    ### Related Topics @@ -71,6 +50,9 @@ The sorted array by bits is [0,1,2,4,8,3,5,6,7] [[Sorting](../../tag/sorting/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Find Subsequence of Length K With the Largest Sum](../find-subsequence-of-length-k-with-the-largest-sum) (Easy) + ### Hints
    Hint 1 diff --git a/problems/sort-integers-by-the-power-value/README.md b/problems/sort-integers-by-the-power-value/README.md index 80eefa8c1..7a507f22c 100644 --- a/problems/sort-integers-by-the-power-value/README.md +++ b/problems/sort-integers-by-the-power-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cinema-seat-allocation "Cinema Seat Allocation") @@ -11,20 +11,20 @@ ## [1387. Sort Integers by The Power Value (Medium)](https://leetcode.com/problems/sort-integers-by-the-power-value "将整数按权重排序") -

    The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps:

    +

    The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps:

    • if x is even then x = x / 2
    • if x is odd then x = 3 * x + 1
    -

    For example, the power of x = 3 is 7 because 3 needs 7 steps to become 1 (3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1).

    +

    For example, the power of x = 3 is 7 because 3 needs 7 steps to become 1 (3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1).

    Given three integers lo, hi and k. The task is to sort all integers in the interval [lo, hi] by the power value in ascending order, if two or more integers have the same power value sort them by ascending order.

    -

    Return the k-th integer in the range [lo, hi] sorted by the power value.

    +

    Return the kth integer in the range [lo, hi] sorted by the power value.

    -

    Notice that for any integer x (lo <= x <= hi) it is guaranteed that x will transform into 1 using these steps and that the power of x is will fit in 32 bit signed integer.

    +

    Notice that for any integer x (lo <= x <= hi) it is guaranteed that x will transform into 1 using these steps and that the power of x is will fit in a 32-bit signed integer.

     

    Example 1:

    @@ -42,13 +42,6 @@ Notice that 12 and 13 have the same power value and we sorted them in ascending

    Example 2:

    -
    -Input: lo = 1, hi = 1, k = 1
    -Output: 1
    -
    - -

    Example 3:

    -
     Input: lo = 7, hi = 11, k = 4
     Output: 7
    @@ -57,20 +50,6 @@ The interval sorted by power is [8, 10, 11, 7, 9].
     The fourth number in the sorted array is 7.
     
    -

    Example 4:

    - -
    -Input: lo = 10, hi = 20, k = 5
    -Output: 13
    -
    - -

    Example 5:

    - -
    -Input: lo = 1, hi = 1000, k = 777
    -Output: 570
    -
    -

     

    Constraints:

    @@ -80,8 +59,8 @@ The fourth number in the sorted array is 7. ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Memoization](../../tag/memoization/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/sort-linked-list-already-sorted-using-absolute-values/README.md b/problems/sort-linked-list-already-sorted-using-absolute-values/README.md index 787f6c9e5..452636892 100644 --- a/problems/sort-linked-list-already-sorted-using-absolute-values/README.md +++ b/problems/sort-linked-list-already-sorted-using-absolute-values/README.md @@ -9,7 +9,7 @@                  [Next >](../number-of-valid-words-in-a-sentence "Number of Valid Words in a Sentence") -## [2046. Sort Linked List Already Sorted Using Absolute Values (Medium)](https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values "") +## [2046. Sort Linked List Already Sorted Using Absolute Values (Medium)](https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values "给按照绝对值排序的链表排序") diff --git a/problems/sort-transformed-array/README.md b/problems/sort-transformed-array/README.md index 5e0bdca3e..6135d7d68 100644 --- a/problems/sort-transformed-array/README.md +++ b/problems/sort-transformed-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../logger-rate-limiter "Logger Rate Limiter") diff --git a/problems/sorting-the-sentence/README.md b/problems/sorting-the-sentence/README.md index bf34188c7..8f696c17d 100644 --- a/problems/sorting-the-sentence/README.md +++ b/problems/sorting-the-sentence/README.md @@ -53,6 +53,9 @@ [[String](../../tag/string/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Check if Numbers Are Ascending in a Sentence](../check-if-numbers-are-ascending-in-a-sentence) (Easy) + ### Hints
    Hint 1 diff --git a/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md b/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md index 421305253..acdb00777 100644 --- a/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md +++ b/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md @@ -46,13 +46,6 @@ x cannot be greater since there are only 2 numbers in nums. Explanation: There are 3 values that are greater than or equal to 3. -

    Example 4:

    - -
    -Input: nums = [3,6,7,7,0]
    -Output: -1
    -
    -

     

    Constraints:

    diff --git a/problems/special-positions-in-a-binary-matrix/README.md b/problems/special-positions-in-a-binary-matrix/README.md index a3e5ee837..3f8fe5cdd 100644 --- a/problems/special-positions-in-a-binary-matrix/README.md +++ b/problems/special-positions-in-a-binary-matrix/README.md @@ -11,60 +11,35 @@ ## [1582. Special Positions in a Binary Matrix (Easy)](https://leetcode.com/problems/special-positions-in-a-binary-matrix "二进制矩阵中的特殊位置") -

    Given a rows x cols matrix mat, where mat[i][j] is either 0 or 1, return the number of special positions in mat.

    +

    Given an m x n binary matrix mat, return the number of special positions in mat.

    -

    A position (i,j) is called special if mat[i][j] == 1 and all other elements in row i and column j are 0 (rows and columns are 0-indexed).

    +

    A position (i, j) is called special if mat[i][j] == 1 and all other elements in row i and column j are 0 (rows and columns are 0-indexed).

     

    Example 1:

    - +
    -Input: mat = [[1,0,0],
    -              [0,0,1],
    -              [1,0,0]]
    +Input: mat = [[1,0,0],[0,0,1],[1,0,0]]
     Output: 1
    -Explanation: (1,2) is a special position because mat[1][2] == 1 and all other elements in row 1 and column 2 are 0.
    +Explanation: (1, 2) is a special position because mat[1][2] == 1 and all other elements in row 1 and column 2 are 0.
     

    Example 2:

    - -
    -Input: mat = [[1,0,0],
    -              [0,1,0],
    -              [0,0,1]]
    -Output: 3
    -Explanation: (0,0), (1,1) and (2,2) are special positions. 
    -
    - -

    Example 3:

    - -
    -Input: mat = [[0,0,0,1],
    -              [1,0,0,0],
    -              [0,1,1,0],
    -              [0,0,0,0]]
    -Output: 2
    -
    - -

    Example 4:

    - +
    -Input: mat = [[0,0,0,0,0],
    -              [1,0,0,0,0],
    -              [0,1,0,0,0],
    -              [0,0,1,0,0],
    -              [0,0,0,1,1]]
    +Input: mat = [[1,0,0],[0,1,0],[0,0,1]]
     Output: 3
    +Explanation: (0, 0), (1, 1) and (2, 2) are special positions.
     

     

    Constraints:

      -
    • rows == mat.length
    • -
    • cols == mat[i].length
    • -
    • 1 <= rows, cols <= 100
    • -
    • mat[i][j] is 0 or 1.
    • +
    • m == mat.length
    • +
    • n == mat[i].length
    • +
    • 1 <= m, n <= 100
    • +
    • mat[i][j] is either 0 or 1.
    ### Related Topics diff --git a/problems/split-array-into-fibonacci-sequence/README.md b/problems/split-array-into-fibonacci-sequence/README.md index bf63e8c47..1d3c593ce 100644 --- a/problems/split-array-into-fibonacci-sequence/README.md +++ b/problems/split-array-into-fibonacci-sequence/README.md @@ -29,26 +29,20 @@

    Example 1:

    -Input: num = "123456579"
    -Output: [123,456,579]
    +Input: num = "1101111"
    +Output: [11,0,11,11]
    +Explanation: The output [110, 1, 111] would also be accepted.
     

    Example 2:

    -
    -Input: num = "11235813"
    -Output: [1,1,2,3,5,8,13]
    -
    - -

    Example 3:

    -
     Input: num = "112358130"
     Output: []
     Explanation: The task is impossible.
     
    -

    Example 4:

    +

    Example 3:

     Input: num = "0123"
    @@ -56,14 +50,6 @@
     Explanation: Leading zeroes are not allowed, so "01", "2", "3" is not valid.
     
    -

    Example 5:

    - -
    -Input: num = "1101111"
    -Output: [11,0,11,11]
    -Explanation: The output [11, 0, 11, 11] would also be accepted.
    -
    -

     

    Constraints:

    diff --git a/problems/split-array-with-same-average/README.md b/problems/split-array-with-same-average/README.md index 248dac471..f7cfa9d69 100644 --- a/problems/split-array-with-same-average/README.md +++ b/problems/split-array-with-same-average/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../unique-morse-code-words "Unique Morse Code Words") diff --git a/problems/split-two-strings-to-make-palindrome/README.md b/problems/split-two-strings-to-make-palindrome/README.md index 8684258eb..b8a9ef7b2 100644 --- a/problems/split-two-strings-to-make-palindrome/README.md +++ b/problems/split-two-strings-to-make-palindrome/README.md @@ -34,8 +34,8 @@ Then, aprefix + bsuffix = "" + "y" = &

    Example 2:

    -Input: a = "abdef", b = "fecab"
    -Output: true
    +Input: a = "xbdef", b = "xecab"
    +Output: false
     

    Example 3:

    @@ -49,13 +49,6 @@ bprefix = "jiz", bsuffix = "alu" Then, aprefix + bsuffix = "ula" + "alu" = "ulaalu", which is a palindrome. -

    Example 4:

    - -
    -Input: a = "xbdef", b = "xecab"
    -Output: false
    -
    -

     

    Constraints:

    @@ -66,9 +59,9 @@ Then, aprefix + bsuffix = "ula" + "alu" ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/splitting-a-string-into-descending-consecutive-values/README.md b/problems/splitting-a-string-into-descending-consecutive-values/README.md index 936b7ddf8..97aca561b 100644 --- a/problems/splitting-a-string-into-descending-consecutive-values/README.md +++ b/problems/splitting-a-string-into-descending-consecutive-values/README.md @@ -50,15 +50,6 @@ The values are in descending order with adjacent values differing by 1. Explanation: There is no valid way to split s. -

    Example 4:

    - -
    -Input: s = "10009998"
    -Output: true
    -Explanation: s can be split into ["100", "099", "98"] with numerical values [100,99,98].
    -The values are in descending order with adjacent values differing by 1.
    -
    -

     

    Constraints:

    diff --git a/problems/squares-of-a-sorted-array/README.md b/problems/squares-of-a-sorted-array/README.md index db487bee4..d4c8ef936 100644 --- a/problems/squares-of-a-sorted-array/README.md +++ b/problems/squares-of-a-sorted-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-perimeter-triangle "Largest Perimeter Triangle") diff --git a/problems/stamping-the-grid/README.md b/problems/stamping-the-grid/README.md new file mode 100644 index 000000000..e11e22239 --- /dev/null +++ b/problems/stamping-the-grid/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../longest-palindrome-by-concatenating-two-letter-words "Longest Palindrome by Concatenating Two Letter Words") +                 +[Next >](../check-if-every-row-and-column-contains-all-numbers "Check if Every Row and Column Contains All Numbers") + +## [2132. Stamping the Grid (Hard)](https://leetcode.com/problems/stamping-the-grid "用邮票贴满网格图") + +

    You are given an m x n binary matrix grid where each cell is either 0 (empty) or 1 (occupied).

    + +

    You are then given stamps of size stampHeight x stampWidth. We want to fit the stamps such that they follow the given restrictions and requirements:

    + +
      +
    1. Cover all the empty cells.
    2. +
    3. Do not cover any of the occupied cells.
    4. +
    5. We can put as many stamps as we want.
    6. +
    7. Stamps can overlap with each other.
    8. +
    9. Stamps are not allowed to be rotated.
    10. +
    11. Stamps must stay completely inside the grid.
    12. +
    + +

    Return true if it is possible to fit the stamps while following the given restrictions and requirements. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: grid = [[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0]], stampHeight = 4, stampWidth = 3
    +Output: true
    +Explanation: We have two overlapping stamps (labeled 1 and 2 in the image) that are able to cover all the empty cells.
    +
    + +

    Example 2:

    + +
    +Input: grid = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]], stampHeight = 2, stampWidth = 2 
    +Output: false 
    +Explanation: There is no way to fit the stamps onto all the empty cells without the stamps going outside the grid.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[r].length
    • +
    • 1 <= m, n <= 105
    • +
    • 1 <= m * n <= 2 * 105
    • +
    • grid[r][c] is either 0 or 1.
    • +
    • 1 <= stampHeight, stampWidth <= 105
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +We can check if every empty cell is a part of a consecutive row of empty cells that has a width of at least stampWidth as well as a consecutive column of empty cells that has a height of at least stampHeight. +
    + +
    +Hint 2 +We can prove that this condition is sufficient and necessary to fit the stamps while following the given restrictions and requirements. +
    + +
    +Hint 3 +For each row, find every consecutive row of empty cells, and mark all the cells where the consecutive row is at least stampWidth wide. Do the same for the columns with stampHeight. Then, you can check if every cell is marked twice. +
    diff --git a/problems/stamping-the-sequence/README.md b/problems/stamping-the-sequence/README.md index b260b7a9b..9b995d25d 100644 --- a/problems/stamping-the-sequence/README.md +++ b/problems/stamping-the-sequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../knight-dialer "Knight Dialer") @@ -61,7 +61,7 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Queue](../../tag/queue/README.md)] - [[String](../../tag/string/README.md)] diff --git a/problems/step-by-step-directions-from-a-binary-tree-node-to-another/README.md b/problems/step-by-step-directions-from-a-binary-tree-node-to-another/README.md new file mode 100644 index 000000000..ad7f54d10 --- /dev/null +++ b/problems/step-by-step-directions-from-a-binary-tree-node-to-another/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../delete-the-middle-node-of-a-linked-list "Delete the Middle Node of a Linked List") +                 +[Next >](../valid-arrangement-of-pairs "Valid Arrangement of Pairs") + +## [2096. Step-By-Step Directions From a Binary Tree Node to Another (Medium)](https://leetcode.com/problems/step-by-step-directions-from-a-binary-tree-node-to-another "从二叉树一个节点到另一个节点每一步的方向") + +

    You are given the root of a binary tree with n nodes. Each node is uniquely assigned a value from 1 to n. You are also given an integer startValue representing the value of the start node s, and a different integer destValue representing the value of the destination node t.

    + +

    Find the shortest path starting from node s and ending at node t. Generate step-by-step directions of such path as a string consisting of only the uppercase letters 'L', 'R', and 'U'. Each letter indicates a specific direction:

    + +
      +
    • 'L' means to go from a node to its left child node.
    • +
    • 'R' means to go from a node to its right child node.
    • +
    • 'U' means to go from a node to its parent node.
    • +
    + +

    Return the step-by-step directions of the shortest path from node s to node t.

    + +

     

    +

    Example 1:

    + +
    +Input: root = [5,1,2,3,null,6,4], startValue = 3, destValue = 6
    +Output: "UURL"
    +Explanation: The shortest path is: 3 → 1 → 5 → 2 → 6.
    +
    + +

    Example 2:

    + +
    +Input: root = [2,1], startValue = 2, destValue = 1
    +Output: "L"
    +Explanation: The shortest path is: 2 → 1.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is n.
    • +
    • 2 <= n <= 105
    • +
    • 1 <= Node.val <= n
    • +
    • All the values in the tree are unique.
    • +
    • 1 <= startValue, destValue <= n
    • +
    • startValue != destValue
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[String](../../tag/string/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] + +### Hints +
    +Hint 1 +The shortest path between any two nodes in a tree must pass through their Lowest Common Ancestor (LCA). The path will travel upwards from node s to the LCA and then downwards from the LCA to node t. +
    + +
    +Hint 2 +Find the path strings from root → s, and root → t. Can you use these two strings to prepare the final answer? +
    + +
    +Hint 3 +Remove the longest common prefix of the two path strings to get the path LCA → s, and LCA → t. Each step in the path of LCA → s should be reversed as 'U'. +
    diff --git a/problems/stepping-numbers/README.md b/problems/stepping-numbers/README.md index 1ee2c7220..015aa8167 100644 --- a/problems/stepping-numbers/README.md +++ b/problems/stepping-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-sum-bsts "Two Sum BSTs") diff --git a/problems/stock-price-fluctuation/README.md b/problems/stock-price-fluctuation/README.md index 85f72ad28..993eb2005 100644 --- a/problems/stock-price-fluctuation/README.md +++ b/problems/stock-price-fluctuation/README.md @@ -69,6 +69,7 @@ stockPrice.minimum(); // return 2, the minimum price is 2 at timestamp 4. ### Related Topics [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/stone-game-ii/README.md b/problems/stone-game-ii/README.md index 61c60a903..7a40acc4c 100644 --- a/problems/stone-game-ii/README.md +++ b/problems/stone-game-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-1-bordered-square "Largest 1-Bordered Square") diff --git a/problems/stone-game-iii/README.md b/problems/stone-game-iii/README.md index e0f6523b3..cb4cc8145 100644 --- a/problems/stone-game-iii/README.md +++ b/problems/stone-game-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-happy-string "Longest Happy String") @@ -11,17 +11,17 @@ ## [1406. Stone Game III (Hard)](https://leetcode.com/problems/stone-game-iii "石子游戏 III") -

    Alice and Bob continue their games with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.

    +

    Alice and Bob continue their games with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.

    -

    Alice and Bob take turns, with Alice starting first. On each player's turn, that player can take 1, 2 or 3 stones from the first remaining stones in the row.

    +

    Alice and Bob take turns, with Alice starting first. On each player's turn, that player can take 1, 2, or 3 stones from the first remaining stones in the row.

    -

    The score of each player is the sum of values of the stones taken. The score of each player is 0 initially.

    +

    The score of each player is the sum of the values of the stones taken. The score of each player is 0 initially.

    The objective of the game is to end with the highest score, and the winner is the player with the highest score and there could be a tie. The game continues until all the stones have been taken.

    -

    Assume Alice and Bob play optimally.

    +

    Assume Alice and Bob play optimally.

    -

    Return "Alice" if Alice will win, "Bob" if Bob will win or "Tie" if they end the game with the same score.

    +

    Return "Alice" if Alice will win, "Bob" if Bob will win, or "Tie" if they will end the game with the same score.

     

    Example 1:

    @@ -38,8 +38,8 @@ Input: values = [1,2,3,-9] Output: "Alice" Explanation: Alice must choose all the three piles at the first move to win and leave Bob with negative score. -If Alice chooses one pile her score will be 1 and the next move Bob's score becomes 5. The next move Alice will take the pile with value = -9 and lose. -If Alice chooses two piles her score will be 3 and the next move Bob's score becomes 3. The next move Alice will take the pile with value = -9 and also lose. +If Alice chooses one pile her score will be 1 and the next move Bob's score becomes 5. In the next move, Alice will take the pile with value = -9 and lose. +If Alice chooses two piles her score will be 3 and the next move Bob's score becomes 3. In the next move, Alice will take the pile with value = -9 and also lose. Remember that both play optimally so here Alice will choose the scenario that makes her win. @@ -51,26 +51,12 @@ Remember that both play optimally so here Alice will choose the scenario that ma Explanation: Alice cannot win this game. She can end the game in a draw if she decided to choose all the first three piles, otherwise she will lose. -

    Example 4:

    - -
    -Input: values = [1,2,3,-1,-2,-3,7]
    -Output: "Alice"
    -
    - -

    Example 5:

    - -
    -Input: values = [-1,-2,-3]
    -Output: "Tie"
    -
    -

     

    Constraints:

      -
    • 1 <= values.length <= 50000
    • -
    • -1000 <= values[i] <= 1000
    • +
    • 1 <= stoneValue.length <= 5 * 104
    • +
    • -1000 <= stoneValue[i] <= 1000
    ### Related Topics diff --git a/problems/stone-game-iv/README.md b/problems/stone-game-iv/README.md index e54c3fc94..e353d2524 100644 --- a/problems/stone-game-iv/README.md +++ b/problems/stone-game-iv/README.md @@ -13,11 +13,11 @@

    Alice and Bob take turns playing a game, with Alice starting first.

    -

    Initially, there are n stones in a pile.  On each player's turn, that player makes a move consisting of removing any non-zero square number of stones in the pile.

    +

    Initially, there are n stones in a pile. On each player's turn, that player makes a move consisting of removing any non-zero square number of stones in the pile.

    Also, if a player cannot make a move, he/she loses the game.

    -

    Given a positive integer n. Return True if and only if Alice wins the game otherwise return False, assuming both players play optimally.

    +

    Given a positive integer n, return true if and only if Alice wins the game otherwise return false, assuming both players play optimally.

     

    Example 1:

    @@ -32,7 +32,8 @@
     Input: n = 2
     Output: false
    -Explanation: Alice can only remove 1 stone, after that Bob removes the last one winning the game (2 -> 1 -> 0).
    +Explanation: Alice can only remove 1 stone, after that Bob removes the last one winning the game (2 -> 1 -> 0). +

    Example 3:

    @@ -42,28 +43,11 @@ Explanation: n is already a perfect square, Alice can win with one move, removing 4 stones (4 -> 0). -

    Example 4:

    - -
    -Input: n = 7
    -Output: false
    -Explanation: Alice can't win the game if Bob plays optimally.
    -If Alice starts removing 4 stones, Bob will remove 1 stone then Alice should remove only 1 stone and finally Bob removes the last one (7 -> 3 -> 2 -> 1 -> 0). 
    -If Alice starts removing 1 stone, Bob will remove 4 stones then Alice only can remove 1 stone and finally Bob removes the last one (7 -> 6 -> 2 -> 1 -> 0).
    - -

    Example 5:

    - -
    -Input: n = 17
    -Output: false
    -Explanation: Alice can't win the game if Bob plays optimally.
    -
    -

     

    Constraints:

      -
    • 1 <= n <= 10^5
    • +
    • 1 <= n <= 105
    ### Related Topics @@ -71,6 +55,13 @@ If Alice starts removing 1 stone, Bob will remove 4 stones then Alice only can r [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Game Theory](../../tag/game-theory/README.md)] +### Similar Questions + 1. [Stone Game V](../stone-game-v) (Hard) + 1. [Stone Game VI](../stone-game-vi) (Medium) + 1. [Stone Game VII](../stone-game-vii) (Medium) + 1. [Stone Game VIII](../stone-game-viii) (Hard) + 1. [Stone Game IX](../stone-game-ix) (Medium) + ### Hints
    Hint 1 diff --git a/problems/stone-game-vii/README.md b/problems/stone-game-vii/README.md index c84453367..5d1b5878e 100644 --- a/problems/stone-game-vii/README.md +++ b/problems/stone-game-vii/README.md @@ -55,17 +55,6 @@ The score difference is 18 - 12 = 6. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Game Theory](../../tag/game-theory/README.md)] -### Similar Questions - 1. [Stone Game](../stone-game) (Medium) - 1. [Stone Game II](../stone-game-ii) (Medium) - 1. [Stone Game III](../stone-game-iii) (Hard) - 1. [Stone Game IV](../stone-game-iv) (Hard) - 1. [Stone Game V](../stone-game-v) (Hard) - 1. [Stone Game VI](../stone-game-vi) (Medium) - 1. [Maximum Score from Performing Multiplication Operations](../maximum-score-from-performing-multiplication-operations) (Medium) - 1. [Stone Game VIII](../stone-game-viii) (Hard) - 1. [Stone Game IX](../stone-game-ix) (Medium) - ### Hints
    Hint 1 diff --git a/problems/strange-printer-ii/README.md b/problems/strange-printer-ii/README.md index efef2f8b8..4f5b30e03 100644 --- a/problems/strange-printer-ii/README.md +++ b/problems/strange-printer-ii/README.md @@ -24,18 +24,14 @@

     

    Example 1:

    - -

    - +
     Input: targetGrid = [[1,1,1,1],[1,2,2,1],[1,2,2,1],[1,1,1,1]]
     Output: true
     

    Example 2:

    - -

    - +
     Input: targetGrid = [[1,1,1,1],[1,1,3,3],[1,1,3,4],[5,5,1,4]]
     Output: true
    @@ -46,13 +42,7 @@
     
     Input: targetGrid = [[1,2,1],[2,1,2],[1,2,1]]
     Output: false
    -Explanation: It is impossible to form targetGrid because it is not allowed to print the same color in different turns.
    - -

    Example 4:

    - -
    -Input: targetGrid = [[1,1,1],[3,1,3]]
    -Output: false
    +Explanation: It is impossible to form targetGrid because it is not allowed to print the same color in different turns.
     

     

    diff --git a/problems/stream-of-characters/README.md b/problems/stream-of-characters/README.md index 1ed4f85dc..3f297045a 100644 --- a/problems/stream-of-characters/README.md +++ b/problems/stream-of-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-sum-of-two-non-overlapping-subarrays "Maximum Sum of Two Non-Overlapping Subarrays") @@ -60,10 +60,10 @@ streamChecker.query("l"); // return True, because 'kl' is in t ### Related Topics - [[Design](../../tag/design/README.md)] - [[Trie](../../tag/trie/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] + [[Trie](../../tag/trie/README.md)] [[Data Stream](../../tag/data-stream/README.md)] ### Hints diff --git a/problems/string-matching-in-an-array/README.md b/problems/string-matching-in-an-array/README.md index 39e81221c..0465ce113 100644 --- a/problems/string-matching-in-an-array/README.md +++ b/problems/string-matching-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../top-travellers "Top Travellers") diff --git a/problems/string-to-integer-atoi/README.md b/problems/string-to-integer-atoi/README.md index f3583d52e..fc45cb209 100644 --- a/problems/string-to-integer-atoi/README.md +++ b/problems/string-to-integer-atoi/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-integer "Reverse Integer") @@ -80,38 +80,6 @@ The parsed integer is 4193. Since 4193 is in the range [-231, 231 - 1], the final result is 4193.
    -

    Example 4:

    - -
    -Input: s = "words and 987"
    -Output: 0
    -Explanation:
    -Step 1: "words and 987" (no characters read because there is no leading whitespace)
    -         ^
    -Step 2: "words and 987" (no characters read because there is neither a '-' nor '+')
    -         ^
    -Step 3: "words and 987" (reading stops immediately because there is a non-digit 'w')
    -         ^
    -The parsed integer is 0 because no digits were read.
    -Since 0 is in the range [-231, 231 - 1], the final result is 0.
    -
    - -

    Example 5:

    - -
    -Input: s = "-91283472332"
    -Output: -2147483648
    -Explanation:
    -Step 1: "-91283472332" (no characters read because there is no leading whitespace)
    -         ^
    -Step 2: "-91283472332" ('-' is read, so the result should be negative)
    -          ^
    -Step 3: "-91283472332" ("91283472332" is read in)
    -                     ^
    -The parsed integer is -91283472332.
    -Since -91283472332 is less than the lower bound of the range [-231, 231 - 1], the final result is clamped to -231 = -2147483648. 
    -
    -

     

    Constraints:

    @@ -124,5 +92,6 @@ Since -91283472332 is less than the lower bound of the range [-231, 2 [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Reverse Integer](../reverse-integer) (Easy) + 1. [Reverse Integer](../reverse-integer) (Medium) 1. [Valid Number](../valid-number) (Hard) + 1. [Check if Numbers Are Ascending in a Sentence](../check-if-numbers-are-ascending-in-a-sentence) (Easy) diff --git a/problems/strings-differ-by-one-character/README.md b/problems/strings-differ-by-one-character/README.md index 16a62cb47..497638a14 100644 --- a/problems/strings-differ-by-one-character/README.md +++ b/problems/strings-differ-by-one-character/README.md @@ -16,8 +16,8 @@ ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Rolling Hash](../../tag/rolling-hash/README.md)] [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/strobogrammatic-number-iii/README.md b/problems/strobogrammatic-number-iii/README.md index 4648f1223..6ba33e54b 100644 --- a/problems/strobogrammatic-number-iii/README.md +++ b/problems/strobogrammatic-number-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../strobogrammatic-number-ii "Strobogrammatic Number II") diff --git a/problems/strobogrammatic-number/README.md b/problems/strobogrammatic-number/README.md index 805989ec0..781c90165 100644 --- a/problems/strobogrammatic-number/README.md +++ b/problems/strobogrammatic-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-word-distance-iii "Shortest Word Distance III") diff --git a/problems/strong-friendship/README.md b/problems/strong-friendship/README.md index d02716190..793c73063 100644 --- a/problems/strong-friendship/README.md +++ b/problems/strong-friendship/README.md @@ -9,7 +9,7 @@                  [Next >](../maximum-of-minimum-values-in-all-subarrays "Maximum of Minimum Values in All Subarrays") -## [1949. Strong Friendship (Medium)](https://leetcode.com/problems/strong-friendship "") +## [1949. Strong Friendship (Medium)](https://leetcode.com/problems/strong-friendship "坚定的友谊") diff --git a/problems/student-attendance-record-ii/README.md b/problems/student-attendance-record-ii/README.md index 2db7f1dce..6931ce270 100644 --- a/problems/student-attendance-record-ii/README.md +++ b/problems/student-attendance-record-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../student-attendance-record-i "Student Attendance Record I") diff --git a/problems/subrectangle-queries/README.md b/problems/subrectangle-queries/README.md index fd1f45944..2f116e489 100644 --- a/problems/subrectangle-queries/README.md +++ b/problems/subrectangle-queries/README.md @@ -94,8 +94,8 @@ subrectangleQueries.getValue(2, 2); // return 20 ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] + [[Design](../../tag/design/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/subsequence-of-size-k-with-the-largest-even-sum/README.md b/problems/subsequence-of-size-k-with-the-largest-even-sum/README.md new file mode 100644 index 000000000..b37446fc3 --- /dev/null +++ b/problems/subsequence-of-size-k-with-the-largest-even-sum/README.md @@ -0,0 +1,35 @@ + + + + + + + +[< Previous](../valid-arrangement-of-pairs "Valid Arrangement of Pairs") +                 +[Next >](../find-subsequence-of-length-k-with-the-largest-sum "Find Subsequence of Length K With the Largest Sum") + +## [2098. Subsequence of Size K With the Largest Even Sum (Medium)](https://leetcode.com/problems/subsequence-of-size-k-with-the-largest-even-sum "") + + + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Is the sum of two even numbers even or odd? How about two odd numbers? One odd number and one even number? +
    + +
    +Hint 2 +If there is an even number of odd numbers, the sum will be even and vice versa. +
    + +
    +Hint 3 +Create an integer array to store all the even numbers in nums and another array to store all the odd numbers in nums. Sort both arrays. +
    diff --git a/problems/substrings-of-size-three-with-distinct-characters/README.md b/problems/substrings-of-size-three-with-distinct-characters/README.md index ee678eb6c..eedd2515f 100644 --- a/problems/substrings-of-size-three-with-distinct-characters/README.md +++ b/problems/substrings-of-size-three-with-distinct-characters/README.md @@ -49,8 +49,8 @@ The good substrings are "abc", "bca", "cab", and & ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] [[Counting](../../tag/counting/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/substrings-that-begin-and-end-with-the-same-letter/README.md b/problems/substrings-that-begin-and-end-with-the-same-letter/README.md index d3d18e50a..0bd2bd07a 100644 --- a/problems/substrings-that-begin-and-end-with-the-same-letter/README.md +++ b/problems/substrings-that-begin-and-end-with-the-same-letter/README.md @@ -9,10 +9,17 @@                  [Next >](../drop-type-1-orders-for-customers-with-type-0-orders "Drop Type 1 Orders for Customers With Type 0 Orders") -## [2083. Substrings That Begin and End With the Same Letter (Medium)](https://leetcode.com/problems/substrings-that-begin-and-end-with-the-same-letter "") +## [2083. Substrings That Begin and End With the Same Letter (Medium)](https://leetcode.com/problems/substrings-that-begin-and-end-with-the-same-letter "求以相同字母开头和结尾的子串总数") +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + ### Hints
    Hint 1 diff --git a/problems/subtree-removal-game-with-fibonacci-tree/README.md b/problems/subtree-removal-game-with-fibonacci-tree/README.md index 07cd9d6f4..094bb4c14 100644 --- a/problems/subtree-removal-game-with-fibonacci-tree/README.md +++ b/problems/subtree-removal-game-with-fibonacci-tree/README.md @@ -9,7 +9,7 @@                  [Next >](../count-number-of-pairs-with-absolute-difference-k "Count Number of Pairs With Absolute Difference K") -## [2005. Subtree Removal Game with Fibonacci Tree (Hard)](https://leetcode.com/problems/subtree-removal-game-with-fibonacci-tree "") +## [2005. Subtree Removal Game with Fibonacci Tree (Hard)](https://leetcode.com/problems/subtree-removal-game-with-fibonacci-tree "斐波那契树的移除子树游戏") diff --git a/problems/sudoku-solver/README.md b/problems/sudoku-solver/README.md index beb8613ad..df556e33c 100644 --- a/problems/sudoku-solver/README.md +++ b/problems/sudoku-solver/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-sudoku "Valid Sudoku") diff --git a/problems/sum-of-square-numbers/README.md b/problems/sum-of-square-numbers/README.md index 1a6589b9a..bdd0de9dd 100644 --- a/problems/sum-of-square-numbers/README.md +++ b/problems/sum-of-square-numbers/README.md @@ -29,27 +29,6 @@ Output: false -

    Example 3:

    - -
    -Input: c = 4
    -Output: true
    -
    - -

    Example 4:

    - -
    -Input: c = 2
    -Output: true
    -
    - -

    Example 5:

    - -
    -Input: c = 1
    -Output: true
    -
    -

     

    Constraints:

    diff --git a/problems/sum-of-subarray-minimums/README.md b/problems/sum-of-subarray-minimums/README.md index bb47a9d74..ee1e208f7 100644 --- a/problems/sum-of-subarray-minimums/README.md +++ b/problems/sum-of-subarray-minimums/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../super-palindromes "Super Palindromes") diff --git a/problems/sum-of-subarray-ranges/README.md b/problems/sum-of-subarray-ranges/README.md new file mode 100644 index 000000000..78e5d4cbd --- /dev/null +++ b/problems/sum-of-subarray-ranges/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../rings-and-rods "Rings and Rods") +                 +[Next >](../watering-plants-ii "Watering Plants II") + +## [2104. Sum of Subarray Ranges (Medium)](https://leetcode.com/problems/sum-of-subarray-ranges "子数组范围和") + +

    You are given an integer array nums. The range of a subarray of nums is the difference between the largest and smallest element in the subarray.

    + +

    Return the sum of all subarray ranges of nums.

    + +

    A subarray is a contiguous non-empty sequence of elements within an array.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3]
    +Output: 4
    +Explanation: The 6 subarrays of nums are the following:
    +[1], range = largest - smallest = 1 - 1 = 0 
    +[2], range = 2 - 2 = 0
    +[3], range = 3 - 3 = 0
    +[1,2], range = 2 - 1 = 1
    +[2,3], range = 3 - 2 = 1
    +[1,2,3], range = 3 - 1 = 2
    +So the sum of all ranges is 0 + 0 + 0 + 1 + 1 + 2 = 4.
    + +

    Example 2:

    + +
    +Input: nums = [1,3,3]
    +Output: 4
    +Explanation: The 6 subarrays of nums are the following:
    +[1], range = largest - smallest = 1 - 1 = 0
    +[3], range = 3 - 3 = 0
    +[3], range = 3 - 3 = 0
    +[1,3], range = 3 - 1 = 2
    +[3,3], range = 3 - 3 = 0
    +[1,3,3], range = 3 - 1 = 2
    +So the sum of all ranges is 0 + 0 + 0 + 2 + 0 + 2 = 4.
    +
    + +

    Example 3:

    + +
    +Input: nums = [4,-2,-3,4,1]
    +Output: 59
    +Explanation: The sum of all subarray ranges of nums is 59.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • -109 <= nums[i] <= 109
    • +
    + +

     

    +

    Follow-up: Could you find a solution with O(n) time complexity?

    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] + +### Hints +
    +Hint 1 +Can you get the max/min of a certain subarray by using the max/min of a smaller subarray within it? +
    + +
    +Hint 2 +Notice that the max of the subarray from index i to j is equal to max of (max of the subarray from index i to j-1) and nums[j]. +
    diff --git a/problems/sum-of-subsequence-widths/README.md b/problems/sum-of-subsequence-widths/README.md index ed7f78ad6..237896b1c 100644 --- a/problems/sum-of-subsequence-widths/README.md +++ b/problems/sum-of-subsequence-widths/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-and-replace-pattern "Find and Replace Pattern") diff --git a/problems/surface-area-of-3d-shapes/README.md b/problems/surface-area-of-3d-shapes/README.md index cc90f7bea..26186f55f 100644 --- a/problems/surface-area-of-3d-shapes/README.md +++ b/problems/surface-area-of-3d-shapes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-subsequence-widths "Sum of Subsequence Widths") @@ -21,34 +21,20 @@

     

    Example 1:

    - -
    -Input: grid = [[2]]
    -Output: 10
    -
    - -

    Example 2:

     Input: grid = [[1,2],[3,4]]
     Output: 34
     
    -

    Example 3:

    - -
    -Input: grid = [[1,0],[0,2]]
    -Output: 16
    -
    - -

    Example 4:

    +

    Example 2:

     Input: grid = [[1,1,1],[1,0,1],[1,1,1]]
     Output: 32
     
    -

    Example 5:

    +

    Example 3:

     Input: grid = [[2,2,2],[2,1,2],[2,2,2]]
    @@ -59,8 +45,7 @@
     

    Constraints:

      -
    • n == grid.length
    • -
    • n == grid[i].length
    • +
    • n == grid.length == grid[i].length
    • 1 <= n <= 50
    • 0 <= grid[i][j] <= 50
    diff --git a/problems/surrounded-regions/README.md b/problems/surrounded-regions/README.md index b0fdb237d..ed9eb8e89 100644 --- a/problems/surrounded-regions/README.md +++ b/problems/surrounded-regions/README.md @@ -42,10 +42,10 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Similar Questions diff --git a/problems/suspicious-bank-accounts/README.md b/problems/suspicious-bank-accounts/README.md index 5d8cdf1ff..10a9cba44 100644 --- a/problems/suspicious-bank-accounts/README.md +++ b/problems/suspicious-bank-accounts/README.md @@ -9,7 +9,7 @@                  [Next >](../replace-all-digits-with-characters "Replace All Digits with Characters") -## [1843. Suspicious Bank Accounts (Medium)](https://leetcode.com/problems/suspicious-bank-accounts "") +## [1843. Suspicious Bank Accounts (Medium)](https://leetcode.com/problems/suspicious-bank-accounts "可疑银行账户") diff --git a/problems/swap-adjacent-in-lr-string/README.md b/problems/swap-adjacent-in-lr-string/README.md index ae714477d..ccc6e21f8 100644 --- a/problems/swap-adjacent-in-lr-string/README.md +++ b/problems/swap-adjacent-in-lr-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../split-bst "Split BST") @@ -34,27 +34,6 @@ XRLXXRRLX Output: false
    -

    Example 3:

    - -
    -Input: start = "LLR", end = "RRL"
    -Output: false
    -
    - -

    Example 4:

    - -
    -Input: start = "XL", end = "LX"
    -Output: true
    -
    - -

    Example 5:

    - -
    -Input: start = "XLLR", end = "LXLX"
    -Output: false
    -
    -

     

    Constraints:

    diff --git a/problems/swap-for-longest-repeated-character-substring/README.md b/problems/swap-for-longest-repeated-character-substring/README.md index 117c95cdd..d4f009b32 100644 --- a/problems/swap-for-longest-repeated-character-substring/README.md +++ b/problems/swap-for-longest-repeated-character-substring/README.md @@ -21,7 +21,7 @@
     Input: text = "ababa"
     Output: 3
    -Explanation: We can swap the first 'b' with the last 'a', or the last 'b' with the first 'a'. Then, the longest repeated character substring is "aaa", which its length is 3.
    +Explanation: We can swap the first 'b' with the last 'a', or the last 'b' with the first 'a'. Then, the longest repeated character substring is "aaa" with length 3.
     

    Example 2:

    @@ -29,29 +29,15 @@
     Input: text = "aaabaaa"
     Output: 6
    -Explanation: Swap 'b' with the last 'a' (or the first 'a'), and we get longest repeated character substring "aaaaaa", which its length is 6.
    +Explanation: Swap 'b' with the last 'a' (or the first 'a'), and we get longest repeated character substring "aaaaaa" with length 6.
     

    Example 3:

    -
    -Input: text = "aaabbaaa"
    -Output: 4
    -
    - -

    Example 4:

    -
     Input: text = "aaaaa"
     Output: 5
    -Explanation: No need to swap, longest repeated character substring is "aaaaa", length is 5.
    -
    - -

    Example 5:

    - -
    -Input: text = "abcdef"
    -Output: 1
    +Explanation: No need to swap, longest repeated character substring is "aaaaa" with length is 5.
     

     

    diff --git a/problems/swapping-nodes-in-a-linked-list/README.md b/problems/swapping-nodes-in-a-linked-list/README.md index 6ec21a3ad..230f24024 100644 --- a/problems/swapping-nodes-in-a-linked-list/README.md +++ b/problems/swapping-nodes-in-a-linked-list/README.md @@ -17,7 +17,7 @@

     

    Example 1:

    - +
     Input: head = [1,2,3,4,5], k = 2
     Output: [1,4,3,2,5]
    @@ -30,27 +30,6 @@
     Output: [7,9,6,6,8,7,3,0,9,5]
     
    -

    Example 3:

    - -
    -Input: head = [1], k = 1
    -Output: [1]
    -
    - -

    Example 4:

    - -
    -Input: head = [1,2], k = 1
    -Output: [2,1]
    -
    - -

    Example 5:

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

     

    Constraints:

    @@ -64,6 +43,11 @@ [[Linked List](../../tag/linked-list/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] +### Similar Questions + 1. [Remove Nth Node From End of List](../remove-nth-node-from-end-of-list) (Medium) + 1. [Swap Nodes in Pairs](../swap-nodes-in-pairs) (Medium) + 1. [Reverse Nodes in k-Group](../reverse-nodes-in-k-group) (Hard) + ### Hints
    Hint 1 diff --git a/problems/symmetric-tree/README.md b/problems/symmetric-tree/README.md index b10b5a489..d5627165a 100644 --- a/problems/symmetric-tree/README.md +++ b/problems/symmetric-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../same-tree "Same Tree") diff --git a/problems/synonymous-sentences/README.md b/problems/synonymous-sentences/README.md index 3bac93e3b..011fc9ffe 100644 --- a/problems/synonymous-sentences/README.md +++ b/problems/synonymous-sentences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-common-region "Smallest Common Region") @@ -40,11 +40,11 @@ text = "I am happy today but was sad yesterday" ### Related Topics - [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Union Find](../../tag/union-find/README.md)] ### Hints
    diff --git a/problems/the-airport-with-the-most-traffic/README.md b/problems/the-airport-with-the-most-traffic/README.md new file mode 100644 index 000000000..00c570b75 --- /dev/null +++ b/problems/the-airport-with-the-most-traffic/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../minimum-operations-to-make-the-array-k-increasing "Minimum Operations to Make the Array K-Increasing") +                 +[Next >](../elements-in-array-after-removing-and-replacing-elements "Elements in Array After Removing and Replacing Elements") + +## [2112. The Airport With the Most Traffic (Medium)](https://leetcode.com/problems/the-airport-with-the-most-traffic "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/the-airport-with-the-most-traffic/mysql_schemas.sql b/problems/the-airport-with-the-most-traffic/mysql_schemas.sql new file mode 100644 index 000000000..2c4c276f3 --- /dev/null +++ b/problems/the-airport-with-the-most-traffic/mysql_schemas.sql @@ -0,0 +1,5 @@ +Create table If Not Exists Flights (departure_airport int, arrival_airport int, flights_count int); +Truncate table Flights; +insert into Flights (departure_airport, arrival_airport, flights_count) values ('1', '2', '4'); +insert into Flights (departure_airport, arrival_airport, flights_count) values ('2', '1', '5'); +insert into Flights (departure_airport, arrival_airport, flights_count) values ('2', '4', '5'); diff --git a/problems/the-earliest-moment-when-everyone-become-friends/README.md b/problems/the-earliest-moment-when-everyone-become-friends/README.md index 5dd41821e..97e5581bb 100644 --- a/problems/the-earliest-moment-when-everyone-become-friends/README.md +++ b/problems/the-earliest-moment-when-everyone-become-friends/README.md @@ -52,8 +52,8 @@ The sixth event occurs at timestamp = 20190301 and after 0 and 3 become friends ### Related Topics - [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] + [[Union Find](../../tag/union-find/README.md)] ### Similar Questions 1. [Number of Provinces](../number-of-provinces) (Medium) diff --git a/problems/the-k-strongest-values-in-an-array/README.md b/problems/the-k-strongest-values-in-an-array/README.md index 2249537cb..d063932a0 100644 --- a/problems/the-k-strongest-values-in-an-array/README.md +++ b/problems/the-k-strongest-values-in-an-array/README.md @@ -11,18 +11,18 @@ ## [1471. The k Strongest Values in an Array (Medium)](https://leetcode.com/problems/the-k-strongest-values-in-an-array "数组中的 k 个最强值") -

    Given an array of integers arr and an integer k.

    +

    Given an array of integers arr and an integer k.

    -

    A value arr[i] is said to be stronger than a value arr[j] if |arr[i] - m| > |arr[j] - m| where m is the median of the array.
    +

    A value arr[i] is said to be stronger than a value arr[j] if |arr[i] - m| > |arr[j] - m| where m is the median of the array.
    If |arr[i] - m| == |arr[j] - m|, then arr[i] is said to be stronger than arr[j] if arr[i] > arr[j].

    Return a list of the strongest k values in the array. return the answer in any arbitrary order.

    -

    Median is the middle value in an ordered integer list. More formally, if the length of the list is n, the median is the element in position ((n - 1) / 2) in the sorted list (0-indexed).

    +

    Median is the middle value in an ordered integer list. More formally, if the length of the list is n, the median is the element in position ((n - 1) / 2) in the sorted list (0-indexed).

      -
    • For arr = [6, -3, 7, 2, 11]n = 5 and the median is obtained by sorting the array arr = [-3, 2, 6, 7, 11] and the median is arr[m] where m = ((5 - 1) / 2) = 2. The median is 6.
    • -
    • For arr = [-7, 22, 17, 3]n = 4 and the median is obtained by sorting the array arr = [-7, 3, 17, 22] and the median is arr[m] where m = ((4 - 1) / 2) = 1. The median is 3.
    • +
    • For arr = [6, -3, 7, 2, 11], n = 5 and the median is obtained by sorting the array arr = [-3, 2, 6, 7, 11] and the median is arr[m] where m = ((5 - 1) / 2) = 2. The median is 6.
    • +
    • For arr = [-7, 22, 17, 3], n = 4 and the median is obtained by sorting the array arr = [-7, 3, 17, 22] and the median is arr[m] where m = ((4 - 1) / 2) = 1. The median is 3.

     

    @@ -52,26 +52,12 @@ Please note that although |5 - 3| == |1 - 3| but 5 is stronger than 1 because 5 Any permutation of [11,8,6,6,7] is accepted. -

    Example 4:

    - -
    -Input: arr = [6,-3,7,2,11], k = 3
    -Output: [-3,11,2]
    -
    - -

    Example 5:

    - -
    -Input: arr = [-7,22,17,3], k = 2
    -Output: [22,17]
    -
    -

     

    Constraints:

      -
    • 1 <= arr.length <= 10^5
    • -
    • -10^5 <= arr[i] <= 10^5
    • +
    • 1 <= arr.length <= 105
    • +
    • -105 <= arr[i] <= 105
    • 1 <= k <= arr.length
    diff --git a/problems/the-kth-factor-of-n/README.md b/problems/the-kth-factor-of-n/README.md index 50dfaa95a..ce9c4a33b 100644 --- a/problems/the-kth-factor-of-n/README.md +++ b/problems/the-kth-factor-of-n/README.md @@ -11,11 +11,9 @@ ## [1492. The kth Factor of n (Medium)](https://leetcode.com/problems/the-kth-factor-of-n "n 的第 k 个因子") -

    Given two positive integers n and k.

    +

    You are given two positive integers n and k. A factor of an integer n is defined as an integer i where n % i == 0.

    -

    A factor of an integer n is defined as an integer i where n % i == 0.

    - -

    Consider a list of all factors of n sorted in ascending order, return the kth factor in this list or return -1 if n has less than k factors.

    +

    Consider a list of all factors of n sorted in ascending order, return the kth factor in this list or return -1 if n has less than k factors.

     

    Example 1:

    @@ -23,7 +21,7 @@
     Input: n = 12, k = 3
     Output: 3
    -Explanation: Factors list is [1, 2, 3, 4, 6, 12], the 3rd factor is 3.
    +Explanation: Factors list is [1, 2, 3, 4, 6, 12], the 3rd factor is 3.
     

    Example 2:

    @@ -31,7 +29,7 @@
     Input: n = 7, k = 2
     Output: 7
    -Explanation: Factors list is [1, 7], the 2nd factor is 7.
    +Explanation: Factors list is [1, 7], the 2nd factor is 7.
     

    Example 3:

    @@ -42,22 +40,6 @@ Explanation: Factors list is [1, 2, 4], there is only 3 factors. We should return -1. -

    Example 4:

    - -
    -Input: n = 1, k = 1
    -Output: 1
    -Explanation: Factors list is [1], the 1st factor is 1.
    -
    - -

    Example 5:

    - -
    -Input: n = 1000, k = 3
    -Output: 4
    -Explanation: Factors list is [1, 2, 4, 5, 8, 10, 20, 25, 40, 50, 100, 125, 200, 250, 500, 1000].
    -
    -

     

    Constraints:

    diff --git a/problems/the-most-frequently-ordered-products-for-each-customer/README.md b/problems/the-most-frequently-ordered-products-for-each-customer/README.md index 876cd2c83..e820d61c9 100644 --- a/problems/the-most-frequently-ordered-products-for-each-customer/README.md +++ b/problems/the-most-frequently-ordered-products-for-each-customer/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [The Most Recent Orders for Each Product](../the-most-recent-orders-for-each-product) (Medium) diff --git a/problems/the-number-of-full-rounds-you-have-played/README.md b/problems/the-number-of-full-rounds-you-have-played/README.md index 72715c1e9..79d5b74f0 100644 --- a/problems/the-number-of-full-rounds-you-have-played/README.md +++ b/problems/the-number-of-full-rounds-you-have-played/README.md @@ -11,54 +11,53 @@ ## [1904. The Number of Full Rounds You Have Played (Medium)](https://leetcode.com/problems/the-number-of-full-rounds-you-have-played "你完成的完整对局数") -

    A new online video game has been released, and in this video game, there are 15-minute rounds scheduled every quarter-hour period. This means that at HH:00, HH:15, HH:30 and HH:45, a new round starts, where HH represents an integer number from 00 to 23. A 24-hour clock is used, so the earliest time in the day is 00:00 and the latest is 23:59.

    +

    You are participating in an online chess tournament. There is a chess round that starts every 15 minutes. The first round of the day starts at 00:00, and after every 15 minutes, a new round starts.

    -

    Given two strings startTime and finishTime in the format "HH:MM" representing the exact time you started and finished playing the game, respectively, calculate the number of full rounds that you played during your game session.

    +
      +
    • For example, the second round starts at 00:15, the fourth round starts at 00:45, and the seventh round starts at 01:30.
    • +
    + +

    You are given two strings loginTime and logoutTime where:

      -
    • For example, if startTime = "05:20" and finishTime = "05:59" this means you played only one full round from 05:30 to 05:45. You did not play the full round from 05:15 to 05:30 because you started after the round began, and you did not play the full round from 05:45 to 06:00 because you stopped before the round ended.
    • +
    • loginTime is the time you will login to the game, and
    • +
    • logoutTime is the time you will logout from the game.
    -

    If finishTime is earlier than startTime, this means you have played overnight (from startTime to the midnight and from midnight to finishTime).

    +

    If logoutTime is earlier than loginTime, this means you have played from loginTime to midnight and from midnight to logoutTime.

    + +

    Return the number of full chess rounds you have played in the tournament.

    -

    Return the number of full rounds that you have played if you had started playing at startTime and finished at finishTime.

    +

    Note: All the given times follow the 24-hour clock. That means the first round of the day starts at 00:00 and the last round of the day starts at 23:45.

     

    Example 1:

    -Input: startTime = "12:01", finishTime = "12:44"
    +Input: loginTime = "09:31", logoutTime = "10:14"
     Output: 1
    -Explanation: You played one full round from 12:15 to 12:30.
    -You did not play the full round from 12:00 to 12:15 because you started playing at 12:01 after it began.
    -You did not play the full round from 12:30 to 12:45 because you stopped playing at 12:44 before it ended.
    +Explanation: You played one full round from 09:45 to 10:00.
    +You did not play the full round from 09:30 to 09:45 because you logged in at 09:31 after it began.
    +You did not play the full round from 10:00 to 10:15 because you logged out at 10:14 before it ended.
     

    Example 2:

    -Input: startTime = "20:00", finishTime = "06:00"
    -Output: 40
    -Explanation: You played 16 full rounds from 20:00 to 00:00 and 24 full rounds from 00:00 to 06:00.
    -16 + 24 = 40.
    -
    - -

    Example 3:

    - -
    -Input: startTime = "00:00", finishTime = "23:59"
    -Output: 95
    -Explanation: You played 4 full rounds each hour except for the last hour where you played 3 full rounds.
    +Input: loginTime = "21:30", logoutTime = "03:00"
    +Output: 22
    +Explanation: You played 10 full rounds from 21:30 to 00:00 and 12 full rounds from 00:00 to 03:00.
    +10 + 12 = 22.
     

     

    Constraints:

      -
    • startTime and finishTime are in the format HH:MM.
    • -
    • 00 <= HH <= 23
    • -
    • 00 <= MM <= 59
    • -
    • startTime and finishTime are not equal.
    • +
    • loginTime and logoutTime are in the format hh:mm.
    • +
    • 00 <= hh <= 23
    • +
    • 00 <= mm <= 59
    • +
    • loginTime and logoutTime are not equal.
    ### Related Topics diff --git a/problems/the-number-of-passengers-in-each-bus-i/README.md b/problems/the-number-of-passengers-in-each-bus-i/README.md new file mode 100644 index 000000000..42c598909 --- /dev/null +++ b/problems/the-number-of-passengers-in-each-bus-i/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../maximum-running-time-of-n-computers "Maximum Running Time of N Computers") +                 +[Next >](../choose-numbers-from-two-arrays-in-range "Choose Numbers From Two Arrays in Range") + +## [2142. The Number of Passengers in Each Bus I (Medium)](https://leetcode.com/problems/the-number-of-passengers-in-each-bus-i "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/the-number-of-passengers-in-each-bus-i/mysql_schemas.sql b/problems/the-number-of-passengers-in-each-bus-i/mysql_schemas.sql new file mode 100644 index 000000000..0fc11eefe --- /dev/null +++ b/problems/the-number-of-passengers-in-each-bus-i/mysql_schemas.sql @@ -0,0 +1,11 @@ +Create table If Not Exists Buses (bus_id int, arrival_time int); +Create table If Not Exists Passengers (passenger_id int, arrival_time int); +Truncate table Buses; +insert into Buses (bus_id, arrival_time) values ('1', '2'); +insert into Buses (bus_id, arrival_time) values ('2', '4'); +insert into Buses (bus_id, arrival_time) values ('3', '7'); +Truncate table Passengers; +insert into Passengers (passenger_id, arrival_time) values ('11', '1'); +insert into Passengers (passenger_id, arrival_time) values ('12', '5'); +insert into Passengers (passenger_id, arrival_time) values ('13', '6'); +insert into Passengers (passenger_id, arrival_time) values ('14', '7'); diff --git a/problems/the-number-of-passengers-in-each-bus-ii/README.md b/problems/the-number-of-passengers-in-each-bus-ii/README.md new file mode 100644 index 000000000..55bbc3466 --- /dev/null +++ b/problems/the-number-of-passengers-in-each-bus-ii/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../minimum-number-of-lines-to-cover-points "Minimum Number of Lines to Cover Points") +                 +[Next >](../keep-multiplying-found-values-by-two "Keep Multiplying Found Values by Two") + +## [2153. The Number of Passengers in Each Bus II (Hard)](https://leetcode.com/problems/the-number-of-passengers-in-each-bus-ii "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/the-number-of-passengers-in-each-bus-ii/mysql_schemas.sql b/problems/the-number-of-passengers-in-each-bus-ii/mysql_schemas.sql new file mode 100644 index 000000000..58e4a205c --- /dev/null +++ b/problems/the-number-of-passengers-in-each-bus-ii/mysql_schemas.sql @@ -0,0 +1,12 @@ +Create table If Not Exists Buses (bus_id int, arrival_time int, capacity int); +Create table If Not Exists Passengers (passenger_id int, arrival_time int); +Truncate table Buses; +insert into Buses (bus_id, arrival_time, capacity) values ('1', '2', '1'); +insert into Buses (bus_id, arrival_time, capacity) values ('2', '4', '10'); +insert into Buses (bus_id, arrival_time, capacity) values ('3', '7', '2'); +Truncate table Passengers; +insert into Passengers (passenger_id, arrival_time) values ('11', '1'); +insert into Passengers (passenger_id, arrival_time) values ('12', '1'); +insert into Passengers (passenger_id, arrival_time) values ('13', '5'); +insert into Passengers (passenger_id, arrival_time) values ('14', '6'); +insert into Passengers (passenger_id, arrival_time) values ('15', '7'); diff --git a/problems/the-number-of-rich-customers/README.md b/problems/the-number-of-rich-customers/README.md index c9d106c47..9cde4d167 100644 --- a/problems/the-number-of-rich-customers/README.md +++ b/problems/the-number-of-rich-customers/README.md @@ -9,7 +9,7 @@                  [Next >](../substrings-that-begin-and-end-with-the-same-letter "Substrings That Begin and End With the Same Letter") -## [2082. The Number of Rich Customers (Easy)](https://leetcode.com/problems/the-number-of-rich-customers "") +## [2082. The Number of Rich Customers (Easy)](https://leetcode.com/problems/the-number-of-rich-customers "富有客户的数量") diff --git a/problems/the-score-of-students-solving-math-expression/README.md b/problems/the-score-of-students-solving-math-expression/README.md index d4f8632b1..d6b8d68bc 100644 --- a/problems/the-score-of-students-solving-math-expression/README.md +++ b/problems/the-score-of-students-solving-math-expression/README.md @@ -60,19 +60,6 @@ By the rules of grading, the students will still be rewarded 5 points (as they g The points for the students are: [0,0,5,0,0,5]. The sum of the points is 10. -

    Example 4:

    - -
    -Input: s = "1+2*3+4", answers = [13,21,11,15]
    -Output: 11
    -Explanation: The correct answer of the expression is 11.
    -Every other student was rewarded 2 points because they could have applied the operators as follows:
    -- ((1+2)*3)+4 = 13
    -- (1+2)*(3+4) = 21
    -- 1+(2*(3+4)) = 15
    -The points for the students are: [2,2,5,2]. The sum of the points is 11.
    -
    -

     

    Constraints:

    diff --git a/problems/the-winner-university/README.md b/problems/the-winner-university/README.md index aa1d5cf91..569867b73 100644 --- a/problems/the-winner-university/README.md +++ b/problems/the-winner-university/README.md @@ -9,7 +9,7 @@                  [Next >](../time-needed-to-buy-tickets "Time Needed to Buy Tickets") -## [2072. The Winner University (Easy)](https://leetcode.com/problems/the-winner-university "") +## [2072. The Winner University (Easy)](https://leetcode.com/problems/the-winner-university "赢得比赛的大学") diff --git a/problems/thousand-separator/README.md b/problems/thousand-separator/README.md index 66c20c984..87bf7dfd4 100644 --- a/problems/thousand-separator/README.md +++ b/problems/thousand-separator/README.md @@ -28,25 +28,11 @@ Output: "1.234" -

    Example 3:

    - -
    -Input: n = 123456789
    -Output: "123.456.789"
    -
    - -

    Example 4:

    - -
    -Input: n = 0
    -Output: "0"
    -
    -

     

    Constraints:

      -
    • 0 <= n < 231
    • +
    • 0 <= n <= 231 - 1
    ### Related Topics diff --git a/problems/three-divisors/README.md b/problems/three-divisors/README.md index 259c755b3..cc81d110e 100644 --- a/problems/three-divisors/README.md +++ b/problems/three-divisors/README.md @@ -42,6 +42,9 @@ ### Related Topics [[Math](../../tag/math/README.md)] +### Similar Questions + 1. [Find Greatest Common Divisor of Array](../find-greatest-common-divisor-of-array) (Easy) + ### Hints
    Hint 1 diff --git a/problems/throne-inheritance/README.md b/problems/throne-inheritance/README.md index 1c639babc..e33c7ee62 100644 --- a/problems/throne-inheritance/README.md +++ b/problems/throne-inheritance/README.md @@ -81,10 +81,13 @@ t.getInheritanceOrder(); // return ["king", "andy", "ma ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Design](../../tag/design/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] + +### Similar Questions + 1. [Operations on Tree](../operations-on-tree) (Medium) ### Hints
    diff --git a/problems/time-based-key-value-store/README.md b/problems/time-based-key-value-store/README.md index 3905deed8..559c1350b 100644 --- a/problems/time-based-key-value-store/README.md +++ b/problems/time-based-key-value-store/README.md @@ -53,10 +53,7 @@ timeMap.get("foo", 5); // return "bar2" ### Related Topics + [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Design](../../tag/design/README.md)] - -### Similar Questions - 1. [Stock Price Fluctuation ](../stock-price-fluctuation) (Medium) diff --git a/problems/time-needed-to-inform-all-employees/README.md b/problems/time-needed-to-inform-all-employees/README.md index 562cedbe1..af158e624 100644 --- a/problems/time-needed-to-inform-all-employees/README.md +++ b/problems/time-needed-to-inform-all-employees/README.md @@ -1,11 +1,11 @@ - - - + + + -[< Previous](../bulb-switcher-iii "Bulb Switcher III") +[< Previous](../number-of-times-binary-string-is-prefix-aligned "Number of Times Binary String Is Prefix-Aligned")                  [Next >](../frog-position-after-t-seconds "Frog Position After T Seconds") @@ -39,37 +39,6 @@ The tree structure of the employees in the company is shown. -

    Example 3:

    - -
    -Input: n = 7, headID = 6, manager = [1,2,3,4,5,6,-1], informTime = [0,6,5,4,3,2,1]
    -Output: 21
    -Explanation: The head has id = 6. He will inform employee with id = 5 in 1 minute.
    -The employee with id = 5 will inform the employee with id = 4 in 2 minutes.
    -The employee with id = 4 will inform the employee with id = 3 in 3 minutes.
    -The employee with id = 3 will inform the employee with id = 2 in 4 minutes.
    -The employee with id = 2 will inform the employee with id = 1 in 5 minutes.
    -The employee with id = 1 will inform the employee with id = 0 in 6 minutes.
    -Needed time = 1 + 2 + 3 + 4 + 5 + 6 = 21.
    -
    - -

    Example 4:

    - -
    -Input: n = 15, headID = 0, manager = [-1,0,0,1,1,2,2,3,3,4,4,5,5,6,6], informTime = [1,1,1,1,1,1,1,0,0,0,0,0,0,0,0]
    -Output: 3
    -Explanation: The first minute the head will inform employees 1 and 2.
    -The second minute they will inform employees 3, 4, 5 and 6.
    -The third minute they will inform the rest of employees.
    -
    - -

    Example 5:

    - -
    -Input: n = 4, headID = 2, manager = [3,3,-1,2], informTime = [0,0,162,914]
    -Output: 1076
    -
    -

     

    Constraints:

    diff --git a/problems/total-sales-amount-by-year/README.md b/problems/total-sales-amount-by-year/README.md index 7a27cc853..f2a0dc254 100644 --- a/problems/total-sales-amount-by-year/README.md +++ b/problems/total-sales-amount-by-year/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-performance-of-a-team "Maximum Performance of a Team") diff --git a/problems/trapping-rain-water/README.md b/problems/trapping-rain-water/README.md index ea93f83c4..63809ff6f 100644 --- a/problems/trapping-rain-water/README.md +++ b/problems/trapping-rain-water/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../first-missing-positive "First Missing Positive") diff --git a/problems/tuple-with-same-product/README.md b/problems/tuple-with-same-product/README.md index 89f9e7bd6..bca35af2d 100644 --- a/problems/tuple-with-same-product/README.md +++ b/problems/tuple-with-same-product/README.md @@ -29,27 +29,13 @@
     Input: nums = [1,2,4,5,10]
     Output: 16
    -Explanation: There are 16 valids tuples:
    +Explanation: There are 16 valid tuples:
     (1,10,2,5) , (1,10,5,2) , (10,1,2,5) , (10,1,5,2)
     (2,5,1,10) , (2,5,10,1) , (5,2,1,10) , (5,2,10,1)
     (2,10,4,5) , (2,10,5,4) , (10,2,4,5) , (10,2,5,4)
     (4,5,2,10) , (4,5,10,2) , (5,4,2,10) , (5,4,10,2)
     
    -

    Example 3:

    - -
    -Input: nums = [2,3,4,6,8,12]
    -Output: 40
    -
    - -

    Example 4:

    - -
    -Input: nums = [2,3,5,7]
    -Output: 0
    -
    -

     

    Constraints:

    diff --git a/problems/two-sum/README.md b/problems/two-sum/README.md index 447a249c4..aa409a146 100644 --- a/problems/two-sum/README.md +++ b/problems/two-sum/README.md @@ -1,8 +1,8 @@ - - - + + + < Previous @@ -23,7 +23,7 @@
     Input: nums = [2,7,11,15], target = 9
     Output: [0,1]
    -Output: Because nums[0] + nums[1] == 9, we return [0, 1].
    +Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
     

    Example 2:

    @@ -60,7 +60,7 @@ ### Similar Questions 1. [3Sum](../3sum) (Medium) 1. [4Sum](../4sum) (Medium) - 1. [Two Sum II - Input array is sorted](../two-sum-ii-input-array-is-sorted) (Easy) + 1. [Two Sum II - Input Array Is Sorted](../two-sum-ii-input-array-is-sorted) (Medium) 1. [Two Sum III - Data structure design](../two-sum-iii-data-structure-design) (Easy) 1. [Subarray Sum Equals K](../subarray-sum-equals-k) (Medium) 1. [Two Sum IV - Input is a BST](../two-sum-iv-input-is-a-bst) (Easy) diff --git a/problems/unique-substrings-with-equal-digit-frequency/README.md b/problems/unique-substrings-with-equal-digit-frequency/README.md new file mode 100644 index 000000000..18b80c84a --- /dev/null +++ b/problems/unique-substrings-with-equal-digit-frequency/README.md @@ -0,0 +1,47 @@ + + + + + + + +[< Previous](../minimum-time-to-remove-all-cars-containing-illegal-goods "Minimum Time to Remove All Cars Containing Illegal Goods") +                 +[Next >](../count-operations-to-obtain-zero "Count Operations to Obtain Zero") + +## [2168. Unique Substrings With Equal Digit Frequency (Medium)](https://leetcode.com/problems/unique-substrings-with-equal-digit-frequency "") + + + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] + +### Hints +
    +Hint 1 +With the constraints, could we try every substring? +
    + +
    +Hint 2 +Yes, checking every substring has runtime O(n^2), which will pass. +
    + +
    +Hint 3 +How can we make sure we only count unique substrings? +
    + +
    +Hint 4 +Use a set to store previously counted substrings. Hashing a string s of length m takes O(m) time. Is there a fast way to compute the hash of s if we know the hash of s[0..m - 2]? +
    + +
    +Hint 5 +Use a rolling hash. +
    diff --git a/problems/user-activity-for-the-past-30-days-i/README.md b/problems/user-activity-for-the-past-30-days-i/README.md index 8450ec32e..123c6b996 100644 --- a/problems/user-activity-for-the-past-30-days-i/README.md +++ b/problems/user-activity-for-the-past-30-days-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game-ii "Stone Game II") diff --git a/problems/users-that-actively-request-confirmation-messages/README.md b/problems/users-that-actively-request-confirmation-messages/README.md index 1b94ef273..d8642a55d 100644 --- a/problems/users-that-actively-request-confirmation-messages/README.md +++ b/problems/users-that-actively-request-confirmation-messages/README.md @@ -9,7 +9,7 @@                  [Next >](../longest-common-subsequence-between-sorted-arrays "Longest Common Subsequence Between Sorted Arrays") -## [1939. Users That Actively Request Confirmation Messages (Easy)](https://leetcode.com/problems/users-that-actively-request-confirmation-messages "") +## [1939. Users That Actively Request Confirmation Messages (Easy)](https://leetcode.com/problems/users-that-actively-request-confirmation-messages "主动请求确认消息的用户") diff --git a/problems/utf-8-validation/README.md b/problems/utf-8-validation/README.md index cbbf134ce..fa8e947a3 100644 --- a/problems/utf-8-validation/README.md +++ b/problems/utf-8-validation/README.md @@ -64,8 +64,8 @@ But the second continuation byte does not start with 10, so it is invalid. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/valid-arrangement-of-pairs/README.md b/problems/valid-arrangement-of-pairs/README.md new file mode 100644 index 000000000..68c06e545 --- /dev/null +++ b/problems/valid-arrangement-of-pairs/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../step-by-step-directions-from-a-binary-tree-node-to-another "Step-By-Step Directions From a Binary Tree Node to Another") +                 +[Next >](../subsequence-of-size-k-with-the-largest-even-sum "Subsequence of Size K With the Largest Even Sum") + +## [2097. Valid Arrangement of Pairs (Hard)](https://leetcode.com/problems/valid-arrangement-of-pairs "合法重新排列数对") + +

    You are given a 0-indexed 2D integer array pairs where pairs[i] = [starti, endi]. An arrangement of pairs is valid if for every index i where 1 <= i < pairs.length, we have endi-1 == starti.

    + +

    Return any valid arrangement of pairs.

    + +

    Note: The inputs will be generated such that there exists a valid arrangement of pairs.

    + +

     

    +

    Example 1:

    + +
    +Input: pairs = [[5,1],[4,5],[11,9],[9,4]]
    +Output: [[11,9],[9,4],[4,5],[5,1]]
    +Explanation:
    +This is a valid arrangement since endi-1 always equals starti.
    +end0 = 9 == 9 = start1 
    +end1 = 4 == 4 = start2
    +end2 = 5 == 5 = start3
    +
    + +

    Example 2:

    + +
    +Input: pairs = [[1,3],[3,2],[2,1]]
    +Output: [[1,3],[3,2],[2,1]]
    +Explanation:
    +This is a valid arrangement since endi-1 always equals starti.
    +end0 = 3 == 3 = start1
    +end1 = 2 == 2 = start2
    +The arrangements [[2,1],[1,3],[3,2]] and [[3,2],[2,1],[1,3]] are also valid.
    +
    + +

    Example 3:

    + +
    +Input: pairs = [[1,2],[1,3],[2,1]]
    +Output: [[1,2],[2,1],[1,3]]
    +Explanation:
    +This is a valid arrangement since endi-1 always equals starti.
    +end0 = 2 == 2 = start1
    +end1 = 1 == 1 = start2
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= pairs.length <= 105
    • +
    • pairs[i].length == 2
    • +
    • 0 <= starti, endi <= 109
    • +
    • starti != endi
    • +
    • No two pairs are exactly the same.
    • +
    • There exists a valid arrangement of pairs.
    • +
    + +### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Eulerian Circuit](../../tag/eulerian-circuit/README.md)] + +### Hints +
    +Hint 1 +Could you convert this into a graph problem? +
    + +
    +Hint 2 +Consider the pairs as edges and each number as a node. +
    + +
    +Hint 3 +We have to find an Eulerian path of this graph. Hierholzer’s algorithm can be used. +
    diff --git a/problems/valid-parenthesis-string/README.md b/problems/valid-parenthesis-string/README.md index b4ce17b44..3edabff41 100644 --- a/problems/valid-parenthesis-string/README.md +++ b/problems/valid-parenthesis-string/README.md @@ -49,3 +49,4 @@ ### Similar Questions 1. [Special Binary String](../special-binary-string) (Hard) + 1. [Check if a Parentheses String Can Be Valid](../check-if-a-parentheses-string-can-be-valid) (Medium) diff --git a/problems/valid-word-abbreviation/README.md b/problems/valid-word-abbreviation/README.md index 29cd566e3..63b929eb4 100644 --- a/problems/valid-word-abbreviation/README.md +++ b/problems/valid-word-abbreviation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../trapping-rain-water-ii "Trapping Rain Water II") @@ -49,3 +49,4 @@ Return false. ### Similar Questions 1. [Minimum Unique Word Abbreviation](../minimum-unique-word-abbreviation) (Hard) 1. [Word Abbreviation](../word-abbreviation) (Hard) + 1. [Check if an Original String Exists Given Two Encoded Strings](../check-if-an-original-string-exists-given-two-encoded-strings) (Hard) diff --git a/problems/verbal-arithmetic-puzzle/README.md b/problems/verbal-arithmetic-puzzle/README.md index 9982377e8..6068accde 100644 --- a/problems/verbal-arithmetic-puzzle/README.md +++ b/problems/verbal-arithmetic-puzzle/README.md @@ -11,18 +11,18 @@ ## [1307. Verbal Arithmetic Puzzle (Hard)](https://leetcode.com/problems/verbal-arithmetic-puzzle "口算难题") -

    Given an equation, represented by words on left side and the result on right side.

    +

    Given an equation, represented by words on the left side and the result on the right side.

    -

    You need to check if the equation is solvable under the following rules:

    +

    You need to check if the equation is solvable under the following rules:

    • Each character is decoded as one digit (0 - 9).
    • -
    • Every pair of different characters they must map to different digits.
    • -
    • Each words[i] and result are decoded as one number without leading zeros.
    • -
    • Sum of numbers on left side (words) will equal to the number on right side (result). 
    • +
    • Every pair of different characters must map to different digits.
    • +
    • Each words[i] and result are decoded as one number without leading zeros.
    • +
    • Sum of numbers on the left side (words) will equal to the number on the right side (result).
    -

    Return True if the equation is solvable otherwise return False.

    +

    Return true if the equation is solvable, otherwise return false.

     

    Example 1:

    @@ -43,13 +43,6 @@ Such that: "SIX" + "SEVEN" + "SEVEN" = "TWENT

    Example 3:

    -
    -Input: words = ["THIS","IS","TOO"], result = "FUNNY"
    -Output: true
    -
    - -

    Example 4:

    -
     Input: words = ["LEET","CODE"], result = "POINT"
     Output: false
    diff --git a/problems/video-stitching/README.md b/problems/video-stitching/README.md
    index c97194b4c..bc7031855 100644
    --- a/problems/video-stitching/README.md
    +++ b/problems/video-stitching/README.md
    @@ -1,8 +1,8 @@
     
     
    -
    -
    -
    +
    +
    +
     
     
     [< Previous](../camelcase-matching "Camelcase Matching")
    @@ -29,8 +29,7 @@
     
     Input: clips = [[0,2],[4,6],[8,10],[1,9],[1,5],[5,9]], time = 10
     Output: 3
    -Explanation: 
    -We take the clips [0,2], [8,10], [1,9]; a total of 3 clips.
    +Explanation: We take the clips [0,2], [8,10], [1,9]; a total of 3 clips.
     Then, we can reconstruct the sporting event as follows:
     We cut [1,9] into segments [1,2] + [2,8] + [8,9].
     Now we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 10].
    @@ -41,7 +40,7 @@ Now we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 1
     
     Input: clips = [[0,1],[1,2]], time = 5
     Output: -1
    -Explanation: We can't cover [0,5] with only [0,1] and [1,2].
    +Explanation: We cannot cover [0,5] with only [0,1] and [1,2].
     

    Example 3:

    @@ -52,14 +51,6 @@ Now we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 1 Explanation: We can take clips [0,4], [4,7], and [6,9].
    -

    Example 4:

    - -
    -Input: clips = [[0,4],[2,8]], time = 5
    -Output: 2
    -Explanation: Notice you can have extra video after the event ends.
    -
    -

     

    Constraints:

    diff --git a/problems/vowels-of-all-substrings/README.md b/problems/vowels-of-all-substrings/README.md index 3d35932cd..a508e72c8 100644 --- a/problems/vowels-of-all-substrings/README.md +++ b/problems/vowels-of-all-substrings/README.md @@ -40,21 +40,15 @@ Hence, the total sum of vowels = 0 + 1 + 1 + 1 + 1 + 2 = 6. All possible substrings are: "a", "ab", "abc", "b", "bc", and "c". - "a", "ab", and "abc" have 1 vowel each - "b", "bc", and "c" have 0 vowels each -Hence, the total sum of vowels = 1 + 1 + 1 + 0 + 0 + 0 = 3.
    +Hence, the total sum of vowels = 1 + 1 + 1 + 0 + 0 + 0 = 3. +

    Example 3:

     Input: word = "ltcd"
     Output: 0
    -Explanation: There are no vowels in any substring of "ltcd".
    - -

    Example 4:

    - -
    -Input: word = "noosabasboosa"
    -Output: 237
    -Explanation: There are a total of 237 vowels in all the substrings.
    +Explanation: There are no vowels in any substring of "ltcd".
     

     

    diff --git a/problems/water-bottles/README.md b/problems/water-bottles/README.md index a12dce419..b299bdd88 100644 --- a/problems/water-bottles/README.md +++ b/problems/water-bottles/README.md @@ -11,55 +11,37 @@ ## [1518. Water Bottles (Easy)](https://leetcode.com/problems/water-bottles "换酒问题") -

    Given numBottles full water bottles, you can exchange numExchange empty water bottles for one full water bottle.

    +

    There are numBottles water bottles that are initially full of water. You can exchange numExchange empty water bottles from the market with one full water bottle.

    The operation of drinking a full water bottle turns it into an empty bottle.

    -

    Return the maximum number of water bottles you can drink.

    +

    Given the two integers numBottles and numExchange, return the maximum number of water bottles you can drink.

     

    Example 1:

    - -

    - +
     Input: numBottles = 9, numExchange = 3
     Output: 13
     Explanation: You can exchange 3 empty bottles to get 1 full water bottle.
    -Number of water bottles you can drink: 9 + 3 + 1 = 13.
    +Number of water bottles you can drink: 9 + 3 + 1 = 13.
     

    Example 2:

    - -

    - +
     Input: numBottles = 15, numExchange = 4
     Output: 19
     Explanation: You can exchange 4 empty bottles to get 1 full water bottle. 
    -Number of water bottles you can drink: 15 + 3 + 1 = 19.
    -
    - -

    Example 3:

    - -
    -Input: numBottles = 5, numExchange = 5
    -Output: 6
    -
    - -

    Example 4:

    - -
    -Input: numBottles = 2, numExchange = 3
    -Output: 2
    +Number of water bottles you can drink: 15 + 3 + 1 = 19.
     

     

    Constraints:

      -
    • 1 <= numBottles <= 100
    • -
    • 2 <= numExchange <= 100
    • +
    • 1 <= numBottles <= 100
    • +
    • 2 <= numExchange <= 100
    ### Related Topics diff --git a/problems/watering-plants-ii/README.md b/problems/watering-plants-ii/README.md new file mode 100644 index 000000000..1d68c1646 --- /dev/null +++ b/problems/watering-plants-ii/README.md @@ -0,0 +1,94 @@ + + + + + + + +[< Previous](../sum-of-subarray-ranges "Sum of Subarray Ranges") +                 +[Next >](../maximum-fruits-harvested-after-at-most-k-steps "Maximum Fruits Harvested After at Most K Steps") + +## [2105. Watering Plants II (Medium)](https://leetcode.com/problems/watering-plants-ii "给植物浇水 II") + +

    Alice and Bob want to water n plants in their garden. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i.

    + +

    Each plant needs a specific amount of water. Alice and Bob have a watering can each, initially full. They water the plants in the following way:

    + +
      +
    • Alice waters the plants in order from left to right, starting from the 0th plant. Bob waters the plants in order from right to left, starting from the (n - 1)th plant. They begin watering the plants simultaneously.
    • +
    • It takes the same amount of time to water each plant regardless of how much water it needs.
    • +
    • Alice/Bob must water the plant if they have enough in their can to fully water it. Otherwise, they first refill their can (instantaneously) then water the plant.
    • +
    • In case both Alice and Bob reach the same plant, the one with more water currently in his/her watering can should water this plant. If they have the same amount of water, then Alice should water this plant.
    • +
    + +

    Given a 0-indexed integer array plants of n integers, where plants[i] is the amount of water the ith plant needs, and two integers capacityA and capacityB representing the capacities of Alice's and Bob's watering cans respectively, return the number of times they have to refill to water all the plants.

    + +

     

    +

    Example 1:

    + +
    +Input: plants = [2,2,3,3], capacityA = 5, capacityB = 5
    +Output: 1
    +Explanation:
    +- Initially, Alice and Bob have 5 units of water each in their watering cans.
    +- Alice waters plant 0, Bob waters plant 3.
    +- Alice and Bob now have 3 units and 2 units of water respectively.
    +- Alice has enough water for plant 1, so she waters it. Bob does not have enough water for plant 2, so he refills his can then waters it.
    +So, the total number of times they have to refill to water all the plants is 0 + 0 + 1 + 0 = 1.
    +
    + +

    Example 2:

    + +
    +Input: plants = [2,2,3,3], capacityA = 3, capacityB = 4
    +Output: 2
    +Explanation:
    +- Initially, Alice and Bob have 3 units and 4 units of water in their watering cans respectively.
    +- Alice waters plant 0, Bob waters plant 3.
    +- Alice and Bob now have 1 unit of water each, and need to water plants 1 and 2 respectively.
    +- Since neither of them have enough water for their current plants, they refill their cans and then water the plants.
    +So, the total number of times they have to refill to water all the plants is 0 + 1 + 1 + 0 = 2.
    +
    + +

    Example 3:

    + +
    +Input: plants = [5], capacityA = 10, capacityB = 8
    +Output: 0
    +Explanation:
    +- There is only one plant.
    +- Alice's watering can has 10 units of water, whereas Bob's can has 8 units. Since Alice has more water in her can, she waters this plant.
    +So, the total number of times they have to refill is 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == plants.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= plants[i] <= 106
    • +
    • max(plants[i]) <= capacityA, capacityB <= 109
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Try "simulating" the process. +
    + +
    +Hint 2 +Since watering each plant takes the same amount of time, where will Alice and Bob meet if they start watering the plants simultaneously? How can you use this to optimize your solution? +
    + +
    +Hint 3 +What will you do when both Alice and Bob have to water the same plant? +
    diff --git a/problems/ways-to-split-array-into-three-subarrays/README.md b/problems/ways-to-split-array-into-three-subarrays/README.md index 543aad389..f9621b2da 100644 --- a/problems/ways-to-split-array-into-three-subarrays/README.md +++ b/problems/ways-to-split-array-into-three-subarrays/README.md @@ -60,6 +60,9 @@ [[Binary Search](../../tag/binary-search/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] +### Similar Questions + 1. [Number of Ways to Divide a Long Corridor](../number-of-ways-to-divide-a-long-corridor) (Hard) + ### Hints
    Hint 1 diff --git a/problems/weather-type-in-each-country/README.md b/problems/weather-type-in-each-country/README.md index 981076584..a58e2ea24 100644 --- a/problems/weather-type-in-each-country/README.md +++ b/problems/weather-type-in-each-country/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-path-in-a-grid-with-obstacles-elimination "Shortest Path in a Grid with Obstacles Elimination") diff --git a/problems/where-will-the-ball-fall/README.md b/problems/where-will-the-ball-fall/README.md index 62d5babec..5d79d418e 100644 --- a/problems/where-will-the-ball-fall/README.md +++ b/problems/where-will-the-ball-fall/README.md @@ -66,9 +66,9 @@ Ball b4 is dropped at column 4 and will get stuck on the box between column 2 an ### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/wiggle-subsequence/README.md b/problems/wiggle-subsequence/README.md index 1f0439667..238eb4b28 100644 --- a/problems/wiggle-subsequence/README.md +++ b/problems/wiggle-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../guess-number-higher-or-lower-ii "Guess Number Higher or Lower II") @@ -59,6 +59,9 @@ One is [1, 17, 10, 13, 10, 16, 8] with differences (16, -7, 3, -3, 6, -8).

    Follow up: Could you solve this in O(n) time?

    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Similar Questions + 1. [Rearrange Array Elements by Sign](../rearrange-array-elements-by-sign) (Medium) diff --git a/problems/word-abbreviation/README.md b/problems/word-abbreviation/README.md index 16762d141..7fd9f8a67 100644 --- a/problems/word-abbreviation/README.md +++ b/problems/word-abbreviation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../beautiful-arrangement "Beautiful Arrangement") diff --git a/problems/word-pattern-ii/README.md b/problems/word-pattern-ii/README.md index dbe80c671..b7e543f01 100644 --- a/problems/word-pattern-ii/README.md +++ b/problems/word-pattern-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-pattern "Word Pattern") diff --git a/problems/word-squares/README.md b/problems/word-squares/README.md index 05908d666..49634a077 100644 --- a/problems/word-squares/README.md +++ b/problems/word-squares/README.md @@ -82,10 +82,10 @@ The output consists of two word squares. The order of output does not matter (ju

    ### Related Topics - [[Trie](../../tag/trie/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Trie](../../tag/trie/README.md)] ### Similar Questions 1. [Valid Word Square](../valid-word-square) (Easy) diff --git a/problems/word-subsets/README.md b/problems/word-subsets/README.md index cca849a2d..67b953a6f 100644 --- a/problems/word-subsets/README.md +++ b/problems/word-subsets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../partition-array-into-disjoint-intervals "Partition Array into Disjoint Intervals") @@ -25,21 +25,19 @@

     

    Example 1:

    -
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","o"]
    -Output: ["facebook","google","leetcode"]
    -

    Example 2:

    -
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["l","e"]
    -Output: ["apple","google","leetcode"]
    -

    Example 3:

    -
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","oo"]
    -Output: ["facebook","google"]
    -

    Example 4:

    -
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["lo","eo"]
    -Output: ["google","leetcode"]
    -

    Example 5:

    -
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["ec","oc","ceo"]
    -Output: ["facebook","leetcode"]
    +
    +
    +Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","o"]
    +Output: ["facebook","google","leetcode"]
     
    + +

    Example 2:

    + +
    +Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["l","e"]
    +Output: ["apple","google","leetcode"]
    +
    +

     

    Constraints:

    diff --git a/problems/xor-operation-in-an-array/README.md b/problems/xor-operation-in-an-array/README.md index fb190c246..89580d8aa 100644 --- a/problems/xor-operation-in-an-array/README.md +++ b/problems/xor-operation-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../clone-binary-tree-with-random-pointer "Clone Binary Tree With Random Pointer") @@ -11,11 +11,11 @@ ## [1486. XOR Operation in an Array (Easy)](https://leetcode.com/problems/xor-operation-in-an-array "数组异或操作") -

    Given an integer n and an integer start.

    +

    You are given an integer n and an integer start.

    -

    Define an array nums where nums[i] = start + 2*i (0-indexed) and n == nums.length.

    +

    Define an array nums where nums[i] = start + 2 * i (0-indexed) and n == nums.length.

    -

    Return the bitwise XOR of all elements of nums.

    +

    Return the bitwise XOR of all elements of nums.

     

    Example 1:

    @@ -23,7 +23,7 @@
     Input: n = 5, start = 0
     Output: 8
    -Explanation: Array nums is equal to [0, 2, 4, 6, 8] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8.
    +Explanation: Array nums is equal to [0, 2, 4, 6, 8] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8.
     Where "^" corresponds to bitwise XOR operator.
     
    @@ -32,20 +32,7 @@ Where "^" corresponds to bitwise XOR operator.
     Input: n = 4, start = 3
     Output: 8
    -Explanation: Array nums is equal to [3, 5, 7, 9] where (3 ^ 5 ^ 7 ^ 9) = 8.
    - -

    Example 3:

    - -
    -Input: n = 1, start = 7
    -Output: 7
    -
    - -

    Example 4:

    - -
    -Input: n = 10, start = 5
    -Output: 2
    +Explanation: Array nums is equal to [3, 5, 7, 9] where (3 ^ 5 ^ 7 ^ 9) = 8.
     

     

    @@ -58,8 +45,8 @@ Where "^" corresponds to bitwise XOR operator. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/xor-queries-of-a-subarray/README.md b/problems/xor-queries-of-a-subarray/README.md index 90df382e7..86c7462b0 100644 --- a/problems/xor-queries-of-a-subarray/README.md +++ b/problems/xor-queries-of-a-subarray/README.md @@ -54,8 +54,8 @@ The XOR values for queries are: ### Related Topics - [[Array](../../tag/array/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints diff --git a/readme/1-300.md b/readme/1-300.md index a4db89dcb..4bb184fe2 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    @@ -130,7 +138,7 @@ LeetCode Problems' Solutions | 50 | [Pow(x, n)](https://leetcode.com/problems/powx-n "Pow(x, n)") | [Go](../problems/powx-n) | Medium | | 51 | [N-Queens](https://leetcode.com/problems/n-queens "N 皇后") | [Go](../problems/n-queens) | Hard | | 52 | [N-Queens II](https://leetcode.com/problems/n-queens-ii "N皇后 II") | [Go](../problems/n-queens-ii) | Hard | -| 53 | [Maximum Subarray](https://leetcode.com/problems/maximum-subarray "最大子序和") | [Go](../problems/maximum-subarray) | Easy | +| 53 | [Maximum Subarray](https://leetcode.com/problems/maximum-subarray "最大子数组和") | [Go](../problems/maximum-subarray) | Easy | | 54 | [Spiral Matrix](https://leetcode.com/problems/spiral-matrix "螺旋矩阵") | [Go](../problems/spiral-matrix) | Medium | | 55 | [Jump Game](https://leetcode.com/problems/jump-game "跳跃游戏") | [Go](../problems/jump-game) | Medium | | 56 | [Merge Intervals](https://leetcode.com/problems/merge-intervals "合并区间") | [Go](../problems/merge-intervals) | Medium | @@ -146,7 +154,7 @@ LeetCode Problems' Solutions | 66 | [Plus One](https://leetcode.com/problems/plus-one "加一") | [Go](../problems/plus-one) | Easy | | 67 | [Add Binary](https://leetcode.com/problems/add-binary "二进制求和") | [Go](../problems/add-binary) | Easy | | 68 | [Text Justification](https://leetcode.com/problems/text-justification "文本左右对齐") | [Go](../problems/text-justification) | Hard | -| 69 | [Sqrt(x)](https://leetcode.com/problems/sqrtx "Sqrt(x)") | [Go](../problems/sqrtx) | Easy | +| 69 | [Sqrt(x)](https://leetcode.com/problems/sqrtx "x 的平方根 ") | [Go](../problems/sqrtx) | Easy | | 70 | [Climbing Stairs](https://leetcode.com/problems/climbing-stairs "爬楼梯") | [Go](../problems/climbing-stairs) | Easy | | 71 | [Simplify Path](https://leetcode.com/problems/simplify-path "简化路径") | [Go](../problems/simplify-path) | Medium | | 72 | [Edit Distance](https://leetcode.com/problems/edit-distance "编辑距离") | [Go](../problems/edit-distance) | Hard | @@ -223,7 +231,7 @@ LeetCode Problems' Solutions | 143 | [Reorder List](https://leetcode.com/problems/reorder-list "重排链表") | [Go](../problems/reorder-list) | Medium | | 144 | [Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal "二叉树的前序遍历") | [Go](../problems/binary-tree-preorder-traversal) | Easy | | 145 | [Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历") | [Go](../problems/binary-tree-postorder-traversal) | Easy | -| 146 | [LRU Cache](https://leetcode.com/problems/lru-cache "LRU 缓存机制") | [Go](../problems/lru-cache) | Medium | +| 146 | [LRU Cache](https://leetcode.com/problems/lru-cache "LRU 缓存") | [Go](../problems/lru-cache) | Medium | | 147 | [Insertion Sort List](https://leetcode.com/problems/insertion-sort-list "对链表进行插入排序") | [Go](../problems/insertion-sort-list) | Medium | | 148 | [Sort List](https://leetcode.com/problems/sort-list "排序链表") | [Go](../problems/sort-list) | Medium | | 149 | [Max Points on a Line](https://leetcode.com/problems/max-points-on-a-line "直线上最多的点数") | [Go](../problems/max-points-on-a-line) | Hard | @@ -244,7 +252,7 @@ LeetCode Problems' Solutions | 164 | [Maximum Gap](https://leetcode.com/problems/maximum-gap "最大间距") | [Go](../problems/maximum-gap) | Hard | | 165 | [Compare Version Numbers](https://leetcode.com/problems/compare-version-numbers "比较版本号") | [Go](../problems/compare-version-numbers) | Medium | | 166 | [Fraction to Recurring Decimal](https://leetcode.com/problems/fraction-to-recurring-decimal "分数到小数") | [Go](../problems/fraction-to-recurring-decimal) | Medium | -| 167 | [Two Sum II - Input Array Is Sorted](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted "两数之和 II - 输入有序数组") | [Go](../problems/two-sum-ii-input-array-is-sorted) | Easy | +| 167 | [Two Sum II - Input Array Is Sorted](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted "两数之和 II - 输入有序数组") | [Go](../problems/two-sum-ii-input-array-is-sorted) | Medium | | 168 | [Excel Sheet Column Title](https://leetcode.com/problems/excel-sheet-column-title "Excel表列名称") | [Go](../problems/excel-sheet-column-title) | Easy | | 169 | [Majority Element](https://leetcode.com/problems/majority-element "多数元素") | [Go](../problems/majority-element) | Easy | | 170 | [Two Sum III - Data structure design](https://leetcode.com/problems/two-sum-iii-data-structure-design "两数之和 III - 数据结构设计") 🔒 | [Go](../problems/two-sum-iii-data-structure-design) | Easy | @@ -361,7 +369,7 @@ LeetCode Problems' Solutions | 281 | [Zigzag Iterator](https://leetcode.com/problems/zigzag-iterator "锯齿迭代器") 🔒 | [Go](../problems/zigzag-iterator) | Medium | | 282 | [Expression Add Operators](https://leetcode.com/problems/expression-add-operators "给表达式添加运算符") | [Go](../problems/expression-add-operators) | Hard | | 283 | [Move Zeroes](https://leetcode.com/problems/move-zeroes "移动零") | [Go](../problems/move-zeroes) | Easy | -| 284 | [Peeking Iterator](https://leetcode.com/problems/peeking-iterator "窥探迭代器") | [Go](../problems/peeking-iterator) | Medium | +| 284 | [Peeking Iterator](https://leetcode.com/problems/peeking-iterator "顶端迭代器") | [Go](../problems/peeking-iterator) | Medium | | 285 | [Inorder Successor in BST](https://leetcode.com/problems/inorder-successor-in-bst "二叉搜索树中的中序后继") 🔒 | [Go](../problems/inorder-successor-in-bst) | Medium | | 286 | [Walls and Gates](https://leetcode.com/problems/walls-and-gates "墙与门") 🔒 | [Go](../problems/walls-and-gates) | Medium | | 287 | [Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number "寻找重复数") | [Go](../problems/find-the-duplicate-number) | Medium | diff --git a/readme/1201-1500.md b/readme/1201-1500.md index 8b5c5123a..cd9ca1be8 100644 --- a/readme/1201-1500.md +++ b/readme/1201-1500.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    @@ -252,7 +260,7 @@ LeetCode Problems' Solutions | 1372 | [Longest ZigZag Path in a Binary Tree](https://leetcode.com/problems/longest-zigzag-path-in-a-binary-tree "二叉树中的最长交错路径") | [Go](../problems/longest-zigzag-path-in-a-binary-tree) | Medium | | 1373 | [Maximum Sum BST in Binary Tree](https://leetcode.com/problems/maximum-sum-bst-in-binary-tree "二叉搜索子树的最大键值和") | [Go](../problems/maximum-sum-bst-in-binary-tree) | Hard | | 1374 | [Generate a String With Characters That Have Odd Counts](https://leetcode.com/problems/generate-a-string-with-characters-that-have-odd-counts "生成每种字符都是奇数个的字符串") | [Go](../problems/generate-a-string-with-characters-that-have-odd-counts) | Easy | -| 1375 | [Bulb Switcher III](https://leetcode.com/problems/bulb-switcher-iii "灯泡开关 III") | [Go](../problems/bulb-switcher-iii) | Medium | +| 1375 | [Number of Times Binary String Is Prefix-Aligned](https://leetcode.com/problems/number-of-times-binary-string-is-prefix-aligned "二进制字符串前缀一致的次数") | [Go](../problems/number-of-times-binary-string-is-prefix-aligned) | Medium | | 1376 | [Time Needed to Inform All Employees](https://leetcode.com/problems/time-needed-to-inform-all-employees "通知所有员工所需的时间") | [Go](../problems/time-needed-to-inform-all-employees) | Medium | | 1377 | [Frog Position After T Seconds](https://leetcode.com/problems/frog-position-after-t-seconds "T 秒后青蛙的位置") | [Go](../problems/frog-position-after-t-seconds) | Hard | | 1378 | [Replace Employee ID With The Unique Identifier](https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier "使用唯一标识码替换员工ID") 🔒 | [MySQL](../problems/replace-employee-id-with-the-unique-identifier) | Easy | diff --git a/readme/1501-1800.md b/readme/1501-1800.md new file mode 100644 index 000000000..85463f503 --- /dev/null +++ b/readme/1501-1800.md @@ -0,0 +1,388 @@ + + + + + + + +# [LeetCode](https://awesee.github.io/leetcode) +LeetCode Problems' Solutions +[[力扣](https://awesee.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/awesee/leetcode/blob/master/tag/README.md)] + +[![Go](https://github.com/awesee/leetcode/workflows/Go/badge.svg)](https://github.com/awesee/leetcode/actions) +[![codecov](https://codecov.io/gh/awesee/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/awesee/leetcode) +[![Go Report Card](https://goreportcard.com/badge/github.com/awesee/leetcode)](https://goreportcard.com/report/github.com/awesee/leetcode) +[![GitHub contributors](https://img.shields.io/github/contributors/awesee/leetcode.svg)](https://github.com/awesee/leetcode/graphs/contributors) +[![license](https://img.shields.io/github/license/awesee/leetcode.svg)](https://github.com/awesee/leetcode/blob/master/LICENSE) +[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fawesee%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fawesee%2Fleetcode?ref=badge_shield) +[![Join the chat](https://badges.gitter.im/awesee/leetcode.svg)](https://gitter.im/awesee/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    + +| # | Title | Solution | Difficulty | +| :-: | - | - | :-: | +| 1501 | [Countries You Can Safely Invest In](https://leetcode.com/problems/countries-you-can-safely-invest-in "可以放心投资的国家") 🔒 | [MySQL](../problems/countries-you-can-safely-invest-in) | Medium | +| 1502 | [Can Make Arithmetic Progression From Sequence](https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence "判断能否形成等差数列") | [Go](../problems/can-make-arithmetic-progression-from-sequence) | Easy | +| 1503 | [Last Moment Before All Ants Fall Out of a Plank](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank "所有蚂蚁掉下来前的最后一刻") | [Go](../problems/last-moment-before-all-ants-fall-out-of-a-plank) | Medium | +| 1504 | [Count Submatrices With All Ones](https://leetcode.com/problems/count-submatrices-with-all-ones "统计全 1 子矩形") | [Go](../problems/count-submatrices-with-all-ones) | Medium | +| 1505 | [Minimum Possible Integer After at Most K Adjacent Swaps On Digits](https://leetcode.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "最多 K 次交换相邻数位后得到的最小整数") | [Go](../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | Hard | +| 1506 | [Find Root of N-Ary Tree](https://leetcode.com/problems/find-root-of-n-ary-tree "找到 N 叉树的根节点") 🔒 | [Go](../problems/find-root-of-n-ary-tree) | Medium | +| 1507 | [Reformat Date](https://leetcode.com/problems/reformat-date "转变日期格式") | [Go](../problems/reformat-date) | Easy | +| 1508 | [Range Sum of Sorted Subarray Sums](https://leetcode.com/problems/range-sum-of-sorted-subarray-sums "子数组和排序后的区间和") | [Go](../problems/range-sum-of-sorted-subarray-sums) | Medium | +| 1509 | [Minimum Difference Between Largest and Smallest Value in Three Moves](https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves "三次操作后最大值与最小值的最小差") | [Go](../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | Medium | +| 1510 | [Stone Game IV](https://leetcode.com/problems/stone-game-iv "石子游戏 IV") | [Go](../problems/stone-game-iv) | Hard | +| 1511 | [Customer Order Frequency](https://leetcode.com/problems/customer-order-frequency "消费者下单频率") 🔒 | [MySQL](../problems/customer-order-frequency) | Easy | +| 1512 | [Number of Good Pairs](https://leetcode.com/problems/number-of-good-pairs "好数对的数目") | [Go](../problems/number-of-good-pairs) | Easy | +| 1513 | [Number of Substrings With Only 1s](https://leetcode.com/problems/number-of-substrings-with-only-1s "仅含 1 的子串数") | [Go](../problems/number-of-substrings-with-only-1s) | Medium | +| 1514 | [Path with Maximum Probability](https://leetcode.com/problems/path-with-maximum-probability "概率最大的路径") | [Go](../problems/path-with-maximum-probability) | Medium | +| 1515 | [Best Position for a Service Centre](https://leetcode.com/problems/best-position-for-a-service-centre "服务中心的最佳位置") | [Go](../problems/best-position-for-a-service-centre) | Hard | +| 1516 | [Move Sub-Tree of N-Ary Tree](https://leetcode.com/problems/move-sub-tree-of-n-ary-tree "移动 N 叉树的子树") 🔒 | [Go](../problems/move-sub-tree-of-n-ary-tree) | Hard | +| 1517 | [Find Users With Valid E-Mails](https://leetcode.com/problems/find-users-with-valid-e-mails "查找拥有有效邮箱的用户") 🔒 | [MySQL](../problems/find-users-with-valid-e-mails) | Easy | +| 1518 | [Water Bottles](https://leetcode.com/problems/water-bottles "换酒问题") | [Go](../problems/water-bottles) | Easy | +| 1519 | [Number of Nodes in the Sub-Tree With the Same Label](https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label "子树中标签相同的节点数") | [Go](../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | Medium | +| 1520 | [Maximum Number of Non-Overlapping Substrings](https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings "最多的不重叠子字符串") | [Go](../problems/maximum-number-of-non-overlapping-substrings) | Hard | +| 1521 | [Find a Value of a Mysterious Function Closest to Target](https://leetcode.com/problems/find-a-value-of-a-mysterious-function-closest-to-target "找到最接近目标值的函数值") | [Go](../problems/find-a-value-of-a-mysterious-function-closest-to-target) | Hard | +| 1522 | [Diameter of N-Ary Tree](https://leetcode.com/problems/diameter-of-n-ary-tree "N 叉树的直径") 🔒 | [Go](../problems/diameter-of-n-ary-tree) | Medium | +| 1523 | [Count Odd Numbers in an Interval Range](https://leetcode.com/problems/count-odd-numbers-in-an-interval-range "在区间范围内统计奇数数目") | [Go](../problems/count-odd-numbers-in-an-interval-range) | Easy | +| 1524 | [Number of Sub-arrays With Odd Sum](https://leetcode.com/problems/number-of-sub-arrays-with-odd-sum "和为奇数的子数组数目") | [Go](../problems/number-of-sub-arrays-with-odd-sum) | Medium | +| 1525 | [Number of Good Ways to Split a String](https://leetcode.com/problems/number-of-good-ways-to-split-a-string "字符串的好分割数目") | [Go](../problems/number-of-good-ways-to-split-a-string) | Medium | +| 1526 | [Minimum Number of Increments on Subarrays to Form a Target Array](https://leetcode.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array "形成目标数组的子数组最少增加次数") | [Go](../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | Hard | +| 1527 | [Patients With a Condition](https://leetcode.com/problems/patients-with-a-condition "患某种疾病的患者") 🔒 | [MySQL](../problems/patients-with-a-condition) | Easy | +| 1528 | [Shuffle String](https://leetcode.com/problems/shuffle-string "重新排列字符串") | [Go](../problems/shuffle-string) | Easy | +| 1529 | [Minimum Suffix Flips](https://leetcode.com/problems/minimum-suffix-flips "最少的后缀翻转次数") | [Go](../problems/minimum-suffix-flips) | Medium | +| 1530 | [Number of Good Leaf Nodes Pairs](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs "好叶子节点对的数量") | [Go](../problems/number-of-good-leaf-nodes-pairs) | Medium | +| 1531 | [String Compression II](https://leetcode.com/problems/string-compression-ii "压缩字符串 II") | [Go](../problems/string-compression-ii) | Hard | +| 1532 | [The Most Recent Three Orders](https://leetcode.com/problems/the-most-recent-three-orders "最近的三笔订单") 🔒 | [MySQL](../problems/the-most-recent-three-orders) | Medium | +| 1533 | [Find the Index of the Large Integer](https://leetcode.com/problems/find-the-index-of-the-large-integer "找到最大整数的索引") 🔒 | [Go](../problems/find-the-index-of-the-large-integer) | Medium | +| 1534 | [Count Good Triplets](https://leetcode.com/problems/count-good-triplets "统计好三元组") | [Go](../problems/count-good-triplets) | Easy | +| 1535 | [Find the Winner of an Array Game](https://leetcode.com/problems/find-the-winner-of-an-array-game "找出数组游戏的赢家") | [Go](../problems/find-the-winner-of-an-array-game) | Medium | +| 1536 | [Minimum Swaps to Arrange a Binary Grid](https://leetcode.com/problems/minimum-swaps-to-arrange-a-binary-grid "排布二进制网格的最少交换次数") | [Go](../problems/minimum-swaps-to-arrange-a-binary-grid) | Medium | +| 1537 | [Get the Maximum Score](https://leetcode.com/problems/get-the-maximum-score "最大得分") | [Go](../problems/get-the-maximum-score) | Hard | +| 1538 | [Guess the Majority in a Hidden Array](https://leetcode.com/problems/guess-the-majority-in-a-hidden-array "找出隐藏数组中出现次数最多的元素") 🔒 | [Go](../problems/guess-the-majority-in-a-hidden-array) | Medium | +| 1539 | [Kth Missing Positive Number](https://leetcode.com/problems/kth-missing-positive-number "第 k 个缺失的正整数") | [Go](../problems/kth-missing-positive-number) | Easy | +| 1540 | [Can Convert String in K Moves](https://leetcode.com/problems/can-convert-string-in-k-moves "K 次操作转变字符串") | [Go](../problems/can-convert-string-in-k-moves) | Medium | +| 1541 | [Minimum Insertions to Balance a Parentheses String](https://leetcode.com/problems/minimum-insertions-to-balance-a-parentheses-string "平衡括号字符串的最少插入次数") | [Go](../problems/minimum-insertions-to-balance-a-parentheses-string) | Medium | +| 1542 | [Find Longest Awesome Substring](https://leetcode.com/problems/find-longest-awesome-substring "找出最长的超赞子字符串") | [Go](../problems/find-longest-awesome-substring) | Hard | +| 1543 | [Fix Product Name Format](https://leetcode.com/problems/fix-product-name-format "产品名称格式修复") 🔒 | [MySQL](../problems/fix-product-name-format) | Easy | +| 1544 | [Make The String Great](https://leetcode.com/problems/make-the-string-great "整理字符串") | [Go](../problems/make-the-string-great) | Easy | +| 1545 | [Find Kth Bit in Nth Binary String](https://leetcode.com/problems/find-kth-bit-in-nth-binary-string "找出第 N 个二进制字符串中的第 K 位") | [Go](../problems/find-kth-bit-in-nth-binary-string) | Medium | +| 1546 | [Maximum Number of Non-Overlapping Subarrays With Sum Equals Target](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值且不重叠的非空子数组的最大数目") | [Go](../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | Medium | +| 1547 | [Minimum Cost to Cut a Stick](https://leetcode.com/problems/minimum-cost-to-cut-a-stick "切棍子的最小成本") | [Go](../problems/minimum-cost-to-cut-a-stick) | Hard | +| 1548 | [The Most Similar Path in a Graph](https://leetcode.com/problems/the-most-similar-path-in-a-graph "图中最相似的路径") 🔒 | [Go](../problems/the-most-similar-path-in-a-graph) | Hard | +| 1549 | [The Most Recent Orders for Each Product](https://leetcode.com/problems/the-most-recent-orders-for-each-product "每件商品的最新订单") 🔒 | [MySQL](../problems/the-most-recent-orders-for-each-product) | Medium | +| 1550 | [Three Consecutive Odds](https://leetcode.com/problems/three-consecutive-odds "存在连续三个奇数的数组") | [Go](../problems/three-consecutive-odds) | Easy | +| 1551 | [Minimum Operations to Make Array Equal](https://leetcode.com/problems/minimum-operations-to-make-array-equal "使数组中所有元素相等的最小操作数") | [Go](../problems/minimum-operations-to-make-array-equal) | Medium | +| 1552 | [Magnetic Force Between Two Balls](https://leetcode.com/problems/magnetic-force-between-two-balls "两球之间的磁力") | [Go](../problems/magnetic-force-between-two-balls) | Medium | +| 1553 | [Minimum Number of Days to Eat N Oranges](https://leetcode.com/problems/minimum-number-of-days-to-eat-n-oranges "吃掉 N 个橘子的最少天数") | [Go](../problems/minimum-number-of-days-to-eat-n-oranges) | Hard | +| 1554 | [Strings Differ by One Character](https://leetcode.com/problems/strings-differ-by-one-character "只有一个不同字符的字符串") 🔒 | [Go](../problems/strings-differ-by-one-character) | Medium | +| 1555 | [Bank Account Summary](https://leetcode.com/problems/bank-account-summary "银行账户概要") 🔒 | [MySQL](../problems/bank-account-summary) | Medium | +| 1556 | [Thousand Separator](https://leetcode.com/problems/thousand-separator "千位分隔数") | [Go](../problems/thousand-separator) | Easy | +| 1557 | [Minimum Number of Vertices to Reach All Nodes](https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes "可以到达所有点的最少点数目") | [Go](../problems/minimum-number-of-vertices-to-reach-all-nodes) | Medium | +| 1558 | [Minimum Numbers of Function Calls to Make Target Array](https://leetcode.com/problems/minimum-numbers-of-function-calls-to-make-target-array "得到目标数组的最少函数调用次数") | [Go](../problems/minimum-numbers-of-function-calls-to-make-target-array) | Medium | +| 1559 | [Detect Cycles in 2D Grid](https://leetcode.com/problems/detect-cycles-in-2d-grid "二维网格图中探测环") | [Go](../problems/detect-cycles-in-2d-grid) | Medium | +| 1560 | [Most Visited Sector in a Circular Track](https://leetcode.com/problems/most-visited-sector-in-a-circular-track "圆形赛道上经过次数最多的扇区") | [Go](../problems/most-visited-sector-in-a-circular-track) | Easy | +| 1561 | [Maximum Number of Coins You Can Get](https://leetcode.com/problems/maximum-number-of-coins-you-can-get "你可以获得的最大硬币数目") | [Go](../problems/maximum-number-of-coins-you-can-get) | Medium | +| 1562 | [Find Latest Group of Size M](https://leetcode.com/problems/find-latest-group-of-size-m "查找大小为 M 的最新分组") | [Go](../problems/find-latest-group-of-size-m) | Medium | +| 1563 | [Stone Game V](https://leetcode.com/problems/stone-game-v "石子游戏 V") | [Go](../problems/stone-game-v) | Hard | +| 1564 | [Put Boxes Into the Warehouse I](https://leetcode.com/problems/put-boxes-into-the-warehouse-i "把箱子放进仓库里 I") 🔒 | [Go](../problems/put-boxes-into-the-warehouse-i) | Medium | +| 1565 | [Unique Orders and Customers Per Month](https://leetcode.com/problems/unique-orders-and-customers-per-month "按月统计订单数与顾客数") 🔒 | [MySQL](../problems/unique-orders-and-customers-per-month) | Easy | +| 1566 | [Detect Pattern of Length M Repeated K or More Times](https://leetcode.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times "重复至少 K 次且长度为 M 的模式") | [Go](../problems/detect-pattern-of-length-m-repeated-k-or-more-times) | Easy | +| 1567 | [Maximum Length of Subarray With Positive Product](https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product "乘积为正数的最长子数组长度") | [Go](../problems/maximum-length-of-subarray-with-positive-product) | Medium | +| 1568 | [Minimum Number of Days to Disconnect Island](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数") | [Go](../problems/minimum-number-of-days-to-disconnect-island) | Hard | +| 1569 | [Number of Ways to Reorder Array to Get Same BST](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst "将子数组重新排序得到同一个二叉查找树的方案数") | [Go](../problems/number-of-ways-to-reorder-array-to-get-same-bst) | Hard | +| 1570 | [Dot Product of Two Sparse Vectors](https://leetcode.com/problems/dot-product-of-two-sparse-vectors "两个稀疏向量的点积") 🔒 | [Go](../problems/dot-product-of-two-sparse-vectors) | Medium | +| 1571 | [Warehouse Manager](https://leetcode.com/problems/warehouse-manager "仓库经理") 🔒 | [MySQL](../problems/warehouse-manager) | Easy | +| 1572 | [Matrix Diagonal Sum](https://leetcode.com/problems/matrix-diagonal-sum "矩阵对角线元素的和") | [Go](../problems/matrix-diagonal-sum) | Easy | +| 1573 | [Number of Ways to Split a String](https://leetcode.com/problems/number-of-ways-to-split-a-string "分割字符串的方案数") | [Go](../problems/number-of-ways-to-split-a-string) | Medium | +| 1574 | [Shortest Subarray to be Removed to Make Array Sorted](https://leetcode.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted "删除最短的子数组使剩余数组有序") | [Go](../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | Medium | +| 1575 | [Count All Possible Routes](https://leetcode.com/problems/count-all-possible-routes "统计所有可行路径") | [Go](../problems/count-all-possible-routes) | Hard | +| 1576 | [Replace All ?'s to Avoid Consecutive Repeating Characters](https://leetcode.com/problems/replace-all-s-to-avoid-consecutive-repeating-characters "替换所有的问号") | [Go](../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | Easy | +| 1577 | [Number of Ways Where Square of Number Is Equal to Product of Two Numbers](https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "数的平方等于两数乘积的方法数") | [Go](../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | Medium | +| 1578 | [Minimum Time to Make Rope Colorful](https://leetcode.com/problems/minimum-time-to-make-rope-colorful "使绳子变成彩色的最短时间") | [Go](../problems/minimum-time-to-make-rope-colorful) | Medium | +| 1579 | [Remove Max Number of Edges to Keep Graph Fully Traversable](https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable "保证图可完全遍历") | [Go](../problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | Hard | +| 1580 | [Put Boxes Into the Warehouse II](https://leetcode.com/problems/put-boxes-into-the-warehouse-ii "把箱子放进仓库里 II") 🔒 | [Go](../problems/put-boxes-into-the-warehouse-ii) | Medium | +| 1581 | [Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的顾客") 🔒 | [MySQL](../problems/customer-who-visited-but-did-not-make-any-transactions) | Easy | +| 1582 | [Special Positions in a Binary Matrix](https://leetcode.com/problems/special-positions-in-a-binary-matrix "二进制矩阵中的特殊位置") | [Go](../problems/special-positions-in-a-binary-matrix) | Easy | +| 1583 | [Count Unhappy Friends](https://leetcode.com/problems/count-unhappy-friends "统计不开心的朋友") | [Go](../problems/count-unhappy-friends) | Medium | +| 1584 | [Min Cost to Connect All Points](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") | [Go](../problems/min-cost-to-connect-all-points) | Medium | +| 1585 | [Check If String Is Transformable With Substring Sort Operations](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations "检查字符串是否可以通过排序子字符串得到另一个字符串") | [Go](../problems/check-if-string-is-transformable-with-substring-sort-operations) | Hard | +| 1586 | [Binary Search Tree Iterator II](https://leetcode.com/problems/binary-search-tree-iterator-ii "二叉搜索树迭代器 II") 🔒 | [Go](../problems/binary-search-tree-iterator-ii) | Medium | +| 1587 | [Bank Account Summary II](https://leetcode.com/problems/bank-account-summary-ii "银行账户概要 II") 🔒 | [MySQL](../problems/bank-account-summary-ii) | Easy | +| 1588 | [Sum of All Odd Length Subarrays](https://leetcode.com/problems/sum-of-all-odd-length-subarrays "所有奇数长度子数组的和") | [Go](../problems/sum-of-all-odd-length-subarrays) | Easy | +| 1589 | [Maximum Sum Obtained of Any Permutation](https://leetcode.com/problems/maximum-sum-obtained-of-any-permutation "所有排列中的最大和") | [Go](../problems/maximum-sum-obtained-of-any-permutation) | Medium | +| 1590 | [Make Sum Divisible by P](https://leetcode.com/problems/make-sum-divisible-by-p "使数组和能被 P 整除") | [Go](../problems/make-sum-divisible-by-p) | Medium | +| 1591 | [Strange Printer II](https://leetcode.com/problems/strange-printer-ii "奇怪的打印机 II") | [Go](../problems/strange-printer-ii) | Hard | +| 1592 | [Rearrange Spaces Between Words](https://leetcode.com/problems/rearrange-spaces-between-words "重新排列单词间的空格") | [Go](../problems/rearrange-spaces-between-words) | Easy | +| 1593 | [Split a String Into the Max Number of Unique Substrings](https://leetcode.com/problems/split-a-string-into-the-max-number-of-unique-substrings "拆分字符串使唯一子字符串的数目最大") | [Go](../problems/split-a-string-into-the-max-number-of-unique-substrings) | Medium | +| 1594 | [Maximum Non Negative Product in a Matrix](https://leetcode.com/problems/maximum-non-negative-product-in-a-matrix "矩阵的最大非负积") | [Go](../problems/maximum-non-negative-product-in-a-matrix) | Medium | +| 1595 | [Minimum Cost to Connect Two Groups of Points](https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points "连通两组点的最小成本") | [Go](../problems/minimum-cost-to-connect-two-groups-of-points) | Hard | +| 1596 | [The Most Frequently Ordered Products for Each Customer](https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer "每位顾客最经常订购的商品") 🔒 | [MySQL](../problems/the-most-frequently-ordered-products-for-each-customer) | Medium | +| 1597 | [Build Binary Expression Tree From Infix Expression](https://leetcode.com/problems/build-binary-expression-tree-from-infix-expression "根据中缀表达式构造二叉表达式树") 🔒 | [Go](../problems/build-binary-expression-tree-from-infix-expression) | Hard | +| 1598 | [Crawler Log Folder](https://leetcode.com/problems/crawler-log-folder "文件夹操作日志搜集器") | [Go](../problems/crawler-log-folder) | Easy | +| 1599 | [Maximum Profit of Operating a Centennial Wheel](https://leetcode.com/problems/maximum-profit-of-operating-a-centennial-wheel "经营摩天轮的最大利润") | [Go](../problems/maximum-profit-of-operating-a-centennial-wheel) | Medium | +| 1600 | [Throne Inheritance](https://leetcode.com/problems/throne-inheritance "皇位继承顺序") | [Go](../problems/throne-inheritance) | Medium | +| 1601 | [Maximum Number of Achievable Transfer Requests](https://leetcode.com/problems/maximum-number-of-achievable-transfer-requests "最多可达成的换楼请求数目") | [Go](../problems/maximum-number-of-achievable-transfer-requests) | Hard | +| 1602 | [Find Nearest Right Node in Binary Tree](https://leetcode.com/problems/find-nearest-right-node-in-binary-tree "找到二叉树中最近的右侧节点") 🔒 | [Go](../problems/find-nearest-right-node-in-binary-tree) | Medium | +| 1603 | [Design Parking System](https://leetcode.com/problems/design-parking-system "设计停车系统") | [Go](../problems/design-parking-system) | Easy | +| 1604 | [Alert Using Same Key-Card Three or More Times in a One Hour Period](https://leetcode.com/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period "警告一小时内使用相同员工卡大于等于三次的人") | [Go](../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | Medium | +| 1605 | [Find Valid Matrix Given Row and Column Sums](https://leetcode.com/problems/find-valid-matrix-given-row-and-column-sums "给定行和列的和求可行矩阵") | [Go](../problems/find-valid-matrix-given-row-and-column-sums) | Medium | +| 1606 | [Find Servers That Handled Most Number of Requests](https://leetcode.com/problems/find-servers-that-handled-most-number-of-requests "找到处理最多请求的服务器") | [Go](../problems/find-servers-that-handled-most-number-of-requests) | Hard | +| 1607 | [Sellers With No Sales](https://leetcode.com/problems/sellers-with-no-sales "没有卖出的卖家") 🔒 | [MySQL](../problems/sellers-with-no-sales) | Easy | +| 1608 | [Special Array With X Elements Greater Than or Equal X](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x "特殊数组的特征值") | [Go](../problems/special-array-with-x-elements-greater-than-or-equal-x) | Easy | +| 1609 | [Even Odd Tree](https://leetcode.com/problems/even-odd-tree "奇偶树") | [Go](../problems/even-odd-tree) | Medium | +| 1610 | [Maximum Number of Visible Points](https://leetcode.com/problems/maximum-number-of-visible-points "可见点的最大数目") | [Go](../problems/maximum-number-of-visible-points) | Hard | +| 1611 | [Minimum One Bit Operations to Make Integers Zero](https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero "使整数变为 0 的最少操作次数") | [Go](../problems/minimum-one-bit-operations-to-make-integers-zero) | Hard | +| 1612 | [Check If Two Expression Trees are Equivalent](https://leetcode.com/problems/check-if-two-expression-trees-are-equivalent "检查两棵二叉表达式树是否等价") 🔒 | [Go](../problems/check-if-two-expression-trees-are-equivalent) | Medium | +| 1613 | [Find the Missing IDs](https://leetcode.com/problems/find-the-missing-ids "找到遗失的ID") 🔒 | [MySQL](../problems/find-the-missing-ids) | Medium | +| 1614 | [Maximum Nesting Depth of the Parentheses](https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses "括号的最大嵌套深度") | [Go](../problems/maximum-nesting-depth-of-the-parentheses) | Easy | +| 1615 | [Maximal Network Rank](https://leetcode.com/problems/maximal-network-rank "最大网络秩") | [Go](../problems/maximal-network-rank) | Medium | +| 1616 | [Split Two Strings to Make Palindrome](https://leetcode.com/problems/split-two-strings-to-make-palindrome "分割两个字符串得到回文串") | [Go](../problems/split-two-strings-to-make-palindrome) | Medium | +| 1617 | [Count Subtrees With Max Distance Between Cities](https://leetcode.com/problems/count-subtrees-with-max-distance-between-cities "统计子树中城市之间最大距离") | [Go](../problems/count-subtrees-with-max-distance-between-cities) | Hard | +| 1618 | [Maximum Font to Fit a Sentence in a Screen](https://leetcode.com/problems/maximum-font-to-fit-a-sentence-in-a-screen "找出适应屏幕的最大字号") 🔒 | [Go](../problems/maximum-font-to-fit-a-sentence-in-a-screen) | Medium | +| 1619 | [Mean of Array After Removing Some Elements](https://leetcode.com/problems/mean-of-array-after-removing-some-elements "删除某些元素后的数组均值") | [Go](../problems/mean-of-array-after-removing-some-elements) | Easy | +| 1620 | [Coordinate With Maximum Network Quality](https://leetcode.com/problems/coordinate-with-maximum-network-quality "网络信号最好的坐标") | [Go](../problems/coordinate-with-maximum-network-quality) | Medium | +| 1621 | [Number of Sets of K Non-Overlapping Line Segments](https://leetcode.com/problems/number-of-sets-of-k-non-overlapping-line-segments "大小为 K 的不重叠线段的数目") | [Go](../problems/number-of-sets-of-k-non-overlapping-line-segments) | Medium | +| 1622 | [Fancy Sequence](https://leetcode.com/problems/fancy-sequence "奇妙序列") | [Go](../problems/fancy-sequence) | Hard | +| 1623 | [All Valid Triplets That Can Represent a Country](https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country "三人国家代表队") 🔒 | [MySQL](../problems/all-valid-triplets-that-can-represent-a-country) | Easy | +| 1624 | [Largest Substring Between Two Equal Characters](https://leetcode.com/problems/largest-substring-between-two-equal-characters "两个相同字符之间的最长子字符串") | [Go](../problems/largest-substring-between-two-equal-characters) | Easy | +| 1625 | [Lexicographically Smallest String After Applying Operations](https://leetcode.com/problems/lexicographically-smallest-string-after-applying-operations "执行操作后字典序最小的字符串") | [Go](../problems/lexicographically-smallest-string-after-applying-operations) | Medium | +| 1626 | [Best Team With No Conflicts](https://leetcode.com/problems/best-team-with-no-conflicts "无矛盾的最佳球队") | [Go](../problems/best-team-with-no-conflicts) | Medium | +| 1627 | [Graph Connectivity With Threshold](https://leetcode.com/problems/graph-connectivity-with-threshold "带阈值的图连通性") | [Go](../problems/graph-connectivity-with-threshold) | Hard | +| 1628 | [Design an Expression Tree With Evaluate Function](https://leetcode.com/problems/design-an-expression-tree-with-evaluate-function "设计带解析函数的表达式树") 🔒 | [Go](../problems/design-an-expression-tree-with-evaluate-function) | Medium | +| 1629 | [Slowest Key](https://leetcode.com/problems/slowest-key "按键持续时间最长的键") | [Go](../problems/slowest-key) | Easy | +| 1630 | [Arithmetic Subarrays](https://leetcode.com/problems/arithmetic-subarrays "等差子数组") | [Go](../problems/arithmetic-subarrays) | Medium | +| 1631 | [Path With Minimum Effort](https://leetcode.com/problems/path-with-minimum-effort "最小体力消耗路径") | [Go](../problems/path-with-minimum-effort) | Medium | +| 1632 | [Rank Transform of a Matrix](https://leetcode.com/problems/rank-transform-of-a-matrix "矩阵转换后的秩") | [Go](../problems/rank-transform-of-a-matrix) | Hard | +| 1633 | [Percentage of Users Attended a Contest](https://leetcode.com/problems/percentage-of-users-attended-a-contest "各赛事的用户注册率") 🔒 | [MySQL](../problems/percentage-of-users-attended-a-contest) | Easy | +| 1634 | [Add Two Polynomials Represented as Linked Lists](https://leetcode.com/problems/add-two-polynomials-represented-as-linked-lists "求两个多项式链表的和") 🔒 | [Go](../problems/add-two-polynomials-represented-as-linked-lists) | Medium | +| 1635 | [Hopper Company Queries I](https://leetcode.com/problems/hopper-company-queries-i "Hopper 公司查询 I") 🔒 | [MySQL](../problems/hopper-company-queries-i) | Hard | +| 1636 | [Sort Array by Increasing Frequency](https://leetcode.com/problems/sort-array-by-increasing-frequency "按照频率将数组升序排序") | [Go](../problems/sort-array-by-increasing-frequency) | Easy | +| 1637 | [Widest Vertical Area Between Two Points Containing No Points](https://leetcode.com/problems/widest-vertical-area-between-two-points-containing-no-points "两点之间不包含任何点的最宽垂直面积") | [Go](../problems/widest-vertical-area-between-two-points-containing-no-points) | Medium | +| 1638 | [Count Substrings That Differ by One Character](https://leetcode.com/problems/count-substrings-that-differ-by-one-character "统计只差一个字符的子串数目") | [Go](../problems/count-substrings-that-differ-by-one-character) | Medium | +| 1639 | [Number of Ways to Form a Target String Given a Dictionary](https://leetcode.com/problems/number-of-ways-to-form-a-target-string-given-a-dictionary "通过给定词典构造目标字符串的方案数") | [Go](../problems/number-of-ways-to-form-a-target-string-given-a-dictionary) | Hard | +| 1640 | [Check Array Formation Through Concatenation](https://leetcode.com/problems/check-array-formation-through-concatenation "能否连接形成数组") | [Go](../problems/check-array-formation-through-concatenation) | Easy | +| 1641 | [Count Sorted Vowel Strings](https://leetcode.com/problems/count-sorted-vowel-strings "统计字典序元音字符串的数目") | [Go](../problems/count-sorted-vowel-strings) | Medium | +| 1642 | [Furthest Building You Can Reach](https://leetcode.com/problems/furthest-building-you-can-reach "可以到达的最远建筑") | [Go](../problems/furthest-building-you-can-reach) | Medium | +| 1643 | [Kth Smallest Instructions](https://leetcode.com/problems/kth-smallest-instructions "第 K 条最小指令") | [Go](../problems/kth-smallest-instructions) | Hard | +| 1644 | [Lowest Common Ancestor of a Binary Tree II](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-ii "二叉树的最近公共祖先 II") 🔒 | [Go](../problems/lowest-common-ancestor-of-a-binary-tree-ii) | Medium | +| 1645 | [Hopper Company Queries II](https://leetcode.com/problems/hopper-company-queries-ii) 🔒 | [MySQL](../problems/hopper-company-queries-ii) | Hard | +| 1646 | [Get Maximum in Generated Array](https://leetcode.com/problems/get-maximum-in-generated-array "获取生成数组中的最大值") | [Go](../problems/get-maximum-in-generated-array) | Easy | +| 1647 | [Minimum Deletions to Make Character Frequencies Unique](https://leetcode.com/problems/minimum-deletions-to-make-character-frequencies-unique "字符频次唯一的最小删除次数") | [Go](../problems/minimum-deletions-to-make-character-frequencies-unique) | Medium | +| 1648 | [Sell Diminishing-Valued Colored Balls](https://leetcode.com/problems/sell-diminishing-valued-colored-balls "销售价值减少的颜色球") | [Go](../problems/sell-diminishing-valued-colored-balls) | Medium | +| 1649 | [Create Sorted Array through Instructions](https://leetcode.com/problems/create-sorted-array-through-instructions "通过指令创建有序数组") | [Go](../problems/create-sorted-array-through-instructions) | Hard | +| 1650 | [Lowest Common Ancestor of a Binary Tree III](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iii "二叉树的最近公共祖先 III") 🔒 | [Go](../problems/lowest-common-ancestor-of-a-binary-tree-iii) | Medium | +| 1651 | [Hopper Company Queries III](https://leetcode.com/problems/hopper-company-queries-iii) 🔒 | [MySQL](../problems/hopper-company-queries-iii) | Hard | +| 1652 | [Defuse the Bomb](https://leetcode.com/problems/defuse-the-bomb "拆炸弹") | [Go](../problems/defuse-the-bomb) | Easy | +| 1653 | [Minimum Deletions to Make String Balanced](https://leetcode.com/problems/minimum-deletions-to-make-string-balanced "使字符串平衡的最少删除次数") | [Go](../problems/minimum-deletions-to-make-string-balanced) | Medium | +| 1654 | [Minimum Jumps to Reach Home](https://leetcode.com/problems/minimum-jumps-to-reach-home "到家的最少跳跃次数") | [Go](../problems/minimum-jumps-to-reach-home) | Medium | +| 1655 | [Distribute Repeating Integers](https://leetcode.com/problems/distribute-repeating-integers "分配重复整数") | [Go](../problems/distribute-repeating-integers) | Hard | +| 1656 | [Design an Ordered Stream](https://leetcode.com/problems/design-an-ordered-stream "设计有序流") | [Go](../problems/design-an-ordered-stream) | Easy | +| 1657 | [Determine if Two Strings Are Close](https://leetcode.com/problems/determine-if-two-strings-are-close "确定两个字符串是否接近") | [Go](../problems/determine-if-two-strings-are-close) | Medium | +| 1658 | [Minimum Operations to Reduce X to Zero](https://leetcode.com/problems/minimum-operations-to-reduce-x-to-zero "将 x 减到 0 的最小操作数") | [Go](../problems/minimum-operations-to-reduce-x-to-zero) | Medium | +| 1659 | [Maximize Grid Happiness](https://leetcode.com/problems/maximize-grid-happiness "最大化网格幸福感") | [Go](../problems/maximize-grid-happiness) | Hard | +| 1660 | [Correct a Binary Tree](https://leetcode.com/problems/correct-a-binary-tree "纠正二叉树") 🔒 | [Go](../problems/correct-a-binary-tree) | Medium | +| 1661 | [Average Time of Process per Machine](https://leetcode.com/problems/average-time-of-process-per-machine "每台机器的进程平均运行时间") 🔒 | [MySQL](../problems/average-time-of-process-per-machine) | Easy | +| 1662 | [Check If Two String Arrays are Equivalent](https://leetcode.com/problems/check-if-two-string-arrays-are-equivalent "检查两个字符串数组是否相等") | [Go](../problems/check-if-two-string-arrays-are-equivalent) | Easy | +| 1663 | [Smallest String With A Given Numeric Value](https://leetcode.com/problems/smallest-string-with-a-given-numeric-value "具有给定数值的最小字符串") | [Go](../problems/smallest-string-with-a-given-numeric-value) | Medium | +| 1664 | [Ways to Make a Fair Array](https://leetcode.com/problems/ways-to-make-a-fair-array "生成平衡数组的方案数") | [Go](../problems/ways-to-make-a-fair-array) | Medium | +| 1665 | [Minimum Initial Energy to Finish Tasks](https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks "完成所有任务的最少初始能量") | [Go](../problems/minimum-initial-energy-to-finish-tasks) | Hard | +| 1666 | [Change the Root of a Binary Tree](https://leetcode.com/problems/change-the-root-of-a-binary-tree "改变二叉树的根节点") 🔒 | [Go](../problems/change-the-root-of-a-binary-tree) | Medium | +| 1667 | [Fix Names in a Table](https://leetcode.com/problems/fix-names-in-a-table "修复表中的名字") 🔒 | [MySQL](../problems/fix-names-in-a-table) | Easy | +| 1668 | [Maximum Repeating Substring](https://leetcode.com/problems/maximum-repeating-substring "最大重复子字符串") | [Go](../problems/maximum-repeating-substring) | Easy | +| 1669 | [Merge In Between Linked Lists](https://leetcode.com/problems/merge-in-between-linked-lists "合并两个链表") | [Go](../problems/merge-in-between-linked-lists) | Medium | +| 1670 | [Design Front Middle Back Queue](https://leetcode.com/problems/design-front-middle-back-queue "设计前中后队列") | [Go](../problems/design-front-middle-back-queue) | Medium | +| 1671 | [Minimum Number of Removals to Make Mountain Array](https://leetcode.com/problems/minimum-number-of-removals-to-make-mountain-array "得到山形数组的最少删除次数") | [Go](../problems/minimum-number-of-removals-to-make-mountain-array) | Hard | +| 1672 | [Richest Customer Wealth](https://leetcode.com/problems/richest-customer-wealth "最富有客户的资产总量") | [Go](../problems/richest-customer-wealth) | Easy | +| 1673 | [Find the Most Competitive Subsequence](https://leetcode.com/problems/find-the-most-competitive-subsequence "找出最具竞争力的子序列") | [Go](../problems/find-the-most-competitive-subsequence) | Medium | +| 1674 | [Minimum Moves to Make Array Complementary](https://leetcode.com/problems/minimum-moves-to-make-array-complementary "使数组互补的最少操作次数") | [Go](../problems/minimum-moves-to-make-array-complementary) | Medium | +| 1675 | [Minimize Deviation in Array](https://leetcode.com/problems/minimize-deviation-in-array "数组的最小偏移量") | [Go](../problems/minimize-deviation-in-array) | Hard | +| 1676 | [Lowest Common Ancestor of a Binary Tree IV](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iv "二叉树的最近公共祖先 IV") 🔒 | [Go](../problems/lowest-common-ancestor-of-a-binary-tree-iv) | Medium | +| 1677 | [Product's Worth Over Invoices](https://leetcode.com/problems/products-worth-over-invoices "发票中的产品金额") 🔒 | [MySQL](../problems/products-worth-over-invoices) | Easy | +| 1678 | [Goal Parser Interpretation](https://leetcode.com/problems/goal-parser-interpretation "设计 Goal 解析器") | [Go](../problems/goal-parser-interpretation) | Easy | +| 1679 | [Max Number of K-Sum Pairs](https://leetcode.com/problems/max-number-of-k-sum-pairs "K 和数对的最大数目") | [Go](../problems/max-number-of-k-sum-pairs) | Medium | +| 1680 | [Concatenation of Consecutive Binary Numbers](https://leetcode.com/problems/concatenation-of-consecutive-binary-numbers "连接连续二进制数字") | [Go](../problems/concatenation-of-consecutive-binary-numbers) | Medium | +| 1681 | [Minimum Incompatibility](https://leetcode.com/problems/minimum-incompatibility "最小不兼容性") | [Go](../problems/minimum-incompatibility) | Hard | +| 1682 | [Longest Palindromic Subsequence II](https://leetcode.com/problems/longest-palindromic-subsequence-ii "最长回文子序列 II") 🔒 | [Go](../problems/longest-palindromic-subsequence-ii) | Medium | +| 1683 | [Invalid Tweets](https://leetcode.com/problems/invalid-tweets "无效的推文") 🔒 | [MySQL](../problems/invalid-tweets) | Easy | +| 1684 | [Count the Number of Consistent Strings](https://leetcode.com/problems/count-the-number-of-consistent-strings "统计一致字符串的数目") | [Go](../problems/count-the-number-of-consistent-strings) | Easy | +| 1685 | [Sum of Absolute Differences in a Sorted Array](https://leetcode.com/problems/sum-of-absolute-differences-in-a-sorted-array "有序数组中差绝对值之和") | [Go](../problems/sum-of-absolute-differences-in-a-sorted-array) | Medium | +| 1686 | [Stone Game VI](https://leetcode.com/problems/stone-game-vi "石子游戏 VI") | [Go](../problems/stone-game-vi) | Medium | +| 1687 | [Delivering Boxes from Storage to Ports](https://leetcode.com/problems/delivering-boxes-from-storage-to-ports "从仓库到码头运输箱子") | [Go](../problems/delivering-boxes-from-storage-to-ports) | Hard | +| 1688 | [Count of Matches in Tournament](https://leetcode.com/problems/count-of-matches-in-tournament "比赛中的配对次数") | [Go](../problems/count-of-matches-in-tournament) | Easy | +| 1689 | [Partitioning Into Minimum Number Of Deci-Binary Numbers](https://leetcode.com/problems/partitioning-into-minimum-number-of-deci-binary-numbers "十-二进制数的最少数目") | [Go](../problems/partitioning-into-minimum-number-of-deci-binary-numbers) | Medium | +| 1690 | [Stone Game VII](https://leetcode.com/problems/stone-game-vii "石子游戏 VII") | [Go](../problems/stone-game-vii) | Medium | +| 1691 | [Maximum Height by Stacking Cuboids](https://leetcode.com/problems/maximum-height-by-stacking-cuboids "堆叠长方体的最大高度") | [Go](../problems/maximum-height-by-stacking-cuboids) | Hard | +| 1692 | [Count Ways to Distribute Candies](https://leetcode.com/problems/count-ways-to-distribute-candies "计算分配糖果的不同方式") 🔒 | [Go](../problems/count-ways-to-distribute-candies) | Hard | +| 1693 | [Daily Leads and Partners](https://leetcode.com/problems/daily-leads-and-partners "每天的领导和合伙人") 🔒 | [MySQL](../problems/daily-leads-and-partners) | Easy | +| 1694 | [Reformat Phone Number](https://leetcode.com/problems/reformat-phone-number "重新格式化电话号码") | [Go](../problems/reformat-phone-number) | Easy | +| 1695 | [Maximum Erasure Value](https://leetcode.com/problems/maximum-erasure-value "删除子数组的最大得分") | [Go](../problems/maximum-erasure-value) | Medium | +| 1696 | [Jump Game VI](https://leetcode.com/problems/jump-game-vi "跳跃游戏 VI") | [Go](../problems/jump-game-vi) | Medium | +| 1697 | [Checking Existence of Edge Length Limited Paths](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths "检查边长度限制的路径是否存在") | [Go](../problems/checking-existence-of-edge-length-limited-paths) | Hard | +| 1698 | [Number of Distinct Substrings in a String](https://leetcode.com/problems/number-of-distinct-substrings-in-a-string "字符串的不同子字符串个数") 🔒 | [Go](../problems/number-of-distinct-substrings-in-a-string) | Medium | +| 1699 | [Number of Calls Between Two Persons](https://leetcode.com/problems/number-of-calls-between-two-persons "两人之间的通话次数") 🔒 | [MySQL](../problems/number-of-calls-between-two-persons) | Medium | +| 1700 | [Number of Students Unable to Eat Lunch](https://leetcode.com/problems/number-of-students-unable-to-eat-lunch "无法吃午餐的学生数量") | [Go](../problems/number-of-students-unable-to-eat-lunch) | Easy | +| 1701 | [Average Waiting Time](https://leetcode.com/problems/average-waiting-time "平均等待时间") | [Go](../problems/average-waiting-time) | Medium | +| 1702 | [Maximum Binary String After Change](https://leetcode.com/problems/maximum-binary-string-after-change "修改后的最大二进制字符串") | [Go](../problems/maximum-binary-string-after-change) | Medium | +| 1703 | [Minimum Adjacent Swaps for K Consecutive Ones](https://leetcode.com/problems/minimum-adjacent-swaps-for-k-consecutive-ones "得到连续 K 个 1 的最少相邻交换次数") | [Go](../problems/minimum-adjacent-swaps-for-k-consecutive-ones) | Hard | +| 1704 | [Determine if String Halves Are Alike](https://leetcode.com/problems/determine-if-string-halves-are-alike "判断字符串的两半是否相似") | [Go](../problems/determine-if-string-halves-are-alike) | Easy | +| 1705 | [Maximum Number of Eaten Apples](https://leetcode.com/problems/maximum-number-of-eaten-apples "吃苹果的最大数目") | [Go](../problems/maximum-number-of-eaten-apples) | Medium | +| 1706 | [Where Will the Ball Fall](https://leetcode.com/problems/where-will-the-ball-fall "球会落何处") | [Go](../problems/where-will-the-ball-fall) | Medium | +| 1707 | [Maximum XOR With an Element From Array](https://leetcode.com/problems/maximum-xor-with-an-element-from-array "与数组中元素的最大异或值") | [Go](../problems/maximum-xor-with-an-element-from-array) | Hard | +| 1708 | [Largest Subarray Length K](https://leetcode.com/problems/largest-subarray-length-k "长度为 K 的最大子数组") 🔒 | [Go](../problems/largest-subarray-length-k) | Easy | +| 1709 | [Biggest Window Between Visits](https://leetcode.com/problems/biggest-window-between-visits "访问日期之间最大的空档期") 🔒 | [MySQL](../problems/biggest-window-between-visits) | Medium | +| 1710 | [Maximum Units on a Truck](https://leetcode.com/problems/maximum-units-on-a-truck "卡车上的最大单元数") | [Go](../problems/maximum-units-on-a-truck) | Easy | +| 1711 | [Count Good Meals](https://leetcode.com/problems/count-good-meals "大餐计数") | [Go](../problems/count-good-meals) | Medium | +| 1712 | [Ways to Split Array Into Three Subarrays](https://leetcode.com/problems/ways-to-split-array-into-three-subarrays "将数组分成三个子数组的方案数") | [Go](../problems/ways-to-split-array-into-three-subarrays) | Medium | +| 1713 | [Minimum Operations to Make a Subsequence](https://leetcode.com/problems/minimum-operations-to-make-a-subsequence "得到子序列的最少操作次数") | [Go](../problems/minimum-operations-to-make-a-subsequence) | Hard | +| 1714 | [Sum Of Special Evenly-Spaced Elements In Array](https://leetcode.com/problems/sum-of-special-evenly-spaced-elements-in-array "数组中特殊等间距元素的和") 🔒 | [Go](../problems/sum-of-special-evenly-spaced-elements-in-array) | Hard | +| 1715 | [Count Apples and Oranges](https://leetcode.com/problems/count-apples-and-oranges "苹果和橘子的个数") 🔒 | [MySQL](../problems/count-apples-and-oranges) | Medium | +| 1716 | [Calculate Money in Leetcode Bank](https://leetcode.com/problems/calculate-money-in-leetcode-bank "计算力扣银行的钱") | [Go](../problems/calculate-money-in-leetcode-bank) | Easy | +| 1717 | [Maximum Score From Removing Substrings](https://leetcode.com/problems/maximum-score-from-removing-substrings "删除子字符串的最大得分") | [Go](../problems/maximum-score-from-removing-substrings) | Medium | +| 1718 | [Construct the Lexicographically Largest Valid Sequence](https://leetcode.com/problems/construct-the-lexicographically-largest-valid-sequence "构建字典序最大的可行序列") | [Go](../problems/construct-the-lexicographically-largest-valid-sequence) | Medium | +| 1719 | [Number Of Ways To Reconstruct A Tree](https://leetcode.com/problems/number-of-ways-to-reconstruct-a-tree "重构一棵树的方案数") | [Go](../problems/number-of-ways-to-reconstruct-a-tree) | Hard | +| 1720 | [Decode XORed Array](https://leetcode.com/problems/decode-xored-array "解码异或后的数组") | [Go](../problems/decode-xored-array) | Easy | +| 1721 | [Swapping Nodes in a Linked List](https://leetcode.com/problems/swapping-nodes-in-a-linked-list "交换链表中的节点") | [Go](../problems/swapping-nodes-in-a-linked-list) | Medium | +| 1722 | [Minimize Hamming Distance After Swap Operations](https://leetcode.com/problems/minimize-hamming-distance-after-swap-operations "执行交换操作后的最小汉明距离") | [Go](../problems/minimize-hamming-distance-after-swap-operations) | Medium | +| 1723 | [Find Minimum Time to Finish All Jobs](https://leetcode.com/problems/find-minimum-time-to-finish-all-jobs "完成所有工作的最短时间") | [Go](../problems/find-minimum-time-to-finish-all-jobs) | Hard | +| 1724 | [Checking Existence of Edge Length Limited Paths II](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths-ii "检查边长度限制的路径是否存在 II") 🔒 | [Go](../problems/checking-existence-of-edge-length-limited-paths-ii) | Hard | +| 1725 | [Number Of Rectangles That Can Form The Largest Square](https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square "可以形成最大正方形的矩形数目") | [Go](../problems/number-of-rectangles-that-can-form-the-largest-square) | Easy | +| 1726 | [Tuple with Same Product](https://leetcode.com/problems/tuple-with-same-product "同积元组") | [Go](../problems/tuple-with-same-product) | Medium | +| 1727 | [Largest Submatrix With Rearrangements](https://leetcode.com/problems/largest-submatrix-with-rearrangements "重新排列后的最大子矩阵") | [Go](../problems/largest-submatrix-with-rearrangements) | Medium | +| 1728 | [Cat and Mouse II](https://leetcode.com/problems/cat-and-mouse-ii "猫和老鼠 II") | [Go](../problems/cat-and-mouse-ii) | Hard | +| 1729 | [Find Followers Count](https://leetcode.com/problems/find-followers-count "求关注者的数量") 🔒 | [MySQL](../problems/find-followers-count) | Easy | +| 1730 | [Shortest Path to Get Food](https://leetcode.com/problems/shortest-path-to-get-food "获取食物的最短路径") 🔒 | [Go](../problems/shortest-path-to-get-food) | Medium | +| 1731 | [The Number of Employees Which Report to Each Employee](https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee "每位经理的下属员工数量") 🔒 | [MySQL](../problems/the-number-of-employees-which-report-to-each-employee) | Easy | +| 1732 | [Find the Highest Altitude](https://leetcode.com/problems/find-the-highest-altitude "找到最高海拔") | [Go](../problems/find-the-highest-altitude) | Easy | +| 1733 | [Minimum Number of People to Teach](https://leetcode.com/problems/minimum-number-of-people-to-teach "需要教语言的最少人数") | [Go](../problems/minimum-number-of-people-to-teach) | Medium | +| 1734 | [Decode XORed Permutation](https://leetcode.com/problems/decode-xored-permutation "解码异或后的排列") | [Go](../problems/decode-xored-permutation) | Medium | +| 1735 | [Count Ways to Make Array With Product](https://leetcode.com/problems/count-ways-to-make-array-with-product "生成乘积数组的方案数") | [Go](../problems/count-ways-to-make-array-with-product) | Hard | +| 1736 | [Latest Time by Replacing Hidden Digits](https://leetcode.com/problems/latest-time-by-replacing-hidden-digits "替换隐藏数字得到的最晚时间") | [Go](../problems/latest-time-by-replacing-hidden-digits) | Easy | +| 1737 | [Change Minimum Characters to Satisfy One of Three Conditions](https://leetcode.com/problems/change-minimum-characters-to-satisfy-one-of-three-conditions "满足三条件之一需改变的最少字符数") | [Go](../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | Medium | +| 1738 | [Find Kth Largest XOR Coordinate Value](https://leetcode.com/problems/find-kth-largest-xor-coordinate-value "找出第 K 大的异或坐标值") | [Go](../problems/find-kth-largest-xor-coordinate-value) | Medium | +| 1739 | [Building Boxes](https://leetcode.com/problems/building-boxes "放置盒子") | [Go](../problems/building-boxes) | Hard | +| 1740 | [Find Distance in a Binary Tree](https://leetcode.com/problems/find-distance-in-a-binary-tree "找到二叉树中的距离") 🔒 | [Go](../problems/find-distance-in-a-binary-tree) | Medium | +| 1741 | [Find Total Time Spent by Each Employee](https://leetcode.com/problems/find-total-time-spent-by-each-employee "查找每个员工花费的总时间") 🔒 | [MySQL](../problems/find-total-time-spent-by-each-employee) | Easy | +| 1742 | [Maximum Number of Balls in a Box](https://leetcode.com/problems/maximum-number-of-balls-in-a-box "盒子中小球的最大数量") | [Go](../problems/maximum-number-of-balls-in-a-box) | Easy | +| 1743 | [Restore the Array From Adjacent Pairs](https://leetcode.com/problems/restore-the-array-from-adjacent-pairs "从相邻元素对还原数组") | [Go](../problems/restore-the-array-from-adjacent-pairs) | Medium | +| 1744 | [Can You Eat Your Favorite Candy on Your Favorite Day?](https://leetcode.com/problems/can-you-eat-your-favorite-candy-on-your-favorite-day "你能在你最喜欢的那天吃到你最喜欢的糖果吗?") | [Go](../problems/can-you-eat-your-favorite-candy-on-your-favorite-day) | Medium | +| 1745 | [Palindrome Partitioning IV](https://leetcode.com/problems/palindrome-partitioning-iv "回文串分割 IV") | [Go](../problems/palindrome-partitioning-iv) | Hard | +| 1746 | [Maximum Subarray Sum After One Operation](https://leetcode.com/problems/maximum-subarray-sum-after-one-operation "经过一次操作后的最大子数组和") 🔒 | [Go](../problems/maximum-subarray-sum-after-one-operation) | Medium | +| 1747 | [Leetflex Banned Accounts](https://leetcode.com/problems/leetflex-banned-accounts "应该被禁止的Leetflex账户") 🔒 | [MySQL](../problems/leetflex-banned-accounts) | Medium | +| 1748 | [Sum of Unique Elements](https://leetcode.com/problems/sum-of-unique-elements "唯一元素的和") | [Go](../problems/sum-of-unique-elements) | Easy | +| 1749 | [Maximum Absolute Sum of Any Subarray](https://leetcode.com/problems/maximum-absolute-sum-of-any-subarray "任意子数组和的绝对值的最大值") | [Go](../problems/maximum-absolute-sum-of-any-subarray) | Medium | +| 1750 | [Minimum Length of String After Deleting Similar Ends](https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends "删除字符串两端相同字符后的最短长度") | [Go](../problems/minimum-length-of-string-after-deleting-similar-ends) | Medium | +| 1751 | [Maximum Number of Events That Can Be Attended II](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended-ii "最多可以参加的会议数目 II") | [Go](../problems/maximum-number-of-events-that-can-be-attended-ii) | Hard | +| 1752 | [Check if Array Is Sorted and Rotated](https://leetcode.com/problems/check-if-array-is-sorted-and-rotated "检查数组是否经排序和轮转得到") | [Go](../problems/check-if-array-is-sorted-and-rotated) | Easy | +| 1753 | [Maximum Score From Removing Stones](https://leetcode.com/problems/maximum-score-from-removing-stones "移除石子的最大得分") | [Go](../problems/maximum-score-from-removing-stones) | Medium | +| 1754 | [Largest Merge Of Two Strings](https://leetcode.com/problems/largest-merge-of-two-strings "构造字典序最大的合并字符串") | [Go](../problems/largest-merge-of-two-strings) | Medium | +| 1755 | [Closest Subsequence Sum](https://leetcode.com/problems/closest-subsequence-sum "最接近目标值的子序列和") | [Go](../problems/closest-subsequence-sum) | Hard | +| 1756 | [Design Most Recently Used Queue](https://leetcode.com/problems/design-most-recently-used-queue "设计最近使用(MRU)队列") 🔒 | [Go](../problems/design-most-recently-used-queue) | Medium | +| 1757 | [Recyclable and Low Fat Products](https://leetcode.com/problems/recyclable-and-low-fat-products "可回收且低脂的产品") 🔒 | [MySQL](../problems/recyclable-and-low-fat-products) | Easy | +| 1758 | [Minimum Changes To Make Alternating Binary String](https://leetcode.com/problems/minimum-changes-to-make-alternating-binary-string "生成交替二进制字符串的最少操作数") | [Go](../problems/minimum-changes-to-make-alternating-binary-string) | Easy | +| 1759 | [Count Number of Homogenous Substrings](https://leetcode.com/problems/count-number-of-homogenous-substrings "统计同构子字符串的数目") | [Go](../problems/count-number-of-homogenous-substrings) | Medium | +| 1760 | [Minimum Limit of Balls in a Bag](https://leetcode.com/problems/minimum-limit-of-balls-in-a-bag "袋子里最少数目的球") | [Go](../problems/minimum-limit-of-balls-in-a-bag) | Medium | +| 1761 | [Minimum Degree of a Connected Trio in a Graph](https://leetcode.com/problems/minimum-degree-of-a-connected-trio-in-a-graph "一个图中连通三元组的最小度数") | [Go](../problems/minimum-degree-of-a-connected-trio-in-a-graph) | Hard | +| 1762 | [Buildings With an Ocean View](https://leetcode.com/problems/buildings-with-an-ocean-view "能看到海景的建筑物") 🔒 | [Go](../problems/buildings-with-an-ocean-view) | Medium | +| 1763 | [Longest Nice Substring](https://leetcode.com/problems/longest-nice-substring "最长的美好子字符串") | [Go](../problems/longest-nice-substring) | Easy | +| 1764 | [Form Array by Concatenating Subarrays of Another Array](https://leetcode.com/problems/form-array-by-concatenating-subarrays-of-another-array "通过连接另一个数组的子数组得到一个数组") | [Go](../problems/form-array-by-concatenating-subarrays-of-another-array) | Medium | +| 1765 | [Map of Highest Peak](https://leetcode.com/problems/map-of-highest-peak "地图中的最高点") | [Go](../problems/map-of-highest-peak) | Medium | +| 1766 | [Tree of Coprimes](https://leetcode.com/problems/tree-of-coprimes "互质树") | [Go](../problems/tree-of-coprimes) | Hard | +| 1767 | [Find the Subtasks That Did Not Execute](https://leetcode.com/problems/find-the-subtasks-that-did-not-execute "寻找没有被执行的任务对") 🔒 | [MySQL](../problems/find-the-subtasks-that-did-not-execute) | Hard | +| 1768 | [Merge Strings Alternately](https://leetcode.com/problems/merge-strings-alternately "交替合并字符串") | [Go](../problems/merge-strings-alternately) | Easy | +| 1769 | [Minimum Number of Operations to Move All Balls to Each Box](https://leetcode.com/problems/minimum-number-of-operations-to-move-all-balls-to-each-box "移动所有球到每个盒子所需的最小操作数") | [Go](../problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | Medium | +| 1770 | [Maximum Score from Performing Multiplication Operations](https://leetcode.com/problems/maximum-score-from-performing-multiplication-operations "执行乘法运算的最大分数") | [Go](../problems/maximum-score-from-performing-multiplication-operations) | Medium | +| 1771 | [Maximize Palindrome Length From Subsequences](https://leetcode.com/problems/maximize-palindrome-length-from-subsequences "由子序列构造的最长回文串的长度") | [Go](../problems/maximize-palindrome-length-from-subsequences) | Hard | +| 1772 | [Sort Features by Popularity](https://leetcode.com/problems/sort-features-by-popularity "按受欢迎程度排列功能") 🔒 | [Go](../problems/sort-features-by-popularity) | Medium | +| 1773 | [Count Items Matching a Rule](https://leetcode.com/problems/count-items-matching-a-rule "统计匹配检索规则的物品数量") | [Go](../problems/count-items-matching-a-rule) | Easy | +| 1774 | [Closest Dessert Cost](https://leetcode.com/problems/closest-dessert-cost "最接近目标价格的甜点成本") | [Go](../problems/closest-dessert-cost) | Medium | +| 1775 | [Equal Sum Arrays With Minimum Number of Operations](https://leetcode.com/problems/equal-sum-arrays-with-minimum-number-of-operations "通过最少操作次数使数组的和相等") | [Go](../problems/equal-sum-arrays-with-minimum-number-of-operations) | Medium | +| 1776 | [Car Fleet II](https://leetcode.com/problems/car-fleet-ii "车队 II") | [Go](../problems/car-fleet-ii) | Hard | +| 1777 | [Product's Price for Each Store](https://leetcode.com/problems/products-price-for-each-store "每家商店的产品价格") 🔒 | [MySQL](../problems/products-price-for-each-store) | Easy | +| 1778 | [Shortest Path in a Hidden Grid](https://leetcode.com/problems/shortest-path-in-a-hidden-grid "未知网格中的最短路径") 🔒 | [Go](../problems/shortest-path-in-a-hidden-grid) | Medium | +| 1779 | [Find Nearest Point That Has the Same X or Y Coordinate](https://leetcode.com/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate "找到最近的有相同 X 或 Y 坐标的点") | [Go](../problems/find-nearest-point-that-has-the-same-x-or-y-coordinate) | Easy | +| 1780 | [Check if Number is a Sum of Powers of Three](https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three "判断一个数字是否可以表示成三的幂的和") | [Go](../problems/check-if-number-is-a-sum-of-powers-of-three) | Medium | +| 1781 | [Sum of Beauty of All Substrings](https://leetcode.com/problems/sum-of-beauty-of-all-substrings "所有子字符串美丽值之和") | [Go](../problems/sum-of-beauty-of-all-substrings) | Medium | +| 1782 | [Count Pairs Of Nodes](https://leetcode.com/problems/count-pairs-of-nodes "统计点对的数目") | [Go](../problems/count-pairs-of-nodes) | Hard | +| 1783 | [Grand Slam Titles](https://leetcode.com/problems/grand-slam-titles "大满贯数量") 🔒 | [MySQL](../problems/grand-slam-titles) | Medium | +| 1784 | [Check if Binary String Has at Most One Segment of Ones](https://leetcode.com/problems/check-if-binary-string-has-at-most-one-segment-of-ones "检查二进制字符串字段") | [Go](../problems/check-if-binary-string-has-at-most-one-segment-of-ones) | Easy | +| 1785 | [Minimum Elements to Add to Form a Given Sum](https://leetcode.com/problems/minimum-elements-to-add-to-form-a-given-sum "构成特定和需要添加的最少元素") | [Go](../problems/minimum-elements-to-add-to-form-a-given-sum) | Medium | +| 1786 | [Number of Restricted Paths From First to Last Node](https://leetcode.com/problems/number-of-restricted-paths-from-first-to-last-node "从第一个节点出发到最后一个节点的受限路径数") | [Go](../problems/number-of-restricted-paths-from-first-to-last-node) | Medium | +| 1787 | [Make the XOR of All Segments Equal to Zero](https://leetcode.com/problems/make-the-xor-of-all-segments-equal-to-zero "使所有区间的异或结果为零") | [Go](../problems/make-the-xor-of-all-segments-equal-to-zero) | Hard | +| 1788 | [Maximize the Beauty of the Garden](https://leetcode.com/problems/maximize-the-beauty-of-the-garden "最大化花园的美观度") 🔒 | [Go](../problems/maximize-the-beauty-of-the-garden) | Hard | +| 1789 | [Primary Department for Each Employee](https://leetcode.com/problems/primary-department-for-each-employee "员工的直属部门") 🔒 | [MySQL](../problems/primary-department-for-each-employee) | Easy | +| 1790 | [Check if One String Swap Can Make Strings Equal](https://leetcode.com/problems/check-if-one-string-swap-can-make-strings-equal "仅执行一次字符串交换能否使两个字符串相等") | [Go](../problems/check-if-one-string-swap-can-make-strings-equal) | Easy | +| 1791 | [Find Center of Star Graph](https://leetcode.com/problems/find-center-of-star-graph "找出星型图的中心节点") | [Go](../problems/find-center-of-star-graph) | Easy | +| 1792 | [Maximum Average Pass Ratio](https://leetcode.com/problems/maximum-average-pass-ratio "最大平均通过率") | [Go](../problems/maximum-average-pass-ratio) | Medium | +| 1793 | [Maximum Score of a Good Subarray](https://leetcode.com/problems/maximum-score-of-a-good-subarray "好子数组的最大分数") | [Go](../problems/maximum-score-of-a-good-subarray) | Hard | +| 1794 | [Count Pairs of Equal Substrings With Minimum Difference](https://leetcode.com/problems/count-pairs-of-equal-substrings-with-minimum-difference "统计距离最小的子串对个数") 🔒 | [Go](../problems/count-pairs-of-equal-substrings-with-minimum-difference) | Medium | +| 1795 | [Rearrange Products Table](https://leetcode.com/problems/rearrange-products-table "每个产品在不同商店的价格") 🔒 | [MySQL](../problems/rearrange-products-table) | Easy | +| 1796 | [Second Largest Digit in a String](https://leetcode.com/problems/second-largest-digit-in-a-string "字符串中第二大的数字") | [Go](../problems/second-largest-digit-in-a-string) | Easy | +| 1797 | [Design Authentication Manager](https://leetcode.com/problems/design-authentication-manager "设计一个验证系统") | [Go](../problems/design-authentication-manager) | Medium | +| 1798 | [Maximum Number of Consecutive Values You Can Make](https://leetcode.com/problems/maximum-number-of-consecutive-values-you-can-make "你能构造出连续值的最大数目") | [Go](../problems/maximum-number-of-consecutive-values-you-can-make) | Medium | +| 1799 | [Maximize Score After N Operations](https://leetcode.com/problems/maximize-score-after-n-operations "N 次操作后的最大分数和") | [Go](../problems/maximize-score-after-n-operations) | Hard | +| 1800 | [Maximum Ascending Subarray Sum](https://leetcode.com/problems/maximum-ascending-subarray-sum "最大升序子数组和") | [Go](../problems/maximum-ascending-subarray-sum) | Easy | diff --git a/readme/301-600.md b/readme/301-600.md index d0b689921..1a0e6f251 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    @@ -103,7 +111,7 @@ LeetCode Problems' Solutions | 323 | [Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph "无向图中连通分量的数目") 🔒 | [Go](../problems/number-of-connected-components-in-an-undirected-graph) | Medium | | 324 | [Wiggle Sort II](https://leetcode.com/problems/wiggle-sort-ii "摆动排序 II") | [Go](../problems/wiggle-sort-ii) | Medium | | 325 | [Maximum Size Subarray Sum Equals k](https://leetcode.com/problems/maximum-size-subarray-sum-equals-k "和等于 k 的最长子数组长度") 🔒 | [Go](../problems/maximum-size-subarray-sum-equals-k) | Medium | -| 326 | [Power of Three](https://leetcode.com/problems/power-of-three "3的幂") | [Go](../problems/power-of-three) | Easy | +| 326 | [Power of Three](https://leetcode.com/problems/power-of-three "3 的幂") | [Go](../problems/power-of-three) | Easy | | 327 | [Count of Range Sum](https://leetcode.com/problems/count-of-range-sum "区间和的个数") | [Go](../problems/count-of-range-sum) | Hard | | 328 | [Odd Even Linked List](https://leetcode.com/problems/odd-even-linked-list "奇偶链表") | [Go](../problems/odd-even-linked-list) | Medium | | 329 | [Longest Increasing Path in a Matrix](https://leetcode.com/problems/longest-increasing-path-in-a-matrix "矩阵中的最长递增路径") | [Go](../problems/longest-increasing-path-in-a-matrix) | Hard | @@ -150,7 +158,7 @@ LeetCode Problems' Solutions | 370 | [Range Addition](https://leetcode.com/problems/range-addition "区间加法") 🔒 | [Go](../problems/range-addition) | Medium | | 371 | [Sum of Two Integers](https://leetcode.com/problems/sum-of-two-integers "两整数之和") | [Go](../problems/sum-of-two-integers) | Medium | | 372 | [Super Pow](https://leetcode.com/problems/super-pow "超级次方") | [Go](../problems/super-pow) | Medium | -| 373 | [Find K Pairs with Smallest Sums](https://leetcode.com/problems/find-k-pairs-with-smallest-sums "查找和最小的K对数字") | [Go](../problems/find-k-pairs-with-smallest-sums) | Medium | +| 373 | [Find K Pairs with Smallest Sums](https://leetcode.com/problems/find-k-pairs-with-smallest-sums "查找和最小的 K 对数字") | [Go](../problems/find-k-pairs-with-smallest-sums) | Medium | | 374 | [Guess Number Higher or Lower](https://leetcode.com/problems/guess-number-higher-or-lower "猜数字大小") | [Go](../problems/guess-number-higher-or-lower) | Easy | | 375 | [Guess Number Higher or Lower II](https://leetcode.com/problems/guess-number-higher-or-lower-ii "猜数字大小 II") | [Go](../problems/guess-number-higher-or-lower-ii) | Medium | | 376 | [Wiggle Subsequence](https://leetcode.com/problems/wiggle-subsequence "摆动序列") | [Go](../problems/wiggle-subsequence) | Medium | diff --git a/readme/601-900.md b/readme/601-900.md index 5ceafc962..91d593fbe 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    @@ -165,7 +173,7 @@ LeetCode Problems' Solutions | 685 | [Redundant Connection II](https://leetcode.com/problems/redundant-connection-ii "冗余连接 II") | [Go](../problems/redundant-connection-ii) | Hard | | 686 | [Repeated String Match](https://leetcode.com/problems/repeated-string-match "重复叠加字符串匹配") | [Go](../problems/repeated-string-match) | Medium | | 687 | [Longest Univalue Path](https://leetcode.com/problems/longest-univalue-path "最长同值路径") | [Go](../problems/longest-univalue-path) | Medium | -| 688 | [Knight Probability in Chessboard](https://leetcode.com/problems/knight-probability-in-chessboard "“马”在棋盘上的概率") | [Go](../problems/knight-probability-in-chessboard) | Medium | +| 688 | [Knight Probability in Chessboard](https://leetcode.com/problems/knight-probability-in-chessboard "骑士在棋盘上的概率") | [Go](../problems/knight-probability-in-chessboard) | Medium | | 689 | [Maximum Sum of 3 Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays "三个无重叠子数组的最大和") | [Go](../problems/maximum-sum-of-3-non-overlapping-subarrays) | Hard | | 690 | [Employee Importance](https://leetcode.com/problems/employee-importance "员工的重要性") | [Go](../problems/employee-importance) | Medium | | 691 | [Stickers to Spell Word](https://leetcode.com/problems/stickers-to-spell-word "贴纸拼词") | [Go](../problems/stickers-to-spell-word) | Hard | @@ -365,7 +373,7 @@ LeetCode Problems' Solutions | 885 | [Spiral Matrix III](https://leetcode.com/problems/spiral-matrix-iii "螺旋矩阵 III") | [Go](../problems/spiral-matrix-iii) | Medium | | 886 | [Possible Bipartition](https://leetcode.com/problems/possible-bipartition "可能的二分法") | [Go](../problems/possible-bipartition) | Medium | | 887 | [Super Egg Drop](https://leetcode.com/problems/super-egg-drop "鸡蛋掉落") | [Go](../problems/super-egg-drop) | Hard | -| 888 | [Fair Candy Swap](https://leetcode.com/problems/fair-candy-swap "公平的糖果棒交换") | [Go](../problems/fair-candy-swap) | Easy | +| 888 | [Fair Candy Swap](https://leetcode.com/problems/fair-candy-swap "公平的糖果交换") | [Go](../problems/fair-candy-swap) | Easy | | 889 | [Construct Binary Tree from Preorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal "根据前序和后序遍历构造二叉树") | [Go](../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | Medium | | 890 | [Find and Replace Pattern](https://leetcode.com/problems/find-and-replace-pattern "查找和替换模式") | [Go](../problems/find-and-replace-pattern) | Medium | | 891 | [Sum of Subsequence Widths](https://leetcode.com/problems/sum-of-subsequence-widths "子序列宽度之和") | [Go](../problems/sum-of-subsequence-widths) | Hard | diff --git a/readme/901-1200.md b/readme/901-1200.md index 56787b7be..d782e4e6a 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    @@ -211,7 +219,7 @@ LeetCode Problems' Solutions | 1031 | [Maximum Sum of Two Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays "两个非重叠子数组的最大和") | [Go](../problems/maximum-sum-of-two-non-overlapping-subarrays) | Medium | | 1032 | [Stream of Characters](https://leetcode.com/problems/stream-of-characters "字符流") | [Go](../problems/stream-of-characters) | Hard | | 1033 | [Moving Stones Until Consecutive](https://leetcode.com/problems/moving-stones-until-consecutive "移动石子直到连续") | [Go](../problems/moving-stones-until-consecutive) | Medium | -| 1034 | [Coloring A Border](https://leetcode.com/problems/coloring-a-border "边框着色") | [Go](../problems/coloring-a-border) | Medium | +| 1034 | [Coloring A Border](https://leetcode.com/problems/coloring-a-border "边界着色") | [Go](../problems/coloring-a-border) | Medium | | 1035 | [Uncrossed Lines](https://leetcode.com/problems/uncrossed-lines "不相交的线") | [Go](../problems/uncrossed-lines) | Medium | | 1036 | [Escape a Large Maze](https://leetcode.com/problems/escape-a-large-maze "逃离大迷宫") | [Go](../problems/escape-a-large-maze) | Hard | | 1037 | [Valid Boomerang](https://leetcode.com/problems/valid-boomerang "有效的回旋镖") | [Go](../problems/valid-boomerang) | Easy | @@ -292,7 +300,7 @@ LeetCode Problems' Solutions | 1112 | [Highest Grade For Each Student](https://leetcode.com/problems/highest-grade-for-each-student "每位学生的最高成绩") 🔒 | [MySQL](../problems/highest-grade-for-each-student) | Medium | | 1113 | [Reported Posts](https://leetcode.com/problems/reported-posts "报告的记录") 🔒 | [MySQL](../problems/reported-posts) | Easy | | 1114 | [Print in Order](https://leetcode.com/problems/print-in-order "按序打印") | [Go](../problems/print-in-order) | Easy | -| 1115 | [Print FooBar Alternately](https://leetcode.com/problems/print-foobar-alternately "交替打印FooBar") | [Go](../problems/print-foobar-alternately) | Medium | +| 1115 | [Print FooBar Alternately](https://leetcode.com/problems/print-foobar-alternately "交替打印 FooBar") | [Go](../problems/print-foobar-alternately) | Medium | | 1116 | [Print Zero Even Odd](https://leetcode.com/problems/print-zero-even-odd "打印零与奇偶数") | [Go](../problems/print-zero-even-odd) | Medium | | 1117 | [Building H2O](https://leetcode.com/problems/building-h2o "H2O 生成") | [Go](../problems/building-h2o) | Medium | | 1118 | [Number of Days in a Month](https://leetcode.com/problems/number-of-days-in-a-month "一月有多少天") 🔒 | [Go](../problems/number-of-days-in-a-month) | Easy | diff --git a/tag/array/README.md b/tag/array/README.md index 90abb510d..ef5f632f3 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,62 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2172 | [数组的最大与和](../../problems/maximum-and-sum-of-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 2171 | [拿出最少数目的魔法豆](../../problems/removing-minimum-number-of-magic-beans) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2170 | [使数组变成交替数组的最少操作数](../../problems/minimum-operations-to-make-the-array-alternating) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2166 | [设计位集](../../problems/design-bitset) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 2164 | [对奇偶下标分别排序](../../problems/sort-even-and-odd-indices-independently) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2163 | [删除元素后和的最小差值](../../problems/minimum-difference-in-sums-after-removal-of-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2161 | [根据给定数字划分数组](../../problems/partition-array-according-to-given-pivot) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2158 | [Amount of New Area Painted Each Day](../../problems/amount-of-new-area-painted-each-day) 🔒 | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 2155 | [分组得分最高的所有下标](../../problems/all-divisions-with-the-highest-score-of-a-binary-array) | [[数组](../array/README.md)] | Medium | +| 2154 | [将找到的值乘以 2](../../problems/keep-multiplying-found-values-by-two) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2151 | [基于陈述统计最多好人数](../../problems/maximum-good-people-based-on-statements) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 2150 | [找出数组中的所有孤独数字](../../problems/find-all-lonely-numbers-in-the-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2149 | [按符号重排数组](../../problems/rearrange-array-elements-by-sign) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2148 | [元素计数](../../problems/count-elements-with-strictly-smaller-and-greater-elements) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2145 | [统计隐藏数组数目](../../problems/count-the-hidden-sequences) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2144 | [打折购买糖果的最小开销](../../problems/minimum-cost-of-buying-candies-with-discount) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2143 | [Choose Numbers From Two Arrays in Range](../../problems/choose-numbers-from-two-arrays-in-range) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2141 | [同时运行 N 台电脑的最长时间](../../problems/maximum-running-time-of-n-computers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2140 | [解决智力问题](../../problems/solving-questions-with-brainpower) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2137 | [Pour Water Between Buckets to Make Water Levels Equal](../../problems/pour-water-between-buckets-to-make-water-levels-equal) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 2136 | [全部开花的最早一天](../../problems/earliest-possible-day-of-full-bloom) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2134 | [最少交换次数来组合所有的 1 II](../../problems/minimum-swaps-to-group-all-1s-together-ii) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2133 | [检查是否每一行每一列都包含全部整数](../../problems/check-if-every-row-and-column-contains-all-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 2132 | [用邮票贴满网格图](../../problems/stamping-the-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2128 | [Remove All Ones With Row and Column Flips](../../problems/remove-all-ones-with-row-and-column-flips) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2126 | [摧毁小行星](../../problems/destroying-asteroids) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2125 | [银行中的激光束数量](../../problems/number-of-laser-beams-in-a-bank) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2123 | [Minimum Operations to Remove Adjacent Ones in Matrix](../../problems/minimum-operations-to-remove-adjacent-ones-in-matrix) 🔒 | [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2122 | [还原原数组](../../problems/recover-the-original-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2121 | [相同元素的间隔之和](../../problems/intervals-between-identical-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 2114 | [句子中的最多单词数](../../problems/maximum-number-of-words-found-in-sentences) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 2113 | [Elements in Array After Removing and Replacing Elements](../../problems/elements-in-array-after-removing-and-replacing-elements) 🔒 | [[数组](../array/README.md)] | Medium | +| 2111 | [使数组 K 递增的最少操作次数](../../problems/minimum-operations-to-make-the-array-k-increasing) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 2110 | [股票平滑下跌阶段的数目](../../problems/number-of-smooth-descent-periods-of-a-stock) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2109 | [向字符串添加空格](../../problems/adding-spaces-to-a-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2108 | [找出数组中的第一个回文字符串](../../problems/find-first-palindromic-string-in-the-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 2107 | [Number of Unique Flavors After Sharing K Candies](../../problems/number-of-unique-flavors-after-sharing-k-candies) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2106 | [摘水果](../../problems/maximum-fruits-harvested-after-at-most-k-steps) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 2105 | [给植物浇水 II](../../problems/watering-plants-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2104 | [子数组范围和](../../problems/sum-of-subarray-ranges) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2100 | [适合打劫银行的日子](../../problems/find-good-days-to-rob-the-bank) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2099 | [找到和最大的长度为 K 的子序列](../../problems/find-subsequence-of-length-k-with-the-largest-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 2098 | [Subsequence of Size K With the Largest Even Sum](../../problems/subsequence-of-size-k-with-the-largest-even-sum) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2094 | [找出 3 位偶数](../../problems/finding-3-digit-even-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2091 | [从数组中移除最大值和最小值](../../problems/removing-minimum-and-maximum-from-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 2090 | [半径为 k 的子数组平均值](../../problems/k-radius-subarray-averages) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2089 | [找出数组排序后的目标下标](../../problems/find-target-indices-after-sorting-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2088 | [统计农场中肥沃金字塔的数目](../../problems/count-fertile-pyramids-in-a-land) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2087 | [网格图中机器人回家的最小代价](../../problems/minimum-cost-homecoming-of-a-robot-in-a-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2085 | [统计出现过一次的公共字符串](../../problems/count-common-words-with-one-occurrence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2079 | [给植物浇水](../../problems/watering-plants) | [[数组](../array/README.md)] | Medium | | 2078 | [两栋颜色不同且距离最远的房子](../../problems/two-furthest-houses-with-different-colors) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | @@ -17,32 +73,31 @@ | 2070 | [每一个查询的最大美丽值](../../problems/most-beautiful-item-for-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 2065 | [最大化一张图中的路径价值](../../problems/maximum-path-quality-of-a-graph) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 2064 | [分配给商店的最多商品的最小值](../../problems/minimized-maximum-of-products-distributed-to-any-store) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 2061 | [Number of Spaces Cleaning Robot Cleaned](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2061 | [扫地机器人清扫过的空间个数](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2059 | [转化数字的最小运算数](../../problems/minimum-operations-to-convert-number) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 2057 | [值相等的最小索引](../../problems/smallest-index-with-equal-value) | [[数组](../array/README.md)] | Easy | | 2056 | [棋盘上有效移动组合的数目](../../problems/number-of-valid-move-combinations-on-chessboard) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[模拟](../simulation/README.md)] | Hard | | 2055 | [蜡烛之间的盘子](../../problems/plates-between-candles) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2053 | [数组中第 K 个独一无二的字符串](../../problems/kth-distinct-string-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | -| 2052 | [Minimum Cost to Separate Sentence Into Rows](../../problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2052 | [将句子分隔成行的最低成本](../../problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 2044 | [统计按位或能得到最大值的子集数目](../../problems/count-number-of-maximum-bitwise-or-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2040 | [两个有序数组的第 K 小乘积](../../problems/kth-smallest-product-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 2037 | [使每位学生都有座位的最少移动次数](../../problems/minimum-number-of-moves-to-seat-everyone) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | -| 2036 | [Maximum Alternating Subarray Sum](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2036 | [最大交替子数组和](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | | 2032 | [至少在两个数组中出现的值](../../problems/two-out-of-three) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 2029 | [石子游戏 IX](../../problems/stone-game-ix) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 2028 | [找出缺失的观测数据](../../problems/find-missing-observations) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2023 | [连接后等于目标字符串的字符串对](../../problems/number-of-pairs-of-strings-with-concatenation-equal-to-target) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 2022 | [将一维数组转变成二维数组](../../problems/convert-1d-array-into-2d-array) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | -| 2021 | [Brightest Position on Street](../../problems/brightest-position-on-street) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2021 | [街上最亮的位置](../../problems/brightest-position-on-street) 🔒 | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 2018 | [判断单词是否能放入填字游戏内](../../problems/check-if-word-can-be-placed-in-crossword) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 2017 | [网格游戏](../../problems/grid-game) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | @@ -54,7 +109,7 @@ | 2009 | [使数组连续的最少操作数](../../problems/minimum-number-of-operations-to-make-array-continuous) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 2008 | [出租车的最大盈利](../../problems/maximum-earnings-from-taxi) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | | 2007 | [从双倍数组中还原原数组](../../problems/find-original-array-from-doubled-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | -| 2006 | [差的绝对值为 K 的数对数目](../../problems/count-number-of-pairs-with-absolute-difference-k) | [[数组](../array/README.md)] | Easy | +| 2006 | [差的绝对值为 K 的数对数目](../../problems/count-number-of-pairs-with-absolute-difference-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 1997 | [访问完所有房间的第一天](../../problems/first-day-where-you-have-been-in-all-the-rooms) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -65,7 +120,7 @@ | 1991 | [找到数组的中间位置](../../problems/find-the-middle-index-in-array) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | | 1986 | [完成任务的最少工作时间段](../../problems/minimum-number-of-work-sessions-to-finish-the-tasks) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1982 | [从子集的和还原数组](../../problems/find-array-given-subset-sums) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] | Hard | | 1981 | [最小化目标值与所选元素的差](../../problems/minimize-the-difference-between-target-and-chosen-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1980 | [找出不同的二进制字符串](../../problems/find-unique-binary-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | @@ -89,9 +144,10 @@ | 1943 | [描述绘画结果](../../problems/describe-the-painting) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1942 | [最小未被占据椅子的编号](../../problems/the-number-of-the-smallest-unoccupied-chair) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1940 | [排序数组之间的最长公共子序列](../../problems/longest-common-subsequence-between-sorted-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 1936 | [新增的最少台阶数](../../problems/add-minimum-number-of-rungs) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1929 | [数组串联](../../problems/concatenation-of-array) | [[数组](../array/README.md)] | Easy | | 1926 | [迷宫中离入口最近的出口](../../problems/nearest-exit-from-entrance-in-maze) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1924 | [Erect the Fence II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1924 | [安装栅栏 II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1920 | [基于排列构建数组](../../problems/build-array-from-permutation) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | @@ -114,7 +170,7 @@ | 1889 | [装包裹的最小浪费空间](../../problems/minimum-space-wasted-from-packaging) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Hard | | 1887 | [使数组元素相等的减少操作次数](../../problems/reduction-operations-to-make-the-array-elements-equal) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1886 | [判断矩阵经轮转后是否一致](../../problems/determine-whether-matrix-can-be-obtained-by-rotation) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | -| 1885 | [Count Pairs in Two Arrays](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1885 | [统计数对](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 1883 | [准时抵达会议现场的最小跳过休息次数](../../problems/minimum-skips-to-arrive-at-meeting-on-time) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1882 | [使用服务器处理任务](../../problems/process-tasks-using-servers) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1879 | [两个数组最小的异或值之和](../../problems/minimum-xor-sum-of-two-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | @@ -146,7 +202,7 @@ | 1827 | [最少操作使数组递增](../../problems/minimum-operations-to-make-the-array-increasing) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 1826 | [有缺陷的传感器](../../problems/faulty-sensor) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 1824 | [最少侧跳次数](../../problems/minimum-sideway-jumps) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1822 | [数组元素积的符号](../../problems/sign-of-the-product-of-an-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1820 | [最多邀请的个数](../../problems/maximum-number-of-accepted-invitations) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Hard | @@ -262,6 +318,7 @@ | 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1605 | [给定行和列的和求可行矩阵](../../problems/find-valid-matrix-given-row-and-column-sums) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1599 | [经营摩天轮的最大利润](../../problems/maximum-profit-of-operating-a-centennial-wheel) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1598 | [文件夹操作日志搜集器](../../problems/crawler-log-folder) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | @@ -274,7 +331,7 @@ | 1583 | [统计不开心的朋友](../../problems/count-unhappy-friends) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1582 | [二进制矩阵中的特殊位置](../../problems/special-positions-in-a-binary-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | | 1580 | [把箱子放进仓库里 II](../../problems/put-boxes-into-the-warehouse-ii) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1578 | [使绳子变成彩色的最短时间](../../problems/minimum-time-to-make-rope-colorful) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | @@ -370,7 +427,7 @@ | 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1380 | [矩阵中的幸运数](../../problems/lucky-numbers-in-a-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | -| 1375 | [灯泡开关 III](../../problems/bulb-switcher-iii) | [[数组](../array/README.md)] | Medium | +| 1375 | [二进制字符串前缀一致的次数](../../problems/number-of-times-binary-string-is-prefix-aligned) | [[数组](../array/README.md)] | Medium | | 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | | 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | @@ -517,7 +574,7 @@ | 1039 | [多边形三角剖分的最低得分](../../problems/minimum-score-triangulation-of-polygon) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 1035 | [不相交的线](../../problems/uncrossed-lines) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1034 | [边界着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1032 | [字符流](../../problems/stream-of-characters) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[数据流](../data-stream/README.md)] | Hard | | 1031 | [两个非重叠子数组的最大和](../../problems/maximum-sum-of-two-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Easy | @@ -610,7 +667,7 @@ | 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 888 | [公平的糖果交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 885 | [螺旋矩阵 III](../../problems/spiral-matrix-iii) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 883 | [三维形体投影面积](../../problems/projection-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Easy | | 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -626,7 +683,7 @@ | 861 | [翻转矩阵后的得分](../../problems/score-after-flipping-matrix) | [[贪心](../greedy/README.md)] [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 860 | [柠檬水找零](../../problems/lemonade-change) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 853 | [车队](../../problems/car-fleet) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 853 | [车队](../../problems/car-fleet) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 852 | [山脉数组的峰顶索引](../../problems/peak-index-in-a-mountain-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 851 | [喧闹和富有](../../problems/loud-and-rich) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] | Medium | | 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[扫描线](../line-sweep/README.md)] | Hard | @@ -649,7 +706,7 @@ | 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 813 | [最大平均值和的分组](../../problems/largest-sum-of-averages) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 812 | [最大三角形面积](../../problems/largest-triangle-area) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | | 810 | [黑板异或游戏](../../problems/chalkboard-xor-game) | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Hard | | 809 | [情感丰富的文字](../../problems/expressive-words) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 807 | [保持城市天际线](../../problems/max-increase-to-keep-city-skyline) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -664,6 +721,7 @@ | 789 | [逃脱阻碍者](../../problems/escape-the-ghosts) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 775 | [全局倒置与局部倒置](../../problems/global-and-local-inversions) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 774 | [最小化去加油站的最大距离](../../problems/minimize-max-distance-to-gas-station) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | @@ -680,6 +738,7 @@ | 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 750 | [角矩形的数量](../../problems/number-of-corner-rectangles) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 749 | [隔离病毒](../../problems/contain-virus) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Hard | +| 748 | [最短补全词](../../problems/shortest-completing-word) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 747 | [至少是其他数字两倍的最大数](../../problems/largest-number-at-least-twice-of-others) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 746 | [使用最小花费爬楼梯](../../problems/min-cost-climbing-stairs) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 744 | [寻找比目标字母大的最小字母](../../problems/find-smallest-letter-greater-than-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | @@ -835,7 +894,7 @@ | 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 377 | [组合总和 Ⅳ](../../problems/combination-sum-iv) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 373 | [查找和最小的K对数字](../../problems/find-k-pairs-with-smallest-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 373 | [查找和最小的 K 对数字](../../problems/find-k-pairs-with-smallest-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 370 | [区间加法](../../problems/range-addition) 🔒 | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | | 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | @@ -877,7 +936,7 @@ | 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 286 | [墙与门](../../problems/walls-and-gates) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 284 | [窥探迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -923,7 +982,7 @@ | 174 | [地下城游戏](../../problems/dungeon-game) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | | 169 | [多数元素](../../problems/majority-element) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | -| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 164 | [最大间距](../../problems/maximum-gap) | [[数组](../array/README.md)] [[桶排序](../bucket-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] | Hard | | 163 | [缺失的区间](../../problems/missing-ranges) 🔒 | [[数组](../array/README.md)] | Easy | | 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -931,6 +990,7 @@ | 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 152 | [乘积最大子数组](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | | 137 | [只出现一次的数字 II](../../problems/single-number-ii) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Medium | | 136 | [只出现一次的数字](../../problems/single-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | | 135 | [分发糖果](../../problems/candy) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Hard | @@ -966,7 +1026,7 @@ | 56 | [合并区间](../../problems/merge-intervals) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 55 | [跳跃游戏](../../problems/jump-game) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 54 | [螺旋矩阵](../../problems/spiral-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 53 | [最大子数组和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 51 | [N 皇后](../../problems/n-queens) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 48 | [旋转图像](../../problems/rotate-image) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 47 | [全排列 II](../../problems/permutations-ii) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index b864fa7ec..88a033751 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2151 | [基于陈述统计最多好人数](../../problems/maximum-good-people-based-on-statements) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2065 | [最大化一张图中的路径价值](../../problems/maximum-path-quality-of-a-graph) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 2056 | [棋盘上有效移动组合的数目](../../problems/number-of-valid-move-combinations-on-chessboard) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[模拟](../simulation/README.md)] | Hard | | 2048 | [下一个更大的数值平衡数](../../problems/next-greater-numerically-balanced-number) | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Medium | @@ -26,6 +28,7 @@ | 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[组合数学](../combinatorics/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Hard | | 1415 | [长度为 n 的开心字符串中字典序第 k 小的字符串](../../problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | @@ -72,6 +75,7 @@ | 291 | [单词规律 II](../../problems/word-pattern-ii) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 282 | [给表达式添加运算符](../../problems/expression-add-operators) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 254 | [因子的组合](../../problems/factor-combinations) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Hard | diff --git a/tag/binary-indexed-tree/README.md b/tag/binary-indexed-tree/README.md index 350e34ae8..efb68694d 100644 --- a/tag/binary-indexed-tree/README.md +++ b/tag/binary-indexed-tree/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1964 | [找出到每个位置为止最长的有效障碍赛跑路线](../../problems/find-the-longest-valid-obstacle-course-at-each-position) | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | diff --git a/tag/binary-search-tree/README.md b/tag/binary-search-tree/README.md index 3a558f6de..a52f03e70 100644 --- a/tag/binary-search-tree/README.md +++ b/tag/binary-search-tree/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1902 | [给定二叉搜索树的插入顺序求深度](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1382 | [将二叉搜索树变平衡](../../problems/balance-a-binary-search-tree) | [[贪心](../greedy/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 3205ba91a..9b634cc8e 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2141 | [同时运行 N 台电脑的最长时间](../../problems/maximum-running-time-of-n-computers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2137 | [Pour Water Between Buckets to Make Water Levels Equal](../../problems/pour-water-between-buckets-to-make-water-levels-equal) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 2111 | [使数组 K 递增的最少操作次数](../../problems/minimum-operations-to-make-the-array-k-increasing) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 2106 | [摘水果](../../problems/maximum-fruits-harvested-after-at-most-k-steps) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 2089 | [找出数组排序后的目标下标](../../problems/find-target-indices-after-sorting-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 2070 | [每一个查询的最大美丽值](../../problems/most-beautiful-item-for-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -17,7 +22,7 @@ | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2040 | [两个有序数组的第 K 小乘积](../../problems/kth-smallest-product-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 2024 | [考试的最大困扰度](../../problems/maximize-the-confusion-of-an-exam) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 2009 | [使数组连续的最少操作数](../../problems/minimum-number-of-operations-to-make-array-continuous) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 2008 | [出租车的最大盈利](../../problems/maximum-earnings-from-taxi) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -33,7 +38,7 @@ | 1894 | [找到需要补充粉笔的学生编号](../../problems/find-the-student-that-will-replace-the-chalk) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1891 | [割绳子](../../problems/cutting-ribbons) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1889 | [装包裹的最小浪费空间](../../problems/minimum-space-wasted-from-packaging) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Hard | -| 1885 | [Count Pairs in Two Arrays](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1885 | [统计数对](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 1870 | [准时到达的列车最小时速](../../problems/minimum-speed-to-arrive-on-time) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1862 | [向下取整数对和](../../problems/sum-of-floored-pairs) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 1855 | [下标对中的最大距离](../../problems/maximum-distance-between-a-pair-of-values) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -104,7 +109,7 @@ | 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 911 | [在线选举](../../problems/online-election) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 902 | [最大为 N 的数字组合](../../problems/numbers-at-most-n-given-digit-set) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 888 | [公平的糖果交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 878 | [第 N 个神奇数字](../../problems/nth-magical-number) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 875 | [爱吃香蕉的珂珂](../../problems/koko-eating-bananas) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -161,13 +166,13 @@ | 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | -| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 154 | [寻找旋转排序数组中的最小值 II](../../problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 81 | [搜索旋转排序数组 II](../../problems/search-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 74 | [搜索二维矩阵](../../problems/search-a-2d-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 69 | [Sqrt(x)](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 69 | [x 的平方根 ](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 35 | [搜索插入位置](../../problems/search-insert-position) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 34 | [在排序数组中查找元素的第一个和最后一个位置](../../problems/find-first-and-last-position-of-element-in-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 33 | [搜索旋转排序数组](../../problems/search-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/binary-tree/README.md b/tag/binary-tree/README.md index 9cea043e7..3fa30ffc7 100644 --- a/tag/binary-tree/README.md +++ b/tag/binary-tree/README.md @@ -9,9 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2096 | [从二叉树一个节点到另一个节点每一步的方向](../../problems/step-by-step-directions-from-a-binary-tree-node-to-another) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | -| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1902 | [给定二叉搜索树的插入顺序求深度](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -44,7 +45,7 @@ | 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -124,7 +125,7 @@ | 285 | [二叉搜索树中的中序后继](../../problems/inorder-successor-in-bst) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -139,11 +140,11 @@ | 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index f008e795e..aef205ab6 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2172 | [数组的最大与和](../../problems/maximum-and-sum-of-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 2157 | [字符串分组](../../problems/groups-of-strings) | [[位运算](../bit-manipulation/README.md)] [[并查集](../union-find/README.md)] [[字符串](../string/README.md)] | Hard | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2151 | [基于陈述统计最多好人数](../../problems/maximum-good-people-based-on-statements) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2128 | [Remove All Ones With Row and Column Flips](../../problems/remove-all-ones-with-row-and-column-flips) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 2044 | [统计按位或能得到最大值的子集数目](../../problems/count-number-of-maximum-bitwise-or-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | @@ -39,7 +45,7 @@ | 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/bitmask/README.md b/tag/bitmask/README.md index 056368cdd..c13f4838e 100644 --- a/tag/bitmask/README.md +++ b/tag/bitmask/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2172 | [数组的最大与和](../../problems/maximum-and-sum-of-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1994 | [好子集的数目](../../problems/the-number-of-good-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 54cf36cd5..4e9f76243 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,8 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | | 2059 | [转化数字的最小运算数](../../problems/minimum-operations-to-convert-number) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | +| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1992 | [找到所有的农场组](../../problems/find-all-groups-of-farmland) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -76,7 +79,7 @@ | 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1197 | [进击的骑士](../../problems/minimum-knight-moves) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | @@ -85,7 +88,7 @@ | 1087 | [花括号展开](../../problems/brace-expansion) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1034 | [边界着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1020 | [飞地的数量](../../problems/number-of-enclaves) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 994 | [腐烂的橘子](../../problems/rotting-oranges) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | @@ -189,8 +192,9 @@ | 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 127 | [单词接龙](../../problems/word-ladder) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | diff --git a/tag/concurrency/README.md b/tag/concurrency/README.md index 6ad20643a..2155bbd8d 100644 --- a/tag/concurrency/README.md +++ b/tag/concurrency/README.md @@ -16,5 +16,5 @@ | 1188 | [设计有限阻塞队列](../../problems/design-bounded-blocking-queue) 🔒 | [[多线程](../concurrency/README.md)] | Medium | | 1117 | [H2O 生成](../../problems/building-h2o) | [[多线程](../concurrency/README.md)] | Medium | | 1116 | [打印零与奇偶数](../../problems/print-zero-even-odd) | [[多线程](../concurrency/README.md)] | Medium | -| 1115 | [交替打印FooBar](../../problems/print-foobar-alternately) | [[多线程](../concurrency/README.md)] | Medium | +| 1115 | [交替打印 FooBar](../../problems/print-foobar-alternately) | [[多线程](../concurrency/README.md)] | Medium | | 1114 | [按序打印](../../problems/print-in-order) | [[多线程](../concurrency/README.md)] | Easy | diff --git a/tag/counting/README.md b/tag/counting/README.md index 111d9c1de..c1807c731 100644 --- a/tag/counting/README.md +++ b/tag/counting/README.md @@ -9,6 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2170 | [使数组变成交替数组的最少操作数](../../problems/minimum-operations-to-make-the-array-alternating) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2150 | [找出数组中的所有孤独数字](../../problems/find-all-lonely-numbers-in-the-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2085 | [统计出现过一次的公共字符串](../../problems/count-common-words-with-one-occurrence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2068 | [检查两个字符串是否几乎相等](../../problems/check-whether-two-strings-are-almost-equivalent) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2067 | [Number of Equal Count Substrings](../../problems/number-of-equal-count-substrings) 🔒 | [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2053 | [数组中第 K 个独一无二的字符串](../../problems/kth-distinct-string-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | @@ -16,6 +22,7 @@ | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2014 | [重复 K 次的最长子序列](../../problems/longest-subsequence-repeated-k-times) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2013 | [检测正方形](../../problems/detect-squares) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2006 | [差的绝对值为 K 的数对数目](../../problems/count-number-of-pairs-with-absolute-difference-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1941 | [检查是否所有字符出现次数相同](../../problems/check-if-all-characters-have-equal-number-of-occurrences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 1940 | [排序数组之间的最长公共子序列](../../problems/longest-common-subsequence-between-sorted-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | @@ -58,6 +65,7 @@ | 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Easy | | 900 | [RLE 迭代器](../../problems/rle-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 869 | [重新排序得到 2 的幂](../../problems/reordered-power-of-2) | [[数学](../math/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Medium | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | | 767 | [重构字符串](../../problems/reorganize-string) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 621 | [任务调度器](../../problems/task-scheduler) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/data-stream/README.md b/tag/data-stream/README.md index 1f6d61328..c7bd52e2a 100644 --- a/tag/data-stream/README.md +++ b/tag/data-stream/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2102 | [序列顺序查询](../../problems/sequentially-ordinal-rank-tracker) | [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] | Medium | | 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] | Easy | | 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 6174bf935..025044f79 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2127 | [参加会议的最多员工数](../../problems/maximum-employees-to-be-invited-to-a-meeting) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2097 | [合法重新排列数对](../../problems/valid-arrangement-of-pairs) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | +| 2096 | [从二叉树一个节点到另一个节点每一步的方向](../../problems/step-by-step-directions-from-a-binary-tree-node-to-another) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | | 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1992 | [找到所有的农场组](../../problems/find-all-groups-of-farmland) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -75,6 +80,7 @@ | 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | | 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1192 | [查找集群内的「关键连接」](../../problems/critical-connections-in-a-network) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[双连通分量](../biconnected-component/README.md)] | Hard | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -85,7 +91,7 @@ | 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1034 | [边界着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1026 | [节点与其祖先之间的最大差值](../../problems/maximum-difference-between-node-and-ancestor) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1022 | [从根到叶的二进制数之和](../../problems/sum-of-root-to-leaf-binary-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | @@ -208,7 +214,7 @@ | 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | | 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 235 | [二叉搜索树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | @@ -227,11 +233,11 @@ | 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | diff --git a/tag/design/README.md b/tag/design/README.md index e62692267..2dc5e63d6 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,10 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2166 | [设计位集](../../problems/design-bitset) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 2102 | [序列顺序查询](../../problems/sequentially-ordinal-rank-tracker) | [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2069 | [模拟行走机器人 II](../../problems/walking-robot-simulation-ii) | [[设计](../design/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | -| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2013 | [检测正方形](../../problems/detect-squares) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | @@ -99,7 +101,7 @@ | 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[设计](../design/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 284 | [窥探迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 271 | [字符串的编码与解码](../../problems/encode-and-decode-strings) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[迭代器](../iterator/README.md)] | Medium | @@ -111,4 +113,4 @@ | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | | 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 146 | [LRU 缓存](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index 6e1eebbbb..e8c6de06d 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1982 | [从子集的和还原数组](../../problems/find-array-given-subset-sums) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] | Hard | | 1901 | [找出顶峰元素 II](../../problems/find-a-peak-element-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -43,6 +43,6 @@ | 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 53 | [最大子数组和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 4 | [寻找两个正序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/doubly-linked-list/README.md b/tag/doubly-linked-list/README.md index 104be93b5..2e57a2202 100644 --- a/tag/doubly-linked-list/README.md +++ b/tag/doubly-linked-list/README.md @@ -15,4 +15,4 @@ | 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Hard | | 430 | [扁平化多级双向链表](../../problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | | 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 146 | [LRU 缓存](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index e156b1010..3e539a824 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,12 +9,23 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2172 | [数组的最大与和](../../problems/maximum-and-sum-of-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 2167 | [移除所有载有违禁货物车厢所需的最少时间](../../problems/minimum-time-to-remove-all-cars-containing-illegal-goods) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2163 | [删除元素后和的最小差值](../../problems/minimum-difference-in-sums-after-removal-of-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2147 | [分隔长廊的方案数](../../problems/number-of-ways-to-divide-a-long-corridor) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2143 | [Choose Numbers From Two Arrays in Range](../../problems/choose-numbers-from-two-arrays-in-range) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2140 | [解决智力问题](../../problems/solving-questions-with-brainpower) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2110 | [股票平滑下跌阶段的数目](../../problems/number-of-smooth-descent-periods-of-a-stock) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2100 | [适合打劫银行的日子](../../problems/find-good-days-to-rob-the-bank) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2088 | [统计农场中肥沃金字塔的数目](../../problems/count-fertile-pyramids-in-a-land) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2086 | [从房屋收集雨水需要的最少水桶数](../../problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2063 | [所有子字符串中的元音](../../problems/vowels-of-all-substrings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | | 2060 | [同源字符串检测](../../problems/check-if-an-original-string-exists-given-two-encoded-strings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 2052 | [Minimum Cost to Separate Sentence Into Rows](../../problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2052 | [将句子分隔成行的最低成本](../../problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2050 | [并行课程 III](../../problems/parallel-courses-iii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 2036 | [Maximum Alternating Subarray Sum](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2036 | [最大交替子数组和](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 2008 | [出租车的最大盈利](../../problems/maximum-earnings-from-taxi) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -85,7 +96,7 @@ | 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1578 | [使绳子变成彩色的最短时间](../../problems/minimum-time-to-make-rope-colorful) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -237,7 +248,7 @@ | 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 689 | [三个无重叠子数组的最大和](../../problems/maximum-sum-of-3-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 688 | [“马”在棋盘上的概率](../../problems/knight-probability-in-chessboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 688 | [骑士在棋盘上的概率](../../problems/knight-probability-in-chessboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 673 | [最长递增子序列的个数](../../problems/number-of-longest-increasing-subsequence) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 664 | [奇怪的打印机](../../problems/strange-printer) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -278,7 +289,7 @@ | 458 | [可怜的小猪](../../problems/poor-pigs) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 446 | [等差数列划分 II - 子序列](../../problems/arithmetic-slices-ii-subsequence) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 435 | [无重叠区间](../../problems/non-overlapping-intervals) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | -| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[模拟](../simulation/README.md)] | Medium | | 416 | [分割等和子集](../../problems/partition-equal-subset-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -343,7 +354,7 @@ | 63 | [不同路径 II](../../problems/unique-paths-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 62 | [不同路径](../../problems/unique-paths) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | | 55 | [跳跃游戏](../../problems/jump-game) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 53 | [最大子数组和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | diff --git a/tag/enumeration/README.md b/tag/enumeration/README.md index cfa2fed90..ff12a4344 100644 --- a/tag/enumeration/README.md +++ b/tag/enumeration/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2162 | [设置时间的最少代价](../../problems/minimum-cost-to-set-cooking-time) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Medium | +| 2151 | [基于陈述统计最多好人数](../../problems/maximum-good-people-based-on-statements) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 2122 | [还原原数组](../../problems/recover-the-original-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2094 | [找出 3 位偶数](../../problems/finding-3-digit-even-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Easy | | 2081 | [k 镜像数字的和](../../problems/sum-of-k-mirror-numbers) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2048 | [下一个更大的数值平衡数](../../problems/next-greater-numerically-balanced-number) | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Medium | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | @@ -20,7 +24,7 @@ | 1925 | [统计平方和三元组的数目](../../problems/count-square-sum-triples) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 1620 | [网络信号最好的坐标](../../problems/coordinate-with-maximum-network-quality) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Medium | | 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[枚举](../enumeration/README.md)] | Hard | -| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1566 | [重复至少 K 次且长度为 M 的模式](../../problems/detect-pattern-of-length-m-repeated-k-or-more-times) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 1534 | [统计好三元组](../../problems/count-good-triplets) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 1291 | [顺次数](../../problems/sequential-digits) | [[枚举](../enumeration/README.md)] | Medium | diff --git a/tag/eulerian-circuit/README.md b/tag/eulerian-circuit/README.md index f48b4407a..a616dce95 100644 --- a/tag/eulerian-circuit/README.md +++ b/tag/eulerian-circuit/README.md @@ -9,5 +9,6 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2097 | [合法重新排列数对](../../problems/valid-arrangement-of-pairs) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | | 753 | [破解保险箱](../../problems/cracking-the-safe) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | | 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index 3bb8dcf8f..e2465ee41 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -9,8 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1956 | [感染 K 种病毒所需的最短时间](../../problems/minimum-time-for-k-virus-variants-to-spread) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[枚举](../enumeration/README.md)] | Hard | -| 1924 | [Erect the Fence II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1924 | [安装栅栏 II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1828 | [统计一个圆中点的数目](../../problems/queries-on-number-of-points-inside-a-circle) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | | 1515 | [服务中心的最佳位置](../../problems/best-position-for-a-service-centre) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Hard | @@ -34,4 +36,4 @@ | 469 | [凸多边形](../../problems/convex-polygon) 🔒 | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | | 335 | [路径交叉](../../problems/self-crossing) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 223 | [矩形面积](../../problems/rectangle-area) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | -| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index 2c116d55e..7fb9edbc3 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,11 +9,18 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2127 | [参加会议的最多员工数](../../problems/maximum-employees-to-be-invited-to-a-meeting) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 2123 | [Minimum Operations to Remove Adjacent Ones in Matrix](../../problems/minimum-operations-to-remove-adjacent-ones-in-matrix) 🔒 | [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2097 | [合法重新排列数对](../../problems/valid-arrangement-of-pairs) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | +| 2093 | [Minimum Cost to Reach City With Discounts](../../problems/minimum-cost-to-reach-city-with-discounts) 🔒 | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Medium | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | | 2077 | [Paths in Maze That Lead to Same Room](../../problems/paths-in-maze-that-lead-to-same-room) 🔒 | [[图](../graph/README.md)] | Medium | | 2076 | [处理含限制条件的好友请求](../../problems/process-restricted-friend-requests) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 2065 | [最大化一张图中的路径价值](../../problems/maximum-path-quality-of-a-graph) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 2050 | [并行课程 III](../../problems/parallel-courses-iii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | +| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 1971 | [寻找图中是否存在路径](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 0d5ade543..273b006ac 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,20 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2170 | [使数组变成交替数组的最少操作数](../../problems/minimum-operations-to-make-the-array-alternating) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2160 | [拆分数位后四位数字的最小和](../../problems/minimum-sum-of-four-digit-number-after-splitting-digits) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2144 | [打折购买糖果的最小开销](../../problems/minimum-cost-of-buying-candies-with-discount) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2141 | [同时运行 N 台电脑的最长时间](../../problems/maximum-running-time-of-n-computers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2139 | [得到目标值的最少行动次数](../../problems/minimum-moves-to-reach-target-score) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 2136 | [全部开花的最早一天](../../problems/earliest-possible-day-of-full-bloom) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2132 | [用邮票贴满网格图](../../problems/stamping-the-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2126 | [摧毁小行星](../../problems/destroying-asteroids) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2116 | [判断一个括号字符串是否有效](../../problems/check-if-a-parentheses-string-can-be-valid) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 2098 | [Subsequence of Size K With the Largest Even Sum](../../problems/subsequence-of-size-k-with-the-largest-even-sum) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2091 | [从数组中移除最大值和最小值](../../problems/removing-minimum-and-maximum-from-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 2087 | [网格图中机器人回家的最小代价](../../problems/minimum-cost-homecoming-of-a-robot-in-a-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2086 | [从房屋收集雨水需要的最少水桶数](../../problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2078 | [两栋颜色不同且距离最远的房子](../../problems/two-furthest-houses-with-different-colors) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 2038 | [如果相邻两个颜色均相同则删除当前颜色](../../problems/remove-colored-pieces-if-both-neighbors-are-the-same-color) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] | Medium | @@ -26,6 +40,7 @@ | 1963 | [使字符串平衡的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-string-balanced) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1953 | [你可以工作的最大周数](../../problems/maximum-number-of-weeks-for-which-you-can-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1946 | [子字符串突变后可能得到的最大整数](../../problems/largest-number-after-mutating-substring) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1936 | [新增的最少台阶数](../../problems/add-minimum-number-of-rungs) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1927 | [求和游戏](../../problems/sum-game) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1903 | [字符串中的最大奇数](../../problems/largest-odd-number-in-string) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | @@ -78,7 +93,7 @@ | 1589 | [所有排列中的最大和](../../problems/maximum-sum-obtained-of-any-permutation) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | | 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 1580 | [把箱子放进仓库里 II](../../problems/put-boxes-into-the-warehouse-ii) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1578 | [使绳子变成彩色的最短时间](../../problems/minimum-time-to-make-rope-colorful) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1564 | [把箱子放进仓库里 I](../../problems/put-boxes-into-the-warehouse-i) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1561 | [你可以获得的最大硬币数目](../../problems/maximum-number-of-coins-you-can-get) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -87,7 +102,7 @@ | 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1537 | [最大得分](../../problems/get-the-maximum-score) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1529 | [最少的后缀翻转次数](../../problems/minimum-suffix-flips) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | | 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -161,7 +176,7 @@ | 846 | [一手顺子](../../problems/hand-of-straights) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | | 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 807 | [保持城市天际线](../../problems/max-increase-to-keep-city-skyline) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 769 | [最多能完成排序的块](../../problems/max-chunks-to-make-sorted) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 768 | [最多能完成排序的块 II](../../problems/max-chunks-to-make-sorted-ii) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 767 | [重构字符串](../../problems/reorganize-string) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/hash-function/README.md b/tag/hash-function/README.md index 7061229ce..15abea6e7 100644 --- a/tag/hash-function/README.md +++ b/tag/hash-function/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2156 | [查找给定哈希值的子串](../../problems/find-substring-with-given-hash-value) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | | 1960 | [两个回文子字符串长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-substrings) | [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index ac840e676..d0645f16b 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,16 +9,35 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2170 | [使数组变成交替数组的最少操作数](../../problems/minimum-operations-to-make-the-array-alternating) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2166 | [设计位集](../../problems/design-bitset) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 2154 | [将找到的值乘以 2](../../problems/keep-multiplying-found-values-by-two) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2150 | [找出数组中的所有孤独数字](../../problems/find-all-lonely-numbers-in-the-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2133 | [检查是否每一行每一列都包含全部整数](../../problems/check-if-every-row-and-column-contains-all-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2122 | [还原原数组](../../problems/recover-the-original-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2121 | [相同元素的间隔之和](../../problems/intervals-between-identical-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 2107 | [Number of Unique Flavors After Sharing K Candies](../../problems/number-of-unique-flavors-after-sharing-k-candies) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2103 | [环和杆](../../problems/rings-and-rods) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 2099 | [找到和最大的长度为 K 的子序列](../../problems/find-subsequence-of-length-k-with-the-largest-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 2094 | [找出 3 位偶数](../../problems/finding-3-digit-even-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2085 | [统计出现过一次的公共字符串](../../problems/count-common-words-with-one-occurrence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2068 | [检查两个字符串是否几乎相等](../../problems/check-whether-two-strings-are-almost-equivalent) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2062 | [统计字符串中的元音子字符串](../../problems/count-vowel-substrings-of-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 2053 | [数组中第 K 个独一无二的字符串](../../problems/kth-distinct-string-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | -| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2032 | [至少在两个数组中出现的值](../../problems/two-out-of-three) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2013 | [检测正方形](../../problems/detect-squares) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | | 2007 | [从双倍数组中还原原数组](../../problems/find-original-array-from-doubled-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2006 | [差的绝对值为 K 的数对数目](../../problems/count-number-of-pairs-with-absolute-difference-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | @@ -194,7 +213,7 @@ | 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 888 | [公平的糖果交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 884 | [两句话中的不常见单词](../../problems/uncommon-words-from-two-sentences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -206,11 +225,11 @@ | 819 | [最常见的单词](../../problems/most-common-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 817 | [链表组件](../../problems/linked-list-components) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | | 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | | 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 792 | [匹配子序列的单词数](../../problems/number-of-matching-subsequences) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 791 | [自定义字符串排序](../../problems/custom-sort-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | -| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 771 | [宝石与石头](../../problems/jewels-and-stones) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | | 767 | [重构字符串](../../problems/reorganize-string) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | @@ -218,12 +237,12 @@ | 760 | [找出变位映射](../../problems/find-anagram-mappings) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | | 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 748 | [最短补全词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 748 | [最短补全词](../../problems/shortest-completing-word) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 740 | [删除并获得点数](../../problems/delete-and-earn) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | | 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | | 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[随机化](../randomized/README.md)] | Hard | @@ -327,8 +346,8 @@ | 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | -| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 146 | [LRU 缓存](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | | 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 141 | [环形链表](../../problems/linked-list-cycle) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 140 | [单词拆分 II](../../problems/word-break-ii) | [[字典树](../trie/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Hard | diff --git a/tag/heap-priority-queue/README.md b/tag/heap-priority-queue/README.md index c5868632c..04cdd71aa 100644 --- a/tag/heap-priority-queue/README.md +++ b/tag/heap-priority-queue/README.md @@ -9,8 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2163 | [删除元素后和的最小差值](../../problems/minimum-difference-in-sums-after-removal-of-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2102 | [序列顺序查询](../../problems/sequentially-ordinal-rank-tracker) | [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2099 | [找到和最大的长度为 K 的子序列](../../problems/find-subsequence-of-length-k-with-the-largest-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2015 | [Average Height of Buildings in Each Segment](../../problems/average-height-of-buildings-in-each-segment) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1962 | [移除石子使总数最小](../../problems/remove-stones-to-minimize-the-total) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | @@ -94,7 +98,7 @@ | 420 | [强密码检验器](../../problems/strong-password-checker) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 373 | [查找和最小的K对数字](../../problems/find-k-pairs-with-smallest-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 373 | [查找和最小的 K 对数字](../../problems/find-k-pairs-with-smallest-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 355 | [设计推特](../../problems/design-twitter) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/iterator/README.md b/tag/iterator/README.md index 641c321ca..0b206b29a 100644 --- a/tag/iterator/README.md +++ b/tag/iterator/README.md @@ -14,7 +14,7 @@ | 900 | [RLE 迭代器](../../problems/rle-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[迭代器](../iterator/README.md)] | Easy | | 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] [[迭代器](../iterator/README.md)] | Medium | -| 284 | [窥探迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index c58530bba..9a8521393 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -9,9 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2130 | [链表最大孪生和](../../problems/maximum-twin-sum-of-a-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2095 | [删除链表的中间节点](../../problems/delete-the-middle-node-of-a-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 2074 | [反转偶数长度组的节点](../../problems/reverse-nodes-in-even-length-groups) | [[链表](../linked-list/README.md)] | Medium | | 2058 | [找出临界点之间的最小和最大距离](../../problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points) | [[链表](../linked-list/README.md)] | Medium | -| 2046 | [Sort Linked List Already Sorted Using Absolute Values](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2046 | [给按照绝对值排序的链表排序](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 1836 | [从未排序的链表中移除重复元素](../../problems/remove-duplicates-from-an-unsorted-linked-list) 🔒 | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | | 1721 | [交换链表中的节点](../../problems/swapping-nodes-in-a-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] | Medium | @@ -52,11 +54,13 @@ | 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 148 | [排序链表](../../problems/sort-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[分治](../divide-and-conquer/README.md)] [[排序](../sorting/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[链表](../linked-list/README.md)] [[排序](../sorting/README.md)] | Medium | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 146 | [LRU 缓存](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | | 143 | [重排链表](../../problems/reorder-list) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 141 | [环形链表](../../problems/linked-list-cycle) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 138 | [复制带随机指针的链表](../../problems/copy-list-with-random-pointer) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 92 | [反转链表 II](../../problems/reverse-linked-list-ii) | [[链表](../linked-list/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 053a05c92..da2c17d3e 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,20 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2169 | [得到 0 的操作数](../../problems/count-operations-to-obtain-zero) | [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2165 | [重排数字的最小值](../../problems/smallest-value-of-the-rearranged-number) | [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2162 | [设置时间的最少代价](../../problems/minimum-cost-to-set-cooking-time) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Medium | +| 2160 | [拆分数位后四位数字的最小和](../../problems/minimum-sum-of-four-digit-number-after-splitting-digits) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2147 | [分隔长廊的方案数](../../problems/number-of-ways-to-divide-a-long-corridor) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2139 | [得到目标值的最少行动次数](../../problems/minimum-moves-to-reach-target-score) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 2128 | [Remove All Ones With Row and Column Flips](../../problems/remove-all-ones-with-row-and-column-flips) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2125 | [银行中的激光束数量](../../problems/number-of-laser-beams-in-a-bank) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2119 | [反转两次的数字](../../problems/a-number-after-a-double-reversal) | [[数学](../math/README.md)] | Easy | +| 2117 | [一个区间内所有数乘积的缩写](../../problems/abbreviating-the-product-of-a-range) | [[数学](../math/README.md)] | Hard | +| 2110 | [股票平滑下跌阶段的数目](../../problems/number-of-smooth-descent-periods-of-a-stock) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2081 | [k 镜像数字的和](../../problems/sum-of-k-mirror-numbers) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2063 | [所有子字符串中的元音](../../problems/vowels-of-all-substrings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | | 2048 | [下一个更大的数值平衡数](../../problems/next-greater-numerically-balanced-number) | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Medium | @@ -27,7 +41,7 @@ | 1952 | [三除数](../../problems/three-divisors) | [[数学](../math/README.md)] | Easy | | 1927 | [求和游戏](../../problems/sum-game) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1925 | [统计平方和三元组的数目](../../problems/count-square-sum-triples) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Easy | -| 1924 | [Erect the Fence II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1924 | [安装栅栏 II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1922 | [统计好数字的数目](../../problems/count-good-numbers) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1908 | [Nim 游戏 II](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | @@ -45,7 +59,7 @@ | 1835 | [所有数对按位与结果的异或和](../../problems/find-xor-sum-of-all-pairs-bitwise-and) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1830 | [使字符串有序的最少操作次数](../../problems/minimum-number-of-operations-to-make-string-sorted) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1828 | [统计一个圆中点的数目](../../problems/queries-on-number-of-points-inside-a-circle) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1822 | [数组元素积的符号](../../problems/sign-of-the-product-of-an-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Hard | | 1814 | [统计一个数组中好对子的数目](../../problems/count-nice-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] | Medium | @@ -97,7 +111,7 @@ | 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | | 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[组合数学](../combinatorics/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Hard | | 1453 | [圆形靶内的最大飞镖数量](../../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | -| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] | Medium | +| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1432 | [改变一个整数能得到的最大差值](../../problems/max-difference-you-can-get-from-changing-an-integer) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | | 1427 | [字符串的左右移](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | @@ -212,7 +226,7 @@ | 789 | [逃脱阻碍者](../../problems/escape-the-ghosts) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 788 | [旋转数字](../../problems/rotated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Hard | -| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 780 | [到达终点](../../problems/reaching-points) | [[数学](../math/README.md)] | Hard | | 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 775 | [全局倒置与局部倒置](../../problems/global-and-local-inversions) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | @@ -293,7 +307,7 @@ | 343 | [整数拆分](../../problems/integer-break) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 342 | [4的幂](../../problems/power-of-four) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | | 335 | [路径交叉](../../problems/self-crossing) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | -| 326 | [3的幂](../../problems/power-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | +| 326 | [3 的幂](../../problems/power-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | | 319 | [灯泡开关](../../problems/bulb-switcher) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Medium | | 313 | [超级丑数](../../problems/super-ugly-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Hard | @@ -320,11 +334,11 @@ | 168 | [Excel表列名称](../../problems/excel-sheet-column-title) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | | 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 89 | [格雷编码](../../problems/gray-code) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 70 | [爬楼梯](../../problems/climbing-stairs) | [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 69 | [Sqrt(x)](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 69 | [x 的平方根 ](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 67 | [二进制求和](../../problems/add-binary) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 66 | [加一](../../problems/plus-one) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 62 | [不同路径](../../problems/unique-paths) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | @@ -336,5 +350,5 @@ | 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 9 | [回文数](../../problems/palindrome-number) | [[数学](../math/README.md)] | Easy | -| 7 | [整数反转](../../problems/reverse-integer) | [[数学](../math/README.md)] | Easy | +| 7 | [整数反转](../../problems/reverse-integer) | [[数学](../math/README.md)] | Medium | | 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/matrix/README.md b/tag/matrix/README.md index f1af6860d..8b27d5128 100644 --- a/tag/matrix/README.md +++ b/tag/matrix/README.md @@ -9,7 +9,15 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2061 | [Number of Spaces Cleaning Robot Cleaned](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2133 | [检查是否每一行每一列都包含全部整数](../../problems/check-if-every-row-and-column-contains-all-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 2132 | [用邮票贴满网格图](../../problems/stamping-the-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2128 | [Remove All Ones With Row and Column Flips](../../problems/remove-all-ones-with-row-and-column-flips) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2125 | [银行中的激光束数量](../../problems/number-of-laser-beams-in-a-bank) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2123 | [Minimum Operations to Remove Adjacent Ones in Matrix](../../problems/minimum-operations-to-remove-adjacent-ones-in-matrix) 🔒 | [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2088 | [统计农场中肥沃金字塔的数目](../../problems/count-fertile-pyramids-in-a-land) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2087 | [网格图中机器人回家的最小代价](../../problems/minimum-cost-homecoming-of-a-robot-in-a-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2061 | [扫地机器人清扫过的空间个数](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | | 2022 | [将一维数组转变成二维数组](../../problems/convert-1d-array-into-2d-array) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | | 2018 | [判断单词是否能放入填字游戏内](../../problems/check-if-word-can-be-placed-in-crossword) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -81,7 +89,7 @@ | 1091 | [二进制矩阵中的最短路径](../../problems/shortest-path-in-binary-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 1072 | [按列翻转得到最大值等行数](../../problems/flip-columns-for-maximum-number-of-equal-rows) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1034 | [边界着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Easy | | 1020 | [飞地的数量](../../problems/number-of-enclaves) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 999 | [可以被一步捕获的棋子数](../../problems/available-captures-for-rook) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | diff --git a/tag/merge-sort/README.md b/tag/merge-sort/README.md index 87b8fff12..81df28808 100644 --- a/tag/merge-sort/README.md +++ b/tag/merge-sort/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 912 | [排序数组](../../problems/sort-an-array) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数排序](../counting-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 493 | [翻转对](../../problems/reverse-pairs) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | diff --git a/tag/monotonic-stack/README.md b/tag/monotonic-stack/README.md index 69ccccc69..b609198b4 100644 --- a/tag/monotonic-stack/README.md +++ b/tag/monotonic-stack/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2104 | [子数组范围和](../../problems/sum-of-subarray-ranges) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 2030 | [含特定字母的最小子序列](../../problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1950 | [所有子数组最小值中的最大值](../../problems/maximum-of-minimum-values-in-all-subarrays) 🔒 | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | @@ -32,6 +33,7 @@ | 962 | [最大宽度坡](../../problems/maximum-width-ramp) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 907 | [子数组的最小值之和](../../problems/sum-of-subarray-minimums) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 901 | [股票价格跨度](../../problems/online-stock-span) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 853 | [车队](../../problems/car-fleet) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 769 | [最多能完成排序的块](../../problems/max-chunks-to-make-sorted) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 768 | [最多能完成排序的块 II](../../problems/max-chunks-to-make-sorted-ii) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | diff --git a/tag/number-theory/README.md b/tag/number-theory/README.md index 47d79b04e..07cf48872 100644 --- a/tag/number-theory/README.md +++ b/tag/number-theory/README.md @@ -12,6 +12,7 @@ | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Hard | | 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] [[数论](../number-theory/README.md)] | Hard | +| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1250 | [检查「好数组」](../../problems/check-if-it-is-a-good-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[数论](../number-theory/README.md)] | Hard | | 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[数论](../number-theory/README.md)] | Medium | | 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Easy | diff --git a/tag/ordered-set/README.md b/tag/ordered-set/README.md index 7665f8456..45db4a2aa 100644 --- a/tag/ordered-set/README.md +++ b/tag/ordered-set/README.md @@ -9,13 +9,15 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2158 | [Amount of New Area Painted Each Day](../../problems/amount-of-new-area-painted-each-day) 🔒 | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 2102 | [序列顺序查询](../../problems/sequentially-ordinal-rank-tracker) | [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | -| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | -| 2021 | [Brightest Position on Street](../../problems/brightest-position-on-street) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2021 | [街上最亮的位置](../../problems/brightest-position-on-street) 🔒 | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1942 | [最小未被占据椅子的编号](../../problems/the-number-of-the-smallest-unoccupied-chair) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1902 | [给定二叉搜索树的插入顺序求深度](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] | Medium | | 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | diff --git a/tag/prefix-sum/README.md b/tag/prefix-sum/README.md index 82e3e9c76..07ca36a90 100644 --- a/tag/prefix-sum/README.md +++ b/tag/prefix-sum/README.md @@ -9,11 +9,18 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2171 | [拿出最少数目的魔法豆](../../problems/removing-minimum-number-of-magic-beans) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2145 | [统计隐藏数组数目](../../problems/count-the-hidden-sequences) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2132 | [用邮票贴满网格图](../../problems/stamping-the-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2121 | [相同元素的间隔之和](../../problems/intervals-between-identical-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2106 | [摘水果](../../problems/maximum-fruits-harvested-after-at-most-k-steps) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 2100 | [适合打劫银行的日子](../../problems/find-good-days-to-rob-the-bank) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2067 | [Number of Equal Count Substrings](../../problems/number-of-equal-count-substrings) 🔒 | [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2055 | [蜡烛之间的盘子](../../problems/plates-between-candles) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2024 | [考试的最大困扰度](../../problems/maximize-the-confusion-of-an-exam) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | -| 2021 | [Brightest Position on Street](../../problems/brightest-position-on-street) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2021 | [街上最亮的位置](../../problems/brightest-position-on-street) 🔒 | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2017 | [网格游戏](../../problems/grid-game) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1991 | [找到数组的中间位置](../../problems/find-the-middle-index-in-array) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | | 1943 | [描述绘画结果](../../problems/describe-the-painting) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index d76a040d3..2db4c7d3d 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -12,6 +12,7 @@ | 2073 | [买票需要的时间](../../problems/time-needed-to-buy-tickets) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1700 | [无法吃午餐的学生数量](../../problems/number-of-students-unable-to-eat-lunch) | [[栈](../stack/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 1696 | [跳跃游戏 VI](../../problems/jump-game-vi) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 9e3769198..c6113caa1 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -11,7 +11,7 @@ | :-: | - | - | :-: | | 1969 | [数组元素的最小非零乘积](../../problems/minimum-non-zero-product-of-the-array-elements) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 1922 | [统计好数字的数目](../../problems/count-good-numbers) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1808 | [好因子的最大数目](../../problems/maximize-number-of-nice-divisors) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | | 1545 | [找出第 N 个二进制字符串中的第 K 位](../../problems/find-kth-bit-in-nth-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | | 1265 | [逆序打印不可变链表](../../problems/print-immutable-linked-list-in-reverse) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | @@ -30,7 +30,7 @@ | 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | | 344 | [反转字符串](../../problems/reverse-string) | [[递归](../recursion/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 342 | [4的幂](../../problems/power-of-four) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | -| 326 | [3的幂](../../problems/power-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | +| 326 | [3 的幂](../../problems/power-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | | 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | | 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | diff --git a/tag/rolling-hash/README.md b/tag/rolling-hash/README.md index 85629bdc3..929c4e240 100644 --- a/tag/rolling-hash/README.md +++ b/tag/rolling-hash/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2156 | [查找给定哈希值的子串](../../problems/find-substring-with-given-hash-value) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | | 1960 | [两个回文子字符串长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-substrings) | [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index 872832452..d15fa7dfa 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -9,8 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2158 | [Amount of New Area Painted Each Day](../../problems/amount-of-new-area-painted-each-day) 🔒 | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/shortest-path/README.md b/tag/shortest-path/README.md index a1cacef5d..09e0f7c25 100644 --- a/tag/shortest-path/README.md +++ b/tag/shortest-path/README.md @@ -9,7 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | +| 2093 | [Minimum Cost to Reach City With Discounts](../../problems/minimum-cost-to-reach-city-with-discounts) 🔒 | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Medium | +| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/simulation/README.md b/tag/simulation/README.md index de5ff39b9..06983fe1f 100644 --- a/tag/simulation/README.md +++ b/tag/simulation/README.md @@ -9,10 +9,18 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2169 | [得到 0 的操作数](../../problems/count-operations-to-obtain-zero) | [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2161 | [根据给定数字划分数组](../../problems/partition-array-according-to-given-pivot) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2154 | [将找到的值乘以 2](../../problems/keep-multiplying-found-values-by-two) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2149 | [按符号重排数组](../../problems/rearrange-array-elements-by-sign) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2138 | [将字符串拆分为若干长度为 k 的组](../../problems/divide-a-string-into-groups-of-size-k) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2120 | [执行所有后缀指令](../../problems/execution-of-all-suffix-instructions-staying-in-a-grid) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2109 | [向字符串添加空格](../../problems/adding-spaces-to-a-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2105 | [给植物浇水 II](../../problems/watering-plants-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2075 | [解码斜向换位密码](../../problems/decode-the-slanted-ciphertext) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2073 | [买票需要的时间](../../problems/time-needed-to-buy-tickets) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 2069 | [模拟行走机器人 II](../../problems/walking-robot-simulation-ii) | [[设计](../design/README.md)] [[模拟](../simulation/README.md)] | Medium | -| 2061 | [Number of Spaces Cleaning Robot Cleaned](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2061 | [扫地机器人清扫过的空间个数](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2056 | [棋盘上有效移动组合的数目](../../problems/number-of-valid-move-combinations-on-chessboard) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[模拟](../simulation/README.md)] | Hard | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2028 | [找出缺失的观测数据](../../problems/find-missing-observations) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | @@ -23,7 +31,7 @@ | 1914 | [循环轮转矩阵](../../problems/cyclically-rotating-a-grid) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1894 | [找到需要补充粉笔的学生编号](../../problems/find-the-student-that-will-replace-the-chalk) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1860 | [增长的内存泄露](../../problems/incremental-memory-leak) | [[模拟](../simulation/README.md)] | Medium | -| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1806 | [还原排列的最少操作步数](../../problems/minimum-number-of-operations-to-reinitialize-a-permutation) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1706 | [球会落何处](../../problems/where-will-the-ball-fall) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | @@ -74,6 +82,7 @@ | 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | | 498 | [对角线遍历](../../problems/diagonal-traverse) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 495 | [提莫攻击](../../problems/teemo-attacking) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[模拟](../simulation/README.md)] | Medium | | 415 | [字符串相加](../../problems/add-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 412 | [Fizz Buzz](../../problems/fizz-buzz) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 289 | [生命游戏](../../problems/game-of-life) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index 888c73f17..c77329490 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -9,7 +9,13 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2156 | [查找给定哈希值的子串](../../problems/find-substring-with-given-hash-value) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2134 | [最少交换次数来组合所有的 1 II](../../problems/minimum-swaps-to-group-all-1s-together-ii) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2107 | [Number of Unique Flavors After Sharing K Candies](../../problems/number-of-unique-flavors-after-sharing-k-candies) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2106 | [摘水果](../../problems/maximum-fruits-harvested-after-at-most-k-steps) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 2090 | [半径为 k 的子数组平均值](../../problems/k-radius-subarray-averages) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 2024 | [考试的最大困扰度](../../problems/maximize-the-confusion-of-an-exam) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1918 | [第 K 小的子数组和·](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1876 | [长度为三且各字符不同的子字符串](../../problems/substrings-of-size-three-with-distinct-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1852 | [每个子数组的数字种类数](../../problems/distinct-numbers-in-each-subarray) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | diff --git a/tag/sorting/README.md b/tag/sorting/README.md index 1e795d316..0ac1e9083 100644 --- a/tag/sorting/README.md +++ b/tag/sorting/README.md @@ -9,10 +9,28 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2171 | [拿出最少数目的魔法豆](../../problems/removing-minimum-number-of-magic-beans) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2165 | [重排数字的最小值](../../problems/smallest-value-of-the-rearranged-number) | [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2164 | [对奇偶下标分别排序](../../problems/sort-even-and-odd-indices-independently) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2160 | [拆分数位后四位数字的最小和](../../problems/minimum-sum-of-four-digit-number-after-splitting-digits) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2154 | [将找到的值乘以 2](../../problems/keep-multiplying-found-values-by-two) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2148 | [元素计数](../../problems/count-elements-with-strictly-smaller-and-greater-elements) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2144 | [打折购买糖果的最小开销](../../problems/minimum-cost-of-buying-candies-with-discount) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2141 | [同时运行 N 台电脑的最长时间](../../problems/maximum-running-time-of-n-computers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2136 | [全部开花的最早一天](../../problems/earliest-possible-day-of-full-bloom) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2126 | [摧毁小行星](../../problems/destroying-asteroids) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2122 | [还原原数组](../../problems/recover-the-original-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2099 | [找到和最大的长度为 K 的子序列](../../problems/find-subsequence-of-length-k-with-the-largest-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 2098 | [Subsequence of Size K With the Largest Even Sum](../../problems/subsequence-of-size-k-with-the-largest-even-sum) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2094 | [找出 3 位偶数](../../problems/finding-3-digit-even-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2089 | [找出数组排序后的目标下标](../../problems/find-target-indices-after-sorting-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 2070 | [每一个查询的最大美丽值](../../problems/most-beautiful-item-for-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 2046 | [Sort Linked List Already Sorted Using Absolute Values](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2046 | [给按照绝对值排序的链表排序](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 2037 | [使每位学生都有座位的最少移动次数](../../problems/minimum-number-of-moves-to-seat-everyone) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | | 2015 | [Average Height of Buildings in Each Segment](../../problems/average-height-of-buildings-in-each-segment) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | @@ -21,13 +39,13 @@ | 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1968 | [构造元素不等于两相邻元素平均值的数组](../../problems/array-with-elements-not-equal-to-average-of-neighbors) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1913 | [两个数对之间的最大乘积差](../../problems/maximum-product-difference-between-two-pairs) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 1889 | [装包裹的最小浪费空间](../../problems/minimum-space-wasted-from-packaging) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Hard | | 1887 | [使数组元素相等的减少操作次数](../../problems/reduction-operations-to-make-the-array-elements-equal) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | -| 1885 | [Count Pairs in Two Arrays](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1885 | [统计数对](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 1878 | [矩阵中最大的三个菱形和](../../problems/get-biggest-three-rhombus-sums-in-a-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1877 | [数组中最大数对和的最小值](../../problems/minimize-maximum-pair-sum-in-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 1874 | [两个数组的最小乘积和](../../problems/minimize-product-sum-of-two-arrays) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -140,12 +158,12 @@ | 905 | [按奇偶排序数组](../../problems/sort-array-by-parity) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Easy | | 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | -| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 888 | [公平的糖果交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 869 | [重新排序得到 2 的幂](../../problems/reordered-power-of-2) | [[数学](../math/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Medium | | 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 853 | [车队](../../problems/car-fleet) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 853 | [车队](../../problems/car-fleet) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 846 | [一手顺子](../../problems/hand-of-straights) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | | 833 | [字符串中的查找与替换](../../problems/find-and-replace-in-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -158,6 +176,7 @@ | 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 757 | [设置交集大小至少为2](../../problems/set-intersection-size-at-least-two) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | | 747 | [至少是其他数字两倍的最大数](../../problems/largest-number-at-least-twice-of-others) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | | 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | | 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[随机化](../randomized/README.md)] | Hard | diff --git a/tag/stack/README.md b/tag/stack/README.md index 7fe784c89..fa5f7a7cd 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2130 | [链表最大孪生和](../../problems/maximum-twin-sum-of-a-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2116 | [判断一个括号字符串是否有效](../../problems/check-if-a-parentheses-string-can-be-valid) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 2104 | [子数组范围和](../../problems/sum-of-subarray-ranges) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 2030 | [含特定字母的最小子序列](../../problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | @@ -69,6 +72,7 @@ | 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 880 | [索引处的解码字符串](../../problems/decoded-string-at-index) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | | 856 | [括号的分数](../../problems/score-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 853 | [车队](../../problems/car-fleet) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | | 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | @@ -77,7 +81,7 @@ | 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 735 | [行星碰撞](../../problems/asteroid-collision) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Medium | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 716 | [最大栈](../../problems/max-stack) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] [[有序集合](../ordered-set/README.md)] | Easy | | 682 | [棒球比赛](../../problems/baseball-game) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index f61110315..0a015eeb0 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,28 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2167 | [移除所有载有违禁货物车厢所需的最少时间](../../problems/minimum-time-to-remove-all-cars-containing-illegal-goods) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2157 | [字符串分组](../../problems/groups-of-strings) | [[位运算](../bit-manipulation/README.md)] [[并查集](../union-find/README.md)] [[字符串](../string/README.md)] | Hard | +| 2156 | [查找给定哈希值的子串](../../problems/find-substring-with-given-hash-value) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2147 | [分隔长廊的方案数](../../problems/number-of-ways-to-divide-a-long-corridor) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2138 | [将字符串拆分为若干长度为 k 的组](../../problems/divide-a-string-into-groups-of-size-k) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2129 | [将标题首字母大写](../../problems/capitalize-the-title) | [[字符串](../string/README.md)] | Easy | +| 2125 | [银行中的激光束数量](../../problems/number-of-laser-beams-in-a-bank) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2124 | [检查是否所有 A 都在 B 之前](../../problems/check-if-all-as-appears-before-all-bs) | [[字符串](../string/README.md)] | Easy | +| 2120 | [执行所有后缀指令](../../problems/execution-of-all-suffix-instructions-staying-in-a-grid) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2116 | [判断一个括号字符串是否有效](../../problems/check-if-a-parentheses-string-can-be-valid) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 2114 | [句子中的最多单词数](../../problems/maximum-number-of-words-found-in-sentences) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 2109 | [向字符串添加空格](../../problems/adding-spaces-to-a-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2108 | [找出数组中的第一个回文字符串](../../problems/find-first-palindromic-string-in-the-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 2103 | [环和杆](../../problems/rings-and-rods) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 2096 | [从二叉树一个节点到另一个节点每一步的方向](../../problems/step-by-step-directions-from-a-binary-tree-node-to-another) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 2086 | [从房屋收集雨水需要的最少水桶数](../../problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2085 | [统计出现过一次的公共字符串](../../problems/count-common-words-with-one-occurrence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2075 | [解码斜向换位密码](../../problems/decode-the-slanted-ciphertext) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2068 | [检查两个字符串是否几乎相等](../../problems/check-whether-two-strings-are-almost-equivalent) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2067 | [Number of Equal Count Substrings](../../problems/number-of-equal-count-substrings) 🔒 | [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | @@ -122,7 +144,7 @@ | 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1592 | [重新排列单词间的空格](../../problems/rearrange-spaces-between-words) | [[字符串](../string/README.md)] | Easy | | 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1578 | [使绳子变成彩色的最短时间](../../problems/minimum-time-to-make-rope-colorful) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1576 | [替换所有的问号](../../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | [[字符串](../string/README.md)] | Easy | | 1573 | [分割字符串的方案数](../../problems/number-of-ways-to-split-a-string) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 1556 | [千位分隔数](../../problems/thousand-separator) | [[字符串](../string/README.md)] | Easy | @@ -133,7 +155,7 @@ | 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1529 | [最少的后缀翻转次数](../../problems/minimum-suffix-flips) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1528 | [重新排列字符串](../../problems/shuffle-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | @@ -147,6 +169,7 @@ | 1455 | [检查单词是否为句中其他单词的前缀](../../problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Easy | | 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1446 | [连续字符](../../problems/consecutive-characters) | [[字符串](../string/README.md)] | Easy | | 1436 | [旅行终点站](../../problems/destination-city) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -291,7 +314,7 @@ | 820 | [单词的压缩编码](../../problems/short-encoding-of-words) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 819 | [最常见的单词](../../problems/most-common-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 816 | [模糊坐标](../../problems/ambiguous-coordinates) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | -| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | | 809 | [情感丰富的文字](../../problems/expressive-words) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 806 | [写字符串需要的行数](../../problems/number-of-lines-to-write-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | @@ -311,14 +334,14 @@ | 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | | 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 751 | [IP 到 CIDR](../../problems/ip-to-cidr) 🔒 | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 748 | [最短补全词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 748 | [最短补全词](../../problems/shortest-completing-word) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 745 | [前缀和后缀搜索](../../problems/prefix-and-suffix-search) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Hard | | 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 722 | [删除注释](../../problems/remove-comments) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 721 | [账户合并](../../problems/accounts-merge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | @@ -392,7 +415,7 @@ | 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 423 | [从英文中重建数字](../../problems/reconstruct-original-digits-from-english) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 420 | [强密码检验器](../../problems/strong-password-checker) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[模拟](../simulation/README.md)] | Medium | | 415 | [字符串相加](../../problems/add-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 412 | [Fizz Buzz](../../problems/fizz-buzz) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 411 | [最短独占单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | @@ -430,7 +453,7 @@ | 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | | 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 266 | [回文排列](../../problems/palindrome-permutation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | | 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/topological-sort/README.md b/tag/topological-sort/README.md index f3fc7304f..eddfb8658 100644 --- a/tag/topological-sort/README.md +++ b/tag/topological-sort/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2127 | [参加会议的最多员工数](../../problems/maximum-employees-to-be-invited-to-a-meeting) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 2050 | [并行课程 III](../../problems/parallel-courses-iii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | diff --git a/tag/tree/README.md b/tag/tree/README.md index a4f396b09..6db216719 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,12 +9,13 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2096 | [从二叉树一个节点到另一个节点每一步的方向](../../problems/step-by-step-directions-from-a-binary-tree-node-to-another) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | -| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1902 | [给定二叉搜索树的插入顺序求深度](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | | 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | @@ -63,7 +64,7 @@ | 1257 | [最小公共区域](../../problems/smallest-common-region) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -153,7 +154,7 @@ | 285 | [二叉搜索树中的中序后继](../../problems/inorder-successor-in-bst) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -168,11 +169,11 @@ | 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index b676b857d..bb35f10de 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,7 +9,13 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2046 | [Sort Linked List Already Sorted Using Absolute Values](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2161 | [根据给定数字划分数组](../../problems/partition-array-according-to-given-pivot) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2149 | [按符号重排数组](../../problems/rearrange-array-elements-by-sign) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2130 | [链表最大孪生和](../../problems/maximum-twin-sum-of-a-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2108 | [找出数组中的第一个回文字符串](../../problems/find-first-palindromic-string-in-the-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 2105 | [给植物浇水 II](../../problems/watering-plants-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2095 | [删除链表的中间节点](../../problems/delete-the-middle-node-of-a-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2046 | [给按照绝对值排序的链表排序](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2000 | [反转单词前缀](../../problems/reverse-prefix-of-word) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 1963 | [使字符串平衡的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-string-balanced) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | @@ -120,7 +126,7 @@ | 189 | [轮转数组](../../problems/rotate-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 186 | [翻转字符串里的单词 II](../../problems/reverse-words-in-a-string-ii) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | -| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 165 | [比较版本号](../../problems/compare-version-numbers) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 161 | [相隔为 1 的编辑距离](../../problems/one-edit-distance) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index b13c5ebf0..7ac700ad6 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2157 | [字符串分组](../../problems/groups-of-strings) | [[位运算](../bit-manipulation/README.md)] [[并查集](../union-find/README.md)] [[字符串](../string/README.md)] | Hard | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | | 2076 | [处理含限制条件的好友请求](../../problems/process-restricted-friend-requests) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | From 80696833dcdc4c66c75ba36f77f9847f1d51fecb Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 16 Feb 2022 15:49:36 +0800 Subject: [PATCH 145/145] A:new --- README.md | 541 ++++++------------ problems/01-matrix/README.md | 6 +- .../README.md | 61 ++ .../README.md | 103 ++++ .../README.md | 2 +- problems/account-balance/README.md | 2 +- problems/active-users/README.md | 6 +- .../add-minimum-number-of-rungs/README.md | 13 +- problems/add-two-numbers/README.md | 6 +- problems/adding-spaces-to-a-string/README.md | 82 +++ problems/ads-performance/README.md | 6 +- .../README.md | 16 +- .../README.md | 92 +++ .../README.md | 29 +- problems/all-oone-data-structure/README.md | 8 +- .../all-possible-full-binary-trees/README.md | 2 +- problems/allocate-mailboxes/README.md | 46 +- .../README.md | 40 ++ problems/android-unlock-patterns/README.md | 6 +- problems/apples-oranges/README.md | 6 +- problems/arithmetic-subarrays/README.md | 4 - problems/armstrong-number/README.md | 6 +- .../available-captures-for-rook/README.md | 6 +- .../README.md | 37 +- problems/average-waiting-time/README.md | 3 - problems/avoid-flood-in-the-city/README.md | 18 +- problems/backspace-string-compare/README.md | 10 +- problems/bag-of-tokens/README.md | 8 +- problems/battleships-in-a-board/README.md | 8 +- problems/beautiful-arrangement/README.md | 2 +- .../README.md | 35 +- .../README.md | 7 - .../README.md | 8 +- .../README.md | 20 +- .../README.md | 2 +- .../README.md | 6 +- problems/binary-subarrays-with-sum/README.md | 8 +- .../README.md | 6 +- .../binary-tree-right-side-view/README.md | 6 +- problems/binary-tree-upside-down/README.md | 6 +- .../README.md | 2 +- problems/break-a-palindrome/README.md | 13 - .../brightest-position-on-street/README.md | 2 +- .../README.md | 39 +- .../README.md | 6 +- problems/build-the-equation/README.md | 17 + problems/build-the-equation/mysql_schemas.sql | 5 + problems/burst-balloons/README.md | 8 +- problems/calculate-salaries/README.md | 6 +- problems/campus-bikes/README.md | 6 +- .../README.md | 3 + .../README.md | 5 +- .../README.md | 8 +- problems/capital-gainloss/README.md | 6 +- problems/capitalize-the-title/README.md | 74 +++ problems/car-fleet-ii/README.md | 7 +- problems/car-pooling/README.md | 22 +- problems/cat-and-mouse-ii/README.md | 30 +- .../cheapest-flights-within-k-stops/README.md | 6 +- .../README.md | 25 +- .../README.md | 86 +++ .../README.md | 34 +- .../README.md | 20 +- .../README.md | 66 +++ .../README.md | 3 + .../README.md | 26 - .../README.md | 18 - .../README.md | 18 +- .../README.md | 3 + .../README.md | 60 ++ .../check-if-n-and-its-double-exist/README.md | 9 +- .../README.md | 9 - .../README.md | 10 +- .../README.md | 23 +- .../README.md | 5 +- problems/cherry-pickup-ii/README.md | 49 +- problems/cherry-pickup/README.md | 6 +- .../README.md | 34 ++ problems/cinema-seat-allocation/README.md | 4 +- .../README.md | 41 +- .../README.md | 6 +- problems/clone-n-ary-tree/README.md | 6 +- .../README.md | 2 +- problems/closest-dessert-cost/README.md | 7 - problems/combination-sum-ii/README.md | 6 +- problems/combination-sum/README.md | 20 +- .../complement-of-base-10-integer/README.md | 6 +- .../README.md | 2 +- problems/consecutive-characters/README.md | 31 +- .../README.md | 8 +- .../README.md | 6 +- .../README.md | 8 +- problems/container-with-most-water/README.md | 28 +- problems/contiguous-array/README.md | 6 +- problems/continuous-subarray-sum/README.md | 6 +- .../convert-1d-array-into-2d-array/README.md | 19 +- .../convert-bst-to-greater-tree/README.md | 16 +- .../README.md | 33 +- .../README.md | 4 +- .../README.md | 22 +- .../README.md | 17 - problems/corporate-flight-bookings/README.md | 6 +- problems/count-all-possible-routes/README.md | 22 +- .../README.md | 6 +- problems/count-binary-substrings/README.md | 6 +- .../README.md | 70 +++ .../README.md | 6 +- .../README.md | 62 ++ .../README.md | 99 ++++ problems/count-good-meals/README.md | 5 + .../count-good-nodes-in-binary-tree/README.md | 6 +- problems/count-good-triplets/README.md | 3 - problems/count-largest-group/README.md | 25 +- .../README.md | 14 - .../count-nice-pairs-in-an-array/README.md | 3 + .../README.md | 2 +- .../README.md | 2 + problems/count-number-of-teams/README.md | 8 +- .../README.md | 13 +- .../count-operations-to-obtain-zero/README.md | 69 +++ problems/count-pairs-in-two-arrays/README.md | 2 +- .../count-pairs-with-xor-in-a-range/README.md | 2 +- .../count-servers-that-communicate/README.md | 4 +- .../README.md | 6 +- .../mysql_schemas.sql | 20 +- problems/count-sub-islands/README.md | 7 +- .../README.md | 2 +- .../README.md | 20 +- .../README.md | 7 +- problems/count-the-hidden-sequences/README.md | 96 ++++ .../README.md | 2 +- .../count-the-number-of-experiments/README.md | 2 +- .../README.md | 25 +- .../README.md | 9 +- .../README.md | 86 +++ problems/counting-bits/README.md | 8 +- .../README.md | 3 + problems/create-a-session-bar-chart/README.md | 6 +- .../README.md | 6 +- .../decode-the-slanted-ciphertext/README.md | 8 - problems/decode-ways-ii/README.md | 1 + problems/decode-xored-permutation/README.md | 2 +- .../README.md | 28 +- problems/deepest-leaves-sum/README.md | 6 +- problems/degree-of-an-array/README.md | 6 +- problems/delete-duplicate-emails/README.md | 48 +- .../delete-duplicate-emails/mysql_schemas.sql | 7 +- .../README.md | 23 - .../README.md | 31 +- .../README.md | 6 +- .../README.md | 75 +++ .../README.md | 15 - .../README.md | 2 +- problems/describe-the-painting/README.md | 4 + .../design-a-file-sharing-system/README.md | 7 +- problems/design-bitset/README.md | 78 +++ problems/design-excel-sum-formula/README.md | 6 +- problems/design-file-system/README.md | 6 +- problems/design-hashmap/README.md | 9 +- problems/design-log-storage-system/README.md | 2 +- problems/design-movie-rental-system/README.md | 4 +- problems/design-parking-system/README.md | 2 +- problems/design-skiplist/README.md | 7 +- problems/design-snake-game/README.md | 6 +- problems/design-underground-system/README.md | 5 +- problems/destroying-asteroids/README.md | 78 +++ .../README.md | 27 +- .../README.md | 18 +- .../README.md | 13 - .../README.md | 3 + problems/detonate-the-maximum-bombs/README.md | 93 +++ problems/diagonal-traverse-ii/README.md | 33 +- problems/diameter-of-binary-tree/README.md | 9 +- problems/distant-barcodes/README.md | 4 +- problems/distinct-echo-substrings/README.md | 4 +- .../distribute-coins-in-binary-tree/README.md | 18 +- .../distribute-repeating-integers/README.md | 21 +- .../README.md | 73 +++ .../README.md | 2 +- .../README.md | 7 +- .../README.md | 95 +++ .../README.md | 3 + .../README.md | 33 ++ .../README.md | 2 +- problems/elimination-game/README.md | 6 +- .../README.md | 2 +- problems/encode-and-decode-strings/README.md | 8 +- problems/encode-and-decode-tinyurl/README.md | 2 +- .../README.md | 6 +- problems/equal-rational-numbers/README.md | 6 +- problems/erect-the-fence-ii/README.md | 2 +- problems/escape-a-large-maze/README.md | 4 +- .../README.md | 2 +- .../README.md | 6 - problems/even-odd-tree/README.md | 30 +- problems/excel-sheet-column-number/README.md | 13 +- .../README.md | 86 +++ problems/fair-candy-swap/README.md | 15 +- problems/filling-bookcase-shelves/README.md | 6 +- .../README.md | 6 +- .../README.md | 20 +- problems/find-a-peak-element-ii/README.md | 3 + .../README.md | 4 +- .../find-all-duplicates-in-an-array/README.md | 6 +- .../README.md | 67 +++ .../find-all-people-with-secret/README.md | 95 +++ .../README.md | 82 +++ problems/find-all-the-lonely-nodes/README.md | 4 + problems/find-and-replace-in-string/README.md | 6 +- problems/find-and-replace-pattern/README.md | 6 +- .../README.md | 6 +- .../README.md | 2 +- problems/find-duplicate-subtrees/README.md | 1 + .../README.md | 10 +- .../README.md | 67 +++ .../find-good-days-to-rob-the-bank/README.md | 86 +++ .../find-if-path-exists-in-graph/README.md | 10 +- problems/find-k-closest-elements/README.md | 6 +- .../README.md | 6 +- .../README.md | 26 +- .../README.md | 13 +- .../find-latest-group-of-size-m/README.md | 25 +- .../find-longest-awesome-substring/README.md | 11 +- .../find-lucky-integer-in-an-array/README.md | 18 +- .../README.md | 6 +- problems/find-missing-observations/README.md | 8 - .../README.md | 3 + .../README.md | 3 + problems/find-root-of-n-ary-tree/README.md | 5 +- .../README.md | 24 +- .../README.md | 72 +++ .../README.md | 75 +++ .../README.md | 70 +++ .../README.md | 11 +- .../README.md | 3 - .../README.md | 30 +- .../find-the-middle-index-in-array/README.md | 19 +- .../README.md | 8 - problems/find-the-missing-ids/README.md | 5 + .../README.md | 6 +- .../README.md | 16 +- .../README.md | 16 +- .../README.md | 3 +- .../README.md | 24 +- .../README.md | 33 +- .../README.md | 8 - .../finding-3-digit-even-numbers/README.md | 73 +++ problems/finding-mk-average/README.md | 7 +- .../README.md | 5 +- .../README.md | 2 +- .../README.md | 6 +- problems/fizz-buzz-multithreaded/README.md | 6 +- .../README.md | 6 +- problems/flip-game-ii/README.md | 6 +- .../README.md | 6 +- .../README.md | 26 +- problems/four-divisors/README.md | 6 +- .../frog-position-after-t-seconds/README.md | 23 +- problems/fruit-into-baskets/README.md | 8 - problems/game-play-analysis-i/README.md | 6 +- problems/get-the-maximum-score/README.md | 19 +- .../README.md | 6 +- .../README.md | 2 +- .../group-sold-products-by-the-date/README.md | 6 +- problems/groups-of-strings/README.md | 96 ++++ .../guess-number-higher-or-lower/README.md | 38 +- problems/guess-the-word/README.md | 2 +- problems/hexspeak/README.md | 6 +- problems/hopper-company-queries-i/README.md | 5 - problems/hopper-company-queries-iii/README.md | 5 - problems/house-robber-iii/README.md | 2 +- problems/house-robber/README.md | 6 +- .../README.md | 6 +- problems/html-entity-parser/README.md | 45 +- problems/image-overlap/README.md | 6 +- problems/immediate-food-delivery-i/README.md | 6 +- problems/immediate-food-delivery-ii/README.md | 6 +- .../implement-rand10-using-rand7/README.md | 6 +- problems/implement-strstr/README.md | 6 +- .../increasing-decreasing-string/README.md | 37 +- problems/integer-replacement/README.md | 6 +- problems/integer-to-english-words/README.md | 36 +- .../README.md | 83 +++ problems/is-graph-bipartite/README.md | 6 +- problems/jump-game-iii/README.md | 6 +- problems/jump-game-v/README.md | 25 +- problems/jump-game-vi/README.md | 8 +- .../README.md | 121 ++++ problems/k-radius-subarray-averages/README.md | 87 +++ .../README.md | 6 +- .../README.md | 81 +++ problems/kill-process/README.md | 6 +- problems/koko-eating-bananas/README.md | 1 + .../kth-largest-element-in-a-stream/README.md | 6 +- problems/largest-1-bordered-square/README.md | 6 +- problems/largest-magic-square/README.md | 3 - problems/largest-multiple-of-three/README.md | 15 +- problems/largest-number/README.md | 18 +- .../largest-odd-number-in-string/README.md | 2 +- problems/largest-perimeter-triangle/README.md | 25 +- problems/largest-subarray-length-k/README.md | 2 +- .../README.md | 20 +- .../README.md | 8 - .../README.md | 29 +- .../README.md | 6 +- .../README.md | 2 +- problems/leetcodify-similar-friends/README.md | 3 + .../README.md | 8 +- problems/letter-case-permutation/README.md | 24 +- .../README.md | 19 +- problems/line-reflection/README.md | 6 +- problems/linked-list-in-binary-tree/README.md | 2 +- problems/logger-rate-limiter/README.md | 6 +- .../README.md | 5 + .../README.md | 6 +- .../longest-arithmetic-subsequence/README.md | 6 +- .../README.md | 8 - .../README.md | 3 + .../README.md | 12 +- .../longest-duplicate-substring/README.md | 10 +- problems/longest-happy-prefix/README.md | 16 +- problems/longest-happy-string/README.md | 28 +- .../longest-harmonious-subsequence/README.md | 6 +- .../README.md | 2 +- problems/longest-mountain-in-array/README.md | 6 +- problems/longest-nice-substring/README.md | 14 +- .../README.md | 80 +++ .../README.md | 3 + .../README.md | 21 +- .../README.md | 8 - .../longest-uncommon-subsequence-ii/README.md | 6 +- problems/longest-univalue-path/README.md | 6 +- problems/longest-winning-streak/README.md | 17 + .../longest-winning-streak/mysql_schemas.sql | 10 + problems/low-quality-problems/README.md | 2 +- .../README.md | 8 + .../README.md | 6 +- problems/majority-element-ii/README.md | 13 +- problems/majority-element/README.md | 6 +- problems/make-sum-divisible-by-p/README.md | 15 - .../README.md | 28 +- problems/making-file-names-unique/README.md | 26 +- problems/map-sum-pairs/README.md | 10 +- problems/matrix-block-sum/README.md | 9 +- .../matrix-cells-in-distance-order/README.md | 10 +- problems/matrix-diagonal-sum/README.md | 3 + problems/max-consecutive-ones-iii/README.md | 9 +- .../README.md | 6 +- problems/max-value-of-equation/README.md | 7 +- problems/maximal-rectangle/README.md | 20 +- .../README.md | 5 +- .../README.md | 2 +- .../README.md | 3 + problems/maximum-and-sum-of-array/README.md | 69 +++ .../README.md | 8 +- .../maximum-ascending-subarray-sum/README.md | 10 +- .../README.md | 2 +- .../README.md | 65 +-- .../README.md | 6 +- .../README.md | 8 - problems/maximum-distance-in-arrays/README.md | 2 +- .../README.md | 2 +- .../README.md | 88 +++ .../README.md | 99 ++++ .../README.md | 8 + .../README.md | 114 ++++ problems/maximum-ice-cream-bars/README.md | 2 +- .../README.md | 8 - .../README.md | 30 +- .../README.md | 19 +- .../README.md | 45 +- .../README.md | 2 + .../README.md | 14 +- .../README.md | 38 +- .../maximum-number-of-eaten-apples/README.md | 5 +- .../README.md | 35 +- .../README.md | 31 +- .../README.md | 2 +- .../README.md | 22 +- .../README.md | 14 +- .../README.md | 4 +- .../README.md | 25 +- .../README.md | 5 +- .../README.md | 61 ++ .../maximum-path-quality-of-a-graph/README.md | 13 +- .../maximum-performance-of-a-team/README.md | 3 + .../README.md | 21 +- .../README.md | 14 - .../maximum-product-of-word-lengths/README.md | 6 +- .../README.md | 25 +- .../maximum-repeating-substring/README.md | 3 - .../README.md | 72 +++ .../README.md | 4 + .../README.md | 5 +- .../README.md | 5 +- .../README.md | 3 + .../maximum-students-taking-exam/README.md | 4 +- .../maximum-sum-bst-in-binary-tree/README.md | 20 +- .../README.md | 6 +- .../README.md | 89 +++ problems/maximum-units-on-a-truck/README.md | 2 +- .../README.md | 2 +- .../README.md | 14 - problems/meeting-rooms-ii/README.md | 8 +- .../merge-bsts-to-create-single-bst/README.md | 8 - .../merge-in-between-linked-lists/README.md | 2 +- problems/merge-intervals/README.md | 1 + problems/merge-strings-alternately/README.md | 3 + .../README.md | 16 +- .../min-cost-to-connect-all-points/README.md | 42 +- problems/mini-parser/README.md | 6 +- .../minimize-deviation-in-array/README.md | 4 +- .../README.md | 5 +- .../minimum-absolute-difference/README.md | 17 +- .../README.md | 20 +- .../README.md | 8 +- problems/minimum-area-rectangle-ii/README.md | 16 +- .../README.md | 75 +++ .../README.md | 100 ++++ .../README.md | 4 +- .../minimum-cost-to-cut-a-stick/README.md | 3 + .../minimum-cost-to-merge-stones/README.md | 6 +- .../README.md | 34 ++ .../README.md | 6 +- .../README.md | 2 +- .../README.md | 98 ++++ .../README.md | 3 + .../README.md | 1 + .../README.md | 25 +- .../README.md | 90 +++ .../README.md | 22 +- .../README.md | 20 +- .../README.md | 8 +- .../README.md | 2 +- .../minimum-falling-path-sum-ii/README.md | 3 + problems/minimum-falling-path-sum/README.md | 6 +- problems/minimum-genetic-mutation/README.md | 6 +- problems/minimum-incompatibility/README.md | 2 +- .../README.md | 16 +- .../README.md | 28 +- .../README.md | 2 +- .../minimum-jumps-to-reach-home/README.md | 2 +- .../README.md | 41 +- .../README.md | 82 +++ .../README.md | 87 +++ .../README.md | 50 +- .../README.md | 20 +- .../README.md | 34 +- .../README.md | 15 +- .../README.md | 36 +- .../README.md | 45 ++ .../README.md | 13 - .../README.md | 3 + .../README.md | 8 +- .../README.md | 14 - .../README.md | 24 +- .../README.md | 2 +- .../README.md | 23 +- .../README.md | 28 +- .../README.md | 40 +- .../README.md | 37 +- .../README.md | 78 +++ .../README.md | 100 ++++ .../README.md | 40 ++ .../README.md | 34 +- .../README.md | 7 - .../README.md | 3 + .../README.md | 2 +- .../README.md | 2 +- problems/minimum-suffix-flips/README.md | 70 +++ .../README.md | 67 +++ .../README.md | 91 +++ .../README.md | 9 +- .../README.md | 22 +- .../README.md | 2 +- .../README.md | 2 +- .../README.md | 67 +++ .../README.md | 97 ++++ .../README.md | 2 +- problems/missing-number/README.md | 17 +- problems/monotone-increasing-digits/README.md | 6 +- problems/monthly-transactions-ii/README.md | 9 +- .../monthly-transactions-ii/mysql_schemas.sql | 4 +- problems/my-calendar-i/README.md | 6 +- problems/my-calendar-ii/README.md | 2 +- .../README.md | 2 +- problems/new-users-daily-count/README.md | 6 +- problems/non-decreasing-array/README.md | 9 +- problems/nth-highest-salary/README.md | 6 +- problems/number-of-1-bits/README.md | 6 +- .../number-of-corner-rectangles/README.md | 6 +- .../README.md | 46 +- problems/number-of-digit-one/README.md | 10 +- .../README.md | 4 +- .../number-of-good-leaf-nodes-pairs/README.md | 26 +- .../README.md | 26 +- .../number-of-laser-beams-in-a-bank/README.md | 89 +++ .../number-of-lines-to-write-string/README.md | 6 +- .../README.md | 4 +- .../README.md | 34 +- .../README.md | 35 +- .../number-of-segments-in-a-string/README.md | 24 +- .../README.md | 25 +- .../README.md | 75 +++ .../README.md | 2 +- .../README.md | 5 +- .../README.md | 6 +- .../README.md | 31 +- .../README.md | 5 +- .../README.md | 31 +- .../README.md | 3 + .../README.md | 26 +- .../README.md | 11 +- .../README.md | 3 - .../README.md | 35 ++ .../README.md | 31 +- .../README.md | 8 - .../README.md | 83 +++ .../README.md | 16 +- .../README.md | 25 +- .../README.md | 57 +- .../README.md | 13 +- .../README.md | 20 +- .../README.md | 30 +- .../README.md | 30 +- .../numbers-with-repeated-digits/README.md | 6 +- problems/odd-even-jump/README.md | 6 +- .../README.md | 4 +- .../order-two-columns-independently/README.md | 17 + .../mysql_schemas.sql | 6 + .../README.md | 2 +- problems/paint-fence/README.md | 6 +- problems/paint-house-iii/README.md | 17 +- problems/palindrome-linked-list/README.md | 6 +- problems/palindrome-pairs/README.md | 1 + .../palindrome-partitioning-iii/README.md | 3 + problems/palindrome-removal/README.md | 6 +- problems/parallel-courses-ii/README.md | 11 +- .../README.md | 74 +++ problems/partition-list/README.md | 6 +- problems/path-sum-ii/README.md | 8 +- problems/path-sum/README.md | 15 +- problems/path-with-minimum-effort/README.md | 10 +- problems/perfect-rectangle/README.md | 8 - problems/pizza-with-3n-slices/README.md | 44 +- problems/plus-one-linked-list/README.md | 6 +- problems/poor-pigs/README.md | 6 +- .../README.md | 7 +- problems/possible-bipartition/README.md | 6 +- .../README.md | 39 ++ problems/power-of-three/README.md | 32 +- problems/prime-arrangements/README.md | 6 +- problems/print-in-order/README.md | 6 +- problems/prison-cells-after-n-days/README.md | 8 +- .../README.md | 16 - .../product-of-array-except-self/README.md | 6 +- .../products-price-for-each-store/README.md | 3 + .../projection-area-of-3d-shapes/README.md | 25 +- .../put-boxes-into-the-warehouse-ii/README.md | 5 +- .../README.md | 6 +- .../queries-quality-and-percentage/README.md | 3 + .../queue-reconstruction-by-height/README.md | 2 +- problems/race-car/README.md | 6 +- problems/random-pick-index/README.md | 8 +- problems/random-pick-with-weight/README.md | 29 +- problems/range-sum-query-mutable/README.md | 8 +- problems/rank-scores/README.md | 6 +- problems/rank-transform-of-a-matrix/README.md | 9 +- problems/reach-a-number/README.md | 6 +- .../README.md | 72 +++ .../rearrange-spaces-between-words/README.md | 32 +- .../README.md | 6 +- .../rearrange-words-in-a-sentence/README.md | 6 +- problems/recover-the-original-array/README.md | 95 +++ problems/rectangle-overlap/README.md | 8 +- problems/rectangles-area/README.md | 6 +- .../reduce-array-size-to-the-half/README.md | 27 +- problems/reducing-dishes/README.md | 11 +- problems/reformat-phone-number/README.md | 16 +- .../README.md | 46 ++ problems/remove-covered-intervals/README.md | 23 +- problems/remove-interval/README.md | 6 +- .../README.md | 2 +- .../README.md | 8 - .../README.md | 3 + .../README.md | 94 +++ .../README.md | 85 +++ .../README.md | 6 +- problems/repeated-string-match/README.md | 23 +- .../README.md | 19 +- problems/reported-posts-ii/README.md | 6 +- problems/restore-the-array/README.md | 24 +- problems/reverse-bits/README.md | 8 +- problems/reverse-linked-list/README.md | 10 +- .../README.md | 28 +- problems/reverse-words-in-a-string/README.md | 20 +- problems/rings-and-rods/README.md | 83 +++ problems/rotate-array/README.md | 8 +- problems/rotate-function/README.md | 6 +- .../README.md | 3 - problems/russian-doll-envelopes/README.md | 10 +- problems/sales-analysis-ii/README.md | 4 + problems/sales-by-day-of-the-week/README.md | 6 +- problems/search-insert-position/README.md | 33 +- problems/search-suggestions-system/README.md | 22 +- problems/second-highest-salary/README.md | 52 +- .../second-highest-salary/mysql_schemas.sql | 8 +- .../README.md | 1 - problems/self-crossing/README.md | 6 +- .../README.md | 15 - problems/sentence-similarity-iii/README.md | 7 - .../README.md | 113 ++++ problems/set-matrix-zeroes/README.md | 10 +- problems/set-mismatch/README.md | 2 +- problems/shift-2d-grid/README.md | 6 +- problems/shortest-bridge/README.md | 20 +- problems/shortest-completing-word/README.md | 22 +- .../README.md | 6 +- .../shortest-path-in-a-hidden-grid/README.md | 4 + problems/shortest-path-to-get-food/README.md | 6 +- .../README.md | 18 +- .../shortest-way-to-form-string/README.md | 3 +- problems/shuffle-string/README.md | 33 +- problems/shuffle-the-array/README.md | 6 +- problems/simplify-path/README.md | 15 +- problems/single-row-keyboard/README.md | 6 +- .../README.md | 2 +- .../smallest-index-with-equal-value/README.md | 8 - .../README.md | 28 +- .../README.md | 2 +- .../README.md | 19 +- .../README.md | 59 ++ .../README.md | 92 +++ problems/sort-an-array/README.md | 12 +- .../README.md | 3 - .../README.md | 81 +++ .../README.md | 36 +- .../README.md | 37 +- .../README.md | 2 +- problems/sort-transformed-array/README.md | 6 +- problems/sorting-the-sentence/README.md | 3 + .../README.md | 7 - .../README.md | 49 +- .../README.md | 22 +- .../split-array-with-same-average/README.md | 6 +- .../README.md | 13 +- .../README.md | 9 - problems/squares-of-a-sorted-array/README.md | 6 +- problems/stamping-the-grid/README.md | 78 +++ problems/stamping-the-sequence/README.md | 8 +- .../README.md | 75 +++ problems/stepping-numbers/README.md | 6 +- problems/stock-price-fluctuation/README.md | 1 + problems/stone-game-ii/README.md | 6 +- problems/stone-game-iii/README.md | 38 +- problems/stone-game-iv/README.md | 33 +- problems/stone-game-vii/README.md | 11 - problems/strange-printer-ii/README.md | 16 +- problems/stream-of-characters/README.md | 10 +- .../string-matching-in-an-array/README.md | 6 +- problems/string-to-integer-atoi/README.md | 41 +- .../strings-differ-by-one-character/README.md | 2 +- problems/strobogrammatic-number-iii/README.md | 6 +- problems/strobogrammatic-number/README.md | 6 +- problems/strong-friendship/README.md | 2 +- .../student-attendance-record-ii/README.md | 6 +- problems/subrectangle-queries/README.md | 2 +- .../README.md | 35 ++ .../README.md | 2 +- .../README.md | 9 +- .../README.md | 2 +- problems/sudoku-solver/README.md | 6 +- problems/sum-of-square-numbers/README.md | 21 - problems/sum-of-subarray-minimums/README.md | 6 +- problems/sum-of-subarray-ranges/README.md | 83 +++ problems/sum-of-subsequence-widths/README.md | 6 +- problems/surface-area-of-3d-shapes/README.md | 27 +- problems/surrounded-regions/README.md | 2 +- problems/suspicious-bank-accounts/README.md | 2 +- problems/swap-adjacent-in-lr-string/README.md | 27 +- .../README.md | 20 +- .../swapping-nodes-in-a-linked-list/README.md | 28 +- problems/symmetric-tree/README.md | 6 +- problems/synonymous-sentences/README.md | 8 +- .../README.md | 17 + .../mysql_schemas.sql | 5 + .../README.md | 2 +- .../README.md | 28 +- problems/the-kth-factor-of-n/README.md | 26 +- .../README.md | 3 + .../README.md | 49 +- .../README.md | 17 + .../mysql_schemas.sql | 11 + .../README.md | 17 + .../mysql_schemas.sql | 12 + .../the-number-of-rich-customers/README.md | 2 +- .../README.md | 13 - problems/the-winner-university/README.md | 2 +- problems/thousand-separator/README.md | 16 +- problems/three-divisors/README.md | 3 + problems/throne-inheritance/README.md | 5 +- problems/time-based-key-value-store/README.md | 5 +- .../README.md | 39 +- problems/total-sales-amount-by-year/README.md | 6 +- problems/trapping-rain-water/README.md | 6 +- problems/tuple-with-same-product/README.md | 16 +- problems/two-sum/README.md | 10 +- .../README.md | 47 ++ .../README.md | 6 +- .../README.md | 2 +- problems/utf-8-validation/README.md | 2 +- problems/valid-arrangement-of-pairs/README.md | 87 +++ problems/valid-parenthesis-string/README.md | 1 + problems/valid-word-abbreviation/README.md | 7 +- problems/verbal-arithmetic-puzzle/README.md | 19 +- problems/video-stitching/README.md | 19 +- problems/vowels-of-all-substrings/README.md | 12 +- problems/water-bottles/README.md | 34 +- problems/watering-plants-ii/README.md | 94 +++ .../README.md | 3 + .../weather-type-in-each-country/README.md | 6 +- problems/where-will-the-ball-fall/README.md | 2 +- problems/wiggle-subsequence/README.md | 11 +- problems/word-abbreviation/README.md | 6 +- problems/word-pattern-ii/README.md | 6 +- problems/word-squares/README.md | 2 +- problems/word-subsets/README.md | 32 +- problems/xor-operation-in-an-array/README.md | 31 +- problems/xor-queries-of-a-subarray/README.md | 2 +- readme/1-300.md | 102 ++-- readme/1201-1500.md | 94 +-- readme/1501-1800.md | 388 +++++++++++++ readme/301-600.md | 96 ++-- readme/601-900.md | 96 ++-- readme/901-1200.md | 96 ++-- tag/array/README.md | 102 +++- tag/backtracking/README.md | 4 + tag/binary-indexed-tree/README.md | 2 +- tag/binary-search-tree/README.md | 2 +- tag/binary-search/README.md | 15 +- tag/binary-tree/README.md | 13 +- tag/bit-manipulation/README.md | 8 +- tag/bitmask/README.md | 2 + tag/breadth-first-search/README.md | 14 +- tag/concurrency/README.md | 2 +- tag/counting/README.md | 8 + tag/data-stream/README.md | 2 + tag/depth-first-search/README.md | 16 +- tag/design/README.md | 8 +- tag/divide-and-conquer/README.md | 4 +- tag/doubly-linked-list/README.md | 2 +- tag/dynamic-programming/README.md | 23 +- tag/enumeration/README.md | 6 +- tag/eulerian-circuit/README.md | 1 + tag/geometry/README.md | 6 +- tag/graph/README.md | 9 +- tag/greedy/README.md | 21 +- tag/hash-function/README.md | 2 + tag/hash-table/README.md | 35 +- tag/heap-priority-queue/README.md | 8 +- tag/iterator/README.md | 2 +- tag/linked-list/README.md | 8 +- tag/math/README.md | 30 +- tag/matrix/README.md | 12 +- tag/merge-sort/README.md | 2 +- tag/monotonic-stack/README.md | 2 + tag/number-theory/README.md | 1 + tag/ordered-set/README.md | 10 +- tag/prefix-sum/README.md | 9 +- tag/queue/README.md | 1 + tag/recursion/README.md | 4 +- tag/rolling-hash/README.md | 2 + tag/segment-tree/README.md | 3 +- tag/shortest-path/README.md | 3 +- tag/simulation/README.md | 13 +- tag/sliding-window/README.md | 6 + tag/sorting/README.md | 29 +- tag/stack/README.md | 6 +- tag/string/README.md | 37 +- tag/topological-sort/README.md | 2 + tag/tree/README.md | 13 +- tag/two-pointers/README.md | 10 +- tag/union-find/README.md | 2 + 783 files changed, 10343 insertions(+), 5686 deletions(-) create mode 100644 problems/a-number-after-a-double-reversal/README.md create mode 100644 problems/abbreviating-the-product-of-a-range/README.md create mode 100644 problems/adding-spaces-to-a-string/README.md create mode 100644 problems/all-divisions-with-the-highest-score-of-a-binary-array/README.md create mode 100644 problems/amount-of-new-area-painted-each-day/README.md create mode 100644 problems/build-the-equation/README.md create mode 100644 problems/build-the-equation/mysql_schemas.sql create mode 100644 problems/capitalize-the-title/README.md create mode 100644 problems/check-if-a-parentheses-string-can-be-valid/README.md create mode 100644 problems/check-if-all-as-appears-before-all-bs/README.md create mode 100644 problems/check-if-every-row-and-column-contains-all-numbers/README.md create mode 100644 problems/choose-numbers-from-two-arrays-in-range/README.md create mode 100644 problems/count-common-words-with-one-occurrence/README.md create mode 100644 problems/count-elements-with-strictly-smaller-and-greater-elements/README.md create mode 100644 problems/count-fertile-pyramids-in-a-land/README.md create mode 100644 problems/count-operations-to-obtain-zero/README.md create mode 100644 problems/count-the-hidden-sequences/README.md create mode 100644 problems/count-words-obtained-after-adding-a-letter/README.md create mode 100644 problems/delete-the-middle-node-of-a-linked-list/README.md create mode 100644 problems/design-bitset/README.md create mode 100644 problems/destroying-asteroids/README.md create mode 100644 problems/detonate-the-maximum-bombs/README.md create mode 100644 problems/divide-a-string-into-groups-of-size-k/README.md create mode 100644 problems/earliest-possible-day-of-full-bloom/README.md create mode 100644 problems/elements-in-array-after-removing-and-replacing-elements/README.md create mode 100644 problems/execution-of-all-suffix-instructions-staying-in-a-grid/README.md create mode 100644 problems/find-all-lonely-numbers-in-the-array/README.md create mode 100644 problems/find-all-people-with-secret/README.md create mode 100644 problems/find-all-possible-recipes-from-given-supplies/README.md create mode 100644 problems/find-first-palindromic-string-in-the-array/README.md create mode 100644 problems/find-good-days-to-rob-the-bank/README.md create mode 100644 problems/find-subsequence-of-length-k-with-the-largest-sum/README.md create mode 100644 problems/find-substring-with-given-hash-value/README.md create mode 100644 problems/find-target-indices-after-sorting-array/README.md create mode 100644 problems/finding-3-digit-even-numbers/README.md create mode 100644 problems/groups-of-strings/README.md create mode 100644 problems/intervals-between-identical-elements/README.md create mode 100644 problems/k-highest-ranked-items-within-a-price-range/README.md create mode 100644 problems/k-radius-subarray-averages/README.md create mode 100644 problems/keep-multiplying-found-values-by-two/README.md create mode 100644 problems/longest-palindrome-by-concatenating-two-letter-words/README.md create mode 100644 problems/longest-winning-streak/README.md create mode 100644 problems/longest-winning-streak/mysql_schemas.sql create mode 100644 problems/maximum-and-sum-of-array/README.md create mode 100644 problems/maximum-employees-to-be-invited-to-a-meeting/README.md create mode 100644 problems/maximum-fruits-harvested-after-at-most-k-steps/README.md create mode 100644 problems/maximum-good-people-based-on-statements/README.md create mode 100644 problems/maximum-number-of-words-found-in-sentences/README.md create mode 100644 problems/maximum-running-time-of-n-computers/README.md create mode 100644 problems/maximum-twin-sum-of-a-linked-list/README.md create mode 100644 problems/minimum-cost-homecoming-of-a-robot-in-a-grid/README.md create mode 100644 problems/minimum-cost-of-buying-candies-with-discount/README.md create mode 100644 problems/minimum-cost-to-reach-city-with-discounts/README.md create mode 100644 problems/minimum-cost-to-set-cooking-time/README.md create mode 100644 problems/minimum-difference-in-sums-after-removal-of-elements/README.md create mode 100644 problems/minimum-moves-to-reach-target-score/README.md create mode 100644 problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses/README.md create mode 100644 problems/minimum-number-of-lines-to-cover-points/README.md create mode 100644 problems/minimum-operations-to-make-the-array-alternating/README.md create mode 100644 problems/minimum-operations-to-make-the-array-k-increasing/README.md create mode 100644 problems/minimum-operations-to-remove-adjacent-ones-in-matrix/README.md create mode 100644 problems/minimum-suffix-flips/README.md create mode 100644 problems/minimum-sum-of-four-digit-number-after-splitting-digits/README.md create mode 100644 problems/minimum-swaps-to-group-all-1s-together-ii/README.md create mode 100644 problems/minimum-time-to-make-rope-colorful/README.md create mode 100644 problems/minimum-time-to-remove-all-cars-containing-illegal-goods/README.md create mode 100644 problems/number-of-laser-beams-in-a-bank/README.md create mode 100644 problems/number-of-smooth-descent-periods-of-a-stock/README.md create mode 100644 problems/number-of-unique-flavors-after-sharing-k-candies/README.md create mode 100644 problems/number-of-ways-to-divide-a-long-corridor/README.md create mode 100644 problems/order-two-columns-independently/README.md create mode 100644 problems/order-two-columns-independently/mysql_schemas.sql create mode 100644 problems/partition-array-according-to-given-pivot/README.md create mode 100644 problems/pour-water-between-buckets-to-make-water-levels-equal/README.md create mode 100644 problems/rearrange-array-elements-by-sign/README.md create mode 100644 problems/recover-the-original-array/README.md create mode 100644 problems/remove-all-ones-with-row-and-column-flips/README.md create mode 100644 problems/removing-minimum-and-maximum-from-array/README.md create mode 100644 problems/removing-minimum-number-of-magic-beans/README.md create mode 100644 problems/rings-and-rods/README.md create mode 100644 problems/sequentially-ordinal-rank-tracker/README.md create mode 100644 problems/smallest-value-of-the-rearranged-number/README.md create mode 100644 problems/solving-questions-with-brainpower/README.md create mode 100644 problems/sort-even-and-odd-indices-independently/README.md create mode 100644 problems/stamping-the-grid/README.md create mode 100644 problems/step-by-step-directions-from-a-binary-tree-node-to-another/README.md create mode 100644 problems/subsequence-of-size-k-with-the-largest-even-sum/README.md create mode 100644 problems/sum-of-subarray-ranges/README.md create mode 100644 problems/the-airport-with-the-most-traffic/README.md create mode 100644 problems/the-airport-with-the-most-traffic/mysql_schemas.sql create mode 100644 problems/the-number-of-passengers-in-each-bus-i/README.md create mode 100644 problems/the-number-of-passengers-in-each-bus-i/mysql_schemas.sql create mode 100644 problems/the-number-of-passengers-in-each-bus-ii/README.md create mode 100644 problems/the-number-of-passengers-in-each-bus-ii/mysql_schemas.sql create mode 100644 problems/unique-substrings-with-equal-digit-frequency/README.md create mode 100644 problems/valid-arrangement-of-pairs/README.md create mode 100644 problems/watering-plants-ii/README.md create mode 100644 readme/1501-1800.md diff --git a/README.md b/README.md index d8ed2b05d..340a1f882 100644 --- a/README.md +++ b/README.md @@ -19,68 +19,165 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    | # | Title | Solution | Difficulty | | :-: | - | - | :-: | -| 2084 | [Drop Type 1 Orders for Customers With Type 0 Orders](https://leetcode.com/problems/drop-type-1-orders-for-customers-with-type-0-orders) 🔒 | [MySQL](problems/drop-type-1-orders-for-customers-with-type-0-orders) | Medium | -| 2083 | [Substrings That Begin and End With the Same Letter](https://leetcode.com/problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [Go](problems/substrings-that-begin-and-end-with-the-same-letter) | Medium | -| 2082 | [The Number of Rich Customers](https://leetcode.com/problems/the-number-of-rich-customers) 🔒 | [MySQL](problems/the-number-of-rich-customers) | Easy | +| 2173 | [Longest Winning Streak](https://leetcode.com/problems/longest-winning-streak) 🔒 | [MySQL](problems/longest-winning-streak) | Hard | +| 2172 | [Maximum AND Sum of Array](https://leetcode.com/problems/maximum-and-sum-of-array "数组的最大与和") | [Go](problems/maximum-and-sum-of-array) | Hard | +| 2171 | [Removing Minimum Number of Magic Beans](https://leetcode.com/problems/removing-minimum-number-of-magic-beans "拿出最少数目的魔法豆") | [Go](problems/removing-minimum-number-of-magic-beans) | Medium | +| 2170 | [Minimum Operations to Make the Array Alternating](https://leetcode.com/problems/minimum-operations-to-make-the-array-alternating "使数组变成交替数组的最少操作数") | [Go](problems/minimum-operations-to-make-the-array-alternating) | Medium | +| 2169 | [Count Operations to Obtain Zero](https://leetcode.com/problems/count-operations-to-obtain-zero "得到 0 的操作数") | [Go](problems/count-operations-to-obtain-zero) | Easy | +| 2168 | [Unique Substrings With Equal Digit Frequency](https://leetcode.com/problems/unique-substrings-with-equal-digit-frequency) 🔒 | [Go](problems/unique-substrings-with-equal-digit-frequency) | Medium | +| 2167 | [Minimum Time to Remove All Cars Containing Illegal Goods](https://leetcode.com/problems/minimum-time-to-remove-all-cars-containing-illegal-goods "移除所有载有违禁货物车厢所需的最少时间") | [Go](problems/minimum-time-to-remove-all-cars-containing-illegal-goods) | Hard | +| 2166 | [Design Bitset](https://leetcode.com/problems/design-bitset "设计位集") | [Go](problems/design-bitset) | Medium | +| 2165 | [Smallest Value of the Rearranged Number](https://leetcode.com/problems/smallest-value-of-the-rearranged-number "重排数字的最小值") | [Go](problems/smallest-value-of-the-rearranged-number) | Medium | +| 2164 | [Sort Even and Odd Indices Independently](https://leetcode.com/problems/sort-even-and-odd-indices-independently "对奇偶下标分别排序") | [Go](problems/sort-even-and-odd-indices-independently) | Easy | +| 2163 | [Minimum Difference in Sums After Removal of Elements](https://leetcode.com/problems/minimum-difference-in-sums-after-removal-of-elements "删除元素后和的最小差值") | [Go](problems/minimum-difference-in-sums-after-removal-of-elements) | Hard | +| 2162 | [Minimum Cost to Set Cooking Time](https://leetcode.com/problems/minimum-cost-to-set-cooking-time "设置时间的最少代价") | [Go](problems/minimum-cost-to-set-cooking-time) | Medium | +| 2161 | [Partition Array According to Given Pivot](https://leetcode.com/problems/partition-array-according-to-given-pivot "根据给定数字划分数组") | [Go](problems/partition-array-according-to-given-pivot) | Medium | +| 2160 | [Minimum Sum of Four Digit Number After Splitting Digits](https://leetcode.com/problems/minimum-sum-of-four-digit-number-after-splitting-digits "拆分数位后四位数字的最小和") | [Go](problems/minimum-sum-of-four-digit-number-after-splitting-digits) | Easy | +| 2159 | [Order Two Columns Independently](https://leetcode.com/problems/order-two-columns-independently) 🔒 | [MySQL](problems/order-two-columns-independently) | Medium | +| 2158 | [Amount of New Area Painted Each Day](https://leetcode.com/problems/amount-of-new-area-painted-each-day) 🔒 | [Go](problems/amount-of-new-area-painted-each-day) | Hard | +| 2157 | [Groups of Strings](https://leetcode.com/problems/groups-of-strings "字符串分组") | [Go](problems/groups-of-strings) | Hard | +| 2156 | [Find Substring With Given Hash Value](https://leetcode.com/problems/find-substring-with-given-hash-value "查找给定哈希值的子串") | [Go](problems/find-substring-with-given-hash-value) | Hard | +| 2155 | [All Divisions With the Highest Score of a Binary Array](https://leetcode.com/problems/all-divisions-with-the-highest-score-of-a-binary-array "分组得分最高的所有下标") | [Go](problems/all-divisions-with-the-highest-score-of-a-binary-array) | Medium | +| 2154 | [Keep Multiplying Found Values by Two](https://leetcode.com/problems/keep-multiplying-found-values-by-two "将找到的值乘以 2") | [Go](problems/keep-multiplying-found-values-by-two) | Easy | +| 2153 | [The Number of Passengers in Each Bus II](https://leetcode.com/problems/the-number-of-passengers-in-each-bus-ii) 🔒 | [MySQL](problems/the-number-of-passengers-in-each-bus-ii) | Hard | +| 2152 | [Minimum Number of Lines to Cover Points](https://leetcode.com/problems/minimum-number-of-lines-to-cover-points) 🔒 | [Go](problems/minimum-number-of-lines-to-cover-points) | Medium | +| 2151 | [Maximum Good People Based on Statements](https://leetcode.com/problems/maximum-good-people-based-on-statements "基于陈述统计最多好人数") | [Go](problems/maximum-good-people-based-on-statements) | Hard | +| 2150 | [Find All Lonely Numbers in the Array](https://leetcode.com/problems/find-all-lonely-numbers-in-the-array "找出数组中的所有孤独数字") | [Go](problems/find-all-lonely-numbers-in-the-array) | Medium | +| 2149 | [Rearrange Array Elements by Sign](https://leetcode.com/problems/rearrange-array-elements-by-sign "按符号重排数组") | [Go](problems/rearrange-array-elements-by-sign) | Medium | +| 2148 | [Count Elements With Strictly Smaller and Greater Elements](https://leetcode.com/problems/count-elements-with-strictly-smaller-and-greater-elements "元素计数") | [Go](problems/count-elements-with-strictly-smaller-and-greater-elements) | Easy | +| 2147 | [Number of Ways to Divide a Long Corridor](https://leetcode.com/problems/number-of-ways-to-divide-a-long-corridor "分隔长廊的方案数") | [Go](problems/number-of-ways-to-divide-a-long-corridor) | Hard | +| 2146 | [K Highest Ranked Items Within a Price Range](https://leetcode.com/problems/k-highest-ranked-items-within-a-price-range "价格范围内最高排名的 K 样物品") | [Go](problems/k-highest-ranked-items-within-a-price-range) | Medium | +| 2145 | [Count the Hidden Sequences](https://leetcode.com/problems/count-the-hidden-sequences "统计隐藏数组数目") | [Go](problems/count-the-hidden-sequences) | Medium | +| 2144 | [Minimum Cost of Buying Candies With Discount](https://leetcode.com/problems/minimum-cost-of-buying-candies-with-discount "打折购买糖果的最小开销") | [Go](problems/minimum-cost-of-buying-candies-with-discount) | Easy | +| 2143 | [Choose Numbers From Two Arrays in Range](https://leetcode.com/problems/choose-numbers-from-two-arrays-in-range) 🔒 | [Go](problems/choose-numbers-from-two-arrays-in-range) | Hard | +| 2142 | [The Number of Passengers in Each Bus I](https://leetcode.com/problems/the-number-of-passengers-in-each-bus-i) 🔒 | [MySQL](problems/the-number-of-passengers-in-each-bus-i) | Medium | +| 2141 | [Maximum Running Time of N Computers](https://leetcode.com/problems/maximum-running-time-of-n-computers "同时运行 N 台电脑的最长时间") | [Go](problems/maximum-running-time-of-n-computers) | Hard | +| 2140 | [Solving Questions With Brainpower](https://leetcode.com/problems/solving-questions-with-brainpower "解决智力问题") | [Go](problems/solving-questions-with-brainpower) | Medium | +| 2139 | [Minimum Moves to Reach Target Score](https://leetcode.com/problems/minimum-moves-to-reach-target-score "得到目标值的最少行动次数") | [Go](problems/minimum-moves-to-reach-target-score) | Medium | +| 2138 | [Divide a String Into Groups of Size k](https://leetcode.com/problems/divide-a-string-into-groups-of-size-k "将字符串拆分为若干长度为 k 的组") | [Go](problems/divide-a-string-into-groups-of-size-k) | Easy | +| 2137 | [Pour Water Between Buckets to Make Water Levels Equal](https://leetcode.com/problems/pour-water-between-buckets-to-make-water-levels-equal) 🔒 | [Go](problems/pour-water-between-buckets-to-make-water-levels-equal) | Medium | +| 2136 | [Earliest Possible Day of Full Bloom](https://leetcode.com/problems/earliest-possible-day-of-full-bloom "全部开花的最早一天") | [Go](problems/earliest-possible-day-of-full-bloom) | Hard | +| 2135 | [Count Words Obtained After Adding a Letter](https://leetcode.com/problems/count-words-obtained-after-adding-a-letter "统计追加字母可以获得的单词数") | [Go](problems/count-words-obtained-after-adding-a-letter) | Medium | +| 2134 | [Minimum Swaps to Group All 1's Together II](https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii "最少交换次数来组合所有的 1 II") | [Go](problems/minimum-swaps-to-group-all-1s-together-ii) | Medium | +| 2133 | [Check if Every Row and Column Contains All Numbers](https://leetcode.com/problems/check-if-every-row-and-column-contains-all-numbers "检查是否每一行每一列都包含全部整数") | [Go](problems/check-if-every-row-and-column-contains-all-numbers) | Easy | +| 2132 | [Stamping the Grid](https://leetcode.com/problems/stamping-the-grid "用邮票贴满网格图") | [Go](problems/stamping-the-grid) | Hard | +| 2131 | [Longest Palindrome by Concatenating Two Letter Words](https://leetcode.com/problems/longest-palindrome-by-concatenating-two-letter-words "连接两字母单词得到的最长回文串") | [Go](problems/longest-palindrome-by-concatenating-two-letter-words) | Medium | +| 2130 | [Maximum Twin Sum of a Linked List](https://leetcode.com/problems/maximum-twin-sum-of-a-linked-list "链表最大孪生和") | [Go](problems/maximum-twin-sum-of-a-linked-list) | Medium | +| 2129 | [Capitalize the Title](https://leetcode.com/problems/capitalize-the-title "将标题首字母大写") | [Go](problems/capitalize-the-title) | Easy | +| 2128 | [Remove All Ones With Row and Column Flips](https://leetcode.com/problems/remove-all-ones-with-row-and-column-flips) 🔒 | [Go](problems/remove-all-ones-with-row-and-column-flips) | Medium | +| 2127 | [Maximum Employees to Be Invited to a Meeting](https://leetcode.com/problems/maximum-employees-to-be-invited-to-a-meeting "参加会议的最多员工数") | [Go](problems/maximum-employees-to-be-invited-to-a-meeting) | Hard | +| 2126 | [Destroying Asteroids](https://leetcode.com/problems/destroying-asteroids "摧毁小行星") | [Go](problems/destroying-asteroids) | Medium | +| 2125 | [Number of Laser Beams in a Bank](https://leetcode.com/problems/number-of-laser-beams-in-a-bank "银行中的激光束数量") | [Go](problems/number-of-laser-beams-in-a-bank) | Medium | +| 2124 | [Check if All A's Appears Before All B's](https://leetcode.com/problems/check-if-all-as-appears-before-all-bs "检查是否所有 A 都在 B 之前") | [Go](problems/check-if-all-as-appears-before-all-bs) | Easy | +| 2123 | [Minimum Operations to Remove Adjacent Ones in Matrix](https://leetcode.com/problems/minimum-operations-to-remove-adjacent-ones-in-matrix) 🔒 | [Go](problems/minimum-operations-to-remove-adjacent-ones-in-matrix) | Hard | +| 2122 | [Recover the Original Array](https://leetcode.com/problems/recover-the-original-array "还原原数组") | [Go](problems/recover-the-original-array) | Hard | +| 2121 | [Intervals Between Identical Elements](https://leetcode.com/problems/intervals-between-identical-elements "相同元素的间隔之和") | [Go](problems/intervals-between-identical-elements) | Medium | +| 2120 | [Execution of All Suffix Instructions Staying in a Grid](https://leetcode.com/problems/execution-of-all-suffix-instructions-staying-in-a-grid "执行所有后缀指令") | [Go](problems/execution-of-all-suffix-instructions-staying-in-a-grid) | Medium | +| 2119 | [A Number After a Double Reversal](https://leetcode.com/problems/a-number-after-a-double-reversal "反转两次的数字") | [Go](problems/a-number-after-a-double-reversal) | Easy | +| 2118 | [Build the Equation](https://leetcode.com/problems/build-the-equation) 🔒 | [MySQL](problems/build-the-equation) | Hard | +| 2117 | [Abbreviating the Product of a Range](https://leetcode.com/problems/abbreviating-the-product-of-a-range "一个区间内所有数乘积的缩写") | [Go](problems/abbreviating-the-product-of-a-range) | Hard | +| 2116 | [Check if a Parentheses String Can Be Valid](https://leetcode.com/problems/check-if-a-parentheses-string-can-be-valid "判断一个括号字符串是否有效") | [Go](problems/check-if-a-parentheses-string-can-be-valid) | Medium | +| 2115 | [Find All Possible Recipes from Given Supplies](https://leetcode.com/problems/find-all-possible-recipes-from-given-supplies "从给定原材料中找到所有可以做出的菜") | [Go](problems/find-all-possible-recipes-from-given-supplies) | Medium | +| 2114 | [Maximum Number of Words Found in Sentences](https://leetcode.com/problems/maximum-number-of-words-found-in-sentences "句子中的最多单词数") | [Go](problems/maximum-number-of-words-found-in-sentences) | Easy | +| 2113 | [Elements in Array After Removing and Replacing Elements](https://leetcode.com/problems/elements-in-array-after-removing-and-replacing-elements) 🔒 | [Go](problems/elements-in-array-after-removing-and-replacing-elements) | Medium | +| 2112 | [The Airport With the Most Traffic](https://leetcode.com/problems/the-airport-with-the-most-traffic) 🔒 | [MySQL](problems/the-airport-with-the-most-traffic) | Medium | +| 2111 | [Minimum Operations to Make the Array K-Increasing](https://leetcode.com/problems/minimum-operations-to-make-the-array-k-increasing "使数组 K 递增的最少操作次数") | [Go](problems/minimum-operations-to-make-the-array-k-increasing) | Hard | +| 2110 | [Number of Smooth Descent Periods of a Stock](https://leetcode.com/problems/number-of-smooth-descent-periods-of-a-stock "股票平滑下跌阶段的数目") | [Go](problems/number-of-smooth-descent-periods-of-a-stock) | Medium | +| 2109 | [Adding Spaces to a String](https://leetcode.com/problems/adding-spaces-to-a-string "向字符串添加空格") | [Go](problems/adding-spaces-to-a-string) | Medium | +| 2108 | [Find First Palindromic String in the Array](https://leetcode.com/problems/find-first-palindromic-string-in-the-array "找出数组中的第一个回文字符串") | [Go](problems/find-first-palindromic-string-in-the-array) | Easy | +| 2107 | [Number of Unique Flavors After Sharing K Candies](https://leetcode.com/problems/number-of-unique-flavors-after-sharing-k-candies) 🔒 | [Go](problems/number-of-unique-flavors-after-sharing-k-candies) | Medium | +| 2106 | [Maximum Fruits Harvested After at Most K Steps](https://leetcode.com/problems/maximum-fruits-harvested-after-at-most-k-steps "摘水果") | [Go](problems/maximum-fruits-harvested-after-at-most-k-steps) | Hard | +| 2105 | [Watering Plants II](https://leetcode.com/problems/watering-plants-ii "给植物浇水 II") | [Go](problems/watering-plants-ii) | Medium | +| 2104 | [Sum of Subarray Ranges](https://leetcode.com/problems/sum-of-subarray-ranges "子数组范围和") | [Go](problems/sum-of-subarray-ranges) | Medium | +| 2103 | [Rings and Rods](https://leetcode.com/problems/rings-and-rods "环和杆") | [Go](problems/rings-and-rods) | Easy | +| 2102 | [Sequentially Ordinal Rank Tracker](https://leetcode.com/problems/sequentially-ordinal-rank-tracker "序列顺序查询") | [Go](problems/sequentially-ordinal-rank-tracker) | Hard | +| 2101 | [Detonate the Maximum Bombs](https://leetcode.com/problems/detonate-the-maximum-bombs "引爆最多的炸弹") | [Go](problems/detonate-the-maximum-bombs) | Medium | +| 2100 | [Find Good Days to Rob the Bank](https://leetcode.com/problems/find-good-days-to-rob-the-bank "适合打劫银行的日子") | [Go](problems/find-good-days-to-rob-the-bank) | Medium | +| 2099 | [Find Subsequence of Length K With the Largest Sum](https://leetcode.com/problems/find-subsequence-of-length-k-with-the-largest-sum "找到和最大的长度为 K 的子序列") | [Go](problems/find-subsequence-of-length-k-with-the-largest-sum) | Easy | +| 2098 | [Subsequence of Size K With the Largest Even Sum](https://leetcode.com/problems/subsequence-of-size-k-with-the-largest-even-sum) 🔒 | [Go](problems/subsequence-of-size-k-with-the-largest-even-sum) | Medium | +| 2097 | [Valid Arrangement of Pairs](https://leetcode.com/problems/valid-arrangement-of-pairs "合法重新排列数对") | [Go](problems/valid-arrangement-of-pairs) | Hard | +| 2096 | [Step-By-Step Directions From a Binary Tree Node to Another](https://leetcode.com/problems/step-by-step-directions-from-a-binary-tree-node-to-another "从二叉树一个节点到另一个节点每一步的方向") | [Go](problems/step-by-step-directions-from-a-binary-tree-node-to-another) | Medium | +| 2095 | [Delete the Middle Node of a Linked List](https://leetcode.com/problems/delete-the-middle-node-of-a-linked-list "删除链表的中间节点") | [Go](problems/delete-the-middle-node-of-a-linked-list) | Medium | +| 2094 | [Finding 3-Digit Even Numbers](https://leetcode.com/problems/finding-3-digit-even-numbers "找出 3 位偶数") | [Go](problems/finding-3-digit-even-numbers) | Easy | +| 2093 | [Minimum Cost to Reach City With Discounts](https://leetcode.com/problems/minimum-cost-to-reach-city-with-discounts) 🔒 | [Go](problems/minimum-cost-to-reach-city-with-discounts) | Medium | +| 2092 | [Find All People With Secret](https://leetcode.com/problems/find-all-people-with-secret "找出知晓秘密的所有专家") | [Go](problems/find-all-people-with-secret) | Hard | +| 2091 | [Removing Minimum and Maximum From Array](https://leetcode.com/problems/removing-minimum-and-maximum-from-array "从数组中移除最大值和最小值") | [Go](problems/removing-minimum-and-maximum-from-array) | Medium | +| 2090 | [K Radius Subarray Averages](https://leetcode.com/problems/k-radius-subarray-averages "半径为 k 的子数组平均值") | [Go](problems/k-radius-subarray-averages) | Medium | +| 2089 | [Find Target Indices After Sorting Array](https://leetcode.com/problems/find-target-indices-after-sorting-array "找出数组排序后的目标下标") | [Go](problems/find-target-indices-after-sorting-array) | Easy | +| 2088 | [Count Fertile Pyramids in a Land](https://leetcode.com/problems/count-fertile-pyramids-in-a-land "统计农场中肥沃金字塔的数目") | [Go](problems/count-fertile-pyramids-in-a-land) | Hard | +| 2087 | [Minimum Cost Homecoming of a Robot in a Grid](https://leetcode.com/problems/minimum-cost-homecoming-of-a-robot-in-a-grid "网格图中机器人回家的最小代价") | [Go](problems/minimum-cost-homecoming-of-a-robot-in-a-grid) | Medium | +| 2086 | [Minimum Number of Buckets Required to Collect Rainwater from Houses](https://leetcode.com/problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses "从房屋收集雨水需要的最少水桶数") | [Go](problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses) | Medium | +| 2085 | [Count Common Words With One Occurrence](https://leetcode.com/problems/count-common-words-with-one-occurrence "统计出现过一次的公共字符串") | [Go](problems/count-common-words-with-one-occurrence) | Easy | +| 2084 | [Drop Type 1 Orders for Customers With Type 0 Orders](https://leetcode.com/problems/drop-type-1-orders-for-customers-with-type-0-orders "为订单类型为 0 的客户删除类型为 1 的订单") 🔒 | [MySQL](problems/drop-type-1-orders-for-customers-with-type-0-orders) | Medium | +| 2083 | [Substrings That Begin and End With the Same Letter](https://leetcode.com/problems/substrings-that-begin-and-end-with-the-same-letter "求以相同字母开头和结尾的子串总数") 🔒 | [Go](problems/substrings-that-begin-and-end-with-the-same-letter) | Medium | +| 2082 | [The Number of Rich Customers](https://leetcode.com/problems/the-number-of-rich-customers "富有客户的数量") 🔒 | [MySQL](problems/the-number-of-rich-customers) | Easy | | 2081 | [Sum of k-Mirror Numbers](https://leetcode.com/problems/sum-of-k-mirror-numbers "k 镜像数字的和") | [Go](problems/sum-of-k-mirror-numbers) | Hard | | 2080 | [Range Frequency Queries](https://leetcode.com/problems/range-frequency-queries "区间内查询数字的频率") | [Go](problems/range-frequency-queries) | Medium | | 2079 | [Watering Plants](https://leetcode.com/problems/watering-plants "给植物浇水") | [Go](problems/watering-plants) | Medium | @@ -90,18 +187,18 @@ LeetCode Problems' Solutions | 2075 | [Decode the Slanted Ciphertext](https://leetcode.com/problems/decode-the-slanted-ciphertext "解码斜向换位密码") | [Go](problems/decode-the-slanted-ciphertext) | Medium | | 2074 | [Reverse Nodes in Even Length Groups](https://leetcode.com/problems/reverse-nodes-in-even-length-groups "反转偶数长度组的节点") | [Go](problems/reverse-nodes-in-even-length-groups) | Medium | | 2073 | [Time Needed to Buy Tickets](https://leetcode.com/problems/time-needed-to-buy-tickets "买票需要的时间") | [Go](problems/time-needed-to-buy-tickets) | Easy | -| 2072 | [The Winner University](https://leetcode.com/problems/the-winner-university) 🔒 | [MySQL](problems/the-winner-university) | Easy | +| 2072 | [The Winner University](https://leetcode.com/problems/the-winner-university "赢得比赛的大学") 🔒 | [MySQL](problems/the-winner-university) | Easy | | 2071 | [Maximum Number of Tasks You Can Assign](https://leetcode.com/problems/maximum-number-of-tasks-you-can-assign "你可以安排的最多任务数目") | [Go](problems/maximum-number-of-tasks-you-can-assign) | Hard | | 2070 | [Most Beautiful Item for Each Query](https://leetcode.com/problems/most-beautiful-item-for-each-query "每一个查询的最大美丽值") | [Go](problems/most-beautiful-item-for-each-query) | Medium | | 2069 | [Walking Robot Simulation II](https://leetcode.com/problems/walking-robot-simulation-ii "模拟行走机器人 II") | [Go](problems/walking-robot-simulation-ii) | Medium | | 2068 | [Check Whether Two Strings are Almost Equivalent](https://leetcode.com/problems/check-whether-two-strings-are-almost-equivalent "检查两个字符串是否几乎相等") | [Go](problems/check-whether-two-strings-are-almost-equivalent) | Easy | | 2067 | [Number of Equal Count Substrings](https://leetcode.com/problems/number-of-equal-count-substrings) 🔒 | [Go](problems/number-of-equal-count-substrings) | Medium | -| 2066 | [Account Balance](https://leetcode.com/problems/account-balance) 🔒 | [MySQL](problems/account-balance) | Medium | +| 2066 | [Account Balance](https://leetcode.com/problems/account-balance "账户余额") 🔒 | [MySQL](problems/account-balance) | Medium | | 2065 | [Maximum Path Quality of a Graph](https://leetcode.com/problems/maximum-path-quality-of-a-graph "最大化一张图中的路径价值") | [Go](problems/maximum-path-quality-of-a-graph) | Hard | | 2064 | [Minimized Maximum of Products Distributed to Any Store](https://leetcode.com/problems/minimized-maximum-of-products-distributed-to-any-store "分配给商店的最多商品的最小值") | [Go](problems/minimized-maximum-of-products-distributed-to-any-store) | Medium | | 2063 | [Vowels of All Substrings](https://leetcode.com/problems/vowels-of-all-substrings "所有子字符串中的元音") | [Go](problems/vowels-of-all-substrings) | Medium | | 2062 | [Count Vowel Substrings of a String](https://leetcode.com/problems/count-vowel-substrings-of-a-string "统计字符串中的元音子字符串") | [Go](problems/count-vowel-substrings-of-a-string) | Easy | -| 2061 | [Number of Spaces Cleaning Robot Cleaned](https://leetcode.com/problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [Go](problems/number-of-spaces-cleaning-robot-cleaned) | Medium | +| 2061 | [Number of Spaces Cleaning Robot Cleaned](https://leetcode.com/problems/number-of-spaces-cleaning-robot-cleaned "扫地机器人清扫过的空间个数") 🔒 | [Go](problems/number-of-spaces-cleaning-robot-cleaned) | Medium | | 2060 | [Check if an Original String Exists Given Two Encoded Strings](https://leetcode.com/problems/check-if-an-original-string-exists-given-two-encoded-strings "同源字符串检测") | [Go](problems/check-if-an-original-string-exists-given-two-encoded-strings) | Hard | | 2059 | [Minimum Operations to Convert Number](https://leetcode.com/problems/minimum-operations-to-convert-number "转化数字的最小运算数") | [Go](problems/minimum-operations-to-convert-number) | Medium | | 2058 | [Find the Minimum and Maximum Number of Nodes Between Critical Points](https://leetcode.com/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points "找出临界点之间的最小和最大距离") | [Go](problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points) | Medium | @@ -110,38 +207,38 @@ LeetCode Problems' Solutions | 2055 | [Plates Between Candles](https://leetcode.com/problems/plates-between-candles "蜡烛之间的盘子") | [Go](problems/plates-between-candles) | Medium | | 2054 | [Two Best Non-Overlapping Events](https://leetcode.com/problems/two-best-non-overlapping-events "两个最好的不重叠活动") | [Go](problems/two-best-non-overlapping-events) | Medium | | 2053 | [Kth Distinct String in an Array](https://leetcode.com/problems/kth-distinct-string-in-an-array "数组中第 K 个独一无二的字符串") | [Go](problems/kth-distinct-string-in-an-array) | Easy | -| 2052 | [Minimum Cost to Separate Sentence Into Rows](https://leetcode.com/problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [Go](problems/minimum-cost-to-separate-sentence-into-rows) | Medium | +| 2052 | [Minimum Cost to Separate Sentence Into Rows](https://leetcode.com/problems/minimum-cost-to-separate-sentence-into-rows "将句子分隔成行的最低成本") 🔒 | [Go](problems/minimum-cost-to-separate-sentence-into-rows) | Medium | | 2051 | [The Category of Each Member in the Store](https://leetcode.com/problems/the-category-of-each-member-in-the-store) 🔒 | [MySQL](problems/the-category-of-each-member-in-the-store) | Medium | | 2050 | [Parallel Courses III](https://leetcode.com/problems/parallel-courses-iii "并行课程 III") | [Go](problems/parallel-courses-iii) | Hard | | 2049 | [Count Nodes With the Highest Score](https://leetcode.com/problems/count-nodes-with-the-highest-score "统计最高分的节点数目") | [Go](problems/count-nodes-with-the-highest-score) | Medium | | 2048 | [Next Greater Numerically Balanced Number](https://leetcode.com/problems/next-greater-numerically-balanced-number "下一个更大的数值平衡数") | [Go](problems/next-greater-numerically-balanced-number) | Medium | | 2047 | [Number of Valid Words in a Sentence](https://leetcode.com/problems/number-of-valid-words-in-a-sentence "句子中的有效单词数") | [Go](problems/number-of-valid-words-in-a-sentence) | Easy | -| 2046 | [Sort Linked List Already Sorted Using Absolute Values](https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [Go](problems/sort-linked-list-already-sorted-using-absolute-values) | Medium | +| 2046 | [Sort Linked List Already Sorted Using Absolute Values](https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values "给按照绝对值排序的链表排序") 🔒 | [Go](problems/sort-linked-list-already-sorted-using-absolute-values) | Medium | | 2045 | [Second Minimum Time to Reach Destination](https://leetcode.com/problems/second-minimum-time-to-reach-destination "到达目的地的第二短时间") | [Go](problems/second-minimum-time-to-reach-destination) | Hard | | 2044 | [Count Number of Maximum Bitwise-OR Subsets](https://leetcode.com/problems/count-number-of-maximum-bitwise-or-subsets "统计按位或能得到最大值的子集数目") | [Go](problems/count-number-of-maximum-bitwise-or-subsets) | Medium | | 2043 | [Simple Bank System](https://leetcode.com/problems/simple-bank-system "简易银行系统") | [Go](problems/simple-bank-system) | Medium | | 2042 | [Check if Numbers Are Ascending in a Sentence](https://leetcode.com/problems/check-if-numbers-are-ascending-in-a-sentence "检查句子中的数字是否递增") | [Go](problems/check-if-numbers-are-ascending-in-a-sentence) | Easy | -| 2041 | [Accepted Candidates From the Interviews](https://leetcode.com/problems/accepted-candidates-from-the-interviews) 🔒 | [MySQL](problems/accepted-candidates-from-the-interviews) | Medium | +| 2041 | [Accepted Candidates From the Interviews](https://leetcode.com/problems/accepted-candidates-from-the-interviews "面试中被录取的候选人") 🔒 | [MySQL](problems/accepted-candidates-from-the-interviews) | Medium | | 2040 | [Kth Smallest Product of Two Sorted Arrays](https://leetcode.com/problems/kth-smallest-product-of-two-sorted-arrays "两个有序数组的第 K 小乘积") | [Go](problems/kth-smallest-product-of-two-sorted-arrays) | Hard | | 2039 | [The Time When the Network Becomes Idle](https://leetcode.com/problems/the-time-when-the-network-becomes-idle "网络空闲的时刻") | [Go](problems/the-time-when-the-network-becomes-idle) | Medium | | 2038 | [Remove Colored Pieces if Both Neighbors are the Same Color](https://leetcode.com/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color "如果相邻两个颜色均相同则删除当前颜色") | [Go](problems/remove-colored-pieces-if-both-neighbors-are-the-same-color) | Medium | | 2037 | [Minimum Number of Moves to Seat Everyone](https://leetcode.com/problems/minimum-number-of-moves-to-seat-everyone "使每位学生都有座位的最少移动次数") | [Go](problems/minimum-number-of-moves-to-seat-everyone) | Easy | -| 2036 | [Maximum Alternating Subarray Sum](https://leetcode.com/problems/maximum-alternating-subarray-sum) 🔒 | [Go](problems/maximum-alternating-subarray-sum) | Medium | +| 2036 | [Maximum Alternating Subarray Sum](https://leetcode.com/problems/maximum-alternating-subarray-sum "最大交替子数组和") 🔒 | [Go](problems/maximum-alternating-subarray-sum) | Medium | | 2035 | [Partition Array Into Two Arrays to Minimize Sum Difference](https://leetcode.com/problems/partition-array-into-two-arrays-to-minimize-sum-difference "将数组分成两个数组并最小化数组和的差") | [Go](problems/partition-array-into-two-arrays-to-minimize-sum-difference) | Hard | | 2034 | [Stock Price Fluctuation](https://leetcode.com/problems/stock-price-fluctuation "股票价格波动") | [Go](problems/stock-price-fluctuation) | Medium | | 2033 | [Minimum Operations to Make a Uni-Value Grid](https://leetcode.com/problems/minimum-operations-to-make-a-uni-value-grid "获取单值网格的最小操作数") | [Go](problems/minimum-operations-to-make-a-uni-value-grid) | Medium | | 2032 | [Two Out of Three](https://leetcode.com/problems/two-out-of-three "至少在两个数组中出现的值") | [Go](problems/two-out-of-three) | Easy | -| 2031 | [Count Subarrays With More Ones Than Zeros](https://leetcode.com/problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [Go](problems/count-subarrays-with-more-ones-than-zeros) | Medium | +| 2031 | [Count Subarrays With More Ones Than Zeros](https://leetcode.com/problems/count-subarrays-with-more-ones-than-zeros "1 比 0 多的子数组个数") 🔒 | [Go](problems/count-subarrays-with-more-ones-than-zeros) | Medium | | 2030 | [Smallest K-Length Subsequence With Occurrences of a Letter](https://leetcode.com/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter "含特定字母的最小子序列") | [Go](problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | Hard | | 2029 | [Stone Game IX](https://leetcode.com/problems/stone-game-ix "石子游戏 IX") | [Go](problems/stone-game-ix) | Medium | | 2028 | [Find Missing Observations](https://leetcode.com/problems/find-missing-observations "找出缺失的观测数据") | [Go](problems/find-missing-observations) | Medium | | 2027 | [Minimum Moves to Convert String](https://leetcode.com/problems/minimum-moves-to-convert-string "转换字符串的最少操作次数") | [Go](problems/minimum-moves-to-convert-string) | Easy | -| 2026 | [Low-Quality Problems](https://leetcode.com/problems/low-quality-problems) 🔒 | [MySQL](problems/low-quality-problems) | Easy | +| 2026 | [Low-Quality Problems](https://leetcode.com/problems/low-quality-problems "低质量的问题") 🔒 | [MySQL](problems/low-quality-problems) | Easy | | 2025 | [Maximum Number of Ways to Partition an Array](https://leetcode.com/problems/maximum-number-of-ways-to-partition-an-array "分割数组的最多方案数") | [Go](problems/maximum-number-of-ways-to-partition-an-array) | Hard | | 2024 | [Maximize the Confusion of an Exam](https://leetcode.com/problems/maximize-the-confusion-of-an-exam "考试的最大困扰度") | [Go](problems/maximize-the-confusion-of-an-exam) | Medium | | 2023 | [Number of Pairs of Strings With Concatenation Equal to Target](https://leetcode.com/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target "连接后等于目标字符串的字符串对") | [Go](problems/number-of-pairs-of-strings-with-concatenation-equal-to-target) | Medium | | 2022 | [Convert 1D Array Into 2D Array](https://leetcode.com/problems/convert-1d-array-into-2d-array "将一维数组转变成二维数组") | [Go](problems/convert-1d-array-into-2d-array) | Easy | -| 2021 | [Brightest Position on Street](https://leetcode.com/problems/brightest-position-on-street) 🔒 | [Go](problems/brightest-position-on-street) | Medium | +| 2021 | [Brightest Position on Street](https://leetcode.com/problems/brightest-position-on-street "街上最亮的位置") 🔒 | [Go](problems/brightest-position-on-street) | Medium | | 2020 | [Number of Accounts That Did Not Stream](https://leetcode.com/problems/number-of-accounts-that-did-not-stream) 🔒 | [MySQL](problems/number-of-accounts-that-did-not-stream) | Medium | | 2019 | [The Score of Students Solving Math Expression](https://leetcode.com/problems/the-score-of-students-solving-math-expression "解出数学表达式的学生分数") | [Go](problems/the-score-of-students-solving-math-expression) | Hard | | 2018 | [Check if Word Can Be Placed In Crossword](https://leetcode.com/problems/check-if-word-can-be-placed-in-crossword "判断单词是否能放入填字游戏内") | [Go](problems/check-if-word-can-be-placed-in-crossword) | Medium | @@ -157,13 +254,13 @@ LeetCode Problems' Solutions | 2008 | [Maximum Earnings From Taxi](https://leetcode.com/problems/maximum-earnings-from-taxi "出租车的最大盈利") | [Go](problems/maximum-earnings-from-taxi) | Medium | | 2007 | [Find Original Array From Doubled Array](https://leetcode.com/problems/find-original-array-from-doubled-array "从双倍数组中还原原数组") | [Go](problems/find-original-array-from-doubled-array) | Medium | | 2006 | [Count Number of Pairs With Absolute Difference K](https://leetcode.com/problems/count-number-of-pairs-with-absolute-difference-k "差的绝对值为 K 的数对数目") | [Go](problems/count-number-of-pairs-with-absolute-difference-k) | Easy | -| 2005 | [Subtree Removal Game with Fibonacci Tree](https://leetcode.com/problems/subtree-removal-game-with-fibonacci-tree) 🔒 | [Go](problems/subtree-removal-game-with-fibonacci-tree) | Hard | +| 2005 | [Subtree Removal Game with Fibonacci Tree](https://leetcode.com/problems/subtree-removal-game-with-fibonacci-tree "斐波那契树的移除子树游戏") 🔒 | [Go](problems/subtree-removal-game-with-fibonacci-tree) | Hard | | 2004 | [The Number of Seniors and Juniors to Join the Company](https://leetcode.com/problems/the-number-of-seniors-and-juniors-to-join-the-company) 🔒 | [MySQL](problems/the-number-of-seniors-and-juniors-to-join-the-company) | Hard | | 2003 | [Smallest Missing Genetic Value in Each Subtree](https://leetcode.com/problems/smallest-missing-genetic-value-in-each-subtree "每棵子树内缺失的最小基因值") | [Go](problems/smallest-missing-genetic-value-in-each-subtree) | Hard | | 2002 | [Maximum Product of the Length of Two Palindromic Subsequences](https://leetcode.com/problems/maximum-product-of-the-length-of-two-palindromic-subsequences "两个回文子序列长度的最大乘积") | [Go](problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | Medium | | 2001 | [Number of Pairs of Interchangeable Rectangles](https://leetcode.com/problems/number-of-pairs-of-interchangeable-rectangles "可互换矩形的组数") | [Go](problems/number-of-pairs-of-interchangeable-rectangles) | Medium | | 2000 | [Reverse Prefix of Word](https://leetcode.com/problems/reverse-prefix-of-word "反转单词前缀") | [Go](problems/reverse-prefix-of-word) | Easy | -| 1999 | [Smallest Greater Multiple Made of Two Digits](https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits) 🔒 | [Go](problems/smallest-greater-multiple-made-of-two-digits) | Medium | +| 1999 | [Smallest Greater Multiple Made of Two Digits](https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits "最小的仅由两个数组成的倍数") 🔒 | [Go](problems/smallest-greater-multiple-made-of-two-digits) | Medium | | 1998 | [GCD Sort of an Array](https://leetcode.com/problems/gcd-sort-of-an-array "数组的最大公因数排序") | [Go](problems/gcd-sort-of-an-array) | Hard | | 1997 | [First Day Where You Have Been in All the Rooms](https://leetcode.com/problems/first-day-where-you-have-been-in-all-the-rooms "访问完所有房间的第一天") | [Go](problems/first-day-where-you-have-been-in-all-the-rooms) | Medium | | 1996 | [The Number of Weak Characters in the Game](https://leetcode.com/problems/the-number-of-weak-characters-in-the-game "游戏中弱角色的数量") | [Go](problems/the-number-of-weak-characters-in-the-game) | Medium | @@ -172,9 +269,9 @@ LeetCode Problems' Solutions | 1993 | [Operations on Tree](https://leetcode.com/problems/operations-on-tree "树上的操作") | [Go](problems/operations-on-tree) | Medium | | 1992 | [Find All Groups of Farmland](https://leetcode.com/problems/find-all-groups-of-farmland "找到所有的农场组") | [Go](problems/find-all-groups-of-farmland) | Medium | | 1991 | [Find the Middle Index in Array](https://leetcode.com/problems/find-the-middle-index-in-array "找到数组的中间位置") | [Go](problems/find-the-middle-index-in-array) | Easy | -| 1990 | [Count the Number of Experiments](https://leetcode.com/problems/count-the-number-of-experiments) 🔒 | [MySQL](problems/count-the-number-of-experiments) | Medium | +| 1990 | [Count the Number of Experiments](https://leetcode.com/problems/count-the-number-of-experiments "统计实验的数量") 🔒 | [MySQL](problems/count-the-number-of-experiments) | Medium | | 1989 | [Maximum Number of People That Can Be Caught in Tag](https://leetcode.com/problems/maximum-number-of-people-that-can-be-caught-in-tag) 🔒 | [Go](problems/maximum-number-of-people-that-can-be-caught-in-tag) | Medium | -| 1988 | [Find Cutoff Score for Each School](https://leetcode.com/problems/find-cutoff-score-for-each-school) 🔒 | [MySQL](problems/find-cutoff-score-for-each-school) | Medium | +| 1988 | [Find Cutoff Score for Each School](https://leetcode.com/problems/find-cutoff-score-for-each-school "找出每所学校的最低分数要求") 🔒 | [MySQL](problems/find-cutoff-score-for-each-school) | Medium | | 1987 | [Number of Unique Good Subsequences](https://leetcode.com/problems/number-of-unique-good-subsequences "不同的好子序列数目") | [Go](problems/number-of-unique-good-subsequences) | Hard | | 1986 | [Minimum Number of Work Sessions to Finish the Tasks](https://leetcode.com/problems/minimum-number-of-work-sessions-to-finish-the-tasks "完成任务的最少工作时间段") | [Go](problems/minimum-number-of-work-sessions-to-finish-the-tasks) | Medium | | 1985 | [Find the Kth Largest Integer in the Array](https://leetcode.com/problems/find-the-kth-largest-integer-in-the-array "找出数组中的第 K 大整数") | [Go](problems/find-the-kth-largest-integer-in-the-array) | Medium | @@ -184,19 +281,19 @@ LeetCode Problems' Solutions | 1981 | [Minimize the Difference Between Target and Chosen Elements](https://leetcode.com/problems/minimize-the-difference-between-target-and-chosen-elements "最小化目标值与所选元素的差") | [Go](problems/minimize-the-difference-between-target-and-chosen-elements) | Medium | | 1980 | [Find Unique Binary String](https://leetcode.com/problems/find-unique-binary-string "找出不同的二进制字符串") | [Go](problems/find-unique-binary-string) | Medium | | 1979 | [Find Greatest Common Divisor of Array](https://leetcode.com/problems/find-greatest-common-divisor-of-array "找出数组的最大公约数") | [Go](problems/find-greatest-common-divisor-of-array) | Easy | -| 1978 | [Employees Whose Manager Left the Company](https://leetcode.com/problems/employees-whose-manager-left-the-company) 🔒 | [MySQL](problems/employees-whose-manager-left-the-company) | Easy | +| 1978 | [Employees Whose Manager Left the Company](https://leetcode.com/problems/employees-whose-manager-left-the-company "上级经理已离职的公司员工") 🔒 | [MySQL](problems/employees-whose-manager-left-the-company) | Easy | | 1977 | [Number of Ways to Separate Numbers](https://leetcode.com/problems/number-of-ways-to-separate-numbers "划分数字的方案数") | [Go](problems/number-of-ways-to-separate-numbers) | Hard | | 1976 | [Number of Ways to Arrive at Destination](https://leetcode.com/problems/number-of-ways-to-arrive-at-destination "到达目的地的方案数") | [Go](problems/number-of-ways-to-arrive-at-destination) | Medium | | 1975 | [Maximum Matrix Sum](https://leetcode.com/problems/maximum-matrix-sum "最大方阵和") | [Go](problems/maximum-matrix-sum) | Medium | | 1974 | [Minimum Time to Type Word Using Special Typewriter](https://leetcode.com/problems/minimum-time-to-type-word-using-special-typewriter "使用特殊打字机键入单词的最少时间") | [Go](problems/minimum-time-to-type-word-using-special-typewriter) | Easy | -| 1973 | [Count Nodes Equal to Sum of Descendants](https://leetcode.com/problems/count-nodes-equal-to-sum-of-descendants) 🔒 | [Go](problems/count-nodes-equal-to-sum-of-descendants) | Medium | -| 1972 | [First and Last Call On the Same Day](https://leetcode.com/problems/first-and-last-call-on-the-same-day) 🔒 | [MySQL](problems/first-and-last-call-on-the-same-day) | Hard | +| 1973 | [Count Nodes Equal to Sum of Descendants](https://leetcode.com/problems/count-nodes-equal-to-sum-of-descendants "值等于子节点值之和的节点数量") 🔒 | [Go](problems/count-nodes-equal-to-sum-of-descendants) | Medium | +| 1972 | [First and Last Call On the Same Day](https://leetcode.com/problems/first-and-last-call-on-the-same-day "同一天的第一个电话和最后一个电话") 🔒 | [MySQL](problems/first-and-last-call-on-the-same-day) | Hard | | 1971 | [Find if Path Exists in Graph](https://leetcode.com/problems/find-if-path-exists-in-graph "寻找图中是否存在路径") | [Go](problems/find-if-path-exists-in-graph) | Easy | | 1970 | [Last Day Where You Can Still Cross](https://leetcode.com/problems/last-day-where-you-can-still-cross "你能穿过矩阵的最后一天") | [Go](problems/last-day-where-you-can-still-cross) | Hard | | 1969 | [Minimum Non-Zero Product of the Array Elements](https://leetcode.com/problems/minimum-non-zero-product-of-the-array-elements "数组元素的最小非零乘积") | [Go](problems/minimum-non-zero-product-of-the-array-elements) | Medium | | 1968 | [Array With Elements Not Equal to Average of Neighbors](https://leetcode.com/problems/array-with-elements-not-equal-to-average-of-neighbors "构造元素不等于两相邻元素平均值的数组") | [Go](problems/array-with-elements-not-equal-to-average-of-neighbors) | Medium | | 1967 | [Number of Strings That Appear as Substrings in Word](https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word "作为子字符串出现在单词中的字符串数目") | [Go](problems/number-of-strings-that-appear-as-substrings-in-word) | Easy | -| 1966 | [Binary Searchable Numbers in an Unsorted Array](https://leetcode.com/problems/binary-searchable-numbers-in-an-unsorted-array) 🔒 | [Go](problems/binary-searchable-numbers-in-an-unsorted-array) | Medium | +| 1966 | [Binary Searchable Numbers in an Unsorted Array](https://leetcode.com/problems/binary-searchable-numbers-in-an-unsorted-array "未排序数组中的可被二分搜索的数") 🔒 | [Go](problems/binary-searchable-numbers-in-an-unsorted-array) | Medium | | 1965 | [Employees With Missing Information](https://leetcode.com/problems/employees-with-missing-information "丢失信息的雇员") 🔒 | [MySQL](problems/employees-with-missing-information) | Easy | | 1964 | [Find the Longest Valid Obstacle Course at Each Position](https://leetcode.com/problems/find-the-longest-valid-obstacle-course-at-each-position "找出到每个位置为止最长的有效障碍赛跑路线") | [Go](problems/find-the-longest-valid-obstacle-course-at-each-position) | Hard | | 1963 | [Minimum Number of Swaps to Make the String Balanced](https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-string-balanced "使字符串平衡的最小交换次数") | [Go](problems/minimum-number-of-swaps-to-make-the-string-balanced) | Medium | @@ -213,7 +310,7 @@ LeetCode Problems' Solutions | 1952 | [Three Divisors](https://leetcode.com/problems/three-divisors "三除数") | [Go](problems/three-divisors) | Easy | | 1951 | [All the Pairs With the Maximum Number of Common Followers](https://leetcode.com/problems/all-the-pairs-with-the-maximum-number-of-common-followers "查询具有最多共同关注者的所有两两结对组") 🔒 | [MySQL](problems/all-the-pairs-with-the-maximum-number-of-common-followers) | Medium | | 1950 | [Maximum of Minimum Values in All Subarrays](https://leetcode.com/problems/maximum-of-minimum-values-in-all-subarrays "所有子数组最小值中的最大值") 🔒 | [Go](problems/maximum-of-minimum-values-in-all-subarrays) | Medium | -| 1949 | [Strong Friendship](https://leetcode.com/problems/strong-friendship) 🔒 | [MySQL](problems/strong-friendship) | Medium | +| 1949 | [Strong Friendship](https://leetcode.com/problems/strong-friendship "坚定的友谊") 🔒 | [MySQL](problems/strong-friendship) | Medium | | 1948 | [Delete Duplicate Folders in System](https://leetcode.com/problems/delete-duplicate-folders-in-system "删除系统中的重复文件夹") | [Go](problems/delete-duplicate-folders-in-system) | Hard | | 1947 | [Maximum Compatibility Score Sum](https://leetcode.com/problems/maximum-compatibility-score-sum "最大兼容性评分和") | [Go](problems/maximum-compatibility-score-sum) | Medium | | 1946 | [Largest Number After Mutating Substring](https://leetcode.com/problems/largest-number-after-mutating-substring "子字符串突变后可能得到的最大整数") | [Go](problems/largest-number-after-mutating-substring) | Medium | @@ -223,7 +320,7 @@ LeetCode Problems' Solutions | 1942 | [The Number of the Smallest Unoccupied Chair](https://leetcode.com/problems/the-number-of-the-smallest-unoccupied-chair "最小未被占据椅子的编号") | [Go](problems/the-number-of-the-smallest-unoccupied-chair) | Medium | | 1941 | [Check if All Characters Have Equal Number of Occurrences](https://leetcode.com/problems/check-if-all-characters-have-equal-number-of-occurrences "检查是否所有字符出现次数相同") | [Go](problems/check-if-all-characters-have-equal-number-of-occurrences) | Easy | | 1940 | [Longest Common Subsequence Between Sorted Arrays](https://leetcode.com/problems/longest-common-subsequence-between-sorted-arrays "排序数组之间的最长公共子序列") 🔒 | [Go](problems/longest-common-subsequence-between-sorted-arrays) | Medium | -| 1939 | [Users That Actively Request Confirmation Messages](https://leetcode.com/problems/users-that-actively-request-confirmation-messages) 🔒 | [MySQL](problems/users-that-actively-request-confirmation-messages) | Easy | +| 1939 | [Users That Actively Request Confirmation Messages](https://leetcode.com/problems/users-that-actively-request-confirmation-messages "主动请求确认消息的用户") 🔒 | [MySQL](problems/users-that-actively-request-confirmation-messages) | Easy | | 1938 | [Maximum Genetic Difference Query](https://leetcode.com/problems/maximum-genetic-difference-query "查询最大基因差") | [Go](problems/maximum-genetic-difference-query) | Hard | | 1937 | [Maximum Number of Points with Cost](https://leetcode.com/problems/maximum-number-of-points-with-cost "扣分后的最大得分") | [Go](problems/maximum-number-of-points-with-cost) | Medium | | 1936 | [Add Minimum Number of Rungs](https://leetcode.com/problems/add-minimum-number-of-rungs "新增的最少台阶数") | [Go](problems/add-minimum-number-of-rungs) | Medium | @@ -238,14 +335,14 @@ LeetCode Problems' Solutions | 1927 | [Sum Game](https://leetcode.com/problems/sum-game "求和游戏") | [Go](problems/sum-game) | Medium | | 1926 | [Nearest Exit from Entrance in Maze](https://leetcode.com/problems/nearest-exit-from-entrance-in-maze "迷宫中离入口最近的出口") | [Go](problems/nearest-exit-from-entrance-in-maze) | Medium | | 1925 | [Count Square Sum Triples](https://leetcode.com/problems/count-square-sum-triples "统计平方和三元组的数目") | [Go](problems/count-square-sum-triples) | Easy | -| 1924 | [Erect the Fence II](https://leetcode.com/problems/erect-the-fence-ii) 🔒 | [Go](problems/erect-the-fence-ii) | Hard | +| 1924 | [Erect the Fence II](https://leetcode.com/problems/erect-the-fence-ii "安装栅栏 II") 🔒 | [Go](problems/erect-the-fence-ii) | Hard | | 1923 | [Longest Common Subpath](https://leetcode.com/problems/longest-common-subpath "最长公共子路径") | [Go](problems/longest-common-subpath) | Hard | | 1922 | [Count Good Numbers](https://leetcode.com/problems/count-good-numbers "统计好数字的数目") | [Go](problems/count-good-numbers) | Medium | | 1921 | [Eliminate Maximum Number of Monsters](https://leetcode.com/problems/eliminate-maximum-number-of-monsters "消灭怪物的最大数量") | [Go](problems/eliminate-maximum-number-of-monsters) | Medium | | 1920 | [Build Array from Permutation](https://leetcode.com/problems/build-array-from-permutation "基于排列构建数组") | [Go](problems/build-array-from-permutation) | Easy | | 1919 | [Leetcodify Similar Friends](https://leetcode.com/problems/leetcodify-similar-friends "兴趣相同的朋友") 🔒 | [MySQL](problems/leetcodify-similar-friends) | Hard | | 1918 | [Kth Smallest Subarray Sum](https://leetcode.com/problems/kth-smallest-subarray-sum "第 K 小的子数组和·") 🔒 | [Go](problems/kth-smallest-subarray-sum) | Medium | -| 1917 | [Leetcodify Friends Recommendations](https://leetcode.com/problems/leetcodify-friends-recommendations) 🔒 | [MySQL](problems/leetcodify-friends-recommendations) | Hard | +| 1917 | [Leetcodify Friends Recommendations](https://leetcode.com/problems/leetcodify-friends-recommendations "Leetcodify 好友推荐") 🔒 | [MySQL](problems/leetcodify-friends-recommendations) | Hard | | 1916 | [Count Ways to Build Rooms in an Ant Colony](https://leetcode.com/problems/count-ways-to-build-rooms-in-an-ant-colony "统计为蚁群构筑房间的不同顺序") | [Go](problems/count-ways-to-build-rooms-in-an-ant-colony) | Hard | | 1915 | [Number of Wonderful Substrings](https://leetcode.com/problems/number-of-wonderful-substrings "最美子字符串的数目") | [Go](problems/number-of-wonderful-substrings) | Medium | | 1914 | [Cyclically Rotating a Grid](https://leetcode.com/problems/cyclically-rotating-a-grid "循环轮转矩阵") | [Go](problems/cyclically-rotating-a-grid) | Medium | @@ -260,7 +357,7 @@ LeetCode Problems' Solutions | 1905 | [Count Sub Islands](https://leetcode.com/problems/count-sub-islands "统计子岛屿") | [Go](problems/count-sub-islands) | Medium | | 1904 | [The Number of Full Rounds You Have Played](https://leetcode.com/problems/the-number-of-full-rounds-you-have-played "你完成的完整对局数") | [Go](problems/the-number-of-full-rounds-you-have-played) | Medium | | 1903 | [Largest Odd Number in String](https://leetcode.com/problems/largest-odd-number-in-string "字符串中的最大奇数") | [Go](problems/largest-odd-number-in-string) | Easy | -| 1902 | [Depth of BST Given Insertion Order](https://leetcode.com/problems/depth-of-bst-given-insertion-order) 🔒 | [Go](problems/depth-of-bst-given-insertion-order) | Medium | +| 1902 | [Depth of BST Given Insertion Order](https://leetcode.com/problems/depth-of-bst-given-insertion-order "给定二叉搜索树的插入顺序求深度") 🔒 | [Go](problems/depth-of-bst-given-insertion-order) | Medium | | 1901 | [Find a Peak Element II](https://leetcode.com/problems/find-a-peak-element-ii "找出顶峰元素 II") | [Go](problems/find-a-peak-element-ii) | Medium | | 1900 | [The Earliest and Latest Rounds Where Players Compete](https://leetcode.com/problems/the-earliest-and-latest-rounds-where-players-compete "最佳运动员的比拼回合") | [Go](problems/the-earliest-and-latest-rounds-where-players-compete) | Hard | | 1899 | [Merge Triplets to Form Target Triplet](https://leetcode.com/problems/merge-triplets-to-form-target-triplet "合并若干三元组以形成目标三元组") | [Go](problems/merge-triplets-to-form-target-triplet) | Medium | @@ -277,7 +374,7 @@ LeetCode Problems' Solutions | 1888 | [Minimum Number of Flips to Make the Binary String Alternating](https://leetcode.com/problems/minimum-number-of-flips-to-make-the-binary-string-alternating "使二进制字符串字符交替的最少反转次数") | [Go](problems/minimum-number-of-flips-to-make-the-binary-string-alternating) | Medium | | 1887 | [Reduction Operations to Make the Array Elements Equal](https://leetcode.com/problems/reduction-operations-to-make-the-array-elements-equal "使数组元素相等的减少操作次数") | [Go](problems/reduction-operations-to-make-the-array-elements-equal) | Medium | | 1886 | [Determine Whether Matrix Can Be Obtained By Rotation](https://leetcode.com/problems/determine-whether-matrix-can-be-obtained-by-rotation "判断矩阵经轮转后是否一致") | [Go](problems/determine-whether-matrix-can-be-obtained-by-rotation) | Easy | -| 1885 | [Count Pairs in Two Arrays](https://leetcode.com/problems/count-pairs-in-two-arrays) 🔒 | [Go](problems/count-pairs-in-two-arrays) | Medium | +| 1885 | [Count Pairs in Two Arrays](https://leetcode.com/problems/count-pairs-in-two-arrays "统计数对") 🔒 | [Go](problems/count-pairs-in-two-arrays) | Medium | | 1884 | [Egg Drop With 2 Eggs and N Floors](https://leetcode.com/problems/egg-drop-with-2-eggs-and-n-floors "鸡蛋掉落-两枚鸡蛋") | [Go](problems/egg-drop-with-2-eggs-and-n-floors) | Medium | | 1883 | [Minimum Skips to Arrive at Meeting On Time](https://leetcode.com/problems/minimum-skips-to-arrive-at-meeting-on-time "准时抵达会议现场的最小跳过休息次数") | [Go](problems/minimum-skips-to-arrive-at-meeting-on-time) | Hard | | 1882 | [Process Tasks Using Servers](https://leetcode.com/problems/process-tasks-using-servers "使用服务器处理任务") | [Go](problems/process-tasks-using-servers) | Medium | @@ -287,7 +384,7 @@ LeetCode Problems' Solutions | 1878 | [Get Biggest Three Rhombus Sums in a Grid](https://leetcode.com/problems/get-biggest-three-rhombus-sums-in-a-grid "矩阵中最大的三个菱形和") | [Go](problems/get-biggest-three-rhombus-sums-in-a-grid) | Medium | | 1877 | [Minimize Maximum Pair Sum in Array](https://leetcode.com/problems/minimize-maximum-pair-sum-in-array "数组中最大数对和的最小值") | [Go](problems/minimize-maximum-pair-sum-in-array) | Medium | | 1876 | [Substrings of Size Three with Distinct Characters](https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters "长度为三且各字符不同的子字符串") | [Go](problems/substrings-of-size-three-with-distinct-characters) | Easy | -| 1875 | [Group Employees of the Same Salary](https://leetcode.com/problems/group-employees-of-the-same-salary) 🔒 | [MySQL](problems/group-employees-of-the-same-salary) | Medium | +| 1875 | [Group Employees of the Same Salary](https://leetcode.com/problems/group-employees-of-the-same-salary "将工资相同的雇员分组") 🔒 | [MySQL](problems/group-employees-of-the-same-salary) | Medium | | 1874 | [Minimize Product Sum of Two Arrays](https://leetcode.com/problems/minimize-product-sum-of-two-arrays "两个数组的最小乘积和") 🔒 | [Go](problems/minimize-product-sum-of-two-arrays) | Medium | | 1873 | [Calculate Special Bonus](https://leetcode.com/problems/calculate-special-bonus "计算特殊奖金") 🔒 | [MySQL](problems/calculate-special-bonus) | Easy | | 1872 | [Stone Game VIII](https://leetcode.com/problems/stone-game-viii "石子游戏 VIII") | [Go](problems/stone-game-viii) | Hard | @@ -295,7 +392,7 @@ LeetCode Problems' Solutions | 1870 | [Minimum Speed to Arrive on Time](https://leetcode.com/problems/minimum-speed-to-arrive-on-time "准时到达的列车最小时速") | [Go](problems/minimum-speed-to-arrive-on-time) | Medium | | 1869 | [Longer Contiguous Segments of Ones than Zeros](https://leetcode.com/problems/longer-contiguous-segments-of-ones-than-zeros "哪种连续子字符串更长") | [Go](problems/longer-contiguous-segments-of-ones-than-zeros) | Easy | | 1868 | [Product of Two Run-Length Encoded Arrays](https://leetcode.com/problems/product-of-two-run-length-encoded-arrays "两个行程编码数组的积") 🔒 | [Go](problems/product-of-two-run-length-encoded-arrays) | Medium | -| 1867 | [Orders With Maximum Quantity Above Average](https://leetcode.com/problems/orders-with-maximum-quantity-above-average) 🔒 | [MySQL](problems/orders-with-maximum-quantity-above-average) | Medium | +| 1867 | [Orders With Maximum Quantity Above Average](https://leetcode.com/problems/orders-with-maximum-quantity-above-average "最大数量高于平均水平的订单") 🔒 | [MySQL](problems/orders-with-maximum-quantity-above-average) | Medium | | 1866 | [Number of Ways to Rearrange Sticks With K Sticks Visible](https://leetcode.com/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible "恰有 K 根木棍可以看到的排列数目") | [Go](problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible) | Hard | | 1865 | [Finding Pairs With a Certain Sum](https://leetcode.com/problems/finding-pairs-with-a-certain-sum "找出和为指定值的下标对") | [Go](problems/finding-pairs-with-a-certain-sum) | Medium | | 1864 | [Minimum Number of Swaps to Make the Binary String Alternating](https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating "构成交替字符串需要的最小交换次数") | [Go](problems/minimum-number-of-swaps-to-make-the-binary-string-alternating) | Medium | @@ -319,7 +416,7 @@ LeetCode Problems' Solutions | 1846 | [Maximum Element After Decreasing and Rearranging](https://leetcode.com/problems/maximum-element-after-decreasing-and-rearranging "减小和重新排列数组后的最大元素") | [Go](problems/maximum-element-after-decreasing-and-rearranging) | Medium | | 1845 | [Seat Reservation Manager](https://leetcode.com/problems/seat-reservation-manager "座位预约管理系统") | [Go](problems/seat-reservation-manager) | Medium | | 1844 | [Replace All Digits with Characters](https://leetcode.com/problems/replace-all-digits-with-characters "将所有数字用字符替换") | [Go](problems/replace-all-digits-with-characters) | Easy | -| 1843 | [Suspicious Bank Accounts](https://leetcode.com/problems/suspicious-bank-accounts) 🔒 | [MySQL](problems/suspicious-bank-accounts) | Medium | +| 1843 | [Suspicious Bank Accounts](https://leetcode.com/problems/suspicious-bank-accounts "可疑银行账户") 🔒 | [MySQL](problems/suspicious-bank-accounts) | Medium | | 1842 | [Next Palindrome Using Same Digits](https://leetcode.com/problems/next-palindrome-using-same-digits "下个由相同数字构成的回文串") 🔒 | [Go](problems/next-palindrome-using-same-digits) | Hard | | 1841 | [League Statistics](https://leetcode.com/problems/league-statistics "联赛信息统计") 🔒 | [MySQL](problems/league-statistics) | Medium | | 1840 | [Maximum Building Height](https://leetcode.com/problems/maximum-building-height "最高建筑高度") | [Go](problems/maximum-building-height) | Hard | @@ -362,303 +459,3 @@ LeetCode Problems' Solutions | 1803 | [Count Pairs With XOR in a Range](https://leetcode.com/problems/count-pairs-with-xor-in-a-range "统计异或值在范围内的数对有多少") | [Go](problems/count-pairs-with-xor-in-a-range) | Hard | | 1802 | [Maximum Value at a Given Index in a Bounded Array](https://leetcode.com/problems/maximum-value-at-a-given-index-in-a-bounded-array "有界数组中指定下标处的最大值") | [Go](problems/maximum-value-at-a-given-index-in-a-bounded-array) | Medium | | 1801 | [Number of Orders in the Backlog](https://leetcode.com/problems/number-of-orders-in-the-backlog "积压订单中的订单总数") | [Go](problems/number-of-orders-in-the-backlog) | Medium | -| 1800 | [Maximum Ascending Subarray Sum](https://leetcode.com/problems/maximum-ascending-subarray-sum "最大升序子数组和") | [Go](problems/maximum-ascending-subarray-sum) | Easy | -| 1799 | [Maximize Score After N Operations](https://leetcode.com/problems/maximize-score-after-n-operations "N 次操作后的最大分数和") | [Go](problems/maximize-score-after-n-operations) | Hard | -| 1798 | [Maximum Number of Consecutive Values You Can Make](https://leetcode.com/problems/maximum-number-of-consecutive-values-you-can-make "你能构造出连续值的最大数目") | [Go](problems/maximum-number-of-consecutive-values-you-can-make) | Medium | -| 1797 | [Design Authentication Manager](https://leetcode.com/problems/design-authentication-manager "设计一个验证系统") | [Go](problems/design-authentication-manager) | Medium | -| 1796 | [Second Largest Digit in a String](https://leetcode.com/problems/second-largest-digit-in-a-string "字符串中第二大的数字") | [Go](problems/second-largest-digit-in-a-string) | Easy | -| 1795 | [Rearrange Products Table](https://leetcode.com/problems/rearrange-products-table "每个产品在不同商店的价格") 🔒 | [MySQL](problems/rearrange-products-table) | Easy | -| 1794 | [Count Pairs of Equal Substrings With Minimum Difference](https://leetcode.com/problems/count-pairs-of-equal-substrings-with-minimum-difference "统计距离最小的子串对个数") 🔒 | [Go](problems/count-pairs-of-equal-substrings-with-minimum-difference) | Medium | -| 1793 | [Maximum Score of a Good Subarray](https://leetcode.com/problems/maximum-score-of-a-good-subarray "好子数组的最大分数") | [Go](problems/maximum-score-of-a-good-subarray) | Hard | -| 1792 | [Maximum Average Pass Ratio](https://leetcode.com/problems/maximum-average-pass-ratio "最大平均通过率") | [Go](problems/maximum-average-pass-ratio) | Medium | -| 1791 | [Find Center of Star Graph](https://leetcode.com/problems/find-center-of-star-graph "找出星型图的中心节点") | [Go](problems/find-center-of-star-graph) | Easy | -| 1790 | [Check if One String Swap Can Make Strings Equal](https://leetcode.com/problems/check-if-one-string-swap-can-make-strings-equal "仅执行一次字符串交换能否使两个字符串相等") | [Go](problems/check-if-one-string-swap-can-make-strings-equal) | Easy | -| 1789 | [Primary Department for Each Employee](https://leetcode.com/problems/primary-department-for-each-employee "员工的直属部门") 🔒 | [MySQL](problems/primary-department-for-each-employee) | Easy | -| 1788 | [Maximize the Beauty of the Garden](https://leetcode.com/problems/maximize-the-beauty-of-the-garden "最大化花园的美观度") 🔒 | [Go](problems/maximize-the-beauty-of-the-garden) | Hard | -| 1787 | [Make the XOR of All Segments Equal to Zero](https://leetcode.com/problems/make-the-xor-of-all-segments-equal-to-zero "使所有区间的异或结果为零") | [Go](problems/make-the-xor-of-all-segments-equal-to-zero) | Hard | -| 1786 | [Number of Restricted Paths From First to Last Node](https://leetcode.com/problems/number-of-restricted-paths-from-first-to-last-node "从第一个节点出发到最后一个节点的受限路径数") | [Go](problems/number-of-restricted-paths-from-first-to-last-node) | Medium | -| 1785 | [Minimum Elements to Add to Form a Given Sum](https://leetcode.com/problems/minimum-elements-to-add-to-form-a-given-sum "构成特定和需要添加的最少元素") | [Go](problems/minimum-elements-to-add-to-form-a-given-sum) | Medium | -| 1784 | [Check if Binary String Has at Most One Segment of Ones](https://leetcode.com/problems/check-if-binary-string-has-at-most-one-segment-of-ones "检查二进制字符串字段") | [Go](problems/check-if-binary-string-has-at-most-one-segment-of-ones) | Easy | -| 1783 | [Grand Slam Titles](https://leetcode.com/problems/grand-slam-titles "大满贯数量") 🔒 | [MySQL](problems/grand-slam-titles) | Medium | -| 1782 | [Count Pairs Of Nodes](https://leetcode.com/problems/count-pairs-of-nodes "统计点对的数目") | [Go](problems/count-pairs-of-nodes) | Hard | -| 1781 | [Sum of Beauty of All Substrings](https://leetcode.com/problems/sum-of-beauty-of-all-substrings "所有子字符串美丽值之和") | [Go](problems/sum-of-beauty-of-all-substrings) | Medium | -| 1780 | [Check if Number is a Sum of Powers of Three](https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three "判断一个数字是否可以表示成三的幂的和") | [Go](problems/check-if-number-is-a-sum-of-powers-of-three) | Medium | -| 1779 | [Find Nearest Point That Has the Same X or Y Coordinate](https://leetcode.com/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate "找到最近的有相同 X 或 Y 坐标的点") | [Go](problems/find-nearest-point-that-has-the-same-x-or-y-coordinate) | Easy | -| 1778 | [Shortest Path in a Hidden Grid](https://leetcode.com/problems/shortest-path-in-a-hidden-grid "未知网格中的最短路径") 🔒 | [Go](problems/shortest-path-in-a-hidden-grid) | Medium | -| 1777 | [Product's Price for Each Store](https://leetcode.com/problems/products-price-for-each-store "每家商店的产品价格") 🔒 | [MySQL](problems/products-price-for-each-store) | Easy | -| 1776 | [Car Fleet II](https://leetcode.com/problems/car-fleet-ii "车队 II") | [Go](problems/car-fleet-ii) | Hard | -| 1775 | [Equal Sum Arrays With Minimum Number of Operations](https://leetcode.com/problems/equal-sum-arrays-with-minimum-number-of-operations "通过最少操作次数使数组的和相等") | [Go](problems/equal-sum-arrays-with-minimum-number-of-operations) | Medium | -| 1774 | [Closest Dessert Cost](https://leetcode.com/problems/closest-dessert-cost "最接近目标价格的甜点成本") | [Go](problems/closest-dessert-cost) | Medium | -| 1773 | [Count Items Matching a Rule](https://leetcode.com/problems/count-items-matching-a-rule "统计匹配检索规则的物品数量") | [Go](problems/count-items-matching-a-rule) | Easy | -| 1772 | [Sort Features by Popularity](https://leetcode.com/problems/sort-features-by-popularity "按受欢迎程度排列功能") 🔒 | [Go](problems/sort-features-by-popularity) | Medium | -| 1771 | [Maximize Palindrome Length From Subsequences](https://leetcode.com/problems/maximize-palindrome-length-from-subsequences "由子序列构造的最长回文串的长度") | [Go](problems/maximize-palindrome-length-from-subsequences) | Hard | -| 1770 | [Maximum Score from Performing Multiplication Operations](https://leetcode.com/problems/maximum-score-from-performing-multiplication-operations "执行乘法运算的最大分数") | [Go](problems/maximum-score-from-performing-multiplication-operations) | Medium | -| 1769 | [Minimum Number of Operations to Move All Balls to Each Box](https://leetcode.com/problems/minimum-number-of-operations-to-move-all-balls-to-each-box "移动所有球到每个盒子所需的最小操作数") | [Go](problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | Medium | -| 1768 | [Merge Strings Alternately](https://leetcode.com/problems/merge-strings-alternately "交替合并字符串") | [Go](problems/merge-strings-alternately) | Easy | -| 1767 | [Find the Subtasks That Did Not Execute](https://leetcode.com/problems/find-the-subtasks-that-did-not-execute "寻找没有被执行的任务对") 🔒 | [MySQL](problems/find-the-subtasks-that-did-not-execute) | Hard | -| 1766 | [Tree of Coprimes](https://leetcode.com/problems/tree-of-coprimes "互质树") | [Go](problems/tree-of-coprimes) | Hard | -| 1765 | [Map of Highest Peak](https://leetcode.com/problems/map-of-highest-peak "地图中的最高点") | [Go](problems/map-of-highest-peak) | Medium | -| 1764 | [Form Array by Concatenating Subarrays of Another Array](https://leetcode.com/problems/form-array-by-concatenating-subarrays-of-another-array "通过连接另一个数组的子数组得到一个数组") | [Go](problems/form-array-by-concatenating-subarrays-of-another-array) | Medium | -| 1763 | [Longest Nice Substring](https://leetcode.com/problems/longest-nice-substring "最长的美好子字符串") | [Go](problems/longest-nice-substring) | Easy | -| 1762 | [Buildings With an Ocean View](https://leetcode.com/problems/buildings-with-an-ocean-view "能看到海景的建筑物") 🔒 | [Go](problems/buildings-with-an-ocean-view) | Medium | -| 1761 | [Minimum Degree of a Connected Trio in a Graph](https://leetcode.com/problems/minimum-degree-of-a-connected-trio-in-a-graph "一个图中连通三元组的最小度数") | [Go](problems/minimum-degree-of-a-connected-trio-in-a-graph) | Hard | -| 1760 | [Minimum Limit of Balls in a Bag](https://leetcode.com/problems/minimum-limit-of-balls-in-a-bag "袋子里最少数目的球") | [Go](problems/minimum-limit-of-balls-in-a-bag) | Medium | -| 1759 | [Count Number of Homogenous Substrings](https://leetcode.com/problems/count-number-of-homogenous-substrings "统计同构子字符串的数目") | [Go](problems/count-number-of-homogenous-substrings) | Medium | -| 1758 | [Minimum Changes To Make Alternating Binary String](https://leetcode.com/problems/minimum-changes-to-make-alternating-binary-string "生成交替二进制字符串的最少操作数") | [Go](problems/minimum-changes-to-make-alternating-binary-string) | Easy | -| 1757 | [Recyclable and Low Fat Products](https://leetcode.com/problems/recyclable-and-low-fat-products "可回收且低脂的产品") 🔒 | [MySQL](problems/recyclable-and-low-fat-products) | Easy | -| 1756 | [Design Most Recently Used Queue](https://leetcode.com/problems/design-most-recently-used-queue "设计最近使用(MRU)队列") 🔒 | [Go](problems/design-most-recently-used-queue) | Medium | -| 1755 | [Closest Subsequence Sum](https://leetcode.com/problems/closest-subsequence-sum "最接近目标值的子序列和") | [Go](problems/closest-subsequence-sum) | Hard | -| 1754 | [Largest Merge Of Two Strings](https://leetcode.com/problems/largest-merge-of-two-strings "构造字典序最大的合并字符串") | [Go](problems/largest-merge-of-two-strings) | Medium | -| 1753 | [Maximum Score From Removing Stones](https://leetcode.com/problems/maximum-score-from-removing-stones "移除石子的最大得分") | [Go](problems/maximum-score-from-removing-stones) | Medium | -| 1752 | [Check if Array Is Sorted and Rotated](https://leetcode.com/problems/check-if-array-is-sorted-and-rotated "检查数组是否经排序和轮转得到") | [Go](problems/check-if-array-is-sorted-and-rotated) | Easy | -| 1751 | [Maximum Number of Events That Can Be Attended II](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended-ii "最多可以参加的会议数目 II") | [Go](problems/maximum-number-of-events-that-can-be-attended-ii) | Hard | -| 1750 | [Minimum Length of String After Deleting Similar Ends](https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends "删除字符串两端相同字符后的最短长度") | [Go](problems/minimum-length-of-string-after-deleting-similar-ends) | Medium | -| 1749 | [Maximum Absolute Sum of Any Subarray](https://leetcode.com/problems/maximum-absolute-sum-of-any-subarray "任意子数组和的绝对值的最大值") | [Go](problems/maximum-absolute-sum-of-any-subarray) | Medium | -| 1748 | [Sum of Unique Elements](https://leetcode.com/problems/sum-of-unique-elements "唯一元素的和") | [Go](problems/sum-of-unique-elements) | Easy | -| 1747 | [Leetflex Banned Accounts](https://leetcode.com/problems/leetflex-banned-accounts "应该被禁止的Leetflex账户") 🔒 | [MySQL](problems/leetflex-banned-accounts) | Medium | -| 1746 | [Maximum Subarray Sum After One Operation](https://leetcode.com/problems/maximum-subarray-sum-after-one-operation "经过一次操作后的最大子数组和") 🔒 | [Go](problems/maximum-subarray-sum-after-one-operation) | Medium | -| 1745 | [Palindrome Partitioning IV](https://leetcode.com/problems/palindrome-partitioning-iv "回文串分割 IV") | [Go](problems/palindrome-partitioning-iv) | Hard | -| 1744 | [Can You Eat Your Favorite Candy on Your Favorite Day?](https://leetcode.com/problems/can-you-eat-your-favorite-candy-on-your-favorite-day "你能在你最喜欢的那天吃到你最喜欢的糖果吗?") | [Go](problems/can-you-eat-your-favorite-candy-on-your-favorite-day) | Medium | -| 1743 | [Restore the Array From Adjacent Pairs](https://leetcode.com/problems/restore-the-array-from-adjacent-pairs "从相邻元素对还原数组") | [Go](problems/restore-the-array-from-adjacent-pairs) | Medium | -| 1742 | [Maximum Number of Balls in a Box](https://leetcode.com/problems/maximum-number-of-balls-in-a-box "盒子中小球的最大数量") | [Go](problems/maximum-number-of-balls-in-a-box) | Easy | -| 1741 | [Find Total Time Spent by Each Employee](https://leetcode.com/problems/find-total-time-spent-by-each-employee "查找每个员工花费的总时间") 🔒 | [MySQL](problems/find-total-time-spent-by-each-employee) | Easy | -| 1740 | [Find Distance in a Binary Tree](https://leetcode.com/problems/find-distance-in-a-binary-tree "找到二叉树中的距离") 🔒 | [Go](problems/find-distance-in-a-binary-tree) | Medium | -| 1739 | [Building Boxes](https://leetcode.com/problems/building-boxes "放置盒子") | [Go](problems/building-boxes) | Hard | -| 1738 | [Find Kth Largest XOR Coordinate Value](https://leetcode.com/problems/find-kth-largest-xor-coordinate-value "找出第 K 大的异或坐标值") | [Go](problems/find-kth-largest-xor-coordinate-value) | Medium | -| 1737 | [Change Minimum Characters to Satisfy One of Three Conditions](https://leetcode.com/problems/change-minimum-characters-to-satisfy-one-of-three-conditions "满足三条件之一需改变的最少字符数") | [Go](problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | Medium | -| 1736 | [Latest Time by Replacing Hidden Digits](https://leetcode.com/problems/latest-time-by-replacing-hidden-digits "替换隐藏数字得到的最晚时间") | [Go](problems/latest-time-by-replacing-hidden-digits) | Easy | -| 1735 | [Count Ways to Make Array With Product](https://leetcode.com/problems/count-ways-to-make-array-with-product "生成乘积数组的方案数") | [Go](problems/count-ways-to-make-array-with-product) | Hard | -| 1734 | [Decode XORed Permutation](https://leetcode.com/problems/decode-xored-permutation "解码异或后的排列") | [Go](problems/decode-xored-permutation) | Medium | -| 1733 | [Minimum Number of People to Teach](https://leetcode.com/problems/minimum-number-of-people-to-teach "需要教语言的最少人数") | [Go](problems/minimum-number-of-people-to-teach) | Medium | -| 1732 | [Find the Highest Altitude](https://leetcode.com/problems/find-the-highest-altitude "找到最高海拔") | [Go](problems/find-the-highest-altitude) | Easy | -| 1731 | [The Number of Employees Which Report to Each Employee](https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee "每位经理的下属员工数量") 🔒 | [MySQL](problems/the-number-of-employees-which-report-to-each-employee) | Easy | -| 1730 | [Shortest Path to Get Food](https://leetcode.com/problems/shortest-path-to-get-food "获取食物的最短路径") 🔒 | [Go](problems/shortest-path-to-get-food) | Medium | -| 1729 | [Find Followers Count](https://leetcode.com/problems/find-followers-count "求关注者的数量") 🔒 | [MySQL](problems/find-followers-count) | Easy | -| 1728 | [Cat and Mouse II](https://leetcode.com/problems/cat-and-mouse-ii "猫和老鼠 II") | [Go](problems/cat-and-mouse-ii) | Hard | -| 1727 | [Largest Submatrix With Rearrangements](https://leetcode.com/problems/largest-submatrix-with-rearrangements "重新排列后的最大子矩阵") | [Go](problems/largest-submatrix-with-rearrangements) | Medium | -| 1726 | [Tuple with Same Product](https://leetcode.com/problems/tuple-with-same-product "同积元组") | [Go](problems/tuple-with-same-product) | Medium | -| 1725 | [Number Of Rectangles That Can Form The Largest Square](https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square "可以形成最大正方形的矩形数目") | [Go](problems/number-of-rectangles-that-can-form-the-largest-square) | Easy | -| 1724 | [Checking Existence of Edge Length Limited Paths II](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths-ii "检查边长度限制的路径是否存在 II") 🔒 | [Go](problems/checking-existence-of-edge-length-limited-paths-ii) | Hard | -| 1723 | [Find Minimum Time to Finish All Jobs](https://leetcode.com/problems/find-minimum-time-to-finish-all-jobs "完成所有工作的最短时间") | [Go](problems/find-minimum-time-to-finish-all-jobs) | Hard | -| 1722 | [Minimize Hamming Distance After Swap Operations](https://leetcode.com/problems/minimize-hamming-distance-after-swap-operations "执行交换操作后的最小汉明距离") | [Go](problems/minimize-hamming-distance-after-swap-operations) | Medium | -| 1721 | [Swapping Nodes in a Linked List](https://leetcode.com/problems/swapping-nodes-in-a-linked-list "交换链表中的节点") | [Go](problems/swapping-nodes-in-a-linked-list) | Medium | -| 1720 | [Decode XORed Array](https://leetcode.com/problems/decode-xored-array "解码异或后的数组") | [Go](problems/decode-xored-array) | Easy | -| 1719 | [Number Of Ways To Reconstruct A Tree](https://leetcode.com/problems/number-of-ways-to-reconstruct-a-tree "重构一棵树的方案数") | [Go](problems/number-of-ways-to-reconstruct-a-tree) | Hard | -| 1718 | [Construct the Lexicographically Largest Valid Sequence](https://leetcode.com/problems/construct-the-lexicographically-largest-valid-sequence "构建字典序最大的可行序列") | [Go](problems/construct-the-lexicographically-largest-valid-sequence) | Medium | -| 1717 | [Maximum Score From Removing Substrings](https://leetcode.com/problems/maximum-score-from-removing-substrings "删除子字符串的最大得分") | [Go](problems/maximum-score-from-removing-substrings) | Medium | -| 1716 | [Calculate Money in Leetcode Bank](https://leetcode.com/problems/calculate-money-in-leetcode-bank "计算力扣银行的钱") | [Go](problems/calculate-money-in-leetcode-bank) | Easy | -| 1715 | [Count Apples and Oranges](https://leetcode.com/problems/count-apples-and-oranges "苹果和橘子的个数") 🔒 | [MySQL](problems/count-apples-and-oranges) | Medium | -| 1714 | [Sum Of Special Evenly-Spaced Elements In Array](https://leetcode.com/problems/sum-of-special-evenly-spaced-elements-in-array "数组中特殊等间距元素的和") 🔒 | [Go](problems/sum-of-special-evenly-spaced-elements-in-array) | Hard | -| 1713 | [Minimum Operations to Make a Subsequence](https://leetcode.com/problems/minimum-operations-to-make-a-subsequence "得到子序列的最少操作次数") | [Go](problems/minimum-operations-to-make-a-subsequence) | Hard | -| 1712 | [Ways to Split Array Into Three Subarrays](https://leetcode.com/problems/ways-to-split-array-into-three-subarrays "将数组分成三个子数组的方案数") | [Go](problems/ways-to-split-array-into-three-subarrays) | Medium | -| 1711 | [Count Good Meals](https://leetcode.com/problems/count-good-meals "大餐计数") | [Go](problems/count-good-meals) | Medium | -| 1710 | [Maximum Units on a Truck](https://leetcode.com/problems/maximum-units-on-a-truck "卡车上的最大单元数") | [Go](problems/maximum-units-on-a-truck) | Easy | -| 1709 | [Biggest Window Between Visits](https://leetcode.com/problems/biggest-window-between-visits "访问日期之间最大的空档期") 🔒 | [MySQL](problems/biggest-window-between-visits) | Medium | -| 1708 | [Largest Subarray Length K](https://leetcode.com/problems/largest-subarray-length-k "长度为 K 的最大子数组") 🔒 | [Go](problems/largest-subarray-length-k) | Easy | -| 1707 | [Maximum XOR With an Element From Array](https://leetcode.com/problems/maximum-xor-with-an-element-from-array "与数组中元素的最大异或值") | [Go](problems/maximum-xor-with-an-element-from-array) | Hard | -| 1706 | [Where Will the Ball Fall](https://leetcode.com/problems/where-will-the-ball-fall "球会落何处") | [Go](problems/where-will-the-ball-fall) | Medium | -| 1705 | [Maximum Number of Eaten Apples](https://leetcode.com/problems/maximum-number-of-eaten-apples "吃苹果的最大数目") | [Go](problems/maximum-number-of-eaten-apples) | Medium | -| 1704 | [Determine if String Halves Are Alike](https://leetcode.com/problems/determine-if-string-halves-are-alike "判断字符串的两半是否相似") | [Go](problems/determine-if-string-halves-are-alike) | Easy | -| 1703 | [Minimum Adjacent Swaps for K Consecutive Ones](https://leetcode.com/problems/minimum-adjacent-swaps-for-k-consecutive-ones "得到连续 K 个 1 的最少相邻交换次数") | [Go](problems/minimum-adjacent-swaps-for-k-consecutive-ones) | Hard | -| 1702 | [Maximum Binary String After Change](https://leetcode.com/problems/maximum-binary-string-after-change "修改后的最大二进制字符串") | [Go](problems/maximum-binary-string-after-change) | Medium | -| 1701 | [Average Waiting Time](https://leetcode.com/problems/average-waiting-time "平均等待时间") | [Go](problems/average-waiting-time) | Medium | -| 1700 | [Number of Students Unable to Eat Lunch](https://leetcode.com/problems/number-of-students-unable-to-eat-lunch "无法吃午餐的学生数量") | [Go](problems/number-of-students-unable-to-eat-lunch) | Easy | -| 1699 | [Number of Calls Between Two Persons](https://leetcode.com/problems/number-of-calls-between-two-persons "两人之间的通话次数") 🔒 | [MySQL](problems/number-of-calls-between-two-persons) | Medium | -| 1698 | [Number of Distinct Substrings in a String](https://leetcode.com/problems/number-of-distinct-substrings-in-a-string "字符串的不同子字符串个数") 🔒 | [Go](problems/number-of-distinct-substrings-in-a-string) | Medium | -| 1697 | [Checking Existence of Edge Length Limited Paths](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths "检查边长度限制的路径是否存在") | [Go](problems/checking-existence-of-edge-length-limited-paths) | Hard | -| 1696 | [Jump Game VI](https://leetcode.com/problems/jump-game-vi "跳跃游戏 VI") | [Go](problems/jump-game-vi) | Medium | -| 1695 | [Maximum Erasure Value](https://leetcode.com/problems/maximum-erasure-value "删除子数组的最大得分") | [Go](problems/maximum-erasure-value) | Medium | -| 1694 | [Reformat Phone Number](https://leetcode.com/problems/reformat-phone-number "重新格式化电话号码") | [Go](problems/reformat-phone-number) | Easy | -| 1693 | [Daily Leads and Partners](https://leetcode.com/problems/daily-leads-and-partners "每天的领导和合伙人") 🔒 | [MySQL](problems/daily-leads-and-partners) | Easy | -| 1692 | [Count Ways to Distribute Candies](https://leetcode.com/problems/count-ways-to-distribute-candies "计算分配糖果的不同方式") 🔒 | [Go](problems/count-ways-to-distribute-candies) | Hard | -| 1691 | [Maximum Height by Stacking Cuboids](https://leetcode.com/problems/maximum-height-by-stacking-cuboids "堆叠长方体的最大高度") | [Go](problems/maximum-height-by-stacking-cuboids) | Hard | -| 1690 | [Stone Game VII](https://leetcode.com/problems/stone-game-vii "石子游戏 VII") | [Go](problems/stone-game-vii) | Medium | -| 1689 | [Partitioning Into Minimum Number Of Deci-Binary Numbers](https://leetcode.com/problems/partitioning-into-minimum-number-of-deci-binary-numbers "十-二进制数的最少数目") | [Go](problems/partitioning-into-minimum-number-of-deci-binary-numbers) | Medium | -| 1688 | [Count of Matches in Tournament](https://leetcode.com/problems/count-of-matches-in-tournament "比赛中的配对次数") | [Go](problems/count-of-matches-in-tournament) | Easy | -| 1687 | [Delivering Boxes from Storage to Ports](https://leetcode.com/problems/delivering-boxes-from-storage-to-ports "从仓库到码头运输箱子") | [Go](problems/delivering-boxes-from-storage-to-ports) | Hard | -| 1686 | [Stone Game VI](https://leetcode.com/problems/stone-game-vi "石子游戏 VI") | [Go](problems/stone-game-vi) | Medium | -| 1685 | [Sum of Absolute Differences in a Sorted Array](https://leetcode.com/problems/sum-of-absolute-differences-in-a-sorted-array "有序数组中差绝对值之和") | [Go](problems/sum-of-absolute-differences-in-a-sorted-array) | Medium | -| 1684 | [Count the Number of Consistent Strings](https://leetcode.com/problems/count-the-number-of-consistent-strings "统计一致字符串的数目") | [Go](problems/count-the-number-of-consistent-strings) | Easy | -| 1683 | [Invalid Tweets](https://leetcode.com/problems/invalid-tweets "无效的推文") 🔒 | [MySQL](problems/invalid-tweets) | Easy | -| 1682 | [Longest Palindromic Subsequence II](https://leetcode.com/problems/longest-palindromic-subsequence-ii "最长回文子序列 II") 🔒 | [Go](problems/longest-palindromic-subsequence-ii) | Medium | -| 1681 | [Minimum Incompatibility](https://leetcode.com/problems/minimum-incompatibility "最小不兼容性") | [Go](problems/minimum-incompatibility) | Hard | -| 1680 | [Concatenation of Consecutive Binary Numbers](https://leetcode.com/problems/concatenation-of-consecutive-binary-numbers "连接连续二进制数字") | [Go](problems/concatenation-of-consecutive-binary-numbers) | Medium | -| 1679 | [Max Number of K-Sum Pairs](https://leetcode.com/problems/max-number-of-k-sum-pairs "K 和数对的最大数目") | [Go](problems/max-number-of-k-sum-pairs) | Medium | -| 1678 | [Goal Parser Interpretation](https://leetcode.com/problems/goal-parser-interpretation "设计 Goal 解析器") | [Go](problems/goal-parser-interpretation) | Easy | -| 1677 | [Product's Worth Over Invoices](https://leetcode.com/problems/products-worth-over-invoices "发票中的产品金额") 🔒 | [MySQL](problems/products-worth-over-invoices) | Easy | -| 1676 | [Lowest Common Ancestor of a Binary Tree IV](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iv "二叉树的最近公共祖先 IV") 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-iv) | Medium | -| 1675 | [Minimize Deviation in Array](https://leetcode.com/problems/minimize-deviation-in-array "数组的最小偏移量") | [Go](problems/minimize-deviation-in-array) | Hard | -| 1674 | [Minimum Moves to Make Array Complementary](https://leetcode.com/problems/minimum-moves-to-make-array-complementary "使数组互补的最少操作次数") | [Go](problems/minimum-moves-to-make-array-complementary) | Medium | -| 1673 | [Find the Most Competitive Subsequence](https://leetcode.com/problems/find-the-most-competitive-subsequence "找出最具竞争力的子序列") | [Go](problems/find-the-most-competitive-subsequence) | Medium | -| 1672 | [Richest Customer Wealth](https://leetcode.com/problems/richest-customer-wealth "最富有客户的资产总量") | [Go](problems/richest-customer-wealth) | Easy | -| 1671 | [Minimum Number of Removals to Make Mountain Array](https://leetcode.com/problems/minimum-number-of-removals-to-make-mountain-array "得到山形数组的最少删除次数") | [Go](problems/minimum-number-of-removals-to-make-mountain-array) | Hard | -| 1670 | [Design Front Middle Back Queue](https://leetcode.com/problems/design-front-middle-back-queue "设计前中后队列") | [Go](problems/design-front-middle-back-queue) | Medium | -| 1669 | [Merge In Between Linked Lists](https://leetcode.com/problems/merge-in-between-linked-lists "合并两个链表") | [Go](problems/merge-in-between-linked-lists) | Medium | -| 1668 | [Maximum Repeating Substring](https://leetcode.com/problems/maximum-repeating-substring "最大重复子字符串") | [Go](problems/maximum-repeating-substring) | Easy | -| 1667 | [Fix Names in a Table](https://leetcode.com/problems/fix-names-in-a-table "修复表中的名字") 🔒 | [MySQL](problems/fix-names-in-a-table) | Easy | -| 1666 | [Change the Root of a Binary Tree](https://leetcode.com/problems/change-the-root-of-a-binary-tree "改变二叉树的根节点") 🔒 | [Go](problems/change-the-root-of-a-binary-tree) | Medium | -| 1665 | [Minimum Initial Energy to Finish Tasks](https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks "完成所有任务的最少初始能量") | [Go](problems/minimum-initial-energy-to-finish-tasks) | Hard | -| 1664 | [Ways to Make a Fair Array](https://leetcode.com/problems/ways-to-make-a-fair-array "生成平衡数组的方案数") | [Go](problems/ways-to-make-a-fair-array) | Medium | -| 1663 | [Smallest String With A Given Numeric Value](https://leetcode.com/problems/smallest-string-with-a-given-numeric-value "具有给定数值的最小字符串") | [Go](problems/smallest-string-with-a-given-numeric-value) | Medium | -| 1662 | [Check If Two String Arrays are Equivalent](https://leetcode.com/problems/check-if-two-string-arrays-are-equivalent "检查两个字符串数组是否相等") | [Go](problems/check-if-two-string-arrays-are-equivalent) | Easy | -| 1661 | [Average Time of Process per Machine](https://leetcode.com/problems/average-time-of-process-per-machine "每台机器的进程平均运行时间") 🔒 | [MySQL](problems/average-time-of-process-per-machine) | Easy | -| 1660 | [Correct a Binary Tree](https://leetcode.com/problems/correct-a-binary-tree "纠正二叉树") 🔒 | [Go](problems/correct-a-binary-tree) | Medium | -| 1659 | [Maximize Grid Happiness](https://leetcode.com/problems/maximize-grid-happiness "最大化网格幸福感") | [Go](problems/maximize-grid-happiness) | Hard | -| 1658 | [Minimum Operations to Reduce X to Zero](https://leetcode.com/problems/minimum-operations-to-reduce-x-to-zero "将 x 减到 0 的最小操作数") | [Go](problems/minimum-operations-to-reduce-x-to-zero) | Medium | -| 1657 | [Determine if Two Strings Are Close](https://leetcode.com/problems/determine-if-two-strings-are-close "确定两个字符串是否接近") | [Go](problems/determine-if-two-strings-are-close) | Medium | -| 1656 | [Design an Ordered Stream](https://leetcode.com/problems/design-an-ordered-stream "设计有序流") | [Go](problems/design-an-ordered-stream) | Easy | -| 1655 | [Distribute Repeating Integers](https://leetcode.com/problems/distribute-repeating-integers "分配重复整数") | [Go](problems/distribute-repeating-integers) | Hard | -| 1654 | [Minimum Jumps to Reach Home](https://leetcode.com/problems/minimum-jumps-to-reach-home "到家的最少跳跃次数") | [Go](problems/minimum-jumps-to-reach-home) | Medium | -| 1653 | [Minimum Deletions to Make String Balanced](https://leetcode.com/problems/minimum-deletions-to-make-string-balanced "使字符串平衡的最少删除次数") | [Go](problems/minimum-deletions-to-make-string-balanced) | Medium | -| 1652 | [Defuse the Bomb](https://leetcode.com/problems/defuse-the-bomb "拆炸弹") | [Go](problems/defuse-the-bomb) | Easy | -| 1651 | [Hopper Company Queries III](https://leetcode.com/problems/hopper-company-queries-iii) 🔒 | [MySQL](problems/hopper-company-queries-iii) | Hard | -| 1650 | [Lowest Common Ancestor of a Binary Tree III](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iii "二叉树的最近公共祖先 III") 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-iii) | Medium | -| 1649 | [Create Sorted Array through Instructions](https://leetcode.com/problems/create-sorted-array-through-instructions "通过指令创建有序数组") | [Go](problems/create-sorted-array-through-instructions) | Hard | -| 1648 | [Sell Diminishing-Valued Colored Balls](https://leetcode.com/problems/sell-diminishing-valued-colored-balls "销售价值减少的颜色球") | [Go](problems/sell-diminishing-valued-colored-balls) | Medium | -| 1647 | [Minimum Deletions to Make Character Frequencies Unique](https://leetcode.com/problems/minimum-deletions-to-make-character-frequencies-unique "字符频次唯一的最小删除次数") | [Go](problems/minimum-deletions-to-make-character-frequencies-unique) | Medium | -| 1646 | [Get Maximum in Generated Array](https://leetcode.com/problems/get-maximum-in-generated-array "获取生成数组中的最大值") | [Go](problems/get-maximum-in-generated-array) | Easy | -| 1645 | [Hopper Company Queries II](https://leetcode.com/problems/hopper-company-queries-ii) 🔒 | [MySQL](problems/hopper-company-queries-ii) | Hard | -| 1644 | [Lowest Common Ancestor of a Binary Tree II](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-ii "二叉树的最近公共祖先 II") 🔒 | [Go](problems/lowest-common-ancestor-of-a-binary-tree-ii) | Medium | -| 1643 | [Kth Smallest Instructions](https://leetcode.com/problems/kth-smallest-instructions "第 K 条最小指令") | [Go](problems/kth-smallest-instructions) | Hard | -| 1642 | [Furthest Building You Can Reach](https://leetcode.com/problems/furthest-building-you-can-reach "可以到达的最远建筑") | [Go](problems/furthest-building-you-can-reach) | Medium | -| 1641 | [Count Sorted Vowel Strings](https://leetcode.com/problems/count-sorted-vowel-strings "统计字典序元音字符串的数目") | [Go](problems/count-sorted-vowel-strings) | Medium | -| 1640 | [Check Array Formation Through Concatenation](https://leetcode.com/problems/check-array-formation-through-concatenation "能否连接形成数组") | [Go](problems/check-array-formation-through-concatenation) | Easy | -| 1639 | [Number of Ways to Form a Target String Given a Dictionary](https://leetcode.com/problems/number-of-ways-to-form-a-target-string-given-a-dictionary "通过给定词典构造目标字符串的方案数") | [Go](problems/number-of-ways-to-form-a-target-string-given-a-dictionary) | Hard | -| 1638 | [Count Substrings That Differ by One Character](https://leetcode.com/problems/count-substrings-that-differ-by-one-character "统计只差一个字符的子串数目") | [Go](problems/count-substrings-that-differ-by-one-character) | Medium | -| 1637 | [Widest Vertical Area Between Two Points Containing No Points](https://leetcode.com/problems/widest-vertical-area-between-two-points-containing-no-points "两点之间不包含任何点的最宽垂直面积") | [Go](problems/widest-vertical-area-between-two-points-containing-no-points) | Medium | -| 1636 | [Sort Array by Increasing Frequency](https://leetcode.com/problems/sort-array-by-increasing-frequency "按照频率将数组升序排序") | [Go](problems/sort-array-by-increasing-frequency) | Easy | -| 1635 | [Hopper Company Queries I](https://leetcode.com/problems/hopper-company-queries-i "Hopper 公司查询 I") 🔒 | [MySQL](problems/hopper-company-queries-i) | Hard | -| 1634 | [Add Two Polynomials Represented as Linked Lists](https://leetcode.com/problems/add-two-polynomials-represented-as-linked-lists "求两个多项式链表的和") 🔒 | [Go](problems/add-two-polynomials-represented-as-linked-lists) | Medium | -| 1633 | [Percentage of Users Attended a Contest](https://leetcode.com/problems/percentage-of-users-attended-a-contest "各赛事的用户注册率") 🔒 | [MySQL](problems/percentage-of-users-attended-a-contest) | Easy | -| 1632 | [Rank Transform of a Matrix](https://leetcode.com/problems/rank-transform-of-a-matrix "矩阵转换后的秩") | [Go](problems/rank-transform-of-a-matrix) | Hard | -| 1631 | [Path With Minimum Effort](https://leetcode.com/problems/path-with-minimum-effort "最小体力消耗路径") | [Go](problems/path-with-minimum-effort) | Medium | -| 1630 | [Arithmetic Subarrays](https://leetcode.com/problems/arithmetic-subarrays "等差子数组") | [Go](problems/arithmetic-subarrays) | Medium | -| 1629 | [Slowest Key](https://leetcode.com/problems/slowest-key "按键持续时间最长的键") | [Go](problems/slowest-key) | Easy | -| 1628 | [Design an Expression Tree With Evaluate Function](https://leetcode.com/problems/design-an-expression-tree-with-evaluate-function "设计带解析函数的表达式树") 🔒 | [Go](problems/design-an-expression-tree-with-evaluate-function) | Medium | -| 1627 | [Graph Connectivity With Threshold](https://leetcode.com/problems/graph-connectivity-with-threshold "带阈值的图连通性") | [Go](problems/graph-connectivity-with-threshold) | Hard | -| 1626 | [Best Team With No Conflicts](https://leetcode.com/problems/best-team-with-no-conflicts "无矛盾的最佳球队") | [Go](problems/best-team-with-no-conflicts) | Medium | -| 1625 | [Lexicographically Smallest String After Applying Operations](https://leetcode.com/problems/lexicographically-smallest-string-after-applying-operations "执行操作后字典序最小的字符串") | [Go](problems/lexicographically-smallest-string-after-applying-operations) | Medium | -| 1624 | [Largest Substring Between Two Equal Characters](https://leetcode.com/problems/largest-substring-between-two-equal-characters "两个相同字符之间的最长子字符串") | [Go](problems/largest-substring-between-two-equal-characters) | Easy | -| 1623 | [All Valid Triplets That Can Represent a Country](https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country "三人国家代表队") 🔒 | [MySQL](problems/all-valid-triplets-that-can-represent-a-country) | Easy | -| 1622 | [Fancy Sequence](https://leetcode.com/problems/fancy-sequence "奇妙序列") | [Go](problems/fancy-sequence) | Hard | -| 1621 | [Number of Sets of K Non-Overlapping Line Segments](https://leetcode.com/problems/number-of-sets-of-k-non-overlapping-line-segments "大小为 K 的不重叠线段的数目") | [Go](problems/number-of-sets-of-k-non-overlapping-line-segments) | Medium | -| 1620 | [Coordinate With Maximum Network Quality](https://leetcode.com/problems/coordinate-with-maximum-network-quality "网络信号最好的坐标") | [Go](problems/coordinate-with-maximum-network-quality) | Medium | -| 1619 | [Mean of Array After Removing Some Elements](https://leetcode.com/problems/mean-of-array-after-removing-some-elements "删除某些元素后的数组均值") | [Go](problems/mean-of-array-after-removing-some-elements) | Easy | -| 1618 | [Maximum Font to Fit a Sentence in a Screen](https://leetcode.com/problems/maximum-font-to-fit-a-sentence-in-a-screen "找出适应屏幕的最大字号") 🔒 | [Go](problems/maximum-font-to-fit-a-sentence-in-a-screen) | Medium | -| 1617 | [Count Subtrees With Max Distance Between Cities](https://leetcode.com/problems/count-subtrees-with-max-distance-between-cities "统计子树中城市之间最大距离") | [Go](problems/count-subtrees-with-max-distance-between-cities) | Hard | -| 1616 | [Split Two Strings to Make Palindrome](https://leetcode.com/problems/split-two-strings-to-make-palindrome "分割两个字符串得到回文串") | [Go](problems/split-two-strings-to-make-palindrome) | Medium | -| 1615 | [Maximal Network Rank](https://leetcode.com/problems/maximal-network-rank "最大网络秩") | [Go](problems/maximal-network-rank) | Medium | -| 1614 | [Maximum Nesting Depth of the Parentheses](https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses "括号的最大嵌套深度") | [Go](problems/maximum-nesting-depth-of-the-parentheses) | Easy | -| 1613 | [Find the Missing IDs](https://leetcode.com/problems/find-the-missing-ids "找到遗失的ID") 🔒 | [MySQL](problems/find-the-missing-ids) | Medium | -| 1612 | [Check If Two Expression Trees are Equivalent](https://leetcode.com/problems/check-if-two-expression-trees-are-equivalent "检查两棵二叉表达式树是否等价") 🔒 | [Go](problems/check-if-two-expression-trees-are-equivalent) | Medium | -| 1611 | [Minimum One Bit Operations to Make Integers Zero](https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero "使整数变为 0 的最少操作次数") | [Go](problems/minimum-one-bit-operations-to-make-integers-zero) | Hard | -| 1610 | [Maximum Number of Visible Points](https://leetcode.com/problems/maximum-number-of-visible-points "可见点的最大数目") | [Go](problems/maximum-number-of-visible-points) | Hard | -| 1609 | [Even Odd Tree](https://leetcode.com/problems/even-odd-tree "奇偶树") | [Go](problems/even-odd-tree) | Medium | -| 1608 | [Special Array With X Elements Greater Than or Equal X](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x "特殊数组的特征值") | [Go](problems/special-array-with-x-elements-greater-than-or-equal-x) | Easy | -| 1607 | [Sellers With No Sales](https://leetcode.com/problems/sellers-with-no-sales "没有卖出的卖家") 🔒 | [MySQL](problems/sellers-with-no-sales) | Easy | -| 1606 | [Find Servers That Handled Most Number of Requests](https://leetcode.com/problems/find-servers-that-handled-most-number-of-requests "找到处理最多请求的服务器") | [Go](problems/find-servers-that-handled-most-number-of-requests) | Hard | -| 1605 | [Find Valid Matrix Given Row and Column Sums](https://leetcode.com/problems/find-valid-matrix-given-row-and-column-sums "给定行和列的和求可行矩阵") | [Go](problems/find-valid-matrix-given-row-and-column-sums) | Medium | -| 1604 | [Alert Using Same Key-Card Three or More Times in a One Hour Period](https://leetcode.com/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period "警告一小时内使用相同员工卡大于等于三次的人") | [Go](problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | Medium | -| 1603 | [Design Parking System](https://leetcode.com/problems/design-parking-system "设计停车系统") | [Go](problems/design-parking-system) | Easy | -| 1602 | [Find Nearest Right Node in Binary Tree](https://leetcode.com/problems/find-nearest-right-node-in-binary-tree "找到二叉树中最近的右侧节点") 🔒 | [Go](problems/find-nearest-right-node-in-binary-tree) | Medium | -| 1601 | [Maximum Number of Achievable Transfer Requests](https://leetcode.com/problems/maximum-number-of-achievable-transfer-requests "最多可达成的换楼请求数目") | [Go](problems/maximum-number-of-achievable-transfer-requests) | Hard | -| 1600 | [Throne Inheritance](https://leetcode.com/problems/throne-inheritance "皇位继承顺序") | [Go](problems/throne-inheritance) | Medium | -| 1599 | [Maximum Profit of Operating a Centennial Wheel](https://leetcode.com/problems/maximum-profit-of-operating-a-centennial-wheel "经营摩天轮的最大利润") | [Go](problems/maximum-profit-of-operating-a-centennial-wheel) | Medium | -| 1598 | [Crawler Log Folder](https://leetcode.com/problems/crawler-log-folder "文件夹操作日志搜集器") | [Go](problems/crawler-log-folder) | Easy | -| 1597 | [Build Binary Expression Tree From Infix Expression](https://leetcode.com/problems/build-binary-expression-tree-from-infix-expression "根据中缀表达式构造二叉表达式树") 🔒 | [Go](problems/build-binary-expression-tree-from-infix-expression) | Hard | -| 1596 | [The Most Frequently Ordered Products for Each Customer](https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer "每位顾客最经常订购的商品") 🔒 | [MySQL](problems/the-most-frequently-ordered-products-for-each-customer) | Medium | -| 1595 | [Minimum Cost to Connect Two Groups of Points](https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points "连通两组点的最小成本") | [Go](problems/minimum-cost-to-connect-two-groups-of-points) | Hard | -| 1594 | [Maximum Non Negative Product in a Matrix](https://leetcode.com/problems/maximum-non-negative-product-in-a-matrix "矩阵的最大非负积") | [Go](problems/maximum-non-negative-product-in-a-matrix) | Medium | -| 1593 | [Split a String Into the Max Number of Unique Substrings](https://leetcode.com/problems/split-a-string-into-the-max-number-of-unique-substrings "拆分字符串使唯一子字符串的数目最大") | [Go](problems/split-a-string-into-the-max-number-of-unique-substrings) | Medium | -| 1592 | [Rearrange Spaces Between Words](https://leetcode.com/problems/rearrange-spaces-between-words "重新排列单词间的空格") | [Go](problems/rearrange-spaces-between-words) | Easy | -| 1591 | [Strange Printer II](https://leetcode.com/problems/strange-printer-ii "奇怪的打印机 II") | [Go](problems/strange-printer-ii) | Hard | -| 1590 | [Make Sum Divisible by P](https://leetcode.com/problems/make-sum-divisible-by-p "使数组和能被 P 整除") | [Go](problems/make-sum-divisible-by-p) | Medium | -| 1589 | [Maximum Sum Obtained of Any Permutation](https://leetcode.com/problems/maximum-sum-obtained-of-any-permutation "所有排列中的最大和") | [Go](problems/maximum-sum-obtained-of-any-permutation) | Medium | -| 1588 | [Sum of All Odd Length Subarrays](https://leetcode.com/problems/sum-of-all-odd-length-subarrays "所有奇数长度子数组的和") | [Go](problems/sum-of-all-odd-length-subarrays) | Easy | -| 1587 | [Bank Account Summary II](https://leetcode.com/problems/bank-account-summary-ii "银行账户概要 II") 🔒 | [MySQL](problems/bank-account-summary-ii) | Easy | -| 1586 | [Binary Search Tree Iterator II](https://leetcode.com/problems/binary-search-tree-iterator-ii "二叉搜索树迭代器 II") 🔒 | [Go](problems/binary-search-tree-iterator-ii) | Medium | -| 1585 | [Check If String Is Transformable With Substring Sort Operations](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations "检查字符串是否可以通过排序子字符串得到另一个字符串") | [Go](problems/check-if-string-is-transformable-with-substring-sort-operations) | Hard | -| 1584 | [Min Cost to Connect All Points](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") | [Go](problems/min-cost-to-connect-all-points) | Medium | -| 1583 | [Count Unhappy Friends](https://leetcode.com/problems/count-unhappy-friends "统计不开心的朋友") | [Go](problems/count-unhappy-friends) | Medium | -| 1582 | [Special Positions in a Binary Matrix](https://leetcode.com/problems/special-positions-in-a-binary-matrix "二进制矩阵中的特殊位置") | [Go](problems/special-positions-in-a-binary-matrix) | Easy | -| 1581 | [Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的顾客") 🔒 | [MySQL](problems/customer-who-visited-but-did-not-make-any-transactions) | Easy | -| 1580 | [Put Boxes Into the Warehouse II](https://leetcode.com/problems/put-boxes-into-the-warehouse-ii "把箱子放进仓库里 II") 🔒 | [Go](problems/put-boxes-into-the-warehouse-ii) | Medium | -| 1579 | [Remove Max Number of Edges to Keep Graph Fully Traversable](https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable "保证图可完全遍历") | [Go](problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | Hard | -| 1578 | [Minimum Deletion Cost to Avoid Repeating Letters](https://leetcode.com/problems/minimum-deletion-cost-to-avoid-repeating-letters "避免重复字母的最小删除成本") | [Go](problems/minimum-deletion-cost-to-avoid-repeating-letters) | Medium | -| 1577 | [Number of Ways Where Square of Number Is Equal to Product of Two Numbers](https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "数的平方等于两数乘积的方法数") | [Go](problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | Medium | -| 1576 | [Replace All ?'s to Avoid Consecutive Repeating Characters](https://leetcode.com/problems/replace-all-s-to-avoid-consecutive-repeating-characters "替换所有的问号") | [Go](problems/replace-all-s-to-avoid-consecutive-repeating-characters) | Easy | -| 1575 | [Count All Possible Routes](https://leetcode.com/problems/count-all-possible-routes "统计所有可行路径") | [Go](problems/count-all-possible-routes) | Hard | -| 1574 | [Shortest Subarray to be Removed to Make Array Sorted](https://leetcode.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted "删除最短的子数组使剩余数组有序") | [Go](problems/shortest-subarray-to-be-removed-to-make-array-sorted) | Medium | -| 1573 | [Number of Ways to Split a String](https://leetcode.com/problems/number-of-ways-to-split-a-string "分割字符串的方案数") | [Go](problems/number-of-ways-to-split-a-string) | Medium | -| 1572 | [Matrix Diagonal Sum](https://leetcode.com/problems/matrix-diagonal-sum "矩阵对角线元素的和") | [Go](problems/matrix-diagonal-sum) | Easy | -| 1571 | [Warehouse Manager](https://leetcode.com/problems/warehouse-manager "仓库经理") 🔒 | [MySQL](problems/warehouse-manager) | Easy | -| 1570 | [Dot Product of Two Sparse Vectors](https://leetcode.com/problems/dot-product-of-two-sparse-vectors "两个稀疏向量的点积") 🔒 | [Go](problems/dot-product-of-two-sparse-vectors) | Medium | -| 1569 | [Number of Ways to Reorder Array to Get Same BST](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst "将子数组重新排序得到同一个二叉查找树的方案数") | [Go](problems/number-of-ways-to-reorder-array-to-get-same-bst) | Hard | -| 1568 | [Minimum Number of Days to Disconnect Island](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数") | [Go](problems/minimum-number-of-days-to-disconnect-island) | Hard | -| 1567 | [Maximum Length of Subarray With Positive Product](https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product "乘积为正数的最长子数组长度") | [Go](problems/maximum-length-of-subarray-with-positive-product) | Medium | -| 1566 | [Detect Pattern of Length M Repeated K or More Times](https://leetcode.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times "重复至少 K 次且长度为 M 的模式") | [Go](problems/detect-pattern-of-length-m-repeated-k-or-more-times) | Easy | -| 1565 | [Unique Orders and Customers Per Month](https://leetcode.com/problems/unique-orders-and-customers-per-month "按月统计订单数与顾客数") 🔒 | [MySQL](problems/unique-orders-and-customers-per-month) | Easy | -| 1564 | [Put Boxes Into the Warehouse I](https://leetcode.com/problems/put-boxes-into-the-warehouse-i "把箱子放进仓库里 I") 🔒 | [Go](problems/put-boxes-into-the-warehouse-i) | Medium | -| 1563 | [Stone Game V](https://leetcode.com/problems/stone-game-v "石子游戏 V") | [Go](problems/stone-game-v) | Hard | -| 1562 | [Find Latest Group of Size M](https://leetcode.com/problems/find-latest-group-of-size-m "查找大小为 M 的最新分组") | [Go](problems/find-latest-group-of-size-m) | Medium | -| 1561 | [Maximum Number of Coins You Can Get](https://leetcode.com/problems/maximum-number-of-coins-you-can-get "你可以获得的最大硬币数目") | [Go](problems/maximum-number-of-coins-you-can-get) | Medium | -| 1560 | [Most Visited Sector in a Circular Track](https://leetcode.com/problems/most-visited-sector-in-a-circular-track "圆形赛道上经过次数最多的扇区") | [Go](problems/most-visited-sector-in-a-circular-track) | Easy | -| 1559 | [Detect Cycles in 2D Grid](https://leetcode.com/problems/detect-cycles-in-2d-grid "二维网格图中探测环") | [Go](problems/detect-cycles-in-2d-grid) | Medium | -| 1558 | [Minimum Numbers of Function Calls to Make Target Array](https://leetcode.com/problems/minimum-numbers-of-function-calls-to-make-target-array "得到目标数组的最少函数调用次数") | [Go](problems/minimum-numbers-of-function-calls-to-make-target-array) | Medium | -| 1557 | [Minimum Number of Vertices to Reach All Nodes](https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes "可以到达所有点的最少点数目") | [Go](problems/minimum-number-of-vertices-to-reach-all-nodes) | Medium | -| 1556 | [Thousand Separator](https://leetcode.com/problems/thousand-separator "千位分隔数") | [Go](problems/thousand-separator) | Easy | -| 1555 | [Bank Account Summary](https://leetcode.com/problems/bank-account-summary "银行账户概要") 🔒 | [MySQL](problems/bank-account-summary) | Medium | -| 1554 | [Strings Differ by One Character](https://leetcode.com/problems/strings-differ-by-one-character "只有一个不同字符的字符串") 🔒 | [Go](problems/strings-differ-by-one-character) | Medium | -| 1553 | [Minimum Number of Days to Eat N Oranges](https://leetcode.com/problems/minimum-number-of-days-to-eat-n-oranges "吃掉 N 个橘子的最少天数") | [Go](problems/minimum-number-of-days-to-eat-n-oranges) | Hard | -| 1552 | [Magnetic Force Between Two Balls](https://leetcode.com/problems/magnetic-force-between-two-balls "两球之间的磁力") | [Go](problems/magnetic-force-between-two-balls) | Medium | -| 1551 | [Minimum Operations to Make Array Equal](https://leetcode.com/problems/minimum-operations-to-make-array-equal "使数组中所有元素相等的最小操作数") | [Go](problems/minimum-operations-to-make-array-equal) | Medium | -| 1550 | [Three Consecutive Odds](https://leetcode.com/problems/three-consecutive-odds "存在连续三个奇数的数组") | [Go](problems/three-consecutive-odds) | Easy | -| 1549 | [The Most Recent Orders for Each Product](https://leetcode.com/problems/the-most-recent-orders-for-each-product "每件商品的最新订单") 🔒 | [MySQL](problems/the-most-recent-orders-for-each-product) | Medium | -| 1548 | [The Most Similar Path in a Graph](https://leetcode.com/problems/the-most-similar-path-in-a-graph "图中最相似的路径") 🔒 | [Go](problems/the-most-similar-path-in-a-graph) | Hard | -| 1547 | [Minimum Cost to Cut a Stick](https://leetcode.com/problems/minimum-cost-to-cut-a-stick "切棍子的最小成本") | [Go](problems/minimum-cost-to-cut-a-stick) | Hard | -| 1546 | [Maximum Number of Non-Overlapping Subarrays With Sum Equals Target](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值且不重叠的非空子数组的最大数目") | [Go](problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | Medium | -| 1545 | [Find Kth Bit in Nth Binary String](https://leetcode.com/problems/find-kth-bit-in-nth-binary-string "找出第 N 个二进制字符串中的第 K 位") | [Go](problems/find-kth-bit-in-nth-binary-string) | Medium | -| 1544 | [Make The String Great](https://leetcode.com/problems/make-the-string-great "整理字符串") | [Go](problems/make-the-string-great) | Easy | -| 1543 | [Fix Product Name Format](https://leetcode.com/problems/fix-product-name-format "产品名称格式修复") 🔒 | [MySQL](problems/fix-product-name-format) | Easy | -| 1542 | [Find Longest Awesome Substring](https://leetcode.com/problems/find-longest-awesome-substring "找出最长的超赞子字符串") | [Go](problems/find-longest-awesome-substring) | Hard | -| 1541 | [Minimum Insertions to Balance a Parentheses String](https://leetcode.com/problems/minimum-insertions-to-balance-a-parentheses-string "平衡括号字符串的最少插入次数") | [Go](problems/minimum-insertions-to-balance-a-parentheses-string) | Medium | -| 1540 | [Can Convert String in K Moves](https://leetcode.com/problems/can-convert-string-in-k-moves "K 次操作转变字符串") | [Go](problems/can-convert-string-in-k-moves) | Medium | -| 1539 | [Kth Missing Positive Number](https://leetcode.com/problems/kth-missing-positive-number "第 k 个缺失的正整数") | [Go](problems/kth-missing-positive-number) | Easy | -| 1538 | [Guess the Majority in a Hidden Array](https://leetcode.com/problems/guess-the-majority-in-a-hidden-array "找出隐藏数组中出现次数最多的元素") 🔒 | [Go](problems/guess-the-majority-in-a-hidden-array) | Medium | -| 1537 | [Get the Maximum Score](https://leetcode.com/problems/get-the-maximum-score "最大得分") | [Go](problems/get-the-maximum-score) | Hard | -| 1536 | [Minimum Swaps to Arrange a Binary Grid](https://leetcode.com/problems/minimum-swaps-to-arrange-a-binary-grid "排布二进制网格的最少交换次数") | [Go](problems/minimum-swaps-to-arrange-a-binary-grid) | Medium | -| 1535 | [Find the Winner of an Array Game](https://leetcode.com/problems/find-the-winner-of-an-array-game "找出数组游戏的赢家") | [Go](problems/find-the-winner-of-an-array-game) | Medium | -| 1534 | [Count Good Triplets](https://leetcode.com/problems/count-good-triplets "统计好三元组") | [Go](problems/count-good-triplets) | Easy | -| 1533 | [Find the Index of the Large Integer](https://leetcode.com/problems/find-the-index-of-the-large-integer "找到最大整数的索引") 🔒 | [Go](problems/find-the-index-of-the-large-integer) | Medium | -| 1532 | [The Most Recent Three Orders](https://leetcode.com/problems/the-most-recent-three-orders "最近的三笔订单") 🔒 | [MySQL](problems/the-most-recent-three-orders) | Medium | -| 1531 | [String Compression II](https://leetcode.com/problems/string-compression-ii "压缩字符串 II") | [Go](problems/string-compression-ii) | Hard | -| 1530 | [Number of Good Leaf Nodes Pairs](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs "好叶子节点对的数量") | [Go](problems/number-of-good-leaf-nodes-pairs) | Medium | -| 1529 | [Bulb Switcher IV](https://leetcode.com/problems/bulb-switcher-iv "灯泡开关 IV") | [Go](problems/bulb-switcher-iv) | Medium | -| 1528 | [Shuffle String](https://leetcode.com/problems/shuffle-string "重新排列字符串") | [Go](problems/shuffle-string) | Easy | -| 1527 | [Patients With a Condition](https://leetcode.com/problems/patients-with-a-condition "患某种疾病的患者") 🔒 | [MySQL](problems/patients-with-a-condition) | Easy | -| 1526 | [Minimum Number of Increments on Subarrays to Form a Target Array](https://leetcode.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array "形成目标数组的子数组最少增加次数") | [Go](problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | Hard | -| 1525 | [Number of Good Ways to Split a String](https://leetcode.com/problems/number-of-good-ways-to-split-a-string "字符串的好分割数目") | [Go](problems/number-of-good-ways-to-split-a-string) | Medium | -| 1524 | [Number of Sub-arrays With Odd Sum](https://leetcode.com/problems/number-of-sub-arrays-with-odd-sum "和为奇数的子数组数目") | [Go](problems/number-of-sub-arrays-with-odd-sum) | Medium | -| 1523 | [Count Odd Numbers in an Interval Range](https://leetcode.com/problems/count-odd-numbers-in-an-interval-range "在区间范围内统计奇数数目") | [Go](problems/count-odd-numbers-in-an-interval-range) | Easy | -| 1522 | [Diameter of N-Ary Tree](https://leetcode.com/problems/diameter-of-n-ary-tree "N 叉树的直径") 🔒 | [Go](problems/diameter-of-n-ary-tree) | Medium | -| 1521 | [Find a Value of a Mysterious Function Closest to Target](https://leetcode.com/problems/find-a-value-of-a-mysterious-function-closest-to-target "找到最接近目标值的函数值") | [Go](problems/find-a-value-of-a-mysterious-function-closest-to-target) | Hard | -| 1520 | [Maximum Number of Non-Overlapping Substrings](https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings "最多的不重叠子字符串") | [Go](problems/maximum-number-of-non-overlapping-substrings) | Hard | -| 1519 | [Number of Nodes in the Sub-Tree With the Same Label](https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label "子树中标签相同的节点数") | [Go](problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | Medium | -| 1518 | [Water Bottles](https://leetcode.com/problems/water-bottles "换酒问题") | [Go](problems/water-bottles) | Easy | -| 1517 | [Find Users With Valid E-Mails](https://leetcode.com/problems/find-users-with-valid-e-mails "查找拥有有效邮箱的用户") 🔒 | [MySQL](problems/find-users-with-valid-e-mails) | Easy | -| 1516 | [Move Sub-Tree of N-Ary Tree](https://leetcode.com/problems/move-sub-tree-of-n-ary-tree "移动 N 叉树的子树") 🔒 | [Go](problems/move-sub-tree-of-n-ary-tree) | Hard | -| 1515 | [Best Position for a Service Centre](https://leetcode.com/problems/best-position-for-a-service-centre "服务中心的最佳位置") | [Go](problems/best-position-for-a-service-centre) | Hard | -| 1514 | [Path with Maximum Probability](https://leetcode.com/problems/path-with-maximum-probability "概率最大的路径") | [Go](problems/path-with-maximum-probability) | Medium | -| 1513 | [Number of Substrings With Only 1s](https://leetcode.com/problems/number-of-substrings-with-only-1s "仅含 1 的子串数") | [Go](problems/number-of-substrings-with-only-1s) | Medium | -| 1512 | [Number of Good Pairs](https://leetcode.com/problems/number-of-good-pairs "好数对的数目") | [Go](problems/number-of-good-pairs) | Easy | -| 1511 | [Customer Order Frequency](https://leetcode.com/problems/customer-order-frequency "消费者下单频率") 🔒 | [MySQL](problems/customer-order-frequency) | Easy | -| 1510 | [Stone Game IV](https://leetcode.com/problems/stone-game-iv "石子游戏 IV") | [Go](problems/stone-game-iv) | Hard | -| 1509 | [Minimum Difference Between Largest and Smallest Value in Three Moves](https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves "三次操作后最大值与最小值的最小差") | [Go](problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | Medium | -| 1508 | [Range Sum of Sorted Subarray Sums](https://leetcode.com/problems/range-sum-of-sorted-subarray-sums "子数组和排序后的区间和") | [Go](problems/range-sum-of-sorted-subarray-sums) | Medium | -| 1507 | [Reformat Date](https://leetcode.com/problems/reformat-date "转变日期格式") | [Go](problems/reformat-date) | Easy | -| 1506 | [Find Root of N-Ary Tree](https://leetcode.com/problems/find-root-of-n-ary-tree "找到 N 叉树的根节点") 🔒 | [Go](problems/find-root-of-n-ary-tree) | Medium | -| 1505 | [Minimum Possible Integer After at Most K Adjacent Swaps On Digits](https://leetcode.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "最多 K 次交换相邻数位后得到的最小整数") | [Go](problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | Hard | -| 1504 | [Count Submatrices With All Ones](https://leetcode.com/problems/count-submatrices-with-all-ones "统计全 1 子矩形") | [Go](problems/count-submatrices-with-all-ones) | Medium | -| 1503 | [Last Moment Before All Ants Fall Out of a Plank](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank "所有蚂蚁掉下来前的最后一刻") | [Go](problems/last-moment-before-all-ants-fall-out-of-a-plank) | Medium | -| 1502 | [Can Make Arithmetic Progression From Sequence](https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence "判断能否形成等差数列") | [Go](problems/can-make-arithmetic-progression-from-sequence) | Easy | -| 1501 | [Countries You Can Safely Invest In](https://leetcode.com/problems/countries-you-can-safely-invest-in "可以放心投资的国家") 🔒 | [MySQL](problems/countries-you-can-safely-invest-in) | Medium | diff --git a/problems/01-matrix/README.md b/problems/01-matrix/README.md index 35b6ca3e1..47aff04e7 100644 --- a/problems/01-matrix/README.md +++ b/problems/01-matrix/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-string-ii "Reverse String II") diff --git a/problems/a-number-after-a-double-reversal/README.md b/problems/a-number-after-a-double-reversal/README.md new file mode 100644 index 000000000..4fffcb4b3 --- /dev/null +++ b/problems/a-number-after-a-double-reversal/README.md @@ -0,0 +1,61 @@ + + + + + + + +[< Previous](../build-the-equation "Build the Equation") +                 +[Next >](../execution-of-all-suffix-instructions-staying-in-a-grid "Execution of All Suffix Instructions Staying in a Grid") + +## [2119. A Number After a Double Reversal (Easy)](https://leetcode.com/problems/a-number-after-a-double-reversal "反转两次的数字") + +

    Reversing an integer means to reverse all its digits.

    + +
      +
    • For example, reversing 2021 gives 1202. Reversing 12300 gives 321 as the leading zeros are not retained.
    • +
    + +

    Given an integer num, reverse num to get reversed1, then reverse reversed1 to get reversed2. Return true if reversed2 equals num. Otherwise return false.

    + +

     

    +

    Example 1:

    + +
    +Input: num = 526
    +Output: true
    +Explanation: Reverse num to get 625, then reverse 625 to get 526, which equals num.
    +
    + +

    Example 2:

    + +
    +Input: num = 1800
    +Output: false
    +Explanation: Reverse num to get 81, then reverse 81 to get 18, which does not equal num.
    +
    + +

    Example 3:

    + +
    +Input: num = 0
    +Output: true
    +Explanation: Reverse num to get 0, then reverse 0 to get 0, which equals num.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= num <= 106
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Other than the number 0 itself, any number that ends with 0 would lose some digits permanently when reversed. +
    diff --git a/problems/abbreviating-the-product-of-a-range/README.md b/problems/abbreviating-the-product-of-a-range/README.md new file mode 100644 index 000000000..3ee8a1c74 --- /dev/null +++ b/problems/abbreviating-the-product-of-a-range/README.md @@ -0,0 +1,103 @@ + + + + + + + +[< Previous](../check-if-a-parentheses-string-can-be-valid "Check if a Parentheses String Can Be Valid") +                 +[Next >](../build-the-equation "Build the Equation") + +## [2117. Abbreviating the Product of a Range (Hard)](https://leetcode.com/problems/abbreviating-the-product-of-a-range "一个区间内所有数乘积的缩写") + +

    You are given two positive integers left and right with left <= right. Calculate the product of all integers in the inclusive range [left, right].

    + +

    Since the product may be very large, you will abbreviate it following these steps:

    + +
      +
    1. Count all trailing zeros in the product and remove them. Let us denote this count as C. +
        +
      • For example, there are 3 trailing zeros in 1000, and there are 0 trailing zeros in 546.
      • +
      +
    2. +
    3. Denote the remaining number of digits in the product as d. If d > 10, then express the product as <pre>...<suf> where <pre> denotes the first 5 digits of the product, and <suf> denotes the last 5 digits of the product after removing all trailing zeros. If d <= 10, we keep it unchanged. +
        +
      • For example, we express 1234567654321 as 12345...54321, but 1234567 is represented as 1234567.
      • +
      +
    4. +
    5. Finally, represent the product as a string "<pre>...<suf>eC". +
        +
      • For example, 12345678987600000 will be represented as "12345...89876e5".
      • +
      +
    6. +
    + +

    Return a string denoting the abbreviated product of all integers in the inclusive range [left, right].

    + +

     

    +

    Example 1:

    + +
    +Input: left = 1, right = 4
    +Output: "24e0"
    +Explanation: The product is 1 × 2 × 3 × 4 = 24.
    +There are no trailing zeros, so 24 remains the same. The abbreviation will end with "e0".
    +Since the number of digits is 2, which is less than 10, we do not have to abbreviate it further.
    +Thus, the final representation is "24e0".
    +
    + +

    Example 2:

    + +
    +Input: left = 2, right = 11
    +Output: "399168e2"
    +Explanation: The product is 39916800.
    +There are 2 trailing zeros, which we remove to get 399168. The abbreviation will end with "e2".
    +The number of digits after removing the trailing zeros is 6, so we do not abbreviate it further.
    +Hence, the abbreviated product is "399168e2".
    +
    + +

    Example 3:

    + +
    +Input: left = 371, right = 375
    +Output: "7219856259e3"
    +Explanation: The product is 7219856259000.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= left <= right <= 104
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Calculating the number of trailing zeros, the last five digits, and the first five digits can all be done separately. +
    + +
    +Hint 2 +Use a prime factorization property to find the number of trailing zeros. Use modulo to find the last 5 digits. Use a logarithm property to find the first 5 digits. +
    + +
    +Hint 3 +The number of trailing zeros C is nothing but the number of times the product is completely divisible by 10. Since 2 and 5 are the only prime factors of 10, C will be equal to the minimum number of times 2 or 5 appear in the prime factorization of the product. +
    + +
    +Hint 4 +Iterate through the integers from left to right. For every integer, keep dividing it by 2 as long as it is divisible by 2 and C occurrences of 2 haven't been removed in total. Repeat this process for 5. Finally, multiply the integer under modulo of 10^5 with the product obtained till now to obtain the last five digits. +
    + +
    +Hint 5 +The product P can be represented as P=10^(x+y) where x is the integral part and y is the fractional part of x+y. Using the property "if S = A * B, then log(S) = log(A) + log(B)", we can write x+y = log_10(P) = sum(log_10(i)) for each integer i in [left, right]. Once we obtain the sum, the first five digits can be represented as floor(10^(y+4)). +
    diff --git a/problems/accepted-candidates-from-the-interviews/README.md b/problems/accepted-candidates-from-the-interviews/README.md index 19d0072c0..b6aa925d5 100644 --- a/problems/accepted-candidates-from-the-interviews/README.md +++ b/problems/accepted-candidates-from-the-interviews/README.md @@ -9,7 +9,7 @@                  [Next >](../check-if-numbers-are-ascending-in-a-sentence "Check if Numbers Are Ascending in a Sentence") -## [2041. Accepted Candidates From the Interviews (Medium)](https://leetcode.com/problems/accepted-candidates-from-the-interviews "") +## [2041. Accepted Candidates From the Interviews (Medium)](https://leetcode.com/problems/accepted-candidates-from-the-interviews "面试中被录取的候选人") diff --git a/problems/account-balance/README.md b/problems/account-balance/README.md index ce0895597..a5dbfabc3 100644 --- a/problems/account-balance/README.md +++ b/problems/account-balance/README.md @@ -9,7 +9,7 @@                  [Next >](../number-of-equal-count-substrings "Number of Equal Count Substrings") -## [2066. Account Balance (Medium)](https://leetcode.com/problems/account-balance "") +## [2066. Account Balance (Medium)](https://leetcode.com/problems/account-balance "账户余额") diff --git a/problems/active-users/README.md b/problems/active-users/README.md index ba0038306..ef8762c21 100644 --- a/problems/active-users/README.md +++ b/problems/active-users/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-number-of-darts-inside-of-a-circular-dartboard "Maximum Number of Darts Inside of a Circular Dartboard") diff --git a/problems/add-minimum-number-of-rungs/README.md b/problems/add-minimum-number-of-rungs/README.md index a1e778ff4..75ced1a88 100644 --- a/problems/add-minimum-number-of-rungs/README.md +++ b/problems/add-minimum-number-of-rungs/README.md @@ -49,15 +49,6 @@ Add a rung at height 1 to climb this ladder. The ladder will now have rungs at [1,3,4,6,7].
    -

    Example 4:

    - -
    -Input: rungs = [5], dist = 10
    -Output: 0
    -Explanation:
    -This ladder can be climbed without adding additional rungs.
    -
    -

     

    Constraints:

    @@ -68,6 +59,10 @@ This ladder can be climbed without adding additional rungs.
  • rungs is strictly increasing.
  • +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + ### Hints
    Hint 1 diff --git a/problems/add-two-numbers/README.md b/problems/add-two-numbers/README.md index 5d07d51cf..4b8b6c228 100644 --- a/problems/add-two-numbers/README.md +++ b/problems/add-two-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-sum "Two Sum") diff --git a/problems/adding-spaces-to-a-string/README.md b/problems/adding-spaces-to-a-string/README.md new file mode 100644 index 000000000..2239ba4fd --- /dev/null +++ b/problems/adding-spaces-to-a-string/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../find-first-palindromic-string-in-the-array "Find First Palindromic String in the Array") +                 +[Next >](../number-of-smooth-descent-periods-of-a-stock "Number of Smooth Descent Periods of a Stock") + +## [2109. Adding Spaces to a String (Medium)](https://leetcode.com/problems/adding-spaces-to-a-string "向字符串添加空格") + +

    You are given a 0-indexed string s and a 0-indexed integer array spaces that describes the indices in the original string where spaces will be added. Each space should be inserted before the character at the given index.

    + +
      +
    • For example, given s = "EnjoyYourCoffee" and spaces = [5, 9], we place spaces before 'Y' and 'C', which are at indices 5 and 9 respectively. Thus, we obtain "Enjoy Your Coffee".
    • +
    + +

    Return the modified string after the spaces have been added.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "LeetcodeHelpsMeLearn", spaces = [8,13,15]
    +Output: "Leetcode Helps Me Learn"
    +Explanation: 
    +The indices 8, 13, and 15 correspond to the underlined characters in "LeetcodeHelpsMeLearn".
    +We then place spaces before those characters.
    +
    + +

    Example 2:

    + +
    +Input: s = "icodeinpython", spaces = [1,5,7,9]
    +Output: "i code in py thon"
    +Explanation:
    +The indices 1, 5, 7, and 9 correspond to the underlined characters in "icodeinpython".
    +We then place spaces before those characters.
    +
    + +

    Example 3:

    + +
    +Input: s = "spacing", spaces = [0,1,2,3,4,5,6]
    +Output: " s p a c i n g"
    +Explanation:
    +We are also able to place spaces before the first character of the string.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 3 * 105
    • +
    • s consists only of lowercase and uppercase English letters.
    • +
    • 1 <= spaces.length <= 3 * 105
    • +
    • 0 <= spaces[i] <= s.length - 1
    • +
    • All the values of spaces are strictly increasing.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Create a new string, initially empty, as the modified string. Iterate through the original string and append each character of the original string to the new string. However, each time you reach a character that requires a space before it, append a space before appending the character. +
    + +
    +Hint 2 +Since the array of indices for the space locations is sorted, use a pointer to keep track of the next index to place a space. Only increment the pointer once a space has been appended. +
    + +
    +Hint 3 +Ensure that your append operation can be done in O(1). +
    diff --git a/problems/ads-performance/README.md b/problems/ads-performance/README.md index 021d8c49e..6ab077012 100644 --- a/problems/ads-performance/README.md +++ b/problems/ads-performance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../restaurant-growth "Restaurant Growth") diff --git a/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md b/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md index e57869f6d..a91e1b097 100644 --- a/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md +++ b/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/README.md @@ -38,27 +38,13 @@ Explanation: "bob" used the keycard 3 times in a one-hour period ("21:00","21:20", "21:30"). -

    Example 3:

    - -
    -Input: keyName = ["john","john","john"], keyTime = ["23:58","23:59","00:01"]
    -Output: []
    -
    - -

    Example 4:

    - -
    -Input: keyName = ["leslie","leslie","leslie","clare","clare","clare","clare"], keyTime = ["13:00","13:20","14:00","18:00","18:51","19:30","19:49"]
    -Output: ["clare","leslie"]
    -
    -

     

    Constraints:

    • 1 <= keyName.length, keyTime.length <= 105
    • keyName.length == keyTime.length
    • -
    • keyTime[i] is in the format "HH:MM".
    • +
    • keyTime[i] is in the format "HH:MM".
    • [keyName[i], keyTime[i]] is unique.
    • 1 <= keyName[i].length <= 10
    • keyName[i] contains only lowercase English letters.
    • diff --git a/problems/all-divisions-with-the-highest-score-of-a-binary-array/README.md b/problems/all-divisions-with-the-highest-score-of-a-binary-array/README.md new file mode 100644 index 000000000..3e8ea2eca --- /dev/null +++ b/problems/all-divisions-with-the-highest-score-of-a-binary-array/README.md @@ -0,0 +1,92 @@ + + + + + + + +[< Previous](../keep-multiplying-found-values-by-two "Keep Multiplying Found Values by Two") +                 +[Next >](../find-substring-with-given-hash-value "Find Substring With Given Hash Value") + +## [2155. All Divisions With the Highest Score of a Binary Array (Medium)](https://leetcode.com/problems/all-divisions-with-the-highest-score-of-a-binary-array "分组得分最高的所有下标") + +

      You are given a 0-indexed binary array nums of length n. nums can be divided at index i (where 0 <= i <= n) into two arrays (possibly empty) numsleft and numsright:

      + +
        +
      • numsleft has all the elements of nums between index 0 and i - 1 (inclusive), while numsright has all the elements of nums between index i and n - 1 (inclusive).
      • +
      • If i == 0, numsleft is empty, while numsright has all the elements of nums.
      • +
      • If i == n, numsleft has all the elements of nums, while numsright is empty.
      • +
      + +

      The division score of an index i is the sum of the number of 0's in numsleft and the number of 1's in numsright.

      + +

      Return all distinct indices that have the highest possible division score. You may return the answer in any order.

      + +

       

      +

      Example 1:

      + +
      +Input: nums = [0,0,1,0]
      +Output: [2,4]
      +Explanation: Division at index
      +- 0: numsleft is []. numsright is [0,0,1,0]. The score is 0 + 1 = 1.
      +- 1: numsleft is [0]. numsright is [0,1,0]. The score is 1 + 1 = 2.
      +- 2: numsleft is [0,0]. numsright is [1,0]. The score is 2 + 1 = 3.
      +- 3: numsleft is [0,0,1]. numsright is [0]. The score is 2 + 0 = 2.
      +- 4: numsleft is [0,0,1,0]. numsright is []. The score is 3 + 0 = 3.
      +Indices 2 and 4 both have the highest possible division score 3.
      +Note the answer [4,2] would also be accepted.
      + +

      Example 2:

      + +
      +Input: nums = [0,0,0]
      +Output: [3]
      +Explanation: Division at index
      +- 0: numsleft is []. numsright is [0,0,0]. The score is 0 + 0 = 0.
      +- 1: numsleft is [0]. numsright is [0,0]. The score is 1 + 0 = 1.
      +- 2: numsleft is [0,0]. numsright is [0]. The score is 2 + 0 = 2.
      +- 3: numsleft is [0,0,0]. numsright is []. The score is 3 + 0 = 3.
      +Only index 3 has the highest possible division score 3.
      +
      + +

      Example 3:

      + +
      +Input: nums = [1,1]
      +Output: [0]
      +Explanation: Division at index
      +- 0: numsleft is []. numsright is [1,1]. The score is 0 + 2 = 2.
      +- 1: numsleft is [1]. numsright is [1]. The score is 0 + 1 = 1.
      +- 2: numsleft is [1,1]. numsright is []. The score is 0 + 0 = 0.
      +Only index 0 has the highest possible division score 2.
      +
      + +

       

      +

      Constraints:

      + +
        +
      • n == nums.length
      • +
      • 1 <= n <= 105
      • +
      • nums[i] is either 0 or 1.
      • +
      + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
      +Hint 1 +When you iterate the array, maintain the number of zeros and ones on the left side. Can you quickly calculate the number of ones on the right side? +
      + +
      +Hint 2 +The number of ones on the right side equals the number of ones in the whole array minus the number of ones on the left side. +
      + +
      +Hint 3 +Alternatively, you can quickly calculate it by using a prefix sum array. +
      diff --git a/problems/all-elements-in-two-binary-search-trees/README.md b/problems/all-elements-in-two-binary-search-trees/README.md index 3489830b3..add402354 100644 --- a/problems/all-elements-in-two-binary-search-trees/README.md +++ b/problems/all-elements-in-two-binary-search-trees/README.md @@ -11,9 +11,7 @@ ## [1305. All Elements in Two Binary Search Trees (Medium)](https://leetcode.com/problems/all-elements-in-two-binary-search-trees "两棵二叉搜索树中的所有元素") -

      Given two binary search trees root1 and root2.

      - -

      Return a list containing all the integers from both trees sorted in ascending order.

      +

      Given two binary search trees root1 and root2, return a list containing all the integers from both trees sorted in ascending order.

       

      Example 1:

      @@ -24,27 +22,6 @@

      Example 2:

      - -
      -Input: root1 = [0,-10,10], root2 = [5,1,7,0,2]
      -Output: [-10,0,0,1,2,5,7,10]
      -
      - -

      Example 3:

      - -
      -Input: root1 = [], root2 = [5,1,7,0,2]
      -Output: [0,1,2,5,7]
      -
      - -

      Example 4:

      - -
      -Input: root1 = [0,-10,10], root2 = []
      -Output: [-10,0,10]
      -
      - -

      Example 5:

       Input: root1 = [1,null,8], root2 = [8,1]
      @@ -55,8 +32,8 @@
       

      Constraints:

        -
      • Each tree has at most 5000 nodes.
      • -
      • Each node's value is between [-10^5, 10^5].
      • +
      • The number of nodes in each tree is in the range [0, 5000].
      • +
      • -105 <= Node.val <= 105
      ### Related Topics diff --git a/problems/all-oone-data-structure/README.md b/problems/all-oone-data-structure/README.md index c4c565fc7..b1bf3b3fc 100644 --- a/problems/all-oone-data-structure/README.md +++ b/problems/all-oone-data-structure/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../encode-n-ary-tree-to-binary-tree "Encode N-ary Tree to Binary Tree") @@ -55,7 +55,7 @@ allOne.getMinKey(); // return "leet"
    ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Design](../../tag/design/README.md)] [[Doubly-Linked List](../../tag/doubly-linked-list/README.md)] diff --git a/problems/all-possible-full-binary-trees/README.md b/problems/all-possible-full-binary-trees/README.md index 7d2cba86f..663028786 100644 --- a/problems/all-possible-full-binary-trees/README.md +++ b/problems/all-possible-full-binary-trees/README.md @@ -40,8 +40,8 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Tree](../../tag/tree/README.md)] [[Recursion](../../tag/recursion/README.md)] [[Memoization](../../tag/memoization/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/allocate-mailboxes/README.md b/problems/allocate-mailboxes/README.md index 5d982f082..b0bd29e7e 100644 --- a/problems/allocate-mailboxes/README.md +++ b/problems/allocate-mailboxes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-two-non-overlapping-sub-arrays-each-with-target-sum "Find Two Non-overlapping Sub-arrays Each With Target Sum") @@ -11,58 +11,38 @@ ## [1478. Allocate Mailboxes (Hard)](https://leetcode.com/problems/allocate-mailboxes "安排邮筒") -

    Given the array houses and an integer k. where houses[i] is the location of the ith house along a street, your task is to allocate k mailboxes in the street.

    +

    Given the array houses where houses[i] is the location of the ith house along a street and an integer k, allocate k mailboxes in the street.

    -

    Return the minimum total distance between each house and its nearest mailbox.

    +

    Return the minimum total distance between each house and its nearest mailbox.

    -

    The answer is guaranteed to fit in a 32-bit signed integer.

    +

    The test cases are generated so that the answer fits in a 32-bit integer.

     

    Example 1:

    - -

    - +
     Input: houses = [1,4,8,10,20], k = 3
     Output: 5
    -Explanation: Allocate mailboxes in position 3, 9 and 20.
    +Explanation: Allocate mailboxes in position 3, 9 and 20.
     Minimum total distance from each houses to nearest mailboxes is |3-1| + |4-3| + |9-8| + |10-9| + |20-20| = 5 
     

    Example 2:

    - -

    - +
     Input: houses = [2,3,5,12,18], k = 2
     Output: 9
    -Explanation: Allocate mailboxes in position 3 and 14.
    +Explanation: Allocate mailboxes in position 3 and 14.
     Minimum total distance from each houses to nearest mailboxes is |2-3| + |3-3| + |5-3| + |12-14| + |18-14| = 9.
     
    -

    Example 3:

    - -
    -Input: houses = [7,4,6,1], k = 1
    -Output: 8
    -
    - -

    Example 4:

    - -
    -Input: houses = [3,6,14,10], k = 4
    -Output: 0
    -
    -

     

    Constraints:

      -
    • n == houses.length
    • -
    • 1 <= n <= 100
    • -
    • 1 <= houses[i] <= 10^4
    • -
    • 1 <= k <= n
    • -
    • Array houses contain unique integers.
    • +
    • 1 <= k <= houses.length <= 100
    • +
    • 1 <= houses[i] <= 104
    • +
    • All the integers of houses are unique.
    ### Related Topics diff --git a/problems/amount-of-new-area-painted-each-day/README.md b/problems/amount-of-new-area-painted-each-day/README.md new file mode 100644 index 000000000..7af517b36 --- /dev/null +++ b/problems/amount-of-new-area-painted-each-day/README.md @@ -0,0 +1,40 @@ + + + + + + + +[< Previous](../groups-of-strings "Groups of Strings") +                 +[Next >](../order-two-columns-independently "Order Two Columns Independently") + +## [2158. Amount of New Area Painted Each Day (Hard)](https://leetcode.com/problems/amount-of-new-area-painted-each-day "") + + + +### Related Topics + [[Segment Tree](../../tag/segment-tree/README.md)] + [[Array](../../tag/array/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + +### Hints +
    +Hint 1 +What’s a good way to keep track of intervals that you have already painted? +
    + +
    +Hint 2 +Create an array of all 1’s, and when you have painted an interval, set the values in that interval to 0. +
    + +
    +Hint 3 +Using this array, how can you quickly calculate the amount of new area that you paint on a given day? +
    + +
    +Hint 4 +Calculate the sum of the new array in the interval that you paint. +
    diff --git a/problems/android-unlock-patterns/README.md b/problems/android-unlock-patterns/README.md index 9d96cd889..681daf4dc 100644 --- a/problems/android-unlock-patterns/README.md +++ b/problems/android-unlock-patterns/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../intersection-of-two-arrays-ii "Intersection of Two Arrays II") diff --git a/problems/apples-oranges/README.md b/problems/apples-oranges/README.md index be80dd0cb..61bfaa61e 100644 --- a/problems/apples-oranges/README.md +++ b/problems/apples-oranges/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-of-cutting-a-pizza "Number of Ways of Cutting a Pizza") diff --git a/problems/arithmetic-subarrays/README.md b/problems/arithmetic-subarrays/README.md index 5c34778f3..e38ff7b32 100644 --- a/problems/arithmetic-subarrays/README.md +++ b/problems/arithmetic-subarrays/README.md @@ -64,10 +64,6 @@ In the 2nd query, the subarray is [5,9,3,7]. This can be [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Arithmetic Slices](../arithmetic-slices) (Medium) - 1. [Can Make Arithmetic Progression From Sequence](../can-make-arithmetic-progression-from-sequence) (Easy) - ### Hints
    Hint 1 diff --git a/problems/armstrong-number/README.md b/problems/armstrong-number/README.md index 2a5aef613..6393d60cd 100644 --- a/problems/armstrong-number/README.md +++ b/problems/armstrong-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-unique-number "Largest Unique Number") diff --git a/problems/available-captures-for-rook/README.md b/problems/available-captures-for-rook/README.md index 6c4c5b748..d1375f510 100644 --- a/problems/available-captures-for-rook/README.md +++ b/problems/available-captures-for-rook/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-binary-tree-ii "Maximum Binary Tree II") diff --git a/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md b/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md index 1dcd53d41..239269d1b 100644 --- a/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md +++ b/problems/average-salary-excluding-the-minimum-and-maximum-salary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../clone-n-ary-tree "Clone N-ary Tree") @@ -11,9 +11,9 @@ ## [1491. Average Salary Excluding the Minimum and Maximum Salary (Easy)](https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary "去掉最低工资和最高工资后的工资平均值") -

    Given an array of unique integers salary where salary[i] is the salary of the employee i.

    +

    You are given an array of unique integers salary where salary[i] is the salary of the ith employee.

    -

    Return the average salary of employees excluding the minimum and maximum salary.

    +

    Return the average salary of employees excluding the minimum and maximum salary. Answers within 10-5 of the actual answer will be accepted.

     

    Example 1:

    @@ -21,8 +21,8 @@
     Input: salary = [4000,3000,1000,2000]
     Output: 2500.00000
    -Explanation: Minimum salary and maximum salary are 1000 and 4000 respectively.
    -Average salary excluding minimum and maximum salary is (2000+3000)/2= 2500
    +Explanation: Minimum salary and maximum salary are 1000 and 4000 respectively.
    +Average salary excluding minimum and maximum salary is (2000+3000) / 2 = 2500
     

    Example 2:

    @@ -30,22 +30,8 @@ Average salary excluding minimum and maximum salary is (2000+3000)/2= 2500
     Input: salary = [1000,2000,3000]
     Output: 2000.00000
    -Explanation: Minimum salary and maximum salary are 1000 and 3000 respectively.
    -Average salary excluding minimum and maximum salary is (2000)/1= 2000
    -
    - -

    Example 3:

    - -
    -Input: salary = [6000,5000,4000,3000,2000,1000]
    -Output: 3500.00000
    -
    - -

    Example 4:

    - -
    -Input: salary = [8000,9000,2000,3000,6000,1000]
    -Output: 4750.00000
    +Explanation: Minimum salary and maximum salary are 1000 and 3000 respectively.
    +Average salary excluding minimum and maximum salary is (2000) / 1 = 2000
     

     

    @@ -53,9 +39,8 @@ Average salary excluding minimum and maximum salary is (2000)/1= 2000
    • 3 <= salary.length <= 100
    • -
    • 10^3 <= salary[i] <= 10^6
    • -
    • salary[i] is unique.
    • -
    • Answers within 10^-5 of the actual value will be accepted as correct.
    • +
    • 1000 <= salary[i] <= 106
    • +
    • All the integers of salary are unique.
    ### Related Topics diff --git a/problems/average-waiting-time/README.md b/problems/average-waiting-time/README.md index ef5e69e93..d2cba9701 100644 --- a/problems/average-waiting-time/README.md +++ b/problems/average-waiting-time/README.md @@ -61,9 +61,6 @@ So the average waiting time = (2 + 6 + 4 + 1) / 4 = 3.25. [[Array](../../tag/array/README.md)] [[Simulation](../../tag/simulation/README.md)] -### Similar Questions - 1. [Average Height of Buildings in Each Segment](../average-height-of-buildings-in-each-segment) (Medium) - ### Hints
    Hint 1 diff --git a/problems/avoid-flood-in-the-city/README.md b/problems/avoid-flood-in-the-city/README.md index a691b24b6..fdd8339ce 100644 --- a/problems/avoid-flood-in-the-city/README.md +++ b/problems/avoid-flood-in-the-city/README.md @@ -25,7 +25,7 @@
    • ans.length == rains.length
    • ans[i] == -1 if rains[i] > 0.
    • -
    • ans[i] is the lake you choose to dry in the ith day if rains[i] == 0.
    • +
    • ans[i] is the lake you choose to dry in the ith day if rains[i] == 0.

    If there are multiple valid answers return any of them. If it is impossible to avoid flood return an empty array.

    @@ -68,22 +68,6 @@ It is easy that this scenario is flood-free. [-1,-1,1,2,-1,-1] is another accept After that, it will rain over lakes [1,2]. It's easy to prove that no matter which lake you choose to dry in the 3rd day, the other one will flood. -

    Example 4:

    - -
    -Input: rains = [69,0,0,0,69]
    -Output: [-1,69,1,1,-1]
    -Explanation: Any solution on one of the forms [-1,69,x,y,-1], [-1,x,69,y,-1] or [-1,x,y,69,-1] is acceptable where 1 <= x,y <= 10^9
    -
    - -

    Example 5:

    - -
    -Input: rains = [10,20,20]
    -Output: []
    -Explanation: It will rain over lake 20 two consecutive days. There is no chance to dry any lake.
    -
    -

     

    Constraints:

    diff --git a/problems/backspace-string-compare/README.md b/problems/backspace-string-compare/README.md index d11ab235a..e5ba9c09d 100644 --- a/problems/backspace-string-compare/README.md +++ b/problems/backspace-string-compare/README.md @@ -34,14 +34,6 @@

    Example 3:

    -
    -Input: s = "a##c", t = "#a#c"
    -Output: true
    -Explanation: Both s and t become "c".
    -
    - -

    Example 4:

    -
     Input: s = "a#c", t = "b"
     Output: false
    @@ -53,7 +45,7 @@
     
     
    • 1 <= s.length, t.length <= 200
    • -
    • s and t only contain lowercase letters and '#' characters.
    • +
    • s and t only contain lowercase letters and '#' characters.

     

    diff --git a/problems/bag-of-tokens/README.md b/problems/bag-of-tokens/README.md index 8b1f6e747..e5400398d 100644 --- a/problems/bag-of-tokens/README.md +++ b/problems/bag-of-tokens/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../most-stones-removed-with-same-row-or-column "Most Stones Removed with Same Row or Column") @@ -63,7 +63,7 @@ There is no need to play the 1st token since you cannot play it face ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] diff --git a/problems/battleships-in-a-board/README.md b/problems/battleships-in-a-board/README.md index 4fd781d03..0fd2ab0d2 100644 --- a/problems/battleships-in-a-board/README.md +++ b/problems/battleships-in-a-board/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sentence-screen-fitting "Sentence Screen Fitting") @@ -44,6 +44,6 @@

    Follow up: Could you do it in one-pass, using only O(1) extra memory and without modifying the values board?

    ### Related Topics - [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Array](../../tag/array/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/beautiful-arrangement/README.md b/problems/beautiful-arrangement/README.md index e9a44b8fa..054a56581 100644 --- a/problems/beautiful-arrangement/README.md +++ b/problems/beautiful-arrangement/README.md @@ -50,10 +50,10 @@ The second beautiful arrangement is [2,1]: ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] ### Similar Questions diff --git a/problems/best-position-for-a-service-centre/README.md b/problems/best-position-for-a-service-centre/README.md index 776cdd14f..224671215 100644 --- a/problems/best-position-for-a-service-centre/README.md +++ b/problems/best-position-for-a-service-centre/README.md @@ -11,13 +11,13 @@ ## [1515. Best Position for a Service Centre (Hard)](https://leetcode.com/problems/best-position-for-a-service-centre "服务中心的最佳位置") -

    A delivery company wants to build a new service centre in a new city. The company knows the positions of all the customers in this city on a 2D-Map and wants to build the new centre in a position such that the sum of the euclidean distances to all customers is minimum.

    +

    A delivery company wants to build a new service center in a new city. The company knows the positions of all the customers in this city on a 2D-Map and wants to build the new center in a position such that the sum of the euclidean distances to all customers is minimum.

    Given an array positions where positions[i] = [xi, yi] is the position of the ith customer on the map, return the minimum sum of the euclidean distances to all customers.

    -

    In other words, you need to choose the position of the service centre [xcentre, ycentre] such that the following formula is minimized:

    +

    In other words, you need to choose the position of the service center [xcentre, ycentre] such that the following formula is minimized:

    -

    Answers within 10^-5 of the actual value will be accepted.

    +

    Answers within 10-5 of the actual value will be accepted.

     

    Example 1:

    @@ -36,38 +36,13 @@ Explanation: The minimum possible sum of distances = sqrt(2) + sqrt(2) = 2.82843
    -

    Example 3:

    - -
    -Input: positions = [[1,1]]
    -Output: 0.00000
    -
    - -

    Example 4:

    - -
    -Input: positions = [[1,1],[0,0],[2,0]]
    -Output: 2.73205
    -Explanation: At the first glance, you may think that locating the centre at [1, 0] will achieve the minimum sum, but locating it at [1, 0] will make the sum of distances = 3.
    -Try to locate the centre at [1.0, 0.5773502711] you will see that the sum of distances is 2.73205.
    -Be careful with the precision!
    -
    - -

    Example 5:

    - -
    -Input: positions = [[0,1],[3,2],[4,5],[7,6],[8,9],[11,1],[2,12]]
    -Output: 32.94036
    -Explanation: You can use [4.3460852395, 4.9813795505] as the position of the centre.
    -
    -

     

    Constraints:

      -
    • 1 <= positions.length <= 50
    • +
    • 1 <= positions.length <= 50
    • positions[i].length == 2
    • -
    • 0 <= positions[i][0], positions[i][1] <= 100
    • +
    • 0 <= xi, yi <= 100
    ### Related Topics diff --git a/problems/best-time-to-buy-and-sell-stock-iii/README.md b/problems/best-time-to-buy-and-sell-stock-iii/README.md index 198700c20..aed420db4 100644 --- a/problems/best-time-to-buy-and-sell-stock-iii/README.md +++ b/problems/best-time-to-buy-and-sell-stock-iii/README.md @@ -43,13 +43,6 @@ Note that you cannot buy on day 1, buy on day 2 and sell them later, as you are Explanation: In this case, no transaction is done, i.e. max profit = 0. -

    Example 4:

    - -
    -Input: prices = [1]
    -Output: 0
    -
    -

     

    Constraints:

    diff --git a/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md b/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md index 654c0256f..199745595 100644 --- a/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md +++ b/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../subarray-product-less-than-k "Subarray Product Less Than K") @@ -48,9 +48,9 @@ The total profit is ((8 - 1) - 2) + ((9 - 4) - 2) = 8. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Similar Questions 1. [Best Time to Buy and Sell Stock II](../best-time-to-buy-and-sell-stock-ii) (Medium) diff --git a/problems/binary-number-with-alternating-bits/README.md b/problems/binary-number-with-alternating-bits/README.md index e1a0fdba1..c4e00c4fe 100644 --- a/problems/binary-number-with-alternating-bits/README.md +++ b/problems/binary-number-with-alternating-bits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../top-k-frequent-words "Top K Frequent Words") @@ -36,20 +36,6 @@ Output: false Explanation: The binary representation of 11 is: 1011. -

    Example 4:

    - -
    -Input: n = 10
    -Output: true
    -Explanation: The binary representation of 10 is: 1010.
    - -

    Example 5:

    - -
    -Input: n = 3
    -Output: false
    -
    -

     

    Constraints:

    diff --git a/problems/binary-searchable-numbers-in-an-unsorted-array/README.md b/problems/binary-searchable-numbers-in-an-unsorted-array/README.md index 456b220f6..6bebaaf0d 100644 --- a/problems/binary-searchable-numbers-in-an-unsorted-array/README.md +++ b/problems/binary-searchable-numbers-in-an-unsorted-array/README.md @@ -9,7 +9,7 @@                  [Next >](../number-of-strings-that-appear-as-substrings-in-word "Number of Strings That Appear as Substrings in Word") -## [1966. Binary Searchable Numbers in an Unsorted Array (Medium)](https://leetcode.com/problems/binary-searchable-numbers-in-an-unsorted-array "") +## [1966. Binary Searchable Numbers in an Unsorted Array (Medium)](https://leetcode.com/problems/binary-searchable-numbers-in-an-unsorted-array "未排序数组中的可被二分搜索的数") diff --git a/problems/binary-string-with-substrings-representing-1-to-n/README.md b/problems/binary-string-with-substrings-representing-1-to-n/README.md index 442d0a730..86dfded8d 100644 --- a/problems/binary-string-with-substrings-representing-1-to-n/README.md +++ b/problems/binary-string-with-substrings-representing-1-to-n/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-integer-divisible-by-k "Smallest Integer Divisible by K") diff --git a/problems/binary-subarrays-with-sum/README.md b/problems/binary-subarrays-with-sum/README.md index a618aad06..775b0833f 100644 --- a/problems/binary-subarrays-with-sum/README.md +++ b/problems/binary-subarrays-with-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../unique-email-addresses "Unique Email Addresses") @@ -47,5 +47,5 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] diff --git a/problems/binary-tree-level-order-traversal/README.md b/problems/binary-tree-level-order-traversal/README.md index 31bcd1c24..60197a3e7 100644 --- a/problems/binary-tree-level-order-traversal/README.md +++ b/problems/binary-tree-level-order-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../symmetric-tree "Symmetric Tree") diff --git a/problems/binary-tree-right-side-view/README.md b/problems/binary-tree-right-side-view/README.md index 792501a62..d005f8380 100644 --- a/problems/binary-tree-right-side-view/README.md +++ b/problems/binary-tree-right-side-view/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../house-robber "House Robber") diff --git a/problems/binary-tree-upside-down/README.md b/problems/binary-tree-upside-down/README.md index a3bf356be..9e4be9643 100644 --- a/problems/binary-tree-upside-down/README.md +++ b/problems/binary-tree-upside-down/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../min-stack "Min Stack") diff --git a/problems/binary-tree-vertical-order-traversal/README.md b/problems/binary-tree-vertical-order-traversal/README.md index 860aab5be..a23002120 100644 --- a/problems/binary-tree-vertical-order-traversal/README.md +++ b/problems/binary-tree-vertical-order-traversal/README.md @@ -90,10 +90,10 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/break-a-palindrome/README.md b/problems/break-a-palindrome/README.md index a6d34289d..aaaae4da1 100644 --- a/problems/break-a-palindrome/README.md +++ b/problems/break-a-palindrome/README.md @@ -35,19 +35,6 @@ Of all the ways, "aaccba" is the lexicographically smallest. Explanation: There is no way to replace a single character to make "a" not a palindrome, so return an empty string. -

    Example 3:

    - -
    -Input: palindrome = "aa"
    -Output: "ab"
    - -

    Example 4:

    - -
    -Input: palindrome = "aba"
    -Output: "abb"
    -
    -

     

    Constraints:

    diff --git a/problems/brightest-position-on-street/README.md b/problems/brightest-position-on-street/README.md index cf9a10f81..0aaf7cc50 100644 --- a/problems/brightest-position-on-street/README.md +++ b/problems/brightest-position-on-street/README.md @@ -9,7 +9,7 @@                  [Next >](../convert-1d-array-into-2d-array "Convert 1D Array Into 2D Array") -## [2021. Brightest Position on Street (Medium)](https://leetcode.com/problems/brightest-position-on-street "") +## [2021. Brightest Position on Street (Medium)](https://leetcode.com/problems/brightest-position-on-street "街上最亮的位置") diff --git a/problems/build-an-array-with-stack-operations/README.md b/problems/build-an-array-with-stack-operations/README.md index 60dd71263..15700b124 100644 --- a/problems/build-an-array-with-stack-operations/README.md +++ b/problems/build-an-array-with-stack-operations/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../evaluate-boolean-expression "Evaluate Boolean Expression") @@ -11,17 +11,19 @@ ## [1441. Build an Array With Stack Operations (Easy)](https://leetcode.com/problems/build-an-array-with-stack-operations "用栈操作构建数组") -

    Given an array target and an integer n. In each iteration, you will read a number from  list = {1,2,3..., n}.

    +

    You are given an array target and an integer n.

    -

    Build the target array using the following operations:

    +

    In each iteration, you will read a number from list = [1, 2, 3, ..., n].

    + +

    Build the target array using the following operations:

      -
    • Push: Read a new element from the beginning list, and push it in the array.
    • -
    • Pop: delete the last element of the array.
    • -
    • If the target array is already built, stop reading more elements.
    • +
    • "Push": Reads a new element from the beginning list, and pushes it in the array.
    • +
    • "Pop": Deletes the last element of the array.
    • +
    • If the target array is already built, stop reading more elements.
    -

    Return the operations to build the target array. You are guaranteed that the answer is unique.

    +

    Return a list of the operations needed to build target. The test cases are generated so that the answer is unique.

     

    Example 1:

    @@ -29,8 +31,8 @@
     Input: target = [1,3], n = 3
     Output: ["Push","Push","Pop","Push"]
    -Explanation: 
    -Read number 1 and automatically push in the array -> [1]
    +Explanation: 
    +Read number 1 and automatically push in the array -> [1]
     Read number 2 and automatically push in the array then Pop it -> [1]
     Read number 3 and automatically push in the array -> [1,3]
     
    @@ -47,14 +49,7 @@ Read number 3 and automatically push in the array -> [1,3]
     Input: target = [1,2], n = 4
     Output: ["Push","Push"]
    -Explanation: You only need to read the first 2 numbers and stop.
    -
    - -

    Example 4:

    - -
    -Input: target = [2,3,4], n = 4
    -Output: ["Push","Pop","Push","Push","Push"]
    +Explanation: You only need to read the first 2 numbers and stop.
     

     

    @@ -62,14 +57,14 @@ Read number 3 and automatically push in the array -> [1,3]
    • 1 <= target.length <= 100
    • -
    • 1 <= target[i] <= n
    • 1 <= n <= 100
    • -
    • target is strictly increasing.
    • +
    • 1 <= target[i] <= n
    • +
    • target is strictly increasing.
    ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] + [[Stack](../../tag/stack/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/build-binary-expression-tree-from-infix-expression/README.md b/problems/build-binary-expression-tree-from-infix-expression/README.md index fc0ee4558..ccb059a16 100644 --- a/problems/build-binary-expression-tree-from-infix-expression/README.md +++ b/problems/build-binary-expression-tree-from-infix-expression/README.md @@ -14,11 +14,15 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Tree](../../tag/tree/README.md)] - [[String](../../tag/string/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Basic Calculator III](../basic-calculator-iii) (Hard) + 1. [Check If Two Expression Trees are Equivalent](../check-if-two-expression-trees-are-equivalent) (Medium) + ### Hints
    Hint 1 diff --git a/problems/build-the-equation/README.md b/problems/build-the-equation/README.md new file mode 100644 index 000000000..1a035a2c2 --- /dev/null +++ b/problems/build-the-equation/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../abbreviating-the-product-of-a-range "Abbreviating the Product of a Range") +                 +[Next >](../a-number-after-a-double-reversal "A Number After a Double Reversal") + +## [2118. Build the Equation (Hard)](https://leetcode.com/problems/build-the-equation "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/build-the-equation/mysql_schemas.sql b/problems/build-the-equation/mysql_schemas.sql new file mode 100644 index 000000000..9cb986611 --- /dev/null +++ b/problems/build-the-equation/mysql_schemas.sql @@ -0,0 +1,5 @@ +Create table If Not Exists Terms (power int, factor int); +Truncate table Terms; +insert into Terms (power, factor) values ('2', '1'); +insert into Terms (power, factor) values ('1', '-4'); +insert into Terms (power, factor) values ('0', '2'); diff --git a/problems/burst-balloons/README.md b/problems/burst-balloons/README.md index e2fb7335a..d8143c649 100644 --- a/problems/burst-balloons/README.md +++ b/problems/burst-balloons/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sparse-matrix-multiplication "Sparse Matrix Multiplication") @@ -39,7 +39,7 @@ coins = 3*1*5 + 3*5*8 + 1*3*8 + 1*8*1 = 167
    • n == nums.length
    • -
    • 1 <= n <= 500
    • +
    • 1 <= n <= 300
    • 0 <= nums[i] <= 100
    diff --git a/problems/calculate-salaries/README.md b/problems/calculate-salaries/README.md index 23f8246eb..9f0654cc5 100644 --- a/problems/calculate-salaries/README.md +++ b/problems/calculate-salaries/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "Probability of a Two Boxes Having The Same Number of Distinct Balls") diff --git a/problems/campus-bikes/README.md b/problems/campus-bikes/README.md index ea7457295..6e99c5415 100644 --- a/problems/campus-bikes/README.md +++ b/problems/campus-bikes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../confusing-number "Confusing Number") diff --git a/problems/can-make-arithmetic-progression-from-sequence/README.md b/problems/can-make-arithmetic-progression-from-sequence/README.md index 92f0cbc72..8ab8e871e 100644 --- a/problems/can-make-arithmetic-progression-from-sequence/README.md +++ b/problems/can-make-arithmetic-progression-from-sequence/README.md @@ -44,6 +44,9 @@ [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Arithmetic Subarrays](../arithmetic-subarrays) (Medium) + ### Hints
    Hint 1 diff --git a/problems/can-make-palindrome-from-substring/README.md b/problems/can-make-palindrome-from-substring/README.md index e8a95283e..20ea8a9eb 100644 --- a/problems/can-make-palindrome-from-substring/README.md +++ b/problems/can-make-palindrome-from-substring/README.md @@ -51,14 +51,11 @@ queries[4]: substring = "abcda", could be changed to "abcba" ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] -### Similar Questions - 1. [Plates Between Candles](../plates-between-candles) (Medium) - ### Hints
    Hint 1 diff --git a/problems/capacity-to-ship-packages-within-d-days/README.md b/problems/capacity-to-ship-packages-within-d-days/README.md index b2df14c7d..7bb5aba1c 100644 --- a/problems/capacity-to-ship-packages-within-d-days/README.md +++ b/problems/capacity-to-ship-packages-within-d-days/README.md @@ -65,15 +65,9 @@ Note that the cargo must be shipped in the order given, so using a ship of capac ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Greedy](../../tag/greedy/README.md)] - -### Similar Questions - 1. [Split Array Largest Sum](../split-array-largest-sum) (Hard) - 1. [Divide Chocolate](../divide-chocolate) (Hard) - 1. [Cutting Ribbons](../cutting-ribbons) (Medium) - 1. [Minimized Maximum of Products Distributed to Any Store](../minimized-maximum-of-products-distributed-to-any-store) (Medium) ### Hints
    diff --git a/problems/capital-gainloss/README.md b/problems/capital-gainloss/README.md index 0529c1234..df3815de0 100644 --- a/problems/capital-gainloss/README.md +++ b/problems/capital-gainloss/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-happy-prefix "Longest Happy Prefix") diff --git a/problems/capitalize-the-title/README.md b/problems/capitalize-the-title/README.md new file mode 100644 index 000000000..390a33635 --- /dev/null +++ b/problems/capitalize-the-title/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../remove-all-ones-with-row-and-column-flips "Remove All Ones With Row and Column Flips") +                 +[Next >](../maximum-twin-sum-of-a-linked-list "Maximum Twin Sum of a Linked List") + +## [2129. Capitalize the Title (Easy)](https://leetcode.com/problems/capitalize-the-title "将标题首字母大写") + +

    You are given a string title consisting of one or more words separated by a single space, where each word consists of English letters. Capitalize the string by changing the capitalization of each word such that:

    + +
      +
    • If the length of the word is 1 or 2 letters, change all letters to lowercase.
    • +
    • Otherwise, change the first letter to uppercase and the remaining letters to lowercase.
    • +
    + +

    Return the capitalized title.

    + +

     

    +

    Example 1:

    + +
    +Input: title = "capiTalIze tHe titLe"
    +Output: "Capitalize The Title"
    +Explanation:
    +Since all the words have a length of at least 3, the first letter of each word is uppercase, and the remaining letters are lowercase.
    +
    + +

    Example 2:

    + +
    +Input: title = "First leTTeR of EACH Word"
    +Output: "First Letter of Each Word"
    +Explanation:
    +The word "of" has length 2, so it is all lowercase.
    +The remaining words have a length of at least 3, so the first letter of each remaining word is uppercase, and the remaining letters are lowercase.
    +
    + +

    Example 3:

    + +
    +Input: title = "i lOve leetcode"
    +Output: "i Love Leetcode"
    +Explanation:
    +The word "i" has length 1, so it is lowercase.
    +The remaining words have a length of at least 3, so the first letter of each remaining word is uppercase, and the remaining letters are lowercase.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= title.length <= 100
    • +
    • title consists of words separated by a single space without any leading or trailing spaces.
    • +
    • Each word consists of uppercase and lowercase English letters and is non-empty.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Firstly, try to find all the words present in the string. +
    + +
    +Hint 2 +On the basis of each word's lengths, simulate the process explained in Problem. +
    diff --git a/problems/car-fleet-ii/README.md b/problems/car-fleet-ii/README.md index dda2040c2..49ff94884 100644 --- a/problems/car-fleet-ii/README.md +++ b/problems/car-fleet-ii/README.md @@ -48,11 +48,14 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Monotonic Stack](../../tag/monotonic-stack/README.md)] + [[Stack](../../tag/stack/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] + +### Similar Questions + 1. [Car Fleet](../car-fleet) (Medium) ### Hints
    diff --git a/problems/car-pooling/README.md b/problems/car-pooling/README.md index 18852963e..ee4665fef 100644 --- a/problems/car-pooling/README.md +++ b/problems/car-pooling/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../statistics-from-a-large-sample "Statistics from a Large Sample") @@ -13,7 +13,7 @@

    There is a car with capacity empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west).

    -

    You are given the integer capacity and an array trips where trip[i] = [numPassengersi, fromi, toi] indicates that the ith trip has numPassengersi passengers and the locations to pick them up and drop them off are fromi and toi respectively. The locations are given as the number of kilometers due east from the car's initial location.

    +

    You are given the integer capacity and an array trips where trips[i] = [numPassengersi, fromi, toi] indicates that the ith trip has numPassengersi passengers and the locations to pick them up and drop them off are fromi and toi respectively. The locations are given as the number of kilometers due east from the car's initial location.

    Return true if it is possible to pick up and drop off all passengers for all the given trips, or false otherwise.

    @@ -32,20 +32,6 @@ Output: true -

    Example 3:

    - -
    -Input: trips = [[2,1,5],[3,5,7]], capacity = 3
    -Output: true
    -
    - -

    Example 4:

    - -
    -Input: trips = [[3,2,7],[3,7,9],[8,3,9]], capacity = 11
    -Output: true
    -
    -

     

    Constraints:

    diff --git a/problems/cat-and-mouse-ii/README.md b/problems/cat-and-mouse-ii/README.md index 1163fd2b3..87c97a15a 100644 --- a/problems/cat-and-mouse-ii/README.md +++ b/problems/cat-and-mouse-ii/README.md @@ -46,9 +46,7 @@

     

    Example 1:

    - -

    - +
     Input: grid = ["####F","#C...","M...."], catJump = 1, mouseJump = 2
     Output: true
    @@ -56,9 +54,7 @@
     

    Example 2:

    - -

    - +
     Input: grid = ["M.C...F"], catJump = 1, mouseJump = 4
     Output: true
    @@ -71,20 +67,6 @@
     Output: false
     
    -

    Example 4:

    - -
    -Input: grid = ["C...#","...#F","....#","M...."], catJump = 2, mouseJump = 5
    -Output: false
    -
    - -

    Example 5:

    - -
    -Input: grid = [".M...","..#..","#..#.","C#.#.","...#F"], catJump = 3, mouseJump = 1
    -Output: true
    -
    -

     

    Constraints:

    @@ -98,13 +80,17 @@ ### Related Topics + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] [[Memoization](../../tag/memoization/README.md)] - [[Math](../../tag/math/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Game Theory](../../tag/game-theory/README.md)] +### Similar Questions + 1. [Escape The Ghosts](../escape-the-ghosts) (Medium) + 1. [Cat and Mouse](../cat-and-mouse) (Hard) + ### Hints
    Hint 1 diff --git a/problems/cheapest-flights-within-k-stops/README.md b/problems/cheapest-flights-within-k-stops/README.md index b2cd7e7b3..04469ee9c 100644 --- a/problems/cheapest-flights-within-k-stops/README.md +++ b/problems/cheapest-flights-within-k-stops/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../k-th-smallest-prime-fraction "K-th Smallest Prime Fraction") diff --git a/problems/check-array-formation-through-concatenation/README.md b/problems/check-array-formation-through-concatenation/README.md index d010e77ab..21e3f6946 100644 --- a/problems/check-array-formation-through-concatenation/README.md +++ b/problems/check-array-formation-through-concatenation/README.md @@ -18,20 +18,13 @@

     

    Example 1:

    -
    -Input: arr = [85], pieces = [[85]]
    -Output: true
    -
    - -

    Example 2:

    -
     Input: arr = [15,88], pieces = [[88],[15]]
     Output: true
    -Explanation: Concatenate [15] then [88]
    +Explanation: Concatenate [15] then [88]
     
    -

    Example 3:

    +

    Example 2:

     Input: arr = [49,18,16], pieces = [[16,18,49]]
    @@ -39,18 +32,12 @@
     Explanation: Even though the numbers match, we cannot reorder pieces[0].
     
    -

    Example 4:

    +

    Example 3:

     Input: arr = [91,4,64,78], pieces = [[78],[4,64],[91]]
     Output: true
    -Explanation: Concatenate [91] then [4,64] then [78]
    - -

    Example 5:

    - -
    -Input: arr = [1,3,5,7], pieces = [[2,4,6,8]]
    -Output: false
    +Explanation: Concatenate [91] then [4,64] then [78]
     

     

    @@ -61,8 +48,8 @@
  • sum(pieces[i].length) == arr.length
  • 1 <= pieces[i].length <= arr.length
  • 1 <= arr[i], pieces[i][j] <= 100
  • -
  • The integers in arr are distinct.
  • -
  • The integers in pieces are distinct (i.e., If we flatten pieces in a 1D array, all the integers in this array are distinct).
  • +
  • The integers in arr are distinct.
  • +
  • The integers in pieces are distinct (i.e., If we flatten pieces in a 1D array, all the integers in this array are distinct).
  • ### Related Topics diff --git a/problems/check-if-a-parentheses-string-can-be-valid/README.md b/problems/check-if-a-parentheses-string-can-be-valid/README.md new file mode 100644 index 000000000..9145e429f --- /dev/null +++ b/problems/check-if-a-parentheses-string-can-be-valid/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../find-all-possible-recipes-from-given-supplies "Find All Possible Recipes from Given Supplies") +                 +[Next >](../abbreviating-the-product-of-a-range "Abbreviating the Product of a Range") + +## [2116. Check if a Parentheses String Can Be Valid (Medium)](https://leetcode.com/problems/check-if-a-parentheses-string-can-be-valid "判断一个括号字符串是否有效") + +

    A parentheses string is a non-empty string consisting only of '(' and ')'. It is valid if any of the following conditions is true:

    + +
      +
    • It is ().
    • +
    • It can be written as AB (A concatenated with B), where A and B are valid parentheses strings.
    • +
    • It can be written as (A), where A is a valid parentheses string.
    • +
    + +

    You are given a parentheses string s and a string locked, both of length n. locked is a binary string consisting only of '0's and '1's. For each index i of locked,

    + +
      +
    • If locked[i] is '1', you cannot change s[i].
    • +
    • But if locked[i] is '0', you can change s[i] to either '(' or ')'.
    • +
    + +

    Return true if you can make s a valid parentheses string. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "))()))", locked = "010100"
    +Output: true
    +Explanation: locked[1] == '1' and locked[3] == '1', so we cannot change s[1] or s[3].
    +We change s[0] and s[4] to '(' while leaving s[2] and s[5] unchanged to make s valid.
    + +

    Example 2:

    + +
    +Input: s = "()()", locked = "0000"
    +Output: true
    +Explanation: We do not need to make any changes because s is already valid.
    +
    + +

    Example 3:

    + +
    +Input: s = ")", locked = "0"
    +Output: false
    +Explanation: locked permits us to change s[0]. 
    +Changing s[0] to either '(' or ')' will not make s valid.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == s.length == locked.length
    • +
    • 1 <= n <= 105
    • +
    • s[i] is either '(' or ')'.
    • +
    • locked[i] is either '0' or '1'.
    • +
    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Can an odd length string ever be valid? +
    + +
    +Hint 2 +From left to right, if a locked ')' is encountered, it must be balanced with either a locked '(' or an unlocked index on its left. If neither exist, what conclusion can be drawn? If both exist, which one is more preferable to use? +
    + +
    +Hint 3 +After the above, we may have locked indices of '(' and additional unlocked indices. How can you balance out the locked '(' now? What if you cannot balance any locked '('? +
    diff --git a/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md b/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md index 9a2188d97..1e1302333 100644 --- a/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md +++ b/problems/check-if-a-string-contains-all-binary-codes-of-size-k/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../make-two-arrays-equal-by-reversing-sub-arrays "Make Two Arrays Equal by Reversing Sub-arrays") @@ -11,9 +11,7 @@ ## [1461. Check If a String Contains All Binary Codes of Size K (Medium)](https://leetcode.com/problems/check-if-a-string-contains-all-binary-codes-of-size-k "检查一个字符串是否包含所有长度为 K 的二进制子串") -

    Given a binary string s and an integer k.

    - -

    Return true if every binary code of length k is a substring of s. Otherwise, return false.

    +

    Given a binary string s and an integer k, return true if every binary code of length k is a substring of s. Otherwise, return false.

     

    Example 1:

    @@ -21,37 +19,23 @@
     Input: s = "00110110", k = 2
     Output: true
    -Explanation: The binary codes of length 2 are "00", "01", "10" and "11". They can be all found as substrings at indicies 0, 1, 3 and 2 respectively.
    +Explanation: The binary codes of length 2 are "00", "01", "10" and "11". They can be all found as substrings at indices 0, 1, 3 and 2 respectively.
     

    Example 2:

    -
    -Input: s = "00110", k = 2
    -Output: true
    -
    - -

    Example 3:

    -
     Input: s = "0110", k = 1
     Output: true
     Explanation: The binary codes of length 1 are "0" and "1", it is clear that both exist as a substring. 
     
    -

    Example 4:

    +

    Example 3:

     Input: s = "0110", k = 2
     Output: false
    -Explanation: The binary code "00" is of length 2 and doesn't exist in the array.
    -
    - -

    Example 5:

    - -
    -Input: s = "0000000001011100", k = 4
    -Output: false
    +Explanation: The binary code "00" is of length 2 and does not exist in the array.
     

     

    @@ -64,11 +48,11 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Hash Function](../../tag/hash-function/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Rolling Hash](../../tag/rolling-hash/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Hints
    diff --git a/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md b/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md index 68d50de68..95c2506ca 100644 --- a/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md +++ b/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../active-users "Active Users") @@ -42,20 +42,6 @@ Explanation: "you" is not a prefix of any word in the sentence. -

    Example 4:

    - -
    -Input: sentence = "i use triple pillow", searchWord = "pill"
    -Output: 4
    -
    - -

    Example 5:

    - -
    -Input: sentence = "hello from the other side", searchWord = "they"
    -Output: -1
    -
    -

     

    Constraints:

    diff --git a/problems/check-if-all-as-appears-before-all-bs/README.md b/problems/check-if-all-as-appears-before-all-bs/README.md new file mode 100644 index 000000000..a5c03bdf8 --- /dev/null +++ b/problems/check-if-all-as-appears-before-all-bs/README.md @@ -0,0 +1,66 @@ + + + + + + + +[< Previous](../minimum-operations-to-remove-adjacent-ones-in-matrix "Minimum Operations to Remove Adjacent Ones in Matrix") +                 +[Next >](../number-of-laser-beams-in-a-bank "Number of Laser Beams in a Bank") + +## [2124. Check if All A's Appears Before All B's (Easy)](https://leetcode.com/problems/check-if-all-as-appears-before-all-bs "检查是否所有 A 都在 B 之前") + +

    Given a string s consisting of only the characters 'a' and 'b', return true if every 'a' appears before every 'b' in the string. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "aaabbb"
    +Output: true
    +Explanation:
    +The 'a's are at indices 0, 1, and 2, while the 'b's are at indices 3, 4, and 5.
    +Hence, every 'a' appears before every 'b' and we return true.
    +
    + +

    Example 2:

    + +
    +Input: s = "abab"
    +Output: false
    +Explanation:
    +There is an 'a' at index 2 and a 'b' at index 1.
    +Hence, not every 'a' appears before every 'b' and we return false.
    +
    + +

    Example 3:

    + +
    +Input: s = "bbb"
    +Output: true
    +Explanation:
    +There are no 'a's, hence, every 'a' appears before every 'b' and we return true.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 100
    • +
    • s[i] is either 'a' or 'b'.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +You can check the opposite: check if there is a ‘b’ before an ‘a’. Then, negate and return that answer. +
    + +
    +Hint 2 +s should not have any occurrences of “ba” as a substring. +
    diff --git a/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md b/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md index d33963e44..aacdbbaa9 100644 --- a/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md +++ b/problems/check-if-all-characters-have-equal-number-of-occurrences/README.md @@ -46,6 +46,9 @@ [[String](../../tag/string/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Rings and Rods](../rings-and-rods) (Easy) + ### Hints
    Hint 1 diff --git a/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md b/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md index ce29c124c..caeebf97b 100644 --- a/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md +++ b/problems/check-if-an-original-string-exists-given-two-encoded-strings/README.md @@ -74,32 +74,6 @@ - The original string encoded as s2 must start with the letter 'c'. -

    Example 4:

    - -
    -Input: s1 = "112s", s2 = "g841"
    -Output: true
    -Explanation: It is possible that "gaaaaaaaaaaaas" was the original string
    -- "gaaaaaaaaaaaas"
    -  -> Split:      ["g", "aaaaaaaaaaaa", "s"]
    -  -> Replace:    ["1", "12",           "s"]
    -  -> Concatenate: "112s", which is s1.
    -- "gaaaaaaaaaaaas"
    -  -> Split:      ["g", "aaaaaaaa", "aaaa", "s"]
    -  -> Replace:    ["g", "8",        "4",    "1"]
    -  -> Concatenate: "g841", which is s2.
    -
    - -

    Example 5:

    - -
    -Input: s1 = "ab", s2 = "a2"
    -Output: false
    -Explanation: It is impossible.
    -- The original string encoded as s1 has two letters.
    -- The original string encoded as s2 has three letters.
    -
    -

     

    Constraints:

    diff --git a/problems/check-if-array-is-sorted-and-rotated/README.md b/problems/check-if-array-is-sorted-and-rotated/README.md index f10753e75..0db6947c5 100644 --- a/problems/check-if-array-is-sorted-and-rotated/README.md +++ b/problems/check-if-array-is-sorted-and-rotated/README.md @@ -44,24 +44,6 @@ You can rotate the array by x = 3 positions to begin on the the element of value You can rotate the array by x = 0 positions (i.e. no rotation) to make nums. -

    Example 4:

    - -
    -Input: nums = [1,1,1]
    -Output: true
    -Explanation: [1,1,1] is the original sorted array.
    -You can rotate any number of positions to make nums.
    -
    - -

    Example 5:

    - -
    -Input: nums = [2,1]
    -Output: true
    -Explanation: [1,2] is the original sorted array.
    -You can rotate the array by x = 5 positions to begin on the element of value 2: [2,1].
    -
    -

     

    Constraints:

    diff --git a/problems/check-if-array-pairs-are-divisible-by-k/README.md b/problems/check-if-array-pairs-are-divisible-by-k/README.md index 729dfd51c..2eeb96e92 100644 --- a/problems/check-if-array-pairs-are-divisible-by-k/README.md +++ b/problems/check-if-array-pairs-are-divisible-by-k/README.md @@ -13,9 +13,9 @@

    Given an array of integers arr of even length n and an integer k.

    -

    We want to divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k.

    +

    We want to divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k.

    -

    Return True If you can find a way to do that or False otherwise.

    +

    Return true If you can find a way to do that or false otherwise.

     

    Example 1:

    @@ -42,20 +42,6 @@ Explanation: You can try all possible pairs to see that there is no way to divide arr into 3 pairs each with sum divisible by 10. -

    Example 4:

    - -
    -Input: arr = [-10,10], k = 2
    -Output: true
    -
    - -

    Example 5:

    - -
    -Input: arr = [-1,1,-2,2,-3,3,-4,4], k = 3
    -Output: true
    -
    -

     

    Constraints:

    diff --git a/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md b/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md index 1306dc3e1..60756572a 100644 --- a/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md +++ b/problems/check-if-binary-string-has-at-most-one-segment-of-ones/README.md @@ -40,6 +40,9 @@ ### Related Topics [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Longer Contiguous Segments of Ones than Zeros](../longer-contiguous-segments-of-ones-than-zeros) (Easy) + ### Hints
    Hint 1 diff --git a/problems/check-if-every-row-and-column-contains-all-numbers/README.md b/problems/check-if-every-row-and-column-contains-all-numbers/README.md new file mode 100644 index 000000000..b3597801f --- /dev/null +++ b/problems/check-if-every-row-and-column-contains-all-numbers/README.md @@ -0,0 +1,60 @@ + + + + + + + +[< Previous](../stamping-the-grid "Stamping the Grid") +                 +[Next >](../minimum-swaps-to-group-all-1s-together-ii "Minimum Swaps to Group All 1's Together II") + +## [2133. Check if Every Row and Column Contains All Numbers (Easy)](https://leetcode.com/problems/check-if-every-row-and-column-contains-all-numbers "检查是否每一行每一列都包含全部整数") + +

    An n x n matrix is valid if every row and every column contains all the integers from 1 to n (inclusive).

    + +

    Given an n x n integer matrix matrix, return true if the matrix is valid. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: matrix = [[1,2,3],[3,1,2],[2,3,1]]
    +Output: true
    +Explanation: In this case, n = 3, and every row and column contains the numbers 1, 2, and 3.
    +Hence, we return true.
    +
    + +

    Example 2:

    + +
    +Input: matrix = [[1,1,1],[1,2,3],[1,2,3]]
    +Output: false
    +Explanation: In this case, n = 3, but the first row and the first column do not contain the numbers 2 or 3.
    +Hence, we return false.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == matrix.length == matrix[i].length
    • +
    • 1 <= n <= 100
    • +
    • 1 <= matrix[i][j] <= n
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Use for loops to check each row for every number from 1 to n. Similarly, do the same for each column. +
    + +
    +Hint 2 +For each check, you can keep a set of the unique elements in the checked row/col. By the end of the check, the size of the set should be n. +
    diff --git a/problems/check-if-n-and-its-double-exist/README.md b/problems/check-if-n-and-its-double-exist/README.md index 5eead7909..c54a20cf5 100644 --- a/problems/check-if-n-and-its-double-exist/README.md +++ b/problems/check-if-n-and-its-double-exist/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../jump-game-iv "Jump Game IV") @@ -61,6 +61,9 @@ [[Binary Search](../../tag/binary-search/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Keep Multiplying Found Values by Two](../keep-multiplying-found-values-by-two) (Easy) + ### Hints
    Hint 1 diff --git a/problems/check-if-numbers-are-ascending-in-a-sentence/README.md b/problems/check-if-numbers-are-ascending-in-a-sentence/README.md index 7c77fe501..f23398623 100644 --- a/problems/check-if-numbers-are-ascending-in-a-sentence/README.md +++ b/problems/check-if-numbers-are-ascending-in-a-sentence/README.md @@ -47,15 +47,6 @@ They are strictly increasing from left to right: 1 < 3 < 4 < 6 < 12. Explanation: The numbers in s are: 7, 51, 50, 60. They are not strictly increasing. -

    Example 4:

    - -
    -Input: s = "4 5 11 26"
    -Output: true
    -Explanation: The numbers in s are: 4, 5, 11, 26.
    -They are strictly increasing from left to right: 4 < 5 < 11 < 26.
    -
    -

     

    Constraints:

    diff --git a/problems/check-if-one-string-swap-can-make-strings-equal/README.md b/problems/check-if-one-string-swap-can-make-strings-equal/README.md index d278fdcd0..97904c0b9 100644 --- a/problems/check-if-one-string-swap-can-make-strings-equal/README.md +++ b/problems/check-if-one-string-swap-can-make-strings-equal/README.md @@ -40,13 +40,6 @@ Explanation: The two strings are already equal, so no string swap operation is required. -

    Example 4:

    - -
    -Input: s1 = "abcd", s2 = "dcba"
    -Output: false
    -
    -

     

    Constraints:

    @@ -61,6 +54,9 @@ [[String](../../tag/string/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Buddy Strings](../buddy-strings) (Easy) + ### Hints
    Hint 1 diff --git a/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md b/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md index 439964b1e..59a65dbb5 100644 --- a/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md +++ b/problems/check-if-string-is-transformable-with-substring-sort-operations/README.md @@ -11,17 +11,19 @@ ## [1585. Check If String Is Transformable With Substring Sort Operations (Hard)](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations "检查字符串是否可以通过排序子字符串得到另一个字符串") -

    Given two strings s and t, you want to transform string s into string t using the following operation any number of times:

    +

    Given two strings s and t, transform string s into string t using the following operation any number of times:

      -
    • Choose a non-empty substring in s and sort it in-place so the characters are in ascending order.
    • +
    • Choose a non-empty substring in s and sort it in place so the characters are in ascending order. +
        +
      • For example, applying the operation on the underlined substring in "14234" results in "12344".
      • +
      +
    -

    For example, applying the operation on the underlined substring in "14234" results in "12344".

    +

    Return true if it is possible to transform s into t. Otherwise, return false.

    -

    Return true if it is possible to transform string s into string t. Otherwise, return false.

    - -

    A substring is a contiguous sequence of characters within a string.

    +

    A substring is a contiguous sequence of characters within a string.

     

    Example 1:

    @@ -51,20 +53,13 @@ Output: false -

    Example 4:

    - -
    -Input: s = "1", t = "2"
    -Output: false
    -
    -

     

    Constraints:

    • s.length == t.length
    • 1 <= s.length <= 105
    • -
    • s and t only contain digits from '0' to '9'.
    • +
    • s and t consist of only digits.
    ### Related Topics diff --git a/problems/checking-existence-of-edge-length-limited-paths/README.md b/problems/checking-existence-of-edge-length-limited-paths/README.md index 86f617a92..cb9115df3 100644 --- a/problems/checking-existence-of-edge-length-limited-paths/README.md +++ b/problems/checking-existence-of-edge-length-limited-paths/README.md @@ -52,14 +52,11 @@ For the second query, there is a path (0 -> 1 -> 2) of two edges with dist ### Related Topics - [[Array](../../tag/array/README.md)] [[Union Find](../../tag/union-find/README.md)] [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Checking Existence of Edge Length Limited Paths II](../checking-existence-of-edge-length-limited-paths-ii) (Hard) - ### Hints
    Hint 1 diff --git a/problems/cherry-pickup-ii/README.md b/problems/cherry-pickup-ii/README.md index 0dac251a8..e44b8c7f0 100644 --- a/problems/cherry-pickup-ii/README.md +++ b/problems/cherry-pickup-ii/README.md @@ -11,61 +11,48 @@ ## [1463. Cherry Pickup II (Hard)](https://leetcode.com/problems/cherry-pickup-ii "摘樱桃 II") -

    Given a rows x cols matrix grid representing a field of cherries. Each cell in grid represents the number of cherries that you can collect.

    +

    You are given a rows x cols matrix grid representing a field of cherries where grid[i][j] represents the number of cherries that you can collect from the (i, j) cell.

    -

    You have two robots that can collect cherries for you, Robot #1 is located at the top-left corner (0,0) , and Robot #2 is located at the top-right corner (0, cols-1) of the grid.

    +

    You have two robots that can collect cherries for you:

    -

    Return the maximum number of cherries collection using both robots  by following the rules below:

    +
      +
    • Robot #1 is located at the top-left corner (0, 0), and
    • +
    • Robot #2 is located at the top-right corner (0, cols - 1).
    • +
    + +

    Return the maximum number of cherries collection using both robots by following the rules below:

      -
    • From a cell (i,j), robots can move to cell (i+1, j-1) , (i+1, j) or (i+1, j+1).
    • -
    • When any robot is passing through a cell, It picks it up all cherries, and the cell becomes an empty cell (0).
    • -
    • When both robots stay on the same cell, only one of them takes the cherries.
    • -
    • Both robots cannot move outside of the grid at any moment.
    • -
    • Both robots should reach the bottom row in the grid.
    • +
    • From a cell (i, j), robots can move to cell (i + 1, j - 1), (i + 1, j), or (i + 1, j + 1).
    • +
    • When any robot passes through a cell, It picks up all cherries, and the cell becomes an empty cell.
    • +
    • When both robots stay in the same cell, only one takes the cherries.
    • +
    • Both robots cannot move outside of the grid at any moment.
    • +
    • Both robots should reach the bottom row in grid.

     

    Example 1:

    - -

    - +
     Input: grid = [[3,1,1],[2,5,1],[1,5,5],[2,1,1]]
     Output: 24
    -Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
    +Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
     Cherries taken by Robot #1, (3 + 2 + 5 + 2) = 12.
     Cherries taken by Robot #2, (1 + 5 + 5 + 1) = 12.
     Total of cherries: 12 + 12 = 24.
     

    Example 2:

    - -

    - +
     Input: grid = [[1,0,0,0,0,0,1],[2,0,0,0,0,3,0],[2,0,9,0,0,0,0],[0,3,0,5,4,0,0],[1,0,2,3,0,0,6]]
     Output: 28
    -Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
    +Explanation: Path of robot #1 and #2 are described in color green and blue respectively.
     Cherries taken by Robot #1, (1 + 9 + 5 + 2) = 17.
     Cherries taken by Robot #2, (1 + 3 + 4 + 3) = 11.
     Total of cherries: 17 + 11 = 28.
     
    -

    Example 3:

    - -
    -Input: grid = [[1,0,0,3],[0,0,0,3],[0,0,3,3],[9,0,3,3]]
    -Output: 22
    -
    - -

    Example 4:

    - -
    -Input: grid = [[1,1],[1,1]]
    -Output: 4
    -
    -

     

    Constraints:

    @@ -73,7 +60,7 @@ Total of cherries: 17 + 11 = 28.
  • rows == grid.length
  • cols == grid[i].length
  • 2 <= rows, cols <= 70
  • -
  • 0 <= grid[i][j] <= 100 
  • +
  • 0 <= grid[i][j] <= 100
  • ### Related Topics diff --git a/problems/cherry-pickup/README.md b/problems/cherry-pickup/README.md index 25337a3d5..07f1b153f 100644 --- a/problems/cherry-pickup/README.md +++ b/problems/cherry-pickup/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-and-earn "Delete and Earn") diff --git a/problems/choose-numbers-from-two-arrays-in-range/README.md b/problems/choose-numbers-from-two-arrays-in-range/README.md new file mode 100644 index 000000000..d35ea7619 --- /dev/null +++ b/problems/choose-numbers-from-two-arrays-in-range/README.md @@ -0,0 +1,34 @@ + + + + + + + +[< Previous](../the-number-of-passengers-in-each-bus-i "The Number of Passengers in Each Bus I") +                 +[Next >](../minimum-cost-of-buying-candies-with-discount "Minimum Cost of Buying Candies With Discount") + +## [2143. Choose Numbers From Two Arrays in Range (Hard)](https://leetcode.com/problems/choose-numbers-from-two-arrays-in-range "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +If you know the possible sums you can get for a range [l, r], how can you use this information to calculate the possible sums you can get for a range [l, r + 1]? +
    + +
    +Hint 2 +For the range [l, r], if it is possible to choose elements such that the sum of elements you picked from nums1 is x and the sum of elements you picked from nums2 is y, then (x + nums1[r + 1], y) and (x, y + nums2[r + 1]) are possible sums you can get in the range [l, r + 1]. +
    + +
    +Hint 3 +How can we save the possible sums obtainable at a given index so that we can reuse this information later? +
    diff --git a/problems/cinema-seat-allocation/README.md b/problems/cinema-seat-allocation/README.md index b08c37802..2a9094e0f 100644 --- a/problems/cinema-seat-allocation/README.md +++ b/problems/cinema-seat-allocation/README.md @@ -57,10 +57,10 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Greedy](../../tag/greedy/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/circle-and-rectangle-overlapping/README.md b/problems/circle-and-rectangle-overlapping/README.md index 3f115e148..546cedeb1 100644 --- a/problems/circle-and-rectangle-overlapping/README.md +++ b/problems/circle-and-rectangle-overlapping/README.md @@ -11,61 +11,46 @@ ## [1401. Circle and Rectangle Overlapping (Medium)](https://leetcode.com/problems/circle-and-rectangle-overlapping "圆和矩形是否有重叠") -

    Given a circle represented as (radius, x_center, y_center) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the rectangle.

    +

    You are given a circle represented as (radius, xCenter, yCenter) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the rectangle.

    -

    Return True if the circle and rectangle are overlapped otherwise return False.

    - -

    In other words, check if there are any point (xi, yi) such that belongs to the circle and the rectangle at the same time.

    +

    Return true if the circle and rectangle are overlapped otherwise return false. In other words, check if there is any point (xi, yi) that belongs to the circle and the rectangle at the same time.

     

    Example 1:

    - -

    - +
    -Input: radius = 1, x_center = 0, y_center = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1
    +Input: radius = 1, xCenter = 0, yCenter = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1
     Output: true
    -Explanation: Circle and rectangle share the point (1,0) 
    +Explanation: Circle and rectangle share the point (1,0).
     

    Example 2:

    -

    -
    -Input: radius = 1, x_center = 0, y_center = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1
    -Output: true
    +Input: radius = 1, xCenter = 1, yCenter = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1
    +Output: false
     

    Example 3:

    - -

    - +
    -Input: radius = 1, x_center = 1, y_center = 1, x1 = -3, y1 = -3, x2 = 3, y2 = 3
    +Input: radius = 1, xCenter = 0, yCenter = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1
     Output: true
     
    -

    Example 4:

    - -
    -Input: radius = 1, x_center = 1, y_center = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1
    -Output: false
    -
    -

     

    Constraints:

    • 1 <= radius <= 2000
    • -
    • -10^4 <= x_center, y_center, x1, y1, x2, y2 <= 10^4
    • -
    • x1 < x2
    • -
    • y1 < y2
    • +
    • -104 <= xCenter, yCenter <= 104
    • +
    • -104 <= x1 < x2 <= 104
    • +
    • -104 <= y1 < y2 <= 104
    ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] ### Hints
    diff --git a/problems/clone-binary-tree-with-random-pointer/README.md b/problems/clone-binary-tree-with-random-pointer/README.md index dac353e67..e50978b09 100644 --- a/problems/clone-binary-tree-with-random-pointer/README.md +++ b/problems/clone-binary-tree-with-random-pointer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../group-sold-products-by-the-date "Group Sold Products By The Date") diff --git a/problems/clone-n-ary-tree/README.md b/problems/clone-n-ary-tree/README.md index 7ef16942f..d1d37b8bd 100644 --- a/problems/clone-n-ary-tree/README.md +++ b/problems/clone-n-ary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree "Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree") diff --git a/problems/closest-binary-search-tree-value/README.md b/problems/closest-binary-search-tree-value/README.md index e1c3da73f..6178001ff 100644 --- a/problems/closest-binary-search-tree-value/README.md +++ b/problems/closest-binary-search-tree-value/README.md @@ -35,10 +35,10 @@ ### Related Topics + [[Binary Search](../../tag/binary-search/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Search Tree](../../tag/binary-search-tree/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/closest-dessert-cost/README.md b/problems/closest-dessert-cost/README.md index 82b8f7617..876fe6d2c 100644 --- a/problems/closest-dessert-cost/README.md +++ b/problems/closest-dessert-cost/README.md @@ -65,13 +65,6 @@ Total: 3 + 4 + 10 + 0 = 17. You cannot make a dessert with a total cost of 18. Explanation: It is possible to make desserts with cost 8 and 10. Return 8 as it is the lower cost. -

    Example 4:

    - -
    -Input: baseCosts = [10], toppingCosts = [1], target = 1
    -Output: 10
    -Explanation: Notice that you don't have to have any toppings, but you must have exactly one base.
    -

     

    Constraints:

    diff --git a/problems/combination-sum-ii/README.md b/problems/combination-sum-ii/README.md index c99f3bcb8..fa8221b01 100644 --- a/problems/combination-sum-ii/README.md +++ b/problems/combination-sum-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../combination-sum "Combination Sum") diff --git a/problems/combination-sum/README.md b/problems/combination-sum/README.md index 9a823c811..14716ac29 100644 --- a/problems/combination-sum/README.md +++ b/problems/combination-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-and-say "Count and Say") @@ -43,20 +43,6 @@ These are the only two combinations. Output: [] -

    Example 4:

    - -
    -Input: candidates = [1], target = 1
    -Output: [[1]]
    -
    - -

    Example 5:

    - -
    -Input: candidates = [1], target = 2
    -Output: [[1,1]]
    -
    -

     

    Constraints:

    diff --git a/problems/complement-of-base-10-integer/README.md b/problems/complement-of-base-10-integer/README.md index ba166f6bd..8b3cbb658 100644 --- a/problems/complement-of-base-10-integer/README.md +++ b/problems/complement-of-base-10-integer/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-binary-search-tree-from-preorder-traversal "Construct Binary Search Tree from Preorder Traversal") diff --git a/problems/concatenation-of-consecutive-binary-numbers/README.md b/problems/concatenation-of-consecutive-binary-numbers/README.md index 1bd4d3bc7..c79a5b348 100644 --- a/problems/concatenation-of-consecutive-binary-numbers/README.md +++ b/problems/concatenation-of-consecutive-binary-numbers/README.md @@ -49,8 +49,8 @@ After modulo 109 + 7, the result is 505379714. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/consecutive-characters/README.md b/problems/consecutive-characters/README.md index 9ea25d484..c3ea0e124 100644 --- a/problems/consecutive-characters/README.md +++ b/problems/consecutive-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../apples-oranges "Apples & Oranges") @@ -32,27 +32,6 @@ Explanation: The substring "eeeee" is of length 5 with the character 'e' only. -

    Example 3:

    - -
    -Input: s = "triplepillooooow"
    -Output: 5
    -
    - -

    Example 4:

    - -
    -Input: s = "hooraaaaaaaaaaay"
    -Output: 11
    -
    - -

    Example 5:

    - -
    -Input: s = "tourist"
    -Output: 1
    -
    -

     

    Constraints:

    @@ -64,10 +43,6 @@ ### Related Topics [[String](../../tag/string/README.md)] -### Similar Questions - 1. [Max Consecutive Ones](../max-consecutive-ones) (Easy) - 1. [Count Number of Homogenous Substrings](../count-number-of-homogenous-substrings) (Medium) - ### Hints
    Hint 1 diff --git a/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md b/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md index 5271b0d6f..f48710384 100644 --- a/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md +++ b/problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-binary-tree-from-preorder-and-inorder-traversal "Construct Binary Tree from Preorder and Inorder Traversal") @@ -42,10 +42,10 @@ ### Related Topics - [[Tree](../../tag/tree/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Tree](../../tag/tree/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md b/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md index 37ae76162..eb1be2100 100644 --- a/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md +++ b/problems/construct-binary-tree-from-preorder-and-postorder-traversal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../fair-candy-swap "Fair Candy Swap") diff --git a/problems/construct-binary-tree-from-string/README.md b/problems/construct-binary-tree-from-string/README.md index 05bb73e4e..985211a95 100644 --- a/problems/construct-binary-tree-from-string/README.md +++ b/problems/construct-binary-tree-from-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../encode-and-decode-tinyurl "Encode and Decode TinyURL") @@ -38,9 +38,9 @@

    ### Related Topics + [[String](../../tag/string/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[String](../../tag/string/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/container-with-most-water/README.md b/problems/container-with-most-water/README.md index edfe43eec..b3b25e052 100644 --- a/problems/container-with-most-water/README.md +++ b/problems/container-with-most-water/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../regular-expression-matching "Regular Expression Matching") @@ -11,7 +11,11 @@ ## [11. Container With Most Water (Medium)](https://leetcode.com/problems/container-with-most-water "盛最多水的容器") -

    Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.

    +

    You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]).

    + +

    Find two lines that together with the x-axis form a container, such that the container contains the most water.

    + +

    Return the maximum amount of water a container can store.

    Notice that you may not slant the container.

    @@ -21,7 +25,7 @@
     Input: height = [1,8,6,2,5,4,8,3,7]
     Output: 49
    -Explanation: The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49.
    +Explanation: The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49.
     

    Example 2:

    @@ -31,20 +35,6 @@ Output: 1 -

    Example 3:

    - -
    -Input: height = [4,3,2,1,4]
    -Output: 16
    -
    - -

    Example 4:

    - -
    -Input: height = [1,2,1]
    -Output: 2
    -
    -

     

    Constraints:

    diff --git a/problems/contiguous-array/README.md b/problems/contiguous-array/README.md index b0b4dbc33..39dec4a3a 100644 --- a/problems/contiguous-array/README.md +++ b/problems/contiguous-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-word-in-dictionary-through-deleting "Longest Word in Dictionary through Deleting") diff --git a/problems/continuous-subarray-sum/README.md b/problems/continuous-subarray-sum/README.md index b70633b7c..f182bd82e 100644 --- a/problems/continuous-subarray-sum/README.md +++ b/problems/continuous-subarray-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-uncommon-subsequence-ii "Longest Uncommon Subsequence II") diff --git a/problems/convert-1d-array-into-2d-array/README.md b/problems/convert-1d-array-into-2d-array/README.md index 43070be5f..1a2c6e69f 100644 --- a/problems/convert-1d-array-into-2d-array/README.md +++ b/problems/convert-1d-array-into-2d-array/README.md @@ -23,8 +23,7 @@
     Input: original = [1,2,3,4], m = 2, n = 2
     Output: [[1,2],[3,4]]
    -Explanation:
    -The constructed 2D array should contain 2 rows and 2 columns.
    +Explanation: The constructed 2D array should contain 2 rows and 2 columns.
     The first group of n=2 elements in original, [1,2], becomes the first row in the constructed 2D array.
     The second group of n=2 elements in original, [3,4], becomes the second row in the constructed 2D array.
     
    @@ -34,8 +33,7 @@ The second group of n=2 elements in original, [3,4], becomes the second row in t
     Input: original = [1,2,3], m = 1, n = 3
     Output: [[1,2,3]]
    -Explanation:
    -The constructed 2D array should contain 1 row and 3 columns.
    +Explanation: The constructed 2D array should contain 1 row and 3 columns.
     Put all three elements in original into the first row of the constructed 2D array.
     
    @@ -44,21 +42,10 @@ Put all three elements in original into the first row of the constructed 2D arra
     Input: original = [1,2], m = 1, n = 1
     Output: []
    -Explanation:
    -There are 2 elements in original.
    +Explanation: There are 2 elements in original.
     It is impossible to fit 2 elements in a 1x1 2D array, so return an empty 2D array.
     
    -

    Example 4:

    - -
    -Input: original = [3], m = 1, n = 2
    -Output: []
    -Explanation:
    -There is 1 element in original.
    -It is impossible to make 1 element fill all the spots in a 1x2 2D array, so return an empty 2D array.
    -
    -

     

    Constraints:

    diff --git a/problems/convert-bst-to-greater-tree/README.md b/problems/convert-bst-to-greater-tree/README.md index 203b61449..d29540249 100644 --- a/problems/convert-bst-to-greater-tree/README.md +++ b/problems/convert-bst-to-greater-tree/README.md @@ -23,7 +23,7 @@

     

    Example 1:

    - +
     Input: root = [4,1,6,0,2,5,7,null,null,null,3,null,null,null,8]
     Output: [30,36,21,36,35,26,15,null,null,null,33,null,null,null,8]
    @@ -36,20 +36,6 @@
     Output: [1,null,1]
     
    -

    Example 3:

    - -
    -Input: root = [1,0,2]
    -Output: [3,3,2]
    -
    - -

    Example 4:

    - -
    -Input: root = [3,2,4,1]
    -Output: [7,9,4,10]
    -
    -

     

    Constraints:

    diff --git a/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md b/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md index 7f0be835b..c06050fea 100644 --- a/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md +++ b/problems/convert-integer-to-the-sum-of-two-no-zero-integers/README.md @@ -11,16 +11,16 @@ ## [1317. Convert Integer to the Sum of Two No-Zero Integers (Easy)](https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers "将整数转换为两个无零整数的和") -

    Given an integer n. No-Zero integer is a positive integer which doesn't contain any 0 in its decimal representation.

    +

    No-Zero integer is a positive integer that does not contain any 0 in its decimal representation.

    -

    Return a list of two integers [A, B] where:

    +

    Given an integer n, return a list of two integers [A, B] where:

      -
    • A and B are No-Zero integers.
    • +
    • A and B are No-Zero integers.
    • A + B = n
    -

    It's guarateed that there is at least one valid solution. If there are many valid solutions you can return any of them.

    +

    The test cases are generated so that there is at least one valid solution. If there are many valid solutions you can return any of them.

     

    Example 1:

    @@ -28,7 +28,7 @@
     Input: n = 2
     Output: [1,1]
    -Explanation: A = 1, B = 1. A + B = n and both A and B don't contain any 0 in their decimal representation.
    +Explanation: A = 1, B = 1. A + B = n and both A and B do not contain any 0 in their decimal representation.
     

    Example 2:

    @@ -38,32 +38,11 @@ Output: [2,9] -

    Example 3:

    - -
    -Input: n = 10000
    -Output: [1,9999]
    -
    - -

    Example 4:

    - -
    -Input: n = 69
    -Output: [1,68]
    -
    - -

    Example 5:

    - -
    -Input: n = 1010
    -Output: [11,999]
    -
    -

     

    Constraints:

      -
    • 2 <= n <= 10^4
    • +
    • 2 <= n <= 104
    ### Related Topics diff --git a/problems/convert-sorted-array-to-binary-search-tree/README.md b/problems/convert-sorted-array-to-binary-search-tree/README.md index 1a722bd23..83415f923 100644 --- a/problems/convert-sorted-array-to-binary-search-tree/README.md +++ b/problems/convert-sorted-array-to-binary-search-tree/README.md @@ -43,10 +43,10 @@ ### Related Topics - [[Tree](../../tag/tree/README.md)] - [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Array](../../tag/array/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/convert-sorted-list-to-binary-search-tree/README.md b/problems/convert-sorted-list-to-binary-search-tree/README.md index e3261f6d8..e91c9b31d 100644 --- a/problems/convert-sorted-list-to-binary-search-tree/README.md +++ b/problems/convert-sorted-list-to-binary-search-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convert-sorted-array-to-binary-search-tree "Convert Sorted Array to Binary Search Tree") @@ -17,7 +17,7 @@

     

    Example 1:

    - +
     Input: head = [-10,-3,0,5,9]
     Output: [0,-3,9,-10,null,5]
    @@ -31,20 +31,6 @@
     Output: []
     
    -

    Example 3:

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

    Example 4:

    - -
    -Input: head = [1,3]
    -Output: [3,1]
    -
    -

     

    Constraints:

    diff --git a/problems/coordinate-with-maximum-network-quality/README.md b/problems/coordinate-with-maximum-network-quality/README.md index 91f1ce025..6ada4d259 100644 --- a/problems/coordinate-with-maximum-network-quality/README.md +++ b/problems/coordinate-with-maximum-network-quality/README.md @@ -59,23 +59,6 @@ No other coordinate has a higher network quality. Explanation: Coordinate (1, 2) has the highest network quality. -

    Example 4:

    - -
    -Input: towers = [[2,1,9],[0,1,9]], radius = 2
    -Output: [0,1]
    -Explanation: Both (0, 1) and (2, 1) are optimal in terms of quality, but (0, 1) is lexicographically minimal.
    -
    - -

    Example 5:

    - -
    -Input: towers = [[42,0,0]], radius = 7
    -Output: [0,0]
    -Explanation: The network quality is 0 at every coordinate, even at the tower's location.
    -Thus, the lexicographically minimum non-negative coordinate is (0, 0).
    -
    -

     

    Constraints:

    diff --git a/problems/corporate-flight-bookings/README.md b/problems/corporate-flight-bookings/README.md index e48e88b45..63e874b4c 100644 --- a/problems/corporate-flight-bookings/README.md +++ b/problems/corporate-flight-bookings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../defanging-an-ip-address "Defanging an IP Address") diff --git a/problems/count-all-possible-routes/README.md b/problems/count-all-possible-routes/README.md index 9dfddc3fe..5de9e8ec3 100644 --- a/problems/count-all-possible-routes/README.md +++ b/problems/count-all-possible-routes/README.md @@ -25,7 +25,7 @@
     Input: locations = [2,3,6,8,4], start = 1, finish = 3, fuel = 5
     Output: 4
    -Explanation: The following are all possible routes, each uses 5 units of fuel:
    +Explanation: The following are all possible routes, each uses 5 units of fuel:
     1 -> 3
     1 -> 2 -> 3
     1 -> 4 -> 3
    @@ -37,7 +37,7 @@
     
     Input: locations = [4,3,1], start = 1, finish = 0, fuel = 6
     Output: 5
    -Explanation: The following are all possible routes:
    +Explanation: The following are all possible routes:
     1 -> 0, used fuel = 1
     1 -> 2 -> 0, used fuel = 5
     1 -> 2 -> 1 -> 0, used fuel = 5
    @@ -50,21 +50,7 @@
     
     Input: locations = [5,2,1], start = 0, finish = 2, fuel = 3
     Output: 0
    -Explanation: It's impossible to get from 0 to 2 using only 3 units of fuel since the shortest route needs 4 units of fuel.
    - -

    Example 4:

    - -
    -Input: locations = [2,1,5], start = 0, finish = 0, fuel = 3
    -Output: 2
    -Explanation: There are two possible routes, 0 and 0 -> 1 -> 0.
    - -

    Example 5:

    - -
    -Input: locations = [1,2,3], start = 0, finish = 2, fuel = 40
    -Output: 615088286
    -Explanation: The total number of possible routes is 2615088300. Taking this number modulo 10^9 + 7 gives us 615088286.
    +Explanation: It is impossible to get from 0 to 2 using only 3 units of fuel since the shortest route needs 4 units of fuel.
     

     

    @@ -79,9 +65,9 @@ ### Related Topics - [[Memoization](../../tag/memoization/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Memoization](../../tag/memoization/README.md)] ### Hints
    diff --git a/problems/count-all-valid-pickup-and-delivery-options/README.md b/problems/count-all-valid-pickup-and-delivery-options/README.md index 2ff24eb41..32cda0c3e 100644 --- a/problems/count-all-valid-pickup-and-delivery-options/README.md +++ b/problems/count-all-valid-pickup-and-delivery-options/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-substrings-containing-all-three-characters "Number of Substrings Containing All Three Characters") diff --git a/problems/count-binary-substrings/README.md b/problems/count-binary-substrings/README.md index 42e1f4151..de93a8d21 100644 --- a/problems/count-binary-substrings/README.md +++ b/problems/count-binary-substrings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-area-of-island "Max Area of Island") diff --git a/problems/count-common-words-with-one-occurrence/README.md b/problems/count-common-words-with-one-occurrence/README.md new file mode 100644 index 000000000..776b6f8bc --- /dev/null +++ b/problems/count-common-words-with-one-occurrence/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../drop-type-1-orders-for-customers-with-type-0-orders "Drop Type 1 Orders for Customers With Type 0 Orders") +                 +[Next >](../minimum-number-of-buckets-required-to-collect-rainwater-from-houses "Minimum Number of Buckets Required to Collect Rainwater from Houses") + +## [2085. Count Common Words With One Occurrence (Easy)](https://leetcode.com/problems/count-common-words-with-one-occurrence "统计出现过一次的公共字符串") + +

    Given two string arrays words1 and words2, return the number of strings that appear exactly once in each of the two arrays.

    + +

     

    +

    Example 1:

    + +
    +Input: words1 = ["leetcode","is","amazing","as","is"], words2 = ["amazing","leetcode","is"]
    +Output: 2
    +Explanation:
    +- "leetcode" appears exactly once in each of the two arrays. We count this string.
    +- "amazing" appears exactly once in each of the two arrays. We count this string.
    +- "is" appears in each of the two arrays, but there are 2 occurrences of it in words1. We do not count this string.
    +- "as" appears once in words1, but does not appear in words2. We do not count this string.
    +Thus, there are 2 strings that appear exactly once in each of the two arrays.
    +
    + +

    Example 2:

    + +
    +Input: words1 = ["b","bb","bbb"], words2 = ["a","aa","aaa"]
    +Output: 0
    +Explanation: There are no strings that appear in each of the two arrays.
    +
    + +

    Example 3:

    + +
    +Input: words1 = ["a","ab"], words2 = ["a","a","a","ab"]
    +Output: 1
    +Explanation: The only string that appears exactly once in each of the two arrays is "ab".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words1.length, words2.length <= 1000
    • +
    • 1 <= words1[i].length, words2[j].length <= 30
    • +
    • words1[i] and words2[j] consists only of lowercase English letters.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Hints +
    +Hint 1 +Could you try every word? +
    + +
    +Hint 2 +Could you use a hash map to achieve a good complexity? +
    diff --git a/problems/count-different-palindromic-subsequences/README.md b/problems/count-different-palindromic-subsequences/README.md index ffc4a31e6..c0d8334f8 100644 --- a/problems/count-different-palindromic-subsequences/README.md +++ b/problems/count-different-palindromic-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../my-calendar-i "My Calendar I") diff --git a/problems/count-elements-with-strictly-smaller-and-greater-elements/README.md b/problems/count-elements-with-strictly-smaller-and-greater-elements/README.md new file mode 100644 index 000000000..199267f0b --- /dev/null +++ b/problems/count-elements-with-strictly-smaller-and-greater-elements/README.md @@ -0,0 +1,62 @@ + + + + + + + +[< Previous](../number-of-ways-to-divide-a-long-corridor "Number of Ways to Divide a Long Corridor") +                 +[Next >](../rearrange-array-elements-by-sign "Rearrange Array Elements by Sign") + +## [2148. Count Elements With Strictly Smaller and Greater Elements (Easy)](https://leetcode.com/problems/count-elements-with-strictly-smaller-and-greater-elements "元素计数") + +

    Given an integer array nums, return the number of elements that have both a strictly smaller and a strictly greater element appear in nums.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [11,7,2,15]
    +Output: 2
    +Explanation: The element 7 has the element 2 strictly smaller than it and the element 11 strictly greater than it.
    +Element 11 has element 7 strictly smaller than it and element 15 strictly greater than it.
    +In total there are 2 elements having both a strictly smaller and a strictly greater element appear in nums.
    +
    + +

    Example 2:

    + +
    +Input: nums = [-3,3,3,90]
    +Output: 2
    +Explanation: The element 3 has the element -3 strictly smaller than it and the element 90 strictly greater than it.
    +Since there are two elements with the value 3, in total there are 2 elements having both a strictly smaller and a strictly greater element appear in nums.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • -105 <= nums[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +All the elements in the array should be counted except for the minimum and maximum elements. +
    + +
    +Hint 2 +If the array has n elements, the answer will be n - count(min(nums)) - count(max(nums)) +
    + +
    +Hint 3 +This formula will not work in case the array has all the elements equal, why? +
    diff --git a/problems/count-fertile-pyramids-in-a-land/README.md b/problems/count-fertile-pyramids-in-a-land/README.md new file mode 100644 index 000000000..9e438e6a1 --- /dev/null +++ b/problems/count-fertile-pyramids-in-a-land/README.md @@ -0,0 +1,99 @@ + + + + + + + +[< Previous](../minimum-cost-homecoming-of-a-robot-in-a-grid "Minimum Cost Homecoming of a Robot in a Grid") +                 +[Next >](../find-target-indices-after-sorting-array "Find Target Indices After Sorting Array") + +## [2088. Count Fertile Pyramids in a Land (Hard)](https://leetcode.com/problems/count-fertile-pyramids-in-a-land "统计农场中肥沃金字塔的数目") + +

    A farmer has a rectangular grid of land with m rows and n columns that can be divided into unit cells. Each cell is either fertile (represented by a 1) or barren (represented by a 0). All cells outside the grid are considered barren.

    + +

    A pyramidal plot of land can be defined as a set of cells with the following criteria:

    + +
      +
    1. The number of cells in the set has to be greater than 1 and all cells must be fertile.
    2. +
    3. The apex of a pyramid is the topmost cell of the pyramid. The height of a pyramid is the number of rows it covers. Let (r, c) be the apex of the pyramid, and its height be h. Then, the plot comprises of cells (i, j) where r <= i <= r + h - 1 and c - (i - r) <= j <= c + (i - r).
    4. +
    + +

    An inverse pyramidal plot of land can be defined as a set of cells with similar criteria:

    + +
      +
    1. The number of cells in the set has to be greater than 1 and all cells must be fertile.
    2. +
    3. The apex of an inverse pyramid is the bottommost cell of the inverse pyramid. The height of an inverse pyramid is the number of rows it covers. Let (r, c) be the apex of the pyramid, and its height be h. Then, the plot comprises of cells (i, j) where r - h + 1 <= i <= r and c - (r - i) <= j <= c + (r - i).
    4. +
    + +

    Some examples of valid and invalid pyramidal (and inverse pyramidal) plots are shown below. Black cells indicate fertile cells.

    + +

    Given a 0-indexed m x n binary matrix grid representing the farmland, return the total number of pyramidal and inverse pyramidal plots that can be found in grid.

    + +

     

    +

    Example 1:

    + +
    +Input: grid = [[0,1,1,0],[1,1,1,1]]
    +Output: 2
    +Explanation: The 2 possible pyramidal plots are shown in blue and red respectively.
    +There are no inverse pyramidal plots in this grid. 
    +Hence total number of pyramidal and inverse pyramidal plots is 2 + 0 = 2.
    +
    + +

    Example 2:

    + +
    +Input: grid = [[1,1,1],[1,1,1]]
    +Output: 2
    +Explanation: The pyramidal plot is shown in blue, and the inverse pyramidal plot is shown in red. 
    +Hence the total number of plots is 1 + 1 = 2.
    +
    + +

    Example 3:

    + +
    +Input: grid = [[1,1,1,1,0],[1,1,1,1,1],[1,1,1,1,1],[0,1,0,0,1]]
    +Output: 13
    +Explanation: There are 7 pyramidal plots, 3 of which are shown in the 2nd and 3rd figures.
    +There are 6 inverse pyramidal plots, 2 of which are shown in the last figure.
    +The total number of plots is 7 + 6 = 13.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 1000
    • +
    • 1 <= m * n <= 105
    • +
    • grid[i][j] is either 0 or 1.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Think about how dynamic programming can help solve the problem. +
    + +
    +Hint 2 +For any fixed cell (r, c), can you calculate the maximum height of the pyramid for which it is the apex? Let us denote this value as dp[r][c]. +
    + +
    +Hint 3 +How will the values at dp[r+1][c-1] and dp[r+1][c+1] help in determining the value at dp[r][c]? +
    + +
    +Hint 4 +For the cell (r, c), is there a relation between the number of pyramids for which it serves as the apex and dp[r][c]? How does it help in calculating the answer? +
    diff --git a/problems/count-good-meals/README.md b/problems/count-good-meals/README.md index a79cf7106..472223138 100644 --- a/problems/count-good-meals/README.md +++ b/problems/count-good-meals/README.md @@ -48,6 +48,11 @@ Their respective sums are 4, 8, 8, and 16, all of which are powers of 2. [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] +### Similar Questions + 1. [Two Sum](../two-sum) (Easy) + 1. [Max Number of K-Sum Pairs](../max-number-of-k-sum-pairs) (Medium) + 1. [Find All Possible Recipes from Given Supplies](../find-all-possible-recipes-from-given-supplies) (Medium) + ### Hints
    Hint 1 diff --git a/problems/count-good-nodes-in-binary-tree/README.md b/problems/count-good-nodes-in-binary-tree/README.md index acab1defb..4a8baa459 100644 --- a/problems/count-good-nodes-in-binary-tree/README.md +++ b/problems/count-good-nodes-in-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../simplified-fractions "Simplified Fractions") diff --git a/problems/count-good-triplets/README.md b/problems/count-good-triplets/README.md index 782b76d51..10a302420 100644 --- a/problems/count-good-triplets/README.md +++ b/problems/count-good-triplets/README.md @@ -56,9 +56,6 @@ [[Array](../../tag/array/README.md)] [[Enumeration](../../tag/enumeration/README.md)] -### Similar Questions - 1. [Count Special Quadruplets](../count-special-quadruplets) (Easy) - ### Hints
    Hint 1 diff --git a/problems/count-largest-group/README.md b/problems/count-largest-group/README.md index 577545eae..38160b260 100644 --- a/problems/count-largest-group/README.md +++ b/problems/count-largest-group/README.md @@ -11,9 +11,11 @@ ## [1399. Count Largest Group (Easy)](https://leetcode.com/problems/count-largest-group "统计最大组的数目") -

    Given an integer n. Each number from 1 to n is grouped according to the sum of its digits. 

    +

    You are given an integer n.

    -

    Return how many groups have the largest size.

    +

    Each number from 1 to n is grouped according to the sum of its digits.

    + +

    Return the number of groups that have the largest size.

     

    Example 1:

    @@ -22,7 +24,8 @@ Input: n = 13 Output: 4 Explanation: There are 9 groups in total, they are grouped according sum of its digits of numbers from 1 to 13: -[1,10], [2,11], [3,12], [4,13], [5], [6], [7], [8], [9]. There are 4 groups with largest size. +[1,10], [2,11], [3,12], [4,13], [5], [6], [7], [8], [9]. +There are 4 groups with largest size.

    Example 2:

    @@ -33,25 +36,11 @@ Explanation: There are 2 groups [1], [2] of size 1.
    -

    Example 3:

    - -
    -Input: n = 15
    -Output: 6
    -
    - -

    Example 4:

    - -
    -Input: n = 24
    -Output: 5
    -
    -

     

    Constraints:

      -
    • 1 <= n <= 10^4
    • +
    • 1 <= n <= 104
    ### Related Topics diff --git a/problems/count-negative-numbers-in-a-sorted-matrix/README.md b/problems/count-negative-numbers-in-a-sorted-matrix/README.md index b9aac1ed8..7bfda52f4 100644 --- a/problems/count-negative-numbers-in-a-sorted-matrix/README.md +++ b/problems/count-negative-numbers-in-a-sorted-matrix/README.md @@ -29,20 +29,6 @@ Output: 0 -

    Example 3:

    - -
    -Input: grid = [[1,-1],[-1,-1]]
    -Output: 3
    -
    - -

    Example 4:

    - -
    -Input: grid = [[-1]]
    -Output: 1
    -
    -

     

    Constraints:

    diff --git a/problems/count-nice-pairs-in-an-array/README.md b/problems/count-nice-pairs-in-an-array/README.md index ce79ee89e..5cc54e815 100644 --- a/problems/count-nice-pairs-in-an-array/README.md +++ b/problems/count-nice-pairs-in-an-array/README.md @@ -52,6 +52,9 @@ [[Math](../../tag/math/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Number of Pairs of Interchangeable Rectangles](../number-of-pairs-of-interchangeable-rectangles) (Medium) + ### Hints
    Hint 1 diff --git a/problems/count-nodes-equal-to-sum-of-descendants/README.md b/problems/count-nodes-equal-to-sum-of-descendants/README.md index 4edd6ed06..3008e7d1d 100644 --- a/problems/count-nodes-equal-to-sum-of-descendants/README.md +++ b/problems/count-nodes-equal-to-sum-of-descendants/README.md @@ -9,7 +9,7 @@                  [Next >](../minimum-time-to-type-word-using-special-typewriter "Minimum Time to Type Word Using Special Typewriter") -## [1973. Count Nodes Equal to Sum of Descendants (Medium)](https://leetcode.com/problems/count-nodes-equal-to-sum-of-descendants "") +## [1973. Count Nodes Equal to Sum of Descendants (Medium)](https://leetcode.com/problems/count-nodes-equal-to-sum-of-descendants "值等于子节点值之和的节点数量") diff --git a/problems/count-number-of-pairs-with-absolute-difference-k/README.md b/problems/count-number-of-pairs-with-absolute-difference-k/README.md index 29e70cae0..588fa71df 100644 --- a/problems/count-number-of-pairs-with-absolute-difference-k/README.md +++ b/problems/count-number-of-pairs-with-absolute-difference-k/README.md @@ -63,6 +63,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/count-number-of-teams/README.md b/problems/count-number-of-teams/README.md index 2f27f44d2..2fb55323d 100644 --- a/problems/count-number-of-teams/README.md +++ b/problems/count-number-of-teams/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-lucky-integer-in-an-array "Find Lucky Integer in an Array") @@ -57,9 +57,9 @@ ### Related Topics + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] ### Hints
    diff --git a/problems/count-of-smaller-numbers-after-self/README.md b/problems/count-of-smaller-numbers-after-self/README.md index 84bfffbb5..70e0604bd 100644 --- a/problems/count-of-smaller-numbers-after-self/README.md +++ b/problems/count-of-smaller-numbers-after-self/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-tree-vertical-order-traversal "Binary Tree Vertical Order Traversal") @@ -49,16 +49,15 @@ To the right of 1 there is 0 smaller element. ### Related Topics + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] - [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] - [[Segment Tree](../../tag/segment-tree/README.md)] - [[Merge Sort](../../tag/merge-sort/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] + [[Merge Sort](../../tag/merge-sort/README.md)] ### Similar Questions 1. [Count of Range Sum](../count-of-range-sum) (Hard) 1. [Queue Reconstruction by Height](../queue-reconstruction-by-height) (Medium) 1. [Reverse Pairs](../reverse-pairs) (Hard) - 1. [How Many Numbers Are Smaller Than the Current Number](../how-many-numbers-are-smaller-than-the-current-number) (Easy) diff --git a/problems/count-operations-to-obtain-zero/README.md b/problems/count-operations-to-obtain-zero/README.md new file mode 100644 index 000000000..019bc3626 --- /dev/null +++ b/problems/count-operations-to-obtain-zero/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../unique-substrings-with-equal-digit-frequency "Unique Substrings With Equal Digit Frequency") +                 +[Next >](../minimum-operations-to-make-the-array-alternating "Minimum Operations to Make the Array Alternating") + +## [2169. Count Operations to Obtain Zero (Easy)](https://leetcode.com/problems/count-operations-to-obtain-zero "得到 0 的操作数") + +

    You are given two non-negative integers num1 and num2.

    + +

    In one operation, if num1 >= num2, you must subtract num2 from num1, otherwise subtract num1 from num2.

    + +
      +
    • For example, if num1 = 5 and num2 = 4, subtract num2 from num1, thus obtaining num1 = 1 and num2 = 4. However, if num1 = 4 and num2 = 5, after one operation, num1 = 4 and num2 = 1.
    • +
    + +

    Return the number of operations required to make either num1 = 0 or num2 = 0.

    + +

     

    +

    Example 1:

    + +
    +Input: num1 = 2, num2 = 3
    +Output: 3
    +Explanation: 
    +- Operation 1: num1 = 2, num2 = 3. Since num1 < num2, we subtract num1 from num2 and get num1 = 2, num2 = 3 - 2 = 1.
    +- Operation 2: num1 = 2, num2 = 1. Since num1 > num2, we subtract num2 from num1.
    +- Operation 3: num1 = 1, num2 = 1. Since num1 == num2, we subtract num2 from num1.
    +Now num1 = 0 and num2 = 1. Since num1 == 0, we do not need to perform any further operations.
    +So the total number of operations required is 3.
    +
    + +

    Example 2:

    + +
    +Input: num1 = 10, num2 = 10
    +Output: 1
    +Explanation: 
    +- Operation 1: num1 = 10, num2 = 10. Since num1 == num2, we subtract num2 from num1 and get num1 = 10 - 10 = 0.
    +Now num1 = 0 and num2 = 10. Since num1 == 0, we are done.
    +So the total number of operations required is 1.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= num1, num2 <= 105
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Try simulating the process until either of the two integers is zero. +
    + +
    +Hint 2 +Count the number of operations done. +
    diff --git a/problems/count-pairs-in-two-arrays/README.md b/problems/count-pairs-in-two-arrays/README.md index f7cdb43e0..82a198799 100644 --- a/problems/count-pairs-in-two-arrays/README.md +++ b/problems/count-pairs-in-two-arrays/README.md @@ -9,7 +9,7 @@                  [Next >](../determine-whether-matrix-can-be-obtained-by-rotation "Determine Whether Matrix Can Be Obtained By Rotation") -## [1885. Count Pairs in Two Arrays (Medium)](https://leetcode.com/problems/count-pairs-in-two-arrays "") +## [1885. Count Pairs in Two Arrays (Medium)](https://leetcode.com/problems/count-pairs-in-two-arrays "统计数对") diff --git a/problems/count-pairs-with-xor-in-a-range/README.md b/problems/count-pairs-with-xor-in-a-range/README.md index 8195188bb..1f7764e98 100644 --- a/problems/count-pairs-with-xor-in-a-range/README.md +++ b/problems/count-pairs-with-xor-in-a-range/README.md @@ -55,9 +55,9 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Trie](../../tag/trie/README.md)] - [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/count-servers-that-communicate/README.md b/problems/count-servers-that-communicate/README.md index b5454c4ec..5e4c3cca0 100644 --- a/problems/count-servers-that-communicate/README.md +++ b/problems/count-servers-that-communicate/README.md @@ -57,12 +57,12 @@ Return the number of servers that communicate with any other server.

    ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] - [[Counting](../../tag/counting/README.md)] [[Matrix](../../tag/matrix/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/count-student-number-in-departments/README.md b/problems/count-student-number-in-departments/README.md index dc03eb901..089034b63 100644 --- a/problems/count-student-number-in-departments/README.md +++ b/problems/count-student-number-in-departments/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-cumulative-salary-of-an-employee "Find Cumulative Salary of an Employee") diff --git a/problems/count-student-number-in-departments/mysql_schemas.sql b/problems/count-student-number-in-departments/mysql_schemas.sql index e4e479904..618e4666d 100644 --- a/problems/count-student-number-in-departments/mysql_schemas.sql +++ b/problems/count-student-number-in-departments/mysql_schemas.sql @@ -1,10 +1,10 @@ -CREATE TABLE IF NOT EXISTS student (student_id INT,student_name VARCHAR(45), gender VARCHAR(6), dept_id INT); -CREATE TABLE IF NOT EXISTS department (dept_id INT, dept_name VARCHAR(255)); -Truncate table student; -insert into student (student_id, student_name, gender, dept_id) values ('1', 'Jack', 'M', '1'); -insert into student (student_id, student_name, gender, dept_id) values ('2', 'Jane', 'F', '1'); -insert into student (student_id, student_name, gender, dept_id) values ('3', 'Mark', 'M', '2'); -Truncate table department; -insert into department (dept_id, dept_name) values ('1', 'Engineering'); -insert into department (dept_id, dept_name) values ('2', 'Science'); -insert into department (dept_id, dept_name) values ('3', 'Law'); +Create table If Not Exists Student (student_id int,student_name varchar(45), gender varchar(6), dept_id int); +Create table If Not Exists Department (dept_id int, dept_name varchar(255)); +Truncate table Student; +insert into Student (student_id, student_name, gender, dept_id) values ('1', 'Jack', 'M', '1'); +insert into Student (student_id, student_name, gender, dept_id) values ('2', 'Jane', 'F', '1'); +insert into Student (student_id, student_name, gender, dept_id) values ('3', 'Mark', 'M', '2'); +Truncate table Department; +insert into Department (dept_id, dept_name) values ('1', 'Engineering'); +insert into Department (dept_id, dept_name) values ('2', 'Science'); +insert into Department (dept_id, dept_name) values ('3', 'Law'); diff --git a/problems/count-sub-islands/README.md b/problems/count-sub-islands/README.md index 3bc57c1ed..03d87c466 100644 --- a/problems/count-sub-islands/README.md +++ b/problems/count-sub-islands/README.md @@ -47,12 +47,17 @@ The 1s colored red in grid2 are those considered to be part of a sub-island. The ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Number of Islands](../number-of-islands) (Medium) + 1. [Number of Distinct Islands](../number-of-distinct-islands) (Medium) + 1. [Find All Groups of Farmland](../find-all-groups-of-farmland) (Medium) + ### Hints
    Hint 1 diff --git a/problems/count-subarrays-with-more-ones-than-zeros/README.md b/problems/count-subarrays-with-more-ones-than-zeros/README.md index 6b4eea3b1..e91e1a9cf 100644 --- a/problems/count-subarrays-with-more-ones-than-zeros/README.md +++ b/problems/count-subarrays-with-more-ones-than-zeros/README.md @@ -9,7 +9,7 @@                  [Next >](../two-out-of-three "Two Out of Three") -## [2031. Count Subarrays With More Ones Than Zeros (Medium)](https://leetcode.com/problems/count-subarrays-with-more-ones-than-zeros "") +## [2031. Count Subarrays With More Ones Than Zeros (Medium)](https://leetcode.com/problems/count-subarrays-with-more-ones-than-zeros "1 比 0 多的子数组个数") diff --git a/problems/count-substrings-that-differ-by-one-character/README.md b/problems/count-substrings-that-differ-by-one-character/README.md index dc837a236..4250e2fc0 100644 --- a/problems/count-substrings-that-differ-by-one-character/README.md +++ b/problems/count-substrings-that-differ-by-one-character/README.md @@ -25,7 +25,7 @@
     Input: s = "aba", t = "baba"
     Output: 6
    -Explanation: The following are the pairs of substrings from s and t that differ by exactly 1 character:
    +Explanation: The following are the pairs of substrings from s and t that differ by exactly 1 character:
     ("aba", "baba")
     ("aba", "baba")
     ("aba", "baba")
    @@ -39,25 +39,12 @@ The underlined portions are the substrings that are chosen from s and t.
     
     Input: s = "ab", t = "bb"
     Output: 3
    -Explanation: The following are the pairs of substrings from s and t that differ by 1 character:
    +Explanation: The following are the pairs of substrings from s and t that differ by 1 character:
     ("ab", "bb")
     ("ab", "bb")
     ("ab", "bb")
     ​​​​The underlined portions are the substrings that are chosen from s and t.
     
    -Example 3: - -
    -Input: s = "a", t = "a"
    -Output: 0
    -
    - -

    Example 4:

    - -
    -Input: s = "abe", t = "bbc"
    -Output: 10
    -

     

    Constraints:

    @@ -72,6 +59,9 @@ The underlined portions are the substrings that are chosen from s and t. [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Count Words Obtained After Adding a Letter](../count-words-obtained-after-adding-a-letter) (Medium) + ### Hints
    Hint 1 diff --git a/problems/count-subtrees-with-max-distance-between-cities/README.md b/problems/count-subtrees-with-max-distance-between-cities/README.md index b2fafe331..4b8a8e661 100644 --- a/problems/count-subtrees-with-max-distance-between-cities/README.md +++ b/problems/count-subtrees-with-max-distance-between-cities/README.md @@ -61,14 +61,11 @@ No subtree has two nodes where the max distance between them is 3. ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Tree](../../tag/tree/README.md)] - [[Enumeration](../../tag/enumeration/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bitmask](../../tag/bitmask/README.md)] - -### Similar Questions - 1. [Tree Diameter](../tree-diameter) (Medium) + [[Enumeration](../../tag/enumeration/README.md)] ### Hints
    diff --git a/problems/count-the-hidden-sequences/README.md b/problems/count-the-hidden-sequences/README.md new file mode 100644 index 000000000..7b6dd0bc0 --- /dev/null +++ b/problems/count-the-hidden-sequences/README.md @@ -0,0 +1,96 @@ + + + + + + + +[< Previous](../minimum-cost-of-buying-candies-with-discount "Minimum Cost of Buying Candies With Discount") +                 +[Next >](../k-highest-ranked-items-within-a-price-range "K Highest Ranked Items Within a Price Range") + +## [2145. Count the Hidden Sequences (Medium)](https://leetcode.com/problems/count-the-hidden-sequences "统计隐藏数组数目") + +

    You are given a 0-indexed array of n integers differences, which describes the differences between each pair of consecutive integers of a hidden sequence of length (n + 1). More formally, call the hidden sequence hidden, then we have that differences[i] = hidden[i + 1] - hidden[i].

    + +

    You are further given two integers lower and upper that describe the inclusive range of values [lower, upper] that the hidden sequence can contain.

    + +
      +
    • For example, given differences = [1, -3, 4], lower = 1, upper = 6, the hidden sequence is a sequence of length 4 whose elements are in between 1 and 6 (inclusive). +
        +
      • [3, 4, 1, 5] and [4, 5, 2, 6] are possible hidden sequences.
      • +
      • [5, 6, 3, 7] is not possible since it contains an element greater than 6.
      • +
      • [1, 2, 3, 4] is not possible since the differences are not correct.
      • +
      +
    • +
    + +

    Return the number of possible hidden sequences there are. If there are no possible sequences, return 0.

    + +

     

    +

    Example 1:

    + +
    +Input: differences = [1,-3,4], lower = 1, upper = 6
    +Output: 2
    +Explanation: The possible hidden sequences are:
    +- [3, 4, 1, 5]
    +- [4, 5, 2, 6]
    +Thus, we return 2.
    +
    + +

    Example 2:

    + +
    +Input: differences = [3,-4,5,1,-2], lower = -4, upper = 5
    +Output: 4
    +Explanation: The possible hidden sequences are:
    +- [-3, 0, -4, 1, 2, 0]
    +- [-2, 1, -3, 2, 3, 1]
    +- [-1, 2, -2, 3, 4, 2]
    +- [0, 3, -1, 4, 5, 3]
    +Thus, we return 4.
    +
    + +

    Example 3:

    + +
    +Input: differences = [4,-7,2], lower = 3, upper = 6
    +Output: 0
    +Explanation: There are no possible hidden sequences. Thus, we return 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == differences.length
    • +
    • 1 <= n <= 105
    • +
    • -105 <= differences[i] <= 105
    • +
    • -105 <= lower <= upper <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +Fix the first element of the hidden sequence to any value x and ignore the given bounds. Notice that we can then determine all the other elements of the sequence by using the differences array. +
    + +
    +Hint 2 +We will also be able to determine the difference between the minimum and maximum elements of the sequence. Notice that the value of x does not affect this. +
    + +
    +Hint 3 +We now have the ‘range’ of the sequence (difference between min and max element), we can then calculate how many ways there are to fit this range into the given range of lower to upper. +
    + +
    +Hint 4 +Answer is (upper - lower + 1) - (range of sequence) +
    diff --git a/problems/count-the-number-of-consistent-strings/README.md b/problems/count-the-number-of-consistent-strings/README.md index e96a04d61..0149ed188 100644 --- a/problems/count-the-number-of-consistent-strings/README.md +++ b/problems/count-the-number-of-consistent-strings/README.md @@ -52,10 +52,10 @@ ### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/count-the-number-of-experiments/README.md b/problems/count-the-number-of-experiments/README.md index 004d98070..32f1a9733 100644 --- a/problems/count-the-number-of-experiments/README.md +++ b/problems/count-the-number-of-experiments/README.md @@ -9,6 +9,6 @@                  [Next >](../find-the-middle-index-in-array "Find the Middle Index in Array") -## [1990. Count the Number of Experiments (Easy)](https://leetcode.com/problems/count-the-number-of-experiments "") +## [1990. Count the Number of Experiments (Easy)](https://leetcode.com/problems/count-the-number-of-experiments "统计实验的数量") diff --git a/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md b/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md index db696b55f..54729a4f0 100644 --- a/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md +++ b/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/README.md @@ -11,7 +11,7 @@ ## [1442. Count Triplets That Can Form Two Arrays of Equal XOR (Medium)](https://leetcode.com/problems/count-triplets-that-can-form-two-arrays-of-equal-xor "形成两个异或相等数组的三元组数目") -

    Given an array of integers arr.

    +

    Given an array of integers arr.

    We want to select three indices i, j and k where (0 <= i < j <= k < arr.length).

    @@ -42,33 +42,12 @@ Output: 10
    -

    Example 3:

    - -
    -Input: arr = [2,3]
    -Output: 0
    -
    - -

    Example 4:

    - -
    -Input: arr = [1,3,5,7,9]
    -Output: 3
    -
    - -

    Example 5:

    - -
    -Input: arr = [7,11,12,9,5,2,7,17,22]
    -Output: 8
    -
    -

     

    Constraints:

    • 1 <= arr.length <= 300
    • -
    • 1 <= arr[i] <= 10^8
    • +
    • 1 <= arr[i] <= 108
    ### Related Topics diff --git a/problems/count-vowel-substrings-of-a-string/README.md b/problems/count-vowel-substrings-of-a-string/README.md index f66f9ed84..29a590805 100644 --- a/problems/count-vowel-substrings-of-a-string/README.md +++ b/problems/count-vowel-substrings-of-a-string/README.md @@ -48,14 +48,7 @@ - "cuaieuouac" - "cuaieuouac" - "cuaieuouac" -- "cuaieuouac" - -

    Example 4:

    - -
    -Input: word = "bbaeixoubb"
    -Output: 0
    -Explanation: The only substrings that contain all five vowels also contain consonants, so there are no vowel substrings.
    +- "cuaieuouac"
     

     

    diff --git a/problems/count-words-obtained-after-adding-a-letter/README.md b/problems/count-words-obtained-after-adding-a-letter/README.md new file mode 100644 index 000000000..b182d8fbc --- /dev/null +++ b/problems/count-words-obtained-after-adding-a-letter/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../minimum-swaps-to-group-all-1s-together-ii "Minimum Swaps to Group All 1's Together II") +                 +[Next >](../earliest-possible-day-of-full-bloom "Earliest Possible Day of Full Bloom") + +## [2135. Count Words Obtained After Adding a Letter (Medium)](https://leetcode.com/problems/count-words-obtained-after-adding-a-letter "统计追加字母可以获得的单词数") + +

    You are given two 0-indexed arrays of strings startWords and targetWords. Each string consists of lowercase English letters only.

    + +

    For each string in targetWords, check if it is possible to choose a string from startWords and perform a conversion operation on it to be equal to that from targetWords.

    + +

    The conversion operation is described in the following two steps:

    + +
      +
    1. Append any lowercase letter that is not present in the string to its end. +
        +
      • For example, if the string is "abc", the letters 'd', 'e', or 'y' can be added to it, but not 'a'. If 'd' is added, the resulting string will be "abcd".
      • +
      +
    2. +
    3. Rearrange the letters of the new string in any arbitrary order. +
        +
      • For example, "abcd" can be rearranged to "acbd", "bacd", "cbda", and so on. Note that it can also be rearranged to "abcd" itself.
      • +
      +
    4. +
    + +

    Return the number of strings in targetWords that can be obtained by performing the operations on any string of startWords.

    + +

    Note that you will only be verifying if the string in targetWords can be obtained from a string in startWords by performing the operations. The strings in startWords do not actually change during this process.

    + +

     

    +

    Example 1:

    + +
    +Input: startWords = ["ant","act","tack"], targetWords = ["tack","act","acti"]
    +Output: 2
    +Explanation:
    +- In order to form targetWords[0] = "tack", we use startWords[1] = "act", append 'k' to it, and rearrange "actk" to "tack".
    +- There is no string in startWords that can be used to obtain targetWords[1] = "act".
    +  Note that "act" does exist in startWords, but we must append one letter to the string before rearranging it.
    +- In order to form targetWords[2] = "acti", we use startWords[1] = "act", append 'i' to it, and rearrange "acti" to "acti" itself.
    +
    + +

    Example 2:

    + +
    +Input: startWords = ["ab","a"], targetWords = ["abc","abcd"]
    +Output: 1
    +Explanation:
    +- In order to form targetWords[0] = "abc", we use startWords[0] = "ab", add 'c' to it, and rearrange it to "abc".
    +- There is no string in startWords that can be used to obtain targetWords[1] = "abcd".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= startWords.length, targetWords.length <= 5 * 104
    • +
    • 1 <= startWords[i].length, targetWords[j].length <= 26
    • +
    • Each string of startWords and targetWords consists of lowercase English letters only.
    • +
    • No letter occurs more than once in any string of startWords or targetWords.
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Which data structure can be used to efficiently check if a string exists in startWords? +
    + +
    +Hint 2 +After appending a letter, all letters of a string can be rearranged in any possible way. How can we use this to reduce our search space while checking if a string in targetWords can be obtained from a string in startWords? +
    diff --git a/problems/counting-bits/README.md b/problems/counting-bits/README.md index 52e02d477..edcd0c085 100644 --- a/problems/counting-bits/README.md +++ b/problems/counting-bits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../house-robber-iii "House Robber III") @@ -55,8 +55,8 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Number of 1 Bits](../number-of-1-bits) (Easy) diff --git a/problems/countries-you-can-safely-invest-in/README.md b/problems/countries-you-can-safely-invest-in/README.md index 0450b8cee..75a1ea51b 100644 --- a/problems/countries-you-can-safely-invest-in/README.md +++ b/problems/countries-you-can-safely-invest-in/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Average Salary: Departments VS Company](../average-salary-departments-vs-company) (Hard) diff --git a/problems/create-a-session-bar-chart/README.md b/problems/create-a-session-bar-chart/README.md index 9bf7444db..2d98529f9 100644 --- a/problems/create-a-session-bar-chart/README.md +++ b/problems/create-a-session-bar-chart/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-ways-to-wear-different-hats-to-each-other "Number of Ways to Wear Different Hats to Each Other") diff --git a/problems/create-target-array-in-the-given-order/README.md b/problems/create-target-array-in-the-given-order/README.md index 26cc2be14..ed80d4212 100644 --- a/problems/create-target-array-in-the-given-order/README.md +++ b/problems/create-target-array-in-the-given-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../pizza-with-3n-slices "Pizza With 3n Slices") diff --git a/problems/decode-the-slanted-ciphertext/README.md b/problems/decode-the-slanted-ciphertext/README.md index 413cba302..b6fac51a5 100644 --- a/problems/decode-the-slanted-ciphertext/README.md +++ b/problems/decode-the-slanted-ciphertext/README.md @@ -55,14 +55,6 @@ The blue arrows show how we can find originalText from encodedText. Explanation: Since there is only 1 row, both originalText and encodedText are the same. -

    Example 4:

    - -
    -Input: encodedText = " b  ac", rows = 2
    -Output: " abc"
    -Explanation: originalText cannot have trailing spaces, but it may be preceded by one or more spaces.
    -
    -

     

    Constraints:

    diff --git a/problems/decode-ways-ii/README.md b/problems/decode-ways-ii/README.md index d8a78212b..7e825db0d 100644 --- a/problems/decode-ways-ii/README.md +++ b/problems/decode-ways-ii/README.md @@ -81,3 +81,4 @@ Hence, there are a total of (6 * 2) + (3 * 1) = 12 + 3 = 15 ways to decode " ### Similar Questions 1. [Decode Ways](../decode-ways) (Medium) 1. [Number of Ways to Separate Numbers](../number-of-ways-to-separate-numbers) (Hard) + 1. [Number of Ways to Divide a Long Corridor](../number-of-ways-to-divide-a-long-corridor) (Hard) diff --git a/problems/decode-xored-permutation/README.md b/problems/decode-xored-permutation/README.md index c848d7942..f1782835e 100644 --- a/problems/decode-xored-permutation/README.md +++ b/problems/decode-xored-permutation/README.md @@ -43,8 +43,8 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md b/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md index e7eb154e6..51121f55c 100644 --- a/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md +++ b/problems/decrypt-string-from-alphabet-to-integer-mapping/README.md @@ -11,16 +11,16 @@ ## [1309. Decrypt String from Alphabet to Integer Mapping (Easy)](https://leetcode.com/problems/decrypt-string-from-alphabet-to-integer-mapping "解码字母到整数映射") -

    Given a string s formed by digits ('0' - '9') and '#' . We want to map s to English lowercase characters as follows:

    +

    You are given a string s formed by digits and '#'. We want to map s to English lowercase characters as follows:

      -
    • Characters ('a' to 'i') are represented by ('1' to '9') respectively.
    • -
    • Characters ('j' to 'z') are represented by ('10#' to '26#') respectively. 
    • +
    • Characters ('a' to 'i') are represented by ('1' to '9') respectively.
    • +
    • Characters ('j' to 'z') are represented by ('10#' to '26#') respectively.
    -

    Return the string formed after mapping.

    +

    Return the string formed after mapping.

    -

    It's guaranteed that a unique mapping will always exist.

    +

    The test cases are generated so that a unique mapping will always exist.

     

    Example 1:

    @@ -38,27 +38,13 @@ Output: "acz" -

    Example 3:

    - -
    -Input: s = "25#"
    -Output: "y"
    -
    - -

    Example 4:

    - -
    -Input: s = "12345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#"
    -Output: "abcdefghijklmnopqrstuvwxyz"
    -
    -

     

    Constraints:

    • 1 <= s.length <= 1000
    • -
    • s[i] only contains digits letters ('0'-'9') and '#' letter.
    • -
    • s will be valid string such that mapping is always possible.
    • +
    • s consists of digits and the '#' letter.
    • +
    • s will be a valid string such that mapping is always possible.
    ### Related Topics diff --git a/problems/deepest-leaves-sum/README.md b/problems/deepest-leaves-sum/README.md index 91cae7c59..82c34bc7f 100644 --- a/problems/deepest-leaves-sum/README.md +++ b/problems/deepest-leaves-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-paths-with-max-score "Number of Paths with Max Score") diff --git a/problems/degree-of-an-array/README.md b/problems/degree-of-an-array/README.md index 691229adc..46abd362f 100644 --- a/problems/degree-of-an-array/README.md +++ b/problems/degree-of-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-binary-substrings "Count Binary Substrings") diff --git a/problems/delete-duplicate-emails/README.md b/problems/delete-duplicate-emails/README.md index b3669d52c..f2ba686fb 100644 --- a/problems/delete-duplicate-emails/README.md +++ b/problems/delete-duplicate-emails/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tenth-line "Tenth Line") @@ -11,33 +11,49 @@ ## [196. Delete Duplicate Emails (Easy)](https://leetcode.com/problems/delete-duplicate-emails "删除重复的电子邮箱") -

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id.

    +

    Table: Person

    ++-------------+---------+
    +| Column Name | Type    |
    ++-------------+---------+
    +| id          | int     |
    +| email       | varchar |
    ++-------------+---------+
    +id is the primary key column for this table.
    +Each row of this table contains an email. The emails will not contain uppercase letters.
    +
    + +

     

    + +

    Write an SQL query to delete all the duplicate emails, keeping only one unique email with the smallest id. Note that you are supposed to write a DELETE statement and not a SELECT one.

    + +

    Return the result table in any order.

    + +

    The query result format is in the following example.

    + +

     

    +

    Example 1:

    + +
    +Input: 
    +Person table:
     +----+------------------+
    -| Id | Email            |
    +| id | email            |
     +----+------------------+
     | 1  | john@example.com |
     | 2  | bob@example.com  |
     | 3  | john@example.com |
     +----+------------------+
    -Id is the primary key column for this table.
    -
    - -

    For example, after running your query, the above Person table should have the following rows:

    - -
    +Output: 
     +----+------------------+
    -| Id | Email            |
    +| id | email            |
     +----+------------------+
     | 1  | john@example.com |
     | 2  | bob@example.com  |
     +----+------------------+
    +Explanation: john@example.com is repeated two times. We keep the row with the smallest Id = 1.
     
    -

    Note:

    - -

    Your output is the whole Person table after executing your sql. Use delete statement.

    - ### Related Topics [[Database](../../tag/database/README.md)] diff --git a/problems/delete-duplicate-emails/mysql_schemas.sql b/problems/delete-duplicate-emails/mysql_schemas.sql index 89062100e..6ee53bdfa 100644 --- a/problems/delete-duplicate-emails/mysql_schemas.sql +++ b/problems/delete-duplicate-emails/mysql_schemas.sql @@ -1,4 +1,5 @@ +Create table If Not Exists Person (Id int, Email varchar(255)); Truncate table Person; -insert into Person (Id, Email) values ('1', 'john@example.com'); -insert into Person (Id, Email) values ('2', 'bob@example.com'); -insert into Person (Id, Email) values ('3', 'john@example.com'); +insert into Person (id, email) values ('1', 'john@example.com'); +insert into Person (id, email) values ('2', 'bob@example.com'); +insert into Person (id, email) values ('3', 'john@example.com'); diff --git a/problems/delete-duplicate-folders-in-system/README.md b/problems/delete-duplicate-folders-in-system/README.md index 4bb81e72f..7e5d89477 100644 --- a/problems/delete-duplicate-folders-in-system/README.md +++ b/problems/delete-duplicate-folders-in-system/README.md @@ -69,29 +69,6 @@ Note that folders "/a" and "/c" are identical after the dele Note that the returned array can be in a different order as the order does not matter. -

    Example 4:

    - -
    -Input: paths = [["a"],["a","x"],["a","x","y"],["a","z"],["b"],["b","x"],["b","x","y"],["b","z"]]
    -Output: []
    -Explanation: The file structure is as shown.
    -Folders "/a/x" and "/b/x" (and their subfolders) are marked for deletion because they both contain an
    -empty folder named "y".
    -Folders "/a" and "/b" (and their subfolders) are marked for deletion because they both contain an empty
    -folder "z" and the folder "x" described above.
    -
    - -

    Example 5:

    - -
    -Input: paths = [["a"],["a","x"],["a","x","y"],["a","z"],["b"],["b","x"],["b","x","y"],["b","z"],["b","w"]]
    -Output: [["b"],["b","w"],["b","z"],["a"],["a","z"]]
    -Explanation: This has the same structure as the previous example, except with the added "/b/w".
    -Folders "/a/x" and "/b/x" are still marked, but "/a" and "/b" are no longer marked because "/b" has the
    -empty folder named "w" and "/a" does not.
    -Note that "/a/z" and "/b/z" are not marked because the set of identical subfolders must be non-empty, but these folders are empty.
    -
    -

     

    Constraints:

    diff --git a/problems/delete-leaves-with-a-given-value/README.md b/problems/delete-leaves-with-a-given-value/README.md index d581caa4a..1b4d423df 100644 --- a/problems/delete-leaves-with-a-given-value/README.md +++ b/problems/delete-leaves-with-a-given-value/README.md @@ -11,14 +11,14 @@ ## [1325. Delete Leaves With a Given Value (Medium)](https://leetcode.com/problems/delete-leaves-with-a-given-value "删除给定值的叶子节点") -

    Given a binary tree root and an integer target, delete all the leaf nodes with value target.

    +

    Given a binary tree root and an integer target, delete all the leaf nodes with value target.

    -

    Note that once you delete a leaf node with value targetif it's parent node becomes a leaf node and has the value target, it should also be deleted (you need to continue doing that until you can't).

    +

    Note that once you delete a leaf node with value target, if its parent node becomes a leaf node and has the value target, it should also be deleted (you need to continue doing that until you cannot).

     

    Example 1:

    -

    +

     Input: root = [1,2,3,2,null,2,4], target = 2
    @@ -29,7 +29,7 @@ After removing, new nodes become leaf nodes with value (target = 2) (Picture in
     
     

    Example 2:

    -

    +

     Input: root = [1,3,3,3,2], target = 3
    @@ -38,7 +38,7 @@ After removing, new nodes become leaf nodes with value (target = 2) (Picture in
     
     

    Example 3:

    -

    +

     Input: root = [1,2,null,2,null,2], target = 2
    @@ -46,34 +46,19 @@ After removing, new nodes become leaf nodes with value (target = 2) (Picture in
     Explanation: Leaf nodes in green with value (target = 2) are removed at each step.
     
    -

    Example 4:

    - -
    -Input: root = [1,1,1], target = 1
    -Output: []
    -
    - -

    Example 5:

    - -
    -Input: root = [1,2,3], target = 1
    -Output: [1,2,3]
    -
    -

     

    Constraints:

      -
    • 1 <= target <= 1000
    • -
    • The given binary tree will have between 1 and 3000 nodes.
    • -
    • Each node's value is between [1, 1000].
    • +
    • The number of nodes in the tree is in the range [1, 3000].
    • +
    • 1 <= Node.val, target <= 1000
    ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md b/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md index e73b8b5f1..9c97fa0c3 100644 --- a/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md +++ b/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../paint-house-iii "Paint House III") diff --git a/problems/delete-the-middle-node-of-a-linked-list/README.md b/problems/delete-the-middle-node-of-a-linked-list/README.md new file mode 100644 index 000000000..e88e98744 --- /dev/null +++ b/problems/delete-the-middle-node-of-a-linked-list/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../finding-3-digit-even-numbers "Finding 3-Digit Even Numbers") +                 +[Next >](../step-by-step-directions-from-a-binary-tree-node-to-another "Step-By-Step Directions From a Binary Tree Node to Another") + +## [2095. Delete the Middle Node of a Linked List (Medium)](https://leetcode.com/problems/delete-the-middle-node-of-a-linked-list "删除链表的中间节点") + +

    You are given the head of a linked list. Delete the middle node, and return the head of the modified linked list.

    + +

    The middle node of a linked list of size n is the ⌊n / 2⌋th node from the start using 0-based indexing, where ⌊x⌋ denotes the largest integer less than or equal to x.

    + +
      +
    • For n = 1, 2, 3, 4, and 5, the middle nodes are 0, 1, 1, 2, and 2, respectively.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: head = [1,3,4,7,1,2,6]
    +Output: [1,3,4,1,2,6]
    +Explanation:
    +The above figure represents the given linked list. The indices of the nodes are written below.
    +Since n = 7, node 3 with value 7 is the middle node, which is marked in red.
    +We return the new list after removing this node. 
    +
    + +

    Example 2:

    + +
    +Input: head = [1,2,3,4]
    +Output: [1,2,4]
    +Explanation:
    +The above figure represents the given linked list.
    +For n = 4, node 2 with value 3 is the middle node, which is marked in red.
    +
    + +

    Example 3:

    + +
    +Input: head = [2,1]
    +Output: [2]
    +Explanation:
    +The above figure represents the given linked list.
    +For n = 2, node 1 with value 1 is the middle node, which is marked in red.
    +Node 0 with value 2 is the only node remaining after removing node 1.
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is in the range [1, 105].
    • +
    • 1 <= Node.val <= 105
    • +
    + +### Related Topics + [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + +### Hints +
    +Hint 1 +If a point with a speed s moves n units in a given time, a point with speed 2 * s will move 2 * n units at the same time. Can you use this to find the middle node of a linked list? +
    + +
    +Hint 2 +If you are given the middle node, the node before it, and the node after it, how can you modify the linked list? +
    diff --git a/problems/delivering-boxes-from-storage-to-ports/README.md b/problems/delivering-boxes-from-storage-to-ports/README.md index a282ef700..a72e47f52 100644 --- a/problems/delivering-boxes-from-storage-to-ports/README.md +++ b/problems/delivering-boxes-from-storage-to-ports/README.md @@ -69,21 +69,6 @@ So the total number of trips is 2 + 2 + 2 = 6. So the total number of trips is 2 + 2 + 2 = 6.
    -

    Example 4:

    - -
    -Input: boxes = [[2,4],[2,5],[3,1],[3,2],[3,7],[3,1],[4,4],[1,3],[5,2]], portsCount = 5, maxBoxes = 5, maxWeight = 7
    -Output: 14
    -Explanation: The optimal strategy is as follows:
    -- The ship takes the first box, goes to port 2, then storage. 2 trips.
    -- The ship takes the second box, goes to port 2, then storage. 2 trips.
    -- The ship takes the third and fourth boxes, goes to port 3, then storage. 2 trips.
    -- The ship takes the fifth box, goes to port 3, then storage. 2 trips.
    -- The ship takes the sixth and seventh boxes, goes to port 3, then port 4, then storage. 3 trips. 
    -- The ship takes the eighth and ninth boxes, goes to port 1, then port 5, then storage. 3 trips.
    -So the total number of trips is 2 + 2 + 2 + 2 + 3 + 3 = 14.
    -
    -

     

    Constraints:

    diff --git a/problems/depth-of-bst-given-insertion-order/README.md b/problems/depth-of-bst-given-insertion-order/README.md index 87f0d6196..ecf971b20 100644 --- a/problems/depth-of-bst-given-insertion-order/README.md +++ b/problems/depth-of-bst-given-insertion-order/README.md @@ -9,7 +9,7 @@                  [Next >](../largest-odd-number-in-string "Largest Odd Number in String") -## [1902. Depth of BST Given Insertion Order (Medium)](https://leetcode.com/problems/depth-of-bst-given-insertion-order "") +## [1902. Depth of BST Given Insertion Order (Medium)](https://leetcode.com/problems/depth-of-bst-given-insertion-order "给定二叉搜索树的插入顺序求深度") diff --git a/problems/describe-the-painting/README.md b/problems/describe-the-painting/README.md index edda7d60e..ac2cbbea4 100644 --- a/problems/describe-the-painting/README.md +++ b/problems/describe-the-painting/README.md @@ -85,6 +85,10 @@ Note that returning a single segment [1,7) is incorrect because the mixed color [[Array](../../tag/array/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] +### Similar Questions + 1. [Average Height of Buildings in Each Segment](../average-height-of-buildings-in-each-segment) (Medium) + 1. [Amount of New Area Painted Each Day](../amount-of-new-area-painted-each-day) (Hard) + ### Hints
    Hint 1 diff --git a/problems/design-a-file-sharing-system/README.md b/problems/design-a-file-sharing-system/README.md index 0eee8641a..ff0ae03e8 100644 --- a/problems/design-a-file-sharing-system/README.md +++ b/problems/design-a-file-sharing-system/README.md @@ -14,10 +14,13 @@ ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Data Stream](../../tag/data-stream/README.md)] + [[Design](../../tag/design/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] + +### Similar Questions + 1. [Design Twitter](../design-twitter) (Medium) ### Hints
    diff --git a/problems/design-bitset/README.md b/problems/design-bitset/README.md new file mode 100644 index 000000000..2cbd3a0ed --- /dev/null +++ b/problems/design-bitset/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../smallest-value-of-the-rearranged-number "Smallest Value of the Rearranged Number") +                 +[Next >](../minimum-time-to-remove-all-cars-containing-illegal-goods "Minimum Time to Remove All Cars Containing Illegal Goods") + +## [2166. Design Bitset (Medium)](https://leetcode.com/problems/design-bitset "设计位集") + +

    A Bitset is a data structure that compactly stores bits.

    + +

    Implement the Bitset class:

    + +
      +
    • Bitset(int size) Initializes the Bitset with size bits, all of which are 0.
    • +
    • void fix(int idx) Updates the value of the bit at the index idx to 1. If the value was already 1, no change occurs.
    • +
    • void unfix(int idx) Updates the value of the bit at the index idx to 0. If the value was already 0, no change occurs.
    • +
    • void flip() Flips the values of each bit in the Bitset. In other words, all bits with value 0 will now have value 1 and vice versa.
    • +
    • boolean all() Checks if the value of each bit in the Bitset is 1. Returns true if it satisfies the condition, false otherwise.
    • +
    • boolean one() Checks if there is at least one bit in the Bitset with value 1. Returns true if it satisfies the condition, false otherwise.
    • +
    • int count() Returns the total number of bits in the Bitset which have value 1.
    • +
    • String toString() Returns the current composition of the Bitset. Note that in the resultant string, the character at the ith index should coincide with the value at the ith bit of the Bitset.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input
    +["Bitset", "fix", "fix", "flip", "all", "unfix", "flip", "one", "unfix", "count", "toString"]
    +[[5], [3], [1], [], [], [0], [], [], [0], [], []]
    +Output
    +[null, null, null, null, false, null, null, true, null, 2, "01010"]
    +
    +Explanation
    +Bitset bs = new Bitset(5); // bitset = "00000".
    +bs.fix(3);     // the value at idx = 3 is updated to 1, so bitset = "00010".
    +bs.fix(1);     // the value at idx = 1 is updated to 1, so bitset = "01010". 
    +bs.flip();     // the value of each bit is flipped, so bitset = "10101". 
    +bs.all();      // return False, as not all values of the bitset are 1.
    +bs.unfix(0);   // the value at idx = 0 is updated to 0, so bitset = "00101".
    +bs.flip();     // the value of each bit is flipped, so bitset = "11010". 
    +bs.one();      // return True, as there is at least 1 index with value 1.
    +bs.unfix(0);   // the value at idx = 0 is updated to 0, so bitset = "01010".
    +bs.count();    // return 2, as there are 2 bits with value 1.
    +bs.toString(); // return "01010", which is the composition of bitset.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= size <= 105
    • +
    • 0 <= idx <= size - 1
    • +
    • At most 105 calls will be made in total to fix, unfix, flip, all, one, count, and toString.
    • +
    • At least one call will be made to all, one, count, or toString.
    • +
    • At most 5 calls will be made to toString.
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + +### Hints +
    +Hint 1 +Note that flipping a bit twice does nothing. +
    + +
    +Hint 2 +In order to determine the value of a bit, consider how you can efficiently count the number of flips made on the bit since its latest update. +
    diff --git a/problems/design-excel-sum-formula/README.md b/problems/design-excel-sum-formula/README.md index aa80932d7..367ed9cca 100644 --- a/problems/design-excel-sum-formula/README.md +++ b/problems/design-excel-sum-formula/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../course-schedule-iii "Course Schedule III") diff --git a/problems/design-file-system/README.md b/problems/design-file-system/README.md index 5d8630e7f..c37500d85 100644 --- a/problems/design-file-system/README.md +++ b/problems/design-file-system/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../single-row-keyboard "Single-Row Keyboard") diff --git a/problems/design-hashmap/README.md b/problems/design-hashmap/README.md index 14ef975d5..ede07f6c4 100644 --- a/problems/design-hashmap/README.md +++ b/problems/design-hashmap/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-hashset "Design HashSet") @@ -53,11 +53,12 @@ myHashMap.get(2); // return -1 (i.e., not found), The map is now [[1,1]] ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Design](../../tag/design/README.md)] [[Hash Function](../../tag/hash-function/README.md)] ### Similar Questions 1. [Design HashSet](../design-hashset) (Easy) + 1. [Design Skiplist](../design-skiplist) (Hard) diff --git a/problems/design-log-storage-system/README.md b/problems/design-log-storage-system/README.md index 1560bb852..9f35d631e 100644 --- a/problems/design-log-storage-system/README.md +++ b/problems/design-log-storage-system/README.md @@ -38,9 +38,9 @@ retrieve("2016:01:01:01:01:01","2017:01:01:23:00:00","Hour"); // return [1,2], b

    ### Related Topics + [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Design](../../tag/design/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] ### Similar Questions diff --git a/problems/design-movie-rental-system/README.md b/problems/design-movie-rental-system/README.md index 7d30137c7..8f579b4f1 100644 --- a/problems/design-movie-rental-system/README.md +++ b/problems/design-movie-rental-system/README.md @@ -69,11 +69,11 @@ movieRentingSystem.search(2); // return [0, 1]. Movies of ID 2 are unrented at ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] + [[Design](../../tag/design/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Hints
    diff --git a/problems/design-parking-system/README.md b/problems/design-parking-system/README.md index c3e886f43..3b78047ab 100644 --- a/problems/design-parking-system/README.md +++ b/problems/design-parking-system/README.md @@ -49,8 +49,8 @@ parkingSystem.addCar(1); // return false because there is no available slot for ### Related Topics [[Design](../../tag/design/README.md)] - [[Counting](../../tag/counting/README.md)] [[Simulation](../../tag/simulation/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/design-skiplist/README.md b/problems/design-skiplist/README.md index c4e2f39fa..07f2933c2 100644 --- a/problems/design-skiplist/README.md +++ b/problems/design-skiplist/README.md @@ -66,5 +66,10 @@ skiplist.search(1); // return False, 1 has already been erased.
    ### Related Topics - [[Design](../../tag/design/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Design](../../tag/design/README.md)] + +### Similar Questions + 1. [Design HashSet](../design-hashset) (Easy) + 1. [Design HashMap](../design-hashmap) (Easy) + 1. [Design Linked List](../design-linked-list) (Medium) diff --git a/problems/design-snake-game/README.md b/problems/design-snake-game/README.md index 16eb867f5..d4a133824 100644 --- a/problems/design-snake-game/README.md +++ b/problems/design-snake-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../data-stream-as-disjoint-intervals "Data Stream as Disjoint Intervals") diff --git a/problems/design-underground-system/README.md b/problems/design-underground-system/README.md index 3c3d61dd4..07d725874 100644 --- a/problems/design-underground-system/README.md +++ b/problems/design-underground-system/README.md @@ -101,9 +101,12 @@ undergroundSystem.getAverageTime("Leyton", "Paradise"); // r ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] + +### Similar Questions + 1. [Design Bitset](../design-bitset) (Medium) ### Hints
    diff --git a/problems/destroying-asteroids/README.md b/problems/destroying-asteroids/README.md new file mode 100644 index 000000000..f1ff813bf --- /dev/null +++ b/problems/destroying-asteroids/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../number-of-laser-beams-in-a-bank "Number of Laser Beams in a Bank") +                 +[Next >](../maximum-employees-to-be-invited-to-a-meeting "Maximum Employees to Be Invited to a Meeting") + +## [2126. Destroying Asteroids (Medium)](https://leetcode.com/problems/destroying-asteroids "摧毁小行星") + +

    You are given an integer mass, which represents the original mass of a planet. You are further given an integer array asteroids, where asteroids[i] is the mass of the ith asteroid.

    + +

    You can arrange for the planet to collide with the asteroids in any arbitrary order. If the mass of the planet is greater than or equal to the mass of the asteroid, the asteroid is destroyed and the planet gains the mass of the asteroid. Otherwise, the planet is destroyed.

    + +

    Return true if all asteroids can be destroyed. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: mass = 10, asteroids = [3,9,19,5,21]
    +Output: true
    +Explanation: One way to order the asteroids is [9,19,5,3,21]:
    +- The planet collides with the asteroid with a mass of 9. New planet mass: 10 + 9 = 19
    +- The planet collides with the asteroid with a mass of 19. New planet mass: 19 + 19 = 38
    +- The planet collides with the asteroid with a mass of 5. New planet mass: 38 + 5 = 43
    +- The planet collides with the asteroid with a mass of 3. New planet mass: 43 + 3 = 46
    +- The planet collides with the asteroid with a mass of 21. New planet mass: 46 + 21 = 67
    +All asteroids are destroyed.
    +
    + +

    Example 2:

    + +
    +Input: mass = 5, asteroids = [4,9,23,4]
    +Output: false
    +Explanation: 
    +The planet cannot ever gain enough mass to destroy the asteroid with a mass of 23.
    +After the planet destroys the other asteroids, it will have a mass of 5 + 4 + 9 + 4 = 22.
    +This is less than 23, so a collision would not destroy the last asteroid.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= mass <= 105
    • +
    • 1 <= asteroids.length <= 105
    • +
    • 1 <= asteroids[i] <= 105
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Choosing the asteroid to collide with can be done greedily. +
    + +
    +Hint 2 +If an asteroid will destroy the planet, then every bigger asteroid will also destroy the planet. +
    + +
    +Hint 3 +You only need to check the smallest asteroid at each collision. If it will destroy the planet, then every other asteroid will also destroy the planet. +
    + +
    +Hint 4 +Sort the asteroids in non-decreasing order by mass, then greedily try to collide with the asteroids in that order. +
    diff --git a/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md b/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md index e154bfa69..6f2fcdace 100644 --- a/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md +++ b/problems/detect-pattern-of-length-m-repeated-k-or-more-times/README.md @@ -11,11 +11,11 @@ ## [1566. Detect Pattern of Length M Repeated K or More Times (Easy)](https://leetcode.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times "重复至少 K 次且长度为 M 的模式") -

    Given an array of positive integers arr,  find a pattern of length m that is repeated k or more times.

    +

    Given an array of positive integers arr, find a pattern of length m that is repeated k or more times.

    A pattern is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times consecutively without overlapping. A pattern is defined by its length and the number of repetitions.

    -

    Return true if there exists a pattern of length m that is repeated k or more times, otherwise return false.

    +

    Return true if there exists a pattern of length m that is repeated k or more times, otherwise return false.

     

    Example 1:

    @@ -42,36 +42,23 @@ Explanation: The pattern (1,2) is of length 2 but is repeated only 2 times. There is no pattern of length 2 that is repeated 3 or more times. -

    Example 4:

    - -
    -Input: arr = [1,2,3,1,2], m = 2, k = 2
    -Output: false
    -Explanation: Notice that the pattern (1,2) exists twice but not consecutively, so it doesn't count.
    -
    - -

    Example 5:

    - -
    -Input: arr = [2,2,2,2], m = 2, k = 3
    -Output: false
    -Explanation: The only pattern of length 2 is (2,2) however it's repeated only twice. Notice that we do not count overlapping repetitions.
    -
    -

     

    Constraints:

    • 2 <= arr.length <= 100
    • 1 <= arr[i] <= 100
    • -
    • 1 <= m <= 100
    • -
    • 2 <= k <= 100
    • +
    • 1 <= m <= 100
    • +
    • 2 <= k <= 100
    ### Related Topics [[Array](../../tag/array/README.md)] [[Enumeration](../../tag/enumeration/README.md)] +### Similar Questions + 1. [Maximum Repeating Substring](../maximum-repeating-substring) (Easy) + ### Hints
    Hint 1 diff --git a/problems/determine-if-string-halves-are-alike/README.md b/problems/determine-if-string-halves-are-alike/README.md index c436e1ff8..8f0453b94 100644 --- a/problems/determine-if-string-halves-are-alike/README.md +++ b/problems/determine-if-string-halves-are-alike/README.md @@ -23,7 +23,7 @@
     Input: s = "book"
     Output: true
    -Explanation: a = "bo" and b = "ok". a has 1 vowel and b has 1 vowel. Therefore, they are alike.
    +Explanation: a = "bo" and b = "ok". a has 1 vowel and b has 1 vowel. Therefore, they are alike.
     

    Example 2:

    @@ -31,24 +31,10 @@
     Input: s = "textbook"
     Output: false
    -Explanation: a = "text" and b = "book". a has 1 vowel whereas b has 2. Therefore, they are not alike.
    +Explanation: a = "text" and b = "book". a has 1 vowel whereas b has 2. Therefore, they are not alike.
     Notice that the vowel o is counted twice.
     
    -

    Example 3:

    - -
    -Input: s = "MerryChristmas"
    -Output: false
    -
    - -

    Example 4:

    - -
    -Input: s = "AbCdEfGh"
    -Output: true
    -
    -

     

    Constraints:

    diff --git a/problems/determine-if-two-strings-are-close/README.md b/problems/determine-if-two-strings-are-close/README.md index 9da101df9..a6740f403 100644 --- a/problems/determine-if-two-strings-are-close/README.md +++ b/problems/determine-if-two-strings-are-close/README.md @@ -60,14 +60,6 @@ Apply Operation 1: "cabbba" -> "caabbb Apply Operation 2: "baaccc" -> "abbccc" -

    Example 4:

    - -
    -Input: word1 = "cabbba", word2 = "aabbss"
    -Output: false
    -Explanation: It is impossible to attain word2 from word1, or vice versa, in any amount of operations.
    -
    -

     

    Constraints:

    @@ -81,11 +73,6 @@ Apply Operation 2: "baaccc" -> "abbccc" [[String](../../tag/string/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Buddy Strings](../buddy-strings) (Easy) - 1. [Minimum Swaps to Make Strings Equal](../minimum-swaps-to-make-strings-equal) (Medium) - 1. [Minimum Number of Steps to Make Two Strings Anagram](../minimum-number-of-steps-to-make-two-strings-anagram) (Medium) - ### Hints
    Hint 1 diff --git a/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md b/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md index 3f86bc907..dc07d77be 100644 --- a/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md +++ b/problems/determine-whether-matrix-can-be-obtained-by-rotation/README.md @@ -52,6 +52,9 @@ [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Rotate Image](../rotate-image) (Medium) + ### Hints
    Hint 1 diff --git a/problems/detonate-the-maximum-bombs/README.md b/problems/detonate-the-maximum-bombs/README.md new file mode 100644 index 000000000..2a7ecfe4b --- /dev/null +++ b/problems/detonate-the-maximum-bombs/README.md @@ -0,0 +1,93 @@ + + + + + + + +[< Previous](../find-good-days-to-rob-the-bank "Find Good Days to Rob the Bank") +                 +[Next >](../sequentially-ordinal-rank-tracker "Sequentially Ordinal Rank Tracker") + +## [2101. Detonate the Maximum Bombs (Medium)](https://leetcode.com/problems/detonate-the-maximum-bombs "引爆最多的炸弹") + +

    You are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the center as the location of the bomb.

    + +

    The bombs are represented by a 0-indexed 2D integer array bombs where bombs[i] = [xi, yi, ri]. xi and yi denote the X-coordinate and Y-coordinate of the location of the ith bomb, whereas ri denotes the radius of its range.

    + +

    You may choose to detonate a single bomb. When a bomb is detonated, it will detonate all bombs that lie in its range. These bombs will further detonate the bombs that lie in their ranges.

    + +

    Given the list of bombs, return the maximum number of bombs that can be detonated if you are allowed to detonate only one bomb.

    + +

     

    +

    Example 1:

    + +
    +Input: bombs = [[2,1,3],[6,1,4]]
    +Output: 2
    +Explanation:
    +The above figure shows the positions and ranges of the 2 bombs.
    +If we detonate the left bomb, the right bomb will not be affected.
    +But if we detonate the right bomb, both bombs will be detonated.
    +So the maximum bombs that can be detonated is max(1, 2) = 2.
    +
    + +

    Example 2:

    + +
    +Input: bombs = [[1,1,5],[10,10,5]]
    +Output: 1
    +Explanation:
    +Detonating either bomb will not detonate the other bomb, so the maximum number of bombs that can be detonated is 1.
    +
    + +

    Example 3:

    + +
    +Input: bombs = [[1,2,3],[2,3,1],[3,4,2],[4,5,3],[5,6,4]]
    +Output: 5
    +Explanation:
    +The best bomb to detonate is bomb 0 because:
    +- Bomb 0 detonates bombs 1 and 2. The red circle denotes the range of bomb 0.
    +- Bomb 2 detonates bomb 3. The blue circle denotes the range of bomb 2.
    +- Bomb 3 detonates bomb 4. The green circle denotes the range of bomb 3.
    +Thus all 5 bombs are detonated.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= bombs.length <= 100
    • +
    • bombs[i].length == 3
    • +
    • 1 <= xi, yi, ri <= 105
    • +
    + +### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +How can we model the relationship between different bombs? Can "graphs" help us? +
    + +
    +Hint 2 +Bombs are nodes and are connected to other bombs in their range by directed edges. +
    + +
    +Hint 3 +If we know which bombs will be affected when any bomb is detonated, how can we find the total number of bombs that will be detonated if we start from a fixed bomb? +
    + +
    +Hint 4 +Run a Depth First Search (DFS) from every node, and all the nodes it reaches are the bombs that will be detonated. +
    diff --git a/problems/diagonal-traverse-ii/README.md b/problems/diagonal-traverse-ii/README.md index 89e88c505..f0f505c37 100644 --- a/problems/diagonal-traverse-ii/README.md +++ b/problems/diagonal-traverse-ii/README.md @@ -11,48 +11,31 @@ ## [1424. Diagonal Traverse II (Medium)](https://leetcode.com/problems/diagonal-traverse-ii "对角线遍历 II") -Given a list of lists of integers, nums, return all elements of nums in diagonal order as shown in the below images. +

    Given a 2D integer array nums, return all elements of nums in diagonal order as shown in the below images.

    +

     

    Example 1:

    - -

    - +
     Input: nums = [[1,2,3],[4,5,6],[7,8,9]]
     Output: [1,4,2,7,5,3,8,6,9]
     

    Example 2:

    - -

    - +
     Input: nums = [[1,2,3,4,5],[6,7],[8],[9,10,11],[12,13,14,15,16]]
     Output: [1,6,2,8,7,3,9,4,12,10,5,13,11,14,15,16]
     
    -

    Example 3:

    - -
    -Input: nums = [[1,2,3],[4],[5,6,7],[8],[9,10,11]]
    -Output: [1,4,2,5,3,8,6,9,7,10,11]
    -
    - -

    Example 4:

    - -
    -Input: nums = [[1,2,3,4,5,6]]
    -Output: [1,2,3,4,5,6]
    -
    -

     

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • 1 <= nums[i].length <= 10^5
    • -
    • 1 <= nums[i][j] <= 10^9
    • -
    • There at most 10^5 elements in nums.
    • +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i].length <= 105
    • +
    • 1 <= sum(nums[i].length) <= 105
    • +
    • 1 <= nums[i][j] <= 105
    ### Related Topics diff --git a/problems/diameter-of-binary-tree/README.md b/problems/diameter-of-binary-tree/README.md index 2af34eb9c..afe2198fb 100644 --- a/problems/diameter-of-binary-tree/README.md +++ b/problems/diameter-of-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../01-matrix "01 Matrix") @@ -45,3 +45,6 @@ [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] + +### Similar Questions + 1. [Diameter of N-Ary Tree](../diameter-of-n-ary-tree) (Medium) diff --git a/problems/distant-barcodes/README.md b/problems/distant-barcodes/README.md index cf6019f5a..dc8ebc8b1 100644 --- a/problems/distant-barcodes/README.md +++ b/problems/distant-barcodes/README.md @@ -32,12 +32,12 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Counting](../../tag/counting/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Counting](../../tag/counting/README.md)] ### Hints
    diff --git a/problems/distinct-echo-substrings/README.md b/problems/distinct-echo-substrings/README.md index de3a4e081..e27254199 100644 --- a/problems/distinct-echo-substrings/README.md +++ b/problems/distinct-echo-substrings/README.md @@ -39,12 +39,12 @@ ### Related Topics + [[Trie](../../tag/trie/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Trie](../../tag/trie/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Rolling Hash](../../tag/rolling-hash/README.md)] [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/distribute-coins-in-binary-tree/README.md b/problems/distribute-coins-in-binary-tree/README.md index bca1db8a7..fe77331b2 100644 --- a/problems/distribute-coins-in-binary-tree/README.md +++ b/problems/distribute-coins-in-binary-tree/README.md @@ -19,7 +19,7 @@

     

    Example 1:

    - +
     Input: root = [3,0,0]
     Output: 2
    @@ -27,27 +27,13 @@
     

    Example 2:

    - +
     Input: root = [0,3,0]
     Output: 3
     Explanation: From the left child of the root, we move two coins to the root [taking two moves]. Then, we move one coin from the root of the tree to the right child.
     
    -

    Example 3:

    - -
    -Input: root = [1,0,2]
    -Output: 2
    -
    - -

    Example 4:

    - -
    -Input: root = [1,0,0,null,3]
    -Output: 4
    -
    -

     

    Constraints:

    diff --git a/problems/distribute-repeating-integers/README.md b/problems/distribute-repeating-integers/README.md index aa9699270..c9c238bd3 100644 --- a/problems/distribute-repeating-integers/README.md +++ b/problems/distribute-repeating-integers/README.md @@ -27,7 +27,7 @@
     Input: nums = [1,2,3,4], quantity = [2]
     Output: false
    -Explanation: The 0th customer cannot be given two different integers.
    +Explanation: The 0th customer cannot be given two different integers.
     

    Example 2:

    @@ -35,7 +35,7 @@
     Input: nums = [1,2,3,3], quantity = [2]
     Output: true
    -Explanation: The 0th customer is given [3,3]. The integers [1,2] are not used.
    +Explanation: The 0th customer is given [3,3]. The integers [1,2] are not used.
     

    Example 3:

    @@ -43,22 +43,7 @@
     Input: nums = [1,1,2,2], quantity = [2,2]
     Output: true
    -Explanation: The 0th customer is given [1,1], and the 1st customer is given [2,2].
    -
    - -

    Example 4:

    - -
    -Input: nums = [1,1,2,3], quantity = [2,2]
    -Output: false
    -Explanation: Although the 0th customer could be given [1,1], the 1st customer cannot be satisfied.
    - -

    Example 5:

    - -
    -Input: nums = [1,1,1,1,1], quantity = [2,3]
    -Output: true
    -Explanation: The 0th customer is given [1,1], and the 1st customer is given [1,1,1].
    +Explanation: The 0th customer is given [1,1], and the 1st customer is given [2,2].
     

     

    diff --git a/problems/divide-a-string-into-groups-of-size-k/README.md b/problems/divide-a-string-into-groups-of-size-k/README.md new file mode 100644 index 000000000..f7fc58e35 --- /dev/null +++ b/problems/divide-a-string-into-groups-of-size-k/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../pour-water-between-buckets-to-make-water-levels-equal "Pour Water Between Buckets to Make Water Levels Equal") +                 +[Next >](../minimum-moves-to-reach-target-score "Minimum Moves to Reach Target Score") + +## [2138. Divide a String Into Groups of Size k (Easy)](https://leetcode.com/problems/divide-a-string-into-groups-of-size-k "将字符串拆分为若干长度为 k 的组") + +

    A string s can be partitioned into groups of size k using the following procedure:

    + +
      +
    • The first group consists of the first k characters of the string, the second group consists of the next k characters of the string, and so on. Each character can be a part of exactly one group.
    • +
    • For the last group, if the string does not have k characters remaining, a character fill is used to complete the group.
    • +
    + +

    Note that the partition is done so that after removing the fill character from the last group (if it exists) and concatenating all the groups in order, the resultant string should be s.

    + +

    Given the string s, the size of each group k and the character fill, return a string array denoting the composition of every group s has been divided into, using the above procedure.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "abcdefghi", k = 3, fill = "x"
    +Output: ["abc","def","ghi"]
    +Explanation:
    +The first 3 characters "abc" form the first group.
    +The next 3 characters "def" form the second group.
    +The last 3 characters "ghi" form the third group.
    +Since all groups can be completely filled by characters from the string, we do not need to use fill.
    +Thus, the groups formed are "abc", "def", and "ghi".
    +
    + +

    Example 2:

    + +
    +Input: s = "abcdefghij", k = 3, fill = "x"
    +Output: ["abc","def","ghi","jxx"]
    +Explanation:
    +Similar to the previous example, we are forming the first three groups "abc", "def", and "ghi".
    +For the last group, we can only use the character 'j' from the string. To complete this group, we add 'x' twice.
    +Thus, the 4 groups formed are "abc", "def", "ghi", and "jxx".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 100
    • +
    • s consists of lowercase English letters only.
    • +
    • 1 <= k <= 100
    • +
    • fill is a lowercase English letter.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Using the length of the string and k, can you count the number of groups the string can be divided into? +
    + +
    +Hint 2 +Try completing each group using characters from the string. If there aren’t enough characters for the last group, use the fill character to complete the group. +
    diff --git a/problems/dot-product-of-two-sparse-vectors/README.md b/problems/dot-product-of-two-sparse-vectors/README.md index 0c36b471c..4dd93440a 100644 --- a/problems/dot-product-of-two-sparse-vectors/README.md +++ b/problems/dot-product-of-two-sparse-vectors/README.md @@ -14,10 +14,10 @@ ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Design](../../tag/design/README.md)] ### Hints
    diff --git a/problems/drop-type-1-orders-for-customers-with-type-0-orders/README.md b/problems/drop-type-1-orders-for-customers-with-type-0-orders/README.md index 1a73e08ea..015d77373 100644 --- a/problems/drop-type-1-orders-for-customers-with-type-0-orders/README.md +++ b/problems/drop-type-1-orders-for-customers-with-type-0-orders/README.md @@ -7,8 +7,11 @@ [< Previous](../substrings-that-begin-and-end-with-the-same-letter "Substrings That Begin and End With the Same Letter")                  -Next > +[Next >](../count-common-words-with-one-occurrence "Count Common Words With One Occurrence") -## [2084. Drop Type 1 Orders for Customers With Type 0 Orders (Medium)](https://leetcode.com/problems/drop-type-1-orders-for-customers-with-type-0-orders "") +## [2084. Drop Type 1 Orders for Customers With Type 0 Orders (Medium)](https://leetcode.com/problems/drop-type-1-orders-for-customers-with-type-0-orders "为订单类型为 0 的客户删除类型为 1 的订单") + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/earliest-possible-day-of-full-bloom/README.md b/problems/earliest-possible-day-of-full-bloom/README.md new file mode 100644 index 000000000..ac699a6ed --- /dev/null +++ b/problems/earliest-possible-day-of-full-bloom/README.md @@ -0,0 +1,95 @@ + + + + + + + +[< Previous](../count-words-obtained-after-adding-a-letter "Count Words Obtained After Adding a Letter") +                 +[Next >](../pour-water-between-buckets-to-make-water-levels-equal "Pour Water Between Buckets to Make Water Levels Equal") + +## [2136. Earliest Possible Day of Full Bloom (Hard)](https://leetcode.com/problems/earliest-possible-day-of-full-bloom "全部开花的最早一天") + +

    You have n flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two 0-indexed integer arrays plantTime and growTime, of length n each:

    + +
      +
    • plantTime[i] is the number of full days it takes you to plant the ith seed. Every day, you can work on planting exactly one seed. You do not have to work on planting the same seed on consecutive days, but the planting of a seed is not complete until you have worked plantTime[i] days on planting it in total.
    • +
    • growTime[i] is the number of full days it takes the ith seed to grow after being completely planted. After the last day of its growth, the flower blooms and stays bloomed forever.
    • +
    + +

    From the beginning of day 0, you can plant the seeds in any order.

    + +

    Return the earliest possible day where all seeds are blooming.

    + +

     

    +

    Example 1:

    + +
    +Input: plantTime = [1,4,3], growTime = [2,3,1]
    +Output: 9
    +Explanation: The grayed out pots represent planting days, colored pots represent growing days, and the flower represents the day it blooms.
    +One optimal way is:
    +On day 0, plant the 0th seed. The seed grows for 2 full days and blooms on day 3.
    +On days 1, 2, 3, and 4, plant the 1st seed. The seed grows for 3 full days and blooms on day 8.
    +On days 5, 6, and 7, plant the 2nd seed. The seed grows for 1 full day and blooms on day 9.
    +Thus, on day 9, all the seeds are blooming.
    +
    + +

    Example 2:

    + +
    +Input: plantTime = [1,2,3,2], growTime = [2,1,2,1]
    +Output: 9
    +Explanation: The grayed out pots represent planting days, colored pots represent growing days, and the flower represents the day it blooms.
    +One optimal way is:
    +On day 1, plant the 0th seed. The seed grows for 2 full days and blooms on day 4.
    +On days 0 and 3, plant the 1st seed. The seed grows for 1 full day and blooms on day 5.
    +On days 2, 4, and 5, plant the 2nd seed. The seed grows for 2 full days and blooms on day 8.
    +On days 6 and 7, plant the 3rd seed. The seed grows for 1 full day and blooms on day 9.
    +Thus, on day 9, all the seeds are blooming.
    +
    + +

    Example 3:

    + +
    +Input: plantTime = [1], growTime = [1]
    +Output: 2
    +Explanation: On day 0, plant the 0th seed. The seed grows for 1 full day and blooms on day 2.
    +Thus, on day 2, all the seeds are blooming.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == plantTime.length == growTime.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= plantTime[i], growTime[i] <= 104
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +List the planting like the diagram above shows, where a row represents the timeline of a seed. A row i is above another row j if the last day planting seed i is ahead of the last day for seed j. Does it have any advantage to spend some days to plant seed j before completely planting seed i? +
    + +
    +Hint 2 +No. It does not help seed j but could potentially delay the completion of seed i, resulting in a worse final answer. Remaining focused is a part of the optimal solution. +
    + +
    +Hint 3 +Sort the seeds by their growTime in descending order. Can you prove why this strategy is the other part of the optimal solution? Note the bloom time of a seed is the sum of plantTime of all seeds preceding this seed plus the growTime of this seed. +
    + +
    +Hint 4 +There is no way to improve this strategy. The seed to bloom last dominates the final answer. Exchanging the planting of this seed with another seed with either a larger or smaller growTime will result in a potentially worse answer. +
    diff --git a/problems/egg-drop-with-2-eggs-and-n-floors/README.md b/problems/egg-drop-with-2-eggs-and-n-floors/README.md index b8408e61b..fb4e7cc26 100644 --- a/problems/egg-drop-with-2-eggs-and-n-floors/README.md +++ b/problems/egg-drop-with-2-eggs-and-n-floors/README.md @@ -54,6 +54,9 @@ Regardless of the outcome, it takes at most 14 drops to determine f. [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Super Egg Drop](../super-egg-drop) (Hard) + ### Hints
    Hint 1 diff --git a/problems/elements-in-array-after-removing-and-replacing-elements/README.md b/problems/elements-in-array-after-removing-and-replacing-elements/README.md new file mode 100644 index 000000000..745729049 --- /dev/null +++ b/problems/elements-in-array-after-removing-and-replacing-elements/README.md @@ -0,0 +1,33 @@ + + + + + + + +[< Previous](../the-airport-with-the-most-traffic "The Airport With the Most Traffic") +                 +[Next >](../maximum-number-of-words-found-in-sentences "Maximum Number of Words Found in Sentences") + +## [2113. Elements in Array After Removing and Replacing Elements (Medium)](https://leetcode.com/problems/elements-in-array-after-removing-and-replacing-elements "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +Try to find a pattern in how nums changes. +
    + +
    +Hint 2 +Let m be the original length of nums. If time_i / m (integer division) is even, then nums is at its original size or decreasing in size. If it is odd, then it is empty, or increasing in size. +
    + +
    +Hint 3 +time_i % m can be used to find how many elements are in nums at minute time_i. +
    diff --git a/problems/eliminate-maximum-number-of-monsters/README.md b/problems/eliminate-maximum-number-of-monsters/README.md index 6a752338f..96c3ed4ba 100644 --- a/problems/eliminate-maximum-number-of-monsters/README.md +++ b/problems/eliminate-maximum-number-of-monsters/README.md @@ -65,8 +65,8 @@ You can only eliminate 1 monster. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/elimination-game/README.md b/problems/elimination-game/README.md index 276a8e60b..2368ac99f 100644 --- a/problems/elimination-game/README.md +++ b/problems/elimination-game/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-the-difference "Find the Difference") diff --git a/problems/employees-whose-manager-left-the-company/README.md b/problems/employees-whose-manager-left-the-company/README.md index 56eee226f..f6c3b1350 100644 --- a/problems/employees-whose-manager-left-the-company/README.md +++ b/problems/employees-whose-manager-left-the-company/README.md @@ -9,6 +9,6 @@                  [Next >](../find-greatest-common-divisor-of-array "Find Greatest Common Divisor of Array") -## [1978. Employees Whose Manager Left the Company (Easy)](https://leetcode.com/problems/employees-whose-manager-left-the-company "") +## [1978. Employees Whose Manager Left the Company (Easy)](https://leetcode.com/problems/employees-whose-manager-left-the-company "上级经理已离职的公司员工") diff --git a/problems/encode-and-decode-strings/README.md b/problems/encode-and-decode-strings/README.md index b24f694f4..b1676d0e4 100644 --- a/problems/encode-and-decode-strings/README.md +++ b/problems/encode-and-decode-strings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../closest-binary-search-tree-value "Closest Binary Search Tree Value") @@ -56,9 +56,9 @@ vector<string> strs2 = decode(encoded_string); ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] ### Similar Questions 1. [Count and Say](../count-and-say) (Medium) diff --git a/problems/encode-and-decode-tinyurl/README.md b/problems/encode-and-decode-tinyurl/README.md index 66c905748..da7d5d6bd 100644 --- a/problems/encode-and-decode-tinyurl/README.md +++ b/problems/encode-and-decode-tinyurl/README.md @@ -47,7 +47,7 @@ string ans = obj.decode(tiny); // returns the original url after deconding it. ### Related Topics - [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] [[Hash Function](../../tag/hash-function/README.md)] diff --git a/problems/encode-n-ary-tree-to-binary-tree/README.md b/problems/encode-n-ary-tree-to-binary-tree/README.md index 22250ebe7..4ed404913 100644 --- a/problems/encode-n-ary-tree-to-binary-tree/README.md +++ b/problems/encode-n-ary-tree-to-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flatten-a-multilevel-doubly-linked-list "Flatten a Multilevel Doubly Linked List") diff --git a/problems/equal-rational-numbers/README.md b/problems/equal-rational-numbers/README.md index 6bf83eb5e..c11e97a3a 100644 --- a/problems/equal-rational-numbers/README.md +++ b/problems/equal-rational-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flip-binary-tree-to-match-preorder-traversal "Flip Binary Tree To Match Preorder Traversal") diff --git a/problems/erect-the-fence-ii/README.md b/problems/erect-the-fence-ii/README.md index 4ca218a50..dcc541793 100644 --- a/problems/erect-the-fence-ii/README.md +++ b/problems/erect-the-fence-ii/README.md @@ -9,7 +9,7 @@                  [Next >](../count-square-sum-triples "Count Square Sum Triples") -## [1924. Erect the Fence II (Hard)](https://leetcode.com/problems/erect-the-fence-ii "") +## [1924. Erect the Fence II (Hard)](https://leetcode.com/problems/erect-the-fence-ii "安装栅栏 II") diff --git a/problems/escape-a-large-maze/README.md b/problems/escape-a-large-maze/README.md index d8546cb79..94f65508f 100644 --- a/problems/escape-a-large-maze/README.md +++ b/problems/escape-a-large-maze/README.md @@ -52,10 +52,10 @@ We cannot move south or west because we cannot go outside of the grid. ### Related Topics - [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Hints
    diff --git a/problems/evaluate-reverse-polish-notation/README.md b/problems/evaluate-reverse-polish-notation/README.md index 9db4857d2..43faff9a6 100644 --- a/problems/evaluate-reverse-polish-notation/README.md +++ b/problems/evaluate-reverse-polish-notation/README.md @@ -59,9 +59,9 @@ ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Stack](../../tag/stack/README.md)] ### Similar Questions 1. [Basic Calculator](../basic-calculator) (Hard) diff --git a/problems/evaluate-the-bracket-pairs-of-a-string/README.md b/problems/evaluate-the-bracket-pairs-of-a-string/README.md index 5e9c0c85e..dc2c9de26 100644 --- a/problems/evaluate-the-bracket-pairs-of-a-string/README.md +++ b/problems/evaluate-the-bracket-pairs-of-a-string/README.md @@ -59,12 +59,6 @@ The key "a" has a value of "yes", so replace all occurrences Notice that the "a"s not in a bracket pair are not evaluated. -

    Example 4:

    - -
    -Input: s = "(a)(b)", knowledge = [["a","b"],["b","a"]]
    -Output: "ba"
    -

     

    Constraints:

    diff --git a/problems/even-odd-tree/README.md b/problems/even-odd-tree/README.md index 2cbc1f3a2..733b0e483 100644 --- a/problems/even-odd-tree/README.md +++ b/problems/even-odd-tree/README.md @@ -23,9 +23,7 @@

     

    Example 1:

    - -

    - +
     Input: root = [1,10,4,3,null,7,9,12,8,6,null,null,2]
     Output: true
    @@ -34,13 +32,11 @@ Level 0: [1]
     Level 1: [10,4]
     Level 2: [3,7,9]
     Level 3: [12,8,6,2]
    -Since levels 0 and 2 are all odd and increasing, and levels 1 and 3 are all even and decreasing, the tree is Even-Odd.
    +Since levels 0 and 2 are all odd and increasing and levels 1 and 3 are all even and decreasing, the tree is Even-Odd.
     

    Example 2:

    - -

    - +
     Input: root = [5,4,2,3,3,7]
     Output: false
    @@ -48,33 +44,17 @@ Since levels 0 and 2 are all odd and increasing, and levels 1 and 3 are all even
     Level 0: [5]
     Level 1: [4,2]
     Level 2: [3,3,7]
    -Node values in the level 2 must be in strictly increasing order, so the tree is not Even-Odd.
    +Node values in level 2 must be in strictly increasing order, so the tree is not Even-Odd.
     

    Example 3:

    - -

    - +
     Input: root = [5,9,1,3,5,7]
     Output: false
     Explanation: Node values in the level 1 should be even integers.
     
    -

    Example 4:

    - -
    -Input: root = [1]
    -Output: true
    -
    - -

    Example 5:

    - -
    -Input: root = [11,8,6,1,3,9,11,30,20,18,16,12,10,4,2,17]
    -Output: true
    -
    -

     

    Constraints:

    diff --git a/problems/excel-sheet-column-number/README.md b/problems/excel-sheet-column-number/README.md index 2db81257f..dad535777 100644 --- a/problems/excel-sheet-column-number/README.md +++ b/problems/excel-sheet-column-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-sum-iii-data-structure-design "Two Sum III - Data structure design") @@ -48,13 +48,6 @@ AB -> 28 Output: 701 -

    Example 4:

    - -
    -Input: columnTitle = "FXSHRXW"
    -Output: 2147483647
    -
    -

     

    Constraints:

    diff --git a/problems/execution-of-all-suffix-instructions-staying-in-a-grid/README.md b/problems/execution-of-all-suffix-instructions-staying-in-a-grid/README.md new file mode 100644 index 000000000..b462fe8ea --- /dev/null +++ b/problems/execution-of-all-suffix-instructions-staying-in-a-grid/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../a-number-after-a-double-reversal "A Number After a Double Reversal") +                 +[Next >](../intervals-between-identical-elements "Intervals Between Identical Elements") + +## [2120. Execution of All Suffix Instructions Staying in a Grid (Medium)](https://leetcode.com/problems/execution-of-all-suffix-instructions-staying-in-a-grid "执行所有后缀指令") + +

    There is an n x n grid, with the top-left cell at (0, 0) and the bottom-right cell at (n - 1, n - 1). You are given the integer n and an integer array startPos where startPos = [startrow, startcol] indicates that a robot is initially at cell (startrow, startcol).

    + +

    You are also given a 0-indexed string s of length m where s[i] is the ith instruction for the robot: 'L' (move left), 'R' (move right), 'U' (move up), and 'D' (move down).

    + +

    The robot can begin executing from any ith instruction in s. It executes the instructions one by one towards the end of s but it stops if either of these conditions is met:

    + +
      +
    • The next instruction will move the robot off the grid.
    • +
    • There are no more instructions left to execute.
    • +
    + +

    Return an array answer of length m where answer[i] is the number of instructions the robot can execute if the robot begins executing from the ith instruction in s.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 3, startPos = [0,1], s = "RRDDLU"
    +Output: [1,5,4,3,1,0]
    +Explanation: Starting from startPos and beginning execution from the ith instruction:
    +- 0th: "RRDDLU". Only one instruction "R" can be executed before it moves off the grid.
    +- 1st:  "RDDLU". All five instructions can be executed while it stays in the grid and ends at (1, 1).
    +- 2nd:   "DDLU". All four instructions can be executed while it stays in the grid and ends at (1, 0).
    +- 3rd:    "DLU". All three instructions can be executed while it stays in the grid and ends at (0, 0).
    +- 4th:     "LU". Only one instruction "L" can be executed before it moves off the grid.
    +- 5th:      "U". If moving up, it would move off the grid.
    +
    + +

    Example 2:

    + +
    +Input: n = 2, startPos = [1,1], s = "LURD"
    +Output: [4,1,0,0]
    +Explanation:
    +- 0th: "LURD".
    +- 1st:  "URD".
    +- 2nd:   "RD".
    +- 3rd:    "D".
    +
    + +

    Example 3:

    + +
    +Input: n = 1, startPos = [0,0], s = "LRUD"
    +Output: [0,0,0,0]
    +Explanation: No matter which instruction the robot begins execution from, it would move off the grid.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == s.length
    • +
    • 1 <= n, m <= 500
    • +
    • startPos.length == 2
    • +
    • 0 <= startrow, startcol < n
    • +
    • s consists of 'L', 'R', 'U', and 'D'.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +The constraints are not very large. Can we simulate the execution by starting from each index of s? +
    + +
    +Hint 2 +Before any of the stopping conditions is met, stop the simulation for that index and set the answer for that index. +
    diff --git a/problems/fair-candy-swap/README.md b/problems/fair-candy-swap/README.md index 65f8226b2..dbdc443d5 100644 --- a/problems/fair-candy-swap/README.md +++ b/problems/fair-candy-swap/README.md @@ -1,15 +1,15 @@ - - - + + + [< Previous](../super-egg-drop "Super Egg Drop")                  [Next >](../construct-binary-tree-from-preorder-and-postorder-traversal "Construct Binary Tree from Preorder and Postorder Traversal") -## [888. Fair Candy Swap (Easy)](https://leetcode.com/problems/fair-candy-swap "公平的糖果棒交换") +## [888. Fair Candy Swap (Easy)](https://leetcode.com/problems/fair-candy-swap "公平的糖果交换")

    Alice and Bob have a different total number of candies. You are given two integer arrays aliceSizes and bobSizes where aliceSizes[i] is the number of candies of the ith box of candy that Alice has and bobSizes[j] is the number of candies of the jth box of candy that Bob has.

    @@ -39,13 +39,6 @@ Output: [2,3] -

    Example 4:

    - -
    -Input: aliceSizes = [1,2,5], bobSizes = [2,4]
    -Output: [5,4]
    -
    -

     

    Constraints:

    diff --git a/problems/filling-bookcase-shelves/README.md b/problems/filling-bookcase-shelves/README.md index 7906d6302..c6cf32c76 100644 --- a/problems/filling-bookcase-shelves/README.md +++ b/problems/filling-bookcase-shelves/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-in-zigzag-labelled-binary-tree "Path In Zigzag Labelled Binary Tree") diff --git a/problems/final-prices-with-a-special-discount-in-a-shop/README.md b/problems/final-prices-with-a-special-discount-in-a-shop/README.md index 25c0fa2da..7c6538477 100644 --- a/problems/final-prices-with-a-special-discount-in-a-shop/README.md +++ b/problems/final-prices-with-a-special-discount-in-a-shop/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-n-nodes-after-m-nodes-of-a-linked-list "Delete N Nodes After M Nodes of a Linked List") diff --git a/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md b/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md index 84e1c95e2..66b06bfd1 100644 --- a/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md +++ b/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../replace-employee-id-with-the-unique-identifier "Replace Employee ID With The Unique Identifier") @@ -42,20 +42,6 @@ Output: 4 -

    Example 4:

    - -
    -Input: tree = [1,2,3,4,5,6,7,8,9,10], target = 5
    -Output: 5
    -
    - -

    Example 5:

    - -
    -Input: tree = [1,2,null,3], target = 2
    -Output: 2
    -
    -

     

    Constraints:

    diff --git a/problems/find-a-peak-element-ii/README.md b/problems/find-a-peak-element-ii/README.md index cdf0afb44..c47255627 100644 --- a/problems/find-a-peak-element-ii/README.md +++ b/problems/find-a-peak-element-ii/README.md @@ -57,6 +57,9 @@ [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Find Peak Element](../find-peak-element) (Medium) + ### Hints
    Hint 1 diff --git a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md index 93a511564..bf5dc8ff7 100644 --- a/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md +++ b/problems/find-a-value-of-a-mysterious-function-closest-to-target/README.md @@ -53,10 +53,10 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] - [[Segment Tree](../../tag/segment-tree/README.md)] [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] ### Hints
    diff --git a/problems/find-all-duplicates-in-an-array/README.md b/problems/find-all-duplicates-in-an-array/README.md index c3651b409..56daee0c2 100644 --- a/problems/find-all-duplicates-in-an-array/README.md +++ b/problems/find-all-duplicates-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../arranging-coins "Arranging Coins") diff --git a/problems/find-all-lonely-numbers-in-the-array/README.md b/problems/find-all-lonely-numbers-in-the-array/README.md new file mode 100644 index 000000000..3ab667e3d --- /dev/null +++ b/problems/find-all-lonely-numbers-in-the-array/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../rearrange-array-elements-by-sign "Rearrange Array Elements by Sign") +                 +[Next >](../maximum-good-people-based-on-statements "Maximum Good People Based on Statements") + +## [2150. Find All Lonely Numbers in the Array (Medium)](https://leetcode.com/problems/find-all-lonely-numbers-in-the-array "找出数组中的所有孤独数字") + +

    You are given an integer array nums. A number x is lonely when it appears only once, and no adjacent numbers (i.e. x + 1 and x - 1) appear in the array.

    + +

    Return all lonely numbers in nums. You may return the answer in any order.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [10,6,5,8]
    +Output: [10,8]
    +Explanation: 
    +- 10 is a lonely number since it appears exactly once and 9 and 11 does not appear in nums.
    +- 8 is a lonely number since it appears exactly once and 7 and 9 does not appear in nums.
    +- 5 is not a lonely number since 6 appears in nums and vice versa.
    +Hence, the lonely numbers in nums are [10, 8].
    +Note that [8, 10] may also be returned.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,3,5,3]
    +Output: [1,5]
    +Explanation: 
    +- 1 is a lonely number since it appears exactly once and 0 and 2 does not appear in nums.
    +- 5 is a lonely number since it appears exactly once and 4 and 6 does not appear in nums.
    +- 3 is not a lonely number since it appears twice.
    +Hence, the lonely numbers in nums are [1, 5].
    +Note that [5, 1] may also be returned.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 0 <= nums[i] <= 106
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Hints +
    +Hint 1 +For a given element x, how can you quickly check if x - 1 and x + 1 are present in the array without reiterating through the entire array? +
    + +
    +Hint 2 +Use a set or a hash map. +
    diff --git a/problems/find-all-people-with-secret/README.md b/problems/find-all-people-with-secret/README.md new file mode 100644 index 000000000..0ff67d5f5 --- /dev/null +++ b/problems/find-all-people-with-secret/README.md @@ -0,0 +1,95 @@ + + + + + + + +[< Previous](../removing-minimum-and-maximum-from-array "Removing Minimum and Maximum From Array") +                 +[Next >](../minimum-cost-to-reach-city-with-discounts "Minimum Cost to Reach City With Discounts") + +## [2092. Find All People With Secret (Hard)](https://leetcode.com/problems/find-all-people-with-secret "找出知晓秘密的所有专家") + +

    You are given an integer n indicating there are n people numbered from 0 to n - 1. You are also given a 0-indexed 2D integer array meetings where meetings[i] = [xi, yi, timei] indicates that person xi and person yi have a meeting at timei. A person may attend multiple meetings at the same time. Finally, you are given an integer firstPerson.

    + +

    Person 0 has a secret and initially shares the secret with a person firstPerson at time 0. This secret is then shared every time a meeting takes place with a person that has the secret. More formally, for every meeting, if a person xi has the secret at timei, then they will share the secret with person yi, and vice versa.

    + +

    The secrets are shared instantaneously. That is, a person may receive the secret and share it with people in other meetings within the same time frame.

    + +

    Return a list of all the people that have the secret after all the meetings have taken place. You may return the answer in any order.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 6, meetings = [[1,2,5],[2,3,8],[1,5,10]], firstPerson = 1
    +Output: [0,1,2,3,5]
    +Explanation:
    +At time 0, person 0 shares the secret with person 1.
    +At time 5, person 1 shares the secret with person 2.
    +At time 8, person 2 shares the secret with person 3.
    +At time 10, person 1 shares the secret with person 5.​​​​
    +Thus, people 0, 1, 2, 3, and 5 know the secret after all the meetings.
    +
    + +

    Example 2:

    + +
    +Input: n = 4, meetings = [[3,1,3],[1,2,2],[0,3,3]], firstPerson = 3
    +Output: [0,1,3]
    +Explanation:
    +At time 0, person 0 shares the secret with person 3.
    +At time 2, neither person 1 nor person 2 know the secret.
    +At time 3, person 3 shares the secret with person 0 and person 1.
    +Thus, people 0, 1, and 3 know the secret after all the meetings.
    +
    + +

    Example 3:

    + +
    +Input: n = 5, meetings = [[3,4,2],[1,2,1],[2,3,1]], firstPerson = 1
    +Output: [0,1,2,3,4]
    +Explanation:
    +At time 0, person 0 shares the secret with person 1.
    +At time 1, person 1 shares the secret with person 2, and person 2 shares the secret with person 3.
    +Note that person 2 can share the secret at the same time as receiving it.
    +At time 2, person 3 shares the secret with person 4.
    +Thus, people 0, 1, 2, 3, and 4 know the secret after all the meetings.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= n <= 105
    • +
    • 1 <= meetings.length <= 105
    • +
    • meetings[i].length == 3
    • +
    • 0 <= xi, yi <= n - 1
    • +
    • xi != yi
    • +
    • 1 <= timei <= 105
    • +
    • 1 <= firstPerson <= n - 1
    • +
    + +### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Could you model all the meetings happening at the same time as a graph? +
    + +
    +Hint 2 +What data structure can you use to efficiently share the secret? +
    + +
    +Hint 3 +You can use the union-find data structure to quickly determine who knows the secret and share the secret. +
    diff --git a/problems/find-all-possible-recipes-from-given-supplies/README.md b/problems/find-all-possible-recipes-from-given-supplies/README.md new file mode 100644 index 000000000..a2dc609d4 --- /dev/null +++ b/problems/find-all-possible-recipes-from-given-supplies/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../maximum-number-of-words-found-in-sentences "Maximum Number of Words Found in Sentences") +                 +[Next >](../check-if-a-parentheses-string-can-be-valid "Check if a Parentheses String Can Be Valid") + +## [2115. Find All Possible Recipes from Given Supplies (Medium)](https://leetcode.com/problems/find-all-possible-recipes-from-given-supplies "从给定原材料中找到所有可以做出的菜") + +

    You have information about n different recipes. You are given a string array recipes and a 2D string array ingredients. The ith recipe has the name recipes[i], and you can create it if you have all the needed ingredients from ingredients[i]. Ingredients to a recipe may need to be created from other recipes, i.e., ingredients[i] may contain a string that is in recipes.

    + +

    You are also given a string array supplies containing all the ingredients that you initially have, and you have an infinite supply of all of them.

    + +

    Return a list of all the recipes that you can create. You may return the answer in any order.

    + +

    Note that two recipes may contain each other in their ingredients.

    + +

     

    +

    Example 1:

    + +
    +Input: recipes = ["bread"], ingredients = [["yeast","flour"]], supplies = ["yeast","flour","corn"]
    +Output: ["bread"]
    +Explanation:
    +We can create "bread" since we have the ingredients "yeast" and "flour".
    +
    + +

    Example 2:

    + +
    +Input: recipes = ["bread","sandwich"], ingredients = [["yeast","flour"],["bread","meat"]], supplies = ["yeast","flour","meat"]
    +Output: ["bread","sandwich"]
    +Explanation:
    +We can create "bread" since we have the ingredients "yeast" and "flour".
    +We can create "sandwich" since we have the ingredient "meat" and can create the ingredient "bread".
    +
    + +

    Example 3:

    + +
    +Input: recipes = ["bread","sandwich","burger"], ingredients = [["yeast","flour"],["bread","meat"],["sandwich","meat","bread"]], supplies = ["yeast","flour","meat"]
    +Output: ["bread","sandwich","burger"]
    +Explanation:
    +We can create "bread" since we have the ingredients "yeast" and "flour".
    +We can create "sandwich" since we have the ingredient "meat" and can create the ingredient "bread".
    +We can create "burger" since we have the ingredient "meat" and can create the ingredients "bread" and "sandwich".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == recipes.length == ingredients.length
    • +
    • 1 <= n <= 100
    • +
    • 1 <= ingredients[i].length, supplies.length <= 100
    • +
    • 1 <= recipes[i].length, ingredients[i][j].length, supplies[k].length <= 10
    • +
    • recipes[i], ingredients[i][j], and supplies[k] consist only of lowercase English letters.
    • +
    • All the values of recipes and supplies combined are unique.
    • +
    • Each ingredients[i] does not contain any duplicate values.
    • +
    + +### Related Topics + [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Can we use a data structure to quickly query whether we have a certain ingredient? +
    + +
    +Hint 2 +Once we verify that we can make a recipe, we can add it to our ingredient data structure. We can then check if we can make more recipes as a result of this. +
    diff --git a/problems/find-all-the-lonely-nodes/README.md b/problems/find-all-the-lonely-nodes/README.md index d0bb2cb6d..d7b5cec33 100644 --- a/problems/find-all-the-lonely-nodes/README.md +++ b/problems/find-all-the-lonely-nodes/README.md @@ -19,6 +19,10 @@ [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Binary Tree Tilt](../binary-tree-tilt) (Easy) + 1. [Univalued Binary Tree](../univalued-binary-tree) (Easy) + ### Hints
    Hint 1 diff --git a/problems/find-and-replace-in-string/README.md b/problems/find-and-replace-in-string/README.md index a7f371184..1d762c099 100644 --- a/problems/find-and-replace-in-string/README.md +++ b/problems/find-and-replace-in-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flipping-an-image "Flipping an Image") diff --git a/problems/find-and-replace-pattern/README.md b/problems/find-and-replace-pattern/README.md index f1d5c8d67..9dfda5196 100644 --- a/problems/find-and-replace-pattern/README.md +++ b/problems/find-and-replace-pattern/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../construct-binary-tree-from-preorder-and-postorder-traversal "Construct Binary Tree from Preorder and Postorder Traversal") diff --git a/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md b/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md index d8036fa81..01117621a 100644 --- a/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md +++ b/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../avoid-flood-in-the-city "Avoid Flood in The City") diff --git a/problems/find-cutoff-score-for-each-school/README.md b/problems/find-cutoff-score-for-each-school/README.md index 5009be138..81a12ad5a 100644 --- a/problems/find-cutoff-score-for-each-school/README.md +++ b/problems/find-cutoff-score-for-each-school/README.md @@ -9,6 +9,6 @@                  [Next >](../maximum-number-of-people-that-can-be-caught-in-tag "Maximum Number of People That Can Be Caught in Tag") -## [1988. Find Cutoff Score for Each School (Medium)](https://leetcode.com/problems/find-cutoff-score-for-each-school "") +## [1988. Find Cutoff Score for Each School (Medium)](https://leetcode.com/problems/find-cutoff-score-for-each-school "找出每所学校的最低分数要求") diff --git a/problems/find-duplicate-subtrees/README.md b/problems/find-duplicate-subtrees/README.md index 13bb973a2..83c94b5a6 100644 --- a/problems/find-duplicate-subtrees/README.md +++ b/problems/find-duplicate-subtrees/README.md @@ -57,3 +57,4 @@ 1. [Serialize and Deserialize Binary Tree](../serialize-and-deserialize-binary-tree) (Hard) 1. [Serialize and Deserialize BST](../serialize-and-deserialize-bst) (Medium) 1. [Construct String from Binary Tree](../construct-string-from-binary-tree) (Easy) + 1. [Delete Duplicate Folders in System](../delete-duplicate-folders-in-system) (Hard) diff --git a/problems/find-first-and-last-position-of-element-in-sorted-array/README.md b/problems/find-first-and-last-position-of-element-in-sorted-array/README.md index fd35bab24..bc6e12886 100644 --- a/problems/find-first-and-last-position-of-element-in-sorted-array/README.md +++ b/problems/find-first-and-last-position-of-element-in-sorted-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../search-in-rotated-sorted-array "Search in Rotated Sorted Array") @@ -11,7 +11,7 @@ ## [34. Find First and Last Position of Element in Sorted Array (Medium)](https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array "在排序数组中查找元素的第一个和最后一个位置") -

    Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.

    +

    Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value.

    If target is not found in the array, return [-1, -1].

    @@ -44,3 +44,5 @@ ### Similar Questions 1. [First Bad Version](../first-bad-version) (Easy) + 1. [Plates Between Candles](../plates-between-candles) (Medium) + 1. [Find Target Indices After Sorting Array](../find-target-indices-after-sorting-array) (Easy) diff --git a/problems/find-first-palindromic-string-in-the-array/README.md b/problems/find-first-palindromic-string-in-the-array/README.md new file mode 100644 index 000000000..d10defefd --- /dev/null +++ b/problems/find-first-palindromic-string-in-the-array/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../number-of-unique-flavors-after-sharing-k-candies "Number of Unique Flavors After Sharing K Candies") +                 +[Next >](../adding-spaces-to-a-string "Adding Spaces to a String") + +## [2108. Find First Palindromic String in the Array (Easy)](https://leetcode.com/problems/find-first-palindromic-string-in-the-array "找出数组中的第一个回文字符串") + +

    Given an array of strings words, return the first palindromic string in the array. If there is no such string, return an empty string "".

    + +

    A string is palindromic if it reads the same forward and backward.

    + +

     

    +

    Example 1:

    + +
    +Input: words = ["abc","car","ada","racecar","cool"]
    +Output: "ada"
    +Explanation: The first string that is palindromic is "ada".
    +Note that "racecar" is also palindromic, but it is not the first.
    +
    + +

    Example 2:

    + +
    +Input: words = ["notapalindrome","racecar"]
    +Output: "racecar"
    +Explanation: The first and only string that is palindromic is "racecar".
    +
    + +

    Example 3:

    + +
    +Input: words = ["def","ghi"]
    +Output: ""
    +Explanation: There are no palindromic strings, so the empty string is returned.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 100
    • +
    • 1 <= words[i].length <= 100
    • +
    • words[i] consists only of lowercase English letters.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Iterate through the elements in order. As soon as the current element is a palindrome, return it. +
    + +
    +Hint 2 +To check if an element is a palindrome, can you reverse the string? +
    diff --git a/problems/find-good-days-to-rob-the-bank/README.md b/problems/find-good-days-to-rob-the-bank/README.md new file mode 100644 index 000000000..0f8c76b53 --- /dev/null +++ b/problems/find-good-days-to-rob-the-bank/README.md @@ -0,0 +1,86 @@ + + + + + + + +[< Previous](../find-subsequence-of-length-k-with-the-largest-sum "Find Subsequence of Length K With the Largest Sum") +                 +[Next >](../detonate-the-maximum-bombs "Detonate the Maximum Bombs") + +## [2100. Find Good Days to Rob the Bank (Medium)](https://leetcode.com/problems/find-good-days-to-rob-the-bank "适合打劫银行的日子") + +

    You and a gang of thieves are planning on robbing a bank. You are given a 0-indexed integer array security, where security[i] is the number of guards on duty on the ith day. The days are numbered starting from 0. You are also given an integer time.

    + +

    The ith day is a good day to rob the bank if:

    + +
      +
    • There are at least time days before and after the ith day,
    • +
    • The number of guards at the bank for the time days before i are non-increasing, and
    • +
    • The number of guards at the bank for the time days after i are non-decreasing.
    • +
    + +

    More formally, this means day i is a good day to rob the bank if and only if security[i - time] >= security[i - time + 1] >= ... >= security[i] <= ... <= security[i + time - 1] <= security[i + time].

    + +

    Return a list of all days (0-indexed) that are good days to rob the bank. The order that the days are returned in does not matter.

    + +

     

    +

    Example 1:

    + +
    +Input: security = [5,3,3,3,5,6,2], time = 2
    +Output: [2,3]
    +Explanation:
    +On day 2, we have security[0] >= security[1] >= security[2] <= security[3] <= security[4].
    +On day 3, we have security[1] >= security[2] >= security[3] <= security[4] <= security[5].
    +No other days satisfy this condition, so days 2 and 3 are the only good days to rob the bank.
    +
    + +

    Example 2:

    + +
    +Input: security = [1,1,1,1,1], time = 0
    +Output: [0,1,2,3,4]
    +Explanation:
    +Since time equals 0, every day is a good day to rob the bank, so return every day.
    +
    + +

    Example 3:

    + +
    +Input: security = [1,2,3,4,5,6], time = 2
    +Output: []
    +Explanation:
    +No day has 2 days before it that have a non-increasing number of guards.
    +Thus, no day is a good day to rob the bank, so return an empty list.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= security.length <= 105
    • +
    • 0 <= security[i], time <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +The trivial solution is to check the time days before and after each day. There are a lot of repeated operations using this solution. How could we optimize this solution? +
    + +
    +Hint 2 +We can use precomputation to make the solution faster. +
    + +
    +Hint 3 +Use an array to store the number of days before the ith day that is non-increasing, and another array to store the number of days after the ith day that is non-decreasing. +
    diff --git a/problems/find-if-path-exists-in-graph/README.md b/problems/find-if-path-exists-in-graph/README.md index 08b773042..f0623ec1c 100644 --- a/problems/find-if-path-exists-in-graph/README.md +++ b/problems/find-if-path-exists-in-graph/README.md @@ -13,15 +13,15 @@

    There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself.

    -

    You want to determine if there is a valid path that exists from vertex start to vertex end.

    +

    You want to determine if there is a valid path that exists from vertex source to vertex destination.

    -

    Given edges and the integers n, start, and end, return true if there is a valid path from start to end, or false otherwise.

    +

    Given edges and the integers n, source, and destination, return true if there is a valid path from source to destination, or false otherwise.

     

    Example 1:

    -Input: n = 3, edges = [[0,1],[1,2],[2,0]], start = 0, end = 2
    +Input: n = 3, edges = [[0,1],[1,2],[2,0]], source = 0, destination = 2
     Output: true
     Explanation: There are two paths from vertex 0 to vertex 2:
     - 0 → 1 → 2
    @@ -31,7 +31,7 @@
     

    Example 2:

    -Input: n = 6, edges = [[0,1],[0,2],[3,5],[5,4],[4,3]], start = 0, end = 5
    +Input: n = 6, edges = [[0,1],[0,2],[3,5],[5,4],[4,3]], source = 0, destination = 5
     Output: false
     Explanation: There is no path from vertex 0 to vertex 5.
     
    @@ -45,7 +45,7 @@
  • edges[i].length == 2
  • 0 <= ui, vi <= n - 1
  • ui != vi
  • -
  • 0 <= start, end <= n - 1
  • +
  • 0 <= source, destination <= n - 1
  • There are no duplicate edges.
  • There are no self edges.
  • diff --git a/problems/find-k-closest-elements/README.md b/problems/find-k-closest-elements/README.md index db3d6d94d..3256c0ea8 100644 --- a/problems/find-k-closest-elements/README.md +++ b/problems/find-k-closest-elements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../robot-return-to-origin "Robot Return to Origin") diff --git a/problems/find-k-length-substrings-with-no-repeated-characters/README.md b/problems/find-k-length-substrings-with-no-repeated-characters/README.md index 8bbd4791a..2ffabda34 100644 --- a/problems/find-k-length-substrings-with-no-repeated-characters/README.md +++ b/problems/find-k-length-substrings-with-no-repeated-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-sum-less-than-k "Two Sum Less Than K") diff --git a/problems/find-kth-bit-in-nth-binary-string/README.md b/problems/find-kth-bit-in-nth-binary-string/README.md index c6deb7db6..a3be3ef9b 100644 --- a/problems/find-kth-bit-in-nth-binary-string/README.md +++ b/problems/find-kth-bit-in-nth-binary-string/README.md @@ -15,12 +15,12 @@
    • S1 = "0"
    • -
    • Si = Si-1 + "1" + reverse(invert(Si-1)) for i > 1
    • +
    • Si = Si - 1 + "1" + reverse(invert(Si - 1)) for i > 1
    -

    Where + denotes the concatenation operation, reverse(x) returns the reversed string x, and invert(x) inverts all the bits in x (0 changes to 1 and 1 changes to 0).

    +

    Where + denotes the concatenation operation, reverse(x) returns the reversed string x, and invert(x) inverts all the bits in x (0 changes to 1 and 1 changes to 0).

    -

    For example, the first 4 strings in the above sequence are:

    +

    For example, the first four strings in the above sequence are:

    • S1 = "0"
    • @@ -37,7 +37,8 @@
       Input: n = 3, k = 1
       Output: "0"
      -Explanation: S3 is "0111001". The first bit is "0".
      +Explanation: S3 is "0111001".
      +The 1st bit is "0".
       

      Example 2:

      @@ -45,21 +46,8 @@
       Input: n = 4, k = 11
       Output: "1"
      -Explanation: S4 is "011100110110001". The 11th bit is "1".
      -
      - -

      Example 3:

      - -
      -Input: n = 1, k = 1
      -Output: "0"
      -
      - -

      Example 4:

      - -
      -Input: n = 2, k = 3
      -Output: "1"
      +Explanation: S4 is "011100110110001".
      +The 11th bit is "1".
       

       

      diff --git a/problems/find-kth-largest-xor-coordinate-value/README.md b/problems/find-kth-largest-xor-coordinate-value/README.md index 09a8dc816..1e1e0f942 100644 --- a/problems/find-kth-largest-xor-coordinate-value/README.md +++ b/problems/find-kth-largest-xor-coordinate-value/README.md @@ -23,14 +23,16 @@
       Input: matrix = [[5,2],[1,6]], k = 1
       Output: 7
      -Explanation: The value of coordinate (0,1) is 5 XOR 2 = 7, which is the largest value.
      +Explanation: The value of coordinate (0,1) is 5 XOR 2 = 7, which is the largest value. +

    Example 2:

     Input: matrix = [[5,2],[1,6]], k = 2
     Output: 5
    -Explanation: The value of coordinate (0,0) is 5 = 5, which is the 2nd largest value.
    +Explanation: The value of coordinate (0,0) is 5 = 5, which is the 2nd largest value. +

    Example 3:

    @@ -39,13 +41,6 @@ Output: 4 Explanation: The value of coordinate (1,0) is 5 XOR 1 = 4, which is the 3rd largest value. -

    Example 4:

    - -
    -Input: matrix = [[5,2],[1,6]], k = 4
    -Output: 0
    -Explanation: The value of coordinate (1,1) is 5 XOR 2 XOR 1 XOR 6 = 0, which is the 4th largest value.
    -

     

    Constraints:

    diff --git a/problems/find-latest-group-of-size-m/README.md b/problems/find-latest-group-of-size-m/README.md index 7b8f9ad12..a9082fdad 100644 --- a/problems/find-latest-group-of-size-m/README.md +++ b/problems/find-latest-group-of-size-m/README.md @@ -25,21 +25,22 @@
     Input: arr = [3,5,1,2,4], m = 1
     Output: 4
    -Explanation:
    -Step 1: "00100", groups: ["1"]
    +Explanation: 
    +Step 1: "00100", groups: ["1"]
     Step 2: "00101", groups: ["1", "1"]
     Step 3: "10101", groups: ["1", "1", "1"]
     Step 4: "11101", groups: ["111", "1"]
     Step 5: "11111", groups: ["11111"]
    -The latest step at which there exists a group of size 1 is step 4.
    +The latest step at which there exists a group of size 1 is step 4. +

    Example 2:

     Input: arr = [3,1,5,4,2], m = 2
     Output: -1
    -Explanation:
    -Step 1: "00100", groups: ["1"]
    +Explanation: 
    +Step 1: "00100", groups: ["1"]
     Step 2: "10100", groups: ["1", "1"]
     Step 3: "10101", groups: ["1", "1", "1"]
     Step 4: "10111", groups: ["1", "111"]
    @@ -47,20 +48,6 @@ Step 5: "11111", groups: ["11111"]
     No group of size 2 exists during any step.
     
    -

    Example 3:

    - -
    -Input: arr = [1], m = 1
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: arr = [2,1], m = 2
    -Output: 2
    -
    -

     

    Constraints:

    diff --git a/problems/find-longest-awesome-substring/README.md b/problems/find-longest-awesome-substring/README.md index 35bff6ebc..b024ca96d 100644 --- a/problems/find-longest-awesome-substring/README.md +++ b/problems/find-longest-awesome-substring/README.md @@ -11,9 +11,9 @@ ## [1542. Find Longest Awesome Substring (Hard)](https://leetcode.com/problems/find-longest-awesome-substring "找出最长的超赞子字符串") -

    Given a string s. An awesome substring is a non-empty substring of s such that we can make any number of swaps in order to make it palindrome.

    +

    You are given a string s. An awesome substring is a non-empty substring of s such that we can make any number of swaps in order to make it a palindrome.

    -

    Return the length of the maximum length awesome substring of s.

    +

    Return the length of the maximum length awesome substring of s.

     

    Example 1:

    @@ -39,13 +39,6 @@ Explanation: "213123" is the longest awesome substring, we can form the palindrome "231132" with some swaps. -

    Example 4:

    - -
    -Input: s = "00"
    -Output: 2
    -
    -

     

    Constraints:

    diff --git a/problems/find-lucky-integer-in-an-array/README.md b/problems/find-lucky-integer-in-an-array/README.md index 2308ca8e0..197c818bd 100644 --- a/problems/find-lucky-integer-in-an-array/README.md +++ b/problems/find-lucky-integer-in-an-array/README.md @@ -11,9 +11,9 @@ ## [1394. Find Lucky Integer in an Array (Easy)](https://leetcode.com/problems/find-lucky-integer-in-an-array "找出数组中的幸运数") -

    Given an array of integers arr, a lucky integer is an integer which has a frequency in the array equal to its value.

    +

    Given an array of integers arr, a lucky integer is an integer that has a frequency in the array equal to its value.

    -

    Return a lucky integer in the array. If there are multiple lucky integers return the largest of them. If there is no lucky integer return -1.

    +

    Return the largest lucky integer in the array. If there is no lucky integer return -1.

     

    Example 1:

    @@ -40,20 +40,6 @@ Explanation: There are no lucky numbers in the array. -

    Example 4:

    - -
    -Input: arr = [5]
    -Output: -1
    -
    - -

    Example 5:

    - -
    -Input: arr = [7,7,7,7,7,7,7]
    -Output: 7
    -
    -

     

    Constraints:

    diff --git a/problems/find-minimum-in-rotated-sorted-array-ii/README.md b/problems/find-minimum-in-rotated-sorted-array-ii/README.md index d9cf6cda9..5fa38008e 100644 --- a/problems/find-minimum-in-rotated-sorted-array-ii/README.md +++ b/problems/find-minimum-in-rotated-sorted-array-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-minimum-in-rotated-sorted-array "Find Minimum in Rotated Sorted Array") diff --git a/problems/find-missing-observations/README.md b/problems/find-missing-observations/README.md index 7509a72d7..65ccb1f6d 100644 --- a/problems/find-missing-observations/README.md +++ b/problems/find-missing-observations/README.md @@ -46,14 +46,6 @@ Explanation: It is impossible for the mean to be 6 no matter what the 4 missing rolls are. -

    Example 4:

    - -
    -Input: rolls = [1], mean = 3, n = 1
    -Output: [5]
    -Explanation: The mean of all n + m rolls is (1 + 5) / 2 = 3.
    -
    -

     

    Constraints:

    diff --git a/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md b/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md index 428b9c620..f390364e6 100644 --- a/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md +++ b/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/README.md @@ -51,6 +51,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] +### Similar Questions + 1. [K Closest Points to Origin](../k-closest-points-to-origin) (Medium) + ### Hints
    Hint 1 diff --git a/problems/find-numbers-with-even-number-of-digits/README.md b/problems/find-numbers-with-even-number-of-digits/README.md index b13bbff63..22abd4751 100644 --- a/problems/find-numbers-with-even-number-of-digits/README.md +++ b/problems/find-numbers-with-even-number-of-digits/README.md @@ -48,6 +48,9 @@ Only 1771 contains an even number of digits. ### Related Topics [[Array](../../tag/array/README.md)] +### Similar Questions + 1. [Finding 3-Digit Even Numbers](../finding-3-digit-even-numbers) (Easy) + ### Hints
    Hint 1 diff --git a/problems/find-root-of-n-ary-tree/README.md b/problems/find-root-of-n-ary-tree/README.md index 86d931298..1e76d79f4 100644 --- a/problems/find-root-of-n-ary-tree/README.md +++ b/problems/find-root-of-n-ary-tree/README.md @@ -14,13 +14,10 @@ ### Related Topics - [[Hash Table](../../tag/hash-table/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - -### Similar Questions - 1. [Move Sub-Tree of N-Ary Tree](../move-sub-tree-of-n-ary-tree) (Hard) + [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/find-servers-that-handled-most-number-of-requests/README.md b/problems/find-servers-that-handled-most-number-of-requests/README.md index c18b61cd2..ac8510ccd 100644 --- a/problems/find-servers-that-handled-most-number-of-requests/README.md +++ b/problems/find-servers-that-handled-most-number-of-requests/README.md @@ -30,7 +30,7 @@
     Input: k = 3, arrival = [1,2,3,4,5], load = [5,2,3,3,3] 
     Output: [1] 
    -Explanation:
    +Explanation: 
     All of the servers start out available.
     The first 3 requests are handled by the first 3 servers in order.
     Request 3 comes in. Server 0 is busy, so it's assigned to the next available server, which is 1.
    @@ -43,7 +43,7 @@ Servers 0 and 2 handled one request each, while server 1 handled two requests. H
     
     Input: k = 3, arrival = [1,2,3,4], load = [1,2,1,2]
     Output: [0]
    -Explanation:
    +Explanation: 
     The first 3 requests are handled by first 3 servers.
     Request 3 comes in. It is handled by server 0 since the server is available.
     Server 0 handled two requests, while servers 1 and 2 handled one request each. Hence server 0 is the busiest server.
    @@ -54,21 +54,7 @@ Server 0 handled two requests, while servers 1 and 2 handled one request each. H
     
     Input: k = 3, arrival = [1,2,3], load = [10,12,11]
     Output: [0,1,2]
    -Explanation: Each server handles a single request, so they are all considered the busiest.
    -
    - -

    Example 4:

    - -
    -Input: k = 3, arrival = [1,2,3,4,8,9,10], load = [5,2,10,3,1,2,2]
    -Output: [1]
    -
    - -

    Example 5:

    - -
    -Input: k = 1, arrival = [1], load = [1]
    -Output: [0]
    +Explanation: Each server handles a single request, so they are all considered the busiest.
     

     

    @@ -83,10 +69,10 @@ Server 0 handled two requests, while servers 1 and 2 handled one request each. H ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] ### Hints
    diff --git a/problems/find-subsequence-of-length-k-with-the-largest-sum/README.md b/problems/find-subsequence-of-length-k-with-the-largest-sum/README.md new file mode 100644 index 000000000..dcdab30b2 --- /dev/null +++ b/problems/find-subsequence-of-length-k-with-the-largest-sum/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../subsequence-of-size-k-with-the-largest-even-sum "Subsequence of Size K With the Largest Even Sum") +                 +[Next >](../find-good-days-to-rob-the-bank "Find Good Days to Rob the Bank") + +## [2099. Find Subsequence of Length K With the Largest Sum (Easy)](https://leetcode.com/problems/find-subsequence-of-length-k-with-the-largest-sum "找到和最大的长度为 K 的子序列") + +

    You are given an integer array nums and an integer k. You want to find a subsequence of nums of length k that has the largest sum.

    + +

    Return any such subsequence as an integer array of length k.

    + +

    A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [2,1,3,3], k = 2
    +Output: [3,3]
    +Explanation:
    +The subsequence has the largest sum of 3 + 3 = 6.
    + +

    Example 2:

    + +
    +Input: nums = [-1,-2,3,4], k = 3
    +Output: [-1,3,4]
    +Explanation: 
    +The subsequence has the largest sum of -1 + 3 + 4 = 6.
    +
    + +

    Example 3:

    + +
    +Input: nums = [3,4,3,3], k = 2
    +Output: [3,4]
    +Explanation:
    +The subsequence has the largest sum of 3 + 4 = 7. 
    +Another possible subsequence is [4, 3].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • -105 <= nums[i] <= 105
    • +
    • 1 <= k <= nums.length
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +From a greedy perspective, what k elements should you pick? +
    + +
    +Hint 2 +Could you sort the array while maintaining the index? +
    diff --git a/problems/find-substring-with-given-hash-value/README.md b/problems/find-substring-with-given-hash-value/README.md new file mode 100644 index 000000000..0c9182b7e --- /dev/null +++ b/problems/find-substring-with-given-hash-value/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../all-divisions-with-the-highest-score-of-a-binary-array "All Divisions With the Highest Score of a Binary Array") +                 +[Next >](../groups-of-strings "Groups of Strings") + +## [2156. Find Substring With Given Hash Value (Medium)](https://leetcode.com/problems/find-substring-with-given-hash-value "查找给定哈希值的子串") + +

    The hash of a 0-indexed string s of length k, given integers p and m, is computed using the following function:

    + +
      +
    • hash(s, p, m) = (val(s[0]) * p0 + val(s[1]) * p1 + ... + val(s[k-1]) * pk-1) mod m.
    • +
    + +

    Where val(s[i]) represents the index of s[i] in the alphabet from val('a') = 1 to val('z') = 26.

    + +

    You are given a string s and the integers power, modulo, k, and hashValue. Return sub, the first substring of s of length k such that hash(sub, power, modulo) == hashValue.

    + +

    The test cases will be generated such that an answer always exists.

    + +

    A substring is a contiguous non-empty sequence of characters within a string.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "leetcode", power = 7, modulo = 20, k = 2, hashValue = 0
    +Output: "ee"
    +Explanation: The hash of "ee" can be computed to be hash("ee", 7, 20) = (5 * 1 + 5 * 7) mod 20 = 40 mod 20 = 0. 
    +"ee" is the first substring of length 2 with hashValue 0. Hence, we return "ee".
    +
    + +

    Example 2:

    + +
    +Input: s = "fbxzaad", power = 31, modulo = 100, k = 3, hashValue = 32
    +Output: "fbx"
    +Explanation: The hash of "fbx" can be computed to be hash("fbx", 31, 100) = (6 * 1 + 2 * 31 + 24 * 312) mod 100 = 23132 mod 100 = 32. 
    +The hash of "bxz" can be computed to be hash("bxz", 31, 100) = (2 * 1 + 24 * 31 + 26 * 312) mod 100 = 25732 mod 100 = 32. 
    +"fbx" is the first substring of length 3 with hashValue 32. Hence, we return "fbx".
    +Note that "bxz" also has a hash of 32 but it appears later than "fbx".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= k <= s.length <= 2 * 104
    • +
    • 1 <= power, modulo <= 109
    • +
    • 0 <= hashValue < modulo
    • +
    • s consists of lowercase English letters only.
    • +
    • The test cases are generated such that an answer always exists.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] + +### Hints +
    +Hint 1 +How can we update the hash value efficiently while iterating instead of recalculating it each time? +
    + +
    +Hint 2 +Use the rolling hash method. +
    diff --git a/problems/find-target-indices-after-sorting-array/README.md b/problems/find-target-indices-after-sorting-array/README.md new file mode 100644 index 000000000..ef7f2708f --- /dev/null +++ b/problems/find-target-indices-after-sorting-array/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../count-fertile-pyramids-in-a-land "Count Fertile Pyramids in a Land") +                 +[Next >](../k-radius-subarray-averages "K Radius Subarray Averages") + +## [2089. Find Target Indices After Sorting Array (Easy)](https://leetcode.com/problems/find-target-indices-after-sorting-array "找出数组排序后的目标下标") + +

    You are given a 0-indexed integer array nums and a target element target.

    + +

    A target index is an index i such that nums[i] == target.

    + +

    Return a list of the target indices of nums after sorting nums in non-decreasing order. If there are no target indices, return an empty list. The returned list must be sorted in increasing order.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,5,2,3], target = 2
    +Output: [1,2]
    +Explanation: After sorting, nums is [1,2,2,3,5].
    +The indices where nums[i] == 2 are 1 and 2.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,2,5,2,3], target = 3
    +Output: [3]
    +Explanation: After sorting, nums is [1,2,2,3,5].
    +The index where nums[i] == 3 is 3.
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,2,5,2,3], target = 5
    +Output: [4]
    +Explanation: After sorting, nums is [1,2,2,3,5].
    +The index where nums[i] == 5 is 4.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • 1 <= nums[i], target <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Try "sorting" the array first. +
    + +
    +Hint 2 +Now find all indices in the array whose values are equal to target. +
    diff --git a/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md b/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md index 8a56a7c1b..fe8cd7fdf 100644 --- a/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md +++ b/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../filter-restaurants-by-vegan-friendly-price-and-distance "Filter Restaurants by Vegan-Friendly, Price and Distance") @@ -60,10 +60,13 @@ The city 0 has 1 neighboring city at a distanceThreshold = 2. ### Related Topics - [[Graph](../../tag/graph/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Graph](../../tag/graph/README.md)] [[Shortest Path](../../tag/shortest-path/README.md)] +### Similar Questions + 1. [Second Minimum Time to Reach Destination](../second-minimum-time-to-reach-destination) (Hard) + ### Hints
    Hint 1 diff --git a/problems/find-the-index-of-the-large-integer/README.md b/problems/find-the-index-of-the-large-integer/README.md index 57eb5c872..4206c138e 100644 --- a/problems/find-the-index-of-the-large-integer/README.md +++ b/problems/find-the-index-of-the-large-integer/README.md @@ -18,9 +18,6 @@ [[Binary Search](../../tag/binary-search/README.md)] [[Interactive](../../tag/interactive/README.md)] -### Similar Questions - 1. [Search in a Sorted Array of Unknown Size](../search-in-a-sorted-array-of-unknown-size) (Medium) - ### Hints
    Hint 1 diff --git a/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md index f115bd5f2..04ac15592 100644 --- a/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md +++ b/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit") @@ -11,9 +11,11 @@ ## [1439. Find the Kth Smallest Sum of a Matrix With Sorted Rows (Hard)](https://leetcode.com/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows "有序矩阵中的第 k 个最小数组和") -

    You are given an m * n matrix, mat, and an integer k, which has its rows sorted in non-decreasing order.

    +

    You are given an m x n matrix mat that has its rows sorted in non-decreasing order and an integer k.

    -

    You are allowed to choose exactly 1 element from each row to form an array. Return the Kth smallest array sum among all possible arrays.

    +

    You are allowed to choose exactly one element from each row to form an array.

    + +

    Return the kth smallest array sum among all possible arrays.

     

    Example 1:

    @@ -21,8 +23,9 @@
     Input: mat = [[1,3,11],[2,4,6]], k = 5
     Output: 7
    -Explanation: Choosing one element from each row, the first k smallest sum are:
    -[1,2], [1,4], [3,2], [3,4], [1,6]. Where the 5th sum is 7.  
    +Explanation: Choosing one element from each row, the first k smallest sum are: +[1,2], [1,4], [3,2], [3,4], [1,6]. Where the 5th sum is 7. +

    Example 2:

    @@ -40,13 +43,6 @@ [1,1,2], [1,1,3], [1,4,2], [1,4,3], [1,1,6], [1,5,2], [1,5,3]. Where the 7th sum is 9.
    -

    Example 4:

    - -
    -Input: mat = [[1,1,10],[2,2,9]], k = 7
    -Output: 12
    -
    -

     

    Constraints:

    @@ -54,16 +50,16 @@
  • m == mat.length
  • n == mat.length[i]
  • 1 <= m, n <= 40
  • -
  • 1 <= k <= min(200, n ^ m)
  • 1 <= mat[i][j] <= 5000
  • -
  • mat[i] is a non decreasing array.
  • +
  • 1 <= k <= min(200, nm)
  • +
  • mat[i] is a non-decreasing array.
  • ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Matrix](../../tag/matrix/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Matrix](../../tag/matrix/README.md)] ### Hints
    diff --git a/problems/find-the-middle-index-in-array/README.md b/problems/find-the-middle-index-in-array/README.md index c9372d3c6..5a9991797 100644 --- a/problems/find-the-middle-index-in-array/README.md +++ b/problems/find-the-middle-index-in-array/README.md @@ -25,8 +25,7 @@
     Input: nums = [2,3,-1,8,4]
     Output: 3
    -Explanation:
    -The sum of the numbers before index 3 is: 2 + 3 + -1 = 4
    +Explanation: The sum of the numbers before index 3 is: 2 + 3 + -1 = 4
     The sum of the numbers after index 3 is: 4 = 4
     
    @@ -35,8 +34,7 @@ The sum of the numbers after index 3 is: 4 = 4
     Input: nums = [1,-1,4]
     Output: 2
    -Explanation:
    -The sum of the numbers before index 2 is: 1 + -1 = 0
    +Explanation: The sum of the numbers before index 2 is: 1 + -1 = 0
     The sum of the numbers after index 2 is: 0
     
    @@ -45,18 +43,7 @@ The sum of the numbers after index 2 is: 0
     Input: nums = [2,5]
     Output: -1
    -Explanation:
    -There is no valid middleIndex.
    -
    - -

    Example 4:

    - -
    -Input: nums = [1]
    -Output: 0
    -Explantion:
    -The sum of the numbers before index 0 is: 0
    -The sum of the numbers after index 0 is: 0
    +Explanation: There is no valid middleIndex.
     

     

    diff --git a/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md b/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md index aa3940150..e614c8384 100644 --- a/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md +++ b/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/README.md @@ -56,14 +56,6 @@ Thus, minDistance and maxDistance is 5 - 2 = 3. Note that the last node is not considered a local maxima because it does not have a next node. -

    Example 4:

    - -
    -Input: head = [2,3,3,2]
    -Output: [-1,-1]
    -Explanation: There are no critical points in [2,3,3,2].
    -
    -

     

    Constraints:

    diff --git a/problems/find-the-missing-ids/README.md b/problems/find-the-missing-ids/README.md index 493874513..ad3d152ac 100644 --- a/problems/find-the-missing-ids/README.md +++ b/problems/find-the-missing-ids/README.md @@ -15,3 +15,8 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Report Contiguous Dates](../report-contiguous-dates) (Hard) + 1. [Find the Start and End Number of Continuous Ranges](../find-the-start-and-end-number-of-continuous-ranges) (Medium) + 1. [Number of Transactions per Visit](../number-of-transactions-per-visit) (Hard) diff --git a/problems/find-the-most-competitive-subsequence/README.md b/problems/find-the-most-competitive-subsequence/README.md index 918cfd3ad..6f21e4840 100644 --- a/problems/find-the-most-competitive-subsequence/README.md +++ b/problems/find-the-most-competitive-subsequence/README.md @@ -43,15 +43,11 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] -### Similar Questions - 1. [Remove K Digits](../remove-k-digits) (Medium) - 1. [Smallest Subsequence of Distinct Characters](../smallest-subsequence-of-distinct-characters) (Medium) - ### Hints
    Hint 1 diff --git a/problems/find-the-smallest-divisor-given-a-threshold/README.md b/problems/find-the-smallest-divisor-given-a-threshold/README.md index ff3a0bece..45f02e814 100644 --- a/problems/find-the-smallest-divisor-given-a-threshold/README.md +++ b/problems/find-the-smallest-divisor-given-a-threshold/README.md @@ -15,7 +15,7 @@

    Each result of the division is rounded to the nearest integer greater than or equal to that element. (For example: 7/3 = 3 and 10/2 = 5).

    -

    It is guaranteed that there will be an answer.

    +

    The test cases are generated so that there will be an answer.

     

    Example 1:

    @@ -34,20 +34,6 @@ If the divisor is 4 we can get a sum of 7 (1+1+2+3) and if the divisor is 5 the Output: 44 -

    Example 3:

    - -
    -Input: nums = [21212,10101,12121], threshold = 1000000
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: nums = [2,3,5,7,11], threshold = 11
    -Output: 3
    -
    -

     

    Constraints:

    diff --git a/problems/find-the-winner-of-an-array-game/README.md b/problems/find-the-winner-of-an-array-game/README.md index ab1c0c3a7..70bb38ceb 100644 --- a/problems/find-the-winner-of-an-array-game/README.md +++ b/problems/find-the-winner-of-an-array-game/README.md @@ -13,7 +13,7 @@

    Given an integer array arr of distinct integers and an integer k.

    -

    A game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of the game, we compare arr[0] with arr[1], the larger integer wins and remains at position 0 and the smaller integer moves to the end of the array. The game ends when an integer wins k consecutive rounds.

    +

    A game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of the game, we compare arr[0] with arr[1], the larger integer wins and remains at position 0, and the smaller integer moves to the end of the array. The game ends when an integer wins k consecutive rounds.

    Return the integer which will win the game.

    @@ -42,20 +42,6 @@ So we can see that 4 rounds will be played and 5 is the winner because it wins 2 Explanation: 3 will win the first 10 rounds consecutively. -

    Example 3:

    - -
    -Input: arr = [1,9,8,2,3,7,6,4,5], k = 7
    -Output: 9
    -
    - -

    Example 4:

    - -
    -Input: arr = [1,11,22,33,44,55,66,77,88,99], k = 1000000000
    -Output: 99
    -
    -

     

    Constraints:

    diff --git a/problems/find-the-winner-of-the-circular-game/README.md b/problems/find-the-winner-of-the-circular-game/README.md index 72592a8ab..f697c1c36 100644 --- a/problems/find-the-winner-of-the-circular-game/README.md +++ b/problems/find-the-winner-of-the-circular-game/README.md @@ -58,9 +58,10 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Recursion](../../tag/recursion/README.md)] + [[Queue](../../tag/queue/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md b/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md index 028421234..8f35b94cf 100644 --- a/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md +++ b/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../subrectangle-queries "Subrectangle Queries") @@ -11,7 +11,7 @@ ## [1477. Find Two Non-overlapping Sub-arrays Each With Target Sum (Medium)](https://leetcode.com/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum "找两个和为目标值且不重叠的子数组") -

    Given an array of integers arr and an integer target.

    +

    You are given an array of integers arr and an integer target.

    You have to find two non-overlapping sub-arrays of arr each with a sum equal target. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is minimum.

    @@ -42,22 +42,6 @@ Explanation: We have only one sub-array of sum = 6. -

    Example 4:

    - -
    -Input: arr = [5,5,4,4,5], target = 3
    -Output: -1
    -Explanation: We cannot find a sub-array of sum = 3.
    -
    - -

    Example 5:

    - -
    -Input: arr = [3,1,1,1,5,1,2,1], target = 3
    -Output: 3
    -Explanation: Note that sub-arrays [1,2] and [2,1] cannot be an answer because they overlap.
    -
    -

     

    Constraints:

    diff --git a/problems/find-valid-matrix-given-row-and-column-sums/README.md b/problems/find-valid-matrix-given-row-and-column-sums/README.md index 937b21680..1ca194f17 100644 --- a/problems/find-valid-matrix-given-row-and-column-sums/README.md +++ b/problems/find-valid-matrix-given-row-and-column-sums/README.md @@ -24,11 +24,11 @@ Input: rowSum = [3,8], colSum = [4,7] Output: [[3,0], [1,7]] -Explanation: -0th row: 3 + 0 = 3 == rowSum[0] -1st row: 1 + 7 = 8 == rowSum[1] -0th column: 3 + 1 = 4 == colSum[0] -1st column: 0 + 7 = 7 == colSum[1] +Explanation: +0th row: 3 + 0 = 3 == rowSum[0] +1st row: 1 + 7 = 8 == rowSum[1] +0th column: 3 + 1 = 4 == colSum[0] +1st column: 0 + 7 = 7 == colSum[1] The row and column sums match, and all matrix elements are non-negative. Another possible matrix is: [[1,2], [3,5]] @@ -43,29 +43,6 @@ Another possible matrix is: [[1,2], [2,0,8]] -

    Example 3:

    - -
    -Input: rowSum = [14,9], colSum = [6,9,8]
    -Output: [[0,9,5],
    -         [6,0,3]]
    -
    - -

    Example 4:

    - -
    -Input: rowSum = [1,0], colSum = [1]
    -Output: [[1],
    -         [0]]
    -
    - -

    Example 5:

    - -
    -Input: rowSum = [0], colSum = [0]
    -Output: [[0]]
    -
    -

     

    Constraints:

    diff --git a/problems/find-winner-on-a-tic-tac-toe-game/README.md b/problems/find-winner-on-a-tic-tac-toe-game/README.md index a9fb045d4..b92f461f3 100644 --- a/problems/find-winner-on-a-tic-tac-toe-game/README.md +++ b/problems/find-winner-on-a-tic-tac-toe-game/README.md @@ -51,14 +51,6 @@ Explanation: The game ends in a draw since there are no moves to make. -

    Example 4:

    - -
    -Input: moves = [[0,0],[1,1]]
    -Output: "Pending"
    -Explanation: The game has not finished yet.
    -
    -

     

    Constraints:

    diff --git a/problems/finding-3-digit-even-numbers/README.md b/problems/finding-3-digit-even-numbers/README.md new file mode 100644 index 000000000..b3b7cc928 --- /dev/null +++ b/problems/finding-3-digit-even-numbers/README.md @@ -0,0 +1,73 @@ + + + + + + + +[< Previous](../minimum-cost-to-reach-city-with-discounts "Minimum Cost to Reach City With Discounts") +                 +[Next >](../delete-the-middle-node-of-a-linked-list "Delete the Middle Node of a Linked List") + +## [2094. Finding 3-Digit Even Numbers (Easy)](https://leetcode.com/problems/finding-3-digit-even-numbers "找出 3 位偶数") + +

    You are given an integer array digits, where each element is a digit. The array may contain duplicates.

    + +

    You need to find all the unique integers that follow the given requirements:

    + +
      +
    • The integer consists of the concatenation of three elements from digits in any arbitrary order.
    • +
    • The integer does not have leading zeros.
    • +
    • The integer is even.
    • +
    + +

    For example, if the given digits were [1, 2, 3], integers 132 and 312 follow the requirements.

    + +

    Return a sorted array of the unique integers.

    + +

     

    +

    Example 1:

    + +
    +Input: digits = [2,1,3,0]
    +Output: [102,120,130,132,210,230,302,310,312,320]
    +Explanation: All the possible integers that follow the requirements are in the output array. 
    +Notice that there are no odd integers or integers with leading zeros.
    +
    + +

    Example 2:

    + +
    +Input: digits = [2,2,8,8,2]
    +Output: [222,228,282,288,822,828,882]
    +Explanation: The same digit can be used as many times as it appears in digits. 
    +In this example, the digit 8 is used twice each time in 288, 828, and 882. 
    +
    + +

    Example 3:

    + +
    +Input: digits = [3,7,5]
    +Output: []
    +Explanation: No even integers can be formed using the given digits.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 3 <= digits.length <= 100
    • +
    • 0 <= digits[i] <= 9
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +The range of possible answers includes all even numbers between 100 and 999 inclusive. Could you check each possible answer to see if it could be formed from the digits in the array? +
    diff --git a/problems/finding-mk-average/README.md b/problems/finding-mk-average/README.md index 17b35c582..8986cc95c 100644 --- a/problems/finding-mk-average/README.md +++ b/problems/finding-mk-average/README.md @@ -69,8 +69,13 @@ obj.calculateMKAverage(); // The last 3 elements are [5,5,5]. ### Related Topics [[Design](../../tag/design/README.md)] [[Queue](../../tag/queue/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + +### Similar Questions + 1. [Find Median from Data Stream](../find-median-from-data-stream) (Hard) + 1. [Kth Largest Element in a Stream](../kth-largest-element-in-a-stream) (Easy) + 1. [Sequentially Ordinal Rank Tracker](../sequentially-ordinal-rank-tracker) (Hard) ### Hints
    diff --git a/problems/finding-pairs-with-a-certain-sum/README.md b/problems/finding-pairs-with-a-certain-sum/README.md index db4adce8e..618963a92 100644 --- a/problems/finding-pairs-with-a-certain-sum/README.md +++ b/problems/finding-pairs-with-a-certain-sum/README.md @@ -62,9 +62,12 @@ findSumPairs.count(7); // return 11; pairs (2,1), (2,2), (2,4), (3,1), (3,2), ( ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Design](../../tag/design/README.md)] + +### Similar Questions + 1. [Count Number of Pairs With Absolute Difference K](../count-number-of-pairs-with-absolute-difference-k) (Easy) ### Hints
    diff --git a/problems/first-and-last-call-on-the-same-day/README.md b/problems/first-and-last-call-on-the-same-day/README.md index b8f2de048..c8755953e 100644 --- a/problems/first-and-last-call-on-the-same-day/README.md +++ b/problems/first-and-last-call-on-the-same-day/README.md @@ -9,7 +9,7 @@                  [Next >](../count-nodes-equal-to-sum-of-descendants "Count Nodes Equal to Sum of Descendants") -## [1972. First and Last Call On the Same Day (Hard)](https://leetcode.com/problems/first-and-last-call-on-the-same-day "") +## [1972. First and Last Call On the Same Day (Hard)](https://leetcode.com/problems/first-and-last-call-on-the-same-day "同一天的第一个电话和最后一个电话") diff --git a/problems/first-unique-character-in-a-string/README.md b/problems/first-unique-character-in-a-string/README.md index 00f41ca4d..6935d8b35 100644 --- a/problems/first-unique-character-in-a-string/README.md +++ b/problems/first-unique-character-in-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lexicographical-numbers "Lexicographical Numbers") diff --git a/problems/fizz-buzz-multithreaded/README.md b/problems/fizz-buzz-multithreaded/README.md index 998449392..64187532e 100644 --- a/problems/fizz-buzz-multithreaded/README.md +++ b/problems/fizz-buzz-multithreaded/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tournament-winners "Tournament Winners") diff --git a/problems/flatten-binary-tree-to-linked-list/README.md b/problems/flatten-binary-tree-to-linked-list/README.md index 2fed5e2d1..3ec60780b 100644 --- a/problems/flatten-binary-tree-to-linked-list/README.md +++ b/problems/flatten-binary-tree-to-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-sum-ii "Path Sum II") diff --git a/problems/flip-game-ii/README.md b/problems/flip-game-ii/README.md index 1723aa64a..6814174ea 100644 --- a/problems/flip-game-ii/README.md +++ b/problems/flip-game-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../flip-game "Flip Game") diff --git a/problems/flip-string-to-monotone-increasing/README.md b/problems/flip-string-to-monotone-increasing/README.md index 64b7a1358..1a4c257d1 100644 --- a/problems/flip-string-to-monotone-increasing/README.md +++ b/problems/flip-string-to-monotone-increasing/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../long-pressed-name "Long Pressed Name") diff --git a/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md b/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md index c79ccb267..939b93d2f 100644 --- a/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md +++ b/problems/form-largest-integer-with-digits-that-add-up-to-target/README.md @@ -11,17 +11,15 @@ ## [1449. Form Largest Integer With Digits That Add up to Target (Hard)](https://leetcode.com/problems/form-largest-integer-with-digits-that-add-up-to-target "数位成本和为目标值的最大数字") -

    Given an array of integers cost and an integer target. Return the maximum integer you can paint under the following rules:

    +

    Given an array of integers cost and an integer target, return the maximum integer you can paint under the following rules:

      -
    • The cost of painting a digit (i+1) is given by cost[i] (0 indexed).
    • -
    • The total cost used must be equal to target.
    • -
    • Integer does not have digits 0.
    • +
    • The cost of painting a digit (i + 1) is given by cost[i] (0-indexed).
    • +
    • The total cost used must be equal to target.
    • +
    • The integer does not have 0 digits.
    -

    Since the answer may be too large, return it as string.

    - -

    If there is no way to paint any integer given the condition, return "0".

    +

    Since the answer may be very large, return it as a string. If there is no way to paint any integer given the condition, return "0".

     

    Example 1:

    @@ -29,7 +27,7 @@
     Input: cost = [4,3,2,5,6,7,2,5,5], target = 9
     Output: "7772"
    -Explanation:  The cost to paint the digit '7' is 2, and the digit '2' is 3. Then cost("7772") = 2*3+ 3*1 = 9. You could also paint "977", but "7772" is the largest number.
    +Explanation: The cost to paint the digit '7' is 2, and the digit '2' is 3. Then cost("7772") = 2*3+ 3*1 = 9. You could also paint "977", but "7772" is the largest number.
     Digit    cost
       1  ->   4
       2  ->   3
    @@ -55,14 +53,7 @@
     
     Input: cost = [2,4,6,2,4,6,4,4,4], target = 5
     Output: "0"
    -Explanation: It's not possible to paint any integer with total cost equal to target.
    -
    - -

    Example 4:

    - -
    -Input: cost = [6,10,15,40,40,40,40,40,40], target = 47
    -Output: "32211"
    +Explanation: It is impossible to paint any integer with total cost equal to target.
     

     

    @@ -70,8 +61,7 @@
    • cost.length == 9
    • -
    • 1 <= cost[i] <= 5000
    • -
    • 1 <= target <= 5000
    • +
    • 1 <= cost[i], target <= 5000
    ### Related Topics diff --git a/problems/four-divisors/README.md b/problems/four-divisors/README.md index c23fcc57b..0bdc98273 100644 --- a/problems/four-divisors/README.md +++ b/problems/four-divisors/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../create-target-array-in-the-given-order "Create Target Array in the Given Order") diff --git a/problems/frog-position-after-t-seconds/README.md b/problems/frog-position-after-t-seconds/README.md index a47663936..1e6ecd7bf 100644 --- a/problems/frog-position-after-t-seconds/README.md +++ b/problems/frog-position-after-t-seconds/README.md @@ -15,22 +15,19 @@

    The edges of the undirected tree are given in the array edges, where edges[i] = [ai, bi] means that exists an edge connecting the vertices ai and bi.

    -

    Return the probability that after t seconds the frog is on the vertex target.

    +

    Return the probability that after t seconds the frog is on the vertex target. Answers within 10-5 of the actual answer will be accepted.

     

    Example 1:

    - -

    - +
     Input: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 2, target = 4
     Output: 0.16666666666666666 
    -Explanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 probability to the vertex 2 after second 1 and then jumping with 1/2 probability to vertex 4 after second 2. Thus the probability for the frog is on the vertex 4 after 2 seconds is 1/3 * 1/2 = 1/6 = 0.16666666666666666. 
    +Explanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 probability to the vertex 2 after second 1 and then jumping with 1/2 probability to vertex 4 after second 2. Thus the probability for the frog is on the vertex 4 after 2 seconds is 1/3 * 1/2 = 1/6 = 0.16666666666666666. 
     

    Example 2:

    - -

    +
     Input: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 1, target = 7
    @@ -38,13 +35,6 @@
     Explanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 = 0.3333333333333333 probability to the vertex 7 after second 1. 
     
    -

    Example 3:

    - -
    -Input: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 20, target = 6
    -Output: 0.16666666666666666
    -
    -

     

    Constraints:

    @@ -53,9 +43,8 @@
  • edges.length == n - 1
  • edges[i].length == 2
  • 1 <= ai, bi <= n
  • -
  • 1 <= t <= 50
  • -
  • 1 <= target <= n
  • -
  • Answers within 10-5 of the actual value will be accepted as correct.
  • +
  • 1 <= t <= 50
  • +
  • 1 <= target <= n
  • ### Related Topics diff --git a/problems/fruit-into-baskets/README.md b/problems/fruit-into-baskets/README.md index 5ddc874cb..e4961b828 100644 --- a/problems/fruit-into-baskets/README.md +++ b/problems/fruit-into-baskets/README.md @@ -50,14 +50,6 @@ If we had started at the first tree, we would only pick from trees [0,1]. If we had started at the first tree, we would only pick from trees [1,2].
    -

    Example 4:

    - -
    -Input: fruits = [3,3,3,1,2,1,1,2,3,3,4]
    -Output: 5
    -Explanation: We can pick from trees [1,2,1,1,2].
    -
    -

     

    Constraints:

    diff --git a/problems/game-play-analysis-i/README.md b/problems/game-play-analysis-i/README.md index eaa4b32f3..5fccd1c99 100644 --- a/problems/game-play-analysis-i/README.md +++ b/problems/game-play-analysis-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../inorder-successor-in-bst-ii "Inorder Successor in BST II") diff --git a/problems/get-the-maximum-score/README.md b/problems/get-the-maximum-score/README.md index 86d638303..26e258cc6 100644 --- a/problems/get-the-maximum-score/README.md +++ b/problems/get-the-maximum-score/README.md @@ -27,13 +27,11 @@

     

    Example 1:

    - -

    - +
     Input: nums1 = [2,4,5,8,10], nums2 = [4,6,8,9]
     Output: 30
    -Explanation: Valid paths:
    +Explanation: Valid paths:
     [2,4,5,8,10], [2,4,5,8,9], [2,4,6,8,9], [2,4,6,8,10],  (starting from nums1)
     [4,6,8,9], [4,5,8,10], [4,5,8,9], [4,6,8,10]    (starting from nums2)
     The maximum is obtained with the path in green [2,4,6,8,10].
    @@ -44,7 +42,7 @@ The maximum is obtained with the path in green [2,4,6,8,10].
     
     Input: nums1 = [1,3,5,7,9], nums2 = [3,5,100]
     Output: 109
    -Explanation: Maximum sum is obtained with the path [1,3,5,100].
    +Explanation: Maximum sum is obtained with the path [1,3,5,100].
     

    Example 3:

    @@ -52,17 +50,10 @@ The maximum is obtained with the path in green [2,4,6,8,10].
     Input: nums1 = [1,2,3,4,5], nums2 = [6,7,8,9,10]
     Output: 40
    -Explanation: There are no common elements between nums1 and nums2.
    +Explanation: There are no common elements between nums1 and nums2.
     Maximum sum is obtained with the path [6,7,8,9,10].
     
    -

    Example 4:

    - -
    -Input: nums1 = [1,4,5,8,9,11,19], nums2 = [2,3,4,11,12]
    -Output: 61
    -
    -

     

    Constraints:

    @@ -73,10 +64,10 @@ Maximum sum is obtained with the path [6,7,8,9,10]. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/get-the-second-most-recent-activity/README.md b/problems/get-the-second-most-recent-activity/README.md index 11682b2cc..60c83d6b0 100644 --- a/problems/get-the-second-most-recent-activity/README.md +++ b/problems/get-the-second-most-recent-activity/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-make-at-least-one-valid-path-in-a-grid "Minimum Cost to Make at Least One Valid Path in a Grid") diff --git a/problems/group-employees-of-the-same-salary/README.md b/problems/group-employees-of-the-same-salary/README.md index f221375de..0b2f7fc0a 100644 --- a/problems/group-employees-of-the-same-salary/README.md +++ b/problems/group-employees-of-the-same-salary/README.md @@ -9,7 +9,7 @@                  [Next >](../substrings-of-size-three-with-distinct-characters "Substrings of Size Three with Distinct Characters") -## [1875. Group Employees of the Same Salary (Medium)](https://leetcode.com/problems/group-employees-of-the-same-salary "") +## [1875. Group Employees of the Same Salary (Medium)](https://leetcode.com/problems/group-employees-of-the-same-salary "将工资相同的雇员分组") diff --git a/problems/group-sold-products-by-the-date/README.md b/problems/group-sold-products-by-the-date/README.md index f107e9cdc..6722eb2d8 100644 --- a/problems/group-sold-products-by-the-date/README.md +++ b/problems/group-sold-products-by-the-date/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../kth-ancestor-of-a-tree-node "Kth Ancestor of a Tree Node") diff --git a/problems/groups-of-strings/README.md b/problems/groups-of-strings/README.md new file mode 100644 index 000000000..0cc7e7afb --- /dev/null +++ b/problems/groups-of-strings/README.md @@ -0,0 +1,96 @@ + + + + + + + +[< Previous](../find-substring-with-given-hash-value "Find Substring With Given Hash Value") +                 +[Next >](../amount-of-new-area-painted-each-day "Amount of New Area Painted Each Day") + +## [2157. Groups of Strings (Hard)](https://leetcode.com/problems/groups-of-strings "字符串分组") + +

    You are given a 0-indexed array of strings words. Each string consists of lowercase English letters only. No letter occurs more than once in any string of words.

    + +

    Two strings s1 and s2 are said to be connected if the set of letters of s2 can be obtained from the set of letters of s1 by any one of the following operations:

    + +
      +
    • Adding exactly one letter to the set of the letters of s1.
    • +
    • Deleting exactly one letter from the set of the letters of s1.
    • +
    • Replacing exactly one letter from the set of the letters of s1 with any letter, including itself.
    • +
    + +

    The array words can be divided into one or more non-intersecting groups. A string belongs to a group if any one of the following is true:

    + +
      +
    • It is connected to at least one other string of the group.
    • +
    • It is the only string present in the group.
    • +
    + +

    Note that the strings in words should be grouped in such a manner that a string belonging to a group cannot be connected to a string present in any other group. It can be proved that such an arrangement is always unique.

    + +

    Return an array ans of size 2 where:

    + +
      +
    • ans[0] is the maximum number of groups words can be divided into, and
    • +
    • ans[1] is the size of the largest group.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: words = ["a","b","ab","cde"]
    +Output: [2,3]
    +Explanation:
    +- words[0] can be used to obtain words[1] (by replacing 'a' with 'b'), and words[2] (by adding 'b'). So words[0] is connected to words[1] and words[2].
    +- words[1] can be used to obtain words[0] (by replacing 'b' with 'a'), and words[2] (by adding 'a'). So words[1] is connected to words[0] and words[2].
    +- words[2] can be used to obtain words[0] (by deleting 'b'), and words[1] (by deleting 'a'). So words[2] is connected to words[0] and words[1].
    +- words[3] is not connected to any string in words.
    +Thus, words can be divided into 2 groups ["a","b","ab"] and ["cde"]. The size of the largest group is 3.  
    +
    + +

    Example 2:

    + +
    +Input: words = ["a","ab","abc"]
    +Output: [1,3]
    +Explanation:
    +- words[0] is connected to words[1].
    +- words[1] is connected to words[0] and words[2].
    +- words[2] is connected to words[1].
    +Since all strings are connected to each other, they should be grouped together.
    +Thus, the size of the largest group is 3.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 2 * 104
    • +
    • 1 <= words[i].length <= 26
    • +
    • words[i] consists of lowercase English letters only.
    • +
    • No letter occurs more than once in words[i].
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Can we build a graph from words, where there exists an edge between nodes i and j if words[i] and words[j] are connected? +
    + +
    +Hint 2 +The problem now boils down to finding the total number of components and the size of the largest component in the graph. +
    + +
    +Hint 3 +How can we use bit masking to reduce the search space while adding edges to node i? +
    diff --git a/problems/guess-number-higher-or-lower/README.md b/problems/guess-number-higher-or-lower/README.md index c09647967..52aa4fcb3 100644 --- a/problems/guess-number-higher-or-lower/README.md +++ b/problems/guess-number-higher-or-lower/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-k-pairs-with-smallest-sums "Find K Pairs with Smallest Sums") @@ -17,30 +17,38 @@

    Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess.

    -

    You call a pre-defined API int guess(int num), which returns 3 possible results:

    +

    You call a pre-defined API int guess(int num), which returns three possible results:

      -
    • -1: The number I picked is lower than your guess (i.e. pick < num).
    • -
    • 1: The number I picked is higher than your guess (i.e. pick > num).
    • -
    • 0: The number I picked is equal to your guess (i.e. pick == num).
    • +
    • -1: Your guess is higher than the number I picked (i.e. num > pick).
    • +
    • 1: Your guess is lower than the number I picked (i.e. num < pick).
    • +
    • 0: your guess is equal to the number I picked (i.e. num == pick).

    Return the number that I picked.

     

    Example 1:

    -
    Input: n = 10, pick = 6
    +
    +
    +Input: n = 10, pick = 6
     Output: 6
    -

    Example 2:

    -
    Input: n = 1, pick = 1
    +
    + +

    Example 2:

    + +
    +Input: n = 1, pick = 1
     Output: 1
    -

    Example 3:

    -
    Input: n = 2, pick = 1
    +
    + +

    Example 3:

    + +
    +Input: n = 2, pick = 1
     Output: 1
    -

    Example 4:

    -
    Input: n = 2, pick = 2
    -Output: 2
     
    +

     

    Constraints:

    diff --git a/problems/guess-the-word/README.md b/problems/guess-the-word/README.md index 488ba5ca4..97fb5c1ad 100644 --- a/problems/guess-the-word/README.md +++ b/problems/guess-the-word/README.md @@ -59,5 +59,5 @@ We made 5 calls to master.guess and one of them was the secret, so we pass the t [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] - [[Interactive](../../tag/interactive/README.md)] [[Game Theory](../../tag/game-theory/README.md)] + [[Interactive](../../tag/interactive/README.md)] diff --git a/problems/hexspeak/README.md b/problems/hexspeak/README.md index 9813d663b..a1b971d22 100644 --- a/problems/hexspeak/README.md +++ b/problems/hexspeak/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-people-report-to-the-given-manager "All People Report to the Given Manager") diff --git a/problems/hopper-company-queries-i/README.md b/problems/hopper-company-queries-i/README.md index da53acdea..c436e61f3 100644 --- a/problems/hopper-company-queries-i/README.md +++ b/problems/hopper-company-queries-i/README.md @@ -15,8 +15,3 @@ ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Trips and Users](../trips-and-users) (Hard) - 1. [Hopper Company Queries II](../hopper-company-queries-ii) (Hard) - 1. [Hopper Company Queries III](../hopper-company-queries-iii) (Hard) diff --git a/problems/hopper-company-queries-iii/README.md b/problems/hopper-company-queries-iii/README.md index 62a14af70..5424cf7fb 100644 --- a/problems/hopper-company-queries-iii/README.md +++ b/problems/hopper-company-queries-iii/README.md @@ -15,8 +15,3 @@ ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Trips and Users](../trips-and-users) (Hard) - 1. [Hopper Company Queries I](../hopper-company-queries-i) (Hard) - 1. [Hopper Company Queries II](../hopper-company-queries-ii) (Hard) diff --git a/problems/house-robber-iii/README.md b/problems/house-robber-iii/README.md index 4f3e1613f..350409147 100644 --- a/problems/house-robber-iii/README.md +++ b/problems/house-robber-iii/README.md @@ -43,9 +43,9 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/house-robber/README.md b/problems/house-robber/README.md index 572ab037c..a37cd0a07 100644 --- a/problems/house-robber/README.md +++ b/problems/house-robber/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rising-temperature "Rising Temperature") diff --git a/problems/how-many-numbers-are-smaller-than-the-current-number/README.md b/problems/how-many-numbers-are-smaller-than-the-current-number/README.md index 1418fd842..2b291471d 100644 --- a/problems/how-many-numbers-are-smaller-than-the-current-number/README.md +++ b/problems/how-many-numbers-are-smaller-than-the-current-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-trusted-contacts-of-a-customer "Number of Trusted Contacts of a Customer") diff --git a/problems/html-entity-parser/README.md b/problems/html-entity-parser/README.md index 87d42149e..5201de90f 100644 --- a/problems/html-entity-parser/README.md +++ b/problems/html-entity-parser/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../queries-on-a-permutation-with-key "Queries on a Permutation With Key") @@ -16,17 +16,17 @@

    The special characters and their entities for HTML are:

      -
    • Quotation Mark: the entity is &quot; and symbol character is ".
    • -
    • Single Quote Mark: the entity is &apos; and symbol character is '.
    • -
    • Ampersand: the entity is &amp; and symbol character is &.
    • -
    • Greater Than Sign: the entity is &gt; and symbol character is >.
    • -
    • Less Than Sign: the entity is &lt; and symbol character is <.
    • -
    • Slash: the entity is &frasl; and symbol character is /.
    • +
    • Quotation Mark: the entity is &quot; and symbol character is ".
    • +
    • Single Quote Mark: the entity is &apos; and symbol character is '.
    • +
    • Ampersand: the entity is &amp; and symbol character is &.
    • +
    • Greater Than Sign: the entity is &gt; and symbol character is >.
    • +
    • Less Than Sign: the entity is &lt; and symbol character is <.
    • +
    • Slash: the entity is &frasl; and symbol character is /.

    Given the input text string to the HTML parser, you have to implement the entity parser.

    -

    Return the text after replacing the entities by the special characters.

    +

    Return the text after replacing the entities by the special characters.

     

    Example 1:

    @@ -44,33 +44,12 @@ Output: "and I quote: \"...\""
    -

    Example 3:

    - -
    -Input: text = "Stay home! Practice on Leetcode :)"
    -Output: "Stay home! Practice on Leetcode :)"
    -
    - -

    Example 4:

    - -
    -Input: text = "x &gt; y &amp;&amp; x &lt; y is always false"
    -Output: "x > y && x < y is always false"
    -
    - -

    Example 5:

    - -
    -Input: text = "leetcode.com&frasl;problemset&frasl;all"
    -Output: "leetcode.com/problemset/all"
    -
    -

     

    Constraints:

      -
    • 1 <= text.length <= 10^5
    • -
    • The string may contain any possible characters out of all the 256 ASCII characters.
    • +
    • 1 <= text.length <= 105
    • +
    • The string may contain any possible characters out of all the 256 ASCII characters.
    ### Related Topics diff --git a/problems/image-overlap/README.md b/problems/image-overlap/README.md index 692a184da..808a96906 100644 --- a/problems/image-overlap/README.md +++ b/problems/image-overlap/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-distances-in-tree "Sum of Distances in Tree") diff --git a/problems/immediate-food-delivery-i/README.md b/problems/immediate-food-delivery-i/README.md index 857bf4d63..446d674e7 100644 --- a/problems/immediate-food-delivery-i/README.md +++ b/problems/immediate-food-delivery-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../dinner-plate-stacks "Dinner Plate Stacks") diff --git a/problems/immediate-food-delivery-ii/README.md b/problems/immediate-food-delivery-ii/README.md index 65fcea5cf..69aa37ffd 100644 --- a/problems/immediate-food-delivery-ii/README.md +++ b/problems/immediate-food-delivery-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../immediate-food-delivery-i "Immediate Food Delivery I") diff --git a/problems/implement-rand10-using-rand7/README.md b/problems/implement-rand10-using-rand7/README.md index 5ae0a32f1..9a1d23cdc 100644 --- a/problems/implement-rand10-using-rand7/README.md +++ b/problems/implement-rand10-using-rand7/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../convex-polygon "Convex Polygon") diff --git a/problems/implement-strstr/README.md b/problems/implement-strstr/README.md index eaaae77cc..a744c0b83 100644 --- a/problems/implement-strstr/README.md +++ b/problems/implement-strstr/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-element "Remove Element") diff --git a/problems/increasing-decreasing-string/README.md b/problems/increasing-decreasing-string/README.md index a64f532bd..8a62e65a2 100644 --- a/problems/increasing-decreasing-string/README.md +++ b/problems/increasing-decreasing-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../get-the-second-most-recent-activity "Get the Second Most Recent Activity") @@ -11,21 +11,21 @@ ## [1370. Increasing Decreasing String (Easy)](https://leetcode.com/problems/increasing-decreasing-string "上升下降字符串") -

    Given a string s. You should re-order the string using the following algorithm:

    +

    You are given a string s. Reorder the string using the following algorithm:

    1. Pick the smallest character from s and append it to the result.
    2. Pick the smallest character from s which is greater than the last appended character to the result and append it.
    3. Repeat step 2 until you cannot pick more characters.
    4. -
    5. Pick the largest character from s and append it to the result.
    6. -
    7. Pick the largest character from s which is smaller than the last appended character to the result and append it.
    8. +
    9. Pick the largest character from s and append it to the result.
    10. +
    11. Pick the largest character from s which is smaller than the last appended character to the result and append it.
    12. Repeat step 5 until you cannot pick more characters.
    13. Repeat the steps from 1 to 6 until you pick all characters from s.

    In each step, If the smallest or the largest character appears more than once you can choose any occurrence and append it to the result.

    -

    Return the result string after sorting s with this algorithm.

    +

    Return the result string after sorting s with this algorithm.

     

    Example 1:

    @@ -48,33 +48,12 @@ After steps 4, 5 and 6 of the second iteration, result = "abccbaabccba" Explanation: The word "rat" becomes "art" after re-ordering it with the mentioned algorithm.
    -

    Example 3:

    - -
    -Input: s = "leetcode"
    -Output: "cdelotee"
    -
    - -

    Example 4:

    - -
    -Input: s = "ggggggg"
    -Output: "ggggggg"
    -
    - -

    Example 5:

    - -
    -Input: s = "spo"
    -Output: "ops"
    -
    -

     

    Constraints:

    • 1 <= s.length <= 500
    • -
    • s contains only lower-case English letters.
    • +
    • s consists of only lowercase English letters.
    ### Related Topics diff --git a/problems/integer-replacement/README.md b/problems/integer-replacement/README.md index ca7535ef4..6e163430d 100644 --- a/problems/integer-replacement/README.md +++ b/problems/integer-replacement/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rotate-function "Rotate Function") diff --git a/problems/integer-to-english-words/README.md b/problems/integer-to-english-words/README.md index a79d587c3..4bc0037c2 100644 --- a/problems/integer-to-english-words/README.md +++ b/problems/integer-to-english-words/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../closest-binary-search-tree-value-ii "Closest Binary Search Tree Value II") @@ -15,18 +15,26 @@

     

    Example 1:

    -
    Input: num = 123
    -Output: "One Hundred Twenty Three"
    -

    Example 2:

    -
    Input: num = 12345
    -Output: "Twelve Thousand Three Hundred Forty Five"
    -

    Example 3:

    -
    Input: num = 1234567
    -Output: "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven"
    -

    Example 4:

    -
    Input: num = 1234567891
    -Output: "One Billion Two Hundred Thirty Four Million Five Hundred Sixty Seven Thousand Eight Hundred Ninety One"
    +
    +
    +Input: num = 123
    +Output: "One Hundred Twenty Three"
    +
    + +

    Example 2:

    + +
    +Input: num = 12345
    +Output: "Twelve Thousand Three Hundred Forty Five"
     
    + +

    Example 3:

    + +
    +Input: num = 1234567
    +Output: "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven"
    +
    +

     

    Constraints:

    diff --git a/problems/intervals-between-identical-elements/README.md b/problems/intervals-between-identical-elements/README.md new file mode 100644 index 000000000..8b689aeac --- /dev/null +++ b/problems/intervals-between-identical-elements/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../execution-of-all-suffix-instructions-staying-in-a-grid "Execution of All Suffix Instructions Staying in a Grid") +                 +[Next >](../recover-the-original-array "Recover the Original Array") + +## [2121. Intervals Between Identical Elements (Medium)](https://leetcode.com/problems/intervals-between-identical-elements "相同元素的间隔之和") + +

    You are given a 0-indexed array of n integers arr.

    + +

    The interval between two elements in arr is defined as the absolute difference between their indices. More formally, the interval between arr[i] and arr[j] is |i - j|.

    + +

    Return an array intervals of length n where intervals[i] is the sum of intervals between arr[i] and each element in arr with the same value as arr[i].

    + +

    Note: |x| is the absolute value of x.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [2,1,3,1,2,3,3]
    +Output: [4,2,7,2,4,4,5]
    +Explanation:
    +- Index 0: Another 2 is found at index 4. |0 - 4| = 4
    +- Index 1: Another 1 is found at index 3. |1 - 3| = 2
    +- Index 2: Two more 3s are found at indices 5 and 6. |2 - 5| + |2 - 6| = 7
    +- Index 3: Another 1 is found at index 1. |3 - 1| = 2
    +- Index 4: Another 2 is found at index 0. |4 - 0| = 4
    +- Index 5: Two more 3s are found at indices 2 and 6. |5 - 2| + |5 - 6| = 4
    +- Index 6: Two more 3s are found at indices 2 and 5. |6 - 2| + |6 - 5| = 5
    +
    + +

    Example 2:

    + +
    +Input: arr = [10,5,10,10]
    +Output: [5,0,3,4]
    +Explanation:
    +- Index 0: Two more 10s are found at indices 2 and 3. |0 - 2| + |0 - 3| = 5
    +- Index 1: There is only one 5 in the array, so its sum of intervals to identical elements is 0.
    +- Index 2: Two more 10s are found at indices 0 and 3. |2 - 0| + |2 - 3| = 3
    +- Index 3: Two more 10s are found at indices 0 and 2. |3 - 0| + |3 - 2| = 4
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == arr.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= arr[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +For each unique value found in the array, store a sorted list of indices of elements that have this value in the array. +
    + +
    +Hint 2 +One way of doing this is to use a HashMap that maps the values to their list of indices. Update this mapping as you iterate through the array. +
    + +
    +Hint 3 +Process each list of indices separately and get the sum of intervals for the elements of that value by utilizing prefix sums. +
    + +
    +Hint 4 +For each element, keep track of the sum of indices of the identical elements that have come before and that will come after respectively. Use this to calculate the sum of intervals for that element to the rest of the elements with identical values. +
    diff --git a/problems/is-graph-bipartite/README.md b/problems/is-graph-bipartite/README.md index dd7928a28..fa8efd94f 100644 --- a/problems/is-graph-bipartite/README.md +++ b/problems/is-graph-bipartite/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../letter-case-permutation "Letter Case Permutation") diff --git a/problems/jump-game-iii/README.md b/problems/jump-game-iii/README.md index a8063e365..876cb75b2 100644 --- a/problems/jump-game-iii/README.md +++ b/problems/jump-game-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-elements-in-two-binary-search-trees "All Elements in Two Binary Search Trees") diff --git a/problems/jump-game-v/README.md b/problems/jump-game-v/README.md index ed8f8ea0c..5c5e3730c 100644 --- a/problems/jump-game-v/README.md +++ b/problems/jump-game-v/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-product-of-splitted-binary-tree "Maximum Product of Splitted Binary Tree") @@ -51,26 +51,12 @@ Similarly You cannot jump from index 3 to index 2 or index 1. Explanation: Start at index 0. You can visit all the indicies.
    -

    Example 4:

    - -
    -Input: arr = [7,1,7,1,7,1], d = 2
    -Output: 2
    -
    - -

    Example 5:

    - -
    -Input: arr = [66], d = 1
    -Output: 1
    -
    -

     

    Constraints:

    • 1 <= arr.length <= 1000
    • -
    • 1 <= arr[i] <= 10^5
    • +
    • 1 <= arr[i] <= 105
    • 1 <= d <= arr.length
    @@ -79,9 +65,6 @@ Similarly You cannot jump from index 3 to index 2 or index 1. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Jump Game VII](../jump-game-vii) (Medium) - ### Hints
    Hint 1 diff --git a/problems/jump-game-vi/README.md b/problems/jump-game-vi/README.md index e18bac1d8..80cd600af 100644 --- a/problems/jump-game-vi/README.md +++ b/problems/jump-game-vi/README.md @@ -52,16 +52,12 @@ ### Related Topics + [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Queue](../../tag/queue/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] [[Monotonic Queue](../../tag/monotonic-queue/README.md)] - -### Similar Questions - 1. [Sliding Window Maximum](../sliding-window-maximum) (Hard) - 1. [Jump Game VII](../jump-game-vii) (Medium) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/k-highest-ranked-items-within-a-price-range/README.md b/problems/k-highest-ranked-items-within-a-price-range/README.md new file mode 100644 index 000000000..85a214e2c --- /dev/null +++ b/problems/k-highest-ranked-items-within-a-price-range/README.md @@ -0,0 +1,121 @@ + + + + + + + +[< Previous](../count-the-hidden-sequences "Count the Hidden Sequences") +                 +[Next >](../number-of-ways-to-divide-a-long-corridor "Number of Ways to Divide a Long Corridor") + +## [2146. K Highest Ranked Items Within a Price Range (Medium)](https://leetcode.com/problems/k-highest-ranked-items-within-a-price-range "价格范围内最高排名的 K 样物品") + +

    You are given a 0-indexed 2D integer array grid of size m x n that represents a map of the items in a shop. The integers in the grid represent the following:

    + +
      +
    • 0 represents a wall that you cannot pass through.
    • +
    • 1 represents an empty cell that you can freely move to and from.
    • +
    • All other positive integers represent the price of an item in that cell. You may also freely move to and from these item cells.
    • +
    + +

    It takes 1 step to travel between adjacent grid cells.

    + +

    You are also given integer arrays pricing and start where pricing = [low, high] and start = [row, col] indicates that you start at the position (row, col) and are interested only in items with a price in the range of [low, high] (inclusive). You are further given an integer k.

    + +

    You are interested in the positions of the k highest-ranked items whose prices are within the given price range. The rank is determined by the first of these criteria that is different:

    + +
      +
    1. Distance, defined as the length of the shortest path from the start (shorter distance has a higher rank).
    2. +
    3. Price (lower price has a higher rank, but it must be in the price range).
    4. +
    5. The row number (smaller row number has a higher rank).
    6. +
    7. The column number (smaller column number has a higher rank).
    8. +
    + +

    Return the k highest-ranked items within the price range sorted by their rank (highest to lowest). If there are fewer than k reachable items within the price range, return all of them.

    + +

     

    +

    Example 1:

    + +
    +Input: grid = [[1,2,0,1],[1,3,0,1],[0,2,5,1]], pricing = [2,5], start = [0,0], k = 3
    +Output: [[0,1],[1,1],[2,1]]
    +Explanation: You start at (0,0).
    +With a price range of [2,5], we can take items from (0,1), (1,1), (2,1) and (2,2).
    +The ranks of these items are:
    +- (0,1) with distance 1
    +- (1,1) with distance 2
    +- (2,1) with distance 3
    +- (2,2) with distance 4
    +Thus, the 3 highest ranked items in the price range are (0,1), (1,1), and (2,1).
    +
    + +

    Example 2:

    + +
    +Input: grid = [[1,2,0,1],[1,3,3,1],[0,2,5,1]], pricing = [2,3], start = [2,3], k = 2
    +Output: [[2,1],[1,2]]
    +Explanation: You start at (2,3).
    +With a price range of [2,3], we can take items from (0,1), (1,1), (1,2) and (2,1).
    +The ranks of these items are:
    +- (2,1) with distance 2, price 2
    +- (1,2) with distance 2, price 3
    +- (1,1) with distance 3
    +- (0,1) with distance 4
    +Thus, the 2 highest ranked items in the price range are (2,1) and (1,2).
    +
    + +

    Example 3:

    + +
    +Input: grid = [[1,1,1],[0,0,1],[2,3,4]], pricing = [2,3], start = [0,0], k = 3
    +Output: [[2,1],[2,0]]
    +Explanation: You start at (0,0).
    +With a price range of [2,3], we can take items from (2,0) and (2,1). 
    +The ranks of these items are: 
    +- (2,1) with distance 5
    +- (2,0) with distance 6
    +Thus, the 2 highest ranked items in the price range are (2,1) and (2,0). 
    +Note that k = 3 but there are only 2 reachable items within the price range.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 105
    • +
    • 1 <= m * n <= 105
    • +
    • 0 <= grid[i][j] <= 105
    • +
    • pricing.length == 2
    • +
    • 2 <= low <= high <= 105
    • +
    • start.length == 2
    • +
    • 0 <= row <= m - 1
    • +
    • 0 <= col <= n - 1
    • +
    • grid[row][col] > 0
    • +
    • 1 <= k <= m * n
    • +
    + +### Related Topics + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +Could you determine the rank of every item efficiently? +
    + +
    +Hint 2 +We can perform a breadth-first search from the starting position and know the length of the shortest path from start to every item. +
    + +
    +Hint 3 +Sort all the items according to the conditions listed in the problem, and return the first k (or all if less than k exist) items as the answer. +
    diff --git a/problems/k-radius-subarray-averages/README.md b/problems/k-radius-subarray-averages/README.md new file mode 100644 index 000000000..f062f0a12 --- /dev/null +++ b/problems/k-radius-subarray-averages/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../find-target-indices-after-sorting-array "Find Target Indices After Sorting Array") +                 +[Next >](../removing-minimum-and-maximum-from-array "Removing Minimum and Maximum From Array") + +## [2090. K Radius Subarray Averages (Medium)](https://leetcode.com/problems/k-radius-subarray-averages "半径为 k 的子数组平均值") + +

    You are given a 0-indexed array nums of n integers, and an integer k.

    + +

    The k-radius average for a subarray of nums centered at some index i with the radius k is the average of all elements in nums between the indices i - k and i + k (inclusive). If there are less than k elements before or after the index i, then the k-radius average is -1.

    + +

    Build and return an array avgs of length n where avgs[i] is the k-radius average for the subarray centered at index i.

    + +

    The average of x elements is the sum of the x elements divided by x, using integer division. The integer division truncates toward zero, which means losing its fractional part.

    + +
      +
    • For example, the average of four elements 2, 3, 1, and 5 is (2 + 3 + 1 + 5) / 4 = 11 / 4 = 2.75, which truncates to 2.
    • +
    + +

     

    +

    Example 1:

    + +
    +Input: nums = [7,4,3,9,1,8,5,2,6], k = 3
    +Output: [-1,-1,-1,5,4,4,-1,-1,-1]
    +Explanation:
    +- avg[0], avg[1], and avg[2] are -1 because there are less than k elements before each index.
    +- The sum of the subarray centered at index 3 with radius 3 is: 7 + 4 + 3 + 9 + 1 + 8 + 5 = 37.
    +  Using integer division, avg[3] = 37 / 7 = 5.
    +- For the subarray centered at index 4, avg[4] = (4 + 3 + 9 + 1 + 8 + 5 + 2) / 7 = 4.
    +- For the subarray centered at index 5, avg[5] = (3 + 9 + 1 + 8 + 5 + 2 + 6) / 7 = 4.
    +- avg[6], avg[7], and avg[8] are -1 because there are less than k elements after each index.
    +
    + +

    Example 2:

    + +
    +Input: nums = [100000], k = 0
    +Output: [100000]
    +Explanation:
    +- The sum of the subarray centered at index 0 with radius 0 is: 100000.
    +  avg[0] = 100000 / 1 = 100000.
    +
    + +

    Example 3:

    + +
    +Input: nums = [8], k = 100000
    +Output: [-1]
    +Explanation: 
    +- avg[0] is -1 because there are less than k elements before and after index 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= n <= 105
    • +
    • 0 <= nums[i], k <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
    +Hint 1 +To calculate the average of a subarray, you need the sum and the K. K is already given. How could you quickly calculate the sum of a subarray? +
    + +
    +Hint 2 +Use the Prefix Sums method to calculate the subarray sums. +
    + +
    +Hint 3 +It is possible that the sum of all the elements does not fit in a 32-bit integer type. Be sure to use a 64-bit integer type for the prefix sum array. +
    diff --git a/problems/k-th-smallest-in-lexicographical-order/README.md b/problems/k-th-smallest-in-lexicographical-order/README.md index 00ede0949..b5ef1c26b 100644 --- a/problems/k-th-smallest-in-lexicographical-order/README.md +++ b/problems/k-th-smallest-in-lexicographical-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../ternary-expression-parser "Ternary Expression Parser") diff --git a/problems/keep-multiplying-found-values-by-two/README.md b/problems/keep-multiplying-found-values-by-two/README.md new file mode 100644 index 000000000..bb4be6ff6 --- /dev/null +++ b/problems/keep-multiplying-found-values-by-two/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../the-number-of-passengers-in-each-bus-ii "The Number of Passengers in Each Bus II") +                 +[Next >](../all-divisions-with-the-highest-score-of-a-binary-array "All Divisions With the Highest Score of a Binary Array") + +## [2154. Keep Multiplying Found Values by Two (Easy)](https://leetcode.com/problems/keep-multiplying-found-values-by-two "将找到的值乘以 2") + +

    You are given an array of integers nums. You are also given an integer original which is the first number that needs to be searched for in nums.

    + +

    You then do the following steps:

    + +
      +
    1. If original is found in nums, multiply it by two (i.e., set original = 2 * original).
    2. +
    3. Otherwise, stop the process.
    4. +
    5. Repeat this process with the new number as long as you keep finding the number.
    6. +
    + +

    Return the final value of original.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [5,3,6,1,12], original = 3
    +Output: 24
    +Explanation: 
    +- 3 is found in nums. 3 is multiplied by 2 to obtain 6.
    +- 6 is found in nums. 6 is multiplied by 2 to obtain 12.
    +- 12 is found in nums. 12 is multiplied by 2 to obtain 24.
    +- 24 is not found in nums. Thus, 24 is returned.
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,7,9], original = 4
    +Output: 4
    +Explanation:
    +- 4 is not found in nums. Thus, 4 is returned.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • 1 <= nums[i], original <= 1000
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sorting](../../tag/sorting/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Repeatedly iterate through the array and check if the current value of original is in the array. +
    + +
    +Hint 2 +If original is not found, stop and return its current value. +
    + +
    +Hint 3 +Otherwise, multiply original by 2 and repeat the process. +
    + +
    +Hint 4 +Use set data structure to check the existence faster. +
    diff --git a/problems/kill-process/README.md b/problems/kill-process/README.md index 7e5c758ca..bd317f457 100644 --- a/problems/kill-process/README.md +++ b/problems/kill-process/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-unsorted-continuous-subarray "Shortest Unsorted Continuous Subarray") diff --git a/problems/koko-eating-bananas/README.md b/problems/koko-eating-bananas/README.md index 89ee52e14..1a72a6186 100644 --- a/problems/koko-eating-bananas/README.md +++ b/problems/koko-eating-bananas/README.md @@ -56,3 +56,4 @@ ### Similar Questions 1. [Minimize Max Distance to Gas Station](../minimize-max-distance-to-gas-station) (Hard) + 1. [Minimized Maximum of Products Distributed to Any Store](../minimized-maximum-of-products-distributed-to-any-store) (Medium) diff --git a/problems/kth-largest-element-in-a-stream/README.md b/problems/kth-largest-element-in-a-stream/README.md index 100e1cf78..5c9061b41 100644 --- a/problems/kth-largest-element-in-a-stream/README.md +++ b/problems/kth-largest-element-in-a-stream/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../search-in-a-sorted-array-of-unknown-size "Search in a Sorted Array of Unknown Size") diff --git a/problems/largest-1-bordered-square/README.md b/problems/largest-1-bordered-square/README.md index 35359c6e7..b2e11e036 100644 --- a/problems/largest-1-bordered-square/README.md +++ b/problems/largest-1-bordered-square/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../alphabet-board-path "Alphabet Board Path") diff --git a/problems/largest-magic-square/README.md b/problems/largest-magic-square/README.md index d0553679e..c13ed708f 100644 --- a/problems/largest-magic-square/README.md +++ b/problems/largest-magic-square/README.md @@ -50,9 +50,6 @@ Every row sum, column sum, and diagonal sum of this magic square is equal to 12. [[Matrix](../../tag/matrix/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] -### Similar Questions - 1. [Magic Squares In Grid](../magic-squares-in-grid) (Medium) - ### Hints
    Hint 1 diff --git a/problems/largest-multiple-of-three/README.md b/problems/largest-multiple-of-three/README.md index 3995859b7..91ce76469 100644 --- a/problems/largest-multiple-of-three/README.md +++ b/problems/largest-multiple-of-three/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../closest-divisors "Closest Divisors") @@ -37,13 +37,6 @@ Output: "" -

    Example 4:

    - -
    -Input: digits = [0,0,0,0,0,0]
    -Output: "0"
    -
    -

     

    Constraints:

    @@ -53,9 +46,9 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/largest-number/README.md b/problems/largest-number/README.md index de24d869a..308b5ad2c 100644 --- a/problems/largest-number/README.md +++ b/problems/largest-number/README.md @@ -11,9 +11,9 @@ ## [179. Largest Number (Medium)](https://leetcode.com/problems/largest-number "最大数") -

    Given a list of non-negative integers nums, arrange them such that they form the largest number.

    +

    Given a list of non-negative integers nums, arrange them such that they form the largest number and return it.

    -

    Note: The result may be very large, so you need to return a string instead of an integer.

    +

    Since the result may be very large, so you need to return a string instead of an integer.

     

    Example 1:

    @@ -30,20 +30,6 @@ Output: "9534330" -

    Example 3:

    - -
    -Input: nums = [1]
    -Output: "1"
    -
    - -

    Example 4:

    - -
    -Input: nums = [10]
    -Output: "10"
    -
    -

     

    Constraints:

    diff --git a/problems/largest-odd-number-in-string/README.md b/problems/largest-odd-number-in-string/README.md index 71116c391..433ce9589 100644 --- a/problems/largest-odd-number-in-string/README.md +++ b/problems/largest-odd-number-in-string/README.md @@ -49,9 +49,9 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/largest-perimeter-triangle/README.md b/problems/largest-perimeter-triangle/README.md index 924d7001a..0bc3e6422 100644 --- a/problems/largest-perimeter-triangle/README.md +++ b/problems/largest-perimeter-triangle/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../odd-even-jump "Odd Even Jump") @@ -15,18 +15,19 @@

     

    Example 1:

    -
    Input: nums = [2,1,2]
    +
    +
    +Input: nums = [2,1,2]
     Output: 5
    -

    Example 2:

    -
    Input: nums = [1,2,1]
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,2,1]
     Output: 0
    -

    Example 3:

    -
    Input: nums = [3,2,3,4]
    -Output: 10
    -

    Example 4:

    -
    Input: nums = [3,6,2,3]
    -Output: 8
     
    +

     

    Constraints:

    diff --git a/problems/largest-subarray-length-k/README.md b/problems/largest-subarray-length-k/README.md index f4590c82e..29371e2c9 100644 --- a/problems/largest-subarray-length-k/README.md +++ b/problems/largest-subarray-length-k/README.md @@ -14,8 +14,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/largest-submatrix-with-rearrangements/README.md b/problems/largest-submatrix-with-rearrangements/README.md index 6c614e375..fd5ac277b 100644 --- a/problems/largest-submatrix-with-rearrangements/README.md +++ b/problems/largest-submatrix-with-rearrangements/README.md @@ -17,9 +17,7 @@

     

    Example 1:

    - -

    - +
     Input: matrix = [[0,0,1],[1,1,1],[1,0,1]]
     Output: 4
    @@ -28,9 +26,7 @@ The largest submatrix of 1s, in bold, has an area of 4.
     

    Example 2:

    - -

    - +
     Input: matrix = [[1,0,1,0,1]]
     Output: 3
    @@ -43,14 +39,8 @@ The largest submatrix of 1s, in bold, has an area of 3.
     
     Input: matrix = [[1,1,0],[1,0,1]]
     Output: 2
    -Explanation: Notice that you must rearrange entire columns, and there is no way to make a submatrix of 1s larger than an area of 2.
    - -

    Example 4:

    - -
    -Input: matrix = [[0,0],[0,0]]
    -Output: 0
    -Explanation: As there are no 1s, no submatrix of 1s can be formed and the area is 0.
    +Explanation: Notice that you must rearrange entire columns, and there is no way to make a submatrix of 1s larger than an area of 2. +

     

    Constraints:

    @@ -59,7 +49,7 @@ The largest submatrix of 1s, in bold, has an area of 3.
  • m == matrix.length
  • n == matrix[i].length
  • 1 <= m * n <= 105
  • -
  • matrix[i][j] is 0 or 1.
  • +
  • matrix[i][j] is either 0 or 1.
  • ### Related Topics diff --git a/problems/largest-substring-between-two-equal-characters/README.md b/problems/largest-substring-between-two-equal-characters/README.md index c707c3506..46a160a10 100644 --- a/problems/largest-substring-between-two-equal-characters/README.md +++ b/problems/largest-substring-between-two-equal-characters/README.md @@ -39,14 +39,6 @@ Explanation: There are no characters that appear twice in s.
    -

    Example 4:

    - -
    -Input: s = "cabbac"
    -Output: 4
    -Explanation: The optimal substring here is "abba". Other non-optimal substrings include "bb" and "".
    -
    -

     

    Constraints:

    diff --git a/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md b/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md index 2cd2780b0..4c259e38a 100644 --- a/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md +++ b/problems/last-moment-before-all-ants-fall-out-of-a-plank/README.md @@ -11,13 +11,13 @@ ## [1503. Last Moment Before All Ants Fall Out of a Plank (Medium)](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank "所有蚂蚁掉下来前的最后一刻") -

    We have a wooden plank of the length n units. Some ants are walking on the plank, each ant moves with speed 1 unit per second. Some of the ants move to the left, the other move to the right.

    +

    We have a wooden plank of the length n units. Some ants are walking on the plank, each ant moves with a speed of 1 unit per second. Some of the ants move to the left, the other move to the right.

    -

    When two ants moving in two different directions meet at some point, they change their directions and continue moving again. Assume changing directions doesn't take any additional time.

    +

    When two ants moving in two different directions meet at some point, they change their directions and continue moving again. Assume changing directions does not take any additional time.

    -

    When an ant reaches one end of the plank at a time t, it falls out of the plank imediately.

    +

    When an ant reaches one end of the plank at a time t, it falls out of the plank immediately.

    -

    Given an integer n and two integer arrays left and right, the positions of the ants moving to the left and the right. Return the moment when the last ant(s) fall out of the plank.

    +

    Given an integer n and two integer arrays left and right, the positions of the ants moving to the left and the right, return the moment when the last ant(s) fall out of the plank.

     

    Example 1:

    @@ -30,7 +30,7 @@ -The ant at index 1 is named B and going to the right. -The ant at index 3 is named C and going to the left. -The ant at index 4 is named D and going to the left. -Note that the last moment when an ant was on the plank is t = 4 second, after that it falls imediately out of the plank. (i.e. We can say that at t = 4.0000000001, there is no ants on the plank). +The last moment when an ant was on the plank is t = 4 seconds. After that, it falls immediately out of the plank. (i.e., We can say that at t = 4.0000000001, there are no ants on the plank).

    Example 2:

    @@ -49,26 +49,11 @@ Note that the last moment when an ant was on the plank is t = 4 second, after th Explanation: All ants are going to the left, the ant at index 7 needs 7 seconds to fall. -

    Example 4:

    - -
    -Input: n = 9, left = [5], right = [4]
    -Output: 5
    -Explanation: At t = 1 second, both ants will be at the same intial position but with different direction.
    -
    - -

    Example 5:

    - -
    -Input: n = 6, left = [6], right = [0]
    -Output: 6
    -
    -

     

    Constraints:

      -
    • 1 <= n <= 10^4
    • +
    • 1 <= n <= 104
    • 0 <= left.length <= n + 1
    • 0 <= left[i] <= n
    • 0 <= right.length <= n + 1
    • @@ -78,8 +63,8 @@ Note that the last moment when an ant was on the plank is t = 4 second, after th
    ### Related Topics - [[Array](../../tag/array/README.md)] [[Brainteaser](../../tag/brainteaser/README.md)] + [[Array](../../tag/array/README.md)] [[Simulation](../../tag/simulation/README.md)] ### Hints diff --git a/problems/least-number-of-unique-integers-after-k-removals/README.md b/problems/least-number-of-unique-integers-after-k-removals/README.md index e31706f4f..07b4b71a6 100644 --- a/problems/least-number-of-unique-integers-after-k-removals/README.md +++ b/problems/least-number-of-unique-integers-after-k-removals/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../running-sum-of-1d-array "Running Sum of 1d Array") diff --git a/problems/leetcodify-friends-recommendations/README.md b/problems/leetcodify-friends-recommendations/README.md index cb786fb0e..dcc682953 100644 --- a/problems/leetcodify-friends-recommendations/README.md +++ b/problems/leetcodify-friends-recommendations/README.md @@ -9,7 +9,7 @@                  [Next >](../kth-smallest-subarray-sum "Kth Smallest Subarray Sum") -## [1917. Leetcodify Friends Recommendations (Hard)](https://leetcode.com/problems/leetcodify-friends-recommendations "") +## [1917. Leetcodify Friends Recommendations (Hard)](https://leetcode.com/problems/leetcodify-friends-recommendations "Leetcodify 好友推荐") diff --git a/problems/leetcodify-similar-friends/README.md b/problems/leetcodify-similar-friends/README.md index f7168514e..3d20773a3 100644 --- a/problems/leetcodify-similar-friends/README.md +++ b/problems/leetcodify-similar-friends/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Leetcodify Friends Recommendations](../leetcodify-friends-recommendations) (Hard) diff --git a/problems/leftmost-column-with-at-least-a-one/README.md b/problems/leftmost-column-with-at-least-a-one/README.md index 52434c5cc..da3d04af4 100644 --- a/problems/leftmost-column-with-at-least-a-one/README.md +++ b/problems/leftmost-column-with-at-least-a-one/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../perform-string-shifts "Perform String Shifts") @@ -16,8 +16,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Interactive](../../tag/interactive/README.md)] [[Matrix](../../tag/matrix/README.md)] + [[Interactive](../../tag/interactive/README.md)] ### Hints
    diff --git a/problems/letter-case-permutation/README.md b/problems/letter-case-permutation/README.md index 1599aa88b..975c5da62 100644 --- a/problems/letter-case-permutation/README.md +++ b/problems/letter-case-permutation/README.md @@ -11,9 +11,9 @@ ## [784. Letter Case Permutation (Medium)](https://leetcode.com/problems/letter-case-permutation "字母大小写全排列") -

    Given a string s, we can transform every letter individually to be lowercase or uppercase to create another string.

    +

    Given a string s, you can transform every letter individually to be lowercase or uppercase to create another string.

    -

    Return a list of all possible strings we could create. You can return the output in any order.

    +

    Return a list of all possible strings we could create. Return the output in any order.

     

    Example 1:

    @@ -30,32 +30,18 @@ Output: ["3z4","3Z4"] -

    Example 3:

    - -
    -Input: s = "12345"
    -Output: ["12345"]
    -
    - -

    Example 4:

    - -
    -Input: s = "0"
    -Output: ["0"]
    -
    -

     

    Constraints:

      -
    • s will be a string with length between 1 and 12.
    • -
    • s will consist only of letters or digits.
    • +
    • 1 <= s.length <= 12
    • +
    • s consists of lowercase English letters, uppercase English letters, and digits.
    ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Similar Questions 1. [Subsets](../subsets) (Medium) diff --git a/problems/lexicographically-smallest-string-after-applying-operations/README.md b/problems/lexicographically-smallest-string-after-applying-operations/README.md index d0c943cb6..09ea81db8 100644 --- a/problems/lexicographically-smallest-string-after-applying-operations/README.md +++ b/problems/lexicographically-smallest-string-after-applying-operations/README.md @@ -30,15 +30,15 @@
     Input: s = "5525", a = 9, b = 2
     Output: "2050"
    -Explanation: We can apply the following operations:
    +Explanation: We can apply the following operations:
     Start:  "5525"
     Rotate: "2555"
     Add:    "2454"
     Add:    "2353"
     Rotate: "5323"
     Add:    "5222"
    -​​​​​​​Add:    "5121"
    -​​​​​​​Rotate: "2151"
    +Add:    "5121"
    +Rotate: "2151"
     ​​​​​​​Add:    "2050"​​​​​​​​​​​​
     There is no way to obtain a string that is lexicographically smaller then "2050".
     
    @@ -48,7 +48,7 @@ There is no way to obtain a string that is lexicographically smaller then "
     Input: s = "74", a = 5, b = 1
     Output: "24"
    -Explanation: We can apply the following operations:
    +Explanation: We can apply the following operations:
     Start:  "74"
     Rotate: "47"
     ​​​​​​​Add:    "42"
    @@ -61,14 +61,7 @@ There is no way to obtain a string that is lexicographically smaller then "
     
     Input: s = "0011", a = 4, b = 2
     Output: "0011"
    -Explanation: There are no sequence of operations that will give us a lexicographically smaller string than "0011".
    -
    - -

    Example 4:

    - -
    -Input: s = "43987654", a = 7, b = 3
    -Output: "00553311"
    +Explanation: There are no sequence of operations that will give us a lexicographically smaller string than "0011".
     

     

    @@ -83,8 +76,8 @@ There is no way to obtain a string that is lexicographically smaller then " ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[String](../../tag/string/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Hints
    diff --git a/problems/line-reflection/README.md b/problems/line-reflection/README.md index e102b042a..ba950f01d 100644 --- a/problems/line-reflection/README.md +++ b/problems/line-reflection/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-twitter "Design Twitter") diff --git a/problems/linked-list-in-binary-tree/README.md b/problems/linked-list-in-binary-tree/README.md index bd5ccf805..9b1a71dfe 100644 --- a/problems/linked-list-in-binary-tree/README.md +++ b/problems/linked-list-in-binary-tree/README.md @@ -55,10 +55,10 @@ ### Related Topics + [[Linked List](../../tag/linked-list/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Linked List](../../tag/linked-list/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints diff --git a/problems/logger-rate-limiter/README.md b/problems/logger-rate-limiter/README.md index 20267a79e..52a6f01b0 100644 --- a/problems/logger-rate-limiter/README.md +++ b/problems/logger-rate-limiter/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rearrange-string-k-distance-apart "Rearrange String k Distance Apart") diff --git a/problems/longer-contiguous-segments-of-ones-than-zeros/README.md b/problems/longer-contiguous-segments-of-ones-than-zeros/README.md index ea4ae8c81..a95dfe168 100644 --- a/problems/longer-contiguous-segments-of-ones-than-zeros/README.md +++ b/problems/longer-contiguous-segments-of-ones-than-zeros/README.md @@ -64,6 +64,11 @@ The segment of 1s is not longer, so return false. ### Related Topics [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Max Consecutive Ones](../max-consecutive-ones) (Easy) + 1. [Count Subarrays With More Ones Than Zeros](../count-subarrays-with-more-ones-than-zeros) (Medium) + 1. [Check if Binary String Has at Most One Segment of Ones](../check-if-binary-string-has-at-most-one-segment-of-ones) (Easy) + ### Hints
    Hint 1 diff --git a/problems/longest-arithmetic-subsequence-of-given-difference/README.md b/problems/longest-arithmetic-subsequence-of-given-difference/README.md index 4158fbe84..dc350155e 100644 --- a/problems/longest-arithmetic-subsequence-of-given-difference/README.md +++ b/problems/longest-arithmetic-subsequence-of-given-difference/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-cost-to-move-chips-to-the-same-position "Minimum Cost to Move Chips to The Same Position") diff --git a/problems/longest-arithmetic-subsequence/README.md b/problems/longest-arithmetic-subsequence/README.md index a11e3f40c..33b7de800 100644 --- a/problems/longest-arithmetic-subsequence/README.md +++ b/problems/longest-arithmetic-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-difference-between-node-and-ancestor "Maximum Difference Between Node and Ancestor") diff --git a/problems/longest-chunked-palindrome-decomposition/README.md b/problems/longest-chunked-palindrome-decomposition/README.md index 6c7f56e26..6e555f50b 100644 --- a/problems/longest-chunked-palindrome-decomposition/README.md +++ b/problems/longest-chunked-palindrome-decomposition/README.md @@ -46,14 +46,6 @@ Explanation: We can split the string on "(a)(nt)(a)(pre)(za)(tpe)(za)(pre)(a)(nt)(a)".
    -

    Example 4:

    - -
    -Input: text = "aaa"
    -Output: 3
    -Explanation: We can split the string on "(a)(a)(a)".
    -
    -

     

    Constraints:

    diff --git a/problems/longest-common-subsequence-between-sorted-arrays/README.md b/problems/longest-common-subsequence-between-sorted-arrays/README.md index 3f9f604dc..1477353b8 100644 --- a/problems/longest-common-subsequence-between-sorted-arrays/README.md +++ b/problems/longest-common-subsequence-between-sorted-arrays/README.md @@ -18,6 +18,9 @@ [[Hash Table](../../tag/hash-table/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Merge Two Sorted Lists](../merge-two-sorted-lists) (Easy) + ### Hints
    Hint 1 diff --git a/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md index 66c810ef5..ae7344147 100644 --- a/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md +++ b/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-all-1s-are-at-least-length-k-places-away "Check If All 1's Are at Least Length K Places Away") @@ -58,12 +58,12 @@ Therefore, the size of the longest subarray is 2. ### Related Topics - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] - [[Ordered Set](../../tag/ordered-set/README.md)] + [[Queue](../../tag/queue/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Monotonic Queue](../../tag/monotonic-queue/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] ### Hints
    diff --git a/problems/longest-duplicate-substring/README.md b/problems/longest-duplicate-substring/README.md index b40016fef..e3a41f9d7 100644 --- a/problems/longest-duplicate-substring/README.md +++ b/problems/longest-duplicate-substring/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../partition-array-for-maximum-sum "Partition Array for Maximum Sum") @@ -34,10 +34,10 @@ ### Related Topics [[String](../../tag/string/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Suffix Array](../../tag/suffix-array/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Hash Function](../../tag/hash-function/README.md)] [[Rolling Hash](../../tag/rolling-hash/README.md)] + [[Suffix Array](../../tag/suffix-array/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] ### Hints
    diff --git a/problems/longest-happy-prefix/README.md b/problems/longest-happy-prefix/README.md index 673083037..7fa67f4df 100644 --- a/problems/longest-happy-prefix/README.md +++ b/problems/longest-happy-prefix/README.md @@ -32,20 +32,6 @@ Explanation: "abab" is the largest prefix which is also suffix. They can overlap in the original string. -

    Example 3:

    - -
    -Input: s = "leetcodeleet"
    -Output: "leet"
    -
    - -

    Example 4:

    - -
    -Input: s = "a"
    -Output: ""
    -
    -

     

    Constraints:

    @@ -56,9 +42,9 @@ ### Related Topics [[String](../../tag/string/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] [[String Matching](../../tag/string-matching/README.md)] [[Hash Function](../../tag/hash-function/README.md)] - [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/longest-happy-string/README.md b/problems/longest-happy-string/README.md index bd6c6c74d..a07549769 100644 --- a/problems/longest-happy-string/README.md +++ b/problems/longest-happy-string/README.md @@ -11,17 +11,19 @@ ## [1405. Longest Happy String (Medium)](https://leetcode.com/problems/longest-happy-string "最长快乐字符串") -

    A string is called happy if it does not have any of the strings 'aaa', 'bbb' or 'ccc' as a substring.

    - -

    Given three integers a, b and c, return any string s, which satisfies following conditions:

    +

    A string s is called happy if it satisfies the following conditions:

      -
    • s is happy and longest possible.
    • -
    • s contains at most a occurrences of the letter 'a', at most b occurrences of the letter 'b' and at most c occurrences of the letter 'c'.
    • -
    • will only contain 'a', 'b' and 'c' letters.
    • +
    • s only contains the letters 'a', 'b', and 'c'.
    • +
    • s does not contain any of "aaa", "bbb", or "ccc" as a substring.
    • +
    • s contains at most a occurrences of the letter 'a'.
    • +
    • s contains at most b occurrences of the letter 'b'.
    • +
    • s contains at most c occurrences of the letter 'c'.
    -

    If there is no such string s return the empty string "".

    +

    Given three integers a, b, and c, return the longest possible happy string. If there are multiple longest happy strings, return any of them. If there is no such string, return the empty string "".

    + +

    A substring is a contiguous sequence of characters within a string.

     

    Example 1:

    @@ -34,17 +36,10 @@

    Example 2:

    -
    -Input: a = 2, b = 2, c = 1
    -Output: "aabbc"
    -
    - -

    Example 3:

    -
     Input: a = 7, b = 1, c = 0
     Output: "aabaa"
    -Explanation: It's the only correct answer in this case.
    +Explanation: It is the only correct answer in this case.
     

     

    @@ -60,6 +55,9 @@ [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] +### Similar Questions + 1. [Reorganize String](../reorganize-string) (Medium) + ### Hints
    Hint 1 diff --git a/problems/longest-harmonious-subsequence/README.md b/problems/longest-harmonious-subsequence/README.md index 61d1605f2..a965eb210 100644 --- a/problems/longest-harmonious-subsequence/README.md +++ b/problems/longest-harmonious-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-square "Valid Square") diff --git a/problems/longest-increasing-path-in-a-matrix/README.md b/problems/longest-increasing-path-in-a-matrix/README.md index 2561b5543..e03319e78 100644 --- a/problems/longest-increasing-path-in-a-matrix/README.md +++ b/problems/longest-increasing-path-in-a-matrix/README.md @@ -50,9 +50,9 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] [[Topological Sort](../../tag/topological-sort/README.md)] [[Memoization](../../tag/memoization/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] diff --git a/problems/longest-mountain-in-array/README.md b/problems/longest-mountain-in-array/README.md index 275d9a58e..c391abf44 100644 --- a/problems/longest-mountain-in-array/README.md +++ b/problems/longest-mountain-in-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../backspace-string-compare "Backspace String Compare") diff --git a/problems/longest-nice-substring/README.md b/problems/longest-nice-substring/README.md index 8d3fc5369..20b09a0f5 100644 --- a/problems/longest-nice-substring/README.md +++ b/problems/longest-nice-substring/README.md @@ -30,22 +30,16 @@
     Input: s = "Bb"
     Output: "Bb"
    -Explanation: "Bb" is a nice string because both 'B' and 'b' appear. The whole string is a substring.
    +Explanation: "Bb" is a nice string because both 'B' and 'b' appear. The whole string is a substring. +

    Example 3:

     Input: s = "c"
     Output: ""
    -Explanation: There are no nice substrings.
    - -

    Example 4:

    - -
    -Input: s = "dDzeE"
    -Output: "dD"
    -Explanation: Both "dD" and "eE" are the longest nice substrings.
    -As there are multiple longest nice substrings, return "dD" since it occurs earlier.
    +Explanation: There are no nice substrings. +

     

    Constraints:

    diff --git a/problems/longest-palindrome-by-concatenating-two-letter-words/README.md b/problems/longest-palindrome-by-concatenating-two-letter-words/README.md new file mode 100644 index 000000000..3efa72307 --- /dev/null +++ b/problems/longest-palindrome-by-concatenating-two-letter-words/README.md @@ -0,0 +1,80 @@ + + + + + + + +[< Previous](../maximum-twin-sum-of-a-linked-list "Maximum Twin Sum of a Linked List") +                 +[Next >](../stamping-the-grid "Stamping the Grid") + +## [2131. Longest Palindrome by Concatenating Two Letter Words (Medium)](https://leetcode.com/problems/longest-palindrome-by-concatenating-two-letter-words "连接两字母单词得到的最长回文串") + +

    You are given an array of strings words. Each element of words consists of two lowercase English letters.

    + +

    Create the longest possible palindrome by selecting some elements from words and concatenating them in any order. Each element can be selected at most once.

    + +

    Return the length of the longest palindrome that you can create. If it is impossible to create any palindrome, return 0.

    + +

    A palindrome is a string that reads the same forward and backward.

    + +

     

    +

    Example 1:

    + +
    +Input: words = ["lc","cl","gg"]
    +Output: 6
    +Explanation: One longest palindrome is "lc" + "gg" + "cl" = "lcggcl", of length 6.
    +Note that "clgglc" is another longest palindrome that can be created.
    +
    + +

    Example 2:

    + +
    +Input: words = ["ab","ty","yt","lc","cl","ab"]
    +Output: 8
    +Explanation: One longest palindrome is "ty" + "lc" + "cl" + "yt" = "tylcclyt", of length 8.
    +Note that "lcyttycl" is another longest palindrome that can be created.
    +
    + +

    Example 3:

    + +
    +Input: words = ["cc","ll","xx"]
    +Output: 2
    +Explanation: One longest palindrome is "cc", of length 2.
    +Note that "ll" is another longest palindrome that can be created, and so is "xx".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= words.length <= 105
    • +
    • words[i].length == 2
    • +
    • words[i] consists of lowercase English letters.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Hints +
    +Hint 1 +A palindrome must be mirrored over the center. Suppose we have a palindrome. If we prepend the word "ab" on the left, what must we append on the right to keep it a palindrome? +
    + +
    +Hint 2 +We must append "ba" on the right. The number of times we can do this is the minimum of (occurrences of "ab") and (occurrences of "ba"). +
    + +
    +Hint 3 +For words that are already palindromes, e.g. "aa", we can prepend and append these in pairs as described in the previous hint. We can also use exactly one in the middle to form an even longer palindrome. +
    diff --git a/problems/longest-palindromic-subsequence-ii/README.md b/problems/longest-palindromic-subsequence-ii/README.md index 7e5d73629..7f8a858a1 100644 --- a/problems/longest-palindromic-subsequence-ii/README.md +++ b/problems/longest-palindromic-subsequence-ii/README.md @@ -17,6 +17,9 @@ [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Longest Palindromic Subsequence](../longest-palindromic-subsequence) (Medium) + ### Hints
    Hint 1 diff --git a/problems/longest-subarray-of-1s-after-deleting-one-element/README.md b/problems/longest-subarray-of-1s-after-deleting-one-element/README.md index 6da0a32b4..4c5892b99 100644 --- a/problems/longest-subarray-of-1s-after-deleting-one-element/README.md +++ b/problems/longest-subarray-of-1s-after-deleting-one-element/README.md @@ -21,34 +21,23 @@
     Input: nums = [1,1,0,1]
     Output: 3
    -Explanation: After deleting the number in position 2, [1,1,1] contains 3 numbers with value of 1's.
    +Explanation: After deleting the number in position 2, [1,1,1] contains 3 numbers with value of 1's. +

    Example 2:

     Input: nums = [0,1,1,1,0,1,1,0,1]
     Output: 5
    -Explanation: After deleting the number in position 4, [0,1,1,1,1,1,0,1] longest subarray with value of 1's is [1,1,1,1,1].
    +Explanation: After deleting the number in position 4, [0,1,1,1,1,1,0,1] longest subarray with value of 1's is [1,1,1,1,1]. +

    Example 3:

     Input: nums = [1,1,1]
     Output: 2
    -Explanation: You must delete one element.
    - -

    Example 4:

    - -
    -Input: nums = [1,1,0,0,1,1,1,0,1]
    -Output: 4
    -
    - -

    Example 5:

    - -
    -Input: nums = [0,0,0]
    -Output: 0
    +Explanation: You must delete one element.
     

     

    diff --git a/problems/longest-subsequence-repeated-k-times/README.md b/problems/longest-subsequence-repeated-k-times/README.md index eb18b2de0..2879b957e 100644 --- a/problems/longest-subsequence-repeated-k-times/README.md +++ b/problems/longest-subsequence-repeated-k-times/README.md @@ -49,14 +49,6 @@ Explanation: There is no subsequence repeated 2 times. Empty string is returned. -

    Example 4:

    - -
    -Input: s = "bbabbabbbbabaababab", k = 3
    -Output: "bbbb"
    -Explanation: The longest subsequence "bbbb" is repeated 3 times in "bbabbabbbbabaababab".
    -
    -

     

    Constraints:

    diff --git a/problems/longest-uncommon-subsequence-ii/README.md b/problems/longest-uncommon-subsequence-ii/README.md index 218b3d5fd..be9dd896a 100644 --- a/problems/longest-uncommon-subsequence-ii/README.md +++ b/problems/longest-uncommon-subsequence-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-uncommon-subsequence-i "Longest Uncommon Subsequence I") diff --git a/problems/longest-univalue-path/README.md b/problems/longest-univalue-path/README.md index de2efc274..87333d2cc 100644 --- a/problems/longest-univalue-path/README.md +++ b/problems/longest-univalue-path/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../repeated-string-match "Repeated String Match") diff --git a/problems/longest-winning-streak/README.md b/problems/longest-winning-streak/README.md new file mode 100644 index 000000000..d136c15df --- /dev/null +++ b/problems/longest-winning-streak/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../maximum-and-sum-of-array "Maximum AND Sum of Array") +                 +Next > + +## [2173. Longest Winning Streak (Hard)](https://leetcode.com/problems/longest-winning-streak "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/longest-winning-streak/mysql_schemas.sql b/problems/longest-winning-streak/mysql_schemas.sql new file mode 100644 index 000000000..6da5cb0fb --- /dev/null +++ b/problems/longest-winning-streak/mysql_schemas.sql @@ -0,0 +1,10 @@ +Create table If Not Exists Matches (player_id int, match_day date, result ENUM('Win', 'Draw', 'Lose')); +Truncate table Matches; +insert into Matches (player_id, match_day, result) values ('1', '2022-01-17', 'Win'); +insert into Matches (player_id, match_day, result) values ('1', '2022-01-18', 'Win'); +insert into Matches (player_id, match_day, result) values ('1', '2022-01-25', 'Win'); +insert into Matches (player_id, match_day, result) values ('1', '2022-01-31', 'Draw'); +insert into Matches (player_id, match_day, result) values ('1', '2022-02-08', 'Win'); +insert into Matches (player_id, match_day, result) values ('2', '2022-02-06', 'Lose'); +insert into Matches (player_id, match_day, result) values ('2', '2022-02-08', 'Lose'); +insert into Matches (player_id, match_day, result) values ('3', '2022-03-30', 'Win'); diff --git a/problems/low-quality-problems/README.md b/problems/low-quality-problems/README.md index 9daaf212c..09b5a0c7a 100644 --- a/problems/low-quality-problems/README.md +++ b/problems/low-quality-problems/README.md @@ -9,7 +9,7 @@                  [Next >](../minimum-moves-to-convert-string "Minimum Moves to Convert String") -## [2026. Low-Quality Problems (Easy)](https://leetcode.com/problems/low-quality-problems "") +## [2026. Low-Quality Problems (Easy)](https://leetcode.com/problems/low-quality-problems "低质量的问题") diff --git a/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md b/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md index 026487e5f..a616f79c8 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree-iv/README.md @@ -18,6 +18,14 @@ [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] +### Similar Questions + 1. [Lowest Common Ancestor of a Binary Search Tree](../lowest-common-ancestor-of-a-binary-search-tree) (Easy) + 1. [Lowest Common Ancestor of a Binary Tree](../lowest-common-ancestor-of-a-binary-tree) (Medium) + 1. [Lowest Common Ancestor of Deepest Leaves](../lowest-common-ancestor-of-deepest-leaves) (Medium) + 1. [Lowest Common Ancestor of a Binary Tree II](../lowest-common-ancestor-of-a-binary-tree-ii) (Medium) + 1. [Lowest Common Ancestor of a Binary Tree III](../lowest-common-ancestor-of-a-binary-tree-iii) (Medium) + 1. [Lowest Common Ancestor of a Binary Tree IV](../lowest-common-ancestor-of-a-binary-tree-iv) (Medium) + ### Hints
    Hint 1 diff --git a/problems/lowest-common-ancestor-of-a-binary-tree/README.md b/problems/lowest-common-ancestor-of-a-binary-tree/README.md index 6baf04ac6..bd54f479f 100644 --- a/problems/lowest-common-ancestor-of-a-binary-tree/README.md +++ b/problems/lowest-common-ancestor-of-a-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../lowest-common-ancestor-of-a-binary-search-tree "Lowest Common Ancestor of a Binary Search Tree") diff --git a/problems/majority-element-ii/README.md b/problems/majority-element-ii/README.md index 8fe8073d6..07c9879d8 100644 --- a/problems/majority-element-ii/README.md +++ b/problems/majority-element-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../summary-ranges "Summary Ranges") @@ -13,8 +13,6 @@

    Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times.

    -

    Follow-up: Could you solve the problem in linear time and in O(1) space?

    -

     

    Example 1:

    @@ -45,11 +43,14 @@
  • -109 <= nums[i] <= 109
  • +

     

    +

    Follow up: Could you solve the problem in linear time and in O(1) space?

    + ### Related Topics [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Counting](../../tag/counting/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Counting](../../tag/counting/README.md)] ### Similar Questions 1. [Majority Element](../majority-element) (Easy) diff --git a/problems/majority-element/README.md b/problems/majority-element/README.md index ae8eb9d3d..0e1ec3228 100644 --- a/problems/majority-element/README.md +++ b/problems/majority-element/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../excel-sheet-column-title "Excel Sheet Column Title") diff --git a/problems/make-sum-divisible-by-p/README.md b/problems/make-sum-divisible-by-p/README.md index ecef87f72..bcdc0d891 100644 --- a/problems/make-sum-divisible-by-p/README.md +++ b/problems/make-sum-divisible-by-p/README.md @@ -42,21 +42,6 @@ Explanation: Here the sum is 6. which is already divisible by 3. Thus we do not need to remove anything. -

    Example 4:

    - -
    -Input: nums = [1,2,3], p = 7
    -Output: -1
    -Explanation: There is no way to remove a subarray in order to get a sum divisible by 7.
    -
    - -

    Example 5:

    - -
    -Input: nums = [1000000000,1000000000,1000000000], p = 3
    -Output: 0
    -
    -

     

    Constraints:

    diff --git a/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md b/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md index 7ccaa9fe5..3f98c203d 100644 --- a/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md +++ b/problems/make-two-arrays-equal-by-reversing-sub-arrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rectangles-area "Rectangles Area") @@ -11,11 +11,9 @@ ## [1460. Make Two Arrays Equal by Reversing Sub-arrays (Easy)](https://leetcode.com/problems/make-two-arrays-equal-by-reversing-sub-arrays "通过翻转子数组使两个数组相等") -

    Given two integer arrays of equal length target and arr.

    +

    You are given two integer arrays of equal length target and arr. In one step, you can select any non-empty sub-array of arr and reverse it. You are allowed to make any number of steps.

    -

    In one step, you can select any non-empty sub-array of arr and reverse it. You are allowed to make any number of steps.

    - -

    Return True if you can make arr equal to target, or False otherwise.

    +

    Return true if you can make arr equal to target or false otherwise.

     

    Example 1:

    @@ -40,24 +38,10 @@ There are multiple ways to convert arr to target, this is not the only way to do

    Example 3:

    -
    -Input: target = [1,12], arr = [12,1]
    -Output: true
    -
    - -

    Example 4:

    -
     Input: target = [3,7,9], arr = [3,7,11]
     Output: false
    -Explanation: arr doesn't have value 9 and it can never be converted to target.
    -
    - -

    Example 5:

    - -
    -Input: target = [1,1,1,1,1], arr = [1,1,1,1,1]
    -Output: true
    +Explanation: arr does not have value 9 and it can never be converted to target.
     

     

    diff --git a/problems/making-file-names-unique/README.md b/problems/making-file-names-unique/README.md index dc950449f..0b8995d41 100644 --- a/problems/making-file-names-unique/README.md +++ b/problems/making-file-names-unique/README.md @@ -11,11 +11,11 @@ ## [1487. Making File Names Unique (Medium)](https://leetcode.com/problems/making-file-names-unique "保证文件名唯一") -

    Given an array of strings names of size n. You will create n folders in your file system such that, at the ith minute, you will create a folder with the name names[i].

    +

    Given an array of strings names of size n. You will create n folders in your file system such that, at the ith minute, you will create a folder with the name names[i].

    -

    Since two files cannot have the same name, if you enter a folder name which is previously used, the system will have a suffix addition to its name in the form of (k), where, k is the smallest positive integer such that the obtained name remains unique.

    +

    Since two files cannot have the same name, if you enter a folder name that was previously used, the system will have a suffix addition to its name in the form of (k), where, k is the smallest positive integer such that the obtained name remains unique.

    -

    Return an array of strings of length n where ans[i] is the actual name the system will assign to the ith folder when you create it.

    +

    Return an array of strings of length n where ans[i] is the actual name the system will assign to the ith folder when you create it.

     

    Example 1:

    @@ -50,29 +50,13 @@ Explanation: When the last folder is created, the smallest positive valid k is 4, and it becomes "onepiece(4)". -

    Example 4:

    - -
    -Input: names = ["wano","wano","wano","wano"]
    -Output: ["wano","wano(1)","wano(2)","wano(3)"]
    -Explanation: Just increase the value of k each time you create folder "wano".
    -
    - -

    Example 5:

    - -
    -Input: names = ["kaido","kaido(1)","kaido","kaido(1)"]
    -Output: ["kaido","kaido(1)","kaido(2)","kaido(1)(1)"]
    -Explanation: Please note that system adds the suffix (k) to current name even it contained the same suffix before.
    -
    -

     

    Constraints:

      -
    • 1 <= names.length <= 5 * 10^4
    • +
    • 1 <= names.length <= 5 * 104
    • 1 <= names[i].length <= 20
    • -
    • names[i] consists of lower case English letters, digits and/or round brackets.
    • +
    • names[i] consists of lowercase English letters, digits, and/or round brackets.
    ### Related Topics diff --git a/problems/map-sum-pairs/README.md b/problems/map-sum-pairs/README.md index 2332b6706..ffca94185 100644 --- a/problems/map-sum-pairs/README.md +++ b/problems/map-sum-pairs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../implement-magic-dictionary "Implement Magic Dictionary") @@ -55,7 +55,7 @@ mapSum.sum("ap"); // return 5 (apple + app = 3 ### Related Topics - [[Design](../../tag/design/README.md)] - [[Trie](../../tag/trie/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] + [[Trie](../../tag/trie/README.md)] diff --git a/problems/matrix-block-sum/README.md b/problems/matrix-block-sum/README.md index 91ae8977a..9fe7fe48f 100644 --- a/problems/matrix-block-sum/README.md +++ b/problems/matrix-block-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../decompress-run-length-encoded-list "Decompress Run-Length Encoded List") @@ -49,6 +49,9 @@ [[Matrix](../../tag/matrix/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] +### Similar Questions + 1. [Stamping the Grid](../stamping-the-grid) (Hard) + ### Hints
    Hint 1 diff --git a/problems/matrix-cells-in-distance-order/README.md b/problems/matrix-cells-in-distance-order/README.md index 3e26821f3..9fa55ff71 100644 --- a/problems/matrix-cells-in-distance-order/README.md +++ b/problems/matrix-cells-in-distance-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-city-scheduling "Two City Scheduling") @@ -54,8 +54,8 @@ There are other answers that would also be accepted as correct, such as [[1,2],[ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Matrix](../../tag/matrix/README.md)] + [[Geometry](../../tag/geometry/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Matrix](../../tag/matrix/README.md)] diff --git a/problems/matrix-diagonal-sum/README.md b/problems/matrix-diagonal-sum/README.md index f45ad0315..ea3934e05 100644 --- a/problems/matrix-diagonal-sum/README.md +++ b/problems/matrix-diagonal-sum/README.md @@ -57,6 +57,9 @@ Notice that element mat[1][1] = 5 is counted only once. [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Check if Every Row and Column Contains All Numbers](../check-if-every-row-and-column-contains-all-numbers) (Easy) + ### Hints
    Hint 1 diff --git a/problems/max-consecutive-ones-iii/README.md b/problems/max-consecutive-ones-iii/README.md index 543968e6c..2d8260401 100644 --- a/problems/max-consecutive-ones-iii/README.md +++ b/problems/max-consecutive-ones-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-word-is-valid-after-substitutions "Check If Word Is Valid After Substitutions") @@ -43,15 +43,14 @@ Bolded numbers were flipped from 0 to 1. The longest subarray is underlined. ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Similar Questions 1. [Longest Substring with At Most K Distinct Characters](../longest-substring-with-at-most-k-distinct-characters) (Medium) 1. [Longest Repeating Character Replacement](../longest-repeating-character-replacement) (Medium) 1. [Max Consecutive Ones](../max-consecutive-ones) (Easy) 1. [Max Consecutive Ones II](../max-consecutive-ones-ii) (Medium) - 1. [Maximize the Confusion of an Exam](../maximize-the-confusion-of-an-exam) (Medium) ### Hints
    diff --git a/problems/max-dot-product-of-two-subsequences/README.md b/problems/max-dot-product-of-two-subsequences/README.md index 7e4087e25..87cfbc3c3 100644 --- a/problems/max-dot-product-of-two-subsequences/README.md +++ b/problems/max-dot-product-of-two-subsequences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../pseudo-palindromic-paths-in-a-binary-tree "Pseudo-Palindromic Paths in a Binary Tree") diff --git a/problems/max-value-of-equation/README.md b/problems/max-value-of-equation/README.md index 485de6f96..4acc64f7b 100644 --- a/problems/max-value-of-equation/README.md +++ b/problems/max-value-of-equation/README.md @@ -48,11 +48,14 @@ No other pairs satisfy the condition, so we return the max of 4 and 1. ### Related Topics - [[Queue](../../tag/queue/README.md)] [[Array](../../tag/array/README.md)] + [[Queue](../../tag/queue/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] - [[Monotonic Queue](../../tag/monotonic-queue/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Monotonic Queue](../../tag/monotonic-queue/README.md)] + +### Similar Questions + 1. [Count Pairs in Two Arrays](../count-pairs-in-two-arrays) (Medium) ### Hints
    diff --git a/problems/maximal-rectangle/README.md b/problems/maximal-rectangle/README.md index 0a5485bb9..78ebdca14 100644 --- a/problems/maximal-rectangle/README.md +++ b/problems/maximal-rectangle/README.md @@ -24,46 +24,32 @@

    Example 2:

    -
    -Input: matrix = []
    -Output: 0
    -
    - -

    Example 3:

    -
     Input: matrix = [["0"]]
     Output: 0
     
    -

    Example 4:

    +

    Example 3:

     Input: matrix = [["1"]]
     Output: 1
     
    -

    Example 5:

    - -
    -Input: matrix = [["0","0"]]
    -Output: 0
    -
    -

     

    Constraints:

    • rows == matrix.length
    • cols == matrix[i].length
    • -
    • 0 <= row, cols <= 200
    • +
    • 1 <= row, cols <= 200
    • matrix[i][j] is '0' or '1'.
    ### Related Topics + [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Stack](../../tag/stack/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] diff --git a/problems/maximize-number-of-nice-divisors/README.md b/problems/maximize-number-of-nice-divisors/README.md index b325bd1cf..69b41c77f 100644 --- a/problems/maximize-number-of-nice-divisors/README.md +++ b/problems/maximize-number-of-nice-divisors/README.md @@ -48,8 +48,11 @@ There is not other value of n that has at most 5 prime factors and more nice div ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Math](../../tag/math/README.md)] + [[Recursion](../../tag/recursion/README.md)] + +### Similar Questions + 1. [Integer Break](../integer-break) (Medium) ### Hints
    diff --git a/problems/maximum-alternating-subarray-sum/README.md b/problems/maximum-alternating-subarray-sum/README.md index 0ae635e82..d761dc4d7 100644 --- a/problems/maximum-alternating-subarray-sum/README.md +++ b/problems/maximum-alternating-subarray-sum/README.md @@ -9,7 +9,7 @@                  [Next >](../minimum-number-of-moves-to-seat-everyone "Minimum Number of Moves to Seat Everyone") -## [2036. Maximum Alternating Subarray Sum (Medium)](https://leetcode.com/problems/maximum-alternating-subarray-sum "") +## [2036. Maximum Alternating Subarray Sum (Medium)](https://leetcode.com/problems/maximum-alternating-subarray-sum "最大交替子数组和") diff --git a/problems/maximum-alternating-subsequence-sum/README.md b/problems/maximum-alternating-subsequence-sum/README.md index 2265c28fd..340f9b788 100644 --- a/problems/maximum-alternating-subsequence-sum/README.md +++ b/problems/maximum-alternating-subsequence-sum/README.md @@ -61,6 +61,9 @@ [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Maximum Alternating Subarray Sum](../maximum-alternating-subarray-sum) (Medium) + ### Hints
    Hint 1 diff --git a/problems/maximum-and-sum-of-array/README.md b/problems/maximum-and-sum-of-array/README.md new file mode 100644 index 000000000..c3a632e65 --- /dev/null +++ b/problems/maximum-and-sum-of-array/README.md @@ -0,0 +1,69 @@ + + + + + + + +[< Previous](../removing-minimum-number-of-magic-beans "Removing Minimum Number of Magic Beans") +                 +[Next >](../longest-winning-streak "Longest Winning Streak") + +## [2172. Maximum AND Sum of Array (Hard)](https://leetcode.com/problems/maximum-and-sum-of-array "数组的最大与和") + +

    You are given an integer array nums of length n and an integer numSlots such that 2 * numSlots >= n. There are numSlots slots numbered from 1 to numSlots.

    + +

    You have to place all n integers into the slots such that each slot contains at most two numbers. The AND sum of a given placement is the sum of the bitwise AND of every number with its respective slot number.

    + +
      +
    • For example, the AND sum of placing the numbers [1, 3] into slot 1 and [4, 6] into slot 2 is equal to (1 AND 1) + (3 AND 1) + (4 AND 2) + (6 AND 2) = 1 + 1 + 0 + 2 = 4.
    • +
    + +

    Return the maximum possible AND sum of nums given numSlots slots.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3,4,5,6], numSlots = 3
    +Output: 9
    +Explanation: One possible placement is [1, 4] into slot 1, [2, 6] into slot 2, and [3, 5] into slot 3. 
    +This gives the maximum AND sum of (1 AND 1) + (4 AND 1) + (2 AND 2) + (6 AND 2) + (3 AND 3) + (5 AND 3) = 1 + 0 + 2 + 2 + 3 + 1 = 9.
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,3,10,4,7,1], numSlots = 9
    +Output: 24
    +Explanation: One possible placement is [1, 1] into slot 1, [3] into slot 3, [4] into slot 4, [7] into slot 7, and [10] into slot 9.
    +This gives the maximum AND sum of (1 AND 1) + (1 AND 1) + (3 AND 3) + (4 AND 4) + (7 AND 7) + (10 AND 9) = 1 + 1 + 3 + 4 + 7 + 8 = 24.
    +Note that slots 2, 5, 6, and 8 are empty which is permitted.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == nums.length
    • +
    • 1 <= numSlots <= 9
    • +
    • 1 <= n <= 2 * numSlots
    • +
    • 1 <= nums[i] <= 15
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] + +### Hints +
    +Hint 1 +Can you think of a dynamic programming solution to this problem? +
    + +
    +Hint 2 +Can you use a bitmask to represent the state of the slots? +
    diff --git a/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md b/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md index c1efb356e..43b1a9eeb 100644 --- a/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md +++ b/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-product-of-two-elements-in-an-array "Maximum Product of Two Elements in an Array") @@ -58,8 +58,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/maximum-ascending-subarray-sum/README.md b/problems/maximum-ascending-subarray-sum/README.md index 33dd72404..349c6752a 100644 --- a/problems/maximum-ascending-subarray-sum/README.md +++ b/problems/maximum-ascending-subarray-sum/README.md @@ -42,13 +42,6 @@ Explanation: [10,11,12] is the ascending subarray with the maximum sum of 33. -

    Example 4:

    - -
    -Input: nums = [100,10,1]
    -Output: 100
    -
    -

     

    Constraints:

    @@ -60,6 +53,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] +### Similar Questions + 1. [Find Good Days to Rob the Bank](../find-good-days-to-rob-the-bank) (Medium) + ### Hints
    Hint 1 diff --git a/problems/maximum-binary-string-after-change/README.md b/problems/maximum-binary-string-after-change/README.md index 07af7eb1a..8f105f46c 100644 --- a/problems/maximum-binary-string-after-change/README.md +++ b/problems/maximum-binary-string-after-change/README.md @@ -59,8 +59,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/maximum-candies-you-can-get-from-boxes/README.md b/problems/maximum-candies-you-can-get-from-boxes/README.md index 7977327ee..d714a6c5d 100644 --- a/problems/maximum-candies-you-can-get-from-boxes/README.md +++ b/problems/maximum-candies-you-can-get-from-boxes/README.md @@ -11,18 +11,18 @@ ## [1298. Maximum Candies You Can Get from Boxes (Hard)](https://leetcode.com/problems/maximum-candies-you-can-get-from-boxes "你能从盒子里获得的最大糖果数") -

    Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:

    +

    You have n boxes labeled from 0 to n - 1. You are given four arrays: status, candies, keys, and containedBoxes where:

      -
    • status[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.
    • -
    • candies[i]: an integer representing the number of candies in box[i].
    • -
    • keys[i]: an array contains the indices of the boxes you can open with the key in box[i].
    • -
    • containedBoxes[i]: an array contains the indices of the boxes found in box[i].
    • +
    • status[i] is 1 if the ith box is open and 0 if the ith box is closed,
    • +
    • candies[i] is the number of candies in the ith box,
    • +
    • keys[i] is a list of the labels of the boxes you can open after opening the ith box.
    • +
    • containedBoxes[i] is a list of the boxes you found inside the ith box.
    -

    You will start with some boxes given in initialBoxes array. You can take all the candies in any open box and you can use the keys in it to open new boxes and you also can use the boxes you find in it.

    +

    You are given an integer array initialBoxes that contains the labels of the boxes you initially have. You can take all the candies in any open box and you can use the keys in it to open new boxes and you also can use the boxes you find in it.

    -

    Return the maximum number of candies you can get following the rules above.

    +

    Return the maximum number of candies you can get following the rules above.

     

    Example 1:

    @@ -30,7 +30,8 @@
     Input: status = [1,0,1,0], candies = [7,5,4,100], keys = [[],[],[1],[]], containedBoxes = [[1,2],[3],[],[]], initialBoxes = [0]
     Output: 16
    -Explanation: You will be initially given box 0. You will find 7 candies in it and boxes 1 and 2. Box 1 is closed and you don't have a key for it so you will open box 2. You will find 4 candies and a key to box 1 in box 2.
    +Explanation: You will be initially given box 0. You will find 7 candies in it and boxes 1 and 2.
    +Box 1 is closed and you do not have a key for it so you will open box 2. You will find 4 candies and a key to box 1 in box 2.
     In box 1, you will find 5 candies and box 3 but you will not find a key to box 3 so box 3 will remain closed.
     Total number of candies collected = 7 + 4 + 5 = 16 candy.
     
    @@ -40,52 +41,32 @@ Total number of candies collected = 7 + 4 + 5 = 16 candy.
     Input: status = [1,0,0,0,0,0], candies = [1,1,1,1,1,1], keys = [[1,2,3,4,5],[],[],[],[],[]], containedBoxes = [[1,2,3,4,5],[],[],[],[],[]], initialBoxes = [0]
     Output: 6
    -Explanation: You have initially box 0. Opening it you can find boxes 1,2,3,4 and 5 and their keys. The total number of candies will be 6.
    -
    - -

    Example 3:

    - -
    -Input: status = [1,1,1], candies = [100,1,100], keys = [[],[0,2],[]], containedBoxes = [[],[],[]], initialBoxes = [1]
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: status = [1], candies = [100], keys = [[]], containedBoxes = [[]], initialBoxes = []
    -Output: 0
    -
    - -

    Example 5:

    - -
    -Input: status = [1,1,1], candies = [2,3,2], keys = [[],[],[]], containedBoxes = [[],[],[]], initialBoxes = [2,1,0]
    -Output: 7
    +Explanation: You have initially box 0. Opening it you can find boxes 1,2,3,4 and 5 and their keys.
    +The total number of candies will be 6.
     

     

    Constraints:

      -
    • 1 <= status.length <= 1000
    • -
    • status.length == candies.length == keys.length == containedBoxes.length == n
    • -
    • status[i] is 0 or 1.
    • +
    • n == status.length == candies.length == keys.length == containedBoxes.length
    • +
    • 1 <= n <= 1000
    • +
    • status[i] is either 0 or 1.
    • 1 <= candies[i] <= 1000
    • -
    • 0 <= keys[i].length <= status.length
    • -
    • 0 <= keys[i][j] < status.length
    • -
    • All values in keys[i] are unique.
    • -
    • 0 <= containedBoxes[i].length <= status.length
    • -
    • 0 <= containedBoxes[i][j] < status.length
    • -
    • All values in containedBoxes[i] are unique.
    • +
    • 0 <= keys[i].length <= n
    • +
    • 0 <= keys[i][j] < n
    • +
    • All values of keys[i] are unique.
    • +
    • 0 <= containedBoxes[i].length <= n
    • +
    • 0 <= containedBoxes[i][j] < n
    • +
    • All values of containedBoxes[i] are unique.
    • Each box is contained in one box at most.
    • -
    • 0 <= initialBoxes.length <= status.length
    • -
    • 0 <= initialBoxes[i] < status.length
    • +
    • 0 <= initialBoxes.length <= n
    • +
    • 0 <= initialBoxes[i] < n
    ### Related Topics - [[Array](../../tag/array/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Array](../../tag/array/README.md)] ### Hints
    diff --git a/problems/maximum-difference-between-node-and-ancestor/README.md b/problems/maximum-difference-between-node-and-ancestor/README.md index 0b9b3cbd1..d8ad9af3b 100644 --- a/problems/maximum-difference-between-node-and-ancestor/README.md +++ b/problems/maximum-difference-between-node-and-ancestor/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../divisor-game "Divisor Game") diff --git a/problems/maximum-distance-between-a-pair-of-values/README.md b/problems/maximum-distance-between-a-pair-of-values/README.md index 6303a4c38..e88895f23 100644 --- a/problems/maximum-distance-between-a-pair-of-values/README.md +++ b/problems/maximum-distance-between-a-pair-of-values/README.md @@ -47,14 +47,6 @@ The maximum distance is 1 with pair (0,1). The maximum distance is 2 with pair (2,4). -

    Example 4:

    - -
    -Input: nums1 = [5,4], nums2 = [3,2]
    -Output: 0
    -Explanation: There are no valid pairs, so return 0.
    -
    -

     

    Constraints:

    diff --git a/problems/maximum-distance-in-arrays/README.md b/problems/maximum-distance-in-arrays/README.md index b9bcdb2a2..4190a9404 100644 --- a/problems/maximum-distance-in-arrays/README.md +++ b/problems/maximum-distance-in-arrays/README.md @@ -35,5 +35,5 @@ One way to reach the maximum distance 4 is to pick 1 in the first or third array

    ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] diff --git a/problems/maximum-element-after-decreasing-and-rearranging/README.md b/problems/maximum-element-after-decreasing-and-rearranging/README.md index 2ec14e72a..b3c3ef248 100644 --- a/problems/maximum-element-after-decreasing-and-rearranging/README.md +++ b/problems/maximum-element-after-decreasing-and-rearranging/README.md @@ -69,8 +69,8 @@ The largest element in arr is 3. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/maximum-employees-to-be-invited-to-a-meeting/README.md b/problems/maximum-employees-to-be-invited-to-a-meeting/README.md new file mode 100644 index 000000000..b593c81e1 --- /dev/null +++ b/problems/maximum-employees-to-be-invited-to-a-meeting/README.md @@ -0,0 +1,88 @@ + + + + + + + +[< Previous](../destroying-asteroids "Destroying Asteroids") +                 +[Next >](../remove-all-ones-with-row-and-column-flips "Remove All Ones With Row and Column Flips") + +## [2127. Maximum Employees to Be Invited to a Meeting (Hard)](https://leetcode.com/problems/maximum-employees-to-be-invited-to-a-meeting "参加会议的最多员工数") + +

    A company is organizing a meeting and has a list of n employees, waiting to be invited. They have arranged for a large circular table, capable of seating any number of employees.

    + +

    The employees are numbered from 0 to n - 1. Each employee has a favorite person and they will attend the meeting only if they can sit next to their favorite person at the table. The favorite person of an employee is not themself.

    + +

    Given a 0-indexed integer array favorite, where favorite[i] denotes the favorite person of the ith employee, return the maximum number of employees that can be invited to the meeting.

    + +

     

    +

    Example 1:

    + +
    +Input: favorite = [2,2,1,2]
    +Output: 3
    +Explanation:
    +The above figure shows how the company can invite employees 0, 1, and 2, and seat them at the round table.
    +All employees cannot be invited because employee 2 cannot sit beside employees 0, 1, and 3, simultaneously.
    +Note that the company can also invite employees 1, 2, and 3, and give them their desired seats.
    +The maximum number of employees that can be invited to the meeting is 3. 
    +
    + +

    Example 2:

    + +
    +Input: favorite = [1,2,0]
    +Output: 3
    +Explanation: 
    +Each employee is the favorite person of at least one other employee, and the only way the company can invite them is if they invite every employee.
    +The seating arrangement will be the same as that in the figure given in example 1:
    +- Employee 0 will sit between employees 2 and 1.
    +- Employee 1 will sit between employees 0 and 2.
    +- Employee 2 will sit between employees 1 and 0.
    +The maximum number of employees that can be invited to the meeting is 3.
    +
    + +

    Example 3:

    + +
    +Input: favorite = [3,0,1,4,1]
    +Output: 4
    +Explanation:
    +The above figure shows how the company will invite employees 0, 1, 3, and 4, and seat them at the round table.
    +Employee 2 cannot be invited because the two spots next to their favorite employee 1 are taken.
    +So the company leaves them out of the meeting.
    +The maximum number of employees that can be invited to the meeting is 4.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == favorite.length
    • +
    • 2 <= n <= 105
    • +
    • 0 <= favorite[i] <= n - 1
    • +
    • favorite[i] != i
    • +
    + +### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Topological Sort](../../tag/topological-sort/README.md)] + +### Hints +
    +Hint 1 +From the given array favorite, create a graph where for every index i, there is a directed edge from favorite[i] to i. The graph will be a combination of cycles and chains of acyclic edges. Now, what are the ways in which we can choose employees to sit at the table? +
    + +
    +Hint 2 +The first way by which we can choose employees is by selecting a cycle of the graph. It can be proven that in this case, the employees that do not lie in the cycle can never be seated at the table. +
    + +
    +Hint 3 +The second way is by combining acyclic chains. At most two chains can be combined by a cycle of length 2, where each chain ends on one of the employees in the cycle. +
    diff --git a/problems/maximum-fruits-harvested-after-at-most-k-steps/README.md b/problems/maximum-fruits-harvested-after-at-most-k-steps/README.md new file mode 100644 index 000000000..997d2537c --- /dev/null +++ b/problems/maximum-fruits-harvested-after-at-most-k-steps/README.md @@ -0,0 +1,99 @@ + + + + + + + +[< Previous](../watering-plants-ii "Watering Plants II") +                 +[Next >](../number-of-unique-flavors-after-sharing-k-candies "Number of Unique Flavors After Sharing K Candies") + +## [2106. Maximum Fruits Harvested After at Most K Steps (Hard)](https://leetcode.com/problems/maximum-fruits-harvested-after-at-most-k-steps "摘水果") + +

    Fruits are available at some positions on an infinite x-axis. You are given a 2D integer array fruits where fruits[i] = [positioni, amounti] depicts amounti fruits at the position positioni. fruits is already sorted by positioni in ascending order, and each positioni is unique.

    + +

    You are also given an integer startPos and an integer k. Initially, you are at the position startPos. From any position, you can either walk to the left or right. It takes one step to move one unit on the x-axis, and you can walk at most k steps in total. For every position you reach, you harvest all the fruits at that position, and the fruits will disappear from that position.

    + +

    Return the maximum total number of fruits you can harvest.

    + +

     

    +

    Example 1:

    + +
    +Input: fruits = [[2,8],[6,3],[8,6]], startPos = 5, k = 4
    +Output: 9
    +Explanation: 
    +The optimal way is to:
    +- Move right to position 6 and harvest 3 fruits
    +- Move right to position 8 and harvest 6 fruits
    +You moved 3 steps and harvested 3 + 6 = 9 fruits in total.
    +
    + +

    Example 2:

    + +
    +Input: fruits = [[0,9],[4,1],[5,7],[6,2],[7,4],[10,9]], startPos = 5, k = 4
    +Output: 14
    +Explanation: 
    +You can move at most k = 4 steps, so you cannot reach position 0 nor 10.
    +The optimal way is to:
    +- Harvest the 7 fruits at the starting position 5
    +- Move left to position 4 and harvest 1 fruit
    +- Move right to position 6 and harvest 2 fruits
    +- Move right to position 7 and harvest 4 fruits
    +You moved 1 + 3 = 4 steps and harvested 7 + 1 + 2 + 4 = 14 fruits in total.
    +
    + +

    Example 3:

    + +
    +Input: fruits = [[0,3],[6,4],[8,5]], startPos = 3, k = 2
    +Output: 0
    +Explanation:
    +You can move at most k = 2 steps and cannot reach any position with fruits.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= fruits.length <= 105
    • +
    • fruits[i].length == 2
    • +
    • 0 <= startPos, positioni <= 2 * 105
    • +
    • positioni-1 < positioni for any i > 0 (0-indexed)
    • +
    • 1 <= amounti <= 104
    • +
    • 0 <= k <= 2 * 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
    +Hint 1 +Does an optimal path have very few patterns? For example, could a path that goes left, turns and goes right, then turns again and goes left be any better than a path that simply goes left, turns, and goes right? +
    + +
    +Hint 2 +The optimal path turns at most once. That is, the optimal path is one of these: to go left only; to go right only; to go left, turn and go right; or to go right, turn and go left. +
    + +
    +Hint 3 +Moving x steps left then k-x steps right gives you a range of positions that you can reach. +
    + +
    +Hint 4 +Use prefix sums to get the sum of all fruits for each possible range. +
    + +
    +Hint 5 +Use a similar strategy for all the paths that go right, then turn and go left. +
    diff --git a/problems/maximum-genetic-difference-query/README.md b/problems/maximum-genetic-difference-query/README.md index dbd84060c..1b13b9038 100644 --- a/problems/maximum-genetic-difference-query/README.md +++ b/problems/maximum-genetic-difference-query/README.md @@ -52,6 +52,14 @@
  • 0 <= vali <= 2 * 105
  • +### Related Topics + [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Trie](../../tag/trie/README.md)] + +### Similar Questions + 1. [Maximum XOR With an Element From Array](../maximum-xor-with-an-element-from-array) (Hard) + ### Hints
    Hint 1 diff --git a/problems/maximum-good-people-based-on-statements/README.md b/problems/maximum-good-people-based-on-statements/README.md new file mode 100644 index 000000000..9b0cf9661 --- /dev/null +++ b/problems/maximum-good-people-based-on-statements/README.md @@ -0,0 +1,114 @@ + + + + + + + +[< Previous](../find-all-lonely-numbers-in-the-array "Find All Lonely Numbers in the Array") +                 +[Next >](../minimum-number-of-lines-to-cover-points "Minimum Number of Lines to Cover Points") + +## [2151. Maximum Good People Based on Statements (Hard)](https://leetcode.com/problems/maximum-good-people-based-on-statements "基于陈述统计最多好人数") + +

    There are two types of persons:

    + +
      +
    • The good person: The person who always tells the truth.
    • +
    • The bad person: The person who might tell the truth and might lie.
    • +
    + +

    You are given a 0-indexed 2D integer array statements of size n x n that represents the statements made by n people about each other. More specifically, statements[i][j] could be one of the following:

    + +
      +
    • 0 which represents a statement made by person i that person j is a bad person.
    • +
    • 1 which represents a statement made by person i that person j is a good person.
    • +
    • 2 represents that no statement is made by person i about person j.
    • +
    + +

    Additionally, no person ever makes a statement about themselves. Formally, we have that statements[i][i] = 2 for all 0 <= i < n.

    + +

    Return the maximum number of people who can be good based on the statements made by the n people.

    + +

     

    +

    Example 1:

    + +
    +Input: statements = [[2,1,2],[1,2,2],[2,0,2]]
    +Output: 2
    +Explanation: Each person makes a single statement.
    +- Person 0 states that person 1 is good.
    +- Person 1 states that person 0 is good.
    +- Person 2 states that person 1 is bad.
    +Let's take person 2 as the key.
    +- Assuming that person 2 is a good person:
    +    - Based on the statement made by person 2, person 1 is a bad person.
    +    - Now we know for sure that person 1 is bad and person 2 is good.
    +    - Based on the statement made by person 1, and since person 1 is bad, they could be:
    +        - telling the truth. There will be a contradiction in this case and this assumption is invalid.
    +        - lying. In this case, person 0 is also a bad person and lied in their statement.
    +    - Following that person 2 is a good person, there will be only one good person in the group.
    +- Assuming that person 2 is a bad person:
    +    - Based on the statement made by person 2, and since person 2 is bad, they could be:
    +        - telling the truth. Following this scenario, person 0 and 1 are both bad as explained before.
    +            - Following that person 2 is bad but told the truth, there will be no good persons in the group.
    +        - lying. In this case person 1 is a good person.
    +            - Since person 1 is a good person, person 0 is also a good person.
    +            - Following that person 2 is bad and lied, there will be two good persons in the group.
    +We can see that at most 2 persons are good in the best case, so we return 2.
    +Note that there is more than one way to arrive at this conclusion.
    +
    + +

    Example 2:

    + +
    +Input: statements = [[2,0],[0,2]]
    +Output: 1
    +Explanation: Each person makes a single statement.
    +- Person 0 states that person 1 is bad.
    +- Person 1 states that person 0 is bad.
    +Let's take person 0 as the key.
    +- Assuming that person 0 is a good person:
    +    - Based on the statement made by person 0, person 1 is a bad person and was lying.
    +    - Following that person 0 is a good person, there will be only one good person in the group.
    +- Assuming that person 0 is a bad person:
    +    - Based on the statement made by person 0, and since person 0 is bad, they could be:
    +        - telling the truth. Following this scenario, person 0 and 1 are both bad.
    +            - Following that person 0 is bad but told the truth, there will be no good persons in the group.
    +        - lying. In this case person 1 is a good person.
    +            - Following that person 0 is bad and lied, there will be only one good person in the group.
    +We can see that at most, one person is good in the best case, so we return 1.
    +Note that there is more than one way to arrive at this conclusion.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == statements.length == statements[i].length
    • +
    • 2 <= n <= 15
    • +
    • statements[i][j] is either 0, 1, or 2.
    • +
    • statements[i][i] == 2
    • +
    + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + +### Hints +
    +Hint 1 +You should test every possible assignment of good and bad people, using a bitmask. +
    + +
    +Hint 2 +In each bitmask, if the person i is good, then his statements should be consistent with the bitmask in order for the assignment to be valid. +
    + +
    +Hint 3 +If the assignment is valid, count how many people are good and keep track of the maximum. +
    diff --git a/problems/maximum-ice-cream-bars/README.md b/problems/maximum-ice-cream-bars/README.md index 5fbc91a10..5b90aaafb 100644 --- a/problems/maximum-ice-cream-bars/README.md +++ b/problems/maximum-ice-cream-bars/README.md @@ -55,8 +55,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md b/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md index 7dd80565b..cc15cde53 100644 --- a/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md +++ b/problems/maximum-length-of-a-concatenated-string-with-unique-characters/README.md @@ -49,14 +49,6 @@ Maximum length is 4. Explanation: The only string in arr has all 26 characters. -

    Example 4:

    - -
    -Input: arr = ["aa","bb"]
    -Output: 0
    -Explanation: Both strings in arr do not have unique characters, thus there are no valid concatenations.
    -
    -

     

    Constraints:

    diff --git a/problems/maximum-length-of-subarray-with-positive-product/README.md b/problems/maximum-length-of-subarray-with-positive-product/README.md index 09559fc46..d1b1c444c 100644 --- a/problems/maximum-length-of-subarray-with-positive-product/README.md +++ b/problems/maximum-length-of-subarray-with-positive-product/README.md @@ -11,11 +11,11 @@ ## [1567. Maximum Length of Subarray With Positive Product (Medium)](https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product "乘积为正数的最长子数组长度") -

    Given an array of integers nums, find the maximum length of a subarray where the product of all its elements is positive.

    +

    Given an array of integers nums, find the maximum length of a subarray where the product of all its elements is positive.

    A subarray of an array is a consecutive sequence of zero or more values taken out of that array.

    -

    Return the maximum length of a subarray with positive product.

    +

    Return the maximum length of a subarray with positive product.

     

    Example 1:

    @@ -23,7 +23,7 @@
     Input: nums = [1,-2,-3,4]
     Output: 4
    -Explanation: The array nums already has a positive product of 24.
    +Explanation: The array nums already has a positive product of 24.
     

    Example 2:

    @@ -31,7 +31,7 @@
     Input: nums = [0,1,-2,-3,-4]
     Output: 3
    -Explanation: The longest subarray with positive product is [1,-2,-3] which has a product of 6.
    +Explanation: The longest subarray with positive product is [1,-2,-3] which has a product of 6.
     Notice that we cannot include 0 in the subarray since that'll make the product 0 which is not positive.

    Example 3:

    @@ -39,35 +39,21 @@ Notice that we cannot include 0 in the subarray since that'll make the produ
     Input: nums = [-1,-2,-3,0,1]
     Output: 2
    -Explanation: The longest subarray with positive product is [-1,-2] or [-2,-3].
    -
    - -

    Example 4:

    - -
    -Input: nums = [-1,2]
    -Output: 1
    -
    - -

    Example 5:

    - -
    -Input: nums = [1,2,3,5,-6,4,0,10]
    -Output: 4
    +Explanation: The longest subarray with positive product is [-1,-2] or [-2,-3].
     

     

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • -10^9 <= nums[i] <= 10^9
    • +
    • 1 <= nums.length <= 105
    • +
    • -109 <= nums[i] <= 109
    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/maximum-nesting-depth-of-the-parentheses/README.md b/problems/maximum-nesting-depth-of-the-parentheses/README.md index b4df75520..93c9ebc78 100644 --- a/problems/maximum-nesting-depth-of-the-parentheses/README.md +++ b/problems/maximum-nesting-depth-of-the-parentheses/README.md @@ -48,20 +48,6 @@ Output: 3 -

    Example 3:

    - -
    -Input: s = "1+(2*3)/(2-1)"
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: s = "1"
    -Output: 0
    -
    -

     

    Constraints:

    @@ -72,8 +58,11 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[String](../../tag/string/README.md)] + [[Stack](../../tag/stack/README.md)] + +### Similar Questions + 1. [Maximum Nesting Depth of Two Valid Parentheses Strings](../maximum-nesting-depth-of-two-valid-parentheses-strings) (Medium) ### Hints
    diff --git a/problems/maximum-non-negative-product-in-a-matrix/README.md b/problems/maximum-non-negative-product-in-a-matrix/README.md index 0b1c73b57..061a705d5 100644 --- a/problems/maximum-non-negative-product-in-a-matrix/README.md +++ b/problems/maximum-non-negative-product-in-a-matrix/README.md @@ -11,59 +11,46 @@ ## [1594. Maximum Non Negative Product in a Matrix (Medium)](https://leetcode.com/problems/maximum-non-negative-product-in-a-matrix "矩阵的最大非负积") -

    You are given a rows x cols matrix grid. Initially, you are located at the top-left corner (0, 0), and in each step, you can only move right or down in the matrix.

    +

    You are given a m x n matrix grid. Initially, you are located at the top-left corner (0, 0), and in each step, you can only move right or down in the matrix.

    -

    Among all possible paths starting from the top-left corner (0, 0) and ending in the bottom-right corner (rows - 1, cols - 1), find the path with the maximum non-negative product. The product of a path is the product of all integers in the grid cells visited along the path.

    +

    Among all possible paths starting from the top-left corner (0, 0) and ending in the bottom-right corner (m - 1, n - 1), find the path with the maximum non-negative product. The product of a path is the product of all integers in the grid cells visited along the path.

    -

    Return the maximum non-negative product modulo 109 + 7If the maximum product is negative return -1.

    +

    Return the maximum non-negative product modulo 109 + 7. If the maximum product is negative, return -1.

    -

    Notice that the modulo is performed after getting the maximum product.

    +

    Notice that the modulo is performed after getting the maximum product.

     

    Example 1:

    - +
    -Input: grid = [[-1,-2,-3],
    -               [-2,-3,-3],
    -               [-3,-3,-2]]
    +Input: grid = [[-1,-2,-3],[-2,-3,-3],[-3,-3,-2]]
     Output: -1
    -Explanation: It's not possible to get non-negative product in the path from (0, 0) to (2, 2), so return -1.
    +Explanation: It is not possible to get non-negative product in the path from (0, 0) to (2, 2), so return -1.
     

    Example 2:

    - +
    -Input: grid = [[1,-2,1],
    -               [1,-2,1],
    -               [3,-4,1]]
    +Input: grid = [[1,-2,1],[1,-2,1],[3,-4,1]]
     Output: 8
    -Explanation: Maximum non-negative product is in bold (1 * 1 * -2 * -4 * 1 = 8).
    +Explanation: Maximum non-negative product is shown (1 * 1 * -2 * -4 * 1 = 8).
     

    Example 3:

    - +
    -Input: grid = [[1, 3],
    -               [0,-4]]
    +Input: grid = [[1,3],[0,-4]]
     Output: 0
    -Explanation: Maximum non-negative product is in bold (1 * 0 * -4 = 0).
    -
    - -

    Example 4:

    - -
    -Input: grid = [[ 1, 4,4,0],
    -               [-2, 0,0,1],
    -               [ 1,-1,1,1]]
    -Output: 2
    -Explanation: Maximum non-negative product is in bold (1 * -2 * 1 * -1 * 1 * 1 = 2).
    +Explanation: Maximum non-negative product is shown (1 * 0 * -4 = 0).
     

     

    Constraints:

      -
    • 1 <= rows, cols <= 15
    • +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 15
    • -4 <= grid[i][j] <= 4
    diff --git a/problems/maximum-number-of-achievable-transfer-requests/README.md b/problems/maximum-number-of-achievable-transfer-requests/README.md index 144c6a30e..8c9be33c7 100644 --- a/problems/maximum-number-of-achievable-transfer-requests/README.md +++ b/problems/maximum-number-of-achievable-transfer-requests/README.md @@ -64,6 +64,8 @@ We can achieve all the requests. ### Related Topics + [[Array](../../tag/array/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Enumeration](../../tag/enumeration/README.md)] diff --git a/problems/maximum-number-of-consecutive-values-you-can-make/README.md b/problems/maximum-number-of-consecutive-values-you-can-make/README.md index 7fdf0d08f..b0826514c 100644 --- a/problems/maximum-number-of-consecutive-values-you-can-make/README.md +++ b/problems/maximum-number-of-consecutive-values-you-can-make/README.md @@ -60,16 +60,24 @@ You can make 8 consecutive integer values starting from 0. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Similar Questions + 1. [Patching Array](../patching-array) (Hard) ### Hints
    Hint 1 -Let's note that if you can make the first x values then you can and you have a value v≤x+1 then you can make all values ≤v+x +If you can make the first x values and you have a value v, then you can make all the values ≤ v + x
    Hint 2 -The smaller v is the smaller the x you need so it's optimal to process elements in a sorted order +Sort the array of coins. You can always make the value 0 so you can start with x = 0. +
    + +
    +Hint 3 +Process the values starting from the smallest and stop when there is a value that cannot be achieved with the current x.
    diff --git a/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md b/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md index 03a0c1879..7767a3d0e 100644 --- a/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md +++ b/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/README.md @@ -11,52 +11,36 @@ ## [1453. Maximum Number of Darts Inside of a Circular Dartboard (Hard)](https://leetcode.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard "圆形靶内的最大飞镖数量") -

    You have a very large square wall and a circular dartboard placed on the wall. You have been challenged to throw darts into the board blindfolded. Darts thrown at the wall are represented as an array of points on a 2D plane. 

    +

    Alice is throwing n darts on a very large wall. You are given an array darts where darts[i] = [xi, yi] is the position of the ith dart that Alice threw on the wall.

    -

    Return the maximum number of points that are within or lie on any circular dartboard of radius r.

    +

    Bob knows the positions of the n darts on the wall. He wants to place a dartboard of radius r on the wall so that the maximum number of darts that Alice throws lies on the dartboard.

    + +

    Given the integer r, return the maximum number of darts that can lie on the dartboard.

     

    Example 1:

    - -

    - +
    -Input: points = [[-2,0],[2,0],[0,2],[0,-2]], r = 2
    +Input: darts = [[-2,0],[2,0],[0,2],[0,-2]], r = 2
     Output: 4
     Explanation: Circle dartboard with center in (0,0) and radius = 2 contain all points.
     

    Example 2:

    - -

    - +
    -Input: points = [[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]], r = 5
    +Input: darts = [[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]], r = 5
     Output: 5
     Explanation: Circle dartboard with center in (0,4) and radius = 5 contain all points except the point (7,8).
     
    -

    Example 3:

    - -
    -Input: points = [[-2,0],[2,0],[0,2],[0,-2]], r = 1
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: points = [[1,2],[3,5],[1,-1],[2,3],[4,1],[1,3]], r = 2
    -Output: 4
    -
    -

     

    Constraints:

      -
    • 1 <= points.length <= 100
    • -
    • points[i].length == 2
    • -
    • -10^4 <= points[i][0], points[i][1] <= 10^4
    • +
    • 1 <= darts.length <= 100
    • +
    • darts[i].length == 2
    • +
    • -104 <= xi, yi <= 104
    • 1 <= r <= 5000
    diff --git a/problems/maximum-number-of-eaten-apples/README.md b/problems/maximum-number-of-eaten-apples/README.md index 2e29bdaa3..4d83aebe7 100644 --- a/problems/maximum-number-of-eaten-apples/README.md +++ b/problems/maximum-number-of-eaten-apples/README.md @@ -45,16 +45,15 @@

    Constraints:

      -
    • apples.length == n
    • -
    • days.length == n
    • +
    • n == apples.length == days.length
    • 1 <= n <= 2 * 104
    • 0 <= apples[i], days[i] <= 2 * 104
    • days[i] = 0 if and only if apples[i] = 0.
    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/maximum-number-of-events-that-can-be-attended/README.md b/problems/maximum-number-of-events-that-can-be-attended/README.md index 4559f8e33..1db35bebc 100644 --- a/problems/maximum-number-of-events-that-can-be-attended/README.md +++ b/problems/maximum-number-of-events-that-can-be-attended/README.md @@ -11,15 +11,15 @@ ## [1353. Maximum Number of Events That Can Be Attended (Medium)](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended "最多可以参加的会议数目") -

    Given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi.

    +

    You are given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi.

    -

    You can attend an event i at any day d where startTimei <= d <= endTimei. Notice that you can only attend one event at any time d.

    +

    You can attend an event i at any day d where startTimei <= d <= endTimei. You can only attend one event at any time d.

    -

    Return the maximum number of events you can attend.

    +

    Return the maximum number of events you can attend.

     

    Example 1:

    - +
     Input: events = [[1,2],[2,3],[3,4]]
     Output: 3
    @@ -37,27 +37,6 @@ Attend the third event on day 3.
     Output: 4
     
    -

    Example 3:

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

    Example 4:

    - -
    -Input: events = [[1,100000]]
    -Output: 1
    -
    - -

    Example 5:

    - -
    -Input: events = [[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7]]
    -Output: 7
    -
    -

     

    Constraints:

    @@ -68,14 +47,10 @@ Attend the third event on day 3. ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] -### Similar Questions - 1. [Maximum Number of Events That Can Be Attended II](../maximum-number-of-events-that-can-be-attended-ii) (Hard) - 1. [Maximum Earnings From Taxi](../maximum-earnings-from-taxi) (Medium) - ### Hints
    Hint 1 diff --git a/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md b/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md index 6f963ba4b..e7e645d7d 100644 --- a/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md +++ b/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/README.md @@ -11,9 +11,7 @@ ## [1546. Maximum Number of Non-Overlapping Subarrays With Sum Equals Target (Medium)](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值且不重叠的非空子数组的最大数目") -

    Given an array nums and an integer target.

    - -

    Return the maximum number of non-empty non-overlapping subarrays such that the sum of values in each subarray is equal to target.

    +

    Given an array nums and an integer target, return the maximum number of non-empty non-overlapping subarrays such that the sum of values in each subarray is equal to target.

     

    Example 1:

    @@ -21,7 +19,7 @@
     Input: nums = [1,1,1,1,1], target = 2
     Output: 2
    -Explanation: There are 2 non-overlapping subarrays [1,1,1,1,1] with sum equals to target(2).
    +Explanation: There are 2 non-overlapping subarrays [1,1,1,1,1] with sum equals to target(2).
     

    Example 2:

    @@ -29,36 +27,23 @@
     Input: nums = [-1,3,5,1,4,2,-9], target = 6
     Output: 2
    -Explanation: There are 3 subarrays with sum equal to 6.
    -([5,1], [4,2], [3,5,1,4,2,-9]) but only the first 2 are non-overlapping.
    - -

    Example 3:

    - -
    -Input: nums = [-2,6,6,3,5,4,1,2,8], target = 10
    -Output: 3
    -
    - -

    Example 4:

    - -
    -Input: nums = [0,0,0], target = 0
    -Output: 3
    +Explanation: There are 3 subarrays with sum equal to 6.
    +([5,1], [4,2], [3,5,1,4,2,-9]) but only the first 2 are non-overlapping.
     

     

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • -10^4 <= nums[i] <= 10^4
    • -
    • 0 <= target <= 10^6
    • +
    • 1 <= nums.length <= 105
    • +
    • -104 <= nums[i] <= 104
    • +
    • 0 <= target <= 106
    ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Greedy](../../tag/greedy/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints diff --git a/problems/maximum-number-of-non-overlapping-substrings/README.md b/problems/maximum-number-of-non-overlapping-substrings/README.md index 4c57eba84..2fb424741 100644 --- a/problems/maximum-number-of-non-overlapping-substrings/README.md +++ b/problems/maximum-number-of-non-overlapping-substrings/README.md @@ -57,8 +57,8 @@ If we choose the first string, we cannot choose anything else and we'd get o ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-occurrences-of-a-substring/README.md b/problems/maximum-number-of-occurrences-of-a-substring/README.md index 3634859c2..c8a0ba0fb 100644 --- a/problems/maximum-number-of-occurrences-of-a-substring/README.md +++ b/problems/maximum-number-of-occurrences-of-a-substring/README.md @@ -11,11 +11,11 @@ ## [1297. Maximum Number of Occurrences of a Substring (Medium)](https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring "子串的最大出现次数") -

    Given a string s, return the maximum number of ocurrences of any substring under the following rules:

    +

    Given a string s, return the maximum number of ocurrences of any substring under the following rules:

    • The number of unique characters in the substring must be less than or equal to maxLetters.
    • -
    • The substring size must be between minSize and maxSize inclusive.
    • +
    • The substring size must be between minSize and maxSize inclusive.

     

    @@ -36,28 +36,14 @@ It satisfies the conditions, 2 unique letters and size 3 (between minSize and ma Explanation: Substring "aaa" occur 2 times in the string. It can overlap. -

    Example 3:

    - -
    -Input: s = "aabcabcab", maxLetters = 2, minSize = 2, maxSize = 3
    -Output: 3
    -
    - -

    Example 4:

    - -
    -Input: s = "abcde", maxLetters = 2, minSize = 3, maxSize = 3
    -Output: 0
    -
    -

     

    Constraints:

      -
    • 1 <= s.length <= 10^5
    • +
    • 1 <= s.length <= 105
    • 1 <= maxLetters <= 26
    • 1 <= minSize <= maxSize <= min(26, s.length)
    • -
    • s only contains lowercase English letters.
    • +
    • s consists of only lowercase English letters.
    ### Related Topics diff --git a/problems/maximum-number-of-tasks-you-can-assign/README.md b/problems/maximum-number-of-tasks-you-can-assign/README.md index a917e8956..03bd179c2 100644 --- a/problems/maximum-number-of-tasks-you-can-assign/README.md +++ b/problems/maximum-number-of-tasks-you-can-assign/README.md @@ -52,19 +52,7 @@ We can assign the magical pills and tasks as follows: - Give the magical pill to worker 0 and worker 1. - Assign worker 0 to task 0 (0 + 10 >= 10) - Assign worker 1 to task 1 (10 + 10 >= 15) - - -

    Example 4:

    - -
    -Input: tasks = [5,9,8,5,9], workers = [1,6,4,2,6], pills = 1, strength = 5
    -Output: 3
    -Explanation:
    -We can assign the magical pill and tasks as follows:
    -- Give the magical pill to worker 2.
    -- Assign worker 1 to task 0 (6 >= 5)
    -- Assign worker 2 to task 2 (4 + 5 >= 8)
    -- Assign worker 4 to task 3 (6 >= 5)
    +The last pill is not given because it will not make any worker strong enough for the last task.
     

     

    diff --git a/problems/maximum-number-of-visible-points/README.md b/problems/maximum-number-of-visible-points/README.md index 1dcf62a62..f9401d886 100644 --- a/problems/maximum-number-of-visible-points/README.md +++ b/problems/maximum-number-of-visible-points/README.md @@ -62,11 +62,11 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] - [[Sorting](../../tag/sorting/README.md)] + [[Geometry](../../tag/geometry/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Sorting](../../tag/sorting/README.md)] ### Hints
    diff --git a/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md b/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md index 8bc9d9ffb..0222974a8 100644 --- a/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md +++ b/problems/maximum-number-of-vowels-in-a-substring-of-given-length/README.md @@ -11,11 +11,9 @@ ## [1456. Maximum Number of Vowels in a Substring of Given Length (Medium)](https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length "定长子串中元音的最大数目") -

    Given a string s and an integer k.

    +

    Given a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k.

    -

    Return the maximum number of vowel letters in any substring of s with length k.

    - -

    Vowel letters in English are (a, e, i, o, u).

    +

    Vowel letters in English are 'a', 'e', 'i', 'o', and 'u'.

     

    Example 1:

    @@ -42,27 +40,12 @@ Explanation: "lee", "eet" and "ode" contain 2 vowels. -

    Example 4:

    - -
    -Input: s = "rhythms", k = 4
    -Output: 0
    -Explanation: We can see that s doesn't have any vowel letters.
    -
    - -

    Example 5:

    - -
    -Input: s = "tryhard", k = 4
    -Output: 1
    -
    -

     

    Constraints:

      -
    • 1 <= s.length <= 10^5
    • -
    • s consists of lowercase English letters.
    • +
    • 1 <= s.length <= 105
    • +
    • s consists of lowercase English letters.
    • 1 <= k <= s.length
    diff --git a/problems/maximum-number-of-weeks-for-which-you-can-work/README.md b/problems/maximum-number-of-weeks-for-which-you-can-work/README.md index 60f444ba4..406210336 100644 --- a/problems/maximum-number-of-weeks-for-which-you-can-work/README.md +++ b/problems/maximum-number-of-weeks-for-which-you-can-work/README.md @@ -68,8 +68,11 @@ Thus, one milestone in project 0 will remain unfinished. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Similar Questions + 1. [Task Scheduler](../task-scheduler) (Medium) ### Hints
    diff --git a/problems/maximum-number-of-words-found-in-sentences/README.md b/problems/maximum-number-of-words-found-in-sentences/README.md new file mode 100644 index 000000000..38e5c6b31 --- /dev/null +++ b/problems/maximum-number-of-words-found-in-sentences/README.md @@ -0,0 +1,61 @@ + + + + + + + +[< Previous](../elements-in-array-after-removing-and-replacing-elements "Elements in Array After Removing and Replacing Elements") +                 +[Next >](../find-all-possible-recipes-from-given-supplies "Find All Possible Recipes from Given Supplies") + +## [2114. Maximum Number of Words Found in Sentences (Easy)](https://leetcode.com/problems/maximum-number-of-words-found-in-sentences "句子中的最多单词数") + +

    A sentence is a list of words that are separated by a single space with no leading or trailing spaces.

    + +

    You are given an array of strings sentences, where each sentences[i] represents a single sentence.

    + +

    Return the maximum number of words that appear in a single sentence.

    + +

     

    +

    Example 1:

    + +
    +Input: sentences = ["alice and bob love leetcode", "i think so too", "this is great thanks very much"]
    +Output: 6
    +Explanation: 
    +- The first sentence, "alice and bob love leetcode", has 5 words in total.
    +- The second sentence, "i think so too", has 4 words in total.
    +- The third sentence, "this is great thanks very much", has 6 words in total.
    +Thus, the maximum number of words in a single sentence comes from the third sentence, which has 6 words.
    +
    + +

    Example 2:

    + +
    +Input: sentences = ["please wait", "continue to fight", "continue to win"]
    +Output: 3
    +Explanation: It is possible that multiple sentences contain the same number of words. 
    +In this example, the second and third sentences (underlined) have the same number of words.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= sentences.length <= 100
    • +
    • 1 <= sentences[i].length <= 100
    • +
    • sentences[i] consists only of lowercase English letters and ' ' only.
    • +
    • sentences[i] does not have leading or trailing spaces.
    • +
    • All the words in sentences[i] are separated by a single space.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +Process each sentence separately and count the number of words by looking for the number of space characters in the sentence and adding it by 1. +
    diff --git a/problems/maximum-path-quality-of-a-graph/README.md b/problems/maximum-path-quality-of-a-graph/README.md index de1176b46..9e6c3bbfd 100644 --- a/problems/maximum-path-quality-of-a-graph/README.md +++ b/problems/maximum-path-quality-of-a-graph/README.md @@ -47,18 +47,7 @@ The nodes visited are 0 and 3, giving a maximal path quality of 5 + 20 = 25. Output: 7 Explanation: One possible path is 0 -> 1 -> 3 -> 1 -> 0. The total time taken is 10 + 13 + 13 + 10 = 46 <= 50. -The nodes visited are 0, 1, and 3, giving a maximal path quality of 1 + 2 + 4 = 7. - -

    Example 4:

    - -

    - -
    -Input: values = [0,1,2], edges = [[1,2,10]], maxTime = 10
    -Output: 0
    -Explanation: 
    -The only path is 0. The total time taken is 0.
    -The only node visited is 0, giving a maximal path quality of 0.
    +The nodes visited are 0, 1, and 3, giving a maximal path quality of 1 + 2 + 4 = 7.
     

     

    diff --git a/problems/maximum-performance-of-a-team/README.md b/problems/maximum-performance-of-a-team/README.md index 4bf572f41..875210e17 100644 --- a/problems/maximum-performance-of-a-team/README.md +++ b/problems/maximum-performance-of-a-team/README.md @@ -62,6 +62,9 @@ We have the maximum performance of the team by selecting engineer 2 (with speed= [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] +### Similar Questions + 1. [Maximum Fruits Harvested After at Most K Steps](../maximum-fruits-harvested-after-at-most-k-steps) (Hard) + ### Hints
    Hint 1 diff --git a/problems/maximum-points-you-can-obtain-from-cards/README.md b/problems/maximum-points-you-can-obtain-from-cards/README.md index c5c74b84a..d01d36990 100644 --- a/problems/maximum-points-you-can-obtain-from-cards/README.md +++ b/problems/maximum-points-you-can-obtain-from-cards/README.md @@ -44,21 +44,6 @@ Explanation: You have to take all the cards. Your score is the sum of points of all cards. -

    Example 4:

    - -
    -Input: cardPoints = [1,1000,1], k = 1
    -Output: 1
    -Explanation: You cannot take the card in the middle. Your best score is 1. 
    -
    - -

    Example 5:

    - -
    -Input: cardPoints = [1,79,80,1,1,1,200,1], k = 3
    -Output: 202
    -
    -

     

    Constraints:

    @@ -70,8 +55,12 @@ ### Related Topics [[Array](../../tag/array/README.md)] - [[Prefix Sum](../../tag/prefix-sum/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Similar Questions + 1. [Maximum Score from Performing Multiplication Operations](../maximum-score-from-performing-multiplication-operations) (Medium) + 1. [Removing Minimum and Maximum From Array](../removing-minimum-and-maximum-from-array) (Medium) ### Hints
    diff --git a/problems/maximum-product-of-splitted-binary-tree/README.md b/problems/maximum-product-of-splitted-binary-tree/README.md index 0d7bea15e..aad097cb2 100644 --- a/problems/maximum-product-of-splitted-binary-tree/README.md +++ b/problems/maximum-product-of-splitted-binary-tree/README.md @@ -34,20 +34,6 @@ Explanation: Remove the red edge and get 2 binary trees with sum 15 and 6.Their product is 90 (15*6) -

    Example 3:

    - -
    -Input: root = [2,3,9,10,7,8,6,5,4,11,1]
    -Output: 1025
    -
    - -

    Example 4:

    - -
    -Input: root = [1,1]
    -Output: 1
    -
    -

     

    Constraints:

    diff --git a/problems/maximum-product-of-word-lengths/README.md b/problems/maximum-product-of-word-lengths/README.md index 32a3e74c8..40fec0598 100644 --- a/problems/maximum-product-of-word-lengths/README.md +++ b/problems/maximum-product-of-word-lengths/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-distance-from-all-buildings "Shortest Distance from All Buildings") diff --git a/problems/maximum-profit-of-operating-a-centennial-wheel/README.md b/problems/maximum-profit-of-operating-a-centennial-wheel/README.md index f638ef1e3..0ef854aa3 100644 --- a/problems/maximum-profit-of-operating-a-centennial-wheel/README.md +++ b/problems/maximum-profit-of-operating-a-centennial-wheel/README.md @@ -21,7 +21,7 @@

     

    Example 1:

    - +
     Input: customers = [8,3], boardingCost = 5, runningCost = 6
     Output: 3
    @@ -29,7 +29,8 @@
     1. 8 customers arrive, 4 board and 4 wait for the next gondola, the wheel rotates. Current profit is 4 * $5 - 1 * $6 = $14.
     2. 3 customers arrive, the 4 waiting board the wheel and the other 3 wait, the wheel rotates. Current profit is 8 * $5 - 2 * $6 = $28.
     3. The final 3 customers board the gondola, the wheel rotates. Current profit is 11 * $5 - 3 * $6 = $37.
    -The highest profit was $37 after rotating the wheel 3 times.
    +The highest profit was $37 after rotating the wheel 3 times. +

    Example 2:

    @@ -45,7 +46,6 @@ The highest profit was $37 after rotating the wheel 3 times. 6. 4 board and 1 waits, the wheel rotates. Current profit is 24 * $6 - 6 * $4 = $120. 7. 1 boards, the wheel rotates. Current profit is 25 * $6 - 7 * $4 = $122. The highest profit was $122 after rotating the wheel 7 times. -

    Example 3:

    @@ -62,25 +62,6 @@ The highest profit was $122 after rotating the wheel 7 times. The profit was never positive, so return -1. -

    Example 4:

    - -
    -Input: customers = [10,10,6,4,7], boardingCost = 3, runningCost = 8
    -Output: 9
    -Explanation:
    -1. 10 customers arrive, 4 board and 6 wait, the wheel rotates. Current profit is 4 * $3 - 1 * $8 = $4.
    -2. 10 customers arrive, 4 board and 12 wait, the wheel rotates. Current profit is 8 * $3 - 2 * $8 = $8.
    -3. 6 customers arrive, 4 board and 14 wait, the wheel rotates. Current profit is 12 * $3 - 3 * $8 = $12.
    -4. 4 customers arrive, 4 board and 14 wait, the wheel rotates. Current profit is 16 * $3 - 4 * $8 = $16.
    -5. 7 customers arrive, 4 board and 17 wait, the wheel rotates. Current profit is 20 * $3 - 5 * $8 = $20.
    -6. 4 board and 13 wait, the wheel rotates. Current profit is 24 * $3 - 6 * $8 = $24.
    -7. 4 board and 9 wait, the wheel rotates. Current profit is 28 * $3 - 7 * $8 = $28.
    -8. 4 board and 5 wait, the wheel rotates. Current profit is 32 * $3 - 8 * $8 = $32.
    -9. 4 board and 1 waits, the wheel rotates. Current profit is 36 * $3 - 9 * $8 = $36.
    -10. 1 board and 0 wait, the wheel rotates. Current profit is 37 * $3 - 10 * $8 = $31.
    -The highest profit was $36 after rotating the wheel 9 times.
    -
    -

     

    Constraints:

    diff --git a/problems/maximum-repeating-substring/README.md b/problems/maximum-repeating-substring/README.md index 96fe3070b..708d69560 100644 --- a/problems/maximum-repeating-substring/README.md +++ b/problems/maximum-repeating-substring/README.md @@ -53,9 +53,6 @@ [[String](../../tag/string/README.md)] [[String Matching](../../tag/string-matching/README.md)] -### Similar Questions - 1. [Detect Pattern of Length M Repeated K or More Times](../detect-pattern-of-length-m-repeated-k-or-more-times) (Easy) - ### Hints
    Hint 1 diff --git a/problems/maximum-running-time-of-n-computers/README.md b/problems/maximum-running-time-of-n-computers/README.md new file mode 100644 index 000000000..671f8e340 --- /dev/null +++ b/problems/maximum-running-time-of-n-computers/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../solving-questions-with-brainpower "Solving Questions With Brainpower") +                 +[Next >](../the-number-of-passengers-in-each-bus-i "The Number of Passengers in Each Bus I") + +## [2141. Maximum Running Time of N Computers (Hard)](https://leetcode.com/problems/maximum-running-time-of-n-computers "同时运行 N 台电脑的最长时间") + +

    You have n computers. You are given the integer n and a 0-indexed integer array batteries where the ith battery can run a computer for batteries[i] minutes. You are interested in running all n computers simultaneously using the given batteries.

    + +

    Initially, you can insert at most one battery into each computer. After that and at any integer time moment, you can remove a battery from a computer and insert another battery any number of times. The inserted battery can be a totally new battery or a battery from another computer. You may assume that the removing and inserting processes take no time.

    + +

    Note that the batteries cannot be recharged.

    + +

    Return the maximum number of minutes you can run all the n computers simultaneously.

    + +

     

    +

    Example 1:

    + +
    +Input: n = 2, batteries = [3,3,3]
    +Output: 4
    +Explanation: 
    +Initially, insert battery 0 into the first computer and battery 1 into the second computer.
    +After two minutes, remove battery 1 from the second computer and insert battery 2 instead. Note that battery 1 can still run for one minute.
    +At the end of the third minute, battery 0 is drained, and you need to remove it from the first computer and insert battery 1 instead.
    +By the end of the fourth minute, battery 1 is also drained, and the first computer is no longer running.
    +We can run the two computers simultaneously for at most 4 minutes, so we return 4.
    +
    +
    + +

    Example 2:

    + +
    +Input: n = 2, batteries = [1,1,1,1]
    +Output: 2
    +Explanation: 
    +Initially, insert battery 0 into the first computer and battery 2 into the second computer. 
    +After one minute, battery 0 and battery 2 are drained so you need to remove them and insert battery 1 into the first computer and battery 3 into the second computer. 
    +After another minute, battery 1 and battery 3 are also drained so the first and second computers are no longer running.
    +We can run the two computers simultaneously for at most 2 minutes, so we return 2.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= n <= batteries.length <= 105
    • +
    • 1 <= batteries[i] <= 109
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +For a given running time, can you determine if it is possible to run all n computers simultaneously? +
    + +
    +Hint 2 +Try to use Binary Search to find the maximal running time +
    diff --git a/problems/maximum-score-from-performing-multiplication-operations/README.md b/problems/maximum-score-from-performing-multiplication-operations/README.md index bc78098df..31175d357 100644 --- a/problems/maximum-score-from-performing-multiplication-operations/README.md +++ b/problems/maximum-score-from-performing-multiplication-operations/README.md @@ -64,6 +64,10 @@ The total score is 50 + 15 - 9 + 4 + 42 = 102. [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Maximum Points You Can Obtain from Cards](../maximum-points-you-can-obtain-from-cards) (Medium) + 1. [Stone Game VII](../stone-game-vii) (Medium) + ### Hints
    Hint 1 diff --git a/problems/maximum-score-from-removing-substrings/README.md b/problems/maximum-score-from-removing-substrings/README.md index 17c71631f..7fca866cd 100644 --- a/problems/maximum-score-from-removing-substrings/README.md +++ b/problems/maximum-score-from-removing-substrings/README.md @@ -58,9 +58,12 @@ Total score = 5 + 4 + 5 + 5 = 19. ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[String](../../tag/string/README.md)] + +### Similar Questions + 1. [Count Words Obtained After Adding a Letter](../count-words-obtained-after-adding-a-letter) (Medium) ### Hints
    diff --git a/problems/maximum-score-of-a-good-subarray/README.md b/problems/maximum-score-of-a-good-subarray/README.md index edeb34460..46c3d4d84 100644 --- a/problems/maximum-score-of-a-good-subarray/README.md +++ b/problems/maximum-score-of-a-good-subarray/README.md @@ -44,12 +44,15 @@ ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Stack](../../tag/stack/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] +### Similar Questions + 1. [Largest Rectangle in Histogram](../largest-rectangle-in-histogram) (Hard) + ### Hints
    Hint 1 diff --git a/problems/maximum-score-words-formed-by-letters/README.md b/problems/maximum-score-words-formed-by-letters/README.md index 97452e4ff..f2d0288bb 100644 --- a/problems/maximum-score-words-formed-by-letters/README.md +++ b/problems/maximum-score-words-formed-by-letters/README.md @@ -67,6 +67,9 @@ Letter "e" can only be used once. [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] +### Similar Questions + 1. [Maximum Good People Based on Statements](../maximum-good-people-based-on-statements) (Hard) + ### Hints
    Hint 1 diff --git a/problems/maximum-students-taking-exam/README.md b/problems/maximum-students-taking-exam/README.md index 3e752af5f..5b38f2519 100644 --- a/problems/maximum-students-taking-exam/README.md +++ b/problems/maximum-students-taking-exam/README.md @@ -65,11 +65,11 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Bitmask](../../tag/bitmask/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Matrix](../../tag/matrix/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/maximum-sum-bst-in-binary-tree/README.md b/problems/maximum-sum-bst-in-binary-tree/README.md index e74dca556..2cdd3f82f 100644 --- a/problems/maximum-sum-bst-in-binary-tree/README.md +++ b/problems/maximum-sum-bst-in-binary-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-zigzag-path-in-a-binary-tree "Longest ZigZag Path in a Binary Tree") @@ -50,20 +50,6 @@ Explanation: All values are negatives. Return an empty BST. -

    Example 4:

    - -
    -Input: root = [2,1,3]
    -Output: 6
    -
    - -

    Example 5:

    - -
    -Input: root = [5,4,8,3,null,6,3]
    -Output: 7
    -
    -

     

    Constraints:

    diff --git a/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md b/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md index bc2d40939..f29094169 100644 --- a/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md +++ b/problems/maximum-sum-of-3-non-overlapping-subarrays/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../knight-probability-in-chessboard "Knight Probability in Chessboard") diff --git a/problems/maximum-twin-sum-of-a-linked-list/README.md b/problems/maximum-twin-sum-of-a-linked-list/README.md new file mode 100644 index 000000000..03df5b91f --- /dev/null +++ b/problems/maximum-twin-sum-of-a-linked-list/README.md @@ -0,0 +1,89 @@ + + + + + + + +[< Previous](../capitalize-the-title "Capitalize the Title") +                 +[Next >](../longest-palindrome-by-concatenating-two-letter-words "Longest Palindrome by Concatenating Two Letter Words") + +## [2130. Maximum Twin Sum of a Linked List (Medium)](https://leetcode.com/problems/maximum-twin-sum-of-a-linked-list "链表最大孪生和") + +

    In a linked list of size n, where n is even, the ith node (0-indexed) of the linked list is known as the twin of the (n-1-i)th node, if 0 <= i <= (n / 2) - 1.

    + +
      +
    • For example, if n = 4, then node 0 is the twin of node 3, and node 1 is the twin of node 2. These are the only nodes with twins for n = 4.
    • +
    + +

    The twin sum is defined as the sum of a node and its twin.

    + +

    Given the head of a linked list with even length, return the maximum twin sum of the linked list.

    + +

     

    +

    Example 1:

    + +
    +Input: head = [5,4,2,1]
    +Output: 6
    +Explanation:
    +Nodes 0 and 1 are the twins of nodes 3 and 2, respectively. All have twin sum = 6.
    +There are no other nodes with twins in the linked list.
    +Thus, the maximum twin sum of the linked list is 6. 
    +
    + +

    Example 2:

    + +
    +Input: head = [4,2,2,3]
    +Output: 7
    +Explanation:
    +The nodes with twins present in this linked list are:
    +- Node 0 is the twin of node 3 having a twin sum of 4 + 3 = 7.
    +- Node 1 is the twin of node 2 having a twin sum of 2 + 2 = 4.
    +Thus, the maximum twin sum of the linked list is max(7, 4) = 7. 
    +
    + +

    Example 3:

    + +
    +Input: head = [1,100000]
    +Output: 100001
    +Explanation:
    +There is only one node with a twin in the linked list having twin sum of 1 + 100000 = 100001.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the list is an even integer in the range [2, 105].
    • +
    • 1 <= Node.val <= 105
    • +
    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Linked List](../../tag/linked-list/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + +### Hints +
    +Hint 1 +How can "reversing" a part of the linked list help find the answer? +
    + +
    +Hint 2 +We know that the nodes of the first half are twins of nodes in the second half, so try dividing the linked list in half and reverse the second half. +
    + +
    +Hint 3 +How can two pointers be used to find every twin sum optimally? +
    + +
    +Hint 4 +Use two different pointers pointing to the first nodes of the two halves of the linked list. The second pointer will point to the first node of the reversed half, which is the (n-1-i)th node in the original linked list. By moving both pointers forward at the same time, we find all twin sums. +
    diff --git a/problems/maximum-units-on-a-truck/README.md b/problems/maximum-units-on-a-truck/README.md index 3ead65713..e08582c6e 100644 --- a/problems/maximum-units-on-a-truck/README.md +++ b/problems/maximum-units-on-a-truck/README.md @@ -53,8 +53,8 @@ The total number of units will be = (1 * 3) + (2 * 2) + (1 * 1) = 8. ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md b/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md index b41ba72a4..885b19f5f 100644 --- a/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md +++ b/problems/maximum-value-at-a-given-index-in-a-bounded-array/README.md @@ -51,8 +51,8 @@ There are no arrays that satisfy all the conditions and have nums[2] == 3, so 2 ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/mean-of-array-after-removing-some-elements/README.md b/problems/mean-of-array-after-removing-some-elements/README.md index 82a728f5a..a3838f31b 100644 --- a/problems/mean-of-array-after-removing-some-elements/README.md +++ b/problems/mean-of-array-after-removing-some-elements/README.md @@ -38,20 +38,6 @@ Output: 4.77778 -

    Example 4:

    - -
    -Input: arr = [9,7,8,7,7,8,4,4,6,8,8,7,6,8,8,9,2,6,0,0,1,10,8,6,3,3,5,1,10,9,0,7,10,0,10,4,1,10,6,9,3,6,0,0,2,7,0,6,7,2,9,7,7,3,0,1,6,1,10,3]
    -Output: 5.27778
    -
    - -

    Example 5:

    - -
    -Input: arr = [4,8,4,10,0,7,1,3,7,8,8,3,4,1,6,2,1,1,8,0,9,8,0,3,9,10,3,10,1,10,7,3,2,1,4,9,10,7,6,4,0,8,5,1,2,1,6,2,5,0,7,10,9,10,3,7,10,5,8,5,7,6,7,6,10,9,5,10,5,5,7,2,10,7,7,8,2,0,1,1]
    -Output: 5.29167
    -
    -

     

    Constraints:

    diff --git a/problems/meeting-rooms-ii/README.md b/problems/meeting-rooms-ii/README.md index e08daae7c..03636b0e5 100644 --- a/problems/meeting-rooms-ii/README.md +++ b/problems/meeting-rooms-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../meeting-rooms "Meeting Rooms") @@ -28,9 +28,9 @@

    NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.

    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/merge-bsts-to-create-single-bst/README.md b/problems/merge-bsts-to-create-single-bst/README.md index 63d8f9678..f8271915c 100644 --- a/problems/merge-bsts-to-create-single-bst/README.md +++ b/problems/merge-bsts-to-create-single-bst/README.md @@ -65,14 +65,6 @@ The resulting tree is shown above. This is the only valid operation that can be Explanation: It is impossible to perform any operations. -

    Example 4:

    - -
    -Input: trees = [[2,1,3]]
    -Output: [2,1,3]
    -Explanation: There is only one tree, and it is already a valid BST, so return its root.
    -
    -

     

    Constraints:

    diff --git a/problems/merge-in-between-linked-lists/README.md b/problems/merge-in-between-linked-lists/README.md index 246908775..2206ccda2 100644 --- a/problems/merge-in-between-linked-lists/README.md +++ b/problems/merge-in-between-linked-lists/README.md @@ -15,7 +15,7 @@

    Remove list1's nodes from the ath node to the bth node, and put list2 in their place.

    -

    The blue edges and nodes in the following figure incidate the result:

    +

    The blue edges and nodes in the following figure indicate the result:

    Build the result list and return its head.

    diff --git a/problems/merge-intervals/README.md b/problems/merge-intervals/README.md index d474da066..9a94b715c 100644 --- a/problems/merge-intervals/README.md +++ b/problems/merge-intervals/README.md @@ -53,3 +53,4 @@ 1. [Employee Free Time](../employee-free-time) (Hard) 1. [Partition Labels](../partition-labels) (Medium) 1. [Interval List Intersections](../interval-list-intersections) (Medium) + 1. [Amount of New Area Painted Each Day](../amount-of-new-area-painted-each-day) (Hard) diff --git a/problems/merge-strings-alternately/README.md b/problems/merge-strings-alternately/README.md index fa3b9c32b..27cb88935 100644 --- a/problems/merge-strings-alternately/README.md +++ b/problems/merge-strings-alternately/README.md @@ -61,6 +61,9 @@ merged: a p b q c d [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Zigzag Iterator](../zigzag-iterator) (Medium) + ### Hints
    Hint 1 diff --git a/problems/merge-triplets-to-form-target-triplet/README.md b/problems/merge-triplets-to-form-target-triplet/README.md index a2105787a..cc1c8f67d 100644 --- a/problems/merge-triplets-to-form-target-triplet/README.md +++ b/problems/merge-triplets-to-form-target-triplet/README.md @@ -31,7 +31,7 @@
     Input: triplets = [[2,5,3],[1,8,4],[1,7,5]], target = [2,7,5]
     Output: true
    -Explanation: Perform the following operations:
    +Explanation: Perform the following operations:
     - Choose the first and last triplets [[2,5,3],[1,8,4],[1,7,5]]. Update the last triplet to be [max(2,1), max(5,7), max(3,5)] = [2,7,5]. triplets = [[2,5,3],[1,8,4],[2,7,5]]
     The target triplet [2,7,5] is now an element of triplets.
     
    @@ -39,9 +39,9 @@ The target triplet [2,7,5] is now an element of triplets.

    Example 2:

    -Input: triplets = [[1,3,4],[2,5,8]], target = [2,5,8]
    -Output: true
    -Explanation: The target triplet [2,5,8] is already an element of triplets.
    +Input: triplets = [[3,4,5],[4,5,6]], target = [3,2,5]
    +Output: false
    +Explanation: It is impossible to have [3,2,5] as an element because there is no 2 in any of the triplets.
     

    Example 3:

    @@ -55,14 +55,6 @@ The target triplet [2,7,5] is now an element of triplets. The target triplet [5,5,5] is now an element of triplets. -

    Example 4:

    - -
    -Input: triplets = [[3,4,5],[4,5,6]], target = [3,2,5]
    -Output: false
    -Explanation: It is impossible to have [3,2,5] as an element because there is no 2 in any of the triplets.
    -
    -

     

    Constraints:

    diff --git a/problems/min-cost-to-connect-all-points/README.md b/problems/min-cost-to-connect-all-points/README.md index 6ad6e59f7..7cb2c19ad 100644 --- a/problems/min-cost-to-connect-all-points/README.md +++ b/problems/min-cost-to-connect-all-points/README.md @@ -11,22 +11,20 @@ ## [1584. Min Cost to Connect All Points (Medium)](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") -

    You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].

    +

    You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].

    -

    The cost of connecting two points [xi, yi] and [xj, yj] is the manhattan distance between them: |xi - xj| + |yi - yj|, where |val| denotes the absolute value of val.

    +

    The cost of connecting two points [xi, yi] and [xj, yj] is the manhattan distance between them: |xi - xj| + |yi - yj|, where |val| denotes the absolute value of val.

    -

    Return the minimum cost to make all points connected. All points are connected if there is exactly one simple path between any two points.

    +

    Return the minimum cost to make all points connected. All points are connected if there is exactly one simple path between any two points.

     

    Example 1:

    - -

    - +
     Input: points = [[0,0],[2,2],[3,10],[5,2],[7,0]]
     Output: 20
    -Explanation:
    -
    +Explanation: 
    +
     We can connect the points as shown above to get the minimum cost of 20.
     Notice that there is a unique path between every pair of points.
     
    @@ -38,41 +36,23 @@ Notice that there is a unique path between every pair of points. Output: 18 -

    Example 3:

    - -
    -Input: points = [[0,0],[1,1],[1,0],[-1,1]]
    -Output: 4
    -
    - -

    Example 4:

    - -
    -Input: points = [[-1000000,-1000000],[1000000,1000000]]
    -Output: 4000000
    -
    - -

    Example 5:

    - -
    -Input: points = [[0,0]]
    -Output: 0
    -
    -

     

    Constraints:

    • 1 <= points.length <= 1000
    • -
    • -106 <= xi, yi <= 106
    • +
    • -106 <= xi, yi <= 106
    • All pairs (xi, yi) are distinct.
    ### Related Topics - [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] + [[Union Find](../../tag/union-find/README.md)] [[Minimum Spanning Tree](../../tag/minimum-spanning-tree/README.md)] +### Similar Questions + 1. [Minimum Number of Lines to Cover Points](../minimum-number-of-lines-to-cover-points) (Medium) + ### Hints
    Hint 1 diff --git a/problems/mini-parser/README.md b/problems/mini-parser/README.md index 35d1f45d1..2a2884145 100644 --- a/problems/mini-parser/README.md +++ b/problems/mini-parser/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shuffle-an-array "Shuffle an Array") diff --git a/problems/minimize-deviation-in-array/README.md b/problems/minimize-deviation-in-array/README.md index 67f25aefa..9b41e74d4 100644 --- a/problems/minimize-deviation-in-array/README.md +++ b/problems/minimize-deviation-in-array/README.md @@ -66,10 +66,10 @@ ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Array](../../tag/array/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/minimize-hamming-distance-after-swap-operations/README.md b/problems/minimize-hamming-distance-after-swap-operations/README.md index 56ca147c2..9a9482090 100644 --- a/problems/minimize-hamming-distance-after-swap-operations/README.md +++ b/problems/minimize-hamming-distance-after-swap-operations/README.md @@ -59,9 +59,12 @@ The Hamming distance of source and target is 2 as they differ in 2 positions: in ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] + +### Similar Questions + 1. [Smallest String With Swaps](../smallest-string-with-swaps) (Medium) ### Hints
    diff --git a/problems/minimum-absolute-difference/README.md b/problems/minimum-absolute-difference/README.md index 58e0d2f6b..a2d9fe276 100644 --- a/problems/minimum-absolute-difference/README.md +++ b/problems/minimum-absolute-difference/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-time-to-build-blocks "Minimum Time to Build Blocks") @@ -11,14 +11,14 @@ ## [1200. Minimum Absolute Difference (Easy)](https://leetcode.com/problems/minimum-absolute-difference "最小绝对差") -

    Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements. 

    +

    Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements.

    Return a list of pairs in ascending order(with respect to pairs), each pair [a, b] follows

    • a, b are from arr
    • a < b
    • -
    • b - a equals to the minimum absolute difference of any two elements in arr
    • +
    • b - a equals to the minimum absolute difference of any two elements in arr

     

    @@ -47,14 +47,17 @@

    Constraints:

      -
    • 2 <= arr.length <= 10^5
    • -
    • -10^6 <= arr[i] <= 10^6
    • +
    • 2 <= arr.length <= 105
    • +
    • -106 <= arr[i] <= 106
    ### Related Topics [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Minimum Cost of Buying Candies With Discount](../minimum-cost-of-buying-candies-with-discount) (Easy) + ### Hints
    Hint 1 diff --git a/problems/minimum-add-to-make-parentheses-valid/README.md b/problems/minimum-add-to-make-parentheses-valid/README.md index b03b231d9..f22abd1a7 100644 --- a/problems/minimum-add-to-make-parentheses-valid/README.md +++ b/problems/minimum-add-to-make-parentheses-valid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-music-playlists "Number of Music Playlists") @@ -42,20 +42,6 @@ Output: 3 -

    Example 3:

    - -
    -Input: s = "()"
    -Output: 0
    -
    - -

    Example 4:

    - -
    -Input: s = "()))(("
    -Output: 4
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md b/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md index 94852b978..2f7a8dce0 100644 --- a/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md +++ b/problems/minimum-adjacent-swaps-for-k-consecutive-ones/README.md @@ -50,10 +50,14 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] - [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Similar Questions + 1. [Minimum Swaps to Group All 1's Together](../minimum-swaps-to-group-all-1s-together) (Medium) + 1. [Minimum Number of Operations to Make Array Continuous](../minimum-number-of-operations-to-make-array-continuous) (Hard) ### Hints
    diff --git a/problems/minimum-area-rectangle-ii/README.md b/problems/minimum-area-rectangle-ii/README.md index c8fc5d698..c413480e8 100644 --- a/problems/minimum-area-rectangle-ii/README.md +++ b/problems/minimum-area-rectangle-ii/README.md @@ -19,7 +19,7 @@

     

    Example 1:

    - +
     Input: points = [[1,2],[2,1],[1,0],[0,1]]
     Output: 2.00000
    @@ -27,7 +27,7 @@
     

    Example 2:

    - +
     Input: points = [[0,1],[2,1],[1,1],[1,0],[2,0]]
     Output: 1.00000
    @@ -35,21 +35,13 @@
     

    Example 3:

    - +
     Input: points = [[0,3],[1,2],[3,1],[1,3],[2,1]]
     Output: 0
     Explanation: There is no possible rectangle to form from these points.
     
    -

    Example 4:

    - -
    -Input: points = [[3,1],[1,1],[0,1],[2,1],[3,3],[3,2],[0,2],[2,3]]
    -Output: 2.00000
    -Explanation: The minimum area rectangle occurs at [2,1],[2,3],[3,3],[3,1], with an area of 2.
    -
    -

     

    Constraints:

    @@ -61,6 +53,6 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] diff --git a/problems/minimum-cost-homecoming-of-a-robot-in-a-grid/README.md b/problems/minimum-cost-homecoming-of-a-robot-in-a-grid/README.md new file mode 100644 index 000000000..49d80e975 --- /dev/null +++ b/problems/minimum-cost-homecoming-of-a-robot-in-a-grid/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../minimum-number-of-buckets-required-to-collect-rainwater-from-houses "Minimum Number of Buckets Required to Collect Rainwater from Houses") +                 +[Next >](../count-fertile-pyramids-in-a-land "Count Fertile Pyramids in a Land") + +## [2087. Minimum Cost Homecoming of a Robot in a Grid (Medium)](https://leetcode.com/problems/minimum-cost-homecoming-of-a-robot-in-a-grid "网格图中机器人回家的最小代价") + +

    There is an m x n grid, where (0, 0) is the top-left cell and (m - 1, n - 1) is the bottom-right cell. You are given an integer array startPos where startPos = [startrow, startcol] indicates that initially, a robot is at the cell (startrow, startcol). You are also given an integer array homePos where homePos = [homerow, homecol] indicates that its home is at the cell (homerow, homecol).

    + +

    The robot needs to go to its home. It can move one cell in four directions: left, right, up, or down, and it can not move outside the boundary. Every move incurs some cost. You are further given two 0-indexed integer arrays: rowCosts of length m and colCosts of length n.

    + +
      +
    • If the robot moves up or down into a cell whose row is r, then this move costs rowCosts[r].
    • +
    • If the robot moves left or right into a cell whose column is c, then this move costs colCosts[c].
    • +
    + +

    Return the minimum total cost for this robot to return home.

    + +

     

    +

    Example 1:

    + +
    +Input: startPos = [1, 0], homePos = [2, 3], rowCosts = [5, 4, 3], colCosts = [8, 2, 6, 7]
    +Output: 18
    +Explanation: One optimal path is that:
    +Starting from (1, 0)
    +-> It goes down to (2, 0). This move costs rowCosts[2] = 3.
    +-> It goes right to (2, 1). This move costs colCosts[1] = 2.
    +-> It goes right to (2, 2). This move costs colCosts[2] = 6.
    +-> It goes right to (2, 3). This move costs colCosts[3] = 7.
    +The total cost is 3 + 2 + 6 + 7 = 18
    + +

    Example 2:

    + +
    +Input: startPos = [0, 0], homePos = [0, 0], rowCosts = [5], colCosts = [26]
    +Output: 0
    +Explanation: The robot is already at its home. Since no moves occur, the total cost is 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == rowCosts.length
    • +
    • n == colCosts.length
    • +
    • 1 <= m, n <= 105
    • +
    • 0 <= rowCosts[r], colCosts[c] <= 104
    • +
    • startPos.length == 2
    • +
    • homePos.length == 2
    • +
    • 0 <= startrow, homerow < m
    • +
    • 0 <= startcol, homecol < n
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Irrespective of what path the robot takes, it will have to traverse all the rows between startRow and homeRow and all the columns between startCol and homeCol. +
    + +
    +Hint 2 +Hence, making any other move other than traversing the required rows and columns will potentially incur more cost which can be avoided. +
    diff --git a/problems/minimum-cost-of-buying-candies-with-discount/README.md b/problems/minimum-cost-of-buying-candies-with-discount/README.md new file mode 100644 index 000000000..f1b686fbd --- /dev/null +++ b/problems/minimum-cost-of-buying-candies-with-discount/README.md @@ -0,0 +1,100 @@ + + + + + + + +[< Previous](../choose-numbers-from-two-arrays-in-range "Choose Numbers From Two Arrays in Range") +                 +[Next >](../count-the-hidden-sequences "Count the Hidden Sequences") + +## [2144. Minimum Cost of Buying Candies With Discount (Easy)](https://leetcode.com/problems/minimum-cost-of-buying-candies-with-discount "打折购买糖果的最小开销") + +

    A shop is selling candies at a discount. For every two candies sold, the shop gives a third candy for free.

    + +

    The customer can choose any candy to take away for free as long as the cost of the chosen candy is less than or equal to the minimum cost of the two candies bought.

    + +
      +
    • For example, if there are 4 candies with costs 1, 2, 3, and 4, and the customer buys candies with costs 2 and 3, they can take the candy with cost 1 for free, but not the candy with cost 4.
    • +
    + +

    Given a 0-indexed integer array cost, where cost[i] denotes the cost of the ith candy, return the minimum cost of buying all the candies.

    + +

     

    +

    Example 1:

    + +
    +Input: cost = [1,2,3]
    +Output: 5
    +Explanation: We buy the candies with costs 2 and 3, and take the candy with cost 1 for free.
    +The total cost of buying all candies is 2 + 3 = 5. This is the only way we can buy the candies.
    +Note that we cannot buy candies with costs 1 and 3, and then take the candy with cost 2 for free.
    +The cost of the free candy has to be less than or equal to the minimum cost of the purchased candies.
    +
    + +

    Example 2:

    + +
    +Input: cost = [6,5,7,9,2,2]
    +Output: 23
    +Explanation: The way in which we can get the minimum cost is described below:
    +- Buy candies with costs 9 and 7
    +- Take the candy with cost 6 for free
    +- We buy candies with costs 5 and 2
    +- Take the last remaining candy with cost 2 for free
    +Hence, the minimum cost to buy all candies is 9 + 7 + 5 + 2 = 23.
    +
    + +

    Example 3:

    + +
    +Input: cost = [5,5]
    +Output: 10
    +Explanation: Since there are only 2 candies, we buy both of them. There is not a third candy we can take for free.
    +Hence, the minimum cost to buy all candies is 5 + 5 = 10.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= cost.length <= 100
    • +
    • 1 <= cost[i] <= 100
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +If we consider costs from high to low, what is the maximum cost of a single candy that we can get for free? +
    + +
    +Hint 2 +How can we generalize this approach to maximize the costs of the candies we get for free? +
    + +
    +Hint 3 +Can “sorting” the array help us find the minimum cost? +
    + +
    +Hint 4 +If we consider costs from high to low, what is the maximum cost of a single candy that we can get for free? +
    + +
    +Hint 5 +How can we generalize this approach to maximize the costs of the candies we get for free? +
    + +
    +Hint 6 +Can “sorting” the array help us find the minimum cost? +
    diff --git a/problems/minimum-cost-to-connect-two-groups-of-points/README.md b/problems/minimum-cost-to-connect-two-groups-of-points/README.md index fa8b8b06d..64c0a7e2b 100644 --- a/problems/minimum-cost-to-connect-two-groups-of-points/README.md +++ b/problems/minimum-cost-to-connect-two-groups-of-points/README.md @@ -62,11 +62,11 @@ Note that there are multiple points connected to point 2 in the first group and ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Bitmask](../../tag/bitmask/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Matrix](../../tag/matrix/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] ### Hints
    diff --git a/problems/minimum-cost-to-cut-a-stick/README.md b/problems/minimum-cost-to-cut-a-stick/README.md index bd27a000b..232a331a8 100644 --- a/problems/minimum-cost-to-cut-a-stick/README.md +++ b/problems/minimum-cost-to-cut-a-stick/README.md @@ -55,6 +55,9 @@ There are much ordering with total cost <= 25, for example, the order [4, 6, [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Number of Ways to Divide a Long Corridor](../number-of-ways-to-divide-a-long-corridor) (Hard) + ### Hints
    Hint 1 diff --git a/problems/minimum-cost-to-merge-stones/README.md b/problems/minimum-cost-to-merge-stones/README.md index da1b34bf4..8efb726aa 100644 --- a/problems/minimum-cost-to-merge-stones/README.md +++ b/problems/minimum-cost-to-merge-stones/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../available-captures-for-rook "Available Captures for Rook") diff --git a/problems/minimum-cost-to-reach-city-with-discounts/README.md b/problems/minimum-cost-to-reach-city-with-discounts/README.md new file mode 100644 index 000000000..873df6d98 --- /dev/null +++ b/problems/minimum-cost-to-reach-city-with-discounts/README.md @@ -0,0 +1,34 @@ + + + + + + + +[< Previous](../find-all-people-with-secret "Find All People With Secret") +                 +[Next >](../finding-3-digit-even-numbers "Finding 3-Digit Even Numbers") + +## [2093. Minimum Cost to Reach City With Discounts (Medium)](https://leetcode.com/problems/minimum-cost-to-reach-city-with-discounts "") + + + +### Related Topics + [[Graph](../../tag/graph/README.md)] + [[Shortest Path](../../tag/shortest-path/README.md)] + +### Hints +
    +Hint 1 +Try to construct a graph out of highways. What type of graph is this? +
    + +
    +Hint 2 +We essentially need to find the minimum distance to get from node 0 to node n - 1 in an undirected weighted graph. What algorithm should we use to do this? +
    + +
    +Hint 3 +Use Dijkstra's algorithm to find the minimum weight path. Keep track of the minimum distance to each vertex with d discounts left +
    diff --git a/problems/minimum-cost-to-reach-destination-in-time/README.md b/problems/minimum-cost-to-reach-destination-in-time/README.md index 73dbdb11c..d2bc9797e 100644 --- a/problems/minimum-cost-to-reach-destination-in-time/README.md +++ b/problems/minimum-cost-to-reach-destination-in-time/README.md @@ -65,8 +65,12 @@ You cannot take path 0 -> 1 -> 2 -> 5 since it would take too long. ### Related Topics - [[Graph](../../tag/graph/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Graph](../../tag/graph/README.md)] + +### Similar Questions + 1. [Maximum Path Quality of a Graph](../maximum-path-quality-of-a-graph) (Hard) + 1. [Minimum Cost to Reach City With Discounts](../minimum-cost-to-reach-city-with-discounts) (Medium) ### Hints
    diff --git a/problems/minimum-cost-to-separate-sentence-into-rows/README.md b/problems/minimum-cost-to-separate-sentence-into-rows/README.md index 36029ae69..559bc0df4 100644 --- a/problems/minimum-cost-to-separate-sentence-into-rows/README.md +++ b/problems/minimum-cost-to-separate-sentence-into-rows/README.md @@ -9,7 +9,7 @@                  [Next >](../kth-distinct-string-in-an-array "Kth Distinct String in an Array") -## [2052. Minimum Cost to Separate Sentence Into Rows (Medium)](https://leetcode.com/problems/minimum-cost-to-separate-sentence-into-rows "") +## [2052. Minimum Cost to Separate Sentence Into Rows (Medium)](https://leetcode.com/problems/minimum-cost-to-separate-sentence-into-rows "将句子分隔成行的最低成本") diff --git a/problems/minimum-cost-to-set-cooking-time/README.md b/problems/minimum-cost-to-set-cooking-time/README.md new file mode 100644 index 000000000..c3235cd38 --- /dev/null +++ b/problems/minimum-cost-to-set-cooking-time/README.md @@ -0,0 +1,98 @@ + + + + + + + +[< Previous](../partition-array-according-to-given-pivot "Partition Array According to Given Pivot") +                 +[Next >](../minimum-difference-in-sums-after-removal-of-elements "Minimum Difference in Sums After Removal of Elements") + +## [2162. Minimum Cost to Set Cooking Time (Medium)](https://leetcode.com/problems/minimum-cost-to-set-cooking-time "设置时间的最少代价") + +

    A generic microwave supports cooking times for:

    + +
      +
    • at least 1 second.
    • +
    • at most 99 minutes and 99 seconds.
    • +
    + +

    To set the cooking time, you push at most four digits. The microwave normalizes what you push as four digits by prepending zeroes. It interprets the first two digits as the minutes and the last two digits as the seconds. It then adds them up as the cooking time. For example,

    + +
      +
    • You push 9 5 4 (three digits). It is normalized as 0954 and interpreted as 9 minutes and 54 seconds.
    • +
    • You push 0 0 0 8 (four digits). It is interpreted as 0 minutes and 8 seconds.
    • +
    • You push 8 0 9 0. It is interpreted as 80 minutes and 90 seconds.
    • +
    • You push 8 1 3 0. It is interpreted as 81 minutes and 30 seconds.
    • +
    + +

    You are given integers startAt, moveCost, pushCost, and targetSeconds. Initially, your finger is on the digit startAt. Moving the finger above any specific digit costs moveCost units of fatigue. Pushing the digit below the finger once costs pushCost units of fatigue.

    + +

    There can be multiple ways to set the microwave to cook for targetSeconds seconds but you are interested in the way with the minimum cost.

    + +

    Return the minimum cost to set targetSeconds seconds of cooking time.

    + +

    Remember that one minute consists of 60 seconds.

    + +

     

    +

    Example 1:

    + +
    +Input: startAt = 1, moveCost = 2, pushCost = 1, targetSeconds = 600
    +Output: 6
    +Explanation: The following are the possible ways to set the cooking time.
    +- 1 0 0 0, interpreted as 10 minutes and 0 seconds.
    +  The finger is already on digit 1, pushes 1 (with cost 1), moves to 0 (with cost 2), pushes 0 (with cost 1), pushes 0 (with cost 1), and pushes 0 (with cost 1).
    +  The cost is: 1 + 2 + 1 + 1 + 1 = 6. This is the minimum cost.
    +- 0 9 6 0, interpreted as 9 minutes and 60 seconds. That is also 600 seconds.
    +  The finger moves to 0 (with cost 2), pushes 0 (with cost 1), moves to 9 (with cost 2), pushes 9 (with cost 1), moves to 6 (with cost 2), pushes 6 (with cost 1), moves to 0 (with cost 2), and pushes 0 (with cost 1).
    +  The cost is: 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 = 12.
    +- 9 6 0, normalized as 0960 and interpreted as 9 minutes and 60 seconds.
    +  The finger moves to 9 (with cost 2), pushes 9 (with cost 1), moves to 6 (with cost 2), pushes 6 (with cost 1), moves to 0 (with cost 2), and pushes 0 (with cost 1).
    +  The cost is: 2 + 1 + 2 + 1 + 2 + 1 = 9.
    +
    + +

    Example 2:

    + +
    +Input: startAt = 0, moveCost = 1, pushCost = 2, targetSeconds = 76
    +Output: 6
    +Explanation: The optimal way is to push two digits: 7 6, interpreted as 76 seconds.
    +The finger moves to 7 (with cost 1), pushes 7 (with cost 2), moves to 6 (with cost 1), and pushes 6 (with cost 2). The total cost is: 1 + 2 + 1 + 2 = 6
    +Note other possible ways are 0076, 076, 0116, and 116, but none of them produces the minimum cost.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 0 <= startAt <= 9
    • +
    • 1 <= moveCost, pushCost <= 105
    • +
    • 1 <= targetSeconds <= 6039
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + +### Hints +
    +Hint 1 +Define a separate function Cost(mm, ss) where 0 <= mm <= 99 and 0 <= ss <= 99. This function should calculate the cost of setting the cocking time to mm minutes and ss seconds +
    + +
    +Hint 2 +The range of the minutes is small (i.e., [0, 99]), how can you use that? +
    + +
    +Hint 3 +For every mm in [0, 99], calculate the needed ss to make mm:ss equal to targetSeconds and minimize the cost of setting the cocking time to mm:ss +
    + +
    +Hint 4 +Be careful in some cases when ss is not in the valid range [0, 99]. +
    diff --git a/problems/minimum-deletions-to-make-string-balanced/README.md b/problems/minimum-deletions-to-make-string-balanced/README.md index ced0f75da..32083314e 100644 --- a/problems/minimum-deletions-to-make-string-balanced/README.md +++ b/problems/minimum-deletions-to-make-string-balanced/README.md @@ -49,6 +49,9 @@ Delete the characters at 0-indexed positions 3 and 6 ("aababba Hint 1 diff --git a/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md b/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md index e33c271fd..f53074997 100644 --- a/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md +++ b/problems/minimum-difference-between-highest-and-lowest-of-k-scores/README.md @@ -53,6 +53,7 @@ The minimum possible difference is 2. ### Related Topics [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md b/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md index b999215c1..4c51853a1 100644 --- a/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md +++ b/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/README.md @@ -11,9 +11,9 @@ ## [1509. Minimum Difference Between Largest and Smallest Value in Three Moves (Medium)](https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves "三次操作后最大值与最小值的最小差") -

    Given an array nums, you are allowed to choose one element of nums and change it by any value in one move.

    +

    You are given an integer array nums. In one move, you can choose one element of nums and change it by any value.

    -

    Return the minimum difference between the largest and smallest value of nums after perfoming at most 3 moves.

    +

    Return the minimum difference between the largest and smallest value of nums after performing at most three moves.

     

    Example 1:

    @@ -22,7 +22,8 @@ Input: nums = [5,3,2,4] Output: 0 Explanation: Change the array [5,3,2,4] to [2,2,2,2]. -The difference between the maximum and minimum is 2-2 = 0. +The difference between the maximum and minimum is 2-2 = 0. +

    Example 2:

    @@ -33,26 +34,12 @@ The difference between the maximum and minimum is 2-2 = 0. The difference between the maximum and minimum is 1-0 = 1. -

    Example 3:

    - -
    -Input: nums = [6,6,0,1,1,4,6]
    -Output: 2
    -
    - -

    Example 4:

    - -
    -Input: nums = [1,5,6,14,15]
    -Output: 1
    -
    -

     

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • -10^9 <= nums[i] <= 10^9
    • +
    • 1 <= nums.length <= 105
    • +
    • -109 <= nums[i] <= 109
    ### Related Topics diff --git a/problems/minimum-difference-in-sums-after-removal-of-elements/README.md b/problems/minimum-difference-in-sums-after-removal-of-elements/README.md new file mode 100644 index 000000000..9daf25991 --- /dev/null +++ b/problems/minimum-difference-in-sums-after-removal-of-elements/README.md @@ -0,0 +1,90 @@ + + + + + + + +[< Previous](../minimum-cost-to-set-cooking-time "Minimum Cost to Set Cooking Time") +                 +[Next >](../sort-even-and-odd-indices-independently "Sort Even and Odd Indices Independently") + +## [2163. Minimum Difference in Sums After Removal of Elements (Hard)](https://leetcode.com/problems/minimum-difference-in-sums-after-removal-of-elements "删除元素后和的最小差值") + +

    You are given a 0-indexed integer array nums consisting of 3 * n elements.

    + +

    You are allowed to remove any subsequence of elements of size exactly n from nums. The remaining 2 * n elements will be divided into two equal parts:

    + +
      +
    • The first n elements belonging to the first part and their sum is sumfirst.
    • +
    • The next n elements belonging to the second part and their sum is sumsecond.
    • +
    + +

    The difference in sums of the two parts is denoted as sumfirst - sumsecond.

    + +
      +
    • For example, if sumfirst = 3 and sumsecond = 2, their difference is 1.
    • +
    • Similarly, if sumfirst = 2 and sumsecond = 3, their difference is -1.
    • +
    + +

    Return the minimum difference possible between the sums of the two parts after the removal of n elements.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [3,1,2]
    +Output: -1
    +Explanation: Here, nums has 3 elements, so n = 1. 
    +Thus we have to remove 1 element from nums and divide the array into two equal parts.
    +- If we remove nums[0] = 3, the array will be [1,2]. The difference in sums of the two parts will be 1 - 2 = -1.
    +- If we remove nums[1] = 1, the array will be [3,2]. The difference in sums of the two parts will be 3 - 2 = 1.
    +- If we remove nums[2] = 2, the array will be [3,1]. The difference in sums of the two parts will be 3 - 1 = 2.
    +The minimum difference between sums of the two parts is min(-1,1,2) = -1. 
    +
    + +

    Example 2:

    + +
    +Input: nums = [7,9,5,8,1,3]
    +Output: 1
    +Explanation: Here n = 2. So we must remove 2 elements and divide the remaining array into two parts containing two elements each.
    +If we remove nums[2] = 5 and nums[3] = 8, the resultant array will be [7,9,1,3]. The difference in sums will be (7+9) - (1+3) = 12.
    +To obtain the minimum difference, we should remove nums[1] = 9 and nums[4] = 1. The resultant array becomes [7,5,8,3]. The difference in sums of the two parts is (7+5) - (8+3) = 1.
    +It can be shown that it is not possible to obtain a difference smaller than 1.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • nums.length == 3 * n
    • +
    • 1 <= n <= 105
    • +
    • 1 <= nums[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +The lowest possible difference can be obtained when the sum of the first n elements in the resultant array is minimum, and the sum of the next n elements is maximum. +
    + +
    +Hint 2 +For every index i, think about how you can find the minimum possible sum of n elements with indices lesser or equal to i, if possible. +
    + +
    +Hint 3 +Similarly, for every index i, try to find the maximum possible sum of n elements with indices greater or equal to i, if possible. +
    + +
    +Hint 4 +Now for all indices, check if we can consider it as the partitioning index and hence find the answer. +
    diff --git a/problems/minimum-difficulty-of-a-job-schedule/README.md b/problems/minimum-difficulty-of-a-job-schedule/README.md index 1dcb96035..7367d9f71 100644 --- a/problems/minimum-difficulty-of-a-job-schedule/README.md +++ b/problems/minimum-difficulty-of-a-job-schedule/README.md @@ -11,13 +11,13 @@ ## [1335. Minimum Difficulty of a Job Schedule (Hard)](https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule "工作计划的最低难度") -

    You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the i-th job, you have to finish all the jobs j where 0 <= j < i).

    +

    You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the ith job, you have to finish all the jobs j where 0 <= j < i).

    -

    You have to finish at least one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the d days. The difficulty of a day is the maximum difficulty of a job done in that day.

    +

    You have to finish at least one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the d days. The difficulty of a day is the maximum difficulty of a job done on that day.

    -

    Given an array of integers jobDifficulty and an integer d. The difficulty of the i-th job is jobDifficulty[i].

    +

    You are given an integer array jobDifficulty and an integer d. The difficulty of the ith job is jobDifficulty[i].

    -

    Return the minimum difficulty of a job schedule. If you cannot find a schedule for the jobs return -1.

    +

    Return the minimum difficulty of a job schedule. If you cannot find a schedule for the jobs return -1.

     

    Example 1:

    @@ -46,20 +46,6 @@ The difficulty of the schedule = 6 + 1 = 7 Explanation: The schedule is one job per day. total difficulty will be 3. -

    Example 4:

    - -
    -Input: jobDifficulty = [7,1,7,1,7,1], d = 3
    -Output: 15
    -
    - -

    Example 5:

    - -
    -Input: jobDifficulty = [11,111,22,222,33,333,44,444], d = 6
    -Output: 843
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md index b519e4090..48841f1ad 100644 --- a/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md +++ b/problems/minimum-distance-to-type-a-word-using-two-fingers/README.md @@ -30,8 +30,7 @@
     Input: word = "CAKE"
     Output: 3
    -Explanation: 
    -Using two fingers, one optimal way to type "CAKE" is: 
    +Explanation: Using two fingers, one optimal way to type "CAKE" is: 
     Finger 1 on letter 'C' -> cost = 0 
     Finger 1 on letter 'A' -> cost = Distance from letter 'C' to letter 'A' = 2 
     Finger 2 on letter 'K' -> cost = 0 
    @@ -44,8 +43,7 @@ Total distance = 3
     
     Input: word = "HAPPY"
     Output: 6
    -Explanation: 
    -Using two fingers, one optimal way to type "HAPPY" is:
    +Explanation: Using two fingers, one optimal way to type "HAPPY" is:
     Finger 1 on letter 'H' -> cost = 0
     Finger 1 on letter 'A' -> cost = Distance from letter 'H' to letter 'A' = 2
     Finger 2 on letter 'P' -> cost = 0
    @@ -54,20 +52,6 @@ Finger 1 on letter 'Y' -> cost = Distance from letter 'A' to
     Total distance = 6
     
    -

    Example 3:

    - -
    -Input: word = "NEW"
    -Output: 3
    -
    - -

    Example 4:

    - -
    -Input: word = "YEAR"
    -Output: 7
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-domino-rotations-for-equal-row/README.md b/problems/minimum-domino-rotations-for-equal-row/README.md index 63b5a53a9..70e13dd34 100644 --- a/problems/minimum-domino-rotations-for-equal-row/README.md +++ b/problems/minimum-domino-rotations-for-equal-row/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../clumsy-factorial "Clumsy Factorial") @@ -49,5 +49,5 @@ In this case, it is not possible to rotate the dominoes to make one row of value ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] diff --git a/problems/minimum-elements-to-add-to-form-a-given-sum/README.md b/problems/minimum-elements-to-add-to-form-a-given-sum/README.md index dfbb7e274..1bad5bcd5 100644 --- a/problems/minimum-elements-to-add-to-form-a-given-sum/README.md +++ b/problems/minimum-elements-to-add-to-form-a-given-sum/README.md @@ -44,8 +44,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/minimum-falling-path-sum-ii/README.md b/problems/minimum-falling-path-sum-ii/README.md index d0c06f521..446fbe15c 100644 --- a/problems/minimum-falling-path-sum-ii/README.md +++ b/problems/minimum-falling-path-sum-ii/README.md @@ -50,6 +50,9 @@ The falling path with the smallest sum is [1,5,7], so the answer is 13 [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Minimum Falling Path Sum](../minimum-falling-path-sum) (Medium) + ### Hints
    Hint 1 diff --git a/problems/minimum-falling-path-sum/README.md b/problems/minimum-falling-path-sum/README.md index 9e7856ffb..cbd4580c6 100644 --- a/problems/minimum-falling-path-sum/README.md +++ b/problems/minimum-falling-path-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../binary-subarrays-with-sum "Binary Subarrays With Sum") diff --git a/problems/minimum-genetic-mutation/README.md b/problems/minimum-genetic-mutation/README.md index 906685cc7..464225609 100644 --- a/problems/minimum-genetic-mutation/README.md +++ b/problems/minimum-genetic-mutation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../all-oone-data-structure "All O`one Data Structure") diff --git a/problems/minimum-incompatibility/README.md b/problems/minimum-incompatibility/README.md index cb789c363..8cce8ee4d 100644 --- a/problems/minimum-incompatibility/README.md +++ b/problems/minimum-incompatibility/README.md @@ -56,9 +56,9 @@ The incompatibility is (2-1) + (3-2) + (8-6) + (3-1) = 6. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Bitmask](../../tag/bitmask/README.md)] ### Hints diff --git a/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md b/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md index db3e86945..4dea8e463 100644 --- a/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md +++ b/problems/minimum-insertion-steps-to-make-a-string-palindrome/README.md @@ -42,26 +42,12 @@ Explanation: Inserting 5 characters the string becomes "leetcodocteel".
    -

    Example 4:

    - -
    -Input: s = "g"
    -Output: 0
    -
    - -

    Example 5:

    - -
    -Input: s = "no"
    -Output: 1
    -
    -

     

    Constraints:

    • 1 <= s.length <= 500
    • -
    • All characters of s are lower case English letters.
    • +
    • s consists of lowercase English letters.
    ### Related Topics diff --git a/problems/minimum-insertions-to-balance-a-parentheses-string/README.md b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md index 3fd4fb5b2..ee880867b 100644 --- a/problems/minimum-insertions-to-balance-a-parentheses-string/README.md +++ b/problems/minimum-insertions-to-balance-a-parentheses-string/README.md @@ -14,13 +14,15 @@

    Given a parentheses string s containing only the characters '(' and ')'. A parentheses string is balanced if:

      -
    • Any left parenthesis '(' must have a corresponding two consecutive right parenthesis '))'.
    • -
    • Left parenthesis '(' must go before the corresponding two consecutive right parenthesis '))'.
    • +
    • Any left parenthesis '(' must have a corresponding two consecutive right parenthesis '))'.
    • +
    • Left parenthesis '(' must go before the corresponding two consecutive right parenthesis '))'.
    -

    In other words, we treat '(' as openning parenthesis and '))' as closing parenthesis.

    +

    In other words, we treat '(' as an opening parenthesis and '))' as a closing parenthesis.

    -

    For example, "())", "())(())))" and "(())())))" are balanced, ")()", "()))" and "(()))" are not balanced.

    +
      +
    • For example, "())", "())(())))" and "(())())))" are balanced, ")()", "()))" and "(()))" are not balanced.
    • +

    You can insert the characters '(' and ')' at any position of the string to balance it if needed.

    @@ -51,27 +53,11 @@ Explanation: Add '(' to match the first '))', Add '))' to match the last '('. -

    Example 4:

    - -
    -Input: s = "(((((("
    -Output: 12
    -Explanation: Add 12 ')' to balance the string.
    -
    - -

    Example 5:

    - -
    -Input: s = ")))))))"
    -Output: 5
    -Explanation: Add 4 '(' at the beginning of the string and one ')' at the end. The string becomes "(((())))))))".
    -
    -

     

    Constraints:

      -
    • 1 <= s.length <= 10^5
    • +
    • 1 <= s.length <= 105
    • s consists of '(' and ')' only.
    diff --git a/problems/minimum-interval-to-include-each-query/README.md b/problems/minimum-interval-to-include-each-query/README.md index 4cfe2d11c..f9a6134b5 100644 --- a/problems/minimum-interval-to-include-each-query/README.md +++ b/problems/minimum-interval-to-include-each-query/README.md @@ -56,8 +56,8 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Sorting](../../tag/sorting/README.md)] [[Line Sweep](../../tag/line-sweep/README.md)] + [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints diff --git a/problems/minimum-jumps-to-reach-home/README.md b/problems/minimum-jumps-to-reach-home/README.md index d9e52ef2a..5f74939af 100644 --- a/problems/minimum-jumps-to-reach-home/README.md +++ b/problems/minimum-jumps-to-reach-home/README.md @@ -62,9 +62,9 @@ ### Related Topics + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] ### Hints
    diff --git a/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md b/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md index 486ed61bd..34b543908 100644 --- a/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md +++ b/problems/minimum-moves-to-move-a-box-to-their-target-location/README.md @@ -30,26 +30,26 @@

     

    Example 1:

    - +
     Input: grid = [["#","#","#","#","#","#"],
                    ["#","T","#","#","#","#"],
    -               ["#",".",".","B",".","#"],
    -               ["#",".","#","#",".","#"],
    -               ["#",".",".",".","S","#"],
    -               ["#","#","#","#","#","#"]]
    +               ["#",".",".","B",".","#"],
    +               ["#",".","#","#",".","#"],
    +               ["#",".",".",".","S","#"],
    +               ["#","#","#","#","#","#"]]
     Output: 3
    -Explanation: We return only the number of times the box is pushed.
    +Explanation: We return only the number of times the box is pushed.

    Example 2:

     Input: grid = [["#","#","#","#","#","#"],
                    ["#","T","#","#","#","#"],
    -               ["#",".",".","B",".","#"],
    -               ["#","#","#","#",".","#"],
    -               ["#",".",".",".","S","#"],
    -               ["#","#","#","#","#","#"]]
    +               ["#",".",".","B",".","#"],
    +               ["#","#","#","#",".","#"],
    +               ["#",".",".",".","S","#"],
    +               ["#","#","#","#","#","#"]]
     Output: -1
     
    @@ -57,22 +57,13 @@
     Input: grid = [["#","#","#","#","#","#"],
    -               ["#","T",".",".","#","#"],
    -               ["#",".","#","B",".","#"],
    -               ["#",".",".",".",".","#"],
    -               ["#",".",".",".","S","#"],
    -               ["#","#","#","#","#","#"]]
    +               ["#","T",".",".","#","#"],
    +               ["#",".","#","B",".","#"],
    +               ["#",".",".",".",".","#"],
    +               ["#",".",".",".","S","#"],
    +               ["#","#","#","#","#","#"]]
     Output: 5
    -Explanation:  push the box down, left, left, up and up.
    -
    - -

    Example 4:

    - -
    -Input: grid = [["#","#","#","#","#","#","#"],
    -               ["#","S","#",".","B","T","#"],
    -               ["#","#","#","#","#","#","#"]]
    -Output: -1
    +Explanation: push the box down, left, left, up and up.
     

     

    diff --git a/problems/minimum-moves-to-reach-target-score/README.md b/problems/minimum-moves-to-reach-target-score/README.md new file mode 100644 index 000000000..03f9395f4 --- /dev/null +++ b/problems/minimum-moves-to-reach-target-score/README.md @@ -0,0 +1,82 @@ + + + + + + + +[< Previous](../divide-a-string-into-groups-of-size-k "Divide a String Into Groups of Size k") +                 +[Next >](../solving-questions-with-brainpower "Solving Questions With Brainpower") + +## [2139. Minimum Moves to Reach Target Score (Medium)](https://leetcode.com/problems/minimum-moves-to-reach-target-score "得到目标值的最少行动次数") + +

    You are playing a game with integers. You start with the integer 1 and you want to reach the integer target.

    + +

    In one move, you can either:

    + +
      +
    • Increment the current integer by one (i.e., x = x + 1).
    • +
    • Double the current integer (i.e., x = 2 * x).
    • +
    + +

    You can use the increment operation any number of times, however, you can only use the double operation at most maxDoubles times.

    + +

    Given the two integers target and maxDoubles, return the minimum number of moves needed to reach target starting with 1.

    + +

     

    +

    Example 1:

    + +
    +Input: target = 5, maxDoubles = 0
    +Output: 4
    +Explanation: Keep incrementing by 1 until you reach target.
    +
    + +

    Example 2:

    + +
    +Input: target = 19, maxDoubles = 2
    +Output: 7
    +Explanation: Initially, x = 1
    +Increment 3 times so x = 4
    +Double once so x = 8
    +Increment once so x = 9
    +Double again so x = 18
    +Increment once so x = 19
    +
    + +

    Example 3:

    + +
    +Input: target = 10, maxDoubles = 4
    +Output: 4
    +Explanation: Initially, x = 1
    +Increment once so x = 2
    +Double once so x = 4
    +Increment once so x = 5
    +Double again so x = 10
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= target <= 109
    • +
    • 0 <= maxDoubles <= 100
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] + +### Hints +
    +Hint 1 +Solve the opposite problem: start at the given score and move to 1. +
    + +
    +Hint 2 +It is better to use the move of the second type once we can to lose more scores fast. +
    diff --git a/problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses/README.md b/problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses/README.md new file mode 100644 index 000000000..8a0798f2f --- /dev/null +++ b/problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../count-common-words-with-one-occurrence "Count Common Words With One Occurrence") +                 +[Next >](../minimum-cost-homecoming-of-a-robot-in-a-grid "Minimum Cost Homecoming of a Robot in a Grid") + +## [2086. Minimum Number of Buckets Required to Collect Rainwater from Houses (Medium)](https://leetcode.com/problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses "从房屋收集雨水需要的最少水桶数") + +

    You are given a 0-indexed string street. Each character in street is either 'H' representing a house or '.' representing an empty space.

    + +

    You can place buckets on the empty spaces to collect rainwater that falls from the adjacent houses. The rainwater from a house at index i is collected if a bucket is placed at index i - 1 and/or index i + 1. A single bucket, if placed adjacent to two houses, can collect the rainwater from both houses.

    + +

    Return the minimum number of buckets needed so that for every house, there is at least one bucket collecting rainwater from it, or -1 if it is impossible.

    + +

     

    +

    Example 1:

    + +
    +Input: street = "H..H"
    +Output: 2
    +Explanation:
    +We can put buckets at index 1 and index 2.
    +"H..H" -> "HBBH" ('B' denotes where a bucket is placed).
    +The house at index 0 has a bucket to its right, and the house at index 3 has a bucket to its left.
    +Thus, for every house, there is at least one bucket collecting rainwater from it.
    +
    + +

    Example 2:

    + +
    +Input: street = ".H.H."
    +Output: 1
    +Explanation:
    +We can put a bucket at index 2.
    +".H.H." -> ".HBH." ('B' denotes where a bucket is placed).
    +The house at index 1 has a bucket to its right, and the house at index 3 has a bucket to its left.
    +Thus, for every house, there is at least one bucket collecting rainwater from it.
    +
    + +

    Example 3:

    + +
    +Input: street = ".HHH."
    +Output: -1
    +Explanation:
    +There is no empty space to place a bucket to collect the rainwater from the house at index 2.
    +Thus, it is impossible to collect the rainwater from all the houses.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= street.length <= 105
    • +
    • street[i] is either'H' or '.'.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +When is it impossible to collect the rainwater from all the houses? +
    + +
    +Hint 2 +When one or more houses do not have an empty space adjacent to it. +
    + +
    +Hint 3 +Assuming the rainwater from all previous houses is collected. If there is a house at index i and you are able to place a bucket at index i - 1 or i + 1, where should you put it? +
    + +
    +Hint 4 +It is always better to place a bucket at index i + 1 because it can collect the rainwater from the next house as well. +
    diff --git a/problems/minimum-number-of-days-to-disconnect-island/README.md b/problems/minimum-number-of-days-to-disconnect-island/README.md index 26163ef0f..2f96201d0 100644 --- a/problems/minimum-number-of-days-to-disconnect-island/README.md +++ b/problems/minimum-number-of-days-to-disconnect-island/README.md @@ -11,73 +11,47 @@ ## [1568. Minimum Number of Days to Disconnect Island (Hard)](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数") -

    Given a 2D grid consisting of 1s (land) and 0s (water).  An island is a maximal 4-directionally (horizontal or vertical) connected group of 1s.

    +

    You are given an m x n binary grid grid where 1 represents land and 0 represents water. An island is a maximal 4-directionally (horizontal or vertical) connected group of 1's.

    -

    The grid is said to be connected if we have exactly one island, otherwise is said disconnected.

    +

    The grid is said to be connected if we have exactly one island, otherwise is said disconnected.

    In one day, we are allowed to change any single land cell (1) into a water cell (0).

    -

    Return the minimum number of days to disconnect the grid.

    +

    Return the minimum number of days to disconnect the grid.

     

    Example 1:

    - -

    - +
     Input: grid = [[0,1,1,0],[0,1,1,0],[0,0,0,0]]
    +
     Output: 2
     Explanation: We need at least 2 days to get a disconnected grid.
     Change land grid[1][1] and grid[0][2] to water and get 2 disconnected island.
     

    Example 2:

    - +
     Input: grid = [[1,1]]
     Output: 2
    -Explanation: Grid of full water is also disconnected ([[1,1]] -> [[0,0]]), 0 islands.
    -
    - -

    Example 3:

    - -
    -Input: grid = [[1,0,1,0]]
    -Output: 0
    -
    - -

    Example 4:

    - -
    -Input: grid = [[1,1,0,1,1],
    -               [1,1,1,1,1],
    -               [1,1,0,1,1],
    -               [1,1,0,1,1]]
    -Output: 1
    -
    - -

    Example 5:

    - -
    -Input: grid = [[1,1,0,1,1],
    -               [1,1,1,1,1],
    -               [1,1,0,1,1],
    -               [1,1,1,1,1]]
    -Output: 2
    +Explanation: Grid of full water is also disconnected ([[1,1]] -> [[0,0]]), 0 islands.
     

     

    Constraints:

      -
    • 1 <= grid.length, grid[i].length <= 30
    • -
    • grid[i][j] is 0 or 1.
    • +
    • m == grid.length
    • +
    • n == grid[i].length
    • +
    • 1 <= m, n <= 30
    • +
    • grid[i][j] is either 0 or 1.
    ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Strongly Connected Component](../../tag/strongly-connected-component/README.md)] diff --git a/problems/minimum-number-of-days-to-eat-n-oranges/README.md b/problems/minimum-number-of-days-to-eat-n-oranges/README.md index 2f250b084..ef9a3d0c3 100644 --- a/problems/minimum-number-of-days-to-eat-n-oranges/README.md +++ b/problems/minimum-number-of-days-to-eat-n-oranges/README.md @@ -15,13 +15,13 @@
    • Eat one orange.
    • -
    • If the number of remaining oranges n is divisible by 2 then you can eat n / 2 oranges.
    • -
    • If the number of remaining oranges n is divisible by 3 then you can eat 2 * (n / 3) oranges.
    • +
    • If the number of remaining oranges n is divisible by 2 then you can eat n / 2 oranges.
    • +
    • If the number of remaining oranges n is divisible by 3 then you can eat 2 * (n / 3) oranges.

    You can only choose one of the actions per day.

    -

    Return the minimum number of days to eat n oranges.

    +

    Given the integer n, return the minimum number of days to eat n oranges.

     

    Example 1:

    @@ -49,20 +49,6 @@ Day 3: Eat the last orange 1 - 1 = 0. You need at least 3 days to eat the 6 oranges. -

    Example 3:

    - -
    -Input: n = 1
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: n = 56
    -Output: 6
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-number-of-days-to-make-m-bouquets/README.md b/problems/minimum-number-of-days-to-make-m-bouquets/README.md index 79478879e..23c7493b3 100644 --- a/problems/minimum-number-of-days-to-make-m-bouquets/README.md +++ b/problems/minimum-number-of-days-to-make-m-bouquets/README.md @@ -11,13 +11,13 @@ ## [1482. Minimum Number of Days to Make m Bouquets (Medium)](https://leetcode.com/problems/minimum-number-of-days-to-make-m-bouquets "制作 m 束花所需的最少天数") -

    Given an integer array bloomDay, an integer m and an integer k.

    +

    You are given an integer array bloomDay, an integer m and an integer k.

    -

    We need to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden.

    +

    You want to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden.

    -

    The garden consists of n flowers, the ith flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet.

    +

    The garden consists of n flowers, the ith flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet.

    -

    Return the minimum number of days you need to wait to be able to make m bouquets from the garden. If it is impossible to make m bouquets return -1.

    +

    Return the minimum number of days you need to wait to be able to make m bouquets from the garden. If it is impossible to make m bouquets return -1.

     

    Example 1:

    @@ -25,7 +25,7 @@
     Input: bloomDay = [1,10,3,10,2], m = 3, k = 1
     Output: 3
    -Explanation: Let's see what happened in the first three days. x means flower bloomed and _ means flower didn't bloom in the garden.
    +Explanation: Let us see what happened in the first three days. x means flower bloomed and _ means flower did not bloom in the garden.
     We need 3 bouquets each should contain 1 flower.
     After day 1: [x, _, _, _, _]   // we can only make one bouquet.
     After day 2: [x, _, _, _, x]   // we can only make two bouquets.
    @@ -46,36 +46,21 @@ After day 3: [x, _, x, _, x]   // we can make 3 bouquets. The answer is 3.
     Input: bloomDay = [7,7,7,7,12,7,7], m = 2, k = 3
     Output: 12
     Explanation: We need 2 bouquets each should have 3 flowers.
    -Here's the garden after the 7 and 12 days:
    +Here is the garden after the 7 and 12 days:
     After day 7: [x, x, x, x, _, x, x]
     We can make one bouquet of the first three flowers that bloomed. We cannot make another bouquet from the last three flowers that bloomed because they are not adjacent.
     After day 12: [x, x, x, x, x, x, x]
     It is obvious that we can make two bouquets in different ways.
     
    -

    Example 4:

    - -
    -Input: bloomDay = [1000000000,1000000000], m = 1, k = 1
    -Output: 1000000000
    -Explanation: You need to wait 1000000000 days to have a flower ready for a bouquet.
    -
    - -

    Example 5:

    - -
    -Input: bloomDay = [1,10,2,9,3,8,4,7,5,6], m = 4, k = 2
    -Output: 9
    -
    -

     

    Constraints:

    • bloomDay.length == n
    • -
    • 1 <= n <= 10^5
    • -
    • 1 <= bloomDay[i] <= 10^9
    • -
    • 1 <= m <= 10^6
    • +
    • 1 <= n <= 105
    • +
    • 1 <= bloomDay[i] <= 109
    • +
    • 1 <= m <= 106
    • 1 <= k <= n
    @@ -85,6 +70,7 @@ It is obvious that we can make two bouquets in different ways. ### Similar Questions 1. [Maximize the Confusion of an Exam](../maximize-the-confusion-of-an-exam) (Medium) + 1. [Earliest Possible Day of Full Bloom](../earliest-possible-day-of-full-bloom) (Hard) ### Hints
    diff --git a/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md b/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md index 0dcbfe47e..1dc73d265 100644 --- a/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md +++ b/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/README.md @@ -33,22 +33,15 @@
     Input: mat = [[0]]
     Output: 0
    -Explanation: Given matrix is a zero matrix. We don't need to change it.
    +Explanation: Given matrix is a zero matrix. We do not need to change it.
     

    Example 3:

    -
    -Input: mat = [[1,1,1],[1,0,1],[0,0,0]]
    -Output: 6
    -
    - -

    Example 4:

    -
     Input: mat = [[1,0,0],[1,0,0]]
     Output: -1
    -Explanation: Given matrix can't be a zero matrix
    +Explanation: Given matrix cannot be a zero matrix.
     

     

    @@ -67,6 +60,10 @@ [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [Minimum Operations to Remove Adjacent Ones in Matrix](../minimum-operations-to-remove-adjacent-ones-in-matrix) (Hard) + 1. [Remove All Ones With Row and Column Flips](../remove-all-ones-with-row-and-column-flips) (Medium) + ### Hints
    Hint 1 diff --git a/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md b/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md index d2ff2706f..48368b32a 100644 --- a/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md +++ b/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/README.md @@ -11,24 +11,24 @@ ## [1526. Minimum Number of Increments on Subarrays to Form a Target Array (Hard)](https://leetcode.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array "形成目标数组的子数组最少增加次数") -

    Given an array of positive integers target and an array initial of same size with all zeros.

    +

    You are given an integer array target. You have an integer array initial of the same size as target with all elements initially zeros.

    -

    Return the minimum number of operations to form a target array from initial if you are allowed to do the following operation:

    +

    In one operation you can choose any subarray from initial and increment each value by one.

    + +

    Return the minimum number of operations to form a target array from initial.

    + +

    The test cases are generated so that the answer fits in a 32-bit integer.

    -
      -
    • Choose any subarray from initial and increment each value by one.
    • -
    -The answer is guaranteed to fit within the range of a 32-bit signed integer.

     

    Example 1:

     Input: target = [1,2,3,2,1]
     Output: 3
    -Explanation: We need at least 3 operations to form the target array from the initial array.
    -[0,0,0,0,0] increment 1 from index 0 to 4 (inclusive).
    -[1,1,1,1,1] increment 1 from index 1 to 3 (inclusive).
    -[1,2,2,2,1] increment 1 at index 2.
    +Explanation: We need at least 3 operations to form the target array from the initial array.
    +[0,0,0,0,0] increment 1 from index 0 to 4 (inclusive).
    +[1,1,1,1,1] increment 1 from index 1 to 3 (inclusive).
    +[1,2,2,2,1] increment 1 at index 2.
     [1,2,3,2,1] target array is formed.
     
    @@ -37,7 +37,7 @@ The answer is guaranteed to fit within the range of a 32-bit signed integer.
     Input: target = [3,1,1,2]
     Output: 4
    -Explanation: (initial)[0,0,0,0] -> [1,1,1,1] -> [1,1,1,2] -> [2,1,1,2] -> [3,1,1,2] (target).
    +Explanation: [0,0,0,0] -> [1,1,1,1] -> [1,1,1,2] -> [2,1,1,2] -> [3,1,1,2]
     

    Example 3:

    @@ -45,23 +45,15 @@ The answer is guaranteed to fit within the range of a 32-bit signed integer.
     Input: target = [3,1,5,4,2]
     Output: 7
    -Explanation: (initial)[0,0,0,0,0] -> [1,1,1,1,1] -> [2,1,1,1,1] -> [3,1,1,1,1] 
    -                                  -> [3,1,2,2,2] -> [3,1,3,3,2] -> [3,1,4,4,2] -> [3,1,5,4,2] (target).
    -
    - -

    Example 4:

    - -
    -Input: target = [1,1,1,1]
    -Output: 1
    +Explanation: [0,0,0,0,0] -> [1,1,1,1,1] -> [2,1,1,1,1] -> [3,1,1,1,1] -> [3,1,2,2,2] -> [3,1,3,3,2] -> [3,1,4,4,2] -> [3,1,5,4,2].
     

     

    Constraints:

      -
    • 1 <= target.length <= 10^5
    • -
    • 1 <= target[i] <= 10^5
    • +
    • 1 <= target.length <= 105
    • +
    • 1 <= target[i] <= 105
    ### Related Topics diff --git a/problems/minimum-number-of-lines-to-cover-points/README.md b/problems/minimum-number-of-lines-to-cover-points/README.md new file mode 100644 index 000000000..582bba6e1 --- /dev/null +++ b/problems/minimum-number-of-lines-to-cover-points/README.md @@ -0,0 +1,45 @@ + + + + + + + +[< Previous](../maximum-good-people-based-on-statements "Maximum Good People Based on Statements") +                 +[Next >](../the-number-of-passengers-in-each-bus-ii "The Number of Passengers in Each Bus II") + +## [2152. Minimum Number of Lines to Cover Points (Medium)](https://leetcode.com/problems/minimum-number-of-lines-to-cover-points "") + + + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Geometry](../../tag/geometry/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] + [[Bitmask](../../tag/bitmask/README.md)] + +### Hints +
    +Hint 1 +What is the highest possible answer for a set of n points? +
    + +
    +Hint 2 +The highest possible answer is n / 2 (rounded up). This is because you can cover at least two points with a line, and if n is odd, you need to add one extra line to cover the last point. +
    + +
    +Hint 3 +Suppose you have a line covering two points, how can you quickly check if a third point is also covered by that line? +
    + +
    +Hint 4 +Calculate the slope from the first point to the second point. If the slope from the first point to the third point is the same, then it is also covered by that line. +
    diff --git a/problems/minimum-number-of-operations-to-make-string-sorted/README.md b/problems/minimum-number-of-operations-to-make-string-sorted/README.md index 7aa3e5a7d..60c4203fb 100644 --- a/problems/minimum-number-of-operations-to-make-string-sorted/README.md +++ b/problems/minimum-number-of-operations-to-make-string-sorted/README.md @@ -46,19 +46,6 @@ Operation 1: i=3, j=4. Swap s[2] and s[4] to get s="aaaab", then rever Operation 2: i=4, j=4. Swap s[3] and s[4] to get s="aaaab", then reverse the substring starting at 4. Now, s="aaaab". -

    Example 3:

    - -
    -Input: s = "cdbea"
    -Output: 63
    - -

    Example 4:

    - -
    -Input: s = "leetcodeleetcodeleetcode"
    -Output: 982157772
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md b/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md index 3f34200f4..42d3cc5e1 100644 --- a/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md +++ b/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/README.md @@ -50,6 +50,9 @@ [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Minimum Cost to Move Chips to The Same Position](../minimum-cost-to-move-chips-to-the-same-position) (Easy) + ### Hints
    Hint 1 diff --git a/problems/minimum-number-of-refueling-stops/README.md b/problems/minimum-number-of-refueling-stops/README.md index c990e21b1..1cc8c8b1f 100644 --- a/problems/minimum-number-of-refueling-stops/README.md +++ b/problems/minimum-number-of-refueling-stops/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../advantage-shuffle "Advantage Shuffle") @@ -61,7 +61,7 @@ We made 2 refueling stops along the way, so we return 2. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/minimum-number-of-removals-to-make-mountain-array/README.md b/problems/minimum-number-of-removals-to-make-mountain-array/README.md index 7f2ca1d02..bfc45b56b 100644 --- a/problems/minimum-number-of-removals-to-make-mountain-array/README.md +++ b/problems/minimum-number-of-removals-to-make-mountain-array/README.md @@ -42,20 +42,6 @@ Explanation: One solution is to remove the elements at indices 0, 1, and 5, making the array nums = [1,5,6,3,1]. -

    Example 3:

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

    Example 4:

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

     

    Constraints:

    diff --git a/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md b/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md index 5038dbee9..22618114e 100644 --- a/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md +++ b/problems/minimum-number-of-steps-to-make-two-strings-anagram/README.md @@ -11,11 +11,11 @@ ## [1347. Minimum Number of Steps to Make Two Strings Anagram (Medium)](https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram "制造字母异位词的最小步骤数") -

    Given two equal-size strings s and t. In one step you can choose any character of t and replace it with another character.

    +

    You are given two strings of the same length s and t. In one step you can choose any character of t and replace it with another character.

    -

    Return the minimum number of steps to make t an anagram of s.

    +

    Return the minimum number of steps to make t an anagram of s.

    -

    An Anagram of a string is a string that contains the same characters with a different (or the same) ordering.

    +

    An Anagram of a string is a string that contains the same characters with a different (or the same) ordering.

     

    Example 1:

    @@ -42,27 +42,13 @@ Explanation: "anagram" and "mangaar" are anagrams. -

    Example 4:

    - -
    -Input: s = "xxyyzz", t = "xxyyzz"
    -Output: 0
    -
    - -

    Example 5:

    - -
    -Input: s = "friend", t = "family"
    -Output: 4
    -
    -

     

    Constraints:

      -
    • 1 <= s.length <= 50000
    • +
    • 1 <= s.length <= 5 * 104
    • s.length == t.length
    • -
    • s and t contain lower-case English letters only.
    • +
    • s and t consist of lowercase English letters only.
    ### Related Topics diff --git a/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md b/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md index 179da70b9..51d236eaa 100644 --- a/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md +++ b/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/README.md @@ -51,8 +51,8 @@ The string is now alternating. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md b/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md index 3f1157121..c44128242 100644 --- a/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md +++ b/problems/minimum-number-of-taps-to-open-to-water-a-garden/README.md @@ -42,27 +42,6 @@ Opening Only the second tap will water the whole garden [0,5] Explanation: Even if you activate all the four taps you cannot water the whole garden. -

    Example 3:

    - -
    -Input: n = 7, ranges = [1,2,1,0,2,1,0,1]
    -Output: 3
    -
    - -

    Example 4:

    - -
    -Input: n = 8, ranges = [4,0,0,0,0,0,0,0,4]
    -Output: 2
    -
    - -

    Example 5:

    - -
    -Input: n = 8, ranges = [4,0,0,0,4,0,0,0,4]
    -Output: 1
    -
    -

     

    Constraints:

    @@ -73,9 +52,9 @@ Opening Only the second tap will water the whole garden [0,5] ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md b/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md index 9fcfb0f7e..78c2033c8 100644 --- a/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md +++ b/problems/minimum-numbers-of-function-calls-to-make-target-array/README.md @@ -11,13 +11,13 @@ ## [1558. Minimum Numbers of Function Calls to Make Target Array (Medium)](https://leetcode.com/problems/minimum-numbers-of-function-calls-to-make-target-array "得到目标数组的最少函数调用次数") -

    +

    You are given an integer array nums. You have an integer array arr of the same length with all values set to 0 initially. You also have the following modify function:

    + +

    You want to use the modify function to covert arr to nums using the minimum number of calls.

    -

    Your task is to form an integer array nums from an initial array of zeros arr that is the same size as nums.

    +

    Return the minimum number of function calls to make nums from arr.

    -

    Return the minimum number of function calls to make nums from arr.

    - -

    The answer is guaranteed to fit in a 32-bit signed integer.

    +

    The test cases are generated so that the answer fits in a 32-bit signed integer.

     

    Example 1:

    @@ -49,26 +49,12 @@ Total of operations: 2 + 1 = 3. Explanation: (initial)[0,0,0] -> [1,0,0] -> [1,0,1] -> [2,0,2] -> [2,1,2] -> [4,2,4] -> [4,2,5](nums). -

    Example 4:

    - -
    -Input: nums = [3,2,2,4]
    -Output: 7
    -
    - -

    Example 5:

    - -
    -Input: nums = [2,4,8,16]
    -Output: 8
    -
    -

     

    Constraints:

      -
    • 1 <= nums.length <= 10^5
    • -
    • 0 <= nums[i] <= 10^9
    • +
    • 1 <= nums.length <= 105
    • +
    • 0 <= nums[i] <= 109
    ### Related Topics diff --git a/problems/minimum-one-bit-operations-to-make-integers-zero/README.md b/problems/minimum-one-bit-operations-to-make-integers-zero/README.md index 6daae4a00..8051fc22e 100644 --- a/problems/minimum-one-bit-operations-to-make-integers-zero/README.md +++ b/problems/minimum-one-bit-operations-to-make-integers-zero/README.md @@ -23,45 +23,24 @@

     

    Example 1:

    -
    -Input: n = 0
    -Output: 0
    -
    - -

    Example 2:

    -
     Input: n = 3
     Output: 2
     Explanation: The binary representation of 3 is "11".
    -"11" -> "01" with the 2nd operation since the 0th bit is 1.
    -"01" -> "00" with the 1st operation.
    +"11" -> "01" with the 2nd operation since the 0th bit is 1.
    +"01" -> "00" with the 1st operation.
     
    -

    Example 3:

    +

    Example 2:

     Input: n = 6
     Output: 4
     Explanation: The binary representation of 6 is "110".
    -"110" -> "010" with the 2nd operation since the 1st bit is 1 and 0th through 0th bits are 0.
    -"010" -> "011" with the 1st operation.
    -"011" -> "001" with the 2nd operation since the 0th bit is 1.
    -"001" -> "000" with the 1st operation.
    -
    - -

    Example 4:

    - -
    -Input: n = 9
    -Output: 14
    -
    - -

    Example 5:

    - -
    -Input: n = 333
    -Output: 393
    +"110" -> "010" with the 2nd operation since the 1st bit is 1 and 0th through 0th bits are 0.
    +"010" -> "011" with the 1st operation.
    +"011" -> "001" with the 2nd operation since the 0th bit is 1.
    +"001" -> "000" with the 1st operation.
     

     

    @@ -72,9 +51,12 @@ ### Related Topics + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Memoization](../../tag/memoization/README.md)] - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Similar Questions + 1. [Minimum Number of Operations to Make Array Continuous](../minimum-number-of-operations-to-make-array-continuous) (Hard) ### Hints
    diff --git a/problems/minimum-operations-to-convert-number/README.md b/problems/minimum-operations-to-convert-number/README.md index 941b3a389..dbf649ccb 100644 --- a/problems/minimum-operations-to-convert-number/README.md +++ b/problems/minimum-operations-to-convert-number/README.md @@ -11,7 +11,7 @@ ## [2059. Minimum Operations to Convert Number (Medium)](https://leetcode.com/problems/minimum-operations-to-convert-number "转化数字的最小运算数") -

    You are given a 0-indexed integer array nums containing distinct numbers, an integer start, and an integer goal. There is an integer x that is initially set to start, and you want to perform operations on x such that it is converted to goal. You can perform the following operation repeatedly on the number x:

    +

    You are given a 0-indexed integer array nums containing distinct numbers, an integer start, and an integer goal. There is an integer x that is initially set to start, and you want to perform operations on x such that it is converted to goal. You can perform the following operation repeatedly on the number x:

    If 0 <= x <= 1000, then for any index i in the array (0 <= i < nums.length), you can set x to any of the following:

    @@ -28,56 +28,31 @@

     

    Example 1:

    -
    -Input: nums = [1,3], start = 6, goal = 4
    -Output: 2
    -Explanation:
    -We can go from 6 → 7 → 4 with the following 2 operations.
    -- 6 ^ 1 = 7
    -- 7 ^ 3 = 4
    -
    - -

    Example 2:

    -
     Input: nums = [2,4,12], start = 2, goal = 12
     Output: 2
    -Explanation:
    -We can go from 2 → 14 → 12 with the following 2 operations.
    +Explanation: We can go from 2 → 14 → 12 with the following 2 operations.
     - 2 + 12 = 14
     - 14 - 2 = 12
     
    -

    Example 3:

    +

    Example 2:

     Input: nums = [3,5,7], start = 0, goal = -4
     Output: 2
    -Explanation:
    -We can go from 0 → 3 → -4 with the following 2 operations. 
    +Explanation: We can go from 0 → 3 → -4 with the following 2 operations. 
     - 0 + 3 = 3
     - 3 - 7 = -4
     Note that the last operation sets x out of the range 0 <= x <= 1000, which is valid.
     
    -

    Example 4:

    +

    Example 3:

     Input: nums = [2,8,16], start = 0, goal = 1
     Output: -1
    -Explanation:
    -There is no way to convert 0 into 1.
    - -

    Example 5:

    - -
    -Input: nums = [1], start = 0, goal = 3
    -Output: 3
    -Explanation: 
    -We can go from 0 → 1 → 2 → 3 with the following 3 operations. 
    -- 0 + 1 = 1 
    -- 1 + 1 = 2
    -- 2 + 1 = 3
    +Explanation: There is no way to convert 0 into 1.
     

     

    diff --git a/problems/minimum-operations-to-make-the-array-alternating/README.md b/problems/minimum-operations-to-make-the-array-alternating/README.md new file mode 100644 index 000000000..8b1fec07d --- /dev/null +++ b/problems/minimum-operations-to-make-the-array-alternating/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../count-operations-to-obtain-zero "Count Operations to Obtain Zero") +                 +[Next >](../removing-minimum-number-of-magic-beans "Removing Minimum Number of Magic Beans") + +## [2170. Minimum Operations to Make the Array Alternating (Medium)](https://leetcode.com/problems/minimum-operations-to-make-the-array-alternating "使数组变成交替数组的最少操作数") + +

    You are given a 0-indexed array nums consisting of n positive integers.

    + +

    The array nums is called alternating if:

    + +
      +
    • nums[i - 2] == nums[i], where 2 <= i <= n - 1.
    • +
    • nums[i - 1] != nums[i], where 1 <= i <= n - 1.
    • +
    + +

    In one operation, you can choose an index i and change nums[i] into any positive integer.

    + +

    Return the minimum number of operations required to make the array alternating.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [3,1,3,2,4,3]
    +Output: 3
    +Explanation:
    +One way to make the array alternating is by converting it to [3,1,3,1,3,1].
    +The number of operations required in this case is 3.
    +It can be proven that it is not possible to make the array alternating in less than 3 operations. 
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,2,2,2,2]
    +Output: 2
    +Explanation:
    +One way to make the array alternating is by converting it to [1,2,1,2,1].
    +The number of operations required in this case is 2.
    +Note that the array cannot be converted to [2,2,2,2,2] because in this case nums[0] == nums[1] which violates the conditions of an alternating array.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • 1 <= nums[i] <= 105
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Counting](../../tag/counting/README.md)] + +### Hints +
    +Hint 1 +Count the frequency of each element in odd positions in the array. Do the same for elements in even positions. +
    + +
    +Hint 2 +To minimize the number of operations we need to maximize the number of elements we keep from the original array. +
    + +
    +Hint 3 +What are the possible combinations of elements we can choose from odd indices and even indices so that the number of unchanged elements is maximized? +
    diff --git a/problems/minimum-operations-to-make-the-array-k-increasing/README.md b/problems/minimum-operations-to-make-the-array-k-increasing/README.md new file mode 100644 index 000000000..3ecfaec2b --- /dev/null +++ b/problems/minimum-operations-to-make-the-array-k-increasing/README.md @@ -0,0 +1,100 @@ + + + + + + + +[< Previous](../number-of-smooth-descent-periods-of-a-stock "Number of Smooth Descent Periods of a Stock") +                 +[Next >](../the-airport-with-the-most-traffic "The Airport With the Most Traffic") + +## [2111. Minimum Operations to Make the Array K-Increasing (Hard)](https://leetcode.com/problems/minimum-operations-to-make-the-array-k-increasing "使数组 K 递增的最少操作次数") + +

    You are given a 0-indexed array arr consisting of n positive integers, and a positive integer k.

    + +

    The array arr is called K-increasing if arr[i-k] <= arr[i] holds for every index i, where k <= i <= n-1.

    + +
      +
    • For example, arr = [4, 1, 5, 2, 6, 2] is K-increasing for k = 2 because: +
        +
      • arr[0] <= arr[2] (4 <= 5)
      • +
      • arr[1] <= arr[3] (1 <= 2)
      • +
      • arr[2] <= arr[4] (5 <= 6)
      • +
      • arr[3] <= arr[5] (2 <= 2)
      • +
      +
    • +
    • However, the same arr is not K-increasing for k = 1 (because arr[0] > arr[1]) or k = 3 (because arr[0] > arr[3]).
    • +
    + +

    In one operation, you can choose an index i and change arr[i] into any positive integer.

    + +

    Return the minimum number of operations required to make the array K-increasing for the given k.

    + +

     

    +

    Example 1:

    + +
    +Input: arr = [5,4,3,2,1], k = 1
    +Output: 4
    +Explanation:
    +For k = 1, the resultant array has to be non-decreasing.
    +Some of the K-increasing arrays that can be formed are [5,6,7,8,9], [1,1,1,1,1], [2,2,3,4,4]. All of them require 4 operations.
    +It is suboptimal to change the array to, for example, [6,7,8,9,10] because it would take 5 operations.
    +It can be shown that we cannot make the array K-increasing in less than 4 operations.
    +
    + +

    Example 2:

    + +
    +Input: arr = [4,1,5,2,6,2], k = 2
    +Output: 0
    +Explanation:
    +This is the same example as the one in the problem description.
    +Here, for every index i where 2 <= i <= 5, arr[i-2] <= arr[i].
    +Since the given array is already K-increasing, we do not need to perform any operations.
    + +

    Example 3:

    + +
    +Input: arr = [4,1,5,2,6,2], k = 3
    +Output: 2
    +Explanation:
    +Indices 3 and 5 are the only ones not satisfying arr[i-3] <= arr[i] for 3 <= i <= 5.
    +One of the ways we can make the array K-increasing is by changing arr[3] to 4 and arr[5] to 5.
    +The array will now be [4,1,5,4,6,5].
    +Note that there can be other ways to make the array K-increasing, but none of them require less than 2 operations.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= arr.length <= 105
    • +
    • 1 <= arr[i], k <= arr.length
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +Can we divide the array into non-overlapping subsequences and simplify the problem? +
    + +
    +Hint 2 +In the final array, arr[i-k] ≤ arr[i] should hold. We can use this to divide the array into at most k non-overlapping sequences, where arr[i] will belong to the (i%k)th sequence. +
    + +
    +Hint 3 +Now our problem boils down to performing the minimum operations on each sequence such that it becomes non-decreasing. Our answer will be the sum of operations on each sequence. +
    + +
    +Hint 4 +Which indices of a sequence should we not change in order to count the minimum operations? Can finding the longest non-decreasing subsequence of the sequence help? +
    diff --git a/problems/minimum-operations-to-remove-adjacent-ones-in-matrix/README.md b/problems/minimum-operations-to-remove-adjacent-ones-in-matrix/README.md new file mode 100644 index 000000000..1d0824208 --- /dev/null +++ b/problems/minimum-operations-to-remove-adjacent-ones-in-matrix/README.md @@ -0,0 +1,40 @@ + + + + + + + +[< Previous](../recover-the-original-array "Recover the Original Array") +                 +[Next >](../check-if-all-as-appears-before-all-bs "Check if All A's Appears Before All B's") + +## [2123. Minimum Operations to Remove Adjacent Ones in Matrix (Hard)](https://leetcode.com/problems/minimum-operations-to-remove-adjacent-ones-in-matrix "") + + + +### Related Topics + [[Graph](../../tag/graph/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Consider each cell containing a 1 as a vertex whose neighbors are the cells 4-directionally connected to it. The grid then becomes a bipartite graph. +
    + +
    +Hint 2 +You want to find the smallest set of vertices such that every edge in the graph has an endpoint in this set. If you remove every vertex in this set from the graph, then all the 1’s will be disconnected. Are there any well-known algorithms for finding this set? +
    + +
    +Hint 3 +This set of vertices is called a minimum vertex cover. You can find the size of a minimum vertex cover by finding the size of a maximum matching (Konig’s theorem). +
    + +
    +Hint 4 +There are well-known algorithms such as Kuhn’s algorithm and Hopcroft-Karp-Karzanov algorithm which can find a maximum matching in a bipartite graph quickly. +
    diff --git a/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md b/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md index 6c894f63b..2bf5130bc 100644 --- a/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md +++ b/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-submatrices-with-all-ones "Count Submatrices With All Ones") @@ -11,11 +11,9 @@ ## [1505. Minimum Possible Integer After at Most K Adjacent Swaps On Digits (Hard)](https://leetcode.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "最多 K 次交换相邻数位后得到的最小整数") -

    Given a string num representing the digits of a very large integer and an integer k.

    +

    You are given a string num representing the digits of a very large integer and an integer k. You are allowed to swap any two adjacent digits of the integer at most k times.

    -

    You are allowed to swap any two adjacent digits of the integer at most k times.

    - -

    Return the minimum integer you can obtain also as a string.

    +

    Return the minimum integer you can obtain also as a string.

     

    Example 1:

    @@ -42,34 +40,20 @@ Explanation: We can keep the number without any swaps. -

    Example 4:

    - -
    -Input: num = "22", k = 22
    -Output: "22"
    -
    - -

    Example 5:

    - -
    -Input: num = "9438957234785635408", k = 23
    -Output: "0345989723478563548"
    -
    -

     

    Constraints:

      -
    • 1 <= num.length <= 30000
    • -
    • num contains digits only and doesn't have leading zeros.
    • -
    • 1 <= k <= 10^9
    • +
    • 1 <= num.length <= 3 * 104
    • +
    • num consists of only digits and does not contain leading zeros.
    • +
    • 1 <= k <= 104
    ### Related Topics - [[String](../../tag/string/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] + [[String](../../tag/string/README.md)] ### Hints
    diff --git a/problems/minimum-remove-to-make-valid-parentheses/README.md b/problems/minimum-remove-to-make-valid-parentheses/README.md index 370877ada..3dc52b55e 100644 --- a/problems/minimum-remove-to-make-valid-parentheses/README.md +++ b/problems/minimum-remove-to-make-valid-parentheses/README.md @@ -47,13 +47,6 @@ Explanation: An empty string is also valid. -

    Example 4:

    - -
    -Input: s = "(a(b(c)d)"
    -Output: "a(b(c)d)"
    -
    -

     

    Constraints:

    diff --git a/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md b/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md index 0e88486e6..788e77637 100644 --- a/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md +++ b/problems/minimum-skips-to-arrive-at-meeting-on-time/README.md @@ -72,6 +72,9 @@ You can skip the first and third rest to arrive in ((7/2 + 0) + (3/2 + 0) [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Minimum Speed to Arrive on Time](../minimum-speed-to-arrive-on-time) (Medium) + ### Hints
    Hint 1 diff --git a/problems/minimum-space-wasted-from-packaging/README.md b/problems/minimum-space-wasted-from-packaging/README.md index a012e8bca..5dc48480a 100644 --- a/problems/minimum-space-wasted-from-packaging/README.md +++ b/problems/minimum-space-wasted-from-packaging/README.md @@ -68,8 +68,8 @@ The total waste is (5-3) + (5-5) + (10-8) + (10-10) + (14-11) + (14-12) = 9. ### Related Topics [[Array](../../tag/array/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Prefix Sum](../../tag/prefix-sum/README.md)] [[Sorting](../../tag/sorting/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints
    diff --git a/problems/minimum-subsequence-in-non-increasing-order/README.md b/problems/minimum-subsequence-in-non-increasing-order/README.md index af2af0779..d9e699479 100644 --- a/problems/minimum-subsequence-in-non-increasing-order/README.md +++ b/problems/minimum-subsequence-in-non-increasing-order/README.md @@ -50,8 +50,8 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/minimum-suffix-flips/README.md b/problems/minimum-suffix-flips/README.md new file mode 100644 index 000000000..2208589ce --- /dev/null +++ b/problems/minimum-suffix-flips/README.md @@ -0,0 +1,70 @@ + + + + + + + +[< Previous](../shuffle-string "Shuffle String") +                 +[Next >](../number-of-good-leaf-nodes-pairs "Number of Good Leaf Nodes Pairs") + +## [1529. Minimum Suffix Flips (Medium)](https://leetcode.com/problems/minimum-suffix-flips "最少的后缀翻转次数") + +

    You are given a 0-indexed binary string target of length n. You have another binary string s of length n that is initially set to all zeros. You want to make s equal to target.

    + +

    In one operation, you can pick an index i where 0 <= i < n and flip all bits in the inclusive range [i, n - 1]. Flip means changing '0' to '1' and '1' to '0'.

    + +

    Return the minimum number of operations needed to make s equal to target.

    + +

     

    +

    Example 1:

    + +
    +Input: target = "10111"
    +Output: 3
    +Explanation: Initially, s = "00000".
    +Choose index i = 2: "00000" -> "00111"
    +Choose index i = 0: "00111" -> "11000"
    +Choose index i = 1: "11000" -> "10111"
    +We need at least 3 flip operations to form target.
    +
    + +

    Example 2:

    + +
    +Input: target = "101"
    +Output: 3
    +Explanation: Initially, s = "000".
    +Choose index i = 0: "000" -> "111"
    +Choose index i = 1: "111" -> "100"
    +Choose index i = 2: "100" -> "101"
    +We need at least 3 flip operations to form target.
    +
    + +

    Example 3:

    + +
    +Input: target = "00000"
    +Output: 0
    +Explanation: We do not need any operations since the initial s already equals target.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == target.length
    • +
    • 1 <= n <= 105
    • +
    • target[i] is either '0' or '1'.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Consider a strategy where the choice of bulb with number i is increasing. In such a strategy, you no longer need to worry about bulbs that have been set to the left. +
    diff --git a/problems/minimum-sum-of-four-digit-number-after-splitting-digits/README.md b/problems/minimum-sum-of-four-digit-number-after-splitting-digits/README.md new file mode 100644 index 000000000..a961edf68 --- /dev/null +++ b/problems/minimum-sum-of-four-digit-number-after-splitting-digits/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../order-two-columns-independently "Order Two Columns Independently") +                 +[Next >](../partition-array-according-to-given-pivot "Partition Array According to Given Pivot") + +## [2160. Minimum Sum of Four Digit Number After Splitting Digits (Easy)](https://leetcode.com/problems/minimum-sum-of-four-digit-number-after-splitting-digits "拆分数位后四位数字的最小和") + +

    You are given a positive integer num consisting of exactly four digits. Split num into two new integers new1 and new2 by using the digits found in num. Leading zeros are allowed in new1 and new2, and all the digits found in num must be used.

    + +
      +
    • For example, given num = 2932, you have the following digits: two 2's, one 9 and one 3. Some of the possible pairs [new1, new2] are [22, 93], [23, 92], [223, 9] and [2, 329].
    • +
    + +

    Return the minimum possible sum of new1 and new2.

    + +

     

    +

    Example 1:

    + +
    +Input: num = 2932
    +Output: 52
    +Explanation: Some possible pairs [new1, new2] are [29, 23], [223, 9], etc.
    +The minimum sum can be obtained by the pair [29, 23]: 29 + 23 = 52.
    +
    + +

    Example 2:

    + +
    +Input: num = 4009
    +Output: 13
    +Explanation: Some possible pairs [new1, new2] are [0, 49], [490, 0], etc. 
    +The minimum sum can be obtained by the pair [4, 9]: 4 + 9 = 13.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1000 <= num <= 9999
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Math](../../tag/math/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Notice that the most optimal way to obtain the minimum possible sum using 4 digits is by summing up two 2-digit numbers. +
    + +
    +Hint 2 +We can use the two smallest digits out of the four as the digits found in the tens place respectively. +
    + +
    +Hint 3 +Similarly, we use the final 2 larger digits as the digits found in the ones place. +
    diff --git a/problems/minimum-swaps-to-group-all-1s-together-ii/README.md b/problems/minimum-swaps-to-group-all-1s-together-ii/README.md new file mode 100644 index 000000000..f254b9dd9 --- /dev/null +++ b/problems/minimum-swaps-to-group-all-1s-together-ii/README.md @@ -0,0 +1,91 @@ + + + + + + + +[< Previous](../check-if-every-row-and-column-contains-all-numbers "Check if Every Row and Column Contains All Numbers") +                 +[Next >](../count-words-obtained-after-adding-a-letter "Count Words Obtained After Adding a Letter") + +## [2134. Minimum Swaps to Group All 1's Together II (Medium)](https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii "最少交换次数来组合所有的 1 II") + +

    A swap is defined as taking two distinct positions in an array and swapping the values in them.

    + +

    A circular array is defined as an array where we consider the first element and the last element to be adjacent.

    + +

    Given a binary circular array nums, return the minimum number of swaps required to group all 1's present in the array together at any location.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [0,1,0,1,1,0,0]
    +Output: 1
    +Explanation: Here are a few of the ways to group all the 1's together:
    +[0,0,1,1,1,0,0] using 1 swap.
    +[0,1,1,1,0,0,0] using 1 swap.
    +[1,1,0,0,0,0,1] using 2 swaps (using the circular property of the array).
    +There is no way to group all 1's together with 0 swaps.
    +Thus, the minimum number of swaps required is 1.
    +
    + +

    Example 2:

    + +
    +Input: nums = [0,1,1,1,0,0,1,1,0]
    +Output: 2
    +Explanation: Here are a few of the ways to group all the 1's together:
    +[1,1,1,0,0,0,0,1,1] using 2 swaps (using the circular property of the array).
    +[1,1,1,1,1,0,0,0,0] using 2 swaps.
    +There is no way to group all 1's together with 0 or 1 swaps.
    +Thus, the minimum number of swaps required is 2.
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,1,0,0,1]
    +Output: 0
    +Explanation: All the 1's are already grouped together due to the circular property of the array.
    +Thus, the minimum number of swaps required is 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • nums[i] is either 0 or 1.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
    +Hint 1 +Notice that the number of 1’s to be grouped together is fixed. It is the number of 1's the whole array has. +
    + +
    +Hint 2 +Call this number total. We should then check for every subarray of size total (possibly wrapped around), how many swaps are required to have the subarray be all 1’s. +
    + +
    +Hint 3 +The number of swaps required is the number of 0’s in the subarray. +
    + +
    +Hint 4 +To eliminate the circular property of the array, we can append the original array to itself. Then, we check each subarray of length total. +
    + +
    +Hint 5 +How do we avoid recounting the number of 0’s in the subarray each time? The Sliding Window technique can help. +
    diff --git a/problems/minimum-swaps-to-make-sequences-increasing/README.md b/problems/minimum-swaps-to-make-sequences-increasing/README.md index 40e16413e..81ce68ef8 100644 --- a/problems/minimum-swaps-to-make-sequences-increasing/README.md +++ b/problems/minimum-swaps-to-make-sequences-increasing/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../similar-rgb-color "Similar RGB Color") @@ -52,3 +52,6 @@ which are both strictly increasing. ### Related Topics [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Similar Questions + 1. [Minimum Operations to Make the Array K-Increasing](../minimum-operations-to-make-the-array-k-increasing) (Hard) diff --git a/problems/minimum-swaps-to-make-strings-equal/README.md b/problems/minimum-swaps-to-make-strings-equal/README.md index c80adf70c..efa4ee8ed 100644 --- a/problems/minimum-swaps-to-make-strings-equal/README.md +++ b/problems/minimum-swaps-to-make-strings-equal/README.md @@ -21,18 +21,18 @@
     Input: s1 = "xx", s2 = "yy"
     Output: 1
    -Explanation: 
    -Swap s1[0] and s2[1], s1 = "yx", s2 = "yx".
    +Explanation: Swap s1[0] and s2[1], s1 = "yx", s2 = "yx". +

    Example 2:

     Input: s1 = "xy", s2 = "yx"
     Output: 2
    -Explanation: 
    -Swap s1[0] and s2[0], s1 = "yy", s2 = "xx".
    +Explanation: Swap s1[0] and s2[0], s1 = "yy", s2 = "xx".
     Swap s1[0] and s2[1], s1 = "xy", s2 = "xy".
    -Note that you can't swap s1[0] and s1[1] to make s1 equal to "yx", cause we can only swap chars in different strings.
    +Note that you cannot swap s1[0] and s1[1] to make s1 equal to "yx", cause we can only swap chars in different strings. +

    Example 3:

    @@ -41,13 +41,6 @@ Note that you can't swap s1[0] and s1[1] to make s1 equal to "yx", Output: -1 -

    Example 4:

    - -
    -Input: s1 = "xxyyxyxyxx", s2 = "xyyxyxxxyx"
    -Output: 4
    -
    -

     

    Constraints:

    @@ -57,9 +50,12 @@ Note that you can't swap s1[0] and s1[1] to make s1 equal to "yx", ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Similar Questions + 1. [Determine if Two Strings Are Close](../determine-if-two-strings-are-close) (Medium) ### Hints
    diff --git a/problems/minimum-time-for-k-virus-variants-to-spread/README.md b/problems/minimum-time-for-k-virus-variants-to-spread/README.md index 3b5cdd475..c288759ed 100644 --- a/problems/minimum-time-for-k-virus-variants-to-spread/README.md +++ b/problems/minimum-time-for-k-virus-variants-to-spread/README.md @@ -14,10 +14,10 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Geometry](../../tag/geometry/README.md)] [[Enumeration](../../tag/enumeration/README.md)] ### Hints diff --git a/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md b/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md index 72ac218db..7572aba8c 100644 --- a/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md +++ b/problems/minimum-time-to-collect-all-apples-in-a-tree/README.md @@ -52,10 +52,10 @@ ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] ### Hints
    diff --git a/problems/minimum-time-to-make-rope-colorful/README.md b/problems/minimum-time-to-make-rope-colorful/README.md new file mode 100644 index 000000000..0bbeb08a5 --- /dev/null +++ b/problems/minimum-time-to-make-rope-colorful/README.md @@ -0,0 +1,67 @@ + + + + + + + +[< Previous](../number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "Number of Ways Where Square of Number Is Equal to Product of Two Numbers") +                 +[Next >](../remove-max-number-of-edges-to-keep-graph-fully-traversable "Remove Max Number of Edges to Keep Graph Fully Traversable") + +## [1578. Minimum Time to Make Rope Colorful (Medium)](https://leetcode.com/problems/minimum-time-to-make-rope-colorful "使绳子变成彩色的最短时间") + +

    Alice has n balloons arranged on a rope. You are given a 0-indexed string colors where colors[i] is the color of the ith balloon.

    + +

    Alice wants the rope to be colorful. She does not want two consecutive balloons to be of the same color, so she asks Bob for help. Bob can remove some balloons from the rope to make it colorful. You are given a 0-indexed integer array neededTime where neededTime[i] is the time (in seconds) that Bob needs to remove the ith balloon from the rope.

    + +

    Return the minimum time Bob needs to make the rope colorful.

    + +

     

    +

    Example 1:

    + +
    +Input: colors = "abaac", neededTime = [1,2,3,4,5]
    +Output: 3
    +Explanation: In the above image, 'a' is blue, 'b' is red, and 'c' is green.
    +Bob can remove the blue balloon at index 2. This takes 3 seconds.
    +There are no longer two consecutive balloons of the same color. Total time = 3.
    + +

    Example 2:

    + +
    +Input: colors = "abc", neededTime = [1,2,3]
    +Output: 0
    +Explanation: The rope is already colorful. Bob does not need to remove any balloons from the rope.
    +
    + +

    Example 3:

    + +
    +Input: colors = "aabaa", neededTime = [1,2,3,4,1]
    +Output: 2
    +Explanation: Bob will remove the ballons at indices 0 and 4. Each ballon takes 1 second to remove.
    +There are no longer two consecutive balloons of the same color. Total time = 1 + 1 = 2.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == colors.length == neededTime.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= neededTime[i] <= 104
    • +
    • colors contains only lowercase English letters.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Hints +
    +Hint 1 +Maintain the running sum and max value for repeated letters. +
    diff --git a/problems/minimum-time-to-remove-all-cars-containing-illegal-goods/README.md b/problems/minimum-time-to-remove-all-cars-containing-illegal-goods/README.md new file mode 100644 index 000000000..2d0a1ba6c --- /dev/null +++ b/problems/minimum-time-to-remove-all-cars-containing-illegal-goods/README.md @@ -0,0 +1,97 @@ + + + + + + + +[< Previous](../design-bitset "Design Bitset") +                 +[Next >](../unique-substrings-with-equal-digit-frequency "Unique Substrings With Equal Digit Frequency") + +## [2167. Minimum Time to Remove All Cars Containing Illegal Goods (Hard)](https://leetcode.com/problems/minimum-time-to-remove-all-cars-containing-illegal-goods "移除所有载有违禁货物车厢所需的最少时间") + +

    You are given a 0-indexed binary string s which represents a sequence of train cars. s[i] = '0' denotes that the ith car does not contain illegal goods and s[i] = '1' denotes that the ith car does contain illegal goods.

    + +

    As the train conductor, you would like to get rid of all the cars containing illegal goods. You can do any of the following three operations any number of times:

    + +
      +
    1. Remove a train car from the left end (i.e., remove s[0]) which takes 1 unit of time.
    2. +
    3. Remove a train car from the right end (i.e., remove s[s.length - 1]) which takes 1 unit of time.
    4. +
    5. Remove a train car from anywhere in the sequence which takes 2 units of time.
    6. +
    + +

    Return the minimum time to remove all the cars containing illegal goods.

    + +

    Note that an empty sequence of cars is considered to have no cars containing illegal goods.

    + +

     

    +

    Example 1:

    + +
    +Input: s = "1100101"
    +Output: 5
    +Explanation: 
    +One way to remove all the cars containing illegal goods from the sequence is to
    +- remove a car from the left end 2 times. Time taken is 2 * 1 = 2.
    +- remove a car from the right end. Time taken is 1.
    +- remove the car containing illegal goods found in the middle. Time taken is 2.
    +This obtains a total time of 2 + 1 + 2 = 5. 
    +
    +An alternative way is to
    +- remove a car from the left end 2 times. Time taken is 2 * 1 = 2.
    +- remove a car from the right end 3 times. Time taken is 3 * 1 = 3.
    +This also obtains a total time of 2 + 3 = 5.
    +
    +5 is the minimum time taken to remove all the cars containing illegal goods. 
    +There are no other ways to remove them with less time.
    +
    + +

    Example 2:

    + +
    +Input: s = "0010"
    +Output: 2
    +Explanation:
    +One way to remove all the cars containing illegal goods from the sequence is to
    +- remove a car from the left end 3 times. Time taken is 3 * 1 = 3.
    +This obtains a total time of 3.
    +
    +Another way to remove all the cars containing illegal goods from the sequence is to
    +- remove the car containing illegal goods found in the middle. Time taken is 2.
    +This obtains a total time of 2.
    +
    +Another way to remove all the cars containing illegal goods from the sequence is to 
    +- remove a car from the right end 2 times. Time taken is 2 * 1 = 2. 
    +This obtains a total time of 2.
    +
    +2 is the minimum time taken to remove all the cars containing illegal goods. 
    +There are no other ways to remove them with less time.
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= s.length <= 2 * 105
    • +
    • s[i] is either '0' or '1'.
    • +
    + +### Related Topics + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Build an array withoutFirst where withoutFirst[i] stores the minimum time to remove all the cars containing illegal goods from the ‘suffix’ of the sequence starting from the ith car without using any type 1 operations. +
    + +
    +Hint 2 +Next, build an array onlyFirst where onlyFirst[i] stores the minimum time to remove all the cars containing illegal goods from the ‘prefix’ of the sequence ending on the ith car using only type 1 operations. +
    + +
    +Hint 3 +Finally, we can compare the best way to split the operations amongst these two types by finding the minimum time across all onlyFirst[i] + withoutFirst[i + 1]. +
    diff --git a/problems/minimum-time-visiting-all-points/README.md b/problems/minimum-time-visiting-all-points/README.md index a30f21c83..8182cda1a 100644 --- a/problems/minimum-time-visiting-all-points/README.md +++ b/problems/minimum-time-visiting-all-points/README.md @@ -56,9 +56,9 @@ Total time = 7 seconds ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] ### Hints
    diff --git a/problems/missing-number/README.md b/problems/missing-number/README.md index 6537570f6..6c6174e60 100644 --- a/problems/missing-number/README.md +++ b/problems/missing-number/README.md @@ -19,7 +19,7 @@
     Input: nums = [3,0,1]
     Output: 2
    -Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not appear in nums.
    +Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not appear in nums.
     

    Example 2:

    @@ -27,7 +27,7 @@
     Input: nums = [0,1]
     Output: 2
    -Explanation: n = 2 since there are 2 numbers, so all numbers are in the range [0,2]. 2 is the missing number in the range since it does not appear in nums.
    +Explanation: n = 2 since there are 2 numbers, so all numbers are in the range [0,2]. 2 is the missing number in the range since it does not appear in nums.
     

    Example 3:

    @@ -35,15 +35,7 @@
     Input: nums = [9,6,4,2,3,5,7,0,1]
     Output: 8
    -Explanation: n = 9 since there are 9 numbers, so all numbers are in the range [0,9]. 8 is the missing number in the range since it does not appear in nums.
    -
    - -

    Example 4:

    - -
    -Input: nums = [0]
    -Output: 1
    -Explanation: n = 1 since there is 1 number, so all numbers are in the range [0,1]. 1 is the missing number in the range since it does not appear in nums.
    +Explanation: n = 9 since there are 9 numbers, so all numbers are in the range [0,9]. 8 is the missing number in the range since it does not appear in nums.
     

     

    @@ -60,10 +52,10 @@

    Follow up: Could you implement a solution using only O(1) extra space complexity and O(n) runtime complexity?

    ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Similar Questions @@ -71,3 +63,4 @@ 1. [Single Number](../single-number) (Easy) 1. [Find the Duplicate Number](../find-the-duplicate-number) (Medium) 1. [Couples Holding Hands](../couples-holding-hands) (Hard) + 1. [Find Unique Binary String](../find-unique-binary-string) (Medium) diff --git a/problems/monotone-increasing-digits/README.md b/problems/monotone-increasing-digits/README.md index acec2dd07..dca596465 100644 --- a/problems/monotone-increasing-digits/README.md +++ b/problems/monotone-increasing-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sentence-similarity-ii "Sentence Similarity II") diff --git a/problems/monthly-transactions-ii/README.md b/problems/monthly-transactions-ii/README.md index 46803195d..8662b3c72 100644 --- a/problems/monthly-transactions-ii/README.md +++ b/problems/monthly-transactions-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../last-person-to-fit-in-the-bus "Last Person to Fit in the Bus") @@ -82,3 +82,6 @@ Result table: ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Monthly Transactions I](../monthly-transactions-i) (Medium) diff --git a/problems/monthly-transactions-ii/mysql_schemas.sql b/problems/monthly-transactions-ii/mysql_schemas.sql index 7b54c5361..d73b157c0 100644 --- a/problems/monthly-transactions-ii/mysql_schemas.sql +++ b/problems/monthly-transactions-ii/mysql_schemas.sql @@ -1,6 +1,6 @@ -create table if not exists Transactions (id int, country varchar(4), state enum('approved', 'declined'), amount int, trans_date date) +Create table If Not Exists Transactions (id int, country varchar(4), state enum('approved', 'declined'), amount int, trans_date date) ; -create table if not exists Chargebacks (trans_id int, trans_date date) +Create table If Not Exists Chargebacks (trans_id int, trans_date date) ; Truncate table Transactions; insert into Transactions (id, country, state, amount, trans_date) values ('101', 'US', 'approved', '1000', '2019-05-18'); diff --git a/problems/my-calendar-i/README.md b/problems/my-calendar-i/README.md index 11c307265..d8e8ab306 100644 --- a/problems/my-calendar-i/README.md +++ b/problems/my-calendar-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../self-dividing-numbers "Self Dividing Numbers") diff --git a/problems/my-calendar-ii/README.md b/problems/my-calendar-ii/README.md index b7e248b90..07f53d2b3 100644 --- a/problems/my-calendar-ii/README.md +++ b/problems/my-calendar-ii/README.md @@ -39,7 +39,7 @@ MyCalendarTwo myCalendarTwo = new MyCalendarTwo(); myCalendarTwo.book(10, 20); // return True, The event can be booked. myCalendarTwo.book(50, 60); // return True, The event can be booked. myCalendarTwo.book(10, 40); // return True, The event can be double booked. -myCalendarTwo.book(5, 15); // return False, The event ca not be booked, because it would result in a triple booking. +myCalendarTwo.book(5, 15); // return False, The event cannot be booked, because it would result in a triple booking. myCalendarTwo.book(5, 10); // return True, The event can be booked, as it does not use time 10 which is already double booked. myCalendarTwo.book(25, 55); // return True, The event can be booked, as the time in [25, 40) will be double booked with the third event, the time [40, 50) will be single booked, and the time [50, 55) will be double booked with the second event. diff --git a/problems/nearest-exit-from-entrance-in-maze/README.md b/problems/nearest-exit-from-entrance-in-maze/README.md index 6ecf2c2bf..3f05dc6b0 100644 --- a/problems/nearest-exit-from-entrance-in-maze/README.md +++ b/problems/nearest-exit-from-entrance-in-maze/README.md @@ -66,8 +66,8 @@ Thus, the nearest exit is [1,2], which is 2 steps away. ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/new-users-daily-count/README.md b/problems/new-users-daily-count/README.md index 776d40322..76f4e50e6 100644 --- a/problems/new-users-daily-count/README.md +++ b/problems/new-users-daily-count/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../parsing-a-boolean-expression "Parsing A Boolean Expression") diff --git a/problems/non-decreasing-array/README.md b/problems/non-decreasing-array/README.md index de826c401..1bf899059 100644 --- a/problems/non-decreasing-array/README.md +++ b/problems/non-decreasing-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../strange-printer "Strange Printer") @@ -43,3 +43,6 @@ ### Related Topics [[Array](../../tag/array/README.md)] + +### Similar Questions + 1. [Find Good Days to Rob the Bank](../find-good-days-to-rob-the-bank) (Medium) diff --git a/problems/nth-highest-salary/README.md b/problems/nth-highest-salary/README.md index c8364cb74..b810c5eca 100644 --- a/problems/nth-highest-salary/README.md +++ b/problems/nth-highest-salary/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../second-highest-salary "Second Highest Salary") diff --git a/problems/number-of-1-bits/README.md b/problems/number-of-1-bits/README.md index dc25d62d8..0fff41367 100644 --- a/problems/number-of-1-bits/README.md +++ b/problems/number-of-1-bits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-bits "Reverse Bits") diff --git a/problems/number-of-corner-rectangles/README.md b/problems/number-of-corner-rectangles/README.md index d6a1bc642..d504a9398 100644 --- a/problems/number-of-corner-rectangles/README.md +++ b/problems/number-of-corner-rectangles/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../contain-virus "Contain Virus") diff --git a/problems/number-of-dice-rolls-with-target-sum/README.md b/problems/number-of-dice-rolls-with-target-sum/README.md index 8ef9457d8..2a075c709 100644 --- a/problems/number-of-dice-rolls-with-target-sum/README.md +++ b/problems/number-of-dice-rolls-with-target-sum/README.md @@ -11,68 +11,52 @@ ## [1155. Number of Dice Rolls With Target Sum (Medium)](https://leetcode.com/problems/number-of-dice-rolls-with-target-sum "掷骰子的N种方法") -

    You have d dice and each die has f faces numbered 1, 2, ..., f. You are given three integers d, f, and target.

    +

    You have n dice and each die has k faces numbered from 1 to k.

    -

    Return the number of possible ways (out of fd total ways) modulo 109 + 7 to roll the dice so the sum of the face-up numbers equals target.

    +

    Given three integers n, k, and target, return the number of possible ways (out of the kn total ways) to roll the dice so the sum of the face-up numbers equals target. Since the answer may be too large, return it modulo 109 + 7.

     

    Example 1:

    -Input: d = 1, f = 6, target = 3
    +Input: n = 1, k = 6, target = 3
     Output: 1
    -Explanation: 
    -You throw one die with 6 faces.  There is only one way to get a sum of 3.
    +Explanation: You throw one die with 6 faces.
    +There is only one way to get a sum of 3.
     

    Example 2:

    -Input: d = 2, f = 6, target = 7
    +Input: n = 2, k = 6, target = 7
     Output: 6
    -Explanation: 
    -You throw two dice, each with 6 faces.  There are 6 ways to get a sum of 7:
    -1+6, 2+5, 3+4, 4+3, 5+2, 6+1.
    +Explanation: You throw two dice, each with 6 faces.
    +There are 6 ways to get a sum of 7: 1+6, 2+5, 3+4, 4+3, 5+2, 6+1.
     

    Example 3:

    -Input: d = 2, f = 5, target = 10
    -Output: 1
    -Explanation: 
    -You throw two dice, each with 5 faces.  There is only one way to get a sum of 10: 5+5.
    -
    - -

    Example 4:

    - -
    -Input: d = 1, f = 2, target = 3
    -Output: 0
    -Explanation: 
    -You throw one die with 2 faces.  There is no way to get a sum of 3.
    -
    - -

    Example 5:

    - -
    -Input: d = 30, f = 30, target = 500
    +Input: n = 30, k = 30, target = 500
     Output: 222616187
    -Explanation: 
    -The answer must be returned modulo 10^9 + 7.
    +Explanation: The answer must be returned modulo 109 + 7.
     

     

    Constraints:

      -
    • 1 <= d, f <= 30
    • +
    • 1 <= n, k <= 30
    • 1 <= target <= 1000
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Equal Sum Arrays With Minimum Number of Operations](../equal-sum-arrays-with-minimum-number-of-operations) (Medium) + 1. [Find Missing Observations](../find-missing-observations) (Medium) + ### Hints
    Hint 1 diff --git a/problems/number-of-digit-one/README.md b/problems/number-of-digit-one/README.md index 79ca7fbd5..efc194352 100644 --- a/problems/number-of-digit-one/README.md +++ b/problems/number-of-digit-one/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../implement-queue-using-stacks "Implement Queue using Stacks") @@ -36,12 +36,12 @@ ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Math](../../tag/math/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions - 1. [Factorial Trailing Zeroes](../factorial-trailing-zeroes) (Easy) + 1. [Factorial Trailing Zeroes](../factorial-trailing-zeroes) (Medium) 1. [Digit Count in Range](../digit-count-in-range) (Hard) ### Hints diff --git a/problems/number-of-distinct-substrings-in-a-string/README.md b/problems/number-of-distinct-substrings-in-a-string/README.md index cbf499178..97806c83a 100644 --- a/problems/number-of-distinct-substrings-in-a-string/README.md +++ b/problems/number-of-distinct-substrings-in-a-string/README.md @@ -14,11 +14,11 @@ ### Related Topics - [[Trie](../../tag/trie/README.md)] [[String](../../tag/string/README.md)] + [[Trie](../../tag/trie/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] [[Suffix Array](../../tag/suffix-array/README.md)] [[Hash Function](../../tag/hash-function/README.md)] - [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/number-of-good-leaf-nodes-pairs/README.md b/problems/number-of-good-leaf-nodes-pairs/README.md index b7b4d21c1..d01430c7f 100644 --- a/problems/number-of-good-leaf-nodes-pairs/README.md +++ b/problems/number-of-good-leaf-nodes-pairs/README.md @@ -5,19 +5,19 @@ -[< Previous](../bulb-switcher-iv "Bulb Switcher IV") +[< Previous](../minimum-suffix-flips "Minimum Suffix Flips")                  [Next >](../string-compression-ii "String Compression II") ## [1530. Number of Good Leaf Nodes Pairs (Medium)](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs "好叶子节点对的数量") -

    Given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the shortest path between them is less than or equal to distance.

    +

    You are given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the shortest path between them is less than or equal to distance.

    Return the number of good leaf node pairs in the tree.

     

    Example 1:

    - +
     Input: root = [1,2,3,null,4], distance = 3
     Output: 1
    @@ -25,7 +25,7 @@
     

    Example 2:

    - +
     Input: root = [1,2,3,4,5,6,7], distance = 3
     Output: 2
    @@ -40,26 +40,12 @@
     Explanation: The only good pair is [2,5].
     
    -

    Example 4:

    - -
    -Input: root = [100], distance = 1
    -Output: 0
    -
    - -

    Example 5:

    - -
    -Input: root = [1,1,1], distance = 2
    -Output: 1
    -
    -

     

    Constraints:

      -
    • The number of nodes in the tree is in the range [1, 2^10].
    • -
    • Each node's value is between [1, 100].
    • +
    • The number of nodes in the tree is in the range [1, 210].
    • +
    • 1 <= Node.val <= 100
    • 1 <= distance <= 10
    diff --git a/problems/number-of-good-ways-to-split-a-string/README.md b/problems/number-of-good-ways-to-split-a-string/README.md index 93f58f1d9..39d75a7e4 100644 --- a/problems/number-of-good-ways-to-split-a-string/README.md +++ b/problems/number-of-good-ways-to-split-a-string/README.md @@ -11,9 +11,11 @@ ## [1525. Number of Good Ways to Split a String (Medium)](https://leetcode.com/problems/number-of-good-ways-to-split-a-string "字符串的好分割数目") -

    You are given a string s, a split is called good if you can split s into 2 non-empty strings p and q where its concatenation is equal to s and the number of distinct letters in p and q are the same.

    +

    You are given a string s.

    -

    Return the number of good splits you can make in s.

    +

    A split is called good if you can split s into two non-empty strings sleft and sright where their concatenation is equal to s (i.e., sleft + sright = s) and the number of distinct letters in sleft and sright is the same.

    + +

    Return the number of good splits you can make in s.

     

    Example 1:

    @@ -34,29 +36,15 @@
     Input: s = "abcd"
     Output: 1
    -Explanation: Split the string as follows ("ab", "cd").
    -
    - -

    Example 3:

    - -
    -Input: s = "aaaaa"
    -Output: 4
    -Explanation: All possible splits are good.
    - -

    Example 4:

    - -
    -Input: s = "acbadbaada"
    -Output: 2
    +Explanation: Split the string as follows ("ab", "cd").
     

     

    Constraints:

      -
    • s contains only lowercase English letters.
    • -
    • 1 <= s.length <= 10^5
    • +
    • 1 <= s.length <= 105
    • +
    • s consists of only lowercase English letters.
    ### Related Topics diff --git a/problems/number-of-laser-beams-in-a-bank/README.md b/problems/number-of-laser-beams-in-a-bank/README.md new file mode 100644 index 000000000..831713168 --- /dev/null +++ b/problems/number-of-laser-beams-in-a-bank/README.md @@ -0,0 +1,89 @@ + + + + + + + +[< Previous](../check-if-all-as-appears-before-all-bs "Check if All A's Appears Before All B's") +                 +[Next >](../destroying-asteroids "Destroying Asteroids") + +## [2125. Number of Laser Beams in a Bank (Medium)](https://leetcode.com/problems/number-of-laser-beams-in-a-bank "银行中的激光束数量") + +

    Anti-theft security devices are activated inside a bank. You are given a 0-indexed binary string array bank representing the floor plan of the bank, which is an m x n 2D matrix. bank[i] represents the ith row, consisting of '0's and '1's. '0' means the cell is empty, while'1' means the cell has a security device.

    + +

    There is one laser beam between any two security devices if both conditions are met:

    + +
      +
    • The two devices are located on two different rows: r1 and r2, where r1 < r2.
    • +
    • For each row i where r1 < i < r2, there are no security devices in the ith row.
    • +
    + +

    Laser beams are independent, i.e., one beam does not interfere nor join with another.

    + +

    Return the total number of laser beams in the bank.

    + +

     

    +

    Example 1:

    + +
    +Input: bank = ["011001","000000","010100","001000"]
    +Output: 8
    +Explanation: Between each of the following device pairs, there is one beam. In total, there are 8 beams:
    + * bank[0][1] -- bank[2][1]
    + * bank[0][1] -- bank[2][3]
    + * bank[0][2] -- bank[2][1]
    + * bank[0][2] -- bank[2][3]
    + * bank[0][5] -- bank[2][1]
    + * bank[0][5] -- bank[2][3]
    + * bank[2][1] -- bank[3][2]
    + * bank[2][3] -- bank[3][2]
    +Note that there is no beam between any device on the 0th row with any on the 3rd row.
    +This is because the 2nd row contains security devices, which breaks the second condition.
    +
    + +

    Example 2:

    + +
    +Input: bank = ["000","111","000"]
    +Output: 0
    +Explanation: There does not exist two devices located on two different rows.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == bank.length
    • +
    • n == bank[i].length
    • +
    • 1 <= m, n <= 500
    • +
    • bank[i][j] is either '0' or '1'.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +What is the commonality between security devices on the same row? +
    + +
    +Hint 2 +Each device on the same row has the same number of beams pointing towards the devices on the next row with devices. +
    + +
    +Hint 3 +If you were given an integer array where each element is the number of security devices on each row, can you solve it? +
    + +
    +Hint 4 +Convert the input to such an array, skip any row with no security device, then find the sum of the product between adjacent elements. +
    diff --git a/problems/number-of-lines-to-write-string/README.md b/problems/number-of-lines-to-write-string/README.md index bff49cf49..c21fe3637 100644 --- a/problems/number-of-lines-to-write-string/README.md +++ b/problems/number-of-lines-to-write-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../split-array-with-same-average "Split Array With Same Average") diff --git a/problems/number-of-longest-increasing-subsequence/README.md b/problems/number-of-longest-increasing-subsequence/README.md index 9baaae016..b3431dc6c 100644 --- a/problems/number-of-longest-increasing-subsequence/README.md +++ b/problems/number-of-longest-increasing-subsequence/README.md @@ -42,10 +42,10 @@ ### Related Topics - [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] - [[Segment Tree](../../tag/segment-tree/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] + [[Segment Tree](../../tag/segment-tree/README.md)] ### Similar Questions 1. [Longest Increasing Subsequence](../longest-increasing-subsequence) (Medium) diff --git a/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md b/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md index 633560907..fbfb6a7ef 100644 --- a/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md +++ b/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/README.md @@ -11,17 +11,17 @@ ## [1519. Number of Nodes in the Sub-Tree With the Same Label (Medium)](https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label "子树中标签相同的节点数") -

    Given a tree (i.e. a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of the tree is the node 0, and each node of the tree has a label which is a lower-case character given in the string labels (i.e. The node with the number i has the label labels[i]).

    +

    You are given a tree (i.e. a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of the tree is the node 0, and each node of the tree has a label which is a lower-case character given in the string labels (i.e. The node with the number i has the label labels[i]).

    The edges array is given on the form edges[i] = [ai, bi], which means there is an edge between nodes ai and bi in the tree.

    -

    Return an array of size n where ans[i] is the number of nodes in the subtree of the ith node which have the same label as node i.

    +

    Return an array of size n where ans[i] is the number of nodes in the subtree of the ith node which have the same label as node i.

    -

    A subtree of a tree T is the tree consisting of a node in T and all of its descendant nodes.

    +

    A subtree of a tree T is the tree consisting of a node in T and all of its descendant nodes.

     

    Example 1:

    - +
     Input: n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], labels = "abaedcd"
     Output: [2,1,1,1,1,1,1]
    @@ -30,7 +30,7 @@ Node 1 has a label 'b'. The sub-tree of node 1 contains nodes 1,4 and 5,
     

    Example 2:

    - +
     Input: n = 4, edges = [[0,1],[1,2],[0,3]], labels = "bbbb"
     Output: [4,2,1,1]
    @@ -41,37 +41,23 @@ The sub-tree of node 0 contains nodes 0, 1, 2 and 3, all with label 'b',
     

    Example 3:

    - +
     Input: n = 5, edges = [[0,1],[0,2],[1,3],[0,4]], labels = "aabab"
     Output: [3,2,1,1,1]
     
    -

    Example 4:

    - -
    -Input: n = 6, edges = [[0,1],[0,2],[1,3],[3,4],[4,5]], labels = "cbabaa"
    -Output: [1,2,1,1,2,1]
    -
    - -

    Example 5:

    - -
    -Input: n = 7, edges = [[0,1],[1,2],[2,3],[3,4],[4,5],[5,6]], labels = "aaabaaa"
    -Output: [6,5,4,1,3,2,1]
    -
    -

     

    Constraints:

      -
    • 1 <= n <= 10^5
    • +
    • 1 <= n <= 105
    • edges.length == n - 1
    • edges[i].length == 2
    • -
    • 0 <= ai, bi < n
    • -
    • ai != bi
    • +
    • 0 <= ai, bi < n
    • +
    • ai != bi
    • labels.length == n
    • -
    • labels is consisting of only of lower-case English letters.
    • +
    • labels is consisting of only of lowercase English letters.
    ### Related Topics diff --git a/problems/number-of-operations-to-make-network-connected/README.md b/problems/number-of-operations-to-make-network-connected/README.md index 68f9686b0..77fb4cf07 100644 --- a/problems/number-of-operations-to-make-network-connected/README.md +++ b/problems/number-of-operations-to-make-network-connected/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-flips-to-make-a-or-b-equal-to-c "Minimum Flips to Make a OR b Equal to c") @@ -11,15 +11,15 @@ ## [1319. Number of Operations to Make Network Connected (Medium)](https://leetcode.com/problems/number-of-operations-to-make-network-connected "连通网络的操作次数") -

    There are n computers numbered from 0 to n-1 connected by ethernet cables connections forming a network where connections[i] = [a, b] represents a connection between computers a and b. Any computer can reach any other computer directly or indirectly through the network.

    +

    There are n computers numbered from 0 to n - 1 connected by ethernet cables connections forming a network where connections[i] = [ai, bi] represents a connection between computers ai and bi. Any computer can reach any other computer directly or indirectly through the network.

    -

    Given an initial computer network connections. You can extract certain cables between two directly connected computers, and place them between any pair of disconnected computers to make them directly connected. Return the minimum number of times you need to do this in order to make all the computers connected. If it's not possible, return -1. 

    +

    You are given an initial computer network connections. You can extract certain cables between two directly connected computers, and place them between any pair of disconnected computers to make them directly connected.

    + +

    Return the minimum number of times you need to do this in order to make all the computers connected. If it is not possible, return -1.

     

    Example 1:

    - -

    - +
     Input: n = 4, connections = [[0,1],[0,2],[1,2]]
     Output: 1
    @@ -27,9 +27,7 @@
     

    Example 2:

    - -

    - +
     Input: n = 6, connections = [[0,1],[0,2],[0,3],[1,2],[1,3]]
     Output: 2
    @@ -43,22 +41,15 @@
     Explanation: There are not enough cables.
     
    -

    Example 4:

    - -
    -Input: n = 5, connections = [[0,1],[0,2],[3,4],[2,3]]
    -Output: 0
    -
    -

     

    Constraints:

      -
    • 1 <= n <= 10^5
    • -
    • 1 <= connections.length <= min(n*(n-1)/2, 10^5)
    • +
    • 1 <= n <= 105
    • +
    • 1 <= connections.length <= min(n * (n - 1) / 2, 105)
    • connections[i].length == 2
    • -
    • 0 <= connections[i][0], connections[i][1] < n
    • -
    • connections[i][0] != connections[i][1]
    • +
    • 0 <= ai, bi < n
    • +
    • ai != bi
    • There are no repeated connections.
    • No two computers are connected by more than one cable.
    diff --git a/problems/number-of-segments-in-a-string/README.md b/problems/number-of-segments-in-a-string/README.md index 75512a97e..ccd1d349a 100644 --- a/problems/number-of-segments-in-a-string/README.md +++ b/problems/number-of-segments-in-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-genetic-mutation "Minimum Genetic Mutation") @@ -11,7 +11,7 @@ ## [434. Number of Segments in a String (Easy)](https://leetcode.com/problems/number-of-segments-in-a-string "字符串中的单词数") -

    You are given a string s, return the number of segments in the string

    +

    Given a string s, return the number of segments in the string.

    A segment is defined to be a contiguous sequence of non-space characters.

    @@ -31,26 +31,12 @@ Output: 1 -

    Example 3:

    - -
    -Input: s = "love live! mu'sic forever"
    -Output: 4
    -
    - -

    Example 4:

    - -
    -Input: s = ""
    -Output: 0
    -
    -

     

    Constraints:

    • 0 <= s.length <= 300
    • -
    • s consists of lower-case and upper-case English letters, digits or one of the following characters "!@#$%^&*()_+-=',.:".
    • +
    • s consists of lowercase and uppercase English letters, digits, or one of the following characters "!@#$%^&*()_+-=',.:".
    • The only space character in s is ' '.
    diff --git a/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md b/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md index 693b07e4d..72246a390 100644 --- a/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md +++ b/problems/number-of-sets-of-k-non-overlapping-line-segments/README.md @@ -13,7 +13,7 @@

    Given n points on a 1-D plane, where the ith point (from 0 to n-1) is at x = i, find the number of ways we can draw exactly k non-overlapping line segments such that each segment covers two or more points. The endpoints of each segment must have integral coordinates. The k line segments do not have to cover all n points, and they are allowed to share endpoints.

    -

    Return the number of ways we can draw k non-overlapping line segments. Since this number can be huge, return it modulo 109 + 7.

    +

    Return the number of ways we can draw k non-overlapping line segments. Since this number can be huge, return it modulo 109 + 7.

     

    Example 1:

    @@ -21,16 +21,16 @@
     Input: n = 4, k = 2
     Output: 5
    -Explanation: 
    -The two line segments are shown in red and blue.
    -The image above shows the 5 different ways {(0,2),(2,3)}, {(0,1),(1,3)}, {(0,1),(2,3)}, {(1,2),(2,3)}, {(0,1),(1,2)}.
    +Explanation: The two line segments are shown in red and blue. +The image above shows the 5 different ways {(0,2),(2,3)}, {(0,1),(1,3)}, {(0,1),(2,3)}, {(1,2),(2,3)}, {(0,1),(1,2)}. +

    Example 2:

     Input: n = 3, k = 1
     Output: 3
    -Explanation: The 3 ways are {(0,1)}, {(0,2)}, {(1,2)}.
    +Explanation: The 3 ways are {(0,1)}, {(0,2)}, {(1,2)}.
     

    Example 3:

    @@ -38,22 +38,9 @@ The image above shows the 5 different ways {(0,2),(2,3)}, {(0,1),(1,3)}, {(0,1),
     Input: n = 30, k = 7
     Output: 796297179
    -Explanation: The total number of possible ways to draw 7 line segments is 3796297200. Taking this number modulo 109 + 7 gives us 796297179.
    -
    - -

    Example 4:

    - -
    -Input: n = 5, k = 3
    -Output: 7
    +Explanation: The total number of possible ways to draw 7 line segments is 3796297200. Taking this number modulo 109 + 7 gives us 796297179.
     
    -

    Example 5:

    - -
    -Input: n = 3, k = 2
    -Output: 1
    -

     

    Constraints:

    diff --git a/problems/number-of-smooth-descent-periods-of-a-stock/README.md b/problems/number-of-smooth-descent-periods-of-a-stock/README.md new file mode 100644 index 000000000..8a05be526 --- /dev/null +++ b/problems/number-of-smooth-descent-periods-of-a-stock/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../adding-spaces-to-a-string "Adding Spaces to a String") +                 +[Next >](../minimum-operations-to-make-the-array-k-increasing "Minimum Operations to Make the Array K-Increasing") + +## [2110. Number of Smooth Descent Periods of a Stock (Medium)](https://leetcode.com/problems/number-of-smooth-descent-periods-of-a-stock "股票平滑下跌阶段的数目") + +

    You are given an integer array prices representing the daily price history of a stock, where prices[i] is the stock price on the ith day.

    + +

    A smooth descent period of a stock consists of one or more contiguous days such that the price on each day is lower than the price on the preceding day by exactly 1. The first day of the period is exempted from this rule.

    + +

    Return the number of smooth descent periods.

    + +

     

    +

    Example 1:

    + +
    +Input: prices = [3,2,1,4]
    +Output: 7
    +Explanation: There are 7 smooth descent periods:
    +[3], [2], [1], [4], [3,2], [2,1], and [3,2,1]
    +Note that a period with one day is a smooth descent period by the definition.
    +
    + +

    Example 2:

    + +
    +Input: prices = [8,6,7,7]
    +Output: 4
    +Explanation: There are 4 smooth descent periods: [8], [6], [7], and [7]
    +Note that [8,6] is not a smooth descent period as 8 - 6 ≠ 1.
    +
    + +

    Example 3:

    + +
    +Input: prices = [1]
    +Output: 1
    +Explanation: There is 1 smooth descent period: [1]
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= prices.length <= 105
    • +
    • 1 <= prices[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Any array is a series of adjacent longest possible smooth descent periods. For example, [5,3,2,1,7,6] is [5] + [3,2,1] + [7,6]. +
    + +
    +Hint 2 +Think of a 2-pointer approach to traverse the array and find each longest possible period. +
    + +
    +Hint 3 +Suppose you found the longest possible period with a length of k. How many periods are within that period? How can you count them quickly? Think of the formula to calculate the sum of 1, 2, 3, ..., k. +
    diff --git a/problems/number-of-spaces-cleaning-robot-cleaned/README.md b/problems/number-of-spaces-cleaning-robot-cleaned/README.md index f9fed2877..c40efb276 100644 --- a/problems/number-of-spaces-cleaning-robot-cleaned/README.md +++ b/problems/number-of-spaces-cleaning-robot-cleaned/README.md @@ -9,7 +9,7 @@                  [Next >](../count-vowel-substrings-of-a-string "Count Vowel Substrings of a String") -## [2061. Number of Spaces Cleaning Robot Cleaned (Medium)](https://leetcode.com/problems/number-of-spaces-cleaning-robot-cleaned "") +## [2061. Number of Spaces Cleaning Robot Cleaned (Medium)](https://leetcode.com/problems/number-of-spaces-cleaning-robot-cleaned "扫地机器人清扫过的空间个数") diff --git a/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md b/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md index 089c252a9..a94b24aca 100644 --- a/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md +++ b/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/README.md @@ -65,8 +65,11 @@ Step 1) 2 is even, divide by 2 and obtain 1.  ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[String](../../tag/string/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + +### Similar Questions + 1. [Minimum Moves to Reach Target Score](../minimum-moves-to-reach-target-score) (Medium) ### Hints
    diff --git a/problems/number-of-steps-to-reduce-a-number-to-zero/README.md b/problems/number-of-steps-to-reduce-a-number-to-zero/README.md index ac1dab90c..6a5b12197 100644 --- a/problems/number-of-steps-to-reduce-a-number-to-zero/README.md +++ b/problems/number-of-steps-to-reduce-a-number-to-zero/README.md @@ -57,8 +57,12 @@ Step 4) 1 is odd; subtract 1 and obtain 0. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + +### Similar Questions + 1. [Minimum Moves to Reach Target Score](../minimum-moves-to-reach-target-score) (Medium) + 1. [Count Operations to Obtain Zero](../count-operations-to-obtain-zero) (Easy) ### Hints
    diff --git a/problems/number-of-students-doing-homework-at-a-given-time/README.md b/problems/number-of-students-doing-homework-at-a-given-time/README.md index 549a039e0..0378b7668 100644 --- a/problems/number-of-students-doing-homework-at-a-given-time/README.md +++ b/problems/number-of-students-doing-homework-at-a-given-time/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../form-largest-integer-with-digits-that-add-up-to-target "Form Largest Integer With Digits That Add up to Target") @@ -15,7 +15,7 @@

    The ith student started doing their homework at the time startTime[i] and finished it at time endTime[i].

    -

    Return the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime lays in the interval [startTime[i], endTime[i]] inclusive.

    +

    Return the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime lays in the interval [startTime[i], endTime[i]] inclusive.

     

    Example 1:

    @@ -37,27 +37,6 @@ The third student started doing homework at time 3 and finished at time 7 and wa Explanation: The only student was doing their homework at the queryTime. -

    Example 3:

    - -
    -Input: startTime = [4], endTime = [4], queryTime = 5
    -Output: 0
    -
    - -

    Example 4:

    - -
    -Input: startTime = [1,1,1,1], endTime = [1,3,2,4], queryTime = 7
    -Output: 0
    -
    - -

    Example 5:

    - -
    -Input: startTime = [9,8,7,6,5,4,3,2,1], endTime = [10,10,10,10,10,10,10,10,10], queryTime = 5
    -Output: 5
    -
    -

     

    Constraints:

    @@ -65,7 +44,7 @@ The third student started doing homework at time 3 and finished at time 7 and wa
  • startTime.length == endTime.length
  • 1 <= startTime.length <= 100
  • 1 <= startTime[i] <= endTime[i] <= 1000
  • -
  • 1 <= queryTime <= 1000
  • +
  • 1 <= queryTime <= 1000
  • ### Related Topics diff --git a/problems/number-of-students-unable-to-eat-lunch/README.md b/problems/number-of-students-unable-to-eat-lunch/README.md index 0251d8e4b..010fc4510 100644 --- a/problems/number-of-students-unable-to-eat-lunch/README.md +++ b/problems/number-of-students-unable-to-eat-lunch/README.md @@ -60,11 +60,14 @@ Hence all students are able to eat. ### Related Topics + [[Array](../../tag/array/README.md)] [[Stack](../../tag/stack/README.md)] [[Queue](../../tag/queue/README.md)] - [[Array](../../tag/array/README.md)] [[Simulation](../../tag/simulation/README.md)] +### Similar Questions + 1. [Time Needed to Buy Tickets](../time-needed-to-buy-tickets) (Easy) + ### Hints
    Hint 1 diff --git a/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md b/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md index 4eead3055..ea0d4c7dd 100644 --- a/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md +++ b/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/README.md @@ -11,9 +11,7 @@ ## [1343. Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold (Medium)](https://leetcode.com/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold "大小为 K 且平均值大于等于阈值的子数组数目") -

    Given an array of integers arr and two integers k and threshold.

    - -

    Return the number of sub-arrays of size k and average greater than or equal to threshold.

    +

    Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold.

     

    Example 1:

    @@ -26,41 +24,20 @@

    Example 2:

    -
    -Input: arr = [1,1,1,1,1], k = 1, threshold = 0
    -Output: 5
    -
    - -

    Example 3:

    -
     Input: arr = [11,13,17,23,29,31,7,5,2,3], k = 3, threshold = 5
     Output: 6
     Explanation: The first 6 sub-arrays of size 3 have averages greater than 5. Note that averages are not integers.
     
    -

    Example 4:

    - -
    -Input: arr = [7,7,7,7,7,7,7], k = 7, threshold = 7
    -Output: 1
    -
    - -

    Example 5:

    - -
    -Input: arr = [4,4,4,4], k = 4, threshold = 1
    -Output: 1
    -
    -

     

    Constraints:

      -
    • 1 <= arr.length <= 10^5
    • -
    • 1 <= arr[i] <= 10^4
    • +
    • 1 <= arr.length <= 105
    • +
    • 1 <= arr[i] <= 104
    • 1 <= k <= arr.length
    • -
    • 0 <= threshold <= 10^4
    • +
    • 0 <= threshold <= 104
    ### Related Topics diff --git a/problems/number-of-sub-arrays-with-odd-sum/README.md b/problems/number-of-sub-arrays-with-odd-sum/README.md index cbb19a8a7..98a5c903c 100644 --- a/problems/number-of-sub-arrays-with-odd-sum/README.md +++ b/problems/number-of-sub-arrays-with-odd-sum/README.md @@ -57,6 +57,9 @@ All sub-arrays have even sum and the answer is 0. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] +### Similar Questions + 1. [Subsequence of Size K With the Largest Even Sum](../subsequence-of-size-k-with-the-largest-even-sum) (Medium) + ### Hints
    Hint 1 diff --git a/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md b/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md index d049a56a9..e05fcbde2 100644 --- a/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md +++ b/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-array-pairs-are-divisible-by-k "Check If Array Pairs Are Divisible by k") @@ -11,9 +11,9 @@ ## [1498. Number of Subsequences That Satisfy the Given Sum Condition (Medium)](https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition "满足条件的子序列数目") -

    Given an array of integers nums and an integer target.

    +

    You are given an array of integers nums and an integer target.

    -

    Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too large, return it modulo 109 + 7.

    +

    Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too large, return it modulo 109 + 7.

     

    Example 1:

    @@ -21,7 +21,7 @@
     Input: nums = [3,5,6,7], target = 9
     Output: 4
    -Explanation: There are 4 subsequences that satisfy the condition.
    +Explanation: There are 4 subsequences that satisfy the condition.
     [3] -> Min value + max value <= target (3 + 3 <= 9)
     [3,5] -> (3 + 5 <= 9)
     [3,5,6] -> (3 + 6 <= 9)
    @@ -33,25 +33,19 @@
     
     Input: nums = [3,3,6,8], target = 10
     Output: 6
    -Explanation: There are 6 subsequences that satisfy the condition. (nums can have repeated numbers).
    -[3] , [3] , [3,3], [3,6] , [3,6] , [3,3,6]
    +Explanation: There are 6 subsequences that satisfy the condition. (nums can have repeated numbers). +[3] , [3] , [3,3], [3,6] , [3,6] , [3,3,6] +

    Example 3:

     Input: nums = [2,3,3,4,6,7], target = 12
     Output: 61
    -Explanation: There are 63 non-empty subsequences, two of them don't satisfy the condition ([6,7], [7]).
    +Explanation: There are 63 non-empty subsequences, two of them do not satisfy the condition ([6,7], [7]).
     Number of valid subsequences (63 - 2 = 61).
     
    -

    Example 4:

    - -
    -Input: nums = [5,2,4,1,7,6,8], target = 16
    -Output: 127
    -Explanation: All non-empty subset satisfy the condition (2^7 - 1) = 127
    -

     

    Constraints:

    diff --git a/problems/number-of-substrings-with-only-1s/README.md b/problems/number-of-substrings-with-only-1s/README.md index ac9643cdb..3e0062cdb 100644 --- a/problems/number-of-substrings-with-only-1s/README.md +++ b/problems/number-of-substrings-with-only-1s/README.md @@ -40,13 +40,6 @@ Explanation: Each substring contains only 1's characters. -

    Example 4:

    - -
    -Input: s = "000"
    -Output: 0
    -
    -

     

    Constraints:

    @@ -59,6 +52,10 @@ [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Count Number of Homogenous Substrings](../count-number-of-homogenous-substrings) (Medium) + 1. [Count Vowel Substrings of a String](../count-vowel-substrings-of-a-string) (Easy) + ### Hints
    Hint 1 diff --git a/problems/number-of-transactions-per-visit/README.md b/problems/number-of-transactions-per-visit/README.md index 423f88ca9..e08f68f39 100644 --- a/problems/number-of-transactions-per-visit/README.md +++ b/problems/number-of-transactions-per-visit/README.md @@ -95,6 +95,3 @@ Note that we stopped at transactions_count = 3 as this is the maximum number of ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Find the Missing IDs](../find-the-missing-ids) (Medium) diff --git a/problems/number-of-unique-flavors-after-sharing-k-candies/README.md b/problems/number-of-unique-flavors-after-sharing-k-candies/README.md new file mode 100644 index 000000000..e77956fbe --- /dev/null +++ b/problems/number-of-unique-flavors-after-sharing-k-candies/README.md @@ -0,0 +1,35 @@ + + + + + + + +[< Previous](../maximum-fruits-harvested-after-at-most-k-steps "Maximum Fruits Harvested After at Most K Steps") +                 +[Next >](../find-first-palindromic-string-in-the-array "Find First Palindromic String in the Array") + +## [2107. Number of Unique Flavors After Sharing K Candies (Medium)](https://leetcode.com/problems/number-of-unique-flavors-after-sharing-k-candies "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] + +### Hints +
    +Hint 1 +For every group of k consecutive candies, count the number of unique flavors not inside that group. Return the largest number of unique flavors. +
    + +
    +Hint 2 +When calculating an adjacent group of k consecutive candies, can you use some of your previous calculations? +
    + +
    +Hint 3 +Use a sliding window where the window is the group of k consecutive candies you are sharing. Use a hash map to store the number of candies of each type you can keep. +
    diff --git a/problems/number-of-valid-move-combinations-on-chessboard/README.md b/problems/number-of-valid-move-combinations-on-chessboard/README.md index dfb94f7e2..89549528a 100644 --- a/problems/number-of-valid-move-combinations-on-chessboard/README.md +++ b/problems/number-of-valid-move-combinations-on-chessboard/README.md @@ -58,33 +58,6 @@ Explanation: The image above shows the possible squares the piece can move to. -

    Example 4:

    - -
    -Input: pieces = ["rook","rook"], positions = [[1,1],[8,8]]
    -Output: 223
    -Explanation: There are 15 moves for each rook which results in 15 * 15 = 225 move combinations.
    -However, there are two invalid move combinations:
    -- Move both rooks to (8, 1), where they collide.
    -- Move both rooks to (1, 8), where they collide.
    -Thus there are 225 - 2 = 223 valid move combinations.
    -Note that there are two valid move combinations that would result in one rook at (1, 8) and the other at (8, 1).
    -Even though the board state is the same, these two move combinations are considered different since the moves themselves are different.
    -
    - -

    Example 5:

    - -
    -Input: pieces = ["queen","bishop"], positions = [[5,7],[3,4]]
    -Output: 281
    -Explanation: There are 12 * 24 = 288 move combinations.
    -However, there are several invalid move combinations:
    -- If the queen stops at (6, 7), it blocks the bishop from moving to (6, 7) or (7, 8).
    -- If the queen stops at (5, 6), it blocks the bishop from moving to (5, 6), (6, 7), or (7, 8).
    -- If the bishop stops at (5, 2), it blocks the queen from moving to (5, 2) or (5, 1).
    -Of the 288 move combinations, 281 are valid.
    -
    -

     

    Constraints:

    @@ -92,10 +65,10 @@ Of the 288 move combinations, 281 are valid.
  • n == pieces.length
  • n == positions.length
  • 1 <= n <= 4
  • -
  • pieces only contains the strings "rook""queen", and "bishop".
  • +
  • pieces only contains the strings "rook", "queen", and "bishop".
  • There will be at most one queen on the chessboard.
  • 1 <= xi, yi <= 8
  • -
  • Each positions[i] is distinct.
  • +
  • Each positions[i] is distinct.
  • ### Related Topics diff --git a/problems/number-of-valid-words-in-a-sentence/README.md b/problems/number-of-valid-words-in-a-sentence/README.md index 624517eb4..6687e6bd5 100644 --- a/problems/number-of-valid-words-in-a-sentence/README.md +++ b/problems/number-of-valid-words-in-a-sentence/README.md @@ -53,14 +53,6 @@ "stone-game10" is invalid because it contains digits. -

    Example 4:

    - -
    -Input: sentence = "he bought 2 pencils, 3 erasers, and 1  pencil-sharpener."
    -Output: 6
    -Explanation: The valid words in the sentence are "he", "bought", "pencils,", "erasers,", "and", and "pencil-sharpener.".
    -
    -

     

    Constraints:

    diff --git a/problems/number-of-ways-to-divide-a-long-corridor/README.md b/problems/number-of-ways-to-divide-a-long-corridor/README.md new file mode 100644 index 000000000..020172312 --- /dev/null +++ b/problems/number-of-ways-to-divide-a-long-corridor/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../k-highest-ranked-items-within-a-price-range "K Highest Ranked Items Within a Price Range") +                 +[Next >](../count-elements-with-strictly-smaller-and-greater-elements "Count Elements With Strictly Smaller and Greater Elements ") + +## [2147. Number of Ways to Divide a Long Corridor (Hard)](https://leetcode.com/problems/number-of-ways-to-divide-a-long-corridor "分隔长廊的方案数") + +

    Along a long library corridor, there is a line of seats and decorative plants. You are given a 0-indexed string corridor of length n consisting of letters 'S' and 'P' where each 'S' represents a seat and each 'P' represents a plant.

    + +

    One room divider has already been installed to the left of index 0, and another to the right of index n - 1. Additional room dividers can be installed. For each position between indices i - 1 and i (1 <= i <= n - 1), at most one divider can be installed.

    + +

    Divide the corridor into non-overlapping sections, where each section has exactly two seats with any number of plants. There may be multiple ways to perform the division. Two ways are different if there is a position with a room divider installed in the first way but not in the second way.

    + +

    Return the number of ways to divide the corridor. Since the answer may be very large, return it modulo 109 + 7. If there is no way, return 0.

    + +

     

    +

    Example 1:

    + +
    +Input: corridor = "SSPPSPS"
    +Output: 3
    +Explanation: There are 3 different ways to divide the corridor.
    +The black bars in the above image indicate the two room dividers already installed.
    +Note that in each of the ways, each section has exactly two seats.
    +
    + +

    Example 2:

    + +
    +Input: corridor = "PPSPSP"
    +Output: 1
    +Explanation: There is only 1 way to divide the corridor, by not installing any additional dividers.
    +Installing any would create some section that does not have exactly two seats.
    +
    + +

    Example 3:

    + +
    +Input: corridor = "S"
    +Output: 0
    +Explanation: There is no way to divide the corridor because there will always be a section that does not have exactly two seats.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == corridor.length
    • +
    • 1 <= n <= 105
    • +
    • corridor[i] is either 'S' or 'P'.
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +Divide the corridor into segments. Each segment has two seats, starts precisely with one seat, and ends precisely with the other seat. +
    + +
    +Hint 2 +How many dividers can you install between two adjacent segments? You must install precisely one. Otherwise, you would have created a section with not exactly two seats. +
    + +
    +Hint 3 +If there are k plants between two adjacent segments, there are k + 1 positions (ways) you could install the divider you must install. +
    + +
    +Hint 4 +The problem now becomes: Find the product of all possible positions between every two adjacent segments. +
    diff --git a/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md b/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md index 209ae1f48..8ef01bd16 100644 --- a/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md +++ b/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/README.md @@ -22,7 +22,7 @@
  • Repeat the process until you form the string target.
  • -

    Notice that you can use multiple characters from the same string in words provided the conditions above are met.

    +

    Notice that you can use multiple characters from the same string in words provided the conditions above are met.

    Return the number of ways to form target from words. Since the answer may be too large, return it modulo 109 + 7.

    @@ -53,20 +53,6 @@ "bab" -> index 1 ("abba"), index 2 ("baab"), index 3 ("baab") -

    Example 3:

    - -
    -Input: words = ["abcd"], target = "abcd"
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: words = ["abab","baba","abba","baab"], target = "abba"
    -Output: 16
    -
    -

     

    Constraints:

    diff --git a/problems/number-of-ways-to-paint-n-3-grid/README.md b/problems/number-of-ways-to-paint-n-3-grid/README.md index 5b1198fdb..aea32d531 100644 --- a/problems/number-of-ways-to-paint-n-3-grid/README.md +++ b/problems/number-of-ways-to-paint-n-3-grid/README.md @@ -26,27 +26,6 @@

    Example 2:

    -
    -Input: n = 2
    -Output: 54
    -
    - -

    Example 3:

    - -
    -Input: n = 3
    -Output: 246
    -
    - -

    Example 4:

    - -
    -Input: n = 7
    -Output: 106494
    -
    - -

    Example 5:

    -
     Input: n = 5000
     Output: 30228214
    @@ -57,13 +36,15 @@
     
     
    • n == grid.length
    • -
    • grid[i].length == 3
    • 1 <= n <= 5000
    ### Related Topics [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Painting a Grid With Three Different Colors](../painting-a-grid-with-three-different-colors) (Hard) + ### Hints
    Hint 1 diff --git a/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md b/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md index b6a36b36a..698d1d0ed 100644 --- a/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md +++ b/problems/number-of-ways-to-reorder-array-to-get-same-bst/README.md @@ -11,33 +11,31 @@ ## [1569. Number of Ways to Reorder Array to Get Same BST (Hard)](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst "将子数组重新排序得到同一个二叉查找树的方案数") -

    Given an array nums that represents a permutation of integers from 1 to n. We are going to construct a binary search tree (BST) by inserting the elements of nums in order into an initially empty BST. Find the number of different ways to reorder nums so that the constructed BST is identical to that formed from the original array nums.

    +

    Given an array nums that represents a permutation of integers from 1 to n. We are going to construct a binary search tree (BST) by inserting the elements of nums in order into an initially empty BST. Find the number of different ways to reorder nums so that the constructed BST is identical to that formed from the original array nums.

    -

    For example, given nums = [2,1,3], we will have 2 as the root, 1 as a left child, and 3 as a right child. The array [2,3,1] also yields the same BST but [3,2,1] yields a different BST.

    +
      +
    • For example, given nums = [2,1,3], we will have 2 as the root, 1 as a left child, and 3 as a right child. The array [2,3,1] also yields the same BST but [3,2,1] yields a different BST.
    • +
    -

    Return the number of ways to reorder nums such that the BST formed is identical to the original BST formed from nums.

    +

    Return the number of ways to reorder nums such that the BST formed is identical to the original BST formed from nums.

    -

    Since the answer may be very large, return it modulo 10^9 + 7.

    +

    Since the answer may be very large, return it modulo 109 + 7.

     

    Example 1:

    - -

    - +
     Input: nums = [2,1,3]
     Output: 1
    -Explanation: We can reorder nums to be [2,3,1] which will yield the same BST. There are no other ways to reorder nums which will yield the same BST.
    +Explanation: We can reorder nums to be [2,3,1] which will yield the same BST. There are no other ways to reorder nums which will yield the same BST.
     

    Example 2:

    - -

    - +
     Input: nums = [3,4,5,1,2]
     Output: 5
    -Explanation: The following 5 arrays will yield the same BST: 
    +Explanation: The following 5 arrays will yield the same BST: 
     [3,1,2,4,5]
     [3,1,4,2,5]
     [3,1,4,5,2]
    @@ -46,30 +44,11 @@
     

    Example 3:

    - -

    - +
     Input: nums = [1,2,3]
     Output: 0
    -Explanation: There are no other orderings of nums that will yield the same BST.
    -
    - -

    Example 4:

    - -

    - -
    -Input: nums = [3,1,2,5,4,6]
    -Output: 19
    -
    - -

    Example 5:

    - -
    -Input: nums = [9,4,2,1,3,6,5,7,8,14,11,10,12,13,16,15,17,18]
    -Output: 216212978
    -Explanation: The number of ways to reorder nums to get the same BST is 3216212999. Taking this number modulo 10^9 + 7 gives 216212978.
    +Explanation: There are no other orderings of nums that will yield the same BST.
     

     

    @@ -78,20 +57,20 @@
    • 1 <= nums.length <= 1000
    • 1 <= nums[i] <= nums.length
    • -
    • All integers in nums are distinct.
    • +
    • All integers in nums are distinct.
    ### Related Topics - [[Tree](../../tag/tree/README.md)] - [[Union Find](../../tag/union-find/README.md)] - [[Binary Search Tree](../../tag/binary-search-tree/README.md)] - [[Memoization](../../tag/memoization/README.md)] [[Array](../../tag/array/README.md)] [[Math](../../tag/math/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Binary Tree](../../tag/binary-tree/README.md)] + [[Tree](../../tag/tree/README.md)] + [[Union Find](../../tag/union-find/README.md)] + [[Binary Search Tree](../../tag/binary-search-tree/README.md)] + [[Memoization](../../tag/memoization/README.md)] [[Combinatorics](../../tag/combinatorics/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] ### Hints
    diff --git a/problems/number-of-ways-to-separate-numbers/README.md b/problems/number-of-ways-to-separate-numbers/README.md index f305dec5b..1d359dd07 100644 --- a/problems/number-of-ways-to-separate-numbers/README.md +++ b/problems/number-of-ways-to-separate-numbers/README.md @@ -21,7 +21,7 @@
     Input: num = "327"
     Output: 2
    -Explanation: You could have written down the numbers:
    +Explanation: You could have written down the numbers:
     3, 27
     327
     
    @@ -31,7 +31,7 @@
     Input: num = "094"
     Output: 0
    -Explanation: No numbers can have leading zeros and all numbers must be positive.
    +Explanation: No numbers can have leading zeros and all numbers must be positive.
     

    Example 3:

    @@ -39,14 +39,7 @@
     Input: num = "0"
     Output: 0
    -Explanation: No numbers can have leading zeros and all numbers must be positive.
    -
    - -

    Example 4:

    - -
    -Input: num = "9999999999999"
    -Output: 101
    +Explanation: No numbers can have leading zeros and all numbers must be positive.
     

     

    diff --git a/problems/number-of-ways-to-split-a-string/README.md b/problems/number-of-ways-to-split-a-string/README.md index cfdbf11da..9874c1112 100644 --- a/problems/number-of-ways-to-split-a-string/README.md +++ b/problems/number-of-ways-to-split-a-string/README.md @@ -11,11 +11,9 @@ ## [1573. Number of Ways to Split a String (Medium)](https://leetcode.com/problems/number-of-ways-to-split-a-string "分割字符串的方案数") -

    Given a binary string s (a string consisting only of '0's and '1's), we can split s into 3 non-empty strings s1, s2, s3 (s1+ s2+ s3 = s).

    +

    Given a binary string s, you can split s into 3 non-empty strings s1, s2, and s3 where s1 + s2 + s3 = s.

    -

    Return the number of ways s can be split such that the number of characters '1' is the same in s1, s2, and s3.

    - -

    Since the answer may be too large, return it modulo 10^9 + 7.

    +

    Return the number of ways s can be split such that the number of ones is the same in s1, s2, and s3. Since the answer may be too large, return it modulo 109 + 7.

     

    Example 1:

    @@ -48,25 +46,21 @@ "00|0|0"
    -

    Example 4:

    - -
    -Input: s = "100100010100110"
    -Output: 12
    -
    -

     

    Constraints:

      -
    • 3 <= s.length <= 10^5
    • -
    • s[i] is '0' or '1'.
    • +
    • 3 <= s.length <= 105
    • +
    • s[i] is either '0' or '1'.
    ### Related Topics [[Math](../../tag/math/README.md)] [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Split Array with Equal Sum](../split-array-with-equal-sum) (Hard) + ### Hints
    Hint 1 diff --git a/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md b/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md index f49a48d8b..a5b016402 100644 --- a/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md +++ b/problems/number-of-ways-to-wear-different-hats-to-each-other/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../check-if-a-string-can-break-another-string "Check If a String Can Break Another String") @@ -11,13 +11,13 @@ ## [1434. Number of Ways to Wear Different Hats to Each Other (Hard)](https://leetcode.com/problems/number-of-ways-to-wear-different-hats-to-each-other "每个人戴不同帽子的方案数") -

    There are n people and 40 types of hats labeled from 1 to 40.

    +

    There are n people and 40 types of hats labeled from 1 to 40.

    -

    Given a list of list of integers hats, where hats[i] is a list of all hats preferred by the i-th person.

    +

    Given a 2D integer array hats, where hats[i] is a list of all hats preferred by the ith person.

    -

    Return the number of ways that the n people wear different hats to each other.

    +

    Return the number of ways that the n people wear different hats to each other.

    -

    Since the answer may be too large, return it modulo 10^9 + 7.

    +

    Since the answer may be too large, return it modulo 109 + 7.

     

    Example 1:

    @@ -25,15 +25,16 @@
     Input: hats = [[3,4],[4,5],[5]]
     Output: 1
    -Explanation: There is only one way to choose hats given the conditions. 
    -First person choose hat 3, Second person choose hat 4 and last one hat 5.
    +Explanation: There is only one way to choose hats given the conditions. +First person choose hat 3, Second person choose hat 4 and last one hat 5. +

    Example 2:

     Input: hats = [[3,5,1],[3,5]]
     Output: 4
    -Explanation: There are 4 ways to choose hats
    +Explanation: There are 4 ways to choose hats:
     (3,5), (5,3), (1,3) and (1,5)
     
    @@ -42,17 +43,10 @@ First person choose hat 3, Second person choose hat 4 and last one hat 5.
     Input: hats = [[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]]
     Output: 24
    -Explanation: Each person can choose hats labeled from 1 to 4.
    +Explanation: Each person can choose hats labeled from 1 to 4.
     Number of Permutations of (1,2,3,4) = 24.
     
    -

    Example 4:

    - -
    -Input: hats = [[1,2,3],[2,3,5,6],[1,3,7,9],[1,8,9],[2,5,7]]
    -Output: 111
    -
    -

     

    Constraints:

    diff --git a/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md b/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md index 4a9a83b5e..9a7b126db 100644 --- a/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md +++ b/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/README.md @@ -7,15 +7,15 @@ [< Previous](../replace-all-s-to-avoid-consecutive-repeating-characters "Replace All ?'s to Avoid Consecutive Repeating Characters")                  -[Next >](../minimum-deletion-cost-to-avoid-repeating-letters "Minimum Deletion Cost to Avoid Repeating Letters") +[Next >](../minimum-time-to-make-rope-colorful "Minimum Time to Make Rope Colorful") ## [1577. Number of Ways Where Square of Number Is Equal to Product of Two Numbers (Medium)](https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "数的平方等于两数乘积的方法数") -

    Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:

    +

    Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:

      -
    • Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
    • -
    • Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where 0 <= i < nums2.length and 0 <= j < k < nums1.length.
    • +
    • Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.
    • +
    • Type 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where 0 <= i < nums2.length and 0 <= j < k < nums1.length.

     

    @@ -24,7 +24,7 @@
     Input: nums1 = [7,4], nums2 = [5,2,8,9]
     Output: 1
    -Explanation: Type 1: (1,1,2), nums1[1]^2 = nums2[1] * nums2[2]. (4^2 = 2 * 8). 
    +Explanation: Type 1: (1, 1, 2), nums1[1]2 = nums2[1] * nums2[2]. (42 = 2 * 8). 
     

    Example 2:

    @@ -32,9 +32,9 @@
     Input: nums1 = [1,1], nums2 = [1,1,1]
     Output: 9
    -Explanation: All Triplets are valid, because 1^2 = 1 * 1.
    -Type 1: (0,0,1), (0,0,2), (0,1,2), (1,0,1), (1,0,2), (1,1,2).  nums1[i]^2 = nums2[j] * nums2[k].
    -Type 2: (0,0,1), (1,0,1), (2,0,1). nums2[i]^2 = nums1[j] * nums1[k].
    +Explanation: All Triplets are valid, because 12 = 1 * 1.
    +Type 1: (0,0,1), (0,0,2), (0,1,2), (1,0,1), (1,0,2), (1,1,2).  nums1[i]2 = nums2[j] * nums2[k].
    +Type 2: (0,0,1), (1,0,1), (2,0,1). nums2[i]2 = nums1[j] * nums1[k].
     

    Example 3:

    @@ -43,16 +43,8 @@ Type 2: (0,0,1), (1,0,1), (2,0,1). nums2[i]^2 = nums1[j] * nums1[k]. Input: nums1 = [7,7,8,3], nums2 = [1,2,9,7] Output: 2 Explanation: There are 2 valid triplets. -Type 1: (3,0,2). nums1[3]^2 = nums2[0] * nums2[2]. -Type 2: (3,0,1). nums2[3]^2 = nums1[0] * nums1[1]. - - -

    Example 4:

    - -
    -Input: nums1 = [4,7,9,11,23], nums2 = [3,5,1024,12,18]
    -Output: 0
    -Explanation: There are no valid triplets.
    +Type 1: (3,0,2).  nums1[3]2 = nums2[0] * nums2[2].
    +Type 2: (3,0,1).  nums2[3]2 = nums1[0] * nums1[1].
     

     

    @@ -60,7 +52,7 @@ Type 2: (3,0,1). nums2[3]^2 = nums1[0] * nums1[1].
    • 1 <= nums1.length, nums2.length <= 1000
    • -
    • 1 <= nums1[i], nums2[i] <= 10^5
    • +
    • 1 <= nums1[i], nums2[i] <= 105
    ### Related Topics diff --git a/problems/numbers-with-repeated-digits/README.md b/problems/numbers-with-repeated-digits/README.md index 83006a889..4d2f0738f 100644 --- a/problems/numbers-with-repeated-digits/README.md +++ b/problems/numbers-with-repeated-digits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../capacity-to-ship-packages-within-d-days "Capacity To Ship Packages Within D Days") diff --git a/problems/odd-even-jump/README.md b/problems/odd-even-jump/README.md index faf449c89..43a345e2d 100644 --- a/problems/odd-even-jump/README.md +++ b/problems/odd-even-jump/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../subarray-sums-divisible-by-k "Subarray Sums Divisible by K") diff --git a/problems/online-majority-element-in-subarray/README.md b/problems/online-majority-element-in-subarray/README.md index 5dd0844bb..a21a6a7ed 100644 --- a/problems/online-majority-element-in-subarray/README.md +++ b/problems/online-majority-element-in-subarray/README.md @@ -52,11 +52,11 @@ majorityChecker.query(2, 3, 2); // return 2 ### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Design](../../tag/design/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] - [[Array](../../tag/array/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] ### Hints
    diff --git a/problems/order-two-columns-independently/README.md b/problems/order-two-columns-independently/README.md new file mode 100644 index 000000000..24bed0989 --- /dev/null +++ b/problems/order-two-columns-independently/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../amount-of-new-area-painted-each-day "Amount of New Area Painted Each Day") +                 +[Next >](../minimum-sum-of-four-digit-number-after-splitting-digits "Minimum Sum of Four Digit Number After Splitting Digits") + +## [2159. Order Two Columns Independently (Medium)](https://leetcode.com/problems/order-two-columns-independently "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/order-two-columns-independently/mysql_schemas.sql b/problems/order-two-columns-independently/mysql_schemas.sql new file mode 100644 index 000000000..444d9231f --- /dev/null +++ b/problems/order-two-columns-independently/mysql_schemas.sql @@ -0,0 +1,6 @@ +Create table If Not Exists Data (first_col int, second_col int); +Truncate table Data; +insert into Data (first_col, second_col) values ('4', '2'); +insert into Data (first_col, second_col) values ('2', '3'); +insert into Data (first_col, second_col) values ('3', '1'); +insert into Data (first_col, second_col) values ('1', '4'); diff --git a/problems/orders-with-maximum-quantity-above-average/README.md b/problems/orders-with-maximum-quantity-above-average/README.md index 063bde62f..4743751d8 100644 --- a/problems/orders-with-maximum-quantity-above-average/README.md +++ b/problems/orders-with-maximum-quantity-above-average/README.md @@ -9,7 +9,7 @@                  [Next >](../product-of-two-run-length-encoded-arrays "Product of Two Run-Length Encoded Arrays") -## [1867. Orders With Maximum Quantity Above Average (Medium)](https://leetcode.com/problems/orders-with-maximum-quantity-above-average "") +## [1867. Orders With Maximum Quantity Above Average (Medium)](https://leetcode.com/problems/orders-with-maximum-quantity-above-average "最大数量高于平均水平的订单") diff --git a/problems/paint-fence/README.md b/problems/paint-fence/README.md index 3317001f8..508201a5d 100644 --- a/problems/paint-fence/README.md +++ b/problems/paint-fence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../h-index-ii "H-Index II") diff --git a/problems/paint-house-iii/README.md b/problems/paint-house-iii/README.md index 71f75b642..2edda59c6 100644 --- a/problems/paint-house-iii/README.md +++ b/problems/paint-house-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-browser-history "Design Browser History") @@ -19,7 +19,7 @@
  • For example: houses = [1,2,2,3,3,2,1,1] contains 5 neighborhoods [{1}, {2,2}, {3,3}, {2}, {1,1}].
  • -

    Given an array houses, an m x n matrix cost and an integer target where:

    +

    Given an array houses, an m x n matrix cost and an integer target where:

    • houses[i]: is the color of the house i, and 0 if the house is not painted yet.
    • @@ -51,13 +51,6 @@ Cost of paint the first and last house (10 + 1) = 11.

      Example 3:

      -
      -Input: houses = [0,0,0,0,0], cost = [[1,10],[10,1],[1,10],[10,1],[1,10]], m = 5, n = 2, target = 5
      -Output: 5
      -
      - -

      Example 4:

      -
       Input: houses = [3,1,2,3], cost = [[1,1,1],[1,1,1],[1,1,1],[1,1,1]], m = 4, n = 3, target = 3
       Output: -1
      @@ -74,7 +67,7 @@ Cost of paint the first and last house (10 + 1) = 11.
       	
    • 1 <= n <= 20
    • 1 <= target <= m
    • 0 <= houses[i] <= n
    • -
    • 1 <= cost[i][j] <= 10^4
    • +
    • 1 <= cost[i][j] <= 104
    ### Related Topics diff --git a/problems/palindrome-linked-list/README.md b/problems/palindrome-linked-list/README.md index 3baebf8c4..95753900b 100644 --- a/problems/palindrome-linked-list/README.md +++ b/problems/palindrome-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-digit-one "Number of Digit One") diff --git a/problems/palindrome-pairs/README.md b/problems/palindrome-pairs/README.md index 7c370230a..05b89368f 100644 --- a/problems/palindrome-pairs/README.md +++ b/problems/palindrome-pairs/README.md @@ -55,3 +55,4 @@ ### Similar Questions 1. [Longest Palindromic Substring](../longest-palindromic-substring) (Medium) 1. [Shortest Palindrome](../shortest-palindrome) (Hard) + 1. [Longest Palindrome by Concatenating Two Letter Words](../longest-palindrome-by-concatenating-two-letter-words) (Medium) diff --git a/problems/palindrome-partitioning-iii/README.md b/problems/palindrome-partitioning-iii/README.md index b54eb04ff..8116ce7c1 100644 --- a/problems/palindrome-partitioning-iii/README.md +++ b/problems/palindrome-partitioning-iii/README.md @@ -55,6 +55,9 @@ [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Palindrome Partitioning IV](../palindrome-partitioning-iv) (Hard) + ### Hints
    Hint 1 diff --git a/problems/palindrome-removal/README.md b/problems/palindrome-removal/README.md index 63f3f227e..f7b82a429 100644 --- a/problems/palindrome-removal/README.md +++ b/problems/palindrome-removal/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tree-diameter "Tree Diameter") diff --git a/problems/parallel-courses-ii/README.md b/problems/parallel-courses-ii/README.md index 01d706e9c..f3ace5883 100644 --- a/problems/parallel-courses-ii/README.md +++ b/problems/parallel-courses-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-subarray-of-1s-after-deleting-one-element "Longest Subarray of 1's After Deleting One Element") @@ -67,14 +67,11 @@ In the fourth semester, you can take course 5. ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Graph](../../tag/graph/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Bitmask](../../tag/bitmask/README.md)] -### Similar Questions - 1. [Parallel Courses](../parallel-courses) (Medium) - ### Hints
    Hint 1 diff --git a/problems/partition-array-according-to-given-pivot/README.md b/problems/partition-array-according-to-given-pivot/README.md new file mode 100644 index 000000000..c058a818e --- /dev/null +++ b/problems/partition-array-according-to-given-pivot/README.md @@ -0,0 +1,74 @@ + + + + + + + +[< Previous](../minimum-sum-of-four-digit-number-after-splitting-digits "Minimum Sum of Four Digit Number After Splitting Digits") +                 +[Next >](../minimum-cost-to-set-cooking-time "Minimum Cost to Set Cooking Time") + +## [2161. Partition Array According to Given Pivot (Medium)](https://leetcode.com/problems/partition-array-according-to-given-pivot "根据给定数字划分数组") + +

    You are given a 0-indexed integer array nums and an integer pivot. Rearrange nums such that the following conditions are satisfied:

    + +
      +
    • Every element less than pivot appears before every element greater than pivot.
    • +
    • Every element equal to pivot appears in between the elements less than and greater than pivot.
    • +
    • The relative order of the elements less than pivot and the elements greater than pivot is maintained. +
        +
      • More formally, consider every pi, pj where pi is the new position of the ith element and pj is the new position of the jth element. For elements less than pivot, if i < j and nums[i] < pivot and nums[j] < pivot, then pi < pj. Similarly for elements greater than pivot, if i < j and nums[i] > pivot and nums[j] > pivot, then pi < pj.
      • +
      +
    • +
    + +

    Return nums after the rearrangement.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [9,12,5,10,14,3,10], pivot = 10
    +Output: [9,5,3,10,10,12,14]
    +Explanation: 
    +The elements 9, 5, and 3 are less than the pivot so they are on the left side of the array.
    +The elements 12 and 14 are greater than the pivot so they are on the right side of the array.
    +The relative ordering of the elements less than and greater than pivot is also maintained. [9, 5, 3] and [12, 14] are the respective orderings.
    +
    + +

    Example 2:

    + +
    +Input: nums = [-3,4,3,2], pivot = 2
    +Output: [-3,2,4,3]
    +Explanation: 
    +The element -3 is less than the pivot so it is on the left side of the array.
    +The elements 4 and 3 are greater than the pivot so they are on the right side of the array.
    +The relative ordering of the elements less than and greater than pivot is also maintained. [-3] and [4, 3] are the respective orderings.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • -106 <= nums[i] <= 106
    • +
    • pivot equals to an element of nums.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Could you put the elements smaller than the pivot and greater than the pivot in a separate list as in the sequence that they occur? +
    + +
    +Hint 2 +With the separate lists generated, could you then generate the result? +
    diff --git a/problems/partition-list/README.md b/problems/partition-list/README.md index fc0ea514d..e212ee33c 100644 --- a/problems/partition-list/README.md +++ b/problems/partition-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximal-rectangle "Maximal Rectangle") diff --git a/problems/path-sum-ii/README.md b/problems/path-sum-ii/README.md index acd143c07..50e88d874 100644 --- a/problems/path-sum-ii/README.md +++ b/problems/path-sum-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../path-sum "Path Sum") @@ -50,9 +50,9 @@ ### Related Topics - [[Backtracking](../../tag/backtracking/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Backtracking](../../tag/backtracking/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/path-sum/README.md b/problems/path-sum/README.md index db538a498..71194c380 100644 --- a/problems/path-sum/README.md +++ b/problems/path-sum/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../minimum-depth-of-binary-tree "Minimum Depth of Binary Tree") @@ -21,6 +21,7 @@
     Input: root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum = 22
     Output: true
    +Explanation: The root-to-leaf path with the target sum is shown.
     

    Example 2:

    @@ -28,13 +29,18 @@
     Input: root = [1,2,3], targetSum = 5
     Output: false
    +Explanation: There two root-to-leaf paths in the tree:
    +(1 --> 2): The sum is 3.
    +(1 --> 3): The sum is 4.
    +There is no root-to-leaf path with sum = 5.
     

    Example 3:

    -Input: root = [1,2], targetSum = 0
    +Input: root = [], targetSum = 0
     Output: false
    +Explanation: Since the tree is empty, there are no root-to-leaf paths.
     

     

    @@ -49,6 +55,7 @@ ### Related Topics [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/path-with-minimum-effort/README.md b/problems/path-with-minimum-effort/README.md index b964c1049..9cee131df 100644 --- a/problems/path-with-minimum-effort/README.md +++ b/problems/path-with-minimum-effort/README.md @@ -58,17 +58,13 @@ This is better than the route of [1,2,2,2,5], where the maximum absolute differe ### Related Topics - [[Array](../../tag/array/README.md)] - [[Binary Search](../../tag/binary-search/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] [[Matrix](../../tag/matrix/README.md)] - -### Similar Questions - 1. [Swim in Rising Water](../swim-in-rising-water) (Hard) - 1. [Path With Maximum Minimum Value](../path-with-maximum-minimum-value) (Medium) + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] ### Hints
    diff --git a/problems/perfect-rectangle/README.md b/problems/perfect-rectangle/README.md index 8949f5f14..971198a6f 100644 --- a/problems/perfect-rectangle/README.md +++ b/problems/perfect-rectangle/README.md @@ -33,14 +33,6 @@

    Example 3:

    - -
    -Input: rectangles = [[1,1,3,3],[3,1,4,2],[1,3,2,4],[3,2,4,4]]
    -Output: false
    -Explanation: Because there is a gap in the top center.
    -
    - -

    Example 4:

     Input: rectangles = [[1,1,3,3],[3,1,4,2],[1,3,2,4],[2,2,4,4]]
    diff --git a/problems/pizza-with-3n-slices/README.md b/problems/pizza-with-3n-slices/README.md
    index fb5a05914..eb813cd89 100644
    --- a/problems/pizza-with-3n-slices/README.md
    +++ b/problems/pizza-with-3n-slices/README.md
    @@ -1,8 +1,8 @@
     
     
    -
    -
    -
    +
    +
    +
     
     
     [< Previous](../sort-integers-by-the-power-value "Sort Integers by The Power Value")
    @@ -11,24 +11,20 @@
     
     ## [1388. Pizza With 3n Slices (Hard)](https://leetcode.com/problems/pizza-with-3n-slices "3n 块披萨")
     
    -

    There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:

    +

    There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:

    • You will pick any pizza slice.
    • -
    • Your friend Alice will pick next slice in anti clockwise direction of your pick. 
    • -
    • Your friend Bob will pick next slice in clockwise direction of your pick.
    • -
    • Repeat until there are no more slices of pizzas.
    • +
    • Your friend Alice will pick the next slice in the anti-clockwise direction of your pick.
    • +
    • Your friend Bob will pick the next slice in the clockwise direction of your pick.
    • +
    • Repeat until there are no more slices of pizzas.
    -

    Sizes of Pizza slices is represented by circular array slices in clockwise direction.

    - -

    Return the maximum possible sum of slice sizes which you can have.

    +

    Given an integer array slices that represent the sizes of the pizza slices in a clockwise direction, return the maximum possible sum of slice sizes that you can pick.

     

    Example 1:

    - -

    - +
     Input: slices = [1,2,3,4,5,6]
     Output: 10
    @@ -36,35 +32,19 @@
     

    Example 2:

    - -

    - +
     Input: slices = [8,9,8,6,1,1]
     Output: 16
    -Output: Pick pizza slice of size 8 in each turn. If you pick slice with size 9 your partners will pick slices of size 8.
    -
    - -

    Example 3:

    - -
    -Input: slices = [4,1,2,5,8,3,1,9,7]
    -Output: 21
    -
    - -

    Example 4:

    - -
    -Input: slices = [3,1,2]
    -Output: 3
    +Explanation: Pick pizza slice of size 8 in each turn. If you pick slice with size 9 your partners will pick slices of size 8.
     

     

    Constraints:

      +
    • 3 * n == slices.length
    • 1 <= slices.length <= 500
    • -
    • slices.length % 3 == 0
    • 1 <= slices[i] <= 1000
    diff --git a/problems/plus-one-linked-list/README.md b/problems/plus-one-linked-list/README.md index b8d162510..ae6a641b4 100644 --- a/problems/plus-one-linked-list/README.md +++ b/problems/plus-one-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-divisible-subset "Largest Divisible Subset") diff --git a/problems/poor-pigs/README.md b/problems/poor-pigs/README.md index a63d6d81b..ed7c5ff79 100644 --- a/problems/poor-pigs/README.md +++ b/problems/poor-pigs/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../circular-array-loop "Circular Array Loop") diff --git a/problems/populating-next-right-pointers-in-each-node-ii/README.md b/problems/populating-next-right-pointers-in-each-node-ii/README.md index ea527badd..7621d80dc 100644 --- a/problems/populating-next-right-pointers-in-each-node-ii/README.md +++ b/problems/populating-next-right-pointers-in-each-node-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../populating-next-right-pointers-in-each-node "Populating Next Right Pointers in Each Node") @@ -62,6 +62,7 @@ struct Node { [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] + [[Linked List](../../tag/linked-list/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/possible-bipartition/README.md b/problems/possible-bipartition/README.md index 1bd27615c..d37d11381 100644 --- a/problems/possible-bipartition/README.md +++ b/problems/possible-bipartition/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../spiral-matrix-iii "Spiral Matrix III") diff --git a/problems/pour-water-between-buckets-to-make-water-levels-equal/README.md b/problems/pour-water-between-buckets-to-make-water-levels-equal/README.md new file mode 100644 index 000000000..3c977e969 --- /dev/null +++ b/problems/pour-water-between-buckets-to-make-water-levels-equal/README.md @@ -0,0 +1,39 @@ + + + + + + + +[< Previous](../earliest-possible-day-of-full-bloom "Earliest Possible Day of Full Bloom") +                 +[Next >](../divide-a-string-into-groups-of-size-k "Divide a String Into Groups of Size k") + +## [2137. Pour Water Between Buckets to Make Water Levels Equal (Medium)](https://leetcode.com/problems/pour-water-between-buckets-to-make-water-levels-equal "") + + + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Binary Search](../../tag/binary-search/README.md)] + +### Hints +
    +Hint 1 +What is the range that the answer must fall into? +
    + +
    +Hint 2 +The answer has to be in the range [0, max(buckets)] (inclusive). +
    + +
    +Hint 3 +For a number x, is there an efficient way to check if it is possible to make the amount of water in each bucket x. +
    + +
    +Hint 4 +Let in be the total amount of water that needs to be poured into buckets and out be the total amount of water that needs to be poured out of buckets to make the amount of water in each bucket x. If out - (out * loss) >= in, then it is possible. +
    diff --git a/problems/power-of-three/README.md b/problems/power-of-three/README.md index e9bd83b14..1f77942fa 100644 --- a/problems/power-of-three/README.md +++ b/problems/power-of-three/README.md @@ -1,15 +1,15 @@ - - - + + + [< Previous](../maximum-size-subarray-sum-equals-k "Maximum Size Subarray Sum Equals k")                  [Next >](../count-of-range-sum "Count of Range Sum") -## [326. Power of Three (Easy)](https://leetcode.com/problems/power-of-three "3的幂") +## [326. Power of Three (Easy)](https://leetcode.com/problems/power-of-three "3 的幂")

    Given an integer n, return true if it is a power of three. Otherwise, return false.

    @@ -17,18 +17,26 @@

     

    Example 1:

    -
    Input: n = 27
    +
    +
    +Input: n = 27
     Output: true
    -

    Example 2:

    -
    Input: n = 0
    +
    + +

    Example 2:

    + +
    +Input: n = 0
     Output: false
    -

    Example 3:

    -
    Input: n = 9
    +
    + +

    Example 3:

    + +
    +Input: n = 9
     Output: true
    -

    Example 4:

    -
    Input: n = 45
    -Output: false
     
    +

     

    Constraints:

    diff --git a/problems/prime-arrangements/README.md b/problems/prime-arrangements/README.md index b85fa61f2..bb7caddf2 100644 --- a/problems/prime-arrangements/README.md +++ b/problems/prime-arrangements/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../immediate-food-delivery-ii "Immediate Food Delivery II") diff --git a/problems/print-in-order/README.md b/problems/print-in-order/README.md index b97cb6ac8..2f0675943 100644 --- a/problems/print-in-order/README.md +++ b/problems/print-in-order/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reported-posts "Reported Posts") diff --git a/problems/prison-cells-after-n-days/README.md b/problems/prison-cells-after-n-days/README.md index fe203b401..1459ec6aa 100644 --- a/problems/prison-cells-after-n-days/README.md +++ b/problems/prison-cells-after-n-days/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../tallest-billboard "Tallest Billboard") @@ -60,7 +60,7 @@ Day 7: [0, 0, 1, 1, 0, 0, 0, 0] ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] diff --git a/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md b/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md index 40e16a1df..4e558e1e6 100644 --- a/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md +++ b/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/README.md @@ -53,22 +53,6 @@ Probability is 8/12 = 0.66667 Probability = 108 / 180 = 0.6
    -

    Example 4:

    - -
    -Input: balls = [3,2,1]
    -Output: 0.30000
    -Explanation: The set of balls is [1, 1, 1, 2, 2, 3]. It is hard to display all the 60 possible random shuffles of this set but it is easy to check that 18 of them will have the same number of distinct colors in each box.
    -Probability = 18 / 60 = 0.3
    -
    - -

    Example 5:

    - -
    -Input: balls = [6,6,6,6,6,6]
    -Output: 0.90327
    -
    -

     

    Constraints:

    diff --git a/problems/product-of-array-except-self/README.md b/problems/product-of-array-except-self/README.md index 665cd7199..0b3fe0d47 100644 --- a/problems/product-of-array-except-self/README.md +++ b/problems/product-of-array-except-self/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../delete-node-in-a-linked-list "Delete Node in a Linked List") diff --git a/problems/products-price-for-each-store/README.md b/problems/products-price-for-each-store/README.md index 5d46b038f..ad3e0f768 100644 --- a/problems/products-price-for-each-store/README.md +++ b/problems/products-price-for-each-store/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Rearrange Products Table](../rearrange-products-table) (Easy) diff --git a/problems/projection-area-of-3d-shapes/README.md b/problems/projection-area-of-3d-shapes/README.md index 5d23f8dbe..645e1c1af 100644 --- a/problems/projection-area-of-3d-shapes/README.md +++ b/problems/projection-area-of-3d-shapes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reachable-nodes-in-subdivided-graph "Reachable Nodes In Subdivided Graph") @@ -44,27 +44,12 @@ Output: 8
    -

    Example 4:

    - -
    -Input: grid = [[1,1,1],[1,0,1],[1,1,1]]
    -Output: 14
    -
    - -

    Example 5:

    - -
    -Input: grid = [[2,2,2],[2,1,2],[2,2,2]]
    -Output: 21
    -
    -

     

    Constraints:

      -
    • n == grid.length
    • -
    • n == grid[i].length
    • -
    • 1 <= n <= 50
    • +
    • n == grid.length == grid[i].length
    • +
    • 1 <= n <= 50
    • 0 <= grid[i][j] <= 50
    diff --git a/problems/put-boxes-into-the-warehouse-ii/README.md b/problems/put-boxes-into-the-warehouse-ii/README.md index e6089dd71..467663579 100644 --- a/problems/put-boxes-into-the-warehouse-ii/README.md +++ b/problems/put-boxes-into-the-warehouse-ii/README.md @@ -14,10 +14,13 @@ ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Put Boxes Into the Warehouse I](../put-boxes-into-the-warehouse-i) (Medium) + ### Hints
    Hint 1 diff --git a/problems/queries-on-a-permutation-with-key/README.md b/problems/queries-on-a-permutation-with-key/README.md index 60eb9a5fb..d1f4999c2 100644 --- a/problems/queries-on-a-permutation-with-key/README.md +++ b/problems/queries-on-a-permutation-with-key/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../string-matching-in-an-array "String Matching in an Array") diff --git a/problems/queries-quality-and-percentage/README.md b/problems/queries-quality-and-percentage/README.md index 36250d98d..a856dd542 100644 --- a/problems/queries-quality-and-percentage/README.md +++ b/problems/queries-quality-and-percentage/README.md @@ -78,3 +78,6 @@ Cat queries poor_ query_percentage is (1 / 3) * 100 = 33.33 ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Percentage of Users Attended a Contest](../percentage-of-users-attended-a-contest) (Easy) diff --git a/problems/queue-reconstruction-by-height/README.md b/problems/queue-reconstruction-by-height/README.md index 2378a7f52..7045e7aa1 100644 --- a/problems/queue-reconstruction-by-height/README.md +++ b/problems/queue-reconstruction-by-height/README.md @@ -49,8 +49,8 @@ Hence [[5,0],[7,0],[5,2],[6,1],[4,4],[7,1]] is the reconstructed queue. ### Related Topics - [[Array](../../tag/array/README.md)] [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Similar Questions diff --git a/problems/race-car/README.md b/problems/race-car/README.md index bbb7c6451..f0097cbbb 100644 --- a/problems/race-car/README.md +++ b/problems/race-car/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../linked-list-components "Linked List Components") diff --git a/problems/random-pick-index/README.md b/problems/random-pick-index/README.md index 01f9412be..8a120eb57 100644 --- a/problems/random-pick-index/README.md +++ b/problems/random-pick-index/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../integer-replacement "Integer Replacement") @@ -48,9 +48,9 @@ solution.pick(3); // It should return either index 2, 3, or 4 randomly. Each ind ### Related Topics - [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[Math](../../tag/math/README.md)] + [[Reservoir Sampling](../../tag/reservoir-sampling/README.md)] [[Randomized](../../tag/randomized/README.md)] ### Similar Questions diff --git a/problems/random-pick-with-weight/README.md b/problems/random-pick-with-weight/README.md index a9dd6b22b..003bbd478 100644 --- a/problems/random-pick-with-weight/README.md +++ b/problems/random-pick-with-weight/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-abbreviation "Word Abbreviation") @@ -11,11 +11,13 @@ ## [528. Random Pick with Weight (Medium)](https://leetcode.com/problems/random-pick-with-weight "按权重随机选择") -

    You are given an array of positive integers w where w[i] describes the weight of ith index (0-indexed).

    +

    You are given a 0-indexed array of positive integers w where w[i] describes the weight of the ith index.

    -

    We need to call the function pickIndex() which randomly returns an integer in the range [0, w.length - 1]pickIndex() should return the integer proportional to its weight in the w array. For example, for w = [1, 3], the probability of picking the index 0 is 1 / (1 + 3) = 0.25 (i.e 25%) while the probability of picking the index 1 is 3 / (1 + 3) = 0.75 (i.e 75%).

    +

    You need to implement the function pickIndex(), which randomly picks an index in the range [0, w.length - 1] (inclusive) and returns it. The probability of picking an index i is w[i] / sum(w).

    -

    More formally, the probability of picking index i is w[i] / sum(w).

    +
      +
    • For example, if w = [1, 3], the probability of picking index 0 is 1 / (1 + 3) = 0.25 (i.e., 25%), and the probability of picking index 1 is 3 / (1 + 3) = 0.75 (i.e., 75%).
    • +

     

    Example 1:

    @@ -29,7 +31,7 @@ Explanation Solution solution = new Solution([1]); -solution.pickIndex(); // return 0. Since there is only one single element on the array the only option is to return the first element. +solution.pickIndex(); // return 0. The only option is to return 0 since there is only one element in w.

    Example 2:

    @@ -43,13 +45,14 @@ solution.pickIndex(); // return 0. Since there is only one single element on the Explanation Solution solution = new Solution([1, 3]); -solution.pickIndex(); // return 1. It's returning the second element (index = 1) that has probability of 3/4. +solution.pickIndex(); // return 1. It is returning the second element (index = 1) that has a probability of 3/4. solution.pickIndex(); // return 1 solution.pickIndex(); // return 1 solution.pickIndex(); // return 1 -solution.pickIndex(); // return 0. It's returning the first element (index = 0) that has probability of 1/4. +solution.pickIndex(); // return 0. It is returning the first element (index = 0) that has a probability of 1/4. -Since this is a randomization problem, multiple answers are allowed so the following outputs can be considered correct : +Since this is a randomization problem, multiple answers are allowed. +All of the following outputs can be considered correct: [null,1,1,1,1,0] [null,1,1,1,1,1] [null,1,1,1,0,0] @@ -63,9 +66,9 @@ and so on.

    Constraints:

      -
    • 1 <= w.length <= 10000
    • -
    • 1 <= w[i] <= 10^5
    • -
    • pickIndex will be called at most 10000 times.
    • +
    • 1 <= w.length <= 104
    • +
    • 1 <= w[i] <= 105
    • +
    • pickIndex will be called at most 104 times.
    ### Related Topics diff --git a/problems/range-sum-query-mutable/README.md b/problems/range-sum-query-mutable/README.md index 8dd88dfdd..9e9b4991a 100644 --- a/problems/range-sum-query-mutable/README.md +++ b/problems/range-sum-query-mutable/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../additive-number "Additive Number") @@ -56,10 +56,10 @@ numArray.sumRange(0, 2); // return 1 + 2 + 5 = 8 ### Related Topics + [[Array](../../tag/array/README.md)] [[Design](../../tag/design/README.md)] [[Binary Indexed Tree](../../tag/binary-indexed-tree/README.md)] [[Segment Tree](../../tag/segment-tree/README.md)] - [[Array](../../tag/array/README.md)] ### Similar Questions 1. [Range Sum Query - Immutable](../range-sum-query-immutable) (Easy) diff --git a/problems/rank-scores/README.md b/problems/rank-scores/README.md index 6160acfc4..22dc4120c 100644 --- a/problems/rank-scores/README.md +++ b/problems/rank-scores/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../nth-highest-salary "Nth Highest Salary") diff --git a/problems/rank-transform-of-a-matrix/README.md b/problems/rank-transform-of-a-matrix/README.md index 836561c15..50ab56c4c 100644 --- a/problems/rank-transform-of-a-matrix/README.md +++ b/problems/rank-transform-of-a-matrix/README.md @@ -27,7 +27,7 @@
  • The rank should be as small as possible.
  • -

    It is guaranteed that answer is unique under the given rules.

    +

    The test cases are generated so that answer is unique under the given rules.

     

    Example 1:

    @@ -56,13 +56,6 @@ The rank of matrix[1][1] is 3 because matrix[1][1] > matrix[0][1], matrix[1][ Output: [[4,2,3],[1,3,4],[5,1,6],[1,3,4]] -

    Example 4:

    - -
    -Input: matrix = [[7,3,6],[1,4,5],[9,8,2]]
    -Output: [[5,1,4],[1,2,3],[6,3,1]]
    -
    -

     

    Constraints:

    diff --git a/problems/reach-a-number/README.md b/problems/reach-a-number/README.md index c9cfef930..3d3d442ee 100644 --- a/problems/reach-a-number/README.md +++ b/problems/reach-a-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cracking-the-safe "Cracking the Safe") diff --git a/problems/rearrange-array-elements-by-sign/README.md b/problems/rearrange-array-elements-by-sign/README.md new file mode 100644 index 000000000..42e6a72bd --- /dev/null +++ b/problems/rearrange-array-elements-by-sign/README.md @@ -0,0 +1,72 @@ + + + + + + + +[< Previous](../count-elements-with-strictly-smaller-and-greater-elements "Count Elements With Strictly Smaller and Greater Elements ") +                 +[Next >](../find-all-lonely-numbers-in-the-array "Find All Lonely Numbers in the Array") + +## [2149. Rearrange Array Elements by Sign (Medium)](https://leetcode.com/problems/rearrange-array-elements-by-sign "按符号重排数组") + +

    You are given a 0-indexed integer array nums of even length consisting of an equal number of positive and negative integers.

    + +

    You should rearrange the elements of nums such that the modified array follows the given conditions:

    + +
      +
    1. Every consecutive pair of integers have opposite signs.
    2. +
    3. For all integers with the same sign, the order in which they were present in nums is preserved.
    4. +
    5. The rearranged array begins with a positive integer.
    6. +
    + +

    Return the modified array after rearranging the elements to satisfy the aforementioned conditions.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [3,1,-2,-5,2,-4]
    +Output: [3,-2,1,-5,2,-4]
    +Explanation:
    +The positive integers in nums are [3,1,2]. The negative integers are [-2,-5,-4].
    +The only possible way to rearrange them such that they satisfy all conditions is [3,-2,1,-5,2,-4].
    +Other ways such as [1,-2,2,-5,3,-4], [3,1,2,-2,-5,-4], [-2,3,-5,1,-4,2] are incorrect because they do not satisfy one or more conditions.  
    +
    + +

    Example 2:

    + +
    +Input: nums = [-1,1]
    +Output: [1,-1]
    +Explanation:
    +1 is the only positive integer and -1 the only negative integer in nums.
    +So nums is rearranged to [1,-1].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 <= nums.length <= 2 * 105
    • +
    • nums.length is even
    • +
    • 1 <= |nums[i]| <= 105
    • +
    • nums consists of equal number of positive and negative integers.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Divide the array into two parts- one comprising of only positive integers and the other of negative integers. +
    + +
    +Hint 2 +Merge the two parts to get the resultant array. +
    diff --git a/problems/rearrange-spaces-between-words/README.md b/problems/rearrange-spaces-between-words/README.md index bd77b2d6f..96a5b97d5 100644 --- a/problems/rearrange-spaces-between-words/README.md +++ b/problems/rearrange-spaces-between-words/README.md @@ -23,7 +23,7 @@
     Input: text = "  this   is  a sentence "
     Output: "this   is   a   sentence"
    -Explanation: There are a total of 9 spaces and 4 words. We can evenly divide the 9 spaces between the words: 9 / (4-1) = 3 spaces.
    +Explanation: There are a total of 9 spaces and 4 words. We can evenly divide the 9 spaces between the words: 9 / (4-1) = 3 spaces.
     

    Example 2:

    @@ -31,28 +31,7 @@
     Input: text = " practice   makes   perfect"
     Output: "practice   makes   perfect "
    -Explanation: There are a total of 7 spaces and 3 words. 7 / (3-1) = 3 spaces plus 1 extra space. We place this extra space at the end of the string.
    -
    - -

    Example 3:

    - -
    -Input: text = "hello   world"
    -Output: "hello   world"
    -
    - -

    Example 4:

    - -
    -Input: text = "  walks  udp package   into  bar a"
    -Output: "walks  udp  package  into  bar  a "
    -
    - -

    Example 5:

    - -
    -Input: text = "a"
    -Output: "a"
    +Explanation: There are a total of 7 spaces and 3 words. 7 / (3-1) = 3 spaces plus 1 extra space. We place this extra space at the end of the string.
     

     

    @@ -60,13 +39,16 @@
    • 1 <= text.length <= 100
    • -
    • text consists of lowercase English letters and ' '.
    • -
    • text contains at least one word.
    • +
    • text consists of lowercase English letters and ' '.
    • +
    • text contains at least one word.
    ### Related Topics [[String](../../tag/string/README.md)] +### Similar Questions + 1. [Text Justification](../text-justification) (Hard) + ### Hints
    Hint 1 diff --git a/problems/rearrange-string-k-distance-apart/README.md b/problems/rearrange-string-k-distance-apart/README.md index 491309082..831175238 100644 --- a/problems/rearrange-string-k-distance-apart/README.md +++ b/problems/rearrange-string-k-distance-apart/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../count-numbers-with-unique-digits "Count Numbers with Unique Digits") diff --git a/problems/rearrange-words-in-a-sentence/README.md b/problems/rearrange-words-in-a-sentence/README.md index 5a62d6e06..b920aad7d 100644 --- a/problems/rearrange-words-in-a-sentence/README.md +++ b/problems/rearrange-words-in-a-sentence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-students-doing-homework-at-a-given-time "Number of Students Doing Homework at a Given Time") diff --git a/problems/recover-the-original-array/README.md b/problems/recover-the-original-array/README.md new file mode 100644 index 000000000..31c4a2224 --- /dev/null +++ b/problems/recover-the-original-array/README.md @@ -0,0 +1,95 @@ + + + + + + + +[< Previous](../intervals-between-identical-elements "Intervals Between Identical Elements") +                 +[Next >](../minimum-operations-to-remove-adjacent-ones-in-matrix "Minimum Operations to Remove Adjacent Ones in Matrix") + +## [2122. Recover the Original Array (Hard)](https://leetcode.com/problems/recover-the-original-array "还原原数组") + +

    Alice had a 0-indexed array arr consisting of n positive integers. She chose an arbitrary positive integer k and created two new 0-indexed integer arrays lower and higher in the following manner:

    + +
      +
    1. lower[i] = arr[i] - k, for every index i where 0 <= i < n
    2. +
    3. higher[i] = arr[i] + k, for every index i where 0 <= i < n
    4. +
    + +

    Unfortunately, Alice lost all three arrays. However, she remembers the integers that were present in the arrays lower and higher, but not the array each integer belonged to. Help Alice and recover the original array.

    + +

    Given an array nums consisting of 2n integers, where exactly n of the integers were present in lower and the remaining in higher, return the original array arr. In case the answer is not unique, return any valid array.

    + +

    Note: The test cases are generated such that there exists at least one valid array arr.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [2,10,6,4,8,12]
    +Output: [3,7,11]
    +Explanation:
    +If arr = [3,7,11] and k = 1, we get lower = [2,6,10] and higher = [4,8,12].
    +Combining lower and higher gives us [2,6,10,4,8,12], which is a permutation of nums.
    +Another valid possibility is that arr = [5,7,9] and k = 3. In that case, lower = [2,4,6] and higher = [8,10,12]. 
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,1,3,3]
    +Output: [2,2]
    +Explanation:
    +If arr = [2,2] and k = 1, we get lower = [1,1] and higher = [3,3].
    +Combining lower and higher gives us [1,1,3,3], which is equal to nums.
    +Note that arr cannot be [1,3] because in that case, the only possible way to obtain [1,1,3,3] is with k = 0.
    +This is invalid since k must be positive.
    +
    + +

    Example 3:

    + +
    +Input: nums = [5,435]
    +Output: [220]
    +Explanation:
    +The only possible combination is arr = [220] and k = 215. Using them, we get lower = [5] and higher = [435].
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 2 * n == nums.length
    • +
    • 1 <= n <= 1000
    • +
    • 1 <= nums[i] <= 109
    • +
    • The test cases are generated such that there exists at least one valid array arr.
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Hash Table](../../tag/hash-table/README.md)] + [[Enumeration](../../tag/enumeration/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +If we fix the value of k, how can we check if an original array exists for the fixed k? +
    + +
    +Hint 2 +The smallest value of nums is obtained by subtracting k from the smallest value of the original array. How can we use this to reduce the search space for finding a valid k? +
    + +
    +Hint 3 +You can compute every possible k by using the smallest value of nums (as lower[i]) against every other value in nums (as the corresponding higher[i]). +
    + +
    +Hint 4 +For every computed k, greedily pair up the values in nums. This can be done sorting nums, then using a map to store previous values and searching that map for a corresponding lower[i] for the current nums[j] (as higher[i]). +
    diff --git a/problems/rectangle-overlap/README.md b/problems/rectangle-overlap/README.md index 00ff72825..e5649b1d5 100644 --- a/problems/rectangle-overlap/README.md +++ b/problems/rectangle-overlap/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../image-overlap "Image Overlap") @@ -39,8 +39,8 @@ ### Related Topics - [[Geometry](../../tag/geometry/README.md)] [[Math](../../tag/math/README.md)] + [[Geometry](../../tag/geometry/README.md)] ### Similar Questions 1. [Rectangle Area](../rectangle-area) (Medium) diff --git a/problems/rectangles-area/README.md b/problems/rectangles-area/README.md index f63085a0a..f64effc69 100644 --- a/problems/rectangles-area/README.md +++ b/problems/rectangles-area/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../max-dot-product-of-two-subsequences "Max Dot Product of Two Subsequences") diff --git a/problems/reduce-array-size-to-the-half/README.md b/problems/reduce-array-size-to-the-half/README.md index 3667f864d..7dcae1f59 100644 --- a/problems/reduce-array-size-to-the-half/README.md +++ b/problems/reduce-array-size-to-the-half/README.md @@ -23,7 +23,7 @@ Output: 2 Explanation: Choosing {3,7} will make the new array [5,5,5,2,2] which has size 5 (i.e equal to half of the size of the old array). Possible sets of size 2 are {3,5},{3,2},{5,2}. -Choosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] which has size greater than half of the size of the old array. +Choosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] which has a size greater than half of the size of the old array.

    Example 2:

    @@ -34,40 +34,19 @@ Choosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] Explanation: The only possible set you can choose is {7}. This will make the new array empty. -

    Example 3:

    - -
    -Input: arr = [1,9]
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: arr = [1000,1000,3,7]
    -Output: 1
    -
    - -

    Example 5:

    - -
    -Input: arr = [1,2,3,4,5,6,7,8,9,10]
    -Output: 5
    -
    -

     

    Constraints:

      -
    • 1 <= arr.length <= 105
    • +
    • 2 <= arr.length <= 105
    • arr.length is even.
    • 1 <= arr[i] <= 105
    ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/reducing-dishes/README.md b/problems/reducing-dishes/README.md index 6e87b7e6c..c17b51662 100644 --- a/problems/reducing-dishes/README.md +++ b/problems/reducing-dishes/README.md @@ -41,14 +41,7 @@ Each dish is prepared in one unit of time.
     Input: satisfaction = [-1,-4,-5]
     Output: 0
    -Explanation: People don't like the dishes. No dish is prepared.
    -
    - -

    Example 4:

    - -
    -Input: satisfaction = [-2,5,-1,0,3,-3]
    -Output: 35
    +Explanation: People do not like the dishes. No dish is prepared.
     

     

    @@ -61,9 +54,9 @@ Each dish is prepared in one unit of time. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/reformat-phone-number/README.md b/problems/reformat-phone-number/README.md index 0ee2dbf14..d4dc85908 100644 --- a/problems/reformat-phone-number/README.md +++ b/problems/reformat-phone-number/README.md @@ -60,26 +60,12 @@ Step 3: There are 2 digits left, so put them in a single block of length 2. The Joining the blocks gives "123-456-78". -

    Example 4:

    - -
    -Input: number = "12"
    -Output: "12"
    -
    - -

    Example 5:

    - -
    -Input: number = "--17-5 229 35-39475 "
    -Output: "175-229-353-94-75"
    -
    -

     

    Constraints:

    • 2 <= number.length <= 100
    • -
    • number consists of digits and the characters '-' and ' '.
    • +
    • number consists of digits and the characters '-' and ' '.
    • There are at least two digits in number.
    diff --git a/problems/remove-all-ones-with-row-and-column-flips/README.md b/problems/remove-all-ones-with-row-and-column-flips/README.md new file mode 100644 index 000000000..f1857a910 --- /dev/null +++ b/problems/remove-all-ones-with-row-and-column-flips/README.md @@ -0,0 +1,46 @@ + + + + + + + +[< Previous](../maximum-employees-to-be-invited-to-a-meeting "Maximum Employees to Be Invited to a Meeting") +                 +[Next >](../capitalize-the-title "Capitalize the Title") + +## [2128. Remove All Ones With Row and Column Flips (Medium)](https://leetcode.com/problems/remove-all-ones-with-row-and-column-flips "") + + + +### Related Topics + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] + [[Math](../../tag/math/README.md)] + [[Matrix](../../tag/matrix/README.md)] + +### Hints +
    +Hint 1 +Does the order, in which you do the operations, matter? +
    + +
    +Hint 2 +No, it does not. An element will keep its original value if the number of operations done on it is even and vice versa. This also means that doing more than 1 operation on the same row or column is unproductive. +
    + +
    +Hint 3 +Try working backward, start with a matrix of all zeros and try to construct grid using operations. +
    + +
    +Hint 4 +Start with operations on columns, after doing them what do you notice about each row? +
    + +
    +Hint 5 +Each row is the exact same. If we then flip some rows, that leaves only two possible arrangements for each row: the same as the original or the opposite. +
    diff --git a/problems/remove-covered-intervals/README.md b/problems/remove-covered-intervals/README.md index b319a77a3..22a2a0ad3 100644 --- a/problems/remove-covered-intervals/README.md +++ b/problems/remove-covered-intervals/README.md @@ -23,7 +23,7 @@
     Input: intervals = [[1,4],[3,6],[2,8]]
     Output: 2
    -Explanation: Interval [3,6] is covered by [2,8], therefore it is removed.
    +Explanation: Interval [3,6] is covered by [2,8], therefore it is removed.
     

    Example 2:

    @@ -33,27 +33,6 @@ Output: 1 -

    Example 3:

    - -
    -Input: intervals = [[0,10],[5,12]]
    -Output: 2
    -
    - -

    Example 4:

    - -
    -Input: intervals = [[3,10],[4,10],[5,11]]
    -Output: 2
    -
    - -

    Example 5:

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

     

    Constraints:

    diff --git a/problems/remove-interval/README.md b/problems/remove-interval/README.md index 89f6001a6..bce96a0c0 100644 --- a/problems/remove-interval/README.md +++ b/problems/remove-interval/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../hexspeak "Hexspeak") diff --git a/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md b/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md index 2073e3fc8..11e59e27d 100644 --- a/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md +++ b/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/README.md @@ -5,7 +5,7 @@ -[< Previous](../minimum-deletion-cost-to-avoid-repeating-letters "Minimum Deletion Cost to Avoid Repeating Letters") +[< Previous](../minimum-time-to-make-rope-colorful "Minimum Time to Make Rope Colorful")                  [Next >](../put-boxes-into-the-warehouse-ii "Put Boxes Into the Warehouse II") diff --git a/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md b/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md index c8499e554..2a1183730 100644 --- a/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md +++ b/problems/remove-one-element-to-make-the-array-strictly-increasing/README.md @@ -46,14 +46,6 @@ No resulting array is strictly increasing, so return false. [1,1] is not strictly increasing, so return false. -

    Example 4:

    - -
    -Input: nums = [1,2,3]
    -Output: true
    -Explanation: [1,2,3] is already strictly increasing, so return true.
    -
    -

     

    Constraints:

    diff --git a/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md b/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md index 239cd5e5b..674f758f7 100644 --- a/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md +++ b/problems/remove-zero-sum-consecutive-nodes-from-linked-list/README.md @@ -52,6 +52,9 @@ [[Hash Table](../../tag/hash-table/README.md)] [[Linked List](../../tag/linked-list/README.md)] +### Similar Questions + 1. [Delete N Nodes After M Nodes of a Linked List](../delete-n-nodes-after-m-nodes-of-a-linked-list) (Easy) + ### Hints
    Hint 1 diff --git a/problems/removing-minimum-and-maximum-from-array/README.md b/problems/removing-minimum-and-maximum-from-array/README.md new file mode 100644 index 000000000..6a9d08876 --- /dev/null +++ b/problems/removing-minimum-and-maximum-from-array/README.md @@ -0,0 +1,94 @@ + + + + + + + +[< Previous](../k-radius-subarray-averages "K Radius Subarray Averages") +                 +[Next >](../find-all-people-with-secret "Find All People With Secret") + +## [2091. Removing Minimum and Maximum From Array (Medium)](https://leetcode.com/problems/removing-minimum-and-maximum-from-array "从数组中移除最大值和最小值") + +

    You are given a 0-indexed array of distinct integers nums.

    + +

    There is an element in nums that has the lowest value and an element that has the highest value. We call them the minimum and maximum respectively. Your goal is to remove both these elements from the array.

    + +

    A deletion is defined as either removing an element from the front of the array or removing an element from the back of the array.

    + +

    Return the minimum number of deletions it would take to remove both the minimum and maximum element from the array.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [2,10,7,5,4,1,8,6]
    +Output: 5
    +Explanation: 
    +The minimum element in the array is nums[5], which is 1.
    +The maximum element in the array is nums[1], which is 10.
    +We can remove both the minimum and maximum by removing 2 elements from the front and 3 elements from the back.
    +This results in 2 + 3 = 5 deletions, which is the minimum number possible.
    +
    + +

    Example 2:

    + +
    +Input: nums = [0,-4,19,1,8,-2,-3,5]
    +Output: 3
    +Explanation: 
    +The minimum element in the array is nums[1], which is -4.
    +The maximum element in the array is nums[2], which is 19.
    +We can remove both the minimum and maximum by removing 3 elements from the front.
    +This results in only 3 deletions, which is the minimum number possible.
    +
    + +

    Example 3:

    + +
    +Input: nums = [101]
    +Output: 1
    +Explanation:  
    +There is only one element in the array, which makes it both the minimum and maximum element.
    +We can remove it with 1 deletion.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 105
    • +
    • -105 <= nums[i] <= 105
    • +
    • The integers in nums are distinct.
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + +### Hints +
    +Hint 1 +There can only be three scenarios for deletions such that both minimum and maximum elements are removed: +
    + +
    +Hint 2 +Scenario 1: Both elements are removed by only deleting from the front. +
    + +
    +Hint 3 +Scenario 2: Both elements are removed by only deleting from the back. +
    + +
    +Hint 4 +Scenario 3: Delete from the front to remove one of the elements, and delete from the back to remove the other element. +
    + +
    +Hint 5 +Compare which of the three scenarios results in the minimum number of moves. +
    diff --git a/problems/removing-minimum-number-of-magic-beans/README.md b/problems/removing-minimum-number-of-magic-beans/README.md new file mode 100644 index 000000000..0e495bb15 --- /dev/null +++ b/problems/removing-minimum-number-of-magic-beans/README.md @@ -0,0 +1,85 @@ + + + + + + + +[< Previous](../minimum-operations-to-make-the-array-alternating "Minimum Operations to Make the Array Alternating") +                 +[Next >](../maximum-and-sum-of-array "Maximum AND Sum of Array") + +## [2171. Removing Minimum Number of Magic Beans (Medium)](https://leetcode.com/problems/removing-minimum-number-of-magic-beans "拿出最少数目的魔法豆") + +

    You are given an array of positive integers beans, where each integer represents the number of magic beans found in a particular magic bag.

    + +

    Remove any number of beans (possibly none) from each bag such that the number of beans in each remaining non-empty bag (still containing at least one bean) is equal. Once a bean has been removed from a bag, you are not allowed to return it to any of the bags.

    + +

    Return the minimum number of magic beans that you have to remove.

    + +

     

    +

    Example 1:

    + +
    +Input: beans = [4,1,6,5]
    +Output: 4
    +Explanation: 
    +- We remove 1 bean from the bag with only 1 bean.
    +  This results in the remaining bags: [4,0,6,5]
    +- Then we remove 2 beans from the bag with 6 beans.
    +  This results in the remaining bags: [4,0,4,5]
    +- Then we remove 1 bean from the bag with 5 beans.
    +  This results in the remaining bags: [4,0,4,4]
    +We removed a total of 1 + 2 + 1 = 4 beans to make the remaining non-empty bags have an equal number of beans.
    +There are no other solutions that remove 4 beans or fewer.
    +
    + +

    Example 2:

    + +
    +Input: beans = [2,10,3,2]
    +Output: 7
    +Explanation:
    +- We remove 2 beans from one of the bags with 2 beans.
    +  This results in the remaining bags: [0,10,3,2]
    +- Then we remove 2 beans from the other bag with 2 beans.
    +  This results in the remaining bags: [0,10,3,0]
    +- Then we remove 3 beans from the bag with 3 beans. 
    +  This results in the remaining bags: [0,10,0,0]
    +We removed a total of 2 + 2 + 3 = 7 beans to make the remaining non-empty bags have an equal number of beans.
    +There are no other solutions that removes 7 beans or fewer.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= beans.length <= 105
    • +
    • 1 <= beans[i] <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Notice that if we choose to make x bags of beans empty, we should choose the x bags with the least amount of beans. +
    + +
    +Hint 2 +Notice that if the minimum number of beans in a non-empty bag is m, then the best way to make all bags have an equal amount of beans is to reduce all the bags to have m beans. +
    + +
    +Hint 3 +Can we iterate over how many bags we should remove and choose the one that minimizes the total amount of beans to remove? +
    + +
    +Hint 4 +Sort the bags of beans first. +
    diff --git a/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md b/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md index 192f235ee..6743b154d 100644 --- a/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md +++ b/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts "Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts") diff --git a/problems/repeated-string-match/README.md b/problems/repeated-string-match/README.md index 508494d61..49ac83fce 100644 --- a/problems/repeated-string-match/README.md +++ b/problems/repeated-string-match/README.md @@ -11,9 +11,9 @@ ## [686. Repeated String Match (Medium)](https://leetcode.com/problems/repeated-string-match "重复叠加字符串匹配") -

    Given two strings a and b, return the minimum number of times you should repeat string a so that string b is a substring of it. If it is impossible for b​​​​​​ to be a substring of a after repeating it, return -1.

    +

    Given two strings a and b, return the minimum number of times you should repeat string a so that string b is a substring of it. If it is impossible for b​​​​​​ to be a substring of a after repeating it, return -1.

    -

    Notice: string "abc" repeated 0 times is "",  repeated 1 time is "abc" and repeated 2 times is "abcabc".

    +

    Notice: string "abc" repeated 0 times is "", repeated 1 time is "abc" and repeated 2 times is "abcabc".

     

    Example 1:

    @@ -31,27 +31,12 @@ Output: 2 -

    Example 3:

    - -
    -Input: a = "a", b = "a"
    -Output: 1
    -
    - -

    Example 4:

    - -
    -Input: a = "abc", b = "wxyz"
    -Output: -1
    -
    -

     

    Constraints:

      -
    • 1 <= a.length <= 104
    • -
    • 1 <= b.length <= 104
    • -
    • a and b consist of lower-case English letters.
    • +
    • 1 <= a.length, b.length <= 104
    • +
    • a and b consist of lowercase English letters.
    ### Related Topics diff --git a/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md b/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md index 42bc3386d..e9aadef5e 100644 --- a/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md +++ b/problems/replace-all-s-to-avoid-consecutive-repeating-characters/README.md @@ -23,28 +23,15 @@
     Input: s = "?zs"
     Output: "azs"
    -Explanation: There are 25 solutions for this problem. From "azs" to "yzs", all are valid. Only "z" is an invalid modification as the string will consist of consecutive repeating characters in "zzs".
    +Explanation: There are 25 solutions for this problem. From "azs" to "yzs", all are valid. Only "z" is an invalid modification as the string will consist of consecutive repeating characters in "zzs". +

    Example 2:

     Input: s = "ubv?w"
     Output: "ubvaw"
    -Explanation: There are 24 solutions for this problem. Only "v" and "w" are invalid modifications as the strings will consist of consecutive repeating characters in "ubvvw" and "ubvww".
    -
    - -

    Example 3:

    - -
    -Input: s = "j?qg??b"
    -Output: "jaqgacb"
    -
    - -

    Example 4:

    - -
    -Input: s = "??yw?ipkj?"
    -Output: "acywaipkja"
    +Explanation: There are 24 solutions for this problem. Only "v" and "w" are invalid modifications as the strings will consist of consecutive repeating characters in "ubvvw" and "ubvww".
     

     

    diff --git a/problems/reported-posts-ii/README.md b/problems/reported-posts-ii/README.md index b14a7515b..bd1a28b4e 100644 --- a/problems/reported-posts-ii/README.md +++ b/problems/reported-posts-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-of-absolute-value-expression "Maximum of Absolute Value Expression") diff --git a/problems/restore-the-array/README.md b/problems/restore-the-array/README.md index 570dbce5a..caa50f9a9 100644 --- a/problems/restore-the-array/README.md +++ b/problems/restore-the-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../the-k-th-lexicographical-string-of-all-happy-strings-of-length-n "The k-th Lexicographical String of All Happy Strings of Length n") @@ -40,21 +40,6 @@ Explanation: Possible arrays are [1317],[131,7],[13,17],[1,317],[13,1,7],[1,31,7],[1,3,17],[1,3,1,7] -

    Example 4:

    - -
    -Input: s = "2020", k = 30
    -Output: 1
    -Explanation: The only possible array is [20,20]. [2020] is invalid because 2020 > 30. [2,020] is ivalid because 020 contains leading zeros.
    -
    - -

    Example 5:

    - -
    -Input: s = "1234567890", k = 90
    -Output: 34
    -
    -

     

    Constraints:

    @@ -68,6 +53,9 @@ [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] +### Similar Questions + 1. [Number of Ways to Separate Numbers](../number-of-ways-to-separate-numbers) (Hard) + ### Hints
    Hint 1 diff --git a/problems/reverse-bits/README.md b/problems/reverse-bits/README.md index a613f07a4..37efcfc69 100644 --- a/problems/reverse-bits/README.md +++ b/problems/reverse-bits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../rotate-array "Rotate Array") @@ -48,8 +48,8 @@

    Follow up: If this function is called many times, how would you optimize it?

    ### Related Topics - [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] ### Similar Questions 1. [Reverse Integer](../reverse-integer) (Medium) diff --git a/problems/reverse-linked-list/README.md b/problems/reverse-linked-list/README.md index 393cdb8d1..be9956cae 100644 --- a/problems/reverse-linked-list/README.md +++ b/problems/reverse-linked-list/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../isomorphic-strings "Isomorphic Strings") @@ -47,10 +47,12 @@

    Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both?

    ### Related Topics - [[Recursion](../../tag/recursion/README.md)] [[Linked List](../../tag/linked-list/README.md)] + [[Recursion](../../tag/recursion/README.md)] ### Similar Questions 1. [Reverse Linked List II](../reverse-linked-list-ii) (Medium) 1. [Binary Tree Upside Down](../binary-tree-upside-down) (Medium) 1. [Palindrome Linked List](../palindrome-linked-list) (Easy) + 1. [Reverse Nodes in Even Length Groups](../reverse-nodes-in-even-length-groups) (Medium) + 1. [Maximum Twin Sum of a Linked List](../maximum-twin-sum-of-a-linked-list) (Medium) diff --git a/problems/reverse-nodes-in-even-length-groups/README.md b/problems/reverse-nodes-in-even-length-groups/README.md index 1acbfaf3b..ff39ee8c6 100644 --- a/problems/reverse-nodes-in-even-length-groups/README.md +++ b/problems/reverse-nodes-in-even-length-groups/README.md @@ -32,9 +32,9 @@ Input: head = [5,2,6,3,9,1,7,3,8,4] Output: [5,6,2,3,9,1,4,8,3,7] Explanation: -- The length of the first group is 1, which is odd, hence no reversal occurrs. +- The length of the first group is 1, which is odd, hence no reversal occurs. - The length of the second group is 2, which is even, hence the nodes are reversed. -- The length of the third group is 3, which is odd, hence no reversal occurrs. +- The length of the third group is 3, which is odd, hence no reversal occurs. - The length of the last group is 4, which is even, hence the nodes are reversed. @@ -44,9 +44,9 @@ Input: head = [1,1,0,6] Output: [1,0,1,6] Explanation: -- The length of the first group is 1. No reversal occurrs. +- The length of the first group is 1. No reversal occurs. - The length of the second group is 2. The nodes are reversed. -- The length of the last group is 1. No reversal occurrs. +- The length of the last group is 1. No reversal occurs.

    Example 3:

    @@ -55,29 +55,11 @@ Input: head = [1,1,0,6,5] Output: [1,0,1,5,6] Explanation: -- The length of the first group is 1. No reversal occurrs. +- The length of the first group is 1. No reversal occurs. - The length of the second group is 2. The nodes are reversed. - The length of the last group is 2. The nodes are reversed. -

    Example 4:

    - -
    -Input: head = [2,1]
    -Output: [2,1]
    -Explanation:
    -- The length of the first group is 1. No reversal occurrs.
    -- The length of the last group is 1. No reversal occurrs.
    -
    - -

    Example 5:

    - -
    -Input: head = [8]
    -Output: [8]
    -Explanation: There is only one group whose length is 1. No reversal occurrs.
    -
    -

     

    Constraints:

    diff --git a/problems/reverse-words-in-a-string/README.md b/problems/reverse-words-in-a-string/README.md index a42fabf98..0a2002fd0 100644 --- a/problems/reverse-words-in-a-string/README.md +++ b/problems/reverse-words-in-a-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../evaluate-reverse-polish-notation "Evaluate Reverse Polish Notation") @@ -43,20 +43,6 @@ Explanation: You need to reduce multiple spaces between two words to a single space in the reversed string. -

    Example 4:

    - -
    -Input: s = "  Bob    Loves  Alice   "
    -Output: "Alice Loves Bob"
    -
    - -

    Example 5:

    - -
    -Input: s = "Alice does not even like bob"
    -Output: "bob like even not does Alice"
    -
    -

     

    Constraints:

    diff --git a/problems/rings-and-rods/README.md b/problems/rings-and-rods/README.md new file mode 100644 index 000000000..3944e5b9c --- /dev/null +++ b/problems/rings-and-rods/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../sequentially-ordinal-rank-tracker "Sequentially Ordinal Rank Tracker") +                 +[Next >](../sum-of-subarray-ranges "Sum of Subarray Ranges") + +## [2103. Rings and Rods (Easy)](https://leetcode.com/problems/rings-and-rods "环和杆") + +

    There are n rings and each ring is either red, green, or blue. The rings are distributed across ten rods labeled from 0 to 9.

    + +

    You are given a string rings of length 2n that describes the n rings that are placed onto the rods. Every two characters in rings forms a color-position pair that is used to describe each ring where:

    + +
      +
    • The first character of the ith pair denotes the ith ring's color ('R', 'G', 'B').
    • +
    • The second character of the ith pair denotes the rod that the ith ring is placed on ('0' to '9').
    • +
    + +

    For example, "R3G2B1" describes n == 3 rings: a red ring placed onto the rod labeled 3, a green ring placed onto the rod labeled 2, and a blue ring placed onto the rod labeled 1.

    + +

    Return the number of rods that have all three colors of rings on them.

    + +

     

    +

    Example 1:

    + +
    +Input: rings = "B0B6G0R6R0R6G9"
    +Output: 1
    +Explanation: 
    +- The rod labeled 0 holds 3 rings with all colors: red, green, and blue.
    +- The rod labeled 6 holds 3 rings, but it only has red and blue.
    +- The rod labeled 9 holds only a green ring.
    +Thus, the number of rods with all three colors is 1.
    +
    + +

    Example 2:

    + +
    +Input: rings = "B0R0G0R9R0B0G0"
    +Output: 1
    +Explanation: 
    +- The rod labeled 0 holds 6 rings with all colors: red, green, and blue.
    +- The rod labeled 9 holds only a red ring.
    +Thus, the number of rods with all three colors is 1.
    +
    + +

    Example 3:

    + +
    +Input: rings = "G4"
    +Output: 0
    +Explanation: 
    +Only one ring is given. Thus, no rods have all three colors.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • rings.length == 2 * n
    • +
    • 1 <= n <= 100
    • +
    • rings[i] where i is even is either 'R', 'G', or 'B' (0-indexed).
    • +
    • rings[i] where i is odd is a digit from '0' to '9' (0-indexed).
    • +
    + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + +### Hints +
    +Hint 1 +For every rod, look through ‘rings’ to see if the rod contains all colors. +
    + +
    +Hint 2 +Create 3 booleans, 1 for each color, to store if that color is present for the current rod. If all 3 are true after looking through the string, then the rod contains all the colors. +
    diff --git a/problems/rotate-array/README.md b/problems/rotate-array/README.md index cf4d0ec51..9b80793b2 100644 --- a/problems/rotate-array/README.md +++ b/problems/rotate-array/README.md @@ -1,15 +1,15 @@ - - - + + + [< Previous](../best-time-to-buy-and-sell-stock-iv "Best Time to Buy and Sell Stock IV")                  [Next >](../reverse-bits "Reverse Bits") -## [189. Rotate Array (Medium)](https://leetcode.com/problems/rotate-array "旋转数组") +## [189. Rotate Array (Medium)](https://leetcode.com/problems/rotate-array "轮转数组")

    Given an array, rotate the array to the right by k steps, where k is non-negative.

    diff --git a/problems/rotate-function/README.md b/problems/rotate-function/README.md index 56f6101fd..1dd719a63 100644 --- a/problems/rotate-function/README.md +++ b/problems/rotate-function/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-substring-with-at-least-k-repeating-characters "Longest Substring with At Least K Repeating Characters") diff --git a/problems/running-total-for-different-genders/README.md b/problems/running-total-for-different-genders/README.md index db8e732bc..107500405 100644 --- a/problems/running-total-for-different-genders/README.md +++ b/problems/running-total-for-different-genders/README.md @@ -76,6 +76,3 @@ Fifth day is 2020-01-07, Bajrang scored 7 points and the total score for the tea ### Related Topics [[Database](../../tag/database/README.md)] - -### Similar Questions - 1. [Last Person to Fit in the Bus](../last-person-to-fit-in-the-bus) (Medium) diff --git a/problems/russian-doll-envelopes/README.md b/problems/russian-doll-envelopes/README.md index de6f285d3..96062bae2 100644 --- a/problems/russian-doll-envelopes/README.md +++ b/problems/russian-doll-envelopes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../design-snake-game "Design Snake Game") @@ -39,9 +39,9 @@

    Constraints:

      -
    • 1 <= envelopes.length <= 5000
    • +
    • 1 <= envelopes.length <= 105
    • envelopes[i].length == 2
    • -
    • 1 <= wi, hi <= 104
    • +
    • 1 <= wi, hi <= 105
    ### Related Topics diff --git a/problems/sales-analysis-ii/README.md b/problems/sales-analysis-ii/README.md index 30e305088..c0995e4d1 100644 --- a/problems/sales-analysis-ii/README.md +++ b/problems/sales-analysis-ii/README.md @@ -77,3 +77,7 @@ The buyer with id 1 bought an S8 but didn't buy an iPhone. The buyer with id ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [Sales Analysis I](../sales-analysis-i) (Easy) + 1. [Sales Analysis III](../sales-analysis-iii) (Easy) diff --git a/problems/sales-by-day-of-the-week/README.md b/problems/sales-by-day-of-the-week/README.md index dcc18624a..753d7a48d 100644 --- a/problems/sales-by-day-of-the-week/README.md +++ b/problems/sales-by-day-of-the-week/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../allocate-mailboxes "Allocate Mailboxes") diff --git a/problems/search-insert-position/README.md b/problems/search-insert-position/README.md index b94c0636a..09a83df93 100644 --- a/problems/search-insert-position/README.md +++ b/problems/search-insert-position/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-first-and-last-position-of-element-in-sorted-array "Find First and Last Position of Element in Sorted Array") @@ -17,21 +17,26 @@

     

    Example 1:

    -
    Input: nums = [1,3,5,6], target = 5
    +
    +
    +Input: nums = [1,3,5,6], target = 5
     Output: 2
    -

    Example 2:

    -
    Input: nums = [1,3,5,6], target = 2
    +
    + +

    Example 2:

    + +
    +Input: nums = [1,3,5,6], target = 2
     Output: 1
    -

    Example 3:

    -
    Input: nums = [1,3,5,6], target = 7
    +
    + +

    Example 3:

    + +
    +Input: nums = [1,3,5,6], target = 7
     Output: 4
    -

    Example 4:

    -
    Input: nums = [1,3,5,6], target = 0
    -Output: 0
    -

    Example 5:

    -
    Input: nums = [1], target = 0
    -Output: 0
     
    +

     

    Constraints:

    diff --git a/problems/search-suggestions-system/README.md b/problems/search-suggestions-system/README.md index e572da055..be6fd4f4d 100644 --- a/problems/search-suggestions-system/README.md +++ b/problems/search-suggestions-system/README.md @@ -11,9 +11,11 @@ ## [1268. Search Suggestions System (Medium)](https://leetcode.com/problems/search-suggestions-system "搜索推荐系统") -

    Given an array of strings products and a string searchWord. We want to design a system that suggests at most three product names from products after each character of searchWord is typed. Suggested products should have common prefix with the searchWord. If there are more than three products with a common prefix return the three lexicographically minimums products.

    +

    You are given an array of strings products and a string searchWord.

    -

    Return list of lists of the suggested products after each character of searchWord is typed. 

    +

    Design a system that suggests at most three product names from products after each character of searchWord is typed. Suggested products should have common prefix with searchWord. If there are more than three products with a common prefix return the three lexicographically minimums products.

    + +

    Return a list of lists of the suggested products after each character of searchWord is typed.

     

    Example 1:

    @@ -46,23 +48,17 @@ After typing mou, mous and mouse the system suggests ["mouse","mo Output: [["baggage","bags","banner"],["baggage","bags","banner"],["baggage","bags"],["bags"]]
    -

    Example 4:

    - -
    -Input: products = ["havana"], searchWord = "tatiana"
    -Output: [[],[],[],[],[],[],[]]
    -
    -

     

    Constraints:

    • 1 <= products.length <= 1000
    • -
    • There are no repeated elements in products.
    • -
    • 1 <= Σ products[i].length <= 2 * 10^4
    • -
    • All characters of products[i] are lower-case English letters.
    • +
    • 1 <= products[i].length <= 3000
    • +
    • 1 <= sum(products[i].length) <= 2 * 104
    • +
    • All the strings of products are unique.
    • +
    • products[i] consists of lowercase English letters.
    • 1 <= searchWord.length <= 1000
    • -
    • All characters of searchWord are lower-case English letters.
    • +
    • searchWord consists of lowercase English letters.
    ### Related Topics diff --git a/problems/second-highest-salary/README.md b/problems/second-highest-salary/README.md index 6f9a61f07..6cb8a3e24 100644 --- a/problems/second-highest-salary/README.md +++ b/problems/second-highest-salary/README.md @@ -1,35 +1,71 @@ - - - + + + [< Previous](../combine-two-tables "Combine Two Tables")                  [Next >](../nth-highest-salary "Nth Highest Salary") -## [176. Second Highest Salary (Easy)](https://leetcode.com/problems/second-highest-salary "第二高的薪水") +## [176. Second Highest Salary (Medium)](https://leetcode.com/problems/second-highest-salary "第二高的薪水") -

    Write a SQL query to get the second highest salary from the Employee table.

    +

    Table: Employee

    ++-------------+------+
    +| Column Name | Type |
    ++-------------+------+
    +| id          | int  |
    +| salary      | int  |
    ++-------------+------+
    +id is the primary key column for this table.
    +Each row of this table contains information about the salary of an employee.
    +
    + +

     

    + +

    Write an SQL query to report the second highest salary from the Employee table. If there is no second highest salary, the query should report null.

    + +

    The query result format is in the following example.

    + +

     

    +

    Example 1:

    + +
    +Input: 
    +Employee table:
     +----+--------+
    -| Id | Salary |
    +| id | salary |
     +----+--------+
     | 1  | 100    |
     | 2  | 200    |
     | 3  | 300    |
     +----+--------+
    +Output: 
    ++---------------------+
    +| SecondHighestSalary |
    ++---------------------+
    +| 200                 |
    ++---------------------+
     
    -

    For example, given the above Employee table, the query should return 200 as the second highest salary. If there is no second highest salary, then the query should return null.

    +

    Example 2:

    +Input: 
    +Employee table:
    ++----+--------+
    +| id | salary |
    ++----+--------+
    +| 1  | 100    |
    ++----+--------+
    +Output: 
     +---------------------+
     | SecondHighestSalary |
     +---------------------+
    -| 200                 |
    +| null                |
     +---------------------+
     
    diff --git a/problems/second-highest-salary/mysql_schemas.sql b/problems/second-highest-salary/mysql_schemas.sql index c08cc8bd5..f98a8511a 100644 --- a/problems/second-highest-salary/mysql_schemas.sql +++ b/problems/second-highest-salary/mysql_schemas.sql @@ -1,5 +1,5 @@ -Create table If Not Exists Employee (Id int, Salary int); +Create table If Not Exists Employee (id int, salary int); Truncate table Employee; -insert into Employee (Id, Salary) values ('1', '100'); -insert into Employee (Id, Salary) values ('2', '200'); -insert into Employee (Id, Salary) values ('3', '300'); +insert into Employee (id, salary) values ('1', '100'); +insert into Employee (id, salary) values ('2', '200'); +insert into Employee (id, salary) values ('3', '300'); diff --git a/problems/second-minimum-time-to-reach-destination/README.md b/problems/second-minimum-time-to-reach-destination/README.md index b6cd23da1..6511ed733 100644 --- a/problems/second-minimum-time-to-reach-destination/README.md +++ b/problems/second-minimum-time-to-reach-destination/README.md @@ -80,7 +80,6 @@ The second minimum time path is 1 -> 2 -> 1 -> 2 with time = 11 minutes ### Related Topics [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Graph](../../tag/graph/README.md)] - [[Array](../../tag/array/README.md)] [[Shortest Path](../../tag/shortest-path/README.md)] ### Hints diff --git a/problems/self-crossing/README.md b/problems/self-crossing/README.md index fdf7c5d0b..39f96b944 100644 --- a/problems/self-crossing/README.md +++ b/problems/self-crossing/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../increasing-triplet-subsequence "Increasing Triplet Subsequence") diff --git a/problems/sell-diminishing-valued-colored-balls/README.md b/problems/sell-diminishing-valued-colored-balls/README.md index 4f26b0d86..e010dd174 100644 --- a/problems/sell-diminishing-valued-colored-balls/README.md +++ b/problems/sell-diminishing-valued-colored-balls/README.md @@ -38,21 +38,6 @@ The maximum total value is 2 + 5 + 4 + 3 = 14. The maximum total value is 3 + 2 + 5 + 4 + 3 + 2 = 19. -

    Example 3:

    - -
    -Input: inventory = [2,8,4,10,6], orders = 20
    -Output: 110
    -
    - -

    Example 4:

    - -
    -Input: inventory = [1000000000], orders = 1000000000
    -Output: 21
    -Explanation: Sell the 1st color 1000000000 times for a total value of 500000000500000000. 500000000500000000 modulo 109 + 7 = 21.
    -
    -

     

    Constraints:

    diff --git a/problems/sentence-similarity-iii/README.md b/problems/sentence-similarity-iii/README.md index 02839ffad..45db111c7 100644 --- a/problems/sentence-similarity-iii/README.md +++ b/problems/sentence-similarity-iii/README.md @@ -42,13 +42,6 @@ Explanation: sentence2 can be turned to sentence1 by inserting "right now" at the end of the sentence. -

    Example 4:

    - -
    -Input: sentence1 = "Luky", sentence2 = "Lucccky"
    -Output: false
    -
    -

     

    Constraints:

    diff --git a/problems/sequentially-ordinal-rank-tracker/README.md b/problems/sequentially-ordinal-rank-tracker/README.md new file mode 100644 index 000000000..4b1402419 --- /dev/null +++ b/problems/sequentially-ordinal-rank-tracker/README.md @@ -0,0 +1,113 @@ + + + + + + + +[< Previous](../detonate-the-maximum-bombs "Detonate the Maximum Bombs") +                 +[Next >](../rings-and-rods "Rings and Rods") + +## [2102. Sequentially Ordinal Rank Tracker (Hard)](https://leetcode.com/problems/sequentially-ordinal-rank-tracker "序列顺序查询") + +

    A scenic location is represented by its name and attractiveness score, where name is a unique string among all locations and score is an integer. Locations can be ranked from the best to the worst. The higher the score, the better the location. If the scores of two locations are equal, then the location with the lexicographically smaller name is better.

    + +

    You are building a system that tracks the ranking of locations with the system initially starting with no locations. It supports:

    + +
      +
    • Adding scenic locations, one at a time.
    • +
    • Querying the ith best location of all locations already added, where i is the number of times the system has been queried (including the current query). +
        +
      • For example, when the system is queried for the 4th time, it returns the 4th best location of all locations already added.
      • +
      +
    • +
    + +

    Note that the test data are generated so that at any time, the number of queries does not exceed the number of locations added to the system.

    + +

    Implement the SORTracker class:

    + +
      +
    • SORTracker() Initializes the tracker system.
    • +
    • void add(string name, int score) Adds a scenic location with name and score to the system.
    • +
    • string get() Queries and returns the ith best location, where i is the number of times this method has been invoked (including this invocation).
    • +
    + +

     

    +

    Example 1:

    + +
    +Input
    +["SORTracker", "add", "add", "get", "add", "get", "add", "get", "add", "get", "add", "get", "get"]
    +[[], ["bradford", 2], ["branford", 3], [], ["alps", 2], [], ["orland", 2], [], ["orlando", 3], [], ["alpine", 2], [], []]
    +Output
    +[null, null, null, "branford", null, "alps", null, "bradford", null, "bradford", null, "bradford", "orland"]
    +
    +Explanation
    +SORTracker tracker = new SORTracker(); // Initialize the tracker system.
    +tracker.add("bradford", 2); // Add location with name="bradford" and score=2 to the system.
    +tracker.add("branford", 3); // Add location with name="branford" and score=3 to the system.
    +tracker.get();              // The sorted locations, from best to worst, are: branford, bradford.
    +                            // Note that branford precedes bradford due to its higher score (3 > 2).
    +                            // This is the 1st time get() is called, so return the best location: "branford".
    +tracker.add("alps", 2);     // Add location with name="alps" and score=2 to the system.
    +tracker.get();              // Sorted locations: branford, alps, bradford.
    +                            // Note that alps precedes bradford even though they have the same score (2).
    +                            // This is because "alps" is lexicographically smaller than "bradford".
    +                            // Return the 2nd best location "alps", as it is the 2nd time get() is called.
    +tracker.add("orland", 2);   // Add location with name="orland" and score=2 to the system.
    +tracker.get();              // Sorted locations: branford, alps, bradford, orland.
    +                            // Return "bradford", as it is the 3rd time get() is called.
    +tracker.add("orlando", 3);  // Add location with name="orlando" and score=3 to the system.
    +tracker.get();              // Sorted locations: branford, orlando, alps, bradford, orland.
    +                            // Return "bradford".
    +tracker.add("alpine", 2);   // Add location with name="alpine" and score=2 to the system.
    +tracker.get();              // Sorted locations: branford, orlando, alpine, alps, bradford, orland.
    +                            // Return "bradford".
    +tracker.get();              // Sorted locations: branford, orlando, alpine, alps, bradford, orland.
    +                            // Return "orland".
    +
    + +

     

    +

    Constraints:

    + +
      +
    • name consists of lowercase English letters, and is unique among all locations.
    • +
    • 1 <= name.length <= 10
    • +
    • 1 <= score <= 105
    • +
    • At any time, the number of calls to get does not exceed the number of calls to add.
    • +
    • At most 4 * 104 calls in total will be made to add and get.
    • +
    + +### Related Topics + [[Design](../../tag/design/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] + [[Ordered Set](../../tag/ordered-set/README.md)] + [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Hints +
    +Hint 1 +If the problem were to find the median of a stream of scenery locations while they are being added, can you solve it? +
    + +
    +Hint 2 +We can use a similar approach as an optimization to avoid repeated sorting. +
    + +
    +Hint 3 +Employ two heaps: left heap and right heap. The left heap is a max-heap, and the right heap is a min-heap. The size of the left heap is k + 1 (best locations), where k is the number of times the get method was invoked. The other locations are maintained in the right heap. +
    + +
    +Hint 4 +Every time when add is being called, we add it to the left heap. If the size of the left heap exceeds k + 1, we move the head element to the right heap. +
    + +
    +Hint 5 +When the get method is invoked again (the k + 1 time it is invoked), we can return the head element of the left heap. But before returning it, if the right heap is not empty, we maintain the left heap to have the best k + 2 items by moving the best location from the right heap to the left heap. +
    diff --git a/problems/set-matrix-zeroes/README.md b/problems/set-matrix-zeroes/README.md index f2ba94241..f3c767924 100644 --- a/problems/set-matrix-zeroes/README.md +++ b/problems/set-matrix-zeroes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../edit-distance "Edit Distance") @@ -11,7 +11,7 @@ ## [73. Set Matrix Zeroes (Medium)](https://leetcode.com/problems/set-matrix-zeroes "矩阵置零") -

    Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's, and return the matrix.

    +

    Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's.

    You must do it in place.

    @@ -56,6 +56,8 @@ ### Similar Questions 1. [Game of Life](../game-of-life) (Medium) + 1. [Number of Laser Beams in a Bank](../number-of-laser-beams-in-a-bank) (Medium) + 1. [Minimum Operations to Remove Adjacent Ones in Matrix](../minimum-operations-to-remove-adjacent-ones-in-matrix) (Hard) ### Hints
    diff --git a/problems/set-mismatch/README.md b/problems/set-mismatch/README.md index 4fd90d16f..afde337fb 100644 --- a/problems/set-mismatch/README.md +++ b/problems/set-mismatch/README.md @@ -34,9 +34,9 @@ ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Similar Questions diff --git a/problems/shift-2d-grid/README.md b/problems/shift-2d-grid/README.md index 2e724740e..3474f127a 100644 --- a/problems/shift-2d-grid/README.md +++ b/problems/shift-2d-grid/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../handshakes-that-dont-cross "Handshakes That Don't Cross") diff --git a/problems/shortest-bridge/README.md b/problems/shortest-bridge/README.md index c99a6492f..c28bec2ab 100644 --- a/problems/shortest-bridge/README.md +++ b/problems/shortest-bridge/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../number-of-recent-calls "Number of Recent Calls") @@ -11,11 +11,13 @@ ## [934. Shortest Bridge (Medium)](https://leetcode.com/problems/shortest-bridge "最短的桥") -

    In a given 2D binary array grid, there are two islands.  (An island is a 4-directionally connected group of 1s not connected to any other 1s.)

    +

    You are given an n x n binary matrix grid where 1 represents land and 0 represents water.

    -

    Now, we may change 0s to 1s so as to connect the two islands together to form 1 island.

    +

    An island is a 4-directionally connected group of 1's not connected to any other 1's. There are exactly two islands in grid.

    -

    Return the smallest number of 0s that must be flipped.  (It is guaranteed that the answer is at least 1.)

    +

    You may change 0's to 1's to connect the two islands to form one island.

    + +

    Return the smallest number of 0's you must flip to connect the two islands.

     

    Example 1:

    @@ -43,8 +45,10 @@

    Constraints:

      -
    • 2 <= grid.length == grid[0].length <= 100
    • -
    • grid[i][j] == 0 or grid[i][j] == 1
    • +
    • n == grid.length == grid[i].length
    • +
    • 2 <= n <= 100
    • +
    • grid[i][j] is either 0 or 1.
    • +
    • There are exactly two islands in grid.
    ### Related Topics diff --git a/problems/shortest-completing-word/README.md b/problems/shortest-completing-word/README.md index 5501b8b5b..10eb3e10f 100644 --- a/problems/shortest-completing-word/README.md +++ b/problems/shortest-completing-word/README.md @@ -41,27 +41,6 @@ Since "steps" is the only word containing all the letters, that is the Explanation: licensePlate only contains the letter 's'. All the words contain 's', but among these "pest", "stew", and "show" are shortest. The answer is "pest" because it is the word that appears earliest of the 3. -

    Example 3:

    - -
    -Input: licensePlate = "Ah71752", words = ["suggest","letter","of","husband","easy","education","drug","prevent","writer","old"]
    -Output: "husband"
    -
    - -

    Example 4:

    - -
    -Input: licensePlate = "OgEu755", words = ["enough","these","play","wide","wonder","box","arrive","money","tax","thus"]
    -Output: "enough"
    -
    - -

    Example 5:

    - -
    -Input: licensePlate = "iMSlpe4", words = ["claim","consumer","student","camera","public","never","wonder","simple","thought","use"]
    -Output: "simple"
    -
    -

     

    Constraints:

    @@ -74,6 +53,7 @@ Since "steps" is the only word containing all the letters, that is the ### Related Topics + [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] diff --git a/problems/shortest-distance-from-all-buildings/README.md b/problems/shortest-distance-from-all-buildings/README.md index ee20e154f..d8508700c 100644 --- a/problems/shortest-distance-from-all-buildings/README.md +++ b/problems/shortest-distance-from-all-buildings/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../remove-duplicate-letters "Remove Duplicate Letters") diff --git a/problems/shortest-path-in-a-hidden-grid/README.md b/problems/shortest-path-in-a-hidden-grid/README.md index 9a8aae6c9..c519f5a97 100644 --- a/problems/shortest-path-in-a-hidden-grid/README.md +++ b/problems/shortest-path-in-a-hidden-grid/README.md @@ -19,6 +19,10 @@ [[Graph](../../tag/graph/README.md)] [[Interactive](../../tag/interactive/README.md)] +### Similar Questions + 1. [Robot Room Cleaner](../robot-room-cleaner) (Hard) + 1. [Minimum Path Cost in a Hidden Grid](../minimum-path-cost-in-a-hidden-grid) (Medium) + ### Hints
    Hint 1 diff --git a/problems/shortest-path-to-get-food/README.md b/problems/shortest-path-to-get-food/README.md index 1332ad811..d6251d5c9 100644 --- a/problems/shortest-path-to-get-food/README.md +++ b/problems/shortest-path-to-get-food/README.md @@ -14,10 +14,14 @@ ### Related Topics - [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Array](../../tag/array/README.md)] + [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] +### Similar Questions + 1. [01 Matrix](../01-matrix) (Medium) + 1. [Shortest Path in a Grid with Obstacles Elimination](../shortest-path-in-a-grid-with-obstacles-elimination) (Hard) + ### Hints
    Hint 1 diff --git a/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md b/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md index 0c1a1106f..6af342eff 100644 --- a/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md +++ b/problems/shortest-subarray-to-be-removed-to-make-array-sorted/README.md @@ -23,15 +23,16 @@
     Input: arr = [1,2,3,10,4,2,3,5]
     Output: 3
    -Explanation: The shortest subarray we can remove is [10,4,2] of length 3. The remaining elements after that will be [1,2,3,3,5] which are sorted.
    -Another correct solution is to remove the subarray [3,10,4].
    +Explanation: The shortest subarray we can remove is [10,4,2] of length 3. The remaining elements after that will be [1,2,3,3,5] which are sorted. +Another correct solution is to remove the subarray [3,10,4]. +

    Example 2:

     Input: arr = [5,4,3,2,1]
     Output: 4
    -Explanation: Since the array is strictly decreasing, we can only keep a single element. Therefore we need to remove a subarray of length 4, either [5,4,3,2] or [4,3,2,1].
    +Explanation: Since the array is strictly decreasing, we can only keep a single element. Therefore we need to remove a subarray of length 4, either [5,4,3,2] or [4,3,2,1].
     

    Example 3:

    @@ -39,14 +40,7 @@ Another correct solution is to remove the subarray [3,10,4].
     Input: arr = [1,2,3]
     Output: 0
    -Explanation: The array is already non-decreasing. We do not need to remove any elements.
    -
    - -

    Example 4:

    - -
    -Input: arr = [1]
    -Output: 0
    +Explanation: The array is already non-decreasing. We do not need to remove any elements.
     

     

    @@ -58,10 +52,10 @@ Another correct solution is to remove the subarray [3,10,4]. ### Related Topics - [[Stack](../../tag/stack/README.md)] [[Array](../../tag/array/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[Binary Search](../../tag/binary-search/README.md)] + [[Stack](../../tag/stack/README.md)] [[Monotonic Stack](../../tag/monotonic-stack/README.md)] ### Hints diff --git a/problems/shortest-way-to-form-string/README.md b/problems/shortest-way-to-form-string/README.md index 6a522ebee..2a8fb3a4b 100644 --- a/problems/shortest-way-to-form-string/README.md +++ b/problems/shortest-way-to-form-string/README.md @@ -51,13 +51,12 @@ ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[String](../../tag/string/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### Similar Questions 1. [Is Subsequence](../is-subsequence) (Easy) - 1. [Number of Matching Subsequences](../number-of-matching-subsequences) (Medium) ### Hints
    diff --git a/problems/shuffle-string/README.md b/problems/shuffle-string/README.md index 83e038f81..ab3bf2124 100644 --- a/problems/shuffle-string/README.md +++ b/problems/shuffle-string/README.md @@ -7,13 +7,11 @@ [< Previous](../patients-with-a-condition "Patients With a Condition")                  -[Next >](../bulb-switcher-iv "Bulb Switcher IV") +[Next >](../minimum-suffix-flips "Minimum Suffix Flips") ## [1528. Shuffle String (Easy)](https://leetcode.com/problems/shuffle-string "重新排列字符串") -

    Given a string s and an integer array indices of the same length.

    - -

    The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.

    +

    You are given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.

    Return the shuffled string.

    @@ -34,36 +32,15 @@ Explanation: After shuffling, each character remains in its position. -

    Example 3:

    - -
    -Input: s = "aiohn", indices = [3,1,4,2,0]
    -Output: "nihao"
    -
    - -

    Example 4:

    - -
    -Input: s = "aaiougrt", indices = [4,0,2,6,7,3,1,5]
    -Output: "arigatou"
    -
    - -

    Example 5:

    - -
    -Input: s = "art", indices = [1,0,2]
    -Output: "rat"
    -
    -

     

    Constraints:

    • s.length == indices.length == n
    • 1 <= n <= 100
    • -
    • s contains only lower-case English letters.
    • -
    • 0 <= indices[i] < n
    • -
    • All values of indices are unique (i.e. indices is a permutation of the integers from 0 to n - 1).
    • +
    • s consists of only lowercase English letters.
    • +
    • 0 <= indices[i] < n
    • +
    • All values of indices are unique.
    ### Related Topics diff --git a/problems/shuffle-the-array/README.md b/problems/shuffle-the-array/README.md index 43679a3af..9180ca6d1 100644 --- a/problems/shuffle-the-array/README.md +++ b/problems/shuffle-the-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-all-the-lonely-nodes "Find All The Lonely Nodes") diff --git a/problems/simplify-path/README.md b/problems/simplify-path/README.md index 842c7792e..3e55de4ff 100644 --- a/problems/simplify-path/README.md +++ b/problems/simplify-path/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../climbing-stairs "Climbing Stairs") @@ -48,14 +48,7 @@
     Input: path = "/home//foo/"
     Output: "/home/foo"
    -Explanation: In the canonical path, multiple consecutive slashes are replaced by a single one.
    -
    - -

    Example 4:

    - -
    -Input: path = "/a/./b/../../c/"
    -Output: "/c"
    +Explanation: In the canonical path, multiple consecutive slashes are replaced by a single one.
     

     

    diff --git a/problems/single-row-keyboard/README.md b/problems/single-row-keyboard/README.md index dabe10b72..37330813a 100644 --- a/problems/single-row-keyboard/README.md +++ b/problems/single-row-keyboard/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../product-price-at-a-given-date "Product Price at a Given Date") diff --git a/problems/smallest-greater-multiple-made-of-two-digits/README.md b/problems/smallest-greater-multiple-made-of-two-digits/README.md index 2b62f9d3f..cd7e4bd7f 100644 --- a/problems/smallest-greater-multiple-made-of-two-digits/README.md +++ b/problems/smallest-greater-multiple-made-of-two-digits/README.md @@ -9,7 +9,7 @@                  [Next >](../reverse-prefix-of-word "Reverse Prefix of Word") -## [1999. Smallest Greater Multiple Made of Two Digits (Medium)](https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits "") +## [1999. Smallest Greater Multiple Made of Two Digits (Medium)](https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits "最小的仅由两个数组成的倍数") diff --git a/problems/smallest-index-with-equal-value/README.md b/problems/smallest-index-with-equal-value/README.md index 580d8f059..48843d83d 100644 --- a/problems/smallest-index-with-equal-value/README.md +++ b/problems/smallest-index-with-equal-value/README.md @@ -49,14 +49,6 @@ i=3: 3 mod 10 = 3 != nums[3]. Explanation: No index satisfies i mod 10 == nums[i]. -

    Example 4:

    - -
    -Input: nums = [2,1,3,5,2]
    -Output: 1
    -Explanation: 1 is the only index with i mod 10 == nums[i].
    -
    -

     

    Constraints:

    diff --git a/problems/smallest-range-covering-elements-from-k-lists/README.md b/problems/smallest-range-covering-elements-from-k-lists/README.md index c6b732dd2..7738b24d9 100644 --- a/problems/smallest-range-covering-elements-from-k-lists/README.md +++ b/problems/smallest-range-covering-elements-from-k-lists/README.md @@ -34,27 +34,6 @@ List 3: [5, 18, 22, 30], 22 is in range [20,24]. Output: [1,1] -

    Example 3:

    - -
    -Input: nums = [[10,10],[11,11]]
    -Output: [10,11]
    -
    - -

    Example 4:

    - -
    -Input: nums = [[10],[11]]
    -Output: [10,11]
    -
    - -

    Example 5:

    - -
    -Input: nums = [[1],[2],[3],[4],[5],[6],[7]]
    -Output: [1,7]
    -
    -

     

    Constraints:

    @@ -67,9 +46,12 @@ List 3: [5, 18, 22, 30], 22 is in range [20,24]. ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] - [[Sorting](../../tag/sorting/README.md)] + [[Greedy](../../tag/greedy/README.md)] [[Sliding Window](../../tag/sliding-window/README.md)] + [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] + +### Similar Questions + 1. [Minimum Window Substring](../minimum-window-substring) (Hard) diff --git a/problems/smallest-string-starting-from-leaf/README.md b/problems/smallest-string-starting-from-leaf/README.md index 2cacbb7f1..9b0831735 100644 --- a/problems/smallest-string-starting-from-leaf/README.md +++ b/problems/smallest-string-starting-from-leaf/README.md @@ -54,9 +54,9 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] - [[String](../../tag/string/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] ### Similar Questions diff --git a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md index 8c29362be..f7479d7cc 100644 --- a/problems/smallest-subtree-with-all-the-deepest-nodes/README.md +++ b/problems/smallest-subtree-with-all-the-deepest-nodes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-path-to-get-all-keys "Shortest Path to Get All Keys") @@ -15,11 +15,9 @@

    Return the smallest subtree such that it contains all the deepest nodes in the original tree.

    -

    A node is called the deepest if it has the largest depth possible among any node in the entire tree.

    +

    A node is called the deepest if it has the largest depth possible among any node in the entire tree.

    -

    The subtree of a node is tree consisting of that node, plus the set of all descendants of that node.

    - -

    Note: This question is the same as 1123: https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/

    +

    The subtree of a node is a tree consisting of that node, plus the set of all descendants of that node.

     

    Example 1:

    @@ -54,12 +52,15 @@ Notice that nodes 5, 3 and 2 contain the deepest nodes in the tree but node 2 is
    • The number of nodes in the tree will be in the range [1, 500].
    • 0 <= Node.val <= 500
    • -
    • The values of the nodes in the tree are unique.
    • +
    • The values of the nodes in the tree are unique.
    +

     

    +

    Note: This question is the same as 1123: https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/

    + ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] [[Binary Tree](../../tag/binary-tree/README.md)] diff --git a/problems/smallest-value-of-the-rearranged-number/README.md b/problems/smallest-value-of-the-rearranged-number/README.md new file mode 100644 index 000000000..3d029d147 --- /dev/null +++ b/problems/smallest-value-of-the-rearranged-number/README.md @@ -0,0 +1,59 @@ + + + + + + + +[< Previous](../sort-even-and-odd-indices-independently "Sort Even and Odd Indices Independently") +                 +[Next >](../design-bitset "Design Bitset") + +## [2165. Smallest Value of the Rearranged Number (Medium)](https://leetcode.com/problems/smallest-value-of-the-rearranged-number "重排数字的最小值") + +

    You are given an integer num. Rearrange the digits of num such that its value is minimized and it does not contain any leading zeros.

    + +

    Return the rearranged number with minimal value.

    + +

    Note that the sign of the number does not change after rearranging the digits.

    + +

     

    +

    Example 1:

    + +
    +Input: num = 310
    +Output: 103
    +Explanation: The possible arrangements for the digits of 310 are 013, 031, 103, 130, 301, 310. 
    +The arrangement with the smallest value that does not contain any leading zeros is 103.
    +
    + +

    Example 2:

    + +
    +Input: num = -7605
    +Output: -7650
    +Explanation: Some possible arrangements for the digits of -7605 are -7650, -6705, -5076, -0567.
    +The arrangement with the smallest value that does not contain any leading zeros is -7650.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • -1015 <= num <= 1015
    • +
    + +### Related Topics + [[Math](../../tag/math/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +For positive numbers, the leading digit should be the smallest nonzero digit. Then the remaining digits follow in ascending order. +
    + +
    +Hint 2 +For negative numbers, the digits should be arranged in descending order. +
    diff --git a/problems/solving-questions-with-brainpower/README.md b/problems/solving-questions-with-brainpower/README.md new file mode 100644 index 000000000..91656b129 --- /dev/null +++ b/problems/solving-questions-with-brainpower/README.md @@ -0,0 +1,92 @@ + + + + + + + +[< Previous](../minimum-moves-to-reach-target-score "Minimum Moves to Reach Target Score") +                 +[Next >](../maximum-running-time-of-n-computers "Maximum Running Time of N Computers") + +## [2140. Solving Questions With Brainpower (Medium)](https://leetcode.com/problems/solving-questions-with-brainpower "解决智力问题") + +

    You are given a 0-indexed 2D integer array questions where questions[i] = [pointsi, brainpoweri].

    + +

    The array describes the questions of an exam, where you have to process the questions in order (i.e., starting from question 0) and make a decision whether to solve or skip each question. Solving question i will earn you pointsi points but you will be unable to solve each of the next brainpoweri questions. If you skip question i, you get to make the decision on the next question.

    + +
      +
    • For example, given questions = [[3, 2], [4, 3], [4, 4], [2, 5]]: +
        +
      • If question 0 is solved, you will earn 3 points but you will be unable to solve questions 1 and 2.
      • +
      • If instead, question 0 is skipped and question 1 is solved, you will earn 4 points but you will be unable to solve questions 2 and 3.
      • +
      +
    • +
    + +

    Return the maximum points you can earn for the exam.

    + +

     

    +

    Example 1:

    + +
    +Input: questions = [[3,2],[4,3],[4,4],[2,5]]
    +Output: 5
    +Explanation: The maximum points can be earned by solving questions 0 and 3.
    +- Solve question 0: Earn 3 points, will be unable to solve the next 2 questions
    +- Unable to solve questions 1 and 2
    +- Solve question 3: Earn 2 points
    +Total points earned: 3 + 2 = 5. There is no other way to earn 5 or more points.
    +
    + +

    Example 2:

    + +
    +Input: questions = [[1,1],[2,2],[3,3],[4,4],[5,5]]
    +Output: 7
    +Explanation: The maximum points can be earned by solving questions 1 and 4.
    +- Skip question 0
    +- Solve question 1: Earn 2 points, will be unable to solve the next 2 questions
    +- Unable to solve questions 2 and 3
    +- Solve question 4: Earn 5 points
    +Total points earned: 2 + 5 = 7. There is no other way to earn 7 or more points.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= questions.length <= 105
    • +
    • questions[i].length == 2
    • +
    • 1 <= pointsi, brainpoweri <= 105
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + +### Hints +
    +Hint 1 +For each question, we can either solve it or skip it. How can we use Dynamic Programming to decide the most optimal option for each problem? +
    + +
    +Hint 2 +We store for each question the maximum points we can earn if we started the exam on that question. +
    + +
    +Hint 3 +If we skip a question, then the answer for it will be the same as the answer for the next question. +
    + +
    +Hint 4 +If we solve a question, then the answer for it will be the points of the current question plus the answer for the next solvable question. +
    + +
    +Hint 5 +The maximum of these two values will be the answer to the current question. +
    diff --git a/problems/sort-an-array/README.md b/problems/sort-an-array/README.md index defec3b25..eade2aa53 100644 --- a/problems/sort-an-array/README.md +++ b/problems/sort-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../online-election "Online Election") @@ -32,9 +32,9 @@ ### Related Topics [[Array](../../tag/array/README.md)] [[Divide and Conquer](../../tag/divide-and-conquer/README.md)] - [[Bucket Sort](../../tag/bucket-sort/README.md)] - [[Counting Sort](../../tag/counting-sort/README.md)] - [[Radix Sort](../../tag/radix-sort/README.md)] [[Sorting](../../tag/sorting/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] [[Merge Sort](../../tag/merge-sort/README.md)] + [[Bucket Sort](../../tag/bucket-sort/README.md)] + [[Radix Sort](../../tag/radix-sort/README.md)] + [[Counting Sort](../../tag/counting-sort/README.md)] diff --git a/problems/sort-array-by-increasing-frequency/README.md b/problems/sort-array-by-increasing-frequency/README.md index 9ed63490c..e5cbf4b46 100644 --- a/problems/sort-array-by-increasing-frequency/README.md +++ b/problems/sort-array-by-increasing-frequency/README.md @@ -51,9 +51,6 @@ [[Hash Table](../../tag/hash-table/README.md)] [[Sorting](../../tag/sorting/README.md)] -### Similar Questions - 1. [Sort Characters By Frequency](../sort-characters-by-frequency) (Medium) - ### Hints
    Hint 1 diff --git a/problems/sort-even-and-odd-indices-independently/README.md b/problems/sort-even-and-odd-indices-independently/README.md new file mode 100644 index 000000000..9cf9fc559 --- /dev/null +++ b/problems/sort-even-and-odd-indices-independently/README.md @@ -0,0 +1,81 @@ + + + + + + + +[< Previous](../minimum-difference-in-sums-after-removal-of-elements "Minimum Difference in Sums After Removal of Elements") +                 +[Next >](../smallest-value-of-the-rearranged-number "Smallest Value of the Rearranged Number") + +## [2164. Sort Even and Odd Indices Independently (Easy)](https://leetcode.com/problems/sort-even-and-odd-indices-independently "对奇偶下标分别排序") + +

    You are given a 0-indexed integer array nums. Rearrange the values of nums according to the following rules:

    + +
      +
    1. Sort the values at odd indices of nums in non-increasing order. +
        +
      • For example, if nums = [4,1,2,3] before this step, it becomes [4,3,2,1] after. The values at odd indices 1 and 3 are sorted in non-increasing order.
      • +
      +
    2. +
    3. Sort the values at even indices of nums in non-decreasing order. +
        +
      • For example, if nums = [4,1,2,3] before this step, it becomes [2,1,4,3] after. The values at even indices 0 and 2 are sorted in non-decreasing order.
      • +
      +
    4. +
    + +

    Return the array formed after rearranging the values of nums.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [4,1,2,3]
    +Output: [2,3,4,1]
    +Explanation: 
    +First, we sort the values present at odd indices (1 and 3) in non-increasing order.
    +So, nums changes from [4,1,2,3] to [4,3,2,1].
    +Next, we sort the values present at even indices (0 and 2) in non-decreasing order.
    +So, nums changes from [4,1,2,3] to [2,3,4,1].
    +Thus, the array formed after rearranging the values is [2,3,4,1].
    +
    + +

    Example 2:

    + +
    +Input: nums = [2,1]
    +Output: [2,1]
    +Explanation: 
    +Since there is exactly one odd index and one even index, no rearrangement of values takes place.
    +The resultant array formed is [2,1], which is the same as the initial array. 
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 100
    • +
    • 1 <= nums[i] <= 100
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Try to separate the elements at odd indices from the elements at even indices. +
    + +
    +Hint 2 +Sort the two groups of elements individually. +
    + +
    +Hint 3 +Combine them to form the resultant array. +
    diff --git a/problems/sort-integers-by-the-number-of-1-bits/README.md b/problems/sort-integers-by-the-number-of-1-bits/README.md index 21a136eaf..9ffba5ff0 100644 --- a/problems/sort-integers-by-the-number-of-1-bits/README.md +++ b/problems/sort-integers-by-the-number-of-1-bits/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../activity-participants "Activity Participants") @@ -11,9 +11,9 @@ ## [1356. Sort Integers by The Number of 1 Bits (Easy)](https://leetcode.com/problems/sort-integers-by-the-number-of-1-bits "根据数字二进制下 1 的数目排序") -

    Given an integer array arr. You have to sort the integers in the array in ascending order by the number of 1's in their binary representation and in case of two or more integers have the same number of 1's you have to sort them in ascending order.

    +

    You are given an integer array arr. Sort the integers in the array in ascending order by the number of 1's in their binary representation and in case of two or more integers have the same number of 1's you have to sort them in ascending order.

    -

    Return the sorted array.

    +

    Return the array after sorting it.

     

    Example 1:

    @@ -36,33 +36,12 @@ The sorted array by bits is [0,1,2,4,8,3,5,6,7] Explantion: All integers have 1 bit in the binary representation, you should just sort them in ascending order. -

    Example 3:

    - -
    -Input: arr = [10000,10000]
    -Output: [10000,10000]
    -
    - -

    Example 4:

    - -
    -Input: arr = [2,3,5,7,11,13,17,19]
    -Output: [2,3,5,17,7,11,13,19]
    -
    - -

    Example 5:

    - -
    -Input: arr = [10,100,1000,10000]
    -Output: [10,100,10000,1000]
    -
    -

     

    Constraints:

    • 1 <= arr.length <= 500
    • -
    • 0 <= arr[i] <= 10^4
    • +
    • 0 <= arr[i] <= 104
    ### Related Topics @@ -71,6 +50,9 @@ The sorted array by bits is [0,1,2,4,8,3,5,6,7] [[Sorting](../../tag/sorting/README.md)] [[Counting](../../tag/counting/README.md)] +### Similar Questions + 1. [Find Subsequence of Length K With the Largest Sum](../find-subsequence-of-length-k-with-the-largest-sum) (Easy) + ### Hints
    Hint 1 diff --git a/problems/sort-integers-by-the-power-value/README.md b/problems/sort-integers-by-the-power-value/README.md index 80eefa8c1..7a507f22c 100644 --- a/problems/sort-integers-by-the-power-value/README.md +++ b/problems/sort-integers-by-the-power-value/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../cinema-seat-allocation "Cinema Seat Allocation") @@ -11,20 +11,20 @@ ## [1387. Sort Integers by The Power Value (Medium)](https://leetcode.com/problems/sort-integers-by-the-power-value "将整数按权重排序") -

    The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps:

    +

    The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps:

    • if x is even then x = x / 2
    • if x is odd then x = 3 * x + 1
    -

    For example, the power of x = 3 is 7 because 3 needs 7 steps to become 1 (3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1).

    +

    For example, the power of x = 3 is 7 because 3 needs 7 steps to become 1 (3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1).

    Given three integers lo, hi and k. The task is to sort all integers in the interval [lo, hi] by the power value in ascending order, if two or more integers have the same power value sort them by ascending order.

    -

    Return the k-th integer in the range [lo, hi] sorted by the power value.

    +

    Return the kth integer in the range [lo, hi] sorted by the power value.

    -

    Notice that for any integer x (lo <= x <= hi) it is guaranteed that x will transform into 1 using these steps and that the power of x is will fit in 32 bit signed integer.

    +

    Notice that for any integer x (lo <= x <= hi) it is guaranteed that x will transform into 1 using these steps and that the power of x is will fit in a 32-bit signed integer.

     

    Example 1:

    @@ -42,13 +42,6 @@ Notice that 12 and 13 have the same power value and we sorted them in ascending

    Example 2:

    -
    -Input: lo = 1, hi = 1, k = 1
    -Output: 1
    -
    - -

    Example 3:

    -
     Input: lo = 7, hi = 11, k = 4
     Output: 7
    @@ -57,20 +50,6 @@ The interval sorted by power is [8, 10, 11, 7, 9].
     The fourth number in the sorted array is 7.
     
    -

    Example 4:

    - -
    -Input: lo = 10, hi = 20, k = 5
    -Output: 13
    -
    - -

    Example 5:

    - -
    -Input: lo = 1, hi = 1000, k = 777
    -Output: 570
    -
    -

     

    Constraints:

    @@ -80,8 +59,8 @@ The fourth number in the sorted array is 7. ### Related Topics - [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Memoization](../../tag/memoization/README.md)] + [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Sorting](../../tag/sorting/README.md)] ### Hints diff --git a/problems/sort-linked-list-already-sorted-using-absolute-values/README.md b/problems/sort-linked-list-already-sorted-using-absolute-values/README.md index 787f6c9e5..452636892 100644 --- a/problems/sort-linked-list-already-sorted-using-absolute-values/README.md +++ b/problems/sort-linked-list-already-sorted-using-absolute-values/README.md @@ -9,7 +9,7 @@                  [Next >](../number-of-valid-words-in-a-sentence "Number of Valid Words in a Sentence") -## [2046. Sort Linked List Already Sorted Using Absolute Values (Medium)](https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values "") +## [2046. Sort Linked List Already Sorted Using Absolute Values (Medium)](https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values "给按照绝对值排序的链表排序") diff --git a/problems/sort-transformed-array/README.md b/problems/sort-transformed-array/README.md index 5e0bdca3e..6135d7d68 100644 --- a/problems/sort-transformed-array/README.md +++ b/problems/sort-transformed-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../logger-rate-limiter "Logger Rate Limiter") diff --git a/problems/sorting-the-sentence/README.md b/problems/sorting-the-sentence/README.md index bf34188c7..8f696c17d 100644 --- a/problems/sorting-the-sentence/README.md +++ b/problems/sorting-the-sentence/README.md @@ -53,6 +53,9 @@ [[String](../../tag/string/README.md)] [[Sorting](../../tag/sorting/README.md)] +### Similar Questions + 1. [Check if Numbers Are Ascending in a Sentence](../check-if-numbers-are-ascending-in-a-sentence) (Easy) + ### Hints
    Hint 1 diff --git a/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md b/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md index 421305253..acdb00777 100644 --- a/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md +++ b/problems/special-array-with-x-elements-greater-than-or-equal-x/README.md @@ -46,13 +46,6 @@ x cannot be greater since there are only 2 numbers in nums. Explanation: There are 3 values that are greater than or equal to 3. -

    Example 4:

    - -
    -Input: nums = [3,6,7,7,0]
    -Output: -1
    -
    -

     

    Constraints:

    diff --git a/problems/special-positions-in-a-binary-matrix/README.md b/problems/special-positions-in-a-binary-matrix/README.md index a3e5ee837..3f8fe5cdd 100644 --- a/problems/special-positions-in-a-binary-matrix/README.md +++ b/problems/special-positions-in-a-binary-matrix/README.md @@ -11,60 +11,35 @@ ## [1582. Special Positions in a Binary Matrix (Easy)](https://leetcode.com/problems/special-positions-in-a-binary-matrix "二进制矩阵中的特殊位置") -

    Given a rows x cols matrix mat, where mat[i][j] is either 0 or 1, return the number of special positions in mat.

    +

    Given an m x n binary matrix mat, return the number of special positions in mat.

    -

    A position (i,j) is called special if mat[i][j] == 1 and all other elements in row i and column j are 0 (rows and columns are 0-indexed).

    +

    A position (i, j) is called special if mat[i][j] == 1 and all other elements in row i and column j are 0 (rows and columns are 0-indexed).

     

    Example 1:

    - +
    -Input: mat = [[1,0,0],
    -              [0,0,1],
    -              [1,0,0]]
    +Input: mat = [[1,0,0],[0,0,1],[1,0,0]]
     Output: 1
    -Explanation: (1,2) is a special position because mat[1][2] == 1 and all other elements in row 1 and column 2 are 0.
    +Explanation: (1, 2) is a special position because mat[1][2] == 1 and all other elements in row 1 and column 2 are 0.
     

    Example 2:

    - -
    -Input: mat = [[1,0,0],
    -              [0,1,0],
    -              [0,0,1]]
    -Output: 3
    -Explanation: (0,0), (1,1) and (2,2) are special positions. 
    -
    - -

    Example 3:

    - -
    -Input: mat = [[0,0,0,1],
    -              [1,0,0,0],
    -              [0,1,1,0],
    -              [0,0,0,0]]
    -Output: 2
    -
    - -

    Example 4:

    - +
    -Input: mat = [[0,0,0,0,0],
    -              [1,0,0,0,0],
    -              [0,1,0,0,0],
    -              [0,0,1,0,0],
    -              [0,0,0,1,1]]
    +Input: mat = [[1,0,0],[0,1,0],[0,0,1]]
     Output: 3
    +Explanation: (0, 0), (1, 1) and (2, 2) are special positions.
     

     

    Constraints:

      -
    • rows == mat.length
    • -
    • cols == mat[i].length
    • -
    • 1 <= rows, cols <= 100
    • -
    • mat[i][j] is 0 or 1.
    • +
    • m == mat.length
    • +
    • n == mat[i].length
    • +
    • 1 <= m, n <= 100
    • +
    • mat[i][j] is either 0 or 1.
    ### Related Topics diff --git a/problems/split-array-into-fibonacci-sequence/README.md b/problems/split-array-into-fibonacci-sequence/README.md index bf63e8c47..1d3c593ce 100644 --- a/problems/split-array-into-fibonacci-sequence/README.md +++ b/problems/split-array-into-fibonacci-sequence/README.md @@ -29,26 +29,20 @@

    Example 1:

    -Input: num = "123456579"
    -Output: [123,456,579]
    +Input: num = "1101111"
    +Output: [11,0,11,11]
    +Explanation: The output [110, 1, 111] would also be accepted.
     

    Example 2:

    -
    -Input: num = "11235813"
    -Output: [1,1,2,3,5,8,13]
    -
    - -

    Example 3:

    -
     Input: num = "112358130"
     Output: []
     Explanation: The task is impossible.
     
    -

    Example 4:

    +

    Example 3:

     Input: num = "0123"
    @@ -56,14 +50,6 @@
     Explanation: Leading zeroes are not allowed, so "01", "2", "3" is not valid.
     
    -

    Example 5:

    - -
    -Input: num = "1101111"
    -Output: [11,0,11,11]
    -Explanation: The output [11, 0, 11, 11] would also be accepted.
    -
    -

     

    Constraints:

    diff --git a/problems/split-array-with-same-average/README.md b/problems/split-array-with-same-average/README.md index 248dac471..f7cfa9d69 100644 --- a/problems/split-array-with-same-average/README.md +++ b/problems/split-array-with-same-average/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../unique-morse-code-words "Unique Morse Code Words") diff --git a/problems/split-two-strings-to-make-palindrome/README.md b/problems/split-two-strings-to-make-palindrome/README.md index 8684258eb..b8a9ef7b2 100644 --- a/problems/split-two-strings-to-make-palindrome/README.md +++ b/problems/split-two-strings-to-make-palindrome/README.md @@ -34,8 +34,8 @@ Then, aprefix + bsuffix = "" + "y" = &

    Example 2:

    -Input: a = "abdef", b = "fecab"
    -Output: true
    +Input: a = "xbdef", b = "xecab"
    +Output: false
     

    Example 3:

    @@ -49,13 +49,6 @@ bprefix = "jiz", bsuffix = "alu" Then, aprefix + bsuffix = "ula" + "alu" = "ulaalu", which is a palindrome. -

    Example 4:

    - -
    -Input: a = "xbdef", b = "xecab"
    -Output: false
    -
    -

     

    Constraints:

    @@ -66,9 +59,9 @@ Then, aprefix + bsuffix = "ula" + "alu" ### Related Topics + [[Greedy](../../tag/greedy/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] [[String](../../tag/string/README.md)] - [[Greedy](../../tag/greedy/README.md)] ### Hints
    diff --git a/problems/splitting-a-string-into-descending-consecutive-values/README.md b/problems/splitting-a-string-into-descending-consecutive-values/README.md index 936b7ddf8..97aca561b 100644 --- a/problems/splitting-a-string-into-descending-consecutive-values/README.md +++ b/problems/splitting-a-string-into-descending-consecutive-values/README.md @@ -50,15 +50,6 @@ The values are in descending order with adjacent values differing by 1. Explanation: There is no valid way to split s. -

    Example 4:

    - -
    -Input: s = "10009998"
    -Output: true
    -Explanation: s can be split into ["100", "099", "98"] with numerical values [100,99,98].
    -The values are in descending order with adjacent values differing by 1.
    -
    -

     

    Constraints:

    diff --git a/problems/squares-of-a-sorted-array/README.md b/problems/squares-of-a-sorted-array/README.md index db487bee4..d4c8ef936 100644 --- a/problems/squares-of-a-sorted-array/README.md +++ b/problems/squares-of-a-sorted-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-perimeter-triangle "Largest Perimeter Triangle") diff --git a/problems/stamping-the-grid/README.md b/problems/stamping-the-grid/README.md new file mode 100644 index 000000000..e11e22239 --- /dev/null +++ b/problems/stamping-the-grid/README.md @@ -0,0 +1,78 @@ + + + + + + + +[< Previous](../longest-palindrome-by-concatenating-two-letter-words "Longest Palindrome by Concatenating Two Letter Words") +                 +[Next >](../check-if-every-row-and-column-contains-all-numbers "Check if Every Row and Column Contains All Numbers") + +## [2132. Stamping the Grid (Hard)](https://leetcode.com/problems/stamping-the-grid "用邮票贴满网格图") + +

    You are given an m x n binary matrix grid where each cell is either 0 (empty) or 1 (occupied).

    + +

    You are then given stamps of size stampHeight x stampWidth. We want to fit the stamps such that they follow the given restrictions and requirements:

    + +
      +
    1. Cover all the empty cells.
    2. +
    3. Do not cover any of the occupied cells.
    4. +
    5. We can put as many stamps as we want.
    6. +
    7. Stamps can overlap with each other.
    8. +
    9. Stamps are not allowed to be rotated.
    10. +
    11. Stamps must stay completely inside the grid.
    12. +
    + +

    Return true if it is possible to fit the stamps while following the given restrictions and requirements. Otherwise, return false.

    + +

     

    +

    Example 1:

    + +
    +Input: grid = [[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0]], stampHeight = 4, stampWidth = 3
    +Output: true
    +Explanation: We have two overlapping stamps (labeled 1 and 2 in the image) that are able to cover all the empty cells.
    +
    + +

    Example 2:

    + +
    +Input: grid = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]], stampHeight = 2, stampWidth = 2 
    +Output: false 
    +Explanation: There is no way to fit the stamps onto all the empty cells without the stamps going outside the grid.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • m == grid.length
    • +
    • n == grid[r].length
    • +
    • 1 <= m, n <= 105
    • +
    • 1 <= m * n <= 2 * 105
    • +
    • grid[r][c] is either 0 or 1.
    • +
    • 1 <= stampHeight, stampWidth <= 105
    • +
    + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Matrix](../../tag/matrix/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + +### Hints +
    +Hint 1 +We can check if every empty cell is a part of a consecutive row of empty cells that has a width of at least stampWidth as well as a consecutive column of empty cells that has a height of at least stampHeight. +
    + +
    +Hint 2 +We can prove that this condition is sufficient and necessary to fit the stamps while following the given restrictions and requirements. +
    + +
    +Hint 3 +For each row, find every consecutive row of empty cells, and mark all the cells where the consecutive row is at least stampWidth wide. Do the same for the columns with stampHeight. Then, you can check if every cell is marked twice. +
    diff --git a/problems/stamping-the-sequence/README.md b/problems/stamping-the-sequence/README.md index b260b7a9b..9b995d25d 100644 --- a/problems/stamping-the-sequence/README.md +++ b/problems/stamping-the-sequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../knight-dialer "Knight Dialer") @@ -61,7 +61,7 @@ ### Related Topics + [[String](../../tag/string/README.md)] [[Stack](../../tag/stack/README.md)] [[Greedy](../../tag/greedy/README.md)] [[Queue](../../tag/queue/README.md)] - [[String](../../tag/string/README.md)] diff --git a/problems/step-by-step-directions-from-a-binary-tree-node-to-another/README.md b/problems/step-by-step-directions-from-a-binary-tree-node-to-another/README.md new file mode 100644 index 000000000..ad7f54d10 --- /dev/null +++ b/problems/step-by-step-directions-from-a-binary-tree-node-to-another/README.md @@ -0,0 +1,75 @@ + + + + + + + +[< Previous](../delete-the-middle-node-of-a-linked-list "Delete the Middle Node of a Linked List") +                 +[Next >](../valid-arrangement-of-pairs "Valid Arrangement of Pairs") + +## [2096. Step-By-Step Directions From a Binary Tree Node to Another (Medium)](https://leetcode.com/problems/step-by-step-directions-from-a-binary-tree-node-to-another "从二叉树一个节点到另一个节点每一步的方向") + +

    You are given the root of a binary tree with n nodes. Each node is uniquely assigned a value from 1 to n. You are also given an integer startValue representing the value of the start node s, and a different integer destValue representing the value of the destination node t.

    + +

    Find the shortest path starting from node s and ending at node t. Generate step-by-step directions of such path as a string consisting of only the uppercase letters 'L', 'R', and 'U'. Each letter indicates a specific direction:

    + +
      +
    • 'L' means to go from a node to its left child node.
    • +
    • 'R' means to go from a node to its right child node.
    • +
    • 'U' means to go from a node to its parent node.
    • +
    + +

    Return the step-by-step directions of the shortest path from node s to node t.

    + +

     

    +

    Example 1:

    + +
    +Input: root = [5,1,2,3,null,6,4], startValue = 3, destValue = 6
    +Output: "UURL"
    +Explanation: The shortest path is: 3 → 1 → 5 → 2 → 6.
    +
    + +

    Example 2:

    + +
    +Input: root = [2,1], startValue = 2, destValue = 1
    +Output: "L"
    +Explanation: The shortest path is: 2 → 1.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • The number of nodes in the tree is n.
    • +
    • 2 <= n <= 105
    • +
    • 1 <= Node.val <= n
    • +
    • All the values in the tree are unique.
    • +
    • 1 <= startValue, destValue <= n
    • +
    • startValue != destValue
    • +
    + +### Related Topics + [[Tree](../../tag/tree/README.md)] + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[String](../../tag/string/README.md)] + [[Binary Tree](../../tag/binary-tree/README.md)] + +### Hints +
    +Hint 1 +The shortest path between any two nodes in a tree must pass through their Lowest Common Ancestor (LCA). The path will travel upwards from node s to the LCA and then downwards from the LCA to node t. +
    + +
    +Hint 2 +Find the path strings from root → s, and root → t. Can you use these two strings to prepare the final answer? +
    + +
    +Hint 3 +Remove the longest common prefix of the two path strings to get the path LCA → s, and LCA → t. Each step in the path of LCA → s should be reversed as 'U'. +
    diff --git a/problems/stepping-numbers/README.md b/problems/stepping-numbers/README.md index 1ee2c7220..015aa8167 100644 --- a/problems/stepping-numbers/README.md +++ b/problems/stepping-numbers/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../two-sum-bsts "Two Sum BSTs") diff --git a/problems/stock-price-fluctuation/README.md b/problems/stock-price-fluctuation/README.md index 85f72ad28..993eb2005 100644 --- a/problems/stock-price-fluctuation/README.md +++ b/problems/stock-price-fluctuation/README.md @@ -69,6 +69,7 @@ stockPrice.minimum(); // return 2, the minimum price is 2 at timestamp 4. ### Related Topics [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] + [[Data Stream](../../tag/data-stream/README.md)] [[Ordered Set](../../tag/ordered-set/README.md)] [[Heap (Priority Queue)](../../tag/heap-priority-queue/README.md)] diff --git a/problems/stone-game-ii/README.md b/problems/stone-game-ii/README.md index 61c60a903..7a40acc4c 100644 --- a/problems/stone-game-ii/README.md +++ b/problems/stone-game-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../largest-1-bordered-square "Largest 1-Bordered Square") diff --git a/problems/stone-game-iii/README.md b/problems/stone-game-iii/README.md index e0f6523b3..cb4cc8145 100644 --- a/problems/stone-game-iii/README.md +++ b/problems/stone-game-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../longest-happy-string "Longest Happy String") @@ -11,17 +11,17 @@ ## [1406. Stone Game III (Hard)](https://leetcode.com/problems/stone-game-iii "石子游戏 III") -

    Alice and Bob continue their games with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.

    +

    Alice and Bob continue their games with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.

    -

    Alice and Bob take turns, with Alice starting first. On each player's turn, that player can take 1, 2 or 3 stones from the first remaining stones in the row.

    +

    Alice and Bob take turns, with Alice starting first. On each player's turn, that player can take 1, 2, or 3 stones from the first remaining stones in the row.

    -

    The score of each player is the sum of values of the stones taken. The score of each player is 0 initially.

    +

    The score of each player is the sum of the values of the stones taken. The score of each player is 0 initially.

    The objective of the game is to end with the highest score, and the winner is the player with the highest score and there could be a tie. The game continues until all the stones have been taken.

    -

    Assume Alice and Bob play optimally.

    +

    Assume Alice and Bob play optimally.

    -

    Return "Alice" if Alice will win, "Bob" if Bob will win or "Tie" if they end the game with the same score.

    +

    Return "Alice" if Alice will win, "Bob" if Bob will win, or "Tie" if they will end the game with the same score.

     

    Example 1:

    @@ -38,8 +38,8 @@ Input: values = [1,2,3,-9] Output: "Alice" Explanation: Alice must choose all the three piles at the first move to win and leave Bob with negative score. -If Alice chooses one pile her score will be 1 and the next move Bob's score becomes 5. The next move Alice will take the pile with value = -9 and lose. -If Alice chooses two piles her score will be 3 and the next move Bob's score becomes 3. The next move Alice will take the pile with value = -9 and also lose. +If Alice chooses one pile her score will be 1 and the next move Bob's score becomes 5. In the next move, Alice will take the pile with value = -9 and lose. +If Alice chooses two piles her score will be 3 and the next move Bob's score becomes 3. In the next move, Alice will take the pile with value = -9 and also lose. Remember that both play optimally so here Alice will choose the scenario that makes her win. @@ -51,26 +51,12 @@ Remember that both play optimally so here Alice will choose the scenario that ma Explanation: Alice cannot win this game. She can end the game in a draw if she decided to choose all the first three piles, otherwise she will lose. -

    Example 4:

    - -
    -Input: values = [1,2,3,-1,-2,-3,7]
    -Output: "Alice"
    -
    - -

    Example 5:

    - -
    -Input: values = [-1,-2,-3]
    -Output: "Tie"
    -
    -

     

    Constraints:

      -
    • 1 <= values.length <= 50000
    • -
    • -1000 <= values[i] <= 1000
    • +
    • 1 <= stoneValue.length <= 5 * 104
    • +
    • -1000 <= stoneValue[i] <= 1000
    ### Related Topics diff --git a/problems/stone-game-iv/README.md b/problems/stone-game-iv/README.md index e54c3fc94..e353d2524 100644 --- a/problems/stone-game-iv/README.md +++ b/problems/stone-game-iv/README.md @@ -13,11 +13,11 @@

    Alice and Bob take turns playing a game, with Alice starting first.

    -

    Initially, there are n stones in a pile.  On each player's turn, that player makes a move consisting of removing any non-zero square number of stones in the pile.

    +

    Initially, there are n stones in a pile. On each player's turn, that player makes a move consisting of removing any non-zero square number of stones in the pile.

    Also, if a player cannot make a move, he/she loses the game.

    -

    Given a positive integer n. Return True if and only if Alice wins the game otherwise return False, assuming both players play optimally.

    +

    Given a positive integer n, return true if and only if Alice wins the game otherwise return false, assuming both players play optimally.

     

    Example 1:

    @@ -32,7 +32,8 @@
     Input: n = 2
     Output: false
    -Explanation: Alice can only remove 1 stone, after that Bob removes the last one winning the game (2 -> 1 -> 0).
    +Explanation: Alice can only remove 1 stone, after that Bob removes the last one winning the game (2 -> 1 -> 0). +

    Example 3:

    @@ -42,28 +43,11 @@ Explanation: n is already a perfect square, Alice can win with one move, removing 4 stones (4 -> 0). -

    Example 4:

    - -
    -Input: n = 7
    -Output: false
    -Explanation: Alice can't win the game if Bob plays optimally.
    -If Alice starts removing 4 stones, Bob will remove 1 stone then Alice should remove only 1 stone and finally Bob removes the last one (7 -> 3 -> 2 -> 1 -> 0). 
    -If Alice starts removing 1 stone, Bob will remove 4 stones then Alice only can remove 1 stone and finally Bob removes the last one (7 -> 6 -> 2 -> 1 -> 0).
    - -

    Example 5:

    - -
    -Input: n = 17
    -Output: false
    -Explanation: Alice can't win the game if Bob plays optimally.
    -
    -

     

    Constraints:

      -
    • 1 <= n <= 10^5
    • +
    • 1 <= n <= 105
    ### Related Topics @@ -71,6 +55,13 @@ If Alice starts removing 1 stone, Bob will remove 4 stones then Alice only can r [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Game Theory](../../tag/game-theory/README.md)] +### Similar Questions + 1. [Stone Game V](../stone-game-v) (Hard) + 1. [Stone Game VI](../stone-game-vi) (Medium) + 1. [Stone Game VII](../stone-game-vii) (Medium) + 1. [Stone Game VIII](../stone-game-viii) (Hard) + 1. [Stone Game IX](../stone-game-ix) (Medium) + ### Hints
    Hint 1 diff --git a/problems/stone-game-vii/README.md b/problems/stone-game-vii/README.md index c84453367..5d1b5878e 100644 --- a/problems/stone-game-vii/README.md +++ b/problems/stone-game-vii/README.md @@ -55,17 +55,6 @@ The score difference is 18 - 12 = 6. [[Dynamic Programming](../../tag/dynamic-programming/README.md)] [[Game Theory](../../tag/game-theory/README.md)] -### Similar Questions - 1. [Stone Game](../stone-game) (Medium) - 1. [Stone Game II](../stone-game-ii) (Medium) - 1. [Stone Game III](../stone-game-iii) (Hard) - 1. [Stone Game IV](../stone-game-iv) (Hard) - 1. [Stone Game V](../stone-game-v) (Hard) - 1. [Stone Game VI](../stone-game-vi) (Medium) - 1. [Maximum Score from Performing Multiplication Operations](../maximum-score-from-performing-multiplication-operations) (Medium) - 1. [Stone Game VIII](../stone-game-viii) (Hard) - 1. [Stone Game IX](../stone-game-ix) (Medium) - ### Hints
    Hint 1 diff --git a/problems/strange-printer-ii/README.md b/problems/strange-printer-ii/README.md index efef2f8b8..4f5b30e03 100644 --- a/problems/strange-printer-ii/README.md +++ b/problems/strange-printer-ii/README.md @@ -24,18 +24,14 @@

     

    Example 1:

    - -

    - +
     Input: targetGrid = [[1,1,1,1],[1,2,2,1],[1,2,2,1],[1,1,1,1]]
     Output: true
     

    Example 2:

    - -

    - +
     Input: targetGrid = [[1,1,1,1],[1,1,3,3],[1,1,3,4],[5,5,1,4]]
     Output: true
    @@ -46,13 +42,7 @@
     
     Input: targetGrid = [[1,2,1],[2,1,2],[1,2,1]]
     Output: false
    -Explanation: It is impossible to form targetGrid because it is not allowed to print the same color in different turns.
    - -

    Example 4:

    - -
    -Input: targetGrid = [[1,1,1],[3,1,3]]
    -Output: false
    +Explanation: It is impossible to form targetGrid because it is not allowed to print the same color in different turns.
     

     

    diff --git a/problems/stream-of-characters/README.md b/problems/stream-of-characters/README.md index 1ed4f85dc..3f297045a 100644 --- a/problems/stream-of-characters/README.md +++ b/problems/stream-of-characters/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-sum-of-two-non-overlapping-subarrays "Maximum Sum of Two Non-Overlapping Subarrays") @@ -60,10 +60,10 @@ streamChecker.query("l"); // return True, because 'kl' is in t ### Related Topics - [[Design](../../tag/design/README.md)] - [[Trie](../../tag/trie/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] + [[Design](../../tag/design/README.md)] + [[Trie](../../tag/trie/README.md)] [[Data Stream](../../tag/data-stream/README.md)] ### Hints diff --git a/problems/string-matching-in-an-array/README.md b/problems/string-matching-in-an-array/README.md index 39e81221c..0465ce113 100644 --- a/problems/string-matching-in-an-array/README.md +++ b/problems/string-matching-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../top-travellers "Top Travellers") diff --git a/problems/string-to-integer-atoi/README.md b/problems/string-to-integer-atoi/README.md index f3583d52e..fc45cb209 100644 --- a/problems/string-to-integer-atoi/README.md +++ b/problems/string-to-integer-atoi/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../reverse-integer "Reverse Integer") @@ -80,38 +80,6 @@ The parsed integer is 4193. Since 4193 is in the range [-231, 231 - 1], the final result is 4193.
    -

    Example 4:

    - -
    -Input: s = "words and 987"
    -Output: 0
    -Explanation:
    -Step 1: "words and 987" (no characters read because there is no leading whitespace)
    -         ^
    -Step 2: "words and 987" (no characters read because there is neither a '-' nor '+')
    -         ^
    -Step 3: "words and 987" (reading stops immediately because there is a non-digit 'w')
    -         ^
    -The parsed integer is 0 because no digits were read.
    -Since 0 is in the range [-231, 231 - 1], the final result is 0.
    -
    - -

    Example 5:

    - -
    -Input: s = "-91283472332"
    -Output: -2147483648
    -Explanation:
    -Step 1: "-91283472332" (no characters read because there is no leading whitespace)
    -         ^
    -Step 2: "-91283472332" ('-' is read, so the result should be negative)
    -          ^
    -Step 3: "-91283472332" ("91283472332" is read in)
    -                     ^
    -The parsed integer is -91283472332.
    -Since -91283472332 is less than the lower bound of the range [-231, 231 - 1], the final result is clamped to -231 = -2147483648. 
    -
    -

     

    Constraints:

    @@ -124,5 +92,6 @@ Since -91283472332 is less than the lower bound of the range [-231, 2 [[String](../../tag/string/README.md)] ### Similar Questions - 1. [Reverse Integer](../reverse-integer) (Easy) + 1. [Reverse Integer](../reverse-integer) (Medium) 1. [Valid Number](../valid-number) (Hard) + 1. [Check if Numbers Are Ascending in a Sentence](../check-if-numbers-are-ascending-in-a-sentence) (Easy) diff --git a/problems/strings-differ-by-one-character/README.md b/problems/strings-differ-by-one-character/README.md index 16a62cb47..497638a14 100644 --- a/problems/strings-differ-by-one-character/README.md +++ b/problems/strings-differ-by-one-character/README.md @@ -16,8 +16,8 @@ ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Rolling Hash](../../tag/rolling-hash/README.md)] [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] ### Hints
    diff --git a/problems/strobogrammatic-number-iii/README.md b/problems/strobogrammatic-number-iii/README.md index 4648f1223..6ba33e54b 100644 --- a/problems/strobogrammatic-number-iii/README.md +++ b/problems/strobogrammatic-number-iii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../strobogrammatic-number-ii "Strobogrammatic Number II") diff --git a/problems/strobogrammatic-number/README.md b/problems/strobogrammatic-number/README.md index 805989ec0..781c90165 100644 --- a/problems/strobogrammatic-number/README.md +++ b/problems/strobogrammatic-number/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-word-distance-iii "Shortest Word Distance III") diff --git a/problems/strong-friendship/README.md b/problems/strong-friendship/README.md index d02716190..793c73063 100644 --- a/problems/strong-friendship/README.md +++ b/problems/strong-friendship/README.md @@ -9,7 +9,7 @@                  [Next >](../maximum-of-minimum-values-in-all-subarrays "Maximum of Minimum Values in All Subarrays") -## [1949. Strong Friendship (Medium)](https://leetcode.com/problems/strong-friendship "") +## [1949. Strong Friendship (Medium)](https://leetcode.com/problems/strong-friendship "坚定的友谊") diff --git a/problems/student-attendance-record-ii/README.md b/problems/student-attendance-record-ii/README.md index 2db7f1dce..6931ce270 100644 --- a/problems/student-attendance-record-ii/README.md +++ b/problems/student-attendance-record-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../student-attendance-record-i "Student Attendance Record I") diff --git a/problems/subrectangle-queries/README.md b/problems/subrectangle-queries/README.md index fd1f45944..2f116e489 100644 --- a/problems/subrectangle-queries/README.md +++ b/problems/subrectangle-queries/README.md @@ -94,8 +94,8 @@ subrectangleQueries.getValue(2, 2); // return 20 ### Related Topics - [[Design](../../tag/design/README.md)] [[Array](../../tag/array/README.md)] + [[Design](../../tag/design/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Hints diff --git a/problems/subsequence-of-size-k-with-the-largest-even-sum/README.md b/problems/subsequence-of-size-k-with-the-largest-even-sum/README.md new file mode 100644 index 000000000..b37446fc3 --- /dev/null +++ b/problems/subsequence-of-size-k-with-the-largest-even-sum/README.md @@ -0,0 +1,35 @@ + + + + + + + +[< Previous](../valid-arrangement-of-pairs "Valid Arrangement of Pairs") +                 +[Next >](../find-subsequence-of-length-k-with-the-largest-sum "Find Subsequence of Length K With the Largest Sum") + +## [2098. Subsequence of Size K With the Largest Even Sum (Medium)](https://leetcode.com/problems/subsequence-of-size-k-with-the-largest-even-sum "") + + + +### Related Topics + [[Greedy](../../tag/greedy/README.md)] + [[Array](../../tag/array/README.md)] + [[Sorting](../../tag/sorting/README.md)] + +### Hints +
    +Hint 1 +Is the sum of two even numbers even or odd? How about two odd numbers? One odd number and one even number? +
    + +
    +Hint 2 +If there is an even number of odd numbers, the sum will be even and vice versa. +
    + +
    +Hint 3 +Create an integer array to store all the even numbers in nums and another array to store all the odd numbers in nums. Sort both arrays. +
    diff --git a/problems/substrings-of-size-three-with-distinct-characters/README.md b/problems/substrings-of-size-three-with-distinct-characters/README.md index ee678eb6c..eedd2515f 100644 --- a/problems/substrings-of-size-three-with-distinct-characters/README.md +++ b/problems/substrings-of-size-three-with-distinct-characters/README.md @@ -49,8 +49,8 @@ The good substrings are "abc", "bca", "cab", and & ### Related Topics [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] - [[Sliding Window](../../tag/sliding-window/README.md)] [[Counting](../../tag/counting/README.md)] + [[Sliding Window](../../tag/sliding-window/README.md)] ### Hints
    diff --git a/problems/substrings-that-begin-and-end-with-the-same-letter/README.md b/problems/substrings-that-begin-and-end-with-the-same-letter/README.md index d3d18e50a..0bd2bd07a 100644 --- a/problems/substrings-that-begin-and-end-with-the-same-letter/README.md +++ b/problems/substrings-that-begin-and-end-with-the-same-letter/README.md @@ -9,10 +9,17 @@                  [Next >](../drop-type-1-orders-for-customers-with-type-0-orders "Drop Type 1 Orders for Customers With Type 0 Orders") -## [2083. Substrings That Begin and End With the Same Letter (Medium)](https://leetcode.com/problems/substrings-that-begin-and-end-with-the-same-letter "") +## [2083. Substrings That Begin and End With the Same Letter (Medium)](https://leetcode.com/problems/substrings-that-begin-and-end-with-the-same-letter "求以相同字母开头和结尾的子串总数") +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[Math](../../tag/math/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Prefix Sum](../../tag/prefix-sum/README.md)] + ### Hints
    Hint 1 diff --git a/problems/subtree-removal-game-with-fibonacci-tree/README.md b/problems/subtree-removal-game-with-fibonacci-tree/README.md index 07cd9d6f4..094bb4c14 100644 --- a/problems/subtree-removal-game-with-fibonacci-tree/README.md +++ b/problems/subtree-removal-game-with-fibonacci-tree/README.md @@ -9,7 +9,7 @@                  [Next >](../count-number-of-pairs-with-absolute-difference-k "Count Number of Pairs With Absolute Difference K") -## [2005. Subtree Removal Game with Fibonacci Tree (Hard)](https://leetcode.com/problems/subtree-removal-game-with-fibonacci-tree "") +## [2005. Subtree Removal Game with Fibonacci Tree (Hard)](https://leetcode.com/problems/subtree-removal-game-with-fibonacci-tree "斐波那契树的移除子树游戏") diff --git a/problems/sudoku-solver/README.md b/problems/sudoku-solver/README.md index beb8613ad..df556e33c 100644 --- a/problems/sudoku-solver/README.md +++ b/problems/sudoku-solver/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../valid-sudoku "Valid Sudoku") diff --git a/problems/sum-of-square-numbers/README.md b/problems/sum-of-square-numbers/README.md index 1a6589b9a..bdd0de9dd 100644 --- a/problems/sum-of-square-numbers/README.md +++ b/problems/sum-of-square-numbers/README.md @@ -29,27 +29,6 @@ Output: false -

    Example 3:

    - -
    -Input: c = 4
    -Output: true
    -
    - -

    Example 4:

    - -
    -Input: c = 2
    -Output: true
    -
    - -

    Example 5:

    - -
    -Input: c = 1
    -Output: true
    -
    -

     

    Constraints:

    diff --git a/problems/sum-of-subarray-minimums/README.md b/problems/sum-of-subarray-minimums/README.md index bb47a9d74..ee1e208f7 100644 --- a/problems/sum-of-subarray-minimums/README.md +++ b/problems/sum-of-subarray-minimums/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../super-palindromes "Super Palindromes") diff --git a/problems/sum-of-subarray-ranges/README.md b/problems/sum-of-subarray-ranges/README.md new file mode 100644 index 000000000..78e5d4cbd --- /dev/null +++ b/problems/sum-of-subarray-ranges/README.md @@ -0,0 +1,83 @@ + + + + + + + +[< Previous](../rings-and-rods "Rings and Rods") +                 +[Next >](../watering-plants-ii "Watering Plants II") + +## [2104. Sum of Subarray Ranges (Medium)](https://leetcode.com/problems/sum-of-subarray-ranges "子数组范围和") + +

    You are given an integer array nums. The range of a subarray of nums is the difference between the largest and smallest element in the subarray.

    + +

    Return the sum of all subarray ranges of nums.

    + +

    A subarray is a contiguous non-empty sequence of elements within an array.

    + +

     

    +

    Example 1:

    + +
    +Input: nums = [1,2,3]
    +Output: 4
    +Explanation: The 6 subarrays of nums are the following:
    +[1], range = largest - smallest = 1 - 1 = 0 
    +[2], range = 2 - 2 = 0
    +[3], range = 3 - 3 = 0
    +[1,2], range = 2 - 1 = 1
    +[2,3], range = 3 - 2 = 1
    +[1,2,3], range = 3 - 1 = 2
    +So the sum of all ranges is 0 + 0 + 0 + 1 + 1 + 2 = 4.
    + +

    Example 2:

    + +
    +Input: nums = [1,3,3]
    +Output: 4
    +Explanation: The 6 subarrays of nums are the following:
    +[1], range = largest - smallest = 1 - 1 = 0
    +[3], range = 3 - 3 = 0
    +[3], range = 3 - 3 = 0
    +[1,3], range = 3 - 1 = 2
    +[3,3], range = 3 - 3 = 0
    +[1,3,3], range = 3 - 1 = 2
    +So the sum of all ranges is 0 + 0 + 0 + 2 + 0 + 2 = 4.
    +
    + +

    Example 3:

    + +
    +Input: nums = [4,-2,-3,4,1]
    +Output: 59
    +Explanation: The sum of all subarray ranges of nums is 59.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= nums.length <= 1000
    • +
    • -109 <= nums[i] <= 109
    • +
    + +

     

    +

    Follow-up: Could you find a solution with O(n) time complexity?

    + +### Related Topics + [[Stack](../../tag/stack/README.md)] + [[Array](../../tag/array/README.md)] + [[Monotonic Stack](../../tag/monotonic-stack/README.md)] + +### Hints +
    +Hint 1 +Can you get the max/min of a certain subarray by using the max/min of a smaller subarray within it? +
    + +
    +Hint 2 +Notice that the max of the subarray from index i to j is equal to max of (max of the subarray from index i to j-1) and nums[j]. +
    diff --git a/problems/sum-of-subsequence-widths/README.md b/problems/sum-of-subsequence-widths/README.md index ed7f78ad6..237896b1c 100644 --- a/problems/sum-of-subsequence-widths/README.md +++ b/problems/sum-of-subsequence-widths/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../find-and-replace-pattern "Find and Replace Pattern") diff --git a/problems/surface-area-of-3d-shapes/README.md b/problems/surface-area-of-3d-shapes/README.md index cc90f7bea..26186f55f 100644 --- a/problems/surface-area-of-3d-shapes/README.md +++ b/problems/surface-area-of-3d-shapes/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../sum-of-subsequence-widths "Sum of Subsequence Widths") @@ -21,34 +21,20 @@

     

    Example 1:

    - -
    -Input: grid = [[2]]
    -Output: 10
    -
    - -

    Example 2:

     Input: grid = [[1,2],[3,4]]
     Output: 34
     
    -

    Example 3:

    - -
    -Input: grid = [[1,0],[0,2]]
    -Output: 16
    -
    - -

    Example 4:

    +

    Example 2:

     Input: grid = [[1,1,1],[1,0,1],[1,1,1]]
     Output: 32
     
    -

    Example 5:

    +

    Example 3:

     Input: grid = [[2,2,2],[2,1,2],[2,2,2]]
    @@ -59,8 +45,7 @@
     

    Constraints:

      -
    • n == grid.length
    • -
    • n == grid[i].length
    • +
    • n == grid.length == grid[i].length
    • 1 <= n <= 50
    • 0 <= grid[i][j] <= 50
    diff --git a/problems/surrounded-regions/README.md b/problems/surrounded-regions/README.md index b0fdb237d..ed9eb8e89 100644 --- a/problems/surrounded-regions/README.md +++ b/problems/surrounded-regions/README.md @@ -42,10 +42,10 @@ ### Related Topics + [[Array](../../tag/array/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Breadth-First Search](../../tag/breadth-first-search/README.md)] [[Union Find](../../tag/union-find/README.md)] - [[Array](../../tag/array/README.md)] [[Matrix](../../tag/matrix/README.md)] ### Similar Questions diff --git a/problems/suspicious-bank-accounts/README.md b/problems/suspicious-bank-accounts/README.md index 5d8cdf1ff..10a9cba44 100644 --- a/problems/suspicious-bank-accounts/README.md +++ b/problems/suspicious-bank-accounts/README.md @@ -9,7 +9,7 @@                  [Next >](../replace-all-digits-with-characters "Replace All Digits with Characters") -## [1843. Suspicious Bank Accounts (Medium)](https://leetcode.com/problems/suspicious-bank-accounts "") +## [1843. Suspicious Bank Accounts (Medium)](https://leetcode.com/problems/suspicious-bank-accounts "可疑银行账户") diff --git a/problems/swap-adjacent-in-lr-string/README.md b/problems/swap-adjacent-in-lr-string/README.md index ae714477d..ccc6e21f8 100644 --- a/problems/swap-adjacent-in-lr-string/README.md +++ b/problems/swap-adjacent-in-lr-string/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../split-bst "Split BST") @@ -34,27 +34,6 @@ XRLXXRRLX Output: false
    -

    Example 3:

    - -
    -Input: start = "LLR", end = "RRL"
    -Output: false
    -
    - -

    Example 4:

    - -
    -Input: start = "XL", end = "LX"
    -Output: true
    -
    - -

    Example 5:

    - -
    -Input: start = "XLLR", end = "LXLX"
    -Output: false
    -
    -

     

    Constraints:

    diff --git a/problems/swap-for-longest-repeated-character-substring/README.md b/problems/swap-for-longest-repeated-character-substring/README.md index 117c95cdd..d4f009b32 100644 --- a/problems/swap-for-longest-repeated-character-substring/README.md +++ b/problems/swap-for-longest-repeated-character-substring/README.md @@ -21,7 +21,7 @@
     Input: text = "ababa"
     Output: 3
    -Explanation: We can swap the first 'b' with the last 'a', or the last 'b' with the first 'a'. Then, the longest repeated character substring is "aaa", which its length is 3.
    +Explanation: We can swap the first 'b' with the last 'a', or the last 'b' with the first 'a'. Then, the longest repeated character substring is "aaa" with length 3.
     

    Example 2:

    @@ -29,29 +29,15 @@
     Input: text = "aaabaaa"
     Output: 6
    -Explanation: Swap 'b' with the last 'a' (or the first 'a'), and we get longest repeated character substring "aaaaaa", which its length is 6.
    +Explanation: Swap 'b' with the last 'a' (or the first 'a'), and we get longest repeated character substring "aaaaaa" with length 6.
     

    Example 3:

    -
    -Input: text = "aaabbaaa"
    -Output: 4
    -
    - -

    Example 4:

    -
     Input: text = "aaaaa"
     Output: 5
    -Explanation: No need to swap, longest repeated character substring is "aaaaa", length is 5.
    -
    - -

    Example 5:

    - -
    -Input: text = "abcdef"
    -Output: 1
    +Explanation: No need to swap, longest repeated character substring is "aaaaa" with length is 5.
     

     

    diff --git a/problems/swapping-nodes-in-a-linked-list/README.md b/problems/swapping-nodes-in-a-linked-list/README.md index 6ec21a3ad..230f24024 100644 --- a/problems/swapping-nodes-in-a-linked-list/README.md +++ b/problems/swapping-nodes-in-a-linked-list/README.md @@ -17,7 +17,7 @@

     

    Example 1:

    - +
     Input: head = [1,2,3,4,5], k = 2
     Output: [1,4,3,2,5]
    @@ -30,27 +30,6 @@
     Output: [7,9,6,6,8,7,3,0,9,5]
     
    -

    Example 3:

    - -
    -Input: head = [1], k = 1
    -Output: [1]
    -
    - -

    Example 4:

    - -
    -Input: head = [1,2], k = 1
    -Output: [2,1]
    -
    - -

    Example 5:

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

     

    Constraints:

    @@ -64,6 +43,11 @@ [[Linked List](../../tag/linked-list/README.md)] [[Two Pointers](../../tag/two-pointers/README.md)] +### Similar Questions + 1. [Remove Nth Node From End of List](../remove-nth-node-from-end-of-list) (Medium) + 1. [Swap Nodes in Pairs](../swap-nodes-in-pairs) (Medium) + 1. [Reverse Nodes in k-Group](../reverse-nodes-in-k-group) (Hard) + ### Hints
    Hint 1 diff --git a/problems/symmetric-tree/README.md b/problems/symmetric-tree/README.md index b10b5a489..d5627165a 100644 --- a/problems/symmetric-tree/README.md +++ b/problems/symmetric-tree/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../same-tree "Same Tree") diff --git a/problems/synonymous-sentences/README.md b/problems/synonymous-sentences/README.md index 3bac93e3b..011fc9ffe 100644 --- a/problems/synonymous-sentences/README.md +++ b/problems/synonymous-sentences/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../smallest-common-region "Smallest Common Region") @@ -40,11 +40,11 @@ text = "I am happy today but was sad yesterday" ### Related Topics - [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Union Find](../../tag/union-find/README.md)] ### Hints
    diff --git a/problems/the-airport-with-the-most-traffic/README.md b/problems/the-airport-with-the-most-traffic/README.md new file mode 100644 index 000000000..00c570b75 --- /dev/null +++ b/problems/the-airport-with-the-most-traffic/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../minimum-operations-to-make-the-array-k-increasing "Minimum Operations to Make the Array K-Increasing") +                 +[Next >](../elements-in-array-after-removing-and-replacing-elements "Elements in Array After Removing and Replacing Elements") + +## [2112. The Airport With the Most Traffic (Medium)](https://leetcode.com/problems/the-airport-with-the-most-traffic "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/the-airport-with-the-most-traffic/mysql_schemas.sql b/problems/the-airport-with-the-most-traffic/mysql_schemas.sql new file mode 100644 index 000000000..2c4c276f3 --- /dev/null +++ b/problems/the-airport-with-the-most-traffic/mysql_schemas.sql @@ -0,0 +1,5 @@ +Create table If Not Exists Flights (departure_airport int, arrival_airport int, flights_count int); +Truncate table Flights; +insert into Flights (departure_airport, arrival_airport, flights_count) values ('1', '2', '4'); +insert into Flights (departure_airport, arrival_airport, flights_count) values ('2', '1', '5'); +insert into Flights (departure_airport, arrival_airport, flights_count) values ('2', '4', '5'); diff --git a/problems/the-earliest-moment-when-everyone-become-friends/README.md b/problems/the-earliest-moment-when-everyone-become-friends/README.md index 5dd41821e..97e5581bb 100644 --- a/problems/the-earliest-moment-when-everyone-become-friends/README.md +++ b/problems/the-earliest-moment-when-everyone-become-friends/README.md @@ -52,8 +52,8 @@ The sixth event occurs at timestamp = 20190301 and after 0 and 3 become friends ### Related Topics - [[Union Find](../../tag/union-find/README.md)] [[Array](../../tag/array/README.md)] + [[Union Find](../../tag/union-find/README.md)] ### Similar Questions 1. [Number of Provinces](../number-of-provinces) (Medium) diff --git a/problems/the-k-strongest-values-in-an-array/README.md b/problems/the-k-strongest-values-in-an-array/README.md index 2249537cb..d063932a0 100644 --- a/problems/the-k-strongest-values-in-an-array/README.md +++ b/problems/the-k-strongest-values-in-an-array/README.md @@ -11,18 +11,18 @@ ## [1471. The k Strongest Values in an Array (Medium)](https://leetcode.com/problems/the-k-strongest-values-in-an-array "数组中的 k 个最强值") -

    Given an array of integers arr and an integer k.

    +

    Given an array of integers arr and an integer k.

    -

    A value arr[i] is said to be stronger than a value arr[j] if |arr[i] - m| > |arr[j] - m| where m is the median of the array.
    +

    A value arr[i] is said to be stronger than a value arr[j] if |arr[i] - m| > |arr[j] - m| where m is the median of the array.
    If |arr[i] - m| == |arr[j] - m|, then arr[i] is said to be stronger than arr[j] if arr[i] > arr[j].

    Return a list of the strongest k values in the array. return the answer in any arbitrary order.

    -

    Median is the middle value in an ordered integer list. More formally, if the length of the list is n, the median is the element in position ((n - 1) / 2) in the sorted list (0-indexed).

    +

    Median is the middle value in an ordered integer list. More formally, if the length of the list is n, the median is the element in position ((n - 1) / 2) in the sorted list (0-indexed).

      -
    • For arr = [6, -3, 7, 2, 11]n = 5 and the median is obtained by sorting the array arr = [-3, 2, 6, 7, 11] and the median is arr[m] where m = ((5 - 1) / 2) = 2. The median is 6.
    • -
    • For arr = [-7, 22, 17, 3]n = 4 and the median is obtained by sorting the array arr = [-7, 3, 17, 22] and the median is arr[m] where m = ((4 - 1) / 2) = 1. The median is 3.
    • +
    • For arr = [6, -3, 7, 2, 11], n = 5 and the median is obtained by sorting the array arr = [-3, 2, 6, 7, 11] and the median is arr[m] where m = ((5 - 1) / 2) = 2. The median is 6.
    • +
    • For arr = [-7, 22, 17, 3], n = 4 and the median is obtained by sorting the array arr = [-7, 3, 17, 22] and the median is arr[m] where m = ((4 - 1) / 2) = 1. The median is 3.

     

    @@ -52,26 +52,12 @@ Please note that although |5 - 3| == |1 - 3| but 5 is stronger than 1 because 5 Any permutation of [11,8,6,6,7] is accepted. -

    Example 4:

    - -
    -Input: arr = [6,-3,7,2,11], k = 3
    -Output: [-3,11,2]
    -
    - -

    Example 5:

    - -
    -Input: arr = [-7,22,17,3], k = 2
    -Output: [22,17]
    -
    -

     

    Constraints:

      -
    • 1 <= arr.length <= 10^5
    • -
    • -10^5 <= arr[i] <= 10^5
    • +
    • 1 <= arr.length <= 105
    • +
    • -105 <= arr[i] <= 105
    • 1 <= k <= arr.length
    diff --git a/problems/the-kth-factor-of-n/README.md b/problems/the-kth-factor-of-n/README.md index 50dfaa95a..ce9c4a33b 100644 --- a/problems/the-kth-factor-of-n/README.md +++ b/problems/the-kth-factor-of-n/README.md @@ -11,11 +11,9 @@ ## [1492. The kth Factor of n (Medium)](https://leetcode.com/problems/the-kth-factor-of-n "n 的第 k 个因子") -

    Given two positive integers n and k.

    +

    You are given two positive integers n and k. A factor of an integer n is defined as an integer i where n % i == 0.

    -

    A factor of an integer n is defined as an integer i where n % i == 0.

    - -

    Consider a list of all factors of n sorted in ascending order, return the kth factor in this list or return -1 if n has less than k factors.

    +

    Consider a list of all factors of n sorted in ascending order, return the kth factor in this list or return -1 if n has less than k factors.

     

    Example 1:

    @@ -23,7 +21,7 @@
     Input: n = 12, k = 3
     Output: 3
    -Explanation: Factors list is [1, 2, 3, 4, 6, 12], the 3rd factor is 3.
    +Explanation: Factors list is [1, 2, 3, 4, 6, 12], the 3rd factor is 3.
     

    Example 2:

    @@ -31,7 +29,7 @@
     Input: n = 7, k = 2
     Output: 7
    -Explanation: Factors list is [1, 7], the 2nd factor is 7.
    +Explanation: Factors list is [1, 7], the 2nd factor is 7.
     

    Example 3:

    @@ -42,22 +40,6 @@ Explanation: Factors list is [1, 2, 4], there is only 3 factors. We should return -1. -

    Example 4:

    - -
    -Input: n = 1, k = 1
    -Output: 1
    -Explanation: Factors list is [1], the 1st factor is 1.
    -
    - -

    Example 5:

    - -
    -Input: n = 1000, k = 3
    -Output: 4
    -Explanation: Factors list is [1, 2, 4, 5, 8, 10, 20, 25, 40, 50, 100, 125, 200, 250, 500, 1000].
    -
    -

     

    Constraints:

    diff --git a/problems/the-most-frequently-ordered-products-for-each-customer/README.md b/problems/the-most-frequently-ordered-products-for-each-customer/README.md index 876cd2c83..e820d61c9 100644 --- a/problems/the-most-frequently-ordered-products-for-each-customer/README.md +++ b/problems/the-most-frequently-ordered-products-for-each-customer/README.md @@ -15,3 +15,6 @@ ### Related Topics [[Database](../../tag/database/README.md)] + +### Similar Questions + 1. [The Most Recent Orders for Each Product](../the-most-recent-orders-for-each-product) (Medium) diff --git a/problems/the-number-of-full-rounds-you-have-played/README.md b/problems/the-number-of-full-rounds-you-have-played/README.md index 72715c1e9..79d5b74f0 100644 --- a/problems/the-number-of-full-rounds-you-have-played/README.md +++ b/problems/the-number-of-full-rounds-you-have-played/README.md @@ -11,54 +11,53 @@ ## [1904. The Number of Full Rounds You Have Played (Medium)](https://leetcode.com/problems/the-number-of-full-rounds-you-have-played "你完成的完整对局数") -

    A new online video game has been released, and in this video game, there are 15-minute rounds scheduled every quarter-hour period. This means that at HH:00, HH:15, HH:30 and HH:45, a new round starts, where HH represents an integer number from 00 to 23. A 24-hour clock is used, so the earliest time in the day is 00:00 and the latest is 23:59.

    +

    You are participating in an online chess tournament. There is a chess round that starts every 15 minutes. The first round of the day starts at 00:00, and after every 15 minutes, a new round starts.

    -

    Given two strings startTime and finishTime in the format "HH:MM" representing the exact time you started and finished playing the game, respectively, calculate the number of full rounds that you played during your game session.

    +
      +
    • For example, the second round starts at 00:15, the fourth round starts at 00:45, and the seventh round starts at 01:30.
    • +
    + +

    You are given two strings loginTime and logoutTime where:

      -
    • For example, if startTime = "05:20" and finishTime = "05:59" this means you played only one full round from 05:30 to 05:45. You did not play the full round from 05:15 to 05:30 because you started after the round began, and you did not play the full round from 05:45 to 06:00 because you stopped before the round ended.
    • +
    • loginTime is the time you will login to the game, and
    • +
    • logoutTime is the time you will logout from the game.
    -

    If finishTime is earlier than startTime, this means you have played overnight (from startTime to the midnight and from midnight to finishTime).

    +

    If logoutTime is earlier than loginTime, this means you have played from loginTime to midnight and from midnight to logoutTime.

    + +

    Return the number of full chess rounds you have played in the tournament.

    -

    Return the number of full rounds that you have played if you had started playing at startTime and finished at finishTime.

    +

    Note: All the given times follow the 24-hour clock. That means the first round of the day starts at 00:00 and the last round of the day starts at 23:45.

     

    Example 1:

    -Input: startTime = "12:01", finishTime = "12:44"
    +Input: loginTime = "09:31", logoutTime = "10:14"
     Output: 1
    -Explanation: You played one full round from 12:15 to 12:30.
    -You did not play the full round from 12:00 to 12:15 because you started playing at 12:01 after it began.
    -You did not play the full round from 12:30 to 12:45 because you stopped playing at 12:44 before it ended.
    +Explanation: You played one full round from 09:45 to 10:00.
    +You did not play the full round from 09:30 to 09:45 because you logged in at 09:31 after it began.
    +You did not play the full round from 10:00 to 10:15 because you logged out at 10:14 before it ended.
     

    Example 2:

    -Input: startTime = "20:00", finishTime = "06:00"
    -Output: 40
    -Explanation: You played 16 full rounds from 20:00 to 00:00 and 24 full rounds from 00:00 to 06:00.
    -16 + 24 = 40.
    -
    - -

    Example 3:

    - -
    -Input: startTime = "00:00", finishTime = "23:59"
    -Output: 95
    -Explanation: You played 4 full rounds each hour except for the last hour where you played 3 full rounds.
    +Input: loginTime = "21:30", logoutTime = "03:00"
    +Output: 22
    +Explanation: You played 10 full rounds from 21:30 to 00:00 and 12 full rounds from 00:00 to 03:00.
    +10 + 12 = 22.
     

     

    Constraints:

      -
    • startTime and finishTime are in the format HH:MM.
    • -
    • 00 <= HH <= 23
    • -
    • 00 <= MM <= 59
    • -
    • startTime and finishTime are not equal.
    • +
    • loginTime and logoutTime are in the format hh:mm.
    • +
    • 00 <= hh <= 23
    • +
    • 00 <= mm <= 59
    • +
    • loginTime and logoutTime are not equal.
    ### Related Topics diff --git a/problems/the-number-of-passengers-in-each-bus-i/README.md b/problems/the-number-of-passengers-in-each-bus-i/README.md new file mode 100644 index 000000000..42c598909 --- /dev/null +++ b/problems/the-number-of-passengers-in-each-bus-i/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../maximum-running-time-of-n-computers "Maximum Running Time of N Computers") +                 +[Next >](../choose-numbers-from-two-arrays-in-range "Choose Numbers From Two Arrays in Range") + +## [2142. The Number of Passengers in Each Bus I (Medium)](https://leetcode.com/problems/the-number-of-passengers-in-each-bus-i "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/the-number-of-passengers-in-each-bus-i/mysql_schemas.sql b/problems/the-number-of-passengers-in-each-bus-i/mysql_schemas.sql new file mode 100644 index 000000000..0fc11eefe --- /dev/null +++ b/problems/the-number-of-passengers-in-each-bus-i/mysql_schemas.sql @@ -0,0 +1,11 @@ +Create table If Not Exists Buses (bus_id int, arrival_time int); +Create table If Not Exists Passengers (passenger_id int, arrival_time int); +Truncate table Buses; +insert into Buses (bus_id, arrival_time) values ('1', '2'); +insert into Buses (bus_id, arrival_time) values ('2', '4'); +insert into Buses (bus_id, arrival_time) values ('3', '7'); +Truncate table Passengers; +insert into Passengers (passenger_id, arrival_time) values ('11', '1'); +insert into Passengers (passenger_id, arrival_time) values ('12', '5'); +insert into Passengers (passenger_id, arrival_time) values ('13', '6'); +insert into Passengers (passenger_id, arrival_time) values ('14', '7'); diff --git a/problems/the-number-of-passengers-in-each-bus-ii/README.md b/problems/the-number-of-passengers-in-each-bus-ii/README.md new file mode 100644 index 000000000..55bbc3466 --- /dev/null +++ b/problems/the-number-of-passengers-in-each-bus-ii/README.md @@ -0,0 +1,17 @@ + + + + + + + +[< Previous](../minimum-number-of-lines-to-cover-points "Minimum Number of Lines to Cover Points") +                 +[Next >](../keep-multiplying-found-values-by-two "Keep Multiplying Found Values by Two") + +## [2153. The Number of Passengers in Each Bus II (Hard)](https://leetcode.com/problems/the-number-of-passengers-in-each-bus-ii "") + + + +### Related Topics + [[Database](../../tag/database/README.md)] diff --git a/problems/the-number-of-passengers-in-each-bus-ii/mysql_schemas.sql b/problems/the-number-of-passengers-in-each-bus-ii/mysql_schemas.sql new file mode 100644 index 000000000..58e4a205c --- /dev/null +++ b/problems/the-number-of-passengers-in-each-bus-ii/mysql_schemas.sql @@ -0,0 +1,12 @@ +Create table If Not Exists Buses (bus_id int, arrival_time int, capacity int); +Create table If Not Exists Passengers (passenger_id int, arrival_time int); +Truncate table Buses; +insert into Buses (bus_id, arrival_time, capacity) values ('1', '2', '1'); +insert into Buses (bus_id, arrival_time, capacity) values ('2', '4', '10'); +insert into Buses (bus_id, arrival_time, capacity) values ('3', '7', '2'); +Truncate table Passengers; +insert into Passengers (passenger_id, arrival_time) values ('11', '1'); +insert into Passengers (passenger_id, arrival_time) values ('12', '1'); +insert into Passengers (passenger_id, arrival_time) values ('13', '5'); +insert into Passengers (passenger_id, arrival_time) values ('14', '6'); +insert into Passengers (passenger_id, arrival_time) values ('15', '7'); diff --git a/problems/the-number-of-rich-customers/README.md b/problems/the-number-of-rich-customers/README.md index c9d106c47..9cde4d167 100644 --- a/problems/the-number-of-rich-customers/README.md +++ b/problems/the-number-of-rich-customers/README.md @@ -9,7 +9,7 @@                  [Next >](../substrings-that-begin-and-end-with-the-same-letter "Substrings That Begin and End With the Same Letter") -## [2082. The Number of Rich Customers (Easy)](https://leetcode.com/problems/the-number-of-rich-customers "") +## [2082. The Number of Rich Customers (Easy)](https://leetcode.com/problems/the-number-of-rich-customers "富有客户的数量") diff --git a/problems/the-score-of-students-solving-math-expression/README.md b/problems/the-score-of-students-solving-math-expression/README.md index d4f8632b1..d6b8d68bc 100644 --- a/problems/the-score-of-students-solving-math-expression/README.md +++ b/problems/the-score-of-students-solving-math-expression/README.md @@ -60,19 +60,6 @@ By the rules of grading, the students will still be rewarded 5 points (as they g The points for the students are: [0,0,5,0,0,5]. The sum of the points is 10. -

    Example 4:

    - -
    -Input: s = "1+2*3+4", answers = [13,21,11,15]
    -Output: 11
    -Explanation: The correct answer of the expression is 11.
    -Every other student was rewarded 2 points because they could have applied the operators as follows:
    -- ((1+2)*3)+4 = 13
    -- (1+2)*(3+4) = 21
    -- 1+(2*(3+4)) = 15
    -The points for the students are: [2,2,5,2]. The sum of the points is 11.
    -
    -

     

    Constraints:

    diff --git a/problems/the-winner-university/README.md b/problems/the-winner-university/README.md index aa1d5cf91..569867b73 100644 --- a/problems/the-winner-university/README.md +++ b/problems/the-winner-university/README.md @@ -9,7 +9,7 @@                  [Next >](../time-needed-to-buy-tickets "Time Needed to Buy Tickets") -## [2072. The Winner University (Easy)](https://leetcode.com/problems/the-winner-university "") +## [2072. The Winner University (Easy)](https://leetcode.com/problems/the-winner-university "赢得比赛的大学") diff --git a/problems/thousand-separator/README.md b/problems/thousand-separator/README.md index 66c20c984..87bf7dfd4 100644 --- a/problems/thousand-separator/README.md +++ b/problems/thousand-separator/README.md @@ -28,25 +28,11 @@ Output: "1.234" -

    Example 3:

    - -
    -Input: n = 123456789
    -Output: "123.456.789"
    -
    - -

    Example 4:

    - -
    -Input: n = 0
    -Output: "0"
    -
    -

     

    Constraints:

      -
    • 0 <= n < 231
    • +
    • 0 <= n <= 231 - 1
    ### Related Topics diff --git a/problems/three-divisors/README.md b/problems/three-divisors/README.md index 259c755b3..cc81d110e 100644 --- a/problems/three-divisors/README.md +++ b/problems/three-divisors/README.md @@ -42,6 +42,9 @@ ### Related Topics [[Math](../../tag/math/README.md)] +### Similar Questions + 1. [Find Greatest Common Divisor of Array](../find-greatest-common-divisor-of-array) (Easy) + ### Hints
    Hint 1 diff --git a/problems/throne-inheritance/README.md b/problems/throne-inheritance/README.md index 1c639babc..e33c7ee62 100644 --- a/problems/throne-inheritance/README.md +++ b/problems/throne-inheritance/README.md @@ -81,10 +81,13 @@ t.getInheritanceOrder(); // return ["king", "andy", "ma ### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] [[Tree](../../tag/tree/README.md)] [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Design](../../tag/design/README.md)] - [[Hash Table](../../tag/hash-table/README.md)] + +### Similar Questions + 1. [Operations on Tree](../operations-on-tree) (Medium) ### Hints
    diff --git a/problems/time-based-key-value-store/README.md b/problems/time-based-key-value-store/README.md index 3905deed8..559c1350b 100644 --- a/problems/time-based-key-value-store/README.md +++ b/problems/time-based-key-value-store/README.md @@ -53,10 +53,7 @@ timeMap.get("foo", 5); // return "bar2" ### Related Topics + [[Design](../../tag/design/README.md)] [[Hash Table](../../tag/hash-table/README.md)] [[String](../../tag/string/README.md)] [[Binary Search](../../tag/binary-search/README.md)] - [[Design](../../tag/design/README.md)] - -### Similar Questions - 1. [Stock Price Fluctuation ](../stock-price-fluctuation) (Medium) diff --git a/problems/time-needed-to-inform-all-employees/README.md b/problems/time-needed-to-inform-all-employees/README.md index 562cedbe1..af158e624 100644 --- a/problems/time-needed-to-inform-all-employees/README.md +++ b/problems/time-needed-to-inform-all-employees/README.md @@ -1,11 +1,11 @@ - - - + + + -[< Previous](../bulb-switcher-iii "Bulb Switcher III") +[< Previous](../number-of-times-binary-string-is-prefix-aligned "Number of Times Binary String Is Prefix-Aligned")                  [Next >](../frog-position-after-t-seconds "Frog Position After T Seconds") @@ -39,37 +39,6 @@ The tree structure of the employees in the company is shown. -

    Example 3:

    - -
    -Input: n = 7, headID = 6, manager = [1,2,3,4,5,6,-1], informTime = [0,6,5,4,3,2,1]
    -Output: 21
    -Explanation: The head has id = 6. He will inform employee with id = 5 in 1 minute.
    -The employee with id = 5 will inform the employee with id = 4 in 2 minutes.
    -The employee with id = 4 will inform the employee with id = 3 in 3 minutes.
    -The employee with id = 3 will inform the employee with id = 2 in 4 minutes.
    -The employee with id = 2 will inform the employee with id = 1 in 5 minutes.
    -The employee with id = 1 will inform the employee with id = 0 in 6 minutes.
    -Needed time = 1 + 2 + 3 + 4 + 5 + 6 = 21.
    -
    - -

    Example 4:

    - -
    -Input: n = 15, headID = 0, manager = [-1,0,0,1,1,2,2,3,3,4,4,5,5,6,6], informTime = [1,1,1,1,1,1,1,0,0,0,0,0,0,0,0]
    -Output: 3
    -Explanation: The first minute the head will inform employees 1 and 2.
    -The second minute they will inform employees 3, 4, 5 and 6.
    -The third minute they will inform the rest of employees.
    -
    - -

    Example 5:

    - -
    -Input: n = 4, headID = 2, manager = [3,3,-1,2], informTime = [0,0,162,914]
    -Output: 1076
    -
    -

     

    Constraints:

    diff --git a/problems/total-sales-amount-by-year/README.md b/problems/total-sales-amount-by-year/README.md index 7a27cc853..f2a0dc254 100644 --- a/problems/total-sales-amount-by-year/README.md +++ b/problems/total-sales-amount-by-year/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../maximum-performance-of-a-team "Maximum Performance of a Team") diff --git a/problems/trapping-rain-water/README.md b/problems/trapping-rain-water/README.md index ea93f83c4..63809ff6f 100644 --- a/problems/trapping-rain-water/README.md +++ b/problems/trapping-rain-water/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../first-missing-positive "First Missing Positive") diff --git a/problems/tuple-with-same-product/README.md b/problems/tuple-with-same-product/README.md index 89f9e7bd6..bca35af2d 100644 --- a/problems/tuple-with-same-product/README.md +++ b/problems/tuple-with-same-product/README.md @@ -29,27 +29,13 @@
     Input: nums = [1,2,4,5,10]
     Output: 16
    -Explanation: There are 16 valids tuples:
    +Explanation: There are 16 valid tuples:
     (1,10,2,5) , (1,10,5,2) , (10,1,2,5) , (10,1,5,2)
     (2,5,1,10) , (2,5,10,1) , (5,2,1,10) , (5,2,10,1)
     (2,10,4,5) , (2,10,5,4) , (10,2,4,5) , (10,2,5,4)
     (4,5,2,10) , (4,5,10,2) , (5,4,2,10) , (5,4,10,2)
     
    -

    Example 3:

    - -
    -Input: nums = [2,3,4,6,8,12]
    -Output: 40
    -
    - -

    Example 4:

    - -
    -Input: nums = [2,3,5,7]
    -Output: 0
    -
    -

     

    Constraints:

    diff --git a/problems/two-sum/README.md b/problems/two-sum/README.md index 447a249c4..aa409a146 100644 --- a/problems/two-sum/README.md +++ b/problems/two-sum/README.md @@ -1,8 +1,8 @@ - - - + + + < Previous @@ -23,7 +23,7 @@
     Input: nums = [2,7,11,15], target = 9
     Output: [0,1]
    -Output: Because nums[0] + nums[1] == 9, we return [0, 1].
    +Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
     

    Example 2:

    @@ -60,7 +60,7 @@ ### Similar Questions 1. [3Sum](../3sum) (Medium) 1. [4Sum](../4sum) (Medium) - 1. [Two Sum II - Input array is sorted](../two-sum-ii-input-array-is-sorted) (Easy) + 1. [Two Sum II - Input Array Is Sorted](../two-sum-ii-input-array-is-sorted) (Medium) 1. [Two Sum III - Data structure design](../two-sum-iii-data-structure-design) (Easy) 1. [Subarray Sum Equals K](../subarray-sum-equals-k) (Medium) 1. [Two Sum IV - Input is a BST](../two-sum-iv-input-is-a-bst) (Easy) diff --git a/problems/unique-substrings-with-equal-digit-frequency/README.md b/problems/unique-substrings-with-equal-digit-frequency/README.md new file mode 100644 index 000000000..18b80c84a --- /dev/null +++ b/problems/unique-substrings-with-equal-digit-frequency/README.md @@ -0,0 +1,47 @@ + + + + + + + +[< Previous](../minimum-time-to-remove-all-cars-containing-illegal-goods "Minimum Time to Remove All Cars Containing Illegal Goods") +                 +[Next >](../count-operations-to-obtain-zero "Count Operations to Obtain Zero") + +## [2168. Unique Substrings With Equal Digit Frequency (Medium)](https://leetcode.com/problems/unique-substrings-with-equal-digit-frequency "") + + + +### Related Topics + [[Hash Table](../../tag/hash-table/README.md)] + [[String](../../tag/string/README.md)] + [[Counting](../../tag/counting/README.md)] + [[Hash Function](../../tag/hash-function/README.md)] + [[Rolling Hash](../../tag/rolling-hash/README.md)] + +### Hints +
    +Hint 1 +With the constraints, could we try every substring? +
    + +
    +Hint 2 +Yes, checking every substring has runtime O(n^2), which will pass. +
    + +
    +Hint 3 +How can we make sure we only count unique substrings? +
    + +
    +Hint 4 +Use a set to store previously counted substrings. Hashing a string s of length m takes O(m) time. Is there a fast way to compute the hash of s if we know the hash of s[0..m - 2]? +
    + +
    +Hint 5 +Use a rolling hash. +
    diff --git a/problems/user-activity-for-the-past-30-days-i/README.md b/problems/user-activity-for-the-past-30-days-i/README.md index 8450ec32e..123c6b996 100644 --- a/problems/user-activity-for-the-past-30-days-i/README.md +++ b/problems/user-activity-for-the-past-30-days-i/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../stone-game-ii "Stone Game II") diff --git a/problems/users-that-actively-request-confirmation-messages/README.md b/problems/users-that-actively-request-confirmation-messages/README.md index 1b94ef273..d8642a55d 100644 --- a/problems/users-that-actively-request-confirmation-messages/README.md +++ b/problems/users-that-actively-request-confirmation-messages/README.md @@ -9,7 +9,7 @@                  [Next >](../longest-common-subsequence-between-sorted-arrays "Longest Common Subsequence Between Sorted Arrays") -## [1939. Users That Actively Request Confirmation Messages (Easy)](https://leetcode.com/problems/users-that-actively-request-confirmation-messages "") +## [1939. Users That Actively Request Confirmation Messages (Easy)](https://leetcode.com/problems/users-that-actively-request-confirmation-messages "主动请求确认消息的用户") diff --git a/problems/utf-8-validation/README.md b/problems/utf-8-validation/README.md index cbbf134ce..fa8e947a3 100644 --- a/problems/utf-8-validation/README.md +++ b/problems/utf-8-validation/README.md @@ -64,8 +64,8 @@ But the second continuation byte does not start with 10, so it is invalid. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Array](../../tag/array/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/valid-arrangement-of-pairs/README.md b/problems/valid-arrangement-of-pairs/README.md new file mode 100644 index 000000000..68c06e545 --- /dev/null +++ b/problems/valid-arrangement-of-pairs/README.md @@ -0,0 +1,87 @@ + + + + + + + +[< Previous](../step-by-step-directions-from-a-binary-tree-node-to-another "Step-By-Step Directions From a Binary Tree Node to Another") +                 +[Next >](../subsequence-of-size-k-with-the-largest-even-sum "Subsequence of Size K With the Largest Even Sum") + +## [2097. Valid Arrangement of Pairs (Hard)](https://leetcode.com/problems/valid-arrangement-of-pairs "合法重新排列数对") + +

    You are given a 0-indexed 2D integer array pairs where pairs[i] = [starti, endi]. An arrangement of pairs is valid if for every index i where 1 <= i < pairs.length, we have endi-1 == starti.

    + +

    Return any valid arrangement of pairs.

    + +

    Note: The inputs will be generated such that there exists a valid arrangement of pairs.

    + +

     

    +

    Example 1:

    + +
    +Input: pairs = [[5,1],[4,5],[11,9],[9,4]]
    +Output: [[11,9],[9,4],[4,5],[5,1]]
    +Explanation:
    +This is a valid arrangement since endi-1 always equals starti.
    +end0 = 9 == 9 = start1 
    +end1 = 4 == 4 = start2
    +end2 = 5 == 5 = start3
    +
    + +

    Example 2:

    + +
    +Input: pairs = [[1,3],[3,2],[2,1]]
    +Output: [[1,3],[3,2],[2,1]]
    +Explanation:
    +This is a valid arrangement since endi-1 always equals starti.
    +end0 = 3 == 3 = start1
    +end1 = 2 == 2 = start2
    +The arrangements [[2,1],[1,3],[3,2]] and [[3,2],[2,1],[1,3]] are also valid.
    +
    + +

    Example 3:

    + +
    +Input: pairs = [[1,2],[1,3],[2,1]]
    +Output: [[1,2],[2,1],[1,3]]
    +Explanation:
    +This is a valid arrangement since endi-1 always equals starti.
    +end0 = 2 == 2 = start1
    +end1 = 1 == 1 = start2
    +
    + +

     

    +

    Constraints:

    + +
      +
    • 1 <= pairs.length <= 105
    • +
    • pairs[i].length == 2
    • +
    • 0 <= starti, endi <= 109
    • +
    • starti != endi
    • +
    • No two pairs are exactly the same.
    • +
    • There exists a valid arrangement of pairs.
    • +
    + +### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] + [[Graph](../../tag/graph/README.md)] + [[Eulerian Circuit](../../tag/eulerian-circuit/README.md)] + +### Hints +
    +Hint 1 +Could you convert this into a graph problem? +
    + +
    +Hint 2 +Consider the pairs as edges and each number as a node. +
    + +
    +Hint 3 +We have to find an Eulerian path of this graph. Hierholzer’s algorithm can be used. +
    diff --git a/problems/valid-parenthesis-string/README.md b/problems/valid-parenthesis-string/README.md index b4ce17b44..3edabff41 100644 --- a/problems/valid-parenthesis-string/README.md +++ b/problems/valid-parenthesis-string/README.md @@ -49,3 +49,4 @@ ### Similar Questions 1. [Special Binary String](../special-binary-string) (Hard) + 1. [Check if a Parentheses String Can Be Valid](../check-if-a-parentheses-string-can-be-valid) (Medium) diff --git a/problems/valid-word-abbreviation/README.md b/problems/valid-word-abbreviation/README.md index 29cd566e3..63b929eb4 100644 --- a/problems/valid-word-abbreviation/README.md +++ b/problems/valid-word-abbreviation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../trapping-rain-water-ii "Trapping Rain Water II") @@ -49,3 +49,4 @@ Return false. ### Similar Questions 1. [Minimum Unique Word Abbreviation](../minimum-unique-word-abbreviation) (Hard) 1. [Word Abbreviation](../word-abbreviation) (Hard) + 1. [Check if an Original String Exists Given Two Encoded Strings](../check-if-an-original-string-exists-given-two-encoded-strings) (Hard) diff --git a/problems/verbal-arithmetic-puzzle/README.md b/problems/verbal-arithmetic-puzzle/README.md index 9982377e8..6068accde 100644 --- a/problems/verbal-arithmetic-puzzle/README.md +++ b/problems/verbal-arithmetic-puzzle/README.md @@ -11,18 +11,18 @@ ## [1307. Verbal Arithmetic Puzzle (Hard)](https://leetcode.com/problems/verbal-arithmetic-puzzle "口算难题") -

    Given an equation, represented by words on left side and the result on right side.

    +

    Given an equation, represented by words on the left side and the result on the right side.

    -

    You need to check if the equation is solvable under the following rules:

    +

    You need to check if the equation is solvable under the following rules:

    • Each character is decoded as one digit (0 - 9).
    • -
    • Every pair of different characters they must map to different digits.
    • -
    • Each words[i] and result are decoded as one number without leading zeros.
    • -
    • Sum of numbers on left side (words) will equal to the number on right side (result). 
    • +
    • Every pair of different characters must map to different digits.
    • +
    • Each words[i] and result are decoded as one number without leading zeros.
    • +
    • Sum of numbers on the left side (words) will equal to the number on the right side (result).
    -

    Return True if the equation is solvable otherwise return False.

    +

    Return true if the equation is solvable, otherwise return false.

     

    Example 1:

    @@ -43,13 +43,6 @@ Such that: "SIX" + "SEVEN" + "SEVEN" = "TWENT

    Example 3:

    -
    -Input: words = ["THIS","IS","TOO"], result = "FUNNY"
    -Output: true
    -
    - -

    Example 4:

    -
     Input: words = ["LEET","CODE"], result = "POINT"
     Output: false
    diff --git a/problems/video-stitching/README.md b/problems/video-stitching/README.md
    index c97194b4c..bc7031855 100644
    --- a/problems/video-stitching/README.md
    +++ b/problems/video-stitching/README.md
    @@ -1,8 +1,8 @@
     
     
    -
    -
    -
    +
    +
    +
     
     
     [< Previous](../camelcase-matching "Camelcase Matching")
    @@ -29,8 +29,7 @@
     
     Input: clips = [[0,2],[4,6],[8,10],[1,9],[1,5],[5,9]], time = 10
     Output: 3
    -Explanation: 
    -We take the clips [0,2], [8,10], [1,9]; a total of 3 clips.
    +Explanation: We take the clips [0,2], [8,10], [1,9]; a total of 3 clips.
     Then, we can reconstruct the sporting event as follows:
     We cut [1,9] into segments [1,2] + [2,8] + [8,9].
     Now we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 10].
    @@ -41,7 +40,7 @@ Now we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 1
     
     Input: clips = [[0,1],[1,2]], time = 5
     Output: -1
    -Explanation: We can't cover [0,5] with only [0,1] and [1,2].
    +Explanation: We cannot cover [0,5] with only [0,1] and [1,2].
     

    Example 3:

    @@ -52,14 +51,6 @@ Now we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 1 Explanation: We can take clips [0,4], [4,7], and [6,9].
    -

    Example 4:

    - -
    -Input: clips = [[0,4],[2,8]], time = 5
    -Output: 2
    -Explanation: Notice you can have extra video after the event ends.
    -
    -

     

    Constraints:

    diff --git a/problems/vowels-of-all-substrings/README.md b/problems/vowels-of-all-substrings/README.md index 3d35932cd..a508e72c8 100644 --- a/problems/vowels-of-all-substrings/README.md +++ b/problems/vowels-of-all-substrings/README.md @@ -40,21 +40,15 @@ Hence, the total sum of vowels = 0 + 1 + 1 + 1 + 1 + 2 = 6. All possible substrings are: "a", "ab", "abc", "b", "bc", and "c". - "a", "ab", and "abc" have 1 vowel each - "b", "bc", and "c" have 0 vowels each -Hence, the total sum of vowels = 1 + 1 + 1 + 0 + 0 + 0 = 3.
    +Hence, the total sum of vowels = 1 + 1 + 1 + 0 + 0 + 0 = 3. +

    Example 3:

     Input: word = "ltcd"
     Output: 0
    -Explanation: There are no vowels in any substring of "ltcd".
    - -

    Example 4:

    - -
    -Input: word = "noosabasboosa"
    -Output: 237
    -Explanation: There are a total of 237 vowels in all the substrings.
    +Explanation: There are no vowels in any substring of "ltcd".
     

     

    diff --git a/problems/water-bottles/README.md b/problems/water-bottles/README.md index a12dce419..b299bdd88 100644 --- a/problems/water-bottles/README.md +++ b/problems/water-bottles/README.md @@ -11,55 +11,37 @@ ## [1518. Water Bottles (Easy)](https://leetcode.com/problems/water-bottles "换酒问题") -

    Given numBottles full water bottles, you can exchange numExchange empty water bottles for one full water bottle.

    +

    There are numBottles water bottles that are initially full of water. You can exchange numExchange empty water bottles from the market with one full water bottle.

    The operation of drinking a full water bottle turns it into an empty bottle.

    -

    Return the maximum number of water bottles you can drink.

    +

    Given the two integers numBottles and numExchange, return the maximum number of water bottles you can drink.

     

    Example 1:

    - -

    - +
     Input: numBottles = 9, numExchange = 3
     Output: 13
     Explanation: You can exchange 3 empty bottles to get 1 full water bottle.
    -Number of water bottles you can drink: 9 + 3 + 1 = 13.
    +Number of water bottles you can drink: 9 + 3 + 1 = 13.
     

    Example 2:

    - -

    - +
     Input: numBottles = 15, numExchange = 4
     Output: 19
     Explanation: You can exchange 4 empty bottles to get 1 full water bottle. 
    -Number of water bottles you can drink: 15 + 3 + 1 = 19.
    -
    - -

    Example 3:

    - -
    -Input: numBottles = 5, numExchange = 5
    -Output: 6
    -
    - -

    Example 4:

    - -
    -Input: numBottles = 2, numExchange = 3
    -Output: 2
    +Number of water bottles you can drink: 15 + 3 + 1 = 19.
     

     

    Constraints:

      -
    • 1 <= numBottles <= 100
    • -
    • 2 <= numExchange <= 100
    • +
    • 1 <= numBottles <= 100
    • +
    • 2 <= numExchange <= 100
    ### Related Topics diff --git a/problems/watering-plants-ii/README.md b/problems/watering-plants-ii/README.md new file mode 100644 index 000000000..1d68c1646 --- /dev/null +++ b/problems/watering-plants-ii/README.md @@ -0,0 +1,94 @@ + + + + + + + +[< Previous](../sum-of-subarray-ranges "Sum of Subarray Ranges") +                 +[Next >](../maximum-fruits-harvested-after-at-most-k-steps "Maximum Fruits Harvested After at Most K Steps") + +## [2105. Watering Plants II (Medium)](https://leetcode.com/problems/watering-plants-ii "给植物浇水 II") + +

    Alice and Bob want to water n plants in their garden. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i.

    + +

    Each plant needs a specific amount of water. Alice and Bob have a watering can each, initially full. They water the plants in the following way:

    + +
      +
    • Alice waters the plants in order from left to right, starting from the 0th plant. Bob waters the plants in order from right to left, starting from the (n - 1)th plant. They begin watering the plants simultaneously.
    • +
    • It takes the same amount of time to water each plant regardless of how much water it needs.
    • +
    • Alice/Bob must water the plant if they have enough in their can to fully water it. Otherwise, they first refill their can (instantaneously) then water the plant.
    • +
    • In case both Alice and Bob reach the same plant, the one with more water currently in his/her watering can should water this plant. If they have the same amount of water, then Alice should water this plant.
    • +
    + +

    Given a 0-indexed integer array plants of n integers, where plants[i] is the amount of water the ith plant needs, and two integers capacityA and capacityB representing the capacities of Alice's and Bob's watering cans respectively, return the number of times they have to refill to water all the plants.

    + +

     

    +

    Example 1:

    + +
    +Input: plants = [2,2,3,3], capacityA = 5, capacityB = 5
    +Output: 1
    +Explanation:
    +- Initially, Alice and Bob have 5 units of water each in their watering cans.
    +- Alice waters plant 0, Bob waters plant 3.
    +- Alice and Bob now have 3 units and 2 units of water respectively.
    +- Alice has enough water for plant 1, so she waters it. Bob does not have enough water for plant 2, so he refills his can then waters it.
    +So, the total number of times they have to refill to water all the plants is 0 + 0 + 1 + 0 = 1.
    +
    + +

    Example 2:

    + +
    +Input: plants = [2,2,3,3], capacityA = 3, capacityB = 4
    +Output: 2
    +Explanation:
    +- Initially, Alice and Bob have 3 units and 4 units of water in their watering cans respectively.
    +- Alice waters plant 0, Bob waters plant 3.
    +- Alice and Bob now have 1 unit of water each, and need to water plants 1 and 2 respectively.
    +- Since neither of them have enough water for their current plants, they refill their cans and then water the plants.
    +So, the total number of times they have to refill to water all the plants is 0 + 1 + 1 + 0 = 2.
    +
    + +

    Example 3:

    + +
    +Input: plants = [5], capacityA = 10, capacityB = 8
    +Output: 0
    +Explanation:
    +- There is only one plant.
    +- Alice's watering can has 10 units of water, whereas Bob's can has 8 units. Since Alice has more water in her can, she waters this plant.
    +So, the total number of times they have to refill is 0.
    +
    + +

     

    +

    Constraints:

    + +
      +
    • n == plants.length
    • +
    • 1 <= n <= 105
    • +
    • 1 <= plants[i] <= 106
    • +
    • max(plants[i]) <= capacityA, capacityB <= 109
    • +
    + +### Related Topics + [[Array](../../tag/array/README.md)] + [[Two Pointers](../../tag/two-pointers/README.md)] + [[Simulation](../../tag/simulation/README.md)] + +### Hints +
    +Hint 1 +Try "simulating" the process. +
    + +
    +Hint 2 +Since watering each plant takes the same amount of time, where will Alice and Bob meet if they start watering the plants simultaneously? How can you use this to optimize your solution? +
    + +
    +Hint 3 +What will you do when both Alice and Bob have to water the same plant? +
    diff --git a/problems/ways-to-split-array-into-three-subarrays/README.md b/problems/ways-to-split-array-into-three-subarrays/README.md index 543aad389..f9621b2da 100644 --- a/problems/ways-to-split-array-into-three-subarrays/README.md +++ b/problems/ways-to-split-array-into-three-subarrays/README.md @@ -60,6 +60,9 @@ [[Binary Search](../../tag/binary-search/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] +### Similar Questions + 1. [Number of Ways to Divide a Long Corridor](../number-of-ways-to-divide-a-long-corridor) (Hard) + ### Hints
    Hint 1 diff --git a/problems/weather-type-in-each-country/README.md b/problems/weather-type-in-each-country/README.md index 981076584..a58e2ea24 100644 --- a/problems/weather-type-in-each-country/README.md +++ b/problems/weather-type-in-each-country/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../shortest-path-in-a-grid-with-obstacles-elimination "Shortest Path in a Grid with Obstacles Elimination") diff --git a/problems/where-will-the-ball-fall/README.md b/problems/where-will-the-ball-fall/README.md index 62d5babec..5d79d418e 100644 --- a/problems/where-will-the-ball-fall/README.md +++ b/problems/where-will-the-ball-fall/README.md @@ -66,9 +66,9 @@ Ball b4 is dropped at column 4 and will get stuck on the box between column 2 an ### Related Topics + [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] - [[Depth-First Search](../../tag/depth-first-search/README.md)] [[Matrix](../../tag/matrix/README.md)] [[Simulation](../../tag/simulation/README.md)] diff --git a/problems/wiggle-subsequence/README.md b/problems/wiggle-subsequence/README.md index 1f0439667..238eb4b28 100644 --- a/problems/wiggle-subsequence/README.md +++ b/problems/wiggle-subsequence/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../guess-number-higher-or-lower-ii "Guess Number Higher or Lower II") @@ -59,6 +59,9 @@ One is [1, 17, 10, 13, 10, 16, 8] with differences (16, -7, 3, -3, 6, -8).

    Follow up: Could you solve this in O(n) time?

    ### Related Topics - [[Greedy](../../tag/greedy/README.md)] [[Array](../../tag/array/README.md)] [[Dynamic Programming](../../tag/dynamic-programming/README.md)] + [[Greedy](../../tag/greedy/README.md)] + +### Similar Questions + 1. [Rearrange Array Elements by Sign](../rearrange-array-elements-by-sign) (Medium) diff --git a/problems/word-abbreviation/README.md b/problems/word-abbreviation/README.md index 16762d141..7fd9f8a67 100644 --- a/problems/word-abbreviation/README.md +++ b/problems/word-abbreviation/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../beautiful-arrangement "Beautiful Arrangement") diff --git a/problems/word-pattern-ii/README.md b/problems/word-pattern-ii/README.md index dbe80c671..b7e543f01 100644 --- a/problems/word-pattern-ii/README.md +++ b/problems/word-pattern-ii/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../word-pattern "Word Pattern") diff --git a/problems/word-squares/README.md b/problems/word-squares/README.md index 05908d666..49634a077 100644 --- a/problems/word-squares/README.md +++ b/problems/word-squares/README.md @@ -82,10 +82,10 @@ The output consists of two word squares. The order of output does not matter (ju

    ### Related Topics - [[Trie](../../tag/trie/README.md)] [[Array](../../tag/array/README.md)] [[String](../../tag/string/README.md)] [[Backtracking](../../tag/backtracking/README.md)] + [[Trie](../../tag/trie/README.md)] ### Similar Questions 1. [Valid Word Square](../valid-word-square) (Easy) diff --git a/problems/word-subsets/README.md b/problems/word-subsets/README.md index cca849a2d..67b953a6f 100644 --- a/problems/word-subsets/README.md +++ b/problems/word-subsets/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../partition-array-into-disjoint-intervals "Partition Array into Disjoint Intervals") @@ -25,21 +25,19 @@

     

    Example 1:

    -
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","o"]
    -Output: ["facebook","google","leetcode"]
    -

    Example 2:

    -
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["l","e"]
    -Output: ["apple","google","leetcode"]
    -

    Example 3:

    -
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","oo"]
    -Output: ["facebook","google"]
    -

    Example 4:

    -
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["lo","eo"]
    -Output: ["google","leetcode"]
    -

    Example 5:

    -
    Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["ec","oc","ceo"]
    -Output: ["facebook","leetcode"]
    +
    +
    +Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","o"]
    +Output: ["facebook","google","leetcode"]
     
    + +

    Example 2:

    + +
    +Input: words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["l","e"]
    +Output: ["apple","google","leetcode"]
    +
    +

     

    Constraints:

    diff --git a/problems/xor-operation-in-an-array/README.md b/problems/xor-operation-in-an-array/README.md index fb190c246..89580d8aa 100644 --- a/problems/xor-operation-in-an-array/README.md +++ b/problems/xor-operation-in-an-array/README.md @@ -1,8 +1,8 @@ - - - + + + [< Previous](../clone-binary-tree-with-random-pointer "Clone Binary Tree With Random Pointer") @@ -11,11 +11,11 @@ ## [1486. XOR Operation in an Array (Easy)](https://leetcode.com/problems/xor-operation-in-an-array "数组异或操作") -

    Given an integer n and an integer start.

    +

    You are given an integer n and an integer start.

    -

    Define an array nums where nums[i] = start + 2*i (0-indexed) and n == nums.length.

    +

    Define an array nums where nums[i] = start + 2 * i (0-indexed) and n == nums.length.

    -

    Return the bitwise XOR of all elements of nums.

    +

    Return the bitwise XOR of all elements of nums.

     

    Example 1:

    @@ -23,7 +23,7 @@
     Input: n = 5, start = 0
     Output: 8
    -Explanation: Array nums is equal to [0, 2, 4, 6, 8] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8.
    +Explanation: Array nums is equal to [0, 2, 4, 6, 8] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8.
     Where "^" corresponds to bitwise XOR operator.
     
    @@ -32,20 +32,7 @@ Where "^" corresponds to bitwise XOR operator.
     Input: n = 4, start = 3
     Output: 8
    -Explanation: Array nums is equal to [3, 5, 7, 9] where (3 ^ 5 ^ 7 ^ 9) = 8.
    - -

    Example 3:

    - -
    -Input: n = 1, start = 7
    -Output: 7
    -
    - -

    Example 4:

    - -
    -Input: n = 10, start = 5
    -Output: 2
    +Explanation: Array nums is equal to [3, 5, 7, 9] where (3 ^ 5 ^ 7 ^ 9) = 8.
     

     

    @@ -58,8 +45,8 @@ Where "^" corresponds to bitwise XOR operator. ### Related Topics - [[Bit Manipulation](../../tag/bit-manipulation/README.md)] [[Math](../../tag/math/README.md)] + [[Bit Manipulation](../../tag/bit-manipulation/README.md)] ### Hints
    diff --git a/problems/xor-queries-of-a-subarray/README.md b/problems/xor-queries-of-a-subarray/README.md index 90df382e7..86c7462b0 100644 --- a/problems/xor-queries-of-a-subarray/README.md +++ b/problems/xor-queries-of-a-subarray/README.md @@ -54,8 +54,8 @@ The XOR values for queries are: ### Related Topics - [[Array](../../tag/array/README.md)] [[Bit Manipulation](../../tag/bit-manipulation/README.md)] + [[Array](../../tag/array/README.md)] [[Prefix Sum](../../tag/prefix-sum/README.md)] ### Hints diff --git a/readme/1-300.md b/readme/1-300.md index a4db89dcb..4bb184fe2 100644 --- a/readme/1-300.md +++ b/readme/1-300.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    @@ -130,7 +138,7 @@ LeetCode Problems' Solutions | 50 | [Pow(x, n)](https://leetcode.com/problems/powx-n "Pow(x, n)") | [Go](../problems/powx-n) | Medium | | 51 | [N-Queens](https://leetcode.com/problems/n-queens "N 皇后") | [Go](../problems/n-queens) | Hard | | 52 | [N-Queens II](https://leetcode.com/problems/n-queens-ii "N皇后 II") | [Go](../problems/n-queens-ii) | Hard | -| 53 | [Maximum Subarray](https://leetcode.com/problems/maximum-subarray "最大子序和") | [Go](../problems/maximum-subarray) | Easy | +| 53 | [Maximum Subarray](https://leetcode.com/problems/maximum-subarray "最大子数组和") | [Go](../problems/maximum-subarray) | Easy | | 54 | [Spiral Matrix](https://leetcode.com/problems/spiral-matrix "螺旋矩阵") | [Go](../problems/spiral-matrix) | Medium | | 55 | [Jump Game](https://leetcode.com/problems/jump-game "跳跃游戏") | [Go](../problems/jump-game) | Medium | | 56 | [Merge Intervals](https://leetcode.com/problems/merge-intervals "合并区间") | [Go](../problems/merge-intervals) | Medium | @@ -146,7 +154,7 @@ LeetCode Problems' Solutions | 66 | [Plus One](https://leetcode.com/problems/plus-one "加一") | [Go](../problems/plus-one) | Easy | | 67 | [Add Binary](https://leetcode.com/problems/add-binary "二进制求和") | [Go](../problems/add-binary) | Easy | | 68 | [Text Justification](https://leetcode.com/problems/text-justification "文本左右对齐") | [Go](../problems/text-justification) | Hard | -| 69 | [Sqrt(x)](https://leetcode.com/problems/sqrtx "Sqrt(x)") | [Go](../problems/sqrtx) | Easy | +| 69 | [Sqrt(x)](https://leetcode.com/problems/sqrtx "x 的平方根 ") | [Go](../problems/sqrtx) | Easy | | 70 | [Climbing Stairs](https://leetcode.com/problems/climbing-stairs "爬楼梯") | [Go](../problems/climbing-stairs) | Easy | | 71 | [Simplify Path](https://leetcode.com/problems/simplify-path "简化路径") | [Go](../problems/simplify-path) | Medium | | 72 | [Edit Distance](https://leetcode.com/problems/edit-distance "编辑距离") | [Go](../problems/edit-distance) | Hard | @@ -223,7 +231,7 @@ LeetCode Problems' Solutions | 143 | [Reorder List](https://leetcode.com/problems/reorder-list "重排链表") | [Go](../problems/reorder-list) | Medium | | 144 | [Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal "二叉树的前序遍历") | [Go](../problems/binary-tree-preorder-traversal) | Easy | | 145 | [Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal "二叉树的后序遍历") | [Go](../problems/binary-tree-postorder-traversal) | Easy | -| 146 | [LRU Cache](https://leetcode.com/problems/lru-cache "LRU 缓存机制") | [Go](../problems/lru-cache) | Medium | +| 146 | [LRU Cache](https://leetcode.com/problems/lru-cache "LRU 缓存") | [Go](../problems/lru-cache) | Medium | | 147 | [Insertion Sort List](https://leetcode.com/problems/insertion-sort-list "对链表进行插入排序") | [Go](../problems/insertion-sort-list) | Medium | | 148 | [Sort List](https://leetcode.com/problems/sort-list "排序链表") | [Go](../problems/sort-list) | Medium | | 149 | [Max Points on a Line](https://leetcode.com/problems/max-points-on-a-line "直线上最多的点数") | [Go](../problems/max-points-on-a-line) | Hard | @@ -244,7 +252,7 @@ LeetCode Problems' Solutions | 164 | [Maximum Gap](https://leetcode.com/problems/maximum-gap "最大间距") | [Go](../problems/maximum-gap) | Hard | | 165 | [Compare Version Numbers](https://leetcode.com/problems/compare-version-numbers "比较版本号") | [Go](../problems/compare-version-numbers) | Medium | | 166 | [Fraction to Recurring Decimal](https://leetcode.com/problems/fraction-to-recurring-decimal "分数到小数") | [Go](../problems/fraction-to-recurring-decimal) | Medium | -| 167 | [Two Sum II - Input Array Is Sorted](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted "两数之和 II - 输入有序数组") | [Go](../problems/two-sum-ii-input-array-is-sorted) | Easy | +| 167 | [Two Sum II - Input Array Is Sorted](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted "两数之和 II - 输入有序数组") | [Go](../problems/two-sum-ii-input-array-is-sorted) | Medium | | 168 | [Excel Sheet Column Title](https://leetcode.com/problems/excel-sheet-column-title "Excel表列名称") | [Go](../problems/excel-sheet-column-title) | Easy | | 169 | [Majority Element](https://leetcode.com/problems/majority-element "多数元素") | [Go](../problems/majority-element) | Easy | | 170 | [Two Sum III - Data structure design](https://leetcode.com/problems/two-sum-iii-data-structure-design "两数之和 III - 数据结构设计") 🔒 | [Go](../problems/two-sum-iii-data-structure-design) | Easy | @@ -361,7 +369,7 @@ LeetCode Problems' Solutions | 281 | [Zigzag Iterator](https://leetcode.com/problems/zigzag-iterator "锯齿迭代器") 🔒 | [Go](../problems/zigzag-iterator) | Medium | | 282 | [Expression Add Operators](https://leetcode.com/problems/expression-add-operators "给表达式添加运算符") | [Go](../problems/expression-add-operators) | Hard | | 283 | [Move Zeroes](https://leetcode.com/problems/move-zeroes "移动零") | [Go](../problems/move-zeroes) | Easy | -| 284 | [Peeking Iterator](https://leetcode.com/problems/peeking-iterator "窥探迭代器") | [Go](../problems/peeking-iterator) | Medium | +| 284 | [Peeking Iterator](https://leetcode.com/problems/peeking-iterator "顶端迭代器") | [Go](../problems/peeking-iterator) | Medium | | 285 | [Inorder Successor in BST](https://leetcode.com/problems/inorder-successor-in-bst "二叉搜索树中的中序后继") 🔒 | [Go](../problems/inorder-successor-in-bst) | Medium | | 286 | [Walls and Gates](https://leetcode.com/problems/walls-and-gates "墙与门") 🔒 | [Go](../problems/walls-and-gates) | Medium | | 287 | [Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number "寻找重复数") | [Go](../problems/find-the-duplicate-number) | Medium | diff --git a/readme/1201-1500.md b/readme/1201-1500.md index 8b5c5123a..cd9ca1be8 100644 --- a/readme/1201-1500.md +++ b/readme/1201-1500.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    @@ -252,7 +260,7 @@ LeetCode Problems' Solutions | 1372 | [Longest ZigZag Path in a Binary Tree](https://leetcode.com/problems/longest-zigzag-path-in-a-binary-tree "二叉树中的最长交错路径") | [Go](../problems/longest-zigzag-path-in-a-binary-tree) | Medium | | 1373 | [Maximum Sum BST in Binary Tree](https://leetcode.com/problems/maximum-sum-bst-in-binary-tree "二叉搜索子树的最大键值和") | [Go](../problems/maximum-sum-bst-in-binary-tree) | Hard | | 1374 | [Generate a String With Characters That Have Odd Counts](https://leetcode.com/problems/generate-a-string-with-characters-that-have-odd-counts "生成每种字符都是奇数个的字符串") | [Go](../problems/generate-a-string-with-characters-that-have-odd-counts) | Easy | -| 1375 | [Bulb Switcher III](https://leetcode.com/problems/bulb-switcher-iii "灯泡开关 III") | [Go](../problems/bulb-switcher-iii) | Medium | +| 1375 | [Number of Times Binary String Is Prefix-Aligned](https://leetcode.com/problems/number-of-times-binary-string-is-prefix-aligned "二进制字符串前缀一致的次数") | [Go](../problems/number-of-times-binary-string-is-prefix-aligned) | Medium | | 1376 | [Time Needed to Inform All Employees](https://leetcode.com/problems/time-needed-to-inform-all-employees "通知所有员工所需的时间") | [Go](../problems/time-needed-to-inform-all-employees) | Medium | | 1377 | [Frog Position After T Seconds](https://leetcode.com/problems/frog-position-after-t-seconds "T 秒后青蛙的位置") | [Go](../problems/frog-position-after-t-seconds) | Hard | | 1378 | [Replace Employee ID With The Unique Identifier](https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier "使用唯一标识码替换员工ID") 🔒 | [MySQL](../problems/replace-employee-id-with-the-unique-identifier) | Easy | diff --git a/readme/1501-1800.md b/readme/1501-1800.md new file mode 100644 index 000000000..85463f503 --- /dev/null +++ b/readme/1501-1800.md @@ -0,0 +1,388 @@ + + + + + + + +# [LeetCode](https://awesee.github.io/leetcode) +LeetCode Problems' Solutions +[[力扣](https://awesee.github.io/categories/leetcode/) ∙ [话题分类](https://github.com/awesee/leetcode/blob/master/tag/README.md)] + +[![Go](https://github.com/awesee/leetcode/workflows/Go/badge.svg)](https://github.com/awesee/leetcode/actions) +[![codecov](https://codecov.io/gh/awesee/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/awesee/leetcode) +[![Go Report Card](https://goreportcard.com/badge/github.com/awesee/leetcode)](https://goreportcard.com/report/github.com/awesee/leetcode) +[![GitHub contributors](https://img.shields.io/github/contributors/awesee/leetcode.svg)](https://github.com/awesee/leetcode/graphs/contributors) +[![license](https://img.shields.io/github/license/awesee/leetcode.svg)](https://github.com/awesee/leetcode/blob/master/LICENSE) +[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fawesee%2Fleetcode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fawesee%2Fleetcode?ref=badge_shield) +[![Join the chat](https://badges.gitter.im/awesee/leetcode.svg)](https://gitter.im/awesee/leetcode?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    + +| # | Title | Solution | Difficulty | +| :-: | - | - | :-: | +| 1501 | [Countries You Can Safely Invest In](https://leetcode.com/problems/countries-you-can-safely-invest-in "可以放心投资的国家") 🔒 | [MySQL](../problems/countries-you-can-safely-invest-in) | Medium | +| 1502 | [Can Make Arithmetic Progression From Sequence](https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence "判断能否形成等差数列") | [Go](../problems/can-make-arithmetic-progression-from-sequence) | Easy | +| 1503 | [Last Moment Before All Ants Fall Out of a Plank](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank "所有蚂蚁掉下来前的最后一刻") | [Go](../problems/last-moment-before-all-ants-fall-out-of-a-plank) | Medium | +| 1504 | [Count Submatrices With All Ones](https://leetcode.com/problems/count-submatrices-with-all-ones "统计全 1 子矩形") | [Go](../problems/count-submatrices-with-all-ones) | Medium | +| 1505 | [Minimum Possible Integer After at Most K Adjacent Swaps On Digits](https://leetcode.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits "最多 K 次交换相邻数位后得到的最小整数") | [Go](../problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits) | Hard | +| 1506 | [Find Root of N-Ary Tree](https://leetcode.com/problems/find-root-of-n-ary-tree "找到 N 叉树的根节点") 🔒 | [Go](../problems/find-root-of-n-ary-tree) | Medium | +| 1507 | [Reformat Date](https://leetcode.com/problems/reformat-date "转变日期格式") | [Go](../problems/reformat-date) | Easy | +| 1508 | [Range Sum of Sorted Subarray Sums](https://leetcode.com/problems/range-sum-of-sorted-subarray-sums "子数组和排序后的区间和") | [Go](../problems/range-sum-of-sorted-subarray-sums) | Medium | +| 1509 | [Minimum Difference Between Largest and Smallest Value in Three Moves](https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves "三次操作后最大值与最小值的最小差") | [Go](../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | Medium | +| 1510 | [Stone Game IV](https://leetcode.com/problems/stone-game-iv "石子游戏 IV") | [Go](../problems/stone-game-iv) | Hard | +| 1511 | [Customer Order Frequency](https://leetcode.com/problems/customer-order-frequency "消费者下单频率") 🔒 | [MySQL](../problems/customer-order-frequency) | Easy | +| 1512 | [Number of Good Pairs](https://leetcode.com/problems/number-of-good-pairs "好数对的数目") | [Go](../problems/number-of-good-pairs) | Easy | +| 1513 | [Number of Substrings With Only 1s](https://leetcode.com/problems/number-of-substrings-with-only-1s "仅含 1 的子串数") | [Go](../problems/number-of-substrings-with-only-1s) | Medium | +| 1514 | [Path with Maximum Probability](https://leetcode.com/problems/path-with-maximum-probability "概率最大的路径") | [Go](../problems/path-with-maximum-probability) | Medium | +| 1515 | [Best Position for a Service Centre](https://leetcode.com/problems/best-position-for-a-service-centre "服务中心的最佳位置") | [Go](../problems/best-position-for-a-service-centre) | Hard | +| 1516 | [Move Sub-Tree of N-Ary Tree](https://leetcode.com/problems/move-sub-tree-of-n-ary-tree "移动 N 叉树的子树") 🔒 | [Go](../problems/move-sub-tree-of-n-ary-tree) | Hard | +| 1517 | [Find Users With Valid E-Mails](https://leetcode.com/problems/find-users-with-valid-e-mails "查找拥有有效邮箱的用户") 🔒 | [MySQL](../problems/find-users-with-valid-e-mails) | Easy | +| 1518 | [Water Bottles](https://leetcode.com/problems/water-bottles "换酒问题") | [Go](../problems/water-bottles) | Easy | +| 1519 | [Number of Nodes in the Sub-Tree With the Same Label](https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label "子树中标签相同的节点数") | [Go](../problems/number-of-nodes-in-the-sub-tree-with-the-same-label) | Medium | +| 1520 | [Maximum Number of Non-Overlapping Substrings](https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings "最多的不重叠子字符串") | [Go](../problems/maximum-number-of-non-overlapping-substrings) | Hard | +| 1521 | [Find a Value of a Mysterious Function Closest to Target](https://leetcode.com/problems/find-a-value-of-a-mysterious-function-closest-to-target "找到最接近目标值的函数值") | [Go](../problems/find-a-value-of-a-mysterious-function-closest-to-target) | Hard | +| 1522 | [Diameter of N-Ary Tree](https://leetcode.com/problems/diameter-of-n-ary-tree "N 叉树的直径") 🔒 | [Go](../problems/diameter-of-n-ary-tree) | Medium | +| 1523 | [Count Odd Numbers in an Interval Range](https://leetcode.com/problems/count-odd-numbers-in-an-interval-range "在区间范围内统计奇数数目") | [Go](../problems/count-odd-numbers-in-an-interval-range) | Easy | +| 1524 | [Number of Sub-arrays With Odd Sum](https://leetcode.com/problems/number-of-sub-arrays-with-odd-sum "和为奇数的子数组数目") | [Go](../problems/number-of-sub-arrays-with-odd-sum) | Medium | +| 1525 | [Number of Good Ways to Split a String](https://leetcode.com/problems/number-of-good-ways-to-split-a-string "字符串的好分割数目") | [Go](../problems/number-of-good-ways-to-split-a-string) | Medium | +| 1526 | [Minimum Number of Increments on Subarrays to Form a Target Array](https://leetcode.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array "形成目标数组的子数组最少增加次数") | [Go](../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | Hard | +| 1527 | [Patients With a Condition](https://leetcode.com/problems/patients-with-a-condition "患某种疾病的患者") 🔒 | [MySQL](../problems/patients-with-a-condition) | Easy | +| 1528 | [Shuffle String](https://leetcode.com/problems/shuffle-string "重新排列字符串") | [Go](../problems/shuffle-string) | Easy | +| 1529 | [Minimum Suffix Flips](https://leetcode.com/problems/minimum-suffix-flips "最少的后缀翻转次数") | [Go](../problems/minimum-suffix-flips) | Medium | +| 1530 | [Number of Good Leaf Nodes Pairs](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs "好叶子节点对的数量") | [Go](../problems/number-of-good-leaf-nodes-pairs) | Medium | +| 1531 | [String Compression II](https://leetcode.com/problems/string-compression-ii "压缩字符串 II") | [Go](../problems/string-compression-ii) | Hard | +| 1532 | [The Most Recent Three Orders](https://leetcode.com/problems/the-most-recent-three-orders "最近的三笔订单") 🔒 | [MySQL](../problems/the-most-recent-three-orders) | Medium | +| 1533 | [Find the Index of the Large Integer](https://leetcode.com/problems/find-the-index-of-the-large-integer "找到最大整数的索引") 🔒 | [Go](../problems/find-the-index-of-the-large-integer) | Medium | +| 1534 | [Count Good Triplets](https://leetcode.com/problems/count-good-triplets "统计好三元组") | [Go](../problems/count-good-triplets) | Easy | +| 1535 | [Find the Winner of an Array Game](https://leetcode.com/problems/find-the-winner-of-an-array-game "找出数组游戏的赢家") | [Go](../problems/find-the-winner-of-an-array-game) | Medium | +| 1536 | [Minimum Swaps to Arrange a Binary Grid](https://leetcode.com/problems/minimum-swaps-to-arrange-a-binary-grid "排布二进制网格的最少交换次数") | [Go](../problems/minimum-swaps-to-arrange-a-binary-grid) | Medium | +| 1537 | [Get the Maximum Score](https://leetcode.com/problems/get-the-maximum-score "最大得分") | [Go](../problems/get-the-maximum-score) | Hard | +| 1538 | [Guess the Majority in a Hidden Array](https://leetcode.com/problems/guess-the-majority-in-a-hidden-array "找出隐藏数组中出现次数最多的元素") 🔒 | [Go](../problems/guess-the-majority-in-a-hidden-array) | Medium | +| 1539 | [Kth Missing Positive Number](https://leetcode.com/problems/kth-missing-positive-number "第 k 个缺失的正整数") | [Go](../problems/kth-missing-positive-number) | Easy | +| 1540 | [Can Convert String in K Moves](https://leetcode.com/problems/can-convert-string-in-k-moves "K 次操作转变字符串") | [Go](../problems/can-convert-string-in-k-moves) | Medium | +| 1541 | [Minimum Insertions to Balance a Parentheses String](https://leetcode.com/problems/minimum-insertions-to-balance-a-parentheses-string "平衡括号字符串的最少插入次数") | [Go](../problems/minimum-insertions-to-balance-a-parentheses-string) | Medium | +| 1542 | [Find Longest Awesome Substring](https://leetcode.com/problems/find-longest-awesome-substring "找出最长的超赞子字符串") | [Go](../problems/find-longest-awesome-substring) | Hard | +| 1543 | [Fix Product Name Format](https://leetcode.com/problems/fix-product-name-format "产品名称格式修复") 🔒 | [MySQL](../problems/fix-product-name-format) | Easy | +| 1544 | [Make The String Great](https://leetcode.com/problems/make-the-string-great "整理字符串") | [Go](../problems/make-the-string-great) | Easy | +| 1545 | [Find Kth Bit in Nth Binary String](https://leetcode.com/problems/find-kth-bit-in-nth-binary-string "找出第 N 个二进制字符串中的第 K 位") | [Go](../problems/find-kth-bit-in-nth-binary-string) | Medium | +| 1546 | [Maximum Number of Non-Overlapping Subarrays With Sum Equals Target](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值且不重叠的非空子数组的最大数目") | [Go](../problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | Medium | +| 1547 | [Minimum Cost to Cut a Stick](https://leetcode.com/problems/minimum-cost-to-cut-a-stick "切棍子的最小成本") | [Go](../problems/minimum-cost-to-cut-a-stick) | Hard | +| 1548 | [The Most Similar Path in a Graph](https://leetcode.com/problems/the-most-similar-path-in-a-graph "图中最相似的路径") 🔒 | [Go](../problems/the-most-similar-path-in-a-graph) | Hard | +| 1549 | [The Most Recent Orders for Each Product](https://leetcode.com/problems/the-most-recent-orders-for-each-product "每件商品的最新订单") 🔒 | [MySQL](../problems/the-most-recent-orders-for-each-product) | Medium | +| 1550 | [Three Consecutive Odds](https://leetcode.com/problems/three-consecutive-odds "存在连续三个奇数的数组") | [Go](../problems/three-consecutive-odds) | Easy | +| 1551 | [Minimum Operations to Make Array Equal](https://leetcode.com/problems/minimum-operations-to-make-array-equal "使数组中所有元素相等的最小操作数") | [Go](../problems/minimum-operations-to-make-array-equal) | Medium | +| 1552 | [Magnetic Force Between Two Balls](https://leetcode.com/problems/magnetic-force-between-two-balls "两球之间的磁力") | [Go](../problems/magnetic-force-between-two-balls) | Medium | +| 1553 | [Minimum Number of Days to Eat N Oranges](https://leetcode.com/problems/minimum-number-of-days-to-eat-n-oranges "吃掉 N 个橘子的最少天数") | [Go](../problems/minimum-number-of-days-to-eat-n-oranges) | Hard | +| 1554 | [Strings Differ by One Character](https://leetcode.com/problems/strings-differ-by-one-character "只有一个不同字符的字符串") 🔒 | [Go](../problems/strings-differ-by-one-character) | Medium | +| 1555 | [Bank Account Summary](https://leetcode.com/problems/bank-account-summary "银行账户概要") 🔒 | [MySQL](../problems/bank-account-summary) | Medium | +| 1556 | [Thousand Separator](https://leetcode.com/problems/thousand-separator "千位分隔数") | [Go](../problems/thousand-separator) | Easy | +| 1557 | [Minimum Number of Vertices to Reach All Nodes](https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes "可以到达所有点的最少点数目") | [Go](../problems/minimum-number-of-vertices-to-reach-all-nodes) | Medium | +| 1558 | [Minimum Numbers of Function Calls to Make Target Array](https://leetcode.com/problems/minimum-numbers-of-function-calls-to-make-target-array "得到目标数组的最少函数调用次数") | [Go](../problems/minimum-numbers-of-function-calls-to-make-target-array) | Medium | +| 1559 | [Detect Cycles in 2D Grid](https://leetcode.com/problems/detect-cycles-in-2d-grid "二维网格图中探测环") | [Go](../problems/detect-cycles-in-2d-grid) | Medium | +| 1560 | [Most Visited Sector in a Circular Track](https://leetcode.com/problems/most-visited-sector-in-a-circular-track "圆形赛道上经过次数最多的扇区") | [Go](../problems/most-visited-sector-in-a-circular-track) | Easy | +| 1561 | [Maximum Number of Coins You Can Get](https://leetcode.com/problems/maximum-number-of-coins-you-can-get "你可以获得的最大硬币数目") | [Go](../problems/maximum-number-of-coins-you-can-get) | Medium | +| 1562 | [Find Latest Group of Size M](https://leetcode.com/problems/find-latest-group-of-size-m "查找大小为 M 的最新分组") | [Go](../problems/find-latest-group-of-size-m) | Medium | +| 1563 | [Stone Game V](https://leetcode.com/problems/stone-game-v "石子游戏 V") | [Go](../problems/stone-game-v) | Hard | +| 1564 | [Put Boxes Into the Warehouse I](https://leetcode.com/problems/put-boxes-into-the-warehouse-i "把箱子放进仓库里 I") 🔒 | [Go](../problems/put-boxes-into-the-warehouse-i) | Medium | +| 1565 | [Unique Orders and Customers Per Month](https://leetcode.com/problems/unique-orders-and-customers-per-month "按月统计订单数与顾客数") 🔒 | [MySQL](../problems/unique-orders-and-customers-per-month) | Easy | +| 1566 | [Detect Pattern of Length M Repeated K or More Times](https://leetcode.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times "重复至少 K 次且长度为 M 的模式") | [Go](../problems/detect-pattern-of-length-m-repeated-k-or-more-times) | Easy | +| 1567 | [Maximum Length of Subarray With Positive Product](https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product "乘积为正数的最长子数组长度") | [Go](../problems/maximum-length-of-subarray-with-positive-product) | Medium | +| 1568 | [Minimum Number of Days to Disconnect Island](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数") | [Go](../problems/minimum-number-of-days-to-disconnect-island) | Hard | +| 1569 | [Number of Ways to Reorder Array to Get Same BST](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst "将子数组重新排序得到同一个二叉查找树的方案数") | [Go](../problems/number-of-ways-to-reorder-array-to-get-same-bst) | Hard | +| 1570 | [Dot Product of Two Sparse Vectors](https://leetcode.com/problems/dot-product-of-two-sparse-vectors "两个稀疏向量的点积") 🔒 | [Go](../problems/dot-product-of-two-sparse-vectors) | Medium | +| 1571 | [Warehouse Manager](https://leetcode.com/problems/warehouse-manager "仓库经理") 🔒 | [MySQL](../problems/warehouse-manager) | Easy | +| 1572 | [Matrix Diagonal Sum](https://leetcode.com/problems/matrix-diagonal-sum "矩阵对角线元素的和") | [Go](../problems/matrix-diagonal-sum) | Easy | +| 1573 | [Number of Ways to Split a String](https://leetcode.com/problems/number-of-ways-to-split-a-string "分割字符串的方案数") | [Go](../problems/number-of-ways-to-split-a-string) | Medium | +| 1574 | [Shortest Subarray to be Removed to Make Array Sorted](https://leetcode.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted "删除最短的子数组使剩余数组有序") | [Go](../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | Medium | +| 1575 | [Count All Possible Routes](https://leetcode.com/problems/count-all-possible-routes "统计所有可行路径") | [Go](../problems/count-all-possible-routes) | Hard | +| 1576 | [Replace All ?'s to Avoid Consecutive Repeating Characters](https://leetcode.com/problems/replace-all-s-to-avoid-consecutive-repeating-characters "替换所有的问号") | [Go](../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | Easy | +| 1577 | [Number of Ways Where Square of Number Is Equal to Product of Two Numbers](https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers "数的平方等于两数乘积的方法数") | [Go](../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | Medium | +| 1578 | [Minimum Time to Make Rope Colorful](https://leetcode.com/problems/minimum-time-to-make-rope-colorful "使绳子变成彩色的最短时间") | [Go](../problems/minimum-time-to-make-rope-colorful) | Medium | +| 1579 | [Remove Max Number of Edges to Keep Graph Fully Traversable](https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable "保证图可完全遍历") | [Go](../problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | Hard | +| 1580 | [Put Boxes Into the Warehouse II](https://leetcode.com/problems/put-boxes-into-the-warehouse-ii "把箱子放进仓库里 II") 🔒 | [Go](../problems/put-boxes-into-the-warehouse-ii) | Medium | +| 1581 | [Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions "进店却未进行过交易的顾客") 🔒 | [MySQL](../problems/customer-who-visited-but-did-not-make-any-transactions) | Easy | +| 1582 | [Special Positions in a Binary Matrix](https://leetcode.com/problems/special-positions-in-a-binary-matrix "二进制矩阵中的特殊位置") | [Go](../problems/special-positions-in-a-binary-matrix) | Easy | +| 1583 | [Count Unhappy Friends](https://leetcode.com/problems/count-unhappy-friends "统计不开心的朋友") | [Go](../problems/count-unhappy-friends) | Medium | +| 1584 | [Min Cost to Connect All Points](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") | [Go](../problems/min-cost-to-connect-all-points) | Medium | +| 1585 | [Check If String Is Transformable With Substring Sort Operations](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations "检查字符串是否可以通过排序子字符串得到另一个字符串") | [Go](../problems/check-if-string-is-transformable-with-substring-sort-operations) | Hard | +| 1586 | [Binary Search Tree Iterator II](https://leetcode.com/problems/binary-search-tree-iterator-ii "二叉搜索树迭代器 II") 🔒 | [Go](../problems/binary-search-tree-iterator-ii) | Medium | +| 1587 | [Bank Account Summary II](https://leetcode.com/problems/bank-account-summary-ii "银行账户概要 II") 🔒 | [MySQL](../problems/bank-account-summary-ii) | Easy | +| 1588 | [Sum of All Odd Length Subarrays](https://leetcode.com/problems/sum-of-all-odd-length-subarrays "所有奇数长度子数组的和") | [Go](../problems/sum-of-all-odd-length-subarrays) | Easy | +| 1589 | [Maximum Sum Obtained of Any Permutation](https://leetcode.com/problems/maximum-sum-obtained-of-any-permutation "所有排列中的最大和") | [Go](../problems/maximum-sum-obtained-of-any-permutation) | Medium | +| 1590 | [Make Sum Divisible by P](https://leetcode.com/problems/make-sum-divisible-by-p "使数组和能被 P 整除") | [Go](../problems/make-sum-divisible-by-p) | Medium | +| 1591 | [Strange Printer II](https://leetcode.com/problems/strange-printer-ii "奇怪的打印机 II") | [Go](../problems/strange-printer-ii) | Hard | +| 1592 | [Rearrange Spaces Between Words](https://leetcode.com/problems/rearrange-spaces-between-words "重新排列单词间的空格") | [Go](../problems/rearrange-spaces-between-words) | Easy | +| 1593 | [Split a String Into the Max Number of Unique Substrings](https://leetcode.com/problems/split-a-string-into-the-max-number-of-unique-substrings "拆分字符串使唯一子字符串的数目最大") | [Go](../problems/split-a-string-into-the-max-number-of-unique-substrings) | Medium | +| 1594 | [Maximum Non Negative Product in a Matrix](https://leetcode.com/problems/maximum-non-negative-product-in-a-matrix "矩阵的最大非负积") | [Go](../problems/maximum-non-negative-product-in-a-matrix) | Medium | +| 1595 | [Minimum Cost to Connect Two Groups of Points](https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points "连通两组点的最小成本") | [Go](../problems/minimum-cost-to-connect-two-groups-of-points) | Hard | +| 1596 | [The Most Frequently Ordered Products for Each Customer](https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer "每位顾客最经常订购的商品") 🔒 | [MySQL](../problems/the-most-frequently-ordered-products-for-each-customer) | Medium | +| 1597 | [Build Binary Expression Tree From Infix Expression](https://leetcode.com/problems/build-binary-expression-tree-from-infix-expression "根据中缀表达式构造二叉表达式树") 🔒 | [Go](../problems/build-binary-expression-tree-from-infix-expression) | Hard | +| 1598 | [Crawler Log Folder](https://leetcode.com/problems/crawler-log-folder "文件夹操作日志搜集器") | [Go](../problems/crawler-log-folder) | Easy | +| 1599 | [Maximum Profit of Operating a Centennial Wheel](https://leetcode.com/problems/maximum-profit-of-operating-a-centennial-wheel "经营摩天轮的最大利润") | [Go](../problems/maximum-profit-of-operating-a-centennial-wheel) | Medium | +| 1600 | [Throne Inheritance](https://leetcode.com/problems/throne-inheritance "皇位继承顺序") | [Go](../problems/throne-inheritance) | Medium | +| 1601 | [Maximum Number of Achievable Transfer Requests](https://leetcode.com/problems/maximum-number-of-achievable-transfer-requests "最多可达成的换楼请求数目") | [Go](../problems/maximum-number-of-achievable-transfer-requests) | Hard | +| 1602 | [Find Nearest Right Node in Binary Tree](https://leetcode.com/problems/find-nearest-right-node-in-binary-tree "找到二叉树中最近的右侧节点") 🔒 | [Go](../problems/find-nearest-right-node-in-binary-tree) | Medium | +| 1603 | [Design Parking System](https://leetcode.com/problems/design-parking-system "设计停车系统") | [Go](../problems/design-parking-system) | Easy | +| 1604 | [Alert Using Same Key-Card Three or More Times in a One Hour Period](https://leetcode.com/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period "警告一小时内使用相同员工卡大于等于三次的人") | [Go](../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | Medium | +| 1605 | [Find Valid Matrix Given Row and Column Sums](https://leetcode.com/problems/find-valid-matrix-given-row-and-column-sums "给定行和列的和求可行矩阵") | [Go](../problems/find-valid-matrix-given-row-and-column-sums) | Medium | +| 1606 | [Find Servers That Handled Most Number of Requests](https://leetcode.com/problems/find-servers-that-handled-most-number-of-requests "找到处理最多请求的服务器") | [Go](../problems/find-servers-that-handled-most-number-of-requests) | Hard | +| 1607 | [Sellers With No Sales](https://leetcode.com/problems/sellers-with-no-sales "没有卖出的卖家") 🔒 | [MySQL](../problems/sellers-with-no-sales) | Easy | +| 1608 | [Special Array With X Elements Greater Than or Equal X](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x "特殊数组的特征值") | [Go](../problems/special-array-with-x-elements-greater-than-or-equal-x) | Easy | +| 1609 | [Even Odd Tree](https://leetcode.com/problems/even-odd-tree "奇偶树") | [Go](../problems/even-odd-tree) | Medium | +| 1610 | [Maximum Number of Visible Points](https://leetcode.com/problems/maximum-number-of-visible-points "可见点的最大数目") | [Go](../problems/maximum-number-of-visible-points) | Hard | +| 1611 | [Minimum One Bit Operations to Make Integers Zero](https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero "使整数变为 0 的最少操作次数") | [Go](../problems/minimum-one-bit-operations-to-make-integers-zero) | Hard | +| 1612 | [Check If Two Expression Trees are Equivalent](https://leetcode.com/problems/check-if-two-expression-trees-are-equivalent "检查两棵二叉表达式树是否等价") 🔒 | [Go](../problems/check-if-two-expression-trees-are-equivalent) | Medium | +| 1613 | [Find the Missing IDs](https://leetcode.com/problems/find-the-missing-ids "找到遗失的ID") 🔒 | [MySQL](../problems/find-the-missing-ids) | Medium | +| 1614 | [Maximum Nesting Depth of the Parentheses](https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses "括号的最大嵌套深度") | [Go](../problems/maximum-nesting-depth-of-the-parentheses) | Easy | +| 1615 | [Maximal Network Rank](https://leetcode.com/problems/maximal-network-rank "最大网络秩") | [Go](../problems/maximal-network-rank) | Medium | +| 1616 | [Split Two Strings to Make Palindrome](https://leetcode.com/problems/split-two-strings-to-make-palindrome "分割两个字符串得到回文串") | [Go](../problems/split-two-strings-to-make-palindrome) | Medium | +| 1617 | [Count Subtrees With Max Distance Between Cities](https://leetcode.com/problems/count-subtrees-with-max-distance-between-cities "统计子树中城市之间最大距离") | [Go](../problems/count-subtrees-with-max-distance-between-cities) | Hard | +| 1618 | [Maximum Font to Fit a Sentence in a Screen](https://leetcode.com/problems/maximum-font-to-fit-a-sentence-in-a-screen "找出适应屏幕的最大字号") 🔒 | [Go](../problems/maximum-font-to-fit-a-sentence-in-a-screen) | Medium | +| 1619 | [Mean of Array After Removing Some Elements](https://leetcode.com/problems/mean-of-array-after-removing-some-elements "删除某些元素后的数组均值") | [Go](../problems/mean-of-array-after-removing-some-elements) | Easy | +| 1620 | [Coordinate With Maximum Network Quality](https://leetcode.com/problems/coordinate-with-maximum-network-quality "网络信号最好的坐标") | [Go](../problems/coordinate-with-maximum-network-quality) | Medium | +| 1621 | [Number of Sets of K Non-Overlapping Line Segments](https://leetcode.com/problems/number-of-sets-of-k-non-overlapping-line-segments "大小为 K 的不重叠线段的数目") | [Go](../problems/number-of-sets-of-k-non-overlapping-line-segments) | Medium | +| 1622 | [Fancy Sequence](https://leetcode.com/problems/fancy-sequence "奇妙序列") | [Go](../problems/fancy-sequence) | Hard | +| 1623 | [All Valid Triplets That Can Represent a Country](https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country "三人国家代表队") 🔒 | [MySQL](../problems/all-valid-triplets-that-can-represent-a-country) | Easy | +| 1624 | [Largest Substring Between Two Equal Characters](https://leetcode.com/problems/largest-substring-between-two-equal-characters "两个相同字符之间的最长子字符串") | [Go](../problems/largest-substring-between-two-equal-characters) | Easy | +| 1625 | [Lexicographically Smallest String After Applying Operations](https://leetcode.com/problems/lexicographically-smallest-string-after-applying-operations "执行操作后字典序最小的字符串") | [Go](../problems/lexicographically-smallest-string-after-applying-operations) | Medium | +| 1626 | [Best Team With No Conflicts](https://leetcode.com/problems/best-team-with-no-conflicts "无矛盾的最佳球队") | [Go](../problems/best-team-with-no-conflicts) | Medium | +| 1627 | [Graph Connectivity With Threshold](https://leetcode.com/problems/graph-connectivity-with-threshold "带阈值的图连通性") | [Go](../problems/graph-connectivity-with-threshold) | Hard | +| 1628 | [Design an Expression Tree With Evaluate Function](https://leetcode.com/problems/design-an-expression-tree-with-evaluate-function "设计带解析函数的表达式树") 🔒 | [Go](../problems/design-an-expression-tree-with-evaluate-function) | Medium | +| 1629 | [Slowest Key](https://leetcode.com/problems/slowest-key "按键持续时间最长的键") | [Go](../problems/slowest-key) | Easy | +| 1630 | [Arithmetic Subarrays](https://leetcode.com/problems/arithmetic-subarrays "等差子数组") | [Go](../problems/arithmetic-subarrays) | Medium | +| 1631 | [Path With Minimum Effort](https://leetcode.com/problems/path-with-minimum-effort "最小体力消耗路径") | [Go](../problems/path-with-minimum-effort) | Medium | +| 1632 | [Rank Transform of a Matrix](https://leetcode.com/problems/rank-transform-of-a-matrix "矩阵转换后的秩") | [Go](../problems/rank-transform-of-a-matrix) | Hard | +| 1633 | [Percentage of Users Attended a Contest](https://leetcode.com/problems/percentage-of-users-attended-a-contest "各赛事的用户注册率") 🔒 | [MySQL](../problems/percentage-of-users-attended-a-contest) | Easy | +| 1634 | [Add Two Polynomials Represented as Linked Lists](https://leetcode.com/problems/add-two-polynomials-represented-as-linked-lists "求两个多项式链表的和") 🔒 | [Go](../problems/add-two-polynomials-represented-as-linked-lists) | Medium | +| 1635 | [Hopper Company Queries I](https://leetcode.com/problems/hopper-company-queries-i "Hopper 公司查询 I") 🔒 | [MySQL](../problems/hopper-company-queries-i) | Hard | +| 1636 | [Sort Array by Increasing Frequency](https://leetcode.com/problems/sort-array-by-increasing-frequency "按照频率将数组升序排序") | [Go](../problems/sort-array-by-increasing-frequency) | Easy | +| 1637 | [Widest Vertical Area Between Two Points Containing No Points](https://leetcode.com/problems/widest-vertical-area-between-two-points-containing-no-points "两点之间不包含任何点的最宽垂直面积") | [Go](../problems/widest-vertical-area-between-two-points-containing-no-points) | Medium | +| 1638 | [Count Substrings That Differ by One Character](https://leetcode.com/problems/count-substrings-that-differ-by-one-character "统计只差一个字符的子串数目") | [Go](../problems/count-substrings-that-differ-by-one-character) | Medium | +| 1639 | [Number of Ways to Form a Target String Given a Dictionary](https://leetcode.com/problems/number-of-ways-to-form-a-target-string-given-a-dictionary "通过给定词典构造目标字符串的方案数") | [Go](../problems/number-of-ways-to-form-a-target-string-given-a-dictionary) | Hard | +| 1640 | [Check Array Formation Through Concatenation](https://leetcode.com/problems/check-array-formation-through-concatenation "能否连接形成数组") | [Go](../problems/check-array-formation-through-concatenation) | Easy | +| 1641 | [Count Sorted Vowel Strings](https://leetcode.com/problems/count-sorted-vowel-strings "统计字典序元音字符串的数目") | [Go](../problems/count-sorted-vowel-strings) | Medium | +| 1642 | [Furthest Building You Can Reach](https://leetcode.com/problems/furthest-building-you-can-reach "可以到达的最远建筑") | [Go](../problems/furthest-building-you-can-reach) | Medium | +| 1643 | [Kth Smallest Instructions](https://leetcode.com/problems/kth-smallest-instructions "第 K 条最小指令") | [Go](../problems/kth-smallest-instructions) | Hard | +| 1644 | [Lowest Common Ancestor of a Binary Tree II](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-ii "二叉树的最近公共祖先 II") 🔒 | [Go](../problems/lowest-common-ancestor-of-a-binary-tree-ii) | Medium | +| 1645 | [Hopper Company Queries II](https://leetcode.com/problems/hopper-company-queries-ii) 🔒 | [MySQL](../problems/hopper-company-queries-ii) | Hard | +| 1646 | [Get Maximum in Generated Array](https://leetcode.com/problems/get-maximum-in-generated-array "获取生成数组中的最大值") | [Go](../problems/get-maximum-in-generated-array) | Easy | +| 1647 | [Minimum Deletions to Make Character Frequencies Unique](https://leetcode.com/problems/minimum-deletions-to-make-character-frequencies-unique "字符频次唯一的最小删除次数") | [Go](../problems/minimum-deletions-to-make-character-frequencies-unique) | Medium | +| 1648 | [Sell Diminishing-Valued Colored Balls](https://leetcode.com/problems/sell-diminishing-valued-colored-balls "销售价值减少的颜色球") | [Go](../problems/sell-diminishing-valued-colored-balls) | Medium | +| 1649 | [Create Sorted Array through Instructions](https://leetcode.com/problems/create-sorted-array-through-instructions "通过指令创建有序数组") | [Go](../problems/create-sorted-array-through-instructions) | Hard | +| 1650 | [Lowest Common Ancestor of a Binary Tree III](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iii "二叉树的最近公共祖先 III") 🔒 | [Go](../problems/lowest-common-ancestor-of-a-binary-tree-iii) | Medium | +| 1651 | [Hopper Company Queries III](https://leetcode.com/problems/hopper-company-queries-iii) 🔒 | [MySQL](../problems/hopper-company-queries-iii) | Hard | +| 1652 | [Defuse the Bomb](https://leetcode.com/problems/defuse-the-bomb "拆炸弹") | [Go](../problems/defuse-the-bomb) | Easy | +| 1653 | [Minimum Deletions to Make String Balanced](https://leetcode.com/problems/minimum-deletions-to-make-string-balanced "使字符串平衡的最少删除次数") | [Go](../problems/minimum-deletions-to-make-string-balanced) | Medium | +| 1654 | [Minimum Jumps to Reach Home](https://leetcode.com/problems/minimum-jumps-to-reach-home "到家的最少跳跃次数") | [Go](../problems/minimum-jumps-to-reach-home) | Medium | +| 1655 | [Distribute Repeating Integers](https://leetcode.com/problems/distribute-repeating-integers "分配重复整数") | [Go](../problems/distribute-repeating-integers) | Hard | +| 1656 | [Design an Ordered Stream](https://leetcode.com/problems/design-an-ordered-stream "设计有序流") | [Go](../problems/design-an-ordered-stream) | Easy | +| 1657 | [Determine if Two Strings Are Close](https://leetcode.com/problems/determine-if-two-strings-are-close "确定两个字符串是否接近") | [Go](../problems/determine-if-two-strings-are-close) | Medium | +| 1658 | [Minimum Operations to Reduce X to Zero](https://leetcode.com/problems/minimum-operations-to-reduce-x-to-zero "将 x 减到 0 的最小操作数") | [Go](../problems/minimum-operations-to-reduce-x-to-zero) | Medium | +| 1659 | [Maximize Grid Happiness](https://leetcode.com/problems/maximize-grid-happiness "最大化网格幸福感") | [Go](../problems/maximize-grid-happiness) | Hard | +| 1660 | [Correct a Binary Tree](https://leetcode.com/problems/correct-a-binary-tree "纠正二叉树") 🔒 | [Go](../problems/correct-a-binary-tree) | Medium | +| 1661 | [Average Time of Process per Machine](https://leetcode.com/problems/average-time-of-process-per-machine "每台机器的进程平均运行时间") 🔒 | [MySQL](../problems/average-time-of-process-per-machine) | Easy | +| 1662 | [Check If Two String Arrays are Equivalent](https://leetcode.com/problems/check-if-two-string-arrays-are-equivalent "检查两个字符串数组是否相等") | [Go](../problems/check-if-two-string-arrays-are-equivalent) | Easy | +| 1663 | [Smallest String With A Given Numeric Value](https://leetcode.com/problems/smallest-string-with-a-given-numeric-value "具有给定数值的最小字符串") | [Go](../problems/smallest-string-with-a-given-numeric-value) | Medium | +| 1664 | [Ways to Make a Fair Array](https://leetcode.com/problems/ways-to-make-a-fair-array "生成平衡数组的方案数") | [Go](../problems/ways-to-make-a-fair-array) | Medium | +| 1665 | [Minimum Initial Energy to Finish Tasks](https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks "完成所有任务的最少初始能量") | [Go](../problems/minimum-initial-energy-to-finish-tasks) | Hard | +| 1666 | [Change the Root of a Binary Tree](https://leetcode.com/problems/change-the-root-of-a-binary-tree "改变二叉树的根节点") 🔒 | [Go](../problems/change-the-root-of-a-binary-tree) | Medium | +| 1667 | [Fix Names in a Table](https://leetcode.com/problems/fix-names-in-a-table "修复表中的名字") 🔒 | [MySQL](../problems/fix-names-in-a-table) | Easy | +| 1668 | [Maximum Repeating Substring](https://leetcode.com/problems/maximum-repeating-substring "最大重复子字符串") | [Go](../problems/maximum-repeating-substring) | Easy | +| 1669 | [Merge In Between Linked Lists](https://leetcode.com/problems/merge-in-between-linked-lists "合并两个链表") | [Go](../problems/merge-in-between-linked-lists) | Medium | +| 1670 | [Design Front Middle Back Queue](https://leetcode.com/problems/design-front-middle-back-queue "设计前中后队列") | [Go](../problems/design-front-middle-back-queue) | Medium | +| 1671 | [Minimum Number of Removals to Make Mountain Array](https://leetcode.com/problems/minimum-number-of-removals-to-make-mountain-array "得到山形数组的最少删除次数") | [Go](../problems/minimum-number-of-removals-to-make-mountain-array) | Hard | +| 1672 | [Richest Customer Wealth](https://leetcode.com/problems/richest-customer-wealth "最富有客户的资产总量") | [Go](../problems/richest-customer-wealth) | Easy | +| 1673 | [Find the Most Competitive Subsequence](https://leetcode.com/problems/find-the-most-competitive-subsequence "找出最具竞争力的子序列") | [Go](../problems/find-the-most-competitive-subsequence) | Medium | +| 1674 | [Minimum Moves to Make Array Complementary](https://leetcode.com/problems/minimum-moves-to-make-array-complementary "使数组互补的最少操作次数") | [Go](../problems/minimum-moves-to-make-array-complementary) | Medium | +| 1675 | [Minimize Deviation in Array](https://leetcode.com/problems/minimize-deviation-in-array "数组的最小偏移量") | [Go](../problems/minimize-deviation-in-array) | Hard | +| 1676 | [Lowest Common Ancestor of a Binary Tree IV](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iv "二叉树的最近公共祖先 IV") 🔒 | [Go](../problems/lowest-common-ancestor-of-a-binary-tree-iv) | Medium | +| 1677 | [Product's Worth Over Invoices](https://leetcode.com/problems/products-worth-over-invoices "发票中的产品金额") 🔒 | [MySQL](../problems/products-worth-over-invoices) | Easy | +| 1678 | [Goal Parser Interpretation](https://leetcode.com/problems/goal-parser-interpretation "设计 Goal 解析器") | [Go](../problems/goal-parser-interpretation) | Easy | +| 1679 | [Max Number of K-Sum Pairs](https://leetcode.com/problems/max-number-of-k-sum-pairs "K 和数对的最大数目") | [Go](../problems/max-number-of-k-sum-pairs) | Medium | +| 1680 | [Concatenation of Consecutive Binary Numbers](https://leetcode.com/problems/concatenation-of-consecutive-binary-numbers "连接连续二进制数字") | [Go](../problems/concatenation-of-consecutive-binary-numbers) | Medium | +| 1681 | [Minimum Incompatibility](https://leetcode.com/problems/minimum-incompatibility "最小不兼容性") | [Go](../problems/minimum-incompatibility) | Hard | +| 1682 | [Longest Palindromic Subsequence II](https://leetcode.com/problems/longest-palindromic-subsequence-ii "最长回文子序列 II") 🔒 | [Go](../problems/longest-palindromic-subsequence-ii) | Medium | +| 1683 | [Invalid Tweets](https://leetcode.com/problems/invalid-tweets "无效的推文") 🔒 | [MySQL](../problems/invalid-tweets) | Easy | +| 1684 | [Count the Number of Consistent Strings](https://leetcode.com/problems/count-the-number-of-consistent-strings "统计一致字符串的数目") | [Go](../problems/count-the-number-of-consistent-strings) | Easy | +| 1685 | [Sum of Absolute Differences in a Sorted Array](https://leetcode.com/problems/sum-of-absolute-differences-in-a-sorted-array "有序数组中差绝对值之和") | [Go](../problems/sum-of-absolute-differences-in-a-sorted-array) | Medium | +| 1686 | [Stone Game VI](https://leetcode.com/problems/stone-game-vi "石子游戏 VI") | [Go](../problems/stone-game-vi) | Medium | +| 1687 | [Delivering Boxes from Storage to Ports](https://leetcode.com/problems/delivering-boxes-from-storage-to-ports "从仓库到码头运输箱子") | [Go](../problems/delivering-boxes-from-storage-to-ports) | Hard | +| 1688 | [Count of Matches in Tournament](https://leetcode.com/problems/count-of-matches-in-tournament "比赛中的配对次数") | [Go](../problems/count-of-matches-in-tournament) | Easy | +| 1689 | [Partitioning Into Minimum Number Of Deci-Binary Numbers](https://leetcode.com/problems/partitioning-into-minimum-number-of-deci-binary-numbers "十-二进制数的最少数目") | [Go](../problems/partitioning-into-minimum-number-of-deci-binary-numbers) | Medium | +| 1690 | [Stone Game VII](https://leetcode.com/problems/stone-game-vii "石子游戏 VII") | [Go](../problems/stone-game-vii) | Medium | +| 1691 | [Maximum Height by Stacking Cuboids](https://leetcode.com/problems/maximum-height-by-stacking-cuboids "堆叠长方体的最大高度") | [Go](../problems/maximum-height-by-stacking-cuboids) | Hard | +| 1692 | [Count Ways to Distribute Candies](https://leetcode.com/problems/count-ways-to-distribute-candies "计算分配糖果的不同方式") 🔒 | [Go](../problems/count-ways-to-distribute-candies) | Hard | +| 1693 | [Daily Leads and Partners](https://leetcode.com/problems/daily-leads-and-partners "每天的领导和合伙人") 🔒 | [MySQL](../problems/daily-leads-and-partners) | Easy | +| 1694 | [Reformat Phone Number](https://leetcode.com/problems/reformat-phone-number "重新格式化电话号码") | [Go](../problems/reformat-phone-number) | Easy | +| 1695 | [Maximum Erasure Value](https://leetcode.com/problems/maximum-erasure-value "删除子数组的最大得分") | [Go](../problems/maximum-erasure-value) | Medium | +| 1696 | [Jump Game VI](https://leetcode.com/problems/jump-game-vi "跳跃游戏 VI") | [Go](../problems/jump-game-vi) | Medium | +| 1697 | [Checking Existence of Edge Length Limited Paths](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths "检查边长度限制的路径是否存在") | [Go](../problems/checking-existence-of-edge-length-limited-paths) | Hard | +| 1698 | [Number of Distinct Substrings in a String](https://leetcode.com/problems/number-of-distinct-substrings-in-a-string "字符串的不同子字符串个数") 🔒 | [Go](../problems/number-of-distinct-substrings-in-a-string) | Medium | +| 1699 | [Number of Calls Between Two Persons](https://leetcode.com/problems/number-of-calls-between-two-persons "两人之间的通话次数") 🔒 | [MySQL](../problems/number-of-calls-between-two-persons) | Medium | +| 1700 | [Number of Students Unable to Eat Lunch](https://leetcode.com/problems/number-of-students-unable-to-eat-lunch "无法吃午餐的学生数量") | [Go](../problems/number-of-students-unable-to-eat-lunch) | Easy | +| 1701 | [Average Waiting Time](https://leetcode.com/problems/average-waiting-time "平均等待时间") | [Go](../problems/average-waiting-time) | Medium | +| 1702 | [Maximum Binary String After Change](https://leetcode.com/problems/maximum-binary-string-after-change "修改后的最大二进制字符串") | [Go](../problems/maximum-binary-string-after-change) | Medium | +| 1703 | [Minimum Adjacent Swaps for K Consecutive Ones](https://leetcode.com/problems/minimum-adjacent-swaps-for-k-consecutive-ones "得到连续 K 个 1 的最少相邻交换次数") | [Go](../problems/minimum-adjacent-swaps-for-k-consecutive-ones) | Hard | +| 1704 | [Determine if String Halves Are Alike](https://leetcode.com/problems/determine-if-string-halves-are-alike "判断字符串的两半是否相似") | [Go](../problems/determine-if-string-halves-are-alike) | Easy | +| 1705 | [Maximum Number of Eaten Apples](https://leetcode.com/problems/maximum-number-of-eaten-apples "吃苹果的最大数目") | [Go](../problems/maximum-number-of-eaten-apples) | Medium | +| 1706 | [Where Will the Ball Fall](https://leetcode.com/problems/where-will-the-ball-fall "球会落何处") | [Go](../problems/where-will-the-ball-fall) | Medium | +| 1707 | [Maximum XOR With an Element From Array](https://leetcode.com/problems/maximum-xor-with-an-element-from-array "与数组中元素的最大异或值") | [Go](../problems/maximum-xor-with-an-element-from-array) | Hard | +| 1708 | [Largest Subarray Length K](https://leetcode.com/problems/largest-subarray-length-k "长度为 K 的最大子数组") 🔒 | [Go](../problems/largest-subarray-length-k) | Easy | +| 1709 | [Biggest Window Between Visits](https://leetcode.com/problems/biggest-window-between-visits "访问日期之间最大的空档期") 🔒 | [MySQL](../problems/biggest-window-between-visits) | Medium | +| 1710 | [Maximum Units on a Truck](https://leetcode.com/problems/maximum-units-on-a-truck "卡车上的最大单元数") | [Go](../problems/maximum-units-on-a-truck) | Easy | +| 1711 | [Count Good Meals](https://leetcode.com/problems/count-good-meals "大餐计数") | [Go](../problems/count-good-meals) | Medium | +| 1712 | [Ways to Split Array Into Three Subarrays](https://leetcode.com/problems/ways-to-split-array-into-three-subarrays "将数组分成三个子数组的方案数") | [Go](../problems/ways-to-split-array-into-three-subarrays) | Medium | +| 1713 | [Minimum Operations to Make a Subsequence](https://leetcode.com/problems/minimum-operations-to-make-a-subsequence "得到子序列的最少操作次数") | [Go](../problems/minimum-operations-to-make-a-subsequence) | Hard | +| 1714 | [Sum Of Special Evenly-Spaced Elements In Array](https://leetcode.com/problems/sum-of-special-evenly-spaced-elements-in-array "数组中特殊等间距元素的和") 🔒 | [Go](../problems/sum-of-special-evenly-spaced-elements-in-array) | Hard | +| 1715 | [Count Apples and Oranges](https://leetcode.com/problems/count-apples-and-oranges "苹果和橘子的个数") 🔒 | [MySQL](../problems/count-apples-and-oranges) | Medium | +| 1716 | [Calculate Money in Leetcode Bank](https://leetcode.com/problems/calculate-money-in-leetcode-bank "计算力扣银行的钱") | [Go](../problems/calculate-money-in-leetcode-bank) | Easy | +| 1717 | [Maximum Score From Removing Substrings](https://leetcode.com/problems/maximum-score-from-removing-substrings "删除子字符串的最大得分") | [Go](../problems/maximum-score-from-removing-substrings) | Medium | +| 1718 | [Construct the Lexicographically Largest Valid Sequence](https://leetcode.com/problems/construct-the-lexicographically-largest-valid-sequence "构建字典序最大的可行序列") | [Go](../problems/construct-the-lexicographically-largest-valid-sequence) | Medium | +| 1719 | [Number Of Ways To Reconstruct A Tree](https://leetcode.com/problems/number-of-ways-to-reconstruct-a-tree "重构一棵树的方案数") | [Go](../problems/number-of-ways-to-reconstruct-a-tree) | Hard | +| 1720 | [Decode XORed Array](https://leetcode.com/problems/decode-xored-array "解码异或后的数组") | [Go](../problems/decode-xored-array) | Easy | +| 1721 | [Swapping Nodes in a Linked List](https://leetcode.com/problems/swapping-nodes-in-a-linked-list "交换链表中的节点") | [Go](../problems/swapping-nodes-in-a-linked-list) | Medium | +| 1722 | [Minimize Hamming Distance After Swap Operations](https://leetcode.com/problems/minimize-hamming-distance-after-swap-operations "执行交换操作后的最小汉明距离") | [Go](../problems/minimize-hamming-distance-after-swap-operations) | Medium | +| 1723 | [Find Minimum Time to Finish All Jobs](https://leetcode.com/problems/find-minimum-time-to-finish-all-jobs "完成所有工作的最短时间") | [Go](../problems/find-minimum-time-to-finish-all-jobs) | Hard | +| 1724 | [Checking Existence of Edge Length Limited Paths II](https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths-ii "检查边长度限制的路径是否存在 II") 🔒 | [Go](../problems/checking-existence-of-edge-length-limited-paths-ii) | Hard | +| 1725 | [Number Of Rectangles That Can Form The Largest Square](https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square "可以形成最大正方形的矩形数目") | [Go](../problems/number-of-rectangles-that-can-form-the-largest-square) | Easy | +| 1726 | [Tuple with Same Product](https://leetcode.com/problems/tuple-with-same-product "同积元组") | [Go](../problems/tuple-with-same-product) | Medium | +| 1727 | [Largest Submatrix With Rearrangements](https://leetcode.com/problems/largest-submatrix-with-rearrangements "重新排列后的最大子矩阵") | [Go](../problems/largest-submatrix-with-rearrangements) | Medium | +| 1728 | [Cat and Mouse II](https://leetcode.com/problems/cat-and-mouse-ii "猫和老鼠 II") | [Go](../problems/cat-and-mouse-ii) | Hard | +| 1729 | [Find Followers Count](https://leetcode.com/problems/find-followers-count "求关注者的数量") 🔒 | [MySQL](../problems/find-followers-count) | Easy | +| 1730 | [Shortest Path to Get Food](https://leetcode.com/problems/shortest-path-to-get-food "获取食物的最短路径") 🔒 | [Go](../problems/shortest-path-to-get-food) | Medium | +| 1731 | [The Number of Employees Which Report to Each Employee](https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee "每位经理的下属员工数量") 🔒 | [MySQL](../problems/the-number-of-employees-which-report-to-each-employee) | Easy | +| 1732 | [Find the Highest Altitude](https://leetcode.com/problems/find-the-highest-altitude "找到最高海拔") | [Go](../problems/find-the-highest-altitude) | Easy | +| 1733 | [Minimum Number of People to Teach](https://leetcode.com/problems/minimum-number-of-people-to-teach "需要教语言的最少人数") | [Go](../problems/minimum-number-of-people-to-teach) | Medium | +| 1734 | [Decode XORed Permutation](https://leetcode.com/problems/decode-xored-permutation "解码异或后的排列") | [Go](../problems/decode-xored-permutation) | Medium | +| 1735 | [Count Ways to Make Array With Product](https://leetcode.com/problems/count-ways-to-make-array-with-product "生成乘积数组的方案数") | [Go](../problems/count-ways-to-make-array-with-product) | Hard | +| 1736 | [Latest Time by Replacing Hidden Digits](https://leetcode.com/problems/latest-time-by-replacing-hidden-digits "替换隐藏数字得到的最晚时间") | [Go](../problems/latest-time-by-replacing-hidden-digits) | Easy | +| 1737 | [Change Minimum Characters to Satisfy One of Three Conditions](https://leetcode.com/problems/change-minimum-characters-to-satisfy-one-of-three-conditions "满足三条件之一需改变的最少字符数") | [Go](../problems/change-minimum-characters-to-satisfy-one-of-three-conditions) | Medium | +| 1738 | [Find Kth Largest XOR Coordinate Value](https://leetcode.com/problems/find-kth-largest-xor-coordinate-value "找出第 K 大的异或坐标值") | [Go](../problems/find-kth-largest-xor-coordinate-value) | Medium | +| 1739 | [Building Boxes](https://leetcode.com/problems/building-boxes "放置盒子") | [Go](../problems/building-boxes) | Hard | +| 1740 | [Find Distance in a Binary Tree](https://leetcode.com/problems/find-distance-in-a-binary-tree "找到二叉树中的距离") 🔒 | [Go](../problems/find-distance-in-a-binary-tree) | Medium | +| 1741 | [Find Total Time Spent by Each Employee](https://leetcode.com/problems/find-total-time-spent-by-each-employee "查找每个员工花费的总时间") 🔒 | [MySQL](../problems/find-total-time-spent-by-each-employee) | Easy | +| 1742 | [Maximum Number of Balls in a Box](https://leetcode.com/problems/maximum-number-of-balls-in-a-box "盒子中小球的最大数量") | [Go](../problems/maximum-number-of-balls-in-a-box) | Easy | +| 1743 | [Restore the Array From Adjacent Pairs](https://leetcode.com/problems/restore-the-array-from-adjacent-pairs "从相邻元素对还原数组") | [Go](../problems/restore-the-array-from-adjacent-pairs) | Medium | +| 1744 | [Can You Eat Your Favorite Candy on Your Favorite Day?](https://leetcode.com/problems/can-you-eat-your-favorite-candy-on-your-favorite-day "你能在你最喜欢的那天吃到你最喜欢的糖果吗?") | [Go](../problems/can-you-eat-your-favorite-candy-on-your-favorite-day) | Medium | +| 1745 | [Palindrome Partitioning IV](https://leetcode.com/problems/palindrome-partitioning-iv "回文串分割 IV") | [Go](../problems/palindrome-partitioning-iv) | Hard | +| 1746 | [Maximum Subarray Sum After One Operation](https://leetcode.com/problems/maximum-subarray-sum-after-one-operation "经过一次操作后的最大子数组和") 🔒 | [Go](../problems/maximum-subarray-sum-after-one-operation) | Medium | +| 1747 | [Leetflex Banned Accounts](https://leetcode.com/problems/leetflex-banned-accounts "应该被禁止的Leetflex账户") 🔒 | [MySQL](../problems/leetflex-banned-accounts) | Medium | +| 1748 | [Sum of Unique Elements](https://leetcode.com/problems/sum-of-unique-elements "唯一元素的和") | [Go](../problems/sum-of-unique-elements) | Easy | +| 1749 | [Maximum Absolute Sum of Any Subarray](https://leetcode.com/problems/maximum-absolute-sum-of-any-subarray "任意子数组和的绝对值的最大值") | [Go](../problems/maximum-absolute-sum-of-any-subarray) | Medium | +| 1750 | [Minimum Length of String After Deleting Similar Ends](https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends "删除字符串两端相同字符后的最短长度") | [Go](../problems/minimum-length-of-string-after-deleting-similar-ends) | Medium | +| 1751 | [Maximum Number of Events That Can Be Attended II](https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended-ii "最多可以参加的会议数目 II") | [Go](../problems/maximum-number-of-events-that-can-be-attended-ii) | Hard | +| 1752 | [Check if Array Is Sorted and Rotated](https://leetcode.com/problems/check-if-array-is-sorted-and-rotated "检查数组是否经排序和轮转得到") | [Go](../problems/check-if-array-is-sorted-and-rotated) | Easy | +| 1753 | [Maximum Score From Removing Stones](https://leetcode.com/problems/maximum-score-from-removing-stones "移除石子的最大得分") | [Go](../problems/maximum-score-from-removing-stones) | Medium | +| 1754 | [Largest Merge Of Two Strings](https://leetcode.com/problems/largest-merge-of-two-strings "构造字典序最大的合并字符串") | [Go](../problems/largest-merge-of-two-strings) | Medium | +| 1755 | [Closest Subsequence Sum](https://leetcode.com/problems/closest-subsequence-sum "最接近目标值的子序列和") | [Go](../problems/closest-subsequence-sum) | Hard | +| 1756 | [Design Most Recently Used Queue](https://leetcode.com/problems/design-most-recently-used-queue "设计最近使用(MRU)队列") 🔒 | [Go](../problems/design-most-recently-used-queue) | Medium | +| 1757 | [Recyclable and Low Fat Products](https://leetcode.com/problems/recyclable-and-low-fat-products "可回收且低脂的产品") 🔒 | [MySQL](../problems/recyclable-and-low-fat-products) | Easy | +| 1758 | [Minimum Changes To Make Alternating Binary String](https://leetcode.com/problems/minimum-changes-to-make-alternating-binary-string "生成交替二进制字符串的最少操作数") | [Go](../problems/minimum-changes-to-make-alternating-binary-string) | Easy | +| 1759 | [Count Number of Homogenous Substrings](https://leetcode.com/problems/count-number-of-homogenous-substrings "统计同构子字符串的数目") | [Go](../problems/count-number-of-homogenous-substrings) | Medium | +| 1760 | [Minimum Limit of Balls in a Bag](https://leetcode.com/problems/minimum-limit-of-balls-in-a-bag "袋子里最少数目的球") | [Go](../problems/minimum-limit-of-balls-in-a-bag) | Medium | +| 1761 | [Minimum Degree of a Connected Trio in a Graph](https://leetcode.com/problems/minimum-degree-of-a-connected-trio-in-a-graph "一个图中连通三元组的最小度数") | [Go](../problems/minimum-degree-of-a-connected-trio-in-a-graph) | Hard | +| 1762 | [Buildings With an Ocean View](https://leetcode.com/problems/buildings-with-an-ocean-view "能看到海景的建筑物") 🔒 | [Go](../problems/buildings-with-an-ocean-view) | Medium | +| 1763 | [Longest Nice Substring](https://leetcode.com/problems/longest-nice-substring "最长的美好子字符串") | [Go](../problems/longest-nice-substring) | Easy | +| 1764 | [Form Array by Concatenating Subarrays of Another Array](https://leetcode.com/problems/form-array-by-concatenating-subarrays-of-another-array "通过连接另一个数组的子数组得到一个数组") | [Go](../problems/form-array-by-concatenating-subarrays-of-another-array) | Medium | +| 1765 | [Map of Highest Peak](https://leetcode.com/problems/map-of-highest-peak "地图中的最高点") | [Go](../problems/map-of-highest-peak) | Medium | +| 1766 | [Tree of Coprimes](https://leetcode.com/problems/tree-of-coprimes "互质树") | [Go](../problems/tree-of-coprimes) | Hard | +| 1767 | [Find the Subtasks That Did Not Execute](https://leetcode.com/problems/find-the-subtasks-that-did-not-execute "寻找没有被执行的任务对") 🔒 | [MySQL](../problems/find-the-subtasks-that-did-not-execute) | Hard | +| 1768 | [Merge Strings Alternately](https://leetcode.com/problems/merge-strings-alternately "交替合并字符串") | [Go](../problems/merge-strings-alternately) | Easy | +| 1769 | [Minimum Number of Operations to Move All Balls to Each Box](https://leetcode.com/problems/minimum-number-of-operations-to-move-all-balls-to-each-box "移动所有球到每个盒子所需的最小操作数") | [Go](../problems/minimum-number-of-operations-to-move-all-balls-to-each-box) | Medium | +| 1770 | [Maximum Score from Performing Multiplication Operations](https://leetcode.com/problems/maximum-score-from-performing-multiplication-operations "执行乘法运算的最大分数") | [Go](../problems/maximum-score-from-performing-multiplication-operations) | Medium | +| 1771 | [Maximize Palindrome Length From Subsequences](https://leetcode.com/problems/maximize-palindrome-length-from-subsequences "由子序列构造的最长回文串的长度") | [Go](../problems/maximize-palindrome-length-from-subsequences) | Hard | +| 1772 | [Sort Features by Popularity](https://leetcode.com/problems/sort-features-by-popularity "按受欢迎程度排列功能") 🔒 | [Go](../problems/sort-features-by-popularity) | Medium | +| 1773 | [Count Items Matching a Rule](https://leetcode.com/problems/count-items-matching-a-rule "统计匹配检索规则的物品数量") | [Go](../problems/count-items-matching-a-rule) | Easy | +| 1774 | [Closest Dessert Cost](https://leetcode.com/problems/closest-dessert-cost "最接近目标价格的甜点成本") | [Go](../problems/closest-dessert-cost) | Medium | +| 1775 | [Equal Sum Arrays With Minimum Number of Operations](https://leetcode.com/problems/equal-sum-arrays-with-minimum-number-of-operations "通过最少操作次数使数组的和相等") | [Go](../problems/equal-sum-arrays-with-minimum-number-of-operations) | Medium | +| 1776 | [Car Fleet II](https://leetcode.com/problems/car-fleet-ii "车队 II") | [Go](../problems/car-fleet-ii) | Hard | +| 1777 | [Product's Price for Each Store](https://leetcode.com/problems/products-price-for-each-store "每家商店的产品价格") 🔒 | [MySQL](../problems/products-price-for-each-store) | Easy | +| 1778 | [Shortest Path in a Hidden Grid](https://leetcode.com/problems/shortest-path-in-a-hidden-grid "未知网格中的最短路径") 🔒 | [Go](../problems/shortest-path-in-a-hidden-grid) | Medium | +| 1779 | [Find Nearest Point That Has the Same X or Y Coordinate](https://leetcode.com/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate "找到最近的有相同 X 或 Y 坐标的点") | [Go](../problems/find-nearest-point-that-has-the-same-x-or-y-coordinate) | Easy | +| 1780 | [Check if Number is a Sum of Powers of Three](https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three "判断一个数字是否可以表示成三的幂的和") | [Go](../problems/check-if-number-is-a-sum-of-powers-of-three) | Medium | +| 1781 | [Sum of Beauty of All Substrings](https://leetcode.com/problems/sum-of-beauty-of-all-substrings "所有子字符串美丽值之和") | [Go](../problems/sum-of-beauty-of-all-substrings) | Medium | +| 1782 | [Count Pairs Of Nodes](https://leetcode.com/problems/count-pairs-of-nodes "统计点对的数目") | [Go](../problems/count-pairs-of-nodes) | Hard | +| 1783 | [Grand Slam Titles](https://leetcode.com/problems/grand-slam-titles "大满贯数量") 🔒 | [MySQL](../problems/grand-slam-titles) | Medium | +| 1784 | [Check if Binary String Has at Most One Segment of Ones](https://leetcode.com/problems/check-if-binary-string-has-at-most-one-segment-of-ones "检查二进制字符串字段") | [Go](../problems/check-if-binary-string-has-at-most-one-segment-of-ones) | Easy | +| 1785 | [Minimum Elements to Add to Form a Given Sum](https://leetcode.com/problems/minimum-elements-to-add-to-form-a-given-sum "构成特定和需要添加的最少元素") | [Go](../problems/minimum-elements-to-add-to-form-a-given-sum) | Medium | +| 1786 | [Number of Restricted Paths From First to Last Node](https://leetcode.com/problems/number-of-restricted-paths-from-first-to-last-node "从第一个节点出发到最后一个节点的受限路径数") | [Go](../problems/number-of-restricted-paths-from-first-to-last-node) | Medium | +| 1787 | [Make the XOR of All Segments Equal to Zero](https://leetcode.com/problems/make-the-xor-of-all-segments-equal-to-zero "使所有区间的异或结果为零") | [Go](../problems/make-the-xor-of-all-segments-equal-to-zero) | Hard | +| 1788 | [Maximize the Beauty of the Garden](https://leetcode.com/problems/maximize-the-beauty-of-the-garden "最大化花园的美观度") 🔒 | [Go](../problems/maximize-the-beauty-of-the-garden) | Hard | +| 1789 | [Primary Department for Each Employee](https://leetcode.com/problems/primary-department-for-each-employee "员工的直属部门") 🔒 | [MySQL](../problems/primary-department-for-each-employee) | Easy | +| 1790 | [Check if One String Swap Can Make Strings Equal](https://leetcode.com/problems/check-if-one-string-swap-can-make-strings-equal "仅执行一次字符串交换能否使两个字符串相等") | [Go](../problems/check-if-one-string-swap-can-make-strings-equal) | Easy | +| 1791 | [Find Center of Star Graph](https://leetcode.com/problems/find-center-of-star-graph "找出星型图的中心节点") | [Go](../problems/find-center-of-star-graph) | Easy | +| 1792 | [Maximum Average Pass Ratio](https://leetcode.com/problems/maximum-average-pass-ratio "最大平均通过率") | [Go](../problems/maximum-average-pass-ratio) | Medium | +| 1793 | [Maximum Score of a Good Subarray](https://leetcode.com/problems/maximum-score-of-a-good-subarray "好子数组的最大分数") | [Go](../problems/maximum-score-of-a-good-subarray) | Hard | +| 1794 | [Count Pairs of Equal Substrings With Minimum Difference](https://leetcode.com/problems/count-pairs-of-equal-substrings-with-minimum-difference "统计距离最小的子串对个数") 🔒 | [Go](../problems/count-pairs-of-equal-substrings-with-minimum-difference) | Medium | +| 1795 | [Rearrange Products Table](https://leetcode.com/problems/rearrange-products-table "每个产品在不同商店的价格") 🔒 | [MySQL](../problems/rearrange-products-table) | Easy | +| 1796 | [Second Largest Digit in a String](https://leetcode.com/problems/second-largest-digit-in-a-string "字符串中第二大的数字") | [Go](../problems/second-largest-digit-in-a-string) | Easy | +| 1797 | [Design Authentication Manager](https://leetcode.com/problems/design-authentication-manager "设计一个验证系统") | [Go](../problems/design-authentication-manager) | Medium | +| 1798 | [Maximum Number of Consecutive Values You Can Make](https://leetcode.com/problems/maximum-number-of-consecutive-values-you-can-make "你能构造出连续值的最大数目") | [Go](../problems/maximum-number-of-consecutive-values-you-can-make) | Medium | +| 1799 | [Maximize Score After N Operations](https://leetcode.com/problems/maximize-score-after-n-operations "N 次操作后的最大分数和") | [Go](../problems/maximize-score-after-n-operations) | Hard | +| 1800 | [Maximum Ascending Subarray Sum](https://leetcode.com/problems/maximum-ascending-subarray-sum "最大升序子数组和") | [Go](../problems/maximum-ascending-subarray-sum) | Easy | diff --git a/readme/301-600.md b/readme/301-600.md index d0b689921..1a0e6f251 100644 --- a/readme/301-600.md +++ b/readme/301-600.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    @@ -103,7 +111,7 @@ LeetCode Problems' Solutions | 323 | [Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph "无向图中连通分量的数目") 🔒 | [Go](../problems/number-of-connected-components-in-an-undirected-graph) | Medium | | 324 | [Wiggle Sort II](https://leetcode.com/problems/wiggle-sort-ii "摆动排序 II") | [Go](../problems/wiggle-sort-ii) | Medium | | 325 | [Maximum Size Subarray Sum Equals k](https://leetcode.com/problems/maximum-size-subarray-sum-equals-k "和等于 k 的最长子数组长度") 🔒 | [Go](../problems/maximum-size-subarray-sum-equals-k) | Medium | -| 326 | [Power of Three](https://leetcode.com/problems/power-of-three "3的幂") | [Go](../problems/power-of-three) | Easy | +| 326 | [Power of Three](https://leetcode.com/problems/power-of-three "3 的幂") | [Go](../problems/power-of-three) | Easy | | 327 | [Count of Range Sum](https://leetcode.com/problems/count-of-range-sum "区间和的个数") | [Go](../problems/count-of-range-sum) | Hard | | 328 | [Odd Even Linked List](https://leetcode.com/problems/odd-even-linked-list "奇偶链表") | [Go](../problems/odd-even-linked-list) | Medium | | 329 | [Longest Increasing Path in a Matrix](https://leetcode.com/problems/longest-increasing-path-in-a-matrix "矩阵中的最长递增路径") | [Go](../problems/longest-increasing-path-in-a-matrix) | Hard | @@ -150,7 +158,7 @@ LeetCode Problems' Solutions | 370 | [Range Addition](https://leetcode.com/problems/range-addition "区间加法") 🔒 | [Go](../problems/range-addition) | Medium | | 371 | [Sum of Two Integers](https://leetcode.com/problems/sum-of-two-integers "两整数之和") | [Go](../problems/sum-of-two-integers) | Medium | | 372 | [Super Pow](https://leetcode.com/problems/super-pow "超级次方") | [Go](../problems/super-pow) | Medium | -| 373 | [Find K Pairs with Smallest Sums](https://leetcode.com/problems/find-k-pairs-with-smallest-sums "查找和最小的K对数字") | [Go](../problems/find-k-pairs-with-smallest-sums) | Medium | +| 373 | [Find K Pairs with Smallest Sums](https://leetcode.com/problems/find-k-pairs-with-smallest-sums "查找和最小的 K 对数字") | [Go](../problems/find-k-pairs-with-smallest-sums) | Medium | | 374 | [Guess Number Higher or Lower](https://leetcode.com/problems/guess-number-higher-or-lower "猜数字大小") | [Go](../problems/guess-number-higher-or-lower) | Easy | | 375 | [Guess Number Higher or Lower II](https://leetcode.com/problems/guess-number-higher-or-lower-ii "猜数字大小 II") | [Go](../problems/guess-number-higher-or-lower-ii) | Medium | | 376 | [Wiggle Subsequence](https://leetcode.com/problems/wiggle-subsequence "摆动序列") | [Go](../problems/wiggle-subsequence) | Medium | diff --git a/readme/601-900.md b/readme/601-900.md index 5ceafc962..91d593fbe 100644 --- a/readme/601-900.md +++ b/readme/601-900.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    @@ -165,7 +173,7 @@ LeetCode Problems' Solutions | 685 | [Redundant Connection II](https://leetcode.com/problems/redundant-connection-ii "冗余连接 II") | [Go](../problems/redundant-connection-ii) | Hard | | 686 | [Repeated String Match](https://leetcode.com/problems/repeated-string-match "重复叠加字符串匹配") | [Go](../problems/repeated-string-match) | Medium | | 687 | [Longest Univalue Path](https://leetcode.com/problems/longest-univalue-path "最长同值路径") | [Go](../problems/longest-univalue-path) | Medium | -| 688 | [Knight Probability in Chessboard](https://leetcode.com/problems/knight-probability-in-chessboard "“马”在棋盘上的概率") | [Go](../problems/knight-probability-in-chessboard) | Medium | +| 688 | [Knight Probability in Chessboard](https://leetcode.com/problems/knight-probability-in-chessboard "骑士在棋盘上的概率") | [Go](../problems/knight-probability-in-chessboard) | Medium | | 689 | [Maximum Sum of 3 Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays "三个无重叠子数组的最大和") | [Go](../problems/maximum-sum-of-3-non-overlapping-subarrays) | Hard | | 690 | [Employee Importance](https://leetcode.com/problems/employee-importance "员工的重要性") | [Go](../problems/employee-importance) | Medium | | 691 | [Stickers to Spell Word](https://leetcode.com/problems/stickers-to-spell-word "贴纸拼词") | [Go](../problems/stickers-to-spell-word) | Hard | @@ -365,7 +373,7 @@ LeetCode Problems' Solutions | 885 | [Spiral Matrix III](https://leetcode.com/problems/spiral-matrix-iii "螺旋矩阵 III") | [Go](../problems/spiral-matrix-iii) | Medium | | 886 | [Possible Bipartition](https://leetcode.com/problems/possible-bipartition "可能的二分法") | [Go](../problems/possible-bipartition) | Medium | | 887 | [Super Egg Drop](https://leetcode.com/problems/super-egg-drop "鸡蛋掉落") | [Go](../problems/super-egg-drop) | Hard | -| 888 | [Fair Candy Swap](https://leetcode.com/problems/fair-candy-swap "公平的糖果棒交换") | [Go](../problems/fair-candy-swap) | Easy | +| 888 | [Fair Candy Swap](https://leetcode.com/problems/fair-candy-swap "公平的糖果交换") | [Go](../problems/fair-candy-swap) | Easy | | 889 | [Construct Binary Tree from Preorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal "根据前序和后序遍历构造二叉树") | [Go](../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | Medium | | 890 | [Find and Replace Pattern](https://leetcode.com/problems/find-and-replace-pattern "查找和替换模式") | [Go](../problems/find-and-replace-pattern) | Medium | | 891 | [Sum of Subsequence Widths](https://leetcode.com/problems/sum-of-subsequence-widths "子序列宽度之和") | [Go](../problems/sum-of-subsequence-widths) | Hard | diff --git a/readme/901-1200.md b/readme/901-1200.md index 56787b7be..d782e4e6a 100644 --- a/readme/901-1200.md +++ b/readme/901-1200.md @@ -19,60 +19,68 @@ LeetCode Problems' Solutions - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + +
    [1-50][51-100][101-150][151-200][201-250][251-300][1-50][51-100][101-150][151-200][201-250][251-300]
    [301-350][351-400][401-450][451-500][501-550][551-600][301-350][351-400][401-450][451-500][501-550][551-600]
    [601-650][651-700][701-750][751-800][801-850][851-900][601-650][651-700][701-750][751-800][801-850][851-900]
    [901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200][901-950][951-1000][1001-1050][1051-1100][1101-1150][1151-1200]
    [1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500][1201-1250][1251-1300][1301-1350][1351-1400][1401-1450][1451-1500]
    [1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800][1501-1550][1551-1600][1601-1650][1651-1700][1701-1750][1751-1800]
    [1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100][1801-1850][1851-1900][1901-1950][1951-2000][2001-2050][2051-2100]
    [2101-2150][2151-2200][2201-2250][2251-2300][2301-2350][2351-2400]
    @@ -211,7 +219,7 @@ LeetCode Problems' Solutions | 1031 | [Maximum Sum of Two Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays "两个非重叠子数组的最大和") | [Go](../problems/maximum-sum-of-two-non-overlapping-subarrays) | Medium | | 1032 | [Stream of Characters](https://leetcode.com/problems/stream-of-characters "字符流") | [Go](../problems/stream-of-characters) | Hard | | 1033 | [Moving Stones Until Consecutive](https://leetcode.com/problems/moving-stones-until-consecutive "移动石子直到连续") | [Go](../problems/moving-stones-until-consecutive) | Medium | -| 1034 | [Coloring A Border](https://leetcode.com/problems/coloring-a-border "边框着色") | [Go](../problems/coloring-a-border) | Medium | +| 1034 | [Coloring A Border](https://leetcode.com/problems/coloring-a-border "边界着色") | [Go](../problems/coloring-a-border) | Medium | | 1035 | [Uncrossed Lines](https://leetcode.com/problems/uncrossed-lines "不相交的线") | [Go](../problems/uncrossed-lines) | Medium | | 1036 | [Escape a Large Maze](https://leetcode.com/problems/escape-a-large-maze "逃离大迷宫") | [Go](../problems/escape-a-large-maze) | Hard | | 1037 | [Valid Boomerang](https://leetcode.com/problems/valid-boomerang "有效的回旋镖") | [Go](../problems/valid-boomerang) | Easy | @@ -292,7 +300,7 @@ LeetCode Problems' Solutions | 1112 | [Highest Grade For Each Student](https://leetcode.com/problems/highest-grade-for-each-student "每位学生的最高成绩") 🔒 | [MySQL](../problems/highest-grade-for-each-student) | Medium | | 1113 | [Reported Posts](https://leetcode.com/problems/reported-posts "报告的记录") 🔒 | [MySQL](../problems/reported-posts) | Easy | | 1114 | [Print in Order](https://leetcode.com/problems/print-in-order "按序打印") | [Go](../problems/print-in-order) | Easy | -| 1115 | [Print FooBar Alternately](https://leetcode.com/problems/print-foobar-alternately "交替打印FooBar") | [Go](../problems/print-foobar-alternately) | Medium | +| 1115 | [Print FooBar Alternately](https://leetcode.com/problems/print-foobar-alternately "交替打印 FooBar") | [Go](../problems/print-foobar-alternately) | Medium | | 1116 | [Print Zero Even Odd](https://leetcode.com/problems/print-zero-even-odd "打印零与奇偶数") | [Go](../problems/print-zero-even-odd) | Medium | | 1117 | [Building H2O](https://leetcode.com/problems/building-h2o "H2O 生成") | [Go](../problems/building-h2o) | Medium | | 1118 | [Number of Days in a Month](https://leetcode.com/problems/number-of-days-in-a-month "一月有多少天") 🔒 | [Go](../problems/number-of-days-in-a-month) | Easy | diff --git a/tag/array/README.md b/tag/array/README.md index 90abb510d..ef5f632f3 100644 --- a/tag/array/README.md +++ b/tag/array/README.md @@ -9,6 +9,62 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2172 | [数组的最大与和](../../problems/maximum-and-sum-of-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 2171 | [拿出最少数目的魔法豆](../../problems/removing-minimum-number-of-magic-beans) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2170 | [使数组变成交替数组的最少操作数](../../problems/minimum-operations-to-make-the-array-alternating) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2166 | [设计位集](../../problems/design-bitset) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 2164 | [对奇偶下标分别排序](../../problems/sort-even-and-odd-indices-independently) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2163 | [删除元素后和的最小差值](../../problems/minimum-difference-in-sums-after-removal-of-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2161 | [根据给定数字划分数组](../../problems/partition-array-according-to-given-pivot) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2158 | [Amount of New Area Painted Each Day](../../problems/amount-of-new-area-painted-each-day) 🔒 | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 2155 | [分组得分最高的所有下标](../../problems/all-divisions-with-the-highest-score-of-a-binary-array) | [[数组](../array/README.md)] | Medium | +| 2154 | [将找到的值乘以 2](../../problems/keep-multiplying-found-values-by-two) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2151 | [基于陈述统计最多好人数](../../problems/maximum-good-people-based-on-statements) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 2150 | [找出数组中的所有孤独数字](../../problems/find-all-lonely-numbers-in-the-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2149 | [按符号重排数组](../../problems/rearrange-array-elements-by-sign) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2148 | [元素计数](../../problems/count-elements-with-strictly-smaller-and-greater-elements) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2145 | [统计隐藏数组数目](../../problems/count-the-hidden-sequences) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2144 | [打折购买糖果的最小开销](../../problems/minimum-cost-of-buying-candies-with-discount) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2143 | [Choose Numbers From Two Arrays in Range](../../problems/choose-numbers-from-two-arrays-in-range) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2141 | [同时运行 N 台电脑的最长时间](../../problems/maximum-running-time-of-n-computers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2140 | [解决智力问题](../../problems/solving-questions-with-brainpower) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2137 | [Pour Water Between Buckets to Make Water Levels Equal](../../problems/pour-water-between-buckets-to-make-water-levels-equal) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 2136 | [全部开花的最早一天](../../problems/earliest-possible-day-of-full-bloom) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2134 | [最少交换次数来组合所有的 1 II](../../problems/minimum-swaps-to-group-all-1s-together-ii) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2133 | [检查是否每一行每一列都包含全部整数](../../problems/check-if-every-row-and-column-contains-all-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 2132 | [用邮票贴满网格图](../../problems/stamping-the-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2128 | [Remove All Ones With Row and Column Flips](../../problems/remove-all-ones-with-row-and-column-flips) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2126 | [摧毁小行星](../../problems/destroying-asteroids) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2125 | [银行中的激光束数量](../../problems/number-of-laser-beams-in-a-bank) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2123 | [Minimum Operations to Remove Adjacent Ones in Matrix](../../problems/minimum-operations-to-remove-adjacent-ones-in-matrix) 🔒 | [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2122 | [还原原数组](../../problems/recover-the-original-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2121 | [相同元素的间隔之和](../../problems/intervals-between-identical-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 2114 | [句子中的最多单词数](../../problems/maximum-number-of-words-found-in-sentences) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 2113 | [Elements in Array After Removing and Replacing Elements](../../problems/elements-in-array-after-removing-and-replacing-elements) 🔒 | [[数组](../array/README.md)] | Medium | +| 2111 | [使数组 K 递增的最少操作次数](../../problems/minimum-operations-to-make-the-array-k-increasing) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 2110 | [股票平滑下跌阶段的数目](../../problems/number-of-smooth-descent-periods-of-a-stock) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2109 | [向字符串添加空格](../../problems/adding-spaces-to-a-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2108 | [找出数组中的第一个回文字符串](../../problems/find-first-palindromic-string-in-the-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 2107 | [Number of Unique Flavors After Sharing K Candies](../../problems/number-of-unique-flavors-after-sharing-k-candies) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2106 | [摘水果](../../problems/maximum-fruits-harvested-after-at-most-k-steps) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 2105 | [给植物浇水 II](../../problems/watering-plants-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2104 | [子数组范围和](../../problems/sum-of-subarray-ranges) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2100 | [适合打劫银行的日子](../../problems/find-good-days-to-rob-the-bank) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2099 | [找到和最大的长度为 K 的子序列](../../problems/find-subsequence-of-length-k-with-the-largest-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 2098 | [Subsequence of Size K With the Largest Even Sum](../../problems/subsequence-of-size-k-with-the-largest-even-sum) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2094 | [找出 3 位偶数](../../problems/finding-3-digit-even-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2091 | [从数组中移除最大值和最小值](../../problems/removing-minimum-and-maximum-from-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 2090 | [半径为 k 的子数组平均值](../../problems/k-radius-subarray-averages) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2089 | [找出数组排序后的目标下标](../../problems/find-target-indices-after-sorting-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2088 | [统计农场中肥沃金字塔的数目](../../problems/count-fertile-pyramids-in-a-land) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2087 | [网格图中机器人回家的最小代价](../../problems/minimum-cost-homecoming-of-a-robot-in-a-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2085 | [统计出现过一次的公共字符串](../../problems/count-common-words-with-one-occurrence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2079 | [给植物浇水](../../problems/watering-plants) | [[数组](../array/README.md)] | Medium | | 2078 | [两栋颜色不同且距离最远的房子](../../problems/two-furthest-houses-with-different-colors) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | @@ -17,32 +73,31 @@ | 2070 | [每一个查询的最大美丽值](../../problems/most-beautiful-item-for-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 2065 | [最大化一张图中的路径价值](../../problems/maximum-path-quality-of-a-graph) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 2064 | [分配给商店的最多商品的最小值](../../problems/minimized-maximum-of-products-distributed-to-any-store) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 2061 | [Number of Spaces Cleaning Robot Cleaned](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2061 | [扫地机器人清扫过的空间个数](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2059 | [转化数字的最小运算数](../../problems/minimum-operations-to-convert-number) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] | Medium | | 2057 | [值相等的最小索引](../../problems/smallest-index-with-equal-value) | [[数组](../array/README.md)] | Easy | | 2056 | [棋盘上有效移动组合的数目](../../problems/number-of-valid-move-combinations-on-chessboard) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[模拟](../simulation/README.md)] | Hard | | 2055 | [蜡烛之间的盘子](../../problems/plates-between-candles) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2053 | [数组中第 K 个独一无二的字符串](../../problems/kth-distinct-string-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | -| 2052 | [Minimum Cost to Separate Sentence Into Rows](../../problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2052 | [将句子分隔成行的最低成本](../../problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 2044 | [统计按位或能得到最大值的子集数目](../../problems/count-number-of-maximum-bitwise-or-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2040 | [两个有序数组的第 K 小乘积](../../problems/kth-smallest-product-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 2037 | [使每位学生都有座位的最少移动次数](../../problems/minimum-number-of-moves-to-seat-everyone) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | -| 2036 | [Maximum Alternating Subarray Sum](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2036 | [最大交替子数组和](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | | 2032 | [至少在两个数组中出现的值](../../problems/two-out-of-three) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 2029 | [石子游戏 IX](../../problems/stone-game-ix) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 2028 | [找出缺失的观测数据](../../problems/find-missing-observations) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2023 | [连接后等于目标字符串的字符串对](../../problems/number-of-pairs-of-strings-with-concatenation-equal-to-target) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 2022 | [将一维数组转变成二维数组](../../problems/convert-1d-array-into-2d-array) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | -| 2021 | [Brightest Position on Street](../../problems/brightest-position-on-street) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2021 | [街上最亮的位置](../../problems/brightest-position-on-street) 🔒 | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 2018 | [判断单词是否能放入填字游戏内](../../problems/check-if-word-can-be-placed-in-crossword) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 2017 | [网格游戏](../../problems/grid-game) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | @@ -54,7 +109,7 @@ | 2009 | [使数组连续的最少操作数](../../problems/minimum-number-of-operations-to-make-array-continuous) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 2008 | [出租车的最大盈利](../../problems/maximum-earnings-from-taxi) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | | 2007 | [从双倍数组中还原原数组](../../problems/find-original-array-from-doubled-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | -| 2006 | [差的绝对值为 K 的数对数目](../../problems/count-number-of-pairs-with-absolute-difference-k) | [[数组](../array/README.md)] | Easy | +| 2006 | [差的绝对值为 K 的数对数目](../../problems/count-number-of-pairs-with-absolute-difference-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 1997 | [访问完所有房间的第一天](../../problems/first-day-where-you-have-been-in-all-the-rooms) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -65,7 +120,7 @@ | 1991 | [找到数组的中间位置](../../problems/find-the-middle-index-in-array) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | | 1986 | [完成任务的最少工作时间段](../../problems/minimum-number-of-work-sessions-to-finish-the-tasks) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1982 | [从子集的和还原数组](../../problems/find-array-given-subset-sums) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] | Hard | | 1981 | [最小化目标值与所选元素的差](../../problems/minimize-the-difference-between-target-and-chosen-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1980 | [找出不同的二进制字符串](../../problems/find-unique-binary-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | @@ -89,9 +144,10 @@ | 1943 | [描述绘画结果](../../problems/describe-the-painting) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1942 | [最小未被占据椅子的编号](../../problems/the-number-of-the-smallest-unoccupied-chair) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1940 | [排序数组之间的最长公共子序列](../../problems/longest-common-subsequence-between-sorted-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 1936 | [新增的最少台阶数](../../problems/add-minimum-number-of-rungs) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1929 | [数组串联](../../problems/concatenation-of-array) | [[数组](../array/README.md)] | Easy | | 1926 | [迷宫中离入口最近的出口](../../problems/nearest-exit-from-entrance-in-maze) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1924 | [Erect the Fence II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1924 | [安装栅栏 II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1920 | [基于排列构建数组](../../problems/build-array-from-permutation) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | @@ -114,7 +170,7 @@ | 1889 | [装包裹的最小浪费空间](../../problems/minimum-space-wasted-from-packaging) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Hard | | 1887 | [使数组元素相等的减少操作次数](../../problems/reduction-operations-to-make-the-array-elements-equal) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1886 | [判断矩阵经轮转后是否一致](../../problems/determine-whether-matrix-can-be-obtained-by-rotation) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | -| 1885 | [Count Pairs in Two Arrays](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1885 | [统计数对](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 1883 | [准时抵达会议现场的最小跳过休息次数](../../problems/minimum-skips-to-arrive-at-meeting-on-time) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1882 | [使用服务器处理任务](../../problems/process-tasks-using-servers) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1879 | [两个数组最小的异或值之和](../../problems/minimum-xor-sum-of-two-arrays) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | @@ -146,7 +202,7 @@ | 1827 | [最少操作使数组递增](../../problems/minimum-operations-to-make-the-array-increasing) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 1826 | [有缺陷的传感器](../../problems/faulty-sensor) 🔒 | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 1824 | [最少侧跳次数](../../problems/minimum-sideway-jumps) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1822 | [数组元素积的符号](../../problems/sign-of-the-product-of-an-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1820 | [最多邀请的个数](../../problems/maximum-number-of-accepted-invitations) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Hard | @@ -262,6 +318,7 @@ | 1606 | [找到处理最多请求的服务器](../../problems/find-servers-that-handled-most-number-of-requests) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1605 | [给定行和列的和求可行矩阵](../../problems/find-valid-matrix-given-row-and-column-sums) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1604 | [警告一小时内使用相同员工卡大于等于三次的人](../../problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1599 | [经营摩天轮的最大利润](../../problems/maximum-profit-of-operating-a-centennial-wheel) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1598 | [文件夹操作日志搜集器](../../problems/crawler-log-folder) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | @@ -274,7 +331,7 @@ | 1583 | [统计不开心的朋友](../../problems/count-unhappy-friends) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1582 | [二进制矩阵中的特殊位置](../../problems/special-positions-in-a-binary-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | | 1580 | [把箱子放进仓库里 II](../../problems/put-boxes-into-the-warehouse-ii) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1578 | [使绳子变成彩色的最短时间](../../problems/minimum-time-to-make-rope-colorful) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1577 | [数的平方等于两数乘积的方法数](../../problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1574 | [删除最短的子数组使剩余数组有序](../../problems/shortest-subarray-to-be-removed-to-make-array-sorted) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | @@ -370,7 +427,7 @@ | 1383 | [最大的团队表现值](../../problems/maximum-performance-of-a-team) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1381 | [设计一个支持增量操作的栈](../../problems/design-a-stack-with-increment-operation) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数组](../array/README.md)] | Medium | | 1380 | [矩阵中的幸运数](../../problems/lucky-numbers-in-a-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Easy | -| 1375 | [灯泡开关 III](../../problems/bulb-switcher-iii) | [[数组](../array/README.md)] | Medium | +| 1375 | [二进制字符串前缀一致的次数](../../problems/number-of-times-binary-string-is-prefix-aligned) | [[数组](../array/README.md)] | Medium | | 1368 | [使网格图至少有一条有效路径的最小代价](../../problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1366 | [通过投票对团队排名](../../problems/rank-teams-by-votes) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Medium | | 1365 | [有多少小于当前数字的数字](../../problems/how-many-numbers-are-smaller-than-the-current-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | @@ -517,7 +574,7 @@ | 1039 | [多边形三角剖分的最低得分](../../problems/minimum-score-triangulation-of-polygon) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 1035 | [不相交的线](../../problems/uncrossed-lines) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1034 | [边界着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1032 | [字符流](../../problems/stream-of-characters) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[数据流](../data-stream/README.md)] | Hard | | 1031 | [两个非重叠子数组的最大和](../../problems/maximum-sum-of-two-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Easy | @@ -610,7 +667,7 @@ | 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 888 | [公平的糖果交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 885 | [螺旋矩阵 III](../../problems/spiral-matrix-iii) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 883 | [三维形体投影面积](../../problems/projection-area-of-3d-shapes) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Easy | | 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -626,7 +683,7 @@ | 861 | [翻转矩阵后的得分](../../problems/score-after-flipping-matrix) | [[贪心](../greedy/README.md)] [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 860 | [柠檬水找零](../../problems/lemonade-change) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 853 | [车队](../../problems/car-fleet) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 853 | [车队](../../problems/car-fleet) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 852 | [山脉数组的峰顶索引](../../problems/peak-index-in-a-mountain-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 851 | [喧闹和富有](../../problems/loud-and-rich) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] | Medium | | 850 | [矩形面积 II](../../problems/rectangle-area-ii) | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[扫描线](../line-sweep/README.md)] | Hard | @@ -649,7 +706,7 @@ | 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | | 813 | [最大平均值和的分组](../../problems/largest-sum-of-averages) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 812 | [最大三角形面积](../../problems/largest-triangle-area) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | -| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | | 810 | [黑板异或游戏](../../problems/chalkboard-xor-game) | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Hard | | 809 | [情感丰富的文字](../../problems/expressive-words) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 807 | [保持城市天际线](../../problems/max-increase-to-keep-city-skyline) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -664,6 +721,7 @@ | 789 | [逃脱阻碍者](../../problems/escape-the-ghosts) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 786 | [第 K 个最小的素数分数](../../problems/k-th-smallest-prime-fraction) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 778 | [水位上升的泳池中游泳](../../problems/swim-in-rising-water) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 775 | [全局倒置与局部倒置](../../problems/global-and-local-inversions) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 774 | [最小化去加油站的最大距离](../../problems/minimize-max-distance-to-gas-station) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | @@ -680,6 +738,7 @@ | 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 750 | [角矩形的数量](../../problems/number-of-corner-rectangles) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 749 | [隔离病毒](../../problems/contain-virus) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Hard | +| 748 | [最短补全词](../../problems/shortest-completing-word) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 747 | [至少是其他数字两倍的最大数](../../problems/largest-number-at-least-twice-of-others) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 746 | [使用最小花费爬楼梯](../../problems/min-cost-climbing-stairs) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 744 | [寻找比目标字母大的最小字母](../../problems/find-smallest-letter-greater-than-target) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | @@ -835,7 +894,7 @@ | 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 377 | [组合总和 Ⅳ](../../problems/combination-sum-iv) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 376 | [摆动序列](../../problems/wiggle-subsequence) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 373 | [查找和最小的K对数字](../../problems/find-k-pairs-with-smallest-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 373 | [查找和最小的 K 对数字](../../problems/find-k-pairs-with-smallest-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 370 | [区间加法](../../problems/range-addition) 🔒 | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 368 | [最大整除子集](../../problems/largest-divisible-subset) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | | 363 | [矩形区域不超过 K 的最大数值和](../../problems/max-sum-of-rectangle-no-larger-than-k) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | @@ -877,7 +936,7 @@ | 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 287 | [寻找重复数](../../problems/find-the-duplicate-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 286 | [墙与门](../../problems/walls-and-gates) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 284 | [窥探迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 283 | [移动零](../../problems/move-zeroes) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 280 | [摆动排序](../../problems/wiggle-sort) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -923,7 +982,7 @@ | 174 | [地下城游戏](../../problems/dungeon-game) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | | 169 | [多数元素](../../problems/majority-element) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] | Easy | -| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 164 | [最大间距](../../problems/maximum-gap) | [[数组](../array/README.md)] [[桶排序](../bucket-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] | Hard | | 163 | [缺失的区间](../../problems/missing-ranges) 🔒 | [[数组](../array/README.md)] | Easy | | 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -931,6 +990,7 @@ | 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 152 | [乘积最大子数组](../../problems/maximum-product-subarray) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | | 137 | [只出现一次的数字 II](../../problems/single-number-ii) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Medium | | 136 | [只出现一次的数字](../../problems/single-number) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] | Easy | | 135 | [分发糖果](../../problems/candy) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Hard | @@ -966,7 +1026,7 @@ | 56 | [合并区间](../../problems/merge-intervals) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 55 | [跳跃游戏](../../problems/jump-game) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 54 | [螺旋矩阵](../../problems/spiral-matrix) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 53 | [最大子数组和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 51 | [N 皇后](../../problems/n-queens) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 48 | [旋转图像](../../problems/rotate-image) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 47 | [全排列 II](../../problems/permutations-ii) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | diff --git a/tag/backtracking/README.md b/tag/backtracking/README.md index b864fa7ec..88a033751 100644 --- a/tag/backtracking/README.md +++ b/tag/backtracking/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2151 | [基于陈述统计最多好人数](../../problems/maximum-good-people-based-on-statements) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2065 | [最大化一张图中的路径价值](../../problems/maximum-path-quality-of-a-graph) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 2056 | [棋盘上有效移动组合的数目](../../problems/number-of-valid-move-combinations-on-chessboard) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[模拟](../simulation/README.md)] | Hard | | 2048 | [下一个更大的数值平衡数](../../problems/next-greater-numerically-balanced-number) | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Medium | @@ -26,6 +28,7 @@ | 1723 | [完成所有工作的最短时间](../../problems/find-minimum-time-to-finish-all-jobs) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1718 | [构建字典序最大的可行序列](../../problems/construct-the-lexicographically-largest-valid-sequence) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[组合数学](../combinatorics/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Hard | | 1415 | [长度为 n 的开心字符串中字典序第 k 小的字符串](../../problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | @@ -72,6 +75,7 @@ | 291 | [单词规律 II](../../problems/word-pattern-ii) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 282 | [给表达式添加运算符](../../problems/expression-add-operators) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 254 | [因子的组合](../../problems/factor-combinations) 🔒 | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 216 | [组合总和 III](../../problems/combination-sum-iii) | [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 212 | [单词搜索 II](../../problems/word-search-ii) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[矩阵](../matrix/README.md)] | Hard | diff --git a/tag/binary-indexed-tree/README.md b/tag/binary-indexed-tree/README.md index 350e34ae8..efb68694d 100644 --- a/tag/binary-indexed-tree/README.md +++ b/tag/binary-indexed-tree/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1964 | [找出到每个位置为止最长的有效障碍赛跑路线](../../problems/find-the-longest-valid-obstacle-course-at-each-position) | [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | diff --git a/tag/binary-search-tree/README.md b/tag/binary-search-tree/README.md index 3a558f6de..a52f03e70 100644 --- a/tag/binary-search-tree/README.md +++ b/tag/binary-search-tree/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1902 | [给定二叉搜索树的插入顺序求深度](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1586 | [二叉搜索树迭代器 II](../../problems/binary-search-tree-iterator-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1382 | [将二叉搜索树变平衡](../../problems/balance-a-binary-search-tree) | [[贪心](../greedy/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | diff --git a/tag/binary-search/README.md b/tag/binary-search/README.md index 3205ba91a..9b634cc8e 100644 --- a/tag/binary-search/README.md +++ b/tag/binary-search/README.md @@ -9,6 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2141 | [同时运行 N 台电脑的最长时间](../../problems/maximum-running-time-of-n-computers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2137 | [Pour Water Between Buckets to Make Water Levels Equal](../../problems/pour-water-between-buckets-to-make-water-levels-equal) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | +| 2111 | [使数组 K 递增的最少操作次数](../../problems/minimum-operations-to-make-the-array-k-increasing) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | +| 2106 | [摘水果](../../problems/maximum-fruits-harvested-after-at-most-k-steps) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 2089 | [找出数组排序后的目标下标](../../problems/find-target-indices-after-sorting-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 2070 | [每一个查询的最大美丽值](../../problems/most-beautiful-item-for-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -17,7 +22,7 @@ | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2040 | [两个有序数组的第 K 小乘积](../../problems/kth-smallest-product-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 2024 | [考试的最大困扰度](../../problems/maximize-the-confusion-of-an-exam) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 2009 | [使数组连续的最少操作数](../../problems/minimum-number-of-operations-to-make-array-continuous) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 2008 | [出租车的最大盈利](../../problems/maximum-earnings-from-taxi) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -33,7 +38,7 @@ | 1894 | [找到需要补充粉笔的学生编号](../../problems/find-the-student-that-will-replace-the-chalk) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1891 | [割绳子](../../problems/cutting-ribbons) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1889 | [装包裹的最小浪费空间](../../problems/minimum-space-wasted-from-packaging) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Hard | -| 1885 | [Count Pairs in Two Arrays](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1885 | [统计数对](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 1870 | [准时到达的列车最小时速](../../problems/minimum-speed-to-arrive-on-time) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 1862 | [向下取整数对和](../../problems/sum-of-floored-pairs) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 1855 | [下标对中的最大距离](../../problems/maximum-distance-between-a-pair-of-values) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -104,7 +109,7 @@ | 981 | [基于时间的键值存储](../../problems/time-based-key-value-store) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 911 | [在线选举](../../problems/online-election) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 902 | [最大为 N 的数字组合](../../problems/numbers-at-most-n-given-digit-set) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 888 | [公平的糖果交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 887 | [鸡蛋掉落](../../problems/super-egg-drop) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 878 | [第 N 个神奇数字](../../problems/nth-magical-number) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 875 | [爱吃香蕉的珂珂](../../problems/koko-eating-bananas) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | @@ -161,13 +166,13 @@ | 240 | [搜索二维矩阵 II](../../problems/search-a-2d-matrix-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 222 | [完全二叉树的节点个数](../../problems/count-complete-tree-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 209 | [长度最小的子数组](../../problems/minimum-size-subarray-sum) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | -| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 162 | [寻找峰值](../../problems/find-peak-element) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 154 | [寻找旋转排序数组中的最小值 II](../../problems/find-minimum-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Hard | | 153 | [寻找旋转排序数组中的最小值](../../problems/find-minimum-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 81 | [搜索旋转排序数组 II](../../problems/search-in-rotated-sorted-array-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 74 | [搜索二维矩阵](../../problems/search-a-2d-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 69 | [Sqrt(x)](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 69 | [x 的平方根 ](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 35 | [搜索插入位置](../../problems/search-insert-position) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 34 | [在排序数组中查找元素的第一个和最后一个位置](../../problems/find-first-and-last-position-of-element-in-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 33 | [搜索旋转排序数组](../../problems/search-in-rotated-sorted-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] | Medium | diff --git a/tag/binary-tree/README.md b/tag/binary-tree/README.md index 9cea043e7..3fa30ffc7 100644 --- a/tag/binary-tree/README.md +++ b/tag/binary-tree/README.md @@ -9,9 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2096 | [从二叉树一个节点到另一个节点每一步的方向](../../problems/step-by-step-directions-from-a-binary-tree-node-to-another) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | -| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1902 | [给定二叉搜索树的插入顺序求深度](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1676 | [二叉树的最近公共祖先 IV](../../problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1666 | [改变二叉树的根节点](../../problems/change-the-root-of-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -44,7 +45,7 @@ | 1302 | [层数最深叶子节点的和](../../problems/deepest-leaves-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1261 | [在受污染的二叉树中查找元素](../../problems/find-elements-in-a-contaminated-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -124,7 +125,7 @@ | 285 | [二叉搜索树中的中序后继](../../problems/inorder-successor-in-bst) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -139,11 +140,11 @@ | 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | diff --git a/tag/bit-manipulation/README.md b/tag/bit-manipulation/README.md index f008e795e..aef205ab6 100644 --- a/tag/bit-manipulation/README.md +++ b/tag/bit-manipulation/README.md @@ -9,6 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2172 | [数组的最大与和](../../problems/maximum-and-sum-of-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 2157 | [字符串分组](../../problems/groups-of-strings) | [[位运算](../bit-manipulation/README.md)] [[并查集](../union-find/README.md)] [[字符串](../string/README.md)] | Hard | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2151 | [基于陈述统计最多好人数](../../problems/maximum-good-people-based-on-statements) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2128 | [Remove All Ones With Row and Column Flips](../../problems/remove-all-ones-with-row-and-column-flips) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 2044 | [统计按位或能得到最大值的子集数目](../../problems/count-number-of-maximum-bitwise-or-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | @@ -39,7 +45,7 @@ | 1655 | [分配重复整数](../../problems/distribute-repeating-integers) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1542 | [找出最长的超赞子字符串](../../problems/find-longest-awesome-substring) | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/bitmask/README.md b/tag/bitmask/README.md index 056368cdd..c13f4838e 100644 --- a/tag/bitmask/README.md +++ b/tag/bitmask/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2172 | [数组的最大与和](../../problems/maximum-and-sum-of-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2002 | [两个回文子序列长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-subsequences) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 1994 | [好子集的数目](../../problems/the-number-of-good-subsets) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | diff --git a/tag/breadth-first-search/README.md b/tag/breadth-first-search/README.md index 54cf36cd5..4e9f76243 100644 --- a/tag/breadth-first-search/README.md +++ b/tag/breadth-first-search/README.md @@ -9,8 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | | 2059 | [转化数字的最小运算数](../../problems/minimum-operations-to-convert-number) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] | Medium | -| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | +| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1992 | [找到所有的农场组](../../problems/find-all-groups-of-farmland) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -76,7 +79,7 @@ | 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1197 | [进击的骑士](../../problems/minimum-knight-moves) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1162 | [地图分析](../../problems/as-far-from-land-as-possible) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1129 | [颜色交替的最短路径](../../problems/shortest-path-with-alternating-colors) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1102 | [得分最高的路径](../../problems/path-with-maximum-minimum-value) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | @@ -85,7 +88,7 @@ | 1087 | [花括号展开](../../problems/brace-expansion) 🔒 | [[广度优先搜索](../breadth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1034 | [边界着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1020 | [飞地的数量](../../problems/number-of-enclaves) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 994 | [腐烂的橘子](../../problems/rotting-oranges) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 993 | [二叉树的堂兄弟节点](../../problems/cousins-in-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | @@ -189,8 +192,9 @@ | 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 127 | [单词接龙](../../problems/word-ladder) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 126 | [单词接龙 II](../../problems/word-ladder-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 107 | [二叉树的层序遍历 II](../../problems/binary-tree-level-order-traversal-ii) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | diff --git a/tag/concurrency/README.md b/tag/concurrency/README.md index 6ad20643a..2155bbd8d 100644 --- a/tag/concurrency/README.md +++ b/tag/concurrency/README.md @@ -16,5 +16,5 @@ | 1188 | [设计有限阻塞队列](../../problems/design-bounded-blocking-queue) 🔒 | [[多线程](../concurrency/README.md)] | Medium | | 1117 | [H2O 生成](../../problems/building-h2o) | [[多线程](../concurrency/README.md)] | Medium | | 1116 | [打印零与奇偶数](../../problems/print-zero-even-odd) | [[多线程](../concurrency/README.md)] | Medium | -| 1115 | [交替打印FooBar](../../problems/print-foobar-alternately) | [[多线程](../concurrency/README.md)] | Medium | +| 1115 | [交替打印 FooBar](../../problems/print-foobar-alternately) | [[多线程](../concurrency/README.md)] | Medium | | 1114 | [按序打印](../../problems/print-in-order) | [[多线程](../concurrency/README.md)] | Easy | diff --git a/tag/counting/README.md b/tag/counting/README.md index 111d9c1de..c1807c731 100644 --- a/tag/counting/README.md +++ b/tag/counting/README.md @@ -9,6 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2170 | [使数组变成交替数组的最少操作数](../../problems/minimum-operations-to-make-the-array-alternating) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2150 | [找出数组中的所有孤独数字](../../problems/find-all-lonely-numbers-in-the-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2085 | [统计出现过一次的公共字符串](../../problems/count-common-words-with-one-occurrence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2068 | [检查两个字符串是否几乎相等](../../problems/check-whether-two-strings-are-almost-equivalent) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2067 | [Number of Equal Count Substrings](../../problems/number-of-equal-count-substrings) 🔒 | [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2053 | [数组中第 K 个独一无二的字符串](../../problems/kth-distinct-string-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | @@ -16,6 +22,7 @@ | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2014 | [重复 K 次的最长子序列](../../problems/longest-subsequence-repeated-k-times) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2013 | [检测正方形](../../problems/detect-squares) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2006 | [差的绝对值为 K 的数对数目](../../problems/count-number-of-pairs-with-absolute-difference-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1941 | [检查是否所有字符出现次数相同](../../problems/check-if-all-characters-have-equal-number-of-occurrences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 1940 | [排序数组之间的最长公共子序列](../../problems/longest-common-subsequence-between-sorted-arrays) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | @@ -58,6 +65,7 @@ | 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Easy | | 900 | [RLE 迭代器](../../problems/rle-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 869 | [重新排序得到 2 的幂](../../problems/reordered-power-of-2) | [[数学](../math/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Medium | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | | 767 | [重构字符串](../../problems/reorganize-string) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 692 | [前K个高频单词](../../problems/top-k-frequent-words) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 621 | [任务调度器](../../problems/task-scheduler) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/data-stream/README.md b/tag/data-stream/README.md index 1f6d61328..c7bd52e2a 100644 --- a/tag/data-stream/README.md +++ b/tag/data-stream/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2102 | [序列顺序查询](../../problems/sequentially-ordinal-rank-tracker) | [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] | Medium | | 1656 | [设计有序流](../../problems/design-an-ordered-stream) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] | Easy | | 1500 | [设计文件分享系统](../../problems/design-a-file-sharing-system) 🔒 | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/depth-first-search/README.md b/tag/depth-first-search/README.md index 6174bf935..025044f79 100644 --- a/tag/depth-first-search/README.md +++ b/tag/depth-first-search/README.md @@ -9,6 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2127 | [参加会议的最多员工数](../../problems/maximum-employees-to-be-invited-to-a-meeting) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2097 | [合法重新排列数对](../../problems/valid-arrangement-of-pairs) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | +| 2096 | [从二叉树一个节点到另一个节点每一步的方向](../../problems/step-by-step-directions-from-a-binary-tree-node-to-another) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | | 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1992 | [找到所有的农场组](../../problems/find-all-groups-of-farmland) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -75,6 +80,7 @@ | 1203 | [项目管理](../../problems/sort-items-by-groups-respecting-dependencies) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | | 1202 | [交换字符串中的元素](../../problems/smallest-string-with-swaps) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1192 | [查找集群内的「关键连接」](../../problems/critical-connections-in-a-network) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[双连通分量](../biconnected-component/README.md)] | Hard | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -85,7 +91,7 @@ | 1042 | [不邻接植花](../../problems/flower-planting-with-no-adjacent) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Medium | | 1038 | [把二叉搜索树转换为累加树](../../problems/binary-search-tree-to-greater-sum-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1036 | [逃离大迷宫](../../problems/escape-a-large-maze) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1034 | [边界着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1028 | [从先序遍历还原二叉树](../../problems/recover-a-tree-from-preorder-traversal) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1026 | [节点与其祖先之间的最大差值](../../problems/maximum-difference-between-node-and-ancestor) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1022 | [从根到叶的二进制数之和](../../problems/sum-of-root-to-leaf-binary-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | @@ -208,7 +214,7 @@ | 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | | 261 | [以图判树](../../problems/graph-valid-tree) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Medium | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 235 | [二叉搜索树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-search-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | @@ -227,11 +233,11 @@ | 130 | [被围绕的区域](../../problems/surrounded-regions) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 104 | [二叉树的最大深度](../../problems/maximum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | diff --git a/tag/design/README.md b/tag/design/README.md index e62692267..2dc5e63d6 100644 --- a/tag/design/README.md +++ b/tag/design/README.md @@ -9,10 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2166 | [设计位集](../../problems/design-bitset) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 2102 | [序列顺序查询](../../problems/sequentially-ordinal-rank-tracker) | [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2069 | [模拟行走机器人 II](../../problems/walking-robot-simulation-ii) | [[设计](../design/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | -| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2013 | [检测正方形](../../problems/detect-squares) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | @@ -99,7 +101,7 @@ | 297 | [二叉树的序列化与反序列化](../../problems/serialize-and-deserialize-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 295 | [数据流的中位数](../../problems/find-median-from-data-stream) | [[设计](../design/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 288 | [单词的唯一缩写](../../problems/unique-word-abbreviation) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 284 | [窥探迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 271 | [字符串的编码与解码](../../problems/encode-and-decode-strings) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[迭代器](../iterator/README.md)] | Medium | @@ -111,4 +113,4 @@ | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | | 155 | [最小栈](../../problems/min-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] | Easy | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 146 | [LRU 缓存](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | diff --git a/tag/divide-and-conquer/README.md b/tag/divide-and-conquer/README.md index 6e1eebbbb..e8c6de06d 100644 --- a/tag/divide-and-conquer/README.md +++ b/tag/divide-and-conquer/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1982 | [从子集的和还原数组](../../problems/find-array-given-subset-sums) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] | Hard | | 1901 | [找出顶峰元素 II](../../problems/find-a-peak-element-ii) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -43,6 +43,6 @@ | 108 | [将有序数组转换为二叉搜索树](../../problems/convert-sorted-array-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 106 | [从中序与后序遍历序列构造二叉树](../../problems/construct-binary-tree-from-inorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 105 | [从前序与中序遍历序列构造二叉树](../../problems/construct-binary-tree-from-preorder-and-inorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 53 | [最大子数组和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 23 | [合并K个升序链表](../../problems/merge-k-sorted-lists) | [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 4 | [寻找两个正序数组的中位数](../../problems/median-of-two-sorted-arrays) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] | Hard | diff --git a/tag/doubly-linked-list/README.md b/tag/doubly-linked-list/README.md index 104be93b5..2e57a2202 100644 --- a/tag/doubly-linked-list/README.md +++ b/tag/doubly-linked-list/README.md @@ -15,4 +15,4 @@ | 432 | [全 O(1) 的数据结构](../../problems/all-oone-data-structure) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Hard | | 430 | [扁平化多级双向链表](../../problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | | 426 | [将二叉搜索树转化为排序的双向链表](../../problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 146 | [LRU 缓存](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | diff --git a/tag/dynamic-programming/README.md b/tag/dynamic-programming/README.md index e156b1010..3e539a824 100644 --- a/tag/dynamic-programming/README.md +++ b/tag/dynamic-programming/README.md @@ -9,12 +9,23 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2172 | [数组的最大与和](../../problems/maximum-and-sum-of-array) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | +| 2167 | [移除所有载有违禁货物车厢所需的最少时间](../../problems/minimum-time-to-remove-all-cars-containing-illegal-goods) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2163 | [删除元素后和的最小差值](../../problems/minimum-difference-in-sums-after-removal-of-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2147 | [分隔长廊的方案数](../../problems/number-of-ways-to-divide-a-long-corridor) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2143 | [Choose Numbers From Two Arrays in Range](../../problems/choose-numbers-from-two-arrays-in-range) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2140 | [解决智力问题](../../problems/solving-questions-with-brainpower) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2110 | [股票平滑下跌阶段的数目](../../problems/number-of-smooth-descent-periods-of-a-stock) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2100 | [适合打劫银行的日子](../../problems/find-good-days-to-rob-the-bank) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2088 | [统计农场中肥沃金字塔的数目](../../problems/count-fertile-pyramids-in-a-land) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2086 | [从房屋收集雨水需要的最少水桶数](../../problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2063 | [所有子字符串中的元音](../../problems/vowels-of-all-substrings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | | 2060 | [同源字符串检测](../../problems/check-if-an-original-string-exists-given-two-encoded-strings) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 2052 | [Minimum Cost to Separate Sentence Into Rows](../../problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2052 | [将句子分隔成行的最低成本](../../problems/minimum-cost-to-separate-sentence-into-rows) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2050 | [并行课程 III](../../problems/parallel-courses-iii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 2036 | [Maximum Alternating Subarray Sum](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2036 | [最大交替子数组和](../../problems/maximum-alternating-subarray-sum) 🔒 | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 2008 | [出租车的最大盈利](../../problems/maximum-earnings-from-taxi) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -85,7 +96,7 @@ | 1611 | [使整数变为 0 的最少操作次数](../../problems/minimum-one-bit-operations-to-make-integers-zero) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1595 | [连通两组点的最小成本](../../problems/minimum-cost-to-connect-two-groups-of-points) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[矩阵](../matrix/README.md)] | Hard | | 1594 | [矩阵的最大非负积](../../problems/maximum-non-negative-product-in-a-matrix) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1578 | [使绳子变成彩色的最短时间](../../problems/minimum-time-to-make-rope-colorful) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1575 | [统计所有可行路径](../../problems/count-all-possible-routes) | [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1569 | [将子数组重新排序得到同一个二叉查找树的方案数](../../problems/number-of-ways-to-reorder-array-to-get-same-bst) | [[树](../tree/README.md)] [[并查集](../union-find/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | @@ -237,7 +248,7 @@ | 698 | [划分为k个相等的子集](../../problems/partition-to-k-equal-sum-subsets) | [[位运算](../bit-manipulation/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | | 691 | [贴纸拼词](../../problems/stickers-to-spell-word) | [[位运算](../bit-manipulation/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Hard | | 689 | [三个无重叠子数组的最大和](../../problems/maximum-sum-of-3-non-overlapping-subarrays) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 688 | [“马”在棋盘上的概率](../../problems/knight-probability-in-chessboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | +| 688 | [骑士在棋盘上的概率](../../problems/knight-probability-in-chessboard) | [[动态规划](../dynamic-programming/README.md)] | Medium | | 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 673 | [最长递增子序列的个数](../../problems/number-of-longest-increasing-subsequence) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 664 | [奇怪的打印机](../../problems/strange-printer) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -278,7 +289,7 @@ | 458 | [可怜的小猪](../../problems/poor-pigs) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 446 | [等差数列划分 II - 子序列](../../problems/arithmetic-slices-ii-subsequence) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 435 | [无重叠区间](../../problems/non-overlapping-intervals) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Medium | -| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[模拟](../simulation/README.md)] | Medium | | 416 | [分割等和子集](../../problems/partition-equal-subset-sum) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 413 | [等差数列划分](../../problems/arithmetic-slices) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 410 | [分割数组的最大值](../../problems/split-array-largest-sum) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | @@ -343,7 +354,7 @@ | 63 | [不同路径 II](../../problems/unique-paths-ii) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 62 | [不同路径](../../problems/unique-paths) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | | 55 | [跳跃游戏](../../problems/jump-game) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | -| 53 | [最大子序和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | +| 53 | [最大子数组和](../../problems/maximum-subarray) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | | 45 | [跳跃游戏 II](../../problems/jump-game-ii) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 44 | [通配符匹配](../../problems/wildcard-matching) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 42 | [接雨水](../../problems/trapping-rain-water) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | diff --git a/tag/enumeration/README.md b/tag/enumeration/README.md index cfa2fed90..ff12a4344 100644 --- a/tag/enumeration/README.md +++ b/tag/enumeration/README.md @@ -9,6 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2162 | [设置时间的最少代价](../../problems/minimum-cost-to-set-cooking-time) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Medium | +| 2151 | [基于陈述统计最多好人数](../../problems/maximum-good-people-based-on-statements) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 2122 | [还原原数组](../../problems/recover-the-original-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2094 | [找出 3 位偶数](../../problems/finding-3-digit-even-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Easy | | 2081 | [k 镜像数字的和](../../problems/sum-of-k-mirror-numbers) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2048 | [下一个更大的数值平衡数](../../problems/next-greater-numerically-balanced-number) | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Medium | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | @@ -20,7 +24,7 @@ | 1925 | [统计平方和三元组的数目](../../problems/count-square-sum-triples) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 1620 | [网络信号最好的坐标](../../problems/coordinate-with-maximum-network-quality) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Medium | | 1617 | [统计子树中城市之间最大距离](../../problems/count-subtrees-with-max-distance-between-cities) | [[位运算](../bit-manipulation/README.md)] [[树](../tree/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[枚举](../enumeration/README.md)] | Hard | -| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[枚举](../enumeration/README.md)] | Hard | +| 1601 | [最多可达成的换楼请求数目](../../problems/maximum-number-of-achievable-transfer-requests) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 1566 | [重复至少 K 次且长度为 M 的模式](../../problems/detect-pattern-of-length-m-repeated-k-or-more-times) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 1534 | [统计好三元组](../../problems/count-good-triplets) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] | Easy | | 1291 | [顺次数](../../problems/sequential-digits) | [[枚举](../enumeration/README.md)] | Medium | diff --git a/tag/eulerian-circuit/README.md b/tag/eulerian-circuit/README.md index f48b4407a..a616dce95 100644 --- a/tag/eulerian-circuit/README.md +++ b/tag/eulerian-circuit/README.md @@ -9,5 +9,6 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2097 | [合法重新排列数对](../../problems/valid-arrangement-of-pairs) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | | 753 | [破解保险箱](../../problems/cracking-the-safe) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | | 332 | [重新安排行程](../../problems/reconstruct-itinerary) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | diff --git a/tag/geometry/README.md b/tag/geometry/README.md index 3bb8dcf8f..e2465ee41 100644 --- a/tag/geometry/README.md +++ b/tag/geometry/README.md @@ -9,8 +9,10 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1956 | [感染 K 种病毒所需的最短时间](../../problems/minimum-time-for-k-virus-variants-to-spread) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[枚举](../enumeration/README.md)] | Hard | -| 1924 | [Erect the Fence II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1924 | [安装栅栏 II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1828 | [统计一个圆中点的数目](../../problems/queries-on-number-of-points-inside-a-circle) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 1610 | [可见点的最大数目](../../problems/maximum-number-of-visible-points) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | | 1515 | [服务中心的最佳位置](../../problems/best-position-for-a-service-centre) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] [[随机化](../randomized/README.md)] | Hard | @@ -34,4 +36,4 @@ | 469 | [凸多边形](../../problems/convex-polygon) 🔒 | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | | 335 | [路径交叉](../../problems/self-crossing) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 223 | [矩形面积](../../problems/rectangle-area) | [[几何](../geometry/README.md)] [[数学](../math/README.md)] | Medium | -| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/graph/README.md b/tag/graph/README.md index 2c116d55e..7fb9edbc3 100644 --- a/tag/graph/README.md +++ b/tag/graph/README.md @@ -9,11 +9,18 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2127 | [参加会议的最多员工数](../../problems/maximum-employees-to-be-invited-to-a-meeting) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 2123 | [Minimum Operations to Remove Adjacent Ones in Matrix](../../problems/minimum-operations-to-remove-adjacent-ones-in-matrix) 🔒 | [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2097 | [合法重新排列数对](../../problems/valid-arrangement-of-pairs) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[欧拉回路](../eulerian-circuit/README.md)] | Hard | +| 2093 | [Minimum Cost to Reach City With Discounts](../../problems/minimum-cost-to-reach-city-with-discounts) 🔒 | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Medium | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | | 2077 | [Paths in Maze That Lead to Same Room](../../problems/paths-in-maze-that-lead-to-same-room) 🔒 | [[图](../graph/README.md)] | Medium | | 2076 | [处理含限制条件的好友请求](../../problems/process-restricted-friend-requests) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 2065 | [最大化一张图中的路径价值](../../problems/maximum-path-quality-of-a-graph) | [[图](../graph/README.md)] [[数组](../array/README.md)] [[回溯](../backtracking/README.md)] | Hard | | 2050 | [并行课程 III](../../problems/parallel-courses-iii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | +| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 2039 | [网络空闲的时刻](../../problems/the-time-when-the-network-becomes-idle) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] | Medium | | 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 1971 | [寻找图中是否存在路径](../../problems/find-if-path-exists-in-graph) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] | Easy | diff --git a/tag/greedy/README.md b/tag/greedy/README.md index 0d5ade543..273b006ac 100644 --- a/tag/greedy/README.md +++ b/tag/greedy/README.md @@ -9,6 +9,20 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2170 | [使数组变成交替数组的最少操作数](../../problems/minimum-operations-to-make-the-array-alternating) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2160 | [拆分数位后四位数字的最小和](../../problems/minimum-sum-of-four-digit-number-after-splitting-digits) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2144 | [打折购买糖果的最小开销](../../problems/minimum-cost-of-buying-candies-with-discount) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2141 | [同时运行 N 台电脑的最长时间](../../problems/maximum-running-time-of-n-computers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2139 | [得到目标值的最少行动次数](../../problems/minimum-moves-to-reach-target-score) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 2136 | [全部开花的最早一天](../../problems/earliest-possible-day-of-full-bloom) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2132 | [用邮票贴满网格图](../../problems/stamping-the-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2126 | [摧毁小行星](../../problems/destroying-asteroids) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2116 | [判断一个括号字符串是否有效](../../problems/check-if-a-parentheses-string-can-be-valid) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 2098 | [Subsequence of Size K With the Largest Even Sum](../../problems/subsequence-of-size-k-with-the-largest-even-sum) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2091 | [从数组中移除最大值和最小值](../../problems/removing-minimum-and-maximum-from-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | +| 2087 | [网格图中机器人回家的最小代价](../../problems/minimum-cost-homecoming-of-a-robot-in-a-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2086 | [从房屋收集雨水需要的最少水桶数](../../problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 2078 | [两栋颜色不同且距离最远的房子](../../problems/two-furthest-houses-with-different-colors) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Easy | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 2038 | [如果相邻两个颜色均相同则删除当前颜色](../../problems/remove-colored-pieces-if-both-neighbors-are-the-same-color) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[博弈](../game-theory/README.md)] | Medium | @@ -26,6 +40,7 @@ | 1963 | [使字符串平衡的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-string-balanced) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 1953 | [你可以工作的最大周数](../../problems/maximum-number-of-weeks-for-which-you-can-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1946 | [子字符串突变后可能得到的最大整数](../../problems/largest-number-after-mutating-substring) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | +| 1936 | [新增的最少台阶数](../../problems/add-minimum-number-of-rungs) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] | Medium | | 1927 | [求和游戏](../../problems/sum-game) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1903 | [字符串中的最大奇数](../../problems/largest-odd-number-in-string) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | @@ -78,7 +93,7 @@ | 1589 | [所有排列中的最大和](../../problems/maximum-sum-obtained-of-any-permutation) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | | 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 1580 | [把箱子放进仓库里 II](../../problems/put-boxes-into-the-warehouse-ii) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1578 | [使绳子变成彩色的最短时间](../../problems/minimum-time-to-make-rope-colorful) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1567 | [乘积为正数的最长子数组长度](../../problems/maximum-length-of-subarray-with-positive-product) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1564 | [把箱子放进仓库里 I](../../problems/put-boxes-into-the-warehouse-i) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1561 | [你可以获得的最大硬币数目](../../problems/maximum-number-of-coins-you-can-get) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -87,7 +102,7 @@ | 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1537 | [最大得分](../../problems/get-the-maximum-score) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1536 | [排布二进制网格的最少交换次数](../../problems/minimum-swaps-to-arrange-a-binary-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1529 | [最少的后缀翻转次数](../../problems/minimum-suffix-flips) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1526 | [形成目标数组的子数组最少增加次数](../../problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | | 1509 | [三次操作后最大值与最小值的最小差](../../problems/minimum-difference-between-largest-and-smallest-value-in-three-moves) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -161,7 +176,7 @@ | 846 | [一手顺子](../../problems/hand-of-straights) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | | 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 807 | [保持城市天际线](../../problems/max-increase-to-keep-city-skyline) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 769 | [最多能完成排序的块](../../problems/max-chunks-to-make-sorted) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 768 | [最多能完成排序的块 II](../../problems/max-chunks-to-make-sorted-ii) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 767 | [重构字符串](../../problems/reorganize-string) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/hash-function/README.md b/tag/hash-function/README.md index 7061229ce..15abea6e7 100644 --- a/tag/hash-function/README.md +++ b/tag/hash-function/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2156 | [查找给定哈希值的子串](../../problems/find-substring-with-given-hash-value) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | | 1960 | [两个回文子字符串长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-substrings) | [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | diff --git a/tag/hash-table/README.md b/tag/hash-table/README.md index ac840e676..d0645f16b 100644 --- a/tag/hash-table/README.md +++ b/tag/hash-table/README.md @@ -9,16 +9,35 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2170 | [使数组变成交替数组的最少操作数](../../problems/minimum-operations-to-make-the-array-alternating) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2166 | [设计位集](../../problems/design-bitset) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Medium | +| 2154 | [将找到的值乘以 2](../../problems/keep-multiplying-found-values-by-two) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2150 | [找出数组中的所有孤独数字](../../problems/find-all-lonely-numbers-in-the-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2133 | [检查是否每一行每一列都包含全部整数](../../problems/check-if-every-row-and-column-contains-all-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2122 | [还原原数组](../../problems/recover-the-original-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2121 | [相同元素的间隔之和](../../problems/intervals-between-identical-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 2107 | [Number of Unique Flavors After Sharing K Candies](../../problems/number-of-unique-flavors-after-sharing-k-candies) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2103 | [环和杆](../../problems/rings-and-rods) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 2099 | [找到和最大的长度为 K 的子序列](../../problems/find-subsequence-of-length-k-with-the-largest-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 2094 | [找出 3 位偶数](../../problems/finding-3-digit-even-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2085 | [统计出现过一次的公共字符串](../../problems/count-common-words-with-one-occurrence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 2068 | [检查两个字符串是否几乎相等](../../problems/check-whether-two-strings-are-almost-equivalent) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2062 | [统计字符串中的元音子字符串](../../problems/count-vowel-substrings-of-a-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 2053 | [数组中第 K 个独一无二的字符串](../../problems/kth-distinct-string-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | -| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2032 | [至少在两个数组中出现的值](../../problems/two-out-of-three) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2013 | [检测正方形](../../problems/detect-squares) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Medium | | 2007 | [从双倍数组中还原原数组](../../problems/find-original-array-from-doubled-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2006 | [差的绝对值为 K 的数对数目](../../problems/count-number-of-pairs-with-absolute-difference-k) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] | Easy | | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1948 | [删除系统中的重复文件夹](../../problems/delete-duplicate-folders-in-system) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | @@ -194,7 +213,7 @@ | 893 | [特殊等价字符串组](../../problems/groups-of-special-equivalent-strings) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 890 | [查找和替换模式](../../problems/find-and-replace-pattern) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 889 | [根据前序和后序遍历构造二叉树](../../problems/construct-binary-tree-from-preorder-and-postorder-traversal) | [[树](../tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 888 | [公平的糖果交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 884 | [两句话中的不常见单词](../../problems/uncommon-words-from-two-sentences) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 873 | [最长的斐波那契子序列的长度](../../problems/length-of-longest-fibonacci-subsequence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 865 | [具有所有最深节点的最小子树](../../problems/smallest-subtree-with-all-the-deepest-nodes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -206,11 +225,11 @@ | 819 | [最常见的单词](../../problems/most-common-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 817 | [链表组件](../../problems/linked-list-components) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | | 815 | [公交路线](../../problems/bus-routes) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Hard | -| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | | 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 792 | [匹配子序列的单词数](../../problems/number-of-matching-subsequences) | [[字典树](../trie/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 791 | [自定义字符串排序](../../problems/custom-sort-string) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | -| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 771 | [宝石与石头](../../problems/jewels-and-stones) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | | 767 | [重构字符串](../../problems/reorganize-string) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | @@ -218,12 +237,12 @@ | 760 | [找出变位映射](../../problems/find-anagram-mappings) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] | Easy | | 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | | 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | -| 748 | [最短补全词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 748 | [最短补全词](../../problems/shortest-completing-word) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 740 | [删除并获得点数](../../problems/delete-and-earn) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | | 711 | [不同岛屿的数量 II](../../problems/number-of-distinct-islands-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[哈希表](../hash-table/README.md)] [[哈希函数](../hash-function/README.md)] | Hard | | 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[随机化](../randomized/README.md)] | Hard | @@ -327,8 +346,8 @@ | 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 159 | [至多包含两个不同字符的最长子串](../../problems/longest-substring-with-at-most-two-distinct-characters) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | -| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 146 | [LRU 缓存](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | | 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 141 | [环形链表](../../problems/linked-list-cycle) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 140 | [单词拆分 II](../../problems/word-break-ii) | [[字典树](../trie/README.md)] [[记忆化搜索](../memoization/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] | Hard | diff --git a/tag/heap-priority-queue/README.md b/tag/heap-priority-queue/README.md index c5868632c..04cdd71aa 100644 --- a/tag/heap-priority-queue/README.md +++ b/tag/heap-priority-queue/README.md @@ -9,8 +9,12 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2163 | [删除元素后和的最小差值](../../problems/minimum-difference-in-sums-after-removal-of-elements) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2102 | [序列顺序查询](../../problems/sequentially-ordinal-rank-tracker) | [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 2099 | [找到和最大的长度为 K 的子序列](../../problems/find-subsequence-of-length-k-with-the-largest-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 2015 | [Average Height of Buildings in Each Segment](../../problems/average-height-of-buildings-in-each-segment) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1962 | [移除石子使总数最小](../../problems/remove-stones-to-minimize-the-total) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | @@ -94,7 +98,7 @@ | 420 | [强密码检验器](../../problems/strong-password-checker) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 407 | [接雨水 II](../../problems/trapping-rain-water-ii) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 378 | [有序矩阵中第 K 小的元素](../../problems/kth-smallest-element-in-a-sorted-matrix) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 373 | [查找和最小的K对数字](../../problems/find-k-pairs-with-smallest-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 373 | [查找和最小的 K 对数字](../../problems/find-k-pairs-with-smallest-sums) | [[数组](../array/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 358 | [K 距离间隔重排字符串](../../problems/rearrange-string-k-distance-apart) 🔒 | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 355 | [设计推特](../../problems/design-twitter) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 347 | [前 K 个高频元素](../../problems/top-k-frequent-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数](../counting/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/iterator/README.md b/tag/iterator/README.md index 641c321ca..0b206b29a 100644 --- a/tag/iterator/README.md +++ b/tag/iterator/README.md @@ -14,7 +14,7 @@ | 900 | [RLE 迭代器](../../problems/rle-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[计数](../counting/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 604 | [迭代压缩字符串](../../problems/design-compressed-string-iterator) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[迭代器](../iterator/README.md)] | Easy | | 341 | [扁平化嵌套列表迭代器](../../problems/flatten-nested-list-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[设计](../design/README.md)] [[队列](../queue/README.md)] [[迭代器](../iterator/README.md)] | Medium | -| 284 | [窥探迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | +| 284 | [顶端迭代器](../../problems/peeking-iterator) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 281 | [锯齿迭代器](../../problems/zigzag-iterator) 🔒 | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 251 | [展开二维向量](../../problems/flatten-2d-vector) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[迭代器](../iterator/README.md)] | Medium | | 173 | [二叉搜索树迭代器](../../problems/binary-search-tree-iterator) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[设计](../design/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[迭代器](../iterator/README.md)] | Medium | diff --git a/tag/linked-list/README.md b/tag/linked-list/README.md index c58530bba..9a8521393 100644 --- a/tag/linked-list/README.md +++ b/tag/linked-list/README.md @@ -9,9 +9,11 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2130 | [链表最大孪生和](../../problems/maximum-twin-sum-of-a-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2095 | [删除链表的中间节点](../../problems/delete-the-middle-node-of-a-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 2074 | [反转偶数长度组的节点](../../problems/reverse-nodes-in-even-length-groups) | [[链表](../linked-list/README.md)] | Medium | | 2058 | [找出临界点之间的最小和最大距离](../../problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points) | [[链表](../linked-list/README.md)] | Medium | -| 2046 | [Sort Linked List Already Sorted Using Absolute Values](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2046 | [给按照绝对值排序的链表排序](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 1836 | [从未排序的链表中移除重复元素](../../problems/remove-duplicates-from-an-unsorted-linked-list) 🔒 | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | | 1721 | [交换链表中的节点](../../problems/swapping-nodes-in-a-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 1670 | [设计前中后队列](../../problems/design-front-middle-back-queue) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[链表](../linked-list/README.md)] [[数据流](../data-stream/README.md)] | Medium | @@ -52,11 +54,13 @@ | 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 148 | [排序链表](../../problems/sort-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[分治](../divide-and-conquer/README.md)] [[排序](../sorting/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 147 | [对链表进行插入排序](../../problems/insertion-sort-list) | [[链表](../linked-list/README.md)] [[排序](../sorting/README.md)] | Medium | -| 146 | [LRU 缓存机制](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | +| 146 | [LRU 缓存](../../problems/lru-cache) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] | Medium | | 143 | [重排链表](../../problems/reorder-list) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 142 | [环形链表 II](../../problems/linked-list-cycle-ii) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 141 | [环形链表](../../problems/linked-list-cycle) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | | 138 | [复制带随机指针的链表](../../problems/copy-list-with-random-pointer) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 92 | [反转链表 II](../../problems/reverse-linked-list-ii) | [[链表](../linked-list/README.md)] | Medium | diff --git a/tag/math/README.md b/tag/math/README.md index 053a05c92..da2c17d3e 100644 --- a/tag/math/README.md +++ b/tag/math/README.md @@ -9,6 +9,20 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2169 | [得到 0 的操作数](../../problems/count-operations-to-obtain-zero) | [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2165 | [重排数字的最小值](../../problems/smallest-value-of-the-rearranged-number) | [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2162 | [设置时间的最少代价](../../problems/minimum-cost-to-set-cooking-time) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Medium | +| 2160 | [拆分数位后四位数字的最小和](../../problems/minimum-sum-of-four-digit-number-after-splitting-digits) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2152 | [Minimum Number of Lines to Cover Points](../../problems/minimum-number-of-lines-to-cover-points) 🔒 | [[位运算](../bit-manipulation/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] | Medium | +| 2147 | [分隔长廊的方案数](../../problems/number-of-ways-to-divide-a-long-corridor) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2139 | [得到目标值的最少行动次数](../../problems/minimum-moves-to-reach-target-score) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | +| 2128 | [Remove All Ones With Row and Column Flips](../../problems/remove-all-ones-with-row-and-column-flips) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2125 | [银行中的激光束数量](../../problems/number-of-laser-beams-in-a-bank) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2119 | [反转两次的数字](../../problems/a-number-after-a-double-reversal) | [[数学](../math/README.md)] | Easy | +| 2117 | [一个区间内所有数乘积的缩写](../../problems/abbreviating-the-product-of-a-range) | [[数学](../math/README.md)] | Hard | +| 2110 | [股票平滑下跌阶段的数目](../../problems/number-of-smooth-descent-periods-of-a-stock) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2101 | [引爆最多的炸弹](../../problems/detonate-the-maximum-bombs) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2081 | [k 镜像数字的和](../../problems/sum-of-k-mirror-numbers) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Hard | | 2063 | [所有子字符串中的元音](../../problems/vowels-of-all-substrings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | | 2048 | [下一个更大的数值平衡数](../../problems/next-greater-numerically-balanced-number) | [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] [[枚举](../enumeration/README.md)] | Medium | @@ -27,7 +41,7 @@ | 1952 | [三除数](../../problems/three-divisors) | [[数学](../math/README.md)] | Easy | | 1927 | [求和游戏](../../problems/sum-game) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[博弈](../game-theory/README.md)] | Medium | | 1925 | [统计平方和三元组的数目](../../problems/count-square-sum-triples) | [[数学](../math/README.md)] [[枚举](../enumeration/README.md)] | Easy | -| 1924 | [Erect the Fence II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | +| 1924 | [安装栅栏 II](../../problems/erect-the-fence-ii) 🔒 | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1922 | [统计好数字的数目](../../problems/count-good-numbers) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1908 | [Nim 游戏 II](../../problems/game-of-nim) 🔒 | [[位运算](../bit-manipulation/README.md)] [[脑筋急转弯](../brainteaser/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[博弈](../game-theory/README.md)] | Medium | @@ -45,7 +59,7 @@ | 1835 | [所有数对按位与结果的异或和](../../problems/find-xor-sum-of-all-pairs-bitwise-and) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | | 1830 | [使字符串有序的最少操作次数](../../problems/minimum-number-of-operations-to-make-string-sorted) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | | 1828 | [统计一个圆中点的数目](../../problems/queries-on-number-of-points-inside-a-circle) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1822 | [数组元素积的符号](../../problems/sign-of-the-product-of-an-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Hard | | 1814 | [统计一个数组中好对子的数目](../../problems/count-nice-pairs-in-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] | Medium | @@ -97,7 +111,7 @@ | 1478 | [安排邮筒](../../problems/allocate-mailboxes) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] | Hard | | 1467 | [两个盒子中球的颜色数相同的概率](../../problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[组合数学](../combinatorics/README.md)] [[概率与统计](../probability-and-statistics/README.md)] | Hard | | 1453 | [圆形靶内的最大飞镖数量](../../problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | -| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] | Medium | +| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1442 | [形成两个异或相等数组的三元组数目](../../problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1432 | [改变一个整数能得到的最大差值](../../problems/max-difference-you-can-get-from-changing-an-integer) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] | Medium | | 1427 | [字符串的左右移](../../problems/perform-string-shifts) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | @@ -212,7 +226,7 @@ | 789 | [逃脱阻碍者](../../problems/escape-the-ghosts) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | | 788 | [旋转数字](../../problems/rotated-digits) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 782 | [变为棋盘](../../problems/transform-to-chessboard) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Hard | -| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | +| 781 | [森林中的兔子](../../problems/rabbits-in-forest) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Medium | | 780 | [到达终点](../../problems/reaching-points) | [[数学](../math/README.md)] | Hard | | 779 | [第K个语法符号](../../problems/k-th-symbol-in-grammar) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 775 | [全局倒置与局部倒置](../../problems/global-and-local-inversions) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | @@ -293,7 +307,7 @@ | 343 | [整数拆分](../../problems/integer-break) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 342 | [4的幂](../../problems/power-of-four) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | | 335 | [路径交叉](../../problems/self-crossing) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Hard | -| 326 | [3的幂](../../problems/power-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | +| 326 | [3 的幂](../../problems/power-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | | 319 | [灯泡开关](../../problems/bulb-switcher) | [[脑筋急转弯](../brainteaser/README.md)] [[数学](../math/README.md)] | Medium | | 313 | [超级丑数](../../problems/super-ugly-number) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 296 | [最佳的碰头地点](../../problems/best-meeting-point) 🔒 | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Hard | @@ -320,11 +334,11 @@ | 168 | [Excel表列名称](../../problems/excel-sheet-column-title) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 166 | [分数到小数](../../problems/fraction-to-recurring-decimal) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 150 | [逆波兰表达式求值](../../problems/evaluate-reverse-polish-notation) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] | Medium | -| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | +| 149 | [直线上最多的点数](../../problems/max-points-on-a-line) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] | Hard | | 96 | [不同的二叉搜索树](../../problems/unique-binary-search-trees) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 89 | [格雷编码](../../problems/gray-code) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 70 | [爬楼梯](../../problems/climbing-stairs) | [[记忆化搜索](../memoization/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] | Easy | -| 69 | [Sqrt(x)](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 69 | [x 的平方根 ](../../problems/sqrtx) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] | Easy | | 67 | [二进制求和](../../problems/add-binary) | [[位运算](../bit-manipulation/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 66 | [加一](../../problems/plus-one) | [[数组](../array/README.md)] [[数学](../math/README.md)] | Easy | | 62 | [不同路径](../../problems/unique-paths) | [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Medium | @@ -336,5 +350,5 @@ | 13 | [罗马数字转整数](../../problems/roman-to-integer) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Easy | | 12 | [整数转罗马数字](../../problems/integer-to-roman) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 9 | [回文数](../../problems/palindrome-number) | [[数学](../math/README.md)] | Easy | -| 7 | [整数反转](../../problems/reverse-integer) | [[数学](../math/README.md)] | Easy | +| 7 | [整数反转](../../problems/reverse-integer) | [[数学](../math/README.md)] | Medium | | 2 | [两数相加](../../problems/add-two-numbers) | [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[数学](../math/README.md)] | Medium | diff --git a/tag/matrix/README.md b/tag/matrix/README.md index f1af6860d..8b27d5128 100644 --- a/tag/matrix/README.md +++ b/tag/matrix/README.md @@ -9,7 +9,15 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2061 | [Number of Spaces Cleaning Robot Cleaned](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2133 | [检查是否每一行每一列都包含全部整数](../../problems/check-if-every-row-and-column-contains-all-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Easy | +| 2132 | [用邮票贴满网格图](../../problems/stamping-the-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2128 | [Remove All Ones With Row and Column Flips](../../problems/remove-all-ones-with-row-and-column-flips) 🔒 | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2125 | [银行中的激光束数量](../../problems/number-of-laser-beams-in-a-bank) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2123 | [Minimum Operations to Remove Adjacent Ones in Matrix](../../problems/minimum-operations-to-remove-adjacent-ones-in-matrix) 🔒 | [[图](../graph/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2088 | [统计农场中肥沃金字塔的数目](../../problems/count-fertile-pyramids-in-a-land) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] | Hard | +| 2087 | [网格图中机器人回家的最小代价](../../problems/minimum-cost-homecoming-of-a-robot-in-a-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2061 | [扫地机器人清扫过的空间个数](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | | 2022 | [将一维数组转变成二维数组](../../problems/convert-1d-array-into-2d-array) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | | 2018 | [判断单词是否能放入填字游戏内](../../problems/check-if-word-can-be-placed-in-crossword) | [[数组](../array/README.md)] [[枚举](../enumeration/README.md)] [[矩阵](../matrix/README.md)] | Medium | @@ -81,7 +89,7 @@ | 1091 | [二进制矩阵中的最短路径](../../problems/shortest-path-in-binary-matrix) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1074 | [元素和为目标值的子矩阵数量](../../problems/number-of-submatrices-that-sum-to-target) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 1072 | [按列翻转得到最大值等行数](../../problems/flip-columns-for-maximum-number-of-equal-rows) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[矩阵](../matrix/README.md)] | Medium | -| 1034 | [边框着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 1034 | [边界着色](../../problems/coloring-a-border) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 1030 | [距离顺序排列矩阵单元格](../../problems/matrix-cells-in-distance-order) | [[几何](../geometry/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Easy | | 1020 | [飞地的数量](../../problems/number-of-enclaves) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] | Medium | | 999 | [可以被一步捕获的棋子数](../../problems/available-captures-for-rook) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Easy | diff --git a/tag/merge-sort/README.md b/tag/merge-sort/README.md index 87b8fff12..81df28808 100644 --- a/tag/merge-sort/README.md +++ b/tag/merge-sort/README.md @@ -9,7 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 912 | [排序数组](../../problems/sort-an-array) | [[数组](../array/README.md)] [[分治](../divide-and-conquer/README.md)] [[桶排序](../bucket-sort/README.md)] [[计数排序](../counting-sort/README.md)] [[基数排序](../radix-sort/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 493 | [翻转对](../../problems/reverse-pairs) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | diff --git a/tag/monotonic-stack/README.md b/tag/monotonic-stack/README.md index 69ccccc69..b609198b4 100644 --- a/tag/monotonic-stack/README.md +++ b/tag/monotonic-stack/README.md @@ -9,6 +9,7 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2104 | [子数组范围和](../../problems/sum-of-subarray-ranges) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 2030 | [含特定字母的最小子序列](../../problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1950 | [所有子数组最小值中的最大值](../../problems/maximum-of-minimum-values-in-all-subarrays) 🔒 | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | @@ -32,6 +33,7 @@ | 962 | [最大宽度坡](../../problems/maximum-width-ramp) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 907 | [子数组的最小值之和](../../problems/sum-of-subarray-minimums) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 901 | [股票价格跨度](../../problems/online-stock-span) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | +| 853 | [车队](../../problems/car-fleet) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 769 | [最多能完成排序的块](../../problems/max-chunks-to-make-sorted) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 768 | [最多能完成排序的块 II](../../problems/max-chunks-to-make-sorted-ii) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | diff --git a/tag/number-theory/README.md b/tag/number-theory/README.md index 47d79b04e..07cf48872 100644 --- a/tag/number-theory/README.md +++ b/tag/number-theory/README.md @@ -12,6 +12,7 @@ | 2001 | [可互换矩形的组数](../../problems/number-of-pairs-of-interchangeable-rectangles) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1819 | [序列中不同最大公约数的数目](../../problems/number-of-different-subsequences-gcds) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Hard | | 1799 | [N 次操作后的最大分数和](../../problems/maximize-score-after-n-operations) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[回溯](../backtracking/README.md)] [[状态压缩](../bitmask/README.md)] [[数论](../number-theory/README.md)] | Hard | +| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1250 | [检查「好数组」](../../problems/check-if-it-is-a-good-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[数论](../number-theory/README.md)] | Hard | | 1201 | [丑数 III](../../problems/ugly-number-iii) | [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[数论](../number-theory/README.md)] | Medium | | 914 | [卡牌分组](../../problems/x-of-a-kind-in-a-deck-of-cards) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[计数](../counting/README.md)] [[数论](../number-theory/README.md)] | Easy | diff --git a/tag/ordered-set/README.md b/tag/ordered-set/README.md index 7665f8456..45db4a2aa 100644 --- a/tag/ordered-set/README.md +++ b/tag/ordered-set/README.md @@ -9,13 +9,15 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2158 | [Amount of New Area Painted Each Day](../../problems/amount-of-new-area-painted-each-day) 🔒 | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | +| 2102 | [序列顺序查询](../../problems/sequentially-ordinal-rank-tracker) | [[设计](../design/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | -| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | -| 2021 | [Brightest Position on Street](../../problems/brightest-position-on-street) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2034 | [股票价格波动](../../problems/stock-price-fluctuation) | [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[数据流](../data-stream/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2021 | [街上最亮的位置](../../problems/brightest-position-on-street) 🔒 | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1942 | [最小未被占据椅子的编号](../../problems/the-number-of-the-smallest-unoccupied-chair) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1912 | [设计电影租借系统](../../problems/design-movie-rental-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1902 | [给定二叉搜索树的插入顺序求深度](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1818 | [绝对差值和](../../problems/minimum-absolute-sum-difference) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[有序集合](../ordered-set/README.md)] [[排序](../sorting/README.md)] | Medium | | 1756 | [设计最近使用(MRU)队列](../../problems/design-most-recently-used-queue) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[树状数组](../binary-indexed-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | diff --git a/tag/prefix-sum/README.md b/tag/prefix-sum/README.md index 82e3e9c76..07ca36a90 100644 --- a/tag/prefix-sum/README.md +++ b/tag/prefix-sum/README.md @@ -9,11 +9,18 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2171 | [拿出最少数目的魔法豆](../../problems/removing-minimum-number-of-magic-beans) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2145 | [统计隐藏数组数目](../../problems/count-the-hidden-sequences) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2132 | [用邮票贴满网格图](../../problems/stamping-the-grid) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | +| 2121 | [相同元素的间隔之和](../../problems/intervals-between-identical-elements) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2106 | [摘水果](../../problems/maximum-fruits-harvested-after-at-most-k-steps) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 2100 | [适合打劫银行的日子](../../problems/find-good-days-to-rob-the-bank) | [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2067 | [Number of Equal Count Substrings](../../problems/number-of-equal-count-substrings) 🔒 | [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2055 | [蜡烛之间的盘子](../../problems/plates-between-candles) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2025 | [分割数组的最多方案数](../../problems/maximum-number-of-ways-to-partition-an-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[前缀和](../prefix-sum/README.md)] | Hard | | 2024 | [考试的最大困扰度](../../problems/maximize-the-confusion-of-an-exam) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | -| 2021 | [Brightest Position on Street](../../problems/brightest-position-on-street) | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | +| 2021 | [街上最亮的位置](../../problems/brightest-position-on-street) 🔒 | [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2017 | [网格游戏](../../problems/grid-game) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 1991 | [找到数组的中间位置](../../problems/find-the-middle-index-in-array) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Easy | | 1943 | [描述绘画结果](../../problems/describe-the-painting) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | diff --git a/tag/queue/README.md b/tag/queue/README.md index d76a040d3..2db4c7d3d 100644 --- a/tag/queue/README.md +++ b/tag/queue/README.md @@ -12,6 +12,7 @@ | 2073 | [买票需要的时间](../../problems/time-needed-to-buy-tickets) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 1825 | [求出 MK 平均值](../../problems/finding-mk-average) | [[设计](../design/README.md)] [[队列](../queue/README.md)] [[有序集合](../ordered-set/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1700 | [无法吃午餐的学生数量](../../problems/number-of-students-unable-to-eat-lunch) | [[栈](../stack/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 1696 | [跳跃游戏 VI](../../problems/jump-game-vi) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | diff --git a/tag/recursion/README.md b/tag/recursion/README.md index 9e3769198..c6113caa1 100644 --- a/tag/recursion/README.md +++ b/tag/recursion/README.md @@ -11,7 +11,7 @@ | :-: | - | - | :-: | | 1969 | [数组元素的最小非零乘积](../../problems/minimum-non-zero-product-of-the-array-elements) | [[贪心](../greedy/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | | 1922 | [统计好数字的数目](../../problems/count-good-numbers) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Medium | -| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1808 | [好因子的最大数目](../../problems/maximize-number-of-nice-divisors) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Hard | | 1545 | [找出第 N 个二进制字符串中的第 K 位](../../problems/find-kth-bit-in-nth-binary-string) | [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | | 1265 | [逆序打印不可变链表](../../problems/print-immutable-linked-list-in-reverse) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | @@ -30,7 +30,7 @@ | 394 | [字符串解码](../../problems/decode-string) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[字符串](../string/README.md)] | Medium | | 344 | [反转字符串](../../problems/reverse-string) | [[递归](../recursion/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 342 | [4的幂](../../problems/power-of-four) | [[位运算](../bit-manipulation/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | -| 326 | [3的幂](../../problems/power-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | +| 326 | [3 的幂](../../problems/power-of-three) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] | Easy | | 273 | [整数转换英文表示](../../problems/integer-to-english-words) | [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | | 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | diff --git a/tag/rolling-hash/README.md b/tag/rolling-hash/README.md index 85629bdc3..929c4e240 100644 --- a/tag/rolling-hash/README.md +++ b/tag/rolling-hash/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2156 | [查找给定哈希值的子串](../../problems/find-substring-with-given-hash-value) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | | 1960 | [两个回文子字符串长度的最大乘积](../../problems/maximum-product-of-the-length-of-two-palindromic-substrings) | [[字符串](../string/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1923 | [最长公共子路径](../../problems/longest-common-subpath) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Hard | | 1698 | [字符串的不同子字符串个数](../../problems/number-of-distinct-substrings-in-a-string) 🔒 | [[字典树](../trie/README.md)] [[字符串](../string/README.md)] [[后缀数组](../suffix-array/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | diff --git a/tag/segment-tree/README.md b/tag/segment-tree/README.md index 872832452..d15fa7dfa 100644 --- a/tag/segment-tree/README.md +++ b/tag/segment-tree/README.md @@ -9,8 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2158 | [Amount of New Area Painted Each Day](../../problems/amount-of-new-area-painted-each-day) 🔒 | [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2080 | [区间内查询数字的频率](../../problems/range-frequency-queries) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] | Medium | -| 2031 | [Count Subarrays With More Ones Than Zeros](../../problems/count-subarrays-with-more-ones-than-zeros) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | +| 2031 | [1 比 0 多的子数组个数](../../problems/count-subarrays-with-more-ones-than-zeros) 🔒 | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Medium | | 1687 | [从仓库到码头运输箱子](../../problems/delivering-boxes-from-storage-to-ports) | [[线段树](../segment-tree/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[单调队列](../monotonic-queue/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 1649 | [通过指令创建有序数组](../../problems/create-sorted-array-through-instructions) | [[树状数组](../binary-indexed-tree/README.md)] [[线段树](../segment-tree/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[分治](../divide-and-conquer/README.md)] [[有序集合](../ordered-set/README.md)] [[归并排序](../merge-sort/README.md)] | Hard | | 1622 | [奇妙序列](../../problems/fancy-sequence) | [[设计](../design/README.md)] [[线段树](../segment-tree/README.md)] [[数学](../math/README.md)] | Hard | diff --git a/tag/shortest-path/README.md b/tag/shortest-path/README.md index a1cacef5d..09e0f7c25 100644 --- a/tag/shortest-path/README.md +++ b/tag/shortest-path/README.md @@ -9,7 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[数组](../array/README.md)] [[最短路](../shortest-path/README.md)] | Hard | +| 2093 | [Minimum Cost to Reach City With Discounts](../../problems/minimum-cost-to-reach-city-with-discounts) 🔒 | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Medium | +| 2045 | [到达目的地的第二短时间](../../problems/second-minimum-time-to-reach-destination) | [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] | Hard | | 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 1786 | [从第一个节点出发到最后一个节点的受限路径数](../../problems/number-of-restricted-paths-from-first-to-last-node) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1514 | [概率最大的路径](../../problems/path-with-maximum-probability) | [[图](../graph/README.md)] [[最短路](../shortest-path/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | diff --git a/tag/simulation/README.md b/tag/simulation/README.md index de5ff39b9..06983fe1f 100644 --- a/tag/simulation/README.md +++ b/tag/simulation/README.md @@ -9,10 +9,18 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2169 | [得到 0 的操作数](../../problems/count-operations-to-obtain-zero) | [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2161 | [根据给定数字划分数组](../../problems/partition-array-according-to-given-pivot) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2154 | [将找到的值乘以 2](../../problems/keep-multiplying-found-values-by-two) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2149 | [按符号重排数组](../../problems/rearrange-array-elements-by-sign) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2138 | [将字符串拆分为若干长度为 k 的组](../../problems/divide-a-string-into-groups-of-size-k) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2120 | [执行所有后缀指令](../../problems/execution-of-all-suffix-instructions-staying-in-a-grid) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2109 | [向字符串添加空格](../../problems/adding-spaces-to-a-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2105 | [给植物浇水 II](../../problems/watering-plants-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2075 | [解码斜向换位密码](../../problems/decode-the-slanted-ciphertext) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2073 | [买票需要的时间](../../problems/time-needed-to-buy-tickets) | [[队列](../queue/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 2069 | [模拟行走机器人 II](../../problems/walking-robot-simulation-ii) | [[设计](../design/README.md)] [[模拟](../simulation/README.md)] | Medium | -| 2061 | [Number of Spaces Cleaning Robot Cleaned](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2061 | [扫地机器人清扫过的空间个数](../../problems/number-of-spaces-cleaning-robot-cleaned) 🔒 | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2056 | [棋盘上有效移动组合的数目](../../problems/number-of-valid-move-combinations-on-chessboard) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[模拟](../simulation/README.md)] | Hard | | 2043 | [简易银行系统](../../problems/simple-bank-system) | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2028 | [找出缺失的观测数据](../../problems/find-missing-observations) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | @@ -23,7 +31,7 @@ | 1914 | [循环轮转矩阵](../../problems/cyclically-rotating-a-grid) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1894 | [找到需要补充粉笔的学生编号](../../problems/find-the-student-that-will-replace-the-chalk) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1860 | [增长的内存泄露](../../problems/incremental-memory-leak) | [[模拟](../simulation/README.md)] | Medium | -| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 1823 | [找出游戏的获胜者](../../problems/find-the-winner-of-the-circular-game) | [[递归](../recursion/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1806 | [还原排列的最少操作步数](../../problems/minimum-number-of-operations-to-reinitialize-a-permutation) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[模拟](../simulation/README.md)] | Medium | | 1801 | [积压订单中的订单总数](../../problems/number-of-orders-in-the-backlog) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1706 | [球会落何处](../../problems/where-will-the-ball-fall) | [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[动态规划](../dynamic-programming/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | @@ -74,6 +82,7 @@ | 537 | [复数乘法](../../problems/complex-number-multiplication) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | | 498 | [对角线遍历](../../problems/diagonal-traverse) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | | 495 | [提莫攻击](../../problems/teemo-attacking) | [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[模拟](../simulation/README.md)] | Medium | | 415 | [字符串相加](../../problems/add-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 412 | [Fizz Buzz](../../problems/fizz-buzz) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 289 | [生命游戏](../../problems/game-of-life) | [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[模拟](../simulation/README.md)] | Medium | diff --git a/tag/sliding-window/README.md b/tag/sliding-window/README.md index 888c73f17..c77329490 100644 --- a/tag/sliding-window/README.md +++ b/tag/sliding-window/README.md @@ -9,7 +9,13 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2156 | [查找给定哈希值的子串](../../problems/find-substring-with-given-hash-value) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2134 | [最少交换次数来组合所有的 1 II](../../problems/minimum-swaps-to-group-all-1s-together-ii) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2107 | [Number of Unique Flavors After Sharing K Candies](../../problems/number-of-unique-flavors-after-sharing-k-candies) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 2106 | [摘水果](../../problems/maximum-fruits-harvested-after-at-most-k-steps) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | +| 2090 | [半径为 k 的子数组平均值](../../problems/k-radius-subarray-averages) | [[数组](../array/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 2024 | [考试的最大困扰度](../../problems/maximize-the-confusion-of-an-exam) | [[字符串](../string/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | +| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1918 | [第 K 小的子数组和·](../../problems/kth-smallest-subarray-sum) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 1876 | [长度为三且各字符不同的子字符串](../../problems/substrings-of-size-three-with-distinct-characters) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1852 | [每个子数组的数字种类数](../../problems/distinct-numbers-in-each-subarray) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | diff --git a/tag/sorting/README.md b/tag/sorting/README.md index 1e795d316..0ac1e9083 100644 --- a/tag/sorting/README.md +++ b/tag/sorting/README.md @@ -9,10 +9,28 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2171 | [拿出最少数目的魔法豆](../../problems/removing-minimum-number-of-magic-beans) | [[数组](../array/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2165 | [重排数字的最小值](../../problems/smallest-value-of-the-rearranged-number) | [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2164 | [对奇偶下标分别排序](../../problems/sort-even-and-odd-indices-independently) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2160 | [拆分数位后四位数字的最小和](../../problems/minimum-sum-of-four-digit-number-after-splitting-digits) | [[贪心](../greedy/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2154 | [将找到的值乘以 2](../../problems/keep-multiplying-found-values-by-two) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2148 | [元素计数](../../problems/count-elements-with-strictly-smaller-and-greater-elements) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2146 | [价格范围内最高排名的 K 样物品](../../problems/k-highest-ranked-items-within-a-price-range) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | +| 2144 | [打折购买糖果的最小开销](../../problems/minimum-cost-of-buying-candies-with-discount) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2141 | [同时运行 N 台电脑的最长时间](../../problems/maximum-running-time-of-n-computers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2136 | [全部开花的最早一天](../../problems/earliest-possible-day-of-full-bloom) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2126 | [摧毁小行星](../../problems/destroying-asteroids) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2122 | [还原原数组](../../problems/recover-the-original-array) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2099 | [找到和最大的长度为 K 的子序列](../../problems/find-subsequence-of-length-k-with-the-largest-sum) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Easy | +| 2098 | [Subsequence of Size K With the Largest Even Sum](../../problems/subsequence-of-size-k-with-the-largest-even-sum) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2094 | [找出 3 位偶数](../../problems/finding-3-digit-even-numbers) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Easy | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | +| 2089 | [找出数组排序后的目标下标](../../problems/find-target-indices-after-sorting-array) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 2071 | [你可以安排的最多任务数目](../../problems/maximum-number-of-tasks-you-can-assign) | [[贪心](../greedy/README.md)] [[队列](../queue/README.md)] [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[单调队列](../monotonic-queue/README.md)] | Hard | | 2070 | [每一个查询的最大美丽值](../../problems/most-beautiful-item-for-each-query) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 2054 | [两个最好的不重叠活动](../../problems/two-best-non-overlapping-events) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 2046 | [Sort Linked List Already Sorted Using Absolute Values](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2046 | [给按照绝对值排序的链表排序](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 2037 | [使每位学生都有座位的最少移动次数](../../problems/minimum-number-of-moves-to-seat-everyone) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 2033 | [获取单值网格的最小操作数](../../problems/minimum-operations-to-make-a-uni-value-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[排序](../sorting/README.md)] | Medium | | 2015 | [Average Height of Buildings in Each Segment](../../problems/average-height-of-buildings-in-each-segment) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | @@ -21,13 +39,13 @@ | 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | | 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 1985 | [找出数组中的第 K 大整数](../../problems/find-the-kth-largest-integer-in-the-array) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[分治](../divide-and-conquer/README.md)] [[快速选择](../quickselect/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | -| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 1984 | [学生分数的最小差值](../../problems/minimum-difference-between-highest-and-lowest-of-k-scores) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[滑动窗口](../sliding-window/README.md)] | Easy | | 1968 | [构造元素不等于两相邻元素平均值的数组](../../problems/array-with-elements-not-equal-to-average-of-neighbors) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1921 | [消灭怪物的最大数量](../../problems/eliminate-maximum-number-of-monsters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 1913 | [两个数对之间的最大乘积差](../../problems/maximum-product-difference-between-two-pairs) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | | 1889 | [装包裹的最小浪费空间](../../problems/minimum-space-wasted-from-packaging) | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] | Hard | | 1887 | [使数组元素相等的减少操作次数](../../problems/reduction-operations-to-make-the-array-elements-equal) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | -| 1885 | [Count Pairs in Two Arrays](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1885 | [统计数对](../../problems/count-pairs-in-two-arrays) 🔒 | [[数组](../array/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | | 1878 | [矩阵中最大的三个菱形和](../../problems/get-biggest-three-rhombus-sums-in-a-grid) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[矩阵](../matrix/README.md)] [[前缀和](../prefix-sum/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Medium | | 1877 | [数组中最大数对和的最小值](../../problems/minimize-maximum-pair-sum-in-array) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 1874 | [两个数组的最小乘积和](../../problems/minimize-product-sum-of-two-arrays) 🔒 | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -140,12 +158,12 @@ | 905 | [按奇偶排序数组](../../problems/sort-array-by-parity) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Easy | | 899 | [有序队列](../../problems/orderly-queue) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 891 | [子序列宽度之和](../../problems/sum-of-subsequence-widths) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard | -| 888 | [公平的糖果棒交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | +| 888 | [公平的糖果交换](../../problems/fair-candy-swap) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Easy | | 881 | [救生艇](../../problems/boats-to-save-people) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 870 | [优势洗牌](../../problems/advantage-shuffle) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | | 869 | [重新排序得到 2 的幂](../../problems/reordered-power-of-2) | [[数学](../math/README.md)] [[计数](../counting/README.md)] [[枚举](../enumeration/README.md)] [[排序](../sorting/README.md)] | Medium | | 857 | [雇佣 K 名工人的最低成本](../../problems/minimum-cost-to-hire-k-workers) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 853 | [车队](../../problems/car-fleet) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Medium | +| 853 | [车队](../../problems/car-fleet) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 846 | [一手顺子](../../problems/hand-of-straights) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[排序](../sorting/README.md)] | Medium | | 833 | [字符串中的查找与替换](../../problems/find-and-replace-in-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | | 826 | [安排工作以达到最大收益](../../problems/most-profit-assigning-work) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -158,6 +176,7 @@ | 759 | [员工空闲时间](../../problems/employee-free-time) 🔒 | [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 757 | [设置交集大小至少为2](../../problems/set-intersection-size-at-least-two) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Hard | | 747 | [至少是其他数字两倍的最大数](../../problems/largest-number-at-least-twice-of-others) | [[数组](../array/README.md)] [[排序](../sorting/README.md)] | Easy | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | | 719 | [找出第 k 小的距离对](../../problems/find-k-th-smallest-pair-distance) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] | Hard | | 710 | [黑名单中的随机数](../../problems/random-pick-with-blacklist) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[二分查找](../binary-search/README.md)] [[排序](../sorting/README.md)] [[随机化](../randomized/README.md)] | Hard | diff --git a/tag/stack/README.md b/tag/stack/README.md index 7fe784c89..fa5f7a7cd 100644 --- a/tag/stack/README.md +++ b/tag/stack/README.md @@ -9,6 +9,9 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2130 | [链表最大孪生和](../../problems/maximum-twin-sum-of-a-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2116 | [判断一个括号字符串是否有效](../../problems/check-if-a-parentheses-string-can-be-valid) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 2104 | [子数组范围和](../../problems/sum-of-subarray-ranges) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 2030 | [含特定字母的最小子序列](../../problems/smallest-k-length-subsequence-with-occurrences-of-a-letter) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[单调栈](../monotonic-stack/README.md)] | Hard | | 2019 | [解出数学表达式的学生分数](../../problems/the-score-of-students-solving-math-expression) | [[栈](../stack/README.md)] [[记忆化搜索](../memoization/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1996 | [游戏中弱角色的数量](../../problems/the-number-of-weak-characters-in-the-game) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | @@ -69,6 +72,7 @@ | 895 | [最大频率栈](../../problems/maximum-frequency-stack) | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 880 | [索引处的解码字符串](../../problems/decoded-string-at-index) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | | 856 | [括号的分数](../../problems/score-of-parentheses) | [[栈](../stack/README.md)] [[字符串](../string/README.md)] | Medium | +| 853 | [车队](../../problems/car-fleet) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[排序](../sorting/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 844 | [比较含退格的字符串](../../problems/backspace-string-compare) | [[栈](../stack/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 772 | [基本计算器 III](../../problems/basic-calculator-iii) 🔒 | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | | 770 | [基本计算器 IV](../../problems/basic-calculator-iv) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Hard | @@ -77,7 +81,7 @@ | 739 | [每日温度](../../problems/daily-temperatures) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 735 | [行星碰撞](../../problems/asteroid-collision) | [[栈](../stack/README.md)] [[数组](../array/README.md)] | Medium | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 716 | [最大栈](../../problems/max-stack) 🔒 | [[栈](../stack/README.md)] [[设计](../design/README.md)] [[链表](../linked-list/README.md)] [[双向链表](../doubly-linked-list/README.md)] [[有序集合](../ordered-set/README.md)] | Easy | | 682 | [棒球比赛](../../problems/baseball-game) | [[栈](../stack/README.md)] [[数组](../array/README.md)] [[模拟](../simulation/README.md)] | Easy | | 678 | [有效的括号字符串](../../problems/valid-parenthesis-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | diff --git a/tag/string/README.md b/tag/string/README.md index f61110315..0a015eeb0 100644 --- a/tag/string/README.md +++ b/tag/string/README.md @@ -9,6 +9,28 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2168 | [Unique Substrings With Equal Digit Frequency](../../problems/unique-substrings-with-equal-digit-frequency) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2167 | [移除所有载有违禁货物车厢所需的最少时间](../../problems/minimum-time-to-remove-all-cars-containing-illegal-goods) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2157 | [字符串分组](../../problems/groups-of-strings) | [[位运算](../bit-manipulation/README.md)] [[并查集](../union-find/README.md)] [[字符串](../string/README.md)] | Hard | +| 2156 | [查找给定哈希值的子串](../../problems/find-substring-with-given-hash-value) | [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] [[哈希函数](../hash-function/README.md)] [[滚动哈希](../rolling-hash/README.md)] | Medium | +| 2147 | [分隔长廊的方案数](../../problems/number-of-ways-to-divide-a-long-corridor) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | +| 2138 | [将字符串拆分为若干长度为 k 的组](../../problems/divide-a-string-into-groups-of-size-k) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | +| 2135 | [统计追加字母可以获得的单词数](../../problems/count-words-obtained-after-adding-a-letter) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2131 | [连接两字母单词得到的最长回文串](../../problems/longest-palindrome-by-concatenating-two-letter-words) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | +| 2129 | [将标题首字母大写](../../problems/capitalize-the-title) | [[字符串](../string/README.md)] | Easy | +| 2125 | [银行中的激光束数量](../../problems/number-of-laser-beams-in-a-bank) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[矩阵](../matrix/README.md)] | Medium | +| 2124 | [检查是否所有 A 都在 B 之前](../../problems/check-if-all-as-appears-before-all-bs) | [[字符串](../string/README.md)] | Easy | +| 2120 | [执行所有后缀指令](../../problems/execution-of-all-suffix-instructions-staying-in-a-grid) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2116 | [判断一个括号字符串是否有效](../../problems/check-if-a-parentheses-string-can-be-valid) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 2114 | [句子中的最多单词数](../../problems/maximum-number-of-words-found-in-sentences) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | +| 2109 | [向字符串添加空格](../../problems/adding-spaces-to-a-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2108 | [找出数组中的第一个回文字符串](../../problems/find-first-palindromic-string-in-the-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 2103 | [环和杆](../../problems/rings-and-rods) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 2096 | [从二叉树一个节点到另一个节点每一步的方向](../../problems/step-by-step-directions-from-a-binary-tree-node-to-another) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 2086 | [从房屋收集雨水需要的最少水桶数](../../problems/minimum-number-of-buckets-required-to-collect-rainwater-from-houses) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 2085 | [统计出现过一次的公共字符串](../../problems/count-common-words-with-one-occurrence) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | +| 2083 | [求以相同字母开头和结尾的子串总数](../../problems/substrings-that-begin-and-end-with-the-same-letter) 🔒 | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | | 2075 | [解码斜向换位密码](../../problems/decode-the-slanted-ciphertext) | [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Medium | | 2068 | [检查两个字符串是否几乎相等](../../problems/check-whether-two-strings-are-almost-equivalent) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Easy | | 2067 | [Number of Equal Count Substrings](../../problems/number-of-equal-count-substrings) 🔒 | [[字符串](../string/README.md)] [[计数](../counting/README.md)] [[前缀和](../prefix-sum/README.md)] | Medium | @@ -122,7 +144,7 @@ | 1593 | [拆分字符串使唯一子字符串的数目最大](../../problems/split-a-string-into-the-max-number-of-unique-substrings) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 1592 | [重新排列单词间的空格](../../problems/rearrange-spaces-between-words) | [[字符串](../string/README.md)] | Easy | | 1585 | [检查字符串是否可以通过排序子字符串得到另一个字符串](../../problems/check-if-string-is-transformable-with-substring-sort-operations) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | -| 1578 | [避免重复字母的最小删除成本](../../problems/minimum-deletion-cost-to-avoid-repeating-letters) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 1578 | [使绳子变成彩色的最短时间](../../problems/minimum-time-to-make-rope-colorful) | [[贪心](../greedy/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1576 | [替换所有的问号](../../problems/replace-all-s-to-avoid-consecutive-repeating-characters) | [[字符串](../string/README.md)] | Easy | | 1573 | [分割字符串的方案数](../../problems/number-of-ways-to-split-a-string) | [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 1556 | [千位分隔数](../../problems/thousand-separator) | [[字符串](../string/README.md)] | Easy | @@ -133,7 +155,7 @@ | 1541 | [平衡括号字符串的最少插入次数](../../problems/minimum-insertions-to-balance-a-parentheses-string) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1540 | [K 次操作转变字符串](../../problems/can-convert-string-in-k-moves) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1531 | [压缩字符串 II](../../problems/string-compression-ii) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | -| 1529 | [灯泡开关 IV](../../problems/bulb-switcher-iv) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | +| 1529 | [最少的后缀翻转次数](../../problems/minimum-suffix-flips) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Medium | | 1528 | [重新排列字符串](../../problems/shuffle-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 1525 | [字符串的好分割数目](../../problems/number-of-good-ways-to-split-a-string) | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | | 1520 | [最多的不重叠子字符串](../../problems/maximum-number-of-non-overlapping-substrings) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] | Hard | @@ -147,6 +169,7 @@ | 1455 | [检查单词是否为句中其他单词的前缀](../../problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Easy | | 1452 | [收藏清单](../../problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1451 | [重新排列句子中的单词](../../problems/rearrange-words-in-a-sentence) | [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | +| 1447 | [最简分数](../../problems/simplified-fractions) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[数论](../number-theory/README.md)] | Medium | | 1446 | [连续字符](../../problems/consecutive-characters) | [[字符串](../string/README.md)] | Easy | | 1436 | [旅行终点站](../../problems/destination-city) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 1433 | [检查一个字符串是否可以打破另一个字符串](../../problems/check-if-a-string-can-break-another-string) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Medium | @@ -291,7 +314,7 @@ | 820 | [单词的压缩编码](../../problems/short-encoding-of-words) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 819 | [最常见的单词](../../problems/most-common-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 816 | [模糊坐标](../../problems/ambiguous-coordinates) | [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | -| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | +| 811 | [子域名访问计数](../../problems/subdomain-visit-count) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[计数](../counting/README.md)] | Medium | | 809 | [情感丰富的文字](../../problems/expressive-words) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 806 | [写字符串需要的行数](../../problems/number-of-lines-to-write-string) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Easy | | 804 | [唯一摩尔斯密码词](../../problems/unique-morse-code-words) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | @@ -311,14 +334,14 @@ | 758 | [字符串中的加粗单词](../../problems/bold-words-in-string) 🔒 | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[字符串匹配](../string-matching/README.md)] | Medium | | 752 | [打开转盘锁](../../problems/open-the-lock) | [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 751 | [IP 到 CIDR](../../problems/ip-to-cidr) 🔒 | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] | Medium | -| 748 | [最短补全词](../../problems/shortest-completing-word) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | +| 748 | [最短补全词](../../problems/shortest-completing-word) | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 745 | [前缀和后缀搜索](../../problems/prefix-and-suffix-search) | [[设计](../design/README.md)] [[字典树](../trie/README.md)] [[字符串](../string/README.md)] | Hard | | 737 | [句子相似性 II](../../problems/sentence-similarity-ii) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 736 | [Lisp 语法解析](../../problems/parse-lisp-expression) | [[栈](../stack/README.md)] [[递归](../recursion/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | | 734 | [句子相似性](../../problems/sentence-similarity) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | | 730 | [统计不同回文子序列](../../problems/count-different-palindromic-subsequences) | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 727 | [最小窗口子序列](../../problems/minimum-window-subsequence) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[滑动窗口](../sliding-window/README.md)] | Hard | -| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Hard | +| 726 | [原子的数量](../../problems/number-of-atoms) | [[栈](../stack/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Hard | | 722 | [删除注释](../../problems/remove-comments) | [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 721 | [账户合并](../../problems/accounts-merge) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | | 720 | [词典中最长的单词](../../problems/longest-word-in-dictionary) | [[字典树](../trie/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[排序](../sorting/README.md)] | Easy | @@ -392,7 +415,7 @@ | 424 | [替换后的最长重复字符](../../problems/longest-repeating-character-replacement) | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[滑动窗口](../sliding-window/README.md)] | Medium | | 423 | [从英文中重建数字](../../problems/reconstruct-original-digits-from-english) | [[哈希表](../hash-table/README.md)] [[数学](../math/README.md)] [[字符串](../string/README.md)] | Medium | | 420 | [强密码检验器](../../problems/strong-password-checker) | [[贪心](../greedy/README.md)] [[字符串](../string/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | -| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] | Medium | +| 418 | [屏幕可显示句子的数量](../../problems/sentence-screen-fitting) 🔒 | [[字符串](../string/README.md)] [[动态规划](../dynamic-programming/README.md)] [[模拟](../simulation/README.md)] | Medium | | 415 | [字符串相加](../../problems/add-strings) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 412 | [Fizz Buzz](../../problems/fizz-buzz) | [[数学](../math/README.md)] [[字符串](../string/README.md)] [[模拟](../simulation/README.md)] | Easy | | 411 | [最短独占单词缩写](../../problems/minimum-unique-word-abbreviation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Hard | @@ -430,7 +453,7 @@ | 269 | [火星词典](../../problems/alien-dictionary) 🔒 | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | | 267 | [回文排列 II](../../problems/palindrome-permutation-ii) 🔒 | [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] | Medium | | 266 | [回文排列](../../problems/palindrome-permutation) 🔒 | [[位运算](../bit-manipulation/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Easy | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 249 | [移位字符串分组](../../problems/group-shifted-strings) 🔒 | [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 248 | [中心对称数 III](../../problems/strobogrammatic-number-iii) 🔒 | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Hard | | 247 | [中心对称数 II](../../problems/strobogrammatic-number-ii) 🔒 | [[递归](../recursion/README.md)] [[数组](../array/README.md)] [[字符串](../string/README.md)] | Medium | diff --git a/tag/topological-sort/README.md b/tag/topological-sort/README.md index f3fc7304f..eddfb8658 100644 --- a/tag/topological-sort/README.md +++ b/tag/topological-sort/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2127 | [参加会议的最多员工数](../../problems/maximum-employees-to-be-invited-to-a-meeting) | [[深度优先搜索](../depth-first-search/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | +| 2115 | [从给定原材料中找到所有可以做出的菜](../../problems/find-all-possible-recipes-from-given-supplies) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 2050 | [并行课程 III](../../problems/parallel-courses-iii) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1976 | [到达目的地的方案数](../../problems/number-of-ways-to-arrive-at-destination) | [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[动态规划](../dynamic-programming/README.md)] [[最短路](../shortest-path/README.md)] | Medium | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | diff --git a/tag/tree/README.md b/tag/tree/README.md index a4f396b09..6db216719 100644 --- a/tag/tree/README.md +++ b/tag/tree/README.md @@ -9,12 +9,13 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2096 | [从二叉树一个节点到另一个节点每一步的方向](../../problems/step-by-step-directions-from-a-binary-tree-node-to-another) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2049 | [统计最高分的节点数目](../../problems/count-nodes-with-the-highest-score) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[数组](../array/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1993 | [树上的操作](../../problems/operations-on-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[设计](../design/README.md)] [[哈希表](../hash-table/README.md)] | Medium | | 1932 | [合并多棵二叉搜索树](../../problems/merge-bsts-to-create-single-bst) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | | 1916 | [统计为蚁群构筑房间的不同顺序](../../problems/count-ways-to-build-rooms-in-an-ant-colony) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] [[数学](../math/README.md)] [[动态规划](../dynamic-programming/README.md)] [[组合数学](../combinatorics/README.md)] | Hard | -| 1902 | [Depth of BST Given Insertion Order](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | +| 1902 | [给定二叉搜索树的插入顺序求深度](../../problems/depth-of-bst-given-insertion-order) 🔒 | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] [[有序集合](../ordered-set/README.md)] | Medium | | 1766 | [互质树](../../problems/tree-of-coprimes) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数学](../math/README.md)] | Hard | | 1740 | [找到二叉树中的距离](../../problems/find-distance-in-a-binary-tree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1719 | [重构一棵树的方案数](../../problems/number-of-ways-to-reconstruct-a-tree) | [[树](../tree/README.md)] [[图](../graph/README.md)] [[拓扑排序](../topological-sort/README.md)] | Hard | @@ -63,7 +64,7 @@ | 1257 | [最小公共区域](../../problems/smallest-common-region) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[字符串](../string/README.md)] | Medium | | 1245 | [树的直径](../../problems/tree-diameter) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] | Medium | | 1214 | [查找两棵二叉搜索树之和](../../problems/two-sum-bsts) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 1161 | [最大层内元素和](../../problems/maximum-level-sum-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1145 | [二叉树着色游戏](../../problems/binary-tree-coloring-game) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1123 | [最深叶节点的最近公共祖先](../../problems/lowest-common-ancestor-of-deepest-leaves) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[哈希表](../hash-table/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 1120 | [子树的最大平均值](../../problems/maximum-average-subtree) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -153,7 +154,7 @@ | 285 | [二叉搜索树中的中序后继](../../problems/inorder-successor-in-bst) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 272 | [最接近的二叉搜索树值 II](../../problems/closest-binary-search-tree-value-ii) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[双指针](../two-pointers/README.md)] [[二叉树](../binary-tree/README.md)] [[堆(优先队列)](../heap-priority-queue/README.md)] | Hard | | 270 | [最接近的二叉搜索树值](../../problems/closest-binary-search-tree-value) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[二分查找](../binary-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | -| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 257 | [二叉树的所有路径](../../problems/binary-tree-paths) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[字符串](../string/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 255 | [验证前序遍历序列二叉搜索树](../../problems/verify-preorder-sequence-in-binary-search-tree) 🔒 | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[递归](../recursion/README.md)] [[二叉树](../binary-tree/README.md)] [[单调栈](../monotonic-stack/README.md)] | Medium | | 250 | [统计同值子树](../../problems/count-univalue-subtrees) 🔒 | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 236 | [二叉树的最近公共祖先](../../problems/lowest-common-ancestor-of-a-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | @@ -168,11 +169,11 @@ | 144 | [二叉树的前序遍历](../../problems/binary-tree-preorder-traversal) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 129 | [求根节点到叶节点数字之和](../../problems/sum-root-to-leaf-numbers) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 124 | [二叉树中的最大路径和](../../problems/binary-tree-maximum-path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[二叉树](../binary-tree/README.md)] | Hard | -| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 117 | [填充每个节点的下一个右侧节点指针 II](../../problems/populating-next-right-pointers-in-each-node-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | +| 116 | [填充每个节点的下一个右侧节点指针](../../problems/populating-next-right-pointers-in-each-node) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 114 | [二叉树展开为链表](../../problems/flatten-binary-tree-to-linked-list) | [[栈](../stack/README.md)] [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[链表](../linked-list/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | | 113 | [路径总和 II](../../problems/path-sum-ii) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[回溯](../backtracking/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | -| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | +| 112 | [路径总和](../../problems/path-sum) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 111 | [二叉树的最小深度](../../problems/minimum-depth-of-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 110 | [平衡二叉树](../../problems/balanced-binary-tree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[二叉树](../binary-tree/README.md)] | Easy | | 109 | [有序链表转换二叉搜索树](../../problems/convert-sorted-list-to-binary-search-tree) | [[树](../tree/README.md)] [[二叉搜索树](../binary-search-tree/README.md)] [[链表](../linked-list/README.md)] [[分治](../divide-and-conquer/README.md)] [[二叉树](../binary-tree/README.md)] | Medium | diff --git a/tag/two-pointers/README.md b/tag/two-pointers/README.md index b676b857d..bb35f10de 100644 --- a/tag/two-pointers/README.md +++ b/tag/two-pointers/README.md @@ -9,7 +9,13 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | -| 2046 | [Sort Linked List Already Sorted Using Absolute Values](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | +| 2161 | [根据给定数字划分数组](../../problems/partition-array-according-to-given-pivot) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2149 | [按符号重排数组](../../problems/rearrange-array-elements-by-sign) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2130 | [链表最大孪生和](../../problems/maximum-twin-sum-of-a-linked-list) | [[栈](../stack/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2108 | [找出数组中的第一个回文字符串](../../problems/find-first-palindromic-string-in-the-array) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | +| 2105 | [给植物浇水 II](../../problems/watering-plants-ii) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[模拟](../simulation/README.md)] | Medium | +| 2095 | [删除链表的中间节点](../../problems/delete-the-middle-node-of-a-linked-list) | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Medium | +| 2046 | [给按照绝对值排序的链表排序](../../problems/sort-linked-list-already-sorted-using-absolute-values) 🔒 | [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] [[排序](../sorting/README.md)] | Medium | | 2035 | [将数组分成两个数组并最小化数组和的差](../../problems/partition-array-into-two-arrays-to-minimize-sum-difference) | [[位运算](../bit-manipulation/README.md)] [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] [[动态规划](../dynamic-programming/README.md)] [[状态压缩](../bitmask/README.md)] [[有序集合](../ordered-set/README.md)] | Hard | | 2000 | [反转单词前缀](../../problems/reverse-prefix-of-word) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Easy | | 1963 | [使字符串平衡的最小交换次数](../../problems/minimum-number-of-swaps-to-make-the-string-balanced) | [[栈](../stack/README.md)] [[贪心](../greedy/README.md)] [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | @@ -120,7 +126,7 @@ | 189 | [轮转数组](../../problems/rotate-array) | [[数组](../array/README.md)] [[数学](../math/README.md)] [[双指针](../two-pointers/README.md)] | Medium | | 186 | [翻转字符串里的单词 II](../../problems/reverse-words-in-a-string-ii) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 170 | [两数之和 III - 数据结构设计](../../problems/two-sum-iii-data-structure-design) 🔒 | [[设计](../design/README.md)] [[数组](../array/README.md)] [[哈希表](../hash-table/README.md)] [[双指针](../two-pointers/README.md)] [[数据流](../data-stream/README.md)] | Easy | -| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Easy | +| 167 | [两数之和 II - 输入有序数组](../../problems/two-sum-ii-input-array-is-sorted) | [[数组](../array/README.md)] [[双指针](../two-pointers/README.md)] [[二分查找](../binary-search/README.md)] | Medium | | 165 | [比较版本号](../../problems/compare-version-numbers) | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 161 | [相隔为 1 的编辑距离](../../problems/one-edit-distance) 🔒 | [[双指针](../two-pointers/README.md)] [[字符串](../string/README.md)] | Medium | | 160 | [相交链表](../../problems/intersection-of-two-linked-lists) | [[哈希表](../hash-table/README.md)] [[链表](../linked-list/README.md)] [[双指针](../two-pointers/README.md)] | Easy | diff --git a/tag/union-find/README.md b/tag/union-find/README.md index b13c5ebf0..7ac700ad6 100644 --- a/tag/union-find/README.md +++ b/tag/union-find/README.md @@ -9,6 +9,8 @@ | # | 题目 | 标签 | 难度 | | :-: | - | - | :-: | +| 2157 | [字符串分组](../../problems/groups-of-strings) | [[位运算](../bit-manipulation/README.md)] [[并查集](../union-find/README.md)] [[字符串](../string/README.md)] | Hard | +| 2092 | [找出知晓秘密的所有专家](../../problems/find-all-people-with-secret) | [[深度优先搜索](../depth-first-search/README.md)] [[广度优先搜索](../breadth-first-search/README.md)] [[并查集](../union-find/README.md)] [[图](../graph/README.md)] [[排序](../sorting/README.md)] | Hard | | 2076 | [处理含限制条件的好友请求](../../problems/process-restricted-friend-requests) | [[并查集](../union-find/README.md)] [[图](../graph/README.md)] | Hard | | 2003 | [每棵子树内缺失的最小基因值](../../problems/smallest-missing-genetic-value-in-each-subtree) | [[树](../tree/README.md)] [[深度优先搜索](../depth-first-search/README.md)] [[并查集](../union-find/README.md)] [[动态规划](../dynamic-programming/README.md)] | Hard | | 1998 | [数组的最大公因数排序](../../problems/gcd-sort-of-an-array) | [[并查集](../union-find/README.md)] [[数组](../array/README.md)] [[数学](../math/README.md)] [[排序](../sorting/README.md)] | Hard |